From 5676241748dbbec00eb2f5b51952c05b006a4c1c Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 14 Apr 2025 14:23:16 +0800 Subject: [PATCH 001/158] refactor(system): remove unused data initialization and update data structures - Remove unused data initialization code for departments, positions, roles, permissions, and users - Update data structures to use keywords instead of IDs for relationships - Modify UserNode to include RoleKeywords - Adjust PositionNode to use DepartmentKeyword - Update JSON files to use keyword-based relationships --- helpers/securityx/security.go | 1 - internal/mock/token_test.go | 33 +++ internal/mods/system/dal/dal.go | 12 +- internal/mods/system/dal/init.go | 299 ------------------------- internal/mods/system/dto/department.go | 6 + internal/mods/system/dto/permission.go | 5 + internal/mods/system/dto/position.go | 7 - internal/mods/system/dto/user.go | 3 +- resources/data/department.json | 3 + resources/data/permission.json | 20 +- resources/data/user.json | 4 +- 11 files changed, 62 insertions(+), 331 deletions(-) create mode 100644 internal/mock/token_test.go delete mode 100644 internal/mods/system/dal/init.go create mode 100644 internal/mods/system/dto/department.go diff --git a/helpers/securityx/security.go b/helpers/securityx/security.go index f2a3020e..5dc99dbf 100644 --- a/helpers/securityx/security.go +++ b/helpers/securityx/security.go @@ -157,7 +157,6 @@ func (obj SecurityBridge) aggregateTokenParsers(outer ...func(ctx context.Contex func (obj SecurityBridge) Build() middleware.KMiddleware { if obj.TokenParser == nil { obj.TokenParser = obj.aggregateTokenParsers( - //FromTransportClient(obj.AuthenticationHeader, obj.Scheme.String()), FromTransportServer(obj.AuthenticationHeader, obj.Scheme.String()), ) } diff --git a/internal/mock/token_test.go b/internal/mock/token_test.go new file mode 100644 index 00000000..8dae4af1 --- /dev/null +++ b/internal/mock/token_test.go @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package mock implements the functions, types, and interfaces for the module. +package mock + +import ( + "testing" + + "github.com/origadmin/runtime/bootstrap" + + "origadmin/application/admin/internal/loader" + "origadmin/application/admin/internal/mods/system/server" +) + +func GenerateTokenTest(t *testing.T) { + bs, err := loader.LoadBootstrap(&loader.Bootstrap{ + Flags: bootstrap.Flags{}, + WorkDir: "", + ConfigPath: "resources/configs/system", + Env: "", + Daemon: false, + }) + if err != nil { + t.Fatalf("failed to load bootstrap: %v", err) + } + v, err := server.NewSystemClient(bs, nil) + if err != nil { + t.Fatalf("failed to new system client: %v", err) + } + +} diff --git a/internal/mods/system/dal/dal.go b/internal/mods/system/dal/dal.go index 5df828bb..9c0d290e 100644 --- a/internal/mods/system/dal/dal.go +++ b/internal/mods/system/dal/dal.go @@ -93,17 +93,7 @@ func NewData(bootstrap *configs.Bootstrap, logger log.KLogger) (*Data, func(), e if cfg == nil { return nil, nil, errors.New("data source not found") } - //if cfg.Dialect == "sqlite3" { - // //cfg.Source = FixSource(cfg.GetSource()) - //} - //if cfg.Dialect == "mysql" { - // log.Infow("msg", "connecting to database", "dialect", cfg.Dialect, "source", cfg.Source) - // sourceConfig, err := mysql.ParseDSN(cfg.Source) - // if err != nil { - // return nil, nil, err - // } - // log.Infow("msg", "connecting to database", "dialect", cfg.Dialect, "source", sourceConfig.Addr) - //} + drv, err := database.Open(cfg) log.Infow("msg", "connecting to database", "dialect", cfg.Dialect, "source", cfg.Source) if err != nil { diff --git a/internal/mods/system/dal/init.go b/internal/mods/system/dal/init.go deleted file mode 100644 index 29fa4f6b..00000000 --- a/internal/mods/system/dal/init.go +++ /dev/null @@ -1,299 +0,0 @@ -package dal - -import ( - "context" - "encoding/json" - "fmt" - "os" - "path/filepath" - - "github.com/origadmin/toolkits/crypto/hash" - - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - _ "origadmin/application/admin/internal/mods/system/dal/entity/ent/runtime" -) - -// InitData 初始化所有数据 -func InitData(ctx context.Context, client *ent.Client) error { - // 按依赖顺序初始化 - initializers := []struct { - name string - fn func(context.Context, *ent.Client) error - }{ - {"department", initDepartments}, - {"position", initPositions}, - {"role", initRoles}, - {"resource", initResources}, - {"permission", initPermissions}, - {"user", initUsers}, - } - - for _, init := range initializers { - if err := init.fn(ctx, client); err != nil { - return fmt.Errorf("init %s: %w", init.name, err) - } - } - - return nil -} - -func initResources(ctx context.Context, client *ent.Client) error { - return loadJSON("resource.json", client.Resource) -} - -// loadJSON 通用的 JSON 加载函数 -func loadJSON(filename string, v interface{}) error { - path := filepath.Join("internal", "mods", "system", "dal", "entity", "ent", "schema", filename) - data, err := os.ReadFile(path) - if err != nil { - return fmt.Errorf("read file %s: %w", filename, err) - } - return json.Unmarshal(data, v) -} - -// DepartmentNode 部门树节点 -type DepartmentNode struct { - Keyword string `json:"keyword"` - Name string `json:"name"` - Sequence int `json:"sequence"` - Status int8 `json:"status"` - Level int `json:"level"` - Description string `json:"description"` - Children []DepartmentNode `json:"children"` -} - -// initDepartments 初始化部门数据 -func initDepartments(ctx context.Context, client *ent.Client) error { - var nodes []DepartmentNode - if err := loadJSON("department.json", &nodes); err != nil { - return err - } - - return createDepartmentTree(ctx, client, nodes, nil) -} - -// createDepartmentTree 递归创建部门树 -func createDepartmentTree(ctx context.Context, client *ent.Client, nodes []DepartmentNode, parent *ent.Department) error { - for _, node := range nodes { - // 检查部门是否已存在 - exists, err := client.Department.Query(). - Where(department.Keyword(node.Keyword)). - Exist(ctx) - if err != nil { - return err - } - if exists { - continue - } - - // 创建部门 - dept, err := client.Department.Create(). - SetKeyword(node.Keyword). - SetName(node.Name). - SetSequence(node.Sequence). - SetStatus(node.Status). - SetLevel(node.Level). - SetDescription(node.Description). - SetParent(parent). - Save(ctx) - if err != nil { - return err - } - - // 递归创建子部门 - if len(node.Children) > 0 { - if err := createDepartmentTree(ctx, client, node.Children, dept); err != nil { - return err - } - } - } - return nil -} - -// initPositions 初始化岗位数据 -func initPositions(ctx context.Context, client *ent.Client) error { - var positions []struct { - Name string `json:"name"` - Description string `json:"description"` - DepartmentID string `json:"department_id"` - } - if err := loadJSON("position.json", &positions); err != nil { - return err - } - - for _, pos := range positions { - // 查找对应部门 - dept, err := client.Department.Query(). - Where(department.Keyword(pos.DepartmentID)). - Only(ctx) - if err != nil { - return fmt.Errorf("find department %s: %w", pos.DepartmentID, err) - } - - // 创建岗位 - _, err = client.Position.Create(). - SetName(pos.Name). - SetDescription(pos.Description). - SetDepartment(dept). - Save(ctx) - if err != nil { - return fmt.Errorf("create position %s: %w", pos.Name, err) - } - } - return nil -} - -// initRoles 初始化角色数据 -func initRoles(ctx context.Context, client *ent.Client) error { - var roles []struct { - Keyword string `json:"keyword"` - Name string `json:"name"` - Type int `json:"type"` - Sequence int `json:"sequence"` - Status int8 `json:"status"` - IsSystem bool `json:"is_system"` - Description string `json:"description"` - } - if err := loadJSON("role.json", &roles); err != nil { - return err - } - - for _, role := range roles { - _, err := client.Role.Create(). - SetKeyword(role.Keyword). - SetName(role.Name). - SetType(int8(role.Type)). - SetSequence(role.Sequence). - SetStatus(role.Status). - SetDescription(role.Description). - Save(ctx) - if err != nil { - return fmt.Errorf("create role %s: %w", role.Name, err) - } - } - return nil -} - -// initPermissions 初始化权限数据 -func initPermissions(ctx context.Context, client *ent.Client) error { - var permissions []struct { - Name string `json:"name"` - Keyword string `json:"keyword"` - Type string `json:"type"` - Description string `json:"description"` - DataScope string `json:"data_scope"` - Resources []string `json:"resources"` - } - if err := loadJSON("permission.json", &permissions); err != nil { - return err - } - - for _, perm := range permissions { - // 创建权限 - p, err := client.Permission.Create(). - SetName(perm.Name). - SetKeyword(perm.Keyword). - //SetType(perm.Type). - SetDescription(perm.Description). - SetDataScope(perm.DataScope). - Save(ctx) - if err != nil { - return fmt.Errorf("create permission %s: %w", perm.Name, err) - } - - // 关联资源 - for _, resKey := range perm.Resources { - res, err := client.Resource.Query(). - Where(resource.Keyword(resKey)). - Only(ctx) - if err != nil { - return fmt.Errorf("find resource %s: %w", resKey, err) - } - if err := p.Update().AddResources(res).Exec(ctx); err != nil { - return fmt.Errorf("link resource %s to permission %s: %w", resKey, perm.Name, err) - } - } - } - return nil -} - -// initUsers 初始化用户数据 -func initUsers(ctx context.Context, client *ent.Client) error { - var users []struct { - Username string `json:"username"` - Nickname string `json:"nickname"` - Password string `json:"password"` - Email string `json:"email"` - Phone string `json:"phone"` - Status int8 `json:"status"` - Roles []string `json:"roles"` - Departments []string `json:"departments"` - Positions []string `json:"positions"` - } - if err := loadJSON("user.json", &users); err != nil { - return err - } - - for _, u := range users { - passwd, err := hash.Generate(u.Password) - if err != nil { - return err - } - // 创建用户 - user, err := client.User.Create(). - SetUsername(u.Username). - SetNickname(u.Nickname). - SetPassword(passwd). // 加密密码 - SetEmail(u.Email). - SetPhone(u.Phone). - SetStatus(u.Status). - Save(ctx) - if err != nil { - return fmt.Errorf("create user %s: %w", u.Username, err) - } - - // 关联角色 - for _, roleKey := range u.Roles { - role, err := client.Role.Query(). - Where(role.Keyword(roleKey)). - Only(ctx) - if err != nil { - return fmt.Errorf("find role %s: %w", roleKey, err) - } - if err := user.Update().AddRoles(role).Exec(ctx); err != nil { - return fmt.Errorf("link role %s to user %s: %w", roleKey, u.Username, err) - } - } - - // 关联部门 - for _, deptKey := range u.Departments { - dept, err := client.Department.Query(). - Where(department.Keyword(deptKey)). - Only(ctx) - if err != nil { - return fmt.Errorf("find department %s: %w", deptKey, err) - } - if err := user.Update().AddDepartments(dept).Exec(ctx); err != nil { - return fmt.Errorf("link department %s to user %s: %w", deptKey, u.Username, err) - } - } - - // 关联岗位 - for _, posName := range u.Positions { - pos, err := client.Position.Query(). - Where(position.Name(posName)). - Only(ctx) - if err != nil { - return fmt.Errorf("find position %s: %w", posName, err) - } - if err := user.Update().AddPositions(pos).Exec(ctx); err != nil { - return fmt.Errorf("link position %s to user %s: %w", posName, u.Username, err) - } - } - } - return nil -} diff --git a/internal/mods/system/dto/department.go b/internal/mods/system/dto/department.go new file mode 100644 index 00000000..0064eed0 --- /dev/null +++ b/internal/mods/system/dto/department.go @@ -0,0 +1,6 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto implements the functions, types, and interfaces for the module. +package dto diff --git a/internal/mods/system/dto/permission.go b/internal/mods/system/dto/permission.go index 7452a312..9453f4d0 100644 --- a/internal/mods/system/dto/permission.go +++ b/internal/mods/system/dto/permission.go @@ -19,6 +19,11 @@ type ( ListPermissionsResponse = pb.ListPermissionsResponse ) +type PermissionNode struct { + PermissionPB + ResourceKeywords []string `json:"resource_keywords"` +} + // PermissionRepo is a Permission repository interface. type PermissionRepo interface { Get(context.Context, int64, ...PermissionQueryOption) (*PermissionPB, error) diff --git a/internal/mods/system/dto/position.go b/internal/mods/system/dto/position.go index 5e42f79f..6d294141 100644 --- a/internal/mods/system/dto/position.go +++ b/internal/mods/system/dto/position.go @@ -8,12 +8,5 @@ package dto // PositionNode position.table.comment type PositionNode struct { PositionPB - //Id int64 `json:"id,omitempty"` - //CreateTime int64 `json:"create_time,omitempty"` - //UpdateTime int64 `json:"update_time,omitempty"` - //Name string `json:"name,omitempty"` - //Keyword string `json:"keyword,omitempty"` - //Description string `json:"description,omitempty"` - //DepartmentId int64 `json:"department_id,omitempty"` DepartmentKeyword string `json:"department_keyword,omitempty"` } diff --git a/internal/mods/system/dto/user.go b/internal/mods/system/dto/user.go index 509b761e..03540500 100644 --- a/internal/mods/system/dto/user.go +++ b/internal/mods/system/dto/user.go @@ -32,7 +32,8 @@ type ( type UserNode struct { UserPB - IsSystem bool `json:"is_system"` + IsSystem bool `json:"is_system"` + RoleKeywords []string `json:"role_keywords"` } // UserRepo is a UserPB repository interface. diff --git a/resources/data/department.json b/resources/data/department.json index 130f7f1d..4efedcff 100644 --- a/resources/data/department.json +++ b/resources/data/department.json @@ -6,6 +6,9 @@ "status": 1, "level": 1, "description": "顶级部门", + "position_keywords": [ + "tech" + ], "children": [ { "keyword": "tech", diff --git a/resources/data/permission.json b/resources/data/permission.json index 613e7596..0de0dda8 100644 --- a/resources/data/permission.json +++ b/resources/data/permission.json @@ -5,7 +5,7 @@ "type": "role", "description": "系统管理权限", "data_scope": "all", - "resources": [ + "resource_keywords": [ "system" ] }, @@ -15,7 +15,7 @@ "type": "role", "description": "组织管理权限", "data_scope": "dept", - "resources": [ + "resource_keywords": [ "system:org", "system:org:dept", "system:org:dept:list", @@ -29,7 +29,7 @@ "type": "role", "description": "用户管理权限", "data_scope": "dept", - "resources": [ + "resource_keywords": [ "system:user", "system:user:list" ] @@ -40,7 +40,7 @@ "type": "position", "description": "部门管理权限", "data_scope": "dept", - "resources": [ + "resource_keywords": [ "system:org:dept:list", "system:org:dept:add", "system:org:dept:edit" @@ -52,7 +52,7 @@ "type": "role", "description": "资源管理权限", "data_scope": "all", - "resources": [ + "resource_keywords": [ "system:resource", "system:resource:list", "system:resource:add", @@ -66,7 +66,7 @@ "type": "role", "description": "访问日志管理权限", "data_scope": "all", - "resources": [ + "resource_keywords": [ "logs:access", "logs:access:list" ] @@ -77,7 +77,7 @@ "type": "role", "description": "登录日志管理权限", "data_scope": "all", - "resources": [ + "resource_keywords": [ "logs:login", "logs:login:list" ] @@ -88,7 +88,7 @@ "type": "role", "description": "修改日志管理权限", "data_scope": "all", - "resources": [ + "resource_keywords": [ "logs:modify", "logs:modify:list" ] @@ -99,7 +99,7 @@ "type": "role", "description": "审计日志管理权限", "data_scope": "all", - "resources": [ + "resource_keywords": [ "logs:audit", "logs:audit:list" ] @@ -110,7 +110,7 @@ "type": "role", "description": "删除日志权限", "data_scope": "all", - "resources": [ + "resource_keywords": [ "logs:delete" ] } diff --git a/resources/data/user.json b/resources/data/user.json index edec09c2..aa9254c3 100644 --- a/resources/data/user.json +++ b/resources/data/user.json @@ -6,7 +6,7 @@ "email": "admin@example.com", "phone": "13800138000", "status": 1, - "roles": ["super_admin"], + "role_keywords": ["super_admin"], "department": "总公司", "department_keywords": ["root"], "is_system": true @@ -18,7 +18,7 @@ "email": "test@example.com", "phone": "13800138001", "status": 1, - "roles": ["user"], + "role_keywords": ["user"], "department": "技术部", "department_keywords": ["dev"] } From 120c47b93248ff834e1963b4626ee738f8cf19cf Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 14 Apr 2025 14:35:55 +0800 Subject: [PATCH 002/158] refactor(system): introduce DepartmentNode struct for hierarchical department data - Add DepartmentNode struct to dto package, extending DepartmentPB with Children and PositionKeywords fields - Update Data.createDepartmentBatch method to use DepartmentNode instead of DepartmentPB - Modify department decoding from file to use the new DepartmentNode struct --- internal/mods/system/dal/dal.go | 9 +++++---- internal/mods/system/dto/department.go | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/mods/system/dal/dal.go b/internal/mods/system/dal/dal.go index 9c0d290e..846874aa 100644 --- a/internal/mods/system/dal/dal.go +++ b/internal/mods/system/dal/dal.go @@ -415,7 +415,7 @@ func (obj *Data) InitDepartmentFromFile(ctx context.Context, filename string) er if err != nil { return err } - var departments []*dto.DepartmentPB + var departments []*dto.DepartmentNode err = codec.DecodeFromFile(abs, &departments) if err != nil { if errors.Is(err, os.ErrNotExist) { @@ -429,7 +429,7 @@ func (obj *Data) InitDepartmentFromFile(ctx context.Context, filename string) er }) } -func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.DepartmentPB, parent *dto.DepartmentPB) error { +func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.DepartmentNode, parent *dto.DepartmentPB) error { total := len(departments) log.Infow("msg", "Starting createDepartmentBatch", "totalItems", total) for i, item := range departments { @@ -443,7 +443,8 @@ func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.D item.TreePath = parent.TreePath + strconv.Itoa(int(parent.Id)) + TreePathDelimiter } - if _, err := obj.Department(ctx).Create().SetDepartment(dto.ConvertDepartmentPB2Object(item)).Save(ctx); err != nil { + if _, err := obj.Department(ctx).Create().SetDepartment(dto.ConvertDepartmentPB2Object(&item.DepartmentPB)). + Save(ctx); err != nil { log.Errorw("msg", "Error creating department item", "itemId", item.Id, "error", err) return err } @@ -451,7 +452,7 @@ func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.D log.Infow("msg", "Department item created successfully", "itemId", item.Id) if len(item.Children) != 0 { log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) - if err := obj.createDepartmentBatch(ctx, item.Children, item); err != nil { + if err := obj.createDepartmentBatch(ctx, item.Children, &item.DepartmentPB); err != nil { log.Errorw("Error processing children", "itemId", item.Id, "error", err) return err } diff --git a/internal/mods/system/dto/department.go b/internal/mods/system/dto/department.go index 0064eed0..1e1fad52 100644 --- a/internal/mods/system/dto/department.go +++ b/internal/mods/system/dto/department.go @@ -4,3 +4,9 @@ // Package dto implements the functions, types, and interfaces for the module. package dto + +type DepartmentNode struct { + DepartmentPB + Children []*DepartmentNode `json:"children"` + PositionKeywords []string `json:"position_keywords"` +} From 7320a1d3ca1e653253dd0f3a73a46f614d2dd123 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 14 Apr 2025 14:41:40 +0800 Subject: [PATCH 003/158] refactor(system): introduce ResourceNode type for hierarchical resource representation - Add ResourceNode type to represent resources with children - Update resource decoding and creation logic to use ResourceNode - Modify createResourceBatchWithParent function to accept ResourceNode - Adjust Department and Permission related functions for consistency --- internal/mods/system/dal/dal.go | 19 +++++++++++-------- internal/mods/system/dto/resource.go | 5 +++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/internal/mods/system/dal/dal.go b/internal/mods/system/dal/dal.go index 846874aa..dfd7fd31 100644 --- a/internal/mods/system/dal/dal.go +++ b/internal/mods/system/dal/dal.go @@ -194,7 +194,7 @@ func (obj *Data) InitResourceFromFile(ctx context.Context, filename string) erro if err != nil { return err } - var resources []*dto.ResourcePB + var resources []*dto.ResourceNode err = codec.DecodeFromFile(abs, &resources) if err != nil { if errors.Is(err, os.ErrNotExist) { @@ -216,7 +216,7 @@ func (obj *Data) InitResourceFromFile(ctx context.Context, filename string) erro }) } -func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto.ResourcePB, parent *dto.ResourcePB) error { +func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto.ResourceNode, parent *dto.ResourcePB) error { total := len(items) log.Infow("msg", "Starting createResourceBatchWithParent", "totalItems", total) @@ -309,7 +309,7 @@ func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto item.TreePath = parent.TreePath + strconv.Itoa(int(pid)) + TreePathDelimiter log.Infow("msg", "Setting parent path for item", "itemId", item.Id, "treePath", item.TreePath) } - itemObj := dto.ConvertResourcePB2Object(item) + itemObj := dto.ConvertResourcePB2Object(&item.ResourcePB) itemObj.UpdateTime = time.Now() itemObj.CreateTime = time.Now() if _, err := obj.Resource(ctx).Create().SetResource(itemObj).Save(ctx); err != nil { @@ -321,7 +321,7 @@ func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto if len(item.Children) != 0 { log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) - if err := obj.createResourceBatchWithParent(ctx, item.Children, item); err != nil { + if err := obj.createResourceBatchWithParent(ctx, item.Children, &item.ResourcePB); err != nil { log.Errorw("Error processing children", "itemId", item.Id, "error", err) return err } @@ -443,7 +443,8 @@ func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.D item.TreePath = parent.TreePath + strconv.Itoa(int(parent.Id)) + TreePathDelimiter } - if _, err := obj.Department(ctx).Create().SetDepartment(dto.ConvertDepartmentPB2Object(&item.DepartmentPB)). + if _, err := obj.Department(ctx).Create(). + SetDepartment(dto.ConvertDepartmentPB2Object(&item.DepartmentPB)). Save(ctx); err != nil { log.Errorw("msg", "Error creating department item", "itemId", item.Id, "error", err) return err @@ -519,7 +520,7 @@ func (obj *Data) InitPermissionFromFile(ctx context.Context, filename string) er if err != nil { return err } - var permissions []*dto.PermissionPB + var permissions []*dto.PermissionNode err = codec.DecodeFromFile(abs, &permissions) if err != nil { if errors.Is(err, os.ErrNotExist) { @@ -533,7 +534,7 @@ func (obj *Data) InitPermissionFromFile(ctx context.Context, filename string) er }) } -func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.PermissionPB) error { +func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.PermissionNode) error { total := len(permissions) log.Infow("msg", "Starting createPermissionBatch", "totalItems", total) for i, item := range permissions { @@ -542,7 +543,9 @@ func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.P item.Id = id.Gen() log.Infow("msg", "Generated new ID for item", "itemId", item.Id) } - if _, err := obj.Permission(ctx).Create().SetPermission(dto.ConvertPermissionPB2Object(item)).Save(ctx); err != nil { + if _, err := obj.Permission(ctx).Create(). + SetPermission(dto.ConvertPermissionPB2Object(&item.PermissionPB)). + Save(ctx); err != nil { log.Errorw("msg", "Error creating permission item", "itemId", item.Id, "error", err) return err } diff --git a/internal/mods/system/dto/resource.go b/internal/mods/system/dto/resource.go index c15d4714..54ff3528 100644 --- a/internal/mods/system/dto/resource.go +++ b/internal/mods/system/dto/resource.go @@ -19,6 +19,11 @@ type ( ListResourcesResponse = pb.ListResourcesResponse ) +type ResourceNode struct { + ResourcePB + Children []*ResourceNode `json:"children"` +} + // ResourceRepo is a Resource repository interface. type ResourceRepo interface { Get(context.Context, int64, ...ResourceQueryOption) (*ResourcePB, error) From d7d35f71b75a3950cb6ae2a0983a0cf43642e696 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 14 Apr 2025 22:02:15 +0800 Subject: [PATCH 004/158] test(security): implement role-based access control using Casbin - Add domain parameter to Enforce method - Print existing policies - Check for grouping policy - Implement authentication and authorization using Casbin - Add tests for token generation and authorization --- contrib/security/authz/casbin/casbin.go | 37 +++++- internal/mock/token_test.go | 130 ++++++++++++++++++- internal/mods/system/dal/auth.dal.go | 7 +- internal/mods/system/service/casbin.authz.go | 6 +- 4 files changed, 174 insertions(+), 6 deletions(-) diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index 438c8e0b..d5b7a57b 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -5,6 +5,7 @@ package casbin import ( + "fmt" "io" "time" @@ -80,13 +81,46 @@ func (auth *Authorizer) Authorized(ctx context.Context, policy security.Policy, if action == "" { action = policy.GetAction() } - if allowed, err = auth.enforcer.Enforce(policy.GetSubject(), object, action); err != nil { + domain := cmp.Or(policy.GetDomain(), auth.wildcardItem) + if domain == "" { + domain = "*" + } + if allowed, err = auth.enforcer.Enforce(policy.GetSubject(), object, action, domain); err != nil { log.Errorf("Authorization failed with error: %v", err) return false, err } else if allowed { log.Debugf("Authorization successful for user with adapter: %+v", policy) return true, nil } + ps, err := auth.enforcer.GetPolicy() + if err != nil { + return false, err + } + for _, p := range ps { + fmt.Printf("Existing policy: %v\n", p) + } + //hasPolicy, err := auth.enforcer.HasPolicy(policy.GetSubject(), object, action, domain) + //if err != nil { + // return false, err + //} + //if hasPolicy { + // log.Debugf("hasPolicy for user with adapter: %+v", policy) + // return false, nil + //} + + hasGroupingPolicy, err := auth.enforcer.HasGroupingPolicy( + policy.GetSubject(), + "role_4", + "*", + ) + if err != nil { + return false, err + } + if hasGroupingPolicy { + log.Debugf("hasGroupingPolicy for user with adapter: %+v", policy) + return false, nil + } + log.Debugf("Authorization failed for user with adapter: %+v", policy) return false, nil } @@ -325,6 +359,7 @@ func NewAuthorizer(cfg *configv1.Security, ss ...Setting) (security.Authorizer, if err != nil { return nil, err } + auth.SyncPolicy(context.TODO()) go auth.WatchUpdate() return auth, nil } diff --git a/internal/mock/token_test.go b/internal/mock/token_test.go index 8dae4af1..f55003eb 100644 --- a/internal/mock/token_test.go +++ b/internal/mock/token_test.go @@ -6,28 +6,152 @@ package mock import ( + "context" "testing" + _ "github.com/origadmin/contrib/consul/config" + _ "github.com/origadmin/contrib/consul/registry" + _ "github.com/origadmin/contrib/database" + msecurity "github.com/origadmin/runtime/agent/middleware/security" "github.com/origadmin/runtime/bootstrap" + "github.com/origadmin/toolkits/security" + "origadmin/application/admin/contrib/security/authz/casbin" + "origadmin/application/admin/helpers/securityx" "origadmin/application/admin/internal/loader" + "origadmin/application/admin/internal/mods/system/dal" "origadmin/application/admin/internal/mods/system/server" ) -func GenerateTokenTest(t *testing.T) { +type data struct { +} + +func (d data) QueryRoles(ctx context.Context, subject string) ([]string, error) { + return []string{ + "role_1", + }, nil +} + +func (d data) QueryPermissions(ctx context.Context, subject string) ([]string, error) { + return []string{ + "user_1", + }, nil +} + +func TestGenerateToken(t *testing.T) { bs, err := loader.LoadBootstrap(&loader.Bootstrap{ Flags: bootstrap.Flags{}, WorkDir: "", - ConfigPath: "resources/configs/system", + ConfigPath: "D:\\workspace\\project\\golang\\origadmin\\backend\\resources\\configs\\config_test.toml", Env: "", Daemon: false, }) if err != nil { t.Fatalf("failed to load bootstrap: %v", err) } + dd, cleanup, err := dal.NewData(bs, nil) + if err != nil { + t.Fatalf("failed to new dd: %v", err) + } + defer cleanup() + //casbinRepo, err := dal.NewCasbinSourceRepo(dd) + //if err != nil { + // t.Fatalf("failed to new casbin source repo: %v", err) + //} + resourceRepo := dal.NewResourceRepo(dd, nil) + roleRepo := dal.NewRoleRepo(dd, nil) + userRepo := dal.NewUserRepo(dd, nil) + basisConfig := loader.NewBasisConfig(bs) + //v, err := server.NewSystemClient(bs, nil) + //if err != nil { + // t.Fatalf("failed to new system client: %v", err) + //} + //auth := system.NewAuthServiceClient(v) + tokenizer, err := loader.NewTokenizer(bs) + if err != nil { + t.Fatalf("failed to new tokenizer: %v", err) + } + refreshTokenizer := dal.RefreshTokenizer(tokenizer) + loginData := &dal.LoginData{ + BasisConfig: basisConfig, + Tokenizer: refreshTokenizer, + Resource: resourceRepo, + Role: roleRepo, + User: userRepo, + } + claims, err := loginData.Tokenizer.CreateClaims(t.Context(), "user_1") + if err != nil { + return + } + token, err := loginData.Tokenizer.CreateToken(t.Context(), claims) + if err != nil { + t.Fatalf("failed to create token: %v", err) + } + t.Logf("token: %s", token) + v, err := server.NewSystemClient(bs, nil) if err != nil { t.Fatalf("failed to new system client: %v", err) } - + //registerAgent, err := server.NewSystemServiceAgentClient(v, nil) + //if err != nil { + // t.Fatalf("failed to new system service agent client: %v", err) + //} + //_ := agent.NewRegisterAgent(registerAgent) + casbinSourceServiceClient := server.NewCasbinServiceClient(v, nil) + //casbinBiz := biz.NewCasbinSourceServiceBiz(casbinRepo, nil) + //client := service.NewCasbinSourceServiceServerPB(casbinBiz) + authenticator, err := securityx.NewAuthenticator(bs) + if err != nil { + panic(err) + } + adapter := casbin.NewAdapter() + authorizer, err := securityx.NewAuthorizer(bs, casbin.WithPolicyAdapter(adapter), casbin.WithServiceClient(casbinSourceServiceClient)) + if err != nil { + panic(err) + } + bridge := securityx.SecurityBridge{ + TokenSource: security.TokenSourceHeader, + Scheme: security.SchemeBearer, + AuthenticationHeader: security.HeaderAuthorize, + Authenticator: authenticator, + Authorizer: authorizer, + SkipKey: msecurity.MetadataSecuritySkipKey, + PublicPaths: nil, + Provider: &data{}, + Skipper: func(path string) bool { + return false + }, + IsRoot: func(ctx context.Context, claims security.Claims) bool { + return claims.GetSubject() == "root" || claims.GetSubject() == "admin" + }, + TokenParser: nil, + PolicyParser: func(ctx context.Context, claims security.Claims) (security.Policy, error) { + return security.RegisteredPolicy{ + Subject: "user_1", + Object: "/api/v1/sys/users", + Action: "GET", + Domain: "*", + //Roles: roles, + //Permissions: permissions, + }, nil + }, + } + ctx := context.Background() + claims2, err := bridge.Authenticator.Authenticate(ctx, token) + if err != nil { + t.Fatalf("failed to authenticate: %v", err) + } + policy, err := bridge.PolicyParser(ctx, claims2) + if err != nil { + t.Fatalf("failed to parse policy: %v", err) + } + authorized, err := bridge.Authorizer.Authorized(context.Background(), policy, "", "") + if err != nil { + t.Errorf("failed to authorize: %v", err) + } + if !authorized { + t.Errorf("failed to authorize: %v", err) + } + t.Logf("authorized: %v", authorized) } diff --git a/internal/mods/system/dal/auth.dal.go b/internal/mods/system/dal/auth.dal.go index 212c66de..8f5c0435 100644 --- a/internal/mods/system/dal/auth.dal.go +++ b/internal/mods/system/dal/auth.dal.go @@ -14,6 +14,7 @@ import ( pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dal/entity/ent" + _ "origadmin/application/admin/internal/mods/system/dal/entity/ent/runtime" "origadmin/application/admin/internal/mods/system/dto" ) @@ -63,7 +64,11 @@ func (repo authRepo) Authenticate(ctx context.Context, request *pb.AuthenticateR if err != nil { return nil, err } - authorized, err := repo.Authorizer.Authorized(ctx, fromClaims(claims, "", ""), request.GetData().GetMethod(), request.GetData().GetPath()) + authorized, err := repo.Authorizer.Authorized( + ctx, + fromClaims(claims, "", ""), + request.GetData().GetMethod(), + request.GetData().GetPath()) if err != nil { return nil, err } diff --git a/internal/mods/system/service/casbin.authz.go b/internal/mods/system/service/casbin.authz.go index 7a8ee5bd..2fee3825 100644 --- a/internal/mods/system/service/casbin.authz.go +++ b/internal/mods/system/service/casbin.authz.go @@ -81,7 +81,11 @@ func (s *CasbinAuthorizerService) Authorized(ctx context.Context, policy securit if action == "" { action = policy.GetAction() } - if allowed, err = s.enforcer.Enforce(policy.GetSubject(), object, action); err != nil { + domain := policy.GetDomain() + if domain == "" { + domain = "*" + } + if allowed, err = s.enforcer.Enforce(policy.GetSubject(), object, action, domain); err != nil { log.Errorf("Authorization failed with error: %v", err) return false, err } else if allowed { From f25f206a59c1d3def995810edf9fe4b89f0d3c7f Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 15 Apr 2025 19:35:27 +0800 Subject: [PATCH 005/158] feat(authz): implement PBWatcher and optimize casbin adapter - Add PBWatcher struct and implement Watcher interface - Refactor casbin adapter to use new PolicySetter interface - Update authorizer to use new watcher and adapter - Improve error handling and retry logic in watcher - Simplify policy parsing and authorization logic --- ... build origadmin_application_admin.run.xml | 12 ++ ...admin_application_admin_cmd_system.run.xml | 12 ++ contrib/security/authz/casbin/adapter.go | 12 +- contrib/security/authz/casbin/casbin.go | 126 ++++--------- contrib/security/authz/casbin/option.go | 46 ++--- contrib/security/authz/casbin/pbwatcher.go | 168 ++++++++++++++++++ helpers/securityx/security.go | 2 +- internal/mock/token_test.go | 47 ++--- internal/mods/system/dal/casbin.dal.go | 3 + internal/mods/system/service/casbin.authz.go | 17 +- internal/mods/system/service/casbin.http.go | 17 ++ 11 files changed, 298 insertions(+), 164 deletions(-) create mode 100644 .run/go build origadmin_application_admin.run.xml create mode 100644 .run/go build origadmin_application_admin_cmd_system.run.xml create mode 100644 contrib/security/authz/casbin/pbwatcher.go diff --git a/.run/go build origadmin_application_admin.run.xml b/.run/go build origadmin_application_admin.run.xml new file mode 100644 index 00000000..61937aa2 --- /dev/null +++ b/.run/go build origadmin_application_admin.run.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.run/go build origadmin_application_admin_cmd_system.run.xml b/.run/go build origadmin_application_admin_cmd_system.run.xml new file mode 100644 index 00000000..2f0671b6 --- /dev/null +++ b/.run/go build origadmin_application_admin_cmd_system.run.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/contrib/security/authz/casbin/adapter.go b/contrib/security/authz/casbin/adapter.go index bcfb5fec..a1b3b809 100644 --- a/contrib/security/authz/casbin/adapter.go +++ b/contrib/security/authz/casbin/adapter.go @@ -12,6 +12,10 @@ import ( "github.com/casbin/casbin/v2/persist" ) +type PolicySetter interface { + SetPolicies(policies map[string][][]string) +} + type adapter struct { typedPolicies map[string][][]string } @@ -137,12 +141,10 @@ func (a *adapter) SetPolicies(policies map[string][][]string) { a.typedPolicies = policies } -func NewAdapter() persist.Adapter { - return &adapter{ - typedPolicies: make(map[string][][]string), +func NewAdapter(policies map[string][][]string) persist.Adapter { + if policies == nil { + policies = make(map[string][][]string) } -} -func NewAdapterWithPolicies(policies map[string][][]string) persist.Adapter { return &adapter{ typedPolicies: policies, } diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index d5b7a57b..0d1364f8 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -5,12 +5,12 @@ package casbin import ( - "fmt" "io" "time" "github.com/casbin/casbin/v2" casbinmodel "github.com/casbin/casbin/v2/model" + "github.com/casbin/casbin/v2/persist" "github.com/goexts/generic/cmp" "github.com/goexts/generic/maps" "github.com/goexts/generic/settings" @@ -34,6 +34,8 @@ type Authorizer struct { lastModified int64 interval int64 wildcardItem string + model casbinmodel.Model + adapter persist.Adapter } const MaxRetryDelay = time.Minute @@ -75,16 +77,10 @@ func (auth *Authorizer) Authorized(ctx context.Context, policy security.Policy, log.Debugf("Authorizing user with adapter: %+v", policy) var err error var allowed bool - if object == "" { - object = policy.GetObject() - } - if action == "" { - action = policy.GetAction() - } - domain := cmp.Or(policy.GetDomain(), auth.wildcardItem) - if domain == "" { - domain = "*" - } + var domain string + domain = cmp.Or(policy.GetDomain(), auth.wildcardItem) + object = cmp.Or(object, policy.GetObject()) + action = cmp.Or(action, policy.GetAction()) if allowed, err = auth.enforcer.Enforce(policy.GetSubject(), object, action, domain); err != nil { log.Errorf("Authorization failed with error: %v", err) return false, err @@ -92,36 +88,6 @@ func (auth *Authorizer) Authorized(ctx context.Context, policy security.Policy, log.Debugf("Authorization successful for user with adapter: %+v", policy) return true, nil } - ps, err := auth.enforcer.GetPolicy() - if err != nil { - return false, err - } - for _, p := range ps { - fmt.Printf("Existing policy: %v\n", p) - } - //hasPolicy, err := auth.enforcer.HasPolicy(policy.GetSubject(), object, action, domain) - //if err != nil { - // return false, err - //} - //if hasPolicy { - // log.Debugf("hasPolicy for user with adapter: %+v", policy) - // return false, nil - //} - - hasGroupingPolicy, err := auth.enforcer.HasGroupingPolicy( - policy.GetSubject(), - "role_4", - "*", - ) - if err != nil { - return false, err - } - if hasGroupingPolicy { - log.Debugf("hasGroupingPolicy for user with adapter: %+v", policy) - return false, nil - } - - log.Debugf("Authorization failed for user with adapter: %+v", policy) return false, nil } @@ -146,7 +112,7 @@ func (auth *Authorizer) AuthorizedWithExtra(ctx context.Context, data security.E log.Debugf("Authorizing user with extra data: %+v", data) policy, ok := data.GetPolicy() if !ok { - return false, errors.New("adapter is empty") + return false, errors.New("policy is empty") } if allowed, err := auth.enforcer.Enforce(policy.GetSubject(), policy.GetObject(), policy.GetAction(), policy.GetDomain()); err != nil { log.Errorf("Authorization failed with error: %v", err) @@ -167,9 +133,8 @@ func (auth *Authorizer) SetPolicies(ctx context.Context, policies map[string]any return k, [][]string{}, false }) - adapter := NewAdapterWithPolicies(p) + adapter := NewAdapter(p) auth.enforcer.SetAdapter(adapter) - //err := auth.enforcer.LoadPolicy() err := auth.options.Watcher.Update() if err != nil { return errors.Wrap(err, "failed to load adapter") @@ -216,55 +181,23 @@ func (auth *Authorizer) SyncPolicy(ctx context.Context) error { } if pLen > 0 { auth.lastModified = time.Now().Unix() - if setter, ok := auth.options.Adapter.(interface { - SetPolicies(policies map[string][][]string) - }); ok { - log.Infof("Setting policies...") + if setter, ok := auth.options.Adapter.(PolicySetter); ok { + log.Infof("AuthorizerOption policies...") setter.SetPolicies(policies) } - //err := auth.options.Watcher.Update() - //if err != nil { - // policySyncCounter.WithLabelValues("failed").Inc() - // return err - //} - //for ptype, policy := range policies { - // switch ptype { - // case "p": - // log.Debugf("Updating %d policies", len(policy)) - // added, err := auth.enforcer.AddPolicies(policy) - // if err != nil { - // log.Warnf("Failed to add policies: %v", err) - // return err - // } - // log.Debugf("Added %b policies", added) - // case "g": - // log.Debugf("Updating %d groupings", len(policy)) - // added, err := auth.enforcer.AddGroupingPolicies(policy) - // if err != nil { - // log.Warnf("Failed to add groupings: %v", err) - // return err - // } - // log.Debugf("Added %b groupings", added) - // } - // - //} err := auth.enforcer.LoadPolicy() if err != nil { log.Warnf("Failed to load policy: %v", err) return err } - policies, err := auth.enforcer.GetPolicy() - if err != nil { - log.Warnf("Failed to get policy: %v", err) - return err - } - //for _, policy := range policies { - // log.Debugf("Updated policy: %+v", policy) + //policies, err := auth.enforcer.GetPolicy() + //if err != nil { + // log.Warnf("Failed to get policy: %v", err) + // return err //} - log.Infof("Updated %d policies", len(policies)) + //log.Infof("Updated %d policies", len(policies)) policyCountGauge.Set(float64(pLen)) policySyncCounter.WithLabelValues("success").Inc() - //auth.enforcer.update } return nil @@ -301,9 +234,6 @@ func (auth *Authorizer) WatchUpdate() { lastDate := response.ModifiedDate if lastDate > auth.lastModified || auth.lastModified == 0 { log.Infof("Update detected, last modified: %v", lastDate) - //auth.lastModified = lastDate - //_ = auth.watcher.Update() - //auth.enforcer go auth.SyncPolicy(ctx) continue } @@ -316,7 +246,7 @@ func (auth *Authorizer) WatchUpdate() { func (auth *Authorizer) Apply() error { if auth.options.Adapter == nil { - return errors.New("adapter adapter is nil") + auth.options.Adapter = NewAdapter(nil) } if auth.options.Model == nil { auth.options.Model, _ = casbinmodel.NewModelFromString(DefaultModel()) @@ -324,13 +254,18 @@ func (auth *Authorizer) Apply() error { if auth.options.Watcher == nil { auth.options.Watcher = NewWatcher() } - if auth.options.Adapter == nil { - auth.options.Adapter = NewAdapter() - } return nil } -func NewAuthorizer(cfg *configv1.Security, ss ...Setting) (security.Authorizer, error) { +func NewDefaultAuthorizer() *Authorizer { + model, _ := casbinmodel.NewModelFromString(DefaultModel()) + return &Authorizer{ + model: model, + adapter: NewAdapter(nil), + } +} + +func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Authorizer, error) { config := cfg.GetAuthz().GetCasbin() if config == nil { return nil, errors.New("authorizer casbin config is empty") @@ -340,13 +275,16 @@ func NewAuthorizer(cfg *configv1.Security, ss ...Setting) (security.Authorizer, ss = append(ss, WithFileModel(config.ModelFile)) } options := settings.Apply(&AuthorizerOptions{ - Interval: 5, - RetryDelay: 3, + Model: casbinmodel.NewModel(), + Watcher: NewWatcher(), + SyncInterval: 5 * time.Second, }, ss) + if options.Model == nil || options.Adapter == nil { + return nil, errors.New("model and adapter are required") + } auth := &Authorizer{ interval: 5, options: options, - client: options.ServiceCli, } if err := auth.Apply(); err != nil { return nil, err diff --git a/contrib/security/authz/casbin/option.go b/contrib/security/authz/casbin/option.go index fa21b7b4..53bb07b8 100644 --- a/contrib/security/authz/casbin/option.go +++ b/contrib/security/authz/casbin/option.go @@ -5,72 +5,74 @@ package casbin import ( + "time" + + "github.com/casbin/casbin/v2" casbinmodel "github.com/casbin/casbin/v2/model" "github.com/casbin/casbin/v2/persist" - pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/contrib/security/authz/casbin/internal/model" - "origadmin/application/admin/contrib/security/authz/casbin/internal/policy" ) type AuthorizerOptions struct { - Model casbinmodel.Model - Adapter persist.Adapter - Watcher persist.Watcher - ServiceCli pb.CasbinSourceServiceClient - Interval int - RetryDelay int + Model casbinmodel.Model // Need + Adapter persist.Adapter // Need + Watcher persist.Watcher // Optional + Enforcer *casbin.SyncedEnforcer // Optional + SyncInterval time.Duration // Optional(Replace Interval/RetryDelay) } -// Setting is a function type for setting the Authenticator. -type Setting = func(*AuthorizerOptions) +// AuthorizerOption is a function type for setting the Authenticator. +type AuthorizerOption = func(*AuthorizerOptions) func DefaultModel() string { return model.DefaultRestfullWithRoleModel } -func DefaultPolicy() []byte { - return policy.MustPolicy("keymatch_with_rbac_in_domain.csv") -} - -func WithModel(model casbinmodel.Model) Setting { +func WithModel(model casbinmodel.Model) AuthorizerOption { return func(s *AuthorizerOptions) { s.Model = model } } -func WithStringModel(str string) Setting { +func WithStringModel(str string) AuthorizerOption { return func(s *AuthorizerOptions) { s.Model, _ = casbinmodel.NewModelFromString(str) } } -func WithFileModel(path string) Setting { +func WithFileModel(path string) AuthorizerOption { return func(s *AuthorizerOptions) { s.Model, _ = casbinmodel.NewModelFromFile(path) } } -func WithNameModel(name string) Setting { +func WithNameModel(name string) AuthorizerOption { return func(s *AuthorizerOptions) { s.Model, _ = casbinmodel.NewModelFromString(model.MustModel(name)) } } -func WithPolicyAdapter(adapter persist.Adapter) Setting { +func WithPolicyAdapter(adapter persist.Adapter) AuthorizerOption { return func(s *AuthorizerOptions) { s.Adapter = adapter } } -func WithWatcher(watcher persist.Watcher) Setting { +func WithWatcher(watcher persist.Watcher) AuthorizerOption { return func(s *AuthorizerOptions) { s.Watcher = watcher } } -func WithServiceClient(client pb.CasbinSourceServiceClient) Setting { +func WithSyncInterval(interval time.Duration) AuthorizerOption { + return func(s *AuthorizerOptions) { + s.SyncInterval = interval + } +} + +func WithEnforcer(enforcer *casbin.SyncedEnforcer) AuthorizerOption { return func(s *AuthorizerOptions) { - s.ServiceCli = client + s.Enforcer = enforcer } } diff --git a/contrib/security/authz/casbin/pbwatcher.go b/contrib/security/authz/casbin/pbwatcher.go new file mode 100644 index 00000000..c62f6520 --- /dev/null +++ b/contrib/security/authz/casbin/pbwatcher.go @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package casbin implements the functions, types, and interfaces for the module. +package casbin + +import ( + "io" + "sync" + "sync/atomic" + "time" + + "github.com/casbin/casbin/v2/persist" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" +) + +type RetryPolicy struct { + BaseDelay time.Duration + MaxDelay time.Duration + MaxRetries int +} + +type PBWatcher struct { + client pb.CasbinSourceServiceClient + setter PolicySetter + callback func(string) + mu sync.RWMutex + ctx context.Context + cancel context.CancelFunc + retryPolicy RetryPolicy + lastModified int64 +} + +func (w *PBWatcher) SetUpdateCallback(cb func(string)) error { + w.mu.Lock() + defer w.mu.Unlock() + w.callback = cb + return nil +} + +func (w *PBWatcher) Update() error { + w.mu.RLock() + defer w.mu.RUnlock() + if w.callback != nil { + w.callback("") + } + return nil +} + +func (w *PBWatcher) Close() { + w.cancel() +} + +func (w *PBWatcher) Watch() { + go w.watchLoop() +} + +func (w *PBWatcher) handleError(err error, retryCount int) int { + if retryCount >= w.retryPolicy.MaxRetries { + log.Fatal("Max retries exceeded") + //return retryCount + } + + delay := w.retryPolicy.BaseDelay * (1 << retryCount) + if delay > w.retryPolicy.MaxDelay { + delay = w.retryPolicy.MaxDelay + } + + log.Warnf("Retrying in %v (attempt %d)", delay, retryCount+1) + time.Sleep(delay) + return retryCount + 1 +} + +func (w *PBWatcher) watchLoop() { + retryCount := 0 + lastModified := int64(0) + for { + select { + case <-w.ctx.Done(): + return + default: + err := w.streamUpdates(lastModified) + if err != nil { + retryCount = w.handleError(err, retryCount) + } else { + retryCount = 0 + } + } + } +} + +func (w *PBWatcher) streamUpdates(lastVersion int64) error { + resp, err := w.client.WatchUpdate(w.ctx, &pb.WatchUpdateRequest{ + LastModified: atomic.LoadInt64(&w.lastModified), + }) + + if err != nil { + return err + } + + if resp.ModifiedDate > atomic.LoadInt64(&w.lastModified) { + policies, err := w.fetchPolicies() + if err != nil { + return err + } + + w.mu.Lock() + defer w.mu.Unlock() + w.setter.SetPolicies(policies) + atomic.StoreInt64(&w.lastModified, resp.ModifiedDate) + + if w.callback != nil { + w.callback("") + } + } + return nil +} + +func (w *PBWatcher) fetchPolicies() (map[string][][]string, error) { + ctx, cancel := context.WithTimeout(w.ctx, 5*time.Second) + defer cancel() + + stream, err := w.client.StreamRules(ctx, &pb.StreamRulesRequest{ + WithGroupings: true, + WithPolicies: true, + }) + if err != nil { + return nil, err + } + + policies := make(map[string][][]string) + for { + rule, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return nil, err + } + + switch v := rule.RuleType.(type) { + case *pb.StreamRulesResponse_Policy: + policies[v.Policy.PType] = append(policies[v.Policy.PType], v.Policy.Params) + case *pb.StreamRulesResponse_Grouping: + policies[v.Grouping.PType] = append(policies[v.Grouping.PType], v.Grouping.Params) + } + } + return policies, nil +} + +func NewPBWatcher(ctx context.Context, client pb.CasbinSourceServiceClient, setter PolicySetter) (persist.Watcher, error) { + ctx, cancel := context.WithCancel(ctx) + return &PBWatcher{ + client: client, + setter: setter, + ctx: ctx, + cancel: cancel, + retryPolicy: RetryPolicy{ + BaseDelay: 1 * time.Second, + MaxDelay: 30 * time.Second, + MaxRetries: 5, + }, + }, nil +} diff --git a/helpers/securityx/security.go b/helpers/securityx/security.go index 5dc99dbf..35ba5a6a 100644 --- a/helpers/securityx/security.go +++ b/helpers/securityx/security.go @@ -39,7 +39,7 @@ func NewTokenizer(bootstrap *configs.Bootstrap, ss ...jwt.Setting) (security.Tok return tokenizer, nil } -func NewAuthorizer(bootstrap *configs.Bootstrap, ss ...casbin.Setting) (security.Authorizer, error) { +func NewAuthorizer(bootstrap *configs.Bootstrap, ss ...casbin.AuthorizerOption) (security.Authorizer, error) { authorizer, err := casbin.NewAuthorizer(bootstrap.GetSecurity(), ss...) if err != nil { return nil, err diff --git a/internal/mock/token_test.go b/internal/mock/token_test.go index f55003eb..9582ff17 100644 --- a/internal/mock/token_test.go +++ b/internal/mock/token_test.go @@ -12,7 +12,6 @@ import ( _ "github.com/origadmin/contrib/consul/config" _ "github.com/origadmin/contrib/consul/registry" _ "github.com/origadmin/contrib/database" - msecurity "github.com/origadmin/runtime/agent/middleware/security" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/toolkits/security" @@ -105,38 +104,24 @@ func TestGenerateToken(t *testing.T) { if err != nil { panic(err) } - adapter := casbin.NewAdapter() - authorizer, err := securityx.NewAuthorizer(bs, casbin.WithPolicyAdapter(adapter), casbin.WithServiceClient(casbinSourceServiceClient)) + //adapter := casbin.NewAdapter() + authorizer, err := securityx.NewAuthorizer(bs, casbin.WithServiceClient(casbinSourceServiceClient)) if err != nil { panic(err) } - bridge := securityx.SecurityBridge{ - TokenSource: security.TokenSourceHeader, - Scheme: security.SchemeBearer, - AuthenticationHeader: security.HeaderAuthorize, - Authenticator: authenticator, - Authorizer: authorizer, - SkipKey: msecurity.MetadataSecuritySkipKey, - PublicPaths: nil, - Provider: &data{}, - Skipper: func(path string) bool { - return false - }, - IsRoot: func(ctx context.Context, claims security.Claims) bool { - return claims.GetSubject() == "root" || claims.GetSubject() == "admin" - }, - TokenParser: nil, - PolicyParser: func(ctx context.Context, claims security.Claims) (security.Policy, error) { - return security.RegisteredPolicy{ - Subject: "user_1", - Object: "/api/v1/sys/users", - Action: "GET", - Domain: "*", - //Roles: roles, - //Permissions: permissions, - }, nil - }, + bridge := securityx.DefaultBridge() + bridge.PolicyParser = func(ctx context.Context, claims security.Claims) (security.Policy, error) { + return security.RegisteredPolicy{ + Subject: "user_1", + Object: "/api/v1/sys/users", + Action: "GET", + Domain: "*", + //Roles: roles, + //Permissions: permissions, + }, nil } + bridge.Authenticator = authenticator + bridge.Authorizer = authorizer ctx := context.Background() claims2, err := bridge.Authenticator.Authenticate(ctx, token) if err != nil { @@ -146,7 +131,9 @@ func TestGenerateToken(t *testing.T) { if err != nil { t.Fatalf("failed to parse policy: %v", err) } - authorized, err := bridge.Authorizer.Authorized(context.Background(), policy, "", "") + + authorized, err := bridge.Authorizer.AuthorizedWithExtra(context.Background(), security.DataWithExtra(claims, + policy, nil)) if err != nil { t.Errorf("failed to authorize: %v", err) } diff --git a/internal/mods/system/dal/casbin.dal.go b/internal/mods/system/dal/casbin.dal.go index b29077a7..7adc91c4 100644 --- a/internal/mods/system/dal/casbin.dal.go +++ b/internal/mods/system/dal/casbin.dal.go @@ -48,6 +48,9 @@ func (c casbinSourceRepo) ListPolicies(ctx context.Context, in *pb.ListPoliciesR continue } for _, resource := range resources { + if resource.Type != "A" && resource.Type != "B" { + continue + } rules = append(rules, &pb.PolicyRule{ PType: "p", Params: []string{ diff --git a/internal/mods/system/service/casbin.authz.go b/internal/mods/system/service/casbin.authz.go index 2fee3825..8c093541 100644 --- a/internal/mods/system/service/casbin.authz.go +++ b/internal/mods/system/service/casbin.authz.go @@ -8,6 +8,7 @@ package service import ( "context" "errors" + "fmt" "io" "sync" "time" @@ -75,19 +76,11 @@ func (s *CasbinAuthorizerService) Authorized(ctx context.Context, policy securit log.Debugf("Authorizing user with adapter: %+v", policy) var err error var allowed bool - if object == "" { - object = policy.GetObject() - } - if action == "" { - action = policy.GetAction() - } - domain := policy.GetDomain() - if domain == "" { - domain = "*" - } + domain := cmp.Or(policy.GetDomain(), s.wildcardItem) + object = cmp.Or(object, policy.GetObject()) + action = cmp.Or(action, policy.GetAction()) if allowed, err = s.enforcer.Enforce(policy.GetSubject(), object, action, domain); err != nil { - log.Errorf("Authorization failed with error: %v", err) - return false, err + return false, fmt.Errorf("authorization failed with error: %v", err) } else if allowed { log.Debugf("Authorization successful for user with adapter: %+v", policy) return true, nil diff --git a/internal/mods/system/service/casbin.http.go b/internal/mods/system/service/casbin.http.go index 70eb0ae4..bf2cd169 100644 --- a/internal/mods/system/service/casbin.http.go +++ b/internal/mods/system/service/casbin.http.go @@ -5,6 +5,8 @@ package service import ( + "github.com/origadmin/runtime/context" + pb "origadmin/application/admin/api/v1/services/system" ) @@ -15,6 +17,21 @@ type CasbinServiceHTTPServer struct { client pb.CasbinSourceServiceHTTPClient } +func (c CasbinServiceHTTPServer) ListGroupings(ctx context.Context, request *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { + //TODO implement me + panic("implement me") +} + +func (c CasbinServiceHTTPServer) ListPolicies(ctx context.Context, request *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { + //TODO implement me + panic("implement me") +} + +func (c CasbinServiceHTTPServer) WatchUpdate(ctx context.Context, request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { + //TODO implement me + panic("implement me") +} + // NewCasbinServiceHTTPServer new a login service. func NewCasbinServiceHTTPServer(client pb.CasbinSourceServiceHTTPClient) *CasbinServiceHTTPServer { return &CasbinServiceHTTPServer{client: client} From 8a97a23bea051447d34000ded013c5c26f3d49a7 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 16 Apr 2025 18:03:48 +0800 Subject: [PATCH 006/158] feat(authz): conditionally enable Prometheus metrics for Casbin authorizer - Add enablePrometheus flag to Authorizer struct - Update NewAuthorizer function to accept enablePrometheus parameter - Register Prometheus metrics only when enablePrometheus is true - Remove unused watcher interfaces and commented-out code --- contrib/security/authz/casbin/casbin.go | 45 ++++++++++++++---------- contrib/security/authz/casbin/watcher.go | 31 ---------------- 2 files changed, 27 insertions(+), 49 deletions(-) diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index 0d1364f8..78860f34 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -28,14 +28,15 @@ import ( // Authorizer is a struct that implements the Authorizer interface. type Authorizer struct { - client pb.CasbinSourceServiceClient - options *AuthorizerOptions - enforcer *casbin.SyncedEnforcer - lastModified int64 - interval int64 - wildcardItem string - model casbinmodel.Model - adapter persist.Adapter + client pb.CasbinSourceServiceClient + options *AuthorizerOptions + enforcer *casbin.SyncedEnforcer + lastModified int64 + interval int64 + wildcardItem string + model casbinmodel.Model + adapter persist.Adapter + enablePrometheus bool } const MaxRetryDelay = time.Minute @@ -66,11 +67,7 @@ var ( ) func init() { - prometheus.MustRegister( - policySyncCounter, - policyCountGauge, - policySyncDuration, - ) + } func (auth *Authorizer) Authorized(ctx context.Context, policy security.Policy, object string, action string) (bool, error) { @@ -260,12 +257,13 @@ func (auth *Authorizer) Apply() error { func NewDefaultAuthorizer() *Authorizer { model, _ := casbinmodel.NewModelFromString(DefaultModel()) return &Authorizer{ - model: model, - adapter: NewAdapter(nil), + model: model, + adapter: NewAdapter(nil), + enablePrometheus: false, // 默认关闭 Prometheus } } -func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Authorizer, error) { +func NewAuthorizer(cfg *configv1.Security, enablePrometheus bool, ss ...AuthorizerOption) (security.Authorizer, error) { config := cfg.GetAuthz().GetCasbin() if config == nil { return nil, errors.New("authorizer casbin config is empty") @@ -283,8 +281,9 @@ func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Aut return nil, errors.New("model and adapter are required") } auth := &Authorizer{ - interval: 5, - options: options, + interval: 5, + options: options, + enablePrometheus: enablePrometheus, // 用户注入是否启用 Prometheus } if err := auth.Apply(); err != nil { return nil, err @@ -299,5 +298,15 @@ func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Aut } auth.SyncPolicy(context.TODO()) go auth.WatchUpdate() + + // 条件性注册 Prometheus 指标 + if auth.enablePrometheus { + prometheus.MustRegister( + policySyncCounter, + policyCountGauge, + policySyncDuration, + ) + } + return auth, nil } diff --git a/contrib/security/authz/casbin/watcher.go b/contrib/security/authz/casbin/watcher.go index b3487700..22234f7d 100644 --- a/contrib/security/authz/casbin/watcher.go +++ b/contrib/security/authz/casbin/watcher.go @@ -22,35 +22,6 @@ type watcher struct { callback func(string) } -//func (w *watcher) UpdateForAddPolicy(sec, ptype string, params ...string) error { -// return w.Update() -//} -// -//func (w *watcher) UpdateForRemovePolicy(sec, ptype string, params ...string) error { -// return w.Update() -//} -// -//func (w *watcher) UpdateForRemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) error { -// return w.Update() -//} -// -//func (w *watcher) UpdateForSavePolicy(model model.Model) error { -// w.mu.Lock() -// defer w.mu.Unlock() -// if w.callback != nil { -// w.callback(model.ToText()) -// } -// return nil -//} -// -//func (w *watcher) UpdateForAddPolicies(sec string, ptype string, rules ...[]string) error { -// return w.Update() -//} -// -//func (w *watcher) UpdateForRemovePolicies(sec string, ptype string, rules ...[]string) error { -// return w.Update() -//} - func (w *watcher) SetUpdateCallback(f func(string)) error { w.mu.Lock() defer w.mu.Unlock() @@ -78,5 +49,3 @@ func NewWatcher() persist.Watcher { } var _ persist.Watcher = &watcher{} - -//var _ persist.WatcherEx = &watcher{} From 854b5d8b5921e4a1794908ad9a45bcbd41a4fdad Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 21 Apr 2025 15:38:28 +0800 Subject: [PATCH 007/158] feat(authz): implement policy updater and notifier for casbin - Add PolicyNotifier interface and policyNotifier struct to manage observers - Implement AuthorizerOptions and update Authorizer to use new options- Create PolicyUpdater struct to handle policy updates from gRPC stream - Refactor casbin adapter to support new policy update mechanisms - Update service and internal modules to use new authorizer options --- contrib/security/authz/casbin/adapter.go | 46 +++- contrib/security/authz/casbin/casbin.go | 256 ++++++------------- contrib/security/authz/casbin/notifier.go | 56 ++++ contrib/security/authz/casbin/option.go | 34 ++- contrib/security/authz/casbin/pbwatcher.go | 168 ------------ contrib/security/authz/casbin/update.go | 100 ++++++++ internal/loader/loader.go | 2 +- internal/mock/token_test.go | 12 +- internal/mods/agent/http.go | 7 +- internal/mods/system/service/casbin.authz.go | 201 +-------------- 10 files changed, 328 insertions(+), 554 deletions(-) create mode 100644 contrib/security/authz/casbin/notifier.go delete mode 100644 contrib/security/authz/casbin/pbwatcher.go create mode 100644 contrib/security/authz/casbin/update.go diff --git a/contrib/security/authz/casbin/adapter.go b/contrib/security/authz/casbin/adapter.go index a1b3b809..297933f4 100644 --- a/contrib/security/authz/casbin/adapter.go +++ b/contrib/security/authz/casbin/adapter.go @@ -6,20 +6,53 @@ package casbin import ( + "context" "fmt" "github.com/casbin/casbin/v2/model" "github.com/casbin/casbin/v2/persist" + "github.com/goexts/generic/maps" + "github.com/origadmin/toolkits/security" ) -type PolicySetter interface { - SetPolicies(policies map[string][][]string) -} - type adapter struct { typedPolicies map[string][][]string } +func (a *adapter) SetRoles(ctx context.Context, roles security.RoleMap) error { + return nil +} + +func (a *adapter) SetPolicies(ctx context.Context, policies security.PolicyMap) error { + a.typedPolicies = maps.Transform(policies, func(k string, v any) (string, [][]string, bool) { + if vv, ok := v.([][]string); ok { + return k, vv, true + } + return "", nil, false + }) + return nil +} + +func (a *adapter) SetPolicyRoles(ctx context.Context, policies security.PolicyMap, roles security.RoleMap) error { + merged := make(map[string][][]string) + maps.Transform(policies, func(k string, v any) (string, [][]string, bool) { + if vv, ok := v.([][]string); ok { + merged[k] = append(merged[k], vv...) + return k, vv, true + } + return "", nil, false + }) + maps.Transform(roles, func(k string, v any) (string, [][]string, bool) { + if vv, ok := v.([][]string); ok { + merged[k] = append(merged[k], vv...) + return k, vv, true + } + return "", nil, false + }) + a.typedPolicies = merged + return nil +} + func (a *adapter) AddPolicies(sec string, ptype string, rules [][]string) error { for _, rule := range rules { err := a.AddPolicy(sec, ptype, rule) @@ -137,10 +170,6 @@ func (a *adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, return nil } -func (a *adapter) SetPolicies(policies map[string][][]string) { - a.typedPolicies = policies -} - func NewAdapter(policies map[string][][]string) persist.Adapter { if policies == nil { policies = make(map[string][][]string) @@ -152,3 +181,4 @@ func NewAdapter(policies map[string][][]string) persist.Adapter { var _ persist.Adapter = (*adapter)(nil) var _ persist.BatchAdapter = (*adapter)(nil) +var _ security.PolicyRegistry = (*adapter)(nil) diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index 78860f34..0e89bb53 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -5,7 +5,6 @@ package casbin import ( - "io" "time" "github.com/casbin/casbin/v2" @@ -14,28 +13,23 @@ import ( "github.com/goexts/generic/cmp" "github.com/goexts/generic/maps" "github.com/goexts/generic/settings" - "github.com/origadmin/runtime/log" - "github.com/prometheus/client_golang/prometheus" - "google.golang.org/grpc/status" - "github.com/origadmin/runtime/context" configv1 "github.com/origadmin/runtime/gen/go/config/v1" + "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/errors" "github.com/origadmin/toolkits/security" - - pb "origadmin/application/admin/api/v1/services/system" + "github.com/prometheus/client_golang/prometheus" ) // Authorizer is a struct that implements the Authorizer interface. type Authorizer struct { - client pb.CasbinSourceServiceClient options *AuthorizerOptions enforcer *casbin.SyncedEnforcer - lastModified int64 - interval int64 + updater *PolicyUpdater wildcardItem string model casbinmodel.Model adapter persist.Adapter + watcher persist.Watcher enablePrometheus bool } @@ -66,190 +60,98 @@ var ( ) ) -func init() { - -} - func (auth *Authorizer) Authorized(ctx context.Context, policy security.Policy, object string, action string) (bool, error) { - log.Debugf("Authorizing user with adapter: %+v", policy) - var err error - var allowed bool - var domain string - domain = cmp.Or(policy.GetDomain(), auth.wildcardItem) + domain := cmp.Or(policy.GetDomain(), "*") object = cmp.Or(object, policy.GetObject()) action = cmp.Or(action, policy.GetAction()) - if allowed, err = auth.enforcer.Enforce(policy.GetSubject(), object, action, domain); err != nil { - log.Errorf("Authorization failed with error: %v", err) - return false, err - } else if allowed { - log.Debugf("Authorization successful for user with adapter: %+v", policy) - return true, nil - } - return false, nil + return auth.enforce(ctx, policy.GetSubject(), object, action, domain) } func (auth *Authorizer) AuthorizedWithDomain(ctx context.Context, policy security.Policy, domain string, object string, action string) (bool, error) { - log.Debugf("Authorizing user with adapter: %+v", policy) - domain = cmp.Or(domain, policy.GetDomain(), auth.wildcardItem) + domain = cmp.Or(domain, policy.GetDomain(), "*") object = cmp.Or(object, policy.GetObject()) action = cmp.Or(action, policy.GetAction()) - - if allowed, err := auth.enforcer.Enforce(policy.GetSubject(), object, action, domain); err != nil { - log.Errorf("Authorization failed with error: %v", err) - return false, err - } else if allowed { - log.Debugf("Authorization successful for user with adapter: %+v", policy) - return true, nil - } - log.Debugf("Authorization failed for user with adapter: %+v", policy) - return false, nil + return auth.enforce(ctx, policy.GetSubject(), object, action, domain) } func (auth *Authorizer) AuthorizedWithExtra(ctx context.Context, data security.ExtraData) (bool, error) { - log.Debugf("Authorizing user with extra data: %+v", data) policy, ok := data.GetPolicy() if !ok { - return false, errors.New("policy is empty") + return false, errors.New("policy not found in extra data") } - if allowed, err := auth.enforcer.Enforce(policy.GetSubject(), policy.GetObject(), policy.GetAction(), policy.GetDomain()); err != nil { - log.Errorf("Authorization failed with error: %v", err) + return auth.enforce(ctx, policy.GetSubject(), policy.GetObject(), policy.GetAction(), policy.GetDomain()) +} + +func (auth *Authorizer) enforce(ctx context.Context, subject, object, action, domain string) (bool, error) { + allowed, err := auth.enforcer.Enforce(subject, object, action, domain) + if err != nil { + log.Errorf("Authorization error: %auth", err) return false, err - } else if allowed { - log.Debugf("Authorization successful for user with adapter: %+v", policy) - return true, nil } - log.Debugf("Authorization failed for user with adapter: %+v", policy) - return false, nil + log.Debugf("Authorization result: %t for %s %s %s %s", allowed, subject, object, action, domain) + return allowed, nil } func (auth *Authorizer) SetPolicies(ctx context.Context, policies map[string]any, roles map[string]any) error { - p := maps.Transform(policies, func(k string, v any) (string, [][]string, bool) { + merged := make(map[string][][]string) + + // Merge policy and role data + maps.Transform(policies, func(k string, v any) (string, [][]string, bool) { if vv, ok := v.([][]string); ok { - return k, vv, ok + merged[k] = append(merged[k], vv...) + return k, vv, true } - return k, [][]string{}, false + return "", nil, false }) - adapter := NewAdapter(p) - auth.enforcer.SetAdapter(adapter) - err := auth.options.Watcher.Update() - if err != nil { - return errors.Wrap(err, "failed to load adapter") - } - return nil -} - -func (auth *Authorizer) SyncPolicy(ctx context.Context) error { - start := time.Now() - defer func() { - duration := time.Since(start).Seconds() - policySyncDuration.Observe(duration) - }() - stream, err := auth.client.StreamRules(ctx, &pb.StreamRulesRequest{ - WithGroupings: true, - WithPolicies: true, - }) - if err != nil { - return err - } - log.Infof("Syncing policies...") - var policies = make(map[string][][]string) - for { - rule, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - st, _ := status.FromError(err) - return status.Errorf(st.Code(), "recvied error: %v", st.Message()) + maps.Transform(roles, func(k string, v any) (string, [][]string, bool) { + if vv, ok := v.([][]string); ok { + merged[k] = append(merged[k], vv...) + return k, vv, true } + return "", nil, false + }) - switch v := rule.RuleType.(type) { - case *pb.StreamRulesResponse_Policy: - policies[v.Policy.PType] = append(policies[v.Policy.PType], v.Policy.Params) - case *pb.StreamRulesResponse_Grouping: - policies[v.Grouping.PType] = append(policies[v.Grouping.PType], v.Grouping.Params) - } - } - pLen := len(policies) - log.Infof("Updated %d policies", pLen) - for s, p := range policies { - log.Debugf("Updated %d %s policies", len(p), s) - } - if pLen > 0 { - auth.lastModified = time.Now().Unix() - if setter, ok := auth.options.Adapter.(PolicySetter); ok { - log.Infof("AuthorizerOption policies...") - setter.SetPolicies(policies) - } - err := auth.enforcer.LoadPolicy() + // Incremental update policy + if ps, ok := auth.adapter.(security.PolicyRegistry); ok { + err := ps.SetPolicyRoles(ctx, policies, roles) if err != nil { - log.Warnf("Failed to load policy: %v", err) return err } - //policies, err := auth.enforcer.GetPolicy() - //if err != nil { - // log.Warnf("Failed to get policy: %v", err) - // return err - //} - //log.Infof("Updated %d policies", len(policies)) - policyCountGauge.Set(float64(pLen)) - policySyncCounter.WithLabelValues("success").Inc() + } + err := auth.watcher.Update() + if err != nil { + return err } return nil } -func (auth *Authorizer) WatchUpdate() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - interval := time.Duration(auth.interval) * time.Second - retryDelay := 3 * time.Second - timer := time.NewTimer(interval) - defer timer.Stop() - log.Infof("Watching for updates every %v", interval) - for { - select { - case <-timer.C: - response, err := auth.client.WatchUpdate(ctx, &pb.WatchUpdateRequest{ - LastModified: auth.lastModified, - }) - - if err != nil { - newDelay := time.Duration(float64(retryDelay) * 1.5) - if newDelay > MaxRetryDelay { - newDelay = MaxRetryDelay - } - retryDelay = newDelay - log.Warnf("WatchUpdate failed, retrying in %v: %v", retryDelay, err) - timer.Reset(retryDelay) - continue - } - - retryDelay = 3 * time.Second - timer.Reset(interval) - lastDate := response.ModifiedDate - if lastDate > auth.lastModified || auth.lastModified == 0 { - log.Infof("Update detected, last modified: %v", lastDate) - go auth.SyncPolicy(ctx) - continue - } - log.Debugf("No update detected, last modified: %v", lastDate) - case <-ctx.Done(): - return - } - } -} - func (auth *Authorizer) Apply() error { + var err error if auth.options.Adapter == nil { - auth.options.Adapter = NewAdapter(nil) + auth.adapter = NewAdapter(nil) } if auth.options.Model == nil { - auth.options.Model, _ = casbinmodel.NewModelFromString(DefaultModel()) + auth.model, err = casbinmodel.NewModelFromString(DefaultModel()) + if err != nil { + return err + } } if auth.options.Watcher == nil { - auth.options.Watcher = NewWatcher() + auth.watcher = NewWatcher() + } + if auth.model == nil || auth.adapter == nil { + return errors.New("model and adapter cannot be nil") + } + + if auth.options.WildcardItem == "" { + auth.wildcardItem = "*" + } + + auth.enforcer, err = casbin.NewSyncedEnforcer(auth.model, auth.adapter) + if err != nil { + return err } return nil } @@ -259,7 +161,7 @@ func NewDefaultAuthorizer() *Authorizer { return &Authorizer{ model: model, adapter: NewAdapter(nil), - enablePrometheus: false, // 默认关闭 Prometheus + enablePrometheus: false, } } @@ -268,39 +170,41 @@ func NewAuthorizer(cfg *configv1.Security, enablePrometheus bool, ss ...Authoriz if config == nil { return nil, errors.New("authorizer casbin config is empty") } - var err error - if config.ModelFile != "" { - ss = append(ss, WithFileModel(config.ModelFile)) + + options := settings.ApplyDefault(DefaultAuthorizerOptions, ss) + if options.Client == nil { + return nil, errors.New("authorizer casbin client is empty") } - options := settings.Apply(&AuthorizerOptions{ - Model: casbinmodel.NewModel(), - Watcher: NewWatcher(), - SyncInterval: 5 * time.Second, - }, ss) - if options.Model == nil || options.Adapter == nil { - return nil, errors.New("model and adapter are required") + + updater := &PolicyUpdater{ + client: options.Client, + adapter: options.Adapter, + interval: options.SyncInterval, } + auth := &Authorizer{ - interval: 5, - options: options, - enablePrometheus: enablePrometheus, // 用户注入是否启用 Prometheus + options: options, + updater: updater, + wildcardItem: options.WildcardItem, } + if err := auth.Apply(); err != nil { return nil, err } - auth.enforcer, err = casbin.NewSyncedEnforcer(auth.options.Model, auth.options.Adapter) + + enforcer, err := casbin.NewSyncedEnforcer(auth.model, auth.adapter) if err != nil { return nil, err } - err = auth.enforcer.SetWatcher(auth.options.Watcher) - if err != nil { + auth.enforcer = enforcer + + if err := auth.enforcer.SetWatcher(auth.watcher); err != nil { return nil, err } - auth.SyncPolicy(context.TODO()) - go auth.WatchUpdate() - // 条件性注册 Prometheus 指标 - if auth.enablePrometheus { + go updater.Watch(context.Background(), auth.watcher) + + if enablePrometheus { prometheus.MustRegister( policySyncCounter, policyCountGauge, diff --git a/contrib/security/authz/casbin/notifier.go b/contrib/security/authz/casbin/notifier.go new file mode 100644 index 00000000..7a731641 --- /dev/null +++ b/contrib/security/authz/casbin/notifier.go @@ -0,0 +1,56 @@ +package casbin + +import ( + "sync" + + "github.com/origadmin/runtime/log" +) + +type PolicyNotifier interface { + AddObserver(name string, callback func()) + RemoveObserver(name string) + NotifyAll() +} + +type policyNotifier struct { + observers map[string]func() + mu sync.RWMutex +} + +func NewPolicyNotifier() PolicyNotifier { + return &policyNotifier{ + observers: make(map[string]func()), + } +} + +func (n *policyNotifier) AddObserver(name string, callback func()) { + n.mu.Lock() + defer n.mu.Unlock() + n.observers[name] = callback + log.Debugf("Added policy observer: %s", name) +} + +func (n *policyNotifier) RemoveObserver(name string) { + n.mu.Lock() + defer n.mu.Unlock() + delete(n.observers, name) + log.Debugf("Removed policy observer: %s", name) +} + +func (n *policyNotifier) NotifyAll() { + n.mu.RLock() + defer n.mu.RUnlock() + + log.Info("Notifying all policy observers") + for name, cb := range n.observers { + log.Debugf("Triggering policy update for: %s", name) + go func(name string, callback func()) { + defer func() { + if err := recover(); err != nil { + log.Errorf("Policy observer %s panic: %v", name, err) + } + }() + callback() + }(name, cb) + } +} diff --git a/contrib/security/authz/casbin/option.go b/contrib/security/authz/casbin/option.go index 53bb07b8..cb5dd942 100644 --- a/contrib/security/authz/casbin/option.go +++ b/contrib/security/authz/casbin/option.go @@ -11,20 +11,32 @@ import ( casbinmodel "github.com/casbin/casbin/v2/model" "github.com/casbin/casbin/v2/persist" + pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/contrib/security/authz/casbin/internal/model" ) type AuthorizerOptions struct { - Model casbinmodel.Model // Need - Adapter persist.Adapter // Need - Watcher persist.Watcher // Optional - Enforcer *casbin.SyncedEnforcer // Optional - SyncInterval time.Duration // Optional(Replace Interval/RetryDelay) + Model casbinmodel.Model // Need + Adapter persist.Adapter // Need + Watcher persist.Watcher // Optional + Enforcer *casbin.SyncedEnforcer // Optional + SyncInterval time.Duration // Optional + Client pb.CasbinSourceServiceClient // gRPC client + WildcardItem string } // AuthorizerOption is a function type for setting the Authenticator. type AuthorizerOption = func(*AuthorizerOptions) +var ( + DefaultAuthorizerOptions = AuthorizerOptions{ + Model: casbinmodel.NewModel(), + Watcher: NewWatcher(), + SyncInterval: 5 * time.Second, + WildcardItem: "*", + } +) + func DefaultModel() string { return model.DefaultRestfullWithRoleModel } @@ -76,3 +88,15 @@ func WithEnforcer(enforcer *casbin.SyncedEnforcer) AuthorizerOption { s.Enforcer = enforcer } } + +func WithWildcardItem(item string) AuthorizerOption { + return func(s *AuthorizerOptions) { + s.WildcardItem = item + } +} + +func WithClient(client pb.CasbinSourceServiceClient) AuthorizerOption { + return func(s *AuthorizerOptions) { + s.Client = client + } +} diff --git a/contrib/security/authz/casbin/pbwatcher.go b/contrib/security/authz/casbin/pbwatcher.go deleted file mode 100644 index c62f6520..00000000 --- a/contrib/security/authz/casbin/pbwatcher.go +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package casbin implements the functions, types, and interfaces for the module. -package casbin - -import ( - "io" - "sync" - "sync/atomic" - "time" - - "github.com/casbin/casbin/v2/persist" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" -) - -type RetryPolicy struct { - BaseDelay time.Duration - MaxDelay time.Duration - MaxRetries int -} - -type PBWatcher struct { - client pb.CasbinSourceServiceClient - setter PolicySetter - callback func(string) - mu sync.RWMutex - ctx context.Context - cancel context.CancelFunc - retryPolicy RetryPolicy - lastModified int64 -} - -func (w *PBWatcher) SetUpdateCallback(cb func(string)) error { - w.mu.Lock() - defer w.mu.Unlock() - w.callback = cb - return nil -} - -func (w *PBWatcher) Update() error { - w.mu.RLock() - defer w.mu.RUnlock() - if w.callback != nil { - w.callback("") - } - return nil -} - -func (w *PBWatcher) Close() { - w.cancel() -} - -func (w *PBWatcher) Watch() { - go w.watchLoop() -} - -func (w *PBWatcher) handleError(err error, retryCount int) int { - if retryCount >= w.retryPolicy.MaxRetries { - log.Fatal("Max retries exceeded") - //return retryCount - } - - delay := w.retryPolicy.BaseDelay * (1 << retryCount) - if delay > w.retryPolicy.MaxDelay { - delay = w.retryPolicy.MaxDelay - } - - log.Warnf("Retrying in %v (attempt %d)", delay, retryCount+1) - time.Sleep(delay) - return retryCount + 1 -} - -func (w *PBWatcher) watchLoop() { - retryCount := 0 - lastModified := int64(0) - for { - select { - case <-w.ctx.Done(): - return - default: - err := w.streamUpdates(lastModified) - if err != nil { - retryCount = w.handleError(err, retryCount) - } else { - retryCount = 0 - } - } - } -} - -func (w *PBWatcher) streamUpdates(lastVersion int64) error { - resp, err := w.client.WatchUpdate(w.ctx, &pb.WatchUpdateRequest{ - LastModified: atomic.LoadInt64(&w.lastModified), - }) - - if err != nil { - return err - } - - if resp.ModifiedDate > atomic.LoadInt64(&w.lastModified) { - policies, err := w.fetchPolicies() - if err != nil { - return err - } - - w.mu.Lock() - defer w.mu.Unlock() - w.setter.SetPolicies(policies) - atomic.StoreInt64(&w.lastModified, resp.ModifiedDate) - - if w.callback != nil { - w.callback("") - } - } - return nil -} - -func (w *PBWatcher) fetchPolicies() (map[string][][]string, error) { - ctx, cancel := context.WithTimeout(w.ctx, 5*time.Second) - defer cancel() - - stream, err := w.client.StreamRules(ctx, &pb.StreamRulesRequest{ - WithGroupings: true, - WithPolicies: true, - }) - if err != nil { - return nil, err - } - - policies := make(map[string][][]string) - for { - rule, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - return nil, err - } - - switch v := rule.RuleType.(type) { - case *pb.StreamRulesResponse_Policy: - policies[v.Policy.PType] = append(policies[v.Policy.PType], v.Policy.Params) - case *pb.StreamRulesResponse_Grouping: - policies[v.Grouping.PType] = append(policies[v.Grouping.PType], v.Grouping.Params) - } - } - return policies, nil -} - -func NewPBWatcher(ctx context.Context, client pb.CasbinSourceServiceClient, setter PolicySetter) (persist.Watcher, error) { - ctx, cancel := context.WithCancel(ctx) - return &PBWatcher{ - client: client, - setter: setter, - ctx: ctx, - cancel: cancel, - retryPolicy: RetryPolicy{ - BaseDelay: 1 * time.Second, - MaxDelay: 30 * time.Second, - MaxRetries: 5, - }, - }, nil -} diff --git a/contrib/security/authz/casbin/update.go b/contrib/security/authz/casbin/update.go new file mode 100644 index 00000000..4f751ad7 --- /dev/null +++ b/contrib/security/authz/casbin/update.go @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package casbin implements the functions, types, and interfaces for the module. +package casbin + +import ( + "context" + "io" + "time" + + "github.com/casbin/casbin/v2" + "github.com/casbin/casbin/v2/persist" + "github.com/goexts/generic/maps" + "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/security" + "google.golang.org/grpc/status" + + pb "origadmin/application/admin/api/v1/services/system" +) + +type PolicyUpdater struct { + client pb.CasbinSourceServiceClient + adapter persist.Adapter + enforcer *casbin.SyncedEnforcer + lastModified int64 + interval time.Duration +} + +func (u *PolicyUpdater) Sync(ctx context.Context) error { + start := time.Now() + defer func() { + policySyncDuration.Observe(time.Since(start).Seconds()) + }() + + stream, err := u.client.StreamRules(ctx, &pb.StreamRulesRequest{ + WithGroupings: true, + WithPolicies: true, + }) + if err != nil { + return err + } + + policies := make(map[string][][]string) + for { + rule, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return status.Errorf(status.Code(err), "received stream error: %v", err) + } + + switch v := rule.RuleType.(type) { + case *pb.StreamRulesResponse_Policy: + policies[v.Policy.PType] = append(policies[v.Policy.PType], v.Policy.Params) + case *pb.StreamRulesResponse_Grouping: + policies[v.Grouping.PType] = append(policies[v.Grouping.PType], v.Grouping.Params) + } + } + + if len(policies) > 0 { + u.lastModified = time.Now().Unix() + switch setter := u.adapter.(type) { + case *adapter: + setter.typedPolicies = policies + case security.PolicyRegistry: + pm := maps.Transform(policies, func(k string, v [][]string) (string, any, bool) { + return k, any(v), true + }) + if err := setter.SetPolicies(ctx, pm); err != nil { + return err + } + } + + policyCountGauge.Set(float64(len(policies))) + policySyncCounter.WithLabelValues("success").Inc() + } + return nil +} + +func (u *PolicyUpdater) Watch(ctx context.Context, notifier persist.Watcher) { + ticker := time.NewTicker(u.interval) + defer ticker.Stop() + + for { + select { + case <-ticker.C: + + if err := u.Sync(ctx); err != nil { + log.Errorf("Policy sync failed: %v", err) + continue + } + _ = notifier.Update() + case <-ctx.Done(): + return + } + } +} diff --git a/internal/loader/loader.go b/internal/loader/loader.go index f385f76d..39584f40 100644 --- a/internal/loader/loader.go +++ b/internal/loader/loader.go @@ -74,7 +74,7 @@ func NewAuthorizer(bootstrap *configs.Bootstrap) (security.Authorizer, error) { } func NewBasisConfig(bootstrap *configs.Bootstrap) *configs.BasisConfig { - //c := DefaultCaptcha() + // c := DefaultCaptcha() // todo Read from the configuration file return DefaultBasisConfig() } diff --git a/internal/mock/token_test.go b/internal/mock/token_test.go index 9582ff17..eb422eea 100644 --- a/internal/mock/token_test.go +++ b/internal/mock/token_test.go @@ -15,7 +15,6 @@ import ( "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/toolkits/security" - "origadmin/application/admin/contrib/security/authz/casbin" "origadmin/application/admin/helpers/securityx" "origadmin/application/admin/internal/loader" "origadmin/application/admin/internal/mods/system/dal" @@ -78,11 +77,12 @@ func TestGenerateToken(t *testing.T) { Role: roleRepo, User: userRepo, } - claims, err := loginData.Tokenizer.CreateClaims(t.Context(), "user_1") + ctx := context.Background() + claims, err := loginData.Tokenizer.CreateClaims(ctx, "user_1") if err != nil { return } - token, err := loginData.Tokenizer.CreateToken(t.Context(), claims) + token, err := loginData.Tokenizer.CreateToken(ctx, claims) if err != nil { t.Fatalf("failed to create token: %v", err) } @@ -98,6 +98,7 @@ func TestGenerateToken(t *testing.T) { //} //_ := agent.NewRegisterAgent(registerAgent) casbinSourceServiceClient := server.NewCasbinServiceClient(v, nil) + _ = casbinSourceServiceClient //casbinBiz := biz.NewCasbinSourceServiceBiz(casbinRepo, nil) //client := service.NewCasbinSourceServiceServerPB(casbinBiz) authenticator, err := securityx.NewAuthenticator(bs) @@ -105,7 +106,7 @@ func TestGenerateToken(t *testing.T) { panic(err) } //adapter := casbin.NewAdapter() - authorizer, err := securityx.NewAuthorizer(bs, casbin.WithServiceClient(casbinSourceServiceClient)) + authorizer, err := securityx.NewAuthorizer(bs) if err != nil { panic(err) } @@ -122,7 +123,6 @@ func TestGenerateToken(t *testing.T) { } bridge.Authenticator = authenticator bridge.Authorizer = authorizer - ctx := context.Background() claims2, err := bridge.Authenticator.Authenticate(ctx, token) if err != nil { t.Fatalf("failed to authenticate: %v", err) @@ -132,7 +132,7 @@ func TestGenerateToken(t *testing.T) { t.Fatalf("failed to parse policy: %v", err) } - authorized, err := bridge.Authorizer.AuthorizedWithExtra(context.Background(), security.DataWithExtra(claims, + authorized, err := bridge.Authorizer.AuthorizedWithExtra(ctx, security.DataWithExtra(claims, policy, nil)) if err != nil { t.Errorf("failed to authorize: %v", err) diff --git a/internal/mods/agent/http.go b/internal/mods/agent/http.go index 4f1dda29..bbfdadba 100644 --- a/internal/mods/agent/http.go +++ b/internal/mods/agent/http.go @@ -57,8 +57,11 @@ func NewHTTPServerAgent(bootstrap *configs.Bootstrap, registrars []ServerRegiste if err != nil { panic(err) } - adapter := casbin.NewAdapter() - authorizer, err := securityx.NewAuthorizer(bootstrap, casbin.WithPolicyAdapter(adapter), casbin.WithServiceClient(client)) + casbinOpts := &casbin.Options{ + PolicyAdapter: casbin.NewAdapter(), + ServiceClient: client, + } + authorizer, err := securityx.NewAuthorizer(bootstrap, casbinOpts) if err != nil { panic(err) } diff --git a/internal/mods/system/service/casbin.authz.go b/internal/mods/system/service/casbin.authz.go index 8c093541..2383969f 100644 --- a/internal/mods/system/service/casbin.authz.go +++ b/internal/mods/system/service/casbin.authz.go @@ -6,128 +6,30 @@ package service import ( - "context" - "errors" - "fmt" - "io" "sync" "time" - casbinv2 "github.com/casbin/casbin/v2" "github.com/casbin/casbin/v2/persist" - "github.com/goexts/generic/cmp" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" - "github.com/origadmin/toolkits/security" - "github.com/prometheus/client_golang/prometheus" - "google.golang.org/grpc/status" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/contrib/security/authz/casbin" ) type CasbinAuthorizerService struct { - adapter persist.Adapter - enforcer *casbinv2.Enforcer client pb.CasbinSourceServiceClient + adapter persist.Adapter mu sync.RWMutex callback func(string) - lastModified int64 - interval int64 + interval time.Duration wildcardItem string + lastModified int64 } -const MaxRetryDelay = time.Minute - -var ( - policySyncCounter = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "casbin_policy_sync_total", - Help: "Total number of policy sync operations", - }, - []string{"status"}, - ) - - policyCountGauge = prometheus.NewGauge( - prometheus.GaugeOpts{ - Name: "casbin_policy_count", - Help: "Current number of loaded policies", - }, - ) - - policySyncDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Name: "casbin_sync_duration_seconds", - Help: "Histogram of policy sync durations", - Buckets: prometheus.DefBuckets, - }, - ) -) - -func init() { - //prometheus.MustRegister( - // policySyncCounter, - // policyCountGauge, - // policySyncDuration, - //) -} - -func (s *CasbinAuthorizerService) Authorized(ctx context.Context, policy security.Policy, object string, action string) (bool, error) { - log.Debugf("Authorizing user with adapter: %+v", policy) - var err error - var allowed bool - domain := cmp.Or(policy.GetDomain(), s.wildcardItem) - object = cmp.Or(object, policy.GetObject()) - action = cmp.Or(action, policy.GetAction()) - if allowed, err = s.enforcer.Enforce(policy.GetSubject(), object, action, domain); err != nil { - return false, fmt.Errorf("authorization failed with error: %v", err) - } else if allowed { - log.Debugf("Authorization successful for user with adapter: %+v", policy) - return true, nil - } - log.Debugf("Authorization failed for user with adapter: %+v", policy) - return false, nil -} - -func (s *CasbinAuthorizerService) AuthorizedWithDomain(ctx context.Context, policy security.Policy, domain string, object string, action string) (bool, error) { - log.Debugf("Authorizing user with adapter: %+v", policy) - domain = cmp.Or(domain, policy.GetDomain(), s.wildcardItem) - object = cmp.Or(object, policy.GetObject()) - action = cmp.Or(action, policy.GetAction()) - - if allowed, err := s.enforcer.Enforce(policy.GetSubject(), object, action, domain); err != nil { - log.Errorf("Authorization failed with error: %v", err) - return false, err - } else if allowed { - log.Debugf("Authorization successful for user with adapter: %+v", policy) - return true, nil - } - log.Debugf("Authorization failed for user with adapter: %+v", policy) - return false, nil -} - -func (s *CasbinAuthorizerService) AuthorizedWithExtra(ctx context.Context, data security.ExtraData) (bool, error) { - log.Debugf("Authorizing user with extra data: %+v", data) - policy, ok := data.GetPolicy() - if !ok { - return false, errors.New("adapter is empty") - } - if allowed, err := s.enforcer.Enforce(policy.GetSubject(), policy.GetObject(), policy.GetAction(), - policy.GetDomain()); err != nil { - log.Errorf("Authorization failed with error: %v", err) - return false, err - } else if allowed { - log.Debugf("Authorization successful for user with adapter: %+v", policy) - return true, nil - } - log.Debugf("Authorization failed for user with adapter: %+v", policy) - return false, nil -} - -func (s *CasbinAuthorizerService) SetUpdateCallback(f func(string)) error { +func (s *CasbinAuthorizerService) SetUpdateCallback(callback func(string)) error { s.mu.Lock() defer s.mu.Unlock() - s.callback = f + s.callback = callback return nil } @@ -135,7 +37,7 @@ func (s *CasbinAuthorizerService) Update() error { s.mu.RLock() defer s.mu.RUnlock() if s.callback != nil { - s.callback("") + s.callback("update") } return nil } @@ -144,95 +46,18 @@ func (s *CasbinAuthorizerService) Close() { s.mu.Lock() defer s.mu.Unlock() s.callback = nil -} - -func (s *CasbinAuthorizerService) SyncPolicy(ctx context.Context) error { - start := time.Now() - defer func() { - duration := time.Since(start).Seconds() - policySyncDuration.Observe(duration) - }() - stream, err := s.client.StreamRules(ctx, &pb.StreamRulesRequest{ - WithGroupings: true, - WithPolicies: true, - }) - if err != nil { - return err - } - - s.mu.Lock() - defer s.mu.Unlock() - var policies = make(map[string][][]string) - for { - rule, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - st, _ := status.FromError(err) - return status.Errorf(st.Code(), "recvied error: %v", st.Message()) - } - - switch v := rule.RuleType.(type) { - case *pb.StreamRulesResponse_Policy: - policies[v.Policy.PType] = append(policies[v.Policy.PType], v.Policy.Params) - case *pb.StreamRulesResponse_Grouping: - policies[v.Grouping.PType] = append(policies[v.Grouping.PType], v.Grouping.Params) - } - } - pLen := len(policies) - if pLen > 0 { - s.adapter = casbin.NewAdapterWithPolicies(policies) - policyCountGauge.Set(float64(pLen)) - policySyncCounter.WithLabelValues("success").Inc() - } - - return nil -} - -func (s *CasbinAuthorizerService) WatchUpdate() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - retryDelay := time.Duration(s.interval) * time.Second - timer := time.NewTimer(retryDelay) - defer timer.Stop() - for { - select { - case <-timer.C: - response, err := s.client.WatchUpdate(ctx, &pb.WatchUpdateRequest{ - LastModified: s.lastModified, - }) - - if err != nil { - newDelay := time.Duration(float64(retryDelay) * 1.5) - if newDelay > MaxRetryDelay { - newDelay = MaxRetryDelay - } - retryDelay = newDelay - log.Warnf("WatchUpdate failed, retrying in %v: %v", retryDelay, err) - timer.Reset(retryDelay) - continue - } - - timer.Reset(time.Duration(s.interval) * time.Second) - lastDate := response.ModifiedDate - if lastDate > s.lastModified || s.lastModified == 0 { - s.lastModified = lastDate - _ = s.Update() - continue - } - case <-ctx.Done(): - return - } - } + //s.adapter.Close() } // NewCasbinAuthorizerService new a casbin service. -func NewCasbinAuthorizerService(client pb.CasbinSourceServiceClient) security.Authorizer { +func NewCasbinAuthorizerService(client pb.CasbinSourceServiceClient) *CasbinAuthorizerService { return &CasbinAuthorizerService{ client: client, + adapter: casbin.NewAdapter(nil), + callback: nil, + interval: 5 * time.Second, + wildcardItem: "*", lastModified: 0, - interval: int64(5 * time.Minute), } } @@ -240,4 +65,4 @@ func NewCasbinSourceServiceClient(client *service.GRPCClient) pb.CasbinSourceSer return pb.NewCasbinSourceServiceClient(client) } -//var _ pb.CasbinSourceServiceServer = (*CasbinAuthorizerService)(nil) +var _ persist.Watcher = (*CasbinAuthorizerService)(nil) From 9d6e2f1ec23bb908fbccd21249a254e6005acb8d Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 21 Apr 2025 15:42:38 +0800 Subject: [PATCH 008/158] refactor(authz): implement efficient policy update mechanism - Add policy version check to avoid unnecessary updates- Implement streaming approach for policy retrieval - Update PolicyUpdater.Sync() to return update status - Handle stream errors and unsupported adapter scenarios --- contrib/security/authz/casbin/update.go | 30 ++++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/contrib/security/authz/casbin/update.go b/contrib/security/authz/casbin/update.go index 4f751ad7..664b3110 100644 --- a/contrib/security/authz/casbin/update.go +++ b/contrib/security/authz/casbin/update.go @@ -7,6 +7,7 @@ package casbin import ( "context" + "errors" "io" "time" @@ -28,18 +29,29 @@ type PolicyUpdater struct { interval time.Duration } -func (u *PolicyUpdater) Sync(ctx context.Context) error { +func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { start := time.Now() defer func() { policySyncDuration.Observe(time.Since(start).Seconds()) }() + update, err := u.client.WatchUpdate(ctx, &pb.WatchUpdateRequest{ + LastModified: u.lastModified, + }) + if err != nil { + return false, err + } + if u.lastModified >= update.ModifiedDate { + return false, nil + } + u.lastModified = update.ModifiedDate + stream, err := u.client.StreamRules(ctx, &pb.StreamRulesRequest{ WithGroupings: true, WithPolicies: true, }) if err != nil { - return err + return false, err } policies := make(map[string][][]string) @@ -49,7 +61,7 @@ func (u *PolicyUpdater) Sync(ctx context.Context) error { break } if err != nil { - return status.Errorf(status.Code(err), "received stream error: %v", err) + return false, status.Errorf(status.Code(err), "received stream error: %v", err) } switch v := rule.RuleType.(type) { @@ -65,19 +77,22 @@ func (u *PolicyUpdater) Sync(ctx context.Context) error { switch setter := u.adapter.(type) { case *adapter: setter.typedPolicies = policies + return true, nil case security.PolicyRegistry: pm := maps.Transform(policies, func(k string, v [][]string) (string, any, bool) { return k, any(v), true }) if err := setter.SetPolicies(ctx, pm); err != nil { - return err + return false, err } + return true, nil + default: + return false, errors.New("unsupported adapter") } - policyCountGauge.Set(float64(len(policies))) policySyncCounter.WithLabelValues("success").Inc() } - return nil + return false, nil } func (u *PolicyUpdater) Watch(ctx context.Context, notifier persist.Watcher) { @@ -87,8 +102,7 @@ func (u *PolicyUpdater) Watch(ctx context.Context, notifier persist.Watcher) { for { select { case <-ticker.C: - - if err := u.Sync(ctx); err != nil { + if update, err := u.Sync(ctx); err != nil || !update { log.Errorf("Policy sync failed: %v", err) continue } From 5f6c32ccb4d29eede945340c0638678e3a1ed9b3 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 21 Apr 2025 15:43:33 +0800 Subject: [PATCH 009/158] fix(authz): correct return value and optimize policy update logic - Move return statement to cover all case branches - Remove redundant return statements in individual cases - Ensure consistent return value placement at the end of the function --- contrib/security/authz/casbin/update.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/security/authz/casbin/update.go b/contrib/security/authz/casbin/update.go index 664b3110..327fb3af 100644 --- a/contrib/security/authz/casbin/update.go +++ b/contrib/security/authz/casbin/update.go @@ -77,7 +77,6 @@ func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { switch setter := u.adapter.(type) { case *adapter: setter.typedPolicies = policies - return true, nil case security.PolicyRegistry: pm := maps.Transform(policies, func(k string, v [][]string) (string, any, bool) { return k, any(v), true @@ -85,12 +84,12 @@ func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { if err := setter.SetPolicies(ctx, pm); err != nil { return false, err } - return true, nil default: return false, errors.New("unsupported adapter") } policyCountGauge.Set(float64(len(policies))) policySyncCounter.WithLabelValues("success").Inc() + return true, nil } return false, nil } From 4bf6b118d943af1584d98db6ca86dfc9f69107e4 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 21 Apr 2025 15:53:08 +0800 Subject: [PATCH 010/158] refactor(authz): rename and restructure Casbin authorizer options - Rename AuthorizerOptions fields for clarity and consistency - Update option.go to use new field names - Modify casbin.go to use new ServiceClient field - Update database.tpl files to use new ServiceClient naming convention - Refactor agent/http.go to use new AuthorizerOptions structure --- contrib/security/authz/casbin/casbin.go | 4 +- contrib/security/authz/casbin/option.go | 55 +++++++++++++++---- internal/mods/agent/http.go | 8 +-- .../dal/entity/ent/template/database.tpl | 2 +- .../dal/entity/ent/template/database.tpl | 2 +- 5 files changed, 53 insertions(+), 18 deletions(-) diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index 0e89bb53..5ce423f0 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -172,12 +172,12 @@ func NewAuthorizer(cfg *configv1.Security, enablePrometheus bool, ss ...Authoriz } options := settings.ApplyDefault(DefaultAuthorizerOptions, ss) - if options.Client == nil { + if options.ServiceClient == nil { return nil, errors.New("authorizer casbin client is empty") } updater := &PolicyUpdater{ - client: options.Client, + client: options.ServiceClient, adapter: options.Adapter, interval: options.SyncInterval, } diff --git a/contrib/security/authz/casbin/option.go b/contrib/security/authz/casbin/option.go index cb5dd942..ea0c1bbe 100644 --- a/contrib/security/authz/casbin/option.go +++ b/contrib/security/authz/casbin/option.go @@ -15,19 +15,32 @@ import ( "origadmin/application/admin/contrib/security/authz/casbin/internal/model" ) +// AuthorizerOptions contains configuration parameters for Casbin authorizer +// Model: Required, Casbin model definition +// Adapter: Required, policy persistence adapter +// Watcher: Optional, policy change watcher +// Enforcer: Optional, existing synced enforcer instance +// SyncInterval: Optional, policy sync interval (default 5s) +// ServiceClient: gRPC client for policy data service +// WildcardItem: Permission matching wildcard (default "*") type AuthorizerOptions struct { - Model casbinmodel.Model // Need - Adapter persist.Adapter // Need - Watcher persist.Watcher // Optional - Enforcer *casbin.SyncedEnforcer // Optional - SyncInterval time.Duration // Optional - Client pb.CasbinSourceServiceClient // gRPC client - WildcardItem string + Model casbinmodel.Model + Adapter persist.Adapter + Watcher persist.Watcher + Enforcer *casbin.SyncedEnforcer + SyncInterval time.Duration + ServiceClient pb.CasbinSourceServiceClient + WildcardItem string } -// AuthorizerOption is a function type for setting the Authenticator. +// AuthorizerOption function type for configuring AuthorizerOptions type AuthorizerOption = func(*AuthorizerOptions) +// Default configuration parameters for authorizer +// Model: Creates new empty model +// Watcher: Initializes new watcher instance +// SyncInterval: 5s sync interval +// WildcardItem: Wildcard "*" var ( DefaultAuthorizerOptions = AuthorizerOptions{ Model: casbinmodel.NewModel(), @@ -37,66 +50,88 @@ var ( } ) +// DefaultModel provides default RESTful role-based model definition +// Returns: Predefined RBAC with RESTful model string func DefaultModel() string { return model.DefaultRestfullWithRoleModel } +// WithModel sets custom Casbin model configuration +// model: Casbin model instance to use func WithModel(model casbinmodel.Model) AuthorizerOption { return func(s *AuthorizerOptions) { s.Model = model } } +// WithStringModel configures model from definition string +// str: Model definition string in Casbin syntax func WithStringModel(str string) AuthorizerOption { return func(s *AuthorizerOptions) { s.Model, _ = casbinmodel.NewModelFromString(str) } } +// WithFileModel loads model configuration from file +// path: Path to model configuration file func WithFileModel(path string) AuthorizerOption { return func(s *AuthorizerOptions) { s.Model, _ = casbinmodel.NewModelFromFile(path) } } +// WithNameModel sets model using predefined model name +// name: Predefined model name from internal/model package func WithNameModel(name string) AuthorizerOption { return func(s *AuthorizerOptions) { s.Model, _ = casbinmodel.NewModelFromString(model.MustModel(name)) } } +// WithPolicyAdapter sets policy storage adapter +// adapter: Persistence adapter instance (database/file/etc) func WithPolicyAdapter(adapter persist.Adapter) AuthorizerOption { return func(s *AuthorizerOptions) { s.Adapter = adapter } } +// WithWatcher sets policy change watcher +// watcher: Watcher implementation for cluster synchronization func WithWatcher(watcher persist.Watcher) AuthorizerOption { return func(s *AuthorizerOptions) { s.Watcher = watcher } } +// WithSyncInterval sets policy synchronization interval +// interval: Duration between policy sync operations func WithSyncInterval(interval time.Duration) AuthorizerOption { return func(s *AuthorizerOptions) { s.SyncInterval = interval } } +// WithEnforcer reuses existing enforcer instance +// enforcer: Preconfigured synced enforcer instance func WithEnforcer(enforcer *casbin.SyncedEnforcer) AuthorizerOption { return func(s *AuthorizerOptions) { s.Enforcer = enforcer } } +// WithWildcardItem sets permission matching wildcard +// item: Wildcard symbol for policy matching (default "*") func WithWildcardItem(item string) AuthorizerOption { return func(s *AuthorizerOptions) { s.WildcardItem = item } } -func WithClient(client pb.CasbinSourceServiceClient) AuthorizerOption { +// WithServiceClient sets gRPC policy source service client +// client: gRPC client implementing CasbinSourceService +func WithServiceClient(client pb.CasbinSourceServiceClient) AuthorizerOption { return func(s *AuthorizerOptions) { - s.Client = client + s.ServiceClient = client } } diff --git a/internal/mods/agent/http.go b/internal/mods/agent/http.go index bbfdadba..3f7d2e6e 100644 --- a/internal/mods/agent/http.go +++ b/internal/mods/agent/http.go @@ -57,9 +57,9 @@ func NewHTTPServerAgent(bootstrap *configs.Bootstrap, registrars []ServerRegiste if err != nil { panic(err) } - casbinOpts := &casbin.Options{ - PolicyAdapter: casbin.NewAdapter(), - ServiceClient: client, + casbinOpts := &casbin.AuthorizerOptions{ + PolicyAdapter: casbin.NewAdapter(), + ServiceClient: client, } authorizer, err := securityx.NewAuthorizer(bootstrap, casbinOpts) if err != nil { @@ -140,7 +140,7 @@ func CallerMiddleware() middleware.KMiddleware { tr, ok := transport.FromServerContext(ctx) log.Infof("Caller Server: %+v, ok: %+v", tr, ok) tr, ok = transport.FromClientContext(ctx) - log.Infof("Caller Client: %+v, ok: %+v", tr, ok) + log.Infof("Caller ServiceClient: %+v, ok: %+v", tr, ok) return handler(ctx, req) } } diff --git a/internal/mods/casbin/dal/entity/ent/template/database.tpl b/internal/mods/casbin/dal/entity/ent/template/database.tpl index 9af6629c..c5f9c208 100644 --- a/internal/mods/casbin/dal/entity/ent/template/database.tpl +++ b/internal/mods/casbin/dal/entity/ent/template/database.tpl @@ -106,7 +106,7 @@ } {{ range $n := $.Nodes }} - {{ $client := print $n.Name "Client" }} + {{ $client := print $n.Name "ServiceClient" }} // {{ $n.Name }} is the client for interacting with the {{ $n.Name }} builders. func (db *Database) {{ $n.Name }}(ctx context.Context) *{{ $client }} { return db.Client(ctx).{{ $n.Name }} diff --git a/internal/mods/system/dal/entity/ent/template/database.tpl b/internal/mods/system/dal/entity/ent/template/database.tpl index fac750a0..727b0146 100644 --- a/internal/mods/system/dal/entity/ent/template/database.tpl +++ b/internal/mods/system/dal/entity/ent/template/database.tpl @@ -112,7 +112,7 @@ } {{ range $n := $.Nodes }} - {{ $client := print $n.Name "Client" }} + {{ $client := print $n.Name "ServiceClient" }} // {{ $n.Name }} is the client for interacting with the {{ $n.Name }} builders. func (db *Database) {{ $n.Name }}(ctx context.Context) *{{ $client }} { return db.Client(ctx).{{ $n.Name }} From 98e448b734a7d4199c81c8e515e2db2734f84d82 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 21 Apr 2025 16:12:06 +0800 Subject: [PATCH 011/158] refactor(authz): Refactored the casbin delegate and added support for Prometheus metrics - Refactored the Authorizer.Apply() method to optimize the configuration loading logic - Added Prometheus metric support as an optional configuration - Modified the PolicyUpdater synchronization logic to support Prometheus metrics - Updated the AuthorizerOptions struct to include the EnablePrometheus field - Optimized the NewAuthorizer function to pass the configuration in variadic mode --- contrib/security/authz/casbin/casbin.go | 36 +++++++++++++------------ contrib/security/authz/casbin/option.go | 25 +++++++++++------ contrib/security/authz/casbin/update.go | 11 +++++--- internal/mods/agent/http.go | 9 +++---- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index 5ce423f0..9219b79b 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -129,30 +129,27 @@ func (auth *Authorizer) SetPolicies(ctx context.Context, policies map[string]any func (auth *Authorizer) Apply() error { var err error - if auth.options.Adapter == nil { - auth.adapter = NewAdapter(nil) + auth.adapter = NewAdapter(nil) + if auth.options.Adapter != nil { + auth.adapter = auth.options.Adapter } - if auth.options.Model == nil { - auth.model, err = casbinmodel.NewModelFromString(DefaultModel()) - if err != nil { - return err - } + auth.model, err = casbinmodel.NewModelFromString(DefaultModel()) + if err != nil { + return err + } + if auth.options.Model != nil { + auth.model = auth.options.Model } - if auth.options.Watcher == nil { - auth.watcher = NewWatcher() + auth.watcher = NewWatcher() + if auth.options.Watcher != nil { + auth.watcher = auth.options.Watcher } if auth.model == nil || auth.adapter == nil { return errors.New("model and adapter cannot be nil") } - if auth.options.WildcardItem == "" { auth.wildcardItem = "*" } - - auth.enforcer, err = casbin.NewSyncedEnforcer(auth.model, auth.adapter) - if err != nil { - return err - } return nil } @@ -165,7 +162,7 @@ func NewDefaultAuthorizer() *Authorizer { } } -func NewAuthorizer(cfg *configv1.Security, enablePrometheus bool, ss ...AuthorizerOption) (security.Authorizer, error) { +func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Authorizer, error) { config := cfg.GetAuthz().GetCasbin() if config == nil { return nil, errors.New("authorizer casbin config is empty") @@ -180,6 +177,7 @@ func NewAuthorizer(cfg *configv1.Security, enablePrometheus bool, ss ...Authoriz client: options.ServiceClient, adapter: options.Adapter, interval: options.SyncInterval, + metric: options.EnablePrometheus, } auth := &Authorizer{ @@ -191,6 +189,10 @@ func NewAuthorizer(cfg *configv1.Security, enablePrometheus bool, ss ...Authoriz if err := auth.Apply(); err != nil { return nil, err } + _, err := updater.Sync(context.Background()) + if err != nil { + return nil, err + } enforcer, err := casbin.NewSyncedEnforcer(auth.model, auth.adapter) if err != nil { @@ -204,7 +206,7 @@ func NewAuthorizer(cfg *configv1.Security, enablePrometheus bool, ss ...Authoriz go updater.Watch(context.Background(), auth.watcher) - if enablePrometheus { + if options.EnablePrometheus { prometheus.MustRegister( policySyncCounter, policyCountGauge, diff --git a/contrib/security/authz/casbin/option.go b/contrib/security/authz/casbin/option.go index ea0c1bbe..4c68ee77 100644 --- a/contrib/security/authz/casbin/option.go +++ b/contrib/security/authz/casbin/option.go @@ -24,19 +24,20 @@ import ( // ServiceClient: gRPC client for policy data service // WildcardItem: Permission matching wildcard (default "*") type AuthorizerOptions struct { - Model casbinmodel.Model - Adapter persist.Adapter - Watcher persist.Watcher - Enforcer *casbin.SyncedEnforcer - SyncInterval time.Duration - ServiceClient pb.CasbinSourceServiceClient - WildcardItem string + Model casbinmodel.Model + Adapter persist.Adapter + Watcher persist.Watcher + Enforcer *casbin.SyncedEnforcer + SyncInterval time.Duration + ServiceClient pb.CasbinSourceServiceClient + WildcardItem string + EnablePrometheus bool } // AuthorizerOption function type for configuring AuthorizerOptions type AuthorizerOption = func(*AuthorizerOptions) -// Default configuration parameters for authorizer +// DefaultAuthorizerOptions parameters for authorizer // Model: Creates new empty model // Watcher: Initializes new watcher instance // SyncInterval: 5s sync interval @@ -135,3 +136,11 @@ func WithServiceClient(client pb.CasbinSourceServiceClient) AuthorizerOption { s.ServiceClient = client } } + +// WithPrometheusMetrics enables Prometheus metrics collection +// enable: Enable Prometheus metrics collection (default false) +func WithPrometheusMetrics(enable bool) AuthorizerOption { + return func(s *AuthorizerOptions) { + s.EnablePrometheus = enable + } +} diff --git a/contrib/security/authz/casbin/update.go b/contrib/security/authz/casbin/update.go index 327fb3af..250605e8 100644 --- a/contrib/security/authz/casbin/update.go +++ b/contrib/security/authz/casbin/update.go @@ -27,12 +27,15 @@ type PolicyUpdater struct { enforcer *casbin.SyncedEnforcer lastModified int64 interval time.Duration + metric bool } func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { start := time.Now() defer func() { - policySyncDuration.Observe(time.Since(start).Seconds()) + if u.metric { + policySyncDuration.Observe(time.Since(start).Seconds()) + } }() update, err := u.client.WatchUpdate(ctx, &pb.WatchUpdateRequest{ @@ -87,8 +90,10 @@ func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { default: return false, errors.New("unsupported adapter") } - policyCountGauge.Set(float64(len(policies))) - policySyncCounter.WithLabelValues("success").Inc() + if u.metric { + policyCountGauge.Set(float64(len(policies))) + policySyncCounter.WithLabelValues("success").Inc() + } return true, nil } return false, nil diff --git a/internal/mods/agent/http.go b/internal/mods/agent/http.go index 3f7d2e6e..c264eb48 100644 --- a/internal/mods/agent/http.go +++ b/internal/mods/agent/http.go @@ -57,11 +57,10 @@ func NewHTTPServerAgent(bootstrap *configs.Bootstrap, registrars []ServerRegiste if err != nil { panic(err) } - casbinOpts := &casbin.AuthorizerOptions{ - PolicyAdapter: casbin.NewAdapter(), - ServiceClient: client, - } - authorizer, err := securityx.NewAuthorizer(bootstrap, casbinOpts) + + opts := []casbin.AuthorizerOption{casbin.WithServiceClient(client)} + + authorizer, err := securityx.NewAuthorizer(bootstrap, opts...) if err != nil { panic(err) } From 599e146bd78c6de180905484dd691d211dc5039b Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 21 Apr 2025 17:27:39 +0800 Subject: [PATCH 012/158] refactor(authz): simplify and restructure casbin authorizer - Remove unnecessary fields and methods from Authorizer struct - Extract option setup logic to AuthorizerOptions - Simplify UpdateRules and WatchUpdate logic - Improve logging and error handling - Update test cases to use new AuthorizerOptions --- contrib/security/authz/casbin/casbin.go | 106 ++++++++----------- contrib/security/authz/casbin/option.go | 20 +++- contrib/security/authz/casbin/update.go | 14 ++- internal/mock/token_test.go | 3 +- internal/mods/agent/auth_test.go | 2 +- internal/mods/system/biz/casbin.biz.go | 7 +- internal/mods/system/service/casbin.authz.go | 68 ------------ internal/mods/system/service/casbin.grpc.go | 5 + 8 files changed, 82 insertions(+), 143 deletions(-) delete mode 100644 internal/mods/system/service/casbin.authz.go diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index 9219b79b..604ee8a4 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -23,14 +23,12 @@ import ( // Authorizer is a struct that implements the Authorizer interface. type Authorizer struct { - options *AuthorizerOptions - enforcer *casbin.SyncedEnforcer - updater *PolicyUpdater - wildcardItem string - model casbinmodel.Model - adapter persist.Adapter - watcher persist.Watcher - enablePrometheus bool + enforcer *casbin.SyncedEnforcer + updater *PolicyUpdater + wildcardItem string + model casbinmodel.Model + adapter persist.Adapter + watcher persist.Watcher } const MaxRetryDelay = time.Minute @@ -88,7 +86,14 @@ func (auth *Authorizer) enforce(ctx context.Context, subject, object, action, do log.Errorf("Authorization error: %auth", err) return false, err } - log.Debugf("Authorization result: %t for %s %s %s %s", allowed, subject, object, action, domain) + if !allowed { + log.Debugf("Authorization result: %t for %s %s %s %s", allowed, subject, object, action, domain) + } + policy, err := auth.enforcer.GetPolicy() + if err != nil { + return false, err + } + log.Infof("Authorization policy %v", policy) return allowed, nil } @@ -127,41 +132,6 @@ func (auth *Authorizer) SetPolicies(ctx context.Context, policies map[string]any return nil } -func (auth *Authorizer) Apply() error { - var err error - auth.adapter = NewAdapter(nil) - if auth.options.Adapter != nil { - auth.adapter = auth.options.Adapter - } - auth.model, err = casbinmodel.NewModelFromString(DefaultModel()) - if err != nil { - return err - } - if auth.options.Model != nil { - auth.model = auth.options.Model - } - auth.watcher = NewWatcher() - if auth.options.Watcher != nil { - auth.watcher = auth.options.Watcher - } - if auth.model == nil || auth.adapter == nil { - return errors.New("model and adapter cannot be nil") - } - if auth.options.WildcardItem == "" { - auth.wildcardItem = "*" - } - return nil -} - -func NewDefaultAuthorizer() *Authorizer { - model, _ := casbinmodel.NewModelFromString(DefaultModel()) - return &Authorizer{ - model: model, - adapter: NewAdapter(nil), - enablePrometheus: false, - } -} - func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Authorizer, error) { config := cfg.GetAuthz().GetCasbin() if config == nil { @@ -172,6 +142,10 @@ func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Aut if options.ServiceClient == nil { return nil, errors.New("authorizer casbin client is empty") } + err := options.Setup() + if err != nil { + return nil, err + } updater := &PolicyUpdater{ client: options.ServiceClient, @@ -180,32 +154,16 @@ func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Aut metric: options.EnablePrometheus, } - auth := &Authorizer{ - options: options, - updater: updater, - wildcardItem: options.WildcardItem, - } - - if err := auth.Apply(); err != nil { - return nil, err - } - _, err := updater.Sync(context.Background()) + _, err = updater.Sync(context.Background()) if err != nil { return nil, err } - - enforcer, err := casbin.NewSyncedEnforcer(auth.model, auth.adapter) + auth, err := authorizerFromOptions(updater, options) if err != nil { return nil, err } - auth.enforcer = enforcer - - if err := auth.enforcer.SetWatcher(auth.watcher); err != nil { - return nil, err - } - - go updater.Watch(context.Background(), auth.watcher) + go updater.Watch(context.Background(), options.Watcher) if options.EnablePrometheus { prometheus.MustRegister( policySyncCounter, @@ -216,3 +174,25 @@ func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Aut return auth, nil } + +func authorizerFromOptions(updater *PolicyUpdater, options *AuthorizerOptions) (security.Authorizer, error) { + auth := &Authorizer{ + model: options.Model, + adapter: options.Adapter, + watcher: options.Watcher, + wildcardItem: options.WildcardItem, + updater: updater, + } + enforcer, err := casbin.NewSyncedEnforcer(auth.model, auth.adapter) + if err != nil { + return nil, err + } + if err := enforcer.SetWatcher(auth.watcher); err != nil { + return nil, err + } + auth.enforcer = enforcer + if auth.model == nil || auth.adapter == nil { + return nil, errors.New("authorizer casbin model or adapter is empty") + } + return auth, nil +} diff --git a/contrib/security/authz/casbin/option.go b/contrib/security/authz/casbin/option.go index 4c68ee77..10a93363 100644 --- a/contrib/security/authz/casbin/option.go +++ b/contrib/security/authz/casbin/option.go @@ -44,7 +44,6 @@ type AuthorizerOption = func(*AuthorizerOptions) // WildcardItem: Wildcard "*" var ( DefaultAuthorizerOptions = AuthorizerOptions{ - Model: casbinmodel.NewModel(), Watcher: NewWatcher(), SyncInterval: 5 * time.Second, WildcardItem: "*", @@ -144,3 +143,22 @@ func WithPrometheusMetrics(enable bool) AuthorizerOption { s.EnablePrometheus = enable } } + +func (s *AuthorizerOptions) Setup() error { + if s.Adapter == nil { + s.Adapter = NewAdapter(nil) + } + + if s.Model == nil { + var err error + s.Model, err = casbinmodel.NewModelFromString(DefaultModel()) + if err != nil { + return err + } + } + + if s.Watcher == nil { + s.Watcher = NewWatcher() + } + return nil +} diff --git a/contrib/security/authz/casbin/update.go b/contrib/security/authz/casbin/update.go index 250605e8..8dc4d2ec 100644 --- a/contrib/security/authz/casbin/update.go +++ b/contrib/security/authz/casbin/update.go @@ -8,6 +8,7 @@ package casbin import ( "context" "errors" + "fmt" "io" "time" @@ -44,11 +45,10 @@ func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { if err != nil { return false, err } - if u.lastModified >= update.ModifiedDate { + if u.lastModified > update.ModifiedDate { return false, nil } - u.lastModified = update.ModifiedDate - + fmt.Printf("Received update: %v to %v\n", u.lastModified, update.ModifiedDate) stream, err := u.client.StreamRules(ctx, &pb.StreamRulesRequest{ WithGroupings: true, WithPolicies: true, @@ -76,11 +76,13 @@ func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { } if len(policies) > 0 { - u.lastModified = time.Now().Unix() + fmt.Printf("Adapter: %T\n", u.adapter) switch setter := u.adapter.(type) { case *adapter: + log.Infof("set policies(inner): %v", policies) setter.typedPolicies = policies case security.PolicyRegistry: + log.Infof("set policies: %v", policies) pm := maps.Transform(policies, func(k string, v [][]string) (string, any, bool) { return k, any(v), true }) @@ -94,6 +96,10 @@ func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { policyCountGauge.Set(float64(len(policies))) policySyncCounter.WithLabelValues("success").Inc() } + + u.lastModified = time.Now().Unix() + //todo: update lastModified + //u.lastModified = update.ModifiedDate return true, nil } return false, nil diff --git a/internal/mock/token_test.go b/internal/mock/token_test.go index eb422eea..4c935875 100644 --- a/internal/mock/token_test.go +++ b/internal/mock/token_test.go @@ -15,6 +15,7 @@ import ( "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/toolkits/security" + "origadmin/application/admin/contrib/security/authz/casbin" "origadmin/application/admin/helpers/securityx" "origadmin/application/admin/internal/loader" "origadmin/application/admin/internal/mods/system/dal" @@ -106,7 +107,7 @@ func TestGenerateToken(t *testing.T) { panic(err) } //adapter := casbin.NewAdapter() - authorizer, err := securityx.NewAuthorizer(bs) + authorizer, err := securityx.NewAuthorizer(bs, casbin.WithServiceClient(casbinSourceServiceClient)) if err != nil { panic(err) } diff --git a/internal/mods/agent/auth_test.go b/internal/mods/agent/auth_test.go index b97d46af..24be6176 100644 --- a/internal/mods/agent/auth_test.go +++ b/internal/mods/agent/auth_test.go @@ -39,7 +39,7 @@ var bridge = securityx.SecurityBridge{ IsRoot: func(ctx context.Context, claims security.Claims) bool { return claims.GetSubject() == "admin" }, - Data: mockData{}, + Provider: mockData{}, //TokenParser: func(ctx context.Context) string { // if tr, ok := transport.FromServerContext(ctx); ok { // return tr.RequestHeader().Get("Authorization") diff --git a/internal/mods/system/biz/casbin.biz.go b/internal/mods/system/biz/casbin.biz.go index 927baf9e..5bb9d239 100644 --- a/internal/mods/system/biz/casbin.biz.go +++ b/internal/mods/system/biz/casbin.biz.go @@ -56,14 +56,11 @@ func (c CasbinSourceServiceBiz) ListGroupings(ctx context.Context, in *pb.ListGr func (c CasbinSourceServiceBiz) WatchUpdate(_ context.Context, request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { log.Info("WatchUpdate") - ModifiedDate := request.LastModified - if c.lastModified.Load() > ModifiedDate { - ModifiedDate = c.lastModified.Load() - } - return &pb.WatchUpdateResponse{ModifiedDate: ModifiedDate}, nil + return &pb.WatchUpdateResponse{ModifiedDate: c.lastModified.Load()}, nil } func (c CasbinSourceServiceBiz) UpdateRules() { + // todo: load from db c.lastModified.Store(time.Now().Unix()) } diff --git a/internal/mods/system/service/casbin.authz.go b/internal/mods/system/service/casbin.authz.go deleted file mode 100644 index 2383969f..00000000 --- a/internal/mods/system/service/casbin.authz.go +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package service implements the functions, types, and interfaces for the moduls.enforcer. -package service - -import ( - "sync" - "time" - - "github.com/casbin/casbin/v2/persist" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/contrib/security/authz/casbin" -) - -type CasbinAuthorizerService struct { - client pb.CasbinSourceServiceClient - adapter persist.Adapter - mu sync.RWMutex - callback func(string) - interval time.Duration - wildcardItem string - lastModified int64 -} - -func (s *CasbinAuthorizerService) SetUpdateCallback(callback func(string)) error { - s.mu.Lock() - defer s.mu.Unlock() - s.callback = callback - return nil -} - -func (s *CasbinAuthorizerService) Update() error { - s.mu.RLock() - defer s.mu.RUnlock() - if s.callback != nil { - s.callback("update") - } - return nil -} - -func (s *CasbinAuthorizerService) Close() { - s.mu.Lock() - defer s.mu.Unlock() - s.callback = nil - //s.adapter.Close() -} - -// NewCasbinAuthorizerService new a casbin service. -func NewCasbinAuthorizerService(client pb.CasbinSourceServiceClient) *CasbinAuthorizerService { - return &CasbinAuthorizerService{ - client: client, - adapter: casbin.NewAdapter(nil), - callback: nil, - interval: 5 * time.Second, - wildcardItem: "*", - lastModified: 0, - } -} - -func NewCasbinSourceServiceClient(client *service.GRPCClient) pb.CasbinSourceServiceClient { - return pb.NewCasbinSourceServiceClient(client) -} - -var _ persist.Watcher = (*CasbinAuthorizerService)(nil) diff --git a/internal/mods/system/service/casbin.grpc.go b/internal/mods/system/service/casbin.grpc.go index eaf439f9..20ad37c5 100644 --- a/internal/mods/system/service/casbin.grpc.go +++ b/internal/mods/system/service/casbin.grpc.go @@ -9,6 +9,7 @@ import ( "context" "github.com/casbin/casbin/v2" + "github.com/origadmin/runtime/service" "google.golang.org/grpc" pb "origadmin/application/admin/api/v1/services/system" @@ -49,4 +50,8 @@ func NewCasbinSourceServiceServerPB(client *biz.CasbinSourceServiceBiz) pb.Casbi return &CasbinSourceServiceServer{client: client} } +func NewCasbinSourceServiceClient(client *service.GRPCClient) pb.CasbinSourceServiceClient { + return pb.NewCasbinSourceServiceClient(client) +} + var _ pb.CasbinSourceServiceServer = (*CasbinSourceServiceServer)(nil) From 624c6efffeeeb350935ee9c09e26008edfe6e422 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 21 Apr 2025 19:54:32 +0800 Subject: [PATCH 013/158] build(mod): update Go toolchain and dependencies - Update Go toolchain to go1.23.8 - Upgrade github.com/casbin/casbin/v2 from v2.104.0 to v2.105.0 - Remove github.com/go-sql-driver/mysql - Upgrade github.com/origadmin/toolkits from v0.2.14 to v0.2.16 - Upgrade github.com/prometheus/client_golang from v1.21.1 to v1.22.0 - Upgrade google.golang.org/grpc from v1.71.0 to v1.72.0 - Upgrade github.com/fsnotify/fsnotify from v1.8.0 to v1.9.0 - Upgrade github.com/gabriel-vasile/mimetype from v1.4.8 to v1.4.9 - Upgrade github.com/gin-contrib/sse from v1.0.0 to v1.1.0 - Upgrade github.com/go-playground/validator/v10 from v10.25.0 to v10.26.0 - Add github.com/go-sql-driver/mysql as an indirect dependency - Add github.com/godcong/go-locale/v2 as a new dependency - Add github.com/iancoleman/strcase as a new dependency - Add github.com/lyft/protoc-gen-star/v2 as a new dependency - Add github.com/spf13/afero as a new dependency - Upgrade github.com/pelletier/go-toml/v2 from v2.2.3 to v2.2.4 - Upgrade github.com/mattn/go-sqlite3 from v1.14.24 to v1.14.28 - Upgrade golang.org/x/arch from v0.15.0 to v0.16.0 - Upgrade golang.org/x/crypto from v0.36.0 to v0.37.0 - Upgrade golang.org/x/exp from v0.0.0-20250305212735-054e65f0b394 to v0.0.0-20250408133849-7e4ce0ab07d0 - Upgrade golang.org/x/image from v0.25.0 to v0.26.0 - Upgrade golang.org/x/text from v0.23.0 to v0.24.0 - Upgrade golang.org/x/tools from v0.31.0 to v0.32.0 - Upgrade google.golang.org/genproto/googleapis/rpc from v0.0.0-20250324211829-b45e905df463 to v0.0.0-20250414145226-207652e42e2e- Upgrade modernc.org/libc from v1.61.13 to v1.63.0 - Upgrade modernc.org/memory from v1.9.1 to v1.10.0 - Upgrade modernc.org/sqlite from v1.36.2 to v1.37.0 --- README.md | 113 +++++++++++++++++++++++++++++++++--------------------- go.mod | 75 ++++++++++++++++++++---------------- go.sum | 84 ++++++++++++++++++++++++++++++++++++++-- main.go | 1 - 4 files changed, 191 insertions(+), 82 deletions(-) diff --git a/README.md b/README.md index a6703c1c..23370476 100644 --- a/README.md +++ b/README.md @@ -4,52 +4,79 @@ This is the backend for the project `OrigAdmin` ## Introduction +The architecture diagram demonstrates a multi-layered directory structure where each directory serves specific +functionalities: + +1. **api**: Houses API-related implementations with subdirectories: + - `http`: HTTP interface definitions + - `multiplatform`: Cross-platform interfaces + - `proto`: Protocol Buffer definitions + - `services`: Service implementations + +2. **cmd**: Contains CLI tool implementations with subdirectories: + - `internal`: Core CLI logic + - `multiplatform`: Platform-agnostic commands + - `root.go`: Root command definitions + - `system`: System management commands + +3. **data**: Stores data files (e.g., admin.db) for persistent storage. + +4. **generate.go**: Code generation utilities. + +5. **helpers**: Utility modules including: + - `command`: CLI toolkit + - `ent`: Entity management + - `errors`: Error handling framework + - `protobuf`: Protocol Buffer utilities + - `resp`: Response handlers + +6. **internal**: Core internal components: + - `configs`: Configuration management + - `generate.go`: Internal code generators + - `loader`: Resource loading system + - `mods`: Modular components + +7. **main.go**: Application entry point with initialization logic. + +8. **Makefile**: Build automation scripts. + +9. **resources**: Resource files including: + - `configs`: Configuration templates + - `docs`: Documentation assets + +10. **third_party**: External dependencies' integration: + - Authentication systems + - Code generation tools + - Configuration management + - Error handling libraries + - Protocol Buffer extensions + - Google API integrations + - Pagination utilities + - Token management + - Validation frameworks + +This project provides a comprehensive API service solution featuring HTTP interfaces, cross-platform support, protocol +definitions, and service implementations, complemented by configuration management, code generation, and modular +architecture. + +## Getting Started -这个项目的架构图展示了一个多层次的目录结构,每个目录都有特定的功能和用途。以下是对每个目录的详细解释: - -1. **.github**:这个目录包含了GitHub相关的配置文件,如CODE_OF_CONDUCT.md、CONTRIBUTING.md、ISSUE_TEMPLATE等,用于管理和指导项目的开发和使用。 - -2. **api**:这个目录包含了API相关的代码,包括HTTP、multiplatform、proto和services等子目录。这些子目录分别用于定义HTTP接口、多平台接口、协议文件和服务代码。 - -3. **cmd**:这个目录包含了命令行工具的代码,包括internal、multiplatform、root.go和system等子目录。这些子目录分别用于定义命令行工具的内部逻辑、多平台逻辑、根命令和系统命令。 - -4. **data**:这个目录包含了数据相关的文件,如admin.db,用于存储项目所需的数据。 - -5. **generate.go**:这个文件包含了代码生成相关的代码,用于生成项目所需的代码文件。 - -6. **go.sum**:这个文件包含了项目依赖的校验和,用于确保依赖的一致性和安全性。 - -7. **helpers**:这个目录包含了辅助工具的代码,如command、ent、errors、protobuf和resp等子目录。这些子目录分别用于定义命令行工具、实体、错误处理、协议缓冲区和响应处理等辅助功能。 - -8. **internal**:这个目录包含了项目内部使用的代码,如configs、generate.go、loader和mods等子目录。这些子目录分别用于定义配置、代码生成、加载器和模块等内部功能。 - -9. **LICENSE**:这个文件包含了项目的许可证信息。 - -10. **main.go**:这个文件是项目的入口点,包含了项目的初始化和启动逻辑。 - -11. **Makefile**:这个文件包含了项目的构建和打包命令。 - -12. **README.md**:这个文件包含了项目的介绍和文档。 - -13. **resources**:这个目录包含了项目的资源文件,如configs和docs等子目录。这些子目录分别用于定义配置文件和文档文件。 +1. Clone the repository -14. **third_party**:这个目录包含了第三方库的代码,如auth、buf、config、errors、gnostic、google、options、pagination、pwt、README.md和validate等子目录。这些子目录分别用于定义认证、代码生成、配置、错误处理、协议缓冲区、谷歌API、选项、分页、令牌、README.md和验证等第三方功能。 + ```bash + # git clone URL_ADDRESS + git clone https://github.com/OrigAdmin/backend.git + ``` -总的来说,这个项目是一个多层次的目录结构,每个目录都有特定的功能和用途。这个项目的目的是提供一套完整的API服务,包括HTTP接口、多平台接口、协议文件和服务代码,以及相关的配置、代码生成、加载器和模块等内部功能。 +2. Install dependencies -1. Clone the repository + ```bash + cd backend + go mod tidy + ``` -```bash -git clone https://github.com/origadmin/admin.git -``` +3. Run the application -2. Install dependencies -```bash -cd admin -go mod tidy -``` - -3. Run the server -```bash -go run main.go start -``` \ No newline at end of file + ```bash + go run main.go start + ``` diff --git a/go.mod b/go.mod index b4e35259..eee75dec 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module origadmin/application/admin -go 1.23.1 +go 1.23.4 + +toolchain go1.23.8 replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0.5.4 @@ -8,14 +10,13 @@ require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250307204501-0409229c3780.1 entgo.io/ent v0.14.4 github.com/caarlos0/go-version v0.2.0 - github.com/casbin/casbin/v2 v2.104.0 + github.com/casbin/casbin/v2 v2.105.0 github.com/dchest/uniuri v1.2.0 github.com/envoyproxy/protoc-gen-validate v1.2.1 github.com/gin-gonic/gin v1.10.0 github.com/go-kratos/kratos/v2 v2.8.4 - github.com/go-sql-driver/mysql v1.9.1 - github.com/goexts/generic v0.2.4 - github.com/golang-cz/devslog v0.0.11 + github.com/goexts/generic v0.2.5 + github.com/golang-cz/devslog v0.0.12 github.com/golang-jwt/jwt/v5 v5.2.2 github.com/google/gnostic v0.7.0 github.com/google/uuid v1.6.0 @@ -31,24 +32,24 @@ require ( github.com/origadmin/entslog/v3 v3.0.6 github.com/origadmin/runtime v0.1.55 github.com/origadmin/slog-kratos v1.0.4 - github.com/origadmin/toolkits v0.2.14 - github.com/origadmin/toolkits/codec v0.2.14 - github.com/origadmin/toolkits/errors v0.2.14 - github.com/origadmin/toolkits/idgen v0.2.14 - github.com/origadmin/toolkits/sloge v0.2.14 - github.com/prometheus/client_golang v1.21.1 + github.com/origadmin/toolkits v0.2.16 + github.com/origadmin/toolkits/codec v0.2.16 + github.com/origadmin/toolkits/errors v0.2.16 + github.com/origadmin/toolkits/idgen v0.2.15 + github.com/origadmin/toolkits/sloge v0.2.16 + github.com/prometheus/client_golang v1.22.0 github.com/sony/sonyflake v1.2.0 github.com/spf13/cobra v1.9.1 github.com/stretchr/testify v1.10.0 - golang.org/x/net v0.37.0 - google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 - google.golang.org/grpc v1.71.0 + golang.org/x/net v0.39.0 + google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e + google.golang.org/grpc v1.72.0 google.golang.org/protobuf v1.36.6 ) require ( ariga.io/atlas v0.32.0 // indirect - cel.dev/expr v0.22.1 // indirect + cel.dev/expr v0.23.1 // indirect dario.cat/mergo v1.0.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/BurntSushi/toml v1.5.0 // indirect @@ -59,7 +60,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect - github.com/bufbuild/protovalidate-go v0.9.2 // indirect + github.com/bufbuild/protovalidate-go v0.9.3 // indirect github.com/bytedance/sonic v1.13.2 // indirect github.com/bytedance/sonic/loader v0.2.4 // indirect github.com/casbin/govaluate v1.3.0 // indirect @@ -70,9 +71,9 @@ require ( github.com/dustin/go-humanize v1.0.1 // indirect github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.8.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.8 // indirect - github.com/gin-contrib/sse v1.0.0 // indirect + github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.9 // indirect + github.com/gin-contrib/sse v1.1.0 // indirect github.com/go-kratos/aegis v0.2.0 // indirect github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250314165958-d9aa7ff19541 // indirect github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250314165958-d9aa7ff19541 // indirect @@ -83,11 +84,14 @@ require ( github.com/go-playground/form/v4 v4.2.2 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.25.0 // indirect + github.com/go-playground/validator/v10 v10.26.0 // indirect + github.com/go-sql-driver/mysql v1.9.2 // indirect github.com/goccy/go-json v0.10.5 // indirect + github.com/godcong/go-locale/v2 v2.0.0 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/cel-go v0.24.1 // indirect github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect @@ -103,6 +107,7 @@ require ( github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl/v2 v2.23.0 // indirect github.com/hashicorp/serf v0.10.2 // indirect + github.com/iancoleman/strcase v0.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect @@ -114,9 +119,10 @@ require ( github.com/lib/pq v1.10.9 // indirect github.com/lmittmann/tint v1.0.7 // indirect github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect + github.com/lyft/protoc-gen-star/v2 v2.0.4 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-sqlite3 v1.14.24 // indirect + github.com/mattn/go-sqlite3 v1.14.28 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -124,7 +130,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect - github.com/pelletier/go-toml/v2 v2.2.3 // indirect + github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect @@ -134,6 +140,7 @@ require ( github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/shirou/gopsutil/v3 v3.24.5 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/spf13/afero v1.14.0 // indirect github.com/spf13/pflag v1.0.6 // indirect github.com/sqlite3ent/sqlite3 v1.34.1 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect @@ -148,21 +155,21 @@ require ( go.opentelemetry.io/otel v1.35.0 // indirect go.opentelemetry.io/otel/metric v1.35.0 // indirect go.opentelemetry.io/otel/trace v1.35.0 // indirect - golang.org/x/arch v0.15.0 // indirect - golang.org/x/crypto v0.36.0 // indirect - golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect - golang.org/x/image v0.25.0 // indirect + golang.org/x/arch v0.16.0 // indirect + golang.org/x/crypto v0.37.0 // indirect + golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect + golang.org/x/image v0.26.0 // indirect golang.org/x/mod v0.24.0 // indirect - golang.org/x/sync v0.12.0 // indirect - golang.org/x/sys v0.31.0 // indirect - golang.org/x/text v0.23.0 // indirect - golang.org/x/tools v0.31.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect + golang.org/x/sync v0.13.0 // indirect + golang.org/x/sys v0.32.0 // indirect + golang.org/x/text v0.24.0 // indirect + golang.org/x/tools v0.32.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - modernc.org/libc v1.61.13 // indirect + modernc.org/libc v1.63.0 // indirect modernc.org/mathutil v1.7.1 // indirect - modernc.org/memory v1.9.1 // indirect - modernc.org/sqlite v1.36.2 // indirect + modernc.org/memory v1.10.0 // indirect + modernc.org/sqlite v1.37.0 // indirect ) diff --git a/go.sum b/go.sum index 2c54ee3f..0be7c23f 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-2025030720450 buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250307204501-0409229c3780.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U= cel.dev/expr v0.22.1 h1:xoFEsNh972Yzey8N9TCPx2nDvMN7TMhQEzxLuj/iRrI= cel.dev/expr v0.22.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw= +cel.dev/expr v0.23.1 h1:K4KOtPCJQjVggkARsjG9RWXP6O4R73aHeJMa/dmCQQg= +cel.dev/expr v0.23.1/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -652,6 +654,8 @@ github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/bufbuild/protovalidate-go v0.9.2 h1:dUoPvFimovS74s3eeFNvHQOxFumRPsk390ifkzJCJ/4= github.com/bufbuild/protovalidate-go v0.9.2/go.mod h1:U9+WHAa6IOrLuqQEWPcxsyE4QEOTwm9fDpVbWXsR0zU= +github.com/bufbuild/protovalidate-go v0.9.3 h1:XvdtwQuppS3wjzGfpOirsqwN5ExH2+PiIuA/XZd3MTM= +github.com/bufbuild/protovalidate-go v0.9.3/go.mod h1:2lUDP6fNd3wxznRNH3Nj64VB07+PySeslamkerwP6tE= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= @@ -662,6 +666,8 @@ github.com/caarlos0/go-version v0.2.0 h1:TTD5dF3PBAtRHbfCKRE173SrVVpbE0yX95EDQ4B github.com/caarlos0/go-version v0.2.0/go.mod h1:X+rI5VAtJDpcjCjeEIXpxGa5+rTcgur1FK66wS0/944= github.com/casbin/casbin/v2 v2.104.0 h1:qDakyBZ4jUg1VskF1+UzIwkg+uXWcp0u0M9PMm1RsTA= github.com/casbin/casbin/v2 v2.104.0/go.mod h1:Ee33aqGrmES+GNL17L0h9X28wXuo829wnNUnS0edAco= +github.com/casbin/casbin/v2 v2.105.0 h1:dLj5P6pLApBRat9SADGiLxLZjiDPvA1bsPkyV4PGx6I= +github.com/casbin/casbin/v2 v2.105.0/go.mod h1:Ee33aqGrmES+GNL17L0h9X28wXuo829wnNUnS0edAco= github.com/casbin/govaluate v1.3.0 h1:VA0eSY0M2lA86dYd5kPPuNZMUD9QkWnOCnavGrw9myc= github.com/casbin/govaluate v1.3.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -695,6 +701,7 @@ github.com/cncf/xds/go v0.0.0-20220314180256-7f1daf1720fc/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20241223141626-cff3c89139a3 h1:boJj011Hh+874zpIySeApCX4GeOjPl9qhRF3QuIZq+Q= github.com/cncf/xds/go v0.0.0-20241223141626-cff3c89139a3/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= +github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 h1:Om6kYQYDUk5wWbT0t0q6pvyM49i9XZAv9dDrkDA7gjk= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -738,11 +745,17 @@ github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/ github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= +github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= +github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY= +github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E= github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0= +github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w= +github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM= github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= @@ -792,19 +805,29 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8= github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus= +github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k= +github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= github.com/go-sql-driver/mysql v1.9.1 h1:oDr3crteKcueQ18yeWSyj52l3Qp8kh4zQlbbJFq0hLY= github.com/go-sql-driver/mysql v1.9.1/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= +github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU= +github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= +github.com/godcong/go-locale/v2 v2.0.0 h1:08Zv/U8UtuCqYqrnRgeYFv0bxVSbzKmw3Otdb96RF+s= +github.com/godcong/go-locale/v2 v2.0.0/go.mod h1:1ZOYuUVWqC9/18tdYVl2Tt2sWfms1RH3y/7hjRstZRE= github.com/goexts/generic v0.2.4 h1:RDcE/GtudVUxWb+hSP9l1jFirkWEkZHrnHfiY4WWFG4= github.com/goexts/generic v0.2.4/go.mod h1:j/ZjWHYt+If6VjeHWvDhYKdoP+gAiAKpm0cu3yvKmfo= +github.com/goexts/generic v0.2.5 h1:+TjsHnduEqQrjXcWbO/ubvOCBNbYHJ5ggvkHicz/JVY= +github.com/goexts/generic v0.2.5/go.mod h1:SZddH3gsbpBCE8JezA87mLXvM0aVrHivRWmnTn+enI4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang-cz/devslog v0.0.11 h1:v4Yb9o0ZpuZ/D8ZrtVw1f9q5XrjnkxwHF1XmWwO8IHg= github.com/golang-cz/devslog v0.0.11/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= +github.com/golang-cz/devslog v0.0.12 h1:wTwC066Qc7ag7J4coy5mBQXA6lYyaSA3ctpArcWofNg= +github.com/golang-cz/devslog v0.0.12/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= @@ -934,6 +957,7 @@ github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyE github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= @@ -982,6 +1006,8 @@ github.com/hashicorp/memberlist v0.5.2/go.mod h1:Ri9p/tRShbjYnpNf4FFPXG7wxEGY4Nr github.com/hashicorp/serf v0.10.2 h1:m5IORhuNSjaxeljg5DeQVDlQyVkhRIjJDimbkCa8aAc= github.com/hashicorp/serf v0.10.2/go.mod h1:T1CmSGfSeGfnfNy/w0odXQUR1rfECGd2Qdsp84DjOiY= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -1039,7 +1065,10 @@ github.com/lmittmann/tint v1.0.7/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr325bN2FD2ISlRRztXibcX6e8f5FR5Dc= github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= +github.com/lyft/protoc-gen-star v0.6.1 h1:erE0rdztuaDq3bpGifD95wfoPrSZc95nGA6tbiNYh6M= github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= +github.com/lyft/protoc-gen-star/v2 v2.0.4 h1:JDlNKttNIRd68AAIychs0AqEpO8/I/WYi01OQ7Raw6Q= +github.com/lyft/protoc-gen-star/v2 v2.0.4/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= @@ -1049,11 +1078,11 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM= github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= +github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE= github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY= @@ -1081,8 +1110,6 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/origadmin/contrib/consul v0.0.32 h1:OVb8xIaoblEGuPeBe0FzLRxrtOoBb43CXP6D62/5tDA= github.com/origadmin/contrib/consul v0.0.32/go.mod h1:YkCs7pFxjJz6ej3wx3OpSxp3CR/U1wBBI+8p9KYarbA= github.com/origadmin/contrib/database v0.0.32 h1:lYdvX74xczO947oMK71KASt9Xhmn1/9VB1QYv3Ft/pQ= @@ -1103,18 +1130,30 @@ github.com/origadmin/slog-kratos v1.0.4 h1:1et3TBy61Uwf5N1ZbEBFhMqCjgxqfRXmz2w0Q github.com/origadmin/slog-kratos v1.0.4/go.mod h1:WUdhcWLyN0i8TbdemqE2Y/muoj0GaZ86OcdpumAWHPo= github.com/origadmin/toolkits v0.2.14 h1:++xkMJj8xzXsUKDDQ0xvFdSyUQ8oEyJKhA8Vr1hmzo4= github.com/origadmin/toolkits v0.2.14/go.mod h1:2tU68ZT0rkSPsG8aLvkZMiZ1K0+C4ceVKbWwLND9MVk= +github.com/origadmin/toolkits v0.2.16 h1:lAUsV9asAjE8Wo4/DIZYotuQE9k00RGLTKk2kXa+ftE= +github.com/origadmin/toolkits v0.2.16/go.mod h1:kERTzbPW4e2y4LqJ38NrPje3vW8OxCECh7+JmeDJ4Ps= github.com/origadmin/toolkits/codec v0.2.14 h1:AsVMRwsEv9eL9QierH4h5QjyplFchSQCfrIiphxMYO8= github.com/origadmin/toolkits/codec v0.2.14/go.mod h1:tfK0adt9HU6cB3QfgDCKGBv92Rj3ub+XAkfX1w///KE= +github.com/origadmin/toolkits/codec v0.2.16 h1:BsmkJcxfaWGAX8AasMeeweJaaaOHjxd88cZ26Dp+id0= +github.com/origadmin/toolkits/codec v0.2.16/go.mod h1:tfK0adt9HU6cB3QfgDCKGBv92Rj3ub+XAkfX1w///KE= github.com/origadmin/toolkits/errors v0.2.14 h1:pZPiNL+LDGrLJorkX/0U1h4XtZRkjanTLyDB19cJ2gc= github.com/origadmin/toolkits/errors v0.2.14/go.mod h1:q38Ao7483Efw4gqCpPNh/Osb4DN27eHTgcCUSq8WrgI= +github.com/origadmin/toolkits/errors v0.2.16 h1:i7dlV0AwSabIa9DopDCjodciclmdroue2D5p0XOpWiw= +github.com/origadmin/toolkits/errors v0.2.16/go.mod h1:q38Ao7483Efw4gqCpPNh/Osb4DN27eHTgcCUSq8WrgI= github.com/origadmin/toolkits/idgen v0.2.14 h1:I8tm8tDQx0sgil0N6H4+dneM6M/b5D8i+KvDCKb0BLc= github.com/origadmin/toolkits/idgen v0.2.14/go.mod h1:mo95k+IJ4ZFp97jzU7oPOC5QtPasR3XnPZwbE1D/CKc= +github.com/origadmin/toolkits/idgen v0.2.15 h1:FERSchNceaKeVp6qAib+DpyFEQDfDGcQKTjWvtsUgKg= +github.com/origadmin/toolkits/idgen v0.2.15/go.mod h1:mo95k+IJ4ZFp97jzU7oPOC5QtPasR3XnPZwbE1D/CKc= github.com/origadmin/toolkits/sloge v0.2.14 h1:KEhFO8uRVOXbw8vs6h/qRwW3iSViFiGe+r1Jg1/RhTI= github.com/origadmin/toolkits/sloge v0.2.14/go.mod h1:Okm6gmOqyTK0XuW/Br2Irb33jBiNpOGmUBUF4sjCuws= +github.com/origadmin/toolkits/sloge v0.2.16 h1:AsTwcQBkx5/6RObWbcqQg6vJqHctsv7AzZA8lo4sqXQ= +github.com/origadmin/toolkits/sloge v0.2.16/go.mod h1:Okm6gmOqyTK0XuW/Br2Irb33jBiNpOGmUBUF4sjCuws= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= +github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= +github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= @@ -1141,6 +1180,8 @@ github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk= github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg= +github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q= +github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -1189,6 +1230,8 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= +github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA= +github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo= github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= @@ -1270,6 +1313,8 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw= golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE= +golang.org/x/arch v0.16.0 h1:foMtLTdyOmIniqWCHjY6+JxuC54XP1fDwx4N0ASyW+U= +golang.org/x/arch v0.16.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -1288,6 +1333,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= +golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1305,6 +1352,8 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw= golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM= +golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM= +golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1321,6 +1370,8 @@ golang.org/x/image v0.0.0-20220302094943-723b81ca9867/go.mod h1:023OzeP/+EPmXeap golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ= golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs= +golang.org/x/image v0.26.0 h1:4XjIFEZWQmCZi6Wv8BoxsDhRU3RVnLX04dToTDAEPlY= +golang.org/x/image v0.26.0/go.mod h1:lcxbMFAovzpnJxzXS3nyL83K27tmqtKzIJpctK8YO5c= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1422,6 +1473,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= +golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1472,6 +1525,8 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= +golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1566,6 +1621,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1600,6 +1657,8 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= +golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1671,6 +1730,8 @@ golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= +golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= +golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1888,10 +1949,14 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go. google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 h1:hE3bRWtU6uceqlh4fhrSnUyjKHMKB9KrTLLG+bc0ddM= google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463/go.mod h1:U90ffi8eUL9MwPcrJylN5+Mk2v3vuPDptd5yyNUiRR8= +google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e h1:UdXH7Kzbj+Vzastr5nVfccbmFsmYNygVLSPk1pEfDoY= +google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e/go.mod h1:085qFyf2+XaZlRdCgKNCIZ3afY2p4HHZdoIRpId8F4A= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 h1:e0AIkUUhxyBKh6ssZNrAMeqhA7RKUj42346d1y02i2g= google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e h1:ztQaXfzEXTmCBvbtWYRhJxW+0iJcz2qXfd38/e9l7bA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1933,6 +1998,8 @@ google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwS google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg= google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= +google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= +google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1991,6 +2058,7 @@ modernc.org/cc/v3 v3.36.2/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= modernc.org/cc/v3 v3.36.3/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= modernc.org/cc/v4 v4.24.4 h1:TFkx1s6dCkQpd6dKurBNmpo+G8Zl4Sq/ztJ+2+DEsh0= modernc.org/cc/v4 v4.24.4/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= +modernc.org/cc/v4 v4.26.0 h1:QMYvbVduUGH0rrO+5mqF/PSPPRZNpRtg2CLELy7vUpA= modernc.org/ccgo/v3 v3.0.0-20220428102840-41399a37e894/go.mod h1:eI31LL8EwEBKPpNpA4bU1/i+sKOwOrQy8D87zWUcRZc= modernc.org/ccgo/v3 v3.0.0-20220430103911-bc99d88307be/go.mod h1:bwdAnOoaIt8Ax9YdWGjxWsdkPcZyRPHqrOvJxaKAKGw= modernc.org/ccgo/v3 v3.16.4/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ= @@ -1999,11 +2067,13 @@ modernc.org/ccgo/v3 v3.16.8/go.mod h1:zNjwkizS+fIFDrDjIAgBSCLkWbJuHF+ar3QRn+Z9aw modernc.org/ccgo/v3 v3.16.9/go.mod h1:zNMzC9A9xeNUepy6KuZBbugn3c0Mc9TeiJO4lgvkJDo= modernc.org/ccgo/v4 v4.23.16 h1:Z2N+kk38b7SfySC1ZkpGLN2vthNJP1+ZzGZIlH7uBxo= modernc.org/ccgo/v4 v4.23.16/go.mod h1:nNma8goMTY7aQZQNTyN9AIoJfxav4nvTnvKThAeMDdo= +modernc.org/ccgo/v4 v4.26.0 h1:gVzXaDzGeBYJ2uXTOpR8FR7OlksDOe9jxnjhIKCsiTc= modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= modernc.org/gc/v2 v2.6.3 h1:aJVhcqAte49LF+mGveZ5KPlsp4tdGdAOT4sipJXADjw= modernc.org/gc/v2 v2.6.3/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= +modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= modernc.org/libc v0.0.0-20220428101251-2d5f3daf273b/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA= modernc.org/libc v1.16.0/go.mod h1:N4LD6DBE9cf+Dzf9buBlzVJndKr/iJHG97vGLHYnb5A= @@ -2014,6 +2084,8 @@ modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0= modernc.org/libc v1.17.1/go.mod h1:FZ23b+8LjxZs7XtFMbSzL/EhPxNbfZbErxEHc7cbD9s= modernc.org/libc v1.61.13 h1:3LRd6ZO1ezsFiX1y+bHd1ipyEHIJKvuprv0sLTBwLW8= modernc.org/libc v1.61.13/go.mod h1:8F/uJWL/3nNil0Lgt1Dpz+GgkApWh04N3el3hxJcA6E= +modernc.org/libc v1.63.0 h1:wKzb61wOGCzgahQBORb1b0dZonh8Ufzl/7r4Yf1D5YA= +modernc.org/libc v1.63.0/go.mod h1:wDzH1mgz1wUIEwottFt++POjGRO9sgyQKrpXaz3x89E= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= @@ -2024,6 +2096,8 @@ modernc.org/memory v1.2.0/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= modernc.org/memory v1.2.1/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= modernc.org/memory v1.9.1 h1:V/Z1solwAVmMW1yttq3nDdZPJqV1rM05Ccq6KMSZ34g= modernc.org/memory v1.9.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= +modernc.org/memory v1.10.0 h1:fzumd51yQ1DxcOxSO+S6X7+QTuVU+n8/Aj7swYjFfC4= +modernc.org/memory v1.10.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= @@ -2033,6 +2107,8 @@ modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJ modernc.org/sqlite v1.18.1/go.mod h1:6ho+Gow7oX5V+OiOQ6Tr4xeqbx13UZ6t+Fw9IRUG4d4= modernc.org/sqlite v1.36.2 h1:vjcSazuoFve9Wm0IVNHgmJECoOXLZM1KfMXbcX2axHA= modernc.org/sqlite v1.36.2/go.mod h1:ADySlx7K4FdY5MaJcEv86hTJ0PjedAloTUuif0YS3ws= +modernc.org/sqlite v1.37.0 h1:s1TMe7T3Q3ovQiK2Ouz4Jwh7dw4ZDqbebSDTlSJdfjI= +modernc.org/sqlite v1.37.0/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM= modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= diff --git a/main.go b/main.go index a8731c1c..031fb136 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ package main import ( goversion "github.com/caarlos0/go-version" - _ "github.com/google/wire" "origadmin/application/admin/cmd" "origadmin/application/admin/internal/loader" From 8c2ecf9e0186ba0db441b68162882906c2f99a3b Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 22 Apr 2025 16:22:28 +0800 Subject: [PATCH 014/158] build(deps): update github.com/origadmin/toolkits and related dependencies - Update github.com/origadmin/toolkits to v0.3.1 - Update related dependencies in go.mod - Modify import paths in bootstrap_test.go and database.tpl - Remove some indirect dependencies --- api/v1/proto/system/casbin.proto | 14 +-- api/v1/proto/system/types.proto | 42 +++---- api/v1/proto/system/user.proto | 20 ++- buf.lock | 4 +- go.mod | 16 +-- go.sum | 117 +++--------------- internal/loader/bootstrap_test.go | 2 +- .../system/dal/entity/ent/internal/schema.go | 2 +- .../system/dal/entity/ent/migrate/schema.go | 2 +- .../mods/system/dal/entity/ent/mutation.go | 52 ++++---- .../system/dal/entity/ent/mutation_fields.go | 10 +- .../system/dal/entity/ent/runtime/runtime.go | 12 +- .../mods/system/dal/entity/ent/schema/user.go | 4 +- .../dal/entity/ent/template/database.tpl | 4 +- internal/mods/system/dal/entity/ent/user.go | 16 +-- .../mods/system/dal/entity/ent/user/user.go | 20 +-- .../mods/system/dal/entity/ent/user/where.go | 84 ++++++------- .../mods/system/dal/entity/ent/user_create.go | 34 ++--- .../mods/system/dal/entity/ent/user_query.go | 4 +- .../mods/system/dal/entity/ent/user_update.go | 44 +++---- 20 files changed, 209 insertions(+), 294 deletions(-) diff --git a/api/v1/proto/system/casbin.proto b/api/v1/proto/system/casbin.proto index dc58b362..6e84dbb3 100644 --- a/api/v1/proto/system/casbin.proto +++ b/api/v1/proto/system/casbin.proto @@ -1,18 +1,18 @@ syntax = "proto3"; -option go_package = "v1/services/system;system"; -option java_multiple_files = true; -option csharp_namespace = "CasbinOrg.Grpc"; -option java_outer_classname = "APIServiceSystemCasbinProto"; -option java_package = "com.origadmin.api.v1.services.system"; -option objc_class_prefix = "APIServiceSystemCasbin"; +package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "system/types.proto"; -package api.v1.services.system; +option go_package = "v1/services/system;system"; +option java_multiple_files = true; +option csharp_namespace = "CasbinOrg.Grpc"; +option java_outer_classname = "APIServiceSystemCasbinProto"; +option java_package = "com.origadmin.api.v1.services.system"; +option objc_class_prefix = "APIServiceSystemCasbin"; // The Casbin source service definition. service CasbinSourceService { diff --git a/api/v1/proto/system/types.proto b/api/v1/proto/system/types.proto index 26bff748..472874bb 100644 --- a/api/v1/proto/system/types.proto +++ b/api/v1/proto/system/types.proto @@ -69,7 +69,7 @@ message MenuEdges { // Role is the model entity for the Role schema. message Role { // ID of the ent. - // field.primary_key.comment + // field.primary_key.comment int64 id = 1 [json_name = "id"]; // create_time.field.comment google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; @@ -118,7 +118,7 @@ message RoleEdges { // User is the model entity for the User schema. message User { // ID of the ent. - // field.primary_key.comment + // field.primary_key.comment int64 id = 1 [json_name = "id"]; // create_author.field.comment int64 create_author = 2 [json_name = "create_author"]; @@ -145,33 +145,35 @@ message User { // user.field.password // @Decrypted don't show this field in response string password = 13 [json_name = "password"]; + // user.field.confirm_password + string confirm_password = 14 [json_name = "confirm_password"]; // user.field.salt // @Decrypted don't show this field in response - string salt = 14 [json_name = "salt"]; + string salt = 15 [json_name = "salt"]; // user.field.phone - string phone = 15 [json_name = "phone"]; + string phone = 16 [json_name = "phone"]; // user.field.email - string email = 16 [json_name = "email"]; + string email = 17 [json_name = "email"]; // user.field.remark - string remark = 17 [json_name = "remark"]; + string remark = 18 [json_name = "remark"]; // user.field.token - string token = 18 [json_name = "token"]; + string token = 19 [json_name = "token"]; // user.field.status - int32 status = 19 [json_name = "status"]; + int32 status = 20 [json_name = "status"]; // user.field.last_login_ip - string last_login_ip = 20 [json_name = "last_login_ip"]; + string last_login_ip = 21 [json_name = "last_login_ip"]; // user.field.last_login_time - google.protobuf.Timestamp last_login_time = 21 [json_name = "last_login_time"]; + google.protobuf.Timestamp last_login_time = 22 [json_name = "last_login_time"]; // user.field.sanction_date - optional google.protobuf.Timestamp sanction_date = 22 [json_name = "sanction_date"]; + optional google.protobuf.Timestamp sanction_date = 23 [json_name = "sanction_date"]; // user.field.manager_id - int64 manager_id = 23 [json_name = "manager_id"]; + int64 manager_id = 24 [json_name = "manager_id"]; // user.field.manager - string manager = 24 [json_name = "manager"]; + string manager = 25 [json_name = "manager"]; // Roles holds the value of the roles edge. - repeated Role roles = 25 [json_name = "roles"]; + repeated Role roles = 26 [json_name = "roles"]; // Role Ids holds the value of the role_ids - repeated int64 role_ids = 26 [json_name = "role_ids"]; + repeated int64 role_ids = 27 [json_name = "role_ids"]; } // UserEdges holds the relations/edges for other nodes in the graph. @@ -239,7 +241,7 @@ message RoleMenuEdges { // Resource is the model entity for the Resource schema. message Resource { // ID of the ent. - // field.primary_key.comment + // field.primary_key.comment int64 id = 1 [json_name = "id"]; // create_time.field.comment google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; @@ -272,7 +274,7 @@ message Resource { // resource.field.tree_path string tree_path = 16 [json_name = "tree_path"]; // resource.field.properties - map properties = 17 [json_name = "properties"]; + map properties = 17 [json_name = "properties"]; // resource.field.description string description = 18 [json_name = "description"]; // resource.field.parent_id @@ -293,7 +295,6 @@ message ResourceEdges { Menu menu = 1 [json_name = "menu"]; } - // department.table.comment message Department { // ID of the ent. @@ -411,7 +412,7 @@ message Permission { // permission.field.data_scope string data_scope = 7 [json_name = "data_scope"]; // permission.field.data_rules - map data_rules = 8 [json_name = "data_rules"]; + map data_rules = 8 [json_name = "data_rules"]; // permission.field.resource_ids repeated int64 resource_ids = 9 [json_name = "resource_ids"]; // permission.field.resources @@ -443,7 +444,6 @@ message UserPosition { int64 user_id = 2 [json_name = "user_id"]; // field.foreign_key.comment int64 position_id = 3 [json_name = "position_id"]; - } // UserPositionEdges holds the relations/edges for other nodes in the graph. @@ -463,7 +463,6 @@ message PositionPermission { int64 position_id = 2 [json_name = "position_id"]; // position_permission.field.permission_id int64 permission_id = 3 [json_name = "permission_id"]; - } // PositionPermissionEdges holds the relations/edges for other nodes in the graph. @@ -483,7 +482,6 @@ message RolePermission { int64 role_id = 2 [json_name = "role_id"]; // field.foreign_key.comment int64 permission_id = 3 [json_name = "permission_id"]; - } // RolePermissionEdges holds the relations/edges for other nodes in the graph. diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index 2c18db05..97985dc8 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -15,34 +15,34 @@ option objc_class_prefix = "APIServiceSystemUser"; // The login service definition. service UserService { - rpc ListUsers (ListUsersRequest) returns (ListUsersResponse) { + rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) { option (google.api.http) = {get: "/sys/users"}; } - rpc ListUserResources (ListUserResourcesRequest) returns (ListUserResourcesResponse) { + rpc ListUserResources(ListUserResourcesRequest) returns (ListUserResourcesResponse) { option (google.api.http) = {get: "/sys/users/{id}/resources"}; } - rpc GetUser (GetUserRequest) returns (GetUserResponse) { + rpc GetUser(GetUserRequest) returns (GetUserResponse) { option (google.api.http) = {get: "/sys/users/{id}"}; } - rpc CreateUser (CreateUserRequest) returns (CreateUserResponse) { + rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) { option (google.api.http) = { post: "/sys/users" body: "user" }; } - rpc UpdateUser (UpdateUserRequest) returns (UpdateUserResponse) { + rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse) { option (google.api.http) = { put: "/sys/users/{user.id}" body: "user" }; } - rpc DeleteUser (DeleteUserRequest) returns (DeleteUserResponse) { + rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse) { option (google.api.http) = {delete: "/sys/users/{user.id}"}; } // UpdateUserStatus Update the status of the user information - rpc UpdateUserStatus (UpdateUserStatusRequest) returns (UpdateUserStatusResponse) { + rpc UpdateUserStatus(UpdateUserStatusRequest) returns (UpdateUserStatusResponse) { option (google.api.http) = { put: "/sys/users/{user.id}/status" body: "user" @@ -50,7 +50,7 @@ service UserService { } // UpdateUserRoles update the user roles - rpc UpdateUserRoles (UpdateUserRolesRequest) returns (UpdateUserRolesResponse) { + rpc UpdateUserRoles(UpdateUserRolesRequest) returns (UpdateUserRolesResponse) { option (google.api.http) = { put: "/sys/users/{user.id}/roles" body: "user" @@ -58,7 +58,7 @@ service UserService { } // ResetUserPassword reset the user s password - rpc ResetUserPassword (ResetUserPasswordRequest) returns (ResetUserPasswordResponse) { + rpc ResetUserPassword(ResetUserPasswordRequest) returns (ResetUserPasswordResponse) { option (google.api.http) = { post: "/sys/users/{id}/password/reset" body: "data" @@ -75,7 +75,6 @@ message ListUserResourcesResponse { repeated Resource resources = 2 [json_name = "resources"]; } - message UpdateUserStatusRequest { User user = 1 [json_name = "user"]; } @@ -159,7 +158,6 @@ message UpdateUserRequest { bool is_system = 4 [json_name = "is_system"]; // The random_password is the query parameter for set only to generate a random password bool random_password = 2 [json_name = "random_password"]; - } message UpdateUserResponse { diff --git a/buf.lock b/buf.lock index 1ec7390a..6ec7add3 100644 --- a/buf.lock +++ b/buf.lock @@ -8,8 +8,8 @@ deps: commit: 087bc8072ce44e339f213209e4d57bf0 digest: b5:c4eebcd04bc2fdd5dd0b8d695eb419682a650b600cdb56ff2ed61208a24603e0eb1b8ae0d467925c69a24bde6d322f3c4112bd2b8efdd682d8c3128384cdac9a - name: buf.build/googleapis/googleapis - commit: 751cbe31638d43a9bfb6162cd2352e67 - digest: b5:51ba5c31f244fd74420f0e66d13f2b5dd6024dcfe1a29dc45bd8f6e61c1444c828b9add9e7dd25a4513ebbee8097a970e0712a2e2cd955c2d60cf8905204f51a + commit: 61b203b9a9164be9a834f58c37be6f62 + digest: b5:7811a98b35bd2e4ae5c3ac73c8b3d9ae429f3a790da15de188dc98fc2b77d6bb10e45711f14903af9553fa9821dff256054f2e4b7795789265bc476bec2f088c - name: buf.build/kratos/apis commit: c2de25f14fa445a79a054214f31d17a8 digest: b5:3e4dac0d26ce9db17309aeb845f0efb38ec7db1af06ee3c6b8dce2f4f7f53f126d62233c4910410384ead7f0a0edb6448cb389e62d1e3da5e927c3a980828f0b diff --git a/go.mod b/go.mod index eee75dec..8eeced41 100644 --- a/go.mod +++ b/go.mod @@ -32,11 +32,12 @@ require ( github.com/origadmin/entslog/v3 v3.0.6 github.com/origadmin/runtime v0.1.55 github.com/origadmin/slog-kratos v1.0.4 - github.com/origadmin/toolkits v0.2.16 - github.com/origadmin/toolkits/codec v0.2.16 - github.com/origadmin/toolkits/errors v0.2.16 - github.com/origadmin/toolkits/idgen v0.2.15 - github.com/origadmin/toolkits/sloge v0.2.16 + github.com/origadmin/toolkits v0.3.1 + github.com/origadmin/toolkits/codec v0.3.1 + github.com/origadmin/toolkits/crypto v0.3.1 + github.com/origadmin/toolkits/errors v0.3.1 + github.com/origadmin/toolkits/identifier v0.3.1 + github.com/origadmin/toolkits/sloge v0.3.1 github.com/prometheus/client_golang v1.22.0 github.com/sony/sonyflake v1.2.0 github.com/spf13/cobra v1.9.1 @@ -87,11 +88,9 @@ require ( github.com/go-playground/validator/v10 v10.26.0 // indirect github.com/go-sql-driver/mysql v1.9.2 // indirect github.com/goccy/go-json v0.10.5 // indirect - github.com/godcong/go-locale/v2 v2.0.0 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/golang/protobuf v1.5.4 // indirect github.com/google/cel-go v0.24.1 // indirect github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect @@ -107,7 +106,6 @@ require ( github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl/v2 v2.23.0 // indirect github.com/hashicorp/serf v0.10.2 // indirect - github.com/iancoleman/strcase v0.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect @@ -119,7 +117,6 @@ require ( github.com/lib/pq v1.10.9 // indirect github.com/lmittmann/tint v1.0.7 // indirect github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect - github.com/lyft/protoc-gen-star/v2 v2.0.4 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-sqlite3 v1.14.28 // indirect @@ -140,7 +137,6 @@ require ( github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/shirou/gopsutil/v3 v3.24.5 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect - github.com/spf13/afero v1.14.0 // indirect github.com/spf13/pflag v1.0.6 // indirect github.com/sqlite3ent/sqlite3 v1.34.1 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect diff --git a/go.sum b/go.sum index 0be7c23f..f3c09560 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ ariga.io/atlas v0.32.0 h1:y+77nueMrExLiKlz1CcPKh/nU7VSlWfBbwCShsJyvCw= ariga.io/atlas v0.32.0/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250307204501-0409229c3780.1 h1:zgJPqo17m28+Lf5BW4xv3PvU20BnrmTcGYrog22lLIU= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250307204501-0409229c3780.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U= -cel.dev/expr v0.22.1 h1:xoFEsNh972Yzey8N9TCPx2nDvMN7TMhQEzxLuj/iRrI= -cel.dev/expr v0.22.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw= cel.dev/expr v0.23.1 h1:K4KOtPCJQjVggkARsjG9RWXP6O4R73aHeJMa/dmCQQg= cel.dev/expr v0.23.1/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= @@ -652,8 +650,6 @@ github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR github.com/bmatcuk/doublestar/v4 v4.8.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/bufbuild/protovalidate-go v0.9.2 h1:dUoPvFimovS74s3eeFNvHQOxFumRPsk390ifkzJCJ/4= -github.com/bufbuild/protovalidate-go v0.9.2/go.mod h1:U9+WHAa6IOrLuqQEWPcxsyE4QEOTwm9fDpVbWXsR0zU= github.com/bufbuild/protovalidate-go v0.9.3 h1:XvdtwQuppS3wjzGfpOirsqwN5ExH2+PiIuA/XZd3MTM= github.com/bufbuild/protovalidate-go v0.9.3/go.mod h1:2lUDP6fNd3wxznRNH3Nj64VB07+PySeslamkerwP6tE= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= @@ -664,8 +660,6 @@ github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCN github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= github.com/caarlos0/go-version v0.2.0 h1:TTD5dF3PBAtRHbfCKRE173SrVVpbE0yX95EDQ4BwTGs= github.com/caarlos0/go-version v0.2.0/go.mod h1:X+rI5VAtJDpcjCjeEIXpxGa5+rTcgur1FK66wS0/944= -github.com/casbin/casbin/v2 v2.104.0 h1:qDakyBZ4jUg1VskF1+UzIwkg+uXWcp0u0M9PMm1RsTA= -github.com/casbin/casbin/v2 v2.104.0/go.mod h1:Ee33aqGrmES+GNL17L0h9X28wXuo829wnNUnS0edAco= github.com/casbin/casbin/v2 v2.105.0 h1:dLj5P6pLApBRat9SADGiLxLZjiDPvA1bsPkyV4PGx6I= github.com/casbin/casbin/v2 v2.105.0/go.mod h1:Ee33aqGrmES+GNL17L0h9X28wXuo829wnNUnS0edAco= github.com/casbin/govaluate v1.3.0 h1:VA0eSY0M2lA86dYd5kPPuNZMUD9QkWnOCnavGrw9myc= @@ -699,9 +693,8 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20220314180256-7f1daf1720fc/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20241223141626-cff3c89139a3 h1:boJj011Hh+874zpIySeApCX4GeOjPl9qhRF3QuIZq+Q= -github.com/cncf/xds/go v0.0.0-20241223141626-cff3c89139a3/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 h1:Om6kYQYDUk5wWbT0t0q6pvyM49i9XZAv9dDrkDA7gjk= +github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -743,17 +736,11 @@ github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= -github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM= -github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8= github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY= github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E= -github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0= github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w= github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM= github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= @@ -803,12 +790,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.25.0 h1:5Dh7cjvzR7BRZadnsVOzPhWsrwUr0nmsZJxEAnFLNO8= -github.com/go-playground/validator/v10 v10.25.0/go.mod h1:GGzBIJMuE98Ic/kJsBXbz1x/7cByt++cQ+YOuDM5wus= github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k= github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= -github.com/go-sql-driver/mysql v1.9.1 h1:oDr3crteKcueQ18yeWSyj52l3Qp8kh4zQlbbJFq0hLY= -github.com/go-sql-driver/mysql v1.9.1/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU= github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -817,15 +800,9 @@ github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3a github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= -github.com/godcong/go-locale/v2 v2.0.0 h1:08Zv/U8UtuCqYqrnRgeYFv0bxVSbzKmw3Otdb96RF+s= -github.com/godcong/go-locale/v2 v2.0.0/go.mod h1:1ZOYuUVWqC9/18tdYVl2Tt2sWfms1RH3y/7hjRstZRE= -github.com/goexts/generic v0.2.4 h1:RDcE/GtudVUxWb+hSP9l1jFirkWEkZHrnHfiY4WWFG4= -github.com/goexts/generic v0.2.4/go.mod h1:j/ZjWHYt+If6VjeHWvDhYKdoP+gAiAKpm0cu3yvKmfo= github.com/goexts/generic v0.2.5 h1:+TjsHnduEqQrjXcWbO/ubvOCBNbYHJ5ggvkHicz/JVY= github.com/goexts/generic v0.2.5/go.mod h1:SZddH3gsbpBCE8JezA87mLXvM0aVrHivRWmnTn+enI4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang-cz/devslog v0.0.11 h1:v4Yb9o0ZpuZ/D8ZrtVw1f9q5XrjnkxwHF1XmWwO8IHg= -github.com/golang-cz/devslog v0.0.11/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= github.com/golang-cz/devslog v0.0.12 h1:wTwC066Qc7ag7J4coy5mBQXA6lYyaSA3ctpArcWofNg= github.com/golang-cz/devslog v0.0.12/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= @@ -957,7 +934,6 @@ github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyE github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= @@ -1006,8 +982,6 @@ github.com/hashicorp/memberlist v0.5.2/go.mod h1:Ri9p/tRShbjYnpNf4FFPXG7wxEGY4Nr github.com/hashicorp/serf v0.10.2 h1:m5IORhuNSjaxeljg5DeQVDlQyVkhRIjJDimbkCa8aAc= github.com/hashicorp/serf v0.10.2/go.mod h1:T1CmSGfSeGfnfNy/w0odXQUR1rfECGd2Qdsp84DjOiY= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= -github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= -github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -1037,8 +1011,6 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:C github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= -github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= -github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= @@ -1065,10 +1037,7 @@ github.com/lmittmann/tint v1.0.7/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr325bN2FD2ISlRRztXibcX6e8f5FR5Dc= github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= -github.com/lyft/protoc-gen-star v0.6.1 h1:erE0rdztuaDq3bpGifD95wfoPrSZc95nGA6tbiNYh6M= github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= -github.com/lyft/protoc-gen-star/v2 v2.0.4 h1:JDlNKttNIRd68AAIychs0AqEpO8/I/WYi01OQ7Raw6Q= -github.com/lyft/protoc-gen-star/v2 v2.0.4/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= @@ -1078,9 +1047,9 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM= -github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -1110,6 +1079,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/origadmin/contrib/consul v0.0.32 h1:OVb8xIaoblEGuPeBe0FzLRxrtOoBb43CXP6D62/5tDA= github.com/origadmin/contrib/consul v0.0.32/go.mod h1:YkCs7pFxjJz6ej3wx3OpSxp3CR/U1wBBI+8p9KYarbA= github.com/origadmin/contrib/database v0.0.32 h1:lYdvX74xczO947oMK71KASt9Xhmn1/9VB1QYv3Ft/pQ= @@ -1128,30 +1099,20 @@ github.com/origadmin/runtime v0.1.55 h1:nb2owsqJFy8HEjVjn2g0DgnOq712B1+00h3zFISo github.com/origadmin/runtime v0.1.55/go.mod h1:gilZK6pkP7ChbYmR2y/L0ikVZMvFQd83dzEbDcN096k= github.com/origadmin/slog-kratos v1.0.4 h1:1et3TBy61Uwf5N1ZbEBFhMqCjgxqfRXmz2w0Q1dujG0= github.com/origadmin/slog-kratos v1.0.4/go.mod h1:WUdhcWLyN0i8TbdemqE2Y/muoj0GaZ86OcdpumAWHPo= -github.com/origadmin/toolkits v0.2.14 h1:++xkMJj8xzXsUKDDQ0xvFdSyUQ8oEyJKhA8Vr1hmzo4= -github.com/origadmin/toolkits v0.2.14/go.mod h1:2tU68ZT0rkSPsG8aLvkZMiZ1K0+C4ceVKbWwLND9MVk= -github.com/origadmin/toolkits v0.2.16 h1:lAUsV9asAjE8Wo4/DIZYotuQE9k00RGLTKk2kXa+ftE= -github.com/origadmin/toolkits v0.2.16/go.mod h1:kERTzbPW4e2y4LqJ38NrPje3vW8OxCECh7+JmeDJ4Ps= -github.com/origadmin/toolkits/codec v0.2.14 h1:AsVMRwsEv9eL9QierH4h5QjyplFchSQCfrIiphxMYO8= -github.com/origadmin/toolkits/codec v0.2.14/go.mod h1:tfK0adt9HU6cB3QfgDCKGBv92Rj3ub+XAkfX1w///KE= -github.com/origadmin/toolkits/codec v0.2.16 h1:BsmkJcxfaWGAX8AasMeeweJaaaOHjxd88cZ26Dp+id0= -github.com/origadmin/toolkits/codec v0.2.16/go.mod h1:tfK0adt9HU6cB3QfgDCKGBv92Rj3ub+XAkfX1w///KE= -github.com/origadmin/toolkits/errors v0.2.14 h1:pZPiNL+LDGrLJorkX/0U1h4XtZRkjanTLyDB19cJ2gc= -github.com/origadmin/toolkits/errors v0.2.14/go.mod h1:q38Ao7483Efw4gqCpPNh/Osb4DN27eHTgcCUSq8WrgI= -github.com/origadmin/toolkits/errors v0.2.16 h1:i7dlV0AwSabIa9DopDCjodciclmdroue2D5p0XOpWiw= -github.com/origadmin/toolkits/errors v0.2.16/go.mod h1:q38Ao7483Efw4gqCpPNh/Osb4DN27eHTgcCUSq8WrgI= -github.com/origadmin/toolkits/idgen v0.2.14 h1:I8tm8tDQx0sgil0N6H4+dneM6M/b5D8i+KvDCKb0BLc= -github.com/origadmin/toolkits/idgen v0.2.14/go.mod h1:mo95k+IJ4ZFp97jzU7oPOC5QtPasR3XnPZwbE1D/CKc= -github.com/origadmin/toolkits/idgen v0.2.15 h1:FERSchNceaKeVp6qAib+DpyFEQDfDGcQKTjWvtsUgKg= -github.com/origadmin/toolkits/idgen v0.2.15/go.mod h1:mo95k+IJ4ZFp97jzU7oPOC5QtPasR3XnPZwbE1D/CKc= -github.com/origadmin/toolkits/sloge v0.2.14 h1:KEhFO8uRVOXbw8vs6h/qRwW3iSViFiGe+r1Jg1/RhTI= -github.com/origadmin/toolkits/sloge v0.2.14/go.mod h1:Okm6gmOqyTK0XuW/Br2Irb33jBiNpOGmUBUF4sjCuws= -github.com/origadmin/toolkits/sloge v0.2.16 h1:AsTwcQBkx5/6RObWbcqQg6vJqHctsv7AzZA8lo4sqXQ= -github.com/origadmin/toolkits/sloge v0.2.16/go.mod h1:Okm6gmOqyTK0XuW/Br2Irb33jBiNpOGmUBUF4sjCuws= +github.com/origadmin/toolkits v0.3.1 h1:38fD+knmXgHG/iOtKqNKROd0csBE8Db6byWQeuyBz4I= +github.com/origadmin/toolkits v0.3.1/go.mod h1:h6oCaOxZ4vHQsHgZ7wzFVjFlwrpmRwo+Mfj8LA5zBxM= +github.com/origadmin/toolkits/codec v0.3.1 h1:/izgcW3HeCL4aeDgO0Dvaapow/6ED4OdFOnP1kBeoP8= +github.com/origadmin/toolkits/codec v0.3.1/go.mod h1:RlnoEXP8tD9FNRXqAk/u/BZ1skVNlukjJ3BqTVaP4AM= +github.com/origadmin/toolkits/crypto v0.3.1 h1:fw/jsuaq7fBVHvnHMau4tH7Pnrhp3Xvb6yWDHrFlN1k= +github.com/origadmin/toolkits/crypto v0.3.1/go.mod h1:4wKSiCDDyRHTqd+5tn1jd36IOuQ3cYycZkFLy/H2e7I= +github.com/origadmin/toolkits/errors v0.3.1 h1:Y1tdJYF8M1vTNIltgf1bCLI0XECGykK08XYo3uWIbgo= +github.com/origadmin/toolkits/errors v0.3.1/go.mod h1:kqVUSV6sz+wiUeesrBxZ3oyUPrNl0alF0+jO0qehBvM= +github.com/origadmin/toolkits/identifier v0.3.1 h1:JgRTIbSbsjbMwbKTGsaGf1FZr5S6UG2VLGwEzqBPaxc= +github.com/origadmin/toolkits/identifier v0.3.1/go.mod h1:M1IodkORni12hNmpFd5/9xrBHqjUkoDzBmPWyHGhIp8= +github.com/origadmin/toolkits/sloge v0.3.1 h1:XQ9ws90NHrE74S/xHXfHKoudxcyYNv+eJD9RIACT458= +github.com/origadmin/toolkits/sloge v0.3.1/go.mod h1:DEzQjJ+wo0KdDPrhos51gna/4yOPhhuSUZUDLcT6n68= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= -github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= @@ -1178,8 +1139,6 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.21.1 h1:DOvXXTqVzvkIewV/CDPFdejpMCGeMcbGCQ8YOmu+Ibk= -github.com/prometheus/client_golang v1.21.1/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg= github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q= github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -1230,8 +1189,6 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= -github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA= -github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo= github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= @@ -1257,7 +1214,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= @@ -1311,8 +1267,6 @@ go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= -golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw= -golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE= golang.org/x/arch v0.16.0 h1:foMtLTdyOmIniqWCHjY6+JxuC54XP1fDwx4N0ASyW+U= golang.org/x/arch v0.16.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1331,8 +1285,6 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1350,8 +1302,6 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw= -golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM= golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM= golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= @@ -1368,8 +1318,6 @@ golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeap golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= golang.org/x/image v0.0.0-20220302094943-723b81ca9867/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= -golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ= -golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs= golang.org/x/image v0.26.0 h1:4XjIFEZWQmCZi6Wv8BoxsDhRU3RVnLX04dToTDAEPlY= golang.org/x/image v0.26.0/go.mod h1:lcxbMFAovzpnJxzXS3nyL83K27tmqtKzIJpctK8YO5c= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1471,8 +1419,6 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= -golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1523,8 +1469,6 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= -golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1619,8 +1563,6 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= @@ -1655,8 +1597,6 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1728,8 +1668,6 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= -golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1947,14 +1885,10 @@ google.golang.org/genproto v0.0.0-20230525234025-438c736192d0/go.mod h1:9ExIQyXL google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54/go.mod h1:zqTuNwFlFRsw5zIts5VnzLQxSRqh+CGOTVMlYbY0Eyk= google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go.mod h1:ts19tUU+Z0ZShN1y3aPyq2+O3d5FUNNgT6FtOzmrNn8= google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 h1:hE3bRWtU6uceqlh4fhrSnUyjKHMKB9KrTLLG+bc0ddM= -google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463/go.mod h1:U90ffi8eUL9MwPcrJylN5+Mk2v3vuPDptd5yyNUiRR8= google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e h1:UdXH7Kzbj+Vzastr5nVfccbmFsmYNygVLSPk1pEfDoY= google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e/go.mod h1:085qFyf2+XaZlRdCgKNCIZ3afY2p4HHZdoIRpId8F4A= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 h1:e0AIkUUhxyBKh6ssZNrAMeqhA7RKUj42346d1y02i2g= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e h1:ztQaXfzEXTmCBvbtWYRhJxW+0iJcz2qXfd38/e9l7bA= google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1996,8 +1930,6 @@ google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCD google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= -google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg= -google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -2056,24 +1988,21 @@ lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= modernc.org/cc/v3 v3.36.2/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= modernc.org/cc/v3 v3.36.3/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= -modernc.org/cc/v4 v4.24.4 h1:TFkx1s6dCkQpd6dKurBNmpo+G8Zl4Sq/ztJ+2+DEsh0= -modernc.org/cc/v4 v4.24.4/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= modernc.org/cc/v4 v4.26.0 h1:QMYvbVduUGH0rrO+5mqF/PSPPRZNpRtg2CLELy7vUpA= +modernc.org/cc/v4 v4.26.0/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= modernc.org/ccgo/v3 v3.0.0-20220428102840-41399a37e894/go.mod h1:eI31LL8EwEBKPpNpA4bU1/i+sKOwOrQy8D87zWUcRZc= modernc.org/ccgo/v3 v3.0.0-20220430103911-bc99d88307be/go.mod h1:bwdAnOoaIt8Ax9YdWGjxWsdkPcZyRPHqrOvJxaKAKGw= modernc.org/ccgo/v3 v3.16.4/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ= modernc.org/ccgo/v3 v3.16.6/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ= modernc.org/ccgo/v3 v3.16.8/go.mod h1:zNjwkizS+fIFDrDjIAgBSCLkWbJuHF+ar3QRn+Z9aws= modernc.org/ccgo/v3 v3.16.9/go.mod h1:zNMzC9A9xeNUepy6KuZBbugn3c0Mc9TeiJO4lgvkJDo= -modernc.org/ccgo/v4 v4.23.16 h1:Z2N+kk38b7SfySC1ZkpGLN2vthNJP1+ZzGZIlH7uBxo= -modernc.org/ccgo/v4 v4.23.16/go.mod h1:nNma8goMTY7aQZQNTyN9AIoJfxav4nvTnvKThAeMDdo= modernc.org/ccgo/v4 v4.26.0 h1:gVzXaDzGeBYJ2uXTOpR8FR7OlksDOe9jxnjhIKCsiTc= +modernc.org/ccgo/v4 v4.26.0/go.mod h1:Sem8f7TFUtVXkG2fiaChQtyyfkqhJBg/zjEJBkmuAVY= modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= -modernc.org/gc/v2 v2.6.3 h1:aJVhcqAte49LF+mGveZ5KPlsp4tdGdAOT4sipJXADjw= -modernc.org/gc/v2 v2.6.3/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= +modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= modernc.org/libc v0.0.0-20220428101251-2d5f3daf273b/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA= modernc.org/libc v1.16.0/go.mod h1:N4LD6DBE9cf+Dzf9buBlzVJndKr/iJHG97vGLHYnb5A= @@ -2082,8 +2011,6 @@ modernc.org/libc v1.16.17/go.mod h1:hYIV5VZczAmGZAnG15Vdngn5HSF5cSkbvfz2B7GRuVU= modernc.org/libc v1.16.19/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA= modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0= modernc.org/libc v1.17.1/go.mod h1:FZ23b+8LjxZs7XtFMbSzL/EhPxNbfZbErxEHc7cbD9s= -modernc.org/libc v1.61.13 h1:3LRd6ZO1ezsFiX1y+bHd1ipyEHIJKvuprv0sLTBwLW8= -modernc.org/libc v1.61.13/go.mod h1:8F/uJWL/3nNil0Lgt1Dpz+GgkApWh04N3el3hxJcA6E= modernc.org/libc v1.63.0 h1:wKzb61wOGCzgahQBORb1b0dZonh8Ufzl/7r4Yf1D5YA= modernc.org/libc v1.63.0/go.mod h1:wDzH1mgz1wUIEwottFt++POjGRO9sgyQKrpXaz3x89E= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= @@ -2094,8 +2021,6 @@ modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJ modernc.org/memory v1.1.1/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= modernc.org/memory v1.2.0/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= modernc.org/memory v1.2.1/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= -modernc.org/memory v1.9.1 h1:V/Z1solwAVmMW1yttq3nDdZPJqV1rM05Ccq6KMSZ34g= -modernc.org/memory v1.9.1/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= modernc.org/memory v1.10.0 h1:fzumd51yQ1DxcOxSO+S6X7+QTuVU+n8/Aj7swYjFfC4= modernc.org/memory v1.10.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= @@ -2105,8 +2030,6 @@ modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= modernc.org/sqlite v1.18.1/go.mod h1:6ho+Gow7oX5V+OiOQ6Tr4xeqbx13UZ6t+Fw9IRUG4d4= -modernc.org/sqlite v1.36.2 h1:vjcSazuoFve9Wm0IVNHgmJECoOXLZM1KfMXbcX2axHA= -modernc.org/sqlite v1.36.2/go.mod h1:ADySlx7K4FdY5MaJcEv86hTJ0PjedAloTUuif0YS3ws= modernc.org/sqlite v1.37.0 h1:s1TMe7T3Q3ovQiK2Ouz4Jwh7dw4ZDqbebSDTlSJdfjI= modernc.org/sqlite v1.37.0/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM= modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= diff --git a/internal/loader/bootstrap_test.go b/internal/loader/bootstrap_test.go index 93784ea3..e597e97c 100644 --- a/internal/loader/bootstrap_test.go +++ b/internal/loader/bootstrap_test.go @@ -17,7 +17,7 @@ import ( "github.com/origadmin/runtime/log" "github.com/origadmin/slog-kratos" "github.com/origadmin/toolkits/crypto/rand" - "github.com/origadmin/toolkits/idgen/uuid" + "github.com/origadmin/toolkits/identifier/uuid" "google.golang.org/protobuf/encoding/protojson" "origadmin/application/admin/internal/configs" diff --git a/internal/mods/system/dal/entity/ent/internal/schema.go b/internal/mods/system/dal/entity/ent/internal/schema.go index c992fc7e..5bccde46 100644 --- a/internal/mods/system/dal/entity/ent/internal/schema.go +++ b/internal/mods/system/dal/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/mods/system/dal/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/mods/system/dal/entity/ent\",\"Schemas\":[{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"children\",\"type\":\"Resource\"},{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref_name\":\"children\",\"unique\":true,\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"i18n_key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n_key\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2,\"default\":true,\"default_value\":\"M\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.component\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.icon\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.visible\"},{\"name\":\"level\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.level\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"properties\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"resource.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"parent_id\"]},{\"fields\":[\"level\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"delete_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/mods/system/dal/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/mods/system/dal/entity/ent\",\"Schemas\":[{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"children\",\"type\":\"Resource\"},{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref_name\":\"children\",\"unique\":true,\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"i18n_key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n_key\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2,\"default\":true,\"default_value\":\"M\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.component\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.icon\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.visible\"},{\"name\":\"level\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.level\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"properties\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"resource.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"parent_id\"]},{\"fields\":[\"level\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"delete_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/mods/system/dal/entity/ent/migrate/schema.go b/internal/mods/system/dal/entity/ent/migrate/schema.go index 67a518b9..5d80d611 100644 --- a/internal/mods/system/dal/entity/ent/migrate/schema.go +++ b/internal/mods/system/dal/entity/ent/migrate/schema.go @@ -386,7 +386,7 @@ var ( {Name: "avatar", Type: field.TypeString, Size: 256, Comment: "user.field.avatar", Default: ""}, {Name: "name", Type: field.TypeString, Size: 64, Comment: "entity.user.field.nickname", Default: ""}, {Name: "gender", Type: field.TypeEnum, Comment: "entity.user.field.gender", Enums: []string{"male", "female", "unknown"}, Default: "unknown"}, - {Name: "password", Type: field.TypeString, Size: 256, Comment: "entity.user.field.password", Default: ""}, + {Name: "encrypted_password", Type: field.TypeString, Size: 256, Comment: "entity.user.field.encrypted_password", Default: ""}, {Name: "salt", Type: field.TypeString, Size: 64, Comment: "entity.user.field.salt", Default: ""}, {Name: "phone", Type: field.TypeString, Size: 32, Comment: "entity.user.field.phone", Default: ""}, {Name: "email", Type: field.TypeString, Size: 64, Comment: "entity.user.field.email", Default: ""}, diff --git a/internal/mods/system/dal/entity/ent/mutation.go b/internal/mods/system/dal/entity/ent/mutation.go index e2bc8bf1..ba7def46 100644 --- a/internal/mods/system/dal/entity/ent/mutation.go +++ b/internal/mods/system/dal/entity/ent/mutation.go @@ -7987,7 +7987,7 @@ type UserMutation struct { avatar *string name *string gender *user.Gender - password *string + encrypted_password *string salt *string phone *string email *string @@ -8645,40 +8645,40 @@ func (m *UserMutation) ResetGender() { m.gender = nil } -// SetPassword sets the "password" field. -func (m *UserMutation) SetPassword(s string) { - m.password = &s +// SetEncryptedPassword sets the "encrypted_password" field. +func (m *UserMutation) SetEncryptedPassword(s string) { + m.encrypted_password = &s } -// Password returns the value of the "password" field in the mutation. -func (m *UserMutation) Password() (r string, exists bool) { - v := m.password +// EncryptedPassword returns the value of the "encrypted_password" field in the mutation. +func (m *UserMutation) EncryptedPassword() (r string, exists bool) { + v := m.encrypted_password if v == nil { return } return *v, true } -// OldPassword returns the old "password" field's value of the User entity. +// OldEncryptedPassword returns the old "encrypted_password" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldEncryptedPassword(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPassword is only allowed on UpdateOne operations") + return v, errors.New("OldEncryptedPassword is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPassword requires an ID field in the mutation") + return v, errors.New("OldEncryptedPassword requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPassword: %w", err) + return v, fmt.Errorf("querying old value for OldEncryptedPassword: %w", err) } - return oldValue.Password, nil + return oldValue.EncryptedPassword, nil } -// ResetPassword resets all changes to the "password" field. -func (m *UserMutation) ResetPassword() { - m.password = nil +// ResetEncryptedPassword resets all changes to the "encrypted_password" field. +func (m *UserMutation) ResetEncryptedPassword() { + m.encrypted_password = nil } // SetSalt sets the "salt" field. @@ -9647,8 +9647,8 @@ func (m *UserMutation) Fields() []string { if m.gender != nil { fields = append(fields, user.FieldGender) } - if m.password != nil { - fields = append(fields, user.FieldPassword) + if m.encrypted_password != nil { + fields = append(fields, user.FieldEncryptedPassword) } if m.salt != nil { fields = append(fields, user.FieldSalt) @@ -9724,8 +9724,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.Name() case user.FieldGender: return m.Gender() - case user.FieldPassword: - return m.Password() + case user.FieldEncryptedPassword: + return m.EncryptedPassword() case user.FieldSalt: return m.Salt() case user.FieldPhone: @@ -9787,8 +9787,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldName(ctx) case user.FieldGender: return m.OldGender(ctx) - case user.FieldPassword: - return m.OldPassword(ctx) + case user.FieldEncryptedPassword: + return m.OldEncryptedPassword(ctx) case user.FieldSalt: return m.OldSalt(ctx) case user.FieldPhone: @@ -9910,12 +9910,12 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetGender(v) return nil - case user.FieldPassword: + case user.FieldEncryptedPassword: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPassword(v) + m.SetEncryptedPassword(v) return nil case user.FieldSalt: v, ok := value.(string) @@ -10184,8 +10184,8 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldGender: m.ResetGender() return nil - case user.FieldPassword: - m.ResetPassword() + case user.FieldEncryptedPassword: + m.ResetEncryptedPassword() return nil case user.FieldSalt: m.ResetSalt() diff --git a/internal/mods/system/dal/entity/ent/mutation_fields.go b/internal/mods/system/dal/entity/ent/mutation_fields.go index d5795e2a..10c0d59f 100644 --- a/internal/mods/system/dal/entity/ent/mutation_fields.go +++ b/internal/mods/system/dal/entity/ent/mutation_fields.go @@ -714,10 +714,10 @@ func (m *UserMutation) SetFields(input *User, fields ...string) error { if input.Gender != zero { m.SetGender(input.Gender) } - case user.FieldPassword: + case user.FieldEncryptedPassword: // check string with sql.NullString if it is empty - if input.Password != "" { - m.SetPassword(input.Password) + if input.EncryptedPassword != "" { + m.SetEncryptedPassword(input.EncryptedPassword) } case user.FieldSalt: // check string with sql.NullString if it is empty @@ -831,8 +831,8 @@ func (m *UserMutation) SetFieldsWithZero(input *User, fields ...string) error { m.SetName(input.Name) case user.FieldGender: m.SetGender(input.Gender) - case user.FieldPassword: - m.SetPassword(input.Password) + case user.FieldEncryptedPassword: + m.SetEncryptedPassword(input.EncryptedPassword) case user.FieldSalt: m.SetSalt(input.Salt) case user.FieldPhone: diff --git a/internal/mods/system/dal/entity/ent/runtime/runtime.go b/internal/mods/system/dal/entity/ent/runtime/runtime.go index d6768577..2e1b918c 100644 --- a/internal/mods/system/dal/entity/ent/runtime/runtime.go +++ b/internal/mods/system/dal/entity/ent/runtime/runtime.go @@ -427,12 +427,12 @@ func init() { user.DefaultName = userDescName.Default.(string) // user.NameValidator is a validator for the "name" field. It is called by the builders before save. user.NameValidator = userDescName.Validators[0].(func(string) error) - // userDescPassword is the schema descriptor for password field. - userDescPassword := userFields[7].Descriptor() - // user.DefaultPassword holds the default value on creation for the password field. - user.DefaultPassword = userDescPassword.Default.(string) - // user.PasswordValidator is a validator for the "password" field. It is called by the builders before save. - user.PasswordValidator = userDescPassword.Validators[0].(func(string) error) + // userDescEncryptedPassword is the schema descriptor for encrypted_password field. + userDescEncryptedPassword := userFields[7].Descriptor() + // user.DefaultEncryptedPassword holds the default value on creation for the encrypted_password field. + user.DefaultEncryptedPassword = userDescEncryptedPassword.Default.(string) + // user.EncryptedPasswordValidator is a validator for the "encrypted_password" field. It is called by the builders before save. + user.EncryptedPasswordValidator = userDescEncryptedPassword.Validators[0].(func(string) error) // userDescSalt is the schema descriptor for salt field. userDescSalt := userFields[8].Descriptor() // user.DefaultSalt holds the default value on creation for the salt field. diff --git a/internal/mods/system/dal/entity/ent/schema/user.go b/internal/mods/system/dal/entity/ent/schema/user.go index c25738fa..8eb10b25 100644 --- a/internal/mods/system/dal/entity/ent/schema/user.go +++ b/internal/mods/system/dal/entity/ent/schema/user.go @@ -63,10 +63,10 @@ func (User) Fields() []ent.Field { Values(UserGenderMale, UserGenderFemale, UserGenderUnknown). Default(UserGenderUnknown). Comment(i18n.Text("entity.user.field.gender")), // Gender of user - field.String("password"). + field.String("encrypted_password"). MaxLen(256). Default(""). - Comment(i18n.Text("entity.user.field.password")), + Comment(i18n.Text("entity.user.field.encrypted_password")), field.String("salt"). MaxLen(64). Default(""). diff --git a/internal/mods/system/dal/entity/ent/template/database.tpl b/internal/mods/system/dal/entity/ent/template/database.tpl index 727b0146..3228f3f0 100644 --- a/internal/mods/system/dal/entity/ent/template/database.tpl +++ b/internal/mods/system/dal/entity/ent/template/database.tpl @@ -3,7 +3,7 @@ {{ define "database" }} - {{- $pkg := base $.Config.Package -}} + {{ $pkg := base $.Config.Package -}} {{ template "header" $ }} /* Additional dependencies injected to config. */ @@ -112,7 +112,7 @@ } {{ range $n := $.Nodes }} - {{ $client := print $n.Name "ServiceClient" }} + {{ $client := print $n.Name "Client" }} // {{ $n.Name }} is the client for interacting with the {{ $n.Name }} builders. func (db *Database) {{ $n.Name }}(ctx context.Context) *{{ $client }} { return db.Client(ctx).{{ $n.Name }} diff --git a/internal/mods/system/dal/entity/ent/user.go b/internal/mods/system/dal/entity/ent/user.go index 180ba3be..6f66bb2b 100644 --- a/internal/mods/system/dal/entity/ent/user.go +++ b/internal/mods/system/dal/entity/ent/user.go @@ -42,8 +42,8 @@ type User struct { Name string `json:"name,omitempty"` // entity.user.field.gender Gender user.Gender `json:"gender,omitempty"` - // entity.user.field.password - Password string `json:"password,omitempty"` + // entity.user.field.encrypted_password + EncryptedPassword string `json:"encrypted_password,omitempty"` // entity.user.field.salt // // Deprecated: toolkits/crypto includes salt management @@ -162,7 +162,7 @@ func (*User) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case user.FieldID, user.FieldCreateAuthor, user.FieldUpdateAuthor, user.FieldStatus, user.FieldManagerID: values[i] = new(sql.NullInt64) - case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldPassword, user.FieldSalt, user.FieldPhone, user.FieldEmail, user.FieldDepartment, user.FieldRemark, user.FieldToken, user.FieldLastLoginIP, user.FieldManager: + case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldEncryptedPassword, user.FieldSalt, user.FieldPhone, user.FieldEmail, user.FieldDepartment, user.FieldRemark, user.FieldToken, user.FieldLastLoginIP, user.FieldManager: values[i] = new(sql.NullString) case user.FieldCreateTime, user.FieldUpdateTime, user.FieldDeleteTime, user.FieldLastLoginTime, user.FieldLoginTime, user.FieldSanctionDate: values[i] = new(sql.NullTime) @@ -260,11 +260,11 @@ func (u *User) assignValues(columns []string, values []any) error { } else if value.Valid { u.Gender = user.Gender(value.String) } - case user.FieldPassword: + case user.FieldEncryptedPassword: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field password", values[i]) + return fmt.Errorf("unexpected type %T for field encrypted_password", values[i]) } else if value.Valid { - u.Password = value.String + u.EncryptedPassword = value.String } case user.FieldSalt: if value, ok := values[i].(*sql.NullString); !ok { @@ -454,8 +454,8 @@ func (u *User) String() string { builder.WriteString("gender=") builder.WriteString(fmt.Sprintf("%v", u.Gender)) builder.WriteString(", ") - builder.WriteString("password=") - builder.WriteString(u.Password) + builder.WriteString("encrypted_password=") + builder.WriteString(u.EncryptedPassword) builder.WriteString(", ") builder.WriteString("salt=") builder.WriteString(u.Salt) diff --git a/internal/mods/system/dal/entity/ent/user/user.go b/internal/mods/system/dal/entity/ent/user/user.go index 4971b6f1..74438628 100644 --- a/internal/mods/system/dal/entity/ent/user/user.go +++ b/internal/mods/system/dal/entity/ent/user/user.go @@ -40,8 +40,8 @@ const ( FieldName = "name" // FieldGender holds the string denoting the gender field in the database. FieldGender = "gender" - // FieldPassword holds the string denoting the password field in the database. - FieldPassword = "password" + // FieldEncryptedPassword holds the string denoting the encrypted_password field in the database. + FieldEncryptedPassword = "encrypted_password" // FieldSalt holds the string denoting the salt field in the database. FieldSalt = "salt" // FieldPhone holds the string denoting the phone field in the database. @@ -137,7 +137,7 @@ var Columns = []string{ FieldAvatar, FieldName, FieldGender, - FieldPassword, + FieldEncryptedPassword, FieldPhone, FieldEmail, FieldDepartment, @@ -216,10 +216,10 @@ var ( DefaultName string // NameValidator is a validator for the "name" field. It is called by the builders before save. NameValidator func(string) error - // DefaultPassword holds the default value on creation for the "password" field. - DefaultPassword string - // PasswordValidator is a validator for the "password" field. It is called by the builders before save. - PasswordValidator func(string) error + // DefaultEncryptedPassword holds the default value on creation for the "encrypted_password" field. + DefaultEncryptedPassword string + // EncryptedPasswordValidator is a validator for the "encrypted_password" field. It is called by the builders before save. + EncryptedPasswordValidator func(string) error // DefaultSalt holds the default value on creation for the "salt" field. DefaultSalt string // SaltValidator is a validator for the "salt" field. It is called by the builders before save. @@ -361,9 +361,9 @@ func ByGender(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldGender, opts...).ToFunc() } -// ByPassword orders the results by the password field. -func ByPassword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPassword, opts...).ToFunc() +// ByEncryptedPassword orders the results by the encrypted_password field. +func ByEncryptedPassword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEncryptedPassword, opts...).ToFunc() } // BySalt orders the results by the salt field. diff --git a/internal/mods/system/dal/entity/ent/user/where.go b/internal/mods/system/dal/entity/ent/user/where.go index b1f5ea80..38cc86e8 100644 --- a/internal/mods/system/dal/entity/ent/user/where.go +++ b/internal/mods/system/dal/entity/ent/user/where.go @@ -110,9 +110,9 @@ func Name(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldName, v)) } -// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ. -func Password(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldPassword, v)) +// EncryptedPassword applies equality check predicate on the "encrypted_password" field. It's identical to EncryptedPasswordEQ. +func EncryptedPassword(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEncryptedPassword, v)) } // Salt applies equality check predicate on the "salt" field. It's identical to SaltEQ. @@ -825,69 +825,69 @@ func GenderNotIn(vs ...Gender) predicate.User { return predicate.User(sql.FieldNotIn(FieldGender, vs...)) } -// PasswordEQ applies the EQ predicate on the "password" field. -func PasswordEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldPassword, v)) +// EncryptedPasswordEQ applies the EQ predicate on the "encrypted_password" field. +func EncryptedPasswordEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEncryptedPassword, v)) } -// PasswordNEQ applies the NEQ predicate on the "password" field. -func PasswordNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldPassword, v)) +// EncryptedPasswordNEQ applies the NEQ predicate on the "encrypted_password" field. +func EncryptedPasswordNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldEncryptedPassword, v)) } -// PasswordIn applies the In predicate on the "password" field. -func PasswordIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldPassword, vs...)) +// EncryptedPasswordIn applies the In predicate on the "encrypted_password" field. +func EncryptedPasswordIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldEncryptedPassword, vs...)) } -// PasswordNotIn applies the NotIn predicate on the "password" field. -func PasswordNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldPassword, vs...)) +// EncryptedPasswordNotIn applies the NotIn predicate on the "encrypted_password" field. +func EncryptedPasswordNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldEncryptedPassword, vs...)) } -// PasswordGT applies the GT predicate on the "password" field. -func PasswordGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldPassword, v)) +// EncryptedPasswordGT applies the GT predicate on the "encrypted_password" field. +func EncryptedPasswordGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldEncryptedPassword, v)) } -// PasswordGTE applies the GTE predicate on the "password" field. -func PasswordGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldPassword, v)) +// EncryptedPasswordGTE applies the GTE predicate on the "encrypted_password" field. +func EncryptedPasswordGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldEncryptedPassword, v)) } -// PasswordLT applies the LT predicate on the "password" field. -func PasswordLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldPassword, v)) +// EncryptedPasswordLT applies the LT predicate on the "encrypted_password" field. +func EncryptedPasswordLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldEncryptedPassword, v)) } -// PasswordLTE applies the LTE predicate on the "password" field. -func PasswordLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldPassword, v)) +// EncryptedPasswordLTE applies the LTE predicate on the "encrypted_password" field. +func EncryptedPasswordLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldEncryptedPassword, v)) } -// PasswordContains applies the Contains predicate on the "password" field. -func PasswordContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldPassword, v)) +// EncryptedPasswordContains applies the Contains predicate on the "encrypted_password" field. +func EncryptedPasswordContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldEncryptedPassword, v)) } -// PasswordHasPrefix applies the HasPrefix predicate on the "password" field. -func PasswordHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldPassword, v)) +// EncryptedPasswordHasPrefix applies the HasPrefix predicate on the "encrypted_password" field. +func EncryptedPasswordHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldEncryptedPassword, v)) } -// PasswordHasSuffix applies the HasSuffix predicate on the "password" field. -func PasswordHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldPassword, v)) +// EncryptedPasswordHasSuffix applies the HasSuffix predicate on the "encrypted_password" field. +func EncryptedPasswordHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldEncryptedPassword, v)) } -// PasswordEqualFold applies the EqualFold predicate on the "password" field. -func PasswordEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldPassword, v)) +// EncryptedPasswordEqualFold applies the EqualFold predicate on the "encrypted_password" field. +func EncryptedPasswordEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldEncryptedPassword, v)) } -// PasswordContainsFold applies the ContainsFold predicate on the "password" field. -func PasswordContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldPassword, v)) +// EncryptedPasswordContainsFold applies the ContainsFold predicate on the "encrypted_password" field. +func EncryptedPasswordContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldEncryptedPassword, v)) } // SaltEQ applies the EQ predicate on the "salt" field. diff --git a/internal/mods/system/dal/entity/ent/user_create.go b/internal/mods/system/dal/entity/ent/user_create.go index 55b494ca..868b46c5 100644 --- a/internal/mods/system/dal/entity/ent/user_create.go +++ b/internal/mods/system/dal/entity/ent/user_create.go @@ -178,16 +178,16 @@ func (uc *UserCreate) SetNillableGender(u *user.Gender) *UserCreate { return uc } -// SetPassword sets the "password" field. -func (uc *UserCreate) SetPassword(s string) *UserCreate { - uc.mutation.SetPassword(s) +// SetEncryptedPassword sets the "encrypted_password" field. +func (uc *UserCreate) SetEncryptedPassword(s string) *UserCreate { + uc.mutation.SetEncryptedPassword(s) return uc } -// SetNillablePassword sets the "password" field if the given value is not nil. -func (uc *UserCreate) SetNillablePassword(s *string) *UserCreate { +// SetNillableEncryptedPassword sets the "encrypted_password" field if the given value is not nil. +func (uc *UserCreate) SetNillableEncryptedPassword(s *string) *UserCreate { if s != nil { - uc.SetPassword(*s) + uc.SetEncryptedPassword(*s) } return uc } @@ -571,9 +571,9 @@ func (uc *UserCreate) defaults() error { v := user.DefaultGender uc.mutation.SetGender(v) } - if _, ok := uc.mutation.Password(); !ok { - v := user.DefaultPassword - uc.mutation.SetPassword(v) + if _, ok := uc.mutation.EncryptedPassword(); !ok { + v := user.DefaultEncryptedPassword + uc.mutation.SetEncryptedPassword(v) } if _, ok := uc.mutation.Salt(); !ok { v := user.DefaultSalt @@ -698,12 +698,12 @@ func (uc *UserCreate) check() error { return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} } } - if _, ok := uc.mutation.Password(); !ok { - return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "User.password"`)} + if _, ok := uc.mutation.EncryptedPassword(); !ok { + return &ValidationError{Name: "encrypted_password", err: errors.New(`ent: missing required field "User.encrypted_password"`)} } - if v, ok := uc.mutation.Password(); ok { - if err := user.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} + if v, ok := uc.mutation.EncryptedPassword(); ok { + if err := user.EncryptedPasswordValidator(v); err != nil { + return &ValidationError{Name: "encrypted_password", err: fmt.Errorf(`ent: validator failed for field "User.encrypted_password": %w`, err)} } } if _, ok := uc.mutation.Salt(); !ok { @@ -867,9 +867,9 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldGender, field.TypeEnum, value) _node.Gender = value } - if value, ok := uc.mutation.Password(); ok { - _spec.SetField(user.FieldPassword, field.TypeString, value) - _node.Password = value + if value, ok := uc.mutation.EncryptedPassword(); ok { + _spec.SetField(user.FieldEncryptedPassword, field.TypeString, value) + _node.EncryptedPassword = value } if value, ok := uc.mutation.Salt(); ok { _spec.SetField(user.FieldSalt, field.TypeString, value) diff --git a/internal/mods/system/dal/entity/ent/user_query.go b/internal/mods/system/dal/entity/ent/user_query.go index 93074468..cf2ae1cc 100644 --- a/internal/mods/system/dal/entity/ent/user_query.go +++ b/internal/mods/system/dal/entity/ent/user_query.go @@ -1039,7 +1039,7 @@ func (uq *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // Avatar string `json:"avatar,omitempty"` // Name string `json:"name,omitempty"` // Gender user.Gender `json:"gender,omitempty"` -// Password string `json:"password,omitempty"` +// EncryptedPassword string `json:"encrypted_password,omitempty"` // Salt string `json:"salt,omitempty"` // Phone string `json:"phone,omitempty"` // Email string `json:"email,omitempty"` @@ -1070,7 +1070,7 @@ func (uq *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // user.FieldAvatar, // user.FieldName, // user.FieldGender, -// user.FieldPassword, +// user.FieldEncryptedPassword, // user.FieldSalt, // user.FieldPhone, // user.FieldEmail, diff --git a/internal/mods/system/dal/entity/ent/user_update.go b/internal/mods/system/dal/entity/ent/user_update.go index 299727f8..3166a264 100644 --- a/internal/mods/system/dal/entity/ent/user_update.go +++ b/internal/mods/system/dal/entity/ent/user_update.go @@ -213,16 +213,16 @@ func (uu *UserUpdate) SetNillableGender(u *user.Gender) *UserUpdate { return uu } -// SetPassword sets the "password" field. -func (uu *UserUpdate) SetPassword(s string) *UserUpdate { - uu.mutation.SetPassword(s) +// SetEncryptedPassword sets the "encrypted_password" field. +func (uu *UserUpdate) SetEncryptedPassword(s string) *UserUpdate { + uu.mutation.SetEncryptedPassword(s) return uu } -// SetNillablePassword sets the "password" field if the given value is not nil. -func (uu *UserUpdate) SetNillablePassword(s *string) *UserUpdate { +// SetNillableEncryptedPassword sets the "encrypted_password" field if the given value is not nil. +func (uu *UserUpdate) SetNillableEncryptedPassword(s *string) *UserUpdate { if s != nil { - uu.SetPassword(*s) + uu.SetEncryptedPassword(*s) } return uu } @@ -744,9 +744,9 @@ func (uu *UserUpdate) check() error { return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} } } - if v, ok := uu.mutation.Password(); ok { - if err := user.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} + if v, ok := uu.mutation.EncryptedPassword(); ok { + if err := user.EncryptedPasswordValidator(v); err != nil { + return &ValidationError{Name: "encrypted_password", err: fmt.Errorf(`ent: validator failed for field "User.encrypted_password": %w`, err)} } } if v, ok := uu.mutation.Salt(); ok { @@ -858,8 +858,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := uu.mutation.Gender(); ok { _spec.SetField(user.FieldGender, field.TypeEnum, value) } - if value, ok := uu.mutation.Password(); ok { - _spec.SetField(user.FieldPassword, field.TypeString, value) + if value, ok := uu.mutation.EncryptedPassword(); ok { + _spec.SetField(user.FieldEncryptedPassword, field.TypeString, value) } if value, ok := uu.mutation.Salt(); ok { _spec.SetField(user.FieldSalt, field.TypeString, value) @@ -1385,16 +1385,16 @@ func (uuo *UserUpdateOne) SetNillableGender(u *user.Gender) *UserUpdateOne { return uuo } -// SetPassword sets the "password" field. -func (uuo *UserUpdateOne) SetPassword(s string) *UserUpdateOne { - uuo.mutation.SetPassword(s) +// SetEncryptedPassword sets the "encrypted_password" field. +func (uuo *UserUpdateOne) SetEncryptedPassword(s string) *UserUpdateOne { + uuo.mutation.SetEncryptedPassword(s) return uuo } -// SetNillablePassword sets the "password" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillablePassword(s *string) *UserUpdateOne { +// SetNillableEncryptedPassword sets the "encrypted_password" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableEncryptedPassword(s *string) *UserUpdateOne { if s != nil { - uuo.SetPassword(*s) + uuo.SetEncryptedPassword(*s) } return uuo } @@ -1929,9 +1929,9 @@ func (uuo *UserUpdateOne) check() error { return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} } } - if v, ok := uuo.mutation.Password(); ok { - if err := user.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} + if v, ok := uuo.mutation.EncryptedPassword(); ok { + if err := user.EncryptedPasswordValidator(v); err != nil { + return &ValidationError{Name: "encrypted_password", err: fmt.Errorf(`ent: validator failed for field "User.encrypted_password": %w`, err)} } } if v, ok := uuo.mutation.Salt(); ok { @@ -2060,8 +2060,8 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) if value, ok := uuo.mutation.Gender(); ok { _spec.SetField(user.FieldGender, field.TypeEnum, value) } - if value, ok := uuo.mutation.Password(); ok { - _spec.SetField(user.FieldPassword, field.TypeString, value) + if value, ok := uuo.mutation.EncryptedPassword(); ok { + _spec.SetField(user.FieldEncryptedPassword, field.TypeString, value) } if value, ok := uuo.mutation.Salt(); ok { _spec.SetField(user.FieldSalt, field.TypeString, value) From 72547f927f121fce782a2045959e39aca2149c7f Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 22 Apr 2025 18:09:30 +0800 Subject: [PATCH 015/158] refactor(system): improve user authentication and policy synchronization - Update user login and password handling: - Use encrypted password instead of plain text - Rename 'GetByUserName' to 'GetByUsername' for consistency - Add 'EncryptedPassword' field to UserNode - Enhance policy synchronization: - Log policy records and synchronization status - Improve error handling in casbin updater - Update OpenAPI documentation for user password fields --- api/v1/services/system/types.pb.go | 792 ++++++++++---------- api/v1/services/system/types.pb.validate.go | 2 + contrib/security/authz/casbin/casbin.go | 2 +- contrib/security/authz/casbin/update.go | 10 +- internal/mods/system/dal/login.dal.go | 4 +- internal/mods/system/dal/user.dal.go | 11 +- internal/mods/system/dto/dto.go | 2 +- internal/mods/system/dto/user.go | 7 +- resources/docs/openapi/openapi.yaml | 8 + 9 files changed, 435 insertions(+), 403 deletions(-) diff --git a/api/v1/services/system/types.pb.go b/api/v1/services/system/types.pb.go index 4dcb837a..5384974d 100644 --- a/api/v1/services/system/types.pb.go +++ b/api/v1/services/system/types.pb.go @@ -604,33 +604,35 @@ type User struct { // user.field.password // @Decrypted don't show this field in response Password string `protobuf:"bytes,13,opt,name=password,proto3" json:"password,omitempty"` + // user.field.confirm_password + ConfirmPassword string `protobuf:"bytes,14,opt,name=confirm_password,proto3" json:"confirm_password,omitempty"` // user.field.salt // @Decrypted don't show this field in response - Salt string `protobuf:"bytes,14,opt,name=salt,proto3" json:"salt,omitempty"` + Salt string `protobuf:"bytes,15,opt,name=salt,proto3" json:"salt,omitempty"` // user.field.phone - Phone string `protobuf:"bytes,15,opt,name=phone,proto3" json:"phone,omitempty"` + Phone string `protobuf:"bytes,16,opt,name=phone,proto3" json:"phone,omitempty"` // user.field.email - Email string `protobuf:"bytes,16,opt,name=email,proto3" json:"email,omitempty"` + Email string `protobuf:"bytes,17,opt,name=email,proto3" json:"email,omitempty"` // user.field.remark - Remark string `protobuf:"bytes,17,opt,name=remark,proto3" json:"remark,omitempty"` + Remark string `protobuf:"bytes,18,opt,name=remark,proto3" json:"remark,omitempty"` // user.field.token - Token string `protobuf:"bytes,18,opt,name=token,proto3" json:"token,omitempty"` + Token string `protobuf:"bytes,19,opt,name=token,proto3" json:"token,omitempty"` // user.field.status - Status int32 `protobuf:"varint,19,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,20,opt,name=status,proto3" json:"status,omitempty"` // user.field.last_login_ip - LastLoginIp string `protobuf:"bytes,20,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` + LastLoginIp string `protobuf:"bytes,21,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` // user.field.last_login_time - LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,21,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` + LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` // user.field.sanction_date - SanctionDate *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` + SanctionDate *timestamppb.Timestamp `protobuf:"bytes,23,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` // user.field.manager_id - ManagerId int64 `protobuf:"varint,23,opt,name=manager_id,proto3" json:"manager_id,omitempty"` + ManagerId int64 `protobuf:"varint,24,opt,name=manager_id,proto3" json:"manager_id,omitempty"` // user.field.manager - Manager string `protobuf:"bytes,24,opt,name=manager,proto3" json:"manager,omitempty"` + Manager string `protobuf:"bytes,25,opt,name=manager,proto3" json:"manager,omitempty"` // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,25,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*Role `protobuf:"bytes,26,rep,name=roles,proto3" json:"roles,omitempty"` // Role Ids holds the value of the role_ids - RoleIds []int64 `protobuf:"varint,26,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` + RoleIds []int64 `protobuf:"varint,27,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` } func (x *User) Reset() { @@ -754,6 +756,13 @@ func (x *User) GetPassword() string { return "" } +func (x *User) GetConfirmPassword() string { + if x != nil { + return x.ConfirmPassword + } + return "" +} + func (x *User) GetSalt() string { if x != nil { return x.Salt @@ -2916,7 +2925,7 @@ var file_system_types_proto_rawDesc = []byte{ 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, 0xff, 0x06, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, + 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, 0xab, 0x07, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x75, @@ -2943,45 +2952,76 @@ var file_system_types_proto_rawDesc = []byte{ 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, - 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x61, 0x6c, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x73, 0x61, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, - 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, - 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, - 0x69, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x11, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, - 0x6b, 0x65, 0x6e, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x13, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, - 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x70, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x70, 0x12, 0x44, - 0x0a, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x72, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x5f, 0x70, 0x61, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x12, + 0x0a, 0x04, 0x73, 0x61, 0x6c, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x61, + 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, + 0x6c, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x16, + 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, + 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x16, 0x0a, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, + 0x69, 0x6e, 0x5f, 0x69, 0x70, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6c, 0x61, 0x73, + 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x70, 0x12, 0x44, 0x0a, 0x0f, 0x6c, 0x61, + 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x16, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x12, 0x45, 0x0a, 0x0d, 0x73, 0x61, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x74, + 0x65, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, - 0x74, 0x69, 0x6d, 0x65, 0x12, 0x45, 0x0a, 0x0d, 0x73, 0x61, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x48, 0x00, 0x52, 0x0d, 0x73, 0x61, 0x6e, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x17, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0a, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, - 0x61, 0x6e, 0x61, 0x67, 0x65, 0x72, 0x18, 0x18, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x61, - 0x6e, 0x61, 0x67, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x19, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, - 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x6c, - 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x03, 0x52, 0x08, 0x72, 0x6f, 0x6c, - 0x65, 0x5f, 0x69, 0x64, 0x73, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x73, 0x61, 0x6e, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x22, 0x81, 0x01, 0x0a, 0x09, 0x55, 0x73, 0x65, 0x72, - 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, - 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x40, 0x0a, 0x0a, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, - 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, 0xcc, 0x02, 0x0a, 0x08, - 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x61, 0x6d, 0x70, 0x48, 0x00, 0x52, 0x0d, 0x73, 0x61, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x64, 0x61, 0x74, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x18, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x61, 0x6e, + 0x61, 0x67, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, + 0x65, 0x72, 0x18, 0x19, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, + 0x72, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, + 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, + 0x73, 0x18, 0x1b, 0x20, 0x03, 0x28, 0x03, 0x52, 0x08, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, + 0x73, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x73, 0x61, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, + 0x61, 0x74, 0x65, 0x22, 0x81, 0x01, 0x0a, 0x09, 0x55, 0x73, 0x65, 0x72, 0x45, 0x64, 0x67, 0x65, + 0x73, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, + 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x40, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x6f, + 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0a, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, 0xcc, 0x02, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, + 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, + 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, + 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, 0x6f, 0x6c, + 0x65, 0x5f, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, + 0x75, 0x73, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x16, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, + 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x73, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, + 0x6c, 0x65, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, + 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0xae, 0x02, 0x0a, 0x08, + 0x52, 0x6f, 0x6c, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, @@ -2990,364 +3030,336 @@ var file_system_types_proto_rawDesc = []byte{ 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, - 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x18, - 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x6f, 0x6c, 0x65, - 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x6f, 0x6c, - 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x15, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, - 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x6e, 0x75, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x07, 0x6d, 0x65, 0x6e, 0x75, 0x5f, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, + 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x73, 0x0a, 0x0d, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x04, 0x75, - 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x30, 0x0a, - 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, + 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x6d, 0x65, + 0x6e, 0x75, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, + 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x73, 0x0a, 0x0d, + 0x52, 0x6f, 0x6c, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, + 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, - 0xae, 0x02, 0x0a, 0x08, 0x52, 0x6f, 0x6c, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, + 0x30, 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, + 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, + 0x75, 0x22, 0x93, 0x07, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, + 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x65, - 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, - 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x6e, 0x75, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x07, 0x6d, 0x65, 0x6e, 0x75, 0x5f, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x04, - 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x30, - 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, 0x75, - 0x22, 0x73, 0x0a, 0x0d, 0x52, 0x6f, 0x6c, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x45, 0x64, 0x67, 0x65, - 0x73, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, - 0x6f, 0x6c, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, - 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x93, 0x07, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1a, 0x0a, 0x08, - 0x69, 0x31, 0x38, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x69, 0x31, 0x38, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x70, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, - 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1c, - 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x69, 0x63, 0x6f, 0x6e, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x63, 0x6f, 0x6e, - 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x0e, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, - 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, - 0x61, 0x74, 0x68, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, - 0x70, 0x61, 0x74, 0x68, 0x12, 0x50, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, - 0x65, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, - 0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, - 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, - 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, - 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x61, 0x72, - 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, - 0x65, 0x6e, 0x18, 0x15, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, - 0x64, 0x72, 0x65, 0x6e, 0x12, 0x38, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x16, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x31, 0x38, 0x6e, + 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x31, 0x38, 0x6e, + 0x5f, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, + 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, + 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x63, 0x6f, 0x6e, + 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, + 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, + 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, + 0x62, 0x6c, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, + 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, + 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, + 0x12, 0x50, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x11, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x26, - 0x0a, 0x0e, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x73, - 0x18, 0x17, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0e, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x73, 0x12, 0x44, 0x0a, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x18, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, + 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, + 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, + 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x15, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, + 0x12, 0x38, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x65, + 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x17, 0x20, 0x03, + 0x28, 0x03, 0x52, 0x0e, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, + 0x64, 0x73, 0x12, 0x44, 0x0a, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, + 0x73, 0x18, 0x18, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, + 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x70, 0x65, 0x72, + 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x70, + 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x41, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, + 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0xea, 0x03, 0x0a, 0x0a, 0x44, + 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, + 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, 0x61, 0x74, + 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x64, + 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, + 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x12, 0x3e, 0x0a, 0x08, 0x63, + 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, + 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, + 0x74, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, 0x3a, 0x0a, 0x06, 0x70, + 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, - 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, - 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x41, 0x0a, 0x0d, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x04, - 0x6d, 0x65, 0x6e, 0x75, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, + 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x22, 0xd5, 0x02, 0x0a, 0x0f, 0x44, 0x65, 0x70, 0x61, + 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x05, 0x75, + 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0xea, - 0x03, 0x0a, 0x0a, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, - 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, - 0x77, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, - 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, - 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x72, 0x65, 0x65, - 0x5f, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, - 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, - 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, - 0x65, 0x6c, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, - 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0b, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x12, - 0x3e, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x0c, 0x20, 0x03, 0x28, + 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, + 0x3e, 0x0a, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, + 0x3e, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, - 0x3a, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x3a, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x22, 0xd5, 0x02, 0x0a, 0x0f, - 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, - 0x32, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, - 0x65, 0x72, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x12, 0x3e, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, - 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, - 0x72, 0x65, 0x6e, 0x12, 0x3a, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, - 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, - 0x52, 0x0a, 0x10, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x10, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x22, 0xa3, 0x01, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x70, 0x61, - 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, - 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, - 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, - 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x12, 0x41, 0x0a, 0x05, 0x65, 0x64, 0x67, 0x65, 0x73, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, + 0x65, 0x6e, 0x74, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x52, 0x0a, 0x10, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, + 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x64, 0x67, - 0x65, 0x73, 0x52, 0x05, 0x65, 0x64, 0x67, 0x65, 0x73, 0x22, 0x8b, 0x01, 0x0a, 0x13, 0x55, 0x73, - 0x65, 0x72, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x64, 0x67, 0x65, - 0x73, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, - 0x73, 0x65, 0x72, 0x12, 0x42, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x65, 0x70, - 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x8c, 0x02, 0x0a, 0x08, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x20, - 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, - 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, - 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x22, 0xfb, 0x02, 0x0a, 0x0d, 0x50, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x42, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x61, - 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, - 0x52, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x32, 0x0a, 0x05, - 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, + 0x73, 0x65, 0x72, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x10, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, + 0xa3, 0x01, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, + 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0d, + 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, + 0x69, 0x64, 0x12, 0x41, 0x0a, 0x05, 0x65, 0x64, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, + 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x64, 0x67, 0x65, 0x73, 0x52, 0x05, + 0x65, 0x64, 0x67, 0x65, 0x73, 0x22, 0x8b, 0x01, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, + 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, + 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, - 0x12, 0x44, 0x0a, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, - 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x4c, 0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5e, 0x0a, 0x14, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x14, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xfd, 0x03, 0x0a, 0x0a, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, - 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1e, 0x0a, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, - 0x51, 0x0a, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x08, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x75, 0x6c, 0x65, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x72, 0x75, 0x6c, - 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, - 0x64, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x1a, 0x3c, 0x0a, 0x0e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x75, - 0x6c, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x22, 0xd9, 0x03, 0x0a, 0x0f, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, - 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, + 0x42, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, + 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, + 0x65, 0x6e, 0x74, 0x22, 0x8c, 0x02, 0x0a, 0x08, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, + 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, + 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, + 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x0d, + 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, + 0x69, 0x64, 0x22, 0xfb, 0x02, 0x0a, 0x0d, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x45, + 0x64, 0x67, 0x65, 0x73, 0x12, 0x42, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, + 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x65, + 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x32, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x09, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x09, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x52, 0x0a, 0x10, - 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x10, - 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x5e, 0x0a, 0x14, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x14, 0x70, 0x65, 0x72, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, + 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x44, 0x0a, 0x0b, + 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, + 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, + 0x6e, 0x73, 0x12, 0x4c, 0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5e, 0x0a, 0x14, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, + 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x14, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x22, 0x5a, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x83, 0x01, 0x0a, - 0x11, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x64, 0x67, - 0x65, 0x73, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, - 0x75, 0x73, 0x65, 0x72, 0x12, 0x3c, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x22, 0x6c, 0x0a, 0x12, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, - 0x22, 0x9b, 0x01, 0x0a, 0x17, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x3c, 0x0a, 0x08, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x42, 0x0a, 0x0a, 0x70, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x60, - 0x0a, 0x0e, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, - 0x22, 0x8b, 0x01, 0x0a, 0x13, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x42, 0x0a, 0x0a, 0x70, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x86, - 0x01, 0x0a, 0x12, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, - 0x07, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x9b, 0x01, 0x0a, 0x17, 0x50, 0x65, 0x72, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x45, 0x64, - 0x67, 0x65, 0x73, 0x12, 0x42, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0xbf, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, + 0x22, 0xfd, 0x03, 0x0a, 0x0a, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, + 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, + 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, + 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, + 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, + 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, + 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x64, + 0x61, 0x74, 0x61, 0x5f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x51, 0x0a, 0x0a, 0x64, + 0x61, 0x74, 0x61, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x31, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x22, + 0x0a, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x09, + 0x20, 0x03, 0x28, 0x03, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, + 0x64, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, + 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x73, 0x1a, 0x3c, 0x0a, 0x0e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0xd9, 0x03, 0x0a, 0x0f, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x45, + 0x64, 0x67, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, + 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x42, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, - 0x41, 0x56, 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, - 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, - 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, - 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, - 0x3a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, + 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x52, 0x0a, 0x10, 0x72, 0x6f, 0x6c, 0x65, + 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, + 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x10, 0x72, 0x6f, 0x6c, 0x65, + 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5e, 0x0a, 0x14, + 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x14, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x5e, 0x0a, 0x14, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x6d, + 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x14, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x5a, 0x0a, 0x0c, + 0x55, 0x73, 0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x83, 0x01, 0x0a, 0x11, 0x55, 0x73, 0x65, + 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, + 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, + 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, + 0x12, 0x3c, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x6c, + 0x0a, 0x12, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, + 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x9b, 0x01, 0x0a, + 0x17, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x3c, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x42, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, + 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x60, 0x0a, 0x0e, 0x52, 0x6f, + 0x6c, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, + 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, + 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, + 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x8b, 0x01, 0x0a, + 0x13, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x45, + 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, + 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x42, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, + 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x86, 0x01, 0x0a, 0x12, 0x50, + 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, + 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x22, 0x9b, 0x01, 0x0a, 0x17, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, + 0x42, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, + 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x42, 0xbf, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, + 0x42, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x19, + 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, 0x41, 0x56, 0x53, 0x53, + 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, 0x41, 0x70, 0x69, 0x5c, + 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, + 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, + 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x79, 0x73, + 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/v1/services/system/types.pb.validate.go b/api/v1/services/system/types.pb.validate.go index 3d0d7370..f38b191e 100644 --- a/api/v1/services/system/types.pb.validate.go +++ b/api/v1/services/system/types.pb.validate.go @@ -1256,6 +1256,8 @@ func (m *User) validate(all bool) error { // no validation rules for Password + // no validation rules for ConfirmPassword + // no validation rules for Salt // no validation rules for Phone diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index 604ee8a4..aa868de7 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -156,7 +156,7 @@ func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Aut _, err = updater.Sync(context.Background()) if err != nil { - return nil, err + log.Errorf("Policy sync failed: %v", err) } auth, err := authorizerFromOptions(updater, options) if err != nil { diff --git a/contrib/security/authz/casbin/update.go b/contrib/security/authz/casbin/update.go index 8dc4d2ec..dd593cc0 100644 --- a/contrib/security/authz/casbin/update.go +++ b/contrib/security/authz/casbin/update.go @@ -76,13 +76,15 @@ func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { } if len(policies) > 0 { - fmt.Printf("Adapter: %T\n", u.adapter) + for s, v := range policies { + log.Infof("record policy: type(%s), len(%d)", s, len(v)) + } switch setter := u.adapter.(type) { case *adapter: - log.Infof("set policies(inner): %v", policies) + log.Info("set policies(inner)") setter.typedPolicies = policies case security.PolicyRegistry: - log.Infof("set policies: %v", policies) + log.Info("set policies") pm := maps.Transform(policies, func(k string, v [][]string) (string, any, bool) { return k, any(v), true }) @@ -113,7 +115,7 @@ func (u *PolicyUpdater) Watch(ctx context.Context, notifier persist.Watcher) { select { case <-ticker.C: if update, err := u.Sync(ctx); err != nil || !update { - log.Errorf("Policy sync failed: %v", err) + log.Errorf("Policy sync failed: err(%v) update(%t)", err, update) continue } _ = notifier.Update() diff --git a/internal/mods/system/dal/login.dal.go b/internal/mods/system/dal/login.dal.go index dad2a779..3f72d8ad 100644 --- a/internal/mods/system/dal/login.dal.go +++ b/internal/mods/system/dal/login.dal.go @@ -91,7 +91,7 @@ func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.Log // get user info log.Debugf("Getting userData info for username %s", data.Username) - userData, err := repo.User.GetByUserName(ctx, data.Username, user.FieldID, user.FieldPassword, user.FieldSalt, user.FieldStatus) + userData, err := repo.User.GetByUsername(ctx, data.Username, user.FieldID, user.FieldEncryptedPassword, user.FieldStatus) if err != nil { log.Errorf("Error getting userData info: %v", err) return nil, err @@ -109,7 +109,7 @@ func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.Log // check password log.Debugf("Comparing password for userData %s", data.Username) - if err := hash.Verify(userData.Password, data.Password); err != nil { + if err := hash.Verify(userData.EncryptedPassword, data.Password); err != nil { log.Warnf("Invalid password for userData %s", data.Username) return nil, dto.ErrInvalidPassword } diff --git a/internal/mods/system/dal/user.dal.go b/internal/mods/system/dal/user.dal.go index c1b0fdef..f0c6669b 100644 --- a/internal/mods/system/dal/user.dal.go +++ b/internal/mods/system/dal/user.dal.go @@ -50,7 +50,7 @@ func (repo userRepo) ListResourceByUserID(ctx context.Context, id int64, return dto.ConvertResources(resources), nil } -func (repo userRepo) GetByUserName(ctx context.Context, username string, fields ...string) (*dto.UserPB, error) { +func (repo userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*dto.UserNode, error) { query := repo.db.User(ctx).Query().Where(user.UsernameEQ(username)) var option dto.UserQueryOption if len(fields) > 0 { @@ -61,7 +61,10 @@ func (repo userRepo) GetByUserName(ctx context.Context, username string, fields if err != nil { return nil, err } - return dto.ConvertUser2PB(result), nil + return &dto.UserNode{ + UserPB: *dto.ConvertUser2PB(result), + EncryptedPassword: result.EncryptedPassword, + }, nil } func (repo userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { @@ -126,10 +129,14 @@ func (repo userRepo) Update(ctx context.Context, userPB *dto.UserPB, options ... if len(userPB.Roles) > 0 { update.ClearRoles() update.AddRoles(dto.ConvertRolesPB2Object(userPB.Roles)...) + } else { + update.ClearRoles() } if len(userPB.RoleIds) > 0 { update.ClearRoles() update.AddRoleIDs(userPB.RoleIds...) + } else { + update.ClearRoles() } update.SetUser(obj, user.SelectColumns([]string{ user.FieldNickname, diff --git a/internal/mods/system/dto/dto.go b/internal/mods/system/dto/dto.go index 87b64a45..2d0aee8d 100644 --- a/internal/mods/system/dto/dto.go +++ b/internal/mods/system/dto/dto.go @@ -71,7 +71,7 @@ func ConvertUser2PB(goModel *User) (pbModel *UserPB) { pbModel.Avatar = goModel.Avatar pbModel.Name = goModel.Name pbModel.Gender = ConvertGender2PB(goModel.Gender) - //pbModel.Password = goModel.Password + //pbModel.Password = goModel.EncryptedPassword //pbModel.Salt = goModel.Salt pbModel.Phone = goModel.Phone pbModel.Email = goModel.Email diff --git a/internal/mods/system/dto/user.go b/internal/mods/system/dto/user.go index 03540500..d88adca8 100644 --- a/internal/mods/system/dto/user.go +++ b/internal/mods/system/dto/user.go @@ -32,8 +32,9 @@ type ( type UserNode struct { UserPB - IsSystem bool `json:"is_system"` - RoleKeywords []string `json:"role_keywords"` + IsSystem bool `json:"is_system"` + RoleKeywords []string `json:"role_keywords"` + EncryptedPassword string `json:"encrypted_password"` } // UserRepo is a UserPB repository interface. @@ -44,7 +45,7 @@ type UserRepo interface { Update(context.Context, *UserPB, ...UserMutationOption) (*UserPB, error) List(context.Context, *ListUsersRequest, ...UserQueryOption) ([]*UserPB, int32, error) AddRoleIDs(context.Context, int64, []int64, ...UserMutationOption) error - GetByUserName(context.Context, string, ...string) (*UserPB, error) + GetByUsername(context.Context, string, ...string) (*UserNode, error) GetRoleIDs(context.Context, int64) ([]int64, error) ListResourceByUserID(context.Context, int64, ...UserQueryOption) ([]*ResourcePB, error) Current(context.Context, int64) (*UserPB, error) diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 111dcab4..fb8ad2ca 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -2104,6 +2104,11 @@ paths: @Decrypted don't show this field in response schema: type: string + - name: user.confirm_password + in: query + description: user.field.confirm_password + schema: + type: string - name: user.salt in: query description: |- @@ -3299,6 +3304,9 @@ components: description: |- user.field.password @Decrypted don't show this field in response + confirm_password: + type: string + description: user.field.confirm_password salt: type: string description: |- From 2ce824c40d66e767d9024bd40a326bdeed9056bc Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 23 Apr 2025 16:14:39 +0800 Subject: [PATCH 016/158] refactor(bootstrap): update middleware configuration and naming - Remove unused agent context functions - Update middleware configuration in bootstrap - Rename and restructure captcha configuration - Update health check configuration - Refactor middleware usage in casbin and system servers - Update logger middleware in agent HTTP server --- buf.lock | 4 +- cmd/internal/start/start.go | 31 +- helpers/securityx/security.go | 2 +- internal/configs/basis_config.proto | 9 +- internal/configs/bootstrap.pb.go | 4 +- internal/configs/bootstrap.pb.validate.go | 6 +- internal/configs/bootstrap.proto | 31 +- internal/configs/captcha.proto | 42 +- internal/configs/server.pb.go | 4 +- internal/configs/server.pb.validate.go | 6 +- internal/configs/server.proto | 15 - internal/loader/bootstrap_default.go | 4 +- internal/mods/agent/auth_test.go | 2 +- internal/mods/agent/http.go | 8 +- internal/mods/casbin/server/gins.go | 2 +- internal/mods/system/server/gins.go | 2 +- internal/mods/system/server/server.go | 18 +- third_party/buf/validate/validate.proto | 130 +++--- third_party/config/v1/gateway.proto | 10 +- third_party/config/v1/security.proto | 2 +- third_party/config/v1/service.proto | 1 - third_party/config/v1/storage.proto | 369 ++++++++++++++++++ third_party/google/api/annotations.proto | 2 +- third_party/google/api/client.proto | 16 +- .../google/api/expr/v1alpha1/checked.proto | 2 +- .../google/api/expr/v1alpha1/eval.proto | 2 +- .../google/api/expr/v1alpha1/explain.proto | 2 +- .../google/api/expr/v1alpha1/syntax.proto | 2 +- .../google/api/expr/v1alpha1/value.proto | 2 +- .../google/api/expr/v1beta1/decl.proto | 2 +- .../google/api/expr/v1beta1/eval.proto | 2 +- .../google/api/expr/v1beta1/expr.proto | 2 +- .../google/api/expr/v1beta1/source.proto | 2 +- .../google/api/expr/v1beta1/value.proto | 2 +- third_party/google/api/field_behavior.proto | 2 +- third_party/google/api/field_info.proto | 2 +- third_party/google/api/http.proto | 3 +- third_party/google/api/httpbody.proto | 2 +- third_party/google/api/launch_stage.proto | 2 +- third_party/google/api/resource.proto | 3 +- third_party/google/api/visibility.proto | 3 +- .../google/bytestream/bytestream.proto | 2 +- third_party/google/geo/type/viewport.proto | 2 +- .../google/longrunning/operations.proto | 2 +- third_party/google/protobuf/descriptor.proto | 58 +++ third_party/google/protobuf/go_features.proto | 23 ++ .../google/protobuf/java_features.proto | 18 + third_party/google/protobuf/wrappers.proto | 42 +- third_party/google/rpc/code.proto | 2 +- .../rpc/context/attribute_context.proto | 2 +- third_party/google/rpc/error_details.proto | 67 +++- third_party/google/rpc/status.proto | 2 +- third_party/google/type/calendar_period.proto | 2 +- third_party/google/type/color.proto | 2 +- third_party/google/type/date.proto | 2 +- third_party/google/type/datetime.proto | 2 +- third_party/google/type/dayofweek.proto | 2 +- third_party/google/type/decimal.proto | 2 +- third_party/google/type/expr.proto | 2 +- third_party/google/type/fraction.proto | 2 +- third_party/google/type/interval.proto | 2 +- third_party/google/type/latlng.proto | 2 +- third_party/google/type/localized_text.proto | 2 +- third_party/google/type/money.proto | 2 +- third_party/google/type/month.proto | 2 +- third_party/google/type/phone_number.proto | 2 +- third_party/google/type/postal_address.proto | 2 +- third_party/google/type/quaternion.proto | 2 +- third_party/google/type/timeofday.proto | 2 +- third_party/pagination/v1/pagination.proto | 16 +- 70 files changed, 794 insertions(+), 233 deletions(-) create mode 100644 third_party/config/v1/storage.proto diff --git a/buf.lock b/buf.lock index 6ec7add3..9f6ca431 100644 --- a/buf.lock +++ b/buf.lock @@ -14,5 +14,5 @@ deps: commit: c2de25f14fa445a79a054214f31d17a8 digest: b5:3e4dac0d26ce9db17309aeb845f0efb38ec7db1af06ee3c6b8dce2f4f7f53f126d62233c4910410384ead7f0a0edb6448cb389e62d1e3da5e927c3a980828f0b - name: buf.build/origadmin/runtime - commit: d177f682a04e456889276f6c6d44ff8b - digest: b5:e8721a3184109a3e2991d16028ec5d3c1a2e17833240220e7b2a42f794ac2d5f3e0e2d7282264e3e7177f017ac4655a154b91c580097376c853274ede8b9c555 + commit: 42c0e727146c4a8eb49d923613bedd0d + digest: b5:bb3df3f4838ddf189dc40459345a4f68c9806650d02efd92eaa71437e262358e1d2331593e391ba52d4c2a4d2906175d573e623ef183dc914ec3880cbd1444c5 diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index fdc75bc8..3cb51fd4 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -120,13 +120,6 @@ func startCommandRun(cmd *cobra.Command, args []string) error { //path := filepath.Join(flags.WorkDir, flags.ConfigPath) //envpath := filepath.Join(flags.WorkDir, flags.EnvPath) log.Infow("msg", "start info", "workpath", flags.WorkPath(), startStatic, staticDir) - //env, _ := bootstrap.LoadEnv(envpath) - //bs, err := bootstrap.FromLocalPath(flags.ServiceName, path, l) - //if err != nil { - // return errors.Wrap(err, "load config error") - //} - //src := loader.LoadSourceFiles(flags.WorkDir, flags.ConfigPath) - //source := loader.FileSourceConfig(flags.WorkPath()) if daemon, _ := cmd.Flags().GetBool("daemon"); daemon { bin, err := filepath.Abs(os.Args[0]) if err != nil { @@ -155,22 +148,20 @@ func startCommandRun(cmd *cobra.Command, args []string) error { return errors.Wrap(err, "load config error") } if bs == nil { - return fmt.Errorf("bootstrap config not found") + return errors.New("bootstrap config not found") } - if bs.CryptoType == "argon2" { - err := hash.UseCrypto(types.TypeArgon2) - if err != nil { - return err - } + + if err := hash.UseCrypto(types.Type(bs.CryptoType)); err != nil { + return errors.Wrap(err, "use crypto error") } - //log.Infof("bootstrap: %+v", loader.PrintString(bs)) lockfile := fmt.Sprintf("%s.lock", command.ToLower(cmd)) if err = os.WriteFile(lockfile, []byte(fmt.Sprintf("%d", os.Getpid())), 0o600); err == nil { defer os.Remove(lockfile) + } else { + return errors.Wrap(err, "write lock file error") } - //engine := gin.New() - //info to ctx + app, cleanup, err := buildInjectors(cmd.Context(), bs, l) if err != nil { return err @@ -193,16 +184,12 @@ func NewApp(ctx context.Context, injector *loader.InjectorClient) *kratos.App { kratos.Signal(syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT), kratos.Logger(injector.Logger), kratos.Server(injector.Server), - //kratos.Server(injector.ServerGINS), } - //err := loader.InjectorGinServer(injector) - //if err != nil { - // log.Errorf("injector gin server error: %v", err) - // os.Exit(1) - //} + if flags.Env == "release" { gin.SetMode(gin.ReleaseMode) } + gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) { log.Infow("msg", "GIN route", "method", httpMethod, "path", absolutePath, "operation", handlerName, "handlers", nuHandlers) } diff --git a/helpers/securityx/security.go b/helpers/securityx/security.go index 35ba5a6a..93a754c6 100644 --- a/helpers/securityx/security.go +++ b/helpers/securityx/security.go @@ -154,7 +154,7 @@ func (obj SecurityBridge) aggregateTokenParsers(outer ...func(ctx context.Contex } } -func (obj SecurityBridge) Build() middleware.KMiddleware { +func (obj SecurityBridge) Middleware() middleware.KMiddleware { if obj.TokenParser == nil { obj.TokenParser = obj.aggregateTokenParsers( FromTransportServer(obj.AuthenticationHeader, obj.Scheme.String()), diff --git a/internal/configs/basis_config.proto b/internal/configs/basis_config.proto index bc59a2cd..d45d86ea 100644 --- a/internal/configs/basis_config.proto +++ b/internal/configs/basis_config.proto @@ -1,12 +1,15 @@ syntax = "proto3"; package configs.api; -import "configs/root_user.proto"; +// 移除对root_user的引用(迁移至安全配置模块) +// import "configs/root_user.proto"; import "configs/captcha.proto"; option go_package = "origadmin/application/admin/internal/configs"; message BasisConfig { - configs.api.RootUser root_user = 1 [json_name = "root_user"]; + // configs.api.RootUser root_user = 1 [json_name = "root_user"]; configs.api.Captcha captcha = 2 [json_name = "captcha"]; -} + + config.v1.Security security = 3 [json_name = "security"]; +} \ No newline at end of file diff --git a/internal/configs/bootstrap.pb.go b/internal/configs/bootstrap.pb.go index 700443b2..d7d65477 100644 --- a/internal/configs/bootstrap.pb.go +++ b/internal/configs/bootstrap.pb.go @@ -444,7 +444,7 @@ var file_configs_bootstrap_proto_goTypes = []any{ (*v1.Service)(nil), // 5: config.v1.Service (*v1.Data)(nil), // 6: config.v1.Data (*v1.Registry)(nil), // 7: config.v1.Registry - (*v11.Middleware)(nil), // 8: middleware.v1.Build + (*v11.Middleware)(nil), // 8: middleware.v1.Middleware (*v12.AuthN)(nil), // 9: security.v1.AuthN (*v12.AuthZ)(nil), // 10: security.v1.AuthZ (*v1.Security)(nil), // 11: config.v1.Security @@ -457,7 +457,7 @@ var file_configs_bootstrap_proto_depIdxs = []int32{ 5, // 2: configs.api.Bootstrap.service:type_name -> config.v1.Service 6, // 3: configs.api.Bootstrap.data:type_name -> config.v1.Data 7, // 4: configs.api.Bootstrap.registry:type_name -> config.v1.Registry - 8, // 5: configs.api.Bootstrap.middleware:type_name -> middleware.v1.Build + 8, // 5: configs.api.Bootstrap.middleware:type_name -> middleware.v1.Middleware 9, // 6: configs.api.Bootstrap.authn:type_name -> security.v1.AuthN 10, // 7: configs.api.Bootstrap.authz:type_name -> security.v1.AuthZ 11, // 8: configs.api.Bootstrap.security:type_name -> config.v1.Security diff --git a/internal/configs/bootstrap.pb.validate.go b/internal/configs/bootstrap.pb.validate.go index 9d69d38a..54c36fb8 100644 --- a/internal/configs/bootstrap.pb.validate.go +++ b/internal/configs/bootstrap.pb.validate.go @@ -307,7 +307,7 @@ func (m *Bootstrap) validate(all bool) error { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ - field: "Build", + field: "Middleware", reason: "embedded message failed validation", cause: err, }) @@ -315,7 +315,7 @@ func (m *Bootstrap) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ - field: "Build", + field: "Middleware", reason: "embedded message failed validation", cause: err, }) @@ -324,7 +324,7 @@ func (m *Bootstrap) validate(all bool) error { } else if v, ok := interface{}(m.GetMiddleware()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ - field: "Build", + field: "Middleware", reason: "embedded message failed validation", cause: err, } diff --git a/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto index 1a2abd6d..ebc7dd79 100644 --- a/internal/configs/bootstrap.proto +++ b/internal/configs/bootstrap.proto @@ -18,9 +18,21 @@ message EntrySelectorConfig { string version = 4 [json_name = "version"]; } +message ServiceConfig { + string name = 1 [ + json_name = "name", + (validate.rules).string.min_len = 1 + ]; + Entry entry = 2 [json_name = "entry"]; // 各服务独立入口配置 + config.v1.Service service = 3 [json_name = "service"]; // 服务专用配置 +// string registry_path = 4 [json_name = "registry_path"]; // 服务发现注册路径 +} + message Bootstrap { // name is the application name or service name for used string name = 1 [json_name = "name"]; + string version = 2 [json_name = "version"]; + string crypto_type = 3 [json_name = "crypto_type"]; string mode = 5 [ json_name = "mode", (validate.rules).string = { // Ensure this matches the new import @@ -30,10 +42,23 @@ message Bootstrap { ] } ]; - string version = 2 [json_name = "version"]; - string crypto_type = 3 [json_name = "crypto_type"]; - map servers = 4 [json_name = "servers"]; + string environment = 6 [ + json_name = "environment", + (validate.rules).string = { + in: [ + "development", + "production" + ] + } + ]; + bool enable_dynamic_config = 7 [json_name = "enable_dynamic_config"]; + + message HealthCheck { + int32 timeout = 1 [json_name = "timeout"]; + string path = 2 [json_name = "path"]; + } + HealthCheck health_check = 1002; // Entry message Entry { string scheme = 1 [json_name = "scheme"]; diff --git a/internal/configs/captcha.proto b/internal/configs/captcha.proto index 57758471..f8f938fc 100644 --- a/internal/configs/captcha.proto +++ b/internal/configs/captcha.proto @@ -1,42 +1,24 @@ syntax = "proto3"; package configs.api; -import "validate/validate.proto"; - option go_package = "origadmin/application/admin/internal/configs"; message Captcha { - // Length of the verification code int32 length = 1 [json_name = "length"]; - // CAPTCHA width int32 width = 2 [json_name = "width"]; - // CAPTCHA height int32 height = 3 [json_name = "height"]; - // Type of cache to use for storing CAPTCHA data - string cache_type = 4 [ - json_name = "cache_type", - (validate.rules).string = { - in: [ - "memory", - "redis" - ] - } - ]; + + string storage_name = 4 [json_name = "storage_name"]; - // Redis configuration for CAPTCHA cache - message Redis { - // Address of the Redis server - string addr = 1 [json_name = "addr"]; - // Username for Redis authentication - string username = 2 [json_name = "username"]; - // Password for Redis authentication - string password = 3 [json_name = "password"]; - // Database index for Redis - int32 db = 4 [json_name = "db"]; - // Prefix for Redis keys (default: "admin:captcha") - string key_prefix = 5 [json_name = "key_prefix"]; - } + config.v1.Storage storage = 5 [json_name = "storage"]; + // 注释原有Redis配置(应由公共配置管理) + // message Redis { + // string addr = 1 [json_name = "addr"]; + // string username = 2 [json_name = "username"]; + // string password = 3 [json_name = "password"]; + // int32 db = 4 [json_name = "db"]; + // string key_prefix = 5 [json_name = "key_prefix"]; + // } - // Redis instance for CAPTCHA cache - Redis redis = 5 [json_name = "redis"]; + // Redis redis = 5 [json_name = "redis"]; } diff --git a/internal/configs/server.pb.go b/internal/configs/server.pb.go index e22cac73..8b278a58 100644 --- a/internal/configs/server.pb.go +++ b/internal/configs/server.pb.go @@ -176,13 +176,13 @@ var file_configs_server_proto_goTypes = []any{ (*v1.Service)(nil), // 1: config.v1.Service (*v1.Data)(nil), // 2: config.v1.Data (*v1.Registry)(nil), // 3: config.v1.Registry - (*v11.Middleware)(nil), // 4: middleware.v1.Build + (*v11.Middleware)(nil), // 4: middleware.v1.Middleware } var file_configs_server_proto_depIdxs = []int32{ 1, // 0: origadmin.configs.api.Server.service:type_name -> config.v1.Service 2, // 1: origadmin.configs.api.Server.data:type_name -> config.v1.Data 3, // 2: origadmin.configs.api.Server.registry:type_name -> config.v1.Registry - 4, // 3: origadmin.configs.api.Server.middleware:type_name -> middleware.v1.Build + 4, // 3: origadmin.configs.api.Server.middleware:type_name -> middleware.v1.Middleware 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name diff --git a/internal/configs/server.pb.validate.go b/internal/configs/server.pb.validate.go index d6d4cd64..af6ba3c3 100644 --- a/internal/configs/server.pb.validate.go +++ b/internal/configs/server.pb.validate.go @@ -154,7 +154,7 @@ func (m *Server) validate(all bool) error { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ServerValidationError{ - field: "Build", + field: "Middleware", reason: "embedded message failed validation", cause: err, }) @@ -162,7 +162,7 @@ func (m *Server) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ServerValidationError{ - field: "Build", + field: "Middleware", reason: "embedded message failed validation", cause: err, }) @@ -171,7 +171,7 @@ func (m *Server) validate(all bool) error { } else if v, ok := interface{}(m.GetMiddleware()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ServerValidationError{ - field: "Build", + field: "Middleware", reason: "embedded message failed validation", cause: err, } diff --git a/internal/configs/server.proto b/internal/configs/server.proto index 84ce6ec0..aac32581 100644 --- a/internal/configs/server.proto +++ b/internal/configs/server.proto @@ -1,7 +1,6 @@ syntax = "proto3"; package origadmin.configs.api; -import "buf/validate/validate.proto"; import "config/v1/data.proto"; import "config/v1/registry.proto"; import "config/v1/service.proto"; @@ -10,22 +9,8 @@ import "middleware/v1/middleware.proto"; option go_package = "origadmin/application/admin/internal/configs"; message Server { - // name is the application name or service name for used string name = 1 [json_name = "name"]; string version = 2 [json_name = "version"]; - string crypto_type = 3 [ - json_name = "crypto_type", - (buf.validate.field).string = { - in: [ - "argon2", - "scrypt", - "bcrypt", - "pbkdf2", - "sha256", - "sha512" - ] - } - ]; config.v1.Service service = 200 [json_name = "service"]; config.v1.Data data = 300 [json_name = "data"]; diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go index ce49f9f9..27bc30a7 100644 --- a/internal/loader/bootstrap_default.go +++ b/internal/loader/bootstrap_default.go @@ -167,7 +167,7 @@ func DefaultData() *configv1.Data { File: &configv1.Data_File{ Root: "", }, - Redis: &configv1.Data_Redis{}, + Redis: &configv1.Data_Redis{}, Badger: &configv1.Data_BadgerDS{}, Mongo: &configv1.Data_Mongo{}, Oss: &configv1.Data_Oss{}, @@ -301,7 +301,7 @@ func DefaultServiceMiddleware() *middlewarev1.Middleware { TokenType: "Bearer", }, }, - // Build filters + // Middleware filters Selector: &selectorv1.Selector{ Enabled: false, }, diff --git a/internal/mods/agent/auth_test.go b/internal/mods/agent/auth_test.go index 24be6176..67931f39 100644 --- a/internal/mods/agent/auth_test.go +++ b/internal/mods/agent/auth_test.go @@ -124,7 +124,7 @@ func TestAuthenticator(t *testing.T) { // Test security middleware chain func TestSecurityMiddlewareChain(t *testing.T) { // Create test middleware chain - chain := selector.Server(bridge.Build()).Match(func(ctx context.Context, operation string) bool { + chain := selector.Server(bridge.Middleware()).Match(func(ctx context.Context, operation string) bool { fmt.Println("operation:", operation) return operation == "/protected" }).Build() diff --git a/internal/mods/agent/http.go b/internal/mods/agent/http.go index c264eb48..a91705d6 100644 --- a/internal/mods/agent/http.go +++ b/internal/mods/agent/http.go @@ -81,7 +81,7 @@ func NewHTTPServerAgent(bootstrap *configs.Bootstrap, registrars []ServerRegiste Provider: &data{}, TokenParser: nil, } - serv := selector.Server(bridge.Build()).Match(func(ctx context.Context, operation string) bool { + serv := selector.Server(bridge.Middleware()).Match(func(ctx context.Context, operation string) bool { for _, p := range paths { if strings.HasPrefix(operation, p) { log.Debugf("Operation '%s' matches public path '%s', returning true", operation, p) @@ -91,7 +91,7 @@ func NewHTTPServerAgent(bootstrap *configs.Bootstrap, registrars []ServerRegiste log.Debugf("Operation '%s' no matches public path '%s'", operation, "*") return true }) - ms = append(ms, serv.Build(), CallerMiddleware()) + ms = append(ms, serv.Build(), CallLoggerMiddleware()) serviceConfig.Name = types.ZeroOr(serviceConfig.Name, "ORIGADMIN_SERVICE") srv, err := runtime.NewHTTPServiceServer(bootstrap.GetService(), service.WithHTTP( @@ -132,10 +132,10 @@ func DefaultPaths() []string { } } -func CallerMiddleware() middleware.KMiddleware { +func CallLoggerMiddleware() middleware.KMiddleware { return func(handler middleware.KHandler) middleware.KHandler { return func(ctx context.Context, req interface{}) (reply interface{}, err error) { - log.Infof("CallerMiddleware: %+v", ctx) + log.Infof("CallLoggerMiddleware: %+v", ctx) tr, ok := transport.FromServerContext(ctx) log.Infof("Caller Server: %+v, ok: %+v", tr, ok) tr, ok = transport.FromClientContext(ctx) diff --git a/internal/mods/casbin/server/gins.go b/internal/mods/casbin/server/gins.go index a6983b7b..26a1c030 100644 --- a/internal/mods/casbin/server/gins.go +++ b/internal/mods/casbin/server/gins.go @@ -43,7 +43,7 @@ func NewGINSServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.Op //middlewares, err := bootstrap.LoadMiddlewares(bootstrap.GetServiceName(), bootstrap, l) //if err == nil && len(middlewares) > 0 { - // opts = append(opts, http.Build(middlewares...)) + // opts = append(opts, http.Middleware(middlewares...)) //} if l != nil { diff --git a/internal/mods/system/server/gins.go b/internal/mods/system/server/gins.go index ca870bf2..5c592786 100644 --- a/internal/mods/system/server/gins.go +++ b/internal/mods/system/server/gins.go @@ -43,7 +43,7 @@ func NewGINSServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.Op //middlewares, err := bootstrap.LoadMiddlewares(bootstrap.GetServiceName(), bootstrap, l) //if err == nil && len(middlewares) > 0 { - // opts = append(opts, http.Build(middlewares...)) + // opts = append(opts, http.Middleware(middlewares...)) //} if l != nil { diff --git a/internal/mods/system/server/server.go b/internal/mods/system/server/server.go index 52730f10..ccbf6ba9 100644 --- a/internal/mods/system/server/server.go +++ b/internal/mods/system/server/server.go @@ -130,10 +130,10 @@ func NewSystemClient(bootstrap *configs.Bootstrap, l log.KLogger) (*service.GRPC return nil, errors.New("no entry") } - servers := bootstrap.GetServers() - if servers == nil { - return nil, errors.New("no servers") - } + //servers := bootstrap.GetServers() + //if servers == nil { + // return nil, errors.New("no servers") + //} registry := bootstrap.GetRegistry() if registry == nil { return nil, errors.New("no registry") @@ -176,14 +176,6 @@ func MiddlewareServer() middleware.KMiddleware { return func(ctx context.Context, req interface{}) (reply interface{}, err error) { if md, ok := metadata.FromClientContext(ctx); ok { log.Debugf("MiddlewareServer: found client context metadata: %+v", md) - // //for k, v := range md { - // // cmd[k] = v - // // log.Debugf("MiddlewareServer: adding key-value pair (%s, %s) to client context metadata", k, v) - // //} - // ctx = metadata.NewClientContext(ctx, cmd) - //log.Debugf("MiddlewareServer: updated client context metadata: %+v", md) - //} else { - // log.Debugf("MiddlewareServer: no client context metadata found") } else { log.Debugf("MiddlewareServer: no client context metadata found") } @@ -192,9 +184,7 @@ func MiddlewareServer() middleware.KMiddleware { } else { log.Debugf("MiddlewareServer: no server context metadata found") } - //log.Debugf("MiddlewareServer: calling handler function") reply, err = handler(ctx, req) - //log.Debugf("MiddlewareServer: handler function returned reply: %+v, error: %v", reply, err) return } } diff --git a/third_party/buf/validate/validate.proto b/third_party/buf/validate/validate.proto index f24d8dff..7d324160 100644 --- a/third_party/buf/validate/validate.proto +++ b/third_party/buf/validate/validate.proto @@ -1,4 +1,4 @@ -// Copyright 2023 Buf Technologies, Inc. +// Copyright 2023-2025 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -242,10 +242,8 @@ message FieldConstraints { TimestampRules timestamp = 22; } - // DEPRECATED: use ignore=IGNORE_ALWAYS instead. TODO: remove this field pre-v1. - optional bool skipped = 24 [deprecated = true]; - // DEPRECATED: use ignore=IGNORE_IF_UNPOPULATED instead. TODO: remove this field pre-v1. - optional bool ignore_empty = 26 [deprecated = true]; + reserved 24, 26; + reserved "skipped", "ignore_empty"; } // PredefinedConstraints are custom constraints that can be re-used with @@ -266,13 +264,17 @@ message PredefinedConstraints { // } // ``` repeated Constraint cel = 1; + + reserved 24, 26; + reserved + "skipped" + "ignore_empty" +; } // Specifies how FieldConstraints.ignore behaves. See the documentation for // FieldConstraints.required for definitions of "populated" and "nullable". enum Ignore { - // buf:lint:ignore ENUM_NO_ALLOW_ALIAS // allowance for deprecations. TODO: remove pre-v1. - option allow_alias = true; // Validation is only skipped if it's an unpopulated nullable fields. // // ```proto @@ -305,8 +307,7 @@ enum Ignore { IGNORE_UNSPECIFIED = 0; // Validation is skipped if the field is unpopulated. This rule is redundant - // if the field is already nullable. This value is equivalent behavior to the - // deprecated ignore_empty rule. + // if the field is already nullable. // // ```proto // syntax="proto3 @@ -416,10 +417,10 @@ enum Ignore { // ``` IGNORE_ALWAYS = 3; - // Deprecated: Use IGNORE_IF_UNPOPULATED instead. TODO: Remove this value pre-v1. - IGNORE_EMPTY = 1 [deprecated = true]; - // Deprecated: Use IGNORE_IF_DEFAULT_VALUE. TODO: Remove this value pre-v1. - IGNORE_DEFAULT = 2 [deprecated = true]; + reserved + "IGNORE_EMPTY" + "IGNORE_DEFAULT" +; } // FloatRules describes the constraints applied to `float` values. These @@ -586,7 +587,7 @@ message FloatRules { // ```proto // message MyFloat { // // value must be in list [1.0, 2.0, 3.0] - // repeated float value = 1 (buf.validate.field).float = { in: [1.0, 2.0, 3.0] }; + // float value = 1 [(buf.validate.field).float = { in: [1.0, 2.0, 3.0] }]; // } // ``` repeated float in = 6 [(predefined).cel = { @@ -601,7 +602,7 @@ message FloatRules { // ```proto // message MyFloat { // // value must not be in list [1.0, 2.0, 3.0] - // repeated float value = 1 (buf.validate.field).float = { not_in: [1.0, 2.0, 3.0] }; + // float value = 1 [(buf.validate.field).float = { not_in: [1.0, 2.0, 3.0] }]; // } // ``` repeated float not_in = 7 [(predefined).cel = { @@ -807,7 +808,7 @@ message DoubleRules { // ```proto // message MyDouble { // // value must be in list [1.0, 2.0, 3.0] - // repeated double value = 1 (buf.validate.field).double = { in: [1.0, 2.0, 3.0] }; + // double value = 1 [(buf.validate.field).double = { in: [1.0, 2.0, 3.0] }]; // } // ``` repeated double in = 6 [(predefined).cel = { @@ -822,7 +823,7 @@ message DoubleRules { // ```proto // message MyDouble { // // value must not be in list [1.0, 2.0, 3.0] - // repeated double value = 1 (buf.validate.field).double = { not_in: [1.0, 2.0, 3.0] }; + // double value = 1 [(buf.validate.field).double = { not_in: [1.0, 2.0, 3.0] }]; // } // ``` repeated double not_in = 7 [(predefined).cel = { @@ -1029,7 +1030,7 @@ message Int32Rules { // ```proto // message MyInt32 { // // value must be in list [1, 2, 3] - // repeated int32 value = 1 (buf.validate.field).int32 = { in: [1, 2, 3] }; + // int32 value = 1 [(buf.validate.field).int32 = { in: [1, 2, 3] }]; // } // ``` repeated int32 in = 6 [(predefined).cel = { @@ -1044,7 +1045,7 @@ message Int32Rules { // ```proto // message MyInt32 { // // value must not be in list [1, 2, 3] - // repeated int32 value = 1 (buf.validate.field).int32 = { not_in: [1, 2, 3] }; + // int32 value = 1 [(buf.validate.field).int32 = { not_in: [1, 2, 3] }]; // } // ``` repeated int32 not_in = 7 [(predefined).cel = { @@ -1244,7 +1245,7 @@ message Int64Rules { // ```proto // message MyInt64 { // // value must be in list [1, 2, 3] - // repeated int64 value = 1 (buf.validate.field).int64 = { in: [1, 2, 3] }; + // int64 value = 1 [(buf.validate.field).int64 = { in: [1, 2, 3] }]; // } // ``` repeated int64 in = 6 [(predefined).cel = { @@ -1259,7 +1260,7 @@ message Int64Rules { // ```proto // message MyInt64 { // // value must not be in list [1, 2, 3] - // repeated int64 value = 1 (buf.validate.field).int64 = { not_in: [1, 2, 3] }; + // int64 value = 1 [(buf.validate.field).int64 = { not_in: [1, 2, 3] }]; // } // ``` repeated int64 not_in = 7 [(predefined).cel = { @@ -1459,7 +1460,7 @@ message UInt32Rules { // ```proto // message MyUInt32 { // // value must be in list [1, 2, 3] - // repeated uint32 value = 1 (buf.validate.field).uint32 = { in: [1, 2, 3] }; + // uint32 value = 1 [(buf.validate.field).uint32 = { in: [1, 2, 3] }]; // } // ``` repeated uint32 in = 6 [(predefined).cel = { @@ -1474,7 +1475,7 @@ message UInt32Rules { // ```proto // message MyUInt32 { // // value must not be in list [1, 2, 3] - // repeated uint32 value = 1 (buf.validate.field).uint32 = { not_in: [1, 2, 3] }; + // uint32 value = 1 [(buf.validate.field).uint32 = { not_in: [1, 2, 3] }]; // } // ``` repeated uint32 not_in = 7 [(predefined).cel = { @@ -1673,7 +1674,7 @@ message UInt64Rules { // ```proto // message MyUInt64 { // // value must be in list [1, 2, 3] - // repeated uint64 value = 1 (buf.validate.field).uint64 = { in: [1, 2, 3] }; + // uint64 value = 1 [(buf.validate.field).uint64 = { in: [1, 2, 3] }]; // } // ``` repeated uint64 in = 6 [(predefined).cel = { @@ -1688,7 +1689,7 @@ message UInt64Rules { // ```proto // message MyUInt64 { // // value must not be in list [1, 2, 3] - // repeated uint64 value = 1 (buf.validate.field).uint64 = { not_in: [1, 2, 3] }; + // uint64 value = 1 [(buf.validate.field).uint64 = { not_in: [1, 2, 3] }]; // } // ``` repeated uint64 not_in = 7 [(predefined).cel = { @@ -1887,7 +1888,7 @@ message SInt32Rules { // ```proto // message MySInt32 { // // value must be in list [1, 2, 3] - // repeated sint32 value = 1 (buf.validate.field).sint32 = { in: [1, 2, 3] }; + // sint32 value = 1 [(buf.validate.field).sint32 = { in: [1, 2, 3] }]; // } // ``` repeated sint32 in = 6 [(predefined).cel = { @@ -1902,7 +1903,7 @@ message SInt32Rules { // ```proto // message MySInt32 { // // value must not be in list [1, 2, 3] - // repeated sint32 value = 1 (buf.validate.field).sint32 = { not_in: [1, 2, 3] }; + // sint32 value = 1 [(buf.validate.field).sint32 = { not_in: [1, 2, 3] }]; // } // ``` repeated sint32 not_in = 7 [(predefined).cel = { @@ -2101,7 +2102,7 @@ message SInt64Rules { // ```proto // message MySInt64 { // // value must be in list [1, 2, 3] - // repeated sint64 value = 1 (buf.validate.field).sint64 = { in: [1, 2, 3] }; + // sint64 value = 1 [(buf.validate.field).sint64 = { in: [1, 2, 3] }]; // } // ``` repeated sint64 in = 6 [(predefined).cel = { @@ -2116,7 +2117,7 @@ message SInt64Rules { // ```proto // message MySInt64 { // // value must not be in list [1, 2, 3] - // repeated sint64 value = 1 (buf.validate.field).sint64 = { not_in: [1, 2, 3] }; + // sint64 value = 1 [(buf.validate.field).sint64 = { not_in: [1, 2, 3] }]; // } // ``` repeated sint64 not_in = 7 [(predefined).cel = { @@ -2315,7 +2316,7 @@ message Fixed32Rules { // ```proto // message MyFixed32 { // // value must be in list [1, 2, 3] - // repeated fixed32 value = 1 (buf.validate.field).fixed32 = { in: [1, 2, 3] }; + // fixed32 value = 1 [(buf.validate.field).fixed32 = { in: [1, 2, 3] }]; // } // ``` repeated fixed32 in = 6 [(predefined).cel = { @@ -2330,7 +2331,7 @@ message Fixed32Rules { // ```proto // message MyFixed32 { // // value must not be in list [1, 2, 3] - // repeated fixed32 value = 1 (buf.validate.field).fixed32 = { not_in: [1, 2, 3] }; + // fixed32 value = 1 [(buf.validate.field).fixed32 = { not_in: [1, 2, 3] }]; // } // ``` repeated fixed32 not_in = 7 [(predefined).cel = { @@ -2529,7 +2530,7 @@ message Fixed64Rules { // ```proto // message MyFixed64 { // // value must be in list [1, 2, 3] - // repeated fixed64 value = 1 (buf.validate.field).fixed64 = { in: [1, 2, 3] }; + // fixed64 value = 1 [(buf.validate.field).fixed64 = { in: [1, 2, 3] }]; // } // ``` repeated fixed64 in = 6 [(predefined).cel = { @@ -2544,7 +2545,7 @@ message Fixed64Rules { // ```proto // message MyFixed64 { // // value must not be in list [1, 2, 3] - // repeated fixed64 value = 1 (buf.validate.field).fixed64 = { not_in: [1, 2, 3] }; + // fixed64 value = 1 [(buf.validate.field).fixed64 = { not_in: [1, 2, 3] }]; // } // ``` repeated fixed64 not_in = 7 [(predefined).cel = { @@ -2743,7 +2744,7 @@ message SFixed32Rules { // ```proto // message MySFixed32 { // // value must be in list [1, 2, 3] - // repeated sfixed32 value = 1 (buf.validate.field).sfixed32 = { in: [1, 2, 3] }; + // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { in: [1, 2, 3] }]; // } // ``` repeated sfixed32 in = 6 [(predefined).cel = { @@ -2758,7 +2759,7 @@ message SFixed32Rules { // ```proto // message MySFixed32 { // // value must not be in list [1, 2, 3] - // repeated sfixed32 value = 1 (buf.validate.field).sfixed32 = { not_in: [1, 2, 3] }; + // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { not_in: [1, 2, 3] }]; // } // ``` repeated sfixed32 not_in = 7 [(predefined).cel = { @@ -2957,7 +2958,7 @@ message SFixed64Rules { // ```proto // message MySFixed64 { // // value must be in list [1, 2, 3] - // repeated sfixed64 value = 1 (buf.validate.field).sfixed64 = { in: [1, 2, 3] }; + // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { in: [1, 2, 3] }]; // } // ``` repeated sfixed64 in = 6 [(predefined).cel = { @@ -2972,7 +2973,7 @@ message SFixed64Rules { // ```proto // message MySFixed64 { // // value must not be in list [1, 2, 3] - // repeated sfixed64 value = 1 (buf.validate.field).sfixed64 = { not_in: [1, 2, 3] }; + // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { not_in: [1, 2, 3] }]; // } // ``` repeated sfixed64 not_in = 7 [(predefined).cel = { @@ -3252,7 +3253,7 @@ message StringRules { // ```proto // message MyString { // // value must be in list ["apple", "banana"] - // repeated string value = 1 [(buf.validate.field).string.in = "apple", (buf.validate.field).string.in = "banana"]; + // string value = 1 [(buf.validate.field).string.in = "apple", (buf.validate.field).string.in = "banana"]; // } // ``` repeated string in = 10 [(predefined).cel = { @@ -3266,7 +3267,7 @@ message StringRules { // ```proto // message MyString { // // value must not be in list ["orange", "grape"] - // repeated string value = 1 [(buf.validate.field).string.not_in = "orange", (buf.validate.field).string.not_in = "grape"]; + // string value = 1 [(buf.validate.field).string.not_in = "orange", (buf.validate.field).string.not_in = "grape"]; // } // ``` repeated string not_in = 11 [(predefined).cel = { @@ -3278,7 +3279,7 @@ message StringRules { // patterns oneof well_known { // `email` specifies that the field value must be a valid email address - // (addr-spec only) as defined by [RFC 5322](https://tools.ietf.org/html/rfc5322#section-3.4.1). + // (addr-spec only) as defined by [RFC 5322](https://datatracker.ietf.org/doc/html/rfc5322#section-3.4.1). // If the field value isn't a valid email address, an error message will be generated. // // ```proto @@ -3301,7 +3302,7 @@ message StringRules { ]; // `hostname` specifies that the field value must be a valid - // hostname as defined by [RFC 1034](https://tools.ietf.org/html/rfc1034#section-3.5). This constraint doesn't support + // hostname as defined by [RFC 1034](https://datatracker.ietf.org/doc/html/rfc1034#section-3.5). This constraint doesn't support // internationalized domain names (IDNs). If the field value isn't a // valid hostname, an error message will be generated. // @@ -3394,9 +3395,10 @@ message StringRules { } ]; - // `uri` specifies that the field value must be a valid, - // absolute URI as defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3). If the field value isn't a valid, - // absolute URI, an error message will be generated. + // `uri` specifies that the field value must be a valid URI as defined by + // [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3). + // + // If the field value isn't a valid URI, an error message will be generated. // // ```proto // message MyString { @@ -3417,24 +3419,29 @@ message StringRules { } ]; - // `uri_ref` specifies that the field value must be a valid URI - // as defined by [RFC 3986](https://tools.ietf.org/html/rfc3986#section-3) and may be either relative or absolute. If the - // field value isn't a valid URI, an error message will be generated. + // `uri_ref` specifies that the field value must be a valid URI Reference as + // defined by [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-4.1). + // + // A URI Reference is either a [URI](https://datatracker.ietf.org/doc/html/rfc3986#section-3), + // or a [Relative Reference](https://datatracker.ietf.org/doc/html/rfc3986#section-4.2). + // + // If the field value isn't a valid URI Reference, an error message will be + // generated. // // ```proto // message MyString { - // // value must be a valid URI + // // value must be a valid URI Reference // string value = 1 [(buf.validate.field).string.uri_ref = true]; // } // ``` bool uri_ref = 18 [(predefined).cel = { id: "string.uri_ref" - message: "value must be a valid URI" + message: "value must be a valid URI Reference" expression: "!rules.uri_ref || this.isUriRef()" }]; // `address` specifies that the field value must be either a valid hostname - // as defined by [RFC 1034](https://tools.ietf.org/html/rfc1034#section-3.5) + // as defined by [RFC 1034](https://datatracker.ietf.org/doc/html/rfc1034#section-3.5) // (which doesn't support internationalized domain names or IDNs) or a valid // IP (v4 or v6). If the field value isn't a valid hostname or IP, an error // message will be generated. @@ -3459,7 +3466,7 @@ message StringRules { ]; // `uuid` specifies that the field value must be a valid UUID as defined by - // [RFC 4122](https://tools.ietf.org/html/rfc4122#section-4.1.2). If the + // [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). If the // field value isn't a valid UUID, an error message will be generated. // // ```proto @@ -3482,7 +3489,7 @@ message StringRules { ]; // `tuuid` (trimmed UUID) specifies that the field value must be a valid UUID as - // defined by [RFC 4122](https://tools.ietf.org/html/rfc4122#section-4.1.2) with all dashes + // defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2) with all dashes // omitted. If the field value isn't a valid UUID without dashes, an error message // will be generated. // @@ -3684,8 +3691,8 @@ message StringRules { // | Name | Number | Description | // |-------------------------------|--------|-------------------------------------------| // | KNOWN_REGEX_UNSPECIFIED | 0 | | - // | KNOWN_REGEX_HTTP_HEADER_NAME | 1 | HTTP header name as defined by [RFC 7230](https://tools.ietf.org/html/rfc7230#section-3.2) | - // | KNOWN_REGEX_HTTP_HEADER_VALUE | 2 | HTTP header value as defined by [RFC 7230](https://tools.ietf.org/html/rfc7230#section-3.2.4) | + // | KNOWN_REGEX_HTTP_HEADER_NAME | 1 | HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2) | + // | KNOWN_REGEX_HTTP_HEADER_VALUE | 2 | HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4) | KnownRegex well_known_regex = 24 [ (predefined).cel = { id: "string.well_known_regex.header_name" @@ -3713,7 +3720,7 @@ message StringRules { // This applies to regexes `HTTP_HEADER_NAME` and `HTTP_HEADER_VALUE` to // enable strict header validation. By default, this is true, and HTTP header - // validations are [RFC-compliant](https://tools.ietf.org/html/rfc7230#section-3). Setting to false will enable looser + // validations are [RFC-compliant](https://datatracker.ietf.org/doc/html/rfc7230#section-3). Setting to false will enable looser // validations that only disallow `\r\n\0` characters, which can be used to // bypass header matching rules. // @@ -3759,10 +3766,10 @@ message StringRules { enum KnownRegex { KNOWN_REGEX_UNSPECIFIED = 0; - // HTTP header name as defined by [RFC 7230](https://tools.ietf.org/html/rfc7230#section-3.2). + // HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2). KNOWN_REGEX_HTTP_HEADER_NAME = 1; - // HTTP header value as defined by [RFC 7230](https://tools.ietf.org/html/rfc7230#section-3.2.4). + // HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4). KNOWN_REGEX_HTTP_HEADER_VALUE = 2; } @@ -4821,12 +4828,6 @@ message Violation { // ``` optional FieldPath rule = 6; - // `field_path` is a human-readable identifier that points to the specific field that failed the validation. - // This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation. - // - // Deprecated: use the `field` instead. - optional string field_path = 1 [deprecated = true]; - // `constraint_id` is the unique identifier of the `Constraint` that was not fulfilled. // This is the same `id` that was specified in the `Constraint` message, allowing easy tracing of which rule was violated. optional string constraint_id = 2; @@ -4837,6 +4838,9 @@ message Violation { // `for_key` indicates whether the violation was caused by a map key, rather than a value. optional bool for_key = 4; + + reserved 1; + reserved "field_path"; } // `FieldPath` provides a path to a nested protobuf field. diff --git a/third_party/config/v1/gateway.proto b/third_party/config/v1/gateway.proto index 7f601336..4412c6e8 100644 --- a/third_party/config/v1/gateway.proto +++ b/third_party/config/v1/gateway.proto @@ -70,9 +70,17 @@ enum Protocol { UNSPECIFIED = 0; HTTP = 1; GRPC = 2; + CUSTOM = 3; } -message HealthCheck {} +message HealthCheck { + enum CheckType { + HTTP = 0; + TCP = 1; + } + CheckType type = 1; + string endpoint = 2; +} message Retry { // default attempts is 1 diff --git a/third_party/config/v1/security.proto b/third_party/config/v1/security.proto index 2a68cd15..b7d22e6e 100644 --- a/third_party/config/v1/security.proto +++ b/third_party/config/v1/security.proto @@ -138,7 +138,7 @@ message AuthZConfig { } // Disable security middleware bool disabled = 1 [json_name = "disabled"]; - // Direct release paths + // Direct release paths, paths exempt from authorization repeated string public_paths = 2 [json_name = "public_paths"]; // Type of authorization noop, casbin, opa, etc string type = 3 [ diff --git a/third_party/config/v1/service.proto b/third_party/config/v1/service.proto index 6192766b..568633ce 100644 --- a/third_party/config/v1/service.proto +++ b/third_party/config/v1/service.proto @@ -51,7 +51,6 @@ message Service { string version = 1; string builder = 2; } - // Service name for service discovery string name = 1 [json_name = "name"]; bool dynamic_endpoint = 2 [json_name = "dynamic_endpoint"]; diff --git a/third_party/config/v1/storage.proto b/third_party/config/v1/storage.proto new file mode 100644 index 00000000..e56e8edf --- /dev/null +++ b/third_party/config/v1/storage.proto @@ -0,0 +1,369 @@ +syntax = "proto3"; + +package config.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/duration.proto"; +import "validate/validate.proto"; + +option cc_enable_arenas = true; +option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option java_multiple_files = true; +option java_outer_classname = "StorageProto"; +option java_package = "com.github.origadmin.runtime.config.v1"; +option objc_class_prefix = "ORC"; + +message Migration { + bool enabled = 1 [ + json_name = "enabled", + (gnostic.openapi.v3.property) = {description: "whether to enable migration"} + ]; + string path = 2 [ + json_name = "path", + (gnostic.openapi.v3.property) = {description: "migration path"} + ]; + repeated string names = 3 [ + json_name = "names", + (gnostic.openapi.v3.property) = {description: "migration name"} + ]; + string version = 4 [ + json_name = "version", + (gnostic.openapi.v3.property) = {description: "migration version"} + ]; + string mode = 5 [ + json_name = "mode", + (gnostic.openapi.v3.property) = {description: "migration mode"} + ]; +} + +// Database +message Database { + // Debugging + bool debug = 1 [ + json_name = "debug", + (gnostic.openapi.v3.property) = {description: "whether to enable debug mode "} + ]; + // Dialect name: mysql, postgresql, mongodb, sqlite...... + string dialect = 2 [ + json_name = "dialect", + (validate.rules).string = { + in: [ + "mssql", + "mysql", + "postgresql", + "mongodb", + "sqlite", + "oracle", + "sqlserver", + "sqlite3" + ] + }, + (gnostic.openapi.v3.property) = {description: "database driver name"} + ]; + // Data source (DSN string) + string source = 3 [ + json_name = "source", + (gnostic.openapi.v3.property) = {description: "data source dsn string"} + ]; + // Data migration + Migration migration = 10 [ + json_name = "migration", + (gnostic.openapi.v3.property) = {description: "data migration"} + ]; + // Link tracking switch + bool enable_trace = 12 [ + json_name = "enable_trace", + (gnostic.openapi.v3.property) = {description: "link tracking switch"} + ]; + // Performance analysis switch + bool enable_metrics = 13 [ + json_name = "enable_metrics", + (gnostic.openapi.v3.property) = {description: "performance analysis switch"} + ]; + // Maximum number of free connections in the connection pool + int32 max_idle_connections = 20 [ + json_name = "max_idle_connections", + (gnostic.openapi.v3.property) = {description: "The maximum number of free connections in the connection pool"} + ]; + // Maximum number of open connections in the connection pool + int32 max_open_connections = 21 [ + json_name = "max_open_connections", + (gnostic.openapi.v3.property) = {description: "The maximum number of open connections in the connection pool"} + ]; + // Maximum length of time that the connection can be reused + int64 connection_max_lifetime = 22 [ + json_name = "connection_max_lifetime", + (gnostic.openapi.v3.property) = {description: "The maximum length of time a connection can be reused"} + ]; + // Maximum number of connections in the connection pool for reading + int64 connection_max_idle_time = 23 [ + json_name = "connection_max_idle_time", + (gnostic.openapi.v3.property) = {description: "The maximum number of connections in the connection pool for reading"} + ]; +} + +// Redis +message Redis { + string network = 1 [ + json_name = "network", + (gnostic.openapi.v3.property) = {description: "network type"} + ]; + string addr = 2 [ + json_name = "addr", + (gnostic.openapi.v3.property) = {description: "address"} + ]; + string password = 3 [ + json_name = "password", + (gnostic.openapi.v3.property) = {description: "cipher"} + ]; + int32 db = 4 [ + json_name = "db", + (gnostic.openapi.v3.property) = {description: "database index"} + ]; + int64 dial_timeout = 5 [ + json_name = "dial_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "dial timeout"} + ]; + int64 read_timeout = 6 [ + json_name = "read_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "read timeout"} + ]; + int64 write_timeout = 7 [ + json_name = "write_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "write timeout"} + ]; +} + +// Memcached +message Memcached { + string addr = 1 [ + json_name = "addr", + (gnostic.openapi.v3.property) = {description: "address"} + ]; + string username = 2 [ + json_name = "username", + (gnostic.openapi.v3.property) = {description: "username"} + ]; + string password = 3 [ + json_name = "password", + (gnostic.openapi.v3.property) = {description: "cipher"} + ]; + int32 max_idle = 4 [ + json_name = "max_idle", + (gnostic.openapi.v3.property) = { + description: "maximum number of idle connections" + minimum: 1 + } + ]; + int64 timeout = 5 [ + json_name = "timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "overtime"} + ]; +} + +// Memory +message Memory { + int32 size = 1 [ + json_name = "size", + (gnostic.openapi.v3.property) = {description: "size"} + ]; + int32 capacity = 2 [ + json_name = "capacity", + (gnostic.openapi.v3.property) = {description: "capacity"} + ]; + int64 expiration = 3 [ + json_name = "expiration", + (gnostic.openapi.v3.property) = {description: "expiration time"} + ]; + int64 cleanup_interval = 4 [ + json_name = "cleanup_interval", + (gnostic.openapi.v3.property) = {description: "clearance interval"} + ]; +} + +message BadgerDS { + string path = 1 [ + json_name = "path", + (gnostic.openapi.v3.property) = {description: "path"} + ]; + bool sync_writes = 2 [ + json_name = "sync_writes", + (gnostic.openapi.v3.property) = {description: "synchronous write or not"} + ]; + int32 value_log_file_size = 3 [ + json_name = "value_log_file_size", + (gnostic.openapi.v3.property) = {description: "value log file size"} + ]; + bool in_memory = 4 [ + json_name = "in_memory", + (gnostic.openapi.v3.property) = {description: "in memory or not"} + ]; + uint32 log_level = 5 [ + json_name = "log_level", + (validate.rules).uint32 = { + gte: 0 + lte: 3 + }, + (gnostic.openapi.v3.property) = {description: "log level"} + ]; +} + +// File +message File { + string root = 1 [ + json_name = "root", + (gnostic.openapi.v3.property) = {description: "root directory"} + ]; +} + +// OSS +message Oss { + string endpoint = 1 [ + json_name = "endpoint", + (gnostic.openapi.v3.property) = {description: "Storage service endpoint"} + ]; + string access_key_id = 2 [json_name = "access_key_id"]; + string access_key_secret = 3 [json_name = "access_key_secret"]; + string bucket = 4 [json_name = "bucket"]; + string region = 5 [json_name = "region"]; + bool ssl = 6 [json_name = "ssl"]; + int64 connect_timeout = 7 [ + json_name = "connect_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Connection timeout in milliseconds"} + ]; + int64 read_timeout = 8 [ + json_name = "read_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Read timeout in milliseconds"} + ]; +} + +// Mongo +message Mongo { + string uri = 1 [ + json_name = "uri", + (gnostic.openapi.v3.property) = {description: "MongoDB connection URI"} + ]; + string database = 2 [ + json_name = "database", + (gnostic.openapi.v3.property) = {description: "Database name"} + ]; + string username = 3 [json_name = "username"]; + string password = 4 [json_name = "password"]; + bool auth_source = 5 [json_name = "auth_source"]; + int32 max_pool_size = 6 [json_name = "max_pool_size"]; + int32 min_pool_size = 7 [json_name = "min_pool_size"]; + int64 connect_timeout = 8 [ + json_name = "connect_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Connection timeout in milliseconds"} + ]; +} + +// Cache +message Cache { + // Driver name: redis, memcached, etc. + string driver = 1 [ + json_name = "driver", + (validate.rules).string = { + in: [ + "none", + "redis", + "memcached", + "memory" + ] + }, + (gnostic.openapi.v3.property) = {description: "cache driver name"} + ]; + string name = 2 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "cache name"} + ]; + // Memcached + Memcached memcached = 10 [ + json_name = "memcached", + (gnostic.openapi.v3.property) = {description: "memcached cache configuration"} + ]; + // Memory cache + Memory memory = 11 [ + json_name = "memory", + (gnostic.openapi.v3.property) = {description: "memory cache configuration"} + ]; + // Redis + Redis redis = 12 [ + json_name = "redis", + (gnostic.openapi.v3.property) = {description: "redis cache configuration"} + ]; + // Badger + BadgerDS badger = 13 [ + json_name = "badger", + (gnostic.openapi.v3.property) = {description: "badger storage configuration"} + ]; +} + +message Storage { + string name = 1 [ + json_name = "name", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "Unique identifier for the storage configuration"} + ]; + + // Type + string type = 2 [ + json_name = "type", + (validate.rules).string = { + in: [ + "none", + "file", + "redis", + "mongo", + "oss", + "database", + "cache" + ] + }, + (gnostic.openapi.v3.property) = {description: "storage type"} + ]; + + // Database + Database database = 3 [ + json_name = "database", + (gnostic.openapi.v3.property) = {description: "database configuration"} + ]; + // Cache + Cache cache = 4 [ + json_name = "cache", + (gnostic.openapi.v3.property) = {description: "cache configuration"} + ]; + + // File + File file = 10 [ + json_name = "file", + (gnostic.openapi.v3.property) = {description: "file storage configuration"} + ]; + // Redis + Redis redis = 11 [ + json_name = "redis", + (gnostic.openapi.v3.property) = {description: "redis storage configuration"} + ]; + // Badger + BadgerDS badger = 12 [ + json_name = "badger", + (gnostic.openapi.v3.property) = {description: "badger storage configuration"} + ]; + // Mongo + Mongo mongo = 13 [ + json_name = "mongo", + (gnostic.openapi.v3.property) = {description: "mongo storage configuration"} + ]; + // OSS + Oss oss = 14 [ + json_name = "oss", + (gnostic.openapi.v3.property) = {description: "oss storage configuration"} + ]; +} diff --git a/third_party/google/api/annotations.proto b/third_party/google/api/annotations.proto index 84c48164..417edd8f 100644 --- a/third_party/google/api/annotations.proto +++ b/third_party/google/api/annotations.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/client.proto b/third_party/google/api/client.proto index 7e3e66e9..3d692560 100644 --- a/third_party/google/api/client.proto +++ b/third_party/google/api/client.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -281,6 +281,12 @@ message PythonSettings { // enabled by default 1 month after launching the feature in preview // packages. bool protobuf_pythonic_types_enabled = 2; + + // Disables generation of an unversioned Python package for this client + // library. This means that the module names will need to be versioned in + // import statements. For example `import google.cloud.library_v2` instead + // of `import google.cloud.library`. + bool unversioned_package_disabled = 3; } // Some settings. @@ -469,4 +475,12 @@ message SelectiveGapicGeneration { // An allowlist of the fully qualified names of RPCs that should be included // on public client surfaces. repeated string methods = 1; + + // Setting this to true indicates to the client generators that methods + // that would be excluded from the generation should instead be generated + // in a way that indicates these methods should not be consumed by + // end users. How this is expressed is up to individual language + // implementations to decide. Some examples may be: added annotations, + // obfuscated identifiers, or other language idiomatic patterns. + bool generate_omitted_as_internal = 2; } diff --git a/third_party/google/api/expr/v1alpha1/checked.proto b/third_party/google/api/expr/v1alpha1/checked.proto index c6849348..ffdbee5f 100644 --- a/third_party/google/api/expr/v1alpha1/checked.proto +++ b/third_party/google/api/expr/v1alpha1/checked.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/expr/v1alpha1/eval.proto b/third_party/google/api/expr/v1alpha1/eval.proto index 541bb0bb..cdf1d48d 100644 --- a/third_party/google/api/expr/v1alpha1/eval.proto +++ b/third_party/google/api/expr/v1alpha1/eval.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/expr/v1alpha1/explain.proto b/third_party/google/api/expr/v1alpha1/explain.proto index 06b6720d..cd5ffc29 100644 --- a/third_party/google/api/expr/v1alpha1/explain.proto +++ b/third_party/google/api/expr/v1alpha1/explain.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/expr/v1alpha1/syntax.proto b/third_party/google/api/expr/v1alpha1/syntax.proto index 7b6668db..b0cdd4d4 100644 --- a/third_party/google/api/expr/v1alpha1/syntax.proto +++ b/third_party/google/api/expr/v1alpha1/syntax.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/expr/v1alpha1/value.proto b/third_party/google/api/expr/v1alpha1/value.proto index 69d171d0..9d695207 100644 --- a/third_party/google/api/expr/v1alpha1/value.proto +++ b/third_party/google/api/expr/v1alpha1/value.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/expr/v1beta1/decl.proto b/third_party/google/api/expr/v1beta1/decl.proto index 652af36a..b433b2df 100644 --- a/third_party/google/api/expr/v1beta1/decl.proto +++ b/third_party/google/api/expr/v1beta1/decl.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/expr/v1beta1/eval.proto b/third_party/google/api/expr/v1beta1/eval.proto index eb6bd8d3..cb8928c3 100644 --- a/third_party/google/api/expr/v1beta1/eval.proto +++ b/third_party/google/api/expr/v1beta1/eval.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/expr/v1beta1/expr.proto b/third_party/google/api/expr/v1beta1/expr.proto index fb36385d..b20a860c 100644 --- a/third_party/google/api/expr/v1beta1/expr.proto +++ b/third_party/google/api/expr/v1beta1/expr.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/expr/v1beta1/source.proto b/third_party/google/api/expr/v1beta1/source.proto index 9906327b..fdf173ba 100644 --- a/third_party/google/api/expr/v1beta1/source.proto +++ b/third_party/google/api/expr/v1beta1/source.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/expr/v1beta1/value.proto b/third_party/google/api/expr/v1beta1/value.proto index 74f225ae..098e92e3 100644 --- a/third_party/google/api/expr/v1beta1/value.proto +++ b/third_party/google/api/expr/v1beta1/value.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/field_behavior.proto b/third_party/google/api/field_behavior.proto index 2865ba05..1fdaaed1 100644 --- a/third_party/google/api/field_behavior.proto +++ b/third_party/google/api/field_behavior.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/field_info.proto b/third_party/google/api/field_info.proto index 2cc0876d..aaa07a18 100644 --- a/third_party/google/api/field_info.proto +++ b/third_party/google/api/field_info.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/http.proto b/third_party/google/api/http.proto index e3270371..57621b53 100644 --- a/third_party/google/api/http.proto +++ b/third_party/google/api/http.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ syntax = "proto3"; package google.api; -option cc_enable_arenas = true; option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; option java_multiple_files = true; option java_outer_classname = "HttpProto"; diff --git a/third_party/google/api/httpbody.proto b/third_party/google/api/httpbody.proto index 32952715..e3e17c8a 100644 --- a/third_party/google/api/httpbody.proto +++ b/third_party/google/api/httpbody.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/launch_stage.proto b/third_party/google/api/launch_stage.proto index 9863fc23..1e86c1ad 100644 --- a/third_party/google/api/launch_stage.proto +++ b/third_party/google/api/launch_stage.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/api/resource.proto b/third_party/google/api/resource.proto index 3762af84..5669cbc9 100644 --- a/third_party/google/api/resource.proto +++ b/third_party/google/api/resource.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package google.api; import "google/protobuf/descriptor.proto"; -option cc_enable_arenas = true; option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; option java_multiple_files = true; option java_outer_classname = "ResourceProto"; diff --git a/third_party/google/api/visibility.proto b/third_party/google/api/visibility.proto index bb378bf0..0ab5bdc1 100644 --- a/third_party/google/api/visibility.proto +++ b/third_party/google/api/visibility.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package google.api; import "google/protobuf/descriptor.proto"; -option cc_enable_arenas = true; option go_package = "google.golang.org/genproto/googleapis/api/visibility;visibility"; option java_multiple_files = true; option java_outer_classname = "VisibilityProto"; diff --git a/third_party/google/bytestream/bytestream.proto b/third_party/google/bytestream/bytestream.proto index 8029f2d5..26bc609e 100644 --- a/third_party/google/bytestream/bytestream.proto +++ b/third_party/google/bytestream/bytestream.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/geo/type/viewport.proto b/third_party/google/geo/type/viewport.proto index df68a324..08c0cce8 100644 --- a/third_party/google/geo/type/viewport.proto +++ b/third_party/google/geo/type/viewport.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/longrunning/operations.proto b/third_party/google/longrunning/operations.proto index bb42620b..e0206a90 100644 --- a/third_party/google/longrunning/operations.proto +++ b/third_party/google/longrunning/operations.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/protobuf/descriptor.proto b/third_party/google/protobuf/descriptor.proto index 6011f72c..f63ff196 100644 --- a/third_party/google/protobuf/descriptor.proto +++ b/third_party/google/protobuf/descriptor.proto @@ -131,9 +131,15 @@ message FileDescriptorProto { // The supported values are "proto2", "proto3", and "editions". // // If `edition` is present, this value must be "editions". + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. optional string syntax = 12; // The edition of the proto file. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. optional Edition edition = 14; } @@ -546,6 +552,9 @@ message FileOptions { optional string ruby_package = 45; // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. optional FeatureSet features = 50; // The parser stores options it doesn't recognize here. @@ -632,6 +641,9 @@ message MessageOptions { optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true]; // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. optional FeatureSet features = 12; // The parser stores options it doesn't recognize here. See above. @@ -772,6 +784,9 @@ message FieldOptions { repeated EditionDefault edition_defaults = 20; // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. optional FeatureSet features = 21; // Information about the support window of a feature. @@ -808,6 +823,9 @@ message FieldOptions { message OneofOptions { // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. optional FeatureSet features = 1; // The parser stores options it doesn't recognize here. See above. @@ -840,6 +858,9 @@ message EnumOptions { optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true]; // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. optional FeatureSet features = 7; // The parser stores options it doesn't recognize here. See above. @@ -857,6 +878,9 @@ message EnumValueOptions { optional bool deprecated = 1 [default = false]; // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. optional FeatureSet features = 2; // Indicate that fields annotated with this enum value should not be printed @@ -877,6 +901,9 @@ message EnumValueOptions { message ServiceOptions { // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. optional FeatureSet features = 34; // Note: Field numbers 1 through 32 are reserved for Google's internal RPC @@ -922,6 +949,9 @@ message MethodOptions { [default = IDEMPOTENCY_UNKNOWN]; // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. optional FeatureSet features = 35; // The parser stores options it doesn't recognize here. See above. @@ -1068,6 +1098,29 @@ message FeatureSet { edition_defaults = { edition: EDITION_PROTO3, value: "ALLOW" } ]; + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0; + STYLE2024 = 1; + STYLE_LEGACY = 2; + } + optional EnforceNamingStyle enforce_naming_style = 7 [ + retention = RETENTION_SOURCE, + targets = TARGET_TYPE_FILE, + targets = TARGET_TYPE_EXTENSION_RANGE, + targets = TARGET_TYPE_MESSAGE, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_ONEOF, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_ENUM_ENTRY, + targets = TARGET_TYPE_SERVICE, + targets = TARGET_TYPE_METHOD, + feature_support = { + edition_introduced: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "STYLE_LEGACY" }, + edition_defaults = { edition: EDITION_2024, value: "STYLE2024" } + ]; + reserved 999; extensions 1000 to 9994 [ @@ -1082,6 +1135,11 @@ message FeatureSet { type: ".pb.JavaFeatures" }, declaration = { number: 1002, full_name: ".pb.go", type: ".pb.GoFeatures" }, + declaration = { + number: 1003, + full_name: ".pb.python", + type: ".pb.PythonFeatures" + }, declaration = { number: 9990, full_name: ".pb.proto1", diff --git a/third_party/google/protobuf/go_features.proto b/third_party/google/protobuf/go_features.proto index ceb3a13d..a9cc7923 100644 --- a/third_party/google/protobuf/go_features.proto +++ b/third_party/google/protobuf/go_features.proto @@ -19,6 +19,7 @@ extend google.protobuf.FeatureSet { message GoFeatures { // Whether or not to generate the deprecated UnmarshalJSON method for enums. + // Can only be true for proto using the Open Struct api. optional bool legacy_unmarshal_json_enum = 1 [ retention = RETENTION_RUNTIME, targets = TARGET_TYPE_ENUM, @@ -54,4 +55,26 @@ message GoFeatures { edition_defaults = { edition: EDITION_LEGACY, value: "API_LEVEL_UNSPECIFIED" }, edition_defaults = { edition: EDITION_2024, value: "API_OPAQUE" } ]; + + enum StripEnumPrefix { + STRIP_ENUM_PREFIX_UNSPECIFIED = 0; + STRIP_ENUM_PREFIX_KEEP = 1; + STRIP_ENUM_PREFIX_GENERATE_BOTH = 2; + STRIP_ENUM_PREFIX_STRIP = 3; + } + + optional StripEnumPrefix strip_enum_prefix = 3 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_ENUM_ENTRY, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2024, + }, + // TODO: change the default to STRIP_ENUM_PREFIX_STRIP for edition 2025. + edition_defaults = { + edition: EDITION_LEGACY, + value: "STRIP_ENUM_PREFIX_KEEP" + } + ]; } diff --git a/third_party/google/protobuf/java_features.proto b/third_party/google/protobuf/java_features.proto index 1c6dbdbc..3f8ee1a2 100644 --- a/third_party/google/protobuf/java_features.proto +++ b/third_party/google/protobuf/java_features.proto @@ -1,3 +1,4 @@ + // Protocol Buffers - Google's data interchange format // Copyright 2023 Google Inc. All rights reserved. // @@ -66,4 +67,21 @@ message JavaFeatures { }, edition_defaults = { edition: EDITION_LEGACY, value: "DEFAULT" } ]; + + // Whether to use the old default outer class name scheme, or the new feature + // which adds a "Proto" suffix to the outer class name. + // + // Users will not be able to set this option, because we removed it in the + // same edition that it was introduced. But we use it to determine which + // naming scheme to use for outer class name defaults. + optional bool use_old_outer_classname_default = 4 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2024, + edition_removed: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "true" }, + edition_defaults = { edition: EDITION_2024, value: "false" } + ]; } diff --git a/third_party/google/protobuf/wrappers.proto b/third_party/google/protobuf/wrappers.proto index 1959fa55..e583e7c4 100644 --- a/third_party/google/protobuf/wrappers.proto +++ b/third_party/google/protobuf/wrappers.proto @@ -28,10 +28,17 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -// Wrappers for primitive (non-message) types. These types are useful -// for embedding primitives in the `google.protobuf.Any` type and for places -// where we need to distinguish between the absence of a primitive -// typed field and its default value. +// Wrappers for primitive (non-message) types. These types were needed +// for legacy reasons and are not recommended for use in new APIs. +// +// Historically these wrappers were useful to have presence on proto3 primitive +// fields, but proto3 syntax has been updated to support the `optional` keyword. +// Using that keyword is now the strongly preferred way to add presence to +// proto3 primitive fields. +// +// A secondary usecase was to embed primitives in the `google.protobuf.Any` +// type: it is now recommended that you embed your value in your own wrapper +// message which can be specifically documented. // // These wrappers have no meaningful use within repeated fields as they lack // the ability to detect presence on individual elements. @@ -53,6 +60,9 @@ option csharp_namespace = "Google.Protobuf.WellKnownTypes"; // Wrapper message for `double`. // // The JSON representation for `DoubleValue` is JSON number. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. message DoubleValue { // The double value. double value = 1; @@ -61,6 +71,9 @@ message DoubleValue { // Wrapper message for `float`. // // The JSON representation for `FloatValue` is JSON number. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. message FloatValue { // The float value. float value = 1; @@ -69,6 +82,9 @@ message FloatValue { // Wrapper message for `int64`. // // The JSON representation for `Int64Value` is JSON string. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. message Int64Value { // The int64 value. int64 value = 1; @@ -77,6 +93,9 @@ message Int64Value { // Wrapper message for `uint64`. // // The JSON representation for `UInt64Value` is JSON string. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. message UInt64Value { // The uint64 value. uint64 value = 1; @@ -85,6 +104,9 @@ message UInt64Value { // Wrapper message for `int32`. // // The JSON representation for `Int32Value` is JSON number. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. message Int32Value { // The int32 value. int32 value = 1; @@ -93,6 +115,9 @@ message Int32Value { // Wrapper message for `uint32`. // // The JSON representation for `UInt32Value` is JSON number. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. message UInt32Value { // The uint32 value. uint32 value = 1; @@ -101,6 +126,9 @@ message UInt32Value { // Wrapper message for `bool`. // // The JSON representation for `BoolValue` is JSON `true` and `false`. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. message BoolValue { // The bool value. bool value = 1; @@ -109,6 +137,9 @@ message BoolValue { // Wrapper message for `string`. // // The JSON representation for `StringValue` is JSON string. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. message StringValue { // The string value. string value = 1; @@ -117,6 +148,9 @@ message StringValue { // Wrapper message for `bytes`. // // The JSON representation for `BytesValue` is JSON string. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. message BytesValue { // The bytes value. bytes value = 1; diff --git a/third_party/google/rpc/code.proto b/third_party/google/rpc/code.proto index ba8f2bf9..aa6ce153 100644 --- a/third_party/google/rpc/code.proto +++ b/third_party/google/rpc/code.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/rpc/context/attribute_context.proto b/third_party/google/rpc/context/attribute_context.proto index 353b28ab..57276600 100644 --- a/third_party/google/rpc/context/attribute_context.proto +++ b/third_party/google/rpc/context/attribute_context.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/rpc/error_details.proto b/third_party/google/rpc/error_details.proto index 776a9d35..4f9ecff0 100644 --- a/third_party/google/rpc/error_details.proto +++ b/third_party/google/rpc/error_details.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -131,6 +131,71 @@ message QuotaFailure { // For example: "Service disabled" or "Daily Limit for read operations // exceeded". string description = 2; + + // The API Service from which the `QuotaFailure.Violation` orginates. In + // some cases, Quota issues originate from an API Service other than the one + // that was called. In other words, a dependency of the called API Service + // could be the cause of the `QuotaFailure`, and this field would have the + // dependency API service name. + // + // For example, if the called API is Kubernetes Engine API + // (container.googleapis.com), and a quota violation occurs in the + // Kubernetes Engine API itself, this field would be + // "container.googleapis.com". On the other hand, if the quota violation + // occurs when the Kubernetes Engine API creates VMs in the Compute Engine + // API (compute.googleapis.com), this field would be + // "compute.googleapis.com". + string api_service = 3; + + // The metric of the violated quota. A quota metric is a named counter to + // measure usage, such as API requests or CPUs. When an activity occurs in a + // service, such as Virtual Machine allocation, one or more quota metrics + // may be affected. + // + // For example, "compute.googleapis.com/cpus_per_vm_family", + // "storage.googleapis.com/internet_egress_bandwidth". + string quota_metric = 4; + + // The id of the violated quota. Also know as "limit name", this is the + // unique identifier of a quota in the context of an API service. + // + // For example, "CPUS-PER-VM-FAMILY-per-project-region". + string quota_id = 5; + + // The dimensions of the violated quota. Every non-global quota is enforced + // on a set of dimensions. While quota metric defines what to count, the + // dimensions specify for what aspects the counter should be increased. + // + // For example, the quota "CPUs per region per VM family" enforces a limit + // on the metric "compute.googleapis.com/cpus_per_vm_family" on dimensions + // "region" and "vm_family". And if the violation occurred in region + // "us-central1" and for VM family "n1", the quota_dimensions would be, + // + // { + // "region": "us-central1", + // "vm_family": "n1", + // } + // + // When a quota is enforced globally, the quota_dimensions would always be + // empty. + map quota_dimensions = 6; + + // The enforced quota value at the time of the `QuotaFailure`. + // + // For example, if the enforced quota value at the time of the + // `QuotaFailure` on the number of CPUs is "10", then the value of this + // field would reflect this quantity. + int64 quota_value = 7; + + // The new quota value being rolled out at the time of the violation. At the + // completion of the rollout, this value will be enforced in place of + // quota_value. If no rollout is in progress at the time of the violation, + // this field is not set. + // + // For example, if at the time of the violation a rollout is in progress + // changing the number of CPUs quota from 10 to 20, 20 would be the value of + // this field. + optional int64 future_quota_value = 8; } // Describes all quota violations. diff --git a/third_party/google/rpc/status.proto b/third_party/google/rpc/status.proto index 90b70ddf..dc14c943 100644 --- a/third_party/google/rpc/status.proto +++ b/third_party/google/rpc/status.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/calendar_period.proto b/third_party/google/type/calendar_period.proto index 25a8f644..57d360ad 100644 --- a/third_party/google/type/calendar_period.proto +++ b/third_party/google/type/calendar_period.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/color.proto b/third_party/google/type/color.proto index 3e57c1fb..26508db9 100644 --- a/third_party/google/type/color.proto +++ b/third_party/google/type/color.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/date.proto b/third_party/google/type/date.proto index 6370cd86..6f63436e 100644 --- a/third_party/google/type/date.proto +++ b/third_party/google/type/date.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/datetime.proto b/third_party/google/type/datetime.proto index a363a41e..9f0d62b0 100644 --- a/third_party/google/type/datetime.proto +++ b/third_party/google/type/datetime.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/dayofweek.proto b/third_party/google/type/dayofweek.proto index e16c1946..5684bec3 100644 --- a/third_party/google/type/dayofweek.proto +++ b/third_party/google/type/dayofweek.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/decimal.proto b/third_party/google/type/decimal.proto index 293d0827..77a06db0 100644 --- a/third_party/google/type/decimal.proto +++ b/third_party/google/type/decimal.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/expr.proto b/third_party/google/type/expr.proto index 544e6687..97c4f7da 100644 --- a/third_party/google/type/expr.proto +++ b/third_party/google/type/expr.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/fraction.proto b/third_party/google/type/fraction.proto index 06f07232..b3b0d0f3 100644 --- a/third_party/google/type/fraction.proto +++ b/third_party/google/type/fraction.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/interval.proto b/third_party/google/type/interval.proto index fcf94c86..d9b24271 100644 --- a/third_party/google/type/interval.proto +++ b/third_party/google/type/interval.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/latlng.proto b/third_party/google/type/latlng.proto index daeba48b..6714f65b 100644 --- a/third_party/google/type/latlng.proto +++ b/third_party/google/type/latlng.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/localized_text.proto b/third_party/google/type/localized_text.proto index 82d083c4..3971e811 100644 --- a/third_party/google/type/localized_text.proto +++ b/third_party/google/type/localized_text.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/money.proto b/third_party/google/type/money.proto index c6109433..f67aa51f 100644 --- a/third_party/google/type/money.proto +++ b/third_party/google/type/money.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/month.proto b/third_party/google/type/month.proto index 19982cb5..169282ae 100644 --- a/third_party/google/type/month.proto +++ b/third_party/google/type/month.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/phone_number.proto b/third_party/google/type/phone_number.proto index 370d1623..23dbc6bd 100644 --- a/third_party/google/type/phone_number.proto +++ b/third_party/google/type/phone_number.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/postal_address.proto b/third_party/google/type/postal_address.proto index 7023a9b3..e58d5c35 100644 --- a/third_party/google/type/postal_address.proto +++ b/third_party/google/type/postal_address.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/quaternion.proto b/third_party/google/type/quaternion.proto index 416de30c..18c7b742 100644 --- a/third_party/google/type/quaternion.proto +++ b/third_party/google/type/quaternion.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/google/type/timeofday.proto b/third_party/google/type/timeofday.proto index 3735745a..cd6a8057 100644 --- a/third_party/google/type/timeofday.proto +++ b/third_party/google/type/timeofday.proto @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2025 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/third_party/pagination/v1/pagination.proto b/third_party/pagination/v1/pagination.proto index 6b1f65a4..3a21db01 100644 --- a/third_party/pagination/v1/pagination.proto +++ b/third_party/pagination/v1/pagination.proto @@ -24,19 +24,19 @@ message PageRequest { default: {number: 1} } ]; - // The page_token is the query parameter for set the page token. - string page_token = 2 [ - json_name = "page_token", - (gnostic.openapi.v3.property) = {description: "paging token"} - ]; // The number of lines per page - optional int32 page_size = 3 [ + optional int32 page_size = 2 [ json_name = "page_size", (gnostic.openapi.v3.property) = { description: "The number of lines per page" default: {number: 15} } ]; + // The page_token is the query parameter for set the page token. + string page_token = 3 [ + json_name = "page_token", + (gnostic.openapi.v3.property) = {description: "paging token"} + ]; // The only_count is the query parameter for set only to query the total number bool only_count = 4 [ json_name = "only_count", @@ -73,7 +73,7 @@ message PageResponse { (gnostic.openapi.v3.property) = {description: "total number"} ]; // The paging data - google.protobuf.Any data = 2 [ + repeated google.protobuf.Any data = 2 [ json_name = "data", (gnostic.openapi.v3.property) = {description: "data"} ]; @@ -95,7 +95,7 @@ message PageResponse { ]; // Additional information about this response. // content to be added without destroying the current data format - google.protobuf.Any extra = 6 [ + map extra = 6 [ json_name = "extra", (gnostic.openapi.v3.property) = {description: "additional information about this response"} ]; From 464e67b4df751ab2488471410afc4e76c9f3a59e Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 23 Apr 2025 16:14:44 +0800 Subject: [PATCH 017/158] refactor(bootstrap): update middleware configuration and naming - Remove unused agent context functions - Update middleware configuration in bootstrap - Rename and restructure captcha configuration - Update health check configuration - Refactor middleware usage in casbin and system servers - Update logger middleware in agent HTTP server --- internal/mods/system/server/agent.go | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 internal/mods/system/server/agent.go diff --git a/internal/mods/system/server/agent.go b/internal/mods/system/server/agent.go deleted file mode 100644 index 55a5c382..00000000 --- a/internal/mods/system/server/agent.go +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package server implements the functions, types, and interfaces for the module. -package server - -import ( - "github.com/go-kratos/kratos/v2/metadata" - "github.com/origadmin/runtime/context" -) - -type agentCtx struct{} - -func NewAgentContext(ctx context.Context, metadata metadata.Metadata) context.Context { - return context.WithValue(ctx, agentCtx{}, metadata) -} - -func FromAgentContext(ctx context.Context) (metadata.Metadata, bool) { - if v, ok := ctx.Value(agentCtx{}).(metadata.Metadata); ok { - return v, true - } - return nil, false -} From 9e6a814bfd1de074ec4e93284dc29525e07767a2 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 24 Apr 2025 15:50:26 +0800 Subject: [PATCH 018/158] feat(config): refactor bootstrap configuration and introduce new service config - Refactor bootstrap.proto to include new service configuration - Remove data.proto import from bootstrap.proto - Update system server initialization to use new service config - Introduce new service.proto file for service-specific configurations --- internal/configs/bootstrap.proto | 29 +-- internal/configs/services/service.proto | 23 ++ internal/mods/system/dal/dal.go | 12 +- internal/mods/system/server/server.go | 2 +- third_party/config/v1/data.proto | 296 ------------------------ 5 files changed, 49 insertions(+), 313 deletions(-) create mode 100644 internal/configs/services/service.proto delete mode 100644 third_party/config/v1/data.proto diff --git a/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto index ebc7dd79..4a883b08 100644 --- a/internal/configs/bootstrap.proto +++ b/internal/configs/bootstrap.proto @@ -2,10 +2,10 @@ syntax = "proto3"; package configs.api; -import "config/v1/data.proto"; import "config/v1/registry.proto"; import "config/v1/security.proto"; import "config/v1/service.proto"; +import "config/v1/storage.proto"; import "middleware/v1/middleware.proto"; import "security/v1/auth.proto"; import "validate/validate.proto"; // Updated import statement @@ -25,7 +25,7 @@ message ServiceConfig { ]; Entry entry = 2 [json_name = "entry"]; // 各服务独立入口配置 config.v1.Service service = 3 [json_name = "service"]; // 服务专用配置 -// string registry_path = 4 [json_name = "registry_path"]; // 服务发现注册路径 + // string registry_path = 4 [json_name = "registry_path"]; // 服务发现注册路径 } message Bootstrap { @@ -43,22 +43,13 @@ message Bootstrap { } ]; - string environment = 6 [ - json_name = "environment", - (validate.rules).string = { - in: [ - "development", - "production" - ] - } - ]; bool enable_dynamic_config = 7 [json_name = "enable_dynamic_config"]; message HealthCheck { int32 timeout = 1 [json_name = "timeout"]; string path = 2 [json_name = "path"]; } - HealthCheck health_check = 1002; + // Entry message Entry { string scheme = 1 [json_name = "scheme"]; @@ -67,16 +58,26 @@ message Bootstrap { // config.v1.Service.GINS gins = 30 [json_name = "gins"]; } - string id = 101; + string id = 100 [json_name = "id"]; + string environment = 2 [ + json_name = "environment", + (validate.rules).string = { in: ["dev", "prod"] } + ]; + // 入口服务专属配置 Entry entry = 100 [json_name = "entry"]; - config.v1.Service service = 200 [json_name = "service"]; + config.v1.Service http_gateway = 101 [json_name = "http_gateway"]; + + // 动态加载服务配置 + repeated ServiceConfig services = 200 [json_name = "services"]; + config.v1.Data data = 300 [json_name = "data"]; config.v1.Registry registry = 400 [json_name = "registry"]; middleware.v1.Middleware middleware = 9 [json_name = "middleware"]; security.v1.AuthN authn = 1000 [json_name = "authn"]; security.v1.AuthZ authz = 1001 [json_name = "authz"]; config.v1.Security security = 1002 [json_name = "security"]; + HealthCheck health_check = 1003 [json_name = "health_check"]; } //message Server { diff --git a/internal/configs/services/service.proto b/internal/configs/services/service.proto new file mode 100644 index 00000000..ba8e6da7 --- /dev/null +++ b/internal/configs/services/service.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +package origadmin.configs.api; + +import "config/v1/registry.proto"; +import "config/v1/service.proto"; +import "config/v1/storage.proto"; +import "middleware/v1/middleware.proto"; + +option go_package = "origadmin/application/admin/internal/configs"; + +message ServiceCore { + string name = 1 [json_name = "name"]; + string version = 2 [json_name = "version"]; + + config.v1.Registry registry = 3 [json_name = "registry"]; + repeated config.v1.Storage storages = 4 [json_name = "storages"]; +} + +message Service { + ServiceCore core = 1 [json_name = "core"]; + config.v1.Service service = 200 [json_name = "service"]; + middleware.v1.RateLimit rate_limit = 4 [json_name = "rate_limit"]; +} \ No newline at end of file diff --git a/internal/mods/system/dal/dal.go b/internal/mods/system/dal/dal.go index dfd7fd31..f7c24f78 100644 --- a/internal/mods/system/dal/dal.go +++ b/internal/mods/system/dal/dal.go @@ -14,6 +14,7 @@ import ( "strings" "time" + "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/schema" "github.com/google/wire" @@ -83,6 +84,13 @@ func FixSource(source string) string { return source } +func debugDatabase(driver dialect.Driver, debug bool) dialect.Driver { + if debug { + return entslog.New(driver) + } + return driver +} + // NewData . func NewData(bootstrap *configs.Bootstrap, logger log.KLogger) (*Data, func(), error) { if bootstrap == nil { @@ -102,8 +110,8 @@ func NewData(bootstrap *configs.Bootstrap, logger log.KLogger) (*Data, func(), e } // Run the auto migration tool. - debugDrv := entslog.New(sql.OpenDB(cfg.Dialect, drv)) - db := ent.NewDatabase(ent.Driver(debugDrv)) + sqldb := debugDatabase(sql.OpenDB(cfg.Dialect, drv), cfg.Debug) + db := ent.NewDatabase(ent.Driver(sqldb)) if true || cfg.GetMigration().GetEnabled() { if err := db.Migration( context.Background(), diff --git a/internal/mods/system/server/server.go b/internal/mods/system/server/server.go index ccbf6ba9..c35da767 100644 --- a/internal/mods/system/server/server.go +++ b/internal/mods/system/server/server.go @@ -46,7 +46,6 @@ func init() { func NewSystemServer(bootstrap *configs.Bootstrap, registers []service.ServerRegister, l log.KLogger) []transport.Server { var servers []transport.Server - middlewares := middleware.NewServer(bootstrap.GetService().GetMiddleware()) serviceConfig := bootstrap.GetService() if serviceConfig == nil { return servers @@ -55,6 +54,7 @@ func NewSystemServer(bootstrap *configs.Bootstrap, registers []service.ServerReg serviceConfig.Name = ServiceName } ctx := context.Background() + middlewares := middleware.NewServer(bootstrap.GetService().GetMiddleware()) if serv := NewGRPCServer(bootstrap, l, service.WithGRPC( servicegrpc.WithMiddlewares(middlewares...), servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), diff --git a/third_party/config/v1/data.proto b/third_party/config/v1/data.proto deleted file mode 100644 index 9986fffb..00000000 --- a/third_party/config/v1/data.proto +++ /dev/null @@ -1,296 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -import "gnostic/openapi/v3/annotations.proto"; -import "google/protobuf/duration.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "DataProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// Data -message Data { - // Database - message Database { - // Debugging - bool debug = 1 [ - json_name = "debug", - (gnostic.openapi.v3.property) = {description: "whether to enable debug mode "} - ]; - // Driver name: mysql, postgresql, mongodb, sqlite...... - string driver = 2 [ - json_name = "driver", - (validate.rules).string = { - in: [ - "mssql", - "mysql", - "postgresql", - "mongodb", - "sqlite", - "oracle", - "sqlserver", - "sqlite3" - ] - }, - (gnostic.openapi.v3.property) = {description: "database driver name"} - ]; - // Data source (DSN string) - string source = 3 [ - json_name = "source", - (gnostic.openapi.v3.property) = {description: "data source dsn string"} - ]; - // Data migration switch - bool migrate = 10 [ - json_name = "migrate", - (gnostic.openapi.v3.property) = {description: "data migration switch"} - ]; - // Link tracking switch - bool enable_trace = 12 [ - json_name = "enable_trace", - (gnostic.openapi.v3.property) = {description: "link tracking switch"} - ]; - // Performance analysis switch - bool enable_metrics = 13 [ - json_name = "enable_metrics", - (gnostic.openapi.v3.property) = {description: "performance analysis switch"} - ]; - // Maximum number of free connections in the connection pool - int32 max_idle_connections = 20 [ - json_name = "max_idle_connections", - (gnostic.openapi.v3.property) = {description: "The maximum number of free connections in the connection pool"} - ]; - // Maximum number of open connections in the connection pool - int32 max_open_connections = 21 [ - json_name = "max_open_connections", - (gnostic.openapi.v3.property) = {description: "The maximum number of open connections in the connection pool"} - ]; - // Maximum length of time that the connection can be reused - int64 connection_max_lifetime = 22 [ - json_name = "connection_max_lifetime", - (gnostic.openapi.v3.property) = {description: "The maximum length of time a connection can be reused"} - ]; - // Maximum number of connections in the connection pool for reading - int64 connection_max_idle_time = 23 [ - json_name = "connection_max_idle_time", - (gnostic.openapi.v3.property) = {description: "The maximum number of connections in the connection pool for reading"} - ]; - } - - // Redis - message Redis { - string network = 1 [ - json_name = "network", - (gnostic.openapi.v3.property) = {description: "network type"} - ]; - string addr = 2 [ - json_name = "addr", - (gnostic.openapi.v3.property) = {description: "address"} - ]; - string password = 3 [ - json_name = "password", - (gnostic.openapi.v3.property) = {description: "cipher"} - ]; - int32 db = 4 [ - json_name = "db", - (gnostic.openapi.v3.property) = {description: "database index"} - ]; - int64 dial_timeout = 5 [ - json_name = "dial_timeout", - (gnostic.openapi.v3.property) = {description: "dial timeout"} - ]; - int64 read_timeout = 6 [ - json_name = "read_timeout", - (gnostic.openapi.v3.property) = {description: "read timeout"} - ]; - int64 write_timeout = 7 [ - json_name = "write_timeout", - (gnostic.openapi.v3.property) = {description: "write timeout"} - ]; - } - - // Memcached - message Memcached { - string addr = 1 [ - json_name = "addr", - (gnostic.openapi.v3.property) = {description: "address"} - ]; - string username = 2 [ - json_name = "username", - (gnostic.openapi.v3.property) = {description: "username"} - ]; - string password = 3 [ - json_name = "password", - (gnostic.openapi.v3.property) = {description: "cipher"} - ]; - int32 max_idle = 4 [ - json_name = "max_idle", - (gnostic.openapi.v3.property) = {description: "maximum number of idle connections"} - ]; - int64 timeout = 5 [ - json_name = "timeout", - (gnostic.openapi.v3.property) = {description: "overtime"} - ]; - } - - // Memory - message Memory { - int32 size = 1 [ - json_name = "size", - (gnostic.openapi.v3.property) = {description: "size"} - ]; - int32 capacity = 2 [ - json_name = "capacity", - (gnostic.openapi.v3.property) = {description: "capacity"} - ]; - int64 expiration = 3 [ - json_name = "expiration", - (gnostic.openapi.v3.property) = {description: "expiration time"} - ]; - int64 cleanup_interval = 4 [ - json_name = "cleanup_interval", - (gnostic.openapi.v3.property) = {description: "clearance interval"} - ]; - } - - message BadgerDS { - string path = 1 [ - json_name = "path", - (gnostic.openapi.v3.property) = {description: "path"} - ]; - bool sync_writes = 2 [ - json_name = "sync_writes", - (gnostic.openapi.v3.property) = {description: "synchronous write or not"} - ]; - int32 value_log_file_size = 3 [ - json_name = "value_log_file_size", - (gnostic.openapi.v3.property) = {description: "value log file size"} - ]; - uint32 log_level = 4 [ - json_name = "log_level", - (validate.rules).uint32 = { - gte: 0 - lte: 3 - }, - (gnostic.openapi.v3.property) = {description: "log level"} - ]; - } - - // File - message File { - string root = 1 [ - json_name = "root", - (gnostic.openapi.v3.property) = {description: "root directory"} - ]; - } - - // OSS - message Oss {} - - // Mongo - message Mongo {} - - // Storage - message Storage { - // Type - string type = 1 [ - json_name = "type", - (validate.rules).string = { - in: [ - "none", - "file", - "redis", - "mongo", - "oss" - ] - }, - (gnostic.openapi.v3.property) = {description: "storage type"} - ]; - // File - File file = 10 [ - json_name = "file", - (gnostic.openapi.v3.property) = {description: "file storage configuration"} - ]; - // Redis - Redis redis = 11 [ - json_name = "redis", - (gnostic.openapi.v3.property) = {description: "redis storage configuration"} - ]; - // Badger - BadgerDS badger = 12 [ - json_name = "badger", - (gnostic.openapi.v3.property) = {description: "badger storage configuration"} - ]; - // Mongo - Mongo mongo = 13 [ - json_name = "mongo", - (gnostic.openapi.v3.property) = {description: "mongo storage configuration"} - ]; - // OSS - Oss oss = 14 [ - json_name = "oss", - (gnostic.openapi.v3.property) = {description: "oss storage configuration"} - ]; - } - - // Cache - message Cache { - // Driver name: redis, memcached, etc. - string driver = 1 [ - json_name = "driver", - (validate.rules).string = { - in: [ - "none", - "redis", - "memcached", - "memory" - ] - }, - (gnostic.openapi.v3.property) = {description: "cache driver name"} - ]; - string name = 2 [ - json_name = "name", - (gnostic.openapi.v3.property) = {description: "cache name"} - ]; - // Memcached - Memcached memcached = 10 [ - json_name = "memcached", - (gnostic.openapi.v3.property) = {description: "memcached cache configuration"} - ]; - // Memory cache - Memory memory = 11 [ - json_name = "memory", - (gnostic.openapi.v3.property) = {description: "memory cache configuration"} - ]; - // Redis - Redis redis = 12 [ - json_name = "redis", - (gnostic.openapi.v3.property) = {description: "redis cache configuration"} - ]; - // Badger - BadgerDS badger = 13 [ - json_name = "badger", - (gnostic.openapi.v3.property) = {description: "badger storage configuration"} - ]; - } - - // Database - Database database = 1 [ - json_name = "database", - (gnostic.openapi.v3.property) = {description: "database configuration"} - ]; - // Cache - Cache cache = 2 [ - json_name = "cache", - (gnostic.openapi.v3.property) = {description: "cache configuration"} - ]; - // Storage - Storage storage = 3 [ - json_name = "storage", - (gnostic.openapi.v3.property) = {description: "storage configuration"} - ]; -} From 3bc2f93e830889c41ed3e96e238f7c8fb794a82d Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 24 Apr 2025 16:43:09 +0800 Subject: [PATCH 019/158] feat(configs): integrate security configuration into basis_config - Add Security field to BasisConfig message - Remove RootUser field from BasisConfig message - Update basis_config.pb.go and basis_config.pb.validate.go to reflect these changes - Add import for config.v1.Security proto --- internal/configs/basis_config.pb.go | 53 +-- internal/configs/basis_config.pb.validate.go | 20 +- internal/configs/basis_config.proto | 5 +- internal/configs/bootstrap.pb.go | 423 ++++++++++++------- internal/configs/bootstrap.pb.validate.go | 326 +++++++++++++- internal/configs/bootstrap.proto | 20 +- internal/configs/captcha.pb.go | 150 ++----- internal/configs/captcha.pb.validate.go | 136 +----- internal/configs/captcha.proto | 4 +- internal/configs/server.pb.go | 82 ++-- internal/configs/server.pb.validate.go | 12 +- internal/configs/server.proto | 4 +- 12 files changed, 720 insertions(+), 515 deletions(-) diff --git a/internal/configs/basis_config.pb.go b/internal/configs/basis_config.pb.go index 8da8e453..06bfffea 100644 --- a/internal/configs/basis_config.pb.go +++ b/internal/configs/basis_config.pb.go @@ -7,6 +7,7 @@ package configs import ( + v1 "github.com/origadmin/runtime/gen/go/config/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -25,8 +26,9 @@ type BasisConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - RootUser *RootUser `protobuf:"bytes,1,opt,name=root_user,proto3" json:"root_user,omitempty"` - Captcha *Captcha `protobuf:"bytes,2,opt,name=captcha,proto3" json:"captcha,omitempty"` + // configs.api.RootUser root_user = 1 [json_name = "root_user"]; + Captcha *Captcha `protobuf:"bytes,2,opt,name=captcha,proto3" json:"captcha,omitempty"` + Security *v1.Security `protobuf:"bytes,3,opt,name=security,proto3" json:"security,omitempty"` } func (x *BasisConfig) Reset() { @@ -59,16 +61,16 @@ func (*BasisConfig) Descriptor() ([]byte, []int) { return file_configs_basis_config_proto_rawDescGZIP(), []int{0} } -func (x *BasisConfig) GetRootUser() *RootUser { +func (x *BasisConfig) GetCaptcha() *Captcha { if x != nil { - return x.RootUser + return x.Captcha } return nil } -func (x *BasisConfig) GetCaptcha() *Captcha { +func (x *BasisConfig) GetSecurity() *v1.Security { if x != nil { - return x.Captcha + return x.Security } return nil } @@ -78,21 +80,21 @@ var File_configs_basis_config_proto protoreflect.FileDescriptor var file_configs_basis_config_proto_rawDesc = []byte{ 0x0a, 0x1a, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x69, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x73, 0x2f, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x15, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x63, 0x61, 0x70, 0x74, - 0x63, 0x68, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x72, 0x0a, 0x0b, 0x42, 0x61, 0x73, - 0x69, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x33, 0x0a, 0x09, 0x72, 0x6f, 0x6f, 0x74, - 0x5f, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x52, 0x6f, 0x6f, 0x74, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x09, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x12, 0x2e, 0x0a, - 0x07, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, - 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x70, - 0x74, 0x63, 0x68, 0x61, 0x52, 0x07, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x42, 0x2e, 0x5a, - 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x63, 0x61, 0x70, + 0x74, 0x63, 0x68, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6e, 0x0a, 0x0b, 0x42, 0x61, + 0x73, 0x69, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x61, 0x70, + 0x74, 0x63, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, + 0x52, 0x07, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x12, 0x2f, 0x0a, 0x08, 0x73, 0x65, 0x63, + 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, + 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -110,12 +112,12 @@ func file_configs_basis_config_proto_rawDescGZIP() []byte { var file_configs_basis_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_basis_config_proto_goTypes = []any{ (*BasisConfig)(nil), // 0: configs.api.BasisConfig - (*RootUser)(nil), // 1: configs.api.RootUser - (*Captcha)(nil), // 2: configs.api.Captcha + (*Captcha)(nil), // 1: configs.api.Captcha + (*v1.Security)(nil), // 2: config.v1.Security } var file_configs_basis_config_proto_depIdxs = []int32{ - 1, // 0: configs.api.BasisConfig.root_user:type_name -> configs.api.RootUser - 2, // 1: configs.api.BasisConfig.captcha:type_name -> configs.api.Captcha + 1, // 0: configs.api.BasisConfig.captcha:type_name -> configs.api.Captcha + 2, // 1: configs.api.BasisConfig.security:type_name -> config.v1.Security 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name @@ -128,7 +130,6 @@ func file_configs_basis_config_proto_init() { if File_configs_basis_config_proto != nil { return } - file_configs_root_user_proto_init() file_configs_captcha_proto_init() type x struct{} out := protoimpl.TypeBuilder{ diff --git a/internal/configs/basis_config.pb.validate.go b/internal/configs/basis_config.pb.validate.go index 9d5480b6..2537a591 100644 --- a/internal/configs/basis_config.pb.validate.go +++ b/internal/configs/basis_config.pb.validate.go @@ -58,11 +58,11 @@ func (m *BasisConfig) validate(all bool) error { var errors []error if all { - switch v := interface{}(m.GetRootUser()).(type) { + switch v := interface{}(m.GetCaptcha()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BasisConfigValidationError{ - field: "RootUser", + field: "Captcha", reason: "embedded message failed validation", cause: err, }) @@ -70,16 +70,16 @@ func (m *BasisConfig) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BasisConfigValidationError{ - field: "RootUser", + field: "Captcha", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetRootUser()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetCaptcha()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BasisConfigValidationError{ - field: "RootUser", + field: "Captcha", reason: "embedded message failed validation", cause: err, } @@ -87,11 +87,11 @@ func (m *BasisConfig) validate(all bool) error { } if all { - switch v := interface{}(m.GetCaptcha()).(type) { + switch v := interface{}(m.GetSecurity()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BasisConfigValidationError{ - field: "Captcha", + field: "Security", reason: "embedded message failed validation", cause: err, }) @@ -99,16 +99,16 @@ func (m *BasisConfig) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BasisConfigValidationError{ - field: "Captcha", + field: "Security", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetCaptcha()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetSecurity()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BasisConfigValidationError{ - field: "Captcha", + field: "Security", reason: "embedded message failed validation", cause: err, } diff --git a/internal/configs/basis_config.proto b/internal/configs/basis_config.proto index d45d86ea..4611f3d1 100644 --- a/internal/configs/basis_config.proto +++ b/internal/configs/basis_config.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package configs.api; +import "config/v1/security.proto"; // 移除对root_user的引用(迁移至安全配置模块) // import "configs/root_user.proto"; import "configs/captcha.proto"; @@ -10,6 +11,6 @@ option go_package = "origadmin/application/admin/internal/configs"; message BasisConfig { // configs.api.RootUser root_user = 1 [json_name = "root_user"]; configs.api.Captcha captcha = 2 [json_name = "captcha"]; - + config.v1.Security security = 3 [json_name = "security"]; -} \ No newline at end of file +} diff --git a/internal/configs/bootstrap.pb.go b/internal/configs/bootstrap.pb.go index d7d65477..05721df5 100644 --- a/internal/configs/bootstrap.pb.go +++ b/internal/configs/bootstrap.pb.go @@ -85,31 +85,81 @@ func (x *EntrySelectorConfig) GetVersion() string { return "" } +type ServiceConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *ServiceConfig) Reset() { + *x = ServiceConfig{} + mi := &file_configs_bootstrap_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServiceConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServiceConfig) ProtoMessage() {} + +func (x *ServiceConfig) ProtoReflect() protoreflect.Message { + mi := &file_configs_bootstrap_proto_msgTypes[1] + 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 ServiceConfig.ProtoReflect.Descriptor instead. +func (*ServiceConfig) Descriptor() ([]byte, []int) { + return file_configs_bootstrap_proto_rawDescGZIP(), []int{1} +} + +func (x *ServiceConfig) GetName() string { + if x != nil { + return x.Name + } + return "" +} + type Bootstrap struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // name is the application name or service name for used - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Mode string `protobuf:"bytes,5,opt,name=mode,proto3" json:"mode,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - CryptoType string `protobuf:"bytes,3,opt,name=crypto_type,proto3" json:"crypto_type,omitempty"` - Servers map[string]string `protobuf:"bytes,4,rep,name=servers,proto3" json:"servers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Id string `protobuf:"bytes,101,opt,name=id,proto3" json:"id,omitempty"` - Entry *Bootstrap_Entry `protobuf:"bytes,100,opt,name=entry,proto3" json:"entry,omitempty"` - Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` - Data *v1.Data `protobuf:"bytes,300,opt,name=data,proto3" json:"data,omitempty"` - Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` - Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` - Authn *v12.AuthN `protobuf:"bytes,1000,opt,name=authn,proto3" json:"authn,omitempty"` - Authz *v12.AuthZ `protobuf:"bytes,1001,opt,name=authz,proto3" json:"authz,omitempty"` - Security *v1.Security `protobuf:"bytes,1002,opt,name=security,proto3" json:"security,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` + CryptoType string `protobuf:"bytes,3,opt,name=crypto_type,proto3" json:"crypto_type,omitempty"` + Mode string `protobuf:"bytes,5,opt,name=mode,proto3" json:"mode,omitempty"` + EnableDynamicConfig bool `protobuf:"varint,7,opt,name=enable_dynamic_config,proto3" json:"enable_dynamic_config,omitempty"` + Id string `protobuf:"bytes,100,opt,name=id,proto3" json:"id,omitempty"` + Environment string `protobuf:"bytes,102,opt,name=environment,proto3" json:"environment,omitempty"` + // 入口服务专属配置 + Entry *Bootstrap_Entry `protobuf:"bytes,103,opt,name=entry,proto3" json:"entry,omitempty"` + HttpGateway *v1.Service `protobuf:"bytes,104,opt,name=http_gateway,proto3" json:"http_gateway,omitempty"` + // 动态加载服务配置 + Services []*ServiceConfig `protobuf:"bytes,200,rep,name=services,proto3" json:"services,omitempty"` + Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` + Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` + Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` + Authn *v12.AuthN `protobuf:"bytes,1000,opt,name=authn,proto3" json:"authn,omitempty"` + Authz *v12.AuthZ `protobuf:"bytes,1001,opt,name=authz,proto3" json:"authz,omitempty"` + Security *v1.Security `protobuf:"bytes,1002,opt,name=security,proto3" json:"security,omitempty"` + HealthCheck *Bootstrap_HealthCheck `protobuf:"bytes,1003,opt,name=health_check,proto3" json:"health_check,omitempty"` } func (x *Bootstrap) Reset() { *x = Bootstrap{} - mi := &file_configs_bootstrap_proto_msgTypes[1] + mi := &file_configs_bootstrap_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -121,7 +171,7 @@ func (x *Bootstrap) String() string { func (*Bootstrap) ProtoMessage() {} func (x *Bootstrap) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[1] + mi := &file_configs_bootstrap_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -134,7 +184,7 @@ func (x *Bootstrap) ProtoReflect() protoreflect.Message { // Deprecated: Use Bootstrap.ProtoReflect.Descriptor instead. func (*Bootstrap) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{1} + return file_configs_bootstrap_proto_rawDescGZIP(), []int{2} } func (x *Bootstrap) GetName() string { @@ -144,32 +194,32 @@ func (x *Bootstrap) GetName() string { return "" } -func (x *Bootstrap) GetMode() string { +func (x *Bootstrap) GetVersion() string { if x != nil { - return x.Mode + return x.Version } return "" } -func (x *Bootstrap) GetVersion() string { +func (x *Bootstrap) GetCryptoType() string { if x != nil { - return x.Version + return x.CryptoType } return "" } -func (x *Bootstrap) GetCryptoType() string { +func (x *Bootstrap) GetMode() string { if x != nil { - return x.CryptoType + return x.Mode } return "" } -func (x *Bootstrap) GetServers() map[string]string { +func (x *Bootstrap) GetEnableDynamicConfig() bool { if x != nil { - return x.Servers + return x.EnableDynamicConfig } - return nil + return false } func (x *Bootstrap) GetId() string { @@ -179,6 +229,13 @@ func (x *Bootstrap) GetId() string { return "" } +func (x *Bootstrap) GetEnvironment() string { + if x != nil { + return x.Environment + } + return "" +} + func (x *Bootstrap) GetEntry() *Bootstrap_Entry { if x != nil { return x.Entry @@ -186,16 +243,23 @@ func (x *Bootstrap) GetEntry() *Bootstrap_Entry { return nil } -func (x *Bootstrap) GetService() *v1.Service { +func (x *Bootstrap) GetHttpGateway() *v1.Service { + if x != nil { + return x.HttpGateway + } + return nil +} + +func (x *Bootstrap) GetServices() []*ServiceConfig { if x != nil { - return x.Service + return x.Services } return nil } -func (x *Bootstrap) GetData() *v1.Data { +func (x *Bootstrap) GetStorage() *v1.Storage { if x != nil { - return x.Data + return x.Storage } return nil } @@ -235,6 +299,13 @@ func (x *Bootstrap) GetSecurity() *v1.Security { return nil } +func (x *Bootstrap) GetHealthCheck() *Bootstrap_HealthCheck { + if x != nil { + return x.HealthCheck + } + return nil +} + type Settings struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -245,7 +316,7 @@ type Settings struct { func (x *Settings) Reset() { *x = Settings{} - mi := &file_configs_bootstrap_proto_msgTypes[2] + mi := &file_configs_bootstrap_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -257,7 +328,7 @@ func (x *Settings) String() string { func (*Settings) ProtoMessage() {} func (x *Settings) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[2] + mi := &file_configs_bootstrap_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -270,7 +341,7 @@ func (x *Settings) ProtoReflect() protoreflect.Message { // Deprecated: Use Settings.ProtoReflect.Descriptor instead. func (*Settings) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{2} + return file_configs_bootstrap_proto_rawDescGZIP(), []int{3} } func (x *Settings) GetCryptoType() string { @@ -280,6 +351,59 @@ func (x *Settings) GetCryptoType() string { return "" } +type Bootstrap_HealthCheck struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Timeout int32 `protobuf:"varint,1,opt,name=timeout,proto3" json:"timeout,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` +} + +func (x *Bootstrap_HealthCheck) Reset() { + *x = Bootstrap_HealthCheck{} + mi := &file_configs_bootstrap_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Bootstrap_HealthCheck) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Bootstrap_HealthCheck) ProtoMessage() {} + +func (x *Bootstrap_HealthCheck) ProtoReflect() protoreflect.Message { + mi := &file_configs_bootstrap_proto_msgTypes[4] + 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 Bootstrap_HealthCheck.ProtoReflect.Descriptor instead. +func (*Bootstrap_HealthCheck) Descriptor() ([]byte, []int) { + return file_configs_bootstrap_proto_rawDescGZIP(), []int{2, 0} +} + +func (x *Bootstrap_HealthCheck) GetTimeout() int32 { + if x != nil { + return x.Timeout + } + return 0 +} + +func (x *Bootstrap_HealthCheck) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + // Entry type Bootstrap_Entry struct { state protoimpl.MessageState @@ -293,7 +417,7 @@ type Bootstrap_Entry struct { func (x *Bootstrap_Entry) Reset() { *x = Bootstrap_Entry{} - mi := &file_configs_bootstrap_proto_msgTypes[4] + mi := &file_configs_bootstrap_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -305,7 +429,7 @@ func (x *Bootstrap_Entry) String() string { func (*Bootstrap_Entry) ProtoMessage() {} func (x *Bootstrap_Entry) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[4] + mi := &file_configs_bootstrap_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -318,7 +442,7 @@ func (x *Bootstrap_Entry) ProtoReflect() protoreflect.Message { // Deprecated: Use Bootstrap_Entry.ProtoReflect.Descriptor instead. func (*Bootstrap_Entry) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{1, 1} + return file_configs_bootstrap_proto_rawDescGZIP(), []int{2, 1} } func (x *Bootstrap_Entry) GetScheme() string { @@ -347,79 +471,94 @@ var File_configs_bootstrap_proto protoreflect.FileDescriptor var file_configs_bootstrap_proto_rawDesc = []byte{ 0x0a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x14, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, - 0x31, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, - 0x31, 0x2f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, 0x64, 0x64, 0x6c, - 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, - 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x73, 0x65, 0x63, 0x75, 0x72, - 0x69, 0x74, 0x79, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5b, 0x0a, 0x13, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, - 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x8e, 0x06, 0x0a, 0x09, 0x42, 0x6f, 0x6f, 0x74, - 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x6d, 0x6f, 0x64, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, 0xfa, 0x42, 0x16, 0x72, 0x14, 0x52, 0x09, - 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x74, 0x6f, 0x6e, 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, - 0x65, 0x72, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, - 0x74, 0x79, 0x70, 0x65, 0x12, 0x3d, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x18, - 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x65, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x32, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x64, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x24, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0xac, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, - 0x31, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x30, 0x0a, 0x08, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x90, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x39, - 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, - 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, - 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x12, 0x29, 0x0a, 0x05, 0x61, 0x75, 0x74, - 0x68, 0x6e, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, 0x63, 0x75, - 0x72, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4e, 0x52, 0x05, 0x61, - 0x75, 0x74, 0x68, 0x6e, 0x12, 0x29, 0x0a, 0x05, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x18, 0xe9, 0x07, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, - 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x5a, 0x52, 0x05, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x12, - 0x30, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0xea, 0x07, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, - 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, - 0x79, 0x1a, 0x3a, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x79, 0x0a, - 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x2b, - 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x12, 0x2b, 0x0a, 0x04, 0x68, - 0x74, 0x74, 0x70, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x48, 0x54, - 0x54, 0x50, 0x52, 0x04, 0x68, 0x74, 0x74, 0x70, 0x22, 0x2c, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, - 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, - 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, - 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, + 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x63, 0x75, + 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, + 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, + 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x73, 0x65, + 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5b, 0x0a, + 0x13, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x2c, 0x0a, 0x0d, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1b, 0x0a, 0x04, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, + 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xce, 0x07, 0x0a, 0x09, 0x42, 0x6f, 0x6f, + 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, + 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, 0xfa, 0x42, 0x16, 0x72, 0x14, 0x52, 0x09, 0x73, 0x69, 0x6e, + 0x67, 0x6c, 0x65, 0x74, 0x6f, 0x6e, 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, + 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x34, 0x0a, 0x15, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, + 0x64, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x79, 0x6e, + 0x61, 0x6d, 0x69, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x64, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x32, 0x0a, 0x0b, 0x65, + 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x66, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x10, 0xfa, 0x42, 0x0d, 0x72, 0x0b, 0x52, 0x03, 0x64, 0x65, 0x76, 0x52, 0x04, 0x70, 0x72, + 0x6f, 0x64, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x12, + 0x32, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x67, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x6f, 0x6f, + 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x65, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x36, 0x0a, 0x0c, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x67, 0x61, 0x74, 0x65, + 0x77, 0x61, 0x79, 0x18, 0x68, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x0c, 0x68, + 0x74, 0x74, 0x70, 0x5f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x37, 0x0a, 0x08, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0xc8, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, + 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, + 0xac, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, + 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, + 0x90, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x76, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x39, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, + 0x61, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x69, 0x64, 0x64, + 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, + 0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, + 0x12, 0x29, 0x0a, 0x05, 0x61, 0x75, 0x74, 0x68, 0x6e, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x12, 0x2e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x41, + 0x75, 0x74, 0x68, 0x4e, 0x52, 0x05, 0x61, 0x75, 0x74, 0x68, 0x6e, 0x12, 0x29, 0x0a, 0x05, 0x61, + 0x75, 0x74, 0x68, 0x7a, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, + 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x5a, 0x52, + 0x05, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x12, 0x30, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, + 0x74, 0x79, 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, + 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x47, 0x0a, 0x0c, 0x68, 0x65, 0x61, 0x6c, + 0x74, 0x68, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x18, 0xeb, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x22, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x6f, + 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x52, 0x0c, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x5f, 0x63, 0x68, 0x65, 0x63, + 0x6b, 0x1a, 0x3b, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, + 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x1a, 0x79, + 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, + 0x2b, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x12, 0x2b, 0x0a, 0x04, + 0x68, 0x74, 0x74, 0x70, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x48, + 0x54, 0x54, 0x50, 0x52, 0x04, 0x68, 0x74, 0x74, 0x70, 0x22, 0x2c, 0x0a, 0x08, 0x53, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, + 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, + 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -434,40 +573,42 @@ func file_configs_bootstrap_proto_rawDescGZIP() []byte { return file_configs_bootstrap_proto_rawDescData } -var file_configs_bootstrap_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_configs_bootstrap_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_configs_bootstrap_proto_goTypes = []any{ - (*EntrySelectorConfig)(nil), // 0: configs.api.EntrySelectorConfig - (*Bootstrap)(nil), // 1: configs.api.Bootstrap - (*Settings)(nil), // 2: configs.api.Settings - nil, // 3: configs.api.Bootstrap.ServersEntry - (*Bootstrap_Entry)(nil), // 4: configs.api.Bootstrap.Entry - (*v1.Service)(nil), // 5: config.v1.Service - (*v1.Data)(nil), // 6: config.v1.Data - (*v1.Registry)(nil), // 7: config.v1.Registry - (*v11.Middleware)(nil), // 8: middleware.v1.Middleware - (*v12.AuthN)(nil), // 9: security.v1.AuthN - (*v12.AuthZ)(nil), // 10: security.v1.AuthZ - (*v1.Security)(nil), // 11: config.v1.Security - (*v1.Service_GRPC)(nil), // 12: config.v1.Service.GRPC - (*v1.Service_HTTP)(nil), // 13: config.v1.Service.HTTP + (*EntrySelectorConfig)(nil), // 0: configs.api.EntrySelectorConfig + (*ServiceConfig)(nil), // 1: configs.api.ServiceConfig + (*Bootstrap)(nil), // 2: configs.api.Bootstrap + (*Settings)(nil), // 3: configs.api.Settings + (*Bootstrap_HealthCheck)(nil), // 4: configs.api.Bootstrap.HealthCheck + (*Bootstrap_Entry)(nil), // 5: configs.api.Bootstrap.Entry + (*v1.Service)(nil), // 6: config.v1.Service + (*v1.Storage)(nil), // 7: config.v1.Storage + (*v1.Registry)(nil), // 8: config.v1.Registry + (*v11.Middleware)(nil), // 9: middleware.v1.Middleware + (*v12.AuthN)(nil), // 10: security.v1.AuthN + (*v12.AuthZ)(nil), // 11: security.v1.AuthZ + (*v1.Security)(nil), // 12: config.v1.Security + (*v1.Service_GRPC)(nil), // 13: config.v1.Service.GRPC + (*v1.Service_HTTP)(nil), // 14: config.v1.Service.HTTP } var file_configs_bootstrap_proto_depIdxs = []int32{ - 3, // 0: configs.api.Bootstrap.servers:type_name -> configs.api.Bootstrap.ServersEntry - 4, // 1: configs.api.Bootstrap.entry:type_name -> configs.api.Bootstrap.Entry - 5, // 2: configs.api.Bootstrap.service:type_name -> config.v1.Service - 6, // 3: configs.api.Bootstrap.data:type_name -> config.v1.Data - 7, // 4: configs.api.Bootstrap.registry:type_name -> config.v1.Registry - 8, // 5: configs.api.Bootstrap.middleware:type_name -> middleware.v1.Middleware - 9, // 6: configs.api.Bootstrap.authn:type_name -> security.v1.AuthN - 10, // 7: configs.api.Bootstrap.authz:type_name -> security.v1.AuthZ - 11, // 8: configs.api.Bootstrap.security:type_name -> config.v1.Security - 12, // 9: configs.api.Bootstrap.Entry.grpc:type_name -> config.v1.Service.GRPC - 13, // 10: configs.api.Bootstrap.Entry.http:type_name -> config.v1.Service.HTTP - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 5, // 0: configs.api.Bootstrap.entry:type_name -> configs.api.Bootstrap.Entry + 6, // 1: configs.api.Bootstrap.http_gateway:type_name -> config.v1.Service + 1, // 2: configs.api.Bootstrap.services:type_name -> configs.api.ServiceConfig + 7, // 3: configs.api.Bootstrap.storage:type_name -> config.v1.Storage + 8, // 4: configs.api.Bootstrap.registry:type_name -> config.v1.Registry + 9, // 5: configs.api.Bootstrap.middleware:type_name -> middleware.v1.Middleware + 10, // 6: configs.api.Bootstrap.authn:type_name -> security.v1.AuthN + 11, // 7: configs.api.Bootstrap.authz:type_name -> security.v1.AuthZ + 12, // 8: configs.api.Bootstrap.security:type_name -> config.v1.Security + 4, // 9: configs.api.Bootstrap.health_check:type_name -> configs.api.Bootstrap.HealthCheck + 13, // 10: configs.api.Bootstrap.Entry.grpc:type_name -> config.v1.Service.GRPC + 14, // 11: configs.api.Bootstrap.Entry.http:type_name -> config.v1.Service.HTTP + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_configs_bootstrap_proto_init() } @@ -481,7 +622,7 @@ func file_configs_bootstrap_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_configs_bootstrap_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/configs/bootstrap.pb.validate.go b/internal/configs/bootstrap.pb.validate.go index 54c36fb8..70125811 100644 --- a/internal/configs/bootstrap.pb.validate.go +++ b/internal/configs/bootstrap.pb.validate.go @@ -143,6 +143,117 @@ var _ interface { ErrorName() string } = EntrySelectorConfigValidationError{} +// Validate checks the field values on ServiceConfig 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 *ServiceConfig) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ServiceConfig 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 ServiceConfigMultiError, or +// nil if none found. +func (m *ServiceConfig) ValidateAll() error { + return m.validate(true) +} + +func (m *ServiceConfig) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetName()) < 1 { + err := ServiceConfigValidationError{ + field: "Name", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return ServiceConfigMultiError(errors) + } + + return nil +} + +// ServiceConfigMultiError is an error wrapping multiple validation errors +// returned by ServiceConfig.ValidateAll() if the designated constraints +// aren't met. +type ServiceConfigMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ServiceConfigMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ServiceConfigMultiError) AllErrors() []error { return m } + +// ServiceConfigValidationError is the validation error returned by +// ServiceConfig.Validate if the designated constraints aren't met. +type ServiceConfigValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ServiceConfigValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ServiceConfigValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ServiceConfigValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ServiceConfigValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ServiceConfigValidationError) ErrorName() string { return "ServiceConfigValidationError" } + +// Error satisfies the builtin error interface +func (e ServiceConfigValidationError) 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 %sServiceConfig.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ServiceConfigValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ServiceConfigValidationError{} + // Validate checks the field values on Bootstrap 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. @@ -167,6 +278,10 @@ func (m *Bootstrap) validate(all bool) error { // no validation rules for Name + // no validation rules for Version + + // no validation rules for CryptoType + if _, ok := _Bootstrap_Mode_InLookup[m.GetMode()]; !ok { err := BootstrapValidationError{ field: "Mode", @@ -178,14 +293,21 @@ func (m *Bootstrap) validate(all bool) error { errors = append(errors, err) } - // no validation rules for Version - - // no validation rules for CryptoType - - // no validation rules for Servers + // no validation rules for EnableDynamicConfig // no validation rules for Id + if _, ok := _Bootstrap_Environment_InLookup[m.GetEnvironment()]; !ok { + err := BootstrapValidationError{ + field: "Environment", + reason: "value must be in list [dev prod]", + } + if !all { + return err + } + errors = append(errors, err) + } + if all { switch v := interface{}(m.GetEntry()).(type) { case interface{ ValidateAll() error }: @@ -216,11 +338,11 @@ func (m *Bootstrap) validate(all bool) error { } if all { - switch v := interface{}(m.GetService()).(type) { + switch v := interface{}(m.GetHttpGateway()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ - field: "Service", + field: "HttpGateway", reason: "embedded message failed validation", cause: err, }) @@ -228,28 +350,62 @@ func (m *Bootstrap) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ - field: "Service", + field: "HttpGateway", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetService()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetHttpGateway()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ - field: "Service", + field: "HttpGateway", reason: "embedded message failed validation", cause: err, } } } + for idx, item := range m.GetServices() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: fmt.Sprintf("Services[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: fmt.Sprintf("Services[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: fmt.Sprintf("Services[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + if all { - switch v := interface{}(m.GetData()).(type) { + switch v := interface{}(m.GetStorage()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ - field: "Data", + field: "Storage", reason: "embedded message failed validation", cause: err, }) @@ -257,16 +413,16 @@ func (m *Bootstrap) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ - field: "Data", + field: "Storage", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetStorage()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ - field: "Data", + field: "Storage", reason: "embedded message failed validation", cause: err, } @@ -418,6 +574,35 @@ func (m *Bootstrap) validate(all bool) error { } } + if all { + switch v := interface{}(m.GetHealthCheck()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "HealthCheck", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "HealthCheck", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetHealthCheck()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "HealthCheck", + reason: "embedded message failed validation", + cause: err, + } + } + } + if len(errors) > 0 { return BootstrapMultiError(errors) } @@ -500,6 +685,11 @@ var _Bootstrap_Mode_InLookup = map[string]struct{}{ "cluster": {}, } +var _Bootstrap_Environment_InLookup = map[string]struct{}{ + "dev": {}, + "prod": {}, +} + // Validate checks the field values on Settings 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. @@ -601,6 +791,112 @@ var _ interface { ErrorName() string } = SettingsValidationError{} +// Validate checks the field values on Bootstrap_HealthCheck 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 *Bootstrap_HealthCheck) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Bootstrap_HealthCheck 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 +// Bootstrap_HealthCheckMultiError, or nil if none found. +func (m *Bootstrap_HealthCheck) ValidateAll() error { + return m.validate(true) +} + +func (m *Bootstrap_HealthCheck) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Timeout + + // no validation rules for Path + + if len(errors) > 0 { + return Bootstrap_HealthCheckMultiError(errors) + } + + return nil +} + +// Bootstrap_HealthCheckMultiError is an error wrapping multiple validation +// errors returned by Bootstrap_HealthCheck.ValidateAll() if the designated +// constraints aren't met. +type Bootstrap_HealthCheckMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m Bootstrap_HealthCheckMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m Bootstrap_HealthCheckMultiError) AllErrors() []error { return m } + +// Bootstrap_HealthCheckValidationError is the validation error returned by +// Bootstrap_HealthCheck.Validate if the designated constraints aren't met. +type Bootstrap_HealthCheckValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e Bootstrap_HealthCheckValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e Bootstrap_HealthCheckValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e Bootstrap_HealthCheckValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e Bootstrap_HealthCheckValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e Bootstrap_HealthCheckValidationError) ErrorName() string { + return "Bootstrap_HealthCheckValidationError" +} + +// Error satisfies the builtin error interface +func (e Bootstrap_HealthCheckValidationError) 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 %sBootstrap_HealthCheck.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = Bootstrap_HealthCheckValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = Bootstrap_HealthCheckValidationError{} + // Validate checks the field values on Bootstrap_Entry 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/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto index 4a883b08..3200f20f 100644 --- a/internal/configs/bootstrap.proto +++ b/internal/configs/bootstrap.proto @@ -23,9 +23,8 @@ message ServiceConfig { json_name = "name", (validate.rules).string.min_len = 1 ]; - Entry entry = 2 [json_name = "entry"]; // 各服务独立入口配置 - config.v1.Service service = 3 [json_name = "service"]; // 服务专用配置 - // string registry_path = 4 [json_name = "registry_path"]; // 服务发现注册路径 +// Entry entry = 2 [json_name = "entry"]; // 各服务独立入口配置 +// repeated config.v1.Service services = 3 [json_name = "services"]; // 服务专用配置 } message Bootstrap { @@ -59,19 +58,24 @@ message Bootstrap { } string id = 100 [json_name = "id"]; - string environment = 2 [ + string environment = 102 [ json_name = "environment", - (validate.rules).string = { in: ["dev", "prod"] } + (validate.rules).string = { + in: [ + "dev", + "prod" + ] + } ]; // 入口服务专属配置 - Entry entry = 100 [json_name = "entry"]; - config.v1.Service http_gateway = 101 [json_name = "http_gateway"]; + Entry entry = 103 [json_name = "entry"]; + config.v1.Service http_gateway = 104 [json_name = "http_gateway"]; // 动态加载服务配置 repeated ServiceConfig services = 200 [json_name = "services"]; - config.v1.Data data = 300 [json_name = "data"]; + config.v1.Storage storage = 300 [json_name = "storage"]; config.v1.Registry registry = 400 [json_name = "registry"]; middleware.v1.Middleware middleware = 9 [json_name = "middleware"]; security.v1.AuthN authn = 1000 [json_name = "authn"]; diff --git a/internal/configs/captcha.pb.go b/internal/configs/captcha.pb.go index 81038885..bfe662ce 100644 --- a/internal/configs/captcha.pb.go +++ b/internal/configs/captcha.pb.go @@ -7,7 +7,7 @@ package configs import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" + v1 "github.com/origadmin/runtime/gen/go/config/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -26,16 +26,11 @@ type Captcha struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Length of the verification code - Length int32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"` - // CAPTCHA width - Width int32 `protobuf:"varint,2,opt,name=width,proto3" json:"width,omitempty"` - // CAPTCHA height - Height int32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` - // Type of cache to use for storing CAPTCHA data - CacheType string `protobuf:"bytes,4,opt,name=cache_type,proto3" json:"cache_type,omitempty"` - // Redis instance for CAPTCHA cache - Redis *Captcha_Redis `protobuf:"bytes,5,opt,name=redis,proto3" json:"redis,omitempty"` + Length int32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"` + Width int32 `protobuf:"varint,2,opt,name=width,proto3" json:"width,omitempty"` + Height int32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + StorageName string `protobuf:"bytes,4,opt,name=storage_name,proto3" json:"storage_name,omitempty"` + Storage *v1.Storage `protobuf:"bytes,5,opt,name=storage,proto3" json:"storage,omitempty"` } func (x *Captcha) Reset() { @@ -89,134 +84,41 @@ func (x *Captcha) GetHeight() int32 { return 0 } -func (x *Captcha) GetCacheType() string { +func (x *Captcha) GetStorageName() string { if x != nil { - return x.CacheType + return x.StorageName } return "" } -func (x *Captcha) GetRedis() *Captcha_Redis { +func (x *Captcha) GetStorage() *v1.Storage { if x != nil { - return x.Redis + return x.Storage } return nil } -// Redis configuration for CAPTCHA cache -type Captcha_Redis struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Address of the Redis server - Addr string `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"` - // Username for Redis authentication - Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` - // Password for Redis authentication - Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` - // Database index for Redis - Db int32 `protobuf:"varint,4,opt,name=db,proto3" json:"db,omitempty"` - // Prefix for Redis keys (default: "admin:captcha") - KeyPrefix string `protobuf:"bytes,5,opt,name=key_prefix,proto3" json:"key_prefix,omitempty"` -} - -func (x *Captcha_Redis) Reset() { - *x = Captcha_Redis{} - mi := &file_configs_captcha_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Captcha_Redis) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Captcha_Redis) ProtoMessage() {} - -func (x *Captcha_Redis) ProtoReflect() protoreflect.Message { - mi := &file_configs_captcha_proto_msgTypes[1] - 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 Captcha_Redis.ProtoReflect.Descriptor instead. -func (*Captcha_Redis) Descriptor() ([]byte, []int) { - return file_configs_captcha_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *Captcha_Redis) GetAddr() string { - if x != nil { - return x.Addr - } - return "" -} - -func (x *Captcha_Redis) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *Captcha_Redis) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -func (x *Captcha_Redis) GetDb() int32 { - if x != nil { - return x.Db - } - return 0 -} - -func (x *Captcha_Redis) GetKeyPrefix() string { - if x != nil { - return x.KeyPrefix - } - return "" -} - var File_configs_captcha_proto protoreflect.FileDescriptor var file_configs_captcha_proto_rawDesc = []byte{ 0x0a, 0x15, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, - 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbd, 0x02, + 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, + 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa1, 0x01, 0x0a, 0x07, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, - 0x34, 0x0a, 0x0a, 0x63, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x14, 0xfa, 0x42, 0x11, 0x72, 0x0f, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x6f, - 0x72, 0x79, 0x52, 0x05, 0x72, 0x65, 0x64, 0x69, 0x73, 0x52, 0x0a, 0x63, 0x61, 0x63, 0x68, 0x65, - 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x30, 0x0a, 0x05, 0x72, 0x65, 0x64, 0x69, 0x73, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x2e, 0x52, 0x65, 0x64, 0x69, 0x73, - 0x52, 0x05, 0x72, 0x65, 0x64, 0x69, 0x73, 0x1a, 0x83, 0x01, 0x0a, 0x05, 0x52, 0x65, 0x64, 0x69, - 0x73, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, - 0x02, 0x64, 0x62, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x64, 0x62, 0x12, 0x1e, 0x0a, - 0x0a, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x42, 0x2e, 0x5a, - 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, + 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -231,13 +133,13 @@ func file_configs_captcha_proto_rawDescGZIP() []byte { return file_configs_captcha_proto_rawDescData } -var file_configs_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_configs_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_captcha_proto_goTypes = []any{ - (*Captcha)(nil), // 0: configs.api.Captcha - (*Captcha_Redis)(nil), // 1: configs.api.Captcha.Redis + (*Captcha)(nil), // 0: configs.api.Captcha + (*v1.Storage)(nil), // 1: config.v1.Storage } var file_configs_captcha_proto_depIdxs = []int32{ - 1, // 0: configs.api.Captcha.redis:type_name -> configs.api.Captcha.Redis + 1, // 0: configs.api.Captcha.storage:type_name -> config.v1.Storage 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -256,7 +158,7 @@ func file_configs_captcha_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_configs_captcha_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 1, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/configs/captcha.pb.validate.go b/internal/configs/captcha.pb.validate.go index 94d0ceb8..9673c480 100644 --- a/internal/configs/captcha.pb.validate.go +++ b/internal/configs/captcha.pb.validate.go @@ -62,23 +62,14 @@ func (m *Captcha) validate(all bool) error { // no validation rules for Height - if _, ok := _Captcha_CacheType_InLookup[m.GetCacheType()]; !ok { - err := CaptchaValidationError{ - field: "CacheType", - reason: "value must be in list [memory redis]", - } - if !all { - return err - } - errors = append(errors, err) - } + // no validation rules for StorageName if all { - switch v := interface{}(m.GetRedis()).(type) { + switch v := interface{}(m.GetStorage()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, CaptchaValidationError{ - field: "Redis", + field: "Storage", reason: "embedded message failed validation", cause: err, }) @@ -86,16 +77,16 @@ func (m *Captcha) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, CaptchaValidationError{ - field: "Redis", + field: "Storage", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetRedis()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetStorage()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CaptchaValidationError{ - field: "Redis", + field: "Storage", reason: "embedded message failed validation", cause: err, } @@ -178,118 +169,3 @@ var _ interface { Cause() error ErrorName() string } = CaptchaValidationError{} - -var _Captcha_CacheType_InLookup = map[string]struct{}{ - "memory": {}, - "redis": {}, -} - -// Validate checks the field values on Captcha_Redis 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 *Captcha_Redis) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Captcha_Redis 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 Captcha_RedisMultiError, or -// nil if none found. -func (m *Captcha_Redis) ValidateAll() error { - return m.validate(true) -} - -func (m *Captcha_Redis) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Addr - - // no validation rules for Username - - // no validation rules for Password - - // no validation rules for Db - - // no validation rules for KeyPrefix - - if len(errors) > 0 { - return Captcha_RedisMultiError(errors) - } - - return nil -} - -// Captcha_RedisMultiError is an error wrapping multiple validation errors -// returned by Captcha_Redis.ValidateAll() if the designated constraints -// aren't met. -type Captcha_RedisMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m Captcha_RedisMultiError) Error() string { - var msgs []string - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m Captcha_RedisMultiError) AllErrors() []error { return m } - -// Captcha_RedisValidationError is the validation error returned by -// Captcha_Redis.Validate if the designated constraints aren't met. -type Captcha_RedisValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e Captcha_RedisValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e Captcha_RedisValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e Captcha_RedisValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e Captcha_RedisValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e Captcha_RedisValidationError) ErrorName() string { return "Captcha_RedisValidationError" } - -// Error satisfies the builtin error interface -func (e Captcha_RedisValidationError) 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 %sCaptcha_Redis.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = Captcha_RedisValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = Captcha_RedisValidationError{} diff --git a/internal/configs/captcha.proto b/internal/configs/captcha.proto index f8f938fc..784e0d39 100644 --- a/internal/configs/captcha.proto +++ b/internal/configs/captcha.proto @@ -1,13 +1,15 @@ syntax = "proto3"; package configs.api; +import "config/v1/storage.proto"; + option go_package = "origadmin/application/admin/internal/configs"; message Captcha { int32 length = 1 [json_name = "length"]; int32 width = 2 [json_name = "width"]; int32 height = 3 [json_name = "height"]; - + string storage_name = 4 [json_name = "storage_name"]; config.v1.Storage storage = 5 [json_name = "storage"]; diff --git a/internal/configs/server.pb.go b/internal/configs/server.pb.go index 8b278a58..1b434d67 100644 --- a/internal/configs/server.pb.go +++ b/internal/configs/server.pb.go @@ -7,7 +7,6 @@ package configs import ( - _ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate" v1 "github.com/origadmin/runtime/gen/go/config/v1" v11 "github.com/origadmin/runtime/gen/go/middleware/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -28,12 +27,10 @@ type Server struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // name is the application name or service name for used Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - CryptoType string `protobuf:"bytes,3,opt,name=crypto_type,proto3" json:"crypto_type,omitempty"` Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` - Data *v1.Data `protobuf:"bytes,300,opt,name=data,proto3" json:"data,omitempty"` + Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` } @@ -82,13 +79,6 @@ func (x *Server) GetVersion() string { return "" } -func (x *Server) GetCryptoType() string { - if x != nil { - return x.CryptoType - } - return "" -} - func (x *Server) GetService() *v1.Service { if x != nil { return x.Service @@ -96,9 +86,9 @@ func (x *Server) GetService() *v1.Service { return nil } -func (x *Server) GetData() *v1.Data { +func (x *Server) GetStorage() *v1.Storage { if x != nil { - return x.Data + return x.Storage } return nil } @@ -122,40 +112,34 @@ var File_configs_server_proto protoreflect.FileDescriptor var file_configs_server_proto_rawDesc = []byte{ 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x1b, 0x62, - 0x75, 0x66, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, - 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0xd1, 0x02, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x57, 0x0a, 0x0b, - 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x35, 0xba, 0x48, 0x32, 0x72, 0x30, 0x52, 0x06, 0x61, 0x72, 0x67, 0x6f, 0x6e, 0x32, - 0x52, 0x06, 0x73, 0x63, 0x72, 0x79, 0x70, 0x74, 0x52, 0x06, 0x62, 0x63, 0x72, 0x79, 0x70, 0x74, - 0x52, 0x06, 0x70, 0x62, 0x6b, 0x64, 0x66, 0x32, 0x52, 0x06, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, - 0x52, 0x06, 0x73, 0x68, 0x61, 0x35, 0x31, 0x32, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, - 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x24, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0xac, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, - 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x30, 0x0a, 0x08, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x90, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x39, 0x0a, 0x0a, - 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x19, 0x2e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, - 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, + 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, 0x64, 0x64, 0x6c, + 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, + 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x81, 0x02, 0x0a, 0x06, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0xc8, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0xac, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, + 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, + 0x12, 0x30, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x90, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x12, 0x39, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, + 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, + 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x42, 0x2e, 0x5a, + 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, + 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -174,13 +158,13 @@ var file_configs_server_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_server_proto_goTypes = []any{ (*Server)(nil), // 0: origadmin.configs.api.Server (*v1.Service)(nil), // 1: config.v1.Service - (*v1.Data)(nil), // 2: config.v1.Data + (*v1.Storage)(nil), // 2: config.v1.Storage (*v1.Registry)(nil), // 3: config.v1.Registry (*v11.Middleware)(nil), // 4: middleware.v1.Middleware } var file_configs_server_proto_depIdxs = []int32{ 1, // 0: origadmin.configs.api.Server.service:type_name -> config.v1.Service - 2, // 1: origadmin.configs.api.Server.data:type_name -> config.v1.Data + 2, // 1: origadmin.configs.api.Server.storage:type_name -> config.v1.Storage 3, // 2: origadmin.configs.api.Server.registry:type_name -> config.v1.Registry 4, // 3: origadmin.configs.api.Server.middleware:type_name -> middleware.v1.Middleware 4, // [4:4] is the sub-list for method output_type diff --git a/internal/configs/server.pb.validate.go b/internal/configs/server.pb.validate.go index af6ba3c3..734ad809 100644 --- a/internal/configs/server.pb.validate.go +++ b/internal/configs/server.pb.validate.go @@ -60,8 +60,6 @@ func (m *Server) validate(all bool) error { // no validation rules for Version - // no validation rules for CryptoType - if all { switch v := interface{}(m.GetService()).(type) { case interface{ ValidateAll() error }: @@ -92,11 +90,11 @@ func (m *Server) validate(all bool) error { } if all { - switch v := interface{}(m.GetData()).(type) { + switch v := interface{}(m.GetStorage()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ServerValidationError{ - field: "Data", + field: "Storage", reason: "embedded message failed validation", cause: err, }) @@ -104,16 +102,16 @@ func (m *Server) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ServerValidationError{ - field: "Data", + field: "Storage", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetStorage()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ServerValidationError{ - field: "Data", + field: "Storage", reason: "embedded message failed validation", cause: err, } diff --git a/internal/configs/server.proto b/internal/configs/server.proto index aac32581..80ccb249 100644 --- a/internal/configs/server.proto +++ b/internal/configs/server.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package origadmin.configs.api; -import "config/v1/data.proto"; +import "config/v1/storage.proto"; import "config/v1/registry.proto"; import "config/v1/service.proto"; import "middleware/v1/middleware.proto"; @@ -13,7 +13,7 @@ message Server { string version = 2 [json_name = "version"]; config.v1.Service service = 200 [json_name = "service"]; - config.v1.Data data = 300 [json_name = "data"]; + config.v1.Storage storage = 300 [json_name = "storage"]; config.v1.Registry registry = 400 [json_name = "registry"]; middleware.v1.Middleware middleware = 9 [json_name = "middleware"]; } From 8aa19120c28053920ba4da97a29e7d1971aa21fa Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 24 Apr 2025 16:59:12 +0800 Subject: [PATCH 020/158] refactor(configs): rename basis_config to auth_config - Rename basis_config.proto to auth_config.proto - Update package and message names from BasisConfig to AuthConfig - Rename basis_config.pb.go to auth_config.pb.go - Rename basis_config.pb.validate.go to auth --- internal/configs/auth_config.pb.go | 151 +++++++++++++++++ ...validate.go => auth_config.pb.validate.go} | 64 ++++---- .../{basis_config.proto => auth_config.proto} | 2 +- internal/configs/basis_config.pb.go | 152 ------------------ 4 files changed, 184 insertions(+), 185 deletions(-) create mode 100644 internal/configs/auth_config.pb.go rename internal/configs/{basis_config.pb.validate.go => auth_config.pb.validate.go} (62%) rename internal/configs/{basis_config.proto => auth_config.proto} (95%) delete mode 100644 internal/configs/basis_config.pb.go diff --git a/internal/configs/auth_config.pb.go b/internal/configs/auth_config.pb.go new file mode 100644 index 00000000..a2d3eddc --- /dev/null +++ b/internal/configs/auth_config.pb.go @@ -0,0 +1,151 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.35.1 +// protoc v5.28.3 +// source: configs/auth_config.proto + +package configs + +import ( + v1 "github.com/origadmin/runtime/gen/go/config/v1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type AuthConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // configs.api.RootUser root_user = 1 [json_name = "root_user"]; + Captcha *Captcha `protobuf:"bytes,2,opt,name=captcha,proto3" json:"captcha,omitempty"` + Security *v1.Security `protobuf:"bytes,3,opt,name=security,proto3" json:"security,omitempty"` +} + +func (x *AuthConfig) Reset() { + *x = AuthConfig{} + mi := &file_configs_auth_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AuthConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthConfig) ProtoMessage() {} + +func (x *AuthConfig) ProtoReflect() protoreflect.Message { + mi := &file_configs_auth_config_proto_msgTypes[0] + 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 AuthConfig.ProtoReflect.Descriptor instead. +func (*AuthConfig) Descriptor() ([]byte, []int) { + return file_configs_auth_config_proto_rawDescGZIP(), []int{0} +} + +func (x *AuthConfig) GetCaptcha() *Captcha { + if x != nil { + return x.Captcha + } + return nil +} + +func (x *AuthConfig) GetSecurity() *v1.Security { + if x != nil { + return x.Security + } + return nil +} + +var File_configs_auth_config_proto protoreflect.FileDescriptor + +var file_configs_auth_config_proto_rawDesc = []byte{ + 0x0a, 0x19, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x15, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x63, 0x61, 0x70, 0x74, + 0x63, 0x68, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6d, 0x0a, 0x0a, 0x41, 0x75, 0x74, + 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x61, 0x70, 0x74, 0x63, + 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x52, 0x07, + 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x12, 0x2f, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, + 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, + 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, + 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_configs_auth_config_proto_rawDescOnce sync.Once + file_configs_auth_config_proto_rawDescData = file_configs_auth_config_proto_rawDesc +) + +func file_configs_auth_config_proto_rawDescGZIP() []byte { + file_configs_auth_config_proto_rawDescOnce.Do(func() { + file_configs_auth_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_configs_auth_config_proto_rawDescData) + }) + return file_configs_auth_config_proto_rawDescData +} + +var file_configs_auth_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_configs_auth_config_proto_goTypes = []any{ + (*AuthConfig)(nil), // 0: configs.api.AuthConfig + (*Captcha)(nil), // 1: configs.api.Captcha + (*v1.Security)(nil), // 2: config.v1.Security +} +var file_configs_auth_config_proto_depIdxs = []int32{ + 1, // 0: configs.api.AuthConfig.captcha:type_name -> configs.api.Captcha + 2, // 1: configs.api.AuthConfig.security:type_name -> config.v1.Security + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_configs_auth_config_proto_init() } +func file_configs_auth_config_proto_init() { + if File_configs_auth_config_proto != nil { + return + } + file_configs_captcha_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_configs_auth_config_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_configs_auth_config_proto_goTypes, + DependencyIndexes: file_configs_auth_config_proto_depIdxs, + MessageInfos: file_configs_auth_config_proto_msgTypes, + }.Build() + File_configs_auth_config_proto = out.File + file_configs_auth_config_proto_rawDesc = nil + file_configs_auth_config_proto_goTypes = nil + file_configs_auth_config_proto_depIdxs = nil +} diff --git a/internal/configs/basis_config.pb.validate.go b/internal/configs/auth_config.pb.validate.go similarity index 62% rename from internal/configs/basis_config.pb.validate.go rename to internal/configs/auth_config.pb.validate.go index 2537a591..60e38d90 100644 --- a/internal/configs/basis_config.pb.validate.go +++ b/internal/configs/auth_config.pb.validate.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: configs/basis_config.proto +// source: configs/auth_config.proto package configs @@ -35,22 +35,22 @@ var ( _ = sort.Sort ) -// Validate checks the field values on BasisConfig with the rules defined in -// the proto definition for this message. If any rules are violated, the first +// Validate checks the field values on AuthConfig 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 *BasisConfig) Validate() error { +func (m *AuthConfig) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on BasisConfig with the rules defined in +// ValidateAll checks the field values on AuthConfig 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 BasisConfigMultiError, or +// result is a list of violation errors wrapped in AuthConfigMultiError, or // nil if none found. -func (m *BasisConfig) ValidateAll() error { +func (m *AuthConfig) ValidateAll() error { return m.validate(true) } -func (m *BasisConfig) validate(all bool) error { +func (m *AuthConfig) validate(all bool) error { if m == nil { return nil } @@ -61,7 +61,7 @@ func (m *BasisConfig) validate(all bool) error { switch v := interface{}(m.GetCaptcha()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, BasisConfigValidationError{ + errors = append(errors, AuthConfigValidationError{ field: "Captcha", reason: "embedded message failed validation", cause: err, @@ -69,7 +69,7 @@ func (m *BasisConfig) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, BasisConfigValidationError{ + errors = append(errors, AuthConfigValidationError{ field: "Captcha", reason: "embedded message failed validation", cause: err, @@ -78,7 +78,7 @@ func (m *BasisConfig) validate(all bool) error { } } else if v, ok := interface{}(m.GetCaptcha()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return BasisConfigValidationError{ + return AuthConfigValidationError{ field: "Captcha", reason: "embedded message failed validation", cause: err, @@ -90,7 +90,7 @@ func (m *BasisConfig) validate(all bool) error { switch v := interface{}(m.GetSecurity()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, BasisConfigValidationError{ + errors = append(errors, AuthConfigValidationError{ field: "Security", reason: "embedded message failed validation", cause: err, @@ -98,7 +98,7 @@ func (m *BasisConfig) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, BasisConfigValidationError{ + errors = append(errors, AuthConfigValidationError{ field: "Security", reason: "embedded message failed validation", cause: err, @@ -107,7 +107,7 @@ func (m *BasisConfig) validate(all bool) error { } } else if v, ok := interface{}(m.GetSecurity()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return BasisConfigValidationError{ + return AuthConfigValidationError{ field: "Security", reason: "embedded message failed validation", cause: err, @@ -116,18 +116,18 @@ func (m *BasisConfig) validate(all bool) error { } if len(errors) > 0 { - return BasisConfigMultiError(errors) + return AuthConfigMultiError(errors) } return nil } -// BasisConfigMultiError is an error wrapping multiple validation errors -// returned by BasisConfig.ValidateAll() if the designated constraints aren't met. -type BasisConfigMultiError []error +// AuthConfigMultiError is an error wrapping multiple validation errors +// returned by AuthConfig.ValidateAll() if the designated constraints aren't met. +type AuthConfigMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m BasisConfigMultiError) Error() string { +func (m AuthConfigMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) @@ -136,11 +136,11 @@ func (m BasisConfigMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m BasisConfigMultiError) AllErrors() []error { return m } +func (m AuthConfigMultiError) AllErrors() []error { return m } -// BasisConfigValidationError is the validation error returned by -// BasisConfig.Validate if the designated constraints aren't met. -type BasisConfigValidationError struct { +// AuthConfigValidationError is the validation error returned by +// AuthConfig.Validate if the designated constraints aren't met. +type AuthConfigValidationError struct { field string reason string cause error @@ -148,22 +148,22 @@ type BasisConfigValidationError struct { } // Field function returns field value. -func (e BasisConfigValidationError) Field() string { return e.field } +func (e AuthConfigValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e BasisConfigValidationError) Reason() string { return e.reason } +func (e AuthConfigValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e BasisConfigValidationError) Cause() error { return e.cause } +func (e AuthConfigValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e BasisConfigValidationError) Key() bool { return e.key } +func (e AuthConfigValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e BasisConfigValidationError) ErrorName() string { return "BasisConfigValidationError" } +func (e AuthConfigValidationError) ErrorName() string { return "AuthConfigValidationError" } // Error satisfies the builtin error interface -func (e BasisConfigValidationError) Error() string { +func (e AuthConfigValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -175,14 +175,14 @@ func (e BasisConfigValidationError) Error() string { } return fmt.Sprintf( - "invalid %sBasisConfig.%s: %s%s", + "invalid %sAuthConfig.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = BasisConfigValidationError{} +var _ error = AuthConfigValidationError{} var _ interface { Field() string @@ -190,4 +190,4 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = BasisConfigValidationError{} +} = AuthConfigValidationError{} diff --git a/internal/configs/basis_config.proto b/internal/configs/auth_config.proto similarity index 95% rename from internal/configs/basis_config.proto rename to internal/configs/auth_config.proto index 4611f3d1..998d104b 100644 --- a/internal/configs/basis_config.proto +++ b/internal/configs/auth_config.proto @@ -8,7 +8,7 @@ import "configs/captcha.proto"; option go_package = "origadmin/application/admin/internal/configs"; -message BasisConfig { +message AuthConfig { // configs.api.RootUser root_user = 1 [json_name = "root_user"]; configs.api.Captcha captcha = 2 [json_name = "captcha"]; diff --git a/internal/configs/basis_config.pb.go b/internal/configs/basis_config.pb.go deleted file mode 100644 index 06bfffea..00000000 --- a/internal/configs/basis_config.pb.go +++ /dev/null @@ -1,152 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.35.1 -// protoc v5.28.3 -// source: configs/basis_config.proto - -package configs - -import ( - v1 "github.com/origadmin/runtime/gen/go/config/v1" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type BasisConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // configs.api.RootUser root_user = 1 [json_name = "root_user"]; - Captcha *Captcha `protobuf:"bytes,2,opt,name=captcha,proto3" json:"captcha,omitempty"` - Security *v1.Security `protobuf:"bytes,3,opt,name=security,proto3" json:"security,omitempty"` -} - -func (x *BasisConfig) Reset() { - *x = BasisConfig{} - mi := &file_configs_basis_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *BasisConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*BasisConfig) ProtoMessage() {} - -func (x *BasisConfig) ProtoReflect() protoreflect.Message { - mi := &file_configs_basis_config_proto_msgTypes[0] - 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 BasisConfig.ProtoReflect.Descriptor instead. -func (*BasisConfig) Descriptor() ([]byte, []int) { - return file_configs_basis_config_proto_rawDescGZIP(), []int{0} -} - -func (x *BasisConfig) GetCaptcha() *Captcha { - if x != nil { - return x.Captcha - } - return nil -} - -func (x *BasisConfig) GetSecurity() *v1.Security { - if x != nil { - return x.Security - } - return nil -} - -var File_configs_basis_config_proto protoreflect.FileDescriptor - -var file_configs_basis_config_proto_rawDesc = []byte{ - 0x0a, 0x1a, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x69, 0x73, 0x5f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x63, 0x61, 0x70, - 0x74, 0x63, 0x68, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6e, 0x0a, 0x0b, 0x42, 0x61, - 0x73, 0x69, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x61, 0x70, - 0x74, 0x63, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, - 0x52, 0x07, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x12, 0x2f, 0x0a, 0x08, 0x73, 0x65, 0x63, - 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, - 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, - 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_configs_basis_config_proto_rawDescOnce sync.Once - file_configs_basis_config_proto_rawDescData = file_configs_basis_config_proto_rawDesc -) - -func file_configs_basis_config_proto_rawDescGZIP() []byte { - file_configs_basis_config_proto_rawDescOnce.Do(func() { - file_configs_basis_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_configs_basis_config_proto_rawDescData) - }) - return file_configs_basis_config_proto_rawDescData -} - -var file_configs_basis_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_configs_basis_config_proto_goTypes = []any{ - (*BasisConfig)(nil), // 0: configs.api.BasisConfig - (*Captcha)(nil), // 1: configs.api.Captcha - (*v1.Security)(nil), // 2: config.v1.Security -} -var file_configs_basis_config_proto_depIdxs = []int32{ - 1, // 0: configs.api.BasisConfig.captcha:type_name -> configs.api.Captcha - 2, // 1: configs.api.BasisConfig.security:type_name -> config.v1.Security - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_configs_basis_config_proto_init() } -func file_configs_basis_config_proto_init() { - if File_configs_basis_config_proto != nil { - return - } - file_configs_captcha_proto_init() - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_configs_basis_config_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_configs_basis_config_proto_goTypes, - DependencyIndexes: file_configs_basis_config_proto_depIdxs, - MessageInfos: file_configs_basis_config_proto_msgTypes, - }.Build() - File_configs_basis_config_proto = out.File - file_configs_basis_config_proto_rawDesc = nil - file_configs_basis_config_proto_goTypes = nil - file_configs_basis_config_proto_depIdxs = nil -} From 5e5f710fc20f76fa875ecbfa9447d1bc2b2ff6bf Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 6 May 2025 17:22:55 +0800 Subject: [PATCH 021/158] feat(loader): implement Consul KV based configuration loading - Add new Consul discovery and configuration manager - Implement LoadRemoteBootstrap function for Consul KV - Remove unnecessary local file configuration loading code - Update configuration parsing logic - Refactor existing code to support remote configuration --- .lingma/rules/project_rule.md | 319 ++++++++++++ Makefile | 8 +- cmd/internal/start/start.go | 117 +---- cmd/system/wire_gen.go | 32 +- contrib/security/authn/jwt/authn.go | 2 +- contrib/security/authn/jwt/authn_test.go | 2 +- contrib/security/authn/jwt/claims.go | 2 +- contrib/security/authn/jwt/jwt.go | 2 +- contrib/security/authz/casbin/adapter.go | 2 +- contrib/security/authz/casbin/casbin.go | 2 +- contrib/security/authz/casbin/update.go | 2 +- go.mod | 50 +- go.sum | 104 ++-- helpers/db/db.go | 2 +- helpers/securityx/auth.go | 2 +- helpers/securityx/security.go | 2 +- internal/configs/auth_config.pb.go | 42 +- internal/configs/auth_config.proto | 6 +- internal/configs/bootstrap.pb.go | 237 +++++---- internal/configs/bootstrap.pb.validate.go | 39 +- internal/configs/bootstrap.proto | 6 +- internal/configs/captcha.pb.go | 39 +- internal/configs/captcha.proto | 2 +- internal/configs/root_user.pb.go | 66 +-- internal/configs/root_user.proto | 2 +- internal/configs/server.pb.go | 68 +-- internal/configs/server.proto | 2 +- internal/configs/services/service.pb.go | 254 ++++++++++ .../configs/services/service.pb.validate.go | 387 ++++++++++++++ internal/configs/services/service.proto | 8 +- internal/generate.go | 2 + internal/loader/application.go | 37 ++ internal/loader/bootstrap.go | 163 +----- internal/loader/bootstrap_default.go | 61 ++- internal/loader/config.go | 140 ++---- internal/loader/config_manager.go | 62 +++ internal/loader/loader.go | 95 +++- internal/loader/service_test.go | 316 ++++++++++++ internal/mods/agent/auth_test.go | 2 +- internal/mods/agent/http.go | 2 +- internal/mods/agent/mock.go | 2 +- internal/mods/casbin/biz/biz.go | 2 +- .../mods/casbin/dal/entity/ent/database.go | 2 +- .../dal/entity/ent/template/database.tpl | 2 +- internal/mods/system/biz/auth.biz.go | 2 +- internal/mods/system/biz/biz.go | 2 +- internal/mods/system/biz/casbin.biz.go | 2 +- internal/mods/system/biz/login.biz.go | 2 +- internal/mods/system/biz/permission.biz.go | 2 +- internal/mods/system/biz/personal.biz.go | 2 +- internal/mods/system/biz/resource.biz.go | 2 +- internal/mods/system/biz/role.biz.go | 2 +- internal/mods/system/biz/user.biz.go | 2 +- internal/mods/system/dal/auth.dal.go | 2 +- .../mods/system/dal/entity/ent/database.go | 2 +- .../dal/entity/ent/template/database.tpl | 2 +- internal/mods/system/dal/login.dal.go | 2 +- internal/mods/system/dto/auth.go | 2 +- internal/mods/system/dto/menu.go | 2 +- internal/mods/system/dto/permission.go | 2 +- internal/mods/system/dto/resource.go | 2 +- internal/mods/system/dto/role.go | 2 +- internal/mods/system/dto/user.go | 2 +- internal/mods/system/server/server.go | 27 +- internal/mods/system/service/resource.http.go | 2 +- {internal/mock => test}/token_test.go | 4 +- third_party/buf/validate/validate.proto | 476 ++++++++++-------- 67 files changed, 2216 insertions(+), 1027 deletions(-) create mode 100644 .lingma/rules/project_rule.md create mode 100644 internal/configs/services/service.pb.go create mode 100644 internal/configs/services/service.pb.validate.go create mode 100644 internal/loader/application.go create mode 100644 internal/loader/config_manager.go create mode 100644 internal/loader/service_test.go rename {internal/mock => test}/token_test.go (98%) diff --git a/.lingma/rules/project_rule.md b/.lingma/rules/project_rule.md new file mode 100644 index 00000000..8a786427 --- /dev/null +++ b/.lingma/rules/project_rule.md @@ -0,0 +1,319 @@ +**添加规则文件可帮助模型精准理解你的编码偏好,如框架、代码风格等** +**规则文件只对当前工程生效,单文件限制10000字符。如果无需将该文件提交到远程 Git 仓库,请将其添加到 .gitignore** + +你是一位经验丰富的 Go 语言开发工程师,严格遵循以下原则: + +- **Clean Architecture**:分层设计,依赖单向流动。 +- **DRY/KISS/YAGNI**:避免重复代码,保持简单,只实现必要功能。 +- **并发安全**:合理使用 Goroutine 和 Channel,避免竞态条件。 +- **OWASP 安全准则**:防范 SQL 注入、XSS、CSRF 等攻击。 +- **代码可维护性**:模块化设计,清晰的包结构和函数命名。 + +## **Technology Stack** + +- **语言版本**:Go 1.23+。 +- **框架**:go-kratos(微服务框架)、gin(HTTP框架)、Ent(Graph-based ORM)、slog(日志库)。 +- **依赖管理**:Go Modules。 +- **数据库**:PostgreSQL/MySQL(手写 SQL 或 ORM)。 +- **测试工具**:Testify、Ginkgo。 +- **构建/部署**:Docker、Kubernetes。 +- **Protocol**:HTTP/REST(通过Buf管理)。 +- **日志**:使用 slog 进行日志记录,可配置日志级别。 +- **代码风格**:遵循 Go 官方风格指南。 +- **代码规范**:使用 gofmt 进行格式化,使用 go vet 进行静态分析。 +- **代码质量**:使用 golangci-lint 进行代码检查。 +- **代码注释**:清晰的函数注释、结构体字段注释。 + +--- + +## **Application Logic Design** + +### **分层设计规范** + +1. **Presentation Layer**(HTTP Handler): + - 处理 HTTP 请求,转换请求参数到 Use Case。 + - 返回结构化 JSON 响应。 + - 依赖 Use Case 层,**不得直接操作数据库**。 +2. **Use Case Layer**(业务逻辑): + - 实现核心业务逻辑,调用 Repositories。 + - 返回结果或错误,**不直接处理 HTTP 协议**。 +3. **Repository Layer**(数据访问): + - 封装数据库操作(如 GORM 或手写 SQL)。 + - 提供接口定义,实现与具体数据库交互。 +4. **Entities Layer**(领域模型): + - 定义领域对象(如 User、Product)。 + - **不包含业务逻辑或数据库操作**。 +5. **DTOs Layer**(数据传输对象): + - 用于跨层数据传输(如 HTTP 请求/响应)。 + - 使用 `struct` 定义,避免与 Entities 重复。 +6. **Utilities Layer**(工具函数): + - 封装通用功能(如日志、加密、时间处理)。 + +--- + +## **具体开发规范** + +### **1. 包管理** + +- **包命名**: + - 包名小写,结构清晰(如 `internal/mods`)。 + - 避免循环依赖,使用 `go mod why` 检查依赖关系。 +- **模块化**: + - 每个功能独立为子包(如 `cmd/api`、`internal/mods`、`helpers`)。 + +### **2. 代码结构** + +- **文件组织**: + ``` + project-root/ + ├── cmd/ # 主入口(如 main.go) + │ ├── internal/ # 内部模块入口 + │ │ ├── stop/ # 停止加载器入口 + │ │ └── start/ # 启动加载器入口 + │ │ ├── wire.go # provider定义 + │ │ └── wire_gen.go # 自动生成 + │ └── system/ # 系统模块入口 + │ ├── wire.go # 初始化入口 + │ ├── wire_gen.go # 自动生成 + │ └── main.go + ├── api/ # 微服务接口 + │ └── v1/ # 版本控制 + │ ├── services/ # 服务接口定义 + │ │ └── system # 系统模块微服务接口定义(包含protobuf和接口数据模型) + │ └── proto/ # Protobuf 文件 + │ └── system # 系统模块Protobuf文件 + ├── internal/ # 核心业务逻辑 + │ ├── configs # 系统配置文件 + │ ├── loader # 启动加载器 + │ ├── mock # 模拟数据 + │ ├── mods # 微服务模块 + │ │ ├── system # 系统模块 + │ │ │ └── biz # 核心业务逻辑层(UseCase实现) + │ │ │ ├── dal # 数据访问层(Repository接口及Ent实现) + │ │ │ ├── dto # 数据传输对象 + │ │ │ ├── service # 微服务接口实现 + │ │ │ ├── server # 接口服务层(gRPC/HTTP服务适配器) + │ │ └── ... # 其他微服务模块 + │ └── proxy # 网关代理服务(独立于核心模块的基础设施) + ├── resources # 资源文件 + │ ├── configs # 配置文件 + │ ├── docs # 文档文件 + │ └── migrations # 数据库迁移脚本 + ├── third_party # 第三方Protobuf文件 + ├── helpers # 辅助工具函数 + ├── buf.gen.yaml # 工具脚本配置 + ├── buf.yaml # 工具脚本配置 + ├── main.go # 主入口文件 + └── go.mod # 模块依赖 + ``` +- **函数设计**: + - 函数单一职责,参数不超过 5 个。 + - 使用 `return err` 显式返回错误,**不忽略错误**。 + - 延迟释放资源(如 `defer file.Close()`)。 + +### **3. 错误处理** + +- **错误传递**: + ```go + func DoSomething() error { + if err := validate(); err != nil { + return fmt.Errorf("validate failed: %w", err) + } + // ... + return nil + } + ``` +- **自定义错误类型**: + ```go + type MyError struct { + Code int `json:"code"` + Message string `json:"message"` + } + func (e *MyError) Error() string { return e.Message } + ``` +- **全局错误处理**: + - 使用 Gin 中间件统一处理 HTTP 错误: + ```go + func RecoveryMiddleware() gin.HandlerFunc { + return func(c *gin.Context) { + defer func() { + if r := recover(); r != nil { + c.JSON(http.StatusInternalServerError, gin.H{"error": "internal server error"}) + } + }() + c.Next() + } + } + ``` + +### **4. 依赖注入** + +- **使用依赖注入框架**: + ```go + // 定义接口 + type UserRepository interface { + FindByID(ctx context.Context, id int) (*User, error) + } + + // 实现依赖注入(如使用 wire) + func InitializeDependencies() (*UserRepository, func()) { + repo := NewGORMUserRepository() + return repo, func() { /* 释放资源 */ } + } + ``` + +### **5. HTTP 处理** + +- **路由设计**: + ```go + router := gin.Default() + v1 := router.Group("/api/v1") + { + v1.POST("/users", CreateUserHandler) + v1.GET("/users/:id", GetUserHandler) + } + ``` +- **响应格式**: + ```go + type APIResponse struct { + Status string `json:"status"` + Message string `json:"message"` + Data interface{} `json:"data,omitempty"` + } + ``` +- **中间件**: + ```go + func LoggerMiddleware() gin.HandlerFunc { + return func(c *gin.Context) { + start := time.Now() + c.Next() + duration := time.Since(start) + zap.L().Info("request", zap.String("path", c.Request.URL.Path), zap.Duration("duration", duration)) + } + } + ``` + +### **6. 数据库操作** + +- **GORM 使用规范**: + ```go + type User struct { + gorm.Model + Name string `gorm:"unique"` + Email string + } + + func (repo *GORMUserRepository) FindByEmail(ctx context.Context, email string) (*User, error) { + var user User + if err := repo.DB.Where("email = ?", email).First(&user).Error; err != nil { + return nil, err + } + return &user, nil + } + ``` +- **SQL 注入防护**: + - 使用参数化查询(如 `WHERE id = ?`)。 + - 避免拼接 SQL 字符串。 + +### **7. 并发处理** + +- **Goroutine 安全**: + ```go + var mu sync.Mutex + var count int + + func Increment() { + mu.Lock() + defer mu.Unlock() + count++ + } + ``` +- **Channel 通信**: + ```go + func Worker(id int, jobs <-chan int, results chan<- int) { + for j := range jobs { + fmt.Printf("Worker %d processing job %d\n", id, j) + results <- j * 2 + } + } + ``` + +### **8. 安全规范** + +- **输入验证**: + ```go + type CreateUserRequest struct { + Name string `json:"name" validate:"required,min=2"` + Email string `json:"email" validate:"required,email"` + } + ``` +- **环境变量**: + ```go + const ( + DBHost = os.Getenv("DB_HOST") + DBUser = os.Getenv("DB_USER") + DBPassword = os.Getenv("DB_PASSWORD") + ) + ``` + +### **9. 测试规范** + +- **单元测试**: + ```go + func TestUserService_CreateUser(t *testing.T) { + // 使用 mock 对象模拟依赖 + mockRepo := &MockUserRepository{} + service := NewUserService(mockRepo) + _, err := service.CreateUser(context.Background(), "test@example.com") + assert.NoError(t, err) + } + ``` + +### **10. 日志规范** + +- **结构化日志**: + ```go + logger, _ := zap.NewProduction() + defer logger.Sync() + logger.Info("user created", zap.String("user_id", "123")) + ``` + +--- + +## **示例:全局错误处理** + +```go +// 定义全局错误响应结构 +type APIResponse struct { +Status string `json:"status"` +Message string `json:"message"` +Data interface{} `json:"data,omitempty"` +} + +// 中间件统一处理错误 +func ErrorHandler() gin.HandlerFunc { +return func (c *gin.Context) { +c.Next() +if len(c.Errors) > 0 { +lastError := c.Errors.Last() +status := lastError.StatusCode +message := lastError.Err.Error() +c.AbortWithStatusJSON(status, APIResponse{ +Status: "error", +Message: message, +}) +} +} +} +``` + +--- + +## **备注** + +- **代码评审**:每次提交必须通过代码评审,确保规范遵守。 +- **性能优化**:使用 `pprof` 分析内存/CPU 使用,避免内存泄漏。 +- **文档**:关键接口需用 `godoc` 注释,API 文档使用 Swagger 生成。 +- **CI/CD**:代码提交后自动触发测试、构建和部署流程。 + +``` \ No newline at end of file diff --git a/Makefile b/Makefile index a072ea33..d8db61dd 100644 --- a/Makefile +++ b/Makefile @@ -196,10 +196,10 @@ gen: .PHONY: all # generate all all: - make api; - make config; - make generate; - make openapi; + $(MAKE) api; + $(MAKE) config; + $(MAKE) generate; + $(MAKE) openapi; .PHONY: http # run http request diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index 3cb51fd4..338d576a 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -8,31 +8,21 @@ package start import ( "context" "fmt" - "log/slog" "os" - "os/exec" - "path/filepath" - "strings" "syscall" "time" "github.com/gin-gonic/gin" "github.com/go-kratos/kratos/v2" - "github.com/go-kratos/kratos/v2/middleware/tracing" - "github.com/golang-cz/devslog" _ "github.com/origadmin/contrib/consul/config" _ "github.com/origadmin/contrib/consul/registry" _ "github.com/origadmin/contrib/database" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" - kslog "github.com/origadmin/slog-kratos" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/hash/types" - "github.com/origadmin/toolkits/errors" - "github.com/origadmin/toolkits/sloge" + "github.com/origadmin/runtime/registry" + "github.com/origadmin/runtime/service" "github.com/spf13/cobra" - "origadmin/application/admin/helpers/command" "origadmin/application/admin/internal/loader" ) @@ -51,7 +41,7 @@ var ( // Version is the Version of the compiled software. Version = "v1.0.0" // flags are the bootstrap flags. - flags = bootstrap.Bootstrap{Env: "release"} + flags = bootstrap.New() ) var cmd = &cobra.Command{ @@ -69,16 +59,14 @@ func RandomID() string { } func init() { //fmt.Println("total env: ", os.Environ(), len(os.Environ())) - flags.Flags.ID = RandomID() - flags.SetFlags(Name, Version) + flags.SetServiceID(RandomID()) + flags.SetServiceInfo(Name, Version) } // Cmd The function defines a CLI command to start a server with various flags and options, including the // ability to run as a daemon. func Cmd() *cobra.Command { cmd.Flags().BoolP(startRandom, "r", false, "start with random password") - //cmd.Flags().StringP(startWorkDir, "d", ".", "working directory") - //cmd.Flags().StringP(startWorkDir, "d", ".", "working directory") cmd.Flags().StringP(startConfig, "c", "bootstrap.toml", "runtime configuration files or directory (relative to workdir, multiple separated by commas)") cmd.Flags().StringP(startStatic, "s", "", "static files directory") @@ -87,91 +75,26 @@ func Cmd() *cobra.Command { return cmd } +// 启动时使用分离的配置 func startCommandRun(cmd *cobra.Command, args []string) error { - debug, _ := cmd.Flags().GetBool(startDebug) - if debug { - flags.Env = "debug" - flags.WorkDir = "resources/configs" - slog.SetLogLoggerLevel(slog.LevelDebug) - } - staticDir, _ := cmd.Flags().GetString(startStatic) - flags.ConfigPath, _ = cmd.Flags().GetString(startConfig) - //random, _ := cmd.Flags().GetBool(startRandom) - slogInstance := sloge.New(sloge.WithFile("logs/admin.log"), sloge.WithDevConfig(&sloge.DevConfig{ - HandlerOptions: &slog.HandlerOptions{Level: slog.LevelDebug}, - MaxSlicePrintSize: 50, - SortKeys: false, - TimeFormat: "[15:04:05]", - DebugColor: devslog.Blue, - InfoColor: devslog.Green, - WarnColor: devslog.Yellow, - ErrorColor: devslog.Red, - })) - l := log.With(kslog.NewLogger(kslog.WithLogger(slogInstance)), - "ts", log.DefaultTimestamp, - "caller", log.DefaultCaller, - "service.id", flags.ID(), - "service.name", flags.ServiceName(), - "service.version", flags.Version(), - "trace.id", tracing.TraceID(), - "span.id", tracing.SpanID(), - ) - log.SetLogger(l) - //path := filepath.Join(flags.WorkDir, flags.ConfigPath) - //envpath := filepath.Join(flags.WorkDir, flags.EnvPath) - log.Infow("msg", "start info", "workpath", flags.WorkPath(), startStatic, staticDir) - if daemon, _ := cmd.Flags().GetBool("daemon"); daemon { - bin, err := filepath.Abs(os.Args[0]) - if err != nil { - log.Errorf("failed to get absolute path for cmd: %s \n", err.Error()) - return err - } - - cmdArgs := []string{"start"} - cmdArgs = append(cmdArgs, "-d", strings.TrimSpace(flags.WorkDir)) - cmdArgs = append(cmdArgs, "-c", strings.TrimSpace(flags.ConfigPath)) - cmdArgs = append(cmdArgs, "-s", strings.TrimSpace(staticDir)) - _, _ = fmt.Printf("execute cmd: %s %s \n", bin, strings.Join(cmdArgs, " ")) - cmd := exec.Command(bin, cmdArgs...) - err = cmd.Start() - if err != nil { - _, _ = fmt.Printf("failed to start daemon thread: %s \n", err.Error()) - return err - } - - pid := cmd.Process.Pid - log.Errorf("service %s daemon thread started with pid %d \n", flags.ServiceName(), pid) - return nil - } - bs, err := loader.LoadBootstrap(&flags) + // 获取纯净配置 + bs, err := loader.LoadBootstrap(config) if err != nil { - return errors.Wrap(err, "load config error") - } - if bs == nil { - return errors.New("bootstrap config not found") - } - - if err := hash.UseCrypto(types.Type(bs.CryptoType)); err != nil { - return errors.Wrap(err, "use crypto error") + return err } - lockfile := fmt.Sprintf("%s.lock", command.ToLower(cmd)) - if err = os.WriteFile(lockfile, []byte(fmt.Sprintf("%d", os.Getpid())), 0o600); err == nil { - defer os.Remove(lockfile) - } else { - return errors.Wrap(err, "write lock file error") + // 显式创建注册器(按需) + var registrar registry.KRegistrar + if flags.IsMainService() { + registrar, _ = registry.NewConsulRegistrar(...) } - app, cleanup, err := buildInjectors(cmd.Context(), bs, l) - if err != nil { - return err - } - defer cleanup() - // start and wait for stop signal - if err := app.Run(); err != nil { - return err - } - return nil + // 组合使用配置和服务 + appInstance := loader.NewApp(cmd.Context(), loader.AppOptions{ + Name: bs.ServiceName, + Version: flags.Version(), + Server: grpcServer, + }) } func NewApp(ctx context.Context, injector *loader.InjectorClient) *kratos.App { @@ -186,7 +109,7 @@ func NewApp(ctx context.Context, injector *loader.InjectorClient) *kratos.App { kratos.Server(injector.Server), } - if flags.Env == "release" { + if flags.Env() == "release" { gin.SetMode(gin.ReleaseMode) } diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index aae51dca..6ed9f8aa 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -1,8 +1,7 @@ // Code generated by Wire. DO NOT EDIT. //go:generate go run -mod=mod github.com/google/wire/cmd/wire -//go:build !wireinject -// +build !wireinject +//+build !wireinject package main @@ -48,7 +47,7 @@ func buildInjectors(contextContext context.Context, bootstrap *configs.Bootstrap authRepo := dal.NewAuthRepo(data, arg) authServiceBiz := biz.NewAuthServiceBiz(authRepo, arg) authServiceServer := service.NewAuthServiceServerPB(authServiceBiz) - basisConfig := loader.NewBasisConfig(bootstrap) + invalid type := loader.NewBasisConfig(bootstrap) tokenizer, err := loader.NewTokenizer(bootstrap) if err != nil { cleanup() @@ -56,11 +55,11 @@ func buildInjectors(contextContext context.Context, bootstrap *configs.Bootstrap } refreshTokenizer := dal.RefreshTokenizer(tokenizer) loginData := &dal.LoginData{ - BasisConfig: basisConfig, - Tokenizer: refreshTokenizer, - Resource: resourceRepo, - Role: roleRepo, - User: userRepo, + BasisConfig: invalid type, + Tokenizer: refreshTokenizer, + Resource: resourceRepo, + Role: roleRepo, + User: userRepo, } loginRepo := dal.NewLoginRepo(loginData, arg) loginServiceBiz := biz.NewLoginServiceBiz(loginRepo, arg) @@ -78,26 +77,17 @@ func buildInjectors(contextContext context.Context, bootstrap *configs.Bootstrap } casbinSourceServiceBiz := biz.NewCasbinSourceServiceBiz(casbinSourceRepo, arg) casbinSourceServiceServer := service.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) - registerServer := &service.RegisterServer{ - Resource: resourceServiceServer, - Role: roleServiceServer, - User: userServiceServer, - Auth: authServiceServer, - Login: loginServiceServer, - Personal: personalServiceServer, - Permission: permissionServiceServer, - Casbin: casbinSourceServiceServer, - } - v2 := server.NewRegisterServer(registerServer) + v2 := server.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, authServiceServer, loginServiceServer, personalServiceServer, permissionServiceServer, casbinSourceServiceServer) v3 := server.NewSystemServer(bootstrap, v2, arg) injectorServer := &loader.InjectorServer{ - Logger: arg, + Logger: arg, Bootstrap: bootstrap, Registrar: v, - Servers: v3, + Servers: v3, } app := NewApp(contextContext, injectorServer) return app, func() { cleanup() }, nil } + diff --git a/contrib/security/authn/jwt/authn.go b/contrib/security/authn/jwt/authn.go index 0047b579..4d9050f6 100644 --- a/contrib/security/authn/jwt/authn.go +++ b/contrib/security/authn/jwt/authn.go @@ -10,7 +10,7 @@ import ( "github.com/goexts/generic/settings" msecurity "github.com/origadmin/runtime/agent/middleware/security" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" ) type Authenticator struct { diff --git a/contrib/security/authn/jwt/authn_test.go b/contrib/security/authn/jwt/authn_test.go index e790e082..edaa2ee9 100644 --- a/contrib/security/authn/jwt/authn_test.go +++ b/contrib/security/authn/jwt/authn_test.go @@ -17,7 +17,7 @@ import ( middlewaresecurity "github.com/origadmin/runtime/agent/middleware/security" configv1 "github.com/origadmin/runtime/gen/go/config/v1" securityv1 "github.com/origadmin/runtime/gen/go/security/v1" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" "github.com/stretchr/testify/assert" ) diff --git a/contrib/security/authn/jwt/claims.go b/contrib/security/authn/jwt/claims.go index 2197dfb6..f816055d 100644 --- a/contrib/security/authn/jwt/claims.go +++ b/contrib/security/authn/jwt/claims.go @@ -11,7 +11,7 @@ import ( jwtv5 "github.com/golang-jwt/jwt/v5" securityv1 "github.com/origadmin/runtime/gen/go/security/v1" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" ) var ( diff --git a/contrib/security/authn/jwt/jwt.go b/contrib/security/authn/jwt/jwt.go index 47d803d2..dd975081 100644 --- a/contrib/security/authn/jwt/jwt.go +++ b/contrib/security/authn/jwt/jwt.go @@ -17,7 +17,7 @@ import ( configv1 "github.com/origadmin/runtime/gen/go/config/v1" securityv1 "github.com/origadmin/runtime/gen/go/security/v1" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" ) const ( diff --git a/contrib/security/authz/casbin/adapter.go b/contrib/security/authz/casbin/adapter.go index 297933f4..ab770c16 100644 --- a/contrib/security/authz/casbin/adapter.go +++ b/contrib/security/authz/casbin/adapter.go @@ -12,7 +12,7 @@ import ( "github.com/casbin/casbin/v2/model" "github.com/casbin/casbin/v2/persist" "github.com/goexts/generic/maps" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" ) type adapter struct { diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index aa868de7..1bb2b153 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -17,7 +17,7 @@ import ( configv1 "github.com/origadmin/runtime/gen/go/config/v1" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/errors" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" "github.com/prometheus/client_golang/prometheus" ) diff --git a/contrib/security/authz/casbin/update.go b/contrib/security/authz/casbin/update.go index dd593cc0..d2bb3c8a 100644 --- a/contrib/security/authz/casbin/update.go +++ b/contrib/security/authz/casbin/update.go @@ -16,7 +16,7 @@ import ( "github.com/casbin/casbin/v2/persist" "github.com/goexts/generic/maps" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" "google.golang.org/grpc/status" pb "origadmin/application/admin/api/v1/services/system" diff --git a/go.mod b/go.mod index 8eeced41..c0d250db 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,12 @@ module origadmin/application/admin -go 1.23.4 +go 1.23.7 toolchain go1.23.8 replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0.5.4 require ( - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250307204501-0409229c3780.1 entgo.io/ent v0.14.4 github.com/caarlos0/go-version v0.2.0 github.com/casbin/casbin/v2 v2.105.0 @@ -15,8 +14,8 @@ require ( github.com/envoyproxy/protoc-gen-validate v1.2.1 github.com/gin-gonic/gin v1.10.0 github.com/go-kratos/kratos/v2 v2.8.4 - github.com/goexts/generic v0.2.5 - github.com/golang-cz/devslog v0.0.12 + github.com/goexts/generic v0.2.6 + github.com/golang-cz/devslog v0.0.13 github.com/golang-jwt/jwt/v5 v5.2.2 github.com/google/gnostic v0.7.0 github.com/google/uuid v1.6.0 @@ -24,32 +23,33 @@ require ( github.com/gorilla/handlers v1.5.2 github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 github.com/mojocn/base64Captcha v1.3.8 - github.com/origadmin/contrib/consul v0.0.32 - github.com/origadmin/contrib/database v0.0.32 - github.com/origadmin/contrib/i18n v0.0.32 - github.com/origadmin/contrib/replacer v0.0.32 - github.com/origadmin/contrib/transport/gins v0.0.32 - github.com/origadmin/entslog/v3 v3.0.6 - github.com/origadmin/runtime v0.1.55 + github.com/origadmin/contrib/consul v0.0.33 + github.com/origadmin/contrib/database v0.0.33 + github.com/origadmin/contrib/i18n v0.0.33 + github.com/origadmin/contrib/replacer v0.0.33 + github.com/origadmin/contrib/transport/gins v0.0.33 + github.com/origadmin/entslog/v3 v3.1.0 + github.com/origadmin/runtime v0.1.58 github.com/origadmin/slog-kratos v1.0.4 - github.com/origadmin/toolkits v0.3.1 - github.com/origadmin/toolkits/codec v0.3.1 - github.com/origadmin/toolkits/crypto v0.3.1 - github.com/origadmin/toolkits/errors v0.3.1 - github.com/origadmin/toolkits/identifier v0.3.1 - github.com/origadmin/toolkits/sloge v0.3.1 + github.com/origadmin/toolkits v0.3.15 + github.com/origadmin/toolkits/codec v0.3.15 + github.com/origadmin/toolkits/crypto v0.3.15 + github.com/origadmin/toolkits/errors v0.3.15 + github.com/origadmin/toolkits/identifier v0.3.15 + github.com/origadmin/toolkits/slogx v0.3.15 github.com/prometheus/client_golang v1.22.0 github.com/sony/sonyflake v1.2.0 github.com/spf13/cobra v1.9.1 github.com/stretchr/testify v1.10.0 golang.org/x/net v0.39.0 - google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e + google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34 google.golang.org/grpc v1.72.0 google.golang.org/protobuf v1.36.6 ) require ( ariga.io/atlas v0.32.0 // indirect + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 // indirect cel.dev/expr v0.23.1 // indirect dario.cat/mergo v1.0.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect @@ -61,7 +61,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect - github.com/bufbuild/protovalidate-go v0.9.3 // indirect + github.com/bufbuild/protovalidate-go v0.10.0 // indirect github.com/bytedance/sonic v1.13.2 // indirect github.com/bytedance/sonic/loader v0.2.4 // indirect github.com/casbin/govaluate v1.3.0 // indirect @@ -76,8 +76,8 @@ require ( github.com/gabriel-vasile/mimetype v1.4.9 // indirect github.com/gin-contrib/sse v1.1.0 // indirect github.com/go-kratos/aegis v0.2.0 // indirect - github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250314165958-d9aa7ff19541 // indirect - github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250314165958-d9aa7ff19541 // indirect + github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250427030626-b463dc514714 // indirect + github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250427030626-b463dc514714 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect @@ -91,11 +91,11 @@ require ( github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/google/cel-go v0.24.1 // indirect + github.com/google/cel-go v0.25.0 // indirect github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/gorilla/mux v1.8.1 // indirect - github.com/hashicorp/consul/api v1.31.2 // indirect + github.com/hashicorp/consul/api v1.32.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect @@ -160,11 +160,11 @@ require ( golang.org/x/sys v0.32.0 // indirect golang.org/x/text v0.24.0 // indirect golang.org/x/tools v0.32.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - modernc.org/libc v1.63.0 // indirect + modernc.org/libc v1.64.0 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.10.0 // indirect modernc.org/sqlite v1.37.0 // indirect diff --git a/go.sum b/go.sum index f3c09560..bcfb8c16 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ ariga.io/atlas v0.32.0 h1:y+77nueMrExLiKlz1CcPKh/nU7VSlWfBbwCShsJyvCw= ariga.io/atlas v0.32.0/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250307204501-0409229c3780.1 h1:zgJPqo17m28+Lf5BW4xv3PvU20BnrmTcGYrog22lLIU= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250307204501-0409229c3780.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 h1:YhMSc48s25kr7kv31Z8vf7sPUIq5YJva9z1mn/hAt0M= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U= cel.dev/expr v0.23.1 h1:K4KOtPCJQjVggkARsjG9RWXP6O4R73aHeJMa/dmCQQg= cel.dev/expr v0.23.1/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= @@ -650,8 +650,8 @@ github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR github.com/bmatcuk/doublestar/v4 v4.8.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/bufbuild/protovalidate-go v0.9.3 h1:XvdtwQuppS3wjzGfpOirsqwN5ExH2+PiIuA/XZd3MTM= -github.com/bufbuild/protovalidate-go v0.9.3/go.mod h1:2lUDP6fNd3wxznRNH3Nj64VB07+PySeslamkerwP6tE= +github.com/bufbuild/protovalidate-go v0.10.0 h1:QdaKhfk3/Dnb2soL9mKmuLPstq+ogAwSWCE3sQ1NBEE= +github.com/bufbuild/protovalidate-go v0.10.0/go.mod h1:nIggbFjqS4DxJgSFBhOzH97Pb8SPNceFc5nygg1pOA8= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= @@ -758,10 +758,10 @@ github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kratos/aegis v0.2.0 h1:dObzCDWn3XVjUkgxyBp6ZeWtx/do0DPZ7LY3yNSJLUQ= github.com/go-kratos/aegis v0.2.0/go.mod h1:v0R2m73WgEEYB3XYu6aE2WcMwsZkJ/Rzuf5eVccm7bI= -github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250314165958-d9aa7ff19541 h1:DpH83kZ4uTRu6UHNrnB/LYVZvoUlTToEaXb8uJ6mtBI= -github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250314165958-d9aa7ff19541/go.mod h1:wRayvgENYEYVKc92zyYgB5clW87JgojqipEtM4Au67A= -github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250314165958-d9aa7ff19541 h1:hew9nMKUssGGU1f6Q8U+LUlNy0xtZ/MD07K8BtVraGU= -github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250314165958-d9aa7ff19541/go.mod h1:OpFw/FRkeh19tGNpVtm1Yiy+y2EqjXLnZQwCuUaOExY= +github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250427030626-b463dc514714 h1:QR7Fl4tegayNFvhUyxnwZwmWxtaegjYV7PbHxLcXo18= +github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250427030626-b463dc514714/go.mod h1:bmXodVT3GSKZAfYskkDAZHCTeN3K04+vDZsho5SOPJg= +github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250427030626-b463dc514714 h1:iPVz2v4+Z6v54pg+B+Z5O8cwRGcrA1SsHNO1enNffRs= +github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250427030626-b463dc514714/go.mod h1:I3L2JB86WBDlvBEICeJ39X/0KF0JJ4fkfbSg8LRSfRU= github.com/go-kratos/kratos/v2 v2.8.4 h1:eIJLE9Qq9WSoKx+Buy2uPyrahtF/lPh+Xf4MTpxhmjs= github.com/go-kratos/kratos/v2 v2.8.4/go.mod h1:mq62W2101a5uYyRxe+7IdWubu7gZCGYqSNKwGFiiRcw= github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= @@ -800,11 +800,11 @@ github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3a github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= -github.com/goexts/generic v0.2.5 h1:+TjsHnduEqQrjXcWbO/ubvOCBNbYHJ5ggvkHicz/JVY= -github.com/goexts/generic v0.2.5/go.mod h1:SZddH3gsbpBCE8JezA87mLXvM0aVrHivRWmnTn+enI4= +github.com/goexts/generic v0.2.6 h1:QKofyPuc7Qo8lxgYP/c+4b+1UGJgjFyFPVr68uqc+js= +github.com/goexts/generic v0.2.6/go.mod h1:SZddH3gsbpBCE8JezA87mLXvM0aVrHivRWmnTn+enI4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang-cz/devslog v0.0.12 h1:wTwC066Qc7ag7J4coy5mBQXA6lYyaSA3ctpArcWofNg= -github.com/golang-cz/devslog v0.0.12/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= +github.com/golang-cz/devslog v0.0.13 h1:JkJ6PPNSOCBpYyU03v3xw7WgpChQ3AYFqgRbYBhUk/Y= +github.com/golang-cz/devslog v0.0.13/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= @@ -855,8 +855,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/cel-go v0.24.1 h1:jsBCtxG8mM5wiUJDSGUqU0K7Mtr3w7Eyv00rw4DiZxI= -github.com/google/cel-go v0.24.1/go.mod h1:Hdf9TqOaTNSFQA1ybQaRqATVoK7m/zcf7IMhGXP5zI8= +github.com/google/cel-go v0.25.0 h1:jsFw9Fhn+3y2kBbltZR4VEz5xKkcIFRPDnuEzAGv5GY= +github.com/google/cel-go v0.25.0/go.mod h1:hjEb6r5SuOSlhCHmFoLzu8HGCERvIsDAbxDAyNU/MmI= github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/gnostic v0.7.0 h1:d7EpuFp8vVdML+y0JJJYiKeOLjKTdH/GvVkLOBWqJpw= github.com/google/gnostic v0.7.0/go.mod h1:IAcUyMl6vtC95f60EZ8oXyqTsOersP6HbwjeG7EyDPM= @@ -939,8 +939,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4Zs github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= -github.com/hashicorp/consul/api v1.31.2 h1:NicObVJHcCmyOIl7Z9iHPvvFrocgTYo9cITSGg0/7pw= -github.com/hashicorp/consul/api v1.31.2/go.mod h1:Z8YgY0eVPukT/17ejW+l+C7zJmKwgPHtjU1q16v/Y40= +github.com/hashicorp/consul/api v1.32.0 h1:5wp5u780Gri7c4OedGEPzmlUEzi0g2KyiPphSr6zjVg= +github.com/hashicorp/consul/api v1.32.0/go.mod h1:Z8YgY0eVPukT/17ejW+l+C7zJmKwgPHtjU1q16v/Y40= github.com/hashicorp/consul/sdk v0.16.1 h1:V8TxTnImoPD5cj0U9Spl0TUxcytjcbbJeADFF07KdHg= github.com/hashicorp/consul/sdk v0.16.1/go.mod h1:fSXvwxB2hmh1FMZCNl6PwX0Q/1wdWtHJcZ7Ea5tns0s= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -1047,8 +1047,6 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= @@ -1079,38 +1077,36 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/origadmin/contrib/consul v0.0.32 h1:OVb8xIaoblEGuPeBe0FzLRxrtOoBb43CXP6D62/5tDA= -github.com/origadmin/contrib/consul v0.0.32/go.mod h1:YkCs7pFxjJz6ej3wx3OpSxp3CR/U1wBBI+8p9KYarbA= -github.com/origadmin/contrib/database v0.0.32 h1:lYdvX74xczO947oMK71KASt9Xhmn1/9VB1QYv3Ft/pQ= -github.com/origadmin/contrib/database v0.0.32/go.mod h1:XIRcyTqh4Da5Eyal3VN/qGicsU5BXwY8ruI23THWlTA= -github.com/origadmin/contrib/i18n v0.0.32 h1:8OyFcFdAZ5FiQ/Z+ZkKlwYARksjDhZUc018vYELmb6I= -github.com/origadmin/contrib/i18n v0.0.32/go.mod h1:s9NFmWfdyDkIVuA2l0dTilgxQhf+7x+A6mS3JvbEPXk= -github.com/origadmin/contrib/replacer v0.0.32 h1:r9brxF92eNJBMOJXwvaUtrRI1EDo1PZhItJGnMb96Os= -github.com/origadmin/contrib/replacer v0.0.32/go.mod h1:zTR4fcc/K43ImF8jFPYK0uHbk+VEPg5fnXLKKAb4EA0= -github.com/origadmin/contrib/transport/gins v0.0.32 h1:C7stnejdsGRCBwenFoxVdztaqqt/tb+p4Wl2ndIz8Mc= -github.com/origadmin/contrib/transport/gins v0.0.32/go.mod h1:fEK2508WhMBKF4S0SeUO9zZrDhpQCiJMqMLKxS15pm8= -github.com/origadmin/entslog/v3 v3.0.6 h1:dSVmiONu5yD5PbyoRtIE/iNh0cu0yykJyWxDtY71WQU= -github.com/origadmin/entslog/v3 v3.0.6/go.mod h1:s9B/cZNsjsqofjOimfNOfpZl2LLHdUKN9MDCBhdWsvI= +github.com/origadmin/contrib/consul v0.0.33 h1:yupFC4cc3d0wTrmg6AbKHWZJxHX6MnkBZ5kHyP8i24I= +github.com/origadmin/contrib/consul v0.0.33/go.mod h1:WN6/MhWc66afuacmxME/8bBfl/tjViECWVKhuMw+xd0= +github.com/origadmin/contrib/database v0.0.33 h1:8gp/s3y1oDyfDLGhAArDTMuUI+cw4vIQUmvq54zlacE= +github.com/origadmin/contrib/database v0.0.33/go.mod h1:C789sBJhECVWe/4095eHFaenjE9VOydwEGCdh+KK4Pg= +github.com/origadmin/contrib/i18n v0.0.33 h1:d5i60H2cd1+aqoDPE3WIvznimCAiHBsTITg2aGNqg1s= +github.com/origadmin/contrib/i18n v0.0.33/go.mod h1:dNURdi4+YbtKueS5cZyZmwT98FPKOfPwaDfhAtE/lr4= +github.com/origadmin/contrib/replacer v0.0.33 h1:Zmc7n4Q8oOnUZu8xNLacHhOWGDpGH+MjZh2bs5MjNv0= +github.com/origadmin/contrib/replacer v0.0.33/go.mod h1:zTR4fcc/K43ImF8jFPYK0uHbk+VEPg5fnXLKKAb4EA0= +github.com/origadmin/contrib/transport/gins v0.0.33 h1:9WKZYyLI3QQq6fCDFyeeEKLMTt5q6FLstizyRILmmSA= +github.com/origadmin/contrib/transport/gins v0.0.33/go.mod h1:LVNgg47PYSFVWABQfZqOaCmMFsehf7jbd7JZOG5IYO8= +github.com/origadmin/entslog/v3 v3.1.0 h1:1SPjs2CWytl08obWW2wAk8UTiwoc0ak/doWdQHN64Rk= +github.com/origadmin/entslog/v3 v3.1.0/go.mod h1:cIFyIZprNlJ69T18DnXBpylvO2CWvEGPhW1r2Sm/51s= github.com/origadmin/go-metrics v0.5.4 h1:odg6zeZUGkTCl6cGJ/bS5GlvjZ3x3GU2zyw9WtNmKFY= github.com/origadmin/go-metrics v0.5.4/go.mod h1:KiuAdjBbuXAkjTjy7p7F4g6sjO6WuvH+6hTlMKUxPkg= -github.com/origadmin/runtime v0.1.55 h1:nb2owsqJFy8HEjVjn2g0DgnOq712B1+00h3zFISoBXo= -github.com/origadmin/runtime v0.1.55/go.mod h1:gilZK6pkP7ChbYmR2y/L0ikVZMvFQd83dzEbDcN096k= +github.com/origadmin/runtime v0.1.58 h1:qNWpm/jOSbtYgQ0NtZJ3OjCyyZgvzUXqk4kCGFj5hMs= +github.com/origadmin/runtime v0.1.58/go.mod h1:WfQLmC9QVyPTsab3ISP8nOu6Ow9rncUEqx38OAunITE= github.com/origadmin/slog-kratos v1.0.4 h1:1et3TBy61Uwf5N1ZbEBFhMqCjgxqfRXmz2w0Q1dujG0= github.com/origadmin/slog-kratos v1.0.4/go.mod h1:WUdhcWLyN0i8TbdemqE2Y/muoj0GaZ86OcdpumAWHPo= -github.com/origadmin/toolkits v0.3.1 h1:38fD+knmXgHG/iOtKqNKROd0csBE8Db6byWQeuyBz4I= -github.com/origadmin/toolkits v0.3.1/go.mod h1:h6oCaOxZ4vHQsHgZ7wzFVjFlwrpmRwo+Mfj8LA5zBxM= -github.com/origadmin/toolkits/codec v0.3.1 h1:/izgcW3HeCL4aeDgO0Dvaapow/6ED4OdFOnP1kBeoP8= -github.com/origadmin/toolkits/codec v0.3.1/go.mod h1:RlnoEXP8tD9FNRXqAk/u/BZ1skVNlukjJ3BqTVaP4AM= -github.com/origadmin/toolkits/crypto v0.3.1 h1:fw/jsuaq7fBVHvnHMau4tH7Pnrhp3Xvb6yWDHrFlN1k= -github.com/origadmin/toolkits/crypto v0.3.1/go.mod h1:4wKSiCDDyRHTqd+5tn1jd36IOuQ3cYycZkFLy/H2e7I= -github.com/origadmin/toolkits/errors v0.3.1 h1:Y1tdJYF8M1vTNIltgf1bCLI0XECGykK08XYo3uWIbgo= -github.com/origadmin/toolkits/errors v0.3.1/go.mod h1:kqVUSV6sz+wiUeesrBxZ3oyUPrNl0alF0+jO0qehBvM= -github.com/origadmin/toolkits/identifier v0.3.1 h1:JgRTIbSbsjbMwbKTGsaGf1FZr5S6UG2VLGwEzqBPaxc= -github.com/origadmin/toolkits/identifier v0.3.1/go.mod h1:M1IodkORni12hNmpFd5/9xrBHqjUkoDzBmPWyHGhIp8= -github.com/origadmin/toolkits/sloge v0.3.1 h1:XQ9ws90NHrE74S/xHXfHKoudxcyYNv+eJD9RIACT458= -github.com/origadmin/toolkits/sloge v0.3.1/go.mod h1:DEzQjJ+wo0KdDPrhos51gna/4yOPhhuSUZUDLcT6n68= +github.com/origadmin/toolkits v0.3.15 h1:Cr8nzoSFvAFkFG4FXhT+lSUgUzoOQT1//ao/3QXmxsc= +github.com/origadmin/toolkits v0.3.15/go.mod h1:l0H6drsQuWNiSDagDwI2jvLqxlNGtF1LI++fPrz5KAg= +github.com/origadmin/toolkits/codec v0.3.15 h1:aeFJbQgaRfHs4jkM06da9YB2J6vaUQKdiPy2dSY4kKY= +github.com/origadmin/toolkits/codec v0.3.15/go.mod h1:XqlOlTxdD3lLDPmC82cZEVoiD4/r4QA3umKKRVrgGu4= +github.com/origadmin/toolkits/crypto v0.3.15 h1:OHgIXLvB2jCvKH55YVdSyTjcOAwB05FmvCQLKn2BoMQ= +github.com/origadmin/toolkits/crypto v0.3.15/go.mod h1:ozRQi1rYHAIL/NSw0hJEWITEkZlSZ7wA9pCQKpqFv2s= +github.com/origadmin/toolkits/errors v0.3.15 h1:NxvwgsIh6Aqt4CasaFz2xQ+nDWEtdAbXqBsjvx/g96Y= +github.com/origadmin/toolkits/errors v0.3.15/go.mod h1:kqVUSV6sz+wiUeesrBxZ3oyUPrNl0alF0+jO0qehBvM= +github.com/origadmin/toolkits/identifier v0.3.15 h1:hl4xYINV3ywDGlqrVYCf/tePx7tjZZ8LWvqzlhzv3rA= +github.com/origadmin/toolkits/identifier v0.3.15/go.mod h1:M1IodkORni12hNmpFd5/9xrBHqjUkoDzBmPWyHGhIp8= +github.com/origadmin/toolkits/slogx v0.3.15 h1:96TOKqX/02m6+6LEJxS/GGf4jndsFS5A7Td3Mtcb/rc= +github.com/origadmin/toolkits/slogx v0.3.15/go.mod h1:6ODf/5T3M7XBc0aKHHkMgOLawkASDzaPCj99JzabYME= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= @@ -1885,12 +1881,12 @@ google.golang.org/genproto v0.0.0-20230525234025-438c736192d0/go.mod h1:9ExIQyXL google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54/go.mod h1:zqTuNwFlFRsw5zIts5VnzLQxSRqh+CGOTVMlYbY0Eyk= google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go.mod h1:ts19tUU+Z0ZShN1y3aPyq2+O3d5FUNNgT6FtOzmrNn8= google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e h1:UdXH7Kzbj+Vzastr5nVfccbmFsmYNygVLSPk1pEfDoY= -google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e/go.mod h1:085qFyf2+XaZlRdCgKNCIZ3afY2p4HHZdoIRpId8F4A= +google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34 h1:0PeQib/pH3nB/5pEmFeVQJotzGohV0dq4Vcp09H5yhE= +google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34/go.mod h1:0awUlEkap+Pb1UMeJwJQQAdJQrt3moU7J2moTy69irI= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e h1:ztQaXfzEXTmCBvbtWYRhJxW+0iJcz2qXfd38/e9l7bA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34 h1:h6p3mQqrmT1XkHVTfzLdNz1u7IhINeZkz67/xTbOuWs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1999,8 +1995,8 @@ modernc.org/ccgo/v3 v3.16.9/go.mod h1:zNMzC9A9xeNUepy6KuZBbugn3c0Mc9TeiJO4lgvkJD modernc.org/ccgo/v4 v4.26.0 h1:gVzXaDzGeBYJ2uXTOpR8FR7OlksDOe9jxnjhIKCsiTc= modernc.org/ccgo/v4 v4.26.0/go.mod h1:Sem8f7TFUtVXkG2fiaChQtyyfkqhJBg/zjEJBkmuAVY= modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= -modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE= -modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ= +modernc.org/fileutil v1.3.1 h1:8vq5fe7jdtEvoCf3Zf9Nm0Q05sH6kGx0Op2CPx1wTC8= +modernc.org/fileutil v1.3.1/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc= modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= @@ -2011,8 +2007,8 @@ modernc.org/libc v1.16.17/go.mod h1:hYIV5VZczAmGZAnG15Vdngn5HSF5cSkbvfz2B7GRuVU= modernc.org/libc v1.16.19/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA= modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0= modernc.org/libc v1.17.1/go.mod h1:FZ23b+8LjxZs7XtFMbSzL/EhPxNbfZbErxEHc7cbD9s= -modernc.org/libc v1.63.0 h1:wKzb61wOGCzgahQBORb1b0dZonh8Ufzl/7r4Yf1D5YA= -modernc.org/libc v1.63.0/go.mod h1:wDzH1mgz1wUIEwottFt++POjGRO9sgyQKrpXaz3x89E= +modernc.org/libc v1.64.0 h1:U0k8BD2d3cD3e9I8RLcZgJBHAcsJzbXx5mKGSb5pyJA= +modernc.org/libc v1.64.0/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= diff --git a/helpers/db/db.go b/helpers/db/db.go index 86ab8e3d..a60ecf4a 100644 --- a/helpers/db/db.go +++ b/helpers/db/db.go @@ -10,7 +10,7 @@ import ( "strings" "entgo.io/ent/dialect/sql" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" ) type QueryPager[T any] interface { diff --git a/helpers/securityx/auth.go b/helpers/securityx/auth.go index d95c07f1..101c71d7 100644 --- a/helpers/securityx/auth.go +++ b/helpers/securityx/auth.go @@ -7,7 +7,7 @@ package securityx import ( "github.com/goexts/generic/settings" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" ) type AuthenticatorSetting = func(tz *authSecurity) diff --git a/helpers/securityx/security.go b/helpers/securityx/security.go index 93a754c6..472cab23 100644 --- a/helpers/securityx/security.go +++ b/helpers/securityx/security.go @@ -14,7 +14,7 @@ import ( msecurity "github.com/origadmin/runtime/agent/middleware/security" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/middleware" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" "origadmin/application/admin/contrib/security/authn/jwt" "origadmin/application/admin/contrib/security/authz/casbin" diff --git a/internal/configs/auth_config.pb.go b/internal/configs/auth_config.pb.go index a2d3eddc..24222d0d 100644 --- a/internal/configs/auth_config.pb.go +++ b/internal/configs/auth_config.pb.go @@ -26,7 +26,7 @@ type AuthConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // configs.api.RootUser root_user = 1 [json_name = "root_user"]; + // origadmin.configs.api.RootUser root_user = 1 [json_name = "root_user"]; Captcha *Captcha `protobuf:"bytes,2,opt,name=captcha,proto3" json:"captcha,omitempty"` Security *v1.Security `protobuf:"bytes,3,opt,name=security,proto3" json:"security,omitempty"` } @@ -79,21 +79,23 @@ var File_configs_auth_config_proto protoreflect.FileDescriptor var file_configs_auth_config_proto_rawDesc = []byte{ 0x0a, 0x19, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x15, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x63, 0x61, 0x70, 0x74, - 0x63, 0x68, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6d, 0x0a, 0x0a, 0x41, 0x75, 0x74, - 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2e, 0x0a, 0x07, 0x63, 0x61, 0x70, 0x74, 0x63, - 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x52, 0x07, - 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x12, 0x2f, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, - 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, - 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, - 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, - 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x6f, 0x72, 0x69, + 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, + 0x70, 0x69, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, + 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0x77, 0x0a, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x38, 0x0a, 0x07, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, + 0x68, 0x61, 0x52, 0x07, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x12, 0x2f, 0x0a, 0x08, 0x73, + 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, + 0x74, 0x79, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x42, 0x2e, 0x5a, 0x2c, + 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -110,13 +112,13 @@ func file_configs_auth_config_proto_rawDescGZIP() []byte { var file_configs_auth_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_auth_config_proto_goTypes = []any{ - (*AuthConfig)(nil), // 0: configs.api.AuthConfig - (*Captcha)(nil), // 1: configs.api.Captcha + (*AuthConfig)(nil), // 0: origadmin.configs.api.AuthConfig + (*Captcha)(nil), // 1: origadmin.configs.api.Captcha (*v1.Security)(nil), // 2: config.v1.Security } var file_configs_auth_config_proto_depIdxs = []int32{ - 1, // 0: configs.api.AuthConfig.captcha:type_name -> configs.api.Captcha - 2, // 1: configs.api.AuthConfig.security:type_name -> config.v1.Security + 1, // 0: origadmin.configs.api.AuthConfig.captcha:type_name -> origadmin.configs.api.Captcha + 2, // 1: origadmin.configs.api.AuthConfig.security:type_name -> config.v1.Security 2, // [2:2] is the sub-list for method output_type 2, // [2:2] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name diff --git a/internal/configs/auth_config.proto b/internal/configs/auth_config.proto index 998d104b..e4cd7728 100644 --- a/internal/configs/auth_config.proto +++ b/internal/configs/auth_config.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package configs.api; +package origadmin.configs.api; import "config/v1/security.proto"; // 移除对root_user的引用(迁移至安全配置模块) @@ -9,8 +9,8 @@ import "configs/captcha.proto"; option go_package = "origadmin/application/admin/internal/configs"; message AuthConfig { - // configs.api.RootUser root_user = 1 [json_name = "root_user"]; - configs.api.Captcha captcha = 2 [json_name = "captcha"]; + // origadmin.configs.api.RootUser root_user = 1 [json_name = "root_user"]; + origadmin.configs.api.Captcha captcha = 2 [json_name = "captcha"]; config.v1.Security security = 3 [json_name = "security"]; } diff --git a/internal/configs/bootstrap.pb.go b/internal/configs/bootstrap.pb.go index 05721df5..ecb74df4 100644 --- a/internal/configs/bootstrap.pb.go +++ b/internal/configs/bootstrap.pb.go @@ -410,9 +410,8 @@ type Bootstrap_Entry struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Scheme string `protobuf:"bytes,1,opt,name=scheme,proto3" json:"scheme,omitempty"` - Grpc *v1.Service_GRPC `protobuf:"bytes,10,opt,name=grpc,proto3" json:"grpc,omitempty"` - Http *v1.Service_HTTP `protobuf:"bytes,20,opt,name=http,proto3" json:"http,omitempty"` // config.v1.Service.GINS gins = 30 [json_name = "gins"]; + Scheme string `protobuf:"bytes,1,opt,name=scheme,proto3" json:"scheme,omitempty"` + Server *v1.Service `protobuf:"bytes,2,opt,name=server,proto3" json:"server,omitempty"` } func (x *Bootstrap_Entry) Reset() { @@ -452,16 +451,9 @@ func (x *Bootstrap_Entry) GetScheme() string { return "" } -func (x *Bootstrap_Entry) GetGrpc() *v1.Service_GRPC { +func (x *Bootstrap_Entry) GetServer() *v1.Service { if x != nil { - return x.Grpc - } - return nil -} - -func (x *Bootstrap_Entry) GetHttp() *v1.Service_HTTP { - if x != nil { - return x.Http + return x.Server } return nil } @@ -470,95 +462,95 @@ var File_configs_bootstrap_proto protoreflect.FileDescriptor var file_configs_bootstrap_proto_rawDesc = []byte{ 0x0a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, - 0x72, 0x61, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, - 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x63, 0x75, - 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, - 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, - 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x73, 0x65, - 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5b, 0x0a, - 0x13, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x2c, 0x0a, 0x0d, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1b, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, - 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xce, 0x07, 0x0a, 0x09, 0x42, 0x6f, 0x6f, - 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x72, 0x61, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x6f, 0x72, 0x69, 0x67, 0x61, + 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, + 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, + 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, + 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5b, 0x0a, 0x13, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, + 0x0a, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, + 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, - 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2d, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, 0xfa, 0x42, 0x16, 0x72, 0x14, 0x52, 0x09, 0x73, 0x69, 0x6e, - 0x67, 0x6c, 0x65, 0x74, 0x6f, 0x6e, 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, - 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x34, 0x0a, 0x15, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, - 0x64, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x79, 0x6e, - 0x61, 0x6d, 0x69, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x64, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x32, 0x0a, 0x0b, 0x65, - 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x66, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x10, 0xfa, 0x42, 0x0d, 0x72, 0x0b, 0x52, 0x03, 0x64, 0x65, 0x76, 0x52, 0x04, 0x70, 0x72, - 0x6f, 0x64, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x12, - 0x32, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x67, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, - 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x6f, 0x6f, - 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x65, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x36, 0x0a, 0x0c, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x67, 0x61, 0x74, 0x65, - 0x77, 0x61, 0x79, 0x18, 0x68, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x0c, 0x68, - 0x74, 0x74, 0x70, 0x5f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, 0x37, 0x0a, 0x08, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0xc8, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, - 0xac, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, - 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, - 0x90, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x76, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x39, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, - 0x61, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x69, 0x64, 0x64, - 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, - 0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, - 0x12, 0x29, 0x0a, 0x05, 0x61, 0x75, 0x74, 0x68, 0x6e, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x12, 0x2e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x41, - 0x75, 0x74, 0x68, 0x4e, 0x52, 0x05, 0x61, 0x75, 0x74, 0x68, 0x6e, 0x12, 0x29, 0x0a, 0x05, 0x61, - 0x75, 0x74, 0x68, 0x7a, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, - 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x5a, 0x52, - 0x05, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x12, 0x30, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, - 0x74, 0x79, 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, - 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x47, 0x0a, 0x0c, 0x68, 0x65, 0x61, 0x6c, - 0x74, 0x68, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x18, 0xeb, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x22, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x6f, - 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, - 0x65, 0x63, 0x6b, 0x52, 0x0c, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x5f, 0x63, 0x68, 0x65, 0x63, - 0x6b, 0x1a, 0x3b, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, - 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x1a, 0x79, - 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, - 0x2b, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x2c, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x22, 0xbe, 0x07, 0x0a, 0x09, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, + 0x0a, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x2d, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, + 0xfa, 0x42, 0x16, 0x72, 0x14, 0x52, 0x09, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x74, 0x6f, 0x6e, + 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, + 0x34, 0x0a, 0x15, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x79, 0x6e, 0x61, 0x6d, 0x69, + 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x5f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x64, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x32, 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, + 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x66, 0x20, 0x01, 0x28, 0x09, 0x42, 0x10, 0xfa, 0x42, 0x0d, 0x72, + 0x0b, 0x52, 0x03, 0x64, 0x65, 0x76, 0x52, 0x04, 0x70, 0x72, 0x6f, 0x64, 0x52, 0x0b, 0x65, 0x6e, + 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x3c, 0x0a, 0x05, 0x65, 0x6e, 0x74, + 0x72, 0x79, 0x18, 0x67, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6f, 0x72, 0x69, 0x67, 0x61, + 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x36, 0x0a, 0x0c, 0x68, 0x74, 0x74, 0x70, 0x5f, + 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x18, 0x68, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x12, 0x2b, 0x0a, 0x04, - 0x68, 0x74, 0x74, 0x70, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x48, - 0x54, 0x54, 0x50, 0x52, 0x04, 0x68, 0x74, 0x74, 0x70, 0x22, 0x2c, 0x0a, 0x08, 0x53, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, - 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x52, 0x0c, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, + 0x41, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0xc8, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0xac, 0x02, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, + 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x12, 0x30, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x90, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, + 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x72, 0x79, 0x12, 0x39, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, + 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, + 0x77, 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, + 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x12, 0x29, + 0x0a, 0x05, 0x61, 0x75, 0x74, 0x68, 0x6e, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, + 0x68, 0x4e, 0x52, 0x05, 0x61, 0x75, 0x74, 0x68, 0x6e, 0x12, 0x29, 0x0a, 0x05, 0x61, 0x75, 0x74, + 0x68, 0x7a, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, 0x63, 0x75, + 0x72, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x5a, 0x52, 0x05, 0x61, + 0x75, 0x74, 0x68, 0x7a, 0x12, 0x30, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, + 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, 0x73, 0x65, + 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x51, 0x0a, 0x0c, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, + 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x18, 0xeb, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, + 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, + 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x0c, 0x68, 0x65, 0x61, + 0x6c, 0x74, 0x68, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x1a, 0x3b, 0x0a, 0x0b, 0x48, 0x65, 0x61, + 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, + 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x1a, 0x4b, 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x06, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x22, 0x2c, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, + 0x20, 0x0a, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, + 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, + 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -575,12 +567,12 @@ func file_configs_bootstrap_proto_rawDescGZIP() []byte { var file_configs_bootstrap_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_configs_bootstrap_proto_goTypes = []any{ - (*EntrySelectorConfig)(nil), // 0: configs.api.EntrySelectorConfig - (*ServiceConfig)(nil), // 1: configs.api.ServiceConfig - (*Bootstrap)(nil), // 2: configs.api.Bootstrap - (*Settings)(nil), // 3: configs.api.Settings - (*Bootstrap_HealthCheck)(nil), // 4: configs.api.Bootstrap.HealthCheck - (*Bootstrap_Entry)(nil), // 5: configs.api.Bootstrap.Entry + (*EntrySelectorConfig)(nil), // 0: origadmin.configs.api.EntrySelectorConfig + (*ServiceConfig)(nil), // 1: origadmin.configs.api.ServiceConfig + (*Bootstrap)(nil), // 2: origadmin.configs.api.Bootstrap + (*Settings)(nil), // 3: origadmin.configs.api.Settings + (*Bootstrap_HealthCheck)(nil), // 4: origadmin.configs.api.Bootstrap.HealthCheck + (*Bootstrap_Entry)(nil), // 5: origadmin.configs.api.Bootstrap.Entry (*v1.Service)(nil), // 6: config.v1.Service (*v1.Storage)(nil), // 7: config.v1.Storage (*v1.Registry)(nil), // 8: config.v1.Registry @@ -588,27 +580,24 @@ var file_configs_bootstrap_proto_goTypes = []any{ (*v12.AuthN)(nil), // 10: security.v1.AuthN (*v12.AuthZ)(nil), // 11: security.v1.AuthZ (*v1.Security)(nil), // 12: config.v1.Security - (*v1.Service_GRPC)(nil), // 13: config.v1.Service.GRPC - (*v1.Service_HTTP)(nil), // 14: config.v1.Service.HTTP } var file_configs_bootstrap_proto_depIdxs = []int32{ - 5, // 0: configs.api.Bootstrap.entry:type_name -> configs.api.Bootstrap.Entry - 6, // 1: configs.api.Bootstrap.http_gateway:type_name -> config.v1.Service - 1, // 2: configs.api.Bootstrap.services:type_name -> configs.api.ServiceConfig - 7, // 3: configs.api.Bootstrap.storage:type_name -> config.v1.Storage - 8, // 4: configs.api.Bootstrap.registry:type_name -> config.v1.Registry - 9, // 5: configs.api.Bootstrap.middleware:type_name -> middleware.v1.Middleware - 10, // 6: configs.api.Bootstrap.authn:type_name -> security.v1.AuthN - 11, // 7: configs.api.Bootstrap.authz:type_name -> security.v1.AuthZ - 12, // 8: configs.api.Bootstrap.security:type_name -> config.v1.Security - 4, // 9: configs.api.Bootstrap.health_check:type_name -> configs.api.Bootstrap.HealthCheck - 13, // 10: configs.api.Bootstrap.Entry.grpc:type_name -> config.v1.Service.GRPC - 14, // 11: configs.api.Bootstrap.Entry.http:type_name -> config.v1.Service.HTTP - 12, // [12:12] is the sub-list for method output_type - 12, // [12:12] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 5, // 0: origadmin.configs.api.Bootstrap.entry:type_name -> origadmin.configs.api.Bootstrap.Entry + 6, // 1: origadmin.configs.api.Bootstrap.http_gateway:type_name -> config.v1.Service + 1, // 2: origadmin.configs.api.Bootstrap.services:type_name -> origadmin.configs.api.ServiceConfig + 7, // 3: origadmin.configs.api.Bootstrap.storage:type_name -> config.v1.Storage + 8, // 4: origadmin.configs.api.Bootstrap.registry:type_name -> config.v1.Registry + 9, // 5: origadmin.configs.api.Bootstrap.middleware:type_name -> middleware.v1.Middleware + 10, // 6: origadmin.configs.api.Bootstrap.authn:type_name -> security.v1.AuthN + 11, // 7: origadmin.configs.api.Bootstrap.authz:type_name -> security.v1.AuthZ + 12, // 8: origadmin.configs.api.Bootstrap.security:type_name -> config.v1.Security + 4, // 9: origadmin.configs.api.Bootstrap.health_check:type_name -> origadmin.configs.api.Bootstrap.HealthCheck + 6, // 10: origadmin.configs.api.Bootstrap.Entry.server:type_name -> config.v1.Service + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_configs_bootstrap_proto_init() } diff --git a/internal/configs/bootstrap.pb.validate.go b/internal/configs/bootstrap.pb.validate.go index 70125811..16f98f07 100644 --- a/internal/configs/bootstrap.pb.validate.go +++ b/internal/configs/bootstrap.pb.validate.go @@ -922,11 +922,11 @@ func (m *Bootstrap_Entry) validate(all bool) error { // no validation rules for Scheme if all { - switch v := interface{}(m.GetGrpc()).(type) { + switch v := interface{}(m.GetServer()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, Bootstrap_EntryValidationError{ - field: "Grpc", + field: "Server", reason: "embedded message failed validation", cause: err, }) @@ -934,45 +934,16 @@ func (m *Bootstrap_Entry) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, Bootstrap_EntryValidationError{ - field: "Grpc", + field: "Server", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetGrpc()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetServer()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return Bootstrap_EntryValidationError{ - field: "Grpc", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetHttp()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, Bootstrap_EntryValidationError{ - field: "Http", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, Bootstrap_EntryValidationError{ - field: "Http", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetHttp()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return Bootstrap_EntryValidationError{ - field: "Http", + field: "Server", reason: "embedded message failed validation", cause: err, } diff --git a/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto index 3200f20f..fc275229 100644 --- a/internal/configs/bootstrap.proto +++ b/internal/configs/bootstrap.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package configs.api; +package origadmin.configs.api; import "config/v1/registry.proto"; import "config/v1/security.proto"; @@ -52,9 +52,7 @@ message Bootstrap { // Entry message Entry { string scheme = 1 [json_name = "scheme"]; - config.v1.Service.GRPC grpc = 10 [json_name = "grpc"]; - config.v1.Service.HTTP http = 20 [json_name = "http"]; - // config.v1.Service.GINS gins = 30 [json_name = "gins"]; + config.v1.Service server = 2 [json_name = "server"]; } string id = 100 [json_name = "id"]; diff --git a/internal/configs/captcha.pb.go b/internal/configs/captcha.pb.go index bfe662ce..8b1ace74 100644 --- a/internal/configs/captcha.pb.go +++ b/internal/configs/captcha.pb.go @@ -102,23 +102,24 @@ var File_configs_captcha_proto protoreflect.FileDescriptor var file_configs_captcha_proto_rawDesc = []byte{ 0x0a, 0x15, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, - 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, - 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, - 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa1, 0x01, - 0x0a, 0x07, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, - 0x67, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, - 0x68, 0x12, 0x14, 0x0a, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, - 0x22, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, - 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, - 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, - 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, + 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa1, 0x01, 0x0a, 0x07, 0x43, 0x61, 0x70, 0x74, + 0x63, 0x68, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x77, + 0x69, 0x64, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, + 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x74, 0x6f, + 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, + 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, + 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, + 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -135,11 +136,11 @@ func file_configs_captcha_proto_rawDescGZIP() []byte { var file_configs_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_captcha_proto_goTypes = []any{ - (*Captcha)(nil), // 0: configs.api.Captcha + (*Captcha)(nil), // 0: origadmin.configs.api.Captcha (*v1.Storage)(nil), // 1: config.v1.Storage } var file_configs_captcha_proto_depIdxs = []int32{ - 1, // 0: configs.api.Captcha.storage:type_name -> config.v1.Storage + 1, // 0: origadmin.configs.api.Captcha.storage:type_name -> config.v1.Storage 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name diff --git a/internal/configs/captcha.proto b/internal/configs/captcha.proto index 784e0d39..c8d8411b 100644 --- a/internal/configs/captcha.proto +++ b/internal/configs/captcha.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package configs.api; +package origadmin.configs.api; import "config/v1/storage.proto"; diff --git a/internal/configs/root_user.pb.go b/internal/configs/root_user.pb.go index 0421877b..07ec0d69 100644 --- a/internal/configs/root_user.pb.go +++ b/internal/configs/root_user.pb.go @@ -166,38 +166,38 @@ var File_configs_root_user_proto protoreflect.FileDescriptor var file_configs_root_user_proto_rawDesc = []byte{ 0x0a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x75, - 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x63, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x8c, 0x03, 0x0a, 0x08, 0x52, 0x6f, 0x6f, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, - 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, - 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x23, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x10, 0x06, 0x18, - 0x20, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1d, 0x0a, 0x04, 0x73, - 0x61, 0x6c, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, - 0x10, 0x06, 0x18, 0x0c, 0x52, 0x04, 0x73, 0x61, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, - 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x6f, 0x62, 0x69, - 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, - 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, - 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x18, 0x64, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x5f, 0x70, - 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x65, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x72, - 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x2e, - 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x6f, 0x72, 0x69, 0x67, 0x61, + 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, + 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x03, 0x0a, 0x08, 0x52, 0x6f, + 0x6f, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, + 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, + 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x23, 0x0a, 0x08, 0x75, 0x73, 0x65, + 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, + 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, + 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x10, 0x06, 0x18, 0x20, 0x52, 0x08, 0x70, 0x61, 0x73, + 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1d, 0x0a, 0x04, 0x73, 0x61, 0x6c, 0x74, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x10, 0x06, 0x18, 0x0c, 0x52, 0x04, + 0x73, 0x61, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, + 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, + 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, + 0x61, 0x74, 0x61, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, + 0x61, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, + 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, + 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x64, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x0b, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x28, + 0x0a, 0x0f, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, + 0x64, 0x18, 0x65, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x5f, + 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, + 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -214,7 +214,7 @@ func file_configs_root_user_proto_rawDescGZIP() []byte { var file_configs_root_user_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_root_user_proto_goTypes = []any{ - (*RootUser)(nil), // 0: configs.api.RootUser + (*RootUser)(nil), // 0: origadmin.configs.api.RootUser } var file_configs_root_user_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type diff --git a/internal/configs/root_user.proto b/internal/configs/root_user.proto index dbf22636..97562fab 100644 --- a/internal/configs/root_user.proto +++ b/internal/configs/root_user.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package configs.api; +package origadmin.configs.api; import "validate/validate.proto"; diff --git a/internal/configs/server.pb.go b/internal/configs/server.pb.go index 1b434d67..74cb00f8 100644 --- a/internal/configs/server.pb.go +++ b/internal/configs/server.pb.go @@ -111,35 +111,35 @@ var File_configs_server_proto protoreflect.FileDescriptor var file_configs_server_proto_rawDesc = []byte{ 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, - 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, 0x64, 0x64, 0x6c, - 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, - 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x81, 0x02, 0x0a, 0x06, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0xc8, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, - 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0xac, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, - 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x12, 0x30, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x90, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, - 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x12, 0x39, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, - 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, - 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x42, 0x2e, 0x5a, - 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1f, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, + 0x6e, 0x2e, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, + 0x76, 0x31, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, + 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0x81, 0x02, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x07, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, + 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x73, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0xac, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x90, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x39, 0x0a, 0x0a, + 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x19, 0x2e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, + 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, + 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, + 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -156,17 +156,17 @@ func file_configs_server_proto_rawDescGZIP() []byte { var file_configs_server_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_server_proto_goTypes = []any{ - (*Server)(nil), // 0: origadmin.configs.api.Server + (*Server)(nil), // 0: origadmin.origadmin.configs.api.Server (*v1.Service)(nil), // 1: config.v1.Service (*v1.Storage)(nil), // 2: config.v1.Storage (*v1.Registry)(nil), // 3: config.v1.Registry (*v11.Middleware)(nil), // 4: middleware.v1.Middleware } var file_configs_server_proto_depIdxs = []int32{ - 1, // 0: origadmin.configs.api.Server.service:type_name -> config.v1.Service - 2, // 1: origadmin.configs.api.Server.storage:type_name -> config.v1.Storage - 3, // 2: origadmin.configs.api.Server.registry:type_name -> config.v1.Registry - 4, // 3: origadmin.configs.api.Server.middleware:type_name -> middleware.v1.Middleware + 1, // 0: origadmin.origadmin.configs.api.Server.service:type_name -> config.v1.Service + 2, // 1: origadmin.origadmin.configs.api.Server.storage:type_name -> config.v1.Storage + 3, // 2: origadmin.origadmin.configs.api.Server.registry:type_name -> config.v1.Registry + 4, // 3: origadmin.origadmin.configs.api.Server.middleware:type_name -> middleware.v1.Middleware 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name diff --git a/internal/configs/server.proto b/internal/configs/server.proto index 80ccb249..09dd14d8 100644 --- a/internal/configs/server.proto +++ b/internal/configs/server.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package origadmin.configs.api; +package origadmin.origadmin.configs.api; import "config/v1/storage.proto"; import "config/v1/registry.proto"; diff --git a/internal/configs/services/service.pb.go b/internal/configs/services/service.pb.go new file mode 100644 index 00000000..0f63913e --- /dev/null +++ b/internal/configs/services/service.pb.go @@ -0,0 +1,254 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.35.1 +// protoc v5.28.3 +// source: configs/services/service.proto + +package services + +import ( + v1 "github.com/origadmin/runtime/gen/go/config/v1" + v11 "github.com/origadmin/runtime/gen/go/middleware/v1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ServiceCore struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` + Registry *v1.Registry `protobuf:"bytes,3,opt,name=registry,proto3" json:"registry,omitempty"` + Storages []*v1.Storage `protobuf:"bytes,4,rep,name=storages,proto3" json:"storages,omitempty"` +} + +func (x *ServiceCore) Reset() { + *x = ServiceCore{} + mi := &file_configs_services_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServiceCore) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServiceCore) ProtoMessage() {} + +func (x *ServiceCore) ProtoReflect() protoreflect.Message { + mi := &file_configs_services_service_proto_msgTypes[0] + 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 ServiceCore.ProtoReflect.Descriptor instead. +func (*ServiceCore) Descriptor() ([]byte, []int) { + return file_configs_services_service_proto_rawDescGZIP(), []int{0} +} + +func (x *ServiceCore) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ServiceCore) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *ServiceCore) GetRegistry() *v1.Registry { + if x != nil { + return x.Registry + } + return nil +} + +func (x *ServiceCore) GetStorages() []*v1.Storage { + if x != nil { + return x.Storages + } + return nil +} + +type Service struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` + Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` + Middleware *v11.Middleware `protobuf:"bytes,300,opt,name=middleware,proto3" json:"middleware,omitempty"` +} + +func (x *Service) Reset() { + *x = Service{} + mi := &file_configs_services_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Service) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Service) ProtoMessage() {} + +func (x *Service) ProtoReflect() protoreflect.Message { + mi := &file_configs_services_service_proto_msgTypes[1] + 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 Service.ProtoReflect.Descriptor instead. +func (*Service) Descriptor() ([]byte, []int) { + return file_configs_services_service_proto_rawDescGZIP(), []int{1} +} + +func (x *Service) GetCore() *ServiceCore { + if x != nil { + return x.Core + } + return nil +} + +func (x *Service) GetService() *v1.Service { + if x != nil { + return x.Service + } + return nil +} + +func (x *Service) GetMiddleware() *v11.Middleware { + if x != nil { + return x.Middleware + } + return nil +} + +var File_configs_services_service_proto protoreflect.FileDescriptor + +var file_configs_services_service_proto_rawDesc = []byte{ + 0x0a, 0x1e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x1e, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x70, 0x69, + 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, + 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, + 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9c, 0x01, 0x0a, + 0x0b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x0a, 0x08, 0x72, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, + 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x2e, 0x0a, 0x08, 0x73, + 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, + 0x65, 0x52, 0x08, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x73, 0x22, 0xb5, 0x01, 0x0a, 0x07, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3f, 0x0a, 0x04, 0x63, 0x6f, 0x72, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, + 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, + 0x72, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, + 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3a, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, + 0x65, 0x77, 0x61, 0x72, 0x65, 0x18, 0xac, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, + 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x64, + 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, + 0x61, 0x72, 0x65, 0x42, 0x37, 0x5a, 0x35, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, + 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, + 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_configs_services_service_proto_rawDescOnce sync.Once + file_configs_services_service_proto_rawDescData = file_configs_services_service_proto_rawDesc +) + +func file_configs_services_service_proto_rawDescGZIP() []byte { + file_configs_services_service_proto_rawDescOnce.Do(func() { + file_configs_services_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_configs_services_service_proto_rawDescData) + }) + return file_configs_services_service_proto_rawDescData +} + +var file_configs_services_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_configs_services_service_proto_goTypes = []any{ + (*ServiceCore)(nil), // 0: origadmin.configs.services.api.ServiceCore + (*Service)(nil), // 1: origadmin.configs.services.api.Service + (*v1.Registry)(nil), // 2: config.v1.Registry + (*v1.Storage)(nil), // 3: config.v1.Storage + (*v1.Service)(nil), // 4: config.v1.Service + (*v11.Middleware)(nil), // 5: middleware.v1.Middleware +} +var file_configs_services_service_proto_depIdxs = []int32{ + 2, // 0: origadmin.configs.services.api.ServiceCore.registry:type_name -> config.v1.Registry + 3, // 1: origadmin.configs.services.api.ServiceCore.storages:type_name -> config.v1.Storage + 0, // 2: origadmin.configs.services.api.Service.core:type_name -> origadmin.configs.services.api.ServiceCore + 4, // 3: origadmin.configs.services.api.Service.service:type_name -> config.v1.Service + 5, // 4: origadmin.configs.services.api.Service.middleware:type_name -> middleware.v1.Middleware + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_configs_services_service_proto_init() } +func file_configs_services_service_proto_init() { + if File_configs_services_service_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_configs_services_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_configs_services_service_proto_goTypes, + DependencyIndexes: file_configs_services_service_proto_depIdxs, + MessageInfos: file_configs_services_service_proto_msgTypes, + }.Build() + File_configs_services_service_proto = out.File + file_configs_services_service_proto_rawDesc = nil + file_configs_services_service_proto_goTypes = nil + file_configs_services_service_proto_depIdxs = nil +} diff --git a/internal/configs/services/service.pb.validate.go b/internal/configs/services/service.pb.validate.go new file mode 100644 index 00000000..c5a9267c --- /dev/null +++ b/internal/configs/services/service.pb.validate.go @@ -0,0 +1,387 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: configs/services/service.proto + +package services + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ServiceCore 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 *ServiceCore) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ServiceCore 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 ServiceCoreMultiError, or +// nil if none found. +func (m *ServiceCore) ValidateAll() error { + return m.validate(true) +} + +func (m *ServiceCore) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Name + + // no validation rules for Version + + if all { + switch v := interface{}(m.GetRegistry()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ServiceCoreValidationError{ + field: "Registry", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ServiceCoreValidationError{ + field: "Registry", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRegistry()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ServiceCoreValidationError{ + field: "Registry", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetStorages() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ServiceCoreValidationError{ + field: fmt.Sprintf("Storages[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ServiceCoreValidationError{ + field: fmt.Sprintf("Storages[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ServiceCoreValidationError{ + field: fmt.Sprintf("Storages[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ServiceCoreMultiError(errors) + } + + return nil +} + +// ServiceCoreMultiError is an error wrapping multiple validation errors +// returned by ServiceCore.ValidateAll() if the designated constraints aren't met. +type ServiceCoreMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ServiceCoreMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ServiceCoreMultiError) AllErrors() []error { return m } + +// ServiceCoreValidationError is the validation error returned by +// ServiceCore.Validate if the designated constraints aren't met. +type ServiceCoreValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ServiceCoreValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ServiceCoreValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ServiceCoreValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ServiceCoreValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ServiceCoreValidationError) ErrorName() string { return "ServiceCoreValidationError" } + +// Error satisfies the builtin error interface +func (e ServiceCoreValidationError) 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 %sServiceCore.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ServiceCoreValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ServiceCoreValidationError{} + +// Validate checks the field values on Service 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 *Service) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Service 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 ServiceMultiError, or nil if none found. +func (m *Service) ValidateAll() error { + return m.validate(true) +} + +func (m *Service) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetCore()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ServiceValidationError{ + field: "Core", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ServiceValidationError{ + field: "Core", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCore()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ServiceValidationError{ + field: "Core", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetService()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ServiceValidationError{ + field: "Service", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ServiceValidationError{ + field: "Service", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetService()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ServiceValidationError{ + field: "Service", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetMiddleware()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ServiceValidationError{ + field: "Middleware", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ServiceValidationError{ + field: "Middleware", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMiddleware()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ServiceValidationError{ + field: "Middleware", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ServiceMultiError(errors) + } + + return nil +} + +// ServiceMultiError is an error wrapping multiple validation errors returned +// by Service.ValidateAll() if the designated constraints aren't met. +type ServiceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ServiceMultiError) Error() string { + var msgs []string + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m ServiceMultiError) AllErrors() []error { return m } + +// ServiceValidationError is the validation error returned by Service.Validate +// if the designated constraints aren't met. +type ServiceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ServiceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ServiceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ServiceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ServiceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ServiceValidationError) ErrorName() string { return "ServiceValidationError" } + +// Error satisfies the builtin error interface +func (e ServiceValidationError) 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 %sService.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ServiceValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ServiceValidationError{} diff --git a/internal/configs/services/service.proto b/internal/configs/services/service.proto index ba8e6da7..6af2385f 100644 --- a/internal/configs/services/service.proto +++ b/internal/configs/services/service.proto @@ -1,12 +1,12 @@ syntax = "proto3"; -package origadmin.configs.api; +package origadmin.configs.services.api; import "config/v1/registry.proto"; import "config/v1/service.proto"; import "config/v1/storage.proto"; import "middleware/v1/middleware.proto"; -option go_package = "origadmin/application/admin/internal/configs"; +option go_package = "origadmin/application/admin/internal/configs/services"; message ServiceCore { string name = 1 [json_name = "name"]; @@ -19,5 +19,5 @@ message ServiceCore { message Service { ServiceCore core = 1 [json_name = "core"]; config.v1.Service service = 200 [json_name = "service"]; - middleware.v1.RateLimit rate_limit = 4 [json_name = "rate_limit"]; -} \ No newline at end of file + middleware.v1.Middleware middleware = 300 [json_name = "middleware"]; +} diff --git a/internal/generate.go b/internal/generate.go index 6487238b..1c9c5b35 100644 --- a/internal/generate.go +++ b/internal/generate.go @@ -13,3 +13,5 @@ package internal // uncomment this line to generate the client code to the same directory //go:generate protoc -I. -I../third_party --go_out=paths=source_relative:../internal ./configs/*.proto //go:generate protoc -I. -I../third_party --validate_out=paths=source_relative,lang=go:../internal ./configs/*.proto +//go:generate protoc -I. -I../third_party --go_out=paths=source_relative:../internal ./configs/services/*.proto +//go:generate protoc -I. -I../third_party --validate_out=paths=source_relative,lang=go:../internal ./configs/services/*.proto diff --git a/internal/loader/application.go b/internal/loader/application.go new file mode 100644 index 00000000..bc0509ac --- /dev/null +++ b/internal/loader/application.go @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package loader implements the functions, types, and interfaces for the module. +package loader + +import ( + "context" + "syscall" + + "github.com/gin-gonic/gin" + "github.com/go-kratos/kratos/v2" +) + +func NewApp(ctx context.Context, injector *InjectorClient) *kratos.App { + opts := []kratos.Option{ + kratos.ID(flags.ServiceID()), + kratos.Name(flags.ServiceName()), + kratos.Version(flags.Version()), + kratos.Metadata(map[string]string{}), + kratos.Context(ctx), + kratos.Signal(syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT), + kratos.Logger(injector.Logger), + kratos.Server(injector.Server), + } + + if flags.Env() == "release" { + gin.SetMode(gin.ReleaseMode) + } + + gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) { + log.Infow("msg", "GIN route", "method", httpMethod, "path", absolutePath, "operation", handlerName, "handlers", nuHandlers) + } + + return kratos.New(opts...) +} diff --git a/internal/loader/bootstrap.go b/internal/loader/bootstrap.go index eee46aeb..93225e9d 100644 --- a/internal/loader/bootstrap.go +++ b/internal/loader/bootstrap.go @@ -6,165 +6,42 @@ package loader import ( - "fmt" - "os" - "path/filepath" - "strings" - - "github.com/goexts/generic/settings" - "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" configv1 "github.com/origadmin/runtime/gen/go/config/v1" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/codec" - "github.com/origadmin/toolkits/errors" - - "origadmin/application/admin/internal/configs" + "github.com/origadmin/runtime/registry" ) -// decodeFile loads the config file from the given path -func decodeFile(path string, cfg any) error { - // skip stupid temp file - if strings.HasSuffix(path, "~") || strings.HasSuffix(path, ".bak") || strings.HasSuffix(path, ".tmp") || strings.HasSuffix(path, ".lock") { - return nil - } - // Decode the file into the config struct - if err := codec.DecodeFromFile(path, cfg); err != nil { - return errors.Wrapf(err, "failed to parse config file %s", path) - } - return nil -} - -// decodeDir loads the config file from the given directory -func decodeDir(path string, cfg any) error { - found := false - // Walk through the directory and load each file - err := filepath.WalkDir(path, func(walkpath string, d os.DirEntry, err error) error { - if err != nil { - return errors.Wrapf(err, "failed to get config file %s", walkpath) - } - // Check if the path is a directory - if d.IsDir() { - return nil - } - - // Decode the file into the config struct - if err := decodeFile(walkpath, cfg); err != nil { - return err - } - found = true - return nil +// LoadRemoteBootstrap 从 Consul KV 获取配置 +func LoadRemoteBootstrap(cfg *bootstrap.SourceConfig) (*configs.Bootstrap, error) { + // 创建 Consul 发现客户端(同时作为 KV 客户端) + discover, err := registry.NewConsulDiscover(®istry.ConsulConfig{ + Address: os.Getenv("CONSUL_ADDR"), + Timeout: 5 * time.Second, }) if err != nil { - return errors.Wrap(err, "load config error") - } - if !found { - return errors.New("no config file found in " + path) - } - return nil -} - -// LoadFileBootstrap load config from file -func LoadFileBootstrap(path string) (*configs.Bootstrap, error) { - typo := codec.TypeFromPath(path) - if typo == codec.UNKNOWN { - return nil, fmt.Errorf("unknown file type: %s", path) - } - - cfg := DefaultBootstrap() - err := decodeFile(path, cfg) - if err != nil { - return nil, err - } - return cfg, nil -} - -func LoadLocalBootstrap(source *configv1.SourceConfig) (*configs.Bootstrap, error) { - if source.File == nil { - return nil, errors.String("file config is nil") - } - path := WorkPath("", source.File.Path) - log.Infof("loading config from %s", path) - stat, err := os.Stat(path) - if err != nil { - return nil, errors.Wrapf(err, "failed to state file %s", path) - } - var bs configs.Bootstrap - if stat.IsDir() { - err := decodeDir(path, &bs) - if err != nil { - return nil, err - } - return &bs, nil - } - return LoadFileBootstrap(path) -} - -// LoadRemoteBootstrap load config from source -func LoadRemoteBootstrap(source *configv1.SourceConfig) (*configs.Bootstrap, error) { - config, err := runtime.NewConfig(source) - if err != nil { - return nil, err - } - if err := config.Load(); err != nil { return nil, err } - cfg := DefaultBootstrap() - if err := config.Scan(cfg); err != nil { - return nil, err - } - return cfg, nil -} -// LoadBootstrap load config from file -func LoadBootstrap(flags *Bootstrap) (*configs.Bootstrap, error) { - fmt.Println("load config from: ", flags.WorkPath()) - sourceConfig, err := bootstrap.LoadSourceConfig(flags) + // 使用 ConfigManager 从 KV 获取配置 + configMgr := NewConfigManager(discover) + kvData, err := configMgr.GetConfig("config/" + cfg.Name) if err != nil { - return nil, err - } - if len(sourceConfig.EnvPrefixes) > 0 { - SetupEnv(sourceConfig.EnvArgs, sourceConfig.EnvPrefixes[0]) + return nil, fmt.Errorf("failed to get KV config: %w", err) } - log.Infof("load source config: %+v", sourceConfig) - var bs *configs.Bootstrap - switch sourceConfig.GetType() { - case "file": - bs, err = LoadLocalBootstrap(sourceConfig) - default: - bs, err = LoadRemoteBootstrap(sourceConfig) - } - if err != nil { + // 解析配置数据(示例实现) + var bs configs.Bootstrap + if err := parseConfigData(kvData, &bs); err != nil { return nil, err } - if err := ReplaceObject(bs, sourceConfig.EnvArgs); err != nil { - return nil, err - } - log.Infof("load config: %+v\n", bs) - return bs, nil + return &bs, nil } -// LoadRemoteServiceBootstrap get the configuration from the remote Configuration Center -func LoadRemoteServiceBootstrap(flags *Bootstrap, name string, ss ...ConfigSetting) (*configs.Bootstrap, error) { - var cfg configs.Bootstrap - sourceConfig, err := bootstrap.LoadSourceConfig(flags) - if err != nil { - return nil, err - } - - sourceConfig.Name = name - sourceConfig = settings.Apply(sourceConfig, ss) - config, err := runtime.NewConfig(sourceConfig) - if err != nil { - return nil, err - } - if err := config.Load(); err != nil { - return nil, err - } - if err := config.Scan(&cfg); err != nil { - return nil, err - } - return &cfg, nil +// parseConfigData 实现配置数据解析逻辑 +func parseConfigData(data []byte, out *configs.Bootstrap) error { + // 根据实际格式实现解析(如 JSON/TOML) + // 示例:json.Unmarshal(data, out) + return nil } diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go index 27bc30a7..3d4abe27 100644 --- a/internal/loader/bootstrap_default.go +++ b/internal/loader/bootstrap_default.go @@ -18,7 +18,6 @@ import ( sjwtv1 "github.com/origadmin/runtime/gen/go/security/jwt/v1" "origadmin/application/admin/internal/configs" - systemserver "origadmin/application/admin/internal/mods/system/server" ) const ( @@ -31,28 +30,30 @@ func DefaultBootstrap() *configs.Bootstrap { Mode: "singleton", Version: "v1.0.0", CryptoType: "argon2", - Servers: map[string]string{ - systemserver.ServiceName: "origadmin.service.system.v1", - }, + //Servers: map[string]string{ + // systemserver.ServiceName: "origadmin.service.system.v1", + //}, Id: "", Entry: &configs.Bootstrap_Entry{ Scheme: "http", }, - Service: &configv1.Service{ - Name: "", - DynamicEndpoint: true, - Grpc: DefaultServiceGrpc(), - Http: DefaultServiceHttp(), - Websocket: DefaultServiceWebsocket(), - Message: DefaultServiceMessage(), - Task: DefaultServiceTask(), - Middleware: DefaultServiceMiddleware(), - Selector: &configv1.Service_Selector{ - Version: "v1.0.0", - Builder: "bbr", - }, + Services: []*configs.ServiceConfig{ + //&configv1.Service{ + // Name: "", + // DynamicEndpoint: true, + // Grpc: DefaultServiceGrpc(), + // Http: DefaultServiceHttp(), + // Websocket: DefaultServiceWebsocket(), + // Message: DefaultServiceMessage(), + // Task: DefaultServiceTask(), + // Middleware: DefaultServiceMiddleware(), + // Selector: &configv1.Service_Selector{ + // Version: "v1.0.0", + // Builder: "bbr", + // }, + //} }, - Data: DefaultData(), + Storage: DefaultStorage(), Registry: DefaultRegistry(), Middleware: DefaultServiceMiddleware(), Security: &configv1.Security{ @@ -111,7 +112,7 @@ func DefaultServiceWebsocket() *configv1.WebSocket { } } -func DefaultData() *configv1.Data { +func DefaultStorage() *configv1.Data { return &configv1.Data{ Database: &configv1.Data_Database{ Debug: false, @@ -348,15 +349,11 @@ func DefaultEntry() *configs.Bootstrap_Entry { func DefaultCaptcha() *configs.Captcha { return &configs.Captcha{ - CacheType: "memory", - Width: 400, - Height: 160, - Length: 4, - Redis: &configs.Captcha_Redis{ - Addr: "${captcha_redis_address:127.0.0.1:6379}", - Db: 0, - KeyPrefix: "captcha", - }, + Length: 4, + Width: 400, + Height: 160, + StorageName: "captcha", + Storage: &configv1.Data_Redis{}, } } @@ -373,9 +370,9 @@ func DefaultRootUser() *configs.RootUser { } } -func DefaultBasisConfig() *configs.BasisConfig { - return &configs.BasisConfig{ - RootUser: DefaultRootUser(), - Captcha: DefaultCaptcha(), +func AuthConfig() *configs.AuthConfig { + return &configs.AuthConfig{ + //RootUser: DefaultRootUser(), + Captcha: DefaultCaptcha(), } } diff --git a/internal/loader/config.go b/internal/loader/config.go index 7dfdfbd1..8180e0a9 100644 --- a/internal/loader/config.go +++ b/internal/loader/config.go @@ -6,126 +6,42 @@ package loader import ( - "os" - "path/filepath" - - "github.com/go-kratos/kratos/v2/config/env" - "github.com/go-kratos/kratos/v2/config/file" - "github.com/goexts/generic/settings" "github.com/origadmin/runtime/bootstrap" - "github.com/origadmin/runtime/config" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" - "github.com/origadmin/toolkits/codec" - "github.com/origadmin/toolkits/codec/json" - "github.com/origadmin/toolkits/errors" - "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/proto" - - "origadmin/application/admin/internal/configs" -) - -type ( - Config = configv1.SourceConfig - Bootstrap = bootstrap.Bootstrap + "github.com/origadmin/runtime/service" ) -type ConfigSetting = func(config *Config) - -func WithPath(name, filename string) ConfigSetting { - return func(config *Config) { - config.Name = name - switch config.Type { - case "file": - config.File.Path = WorkPath("", filename) - case "consul": - config.Consul.Path = ConsulConfigPath(name, filename) - } - } +// BootstrapConfig 包含启动配置 +type BootstrapConfig struct { + Service service.ServiceBuilder + Source bootstrap.SourceConfig } -func WithServiceName(name string) ConfigSetting { - return func(config *Config) { - config.Name = name +// LoadBootstrap 加载基础配置 +func LoadBootstrap(cfg BootstrapConfig) (*configs.Bootstrap, error) { + var bs *configs.Bootstrap + var err error + + switch cfg.Source.GetType() { + case "file": + bs, err = LoadLocalBootstrap(&cfg.Source) + default: + bs, err = LoadRemoteBootstrap(&cfg.Source) } -} - -// LoadEnvFiles Loads configuration files in various formats from a directory, -func LoadEnvFiles(paths ...string) (map[string]string, error) { - envs := make(map[string]string) - for i := range paths { - if err := filepath.WalkDir(paths[i], func(walkpath string, d os.DirEntry, err error) error { - if err != nil { - return errors.Wrapf(err, "failed to get config file %s", walkpath) - } else if d.IsDir() { - return nil - } - typo := codec.TypeFromExt(filepath.Ext(walkpath)) - if typo == codec.UNKNOWN { - return nil - } - if err := codec.DecodeFromFile(walkpath, &envs); err != nil { - return errors.Wrapf(err, "failed to parse config file %s", walkpath) - } - return nil - }); err != nil { - return nil, err - } - } - - return envs, nil -} - -func FromLocalPath(path string, ss ...ConfigSetting) (*configs.Bootstrap, error) { - source := FileSourceConfig(path) - return LoadLocalBootstrap(settings.Apply(source, ss)) -} - -func NewFileConfig(cfg *Config, ss ...config.OptionSetting) (config.KConfig, error) { - var sources = []config.KSource{file.NewSource(cfg.File.Path)} - if cfg.EnvPrefixes != nil { - sources = append(sources, env.NewSource(cfg.EnvPrefixes...)) - SetupEnv(cfg.EnvArgs, cfg.EnvPrefixes[0]) - } - option := settings.ApplyOrZero(ss...) - option.SourceOptions = append(option.SourceOptions, config.WithSource(sources...)) - return config.NewSourceConfig(option.SourceOptions...), nil -} - -func FileSourceConfig(path string) *Config { - return &Config{ - Type: "file", - File: &configv1.SourceConfig_File{ - Path: path, - }, - } -} - -func WorkPath(wd, path string) string { - if wd != "" && !filepath.IsAbs(path) { - path = filepath.Join(wd, path) - } - path, _ = filepath.Abs(path) - return path -} - -func PrintString(v any) string { - if message, ok := v.(proto.Message); ok { - option := protojson.MarshalOptions{ - Indent: " ", - EmitDefaultValues: false, - EmitUnpopulated: false, - } - bytes, _ := option.Marshal(message) - return string(bytes) - } - - bytes, err := json.MarshalIndent(v, "", " ") + if err != nil { - return "" + return nil, fmt.Errorf("load bootstrap error: %v", err) } - return string(bytes) + + return bs, nil } -func ConsulConfigPath(name, filename string) string { - return "/config/" + name + "/" + filename +// 新增服务发现配置加载 +func LoadRemoteBootstrap(cfg *bootstrap.SourceConfig) (*configs.Bootstrap, error) { + discoveryConfig := ®istry.ConsulConfig{ /*...*/ } + registrar, _ := registry.NewConsulRegistrar(discoveryConfig) + + return &configs.Bootstrap{ + Registry: registrar, // 远程配置携带服务注册能力 + Discovery: discoveryConfig.Client, + }, nil } diff --git a/internal/loader/config_manager.go b/internal/loader/config_manager.go new file mode 100644 index 00000000..03d9fe0b --- /dev/null +++ b/internal/loader/config_manager.go @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package loader implements the functions, types, and interfaces for the module. +package loader + +import ( + "fmt" + + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/registry" + + "origadmin/application/admin/internal/configs" +) + +// ConfigManager 实现配置获取和转换能力 +type ConfigManager struct { + discover registry.KDiscovery +} + +func NewConfigManager(discover registry.KDiscovery) *ConfigManager { + return &ConfigManager{discover: discover} +} + +// 从 Consul KV 获取特定配置 +func (cm *ConfigManager) GetConfig(configName string) ([]byte, error) { + client, ok := cm.discover.(*registry.ConsulClient) + if !ok { + return nil, fmt.Errorf("discovery client is not Consul") + } + + // 从 Consul KV 获取配置 + return client.GetKV(configName) +} + +// 从发现服务获取配置 +func (cm *ConfigManager) GetServiceConfig(ctx context.Context, name string) (*configs.Bootstrap, error) { + instances, err := cm.discover.GetService(ctx, name) + if err != nil { + return nil, err + } + + // 实现配置转换逻辑 + return convertInstancesToConfig(instances) +} + +// 实现配置转换逻辑 +func convertInstancesToConfig(instances []*registry.KServiceInstance) (*configs.Bootstrap, error) { + if len(instances) == 0 { + return nil, fmt.Errorf("no instances found") + } + + // 示例实现:从第一个实例提取基础配置 + firstInstance := instances[0] + return &configs.Bootstrap{ + ServiceName: firstInstance.Name, + Discovery: nil, // 需要重新初始化发现客户端 + // 其他字段根据需要映射... + + }, nil +} diff --git a/internal/loader/loader.go b/internal/loader/loader.go index 39584f40..6509886f 100644 --- a/internal/loader/loader.go +++ b/internal/loader/loader.go @@ -6,24 +6,39 @@ package loader import ( + "fmt" + "os" + "github.com/go-kratos/kratos/v2/transport" "github.com/go-kratos/kratos/v2/transport/grpc" "github.com/go-kratos/kratos/v2/transport/http" "github.com/google/wire" "github.com/origadmin/contrib/transport/gins" "github.com/origadmin/runtime" + "github.com/origadmin/runtime/bootstrap" + configv1 "github.com/origadmin/runtime/gen/go/config/v1" + "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/registry" "github.com/origadmin/runtime/service" - "github.com/origadmin/toolkits/security" "origadmin/application/admin/helpers/securityx" "origadmin/application/admin/internal/configs" ) +// AppOptions 包含微服务核心配置 +type AppOptions struct { + ID string + Name string + Version string + Metadata map[string]string + Logger log.KLogger + Server transport.Server // 改为通用传输层接口 +} + var ( ProviderSet = wire.NewSet( - NewBasisConfig, + NewAuthConfig, NewRegistrar, NewTokenizer, NewAuthorizer, @@ -39,6 +54,10 @@ var ( _ *grpc.Server ) +type Loader interface { + SetupEnv() error +} + type InjectorClient struct { Logger log.KLogger Bootstrap *configs.Bootstrap @@ -73,8 +92,76 @@ func NewAuthorizer(bootstrap *configs.Bootstrap) (security.Authorizer, error) { return securityx.NewAuthorizer(bootstrap) } -func NewBasisConfig(bootstrap *configs.Bootstrap) *configs.BasisConfig { +func NewAuthConfig(bootstrap *configs.Bootstrap) *configs.AuthConfig { // c := DefaultCaptcha() // todo Read from the configuration file - return DefaultBasisConfig() + return AuthConfig() +} + +type loader struct { + flags *bootstrap.Bootstrap + cfg *configv1.SourceConfig +} + +func (l loader) SetupEnv() error { + if len(l.cfg.EnvPrefixes) > 0 { + SetupEnv(l.cfg.EnvArgs, l.cfg.EnvPrefixes[0]) + } + return nil +} + +func (l loader) Bootstrap() (*configs.Bootstrap, error) { + var bs *configs.Bootstrap + var err error + switch l.cfg.GetType() { + case "file": + bs, err = LoadLocalBootstrap(l.cfg) + default: + bs, err = LoadRemoteBootstrap(l.cfg) + } + if err != nil { + return nil, fmt.Errorf("load bootstrap error: %s", err.Error()) + } + + log.Infof("load config: %+v\n", bs) + return bs, nil +} + +func New(flags *Bootstrap) (Loader, error) { + load := &loader{ + flags: flags, + } + sourceConfig, err := bootstrap.LoadSourceConfig(flags) + if err != nil { + return nil, err + } + load.cfg = sourceConfig + return load, nil +} + +// 删除复杂的多级错误收集机制,简化为优先级失败模式 +func LoadBootstrap(cfg BootstrapConfig) (*configs.Bootstrap, error) { + var bs *configs.Bootstrap + var err error + + // 优先尝试加载远程配置 ✅ 首选远程配置中心 + bs, err = LoadRemoteBootstrap(&cfg.Source) + if err == nil && bs != nil { + if envErr := ReplaceObject(bs, cfg.Source.EnvArgs); envErr == nil { + return bs, nil + } + return nil, fmt.Errorf("remote config replace failed: %w", envErr) + } + + // 远程加载失败时回退到本地配置 ⛔️ 仅作为降级方案 + bs, err = LoadLocalBootstrap(&cfg.Source) + if err == nil && bs != nil { + if envErr := ReplaceObject(bs, cfg.Source.EnvArgs); envErr == nil { + return bs, nil + } + return nil, fmt.Errorf("local config replace failed: %w", envErr) + } + + return nil, fmt.Errorf("failed to load config: remote[%v], local[%v]", + err, os.ErrNotExist) } diff --git a/internal/loader/service_test.go b/internal/loader/service_test.go new file mode 100644 index 00000000..22943206 --- /dev/null +++ b/internal/loader/service_test.go @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package loader implements the functions, types, and interfaces for the module. +package loader + +import ( + "testing" + + configv1 "github.com/origadmin/runtime/gen/go/config/v1" + jwtv1 "github.com/origadmin/runtime/gen/go/middleware/jwt/v1" + "github.com/origadmin/runtime/gen/go/middleware/metrics/v1" + "github.com/origadmin/runtime/gen/go/middleware/ratelimit/v1" + "github.com/origadmin/runtime/gen/go/middleware/selector/v1" + v11 "github.com/origadmin/runtime/gen/go/middleware/v1" + "github.com/origadmin/runtime/gen/go/middleware/validator/v1" + "github.com/stretchr/testify/assert" + + "origadmin/application/admin/internal/configs/services" +) + +func TestServiceDefaultOutput(t *testing.T) { + // Test the default service configuration initialization + ss := make([]*services.Service, 0) + + // Verify empty slice initialization + assert.Empty(t, ss, "默认服务列表应为空") + + // 添加测试服务实例 + testService := &services.Service{ + Core: &services.ServiceCore{ + Name: "test-service", + Version: "v1.0.0", + Registry: &configv1.Registry{ + Type: "", + ServiceName: "", + Debug: false, + Consul: &configv1.Registry_Consul{ + Address: "", + Scheme: "", + Token: "", + HeartBeat: false, + HealthCheck: false, + Datacenter: "", + HealthCheckInterval: 0, + Timeout: 0, + DeregisterCriticalServiceAfter: 0, + }, + Etcd: &configv1.Registry_ETCD{ + Endpoints: nil, + }, + }, + Storages: nil, + }, + Service: &configv1.Service{ + Name: "", + DynamicEndpoint: false, + Grpc: &configv1.Service_GRPC{ + Network: "", + Addr: "", + UseTls: false, + TlsConfig: &configv1.TLSConfig{ + File: &configv1.TLSConfig_File{ + Cert: "", + Key: "", + Ca: "", + }, + Pem: &configv1.TLSConfig_PEM{ + Cert: nil, + Key: nil, + Ca: nil, + }, + }, + Timeout: 0, + ShutdownTimeout: 0, + ReadTimeout: 0, + WriteTimeout: 0, + IdleTimeout: 0, + Endpoint: "", + }, + Http: &configv1.Service_HTTP{ + Network: "", + Addr: "", + UseTls: false, + TlsConfig: &configv1.TLSConfig{ + File: &configv1.TLSConfig_File{ + Cert: "", + Key: "", + Ca: "", + }, + Pem: &configv1.TLSConfig_PEM{ + Cert: nil, + Key: nil, + Ca: nil, + }, + }, + Timeout: 0, + ShutdownTimeout: 0, + ReadTimeout: 0, + WriteTimeout: 0, + IdleTimeout: 0, + Endpoint: "", + }, + Websocket: &configv1.WebSocket{ + Network: "", + Addr: "", + Path: "", + Codec: "", + Timeout: 0, + }, + Message: &configv1.Message{ + Type: "", + Name: "", + Mqtt: &configv1.Message_MQTT{ + Endpoint: "", + Codec: "", + }, + Kafka: &configv1.Message_Kafka{ + Endpoint: "", + Codec: "", + }, + Rabbitmq: &configv1.Message_RabbitMQ{ + Endpoint: "", + Codec: "", + }, + Activemq: &configv1.Message_ActiveMQ{ + Endpoint: "", + Codec: "", + }, + Nats: &configv1.Message_NATS{ + Endpoint: "", + Codec: "", + }, + Nsq: &configv1.Message_NSQ{ + Endpoint: "", + Codec: "", + }, + Pulsar: &configv1.Message_Pulsar{ + Endpoint: "", + Codec: "", + }, + Redis: &configv1.Message_Redis{ + Endpoint: "", + Codec: "", + }, + Rocketmq: &configv1.Message_RocketMQ{ + Endpoint: "", + Codec: "", + EnableTrace: false, + NameServers: nil, + NameServerDomain: "", + AccessKey: "", + SecretKey: "", + SecurityToken: "", + Namespace: "", + InstanceName: "", + GroupName: "", + }, + }, + Task: &configv1.Task{ + Type: "", + Name: "", + Asynq: &configv1.Task_Asynq{ + Endpoint: "", + Password: "", + Db: 0, + Location: "", + }, + Machinery: &configv1.Task_Machinery{ + Brokers: nil, + Backends: nil, + }, + Cron: &configv1.Task_Cron{ + Addr: "", + }, + }, + Middleware: &v11.Middleware{ + Logging: false, + Recovery: false, + Tracing: false, + CircuitBreaker: false, + Metadata: &v11.Middleware_Metadata{ + Enabled: false, + Prefix: "", + Data: nil, + }, + RateLimiter: &ratelimitv1.RateLimiter{ + Enabled: false, + Name: "", + Period: 0, + XRatelimitLimit: 0, + XRatelimitRemaining: 0, + XRatelimitReset: 0, + RetryAfter: 0, + Memory: &ratelimitv1.RateLimiter_Memory{ + Expiration: 0, + CleanupInterval: 0, + }, + Redis: &ratelimitv1.RateLimiter_Redis{ + Addr: "", + Username: "", + Password: "", + Db: 0, + }, + }, + Metrics: &metricsv1.Metrics{ + Enabled: false, + SupportedMetrics: nil, + UserMetrics: nil, + }, + Validator: &validatorv1.Validator{ + Enabled: false, + Version: 0, + FailFast: false, + }, + Jwt: &jwtv1.JWT{ + Enabled: false, + Subject: "", + ClaimType: "", + TokenHeader: nil, + Config: &jwtv1.Config{ + SigningMethod: "", + Key: "", + Key2: "", + AccessTokenLifetime: 0, + RefreshTokenLifetime: 0, + Issuer: "", + Audience: nil, + TokenType: "", + }, + }, + Selector: &selectorv1.Selector{ + Enabled: false, + Names: nil, + Paths: nil, + Regex: "", + Prefixes: nil, + }, + }, + Selector: &configv1.Service_Selector{ + Version: "", + Builder: "", + }, + }, + Middleware: &v11.Middleware{ + Logging: false, + Recovery: false, + Tracing: false, + CircuitBreaker: false, + Metadata: &v11.Middleware_Metadata{ + Enabled: false, + Prefix: "", + Data: nil, + }, + RateLimiter: &ratelimitv1.RateLimiter{ + Enabled: false, + Name: "", + Period: 0, + XRatelimitLimit: 0, + XRatelimitRemaining: 0, + XRatelimitReset: 0, + RetryAfter: 0, + Memory: &ratelimitv1.RateLimiter_Memory{ + Expiration: 0, + CleanupInterval: 0, + }, + Redis: &ratelimitv1.RateLimiter_Redis{ + Addr: "", + Username: "", + Password: "", + Db: 0, + }, + }, + Metrics: &metricsv1.Metrics{ + Enabled: false, + SupportedMetrics: nil, + UserMetrics: nil, + }, + Validator: &validatorv1.Validator{ + Enabled: false, + Version: 0, + FailFast: false, + }, + Jwt: &jwtv1.JWT{ + Enabled: false, + Subject: "", + ClaimType: "", + TokenHeader: nil, + Config: &jwtv1.Config{ + SigningMethod: "", + Key: "", + Key2: "", + AccessTokenLifetime: 0, + RefreshTokenLifetime: 0, + Issuer: "", + Audience: nil, + TokenType: "", + }, + }, + Selector: &selectorv1.Selector{ + Enabled: false, + Names: nil, + Paths: nil, + Regex: "", + Prefixes: nil, + }, + }, + } + services = append(services, testService) + + // 验证服务添加后的数量和内容 + assert.Len(t, services, 1, "添加服务后应包含一个元素") + assert.Equal(t, "test-service", services[0].Name, "服务名称不匹配") + assert.Equal(t, "v1.0.0", services[0].Version, "服务版本不匹配") +} diff --git a/internal/mods/agent/auth_test.go b/internal/mods/agent/auth_test.go index 67931f39..36e017ca 100644 --- a/internal/mods/agent/auth_test.go +++ b/internal/mods/agent/auth_test.go @@ -20,7 +20,7 @@ import ( configv1 "github.com/origadmin/runtime/gen/go/config/v1" "github.com/origadmin/runtime/log" kslog "github.com/origadmin/slog-kratos" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" "github.com/stretchr/testify/assert" "origadmin/application/admin/helpers/securityx" diff --git a/internal/mods/agent/http.go b/internal/mods/agent/http.go index a91705d6..db1d9565 100644 --- a/internal/mods/agent/http.go +++ b/internal/mods/agent/http.go @@ -21,7 +21,7 @@ import ( "github.com/origadmin/runtime/middleware" "github.com/origadmin/runtime/service" servicehttp "github.com/origadmin/runtime/service/http" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/contrib/security/authz/casbin" diff --git a/internal/mods/agent/mock.go b/internal/mods/agent/mock.go index 9e76c462..4b5bb093 100644 --- a/internal/mods/agent/mock.go +++ b/internal/mods/agent/mock.go @@ -10,7 +10,7 @@ import ( "fmt" "github.com/origadmin/runtime/context" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" ) type mockAuthenticator struct { diff --git a/internal/mods/casbin/biz/biz.go b/internal/mods/casbin/biz/biz.go index a390b33b..d918b7e5 100644 --- a/internal/mods/casbin/biz/biz.go +++ b/internal/mods/casbin/biz/biz.go @@ -9,7 +9,7 @@ import ( "github.com/google/wire" "github.com/origadmin/toolkits/errors/httperr" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" ) diff --git a/internal/mods/casbin/dal/entity/ent/database.go b/internal/mods/casbin/dal/entity/ent/database.go index 3cdf8268..26903f60 100644 --- a/internal/mods/casbin/dal/entity/ent/database.go +++ b/internal/mods/casbin/dal/entity/ent/database.go @@ -10,7 +10,7 @@ import ( "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" - "github.com/origadmin/toolkits/database" + "github.com/origadmin/runtime/interfaces/database" ) // Database is the client that holds all ent builders. diff --git a/internal/mods/casbin/dal/entity/ent/template/database.tpl b/internal/mods/casbin/dal/entity/ent/template/database.tpl index c5f9c208..914a4f34 100644 --- a/internal/mods/casbin/dal/entity/ent/template/database.tpl +++ b/internal/mods/casbin/dal/entity/ent/template/database.tpl @@ -13,7 +13,7 @@ "context" "fmt" "entgo.io/ent/dialect/sql" - "github.com/origadmin/toolkits/database" + "github.com/origadmin/runtime/interfaces/database" ) // Database is the client that holds all ent builders. diff --git a/internal/mods/system/biz/auth.biz.go b/internal/mods/system/biz/auth.biz.go index 04006651..50efeb99 100644 --- a/internal/mods/system/biz/auth.biz.go +++ b/internal/mods/system/biz/auth.biz.go @@ -8,7 +8,7 @@ package biz import ( "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" diff --git a/internal/mods/system/biz/biz.go b/internal/mods/system/biz/biz.go index 8692804f..96fb99dc 100644 --- a/internal/mods/system/biz/biz.go +++ b/internal/mods/system/biz/biz.go @@ -9,7 +9,7 @@ import ( "github.com/google/wire" "github.com/origadmin/toolkits/errors/httperr" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" ) diff --git a/internal/mods/system/biz/casbin.biz.go b/internal/mods/system/biz/casbin.biz.go index 5bb9d239..828973d6 100644 --- a/internal/mods/system/biz/casbin.biz.go +++ b/internal/mods/system/biz/casbin.biz.go @@ -11,7 +11,7 @@ import ( "time" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" "google.golang.org/grpc" pb "origadmin/application/admin/api/v1/services/system" diff --git a/internal/mods/system/biz/login.biz.go b/internal/mods/system/biz/login.biz.go index 93b49d48..d39bf20f 100644 --- a/internal/mods/system/biz/login.biz.go +++ b/internal/mods/system/biz/login.biz.go @@ -9,7 +9,7 @@ import ( "context" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" diff --git a/internal/mods/system/biz/permission.biz.go b/internal/mods/system/biz/permission.biz.go index 4a16c462..35b22af4 100644 --- a/internal/mods/system/biz/permission.biz.go +++ b/internal/mods/system/biz/permission.biz.go @@ -8,7 +8,7 @@ package biz import ( "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" diff --git a/internal/mods/system/biz/personal.biz.go b/internal/mods/system/biz/personal.biz.go index 67935320..b1e90a89 100644 --- a/internal/mods/system/biz/personal.biz.go +++ b/internal/mods/system/biz/personal.biz.go @@ -9,7 +9,7 @@ import ( "context" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" diff --git a/internal/mods/system/biz/resource.biz.go b/internal/mods/system/biz/resource.biz.go index edc1415c..3df3b9ec 100644 --- a/internal/mods/system/biz/resource.biz.go +++ b/internal/mods/system/biz/resource.biz.go @@ -8,7 +8,7 @@ package biz import ( "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" diff --git a/internal/mods/system/biz/role.biz.go b/internal/mods/system/biz/role.biz.go index 333c43e8..3bea9ed3 100644 --- a/internal/mods/system/biz/role.biz.go +++ b/internal/mods/system/biz/role.biz.go @@ -8,7 +8,7 @@ package biz import ( "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" diff --git a/internal/mods/system/biz/user.biz.go b/internal/mods/system/biz/user.biz.go index 22f79ada..005dd7fe 100644 --- a/internal/mods/system/biz/user.biz.go +++ b/internal/mods/system/biz/user.biz.go @@ -10,7 +10,7 @@ import ( "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" diff --git a/internal/mods/system/dal/auth.dal.go b/internal/mods/system/dal/auth.dal.go index 8f5c0435..5ecc0a52 100644 --- a/internal/mods/system/dal/auth.dal.go +++ b/internal/mods/system/dal/auth.dal.go @@ -9,8 +9,8 @@ import ( "errors" "sync" + "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/security" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dal/entity/ent" diff --git a/internal/mods/system/dal/entity/ent/database.go b/internal/mods/system/dal/entity/ent/database.go index 4d7f431e..94d599e9 100644 --- a/internal/mods/system/dal/entity/ent/database.go +++ b/internal/mods/system/dal/entity/ent/database.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/schema" - "github.com/origadmin/toolkits/database" + "github.com/origadmin/runtime/interfaces/database" ) // Database is the client that holds all ent builders. diff --git a/internal/mods/system/dal/entity/ent/template/database.tpl b/internal/mods/system/dal/entity/ent/template/database.tpl index 3228f3f0..86a38099 100644 --- a/internal/mods/system/dal/entity/ent/template/database.tpl +++ b/internal/mods/system/dal/entity/ent/template/database.tpl @@ -13,7 +13,7 @@ "context" "fmt" "entgo.io/ent/dialect/sql" - "github.com/origadmin/toolkits/database" + "github.com/origadmin/runtime/interfaces/database" ) // Database is the client that holds all ent builders. diff --git a/internal/mods/system/dal/login.dal.go b/internal/mods/system/dal/login.dal.go index 3f72d8ad..91725a95 100644 --- a/internal/mods/system/dal/login.dal.go +++ b/internal/mods/system/dal/login.dal.go @@ -17,7 +17,7 @@ import ( "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/rand" "github.com/origadmin/toolkits/errors/httperr" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/captcha" diff --git a/internal/mods/system/dto/auth.go b/internal/mods/system/dto/auth.go index 86a3b1cf..81dc7026 100644 --- a/internal/mods/system/dto/auth.go +++ b/internal/mods/system/dto/auth.go @@ -8,7 +8,7 @@ package dto import ( "context" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" ) diff --git a/internal/mods/system/dto/menu.go b/internal/mods/system/dto/menu.go index 800c5ab4..9568d083 100644 --- a/internal/mods/system/dto/menu.go +++ b/internal/mods/system/dto/menu.go @@ -6,7 +6,7 @@ package dto import ( - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" ) diff --git a/internal/mods/system/dto/permission.go b/internal/mods/system/dto/permission.go index 9453f4d0..39dd6487 100644 --- a/internal/mods/system/dto/permission.go +++ b/internal/mods/system/dto/permission.go @@ -8,7 +8,7 @@ package dto import ( "context" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/resp" diff --git a/internal/mods/system/dto/resource.go b/internal/mods/system/dto/resource.go index 54ff3528..74a0c30a 100644 --- a/internal/mods/system/dto/resource.go +++ b/internal/mods/system/dto/resource.go @@ -8,7 +8,7 @@ package dto import ( "context" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/resp" diff --git a/internal/mods/system/dto/role.go b/internal/mods/system/dto/role.go index b8b6d202..018d05a8 100644 --- a/internal/mods/system/dto/role.go +++ b/internal/mods/system/dto/role.go @@ -9,7 +9,7 @@ import ( "context" "time" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" "google.golang.org/protobuf/proto" pb "origadmin/application/admin/api/v1/services/system" diff --git a/internal/mods/system/dto/user.go b/internal/mods/system/dto/user.go index d88adca8..973866ac 100644 --- a/internal/mods/system/dto/user.go +++ b/internal/mods/system/dto/user.go @@ -12,7 +12,7 @@ import ( "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/rand" - "github.com/origadmin/toolkits/net/pagination" + "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/id" diff --git a/internal/mods/system/server/server.go b/internal/mods/system/server/server.go index c35da767..bb2d4355 100644 --- a/internal/mods/system/server/server.go +++ b/internal/mods/system/server/server.go @@ -55,7 +55,7 @@ func NewSystemServer(bootstrap *configs.Bootstrap, registers []service.ServerReg } ctx := context.Background() middlewares := middleware.NewServer(bootstrap.GetService().GetMiddleware()) - if serv := NewGRPCServer(bootstrap, l, service.WithGRPC( + if serv := runtime.NewGRPCServiceServer(bootstrap, l, service.WithGRPC( servicegrpc.WithMiddlewares(middlewares...), servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), )); serv != nil { @@ -148,8 +148,9 @@ func NewSystemClient(bootstrap *configs.Bootstrap, l log.KLogger) (*service.GRPC }, } if v, ok := bootstrap.GetServers()[ServiceName]; ok { - registry.ServiceName = v + registry.ServiceName = ServiceName } + //registry.ServiceName = ServiceName log.Infof("service name: %s", registry.ServiceName) discovery, err := runtime.NewDiscovery(registry) if err != nil { @@ -190,9 +191,27 @@ func MiddlewareServer() middleware.KMiddleware { } } -func NewRegisterServer(s1 *systemservice.RegisterServer) []service.ServerRegister { +func NewRegisterServer( + Resource pb.ResourceServiceServer, + Role pb.RoleServiceServer, + User pb.UserServiceServer, + Auth pb.AuthServiceServer, + Login pb.LoginServiceServer, + Personal pb.PersonalServiceServer, + Permission pb.PermissionServiceServer, + Casbin pb.CasbinSourceServiceServer, +) []service.ServerRegister { return []service.ServerRegister{ - s1, + &systemservice.RegisterServer{ + Resource: Resource, + Role: Role, + User: User, + Auth: Auth, + Login: Login, + Personal: Personal, + Permission: Permission, + Casbin: Casbin, + }, } } diff --git a/internal/mods/system/service/resource.http.go b/internal/mods/system/service/resource.http.go index 20618356..1160bfb8 100644 --- a/internal/mods/system/service/resource.http.go +++ b/internal/mods/system/service/resource.http.go @@ -48,7 +48,7 @@ func NewResourceServiceHTTPServer(client pb.ResourceServiceHTTPClient) *Resource } // NewResourceServiceHTTPServerPB new a menu service. -func NewResourceServiceHTTPServerPB(client pb.ResourceServiceHTTPClient) pb.ResourceServiceServer { +func NewResourceServiceHTTPServerPB(client pb.ResourceServiceHTTPClient) pb.ResourceServiceHTTPServer { return &ResourceServiceHTTPServer{client: client} } diff --git a/internal/mock/token_test.go b/test/token_test.go similarity index 98% rename from internal/mock/token_test.go rename to test/token_test.go index 4c935875..67938612 100644 --- a/internal/mock/token_test.go +++ b/test/token_test.go @@ -3,7 +3,7 @@ */ // Package mock implements the functions, types, and interfaces for the module. -package mock +package test import ( "context" @@ -13,7 +13,7 @@ import ( _ "github.com/origadmin/contrib/consul/registry" _ "github.com/origadmin/contrib/database" "github.com/origadmin/runtime/bootstrap" - "github.com/origadmin/toolkits/security" + "github.com/origadmin/runtime/interfaces/security" "origadmin/application/admin/contrib/security/authz/casbin" "origadmin/application/admin/helpers/securityx" diff --git a/third_party/buf/validate/validate.proto b/third_party/buf/validate/validate.proto index 7d324160..40236f65 100644 --- a/third_party/buf/validate/validate.proto +++ b/third_party/buf/validate/validate.proto @@ -32,7 +32,7 @@ option java_package = "build.buf.validate"; extend google.protobuf.MessageOptions { // Rules specify the validations to be performed on this message. By default, // no validation is performed against a message. - optional MessageConstraints message = 1159; + optional MessageRules message = 1159; } // OneofOptions is an extension to google.protobuf.OneofOptions. It allows @@ -42,7 +42,7 @@ extend google.protobuf.MessageOptions { extend google.protobuf.OneofOptions { // Rules specify the validations to be performed on this oneof. By default, // no validation is performed against a oneof. - optional OneofConstraints oneof = 1159; + optional OneofRules oneof = 1159; } // FieldOptions is an extension to google.protobuf.FieldOptions. It allows @@ -52,9 +52,9 @@ extend google.protobuf.OneofOptions { extend google.protobuf.FieldOptions { // Rules specify the validations to be performed on this field. By default, // no validation is performed against a field. - optional FieldConstraints field = 1159; + optional FieldRules field = 1159; - // Specifies predefined rules. When extending a standard constraint message, + // Specifies predefined rules. When extending a standard rule message, // this adds additional CEL expressions that apply when the extension is used. // // ```proto @@ -70,11 +70,11 @@ extend google.protobuf.FieldOptions { // int32 reserved = 1 [(buf.validate.field).int32.(is_zero) = true]; // } // ``` - optional PredefinedConstraints predefined = 1160; + optional PredefinedRules predefined = 1160; } -// `Constraint` represents a validation rule written in the Common Expression -// Language (CEL) syntax. Each Constraint includes a unique identifier, an +// `Rule` represents a validation rule written in the Common Expression +// Language (CEL) syntax. Each Rule includes a unique identifier, an // optional error message, and the CEL expression to evaluate. For more // information on CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). // @@ -88,13 +88,13 @@ extend google.protobuf.FieldOptions { // int32 bar = 1; // } // ``` -message Constraint { - // `id` is a string that serves as a machine-readable name for this Constraint. +message Rule { + // `id` is a string that serves as a machine-readable name for this Rule. // It should be unique within its scope, which could be either a message or a field. optional string id = 1; // `message` is an optional field that provides a human-readable error message - // for this Constraint when the CEL expression evaluates to false. If a + // for this Rule when the CEL expression evaluates to false. If a // non-empty message is provided, any strings resulting from the CEL // expression evaluation are ignored. optional string message = 2; @@ -106,9 +106,9 @@ message Constraint { optional string expression = 3; } -// MessageConstraints represents validation rules that are applied to the entire message. -// It includes disabling options and a list of Constraint messages representing Common Expression Language (CEL) validation rules. -message MessageConstraints { +// MessageRules represents validation rules that are applied to the entire message. +// It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules. +message MessageRules { // `disabled` is a boolean flag that, when set to true, nullifies any validation rules for this message. // This includes any fields within the message that would otherwise support validation. // @@ -120,8 +120,8 @@ message MessageConstraints { // ``` optional bool disabled = 1; - // `cel` is a repeated field of type Constraint. Each Constraint specifies a validation rule to be applied to this message. - // These constraints are written in Common Expression Language (CEL) syntax. For more information on + // `cel` is a repeated field of type Rule. Each Rule specifies a validation rule to be applied to this message. + // These rules are written in Common Expression Language (CEL) syntax. For more information on // CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). // // @@ -136,15 +136,15 @@ message MessageConstraints { // optional int32 foo = 1; // } // ``` - repeated Constraint cel = 3; + repeated Rule cel = 3; } -// The `OneofConstraints` message type enables you to manage constraints for +// The `OneofRules` message type enables you to manage rules for // oneof fields in your protobuf messages. -message OneofConstraints { +message OneofRules { // If `required` is true, exactly one field of the oneof must be present. A // validation error is returned if no fields in the oneof are present. The - // field itself may still be a default value; further constraints + // field itself may still be a default value; further rules // should be placed on the fields themselves to ensure they are valid values, // such as `min_len` or `gt`. // @@ -162,9 +162,9 @@ message OneofConstraints { optional bool required = 1; } -// FieldConstraints encapsulates the rules for each type of field. Depending on +// FieldRules encapsulates the rules for each type of field. Depending on // the field, the correct set should be used to ensure proper validations. -message FieldConstraints { +message FieldRules { // `cel` is a repeated field used to represent a textual expression // in the Common Expression Language (CEL) syntax. For more information on // CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). @@ -179,12 +179,12 @@ message FieldConstraints { // }]; // } // ``` - repeated Constraint cel = 23; + repeated Rule cel = 23; // If `required` is true, the field must be populated. A populated field can be // described as "serialized in the wire format," which includes: // // - the following "nullable" fields must be explicitly set to be considered populated: - // - singular message fields (whose fields may be unpopulated/default values) + // - singular message fields (whose fields may be unpopulated / default values) // - member fields of a oneof (may be their default value) // - proto3 optional fields (may be their default value) // - proto2 scalar fields (both optional and required) @@ -246,9 +246,9 @@ message FieldConstraints { reserved "skipped", "ignore_empty"; } -// PredefinedConstraints are custom constraints that can be re-used with +// PredefinedRules are custom rules that can be re-used with // multiple fields. -message PredefinedConstraints { +message PredefinedRules { // `cel` is a repeated field used to represent a textual expression // in the Common Expression Language (CEL) syntax. For more information on // CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). @@ -263,7 +263,7 @@ message PredefinedConstraints { // }]; // } // ``` - repeated Constraint cel = 1; + repeated Rule cel = 1; reserved 24, 26; reserved @@ -272,8 +272,8 @@ message PredefinedConstraints { ; } -// Specifies how FieldConstraints.ignore behaves. See the documentation for -// FieldConstraints.required for definitions of "populated" and "nullable". +// Specifies how FieldRules.ignore behaves. See the documentation for +// FieldRules.required for definitions of "populated" and "nullable". enum Ignore { // Validation is only skipped if it's an unpopulated nullable fields. // @@ -405,7 +405,7 @@ enum Ignore { // The validation rules of this field will be skipped and not evaluated. This // is useful for situations that necessitate turning off the rules of a field // containing a message that may not make sense in the current context, or to - // temporarily disable constraints during development. + // temporarily disable rules during development. // // ```proto // message MyMessage { @@ -423,7 +423,7 @@ enum Ignore { ; } -// FloatRules describes the constraints applied to `float` values. These +// FloatRules describes the rules applied to `float` values. These // rules may also be applied to the `google.protobuf.FloatValue` Well-Known-Type. message FloatRules { // `const` requires the field value to exactly match the specified value. If @@ -437,7 +437,7 @@ message FloatRules { // ``` optional float const = 1 [(predefined).cel = { id: "float.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { @@ -592,7 +592,7 @@ message FloatRules { // ``` repeated float in = 6 [(predefined).cel = { id: "float.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `in` requires the field value to not be equal to any of the specified @@ -618,7 +618,7 @@ message FloatRules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -635,8 +635,8 @@ message FloatRules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -647,7 +647,7 @@ message FloatRules { extensions 1000 to max; } -// DoubleRules describes the constraints applied to `double` values. These +// DoubleRules describes the rules applied to `double` values. These // rules may also be applied to the `google.protobuf.DoubleValue` Well-Known-Type. message DoubleRules { // `const` requires the field value to exactly match the specified value. If @@ -661,7 +661,7 @@ message DoubleRules { // ``` optional double const = 1 [(predefined).cel = { id: "double.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -813,7 +813,7 @@ message DoubleRules { // ``` repeated double in = 6 [(predefined).cel = { id: "double.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -839,7 +839,7 @@ message DoubleRules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -856,8 +856,8 @@ message DoubleRules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -868,7 +868,7 @@ message DoubleRules { extensions 1000 to max; } -// Int32Rules describes the constraints applied to `int32` values. These +// Int32Rules describes the rules applied to `int32` values. These // rules may also be applied to the `google.protobuf.Int32Value` Well-Known-Type. message Int32Rules { // `const` requires the field value to exactly match the specified value. If @@ -882,7 +882,7 @@ message Int32Rules { // ``` optional int32 const = 1 [(predefined).cel = { id: "int32.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field @@ -1035,7 +1035,7 @@ message Int32Rules { // ``` repeated int32 in = 6 [(predefined).cel = { id: "int32.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -1054,7 +1054,7 @@ message Int32Rules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -1071,8 +1071,8 @@ message Int32Rules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -1083,7 +1083,7 @@ message Int32Rules { extensions 1000 to max; } -// Int64Rules describes the constraints applied to `int64` values. These +// Int64Rules describes the rules applied to `int64` values. These // rules may also be applied to the `google.protobuf.Int64Value` Well-Known-Type. message Int64Rules { // `const` requires the field value to exactly match the specified value. If @@ -1097,7 +1097,7 @@ message Int64Rules { // ``` optional int64 const = 1 [(predefined).cel = { id: "int64.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -1250,7 +1250,7 @@ message Int64Rules { // ``` repeated int64 in = 6 [(predefined).cel = { id: "int64.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -1269,7 +1269,7 @@ message Int64Rules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -1286,8 +1286,8 @@ message Int64Rules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -1298,7 +1298,7 @@ message Int64Rules { extensions 1000 to max; } -// UInt32Rules describes the constraints applied to `uint32` values. These +// UInt32Rules describes the rules applied to `uint32` values. These // rules may also be applied to the `google.protobuf.UInt32Value` Well-Known-Type. message UInt32Rules { // `const` requires the field value to exactly match the specified value. If @@ -1312,7 +1312,7 @@ message UInt32Rules { // ``` optional uint32 const = 1 [(predefined).cel = { id: "uint32.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -1465,7 +1465,7 @@ message UInt32Rules { // ``` repeated uint32 in = 6 [(predefined).cel = { id: "uint32.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -1484,7 +1484,7 @@ message UInt32Rules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -1501,8 +1501,8 @@ message UInt32Rules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -1513,7 +1513,7 @@ message UInt32Rules { extensions 1000 to max; } -// UInt64Rules describes the constraints applied to `uint64` values. These +// UInt64Rules describes the rules applied to `uint64` values. These // rules may also be applied to the `google.protobuf.UInt64Value` Well-Known-Type. message UInt64Rules { // `const` requires the field value to exactly match the specified value. If @@ -1527,7 +1527,7 @@ message UInt64Rules { // ``` optional uint64 const = 1 [(predefined).cel = { id: "uint64.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -1679,7 +1679,7 @@ message UInt64Rules { // ``` repeated uint64 in = 6 [(predefined).cel = { id: "uint64.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -1698,7 +1698,7 @@ message UInt64Rules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -1715,8 +1715,8 @@ message UInt64Rules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -1727,7 +1727,7 @@ message UInt64Rules { extensions 1000 to max; } -// SInt32Rules describes the constraints applied to `sint32` values. +// SInt32Rules describes the rules applied to `sint32` values. message SInt32Rules { // `const` requires the field value to exactly match the specified value. If // the field value doesn't match, an error message is generated. @@ -1740,7 +1740,7 @@ message SInt32Rules { // ``` optional sint32 const = 1 [(predefined).cel = { id: "sint32.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field @@ -1893,7 +1893,7 @@ message SInt32Rules { // ``` repeated sint32 in = 6 [(predefined).cel = { id: "sint32.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -1912,7 +1912,7 @@ message SInt32Rules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -1929,8 +1929,8 @@ message SInt32Rules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -1941,7 +1941,7 @@ message SInt32Rules { extensions 1000 to max; } -// SInt64Rules describes the constraints applied to `sint64` values. +// SInt64Rules describes the rules applied to `sint64` values. message SInt64Rules { // `const` requires the field value to exactly match the specified value. If // the field value doesn't match, an error message is generated. @@ -1954,7 +1954,7 @@ message SInt64Rules { // ``` optional sint64 const = 1 [(predefined).cel = { id: "sint64.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field @@ -2107,7 +2107,7 @@ message SInt64Rules { // ``` repeated sint64 in = 6 [(predefined).cel = { id: "sint64.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -2126,7 +2126,7 @@ message SInt64Rules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -2143,8 +2143,8 @@ message SInt64Rules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -2155,7 +2155,7 @@ message SInt64Rules { extensions 1000 to max; } -// Fixed32Rules describes the constraints applied to `fixed32` values. +// Fixed32Rules describes the rules applied to `fixed32` values. message Fixed32Rules { // `const` requires the field value to exactly match the specified value. // If the field value doesn't match, an error message is generated. @@ -2168,7 +2168,7 @@ message Fixed32Rules { // ``` optional fixed32 const = 1 [(predefined).cel = { id: "fixed32.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -2321,7 +2321,7 @@ message Fixed32Rules { // ``` repeated fixed32 in = 6 [(predefined).cel = { id: "fixed32.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -2340,7 +2340,7 @@ message Fixed32Rules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -2357,8 +2357,8 @@ message Fixed32Rules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -2369,7 +2369,7 @@ message Fixed32Rules { extensions 1000 to max; } -// Fixed64Rules describes the constraints applied to `fixed64` values. +// Fixed64Rules describes the rules applied to `fixed64` values. message Fixed64Rules { // `const` requires the field value to exactly match the specified value. If // the field value doesn't match, an error message is generated. @@ -2382,7 +2382,7 @@ message Fixed64Rules { // ``` optional fixed64 const = 1 [(predefined).cel = { id: "fixed64.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -2535,7 +2535,7 @@ message Fixed64Rules { // ``` repeated fixed64 in = 6 [(predefined).cel = { id: "fixed64.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -2554,7 +2554,7 @@ message Fixed64Rules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -2571,8 +2571,8 @@ message Fixed64Rules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -2583,7 +2583,7 @@ message Fixed64Rules { extensions 1000 to max; } -// SFixed32Rules describes the constraints applied to `fixed32` values. +// SFixed32Rules describes the rules applied to `fixed32` values. message SFixed32Rules { // `const` requires the field value to exactly match the specified value. If // the field value doesn't match, an error message is generated. @@ -2596,7 +2596,7 @@ message SFixed32Rules { // ``` optional sfixed32 const = 1 [(predefined).cel = { id: "sfixed32.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -2749,7 +2749,7 @@ message SFixed32Rules { // ``` repeated sfixed32 in = 6 [(predefined).cel = { id: "sfixed32.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -2768,7 +2768,7 @@ message SFixed32Rules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -2785,8 +2785,8 @@ message SFixed32Rules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -2797,7 +2797,7 @@ message SFixed32Rules { extensions 1000 to max; } -// SFixed64Rules describes the constraints applied to `fixed64` values. +// SFixed64Rules describes the rules applied to `fixed64` values. message SFixed64Rules { // `const` requires the field value to exactly match the specified value. If // the field value doesn't match, an error message is generated. @@ -2810,7 +2810,7 @@ message SFixed64Rules { // ``` optional sfixed64 const = 1 [(predefined).cel = { id: "sfixed64.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` requires the field value to be less than the specified value (field < @@ -2963,7 +2963,7 @@ message SFixed64Rules { // ``` repeated sfixed64 in = 6 [(predefined).cel = { id: "sfixed64.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to not be equal to any of the specified @@ -2982,7 +2982,7 @@ message SFixed64Rules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -2999,8 +2999,8 @@ message SFixed64Rules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -3011,7 +3011,7 @@ message SFixed64Rules { extensions 1000 to max; } -// BoolRules describes the constraints applied to `bool` values. These rules +// BoolRules describes the rules applied to `bool` values. These rules // may also be applied to the `google.protobuf.BoolValue` Well-Known-Type. message BoolRules { // `const` requires the field value to exactly match the specified boolean value. @@ -3025,11 +3025,11 @@ message BoolRules { // ``` optional bool const = 1 [(predefined).cel = { id: "bool.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -3046,8 +3046,8 @@ message BoolRules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -3058,7 +3058,7 @@ message BoolRules { extensions 1000 to max; } -// StringRules describes the constraints applied to `string` values These +// StringRules describes the rules applied to `string` values These // rules may also be applied to the `google.protobuf.StringValue` Well-Known-Type. message StringRules { // `const` requires the field value to exactly match the specified value. If @@ -3072,7 +3072,7 @@ message StringRules { // ``` optional string const = 1 [(predefined).cel = { id: "string.const" - expression: "this != rules.const ? 'value must equal `%s`'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal `%s`'.format([getField(rules, 'const')]) : ''" }]; // `len` dictates that the field value must have the specified @@ -3258,7 +3258,7 @@ message StringRules { // ``` repeated string in = 10 [(predefined).cel = { id: "string.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` specifies that the field value cannot be equal to any @@ -3275,11 +3275,17 @@ message StringRules { expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" }]; - // `WellKnown` rules provide advanced constraints against common string - // patterns + // `WellKnown` rules provide advanced rules against common string + // patterns. oneof well_known { - // `email` specifies that the field value must be a valid email address - // (addr-spec only) as defined by [RFC 5322](https://datatracker.ietf.org/doc/html/rfc5322#section-3.4.1). + // `email` specifies that the field value must be a valid email address, for + // example "foo@example.com". + // + // Conforms to the definition for a valid email address from the [HTML standard](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address). + // Note that this standard willfully deviates from [RFC 5322](https://datatracker.ietf.org/doc/html/rfc5322), + // which allows many unexpected forms of email addresses and will easily match + // a typographical error. + // // If the field value isn't a valid email address, an error message will be generated. // // ```proto @@ -3301,10 +3307,18 @@ message StringRules { } ]; - // `hostname` specifies that the field value must be a valid - // hostname as defined by [RFC 1034](https://datatracker.ietf.org/doc/html/rfc1034#section-3.5). This constraint doesn't support - // internationalized domain names (IDNs). If the field value isn't a - // valid hostname, an error message will be generated. + // `hostname` specifies that the field value must be a valid hostname, for + // example "foo.example.com". + // + // A valid hostname follows the rules below: + // - The name consists of one or more labels, separated by a dot ("."). + // - Each label can be 1 to 63 alphanumeric characters. + // - A label can contain hyphens ("-"), but must not start or end with a hyphen. + // - The right-most label must not be digits only. + // - The name can have a trailing dot—for example, "foo.example.com.". + // - The name can be 253 characters at most, excluding the optional trailing dot. + // + // If the field value isn't a valid hostname, an error message will be generated. // // ```proto // message MyString { @@ -3325,8 +3339,15 @@ message StringRules { } ]; - // `ip` specifies that the field value must be a valid IP - // (v4 or v6) address, without surrounding square brackets for IPv6 addresses. + // `ip` specifies that the field value must be a valid IP (v4 or v6) address. + // + // IPv4 addresses are expected in the dotted decimal format—for example, "192.168.5.21". + // IPv6 addresses are expected in their text representation—for example, "::1", + // or "2001:0DB8:ABCD:0012::0". + // + // Both formats are well-defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). + // Zone identifiers for IPv6 addresses (for example, "fe80::a%en1") are supported. + // // If the field value isn't a valid IP address, an error message will be // generated. // @@ -3349,9 +3370,9 @@ message StringRules { } ]; - // `ipv4` specifies that the field value must be a valid IPv4 - // address. If the field value isn't a valid IPv4 address, an error message - // will be generated. + // `ipv4` specifies that the field value must be a valid IPv4 address—for + // example "192.168.5.21". If the field value isn't a valid IPv4 address, an + // error message will be generated. // // ```proto // message MyString { @@ -3372,9 +3393,9 @@ message StringRules { } ]; - // `ipv6` specifies that the field value must be a valid - // IPv6 address, without surrounding square brackets. If the field value is - // not a valid IPv6 address, an error message will be generated. + // `ipv6` specifies that the field value must be a valid IPv6 address—for + // example "::1", or "d7a:115c:a1e0:ab12:4843:cd96:626b:430b". If the field + // value is not a valid IPv6 address, an error message will be generated. // // ```proto // message MyString { @@ -3395,8 +3416,11 @@ message StringRules { } ]; - // `uri` specifies that the field value must be a valid URI as defined by - // [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3). + // `uri` specifies that the field value must be a valid URI, for example + // "https://example.com/foo/bar?baz=quux#frag". + // + // URI is defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). + // Zone Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)). // // If the field value isn't a valid URI, an error message will be generated. // @@ -3419,11 +3443,13 @@ message StringRules { } ]; - // `uri_ref` specifies that the field value must be a valid URI Reference as - // defined by [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-4.1). + // `uri_ref` specifies that the field value must be a valid URI Reference—either + // a URI such as "https://example.com/foo/bar?baz=quux#frag", or a Relative + // Reference such as "./foo/bar?query". // - // A URI Reference is either a [URI](https://datatracker.ietf.org/doc/html/rfc3986#section-3), - // or a [Relative Reference](https://datatracker.ietf.org/doc/html/rfc3986#section-4.2). + // URI, URI Reference, and Relative Reference are defined in the internet + // standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). Zone + // Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)). // // If the field value isn't a valid URI Reference, an error message will be // generated. @@ -3441,10 +3467,9 @@ message StringRules { }]; // `address` specifies that the field value must be either a valid hostname - // as defined by [RFC 1034](https://datatracker.ietf.org/doc/html/rfc1034#section-3.5) - // (which doesn't support internationalized domain names or IDNs) or a valid - // IP (v4 or v6). If the field value isn't a valid hostname or IP, an error - // message will be generated. + // (for example, "example.com"), or a valid IP (v4 or v6) address (for example, + // "192.168.0.1", or "::1"). If the field value isn't a valid hostname or IP, + // an error message will be generated. // // ```proto // message MyString { @@ -3512,10 +3537,10 @@ message StringRules { } ]; - // `ip_with_prefixlen` specifies that the field value must be a valid IP (v4 or v6) - // address with prefix length. If the field value isn't a valid IP with prefix - // length, an error message will be generated. - // + // `ip_with_prefixlen` specifies that the field value must be a valid IP + // (v4 or v6) address with prefix length—for example, "192.168.5.21/16" or + // "2001:0DB8:ABCD:0012::F1/64". If the field value isn't a valid IP with + // prefix length, an error message will be generated. // // ```proto // message MyString { @@ -3537,9 +3562,9 @@ message StringRules { ]; // `ipv4_with_prefixlen` specifies that the field value must be a valid - // IPv4 address with prefix. - // If the field value isn't a valid IPv4 address with prefix length, - // an error message will be generated. + // IPv4 address with prefix length—for example, "192.168.5.21/16". If the + // field value isn't a valid IPv4 address with prefix length, an error + // message will be generated. // // ```proto // message MyString { @@ -3561,7 +3586,7 @@ message StringRules { ]; // `ipv6_with_prefixlen` specifies that the field value must be a valid - // IPv6 address with prefix length. + // IPv6 address with prefix length—for example, "2001:0DB8:ABCD:0012::F1/64". // If the field value is not a valid IPv6 address with prefix length, // an error message will be generated. // @@ -3584,10 +3609,15 @@ message StringRules { } ]; - // `ip_prefix` specifies that the field value must be a valid IP (v4 or v6) prefix. + // `ip_prefix` specifies that the field value must be a valid IP (v4 or v6) + // prefix—for example, "192.168.0.0/16" or "2001:0DB8:ABCD:0012::0/64". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the + // prefix, and the remaining 64 bits must be zero. + // // If the field value isn't a valid IP prefix, an error message will be - // generated. The prefix must have all zeros for the masked bits of the prefix (e.g., - // `127.0.0.0/16`, not `127.0.0.1/16`). + // generated. // // ```proto // message MyString { @@ -3609,9 +3639,14 @@ message StringRules { ]; // `ipv4_prefix` specifies that the field value must be a valid IPv4 - // prefix. If the field value isn't a valid IPv4 prefix, an error message - // will be generated. The prefix must have all zeros for the masked bits of - // the prefix (e.g., `127.0.0.0/16`, not `127.0.0.1/16`). + // prefix, for example "192.168.0.0/16". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "192.168.0.0/16" designates the left-most 16 bits for the prefix, + // and the remaining 16 bits must be zero. + // + // If the field value isn't a valid IPv4 prefix, an error message + // will be generated. // // ```proto // message MyString { @@ -3632,10 +3667,15 @@ message StringRules { } ]; - // `ipv6_prefix` specifies that the field value must be a valid IPv6 prefix. + // `ipv6_prefix` specifies that the field value must be a valid IPv6 prefix—for + // example, "2001:0DB8:ABCD:0012::0/64". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the + // prefix, and the remaining 64 bits must be zero. + // // If the field value is not a valid IPv6 prefix, an error message will be - // generated. The prefix must have all zeros for the masked bits of the prefix - // (e.g., `2001:db8::/48`, not `2001:db8::1/48`). + // generated. // // ```proto // message MyString { @@ -3656,10 +3696,16 @@ message StringRules { } ]; - // `host_and_port` specifies the field value must be a valid host and port - // pair. The host must be a valid hostname or IP address while the port - // must be in the range of 0-65535, inclusive. IPv6 addresses must be delimited - // with square brackets (e.g., `[::1]:1234`). + // `host_and_port` specifies that the field value must be valid host/port + // pair—for example, "example.com:8080". + // + // The host can be one of: + //- An IPv4 address in dotted decimal format—for example, "192.168.5.21". + //- An IPv6 address enclosed in square brackets—for example, "[2001:0DB8:ABCD:0012::F1]". + //- A hostname—for example, "example.com". + // + // The port is separated by a colon. It must be non-empty, with a decimal number + // in the range of 0-65535, inclusive. bool host_and_port = 32 [ (predefined).cel = { id: "string.host_and_port" @@ -3733,7 +3779,7 @@ message StringRules { optional bool strict = 25; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -3750,8 +3796,8 @@ message StringRules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -3773,7 +3819,7 @@ enum KnownRegex { KNOWN_REGEX_HTTP_HEADER_VALUE = 2; } -// BytesRules describe the constraints applied to `bytes` values. These rules +// BytesRules describe the rules applied to `bytes` values. These rules // may also be applied to the `google.protobuf.BytesValue` Well-Known-Type. message BytesRules { // `const` requires the field value to exactly match the specified bytes @@ -3787,7 +3833,7 @@ message BytesRules { // ``` optional bytes const = 1 [(predefined).cel = { id: "bytes.const" - expression: "this != rules.const ? 'value must be %x'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must be %x'.format([getField(rules, 'const')]) : ''" }]; // `len` requires the field value to have the specified length in bytes. @@ -3908,7 +3954,7 @@ message BytesRules { // ``` repeated bytes in = 8 [(predefined).cel = { id: "bytes.in" - expression: "dyn(rules)['in'].size() > 0 && !(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to be not equal to any of the specified @@ -3927,11 +3973,11 @@ message BytesRules { expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" }]; - // WellKnown rules provide advanced constraints against common byte + // WellKnown rules provide advanced rules against common byte // patterns oneof well_known { // `ip` ensures that the field `value` is a valid IP address (v4 or v6) in byte format. - // If the field value doesn't meet this constraint, an error message is generated. + // If the field value doesn't meet this rule, an error message is generated. // // ```proto // message MyBytes { @@ -3953,7 +3999,7 @@ message BytesRules { ]; // `ipv4` ensures that the field `value` is a valid IPv4 address in byte format. - // If the field value doesn't meet this constraint, an error message is generated. + // If the field value doesn't meet this rule, an error message is generated. // // ```proto // message MyBytes { @@ -3975,7 +4021,7 @@ message BytesRules { ]; // `ipv6` ensures that the field `value` is a valid IPv6 address in byte format. - // If the field value doesn't meet this constraint, an error message is generated. + // If the field value doesn't meet this rule, an error message is generated. // ```proto // message MyBytes { // // value must be a valid IPv6 address @@ -3997,7 +4043,7 @@ message BytesRules { } // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -4014,8 +4060,8 @@ message BytesRules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -4026,7 +4072,7 @@ message BytesRules { extensions 1000 to max; } -// EnumRules describe the constraints applied to `enum` values. +// EnumRules describe the rules applied to `enum` values. message EnumRules { // `const` requires the field value to exactly match the specified enum value. // If the field value doesn't match, an error message is generated. @@ -4045,7 +4091,7 @@ message EnumRules { // ``` optional int32 const = 1 [(predefined).cel = { id: "enum.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; // `defined_only` requires the field value to be one of the defined values for @@ -4083,7 +4129,7 @@ message EnumRules { // ``` repeated int32 in = 3 [(predefined).cel = { id: "enum.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` requires the field value to be not equal to any of the @@ -4108,7 +4154,7 @@ message EnumRules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -4129,8 +4175,8 @@ message EnumRules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -4141,7 +4187,7 @@ message EnumRules { extensions 1000 to max; } -// RepeatedRules describe the constraints applied to `repeated` values. +// RepeatedRules describe the rules applied to `repeated` values. message RepeatedRules { // `min_items` requires that this field must contain at least the specified // minimum number of items. @@ -4176,7 +4222,7 @@ message RepeatedRules { }]; // `unique` indicates that all elements in this field must - // be unique. This constraint is strictly applicable to scalar and enum + // be unique. This rule is strictly applicable to scalar and enum // types, with message types not being supported. // // ```proto @@ -4191,13 +4237,13 @@ message RepeatedRules { expression: "!rules.unique || this.unique()" }]; - // `items` details the constraints to be applied to each item + // `items` details the rules to be applied to each item // in the field. Even for repeated message fields, validation is executed // against each item unless skip is explicitly specified. // // ```proto // message MyRepeated { - // // The items in the field `value` must follow the specified constraints. + // // The items in the field `value` must follow the specified rules. // repeated string value = 1 [(buf.validate.field).repeated.items = { // string: { // min_len: 3 @@ -4206,11 +4252,11 @@ message RepeatedRules { // }]; // } // ``` - optional FieldConstraints items = 4; + optional FieldRules items = 4; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -4221,7 +4267,7 @@ message RepeatedRules { extensions 1000 to max; } -// MapRules describe the constraints applied to `map` values. +// MapRules describe the rules applied to `map` values. message MapRules { //Specifies the minimum number of key-value pairs allowed. If the field has // fewer key-value pairs than specified, an error message is generated. @@ -4251,11 +4297,11 @@ message MapRules { expression: "uint(this.size()) > rules.max_pairs ? 'map must be at most %d entries'.format([rules.max_pairs]) : ''" }]; - //Specifies the constraints to be applied to each key in the field. + //Specifies the rules to be applied to each key in the field. // // ```proto // message MyMap { - // // The keys in the field `value` must follow the specified constraints. + // // The keys in the field `value` must follow the specified rules. // map value = 1 [(buf.validate.field).map.keys = { // string: { // min_len: 3 @@ -4264,15 +4310,15 @@ message MapRules { // }]; // } // ``` - optional FieldConstraints keys = 4; + optional FieldRules keys = 4; - //Specifies the constraints to be applied to the value of each key in the + //Specifies the rules to be applied to the value of each key in the // field. Message values will still have their validations evaluated unless //skip is specified here. // // ```proto // message MyMap { - // // The values in the field `value` must follow the specified constraints. + // // The values in the field `value` must follow the specified rules. // map value = 1 [(buf.validate.field).map.values = { // string: { // min_len: 5 @@ -4281,11 +4327,11 @@ message MapRules { // }]; // } // ``` - optional FieldConstraints values = 5; + optional FieldRules values = 5; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -4296,7 +4342,7 @@ message MapRules { extensions 1000 to max; } -// AnyRules describe constraints applied exclusively to the `google.protobuf.Any` well-known type. +// AnyRules describe rules applied exclusively to the `google.protobuf.Any` well-known type. message AnyRules { // `in` requires the field's `type_url` to be equal to one of the //specified values. If it doesn't match any of the specified values, an error @@ -4321,7 +4367,7 @@ message AnyRules { repeated string not_in = 3; } -// DurationRules describe the constraints applied exclusively to the `google.protobuf.Duration` well-known type. +// DurationRules describe the rules applied exclusively to the `google.protobuf.Duration` well-known type. message DurationRules { // `const` dictates that the field must match the specified value of the `google.protobuf.Duration` type exactly. // If the field's value deviates from the specified value, an error message @@ -4335,7 +4381,7 @@ message DurationRules { // ``` optional google.protobuf.Duration const = 2 [(predefined).cel = { id: "duration.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // `lt` stipulates that the field must be less than the specified value of the `google.protobuf.Duration` type, @@ -4488,7 +4534,7 @@ message DurationRules { // ``` repeated google.protobuf.Duration in = 7 [(predefined).cel = { id: "duration.in" - expression: "!(this in dyn(rules)['in']) ? 'value must be in list %s'.format([dyn(rules)['in']]) : ''" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" }]; // `not_in` denotes that the field must not be equal to @@ -4508,7 +4554,7 @@ message DurationRules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -4525,8 +4571,8 @@ message DurationRules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -4537,7 +4583,7 @@ message DurationRules { extensions 1000 to max; } -// TimestampRules describe the constraints applied exclusively to the `google.protobuf.Timestamp` well-known type. +// TimestampRules describe the rules applied exclusively to the `google.protobuf.Timestamp` well-known type. message TimestampRules { // `const` dictates that this field, of the `google.protobuf.Timestamp` type, must exactly match the specified value. If the field value doesn't correspond to the specified timestamp, an error message will be generated. // @@ -4549,7 +4595,7 @@ message TimestampRules { // ``` optional google.protobuf.Timestamp const = 2 [(predefined).cel = { id: "timestamp.const" - expression: "this != rules.const ? 'value must equal %s'.format([rules.const]) : ''" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" }]; oneof less_than { // requires the duration field value to be less than the specified value (field < value). If the field value doesn't meet the required conditions, an error message is generated. @@ -4726,7 +4772,7 @@ message TimestampRules { }]; // `example` specifies values that the field may have. These values SHOULD - // conform to other constraints. `example` values will not impact validation + // conform to other rules. `example` values will not impact validation // but may be used as helpful guidance on how to populate the given field. // // ```proto @@ -4744,8 +4790,8 @@ message TimestampRules { }]; // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field constraints that can then be - // set on the field options of other fields to apply field constraints. + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. // Extension numbers 1000 to 99999 are reserved for extension numbers that are // defined in the [Protobuf Global Extension Registry][1]. Extension numbers // above this range are reserved for extension numbers that are not explicitly @@ -4757,7 +4803,7 @@ message TimestampRules { } // `Violations` is a collection of `Violation` messages. This message type is returned by -// protovalidate when a proto message fails to meet the requirements set by the `Constraint` validation rules. +// protovalidate when a proto message fails to meet the requirements set by the `Rule` validation rules. // Each individual violation is represented by a `Violation` message. message Violations { // `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected. @@ -4765,14 +4811,14 @@ message Violations { } // `Violation` represents a single instance where a validation rule, expressed -// as a `Constraint`, was not met. It provides information about the field that -// caused the violation, the specific constraint that wasn't fulfilled, and a +// as a `Rule`, was not met. It provides information about the field that +// caused the violation, the specific rule that wasn't fulfilled, and a // human-readable error message. // // ```json // { // "fieldPath": "bar", -// "constraintId": "foo.bar", +// "ruleId": "foo.bar", // "message": "bar must be greater than 0" // } // ``` @@ -4798,9 +4844,9 @@ message Violation { // ``` optional FieldPath field = 5; - // `rule` is a machine-readable path that points to the specific constraint rule that failed validation. - // This will be a nested field starting from the FieldConstraints of the field that failed validation. - // For custom constraints, this will provide the path of the constraint, e.g. `cel[0]`. + // `rule` is a machine-readable path that points to the specific rule rule that failed validation. + // This will be a nested field starting from the FieldRules of the field that failed validation. + // For custom rules, this will provide the path of the rule, e.g. `cel[0]`. // // For example, consider the following message: // @@ -4808,7 +4854,7 @@ message Violation { // message Message { // bool a = 1 [(buf.validate.field).required = true]; // bool b = 2 [(buf.validate.field).cel = { - // id: "custom_constraint", + // id: "custom_rule", // expression: "!this ? 'b must be true': ''" // }] // } @@ -4828,12 +4874,12 @@ message Violation { // ``` optional FieldPath rule = 6; - // `constraint_id` is the unique identifier of the `Constraint` that was not fulfilled. - // This is the same `id` that was specified in the `Constraint` message, allowing easy tracing of which rule was violated. - optional string constraint_id = 2; + // `rule_id` is the unique identifier of the `Rule` that was not fulfilled. + // This is the same `id` that was specified in the `Rule` message, allowing easy tracing of which rule was violated. + optional string rule_id = 2; // `message` is a human-readable error message that describes the nature of the violation. - // This can be the default error message from the violated `Constraint`, or it can be a custom message that gives more context about the violation. + // This can be the default error message from the violated `Rule`, or it can be a custom message that gives more context about the violation. optional string message = 3; // `for_key` indicates whether the violation was caused by a map key, rather than a value. From a0e9c0cdef7a49409749bed8b60e43ea3f7cffc0 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 22 May 2025 15:14:19 +0800 Subject: [PATCH 022/158] refactor(start): rewrite start command with runtime - Remove RandomID function and use runtime-generated service ID - Load runtime configuration and create app instance - Use gRPC Gateway for HTTP transport - Refactor wire.go and wire_gen.go for new runtime-based approach - Update service.pb.go and service.pb.validate.go for new message structure --- README.md | 47 + cmd/internal/start/start.go | 33 +- cmd/internal/start/wire.go | 3 +- cmd/system/main.go | 89 +- cmd/system/wire.go | 11 +- cmd/system/wire_gen.go | 58 +- contrib/security/authn/jwt/authn.go | 9 +- go.mod | 34 +- go.sum | 60 +- internal/configs/auth_config.pb.go | 48 +- internal/configs/auth_config.pb.validate.go | 2 +- internal/configs/bootstrap.pb.go | 228 +-- internal/configs/bootstrap.pb.validate.go | 41 +- internal/configs/bootstrap.proto | 27 +- internal/configs/captcha.pb.go | 55 +- internal/configs/captcha.pb.validate.go | 2 +- internal/configs/root_user.pb.go | 96 +- internal/configs/root_user.pb.validate.go | 2 +- internal/configs/server.pb.go | 71 +- internal/configs/server.pb.validate.go | 2 +- internal/configs/services/service.pb.go | 87 +- .../configs/services/service.pb.validate.go | 4 +- .../casbin/dal => data}/casbin-adapter.dal.go | 8 +- internal/data/data.go | 104 + .../dal => data}/entity/ent/casbinrule.go | 2 +- .../entity/ent/casbinrule/casbinrule.go | 0 .../entity/ent/casbinrule/where.go | 2 +- .../entity/ent/casbinrule_create.go | 2 +- .../entity/ent/casbinrule_delete.go | 4 +- .../entity/ent/casbinrule_query.go | 4 +- .../entity/ent/casbinrule_update.go | 4 +- .../system/dal => data}/entity/ent/client.go | 206 +- .../casbin/dal => data}/entity/ent/crud.go | 0 .../dal => data}/entity/ent/database.go | 5 + .../dal => data}/entity/ent/department.go | 2 +- .../entity/ent/department_create.go | 8 +- .../entity/ent/department_delete.go | 4 +- .../entity/ent/department_query.go | 10 +- .../entity/ent/department_update.go | 10 +- .../system/dal => data}/entity/ent/ent.go | 26 +- .../entity/ent/enttest/enttest.go | 6 +- internal/data/entity/ent/generate.go | 8 + .../dal => data}/entity/ent/hook/hook.go | 14 +- .../entity/ent/intercept/intercept.go | 58 +- internal/data/entity/ent/internal/schema.go | 9 + .../entity/ent/migrate/migrate.go | 0 .../dal => data}/entity/ent/migrate/schema.go | 18 + .../dal => data}/entity/ent/mutation.go | 678 ++++++- .../entity/ent/mutation_fields.go | 100 +- .../dal => data}/entity/ent/permission.go | 2 +- .../entity/ent/permission_create.go | 14 +- .../entity/ent/permission_delete.go | 4 +- .../entity/ent/permission_query.go | 16 +- .../entity/ent/permission_update.go | 16 +- .../entity/ent/permissionresource.go | 6 +- .../entity/ent/permissionresource_create.go | 6 +- .../entity/ent/permissionresource_delete.go | 4 +- .../entity/ent/permissionresource_query.go | 8 +- .../entity/ent/permissionresource_update.go | 8 +- .../dal => data}/entity/ent/position.go | 4 +- .../entity/ent/position_create.go | 12 +- .../entity/ent/position_delete.go | 4 +- .../dal => data}/entity/ent/position_query.go | 14 +- .../entity/ent/position_update.go | 14 +- .../entity/ent/positionpermission.go | 6 +- .../entity/ent/positionpermission_create.go | 6 +- .../entity/ent/positionpermission_delete.go | 4 +- .../entity/ent/positionpermission_query.go | 8 +- .../entity/ent/positionpermission_update.go | 8 +- .../entity/ent/predicate/predicate.go | 3 + .../dal => data}/entity/ent/resource.go | 2 +- .../entity/ent/resource_create.go | 6 +- .../entity/ent/resource_delete.go | 4 +- .../dal => data}/entity/ent/resource_query.go | 8 +- .../entity/ent/resource_update.go | 8 +- .../system/dal => data}/entity/ent/role.go | 2 +- .../dal => data}/entity/ent/role_create.go | 10 +- .../dal => data}/entity/ent/role_delete.go | 4 +- .../dal => data}/entity/ent/role_query.go | 12 +- .../dal => data}/entity/ent/role_update.go | 12 +- .../dal => data}/entity/ent/rolepermission.go | 6 +- .../entity/ent/rolepermission_create.go | 6 +- .../entity/ent/rolepermission_delete.go | 4 +- .../entity/ent/rolepermission_query.go | 8 +- .../entity/ent/rolepermission_update.go | 8 +- .../system/dal => data}/entity/ent/runtime.go | 2 +- .../entity/ent/runtime/runtime.go | 60 +- .../entity/ent/schema/audit/service.go | 4 +- .../entity/ent/schema/casbinrule.go | 0 .../entity/ent/schema/department.go | 0 .../dal => data}/entity/ent/schema/hooks.go | 5 +- .../entity/ent/schema/permission.go | 0 .../entity/ent/schema/permissionresource.go | 0 .../entity/ent/schema/position.go | 0 .../entity/ent/schema/positionpermission.go | 0 .../entity/ent/schema/resource.go | 0 .../dal => data}/entity/ent/schema/role.go | 2 +- .../entity/ent/schema/rolepermission.go | 0 .../entity/ent/schema/softdelete.go | 6 +- .../entity/ent/schema/types/constants.go | 0 .../entity/ent/schema/types/structs.go | 0 .../dal => data}/entity/ent/schema/user.go | 6 +- .../entity/ent/schema/userdepartment.go | 0 .../entity/ent/schema/userposition.go | 0 .../entity/ent/schema/userrole.go | 0 .../dal => data}/entity/ent/template/crud.tpl | 0 .../entity/ent/template/crud_create.tpl | 0 .../entity/ent/template/crud_query.tpl | 0 .../entity/ent/template/crud_update.tpl | 0 .../entity/ent/template/crud_update_one.tpl | 0 .../entity/ent/template/database.tpl | 0 .../entity/ent/template/mutation_fields.tpl | 0 .../entity/ent/template/type_meta_fields.tpl | 0 .../entity/ent/template/type_meta_where.tpl | 0 .../system/dal => data}/entity/ent/tx.go | 5 +- .../system/dal => data}/entity/ent/user.go | 2 +- .../dal => data}/entity/ent/user_create.go | 14 +- .../dal => data}/entity/ent/user_delete.go | 4 +- .../dal => data}/entity/ent/user_query.go | 16 +- .../dal => data}/entity/ent/user_update.go | 16 +- .../dal => data}/entity/ent/userdepartment.go | 6 +- .../entity/ent/userdepartment_create.go | 6 +- .../entity/ent/userdepartment_delete.go | 4 +- .../entity/ent/userdepartment_query.go | 8 +- .../entity/ent/userdepartment_update.go | 8 +- .../dal => data}/entity/ent/userposition.go | 6 +- .../entity/ent/userposition_create.go | 6 +- .../entity/ent/userposition_delete.go | 4 +- .../entity/ent/userposition_query.go | 8 +- .../entity/ent/userposition_update.go | 8 +- .../dal => data}/entity/ent/userrole.go | 6 +- .../entity/ent/userrole_create.go | 6 +- .../entity/ent/userrole_delete.go | 4 +- .../dal => data}/entity/ent/userrole_query.go | 8 +- .../entity/ent/userrole_update.go | 8 +- internal/loader/application.go | 53 +- internal/loader/bootstrap.go | 110 +- internal/loader/bootstrap_test.go | 25 +- internal/loader/config.go | 55 +- internal/loader/config_manager.go | 62 - internal/loader/file.go | 15 + internal/loader/{loader.go => load.go} | 65 +- internal/loader/setup.go | 27 - internal/mods/agent/http.go | 2 +- internal/mods/auth/biz/README.md | 3 + internal/mods/auth/biz/auth.biz.go | 61 + internal/mods/{casbin => auth}/biz/biz.go | 12 +- internal/mods/auth/biz/casbin.biz.go | 109 + internal/mods/auth/biz/login.biz.go | 73 + internal/mods/auth/dal/README.md | 3 + internal/mods/auth/dal/auth.dal.go | 181 ++ internal/mods/auth/dal/casbin.dal.go | 115 ++ internal/mods/auth/dal/dal.go | 567 ++++++ internal/mods/auth/dal/login.dal.go | 440 ++++ internal/mods/casbin/dal/dal.go | 20 - internal/mods/casbin/dal/entity/ent/client.go | 341 ---- .../mods/casbin/dal/entity/ent/database.go | 108 - internal/mods/casbin/dal/entity/ent/ent.go | 608 ------ .../casbin/dal/entity/ent/enttest/enttest.go | 85 - .../mods/casbin/dal/entity/ent/generate.go | 8 - .../mods/casbin/dal/entity/ent/hook/hook.go | 198 -- .../dal/entity/ent/intercept/intercept.go | 150 -- .../casbin/dal/entity/ent/internal/schema.go | 9 - .../casbin/dal/entity/ent/migrate/schema.go | 35 - .../mods/casbin/dal/entity/ent/mutation.go | 677 ------- .../casbin/dal/entity/ent/mutation_fields.go | 83 - .../dal/entity/ent/predicate/predicate.go | 10 - .../mods/casbin/dal/entity/ent/runtime.go | 44 - .../casbin/dal/entity/ent/runtime/runtime.go | 10 - .../dal/entity/ent/template/database.tpl | 116 -- .../entity/ent/template/mutation_fields.tpl | 116 -- internal/mods/casbin/dal/entity/ent/tx.go | 210 -- internal/mods/casbin/dto/casbin-adapter.go | 26 - internal/mods/casbin/server/README.md | 4 - internal/mods/casbin/server/agent.go | 24 - internal/mods/casbin/server/gins.go | 75 - internal/mods/casbin/server/grpc.go | 22 - internal/mods/casbin/server/http.go | 22 - internal/mods/casbin/server/server.go | 178 -- .../mods/casbin/service/casbin-source.grpc.go | 82 - internal/mods/casbin/service/service.go | 42 - internal/mods/system/biz/auth.biz.go | 11 +- internal/mods/system/biz/resource.biz.go | 2 +- internal/mods/system/dal/auth.dal.go | 4 +- internal/mods/system/dal/casbin.dal.go | 2 +- internal/mods/system/dal/dal.go | 13 +- internal/mods/system/dal/entity/ent/crud.go | 3 - .../dal/entity/ent/department/department.go | 358 ---- .../system/dal/entity/ent/department/where.go | 726 ------- .../mods/system/dal/entity/ent/generate.go | 8 - .../system/dal/entity/ent/internal/schema.go | 9 - .../system/dal/entity/ent/migrate/migrate.go | 96 - .../dal/entity/ent/permission/permission.go | 403 ---- .../system/dal/entity/ent/permission/where.go | 609 ------ .../permissionresource/permissionresource.go | 171 -- .../entity/ent/permissionresource/where.go | 166 -- .../dal/entity/ent/position/position.go | 323 --- .../system/dal/entity/ent/position/where.go | 511 ----- .../positionpermission/positionpermission.go | 171 -- .../entity/ent/positionpermission/where.go | 166 -- .../dal/entity/ent/resource/resource.go | 427 ---- .../system/dal/entity/ent/resource/where.go | 1218 ----------- .../mods/system/dal/entity/ent/role/role.go | 322 --- .../mods/system/dal/entity/ent/role/where.go | 598 ------ .../ent/rolepermission/rolepermission.go | 171 -- .../dal/entity/ent/rolepermission/where.go | 166 -- .../system/dal/entity/ent/template/crud.tpl | 40 - .../dal/entity/ent/template/crud_create.tpl | 34 - .../dal/entity/ent/template/crud_query.tpl | 48 - .../dal/entity/ent/template/crud_update.tpl | 33 - .../entity/ent/template/crud_update_one.tpl | 48 - .../entity/ent/template/type_meta_fields.tpl | 67 - .../mods/system/dal/entity/ent/user/user.go | 625 ------ .../mods/system/dal/entity/ent/user/where.go | 1794 ----------------- .../ent/userdepartment/userdepartment.go | 171 -- .../dal/entity/ent/userdepartment/where.go | 166 -- .../entity/ent/userposition/userposition.go | 171 -- .../dal/entity/ent/userposition/where.go | 166 -- .../dal/entity/ent/userrole/userrole.go | 171 -- .../system/dal/entity/ent/userrole/where.go | 166 -- internal/mods/system/dal/login.dal.go | 36 +- internal/mods/system/dal/permission.dal.go | 4 +- internal/mods/system/dal/personal.dal.go | 6 +- internal/mods/system/dal/resource.dal.go | 4 +- internal/mods/system/dal/role.dal.go | 4 +- internal/mods/system/dal/user.dal.go | 4 +- internal/mods/system/dto/dto.go | 6 +- internal/mods/system/dto/resource_type.go | 2 +- internal/mods/system/dto/role.go | 2 +- internal/mods/system/dto/user.go | 2 +- internal/mods/system/server/server.go | 11 +- 231 files changed, 3677 insertions(+), 14845 deletions(-) rename internal/{mods/casbin/dal => data}/casbin-adapter.dal.go (98%) create mode 100644 internal/data/data.go rename internal/{mods/casbin/dal => data}/entity/ent/casbinrule.go (98%) rename internal/{mods/casbin/dal => data}/entity/ent/casbinrule/casbinrule.go (100%) rename internal/{mods/casbin/dal => data}/entity/ent/casbinrule/where.go (99%) rename internal/{mods/casbin/dal => data}/entity/ent/casbinrule_create.go (99%) rename internal/{mods/casbin/dal => data}/entity/ent/casbinrule_delete.go (93%) rename internal/{mods/casbin/dal => data}/entity/ent/casbinrule_query.go (99%) rename internal/{mods/casbin/dal => data}/entity/ent/casbinrule_update.go (98%) rename internal/{mods/system/dal => data}/entity/ent/client.go (93%) rename internal/{mods/casbin/dal => data}/entity/ent/crud.go (100%) rename internal/{mods/system/dal => data}/entity/ent/database.go (96%) rename internal/{mods/system/dal => data}/entity/ent/department.go (99%) rename internal/{mods/system/dal => data}/entity/ent/department_create.go (98%) rename internal/{mods/system/dal => data}/entity/ent/department_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/department_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/department_update.go (99%) rename internal/{mods/system/dal => data}/entity/ent/ent.go (94%) rename internal/{mods/system/dal => data}/entity/ent/enttest/enttest.go (88%) create mode 100644 internal/data/entity/ent/generate.go rename internal/{mods/system/dal => data}/entity/ent/hook/hook.go (95%) rename internal/{mods/system/dal => data}/entity/ent/intercept/intercept.go (88%) create mode 100644 internal/data/entity/ent/internal/schema.go rename internal/{mods/casbin/dal => data}/entity/ent/migrate/migrate.go (100%) rename internal/{mods/system/dal => data}/entity/ent/migrate/schema.go (97%) rename internal/{mods/system/dal => data}/entity/ent/mutation.go (94%) rename internal/{mods/system/dal => data}/entity/ent/mutation_fields.go (90%) rename internal/{mods/system/dal => data}/entity/ent/permission.go (99%) rename internal/{mods/system/dal => data}/entity/ent/permission_create.go (97%) rename internal/{mods/system/dal => data}/entity/ent/permission_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/permission_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/permission_update.go (98%) rename internal/{mods/system/dal => data}/entity/ent/permissionresource.go (95%) rename internal/{mods/system/dal => data}/entity/ent/permissionresource_create.go (97%) rename internal/{mods/system/dal => data}/entity/ent/permissionresource_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/permissionresource_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/permissionresource_update.go (98%) rename internal/{mods/system/dal => data}/entity/ent/position.go (98%) rename internal/{mods/system/dal => data}/entity/ent/position_create.go (96%) rename internal/{mods/system/dal => data}/entity/ent/position_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/position_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/position_update.go (98%) rename internal/{mods/system/dal => data}/entity/ent/positionpermission.go (95%) rename internal/{mods/system/dal => data}/entity/ent/positionpermission_create.go (97%) rename internal/{mods/system/dal => data}/entity/ent/positionpermission_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/positionpermission_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/positionpermission_update.go (98%) rename internal/{mods/system/dal => data}/entity/ent/predicate/predicate.go (92%) rename internal/{mods/system/dal => data}/entity/ent/resource.go (99%) rename internal/{mods/system/dal => data}/entity/ent/resource_create.go (99%) rename internal/{mods/system/dal => data}/entity/ent/resource_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/resource_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/resource_update.go (99%) rename internal/{mods/system/dal => data}/entity/ent/role.go (99%) rename internal/{mods/system/dal => data}/entity/ent/role_create.go (97%) rename internal/{mods/system/dal => data}/entity/ent/role_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/role_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/role_update.go (98%) rename internal/{mods/system/dal => data}/entity/ent/rolepermission.go (95%) rename internal/{mods/system/dal => data}/entity/ent/rolepermission_create.go (97%) rename internal/{mods/system/dal => data}/entity/ent/rolepermission_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/rolepermission_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/rolepermission_update.go (98%) rename internal/{mods/system/dal => data}/entity/ent/runtime.go (64%) rename internal/{mods/system/dal => data}/entity/ent/runtime/runtime.go (92%) rename internal/{mods/system/dal => data}/entity/ent/schema/audit/service.go (82%) rename internal/{mods/casbin/dal => data}/entity/ent/schema/casbinrule.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/department.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/hooks.go (82%) rename internal/{mods/system/dal => data}/entity/ent/schema/permission.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/permissionresource.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/position.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/positionpermission.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/resource.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/role.go (96%) rename internal/{mods/system/dal => data}/entity/ent/schema/rolepermission.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/softdelete.go (88%) rename internal/{mods/system/dal => data}/entity/ent/schema/types/constants.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/types/structs.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/user.go (95%) rename internal/{mods/system/dal => data}/entity/ent/schema/userdepartment.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/userposition.go (100%) rename internal/{mods/system/dal => data}/entity/ent/schema/userrole.go (100%) rename internal/{mods/casbin/dal => data}/entity/ent/template/crud.tpl (100%) rename internal/{mods/casbin/dal => data}/entity/ent/template/crud_create.tpl (100%) rename internal/{mods/casbin/dal => data}/entity/ent/template/crud_query.tpl (100%) rename internal/{mods/casbin/dal => data}/entity/ent/template/crud_update.tpl (100%) rename internal/{mods/casbin/dal => data}/entity/ent/template/crud_update_one.tpl (100%) rename internal/{mods/system/dal => data}/entity/ent/template/database.tpl (100%) rename internal/{mods/system/dal => data}/entity/ent/template/mutation_fields.tpl (100%) rename internal/{mods/casbin/dal => data}/entity/ent/template/type_meta_fields.tpl (100%) rename internal/{mods/system/dal => data}/entity/ent/template/type_meta_where.tpl (100%) rename internal/{mods/system/dal => data}/entity/ent/tx.go (97%) rename internal/{mods/system/dal => data}/entity/ent/user.go (99%) rename internal/{mods/system/dal => data}/entity/ent/user_create.go (98%) rename internal/{mods/system/dal => data}/entity/ent/user_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/user_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/user_update.go (99%) rename internal/{mods/system/dal => data}/entity/ent/userdepartment.go (95%) rename internal/{mods/system/dal => data}/entity/ent/userdepartment_create.go (97%) rename internal/{mods/system/dal => data}/entity/ent/userdepartment_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/userdepartment_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/userdepartment_update.go (98%) rename internal/{mods/system/dal => data}/entity/ent/userposition.go (95%) rename internal/{mods/system/dal => data}/entity/ent/userposition_create.go (97%) rename internal/{mods/system/dal => data}/entity/ent/userposition_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/userposition_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/userposition_update.go (98%) rename internal/{mods/system/dal => data}/entity/ent/userrole.go (95%) rename internal/{mods/system/dal => data}/entity/ent/userrole_create.go (97%) rename internal/{mods/system/dal => data}/entity/ent/userrole_delete.go (93%) rename internal/{mods/system/dal => data}/entity/ent/userrole_query.go (98%) rename internal/{mods/system/dal => data}/entity/ent/userrole_update.go (98%) delete mode 100644 internal/loader/config_manager.go rename internal/loader/{loader.go => load.go} (58%) delete mode 100644 internal/loader/setup.go create mode 100644 internal/mods/auth/biz/README.md create mode 100644 internal/mods/auth/biz/auth.biz.go rename internal/mods/{casbin => auth}/biz/biz.go (79%) create mode 100644 internal/mods/auth/biz/casbin.biz.go create mode 100644 internal/mods/auth/biz/login.biz.go create mode 100644 internal/mods/auth/dal/README.md create mode 100644 internal/mods/auth/dal/auth.dal.go create mode 100644 internal/mods/auth/dal/casbin.dal.go create mode 100644 internal/mods/auth/dal/dal.go create mode 100644 internal/mods/auth/dal/login.dal.go delete mode 100644 internal/mods/casbin/dal/dal.go delete mode 100644 internal/mods/casbin/dal/entity/ent/client.go delete mode 100644 internal/mods/casbin/dal/entity/ent/database.go delete mode 100644 internal/mods/casbin/dal/entity/ent/ent.go delete mode 100644 internal/mods/casbin/dal/entity/ent/enttest/enttest.go delete mode 100644 internal/mods/casbin/dal/entity/ent/generate.go delete mode 100644 internal/mods/casbin/dal/entity/ent/hook/hook.go delete mode 100644 internal/mods/casbin/dal/entity/ent/intercept/intercept.go delete mode 100644 internal/mods/casbin/dal/entity/ent/internal/schema.go delete mode 100644 internal/mods/casbin/dal/entity/ent/migrate/schema.go delete mode 100644 internal/mods/casbin/dal/entity/ent/mutation.go delete mode 100644 internal/mods/casbin/dal/entity/ent/mutation_fields.go delete mode 100644 internal/mods/casbin/dal/entity/ent/predicate/predicate.go delete mode 100644 internal/mods/casbin/dal/entity/ent/runtime.go delete mode 100644 internal/mods/casbin/dal/entity/ent/runtime/runtime.go delete mode 100644 internal/mods/casbin/dal/entity/ent/template/database.tpl delete mode 100644 internal/mods/casbin/dal/entity/ent/template/mutation_fields.tpl delete mode 100644 internal/mods/casbin/dal/entity/ent/tx.go delete mode 100644 internal/mods/casbin/dto/casbin-adapter.go delete mode 100644 internal/mods/casbin/server/README.md delete mode 100644 internal/mods/casbin/server/agent.go delete mode 100644 internal/mods/casbin/server/gins.go delete mode 100644 internal/mods/casbin/server/grpc.go delete mode 100644 internal/mods/casbin/server/http.go delete mode 100644 internal/mods/casbin/server/server.go delete mode 100644 internal/mods/casbin/service/casbin-source.grpc.go delete mode 100644 internal/mods/casbin/service/service.go delete mode 100644 internal/mods/system/dal/entity/ent/crud.go delete mode 100644 internal/mods/system/dal/entity/ent/department/department.go delete mode 100644 internal/mods/system/dal/entity/ent/department/where.go delete mode 100644 internal/mods/system/dal/entity/ent/generate.go delete mode 100644 internal/mods/system/dal/entity/ent/internal/schema.go delete mode 100644 internal/mods/system/dal/entity/ent/migrate/migrate.go delete mode 100644 internal/mods/system/dal/entity/ent/permission/permission.go delete mode 100644 internal/mods/system/dal/entity/ent/permission/where.go delete mode 100644 internal/mods/system/dal/entity/ent/permissionresource/permissionresource.go delete mode 100644 internal/mods/system/dal/entity/ent/permissionresource/where.go delete mode 100644 internal/mods/system/dal/entity/ent/position/position.go delete mode 100644 internal/mods/system/dal/entity/ent/position/where.go delete mode 100644 internal/mods/system/dal/entity/ent/positionpermission/positionpermission.go delete mode 100644 internal/mods/system/dal/entity/ent/positionpermission/where.go delete mode 100644 internal/mods/system/dal/entity/ent/resource/resource.go delete mode 100644 internal/mods/system/dal/entity/ent/resource/where.go delete mode 100644 internal/mods/system/dal/entity/ent/role/role.go delete mode 100644 internal/mods/system/dal/entity/ent/role/where.go delete mode 100644 internal/mods/system/dal/entity/ent/rolepermission/rolepermission.go delete mode 100644 internal/mods/system/dal/entity/ent/rolepermission/where.go delete mode 100644 internal/mods/system/dal/entity/ent/template/crud.tpl delete mode 100644 internal/mods/system/dal/entity/ent/template/crud_create.tpl delete mode 100644 internal/mods/system/dal/entity/ent/template/crud_query.tpl delete mode 100644 internal/mods/system/dal/entity/ent/template/crud_update.tpl delete mode 100644 internal/mods/system/dal/entity/ent/template/crud_update_one.tpl delete mode 100644 internal/mods/system/dal/entity/ent/template/type_meta_fields.tpl delete mode 100644 internal/mods/system/dal/entity/ent/user/user.go delete mode 100644 internal/mods/system/dal/entity/ent/user/where.go delete mode 100644 internal/mods/system/dal/entity/ent/userdepartment/userdepartment.go delete mode 100644 internal/mods/system/dal/entity/ent/userdepartment/where.go delete mode 100644 internal/mods/system/dal/entity/ent/userposition/userposition.go delete mode 100644 internal/mods/system/dal/entity/ent/userposition/where.go delete mode 100644 internal/mods/system/dal/entity/ent/userrole/userrole.go delete mode 100644 internal/mods/system/dal/entity/ent/userrole/where.go diff --git a/README.md b/README.md index 23370476..28956bbf 100644 --- a/README.md +++ b/README.md @@ -80,3 +80,50 @@ architecture. ```bash go run main.go start ``` + +# SourceTree + +```plainText +. +├── api/ # API interface definitions +│ ├── http/ # HTTP interface +│ ├── multiplatform/ # Cross-platform interfaces +│ ├── proto/ # Protocol Buffer definitions +│ └── services/ # Service implementations +├── cmd/ # CLI tool implementations +│ ├── internal/ # Core CLI logic +│ ├── multiplatform/ # Platform-agnostic commands +│ ├── root.go # Root command definitions +│ └── system/ # System management commands +├── data/ # Data storage +├── generate.go # Code generation utilities +├── helpers/ # Utility modules +│ ├── command/ # CLI toolkit +│ ├── ent/ # Entity management +│ ├── errors/ # Error handling framework +│ ├── protobuf/ # Protocol Buffer utilities +│ └── resp/ # Response handlers +├── internal/ # Core internal components +│ ├── configs/ # Configuration management +│ ├── generate.go # Internal code generators +│ ├── loader/ # Resource loading system +│ └── mods/ # Modular components +├── main.go # Application entry point +├── Makefile # Build automation scripts +├── resources/ # Resource files +│ ├── configs/ # Configuration templates +│ └── docs/ # Documentation assets +├── third_party/ # External dependencies +│ ├── auth/ # Authentication systems +│ ├── codegen/ # Code generation tools +│ ├── config/ # Configuration management +│ ├── errors/ # Error handling libraries +│ ├── proto/ # Protocol Buffer extensions +│ ├── google/ # Google API integrations +│ ├── pagination/ # Pagination utilities +│ ├── token/ # Token management +│ └── validation/ # Validation frameworks +└── go.mod # Go module dependencies +``` + + diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index 338d576a..d3a4b290 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -7,20 +7,19 @@ package start import ( "context" - "fmt" - "os" "syscall" - "time" "github.com/gin-gonic/gin" "github.com/go-kratos/kratos/v2" + transhttp "github.com/go-kratos/kratos/v2/transport/http" + gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" _ "github.com/origadmin/contrib/consul/config" _ "github.com/origadmin/contrib/consul/registry" _ "github.com/origadmin/contrib/database" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/registry" - "github.com/origadmin/runtime/service" "github.com/spf13/cobra" "origadmin/application/admin/internal/loader" @@ -50,16 +49,7 @@ var cmd = &cobra.Command{ RunE: startCommandRun, } -func RandomID() string { - id, err := os.Hostname() - if err != nil { - id = "unknown" - } - return id + "." + fmt.Sprintf("%08d", time.Now().UnixNano()%(1<<32)) -} func init() { - //fmt.Println("total env: ", os.Environ(), len(os.Environ())) - flags.SetServiceID(RandomID()) flags.SetServiceInfo(Name, Version) } @@ -75,20 +65,23 @@ func Cmd() *cobra.Command { return cmd } -// 启动时使用分离的配置 func startCommandRun(cmd *cobra.Command, args []string) error { - // 获取纯净配置 - bs, err := loader.LoadBootstrap(config) + r, err := runtime.Load(flags, func(options *runtime.Options) { + // Set your runtime options. + }) if err != nil { return err } - // 显式创建注册器(按需) var registrar registry.KRegistrar if flags.IsMainService() { - registrar, _ = registry.NewConsulRegistrar(...) + registrar, _ = registry.NewConsulRegistrar() } + buildInjectors() + + r.CreateApp(cmd.Context()) + // 组合使用配置和服务 appInstance := loader.NewApp(cmd.Context(), loader.AppOptions{ Name: bs.ServiceName, @@ -108,6 +101,10 @@ func NewApp(ctx context.Context, injector *loader.InjectorClient) *kratos.App { kratos.Logger(injector.Logger), kratos.Server(injector.Server), } + mux := gwruntime.NewServeMux() + srv := transhttp.NewServer() + srv.Handler = mux + kratos.Server(srv) if flags.Env() == "release" { gin.SetMode(gin.ReleaseMode) diff --git a/cmd/internal/start/wire.go b/cmd/internal/start/wire.go index a62ab1c7..cf9681d2 100644 --- a/cmd/internal/start/wire.go +++ b/cmd/internal/start/wire.go @@ -13,7 +13,6 @@ import ( "github.com/go-kratos/kratos/v2" "github.com/google/wire" - "github.com/origadmin/runtime/log" "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/loader" @@ -22,7 +21,7 @@ import ( ) // buildInjectors init kratos application. -func buildInjectors(context.Context, *configs.Bootstrap, log.KLogger) (*kratos.App, func(), error) { +func buildInjectors(context.Context, *configs.Bootstrap) (*kratos.App, func(), error) { panic(wire.Build( loader.ProviderSet, agent.ProviderSet, diff --git a/cmd/system/main.go b/cmd/system/main.go index c78db6e5..5056c089 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -9,16 +9,14 @@ import ( "flag" "fmt" "log/slog" - "syscall" "github.com/go-kratos/kratos/v2" - "github.com/go-kratos/kratos/v2/middleware/tracing" _ "github.com/origadmin/contrib/consul/config" _ "github.com/origadmin/contrib/consul/registry" _ "github.com/origadmin/contrib/database" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" - kslog "github.com/origadmin/slog-kratos" "origadmin/application/admin/internal/loader" ) @@ -30,16 +28,17 @@ var ( // Version is the Version of the compiled software. Version = "v1.0.0" // boot are the bootstrap boot. - flags = bootstrap.DefaultBootstrap() + flags = bootstrap.New() // debug mode debug = false + // configPath is the config path, default is config.toml + configPath = "" ) func init() { - flags.Env = "release" - flags.SetFlags(Name, Version) + flags.SetServiceInfo(Name, Version) flag.BoolVar(&debug, "debug", false, "set environment, eg: -debug") - flag.StringVar(&flags.ConfigPath, "c", "config.toml", "config path, eg: -c config.toml") + flag.StringVar(&configPath, "c", "config.toml", "config path, eg: -c config.toml") } func main() { @@ -48,69 +47,33 @@ func main() { // the release mode, work dir sets to empty, use config path as work dir if debug { fmt.Println("debug mode") - flags.Env = "debug" - flags.WorkDir = "resources/configs" + flags.SetEnv("debug") + flags.SetConfigPath("resources/configs") slog.SetLogLoggerLevel(slog.LevelDebug) } - l := log.With(kslog.NewLogger(), - "ts", log.DefaultTimestamp, - "caller", log.DefaultCaller, - "service.id", flags.ID(), - "service.name", flags.ServiceName(), - "service.version", flags.Version(), - "trace.id", tracing.TraceID(), - "span.id", tracing.SpanID(), - ) - log.SetLogger(l) - log.Infof("bootstrap flags: %+v\n", flags) - bs, err := loader.LoadBootstrap(flags) - if err != nil { - log.Fatalf("failed to load config: %s", err.Error()) - return - } - //v, err := validate.NewValidateV2() + //r, err := runtime.Load(flags) //if err != nil { - // log.Fatalf("failed to new validate: %s", err.Error()) + // return //} - // v1 used method Validate to check the config - if err := bs.Validate(); err != nil { - log.Fatalf("failed to validate config: %s", err.Error()) - } - - if err := loader.InitSetup(bs); err != nil { - log.Fatalf("failed to init setup: %s", err.Error()) + //l := r.Logger( + // "ts", log.DefaultTimestamp, + // "caller", log.DefaultCaller, + // "service.id", flags.ServiceID(), + // "service.name", flags.ServiceName(), + // "service.version", flags.Version(), + // "trace.id", tracing.TraceID(), + // "span.id", tracing.SpanID(), + //) + //log.SetLogger(l) + log.Infof("bootstrap flags: %+v\n", flags) + if err := loader.Bootstrap(context.Background(), flags, buildInjectors); err != nil { + log.Fatalf("failed to bootstrap: %s", err.Error()) return } - - //log.Infof("bootstrap config: %+v\n", loader.PrintString(bs)) - ctx := context.Background() - //info to ctx - app, cleanup, err := buildInjectors(ctx, bs, l) - if err != nil { - log.Fatalf("failed to build injector: %s", err.Error()) - } - defer cleanup() - // start and wait for stop signal - if err := app.Run(); err != nil { - log.Fatalf("app stopped with error: %s", err.Error()) - } } -func NewApp(ctx context.Context, injector *loader.InjectorServer) *kratos.App { - opts := []kratos.Option{ - kratos.ID(flags.ServiceID()), - kratos.Name(flags.ServiceName()), - kratos.Version(flags.Version()), - kratos.Metadata(flags.Metadata()), - kratos.Context(ctx), - kratos.Signal(syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT), - kratos.Logger(injector.Logger), - kratos.Server(injector.Servers...), - } - if injector.Registrar != nil { - opts = append(opts, kratos.Registrar(injector.Registrar)) - } - - return kratos.New(opts...) +// NewAppProvider 是一个provider函数,它使用runtime.Runtime的CreateApp方法 +func NewAppProvider(r runtime.Runtime, injector *loader.Injector) *kratos.App { + return r.CreateApp(injector.Servers...) } diff --git a/cmd/system/wire.go b/cmd/system/wire.go index cafc5b27..6ad7e7d1 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -9,13 +9,12 @@ package main import ( - "context" - "github.com/go-kratos/kratos/v2" "github.com/google/wire" - "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime" "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/loader" systembiz "origadmin/application/admin/internal/mods/system/biz" systemdal "origadmin/application/admin/internal/mods/system/dal" @@ -24,9 +23,10 @@ import ( ) // buildInjectors init kratos application. -func buildInjectors(context.Context, *configs.Bootstrap, log.KLogger) (*kratos.App, func(), error) { +func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { panic(wire.Build( loader.ProviderSet, + data.ProviderSet, //basisdal.ProviderSet, //basisbiz.ProviderSet, //basisservice.ProviderSet, @@ -36,5 +36,6 @@ func buildInjectors(context.Context, *configs.Bootstrap, log.KLogger) (*kratos.A systemservice.ProviderSet, systemserver.ProviderSet, /* add your providers here */ - NewApp)) + NewAppProvider, + )) } diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index 6ed9f8aa..c8c48be2 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -1,13 +1,14 @@ // Code generated by Wire. DO NOT EDIT. //go:generate go run -mod=mod github.com/google/wire/cmd/wire -//+build !wireinject +//go:build !wireinject +// +build !wireinject package main import ( - "context" "github.com/go-kratos/kratos/v2" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/loader" @@ -26,28 +27,27 @@ import ( // Injectors from wire.go: // buildInjectors init kratos application. -func buildInjectors(contextContext context.Context, bootstrap *configs.Bootstrap, arg log.KLogger) (*kratos.App, func(), error) { +func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { v, err := loader.NewRegistrar(bootstrap) if err != nil { return nil, nil, err } - data, cleanup, err := dal.NewData(bootstrap, arg) + data, cleanup, err := dal.NewData(bootstrap, logger) if err != nil { return nil, nil, err } - resourceRepo := dal.NewResourceRepo(data, arg) - resourceServiceBiz := biz.NewResourceServiceBiz(resourceRepo, arg) + resourceRepo := dal.NewResourceRepo(data, logger) + resourceServiceBiz := biz.NewResourceServiceBiz(resourceRepo, logger) resourceServiceServer := service.NewResourceServiceServerPB(resourceServiceBiz) - roleRepo := dal.NewRoleRepo(data, arg) - roleServiceBiz := biz.NewRoleServiceBiz(roleRepo, arg) + roleRepo := dal.NewRoleRepo(data, logger) + roleServiceBiz := biz.NewRoleServiceBiz(roleRepo, logger) roleServiceServer := service.NewRoleServiceServerPB(roleServiceBiz) - userRepo := dal.NewUserRepo(data, arg) - userServiceBiz := biz.NewUserServiceBiz(userRepo, arg) + userRepo := dal.NewUserRepo(data, logger) + userServiceBiz := biz.NewUserServiceBiz(userRepo, logger) userServiceServer := service.NewUserServiceServerPB(userServiceBiz) - authRepo := dal.NewAuthRepo(data, arg) - authServiceBiz := biz.NewAuthServiceBiz(authRepo, arg) + authRepo := dal.NewAuthRepo(data, logger) + authServiceBiz := biz.NewAuthServiceBiz(authRepo, logger) authServiceServer := service.NewAuthServiceServerPB(authServiceBiz) - invalid type := loader.NewBasisConfig(bootstrap) tokenizer, err := loader.NewTokenizer(bootstrap) if err != nil { cleanup() @@ -55,39 +55,35 @@ func buildInjectors(contextContext context.Context, bootstrap *configs.Bootstrap } refreshTokenizer := dal.RefreshTokenizer(tokenizer) loginData := &dal.LoginData{ - BasisConfig: invalid type, Tokenizer: refreshTokenizer, - Resource: resourceRepo, - Role: roleRepo, - User: userRepo, + Resource: resourceRepo, + Role: roleRepo, + User: userRepo, } - loginRepo := dal.NewLoginRepo(loginData, arg) - loginServiceBiz := biz.NewLoginServiceBiz(loginRepo, arg) + loginRepo := dal.NewLoginRepo(loginData, logger) + loginServiceBiz := biz.NewLoginServiceBiz(loginRepo, logger) loginServiceServer := service.NewLoginServiceServerPB(loginServiceBiz) - personalRepo := dal.NewPersonalRepo(data, arg) - personalServiceBiz := biz.NewPersonalServiceBiz(personalRepo, arg) + personalRepo := dal.NewPersonalRepo(data, logger) + personalServiceBiz := biz.NewPersonalServiceBiz(personalRepo, logger) personalServiceServer := service.NewPersonalServiceServerPB(personalServiceBiz) - permissionRepo := dal.NewPermissionRepo(data, arg) - permissionServiceBiz := biz.NewPermissionServiceBiz(permissionRepo, arg) + permissionRepo := dal.NewPermissionRepo(data, logger) + permissionServiceBiz := biz.NewPermissionServiceBiz(permissionRepo, logger) permissionServiceServer := service.NewPermissionServiceServerPB(permissionServiceBiz) casbinSourceRepo, err := dal.NewCasbinSourceRepo(data) if err != nil { cleanup() return nil, nil, err } - casbinSourceServiceBiz := biz.NewCasbinSourceServiceBiz(casbinSourceRepo, arg) + casbinSourceServiceBiz := biz.NewCasbinSourceServiceBiz(casbinSourceRepo, logger) casbinSourceServiceServer := service.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) v2 := server.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, authServiceServer, loginServiceServer, personalServiceServer, permissionServiceServer, casbinSourceServiceServer) - v3 := server.NewSystemServer(bootstrap, v2, arg) - injectorServer := &loader.InjectorServer{ - Logger: arg, - Bootstrap: bootstrap, + v3 := server.NewSystemServer(bootstrap, v2, logger) + injector := &loader.Injector{ Registrar: v, - Servers: v3, + Servers: v3, } - app := NewApp(contextContext, injectorServer) + app := NewAppProvider(r, injector) return app, func() { cleanup() }, nil } - diff --git a/contrib/security/authn/jwt/authn.go b/contrib/security/authn/jwt/authn.go index 4d9050f6..e454a3be 100644 --- a/contrib/security/authn/jwt/authn.go +++ b/contrib/security/authn/jwt/authn.go @@ -11,11 +11,12 @@ import ( "github.com/goexts/generic/settings" msecurity "github.com/origadmin/runtime/agent/middleware/security" "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/runtime/interfaces/security/token" ) type Authenticator struct { Tokenizer security.Tokenizer - Cache security.CacheStorage + Cache token.CacheStorage Scheme security.Scheme } @@ -36,11 +37,11 @@ func (obj Authenticator) AuthenticateContext(ctx context.Context, tokenType secu } func (obj Authenticator) DestroyToken(ctx context.Context, tokenStr string) error { - return obj.Cache.Remove(ctx, obj.key(security.TokenCacheAccess, tokenStr)) + return obj.Cache.Remove(ctx, obj.key(token.CacheAccess, tokenStr)) } func (obj Authenticator) DestroyRefreshToken(ctx context.Context, tokenStr string) error { - return obj.Cache.Remove(ctx, obj.key(security.TokenCacheRefresh, tokenStr)) + return obj.Cache.Remove(ctx, obj.key(token.CacheRefresh, tokenStr)) } func (obj Authenticator) key(ns, token string) string { @@ -52,7 +53,7 @@ type AuthenticatorSetting = func(*Authenticator) func NewAuthenticator(tokenizer security.Tokenizer, ss ...AuthenticatorSetting) security.Authenticator { return settings.Apply(&Authenticator{ Tokenizer: tokenizer, - Cache: security.NewCacheStorage(), + Cache: token.New(), Scheme: security.SchemeBearer, }, ss) } diff --git a/go.mod b/go.mod index c0d250db..1b553b56 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,6 @@ module origadmin/application/admin go 1.23.7 -toolchain go1.23.8 - replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0.5.4 require ( @@ -14,8 +12,7 @@ require ( github.com/envoyproxy/protoc-gen-validate v1.2.1 github.com/gin-gonic/gin v1.10.0 github.com/go-kratos/kratos/v2 v2.8.4 - github.com/goexts/generic v0.2.6 - github.com/golang-cz/devslog v0.0.13 + github.com/goexts/generic v0.3.0 github.com/golang-jwt/jwt/v5 v5.2.2 github.com/google/gnostic v0.7.0 github.com/google/uuid v1.6.0 @@ -29,19 +26,18 @@ require ( github.com/origadmin/contrib/replacer v0.0.33 github.com/origadmin/contrib/transport/gins v0.0.33 github.com/origadmin/entslog/v3 v3.1.0 - github.com/origadmin/runtime v0.1.58 + github.com/origadmin/runtime v0.2.0 github.com/origadmin/slog-kratos v1.0.4 - github.com/origadmin/toolkits v0.3.15 - github.com/origadmin/toolkits/codec v0.3.15 + github.com/origadmin/toolkits v0.3.16 + github.com/origadmin/toolkits/codec v0.3.16 github.com/origadmin/toolkits/crypto v0.3.15 - github.com/origadmin/toolkits/errors v0.3.15 + github.com/origadmin/toolkits/errors v0.3.16 github.com/origadmin/toolkits/identifier v0.3.15 - github.com/origadmin/toolkits/slogx v0.3.15 github.com/prometheus/client_golang v1.22.0 github.com/sony/sonyflake v1.2.0 github.com/spf13/cobra v1.9.1 github.com/stretchr/testify v1.10.0 - golang.org/x/net v0.39.0 + golang.org/x/net v0.40.0 google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34 google.golang.org/grpc v1.72.0 google.golang.org/protobuf v1.36.6 @@ -50,6 +46,7 @@ require ( require ( ariga.io/atlas v0.32.0 // indirect buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 // indirect + buf.build/go/protovalidate v0.12.0 // indirect cel.dev/expr v0.23.1 // indirect dario.cat/mergo v1.0.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect @@ -61,7 +58,6 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect - github.com/bufbuild/protovalidate-go v0.10.0 // indirect github.com/bytedance/sonic v1.13.2 // indirect github.com/bytedance/sonic/loader v0.2.4 // indirect github.com/casbin/govaluate v1.3.0 // indirect @@ -88,6 +84,7 @@ require ( github.com/go-playground/validator/v10 v10.26.0 // indirect github.com/go-sql-driver/mysql v1.9.2 // indirect github.com/goccy/go-json v0.10.5 // indirect + github.com/golang-cz/devslog v0.0.13 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect @@ -127,6 +124,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect + github.com/origadmin/toolkits/slogx v0.3.16 // indirect github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect @@ -151,15 +149,15 @@ require ( go.opentelemetry.io/otel v1.35.0 // indirect go.opentelemetry.io/otel/metric v1.35.0 // indirect go.opentelemetry.io/otel/trace v1.35.0 // indirect - golang.org/x/arch v0.16.0 // indirect - golang.org/x/crypto v0.37.0 // indirect - golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect + golang.org/x/arch v0.17.0 // indirect + golang.org/x/crypto v0.38.0 // indirect + golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect golang.org/x/image v0.26.0 // indirect golang.org/x/mod v0.24.0 // indirect - golang.org/x/sync v0.13.0 // indirect - golang.org/x/sys v0.32.0 // indirect - golang.org/x/text v0.24.0 // indirect - golang.org/x/tools v0.32.0 // indirect + golang.org/x/sync v0.14.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/text v0.25.0 // indirect + golang.org/x/tools v0.33.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index bcfb8c16..0b141332 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ ariga.io/atlas v0.32.0 h1:y+77nueMrExLiKlz1CcPKh/nU7VSlWfBbwCShsJyvCw= ariga.io/atlas v0.32.0/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 h1:YhMSc48s25kr7kv31Z8vf7sPUIq5YJva9z1mn/hAt0M= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U= +buf.build/go/protovalidate v0.12.0 h1:4GKJotbspQjRCcqZMGVSuC8SjwZ/FmgtSuKDpKUTZew= +buf.build/go/protovalidate v0.12.0/go.mod h1:q3PFfbzI05LeqxSwq+begW2syjy2Z6hLxZSkP1OH/D0= cel.dev/expr v0.23.1 h1:K4KOtPCJQjVggkARsjG9RWXP6O4R73aHeJMa/dmCQQg= cel.dev/expr v0.23.1/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= @@ -650,8 +652,6 @@ github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR github.com/bmatcuk/doublestar/v4 v4.8.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/bufbuild/protovalidate-go v0.10.0 h1:QdaKhfk3/Dnb2soL9mKmuLPstq+ogAwSWCE3sQ1NBEE= -github.com/bufbuild/protovalidate-go v0.10.0/go.mod h1:nIggbFjqS4DxJgSFBhOzH97Pb8SPNceFc5nygg1pOA8= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= @@ -800,8 +800,8 @@ github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3a github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= -github.com/goexts/generic v0.2.6 h1:QKofyPuc7Qo8lxgYP/c+4b+1UGJgjFyFPVr68uqc+js= -github.com/goexts/generic v0.2.6/go.mod h1:SZddH3gsbpBCE8JezA87mLXvM0aVrHivRWmnTn+enI4= +github.com/goexts/generic v0.3.0 h1:IimURW0H6QS6XBBf6H/wTRhtKtFub14n0aNDIYud4A4= +github.com/goexts/generic v0.3.0/go.mod h1:SZddH3gsbpBCE8JezA87mLXvM0aVrHivRWmnTn+enI4= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang-cz/devslog v0.0.13 h1:JkJ6PPNSOCBpYyU03v3xw7WgpChQ3AYFqgRbYBhUk/Y= github.com/golang-cz/devslog v0.0.13/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= @@ -1091,22 +1091,22 @@ github.com/origadmin/entslog/v3 v3.1.0 h1:1SPjs2CWytl08obWW2wAk8UTiwoc0ak/doWdQH github.com/origadmin/entslog/v3 v3.1.0/go.mod h1:cIFyIZprNlJ69T18DnXBpylvO2CWvEGPhW1r2Sm/51s= github.com/origadmin/go-metrics v0.5.4 h1:odg6zeZUGkTCl6cGJ/bS5GlvjZ3x3GU2zyw9WtNmKFY= github.com/origadmin/go-metrics v0.5.4/go.mod h1:KiuAdjBbuXAkjTjy7p7F4g6sjO6WuvH+6hTlMKUxPkg= -github.com/origadmin/runtime v0.1.58 h1:qNWpm/jOSbtYgQ0NtZJ3OjCyyZgvzUXqk4kCGFj5hMs= -github.com/origadmin/runtime v0.1.58/go.mod h1:WfQLmC9QVyPTsab3ISP8nOu6Ow9rncUEqx38OAunITE= +github.com/origadmin/runtime v0.2.0 h1:4FbuNYqJbQZFZrKQB6l/L5RXlC3hr40uWFKjUMUYMgA= +github.com/origadmin/runtime v0.2.0/go.mod h1:b+TK2xaJlTsna1RESE4+y9Do+qz80Wnz2+KqrA4gLnI= github.com/origadmin/slog-kratos v1.0.4 h1:1et3TBy61Uwf5N1ZbEBFhMqCjgxqfRXmz2w0Q1dujG0= github.com/origadmin/slog-kratos v1.0.4/go.mod h1:WUdhcWLyN0i8TbdemqE2Y/muoj0GaZ86OcdpumAWHPo= -github.com/origadmin/toolkits v0.3.15 h1:Cr8nzoSFvAFkFG4FXhT+lSUgUzoOQT1//ao/3QXmxsc= -github.com/origadmin/toolkits v0.3.15/go.mod h1:l0H6drsQuWNiSDagDwI2jvLqxlNGtF1LI++fPrz5KAg= -github.com/origadmin/toolkits/codec v0.3.15 h1:aeFJbQgaRfHs4jkM06da9YB2J6vaUQKdiPy2dSY4kKY= -github.com/origadmin/toolkits/codec v0.3.15/go.mod h1:XqlOlTxdD3lLDPmC82cZEVoiD4/r4QA3umKKRVrgGu4= +github.com/origadmin/toolkits v0.3.16 h1:R/Ws2S2W64ZScSkBz4QQ8HPXWpuH/ac+z1z0iHPyG0M= +github.com/origadmin/toolkits v0.3.16/go.mod h1:l0H6drsQuWNiSDagDwI2jvLqxlNGtF1LI++fPrz5KAg= +github.com/origadmin/toolkits/codec v0.3.16 h1:fRyWCMwyXz032I1ZHpsRuG/8YfWRS4YlfqYNdjeziMw= +github.com/origadmin/toolkits/codec v0.3.16/go.mod h1:XqlOlTxdD3lLDPmC82cZEVoiD4/r4QA3umKKRVrgGu4= github.com/origadmin/toolkits/crypto v0.3.15 h1:OHgIXLvB2jCvKH55YVdSyTjcOAwB05FmvCQLKn2BoMQ= github.com/origadmin/toolkits/crypto v0.3.15/go.mod h1:ozRQi1rYHAIL/NSw0hJEWITEkZlSZ7wA9pCQKpqFv2s= -github.com/origadmin/toolkits/errors v0.3.15 h1:NxvwgsIh6Aqt4CasaFz2xQ+nDWEtdAbXqBsjvx/g96Y= -github.com/origadmin/toolkits/errors v0.3.15/go.mod h1:kqVUSV6sz+wiUeesrBxZ3oyUPrNl0alF0+jO0qehBvM= +github.com/origadmin/toolkits/errors v0.3.16 h1:W6Izq84z3dkusnWZC5nMHGd7DYCYM2sZZYiga/hg8iU= +github.com/origadmin/toolkits/errors v0.3.16/go.mod h1:kqVUSV6sz+wiUeesrBxZ3oyUPrNl0alF0+jO0qehBvM= github.com/origadmin/toolkits/identifier v0.3.15 h1:hl4xYINV3ywDGlqrVYCf/tePx7tjZZ8LWvqzlhzv3rA= github.com/origadmin/toolkits/identifier v0.3.15/go.mod h1:M1IodkORni12hNmpFd5/9xrBHqjUkoDzBmPWyHGhIp8= -github.com/origadmin/toolkits/slogx v0.3.15 h1:96TOKqX/02m6+6LEJxS/GGf4jndsFS5A7Td3Mtcb/rc= -github.com/origadmin/toolkits/slogx v0.3.15/go.mod h1:6ODf/5T3M7XBc0aKHHkMgOLawkASDzaPCj99JzabYME= +github.com/origadmin/toolkits/slogx v0.3.16 h1:+sJAKM2t/3ZyT6qi+Q1CwnzXO/ObXJlKTfPA6RdJno0= +github.com/origadmin/toolkits/slogx v0.3.16/go.mod h1:6ODf/5T3M7XBc0aKHHkMgOLawkASDzaPCj99JzabYME= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= @@ -1263,8 +1263,8 @@ go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= -golang.org/x/arch v0.16.0 h1:foMtLTdyOmIniqWCHjY6+JxuC54XP1fDwx4N0ASyW+U= -golang.org/x/arch v0.16.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE= +golang.org/x/arch v0.17.0 h1:4O3dfLzd+lQewptAHqjewQZQDyEdejz3VwgeYwkZneU= +golang.org/x/arch v0.17.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -1281,8 +1281,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= -golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= +golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= +golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1298,8 +1298,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM= -golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8= +golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI= +golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1415,8 +1415,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= -golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1465,8 +1465,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= -golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1559,8 +1559,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= -golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1593,8 +1593,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= -golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1664,8 +1664,8 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= -golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/configs/auth_config.pb.go b/internal/configs/auth_config.pb.go index 24222d0d..7c785b8d 100644 --- a/internal/configs/auth_config.pb.go +++ b/internal/configs/auth_config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc v5.28.3 // source: configs/auth_config.proto @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -22,13 +23,12 @@ const ( ) type AuthConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // origadmin.configs.api.RootUser root_user = 1 [json_name = "root_user"]; - Captcha *Captcha `protobuf:"bytes,2,opt,name=captcha,proto3" json:"captcha,omitempty"` - Security *v1.Security `protobuf:"bytes,3,opt,name=security,proto3" json:"security,omitempty"` + Captcha *Captcha `protobuf:"bytes,2,opt,name=captcha,proto3" json:"captcha,omitempty"` + Security *v1.Security `protobuf:"bytes,3,opt,name=security,proto3" json:"security,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *AuthConfig) Reset() { @@ -77,35 +77,22 @@ func (x *AuthConfig) GetSecurity() *v1.Security { var File_configs_auth_config_proto protoreflect.FileDescriptor -var file_configs_auth_config_proto_rawDesc = []byte{ - 0x0a, 0x19, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x6f, 0x72, 0x69, - 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, - 0x70, 0x69, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, - 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x77, 0x0a, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x38, 0x0a, 0x07, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, - 0x68, 0x61, 0x52, 0x07, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x12, 0x2f, 0x0a, 0x08, 0x73, - 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, - 0x74, 0x79, 0x52, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x42, 0x2e, 0x5a, 0x2c, - 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -} +const file_configs_auth_config_proto_rawDesc = "" + + "\n" + + "\x19configs/auth_config.proto\x12\x15origadmin.configs.api\x1a\x18config/v1/security.proto\x1a\x15configs/captcha.proto\"w\n" + + "\n" + + "AuthConfig\x128\n" + + "\acaptcha\x18\x02 \x01(\v2\x1e.origadmin.configs.api.CaptchaR\acaptcha\x12/\n" + + "\bsecurity\x18\x03 \x01(\v2\x13.config.v1.SecurityR\bsecurityB.Z,origadmin/application/admin/internal/configsb\x06proto3" var ( file_configs_auth_config_proto_rawDescOnce sync.Once - file_configs_auth_config_proto_rawDescData = file_configs_auth_config_proto_rawDesc + file_configs_auth_config_proto_rawDescData []byte ) func file_configs_auth_config_proto_rawDescGZIP() []byte { file_configs_auth_config_proto_rawDescOnce.Do(func() { - file_configs_auth_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_configs_auth_config_proto_rawDescData) + file_configs_auth_config_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_auth_config_proto_rawDesc), len(file_configs_auth_config_proto_rawDesc))) }) return file_configs_auth_config_proto_rawDescData } @@ -136,7 +123,7 @@ func file_configs_auth_config_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_configs_auth_config_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_auth_config_proto_rawDesc), len(file_configs_auth_config_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -147,7 +134,6 @@ func file_configs_auth_config_proto_init() { MessageInfos: file_configs_auth_config_proto_msgTypes, }.Build() File_configs_auth_config_proto = out.File - file_configs_auth_config_proto_rawDesc = nil file_configs_auth_config_proto_goTypes = nil file_configs_auth_config_proto_depIdxs = nil } diff --git a/internal/configs/auth_config.pb.validate.go b/internal/configs/auth_config.pb.validate.go index 60e38d90..7ff1999d 100644 --- a/internal/configs/auth_config.pb.validate.go +++ b/internal/configs/auth_config.pb.validate.go @@ -128,7 +128,7 @@ type AuthConfigMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m AuthConfigMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/internal/configs/bootstrap.pb.go b/internal/configs/bootstrap.pb.go index ecb74df4..60b315ea 100644 --- a/internal/configs/bootstrap.pb.go +++ b/internal/configs/bootstrap.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc v5.28.3 // source: configs/bootstrap.proto @@ -15,6 +15,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -25,13 +26,12 @@ const ( ) type EntrySelectorConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Global bool `protobuf:"varint,2,opt,name=global,proto3" json:"global,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` unknownFields protoimpl.UnknownFields - - Global bool `protobuf:"varint,2,opt,name=global,proto3" json:"global,omitempty"` - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` + sizeCache protoimpl.SizeCache } func (x *EntrySelectorConfig) Reset() { @@ -86,11 +86,10 @@ func (x *EntrySelectorConfig) GetVersion() string { } type ServiceConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ServiceConfig) Reset() { @@ -131,10 +130,7 @@ func (x *ServiceConfig) GetName() string { } type Bootstrap struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // name is the application name or service name for used Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` @@ -147,14 +143,17 @@ type Bootstrap struct { Entry *Bootstrap_Entry `protobuf:"bytes,103,opt,name=entry,proto3" json:"entry,omitempty"` HttpGateway *v1.Service `protobuf:"bytes,104,opt,name=http_gateway,proto3" json:"http_gateway,omitempty"` // 动态加载服务配置 - Services []*ServiceConfig `protobuf:"bytes,200,rep,name=services,proto3" json:"services,omitempty"` - Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` - Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` - Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` - Authn *v12.AuthN `protobuf:"bytes,1000,opt,name=authn,proto3" json:"authn,omitempty"` - Authz *v12.AuthZ `protobuf:"bytes,1001,opt,name=authz,proto3" json:"authz,omitempty"` - Security *v1.Security `protobuf:"bytes,1002,opt,name=security,proto3" json:"security,omitempty"` - HealthCheck *Bootstrap_HealthCheck `protobuf:"bytes,1003,opt,name=health_check,proto3" json:"health_check,omitempty"` + Services []*ServiceConfig `protobuf:"bytes,200,rep,name=services,proto3" json:"services,omitempty"` + Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` + Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` + Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` + Authn *v12.AuthN `protobuf:"bytes,1000,opt,name=authn,proto3" json:"authn,omitempty"` + Authz *v12.AuthZ `protobuf:"bytes,1001,opt,name=authz,proto3" json:"authz,omitempty"` + Security *v1.Security `protobuf:"bytes,1002,opt,name=security,proto3" json:"security,omitempty"` + HealthCheck *Bootstrap_HealthCheck `protobuf:"bytes,1003,opt,name=health_check,proto3" json:"health_check,omitempty"` + Logger *v1.Logger `protobuf:"bytes,1004,opt,name=logger,proto3" json:"logger,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Bootstrap) Reset() { @@ -306,12 +305,18 @@ func (x *Bootstrap) GetHealthCheck() *Bootstrap_HealthCheck { return nil } +func (x *Bootstrap) GetLogger() *v1.Logger { + if x != nil { + return x.Logger + } + return nil +} + type Settings struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + CryptoType string `protobuf:"bytes,1,opt,name=crypto_type,proto3" json:"crypto_type,omitempty"` unknownFields protoimpl.UnknownFields - - CryptoType string `protobuf:"bytes,1,opt,name=crypto_type,proto3" json:"crypto_type,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Settings) Reset() { @@ -352,12 +357,11 @@ func (x *Settings) GetCryptoType() string { } type Bootstrap_HealthCheck struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Timeout int32 `protobuf:"varint,1,opt,name=timeout,proto3" json:"timeout,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` unknownFields protoimpl.UnknownFields - - Timeout int32 `protobuf:"varint,1,opt,name=timeout,proto3" json:"timeout,omitempty"` - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Bootstrap_HealthCheck) Reset() { @@ -406,12 +410,11 @@ func (x *Bootstrap_HealthCheck) GetPath() string { // Entry type Bootstrap_Entry struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Scheme string `protobuf:"bytes,1,opt,name=scheme,proto3" json:"scheme,omitempty"` + Server *v1.Service `protobuf:"bytes,2,opt,name=server,proto3" json:"server,omitempty"` unknownFields protoimpl.UnknownFields - - Scheme string `protobuf:"bytes,1,opt,name=scheme,proto3" json:"scheme,omitempty"` - Server *v1.Service `protobuf:"bytes,2,opt,name=server,proto3" json:"server,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Bootstrap_Entry) Reset() { @@ -460,107 +463,53 @@ func (x *Bootstrap_Entry) GetServer() *v1.Service { var File_configs_bootstrap_proto protoreflect.FileDescriptor -var file_configs_bootstrap_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, - 0x72, 0x61, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x6f, 0x72, 0x69, 0x67, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, - 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, - 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, - 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5b, 0x0a, 0x13, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, - 0x0a, 0x06, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, - 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x2c, 0x0a, 0x0d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1b, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x22, 0xbe, 0x07, 0x0a, 0x09, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x20, - 0x0a, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, - 0x12, 0x2d, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, - 0xfa, 0x42, 0x16, 0x72, 0x14, 0x52, 0x09, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x74, 0x6f, 0x6e, - 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, - 0x34, 0x0a, 0x15, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x79, 0x6e, 0x61, 0x6d, 0x69, - 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x15, - 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x79, 0x6e, 0x61, 0x6d, 0x69, 0x63, 0x5f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x64, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x32, 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, - 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x66, 0x20, 0x01, 0x28, 0x09, 0x42, 0x10, 0xfa, 0x42, 0x0d, 0x72, - 0x0b, 0x52, 0x03, 0x64, 0x65, 0x76, 0x52, 0x04, 0x70, 0x72, 0x6f, 0x64, 0x52, 0x0b, 0x65, 0x6e, - 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x3c, 0x0a, 0x05, 0x65, 0x6e, 0x74, - 0x72, 0x79, 0x18, 0x67, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x6f, 0x72, 0x69, 0x67, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x36, 0x0a, 0x0c, 0x68, 0x74, 0x74, 0x70, 0x5f, - 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x18, 0x68, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x52, 0x0c, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x67, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x12, - 0x41, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0xc8, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0xac, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, - 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, - 0x65, 0x12, 0x30, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x90, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, - 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x72, 0x79, 0x12, 0x39, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, - 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, - 0x77, 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, - 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x12, 0x29, - 0x0a, 0x05, 0x61, 0x75, 0x74, 0x68, 0x6e, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, - 0x2e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, - 0x68, 0x4e, 0x52, 0x05, 0x61, 0x75, 0x74, 0x68, 0x6e, 0x12, 0x29, 0x0a, 0x05, 0x61, 0x75, 0x74, - 0x68, 0x7a, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, 0x63, 0x75, - 0x72, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x5a, 0x52, 0x05, 0x61, - 0x75, 0x74, 0x68, 0x7a, 0x12, 0x30, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, - 0x18, 0xea, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, 0x73, 0x65, - 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x51, 0x0a, 0x0c, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, - 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x18, 0xeb, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, - 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2e, - 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x0c, 0x68, 0x65, 0x61, - 0x6c, 0x74, 0x68, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x1a, 0x3b, 0x0a, 0x0b, 0x48, 0x65, 0x61, - 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, - 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, - 0x75, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x1a, 0x4b, 0x0a, 0x05, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x06, 0x73, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x22, 0x2c, 0x0a, 0x08, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, - 0x20, 0x0a, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x74, 0x79, 0x70, - 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, - 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_configs_bootstrap_proto_rawDesc = "" + + "\n" + + "\x17configs/bootstrap.proto\x12\x15origadmin.configs.api\x1a\x16config/v1/logger.proto\x1a\x18config/v1/registry.proto\x1a\x18config/v1/security.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1emiddleware/v1/middleware.proto\x1a\x16security/v1/auth.proto\x1a\x17validate/validate.proto\"[\n" + + "\x13EntrySelectorConfig\x12\x16\n" + + "\x06global\x18\x02 \x01(\bR\x06global\x12\x12\n" + + "\x04name\x18\x03 \x01(\tR\x04name\x12\x18\n" + + "\aversion\x18\x04 \x01(\tR\aversion\",\n" + + "\rServiceConfig\x12\x1b\n" + + "\x04name\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x04name\"\xea\a\n" + + "\tBootstrap\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + + "\aversion\x18\x02 \x01(\tR\aversion\x12 \n" + + "\vcrypto_type\x18\x03 \x01(\tR\vcrypto_type\x12-\n" + + "\x04mode\x18\x05 \x01(\tB\x19\xfaB\x16r\x14R\tsingletonR\aclusterR\x04mode\x124\n" + + "\x15enable_dynamic_config\x18\a \x01(\bR\x15enable_dynamic_config\x12\x0e\n" + + "\x02id\x18d \x01(\tR\x02id\x122\n" + + "\venvironment\x18f \x01(\tB\x10\xfaB\rr\vR\x03devR\x04prodR\venvironment\x12<\n" + + "\x05entry\x18g \x01(\v2&.origadmin.configs.api.Bootstrap.EntryR\x05entry\x126\n" + + "\fhttp_gateway\x18h \x01(\v2\x12.config.v1.ServiceR\fhttp_gateway\x12A\n" + + "\bservices\x18\xc8\x01 \x03(\v2$.origadmin.configs.api.ServiceConfigR\bservices\x12-\n" + + "\astorage\x18\xac\x02 \x01(\v2\x12.config.v1.StorageR\astorage\x120\n" + + "\bregistry\x18\x90\x03 \x01(\v2\x13.config.v1.RegistryR\bregistry\x129\n" + + "\n" + + "middleware\x18\t \x01(\v2\x19.middleware.v1.MiddlewareR\n" + + "middleware\x12)\n" + + "\x05authn\x18\xe8\a \x01(\v2\x12.security.v1.AuthNR\x05authn\x12)\n" + + "\x05authz\x18\xe9\a \x01(\v2\x12.security.v1.AuthZR\x05authz\x120\n" + + "\bsecurity\x18\xea\a \x01(\v2\x13.config.v1.SecurityR\bsecurity\x12Q\n" + + "\fhealth_check\x18\xeb\a \x01(\v2,.origadmin.configs.api.Bootstrap.HealthCheckR\fhealth_check\x12*\n" + + "\x06logger\x18\xec\a \x01(\v2\x11.config.v1.LoggerR\x06logger\x1a;\n" + + "\vHealthCheck\x12\x18\n" + + "\atimeout\x18\x01 \x01(\x05R\atimeout\x12\x12\n" + + "\x04path\x18\x02 \x01(\tR\x04path\x1aK\n" + + "\x05Entry\x12\x16\n" + + "\x06scheme\x18\x01 \x01(\tR\x06scheme\x12*\n" + + "\x06server\x18\x02 \x01(\v2\x12.config.v1.ServiceR\x06server\",\n" + + "\bSettings\x12 \n" + + "\vcrypto_type\x18\x01 \x01(\tR\vcrypto_typeB.Z,origadmin/application/admin/internal/configsb\x06proto3" var ( file_configs_bootstrap_proto_rawDescOnce sync.Once - file_configs_bootstrap_proto_rawDescData = file_configs_bootstrap_proto_rawDesc + file_configs_bootstrap_proto_rawDescData []byte ) func file_configs_bootstrap_proto_rawDescGZIP() []byte { file_configs_bootstrap_proto_rawDescOnce.Do(func() { - file_configs_bootstrap_proto_rawDescData = protoimpl.X.CompressGZIP(file_configs_bootstrap_proto_rawDescData) + file_configs_bootstrap_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_bootstrap_proto_rawDesc), len(file_configs_bootstrap_proto_rawDesc))) }) return file_configs_bootstrap_proto_rawDescData } @@ -580,6 +529,7 @@ var file_configs_bootstrap_proto_goTypes = []any{ (*v12.AuthN)(nil), // 10: security.v1.AuthN (*v12.AuthZ)(nil), // 11: security.v1.AuthZ (*v1.Security)(nil), // 12: config.v1.Security + (*v1.Logger)(nil), // 13: config.v1.Logger } var file_configs_bootstrap_proto_depIdxs = []int32{ 5, // 0: origadmin.configs.api.Bootstrap.entry:type_name -> origadmin.configs.api.Bootstrap.Entry @@ -592,12 +542,13 @@ var file_configs_bootstrap_proto_depIdxs = []int32{ 11, // 7: origadmin.configs.api.Bootstrap.authz:type_name -> security.v1.AuthZ 12, // 8: origadmin.configs.api.Bootstrap.security:type_name -> config.v1.Security 4, // 9: origadmin.configs.api.Bootstrap.health_check:type_name -> origadmin.configs.api.Bootstrap.HealthCheck - 6, // 10: origadmin.configs.api.Bootstrap.Entry.server:type_name -> config.v1.Service - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 13, // 10: origadmin.configs.api.Bootstrap.logger:type_name -> config.v1.Logger + 6, // 11: origadmin.configs.api.Bootstrap.Entry.server:type_name -> config.v1.Service + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_configs_bootstrap_proto_init() } @@ -609,7 +560,7 @@ func file_configs_bootstrap_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_configs_bootstrap_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_bootstrap_proto_rawDesc), len(file_configs_bootstrap_proto_rawDesc)), NumEnums: 0, NumMessages: 6, NumExtensions: 0, @@ -620,7 +571,6 @@ func file_configs_bootstrap_proto_init() { MessageInfos: file_configs_bootstrap_proto_msgTypes, }.Build() File_configs_bootstrap_proto = out.File - file_configs_bootstrap_proto_rawDesc = nil file_configs_bootstrap_proto_goTypes = nil file_configs_bootstrap_proto_depIdxs = nil } diff --git a/internal/configs/bootstrap.pb.validate.go b/internal/configs/bootstrap.pb.validate.go index 16f98f07..3322c892 100644 --- a/internal/configs/bootstrap.pb.validate.go +++ b/internal/configs/bootstrap.pb.validate.go @@ -77,7 +77,7 @@ type EntrySelectorConfigMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m EntrySelectorConfigMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -190,7 +190,7 @@ type ServiceConfigMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ServiceConfigMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -603,6 +603,35 @@ func (m *Bootstrap) validate(all bool) error { } } + if all { + switch v := interface{}(m.GetLogger()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Logger", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Logger", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetLogger()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "Logger", + reason: "embedded message failed validation", + cause: err, + } + } + } + if len(errors) > 0 { return BootstrapMultiError(errors) } @@ -616,7 +645,7 @@ type BootstrapMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m BootstrapMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -727,7 +756,7 @@ type SettingsMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m SettingsMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -831,7 +860,7 @@ type Bootstrap_HealthCheckMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m Bootstrap_HealthCheckMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -964,7 +993,7 @@ type Bootstrap_EntryMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m Bootstrap_EntryMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto index fc275229..548dc083 100644 --- a/internal/configs/bootstrap.proto +++ b/internal/configs/bootstrap.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package origadmin.configs.api; +import "config/v1/logger.proto"; import "config/v1/registry.proto"; import "config/v1/security.proto"; import "config/v1/service.proto"; @@ -23,8 +24,8 @@ message ServiceConfig { json_name = "name", (validate.rules).string.min_len = 1 ]; -// Entry entry = 2 [json_name = "entry"]; // 各服务独立入口配置 -// repeated config.v1.Service services = 3 [json_name = "services"]; // 服务专用配置 + // Entry entry = 2 [json_name = "entry"]; // 各服务独立入口配置 + // repeated config.v1.Service services = 3 [json_name = "services"]; // 服务专用配置 } message Bootstrap { @@ -80,29 +81,9 @@ message Bootstrap { security.v1.AuthZ authz = 1001 [json_name = "authz"]; config.v1.Security security = 1002 [json_name = "security"]; HealthCheck health_check = 1003 [json_name = "health_check"]; + config.v1.Logger logger = 1004 [json_name = "logger"]; } -//message Server { -// message Cors { -// bool enabled = 1; -// bool allow_all_origins = 2 [json_name = "allow_all_origins"]; -// repeated string allow_origins = 3 [json_name = "allow_origins"]; -// repeated string allow_methods = 4 [json_name = "allow_methods"]; -// repeated string allow_headers = 5 [json_name = "allow_headers"]; -// bool allow_credentials = 6 [json_name = "allow_credentials"]; -// repeated string expose_headers = 7 [json_name = "expose_headers"]; -// int32 max_age = 8 [json_name = "max_age"]; -// bool allow_wildcard = 9 [json_name = "allow_wildcard"]; -// bool allow_browser_extensions = 10 [json_name = "allow_browser_extensions"]; -// bool allow_web_sockets = 11 [json_name = "allow_web_sockets"]; -// bool allow_files = 12 [json_name = "allow_files"]; -// } -// -// Cors cors = 1 [json_name = "cors"]; -// -// string host = 100 [json_name = "host"]; -//} - message Settings { string crypto_type = 1 [json_name = "crypto_type"]; } diff --git a/internal/configs/captcha.pb.go b/internal/configs/captcha.pb.go index 8b1ace74..355e273f 100644 --- a/internal/configs/captcha.pb.go +++ b/internal/configs/captcha.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc v5.28.3 // source: configs/captcha.proto @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -22,15 +23,14 @@ const ( ) type Captcha struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Length int32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"` + Width int32 `protobuf:"varint,2,opt,name=width,proto3" json:"width,omitempty"` + Height int32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + StorageName string `protobuf:"bytes,4,opt,name=storage_name,proto3" json:"storage_name,omitempty"` + Storage *v1.Storage `protobuf:"bytes,5,opt,name=storage,proto3" json:"storage,omitempty"` unknownFields protoimpl.UnknownFields - - Length int32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"` - Width int32 `protobuf:"varint,2,opt,name=width,proto3" json:"width,omitempty"` - Height int32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` - StorageName string `protobuf:"bytes,4,opt,name=storage_name,proto3" json:"storage_name,omitempty"` - Storage *v1.Storage `protobuf:"bytes,5,opt,name=storage,proto3" json:"storage,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Captcha) Reset() { @@ -100,36 +100,24 @@ func (x *Captcha) GetStorage() *v1.Storage { var File_configs_captcha_proto protoreflect.FileDescriptor -var file_configs_captcha_proto_rawDesc = []byte{ - 0x0a, 0x15, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, - 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, - 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa1, 0x01, 0x0a, 0x07, 0x43, 0x61, 0x70, 0x74, - 0x63, 0x68, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x06, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x77, - 0x69, 0x64, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x77, 0x69, 0x64, 0x74, - 0x68, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x74, 0x6f, - 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, - 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, - 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, - 0x67, 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, - 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, -} +const file_configs_captcha_proto_rawDesc = "" + + "\n" + + "\x15configs/captcha.proto\x12\x15origadmin.configs.api\x1a\x17config/v1/storage.proto\"\xa1\x01\n" + + "\aCaptcha\x12\x16\n" + + "\x06length\x18\x01 \x01(\x05R\x06length\x12\x14\n" + + "\x05width\x18\x02 \x01(\x05R\x05width\x12\x16\n" + + "\x06height\x18\x03 \x01(\x05R\x06height\x12\"\n" + + "\fstorage_name\x18\x04 \x01(\tR\fstorage_name\x12,\n" + + "\astorage\x18\x05 \x01(\v2\x12.config.v1.StorageR\astorageB.Z,origadmin/application/admin/internal/configsb\x06proto3" var ( file_configs_captcha_proto_rawDescOnce sync.Once - file_configs_captcha_proto_rawDescData = file_configs_captcha_proto_rawDesc + file_configs_captcha_proto_rawDescData []byte ) func file_configs_captcha_proto_rawDescGZIP() []byte { file_configs_captcha_proto_rawDescOnce.Do(func() { - file_configs_captcha_proto_rawDescData = protoimpl.X.CompressGZIP(file_configs_captcha_proto_rawDescData) + file_configs_captcha_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_captcha_proto_rawDesc), len(file_configs_captcha_proto_rawDesc))) }) return file_configs_captcha_proto_rawDescData } @@ -157,7 +145,7 @@ func file_configs_captcha_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_configs_captcha_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_captcha_proto_rawDesc), len(file_configs_captcha_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -168,7 +156,6 @@ func file_configs_captcha_proto_init() { MessageInfos: file_configs_captcha_proto_msgTypes, }.Build() File_configs_captcha_proto = out.File - file_configs_captcha_proto_rawDesc = nil file_configs_captcha_proto_goTypes = nil file_configs_captcha_proto_depIdxs = nil } diff --git a/internal/configs/captcha.pb.validate.go b/internal/configs/captcha.pb.validate.go index 9673c480..c354c51f 100644 --- a/internal/configs/captcha.pb.validate.go +++ b/internal/configs/captcha.pb.validate.go @@ -106,7 +106,7 @@ type CaptchaMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CaptchaMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/internal/configs/root_user.pb.go b/internal/configs/root_user.pb.go index 07ec0d69..56f92d52 100644 --- a/internal/configs/root_user.pb.go +++ b/internal/configs/root_user.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc v5.28.3 // source: configs/root_user.proto @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -22,23 +23,22 @@ const ( ) type RootUser struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` - Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` - Salt string `protobuf:"bytes,5,opt,name=salt,proto3" json:"salt,omitempty"` - Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` - Email string `protobuf:"bytes,7,opt,name=email,proto3" json:"email,omitempty"` - Nickname string `protobuf:"bytes,8,opt,name=nickname,proto3" json:"nickname,omitempty"` - Avatar string `protobuf:"bytes,9,opt,name=avatar,proto3" json:"avatar,omitempty"` - Mobile string `protobuf:"bytes,10,opt,name=mobile,proto3" json:"mobile,omitempty"` - Description string `protobuf:"bytes,11,opt,name=description,proto3" json:"description,omitempty"` - AutoCreate bool `protobuf:"varint,100,opt,name=auto_create,proto3" json:"auto_create,omitempty"` - RandomPassword bool `protobuf:"varint,101,opt,name=random_password,proto3" json:"random_password,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` + Salt string `protobuf:"bytes,5,opt,name=salt,proto3" json:"salt,omitempty"` + Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` + Email string `protobuf:"bytes,7,opt,name=email,proto3" json:"email,omitempty"` + Nickname string `protobuf:"bytes,8,opt,name=nickname,proto3" json:"nickname,omitempty"` + Avatar string `protobuf:"bytes,9,opt,name=avatar,proto3" json:"avatar,omitempty"` + Mobile string `protobuf:"bytes,10,opt,name=mobile,proto3" json:"mobile,omitempty"` + Description string `protobuf:"bytes,11,opt,name=description,proto3" json:"description,omitempty"` + AutoCreate bool `protobuf:"varint,100,opt,name=auto_create,proto3" json:"auto_create,omitempty"` + RandomPassword bool `protobuf:"varint,101,opt,name=random_password,proto3" json:"random_password,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *RootUser) Reset() { @@ -164,50 +164,33 @@ func (x *RootUser) GetRandomPassword() bool { var File_configs_root_user_proto protoreflect.FileDescriptor -var file_configs_root_user_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x72, 0x6f, 0x6f, 0x74, 0x5f, 0x75, - 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x6f, 0x72, 0x69, 0x67, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x03, 0x0a, 0x08, 0x52, 0x6f, - 0x6f, 0x74, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, - 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, - 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x02, 0x69, 0x64, 0x12, 0x23, 0x0a, 0x08, 0x75, 0x73, 0x65, - 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, - 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, - 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x10, 0x06, 0x18, 0x20, 0x52, 0x08, 0x70, 0x61, 0x73, - 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1d, 0x0a, 0x04, 0x73, 0x61, 0x6c, 0x74, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x09, 0xfa, 0x42, 0x06, 0x72, 0x04, 0x10, 0x06, 0x18, 0x0c, 0x52, 0x04, - 0x73, 0x61, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, - 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, - 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, - 0x61, 0x74, 0x61, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, - 0x61, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, - 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x64, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0b, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x28, - 0x0a, 0x0f, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, - 0x64, 0x18, 0x65, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x5f, - 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, - 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, - 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_configs_root_user_proto_rawDesc = "" + + "\n" + + "\x17configs/root_user.proto\x12\x15origadmin.configs.api\x1a\x17validate/validate.proto\"\x8c\x03\n" + + "\bRootUser\x12\x18\n" + + "\aenabled\x18\x01 \x01(\bR\aenabled\x12\x17\n" + + "\x02id\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x02id\x12#\n" + + "\busername\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12%\n" + + "\bpassword\x18\x04 \x01(\tB\t\xfaB\x06r\x04\x10\x06\x18 R\bpassword\x12\x1d\n" + + "\x04salt\x18\x05 \x01(\tB\t\xfaB\x06r\x04\x10\x06\x18\fR\x04salt\x12\x12\n" + + "\x04name\x18\x06 \x01(\tR\x04name\x12\x14\n" + + "\x05email\x18\a \x01(\tR\x05email\x12\x1a\n" + + "\bnickname\x18\b \x01(\tR\bnickname\x12\x16\n" + + "\x06avatar\x18\t \x01(\tR\x06avatar\x12\x16\n" + + "\x06mobile\x18\n" + + " \x01(\tR\x06mobile\x12 \n" + + "\vdescription\x18\v \x01(\tR\vdescription\x12 \n" + + "\vauto_create\x18d \x01(\bR\vauto_create\x12(\n" + + "\x0frandom_password\x18e \x01(\bR\x0frandom_passwordB.Z,origadmin/application/admin/internal/configsb\x06proto3" var ( file_configs_root_user_proto_rawDescOnce sync.Once - file_configs_root_user_proto_rawDescData = file_configs_root_user_proto_rawDesc + file_configs_root_user_proto_rawDescData []byte ) func file_configs_root_user_proto_rawDescGZIP() []byte { file_configs_root_user_proto_rawDescOnce.Do(func() { - file_configs_root_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_configs_root_user_proto_rawDescData) + file_configs_root_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_root_user_proto_rawDesc), len(file_configs_root_user_proto_rawDesc))) }) return file_configs_root_user_proto_rawDescData } @@ -233,7 +216,7 @@ func file_configs_root_user_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_configs_root_user_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_root_user_proto_rawDesc), len(file_configs_root_user_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -244,7 +227,6 @@ func file_configs_root_user_proto_init() { MessageInfos: file_configs_root_user_proto_msgTypes, }.Build() File_configs_root_user_proto = out.File - file_configs_root_user_proto_rawDesc = nil file_configs_root_user_proto_goTypes = nil file_configs_root_user_proto_depIdxs = nil } diff --git a/internal/configs/root_user.pb.validate.go b/internal/configs/root_user.pb.validate.go index b489a47b..7bbf6e68 100644 --- a/internal/configs/root_user.pb.validate.go +++ b/internal/configs/root_user.pb.validate.go @@ -132,7 +132,7 @@ type RootUserMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RootUserMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/internal/configs/server.pb.go b/internal/configs/server.pb.go index 74cb00f8..b8bf3b28 100644 --- a/internal/configs/server.pb.go +++ b/internal/configs/server.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc v5.28.3 // source: configs/server.proto @@ -13,6 +13,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -23,16 +24,15 @@ const ( ) type Server struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` + Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` + Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` + Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` + Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` - Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` - Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` - Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Server) Reset() { @@ -109,47 +109,27 @@ func (x *Server) GetMiddleware() *v11.Middleware { var File_configs_server_proto protoreflect.FileDescriptor -var file_configs_server_proto_rawDesc = []byte{ - 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1f, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x2e, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, - 0x76, 0x31, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, - 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x81, 0x02, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a, 0x07, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, - 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x73, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x18, 0xac, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, - 0x65, 0x52, 0x07, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x90, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x72, 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x39, 0x0a, 0x0a, - 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x19, 0x2e, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, - 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, - 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x6f, 0x72, 0x69, 0x67, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_configs_server_proto_rawDesc = "" + + "\n" + + "\x14configs/server.proto\x12\x1forigadmin.origadmin.configs.api\x1a\x17config/v1/storage.proto\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x1emiddleware/v1/middleware.proto\"\x81\x02\n" + + "\x06Server\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + + "\aversion\x18\x02 \x01(\tR\aversion\x12-\n" + + "\aservice\x18\xc8\x01 \x01(\v2\x12.config.v1.ServiceR\aservice\x12-\n" + + "\astorage\x18\xac\x02 \x01(\v2\x12.config.v1.StorageR\astorage\x120\n" + + "\bregistry\x18\x90\x03 \x01(\v2\x13.config.v1.RegistryR\bregistry\x129\n" + + "\n" + + "middleware\x18\t \x01(\v2\x19.middleware.v1.MiddlewareR\n" + + "middlewareB.Z,origadmin/application/admin/internal/configsb\x06proto3" var ( file_configs_server_proto_rawDescOnce sync.Once - file_configs_server_proto_rawDescData = file_configs_server_proto_rawDesc + file_configs_server_proto_rawDescData []byte ) func file_configs_server_proto_rawDescGZIP() []byte { file_configs_server_proto_rawDescOnce.Do(func() { - file_configs_server_proto_rawDescData = protoimpl.X.CompressGZIP(file_configs_server_proto_rawDescData) + file_configs_server_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_server_proto_rawDesc), len(file_configs_server_proto_rawDesc))) }) return file_configs_server_proto_rawDescData } @@ -183,7 +163,7 @@ func file_configs_server_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_configs_server_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_server_proto_rawDesc), len(file_configs_server_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, @@ -194,7 +174,6 @@ func file_configs_server_proto_init() { MessageInfos: file_configs_server_proto_msgTypes, }.Build() File_configs_server_proto = out.File - file_configs_server_proto_rawDesc = nil file_configs_server_proto_goTypes = nil file_configs_server_proto_depIdxs = nil } diff --git a/internal/configs/server.pb.validate.go b/internal/configs/server.pb.validate.go index 734ad809..066561b4 100644 --- a/internal/configs/server.pb.validate.go +++ b/internal/configs/server.pb.validate.go @@ -189,7 +189,7 @@ type ServerMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ServerMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/internal/configs/services/service.pb.go b/internal/configs/services/service.pb.go index 0f63913e..c43d14e1 100644 --- a/internal/configs/services/service.pb.go +++ b/internal/configs/services/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc v5.28.3 // source: configs/services/service.proto @@ -13,6 +13,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -23,14 +24,13 @@ const ( ) type ServiceCore struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` + Registry *v1.Registry `protobuf:"bytes,3,opt,name=registry,proto3" json:"registry,omitempty"` + Storages []*v1.Storage `protobuf:"bytes,4,rep,name=storages,proto3" json:"storages,omitempty"` unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Registry *v1.Registry `protobuf:"bytes,3,opt,name=registry,proto3" json:"registry,omitempty"` - Storages []*v1.Storage `protobuf:"bytes,4,rep,name=storages,proto3" json:"storages,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ServiceCore) Reset() { @@ -92,13 +92,12 @@ func (x *ServiceCore) GetStorages() []*v1.Storage { } type Service struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` + Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` + Middleware *v11.Middleware `protobuf:"bytes,300,opt,name=middleware,proto3" json:"middleware,omitempty"` unknownFields protoimpl.UnknownFields - - Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` - Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` - Middleware *v11.Middleware `protobuf:"bytes,300,opt,name=middleware,proto3" json:"middleware,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Service) Reset() { @@ -154,54 +153,29 @@ func (x *Service) GetMiddleware() *v11.Middleware { var File_configs_services_service_proto protoreflect.FileDescriptor -var file_configs_services_service_proto_rawDesc = []byte{ - 0x0a, 0x1e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x1e, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x61, 0x70, 0x69, - 0x1a, 0x18, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x73, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x6d, 0x69, - 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, - 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9c, 0x01, 0x0a, - 0x0b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x0a, 0x08, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x79, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x12, 0x2e, 0x0a, 0x08, 0x73, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, - 0x65, 0x52, 0x08, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x73, 0x22, 0xb5, 0x01, 0x0a, 0x07, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3f, 0x0a, 0x04, 0x63, 0x6f, 0x72, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x73, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, - 0x72, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x18, 0xc8, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3a, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, - 0x65, 0x77, 0x61, 0x72, 0x65, 0x18, 0xac, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, - 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x69, 0x64, - 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, - 0x61, 0x72, 0x65, 0x42, 0x37, 0x5a, 0x35, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, - 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, 0x64, 0x6d, - 0x69, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x73, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -} +const file_configs_services_service_proto_rawDesc = "" + + "\n" + + "\x1econfigs/services/service.proto\x12\x1eorigadmin.configs.services.api\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1emiddleware/v1/middleware.proto\"\x9c\x01\n" + + "\vServiceCore\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + + "\aversion\x18\x02 \x01(\tR\aversion\x12/\n" + + "\bregistry\x18\x03 \x01(\v2\x13.config.v1.RegistryR\bregistry\x12.\n" + + "\bstorages\x18\x04 \x03(\v2\x12.config.v1.StorageR\bstorages\"\xb5\x01\n" + + "\aService\x12?\n" + + "\x04core\x18\x01 \x01(\v2+.origadmin.configs.services.api.ServiceCoreR\x04core\x12-\n" + + "\aservice\x18\xc8\x01 \x01(\v2\x12.config.v1.ServiceR\aservice\x12:\n" + + "\n" + + "middleware\x18\xac\x02 \x01(\v2\x19.middleware.v1.MiddlewareR\n" + + "middlewareB7Z5origadmin/application/admin/internal/configs/servicesb\x06proto3" var ( file_configs_services_service_proto_rawDescOnce sync.Once - file_configs_services_service_proto_rawDescData = file_configs_services_service_proto_rawDesc + file_configs_services_service_proto_rawDescData []byte ) func file_configs_services_service_proto_rawDescGZIP() []byte { file_configs_services_service_proto_rawDescOnce.Do(func() { - file_configs_services_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_configs_services_service_proto_rawDescData) + file_configs_services_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_services_service_proto_rawDesc), len(file_configs_services_service_proto_rawDesc))) }) return file_configs_services_service_proto_rawDescData } @@ -237,7 +211,7 @@ func file_configs_services_service_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_configs_services_service_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_services_service_proto_rawDesc), len(file_configs_services_service_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -248,7 +222,6 @@ func file_configs_services_service_proto_init() { MessageInfos: file_configs_services_service_proto_msgTypes, }.Build() File_configs_services_service_proto = out.File - file_configs_services_service_proto_rawDesc = nil file_configs_services_service_proto_goTypes = nil file_configs_services_service_proto_depIdxs = nil } diff --git a/internal/configs/services/service.pb.validate.go b/internal/configs/services/service.pb.validate.go index c5a9267c..fabb91d3 100644 --- a/internal/configs/services/service.pb.validate.go +++ b/internal/configs/services/service.pb.validate.go @@ -137,7 +137,7 @@ type ServiceCoreMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ServiceCoreMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -322,7 +322,7 @@ type ServiceMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ServiceMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/internal/mods/casbin/dal/casbin-adapter.dal.go b/internal/data/casbin-adapter.dal.go similarity index 98% rename from internal/mods/casbin/dal/casbin-adapter.dal.go rename to internal/data/casbin-adapter.dal.go index 801e45b7..c49cca72 100644 --- a/internal/mods/casbin/dal/casbin-adapter.dal.go +++ b/internal/data/casbin-adapter.dal.go @@ -2,7 +2,7 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -package dal +package data import ( "context" @@ -16,9 +16,9 @@ import ( "github.com/casbin/casbin/v2/model" "github.com/casbin/casbin/v2/persist" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/predicate" ) const ( diff --git a/internal/data/data.go b/internal/data/data.go new file mode 100644 index 00000000..a0394d6b --- /dev/null +++ b/internal/data/data.go @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package data implements the functions, types, and interfaces for the module. +package data + +import ( + "errors" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/schema" + "github.com/google/wire" + "github.com/origadmin/contrib/database" + "github.com/origadmin/entslog/v3" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/runtime/log" + + "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/data/entity/ent" +) + +// ProviderSet is data providers. +var ProviderSet = wire.NewSet( + //wire.Struct(new(LoginData), "*"), + NewDataWithClient, +) + +type Data struct { + *ent.Database +} + +type LoginData struct { + Captcha *configs.Captcha + RootUser *configs.RootUser + Tokenizer security.RefreshTokenizer + //Resource systemdto.ResourceRepo + //Role systemdto.RoleRepo + //User systemdto.UserRepo +} + +func NewDataWithClient(client *ent.Client) *Data { + return &Data{ + Database: ent.NewDatabaseWithClient(client), + } +} + +func debugDatabase(driver dialect.Driver, debug bool) dialect.Driver { + if debug { + return entslog.New(driver) + } + return driver +} + +// NewData . + +// NewData . +func NewData(r runtime.Runtime, bootstrap *configs.Bootstrap) (*Data, func(), error) { + if bootstrap == nil { + return nil, nil, errors.New("bootstrap is nil") + } + + cfg := bootstrap.GetStorage().GetDatabase() + if cfg == nil { + return nil, nil, errors.New("data source not found") + } + + drv, err := database.Open(cfg) + log.Infow("msg", "connecting to database", "dialect", cfg.Dialect, "source", cfg.Source) + if err != nil { + log.Errorw("msg", "failed opening connection to database", "error", err) + return nil, nil, err + } + + // Run the auto migration tool. + //sqldb := debugDatabase(sql.OpenDB(cfg.Dialect, drv), cfg.Debug) + + db := ent.NewDatabase(ent.Driver(sql.OpenDB(cfg.Dialect, drv)), ent.WithDebug(func(driver dialect.Driver, f ...func(...any)) dialect.Driver { + return debugDatabase(driver, cfg.Debug) + })) + if true || cfg.GetMigration().GetEnabled() { + if err := db.Migration( + r.Context(), + schema.WithDropIndex(true), + schema.WithDropColumn(true), + schema.WithForeignKeys(false)); err != nil { + log.Errorw("msg", "failed creating schema resources", "error", err) + return nil, nil, err + } + } + + data := &Data{ + Database: db, + } + + return data, func() { + log.Info("closing the data resources") + if err := drv.Close(); err != nil { + log.Error(err) + } + }, nil +} diff --git a/internal/mods/casbin/dal/entity/ent/casbinrule.go b/internal/data/entity/ent/casbinrule.go similarity index 98% rename from internal/mods/casbin/dal/entity/ent/casbinrule.go rename to internal/data/entity/ent/casbinrule.go index be856688..f495842c 100644 --- a/internal/mods/casbin/dal/entity/ent/casbinrule.go +++ b/internal/data/entity/ent/casbinrule.go @@ -4,7 +4,7 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" "strings" "entgo.io/ent" diff --git a/internal/mods/casbin/dal/entity/ent/casbinrule/casbinrule.go b/internal/data/entity/ent/casbinrule/casbinrule.go similarity index 100% rename from internal/mods/casbin/dal/entity/ent/casbinrule/casbinrule.go rename to internal/data/entity/ent/casbinrule/casbinrule.go diff --git a/internal/mods/casbin/dal/entity/ent/casbinrule/where.go b/internal/data/entity/ent/casbinrule/where.go similarity index 99% rename from internal/mods/casbin/dal/entity/ent/casbinrule/where.go rename to internal/data/entity/ent/casbinrule/where.go index 61206ad9..28328367 100644 --- a/internal/mods/casbin/dal/entity/ent/casbinrule/where.go +++ b/internal/data/entity/ent/casbinrule/where.go @@ -3,7 +3,7 @@ package casbinrule import ( - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent/dialect/sql" ) diff --git a/internal/mods/casbin/dal/entity/ent/casbinrule_create.go b/internal/data/entity/ent/casbinrule_create.go similarity index 99% rename from internal/mods/casbin/dal/entity/ent/casbinrule_create.go rename to internal/data/entity/ent/casbinrule_create.go index 688e642b..9a8fb02f 100644 --- a/internal/mods/casbin/dal/entity/ent/casbinrule_create.go +++ b/internal/data/entity/ent/casbinrule_create.go @@ -6,7 +6,7 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" diff --git a/internal/mods/casbin/dal/entity/ent/casbinrule_delete.go b/internal/data/entity/ent/casbinrule_delete.go similarity index 93% rename from internal/mods/casbin/dal/entity/ent/casbinrule_delete.go rename to internal/data/entity/ent/casbinrule_delete.go index e0a12720..8512a6e0 100644 --- a/internal/mods/casbin/dal/entity/ent/casbinrule_delete.go +++ b/internal/data/entity/ent/casbinrule_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/casbin/dal/entity/ent/casbinrule_query.go b/internal/data/entity/ent/casbinrule_query.go similarity index 99% rename from internal/mods/casbin/dal/entity/ent/casbinrule_query.go rename to internal/data/entity/ent/casbinrule_query.go index 88e3218d..5e8b2676 100644 --- a/internal/mods/casbin/dal/entity/ent/casbinrule_query.go +++ b/internal/data/entity/ent/casbinrule_query.go @@ -6,8 +6,8 @@ import ( "context" "fmt" "math" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/casbin/dal/entity/ent/casbinrule_update.go b/internal/data/entity/ent/casbinrule_update.go similarity index 98% rename from internal/mods/casbin/dal/entity/ent/casbinrule_update.go rename to internal/data/entity/ent/casbinrule_update.go index 3773ae71..f0d72f88 100644 --- a/internal/mods/casbin/dal/entity/ent/casbinrule_update.go +++ b/internal/data/entity/ent/casbinrule_update.go @@ -6,8 +6,8 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/client.go b/internal/data/entity/ent/client.go similarity index 93% rename from internal/mods/system/dal/entity/ent/client.go rename to internal/data/entity/ent/client.go index e7f54ead..dc5e94dd 100644 --- a/internal/mods/system/dal/entity/ent/client.go +++ b/internal/data/entity/ent/client.go @@ -9,20 +9,21 @@ import ( "log" "reflect" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/migrate" - - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/migrate" + + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/userrole" "entgo.io/ent" "entgo.io/ent/dialect" @@ -35,6 +36,8 @@ type Client struct { config // Schema is the client for creating, migrating and dropping schema. Schema *migrate.Schema + // CasbinRule is the client for interacting with the CasbinRule builders. + CasbinRule *CasbinRuleClient // Department is the client for interacting with the Department builders. Department *DepartmentClient // Permission is the client for interacting with the Permission builders. @@ -70,6 +73,7 @@ func NewClient(opts ...Option) *Client { func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) + c.CasbinRule = NewCasbinRuleClient(c.config) c.Department = NewDepartmentClient(c.config) c.Permission = NewPermissionClient(c.config) c.PermissionResource = NewPermissionResourceClient(c.config) @@ -90,7 +94,7 @@ type ( // driver used for executing database requests. driver dialect.Driver // debug enable a debug logging. - debug bool + debug func(dialect.Driver, ...func(...any)) dialect.Driver // log used for logging on debug mode. log func(...any) // hooks to execute on mutations. @@ -114,15 +118,22 @@ func (c *config) options(opts ...Option) { for _, opt := range opts { opt(c) } - if c.debug { - c.driver = dialect.Debug(c.driver, c.log) + if c.debug != nil { + c.driver = c.debug(c.driver, c.log) } } // Debug enables debug logging on the ent.Driver. func Debug() Option { return func(c *config) { - c.debug = true + c.debug = dialect.Debug + } +} + +// WithDebug configures the debug function. +func WithDebug(fn func(dialect.Driver, ...func(...any)) dialect.Driver) Option { + return func(c *config) { + c.debug = fn } } @@ -174,6 +185,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { return &Tx{ ctx: ctx, config: cfg, + CasbinRule: NewCasbinRuleClient(cfg), Department: NewDepartmentClient(cfg), Permission: NewPermissionClient(cfg), PermissionResource: NewPermissionResourceClient(cfg), @@ -205,6 +217,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) return &Tx{ ctx: ctx, config: cfg, + CasbinRule: NewCasbinRuleClient(cfg), Department: NewDepartmentClient(cfg), Permission: NewPermissionClient(cfg), PermissionResource: NewPermissionResourceClient(cfg), @@ -223,15 +236,15 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) // Debug returns a new debug-client. It's used to get verbose logging on specific operations. // // client.Debug(). -// Department. +// CasbinRule. // Query(). // Count(ctx) func (c *Client) Debug() *Client { - if c.debug { + if c.debug != nil { return c } cfg := c.config - cfg.driver = dialect.Debug(c.driver, c.log) + cfg.driver = c.debug(c.driver, c.log) client := &Client{config: cfg} client.init() return client @@ -246,7 +259,7 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.Department, c.Permission, c.PermissionResource, c.Position, + c.CasbinRule, c.Department, c.Permission, c.PermissionResource, c.Position, c.PositionPermission, c.Resource, c.Role, c.RolePermission, c.User, c.UserDepartment, c.UserPosition, c.UserRole, } { @@ -258,7 +271,7 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Department, c.Permission, c.PermissionResource, c.Position, + c.CasbinRule, c.Department, c.Permission, c.PermissionResource, c.Position, c.PositionPermission, c.Resource, c.Role, c.RolePermission, c.User, c.UserDepartment, c.UserPosition, c.UserRole, } { @@ -269,6 +282,8 @@ func (c *Client) Intercept(interceptors ...Interceptor) { // Mutate implements the ent.Mutator interface. func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { switch m := m.(type) { + case *CasbinRuleMutation: + return c.CasbinRule.mutate(ctx, m) case *DepartmentMutation: return c.Department.mutate(ctx, m) case *PermissionMutation: @@ -298,6 +313,139 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { } } +// CasbinRuleClient is a client for the CasbinRule schema. +type CasbinRuleClient struct { + config +} + +// NewCasbinRuleClient returns a client for the CasbinRule from the given config. +func NewCasbinRuleClient(c config) *CasbinRuleClient { + return &CasbinRuleClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `casbinrule.Hooks(f(g(h())))`. +func (c *CasbinRuleClient) Use(hooks ...Hook) { + c.hooks.CasbinRule = append(c.hooks.CasbinRule, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `casbinrule.Intercept(f(g(h())))`. +func (c *CasbinRuleClient) Intercept(interceptors ...Interceptor) { + c.inters.CasbinRule = append(c.inters.CasbinRule, interceptors...) +} + +// Create returns a builder for creating a CasbinRule entity. +func (c *CasbinRuleClient) Create() *CasbinRuleCreate { + mutation := newCasbinRuleMutation(c.config, OpCreate) + return &CasbinRuleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of CasbinRule entities. +func (c *CasbinRuleClient) CreateBulk(builders ...*CasbinRuleCreate) *CasbinRuleCreateBulk { + return &CasbinRuleCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *CasbinRuleClient) MapCreateBulk(slice any, setFunc func(*CasbinRuleCreate, int)) *CasbinRuleCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &CasbinRuleCreateBulk{err: fmt.Errorf("calling to CasbinRuleClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*CasbinRuleCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &CasbinRuleCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for CasbinRule. +func (c *CasbinRuleClient) Update() *CasbinRuleUpdate { + mutation := newCasbinRuleMutation(c.config, OpUpdate) + return &CasbinRuleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *CasbinRuleClient) UpdateOne(cr *CasbinRule) *CasbinRuleUpdateOne { + mutation := newCasbinRuleMutation(c.config, OpUpdateOne, withCasbinRule(cr)) + return &CasbinRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *CasbinRuleClient) UpdateOneID(id int) *CasbinRuleUpdateOne { + mutation := newCasbinRuleMutation(c.config, OpUpdateOne, withCasbinRuleID(id)) + return &CasbinRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for CasbinRule. +func (c *CasbinRuleClient) Delete() *CasbinRuleDelete { + mutation := newCasbinRuleMutation(c.config, OpDelete) + return &CasbinRuleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *CasbinRuleClient) DeleteOne(cr *CasbinRule) *CasbinRuleDeleteOne { + return c.DeleteOneID(cr.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *CasbinRuleClient) DeleteOneID(id int) *CasbinRuleDeleteOne { + builder := c.Delete().Where(casbinrule.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &CasbinRuleDeleteOne{builder} +} + +// Query returns a query builder for CasbinRule. +func (c *CasbinRuleClient) Query() *CasbinRuleQuery { + return &CasbinRuleQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeCasbinRule}, + inters: c.Interceptors(), + } +} + +// Get returns a CasbinRule entity by its id. +func (c *CasbinRuleClient) Get(ctx context.Context, id int) (*CasbinRule, error) { + return c.Query().Where(casbinrule.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *CasbinRuleClient) GetX(ctx context.Context, id int) *CasbinRule { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *CasbinRuleClient) Hooks() []Hook { + return c.hooks.CasbinRule +} + +// Interceptors returns the client interceptors. +func (c *CasbinRuleClient) Interceptors() []Interceptor { + return c.inters.CasbinRule +} + +func (c *CasbinRuleClient) mutate(ctx context.Context, m *CasbinRuleMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&CasbinRuleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&CasbinRuleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&CasbinRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&CasbinRuleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown CasbinRule mutation op: %q", m.Op()) + } +} + // DepartmentClient is a client for the Department schema. type DepartmentClient struct { config @@ -2571,13 +2719,13 @@ func (c *UserRoleClient) mutate(ctx context.Context, m *UserRoleMutation) (Value // hooks and interceptors per client, for fast access. type ( hooks struct { - Department, Permission, PermissionResource, Position, PositionPermission, - Resource, Role, RolePermission, User, UserDepartment, UserPosition, - UserRole []ent.Hook + CasbinRule, Department, Permission, PermissionResource, Position, + PositionPermission, Resource, Role, RolePermission, User, UserDepartment, + UserPosition, UserRole []ent.Hook } inters struct { - Department, Permission, PermissionResource, Position, PositionPermission, - Resource, Role, RolePermission, User, UserDepartment, UserPosition, - UserRole []ent.Interceptor + CasbinRule, Department, Permission, PermissionResource, Position, + PositionPermission, Resource, Role, RolePermission, User, UserDepartment, + UserPosition, UserRole []ent.Interceptor } ) diff --git a/internal/mods/casbin/dal/entity/ent/crud.go b/internal/data/entity/ent/crud.go similarity index 100% rename from internal/mods/casbin/dal/entity/ent/crud.go rename to internal/data/entity/ent/crud.go diff --git a/internal/mods/system/dal/entity/ent/database.go b/internal/data/entity/ent/database.go similarity index 96% rename from internal/mods/system/dal/entity/ent/database.go rename to internal/data/entity/ent/database.go index 94d599e9..f59473ab 100644 --- a/internal/mods/system/dal/entity/ent/database.go +++ b/internal/data/entity/ent/database.go @@ -109,6 +109,11 @@ func (db *Database) Query(ctx context.Context, query string, args ...interface{} return &rows, nil } +// CasbinRule is the client for interacting with the CasbinRule builders. +func (db *Database) CasbinRule(ctx context.Context) *CasbinRuleClient { + return db.Client(ctx).CasbinRule +} + // Department is the client for interacting with the Department builders. func (db *Database) Department(ctx context.Context) *DepartmentClient { return db.Client(ctx).Department diff --git a/internal/mods/system/dal/entity/ent/department.go b/internal/data/entity/ent/department.go similarity index 99% rename from internal/mods/system/dal/entity/ent/department.go rename to internal/data/entity/ent/department.go index c322e11b..2d145c6c 100644 --- a/internal/mods/system/dal/entity/ent/department.go +++ b/internal/data/entity/ent/department.go @@ -4,7 +4,7 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/department" "strings" "time" diff --git a/internal/mods/system/dal/entity/ent/department_create.go b/internal/data/entity/ent/department_create.go similarity index 98% rename from internal/mods/system/dal/entity/ent/department_create.go rename to internal/data/entity/ent/department_create.go index a21d63e2..c05a492f 100644 --- a/internal/mods/system/dal/entity/ent/department_create.go +++ b/internal/data/entity/ent/department_create.go @@ -6,10 +6,10 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" "time" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/department_delete.go b/internal/data/entity/ent/department_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/department_delete.go rename to internal/data/entity/ent/department_delete.go index a0f5f5b0..90ea30a3 100644 --- a/internal/mods/system/dal/entity/ent/department_delete.go +++ b/internal/data/entity/ent/department_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/department_query.go b/internal/data/entity/ent/department_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/department_query.go rename to internal/data/entity/ent/department_query.go index 52deac5f..6aa920ea 100644 --- a/internal/mods/system/dal/entity/ent/department_query.go +++ b/internal/data/entity/ent/department_query.go @@ -7,11 +7,11 @@ import ( "database/sql/driver" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/department_update.go b/internal/data/entity/ent/department_update.go similarity index 99% rename from internal/mods/system/dal/entity/ent/department_update.go rename to internal/data/entity/ent/department_update.go index aec103e9..16fd6a7f 100644 --- a/internal/mods/system/dal/entity/ent/department_update.go +++ b/internal/data/entity/ent/department_update.go @@ -6,11 +6,11 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" "time" "entgo.io/ent/dialect/sql" diff --git a/internal/mods/system/dal/entity/ent/ent.go b/internal/data/entity/ent/ent.go similarity index 94% rename from internal/mods/system/dal/entity/ent/ent.go rename to internal/data/entity/ent/ent.go index 629b5585..e530c768 100644 --- a/internal/mods/system/dal/entity/ent/ent.go +++ b/internal/data/entity/ent/ent.go @@ -6,18 +6,19 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/userrole" "reflect" "sync" @@ -84,6 +85,7 @@ var ( func checkColumn(table, column string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + casbinrule.Table: casbinrule.ValidColumn, department.Table: department.ValidColumn, permission.Table: permission.ValidColumn, permissionresource.Table: permissionresource.ValidColumn, diff --git a/internal/mods/system/dal/entity/ent/enttest/enttest.go b/internal/data/entity/ent/enttest/enttest.go similarity index 88% rename from internal/mods/system/dal/entity/ent/enttest/enttest.go rename to internal/data/entity/ent/enttest/enttest.go index 1eb63fb6..624dcb28 100644 --- a/internal/mods/system/dal/entity/ent/enttest/enttest.go +++ b/internal/data/entity/ent/enttest/enttest.go @@ -5,11 +5,11 @@ package enttest import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" + "origadmin/application/admin/internal/data/entity/ent" // required by schema hooks. - _ "origadmin/application/admin/internal/mods/system/dal/entity/ent/runtime" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/migrate" + "origadmin/application/admin/internal/data/entity/ent/migrate" "entgo.io/ent/dialect/sql/schema" ) diff --git a/internal/data/entity/ent/generate.go b/internal/data/entity/ent/generate.go new file mode 100644 index 00000000..63845bbc --- /dev/null +++ b/internal/data/entity/ent/generate.go @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package ent is the data access object for SYS. +package ent + +//go:generate ./ent generate --template ./template --feature intercept --feature schema/snapshot --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema diff --git a/internal/mods/system/dal/entity/ent/hook/hook.go b/internal/data/entity/ent/hook/hook.go similarity index 95% rename from internal/mods/system/dal/entity/ent/hook/hook.go rename to internal/data/entity/ent/hook/hook.go index 95ea793b..43ead7fd 100644 --- a/internal/mods/system/dal/entity/ent/hook/hook.go +++ b/internal/data/entity/ent/hook/hook.go @@ -5,9 +5,21 @@ package hook import ( "context" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" + "origadmin/application/admin/internal/data/entity/ent" ) +// The CasbinRuleFunc type is an adapter to allow the use of ordinary +// function as CasbinRule mutator. +type CasbinRuleFunc func(context.Context, *ent.CasbinRuleMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f CasbinRuleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.CasbinRuleMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CasbinRuleMutation", m) +} + // The DepartmentFunc type is an adapter to allow the use of ordinary // function as Department mutator. type DepartmentFunc func(context.Context, *ent.DepartmentMutation) (ent.Value, error) diff --git a/internal/mods/system/dal/entity/ent/intercept/intercept.go b/internal/data/entity/ent/intercept/intercept.go similarity index 88% rename from internal/mods/system/dal/entity/ent/intercept/intercept.go rename to internal/data/entity/ent/intercept/intercept.go index 3225941b..e35adb18 100644 --- a/internal/mods/system/dal/entity/ent/intercept/intercept.go +++ b/internal/data/entity/ent/intercept/intercept.go @@ -6,20 +6,21 @@ import ( "context" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/userrole" "entgo.io/ent/dialect/sql" ) @@ -80,6 +81,33 @@ func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error { return f(ctx, query) } +// The CasbinRuleFunc type is an adapter to allow the use of ordinary function as a Querier. +type CasbinRuleFunc func(context.Context, *ent.CasbinRuleQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f CasbinRuleFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.CasbinRuleQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.CasbinRuleQuery", q) +} + +// The TraverseCasbinRule type is an adapter to allow the use of ordinary function as Traverser. +type TraverseCasbinRule func(context.Context, *ent.CasbinRuleQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseCasbinRule) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseCasbinRule) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.CasbinRuleQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.CasbinRuleQuery", q) +} + // The DepartmentFunc type is an adapter to allow the use of ordinary function as a Querier. type DepartmentFunc func(context.Context, *ent.DepartmentQuery) (ent.Value, error) @@ -407,6 +435,8 @@ func (f TraverseUserRole) Traverse(ctx context.Context, q ent.Query) error { // NewQuery returns the generic Query interface for the given typed query. func NewQuery(q ent.Query) (Query, error) { switch q := q.(type) { + case *ent.CasbinRuleQuery: + return &query[*ent.CasbinRuleQuery, predicate.CasbinRule, casbinrule.OrderOption]{typ: ent.TypeCasbinRule, tq: q}, nil case *ent.DepartmentQuery: return &query[*ent.DepartmentQuery, predicate.Department, department.OrderOption]{typ: ent.TypeDepartment, tq: q}, nil case *ent.PermissionQuery: diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go new file mode 100644 index 00000000..dfb7c20e --- /dev/null +++ b/internal/data/entity/ent/internal/schema.go @@ -0,0 +1,9 @@ +// Code generated by ent, DO NOT EDIT. + +//go:build tools +// +build tools + +// Package internal holds a loadable version of the latest schema. +package internal + +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"children\",\"type\":\"Resource\"},{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref_name\":\"children\",\"unique\":true,\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"i18n_key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n_key\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2,\"default\":true,\"default_value\":\"M\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.component\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.icon\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.visible\"},{\"name\":\"level\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.level\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"properties\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"resource.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"parent_id\"]},{\"fields\":[\"level\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"delete_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/mods/casbin/dal/entity/ent/migrate/migrate.go b/internal/data/entity/ent/migrate/migrate.go similarity index 100% rename from internal/mods/casbin/dal/entity/ent/migrate/migrate.go rename to internal/data/entity/ent/migrate/migrate.go diff --git a/internal/mods/system/dal/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go similarity index 97% rename from internal/mods/system/dal/entity/ent/migrate/schema.go rename to internal/data/entity/ent/migrate/schema.go index 5d80d611..8337e072 100644 --- a/internal/mods/system/dal/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -9,6 +9,23 @@ import ( ) var ( + // CasbinRulesColumns holds the columns for the "casbin_rules" table. + CasbinRulesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "ptype", Type: field.TypeString, Default: ""}, + {Name: "v0", Type: field.TypeString, Default: ""}, + {Name: "v1", Type: field.TypeString, Default: ""}, + {Name: "v2", Type: field.TypeString, Default: ""}, + {Name: "v3", Type: field.TypeString, Default: ""}, + {Name: "v4", Type: field.TypeString, Default: ""}, + {Name: "v5", Type: field.TypeString, Default: ""}, + } + // CasbinRulesTable holds the schema information for the "casbin_rules" table. + CasbinRulesTable = &schema.Table{ + Name: "casbin_rules", + Columns: CasbinRulesColumns, + PrimaryKey: []*schema.Column{CasbinRulesColumns[0]}, + } // SysDepartmentsColumns holds the columns for the "sys_departments" table. SysDepartmentsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, @@ -590,6 +607,7 @@ var ( } // Tables holds all the tables in the schema. Tables = []*schema.Table{ + CasbinRulesTable, SysDepartmentsTable, SysPermissionsTable, SysPermissionResourcesTable, diff --git a/internal/mods/system/dal/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go similarity index 94% rename from internal/mods/system/dal/entity/ent/mutation.go rename to internal/data/entity/ent/mutation.go index ba7def46..7f5df561 100644 --- a/internal/mods/system/dal/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -6,19 +6,20 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/userrole" "sync" "time" @@ -35,6 +36,7 @@ const ( OpUpdateOne = ent.OpUpdateOne // Node types. + TypeCasbinRule = "CasbinRule" TypeDepartment = "Department" TypePermission = "Permission" TypePermissionResource = "PermissionResource" @@ -49,6 +51,656 @@ const ( TypeUserRole = "UserRole" ) +// CasbinRuleMutation represents an operation that mutates the CasbinRule nodes in the graph. +type CasbinRuleMutation struct { + config + op Op + typ string + id *int + _Ptype *string + _V0 *string + _V1 *string + _V2 *string + _V3 *string + _V4 *string + _V5 *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*CasbinRule, error) + predicates []predicate.CasbinRule +} + +var _ ent.Mutation = (*CasbinRuleMutation)(nil) + +// casbinruleOption allows management of the mutation configuration using functional options. +type casbinruleOption func(*CasbinRuleMutation) + +// newCasbinRuleMutation creates new mutation for the CasbinRule entity. +func newCasbinRuleMutation(c config, op Op, opts ...casbinruleOption) *CasbinRuleMutation { + m := &CasbinRuleMutation{ + config: c, + op: op, + typ: TypeCasbinRule, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withCasbinRuleID sets the ID field of the mutation. +func withCasbinRuleID(id int) casbinruleOption { + return func(m *CasbinRuleMutation) { + var ( + err error + once sync.Once + value *CasbinRule + ) + m.oldValue = func(ctx context.Context) (*CasbinRule, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().CasbinRule.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withCasbinRule sets the old CasbinRule of the mutation. +func withCasbinRule(node *CasbinRule) casbinruleOption { + return func(m *CasbinRuleMutation) { + m.oldValue = func(context.Context) (*CasbinRule, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m CasbinRuleMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m CasbinRuleMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *CasbinRuleMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *CasbinRuleMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().CasbinRule.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetPtype sets the "Ptype" field. +func (m *CasbinRuleMutation) SetPtype(s string) { + m._Ptype = &s +} + +// Ptype returns the value of the "Ptype" field in the mutation. +func (m *CasbinRuleMutation) Ptype() (r string, exists bool) { + v := m._Ptype + if v == nil { + return + } + return *v, true +} + +// OldPtype returns the old "Ptype" field's value of the CasbinRule entity. +// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CasbinRuleMutation) OldPtype(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPtype is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPtype requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPtype: %w", err) + } + return oldValue.Ptype, nil +} + +// ResetPtype resets all changes to the "Ptype" field. +func (m *CasbinRuleMutation) ResetPtype() { + m._Ptype = nil +} + +// SetV0 sets the "V0" field. +func (m *CasbinRuleMutation) SetV0(s string) { + m._V0 = &s +} + +// V0 returns the value of the "V0" field in the mutation. +func (m *CasbinRuleMutation) V0() (r string, exists bool) { + v := m._V0 + if v == nil { + return + } + return *v, true +} + +// OldV0 returns the old "V0" field's value of the CasbinRule entity. +// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CasbinRuleMutation) OldV0(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV0 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV0 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV0: %w", err) + } + return oldValue.V0, nil +} + +// ResetV0 resets all changes to the "V0" field. +func (m *CasbinRuleMutation) ResetV0() { + m._V0 = nil +} + +// SetV1 sets the "V1" field. +func (m *CasbinRuleMutation) SetV1(s string) { + m._V1 = &s +} + +// V1 returns the value of the "V1" field in the mutation. +func (m *CasbinRuleMutation) V1() (r string, exists bool) { + v := m._V1 + if v == nil { + return + } + return *v, true +} + +// OldV1 returns the old "V1" field's value of the CasbinRule entity. +// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CasbinRuleMutation) OldV1(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV1 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV1 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV1: %w", err) + } + return oldValue.V1, nil +} + +// ResetV1 resets all changes to the "V1" field. +func (m *CasbinRuleMutation) ResetV1() { + m._V1 = nil +} + +// SetV2 sets the "V2" field. +func (m *CasbinRuleMutation) SetV2(s string) { + m._V2 = &s +} + +// V2 returns the value of the "V2" field in the mutation. +func (m *CasbinRuleMutation) V2() (r string, exists bool) { + v := m._V2 + if v == nil { + return + } + return *v, true +} + +// OldV2 returns the old "V2" field's value of the CasbinRule entity. +// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CasbinRuleMutation) OldV2(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV2 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV2 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV2: %w", err) + } + return oldValue.V2, nil +} + +// ResetV2 resets all changes to the "V2" field. +func (m *CasbinRuleMutation) ResetV2() { + m._V2 = nil +} + +// SetV3 sets the "V3" field. +func (m *CasbinRuleMutation) SetV3(s string) { + m._V3 = &s +} + +// V3 returns the value of the "V3" field in the mutation. +func (m *CasbinRuleMutation) V3() (r string, exists bool) { + v := m._V3 + if v == nil { + return + } + return *v, true +} + +// OldV3 returns the old "V3" field's value of the CasbinRule entity. +// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CasbinRuleMutation) OldV3(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV3 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV3 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV3: %w", err) + } + return oldValue.V3, nil +} + +// ResetV3 resets all changes to the "V3" field. +func (m *CasbinRuleMutation) ResetV3() { + m._V3 = nil +} + +// SetV4 sets the "V4" field. +func (m *CasbinRuleMutation) SetV4(s string) { + m._V4 = &s +} + +// V4 returns the value of the "V4" field in the mutation. +func (m *CasbinRuleMutation) V4() (r string, exists bool) { + v := m._V4 + if v == nil { + return + } + return *v, true +} + +// OldV4 returns the old "V4" field's value of the CasbinRule entity. +// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CasbinRuleMutation) OldV4(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV4 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV4 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV4: %w", err) + } + return oldValue.V4, nil +} + +// ResetV4 resets all changes to the "V4" field. +func (m *CasbinRuleMutation) ResetV4() { + m._V4 = nil +} + +// SetV5 sets the "V5" field. +func (m *CasbinRuleMutation) SetV5(s string) { + m._V5 = &s +} + +// V5 returns the value of the "V5" field in the mutation. +func (m *CasbinRuleMutation) V5() (r string, exists bool) { + v := m._V5 + if v == nil { + return + } + return *v, true +} + +// OldV5 returns the old "V5" field's value of the CasbinRule entity. +// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *CasbinRuleMutation) OldV5(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldV5 is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldV5 requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldV5: %w", err) + } + return oldValue.V5, nil +} + +// ResetV5 resets all changes to the "V5" field. +func (m *CasbinRuleMutation) ResetV5() { + m._V5 = nil +} + +// Where appends a list predicates to the CasbinRuleMutation builder. +func (m *CasbinRuleMutation) Where(ps ...predicate.CasbinRule) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the CasbinRuleMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *CasbinRuleMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.CasbinRule, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *CasbinRuleMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *CasbinRuleMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (CasbinRule). +func (m *CasbinRuleMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *CasbinRuleMutation) Fields() []string { + fields := make([]string, 0, 7) + if m._Ptype != nil { + fields = append(fields, casbinrule.FieldPtype) + } + if m._V0 != nil { + fields = append(fields, casbinrule.FieldV0) + } + if m._V1 != nil { + fields = append(fields, casbinrule.FieldV1) + } + if m._V2 != nil { + fields = append(fields, casbinrule.FieldV2) + } + if m._V3 != nil { + fields = append(fields, casbinrule.FieldV3) + } + if m._V4 != nil { + fields = append(fields, casbinrule.FieldV4) + } + if m._V5 != nil { + fields = append(fields, casbinrule.FieldV5) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *CasbinRuleMutation) Field(name string) (ent.Value, bool) { + switch name { + case casbinrule.FieldPtype: + return m.Ptype() + case casbinrule.FieldV0: + return m.V0() + case casbinrule.FieldV1: + return m.V1() + case casbinrule.FieldV2: + return m.V2() + case casbinrule.FieldV3: + return m.V3() + case casbinrule.FieldV4: + return m.V4() + case casbinrule.FieldV5: + return m.V5() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *CasbinRuleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case casbinrule.FieldPtype: + return m.OldPtype(ctx) + case casbinrule.FieldV0: + return m.OldV0(ctx) + case casbinrule.FieldV1: + return m.OldV1(ctx) + case casbinrule.FieldV2: + return m.OldV2(ctx) + case casbinrule.FieldV3: + return m.OldV3(ctx) + case casbinrule.FieldV4: + return m.OldV4(ctx) + case casbinrule.FieldV5: + return m.OldV5(ctx) + } + return nil, fmt.Errorf("unknown CasbinRule field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *CasbinRuleMutation) SetField(name string, value ent.Value) error { + switch name { + case casbinrule.FieldPtype: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPtype(v) + return nil + case casbinrule.FieldV0: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV0(v) + return nil + case casbinrule.FieldV1: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV1(v) + return nil + case casbinrule.FieldV2: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV2(v) + return nil + case casbinrule.FieldV3: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV3(v) + return nil + case casbinrule.FieldV4: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV4(v) + return nil + case casbinrule.FieldV5: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetV5(v) + return nil + } + return fmt.Errorf("unknown CasbinRule field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *CasbinRuleMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *CasbinRuleMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *CasbinRuleMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown CasbinRule numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *CasbinRuleMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *CasbinRuleMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *CasbinRuleMutation) ClearField(name string) error { + return fmt.Errorf("unknown CasbinRule nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *CasbinRuleMutation) ResetField(name string) error { + switch name { + case casbinrule.FieldPtype: + m.ResetPtype() + return nil + case casbinrule.FieldV0: + m.ResetV0() + return nil + case casbinrule.FieldV1: + m.ResetV1() + return nil + case casbinrule.FieldV2: + m.ResetV2() + return nil + case casbinrule.FieldV3: + m.ResetV3() + return nil + case casbinrule.FieldV4: + m.ResetV4() + return nil + case casbinrule.FieldV5: + m.ResetV5() + return nil + } + return fmt.Errorf("unknown CasbinRule field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *CasbinRuleMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *CasbinRuleMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *CasbinRuleMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *CasbinRuleMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *CasbinRuleMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *CasbinRuleMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *CasbinRuleMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown CasbinRule unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *CasbinRuleMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown CasbinRule edge %s", name) +} + // DepartmentMutation represents an operation that mutates the Department nodes in the graph. type DepartmentMutation struct { config diff --git a/internal/mods/system/dal/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go similarity index 90% rename from internal/mods/system/dal/entity/ent/mutation_fields.go rename to internal/data/entity/ent/mutation_fields.go index 10c0d59f..37a5e8d9 100644 --- a/internal/mods/system/dal/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -4,20 +4,96 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/userrole" ) +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *CasbinRuleMutation) SetFields(input *CasbinRule, fields ...string) error { + for i := range fields { + switch fields[i] { + case casbinrule.FieldPtype: + // check string with sql.NullString if it is empty + if input.Ptype != "" { + m.SetPtype(input.Ptype) + } + case casbinrule.FieldV0: + // check string with sql.NullString if it is empty + if input.V0 != "" { + m.SetV0(input.V0) + } + case casbinrule.FieldV1: + // check string with sql.NullString if it is empty + if input.V1 != "" { + m.SetV1(input.V1) + } + case casbinrule.FieldV2: + // check string with sql.NullString if it is empty + if input.V2 != "" { + m.SetV2(input.V2) + } + case casbinrule.FieldV3: + // check string with sql.NullString if it is empty + if input.V3 != "" { + m.SetV3(input.V3) + } + case casbinrule.FieldV4: + // check string with sql.NullString if it is empty + if input.V4 != "" { + m.SetV4(input.V4) + } + case casbinrule.FieldV5: + // check string with sql.NullString if it is empty + if input.V5 != "" { + m.SetV5(input.V5) + } + default: + return fmt.Errorf("unknown CasbinRule field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *CasbinRuleMutation) SetFieldsWithZero(input *CasbinRule, fields ...string) error { + for i := range fields { + switch fields[i] { + case casbinrule.FieldPtype: + m.SetPtype(input.Ptype) + case casbinrule.FieldV0: + m.SetV0(input.V0) + case casbinrule.FieldV1: + m.SetV1(input.V1) + case casbinrule.FieldV2: + m.SetV2(input.V2) + case casbinrule.FieldV3: + m.SetV3(input.V3) + case casbinrule.FieldV4: + m.SetV4(input.V4) + case casbinrule.FieldV5: + m.SetV5(input.V5) + default: + return fmt.Errorf("unknown CasbinRule field %s", fields[i]) + } + } + return nil +} + // SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the // field type. diff --git a/internal/mods/system/dal/entity/ent/permission.go b/internal/data/entity/ent/permission.go similarity index 99% rename from internal/mods/system/dal/entity/ent/permission.go rename to internal/data/entity/ent/permission.go index 5c3e9378..d2a28ce4 100644 --- a/internal/mods/system/dal/entity/ent/permission.go +++ b/internal/data/entity/ent/permission.go @@ -5,7 +5,7 @@ package ent import ( "encoding/json" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permission" "strings" "time" diff --git a/internal/mods/system/dal/entity/ent/permission_create.go b/internal/data/entity/ent/permission_create.go similarity index 97% rename from internal/mods/system/dal/entity/ent/permission_create.go rename to internal/data/entity/ent/permission_create.go index e04857ad..f1504abc 100644 --- a/internal/mods/system/dal/entity/ent/permission_create.go +++ b/internal/data/entity/ent/permission_create.go @@ -6,13 +6,13 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" "time" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/permission_delete.go b/internal/data/entity/ent/permission_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/permission_delete.go rename to internal/data/entity/ent/permission_delete.go index 3d2d8f90..5f02f37b 100644 --- a/internal/mods/system/dal/entity/ent/permission_delete.go +++ b/internal/data/entity/ent/permission_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/permission_query.go b/internal/data/entity/ent/permission_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/permission_query.go rename to internal/data/entity/ent/permission_query.go index 4ab7b8be..8cc24de7 100644 --- a/internal/mods/system/dal/entity/ent/permission_query.go +++ b/internal/data/entity/ent/permission_query.go @@ -7,14 +7,14 @@ import ( "database/sql/driver" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/permission_update.go b/internal/data/entity/ent/permission_update.go similarity index 98% rename from internal/mods/system/dal/entity/ent/permission_update.go rename to internal/data/entity/ent/permission_update.go index ed3481c0..26cbcd84 100644 --- a/internal/mods/system/dal/entity/ent/permission_update.go +++ b/internal/data/entity/ent/permission_update.go @@ -6,14 +6,14 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" "time" "entgo.io/ent/dialect/sql" diff --git a/internal/mods/system/dal/entity/ent/permissionresource.go b/internal/data/entity/ent/permissionresource.go similarity index 95% rename from internal/mods/system/dal/entity/ent/permissionresource.go rename to internal/data/entity/ent/permissionresource.go index fd00eccf..44ee86dd 100644 --- a/internal/mods/system/dal/entity/ent/permissionresource.go +++ b/internal/data/entity/ent/permissionresource.go @@ -4,9 +4,9 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/resource" "strings" "entgo.io/ent" diff --git a/internal/mods/system/dal/entity/ent/permissionresource_create.go b/internal/data/entity/ent/permissionresource_create.go similarity index 97% rename from internal/mods/system/dal/entity/ent/permissionresource_create.go rename to internal/data/entity/ent/permissionresource_create.go index b333ac42..16db9732 100644 --- a/internal/mods/system/dal/entity/ent/permissionresource_create.go +++ b/internal/data/entity/ent/permissionresource_create.go @@ -6,9 +6,9 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/resource" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" diff --git a/internal/mods/system/dal/entity/ent/permissionresource_delete.go b/internal/data/entity/ent/permissionresource_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/permissionresource_delete.go rename to internal/data/entity/ent/permissionresource_delete.go index 35b18139..d2d61f5c 100644 --- a/internal/mods/system/dal/entity/ent/permissionresource_delete.go +++ b/internal/data/entity/ent/permissionresource_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/permissionresource_query.go b/internal/data/entity/ent/permissionresource_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/permissionresource_query.go rename to internal/data/entity/ent/permissionresource_query.go index f5d216e8..aeac5c2c 100644 --- a/internal/mods/system/dal/entity/ent/permissionresource_query.go +++ b/internal/data/entity/ent/permissionresource_query.go @@ -6,10 +6,10 @@ import ( "context" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/permissionresource_update.go b/internal/data/entity/ent/permissionresource_update.go similarity index 98% rename from internal/mods/system/dal/entity/ent/permissionresource_update.go rename to internal/data/entity/ent/permissionresource_update.go index 83020d5a..70b40ef8 100644 --- a/internal/mods/system/dal/entity/ent/permissionresource_update.go +++ b/internal/data/entity/ent/permissionresource_update.go @@ -6,10 +6,10 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/position.go b/internal/data/entity/ent/position.go similarity index 98% rename from internal/mods/system/dal/entity/ent/position.go rename to internal/data/entity/ent/position.go index 39741b73..847e7555 100644 --- a/internal/mods/system/dal/entity/ent/position.go +++ b/internal/data/entity/ent/position.go @@ -4,8 +4,8 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/position" "strings" "time" diff --git a/internal/mods/system/dal/entity/ent/position_create.go b/internal/data/entity/ent/position_create.go similarity index 96% rename from internal/mods/system/dal/entity/ent/position_create.go rename to internal/data/entity/ent/position_create.go index c7efd668..3236b4c5 100644 --- a/internal/mods/system/dal/entity/ent/position_create.go +++ b/internal/data/entity/ent/position_create.go @@ -6,12 +6,12 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userposition" "time" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/position_delete.go b/internal/data/entity/ent/position_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/position_delete.go rename to internal/data/entity/ent/position_delete.go index c0737815..5d2d5fa4 100644 --- a/internal/mods/system/dal/entity/ent/position_delete.go +++ b/internal/data/entity/ent/position_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/position_query.go b/internal/data/entity/ent/position_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/position_query.go rename to internal/data/entity/ent/position_query.go index ad2a3225..ca67bf2f 100644 --- a/internal/mods/system/dal/entity/ent/position_query.go +++ b/internal/data/entity/ent/position_query.go @@ -7,13 +7,13 @@ import ( "database/sql/driver" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userposition" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/position_update.go b/internal/data/entity/ent/position_update.go similarity index 98% rename from internal/mods/system/dal/entity/ent/position_update.go rename to internal/data/entity/ent/position_update.go index 5e8eecb7..e42e7faf 100644 --- a/internal/mods/system/dal/entity/ent/position_update.go +++ b/internal/data/entity/ent/position_update.go @@ -6,13 +6,13 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userposition" "time" "entgo.io/ent/dialect/sql" diff --git a/internal/mods/system/dal/entity/ent/positionpermission.go b/internal/data/entity/ent/positionpermission.go similarity index 95% rename from internal/mods/system/dal/entity/ent/positionpermission.go rename to internal/data/entity/ent/positionpermission.go index adac1733..b0efc10f 100644 --- a/internal/mods/system/dal/entity/ent/positionpermission.go +++ b/internal/data/entity/ent/positionpermission.go @@ -4,9 +4,9 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" "strings" "entgo.io/ent" diff --git a/internal/mods/system/dal/entity/ent/positionpermission_create.go b/internal/data/entity/ent/positionpermission_create.go similarity index 97% rename from internal/mods/system/dal/entity/ent/positionpermission_create.go rename to internal/data/entity/ent/positionpermission_create.go index 3f695b50..1e41ae36 100644 --- a/internal/mods/system/dal/entity/ent/positionpermission_create.go +++ b/internal/data/entity/ent/positionpermission_create.go @@ -6,9 +6,9 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" diff --git a/internal/mods/system/dal/entity/ent/positionpermission_delete.go b/internal/data/entity/ent/positionpermission_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/positionpermission_delete.go rename to internal/data/entity/ent/positionpermission_delete.go index 6f78d52c..955b446a 100644 --- a/internal/mods/system/dal/entity/ent/positionpermission_delete.go +++ b/internal/data/entity/ent/positionpermission_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/positionpermission_query.go b/internal/data/entity/ent/positionpermission_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/positionpermission_query.go rename to internal/data/entity/ent/positionpermission_query.go index 7be80be7..341b3613 100644 --- a/internal/mods/system/dal/entity/ent/positionpermission_query.go +++ b/internal/data/entity/ent/positionpermission_query.go @@ -6,10 +6,10 @@ import ( "context" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/positionpermission_update.go b/internal/data/entity/ent/positionpermission_update.go similarity index 98% rename from internal/mods/system/dal/entity/ent/positionpermission_update.go rename to internal/data/entity/ent/positionpermission_update.go index ed972a12..9da383d4 100644 --- a/internal/mods/system/dal/entity/ent/positionpermission_update.go +++ b/internal/data/entity/ent/positionpermission_update.go @@ -6,10 +6,10 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/predicate" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/predicate/predicate.go b/internal/data/entity/ent/predicate/predicate.go similarity index 92% rename from internal/mods/system/dal/entity/ent/predicate/predicate.go rename to internal/data/entity/ent/predicate/predicate.go index 15d9e300..c2bd1e13 100644 --- a/internal/mods/system/dal/entity/ent/predicate/predicate.go +++ b/internal/data/entity/ent/predicate/predicate.go @@ -6,6 +6,9 @@ import ( "entgo.io/ent/dialect/sql" ) +// CasbinRule is the predicate function for casbinrule builders. +type CasbinRule func(*sql.Selector) + // Department is the predicate function for department builders. type Department func(*sql.Selector) diff --git a/internal/mods/system/dal/entity/ent/resource.go b/internal/data/entity/ent/resource.go similarity index 99% rename from internal/mods/system/dal/entity/ent/resource.go rename to internal/data/entity/ent/resource.go index 012c0686..5fc39ce6 100644 --- a/internal/mods/system/dal/entity/ent/resource.go +++ b/internal/data/entity/ent/resource.go @@ -5,7 +5,7 @@ package ent import ( "encoding/json" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/resource" "strings" "time" diff --git a/internal/mods/system/dal/entity/ent/resource_create.go b/internal/data/entity/ent/resource_create.go similarity index 99% rename from internal/mods/system/dal/entity/ent/resource_create.go rename to internal/data/entity/ent/resource_create.go index 59ae4065..243b139a 100644 --- a/internal/mods/system/dal/entity/ent/resource_create.go +++ b/internal/data/entity/ent/resource_create.go @@ -6,9 +6,9 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/resource" "time" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/resource_delete.go b/internal/data/entity/ent/resource_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/resource_delete.go rename to internal/data/entity/ent/resource_delete.go index 33b7120e..64063c39 100644 --- a/internal/mods/system/dal/entity/ent/resource_delete.go +++ b/internal/data/entity/ent/resource_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/resource_query.go b/internal/data/entity/ent/resource_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/resource_query.go rename to internal/data/entity/ent/resource_query.go index 74e17f94..f221e290 100644 --- a/internal/mods/system/dal/entity/ent/resource_query.go +++ b/internal/data/entity/ent/resource_query.go @@ -7,10 +7,10 @@ import ( "database/sql/driver" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/resource_update.go b/internal/data/entity/ent/resource_update.go similarity index 99% rename from internal/mods/system/dal/entity/ent/resource_update.go rename to internal/data/entity/ent/resource_update.go index 0f02ad84..0095e30a 100644 --- a/internal/mods/system/dal/entity/ent/resource_update.go +++ b/internal/data/entity/ent/resource_update.go @@ -6,10 +6,10 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" "time" "entgo.io/ent/dialect/sql" diff --git a/internal/mods/system/dal/entity/ent/role.go b/internal/data/entity/ent/role.go similarity index 99% rename from internal/mods/system/dal/entity/ent/role.go rename to internal/data/entity/ent/role.go index 03a5def2..b6a0dff4 100644 --- a/internal/mods/system/dal/entity/ent/role.go +++ b/internal/data/entity/ent/role.go @@ -4,7 +4,7 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/role" "strings" "time" diff --git a/internal/mods/system/dal/entity/ent/role_create.go b/internal/data/entity/ent/role_create.go similarity index 97% rename from internal/mods/system/dal/entity/ent/role_create.go rename to internal/data/entity/ent/role_create.go index e03f0db3..5f3e0635 100644 --- a/internal/mods/system/dal/entity/ent/role_create.go +++ b/internal/data/entity/ent/role_create.go @@ -6,11 +6,11 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userrole" "time" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/role_delete.go b/internal/data/entity/ent/role_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/role_delete.go rename to internal/data/entity/ent/role_delete.go index b18dede7..08fe7606 100644 --- a/internal/mods/system/dal/entity/ent/role_delete.go +++ b/internal/data/entity/ent/role_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/role" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/role_query.go b/internal/data/entity/ent/role_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/role_query.go rename to internal/data/entity/ent/role_query.go index 864cec88..c18c9337 100644 --- a/internal/mods/system/dal/entity/ent/role_query.go +++ b/internal/data/entity/ent/role_query.go @@ -7,12 +7,12 @@ import ( "database/sql/driver" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userrole" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/role_update.go b/internal/data/entity/ent/role_update.go similarity index 98% rename from internal/mods/system/dal/entity/ent/role_update.go rename to internal/data/entity/ent/role_update.go index c5a9260d..833be2d0 100644 --- a/internal/mods/system/dal/entity/ent/role_update.go +++ b/internal/data/entity/ent/role_update.go @@ -6,12 +6,12 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userrole" "time" "entgo.io/ent/dialect/sql" diff --git a/internal/mods/system/dal/entity/ent/rolepermission.go b/internal/data/entity/ent/rolepermission.go similarity index 95% rename from internal/mods/system/dal/entity/ent/rolepermission.go rename to internal/data/entity/ent/rolepermission.go index 5596b67b..cbcb7900 100644 --- a/internal/mods/system/dal/entity/ent/rolepermission.go +++ b/internal/data/entity/ent/rolepermission.go @@ -4,9 +4,9 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" "strings" "entgo.io/ent" diff --git a/internal/mods/system/dal/entity/ent/rolepermission_create.go b/internal/data/entity/ent/rolepermission_create.go similarity index 97% rename from internal/mods/system/dal/entity/ent/rolepermission_create.go rename to internal/data/entity/ent/rolepermission_create.go index 56fe8ddd..f0dbb800 100644 --- a/internal/mods/system/dal/entity/ent/rolepermission_create.go +++ b/internal/data/entity/ent/rolepermission_create.go @@ -6,9 +6,9 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" diff --git a/internal/mods/system/dal/entity/ent/rolepermission_delete.go b/internal/data/entity/ent/rolepermission_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/rolepermission_delete.go rename to internal/data/entity/ent/rolepermission_delete.go index 8b2098a5..d9add15f 100644 --- a/internal/mods/system/dal/entity/ent/rolepermission_delete.go +++ b/internal/data/entity/ent/rolepermission_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/rolepermission_query.go b/internal/data/entity/ent/rolepermission_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/rolepermission_query.go rename to internal/data/entity/ent/rolepermission_query.go index 678e49f6..a20dc4dc 100644 --- a/internal/mods/system/dal/entity/ent/rolepermission_query.go +++ b/internal/data/entity/ent/rolepermission_query.go @@ -6,10 +6,10 @@ import ( "context" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/rolepermission_update.go b/internal/data/entity/ent/rolepermission_update.go similarity index 98% rename from internal/mods/system/dal/entity/ent/rolepermission_update.go rename to internal/data/entity/ent/rolepermission_update.go index dbd2cb8b..a9c7534a 100644 --- a/internal/mods/system/dal/entity/ent/rolepermission_update.go +++ b/internal/data/entity/ent/rolepermission_update.go @@ -6,10 +6,10 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/runtime.go b/internal/data/entity/ent/runtime.go similarity index 64% rename from internal/mods/system/dal/entity/ent/runtime.go rename to internal/data/entity/ent/runtime.go index 821599f9..19ed6408 100644 --- a/internal/mods/system/dal/entity/ent/runtime.go +++ b/internal/data/entity/ent/runtime.go @@ -2,4 +2,4 @@ package ent -// The schema-stitching logic is generated in origadmin/application/admin/internal/mods/system/dal/entity/ent/runtime/runtime.go +// The schema-stitching logic is generated in origadmin/application/admin/internal/data/entity/ent/runtime/runtime.go diff --git a/internal/mods/system/dal/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go similarity index 92% rename from internal/mods/system/dal/entity/ent/runtime/runtime.go rename to internal/data/entity/ent/runtime/runtime.go index 2e1b918c..0194d480 100644 --- a/internal/mods/system/dal/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -3,19 +3,20 @@ package runtime import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permissionresource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/positionpermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/rolepermission" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/schema" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/permissionresource" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/positionpermission" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/schema" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/userrole" "time" ) @@ -23,6 +24,36 @@ import ( // (default values, validators, hooks and policies) and stitches it // to their package variables. func init() { + casbinruleFields := schema.CasbinRule{}.Fields() + _ = casbinruleFields + // casbinruleDescPtype is the schema descriptor for Ptype field. + casbinruleDescPtype := casbinruleFields[0].Descriptor() + // casbinrule.DefaultPtype holds the default value on creation for the Ptype field. + casbinrule.DefaultPtype = casbinruleDescPtype.Default.(string) + // casbinruleDescV0 is the schema descriptor for V0 field. + casbinruleDescV0 := casbinruleFields[1].Descriptor() + // casbinrule.DefaultV0 holds the default value on creation for the V0 field. + casbinrule.DefaultV0 = casbinruleDescV0.Default.(string) + // casbinruleDescV1 is the schema descriptor for V1 field. + casbinruleDescV1 := casbinruleFields[2].Descriptor() + // casbinrule.DefaultV1 holds the default value on creation for the V1 field. + casbinrule.DefaultV1 = casbinruleDescV1.Default.(string) + // casbinruleDescV2 is the schema descriptor for V2 field. + casbinruleDescV2 := casbinruleFields[3].Descriptor() + // casbinrule.DefaultV2 holds the default value on creation for the V2 field. + casbinrule.DefaultV2 = casbinruleDescV2.Default.(string) + // casbinruleDescV3 is the schema descriptor for V3 field. + casbinruleDescV3 := casbinruleFields[4].Descriptor() + // casbinrule.DefaultV3 holds the default value on creation for the V3 field. + casbinrule.DefaultV3 = casbinruleDescV3.Default.(string) + // casbinruleDescV4 is the schema descriptor for V4 field. + casbinruleDescV4 := casbinruleFields[5].Descriptor() + // casbinrule.DefaultV4 holds the default value on creation for the V4 field. + casbinrule.DefaultV4 = casbinruleDescV4.Default.(string) + // casbinruleDescV5 is the schema descriptor for V5 field. + casbinruleDescV5 := casbinruleFields[6].Descriptor() + // casbinrule.DefaultV5 holds the default value on creation for the V5 field. + casbinrule.DefaultV5 = casbinruleDescV5.Default.(string) departmentMixin := schema.Department{}.Mixin() departmentMixinFields0 := departmentMixin[0].Fields() _ = departmentMixinFields0 @@ -538,6 +569,5 @@ func init() { } const ( - Version = "v0.14.4" // Version of ent codegen. - Sum = "h1:/DhDraSLXIkBhyiVoJeSshr4ZYi7femzhj6/TckzZuI=" // Sum of ent codegen. + Version = "(devel)" // Version of ent codegen. ) diff --git a/internal/mods/system/dal/entity/ent/schema/audit/service.go b/internal/data/entity/ent/schema/audit/service.go similarity index 82% rename from internal/mods/system/dal/entity/ent/schema/audit/service.go rename to internal/data/entity/ent/schema/audit/service.go index 45f12e9a..34092154 100644 --- a/internal/mods/system/dal/entity/ent/schema/audit/service.go +++ b/internal/data/entity/ent/schema/audit/service.go @@ -7,8 +7,6 @@ package audit import ( "context" - - "github.com/origadmin/runtime/log" ) type Service interface { @@ -19,7 +17,7 @@ type service struct { } func (s service) Log(ctx context.Context, action string, entity interface{}) { - log.Info("audit", "action", action, "entity", entity) + //log.Info("audit", "action", action, "entity", entity) } func NewService() Service { diff --git a/internal/mods/casbin/dal/entity/ent/schema/casbinrule.go b/internal/data/entity/ent/schema/casbinrule.go similarity index 100% rename from internal/mods/casbin/dal/entity/ent/schema/casbinrule.go rename to internal/data/entity/ent/schema/casbinrule.go diff --git a/internal/mods/system/dal/entity/ent/schema/department.go b/internal/data/entity/ent/schema/department.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/department.go rename to internal/data/entity/ent/schema/department.go diff --git a/internal/mods/system/dal/entity/ent/schema/hooks.go b/internal/data/entity/ent/schema/hooks.go similarity index 82% rename from internal/mods/system/dal/entity/ent/schema/hooks.go rename to internal/data/entity/ent/schema/hooks.go index 5fe6f015..2390e97a 100644 --- a/internal/mods/system/dal/entity/ent/schema/hooks.go +++ b/internal/data/entity/ent/schema/hooks.go @@ -11,9 +11,8 @@ import ( "strings" "entgo.io/ent" - "github.com/origadmin/runtime/log" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/schema/audit" + "origadmin/application/admin/internal/data/entity/ent/schema/audit" ) func UserAuditHook(service audit.Service) ent.Hook { @@ -27,7 +26,7 @@ func UserAuditHook(service audit.Service) ent.Hook { go func() { defer func() { if r := recover(); r != nil { - log.Error("audit panic recovered", r) + //log.Error("audit panic recovered", r) } }() action := strings.ToUpper(strings.TrimPrefix(fmt.Sprintf("%T", m), "*ent.")) diff --git a/internal/mods/system/dal/entity/ent/schema/permission.go b/internal/data/entity/ent/schema/permission.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/permission.go rename to internal/data/entity/ent/schema/permission.go diff --git a/internal/mods/system/dal/entity/ent/schema/permissionresource.go b/internal/data/entity/ent/schema/permissionresource.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/permissionresource.go rename to internal/data/entity/ent/schema/permissionresource.go diff --git a/internal/mods/system/dal/entity/ent/schema/position.go b/internal/data/entity/ent/schema/position.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/position.go rename to internal/data/entity/ent/schema/position.go diff --git a/internal/mods/system/dal/entity/ent/schema/positionpermission.go b/internal/data/entity/ent/schema/positionpermission.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/positionpermission.go rename to internal/data/entity/ent/schema/positionpermission.go diff --git a/internal/mods/system/dal/entity/ent/schema/resource.go b/internal/data/entity/ent/schema/resource.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/resource.go rename to internal/data/entity/ent/schema/resource.go diff --git a/internal/mods/system/dal/entity/ent/schema/role.go b/internal/data/entity/ent/schema/role.go similarity index 96% rename from internal/mods/system/dal/entity/ent/schema/role.go rename to internal/data/entity/ent/schema/role.go index c89dba50..377ba28e 100644 --- a/internal/mods/system/dal/entity/ent/schema/role.go +++ b/internal/data/entity/ent/schema/role.go @@ -15,7 +15,7 @@ import ( "origadmin/application/admin/helpers/ent/mixin" "origadmin/application/admin/helpers/i18n" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/schema/types" + "origadmin/application/admin/internal/data/entity/ent/schema/types" ) // Role type constant diff --git a/internal/mods/system/dal/entity/ent/schema/rolepermission.go b/internal/data/entity/ent/schema/rolepermission.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/rolepermission.go rename to internal/data/entity/ent/schema/rolepermission.go diff --git a/internal/mods/system/dal/entity/ent/schema/softdelete.go b/internal/data/entity/ent/schema/softdelete.go similarity index 88% rename from internal/mods/system/dal/entity/ent/schema/softdelete.go rename to internal/data/entity/ent/schema/softdelete.go index d3a6e268..40f1e9ea 100644 --- a/internal/mods/system/dal/entity/ent/schema/softdelete.go +++ b/internal/data/entity/ent/schema/softdelete.go @@ -13,9 +13,9 @@ import ( "entgo.io/ent/dialect/sql" "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/hook" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/intercept" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/hook" + "origadmin/application/admin/internal/data/entity/ent/intercept" ) // SoftDelete is schema to include control and time fields. diff --git a/internal/mods/system/dal/entity/ent/schema/types/constants.go b/internal/data/entity/ent/schema/types/constants.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/types/constants.go rename to internal/data/entity/ent/schema/types/constants.go diff --git a/internal/mods/system/dal/entity/ent/schema/types/structs.go b/internal/data/entity/ent/schema/types/structs.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/types/structs.go rename to internal/data/entity/ent/schema/types/structs.go diff --git a/internal/mods/system/dal/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go similarity index 95% rename from internal/mods/system/dal/entity/ent/schema/user.go rename to internal/data/entity/ent/schema/user.go index 8eb10b25..4365b497 100644 --- a/internal/mods/system/dal/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -15,9 +15,9 @@ import ( "origadmin/application/admin/helpers/ent/mixin" "origadmin/application/admin/helpers/i18n" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/hook" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/schema/audit" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/schema/types" + "origadmin/application/admin/internal/data/entity/ent/hook" + "origadmin/application/admin/internal/data/entity/ent/schema/audit" + "origadmin/application/admin/internal/data/entity/ent/schema/types" ) const ( diff --git a/internal/mods/system/dal/entity/ent/schema/userdepartment.go b/internal/data/entity/ent/schema/userdepartment.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/userdepartment.go rename to internal/data/entity/ent/schema/userdepartment.go diff --git a/internal/mods/system/dal/entity/ent/schema/userposition.go b/internal/data/entity/ent/schema/userposition.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/userposition.go rename to internal/data/entity/ent/schema/userposition.go diff --git a/internal/mods/system/dal/entity/ent/schema/userrole.go b/internal/data/entity/ent/schema/userrole.go similarity index 100% rename from internal/mods/system/dal/entity/ent/schema/userrole.go rename to internal/data/entity/ent/schema/userrole.go diff --git a/internal/mods/casbin/dal/entity/ent/template/crud.tpl b/internal/data/entity/ent/template/crud.tpl similarity index 100% rename from internal/mods/casbin/dal/entity/ent/template/crud.tpl rename to internal/data/entity/ent/template/crud.tpl diff --git a/internal/mods/casbin/dal/entity/ent/template/crud_create.tpl b/internal/data/entity/ent/template/crud_create.tpl similarity index 100% rename from internal/mods/casbin/dal/entity/ent/template/crud_create.tpl rename to internal/data/entity/ent/template/crud_create.tpl diff --git a/internal/mods/casbin/dal/entity/ent/template/crud_query.tpl b/internal/data/entity/ent/template/crud_query.tpl similarity index 100% rename from internal/mods/casbin/dal/entity/ent/template/crud_query.tpl rename to internal/data/entity/ent/template/crud_query.tpl diff --git a/internal/mods/casbin/dal/entity/ent/template/crud_update.tpl b/internal/data/entity/ent/template/crud_update.tpl similarity index 100% rename from internal/mods/casbin/dal/entity/ent/template/crud_update.tpl rename to internal/data/entity/ent/template/crud_update.tpl diff --git a/internal/mods/casbin/dal/entity/ent/template/crud_update_one.tpl b/internal/data/entity/ent/template/crud_update_one.tpl similarity index 100% rename from internal/mods/casbin/dal/entity/ent/template/crud_update_one.tpl rename to internal/data/entity/ent/template/crud_update_one.tpl diff --git a/internal/mods/system/dal/entity/ent/template/database.tpl b/internal/data/entity/ent/template/database.tpl similarity index 100% rename from internal/mods/system/dal/entity/ent/template/database.tpl rename to internal/data/entity/ent/template/database.tpl diff --git a/internal/mods/system/dal/entity/ent/template/mutation_fields.tpl b/internal/data/entity/ent/template/mutation_fields.tpl similarity index 100% rename from internal/mods/system/dal/entity/ent/template/mutation_fields.tpl rename to internal/data/entity/ent/template/mutation_fields.tpl diff --git a/internal/mods/casbin/dal/entity/ent/template/type_meta_fields.tpl b/internal/data/entity/ent/template/type_meta_fields.tpl similarity index 100% rename from internal/mods/casbin/dal/entity/ent/template/type_meta_fields.tpl rename to internal/data/entity/ent/template/type_meta_fields.tpl diff --git a/internal/mods/system/dal/entity/ent/template/type_meta_where.tpl b/internal/data/entity/ent/template/type_meta_where.tpl similarity index 100% rename from internal/mods/system/dal/entity/ent/template/type_meta_where.tpl rename to internal/data/entity/ent/template/type_meta_where.tpl diff --git a/internal/mods/system/dal/entity/ent/tx.go b/internal/data/entity/ent/tx.go similarity index 97% rename from internal/mods/system/dal/entity/ent/tx.go rename to internal/data/entity/ent/tx.go index 65e6a7ef..3c91384b 100644 --- a/internal/mods/system/dal/entity/ent/tx.go +++ b/internal/data/entity/ent/tx.go @@ -12,6 +12,8 @@ import ( // Tx is a transactional client that is created by calling Client.Tx(). type Tx struct { config + // CasbinRule is the client for interacting with the CasbinRule builders. + CasbinRule *CasbinRuleClient // Department is the client for interacting with the Department builders. Department *DepartmentClient // Permission is the client for interacting with the Permission builders. @@ -167,6 +169,7 @@ func (tx *Tx) Client() *Client { } func (tx *Tx) init() { + tx.CasbinRule = NewCasbinRuleClient(tx.config) tx.Department = NewDepartmentClient(tx.config) tx.Permission = NewPermissionClient(tx.config) tx.PermissionResource = NewPermissionResourceClient(tx.config) @@ -188,7 +191,7 @@ func (tx *Tx) init() { // of them in order to commit or rollback the transaction. // // If a closed transaction is embedded in one of the generated entities, and the entity -// applies a query, for example: Department.QueryXXX(), the query will be executed +// applies a query, for example: CasbinRule.QueryXXX(), the query will be executed // through the driver which created this transaction. // // Note that txDriver is not goroutine safe. diff --git a/internal/mods/system/dal/entity/ent/user.go b/internal/data/entity/ent/user.go similarity index 99% rename from internal/mods/system/dal/entity/ent/user.go rename to internal/data/entity/ent/user.go index 6f66bb2b..a8a0a124 100644 --- a/internal/mods/system/dal/entity/ent/user.go +++ b/internal/data/entity/ent/user.go @@ -4,7 +4,7 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/user" "strings" "time" diff --git a/internal/mods/system/dal/entity/ent/user_create.go b/internal/data/entity/ent/user_create.go similarity index 98% rename from internal/mods/system/dal/entity/ent/user_create.go rename to internal/data/entity/ent/user_create.go index 868b46c5..3d012ec2 100644 --- a/internal/mods/system/dal/entity/ent/user_create.go +++ b/internal/data/entity/ent/user_create.go @@ -6,13 +6,13 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/userrole" "time" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/user_delete.go b/internal/data/entity/ent/user_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/user_delete.go rename to internal/data/entity/ent/user_delete.go index e0e38e38..5af88d72 100644 --- a/internal/mods/system/dal/entity/ent/user_delete.go +++ b/internal/data/entity/ent/user_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/user" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/user_query.go b/internal/data/entity/ent/user_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/user_query.go rename to internal/data/entity/ent/user_query.go index cf2ae1cc..471c48b1 100644 --- a/internal/mods/system/dal/entity/ent/user_query.go +++ b/internal/data/entity/ent/user_query.go @@ -7,14 +7,14 @@ import ( "database/sql/driver" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/userrole" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/user_update.go b/internal/data/entity/ent/user_update.go similarity index 99% rename from internal/mods/system/dal/entity/ent/user_update.go rename to internal/data/entity/ent/user_update.go index 3166a264..618b01c5 100644 --- a/internal/mods/system/dal/entity/ent/user_update.go +++ b/internal/data/entity/ent/user_update.go @@ -6,14 +6,14 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/userrole" "time" "entgo.io/ent/dialect/sql" diff --git a/internal/mods/system/dal/entity/ent/userdepartment.go b/internal/data/entity/ent/userdepartment.go similarity index 95% rename from internal/mods/system/dal/entity/ent/userdepartment.go rename to internal/data/entity/ent/userdepartment.go index 5f209d8b..2617c5d3 100644 --- a/internal/mods/system/dal/entity/ent/userdepartment.go +++ b/internal/data/entity/ent/userdepartment.go @@ -4,9 +4,9 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" "strings" "entgo.io/ent" diff --git a/internal/mods/system/dal/entity/ent/userdepartment_create.go b/internal/data/entity/ent/userdepartment_create.go similarity index 97% rename from internal/mods/system/dal/entity/ent/userdepartment_create.go rename to internal/data/entity/ent/userdepartment_create.go index b3661ca5..e3803367 100644 --- a/internal/mods/system/dal/entity/ent/userdepartment_create.go +++ b/internal/data/entity/ent/userdepartment_create.go @@ -6,9 +6,9 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" diff --git a/internal/mods/system/dal/entity/ent/userdepartment_delete.go b/internal/data/entity/ent/userdepartment_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/userdepartment_delete.go rename to internal/data/entity/ent/userdepartment_delete.go index ac6107c9..ccda834e 100644 --- a/internal/mods/system/dal/entity/ent/userdepartment_delete.go +++ b/internal/data/entity/ent/userdepartment_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/userdepartment_query.go b/internal/data/entity/ent/userdepartment_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/userdepartment_query.go rename to internal/data/entity/ent/userdepartment_query.go index 3183779b..f55a7b48 100644 --- a/internal/mods/system/dal/entity/ent/userdepartment_query.go +++ b/internal/data/entity/ent/userdepartment_query.go @@ -6,10 +6,10 @@ import ( "context" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/userdepartment_update.go b/internal/data/entity/ent/userdepartment_update.go similarity index 98% rename from internal/mods/system/dal/entity/ent/userdepartment_update.go rename to internal/data/entity/ent/userdepartment_update.go index 6fc84063..e3ad697d 100644 --- a/internal/mods/system/dal/entity/ent/userdepartment_update.go +++ b/internal/data/entity/ent/userdepartment_update.go @@ -6,10 +6,10 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userdepartment" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userdepartment" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/userposition.go b/internal/data/entity/ent/userposition.go similarity index 95% rename from internal/mods/system/dal/entity/ent/userposition.go rename to internal/data/entity/ent/userposition.go index f3ebaf56..9e75d513 100644 --- a/internal/mods/system/dal/entity/ent/userposition.go +++ b/internal/data/entity/ent/userposition.go @@ -4,9 +4,9 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userposition" "strings" "entgo.io/ent" diff --git a/internal/mods/system/dal/entity/ent/userposition_create.go b/internal/data/entity/ent/userposition_create.go similarity index 97% rename from internal/mods/system/dal/entity/ent/userposition_create.go rename to internal/data/entity/ent/userposition_create.go index e4ed5698..bf6ffd23 100644 --- a/internal/mods/system/dal/entity/ent/userposition_create.go +++ b/internal/data/entity/ent/userposition_create.go @@ -6,9 +6,9 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userposition" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" diff --git a/internal/mods/system/dal/entity/ent/userposition_delete.go b/internal/data/entity/ent/userposition_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/userposition_delete.go rename to internal/data/entity/ent/userposition_delete.go index 6e86099f..96c9db6c 100644 --- a/internal/mods/system/dal/entity/ent/userposition_delete.go +++ b/internal/data/entity/ent/userposition_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/userposition" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/userposition_query.go b/internal/data/entity/ent/userposition_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/userposition_query.go rename to internal/data/entity/ent/userposition_query.go index 76521d9a..70b5484a 100644 --- a/internal/mods/system/dal/entity/ent/userposition_query.go +++ b/internal/data/entity/ent/userposition_query.go @@ -6,10 +6,10 @@ import ( "context" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userposition" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/userposition_update.go b/internal/data/entity/ent/userposition_update.go similarity index 98% rename from internal/mods/system/dal/entity/ent/userposition_update.go rename to internal/data/entity/ent/userposition_update.go index 27122a5d..c4a7f3b0 100644 --- a/internal/mods/system/dal/entity/ent/userposition_update.go +++ b/internal/data/entity/ent/userposition_update.go @@ -6,10 +6,10 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/position" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userposition" + "origadmin/application/admin/internal/data/entity/ent/position" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userposition" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/userrole.go b/internal/data/entity/ent/userrole.go similarity index 95% rename from internal/mods/system/dal/entity/ent/userrole.go rename to internal/data/entity/ent/userrole.go index 1a273225..3da25710 100644 --- a/internal/mods/system/dal/entity/ent/userrole.go +++ b/internal/data/entity/ent/userrole.go @@ -4,9 +4,9 @@ package ent import ( "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userrole" "strings" "entgo.io/ent" diff --git a/internal/mods/system/dal/entity/ent/userrole_create.go b/internal/data/entity/ent/userrole_create.go similarity index 97% rename from internal/mods/system/dal/entity/ent/userrole_create.go rename to internal/data/entity/ent/userrole_create.go index d6b5786f..7269d57a 100644 --- a/internal/mods/system/dal/entity/ent/userrole_create.go +++ b/internal/data/entity/ent/userrole_create.go @@ -6,9 +6,9 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userrole" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" diff --git a/internal/mods/system/dal/entity/ent/userrole_delete.go b/internal/data/entity/ent/userrole_delete.go similarity index 93% rename from internal/mods/system/dal/entity/ent/userrole_delete.go rename to internal/data/entity/ent/userrole_delete.go index e4ea5506..00d7c9bb 100644 --- a/internal/mods/system/dal/entity/ent/userrole_delete.go +++ b/internal/data/entity/ent/userrole_delete.go @@ -4,8 +4,8 @@ package ent import ( "context" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/userrole" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/mods/system/dal/entity/ent/userrole_query.go b/internal/data/entity/ent/userrole_query.go similarity index 98% rename from internal/mods/system/dal/entity/ent/userrole_query.go rename to internal/data/entity/ent/userrole_query.go index bf76f6ec..9fa3b276 100644 --- a/internal/mods/system/dal/entity/ent/userrole_query.go +++ b/internal/data/entity/ent/userrole_query.go @@ -6,10 +6,10 @@ import ( "context" "fmt" "math" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userrole" "entgo.io/ent" "entgo.io/ent/dialect" diff --git a/internal/mods/system/dal/entity/ent/userrole_update.go b/internal/data/entity/ent/userrole_update.go similarity index 98% rename from internal/mods/system/dal/entity/ent/userrole_update.go rename to internal/data/entity/ent/userrole_update.go index dd25641b..79abc5f4 100644 --- a/internal/mods/system/dal/entity/ent/userrole_update.go +++ b/internal/data/entity/ent/userrole_update.go @@ -6,10 +6,10 @@ import ( "context" "errors" "fmt" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/userrole" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" diff --git a/internal/loader/application.go b/internal/loader/application.go index bc0509ac..03b572e8 100644 --- a/internal/loader/application.go +++ b/internal/loader/application.go @@ -5,33 +5,26 @@ // Package loader implements the functions, types, and interfaces for the module. package loader -import ( - "context" - "syscall" - - "github.com/gin-gonic/gin" - "github.com/go-kratos/kratos/v2" -) - -func NewApp(ctx context.Context, injector *InjectorClient) *kratos.App { - opts := []kratos.Option{ - kratos.ID(flags.ServiceID()), - kratos.Name(flags.ServiceName()), - kratos.Version(flags.Version()), - kratos.Metadata(map[string]string{}), - kratos.Context(ctx), - kratos.Signal(syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT), - kratos.Logger(injector.Logger), - kratos.Server(injector.Server), - } - - if flags.Env() == "release" { - gin.SetMode(gin.ReleaseMode) - } - - gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) { - log.Infow("msg", "GIN route", "method", httpMethod, "path", absolutePath, "operation", handlerName, "handlers", nuHandlers) - } - - return kratos.New(opts...) -} +// +//func NewApp(ctx context.Context, injector *InjectorClient) *kratos.App { +// opts := []kratos.Option{ +// kratos.ID(flags.ServiceID()), +// kratos.Name(flags.ServiceName()), +// kratos.Version(flags.Version()), +// kratos.Metadata(map[string]string{}), +// kratos.Context(ctx), +// kratos.Signal(syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT), +// kratos.Logger(injector.Logger), +// kratos.Server(injector.Server), +// } +// +// if flags.Env() == "release" { +// gin.SetMode(gin.ReleaseMode) +// } +// +// gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) { +// log.Infow("msg", "GIN route", "method", httpMethod, "path", absolutePath, "operation", handlerName, "handlers", nuHandlers) +// } +// +// return kratos.New(opts...) +//} diff --git a/internal/loader/bootstrap.go b/internal/loader/bootstrap.go index 93225e9d..d44d6843 100644 --- a/internal/loader/bootstrap.go +++ b/internal/loader/bootstrap.go @@ -6,42 +6,106 @@ package loader import ( + "context" + "fmt" + + "github.com/go-kratos/kratos/v2" + "github.com/go-kratos/kratos/v2/middleware/tracing" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" + "github.com/origadmin/runtime/config" configv1 "github.com/origadmin/runtime/gen/go/config/v1" + middlewarev1 "github.com/origadmin/runtime/gen/go/middleware/v1" "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/registry" + + "origadmin/application/admin/internal/configs" ) -// LoadRemoteBootstrap 从 Consul KV 获取配置 -func LoadRemoteBootstrap(cfg *bootstrap.SourceConfig) (*configs.Bootstrap, error) { - // 创建 Consul 发现客户端(同时作为 KV 客户端) - discover, err := registry.NewConsulDiscover(®istry.ConsulConfig{ - Address: os.Getenv("CONSUL_ADDR"), - Timeout: 5 * time.Second, - }) - if err != nil { +type NewApp func(runtime.Runtime, *configs.Bootstrap) (*kratos.App, func(), error) + +func Resolve(config config.KConfig) (config.Resolved, error) { + var rb ResolvedBootstrap + if err := config.Load(); err != nil { return nil, err } - - // 使用 ConfigManager 从 KV 获取配置 - configMgr := NewConfigManager(discover) - kvData, err := configMgr.GetConfig("config/" + cfg.Name) - if err != nil { - return nil, fmt.Errorf("failed to get KV config: %w", err) + if err := config.Scan(&rb.bootstrap); err != nil { + return nil, err } + return &rb, nil +} + +type BootstrapConfig func(config config.KConfig) (config.Resolved, error) - // 解析配置数据(示例实现) - var bs configs.Bootstrap - if err := parseConfigData(kvData, &bs); err != nil { +func (b BootstrapConfig) Resolve(config config.KConfig) (config.Resolved, error) { + return b(config) +} + +type ResolvedBootstrap struct { + bootstrap configs.Bootstrap +} + +func (r *ResolvedBootstrap) Resolve(config config.KConfig) (config.Resolved, error) { + if err := config.Scan(&r.bootstrap); err != nil { return nil, err } + return r, nil +} + +func (r *ResolvedBootstrap) WithDecode(name string, v any, decode func([]byte, any) error) error { + if decode == nil { + return fmt.Errorf("decode function is nil") + } + return nil +} + +func (r *ResolvedBootstrap) Value(name string) (any, error) { + switch name { + + default: + return nil, fmt.Errorf("unknown config name: %s", name) + } - return &bs, nil } -// parseConfigData 实现配置数据解析逻辑 -func parseConfigData(data []byte, out *configs.Bootstrap) error { - // 根据实际格式实现解析(如 JSON/TOML) - // 示例:json.Unmarshal(data, out) +func (r *ResolvedBootstrap) Registry() *configv1.Registry { + return r.bootstrap.GetRegistry() +} + +func (r *ResolvedBootstrap) Middleware() *middlewarev1.Middleware { + return r.bootstrap.GetMiddleware() +} + +func (r *ResolvedBootstrap) Service() *configv1.Service { + panic("unimplemented") + //return r.bootstrap.GetService() +} + +func (r *ResolvedBootstrap) Logger() *configv1.Logger { + return r.bootstrap.GetLogger() +} + +func Bootstrap(ctx context.Context, flags *bootstrap.Bootstrap, newApp NewApp) error { + var rb ResolvedBootstrap + r, err := runtime.Load(flags, runtime.WithResolver(&rb), runtime.WithContext(ctx)) + if err != nil { + return err + } + r = r.WithLoggerAttrs( + "ts", log.DefaultTimestamp, + "caller", log.DefaultCaller, + "service.id", flags.ServiceID(), + "service.name", flags.ServiceName(), + "service.version", flags.Version(), + "trace.id", tracing.TraceID(), + "span.id", tracing.SpanID(), + ) + app, clean, err := newApp(r, &rb.bootstrap) + if err != nil { + return err + } + defer clean() + if err := app.Run(); err != nil { + return err + } return nil } diff --git a/internal/loader/bootstrap_test.go b/internal/loader/bootstrap_test.go index e597e97c..4c5e21c0 100644 --- a/internal/loader/bootstrap_test.go +++ b/internal/loader/bootstrap_test.go @@ -14,6 +14,7 @@ import ( "time" _ "github.com/origadmin/contrib/database" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/slog-kratos" "github.com/origadmin/toolkits/crypto/rand" @@ -21,9 +22,9 @@ import ( "google.golang.org/protobuf/encoding/protojson" "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/mods/system/dal" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - _ "origadmin/application/admin/internal/mods/system/dal/entity/ent/runtime" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/data/entity/ent" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" ) const ( @@ -49,8 +50,8 @@ func TestSaveConfig(t *testing.T) { bootstrap.Security.Authn.Jwt.SigningKey = key bootstrap.Middleware.Jwt.Config.Key = key bootstrap.Middleware.Jwt.Config.SigningMethod = "HS512" - bootstrap.Service.Middleware.Jwt.Config.Key = key - bootstrap.Service.Middleware.Jwt.Config.SigningMethod = "HS512" + //bootstrap.Service.Middleware.Jwt.Config.Key = key + //bootstrap.Service.Middleware.Jwt.Config.SigningMethod = "HS512" type args struct { path string conf *configs.Bootstrap @@ -140,7 +141,8 @@ func TestLoadConfig(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := LoadFileBootstrap(filepath.Join(testPath, tt.args.path)) + + got, err := LoadLocalBootstrap(filepath.Join(testPath, tt.args.path)) if (err != nil) != tt.wantErr { t.Errorf("LoadConf() error = %v, wantErr %v", err, tt.wantErr) return @@ -190,23 +192,22 @@ func TestData_InitDataFromPath(t *testing.T) { return } log.Infof("abs: %s", abs) - bs, err := LoadFileBootstrap("../../resources/configs/system/bootstrap.toml") + bs, err := LoadLocalBootstrap("../../resources/configs/system/bootstrap.toml") if err != nil { t.Fatal(err) return } tt.fields.Bootstrap = bs } - - d, cleanup, err := dal.NewData(tt.fields.Bootstrap, log.DefaultLogger) + _, cleanup, err := data.NewData(runtime.Global(), tt.fields.Bootstrap) if err != nil { t.Errorf("NewData() error = %v", err) return } defer cleanup() - if err := d.InitDataFromPath(context.Background(), tt.args.filename, "resource"); (err != nil) != tt.wantErr { - t.Errorf("InitFromFile() error = %v, wantErr %v", err, tt.wantErr) - } + //if err := d.InitDataFromPath(context.Background(), tt.args.filename, "resource"); (err != nil) != tt.wantErr { + // t.Errorf("InitFromFile() error = %v, wantErr %v", err, tt.wantErr) + //} }) } } diff --git a/internal/loader/config.go b/internal/loader/config.go index 8180e0a9..dd6871a6 100644 --- a/internal/loader/config.go +++ b/internal/loader/config.go @@ -6,42 +6,33 @@ package loader import ( - "github.com/origadmin/runtime/bootstrap" - "github.com/origadmin/runtime/service" -) + "github.com/origadmin/runtime" + configv1 "github.com/origadmin/runtime/gen/go/config/v1" -// BootstrapConfig 包含启动配置 -type BootstrapConfig struct { - Service service.ServiceBuilder - Source bootstrap.SourceConfig -} + "origadmin/application/admin/internal/configs" +) -// LoadBootstrap 加载基础配置 -func LoadBootstrap(cfg BootstrapConfig) (*configs.Bootstrap, error) { - var bs *configs.Bootstrap - var err error - - switch cfg.Source.GetType() { - case "file": - bs, err = LoadLocalBootstrap(&cfg.Source) - default: - bs, err = LoadRemoteBootstrap(&cfg.Source) - } - +func LoadBootstrap(cfg *configv1.SourceConfig) (*configs.Bootstrap, error) { + source, err := runtime.NewConfig(cfg) if err != nil { - return nil, fmt.Errorf("load bootstrap error: %v", err) + return nil, err } - - return bs, nil + if err := source.Load(); err != nil { + return nil, err + } + var bs configs.Bootstrap + if err := source.Scan(&bs); err != nil { + return nil, err + } + return &bs, nil } -// 新增服务发现配置加载 -func LoadRemoteBootstrap(cfg *bootstrap.SourceConfig) (*configs.Bootstrap, error) { - discoveryConfig := ®istry.ConsulConfig{ /*...*/ } - registrar, _ := registry.NewConsulRegistrar(discoveryConfig) - - return &configs.Bootstrap{ - Registry: registrar, // 远程配置携带服务注册能力 - Discovery: discoveryConfig.Client, - }, nil +func LoadLocalBootstrap(path string) (*configs.Bootstrap, error) { + source := configv1.SourceConfig{ + Types: []string{"file"}, + File: &configv1.SourceConfig_File{ + Path: path, + }, + } + return LoadBootstrap(&source) } diff --git a/internal/loader/config_manager.go b/internal/loader/config_manager.go deleted file mode 100644 index 03d9fe0b..00000000 --- a/internal/loader/config_manager.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "fmt" - - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/registry" - - "origadmin/application/admin/internal/configs" -) - -// ConfigManager 实现配置获取和转换能力 -type ConfigManager struct { - discover registry.KDiscovery -} - -func NewConfigManager(discover registry.KDiscovery) *ConfigManager { - return &ConfigManager{discover: discover} -} - -// 从 Consul KV 获取特定配置 -func (cm *ConfigManager) GetConfig(configName string) ([]byte, error) { - client, ok := cm.discover.(*registry.ConsulClient) - if !ok { - return nil, fmt.Errorf("discovery client is not Consul") - } - - // 从 Consul KV 获取配置 - return client.GetKV(configName) -} - -// 从发现服务获取配置 -func (cm *ConfigManager) GetServiceConfig(ctx context.Context, name string) (*configs.Bootstrap, error) { - instances, err := cm.discover.GetService(ctx, name) - if err != nil { - return nil, err - } - - // 实现配置转换逻辑 - return convertInstancesToConfig(instances) -} - -// 实现配置转换逻辑 -func convertInstancesToConfig(instances []*registry.KServiceInstance) (*configs.Bootstrap, error) { - if len(instances) == 0 { - return nil, fmt.Errorf("no instances found") - } - - // 示例实现:从第一个实例提取基础配置 - firstInstance := instances[0] - return &configs.Bootstrap{ - ServiceName: firstInstance.Name, - Discovery: nil, // 需要重新初始化发现客户端 - // 其他字段根据需要映射... - - }, nil -} diff --git a/internal/loader/file.go b/internal/loader/file.go index 60d8cec1..c6b803d5 100644 --- a/internal/loader/file.go +++ b/internal/loader/file.go @@ -12,6 +12,9 @@ import ( "github.com/goexts/generic/settings" "github.com/origadmin/contrib/replacer" + "github.com/origadmin/runtime/config" + "github.com/origadmin/runtime/config/file" + configv1 "github.com/origadmin/runtime/gen/go/config/v1" "github.com/origadmin/toolkits/codec" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" @@ -57,3 +60,15 @@ func ReplaceObject(s any, envs map[string]string) error { marshal = Replace(marshal, envs) return json.Unmarshal(marshal, s) } + +func NewFileConfig(sourceConfig *configv1.SourceConfig, _ *config.Options) (config.KSource, error) { + cfg := sourceConfig.GetFile() + if cfg == nil { + return nil, config.ErrInvalidConfigType + } + var options []file.Option + if len(cfg.Ignores) > 0 { + options = append(options, file.WithIgnores(cfg.Ignores...)) + } + return file.NewSource(cfg.Path, options...), nil +} diff --git a/internal/loader/loader.go b/internal/loader/load.go similarity index 58% rename from internal/loader/loader.go rename to internal/loader/load.go index 6509886f..61c5e654 100644 --- a/internal/loader/loader.go +++ b/internal/loader/load.go @@ -6,9 +6,6 @@ package loader import ( - "fmt" - "os" - "github.com/go-kratos/kratos/v2/transport" "github.com/go-kratos/kratos/v2/transport/grpc" "github.com/go-kratos/kratos/v2/transport/http" @@ -20,7 +17,6 @@ import ( "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/registry" - "github.com/origadmin/runtime/service" "origadmin/application/admin/helpers/securityx" "origadmin/application/admin/internal/configs" @@ -33,7 +29,7 @@ type AppOptions struct { Version string Metadata map[string]string Logger log.KLogger - Server transport.Server // 改为通用传输层接口 + Server transport.Server } var ( @@ -43,7 +39,7 @@ var ( NewTokenizer, NewAuthorizer, NewAuthenticator, - wire.Struct(new(InjectorServer), "*"), + wire.Struct(new(Injector), "*"), wire.Struct(new(InjectorClient), "*"), ) ) @@ -64,16 +60,14 @@ type InjectorClient struct { Server *http.Server } -type InjectorServer struct { - Logger log.KLogger - Bootstrap *configs.Bootstrap +type Injector struct { Registrar registry.KRegistrar Servers []transport.Server } func init() { runtime.RegisterConfigFunc("file", NewFileConfig) - runtime.RegisterService("ORIGADMIN_SERVICE", service.DefaultServiceBuilder) + //runtime.RegisterService(service.Service, service.DefaultServiceBuilder) } func NewAuthenticator(bootstrap *configs.Bootstrap) (security.Authenticator, error) { @@ -111,57 +105,12 @@ func (l loader) SetupEnv() error { } func (l loader) Bootstrap() (*configs.Bootstrap, error) { - var bs *configs.Bootstrap - var err error - switch l.cfg.GetType() { - case "file": - bs, err = LoadLocalBootstrap(l.cfg) - default: - bs, err = LoadRemoteBootstrap(l.cfg) - } - if err != nil { - return nil, fmt.Errorf("load bootstrap error: %s", err.Error()) - } - - log.Infof("load config: %+v\n", bs) - return bs, nil + return LoadBootstrap(l.cfg) } -func New(flags *Bootstrap) (Loader, error) { +func NewLoader(bs *bootstrap.Bootstrap) (Loader, error) { load := &loader{ - flags: flags, - } - sourceConfig, err := bootstrap.LoadSourceConfig(flags) - if err != nil { - return nil, err + flags: bs, } - load.cfg = sourceConfig return load, nil } - -// 删除复杂的多级错误收集机制,简化为优先级失败模式 -func LoadBootstrap(cfg BootstrapConfig) (*configs.Bootstrap, error) { - var bs *configs.Bootstrap - var err error - - // 优先尝试加载远程配置 ✅ 首选远程配置中心 - bs, err = LoadRemoteBootstrap(&cfg.Source) - if err == nil && bs != nil { - if envErr := ReplaceObject(bs, cfg.Source.EnvArgs); envErr == nil { - return bs, nil - } - return nil, fmt.Errorf("remote config replace failed: %w", envErr) - } - - // 远程加载失败时回退到本地配置 ⛔️ 仅作为降级方案 - bs, err = LoadLocalBootstrap(&cfg.Source) - if err == nil && bs != nil { - if envErr := ReplaceObject(bs, cfg.Source.EnvArgs); envErr == nil { - return bs, nil - } - return nil, fmt.Errorf("local config replace failed: %w", envErr) - } - - return nil, fmt.Errorf("failed to load config: remote[%v], local[%v]", - err, os.ErrNotExist) -} diff --git a/internal/loader/setup.go b/internal/loader/setup.go deleted file mode 100644 index fa566403..00000000 --- a/internal/loader/setup.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/hash/types" - - "origadmin/application/admin/internal/configs" -) - -func InitSetup(bootstrap *configs.Bootstrap) error { - // add init action here - crypto := bootstrap.GetCryptoType() - cryptoType := types.TypeArgon2 - if crypto != "" { - cryptoType = types.ParseType(crypto) - } - err := hash.UseCrypto(cryptoType) - if err != nil { - return err - } - return nil -} diff --git a/internal/mods/agent/http.go b/internal/mods/agent/http.go index db1d9565..95fc1250 100644 --- a/internal/mods/agent/http.go +++ b/internal/mods/agent/http.go @@ -17,11 +17,11 @@ import ( "github.com/origadmin/runtime" msecurity "github.com/origadmin/runtime/agent/middleware/security" "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/middleware" "github.com/origadmin/runtime/service" servicehttp "github.com/origadmin/runtime/service/http" - "github.com/origadmin/runtime/interfaces/security" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/contrib/security/authz/casbin" diff --git a/internal/mods/auth/biz/README.md b/internal/mods/auth/biz/README.md new file mode 100644 index 00000000..c68e603d --- /dev/null +++ b/internal/mods/auth/biz/README.md @@ -0,0 +1,3 @@ +# Biz + +This directory contains the business logic of the service. \ No newline at end of file diff --git a/internal/mods/auth/biz/auth.biz.go b/internal/mods/auth/biz/auth.biz.go new file mode 100644 index 00000000..9c86efe9 --- /dev/null +++ b/internal/mods/auth/biz/auth.biz.go @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/dto" +) + +// AuthServiceBiz is a Auth use case. +type AuthServiceBiz struct { + dao dto.AuthRepo + limiter pagination.PageLimiter + log *log.KHelper +} + +func (biz AuthServiceBiz) AuthLogout(ctx context.Context, in *pb.AuthLogoutRequest) (*pb.AuthLogoutResponse, error) { + return biz.dao.AuthLogout(ctx, in) +} + +func (biz AuthServiceBiz) CreateToken(ctx context.Context, in *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error) { + return biz.dao.CreateToken(ctx, in) +} + +func (biz AuthServiceBiz) ValidateToken(ctx context.Context, in *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) { + return biz.dao.ValidateToken(ctx, in) +} + +func (biz AuthServiceBiz) DestroyToken(ctx context.Context, in *pb.DestroyTokenRequest) (*pb.DestroyTokenResponse, error) { + return biz.dao.DestroyToken(ctx, in) +} + +func (biz AuthServiceBiz) Authenticate(ctx context.Context, in *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) { + return biz.dao.Authenticate(ctx, in) +} + +func (biz AuthServiceBiz) ListAuthResources(ctx context.Context, in *pb.ListAuthResourcesRequest) (*pb.ListAuthResourcesResponse, error) { + var option dto.AuthResourceQueryOption + if err := option.FromListRequest(in, biz.limiter); err != nil { + return nil, err + } + biz.log.Info("ListAuths") + result, total, err := biz.dao.ListAuthResources(ctx, in, option) + if err != nil { + return nil, err + } + return dto.ToListAuthResourcesResponse(result, in, total) +} + +// NewAuthServiceBiz new Auth use case. +func NewAuthServiceBiz(r runtime.Runtime, repo dto.AuthRepo) *AuthServiceBiz { + return &AuthServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.WithLogger("module", "biz/auth"))} +} diff --git a/internal/mods/casbin/biz/biz.go b/internal/mods/auth/biz/biz.go similarity index 79% rename from internal/mods/casbin/biz/biz.go rename to internal/mods/auth/biz/biz.go index d918b7e5..617e105d 100644 --- a/internal/mods/casbin/biz/biz.go +++ b/internal/mods/auth/biz/biz.go @@ -8,14 +8,18 @@ import ( "net/http" "github.com/google/wire" - "github.com/origadmin/toolkits/errors/httperr" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/toolkits/errors/httperr" pb "origadmin/application/admin/api/v1/services/system" ) // ProviderSet is biz providers. -var ProviderSet = wire.NewSet() +var ProviderSet = wire.NewSet( + NewAuthServiceBiz, + NewLoginServiceBiz, + NewCasbinSourceServiceBiz, +) var ( // ErrUserNotFound is user not found. @@ -25,3 +29,7 @@ var ( var ( defaultLimiter = pagination.DefaultLimiter() ) + +type UpdateHooker interface { + UpdateRules() +} diff --git a/internal/mods/auth/biz/casbin.biz.go b/internal/mods/auth/biz/casbin.biz.go new file mode 100644 index 00000000..828973d6 --- /dev/null +++ b/internal/mods/auth/biz/casbin.biz.go @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "context" + "sync/atomic" + "time" + + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/interfaces/pagination" + "google.golang.org/grpc" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/dto" +) + +// CasbinSourceServiceBiz is a CasbinSource use case. +type CasbinSourceServiceBiz struct { + dao dto.CasbinSourceRepo + limiter pagination.PageLimiter + log *log.KHelper + lastModified *atomic.Int64 +} + +func (c CasbinSourceServiceBiz) StreamRules(request *pb.StreamRulesRequest, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { + log.Info("StreamRules") + ctx := stream.Context() + if request.WithPolicies { + if err := c.streamPolicies(ctx, stream); err != nil { + return err + } + } + + if request.WithGroupings { + if err := c.streamGroupings(ctx, stream); err != nil { + return err + } + } + return nil +} + +func (c CasbinSourceServiceBiz) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { + log.Info("ListPolicies") + return c.dao.ListPolicies(ctx, in) +} + +func (c CasbinSourceServiceBiz) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { + log.Info("ListGroupings") + return c.dao.ListGroupings(ctx, in) +} + +func (c CasbinSourceServiceBiz) WatchUpdate(_ context.Context, + request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { + log.Info("WatchUpdate") + return &pb.WatchUpdateResponse{ModifiedDate: c.lastModified.Load()}, nil +} + +func (c CasbinSourceServiceBiz) UpdateRules() { + // todo: load from db + c.lastModified.Store(time.Now().Unix()) +} + +func (c CasbinSourceServiceBiz) streamPolicies(ctx context.Context, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { + policies, err := c.ListPolicies(ctx, &pb.ListPoliciesRequest{}) + if err != nil { + return err + } + for _, rule := range policies.Rules { + if err := stream.Send(newPolicyResponse(rule)); err != nil { + return err + } + } + return nil +} + +func (c CasbinSourceServiceBiz) streamGroupings(ctx context.Context, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { + groupings, err := c.ListGroupings(ctx, &pb.ListGroupingsRequest{}) + if err != nil { + return err + } + for _, rule := range groupings.Rules { + if err := stream.Send(newGroupingResponse(rule)); err != nil { + return err + } + } + return nil +} + +func newPolicyResponse(rule *pb.PolicyRule) *pb.StreamRulesResponse { + return &pb.StreamRulesResponse{ + RuleType: &pb.StreamRulesResponse_Policy{Policy: rule}, + } +} + +func newGroupingResponse(rule *pb.GroupingRule) *pb.StreamRulesResponse { + return &pb.StreamRulesResponse{ + RuleType: &pb.StreamRulesResponse_Grouping{Grouping: rule}, + } +} + +// NewCasbinSourceServiceBiz new a CasbinSource use case. +func NewCasbinSourceServiceBiz(repo dto.CasbinSourceRepo, logger log.KLogger) *CasbinSourceServiceBiz { + return &CasbinSourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger), + lastModified: &atomic.Int64{}} +} diff --git a/internal/mods/auth/biz/login.biz.go b/internal/mods/auth/biz/login.biz.go new file mode 100644 index 00000000..d39bf20f --- /dev/null +++ b/internal/mods/auth/biz/login.biz.go @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "context" + + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/interfaces/pagination" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/dto" +) + +// LoginServiceBiz is a Login use case. +type LoginServiceBiz struct { + dao dto.LoginRepo + limiter pagination.PageLimiter + log *log.KHelper +} + +func (biz LoginServiceBiz) CaptchaId(ctx context.Context, in *pb.CaptchaIdRequest) (*pb.CaptchaIdResponse, error) { + log.Info("CaptchaId") + return biz.dao.CaptchaID(ctx, in) +} + +func (biz LoginServiceBiz) Register(ctx context.Context, in *pb.RegisterRequest) (*pb.RegisterResponse, error) { + log.Info("Register") + return biz.dao.Register(ctx, in) +} + +func (biz LoginServiceBiz) Captcha(ctx context.Context, in *pb.CaptchaRequest) (*pb.CaptchaResponse, error) { + log.Info("Captcha") + return biz.dao.Captcha(ctx, in) +} + +func (biz LoginServiceBiz) CaptchaImage(ctx context.Context, in *dto.CaptchaImageRequest) (*dto.CaptchaImageResponse, error) { + log.Info("CaptchaImage") + return biz.dao.CaptchaImage(ctx, in.Id, in.Reload == "1" || in.Reload == "true") +} + +func (biz LoginServiceBiz) CaptchaAudio(ctx context.Context, in *pb.CaptchaAudioRequest) (*pb.CaptchaAudioResponse, error) { + log.Info("CaptchaAudio") + return biz.dao.CaptchaAudio(ctx, in.Id, in.Reload == "1" || in.Reload == "true") +} + +func (biz LoginServiceBiz) Login(ctx context.Context, in *dto.LoginRequest) (*dto.LoginResponse, error) { + log.Info("Login") + return biz.dao.Login(ctx, in) +} + +func (biz LoginServiceBiz) Logout(ctx context.Context, in *dto.LogoutRequest) (*dto.LogoutResponse, error) { + log.Info("Logout") + return biz.dao.Logout(ctx, in) +} + +func (biz LoginServiceBiz) CurrentUser(ctx context.Context, in *dto.CurrentUserRequest) (*dto.CurrentUserResponse, error) { + log.Info("CurrentUser") + return biz.dao.CurrentUser(ctx, in) +} + +func (biz LoginServiceBiz) TokenRefresh(ctx context.Context, in *pb.TokenRefreshRequest) (*pb.TokenRefreshResponse, error) { + log.Info("TokenRefresh") + return biz.dao.TokenRefresh(ctx, in) +} + +// NewLoginServiceBiz new a Login use case. +func NewLoginServiceBiz(repo dto.LoginRepo, logger log.KLogger) *LoginServiceBiz { + return &LoginServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger)} +} diff --git a/internal/mods/auth/dal/README.md b/internal/mods/auth/dal/README.md new file mode 100644 index 00000000..0f77dee7 --- /dev/null +++ b/internal/mods/auth/dal/README.md @@ -0,0 +1,3 @@ +# Dal + +This directory contains the data access layer (DAL) for the service. diff --git a/internal/mods/auth/dal/auth.dal.go b/internal/mods/auth/dal/auth.dal.go new file mode 100644 index 00000000..c1fc22bd --- /dev/null +++ b/internal/mods/auth/dal/auth.dal.go @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "context" + "errors" + "sync" + + "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data/entity/ent" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" + "origadmin/application/admin/internal/mods/system/dto" +) + +type authRepo struct { + DB *Data + BufPool *sync.Pool + Tokenizer security.Tokenizer + Authorizer security.Authorizer +} + +func (repo authRepo) AuthLogout(ctx context.Context, request *pb.AuthLogoutRequest) (*pb.AuthLogoutResponse, error) { + //TODO implement me + panic("implement me") +} + +func (repo authRepo) CreateToken(ctx context.Context, request *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error) { + claims := security.ClaimsFromContext(ctx) + token, err := repo.Tokenizer.CreateToken(ctx, claims) + if err != nil { + return nil, err + } + return &pb.CreateTokenResponse{ + Token: token, + }, nil +} + +func (repo authRepo) ValidateToken(ctx context.Context, request *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) { + valid, err := repo.Tokenizer.Validate(ctx, request.Token) + if err != nil { + return nil, err + } + return &pb.ValidateTokenResponse{ + IsValid: valid, + }, nil +} + +func (repo authRepo) DestroyToken(ctx context.Context, request *pb.DestroyTokenRequest) (*pb.DestroyTokenResponse, error) { + //err := repo.Tokenizer.DestroyToken(ctx, request.Token) + //if err != nil { + // return nil, err + //} + return &pb.DestroyTokenResponse{}, nil +} + +func (repo authRepo) Authenticate(ctx context.Context, request *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) { + claims, err := repo.Tokenizer.ParseClaims(ctx, request.GetData().GetToken()) + if err != nil { + return nil, err + } + authorized, err := repo.Authorizer.Authorized( + ctx, + fromClaims(claims, "", ""), + request.GetData().GetMethod(), + request.GetData().GetPath()) + if err != nil { + return nil, err + } + return &pb.AuthenticateResponse{ + IsValid: authorized, + //Claims: fromClaims(claims), + }, nil +} + +func (repo authRepo) ListAuthResources(ctx context.Context, in *dto.ListAuthResourcesRequest, options ...dto.AuthResourceQueryOption) ([]*dto.ResourcePB, int32, error) { + var option dto.AuthResourceQueryOption + if len(options) > 0 { + option = options[0] + } + query := repo.DB.Resource(ctx).Query() + return authResourcePageQuery(ctx, query, in, option) +} + +func fromClaims(claims security.Claims, method, path string) security.Policy { + return &security.RegisteredPolicy{ + Subject: claims.GetSubject(), + Object: path, + Action: method, + Domain: claims.GetIssuer(), + Roles: nil, + Permissions: nil, + } +} + +// NewAuthRepo . +func NewAuthRepo(db *Data, logger log.KLogger) dto.AuthRepo { + return &authRepo{ + DB: db, + BufPool: BufPool(), + } +} + +func authResourcePageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.ListAuthResourcesRequest, option dto.AuthResourceQueryOption) ([]*dto.ResourcePB, int32, error) { + query = authResourceQueryPage(query, in) + query = authResourceQueryOptions(query, option) + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + result, err := query.All(ctx) + return dto.ConvertResources(result), int32(count), err +} + +func authResourceQueryPage(query *ent.ResourceQuery, in *pb.ListAuthResourcesRequest) *ent.ResourceQuery { + if in.NoPaging { + pageSize := in.PageSize + if pageSize > 0 { + query = query.Limit(int(pageSize)) + } + return query + } + + pageSize := in.PageSize + if pageSize > 0 { + query = query.Limit(int(pageSize)) + } + current := in.Current + if current > 0 { + query = query.Offset(int((current - 1) * pageSize)) + } + return query +} + +func authResourceQueryOptions(query *ent.ResourceQuery, option dto.AuthResourceQueryOption) *ent.ResourceQuery { + if len(option.SelectFields) > 0 { + query = query.Select(option.SelectFields...).ResourceQuery + } + if len(option.OmitFields) > 0 { + query = query.Omit(option.OmitFields...).ResourceQuery + } + if len(option.OrderFields) > 0 { + query = query.Order(resourceOrderBy(option.OrderFields)...) + } + return query +} + +type refreshTokenizer struct { + tokenizer security.Tokenizer +} + +func (r refreshTokenizer) CreateClaims(ctx context.Context, s string) (security.Claims, error) { + return r.tokenizer.CreateClaims(ctx, s) +} + +func (r refreshTokenizer) CreateToken(ctx context.Context, claims security.Claims) (string, error) { + return r.tokenizer.CreateToken(ctx, claims) +} + +func (r refreshTokenizer) ParseClaims(ctx context.Context, s string) (security.Claims, error) { + return r.tokenizer.ParseClaims(ctx, s) +} + +func (r refreshTokenizer) Validate(ctx context.Context, s string) (bool, error) { + return r.tokenizer.Validate(ctx, s) +} + +func (r refreshTokenizer) CreateRefreshClaims(ctx context.Context, s string) (security.Claims, error) { + return nil, errors.New("not implemented") +} + +func wrapRefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { + return &refreshTokenizer{ + tokenizer: tokenizer, + } +} diff --git a/internal/mods/auth/dal/casbin.dal.go b/internal/mods/auth/dal/casbin.dal.go new file mode 100644 index 00000000..8a84bee9 --- /dev/null +++ b/internal/mods/auth/dal/casbin.dal.go @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dal implements the functions, types, and interfaces for the module. +package dal + +import ( + "context" + "strconv" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/mods/system/dto" +) + +type CasbinSourceConfig struct { + PrefixNumberID func(prefix string, id int64) string +} + +type casbinSourceRepo struct { + ctx context.Context + data *Data + config *CasbinSourceConfig +} + +func (c casbinSourceRepo) mustEmbedUnimplementedCasbinSourceServiceServer() { + // This method is useless, + // it is just automatically generated when using the inheritance implementation interface +} + +func permissionResourceQuery(query *ent.PermissionQuery) { + query.WithResources() +} +func (c casbinSourceRepo) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { + rolePermissions, err := c.data.RolePermission(ctx).Query().WithPermission(permissionResourceQuery).WithRole().All(ctx) + if err != nil { + return nil, err + } + var rules []*pb.PolicyRule + for _, rolePermission := range rolePermissions { + permission, err := rolePermission.Edges.PermissionOrErr() + if err != nil { + continue + } + resources, err := permission.Edges.ResourcesOrErr() + if err != nil { + continue + } + for _, resource := range resources { + if resource.Type != "A" && resource.Type != "B" { + continue + } + rules = append(rules, &pb.PolicyRule{ + PType: "p", + Params: []string{ + c.config.PrefixNumberID("role", rolePermission.RoleID), + resource.Path, + resource.Method, + "*", + }, + }) + } + } + return &pb.ListPoliciesResponse{Rules: rules}, nil +} + +func (c casbinSourceRepo) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { + userRoles, err := c.data.UserRole(ctx).Query().All(ctx) + if err != nil { + return nil, err + } + var rules []*pb.GroupingRule + for _, userRole := range userRoles { + rules = append(rules, &pb.GroupingRule{ + PType: "g", + Params: []string{ + c.config.PrefixNumberID("user", userRole.UserID), + c.config.PrefixNumberID("role", userRole.RoleID), + //todo: add domain support + "*", + }, + }) + } + return &pb.ListGroupingsResponse{ + Rules: rules, + }, nil +} + +// NewCasbinSourceRepo returns a new CasbinSourceRepo +func NewCasbinSourceRepo(data *Data) (dto.CasbinSourceRepo, error) { + c := &casbinSourceRepo{ + data: data, + config: &CasbinSourceConfig{ + PrefixNumberID: func(prefix string, id int64) string { + return prefix + "_" + strconv.FormatInt(id, 10) + }, + }, + } + return c, nil +} + +// NewCasbinSourceWithClient create a new CasbinSourceRepo with given client. +// This method does not ensure the existence of database, user should create database manually. +func NewCasbinSourceWithClient(client *ent.Client) (dto.CasbinSourceRepo, error) { + c := &casbinSourceRepo{ + data: NewDataWithClient(client), + config: &CasbinSourceConfig{ + PrefixNumberID: func(prefix string, id int64) string { + return prefix + "_" + strconv.FormatInt(id, 10) + }, + }, + } + return c, nil +} diff --git a/internal/mods/auth/dal/dal.go b/internal/mods/auth/dal/dal.go new file mode 100644 index 00000000..e4451fa9 --- /dev/null +++ b/internal/mods/auth/dal/dal.go @@ -0,0 +1,567 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "context" + "errors" + "fmt" + "os" + "path/filepath" + "strconv" + "strings" + "time" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/schema" + "github.com/google/wire" + "github.com/origadmin/contrib/database" + "github.com/origadmin/entslog/v3" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/codec" + + "origadmin/application/admin/helpers/db" + "origadmin/application/admin/helpers/id" + "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/mods/system/dto" +) + +const ( + TreePathDelimiter = "." +) + +// Data . +type Data struct { + *ent.Database +} + +// ProviderSet is data providers. +var ProviderSet = wire.NewSet( + wire.Struct(new(LoginData), "*"), + NewData, + NewAuthRepo, + NewLoginRepo, + NewCasbinSourceRepo, + RefreshTokenizer, +) + +// NewTrans returns a transaction wit data +//func NewTrans(data *Data) database.Trans { +// return data +//} + +const FKSuffix = "_fk=1" + +func FixSource(source string) string { + // Check if the source already contains the FK parameter + if strings.Contains(source, FKSuffix) { + return source + } + + // Check if the source already contains parameters + if strings.Contains(source, "?") { + // If parameters exist, append with & + if !strings.HasSuffix(source, "&") { + source += "&" + } + source += FKSuffix + } else { + // If no parameters exist, append with ? + source += "?" + FKSuffix + } + return source +} + +func debugDatabase(driver dialect.Driver, debug bool) dialect.Driver { + if debug { + return entslog.New(driver) + } + return driver +} + +// NewData . +func NewData(r runtime.Runtime, bootstrap *configs.Bootstrap) (*Data, func(), error) { + if bootstrap == nil { + return nil, nil, errors.New("bootstrap is nil") + } + + cfg := bootstrap.GetStorage().GetDatabase() + if cfg == nil { + return nil, nil, errors.New("data source not found") + } + + drv, err := database.Open(cfg) + log.Infow("msg", "connecting to database", "dialect", cfg.Dialect, "source", cfg.Source) + if err != nil { + log.Errorw("msg", "failed opening connection to database", "error", err) + return nil, nil, err + } + + // Run the auto migration tool. + //sqldb := debugDatabase(sql.OpenDB(cfg.Dialect, drv), cfg.Debug) + + db := ent.NewDatabase(ent.Driver(sql.OpenDB(cfg.Dialect, drv)), ent.WithDebug(func(driver dialect.Driver, f ...func(...any)) dialect.Driver { + return debugDatabase(driver, cfg.Debug) + })) + if true || cfg.GetMigration().GetEnabled() { + if err := db.Migration( + context.Background(), + schema.WithDropIndex(true), + schema.WithDropColumn(true), + schema.WithForeignKeys(false)); err != nil { + log.Errorw("msg", "failed creating schema resources", "error", err) + return nil, nil, err + } + } + + data := &Data{ + Database: db, + } + + // 初始化数据 + if err := data.InitDataFromPath(context.Background(), ""); err != nil { + log.Errorw("failed to init data", "error", err) + return nil, nil, err + } + + return data, func() { + log.Info("closing the data resources") + if err := drv.Close(); err != nil { + log.Error(err) + } + }, nil +} + +func NewDataWithClient(client *ent.Client) *Data { + return &Data{ + Database: ent.NewDatabaseWithClient(client), + } +} + +func (obj *Data) InitDataFromPath(ctx context.Context, path string, filters ...string) error { + type data struct { + name string + fn func(ctx context.Context, filename string) error + } + initializers := []data{ + { + name: "resource", + fn: obj.InitResourceFromFile, + }, + { + name: "role", + fn: obj.InitRoleFromFile, + }, + { + name: "user", + fn: obj.InitUserFromFile, + }, + { + name: "department", + fn: obj.InitDepartmentFromFile, + }, + { + name: "position", + fn: obj.InitPositionFromFile, + }, + { + name: "permission", + fn: obj.InitPermissionFromFile, + }, + } + actions := make([]data, 0) + for _, di := range initializers { + for _, filter := range filters { + if di.name == filter { + actions = append(actions, di) + } + } + + } + for _, action := range actions { + action.name = filepath.Join(path, action.name+".json") + err := action.fn(ctx, action.name) + if err != nil { + return err + } + } + + return nil +} +func (obj *Data) InitResourceFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var resources []*dto.ResourceNode + err = codec.DecodeFromFile(abs, &resources) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("Resource data file not found, skip init resource data from file", "file", abs) + return nil + } + return err + } + for i, pb := range resources { + log.Infow("msg", "Processing resource", "index", i, "resourceId", pb.Id, "resourceKeyword", pb.Keyword, "resourceName", pb.Name) + if pb.Children != nil { + for i2, child := range pb.Children { + log.Infow("msg", "Processing child", "index", i2, "childId", child.Id, "childKeyword", child.Keyword, "childName", child.Name) + } + } + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createResourceBatchWithParent(ctx, resources, nil) + }) +} + +func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto.ResourceNode, parent *dto.ResourcePB) error { + total := len(items) + log.Infow("msg", "Starting createResourceBatchWithParent", "totalItems", total) + + for i, item := range items { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) + var pid int64 + if parent != nil { + pid = parent.Id + log.Infow("msg", "Parent ID set", "parentId", pid) + } + founded := false + switch { + case item.Id != 0: + log.Infow("Checking item by ID", "itemId", item.Id) + exists, err := obj.Resource(ctx).Query().Where(resource.ID(item.Id)).Exist(ctx) + if err != nil { + log.Errorw("msg", "Error checking item by ID", "itemId", item.Id, "error", err) + return err + } + if exists { + log.Infow("msg", "Item already exists by ID", "itemId", item.Id) + continue + } + case item.Keyword != "": + log.Infow("msg", "Checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid) + var wheres = []predicate.Resource{ + resource.Keyword(item.Keyword), + } + if pid != 0 { + wheres = append(wheres, resource.ParentID(pid)) + } + exists, err := obj.Resource(ctx).Query().Where(wheres...).Exist(ctx) + if err != nil { + log.Errorw("msg", "Error checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) + return err + } + if exists { + resourceItem, err := obj.Resource(ctx).Query().Where(wheres...).First(ctx) + if err != nil { + log.Errorw("msg", "Error fetching item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) + return err + } + founded = true + item.Id = resourceItem.ID + log.Infow("msg", "Item found by Keyword", "itemKeyword", item.Keyword, "itemId", item.Id) + } + case item.Name != "": + log.Infow("msg", "Checking item by Name", "itemName", item.Name, "parentId", pid) + var conditions = []predicate.Resource{ + resource.Name(item.Name), + } + if pid != 0 { + conditions = append(conditions, resource.ParentID(pid)) + } + exists, err := obj.Resource(ctx).Query().Where(conditions...).Exist(ctx) + if err != nil { + log.Errorw("msg", "Error checking item by Name", "itemName", item.Name, "parentId", pid, "error", err) + return err + } + if exists { + resourceItem, err := obj.Resource(ctx).Query().Where(conditions...).First(ctx) + if err != nil { + log.Errorw("msg", "Error fetching item by Name", "itemName", item.Name, "parentId", pid, "error", err) + return err + } + founded = true + item.Id = resourceItem.ID + log.Infow("msg", "Item found by Name", "itemName", item.Name, "itemId", item.Id) + } + default: + log.Infow("msg", "No ID, Keyword, or Name provided for item") + } + + if !founded { + if item.Id == 0 { + item.Id = id.Gen() + log.Infow("msg", "Generated new ID for item", "itemId", item.Id) + } + if item.Status == 0 { + item.Status = int32(dto.UserStatusActive) + log.Infow("msg", "Setting default status for item", "itemId", item.Id, "status", item.Status) + } + if item.Sequence == 0 { + item.Sequence = int32(total - i) + log.Infow("msg", "Setting default sequence for item", "itemId", item.Id, "sequence", item.Sequence) + } + + item.ParentId = pid + if parent != nil { + item.TreePath = parent.TreePath + strconv.Itoa(int(pid)) + TreePathDelimiter + log.Infow("msg", "Setting parent path for item", "itemId", item.Id, "treePath", item.TreePath) + } + itemObj := dto.ConvertResourcePB2Object(&item.ResourcePB) + itemObj.UpdateTime = time.Now() + itemObj.CreateTime = time.Now() + if _, err := obj.Resource(ctx).Create().SetResource(itemObj).Save(ctx); err != nil { + log.Errorw("msg", "Error creating resource item", "itemId", item.Id, "sequence", item.Sequence, "error", err) + return err + } + log.Infow("msg", "Resource item created successfully", "itemId", item.Id) + } + + if len(item.Children) != 0 { + log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) + if err := obj.createResourceBatchWithParent(ctx, item.Children, &item.ResourcePB); err != nil { + log.Errorw("Error processing children", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "Children processed successfully", "itemId", item.Id) + } + } + log.Infow("msg", "Finished createResourceBatchWithParent") + return nil +} + +func (obj *Data) InitUserFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var users []*dto.UserNode + err = codec.DecodeFromFile(abs, &users) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("User data file not found, skip init user data from file", "file", abs) + return nil + } + return err + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createUserBatch(ctx, users) + }) +} + +func (obj *Data) createUserBatch(ctx context.Context, users []*dto.UserNode) error { + total := len(users) + log.Infow("msg", "Starting createUserBatch", "totalItems", total) + for i, item := range users { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemUsername", item.Username, "itemNickname", item.Nickname) + user, ps, err := dto.MakeCreateUser(&item.UserPB, item.Username, item.Password, dto.UserMutationOption{}) + if err != nil { + return err + } + fmt.Println("generate user: ", user.Username, "with password: ", ps) + if _, err := obj.User(ctx).Create().SetIsSystem(item.IsSystem).SetUser(dto.ConvertUserPB2Object(user)). + Save(ctx); err != nil { + log.Errorw("msg", "Error creating user item", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "User item created successfully", "itemId", item.Id, "itemUuid", item.Uuid) + } + log.Infow("msg", "Finished createUserBatch") + return nil +} + +func (obj *Data) InitRoleFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var roles []*dto.RolePB + err = codec.DecodeFromFile(abs, &roles) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("Role data file not found, skip init role data from file", "file", abs) + return nil + } + return err + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createRoleBatch(ctx, roles) + }) +} + +func (obj *Data) createRoleBatch(ctx context.Context, roles []*dto.RolePB) error { + total := len(roles) + log.Infow("msg", "Starting createRoleBatch", "totalItems", total) + for i, item := range roles { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) + if item.Id == 0 { + item.Id = id.Gen() + log.Infow("msg", "Generated new ID for item", "itemId", item.Id) + } + if _, err := obj.Role(ctx).Create().SetRole(dto.ConvertRolePB2Object(item)).Save(ctx); err != nil { + log.Errorw("msg", "Error creating role item", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "Role item created successfully", "itemId", item.Id) + } + log.Infow("msg", "Finished createRoleBatch") + return nil +} + +func (obj *Data) InitDepartmentFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var departments []*dto.DepartmentNode + err = codec.DecodeFromFile(abs, &departments) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("Department data file not found, skip init department data from file", "file", abs) + return nil + } + return err + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createDepartmentBatch(ctx, departments, nil) + }) +} + +func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.DepartmentNode, parent *dto.DepartmentPB) error { + total := len(departments) + log.Infow("msg", "Starting createDepartmentBatch", "totalItems", total) + for i, item := range departments { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) + if item.Id == 0 { + item.Id = id.Gen() + log.Infow("msg", "Generated new ID for item", "itemId", item.Id) + } + if parent != nil { + item.ParentId = parent.Id + item.TreePath = parent.TreePath + strconv.Itoa(int(parent.Id)) + TreePathDelimiter + } + + if _, err := obj.Department(ctx).Create(). + SetDepartment(dto.ConvertDepartmentPB2Object(&item.DepartmentPB)). + Save(ctx); err != nil { + log.Errorw("msg", "Error creating department item", "itemId", item.Id, "error", err) + return err + } + + log.Infow("msg", "Department item created successfully", "itemId", item.Id) + if len(item.Children) != 0 { + log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) + if err := obj.createDepartmentBatch(ctx, item.Children, &item.DepartmentPB); err != nil { + log.Errorw("Error processing children", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "Children processed successfully", "itemId", item.Id) + } + } + log.Infow("msg", "Finished createDepartmentBatch") + return nil +} + +func (obj *Data) InitPositionFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var positions []*dto.PositionNode + err = codec.DecodeFromFile(abs, &positions) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("Position data file not found, skip init position data from file", "file", abs) + return nil + } + return err + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createPositionBatch(ctx, positions) + }) +} + +func (obj *Data) createPositionBatch(ctx context.Context, positions []*dto.PositionNode) error { + total := len(positions) + log.Infow("msg", "Starting createPositionBatch", "totalItems", total) + for i, item := range positions { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) + if item.Id == 0 { + item.Id = id.Gen() + log.Infow("msg", "Generated new ID for item", "itemId", item.Id) + } + dept, err := obj.Department(ctx).Query().Where(department.Keyword(item.DepartmentKeyword)).Only(ctx) + if err != nil { + return err + } + + if _, err := obj.Position(ctx).Create().SetPosition(&dto.Position{ + ID: item.Id, + CreateTime: time.Now(), + UpdateTime: time.Now(), + Name: item.Name, + Keyword: item.Keyword, + Description: item.Description, + DepartmentID: dept.ID, + }).Save(ctx); err != nil { + log.Errorw("msg", "Error creating position item", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "Position item created successfully", "itemId", item.Id) + } + log.Infow("msg", "Finished createPositionBatch") + return nil +} + +func (obj *Data) InitPermissionFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var permissions []*dto.PermissionNode + err = codec.DecodeFromFile(abs, &permissions) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("Permission data file not found, skip init permission data from file", "file", abs) + return nil + } + return err + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createPermissionBatch(ctx, permissions) + }) +} + +func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.PermissionNode) error { + total := len(permissions) + log.Infow("msg", "Starting createPermissionBatch", "totalItems", total) + for i, item := range permissions { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) + if item.Id == 0 { + item.Id = id.Gen() + log.Infow("msg", "Generated new ID for item", "itemId", item.Id) + } + if _, err := obj.Permission(ctx).Create(). + SetPermission(dto.ConvertPermissionPB2Object(&item.PermissionPB)). + Save(ctx); err != nil { + log.Errorw("msg", "Error creating permission item", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "Permission item created successfully", "itemId", item.Id) + } + log.Infow("msg", "Finished createPermissionBatch") + return nil +} + +func resourceOrderBy(orders []string) []resource.OrderOption { + return db.OrderBy[resource.OrderOption](orders) +} diff --git a/internal/mods/auth/dal/login.dal.go b/internal/mods/auth/dal/login.dal.go new file mode 100644 index 00000000..076121a7 --- /dev/null +++ b/internal/mods/auth/dal/login.dal.go @@ -0,0 +1,440 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "bytes" + "fmt" + "sync" + + kerr "github.com/go-kratos/kratos/v2/errors" + "github.com/origadmin/runtime/context" + jwtv1 "github.com/origadmin/runtime/gen/go/security/jwt/v1" + securityv1 "github.com/origadmin/runtime/gen/go/security/v1" + "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/crypto/hash" + "github.com/origadmin/toolkits/crypto/rand" + "github.com/origadmin/toolkits/errors/httperr" + + "origadmin/application/admin/internal/data/entity/ent/user" + + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/captcha" + "origadmin/application/admin/helpers/resp" + "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/mods/system/dto" + systemdto "origadmin/application/admin/internal/mods/system/dto" +) + +type loginRepo struct { + *LoginData + captcha *captcha.Captcha + bufpool *sync.Pool +} + +func (repo loginRepo) TokenRefresh(ctx context.Context, in *dto.TokenRefreshRequest) (*dto.TokenRefreshResponse, error) { + log.Debugf("Token refresh request received with data: %+v", in.GetData()) + return repo.refreshToken(ctx, in.GetData().GetRefreshToken()) +} + +func (repo loginRepo) Register(ctx context.Context, in *dto.RegisterRequest) (*dto.RegisterResponse, error) { + log.Debugf("Register request received with data: %+v", in.GetData()) + data := in.GetData() + var err error + createUser := new(dto.UserPB) + createUser, _, err = dto.MakeCreateUser(createUser, data.GetUsername(), data.GetPassword(), dto.UserMutationOption{}) + if err != nil { + return nil, err + } + if _, err := repo.User.Create(ctx, createUser); err != nil { + return nil, err + } + + return &dto.RegisterResponse{ + Success: true, + Data: &system.RegisterResponse_Data{ + Redirect: "", + }, + }, nil +} + +func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.LoginResponse, error) { + log.Debugf("Login request received with data: %+v", in.GetData()) + data := in.GetData() + + // verify captcha + log.Debugf("Verifying captcha with id %s and code %s", data.CaptchaId, data.CaptchaCode) + if !repo.captcha.Store.Verify(data.CaptchaId, data.CaptchaCode, true) { + log.Warnf("Invalid captcha id %s or code %s", data.CaptchaId, data.CaptchaCode) + return nil, dto.ErrInvalidCaptchaID + } + + if root := repo.rootUser(); root.GetEnabled() { + log.Debugf("Root userData is enabled, checking if username matches") + // login by root + username := root.Username + if data.Username == username { + log.Debugf("Username matches, checking password") + if err := hash.Verify(root.Password, data.Password); err != nil { + log.Warnf("Invalid password for root userData") + return nil, dto.ErrInvalidPassword + } + + userID := root.Id + ctx = context.NewID(ctx, root.Id) + log.Infof("Login by root successful, userData ID: %s", userID) + return repo.genToken(ctx, userID) + } + } + + // get user info + log.Debugf("Getting userData info for username %s", data.Username) + userData, err := repo.User.GetByUsername(ctx, data.Username, user.FieldID, user.FieldEncryptedPassword, user.FieldStatus) + if err != nil { + log.Errorf("Error getting userData info: %v", err) + return nil, err + } + switch { + case userData == nil: + log.Warnf("User not found with username %s", data.Username) + return nil, dto.ErrInvalidUsername + case userData.Status != systemdto.UserStatusActive: + log.Warnf("User %s is not activated", data.Username) + return nil, httperr.New("unknown", 400, "User status is not activated, please contact the administrator") + default: + log.Debugf("User found with ID %d and status %d", userData.Id, userData.Status) + } + + // check password + log.Debugf("Comparing password for userData %s", data.Username) + if err := hash.Verify(userData.EncryptedPassword, data.Password); err != nil { + log.Warnf("Invalid password for userData %s", data.Username) + return nil, dto.ErrInvalidPassword + } + + userUUID := userData.Uuid + username := userData.Username + ctx = context.NewID(ctx, userUUID) + + // set userData cache with role ids + log.Debugf("Getting role IDs for userData %s", username) + roleIDs, err := repo.User.GetRoleIDs(ctx, userData.Id) + if err != nil { + log.Errorf("Error getting role IDs: %v", err) + return nil, kerr.Newf(404, "UNKNOWN", "failed to get userData role ids: %v", err) + } + + log.Infof("User %s logged in successfully with role ids: %v", username, roleIDs) + // generate token + log.Debugf("Generating token for userData %s", username) + return repo.genToken(ctx, userUUID) +} +func (repo loginRepo) CaptchaAudio(ctx context.Context, id string, reload bool) (*dto.CaptchaAudioResponse, error) { + var err error + log.Debugf("Generating captcha audio with id %s and reload %v", id, reload) + if reload && !repo.captcha.Reload(captcha.TypeAudio, id) { + log.Warnf("Captcha id %s not found during reload, regenerating", id) + id, err = repo.getCaptchaID() + if err != nil { + return nil, err + } + } + content := repo.captcha.Store.Get(id, false) + item, err := repo.captcha.DriverAudio.Driver.DrawCaptcha(content) + if err != nil { + return nil, err + } + buf := repo.getBuf() + _, err = item.WriteTo(buf) + if err != nil { + return nil, err + } + response := new(dto.CaptchaAudioResponse) + response.Headers = map[string]string{ + "Cache-Control": "no-cache, no-store, must-revalidate", + "Pragma": "no-cache", + "Expires": "0", + "Content-Type": captcha.MimeTypeAudio, + } + response.Audio = buf.Bytes() + return response, nil +} + +func (repo loginRepo) CaptchaImage(ctx context.Context, id string, reload bool) (*dto.CaptchaImageResponse, error) { + log.Debugf("Generating captcha image with id %s and reload %v", id, reload) + var err error + if reload && !repo.captcha.Reload(captcha.TypeDigit, id) { + log.Warnf("Captcha id %s not found during reload, regenerating", id) + id, err = repo.getCaptchaID() + if err != nil { + return nil, err + } + } + content := repo.captcha.Store.Get(id, false) + item, err := repo.captcha.DriverDigit.Driver.DrawCaptcha(content) + if err != nil { + return nil, err + } + buf := repo.getBuf() + _, err = item.WriteTo(buf) + if err != nil { + return nil, err + } + log.Debugf("Captcha image generated successfully") + response := new(dto.CaptchaImageResponse) + response.Headers = map[string]string{ + "Cache-Control": "no-cache, no-store, must-revalidate", + "Pragma": "no-cache", + "Expires": "0", + "Content-Type": captcha.MimeTypeImage, + } + response.Image = buf.Bytes() + log.Debugf("Returning captcha image response with headers: %+v", response.Headers) + return response, nil +} + +func (repo loginRepo) CurrentUser(ctx context.Context, in *dto.CurrentUserRequest) (*dto.CurrentUserResponse, error) { + current, err := repo.User.Current(ctx, in.GetData().GetUserId()) + if err != nil { + return nil, err + } + return &dto.CurrentUserResponse{ + Data: resp.Any(current), + }, nil +} + +func (repo loginRepo) Logout(ctx context.Context, in *dto.LogoutRequest) (*dto.LogoutResponse, error) { + return &dto.LogoutResponse{}, nil +} + +func (repo loginRepo) CaptchaID(ctx context.Context, in *dto.CaptchaIDRequest) (*dto.CaptchaIDResponse, error) { + id, err := repo.getCaptchaID() + if err != nil { + return nil, err + } + return &dto.CaptchaIDResponse{ + Data: id, + }, nil +} + +func (repo loginRepo) Captcha(ctx context.Context, in *dto.CaptchaRequest) (*dto.CaptchaResponse, error) { + var err error + var id = in.Id + if id == "" { + id, err = repo.getCaptchaID() + if err != nil { + return nil, err + } + } + driver, err := repo.getCaptchaDriver(in.Type) + if err != nil { + return nil, err + } + if in.Reload && in.Id != "" && !repo.captcha.Reload(in.Type, in.Id) { + log.Warnf("Captcha id %s not found during reload, regenerating id", id) + id, err = repo.getCaptchaID() + if err != nil { + return nil, err + } + } + data, err := repo.getCaptchaData(driver, id) + if err != nil { + return nil, err + } + return &dto.CaptchaResponse{ + Id: id, + Type: in.Type, + Data: data, + }, nil +} + +func (repo loginRepo) getCaptchaID() (string, error) { + id, _, answ, err := repo.captcha.DriverDigit.Generate() + if err != nil { + return "", err + } + log.Debugf("Generated captcha with id %s and answer %s", id, answ) + return id, nil +} + +func (repo loginRepo) FreeBuf(buf *bytes.Buffer) { + repo.putBuf(buf) +} + +func (repo loginRepo) getBuf() *bytes.Buffer { + return repo.bufpool.Get().(*bytes.Buffer) +} + +func (repo loginRepo) putBuf(buf *bytes.Buffer) { + buf.Reset() + repo.bufpool.Put(buf) +} + +func (repo loginRepo) refreshToken(ctx context.Context, token string) (*dto.TokenRefreshResponse, error) { + claims, err := repo.Tokenizer.ParseClaims(ctx, token) + if err != nil { + return nil, err + } + genToken, err := repo.genToken(ctx, claims.GetSubject()) + if err != nil { + return nil, err + } + return &dto.TokenRefreshResponse{ + Token: genToken.Token, + }, nil +} + +func (repo loginRepo) genToken(ctx context.Context, id string) (*dto.LoginResponse, error) { + claims, err := repo.Tokenizer.CreateClaims(ctx, id) + if err != nil { + return nil, err + } + token, err := repo.Tokenizer.CreateToken(ctx, claims) + if err != nil { + return nil, err + } + refreshClaims, err := repo.Tokenizer.CreateRefreshClaims(ctx, id) + if err != nil { + return nil, err + } + refreshToken, err := repo.Tokenizer.CreateToken(ctx, refreshClaims) + if err != nil { + return nil, err + } + return &dto.LoginResponse{ + Token: &jwtv1.Token{ + UserId: id, + AccessToken: token, + RefreshToken: refreshToken, + ExpirationTime: claims.GetExpiration(), + }, + }, nil +} + +func fromSecurityClaims(claims security.Claims) *securityv1.Claims { + return &securityv1.Claims{ + Sub: claims.GetSubject(), + Iss: claims.GetIssuer(), + Aud: claims.GetAudience(), + Exp: claims.GetExpiration(), + Nbf: claims.GetNotBefore(), + Iat: claims.GetIssuedAt(), + Jti: claims.GetID(), + Scopes: claims.GetScopes(), + } +} + +func RefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { + if rt, ok := tokenizer.(security.RefreshTokenizer); ok { + return rt + } + return wrapRefreshTokenizer(tokenizer) +} + +func (repo loginRepo) rootUser() *configs.RootUser { + return repo.LoginData.RootUser +} + +func (repo loginRepo) getCaptchaDriver(typ string) (captcha.Driver, error) { + var driver captcha.Driver + switch typ { + case captcha.TypeAudio: + driver = repo.captcha.DriverAudio.Driver + default: + driver = repo.captcha.DriverDigit.Driver + } + log.Debugf("Captcha audio generated successfully") + return driver, nil +} + +func (repo loginRepo) getCaptchaData(driver captcha.Driver, id string) (string, error) { + content := repo.captcha.Store.Get(id, false) + item, err := driver.DrawCaptcha(content) + if err != nil { + return "", err + } + return item.EncodeB64string(), nil +} + +func (repo loginRepo) getCaptchaAudio(id string) (string, error) { + log.Debugf("Writing captcha audio to buffer with id %s", id) + content := repo.captcha.Store.Get(id, false) + item, err := repo.captcha.DriverAudio.Driver.DrawCaptcha(content) + if err != nil { + return "", err + } + log.Debugf("Captcha audio generated successfully") + return item.EncodeB64string(), nil +} + +func (repo loginRepo) getCaptchaImage(id string) (string, error) { + log.Debugf("Writing captcha image to buffer with id %s", id) + content := repo.captcha.Store.Get(id, false) + item, err := repo.captcha.DriverDigit.Driver.DrawCaptcha(content) + if err != nil { + return "", err + } + log.Debugf("Captcha image generated successfully") + return item.EncodeB64string(), nil +} + +type LoginData struct { + Captcha *configs.Captcha + RootUser *configs.RootUser + Tokenizer security.RefreshTokenizer + Resource systemdto.ResourceRepo + Role systemdto.RoleRepo + User systemdto.UserRepo +} + +func NewCaptcha(cfg *configs.Captcha) *captcha.Captcha { + return captcha.NewCaptcha(&captcha.Config{ + DriverDigit: &captcha.DriverDigit{ + Height: int(cfg.Height), + Width: int(cfg.Width), + Length: int(cfg.Length), + MaxSkew: 0.7, + DotCount: 120, + }, + }) +} + +// NewLoginRepo . +func NewLoginRepo(data *LoginData, logger log.KLogger) dto.LoginRepo { + var err error + cfg := data.RootUser + // todo: generate random password for root user if not exists + if cfg.RandomPassword { + passwd := rand.GenerateRandom(12) + cfg.Password, err = hash.Generate(passwd) + if err == nil { + fmt.Println("Root user password:", passwd) + } else { + log.Errorf("Error generating password: %v", err) + cfg.RandomPassword = false + } + } + if cfg.Id == "" { + cfg.Id = cfg.Username + } + //authenticator, err := jwt.NewAuthenticator(&configv1.Security{}) + //if err != nil { + // panic(err) + //} + return &loginRepo{ + bufpool: BufPool(), + LoginData: data, + captcha: NewCaptcha(data.Captcha), + } +} + +func BufPool() *sync.Pool { + return &sync.Pool{ + New: func() interface{} { + return &bytes.Buffer{} + }, + } +} diff --git a/internal/mods/casbin/dal/dal.go b/internal/mods/casbin/dal/dal.go deleted file mode 100644 index 0b1e264e..00000000 --- a/internal/mods/casbin/dal/dal.go +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package entity implements the functions, types, and interfaces for the module. -package dal - -import ( - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent" -) - -type Data struct { - *ent.Database -} - -func NewDataWithClient(client *ent.Client) *Data { - return &Data{ - Database: ent.NewDatabase(client), - } -} diff --git a/internal/mods/casbin/dal/entity/ent/client.go b/internal/mods/casbin/dal/entity/ent/client.go deleted file mode 100644 index 99e7f8f4..00000000 --- a/internal/mods/casbin/dal/entity/ent/client.go +++ /dev/null @@ -1,341 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "log" - "reflect" - - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/migrate" - - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" -) - -// Client is the client that holds all ent builders. -type Client struct { - config - // Schema is the client for creating, migrating and dropping schema. - Schema *migrate.Schema - // CasbinRule is the client for interacting with the CasbinRule builders. - CasbinRule *CasbinRuleClient -} - -// NewClient creates a new client configured with the given options. -func NewClient(opts ...Option) *Client { - client := &Client{config: newConfig(opts...)} - client.init() - return client -} - -func (c *Client) init() { - c.Schema = migrate.NewSchema(c.driver) - c.CasbinRule = NewCasbinRuleClient(c.config) -} - -type ( - // config is the configuration for the client and its builder. - config struct { - // driver used for executing database requests. - driver dialect.Driver - // debug enable a debug logging. - debug bool - // log used for logging on debug mode. - log func(...any) - // hooks to execute on mutations. - hooks *hooks - // interceptors to execute on queries. - inters *inters - } - // Option function to configure the client. - Option func(*config) -) - -// newConfig creates a new config for the client. -func newConfig(opts ...Option) config { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - return cfg -} - -// options applies the options on the config object. -func (c *config) options(opts ...Option) { - for _, opt := range opts { - opt(c) - } - if c.debug { - c.driver = dialect.Debug(c.driver, c.log) - } -} - -// Debug enables debug logging on the ent.Driver. -func Debug() Option { - return func(c *config) { - c.debug = true - } -} - -// Log sets the logging function for debug mode. -func Log(fn func(...any)) Option { - return func(c *config) { - c.log = fn - } -} - -// Driver configures the client driver. -func Driver(driver dialect.Driver) Option { - return func(c *config) { - c.driver = driver - } -} - -// Open opens a database/sql.DB specified by the driver name and -// the data source name, and returns a new client attached to it. -// Optional parameters can be added for configuring the client. -func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { - switch driverName { - case dialect.MySQL, dialect.Postgres, dialect.SQLite: - drv, err := sql.Open(driverName, dataSourceName) - if err != nil { - return nil, err - } - return NewClient(append(options, Driver(drv))...), nil - default: - return nil, fmt.Errorf("unsupported driver: %q", driverName) - } -} - -// ErrTxStarted is returned when trying to start a new transaction from a transactional client. -var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") - -// Tx returns a new transactional client. The provided context -// is used until the transaction is committed or rolled back. -func (c *Client) Tx(ctx context.Context) (*Tx, error) { - if _, ok := c.driver.(*txDriver); ok { - return nil, ErrTxStarted - } - tx, err := newTx(ctx, c.driver) - if err != nil { - return nil, fmt.Errorf("ent: starting a transaction: %w", err) - } - cfg := c.config - cfg.driver = tx - return &Tx{ - ctx: ctx, - config: cfg, - CasbinRule: NewCasbinRuleClient(cfg), - }, nil -} - -// BeginTx returns a transactional client with specified options. -func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { - if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") - } - tx, err := c.driver.(interface { - BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) - }).BeginTx(ctx, opts) - if err != nil { - return nil, fmt.Errorf("ent: starting a transaction: %w", err) - } - cfg := c.config - cfg.driver = &txDriver{tx: tx, drv: c.driver} - return &Tx{ - ctx: ctx, - config: cfg, - CasbinRule: NewCasbinRuleClient(cfg), - }, nil -} - -// Debug returns a new debug-client. It's used to get verbose logging on specific operations. -// -// client.Debug(). -// CasbinRule. -// Query(). -// Count(ctx) -func (c *Client) Debug() *Client { - if c.debug { - return c - } - cfg := c.config - cfg.driver = dialect.Debug(c.driver, c.log) - client := &Client{config: cfg} - client.init() - return client -} - -// Close closes the database connection and prevents new queries from starting. -func (c *Client) Close() error { - return c.driver.Close() -} - -// Use adds the mutation hooks to all the entity clients. -// In order to add hooks to a specific client, call: `client.Node.Use(...)`. -func (c *Client) Use(hooks ...Hook) { - c.CasbinRule.Use(hooks...) -} - -// Intercept adds the query interceptors to all the entity clients. -// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. -func (c *Client) Intercept(interceptors ...Interceptor) { - c.CasbinRule.Intercept(interceptors...) -} - -// Mutate implements the ent.Mutator interface. -func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { - switch m := m.(type) { - case *CasbinRuleMutation: - return c.CasbinRule.mutate(ctx, m) - default: - return nil, fmt.Errorf("ent: unknown mutation type %T", m) - } -} - -// CasbinRuleClient is a client for the CasbinRule schema. -type CasbinRuleClient struct { - config -} - -// NewCasbinRuleClient returns a client for the CasbinRule from the given config. -func NewCasbinRuleClient(c config) *CasbinRuleClient { - return &CasbinRuleClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `casbinrule.Hooks(f(g(h())))`. -func (c *CasbinRuleClient) Use(hooks ...Hook) { - c.hooks.CasbinRule = append(c.hooks.CasbinRule, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `casbinrule.Intercept(f(g(h())))`. -func (c *CasbinRuleClient) Intercept(interceptors ...Interceptor) { - c.inters.CasbinRule = append(c.inters.CasbinRule, interceptors...) -} - -// Create returns a builder for creating a CasbinRule entity. -func (c *CasbinRuleClient) Create() *CasbinRuleCreate { - mutation := newCasbinRuleMutation(c.config, OpCreate) - return &CasbinRuleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of CasbinRule entities. -func (c *CasbinRuleClient) CreateBulk(builders ...*CasbinRuleCreate) *CasbinRuleCreateBulk { - return &CasbinRuleCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *CasbinRuleClient) MapCreateBulk(slice any, setFunc func(*CasbinRuleCreate, int)) *CasbinRuleCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &CasbinRuleCreateBulk{err: fmt.Errorf("calling to CasbinRuleClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*CasbinRuleCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &CasbinRuleCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for CasbinRule. -func (c *CasbinRuleClient) Update() *CasbinRuleUpdate { - mutation := newCasbinRuleMutation(c.config, OpUpdate) - return &CasbinRuleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *CasbinRuleClient) UpdateOne(cr *CasbinRule) *CasbinRuleUpdateOne { - mutation := newCasbinRuleMutation(c.config, OpUpdateOne, withCasbinRule(cr)) - return &CasbinRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *CasbinRuleClient) UpdateOneID(id int) *CasbinRuleUpdateOne { - mutation := newCasbinRuleMutation(c.config, OpUpdateOne, withCasbinRuleID(id)) - return &CasbinRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for CasbinRule. -func (c *CasbinRuleClient) Delete() *CasbinRuleDelete { - mutation := newCasbinRuleMutation(c.config, OpDelete) - return &CasbinRuleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *CasbinRuleClient) DeleteOne(cr *CasbinRule) *CasbinRuleDeleteOne { - return c.DeleteOneID(cr.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *CasbinRuleClient) DeleteOneID(id int) *CasbinRuleDeleteOne { - builder := c.Delete().Where(casbinrule.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &CasbinRuleDeleteOne{builder} -} - -// Query returns a query builder for CasbinRule. -func (c *CasbinRuleClient) Query() *CasbinRuleQuery { - return &CasbinRuleQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeCasbinRule}, - inters: c.Interceptors(), - } -} - -// Get returns a CasbinRule entity by its id. -func (c *CasbinRuleClient) Get(ctx context.Context, id int) (*CasbinRule, error) { - return c.Query().Where(casbinrule.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *CasbinRuleClient) GetX(ctx context.Context, id int) *CasbinRule { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// Hooks returns the client hooks. -func (c *CasbinRuleClient) Hooks() []Hook { - return c.hooks.CasbinRule -} - -// Interceptors returns the client interceptors. -func (c *CasbinRuleClient) Interceptors() []Interceptor { - return c.inters.CasbinRule -} - -func (c *CasbinRuleClient) mutate(ctx context.Context, m *CasbinRuleMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&CasbinRuleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&CasbinRuleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&CasbinRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&CasbinRuleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown CasbinRule mutation op: %q", m.Op()) - } -} - -// hooks and interceptors per client, for fast access. -type ( - hooks struct { - CasbinRule []ent.Hook - } - inters struct { - CasbinRule []ent.Interceptor - } -) diff --git a/internal/mods/casbin/dal/entity/ent/database.go b/internal/mods/casbin/dal/entity/ent/database.go deleted file mode 100644 index 26903f60..00000000 --- a/internal/mods/casbin/dal/entity/ent/database.go +++ /dev/null @@ -1,108 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -/* Additional dependencies injected to config. */ - -import ( - "context" - "fmt" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime/interfaces/database" -) - -// Database is the client that holds all ent builders. -type Database struct { - client *Client -} - -// NewDatabase creates a new database configured with the given options. -func NewDatabase(client *Client, opts ...Option) *Database { - if client == nil { - client = NewClient(opts...) - } - return &Database{client: client} -} - -func (db *Database) clientDriver(ctx context.Context) dialect.Driver { - tx := TxFromContext(ctx) - c := db.client - if tx != nil { - c = tx.Client() - } - return c.driver -} - -// Tx runs the given function f within a transaction. -func (db *Database) Tx(ctx context.Context, fn func(context.Context) error) error { - tx := TxFromContext(ctx) - if tx != nil { - return fn(ctx) - } - - return db.InTx(ctx, func(tx database.Tx) error { - txv, ok := tx.(*Tx) - if !ok { - return fmt.Errorf("ent: expected tx context") - } - return fn(NewTxContext(ctx, txv)) - }) -} - -// InTx runs the given function f within a transaction. -func (db *Database) InTx(ctx context.Context, fn func(tx database.Tx) error) error { - tx := TxFromContext(ctx) - if tx != nil { - return fn(tx) - } - tx, err := db.client.Tx(ctx) - if err != nil { - return fmt.Errorf("starting transaction: %w", err) - } - if err = fn(tx); err != nil { - if txerr := tx.Rollback(); txerr != nil { - return fmt.Errorf("rolling back transaction: %v (original error: %w)", txerr, err) - } - return err - } - if err := tx.Commit(); err != nil { - return fmt.Errorf("committing transaction: %w", err) - } - return nil -} - -// Client returns the client that holds all ent builders. -func (db *Database) Client(ctx context.Context) *Client { - tx := TxFromContext(ctx) - if tx != nil { - return tx.Client() - } - return db.client -} - -// Exec executes a query that doesn't return rows. For example, in SQL, INSERT or UPDATE. -func (db *Database) Exec(ctx context.Context, query string, args ...interface{}) (*sql.Result, error) { - var res sql.Result - err := db.clientDriver(ctx).Exec(ctx, query, args, &res) - if err != nil { - return nil, err - } - return &res, nil -} - -// Query executes a query that returns rows, typically a SELECT in SQL. -func (db *Database) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) { - var rows sql.Rows - err := db.clientDriver(ctx).Query(ctx, query, args, &rows) - if err != nil { - return nil, err - } - return &rows, nil -} - -// CasbinRule is the client for interacting with the CasbinRule builders. -func (db *Database) CasbinRule(ctx context.Context) *CasbinRuleClient { - return db.Client(ctx).CasbinRule -} diff --git a/internal/mods/casbin/dal/entity/ent/ent.go b/internal/mods/casbin/dal/entity/ent/ent.go deleted file mode 100644 index fb1d014a..00000000 --- a/internal/mods/casbin/dal/entity/ent/ent.go +++ /dev/null @@ -1,608 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" - "reflect" - "sync" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ent aliases to avoid import conflicts in user's code. -type ( - Op = ent.Op - Hook = ent.Hook - Value = ent.Value - Query = ent.Query - QueryContext = ent.QueryContext - Querier = ent.Querier - QuerierFunc = ent.QuerierFunc - Interceptor = ent.Interceptor - InterceptFunc = ent.InterceptFunc - Traverser = ent.Traverser - TraverseFunc = ent.TraverseFunc - Policy = ent.Policy - Mutator = ent.Mutator - Mutation = ent.Mutation - MutateFunc = ent.MutateFunc -) - -type clientCtxKey struct{} - -// FromContext returns a Client stored inside a context, or nil if there isn't one. -func FromContext(ctx context.Context) *Client { - c, _ := ctx.Value(clientCtxKey{}).(*Client) - return c -} - -// NewContext returns a new context with the given Client attached. -func NewContext(parent context.Context, c *Client) context.Context { - return context.WithValue(parent, clientCtxKey{}, c) -} - -type txCtxKey struct{} - -// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. -func TxFromContext(ctx context.Context) *Tx { - tx, _ := ctx.Value(txCtxKey{}).(*Tx) - return tx -} - -// NewTxContext returns a new context with the given Tx attached. -func NewTxContext(parent context.Context, tx *Tx) context.Context { - return context.WithValue(parent, txCtxKey{}, tx) -} - -// OrderFunc applies an ordering on the sql selector. -// Deprecated: Use Asc/Desc functions or the package builders instead. -type OrderFunc func(*sql.Selector) - -var ( - initCheck sync.Once - columnCheck sql.ColumnCheck -) - -// checkColumn checks if the column exists in the given table. -func checkColumn(table, column string) error { - initCheck.Do(func() { - columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ - casbinrule.Table: casbinrule.ValidColumn, - }) - }) - return columnCheck(table, column) -} - -// Asc applies the given fields in ASC order. -func Asc(fields ...string) func(*sql.Selector) { - return func(s *sql.Selector) { - for _, f := range fields { - if err := checkColumn(s.TableName(), f); err != nil { - s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) - } - s.OrderBy(sql.Asc(s.C(f))) - } - } -} - -// Desc applies the given fields in DESC order. -func Desc(fields ...string) func(*sql.Selector) { - return func(s *sql.Selector) { - for _, f := range fields { - if err := checkColumn(s.TableName(), f); err != nil { - s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) - } - s.OrderBy(sql.Desc(s.C(f))) - } - } -} - -// AggregateFunc applies an aggregation step on the group-by traversal/selector. -type AggregateFunc func(*sql.Selector) string - -// As is a pseudo aggregation function for renaming another other functions with custom names. For example: -// -// GroupBy(field1, field2). -// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). -// Scan(ctx, &v) -func As(fn AggregateFunc, end string) AggregateFunc { - return func(s *sql.Selector) string { - return sql.As(fn(s), end) - } -} - -// Count applies the "count" aggregation function on each group. -func Count() AggregateFunc { - return func(s *sql.Selector) string { - return sql.Count("*") - } -} - -// Max applies the "max" aggregation function on the given field of each group. -func Max(field string) AggregateFunc { - return func(s *sql.Selector) string { - if err := checkColumn(s.TableName(), field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Max(s.C(field)) - } -} - -// Mean applies the "mean" aggregation function on the given field of each group. -func Mean(field string) AggregateFunc { - return func(s *sql.Selector) string { - if err := checkColumn(s.TableName(), field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Avg(s.C(field)) - } -} - -// Min applies the "min" aggregation function on the given field of each group. -func Min(field string) AggregateFunc { - return func(s *sql.Selector) string { - if err := checkColumn(s.TableName(), field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Min(s.C(field)) - } -} - -// Sum applies the "sum" aggregation function on the given field of each group. -func Sum(field string) AggregateFunc { - return func(s *sql.Selector) string { - if err := checkColumn(s.TableName(), field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Sum(s.C(field)) - } -} - -// ValidationError returns when validating a field or edge fails. -type ValidationError struct { - Name string // Field or edge name. - err error -} - -// Error implements the error interface. -func (e *ValidationError) Error() string { - return e.err.Error() -} - -// Unwrap implements the errors.Wrapper interface. -func (e *ValidationError) Unwrap() error { - return e.err -} - -// IsValidationError returns a boolean indicating whether the error is a validation error. -func IsValidationError(err error) bool { - if err == nil { - return false - } - var e *ValidationError - return errors.As(err, &e) -} - -// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. -type NotFoundError struct { - label string -} - -// Error implements the error interface. -func (e *NotFoundError) Error() string { - return "ent: " + e.label + " not found" -} - -// IsNotFound returns a boolean indicating whether the error is a not found error. -func IsNotFound(err error) bool { - if err == nil { - return false - } - var e *NotFoundError - return errors.As(err, &e) -} - -// MaskNotFound masks not found error. -func MaskNotFound(err error) error { - if IsNotFound(err) { - return nil - } - return err -} - -// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. -type NotSingularError struct { - label string -} - -// Error implements the error interface. -func (e *NotSingularError) Error() string { - return "ent: " + e.label + " not singular" -} - -// IsNotSingular returns a boolean indicating whether the error is a not singular error. -func IsNotSingular(err error) bool { - if err == nil { - return false - } - var e *NotSingularError - return errors.As(err, &e) -} - -// NotLoadedError returns when trying to get a node that was not loaded by the query. -type NotLoadedError struct { - edge string -} - -// Error implements the error interface. -func (e *NotLoadedError) Error() string { - return "ent: " + e.edge + " edge was not loaded" -} - -// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. -func IsNotLoaded(err error) bool { - if err == nil { - return false - } - var e *NotLoadedError - return errors.As(err, &e) -} - -// ConstraintError returns when trying to create/update one or more entities and -// one or more of their constraints failed. For example, violation of edge or -// field uniqueness. -type ConstraintError struct { - msg string - wrap error -} - -// Error implements the error interface. -func (e ConstraintError) Error() string { - return "ent: constraint failed: " + e.msg -} - -// Unwrap implements the errors.Wrapper interface. -func (e *ConstraintError) Unwrap() error { - return e.wrap -} - -// IsConstraintError returns a boolean indicating whether the error is a constraint failure. -func IsConstraintError(err error) bool { - if err == nil { - return false - } - var e *ConstraintError - return errors.As(err, &e) -} - -// selector embedded by the different Select/GroupBy builders. -type selector struct { - label string - flds *[]string - fns []AggregateFunc - scan func(context.Context, any) error -} - -// ScanX is like Scan, but panics if an error occurs. -func (s *selector) ScanX(ctx context.Context, v any) { - if err := s.scan(ctx, v); err != nil { - panic(err) - } -} - -// Strings returns list of strings from a selector. It is only allowed when selecting one field. -func (s *selector) Strings(ctx context.Context) ([]string, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") - } - var v []string - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// StringsX is like Strings, but panics if an error occurs. -func (s *selector) StringsX(ctx context.Context) []string { - v, err := s.Strings(ctx) - if err != nil { - panic(err) - } - return v -} - -// String returns a single string from a selector. It is only allowed when selecting one field. -func (s *selector) String(ctx context.Context) (_ string, err error) { - var v []string - if v, err = s.Strings(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) - } - return -} - -// StringX is like String, but panics if an error occurs. -func (s *selector) StringX(ctx context.Context) string { - v, err := s.String(ctx) - if err != nil { - panic(err) - } - return v -} - -// Ints returns list of ints from a selector. It is only allowed when selecting one field. -func (s *selector) Ints(ctx context.Context) ([]int, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") - } - var v []int - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// IntsX is like Ints, but panics if an error occurs. -func (s *selector) IntsX(ctx context.Context) []int { - v, err := s.Ints(ctx) - if err != nil { - panic(err) - } - return v -} - -// Int returns a single int from a selector. It is only allowed when selecting one field. -func (s *selector) Int(ctx context.Context) (_ int, err error) { - var v []int - if v, err = s.Ints(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) - } - return -} - -// IntX is like Int, but panics if an error occurs. -func (s *selector) IntX(ctx context.Context) int { - v, err := s.Int(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. -func (s *selector) Float64s(ctx context.Context) ([]float64, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") - } - var v []float64 - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// Float64sX is like Float64s, but panics if an error occurs. -func (s *selector) Float64sX(ctx context.Context) []float64 { - v, err := s.Float64s(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. -func (s *selector) Float64(ctx context.Context) (_ float64, err error) { - var v []float64 - if v, err = s.Float64s(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) - } - return -} - -// Float64X is like Float64, but panics if an error occurs. -func (s *selector) Float64X(ctx context.Context) float64 { - v, err := s.Float64(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bools returns list of bools from a selector. It is only allowed when selecting one field. -func (s *selector) Bools(ctx context.Context) ([]bool, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") - } - var v []bool - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// BoolsX is like Bools, but panics if an error occurs. -func (s *selector) BoolsX(ctx context.Context) []bool { - v, err := s.Bools(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bool returns a single bool from a selector. It is only allowed when selecting one field. -func (s *selector) Bool(ctx context.Context) (_ bool, err error) { - var v []bool - if v, err = s.Bools(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) - } - return -} - -// BoolX is like Bool, but panics if an error occurs. -func (s *selector) BoolX(ctx context.Context) bool { - v, err := s.Bool(ctx) - if err != nil { - panic(err) - } - return v -} - -// withHooks invokes the builder operation with the given hooks, if any. -func withHooks[V Value, M any, PM interface { - *M - Mutation -}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { - if len(hooks) == 0 { - return exec(ctx) - } - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutationT, ok := any(m).(PM) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - // Set the mutation to the builder. - *mutation = *mutationT - return exec(ctx) - }) - for i := len(hooks) - 1; i >= 0; i-- { - if hooks[i] == nil { - return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = hooks[i](mut) - } - v, err := mut.Mutate(ctx, mutation) - if err != nil { - return value, err - } - nv, ok := v.(V) - if !ok { - return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) - } - return nv, nil -} - -// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. -func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { - if ent.QueryFromContext(ctx) == nil { - qc.Op = op - ctx = ent.NewQueryContext(ctx, qc) - } - return ctx -} - -func querierAll[V Value, Q interface { - sqlAll(context.Context, ...queryHook) (V, error) -}]() Querier { - return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - query, ok := q.(Q) - if !ok { - return nil, fmt.Errorf("unexpected query type %T", q) - } - return query.sqlAll(ctx) - }) -} - -func querierCount[Q interface { - sqlCount(context.Context) (int, error) -}]() Querier { - return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - query, ok := q.(Q) - if !ok { - return nil, fmt.Errorf("unexpected query type %T", q) - } - return query.sqlCount(ctx) - }) -} - -func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { - for i := len(inters) - 1; i >= 0; i-- { - qr = inters[i].Intercept(qr) - } - rv, err := qr.Query(ctx, q) - if err != nil { - return v, err - } - vt, ok := rv.(V) - if !ok { - return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) - } - return vt, nil -} - -func scanWithInterceptors[Q1 ent.Query, Q2 interface { - sqlScan(context.Context, Q1, any) error -}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { - rv := reflect.ValueOf(v) - var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - query, ok := q.(Q1) - if !ok { - return nil, fmt.Errorf("unexpected query type %T", q) - } - if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { - return nil, err - } - if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { - return rv.Elem().Interface(), nil - } - return v, nil - }) - for i := len(inters) - 1; i >= 0; i-- { - qr = inters[i].Intercept(qr) - } - vv, err := qr.Query(ctx, rootQuery) - if err != nil { - return err - } - switch rv2 := reflect.ValueOf(vv); { - case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: - case rv.Type() == rv2.Type(): - rv.Elem().Set(rv2.Elem()) - case rv.Elem().Type() == rv2.Type(): - rv.Elem().Set(rv2) - } - return nil -} - -// queryHook describes an internal hook for the different sqlAll methods. -type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/internal/mods/casbin/dal/entity/ent/enttest/enttest.go b/internal/mods/casbin/dal/entity/ent/enttest/enttest.go deleted file mode 100644 index f725836c..00000000 --- a/internal/mods/casbin/dal/entity/ent/enttest/enttest.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package enttest - -import ( - "context" - - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent" - // required by schema hooks. - _ "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/runtime" - - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/migrate" - - "entgo.io/ent/dialect/sql/schema" -) - -type ( - // TestingT is the interface that is shared between - // testing.T and testing.B and used by enttest. - TestingT interface { - FailNow() - Error(...any) - } - - // Option configures client creation. - Option func(*options) - - options struct { - opts []ent.Option - migrateOpts []schema.MigrateOption - } -) - -// WithOptions forwards options to client creation. -func WithOptions(opts ...ent.Option) Option { - return func(o *options) { - o.opts = append(o.opts, opts...) - } -} - -// WithMigrateOptions forwards options to auto migration. -func WithMigrateOptions(opts ...schema.MigrateOption) Option { - return func(o *options) { - o.migrateOpts = append(o.migrateOpts, opts...) - } -} - -func newOptions(opts []Option) *options { - o := &options{} - for _, opt := range opts { - opt(o) - } - return o -} - -// Open calls ent.Open and auto-run migration. -func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { - o := newOptions(opts) - c, err := ent.Open(driverName, dataSourceName, o.opts...) - if err != nil { - t.Error(err) - t.FailNow() - } - migrateSchema(t, c, o) - return c -} - -// NewClient calls ent.NewClient and auto-run migration. -func NewClient(t TestingT, opts ...Option) *ent.Client { - o := newOptions(opts) - c := ent.NewClient(o.opts...) - migrateSchema(t, c, o) - return c -} -func migrateSchema(t TestingT, c *ent.Client, o *options) { - tables, err := schema.CopyTables(migrate.Tables) - if err != nil { - t.Error(err) - t.FailNow() - } - if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { - t.Error(err) - t.FailNow() - } -} diff --git a/internal/mods/casbin/dal/entity/ent/generate.go b/internal/mods/casbin/dal/entity/ent/generate.go deleted file mode 100644 index 570bd0ed..00000000 --- a/internal/mods/casbin/dal/entity/ent/generate.go +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package ent is the data access object for SYS. -package ent - -//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --template ./template --feature intercept --feature schema/snapshot --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema diff --git a/internal/mods/casbin/dal/entity/ent/hook/hook.go b/internal/mods/casbin/dal/entity/ent/hook/hook.go deleted file mode 100644 index 5ca0f0d7..00000000 --- a/internal/mods/casbin/dal/entity/ent/hook/hook.go +++ /dev/null @@ -1,198 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package hook - -import ( - "context" - "fmt" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent" -) - -// The CasbinRuleFunc type is an adapter to allow the use of ordinary -// function as CasbinRule mutator. -type CasbinRuleFunc func(context.Context, *ent.CasbinRuleMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f CasbinRuleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.CasbinRuleMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.CasbinRuleMutation", m) -} - -// Condition is a hook condition function. -type Condition func(context.Context, ent.Mutation) bool - -// And groups conditions with the AND operator. -func And(first, second Condition, rest ...Condition) Condition { - return func(ctx context.Context, m ent.Mutation) bool { - if !first(ctx, m) || !second(ctx, m) { - return false - } - for _, cond := range rest { - if !cond(ctx, m) { - return false - } - } - return true - } -} - -// Or groups conditions with the OR operator. -func Or(first, second Condition, rest ...Condition) Condition { - return func(ctx context.Context, m ent.Mutation) bool { - if first(ctx, m) || second(ctx, m) { - return true - } - for _, cond := range rest { - if cond(ctx, m) { - return true - } - } - return false - } -} - -// Not negates a given condition. -func Not(cond Condition) Condition { - return func(ctx context.Context, m ent.Mutation) bool { - return !cond(ctx, m) - } -} - -// HasOp is a condition testing mutation operation. -func HasOp(op ent.Op) Condition { - return func(_ context.Context, m ent.Mutation) bool { - return m.Op().Is(op) - } -} - -// HasAddedFields is a condition validating `.AddedField` on fields. -func HasAddedFields(field string, fields ...string) Condition { - return func(_ context.Context, m ent.Mutation) bool { - if _, exists := m.AddedField(field); !exists { - return false - } - for _, field := range fields { - if _, exists := m.AddedField(field); !exists { - return false - } - } - return true - } -} - -// HasClearedFields is a condition validating `.FieldCleared` on fields. -func HasClearedFields(field string, fields ...string) Condition { - return func(_ context.Context, m ent.Mutation) bool { - if exists := m.FieldCleared(field); !exists { - return false - } - for _, field := range fields { - if exists := m.FieldCleared(field); !exists { - return false - } - } - return true - } -} - -// HasFields is a condition validating `.Field` on fields. -func HasFields(field string, fields ...string) Condition { - return func(_ context.Context, m ent.Mutation) bool { - if _, exists := m.Field(field); !exists { - return false - } - for _, field := range fields { - if _, exists := m.Field(field); !exists { - return false - } - } - return true - } -} - -// If executes the given hook under condition. -// -// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) -func If(hk ent.Hook, cond Condition) ent.Hook { - return func(next ent.Mutator) ent.Mutator { - return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if cond(ctx, m) { - return hk(next).Mutate(ctx, m) - } - return next.Mutate(ctx, m) - }) - } -} - -// On executes the given hook only for the given operation. -// -// hook.On(Log, ent.Delete|ent.Create) -func On(hk ent.Hook, op ent.Op) ent.Hook { - return If(hk, HasOp(op)) -} - -// Unless skips the given hook only for the given operation. -// -// hook.Unless(Log, ent.Update|ent.UpdateOne) -func Unless(hk ent.Hook, op ent.Op) ent.Hook { - return If(hk, Not(HasOp(op))) -} - -// FixedError is a hook returning a fixed error. -func FixedError(err error) ent.Hook { - return func(ent.Mutator) ent.Mutator { - return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { - return nil, err - }) - } -} - -// Reject returns a hook that rejects all operations that match op. -// -// func (T) Hooks() []ent.Hook { -// return []ent.Hook{ -// Reject(ent.Delete|ent.Update), -// } -// } -func Reject(op ent.Op) ent.Hook { - hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) - return On(hk, op) -} - -// Chain acts as a list of hooks and is effectively immutable. -// Once created, it will always hold the same set of hooks in the same order. -type Chain struct { - hooks []ent.Hook -} - -// NewChain creates a new chain of hooks. -func NewChain(hooks ...ent.Hook) Chain { - return Chain{append([]ent.Hook(nil), hooks...)} -} - -// Hook chains the list of hooks and returns the final hook. -func (c Chain) Hook() ent.Hook { - return func(mutator ent.Mutator) ent.Mutator { - for i := len(c.hooks) - 1; i >= 0; i-- { - mutator = c.hooks[i](mutator) - } - return mutator - } -} - -// Append extends a chain, adding the specified hook -// as the last ones in the mutation flow. -func (c Chain) Append(hooks ...ent.Hook) Chain { - newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) - newHooks = append(newHooks, c.hooks...) - newHooks = append(newHooks, hooks...) - return Chain{newHooks} -} - -// Extend extends a chain, adding the specified chain -// as the last ones in the mutation flow. -func (c Chain) Extend(chain Chain) Chain { - return c.Append(chain.hooks...) -} diff --git a/internal/mods/casbin/dal/entity/ent/intercept/intercept.go b/internal/mods/casbin/dal/entity/ent/intercept/intercept.go deleted file mode 100644 index 5fcdf6ef..00000000 --- a/internal/mods/casbin/dal/entity/ent/intercept/intercept.go +++ /dev/null @@ -1,150 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package intercept - -import ( - "context" - "fmt" - - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/predicate" - - "entgo.io/ent/dialect/sql" -) - -// The Query interface represents an operation that queries a graph. -// By using this interface, users can write generic code that manipulates -// query builders of different types. -type Query interface { - // Type returns the string representation of the query type. - Type() string - // Limit the number of records to be returned by this query. - Limit(int) - // Offset to start from. - Offset(int) - // Unique configures the query builder to filter duplicate records. - Unique(bool) - // Order specifies how the records should be ordered. - Order(...func(*sql.Selector)) - // WhereP appends storage-level predicates to the query builder. Using this method, users - // can use type-assertion to append predicates that do not depend on any generated package. - WhereP(...func(*sql.Selector)) -} - -// The Func type is an adapter that allows ordinary functions to be used as interceptors. -// Unlike traversal functions, interceptors are skipped during graph traversals. Note that the -// implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc. -type Func func(context.Context, Query) error - -// Intercept calls f(ctx, q) and then applied the next Querier. -func (f Func) Intercept(next ent.Querier) ent.Querier { - return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) { - query, err := NewQuery(q) - if err != nil { - return nil, err - } - if err := f(ctx, query); err != nil { - return nil, err - } - return next.Query(ctx, q) - }) -} - -// The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser. -// If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f. -type TraverseFunc func(context.Context, Query) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error { - query, err := NewQuery(q) - if err != nil { - return err - } - return f(ctx, query) -} - -// The CasbinRuleFunc type is an adapter to allow the use of ordinary function as a Querier. -type CasbinRuleFunc func(context.Context, *ent.CasbinRuleQuery) (ent.Value, error) - -// Query calls f(ctx, q). -func (f CasbinRuleFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { - if q, ok := q.(*ent.CasbinRuleQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *ent.CasbinRuleQuery", q) -} - -// The TraverseCasbinRule type is an adapter to allow the use of ordinary function as Traverser. -type TraverseCasbinRule func(context.Context, *ent.CasbinRuleQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseCasbinRule) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseCasbinRule) Traverse(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.CasbinRuleQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *ent.CasbinRuleQuery", q) -} - -// NewQuery returns the generic Query interface for the given typed query. -func NewQuery(q ent.Query) (Query, error) { - switch q := q.(type) { - case *ent.CasbinRuleQuery: - return &query[*ent.CasbinRuleQuery, predicate.CasbinRule, casbinrule.OrderOption]{typ: ent.TypeCasbinRule, tq: q}, nil - default: - return nil, fmt.Errorf("unknown query type %T", q) - } -} - -type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct { - typ string - tq interface { - Limit(int) T - Offset(int) T - Unique(bool) T - Order(...R) T - Where(...P) T - } -} - -func (q query[T, P, R]) Type() string { - return q.typ -} - -func (q query[T, P, R]) Limit(limit int) { - q.tq.Limit(limit) -} - -func (q query[T, P, R]) Offset(offset int) { - q.tq.Offset(offset) -} - -func (q query[T, P, R]) Unique(unique bool) { - q.tq.Unique(unique) -} - -func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) { - rs := make([]R, len(orders)) - for i := range orders { - rs[i] = orders[i] - } - q.tq.Order(rs...) -} - -func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) { - p := make([]P, len(ps)) - for i := range ps { - p[i] = ps[i] - } - q.tq.Where(p...) -} diff --git a/internal/mods/casbin/dal/entity/ent/internal/schema.go b/internal/mods/casbin/dal/entity/ent/internal/schema.go deleted file mode 100644 index dcc88786..00000000 --- a/internal/mods/casbin/dal/entity/ent/internal/schema.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -//go:build tools -// +build tools - -// Package internal holds a loadable version of the latest schema. -package internal - -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/mods/casbin/dal/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/mods/casbin/dal/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/mods/casbin/dal/entity/ent/migrate/schema.go b/internal/mods/casbin/dal/entity/ent/migrate/schema.go deleted file mode 100644 index 4e3cd0e1..00000000 --- a/internal/mods/casbin/dal/entity/ent/migrate/schema.go +++ /dev/null @@ -1,35 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package migrate - -import ( - "entgo.io/ent/dialect/sql/schema" - "entgo.io/ent/schema/field" -) - -var ( - // CasbinRulesColumns holds the columns for the "casbin_rules" table. - CasbinRulesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "ptype", Type: field.TypeString, Default: ""}, - {Name: "v0", Type: field.TypeString, Default: ""}, - {Name: "v1", Type: field.TypeString, Default: ""}, - {Name: "v2", Type: field.TypeString, Default: ""}, - {Name: "v3", Type: field.TypeString, Default: ""}, - {Name: "v4", Type: field.TypeString, Default: ""}, - {Name: "v5", Type: field.TypeString, Default: ""}, - } - // CasbinRulesTable holds the schema information for the "casbin_rules" table. - CasbinRulesTable = &schema.Table{ - Name: "casbin_rules", - Columns: CasbinRulesColumns, - PrimaryKey: []*schema.Column{CasbinRulesColumns[0]}, - } - // Tables holds all the tables in the schema. - Tables = []*schema.Table{ - CasbinRulesTable, - } -) - -func init() { -} diff --git a/internal/mods/casbin/dal/entity/ent/mutation.go b/internal/mods/casbin/dal/entity/ent/mutation.go deleted file mode 100644 index ef6fad04..00000000 --- a/internal/mods/casbin/dal/entity/ent/mutation.go +++ /dev/null @@ -1,677 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "sync" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" -) - -const ( - // Operation types. - OpCreate = ent.OpCreate - OpDelete = ent.OpDelete - OpDeleteOne = ent.OpDeleteOne - OpUpdate = ent.OpUpdate - OpUpdateOne = ent.OpUpdateOne - - // Node types. - TypeCasbinRule = "CasbinRule" -) - -// CasbinRuleMutation represents an operation that mutates the CasbinRule nodes in the graph. -type CasbinRuleMutation struct { - config - op Op - typ string - id *int - _Ptype *string - _V0 *string - _V1 *string - _V2 *string - _V3 *string - _V4 *string - _V5 *string - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*CasbinRule, error) - predicates []predicate.CasbinRule -} - -var _ ent.Mutation = (*CasbinRuleMutation)(nil) - -// casbinruleOption allows management of the mutation configuration using functional options. -type casbinruleOption func(*CasbinRuleMutation) - -// newCasbinRuleMutation creates new mutation for the CasbinRule entity. -func newCasbinRuleMutation(c config, op Op, opts ...casbinruleOption) *CasbinRuleMutation { - m := &CasbinRuleMutation{ - config: c, - op: op, - typ: TypeCasbinRule, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withCasbinRuleID sets the ID field of the mutation. -func withCasbinRuleID(id int) casbinruleOption { - return func(m *CasbinRuleMutation) { - var ( - err error - once sync.Once - value *CasbinRule - ) - m.oldValue = func(ctx context.Context) (*CasbinRule, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().CasbinRule.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withCasbinRule sets the old CasbinRule of the mutation. -func withCasbinRule(node *CasbinRule) casbinruleOption { - return func(m *CasbinRuleMutation) { - m.oldValue = func(context.Context) (*CasbinRule, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m CasbinRuleMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m CasbinRuleMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *CasbinRuleMutation) ID() (id int, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *CasbinRuleMutation) IDs(ctx context.Context) ([]int, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().CasbinRule.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetPtype sets the "Ptype" field. -func (m *CasbinRuleMutation) SetPtype(s string) { - m._Ptype = &s -} - -// Ptype returns the value of the "Ptype" field in the mutation. -func (m *CasbinRuleMutation) Ptype() (r string, exists bool) { - v := m._Ptype - if v == nil { - return - } - return *v, true -} - -// OldPtype returns the old "Ptype" field's value of the CasbinRule entity. -// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CasbinRuleMutation) OldPtype(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPtype is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPtype requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPtype: %w", err) - } - return oldValue.Ptype, nil -} - -// ResetPtype resets all changes to the "Ptype" field. -func (m *CasbinRuleMutation) ResetPtype() { - m._Ptype = nil -} - -// SetV0 sets the "V0" field. -func (m *CasbinRuleMutation) SetV0(s string) { - m._V0 = &s -} - -// V0 returns the value of the "V0" field in the mutation. -func (m *CasbinRuleMutation) V0() (r string, exists bool) { - v := m._V0 - if v == nil { - return - } - return *v, true -} - -// OldV0 returns the old "V0" field's value of the CasbinRule entity. -// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CasbinRuleMutation) OldV0(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldV0 is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldV0 requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldV0: %w", err) - } - return oldValue.V0, nil -} - -// ResetV0 resets all changes to the "V0" field. -func (m *CasbinRuleMutation) ResetV0() { - m._V0 = nil -} - -// SetV1 sets the "V1" field. -func (m *CasbinRuleMutation) SetV1(s string) { - m._V1 = &s -} - -// V1 returns the value of the "V1" field in the mutation. -func (m *CasbinRuleMutation) V1() (r string, exists bool) { - v := m._V1 - if v == nil { - return - } - return *v, true -} - -// OldV1 returns the old "V1" field's value of the CasbinRule entity. -// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CasbinRuleMutation) OldV1(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldV1 is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldV1 requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldV1: %w", err) - } - return oldValue.V1, nil -} - -// ResetV1 resets all changes to the "V1" field. -func (m *CasbinRuleMutation) ResetV1() { - m._V1 = nil -} - -// SetV2 sets the "V2" field. -func (m *CasbinRuleMutation) SetV2(s string) { - m._V2 = &s -} - -// V2 returns the value of the "V2" field in the mutation. -func (m *CasbinRuleMutation) V2() (r string, exists bool) { - v := m._V2 - if v == nil { - return - } - return *v, true -} - -// OldV2 returns the old "V2" field's value of the CasbinRule entity. -// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CasbinRuleMutation) OldV2(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldV2 is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldV2 requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldV2: %w", err) - } - return oldValue.V2, nil -} - -// ResetV2 resets all changes to the "V2" field. -func (m *CasbinRuleMutation) ResetV2() { - m._V2 = nil -} - -// SetV3 sets the "V3" field. -func (m *CasbinRuleMutation) SetV3(s string) { - m._V3 = &s -} - -// V3 returns the value of the "V3" field in the mutation. -func (m *CasbinRuleMutation) V3() (r string, exists bool) { - v := m._V3 - if v == nil { - return - } - return *v, true -} - -// OldV3 returns the old "V3" field's value of the CasbinRule entity. -// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CasbinRuleMutation) OldV3(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldV3 is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldV3 requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldV3: %w", err) - } - return oldValue.V3, nil -} - -// ResetV3 resets all changes to the "V3" field. -func (m *CasbinRuleMutation) ResetV3() { - m._V3 = nil -} - -// SetV4 sets the "V4" field. -func (m *CasbinRuleMutation) SetV4(s string) { - m._V4 = &s -} - -// V4 returns the value of the "V4" field in the mutation. -func (m *CasbinRuleMutation) V4() (r string, exists bool) { - v := m._V4 - if v == nil { - return - } - return *v, true -} - -// OldV4 returns the old "V4" field's value of the CasbinRule entity. -// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CasbinRuleMutation) OldV4(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldV4 is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldV4 requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldV4: %w", err) - } - return oldValue.V4, nil -} - -// ResetV4 resets all changes to the "V4" field. -func (m *CasbinRuleMutation) ResetV4() { - m._V4 = nil -} - -// SetV5 sets the "V5" field. -func (m *CasbinRuleMutation) SetV5(s string) { - m._V5 = &s -} - -// V5 returns the value of the "V5" field in the mutation. -func (m *CasbinRuleMutation) V5() (r string, exists bool) { - v := m._V5 - if v == nil { - return - } - return *v, true -} - -// OldV5 returns the old "V5" field's value of the CasbinRule entity. -// If the CasbinRule object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *CasbinRuleMutation) OldV5(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldV5 is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldV5 requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldV5: %w", err) - } - return oldValue.V5, nil -} - -// ResetV5 resets all changes to the "V5" field. -func (m *CasbinRuleMutation) ResetV5() { - m._V5 = nil -} - -// Where appends a list predicates to the CasbinRuleMutation builder. -func (m *CasbinRuleMutation) Where(ps ...predicate.CasbinRule) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the CasbinRuleMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *CasbinRuleMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.CasbinRule, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *CasbinRuleMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *CasbinRuleMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (CasbinRule). -func (m *CasbinRuleMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *CasbinRuleMutation) Fields() []string { - fields := make([]string, 0, 7) - if m._Ptype != nil { - fields = append(fields, casbinrule.FieldPtype) - } - if m._V0 != nil { - fields = append(fields, casbinrule.FieldV0) - } - if m._V1 != nil { - fields = append(fields, casbinrule.FieldV1) - } - if m._V2 != nil { - fields = append(fields, casbinrule.FieldV2) - } - if m._V3 != nil { - fields = append(fields, casbinrule.FieldV3) - } - if m._V4 != nil { - fields = append(fields, casbinrule.FieldV4) - } - if m._V5 != nil { - fields = append(fields, casbinrule.FieldV5) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *CasbinRuleMutation) Field(name string) (ent.Value, bool) { - switch name { - case casbinrule.FieldPtype: - return m.Ptype() - case casbinrule.FieldV0: - return m.V0() - case casbinrule.FieldV1: - return m.V1() - case casbinrule.FieldV2: - return m.V2() - case casbinrule.FieldV3: - return m.V3() - case casbinrule.FieldV4: - return m.V4() - case casbinrule.FieldV5: - return m.V5() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *CasbinRuleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case casbinrule.FieldPtype: - return m.OldPtype(ctx) - case casbinrule.FieldV0: - return m.OldV0(ctx) - case casbinrule.FieldV1: - return m.OldV1(ctx) - case casbinrule.FieldV2: - return m.OldV2(ctx) - case casbinrule.FieldV3: - return m.OldV3(ctx) - case casbinrule.FieldV4: - return m.OldV4(ctx) - case casbinrule.FieldV5: - return m.OldV5(ctx) - } - return nil, fmt.Errorf("unknown CasbinRule field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *CasbinRuleMutation) SetField(name string, value ent.Value) error { - switch name { - case casbinrule.FieldPtype: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPtype(v) - return nil - case casbinrule.FieldV0: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetV0(v) - return nil - case casbinrule.FieldV1: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetV1(v) - return nil - case casbinrule.FieldV2: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetV2(v) - return nil - case casbinrule.FieldV3: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetV3(v) - return nil - case casbinrule.FieldV4: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetV4(v) - return nil - case casbinrule.FieldV5: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetV5(v) - return nil - } - return fmt.Errorf("unknown CasbinRule field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *CasbinRuleMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *CasbinRuleMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *CasbinRuleMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown CasbinRule numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *CasbinRuleMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *CasbinRuleMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *CasbinRuleMutation) ClearField(name string) error { - return fmt.Errorf("unknown CasbinRule nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *CasbinRuleMutation) ResetField(name string) error { - switch name { - case casbinrule.FieldPtype: - m.ResetPtype() - return nil - case casbinrule.FieldV0: - m.ResetV0() - return nil - case casbinrule.FieldV1: - m.ResetV1() - return nil - case casbinrule.FieldV2: - m.ResetV2() - return nil - case casbinrule.FieldV3: - m.ResetV3() - return nil - case casbinrule.FieldV4: - m.ResetV4() - return nil - case casbinrule.FieldV5: - m.ResetV5() - return nil - } - return fmt.Errorf("unknown CasbinRule field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *CasbinRuleMutation) AddedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *CasbinRuleMutation) AddedIDs(name string) []ent.Value { - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *CasbinRuleMutation) RemovedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *CasbinRuleMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *CasbinRuleMutation) ClearedEdges() []string { - edges := make([]string, 0, 0) - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *CasbinRuleMutation) EdgeCleared(name string) bool { - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *CasbinRuleMutation) ClearEdge(name string) error { - return fmt.Errorf("unknown CasbinRule unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *CasbinRuleMutation) ResetEdge(name string) error { - return fmt.Errorf("unknown CasbinRule edge %s", name) -} diff --git a/internal/mods/casbin/dal/entity/ent/mutation_fields.go b/internal/mods/casbin/dal/entity/ent/mutation_fields.go deleted file mode 100644 index bd3282ba..00000000 --- a/internal/mods/casbin/dal/entity/ent/mutation_fields.go +++ /dev/null @@ -1,83 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" -) - -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *CasbinRuleMutation) SetFields(input *CasbinRule, fields ...string) error { - for i := range fields { - switch fields[i] { - case casbinrule.FieldPtype: - // check string with sql.NullString if it is empty - if input.Ptype != "" { - m.SetPtype(input.Ptype) - } - case casbinrule.FieldV0: - // check string with sql.NullString if it is empty - if input.V0 != "" { - m.SetV0(input.V0) - } - case casbinrule.FieldV1: - // check string with sql.NullString if it is empty - if input.V1 != "" { - m.SetV1(input.V1) - } - case casbinrule.FieldV2: - // check string with sql.NullString if it is empty - if input.V2 != "" { - m.SetV2(input.V2) - } - case casbinrule.FieldV3: - // check string with sql.NullString if it is empty - if input.V3 != "" { - m.SetV3(input.V3) - } - case casbinrule.FieldV4: - // check string with sql.NullString if it is empty - if input.V4 != "" { - m.SetV4(input.V4) - } - case casbinrule.FieldV5: - // check string with sql.NullString if it is empty - if input.V5 != "" { - m.SetV5(input.V5) - } - default: - return fmt.Errorf("unknown CasbinRule field %s", fields[i]) - } - } - return nil -} - -// SetFieldsWithZero sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *CasbinRuleMutation) SetFieldsWithZero(input *CasbinRule, fields ...string) error { - for i := range fields { - switch fields[i] { - case casbinrule.FieldPtype: - m.SetPtype(input.Ptype) - case casbinrule.FieldV0: - m.SetV0(input.V0) - case casbinrule.FieldV1: - m.SetV1(input.V1) - case casbinrule.FieldV2: - m.SetV2(input.V2) - case casbinrule.FieldV3: - m.SetV3(input.V3) - case casbinrule.FieldV4: - m.SetV4(input.V4) - case casbinrule.FieldV5: - m.SetV5(input.V5) - default: - return fmt.Errorf("unknown CasbinRule field %s", fields[i]) - } - } - return nil -} diff --git a/internal/mods/casbin/dal/entity/ent/predicate/predicate.go b/internal/mods/casbin/dal/entity/ent/predicate/predicate.go deleted file mode 100644 index 88908808..00000000 --- a/internal/mods/casbin/dal/entity/ent/predicate/predicate.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package predicate - -import ( - "entgo.io/ent/dialect/sql" -) - -// CasbinRule is the predicate function for casbinrule builders. -type CasbinRule func(*sql.Selector) diff --git a/internal/mods/casbin/dal/entity/ent/runtime.go b/internal/mods/casbin/dal/entity/ent/runtime.go deleted file mode 100644 index 6ec57bd3..00000000 --- a/internal/mods/casbin/dal/entity/ent/runtime.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/casbinrule" - "origadmin/application/admin/internal/mods/casbin/dal/entity/ent/schema" -) - -// The init function reads all schema descriptors with runtime code -// (default values, validators, hooks and policies) and stitches it -// to their package variables. -func init() { - casbinruleFields := schema.CasbinRule{}.Fields() - _ = casbinruleFields - // casbinruleDescPtype is the schema descriptor for Ptype field. - casbinruleDescPtype := casbinruleFields[0].Descriptor() - // casbinrule.DefaultPtype holds the default value on creation for the Ptype field. - casbinrule.DefaultPtype = casbinruleDescPtype.Default.(string) - // casbinruleDescV0 is the schema descriptor for V0 field. - casbinruleDescV0 := casbinruleFields[1].Descriptor() - // casbinrule.DefaultV0 holds the default value on creation for the V0 field. - casbinrule.DefaultV0 = casbinruleDescV0.Default.(string) - // casbinruleDescV1 is the schema descriptor for V1 field. - casbinruleDescV1 := casbinruleFields[2].Descriptor() - // casbinrule.DefaultV1 holds the default value on creation for the V1 field. - casbinrule.DefaultV1 = casbinruleDescV1.Default.(string) - // casbinruleDescV2 is the schema descriptor for V2 field. - casbinruleDescV2 := casbinruleFields[3].Descriptor() - // casbinrule.DefaultV2 holds the default value on creation for the V2 field. - casbinrule.DefaultV2 = casbinruleDescV2.Default.(string) - // casbinruleDescV3 is the schema descriptor for V3 field. - casbinruleDescV3 := casbinruleFields[4].Descriptor() - // casbinrule.DefaultV3 holds the default value on creation for the V3 field. - casbinrule.DefaultV3 = casbinruleDescV3.Default.(string) - // casbinruleDescV4 is the schema descriptor for V4 field. - casbinruleDescV4 := casbinruleFields[5].Descriptor() - // casbinrule.DefaultV4 holds the default value on creation for the V4 field. - casbinrule.DefaultV4 = casbinruleDescV4.Default.(string) - // casbinruleDescV5 is the schema descriptor for V5 field. - casbinruleDescV5 := casbinruleFields[6].Descriptor() - // casbinrule.DefaultV5 holds the default value on creation for the V5 field. - casbinrule.DefaultV5 = casbinruleDescV5.Default.(string) -} diff --git a/internal/mods/casbin/dal/entity/ent/runtime/runtime.go b/internal/mods/casbin/dal/entity/ent/runtime/runtime.go deleted file mode 100644 index a6ca836e..00000000 --- a/internal/mods/casbin/dal/entity/ent/runtime/runtime.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package runtime - -// The schema-stitching logic is generated in origadmin/application/admin/internal/mods/casbin/dal/entity/ent/runtime.go - -const ( - Version = "v0.14.1" // Version of ent codegen. - Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen. -) diff --git a/internal/mods/casbin/dal/entity/ent/template/database.tpl b/internal/mods/casbin/dal/entity/ent/template/database.tpl deleted file mode 100644 index 914a4f34..00000000 --- a/internal/mods/casbin/dal/entity/ent/template/database.tpl +++ /dev/null @@ -1,116 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based *gen.Type type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Type */}} - - -{{ define "database" }} - {{- $pkg := base $.Config.Package -}} - {{ template "header" $ }} - - /* Additional dependencies injected to config. */ - {{ $deps := list }}{{ with $.Config.Annotations }}{{ $deps = $.Config.Annotations.Dependencies }}{{ end }} - - import ( - "context" - "fmt" - "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime/interfaces/database" - ) - - // Database is the client that holds all ent builders. - type Database struct { - client *Client - } - - // NewDatabase creates a new database configured with the given options. - func NewDatabase(client *Client,opts ...Option) *Database { - if client == nil { - client = NewClient(opts...) - } - return &Database{client: client} - } - - func (db *Database) clientDriver(ctx context.Context) dialect.Driver { - tx := TxFromContext(ctx) - c := db.client - if tx != nil { - c = tx.Client() - } - return c.driver - } - - // Tx runs the given function f within a transaction. - func (db *Database) Tx(ctx context.Context, fn func(context.Context) error) error { - tx := TxFromContext(ctx) - if tx != nil { - return fn(ctx) - } - - return db.InTx(ctx, func (tx database.Tx) error { - txv, ok := tx.(*Tx) - if !ok { - return fmt.Errorf("ent: expected tx context") - } - return fn(NewTxContext(ctx, txv)) - }) - } - - // InTx runs the given function f within a transaction. - func (db *Database) InTx(ctx context.Context, fn func(tx database.Tx) error) error { - tx := TxFromContext(ctx) - if tx != nil { - return fn(tx) - } - tx, err := db.client.Tx(ctx) - if err != nil { - return fmt.Errorf("starting transaction: %w", err) - } - if err = fn(tx); err != nil { - if txerr := tx.Rollback(); txerr != nil { - return fmt.Errorf("rolling back transaction: %v (original error: %w)", txerr, err) - } - return err - } - if err := tx.Commit(); err != nil { - return fmt.Errorf("committing transaction: %w", err) - } - return nil - } - - // Client returns the client that holds all ent builders. - func (db *Database) Client(ctx context.Context) *Client { - tx := TxFromContext(ctx) - if tx != nil { - return tx.Client() - } - return db.client - } - - // Exec executes a query that doesn't return rows. For example, in SQL, INSERT or UPDATE. - func (db *Database) Exec(ctx context.Context, query string, args ...interface{}) (*sql.Result, error) { - var res sql.Result - err := db.clientDriver(ctx).Exec(ctx, query, args, &res) - if err != nil { - return nil, err - } - return &res, nil - } - - // Query executes a query that returns rows, typically a SELECT in SQL. - func (db *Database) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) { - var rows sql.Rows - err := db.clientDriver(ctx).Query(ctx, query, args, &rows) - if err != nil { - return nil, err - } - return &rows, nil - } - - {{ range $n := $.Nodes }} - {{ $client := print $n.Name "ServiceClient" }} - // {{ $n.Name }} is the client for interacting with the {{ $n.Name }} builders. - func (db *Database) {{ $n.Name }}(ctx context.Context) *{{ $client }} { - return db.Client(ctx).{{ $n.Name }} - } - {{ end }} - -{{ end }} \ No newline at end of file diff --git a/internal/mods/casbin/dal/entity/ent/template/mutation_fields.tpl b/internal/mods/casbin/dal/entity/ent/template/mutation_fields.tpl deleted file mode 100644 index a18b1ce0..00000000 --- a/internal/mods/casbin/dal/entity/ent/template/mutation_fields.tpl +++ /dev/null @@ -1,116 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Graph */}} - -{{ define "mutation_fields" }} - {{- $pkg := base $.Config.Package -}} - {{- template "header" $ -}} - - {{/* Additional dependencies injected to config. */}} - {{ $deps := list }}{{ with $.Config.Annotations }}{{ $deps = $.Config.Annotations.Dependencies }}{{ end }} - - import ( - "log" - - "entgo.io/ent/dialect" - - {{- range $n := $.Nodes }} - {{ $n.PackageAlias }} "{{ $n.Config.Package }}/{{ $n.PackageDir }}" - {{- end }} - {{- range $dep := $deps }} - {{ $dep.Type.PkgName }} "{{ $dep.Type.PkgPath }}" - {{- end }} - "{{ $.Config.Package }}/migrate" - {{- range $import := $.Storage.Imports }} - "{{ $import }}" - {{- end -}} - {{- template "import/additional" $ }} - ) - - {{ range $n := $.MutableNodes }} - {{ $fields := $n.Fields }} - {{- if .ID.UserDefined }} - {{ $fields = append $fields .ID }} - {{- end }} - {{ $mutation := $n.MutationName }} - // SetFields sets the values of the fields with the given names. It returns an - // error if the field is not defined in the schema, or if the type mismatched the - // field type. - func (m *{{ $mutation }}) SetFields(input *{{ .Name }}, fields ...string) error { - for i := range fields { - switch fields[i] { - {{- range $f := $fields }} - {{- $const := print $n.Package "." $f.Constant }} - {{- $setter := print "Set" $f.StructField }} - case {{ $const }}: - {{- if $f.Nillable}} - if input.{{ $f.StructField }} != nil { - m.{{ $setter }}(*input.{{ $f.StructField }}) - } - {{- else if $f.IsBool}} - if input.{{ $f.StructField }} { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- else if $f.IsTime}} - if input.{{ $f.StructField }}.Unix() != 0 { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- else if $f.IsJSON}} - if len(input.{{ $f.StructField }}) > 0 { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- else if $f.IsString}} - // check {{$f.Type}} with {{$f.ScanType}} if it is empty - if input.{{ $f.StructField }} != "" { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- else if $f.Type.Numeric}} - // check {{$f.Type}} with {{$f.ScanType}} if it is zero - if input.{{ $f.StructField }} != 0 { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- else }} - var zero {{ $f.Type }} - // check {{$f.Type}} with {{$f.ScanType}} if it is empty - if input.{{ $f.StructField }} != zero { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- end}} - {{- end }} - default: - return fmt.Errorf("unknown {{ .Name }} field %s", fields[i]) - } - } - return nil - } - - // SetFieldsWithZero sets the values of the fields with the given names. It returns an - // error if the field is not defined in the schema, or if the type mismatched the - // field type. - func (m *{{ $mutation }}) SetFieldsWithZero(input *{{ .Name }}, fields ...string) error { - for i := range fields { - switch fields[i] { - {{- range $f := $fields }} - {{- $const := print $n.Package "." $f.Constant }} - {{- $setter := print "Set" $f.StructField }} - {{- $clear := print "Reset" $f.StructField }} - case {{ $const }}: - {{- if $f.Nillable}} - if input.{{ $f.StructField }}!= nil { - m.{{ $setter }}(*input.{{ $f.StructField }}) - }else{ - m.{{ $clear }}() - } - {{- else}} - m.{{ $setter }}(input.{{ $f.StructField }}) - {{- end}} - {{- end }} - default: - return fmt.Errorf("unknown {{ .Name }} field %s", fields[i]) - } - } - return nil - } - {{- end }} - -{{ end }} - diff --git a/internal/mods/casbin/dal/entity/ent/tx.go b/internal/mods/casbin/dal/entity/ent/tx.go deleted file mode 100644 index 70f051fc..00000000 --- a/internal/mods/casbin/dal/entity/ent/tx.go +++ /dev/null @@ -1,210 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "sync" - - "entgo.io/ent/dialect" -) - -// Tx is a transactional client that is created by calling Client.Tx(). -type Tx struct { - config - // CasbinRule is the client for interacting with the CasbinRule builders. - CasbinRule *CasbinRuleClient - - // lazily loaded. - client *Client - clientOnce sync.Once - // ctx lives for the life of the transaction. It is - // the same context used by the underlying connection. - ctx context.Context -} - -type ( - // Committer is the interface that wraps the Commit method. - Committer interface { - Commit(context.Context, *Tx) error - } - - // The CommitFunc type is an adapter to allow the use of ordinary - // function as a Committer. If f is a function with the appropriate - // signature, CommitFunc(f) is a Committer that calls f. - CommitFunc func(context.Context, *Tx) error - - // CommitHook defines the "commit middleware". A function that gets a Committer - // and returns a Committer. For example: - // - // hook := func(next ent.Committer) ent.Committer { - // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { - // // Do some stuff before. - // if err := next.Commit(ctx, tx); err != nil { - // return err - // } - // // Do some stuff after. - // return nil - // }) - // } - // - CommitHook func(Committer) Committer -) - -// Commit calls f(ctx, m). -func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { - return f(ctx, tx) -} - -// Commit commits the transaction. -func (tx *Tx) Commit() error { - txDriver := tx.config.driver.(*txDriver) - var fn Committer = CommitFunc(func(context.Context, *Tx) error { - return txDriver.tx.Commit() - }) - txDriver.mu.Lock() - hooks := append([]CommitHook(nil), txDriver.onCommit...) - txDriver.mu.Unlock() - for i := len(hooks) - 1; i >= 0; i-- { - fn = hooks[i](fn) - } - return fn.Commit(tx.ctx, tx) -} - -// OnCommit adds a hook to call on commit. -func (tx *Tx) OnCommit(f CommitHook) { - txDriver := tx.config.driver.(*txDriver) - txDriver.mu.Lock() - txDriver.onCommit = append(txDriver.onCommit, f) - txDriver.mu.Unlock() -} - -type ( - // Rollbacker is the interface that wraps the Rollback method. - Rollbacker interface { - Rollback(context.Context, *Tx) error - } - - // The RollbackFunc type is an adapter to allow the use of ordinary - // function as a Rollbacker. If f is a function with the appropriate - // signature, RollbackFunc(f) is a Rollbacker that calls f. - RollbackFunc func(context.Context, *Tx) error - - // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker - // and returns a Rollbacker. For example: - // - // hook := func(next ent.Rollbacker) ent.Rollbacker { - // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { - // // Do some stuff before. - // if err := next.Rollback(ctx, tx); err != nil { - // return err - // } - // // Do some stuff after. - // return nil - // }) - // } - // - RollbackHook func(Rollbacker) Rollbacker -) - -// Rollback calls f(ctx, m). -func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { - return f(ctx, tx) -} - -// Rollback rollbacks the transaction. -func (tx *Tx) Rollback() error { - txDriver := tx.config.driver.(*txDriver) - var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { - return txDriver.tx.Rollback() - }) - txDriver.mu.Lock() - hooks := append([]RollbackHook(nil), txDriver.onRollback...) - txDriver.mu.Unlock() - for i := len(hooks) - 1; i >= 0; i-- { - fn = hooks[i](fn) - } - return fn.Rollback(tx.ctx, tx) -} - -// OnRollback adds a hook to call on rollback. -func (tx *Tx) OnRollback(f RollbackHook) { - txDriver := tx.config.driver.(*txDriver) - txDriver.mu.Lock() - txDriver.onRollback = append(txDriver.onRollback, f) - txDriver.mu.Unlock() -} - -// Client returns a Client that binds to current transaction. -func (tx *Tx) Client() *Client { - tx.clientOnce.Do(func() { - tx.client = &Client{config: tx.config} - tx.client.init() - }) - return tx.client -} - -func (tx *Tx) init() { - tx.CasbinRule = NewCasbinRuleClient(tx.config) -} - -// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. -// The idea is to support transactions without adding any extra code to the builders. -// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. -// Commit and Rollback are nop for the internal builders and the user must call one -// of them in order to commit or rollback the transaction. -// -// If a closed transaction is embedded in one of the generated entities, and the entity -// applies a query, for example: CasbinRule.QueryXXX(), the query will be executed -// through the driver which created this transaction. -// -// Note that txDriver is not goroutine safe. -type txDriver struct { - // the driver we started the transaction from. - drv dialect.Driver - // tx is the underlying transaction. - tx dialect.Tx - // completion hooks. - mu sync.Mutex - onCommit []CommitHook - onRollback []RollbackHook -} - -// newTx creates a new transactional driver. -func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { - tx, err := drv.Tx(ctx) - if err != nil { - return nil, err - } - return &txDriver{tx: tx, drv: drv}, nil -} - -// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls -// from the internal builders. Should be called only by the internal builders. -func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } - -// Dialect returns the dialect of the driver we started the transaction from. -func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } - -// Close is a nop close. -func (*txDriver) Close() error { return nil } - -// Commit is a nop commit for the internal builders. -// User must call `Tx.Commit` in order to commit the transaction. -func (*txDriver) Commit() error { return nil } - -// Rollback is a nop rollback for the internal builders. -// User must call `Tx.Rollback` in order to rollback the transaction. -func (*txDriver) Rollback() error { return nil } - -// Exec calls tx.Exec. -func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error { - return tx.tx.Exec(ctx, query, args, v) -} - -// Query calls tx.Query. -func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error { - return tx.tx.Query(ctx, query, args, v) -} - -var _ dialect.Driver = (*txDriver)(nil) diff --git a/internal/mods/casbin/dto/casbin-adapter.go b/internal/mods/casbin/dto/casbin-adapter.go deleted file mode 100644 index 58401f81..00000000 --- a/internal/mods/casbin/dto/casbin-adapter.go +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto implements the functions, types, and interfaces for the module. -package dto - -import ( - "github.com/casbin/casbin/v2/model" -) - -type CasbinAdapterRepo interface { - LoadPolicy(model model.Model) error - LoadFilteredPolicy(model model.Model, filter interface{}) error - IsFiltered() bool - SavePolicy(model model.Model) error - AddPolicy(sec string, ptype string, rule []string) error - RemovePolicy(sec string, ptype string, rule []string) error - RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error - AddPolicies(sec string, ptype string, rules [][]string) error - RemovePolicies(sec string, ptype string, rules [][]string) error - UpdatePolicy(sec string, ptype string, oldRule, newPolicy []string) error - UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) error - UpdateFilteredPolicies(sec string, ptype string, newPolicies [][]string, fieldIndex int, - fieldValues ...string) ([][]string, error) -} diff --git a/internal/mods/casbin/server/README.md b/internal/mods/casbin/server/README.md deleted file mode 100644 index be23f4ff..00000000 --- a/internal/mods/casbin/server/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Server - -This directory contains the server code. - diff --git a/internal/mods/casbin/server/agent.go b/internal/mods/casbin/server/agent.go deleted file mode 100644 index 55a5c382..00000000 --- a/internal/mods/casbin/server/agent.go +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package server implements the functions, types, and interfaces for the module. -package server - -import ( - "github.com/go-kratos/kratos/v2/metadata" - "github.com/origadmin/runtime/context" -) - -type agentCtx struct{} - -func NewAgentContext(ctx context.Context, metadata metadata.Metadata) context.Context { - return context.WithValue(ctx, agentCtx{}, metadata) -} - -func FromAgentContext(ctx context.Context) (metadata.Metadata, bool) { - if v, ok := ctx.Value(agentCtx{}).(metadata.Metadata); ok { - return v, true - } - return nil, false -} diff --git a/internal/mods/casbin/server/gins.go b/internal/mods/casbin/server/gins.go deleted file mode 100644 index 26a1c030..00000000 --- a/internal/mods/casbin/server/gins.go +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "net/url" - - "github.com/origadmin/contrib/transport/gins" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/service" - "github.com/origadmin/toolkits/env" - "github.com/origadmin/toolkits/net" - - "origadmin/application/admin/internal/configs" -) - -// NewGINSServer new a gin server. -func NewGINSServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.OptionSetting) *gins.Server { - ms := middleware.NewServer(bootstrap.GetMiddleware()) - //option := settings.ApplyOrZero(ss...) - var opts = []gins.ServerOption{ - gins.Middleware(ms...), - } - //serviceConfig := bootstrap.GetService() - //cfg := serviceConfig.GetGins() - //if cfg == nil { - // return nil - //} - // - //if cfg.Network != "" { - // opts = append(opts, gins.Network(cfg.Network)) - //} - //if cfg.Addr != "" { - // opts = append(opts, gins.Address(cfg.Addr)) - //} - //if cfg.Timeout != nil { - // opts = append(opts, gins.Timeout(cfg.Timeout.AsDuration())) - //} - - //middlewares, err := bootstrap.LoadMiddlewares(bootstrap.GetServiceName(), bootstrap, l) - //if err == nil && len(middlewares) > 0 { - // opts = append(opts, http.Middleware(middlewares...)) - //} - - if l != nil { - opts = append(opts, gins.WithLogger(log.With(l, "module", "gins"))) - } - log.Infof("GetHostName: %s", env.Var(runtime.DefaultEnvPrefix, "host")) - host := env.Var(runtime.DefaultEnvPrefix, "host") - hostIP := env.GetEnv(env.Var(runtime.DefaultEnvPrefix, "host_ip")) - if hostIP == "" { - log.Debugf("HostIP is empty, replacing with HostAddr: %s", host) - hostIP = net.HostAddr(host) - log.Debugf("HostIP after replacement: %s", hostIP) - } - - var endpoint string - //if cfg.Endpoint == "" { - // endpoint, _ = helpers.ServiceEndpoint("http", hostIP, cfg.Addr) - //} else { - // endpoint = cfg.Endpoint - //} - log.Debugf("GINS.Endpoint: %v", endpoint) - ep, _ := url.Parse(endpoint) - opts = append(opts, gins.Endpoint(ep)) - srv := gins.NewServer(opts...) - //if register != nil { - // register(srv) - //} - return srv -} diff --git a/internal/mods/casbin/server/grpc.go b/internal/mods/casbin/server/grpc.go deleted file mode 100644 index 946afe7e..00000000 --- a/internal/mods/casbin/server/grpc.go +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - "origadmin/application/admin/internal/configs" -) - -// NewGRPCServer new a gRPC server. -func NewGRPCServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.OptionSetting) *service.GRPCServer { - srv, err := runtime.NewGRPCServiceServer(bootstrap.GetService(), ss...) - if err != nil { - panic(err) - } - return srv -} diff --git a/internal/mods/casbin/server/http.go b/internal/mods/casbin/server/http.go deleted file mode 100644 index 4c454419..00000000 --- a/internal/mods/casbin/server/http.go +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - "origadmin/application/admin/internal/configs" -) - -// NewHTTPServer new an HTTP server. -func NewHTTPServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.OptionSetting) *service.HTTPServer { - srv, err := runtime.NewHTTPServiceServer(bootstrap.GetService(), ss...) - if err != nil { - panic(err) - } - return srv -} diff --git a/internal/mods/casbin/server/server.go b/internal/mods/casbin/server/server.go deleted file mode 100644 index 2ebde995..00000000 --- a/internal/mods/casbin/server/server.go +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "github.com/go-kratos/kratos/v2/metadata" - "github.com/go-kratos/kratos/v2/transport" - "github.com/google/wire" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/service" - servicegrpc "github.com/origadmin/runtime/service/grpc" - servicehttp "github.com/origadmin/runtime/service/http" - "github.com/origadmin/toolkits/errors" - - "origadmin/application/admin/internal/configs" - casbinservice "origadmin/application/admin/internal/mods/casbin/service" -) - -const ( - // ServiceName is service name. - ServiceName = "casbin" -) - -var ( - // ProviderSet is server providers. - ProviderSet = wire.NewSet( - NewRegisterServer, - NewSystemClient, - NewSystemServer, - NewSystemServiceAgentClient) -) - -func init() { - runtime.RegisterService(ServiceName, service.DefaultServiceBuilder) -} - -func NewSystemServer(bootstrap *configs.Bootstrap, registers []service.ServerRegister, l log.KLogger) []transport.Server { - var servers []transport.Server - middlewares := middleware.NewServer(bootstrap.GetService().GetMiddleware()) - serviceConfig := bootstrap.GetService() - if serviceConfig == nil { - return servers - } - if serviceConfig.Name == "" { - serviceConfig.Name = ServiceName - } - ctx := context.Background() - if serv := NewGRPCServer(bootstrap, l, service.WithGRPC( - servicegrpc.WithMiddlewares(middlewares...), - servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), - )); serv != nil { - for i := range registers { - registers[i].GRPCServer(ctx, serv) - } - servers = append(servers, serv) - } - if serv := NewHTTPServer(bootstrap, l, service.WithHTTP( - servicehttp.WithMiddlewares(middlewares...), - servicehttp.WithPrefix(runtime.DefaultEnvPrefix), - )); serv != nil { - for i := range registers { - registers[i].HTTPServer(ctx, serv) - } - servers = append(servers, serv) - } - return servers -} - -type RegisterAgent struct { -} - -func (s RegisterAgent) GRPCServer(ctx context.Context, server *service.GRPCServer) { - log.Info("grpc server casbin init") -} - -func (s RegisterAgent) HTTPServer(ctx context.Context, server *service.HTTPServer) { - log.Info("http server casbin init") -} - -func (s RegisterAgent) Server(ctx context.Context, grpcServer *service.GRPCServer, httpServer *service.HTTPServer) { - s.HTTPServer(ctx, httpServer) - s.GRPCServer(ctx, grpcServer) -} - -func NewSystemServiceAgentClient(client *service.GRPCClient, l log.KLogger) (*RegisterAgent, error) { - register := RegisterAgent{} - return ®ister, nil -} - -func NewSystemClient(bootstrap *configs.Bootstrap, l log.KLogger) (*service.GRPCClient, error) { - entry := bootstrap.GetEntry() - if entry == nil { - return nil, errors.New("no entry") - } - - servers := bootstrap.GetServers() - if servers == nil { - return nil, errors.New("no servers") - } - registry := bootstrap.GetRegistry() - if registry == nil { - return nil, errors.New("no registry") - } - serviceConfig := &configv1.Service{ - Name: ServiceName, - Grpc: entry.GetGrpc(), - Http: entry.GetHttp(), - Selector: &configv1.Service_Selector{ - Version: "v1.0.0", - Builder: "bbr", - }, - } - if v, ok := bootstrap.GetServers()[ServiceName]; ok { - registry.ServiceName = v - } - log.Infof("service name: %s", registry.ServiceName) - discovery, err := runtime.NewDiscovery(registry) - if err != nil { - return nil, errors.Wrap(err, "create discovery") - } - var ms []middleware.KMiddleware - options := []servicegrpc.OptionSetting{ - servicegrpc.WithDiscovery(registry.ServiceName, discovery), - } - ms = append(ms, middleware.NewClient(bootstrap.GetMiddleware())...) - ms = append(ms, MiddlewareServer()) - if len(ms) > 0 { - options = append(options, servicegrpc.WithMiddlewares(ms...)) - } - client, err := runtime.NewGRPCServiceClient(context.Background(), serviceConfig, service.WithGRPC(options...)) - if err != nil { - return nil, errors.Wrap(err, "create menu grpc client") - } - return client, nil -} - -func MiddlewareServer() middleware.KMiddleware { - return func(handler middleware.KHandler) middleware.KHandler { - return func(ctx context.Context, req interface{}) (reply interface{}, err error) { - if md, ok := metadata.FromClientContext(ctx); ok { - log.Debugf("MiddlewareServer: found client context metadata: %+v", md) - // //for k, v := range md { - // // cmd[k] = v - // // log.Debugf("MiddlewareServer: adding key-value pair (%s, %s) to client context metadata", k, v) - // //} - // ctx = metadata.NewClientContext(ctx, cmd) - //log.Debugf("MiddlewareServer: updated client context metadata: %+v", md) - //} else { - // log.Debugf("MiddlewareServer: no client context metadata found") - } else { - log.Debugf("MiddlewareServer: no client context metadata found") - } - if md, ok := metadata.FromServerContext(ctx); ok { - log.Debugf("MiddlewareServer: found server context metadata: %+v", md) - } else { - log.Debugf("MiddlewareServer: no server context metadata found") - } - //log.Debugf("MiddlewareServer: calling handler function") - reply, err = handler(ctx, req) - //log.Debugf("MiddlewareServer: handler function returned reply: %+v, error: %v", reply, err) - return - } - } -} - -func NewRegisterServer(s1 *casbinservice.RegisterServer) []service.ServerRegister { - return []service.ServerRegister{ - s1, - } -} - -var _ service.ServerRegister = (*RegisterAgent)(nil) diff --git a/internal/mods/casbin/service/casbin-source.grpc.go b/internal/mods/casbin/service/casbin-source.grpc.go deleted file mode 100644 index b27d7e1d..00000000 --- a/internal/mods/casbin/service/casbin-source.grpc.go +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package service implements the functions, types, and interfaces for the moduls.enforcer. -package service - -import ( - "context" - "io" - - "github.com/casbin/casbin/v2" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - pb "origadmin/application/admin/api/v1/services/casbin" -) - -type CasbinSourceServiceServer struct { - pb.UnimplementedCasbinSourceServiceServer - - client pb.CasbinSourceServiceClient - enforcer *casbin.Enforcer -} - -func (c *CasbinSourceServiceServer) ListPolicies(ctx context.Context, - request *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { - return c.client.ListPolicies(ctx, request) -} - -func (c *CasbinSourceServiceServer) ListGroupings(ctx context.Context, - request *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, request) -} - -func (c *CasbinSourceServiceServer) StreamRules(request *pb.StreamRulesRequest, - g grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { - stream, err := c.client.StreamRules(g.Context(), request) - if err != nil { - return status.Errorf(codes.Unavailable, "connect server failed: %v", err) - } - - for { - rule, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - st, _ := status.FromError(err) - return status.Errorf(st.Code(), "recvied error: %v", st.Message()) - } - if err := g.Send(rule); err != nil { - if status.Code(err) == codes.Canceled { - _ = stream.CloseSend() - return nil - } - return status.Errorf(codes.Internal, "send data error: %v", err) - } - if c.enforcer != nil { - switch v := rule.RuleType.(type) { - case *pb.StreamRulesResponse_Policy: - _, _ = c.enforcer.AddPolicy(v.Policy.Params) - case *pb.StreamRulesResponse_Grouping: - _, _ = c.enforcer.AddGroupingPolicy(v.Grouping.Params) - } - } - } - return nil -} - -// NewCasbinSourceServiceServer new a menu service. -func NewCasbinSourceServiceServer(client pb.CasbinSourceServiceClient) *CasbinSourceServiceServer { - return &CasbinSourceServiceServer{client: client} -} - -// NewCasbinSourceServiceServerPB new a menu service. -func NewCasbinSourceServiceServerPB(client pb.CasbinSourceServiceClient) pb.CasbinSourceServiceServer { - return &CasbinSourceServiceServer{client: client} -} - -var _ pb.CasbinSourceServiceServer = (*CasbinSourceServiceServer)(nil) diff --git a/internal/mods/casbin/service/service.go b/internal/mods/casbin/service/service.go deleted file mode 100644 index 548f64da..00000000 --- a/internal/mods/casbin/service/service.go +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - - "github.com/google/wire" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/casbin" -) - -// ProviderSet is service providers. -var ProviderSet = wire.NewSet( - wire.Struct(new(RegisterServer), "*"), - NewCasbinSourceServiceServer, - NewCasbinSourceServiceServerPB, -) - -type RegisterServer struct { - CasbinSource pb.CasbinSourceServiceServer -} - -func (s RegisterServer) GRPCServer(ctx context.Context, server *service.GRPCServer) { - log.Info("grpc server system init") - pb.RegisterCasbinSourceServiceServer(server, s.CasbinSource) -} - -func (s RegisterServer) HTTPServer(ctx context.Context, server *service.HTTPServer) { - log.Info("http server system init") -} - -func (s RegisterServer) Server(ctx context.Context, grpcServer *service.GRPCServer, httpServer *service.HTTPServer) { - s.HTTPServer(ctx, httpServer) - s.GRPCServer(ctx, grpcServer) -} - -var _ service.ServerRegister = (*RegisterServer)(nil) diff --git a/internal/mods/system/biz/auth.biz.go b/internal/mods/system/biz/auth.biz.go index 50efeb99..9c86efe9 100644 --- a/internal/mods/system/biz/auth.biz.go +++ b/internal/mods/system/biz/auth.biz.go @@ -6,9 +6,10 @@ package biz import ( + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" @@ -46,7 +47,7 @@ func (biz AuthServiceBiz) ListAuthResources(ctx context.Context, in *pb.ListAuth if err := option.FromListRequest(in, biz.limiter); err != nil { return nil, err } - log.Info("ListAuths") + biz.log.Info("ListAuths") result, total, err := biz.dao.ListAuthResources(ctx, in, option) if err != nil { return nil, err @@ -54,7 +55,7 @@ func (biz AuthServiceBiz) ListAuthResources(ctx context.Context, in *pb.ListAuth return dto.ToListAuthResourcesResponse(result, in, total) } -// NewAuthServiceBiz new a Auth use case. -func NewAuthServiceBiz(repo dto.AuthRepo, logger log.KLogger) *AuthServiceBiz { - return &AuthServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger)} +// NewAuthServiceBiz new Auth use case. +func NewAuthServiceBiz(r runtime.Runtime, repo dto.AuthRepo) *AuthServiceBiz { + return &AuthServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.WithLogger("module", "biz/auth"))} } diff --git a/internal/mods/system/biz/resource.biz.go b/internal/mods/system/biz/resource.biz.go index 3df3b9ec..229deade 100644 --- a/internal/mods/system/biz/resource.biz.go +++ b/internal/mods/system/biz/resource.biz.go @@ -11,7 +11,7 @@ import ( "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/mods/system/dto" ) diff --git a/internal/mods/system/dal/auth.dal.go b/internal/mods/system/dal/auth.dal.go index 5ecc0a52..c1fc22bd 100644 --- a/internal/mods/system/dal/auth.dal.go +++ b/internal/mods/system/dal/auth.dal.go @@ -13,8 +13,8 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - _ "origadmin/application/admin/internal/mods/system/dal/entity/ent/runtime" + "origadmin/application/admin/internal/data/entity/ent" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/mods/system/dto" ) diff --git a/internal/mods/system/dal/casbin.dal.go b/internal/mods/system/dal/casbin.dal.go index 7adc91c4..8a84bee9 100644 --- a/internal/mods/system/dal/casbin.dal.go +++ b/internal/mods/system/dal/casbin.dal.go @@ -10,7 +10,7 @@ import ( "strconv" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" + "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/mods/system/dto" ) diff --git a/internal/mods/system/dal/dal.go b/internal/mods/system/dal/dal.go index f7c24f78..4e0f19ab 100644 --- a/internal/mods/system/dal/dal.go +++ b/internal/mods/system/dal/dal.go @@ -25,10 +25,10 @@ import ( "origadmin/application/admin/helpers/id" "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/department" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/mods/system/dto" ) @@ -97,7 +97,7 @@ func NewData(bootstrap *configs.Bootstrap, logger log.KLogger) (*Data, func(), e return nil, nil, errors.New("bootstrap is nil") } - cfg := bootstrap.GetData().GetDatabase() + cfg := bootstrap.GetStorage().GetDatabase() if cfg == nil { return nil, nil, errors.New("data source not found") } @@ -147,6 +147,9 @@ func NewDataWithClient(client *ent.Client) *Data { } } +/* <<<<<<<<<<<<<< ✨ Windsurf Command ⭐ >>>>>>>>>>>>>>>> */ +// InitDataFromPath . +/* <<<<<<<<<< 5ac4ba63-529d-41b7-890c-f5204968f606 >>>>>>>>>>> */ func (obj *Data) InitDataFromPath(ctx context.Context, path string, filters ...string) error { type data struct { name string diff --git a/internal/mods/system/dal/entity/ent/crud.go b/internal/mods/system/dal/entity/ent/crud.go deleted file mode 100644 index 1aa9b3b5..00000000 --- a/internal/mods/system/dal/entity/ent/crud.go +++ /dev/null @@ -1,3 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent diff --git a/internal/mods/system/dal/entity/ent/department/department.go b/internal/mods/system/dal/entity/ent/department/department.go deleted file mode 100644 index ea3a35e2..00000000 --- a/internal/mods/system/dal/entity/ent/department/department.go +++ /dev/null @@ -1,358 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package department - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the department type in the database. - Label = "department" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldKeyword holds the string denoting the keyword field in the database. - FieldKeyword = "keyword" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldTreePath holds the string denoting the tree_path field in the database. - FieldTreePath = "tree_path" - // FieldSequence holds the string denoting the sequence field in the database. - FieldSequence = "sequence" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" - // FieldLevel holds the string denoting the level field in the database. - FieldLevel = "level" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldParentID holds the string denoting the parent_id field in the database. - FieldParentID = "parent_id" - // EdgeUsers holds the string denoting the users edge name in mutations. - EdgeUsers = "users" - // EdgePositions holds the string denoting the positions edge name in mutations. - EdgePositions = "positions" - // EdgeParent holds the string denoting the parent edge name in mutations. - EdgeParent = "parent" - // EdgeChildren holds the string denoting the children edge name in mutations. - EdgeChildren = "children" - // EdgeUserDepartments holds the string denoting the user_departments edge name in mutations. - EdgeUserDepartments = "user_departments" - // Table holds the table name of the department in the database. - Table = "sys_departments" - // UsersTable is the table that holds the users relation/edge. The primary key declared below. - UsersTable = "sys_user_departments" - // UsersInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UsersInverseTable = "sys_users" - // PositionsTable is the table that holds the positions relation/edge. - PositionsTable = "sys_positions" - // PositionsInverseTable is the table name for the Position entity. - // It exists in this package in order to avoid circular dependency with the "position" package. - PositionsInverseTable = "sys_positions" - // PositionsColumn is the table column denoting the positions relation/edge. - PositionsColumn = "department_id" - // ParentTable is the table that holds the parent relation/edge. - ParentTable = "sys_departments" - // ParentColumn is the table column denoting the parent relation/edge. - ParentColumn = "parent_id" - // ChildrenTable is the table that holds the children relation/edge. - ChildrenTable = "sys_departments" - // ChildrenColumn is the table column denoting the children relation/edge. - ChildrenColumn = "parent_id" - // UserDepartmentsTable is the table that holds the user_departments relation/edge. - UserDepartmentsTable = "sys_user_departments" - // UserDepartmentsInverseTable is the table name for the UserDepartment entity. - // It exists in this package in order to avoid circular dependency with the "userdepartment" package. - UserDepartmentsInverseTable = "sys_user_departments" - // UserDepartmentsColumn is the table column denoting the user_departments relation/edge. - UserDepartmentsColumn = "department_id" -) - -// Columns holds all SQL columns for department fields. -var Columns = []string{ - FieldID, - FieldCreateTime, - FieldUpdateTime, - FieldKeyword, - FieldName, - FieldTreePath, - FieldSequence, - FieldStatus, - FieldLevel, - FieldDescription, - FieldParentID, -} - -var ( - // UsersPrimaryKey and UsersColumn2 are the table columns denoting the - // primary key for the users relation (M2M). - UsersPrimaryKey = []string{"user_id", "department_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() time.Time - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() time.Time - // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. - UpdateDefaultUpdateTime func() time.Time - // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - KeywordValidator func(string) error - // DefaultName holds the default value on creation for the "name" field. - DefaultName string - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // DefaultTreePath holds the default value on creation for the "tree_path" field. - DefaultTreePath string - // TreePathValidator is a validator for the "tree_path" field. It is called by the builders before save. - TreePathValidator func(string) error - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 - // DefaultLevel holds the default value on creation for the "level" field. - DefaultLevel int - // DefaultDescription holds the default value on creation for the "description" field. - DefaultDescription string - // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - DescriptionValidator func(string) error - // ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. - ParentIDValidator func(int64) error - // DefaultID holds the default value on creation for the "id" field. - DefaultID func() int64 - // IDValidator is a validator for the "id" field. It is called by the builders before save. - IDValidator func(int64) error -) - -// OrderOption defines the ordering options for the Department queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByKeyword orders the results by the keyword field. -func ByKeyword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldKeyword, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByTreePath orders the results by the tree_path field. -func ByTreePath(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTreePath, opts...).ToFunc() -} - -// BySequence orders the results by the sequence field. -func BySequence(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSequence, opts...).ToFunc() -} - -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - -// ByLevel orders the results by the level field. -func ByLevel(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldLevel, opts...).ToFunc() -} - -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() -} - -// ByParentID orders the results by the parent_id field. -func ByParentID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldParentID, opts...).ToFunc() -} - -// ByUsersCount orders the results by users count. -func ByUsersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...) - } -} - -// ByUsers orders the results by users terms. -func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPositionsCount orders the results by positions count. -func ByPositionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPositionsStep(), opts...) - } -} - -// ByPositions orders the results by positions terms. -func ByPositions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPositionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByParentField orders the results by parent field. -func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) - } -} - -// ByChildrenCount orders the results by children count. -func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) - } -} - -// ByChildren orders the results by children terms. -func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByUserDepartmentsCount orders the results by user_departments count. -func ByUserDepartmentsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUserDepartmentsStep(), opts...) - } -} - -// ByUserDepartments orders the results by user_departments terms. -func ByUserDepartments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserDepartmentsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newUsersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UsersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), - ) -} -func newPositionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PositionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, PositionsTable, PositionsColumn), - ) -} -func newParentStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), - ) -} -func newChildrenStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), - ) -} -func newUserDepartmentsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserDepartmentsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserDepartmentsTable, UserDepartmentsColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/department/where.go b/internal/mods/system/dal/entity/ent/department/where.go deleted file mode 100644 index 0f470e6d..00000000 --- a/internal/mods/system/dal/entity/ent/department/where.go +++ /dev/null @@ -1,726 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package department - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.Department { - return predicate.Department(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.Department { - return predicate.Department(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.Department { - return predicate.Department(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.Department { - return predicate.Department(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.Department { - return predicate.Department(sql.FieldLTE(FieldID, id)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v time.Time) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v time.Time) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldUpdateTime, v)) -} - -// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. -func Keyword(v string) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldKeyword, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldName, v)) -} - -// TreePath applies equality check predicate on the "tree_path" field. It's identical to TreePathEQ. -func TreePath(v string) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldTreePath, v)) -} - -// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. -func Sequence(v int) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldSequence, v)) -} - -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldStatus, v)) -} - -// Level applies equality check predicate on the "level" field. It's identical to LevelEQ. -func Level(v int) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldLevel, v)) -} - -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldDescription, v)) -} - -// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ. -func ParentID(v int64) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldParentID, v)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v time.Time) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v time.Time) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...time.Time) predicate.Department { - return predicate.Department(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...time.Time) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v time.Time) predicate.Department { - return predicate.Department(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v time.Time) predicate.Department { - return predicate.Department(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v time.Time) predicate.Department { - return predicate.Department(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v time.Time) predicate.Department { - return predicate.Department(sql.FieldLTE(FieldCreateTime, v)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v time.Time) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v time.Time) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...time.Time) predicate.Department { - return predicate.Department(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...time.Time) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v time.Time) predicate.Department { - return predicate.Department(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v time.Time) predicate.Department { - return predicate.Department(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v time.Time) predicate.Department { - return predicate.Department(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v time.Time) predicate.Department { - return predicate.Department(sql.FieldLTE(FieldUpdateTime, v)) -} - -// KeywordEQ applies the EQ predicate on the "keyword" field. -func KeywordEQ(v string) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldKeyword, v)) -} - -// KeywordNEQ applies the NEQ predicate on the "keyword" field. -func KeywordNEQ(v string) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldKeyword, v)) -} - -// KeywordIn applies the In predicate on the "keyword" field. -func KeywordIn(vs ...string) predicate.Department { - return predicate.Department(sql.FieldIn(FieldKeyword, vs...)) -} - -// KeywordNotIn applies the NotIn predicate on the "keyword" field. -func KeywordNotIn(vs ...string) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldKeyword, vs...)) -} - -// KeywordGT applies the GT predicate on the "keyword" field. -func KeywordGT(v string) predicate.Department { - return predicate.Department(sql.FieldGT(FieldKeyword, v)) -} - -// KeywordGTE applies the GTE predicate on the "keyword" field. -func KeywordGTE(v string) predicate.Department { - return predicate.Department(sql.FieldGTE(FieldKeyword, v)) -} - -// KeywordLT applies the LT predicate on the "keyword" field. -func KeywordLT(v string) predicate.Department { - return predicate.Department(sql.FieldLT(FieldKeyword, v)) -} - -// KeywordLTE applies the LTE predicate on the "keyword" field. -func KeywordLTE(v string) predicate.Department { - return predicate.Department(sql.FieldLTE(FieldKeyword, v)) -} - -// KeywordContains applies the Contains predicate on the "keyword" field. -func KeywordContains(v string) predicate.Department { - return predicate.Department(sql.FieldContains(FieldKeyword, v)) -} - -// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. -func KeywordHasPrefix(v string) predicate.Department { - return predicate.Department(sql.FieldHasPrefix(FieldKeyword, v)) -} - -// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. -func KeywordHasSuffix(v string) predicate.Department { - return predicate.Department(sql.FieldHasSuffix(FieldKeyword, v)) -} - -// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. -func KeywordEqualFold(v string) predicate.Department { - return predicate.Department(sql.FieldEqualFold(FieldKeyword, v)) -} - -// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. -func KeywordContainsFold(v string) predicate.Department { - return predicate.Department(sql.FieldContainsFold(FieldKeyword, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Department { - return predicate.Department(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Department { - return predicate.Department(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Department { - return predicate.Department(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Department { - return predicate.Department(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Department { - return predicate.Department(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Department { - return predicate.Department(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Department { - return predicate.Department(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Department { - return predicate.Department(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Department { - return predicate.Department(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Department { - return predicate.Department(sql.FieldContainsFold(FieldName, v)) -} - -// TreePathEQ applies the EQ predicate on the "tree_path" field. -func TreePathEQ(v string) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldTreePath, v)) -} - -// TreePathNEQ applies the NEQ predicate on the "tree_path" field. -func TreePathNEQ(v string) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldTreePath, v)) -} - -// TreePathIn applies the In predicate on the "tree_path" field. -func TreePathIn(vs ...string) predicate.Department { - return predicate.Department(sql.FieldIn(FieldTreePath, vs...)) -} - -// TreePathNotIn applies the NotIn predicate on the "tree_path" field. -func TreePathNotIn(vs ...string) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldTreePath, vs...)) -} - -// TreePathGT applies the GT predicate on the "tree_path" field. -func TreePathGT(v string) predicate.Department { - return predicate.Department(sql.FieldGT(FieldTreePath, v)) -} - -// TreePathGTE applies the GTE predicate on the "tree_path" field. -func TreePathGTE(v string) predicate.Department { - return predicate.Department(sql.FieldGTE(FieldTreePath, v)) -} - -// TreePathLT applies the LT predicate on the "tree_path" field. -func TreePathLT(v string) predicate.Department { - return predicate.Department(sql.FieldLT(FieldTreePath, v)) -} - -// TreePathLTE applies the LTE predicate on the "tree_path" field. -func TreePathLTE(v string) predicate.Department { - return predicate.Department(sql.FieldLTE(FieldTreePath, v)) -} - -// TreePathContains applies the Contains predicate on the "tree_path" field. -func TreePathContains(v string) predicate.Department { - return predicate.Department(sql.FieldContains(FieldTreePath, v)) -} - -// TreePathHasPrefix applies the HasPrefix predicate on the "tree_path" field. -func TreePathHasPrefix(v string) predicate.Department { - return predicate.Department(sql.FieldHasPrefix(FieldTreePath, v)) -} - -// TreePathHasSuffix applies the HasSuffix predicate on the "tree_path" field. -func TreePathHasSuffix(v string) predicate.Department { - return predicate.Department(sql.FieldHasSuffix(FieldTreePath, v)) -} - -// TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. -func TreePathEqualFold(v string) predicate.Department { - return predicate.Department(sql.FieldEqualFold(FieldTreePath, v)) -} - -// TreePathContainsFold applies the ContainsFold predicate on the "tree_path" field. -func TreePathContainsFold(v string) predicate.Department { - return predicate.Department(sql.FieldContainsFold(FieldTreePath, v)) -} - -// SequenceEQ applies the EQ predicate on the "sequence" field. -func SequenceEQ(v int) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldSequence, v)) -} - -// SequenceNEQ applies the NEQ predicate on the "sequence" field. -func SequenceNEQ(v int) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldSequence, v)) -} - -// SequenceIn applies the In predicate on the "sequence" field. -func SequenceIn(vs ...int) predicate.Department { - return predicate.Department(sql.FieldIn(FieldSequence, vs...)) -} - -// SequenceNotIn applies the NotIn predicate on the "sequence" field. -func SequenceNotIn(vs ...int) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldSequence, vs...)) -} - -// SequenceGT applies the GT predicate on the "sequence" field. -func SequenceGT(v int) predicate.Department { - return predicate.Department(sql.FieldGT(FieldSequence, v)) -} - -// SequenceGTE applies the GTE predicate on the "sequence" field. -func SequenceGTE(v int) predicate.Department { - return predicate.Department(sql.FieldGTE(FieldSequence, v)) -} - -// SequenceLT applies the LT predicate on the "sequence" field. -func SequenceLT(v int) predicate.Department { - return predicate.Department(sql.FieldLT(FieldSequence, v)) -} - -// SequenceLTE applies the LTE predicate on the "sequence" field. -func SequenceLTE(v int) predicate.Department { - return predicate.Department(sql.FieldLTE(FieldSequence, v)) -} - -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.Department { - return predicate.Department(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldStatus, vs...)) -} - -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.Department { - return predicate.Department(sql.FieldGT(FieldStatus, v)) -} - -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.Department { - return predicate.Department(sql.FieldGTE(FieldStatus, v)) -} - -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.Department { - return predicate.Department(sql.FieldLT(FieldStatus, v)) -} - -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.Department { - return predicate.Department(sql.FieldLTE(FieldStatus, v)) -} - -// LevelEQ applies the EQ predicate on the "level" field. -func LevelEQ(v int) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldLevel, v)) -} - -// LevelNEQ applies the NEQ predicate on the "level" field. -func LevelNEQ(v int) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldLevel, v)) -} - -// LevelIn applies the In predicate on the "level" field. -func LevelIn(vs ...int) predicate.Department { - return predicate.Department(sql.FieldIn(FieldLevel, vs...)) -} - -// LevelNotIn applies the NotIn predicate on the "level" field. -func LevelNotIn(vs ...int) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldLevel, vs...)) -} - -// LevelGT applies the GT predicate on the "level" field. -func LevelGT(v int) predicate.Department { - return predicate.Department(sql.FieldGT(FieldLevel, v)) -} - -// LevelGTE applies the GTE predicate on the "level" field. -func LevelGTE(v int) predicate.Department { - return predicate.Department(sql.FieldGTE(FieldLevel, v)) -} - -// LevelLT applies the LT predicate on the "level" field. -func LevelLT(v int) predicate.Department { - return predicate.Department(sql.FieldLT(FieldLevel, v)) -} - -// LevelLTE applies the LTE predicate on the "level" field. -func LevelLTE(v int) predicate.Department { - return predicate.Department(sql.FieldLTE(FieldLevel, v)) -} - -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldDescription, v)) -} - -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldDescription, v)) -} - -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.Department { - return predicate.Department(sql.FieldIn(FieldDescription, vs...)) -} - -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldDescription, vs...)) -} - -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.Department { - return predicate.Department(sql.FieldGT(FieldDescription, v)) -} - -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.Department { - return predicate.Department(sql.FieldGTE(FieldDescription, v)) -} - -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.Department { - return predicate.Department(sql.FieldLT(FieldDescription, v)) -} - -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.Department { - return predicate.Department(sql.FieldLTE(FieldDescription, v)) -} - -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.Department { - return predicate.Department(sql.FieldContains(FieldDescription, v)) -} - -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.Department { - return predicate.Department(sql.FieldHasPrefix(FieldDescription, v)) -} - -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.Department { - return predicate.Department(sql.FieldHasSuffix(FieldDescription, v)) -} - -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.Department { - return predicate.Department(sql.FieldEqualFold(FieldDescription, v)) -} - -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.Department { - return predicate.Department(sql.FieldContainsFold(FieldDescription, v)) -} - -// ParentIDEQ applies the EQ predicate on the "parent_id" field. -func ParentIDEQ(v int64) predicate.Department { - return predicate.Department(sql.FieldEQ(FieldParentID, v)) -} - -// ParentIDNEQ applies the NEQ predicate on the "parent_id" field. -func ParentIDNEQ(v int64) predicate.Department { - return predicate.Department(sql.FieldNEQ(FieldParentID, v)) -} - -// ParentIDIn applies the In predicate on the "parent_id" field. -func ParentIDIn(vs ...int64) predicate.Department { - return predicate.Department(sql.FieldIn(FieldParentID, vs...)) -} - -// ParentIDNotIn applies the NotIn predicate on the "parent_id" field. -func ParentIDNotIn(vs ...int64) predicate.Department { - return predicate.Department(sql.FieldNotIn(FieldParentID, vs...)) -} - -// ParentIDIsNil applies the IsNil predicate on the "parent_id" field. -func ParentIDIsNil() predicate.Department { - return predicate.Department(sql.FieldIsNull(FieldParentID)) -} - -// ParentIDNotNil applies the NotNil predicate on the "parent_id" field. -func ParentIDNotNil() predicate.Department { - return predicate.Department(sql.FieldNotNull(FieldParentID)) -} - -// HasUsers applies the HasEdge predicate on the "users" edge. -func HasUsers() predicate.Department { - return predicate.Department(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUsersWith applies the HasEdge predicate on the "users" edge with a given conditions (other predicates). -func HasUsersWith(preds ...predicate.User) predicate.Department { - return predicate.Department(func(s *sql.Selector) { - step := newUsersStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPositions applies the HasEdge predicate on the "positions" edge. -func HasPositions() predicate.Department { - return predicate.Department(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, PositionsTable, PositionsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPositionsWith applies the HasEdge predicate on the "positions" edge with a given conditions (other predicates). -func HasPositionsWith(preds ...predicate.Position) predicate.Department { - return predicate.Department(func(s *sql.Selector) { - step := newPositionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasParent applies the HasEdge predicate on the "parent" edge. -func HasParent() predicate.Department { - return predicate.Department(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). -func HasParentWith(preds ...predicate.Department) predicate.Department { - return predicate.Department(func(s *sql.Selector) { - step := newParentStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasChildren applies the HasEdge predicate on the "children" edge. -func HasChildren() predicate.Department { - return predicate.Department(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates). -func HasChildrenWith(preds ...predicate.Department) predicate.Department { - return predicate.Department(func(s *sql.Selector) { - step := newChildrenStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasUserDepartments applies the HasEdge predicate on the "user_departments" edge. -func HasUserDepartments() predicate.Department { - return predicate.Department(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserDepartmentsTable, UserDepartmentsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserDepartmentsWith applies the HasEdge predicate on the "user_departments" edge with a given conditions (other predicates). -func HasUserDepartmentsWith(preds ...predicate.UserDepartment) predicate.Department { - return predicate.Department(func(s *sql.Selector) { - step := newUserDepartmentsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Department) predicate.Department { - return predicate.Department(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Department) predicate.Department { - return predicate.Department(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Department) predicate.Department { - return predicate.Department(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/generate.go b/internal/mods/system/dal/entity/ent/generate.go deleted file mode 100644 index 570bd0ed..00000000 --- a/internal/mods/system/dal/entity/ent/generate.go +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package ent is the data access object for SYS. -package ent - -//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --template ./template --feature intercept --feature schema/snapshot --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema diff --git a/internal/mods/system/dal/entity/ent/internal/schema.go b/internal/mods/system/dal/entity/ent/internal/schema.go deleted file mode 100644 index 5bccde46..00000000 --- a/internal/mods/system/dal/entity/ent/internal/schema.go +++ /dev/null @@ -1,9 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -//go:build tools -// +build tools - -// Package internal holds a loadable version of the latest schema. -package internal - -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/mods/system/dal/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/mods/system/dal/entity/ent\",\"Schemas\":[{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"children\",\"type\":\"Resource\"},{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref_name\":\"children\",\"unique\":true,\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"i18n_key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n_key\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2,\"default\":true,\"default_value\":\"M\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.component\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.icon\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.visible\"},{\"name\":\"level\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.level\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"properties\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"resource.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"parent_id\"]},{\"fields\":[\"level\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"delete_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/mods/system/dal/entity/ent/migrate/migrate.go b/internal/mods/system/dal/entity/ent/migrate/migrate.go deleted file mode 100644 index d8d3bcb8..00000000 --- a/internal/mods/system/dal/entity/ent/migrate/migrate.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package migrate - -import ( - "context" - "fmt" - "io" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql/schema" -) - -var ( - // WithGlobalUniqueID sets the universal ids options to the migration. - // If this option is enabled, ent migration will allocate a 1<<32 range - // for the ids of each entity (table). - // Note that this option cannot be applied on tables that already exist. - WithGlobalUniqueID = schema.WithGlobalUniqueID - // WithDropColumn sets the drop column option to the migration. - // If this option is enabled, ent migration will drop old columns - // that were used for both fields and edges. This defaults to false. - WithDropColumn = schema.WithDropColumn - // WithDropIndex sets the drop index option to the migration. - // If this option is enabled, ent migration will drop old indexes - // that were defined in the schema. This defaults to false. - // Note that unique constraints are defined using `UNIQUE INDEX`, - // and therefore, it's recommended to enable this option to get more - // flexibility in the schema changes. - WithDropIndex = schema.WithDropIndex - // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. - WithForeignKeys = schema.WithForeignKeys -) - -// Schema is the API for creating, migrating and dropping a schema. -type Schema struct { - drv dialect.Driver -} - -// NewSchema creates a new schema client. -func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } - -// Create creates all schema resources. -func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { - return Create(ctx, s, Tables, opts...) -} - -// Create creates all table resources using the given schema driver. -func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { - migrate, err := schema.NewMigrate(s.drv, opts...) - if err != nil { - return fmt.Errorf("ent/migrate: %w", err) - } - return migrate.Create(ctx, tables...) -} - -// Diff compares the state read from a database connection or migration directory with -// the state defined by the Ent schema. Changes will be written to new migration files. -func Diff(ctx context.Context, url string, opts ...schema.MigrateOption) error { - return NamedDiff(ctx, url, "changes", opts...) -} - -// NamedDiff compares the state read from a database connection or migration directory with -// the state defined by the Ent schema. Changes will be written to new named migration files. -func NamedDiff(ctx context.Context, url, name string, opts ...schema.MigrateOption) error { - return schema.Diff(ctx, url, name, Tables, opts...) -} - -// Diff creates a migration file containing the statements to resolve the diff -// between the Ent schema and the connected database. -func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error { - migrate, err := schema.NewMigrate(s.drv, opts...) - if err != nil { - return fmt.Errorf("ent/migrate: %w", err) - } - return migrate.Diff(ctx, Tables...) -} - -// NamedDiff creates a named migration file containing the statements to resolve the diff -// between the Ent schema and the connected database. -func (s *Schema) NamedDiff(ctx context.Context, name string, opts ...schema.MigrateOption) error { - migrate, err := schema.NewMigrate(s.drv, opts...) - if err != nil { - return fmt.Errorf("ent/migrate: %w", err) - } - return migrate.NamedDiff(ctx, name, Tables...) -} - -// WriteTo writes the schema changes to w instead of running them against the database. -// -// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { -// log.Fatal(err) -// } -func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { - return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) -} diff --git a/internal/mods/system/dal/entity/ent/permission/permission.go b/internal/mods/system/dal/entity/ent/permission/permission.go deleted file mode 100644 index 45cd170f..00000000 --- a/internal/mods/system/dal/entity/ent/permission/permission.go +++ /dev/null @@ -1,403 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package permission - -import ( - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the permission type in the database. - Label = "permission" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldKeyword holds the string denoting the keyword field in the database. - FieldKeyword = "keyword" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldDataScope holds the string denoting the data_scope field in the database. - FieldDataScope = "data_scope" - // FieldDataRules holds the string denoting the data_rules field in the database. - FieldDataRules = "data_rules" - // FieldActions holds the string denoting the actions field in the database. - FieldActions = "actions" - // EdgeRoles holds the string denoting the roles edge name in mutations. - EdgeRoles = "roles" - // EdgePositions holds the string denoting the positions edge name in mutations. - EdgePositions = "positions" - // EdgeResources holds the string denoting the resources edge name in mutations. - EdgeResources = "resources" - // EdgeRolePermissions holds the string denoting the role_permissions edge name in mutations. - EdgeRolePermissions = "role_permissions" - // EdgePositionPermissions holds the string denoting the position_permissions edge name in mutations. - EdgePositionPermissions = "position_permissions" - // EdgePermissionResources holds the string denoting the permission_resources edge name in mutations. - EdgePermissionResources = "permission_resources" - // Table holds the table name of the permission in the database. - Table = "sys_permissions" - // RolesTable is the table that holds the roles relation/edge. The primary key declared below. - RolesTable = "sys_role_permissions" - // RolesInverseTable is the table name for the Role entity. - // It exists in this package in order to avoid circular dependency with the "role" package. - RolesInverseTable = "sys_roles" - // PositionsTable is the table that holds the positions relation/edge. The primary key declared below. - PositionsTable = "sys_position_permissions" - // PositionsInverseTable is the table name for the Position entity. - // It exists in this package in order to avoid circular dependency with the "position" package. - PositionsInverseTable = "sys_positions" - // ResourcesTable is the table that holds the resources relation/edge. The primary key declared below. - ResourcesTable = "sys_permission_resources" - // ResourcesInverseTable is the table name for the Resource entity. - // It exists in this package in order to avoid circular dependency with the "resource" package. - ResourcesInverseTable = "sys_resources" - // RolePermissionsTable is the table that holds the role_permissions relation/edge. - RolePermissionsTable = "sys_role_permissions" - // RolePermissionsInverseTable is the table name for the RolePermission entity. - // It exists in this package in order to avoid circular dependency with the "rolepermission" package. - RolePermissionsInverseTable = "sys_role_permissions" - // RolePermissionsColumn is the table column denoting the role_permissions relation/edge. - RolePermissionsColumn = "permission_id" - // PositionPermissionsTable is the table that holds the position_permissions relation/edge. - PositionPermissionsTable = "sys_position_permissions" - // PositionPermissionsInverseTable is the table name for the PositionPermission entity. - // It exists in this package in order to avoid circular dependency with the "positionpermission" package. - PositionPermissionsInverseTable = "sys_position_permissions" - // PositionPermissionsColumn is the table column denoting the position_permissions relation/edge. - PositionPermissionsColumn = "permission_id" - // PermissionResourcesTable is the table that holds the permission_resources relation/edge. - PermissionResourcesTable = "sys_permission_resources" - // PermissionResourcesInverseTable is the table name for the PermissionResource entity. - // It exists in this package in order to avoid circular dependency with the "permissionresource" package. - PermissionResourcesInverseTable = "sys_permission_resources" - // PermissionResourcesColumn is the table column denoting the permission_resources relation/edge. - PermissionResourcesColumn = "permission_id" -) - -// Columns holds all SQL columns for permission fields. -var Columns = []string{ - FieldID, - FieldCreateTime, - FieldUpdateTime, - FieldName, - FieldKeyword, - FieldDescription, - FieldDataScope, - FieldDataRules, - FieldActions, -} - -var ( - // RolesPrimaryKey and RolesColumn2 are the table columns denoting the - // primary key for the roles relation (M2M). - RolesPrimaryKey = []string{"role_id", "permission_id"} - // PositionsPrimaryKey and PositionsColumn2 are the table columns denoting the - // primary key for the positions relation (M2M). - PositionsPrimaryKey = []string{"position_id", "permission_id"} - // ResourcesPrimaryKey and ResourcesColumn2 are the table columns denoting the - // primary key for the resources relation (M2M). - ResourcesPrimaryKey = []string{"permission_id", "resource_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() time.Time - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() time.Time - // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. - UpdateDefaultUpdateTime func() time.Time - // DefaultName holds the default value on creation for the "name" field. - DefaultName string - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - KeywordValidator func(string) error - // DefaultDescription holds the default value on creation for the "description" field. - DefaultDescription string - // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - DescriptionValidator func(string) error - // DefaultDataScope holds the default value on creation for the "data_scope" field. - DefaultDataScope string - // DefaultID holds the default value on creation for the "id" field. - DefaultID func() int64 - // IDValidator is a validator for the "id" field. It is called by the builders before save. - IDValidator func(int64) error -) - -// Actions defines the type for the "actions" enum field. -type Actions string - -// ActionsRead is the default value of the Actions enum. -const DefaultActions = ActionsRead - -// Actions values. -const ( - ActionsRead Actions = "read" - ActionsWrite Actions = "write" - ActionsDelete Actions = "delete" - ActionsManage Actions = "manage" -) - -func (a Actions) String() string { - return string(a) -} - -// ActionsValidator is a validator for the "actions" field enum values. It is called by the builders before save. -func ActionsValidator(a Actions) error { - switch a { - case ActionsRead, ActionsWrite, ActionsDelete, ActionsManage: - return nil - default: - return fmt.Errorf("permission: invalid enum value for actions field: %q", a) - } -} - -// OrderOption defines the ordering options for the Permission queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByKeyword orders the results by the keyword field. -func ByKeyword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldKeyword, opts...).ToFunc() -} - -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() -} - -// ByDataScope orders the results by the data_scope field. -func ByDataScope(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDataScope, opts...).ToFunc() -} - -// ByActions orders the results by the actions field. -func ByActions(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldActions, opts...).ToFunc() -} - -// ByRolesCount orders the results by roles count. -func ByRolesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...) - } -} - -// ByRoles orders the results by roles terms. -func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPositionsCount orders the results by positions count. -func ByPositionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPositionsStep(), opts...) - } -} - -// ByPositions orders the results by positions terms. -func ByPositions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPositionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByResourcesCount orders the results by resources count. -func ByResourcesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newResourcesStep(), opts...) - } -} - -// ByResources orders the results by resources terms. -func ByResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByRolePermissionsCount orders the results by role_permissions count. -func ByRolePermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newRolePermissionsStep(), opts...) - } -} - -// ByRolePermissions orders the results by role_permissions terms. -func ByRolePermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRolePermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPositionPermissionsCount orders the results by position_permissions count. -func ByPositionPermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPositionPermissionsStep(), opts...) - } -} - -// ByPositionPermissions orders the results by position_permissions terms. -func ByPositionPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPositionPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPermissionResourcesCount orders the results by permission_resources count. -func ByPermissionResourcesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPermissionResourcesStep(), opts...) - } -} - -// ByPermissionResources orders the results by permission_resources terms. -func ByPermissionResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newRolesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RolesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, RolesTable, RolesPrimaryKey...), - ) -} -func newPositionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PositionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, PositionsTable, PositionsPrimaryKey...), - ) -} -func newResourcesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(ResourcesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), - ) -} -func newRolePermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RolePermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), - ) -} -func newPositionPermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PositionPermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PositionPermissionsTable, PositionPermissionsColumn), - ) -} -func newPermissionResourcesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionResourcesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/permission/where.go b/internal/mods/system/dal/entity/ent/permission/where.go deleted file mode 100644 index 957803e8..00000000 --- a/internal/mods/system/dal/entity/ent/permission/where.go +++ /dev/null @@ -1,609 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package permission - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldID, id)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldUpdateTime, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldName, v)) -} - -// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. -func Keyword(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldKeyword, v)) -} - -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldDescription, v)) -} - -// DataScope applies equality check predicate on the "data_scope" field. It's identical to DataScopeEQ. -func DataScope(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldDataScope, v)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...time.Time) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...time.Time) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldCreateTime, v)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...time.Time) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...time.Time) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldUpdateTime, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Permission { - return predicate.Permission(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldContainsFold(FieldName, v)) -} - -// KeywordEQ applies the EQ predicate on the "keyword" field. -func KeywordEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldKeyword, v)) -} - -// KeywordNEQ applies the NEQ predicate on the "keyword" field. -func KeywordNEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldKeyword, v)) -} - -// KeywordIn applies the In predicate on the "keyword" field. -func KeywordIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldKeyword, vs...)) -} - -// KeywordNotIn applies the NotIn predicate on the "keyword" field. -func KeywordNotIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldKeyword, vs...)) -} - -// KeywordGT applies the GT predicate on the "keyword" field. -func KeywordGT(v string) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldKeyword, v)) -} - -// KeywordGTE applies the GTE predicate on the "keyword" field. -func KeywordGTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldKeyword, v)) -} - -// KeywordLT applies the LT predicate on the "keyword" field. -func KeywordLT(v string) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldKeyword, v)) -} - -// KeywordLTE applies the LTE predicate on the "keyword" field. -func KeywordLTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldKeyword, v)) -} - -// KeywordContains applies the Contains predicate on the "keyword" field. -func KeywordContains(v string) predicate.Permission { - return predicate.Permission(sql.FieldContains(FieldKeyword, v)) -} - -// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. -func KeywordHasPrefix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasPrefix(FieldKeyword, v)) -} - -// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. -func KeywordHasSuffix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasSuffix(FieldKeyword, v)) -} - -// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. -func KeywordEqualFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldEqualFold(FieldKeyword, v)) -} - -// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. -func KeywordContainsFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldContainsFold(FieldKeyword, v)) -} - -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldDescription, v)) -} - -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldDescription, v)) -} - -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldDescription, vs...)) -} - -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldDescription, vs...)) -} - -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldDescription, v)) -} - -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldDescription, v)) -} - -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldDescription, v)) -} - -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldDescription, v)) -} - -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.Permission { - return predicate.Permission(sql.FieldContains(FieldDescription, v)) -} - -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasPrefix(FieldDescription, v)) -} - -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasSuffix(FieldDescription, v)) -} - -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldEqualFold(FieldDescription, v)) -} - -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldContainsFold(FieldDescription, v)) -} - -// DataScopeEQ applies the EQ predicate on the "data_scope" field. -func DataScopeEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldDataScope, v)) -} - -// DataScopeNEQ applies the NEQ predicate on the "data_scope" field. -func DataScopeNEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldDataScope, v)) -} - -// DataScopeIn applies the In predicate on the "data_scope" field. -func DataScopeIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldDataScope, vs...)) -} - -// DataScopeNotIn applies the NotIn predicate on the "data_scope" field. -func DataScopeNotIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldDataScope, vs...)) -} - -// DataScopeGT applies the GT predicate on the "data_scope" field. -func DataScopeGT(v string) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldDataScope, v)) -} - -// DataScopeGTE applies the GTE predicate on the "data_scope" field. -func DataScopeGTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldDataScope, v)) -} - -// DataScopeLT applies the LT predicate on the "data_scope" field. -func DataScopeLT(v string) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldDataScope, v)) -} - -// DataScopeLTE applies the LTE predicate on the "data_scope" field. -func DataScopeLTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldDataScope, v)) -} - -// DataScopeContains applies the Contains predicate on the "data_scope" field. -func DataScopeContains(v string) predicate.Permission { - return predicate.Permission(sql.FieldContains(FieldDataScope, v)) -} - -// DataScopeHasPrefix applies the HasPrefix predicate on the "data_scope" field. -func DataScopeHasPrefix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasPrefix(FieldDataScope, v)) -} - -// DataScopeHasSuffix applies the HasSuffix predicate on the "data_scope" field. -func DataScopeHasSuffix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasSuffix(FieldDataScope, v)) -} - -// DataScopeEqualFold applies the EqualFold predicate on the "data_scope" field. -func DataScopeEqualFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldEqualFold(FieldDataScope, v)) -} - -// DataScopeContainsFold applies the ContainsFold predicate on the "data_scope" field. -func DataScopeContainsFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldContainsFold(FieldDataScope, v)) -} - -// DataRulesIsNil applies the IsNil predicate on the "data_rules" field. -func DataRulesIsNil() predicate.Permission { - return predicate.Permission(sql.FieldIsNull(FieldDataRules)) -} - -// DataRulesNotNil applies the NotNil predicate on the "data_rules" field. -func DataRulesNotNil() predicate.Permission { - return predicate.Permission(sql.FieldNotNull(FieldDataRules)) -} - -// ActionsEQ applies the EQ predicate on the "actions" field. -func ActionsEQ(v Actions) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldActions, v)) -} - -// ActionsNEQ applies the NEQ predicate on the "actions" field. -func ActionsNEQ(v Actions) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldActions, v)) -} - -// ActionsIn applies the In predicate on the "actions" field. -func ActionsIn(vs ...Actions) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldActions, vs...)) -} - -// ActionsNotIn applies the NotIn predicate on the "actions" field. -func ActionsNotIn(vs ...Actions) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldActions, vs...)) -} - -// HasRoles applies the HasEdge predicate on the "roles" edge. -func HasRoles() predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, RolesTable, RolesPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRolesWith applies the HasEdge predicate on the "roles" edge with a given conditions (other predicates). -func HasRolesWith(preds ...predicate.Role) predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := newRolesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPositions applies the HasEdge predicate on the "positions" edge. -func HasPositions() predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, PositionsTable, PositionsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPositionsWith applies the HasEdge predicate on the "positions" edge with a given conditions (other predicates). -func HasPositionsWith(preds ...predicate.Position) predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := newPositionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasResources applies the HasEdge predicate on the "resources" edge. -func HasResources() predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasResourcesWith applies the HasEdge predicate on the "resources" edge with a given conditions (other predicates). -func HasResourcesWith(preds ...predicate.Resource) predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := newResourcesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasRolePermissions applies the HasEdge predicate on the "role_permissions" edge. -func HasRolePermissions() predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRolePermissionsWith applies the HasEdge predicate on the "role_permissions" edge with a given conditions (other predicates). -func HasRolePermissionsWith(preds ...predicate.RolePermission) predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := newRolePermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPositionPermissions applies the HasEdge predicate on the "position_permissions" edge. -func HasPositionPermissions() predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PositionPermissionsTable, PositionPermissionsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPositionPermissionsWith applies the HasEdge predicate on the "position_permissions" edge with a given conditions (other predicates). -func HasPositionPermissionsWith(preds ...predicate.PositionPermission) predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := newPositionPermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermissionResources applies the HasEdge predicate on the "permission_resources" edge. -func HasPermissionResources() predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionResourcesWith applies the HasEdge predicate on the "permission_resources" edge with a given conditions (other predicates). -func HasPermissionResourcesWith(preds ...predicate.PermissionResource) predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := newPermissionResourcesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Permission) predicate.Permission { - return predicate.Permission(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Permission) predicate.Permission { - return predicate.Permission(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Permission) predicate.Permission { - return predicate.Permission(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/permissionresource/permissionresource.go b/internal/mods/system/dal/entity/ent/permissionresource/permissionresource.go deleted file mode 100644 index 22d0c165..00000000 --- a/internal/mods/system/dal/entity/ent/permissionresource/permissionresource.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package permissionresource - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the permissionresource type in the database. - Label = "permission_resource" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldPermissionID holds the string denoting the permission_id field in the database. - FieldPermissionID = "permission_id" - // FieldResourceID holds the string denoting the resource_id field in the database. - FieldResourceID = "resource_id" - // EdgePermission holds the string denoting the permission edge name in mutations. - EdgePermission = "permission" - // EdgeResource holds the string denoting the resource edge name in mutations. - EdgeResource = "resource" - // Table holds the table name of the permissionresource in the database. - Table = "sys_permission_resources" - // PermissionTable is the table that holds the permission relation/edge. - PermissionTable = "sys_permission_resources" - // PermissionInverseTable is the table name for the Permission entity. - // It exists in this package in order to avoid circular dependency with the "permission" package. - PermissionInverseTable = "sys_permissions" - // PermissionColumn is the table column denoting the permission relation/edge. - PermissionColumn = "permission_id" - // ResourceTable is the table that holds the resource relation/edge. - ResourceTable = "sys_permission_resources" - // ResourceInverseTable is the table name for the Resource entity. - // It exists in this package in order to avoid circular dependency with the "resource" package. - ResourceInverseTable = "sys_resources" - // ResourceColumn is the table column denoting the resource relation/edge. - ResourceColumn = "resource_id" -) - -// Columns holds all SQL columns for permissionresource fields. -var Columns = []string{ - FieldID, - FieldPermissionID, - FieldResourceID, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // PermissionIDValidator is a validator for the "permission_id" field. It is called by the builders before save. - PermissionIDValidator func(int64) error - // ResourceIDValidator is a validator for the "resource_id" field. It is called by the builders before save. - ResourceIDValidator func(int64) error -) - -// OrderOption defines the ordering options for the PermissionResource queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByPermissionID orders the results by the permission_id field. -func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPermissionID, opts...).ToFunc() -} - -// ByResourceID orders the results by the resource_id field. -func ByResourceID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldResourceID, opts...).ToFunc() -} - -// ByPermissionField orders the results by permission field. -func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) - } -} - -// ByResourceField orders the results by resource field. -func ByResourceField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newResourceStep(), sql.OrderByField(field, opts...)) - } -} -func newPermissionStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), - ) -} -func newResourceStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(ResourceInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, ResourceTable, ResourceColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/permissionresource/where.go b/internal/mods/system/dal/entity/ent/permissionresource/where.go deleted file mode 100644 index aeda3d6e..00000000 --- a/internal/mods/system/dal/entity/ent/permissionresource/where.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package permissionresource - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldLTE(FieldID, id)) -} - -// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. -func PermissionID(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldPermissionID, v)) -} - -// ResourceID applies equality check predicate on the "resource_id" field. It's identical to ResourceIDEQ. -func ResourceID(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldResourceID, v)) -} - -// PermissionIDEQ applies the EQ predicate on the "permission_id" field. -func PermissionIDEQ(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldPermissionID, v)) -} - -// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. -func PermissionIDNEQ(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNEQ(FieldPermissionID, v)) -} - -// PermissionIDIn applies the In predicate on the "permission_id" field. -func PermissionIDIn(vs ...int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldIn(FieldPermissionID, vs...)) -} - -// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. -func PermissionIDNotIn(vs ...int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNotIn(FieldPermissionID, vs...)) -} - -// ResourceIDEQ applies the EQ predicate on the "resource_id" field. -func ResourceIDEQ(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldResourceID, v)) -} - -// ResourceIDNEQ applies the NEQ predicate on the "resource_id" field. -func ResourceIDNEQ(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNEQ(FieldResourceID, v)) -} - -// ResourceIDIn applies the In predicate on the "resource_id" field. -func ResourceIDIn(vs ...int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldIn(FieldResourceID, vs...)) -} - -// ResourceIDNotIn applies the NotIn predicate on the "resource_id" field. -func ResourceIDNotIn(vs ...int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNotIn(FieldResourceID, vs...)) -} - -// HasPermission applies the HasEdge predicate on the "permission" edge. -func HasPermission() predicate.PermissionResource { - return predicate.PermissionResource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). -func HasPermissionWith(preds ...predicate.Permission) predicate.PermissionResource { - return predicate.PermissionResource(func(s *sql.Selector) { - step := newPermissionStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasResource applies the HasEdge predicate on the "resource" edge. -func HasResource() predicate.PermissionResource { - return predicate.PermissionResource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, ResourceTable, ResourceColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasResourceWith applies the HasEdge predicate on the "resource" edge with a given conditions (other predicates). -func HasResourceWith(preds ...predicate.Resource) predicate.PermissionResource { - return predicate.PermissionResource(func(s *sql.Selector) { - step := newResourceStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.PermissionResource) predicate.PermissionResource { - return predicate.PermissionResource(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.PermissionResource) predicate.PermissionResource { - return predicate.PermissionResource(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.PermissionResource) predicate.PermissionResource { - return predicate.PermissionResource(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/position/position.go b/internal/mods/system/dal/entity/ent/position/position.go deleted file mode 100644 index c376960e..00000000 --- a/internal/mods/system/dal/entity/ent/position/position.go +++ /dev/null @@ -1,323 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package position - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the position type in the database. - Label = "position" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldKeyword holds the string denoting the keyword field in the database. - FieldKeyword = "keyword" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldDepartmentID holds the string denoting the department_id field in the database. - FieldDepartmentID = "department_id" - // EdgeDepartment holds the string denoting the department edge name in mutations. - EdgeDepartment = "department" - // EdgeUsers holds the string denoting the users edge name in mutations. - EdgeUsers = "users" - // EdgePermissions holds the string denoting the permissions edge name in mutations. - EdgePermissions = "permissions" - // EdgeUserPositions holds the string denoting the user_positions edge name in mutations. - EdgeUserPositions = "user_positions" - // EdgePositionPermissions holds the string denoting the position_permissions edge name in mutations. - EdgePositionPermissions = "position_permissions" - // Table holds the table name of the position in the database. - Table = "sys_positions" - // DepartmentTable is the table that holds the department relation/edge. - DepartmentTable = "sys_positions" - // DepartmentInverseTable is the table name for the Department entity. - // It exists in this package in order to avoid circular dependency with the "department" package. - DepartmentInverseTable = "sys_departments" - // DepartmentColumn is the table column denoting the department relation/edge. - DepartmentColumn = "department_id" - // UsersTable is the table that holds the users relation/edge. The primary key declared below. - UsersTable = "sys_user_positions" - // UsersInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UsersInverseTable = "sys_users" - // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. - PermissionsTable = "sys_position_permissions" - // PermissionsInverseTable is the table name for the Permission entity. - // It exists in this package in order to avoid circular dependency with the "permission" package. - PermissionsInverseTable = "sys_permissions" - // UserPositionsTable is the table that holds the user_positions relation/edge. - UserPositionsTable = "sys_user_positions" - // UserPositionsInverseTable is the table name for the UserPosition entity. - // It exists in this package in order to avoid circular dependency with the "userposition" package. - UserPositionsInverseTable = "sys_user_positions" - // UserPositionsColumn is the table column denoting the user_positions relation/edge. - UserPositionsColumn = "position_id" - // PositionPermissionsTable is the table that holds the position_permissions relation/edge. - PositionPermissionsTable = "sys_position_permissions" - // PositionPermissionsInverseTable is the table name for the PositionPermission entity. - // It exists in this package in order to avoid circular dependency with the "positionpermission" package. - PositionPermissionsInverseTable = "sys_position_permissions" - // PositionPermissionsColumn is the table column denoting the position_permissions relation/edge. - PositionPermissionsColumn = "position_id" -) - -// Columns holds all SQL columns for position fields. -var Columns = []string{ - FieldID, - FieldCreateTime, - FieldUpdateTime, - FieldName, - FieldKeyword, - FieldDescription, - FieldDepartmentID, -} - -var ( - // UsersPrimaryKey and UsersColumn2 are the table columns denoting the - // primary key for the users relation (M2M). - UsersPrimaryKey = []string{"user_id", "position_id"} - // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the - // primary key for the permissions relation (M2M). - PermissionsPrimaryKey = []string{"position_id", "permission_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() time.Time - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() time.Time - // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. - UpdateDefaultUpdateTime func() time.Time - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - KeywordValidator func(string) error - // DefaultDescription holds the default value on creation for the "description" field. - DefaultDescription string - // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - DescriptionValidator func(string) error - // DepartmentIDValidator is a validator for the "department_id" field. It is called by the builders before save. - DepartmentIDValidator func(int64) error - // DefaultID holds the default value on creation for the "id" field. - DefaultID func() int64 - // IDValidator is a validator for the "id" field. It is called by the builders before save. - IDValidator func(int64) error -) - -// OrderOption defines the ordering options for the Position queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByKeyword orders the results by the keyword field. -func ByKeyword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldKeyword, opts...).ToFunc() -} - -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() -} - -// ByDepartmentID orders the results by the department_id field. -func ByDepartmentID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDepartmentID, opts...).ToFunc() -} - -// ByDepartmentField orders the results by department field. -func ByDepartmentField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newDepartmentStep(), sql.OrderByField(field, opts...)) - } -} - -// ByUsersCount orders the results by users count. -func ByUsersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...) - } -} - -// ByUsers orders the results by users terms. -func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPermissionsCount orders the results by permissions count. -func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) - } -} - -// ByPermissions orders the results by permissions terms. -func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByUserPositionsCount orders the results by user_positions count. -func ByUserPositionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUserPositionsStep(), opts...) - } -} - -// ByUserPositions orders the results by user_positions terms. -func ByUserPositions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserPositionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPositionPermissionsCount orders the results by position_permissions count. -func ByPositionPermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPositionPermissionsStep(), opts...) - } -} - -// ByPositionPermissions orders the results by position_permissions terms. -func ByPositionPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPositionPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newDepartmentStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(DepartmentInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, DepartmentTable, DepartmentColumn), - ) -} -func newUsersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UsersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), - ) -} -func newPermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), - ) -} -func newUserPositionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserPositionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserPositionsTable, UserPositionsColumn), - ) -} -func newPositionPermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PositionPermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PositionPermissionsTable, PositionPermissionsColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/position/where.go b/internal/mods/system/dal/entity/ent/position/where.go deleted file mode 100644 index 6bc2b195..00000000 --- a/internal/mods/system/dal/entity/ent/position/where.go +++ /dev/null @@ -1,511 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package position - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.Position { - return predicate.Position(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.Position { - return predicate.Position(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.Position { - return predicate.Position(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.Position { - return predicate.Position(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.Position { - return predicate.Position(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.Position { - return predicate.Position(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.Position { - return predicate.Position(sql.FieldLTE(FieldID, id)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v time.Time) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v time.Time) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldUpdateTime, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldName, v)) -} - -// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. -func Keyword(v string) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldKeyword, v)) -} - -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldDescription, v)) -} - -// DepartmentID applies equality check predicate on the "department_id" field. It's identical to DepartmentIDEQ. -func DepartmentID(v int64) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldDepartmentID, v)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v time.Time) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v time.Time) predicate.Position { - return predicate.Position(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...time.Time) predicate.Position { - return predicate.Position(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...time.Time) predicate.Position { - return predicate.Position(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v time.Time) predicate.Position { - return predicate.Position(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v time.Time) predicate.Position { - return predicate.Position(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v time.Time) predicate.Position { - return predicate.Position(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v time.Time) predicate.Position { - return predicate.Position(sql.FieldLTE(FieldCreateTime, v)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v time.Time) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v time.Time) predicate.Position { - return predicate.Position(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...time.Time) predicate.Position { - return predicate.Position(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...time.Time) predicate.Position { - return predicate.Position(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v time.Time) predicate.Position { - return predicate.Position(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v time.Time) predicate.Position { - return predicate.Position(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v time.Time) predicate.Position { - return predicate.Position(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v time.Time) predicate.Position { - return predicate.Position(sql.FieldLTE(FieldUpdateTime, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Position { - return predicate.Position(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Position { - return predicate.Position(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Position { - return predicate.Position(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Position { - return predicate.Position(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Position { - return predicate.Position(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Position { - return predicate.Position(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Position { - return predicate.Position(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Position { - return predicate.Position(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Position { - return predicate.Position(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Position { - return predicate.Position(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Position { - return predicate.Position(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Position { - return predicate.Position(sql.FieldContainsFold(FieldName, v)) -} - -// KeywordEQ applies the EQ predicate on the "keyword" field. -func KeywordEQ(v string) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldKeyword, v)) -} - -// KeywordNEQ applies the NEQ predicate on the "keyword" field. -func KeywordNEQ(v string) predicate.Position { - return predicate.Position(sql.FieldNEQ(FieldKeyword, v)) -} - -// KeywordIn applies the In predicate on the "keyword" field. -func KeywordIn(vs ...string) predicate.Position { - return predicate.Position(sql.FieldIn(FieldKeyword, vs...)) -} - -// KeywordNotIn applies the NotIn predicate on the "keyword" field. -func KeywordNotIn(vs ...string) predicate.Position { - return predicate.Position(sql.FieldNotIn(FieldKeyword, vs...)) -} - -// KeywordGT applies the GT predicate on the "keyword" field. -func KeywordGT(v string) predicate.Position { - return predicate.Position(sql.FieldGT(FieldKeyword, v)) -} - -// KeywordGTE applies the GTE predicate on the "keyword" field. -func KeywordGTE(v string) predicate.Position { - return predicate.Position(sql.FieldGTE(FieldKeyword, v)) -} - -// KeywordLT applies the LT predicate on the "keyword" field. -func KeywordLT(v string) predicate.Position { - return predicate.Position(sql.FieldLT(FieldKeyword, v)) -} - -// KeywordLTE applies the LTE predicate on the "keyword" field. -func KeywordLTE(v string) predicate.Position { - return predicate.Position(sql.FieldLTE(FieldKeyword, v)) -} - -// KeywordContains applies the Contains predicate on the "keyword" field. -func KeywordContains(v string) predicate.Position { - return predicate.Position(sql.FieldContains(FieldKeyword, v)) -} - -// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. -func KeywordHasPrefix(v string) predicate.Position { - return predicate.Position(sql.FieldHasPrefix(FieldKeyword, v)) -} - -// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. -func KeywordHasSuffix(v string) predicate.Position { - return predicate.Position(sql.FieldHasSuffix(FieldKeyword, v)) -} - -// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. -func KeywordEqualFold(v string) predicate.Position { - return predicate.Position(sql.FieldEqualFold(FieldKeyword, v)) -} - -// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. -func KeywordContainsFold(v string) predicate.Position { - return predicate.Position(sql.FieldContainsFold(FieldKeyword, v)) -} - -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldDescription, v)) -} - -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.Position { - return predicate.Position(sql.FieldNEQ(FieldDescription, v)) -} - -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.Position { - return predicate.Position(sql.FieldIn(FieldDescription, vs...)) -} - -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.Position { - return predicate.Position(sql.FieldNotIn(FieldDescription, vs...)) -} - -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.Position { - return predicate.Position(sql.FieldGT(FieldDescription, v)) -} - -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.Position { - return predicate.Position(sql.FieldGTE(FieldDescription, v)) -} - -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.Position { - return predicate.Position(sql.FieldLT(FieldDescription, v)) -} - -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.Position { - return predicate.Position(sql.FieldLTE(FieldDescription, v)) -} - -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.Position { - return predicate.Position(sql.FieldContains(FieldDescription, v)) -} - -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.Position { - return predicate.Position(sql.FieldHasPrefix(FieldDescription, v)) -} - -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.Position { - return predicate.Position(sql.FieldHasSuffix(FieldDescription, v)) -} - -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.Position { - return predicate.Position(sql.FieldEqualFold(FieldDescription, v)) -} - -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.Position { - return predicate.Position(sql.FieldContainsFold(FieldDescription, v)) -} - -// DepartmentIDEQ applies the EQ predicate on the "department_id" field. -func DepartmentIDEQ(v int64) predicate.Position { - return predicate.Position(sql.FieldEQ(FieldDepartmentID, v)) -} - -// DepartmentIDNEQ applies the NEQ predicate on the "department_id" field. -func DepartmentIDNEQ(v int64) predicate.Position { - return predicate.Position(sql.FieldNEQ(FieldDepartmentID, v)) -} - -// DepartmentIDIn applies the In predicate on the "department_id" field. -func DepartmentIDIn(vs ...int64) predicate.Position { - return predicate.Position(sql.FieldIn(FieldDepartmentID, vs...)) -} - -// DepartmentIDNotIn applies the NotIn predicate on the "department_id" field. -func DepartmentIDNotIn(vs ...int64) predicate.Position { - return predicate.Position(sql.FieldNotIn(FieldDepartmentID, vs...)) -} - -// HasDepartment applies the HasEdge predicate on the "department" edge. -func HasDepartment() predicate.Position { - return predicate.Position(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, DepartmentTable, DepartmentColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasDepartmentWith applies the HasEdge predicate on the "department" edge with a given conditions (other predicates). -func HasDepartmentWith(preds ...predicate.Department) predicate.Position { - return predicate.Position(func(s *sql.Selector) { - step := newDepartmentStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasUsers applies the HasEdge predicate on the "users" edge. -func HasUsers() predicate.Position { - return predicate.Position(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUsersWith applies the HasEdge predicate on the "users" edge with a given conditions (other predicates). -func HasUsersWith(preds ...predicate.User) predicate.Position { - return predicate.Position(func(s *sql.Selector) { - step := newUsersStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermissions applies the HasEdge predicate on the "permissions" edge. -func HasPermissions() predicate.Position { - return predicate.Position(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). -func HasPermissionsWith(preds ...predicate.Permission) predicate.Position { - return predicate.Position(func(s *sql.Selector) { - step := newPermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasUserPositions applies the HasEdge predicate on the "user_positions" edge. -func HasUserPositions() predicate.Position { - return predicate.Position(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserPositionsTable, UserPositionsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserPositionsWith applies the HasEdge predicate on the "user_positions" edge with a given conditions (other predicates). -func HasUserPositionsWith(preds ...predicate.UserPosition) predicate.Position { - return predicate.Position(func(s *sql.Selector) { - step := newUserPositionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPositionPermissions applies the HasEdge predicate on the "position_permissions" edge. -func HasPositionPermissions() predicate.Position { - return predicate.Position(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PositionPermissionsTable, PositionPermissionsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPositionPermissionsWith applies the HasEdge predicate on the "position_permissions" edge with a given conditions (other predicates). -func HasPositionPermissionsWith(preds ...predicate.PositionPermission) predicate.Position { - return predicate.Position(func(s *sql.Selector) { - step := newPositionPermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Position) predicate.Position { - return predicate.Position(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Position) predicate.Position { - return predicate.Position(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Position) predicate.Position { - return predicate.Position(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/positionpermission/positionpermission.go b/internal/mods/system/dal/entity/ent/positionpermission/positionpermission.go deleted file mode 100644 index 17b96808..00000000 --- a/internal/mods/system/dal/entity/ent/positionpermission/positionpermission.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package positionpermission - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the positionpermission type in the database. - Label = "position_permission" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldPositionID holds the string denoting the position_id field in the database. - FieldPositionID = "position_id" - // FieldPermissionID holds the string denoting the permission_id field in the database. - FieldPermissionID = "permission_id" - // EdgePosition holds the string denoting the position edge name in mutations. - EdgePosition = "position" - // EdgePermission holds the string denoting the permission edge name in mutations. - EdgePermission = "permission" - // Table holds the table name of the positionpermission in the database. - Table = "sys_position_permissions" - // PositionTable is the table that holds the position relation/edge. - PositionTable = "sys_position_permissions" - // PositionInverseTable is the table name for the Position entity. - // It exists in this package in order to avoid circular dependency with the "position" package. - PositionInverseTable = "sys_positions" - // PositionColumn is the table column denoting the position relation/edge. - PositionColumn = "position_id" - // PermissionTable is the table that holds the permission relation/edge. - PermissionTable = "sys_position_permissions" - // PermissionInverseTable is the table name for the Permission entity. - // It exists in this package in order to avoid circular dependency with the "permission" package. - PermissionInverseTable = "sys_permissions" - // PermissionColumn is the table column denoting the permission relation/edge. - PermissionColumn = "permission_id" -) - -// Columns holds all SQL columns for positionpermission fields. -var Columns = []string{ - FieldID, - FieldPositionID, - FieldPermissionID, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // PositionIDValidator is a validator for the "position_id" field. It is called by the builders before save. - PositionIDValidator func(int64) error - // PermissionIDValidator is a validator for the "permission_id" field. It is called by the builders before save. - PermissionIDValidator func(int64) error -) - -// OrderOption defines the ordering options for the PositionPermission queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByPositionID orders the results by the position_id field. -func ByPositionID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPositionID, opts...).ToFunc() -} - -// ByPermissionID orders the results by the permission_id field. -func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPermissionID, opts...).ToFunc() -} - -// ByPositionField orders the results by position field. -func ByPositionField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPositionStep(), sql.OrderByField(field, opts...)) - } -} - -// ByPermissionField orders the results by permission field. -func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) - } -} -func newPositionStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PositionInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PositionTable, PositionColumn), - ) -} -func newPermissionStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/positionpermission/where.go b/internal/mods/system/dal/entity/ent/positionpermission/where.go deleted file mode 100644 index 967459cc..00000000 --- a/internal/mods/system/dal/entity/ent/positionpermission/where.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package positionpermission - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldLTE(FieldID, id)) -} - -// PositionID applies equality check predicate on the "position_id" field. It's identical to PositionIDEQ. -func PositionID(v int64) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldEQ(FieldPositionID, v)) -} - -// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. -func PermissionID(v int64) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldEQ(FieldPermissionID, v)) -} - -// PositionIDEQ applies the EQ predicate on the "position_id" field. -func PositionIDEQ(v int64) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldEQ(FieldPositionID, v)) -} - -// PositionIDNEQ applies the NEQ predicate on the "position_id" field. -func PositionIDNEQ(v int64) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldNEQ(FieldPositionID, v)) -} - -// PositionIDIn applies the In predicate on the "position_id" field. -func PositionIDIn(vs ...int64) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldIn(FieldPositionID, vs...)) -} - -// PositionIDNotIn applies the NotIn predicate on the "position_id" field. -func PositionIDNotIn(vs ...int64) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldNotIn(FieldPositionID, vs...)) -} - -// PermissionIDEQ applies the EQ predicate on the "permission_id" field. -func PermissionIDEQ(v int64) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldEQ(FieldPermissionID, v)) -} - -// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. -func PermissionIDNEQ(v int64) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldNEQ(FieldPermissionID, v)) -} - -// PermissionIDIn applies the In predicate on the "permission_id" field. -func PermissionIDIn(vs ...int64) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldIn(FieldPermissionID, vs...)) -} - -// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. -func PermissionIDNotIn(vs ...int64) predicate.PositionPermission { - return predicate.PositionPermission(sql.FieldNotIn(FieldPermissionID, vs...)) -} - -// HasPosition applies the HasEdge predicate on the "position" edge. -func HasPosition() predicate.PositionPermission { - return predicate.PositionPermission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PositionTable, PositionColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPositionWith applies the HasEdge predicate on the "position" edge with a given conditions (other predicates). -func HasPositionWith(preds ...predicate.Position) predicate.PositionPermission { - return predicate.PositionPermission(func(s *sql.Selector) { - step := newPositionStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermission applies the HasEdge predicate on the "permission" edge. -func HasPermission() predicate.PositionPermission { - return predicate.PositionPermission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). -func HasPermissionWith(preds ...predicate.Permission) predicate.PositionPermission { - return predicate.PositionPermission(func(s *sql.Selector) { - step := newPermissionStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.PositionPermission) predicate.PositionPermission { - return predicate.PositionPermission(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.PositionPermission) predicate.PositionPermission { - return predicate.PositionPermission(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.PositionPermission) predicate.PositionPermission { - return predicate.PositionPermission(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/resource/resource.go b/internal/mods/system/dal/entity/ent/resource/resource.go deleted file mode 100644 index 9dc8240a..00000000 --- a/internal/mods/system/dal/entity/ent/resource/resource.go +++ /dev/null @@ -1,427 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package resource - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the resource type in the database. - Label = "resource" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldKeyword holds the string denoting the keyword field in the database. - FieldKeyword = "keyword" - // FieldI18nKey holds the string denoting the i18n_key field in the database. - FieldI18nKey = "i18n_key" - // FieldType holds the string denoting the type field in the database. - FieldType = "type" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" - // FieldPath holds the string denoting the path field in the database. - FieldPath = "path" - // FieldOperation holds the string denoting the operation field in the database. - FieldOperation = "operation" - // FieldMethod holds the string denoting the method field in the database. - FieldMethod = "method" - // FieldComponent holds the string denoting the component field in the database. - FieldComponent = "component" - // FieldIcon holds the string denoting the icon field in the database. - FieldIcon = "icon" - // FieldSequence holds the string denoting the sequence field in the database. - FieldSequence = "sequence" - // FieldVisible holds the string denoting the visible field in the database. - FieldVisible = "visible" - // FieldLevel holds the string denoting the level field in the database. - FieldLevel = "level" - // FieldTreePath holds the string denoting the tree_path field in the database. - FieldTreePath = "tree_path" - // FieldProperties holds the string denoting the properties field in the database. - FieldProperties = "properties" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldParentID holds the string denoting the parent_id field in the database. - FieldParentID = "parent_id" - // EdgeChildren holds the string denoting the children edge name in mutations. - EdgeChildren = "children" - // EdgeParent holds the string denoting the parent edge name in mutations. - EdgeParent = "parent" - // EdgePermissions holds the string denoting the permissions edge name in mutations. - EdgePermissions = "permissions" - // EdgePermissionResources holds the string denoting the permission_resources edge name in mutations. - EdgePermissionResources = "permission_resources" - // Table holds the table name of the resource in the database. - Table = "sys_resources" - // ChildrenTable is the table that holds the children relation/edge. - ChildrenTable = "sys_resources" - // ChildrenColumn is the table column denoting the children relation/edge. - ChildrenColumn = "parent_id" - // ParentTable is the table that holds the parent relation/edge. - ParentTable = "sys_resources" - // ParentColumn is the table column denoting the parent relation/edge. - ParentColumn = "parent_id" - // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. - PermissionsTable = "sys_permission_resources" - // PermissionsInverseTable is the table name for the Permission entity. - // It exists in this package in order to avoid circular dependency with the "permission" package. - PermissionsInverseTable = "sys_permissions" - // PermissionResourcesTable is the table that holds the permission_resources relation/edge. - PermissionResourcesTable = "sys_permission_resources" - // PermissionResourcesInverseTable is the table name for the PermissionResource entity. - // It exists in this package in order to avoid circular dependency with the "permissionresource" package. - PermissionResourcesInverseTable = "sys_permission_resources" - // PermissionResourcesColumn is the table column denoting the permission_resources relation/edge. - PermissionResourcesColumn = "resource_id" -) - -// Columns holds all SQL columns for resource fields. -var Columns = []string{ - FieldID, - FieldCreateTime, - FieldUpdateTime, - FieldName, - FieldKeyword, - FieldI18nKey, - FieldType, - FieldStatus, - FieldPath, - FieldOperation, - FieldMethod, - FieldComponent, - FieldIcon, - FieldSequence, - FieldVisible, - FieldLevel, - FieldTreePath, - FieldProperties, - FieldDescription, - FieldParentID, -} - -var ( - // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the - // primary key for the permissions relation (M2M). - PermissionsPrimaryKey = []string{"permission_id", "resource_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() time.Time - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() time.Time - // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. - UpdateDefaultUpdateTime func() time.Time - // DefaultName holds the default value on creation for the "name" field. - DefaultName string - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - KeywordValidator func(string) error - // DefaultI18nKey holds the default value on creation for the "i18n_key" field. - DefaultI18nKey string - // I18nKeyValidator is a validator for the "i18n_key" field. It is called by the builders before save. - I18nKeyValidator func(string) error - // DefaultType holds the default value on creation for the "type" field. - DefaultType string - // TypeValidator is a validator for the "type" field. It is called by the builders before save. - TypeValidator func(string) error - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 - // DefaultPath holds the default value on creation for the "path" field. - DefaultPath string - // PathValidator is a validator for the "path" field. It is called by the builders before save. - PathValidator func(string) error - // DefaultOperation holds the default value on creation for the "operation" field. - DefaultOperation string - // OperationValidator is a validator for the "operation" field. It is called by the builders before save. - OperationValidator func(string) error - // DefaultMethod holds the default value on creation for the "method" field. - DefaultMethod string - // MethodValidator is a validator for the "method" field. It is called by the builders before save. - MethodValidator func(string) error - // DefaultComponent holds the default value on creation for the "component" field. - DefaultComponent string - // ComponentValidator is a validator for the "component" field. It is called by the builders before save. - ComponentValidator func(string) error - // DefaultIcon holds the default value on creation for the "icon" field. - DefaultIcon string - // IconValidator is a validator for the "icon" field. It is called by the builders before save. - IconValidator func(string) error - // DefaultSequence holds the default value on creation for the "sequence" field. - DefaultSequence int - // DefaultVisible holds the default value on creation for the "visible" field. - DefaultVisible bool - // DefaultLevel holds the default value on creation for the "level" field. - DefaultLevel int8 - // DefaultTreePath holds the default value on creation for the "tree_path" field. - DefaultTreePath string - // TreePathValidator is a validator for the "tree_path" field. It is called by the builders before save. - TreePathValidator func(string) error - // DefaultDescription holds the default value on creation for the "description" field. - DefaultDescription string - // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - DescriptionValidator func(string) error - // ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. - ParentIDValidator func(int64) error - // DefaultID holds the default value on creation for the "id" field. - DefaultID func() int64 - // IDValidator is a validator for the "id" field. It is called by the builders before save. - IDValidator func(int64) error -) - -// OrderOption defines the ordering options for the Resource queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByKeyword orders the results by the keyword field. -func ByKeyword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldKeyword, opts...).ToFunc() -} - -// ByI18nKey orders the results by the i18n_key field. -func ByI18nKey(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldI18nKey, opts...).ToFunc() -} - -// ByType orders the results by the type field. -func ByType(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldType, opts...).ToFunc() -} - -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - -// ByPath orders the results by the path field. -func ByPath(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPath, opts...).ToFunc() -} - -// ByOperation orders the results by the operation field. -func ByOperation(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldOperation, opts...).ToFunc() -} - -// ByMethod orders the results by the method field. -func ByMethod(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldMethod, opts...).ToFunc() -} - -// ByComponent orders the results by the component field. -func ByComponent(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldComponent, opts...).ToFunc() -} - -// ByIcon orders the results by the icon field. -func ByIcon(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldIcon, opts...).ToFunc() -} - -// BySequence orders the results by the sequence field. -func BySequence(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSequence, opts...).ToFunc() -} - -// ByVisible orders the results by the visible field. -func ByVisible(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldVisible, opts...).ToFunc() -} - -// ByLevel orders the results by the level field. -func ByLevel(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldLevel, opts...).ToFunc() -} - -// ByTreePath orders the results by the tree_path field. -func ByTreePath(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTreePath, opts...).ToFunc() -} - -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() -} - -// ByParentID orders the results by the parent_id field. -func ByParentID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldParentID, opts...).ToFunc() -} - -// ByChildrenCount orders the results by children count. -func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) - } -} - -// ByChildren orders the results by children terms. -func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByParentField orders the results by parent field. -func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) - } -} - -// ByPermissionsCount orders the results by permissions count. -func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) - } -} - -// ByPermissions orders the results by permissions terms. -func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPermissionResourcesCount orders the results by permission_resources count. -func ByPermissionResourcesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPermissionResourcesStep(), opts...) - } -} - -// ByPermissionResources orders the results by permission_resources terms. -func ByPermissionResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newChildrenStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), - ) -} -func newParentStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), - ) -} -func newPermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), - ) -} -func newPermissionResourcesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionResourcesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/resource/where.go b/internal/mods/system/dal/entity/ent/resource/where.go deleted file mode 100644 index 27d85763..00000000 --- a/internal/mods/system/dal/entity/ent/resource/where.go +++ /dev/null @@ -1,1218 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package resource - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldID, id)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldUpdateTime, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldName, v)) -} - -// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. -func Keyword(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) -} - -// I18nKey applies equality check predicate on the "i18n_key" field. It's identical to I18nKeyEQ. -func I18nKey(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldI18nKey, v)) -} - -// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. -func Type(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldType, v)) -} - -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldStatus, v)) -} - -// Path applies equality check predicate on the "path" field. It's identical to PathEQ. -func Path(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldPath, v)) -} - -// Operation applies equality check predicate on the "operation" field. It's identical to OperationEQ. -func Operation(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldOperation, v)) -} - -// Method applies equality check predicate on the "method" field. It's identical to MethodEQ. -func Method(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldMethod, v)) -} - -// Component applies equality check predicate on the "component" field. It's identical to ComponentEQ. -func Component(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldComponent, v)) -} - -// Icon applies equality check predicate on the "icon" field. It's identical to IconEQ. -func Icon(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldIcon, v)) -} - -// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. -func Sequence(v int) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldSequence, v)) -} - -// Visible applies equality check predicate on the "visible" field. It's identical to VisibleEQ. -func Visible(v bool) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldVisible, v)) -} - -// Level applies equality check predicate on the "level" field. It's identical to LevelEQ. -func Level(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldLevel, v)) -} - -// TreePath applies equality check predicate on the "tree_path" field. It's identical to TreePathEQ. -func TreePath(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) -} - -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldDescription, v)) -} - -// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ. -func ParentID(v int64) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldParentID, v)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...time.Time) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...time.Time) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldCreateTime, v)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...time.Time) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...time.Time) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldUpdateTime, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldName, v)) -} - -// KeywordEQ applies the EQ predicate on the "keyword" field. -func KeywordEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) -} - -// KeywordNEQ applies the NEQ predicate on the "keyword" field. -func KeywordNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldKeyword, v)) -} - -// KeywordIn applies the In predicate on the "keyword" field. -func KeywordIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldKeyword, vs...)) -} - -// KeywordNotIn applies the NotIn predicate on the "keyword" field. -func KeywordNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldKeyword, vs...)) -} - -// KeywordGT applies the GT predicate on the "keyword" field. -func KeywordGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldKeyword, v)) -} - -// KeywordGTE applies the GTE predicate on the "keyword" field. -func KeywordGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldKeyword, v)) -} - -// KeywordLT applies the LT predicate on the "keyword" field. -func KeywordLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldKeyword, v)) -} - -// KeywordLTE applies the LTE predicate on the "keyword" field. -func KeywordLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldKeyword, v)) -} - -// KeywordContains applies the Contains predicate on the "keyword" field. -func KeywordContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldKeyword, v)) -} - -// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. -func KeywordHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldKeyword, v)) -} - -// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. -func KeywordHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldKeyword, v)) -} - -// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. -func KeywordEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldKeyword, v)) -} - -// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. -func KeywordContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldKeyword, v)) -} - -// I18nKeyEQ applies the EQ predicate on the "i18n_key" field. -func I18nKeyEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldI18nKey, v)) -} - -// I18nKeyNEQ applies the NEQ predicate on the "i18n_key" field. -func I18nKeyNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldI18nKey, v)) -} - -// I18nKeyIn applies the In predicate on the "i18n_key" field. -func I18nKeyIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldI18nKey, vs...)) -} - -// I18nKeyNotIn applies the NotIn predicate on the "i18n_key" field. -func I18nKeyNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldI18nKey, vs...)) -} - -// I18nKeyGT applies the GT predicate on the "i18n_key" field. -func I18nKeyGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldI18nKey, v)) -} - -// I18nKeyGTE applies the GTE predicate on the "i18n_key" field. -func I18nKeyGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldI18nKey, v)) -} - -// I18nKeyLT applies the LT predicate on the "i18n_key" field. -func I18nKeyLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldI18nKey, v)) -} - -// I18nKeyLTE applies the LTE predicate on the "i18n_key" field. -func I18nKeyLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldI18nKey, v)) -} - -// I18nKeyContains applies the Contains predicate on the "i18n_key" field. -func I18nKeyContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldI18nKey, v)) -} - -// I18nKeyHasPrefix applies the HasPrefix predicate on the "i18n_key" field. -func I18nKeyHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldI18nKey, v)) -} - -// I18nKeyHasSuffix applies the HasSuffix predicate on the "i18n_key" field. -func I18nKeyHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldI18nKey, v)) -} - -// I18nKeyEqualFold applies the EqualFold predicate on the "i18n_key" field. -func I18nKeyEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldI18nKey, v)) -} - -// I18nKeyContainsFold applies the ContainsFold predicate on the "i18n_key" field. -func I18nKeyContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldI18nKey, v)) -} - -// TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldType, v)) -} - -// TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldType, v)) -} - -// TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldType, vs...)) -} - -// TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldType, vs...)) -} - -// TypeGT applies the GT predicate on the "type" field. -func TypeGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldType, v)) -} - -// TypeGTE applies the GTE predicate on the "type" field. -func TypeGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldType, v)) -} - -// TypeLT applies the LT predicate on the "type" field. -func TypeLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldType, v)) -} - -// TypeLTE applies the LTE predicate on the "type" field. -func TypeLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldType, v)) -} - -// TypeContains applies the Contains predicate on the "type" field. -func TypeContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldType, v)) -} - -// TypeHasPrefix applies the HasPrefix predicate on the "type" field. -func TypeHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldType, v)) -} - -// TypeHasSuffix applies the HasSuffix predicate on the "type" field. -func TypeHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldType, v)) -} - -// TypeEqualFold applies the EqualFold predicate on the "type" field. -func TypeEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldType, v)) -} - -// TypeContainsFold applies the ContainsFold predicate on the "type" field. -func TypeContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldType, v)) -} - -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldStatus, vs...)) -} - -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldStatus, v)) -} - -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldStatus, v)) -} - -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldStatus, v)) -} - -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldStatus, v)) -} - -// PathEQ applies the EQ predicate on the "path" field. -func PathEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldPath, v)) -} - -// PathNEQ applies the NEQ predicate on the "path" field. -func PathNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldPath, v)) -} - -// PathIn applies the In predicate on the "path" field. -func PathIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldPath, vs...)) -} - -// PathNotIn applies the NotIn predicate on the "path" field. -func PathNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldPath, vs...)) -} - -// PathGT applies the GT predicate on the "path" field. -func PathGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldPath, v)) -} - -// PathGTE applies the GTE predicate on the "path" field. -func PathGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldPath, v)) -} - -// PathLT applies the LT predicate on the "path" field. -func PathLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldPath, v)) -} - -// PathLTE applies the LTE predicate on the "path" field. -func PathLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldPath, v)) -} - -// PathContains applies the Contains predicate on the "path" field. -func PathContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldPath, v)) -} - -// PathHasPrefix applies the HasPrefix predicate on the "path" field. -func PathHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldPath, v)) -} - -// PathHasSuffix applies the HasSuffix predicate on the "path" field. -func PathHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldPath, v)) -} - -// PathEqualFold applies the EqualFold predicate on the "path" field. -func PathEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldPath, v)) -} - -// PathContainsFold applies the ContainsFold predicate on the "path" field. -func PathContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldPath, v)) -} - -// OperationEQ applies the EQ predicate on the "operation" field. -func OperationEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldOperation, v)) -} - -// OperationNEQ applies the NEQ predicate on the "operation" field. -func OperationNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldOperation, v)) -} - -// OperationIn applies the In predicate on the "operation" field. -func OperationIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldOperation, vs...)) -} - -// OperationNotIn applies the NotIn predicate on the "operation" field. -func OperationNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldOperation, vs...)) -} - -// OperationGT applies the GT predicate on the "operation" field. -func OperationGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldOperation, v)) -} - -// OperationGTE applies the GTE predicate on the "operation" field. -func OperationGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldOperation, v)) -} - -// OperationLT applies the LT predicate on the "operation" field. -func OperationLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldOperation, v)) -} - -// OperationLTE applies the LTE predicate on the "operation" field. -func OperationLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldOperation, v)) -} - -// OperationContains applies the Contains predicate on the "operation" field. -func OperationContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldOperation, v)) -} - -// OperationHasPrefix applies the HasPrefix predicate on the "operation" field. -func OperationHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldOperation, v)) -} - -// OperationHasSuffix applies the HasSuffix predicate on the "operation" field. -func OperationHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldOperation, v)) -} - -// OperationEqualFold applies the EqualFold predicate on the "operation" field. -func OperationEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldOperation, v)) -} - -// OperationContainsFold applies the ContainsFold predicate on the "operation" field. -func OperationContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldOperation, v)) -} - -// MethodEQ applies the EQ predicate on the "method" field. -func MethodEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldMethod, v)) -} - -// MethodNEQ applies the NEQ predicate on the "method" field. -func MethodNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldMethod, v)) -} - -// MethodIn applies the In predicate on the "method" field. -func MethodIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldMethod, vs...)) -} - -// MethodNotIn applies the NotIn predicate on the "method" field. -func MethodNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldMethod, vs...)) -} - -// MethodGT applies the GT predicate on the "method" field. -func MethodGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldMethod, v)) -} - -// MethodGTE applies the GTE predicate on the "method" field. -func MethodGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldMethod, v)) -} - -// MethodLT applies the LT predicate on the "method" field. -func MethodLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldMethod, v)) -} - -// MethodLTE applies the LTE predicate on the "method" field. -func MethodLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldMethod, v)) -} - -// MethodContains applies the Contains predicate on the "method" field. -func MethodContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldMethod, v)) -} - -// MethodHasPrefix applies the HasPrefix predicate on the "method" field. -func MethodHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldMethod, v)) -} - -// MethodHasSuffix applies the HasSuffix predicate on the "method" field. -func MethodHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldMethod, v)) -} - -// MethodEqualFold applies the EqualFold predicate on the "method" field. -func MethodEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldMethod, v)) -} - -// MethodContainsFold applies the ContainsFold predicate on the "method" field. -func MethodContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldMethod, v)) -} - -// ComponentEQ applies the EQ predicate on the "component" field. -func ComponentEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldComponent, v)) -} - -// ComponentNEQ applies the NEQ predicate on the "component" field. -func ComponentNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldComponent, v)) -} - -// ComponentIn applies the In predicate on the "component" field. -func ComponentIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldComponent, vs...)) -} - -// ComponentNotIn applies the NotIn predicate on the "component" field. -func ComponentNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldComponent, vs...)) -} - -// ComponentGT applies the GT predicate on the "component" field. -func ComponentGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldComponent, v)) -} - -// ComponentGTE applies the GTE predicate on the "component" field. -func ComponentGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldComponent, v)) -} - -// ComponentLT applies the LT predicate on the "component" field. -func ComponentLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldComponent, v)) -} - -// ComponentLTE applies the LTE predicate on the "component" field. -func ComponentLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldComponent, v)) -} - -// ComponentContains applies the Contains predicate on the "component" field. -func ComponentContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldComponent, v)) -} - -// ComponentHasPrefix applies the HasPrefix predicate on the "component" field. -func ComponentHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldComponent, v)) -} - -// ComponentHasSuffix applies the HasSuffix predicate on the "component" field. -func ComponentHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldComponent, v)) -} - -// ComponentEqualFold applies the EqualFold predicate on the "component" field. -func ComponentEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldComponent, v)) -} - -// ComponentContainsFold applies the ContainsFold predicate on the "component" field. -func ComponentContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldComponent, v)) -} - -// IconEQ applies the EQ predicate on the "icon" field. -func IconEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldIcon, v)) -} - -// IconNEQ applies the NEQ predicate on the "icon" field. -func IconNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldIcon, v)) -} - -// IconIn applies the In predicate on the "icon" field. -func IconIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldIcon, vs...)) -} - -// IconNotIn applies the NotIn predicate on the "icon" field. -func IconNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldIcon, vs...)) -} - -// IconGT applies the GT predicate on the "icon" field. -func IconGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldIcon, v)) -} - -// IconGTE applies the GTE predicate on the "icon" field. -func IconGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldIcon, v)) -} - -// IconLT applies the LT predicate on the "icon" field. -func IconLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldIcon, v)) -} - -// IconLTE applies the LTE predicate on the "icon" field. -func IconLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldIcon, v)) -} - -// IconContains applies the Contains predicate on the "icon" field. -func IconContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldIcon, v)) -} - -// IconHasPrefix applies the HasPrefix predicate on the "icon" field. -func IconHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldIcon, v)) -} - -// IconHasSuffix applies the HasSuffix predicate on the "icon" field. -func IconHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldIcon, v)) -} - -// IconEqualFold applies the EqualFold predicate on the "icon" field. -func IconEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldIcon, v)) -} - -// IconContainsFold applies the ContainsFold predicate on the "icon" field. -func IconContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldIcon, v)) -} - -// SequenceEQ applies the EQ predicate on the "sequence" field. -func SequenceEQ(v int) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldSequence, v)) -} - -// SequenceNEQ applies the NEQ predicate on the "sequence" field. -func SequenceNEQ(v int) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldSequence, v)) -} - -// SequenceIn applies the In predicate on the "sequence" field. -func SequenceIn(vs ...int) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldSequence, vs...)) -} - -// SequenceNotIn applies the NotIn predicate on the "sequence" field. -func SequenceNotIn(vs ...int) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldSequence, vs...)) -} - -// SequenceGT applies the GT predicate on the "sequence" field. -func SequenceGT(v int) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldSequence, v)) -} - -// SequenceGTE applies the GTE predicate on the "sequence" field. -func SequenceGTE(v int) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldSequence, v)) -} - -// SequenceLT applies the LT predicate on the "sequence" field. -func SequenceLT(v int) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldSequence, v)) -} - -// SequenceLTE applies the LTE predicate on the "sequence" field. -func SequenceLTE(v int) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldSequence, v)) -} - -// VisibleEQ applies the EQ predicate on the "visible" field. -func VisibleEQ(v bool) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldVisible, v)) -} - -// VisibleNEQ applies the NEQ predicate on the "visible" field. -func VisibleNEQ(v bool) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldVisible, v)) -} - -// LevelEQ applies the EQ predicate on the "level" field. -func LevelEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldLevel, v)) -} - -// LevelNEQ applies the NEQ predicate on the "level" field. -func LevelNEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldLevel, v)) -} - -// LevelIn applies the In predicate on the "level" field. -func LevelIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldLevel, vs...)) -} - -// LevelNotIn applies the NotIn predicate on the "level" field. -func LevelNotIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldLevel, vs...)) -} - -// LevelGT applies the GT predicate on the "level" field. -func LevelGT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldLevel, v)) -} - -// LevelGTE applies the GTE predicate on the "level" field. -func LevelGTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldLevel, v)) -} - -// LevelLT applies the LT predicate on the "level" field. -func LevelLT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldLevel, v)) -} - -// LevelLTE applies the LTE predicate on the "level" field. -func LevelLTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldLevel, v)) -} - -// TreePathEQ applies the EQ predicate on the "tree_path" field. -func TreePathEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) -} - -// TreePathNEQ applies the NEQ predicate on the "tree_path" field. -func TreePathNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldTreePath, v)) -} - -// TreePathIn applies the In predicate on the "tree_path" field. -func TreePathIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldTreePath, vs...)) -} - -// TreePathNotIn applies the NotIn predicate on the "tree_path" field. -func TreePathNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldTreePath, vs...)) -} - -// TreePathGT applies the GT predicate on the "tree_path" field. -func TreePathGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldTreePath, v)) -} - -// TreePathGTE applies the GTE predicate on the "tree_path" field. -func TreePathGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldTreePath, v)) -} - -// TreePathLT applies the LT predicate on the "tree_path" field. -func TreePathLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldTreePath, v)) -} - -// TreePathLTE applies the LTE predicate on the "tree_path" field. -func TreePathLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldTreePath, v)) -} - -// TreePathContains applies the Contains predicate on the "tree_path" field. -func TreePathContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldTreePath, v)) -} - -// TreePathHasPrefix applies the HasPrefix predicate on the "tree_path" field. -func TreePathHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldTreePath, v)) -} - -// TreePathHasSuffix applies the HasSuffix predicate on the "tree_path" field. -func TreePathHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldTreePath, v)) -} - -// TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. -func TreePathEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldTreePath, v)) -} - -// TreePathContainsFold applies the ContainsFold predicate on the "tree_path" field. -func TreePathContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldTreePath, v)) -} - -// PropertiesIsNil applies the IsNil predicate on the "properties" field. -func PropertiesIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldProperties)) -} - -// PropertiesNotNil applies the NotNil predicate on the "properties" field. -func PropertiesNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldProperties)) -} - -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldDescription, v)) -} - -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldDescription, v)) -} - -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldDescription, vs...)) -} - -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldDescription, vs...)) -} - -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldDescription, v)) -} - -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldDescription, v)) -} - -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldDescription, v)) -} - -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldDescription, v)) -} - -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldDescription, v)) -} - -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldDescription, v)) -} - -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldDescription, v)) -} - -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldDescription, v)) -} - -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldDescription, v)) -} - -// ParentIDEQ applies the EQ predicate on the "parent_id" field. -func ParentIDEQ(v int64) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldParentID, v)) -} - -// ParentIDNEQ applies the NEQ predicate on the "parent_id" field. -func ParentIDNEQ(v int64) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldParentID, v)) -} - -// ParentIDIn applies the In predicate on the "parent_id" field. -func ParentIDIn(vs ...int64) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldParentID, vs...)) -} - -// ParentIDNotIn applies the NotIn predicate on the "parent_id" field. -func ParentIDNotIn(vs ...int64) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldParentID, vs...)) -} - -// ParentIDIsNil applies the IsNil predicate on the "parent_id" field. -func ParentIDIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldParentID)) -} - -// ParentIDNotNil applies the NotNil predicate on the "parent_id" field. -func ParentIDNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldParentID)) -} - -// HasChildren applies the HasEdge predicate on the "children" edge. -func HasChildren() predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates). -func HasChildrenWith(preds ...predicate.Resource) predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := newChildrenStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasParent applies the HasEdge predicate on the "parent" edge. -func HasParent() predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). -func HasParentWith(preds ...predicate.Resource) predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := newParentStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermissions applies the HasEdge predicate on the "permissions" edge. -func HasPermissions() predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). -func HasPermissionsWith(preds ...predicate.Permission) predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := newPermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermissionResources applies the HasEdge predicate on the "permission_resources" edge. -func HasPermissionResources() predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionResourcesWith applies the HasEdge predicate on the "permission_resources" edge with a given conditions (other predicates). -func HasPermissionResourcesWith(preds ...predicate.PermissionResource) predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := newPermissionResourcesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Resource) predicate.Resource { - return predicate.Resource(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Resource) predicate.Resource { - return predicate.Resource(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Resource) predicate.Resource { - return predicate.Resource(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/role/role.go b/internal/mods/system/dal/entity/ent/role/role.go deleted file mode 100644 index a09ff5e5..00000000 --- a/internal/mods/system/dal/entity/ent/role/role.go +++ /dev/null @@ -1,322 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package role - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the role type in the database. - Label = "role" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldKeyword holds the string denoting the keyword field in the database. - FieldKeyword = "keyword" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldType holds the string denoting the type field in the database. - FieldType = "type" - // FieldSequence holds the string denoting the sequence field in the database. - FieldSequence = "sequence" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" - // EdgeUsers holds the string denoting the users edge name in mutations. - EdgeUsers = "users" - // EdgePermissions holds the string denoting the permissions edge name in mutations. - EdgePermissions = "permissions" - // EdgeUserRoles holds the string denoting the user_roles edge name in mutations. - EdgeUserRoles = "user_roles" - // EdgeRolePermissions holds the string denoting the role_permissions edge name in mutations. - EdgeRolePermissions = "role_permissions" - // Table holds the table name of the role in the database. - Table = "sys_roles" - // UsersTable is the table that holds the users relation/edge. The primary key declared below. - UsersTable = "sys_user_roles" - // UsersInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UsersInverseTable = "sys_users" - // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. - PermissionsTable = "sys_role_permissions" - // PermissionsInverseTable is the table name for the Permission entity. - // It exists in this package in order to avoid circular dependency with the "permission" package. - PermissionsInverseTable = "sys_permissions" - // UserRolesTable is the table that holds the user_roles relation/edge. - UserRolesTable = "sys_user_roles" - // UserRolesInverseTable is the table name for the UserRole entity. - // It exists in this package in order to avoid circular dependency with the "userrole" package. - UserRolesInverseTable = "sys_user_roles" - // UserRolesColumn is the table column denoting the user_roles relation/edge. - UserRolesColumn = "role_id" - // RolePermissionsTable is the table that holds the role_permissions relation/edge. - RolePermissionsTable = "sys_role_permissions" - // RolePermissionsInverseTable is the table name for the RolePermission entity. - // It exists in this package in order to avoid circular dependency with the "rolepermission" package. - RolePermissionsInverseTable = "sys_role_permissions" - // RolePermissionsColumn is the table column denoting the role_permissions relation/edge. - RolePermissionsColumn = "role_id" -) - -// Columns holds all SQL columns for role fields. -var Columns = []string{ - FieldID, - FieldCreateTime, - FieldUpdateTime, - FieldKeyword, - FieldName, - FieldDescription, - FieldType, - FieldSequence, - FieldStatus, -} - -var ( - // UsersPrimaryKey and UsersColumn2 are the table columns denoting the - // primary key for the users relation (M2M). - UsersPrimaryKey = []string{"user_id", "role_id"} - // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the - // primary key for the permissions relation (M2M). - PermissionsPrimaryKey = []string{"role_id", "permission_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() time.Time - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() time.Time - // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. - UpdateDefaultUpdateTime func() time.Time - // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - KeywordValidator func(string) error - // DefaultName holds the default value on creation for the "name" field. - DefaultName string - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // DefaultDescription holds the default value on creation for the "description" field. - DefaultDescription string - // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - DescriptionValidator func(string) error - // DefaultType holds the default value on creation for the "type" field. - DefaultType int8 - // DefaultSequence holds the default value on creation for the "sequence" field. - DefaultSequence int - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 - // DefaultID holds the default value on creation for the "id" field. - DefaultID func() int64 - // IDValidator is a validator for the "id" field. It is called by the builders before save. - IDValidator func(int64) error -) - -// OrderOption defines the ordering options for the Role queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByKeyword orders the results by the keyword field. -func ByKeyword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldKeyword, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() -} - -// ByType orders the results by the type field. -func ByType(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldType, opts...).ToFunc() -} - -// BySequence orders the results by the sequence field. -func BySequence(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSequence, opts...).ToFunc() -} - -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - -// ByUsersCount orders the results by users count. -func ByUsersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...) - } -} - -// ByUsers orders the results by users terms. -func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPermissionsCount orders the results by permissions count. -func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) - } -} - -// ByPermissions orders the results by permissions terms. -func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByUserRolesCount orders the results by user_roles count. -func ByUserRolesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUserRolesStep(), opts...) - } -} - -// ByUserRoles orders the results by user_roles terms. -func ByUserRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserRolesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByRolePermissionsCount orders the results by role_permissions count. -func ByRolePermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newRolePermissionsStep(), opts...) - } -} - -// ByRolePermissions orders the results by role_permissions terms. -func ByRolePermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRolePermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newUsersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UsersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), - ) -} -func newPermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), - ) -} -func newUserRolesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserRolesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), - ) -} -func newRolePermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RolePermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/role/where.go b/internal/mods/system/dal/entity/ent/role/where.go deleted file mode 100644 index 42741607..00000000 --- a/internal/mods/system/dal/entity/ent/role/where.go +++ /dev/null @@ -1,598 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package role - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.Role { - return predicate.Role(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.Role { - return predicate.Role(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.Role { - return predicate.Role(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldID, id)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v time.Time) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v time.Time) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldUpdateTime, v)) -} - -// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. -func Keyword(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldKeyword, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldName, v)) -} - -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldDescription, v)) -} - -// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. -func Type(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldType, v)) -} - -// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. -func Sequence(v int) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldSequence, v)) -} - -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldStatus, v)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v time.Time) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v time.Time) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...time.Time) predicate.Role { - return predicate.Role(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...time.Time) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v time.Time) predicate.Role { - return predicate.Role(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v time.Time) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v time.Time) predicate.Role { - return predicate.Role(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v time.Time) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldCreateTime, v)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v time.Time) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v time.Time) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...time.Time) predicate.Role { - return predicate.Role(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...time.Time) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v time.Time) predicate.Role { - return predicate.Role(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v time.Time) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v time.Time) predicate.Role { - return predicate.Role(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v time.Time) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldUpdateTime, v)) -} - -// KeywordEQ applies the EQ predicate on the "keyword" field. -func KeywordEQ(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldKeyword, v)) -} - -// KeywordNEQ applies the NEQ predicate on the "keyword" field. -func KeywordNEQ(v string) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldKeyword, v)) -} - -// KeywordIn applies the In predicate on the "keyword" field. -func KeywordIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldIn(FieldKeyword, vs...)) -} - -// KeywordNotIn applies the NotIn predicate on the "keyword" field. -func KeywordNotIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldKeyword, vs...)) -} - -// KeywordGT applies the GT predicate on the "keyword" field. -func KeywordGT(v string) predicate.Role { - return predicate.Role(sql.FieldGT(FieldKeyword, v)) -} - -// KeywordGTE applies the GTE predicate on the "keyword" field. -func KeywordGTE(v string) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldKeyword, v)) -} - -// KeywordLT applies the LT predicate on the "keyword" field. -func KeywordLT(v string) predicate.Role { - return predicate.Role(sql.FieldLT(FieldKeyword, v)) -} - -// KeywordLTE applies the LTE predicate on the "keyword" field. -func KeywordLTE(v string) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldKeyword, v)) -} - -// KeywordContains applies the Contains predicate on the "keyword" field. -func KeywordContains(v string) predicate.Role { - return predicate.Role(sql.FieldContains(FieldKeyword, v)) -} - -// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. -func KeywordHasPrefix(v string) predicate.Role { - return predicate.Role(sql.FieldHasPrefix(FieldKeyword, v)) -} - -// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. -func KeywordHasSuffix(v string) predicate.Role { - return predicate.Role(sql.FieldHasSuffix(FieldKeyword, v)) -} - -// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. -func KeywordEqualFold(v string) predicate.Role { - return predicate.Role(sql.FieldEqualFold(FieldKeyword, v)) -} - -// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. -func KeywordContainsFold(v string) predicate.Role { - return predicate.Role(sql.FieldContainsFold(FieldKeyword, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Role { - return predicate.Role(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Role { - return predicate.Role(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Role { - return predicate.Role(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Role { - return predicate.Role(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Role { - return predicate.Role(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Role { - return predicate.Role(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Role { - return predicate.Role(sql.FieldContainsFold(FieldName, v)) -} - -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldDescription, v)) -} - -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldDescription, v)) -} - -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldIn(FieldDescription, vs...)) -} - -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldDescription, vs...)) -} - -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.Role { - return predicate.Role(sql.FieldGT(FieldDescription, v)) -} - -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldDescription, v)) -} - -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.Role { - return predicate.Role(sql.FieldLT(FieldDescription, v)) -} - -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldDescription, v)) -} - -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.Role { - return predicate.Role(sql.FieldContains(FieldDescription, v)) -} - -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.Role { - return predicate.Role(sql.FieldHasPrefix(FieldDescription, v)) -} - -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.Role { - return predicate.Role(sql.FieldHasSuffix(FieldDescription, v)) -} - -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.Role { - return predicate.Role(sql.FieldEqualFold(FieldDescription, v)) -} - -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.Role { - return predicate.Role(sql.FieldContainsFold(FieldDescription, v)) -} - -// TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldType, v)) -} - -// TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldType, v)) -} - -// TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldIn(FieldType, vs...)) -} - -// TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldType, vs...)) -} - -// TypeGT applies the GT predicate on the "type" field. -func TypeGT(v int8) predicate.Role { - return predicate.Role(sql.FieldGT(FieldType, v)) -} - -// TypeGTE applies the GTE predicate on the "type" field. -func TypeGTE(v int8) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldType, v)) -} - -// TypeLT applies the LT predicate on the "type" field. -func TypeLT(v int8) predicate.Role { - return predicate.Role(sql.FieldLT(FieldType, v)) -} - -// TypeLTE applies the LTE predicate on the "type" field. -func TypeLTE(v int8) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldType, v)) -} - -// SequenceEQ applies the EQ predicate on the "sequence" field. -func SequenceEQ(v int) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldSequence, v)) -} - -// SequenceNEQ applies the NEQ predicate on the "sequence" field. -func SequenceNEQ(v int) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldSequence, v)) -} - -// SequenceIn applies the In predicate on the "sequence" field. -func SequenceIn(vs ...int) predicate.Role { - return predicate.Role(sql.FieldIn(FieldSequence, vs...)) -} - -// SequenceNotIn applies the NotIn predicate on the "sequence" field. -func SequenceNotIn(vs ...int) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldSequence, vs...)) -} - -// SequenceGT applies the GT predicate on the "sequence" field. -func SequenceGT(v int) predicate.Role { - return predicate.Role(sql.FieldGT(FieldSequence, v)) -} - -// SequenceGTE applies the GTE predicate on the "sequence" field. -func SequenceGTE(v int) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldSequence, v)) -} - -// SequenceLT applies the LT predicate on the "sequence" field. -func SequenceLT(v int) predicate.Role { - return predicate.Role(sql.FieldLT(FieldSequence, v)) -} - -// SequenceLTE applies the LTE predicate on the "sequence" field. -func SequenceLTE(v int) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldSequence, v)) -} - -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldStatus, vs...)) -} - -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.Role { - return predicate.Role(sql.FieldGT(FieldStatus, v)) -} - -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldStatus, v)) -} - -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.Role { - return predicate.Role(sql.FieldLT(FieldStatus, v)) -} - -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldStatus, v)) -} - -// HasUsers applies the HasEdge predicate on the "users" edge. -func HasUsers() predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUsersWith applies the HasEdge predicate on the "users" edge with a given conditions (other predicates). -func HasUsersWith(preds ...predicate.User) predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := newUsersStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermissions applies the HasEdge predicate on the "permissions" edge. -func HasPermissions() predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). -func HasPermissionsWith(preds ...predicate.Permission) predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := newPermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasUserRoles applies the HasEdge predicate on the "user_roles" edge. -func HasUserRoles() predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserRolesWith applies the HasEdge predicate on the "user_roles" edge with a given conditions (other predicates). -func HasUserRolesWith(preds ...predicate.UserRole) predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := newUserRolesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasRolePermissions applies the HasEdge predicate on the "role_permissions" edge. -func HasRolePermissions() predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRolePermissionsWith applies the HasEdge predicate on the "role_permissions" edge with a given conditions (other predicates). -func HasRolePermissionsWith(preds ...predicate.RolePermission) predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := newRolePermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Role) predicate.Role { - return predicate.Role(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Role) predicate.Role { - return predicate.Role(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Role) predicate.Role { - return predicate.Role(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/rolepermission/rolepermission.go b/internal/mods/system/dal/entity/ent/rolepermission/rolepermission.go deleted file mode 100644 index f5e2fac3..00000000 --- a/internal/mods/system/dal/entity/ent/rolepermission/rolepermission.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package rolepermission - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the rolepermission type in the database. - Label = "role_permission" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldRoleID holds the string denoting the role_id field in the database. - FieldRoleID = "role_id" - // FieldPermissionID holds the string denoting the permission_id field in the database. - FieldPermissionID = "permission_id" - // EdgeRole holds the string denoting the role edge name in mutations. - EdgeRole = "role" - // EdgePermission holds the string denoting the permission edge name in mutations. - EdgePermission = "permission" - // Table holds the table name of the rolepermission in the database. - Table = "sys_role_permissions" - // RoleTable is the table that holds the role relation/edge. - RoleTable = "sys_role_permissions" - // RoleInverseTable is the table name for the Role entity. - // It exists in this package in order to avoid circular dependency with the "role" package. - RoleInverseTable = "sys_roles" - // RoleColumn is the table column denoting the role relation/edge. - RoleColumn = "role_id" - // PermissionTable is the table that holds the permission relation/edge. - PermissionTable = "sys_role_permissions" - // PermissionInverseTable is the table name for the Permission entity. - // It exists in this package in order to avoid circular dependency with the "permission" package. - PermissionInverseTable = "sys_permissions" - // PermissionColumn is the table column denoting the permission relation/edge. - PermissionColumn = "permission_id" -) - -// Columns holds all SQL columns for rolepermission fields. -var Columns = []string{ - FieldID, - FieldRoleID, - FieldPermissionID, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // RoleIDValidator is a validator for the "role_id" field. It is called by the builders before save. - RoleIDValidator func(int64) error - // PermissionIDValidator is a validator for the "permission_id" field. It is called by the builders before save. - PermissionIDValidator func(int64) error -) - -// OrderOption defines the ordering options for the RolePermission queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByRoleID orders the results by the role_id field. -func ByRoleID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRoleID, opts...).ToFunc() -} - -// ByPermissionID orders the results by the permission_id field. -func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPermissionID, opts...).ToFunc() -} - -// ByRoleField orders the results by role field. -func ByRoleField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRoleStep(), sql.OrderByField(field, opts...)) - } -} - -// ByPermissionField orders the results by permission field. -func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) - } -} -func newRoleStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RoleInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), - ) -} -func newPermissionStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/rolepermission/where.go b/internal/mods/system/dal/entity/ent/rolepermission/where.go deleted file mode 100644 index e75a7950..00000000 --- a/internal/mods/system/dal/entity/ent/rolepermission/where.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package rolepermission - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldLTE(FieldID, id)) -} - -// RoleID applies equality check predicate on the "role_id" field. It's identical to RoleIDEQ. -func RoleID(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldRoleID, v)) -} - -// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. -func PermissionID(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldPermissionID, v)) -} - -// RoleIDEQ applies the EQ predicate on the "role_id" field. -func RoleIDEQ(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldRoleID, v)) -} - -// RoleIDNEQ applies the NEQ predicate on the "role_id" field. -func RoleIDNEQ(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNEQ(FieldRoleID, v)) -} - -// RoleIDIn applies the In predicate on the "role_id" field. -func RoleIDIn(vs ...int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldIn(FieldRoleID, vs...)) -} - -// RoleIDNotIn applies the NotIn predicate on the "role_id" field. -func RoleIDNotIn(vs ...int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNotIn(FieldRoleID, vs...)) -} - -// PermissionIDEQ applies the EQ predicate on the "permission_id" field. -func PermissionIDEQ(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldPermissionID, v)) -} - -// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. -func PermissionIDNEQ(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNEQ(FieldPermissionID, v)) -} - -// PermissionIDIn applies the In predicate on the "permission_id" field. -func PermissionIDIn(vs ...int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldIn(FieldPermissionID, vs...)) -} - -// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. -func PermissionIDNotIn(vs ...int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNotIn(FieldPermissionID, vs...)) -} - -// HasRole applies the HasEdge predicate on the "role" edge. -func HasRole() predicate.RolePermission { - return predicate.RolePermission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRoleWith applies the HasEdge predicate on the "role" edge with a given conditions (other predicates). -func HasRoleWith(preds ...predicate.Role) predicate.RolePermission { - return predicate.RolePermission(func(s *sql.Selector) { - step := newRoleStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermission applies the HasEdge predicate on the "permission" edge. -func HasPermission() predicate.RolePermission { - return predicate.RolePermission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). -func HasPermissionWith(preds ...predicate.Permission) predicate.RolePermission { - return predicate.RolePermission(func(s *sql.Selector) { - step := newPermissionStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.RolePermission) predicate.RolePermission { - return predicate.RolePermission(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.RolePermission) predicate.RolePermission { - return predicate.RolePermission(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.RolePermission) predicate.RolePermission { - return predicate.RolePermission(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/template/crud.tpl b/internal/mods/system/dal/entity/ent/template/crud.tpl deleted file mode 100644 index d119b8c5..00000000 --- a/internal/mods/system/dal/entity/ent/template/crud.tpl +++ /dev/null @@ -1,40 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Graph */}} - -{{ define "crud" }} - {{- $pkg := base $.Config.Package -}} - {{- template "header" $ -}} - - {{/* Additional dependencies injected to config. */}} - {{ $deps := list }}{{ with $.Config.Annotations }}{{ $deps = $.Config.Annotations.Dependencies }}{{ end }} - - import ( - "log" - - "entgo.io/ent/dialect" - - {{- range $n := $.Nodes }} - {{ $n.PackageAlias }} "{{ $n.Config.Package }}/{{ $n.PackageDir }}" - {{- end }} - {{- range $dep := $deps }} - {{ $dep.Type.PkgName }} "{{ $dep.Type.PkgPath }}" - {{- end }} - "{{ $.Config.Package }}/migrate" - {{- range $import := $.Storage.Imports }} - "{{ $import }}" - {{- end -}} - {{- template "import/additional" $ }} - ) - - {{ range $n := $.Nodes }} - {{- /* Support adding create methods by global templates. */}} - {{- with $tmpls := matchTemplate "crud/helper/*" }} - {{- range $tmpl := $tmpls }} - {{ xtemplate $tmpl $n }} - {{- end }} - {{- end }} - {{ end }} - -{{ end }} - - diff --git a/internal/mods/system/dal/entity/ent/template/crud_create.tpl b/internal/mods/system/dal/entity/ent/template/crud_create.tpl deleted file mode 100644 index bfd1fa84..00000000 --- a/internal/mods/system/dal/entity/ent/template/crud_create.tpl +++ /dev/null @@ -1,34 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Graph */}} - -{{ define "create/additional/crud" }} - - {{ $builder := .CreateName }} - {{ $receiver := .CreateReceiver }} - {{ $fields := .Fields }} - {{- $const := print .Package}} - {{- if .ID.UserDefined }} - {{ $fields = append $fields .ID }} - {{- end }} - - {{ print "// Set" .Name " set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{ $const }}.Columns - } - _ = m.SetFields(input, fields...) - return {{ $receiver }} - } - - {{ print "// Set" .Name "WithZero set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{ $const }}.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return {{ $receiver }} - } - -{{- end -}} diff --git a/internal/mods/system/dal/entity/ent/template/crud_query.tpl b/internal/mods/system/dal/entity/ent/template/crud_query.tpl deleted file mode 100644 index da033c1d..00000000 --- a/internal/mods/system/dal/entity/ent/template/crud_query.tpl +++ /dev/null @@ -1,48 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Type */}} - -{{ define "query/additional/crud" }} - - {{ $pkg := .Package }} - {{ $fields := .Fields }} - {{ $builder := .QueryName }} - {{ $receiver := receiver $builder }} - {{ $selectBuilder := pascal .Name | printf "%sSelect" }} - - // Omit allows the unselect one or more fields/columns for the given query, - // instead of selecting all fields in the entity. - {{- with len $fields }} - // Example: - // - // var v []struct { - {{- range $f := $fields }} - // {{ $f.StructField }} {{ $f.Type }} `{{ $f.StructTag }}` - {{- end }} - // } - // - // client.{{ pascal $.Name }}.Query(). - // Omit( - {{- range $f := $fields }} - // {{ $pkg }}.{{ $f.Constant }}, - {{- end }} - // ). - // Scan(ctx, &v) - {{- end }} - func ({{ $receiver }} *{{ $builder }}) Omit(fields ...string) *{{ $selectBuilder }} { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - for _, col := range {{ $pkg }}.Columns { - if _, ok := omits[col]; !ok { - {{ $receiver }}.ctx.Fields = append({{ $receiver }}.ctx.Fields, col) - } - } - - sbuild := &{{ $selectBuilder }}{ {{ $builder }}: {{ $receiver }} } - sbuild.label = {{ $pkg }}.Label - sbuild.flds, sbuild.scan = &{{ $receiver }}.ctx.Fields, sbuild.Scan - return sbuild - } - -{{- end -}} diff --git a/internal/mods/system/dal/entity/ent/template/crud_update.tpl b/internal/mods/system/dal/entity/ent/template/crud_update.tpl deleted file mode 100644 index 17b34147..00000000 --- a/internal/mods/system/dal/entity/ent/template/crud_update.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Graph */}} - -{{ define "update/additional/crud/update" }} - - {{ $builder := .UpdateName }} - {{ $receiver := receiver $builder }} - {{ $fields := .Fields }} - {{- if or (hasSuffix $builder "Update") (hasSuffix $builder "UpdateOne") }} - {{ $fields = .MutableFields }} - {{- end }} - - {{ print "// Set" .Name " set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { - {{- $const := print .Package}} - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{$const}}.OmitColumns({{$const}}.FieldID) - } - _ = m.SetFields(input, fields...) - return {{ $receiver }} - } - - {{ print "// Set" .Name "WithZero set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{ $const }}.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return {{ $receiver }} - } -{{- end -}} diff --git a/internal/mods/system/dal/entity/ent/template/crud_update_one.tpl b/internal/mods/system/dal/entity/ent/template/crud_update_one.tpl deleted file mode 100644 index e384a498..00000000 --- a/internal/mods/system/dal/entity/ent/template/crud_update_one.tpl +++ /dev/null @@ -1,48 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Graph */}} - -{{ define "update/additional/crud_one" }} - {{ $builder := $.UpdateOneName }} - {{- if hasSuffix $builder "UpdateOne" }} - {{ $receiver := receiver $builder }} - {{ print "// Set" .Name " set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { - {{- $const := print .Package}} - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{$const}}.OmitColumns({{$const}}.FieldID) - } - _ = m.SetFields(input, fields...) - return {{ $receiver }} - } - - {{ print "// Set" .Name "WithZero set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{ $const }}.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return {{ $receiver }} - } - - {{ $onebuilder := $.UpdateOneName }} - {{ $receiver = receiver $onebuilder }} - // Omit allows the unselect one or more fields/columns for the given query, - // instead of selecting all fields in the entity. - func ({{ $receiver }} *{{ $onebuilder }}) Omit(fields ...string) *{{ $onebuilder }} { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - {{ $receiver }}.fields = []string(nil) - for _, col := range {{ .Package }}.Columns { - if _, ok := omits[col]; !ok { - {{ $receiver }}.fields = append({{ $receiver }}.fields, col) - } - } - return {{ $receiver }} - } - {{- end }} - -{{- end -}} diff --git a/internal/mods/system/dal/entity/ent/template/type_meta_fields.tpl b/internal/mods/system/dal/entity/ent/template/type_meta_fields.tpl deleted file mode 100644 index 5cd85559..00000000 --- a/internal/mods/system/dal/entity/ent/template/type_meta_fields.tpl +++ /dev/null @@ -1,67 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Type*/}} - -{{ define "meta/additional/fields" }} - - // SelectColumns returns all selected fields. - func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields - } - - // OmitColumns returns all fields that are not in the list of fields. - func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns,fields, true) - } - - // OmitCustomColumns returns all fields that are not in the list of fields. - func OmitCustomColumns(src []string,fields ...string) []string { - if len(src) == 0 { - src= Columns - } - // Default removal FieldID - return omitColumns(src,fields, true) - } - - // OmitColumnsWithID returns all fields that are not in the list of fields. - func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns,fields, false) - } - - // OmitCustomColumns returns all fields that are not in the list of fields. - func OmitCustomColumnsWithID(src []string,fields ...string) []string { - if len(src) == 0 { - src= Columns - } - // Not remove FieldID - return omitColumns(src,fields, false) - } - - func omitColumns(src []string,fields []string,omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields - } - - func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false - } -{{ end }} diff --git a/internal/mods/system/dal/entity/ent/user/user.go b/internal/mods/system/dal/entity/ent/user/user.go deleted file mode 100644 index 74438628..00000000 --- a/internal/mods/system/dal/entity/ent/user/user.go +++ /dev/null @@ -1,625 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package user - -import ( - "fmt" - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the user type in the database. - Label = "user" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateAuthor holds the string denoting the create_author field in the database. - FieldCreateAuthor = "create_author" - // FieldUpdateAuthor holds the string denoting the update_author field in the database. - FieldUpdateAuthor = "update_author" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldDeleteTime holds the string denoting the delete_time field in the database. - FieldDeleteTime = "delete_time" - // FieldUUID holds the string denoting the uuid field in the database. - FieldUUID = "uuid" - // FieldAllowedIP holds the string denoting the allowed_ip field in the database. - FieldAllowedIP = "allowed_ip" - // FieldUsername holds the string denoting the username field in the database. - FieldUsername = "username" - // FieldNickname holds the string denoting the nickname field in the database. - FieldNickname = "nickname" - // FieldAvatar holds the string denoting the avatar field in the database. - FieldAvatar = "avatar" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldGender holds the string denoting the gender field in the database. - FieldGender = "gender" - // FieldEncryptedPassword holds the string denoting the encrypted_password field in the database. - FieldEncryptedPassword = "encrypted_password" - // FieldSalt holds the string denoting the salt field in the database. - FieldSalt = "salt" - // FieldPhone holds the string denoting the phone field in the database. - FieldPhone = "phone" - // FieldEmail holds the string denoting the email field in the database. - FieldEmail = "email" - // FieldDepartment holds the string denoting the department field in the database. - FieldDepartment = "department" - // FieldRemark holds the string denoting the remark field in the database. - FieldRemark = "remark" - // FieldToken holds the string denoting the token field in the database. - FieldToken = "token" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" - // FieldIsSystem holds the string denoting the is_system field in the database. - FieldIsSystem = "is_system" - // FieldLastLoginIP holds the string denoting the last_login_ip field in the database. - FieldLastLoginIP = "last_login_ip" - // FieldLastLoginTime holds the string denoting the last_login_time field in the database. - FieldLastLoginTime = "last_login_time" - // FieldLoginTime holds the string denoting the login_time field in the database. - FieldLoginTime = "login_time" - // FieldSanctionDate holds the string denoting the sanction_date field in the database. - FieldSanctionDate = "sanction_date" - // FieldManagerID holds the string denoting the manager_id field in the database. - FieldManagerID = "manager_id" - // FieldManager holds the string denoting the manager field in the database. - FieldManager = "manager" - // EdgeRoles holds the string denoting the roles edge name in mutations. - EdgeRoles = "roles" - // EdgePositions holds the string denoting the positions edge name in mutations. - EdgePositions = "positions" - // EdgeDepartments holds the string denoting the departments edge name in mutations. - EdgeDepartments = "departments" - // EdgeUserRoles holds the string denoting the user_roles edge name in mutations. - EdgeUserRoles = "user_roles" - // EdgeUserPositions holds the string denoting the user_positions edge name in mutations. - EdgeUserPositions = "user_positions" - // EdgeUserDepartments holds the string denoting the user_departments edge name in mutations. - EdgeUserDepartments = "user_departments" - // Table holds the table name of the user in the database. - Table = "sys_users" - // RolesTable is the table that holds the roles relation/edge. The primary key declared below. - RolesTable = "sys_user_roles" - // RolesInverseTable is the table name for the Role entity. - // It exists in this package in order to avoid circular dependency with the "role" package. - RolesInverseTable = "sys_roles" - // PositionsTable is the table that holds the positions relation/edge. The primary key declared below. - PositionsTable = "sys_user_positions" - // PositionsInverseTable is the table name for the Position entity. - // It exists in this package in order to avoid circular dependency with the "position" package. - PositionsInverseTable = "sys_positions" - // DepartmentsTable is the table that holds the departments relation/edge. The primary key declared below. - DepartmentsTable = "sys_user_departments" - // DepartmentsInverseTable is the table name for the Department entity. - // It exists in this package in order to avoid circular dependency with the "department" package. - DepartmentsInverseTable = "sys_departments" - // UserRolesTable is the table that holds the user_roles relation/edge. - UserRolesTable = "sys_user_roles" - // UserRolesInverseTable is the table name for the UserRole entity. - // It exists in this package in order to avoid circular dependency with the "userrole" package. - UserRolesInverseTable = "sys_user_roles" - // UserRolesColumn is the table column denoting the user_roles relation/edge. - UserRolesColumn = "user_id" - // UserPositionsTable is the table that holds the user_positions relation/edge. - UserPositionsTable = "sys_user_positions" - // UserPositionsInverseTable is the table name for the UserPosition entity. - // It exists in this package in order to avoid circular dependency with the "userposition" package. - UserPositionsInverseTable = "sys_user_positions" - // UserPositionsColumn is the table column denoting the user_positions relation/edge. - UserPositionsColumn = "user_id" - // UserDepartmentsTable is the table that holds the user_departments relation/edge. - UserDepartmentsTable = "sys_user_departments" - // UserDepartmentsInverseTable is the table name for the UserDepartment entity. - // It exists in this package in order to avoid circular dependency with the "userdepartment" package. - UserDepartmentsInverseTable = "sys_user_departments" - // UserDepartmentsColumn is the table column denoting the user_departments relation/edge. - UserDepartmentsColumn = "user_id" -) - -// Columns holds all SQL columns for user fields. -var Columns = []string{ - FieldID, - FieldCreateAuthor, - FieldUpdateAuthor, - FieldCreateTime, - FieldUpdateTime, - FieldDeleteTime, - FieldUUID, - FieldAllowedIP, - FieldUsername, - FieldNickname, - FieldAvatar, - FieldName, - FieldGender, - FieldEncryptedPassword, - FieldPhone, - FieldEmail, - FieldDepartment, - FieldRemark, - FieldToken, - FieldStatus, - FieldIsSystem, - FieldLastLoginIP, - FieldLastLoginTime, - FieldLoginTime, - FieldSanctionDate, - FieldManagerID, - FieldManager, -} - -var ( - // RolesPrimaryKey and RolesColumn2 are the table columns denoting the - // primary key for the roles relation (M2M). - RolesPrimaryKey = []string{"user_id", "role_id"} - // PositionsPrimaryKey and PositionsColumn2 are the table columns denoting the - // primary key for the positions relation (M2M). - PositionsPrimaryKey = []string{"user_id", "position_id"} - // DepartmentsPrimaryKey and DepartmentsColumn2 are the table columns denoting the - // primary key for the departments relation (M2M). - DepartmentsPrimaryKey = []string{"user_id", "department_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - for _, f := range [...]string{FieldSalt} { - if column == f { - return true - } - } - return false -} - -// Note that the variables below are initialized by the runtime -// package on the initialization of the application. Therefore, -// it should be imported in the main as follows: -// -// import _ "origadmin/application/admin/internal/mods/system/dal/entity/ent/runtime" -var ( - Hooks [2]ent.Hook - Interceptors [1]ent.Interceptor - // DefaultCreateAuthor holds the default value on creation for the "create_author" field. - DefaultCreateAuthor int64 - // DefaultUpdateAuthor holds the default value on creation for the "update_author" field. - DefaultUpdateAuthor int64 - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() time.Time - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() time.Time - // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. - UpdateDefaultUpdateTime func() time.Time - // UUIDValidator is a validator for the "uuid" field. It is called by the builders before save. - UUIDValidator func(string) error - // DefaultAllowedIP holds the default value on creation for the "allowed_ip" field. - DefaultAllowedIP string - // UsernameValidator is a validator for the "username" field. It is called by the builders before save. - UsernameValidator func(string) error - // DefaultNickname holds the default value on creation for the "nickname" field. - DefaultNickname string - // NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. - NicknameValidator func(string) error - // DefaultAvatar holds the default value on creation for the "avatar" field. - DefaultAvatar string - // AvatarValidator is a validator for the "avatar" field. It is called by the builders before save. - AvatarValidator func(string) error - // DefaultName holds the default value on creation for the "name" field. - DefaultName string - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // DefaultEncryptedPassword holds the default value on creation for the "encrypted_password" field. - DefaultEncryptedPassword string - // EncryptedPasswordValidator is a validator for the "encrypted_password" field. It is called by the builders before save. - EncryptedPasswordValidator func(string) error - // DefaultSalt holds the default value on creation for the "salt" field. - DefaultSalt string - // SaltValidator is a validator for the "salt" field. It is called by the builders before save. - SaltValidator func(string) error - // DefaultPhone holds the default value on creation for the "phone" field. - DefaultPhone string - // PhoneValidator is a validator for the "phone" field. It is called by the builders before save. - PhoneValidator func(string) error - // DefaultEmail holds the default value on creation for the "email" field. - DefaultEmail string - // EmailValidator is a validator for the "email" field. It is called by the builders before save. - EmailValidator func(string) error - // DefaultDepartment holds the default value on creation for the "department" field. - DefaultDepartment string - // DepartmentValidator is a validator for the "department" field. It is called by the builders before save. - DepartmentValidator func(string) error - // DefaultRemark holds the default value on creation for the "remark" field. - DefaultRemark string - // RemarkValidator is a validator for the "remark" field. It is called by the builders before save. - RemarkValidator func(string) error - // DefaultToken holds the default value on creation for the "token" field. - DefaultToken string - // TokenValidator is a validator for the "token" field. It is called by the builders before save. - TokenValidator func(string) error - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 - // DefaultIsSystem holds the default value on creation for the "is_system" field. - DefaultIsSystem bool - // DefaultLastLoginIP holds the default value on creation for the "last_login_ip" field. - DefaultLastLoginIP string - // LastLoginIPValidator is a validator for the "last_login_ip" field. It is called by the builders before save. - LastLoginIPValidator func(string) error - // DefaultLastLoginTime holds the default value on creation for the "last_login_time" field. - DefaultLastLoginTime func() time.Time - // DefaultLoginTime holds the default value on creation for the "login_time" field. - DefaultLoginTime func() time.Time - // ManagerIDValidator is a validator for the "manager_id" field. It is called by the builders before save. - ManagerIDValidator func(int64) error - // DefaultManager holds the default value on creation for the "manager" field. - DefaultManager string - // DefaultID holds the default value on creation for the "id" field. - DefaultID func() int64 - // IDValidator is a validator for the "id" field. It is called by the builders before save. - IDValidator func(int64) error -) - -// Gender defines the type for the "gender" enum field. -type Gender string - -// GenderUnknown is the default value of the Gender enum. -const DefaultGender = GenderUnknown - -// Gender values. -const ( - GenderMale Gender = "male" - GenderFemale Gender = "female" - GenderUnknown Gender = "unknown" -) - -func (ge Gender) String() string { - return string(ge) -} - -// GenderValidator is a validator for the "gender" field enum values. It is called by the builders before save. -func GenderValidator(ge Gender) error { - switch ge { - case GenderMale, GenderFemale, GenderUnknown: - return nil - default: - return fmt.Errorf("user: invalid enum value for gender field: %q", ge) - } -} - -// OrderOption defines the ordering options for the User queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateAuthor orders the results by the create_author field. -func ByCreateAuthor(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateAuthor, opts...).ToFunc() -} - -// ByUpdateAuthor orders the results by the update_author field. -func ByUpdateAuthor(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateAuthor, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByDeleteTime orders the results by the delete_time field. -func ByDeleteTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDeleteTime, opts...).ToFunc() -} - -// ByUUID orders the results by the uuid field. -func ByUUID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUUID, opts...).ToFunc() -} - -// ByAllowedIP orders the results by the allowed_ip field. -func ByAllowedIP(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldAllowedIP, opts...).ToFunc() -} - -// ByUsername orders the results by the username field. -func ByUsername(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUsername, opts...).ToFunc() -} - -// ByNickname orders the results by the nickname field. -func ByNickname(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldNickname, opts...).ToFunc() -} - -// ByAvatar orders the results by the avatar field. -func ByAvatar(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldAvatar, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByGender orders the results by the gender field. -func ByGender(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldGender, opts...).ToFunc() -} - -// ByEncryptedPassword orders the results by the encrypted_password field. -func ByEncryptedPassword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldEncryptedPassword, opts...).ToFunc() -} - -// BySalt orders the results by the salt field. -func BySalt(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSalt, opts...).ToFunc() -} - -// ByPhone orders the results by the phone field. -func ByPhone(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPhone, opts...).ToFunc() -} - -// ByEmail orders the results by the email field. -func ByEmail(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldEmail, opts...).ToFunc() -} - -// ByDepartment orders the results by the department field. -func ByDepartment(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDepartment, opts...).ToFunc() -} - -// ByRemark orders the results by the remark field. -func ByRemark(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRemark, opts...).ToFunc() -} - -// ByToken orders the results by the token field. -func ByToken(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldToken, opts...).ToFunc() -} - -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - -// ByIsSystem orders the results by the is_system field. -func ByIsSystem(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldIsSystem, opts...).ToFunc() -} - -// ByLastLoginIP orders the results by the last_login_ip field. -func ByLastLoginIP(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldLastLoginIP, opts...).ToFunc() -} - -// ByLastLoginTime orders the results by the last_login_time field. -func ByLastLoginTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldLastLoginTime, opts...).ToFunc() -} - -// ByLoginTime orders the results by the login_time field. -func ByLoginTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldLoginTime, opts...).ToFunc() -} - -// BySanctionDate orders the results by the sanction_date field. -func BySanctionDate(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSanctionDate, opts...).ToFunc() -} - -// ByManagerID orders the results by the manager_id field. -func ByManagerID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldManagerID, opts...).ToFunc() -} - -// ByManager orders the results by the manager field. -func ByManager(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldManager, opts...).ToFunc() -} - -// ByRolesCount orders the results by roles count. -func ByRolesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...) - } -} - -// ByRoles orders the results by roles terms. -func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPositionsCount orders the results by positions count. -func ByPositionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPositionsStep(), opts...) - } -} - -// ByPositions orders the results by positions terms. -func ByPositions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPositionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByDepartmentsCount orders the results by departments count. -func ByDepartmentsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newDepartmentsStep(), opts...) - } -} - -// ByDepartments orders the results by departments terms. -func ByDepartments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newDepartmentsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByUserRolesCount orders the results by user_roles count. -func ByUserRolesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUserRolesStep(), opts...) - } -} - -// ByUserRoles orders the results by user_roles terms. -func ByUserRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserRolesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByUserPositionsCount orders the results by user_positions count. -func ByUserPositionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUserPositionsStep(), opts...) - } -} - -// ByUserPositions orders the results by user_positions terms. -func ByUserPositions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserPositionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByUserDepartmentsCount orders the results by user_departments count. -func ByUserDepartmentsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUserDepartmentsStep(), opts...) - } -} - -// ByUserDepartments orders the results by user_departments terms. -func ByUserDepartments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserDepartmentsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newRolesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RolesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...), - ) -} -func newPositionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PositionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, PositionsTable, PositionsPrimaryKey...), - ) -} -func newDepartmentsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(DepartmentsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, DepartmentsTable, DepartmentsPrimaryKey...), - ) -} -func newUserRolesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserRolesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), - ) -} -func newUserPositionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserPositionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserPositionsTable, UserPositionsColumn), - ) -} -func newUserDepartmentsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserDepartmentsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserDepartmentsTable, UserDepartmentsColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/user/where.go b/internal/mods/system/dal/entity/ent/user/where.go deleted file mode 100644 index 38cc86e8..00000000 --- a/internal/mods/system/dal/entity/ent/user/where.go +++ /dev/null @@ -1,1794 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package user - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.User { - return predicate.User(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.User { - return predicate.User(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.User { - return predicate.User(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.User { - return predicate.User(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.User { - return predicate.User(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.User { - return predicate.User(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.User { - return predicate.User(sql.FieldLTE(FieldID, id)) -} - -// CreateAuthor applies equality check predicate on the "create_author" field. It's identical to CreateAuthorEQ. -func CreateAuthor(v int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldCreateAuthor, v)) -} - -// UpdateAuthor applies equality check predicate on the "update_author" field. It's identical to UpdateAuthorEQ. -func UpdateAuthor(v int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldUpdateAuthor, v)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldUpdateTime, v)) -} - -// DeleteTime applies equality check predicate on the "delete_time" field. It's identical to DeleteTimeEQ. -func DeleteTime(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldDeleteTime, v)) -} - -// UUID applies equality check predicate on the "uuid" field. It's identical to UUIDEQ. -func UUID(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldUUID, v)) -} - -// AllowedIP applies equality check predicate on the "allowed_ip" field. It's identical to AllowedIPEQ. -func AllowedIP(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldAllowedIP, v)) -} - -// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. -func Username(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldUsername, v)) -} - -// Nickname applies equality check predicate on the "nickname" field. It's identical to NicknameEQ. -func Nickname(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldNickname, v)) -} - -// Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ. -func Avatar(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldAvatar, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldName, v)) -} - -// EncryptedPassword applies equality check predicate on the "encrypted_password" field. It's identical to EncryptedPasswordEQ. -func EncryptedPassword(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldEncryptedPassword, v)) -} - -// Salt applies equality check predicate on the "salt" field. It's identical to SaltEQ. -func Salt(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldSalt, v)) -} - -// Phone applies equality check predicate on the "phone" field. It's identical to PhoneEQ. -func Phone(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldPhone, v)) -} - -// Email applies equality check predicate on the "email" field. It's identical to EmailEQ. -func Email(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldEmail, v)) -} - -// Department applies equality check predicate on the "department" field. It's identical to DepartmentEQ. -func Department(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldDepartment, v)) -} - -// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ. -func Remark(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldRemark, v)) -} - -// Token applies equality check predicate on the "token" field. It's identical to TokenEQ. -func Token(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldToken, v)) -} - -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.User { - return predicate.User(sql.FieldEQ(FieldStatus, v)) -} - -// IsSystem applies equality check predicate on the "is_system" field. It's identical to IsSystemEQ. -func IsSystem(v bool) predicate.User { - return predicate.User(sql.FieldEQ(FieldIsSystem, v)) -} - -// LastLoginIP applies equality check predicate on the "last_login_ip" field. It's identical to LastLoginIPEQ. -func LastLoginIP(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldLastLoginIP, v)) -} - -// LastLoginTime applies equality check predicate on the "last_login_time" field. It's identical to LastLoginTimeEQ. -func LastLoginTime(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldLastLoginTime, v)) -} - -// LoginTime applies equality check predicate on the "login_time" field. It's identical to LoginTimeEQ. -func LoginTime(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldLoginTime, v)) -} - -// SanctionDate applies equality check predicate on the "sanction_date" field. It's identical to SanctionDateEQ. -func SanctionDate(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldSanctionDate, v)) -} - -// ManagerID applies equality check predicate on the "manager_id" field. It's identical to ManagerIDEQ. -func ManagerID(v int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldManagerID, v)) -} - -// Manager applies equality check predicate on the "manager" field. It's identical to ManagerEQ. -func Manager(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldManager, v)) -} - -// CreateAuthorEQ applies the EQ predicate on the "create_author" field. -func CreateAuthorEQ(v int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldCreateAuthor, v)) -} - -// CreateAuthorNEQ applies the NEQ predicate on the "create_author" field. -func CreateAuthorNEQ(v int64) predicate.User { - return predicate.User(sql.FieldNEQ(FieldCreateAuthor, v)) -} - -// CreateAuthorIn applies the In predicate on the "create_author" field. -func CreateAuthorIn(vs ...int64) predicate.User { - return predicate.User(sql.FieldIn(FieldCreateAuthor, vs...)) -} - -// CreateAuthorNotIn applies the NotIn predicate on the "create_author" field. -func CreateAuthorNotIn(vs ...int64) predicate.User { - return predicate.User(sql.FieldNotIn(FieldCreateAuthor, vs...)) -} - -// CreateAuthorGT applies the GT predicate on the "create_author" field. -func CreateAuthorGT(v int64) predicate.User { - return predicate.User(sql.FieldGT(FieldCreateAuthor, v)) -} - -// CreateAuthorGTE applies the GTE predicate on the "create_author" field. -func CreateAuthorGTE(v int64) predicate.User { - return predicate.User(sql.FieldGTE(FieldCreateAuthor, v)) -} - -// CreateAuthorLT applies the LT predicate on the "create_author" field. -func CreateAuthorLT(v int64) predicate.User { - return predicate.User(sql.FieldLT(FieldCreateAuthor, v)) -} - -// CreateAuthorLTE applies the LTE predicate on the "create_author" field. -func CreateAuthorLTE(v int64) predicate.User { - return predicate.User(sql.FieldLTE(FieldCreateAuthor, v)) -} - -// CreateAuthorIsNil applies the IsNil predicate on the "create_author" field. -func CreateAuthorIsNil() predicate.User { - return predicate.User(sql.FieldIsNull(FieldCreateAuthor)) -} - -// CreateAuthorNotNil applies the NotNil predicate on the "create_author" field. -func CreateAuthorNotNil() predicate.User { - return predicate.User(sql.FieldNotNull(FieldCreateAuthor)) -} - -// UpdateAuthorEQ applies the EQ predicate on the "update_author" field. -func UpdateAuthorEQ(v int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldUpdateAuthor, v)) -} - -// UpdateAuthorNEQ applies the NEQ predicate on the "update_author" field. -func UpdateAuthorNEQ(v int64) predicate.User { - return predicate.User(sql.FieldNEQ(FieldUpdateAuthor, v)) -} - -// UpdateAuthorIn applies the In predicate on the "update_author" field. -func UpdateAuthorIn(vs ...int64) predicate.User { - return predicate.User(sql.FieldIn(FieldUpdateAuthor, vs...)) -} - -// UpdateAuthorNotIn applies the NotIn predicate on the "update_author" field. -func UpdateAuthorNotIn(vs ...int64) predicate.User { - return predicate.User(sql.FieldNotIn(FieldUpdateAuthor, vs...)) -} - -// UpdateAuthorGT applies the GT predicate on the "update_author" field. -func UpdateAuthorGT(v int64) predicate.User { - return predicate.User(sql.FieldGT(FieldUpdateAuthor, v)) -} - -// UpdateAuthorGTE applies the GTE predicate on the "update_author" field. -func UpdateAuthorGTE(v int64) predicate.User { - return predicate.User(sql.FieldGTE(FieldUpdateAuthor, v)) -} - -// UpdateAuthorLT applies the LT predicate on the "update_author" field. -func UpdateAuthorLT(v int64) predicate.User { - return predicate.User(sql.FieldLT(FieldUpdateAuthor, v)) -} - -// UpdateAuthorLTE applies the LTE predicate on the "update_author" field. -func UpdateAuthorLTE(v int64) predicate.User { - return predicate.User(sql.FieldLTE(FieldUpdateAuthor, v)) -} - -// UpdateAuthorIsNil applies the IsNil predicate on the "update_author" field. -func UpdateAuthorIsNil() predicate.User { - return predicate.User(sql.FieldIsNull(FieldUpdateAuthor)) -} - -// UpdateAuthorNotNil applies the NotNil predicate on the "update_author" field. -func UpdateAuthorNotNil() predicate.User { - return predicate.User(sql.FieldNotNull(FieldUpdateAuthor)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v time.Time) predicate.User { - return predicate.User(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v time.Time) predicate.User { - return predicate.User(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v time.Time) predicate.User { - return predicate.User(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v time.Time) predicate.User { - return predicate.User(sql.FieldLTE(FieldCreateTime, v)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v time.Time) predicate.User { - return predicate.User(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v time.Time) predicate.User { - return predicate.User(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v time.Time) predicate.User { - return predicate.User(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v time.Time) predicate.User { - return predicate.User(sql.FieldLTE(FieldUpdateTime, v)) -} - -// DeleteTimeEQ applies the EQ predicate on the "delete_time" field. -func DeleteTimeEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldDeleteTime, v)) -} - -// DeleteTimeNEQ applies the NEQ predicate on the "delete_time" field. -func DeleteTimeNEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldNEQ(FieldDeleteTime, v)) -} - -// DeleteTimeIn applies the In predicate on the "delete_time" field. -func DeleteTimeIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldIn(FieldDeleteTime, vs...)) -} - -// DeleteTimeNotIn applies the NotIn predicate on the "delete_time" field. -func DeleteTimeNotIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldNotIn(FieldDeleteTime, vs...)) -} - -// DeleteTimeGT applies the GT predicate on the "delete_time" field. -func DeleteTimeGT(v time.Time) predicate.User { - return predicate.User(sql.FieldGT(FieldDeleteTime, v)) -} - -// DeleteTimeGTE applies the GTE predicate on the "delete_time" field. -func DeleteTimeGTE(v time.Time) predicate.User { - return predicate.User(sql.FieldGTE(FieldDeleteTime, v)) -} - -// DeleteTimeLT applies the LT predicate on the "delete_time" field. -func DeleteTimeLT(v time.Time) predicate.User { - return predicate.User(sql.FieldLT(FieldDeleteTime, v)) -} - -// DeleteTimeLTE applies the LTE predicate on the "delete_time" field. -func DeleteTimeLTE(v time.Time) predicate.User { - return predicate.User(sql.FieldLTE(FieldDeleteTime, v)) -} - -// DeleteTimeIsNil applies the IsNil predicate on the "delete_time" field. -func DeleteTimeIsNil() predicate.User { - return predicate.User(sql.FieldIsNull(FieldDeleteTime)) -} - -// DeleteTimeNotNil applies the NotNil predicate on the "delete_time" field. -func DeleteTimeNotNil() predicate.User { - return predicate.User(sql.FieldNotNull(FieldDeleteTime)) -} - -// UUIDEQ applies the EQ predicate on the "uuid" field. -func UUIDEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldUUID, v)) -} - -// UUIDNEQ applies the NEQ predicate on the "uuid" field. -func UUIDNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldUUID, v)) -} - -// UUIDIn applies the In predicate on the "uuid" field. -func UUIDIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldUUID, vs...)) -} - -// UUIDNotIn applies the NotIn predicate on the "uuid" field. -func UUIDNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldUUID, vs...)) -} - -// UUIDGT applies the GT predicate on the "uuid" field. -func UUIDGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldUUID, v)) -} - -// UUIDGTE applies the GTE predicate on the "uuid" field. -func UUIDGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldUUID, v)) -} - -// UUIDLT applies the LT predicate on the "uuid" field. -func UUIDLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldUUID, v)) -} - -// UUIDLTE applies the LTE predicate on the "uuid" field. -func UUIDLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldUUID, v)) -} - -// UUIDContains applies the Contains predicate on the "uuid" field. -func UUIDContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldUUID, v)) -} - -// UUIDHasPrefix applies the HasPrefix predicate on the "uuid" field. -func UUIDHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldUUID, v)) -} - -// UUIDHasSuffix applies the HasSuffix predicate on the "uuid" field. -func UUIDHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldUUID, v)) -} - -// UUIDEqualFold applies the EqualFold predicate on the "uuid" field. -func UUIDEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldUUID, v)) -} - -// UUIDContainsFold applies the ContainsFold predicate on the "uuid" field. -func UUIDContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldUUID, v)) -} - -// AllowedIPEQ applies the EQ predicate on the "allowed_ip" field. -func AllowedIPEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldAllowedIP, v)) -} - -// AllowedIPNEQ applies the NEQ predicate on the "allowed_ip" field. -func AllowedIPNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldAllowedIP, v)) -} - -// AllowedIPIn applies the In predicate on the "allowed_ip" field. -func AllowedIPIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldAllowedIP, vs...)) -} - -// AllowedIPNotIn applies the NotIn predicate on the "allowed_ip" field. -func AllowedIPNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldAllowedIP, vs...)) -} - -// AllowedIPGT applies the GT predicate on the "allowed_ip" field. -func AllowedIPGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldAllowedIP, v)) -} - -// AllowedIPGTE applies the GTE predicate on the "allowed_ip" field. -func AllowedIPGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldAllowedIP, v)) -} - -// AllowedIPLT applies the LT predicate on the "allowed_ip" field. -func AllowedIPLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldAllowedIP, v)) -} - -// AllowedIPLTE applies the LTE predicate on the "allowed_ip" field. -func AllowedIPLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldAllowedIP, v)) -} - -// AllowedIPContains applies the Contains predicate on the "allowed_ip" field. -func AllowedIPContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldAllowedIP, v)) -} - -// AllowedIPHasPrefix applies the HasPrefix predicate on the "allowed_ip" field. -func AllowedIPHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldAllowedIP, v)) -} - -// AllowedIPHasSuffix applies the HasSuffix predicate on the "allowed_ip" field. -func AllowedIPHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldAllowedIP, v)) -} - -// AllowedIPEqualFold applies the EqualFold predicate on the "allowed_ip" field. -func AllowedIPEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldAllowedIP, v)) -} - -// AllowedIPContainsFold applies the ContainsFold predicate on the "allowed_ip" field. -func AllowedIPContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldAllowedIP, v)) -} - -// UsernameEQ applies the EQ predicate on the "username" field. -func UsernameEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldUsername, v)) -} - -// UsernameNEQ applies the NEQ predicate on the "username" field. -func UsernameNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldUsername, v)) -} - -// UsernameIn applies the In predicate on the "username" field. -func UsernameIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldUsername, vs...)) -} - -// UsernameNotIn applies the NotIn predicate on the "username" field. -func UsernameNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldUsername, vs...)) -} - -// UsernameGT applies the GT predicate on the "username" field. -func UsernameGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldUsername, v)) -} - -// UsernameGTE applies the GTE predicate on the "username" field. -func UsernameGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldUsername, v)) -} - -// UsernameLT applies the LT predicate on the "username" field. -func UsernameLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldUsername, v)) -} - -// UsernameLTE applies the LTE predicate on the "username" field. -func UsernameLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldUsername, v)) -} - -// UsernameContains applies the Contains predicate on the "username" field. -func UsernameContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldUsername, v)) -} - -// UsernameHasPrefix applies the HasPrefix predicate on the "username" field. -func UsernameHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldUsername, v)) -} - -// UsernameHasSuffix applies the HasSuffix predicate on the "username" field. -func UsernameHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldUsername, v)) -} - -// UsernameEqualFold applies the EqualFold predicate on the "username" field. -func UsernameEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldUsername, v)) -} - -// UsernameContainsFold applies the ContainsFold predicate on the "username" field. -func UsernameContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldUsername, v)) -} - -// NicknameEQ applies the EQ predicate on the "nickname" field. -func NicknameEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldNickname, v)) -} - -// NicknameNEQ applies the NEQ predicate on the "nickname" field. -func NicknameNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldNickname, v)) -} - -// NicknameIn applies the In predicate on the "nickname" field. -func NicknameIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldNickname, vs...)) -} - -// NicknameNotIn applies the NotIn predicate on the "nickname" field. -func NicknameNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldNickname, vs...)) -} - -// NicknameGT applies the GT predicate on the "nickname" field. -func NicknameGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldNickname, v)) -} - -// NicknameGTE applies the GTE predicate on the "nickname" field. -func NicknameGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldNickname, v)) -} - -// NicknameLT applies the LT predicate on the "nickname" field. -func NicknameLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldNickname, v)) -} - -// NicknameLTE applies the LTE predicate on the "nickname" field. -func NicknameLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldNickname, v)) -} - -// NicknameContains applies the Contains predicate on the "nickname" field. -func NicknameContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldNickname, v)) -} - -// NicknameHasPrefix applies the HasPrefix predicate on the "nickname" field. -func NicknameHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldNickname, v)) -} - -// NicknameHasSuffix applies the HasSuffix predicate on the "nickname" field. -func NicknameHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldNickname, v)) -} - -// NicknameEqualFold applies the EqualFold predicate on the "nickname" field. -func NicknameEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldNickname, v)) -} - -// NicknameContainsFold applies the ContainsFold predicate on the "nickname" field. -func NicknameContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldNickname, v)) -} - -// AvatarEQ applies the EQ predicate on the "avatar" field. -func AvatarEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldAvatar, v)) -} - -// AvatarNEQ applies the NEQ predicate on the "avatar" field. -func AvatarNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldAvatar, v)) -} - -// AvatarIn applies the In predicate on the "avatar" field. -func AvatarIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldAvatar, vs...)) -} - -// AvatarNotIn applies the NotIn predicate on the "avatar" field. -func AvatarNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldAvatar, vs...)) -} - -// AvatarGT applies the GT predicate on the "avatar" field. -func AvatarGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldAvatar, v)) -} - -// AvatarGTE applies the GTE predicate on the "avatar" field. -func AvatarGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldAvatar, v)) -} - -// AvatarLT applies the LT predicate on the "avatar" field. -func AvatarLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldAvatar, v)) -} - -// AvatarLTE applies the LTE predicate on the "avatar" field. -func AvatarLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldAvatar, v)) -} - -// AvatarContains applies the Contains predicate on the "avatar" field. -func AvatarContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldAvatar, v)) -} - -// AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field. -func AvatarHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldAvatar, v)) -} - -// AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field. -func AvatarHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldAvatar, v)) -} - -// AvatarEqualFold applies the EqualFold predicate on the "avatar" field. -func AvatarEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldAvatar, v)) -} - -// AvatarContainsFold applies the ContainsFold predicate on the "avatar" field. -func AvatarContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldAvatar, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldName, v)) -} - -// GenderEQ applies the EQ predicate on the "gender" field. -func GenderEQ(v Gender) predicate.User { - return predicate.User(sql.FieldEQ(FieldGender, v)) -} - -// GenderNEQ applies the NEQ predicate on the "gender" field. -func GenderNEQ(v Gender) predicate.User { - return predicate.User(sql.FieldNEQ(FieldGender, v)) -} - -// GenderIn applies the In predicate on the "gender" field. -func GenderIn(vs ...Gender) predicate.User { - return predicate.User(sql.FieldIn(FieldGender, vs...)) -} - -// GenderNotIn applies the NotIn predicate on the "gender" field. -func GenderNotIn(vs ...Gender) predicate.User { - return predicate.User(sql.FieldNotIn(FieldGender, vs...)) -} - -// EncryptedPasswordEQ applies the EQ predicate on the "encrypted_password" field. -func EncryptedPasswordEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldEncryptedPassword, v)) -} - -// EncryptedPasswordNEQ applies the NEQ predicate on the "encrypted_password" field. -func EncryptedPasswordNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldEncryptedPassword, v)) -} - -// EncryptedPasswordIn applies the In predicate on the "encrypted_password" field. -func EncryptedPasswordIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldEncryptedPassword, vs...)) -} - -// EncryptedPasswordNotIn applies the NotIn predicate on the "encrypted_password" field. -func EncryptedPasswordNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldEncryptedPassword, vs...)) -} - -// EncryptedPasswordGT applies the GT predicate on the "encrypted_password" field. -func EncryptedPasswordGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldEncryptedPassword, v)) -} - -// EncryptedPasswordGTE applies the GTE predicate on the "encrypted_password" field. -func EncryptedPasswordGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldEncryptedPassword, v)) -} - -// EncryptedPasswordLT applies the LT predicate on the "encrypted_password" field. -func EncryptedPasswordLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldEncryptedPassword, v)) -} - -// EncryptedPasswordLTE applies the LTE predicate on the "encrypted_password" field. -func EncryptedPasswordLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldEncryptedPassword, v)) -} - -// EncryptedPasswordContains applies the Contains predicate on the "encrypted_password" field. -func EncryptedPasswordContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldEncryptedPassword, v)) -} - -// EncryptedPasswordHasPrefix applies the HasPrefix predicate on the "encrypted_password" field. -func EncryptedPasswordHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldEncryptedPassword, v)) -} - -// EncryptedPasswordHasSuffix applies the HasSuffix predicate on the "encrypted_password" field. -func EncryptedPasswordHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldEncryptedPassword, v)) -} - -// EncryptedPasswordEqualFold applies the EqualFold predicate on the "encrypted_password" field. -func EncryptedPasswordEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldEncryptedPassword, v)) -} - -// EncryptedPasswordContainsFold applies the ContainsFold predicate on the "encrypted_password" field. -func EncryptedPasswordContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldEncryptedPassword, v)) -} - -// SaltEQ applies the EQ predicate on the "salt" field. -func SaltEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldSalt, v)) -} - -// SaltNEQ applies the NEQ predicate on the "salt" field. -func SaltNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldSalt, v)) -} - -// SaltIn applies the In predicate on the "salt" field. -func SaltIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldSalt, vs...)) -} - -// SaltNotIn applies the NotIn predicate on the "salt" field. -func SaltNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldSalt, vs...)) -} - -// SaltGT applies the GT predicate on the "salt" field. -func SaltGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldSalt, v)) -} - -// SaltGTE applies the GTE predicate on the "salt" field. -func SaltGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldSalt, v)) -} - -// SaltLT applies the LT predicate on the "salt" field. -func SaltLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldSalt, v)) -} - -// SaltLTE applies the LTE predicate on the "salt" field. -func SaltLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldSalt, v)) -} - -// SaltContains applies the Contains predicate on the "salt" field. -func SaltContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldSalt, v)) -} - -// SaltHasPrefix applies the HasPrefix predicate on the "salt" field. -func SaltHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldSalt, v)) -} - -// SaltHasSuffix applies the HasSuffix predicate on the "salt" field. -func SaltHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldSalt, v)) -} - -// SaltEqualFold applies the EqualFold predicate on the "salt" field. -func SaltEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldSalt, v)) -} - -// SaltContainsFold applies the ContainsFold predicate on the "salt" field. -func SaltContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldSalt, v)) -} - -// PhoneEQ applies the EQ predicate on the "phone" field. -func PhoneEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldPhone, v)) -} - -// PhoneNEQ applies the NEQ predicate on the "phone" field. -func PhoneNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldPhone, v)) -} - -// PhoneIn applies the In predicate on the "phone" field. -func PhoneIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldPhone, vs...)) -} - -// PhoneNotIn applies the NotIn predicate on the "phone" field. -func PhoneNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldPhone, vs...)) -} - -// PhoneGT applies the GT predicate on the "phone" field. -func PhoneGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldPhone, v)) -} - -// PhoneGTE applies the GTE predicate on the "phone" field. -func PhoneGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldPhone, v)) -} - -// PhoneLT applies the LT predicate on the "phone" field. -func PhoneLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldPhone, v)) -} - -// PhoneLTE applies the LTE predicate on the "phone" field. -func PhoneLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldPhone, v)) -} - -// PhoneContains applies the Contains predicate on the "phone" field. -func PhoneContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldPhone, v)) -} - -// PhoneHasPrefix applies the HasPrefix predicate on the "phone" field. -func PhoneHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldPhone, v)) -} - -// PhoneHasSuffix applies the HasSuffix predicate on the "phone" field. -func PhoneHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldPhone, v)) -} - -// PhoneEqualFold applies the EqualFold predicate on the "phone" field. -func PhoneEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldPhone, v)) -} - -// PhoneContainsFold applies the ContainsFold predicate on the "phone" field. -func PhoneContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldPhone, v)) -} - -// EmailEQ applies the EQ predicate on the "email" field. -func EmailEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldEmail, v)) -} - -// EmailNEQ applies the NEQ predicate on the "email" field. -func EmailNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldEmail, v)) -} - -// EmailIn applies the In predicate on the "email" field. -func EmailIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldEmail, vs...)) -} - -// EmailNotIn applies the NotIn predicate on the "email" field. -func EmailNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldEmail, vs...)) -} - -// EmailGT applies the GT predicate on the "email" field. -func EmailGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldEmail, v)) -} - -// EmailGTE applies the GTE predicate on the "email" field. -func EmailGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldEmail, v)) -} - -// EmailLT applies the LT predicate on the "email" field. -func EmailLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldEmail, v)) -} - -// EmailLTE applies the LTE predicate on the "email" field. -func EmailLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldEmail, v)) -} - -// EmailContains applies the Contains predicate on the "email" field. -func EmailContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldEmail, v)) -} - -// EmailHasPrefix applies the HasPrefix predicate on the "email" field. -func EmailHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldEmail, v)) -} - -// EmailHasSuffix applies the HasSuffix predicate on the "email" field. -func EmailHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldEmail, v)) -} - -// EmailEqualFold applies the EqualFold predicate on the "email" field. -func EmailEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldEmail, v)) -} - -// EmailContainsFold applies the ContainsFold predicate on the "email" field. -func EmailContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldEmail, v)) -} - -// DepartmentEQ applies the EQ predicate on the "department" field. -func DepartmentEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldDepartment, v)) -} - -// DepartmentNEQ applies the NEQ predicate on the "department" field. -func DepartmentNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldDepartment, v)) -} - -// DepartmentIn applies the In predicate on the "department" field. -func DepartmentIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldDepartment, vs...)) -} - -// DepartmentNotIn applies the NotIn predicate on the "department" field. -func DepartmentNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldDepartment, vs...)) -} - -// DepartmentGT applies the GT predicate on the "department" field. -func DepartmentGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldDepartment, v)) -} - -// DepartmentGTE applies the GTE predicate on the "department" field. -func DepartmentGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldDepartment, v)) -} - -// DepartmentLT applies the LT predicate on the "department" field. -func DepartmentLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldDepartment, v)) -} - -// DepartmentLTE applies the LTE predicate on the "department" field. -func DepartmentLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldDepartment, v)) -} - -// DepartmentContains applies the Contains predicate on the "department" field. -func DepartmentContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldDepartment, v)) -} - -// DepartmentHasPrefix applies the HasPrefix predicate on the "department" field. -func DepartmentHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldDepartment, v)) -} - -// DepartmentHasSuffix applies the HasSuffix predicate on the "department" field. -func DepartmentHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldDepartment, v)) -} - -// DepartmentEqualFold applies the EqualFold predicate on the "department" field. -func DepartmentEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldDepartment, v)) -} - -// DepartmentContainsFold applies the ContainsFold predicate on the "department" field. -func DepartmentContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldDepartment, v)) -} - -// RemarkEQ applies the EQ predicate on the "remark" field. -func RemarkEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldRemark, v)) -} - -// RemarkNEQ applies the NEQ predicate on the "remark" field. -func RemarkNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldRemark, v)) -} - -// RemarkIn applies the In predicate on the "remark" field. -func RemarkIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldRemark, vs...)) -} - -// RemarkNotIn applies the NotIn predicate on the "remark" field. -func RemarkNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldRemark, vs...)) -} - -// RemarkGT applies the GT predicate on the "remark" field. -func RemarkGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldRemark, v)) -} - -// RemarkGTE applies the GTE predicate on the "remark" field. -func RemarkGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldRemark, v)) -} - -// RemarkLT applies the LT predicate on the "remark" field. -func RemarkLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldRemark, v)) -} - -// RemarkLTE applies the LTE predicate on the "remark" field. -func RemarkLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldRemark, v)) -} - -// RemarkContains applies the Contains predicate on the "remark" field. -func RemarkContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldRemark, v)) -} - -// RemarkHasPrefix applies the HasPrefix predicate on the "remark" field. -func RemarkHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldRemark, v)) -} - -// RemarkHasSuffix applies the HasSuffix predicate on the "remark" field. -func RemarkHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldRemark, v)) -} - -// RemarkEqualFold applies the EqualFold predicate on the "remark" field. -func RemarkEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldRemark, v)) -} - -// RemarkContainsFold applies the ContainsFold predicate on the "remark" field. -func RemarkContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldRemark, v)) -} - -// TokenEQ applies the EQ predicate on the "token" field. -func TokenEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldToken, v)) -} - -// TokenNEQ applies the NEQ predicate on the "token" field. -func TokenNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldToken, v)) -} - -// TokenIn applies the In predicate on the "token" field. -func TokenIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldToken, vs...)) -} - -// TokenNotIn applies the NotIn predicate on the "token" field. -func TokenNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldToken, vs...)) -} - -// TokenGT applies the GT predicate on the "token" field. -func TokenGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldToken, v)) -} - -// TokenGTE applies the GTE predicate on the "token" field. -func TokenGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldToken, v)) -} - -// TokenLT applies the LT predicate on the "token" field. -func TokenLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldToken, v)) -} - -// TokenLTE applies the LTE predicate on the "token" field. -func TokenLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldToken, v)) -} - -// TokenContains applies the Contains predicate on the "token" field. -func TokenContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldToken, v)) -} - -// TokenHasPrefix applies the HasPrefix predicate on the "token" field. -func TokenHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldToken, v)) -} - -// TokenHasSuffix applies the HasSuffix predicate on the "token" field. -func TokenHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldToken, v)) -} - -// TokenEqualFold applies the EqualFold predicate on the "token" field. -func TokenEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldToken, v)) -} - -// TokenContainsFold applies the ContainsFold predicate on the "token" field. -func TokenContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldToken, v)) -} - -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.User { - return predicate.User(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.User { - return predicate.User(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.User { - return predicate.User(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.User { - return predicate.User(sql.FieldNotIn(FieldStatus, vs...)) -} - -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.User { - return predicate.User(sql.FieldGT(FieldStatus, v)) -} - -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.User { - return predicate.User(sql.FieldGTE(FieldStatus, v)) -} - -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.User { - return predicate.User(sql.FieldLT(FieldStatus, v)) -} - -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.User { - return predicate.User(sql.FieldLTE(FieldStatus, v)) -} - -// IsSystemEQ applies the EQ predicate on the "is_system" field. -func IsSystemEQ(v bool) predicate.User { - return predicate.User(sql.FieldEQ(FieldIsSystem, v)) -} - -// IsSystemNEQ applies the NEQ predicate on the "is_system" field. -func IsSystemNEQ(v bool) predicate.User { - return predicate.User(sql.FieldNEQ(FieldIsSystem, v)) -} - -// LastLoginIPEQ applies the EQ predicate on the "last_login_ip" field. -func LastLoginIPEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldLastLoginIP, v)) -} - -// LastLoginIPNEQ applies the NEQ predicate on the "last_login_ip" field. -func LastLoginIPNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldLastLoginIP, v)) -} - -// LastLoginIPIn applies the In predicate on the "last_login_ip" field. -func LastLoginIPIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldLastLoginIP, vs...)) -} - -// LastLoginIPNotIn applies the NotIn predicate on the "last_login_ip" field. -func LastLoginIPNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldLastLoginIP, vs...)) -} - -// LastLoginIPGT applies the GT predicate on the "last_login_ip" field. -func LastLoginIPGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldLastLoginIP, v)) -} - -// LastLoginIPGTE applies the GTE predicate on the "last_login_ip" field. -func LastLoginIPGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldLastLoginIP, v)) -} - -// LastLoginIPLT applies the LT predicate on the "last_login_ip" field. -func LastLoginIPLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldLastLoginIP, v)) -} - -// LastLoginIPLTE applies the LTE predicate on the "last_login_ip" field. -func LastLoginIPLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldLastLoginIP, v)) -} - -// LastLoginIPContains applies the Contains predicate on the "last_login_ip" field. -func LastLoginIPContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldLastLoginIP, v)) -} - -// LastLoginIPHasPrefix applies the HasPrefix predicate on the "last_login_ip" field. -func LastLoginIPHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldLastLoginIP, v)) -} - -// LastLoginIPHasSuffix applies the HasSuffix predicate on the "last_login_ip" field. -func LastLoginIPHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldLastLoginIP, v)) -} - -// LastLoginIPEqualFold applies the EqualFold predicate on the "last_login_ip" field. -func LastLoginIPEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldLastLoginIP, v)) -} - -// LastLoginIPContainsFold applies the ContainsFold predicate on the "last_login_ip" field. -func LastLoginIPContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldLastLoginIP, v)) -} - -// LastLoginTimeEQ applies the EQ predicate on the "last_login_time" field. -func LastLoginTimeEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldLastLoginTime, v)) -} - -// LastLoginTimeNEQ applies the NEQ predicate on the "last_login_time" field. -func LastLoginTimeNEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldNEQ(FieldLastLoginTime, v)) -} - -// LastLoginTimeIn applies the In predicate on the "last_login_time" field. -func LastLoginTimeIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldIn(FieldLastLoginTime, vs...)) -} - -// LastLoginTimeNotIn applies the NotIn predicate on the "last_login_time" field. -func LastLoginTimeNotIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldNotIn(FieldLastLoginTime, vs...)) -} - -// LastLoginTimeGT applies the GT predicate on the "last_login_time" field. -func LastLoginTimeGT(v time.Time) predicate.User { - return predicate.User(sql.FieldGT(FieldLastLoginTime, v)) -} - -// LastLoginTimeGTE applies the GTE predicate on the "last_login_time" field. -func LastLoginTimeGTE(v time.Time) predicate.User { - return predicate.User(sql.FieldGTE(FieldLastLoginTime, v)) -} - -// LastLoginTimeLT applies the LT predicate on the "last_login_time" field. -func LastLoginTimeLT(v time.Time) predicate.User { - return predicate.User(sql.FieldLT(FieldLastLoginTime, v)) -} - -// LastLoginTimeLTE applies the LTE predicate on the "last_login_time" field. -func LastLoginTimeLTE(v time.Time) predicate.User { - return predicate.User(sql.FieldLTE(FieldLastLoginTime, v)) -} - -// LoginTimeEQ applies the EQ predicate on the "login_time" field. -func LoginTimeEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldLoginTime, v)) -} - -// LoginTimeNEQ applies the NEQ predicate on the "login_time" field. -func LoginTimeNEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldNEQ(FieldLoginTime, v)) -} - -// LoginTimeIn applies the In predicate on the "login_time" field. -func LoginTimeIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldIn(FieldLoginTime, vs...)) -} - -// LoginTimeNotIn applies the NotIn predicate on the "login_time" field. -func LoginTimeNotIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldNotIn(FieldLoginTime, vs...)) -} - -// LoginTimeGT applies the GT predicate on the "login_time" field. -func LoginTimeGT(v time.Time) predicate.User { - return predicate.User(sql.FieldGT(FieldLoginTime, v)) -} - -// LoginTimeGTE applies the GTE predicate on the "login_time" field. -func LoginTimeGTE(v time.Time) predicate.User { - return predicate.User(sql.FieldGTE(FieldLoginTime, v)) -} - -// LoginTimeLT applies the LT predicate on the "login_time" field. -func LoginTimeLT(v time.Time) predicate.User { - return predicate.User(sql.FieldLT(FieldLoginTime, v)) -} - -// LoginTimeLTE applies the LTE predicate on the "login_time" field. -func LoginTimeLTE(v time.Time) predicate.User { - return predicate.User(sql.FieldLTE(FieldLoginTime, v)) -} - -// SanctionDateEQ applies the EQ predicate on the "sanction_date" field. -func SanctionDateEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldSanctionDate, v)) -} - -// SanctionDateNEQ applies the NEQ predicate on the "sanction_date" field. -func SanctionDateNEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldNEQ(FieldSanctionDate, v)) -} - -// SanctionDateIn applies the In predicate on the "sanction_date" field. -func SanctionDateIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldIn(FieldSanctionDate, vs...)) -} - -// SanctionDateNotIn applies the NotIn predicate on the "sanction_date" field. -func SanctionDateNotIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldNotIn(FieldSanctionDate, vs...)) -} - -// SanctionDateGT applies the GT predicate on the "sanction_date" field. -func SanctionDateGT(v time.Time) predicate.User { - return predicate.User(sql.FieldGT(FieldSanctionDate, v)) -} - -// SanctionDateGTE applies the GTE predicate on the "sanction_date" field. -func SanctionDateGTE(v time.Time) predicate.User { - return predicate.User(sql.FieldGTE(FieldSanctionDate, v)) -} - -// SanctionDateLT applies the LT predicate on the "sanction_date" field. -func SanctionDateLT(v time.Time) predicate.User { - return predicate.User(sql.FieldLT(FieldSanctionDate, v)) -} - -// SanctionDateLTE applies the LTE predicate on the "sanction_date" field. -func SanctionDateLTE(v time.Time) predicate.User { - return predicate.User(sql.FieldLTE(FieldSanctionDate, v)) -} - -// SanctionDateIsNil applies the IsNil predicate on the "sanction_date" field. -func SanctionDateIsNil() predicate.User { - return predicate.User(sql.FieldIsNull(FieldSanctionDate)) -} - -// SanctionDateNotNil applies the NotNil predicate on the "sanction_date" field. -func SanctionDateNotNil() predicate.User { - return predicate.User(sql.FieldNotNull(FieldSanctionDate)) -} - -// ManagerIDEQ applies the EQ predicate on the "manager_id" field. -func ManagerIDEQ(v int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldManagerID, v)) -} - -// ManagerIDNEQ applies the NEQ predicate on the "manager_id" field. -func ManagerIDNEQ(v int64) predicate.User { - return predicate.User(sql.FieldNEQ(FieldManagerID, v)) -} - -// ManagerIDIn applies the In predicate on the "manager_id" field. -func ManagerIDIn(vs ...int64) predicate.User { - return predicate.User(sql.FieldIn(FieldManagerID, vs...)) -} - -// ManagerIDNotIn applies the NotIn predicate on the "manager_id" field. -func ManagerIDNotIn(vs ...int64) predicate.User { - return predicate.User(sql.FieldNotIn(FieldManagerID, vs...)) -} - -// ManagerIDGT applies the GT predicate on the "manager_id" field. -func ManagerIDGT(v int64) predicate.User { - return predicate.User(sql.FieldGT(FieldManagerID, v)) -} - -// ManagerIDGTE applies the GTE predicate on the "manager_id" field. -func ManagerIDGTE(v int64) predicate.User { - return predicate.User(sql.FieldGTE(FieldManagerID, v)) -} - -// ManagerIDLT applies the LT predicate on the "manager_id" field. -func ManagerIDLT(v int64) predicate.User { - return predicate.User(sql.FieldLT(FieldManagerID, v)) -} - -// ManagerIDLTE applies the LTE predicate on the "manager_id" field. -func ManagerIDLTE(v int64) predicate.User { - return predicate.User(sql.FieldLTE(FieldManagerID, v)) -} - -// ManagerIDIsNil applies the IsNil predicate on the "manager_id" field. -func ManagerIDIsNil() predicate.User { - return predicate.User(sql.FieldIsNull(FieldManagerID)) -} - -// ManagerIDNotNil applies the NotNil predicate on the "manager_id" field. -func ManagerIDNotNil() predicate.User { - return predicate.User(sql.FieldNotNull(FieldManagerID)) -} - -// ManagerEQ applies the EQ predicate on the "manager" field. -func ManagerEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldManager, v)) -} - -// ManagerNEQ applies the NEQ predicate on the "manager" field. -func ManagerNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldManager, v)) -} - -// ManagerIn applies the In predicate on the "manager" field. -func ManagerIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldManager, vs...)) -} - -// ManagerNotIn applies the NotIn predicate on the "manager" field. -func ManagerNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldManager, vs...)) -} - -// ManagerGT applies the GT predicate on the "manager" field. -func ManagerGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldManager, v)) -} - -// ManagerGTE applies the GTE predicate on the "manager" field. -func ManagerGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldManager, v)) -} - -// ManagerLT applies the LT predicate on the "manager" field. -func ManagerLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldManager, v)) -} - -// ManagerLTE applies the LTE predicate on the "manager" field. -func ManagerLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldManager, v)) -} - -// ManagerContains applies the Contains predicate on the "manager" field. -func ManagerContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldManager, v)) -} - -// ManagerHasPrefix applies the HasPrefix predicate on the "manager" field. -func ManagerHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldManager, v)) -} - -// ManagerHasSuffix applies the HasSuffix predicate on the "manager" field. -func ManagerHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldManager, v)) -} - -// ManagerEqualFold applies the EqualFold predicate on the "manager" field. -func ManagerEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldManager, v)) -} - -// ManagerContainsFold applies the ContainsFold predicate on the "manager" field. -func ManagerContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldManager, v)) -} - -// HasRoles applies the HasEdge predicate on the "roles" edge. -func HasRoles() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRolesWith applies the HasEdge predicate on the "roles" edge with a given conditions (other predicates). -func HasRolesWith(preds ...predicate.Role) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := newRolesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPositions applies the HasEdge predicate on the "positions" edge. -func HasPositions() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, PositionsTable, PositionsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPositionsWith applies the HasEdge predicate on the "positions" edge with a given conditions (other predicates). -func HasPositionsWith(preds ...predicate.Position) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := newPositionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasDepartments applies the HasEdge predicate on the "departments" edge. -func HasDepartments() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, DepartmentsTable, DepartmentsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasDepartmentsWith applies the HasEdge predicate on the "departments" edge with a given conditions (other predicates). -func HasDepartmentsWith(preds ...predicate.Department) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := newDepartmentsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasUserRoles applies the HasEdge predicate on the "user_roles" edge. -func HasUserRoles() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserRolesWith applies the HasEdge predicate on the "user_roles" edge with a given conditions (other predicates). -func HasUserRolesWith(preds ...predicate.UserRole) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := newUserRolesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasUserPositions applies the HasEdge predicate on the "user_positions" edge. -func HasUserPositions() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserPositionsTable, UserPositionsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserPositionsWith applies the HasEdge predicate on the "user_positions" edge with a given conditions (other predicates). -func HasUserPositionsWith(preds ...predicate.UserPosition) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := newUserPositionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasUserDepartments applies the HasEdge predicate on the "user_departments" edge. -func HasUserDepartments() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserDepartmentsTable, UserDepartmentsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserDepartmentsWith applies the HasEdge predicate on the "user_departments" edge with a given conditions (other predicates). -func HasUserDepartmentsWith(preds ...predicate.UserDepartment) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := newUserDepartmentsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.User) predicate.User { - return predicate.User(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.User) predicate.User { - return predicate.User(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.User) predicate.User { - return predicate.User(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/userdepartment/userdepartment.go b/internal/mods/system/dal/entity/ent/userdepartment/userdepartment.go deleted file mode 100644 index 92e3ac17..00000000 --- a/internal/mods/system/dal/entity/ent/userdepartment/userdepartment.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package userdepartment - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the userdepartment type in the database. - Label = "user_department" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldUserID holds the string denoting the user_id field in the database. - FieldUserID = "user_id" - // FieldDepartmentID holds the string denoting the department_id field in the database. - FieldDepartmentID = "department_id" - // EdgeUser holds the string denoting the user edge name in mutations. - EdgeUser = "user" - // EdgeDepartment holds the string denoting the department edge name in mutations. - EdgeDepartment = "department" - // Table holds the table name of the userdepartment in the database. - Table = "sys_user_departments" - // UserTable is the table that holds the user relation/edge. - UserTable = "sys_user_departments" - // UserInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UserInverseTable = "sys_users" - // UserColumn is the table column denoting the user relation/edge. - UserColumn = "user_id" - // DepartmentTable is the table that holds the department relation/edge. - DepartmentTable = "sys_user_departments" - // DepartmentInverseTable is the table name for the Department entity. - // It exists in this package in order to avoid circular dependency with the "department" package. - DepartmentInverseTable = "sys_departments" - // DepartmentColumn is the table column denoting the department relation/edge. - DepartmentColumn = "department_id" -) - -// Columns holds all SQL columns for userdepartment fields. -var Columns = []string{ - FieldID, - FieldUserID, - FieldDepartmentID, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. - UserIDValidator func(int64) error - // DepartmentIDValidator is a validator for the "department_id" field. It is called by the builders before save. - DepartmentIDValidator func(int64) error -) - -// OrderOption defines the ordering options for the UserDepartment queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByUserID orders the results by the user_id field. -func ByUserID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUserID, opts...).ToFunc() -} - -// ByDepartmentID orders the results by the department_id field. -func ByDepartmentID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDepartmentID, opts...).ToFunc() -} - -// ByUserField orders the results by user field. -func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) - } -} - -// ByDepartmentField orders the results by department field. -func ByDepartmentField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newDepartmentStep(), sql.OrderByField(field, opts...)) - } -} -func newUserStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), - ) -} -func newDepartmentStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(DepartmentInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, DepartmentTable, DepartmentColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/userdepartment/where.go b/internal/mods/system/dal/entity/ent/userdepartment/where.go deleted file mode 100644 index eb577681..00000000 --- a/internal/mods/system/dal/entity/ent/userdepartment/where.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package userdepartment - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldLTE(FieldID, id)) -} - -// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. -func UserID(v int64) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldEQ(FieldUserID, v)) -} - -// DepartmentID applies equality check predicate on the "department_id" field. It's identical to DepartmentIDEQ. -func DepartmentID(v int64) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldEQ(FieldDepartmentID, v)) -} - -// UserIDEQ applies the EQ predicate on the "user_id" field. -func UserIDEQ(v int64) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldEQ(FieldUserID, v)) -} - -// UserIDNEQ applies the NEQ predicate on the "user_id" field. -func UserIDNEQ(v int64) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldNEQ(FieldUserID, v)) -} - -// UserIDIn applies the In predicate on the "user_id" field. -func UserIDIn(vs ...int64) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldIn(FieldUserID, vs...)) -} - -// UserIDNotIn applies the NotIn predicate on the "user_id" field. -func UserIDNotIn(vs ...int64) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldNotIn(FieldUserID, vs...)) -} - -// DepartmentIDEQ applies the EQ predicate on the "department_id" field. -func DepartmentIDEQ(v int64) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldEQ(FieldDepartmentID, v)) -} - -// DepartmentIDNEQ applies the NEQ predicate on the "department_id" field. -func DepartmentIDNEQ(v int64) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldNEQ(FieldDepartmentID, v)) -} - -// DepartmentIDIn applies the In predicate on the "department_id" field. -func DepartmentIDIn(vs ...int64) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldIn(FieldDepartmentID, vs...)) -} - -// DepartmentIDNotIn applies the NotIn predicate on the "department_id" field. -func DepartmentIDNotIn(vs ...int64) predicate.UserDepartment { - return predicate.UserDepartment(sql.FieldNotIn(FieldDepartmentID, vs...)) -} - -// HasUser applies the HasEdge predicate on the "user" edge. -func HasUser() predicate.UserDepartment { - return predicate.UserDepartment(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). -func HasUserWith(preds ...predicate.User) predicate.UserDepartment { - return predicate.UserDepartment(func(s *sql.Selector) { - step := newUserStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasDepartment applies the HasEdge predicate on the "department" edge. -func HasDepartment() predicate.UserDepartment { - return predicate.UserDepartment(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, DepartmentTable, DepartmentColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasDepartmentWith applies the HasEdge predicate on the "department" edge with a given conditions (other predicates). -func HasDepartmentWith(preds ...predicate.Department) predicate.UserDepartment { - return predicate.UserDepartment(func(s *sql.Selector) { - step := newDepartmentStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.UserDepartment) predicate.UserDepartment { - return predicate.UserDepartment(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.UserDepartment) predicate.UserDepartment { - return predicate.UserDepartment(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.UserDepartment) predicate.UserDepartment { - return predicate.UserDepartment(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/userposition/userposition.go b/internal/mods/system/dal/entity/ent/userposition/userposition.go deleted file mode 100644 index 6ec7d185..00000000 --- a/internal/mods/system/dal/entity/ent/userposition/userposition.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package userposition - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the userposition type in the database. - Label = "user_position" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldUserID holds the string denoting the user_id field in the database. - FieldUserID = "user_id" - // FieldPositionID holds the string denoting the position_id field in the database. - FieldPositionID = "position_id" - // EdgeUser holds the string denoting the user edge name in mutations. - EdgeUser = "user" - // EdgePosition holds the string denoting the position edge name in mutations. - EdgePosition = "position" - // Table holds the table name of the userposition in the database. - Table = "sys_user_positions" - // UserTable is the table that holds the user relation/edge. - UserTable = "sys_user_positions" - // UserInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UserInverseTable = "sys_users" - // UserColumn is the table column denoting the user relation/edge. - UserColumn = "user_id" - // PositionTable is the table that holds the position relation/edge. - PositionTable = "sys_user_positions" - // PositionInverseTable is the table name for the Position entity. - // It exists in this package in order to avoid circular dependency with the "position" package. - PositionInverseTable = "sys_positions" - // PositionColumn is the table column denoting the position relation/edge. - PositionColumn = "position_id" -) - -// Columns holds all SQL columns for userposition fields. -var Columns = []string{ - FieldID, - FieldUserID, - FieldPositionID, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. - UserIDValidator func(int64) error - // PositionIDValidator is a validator for the "position_id" field. It is called by the builders before save. - PositionIDValidator func(int64) error -) - -// OrderOption defines the ordering options for the UserPosition queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByUserID orders the results by the user_id field. -func ByUserID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUserID, opts...).ToFunc() -} - -// ByPositionID orders the results by the position_id field. -func ByPositionID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPositionID, opts...).ToFunc() -} - -// ByUserField orders the results by user field. -func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) - } -} - -// ByPositionField orders the results by position field. -func ByPositionField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPositionStep(), sql.OrderByField(field, opts...)) - } -} -func newUserStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), - ) -} -func newPositionStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PositionInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PositionTable, PositionColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/userposition/where.go b/internal/mods/system/dal/entity/ent/userposition/where.go deleted file mode 100644 index cf94a65a..00000000 --- a/internal/mods/system/dal/entity/ent/userposition/where.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package userposition - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.UserPosition { - return predicate.UserPosition(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.UserPosition { - return predicate.UserPosition(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.UserPosition { - return predicate.UserPosition(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.UserPosition { - return predicate.UserPosition(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.UserPosition { - return predicate.UserPosition(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.UserPosition { - return predicate.UserPosition(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.UserPosition { - return predicate.UserPosition(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.UserPosition { - return predicate.UserPosition(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.UserPosition { - return predicate.UserPosition(sql.FieldLTE(FieldID, id)) -} - -// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. -func UserID(v int64) predicate.UserPosition { - return predicate.UserPosition(sql.FieldEQ(FieldUserID, v)) -} - -// PositionID applies equality check predicate on the "position_id" field. It's identical to PositionIDEQ. -func PositionID(v int64) predicate.UserPosition { - return predicate.UserPosition(sql.FieldEQ(FieldPositionID, v)) -} - -// UserIDEQ applies the EQ predicate on the "user_id" field. -func UserIDEQ(v int64) predicate.UserPosition { - return predicate.UserPosition(sql.FieldEQ(FieldUserID, v)) -} - -// UserIDNEQ applies the NEQ predicate on the "user_id" field. -func UserIDNEQ(v int64) predicate.UserPosition { - return predicate.UserPosition(sql.FieldNEQ(FieldUserID, v)) -} - -// UserIDIn applies the In predicate on the "user_id" field. -func UserIDIn(vs ...int64) predicate.UserPosition { - return predicate.UserPosition(sql.FieldIn(FieldUserID, vs...)) -} - -// UserIDNotIn applies the NotIn predicate on the "user_id" field. -func UserIDNotIn(vs ...int64) predicate.UserPosition { - return predicate.UserPosition(sql.FieldNotIn(FieldUserID, vs...)) -} - -// PositionIDEQ applies the EQ predicate on the "position_id" field. -func PositionIDEQ(v int64) predicate.UserPosition { - return predicate.UserPosition(sql.FieldEQ(FieldPositionID, v)) -} - -// PositionIDNEQ applies the NEQ predicate on the "position_id" field. -func PositionIDNEQ(v int64) predicate.UserPosition { - return predicate.UserPosition(sql.FieldNEQ(FieldPositionID, v)) -} - -// PositionIDIn applies the In predicate on the "position_id" field. -func PositionIDIn(vs ...int64) predicate.UserPosition { - return predicate.UserPosition(sql.FieldIn(FieldPositionID, vs...)) -} - -// PositionIDNotIn applies the NotIn predicate on the "position_id" field. -func PositionIDNotIn(vs ...int64) predicate.UserPosition { - return predicate.UserPosition(sql.FieldNotIn(FieldPositionID, vs...)) -} - -// HasUser applies the HasEdge predicate on the "user" edge. -func HasUser() predicate.UserPosition { - return predicate.UserPosition(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). -func HasUserWith(preds ...predicate.User) predicate.UserPosition { - return predicate.UserPosition(func(s *sql.Selector) { - step := newUserStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPosition applies the HasEdge predicate on the "position" edge. -func HasPosition() predicate.UserPosition { - return predicate.UserPosition(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PositionTable, PositionColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPositionWith applies the HasEdge predicate on the "position" edge with a given conditions (other predicates). -func HasPositionWith(preds ...predicate.Position) predicate.UserPosition { - return predicate.UserPosition(func(s *sql.Selector) { - step := newPositionStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.UserPosition) predicate.UserPosition { - return predicate.UserPosition(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.UserPosition) predicate.UserPosition { - return predicate.UserPosition(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.UserPosition) predicate.UserPosition { - return predicate.UserPosition(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/entity/ent/userrole/userrole.go b/internal/mods/system/dal/entity/ent/userrole/userrole.go deleted file mode 100644 index b3956f7f..00000000 --- a/internal/mods/system/dal/entity/ent/userrole/userrole.go +++ /dev/null @@ -1,171 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package userrole - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the userrole type in the database. - Label = "user_role" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldUserID holds the string denoting the user_id field in the database. - FieldUserID = "user_id" - // FieldRoleID holds the string denoting the role_id field in the database. - FieldRoleID = "role_id" - // EdgeUser holds the string denoting the user edge name in mutations. - EdgeUser = "user" - // EdgeRole holds the string denoting the role edge name in mutations. - EdgeRole = "role" - // Table holds the table name of the userrole in the database. - Table = "sys_user_roles" - // UserTable is the table that holds the user relation/edge. - UserTable = "sys_user_roles" - // UserInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UserInverseTable = "sys_users" - // UserColumn is the table column denoting the user relation/edge. - UserColumn = "user_id" - // RoleTable is the table that holds the role relation/edge. - RoleTable = "sys_user_roles" - // RoleInverseTable is the table name for the Role entity. - // It exists in this package in order to avoid circular dependency with the "role" package. - RoleInverseTable = "sys_roles" - // RoleColumn is the table column denoting the role relation/edge. - RoleColumn = "role_id" -) - -// Columns holds all SQL columns for userrole fields. -var Columns = []string{ - FieldID, - FieldUserID, - FieldRoleID, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. - UserIDValidator func(int64) error - // RoleIDValidator is a validator for the "role_id" field. It is called by the builders before save. - RoleIDValidator func(int64) error -) - -// OrderOption defines the ordering options for the UserRole queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByUserID orders the results by the user_id field. -func ByUserID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUserID, opts...).ToFunc() -} - -// ByRoleID orders the results by the role_id field. -func ByRoleID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRoleID, opts...).ToFunc() -} - -// ByUserField orders the results by user field. -func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) - } -} - -// ByRoleField orders the results by role field. -func ByRoleField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRoleStep(), sql.OrderByField(field, opts...)) - } -} -func newUserStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), - ) -} -func newRoleStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RoleInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/mods/system/dal/entity/ent/userrole/where.go b/internal/mods/system/dal/entity/ent/userrole/where.go deleted file mode 100644 index 2a853468..00000000 --- a/internal/mods/system/dal/entity/ent/userrole/where.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package userrole - -import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.UserRole { - return predicate.UserRole(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.UserRole { - return predicate.UserRole(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldLTE(FieldID, id)) -} - -// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. -func UserID(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldUserID, v)) -} - -// RoleID applies equality check predicate on the "role_id" field. It's identical to RoleIDEQ. -func RoleID(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldRoleID, v)) -} - -// UserIDEQ applies the EQ predicate on the "user_id" field. -func UserIDEQ(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldUserID, v)) -} - -// UserIDNEQ applies the NEQ predicate on the "user_id" field. -func UserIDNEQ(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldNEQ(FieldUserID, v)) -} - -// UserIDIn applies the In predicate on the "user_id" field. -func UserIDIn(vs ...int64) predicate.UserRole { - return predicate.UserRole(sql.FieldIn(FieldUserID, vs...)) -} - -// UserIDNotIn applies the NotIn predicate on the "user_id" field. -func UserIDNotIn(vs ...int64) predicate.UserRole { - return predicate.UserRole(sql.FieldNotIn(FieldUserID, vs...)) -} - -// RoleIDEQ applies the EQ predicate on the "role_id" field. -func RoleIDEQ(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldRoleID, v)) -} - -// RoleIDNEQ applies the NEQ predicate on the "role_id" field. -func RoleIDNEQ(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldNEQ(FieldRoleID, v)) -} - -// RoleIDIn applies the In predicate on the "role_id" field. -func RoleIDIn(vs ...int64) predicate.UserRole { - return predicate.UserRole(sql.FieldIn(FieldRoleID, vs...)) -} - -// RoleIDNotIn applies the NotIn predicate on the "role_id" field. -func RoleIDNotIn(vs ...int64) predicate.UserRole { - return predicate.UserRole(sql.FieldNotIn(FieldRoleID, vs...)) -} - -// HasUser applies the HasEdge predicate on the "user" edge. -func HasUser() predicate.UserRole { - return predicate.UserRole(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). -func HasUserWith(preds ...predicate.User) predicate.UserRole { - return predicate.UserRole(func(s *sql.Selector) { - step := newUserStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasRole applies the HasEdge predicate on the "role" edge. -func HasRole() predicate.UserRole { - return predicate.UserRole(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRoleWith applies the HasEdge predicate on the "role" edge with a given conditions (other predicates). -func HasRoleWith(preds ...predicate.Role) predicate.UserRole { - return predicate.UserRole(func(s *sql.Selector) { - step := newRoleStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.UserRole) predicate.UserRole { - return predicate.UserRole(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.UserRole) predicate.UserRole { - return predicate.UserRole(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.UserRole) predicate.UserRole { - return predicate.UserRole(sql.NotPredicates(p)) -} diff --git a/internal/mods/system/dal/login.dal.go b/internal/mods/system/dal/login.dal.go index 91725a95..076121a7 100644 --- a/internal/mods/system/dal/login.dal.go +++ b/internal/mods/system/dal/login.dal.go @@ -13,17 +13,18 @@ import ( "github.com/origadmin/runtime/context" jwtv1 "github.com/origadmin/runtime/gen/go/security/jwt/v1" securityv1 "github.com/origadmin/runtime/gen/go/security/v1" + "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/rand" "github.com/origadmin/toolkits/errors/httperr" - "github.com/origadmin/runtime/interfaces/security" + + "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/captcha" "origadmin/application/admin/helpers/resp" "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" "origadmin/application/admin/internal/mods/system/dto" systemdto "origadmin/application/admin/internal/mods/system/dto" ) @@ -71,7 +72,7 @@ func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.Log return nil, dto.ErrInvalidCaptchaID } - if root := repo.cfg().RootUser; root.GetEnabled() { + if root := repo.rootUser(); root.GetEnabled() { log.Debugf("Root userData is enabled, checking if username matches") // login by root username := root.Username @@ -333,8 +334,8 @@ func RefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { return wrapRefreshTokenizer(tokenizer) } -func (repo loginRepo) cfg() *configs.BasisConfig { - return repo.LoginData.BasisConfig +func (repo loginRepo) rootUser() *configs.RootUser { + return repo.LoginData.RootUser } func (repo loginRepo) getCaptchaDriver(typ string) (captcha.Driver, error) { @@ -381,11 +382,12 @@ func (repo loginRepo) getCaptchaImage(id string) (string, error) { } type LoginData struct { - BasisConfig *configs.BasisConfig - Tokenizer security.RefreshTokenizer - Resource systemdto.ResourceRepo - Role systemdto.RoleRepo - User systemdto.UserRepo + Captcha *configs.Captcha + RootUser *configs.RootUser + Tokenizer security.RefreshTokenizer + Resource systemdto.ResourceRepo + Role systemdto.RoleRepo + User systemdto.UserRepo } func NewCaptcha(cfg *configs.Captcha) *captcha.Captcha { @@ -403,20 +405,20 @@ func NewCaptcha(cfg *configs.Captcha) *captcha.Captcha { // NewLoginRepo . func NewLoginRepo(data *LoginData, logger log.KLogger) dto.LoginRepo { var err error - cfg := data.BasisConfig + cfg := data.RootUser // todo: generate random password for root user if not exists - if cfg.RootUser.RandomPassword { + if cfg.RandomPassword { passwd := rand.GenerateRandom(12) - cfg.RootUser.Password, err = hash.Generate(passwd) + cfg.Password, err = hash.Generate(passwd) if err == nil { fmt.Println("Root user password:", passwd) } else { log.Errorf("Error generating password: %v", err) - cfg.RootUser.RandomPassword = false + cfg.RandomPassword = false } } - if cfg.RootUser.Id == "" { - cfg.RootUser.Id = cfg.RootUser.Username + if cfg.Id == "" { + cfg.Id = cfg.Username } //authenticator, err := jwt.NewAuthenticator(&configv1.Security{}) //if err != nil { @@ -425,7 +427,7 @@ func NewLoginRepo(data *LoginData, logger log.KLogger) dto.LoginRepo { return &loginRepo{ bufpool: BufPool(), LoginData: data, - captcha: NewCaptcha(cfg.Captcha), + captcha: NewCaptcha(data.Captcha), } } diff --git a/internal/mods/system/dal/permission.dal.go b/internal/mods/system/dal/permission.dal.go index 1eb638b5..e83d89f4 100644 --- a/internal/mods/system/dal/permission.dal.go +++ b/internal/mods/system/dal/permission.dal.go @@ -12,8 +12,8 @@ import ( pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/db" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/mods/system/dto" ) diff --git a/internal/mods/system/dal/personal.dal.go b/internal/mods/system/dal/personal.dal.go index 27a03c1d..dfa605c7 100644 --- a/internal/mods/system/dal/personal.dal.go +++ b/internal/mods/system/dal/personal.dal.go @@ -12,9 +12,9 @@ import ( pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/securityx" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/mods/system/dto" ) diff --git a/internal/mods/system/dal/resource.dal.go b/internal/mods/system/dal/resource.dal.go index 8390e8b8..9be732a9 100644 --- a/internal/mods/system/dal/resource.dal.go +++ b/internal/mods/system/dal/resource.dal.go @@ -12,8 +12,8 @@ import ( pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/db" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/mods/system/dto" ) diff --git a/internal/mods/system/dal/role.dal.go b/internal/mods/system/dal/role.dal.go index 1ee3b55c..46aec871 100644 --- a/internal/mods/system/dal/role.dal.go +++ b/internal/mods/system/dal/role.dal.go @@ -15,8 +15,8 @@ import ( pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/db" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/role" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/role" "origadmin/application/admin/internal/mods/system/dto" ) diff --git a/internal/mods/system/dal/user.dal.go b/internal/mods/system/dal/user.dal.go index f0c6669b..dda38a3b 100644 --- a/internal/mods/system/dal/user.dal.go +++ b/internal/mods/system/dal/user.dal.go @@ -15,8 +15,8 @@ import ( pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/db" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/mods/system/dto" ) diff --git a/internal/mods/system/dto/dto.go b/internal/mods/system/dto/dto.go index 2d0aee8d..68e41bec 100644 --- a/internal/mods/system/dto/dto.go +++ b/internal/mods/system/dto/dto.go @@ -12,9 +12,9 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/schema/types" - "origadmin/application/admin/internal/mods/system/dal/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/schema/types" + "origadmin/application/admin/internal/data/entity/ent/user" ) var ( diff --git a/internal/mods/system/dto/resource_type.go b/internal/mods/system/dto/resource_type.go index 4c4c01c7..f3b265fa 100644 --- a/internal/mods/system/dto/resource_type.go +++ b/internal/mods/system/dto/resource_type.go @@ -6,7 +6,7 @@ package dto import ( - "origadmin/application/admin/internal/mods/system/dal/entity/ent/schema" + "origadmin/application/admin/internal/data/entity/ent/schema" ) const ( diff --git a/internal/mods/system/dto/role.go b/internal/mods/system/dto/role.go index 018d05a8..157b6950 100644 --- a/internal/mods/system/dto/role.go +++ b/internal/mods/system/dto/role.go @@ -14,7 +14,7 @@ import ( pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/resp" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" + "origadmin/application/admin/internal/data/entity/ent" ) type ( diff --git a/internal/mods/system/dto/user.go b/internal/mods/system/dto/user.go index 973866ac..29316be3 100644 --- a/internal/mods/system/dto/user.go +++ b/internal/mods/system/dto/user.go @@ -17,7 +17,7 @@ import ( pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/id" "origadmin/application/admin/helpers/resp" - "origadmin/application/admin/internal/mods/system/dal/entity/ent" + "origadmin/application/admin/internal/data/entity/ent" ) type ( diff --git a/internal/mods/system/server/server.go b/internal/mods/system/server/server.go index bb2d4355..4e5a9f8d 100644 --- a/internal/mods/system/server/server.go +++ b/internal/mods/system/server/server.go @@ -41,12 +41,12 @@ var ( ) func init() { - runtime.RegisterService(ServiceName, service.DefaultServiceBuilder) + runtime.RegisterService(ServiceName, service.DefaultServiceFactory) } func NewSystemServer(bootstrap *configs.Bootstrap, registers []service.ServerRegister, l log.KLogger) []transport.Server { var servers []transport.Server - serviceConfig := bootstrap.GetService() + serviceConfig := bootstrap.GetServices() if serviceConfig == nil { return servers } @@ -124,7 +124,7 @@ func NewCasbinServiceClient(client *service.GRPCClient, l log.KLogger) pb.Casbin return systemservice.NewCasbinSourceServiceClient(client) } -func NewSystemClient(bootstrap *configs.Bootstrap, l log.KLogger) (*service.GRPCClient, error) { +func NewSystemClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service.GRPCClient, error) { entry := bootstrap.GetEntry() if entry == nil { return nil, errors.New("no entry") @@ -150,14 +150,15 @@ func NewSystemClient(bootstrap *configs.Bootstrap, l log.KLogger) (*service.GRPC if v, ok := bootstrap.GetServers()[ServiceName]; ok { registry.ServiceName = ServiceName } + helper := log.NewHelper(r.Logger()) //registry.ServiceName = ServiceName - log.Infof("service name: %s", registry.ServiceName) + helper.Infof("service name: %s", registry.ServiceName) discovery, err := runtime.NewDiscovery(registry) if err != nil { return nil, errors.Wrap(err, "create discovery") } var ms []middleware.KMiddleware - options := []servicegrpc.OptionSetting{ + options := []servicegrpc.Option{ servicegrpc.WithDiscovery(registry.ServiceName, discovery), } ms = append(ms, middleware.NewClient(bootstrap.GetMiddleware())...) From c7d1671bdd3a2369a9f911b4d1407e7fdc4bd5bc Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 22 May 2025 19:16:57 +0800 Subject: [PATCH 023/158] refactor(database): implement database client wrapper - Add database client wrapper for different database drivers - Implement functions to create and open databases - Support MySQL, SQLite, PostgreSQL, and MSSQL - Refactor existing database related code to use the new wrapper --- api/v1/services/annotations.pb.go | 66 +- api/v1/services/system/auth.pb.go | 356 ++---- api/v1/services/system/auth.pb.validate.go | 32 +- api/v1/services/system/auth_http.pb.go | 2 +- api/v1/services/system/casbin.pb.go | 241 ++-- api/v1/services/system/casbin.pb.validate.go | 20 +- api/v1/services/system/casbin_http.pb.go | 2 +- api/v1/services/system/department.pb.go | 303 ++--- .../services/system/department.pb.validate.go | 20 +- api/v1/services/system/department_http.pb.go | 2 +- api/v1/services/system/error.pb.go | 114 +- api/v1/services/system/login.pb.go | 539 +++----- api/v1/services/system/login.pb.validate.go | 48 +- api/v1/services/system/login_http.pb.go | 2 +- api/v1/services/system/menu.pb.go | 274 ++--- api/v1/services/system/menu.pb.validate.go | 20 +- api/v1/services/system/menu_http.pb.go | 2 +- api/v1/services/system/permission.pb.go | 306 ++--- .../services/system/permission.pb.validate.go | 20 +- api/v1/services/system/permission_http.pb.go | 2 +- api/v1/services/system/personal.pb.go | 383 ++---- .../services/system/personal.pb.validate.go | 40 +- api/v1/services/system/personal_http.pb.go | 2 +- api/v1/services/system/position.pb.go | 284 ++--- .../services/system/position.pb.validate.go | 20 +- api/v1/services/system/position_http.pb.go | 2 +- api/v1/services/system/resource.pb.go | 290 ++--- .../services/system/resource.pb.validate.go | 20 +- api/v1/services/system/resource_http.pb.go | 2 +- api/v1/services/system/role.pb.go | 275 ++--- api/v1/services/system/role.pb.validate.go | 20 +- api/v1/services/system/role_http.pb.go | 2 +- api/v1/services/system/types.pb.go | 1085 ++++++----------- api/v1/services/system/types.pb.validate.go | 56 +- api/v1/services/system/user.pb.go | 449 +++---- api/v1/services/system/user.pb.validate.go | 36 +- api/v1/services/system/user_http.pb.go | 2 +- buf.lock | 4 +- cmd/internal/start/start.go | 74 +- cmd/internal/start/wire.go | 13 +- cmd/internal/start/wire_gen.go | 27 +- cmd/system/main.go | 2 +- cmd/system/wire.go | 2 +- cmd/system/wire_gen.go | 54 +- contrib/database/const.go | 24 + contrib/database/database.go | 54 + contrib/database/everyone.go | 18 + contrib/database/internal/mysql/mysql.go | 48 + contrib/database/internal/sqlite/sqlite.go | 32 + contrib/database/mssql.go | 14 + contrib/database/mysql.go | 14 + contrib/database/pgx.go | 14 + contrib/database/postgres.go | 14 + contrib/database/sqlite3_cgo.go | 14 + contrib/database/sqlite3_go.go | 14 + go.mod | 1 - helpers/resp/data/v1/data.pb.go | 390 +++--- helpers/securityx/security.go | 8 +- internal/configs/auth_config.pb.go | 139 --- internal/configs/auth_config.proto | 16 - internal/configs/bootstrap.pb.go | 59 +- internal/configs/bootstrap.pb.validate.go | 58 - internal/configs/bootstrap.proto | 8 +- internal/configs/security_config.pb.go | 149 +++ ...date.go => security_config.pb.validate.go} | 98 +- internal/configs/security_config.proto | 15 + internal/data/data.go | 471 ++++++- internal/loader/bootstrap_default.go | 168 +-- internal/loader/bootstrap_test.go | 12 +- internal/loader/config_test.go | 4 +- internal/loader/load.go | 37 +- internal/loader/service_test.go | 63 +- internal/mods/auth/dal/auth.dal.go | 6 - internal/mods/auth/dal/dal.go | 17 +- internal/mods/auth/dal/login.dal.go | 29 +- internal/mods/auth/dal/user.dal.go | 227 ++++ internal/mods/system/biz/biz.go | 10 +- internal/mods/system/biz/casbin.biz.go | 8 +- internal/mods/system/biz/login.biz.go | 7 +- internal/mods/system/biz/permission.biz.go | 7 +- internal/mods/system/biz/personal.biz.go | 7 +- internal/mods/system/biz/resource.biz.go | 7 +- internal/mods/system/biz/role.biz.go | 7 +- internal/mods/system/biz/user.biz.go | 8 +- internal/mods/system/dal/auth.dal.go | 7 +- internal/mods/system/dal/casbin.dal.go | 11 +- internal/mods/system/dal/dal.go | 554 +-------- internal/mods/system/dal/login.dal.go | 15 +- internal/mods/system/dal/menu.dal.go | 7 +- internal/mods/system/dal/permission.dal.go | 7 +- internal/mods/system/dal/personal.dal.go | 6 +- internal/mods/system/dal/resource.dal.go | 6 +- internal/mods/system/dal/role.dal.go | 7 +- internal/mods/system/dal/user.dal.go | 7 +- internal/mods/system/server/gins.go | 2 +- internal/mods/system/server/grpc.go | 11 +- internal/mods/system/server/http.go | 17 +- internal/mods/system/server/server.go | 85 +- internal/mods/system/service/service.go | 40 +- resources/configs/system/bootstrap.toml | 5 +- resources/configs/system/data.toml | 57 - resources/configs/system/middleware.toml | 9 +- resources/configs/system/security.toml | 32 +- resources/configs/system/storage.toml | 46 + test/token_test.go | 9 +- 105 files changed, 3658 insertions(+), 5093 deletions(-) create mode 100644 contrib/database/const.go create mode 100644 contrib/database/database.go create mode 100644 contrib/database/everyone.go create mode 100644 contrib/database/internal/mysql/mysql.go create mode 100644 contrib/database/internal/sqlite/sqlite.go create mode 100644 contrib/database/mssql.go create mode 100644 contrib/database/mysql.go create mode 100644 contrib/database/pgx.go create mode 100644 contrib/database/postgres.go create mode 100644 contrib/database/sqlite3_cgo.go create mode 100644 contrib/database/sqlite3_go.go delete mode 100644 internal/configs/auth_config.pb.go delete mode 100644 internal/configs/auth_config.proto create mode 100644 internal/configs/security_config.pb.go rename internal/configs/{auth_config.pb.validate.go => security_config.pb.validate.go} (51%) create mode 100644 internal/configs/security_config.proto create mode 100644 internal/mods/auth/dal/user.dal.go delete mode 100644 resources/configs/system/data.toml create mode 100644 resources/configs/system/storage.toml diff --git a/api/v1/services/annotations.pb.go b/api/v1/services/annotations.pb.go index 2b46161b..17679d70 100644 --- a/api/v1/services/annotations.pb.go +++ b/api/v1/services/annotations.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: annotations.proto @@ -11,6 +11,7 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" + unsafe "unsafe" ) const ( @@ -22,49 +23,23 @@ const ( var File_annotations_proto protoreflect.FileDescriptor -var file_annotations_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x1a, 0x24, 0x67, 0x6e, 0x6f, 0x73, 0x74, 0x69, 0x63, 0x2f, 0x6f, 0x70, - 0x65, 0x6e, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x33, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0xae, 0x04, 0xba, 0x47, 0x8f, - 0x03, 0x12, 0x8c, 0x02, 0x0a, 0x0d, 0x4f, 0x72, 0x69, 0x67, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x20, - 0x41, 0x50, 0x49, 0x12, 0x5f, 0x41, 0x20, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, - 0x68, 0x74, 0x2c, 0x20, 0x66, 0x6c, 0x65, 0x78, 0x69, 0x62, 0x6c, 0x65, 0x2c, 0x20, 0x65, 0x6c, - 0x65, 0x67, 0x61, 0x6e, 0x74, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x66, 0x75, 0x6c, 0x6c, 0x2d, 0x66, - 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x64, 0x20, 0x52, 0x42, 0x41, 0x43, 0x20, 0x73, 0x63, 0x61, - 0x66, 0x66, 0x6f, 0x6c, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, - 0x20, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x70, 0x72, 0x6f, 0x6a, - 0x65, 0x63, 0x74, 0x2e, 0x22, 0x40, 0x0a, 0x07, 0x47, 0x6f, 0x64, 0x43, 0x6f, 0x6e, 0x67, 0x12, - 0x1c, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x1a, 0x17, 0x77, - 0x61, 0x69, 0x74, 0x66, 0x6f, 0x72, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x40, 0x67, 0x6d, 0x61, - 0x69, 0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x2a, 0x3f, 0x0a, 0x03, 0x4d, 0x49, 0x54, 0x12, 0x38, 0x68, - 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x62, 0x61, 0x63, 0x6b, - 0x65, 0x6e, 0x64, 0x2f, 0x62, 0x6c, 0x6f, 0x62, 0x2f, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x2f, - 0x4c, 0x49, 0x43, 0x45, 0x4e, 0x53, 0x45, 0x32, 0x17, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x1a, 0x18, 0x0a, 0x16, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, - 0x68, 0x6f, 0x73, 0x74, 0x3a, 0x31, 0x30, 0x30, 0x38, 0x30, 0x1a, 0x19, 0x0a, 0x17, 0x68, 0x74, - 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, 0x73, 0x74, 0x3a, - 0x31, 0x30, 0x30, 0x38, 0x30, 0x2a, 0x49, 0x3a, 0x47, 0x0a, 0x18, 0x0a, 0x05, 0x42, 0x61, 0x73, - 0x69, 0x63, 0x12, 0x0f, 0x0a, 0x0d, 0x0a, 0x04, 0x68, 0x74, 0x74, 0x70, 0x2a, 0x05, 0x62, 0x61, - 0x73, 0x69, 0x63, 0x0a, 0x2b, 0x0a, 0x06, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x12, 0x21, 0x0a, - 0x1f, 0x0a, 0x06, 0x61, 0x70, 0x69, 0x4b, 0x65, 0x79, 0x1a, 0x0d, 0x41, 0x75, 0x74, 0x68, 0x6f, - 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x42, 0x10, 0x41, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x14, 0x76, 0x31, 0x2f, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0xa2, - 0x02, 0x03, 0x41, 0x56, 0x53, 0xaa, 0x02, 0x0f, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0xca, 0x02, 0x0f, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, - 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0xe2, 0x02, 0x1b, 0x41, 0x70, 0x69, 0x5c, - 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, - 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, -} +const file_annotations_proto_rawDesc = "" + + "\n" + + "\x11annotations.proto\x12\x0fapi.v1.services\x1a$gnostic/openapi/v3/annotations.protoB\xae\x04\xbaG\x8f\x03\x12\x8c\x02\n" + + "\rOrigAdmin API\x12_A lightweight, flexible, elegant and full-featured RBAC scaffolding backend management project.\"@\n" + + "\aGodCong\x12\x1chttps://github.com/origadmin\x1a\x17waitforadding@gmail.com*?\n" + + "\x03MIT\x128https://github.com/origadmin/backend/blob/master/LICENSE2\x17Version from annotation\x1a\x18\n" + + "\x16http://localhost:10080\x1a\x19\n" + + "\x17https://localhost:10080*I:G\n" + + "\x18\n" + + "\x05Basic\x12\x0f\n" + + "\r\n" + + "\x04http*\x05basic\n" + + "+\n" + + "\x06Bearer\x12!\n" + + "\x1f\n" + + "\x06apiKey\x1a\rAuthorization\"\x06header\n" + + "\x13com.api.v1.servicesB\x10AnnotationsProtoP\x01Z\x14v1/services;services\xa2\x02\x03AVS\xaa\x02\x0fApi.V1.Services\xca\x02\x0fApi\\V1\\Services\xe2\x02\x1bApi\\V1\\Services\\GPBMetadata\xea\x02\x11Api::V1::Servicesb\x06proto3" var file_annotations_proto_goTypes = []any{} var file_annotations_proto_depIdxs = []int32{ @@ -84,7 +59,7 @@ func file_annotations_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_annotations_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_annotations_proto_rawDesc), len(file_annotations_proto_rawDesc)), NumEnums: 0, NumMessages: 0, NumExtensions: 0, @@ -94,7 +69,6 @@ func file_annotations_proto_init() { DependencyIndexes: file_annotations_proto_depIdxs, }.Build() File_annotations_proto = out.File - file_annotations_proto_rawDesc = nil file_annotations_proto_goTypes = nil file_annotations_proto_depIdxs = nil } diff --git a/api/v1/services/system/auth.pb.go b/api/v1/services/system/auth.pb.go index 0a5c370a..d938dea0 100644 --- a/api/v1/services/system/auth.pb.go +++ b/api/v1/services/system/auth.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/auth.proto @@ -13,6 +13,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -23,11 +24,10 @@ const ( ) type AuthLogoutRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *AuthLogoutRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *AuthLogoutRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AuthLogoutRequest) Reset() { @@ -68,11 +68,10 @@ func (x *AuthLogoutRequest) GetData() *AuthLogoutRequest_Data { } type AuthLogoutResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` unknownFields protoimpl.UnknownFields - - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AuthLogoutResponse) Reset() { @@ -113,10 +112,7 @@ func (x *AuthLogoutResponse) GetEmpty() *emptypb.Empty { } type ListAuthResourcesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The maximum number of Auths to return. PageSize int32 `protobuf:"varint,1,opt,name=page_size,proto3" json:"page_size,omitempty"` // The next_page_token value returned from a previous List request, if any. @@ -124,7 +120,9 @@ type ListAuthResourcesRequest struct { // The current page number. Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,4,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + NoPaging bool `protobuf:"varint,4,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListAuthResourcesRequest) Reset() { @@ -186,14 +184,13 @@ func (x *ListAuthResourcesRequest) GetNoPaging() bool { } type ListAuthResourcesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The list of Auths. Resources []*Resource `protobuf:"bytes,1,rep,name=resources,proto3" json:"resources,omitempty"` // The total number of Auths in the result set. - TotalSize int32 `protobuf:"varint,2,opt,name=total_size,proto3" json:"total_size,omitempty"` + TotalSize int32 `protobuf:"varint,2,opt,name=total_size,proto3" json:"total_size,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListAuthResourcesResponse) Reset() { @@ -242,11 +239,10 @@ func (x *ListAuthResourcesResponse) GetTotalSize() int32 { // CreateTokenRequest contains the information needed to create a token. type CreateTokenRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *CreateTokenRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *CreateTokenRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateTokenRequest) Reset() { @@ -288,11 +284,10 @@ func (x *CreateTokenRequest) GetData() *CreateTokenRequest_Data { // CreateTokenResponse contains the generated token. type CreateTokenResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` unknownFields protoimpl.UnknownFields - - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateTokenResponse) Reset() { @@ -334,11 +329,10 @@ func (x *CreateTokenResponse) GetToken() string { // VerifyTokenRequest contains the token to be verified. type ValidateTokenRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` unknownFields protoimpl.UnknownFields - - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ValidateTokenRequest) Reset() { @@ -380,12 +374,11 @@ func (x *ValidateTokenRequest) GetToken() string { // VerifyTokenResponse contains the result of the verification. type ValidateTokenResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + IsValid bool `protobuf:"varint,1,opt,name=is_valid,proto3" json:"is_valid,omitempty"` + Claims map[string]string `protobuf:"bytes,2,rep,name=claims,proto3" json:"claims,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields - - IsValid bool `protobuf:"varint,1,opt,name=is_valid,proto3" json:"is_valid,omitempty"` - Claims map[string]string `protobuf:"bytes,2,rep,name=claims,proto3" json:"claims,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + sizeCache protoimpl.SizeCache } func (x *ValidateTokenResponse) Reset() { @@ -434,11 +427,10 @@ func (x *ValidateTokenResponse) GetClaims() map[string]string { // DestroyTokenRequest contains the token to be invalidated. type DestroyTokenRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *DestroyTokenRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *DestroyTokenRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DestroyTokenRequest) Reset() { @@ -480,11 +472,10 @@ func (x *DestroyTokenRequest) GetData() *DestroyTokenRequest_Data { // DestroyTokenResponse contains the result of the invalidation. type DestroyTokenResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` unknownFields protoimpl.UnknownFields - - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DestroyTokenResponse) Reset() { @@ -525,11 +516,10 @@ func (x *DestroyTokenResponse) GetEmpty() *emptypb.Empty { } type AuthenticateRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *AuthenticateRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *AuthenticateRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AuthenticateRequest) Reset() { @@ -570,11 +560,10 @@ func (x *AuthenticateRequest) GetData() *AuthenticateRequest_Data { } type AuthenticateResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + IsValid bool `protobuf:"varint,1,opt,name=is_valid,proto3" json:"is_valid,omitempty"` unknownFields protoimpl.UnknownFields - - IsValid bool `protobuf:"varint,1,opt,name=is_valid,proto3" json:"is_valid,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AuthenticateResponse) Reset() { @@ -615,11 +604,10 @@ func (x *AuthenticateResponse) GetIsValid() bool { } type AuthLogoutRequest_Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` unknownFields protoimpl.UnknownFields - - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AuthLogoutRequest_Data) Reset() { @@ -660,12 +648,11 @@ func (x *AuthLogoutRequest_Data) GetToken() string { } type CreateTokenRequest_Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,proto3" json:"user_id,omitempty"` + Scopes []string `protobuf:"bytes,2,rep,name=scopes,proto3" json:"scopes,omitempty"` unknownFields protoimpl.UnknownFields - - UserId string `protobuf:"bytes,1,opt,name=user_id,proto3" json:"user_id,omitempty"` - Scopes []string `protobuf:"bytes,2,rep,name=scopes,proto3" json:"scopes,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateTokenRequest_Data) Reset() { @@ -713,11 +700,10 @@ func (x *CreateTokenRequest_Data) GetScopes() []string { } type DestroyTokenRequest_Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` unknownFields protoimpl.UnknownFields - - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DestroyTokenRequest_Data) Reset() { @@ -758,14 +744,13 @@ func (x *DestroyTokenRequest_Data) GetToken() string { } type AuthenticateRequest_Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` + Method string `protobuf:"bytes,4,opt,name=method,proto3" json:"method,omitempty"` + Operation string `protobuf:"bytes,5,opt,name=operation,proto3" json:"operation,omitempty"` unknownFields protoimpl.UnknownFields - - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` - Method string `protobuf:"bytes,4,opt,name=method,proto3" json:"method,omitempty"` - Operation string `protobuf:"bytes,5,opt,name=operation,proto3" json:"operation,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AuthenticateRequest_Data) Reset() { @@ -828,175 +813,75 @@ func (x *AuthenticateRequest_Data) GetOperation() string { var File_system_auth_proto protoreflect.FileDescriptor -var file_system_auth_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x74, - 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x75, 0x0a, 0x11, 0x41, 0x75, - 0x74, 0x68, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x42, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4c, 0x6f, 0x67, 0x6f, 0x75, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x1a, 0x1c, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x22, 0x42, 0x0a, 0x12, 0x41, 0x75, 0x74, 0x68, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x05, - 0x65, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x90, 0x01, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, - 0x74, 0x68, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, - 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x6f, - 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6e, - 0x6f, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x22, 0x7b, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, - 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, - 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, - 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x93, 0x01, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x1a, 0x38, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x22, 0x2b, 0x0a, 0x13, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x2c, 0x0a, 0x14, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xc1, 0x01, 0x0a, 0x15, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x51, 0x0a, 0x06, - 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x39, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x43, 0x6c, 0x61, 0x69, - 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x63, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x1a, - 0x39, 0x0a, 0x0b, 0x43, 0x6c, 0x61, 0x69, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x79, 0x0a, 0x13, 0x44, 0x65, - 0x73, 0x74, 0x72, 0x6f, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x44, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x44, 0x61, 0x74, - 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x1c, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, - 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x44, 0x0a, 0x14, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, - 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x52, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x22, 0xc3, 0x01, 0x0a, 0x13, - 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x44, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x65, - 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x44, - 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x66, 0x0a, 0x04, 0x44, 0x61, 0x74, - 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x16, 0x0a, 0x06, 0x6d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x22, 0x32, 0x0a, 0x14, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, 0x5f, - 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x5f, - 0x76, 0x61, 0x6c, 0x69, 0x64, 0x32, 0xdd, 0x06, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x95, 0x01, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, - 0x74, 0x68, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x30, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, 0x74, 0x68, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x61, - 0x75, 0x74, 0x68, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x85, 0x01, - 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2a, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x3a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x22, 0x0f, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x88, 0x01, 0x0a, 0x0d, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x14, 0x12, 0x12, 0x2f, 0x73, - 0x79, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x12, 0x8a, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x12, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x72, - 0x6f, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1f, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x19, 0x3a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x11, 0x2f, 0x73, 0x79, 0x73, - 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x64, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x79, 0x12, 0x8f, 0x01, - 0x0a, 0x0c, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x2b, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, - 0x63, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x1e, 0x3a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x16, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x61, 0x75, - 0x74, 0x68, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, - 0x83, 0x01, 0x0a, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, 0x29, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4c, 0x6f, 0x67, 0x6f, - 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x18, 0x3a, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x22, 0x10, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x6c, - 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x42, 0xbe, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x42, 0x09, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, 0x41, - 0x56, 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, 0x41, - 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, 0x47, - 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, 0x69, - 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, - 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_system_auth_proto_rawDesc = "" + + "\n" + + "\x11system/auth.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"u\n" + + "\x11AuthLogoutRequest\x12B\n" + + "\x04data\x18\x01 \x01(\v2..api.v1.services.system.AuthLogoutRequest.DataR\x04data\x1a\x1c\n" + + "\x04Data\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token\"B\n" + + "\x12AuthLogoutResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"\x90\x01\n" + + "\x18ListAuthResourcesRequest\x12\x1c\n" + + "\tpage_size\x18\x01 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x02 \x01(\tR\n" + + "page_token\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tno_paging\x18\x04 \x01(\bR\tno_paging\"{\n" + + "\x19ListAuthResourcesResponse\x12>\n" + + "\tresources\x18\x01 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x12\x1e\n" + + "\n" + + "total_size\x18\x02 \x01(\x05R\n" + + "total_size\"\x93\x01\n" + + "\x12CreateTokenRequest\x12C\n" + + "\x04data\x18\x01 \x01(\v2/.api.v1.services.system.CreateTokenRequest.DataR\x04data\x1a8\n" + + "\x04Data\x12\x18\n" + + "\auser_id\x18\x01 \x01(\tR\auser_id\x12\x16\n" + + "\x06scopes\x18\x02 \x03(\tR\x06scopes\"+\n" + + "\x13CreateTokenResponse\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token\",\n" + + "\x14ValidateTokenRequest\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token\"\xc1\x01\n" + + "\x15ValidateTokenResponse\x12\x1a\n" + + "\bis_valid\x18\x01 \x01(\bR\bis_valid\x12Q\n" + + "\x06claims\x18\x02 \x03(\v29.api.v1.services.system.ValidateTokenResponse.ClaimsEntryR\x06claims\x1a9\n" + + "\vClaimsEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"y\n" + + "\x13DestroyTokenRequest\x12D\n" + + "\x04data\x18\x01 \x01(\v20.api.v1.services.system.DestroyTokenRequest.DataR\x04data\x1a\x1c\n" + + "\x04Data\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token\"D\n" + + "\x14DestroyTokenResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"\xc3\x01\n" + + "\x13AuthenticateRequest\x12D\n" + + "\x04data\x18\x01 \x01(\v20.api.v1.services.system.AuthenticateRequest.DataR\x04data\x1af\n" + + "\x04Data\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token\x12\x12\n" + + "\x04path\x18\x03 \x01(\tR\x04path\x12\x16\n" + + "\x06method\x18\x04 \x01(\tR\x06method\x12\x1c\n" + + "\toperation\x18\x05 \x01(\tR\toperation\"2\n" + + "\x14AuthenticateResponse\x12\x1a\n" + + "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xdd\x06\n" + + "\vAuthService\x12\x95\x01\n" + + "\x11ListAuthResources\x120.api.v1.services.system.ListAuthResourcesRequest\x1a1.api.v1.services.system.ListAuthResourcesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/auth/resources\x12\x85\x01\n" + + "\vCreateToken\x12*.api.v1.services.system.CreateTokenRequest\x1a+.api.v1.services.system.CreateTokenResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x04data\"\x0f/sys/auth/token\x12\x88\x01\n" + + "\rValidateToken\x12,.api.v1.services.system.ValidateTokenRequest\x1a-.api.v1.services.system.ValidateTokenResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/sys/auth/validate\x12\x8a\x01\n" + + "\fDestroyToken\x12+.api.v1.services.system.DestroyTokenRequest\x1a,.api.v1.services.system.DestroyTokenResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x04data\"\x11/sys/auth/destroy\x12\x8f\x01\n" + + "\fAuthenticate\x12+.api.v1.services.system.AuthenticateRequest\x1a,.api.v1.services.system.AuthenticateResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\"\x16/sys/auth/authenticate\x12\x83\x01\n" + + "\n" + + "AuthLogout\x12).api.v1.services.system.AuthLogoutRequest\x1a*.api.v1.services.system.AuthLogoutResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x04data\"\x10/sys/auth/logoutB\xbe\x01\n" + + "\x1acom.api.v1.services.systemB\tAuthProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_auth_proto_rawDescOnce sync.Once - file_system_auth_proto_rawDescData = file_system_auth_proto_rawDesc + file_system_auth_proto_rawDescData []byte ) func file_system_auth_proto_rawDescGZIP() []byte { file_system_auth_proto_rawDescOnce.Do(func() { - file_system_auth_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_auth_proto_rawDescData) + file_system_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_auth_proto_rawDesc), len(file_system_auth_proto_rawDesc))) }) return file_system_auth_proto_rawDescData } @@ -1061,7 +946,7 @@ func file_system_auth_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_auth_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_auth_proto_rawDesc), len(file_system_auth_proto_rawDesc)), NumEnums: 0, NumMessages: 17, NumExtensions: 0, @@ -1072,7 +957,6 @@ func file_system_auth_proto_init() { MessageInfos: file_system_auth_proto_msgTypes, }.Build() File_system_auth_proto = out.File - file_system_auth_proto_rawDesc = nil file_system_auth_proto_goTypes = nil file_system_auth_proto_depIdxs = nil } diff --git a/api/v1/services/system/auth.pb.validate.go b/api/v1/services/system/auth.pb.validate.go index 1baff8f1..730b5486 100644 --- a/api/v1/services/system/auth.pb.validate.go +++ b/api/v1/services/system/auth.pb.validate.go @@ -100,7 +100,7 @@ type AuthLogoutRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m AuthLogoutRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -231,7 +231,7 @@ type AuthLogoutResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m AuthLogoutResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -341,7 +341,7 @@ type ListAuthResourcesRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListAuthResourcesRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -479,7 +479,7 @@ type ListAuthResourcesResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListAuthResourcesResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -610,7 +610,7 @@ type CreateTokenRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateTokenRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -714,7 +714,7 @@ type CreateTokenResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateTokenResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -818,7 +818,7 @@ type ValidateTokenRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ValidateTokenRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -924,7 +924,7 @@ type ValidateTokenResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ValidateTokenResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1055,7 +1055,7 @@ type DestroyTokenRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DestroyTokenRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1186,7 +1186,7 @@ type DestroyTokenResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DestroyTokenResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1317,7 +1317,7 @@ type AuthenticateRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m AuthenticateRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1421,7 +1421,7 @@ type AuthenticateResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m AuthenticateResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1525,7 +1525,7 @@ type AuthLogoutRequest_DataMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m AuthLogoutRequest_DataMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1629,7 +1629,7 @@ type CreateTokenRequest_DataMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateTokenRequest_DataMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1733,7 +1733,7 @@ type DestroyTokenRequest_DataMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DestroyTokenRequest_DataMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1843,7 +1843,7 @@ type AuthenticateRequest_DataMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m AuthenticateRequest_DataMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/auth_http.pb.go b/api/v1/services/system/auth_http.pb.go index 649115fd..fb7034d5 100644 --- a/api/v1/services/system/auth_http.pb.go +++ b/api/v1/services/system/auth_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/auth.proto diff --git a/api/v1/services/system/casbin.pb.go b/api/v1/services/system/casbin.pb.go index 69e550b3..6edeefb9 100644 --- a/api/v1/services/system/casbin.pb.go +++ b/api/v1/services/system/casbin.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/casbin.proto @@ -14,6 +14,7 @@ import ( _ "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -24,9 +25,9 @@ const ( ) type ListPoliciesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListPoliciesRequest) Reset() { @@ -60,11 +61,10 @@ func (*ListPoliciesRequest) Descriptor() ([]byte, []int) { } type ListPoliciesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Rules []*PolicyRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` unknownFields protoimpl.UnknownFields - - Rules []*PolicyRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ListPoliciesResponse) Reset() { @@ -105,12 +105,11 @@ func (x *ListPoliciesResponse) GetRules() []*PolicyRule { } type PolicyRule struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + PType string `protobuf:"bytes,1,opt,name=p_type,proto3" json:"p_type,omitempty"` + Params []string `protobuf:"bytes,2,rep,name=params,proto3" json:"params,omitempty"` unknownFields protoimpl.UnknownFields - - PType string `protobuf:"bytes,1,opt,name=p_type,proto3" json:"p_type,omitempty"` - Params []string `protobuf:"bytes,2,rep,name=params,proto3" json:"params,omitempty"` + sizeCache protoimpl.SizeCache } func (x *PolicyRule) Reset() { @@ -158,9 +157,9 @@ func (x *PolicyRule) GetParams() []string { } type ListGroupingsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListGroupingsRequest) Reset() { @@ -194,11 +193,10 @@ func (*ListGroupingsRequest) Descriptor() ([]byte, []int) { } type ListGroupingsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Rules []*GroupingRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` unknownFields protoimpl.UnknownFields - - Rules []*GroupingRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ListGroupingsResponse) Reset() { @@ -239,12 +237,11 @@ func (x *ListGroupingsResponse) GetRules() []*GroupingRule { } type GroupingRule struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + PType string `protobuf:"bytes,1,opt,name=p_type,proto3" json:"p_type,omitempty"` + Params []string `protobuf:"bytes,2,rep,name=params,proto3" json:"params,omitempty"` unknownFields protoimpl.UnknownFields - - PType string `protobuf:"bytes,1,opt,name=p_type,proto3" json:"p_type,omitempty"` - Params []string `protobuf:"bytes,2,rep,name=params,proto3" json:"params,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GroupingRule) Reset() { @@ -292,12 +289,11 @@ func (x *GroupingRule) GetParams() []string { } type StreamRulesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + WithPolicies bool `protobuf:"varint,1,opt,name=with_policies,proto3" json:"with_policies,omitempty"` + WithGroupings bool `protobuf:"varint,2,opt,name=with_groupings,proto3" json:"with_groupings,omitempty"` unknownFields protoimpl.UnknownFields - - WithPolicies bool `protobuf:"varint,1,opt,name=with_policies,proto3" json:"with_policies,omitempty"` - WithGroupings bool `protobuf:"varint,2,opt,name=with_groupings,proto3" json:"with_groupings,omitempty"` + sizeCache protoimpl.SizeCache } func (x *StreamRulesRequest) Reset() { @@ -345,15 +341,14 @@ func (x *StreamRulesRequest) GetWithGroupings() bool { } type StreamRulesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Types that are assignable to RuleType: + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to RuleType: // // *StreamRulesResponse_Policy // *StreamRulesResponse_Grouping - RuleType isStreamRulesResponse_RuleType `protobuf_oneof:"rule_type"` + RuleType isStreamRulesResponse_RuleType `protobuf_oneof:"rule_type"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *StreamRulesResponse) Reset() { @@ -386,23 +381,27 @@ func (*StreamRulesResponse) Descriptor() ([]byte, []int) { return file_system_casbin_proto_rawDescGZIP(), []int{7} } -func (m *StreamRulesResponse) GetRuleType() isStreamRulesResponse_RuleType { - if m != nil { - return m.RuleType +func (x *StreamRulesResponse) GetRuleType() isStreamRulesResponse_RuleType { + if x != nil { + return x.RuleType } return nil } func (x *StreamRulesResponse) GetPolicy() *PolicyRule { - if x, ok := x.GetRuleType().(*StreamRulesResponse_Policy); ok { - return x.Policy + if x != nil { + if x, ok := x.RuleType.(*StreamRulesResponse_Policy); ok { + return x.Policy + } } return nil } func (x *StreamRulesResponse) GetGrouping() *GroupingRule { - if x, ok := x.GetRuleType().(*StreamRulesResponse_Grouping); ok { - return x.Grouping + if x != nil { + if x, ok := x.RuleType.(*StreamRulesResponse_Grouping); ok { + return x.Grouping + } } return nil } @@ -424,11 +423,10 @@ func (*StreamRulesResponse_Policy) isStreamRulesResponse_RuleType() {} func (*StreamRulesResponse_Grouping) isStreamRulesResponse_RuleType() {} type WatchUpdateRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + LastModified int64 `protobuf:"varint,1,opt,name=last_modified,proto3" json:"last_modified,omitempty"` unknownFields protoimpl.UnknownFields - - LastModified int64 `protobuf:"varint,1,opt,name=last_modified,proto3" json:"last_modified,omitempty"` + sizeCache protoimpl.SizeCache } func (x *WatchUpdateRequest) Reset() { @@ -469,11 +467,10 @@ func (x *WatchUpdateRequest) GetLastModified() int64 { } type WatchUpdateResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + ModifiedDate int64 `protobuf:"varint,1,opt,name=modified_date,proto3" json:"modified_date,omitempty"` unknownFields protoimpl.UnknownFields - - ModifiedDate int64 `protobuf:"varint,1,opt,name=modified_date,proto3" json:"modified_date,omitempty"` + sizeCache protoimpl.SizeCache } func (x *WatchUpdateResponse) Reset() { @@ -515,121 +512,48 @@ func (x *WatchUpdateResponse) GetModifiedDate() int64 { var File_system_casbin_proto protoreflect.FileDescriptor -var file_system_casbin_proto_rawDesc = []byte{ - 0x0a, 0x13, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x63, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x1c, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x50, - 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, - 0x22, 0x3c, 0x0a, 0x0a, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x16, - 0x0a, 0x06, 0x70, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x70, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x16, - 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x53, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x3a, 0x0a, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, - 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x3e, 0x0a, 0x0c, 0x47, - 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, - 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x22, 0x62, 0x0a, 0x12, 0x53, - 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, - 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x70, - 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x77, 0x69, 0x74, 0x68, 0x5f, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0e, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x22, - 0xa4, 0x01, 0x0a, 0x13, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x06, 0x70, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x75, 0x6c, 0x65, 0x48, 0x00, 0x52, 0x06, 0x70, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x42, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x48, 0x00, 0x52, - 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, 0x42, 0x0b, 0x0a, 0x09, 0x72, 0x75, 0x6c, - 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x22, 0x3a, 0x0a, 0x12, 0x57, 0x61, 0x74, 0x63, 0x68, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0d, - 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, - 0x65, 0x64, 0x22, 0x3b, 0x0a, 0x13, 0x57, 0x61, 0x74, 0x63, 0x68, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x6f, 0x64, - 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x0d, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, 0x64, 0x61, 0x74, 0x65, 0x32, - 0xb4, 0x04, 0x0a, 0x13, 0x43, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x86, 0x01, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, - 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x12, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, - 0x69, 0x73, 0x74, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x62, 0x01, 0x2a, 0x12, 0x10, - 0x2f, 0x63, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x2f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x69, 0x65, 0x73, - 0x12, 0x8a, 0x01, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, - 0x67, 0x73, 0x12, 0x2c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x47, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x62, 0x01, 0x2a, 0x12, 0x11, 0x2f, 0x63, 0x61, 0x73, - 0x62, 0x69, 0x6e, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x80, 0x01, - 0x0a, 0x0b, 0x57, 0x61, 0x74, 0x63, 0x68, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x12, 0x2a, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x57, 0x61, 0x74, 0x63, 0x68, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x62, 0x01, - 0x2a, 0x12, 0x0d, 0x2f, 0x63, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x2f, 0x77, 0x61, 0x74, 0x63, 0x68, - 0x12, 0x83, 0x01, 0x0a, 0x0b, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x75, 0x6c, 0x65, 0x73, - 0x12, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, - 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x75, 0x6c, 0x65, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x13, 0x62, 0x01, 0x2a, 0x12, 0x0e, 0x2f, 0x63, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x2f, 0x73, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x30, 0x01, 0x42, 0xc0, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x42, 0x0b, 0x43, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, - 0x02, 0x04, 0x41, 0x56, 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, - 0x02, 0x16, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, - 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, - 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x3a, 0x3a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} +const file_system_casbin_proto_rawDesc = "" + + "\n" + + "\x13system/casbin.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\x15\n" + + "\x13ListPoliciesRequest\"P\n" + + "\x14ListPoliciesResponse\x128\n" + + "\x05rules\x18\x01 \x03(\v2\".api.v1.services.system.PolicyRuleR\x05rules\"<\n" + + "\n" + + "PolicyRule\x12\x16\n" + + "\x06p_type\x18\x01 \x01(\tR\x06p_type\x12\x16\n" + + "\x06params\x18\x02 \x03(\tR\x06params\"\x16\n" + + "\x14ListGroupingsRequest\"S\n" + + "\x15ListGroupingsResponse\x12:\n" + + "\x05rules\x18\x01 \x03(\v2$.api.v1.services.system.GroupingRuleR\x05rules\">\n" + + "\fGroupingRule\x12\x16\n" + + "\x06p_type\x18\x01 \x01(\tR\x06p_type\x12\x16\n" + + "\x06params\x18\x02 \x03(\tR\x06params\"b\n" + + "\x12StreamRulesRequest\x12$\n" + + "\rwith_policies\x18\x01 \x01(\bR\rwith_policies\x12&\n" + + "\x0ewith_groupings\x18\x02 \x01(\bR\x0ewith_groupings\"\xa4\x01\n" + + "\x13StreamRulesResponse\x12<\n" + + "\x06policy\x18\x01 \x01(\v2\".api.v1.services.system.PolicyRuleH\x00R\x06policy\x12B\n" + + "\bgrouping\x18\x02 \x01(\v2$.api.v1.services.system.GroupingRuleH\x00R\bgroupingB\v\n" + + "\trule_type\":\n" + + "\x12WatchUpdateRequest\x12$\n" + + "\rlast_modified\x18\x01 \x01(\x03R\rlast_modified\";\n" + + "\x13WatchUpdateResponse\x12$\n" + + "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\xb4\x04\n" + + "\x13CasbinSourceService\x12\x86\x01\n" + + "\fListPolicies\x12+.api.v1.services.system.ListPoliciesRequest\x1a,.api.v1.services.system.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x8a\x01\n" + + "\rListGroupings\x12,.api.v1.services.system.ListGroupingsRequest\x1a-.api.v1.services.system.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12\x80\x01\n" + + "\vWatchUpdate\x12*.api.v1.services.system.WatchUpdateRequest\x1a+.api.v1.services.system.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12\x83\x01\n" + + "\vStreamRules\x12*.api.v1.services.system.StreamRulesRequest\x1a+.api.v1.services.system.StreamRulesResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/casbin/stream0\x01B\xc0\x01\n" + + "\x1acom.api.v1.services.systemB\vCasbinProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_casbin_proto_rawDescOnce sync.Once - file_system_casbin_proto_rawDescData = file_system_casbin_proto_rawDesc + file_system_casbin_proto_rawDescData []byte ) func file_system_casbin_proto_rawDescGZIP() []byte { file_system_casbin_proto_rawDescOnce.Do(func() { - file_system_casbin_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_casbin_proto_rawDescData) + file_system_casbin_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_casbin_proto_rawDesc), len(file_system_casbin_proto_rawDesc))) }) return file_system_casbin_proto_rawDescData } @@ -681,7 +605,7 @@ func file_system_casbin_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_casbin_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_casbin_proto_rawDesc), len(file_system_casbin_proto_rawDesc)), NumEnums: 0, NumMessages: 10, NumExtensions: 0, @@ -692,7 +616,6 @@ func file_system_casbin_proto_init() { MessageInfos: file_system_casbin_proto_msgTypes, }.Build() File_system_casbin_proto = out.File - file_system_casbin_proto_rawDesc = nil file_system_casbin_proto_goTypes = nil file_system_casbin_proto_depIdxs = nil } diff --git a/api/v1/services/system/casbin.pb.validate.go b/api/v1/services/system/casbin.pb.validate.go index d7c99c25..61ddaec5 100644 --- a/api/v1/services/system/casbin.pb.validate.go +++ b/api/v1/services/system/casbin.pb.validate.go @@ -71,7 +71,7 @@ type ListPoliciesRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListPoliciesRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -207,7 +207,7 @@ type ListPoliciesResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListPoliciesResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -310,7 +310,7 @@ type PolicyRuleMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PolicyRuleMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -410,7 +410,7 @@ type ListGroupingsRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListGroupingsRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -546,7 +546,7 @@ type ListGroupingsResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListGroupingsResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -649,7 +649,7 @@ type GroupingRuleMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GroupingRuleMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -753,7 +753,7 @@ type StreamRulesRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m StreamRulesRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -942,7 +942,7 @@ type StreamRulesResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m StreamRulesResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1046,7 +1046,7 @@ type WatchUpdateRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m WatchUpdateRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1150,7 +1150,7 @@ type WatchUpdateResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m WatchUpdateResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/casbin_http.pb.go b/api/v1/services/system/casbin_http.pb.go index 265cd5bb..66b93ee1 100644 --- a/api/v1/services/system/casbin_http.pb.go +++ b/api/v1/services/system/casbin_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/casbin.proto diff --git a/api/v1/services/system/department.pb.go b/api/v1/services/system/department.pb.go index 540897c1..0a5adc7f 100644 --- a/api/v1/services/system/department.pb.go +++ b/api/v1/services/system/department.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/department.proto @@ -14,6 +14,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -24,10 +25,7 @@ const ( ) type ListDepartmentsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id, for example, "shelves/shelf1". Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The current page number. @@ -39,7 +37,9 @@ type ListDepartmentsRequest struct { // The no_paging is used to disable pagination. NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListDepartmentsRequest) Reset() { @@ -115,10 +115,7 @@ func (x *ListDepartmentsRequest) GetOnlyCount() bool { } type ListDepartmentsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus @@ -132,7 +129,9 @@ type ListDepartmentsResponse struct { NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` // Additional information about this response. // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListDepartmentsResponse) Reset() { @@ -208,13 +207,12 @@ func (x *ListDepartmentsResponse) GetExtra() *anypb.Any { } type GetDepartmentRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The field will contain id of the resource requested, for example: // "shelves/shelf1/departments/department2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetDepartmentRequest) Reset() { @@ -255,11 +253,10 @@ func (x *GetDepartmentRequest) GetId() int64 { } type GetDepartmentResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` unknownFields protoimpl.UnknownFields - - Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetDepartmentResponse) Reset() { @@ -300,17 +297,16 @@ func (x *GetDepartmentResponse) GetDepartment() *Department { } type CreateDepartmentRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id where the department is to be created. Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` // The department id to use for this department. DepartmentId string `protobuf:"bytes,3,opt,name=department_id,proto3" json:"department_id,omitempty"` // The department resource to create. // The field id should match the Noun in the method id. - Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CreateDepartmentRequest) Reset() { @@ -365,11 +361,10 @@ func (x *CreateDepartmentRequest) GetDepartment() *Department { } type CreateDepartmentResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` unknownFields protoimpl.UnknownFields - - Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateDepartmentResponse) Reset() { @@ -410,14 +405,13 @@ func (x *CreateDepartmentResponse) GetDepartment() *Department { } type UpdateDepartmentRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The department id to use for this department. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The department resource which replaces the resource on the server. - Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdateDepartmentRequest) Reset() { @@ -465,11 +459,10 @@ func (x *UpdateDepartmentRequest) GetDepartment() *Department { } type UpdateDepartmentResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` unknownFields protoimpl.UnknownFields - - Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdateDepartmentResponse) Reset() { @@ -510,13 +503,12 @@ func (x *UpdateDepartmentResponse) GetDepartment() *Department { } type DeleteDepartmentRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The resource id of the department to be deleted, for example: // "shelves/shelf1/departments/department2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *DeleteDepartmentRequest) Reset() { @@ -557,11 +549,10 @@ func (x *DeleteDepartmentRequest) GetId() int64 { } type DeleteDepartmentResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` unknownFields protoimpl.UnknownFields - - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DeleteDepartmentResponse) Reset() { @@ -603,164 +594,77 @@ func (x *DeleteDepartmentResponse) GetEmpty() *emptypb.Empty { var File_system_department_proto protoreflect.FileDescriptor -var file_system_department_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, - 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, - 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, - 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, - 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, - 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbe, 0x01, 0x0a, 0x16, - 0x4c, 0x69, 0x73, 0x74, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1e, - 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1c, - 0x0a, 0x09, 0x6e, 0x6f, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x09, 0x6e, 0x6f, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a, - 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x0a, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x9c, 0x02, 0x0a, - 0x17, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, - 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, - 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x64, 0x65, 0x70, 0x61, - 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x0b, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x18, - 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, - 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x67, - 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, - 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x12, 0x2f, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x48, 0x00, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x88, 0x01, - 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x65, 0x78, 0x74, 0x72, 0x61, 0x22, 0x26, 0x0a, 0x14, 0x47, - 0x65, 0x74, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x02, 0x69, 0x64, 0x22, 0x5b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x0a, - 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, - 0x22, 0x9b, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, - 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, - 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, - 0x72, 0x65, 0x6e, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x70, - 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x12, 0x42, 0x0a, 0x0a, 0x64, 0x65, - 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x5e, - 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x0a, 0x64, 0x65, - 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x6d, - 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x42, 0x0a, 0x0a, 0x64, 0x65, 0x70, - 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x5e, 0x0a, - 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x0a, 0x64, 0x65, 0x70, - 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x29, 0x0a, - 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x48, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x05, 0x65, 0x6d, 0x70, - 0x74, 0x79, 0x32, 0x93, 0x06, 0x0a, 0x11, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x8c, 0x01, 0x0a, 0x0f, 0x4c, 0x69, 0x73, - 0x74, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x2e, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x64, 0x65, 0x70, 0x61, - 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x12, 0x8b, 0x01, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x44, - 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2c, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x12, 0x15, - 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, - 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x9b, 0x01, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, - 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x24, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x3a, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x22, 0x10, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x12, 0xab, 0x01, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x65, - 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x34, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x2e, 0x3a, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x1a, - 0x20, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x2f, 0x7b, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x69, 0x64, - 0x7d, 0x12, 0x94, 0x01, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, - 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x17, 0x2a, 0x15, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xc4, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x42, 0x0f, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, - 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, 0x41, 0x56, 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, - 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, - 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_system_department_proto_rawDesc = "" + + "\n" + + "\x17system/department.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xbe\x01\n" + + "\x16ListDepartmentsRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\"\x9c\x02\n" + + "\x17ListDepartmentsResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x12D\n" + + "\vdepartments\x18\x02 \x03(\v2\".api.v1.services.system.DepartmentR\vdepartments\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"&\n" + + "\x14GetDepartmentRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"[\n" + + "\x15GetDepartmentResponse\x12B\n" + + "\n" + + "department\x18\x01 \x01(\v2\".api.v1.services.system.DepartmentR\n" + + "department\"\x9b\x01\n" + + "\x17CreateDepartmentRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12$\n" + + "\rdepartment_id\x18\x03 \x01(\tR\rdepartment_id\x12B\n" + + "\n" + + "department\x18\x02 \x01(\v2\".api.v1.services.system.DepartmentR\n" + + "department\"^\n" + + "\x18CreateDepartmentResponse\x12B\n" + + "\n" + + "department\x18\x01 \x01(\v2\".api.v1.services.system.DepartmentR\n" + + "department\"m\n" + + "\x17UpdateDepartmentRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12B\n" + + "\n" + + "department\x18\x02 \x01(\v2\".api.v1.services.system.DepartmentR\n" + + "department\"^\n" + + "\x18UpdateDepartmentResponse\x12B\n" + + "\n" + + "department\x18\x01 \x01(\v2\".api.v1.services.system.DepartmentR\n" + + "department\")\n" + + "\x17DeleteDepartmentRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + + "\x18DeleteDepartmentResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x93\x06\n" + + "\x11DepartmentService\x12\x8c\x01\n" + + "\x0fListDepartments\x12..api.v1.services.system.ListDepartmentsRequest\x1a/.api.v1.services.system.ListDepartmentsResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/departments\x12\x8b\x01\n" + + "\rGetDepartment\x12,.api.v1.services.system.GetDepartmentRequest\x1a-.api.v1.services.system.GetDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/departments/{id}\x12\x9b\x01\n" + + "\x10CreateDepartment\x12/.api.v1.services.system.CreateDepartmentRequest\x1a0.api.v1.services.system.CreateDepartmentResponse\"$\x82\xd3\xe4\x93\x02\x1e:\n" + + "department\"\x10/sys/departments\x12\xab\x01\n" + + "\x10UpdateDepartment\x12/.api.v1.services.system.UpdateDepartmentRequest\x1a0.api.v1.services.system.UpdateDepartmentResponse\"4\x82\xd3\xe4\x93\x02.:\n" + + "department\x1a /sys/departments/{department.id}\x12\x94\x01\n" + + "\x10DeleteDepartment\x12/.api.v1.services.system.DeleteDepartmentRequest\x1a0.api.v1.services.system.DeleteDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/departments/{id}B\xc4\x01\n" + + "\x1acom.api.v1.services.systemB\x0fDepartmentProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_department_proto_rawDescOnce sync.Once - file_system_department_proto_rawDescData = file_system_department_proto_rawDesc + file_system_department_proto_rawDescData []byte ) func file_system_department_proto_rawDescGZIP() []byte { file_system_department_proto_rawDescOnce.Do(func() { - file_system_department_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_department_proto_rawDescData) + file_system_department_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_department_proto_rawDesc), len(file_system_department_proto_rawDesc))) }) return file_system_department_proto_rawDescData } @@ -818,7 +722,7 @@ func file_system_department_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_department_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_department_proto_rawDesc), len(file_system_department_proto_rawDesc)), NumEnums: 0, NumMessages: 10, NumExtensions: 0, @@ -829,7 +733,6 @@ func file_system_department_proto_init() { MessageInfos: file_system_department_proto_msgTypes, }.Build() File_system_department_proto = out.File - file_system_department_proto_rawDesc = nil file_system_department_proto_goTypes = nil file_system_department_proto_depIdxs = nil } diff --git a/api/v1/services/system/department.pb.validate.go b/api/v1/services/system/department.pb.validate.go index 5dc20553..3c32bc5e 100644 --- a/api/v1/services/system/department.pb.validate.go +++ b/api/v1/services/system/department.pb.validate.go @@ -83,7 +83,7 @@ type ListDepartmentsRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListDepartmentsRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -260,7 +260,7 @@ type ListDepartmentsResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListDepartmentsResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -364,7 +364,7 @@ type GetDepartmentRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetDepartmentRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -495,7 +495,7 @@ type GetDepartmentResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetDepartmentResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -630,7 +630,7 @@ type CreateDepartmentRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateDepartmentRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -761,7 +761,7 @@ type CreateDepartmentResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateDepartmentResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -894,7 +894,7 @@ type UpdateDepartmentRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateDepartmentRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1025,7 +1025,7 @@ type UpdateDepartmentResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateDepartmentResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1129,7 +1129,7 @@ type DeleteDepartmentRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeleteDepartmentRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1260,7 +1260,7 @@ type DeleteDepartmentResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeleteDepartmentResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/department_http.pb.go b/api/v1/services/system/department_http.pb.go index 05d64ab8..dd2242cc 100644 --- a/api/v1/services/system/department_http.pb.go +++ b/api/v1/services/system/department_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/department.proto diff --git a/api/v1/services/system/error.pb.go b/api/v1/services/system/error.pb.go index 239fd279..8485f61a 100644 --- a/api/v1/services/system/error.pb.go +++ b/api/v1/services/system/error.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/error.proto @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -120,94 +121,40 @@ func (SystemErrorReason) EnumDescriptor() ([]byte, []int) { var File_system_error_proto protoreflect.FileDescriptor -var file_system_error_proto_rawDesc = []byte{ - 0x0a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x13, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x73, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0xbf, 0x07, 0x0a, 0x11, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x45, 0x72, 0x72, 0x6f, - 0x72, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x1f, 0x53, 0x59, 0x53, 0x54, 0x45, - 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x55, - 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x2d, 0x0a, 0x22, - 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, - 0x53, 0x4f, 0x4e, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, - 0x4e, 0x44, 0x10, 0xd1, 0x0f, 0x1a, 0x04, 0xa8, 0x45, 0x94, 0x03, 0x12, 0x32, 0x0a, 0x27, 0x53, - 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, - 0x4f, 0x4e, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x41, 0x4c, 0x52, 0x45, 0x41, 0x44, 0x59, 0x5f, - 0x45, 0x58, 0x49, 0x53, 0x54, 0x53, 0x10, 0xd2, 0x0f, 0x1a, 0x04, 0xa8, 0x45, 0x99, 0x03, 0x12, - 0x31, 0x0a, 0x26, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, - 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, - 0x4c, 0x4f, 0x47, 0x47, 0x45, 0x44, 0x5f, 0x49, 0x4e, 0x10, 0xd3, 0x0f, 0x1a, 0x04, 0xa8, 0x45, - 0x91, 0x03, 0x12, 0x32, 0x0a, 0x27, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, - 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x5f, 0x4e, - 0x4f, 0x54, 0x5f, 0x4c, 0x4f, 0x47, 0x47, 0x45, 0x44, 0x5f, 0x4f, 0x55, 0x54, 0x10, 0xd4, 0x0f, - 0x1a, 0x04, 0xa8, 0x45, 0x91, 0x03, 0x12, 0x2c, 0x0a, 0x21, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, - 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x54, 0x4f, - 0x4b, 0x45, 0x4e, 0x5f, 0x45, 0x58, 0x50, 0x49, 0x52, 0x45, 0x44, 0x10, 0xd5, 0x0f, 0x1a, 0x04, - 0xa8, 0x45, 0x91, 0x03, 0x12, 0x2e, 0x0a, 0x23, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, - 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x54, 0x4f, 0x4b, 0x45, - 0x4e, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0xd6, 0x0f, 0x1a, 0x04, - 0xa8, 0x45, 0x91, 0x03, 0x12, 0x2c, 0x0a, 0x21, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, - 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, - 0x4c, 0x49, 0x44, 0x5f, 0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x10, 0xd7, 0x0f, 0x1a, 0x04, 0xa8, 0x45, - 0x91, 0x03, 0x12, 0x2d, 0x0a, 0x22, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, - 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, - 0x44, 0x5f, 0x43, 0x4c, 0x41, 0x49, 0x4d, 0x53, 0x10, 0xd8, 0x0f, 0x1a, 0x04, 0xa8, 0x45, 0x91, - 0x03, 0x12, 0x35, 0x0a, 0x2a, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, - 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, - 0x5f, 0x41, 0x55, 0x54, 0x48, 0x45, 0x4e, 0x54, 0x49, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, - 0xd9, 0x0f, 0x1a, 0x04, 0xa8, 0x45, 0x91, 0x03, 0x12, 0x34, 0x0a, 0x29, 0x53, 0x59, 0x53, 0x54, - 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, - 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x5a, - 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0xda, 0x0f, 0x1a, 0x04, 0xa8, 0x45, 0x93, 0x03, 0x12, 0x2e, - 0x0a, 0x23, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, - 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x52, 0x45, - 0x51, 0x55, 0x45, 0x53, 0x54, 0x10, 0xdb, 0x0f, 0x1a, 0x04, 0xa8, 0x45, 0x90, 0x03, 0x12, 0x2f, - 0x0a, 0x24, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, - 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x52, 0x45, - 0x53, 0x50, 0x4f, 0x4e, 0x53, 0x45, 0x10, 0xdc, 0x0f, 0x1a, 0x04, 0xa8, 0x45, 0xf4, 0x03, 0x12, - 0x2d, 0x0a, 0x22, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, - 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x53, - 0x45, 0x52, 0x56, 0x45, 0x52, 0x10, 0xdd, 0x0f, 0x1a, 0x04, 0xa8, 0x45, 0xf4, 0x03, 0x12, 0x33, - 0x0a, 0x28, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, - 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x43, 0x41, 0x50, 0x54, 0x43, 0x48, 0x41, 0x5f, 0x49, 0x44, - 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x46, 0x4f, 0x55, 0x4e, 0x44, 0x10, 0xe9, 0x07, 0x1a, 0x04, 0xa8, - 0x45, 0x94, 0x03, 0x12, 0x31, 0x0a, 0x26, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, - 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, - 0x49, 0x44, 0x5f, 0x43, 0x41, 0x50, 0x54, 0x43, 0x48, 0x41, 0x5f, 0x49, 0x44, 0x10, 0xea, 0x07, - 0x1a, 0x04, 0xa8, 0x45, 0x90, 0x03, 0x12, 0x33, 0x0a, 0x28, 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, - 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, - 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x43, 0x41, 0x50, 0x54, 0x43, 0x48, 0x41, 0x5f, 0x43, 0x4f, - 0x44, 0x45, 0x10, 0xeb, 0x07, 0x1a, 0x04, 0xa8, 0x45, 0x90, 0x03, 0x12, 0x2f, 0x0a, 0x24, 0x53, - 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, 0x53, - 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x55, 0x53, 0x45, 0x52, 0x4e, - 0x41, 0x4d, 0x45, 0x10, 0xed, 0x07, 0x1a, 0x04, 0xa8, 0x45, 0x90, 0x03, 0x12, 0x2f, 0x0a, 0x24, - 0x53, 0x59, 0x53, 0x54, 0x45, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x41, - 0x53, 0x4f, 0x4e, 0x5f, 0x49, 0x4e, 0x56, 0x41, 0x4c, 0x49, 0x44, 0x5f, 0x50, 0x41, 0x53, 0x53, - 0x57, 0x4f, 0x52, 0x44, 0x10, 0xee, 0x07, 0x1a, 0x04, 0xa8, 0x45, 0x90, 0x03, 0x1a, 0x04, 0xa0, - 0x45, 0xf4, 0x03, 0x42, 0xbf, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x42, 0x0a, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, 0x41, 0x56, - 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, 0x41, 0x70, - 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, 0x69, 0x3a, - 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x53, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_system_error_proto_rawDesc = "" + + "\n" + + "\x12system/error.proto\x12\x16api.v1.services.system\x1a\x13errors/errors.proto*\xbf\a\n" + + "\x11SystemErrorReason\x12#\n" + + "\x1fSYSTEM_ERROR_REASON_UNSPECIFIED\x10\x00\x12-\n" + + "\"SYSTEM_ERROR_REASON_USER_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x122\n" + + "'SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS\x10\xd2\x0f\x1a\x04\xa8E\x99\x03\x121\n" + + "&SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN\x10\xd3\x0f\x1a\x04\xa8E\x91\x03\x122\n" + + "'SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT\x10\xd4\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + + "!SYSTEM_ERROR_REASON_TOKEN_EXPIRED\x10\xd5\x0f\x1a\x04\xa8E\x91\x03\x12.\n" + + "#SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND\x10\xd6\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + + "!SYSTEM_ERROR_REASON_INVALID_TOKEN\x10\xd7\x0f\x1a\x04\xa8E\x91\x03\x12-\n" + + "\"SYSTEM_ERROR_REASON_INVALID_CLAIMS\x10\xd8\x0f\x1a\x04\xa8E\x91\x03\x125\n" + + "*SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION\x10\xd9\x0f\x1a\x04\xa8E\x91\x03\x124\n" + + ")SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION\x10\xda\x0f\x1a\x04\xa8E\x93\x03\x12.\n" + + "#SYSTEM_ERROR_REASON_INVALID_REQUEST\x10\xdb\x0f\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_RESPONSE\x10\xdc\x0f\x1a\x04\xa8E\xf4\x03\x12-\n" + + "\"SYSTEM_ERROR_REASON_INVALID_SERVER\x10\xdd\x0f\x1a\x04\xa8E\xf4\x03\x123\n" + + "(SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND\x10\xe9\a\x1a\x04\xa8E\x94\x03\x121\n" + + "&SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID\x10\xea\a\x1a\x04\xa8E\x90\x03\x123\n" + + "(SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE\x10\xeb\a\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_USERNAME\x10\xed\a\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_PASSWORD\x10\xee\a\x1a\x04\xa8E\x90\x03\x1a\x04\xa0E\xf4\x03B\xbf\x01\n" + + "\x1acom.api.v1.services.systemB\n" + + "ErrorProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_error_proto_rawDescOnce sync.Once - file_system_error_proto_rawDescData = file_system_error_proto_rawDesc + file_system_error_proto_rawDescData []byte ) func file_system_error_proto_rawDescGZIP() []byte { file_system_error_proto_rawDescOnce.Do(func() { - file_system_error_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_error_proto_rawDescData) + file_system_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_error_proto_rawDesc), len(file_system_error_proto_rawDesc))) }) return file_system_error_proto_rawDescData } @@ -233,7 +180,7 @@ func file_system_error_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_error_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_error_proto_rawDesc), len(file_system_error_proto_rawDesc)), NumEnums: 1, NumMessages: 0, NumExtensions: 0, @@ -244,7 +191,6 @@ func file_system_error_proto_init() { EnumInfos: file_system_error_proto_enumTypes, }.Build() File_system_error_proto = out.File - file_system_error_proto_rawDesc = nil file_system_error_proto_goTypes = nil file_system_error_proto_depIdxs = nil } diff --git a/api/v1/services/system/login.pb.go b/api/v1/services/system/login.pb.go index 96c5a68d..8643d693 100644 --- a/api/v1/services/system/login.pb.go +++ b/api/v1/services/system/login.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/login.proto @@ -15,6 +15,7 @@ import ( anypb "google.golang.org/protobuf/types/known/anypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -25,11 +26,10 @@ const ( ) type TokenRefreshRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *TokenRefreshRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *TokenRefreshRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *TokenRefreshRequest) Reset() { @@ -70,11 +70,10 @@ func (x *TokenRefreshRequest) GetData() *TokenRefreshRequest_Data { } type TokenRefreshResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Token *v1.Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` unknownFields protoimpl.UnknownFields - - Token *v1.Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + sizeCache protoimpl.SizeCache } func (x *TokenRefreshResponse) Reset() { @@ -115,11 +114,10 @@ func (x *TokenRefreshResponse) GetToken() *v1.Token { } type LoginRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *LoginRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *LoginRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *LoginRequest) Reset() { @@ -160,11 +158,10 @@ func (x *LoginRequest) GetData() *LoginRequest_Data { } type LoginResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Token *v1.Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` unknownFields protoimpl.UnknownFields - - Token *v1.Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + sizeCache protoimpl.SizeCache } func (x *LoginResponse) Reset() { @@ -205,11 +202,10 @@ func (x *LoginResponse) GetToken() *v1.Token { } type CurrentUserRequestQuery struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,proto3" json:"user_id,omitempty"` unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=user_id,proto3" json:"user_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CurrentUserRequestQuery) Reset() { @@ -250,11 +246,10 @@ func (x *CurrentUserRequestQuery) GetUserId() int64 { } type CurrentUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *CurrentUserRequestQuery `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *CurrentUserRequestQuery `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CurrentUserRequest) Reset() { @@ -295,12 +290,11 @@ func (x *CurrentUserRequest) GetData() *CurrentUserRequestQuery { } type CurrentUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CurrentUserResponse) Reset() { @@ -348,13 +342,12 @@ func (x *CurrentUserResponse) GetData() *anypb.Any { } type CaptchaIdRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The timestamp of the request prevent caching of the same result - Ts string `protobuf:"bytes,1,opt,name=ts,proto3" json:"ts,omitempty"` - Reload bool `protobuf:"varint,2,opt,name=reload,proto3" json:"reload,omitempty"` + Ts string `protobuf:"bytes,1,opt,name=ts,proto3" json:"ts,omitempty"` + Reload bool `protobuf:"varint,2,opt,name=reload,proto3" json:"reload,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CaptchaIdRequest) Reset() { @@ -402,11 +395,10 @@ func (x *CaptchaIdRequest) GetReload() bool { } type CaptchaIdResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CaptchaIdResponse) Reset() { @@ -448,13 +440,12 @@ func (x *CaptchaIdResponse) GetData() string { // The request message containing the user's name. type CaptchaImageRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Reload string `protobuf:"bytes,2,opt,name=reload,proto3" json:"reload,omitempty"` + Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Reload string `protobuf:"bytes,2,opt,name=reload,proto3" json:"reload,omitempty"` - Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CaptchaImageRequest) Reset() { @@ -509,12 +500,11 @@ func (x *CaptchaImageRequest) GetData() *anypb.Any { } type CaptchaData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` + CaptchaImg string `protobuf:"bytes,2,opt,name=captcha_img,json=captchaImg,proto3" json:"captcha_img,omitempty"` unknownFields protoimpl.UnknownFields - - CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` - CaptchaImg string `protobuf:"bytes,2,opt,name=captcha_img,json=captchaImg,proto3" json:"captcha_img,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CaptchaData) Reset() { @@ -563,12 +553,11 @@ func (x *CaptchaData) GetCaptchaImg() string { // The response message containing the greetings type CaptchaImageResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Image []byte `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"` unknownFields protoimpl.UnknownFields - - Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Image []byte `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CaptchaImageResponse) Reset() { @@ -617,13 +606,12 @@ func (x *CaptchaImageResponse) GetImage() []byte { // The request message containing the user's name. type CaptchaAudioRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Reload string `protobuf:"bytes,2,opt,name=reload,proto3" json:"reload,omitempty"` + Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Reload string `protobuf:"bytes,2,opt,name=reload,proto3" json:"reload,omitempty"` - Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CaptchaAudioRequest) Reset() { @@ -679,12 +667,11 @@ func (x *CaptchaAudioRequest) GetData() *anypb.Any { // The response message containing the greetings type CaptchaAudioResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Audio []byte `protobuf:"bytes,2,opt,name=audio,proto3" json:"audio,omitempty"` unknownFields protoimpl.UnknownFields - - Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Audio []byte `protobuf:"bytes,2,opt,name=audio,proto3" json:"audio,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CaptchaAudioResponse) Reset() { @@ -732,10 +719,7 @@ func (x *CaptchaAudioResponse) GetAudio() []byte { } type CaptchaRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The id of the captcha Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // The type of the captcha @@ -743,7 +727,9 @@ type CaptchaRequest struct { // The reload is used to reload the captcha Reload bool `protobuf:"varint,3,opt,name=reload,proto3" json:"reload,omitempty"` // The timestamp of the request prevent caching of the same result - Ts string `protobuf:"bytes,4,opt,name=ts,proto3" json:"ts,omitempty"` + Ts string `protobuf:"bytes,4,opt,name=ts,proto3" json:"ts,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CaptchaRequest) Reset() { @@ -805,13 +791,12 @@ func (x *CaptchaRequest) GetTs() string { } type CaptchaResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CaptchaResponse) Reset() { @@ -866,11 +851,10 @@ func (x *CaptchaResponse) GetData() string { } type RegisterRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *RegisterRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *RegisterRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *RegisterRequest) Reset() { @@ -911,12 +895,11 @@ func (x *RegisterRequest) GetData() *RegisterRequest_Data { } type RegisterResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data *RegisterResponse_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data *RegisterResponse_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *RegisterResponse) Reset() { @@ -964,11 +947,10 @@ func (x *RegisterResponse) GetData() *RegisterResponse_Data { } type LogoutRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *LogoutRequest) Reset() { @@ -1009,11 +991,10 @@ func (x *LogoutRequest) GetData() *anypb.Any { } type LogoutResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + sizeCache protoimpl.SizeCache } func (x *LogoutResponse) Reset() { @@ -1054,11 +1035,10 @@ func (x *LogoutResponse) GetSuccess() bool { } type TokenRefreshRequest_Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` unknownFields protoimpl.UnknownFields - - RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` + sizeCache protoimpl.SizeCache } func (x *TokenRefreshRequest_Data) Reset() { @@ -1099,14 +1079,13 @@ func (x *TokenRefreshRequest_Data) GetRefreshToken() string { } type LoginRequest_Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` + CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` unknownFields protoimpl.UnknownFields - - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` - CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` - CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` + sizeCache protoimpl.SizeCache } func (x *LoginRequest_Data) Reset() { @@ -1168,14 +1147,13 @@ func (x *LoginRequest_Data) GetCaptchaCode() string { } type RegisterRequest_Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` + CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` unknownFields protoimpl.UnknownFields - - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` - CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` - CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` + sizeCache protoimpl.SizeCache } func (x *RegisterRequest_Data) Reset() { @@ -1237,11 +1215,10 @@ func (x *RegisterRequest_Data) GetCaptchaCode() string { } type RegisterResponse_Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Redirect string `protobuf:"bytes,1,opt,name=redirect,proto3" json:"redirect,omitempty"` unknownFields protoimpl.UnknownFields - - Redirect string `protobuf:"bytes,1,opt,name=redirect,proto3" json:"redirect,omitempty"` + sizeCache protoimpl.SizeCache } func (x *RegisterResponse_Data) Reset() { @@ -1283,241 +1260,110 @@ func (x *RegisterResponse_Data) GetRedirect() string { var File_system_login_proto protoreflect.FileDescriptor -var file_system_login_proto_rawDesc = []byte{ - 0x0a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x1c, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, - 0x6a, 0x77, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x92, 0x01, 0x0a, 0x13, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x44, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, - 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x44, - 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x35, 0x0a, 0x04, 0x44, 0x61, 0x74, - 0x61, 0x12, 0x2d, 0x0a, 0x0d, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, - 0x01, 0x52, 0x0d, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x22, 0x44, 0x0a, 0x14, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, - 0x74, 0x79, 0x2e, 0x6a, 0x77, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, - 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0xf6, 0x01, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, - 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x44, 0x61, 0x74, 0x61, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0xa6, 0x01, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, - 0x23, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, - 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x27, 0x0a, 0x0a, 0x63, 0x61, 0x70, - 0x74, 0x63, 0x68, 0x61, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, - 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x5f, - 0x69, 0x64, 0x12, 0x2b, 0x0a, 0x0c, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x5f, 0x63, 0x6f, - 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, - 0x01, 0x52, 0x0c, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x22, - 0x3d, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x2c, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x16, 0x2e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2e, 0x6a, 0x77, 0x74, 0x2e, 0x76, - 0x31, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x33, - 0x0a, 0x17, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x22, 0x59, 0x0a, 0x12, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x59, - 0x0a, 0x13, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, - 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x0a, 0x10, 0x43, 0x61, 0x70, - 0x74, 0x63, 0x68, 0x61, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, - 0x02, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x74, 0x73, 0x12, 0x16, 0x0a, - 0x06, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, - 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x27, 0x0a, 0x11, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, - 0x49, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x67, - 0x0a, 0x13, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x28, 0x0a, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, - 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x4d, 0x0a, 0x0b, 0x43, 0x61, 0x70, 0x74, 0x63, - 0x68, 0x61, 0x44, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, - 0x61, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x61, 0x70, 0x74, - 0x63, 0x68, 0x61, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, - 0x5f, 0x69, 0x6d, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x61, 0x70, 0x74, - 0x63, 0x68, 0x61, 0x49, 0x6d, 0x67, 0x22, 0xbd, 0x01, 0x0a, 0x14, 0x43, 0x61, 0x70, 0x74, 0x63, - 0x68, 0x61, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x53, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x39, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, - 0x61, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x67, 0x0a, 0x13, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, - 0x61, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, - 0x06, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, - 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, - 0xbd, 0x01, 0x0a, 0x14, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x41, 0x75, 0x64, 0x69, 0x6f, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x39, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x14, 0x0a, - 0x05, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x61, 0x75, - 0x64, 0x69, 0x6f, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0x5c, 0x0a, 0x0e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, 0x65, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x0e, 0x0a, - 0x02, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x74, 0x73, 0x22, 0x49, 0x0a, - 0x0f, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0xfc, 0x01, 0x0a, 0x0f, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0xa6, - 0x01, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x23, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, - 0x10, 0x01, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x08, - 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, - 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, - 0x64, 0x12, 0x27, 0x0a, 0x0a, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x5f, 0x69, 0x64, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0a, - 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x5f, 0x69, 0x64, 0x12, 0x2b, 0x0a, 0x0c, 0x63, 0x61, - 0x70, 0x74, 0x63, 0x68, 0x61, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x07, 0xfa, 0x42, 0x04, 0x72, 0x02, 0x10, 0x01, 0x52, 0x0c, 0x63, 0x61, 0x70, 0x74, 0x63, - 0x68, 0x61, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x22, 0x93, 0x01, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, - 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, - 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x41, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x44, - 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x22, 0x0a, 0x04, 0x44, 0x61, 0x74, - 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x22, 0x39, 0x0a, - 0x0d, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, - 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, - 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2a, 0x0a, 0x0e, 0x4c, 0x6f, 0x67, 0x6f, - 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, - 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, - 0x63, 0x65, 0x73, 0x73, 0x32, 0xe2, 0x07, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6f, 0x0a, 0x07, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, - 0x12, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, - 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, 0x62, 0x01, 0x2a, 0x12, 0x08, 0x2f, 0x63, - 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x12, 0x75, 0x0a, 0x09, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, - 0x61, 0x49, 0x64, 0x12, 0x28, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x61, 0x70, - 0x74, 0x63, 0x68, 0x61, 0x49, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x49, 0x64, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x13, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0d, - 0x12, 0x0b, 0x2f, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x2f, 0x69, 0x64, 0x12, 0x84, 0x01, - 0x0a, 0x0c, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, 0x2b, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x49, - 0x6d, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x49, 0x6d, 0x61, 0x67, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x13, 0x62, 0x01, 0x2a, 0x12, 0x0e, 0x2f, 0x63, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x2f, 0x69, - 0x6d, 0x61, 0x67, 0x65, 0x12, 0x84, 0x01, 0x0a, 0x0c, 0x43, 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, - 0x41, 0x75, 0x64, 0x69, 0x6f, 0x12, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, - 0x61, 0x70, 0x74, 0x63, 0x68, 0x61, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x61, 0x70, 0x74, - 0x63, 0x68, 0x61, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x62, 0x01, 0x2a, 0x12, 0x0e, 0x2f, 0x63, 0x61, - 0x70, 0x74, 0x63, 0x68, 0x61, 0x2f, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x12, 0x6a, 0x0a, 0x05, 0x4c, - 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x24, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x6f, - 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x3a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, - 0x06, 0x2f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x6e, 0x0a, 0x06, 0x4c, 0x6f, 0x67, 0x6f, 0x75, - 0x74, 0x12, 0x25, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x6f, 0x67, 0x6f, 0x75, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x15, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0f, 0x3a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x07, - 0x2f, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, 0x76, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, - 0x74, 0x65, 0x72, 0x12, 0x27, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x3a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x22, 0x09, 0x2f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, - 0x87, 0x01, 0x0a, 0x0c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, - 0x12, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, - 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x66, 0x72, - 0x65, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x16, 0x3a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x0e, 0x2f, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x2f, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x42, 0xbf, 0x01, 0x0a, 0x1a, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x42, 0x0a, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0xa2, 0x02, 0x04, 0x41, 0x56, 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, - 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0xca, 0x02, 0x16, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, - 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x19, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, -} +const file_system_login_proto_rawDesc = "" + + "\n" + + "\x12system/login.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bsecurity/jwt/v1/token.proto\x1a\x17validate/validate.proto\"\x92\x01\n" + + "\x13TokenRefreshRequest\x12D\n" + + "\x04data\x18\x02 \x01(\v20.api.v1.services.system.TokenRefreshRequest.DataR\x04data\x1a5\n" + + "\x04Data\x12-\n" + + "\rrefresh_token\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\rrefresh_token\"D\n" + + "\x14TokenRefreshResponse\x12,\n" + + "\x05token\x18\x01 \x01(\v2\x16.security.jwt.v1.TokenR\x05token\"\xf6\x01\n" + + "\fLoginRequest\x12=\n" + + "\x04data\x18\x02 \x01(\v2).api.v1.services.system.LoginRequest.DataR\x04data\x1a\xa6\x01\n" + + "\x04Data\x12#\n" + + "\busername\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12#\n" + + "\bpassword\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\bpassword\x12'\n" + + "\n" + + "captcha_id\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\n" + + "captcha_id\x12+\n" + + "\fcaptcha_code\x18\x04 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\fcaptcha_code\"=\n" + + "\rLoginResponse\x12,\n" + + "\x05token\x18\x01 \x01(\v2\x16.security.jwt.v1.TokenR\x05token\"3\n" + + "\x17CurrentUserRequestQuery\x12\x18\n" + + "\auser_id\x18\x01 \x01(\x03R\auser_id\"Y\n" + + "\x12CurrentUserRequest\x12C\n" + + "\x04data\x18\x01 \x01(\v2/.api.v1.services.system.CurrentUserRequestQueryR\x04data\"Y\n" + + "\x13CurrentUserResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\":\n" + + "\x10CaptchaIdRequest\x12\x0e\n" + + "\x02ts\x18\x01 \x01(\tR\x02ts\x12\x16\n" + + "\x06reload\x18\x02 \x01(\bR\x06reload\"'\n" + + "\x11CaptchaIdResponse\x12\x12\n" + + "\x04data\x18\x01 \x01(\tR\x04data\"g\n" + + "\x13CaptchaImageRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" + + "\x06reload\x18\x02 \x01(\tR\x06reload\x12(\n" + + "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\"M\n" + + "\vCaptchaData\x12\x1d\n" + + "\n" + + "captcha_id\x18\x01 \x01(\tR\tcaptchaId\x12\x1f\n" + + "\vcaptcha_img\x18\x02 \x01(\tR\n" + + "captchaImg\"\xbd\x01\n" + + "\x14CaptchaImageResponse\x12S\n" + + "\aheaders\x18\x01 \x03(\v29.api.v1.services.system.CaptchaImageResponse.HeadersEntryR\aheaders\x12\x14\n" + + "\x05image\x18\x02 \x01(\fR\x05image\x1a:\n" + + "\fHeadersEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"g\n" + + "\x13CaptchaAudioRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" + + "\x06reload\x18\x02 \x01(\tR\x06reload\x12(\n" + + "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\xbd\x01\n" + + "\x14CaptchaAudioResponse\x12S\n" + + "\aheaders\x18\x01 \x03(\v29.api.v1.services.system.CaptchaAudioResponse.HeadersEntryR\aheaders\x12\x14\n" + + "\x05audio\x18\x02 \x01(\fR\x05audio\x1a:\n" + + "\fHeadersEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\\\n" + + "\x0eCaptchaRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04type\x18\x02 \x01(\tR\x04type\x12\x16\n" + + "\x06reload\x18\x03 \x01(\bR\x06reload\x12\x0e\n" + + "\x02ts\x18\x04 \x01(\tR\x02ts\"I\n" + + "\x0fCaptchaResponse\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04type\x18\x02 \x01(\tR\x04type\x12\x12\n" + + "\x04data\x18\x03 \x01(\tR\x04data\"\xfc\x01\n" + + "\x0fRegisterRequest\x12@\n" + + "\x04data\x18\x02 \x01(\v2,.api.v1.services.system.RegisterRequest.DataR\x04data\x1a\xa6\x01\n" + + "\x04Data\x12#\n" + + "\busername\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12#\n" + + "\bpassword\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\bpassword\x12'\n" + + "\n" + + "captcha_id\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\n" + + "captcha_id\x12+\n" + + "\fcaptcha_code\x18\x04 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\fcaptcha_code\"\x93\x01\n" + + "\x10RegisterResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12A\n" + + "\x04data\x18\x02 \x01(\v2-.api.v1.services.system.RegisterResponse.DataR\x04data\x1a\"\n" + + "\x04Data\x12\x1a\n" + + "\bredirect\x18\x01 \x01(\tR\bredirect\"9\n" + + "\rLogoutRequest\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"*\n" + + "\x0eLogoutResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess2\xe2\a\n" + + "\fLoginService\x12o\n" + + "\aCaptcha\x12&.api.v1.services.system.CaptchaRequest\x1a'.api.v1.services.system.CaptchaResponse\"\x13\x82\xd3\xe4\x93\x02\rb\x01*\x12\b/captcha\x12u\n" + + "\tCaptchaId\x12(.api.v1.services.system.CaptchaIdRequest\x1a).api.v1.services.system.CaptchaIdResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/captcha/id\x12\x84\x01\n" + + "\fCaptchaImage\x12+.api.v1.services.system.CaptchaImageRequest\x1a,.api.v1.services.system.CaptchaImageResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/image\x12\x84\x01\n" + + "\fCaptchaAudio\x12+.api.v1.services.system.CaptchaAudioRequest\x1a,.api.v1.services.system.CaptchaAudioResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/audio\x12j\n" + + "\x05Login\x12$.api.v1.services.system.LoginRequest\x1a%.api.v1.services.system.LoginResponse\"\x14\x82\xd3\xe4\x93\x02\x0e:\x04data\"\x06/login\x12n\n" + + "\x06Logout\x12%.api.v1.services.system.LogoutRequest\x1a&.api.v1.services.system.LogoutResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/logout\x12v\n" + + "\bRegister\x12'.api.v1.services.system.RegisterRequest\x1a(.api.v1.services.system.RegisterResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x04data\"\t/register\x12\x87\x01\n" + + "\fTokenRefresh\x12+.api.v1.services.system.TokenRefreshRequest\x1a,.api.v1.services.system.TokenRefreshResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04data\"\x0e/token/refreshB\xbf\x01\n" + + "\x1acom.api.v1.services.systemB\n" + + "LoginProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_login_proto_rawDescOnce sync.Once - file_system_login_proto_rawDescData = file_system_login_proto_rawDesc + file_system_login_proto_rawDescData []byte ) func file_system_login_proto_rawDescGZIP() []byte { file_system_login_proto_rawDescOnce.Do(func() { - file_system_login_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_login_proto_rawDescData) + file_system_login_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_login_proto_rawDesc), len(file_system_login_proto_rawDesc))) }) return file_system_login_proto_rawDescData } @@ -1599,7 +1445,7 @@ func file_system_login_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_login_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_login_proto_rawDesc), len(file_system_login_proto_rawDesc)), NumEnums: 0, NumMessages: 26, NumExtensions: 0, @@ -1610,7 +1456,6 @@ func file_system_login_proto_init() { MessageInfos: file_system_login_proto_msgTypes, }.Build() File_system_login_proto = out.File - file_system_login_proto_rawDesc = nil file_system_login_proto_goTypes = nil file_system_login_proto_depIdxs = nil } diff --git a/api/v1/services/system/login.pb.validate.go b/api/v1/services/system/login.pb.validate.go index c6f95426..1352f700 100644 --- a/api/v1/services/system/login.pb.validate.go +++ b/api/v1/services/system/login.pb.validate.go @@ -100,7 +100,7 @@ type TokenRefreshRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m TokenRefreshRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -231,7 +231,7 @@ type TokenRefreshResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m TokenRefreshResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -361,7 +361,7 @@ type LoginRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m LoginRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -490,7 +490,7 @@ type LoginResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m LoginResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -592,7 +592,7 @@ type CurrentUserRequestQueryMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CurrentUserRequestQueryMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -723,7 +723,7 @@ type CurrentUserRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CurrentUserRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -856,7 +856,7 @@ type CurrentUserResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CurrentUserResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -962,7 +962,7 @@ type CaptchaIdRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CaptchaIdRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1064,7 +1064,7 @@ type CaptchaIdResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CaptchaIdResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1199,7 +1199,7 @@ type CaptchaImageRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CaptchaImageRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1304,7 +1304,7 @@ type CaptchaDataMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CaptchaDataMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1408,7 +1408,7 @@ type CaptchaImageResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CaptchaImageResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1543,7 +1543,7 @@ type CaptchaAudioRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CaptchaAudioRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1649,7 +1649,7 @@ type CaptchaAudioResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CaptchaAudioResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1759,7 +1759,7 @@ type CaptchaRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CaptchaRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1865,7 +1865,7 @@ type CaptchaResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CaptchaResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1994,7 +1994,7 @@ type RegisterRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RegisterRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2125,7 +2125,7 @@ type RegisterResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RegisterResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2254,7 +2254,7 @@ type LogoutRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m LogoutRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2356,7 +2356,7 @@ type LogoutResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m LogoutResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2467,7 +2467,7 @@ type TokenRefreshRequest_DataMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m TokenRefreshRequest_DataMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2613,7 +2613,7 @@ type LoginRequest_DataMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m LoginRequest_DataMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2759,7 +2759,7 @@ type RegisterRequest_DataMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RegisterRequest_DataMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2863,7 +2863,7 @@ type RegisterResponse_DataMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RegisterResponse_DataMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/login_http.pb.go b/api/v1/services/system/login_http.pb.go index ee136975..17da8f95 100644 --- a/api/v1/services/system/login_http.pb.go +++ b/api/v1/services/system/login_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/login.proto diff --git a/api/v1/services/system/menu.pb.go b/api/v1/services/system/menu.pb.go index deb3bff5..a27bdba8 100644 --- a/api/v1/services/system/menu.pb.go +++ b/api/v1/services/system/menu.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/menu.proto @@ -14,6 +14,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -25,10 +26,7 @@ const ( // ListMenusRequest is the request for the MenuService.ListMenus method. type ListMenusRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id, for example, "shelves/shelf1". Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The current page number. @@ -40,7 +38,9 @@ type ListMenusRequest struct { // The no_paging is used to disable pagination. NoPaging bool `protobuf:"varint,5,opt,name=no_paging,json=noPaging,proto3" json:"no_paging,omitempty"` // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,json=onlyCount,proto3" json:"only_count,omitempty"` + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,json=onlyCount,proto3" json:"only_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListMenusRequest) Reset() { @@ -117,10 +117,7 @@ func (x *ListMenusRequest) GetOnlyCount() bool { // ListMenusResponse is the response for the MenuService.ListMenus method. type ListMenusResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus @@ -134,7 +131,9 @@ type ListMenusResponse struct { NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` // Additional information about this response. // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListMenusResponse) Reset() { @@ -211,13 +210,12 @@ func (x *ListMenusResponse) GetExtra() *anypb.Any { // GetMenuRequest is the request for the MenuService.GetMenu method. type GetMenuRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The field will contain id of the resource requested, for example: // "shelves/shelf1/menus/menu2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetMenuRequest) Reset() { @@ -259,12 +257,11 @@ func (x *GetMenuRequest) GetId() int64 { // GetMenuResponse is the response for the MenuService.GetMenu method. type GetMenuResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The field id should match the Noun in the method id. - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetMenuResponse) Reset() { @@ -306,17 +303,16 @@ func (x *GetMenuResponse) GetMenu() *Menu { // CreateMenuRequest is the request for the MenuService.CreateMenu method. type CreateMenuRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id where the menu is to be created. Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` // The menu id to use for this menu. MenuId string `protobuf:"bytes,3,opt,name=menu_id,json=menuId,proto3" json:"menu_id,omitempty"` // The menu resource to create. // The field id should match the Noun in the method id. - Menu *Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CreateMenuRequest) Reset() { @@ -372,11 +368,10 @@ func (x *CreateMenuRequest) GetMenu() *Menu { // CreateMenuResponse is the response for the MenuService.CreateMenu method. type CreateMenuResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` unknownFields protoimpl.UnknownFields - - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateMenuResponse) Reset() { @@ -418,12 +413,11 @@ func (x *CreateMenuResponse) GetMenu() *Menu { // UpdateMenuRequest is the request for the MenuService.UpdateMenu method. type UpdateMenuRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The menu resource which replaces the resource on the server. - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdateMenuRequest) Reset() { @@ -465,11 +459,10 @@ func (x *UpdateMenuRequest) GetMenu() *Menu { // UpdateMenuResponse is the response for the MenuService.UpdateMenu method. type UpdateMenuResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` unknownFields protoimpl.UnknownFields - - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdateMenuResponse) Reset() { @@ -511,13 +504,12 @@ func (x *UpdateMenuResponse) GetMenu() *Menu { // DeleteMenuRequest is the request for the MenuService.DeleteMenu method. type DeleteMenuRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The resource id of the menu to be deleted, for example: // "shelves/shelf1/menus/menu2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *DeleteMenuRequest) Reset() { @@ -559,12 +551,11 @@ func (x *DeleteMenuRequest) GetId() int64 { // DeleteMenuResponse is the response for the MenuService.DeleteMenu method. type DeleteMenuResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // or Menu menu = 1; or google.protobuf.Empty empty = 1; - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *DeleteMenuResponse) Reset() { @@ -606,141 +597,67 @@ func (x *DeleteMenuResponse) GetEmpty() *emptypb.Empty { var File_system_menu_proto protoreflect.FileDescriptor -var file_system_menu_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x6d, 0x65, 0x6e, 0x75, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb4, 0x01, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, - 0x6e, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, - 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, - 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x08, 0x6e, 0x6f, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x12, 0x1d, 0x0a, - 0x0a, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x09, 0x6f, 0x6e, 0x6c, 0x79, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x84, 0x02, 0x0a, - 0x11, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x6e, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, - 0x7a, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, - 0x05, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x28, - 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2f, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, - 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x48, 0x00, 0x52, - 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x65, 0x78, - 0x74, 0x72, 0x61, 0x22, 0x20, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x43, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4d, 0x65, 0x6e, 0x75, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x76, 0x0a, 0x11, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x65, 0x6e, 0x75, 0x5f, - 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x6e, 0x75, 0x49, 0x64, - 0x12, 0x30, 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, - 0x6e, 0x75, 0x22, 0x46, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x45, 0x0a, 0x11, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x30, 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, - 0x75, 0x22, 0x46, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, - 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x23, 0x0a, 0x11, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x42, - 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x05, 0x65, 0x6d, 0x70, - 0x74, 0x79, 0x32, 0xff, 0x04, 0x0a, 0x0b, 0x4d, 0x65, 0x6e, 0x75, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x74, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x6e, 0x75, 0x73, 0x12, - 0x28, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x6e, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x6e, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x12, 0x0a, 0x2f, 0x73, - 0x79, 0x73, 0x2f, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x12, 0x73, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x4d, - 0x65, 0x6e, 0x75, 0x12, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, - 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, 0x73, - 0x79, 0x73, 0x2f, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x7d, 0x0a, - 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x12, 0x29, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x04, 0x6d, 0x65, 0x6e, 0x75, - 0x22, 0x0a, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x12, 0x87, 0x01, 0x0a, - 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x12, 0x29, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x3a, 0x04, 0x6d, 0x65, 0x6e, 0x75, - 0x1a, 0x14, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x2f, 0x7b, 0x6d, 0x65, - 0x6e, 0x75, 0x2e, 0x69, 0x64, 0x7d, 0x12, 0x7c, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x4d, 0x65, 0x6e, 0x75, 0x12, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4d, - 0x65, 0x6e, 0x75, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x11, 0x2a, 0x0f, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x2f, - 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xbe, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x42, 0x09, 0x4d, 0x65, 0x6e, 0x75, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, 0x41, 0x56, - 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, 0x41, 0x70, - 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, 0x69, 0x3a, - 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x53, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_system_menu_proto_rawDesc = "" + + "\n" + + "\x11system/menu.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xb4\x01\n" + + "\x10ListMenusRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1b\n" + + "\tpage_size\x18\x03 \x01(\x05R\bpageSize\x12\x1d\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\tpageToken\x12\x1b\n" + + "\tno_paging\x18\x05 \x01(\bR\bnoPaging\x12\x1d\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\tonlyCount\"\x84\x02\n" + + "\x11ListMenusResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x122\n" + + "\x05menus\x18\x02 \x03(\v2\x1c.api.v1.services.system.MenuR\x05menus\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\" \n" + + "\x0eGetMenuRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"C\n" + + "\x0fGetMenuResponse\x120\n" + + "\x04menu\x18\x01 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"v\n" + + "\x11CreateMenuRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x17\n" + + "\amenu_id\x18\x03 \x01(\tR\x06menuId\x120\n" + + "\x04menu\x18\x02 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"F\n" + + "\x12CreateMenuResponse\x120\n" + + "\x04menu\x18\x01 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"E\n" + + "\x11UpdateMenuRequest\x120\n" + + "\x04menu\x18\x01 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"F\n" + + "\x12UpdateMenuResponse\x120\n" + + "\x04menu\x18\x01 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"#\n" + + "\x11DeleteMenuRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x12DeleteMenuResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xff\x04\n" + + "\vMenuService\x12t\n" + + "\tListMenus\x12(.api.v1.services.system.ListMenusRequest\x1a).api.v1.services.system.ListMenusResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + + "/sys/menus\x12s\n" + + "\aGetMenu\x12&.api.v1.services.system.GetMenuRequest\x1a'.api.v1.services.system.GetMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/menus/{id}\x12}\n" + + "\n" + + "CreateMenu\x12).api.v1.services.system.CreateMenuRequest\x1a*.api.v1.services.system.CreateMenuResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04menu\"\n" + + "/sys/menus\x12\x87\x01\n" + + "\n" + + "UpdateMenu\x12).api.v1.services.system.UpdateMenuRequest\x1a*.api.v1.services.system.UpdateMenuResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04menu\x1a\x14/sys/menus/{menu.id}\x12|\n" + + "\n" + + "DeleteMenu\x12).api.v1.services.system.DeleteMenuRequest\x1a*.api.v1.services.system.DeleteMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/menus/{id}B\xbe\x01\n" + + "\x1acom.api.v1.services.systemB\tMenuProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_menu_proto_rawDescOnce sync.Once - file_system_menu_proto_rawDescData = file_system_menu_proto_rawDesc + file_system_menu_proto_rawDescData []byte ) func file_system_menu_proto_rawDescGZIP() []byte { file_system_menu_proto_rawDescOnce.Do(func() { - file_system_menu_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_menu_proto_rawDescData) + file_system_menu_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_menu_proto_rawDesc), len(file_system_menu_proto_rawDesc))) }) return file_system_menu_proto_rawDescData } @@ -798,7 +715,7 @@ func file_system_menu_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_menu_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_menu_proto_rawDesc), len(file_system_menu_proto_rawDesc)), NumEnums: 0, NumMessages: 10, NumExtensions: 0, @@ -809,7 +726,6 @@ func file_system_menu_proto_init() { MessageInfos: file_system_menu_proto_msgTypes, }.Build() File_system_menu_proto = out.File - file_system_menu_proto_rawDesc = nil file_system_menu_proto_goTypes = nil file_system_menu_proto_depIdxs = nil } diff --git a/api/v1/services/system/menu.pb.validate.go b/api/v1/services/system/menu.pb.validate.go index 7b548eeb..c39c7c0b 100644 --- a/api/v1/services/system/menu.pb.validate.go +++ b/api/v1/services/system/menu.pb.validate.go @@ -83,7 +83,7 @@ type ListMenusRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListMenusRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -258,7 +258,7 @@ type ListMenusResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListMenusResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -362,7 +362,7 @@ type GetMenuRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetMenuRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -491,7 +491,7 @@ type GetMenuResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetMenuResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -624,7 +624,7 @@ type CreateMenuRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateMenuRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -755,7 +755,7 @@ type CreateMenuResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateMenuResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -886,7 +886,7 @@ type UpdateMenuRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateMenuRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1017,7 +1017,7 @@ type UpdateMenuResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateMenuResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1121,7 +1121,7 @@ type DeleteMenuRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeleteMenuRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1252,7 +1252,7 @@ type DeleteMenuResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeleteMenuResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/menu_http.pb.go b/api/v1/services/system/menu_http.pb.go index cb8a3213..30e4ec1c 100644 --- a/api/v1/services/system/menu_http.pb.go +++ b/api/v1/services/system/menu_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/menu.proto diff --git a/api/v1/services/system/permission.pb.go b/api/v1/services/system/permission.pb.go index f96f0799..1baf3503 100644 --- a/api/v1/services/system/permission.pb.go +++ b/api/v1/services/system/permission.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/permission.proto @@ -14,6 +14,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -24,10 +25,7 @@ const ( ) type ListPermissionsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id, for example, "shelves/shelf1". Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The current page number. @@ -41,7 +39,9 @@ type ListPermissionsRequest struct { // The only_count is the query parameter for set only to query the total number OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` // The data_scopes is used to query the permission by data scopes. - DataScopes []string `protobuf:"bytes,7,rep,name=data_scopes,proto3" json:"data_scopes,omitempty"` + DataScopes []string `protobuf:"bytes,7,rep,name=data_scopes,proto3" json:"data_scopes,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListPermissionsRequest) Reset() { @@ -124,10 +124,7 @@ func (x *ListPermissionsRequest) GetDataScopes() []string { } type ListPermissionsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus @@ -141,7 +138,9 @@ type ListPermissionsResponse struct { NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` // Additional information about this response. // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListPermissionsResponse) Reset() { @@ -217,13 +216,12 @@ func (x *ListPermissionsResponse) GetExtra() *anypb.Any { } type GetPermissionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The field will contain id of the resource requested, for example: // "shelves/shelf1/permissions/permission2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetPermissionRequest) Reset() { @@ -264,11 +262,10 @@ func (x *GetPermissionRequest) GetId() int64 { } type GetPermissionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` unknownFields protoimpl.UnknownFields - - Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetPermissionResponse) Reset() { @@ -309,17 +306,16 @@ func (x *GetPermissionResponse) GetPermission() *Permission { } type CreatePermissionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id where the permission is to be created. Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` // The permission id to use for this permission. PermissionId string `protobuf:"bytes,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` // The permission resource to create. // The field id should match the Noun in the method id. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CreatePermissionRequest) Reset() { @@ -374,11 +370,10 @@ func (x *CreatePermissionRequest) GetPermission() *Permission { } type CreatePermissionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` unknownFields protoimpl.UnknownFields - - Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreatePermissionResponse) Reset() { @@ -419,14 +414,13 @@ func (x *CreatePermissionResponse) GetPermission() *Permission { } type UpdatePermissionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The resource name of the permission to update. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The permission resource which replaces the resource on the server. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdatePermissionRequest) Reset() { @@ -474,11 +468,10 @@ func (x *UpdatePermissionRequest) GetPermission() *Permission { } type UpdatePermissionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` unknownFields protoimpl.UnknownFields - - Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdatePermissionResponse) Reset() { @@ -519,13 +512,12 @@ func (x *UpdatePermissionResponse) GetPermission() *Permission { } type DeletePermissionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The resource id of the permission to be deleted, for example: // "shelves/shelf1/permissions/permission2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *DeletePermissionRequest) Reset() { @@ -566,11 +558,10 @@ func (x *DeletePermissionRequest) GetId() int64 { } type DeletePermissionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` unknownFields protoimpl.UnknownFields - - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DeletePermissionResponse) Reset() { @@ -612,166 +603,78 @@ func (x *DeletePermissionResponse) GetEmpty() *emptypb.Empty { var File_system_permission_proto protoreflect.FileDescriptor -var file_system_permission_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, - 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, - 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, - 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, - 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe0, 0x01, 0x0a, 0x16, - 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1e, - 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1c, - 0x0a, 0x09, 0x6e, 0x6f, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x09, 0x6e, 0x6f, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a, - 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x0a, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x20, 0x0a, 0x0b, - 0x64, 0x61, 0x74, 0x61, 0x5f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x0b, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x73, 0x22, 0x9c, - 0x02, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, - 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, - 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x70, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, - 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, - 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x12, 0x2f, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x48, 0x00, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, - 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x65, 0x78, 0x74, 0x72, 0x61, 0x22, 0x26, 0x0a, - 0x14, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x5b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, - 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x22, 0x9b, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, - 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, - 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x12, 0x42, 0x0a, 0x0a, - 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x22, 0x5e, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x0a, - 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x22, 0x6d, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x42, 0x0a, 0x0a, 0x70, - 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, - 0x5e, 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x0a, 0x70, - 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, - 0x29, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x48, 0x0a, 0x18, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x05, 0x65, - 0x6d, 0x70, 0x74, 0x79, 0x32, 0x93, 0x06, 0x0a, 0x11, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x8c, 0x01, 0x0a, 0x0f, 0x4c, - 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2e, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x8b, 0x01, 0x0a, 0x0d, 0x47, 0x65, - 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x17, - 0x12, 0x15, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x9b, 0x01, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x24, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1e, 0x3a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x22, 0x10, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0xab, 0x01, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x34, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x2e, 0x3a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x1a, 0x20, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x73, 0x2f, 0x7b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, - 0x69, 0x64, 0x7d, 0x12, 0x94, 0x01, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x17, 0x2a, 0x15, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xc4, 0x01, 0x0a, 0x1a, 0x63, - 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x42, 0x0f, 0x50, 0x65, 0x72, 0x6d, 0x69, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x19, 0x76, 0x31, - 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, 0x41, 0x56, 0x53, 0x53, 0xaa, 0x02, - 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, - 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x3a, - 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_system_permission_proto_rawDesc = "" + + "\n" + + "\x17system/permission.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xe0\x01\n" + + "\x16ListPermissionsRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12 \n" + + "\vdata_scopes\x18\a \x03(\tR\vdata_scopes\"\x9c\x02\n" + + "\x17ListPermissionsResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x12D\n" + + "\vpermissions\x18\x02 \x03(\v2\".api.v1.services.system.PermissionR\vpermissions\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"&\n" + + "\x14GetPermissionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"[\n" + + "\x15GetPermissionResponse\x12B\n" + + "\n" + + "permission\x18\x01 \x01(\v2\".api.v1.services.system.PermissionR\n" + + "permission\"\x9b\x01\n" + + "\x17CreatePermissionRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12$\n" + + "\rpermission_id\x18\x03 \x01(\tR\rpermission_id\x12B\n" + + "\n" + + "permission\x18\x02 \x01(\v2\".api.v1.services.system.PermissionR\n" + + "permission\"^\n" + + "\x18CreatePermissionResponse\x12B\n" + + "\n" + + "permission\x18\x01 \x01(\v2\".api.v1.services.system.PermissionR\n" + + "permission\"m\n" + + "\x17UpdatePermissionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12B\n" + + "\n" + + "permission\x18\x02 \x01(\v2\".api.v1.services.system.PermissionR\n" + + "permission\"^\n" + + "\x18UpdatePermissionResponse\x12B\n" + + "\n" + + "permission\x18\x01 \x01(\v2\".api.v1.services.system.PermissionR\n" + + "permission\")\n" + + "\x17DeletePermissionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + + "\x18DeletePermissionResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x93\x06\n" + + "\x11PermissionService\x12\x8c\x01\n" + + "\x0fListPermissions\x12..api.v1.services.system.ListPermissionsRequest\x1a/.api.v1.services.system.ListPermissionsResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/permissions\x12\x8b\x01\n" + + "\rGetPermission\x12,.api.v1.services.system.GetPermissionRequest\x1a-.api.v1.services.system.GetPermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/permissions/{id}\x12\x9b\x01\n" + + "\x10CreatePermission\x12/.api.v1.services.system.CreatePermissionRequest\x1a0.api.v1.services.system.CreatePermissionResponse\"$\x82\xd3\xe4\x93\x02\x1e:\n" + + "permission\"\x10/sys/permissions\x12\xab\x01\n" + + "\x10UpdatePermission\x12/.api.v1.services.system.UpdatePermissionRequest\x1a0.api.v1.services.system.UpdatePermissionResponse\"4\x82\xd3\xe4\x93\x02.:\n" + + "permission\x1a /sys/permissions/{permission.id}\x12\x94\x01\n" + + "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xc4\x01\n" + + "\x1acom.api.v1.services.systemB\x0fPermissionProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_permission_proto_rawDescOnce sync.Once - file_system_permission_proto_rawDescData = file_system_permission_proto_rawDesc + file_system_permission_proto_rawDescData []byte ) func file_system_permission_proto_rawDescGZIP() []byte { file_system_permission_proto_rawDescOnce.Do(func() { - file_system_permission_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_permission_proto_rawDescData) + file_system_permission_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_permission_proto_rawDesc), len(file_system_permission_proto_rawDesc))) }) return file_system_permission_proto_rawDescData } @@ -829,7 +732,7 @@ func file_system_permission_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_permission_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_permission_proto_rawDesc), len(file_system_permission_proto_rawDesc)), NumEnums: 0, NumMessages: 10, NumExtensions: 0, @@ -840,7 +743,6 @@ func file_system_permission_proto_init() { MessageInfos: file_system_permission_proto_msgTypes, }.Build() File_system_permission_proto = out.File - file_system_permission_proto_rawDesc = nil file_system_permission_proto_goTypes = nil file_system_permission_proto_depIdxs = nil } diff --git a/api/v1/services/system/permission.pb.validate.go b/api/v1/services/system/permission.pb.validate.go index 67de17bc..4e4555e6 100644 --- a/api/v1/services/system/permission.pb.validate.go +++ b/api/v1/services/system/permission.pb.validate.go @@ -83,7 +83,7 @@ type ListPermissionsRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListPermissionsRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -260,7 +260,7 @@ type ListPermissionsResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListPermissionsResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -364,7 +364,7 @@ type GetPermissionRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetPermissionRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -495,7 +495,7 @@ type GetPermissionResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetPermissionResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -630,7 +630,7 @@ type CreatePermissionRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreatePermissionRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -761,7 +761,7 @@ type CreatePermissionResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreatePermissionResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -894,7 +894,7 @@ type UpdatePermissionRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePermissionRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1025,7 +1025,7 @@ type UpdatePermissionResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePermissionResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1129,7 +1129,7 @@ type DeletePermissionRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeletePermissionRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1260,7 +1260,7 @@ type DeletePermissionResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeletePermissionResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/permission_http.pb.go b/api/v1/services/system/permission_http.pb.go index 1b0193df..338a7c76 100644 --- a/api/v1/services/system/permission_http.pb.go +++ b/api/v1/services/system/permission_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/permission.proto diff --git a/api/v1/services/system/personal.pb.go b/api/v1/services/system/personal.pb.go index 552e7488..dba93957 100644 --- a/api/v1/services/system/personal.pb.go +++ b/api/v1/services/system/personal.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/personal.proto @@ -14,6 +14,7 @@ import ( anypb "google.golang.org/protobuf/types/known/anypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -24,11 +25,10 @@ const ( ) type UpdatePersonalSettingRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdatePersonalSettingRequest) Reset() { @@ -69,9 +69,9 @@ func (x *UpdatePersonalSettingRequest) GetData() *anypb.Any { } type UpdatePersonalSettingResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdatePersonalSettingResponse) Reset() { @@ -105,11 +105,10 @@ func (*UpdatePersonalSettingResponse) Descriptor() ([]byte, []int) { } type UpdatePersonalRoleRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields - - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdatePersonalRoleRequest) Reset() { @@ -150,9 +149,9 @@ func (x *UpdatePersonalRoleRequest) GetRole() *Role { } type UpdatePersonalRoleResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdatePersonalRoleResponse) Reset() { @@ -186,10 +185,7 @@ func (*UpdatePersonalRoleResponse) Descriptor() ([]byte, []int) { } type ListPersonalResourcesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id, for example, "shelves/shelf1". Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The current page number. @@ -201,7 +197,9 @@ type ListPersonalResourcesRequest struct { // The no_paging is used to disable pagination. NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListPersonalResourcesRequest) Reset() { @@ -277,10 +275,7 @@ func (x *ListPersonalResourcesRequest) GetOnlyCount() bool { } type ListPersonalResourcesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. TotalSize int64 `protobuf:"varint,1,opt,name=total_size,json=total,proto3" json:"total_size,omitempty"` // list of resources @@ -288,6 +283,8 @@ type ListPersonalResourcesResponse struct { // Token to retrieve the next page of results, or empty if there are no // more results in the list. NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListPersonalResourcesResponse) Reset() { @@ -342,11 +339,10 @@ func (x *ListPersonalResourcesResponse) GetNextPageToken() string { } type UpdatePersonalPasswordRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdatePersonalPasswordRequest) Reset() { @@ -387,9 +383,9 @@ func (x *UpdatePersonalPasswordRequest) GetData() *anypb.Any { } type UpdatePersonalPasswordResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdatePersonalPasswordResponse) Reset() { @@ -423,11 +419,10 @@ func (*UpdatePersonalPasswordResponse) Descriptor() ([]byte, []int) { } type PersonalPasswordRestRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *PersonalPasswordRestRequest) Reset() { @@ -468,9 +463,9 @@ func (x *PersonalPasswordRestRequest) GetId() int64 { } type PersonalPasswordRestResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PersonalPasswordRestResponse) Reset() { @@ -504,11 +499,10 @@ func (*PersonalPasswordRestResponse) Descriptor() ([]byte, []int) { } type UpdatePersonalProfileRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdatePersonalProfileRequest) Reset() { @@ -549,9 +543,9 @@ func (x *UpdatePersonalProfileRequest) GetData() *anypb.Any { } type UpdatePersonalProfileResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdatePersonalProfileResponse) Reset() { @@ -585,11 +579,10 @@ func (*UpdatePersonalProfileResponse) Descriptor() ([]byte, []int) { } type PersonalLogoutRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *PersonalLogoutRequest) Reset() { @@ -630,11 +623,10 @@ func (x *PersonalLogoutRequest) GetData() *anypb.Any { } type PersonalLogoutResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + sizeCache protoimpl.SizeCache } func (x *PersonalLogoutResponse) Reset() { @@ -675,9 +667,9 @@ func (x *PersonalLogoutResponse) GetSuccess() bool { } type ListPersonalRolesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListPersonalRolesRequest) Reset() { @@ -711,11 +703,10 @@ func (*ListPersonalRolesRequest) Descriptor() ([]byte, []int) { } type ListPersonalRolesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` unknownFields protoimpl.UnknownFields - - Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ListPersonalRolesResponse) Reset() { @@ -756,9 +747,9 @@ func (x *ListPersonalRolesResponse) GetRoles() []*Role { } type GetPersonalProfileRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetPersonalProfileRequest) Reset() { @@ -792,11 +783,10 @@ func (*GetPersonalProfileRequest) Descriptor() ([]byte, []int) { } type GetPersonalProfileResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields - - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetPersonalProfileResponse) Reset() { @@ -837,11 +827,10 @@ func (x *GetPersonalProfileResponse) GetUser() *User { } type RefreshPersonalTokenRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *RefreshPersonalTokenRequest) Reset() { @@ -882,11 +871,10 @@ func (x *RefreshPersonalTokenRequest) GetData() *anypb.Any { } type RefreshPersonalTokenResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` unknownFields protoimpl.UnknownFields - - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + sizeCache protoimpl.SizeCache } func (x *RefreshPersonalTokenResponse) Reset() { @@ -928,208 +916,74 @@ func (x *RefreshPersonalTokenResponse) GetToken() string { var File_system_personal_proto protoreflect.FileDescriptor -var file_system_personal_proto_rawDesc = []byte{ - 0x0a, 0x15, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, - 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, - 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, - 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x76, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x48, 0x0a, 0x1c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, - 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, - 0x1f, 0x0a, 0x1d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, - 0x6c, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x4d, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, - 0x61, 0x6c, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x30, 0x0a, - 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, - 0x1c, 0x0a, 0x1a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, - 0x6c, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xc4, 0x01, - 0x0a, 0x1c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, - 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, - 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x67, - 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, - 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x6f, 0x5f, 0x70, 0x61, 0x67, - 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6e, 0x6f, 0x5f, 0x70, 0x61, - 0x67, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xa4, 0x01, 0x0a, 0x1d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, - 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, - 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, - 0x6c, 0x12, 0x3e, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6e, 0x65, 0x78, 0x74, - 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x49, 0x0a, 0x1d, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x61, 0x73, - 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x20, 0x0a, 0x1e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x36, 0x0a, 0x1b, 0x50, 0x65, 0x72, 0x73, - 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x42, 0x07, 0xfa, 0x42, 0x04, 0x22, 0x02, 0x20, 0x00, 0x52, 0x02, 0x69, 0x64, - 0x22, 0x1e, 0x0a, 0x1c, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x61, 0x73, 0x73, - 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x48, 0x0a, 0x1c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, - 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x1f, 0x0a, 0x1d, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x66, - 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x41, 0x0a, 0x15, 0x50, - 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x32, - 0x0a, 0x16, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, - 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, - 0x73, 0x73, 0x22, 0x1a, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, - 0x61, 0x6c, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4f, - 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x6f, - 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x72, - 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, - 0x1b, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, - 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4e, 0x0a, 0x1a, - 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x66, 0x69, - 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, - 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x47, 0x0a, 0x1b, - 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, 0x0a, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x34, 0x0a, 0x1c, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, - 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x32, 0xbb, 0x0a, 0x0a, 0x0f, - 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x9a, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, - 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x31, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x66, 0x69, - 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, - 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1d, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x17, 0x12, 0x15, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x73, - 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0xa5, 0x01, 0x0a, - 0x15, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x34, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, - 0x61, 0x6c, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x1f, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x12, 0x17, 0x2f, 0x73, 0x79, - 0x73, 0x2f, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x73, 0x12, 0x95, 0x01, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, - 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x30, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, - 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, - 0x61, 0x6c, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x65, - 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x93, 0x01, 0x0a, - 0x0e, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, - 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, - 0x6c, 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, - 0x4c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x22, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x3a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x14, 0x2f, 0x73, - 0x79, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x6c, 0x6f, 0x67, 0x6f, - 0x75, 0x74, 0x12, 0xac, 0x01, 0x0a, 0x14, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x50, 0x65, - 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x33, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x50, 0x65, 0x72, 0x73, - 0x6f, 0x6e, 0x61, 0x6c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x34, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, - 0x68, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x3a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x22, 0x1b, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x73, 0x6f, - 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x2f, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, - 0x68, 0x12, 0xad, 0x01, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, - 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x35, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, - 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x61, 0x73, 0x73, 0x77, - 0x6f, 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x24, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x1e, 0x3a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x16, 0x2f, 0x73, 0x79, 0x73, 0x2f, - 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, - 0x64, 0x12, 0xa9, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, - 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x34, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, - 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x35, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, - 0x3a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x15, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x65, 0x72, - 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0xa9, 0x01, - 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, - 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x53, - 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x35, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, - 0x73, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x3a, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x1a, 0x15, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x61, - 0x6c, 0x2f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x42, 0xc2, 0x01, 0x0a, 0x1a, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x42, 0x0d, 0x50, 0x65, 0x72, 0x73, 0x6f, 0x6e, - 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, 0x41, 0x56, 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, 0x70, - 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, 0x22, - 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, - 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_system_personal_proto_rawDesc = "" + + "\n" + + "\x15system/personal.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12system/types.proto\x1a\x17validate/validate.proto\"H\n" + + "\x1cUpdatePersonalSettingRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + + "\x1dUpdatePersonalSettingResponse\"M\n" + + "\x19UpdatePersonalRoleRequest\x120\n" + + "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"\x1c\n" + + "\x1aUpdatePersonalRoleResponse\"\xc4\x01\n" + + "\x1cListPersonalResourcesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\"\xa4\x01\n" + + "\x1dListPersonalResourcesResponse\x12\x19\n" + + "\n" + + "total_size\x18\x01 \x01(\x03R\x05total\x12>\n" + + "\tresources\x18\x02 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\"I\n" + + "\x1dUpdatePersonalPasswordRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\" \n" + + "\x1eUpdatePersonalPasswordResponse\"6\n" + + "\x1bPersonalPasswordRestRequest\x12\x17\n" + + "\x02id\x18\x01 \x01(\x03B\a\xfaB\x04\"\x02 \x00R\x02id\"\x1e\n" + + "\x1cPersonalPasswordRestResponse\"H\n" + + "\x1cUpdatePersonalProfileRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + + "\x1dUpdatePersonalProfileResponse\"A\n" + + "\x15PersonalLogoutRequest\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"2\n" + + "\x16PersonalLogoutResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\"\x1a\n" + + "\x18ListPersonalRolesRequest\"O\n" + + "\x19ListPersonalRolesResponse\x122\n" + + "\x05roles\x18\x01 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\"\x1b\n" + + "\x19GetPersonalProfileRequest\"N\n" + + "\x1aGetPersonalProfileResponse\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"G\n" + + "\x1bRefreshPersonalTokenRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"4\n" + + "\x1cRefreshPersonalTokenResponse\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token2\xbb\n" + + "\n" + + "\x0fPersonalService\x12\x9a\x01\n" + + "\x12GetPersonalProfile\x121.api.v1.services.system.GetPersonalProfileRequest\x1a2.api.v1.services.system.GetPersonalProfileResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/personal/profile\x12\xa5\x01\n" + + "\x15ListPersonalResources\x124.api.v1.services.system.ListPersonalResourcesRequest\x1a5.api.v1.services.system.ListPersonalResourcesResponse\"\x1f\x82\xd3\xe4\x93\x02\x19\x12\x17/sys/personal/resources\x12\x95\x01\n" + + "\x11ListPersonalRoles\x120.api.v1.services.system.ListPersonalRolesRequest\x1a1.api.v1.services.system.ListPersonalRolesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/personal/roles\x12\x93\x01\n" + + "\x0ePersonalLogout\x12-.api.v1.services.system.PersonalLogoutRequest\x1a..api.v1.services.system.PersonalLogoutResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04data\"\x14/sys/personal/logout\x12\xac\x01\n" + + "\x14RefreshPersonalToken\x123.api.v1.services.system.RefreshPersonalTokenRequest\x1a4.api.v1.services.system.RefreshPersonalTokenResponse\")\x82\xd3\xe4\x93\x02#:\x04data\"\x1b/sys/personal/token/refresh\x12\xad\x01\n" + + "\x16UpdatePersonalPassword\x125.api.v1.services.system.UpdatePersonalPasswordRequest\x1a6.api.v1.services.system.UpdatePersonalPasswordResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/sys/personal/password\x12\xa9\x01\n" + + "\x15UpdatePersonalProfile\x124.api.v1.services.system.UpdatePersonalProfileRequest\x1a5.api.v1.services.system.UpdatePersonalProfileResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\x1a\x15/sys/personal/profile\x12\xa9\x01\n" + + "\x15UpdatePersonalSetting\x124.api.v1.services.system.UpdatePersonalSettingRequest\x1a5.api.v1.services.system.UpdatePersonalSettingResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\x1a\x15/sys/personal/settingB\xc2\x01\n" + + "\x1acom.api.v1.services.systemB\rPersonalProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_personal_proto_rawDescOnce sync.Once - file_system_personal_proto_rawDescData = file_system_personal_proto_rawDesc + file_system_personal_proto_rawDescData []byte ) func file_system_personal_proto_rawDescGZIP() []byte { file_system_personal_proto_rawDescOnce.Do(func() { - file_system_personal_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_personal_proto_rawDescData) + file_system_personal_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_personal_proto_rawDesc), len(file_system_personal_proto_rawDesc))) }) return file_system_personal_proto_rawDescData } @@ -1204,7 +1058,7 @@ func file_system_personal_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_personal_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_personal_proto_rawDesc), len(file_system_personal_proto_rawDesc)), NumEnums: 0, NumMessages: 20, NumExtensions: 0, @@ -1215,7 +1069,6 @@ func file_system_personal_proto_init() { MessageInfos: file_system_personal_proto_msgTypes, }.Build() File_system_personal_proto = out.File - file_system_personal_proto_rawDesc = nil file_system_personal_proto_goTypes = nil file_system_personal_proto_depIdxs = nil } diff --git a/api/v1/services/system/personal.pb.validate.go b/api/v1/services/system/personal.pb.validate.go index d5284eca..00d0e6b7 100644 --- a/api/v1/services/system/personal.pb.validate.go +++ b/api/v1/services/system/personal.pb.validate.go @@ -100,7 +100,7 @@ type UpdatePersonalSettingRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePersonalSettingRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -203,7 +203,7 @@ type UpdatePersonalSettingResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePersonalSettingResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -335,7 +335,7 @@ type UpdatePersonalRoleRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePersonalRoleRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -437,7 +437,7 @@ type UpdatePersonalRoleResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePersonalRoleResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -551,7 +551,7 @@ type ListPersonalResourcesRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListPersonalResourcesRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -692,7 +692,7 @@ type ListPersonalResourcesResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListPersonalResourcesResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -824,7 +824,7 @@ type UpdatePersonalPasswordRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePersonalPasswordRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -927,7 +927,7 @@ type UpdatePersonalPasswordResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePersonalPasswordResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1041,7 +1041,7 @@ type PersonalPasswordRestRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PersonalPasswordRestRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1144,7 +1144,7 @@ type PersonalPasswordRestResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PersonalPasswordRestResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1276,7 +1276,7 @@ type UpdatePersonalProfileRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePersonalProfileRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1379,7 +1379,7 @@ type UpdatePersonalProfileResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePersonalProfileResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1511,7 +1511,7 @@ type PersonalLogoutRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PersonalLogoutRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1615,7 +1615,7 @@ type PersonalLogoutResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PersonalLogoutResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1717,7 +1717,7 @@ type ListPersonalRolesRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListPersonalRolesRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1853,7 +1853,7 @@ type ListPersonalRolesResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListPersonalRolesResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1955,7 +1955,7 @@ type GetPersonalProfileRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetPersonalProfileRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2086,7 +2086,7 @@ type GetPersonalProfileResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetPersonalProfileResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2217,7 +2217,7 @@ type RefreshPersonalTokenRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RefreshPersonalTokenRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2322,7 +2322,7 @@ type RefreshPersonalTokenResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RefreshPersonalTokenResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/personal_http.pb.go b/api/v1/services/system/personal_http.pb.go index 0e1e0e94..b38d3c36 100644 --- a/api/v1/services/system/personal_http.pb.go +++ b/api/v1/services/system/personal_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/personal.proto diff --git a/api/v1/services/system/position.pb.go b/api/v1/services/system/position.pb.go index 5631d2c8..d4f24e14 100644 --- a/api/v1/services/system/position.pb.go +++ b/api/v1/services/system/position.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/position.proto @@ -14,6 +14,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -24,10 +25,7 @@ const ( ) type ListPositionsRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id, for example, "shelves/shelf1". Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The current page number. @@ -39,7 +37,9 @@ type ListPositionsRequest struct { // The no_paging is used to disable pagination. NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListPositionsRequest) Reset() { @@ -115,10 +115,7 @@ func (x *ListPositionsRequest) GetOnlyCount() bool { } type ListPositionsResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus @@ -132,7 +129,9 @@ type ListPositionsResponse struct { NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` // Additional information about this response. // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListPositionsResponse) Reset() { @@ -208,13 +207,12 @@ func (x *ListPositionsResponse) GetExtra() *anypb.Any { } type GetPositionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The field will contain id of the resource requested, for example: // "shelves/shelf1/positions/position2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetPositionRequest) Reset() { @@ -255,11 +253,10 @@ func (x *GetPositionRequest) GetId() int64 { } type GetPositionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` unknownFields protoimpl.UnknownFields - - Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetPositionResponse) Reset() { @@ -300,16 +297,15 @@ func (x *GetPositionResponse) GetPosition() *Position { } type CreatePositionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id where the position is to be created. Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` // The position id to use for this position. PositionId string `protobuf:"bytes,2,opt,name=position_id,proto3" json:"position_id,omitempty"` // The position object to create. - Position *Position `protobuf:"bytes,3,opt,name=position,proto3" json:"position,omitempty"` + Position *Position `protobuf:"bytes,3,opt,name=position,proto3" json:"position,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CreatePositionRequest) Reset() { @@ -364,11 +360,10 @@ func (x *CreatePositionRequest) GetPosition() *Position { } type CreatePositionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` unknownFields protoimpl.UnknownFields - - Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreatePositionResponse) Reset() { @@ -409,14 +404,13 @@ func (x *CreatePositionResponse) GetPosition() *Position { } type UpdatePositionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The id of the position resource to update. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The position resource which replaces the resource on the server. - Position *Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` + Position *Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdatePositionRequest) Reset() { @@ -464,11 +458,10 @@ func (x *UpdatePositionRequest) GetPosition() *Position { } type UpdatePositionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` unknownFields protoimpl.UnknownFields - - Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdatePositionResponse) Reset() { @@ -509,13 +502,12 @@ func (x *UpdatePositionResponse) GetPosition() *Position { } type DeletePositionRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The resource id of the position to be deleted, for example: // "shelves/shelf1/positions/position2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *DeletePositionRequest) Reset() { @@ -556,11 +548,10 @@ func (x *DeletePositionRequest) GetId() int64 { } type DeletePositionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` unknownFields protoimpl.UnknownFields - - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DeletePositionResponse) Reset() { @@ -602,157 +593,65 @@ func (x *DeletePositionResponse) GetEmpty() *emptypb.Empty { var File_system_position_proto protoreflect.FileDescriptor -var file_system_position_proto_rawDesc = []byte{ - 0x0a, 0x15, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, - 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, - 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbc, 0x01, 0x0a, 0x14, 0x4c, 0x69, - 0x73, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, - 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x6f, - 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6e, - 0x6f, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a, 0x6f, 0x6e, 0x6c, 0x79, - 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6f, 0x6e, - 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x94, 0x02, 0x0a, 0x15, 0x4c, 0x69, 0x73, - 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, - 0x7a, 0x65, 0x12, 0x3e, 0x0a, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, - 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x6e, 0x65, - 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2f, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x48, 0x00, 0x52, 0x05, 0x65, 0x78, 0x74, - 0x72, 0x61, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x65, 0x78, 0x74, 0x72, 0x61, 0x22, - 0x24, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x53, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x08, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x8f, 0x01, 0x0a, 0x15, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x20, 0x0a, 0x0b, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x12, 0x3c, - 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x56, 0x0a, 0x16, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x65, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, - 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x56, 0x0a, 0x16, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x22, 0x27, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x46, 0x0a, 0x16, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x05, 0x65, - 0x6d, 0x70, 0x74, 0x79, 0x32, 0xe3, 0x05, 0x0a, 0x0f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, - 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x84, 0x01, 0x0a, 0x0d, 0x4c, 0x69, 0x73, - 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2c, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, - 0x0e, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x83, 0x01, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, - 0x12, 0x13, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x91, 0x01, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1a, 0x3a, - 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x0e, 0x2f, 0x73, 0x79, 0x73, 0x2f, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x9f, 0x01, 0x0a, 0x0e, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x28, 0x3a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x1c, 0x2f, - 0x73, 0x79, 0x73, 0x2f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x7b, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x69, 0x64, 0x7d, 0x12, 0x8c, 0x01, 0x0a, 0x0e, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x2a, 0x13, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xc2, 0x01, 0x0a, 0x1a, 0x63, - 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x42, 0x0d, 0x50, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, 0x41, 0x56, 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, - 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, - 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_system_position_proto_rawDesc = "" + + "\n" + + "\x15system/position.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xbc\x01\n" + + "\x14ListPositionsRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\"\x94\x02\n" + + "\x15ListPositionsResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x12>\n" + + "\tpositions\x18\x02 \x03(\v2 .api.v1.services.system.PositionR\tpositions\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"$\n" + + "\x12GetPositionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"S\n" + + "\x13GetPositionResponse\x12<\n" + + "\bposition\x18\x01 \x01(\v2 .api.v1.services.system.PositionR\bposition\"\x8f\x01\n" + + "\x15CreatePositionRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12 \n" + + "\vposition_id\x18\x02 \x01(\tR\vposition_id\x12<\n" + + "\bposition\x18\x03 \x01(\v2 .api.v1.services.system.PositionR\bposition\"V\n" + + "\x16CreatePositionResponse\x12<\n" + + "\bposition\x18\x01 \x01(\v2 .api.v1.services.system.PositionR\bposition\"e\n" + + "\x15UpdatePositionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\bposition\x18\x02 \x01(\v2 .api.v1.services.system.PositionR\bposition\"V\n" + + "\x16UpdatePositionResponse\x12<\n" + + "\bposition\x18\x01 \x01(\v2 .api.v1.services.system.PositionR\bposition\"'\n" + + "\x15DeletePositionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + + "\x16DeletePositionResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xe3\x05\n" + + "\x0fPositionService\x12\x84\x01\n" + + "\rListPositions\x12,.api.v1.services.system.ListPositionsRequest\x1a-.api.v1.services.system.ListPositionsResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/positions\x12\x83\x01\n" + + "\vGetPosition\x12*.api.v1.services.system.GetPositionRequest\x1a+.api.v1.services.system.GetPositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/positions/{id}\x12\x91\x01\n" + + "\x0eCreatePosition\x12-.api.v1.services.system.CreatePositionRequest\x1a..api.v1.services.system.CreatePositionResponse\" \x82\xd3\xe4\x93\x02\x1a:\bposition\"\x0e/sys/positions\x12\x9f\x01\n" + + "\x0eUpdatePosition\x12-.api.v1.services.system.UpdatePositionRequest\x1a..api.v1.services.system.UpdatePositionResponse\".\x82\xd3\xe4\x93\x02(:\bposition\x1a\x1c/sys/positions/{position.id}\x12\x8c\x01\n" + + "\x0eDeletePosition\x12-.api.v1.services.system.DeletePositionRequest\x1a..api.v1.services.system.DeletePositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/positions/{id}B\xc2\x01\n" + + "\x1acom.api.v1.services.systemB\rPositionProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_position_proto_rawDescOnce sync.Once - file_system_position_proto_rawDescData = file_system_position_proto_rawDesc + file_system_position_proto_rawDescData []byte ) func file_system_position_proto_rawDescGZIP() []byte { file_system_position_proto_rawDescOnce.Do(func() { - file_system_position_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_position_proto_rawDescData) + file_system_position_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_position_proto_rawDesc), len(file_system_position_proto_rawDesc))) }) return file_system_position_proto_rawDescData } @@ -810,7 +709,7 @@ func file_system_position_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_position_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_position_proto_rawDesc), len(file_system_position_proto_rawDesc)), NumEnums: 0, NumMessages: 10, NumExtensions: 0, @@ -821,7 +720,6 @@ func file_system_position_proto_init() { MessageInfos: file_system_position_proto_msgTypes, }.Build() File_system_position_proto = out.File - file_system_position_proto_rawDesc = nil file_system_position_proto_goTypes = nil file_system_position_proto_depIdxs = nil } diff --git a/api/v1/services/system/position.pb.validate.go b/api/v1/services/system/position.pb.validate.go index 5c4b32e1..795208ed 100644 --- a/api/v1/services/system/position.pb.validate.go +++ b/api/v1/services/system/position.pb.validate.go @@ -83,7 +83,7 @@ type ListPositionsRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListPositionsRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -260,7 +260,7 @@ type ListPositionsResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListPositionsResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -364,7 +364,7 @@ type GetPositionRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetPositionRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -495,7 +495,7 @@ type GetPositionResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetPositionResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -630,7 +630,7 @@ type CreatePositionRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreatePositionRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -761,7 +761,7 @@ type CreatePositionResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreatePositionResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -894,7 +894,7 @@ type UpdatePositionRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePositionRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1025,7 +1025,7 @@ type UpdatePositionResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdatePositionResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1129,7 +1129,7 @@ type DeletePositionRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeletePositionRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1260,7 +1260,7 @@ type DeletePositionResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeletePositionResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/position_http.pb.go b/api/v1/services/system/position_http.pb.go index b598c042..ed5e52ba 100644 --- a/api/v1/services/system/position_http.pb.go +++ b/api/v1/services/system/position_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/position.proto diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go index 1568b5a9..e2a9c541 100644 --- a/api/v1/services/system/resource.pb.go +++ b/api/v1/services/system/resource.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/resource.proto @@ -14,6 +14,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -25,10 +26,7 @@ const ( // ListResourcesRequest is the request for the ResourceService.ListResources method. type ListResourcesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id, for example, "shelves/shelf1". Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The current page number. @@ -42,7 +40,9 @@ type ListResourcesRequest struct { // The only_count is the query parameter for set only to query the total number OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` // resource type - Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListResourcesRequest) Reset() { @@ -126,10 +126,7 @@ func (x *ListResourcesRequest) GetType() string { // ListResourcesResponse is the response for the ResourceService.ListResources method. type ListResourcesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging resources @@ -143,7 +140,9 @@ type ListResourcesResponse struct { NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` // Additional information about this response. // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListResourcesResponse) Reset() { @@ -220,13 +219,12 @@ func (x *ListResourcesResponse) GetExtra() *anypb.Any { // GetResourceRequest is the request for the ResourceService.GetResource method. type GetResourceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The field will contain id of the resource requested, for example: // "shelves/shelf1/resources/resource2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetResourceRequest) Reset() { @@ -268,12 +266,11 @@ func (x *GetResourceRequest) GetId() int64 { // GetResourceResponse is the response for the ResourceService.GetResource method. type GetResourceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The field id should match the Noun in the method id. - Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetResourceResponse) Reset() { @@ -315,16 +312,15 @@ func (x *GetResourceResponse) GetResource() *Resource { // CreateResourceRequest is the request for the ResourceService.CreateResource method. type CreateResourceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id where the resource is to be created. Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` // The resource id to use for this resource. ResourceId string `protobuf:"bytes,2,opt,name=resource_id,proto3" json:"resource_id,omitempty"` // The resource object to create. - Resource *Resource `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` + Resource *Resource `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CreateResourceRequest) Reset() { @@ -380,11 +376,10 @@ func (x *CreateResourceRequest) GetResource() *Resource { // CreateResourceResponse is the response for the ResourceService.CreateResource method. type CreateResourceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` unknownFields protoimpl.UnknownFields - - Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateResourceResponse) Reset() { @@ -426,14 +421,13 @@ func (x *CreateResourceResponse) GetResource() *Resource { // UpdateResourceRequest is the request for the ResourceService.UpdateResource method. type UpdateResourceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The id of the resource object to update. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The resource object which replaces the resource on the server. - Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` + Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdateResourceRequest) Reset() { @@ -482,11 +476,10 @@ func (x *UpdateResourceRequest) GetResource() *Resource { // UpdateResourceResponse is the response for the ResourceService.UpdateResource method. type UpdateResourceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` unknownFields protoimpl.UnknownFields - - Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdateResourceResponse) Reset() { @@ -528,13 +521,12 @@ func (x *UpdateResourceResponse) GetResource() *Resource { // DeleteResourceRequest is the request for the ResourceService.DeleteResource method. type DeleteResourceRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The resource id of the resource to be deleted, for example: // "shelves/shelf1/resources/resource2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *DeleteResourceRequest) Reset() { @@ -576,12 +568,11 @@ func (x *DeleteResourceRequest) GetId() int64 { // DeleteResourceResponse is the response for the ResourceService.DeleteResource method. type DeleteResourceResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // or Resource resource = 1; or google.protobuf.Empty empty = 1; - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *DeleteResourceResponse) Reset() { @@ -623,158 +614,66 @@ func (x *DeleteResourceResponse) GetEmpty() *emptypb.Empty { var File_system_resource_proto protoreflect.FileDescriptor -var file_system_resource_proto_rawDesc = []byte{ - 0x0a, 0x15, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, - 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, - 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, - 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd0, 0x01, 0x0a, 0x14, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, - 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x6f, - 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6e, - 0x6f, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a, 0x6f, 0x6e, 0x6c, 0x79, - 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6f, 0x6e, - 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x94, 0x02, 0x0a, - 0x15, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, - 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, - 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x3e, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x28, - 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2f, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, - 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x48, 0x00, 0x52, - 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x65, 0x78, - 0x74, 0x72, 0x61, 0x22, 0x24, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x53, 0x0a, 0x13, 0x47, 0x65, 0x74, - 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x3c, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x8f, - 0x01, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, - 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, - 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x22, 0x56, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x08, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x65, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x3c, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, - 0x56, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x08, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x27, 0x0a, 0x15, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, - 0x22, 0x46, 0x0a, 0x16, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x65, 0x6d, - 0x70, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x52, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x32, 0xe3, 0x05, 0x0a, 0x0f, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x84, 0x01, 0x0a, - 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x2c, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x73, 0x12, 0x83, 0x01, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x12, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, - 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x15, 0x12, 0x13, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x91, 0x01, 0x0a, 0x0e, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x2d, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x1a, 0x3a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x0e, 0x2f, - 0x73, 0x79, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x9f, 0x01, - 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x12, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x3a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x1a, 0x1c, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x73, 0x2f, 0x7b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x69, 0x64, 0x7d, 0x12, - 0x8c, 0x01, 0x0a, 0x0e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x12, 0x2d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x2e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x2a, 0x13, 0x2f, 0x73, 0x79, 0x73, 0x2f, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xc2, - 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x42, 0x0d, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x19, - 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, 0x41, 0x56, 0x53, 0x53, - 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, 0x41, 0x70, 0x69, 0x5c, - 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, - 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_system_resource_proto_rawDesc = "" + + "\n" + + "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xd0\x01\n" + + "\x14ListResourcesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x12\n" + + "\x04type\x18\a \x01(\tR\x04type\"\x94\x02\n" + + "\x15ListResourcesResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x12>\n" + + "\tresources\x18\x02 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"$\n" + + "\x12GetResourceRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"S\n" + + "\x13GetResourceResponse\x12<\n" + + "\bresource\x18\x01 \x01(\v2 .api.v1.services.system.ResourceR\bresource\"\x8f\x01\n" + + "\x15CreateResourceRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12 \n" + + "\vresource_id\x18\x02 \x01(\tR\vresource_id\x12<\n" + + "\bresource\x18\x03 \x01(\v2 .api.v1.services.system.ResourceR\bresource\"V\n" + + "\x16CreateResourceResponse\x12<\n" + + "\bresource\x18\x01 \x01(\v2 .api.v1.services.system.ResourceR\bresource\"e\n" + + "\x15UpdateResourceRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\bresource\x18\x02 \x01(\v2 .api.v1.services.system.ResourceR\bresource\"V\n" + + "\x16UpdateResourceResponse\x12<\n" + + "\bresource\x18\x01 \x01(\v2 .api.v1.services.system.ResourceR\bresource\"'\n" + + "\x15DeleteResourceRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + + "\x16DeleteResourceResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xe3\x05\n" + + "\x0fResourceService\x12\x84\x01\n" + + "\rListResources\x12,.api.v1.services.system.ListResourcesRequest\x1a-.api.v1.services.system.ListResourcesResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/resources\x12\x83\x01\n" + + "\vGetResource\x12*.api.v1.services.system.GetResourceRequest\x1a+.api.v1.services.system.GetResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/resources/{id}\x12\x91\x01\n" + + "\x0eCreateResource\x12-.api.v1.services.system.CreateResourceRequest\x1a..api.v1.services.system.CreateResourceResponse\" \x82\xd3\xe4\x93\x02\x1a:\bresource\"\x0e/sys/resources\x12\x9f\x01\n" + + "\x0eUpdateResource\x12-.api.v1.services.system.UpdateResourceRequest\x1a..api.v1.services.system.UpdateResourceResponse\".\x82\xd3\xe4\x93\x02(:\bresource\x1a\x1c/sys/resources/{resource.id}\x12\x8c\x01\n" + + "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xc2\x01\n" + + "\x1acom.api.v1.services.systemB\rResourceProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_resource_proto_rawDescOnce sync.Once - file_system_resource_proto_rawDescData = file_system_resource_proto_rawDesc + file_system_resource_proto_rawDescData []byte ) func file_system_resource_proto_rawDescGZIP() []byte { file_system_resource_proto_rawDescOnce.Do(func() { - file_system_resource_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_resource_proto_rawDescData) + file_system_resource_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_resource_proto_rawDesc), len(file_system_resource_proto_rawDesc))) }) return file_system_resource_proto_rawDescData } @@ -832,7 +731,7 @@ func file_system_resource_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_resource_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_resource_proto_rawDesc), len(file_system_resource_proto_rawDesc)), NumEnums: 0, NumMessages: 10, NumExtensions: 0, @@ -843,7 +742,6 @@ func file_system_resource_proto_init() { MessageInfos: file_system_resource_proto_msgTypes, }.Build() File_system_resource_proto = out.File - file_system_resource_proto_rawDesc = nil file_system_resource_proto_goTypes = nil file_system_resource_proto_depIdxs = nil } diff --git a/api/v1/services/system/resource.pb.validate.go b/api/v1/services/system/resource.pb.validate.go index 30820663..aa7567f4 100644 --- a/api/v1/services/system/resource.pb.validate.go +++ b/api/v1/services/system/resource.pb.validate.go @@ -85,7 +85,7 @@ type ListResourcesRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListResourcesRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -262,7 +262,7 @@ type ListResourcesResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListResourcesResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -366,7 +366,7 @@ type GetResourceRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetResourceRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -497,7 +497,7 @@ type GetResourceResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetResourceResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -632,7 +632,7 @@ type CreateResourceRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateResourceRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -763,7 +763,7 @@ type CreateResourceResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateResourceResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -896,7 +896,7 @@ type UpdateResourceRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateResourceRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1027,7 +1027,7 @@ type UpdateResourceResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateResourceResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1131,7 +1131,7 @@ type DeleteResourceRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeleteResourceRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1262,7 +1262,7 @@ type DeleteResourceResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeleteResourceResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/resource_http.pb.go b/api/v1/services/system/resource_http.pb.go index 805aa8cb..ac0caac8 100644 --- a/api/v1/services/system/resource_http.pb.go +++ b/api/v1/services/system/resource_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/resource.proto diff --git a/api/v1/services/system/role.pb.go b/api/v1/services/system/role.pb.go index 85ba3bc5..3cd48acd 100644 --- a/api/v1/services/system/role.pb.go +++ b/api/v1/services/system/role.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/role.proto @@ -14,6 +14,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -24,10 +25,7 @@ const ( ) type ListRolesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id, for example, "shelves/shelf1". Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The current page number. @@ -39,7 +37,9 @@ type ListRolesRequest struct { // The no_paging is used to disable pagination. NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListRolesRequest) Reset() { @@ -115,10 +115,7 @@ func (x *ListRolesRequest) GetOnlyCount() bool { } type ListRolesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus @@ -132,7 +129,9 @@ type ListRolesResponse struct { NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` // Additional information about this response. // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListRolesResponse) Reset() { @@ -208,13 +207,12 @@ func (x *ListRolesResponse) GetExtra() *anypb.Any { } type GetRoleRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The field will contain id of the resource requested, for example: // "shelves/shelf1/roles/role2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetRoleRequest) Reset() { @@ -255,11 +253,10 @@ func (x *GetRoleRequest) GetId() int64 { } type GetRoleResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields - - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetRoleResponse) Reset() { @@ -300,17 +297,16 @@ func (x *GetRoleResponse) GetRole() *Role { } type CreateRoleRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id where the role is to be created. Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` // The role id to use for this role. RoleId string `protobuf:"bytes,3,opt,name=role_id,proto3" json:"role_id,omitempty"` // The role resource to create. // The field id should match the Noun in the method id. - Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CreateRoleRequest) Reset() { @@ -365,11 +361,10 @@ func (x *CreateRoleRequest) GetRole() *Role { } type CreateRoleResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields - - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateRoleResponse) Reset() { @@ -410,14 +405,13 @@ func (x *CreateRoleResponse) GetRole() *Role { } type UpdateRoleRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The id of the role resource to update. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The role resource which replaces the resource on the server. - Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdateRoleRequest) Reset() { @@ -465,11 +459,10 @@ func (x *UpdateRoleRequest) GetRole() *Role { } type UpdateRoleResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields - - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdateRoleResponse) Reset() { @@ -510,13 +503,12 @@ func (x *UpdateRoleResponse) GetRole() *Role { } type DeleteRoleRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The resource id of the role to be deleted, for example: // "shelves/shelf1/roles/role2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *DeleteRoleRequest) Reset() { @@ -557,11 +549,10 @@ func (x *DeleteRoleRequest) GetId() int64 { } type DeleteRoleResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` unknownFields protoimpl.UnknownFields - - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DeleteRoleResponse) Reset() { @@ -603,143 +594,70 @@ func (x *DeleteRoleResponse) GetEmpty() *emptypb.Empty { var File_system_role_proto protoreflect.FileDescriptor -var file_system_role_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x72, 0x6f, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb8, 0x01, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x6f, - 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, - 0x7a, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x6f, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6e, 0x6f, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x67, - 0x12, 0x1e, 0x0a, 0x0a, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x22, 0x84, 0x02, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, - 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, - 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, - 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, - 0x7a, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6e, 0x65, 0x78, - 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2f, 0x0a, 0x05, - 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, - 0x79, 0x48, 0x00, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, - 0x06, 0x5f, 0x65, 0x78, 0x74, 0x72, 0x61, 0x22, 0x20, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x6f, - 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x43, 0x0a, 0x0f, 0x47, 0x65, 0x74, - 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, - 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x77, - 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x72, - 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x6f, - 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, - 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x46, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, - 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, - 0x55, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, - 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x46, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, - 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x23, - 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x02, 0x69, 0x64, 0x22, 0x42, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x65, 0x6d, 0x70, - 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x52, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x32, 0xff, 0x04, 0x0a, 0x0b, 0x52, 0x6f, 0x6c, 0x65, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x74, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, - 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x28, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x6f, 0x6c, 0x65, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x0c, 0x12, 0x0a, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x73, 0x0a, - 0x07, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x27, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x6c, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x11, 0x12, 0x0f, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x2f, 0x7b, 0x69, - 0x64, 0x7d, 0x12, 0x7d, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, - 0x12, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, - 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x0a, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x72, 0x6f, 0x6c, 0x65, - 0x73, 0x12, 0x87, 0x01, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, - 0x12, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x3a, - 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x1a, 0x14, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x72, 0x6f, 0x6c, 0x65, - 0x73, 0x2f, 0x7b, 0x72, 0x6f, 0x6c, 0x65, 0x2e, 0x69, 0x64, 0x7d, 0x12, 0x7c, 0x0a, 0x0a, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x2a, 0x0f, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x72, - 0x6f, 0x6c, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x42, 0xbe, 0x01, 0x0a, 0x1a, 0x63, 0x6f, - 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x42, 0x09, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0xa2, 0x02, 0x04, 0x41, 0x56, 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, - 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0xca, 0x02, 0x16, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, - 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x19, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} +const file_system_role_proto_rawDesc = "" + + "\n" + + "\x11system/role.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xb8\x01\n" + + "\x10ListRolesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\"\x84\x02\n" + + "\x11ListRolesResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x122\n" + + "\x05roles\x18\x02 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\" \n" + + "\x0eGetRoleRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"C\n" + + "\x0fGetRoleResponse\x120\n" + + "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"w\n" + + "\x11CreateRoleRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x18\n" + + "\arole_id\x18\x03 \x01(\tR\arole_id\x120\n" + + "\x04role\x18\x02 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"F\n" + + "\x12CreateRoleResponse\x120\n" + + "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"U\n" + + "\x11UpdateRoleRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x120\n" + + "\x04role\x18\x02 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"F\n" + + "\x12UpdateRoleResponse\x120\n" + + "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"#\n" + + "\x11DeleteRoleRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x12DeleteRoleResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xff\x04\n" + + "\vRoleService\x12t\n" + + "\tListRoles\x12(.api.v1.services.system.ListRolesRequest\x1a).api.v1.services.system.ListRolesResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + + "/sys/roles\x12s\n" + + "\aGetRole\x12&.api.v1.services.system.GetRoleRequest\x1a'.api.v1.services.system.GetRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/roles/{id}\x12}\n" + + "\n" + + "CreateRole\x12).api.v1.services.system.CreateRoleRequest\x1a*.api.v1.services.system.CreateRoleResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04role\"\n" + + "/sys/roles\x12\x87\x01\n" + + "\n" + + "UpdateRole\x12).api.v1.services.system.UpdateRoleRequest\x1a*.api.v1.services.system.UpdateRoleResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04role\x1a\x14/sys/roles/{role.id}\x12|\n" + + "\n" + + "DeleteRole\x12).api.v1.services.system.DeleteRoleRequest\x1a*.api.v1.services.system.DeleteRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/roles/{id}B\xbe\x01\n" + + "\x1acom.api.v1.services.systemB\tRoleProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_role_proto_rawDescOnce sync.Once - file_system_role_proto_rawDescData = file_system_role_proto_rawDesc + file_system_role_proto_rawDescData []byte ) func file_system_role_proto_rawDescGZIP() []byte { file_system_role_proto_rawDescOnce.Do(func() { - file_system_role_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_role_proto_rawDescData) + file_system_role_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_role_proto_rawDesc), len(file_system_role_proto_rawDesc))) }) return file_system_role_proto_rawDescData } @@ -797,7 +715,7 @@ func file_system_role_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_role_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_role_proto_rawDesc), len(file_system_role_proto_rawDesc)), NumEnums: 0, NumMessages: 10, NumExtensions: 0, @@ -808,7 +726,6 @@ func file_system_role_proto_init() { MessageInfos: file_system_role_proto_msgTypes, }.Build() File_system_role_proto = out.File - file_system_role_proto_rawDesc = nil file_system_role_proto_goTypes = nil file_system_role_proto_depIdxs = nil } diff --git a/api/v1/services/system/role.pb.validate.go b/api/v1/services/system/role.pb.validate.go index 3dd3b30b..d4113bc2 100644 --- a/api/v1/services/system/role.pb.validate.go +++ b/api/v1/services/system/role.pb.validate.go @@ -83,7 +83,7 @@ type ListRolesRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListRolesRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -258,7 +258,7 @@ type ListRolesResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListRolesResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -362,7 +362,7 @@ type GetRoleRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetRoleRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -491,7 +491,7 @@ type GetRoleResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetRoleResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -624,7 +624,7 @@ type CreateRoleRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateRoleRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -755,7 +755,7 @@ type CreateRoleResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateRoleResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -888,7 +888,7 @@ type UpdateRoleRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateRoleRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1019,7 +1019,7 @@ type UpdateRoleResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateRoleResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1123,7 +1123,7 @@ type DeleteRoleRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeleteRoleRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1254,7 +1254,7 @@ type DeleteRoleResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeleteRoleResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/role_http.pb.go b/api/v1/services/system/role_http.pb.go index cdfe732c..221edd5f 100644 --- a/api/v1/services/system/role_http.pb.go +++ b/api/v1/services/system/role_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/role.proto diff --git a/api/v1/services/system/types.pb.go b/api/v1/services/system/types.pb.go index 5384974d..5491d861 100644 --- a/api/v1/services/system/types.pb.go +++ b/api/v1/services/system/types.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/types.proto @@ -12,6 +12,7 @@ import ( timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -23,10 +24,7 @@ const ( // Menu is the model entity for the Menu schema. type Menu struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // CreateTime holds the value of the "create_time" field. @@ -64,7 +62,9 @@ type Menu struct { // Resources holds the value of the resources edge. Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Menu) Reset() { @@ -232,10 +232,7 @@ func (x *Menu) GetRoles() []*Role { // MenuEdges holds the relations/edges for other nodes in the graph. type MenuEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Children holds the value of the children edge. Children []*Menu `protobuf:"bytes,1,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. @@ -245,7 +242,9 @@ type MenuEdges struct { // Roles holds the value of the roles edge. Roles []*Role `protobuf:"bytes,4,rep,name=roles,proto3" json:"roles,omitempty"` // RoleMenu holds the value of the role_menu edge. - RoleMenus []*RoleMenu `protobuf:"bytes,5,rep,name=role_menus,proto3" json:"role_menus,omitempty"` + RoleMenus []*RoleMenu `protobuf:"bytes,5,rep,name=role_menus,proto3" json:"role_menus,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *MenuEdges) Reset() { @@ -315,10 +314,7 @@ func (x *MenuEdges) GetRoleMenus() []*RoleMenu { // Role is the model entity for the Role schema. type Role struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -352,6 +348,8 @@ type Role struct { Permissions []*Permission `protobuf:"bytes,25,rep,name=permissions,proto3" json:"permissions,omitempty"` // Permission Ids holds the value of the permission_ids edge. PermissionIds []int64 `protobuf:"varint,26,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Role) Reset() { @@ -498,10 +496,7 @@ func (x *Role) GetPermissionIds() []int64 { // RoleEdges holds the relations/edges for other nodes in the graph. type RoleEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Menus holds the value of the menus edge. Menus []*Menu `protobuf:"bytes,1,rep,name=menus,proto3" json:"menus,omitempty"` // Users holds the value of the users edge. @@ -509,7 +504,9 @@ type RoleEdges struct { // RoleMenu holds the value of the role_menu edge. RoleMenus []*RoleMenu `protobuf:"bytes,3,rep,name=role_menus,proto3" json:"role_menus,omitempty"` // UserRole holds the value of the user_role edge. - UserRoles []*UserRole `protobuf:"bytes,4,rep,name=user_roles,proto3" json:"user_roles,omitempty"` + UserRoles []*UserRole `protobuf:"bytes,4,rep,name=user_roles,proto3" json:"user_roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *RoleEdges) Reset() { @@ -572,10 +569,7 @@ func (x *RoleEdges) GetUserRoles() []*UserRole { // User is the model entity for the User schema. type User struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -632,7 +626,9 @@ type User struct { // Roles holds the value of the roles edge. Roles []*Role `protobuf:"bytes,26,rep,name=roles,proto3" json:"roles,omitempty"` // Role Ids holds the value of the role_ids - RoleIds []int64 `protobuf:"varint,27,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` + RoleIds []int64 `protobuf:"varint,27,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *User) Reset() { @@ -856,14 +852,13 @@ func (x *User) GetRoleIds() []int64 { // UserEdges holds the relations/edges for other nodes in the graph. type UserEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Roles holds the value of the roles edge. Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` // UserRole holds the value of the user_role edge. - UserRoles []*UserRole `protobuf:"bytes,2,rep,name=user_roles,proto3" json:"user_roles,omitempty"` + UserRoles []*UserRole `protobuf:"bytes,2,rep,name=user_roles,proto3" json:"user_roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UserEdges) Reset() { @@ -912,10 +907,7 @@ func (x *UserEdges) GetUserRoles() []*UserRole { // UserRole is the model entity for the UserRole schema. type UserRole struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // CreateTime holds the value of the "create_time" field. @@ -931,7 +923,9 @@ type UserRole struct { // User holds the value of the user edge. User *User `protobuf:"bytes,21,opt,name=user,proto3" json:"user,omitempty"` // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,22,opt,name=role,proto3" json:"role,omitempty"` + Role *Role `protobuf:"bytes,22,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UserRole) Reset() { @@ -1022,14 +1016,13 @@ func (x *UserRole) GetRole() *Role { // UserRoleEdges holds the relations/edges for other nodes in the graph. type UserRoleEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // User holds the value of the user edge. User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UserRoleEdges) Reset() { @@ -1078,10 +1071,7 @@ func (x *UserRoleEdges) GetRole() *Role { // RoleMenu is the model entity for the RoleMenu schema. type RoleMenu struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // CreateTime holds the value of the "create_time" field. @@ -1095,7 +1085,9 @@ type RoleMenu struct { // Role holds the value of the role edge. Role *Role `protobuf:"bytes,21,opt,name=role,proto3" json:"role,omitempty"` // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,22,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *Menu `protobuf:"bytes,22,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *RoleMenu) Reset() { @@ -1179,14 +1171,13 @@ func (x *RoleMenu) GetMenu() *Menu { // RoleMenuEdges holds the relations/edges for other nodes in the graph. type RoleMenuEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Role holds the value of the role edge. Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *RoleMenuEdges) Reset() { @@ -1235,10 +1226,7 @@ func (x *RoleMenuEdges) GetMenu() *Menu { // Resource is the model entity for the Resource schema. type Resource struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -1273,7 +1261,7 @@ type Resource struct { // resource.field.tree_path TreePath string `protobuf:"bytes,16,opt,name=tree_path,proto3" json:"tree_path,omitempty"` // resource.field.properties - Properties map[string]string `protobuf:"bytes,17,rep,name=properties,proto3" json:"properties,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Properties map[string]string `protobuf:"bytes,17,rep,name=properties,proto3" json:"properties,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // resource.field.description Description string `protobuf:"bytes,18,opt,name=description,proto3" json:"description,omitempty"` // resource.field.parent_id @@ -1285,7 +1273,9 @@ type Resource struct { // Permission Ids holds the value of the permission_ids edge. PermissionIds []int64 `protobuf:"varint,23,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,24,rep,name=permissions,proto3" json:"permissions,omitempty"` + Permissions []*Permission `protobuf:"bytes,24,rep,name=permissions,proto3" json:"permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Resource) Reset() { @@ -1481,12 +1471,11 @@ func (x *Resource) GetPermissions() []*Permission { // ResourceEdges holds the relations/edges for other nodes in the graph. type ResourceEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ResourceEdges) Reset() { @@ -1528,10 +1517,7 @@ func (x *ResourceEdges) GetMenu() *Menu { // department.table.comment type Department struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -1558,7 +1544,9 @@ type Department struct { // Children holds the value of the children edge. Children []*Department `protobuf:"bytes,12,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. - Parent *Department `protobuf:"bytes,13,opt,name=parent,proto3" json:"parent,omitempty"` + Parent *Department `protobuf:"bytes,13,opt,name=parent,proto3" json:"parent,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Department) Reset() { @@ -1683,10 +1671,7 @@ func (x *Department) GetParent() *Department { } type DepartmentEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Users holds the value of the users edge. Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` // Positions holds the value of the positions edge. @@ -1697,6 +1682,8 @@ type DepartmentEdges struct { Parent *Department `protobuf:"bytes,4,opt,name=parent,proto3" json:"parent,omitempty"` // UserDepartments holds the value of the user_departments edge. UserDepartments []*UserDepartment `protobuf:"bytes,5,rep,name=user_departments,proto3" json:"user_departments,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *DepartmentEdges) Reset() { @@ -1766,10 +1753,7 @@ func (x *DepartmentEdges) GetUserDepartments() []*UserDepartment { // user_department.table.comment type UserDepartment struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -1779,7 +1763,9 @@ type UserDepartment struct { DepartmentId int64 `protobuf:"varint,3,opt,name=department_id,proto3" json:"department_id,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the UserDepartmentQuery when eager-loading is set. - Edges *UserDepartmentEdges `protobuf:"bytes,4,opt,name=edges,proto3" json:"edges,omitempty"` + Edges *UserDepartmentEdges `protobuf:"bytes,4,opt,name=edges,proto3" json:"edges,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UserDepartment) Reset() { @@ -1842,14 +1828,13 @@ func (x *UserDepartment) GetEdges() *UserDepartmentEdges { // UserDepartmentEdges holds the relations/edges for other nodes in the graph. type UserDepartmentEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // User holds the value of the user edge. User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` // Department holds the value of the department edge. - Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UserDepartmentEdges) Reset() { @@ -1898,10 +1883,7 @@ func (x *UserDepartmentEdges) GetDepartment() *Department { // position.table.comment type Position struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -1916,7 +1898,9 @@ type Position struct { // position.field.description Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` // department.field.department_id - DepartmentId int64 `protobuf:"varint,7,opt,name=department_id,proto3" json:"department_id,omitempty"` + DepartmentId int64 `protobuf:"varint,7,opt,name=department_id,proto3" json:"department_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Position) Reset() { @@ -2000,10 +1984,7 @@ func (x *Position) GetDepartmentId() int64 { // PositionEdges holds the relations/edges for other nodes in the graph. type PositionEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Department holds the value of the department edge. Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` // Users holds the value of the users edge. @@ -2014,6 +1995,8 @@ type PositionEdges struct { UserPositions []*UserPosition `protobuf:"bytes,4,rep,name=user_positions,proto3" json:"user_positions,omitempty"` // PositionPermissions holds the value of the position_permissions edge. PositionPermissions []*PositionPermission `protobuf:"bytes,5,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PositionEdges) Reset() { @@ -2083,10 +2066,7 @@ func (x *PositionEdges) GetPositionPermissions() []*PositionPermission { // permission.table.comment type Permission struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -2103,11 +2083,13 @@ type Permission struct { // permission.field.data_scope DataScope string `protobuf:"bytes,7,opt,name=data_scope,proto3" json:"data_scope,omitempty"` // permission.field.data_rules - DataRules map[string]string `protobuf:"bytes,8,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + DataRules map[string]string `protobuf:"bytes,8,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // permission.field.resource_ids ResourceIds []int64 `protobuf:"varint,9,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` // permission.field.resources - Resources []*Resource `protobuf:"bytes,10,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*Resource `protobuf:"bytes,10,rep,name=resources,proto3" json:"resources,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Permission) Reset() { @@ -2212,10 +2194,7 @@ func (x *Permission) GetResources() []*Resource { // PermissionEdges holds the relations/edges for other nodes in the graph. type PermissionEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Roles holds the value of the roles edge. Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` // Resources holds the value of the resources edge. @@ -2228,6 +2207,8 @@ type PermissionEdges struct { PermissionResources []*PermissionResource `protobuf:"bytes,5,rep,name=permission_resources,proto3" json:"permission_resources,omitempty"` // PositionPermissions holds the value of the position_permissions edge. PositionPermissions []*PositionPermission `protobuf:"bytes,6,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PermissionEdges) Reset() { @@ -2304,17 +2285,16 @@ func (x *PermissionEdges) GetPositionPermissions() []*PositionPermission { // user_position.table.comment type UserPosition struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // field.foreign_key.comment UserId int64 `protobuf:"varint,2,opt,name=user_id,proto3" json:"user_id,omitempty"` // field.foreign_key.comment - PositionId int64 `protobuf:"varint,3,opt,name=position_id,proto3" json:"position_id,omitempty"` + PositionId int64 `protobuf:"varint,3,opt,name=position_id,proto3" json:"position_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UserPosition) Reset() { @@ -2370,14 +2350,13 @@ func (x *UserPosition) GetPositionId() int64 { // UserPositionEdges holds the relations/edges for other nodes in the graph. type UserPositionEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // User holds the value of the user edge. User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` // Position holds the value of the position edge. - Position *Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` + Position *Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UserPositionEdges) Reset() { @@ -2426,17 +2405,16 @@ func (x *UserPositionEdges) GetPosition() *Position { // position_permission.table.comment type PositionPermission struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // position_permission.field.position_id PositionId int64 `protobuf:"varint,2,opt,name=position_id,proto3" json:"position_id,omitempty"` // position_permission.field.permission_id - PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PositionPermission) Reset() { @@ -2492,14 +2470,13 @@ func (x *PositionPermission) GetPermissionId() int64 { // PositionPermissionEdges holds the relations/edges for other nodes in the graph. type PositionPermissionEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Position holds the value of the position edge. Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PositionPermissionEdges) Reset() { @@ -2548,17 +2525,16 @@ func (x *PositionPermissionEdges) GetPermission() *Permission { // role_permission.table.comment type RolePermission struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // field.foreign_key.comment RoleId int64 `protobuf:"varint,2,opt,name=role_id,proto3" json:"role_id,omitempty"` // field.foreign_key.comment - PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *RolePermission) Reset() { @@ -2614,14 +2590,13 @@ func (x *RolePermission) GetPermissionId() int64 { // RolePermissionEdges holds the relations/edges for other nodes in the graph. type RolePermissionEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Role holds the value of the role edge. Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *RolePermissionEdges) Reset() { @@ -2670,10 +2645,7 @@ func (x *RolePermissionEdges) GetPermission() *Permission { // permission_resource.table.comment type PermissionResource struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -2682,7 +2654,9 @@ type PermissionResource struct { // field.foreign_key.comment ResourceId int64 `protobuf:"varint,3,opt,name=resource_id,proto3" json:"resource_id,omitempty"` // permission_resource.field.actions - Actions string `protobuf:"bytes,4,opt,name=actions,proto3" json:"actions,omitempty"` + Actions string `protobuf:"bytes,4,opt,name=actions,proto3" json:"actions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PermissionResource) Reset() { @@ -2745,14 +2719,13 @@ func (x *PermissionResource) GetActions() string { // PermissionResourceEdges holds the relations/edges for other nodes in the graph. type PermissionResourceEdges struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // Permission holds the value of the permission edge. Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` // Resource holds the value of the resource edge. - Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` + Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PermissionResourceEdges) Reset() { @@ -2801,575 +2774,282 @@ func (x *PermissionResourceEdges) GetResource() *Resource { var File_system_types_proto protoreflect.FileDescriptor -var file_system_types_proto_rawDesc = []byte{ - 0x0a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x1f, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb2, 0x05, - 0x0a, 0x04, 0x4d, 0x65, 0x6e, 0x75, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, - 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x31, 0x38, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x69, 0x31, 0x38, 0x6e, 0x5f, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, - 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x63, - 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x69, 0x65, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, - 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x18, 0x0d, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, - 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, - 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x0f, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x12, 0x38, - 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x15, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x08, - 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, 0x34, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, - 0x6e, 0x74, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x3e, - 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x17, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x32, - 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x18, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, - 0x65, 0x73, 0x22, 0xb1, 0x02, 0x0a, 0x09, 0x4d, 0x65, 0x6e, 0x75, 0x45, 0x64, 0x67, 0x65, 0x73, - 0x12, 0x38, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, - 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, 0x34, 0x0a, 0x06, 0x70, 0x61, - 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, - 0x12, 0x3e, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, - 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, 0x72, - 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x40, 0x0a, 0x0a, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6d, 0x65, 0x6e, - 0x75, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x0a, 0x72, 0x6f, 0x6c, 0x65, - 0x5f, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x22, 0x82, 0x05, 0x0a, 0x04, 0x52, 0x6f, 0x6c, 0x65, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, - 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, - 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6b, - 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, - 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, - 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x5f, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x12, 0x32, 0x0a, 0x05, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x18, 0x15, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x05, - 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x12, 0x32, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x16, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x17, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x18, 0x20, 0x03, 0x28, 0x03, 0x52, - 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x12, 0x44, 0x0a, - 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x19, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0e, 0x70, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x73, 0x22, 0xf7, 0x01, 0x0a, 0x09, - 0x52, 0x6f, 0x6c, 0x65, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x05, 0x6d, 0x65, 0x6e, - 0x75, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x05, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x12, 0x32, 0x0a, - 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, - 0x73, 0x12, 0x40, 0x0a, 0x0a, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6d, 0x65, 0x6e, 0x75, 0x73, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, - 0x6f, 0x6c, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x0a, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6d, 0x65, - 0x6e, 0x75, 0x73, 0x12, 0x40, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x6f, 0x6c, 0x65, - 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, 0xab, 0x07, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x24, - 0x0a, 0x0d, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x61, 0x75, - 0x74, 0x68, 0x6f, 0x72, 0x12, 0x24, 0x0a, 0x0d, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x61, - 0x75, 0x74, 0x68, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x75, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x6c, - 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x69, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, - 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x69, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, - 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, - 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x0a, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, - 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, - 0x72, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, - 0x72, 0x64, 0x12, 0x2a, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x5f, 0x70, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x12, - 0x0a, 0x04, 0x73, 0x61, 0x6c, 0x74, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x61, - 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, - 0x6c, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x16, - 0x0a, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, - 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x16, 0x0a, 0x06, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, - 0x69, 0x6e, 0x5f, 0x69, 0x70, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6c, 0x61, 0x73, - 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x69, 0x70, 0x12, 0x44, 0x0a, 0x0f, 0x6c, 0x61, - 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x16, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x12, 0x45, 0x0a, 0x0d, 0x73, 0x61, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, 0x61, 0x74, - 0x65, 0x18, 0x17, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x48, 0x00, 0x52, 0x0d, 0x73, 0x61, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, - 0x64, 0x61, 0x74, 0x65, 0x88, 0x01, 0x01, 0x12, 0x1e, 0x0a, 0x0a, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x18, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6d, 0x61, 0x6e, - 0x61, 0x67, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, - 0x65, 0x72, 0x18, 0x19, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, - 0x72, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, - 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, - 0x73, 0x18, 0x1b, 0x20, 0x03, 0x28, 0x03, 0x52, 0x08, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, - 0x73, 0x42, 0x10, 0x0a, 0x0e, 0x5f, 0x73, 0x61, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x64, - 0x61, 0x74, 0x65, 0x22, 0x81, 0x01, 0x0a, 0x09, 0x55, 0x73, 0x65, 0x72, 0x45, 0x64, 0x67, 0x65, - 0x73, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x05, - 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x40, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x6f, - 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x0a, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, 0xcc, 0x02, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, - 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, - 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, - 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, 0x6f, 0x6c, - 0x65, 0x5f, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, - 0x75, 0x73, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x16, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, - 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x73, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, - 0x6c, 0x65, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0xae, 0x02, 0x0a, 0x08, - 0x52, 0x6f, 0x6c, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, - 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, - 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x6e, 0x75, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x07, 0x6d, 0x65, 0x6e, 0x75, 0x5f, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, - 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x6d, 0x65, - 0x6e, 0x75, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x73, 0x0a, 0x0d, - 0x52, 0x6f, 0x6c, 0x65, 0x4d, 0x65, 0x6e, 0x75, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, - 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, - 0x30, 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, - 0x75, 0x22, 0x93, 0x07, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, - 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, - 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, - 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x31, 0x38, 0x6e, - 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x31, 0x38, 0x6e, - 0x5f, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x70, 0x61, 0x74, 0x68, 0x12, 0x1c, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, - 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, - 0x6f, 0x6d, 0x70, 0x6f, 0x6e, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x63, 0x6f, 0x6e, - 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x63, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, - 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, - 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, - 0x62, 0x6c, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, - 0x6c, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, - 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, - 0x12, 0x50, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x11, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, - 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, - 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, - 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x15, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, - 0x12, 0x38, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x70, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x17, 0x20, 0x03, - 0x28, 0x03, 0x52, 0x0e, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, - 0x64, 0x73, 0x12, 0x44, 0x0a, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x73, 0x18, 0x18, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x70, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x50, 0x72, 0x6f, 0x70, - 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x41, 0x0a, 0x0d, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x04, 0x6d, 0x65, 0x6e, 0x75, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x4d, 0x65, 0x6e, 0x75, 0x52, 0x04, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0xea, 0x03, 0x0a, 0x0a, 0x44, - 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x72, 0x65, 0x65, 0x5f, 0x70, 0x61, 0x74, - 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x16, 0x0a, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x09, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x20, 0x0a, 0x0b, 0x64, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, - 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x12, 0x3e, 0x0a, 0x08, 0x63, - 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, 0x3a, 0x0a, 0x06, 0x70, - 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, - 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x22, 0xd5, 0x02, 0x0a, 0x0f, 0x44, 0x65, 0x70, 0x61, - 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x05, 0x75, - 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, - 0x3e, 0x0a, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, - 0x3e, 0x0a, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, - 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x63, 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, - 0x3a, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x52, 0x0a, 0x10, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x18, - 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x10, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, - 0xa3, 0x01, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0d, - 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, - 0x69, 0x64, 0x12, 0x41, 0x0a, 0x05, 0x65, 0x64, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, - 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x64, 0x67, 0x65, 0x73, 0x52, 0x05, - 0x65, 0x64, 0x67, 0x65, 0x73, 0x22, 0x8b, 0x01, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, - 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, - 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, - 0x42, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x70, - 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, - 0x65, 0x6e, 0x74, 0x22, 0x8c, 0x02, 0x0a, 0x08, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, - 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, - 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, - 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x24, 0x0a, 0x0d, - 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x07, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x0d, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x5f, - 0x69, 0x64, 0x22, 0xfb, 0x02, 0x0a, 0x0d, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x45, - 0x64, 0x67, 0x65, 0x73, 0x12, 0x42, 0x0a, 0x0a, 0x64, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x44, 0x65, 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0a, 0x64, 0x65, - 0x70, 0x61, 0x72, 0x74, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x32, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x44, 0x0a, 0x0b, - 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x73, 0x12, 0x4c, 0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x52, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x5e, 0x0a, 0x14, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, - 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x14, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, - 0x22, 0xfd, 0x03, 0x0a, 0x0a, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x3c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x52, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x3c, 0x0a, - 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0b, - 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x64, - 0x61, 0x74, 0x61, 0x5f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0a, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x12, 0x51, 0x0a, 0x0a, 0x64, - 0x61, 0x74, 0x61, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x31, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x22, - 0x0a, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x09, - 0x20, 0x03, 0x28, 0x03, 0x52, 0x0c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, - 0x64, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, - 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x73, 0x1a, 0x3c, 0x0a, 0x0e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x22, 0xd9, 0x03, 0x0a, 0x0f, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x45, - 0x64, 0x67, 0x65, 0x73, 0x12, 0x32, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, - 0x65, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x3e, 0x0a, 0x09, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, - 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x70, - 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x52, 0x0a, 0x10, 0x72, 0x6f, 0x6c, 0x65, - 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, - 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x10, 0x72, 0x6f, 0x6c, 0x65, - 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5e, 0x0a, 0x14, - 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x14, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x5e, 0x0a, 0x14, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x14, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x5a, 0x0a, 0x0c, - 0x55, 0x73, 0x65, 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, - 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x70, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x83, 0x01, 0x0a, 0x11, 0x55, 0x73, 0x65, - 0x72, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, - 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, - 0x12, 0x3c, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x6c, - 0x0a, 0x12, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x70, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, - 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x9b, 0x01, 0x0a, - 0x17, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, 0x3c, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x6f, - 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x42, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, - 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x60, 0x0a, 0x0e, 0x52, 0x6f, - 0x6c, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, - 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x72, - 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, - 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x22, 0x8b, 0x01, 0x0a, - 0x13, 0x52, 0x6f, 0x6c, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x45, - 0x64, 0x67, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x6f, 0x6c, 0x65, - 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x42, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, - 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x86, 0x01, 0x0a, 0x12, 0x50, - 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, - 0x64, 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x22, 0x9b, 0x01, 0x0a, 0x17, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x45, 0x64, 0x67, 0x65, 0x73, 0x12, - 0x42, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x50, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x42, 0xbf, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x42, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x19, - 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, 0x41, 0x56, 0x53, 0x53, - 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, 0x41, 0x70, 0x69, 0x5c, - 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, - 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, 0x3a, 0x53, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_system_types_proto_rawDesc = "" + + "\n" + + "\x12system/types.proto\x12\x16api.v1.services.system\x1a\x1fgoogle/protobuf/timestamp.proto\"\xb2\x05\n" + + "\x04Menu\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12\x1a\n" + + "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12 \n" + + "\vdescription\x18\a \x01(\tR\vdescription\x12\x1a\n" + + "\bsequence\x18\b \x01(\x05R\bsequence\x12\x12\n" + + "\x04type\x18\t \x01(\tR\x04type\x12\x12\n" + + "\x04icon\x18\n" + + " \x01(\tR\x04icon\x12\x12\n" + + "\x04path\x18\v \x01(\tR\x04path\x12\x1e\n" + + "\n" + + "properties\x18\f \x01(\tR\n" + + "properties\x12\x16\n" + + "\x06status\x18\r \x01(\x05R\x06status\x12\x1c\n" + + "\tparent_id\x18\x0e \x01(\x03R\tparent_id\x12 \n" + + "\vparent_path\x18\x0f \x01(\tR\vparent_path\x128\n" + + "\bchildren\x18\x15 \x03(\v2\x1c.api.v1.services.system.MenuR\bchildren\x124\n" + + "\x06parent\x18\x16 \x01(\v2\x1c.api.v1.services.system.MenuR\x06parent\x12>\n" + + "\tresources\x18\x17 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x122\n" + + "\x05roles\x18\x18 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\"\xb1\x02\n" + + "\tMenuEdges\x128\n" + + "\bchildren\x18\x01 \x03(\v2\x1c.api.v1.services.system.MenuR\bchildren\x124\n" + + "\x06parent\x18\x02 \x01(\v2\x1c.api.v1.services.system.MenuR\x06parent\x12>\n" + + "\tresources\x18\x03 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x122\n" + + "\x05roles\x18\x04 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\x12@\n" + + "\n" + + "role_menus\x18\x05 \x03(\v2 .api.v1.services.system.RoleMenuR\n" + + "role_menus\"\x82\x05\n" + + "\x04Role\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x12\n" + + "\x04type\x18\a \x01(\x05R\x04type\x12\x1a\n" + + "\bsequence\x18\b \x01(\x05R\bsequence\x12\x16\n" + + "\x06status\x18\t \x01(\x05R\x06status\x12\x1c\n" + + "\tis_system\x18\n" + + " \x01(\bR\tis_system\x122\n" + + "\x05menus\x18\x15 \x03(\v2\x1c.api.v1.services.system.MenuR\x05menus\x122\n" + + "\x05users\x18\x16 \x03(\v2\x1c.api.v1.services.system.UserR\x05users\x12>\n" + + "\tresources\x18\x17 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x12\"\n" + + "\fresource_ids\x18\x18 \x03(\x03R\fresource_ids\x12D\n" + + "\vpermissions\x18\x19 \x03(\v2\".api.v1.services.system.PermissionR\vpermissions\x12&\n" + + "\x0epermission_ids\x18\x1a \x03(\x03R\x0epermission_ids\"\xf7\x01\n" + + "\tRoleEdges\x122\n" + + "\x05menus\x18\x01 \x03(\v2\x1c.api.v1.services.system.MenuR\x05menus\x122\n" + + "\x05users\x18\x02 \x03(\v2\x1c.api.v1.services.system.UserR\x05users\x12@\n" + + "\n" + + "role_menus\x18\x03 \x03(\v2 .api.v1.services.system.RoleMenuR\n" + + "role_menus\x12@\n" + + "\n" + + "user_roles\x18\x04 \x03(\v2 .api.v1.services.system.UserRoleR\n" + + "user_roles\"\xab\a\n" + + "\x04User\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + + "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + + "\rupdate_author\x18\x03 \x01(\x03R\rupdate_author\x12<\n" + + "\vcreate_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04uuid\x18\x06 \x01(\tR\x04uuid\x12\x1e\n" + + "\n" + + "allowed_ip\x18\a \x01(\tR\n" + + "allowed_ip\x12\x1a\n" + + "\busername\x18\b \x01(\tR\busername\x12\x1a\n" + + "\bnickname\x18\t \x01(\tR\bnickname\x12\x16\n" + + "\x06avatar\x18\n" + + " \x01(\tR\x06avatar\x12\x12\n" + + "\x04name\x18\v \x01(\tR\x04name\x12\x16\n" + + "\x06gender\x18\f \x01(\tR\x06gender\x12\x1a\n" + + "\bpassword\x18\r \x01(\tR\bpassword\x12*\n" + + "\x10confirm_password\x18\x0e \x01(\tR\x10confirm_password\x12\x12\n" + + "\x04salt\x18\x0f \x01(\tR\x04salt\x12\x14\n" + + "\x05phone\x18\x10 \x01(\tR\x05phone\x12\x14\n" + + "\x05email\x18\x11 \x01(\tR\x05email\x12\x16\n" + + "\x06remark\x18\x12 \x01(\tR\x06remark\x12\x14\n" + + "\x05token\x18\x13 \x01(\tR\x05token\x12\x16\n" + + "\x06status\x18\x14 \x01(\x05R\x06status\x12$\n" + + "\rlast_login_ip\x18\x15 \x01(\tR\rlast_login_ip\x12D\n" + + "\x0flast_login_time\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12E\n" + + "\rsanction_date\x18\x17 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x12\x1e\n" + + "\n" + + "manager_id\x18\x18 \x01(\x03R\n" + + "manager_id\x12\x18\n" + + "\amanager\x18\x19 \x01(\tR\amanager\x122\n" + + "\x05roles\x18\x1a \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\x12\x1a\n" + + "\brole_ids\x18\x1b \x03(\x03R\brole_idsB\x10\n" + + "\x0e_sanction_date\"\x81\x01\n" + + "\tUserEdges\x122\n" + + "\x05roles\x18\x01 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\x12@\n" + + "\n" + + "user_roles\x18\x02 \x03(\v2 .api.v1.services.system.UserRoleR\n" + + "user_roles\"\xcc\x02\n" + + "\bUserRole\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\auser_id\x18\x04 \x01(\x03R\auser_id\x12\x18\n" + + "\arole_id\x18\x05 \x01(\x03R\arole_id\x12\x1c\n" + + "\trole_name\x18\x06 \x01(\tR\trole_name\x120\n" + + "\x04user\x18\x15 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x120\n" + + "\x04role\x18\x16 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"s\n" + + "\rUserRoleEdges\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x120\n" + + "\x04role\x18\x02 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"\xae\x02\n" + + "\bRoleMenu\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\arole_id\x18\x04 \x01(\x03R\arole_id\x12\x18\n" + + "\amenu_id\x18\x05 \x01(\x03R\amenu_id\x120\n" + + "\x04role\x18\x15 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\x120\n" + + "\x04menu\x18\x16 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"s\n" + + "\rRoleMenuEdges\x120\n" + + "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\x120\n" + + "\x04menu\x18\x02 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"\x93\a\n" + + "\bResource\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x1a\n" + + "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12\x12\n" + + "\x04type\x18\a \x01(\tR\x04type\x12\x16\n" + + "\x06status\x18\b \x01(\x05R\x06status\x12\x12\n" + + "\x04path\x18\t \x01(\tR\x04path\x12\x1c\n" + + "\toperation\x18\n" + + " \x01(\tR\toperation\x12\x16\n" + + "\x06method\x18\v \x01(\tR\x06method\x12\x1c\n" + + "\tcomponent\x18\f \x01(\tR\tcomponent\x12\x12\n" + + "\x04icon\x18\r \x01(\tR\x04icon\x12\x1a\n" + + "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x18\n" + + "\avisible\x18\x0f \x01(\bR\avisible\x12\x1c\n" + + "\ttree_path\x18\x10 \x01(\tR\ttree_path\x12P\n" + + "\n" + + "properties\x18\x11 \x03(\v20.api.v1.services.system.Resource.PropertiesEntryR\n" + + "properties\x12 \n" + + "\vdescription\x18\x12 \x01(\tR\vdescription\x12\x1c\n" + + "\tparent_id\x18\x13 \x01(\x03R\tparent_id\x12<\n" + + "\bchildren\x18\x15 \x03(\v2 .api.v1.services.system.ResourceR\bchildren\x128\n" + + "\x06parent\x18\x16 \x01(\v2 .api.v1.services.system.ResourceR\x06parent\x12&\n" + + "\x0epermission_ids\x18\x17 \x03(\x03R\x0epermission_ids\x12D\n" + + "\vpermissions\x18\x18 \x03(\v2\".api.v1.services.system.PermissionR\vpermissions\x1a=\n" + + "\x0fPropertiesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"A\n" + + "\rResourceEdges\x120\n" + + "\x04menu\x18\x01 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"\xea\x03\n" + + "\n" + + "Department\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12\x1c\n" + + "\ttree_path\x18\x06 \x01(\tR\ttree_path\x12\x1a\n" + + "\bsequence\x18\a \x01(\x05R\bsequence\x12\x16\n" + + "\x06status\x18\b \x01(\x05R\x06status\x12\x14\n" + + "\x05level\x18\t \x01(\x05R\x05level\x12 \n" + + "\vdescription\x18\n" + + " \x01(\tR\vdescription\x12\x1c\n" + + "\tparent_id\x18\v \x01(\x03R\tparent_id\x12>\n" + + "\bchildren\x18\f \x03(\v2\".api.v1.services.system.DepartmentR\bchildren\x12:\n" + + "\x06parent\x18\r \x01(\v2\".api.v1.services.system.DepartmentR\x06parent\"\xd5\x02\n" + + "\x0fDepartmentEdges\x122\n" + + "\x05users\x18\x01 \x03(\v2\x1c.api.v1.services.system.UserR\x05users\x12>\n" + + "\tpositions\x18\x02 \x03(\v2 .api.v1.services.system.PositionR\tpositions\x12>\n" + + "\bchildren\x18\x03 \x03(\v2\".api.v1.services.system.DepartmentR\bchildren\x12:\n" + + "\x06parent\x18\x04 \x01(\v2\".api.v1.services.system.DepartmentR\x06parent\x12R\n" + + "\x10user_departments\x18\x05 \x03(\v2&.api.v1.services.system.UserDepartmentR\x10user_departments\"\xa3\x01\n" + + "\x0eUserDepartment\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\auser_id\x18\x02 \x01(\x03R\auser_id\x12$\n" + + "\rdepartment_id\x18\x03 \x01(\x03R\rdepartment_id\x12A\n" + + "\x05edges\x18\x04 \x01(\v2+.api.v1.services.system.UserDepartmentEdgesR\x05edges\"\x8b\x01\n" + + "\x13UserDepartmentEdges\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x12B\n" + + "\n" + + "department\x18\x02 \x01(\v2\".api.v1.services.system.DepartmentR\n" + + "department\"\x8c\x02\n" + + "\bPosition\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12$\n" + + "\rdepartment_id\x18\a \x01(\x03R\rdepartment_id\"\xfb\x02\n" + + "\rPositionEdges\x12B\n" + + "\n" + + "department\x18\x01 \x01(\v2\".api.v1.services.system.DepartmentR\n" + + "department\x122\n" + + "\x05users\x18\x02 \x03(\v2\x1c.api.v1.services.system.UserR\x05users\x12D\n" + + "\vpermissions\x18\x03 \x03(\v2\".api.v1.services.system.PermissionR\vpermissions\x12L\n" + + "\x0euser_positions\x18\x04 \x03(\v2$.api.v1.services.system.UserPositionR\x0euser_positions\x12^\n" + + "\x14position_permissions\x18\x05 \x03(\v2*.api.v1.services.system.PositionPermissionR\x14position_permissions\"\xfd\x03\n" + + "\n" + + "Permission\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x1e\n" + + "\n" + + "data_scope\x18\a \x01(\tR\n" + + "data_scope\x12Q\n" + + "\n" + + "data_rules\x18\b \x03(\v21.api.v1.services.system.Permission.DataRulesEntryR\n" + + "data_rules\x12\"\n" + + "\fresource_ids\x18\t \x03(\x03R\fresource_ids\x12>\n" + + "\tresources\x18\n" + + " \x03(\v2 .api.v1.services.system.ResourceR\tresources\x1a<\n" + + "\x0eDataRulesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xd9\x03\n" + + "\x0fPermissionEdges\x122\n" + + "\x05roles\x18\x01 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\x12>\n" + + "\tresources\x18\x02 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x12>\n" + + "\tpositions\x18\x03 \x03(\v2 .api.v1.services.system.PositionR\tpositions\x12R\n" + + "\x10role_permissions\x18\x04 \x03(\v2&.api.v1.services.system.RolePermissionR\x10role_permissions\x12^\n" + + "\x14permission_resources\x18\x05 \x03(\v2*.api.v1.services.system.PermissionResourceR\x14permission_resources\x12^\n" + + "\x14position_permissions\x18\x06 \x03(\v2*.api.v1.services.system.PositionPermissionR\x14position_permissions\"Z\n" + + "\fUserPosition\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\auser_id\x18\x02 \x01(\x03R\auser_id\x12 \n" + + "\vposition_id\x18\x03 \x01(\x03R\vposition_id\"\x83\x01\n" + + "\x11UserPositionEdges\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x12<\n" + + "\bposition\x18\x02 \x01(\v2 .api.v1.services.system.PositionR\bposition\"l\n" + + "\x12PositionPermission\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12 \n" + + "\vposition_id\x18\x02 \x01(\x03R\vposition_id\x12$\n" + + "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x9b\x01\n" + + "\x17PositionPermissionEdges\x12<\n" + + "\bposition\x18\x01 \x01(\v2 .api.v1.services.system.PositionR\bposition\x12B\n" + + "\n" + + "permission\x18\x02 \x01(\v2\".api.v1.services.system.PermissionR\n" + + "permission\"`\n" + + "\x0eRolePermission\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\arole_id\x18\x02 \x01(\x03R\arole_id\x12$\n" + + "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x8b\x01\n" + + "\x13RolePermissionEdges\x120\n" + + "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\x12B\n" + + "\n" + + "permission\x18\x02 \x01(\v2\".api.v1.services.system.PermissionR\n" + + "permission\"\x86\x01\n" + + "\x12PermissionResource\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + + "\rpermission_id\x18\x02 \x01(\x03R\rpermission_id\x12 \n" + + "\vresource_id\x18\x03 \x01(\x03R\vresource_id\x12\x18\n" + + "\aactions\x18\x04 \x01(\tR\aactions\"\x9b\x01\n" + + "\x17PermissionResourceEdges\x12B\n" + + "\n" + + "permission\x18\x01 \x01(\v2\".api.v1.services.system.PermissionR\n" + + "permission\x12<\n" + + "\bresource\x18\x02 \x01(\v2 .api.v1.services.system.ResourceR\bresourceB\xbf\x01\n" + + "\x1acom.api.v1.services.systemB\n" + + "TypesProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_types_proto_rawDescOnce sync.Once - file_system_types_proto_rawDescData = file_system_types_proto_rawDesc + file_system_types_proto_rawDescData []byte ) func file_system_types_proto_rawDescGZIP() []byte { file_system_types_proto_rawDescOnce.Do(func() { - file_system_types_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_types_proto_rawDescData) + file_system_types_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_types_proto_rawDesc), len(file_system_types_proto_rawDesc))) }) return file_system_types_proto_rawDescData } @@ -3510,7 +3190,7 @@ func file_system_types_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_types_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_types_proto_rawDesc), len(file_system_types_proto_rawDesc)), NumEnums: 0, NumMessages: 30, NumExtensions: 0, @@ -3521,7 +3201,6 @@ func file_system_types_proto_init() { MessageInfos: file_system_types_proto_msgTypes, }.Build() File_system_types_proto = out.File - file_system_types_proto_rawDesc = nil file_system_types_proto_goTypes = nil file_system_types_proto_depIdxs = nil } diff --git a/api/v1/services/system/types.pb.validate.go b/api/v1/services/system/types.pb.validate.go index f38b191e..31b35578 100644 --- a/api/v1/services/system/types.pb.validate.go +++ b/api/v1/services/system/types.pb.validate.go @@ -284,7 +284,7 @@ type MenuMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m MenuMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -548,7 +548,7 @@ type MenuEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m MenuEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -856,7 +856,7 @@ type RoleMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RoleMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1091,7 +1091,7 @@ type RoleEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RoleEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1385,7 +1385,7 @@ type UserMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UserMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1552,7 +1552,7 @@ type UserEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UserEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1775,7 +1775,7 @@ type UserRoleMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UserRoleMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1933,7 +1933,7 @@ type UserRoleEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UserRoleEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2154,7 +2154,7 @@ type RoleMenuMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RoleMenuMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2312,7 +2312,7 @@ type RoleMenuEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RoleMenuEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2600,7 +2600,7 @@ type ResourceMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ResourceMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2729,7 +2729,7 @@ type ResourceEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ResourceEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2967,7 +2967,7 @@ type DepartmentMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DepartmentMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -3232,7 +3232,7 @@ type DepartmentEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DepartmentEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -3367,7 +3367,7 @@ type UserDepartmentMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UserDepartmentMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -3525,7 +3525,7 @@ type UserDepartmentEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UserDepartmentEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -3694,7 +3694,7 @@ type PositionMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PositionMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -3959,7 +3959,7 @@ type PositionEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PositionEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -4162,7 +4162,7 @@ type PermissionMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PermissionMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -4466,7 +4466,7 @@ type PermissionEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PermissionEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -4571,7 +4571,7 @@ type UserPositionMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UserPositionMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -4729,7 +4729,7 @@ type UserPositionEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UserPositionEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -4837,7 +4837,7 @@ type PositionPermissionMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PositionPermissionMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -4997,7 +4997,7 @@ type PositionPermissionEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PositionPermissionEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -5105,7 +5105,7 @@ type RolePermissionMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RolePermissionMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -5263,7 +5263,7 @@ type RolePermissionEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RolePermissionEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -5373,7 +5373,7 @@ type PermissionResourceMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PermissionResourceMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -5533,7 +5533,7 @@ type PermissionResourceEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PermissionResourceEdgesMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go index 50ae5f40..c9783b2c 100644 --- a/api/v1/services/system/user.pb.go +++ b/api/v1/services/system/user.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: system/user.proto @@ -14,6 +14,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -24,11 +25,10 @@ const ( ) type ListUserResourcesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ListUserResourcesRequest) Reset() { @@ -69,12 +69,11 @@ func (x *ListUserResourcesRequest) GetId() int64 { } type ListUserResourcesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` + Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` unknownFields protoimpl.UnknownFields - - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ListUserResourcesResponse) Reset() { @@ -122,11 +121,10 @@ func (x *ListUserResourcesResponse) GetResources() []*Resource { } type UpdateUserStatusRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields - - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdateUserStatusRequest) Reset() { @@ -167,9 +165,9 @@ func (x *UpdateUserStatusRequest) GetUser() *User { } type UpdateUserStatusResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdateUserStatusResponse) Reset() { @@ -203,12 +201,11 @@ func (*UpdateUserStatusResponse) Descriptor() ([]byte, []int) { } type ResetUserPasswordRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ResetUserPasswordRequest) Reset() { @@ -256,9 +253,9 @@ func (x *ResetUserPasswordRequest) GetData() *anypb.Any { } type ResetUserPasswordResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ResetUserPasswordResponse) Reset() { @@ -292,10 +289,7 @@ func (*ResetUserPasswordResponse) Descriptor() ([]byte, []int) { } type ListUsersRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id, for example, "shelves/shelf1". Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The current page number. @@ -309,7 +303,9 @@ type ListUsersRequest struct { // The only_count is the query parameter for set only to query the total number OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` // The title query parameter for set only to query the title - Title string `protobuf:"bytes,7,opt,name=title,proto3" json:"title,omitempty"` + Title string `protobuf:"bytes,7,opt,name=title,proto3" json:"title,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListUsersRequest) Reset() { @@ -392,10 +388,7 @@ func (x *ListUsersRequest) GetTitle() string { } type ListUsersResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus @@ -409,7 +402,9 @@ type ListUsersResponse struct { NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` // Additional information about this response. // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ListUsersResponse) Reset() { @@ -485,13 +480,12 @@ func (x *ListUsersResponse) GetExtra() *anypb.Any { } type GetUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The field will contain id of the resource requested, for example: // "shelves/shelf1/users/user2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GetUserRequest) Reset() { @@ -532,11 +526,10 @@ func (x *GetUserRequest) GetId() int64 { } type GetUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields - - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GetUserResponse) Reset() { @@ -577,10 +570,7 @@ func (x *GetUserResponse) GetUser() *User { } type CreateUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The parent resource id where the user is to be created. Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` // The user resource to be created. @@ -591,6 +581,8 @@ type CreateUserRequest struct { IsSystem bool `protobuf:"varint,4,opt,name=is_system,proto3" json:"is_system,omitempty"` // The random_password is the query parameter for set only to generate a random password RandomPassword bool `protobuf:"varint,5,opt,name=random_password,proto3" json:"random_password,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CreateUserRequest) Reset() { @@ -659,11 +651,10 @@ func (x *CreateUserRequest) GetRandomPassword() bool { } type CreateUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields - - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + sizeCache protoimpl.SizeCache } func (x *CreateUserResponse) Reset() { @@ -704,10 +695,7 @@ func (x *CreateUserResponse) GetUser() *User { } type UpdateUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The user resource which replaces the resource on the server. User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` // The user id to use for this user. @@ -716,6 +704,8 @@ type UpdateUserRequest struct { IsSystem bool `protobuf:"varint,4,opt,name=is_system,proto3" json:"is_system,omitempty"` // The random_password is the query parameter for set only to generate a random password RandomPassword bool `protobuf:"varint,2,opt,name=random_password,proto3" json:"random_password,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdateUserRequest) Reset() { @@ -777,11 +767,10 @@ func (x *UpdateUserRequest) GetRandomPassword() bool { } type UpdateUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields - - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdateUserResponse) Reset() { @@ -822,13 +811,12 @@ func (x *UpdateUserResponse) GetUser() *User { } type DeleteUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The resource id of the user to be deleted, for example: // "shelves/shelf1/users/user2" - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *DeleteUserRequest) Reset() { @@ -869,11 +857,10 @@ func (x *DeleteUserRequest) GetUser() *User { } type DeleteUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` unknownFields protoimpl.UnknownFields - - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DeleteUserResponse) Reset() { @@ -914,13 +901,12 @@ func (x *DeleteUserResponse) GetEmpty() *emptypb.Empty { } type UpdateUserRolesRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + User *User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` + RoleIds []int64 `protobuf:"varint,3,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` // bool is_add = 5 [json_name = "is_add"]; unknownFields protoimpl.UnknownFields - - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - User *User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` - RoleIds []int64 `protobuf:"varint,3,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` // bool is_add = 5 [json_name = "is_add"]; + sizeCache protoimpl.SizeCache } func (x *UpdateUserRolesRequest) Reset() { @@ -975,11 +961,10 @@ func (x *UpdateUserRolesRequest) GetRoleIds() []int64 { } type UpdateUserRolesResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields - - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdateUserRolesResponse) Reset() { @@ -1021,233 +1006,100 @@ func (x *UpdateUserRolesResponse) GetUser() *User { var File_system_user_proto protoreflect.FileDescriptor -var file_system_user_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x16, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x12, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2a, 0x0a, 0x18, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, - 0x64, 0x22, 0x7b, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1e, - 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x3e, - 0x0a, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x20, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x52, 0x09, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x22, 0x4b, - 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x1a, 0x0a, 0x18, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x54, 0x0a, 0x18, 0x52, 0x65, 0x73, 0x65, 0x74, - 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x02, 0x69, 0x64, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x1b, 0x0a, - 0x19, 0x52, 0x65, 0x73, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, - 0x72, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xce, 0x01, 0x0a, 0x10, 0x4c, - 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, - 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, - 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x5f, - 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x61, 0x67, - 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x6f, 0x5f, 0x70, 0x61, - 0x67, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6e, 0x6f, 0x5f, 0x70, - 0x61, 0x67, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x0a, 0x0a, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6f, 0x6e, 0x6c, 0x79, 0x5f, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x22, 0x84, 0x02, 0x0a, 0x11, - 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, 0x69, 0x7a, - 0x65, 0x12, 0x32, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, - 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x12, - 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x28, 0x0a, - 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67, - 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x2f, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x48, 0x00, 0x52, 0x05, - 0x65, 0x78, 0x74, 0x72, 0x61, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x65, 0x78, 0x74, - 0x72, 0x61, 0x22, 0x20, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x02, 0x69, 0x64, 0x22, 0x43, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0xbf, 0x01, 0x0a, 0x11, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x16, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x5f, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x5f, 0x70, 0x61, 0x73, 0x73, - 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x72, 0x61, 0x6e, 0x64, - 0x6f, 0x6d, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x46, 0x0a, 0x12, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, - 0x73, 0x65, 0x72, 0x22, 0xa7, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, - 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x73, 0x79, 0x73, 0x74, - 0x65, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x5f, 0x73, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d, 0x5f, 0x70, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x72, 0x61, - 0x6e, 0x64, 0x6f, 0x6d, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x46, 0x0a, - 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x45, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, - 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x42, 0x0a, 0x12, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x2c, 0x0a, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x05, 0x65, 0x6d, 0x70, 0x74, 0x79, - 0x22, 0x76, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, - 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, - 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, - 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, - 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, - 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x08, - 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x69, 0x64, 0x73, 0x22, 0x4b, 0x0a, 0x17, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1c, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x04, 0x75, 0x73, 0x65, 0x72, 0x32, 0x8e, 0x0a, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x74, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x73, 0x12, 0x28, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, - 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x12, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0c, 0x12, - 0x0a, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x9b, 0x01, 0x0a, 0x11, - 0x4c, 0x69, 0x73, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x73, 0x12, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x21, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1b, 0x12, 0x19, - 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x2f, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x12, 0x73, 0x0a, 0x07, 0x47, 0x65, 0x74, - 0x55, 0x73, 0x65, 0x72, 0x12, 0x26, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x65, - 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x17, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x11, 0x12, 0x0f, 0x2f, - 0x73, 0x79, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x12, 0x7d, - 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x29, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x3a, 0x04, 0x75, 0x73, 0x65, - 0x72, 0x22, 0x0a, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x87, 0x01, - 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x29, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1c, 0x3a, 0x04, 0x75, 0x73, 0x65, - 0x72, 0x1a, 0x14, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x75, - 0x73, 0x65, 0x72, 0x2e, 0x69, 0x64, 0x7d, 0x12, 0x81, 0x01, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x29, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x2a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x2a, 0x14, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, - 0x73, 0x2f, 0x7b, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x69, 0x64, 0x7d, 0x12, 0xa0, 0x01, 0x0a, 0x10, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x12, 0x2f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x55, 0x73, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x3a, 0x04, 0x75, 0x73, 0x65, - 0x72, 0x1a, 0x1b, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x75, - 0x73, 0x65, 0x72, 0x2e, 0x69, 0x64, 0x7d, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x9c, - 0x01, 0x0a, 0x0f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, - 0x65, 0x73, 0x12, 0x2e, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x28, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x22, 0x3a, 0x04, 0x75, 0x73, 0x65, - 0x72, 0x1a, 0x1a, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x75, - 0x73, 0x65, 0x72, 0x2e, 0x69, 0x64, 0x7d, 0x2f, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x12, 0xa6, 0x01, - 0x0a, 0x11, 0x52, 0x65, 0x73, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x73, 0x73, 0x77, - 0x6f, 0x72, 0x64, 0x12, 0x30, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, 0x65, 0x73, - 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x2e, 0x52, - 0x65, 0x73, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x26, - 0x3a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x1e, 0x2f, 0x73, 0x79, 0x73, 0x2f, 0x75, 0x73, 0x65, - 0x72, 0x73, 0x2f, 0x7b, 0x69, 0x64, 0x7d, 0x2f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, - 0x2f, 0x72, 0x65, 0x73, 0x65, 0x74, 0x42, 0xbe, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x73, - 0x79, 0x73, 0x74, 0x65, 0x6d, 0x42, 0x09, 0x55, 0x73, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x19, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, - 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x3b, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xa2, 0x02, 0x04, - 0x41, 0x56, 0x53, 0x53, 0xaa, 0x02, 0x16, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0x2e, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xca, 0x02, 0x16, - 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, - 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0xe2, 0x02, 0x22, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x5c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x41, 0x70, - 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x3a, - 0x3a, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_system_user_proto_rawDesc = "" + + "\n" + + "\x11system/user.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"*\n" + + "\x18ListUserResourcesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"{\n" + + "\x19ListUserResourcesResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x12>\n" + + "\tresources\x18\x02 \x03(\v2 .api.v1.services.system.ResourceR\tresources\"K\n" + + "\x17UpdateUserStatusRequest\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"\x1a\n" + + "\x18UpdateUserStatusResponse\"T\n" + + "\x18ResetUserPasswordRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1b\n" + + "\x19ResetUserPasswordResponse\"\xce\x01\n" + + "\x10ListUsersRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x14\n" + + "\x05title\x18\a \x01(\tR\x05title\"\x84\x02\n" + + "\x11ListUsersResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x122\n" + + "\x05users\x18\x02 \x03(\v2\x1c.api.v1.services.system.UserR\x05users\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\" \n" + + "\x0eGetUserRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"C\n" + + "\x0fGetUserResponse\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"\xbf\x01\n" + + "\x11CreateUserRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x120\n" + + "\x04user\x18\x02 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x12\x18\n" + + "\auser_id\x18\x03 \x01(\tR\auser_id\x12\x1c\n" + + "\tis_system\x18\x04 \x01(\bR\tis_system\x12(\n" + + "\x0frandom_password\x18\x05 \x01(\bR\x0frandom_password\"F\n" + + "\x12CreateUserResponse\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"\xa7\x01\n" + + "\x11UpdateUserRequest\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x12\x18\n" + + "\auser_id\x18\x03 \x01(\tR\auser_id\x12\x1c\n" + + "\tis_system\x18\x04 \x01(\bR\tis_system\x12(\n" + + "\x0frandom_password\x18\x02 \x01(\bR\x0frandom_password\"F\n" + + "\x12UpdateUserResponse\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"E\n" + + "\x11DeleteUserRequest\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"B\n" + + "\x12DeleteUserResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"v\n" + + "\x16UpdateUserRolesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x120\n" + + "\x04user\x18\x02 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x12\x1a\n" + + "\brole_ids\x18\x03 \x03(\x03R\brole_ids\"K\n" + + "\x17UpdateUserRolesResponse\x120\n" + + "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user2\x8e\n" + + "\n" + + "\vUserService\x12t\n" + + "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + + "/sys/users\x12\x9b\x01\n" + + "\x11ListUserResources\x120.api.v1.services.system.ListUserResourcesRequest\x1a1.api.v1.services.system.ListUserResourcesResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/sys/users/{id}/resources\x12s\n" + + "\aGetUser\x12&.api.v1.services.system.GetUserRequest\x1a'.api.v1.services.system.GetUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/users/{id}\x12}\n" + + "\n" + + "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a*.api.v1.services.system.CreateUserResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04user\"\n" + + "/sys/users\x12\x87\x01\n" + + "\n" + + "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04user\x1a\x14/sys/users/{user.id}\x12\x81\x01\n" + + "\n" + + "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x1c\x82\xd3\xe4\x93\x02\x16*\x14/sys/users/{user.id}\x12\xa0\x01\n" + + "\x10UpdateUserStatus\x12/.api.v1.services.system.UpdateUserStatusRequest\x1a0.api.v1.services.system.UpdateUserStatusResponse\")\x82\xd3\xe4\x93\x02#:\x04user\x1a\x1b/sys/users/{user.id}/status\x12\x9c\x01\n" + + "\x0fUpdateUserRoles\x12..api.v1.services.system.UpdateUserRolesRequest\x1a/.api.v1.services.system.UpdateUserRolesResponse\"(\x82\xd3\xe4\x93\x02\":\x04user\x1a\x1a/sys/users/{user.id}/roles\x12\xa6\x01\n" + + "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\",\x82\xd3\xe4\x93\x02&:\x04data\"\x1e/sys/users/{id}/password/resetB\xbe\x01\n" + + "\x1acom.api.v1.services.systemB\tUserProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_user_proto_rawDescOnce sync.Once - file_system_user_proto_rawDescData = file_system_user_proto_rawDesc + file_system_user_proto_rawDescData []byte ) func file_system_user_proto_rawDescGZIP() []byte { file_system_user_proto_rawDescOnce.Do(func() { - file_system_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_system_user_proto_rawDescData) + file_system_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_user_proto_rawDesc), len(file_system_user_proto_rawDesc))) }) return file_system_user_proto_rawDescData } @@ -1328,7 +1180,7 @@ func file_system_user_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_system_user_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_user_proto_rawDesc), len(file_system_user_proto_rawDesc)), NumEnums: 0, NumMessages: 18, NumExtensions: 0, @@ -1339,7 +1191,6 @@ func file_system_user_proto_init() { MessageInfos: file_system_user_proto_msgTypes, }.Build() File_system_user_proto = out.File - file_system_user_proto_rawDesc = nil file_system_user_proto_goTypes = nil file_system_user_proto_depIdxs = nil } diff --git a/api/v1/services/system/user.pb.validate.go b/api/v1/services/system/user.pb.validate.go index 9fb11883..b9c2345d 100644 --- a/api/v1/services/system/user.pb.validate.go +++ b/api/v1/services/system/user.pb.validate.go @@ -73,7 +73,7 @@ type ListUserResourcesRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListUserResourcesRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -211,7 +211,7 @@ type ListUserResourcesResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListUserResourcesResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -342,7 +342,7 @@ type UpdateUserStatusRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateUserStatusRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -444,7 +444,7 @@ type UpdateUserStatusResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateUserStatusResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -577,7 +577,7 @@ type ResetUserPasswordRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ResetUserPasswordRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -679,7 +679,7 @@ type ResetUserPasswordResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ResetUserPasswordResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -795,7 +795,7 @@ type ListUsersRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListUsersRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -970,7 +970,7 @@ type ListUsersResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ListUsersResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1074,7 +1074,7 @@ type GetUserRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetUserRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1203,7 +1203,7 @@ type GetUserResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m GetUserResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1340,7 +1340,7 @@ type CreateUserRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateUserRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1471,7 +1471,7 @@ type CreateUserResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CreateUserResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1608,7 +1608,7 @@ type UpdateUserRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateUserRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1739,7 +1739,7 @@ type UpdateUserResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateUserResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -1870,7 +1870,7 @@ type DeleteUserRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeleteUserRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2001,7 +2001,7 @@ type DeleteUserResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DeleteUserResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2134,7 +2134,7 @@ type UpdateUserRolesRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateUserRolesRequestMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } @@ -2265,7 +2265,7 @@ type UpdateUserRolesResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m UpdateUserRolesResponseMultiError) Error() string { - var msgs []string + msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) } diff --git a/api/v1/services/system/user_http.pb.go b/api/v1/services/system/user_http.pb.go index beaedb51..fb90c3bf 100644 --- a/api/v1/services/system/user_http.pb.go +++ b/api/v1/services/system/user_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.2 +// - protoc-gen-go-http v2.8.4 // - protoc (unknown) // source: system/user.proto diff --git a/buf.lock b/buf.lock index 9f6ca431..017d2883 100644 --- a/buf.lock +++ b/buf.lock @@ -14,5 +14,5 @@ deps: commit: c2de25f14fa445a79a054214f31d17a8 digest: b5:3e4dac0d26ce9db17309aeb845f0efb38ec7db1af06ee3c6b8dce2f4f7f53f126d62233c4910410384ead7f0a0edb6448cb389e62d1e3da5e927c3a980828f0b - name: buf.build/origadmin/runtime - commit: 42c0e727146c4a8eb49d923613bedd0d - digest: b5:bb3df3f4838ddf189dc40459345a4f68c9806650d02efd92eaa71437e262358e1d2331593e391ba52d4c2a4d2906175d573e623ef183dc914ec3880cbd1444c5 + commit: d2bec5453e2743999effe8adee2bb328 + digest: b5:0f9a10fc5423ace00df29150f43ff21a5fe701e67c2ba059633eedc393344042d99a6ce08345e0acc6185cdb1ab04284a35ea782f0995998de81c7c58e552996 diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index d3a4b290..cb02edf9 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -6,22 +6,14 @@ package start import ( - "context" - "syscall" - - "github.com/gin-gonic/gin" "github.com/go-kratos/kratos/v2" - transhttp "github.com/go-kratos/kratos/v2/transport/http" - gwruntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" _ "github.com/origadmin/contrib/consul/config" _ "github.com/origadmin/contrib/consul/registry" - _ "github.com/origadmin/contrib/database" "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/registry" "github.com/spf13/cobra" + _ "origadmin/application/admin/contrib/database" "origadmin/application/admin/internal/loader" ) @@ -66,53 +58,27 @@ func Cmd() *cobra.Command { } func startCommandRun(cmd *cobra.Command, args []string) error { - r, err := runtime.Load(flags, func(options *runtime.Options) { - // Set your runtime options. - }) - if err != nil { + if err := loader.Bootstrap(cmd.Context(), flags, buildInjectors); err != nil { return err } - - var registrar registry.KRegistrar - if flags.IsMainService() { - registrar, _ = registry.NewConsulRegistrar() - } - - buildInjectors() - - r.CreateApp(cmd.Context()) - - // 组合使用配置和服务 - appInstance := loader.NewApp(cmd.Context(), loader.AppOptions{ - Name: bs.ServiceName, - Version: flags.Version(), - Server: grpcServer, - }) + //var registrar registry.KRegistrar + //if flags.IsMainService() { + // registrar, _ = registry.NewConsulRegistrar() + //} + // + //buildInjectors() + // + //r.CreateApp(cmd.Context()) + // + //// 组合使用配置和服务 + //appInstance := loader.NewApp(cmd.Context(), loader.AppOptions{ + // Name: bs.ServiceName, + // Version: flags.Version(), + // Server: grpcServer, + //}) + return nil } -func NewApp(ctx context.Context, injector *loader.InjectorClient) *kratos.App { - opts := []kratos.Option{ - kratos.ID(flags.ServiceID()), - kratos.Name(flags.ServiceName()), - kratos.Version(flags.Version()), - kratos.Metadata(map[string]string{}), - kratos.Context(ctx), - kratos.Signal(syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT), - kratos.Logger(injector.Logger), - kratos.Server(injector.Server), - } - mux := gwruntime.NewServeMux() - srv := transhttp.NewServer() - srv.Handler = mux - kratos.Server(srv) - - if flags.Env() == "release" { - gin.SetMode(gin.ReleaseMode) - } - - gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) { - log.Infow("msg", "GIN route", "method", httpMethod, "path", absolutePath, "operation", handlerName, "handlers", nuHandlers) - } - - return kratos.New(opts...) +func NewAppProvider(r runtime.Runtime, injector *loader.InjectorClient) *kratos.App { + return r.CreateApp(injector.Server) } diff --git a/cmd/internal/start/wire.go b/cmd/internal/start/wire.go index cf9681d2..86cd8816 100644 --- a/cmd/internal/start/wire.go +++ b/cmd/internal/start/wire.go @@ -9,23 +9,20 @@ package start import ( - "context" - "github.com/go-kratos/kratos/v2" "github.com/google/wire" + "github.com/origadmin/runtime" "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/loader" - "origadmin/application/admin/internal/mods/agent" - "origadmin/application/admin/internal/mods/system/server" ) // buildInjectors init kratos application. -func buildInjectors(context.Context, *configs.Bootstrap) (*kratos.App, func(), error) { +func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { panic(wire.Build( loader.ProviderSet, - agent.ProviderSet, - server.ProviderSet, + //agent.ProviderSet, + //server.ProviderSet, //basisserver.ProviderSet, - NewApp)) + NewAppProvider)) } diff --git a/cmd/internal/start/wire_gen.go b/cmd/internal/start/wire_gen.go index 9c604a8a..d96a2368 100644 --- a/cmd/internal/start/wire_gen.go +++ b/cmd/internal/start/wire_gen.go @@ -7,42 +7,27 @@ package start import ( - "context" "github.com/go-kratos/kratos/v2" - "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime" "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/loader" - "origadmin/application/admin/internal/mods/agent" - "origadmin/application/admin/internal/mods/system/server" ) import ( _ "github.com/origadmin/contrib/consul/config" _ "github.com/origadmin/contrib/consul/registry" - _ "github.com/origadmin/contrib/database" + _ "origadmin/application/admin/contrib/database" ) // Injectors from wire.go: // buildInjectors init kratos application. -func buildInjectors(contextContext context.Context, bootstrap *configs.Bootstrap, arg log.KLogger) (*kratos.App, func(), error) { - v, err := server.NewSystemClient(bootstrap, arg) - if err != nil { - return nil, nil, err - } - registerAgent, err := server.NewSystemServiceAgentClient(v, arg) - if err != nil { - return nil, nil, err - } - v2 := agent.NewRegisterAgent(registerAgent) - casbinSourceServiceClient := server.NewCasbinServiceClient(v, arg) - httpServer := agent.NewHTTPServerAgent(bootstrap, v2, casbinSourceServiceClient, arg) +func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { + server := loader.MockHttpServer() injectorClient := &loader.InjectorClient{ - Logger: arg, - Bootstrap: bootstrap, - Server: httpServer, + Server: server, } - app := NewApp(contextContext, injectorClient) + app := NewAppProvider(r, injectorClient) return app, func() { }, nil } diff --git a/cmd/system/main.go b/cmd/system/main.go index 5056c089..80928f31 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -13,11 +13,11 @@ import ( "github.com/go-kratos/kratos/v2" _ "github.com/origadmin/contrib/consul/config" _ "github.com/origadmin/contrib/consul/registry" - _ "github.com/origadmin/contrib/database" "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" + _ "origadmin/application/admin/contrib/database" "origadmin/application/admin/internal/loader" ) diff --git a/cmd/system/wire.go b/cmd/system/wire.go index 6ad7e7d1..d31ed0e7 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -27,7 +27,7 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap panic(wire.Build( loader.ProviderSet, data.ProviderSet, - //basisdal.ProviderSet, + //authdal.ProviderSet, //basisbiz.ProviderSet, //basisservice.ProviderSet, //basisserver.ProviderSet, diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index c8c48be2..d25c7edc 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -9,8 +9,8 @@ package main import ( "github.com/go-kratos/kratos/v2" "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/loader" "origadmin/application/admin/internal/mods/system/biz" "origadmin/application/admin/internal/mods/system/dal" @@ -21,7 +21,7 @@ import ( import ( _ "github.com/origadmin/contrib/consul/config" _ "github.com/origadmin/contrib/consul/registry" - _ "github.com/origadmin/contrib/database" + _ "origadmin/application/admin/contrib/database" ) // Injectors from wire.go: @@ -32,52 +32,24 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap if err != nil { return nil, nil, err } - data, cleanup, err := dal.NewData(bootstrap, logger) + dataData, cleanup, err := data.NewData(r, bootstrap) if err != nil { return nil, nil, err } - resourceRepo := dal.NewResourceRepo(data, logger) - resourceServiceBiz := biz.NewResourceServiceBiz(resourceRepo, logger) + resourceRepo := dal.NewResourceRepo(r, dataData) + resourceServiceBiz := biz.NewResourceServiceBiz(r, resourceRepo) resourceServiceServer := service.NewResourceServiceServerPB(resourceServiceBiz) - roleRepo := dal.NewRoleRepo(data, logger) - roleServiceBiz := biz.NewRoleServiceBiz(roleRepo, logger) + roleRepo := dal.NewRoleRepo(r, dataData) + roleServiceBiz := biz.NewRoleServiceBiz(r, roleRepo) roleServiceServer := service.NewRoleServiceServerPB(roleServiceBiz) - userRepo := dal.NewUserRepo(data, logger) - userServiceBiz := biz.NewUserServiceBiz(userRepo, logger) + userRepo := dal.NewUserRepo(r, dataData) + userServiceBiz := biz.NewUserServiceBiz(r, userRepo) userServiceServer := service.NewUserServiceServerPB(userServiceBiz) - authRepo := dal.NewAuthRepo(data, logger) - authServiceBiz := biz.NewAuthServiceBiz(authRepo, logger) - authServiceServer := service.NewAuthServiceServerPB(authServiceBiz) - tokenizer, err := loader.NewTokenizer(bootstrap) - if err != nil { - cleanup() - return nil, nil, err - } - refreshTokenizer := dal.RefreshTokenizer(tokenizer) - loginData := &dal.LoginData{ - Tokenizer: refreshTokenizer, - Resource: resourceRepo, - Role: roleRepo, - User: userRepo, - } - loginRepo := dal.NewLoginRepo(loginData, logger) - loginServiceBiz := biz.NewLoginServiceBiz(loginRepo, logger) - loginServiceServer := service.NewLoginServiceServerPB(loginServiceBiz) - personalRepo := dal.NewPersonalRepo(data, logger) - personalServiceBiz := biz.NewPersonalServiceBiz(personalRepo, logger) - personalServiceServer := service.NewPersonalServiceServerPB(personalServiceBiz) - permissionRepo := dal.NewPermissionRepo(data, logger) - permissionServiceBiz := biz.NewPermissionServiceBiz(permissionRepo, logger) + permissionRepo := dal.NewPermissionRepo(r, dataData) + permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) permissionServiceServer := service.NewPermissionServiceServerPB(permissionServiceBiz) - casbinSourceRepo, err := dal.NewCasbinSourceRepo(data) - if err != nil { - cleanup() - return nil, nil, err - } - casbinSourceServiceBiz := biz.NewCasbinSourceServiceBiz(casbinSourceRepo, logger) - casbinSourceServiceServer := service.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) - v2 := server.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, authServiceServer, loginServiceServer, personalServiceServer, permissionServiceServer, casbinSourceServiceServer) - v3 := server.NewSystemServer(bootstrap, v2, logger) + v2 := server.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + v3 := server.NewSystemServer(r, bootstrap, v2) injector := &loader.Injector{ Registrar: v, Servers: v3, diff --git a/contrib/database/const.go b/contrib/database/const.go new file mode 100644 index 00000000..a4de500b --- /dev/null +++ b/contrib/database/const.go @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package database implements the functions, types, and interfaces for the module. +package database + +import ( + "context" + "database/sql/driver" + + "github.com/origadmin/runtime/interfaces/database" +) + +type ( + // Tx is a transaction aliased to driver.Tx + Tx = driver.Tx + // ExecFunc is a function that can be executed within a transaction + ExecFunc = func(context.Context) error + // TxFunc is a function that can be executed within a transaction + TxFunc = func(tx Tx) error + // Trans is a transaction interface + Trans database.Trans +) diff --git a/contrib/database/database.go b/contrib/database/database.go new file mode 100644 index 00000000..11970761 --- /dev/null +++ b/contrib/database/database.go @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package database implements the functions, types, and interfaces for the module. +package database + +import ( + "database/sql" + "time" + + configv1 "github.com/origadmin/runtime/gen/go/config/v1" + "github.com/origadmin/toolkits/errors" + + "origadmin/application/admin/contrib/database/internal/mysql" + "origadmin/application/admin/contrib/database/internal/sqlite" +) + +func Open(database *configv1.Database) (*sql.DB, error) { + if database == nil { + return nil, errors.New("config: database is nil") + } + switch database.Dialect { + case "mysql": + err := mysql.CreateDatabase(database.Source, "") + if err != nil { + return nil, errors.Wrap(err, "mysql: create database error") + } + case "pgx": + database.Dialect = "postgres" + case "sqlite3", "sqlite": + database.Dialect = "sqlite3" + database.Source = sqlite.SourceForeignKeys(database.Source) + default: + + } + db, err := sql.Open(database.Dialect, database.Source) + if err != nil { + return nil, errors.Wrap(err, "database: open database error") + } + if database.MaxIdleConnections > 0 { + db.SetMaxIdleConns(int(database.MaxIdleConnections)) + } + if database.MaxOpenConnections > 0 { + db.SetMaxOpenConns(int(database.MaxOpenConnections)) + } + if t := database.ConnectionMaxLifetime; t > 0 { + db.SetConnMaxLifetime(time.Duration(t)) + } + if t := database.ConnectionMaxIdleTime; t > 0 { + db.SetConnMaxIdleTime(time.Duration(t)) + } + return db, nil +} diff --git a/contrib/database/everyone.go b/contrib/database/everyone.go new file mode 100644 index 00000000..d79f296e --- /dev/null +++ b/contrib/database/everyone.go @@ -0,0 +1,18 @@ +//go:build !sqlite3 && !mysql && !postgres && !sqlserver && !mssql && !pgx + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package database is the database client wrapper +package database + +import ( + _ "github.com/denisenkom/go-mssqldb" + _ "github.com/go-sql-driver/mysql" + _ "github.com/lib/pq" + _ "github.com/sqlite3ent/sqlite3" +) + +// EveryOne ... +type EveryOne struct{} diff --git a/contrib/database/internal/mysql/mysql.go b/contrib/database/internal/mysql/mysql.go new file mode 100644 index 00000000..09e20ce9 --- /dev/null +++ b/contrib/database/internal/mysql/mysql.go @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package mysql + +import ( + "database/sql" + "fmt" + "os" + + "github.com/go-sql-driver/mysql" + "github.com/goexts/generic/types" +) + +const ( + databaseCreateQuery = "CREATE DATABASE IF NOT EXISTS `%s` DEFAULT CHARACTER SET '%s' DEFAULT COLLATE '%s';" + defaultCharSet = "utf8mb4" + defaultCollate = "utf8mb4_general_ci" +) + +// CreateDatabase creates a MySQL database with the given DSN. +func CreateDatabase(dsn string, name string) error { + cfg, err := mysql.ParseDSN(dsn) + if err != nil { + return err + } + + db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/", cfg.User, cfg.Passwd, cfg.Addr)) + if err != nil { + return fmt.Errorf("failed to open database: %v", err) + } + defer func(db *sql.DB) { + err := db.Close() + if err != nil { + fmt.Fprintf(os.Stderr, "Failed to close database: %v\n", err) + } + }(db) + + charset := types.ZeroOr(cfg.Params["charset"], defaultCharSet) + collate := types.ZeroOr(cfg.Collation, defaultCollate) + if name == "" { + name = cfg.DBName + } + query := fmt.Sprintf(databaseCreateQuery, name, charset, collate) + _, err = db.Exec(query) + return err +} diff --git a/contrib/database/internal/sqlite/sqlite.go b/contrib/database/internal/sqlite/sqlite.go new file mode 100644 index 00000000..c7eefceb --- /dev/null +++ b/contrib/database/internal/sqlite/sqlite.go @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package sqlite implements the functions, types, and interfaces for the module. +package sqlite + +import ( + "strings" +) + +const FKSuffix = "_fk=1" + +func SourceForeignKeys(source string) string { + // Check if the source already contains the FK parameter + if strings.Contains(source, FKSuffix) { + return source + } + + // Check if the source already contains parameters + if strings.Contains(source, "?") { + // If parameters exist, append with & + if !strings.HasSuffix(source, "&") { + source += "&" + } + source += FKSuffix + } else { + // If no parameters exist, append with ? + source += "?" + FKSuffix + } + return source +} diff --git a/contrib/database/mssql.go b/contrib/database/mssql.go new file mode 100644 index 00000000..7016af03 --- /dev/null +++ b/contrib/database/mssql.go @@ -0,0 +1,14 @@ +//go:build mssql || sqlserver + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package database implements the functions, types, and interfaces for the module. +package database + +import ( + _ "github.com/denisenkom/go-mssqldb" +) + +type MSSQL struct{} diff --git a/contrib/database/mysql.go b/contrib/database/mysql.go new file mode 100644 index 00000000..d66e004b --- /dev/null +++ b/contrib/database/mysql.go @@ -0,0 +1,14 @@ +//go:build mysql + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package database is the database client wrapper +package database + +import ( + _ "github.com/go-sql-driver/mysql" +) + +type MySQL struct{} diff --git a/contrib/database/pgx.go b/contrib/database/pgx.go new file mode 100644 index 00000000..a2656f74 --- /dev/null +++ b/contrib/database/pgx.go @@ -0,0 +1,14 @@ +//go:build !postgres && pgx + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package database implements the functions, types, and interfaces for the module. +package database + +import ( + _ "github.com/jackc/pgx/v5/stdlib" +) + +type Pgx struct{} diff --git a/contrib/database/postgres.go b/contrib/database/postgres.go new file mode 100644 index 00000000..e78aafd3 --- /dev/null +++ b/contrib/database/postgres.go @@ -0,0 +1,14 @@ +//go:build postgres && !pgx + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package database is the database client wrapper +package database + +import ( + _ "github.com/lib/pq" +) + +type Postgres struct{} diff --git a/contrib/database/sqlite3_cgo.go b/contrib/database/sqlite3_cgo.go new file mode 100644 index 00000000..3ab1312f --- /dev/null +++ b/contrib/database/sqlite3_cgo.go @@ -0,0 +1,14 @@ +//go:build sqlite3 && cgo + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package database is the database client wrapper +package database + +import ( + _ "github.com/mattn/go-sqlite3" +) + +type SQLite3Cgo struct{} diff --git a/contrib/database/sqlite3_go.go b/contrib/database/sqlite3_go.go new file mode 100644 index 00000000..9463adab --- /dev/null +++ b/contrib/database/sqlite3_go.go @@ -0,0 +1,14 @@ +//go:build sqlite3 && !cgo + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package database is the database client wrapper +package database + +import ( + _ "github.com/sqlite3ent/sqlite3" +) + +type SQLite3Go struct{} diff --git a/go.mod b/go.mod index 1b553b56..b6185911 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,6 @@ require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 github.com/mojocn/base64Captcha v1.3.8 github.com/origadmin/contrib/consul v0.0.33 - github.com/origadmin/contrib/database v0.0.33 github.com/origadmin/contrib/i18n v0.0.33 github.com/origadmin/contrib/replacer v0.0.33 github.com/origadmin/contrib/transport/gins v0.0.33 diff --git a/helpers/resp/data/v1/data.pb.go b/helpers/resp/data/v1/data.pb.go index 72b841ba..9c6bc3a2 100644 --- a/helpers/resp/data/v1/data.pb.go +++ b/helpers/resp/data/v1/data.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.36.6 // protoc v5.28.3 // source: helpers/resp/data/v1/data.proto @@ -13,6 +13,7 @@ import ( structpb "google.golang.org/protobuf/types/known/structpb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -24,11 +25,8 @@ const ( // PageResponse general result type Page struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` // The total number of items in the list. Total int32 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"` // The paging data @@ -39,9 +37,11 @@ type Page struct { PageSize *int32 `protobuf:"varint,5,opt,name=page_size,proto3,oneof" json:"page_size,omitempty"` // Additional information about this response. // content to be added without destroying the current data format - Extra map[string]*structpb.Struct `protobuf:"bytes,6,rep,name=extra,proto3" json:"extra,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Value *structpb.Value `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"` - Struct *structpb.Struct `protobuf:"bytes,8,opt,name=struct,proto3" json:"struct,omitempty"` + Extra map[string]*structpb.Struct `protobuf:"bytes,6,rep,name=extra,proto3" json:"extra,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Value *structpb.Value `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"` + Struct *structpb.Struct `protobuf:"bytes,8,opt,name=struct,proto3" json:"struct,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Page) Reset() { @@ -132,11 +132,8 @@ func (x *Page) GetStruct() *structpb.Struct { // SourcePage type SourcePage struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` // The total number of items in the list. Total int32 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"` // The paging data @@ -147,7 +144,9 @@ type SourcePage struct { PageSize *int32 `protobuf:"varint,5,opt,name=page_size,proto3,oneof" json:"page_size,omitempty"` // Additional information about this response. // content to be added without destroying the current data format - Extra string `protobuf:"bytes,6,opt,name=extra,proto3" json:"extra,omitempty"` + Extra string `protobuf:"bytes,6,opt,name=extra,proto3" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *SourcePage) Reset() { @@ -223,14 +222,13 @@ func (x *SourcePage) GetExtra() string { } type Error struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Code int32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"` + Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` + Detail string `protobuf:"bytes,4,opt,name=detail,proto3" json:"detail,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Code int32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"` - Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"` - Detail string `protobuf:"bytes,4,opt,name=detail,proto3" json:"detail,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Error) Reset() { @@ -292,14 +290,13 @@ func (x *Error) GetDetail() string { } type Data struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + Extra map[string]*anypb.Any `protobuf:"bytes,4,rep,name=extra,proto3" json:"extra,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Error *Error `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - Extra map[string]*anypb.Any `protobuf:"bytes,4,rep,name=extra,proto3" json:"extra,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Error *Error `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Data) Reset() { @@ -361,14 +358,13 @@ func (x *Data) GetError() *Error { } type SourceData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + Extra map[string]*anypb.Any `protobuf:"bytes,4,rep,name=extra,proto3" json:"extra,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Error *Error `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - Extra map[string]*anypb.Any `protobuf:"bytes,4,rep,name=extra,proto3" json:"extra,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Error *Error `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` + sizeCache protoimpl.SizeCache } func (x *SourceData) Reset() { @@ -430,14 +426,13 @@ func (x *SourceData) GetError() *Error { } type DataArray struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data []*anypb.Any `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"` + Extra map[string]*anypb.Any `protobuf:"bytes,4,rep,name=extra,proto3" json:"extra,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Error *Error `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data []*anypb.Any `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"` - Extra map[string]*anypb.Any `protobuf:"bytes,4,rep,name=extra,proto3" json:"extra,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Error *Error `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DataArray) Reset() { @@ -499,14 +494,13 @@ func (x *DataArray) GetError() *Error { } type SourceDataArray struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data [][]byte `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"` + Extra map[string]*anypb.Any `protobuf:"bytes,4,rep,name=extra,proto3" json:"extra,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Error *Error `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data [][]byte `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"` - Extra map[string]*anypb.Any `protobuf:"bytes,4,rep,name=extra,proto3" json:"extra,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - Error *Error `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` + sizeCache protoimpl.SizeCache } func (x *SourceDataArray) Reset() { @@ -568,12 +562,11 @@ func (x *SourceDataArray) GetError() *Error { } type StringData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *StringData) Reset() { @@ -621,12 +614,11 @@ func (x *StringData) GetData() string { } type BytesData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *BytesData) Reset() { @@ -674,12 +666,11 @@ func (x *BytesData) GetData() []byte { } type ErrorData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Error *Error `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Error *Error `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ErrorData) Reset() { @@ -727,18 +718,17 @@ func (x *ErrorData) GetError() *Error { } type Token struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // "user_id": response.Token.GetUserId(), // "access_token": response.Token.GetAccessToken(), // "refresh_token": response.Token.GetRefreshToken(), // "expires_at": response.Token.GetExpirationTime(), - UserId string `protobuf:"bytes,1,opt,name=user_id,proto3" json:"user_id,omitempty"` - AccessToken string `protobuf:"bytes,2,opt,name=access_token,proto3" json:"access_token,omitempty"` - RefreshToken string `protobuf:"bytes,3,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` - ExpiresAt int64 `protobuf:"varint,4,opt,name=expires_at,proto3" json:"expires_at,omitempty"` + UserId string `protobuf:"bytes,1,opt,name=user_id,proto3" json:"user_id,omitempty"` + AccessToken string `protobuf:"bytes,2,opt,name=access_token,proto3" json:"access_token,omitempty"` + RefreshToken string `protobuf:"bytes,3,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` + ExpiresAt int64 `protobuf:"varint,4,opt,name=expires_at,proto3" json:"expires_at,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Token) Reset() { @@ -800,12 +790,11 @@ func (x *Token) GetExpiresAt() int64 { } type AnyData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data []*anypb.Any `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data []*anypb.Any `protobuf:"bytes,3,rep,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AnyData) Reset() { @@ -854,159 +843,109 @@ func (x *AnyData) GetData() []*anypb.Any { var File_helpers_resp_data_v1_data_proto protoreflect.FileDescriptor -var file_helpers_resp_data_v1_data_proto_rawDesc = []byte{ - 0x0a, 0x1f, 0x68, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x73, 0x2f, 0x72, 0x65, 0x73, 0x70, 0x2f, 0x64, - 0x61, 0x74, 0x61, 0x2f, 0x76, 0x31, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x07, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x22, 0x9e, 0x03, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, - 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x28, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, - 0x6e, 0x74, 0x88, 0x01, 0x01, 0x12, 0x21, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, - 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, - 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x88, 0x01, 0x01, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, - 0x61, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, - 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x2e, 0x45, 0x78, 0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x12, 0x2c, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x2f, 0x0a, 0x06, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, - 0x06, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x1a, 0x51, 0x0a, 0x0a, 0x45, 0x78, 0x74, 0x72, 0x61, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2d, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x63, - 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, - 0x73, 0x69, 0x7a, 0x65, 0x22, 0xc2, 0x01, 0x0a, 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, - 0x61, 0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, - 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x6f, - 0x74, 0x61, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x07, 0x63, 0x75, 0x72, 0x72, 0x65, - 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x07, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x88, 0x01, 0x01, 0x12, 0x21, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, - 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01, 0x52, 0x09, 0x70, 0x61, 0x67, - 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x88, 0x01, 0x01, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x78, 0x74, - 0x72, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x42, - 0x0a, 0x0a, 0x08, 0x5f, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, - 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x5d, 0x0a, 0x05, 0x45, 0x72, 0x72, - 0x6f, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, - 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x22, 0xf0, 0x01, 0x0a, 0x04, 0x44, 0x61, 0x74, - 0x61, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x28, 0x0a, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, 0x04, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x44, - 0x61, 0x74, 0x61, 0x2e, 0x45, 0x78, 0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, - 0x65, 0x78, 0x74, 0x72, 0x61, 0x12, 0x24, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x1a, 0x4e, 0x0a, 0x0a, 0x45, - 0x78, 0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2a, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xe6, 0x01, 0x0a, 0x0a, - 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, - 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, - 0x63, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x34, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, - 0x61, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, - 0x31, 0x2e, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x45, 0x78, 0x74, - 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x12, 0x24, - 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x1a, 0x4e, 0x0a, 0x0a, 0x45, 0x78, 0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x22, 0xfa, 0x01, 0x0a, 0x09, 0x44, 0x61, 0x74, 0x61, 0x41, 0x72, 0x72, - 0x61, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x28, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x33, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, - 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, - 0x44, 0x61, 0x74, 0x61, 0x41, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x45, 0x78, 0x74, 0x72, 0x61, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x12, 0x24, 0x0a, 0x05, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x64, 0x61, 0x74, - 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, - 0x72, 0x1a, 0x4e, 0x0a, 0x0a, 0x45, 0x78, 0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x2a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x22, 0xf0, 0x01, 0x0a, 0x0f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, - 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, - 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x12, 0x39, 0x0a, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x44, 0x61, 0x74, 0x61, 0x41, 0x72, 0x72, 0x61, 0x79, 0x2e, 0x45, 0x78, 0x74, - 0x72, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, 0x65, 0x78, 0x74, 0x72, 0x61, 0x12, 0x24, - 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x1a, 0x4e, 0x0a, 0x0a, 0x45, 0x78, 0x74, 0x72, 0x61, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2a, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3a, 0x0a, 0x0a, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x44, 0x61, - 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, - 0x22, 0x39, 0x0a, 0x09, 0x42, 0x79, 0x74, 0x65, 0x73, 0x44, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, - 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, - 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x4b, 0x0a, 0x09, 0x45, - 0x72, 0x72, 0x6f, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, - 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, - 0x73, 0x73, 0x12, 0x24, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0e, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, - 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x8b, 0x01, 0x0a, 0x05, 0x54, 0x6f, 0x6b, - 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x12, 0x22, 0x0a, 0x0c, - 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, - 0x12, 0x24, 0x0a, 0x0d, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, - 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, - 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, - 0x73, 0x5f, 0x61, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x65, 0x78, 0x70, 0x69, - 0x72, 0x65, 0x73, 0x5f, 0x61, 0x74, 0x22, 0x4d, 0x0a, 0x07, 0x41, 0x6e, 0x79, 0x44, 0x61, 0x74, - 0x61, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x28, 0x0a, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x39, 0x5a, 0x37, 0x6f, 0x72, 0x69, 0x67, 0x61, 0x64, 0x6d, - 0x69, 0x6e, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x2f, 0x68, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x73, 0x2f, 0x72, 0x65, 0x73, - 0x70, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x76, 0x31, 0x3b, 0x64, 0x61, 0x74, 0x61, 0x76, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_helpers_resp_data_v1_data_proto_rawDesc = "" + + "\n" + + "\x1fhelpers/resp/data/v1/data.proto\x12\adata.v1\x1a\x19google/protobuf/any.proto\x1a\x1cgoogle/protobuf/struct.proto\"\x9e\x03\n" + + "\x04Page\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x14\n" + + "\x05total\x18\x02 \x01(\x05R\x05total\x12(\n" + + "\x04data\x18\x03 \x03(\v2\x14.google.protobuf.AnyR\x04data\x12\x1d\n" + + "\acurrent\x18\x04 \x01(\x05H\x00R\acurrent\x88\x01\x01\x12!\n" + + "\tpage_size\x18\x05 \x01(\x05H\x01R\tpage_size\x88\x01\x01\x12.\n" + + "\x05extra\x18\x06 \x03(\v2\x18.data.v1.Page.ExtraEntryR\x05extra\x12,\n" + + "\x05value\x18\a \x01(\v2\x16.google.protobuf.ValueR\x05value\x12/\n" + + "\x06struct\x18\b \x01(\v2\x17.google.protobuf.StructR\x06struct\x1aQ\n" + + "\n" + + "ExtraEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12-\n" + + "\x05value\x18\x02 \x01(\v2\x17.google.protobuf.StructR\x05value:\x028\x01B\n" + + "\n" + + "\b_currentB\f\n" + + "\n" + + "_page_size\"\xc2\x01\n" + + "\n" + + "SourcePage\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x14\n" + + "\x05total\x18\x02 \x01(\x05R\x05total\x12\x12\n" + + "\x04data\x18\x03 \x01(\fR\x04data\x12\x1d\n" + + "\acurrent\x18\x04 \x01(\x05H\x00R\acurrent\x88\x01\x01\x12!\n" + + "\tpage_size\x18\x05 \x01(\x05H\x01R\tpage_size\x88\x01\x01\x12\x14\n" + + "\x05extra\x18\x06 \x01(\tR\x05extraB\n" + + "\n" + + "\b_currentB\f\n" + + "\n" + + "_page_size\"]\n" + + "\x05Error\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04code\x18\x02 \x01(\x05R\x04code\x12\x18\n" + + "\amessage\x18\x03 \x01(\tR\amessage\x12\x16\n" + + "\x06detail\x18\x04 \x01(\tR\x06detail\"\xf0\x01\n" + + "\x04Data\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12(\n" + + "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\x12.\n" + + "\x05extra\x18\x04 \x03(\v2\x18.data.v1.Data.ExtraEntryR\x05extra\x12$\n" + + "\x05error\x18\x05 \x01(\v2\x0e.data.v1.ErrorR\x05error\x1aN\n" + + "\n" + + "ExtraEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12*\n" + + "\x05value\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x05value:\x028\x01\"\xe6\x01\n" + + "\n" + + "SourceData\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x12\n" + + "\x04data\x18\x03 \x01(\fR\x04data\x124\n" + + "\x05extra\x18\x04 \x03(\v2\x1e.data.v1.SourceData.ExtraEntryR\x05extra\x12$\n" + + "\x05error\x18\x05 \x01(\v2\x0e.data.v1.ErrorR\x05error\x1aN\n" + + "\n" + + "ExtraEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12*\n" + + "\x05value\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x05value:\x028\x01\"\xfa\x01\n" + + "\tDataArray\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12(\n" + + "\x04data\x18\x03 \x03(\v2\x14.google.protobuf.AnyR\x04data\x123\n" + + "\x05extra\x18\x04 \x03(\v2\x1d.data.v1.DataArray.ExtraEntryR\x05extra\x12$\n" + + "\x05error\x18\x05 \x01(\v2\x0e.data.v1.ErrorR\x05error\x1aN\n" + + "\n" + + "ExtraEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12*\n" + + "\x05value\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x05value:\x028\x01\"\xf0\x01\n" + + "\x0fSourceDataArray\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x12\n" + + "\x04data\x18\x03 \x03(\fR\x04data\x129\n" + + "\x05extra\x18\x04 \x03(\v2#.data.v1.SourceDataArray.ExtraEntryR\x05extra\x12$\n" + + "\x05error\x18\x05 \x01(\v2\x0e.data.v1.ErrorR\x05error\x1aN\n" + + "\n" + + "ExtraEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12*\n" + + "\x05value\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x05value:\x028\x01\":\n" + + "\n" + + "StringData\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x12\n" + + "\x04data\x18\x03 \x01(\tR\x04data\"9\n" + + "\tBytesData\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12\x12\n" + + "\x04data\x18\x03 \x01(\fR\x04data\"K\n" + + "\tErrorData\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12$\n" + + "\x05error\x18\x05 \x01(\v2\x0e.data.v1.ErrorR\x05error\"\x8b\x01\n" + + "\x05Token\x12\x18\n" + + "\auser_id\x18\x01 \x01(\tR\auser_id\x12\"\n" + + "\faccess_token\x18\x02 \x01(\tR\faccess_token\x12$\n" + + "\rrefresh_token\x18\x03 \x01(\tR\rrefresh_token\x12\x1e\n" + + "\n" + + "expires_at\x18\x04 \x01(\x03R\n" + + "expires_at\"M\n" + + "\aAnyData\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12(\n" + + "\x04data\x18\x03 \x03(\v2\x14.google.protobuf.AnyR\x04dataB9Z7origadmin/application/admin/helpers/resp/data/v1;datav1b\x06proto3" var ( file_helpers_resp_data_v1_data_proto_rawDescOnce sync.Once - file_helpers_resp_data_v1_data_proto_rawDescData = file_helpers_resp_data_v1_data_proto_rawDesc + file_helpers_resp_data_v1_data_proto_rawDescData []byte ) func file_helpers_resp_data_v1_data_proto_rawDescGZIP() []byte { file_helpers_resp_data_v1_data_proto_rawDescOnce.Do(func() { - file_helpers_resp_data_v1_data_proto_rawDescData = protoimpl.X.CompressGZIP(file_helpers_resp_data_v1_data_proto_rawDescData) + file_helpers_resp_data_v1_data_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_helpers_resp_data_v1_data_proto_rawDesc), len(file_helpers_resp_data_v1_data_proto_rawDesc))) }) return file_helpers_resp_data_v1_data_proto_rawDescData } @@ -1074,7 +1013,7 @@ func file_helpers_resp_data_v1_data_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_helpers_resp_data_v1_data_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_helpers_resp_data_v1_data_proto_rawDesc), len(file_helpers_resp_data_v1_data_proto_rawDesc)), NumEnums: 0, NumMessages: 17, NumExtensions: 0, @@ -1085,7 +1024,6 @@ func file_helpers_resp_data_v1_data_proto_init() { MessageInfos: file_helpers_resp_data_v1_data_proto_msgTypes, }.Build() File_helpers_resp_data_v1_data_proto = out.File - file_helpers_resp_data_v1_data_proto_rawDesc = nil file_helpers_resp_data_v1_data_proto_goTypes = nil file_helpers_resp_data_v1_data_proto_depIdxs = nil } diff --git a/helpers/securityx/security.go b/helpers/securityx/security.go index 472cab23..bd946a79 100644 --- a/helpers/securityx/security.go +++ b/helpers/securityx/security.go @@ -12,9 +12,9 @@ import ( "github.com/go-kratos/kratos/v2/transport" transhttp "github.com/go-kratos/kratos/v2/transport/http" msecurity "github.com/origadmin/runtime/agent/middleware/security" + "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/interfaces/security" "origadmin/application/admin/contrib/security/authn/jwt" "origadmin/application/admin/contrib/security/authz/casbin" @@ -22,7 +22,7 @@ import ( ) func NewAuthenticator(bootstrap *configs.Bootstrap, ss ...jwt.Setting) (security.Authenticator, error) { - tokenizer, err := jwt.NewTokenizer(bootstrap.GetSecurity(), ss...) + tokenizer, err := jwt.NewTokenizer(bootstrap.GetSecurity().GetSecurity(), ss...) if err != nil { return nil, err } @@ -32,7 +32,7 @@ func NewAuthenticator(bootstrap *configs.Bootstrap, ss ...jwt.Setting) (security } func NewTokenizer(bootstrap *configs.Bootstrap, ss ...jwt.Setting) (security.Tokenizer, error) { - tokenizer, err := jwt.NewTokenizer(bootstrap.GetSecurity(), ss...) + tokenizer, err := jwt.NewTokenizer(bootstrap.GetSecurity().GetSecurity(), ss...) if err != nil { return nil, err } @@ -40,7 +40,7 @@ func NewTokenizer(bootstrap *configs.Bootstrap, ss ...jwt.Setting) (security.Tok } func NewAuthorizer(bootstrap *configs.Bootstrap, ss ...casbin.AuthorizerOption) (security.Authorizer, error) { - authorizer, err := casbin.NewAuthorizer(bootstrap.GetSecurity(), ss...) + authorizer, err := casbin.NewAuthorizer(bootstrap.GetSecurity().GetSecurity(), ss...) if err != nil { return nil, err } diff --git a/internal/configs/auth_config.pb.go b/internal/configs/auth_config.pb.go deleted file mode 100644 index 7c785b8d..00000000 --- a/internal/configs/auth_config.pb.go +++ /dev/null @@ -1,139 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc v5.28.3 -// source: configs/auth_config.proto - -package configs - -import ( - v1 "github.com/origadmin/runtime/gen/go/config/v1" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type AuthConfig struct { - state protoimpl.MessageState `protogen:"open.v1"` - // origadmin.configs.api.RootUser root_user = 1 [json_name = "root_user"]; - Captcha *Captcha `protobuf:"bytes,2,opt,name=captcha,proto3" json:"captcha,omitempty"` - Security *v1.Security `protobuf:"bytes,3,opt,name=security,proto3" json:"security,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AuthConfig) Reset() { - *x = AuthConfig{} - mi := &file_configs_auth_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AuthConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthConfig) ProtoMessage() {} - -func (x *AuthConfig) ProtoReflect() protoreflect.Message { - mi := &file_configs_auth_config_proto_msgTypes[0] - 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 AuthConfig.ProtoReflect.Descriptor instead. -func (*AuthConfig) Descriptor() ([]byte, []int) { - return file_configs_auth_config_proto_rawDescGZIP(), []int{0} -} - -func (x *AuthConfig) GetCaptcha() *Captcha { - if x != nil { - return x.Captcha - } - return nil -} - -func (x *AuthConfig) GetSecurity() *v1.Security { - if x != nil { - return x.Security - } - return nil -} - -var File_configs_auth_config_proto protoreflect.FileDescriptor - -const file_configs_auth_config_proto_rawDesc = "" + - "\n" + - "\x19configs/auth_config.proto\x12\x15origadmin.configs.api\x1a\x18config/v1/security.proto\x1a\x15configs/captcha.proto\"w\n" + - "\n" + - "AuthConfig\x128\n" + - "\acaptcha\x18\x02 \x01(\v2\x1e.origadmin.configs.api.CaptchaR\acaptcha\x12/\n" + - "\bsecurity\x18\x03 \x01(\v2\x13.config.v1.SecurityR\bsecurityB.Z,origadmin/application/admin/internal/configsb\x06proto3" - -var ( - file_configs_auth_config_proto_rawDescOnce sync.Once - file_configs_auth_config_proto_rawDescData []byte -) - -func file_configs_auth_config_proto_rawDescGZIP() []byte { - file_configs_auth_config_proto_rawDescOnce.Do(func() { - file_configs_auth_config_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_auth_config_proto_rawDesc), len(file_configs_auth_config_proto_rawDesc))) - }) - return file_configs_auth_config_proto_rawDescData -} - -var file_configs_auth_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_configs_auth_config_proto_goTypes = []any{ - (*AuthConfig)(nil), // 0: origadmin.configs.api.AuthConfig - (*Captcha)(nil), // 1: origadmin.configs.api.Captcha - (*v1.Security)(nil), // 2: config.v1.Security -} -var file_configs_auth_config_proto_depIdxs = []int32{ - 1, // 0: origadmin.configs.api.AuthConfig.captcha:type_name -> origadmin.configs.api.Captcha - 2, // 1: origadmin.configs.api.AuthConfig.security:type_name -> config.v1.Security - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_configs_auth_config_proto_init() } -func file_configs_auth_config_proto_init() { - if File_configs_auth_config_proto != nil { - return - } - file_configs_captcha_proto_init() - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_auth_config_proto_rawDesc), len(file_configs_auth_config_proto_rawDesc)), - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_configs_auth_config_proto_goTypes, - DependencyIndexes: file_configs_auth_config_proto_depIdxs, - MessageInfos: file_configs_auth_config_proto_msgTypes, - }.Build() - File_configs_auth_config_proto = out.File - file_configs_auth_config_proto_goTypes = nil - file_configs_auth_config_proto_depIdxs = nil -} diff --git a/internal/configs/auth_config.proto b/internal/configs/auth_config.proto deleted file mode 100644 index e4cd7728..00000000 --- a/internal/configs/auth_config.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; -package origadmin.configs.api; - -import "config/v1/security.proto"; -// 移除对root_user的引用(迁移至安全配置模块) -// import "configs/root_user.proto"; -import "configs/captcha.proto"; - -option go_package = "origadmin/application/admin/internal/configs"; - -message AuthConfig { - // origadmin.configs.api.RootUser root_user = 1 [json_name = "root_user"]; - origadmin.configs.api.Captcha captcha = 2 [json_name = "captcha"]; - - config.v1.Security security = 3 [json_name = "security"]; -} diff --git a/internal/configs/bootstrap.pb.go b/internal/configs/bootstrap.pb.go index 60b315ea..794e897b 100644 --- a/internal/configs/bootstrap.pb.go +++ b/internal/configs/bootstrap.pb.go @@ -10,7 +10,6 @@ import ( _ "github.com/envoyproxy/protoc-gen-validate/validate" v1 "github.com/origadmin/runtime/gen/go/config/v1" v11 "github.com/origadmin/runtime/gen/go/middleware/v1" - v12 "github.com/origadmin/runtime/gen/go/security/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -147,9 +146,7 @@ type Bootstrap struct { Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` - Authn *v12.AuthN `protobuf:"bytes,1000,opt,name=authn,proto3" json:"authn,omitempty"` - Authz *v12.AuthZ `protobuf:"bytes,1001,opt,name=authz,proto3" json:"authz,omitempty"` - Security *v1.Security `protobuf:"bytes,1002,opt,name=security,proto3" json:"security,omitempty"` + Security *SecurityConfig `protobuf:"bytes,10,opt,name=security,proto3" json:"security,omitempty"` HealthCheck *Bootstrap_HealthCheck `protobuf:"bytes,1003,opt,name=health_check,proto3" json:"health_check,omitempty"` Logger *v1.Logger `protobuf:"bytes,1004,opt,name=logger,proto3" json:"logger,omitempty"` unknownFields protoimpl.UnknownFields @@ -277,21 +274,7 @@ func (x *Bootstrap) GetMiddleware() *v11.Middleware { return nil } -func (x *Bootstrap) GetAuthn() *v12.AuthN { - if x != nil { - return x.Authn - } - return nil -} - -func (x *Bootstrap) GetAuthz() *v12.AuthZ { - if x != nil { - return x.Authz - } - return nil -} - -func (x *Bootstrap) GetSecurity() *v1.Security { +func (x *Bootstrap) GetSecurity() *SecurityConfig { if x != nil { return x.Security } @@ -465,13 +448,13 @@ var File_configs_bootstrap_proto protoreflect.FileDescriptor const file_configs_bootstrap_proto_rawDesc = "" + "\n" + - "\x17configs/bootstrap.proto\x12\x15origadmin.configs.api\x1a\x16config/v1/logger.proto\x1a\x18config/v1/registry.proto\x1a\x18config/v1/security.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1emiddleware/v1/middleware.proto\x1a\x16security/v1/auth.proto\x1a\x17validate/validate.proto\"[\n" + + "\x17configs/bootstrap.proto\x12\x15origadmin.configs.api\x1a\x16config/v1/logger.proto\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1dconfigs/security_config.proto\x1a\x1emiddleware/v1/middleware.proto\x1a\x17validate/validate.proto\"[\n" + "\x13EntrySelectorConfig\x12\x16\n" + "\x06global\x18\x02 \x01(\bR\x06global\x12\x12\n" + "\x04name\x18\x03 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x04 \x01(\tR\aversion\",\n" + "\rServiceConfig\x12\x1b\n" + - "\x04name\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x04name\"\xea\a\n" + + "\x04name\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x04name\"\xa5\a\n" + "\tBootstrap\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x02 \x01(\tR\aversion\x12 \n" + @@ -487,10 +470,9 @@ const file_configs_bootstrap_proto_rawDesc = "" + "\bregistry\x18\x90\x03 \x01(\v2\x13.config.v1.RegistryR\bregistry\x129\n" + "\n" + "middleware\x18\t \x01(\v2\x19.middleware.v1.MiddlewareR\n" + - "middleware\x12)\n" + - "\x05authn\x18\xe8\a \x01(\v2\x12.security.v1.AuthNR\x05authn\x12)\n" + - "\x05authz\x18\xe9\a \x01(\v2\x12.security.v1.AuthZR\x05authz\x120\n" + - "\bsecurity\x18\xea\a \x01(\v2\x13.config.v1.SecurityR\bsecurity\x12Q\n" + + "middleware\x12A\n" + + "\bsecurity\x18\n" + + " \x01(\v2%.origadmin.configs.api.SecurityConfigR\bsecurity\x12Q\n" + "\fhealth_check\x18\xeb\a \x01(\v2,.origadmin.configs.api.Bootstrap.HealthCheckR\fhealth_check\x12*\n" + "\x06logger\x18\xec\a \x01(\v2\x11.config.v1.LoggerR\x06logger\x1a;\n" + "\vHealthCheck\x12\x18\n" + @@ -526,10 +508,8 @@ var file_configs_bootstrap_proto_goTypes = []any{ (*v1.Storage)(nil), // 7: config.v1.Storage (*v1.Registry)(nil), // 8: config.v1.Registry (*v11.Middleware)(nil), // 9: middleware.v1.Middleware - (*v12.AuthN)(nil), // 10: security.v1.AuthN - (*v12.AuthZ)(nil), // 11: security.v1.AuthZ - (*v1.Security)(nil), // 12: config.v1.Security - (*v1.Logger)(nil), // 13: config.v1.Logger + (*SecurityConfig)(nil), // 10: origadmin.configs.api.SecurityConfig + (*v1.Logger)(nil), // 11: config.v1.Logger } var file_configs_bootstrap_proto_depIdxs = []int32{ 5, // 0: origadmin.configs.api.Bootstrap.entry:type_name -> origadmin.configs.api.Bootstrap.Entry @@ -538,17 +518,15 @@ var file_configs_bootstrap_proto_depIdxs = []int32{ 7, // 3: origadmin.configs.api.Bootstrap.storage:type_name -> config.v1.Storage 8, // 4: origadmin.configs.api.Bootstrap.registry:type_name -> config.v1.Registry 9, // 5: origadmin.configs.api.Bootstrap.middleware:type_name -> middleware.v1.Middleware - 10, // 6: origadmin.configs.api.Bootstrap.authn:type_name -> security.v1.AuthN - 11, // 7: origadmin.configs.api.Bootstrap.authz:type_name -> security.v1.AuthZ - 12, // 8: origadmin.configs.api.Bootstrap.security:type_name -> config.v1.Security - 4, // 9: origadmin.configs.api.Bootstrap.health_check:type_name -> origadmin.configs.api.Bootstrap.HealthCheck - 13, // 10: origadmin.configs.api.Bootstrap.logger:type_name -> config.v1.Logger - 6, // 11: origadmin.configs.api.Bootstrap.Entry.server:type_name -> config.v1.Service - 12, // [12:12] is the sub-list for method output_type - 12, // [12:12] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 10, // 6: origadmin.configs.api.Bootstrap.security:type_name -> origadmin.configs.api.SecurityConfig + 4, // 7: origadmin.configs.api.Bootstrap.health_check:type_name -> origadmin.configs.api.Bootstrap.HealthCheck + 11, // 8: origadmin.configs.api.Bootstrap.logger:type_name -> config.v1.Logger + 6, // 9: origadmin.configs.api.Bootstrap.Entry.server:type_name -> config.v1.Service + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_configs_bootstrap_proto_init() } @@ -556,6 +534,7 @@ func file_configs_bootstrap_proto_init() { if File_configs_bootstrap_proto != nil { return } + file_configs_security_config_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/internal/configs/bootstrap.pb.validate.go b/internal/configs/bootstrap.pb.validate.go index 3322c892..4f1c8b0c 100644 --- a/internal/configs/bootstrap.pb.validate.go +++ b/internal/configs/bootstrap.pb.validate.go @@ -487,64 +487,6 @@ func (m *Bootstrap) validate(all bool) error { } } - if all { - switch v := interface{}(m.GetAuthn()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Authn", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Authn", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetAuthn()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "Authn", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetAuthz()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Authz", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Authz", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetAuthz()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "Authz", - reason: "embedded message failed validation", - cause: err, - } - } - } - if all { switch v := interface{}(m.GetSecurity()).(type) { case interface{ ValidateAll() error }: diff --git a/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto index 548dc083..f35b2aa1 100644 --- a/internal/configs/bootstrap.proto +++ b/internal/configs/bootstrap.proto @@ -4,11 +4,10 @@ package origadmin.configs.api; import "config/v1/logger.proto"; import "config/v1/registry.proto"; -import "config/v1/security.proto"; import "config/v1/service.proto"; import "config/v1/storage.proto"; +import "configs/security_config.proto"; import "middleware/v1/middleware.proto"; -import "security/v1/auth.proto"; import "validate/validate.proto"; // Updated import statement option go_package = "origadmin/application/admin/internal/configs"; @@ -77,9 +76,8 @@ message Bootstrap { config.v1.Storage storage = 300 [json_name = "storage"]; config.v1.Registry registry = 400 [json_name = "registry"]; middleware.v1.Middleware middleware = 9 [json_name = "middleware"]; - security.v1.AuthN authn = 1000 [json_name = "authn"]; - security.v1.AuthZ authz = 1001 [json_name = "authz"]; - config.v1.Security security = 1002 [json_name = "security"]; + SecurityConfig security = 10 [json_name = "security"]; + HealthCheck health_check = 1003 [json_name = "health_check"]; config.v1.Logger logger = 1004 [json_name = "logger"]; } diff --git a/internal/configs/security_config.pb.go b/internal/configs/security_config.pb.go new file mode 100644 index 00000000..b38cbcbc --- /dev/null +++ b/internal/configs/security_config.pb.go @@ -0,0 +1,149 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.28.3 +// source: configs/security_config.proto + +package configs + +import ( + v1 "github.com/origadmin/runtime/gen/go/config/v1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SecurityConfig struct { + state protoimpl.MessageState `protogen:"open.v1"` + RootUser *RootUser `protobuf:"bytes,1,opt,name=root_user,proto3" json:"root_user,omitempty"` + Captcha *Captcha `protobuf:"bytes,2,opt,name=captcha,proto3" json:"captcha,omitempty"` + Security *v1.Security `protobuf:"bytes,3,opt,name=security,proto3" json:"security,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SecurityConfig) Reset() { + *x = SecurityConfig{} + mi := &file_configs_security_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SecurityConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SecurityConfig) ProtoMessage() {} + +func (x *SecurityConfig) ProtoReflect() protoreflect.Message { + mi := &file_configs_security_config_proto_msgTypes[0] + 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 SecurityConfig.ProtoReflect.Descriptor instead. +func (*SecurityConfig) Descriptor() ([]byte, []int) { + return file_configs_security_config_proto_rawDescGZIP(), []int{0} +} + +func (x *SecurityConfig) GetRootUser() *RootUser { + if x != nil { + return x.RootUser + } + return nil +} + +func (x *SecurityConfig) GetCaptcha() *Captcha { + if x != nil { + return x.Captcha + } + return nil +} + +func (x *SecurityConfig) GetSecurity() *v1.Security { + if x != nil { + return x.Security + } + return nil +} + +var File_configs_security_config_proto protoreflect.FileDescriptor + +const file_configs_security_config_proto_rawDesc = "" + + "\n" + + "\x1dconfigs/security_config.proto\x12\x15origadmin.configs.api\x1a\x18config/v1/security.proto\x1a\x15configs/captcha.proto\x1a\x17configs/root_user.proto\"\xba\x01\n" + + "\x0eSecurityConfig\x12=\n" + + "\troot_user\x18\x01 \x01(\v2\x1f.origadmin.configs.api.RootUserR\troot_user\x128\n" + + "\acaptcha\x18\x02 \x01(\v2\x1e.origadmin.configs.api.CaptchaR\acaptcha\x12/\n" + + "\bsecurity\x18\x03 \x01(\v2\x13.config.v1.SecurityR\bsecurityB.Z,origadmin/application/admin/internal/configsb\x06proto3" + +var ( + file_configs_security_config_proto_rawDescOnce sync.Once + file_configs_security_config_proto_rawDescData []byte +) + +func file_configs_security_config_proto_rawDescGZIP() []byte { + file_configs_security_config_proto_rawDescOnce.Do(func() { + file_configs_security_config_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_security_config_proto_rawDesc), len(file_configs_security_config_proto_rawDesc))) + }) + return file_configs_security_config_proto_rawDescData +} + +var file_configs_security_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_configs_security_config_proto_goTypes = []any{ + (*SecurityConfig)(nil), // 0: origadmin.configs.api.SecurityConfig + (*RootUser)(nil), // 1: origadmin.configs.api.RootUser + (*Captcha)(nil), // 2: origadmin.configs.api.Captcha + (*v1.Security)(nil), // 3: config.v1.Security +} +var file_configs_security_config_proto_depIdxs = []int32{ + 1, // 0: origadmin.configs.api.SecurityConfig.root_user:type_name -> origadmin.configs.api.RootUser + 2, // 1: origadmin.configs.api.SecurityConfig.captcha:type_name -> origadmin.configs.api.Captcha + 3, // 2: origadmin.configs.api.SecurityConfig.security:type_name -> config.v1.Security + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_configs_security_config_proto_init() } +func file_configs_security_config_proto_init() { + if File_configs_security_config_proto != nil { + return + } + file_configs_captcha_proto_init() + file_configs_root_user_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_security_config_proto_rawDesc), len(file_configs_security_config_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_configs_security_config_proto_goTypes, + DependencyIndexes: file_configs_security_config_proto_depIdxs, + MessageInfos: file_configs_security_config_proto_msgTypes, + }.Build() + File_configs_security_config_proto = out.File + file_configs_security_config_proto_goTypes = nil + file_configs_security_config_proto_depIdxs = nil +} diff --git a/internal/configs/auth_config.pb.validate.go b/internal/configs/security_config.pb.validate.go similarity index 51% rename from internal/configs/auth_config.pb.validate.go rename to internal/configs/security_config.pb.validate.go index 7ff1999d..e6227f9c 100644 --- a/internal/configs/auth_config.pb.validate.go +++ b/internal/configs/security_config.pb.validate.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: configs/auth_config.proto +// source: configs/security_config.proto package configs @@ -35,33 +35,62 @@ var ( _ = sort.Sort ) -// Validate checks the field values on AuthConfig with the rules defined in the -// proto definition for this message. If any rules are violated, the first +// Validate checks the field values on SecurityConfig 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 *AuthConfig) Validate() error { +func (m *SecurityConfig) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on AuthConfig 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 AuthConfigMultiError, or -// nil if none found. -func (m *AuthConfig) ValidateAll() error { +// ValidateAll checks the field values on SecurityConfig 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 SecurityConfigMultiError, +// or nil if none found. +func (m *SecurityConfig) ValidateAll() error { return m.validate(true) } -func (m *AuthConfig) validate(all bool) error { +func (m *SecurityConfig) validate(all bool) error { if m == nil { return nil } var errors []error + if all { + switch v := interface{}(m.GetRootUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, SecurityConfigValidationError{ + field: "RootUser", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, SecurityConfigValidationError{ + field: "RootUser", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRootUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return SecurityConfigValidationError{ + field: "RootUser", + reason: "embedded message failed validation", + cause: err, + } + } + } + if all { switch v := interface{}(m.GetCaptcha()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, AuthConfigValidationError{ + errors = append(errors, SecurityConfigValidationError{ field: "Captcha", reason: "embedded message failed validation", cause: err, @@ -69,7 +98,7 @@ func (m *AuthConfig) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, AuthConfigValidationError{ + errors = append(errors, SecurityConfigValidationError{ field: "Captcha", reason: "embedded message failed validation", cause: err, @@ -78,7 +107,7 @@ func (m *AuthConfig) validate(all bool) error { } } else if v, ok := interface{}(m.GetCaptcha()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return AuthConfigValidationError{ + return SecurityConfigValidationError{ field: "Captcha", reason: "embedded message failed validation", cause: err, @@ -90,7 +119,7 @@ func (m *AuthConfig) validate(all bool) error { switch v := interface{}(m.GetSecurity()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, AuthConfigValidationError{ + errors = append(errors, SecurityConfigValidationError{ field: "Security", reason: "embedded message failed validation", cause: err, @@ -98,7 +127,7 @@ func (m *AuthConfig) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, AuthConfigValidationError{ + errors = append(errors, SecurityConfigValidationError{ field: "Security", reason: "embedded message failed validation", cause: err, @@ -107,7 +136,7 @@ func (m *AuthConfig) validate(all bool) error { } } else if v, ok := interface{}(m.GetSecurity()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return AuthConfigValidationError{ + return SecurityConfigValidationError{ field: "Security", reason: "embedded message failed validation", cause: err, @@ -116,18 +145,19 @@ func (m *AuthConfig) validate(all bool) error { } if len(errors) > 0 { - return AuthConfigMultiError(errors) + return SecurityConfigMultiError(errors) } return nil } -// AuthConfigMultiError is an error wrapping multiple validation errors -// returned by AuthConfig.ValidateAll() if the designated constraints aren't met. -type AuthConfigMultiError []error +// SecurityConfigMultiError is an error wrapping multiple validation errors +// returned by SecurityConfig.ValidateAll() if the designated constraints +// aren't met. +type SecurityConfigMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m AuthConfigMultiError) Error() string { +func (m SecurityConfigMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -136,11 +166,11 @@ func (m AuthConfigMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m AuthConfigMultiError) AllErrors() []error { return m } +func (m SecurityConfigMultiError) AllErrors() []error { return m } -// AuthConfigValidationError is the validation error returned by -// AuthConfig.Validate if the designated constraints aren't met. -type AuthConfigValidationError struct { +// SecurityConfigValidationError is the validation error returned by +// SecurityConfig.Validate if the designated constraints aren't met. +type SecurityConfigValidationError struct { field string reason string cause error @@ -148,22 +178,22 @@ type AuthConfigValidationError struct { } // Field function returns field value. -func (e AuthConfigValidationError) Field() string { return e.field } +func (e SecurityConfigValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e AuthConfigValidationError) Reason() string { return e.reason } +func (e SecurityConfigValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e AuthConfigValidationError) Cause() error { return e.cause } +func (e SecurityConfigValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e AuthConfigValidationError) Key() bool { return e.key } +func (e SecurityConfigValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e AuthConfigValidationError) ErrorName() string { return "AuthConfigValidationError" } +func (e SecurityConfigValidationError) ErrorName() string { return "SecurityConfigValidationError" } // Error satisfies the builtin error interface -func (e AuthConfigValidationError) Error() string { +func (e SecurityConfigValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -175,14 +205,14 @@ func (e AuthConfigValidationError) Error() string { } return fmt.Sprintf( - "invalid %sAuthConfig.%s: %s%s", + "invalid %sSecurityConfig.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = AuthConfigValidationError{} +var _ error = SecurityConfigValidationError{} var _ interface { Field() string @@ -190,4 +220,4 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = AuthConfigValidationError{} +} = SecurityConfigValidationError{} diff --git a/internal/configs/security_config.proto b/internal/configs/security_config.proto new file mode 100644 index 00000000..6e6ce20a --- /dev/null +++ b/internal/configs/security_config.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package origadmin.configs.api; + +import "config/v1/security.proto"; +import "configs/captcha.proto"; +import "configs/root_user.proto"; + +option go_package = "origadmin/application/admin/internal/configs"; + +message SecurityConfig { + RootUser root_user = 1 [json_name = "root_user"]; + Captcha captcha = 2 [json_name = "captcha"]; + + config.v1.Security security = 3 [json_name = "security"]; +} diff --git a/internal/data/data.go b/internal/data/data.go index a0394d6b..c8af1a6f 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -7,25 +7,45 @@ package data import ( "errors" + "fmt" + "os" + "path/filepath" + "strconv" + "time" "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/schema" "github.com/google/wire" - "github.com/origadmin/contrib/database" "github.com/origadmin/entslog/v3" "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/codec" + "origadmin/application/admin/contrib/database" + "origadmin/application/admin/helpers/id" + "origadmin/application/admin/helpers/securityx" "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/mods/system/dto" +) + +const ( + TreePathDelimiter = "." ) // ProviderSet is data providers. var ProviderSet = wire.NewSet( - //wire.Struct(new(LoginData), "*"), - NewDataWithClient, + NewData, + NewLoginData, + NewAuthenticator, + NewTokenizer, + NewAuthorizer, ) type Data struct { @@ -41,12 +61,36 @@ type LoginData struct { //User systemdto.UserRepo } +func NewLoginData(cfg *configs.Bootstrap, tokenizer security.RefreshTokenizer) *LoginData { + return &LoginData{ + Captcha: cfg.GetSecurity().GetCaptcha(), + RootUser: cfg.GetSecurity().GetRootUser(), + Tokenizer: tokenizer, + } +} + func NewDataWithClient(client *ent.Client) *Data { return &Data{ Database: ent.NewDatabaseWithClient(client), } } +func NewAuthenticator(bootstrap *configs.Bootstrap) (security.Authenticator, error) { + return securityx.NewAuthenticator(bootstrap) +} + +func NewTokenizer(bootstrap *configs.Bootstrap) (security.Tokenizer, error) { + authenticator, err := securityx.NewTokenizer(bootstrap) + if err != nil { + return nil, err + } + return authenticator, nil +} + +func NewAuthorizer(bootstrap *configs.Bootstrap) (security.Authorizer, error) { + return securityx.NewAuthorizer(bootstrap) +} + func debugDatabase(driver dialect.Driver, debug bool) dialect.Driver { if debug { return entslog.New(driver) @@ -54,14 +98,12 @@ func debugDatabase(driver dialect.Driver, debug bool) dialect.Driver { return driver } -// NewData . - // NewData . func NewData(r runtime.Runtime, bootstrap *configs.Bootstrap) (*Data, func(), error) { if bootstrap == nil { return nil, nil, errors.New("bootstrap is nil") } - + fmt.Printf("bootstrap: %+v\n", bootstrap) cfg := bootstrap.GetStorage().GetDatabase() if cfg == nil { return nil, nil, errors.New("data source not found") @@ -102,3 +144,420 @@ func NewData(r runtime.Runtime, bootstrap *configs.Bootstrap) (*Data, func(), er } }, nil } + +// InitDataFromPath . +func (obj *Data) InitDataFromPath(ctx context.Context, path string, filters ...string) error { + type data struct { + name string + fn func(ctx context.Context, filename string) error + } + initializers := []data{ + { + name: "resource", + fn: obj.InitResourceFromFile, + }, + { + name: "role", + fn: obj.InitRoleFromFile, + }, + { + name: "user", + fn: obj.InitUserFromFile, + }, + { + name: "department", + fn: obj.InitDepartmentFromFile, + }, + { + name: "position", + fn: obj.InitPositionFromFile, + }, + { + name: "permission", + fn: obj.InitPermissionFromFile, + }, + } + actions := make([]data, 0) + for _, di := range initializers { + for _, filter := range filters { + if di.name == filter { + actions = append(actions, di) + } + } + + } + for _, action := range actions { + action.name = filepath.Join(path, action.name+".json") + err := action.fn(ctx, action.name) + if err != nil { + return err + } + } + + return nil +} +func (obj *Data) InitResourceFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var resources []*dto.ResourceNode + err = codec.DecodeFromFile(abs, &resources) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("Resource data file not found, skip init resource data from file", "file", abs) + return nil + } + return err + } + for i, pb := range resources { + log.Infow("msg", "Processing resource", "index", i, "resourceId", pb.Id, "resourceKeyword", pb.Keyword, "resourceName", pb.Name) + if pb.Children != nil { + for i2, child := range pb.Children { + log.Infow("msg", "Processing child", "index", i2, "childId", child.Id, "childKeyword", child.Keyword, "childName", child.Name) + } + } + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createResourceBatchWithParent(ctx, resources, nil) + }) +} + +func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto.ResourceNode, parent *dto.ResourcePB) error { + total := len(items) + log.Infow("msg", "Starting createResourceBatchWithParent", "totalItems", total) + + for i, item := range items { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) + var pid int64 + if parent != nil { + pid = parent.Id + log.Infow("msg", "Parent ID set", "parentId", pid) + } + founded := false + switch { + case item.Id != 0: + log.Infow("Checking item by ID", "itemId", item.Id) + exists, err := obj.Resource(ctx).Query().Where(resource.ID(item.Id)).Exist(ctx) + if err != nil { + log.Errorw("msg", "Error checking item by ID", "itemId", item.Id, "error", err) + return err + } + if exists { + log.Infow("msg", "Item already exists by ID", "itemId", item.Id) + continue + } + case item.Keyword != "": + log.Infow("msg", "Checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid) + var wheres = []predicate.Resource{ + resource.Keyword(item.Keyword), + } + if pid != 0 { + wheres = append(wheres, resource.ParentID(pid)) + } + exists, err := obj.Resource(ctx).Query().Where(wheres...).Exist(ctx) + if err != nil { + log.Errorw("msg", "Error checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) + return err + } + if exists { + resourceItem, err := obj.Resource(ctx).Query().Where(wheres...).First(ctx) + if err != nil { + log.Errorw("msg", "Error fetching item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) + return err + } + founded = true + item.Id = resourceItem.ID + log.Infow("msg", "Item found by Keyword", "itemKeyword", item.Keyword, "itemId", item.Id) + } + case item.Name != "": + log.Infow("msg", "Checking item by Name", "itemName", item.Name, "parentId", pid) + var conditions = []predicate.Resource{ + resource.Name(item.Name), + } + if pid != 0 { + conditions = append(conditions, resource.ParentID(pid)) + } + exists, err := obj.Resource(ctx).Query().Where(conditions...).Exist(ctx) + if err != nil { + log.Errorw("msg", "Error checking item by Name", "itemName", item.Name, "parentId", pid, "error", err) + return err + } + if exists { + resourceItem, err := obj.Resource(ctx).Query().Where(conditions...).First(ctx) + if err != nil { + log.Errorw("msg", "Error fetching item by Name", "itemName", item.Name, "parentId", pid, "error", err) + return err + } + founded = true + item.Id = resourceItem.ID + log.Infow("msg", "Item found by Name", "itemName", item.Name, "itemId", item.Id) + } + default: + log.Infow("msg", "No ID, Keyword, or Name provided for item") + } + + if !founded { + if item.Id == 0 { + item.Id = id.Gen() + log.Infow("msg", "Generated new ID for item", "itemId", item.Id) + } + if item.Status == 0 { + item.Status = int32(dto.UserStatusActive) + log.Infow("msg", "Setting default status for item", "itemId", item.Id, "status", item.Status) + } + if item.Sequence == 0 { + item.Sequence = int32(total - i) + log.Infow("msg", "Setting default sequence for item", "itemId", item.Id, "sequence", item.Sequence) + } + + item.ParentId = pid + if parent != nil { + item.TreePath = parent.TreePath + strconv.Itoa(int(pid)) + TreePathDelimiter + log.Infow("msg", "Setting parent path for item", "itemId", item.Id, "treePath", item.TreePath) + } + itemObj := dto.ConvertResourcePB2Object(&item.ResourcePB) + itemObj.UpdateTime = time.Now() + itemObj.CreateTime = time.Now() + if _, err := obj.Resource(ctx).Create().SetResource(itemObj).Save(ctx); err != nil { + log.Errorw("msg", "Error creating resource item", "itemId", item.Id, "sequence", item.Sequence, "error", err) + return err + } + log.Infow("msg", "Resource item created successfully", "itemId", item.Id) + } + + if len(item.Children) != 0 { + log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) + if err := obj.createResourceBatchWithParent(ctx, item.Children, &item.ResourcePB); err != nil { + log.Errorw("Error processing children", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "Children processed successfully", "itemId", item.Id) + } + } + log.Infow("msg", "Finished createResourceBatchWithParent") + return nil +} + +func (obj *Data) InitUserFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var users []*dto.UserNode + err = codec.DecodeFromFile(abs, &users) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("User data file not found, skip init user data from file", "file", abs) + return nil + } + return err + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createUserBatch(ctx, users) + }) +} + +func (obj *Data) createUserBatch(ctx context.Context, users []*dto.UserNode) error { + total := len(users) + log.Infow("msg", "Starting createUserBatch", "totalItems", total) + for i, item := range users { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemUsername", item.Username, "itemNickname", item.Nickname) + user, ps, err := dto.MakeCreateUser(&item.UserPB, item.Username, item.Password, dto.UserMutationOption{}) + if err != nil { + return err + } + fmt.Println("generate user: ", user.Username, "with password: ", ps) + if _, err := obj.User(ctx).Create().SetIsSystem(item.IsSystem).SetUser(dto.ConvertUserPB2Object(user)). + Save(ctx); err != nil { + log.Errorw("msg", "Error creating user item", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "User item created successfully", "itemId", item.Id, "itemUuid", item.Uuid) + } + log.Infow("msg", "Finished createUserBatch") + return nil +} + +func (obj *Data) InitRoleFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var roles []*dto.RolePB + err = codec.DecodeFromFile(abs, &roles) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("Role data file not found, skip init role data from file", "file", abs) + return nil + } + return err + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createRoleBatch(ctx, roles) + }) +} + +func (obj *Data) createRoleBatch(ctx context.Context, roles []*dto.RolePB) error { + total := len(roles) + log.Infow("msg", "Starting createRoleBatch", "totalItems", total) + for i, item := range roles { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) + if item.Id == 0 { + item.Id = id.Gen() + log.Infow("msg", "Generated new ID for item", "itemId", item.Id) + } + if _, err := obj.Role(ctx).Create().SetRole(dto.ConvertRolePB2Object(item)).Save(ctx); err != nil { + log.Errorw("msg", "Error creating role item", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "Role item created successfully", "itemId", item.Id) + } + log.Infow("msg", "Finished createRoleBatch") + return nil +} + +func (obj *Data) InitDepartmentFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var departments []*dto.DepartmentNode + err = codec.DecodeFromFile(abs, &departments) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("Department data file not found, skip init department data from file", "file", abs) + return nil + } + return err + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createDepartmentBatch(ctx, departments, nil) + }) +} + +func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.DepartmentNode, parent *dto.DepartmentPB) error { + total := len(departments) + log.Infow("msg", "Starting createDepartmentBatch", "totalItems", total) + for i, item := range departments { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) + if item.Id == 0 { + item.Id = id.Gen() + log.Infow("msg", "Generated new ID for item", "itemId", item.Id) + } + if parent != nil { + item.ParentId = parent.Id + item.TreePath = parent.TreePath + strconv.Itoa(int(parent.Id)) + TreePathDelimiter + } + + if _, err := obj.Department(ctx).Create(). + SetDepartment(dto.ConvertDepartmentPB2Object(&item.DepartmentPB)). + Save(ctx); err != nil { + log.Errorw("msg", "Error creating department item", "itemId", item.Id, "error", err) + return err + } + + log.Infow("msg", "Department item created successfully", "itemId", item.Id) + if len(item.Children) != 0 { + log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) + if err := obj.createDepartmentBatch(ctx, item.Children, &item.DepartmentPB); err != nil { + log.Errorw("Error processing children", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "Children processed successfully", "itemId", item.Id) + } + } + log.Infow("msg", "Finished createDepartmentBatch") + return nil +} + +func (obj *Data) InitPositionFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var positions []*dto.PositionNode + err = codec.DecodeFromFile(abs, &positions) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("Position data file not found, skip init position data from file", "file", abs) + return nil + } + return err + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createPositionBatch(ctx, positions) + }) +} + +func (obj *Data) createPositionBatch(ctx context.Context, positions []*dto.PositionNode) error { + total := len(positions) + log.Infow("msg", "Starting createPositionBatch", "totalItems", total) + for i, item := range positions { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) + if item.Id == 0 { + item.Id = id.Gen() + log.Infow("msg", "Generated new ID for item", "itemId", item.Id) + } + dept, err := obj.Department(ctx).Query().Where(department.Keyword(item.DepartmentKeyword)).Only(ctx) + if err != nil { + return err + } + + if _, err := obj.Position(ctx).Create().SetPosition(&dto.Position{ + ID: item.Id, + CreateTime: time.Now(), + UpdateTime: time.Now(), + Name: item.Name, + Keyword: item.Keyword, + Description: item.Description, + DepartmentID: dept.ID, + }).Save(ctx); err != nil { + log.Errorw("msg", "Error creating position item", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "Position item created successfully", "itemId", item.Id) + } + log.Infow("msg", "Finished createPositionBatch") + return nil +} + +func (obj *Data) InitPermissionFromFile(ctx context.Context, filename string) error { + abs, err := filepath.Abs(filename) + if err != nil { + return err + } + var permissions []*dto.PermissionNode + err = codec.DecodeFromFile(abs, &permissions) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + log.Warnw("Permission data file not found, skip init permission data from file", "file", abs) + return nil + } + return err + } + return obj.Tx(ctx, func(ctx context.Context) error { + return obj.createPermissionBatch(ctx, permissions) + }) +} + +func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.PermissionNode) error { + total := len(permissions) + log.Infow("msg", "Starting createPermissionBatch", "totalItems", total) + for i, item := range permissions { + log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) + if item.Id == 0 { + item.Id = id.Gen() + log.Infow("msg", "Generated new ID for item", "itemId", item.Id) + } + if _, err := obj.Permission(ctx).Create(). + SetPermission(dto.ConvertPermissionPB2Object(&item.PermissionPB)). + Save(ctx); err != nil { + log.Errorw("msg", "Error creating permission item", "itemId", item.Id, "error", err) + return err + } + log.Infow("msg", "Permission item created successfully", "itemId", item.Id) + } + log.Infow("msg", "Finished createPermissionBatch") + return nil +} diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go index 3d4abe27..2dd18189 100644 --- a/internal/loader/bootstrap_default.go +++ b/internal/loader/bootstrap_default.go @@ -56,49 +56,51 @@ func DefaultBootstrap() *configs.Bootstrap { Storage: DefaultStorage(), Registry: DefaultRegistry(), Middleware: DefaultServiceMiddleware(), - Security: &configv1.Security{ - PublicPaths: []string{ - "/swagger/*", - "/api/v1/health", - "/api/v1/health/*", - "/api/v1/captcha", - "/api/v1/captcha/*", - "/api/v1/login", - "/api/v1/register", - "/api/v1/current/logout", - "/api/v1/refresh_token", - "/api.v1.services.system.LoginAPI/CaptchaId", - "/api.v1.services.system.LoginAPI/CaptchaImage", - "/api.v1.services.system.LoginAPI/CaptchaResource", - "/api.v1.services.system.LoginAPI/CaptchaResources", - "/api.v1.services.system.LoginAPI/Login", - "/api.v1.services.system.LoginAPI/Register", - "/api.v1.services.system.LoginAPI/Refresh", - //"/api.v1.services.basis.LoginAPI/Logout", - //"/api.v1.services.basis.LoginAPI/CurrentUser", - //"/api.v1.services.basis.LoginAPI/CurrentMenus", - }, - Authz: &configv1.AuthZConfig{ - Disabled: false, - PublicPaths: nil, - Type: "casbin", - Casbin: &configv1.AuthZConfig_CasbinConfig{ - PolicyFile: "", - ModelFile: "", + Security: &configs.SecurityConfig{ + Security: &configv1.Security{ + PublicPaths: []string{ + "/swagger/*", + "/api/v1/health", + "/api/v1/health/*", + "/api/v1/captcha", + "/api/v1/captcha/*", + "/api/v1/login", + "/api/v1/register", + "/api/v1/current/logout", + "/api/v1/refresh_token", + "/api.v1.services.system.LoginAPI/CaptchaId", + "/api.v1.services.system.LoginAPI/CaptchaImage", + "/api.v1.services.system.LoginAPI/CaptchaResource", + "/api.v1.services.system.LoginAPI/CaptchaResources", + "/api.v1.services.system.LoginAPI/Login", + "/api.v1.services.system.LoginAPI/Register", + "/api.v1.services.system.LoginAPI/Refresh", + //"/api.v1.services.basis.LoginAPI/Logout", + //"/api.v1.services.basis.LoginAPI/CurrentUser", + //"/api.v1.services.basis.LoginAPI/CurrentMenus", }, - Opa: nil, - Zanzibar: nil, - }, - Authn: &configv1.AuthNConfig{ - Disabled: false, - Type: "jwt", - Jwt: &configv1.AuthNConfig_JWTConfig{ - Algorithm: "HS512", - SigningKey: SigningKey, - OldSigningKey: "", - ExpireTime: 0, // use default - RefreshTime: 0, // use default - CacheName: "", + Authz: &configv1.AuthZConfig{ + Disabled: false, + PublicPaths: nil, + Type: "casbin", + Casbin: &configv1.AuthZConfig_CasbinConfig{ + PolicyFile: "", + ModelFile: "", + }, + Opa: nil, + Zanzibar: nil, + }, + Authn: &configv1.AuthNConfig{ + Disabled: false, + Type: "jwt", + Jwt: &configv1.AuthNConfig_JWTConfig{ + Algorithm: "HS512", + SigningKey: SigningKey, + OldSigningKey: "", + ExpireTime: 0, // use default + RefreshTime: 0, // use default + CacheName: "", + }, }, }, }, @@ -112,9 +114,11 @@ func DefaultServiceWebsocket() *configv1.WebSocket { } } -func DefaultStorage() *configv1.Data { - return &configv1.Data{ - Database: &configv1.Data_Database{ +func DefaultStorage() *configv1.Storage { + return &configv1.Storage{ + Name: "", + Type: "", + Database: &configv1.Database{ Debug: false, Dialect: "sqlite3", Source: "data/admin.db", @@ -132,22 +136,22 @@ func DefaultStorage() *configv1.Data { ConnectionMaxLifetime: 0, ConnectionMaxIdleTime: 0, }, - Cache: &configv1.Data_Cache{ + Cache: &configv1.Cache{ Driver: "memory", //["none", "redis", "memcached", "memory"] [string.in] - Memcached: &configv1.Data_Memcached{ + Memcached: &configv1.Memcached{ Addr: "", Username: "", Password: "", MaxIdle: 0, Timeout: 0, }, - Memory: &configv1.Data_Memory{ + Memory: &configv1.Memory{ Size: 0, Capacity: 0, Expiration: 0, CleanupInterval: 0, }, - Redis: &configv1.Data_Redis{ + Redis: &configv1.Redis{ Network: "", Addr: "", Password: "", @@ -156,23 +160,18 @@ func DefaultStorage() *configv1.Data { ReadTimeout: 0, WriteTimeout: 0, }, - Badger: &configv1.Data_BadgerDS{ + Badger: &configv1.BadgerDS{ Path: "", SyncWrites: false, ValueLogFileSize: 0, LogLevel: 0, }, }, - Storage: &configv1.Data_Storage{ - Type: "none", //["none", "file", "redis", "mongo", "oss"] [string.in] - File: &configv1.Data_File{ - Root: "", - }, - Redis: &configv1.Data_Redis{}, - Badger: &configv1.Data_BadgerDS{}, - Mongo: &configv1.Data_Mongo{}, - Oss: &configv1.Data_Oss{}, - }, + File: nil, + Redis: nil, + Badger: nil, + Mongo: nil, + Oss: nil, } } @@ -269,10 +268,22 @@ func DefaultRegistry() *configv1.Registry { func DefaultServiceMiddleware() *middlewarev1.Middleware { return &middlewarev1.Middleware{ - Logging: true, - Recovery: true, - Tracing: true, - CircuitBreaker: true, + EnabledMiddlewares: []string{ + "logging", + "recovery", + "tracing", + "circuit_breaker", + "metadata", + "rate_limiter", + "metrics", + "validator", + "jwt", + "selector", + }, + //Logging: true, + //Recovery: true, + //Tracing: true, + //CircuitBreaker: true, Metadata: &middlewarev1.Middleware_Metadata{ Enabled: true, }, @@ -311,11 +322,11 @@ func DefaultServiceMiddleware() *middlewarev1.Middleware { func DefaultServiceGrpc() *configv1.Service_GRPC { return &configv1.Service_GRPC{ - Network: "tcp", - Addr: "${grpc_address:0.0.0.0:18000}", - UseTls: false, - CertFile: "", - KeyFile: "", + Network: "tcp", + Addr: "${grpc_address:0.0.0.0:18000}", + UseTls: false, + //CertFile: "", + //KeyFile: "", Timeout: 0, ShutdownTimeout: 0, ReadTimeout: 0, @@ -327,11 +338,11 @@ func DefaultServiceGrpc() *configv1.Service_GRPC { func DefaultServiceHttp() *configv1.Service_HTTP { return &configv1.Service_HTTP{ - Network: "tcp", - Addr: "${http_address:0.0.0.0:18100}", - UseTls: false, - CertFile: "", - KeyFile: "", + Network: "tcp", + Addr: "${http_address:0.0.0.0:18100}", + UseTls: false, + //CertFile: "", + //KeyFile: "", Timeout: 0, ShutdownTimeout: 0, ReadTimeout: 0, @@ -353,7 +364,7 @@ func DefaultCaptcha() *configs.Captcha { Width: 400, Height: 160, StorageName: "captcha", - Storage: &configv1.Data_Redis{}, + Storage: &configv1.Storage{}, } } @@ -369,10 +380,3 @@ func DefaultRootUser() *configs.RootUser { Mobile: "1380000000", } } - -func AuthConfig() *configs.AuthConfig { - return &configs.AuthConfig{ - //RootUser: DefaultRootUser(), - Captcha: DefaultCaptcha(), - } -} diff --git a/internal/loader/bootstrap_test.go b/internal/loader/bootstrap_test.go index 4c5e21c0..c0e35c1f 100644 --- a/internal/loader/bootstrap_test.go +++ b/internal/loader/bootstrap_test.go @@ -13,14 +13,16 @@ import ( "testing" "time" - _ "github.com/origadmin/contrib/database" + "github.com/go-kratos/kratos/v2/encoding" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/slog-kratos" + "github.com/origadmin/toolkits/codec/toml" "github.com/origadmin/toolkits/crypto/rand" "github.com/origadmin/toolkits/identifier/uuid" "google.golang.org/protobuf/encoding/protojson" + _ "origadmin/application/admin/contrib/database" "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" @@ -36,6 +38,7 @@ var ( ) func init() { + encoding.RegisterCodec(toml.Codec) _, err := os.Stat(testPath) if err != nil { os.MkdirAll(testPath, 0755) @@ -47,7 +50,7 @@ func TestSaveConfig(t *testing.T) { fmt.Println("unixmillis:", time.Now().UnixMilli()) bootstrap := DefaultBootstrap() //bootstrap.Security.Authn.Jwt.SigningMethod = "HS256" - bootstrap.Security.Authn.Jwt.SigningKey = key + //bootstrap.Security.Authn.Jwt.SigningKey = key bootstrap.Middleware.Jwt.Config.Key = key bootstrap.Middleware.Jwt.Config.SigningMethod = "HS512" //bootstrap.Service.Middleware.Jwt.Config.Key = key @@ -141,7 +144,6 @@ func TestLoadConfig(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := LoadLocalBootstrap(filepath.Join(testPath, tt.args.path)) if (err != nil) != tt.wantErr { t.Errorf("LoadConf() error = %v, wantErr %v", err, tt.wantErr) @@ -187,12 +189,12 @@ func TestData_InitDataFromPath(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if tt.fields.Bootstrap == nil { - abs, err := filepath.Abs("../../resources/configs/system/bootstrap.toml") + abs, err := filepath.Abs("../../resources/configs/system") if err != nil { return } log.Infof("abs: %s", abs) - bs, err := LoadLocalBootstrap("../../resources/configs/system/bootstrap.toml") + bs, err := LoadLocalBootstrap(`D:\workspace\project\golang\origadmin\backend\internal\loader\test\test.toml`) if err != nil { t.Fatal(err) return diff --git a/internal/loader/config_test.go b/internal/loader/config_test.go index 3cc9789a..ee79563e 100644 --- a/internal/loader/config_test.go +++ b/internal/loader/config_test.go @@ -31,7 +31,7 @@ func TestNewFileSourceConfig(t *testing.T) { path: "resources/configs", }, want: &configv1.SourceConfig{ - Type: "consul", + Types: []string{"consul"}, File: &configv1.SourceConfig_File{ Path: "resources/configs", }, @@ -52,7 +52,7 @@ func TestNewFileSourceConfig(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { got := &configv1.SourceConfig{ - Type: "consul", + Types: []string{"consul"}, File: &configv1.SourceConfig_File{ Path: "resources/configs", }, diff --git a/internal/loader/load.go b/internal/loader/load.go index 61c5e654..19d75a15 100644 --- a/internal/loader/load.go +++ b/internal/loader/load.go @@ -14,11 +14,9 @@ import ( "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" configv1 "github.com/origadmin/runtime/gen/go/config/v1" - "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/registry" - "origadmin/application/admin/helpers/securityx" "origadmin/application/admin/internal/configs" ) @@ -34,11 +32,8 @@ type AppOptions struct { var ( ProviderSet = wire.NewSet( - NewAuthConfig, NewRegistrar, - NewTokenizer, - NewAuthorizer, - NewAuthenticator, + MockHttpServer, wire.Struct(new(Injector), "*"), wire.Struct(new(InjectorClient), "*"), ) @@ -55,9 +50,7 @@ type Loader interface { } type InjectorClient struct { - Logger log.KLogger - Bootstrap *configs.Bootstrap - Server *http.Server + Server *http.Server } type Injector struct { @@ -70,28 +63,6 @@ func init() { //runtime.RegisterService(service.Service, service.DefaultServiceBuilder) } -func NewAuthenticator(bootstrap *configs.Bootstrap) (security.Authenticator, error) { - return securityx.NewAuthenticator(bootstrap) -} - -func NewTokenizer(bootstrap *configs.Bootstrap) (security.Tokenizer, error) { - authenticator, err := securityx.NewTokenizer(bootstrap) - if err != nil { - return nil, err - } - return authenticator, nil -} - -func NewAuthorizer(bootstrap *configs.Bootstrap) (security.Authorizer, error) { - return securityx.NewAuthorizer(bootstrap) -} - -func NewAuthConfig(bootstrap *configs.Bootstrap) *configs.AuthConfig { - // c := DefaultCaptcha() - // todo Read from the configuration file - return AuthConfig() -} - type loader struct { flags *bootstrap.Bootstrap cfg *configv1.SourceConfig @@ -114,3 +85,7 @@ func NewLoader(bs *bootstrap.Bootstrap) (Loader, error) { } return load, nil } + +func MockHttpServer() *http.Server { + return http.NewServer() +} diff --git a/internal/loader/service_test.go b/internal/loader/service_test.go index 22943206..d0176132 100644 --- a/internal/loader/service_test.go +++ b/internal/loader/service_test.go @@ -176,10 +176,10 @@ func TestServiceDefaultOutput(t *testing.T) { }, }, Middleware: &v11.Middleware{ - Logging: false, - Recovery: false, - Tracing: false, - CircuitBreaker: false, + //Logging: false, + //Recovery: false, + //Tracing: false, + //CircuitBreaker: false, Metadata: &v11.Middleware_Metadata{ Enabled: false, Prefix: "", @@ -219,16 +219,16 @@ func TestServiceDefaultOutput(t *testing.T) { Subject: "", ClaimType: "", TokenHeader: nil, - Config: &jwtv1.Config{ - SigningMethod: "", - Key: "", - Key2: "", - AccessTokenLifetime: 0, - RefreshTokenLifetime: 0, - Issuer: "", - Audience: nil, - TokenType: "", - }, + //Config: &jwtv1.Config{ + // SigningMethod: "", + // Key: "", + // Key2: "", + // AccessTokenLifetime: 0, + // RefreshTokenLifetime: 0, + // Issuer: "", + // Audience: nil, + // TokenType: "", + //}, }, Selector: &selectorv1.Selector{ Enabled: false, @@ -244,10 +244,10 @@ func TestServiceDefaultOutput(t *testing.T) { }, }, Middleware: &v11.Middleware{ - Logging: false, - Recovery: false, - Tracing: false, - CircuitBreaker: false, + //Logging: false, + //Recovery: false, + //Tracing: false, + //CircuitBreaker: false, Metadata: &v11.Middleware_Metadata{ Enabled: false, Prefix: "", @@ -287,16 +287,16 @@ func TestServiceDefaultOutput(t *testing.T) { Subject: "", ClaimType: "", TokenHeader: nil, - Config: &jwtv1.Config{ - SigningMethod: "", - Key: "", - Key2: "", - AccessTokenLifetime: 0, - RefreshTokenLifetime: 0, - Issuer: "", - Audience: nil, - TokenType: "", - }, + //Config: &jwtv1.Config{ + // SigningMethod: "", + // Key: "", + // Key2: "", + // AccessTokenLifetime: 0, + // RefreshTokenLifetime: 0, + // Issuer: "", + // Audience: nil, + // TokenType: "", + //}, }, Selector: &selectorv1.Selector{ Enabled: false, @@ -307,10 +307,9 @@ func TestServiceDefaultOutput(t *testing.T) { }, }, } - services = append(services, testService) + ss = append(ss, testService) // 验证服务添加后的数量和内容 - assert.Len(t, services, 1, "添加服务后应包含一个元素") - assert.Equal(t, "test-service", services[0].Name, "服务名称不匹配") - assert.Equal(t, "v1.0.0", services[0].Version, "服务版本不匹配") + assert.Len(t, ss, 1, "添加服务后应包含一个元素") + assert.Equal(t, "test-service", ss[0].Service.Name, "服务名称不匹配") } diff --git a/internal/mods/auth/dal/auth.dal.go b/internal/mods/auth/dal/auth.dal.go index c1fc22bd..3d4de797 100644 --- a/internal/mods/auth/dal/auth.dal.go +++ b/internal/mods/auth/dal/auth.dal.go @@ -173,9 +173,3 @@ func (r refreshTokenizer) Validate(ctx context.Context, s string) (bool, error) func (r refreshTokenizer) CreateRefreshClaims(ctx context.Context, s string) (security.Claims, error) { return nil, errors.New("not implemented") } - -func wrapRefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { - return &refreshTokenizer{ - tokenizer: tokenizer, - } -} diff --git a/internal/mods/auth/dal/dal.go b/internal/mods/auth/dal/dal.go index e4451fa9..a8ef32c9 100644 --- a/internal/mods/auth/dal/dal.go +++ b/internal/mods/auth/dal/dal.go @@ -18,12 +18,13 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/schema" "github.com/google/wire" - "github.com/origadmin/contrib/database" "github.com/origadmin/entslog/v3" "github.com/origadmin/runtime" + "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/codec" + "origadmin/application/admin/contrib/database" "origadmin/application/admin/helpers/db" "origadmin/application/admin/helpers/id" "origadmin/application/admin/internal/configs" @@ -45,7 +46,6 @@ type Data struct { // ProviderSet is data providers. var ProviderSet = wire.NewSet( - wire.Struct(new(LoginData), "*"), NewData, NewAuthRepo, NewLoginRepo, @@ -565,3 +565,16 @@ func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.P func resourceOrderBy(orders []string) []resource.OrderOption { return db.OrderBy[resource.OrderOption](orders) } + +func wrapRefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { + return &refreshTokenizer{ + tokenizer: tokenizer, + } +} + +func RefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { + if rt, ok := tokenizer.(security.RefreshTokenizer); ok { + return rt + } + return wrapRefreshTokenizer(tokenizer) +} diff --git a/internal/mods/auth/dal/login.dal.go b/internal/mods/auth/dal/login.dal.go index 076121a7..07887bf0 100644 --- a/internal/mods/auth/dal/login.dal.go +++ b/internal/mods/auth/dal/login.dal.go @@ -19,6 +19,7 @@ import ( "github.com/origadmin/toolkits/crypto/rand" "github.com/origadmin/toolkits/errors/httperr" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/api/v1/services/system" @@ -30,7 +31,8 @@ import ( ) type loginRepo struct { - *LoginData + *data.LoginData + User *userRepo captcha *captcha.Captcha bufpool *sync.Pool } @@ -327,13 +329,6 @@ func fromSecurityClaims(claims security.Claims) *securityv1.Claims { } } -func RefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { - if rt, ok := tokenizer.(security.RefreshTokenizer); ok { - return rt - } - return wrapRefreshTokenizer(tokenizer) -} - func (repo loginRepo) rootUser() *configs.RootUser { return repo.LoginData.RootUser } @@ -381,15 +376,6 @@ func (repo loginRepo) getCaptchaImage(id string) (string, error) { return item.EncodeB64string(), nil } -type LoginData struct { - Captcha *configs.Captcha - RootUser *configs.RootUser - Tokenizer security.RefreshTokenizer - Resource systemdto.ResourceRepo - Role systemdto.RoleRepo - User systemdto.UserRepo -} - func NewCaptcha(cfg *configs.Captcha) *captcha.Captcha { return captcha.NewCaptcha(&captcha.Config{ DriverDigit: &captcha.DriverDigit{ @@ -403,9 +389,9 @@ func NewCaptcha(cfg *configs.Captcha) *captcha.Captcha { } // NewLoginRepo . -func NewLoginRepo(data *LoginData, logger log.KLogger) dto.LoginRepo { +func NewLoginRepo(dd *data.Data, ld *data.LoginData) dto.LoginRepo { var err error - cfg := data.RootUser + cfg := ld.RootUser // todo: generate random password for root user if not exists if cfg.RandomPassword { passwd := rand.GenerateRandom(12) @@ -426,8 +412,9 @@ func NewLoginRepo(data *LoginData, logger log.KLogger) dto.LoginRepo { //} return &loginRepo{ bufpool: BufPool(), - LoginData: data, - captcha: NewCaptcha(data.Captcha), + LoginData: ld, + User: &userRepo{db: dd}, + captcha: NewCaptcha(ld.Captcha), } } diff --git a/internal/mods/auth/dal/user.dal.go b/internal/mods/auth/dal/user.dal.go new file mode 100644 index 00000000..4f9c1ba9 --- /dev/null +++ b/internal/mods/auth/dal/user.dal.go @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dal is the data access object +package dal + +import ( + "errors" + "time" + + "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/db" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/mods/system/dto" +) + +type userRepo struct { + db *data.Data +} + +func (repo userRepo) AddRoleIDs(ctx context.Context, i int64, int64s []int64, option ...dto.UserMutationOption) error { + //TODO implement me + panic("implement me") +} + +func (repo userRepo) UpdateUserStatus(ctx context.Context, id int64, status int8, options ...dto.UserQueryOption) error { + err := repo.db.User(ctx).UpdateOneID(id).SetStatus(status).Exec(ctx) + if err != nil { + return err + } + return nil +} + +func (repo userRepo) Current(ctx context.Context, id int64) (*dto.UserPB, error) { + return repo.Get(ctx, id) +} + +func (repo userRepo) ListResourceByUserID(ctx context.Context, id int64, + option ...dto.UserQueryOption) ([]*dto.ResourcePB, error) { + resources, err := repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResources(resources), nil +} + +func (repo userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*dto.UserNode, error) { + query := repo.db.User(ctx).Query().Where(user.UsernameEQ(username)) + var option dto.UserQueryOption + if len(fields) > 0 { + option.SelectFields = fields + } + query = userQueryOptions(query, option) + result, err := query.First(ctx) + if err != nil { + return nil, err + } + return &dto.UserNode{ + UserPB: *dto.ConvertUser2PB(result), + EncryptedPassword: result.EncryptedPassword, + }, nil +} + +func (repo userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { + return repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().IDs(ctx) +} + +func (repo userRepo) Get(ctx context.Context, id int64, options ...dto.UserQueryOption) (*dto.UserPB, error) { + var option dto.UserQueryOption + if len(options) > 0 { + option = options[0] + } + query := repo.db.User(ctx).Query().Where(user.ID(id)) + query = userQueryOptions(query, option) + result, err := query.First(ctx) + if err != nil { + return nil, err + } + return dto.ConvertUser2PB(result), nil +} + +func (repo userRepo) Create(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { + var option dto.UserMutationOption + if len(options) > 0 { + option = options[0] + } + + var err error + exist, err := repo.db.User(ctx).Query().Where(user.UsernameEQ(userPB.Username)).Exist(ctx) + if err != nil || exist { + return nil, errors.New("user already exists") + } + obj := dto.ConvertUserPB2Object(userPB) + obj.CreateTime = time.Now() + obj.UpdateTime = time.Now() + err = repo.db.Tx(ctx, func(ctx context.Context) error { + create := repo.db.User(ctx).Create() + create.SetUser(obj, option.Fields...) + saved, err := create.Save(ctx) + if err != nil { + return err + } + userPB = dto.ConvertUser2PB(saved) + return nil + }) + if err != nil { + return nil, err + } + return userPB, nil +} + +func (repo userRepo) Delete(ctx context.Context, id int64) error { + return repo.db.Tx(ctx, func(ctx context.Context) error { + return repo.db.User(ctx).DeleteOneID(id).Exec(ctx) + }) +} + +func (repo userRepo) Update(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { + obj := dto.ConvertUserPB2Object(userPB) + obj.UpdateTime = time.Now() + err := repo.db.Tx(ctx, func(ctx context.Context) error { + update := repo.db.User(ctx).UpdateOneID(userPB.Id) + if len(userPB.Roles) > 0 { + update.ClearRoles() + update.AddRoles(dto.ConvertRolesPB2Object(userPB.Roles)...) + } else { + update.ClearRoles() + } + if len(userPB.RoleIds) > 0 { + update.ClearRoles() + update.AddRoleIDs(userPB.RoleIds...) + } else { + update.ClearRoles() + } + update.SetUser(obj, user.SelectColumns([]string{ + user.FieldNickname, + user.FieldUsername, + user.FieldPhone, + user.FieldEmail, + user.FieldUpdateTime})...) + saved, err := update.Save(ctx) + if err != nil { + return err + } + userPB = dto.ConvertUser2PB(saved) + return nil + }) + if err != nil { + return nil, err + } + return userPB, nil +} + +func (repo userRepo) List(ctx context.Context, in *pb.ListUsersRequest, options ...dto.UserQueryOption) ([]*dto.UserPB, int32, error) { + var option dto.UserQueryOption + if len(options) > 0 { + option = options[0] + } + + query := repo.db.User(ctx).Query() + if option.IncludeRoles { + query = query.WithRoles() + } + if in.Title != "" { + query = query.Where(user.Or(user.UsernameContainsFold(in.Title), user.PhoneContainsFold(in.Title), user.EmailContainsFold(in.Title))) + } + + if v := option.Status; v > 0 { + query = query.Where(user.StatusEQ(v)) + } + + return userPageQuery(ctx, query, in, option) +} + +// NewUserRepo . +func NewUserRepo(r runtime.Runtime, db *data.Data) dto.UserRepo { + return &userRepo{ + db: db, + } +} + +func userPageQuery(ctx context.Context, query *ent.UserQuery, in *pb.ListUsersRequest, option dto.UserQueryOption) ([]*dto.UserPB, int32, error) { + if in.OnlyCount { + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + return nil, int32(count), nil + } + + query = userQueryOptions(query, option) + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + query = db.PaginationQuery(query, in, !in.NoPaging) + result, err := query.All(ctx) + return dto.ConvertUsers(result), int32(count), err +} + +func userQueryOptions(query *ent.UserQuery, option dto.UserQueryOption) *ent.UserQuery { + if len(option.SelectFields) > 0 { + query = query.Select(option.SelectFields...).UserQuery + } + if len(option.OmitFields) > 0 { + query = query.Omit(option.OmitFields...).UserQuery + } + if len(option.OrderFields) > 0 { + query = query.Order(userOrderBy(option.OrderFields)...) + } + return query +} + +func userOrderBy(fields []string, opts ...sql.OrderTermOption) []user.OrderOption { + var orders []user.OrderOption + for _, field := range fields { + orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) + } + return orders +} diff --git a/internal/mods/system/biz/biz.go b/internal/mods/system/biz/biz.go index 96fb99dc..f2a98457 100644 --- a/internal/mods/system/biz/biz.go +++ b/internal/mods/system/biz/biz.go @@ -8,22 +8,22 @@ import ( "net/http" "github.com/google/wire" - "github.com/origadmin/toolkits/errors/httperr" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/toolkits/errors/httperr" pb "origadmin/application/admin/api/v1/services/system" ) // ProviderSet is biz providers. var ProviderSet = wire.NewSet( - NewAuthServiceBiz, - NewLoginServiceBiz, - NewPersonalServiceBiz, + //NewAuthServiceBiz, + //NewLoginServiceBiz, + //NewPersonalServiceBiz, NewResourceServiceBiz, NewRoleServiceBiz, NewUserServiceBiz, NewPermissionServiceBiz, - NewCasbinSourceServiceBiz, + //NewCasbinSourceServiceBiz, ) var ( diff --git a/internal/mods/system/biz/casbin.biz.go b/internal/mods/system/biz/casbin.biz.go index 828973d6..9440ca51 100644 --- a/internal/mods/system/biz/casbin.biz.go +++ b/internal/mods/system/biz/casbin.biz.go @@ -10,8 +10,9 @@ import ( "sync/atomic" "time" - "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" "google.golang.org/grpc" pb "origadmin/application/admin/api/v1/services/system" @@ -103,7 +104,8 @@ func newGroupingResponse(rule *pb.GroupingRule) *pb.StreamRulesResponse { } // NewCasbinSourceServiceBiz new a CasbinSource use case. -func NewCasbinSourceServiceBiz(repo dto.CasbinSourceRepo, logger log.KLogger) *CasbinSourceServiceBiz { - return &CasbinSourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger), + +func NewCasbinSourceServiceBiz(r runtime.Runtime, repo dto.CasbinSourceRepo) *CasbinSourceServiceBiz { + return &CasbinSourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger()), lastModified: &atomic.Int64{}} } diff --git a/internal/mods/system/biz/login.biz.go b/internal/mods/system/biz/login.biz.go index d39bf20f..79ac7679 100644 --- a/internal/mods/system/biz/login.biz.go +++ b/internal/mods/system/biz/login.biz.go @@ -8,8 +8,9 @@ package biz import ( "context" - "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" @@ -68,6 +69,6 @@ func (biz LoginServiceBiz) TokenRefresh(ctx context.Context, in *pb.TokenRefresh } // NewLoginServiceBiz new a Login use case. -func NewLoginServiceBiz(repo dto.LoginRepo, logger log.KLogger) *LoginServiceBiz { - return &LoginServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger)} +func NewLoginServiceBiz(r runtime.Runtime, repo dto.LoginRepo) *LoginServiceBiz { + return &LoginServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} } diff --git a/internal/mods/system/biz/permission.biz.go b/internal/mods/system/biz/permission.biz.go index 35b22af4..df9acc06 100644 --- a/internal/mods/system/biz/permission.biz.go +++ b/internal/mods/system/biz/permission.biz.go @@ -6,9 +6,10 @@ package biz import ( + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" @@ -85,6 +86,6 @@ func (biz PermissionServiceBiz) DeletePermission(ctx context.Context, in *pb.Del } // NewPermissionServiceBiz new a PermissionPB use case. -func NewPermissionServiceBiz(repo dto.PermissionRepo, logger log.KLogger) *PermissionServiceBiz { - return &PermissionServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger)} +func NewPermissionServiceBiz(r runtime.Runtime, repo dto.PermissionRepo) *PermissionServiceBiz { + return &PermissionServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} } diff --git a/internal/mods/system/biz/personal.biz.go b/internal/mods/system/biz/personal.biz.go index b1e90a89..5734af1a 100644 --- a/internal/mods/system/biz/personal.biz.go +++ b/internal/mods/system/biz/personal.biz.go @@ -8,8 +8,9 @@ package biz import ( "context" - "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" @@ -56,6 +57,6 @@ func (biz PersonalServiceBiz) UpdatePersonalSetting(ctx context.Context, in *pb. } // NewPersonalServiceBiz new a Personal use case. -func NewPersonalServiceBiz(repo dto.PersonalRepo, logger log.KLogger) *PersonalServiceBiz { - return &PersonalServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger)} +func NewPersonalServiceBiz(r runtime.Runtime, repo dto.PersonalRepo) *PersonalServiceBiz { + return &PersonalServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} } diff --git a/internal/mods/system/biz/resource.biz.go b/internal/mods/system/biz/resource.biz.go index 229deade..2b980143 100644 --- a/internal/mods/system/biz/resource.biz.go +++ b/internal/mods/system/biz/resource.biz.go @@ -6,9 +6,10 @@ package biz import ( + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/data/entity/ent/resource" @@ -94,6 +95,6 @@ func (biz ResourceServiceBiz) DeleteResource(ctx context.Context, in *pb.DeleteR } // NewResourceServiceBiz new a ResourcePB use case. -func NewResourceServiceBiz(repo dto.ResourceRepo, logger log.KLogger) *ResourceServiceBiz { - return &ResourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger)} +func NewResourceServiceBiz(r runtime.Runtime, repo dto.ResourceRepo) *ResourceServiceBiz { + return &ResourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} } diff --git a/internal/mods/system/biz/role.biz.go b/internal/mods/system/biz/role.biz.go index 3bea9ed3..78afc8d2 100644 --- a/internal/mods/system/biz/role.biz.go +++ b/internal/mods/system/biz/role.biz.go @@ -6,9 +6,10 @@ package biz import ( + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" @@ -97,6 +98,6 @@ func (biz RoleServiceBiz) DeleteRole(ctx context.Context, in *pb.DeleteRoleReque } // NewRoleServiceBiz new a RolePB use case. -func NewRoleServiceBiz(repo dto.RoleRepo, logger log.KLogger) *RoleServiceBiz { - return &RoleServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger)} +func NewRoleServiceBiz(r runtime.Runtime, repo dto.RoleRepo) *RoleServiceBiz { + return &RoleServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} } diff --git a/internal/mods/system/biz/user.biz.go b/internal/mods/system/biz/user.biz.go index 005dd7fe..ad8ddc0b 100644 --- a/internal/mods/system/biz/user.biz.go +++ b/internal/mods/system/biz/user.biz.go @@ -8,9 +8,10 @@ package biz import ( "fmt" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/dto" @@ -171,6 +172,7 @@ func (biz UserServiceBiz) DeleteUser(ctx context.Context, in *pb.DeleteUserReque } // NewUserServiceBiz new a UserPB use case. -func NewUserServiceBiz(repo dto.UserRepo, logger log.KLogger) *UserServiceBiz { - return &UserServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger)} + +func NewUserServiceBiz(r runtime.Runtime, repo dto.UserRepo) *UserServiceBiz { + return &UserServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} } diff --git a/internal/mods/system/dal/auth.dal.go b/internal/mods/system/dal/auth.dal.go index c1fc22bd..d41ca114 100644 --- a/internal/mods/system/dal/auth.dal.go +++ b/internal/mods/system/dal/auth.dal.go @@ -9,17 +9,18 @@ import ( "errors" "sync" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/interfaces/security" - "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/mods/system/dto" ) type authRepo struct { - DB *Data + DB *data.Data BufPool *sync.Pool Tokenizer security.Tokenizer Authorizer security.Authorizer @@ -99,7 +100,7 @@ func fromClaims(claims security.Claims, method, path string) security.Policy { } // NewAuthRepo . -func NewAuthRepo(db *Data, logger log.KLogger) dto.AuthRepo { +func NewAuthRepo(r runtime.Runtime, db *data.Data) dto.AuthRepo { return &authRepo{ DB: db, BufPool: BufPool(), diff --git a/internal/mods/system/dal/casbin.dal.go b/internal/mods/system/dal/casbin.dal.go index 8a84bee9..9720ef77 100644 --- a/internal/mods/system/dal/casbin.dal.go +++ b/internal/mods/system/dal/casbin.dal.go @@ -9,7 +9,10 @@ import ( "context" "strconv" + "github.com/origadmin/runtime" + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/mods/system/dto" ) @@ -20,7 +23,7 @@ type CasbinSourceConfig struct { type casbinSourceRepo struct { ctx context.Context - data *Data + data *data.Data config *CasbinSourceConfig } @@ -88,9 +91,9 @@ func (c casbinSourceRepo) ListGroupings(ctx context.Context, in *pb.ListGrouping } // NewCasbinSourceRepo returns a new CasbinSourceRepo -func NewCasbinSourceRepo(data *Data) (dto.CasbinSourceRepo, error) { +func NewCasbinSourceRepo(r runtime.Runtime, db *data.Data) (dto.CasbinSourceRepo, error) { c := &casbinSourceRepo{ - data: data, + data: db, config: &CasbinSourceConfig{ PrefixNumberID: func(prefix string, id int64) string { return prefix + "_" + strconv.FormatInt(id, 10) @@ -104,7 +107,7 @@ func NewCasbinSourceRepo(data *Data) (dto.CasbinSourceRepo, error) { // This method does not ensure the existence of database, user should create database manually. func NewCasbinSourceWithClient(client *ent.Client) (dto.CasbinSourceRepo, error) { c := &casbinSourceRepo{ - data: NewDataWithClient(client), + data: data.NewDataWithClient(client), config: &CasbinSourceConfig{ PrefixNumberID: func(prefix string, id int64) string { return prefix + "_" + strconv.FormatInt(id, 10) diff --git a/internal/mods/system/dal/dal.go b/internal/mods/system/dal/dal.go index 4e0f19ab..7814e1f7 100644 --- a/internal/mods/system/dal/dal.go +++ b/internal/mods/system/dal/dal.go @@ -5,563 +5,19 @@ package dal import ( - "context" - "errors" - "fmt" - "os" - "path/filepath" - "strconv" - "strings" - "time" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/schema" "github.com/google/wire" - "github.com/origadmin/contrib/database" - "github.com/origadmin/entslog/v3" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/codec" - - "origadmin/application/admin/helpers/id" - "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/department" - "origadmin/application/admin/internal/data/entity/ent/predicate" - "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dto" ) -const ( - TreePathDelimiter = "." -) - -// Data . -type Data struct { - *ent.Database -} - // ProviderSet is data providers. var ProviderSet = wire.NewSet( - wire.Struct(new(LoginData), "*"), - NewData, - NewAuthRepo, - NewLoginRepo, - NewPersonalRepo, + //NewAuthRepo, + //NewLoginRepo, + //NewPersonalRepo, NewMenuRepo, NewResourceRepo, NewRoleRepo, NewUserRepo, NewPermissionRepo, - NewCasbinSourceRepo, - RefreshTokenizer, + //NewCasbinSourceRepo, + //RefreshTokenizer, ) - -// NewTrans returns a transaction wit data -//func NewTrans(data *Data) database.Trans { -// return data -//} - -const FKSuffix = "_fk=1" - -func FixSource(source string) string { - // Check if the source already contains the FK parameter - if strings.Contains(source, FKSuffix) { - return source - } - - // Check if the source already contains parameters - if strings.Contains(source, "?") { - // If parameters exist, append with & - if !strings.HasSuffix(source, "&") { - source += "&" - } - source += FKSuffix - } else { - // If no parameters exist, append with ? - source += "?" + FKSuffix - } - return source -} - -func debugDatabase(driver dialect.Driver, debug bool) dialect.Driver { - if debug { - return entslog.New(driver) - } - return driver -} - -// NewData . -func NewData(bootstrap *configs.Bootstrap, logger log.KLogger) (*Data, func(), error) { - if bootstrap == nil { - return nil, nil, errors.New("bootstrap is nil") - } - - cfg := bootstrap.GetStorage().GetDatabase() - if cfg == nil { - return nil, nil, errors.New("data source not found") - } - - drv, err := database.Open(cfg) - log.Infow("msg", "connecting to database", "dialect", cfg.Dialect, "source", cfg.Source) - if err != nil { - log.Errorw("msg", "failed opening connection to database", "error", err) - return nil, nil, err - } - - // Run the auto migration tool. - sqldb := debugDatabase(sql.OpenDB(cfg.Dialect, drv), cfg.Debug) - db := ent.NewDatabase(ent.Driver(sqldb)) - if true || cfg.GetMigration().GetEnabled() { - if err := db.Migration( - context.Background(), - schema.WithDropIndex(true), - schema.WithDropColumn(true), - schema.WithForeignKeys(false)); err != nil { - log.Errorw("msg", "failed creating schema resources", "error", err) - return nil, nil, err - } - } - - data := &Data{ - Database: db, - } - - // 初始化数据 - if err := data.InitDataFromPath(context.Background(), ""); err != nil { - log.Errorw("failed to init data", "error", err) - return nil, nil, err - } - - return data, func() { - log.Info("closing the data resources") - if err := drv.Close(); err != nil { - log.Error(err) - } - }, nil -} - -func NewDataWithClient(client *ent.Client) *Data { - return &Data{ - Database: ent.NewDatabaseWithClient(client), - } -} - -/* <<<<<<<<<<<<<< ✨ Windsurf Command ⭐ >>>>>>>>>>>>>>>> */ -// InitDataFromPath . -/* <<<<<<<<<< 5ac4ba63-529d-41b7-890c-f5204968f606 >>>>>>>>>>> */ -func (obj *Data) InitDataFromPath(ctx context.Context, path string, filters ...string) error { - type data struct { - name string - fn func(ctx context.Context, filename string) error - } - initializers := []data{ - { - name: "resource", - fn: obj.InitResourceFromFile, - }, - { - name: "role", - fn: obj.InitRoleFromFile, - }, - { - name: "user", - fn: obj.InitUserFromFile, - }, - { - name: "department", - fn: obj.InitDepartmentFromFile, - }, - { - name: "position", - fn: obj.InitPositionFromFile, - }, - { - name: "permission", - fn: obj.InitPermissionFromFile, - }, - } - actions := make([]data, 0) - for _, di := range initializers { - for _, filter := range filters { - if di.name == filter { - actions = append(actions, di) - } - } - - } - for _, action := range actions { - action.name = filepath.Join(path, action.name+".json") - err := action.fn(ctx, action.name) - if err != nil { - return err - } - } - - return nil -} -func (obj *Data) InitResourceFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var resources []*dto.ResourceNode - err = codec.DecodeFromFile(abs, &resources) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Resource data file not found, skip init resource data from file", "file", abs) - return nil - } - return err - } - for i, pb := range resources { - log.Infow("msg", "Processing resource", "index", i, "resourceId", pb.Id, "resourceKeyword", pb.Keyword, "resourceName", pb.Name) - if pb.Children != nil { - for i2, child := range pb.Children { - log.Infow("msg", "Processing child", "index", i2, "childId", child.Id, "childKeyword", child.Keyword, "childName", child.Name) - } - } - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createResourceBatchWithParent(ctx, resources, nil) - }) -} - -func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto.ResourceNode, parent *dto.ResourcePB) error { - total := len(items) - log.Infow("msg", "Starting createResourceBatchWithParent", "totalItems", total) - - for i, item := range items { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - var pid int64 - if parent != nil { - pid = parent.Id - log.Infow("msg", "Parent ID set", "parentId", pid) - } - founded := false - switch { - case item.Id != 0: - log.Infow("Checking item by ID", "itemId", item.Id) - exists, err := obj.Resource(ctx).Query().Where(resource.ID(item.Id)).Exist(ctx) - if err != nil { - log.Errorw("msg", "Error checking item by ID", "itemId", item.Id, "error", err) - return err - } - if exists { - log.Infow("msg", "Item already exists by ID", "itemId", item.Id) - continue - } - case item.Keyword != "": - log.Infow("msg", "Checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid) - var wheres = []predicate.Resource{ - resource.Keyword(item.Keyword), - } - if pid != 0 { - wheres = append(wheres, resource.ParentID(pid)) - } - exists, err := obj.Resource(ctx).Query().Where(wheres...).Exist(ctx) - if err != nil { - log.Errorw("msg", "Error checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) - return err - } - if exists { - resourceItem, err := obj.Resource(ctx).Query().Where(wheres...).First(ctx) - if err != nil { - log.Errorw("msg", "Error fetching item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) - return err - } - founded = true - item.Id = resourceItem.ID - log.Infow("msg", "Item found by Keyword", "itemKeyword", item.Keyword, "itemId", item.Id) - } - case item.Name != "": - log.Infow("msg", "Checking item by Name", "itemName", item.Name, "parentId", pid) - var conditions = []predicate.Resource{ - resource.Name(item.Name), - } - if pid != 0 { - conditions = append(conditions, resource.ParentID(pid)) - } - exists, err := obj.Resource(ctx).Query().Where(conditions...).Exist(ctx) - if err != nil { - log.Errorw("msg", "Error checking item by Name", "itemName", item.Name, "parentId", pid, "error", err) - return err - } - if exists { - resourceItem, err := obj.Resource(ctx).Query().Where(conditions...).First(ctx) - if err != nil { - log.Errorw("msg", "Error fetching item by Name", "itemName", item.Name, "parentId", pid, "error", err) - return err - } - founded = true - item.Id = resourceItem.ID - log.Infow("msg", "Item found by Name", "itemName", item.Name, "itemId", item.Id) - } - default: - log.Infow("msg", "No ID, Keyword, or Name provided for item") - } - - if !founded { - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if item.Status == 0 { - item.Status = int32(dto.UserStatusActive) - log.Infow("msg", "Setting default status for item", "itemId", item.Id, "status", item.Status) - } - if item.Sequence == 0 { - item.Sequence = int32(total - i) - log.Infow("msg", "Setting default sequence for item", "itemId", item.Id, "sequence", item.Sequence) - } - - item.ParentId = pid - if parent != nil { - item.TreePath = parent.TreePath + strconv.Itoa(int(pid)) + TreePathDelimiter - log.Infow("msg", "Setting parent path for item", "itemId", item.Id, "treePath", item.TreePath) - } - itemObj := dto.ConvertResourcePB2Object(&item.ResourcePB) - itemObj.UpdateTime = time.Now() - itemObj.CreateTime = time.Now() - if _, err := obj.Resource(ctx).Create().SetResource(itemObj).Save(ctx); err != nil { - log.Errorw("msg", "Error creating resource item", "itemId", item.Id, "sequence", item.Sequence, "error", err) - return err - } - log.Infow("msg", "Resource item created successfully", "itemId", item.Id) - } - - if len(item.Children) != 0 { - log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) - if err := obj.createResourceBatchWithParent(ctx, item.Children, &item.ResourcePB); err != nil { - log.Errorw("Error processing children", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Children processed successfully", "itemId", item.Id) - } - } - log.Infow("msg", "Finished createResourceBatchWithParent") - return nil -} - -func (obj *Data) InitUserFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var users []*dto.UserNode - err = codec.DecodeFromFile(abs, &users) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("User data file not found, skip init user data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createUserBatch(ctx, users) - }) -} - -func (obj *Data) createUserBatch(ctx context.Context, users []*dto.UserNode) error { - total := len(users) - log.Infow("msg", "Starting createUserBatch", "totalItems", total) - for i, item := range users { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemUsername", item.Username, "itemNickname", item.Nickname) - user, ps, err := dto.MakeCreateUser(&item.UserPB, item.Username, item.Password, dto.UserMutationOption{}) - if err != nil { - return err - } - fmt.Println("generate user: ", user.Username, "with password: ", ps) - if _, err := obj.User(ctx).Create().SetIsSystem(item.IsSystem).SetUser(dto.ConvertUserPB2Object(user)). - Save(ctx); err != nil { - log.Errorw("msg", "Error creating user item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "User item created successfully", "itemId", item.Id, "itemUuid", item.Uuid) - } - log.Infow("msg", "Finished createUserBatch") - return nil -} - -func (obj *Data) InitRoleFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var roles []*dto.RolePB - err = codec.DecodeFromFile(abs, &roles) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Role data file not found, skip init role data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createRoleBatch(ctx, roles) - }) -} - -func (obj *Data) createRoleBatch(ctx context.Context, roles []*dto.RolePB) error { - total := len(roles) - log.Infow("msg", "Starting createRoleBatch", "totalItems", total) - for i, item := range roles { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if _, err := obj.Role(ctx).Create().SetRole(dto.ConvertRolePB2Object(item)).Save(ctx); err != nil { - log.Errorw("msg", "Error creating role item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Role item created successfully", "itemId", item.Id) - } - log.Infow("msg", "Finished createRoleBatch") - return nil -} - -func (obj *Data) InitDepartmentFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var departments []*dto.DepartmentNode - err = codec.DecodeFromFile(abs, &departments) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Department data file not found, skip init department data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createDepartmentBatch(ctx, departments, nil) - }) -} - -func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.DepartmentNode, parent *dto.DepartmentPB) error { - total := len(departments) - log.Infow("msg", "Starting createDepartmentBatch", "totalItems", total) - for i, item := range departments { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if parent != nil { - item.ParentId = parent.Id - item.TreePath = parent.TreePath + strconv.Itoa(int(parent.Id)) + TreePathDelimiter - } - - if _, err := obj.Department(ctx).Create(). - SetDepartment(dto.ConvertDepartmentPB2Object(&item.DepartmentPB)). - Save(ctx); err != nil { - log.Errorw("msg", "Error creating department item", "itemId", item.Id, "error", err) - return err - } - - log.Infow("msg", "Department item created successfully", "itemId", item.Id) - if len(item.Children) != 0 { - log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) - if err := obj.createDepartmentBatch(ctx, item.Children, &item.DepartmentPB); err != nil { - log.Errorw("Error processing children", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Children processed successfully", "itemId", item.Id) - } - } - log.Infow("msg", "Finished createDepartmentBatch") - return nil -} - -func (obj *Data) InitPositionFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var positions []*dto.PositionNode - err = codec.DecodeFromFile(abs, &positions) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Position data file not found, skip init position data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createPositionBatch(ctx, positions) - }) -} - -func (obj *Data) createPositionBatch(ctx context.Context, positions []*dto.PositionNode) error { - total := len(positions) - log.Infow("msg", "Starting createPositionBatch", "totalItems", total) - for i, item := range positions { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - dept, err := obj.Department(ctx).Query().Where(department.Keyword(item.DepartmentKeyword)).Only(ctx) - if err != nil { - return err - } - - if _, err := obj.Position(ctx).Create().SetPosition(&dto.Position{ - ID: item.Id, - CreateTime: time.Now(), - UpdateTime: time.Now(), - Name: item.Name, - Keyword: item.Keyword, - Description: item.Description, - DepartmentID: dept.ID, - }).Save(ctx); err != nil { - log.Errorw("msg", "Error creating position item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Position item created successfully", "itemId", item.Id) - } - log.Infow("msg", "Finished createPositionBatch") - return nil -} - -func (obj *Data) InitPermissionFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var permissions []*dto.PermissionNode - err = codec.DecodeFromFile(abs, &permissions) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Permission data file not found, skip init permission data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createPermissionBatch(ctx, permissions) - }) -} - -func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.PermissionNode) error { - total := len(permissions) - log.Infow("msg", "Starting createPermissionBatch", "totalItems", total) - for i, item := range permissions { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if _, err := obj.Permission(ctx).Create(). - SetPermission(dto.ConvertPermissionPB2Object(&item.PermissionPB)). - Save(ctx); err != nil { - log.Errorw("msg", "Error creating permission item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Permission item created successfully", "itemId", item.Id) - } - log.Infow("msg", "Finished createPermissionBatch") - return nil -} diff --git a/internal/mods/system/dal/login.dal.go b/internal/mods/system/dal/login.dal.go index 076121a7..a7eea36e 100644 --- a/internal/mods/system/dal/login.dal.go +++ b/internal/mods/system/dal/login.dal.go @@ -10,6 +10,7 @@ import ( "sync" kerr "github.com/go-kratos/kratos/v2/errors" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" jwtv1 "github.com/origadmin/runtime/gen/go/security/jwt/v1" securityv1 "github.com/origadmin/runtime/gen/go/security/v1" @@ -390,20 +391,8 @@ type LoginData struct { User systemdto.UserRepo } -func NewCaptcha(cfg *configs.Captcha) *captcha.Captcha { - return captcha.NewCaptcha(&captcha.Config{ - DriverDigit: &captcha.DriverDigit{ - Height: int(cfg.Height), - Width: int(cfg.Width), - Length: int(cfg.Length), - MaxSkew: 0.7, - DotCount: 120, - }, - }) -} - // NewLoginRepo . -func NewLoginRepo(data *LoginData, logger log.KLogger) dto.LoginRepo { +func NewLoginRepo(r runtime.Runtime, data *LoginData) dto.LoginRepo { var err error cfg := data.RootUser // todo: generate random password for root user if not exists diff --git a/internal/mods/system/dal/menu.dal.go b/internal/mods/system/dal/menu.dal.go index f31f4705..e37e4e8e 100644 --- a/internal/mods/system/dal/menu.dal.go +++ b/internal/mods/system/dal/menu.dal.go @@ -5,13 +5,14 @@ package dal import ( - "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/mods/system/dto" ) type menuRepo struct { - db *Data + db *data.Data } // @@ -109,7 +110,7 @@ type menuRepo struct { //} // NewMenuRepo . -func NewMenuRepo(db *Data, logger log.KLogger) dto.MenuRepo { +func NewMenuRepo(r runtime.Runtime, db *data.Data) dto.MenuRepo { return &menuRepo{ db: db, } diff --git a/internal/mods/system/dal/permission.dal.go b/internal/mods/system/dal/permission.dal.go index e83d89f4..b2e05729 100644 --- a/internal/mods/system/dal/permission.dal.go +++ b/internal/mods/system/dal/permission.dal.go @@ -8,17 +8,18 @@ import ( "context" "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/db" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/mods/system/dto" ) type permissionRepo struct { - db *Data + db *data.Data } func (repo permissionRepo) Get(ctx context.Context, id int64, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { @@ -104,7 +105,7 @@ func (repo permissionRepo) List(ctx context.Context, in *dto.ListPermissionsRequ } // NewPermissionRepo . -func NewPermissionRepo(db *Data, logger log.KLogger) dto.PermissionRepo { +func NewPermissionRepo(r runtime.Runtime, db *data.Data) dto.PermissionRepo { return &permissionRepo{ db: db, } diff --git a/internal/mods/system/dal/personal.dal.go b/internal/mods/system/dal/personal.dal.go index dfa605c7..7ea4c065 100644 --- a/internal/mods/system/dal/personal.dal.go +++ b/internal/mods/system/dal/personal.dal.go @@ -8,10 +8,12 @@ import ( "context" "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/securityx" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/user" @@ -19,7 +21,7 @@ import ( ) type personalRepo struct { - db *Data + db *data.Data } func (repo personalRepo) GetPersonalProfile(ctx context.Context, in *pb.GetPersonalProfileRequest) (*pb.GetPersonalProfileResponse, error) { @@ -92,7 +94,7 @@ func (repo personalRepo) ListResources(ctx context.Context, in *dto.ListResource } // NewPersonalRepo . -func NewPersonalRepo(db *Data, logger log.KLogger) dto.PersonalRepo { +func NewPersonalRepo(r runtime.Runtime, db *data.Data) dto.PersonalRepo { return &personalRepo{ db: db, } diff --git a/internal/mods/system/dal/resource.dal.go b/internal/mods/system/dal/resource.dal.go index 9be732a9..73946b79 100644 --- a/internal/mods/system/dal/resource.dal.go +++ b/internal/mods/system/dal/resource.dal.go @@ -8,17 +8,19 @@ import ( "context" "strconv" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/db" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/mods/system/dto" ) type resourceRepo struct { - db *Data + db *data.Data } func (repo resourceRepo) Get(ctx context.Context, id int64, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { @@ -109,7 +111,7 @@ func (repo resourceRepo) List(ctx context.Context, in *dto.ListResourcesRequest, } // NewResourceRepo . -func NewResourceRepo(db *Data, logger log.KLogger) dto.ResourceRepo { +func NewResourceRepo(r runtime.Runtime, db *data.Data) dto.ResourceRepo { return &resourceRepo{ db: db, } diff --git a/internal/mods/system/dal/role.dal.go b/internal/mods/system/dal/role.dal.go index 46aec871..9ed8df41 100644 --- a/internal/mods/system/dal/role.dal.go +++ b/internal/mods/system/dal/role.dal.go @@ -9,12 +9,13 @@ import ( "errors" "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/rand" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/db" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/role" "origadmin/application/admin/internal/mods/system/dto" @@ -22,7 +23,7 @@ import ( type roleRepo struct { gen *rand.Rand - db *Data + db *data.Data } func (repo roleRepo) Get(ctx context.Context, id int64, options ...dto.RoleQueryOption) (*dto.RolePB, error) { @@ -127,7 +128,7 @@ func (repo roleRepo) List(ctx context.Context, in *pb.ListRolesRequest, options } // NewRoleRepo . -func NewRoleRepo(db *Data, logger log.KLogger) dto.RoleRepo { +func NewRoleRepo(r runtime.Runtime, db *data.Data) dto.RoleRepo { return &roleRepo{ gen: rand.DigitAndLowerCase, db: db, diff --git a/internal/mods/system/dal/user.dal.go b/internal/mods/system/dal/user.dal.go index dda38a3b..4f9c1ba9 100644 --- a/internal/mods/system/dal/user.dal.go +++ b/internal/mods/system/dal/user.dal.go @@ -10,18 +10,19 @@ import ( "time" "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/db" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/mods/system/dto" ) type userRepo struct { - db *Data + db *data.Data } func (repo userRepo) AddRoleIDs(ctx context.Context, i int64, int64s []int64, option ...dto.UserMutationOption) error { @@ -179,7 +180,7 @@ func (repo userRepo) List(ctx context.Context, in *pb.ListUsersRequest, options } // NewUserRepo . -func NewUserRepo(db *Data, logger log.KLogger) dto.UserRepo { +func NewUserRepo(r runtime.Runtime, db *data.Data) dto.UserRepo { return &userRepo{ db: db, } diff --git a/internal/mods/system/server/gins.go b/internal/mods/system/server/gins.go index 5c592786..26373997 100644 --- a/internal/mods/system/server/gins.go +++ b/internal/mods/system/server/gins.go @@ -19,7 +19,7 @@ import ( ) // NewGINSServer new a gin server. -func NewGINSServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.OptionSetting) *gins.Server { +func NewGINSServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.ServerOption) *gins.Server { ms := middleware.NewServer(bootstrap.GetMiddleware()) //option := settings.ApplyOrZero(ss...) var opts = []gins.ServerOption{ diff --git a/internal/mods/system/server/grpc.go b/internal/mods/system/server/grpc.go index 946afe7e..0c8f51a3 100644 --- a/internal/mods/system/server/grpc.go +++ b/internal/mods/system/server/grpc.go @@ -5,7 +5,6 @@ package server import ( - "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -13,10 +12,10 @@ import ( ) // NewGRPCServer new a gRPC server. -func NewGRPCServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.OptionSetting) *service.GRPCServer { - srv, err := runtime.NewGRPCServiceServer(bootstrap.GetService(), ss...) - if err != nil { - panic(err) - } +func NewGRPCServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.ServerOption) *service.GRPCServer { + //srv, err := runtime.NewGRPCServiceServer(bootstrap.GetService(), ss...) + //if err != nil { + // panic(err) + //} return srv } diff --git a/internal/mods/system/server/http.go b/internal/mods/system/server/http.go index 4c454419..413833bd 100644 --- a/internal/mods/system/server/http.go +++ b/internal/mods/system/server/http.go @@ -5,7 +5,6 @@ package server import ( - "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -13,10 +12,14 @@ import ( ) // NewHTTPServer new an HTTP server. -func NewHTTPServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.OptionSetting) *service.HTTPServer { - srv, err := runtime.NewHTTPServiceServer(bootstrap.GetService(), ss...) - if err != nil { - panic(err) - } - return srv +func NewHTTPServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.ServerOption) *service.HTTPServer { + //options := settings.ApplyZero(ss) + //for i, config := range bootstrap.GetServices() { + // srv, err := runtime.NewHTTPServiceServer(bootstrap.GetServices(), options.ToHTTP()) + // if err != nil { + // panic(err) + // } + // return srv + //} + return nil } diff --git a/internal/mods/system/server/server.go b/internal/mods/system/server/server.go index 4e5a9f8d..18538206 100644 --- a/internal/mods/system/server/server.go +++ b/internal/mods/system/server/server.go @@ -16,7 +16,6 @@ import ( "github.com/origadmin/runtime/middleware" "github.com/origadmin/runtime/service" servicegrpc "github.com/origadmin/runtime/service/grpc" - servicehttp "github.com/origadmin/runtime/service/http" "github.com/origadmin/toolkits/errors" pb "origadmin/application/admin/api/v1/services/system" @@ -44,35 +43,37 @@ func init() { runtime.RegisterService(ServiceName, service.DefaultServiceFactory) } -func NewSystemServer(bootstrap *configs.Bootstrap, registers []service.ServerRegister, l log.KLogger) []transport.Server { +func NewSystemServer(r runtime.Runtime, bootstrap *configs.Bootstrap, registers []service.ServerRegister) []transport. +Server { var servers []transport.Server serviceConfig := bootstrap.GetServices() if serviceConfig == nil { return servers } - if serviceConfig.Name == "" { - serviceConfig.Name = ServiceName - } - ctx := context.Background() - middlewares := middleware.NewServer(bootstrap.GetService().GetMiddleware()) - if serv := runtime.NewGRPCServiceServer(bootstrap, l, service.WithGRPC( - servicegrpc.WithMiddlewares(middlewares...), - servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), - )); serv != nil { - for i := range registers { - registers[i].GRPCServer(ctx, serv) - } - servers = append(servers, serv) - } - if serv := NewHTTPServer(bootstrap, l, service.WithHTTP( - servicehttp.WithMiddlewares(middlewares...), - servicehttp.WithPrefix(runtime.DefaultEnvPrefix), - )); serv != nil { - for i := range registers { - registers[i].HTTPServer(ctx, serv) - } - servers = append(servers, serv) - } + //if serviceConfig.Name == "" { + // serviceConfig.Name = ServiceName + //} + //ctx := context.Background() + //middlewares := middleware.NewServer(bootstrap.GetMiddleware()) + + //if serv, _ := runtime.NewGRPCServiceServer(bootstrap, l, service.WithGRPC( + // servicegrpc.WithMiddlewares(middlewares...), + // servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), + //)); serv != nil { + // for i := range registers { + // registers[i].GRPCServer(ctx, serv) + // } + // servers = append(servers, serv) + //} + //if serv := NewHTTPServer(bootstrap, l, service.WithHTTP( + // servicehttp.WithMiddlewares(middlewares...), + // servicehttp.WithPrefix(runtime.DefaultEnvPrefix), + //)); serv != nil { + // for i := range registers { + // registers[i].HTTPServer(ctx, serv) + // } + // servers = append(servers, serv) + //} return servers } @@ -140,16 +141,16 @@ func NewSystemClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service. } serviceConfig := &configv1.Service{ Name: ServiceName, - Grpc: entry.GetGrpc(), - Http: entry.GetHttp(), + //Grpc: entry.GetGrpc(), + //Http: entry.GetHttp(), Selector: &configv1.Service_Selector{ Version: "v1.0.0", Builder: "bbr", }, } - if v, ok := bootstrap.GetServers()[ServiceName]; ok { - registry.ServiceName = ServiceName - } + //if v, ok := bootstrap.GetServices()[ServiceName]; ok { + // registry.ServiceName = ServiceName + //} helper := log.NewHelper(r.Logger()) //registry.ServiceName = ServiceName helper.Infof("service name: %s", registry.ServiceName) @@ -166,7 +167,7 @@ func NewSystemClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service. if len(ms) > 0 { options = append(options, servicegrpc.WithMiddlewares(ms...)) } - client, err := runtime.NewGRPCServiceClient(context.Background(), serviceConfig, service.WithGRPC(options...)) + client, err := runtime.NewGRPCServiceClient(context.Background(), serviceConfig, options...) if err != nil { return nil, errors.Wrap(err, "create menu grpc client") } @@ -196,22 +197,22 @@ func NewRegisterServer( Resource pb.ResourceServiceServer, Role pb.RoleServiceServer, User pb.UserServiceServer, - Auth pb.AuthServiceServer, - Login pb.LoginServiceServer, - Personal pb.PersonalServiceServer, +//Auth pb.AuthServiceServer, +//Login pb.LoginServiceServer, +//Personal pb.PersonalServiceServer, Permission pb.PermissionServiceServer, - Casbin pb.CasbinSourceServiceServer, +//Casbin pb.CasbinSourceServiceServer, ) []service.ServerRegister { return []service.ServerRegister{ &systemservice.RegisterServer{ - Resource: Resource, - Role: Role, - User: User, - Auth: Auth, - Login: Login, - Personal: Personal, + Resource: Resource, + Role: Role, + User: User, + //Auth: Auth, + //Login: Login, + //Personal: Personal, Permission: Permission, - Casbin: Casbin, + //Casbin: Casbin, }, } } diff --git a/internal/mods/system/service/service.go b/internal/mods/system/service/service.go index 288c8c11..68e86eff 100644 --- a/internal/mods/system/service/service.go +++ b/internal/mods/system/service/service.go @@ -17,8 +17,8 @@ import ( // ProviderSet is service providers. var ProviderSet = wire.NewSet( wire.Struct(new(RegisterServer), "*"), - NewLoginServiceServerPB, - NewLoginServiceHTTPServerPB, + //NewLoginServiceServerPB, + //NewLoginServiceHTTPServerPB, NewResourceServiceServerPB, NewResourceServiceHTTPServerPB, NewRoleServiceServerPB, @@ -27,22 +27,22 @@ var ProviderSet = wire.NewSet( NewUserServiceHTTPServerPB, NewPersonalServiceServerPB, NewPersonalServiceHTTPServerPB, - NewAuthServiceServerPB, - NewAuthServiceHTTPServerPB, + //NewAuthServiceServerPB, + //NewAuthServiceHTTPServerPB, NewPermissionServiceServerPB, NewPermissionServiceHTTPServerPB, - NewCasbinSourceServiceServerPB, + //NewCasbinSourceServiceServerPB, ) type RegisterServer struct { - Resource pb.ResourceServiceServer - Role pb.RoleServiceServer - User pb.UserServiceServer - Auth pb.AuthServiceServer - Login pb.LoginServiceServer - Personal pb.PersonalServiceServer + Resource pb.ResourceServiceServer + Role pb.RoleServiceServer + User pb.UserServiceServer + //Auth pb.AuthServiceServer + //Login pb.LoginServiceServer + //Personal pb.PersonalServiceServer Permission pb.PermissionServiceServer - Casbin pb.CasbinSourceServiceServer + //Casbin pb.CasbinSourceServiceServer } func (s RegisterServer) GRPCServer(ctx context.Context, server *service.GRPCServer) { @@ -50,11 +50,11 @@ func (s RegisterServer) GRPCServer(ctx context.Context, server *service.GRPCServ pb.RegisterResourceServiceServer(server, s.Resource) pb.RegisterRoleServiceServer(server, s.Role) pb.RegisterUserServiceServer(server, s.User) - pb.RegisterAuthServiceServer(server, s.Auth) - pb.RegisterLoginServiceServer(server, s.Login) - pb.RegisterPersonalServiceServer(server, s.Personal) + //pb.RegisterAuthServiceServer(server, s.Auth) + //pb.RegisterLoginServiceServer(server, s.Login) + //pb.RegisterPersonalServiceServer(server, s.Personal) pb.RegisterPermissionServiceServer(server, s.Permission) - pb.RegisterCasbinSourceServiceServer(server, s.Casbin) + //pb.RegisterCasbinSourceServiceServer(server, s.Casbin) } func (s RegisterServer) HTTPServer(ctx context.Context, server *service.HTTPServer) { @@ -62,11 +62,11 @@ func (s RegisterServer) HTTPServer(ctx context.Context, server *service.HTTPServ pb.RegisterResourceServiceHTTPServer(server, s.Resource) pb.RegisterRoleServiceHTTPServer(server, s.Role) pb.RegisterUserServiceHTTPServer(server, s.User) - pb.RegisterAuthServiceHTTPServer(server, s.Auth) - pb.RegisterLoginServiceHTTPServer(server, s.Login) - pb.RegisterPersonalServiceHTTPServer(server, s.Personal) + //pb.RegisterAuthServiceHTTPServer(server, s.Auth) + //pb.RegisterLoginServiceHTTPServer(server, s.Login) + //pb.RegisterPersonalServiceHTTPServer(server, s.Personal) pb.RegisterPermissionServiceHTTPServer(server, s.Permission) - pb.RegisterCasbinSourceServiceHTTPServer(server, s.Casbin) + //pb.RegisterCasbinSourceServiceHTTPServer(server, s.Casbin) } func (s RegisterServer) Server(ctx context.Context, grpcServer *service.GRPCServer, httpServer *service.HTTPServer) { diff --git a/resources/configs/system/bootstrap.toml b/resources/configs/system/bootstrap.toml index 6d4a3fac..c498cabc 100644 --- a/resources/configs/system/bootstrap.toml +++ b/resources/configs/system/bootstrap.toml @@ -1,8 +1,11 @@ Name = "origadmin.agent.service.admin.v1" -Mode = "singleton" Version = "v1.0.0" CryptoType = "argon2" +Mode = "singleton" +EnableDynamicConfig = false Id = "" +Environment = "" +Services = [] [Servers] system = "origadmin.service.system.v1" diff --git a/resources/configs/system/data.toml b/resources/configs/system/data.toml deleted file mode 100644 index b3b5d63a..00000000 --- a/resources/configs/system/data.toml +++ /dev/null @@ -1,57 +0,0 @@ -[Data.Database] -Debug = false -Dialect = "${database_dialect:sqlite}" -Source = "${database_source:file://origadmin}" -Migrate = false -EnableTrace = false -EnableMetrics = false -MaxIdleConnections = 0 -MaxOpenConnections = 0 -ConnectionMaxLifetime = 0 -ConnectionMaxIdleTime = 0 -[Data.Cache] -Driver = "memory" -Name = "" -[Data.Cache.Memcached] -Addr = "" -Username = "" -Password = "" -MaxIdle = 0 -Timeout = 0 -[Data.Cache.Memory] -Size = 0 -Capacity = 0 -Expiration = 0 -CleanupInterval = 0 -[Data.Cache.Redis] -Network = "" -Addr = "" -Password = "" -Db = 0 -DialTimeout = 0 -ReadTimeout = 0 -WriteTimeout = 0 -[Data.Cache.Badger] -Path = "" -SyncWrites = false -ValueLogFileSize = 0 -LogLevel = 0 -[Data.Storage] -Type = "none" -[Data.Storage.File] -Root = "" -[Data.Storage.Redis] -Network = "" -Addr = "" -Password = "" -Db = 0 -DialTimeout = 0 -ReadTimeout = 0 -WriteTimeout = 0 -[Data.Storage.Badger] -Path = "" -SyncWrites = false -ValueLogFileSize = 0 -LogLevel = 0 -[Data.Storage.Mongo] -[Data.Storage.Oss] \ No newline at end of file diff --git a/resources/configs/system/middleware.toml b/resources/configs/system/middleware.toml index 7771854b..d50d0680 100644 --- a/resources/configs/system/middleware.toml +++ b/resources/configs/system/middleware.toml @@ -1,8 +1,5 @@ [Middleware] -Logging = true -Recovery = true -Tracing = true -CircuitBreaker = true +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] [Middleware.Metadata] Enabled = true Prefix = "" @@ -26,7 +23,7 @@ Subject = "" ClaimType = "" [Middleware.Jwt.Config] SigningMethod = "HS512" -Key = "${middleware_jwt_key:12345678901234567890123456789012}" +Key = "wSX^6C1d2HM%K9D_H6I*YPZVMa3^Gvhj" Key2 = "can empty next version fixed" AccessTokenLifetime = 900000000000 RefreshTokenLifetime = 259200000000000 @@ -34,4 +31,4 @@ Issuer = "localhost" TokenType = "Bearer" [Middleware.Selector] Enabled = false -Regex = "" \ No newline at end of file +Regex = "" diff --git a/resources/configs/system/security.toml b/resources/configs/system/security.toml index 8167f8e5..34bc19e0 100644 --- a/resources/configs/system/security.toml +++ b/resources/configs/system/security.toml @@ -1,35 +1,19 @@ [Security] -PublicPaths = [ - "/swagger/*", - "/api/v1/health", - "/api/v1/health/*", - "/api/v1/captcha", - "/api/v1/captcha/*", - "/api/v1/login", - "/api/v1/register", - "/api/v1/current/logout", - "/api.v1.services.system.LoginAPI/CaptchaId", - "/api.v1.services.system.LoginAPI/CaptchaImage", - "/api.v1.services.system.LoginAPI/CaptchaResource", - "/api.v1.services.system.LoginAPI/CaptchaResources", - "/api.v1.services.system.LoginAPI/Login", - "/api.v1.services.system.LoginAPI/Register", - "/api.v1.services.system.LoginAPI/Refresh", - "/api.v1.services.system.LoginAPI/TokenRefresh", -] -[Security.Authz] +[Security.Security] +PublicPaths = ["/swagger/*", "/api/v1/health", "/api/v1/health/*", "/api/v1/captcha", "/api/v1/captcha/*", "/api/v1/login", "/api/v1/register", "/api/v1/current/logout", "/api/v1/refresh_token", "/api.v1.services.system.LoginAPI/CaptchaId", "/api.v1.services.system.LoginAPI/CaptchaImage", "/api.v1.services.system.LoginAPI/CaptchaResource", "/api.v1.services.system.LoginAPI/CaptchaResources", "/api.v1.services.system.LoginAPI/Login", "/api.v1.services.system.LoginAPI/Register", "/api.v1.services.system.LoginAPI/Refresh"] +[Security.Security.Authz] Disabled = false Type = "casbin" -[Security.Authz.Casbin] +[Security.Security.Authz.Casbin] PolicyFile = "" ModelFile = "" -[Security.Authn] +[Security.Security.Authn] Disabled = false Type = "jwt" -[Security.Authn.Jwt] +[Security.Security.Authn.Jwt] Algorithm = "HS512" -SigningKey = "${middleware_jwt_key:12345678901234567890123456789012}" +SigningKey = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" OldSigningKey = "" ExpireTime = 0 RefreshTime = 0 -CacheName = "" \ No newline at end of file +CacheName = "" diff --git a/resources/configs/system/storage.toml b/resources/configs/system/storage.toml new file mode 100644 index 00000000..15906e90 --- /dev/null +++ b/resources/configs/system/storage.toml @@ -0,0 +1,46 @@ +[Storage] +Name = "" +Type = "" +[Storage.Database] +Debug = false +Dialect = "sqlite3" +Source = "data/admin.db" +EnableTrace = false +EnableMetrics = false +MaxIdleConnections = 0 +MaxOpenConnections = 0 +ConnectionMaxLifetime = 0 +ConnectionMaxIdleTime = 0 +[Storage.Database.Migration] +Enabled = false +Path = "" +Version = "" +Mode = "" +[Storage.Cache] +Driver = "memory" +Name = "" +[Storage.Cache.Memcached] +Addr = "" +Username = "" +Password = "" +MaxIdle = 0 +Timeout = 0 +[Storage.Cache.Memory] +Size = 0 +Capacity = 0 +Expiration = 0 +CleanupInterval = 0 +[Storage.Cache.Redis] +Network = "" +Addr = "" +Password = "" +Db = 0 +DialTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +[Storage.Cache.Badger] +Path = "" +SyncWrites = false +ValueLogFileSize = 0 +InMemory = false +LogLevel = 0 \ No newline at end of file diff --git a/test/token_test.go b/test/token_test.go index 67938612..44b4a267 100644 --- a/test/token_test.go +++ b/test/token_test.go @@ -72,11 +72,10 @@ func TestGenerateToken(t *testing.T) { } refreshTokenizer := dal.RefreshTokenizer(tokenizer) loginData := &dal.LoginData{ - BasisConfig: basisConfig, - Tokenizer: refreshTokenizer, - Resource: resourceRepo, - Role: roleRepo, - User: userRepo, + Tokenizer: refreshTokenizer, + Resource: resourceRepo, + Role: roleRepo, + User: userRepo, } ctx := context.Background() claims, err := loginData.Tokenizer.CreateClaims(ctx, "user_1") From 6dabecc7dc65f207cf962b9add23756848bca6b9 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 27 May 2025 04:48:39 +0800 Subject: [PATCH 024/158] refactor(config): update consul config and registry implementation - Update consul config and registry packages to new locations - Refactor config and registry initialization - Improve error handling and logging - Update database initialization to create source directory if needed - Refactor service and bootstrap proto definitions --- cmd/internal/start/start.go | 4 +- cmd/internal/start/wire_gen.go | 4 +- cmd/system/main.go | 15 ++- cmd/system/wire.go | 2 +- cmd/system/wire_gen.go | 6 +- contrib/consul/config/config.go | 110 +++++++++++++++++++++ contrib/consul/config/const.go | 38 +++++++ contrib/consul/registry/const.go | 73 ++++++++++++++ contrib/consul/registry/registry.go | 93 +++++++++++++++++ contrib/database/database.go | 6 ++ contrib/database/internal/sqlite/sqlite.go | 21 ++++ go.mod | 20 ++-- go.sum | 6 +- internal/configs/bootstrap.pb.go | 79 +++++++-------- internal/configs/bootstrap.pb.validate.go | 29 ------ internal/configs/bootstrap.proto | 8 +- internal/configs/captcha.pb.go | 6 +- internal/configs/captcha.proto | 2 +- internal/configs/root_user.pb.go | 4 +- internal/configs/root_user.proto | 2 +- internal/configs/security_config.pb.go | 20 ++-- internal/configs/security_config.proto | 2 +- internal/configs/server.pb.go | 12 +-- internal/configs/server.proto | 2 +- internal/configs/services/service.pb.go | 22 ++--- internal/configs/services/service.proto | 2 +- internal/data/data.go | 4 +- internal/loader/bootstrap.go | 6 +- internal/loader/bootstrap_default.go | 76 +++++++++++--- internal/loader/bootstrap_test.go | 6 +- internal/loader/file.go | 60 +++++++++++ internal/loader/load.go | 1 - internal/mods/auth/dal/auth.dal.go | 5 +- internal/mods/auth/dal/casbin.dal.go | 7 +- internal/mods/auth/dal/dal.go | 79 +-------------- internal/mods/system/dal/login.dal.go | 2 +- internal/mods/system/dal/resource.dal.go | 3 +- internal/mods/system/server/grpc.go | 21 ++-- internal/mods/system/server/http.go | 23 +++-- main.go | 1 - resources/configs/system/logger.toml | 19 ++++ test/token_test.go | 4 +- 42 files changed, 641 insertions(+), 264 deletions(-) create mode 100644 contrib/consul/config/config.go create mode 100644 contrib/consul/config/const.go create mode 100644 contrib/consul/registry/const.go create mode 100644 contrib/consul/registry/registry.go create mode 100644 resources/configs/system/logger.toml diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index cb02edf9..0a2ec513 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -7,8 +7,8 @@ package start import ( "github.com/go-kratos/kratos/v2" - _ "github.com/origadmin/contrib/consul/config" - _ "github.com/origadmin/contrib/consul/registry" + _ "origadmin/application/admin/contrib/consul/config" + _ "origadmin/contrib/consul/registry" "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" "github.com/spf13/cobra" diff --git a/cmd/internal/start/wire_gen.go b/cmd/internal/start/wire_gen.go index d96a2368..ce20202e 100644 --- a/cmd/internal/start/wire_gen.go +++ b/cmd/internal/start/wire_gen.go @@ -14,8 +14,8 @@ import ( ) import ( - _ "github.com/origadmin/contrib/consul/config" - _ "github.com/origadmin/contrib/consul/registry" + _ "origadmin/application/admin/contrib/consul/config" + _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" ) diff --git a/cmd/system/main.go b/cmd/system/main.go index 80928f31..b1ec148b 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -11,12 +11,15 @@ import ( "log/slog" "github.com/go-kratos/kratos/v2" - _ "github.com/origadmin/contrib/consul/config" - _ "github.com/origadmin/contrib/consul/registry" + "github.com/go-kratos/kratos/v2/encoding" "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/codec/toml" + + _ "origadmin/application/admin/contrib/consul/config" + _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" "origadmin/application/admin/internal/loader" ) @@ -36,6 +39,7 @@ var ( ) func init() { + encoding.RegisterCodec(toml.Codec) flags.SetServiceInfo(Name, Version) flag.BoolVar(&debug, "debug", false, "set environment, eg: -debug") flag.StringVar(&configPath, "c", "config.toml", "config path, eg: -c config.toml") @@ -48,7 +52,8 @@ func main() { if debug { fmt.Println("debug mode") flags.SetEnv("debug") - flags.SetConfigPath("resources/configs") + flags.SetConfigPath("resources/configs/config.toml") + flags.SetWorkDir(".") slog.SetLogLoggerLevel(slog.LevelDebug) } @@ -73,7 +78,7 @@ func main() { } } -// NewAppProvider 是一个provider函数,它使用runtime.Runtime的CreateApp方法 -func NewAppProvider(r runtime.Runtime, injector *loader.Injector) *kratos.App { +// NewApp new app with runtime and injector +func NewApp(r runtime.Runtime, injector *loader.Injector) *kratos.App { return r.CreateApp(injector.Servers...) } diff --git a/cmd/system/wire.go b/cmd/system/wire.go index d31ed0e7..5ed90286 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -36,6 +36,6 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap systemservice.ProviderSet, systemserver.ProviderSet, /* add your providers here */ - NewAppProvider, + NewApp, )) } diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index d25c7edc..56f46048 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -19,8 +19,8 @@ import ( ) import ( - _ "github.com/origadmin/contrib/consul/config" - _ "github.com/origadmin/contrib/consul/registry" + _ "origadmin/application/admin/contrib/consul/config" + _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" ) @@ -54,7 +54,7 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap Registrar: v, Servers: v3, } - app := NewAppProvider(r, injector) + app := NewApp(r, injector) return app, func() { cleanup() }, nil diff --git a/contrib/consul/config/config.go b/contrib/consul/config/config.go new file mode 100644 index 00000000..b819decf --- /dev/null +++ b/contrib/consul/config/config.go @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package config + +import ( + "encoding/json" + + "github.com/hashicorp/consul/api" + "github.com/origadmin/toolkits/errors" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" + + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/config" + configv1 "github.com/origadmin/runtime/gen/go/config/v1" +) + +func init() { + runtime.RegisterConfigFunc(Type, NewConsulConfig) + runtime.RegisterConfigSync(Type, config.SyncFunc(SyncConfig)) +} + +// NewConsulConfig create a new consul config. +func NewConsulConfig(ccfg *configv1.SourceConfig, options *config.Options) (config.KSource, error) { + consul := ccfg.GetConsul() + if consul == nil { + return nil, errors.New("consul config error") + } + + cfg := api.DefaultConfig() + cfg.Address = consul.Address + cfg.Scheme = consul.Scheme + + apiClient, err := api.NewClient(cfg) + if err != nil { + return nil, errors.Wrap(err, "consul client error") + } + + if consul.Path == "" { + consul.Path = FileConfigPath(ccfg.Name, DefaultPathName) + } + + source, err := New(apiClient, WithPath(consul.Path)) + if err != nil { + return nil, errors.Wrap(err, "consul source error") + } + + //var configSources = []config.KSource{source} + //if ccfg.EnvPrefixes != nil { + // configSources = append(configSources, env.NewSource(ccfg.EnvPrefixes...)) + //} + // + //options.Sources = append(options.Sources, configSources...) + //if options.Decoder != nil { + // options.ConfigOptions = append(options.ConfigOptions, config.WithDecoder(options.Decoder)) + //} + return source, nil +} + +func SyncConfig(ccfg *configv1.SourceConfig, k string, v any, options *config.Options) error { + consul := ccfg.GetConsul() + if consul == nil { + return errors.New("consul config error") + } + + cfg := api.DefaultConfig() + cfg.Address = consul.Address + cfg.Scheme = consul.Scheme + apiClient, err := api.NewClient(cfg) + if err != nil { + return errors.Wrap(err, "consul client error") + } + + if consul.Path == "" { + consul.Path = FileConfigPath(ccfg.Name, DefaultPathName) + } + + encode := marshalJSON + if options.Encoder != nil { + encode = options.Encoder + } + marshal, err := encode(v) + if err != nil { + return errors.Wrap(err, "marshal config error") + } + + if _, err := apiClient.KV().Put(&api.KVPair{ + Key: consul.Path, + Value: marshal, + }, nil); err != nil { + return errors.Wrap(err, "consul put error") + } + return nil +} + +func FileConfigPath(serviceName, filename string) string { + return "/config/" + serviceName + "/" + filename +} +func marshalJSON(v any) ([]byte, error) { + if data, ok := v.(proto.Message); ok { + opt := protojson.MarshalOptions{ + EmitUnpopulated: true, + Indent: " ", + } + return opt.Marshal(data) + } + return json.Marshal(v) +} diff --git a/contrib/consul/config/const.go b/contrib/consul/config/const.go new file mode 100644 index 00000000..75376312 --- /dev/null +++ b/contrib/consul/config/const.go @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package config implements the functions, types, and interfaces for the module. +package config + +import ( + "github.com/go-kratos/kratos/contrib/config/consul/v2" + "github.com/hashicorp/consul/api" + + "github.com/origadmin/runtime/config" + "github.com/origadmin/runtime/context" +) + +const ( + DefaultPathName = "bootstrap.json" + Type = "consul" +) + +type ( + Option = consul.Option +) + +// New returns a new consul config source +func New(client *api.Client, opts ...Option) (config.KSource, error) { + return consul.New(client, opts...) +} + +// WithContext with registry context +func WithContext(ctx context.Context) Option { + return consul.WithContext(ctx) +} + +// WithPath with registry path +func WithPath(p string) Option { + return consul.WithPath(p) +} diff --git a/contrib/consul/registry/const.go b/contrib/consul/registry/const.go new file mode 100644 index 00000000..c3aadf9d --- /dev/null +++ b/contrib/consul/registry/const.go @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package registry implements the functions, types, and interfaces for the module. +package registry + +import ( + "time" + + "github.com/go-kratos/kratos/contrib/registry/consul/v2" + "github.com/hashicorp/consul/api" +) + +const ( + SingleDatacenter = consul.SingleDatacenter + MultiDatacenter = consul.MultiDatacenter + Type = "consul" +) + +type ( + Datacenter = consul.Datacenter + Client = consul.Client + ServiceResolver = consul.ServiceResolver + Option = consul.Option + Config = consul.Config + Registry = consul.Registry +) + +// WithHealthCheck is a wrapper for consul.WithHealthCheck +func WithHealthCheck(check bool) Option { + return consul.WithHealthCheck(check) +} + +// WithTimeout is a wrapper for consul.WithTimeout +func WithTimeout(timeout time.Duration) Option { + return consul.WithTimeout(timeout) +} + +// WithDatacenter is a wrapper for consul.WithDatacenter +func WithDatacenter(datacenter Datacenter) Option { + return consul.WithDatacenter(datacenter) +} + +// WithHeartbeat is a wrapper for consul.WithHeartbeat +func WithHeartbeat(heartbeat bool) Option { + return consul.WithHeartbeat(heartbeat) +} + +// WithServiceResolver is a wrapper for consul.WithServiceResolver +func WithServiceResolver(resolver ServiceResolver) Option { + return consul.WithServiceResolver(resolver) +} + +// WithHealthCheckInterval is a wrapper for consul.WithHealthCheckInterval +func WithHealthCheckInterval(interval int) Option { + return consul.WithHealthCheckInterval(interval) +} + +// WithDeregisterCriticalServiceAfter is a wrapper for consul.WithDeregisterCriticalServiceAfter +func WithDeregisterCriticalServiceAfter(duration int) Option { + return consul.WithDeregisterCriticalServiceAfter(duration) +} + +// WithServiceCheck is a wrapper for consul.WithServiceCheck +func WithServiceCheck(check *api.AgentServiceCheck) Option { + return consul.WithServiceCheck(check) +} + +// New is a wrapper for consul.New +func New(client *api.Client, opts ...Option) *Registry { + return consul.New(client, opts...) +} diff --git a/contrib/consul/registry/registry.go b/contrib/consul/registry/registry.go new file mode 100644 index 00000000..5d612c98 --- /dev/null +++ b/contrib/consul/registry/registry.go @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package registry + +import ( + "time" + + "github.com/hashicorp/consul/api" + "github.com/origadmin/runtime" + configv1 "github.com/origadmin/runtime/gen/go/config/v1" + "github.com/origadmin/runtime/registry" + "github.com/origadmin/toolkits/errors" +) + +type consulBuilder struct { +} + +func init() { + runtime.RegisterRegistry(Type, &consulBuilder{}) +} + +func configFromConfig(registry *configv1.Registry) *api.Config { + apiconfig := api.DefaultConfig() + cfg := registry.GetConsul() + if cfg == nil { + return apiconfig + } + if cfg.Address != "" { + apiconfig.Address = cfg.Address + } + if cfg.Scheme != "" { + apiconfig.Scheme = cfg.Scheme + } + if cfg.Datacenter != "" { + apiconfig.Datacenter = cfg.Datacenter + } + if cfg.Token != "" { + apiconfig.Token = cfg.Token + } + return apiconfig +} + +func optionsFromConfig(registry *configv1.Registry) []Option { + var opts []Option + + cfg := registry.GetConsul() + if cfg == nil { + return opts + } + + if cfg.HealthCheck { + opts = append(opts, WithHealthCheck(cfg.HealthCheck)) + } + if cfg.HeartBeat { + opts = append(opts, WithHeartbeat(cfg.HeartBeat)) + } + if cfg.Timeout != 0 { + opts = append(opts, WithTimeout(time.Duration(cfg.Timeout))) + } + if cfg.Datacenter != "" { + opts = append(opts, WithDatacenter(Datacenter(cfg.Datacenter))) + } + if cfg.HealthCheckInterval > 0 { + opts = append(opts, WithHealthCheckInterval(int(cfg.HealthCheckInterval))) + } + if cfg.DeregisterCriticalServiceAfter > 0 { + opts = append(opts, WithDeregisterCriticalServiceAfter(int(cfg.DeregisterCriticalServiceAfter))) + } + return opts +} + +func (c *consulBuilder) NewDiscovery(cfg *configv1.Registry, opts ...registry.Option) (registry.KDiscovery, error) { + return c.Create(cfg, opts...) +} + +func (c *consulBuilder) NewRegistrar(cfg *configv1.Registry, opts ...registry.Option) (registry.KRegistrar, error) { + return c.Create(cfg, opts...) +} + +func (c *consulBuilder) Create(cfg *configv1.Registry, _ ...registry.Option) (registry.Registry, error) { + if cfg == nil || cfg.Consul == nil { + return nil, errors.New("configuration: consul config is required") + } + apiConfig := configFromConfig(cfg) + apiClient, err := api.NewClient(apiConfig) + if err != nil { + return nil, errors.Wrap(err, "failed to create consul client") + } + r := New(apiClient, optionsFromConfig(cfg)...) + return r, nil +} diff --git a/contrib/database/database.go b/contrib/database/database.go index 11970761..e4439716 100644 --- a/contrib/database/database.go +++ b/contrib/database/database.go @@ -7,6 +7,8 @@ package database import ( "database/sql" + "fmt" + "strings" "time" configv1 "github.com/origadmin/runtime/gen/go/config/v1" @@ -30,10 +32,14 @@ func Open(database *configv1.Database) (*sql.DB, error) { database.Dialect = "postgres" case "sqlite3", "sqlite": database.Dialect = "sqlite3" + if !strings.Contains(database.Source, ":memory:") { + sqlite.MakeSourceDirectory(database.Source) + } database.Source = sqlite.SourceForeignKeys(database.Source) default: } + fmt.Printf("database: dialect: %s, source: %s\n", database.Dialect, database.Source) db, err := sql.Open(database.Dialect, database.Source) if err != nil { return nil, errors.Wrap(err, "database: open database error") diff --git a/contrib/database/internal/sqlite/sqlite.go b/contrib/database/internal/sqlite/sqlite.go index c7eefceb..ca36fe2d 100644 --- a/contrib/database/internal/sqlite/sqlite.go +++ b/contrib/database/internal/sqlite/sqlite.go @@ -6,6 +6,7 @@ package sqlite import ( + "os" "strings" ) @@ -30,3 +31,23 @@ func SourceForeignKeys(source string) string { } return source } + +func MakeSourceDirectory(source string) { + if strings.HasPrefix(source, "file://") { + source = strings.TrimPrefix(source, "file://") + } + idx := strings.Index(source, "?") + if idx > 0 { + source = source[:idx] + } + dirs := strings.Split(source, "/") + if len(dirs) > 1 { + dirs = dirs[:len(dirs)-1] + dir := strings.Join(dirs, "/") + _, err := os.Stat(dir) + if err != nil { + os.MkdirAll(dir, 0755) + return + } + } +} diff --git a/go.mod b/go.mod index b6185911..a54ea131 100644 --- a/go.mod +++ b/go.mod @@ -9,9 +9,13 @@ require ( github.com/caarlos0/go-version v0.2.0 github.com/casbin/casbin/v2 v2.105.0 github.com/dchest/uniuri v1.2.0 + github.com/denisenkom/go-mssqldb v0.12.3 github.com/envoyproxy/protoc-gen-validate v1.2.1 github.com/gin-gonic/gin v1.10.0 + github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250427030626-b463dc514714 + github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250427030626-b463dc514714 github.com/go-kratos/kratos/v2 v2.8.4 + github.com/go-sql-driver/mysql v1.9.2 github.com/goexts/generic v0.3.0 github.com/golang-jwt/jwt/v5 v5.2.2 github.com/google/gnostic v0.7.0 @@ -19,8 +23,12 @@ require ( github.com/google/wire v0.6.0 github.com/gorilla/handlers v1.5.2 github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 + github.com/hashicorp/consul/api v1.32.0 + github.com/jackc/pgx/v5 v5.7.4 + github.com/lib/pq v1.10.9 + github.com/mattn/go-sqlite3 v1.14.28 github.com/mojocn/base64Captcha v1.3.8 - github.com/origadmin/contrib/consul v0.0.33 + github.com/origadmin/contrib/database v0.0.34 github.com/origadmin/contrib/i18n v0.0.33 github.com/origadmin/contrib/replacer v0.0.33 github.com/origadmin/contrib/transport/gins v0.0.33 @@ -35,6 +43,7 @@ require ( github.com/prometheus/client_golang v1.22.0 github.com/sony/sonyflake v1.2.0 github.com/spf13/cobra v1.9.1 + github.com/sqlite3ent/sqlite3 v1.34.1 github.com/stretchr/testify v1.10.0 golang.org/x/net v0.40.0 google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34 @@ -63,7 +72,6 @@ require ( github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/cloudwego/base64x v0.1.5 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/denisenkom/go-mssqldb v0.12.3 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect @@ -71,8 +79,6 @@ require ( github.com/gabriel-vasile/mimetype v1.4.9 // indirect github.com/gin-contrib/sse v1.1.0 // indirect github.com/go-kratos/aegis v0.2.0 // indirect - github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250427030626-b463dc514714 // indirect - github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250427030626-b463dc514714 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect @@ -81,7 +87,6 @@ require ( github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.26.0 // indirect - github.com/go-sql-driver/mysql v1.9.2 // indirect github.com/goccy/go-json v0.10.5 // indirect github.com/golang-cz/devslog v0.0.13 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect @@ -91,7 +96,6 @@ require ( github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect github.com/gorilla/mux v1.8.1 // indirect - github.com/hashicorp/consul/api v1.32.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.6.3 // indirect @@ -105,17 +109,14 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect - github.com/jackc/pgx/v5 v5.7.4 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/leodido/go-urn v1.4.0 // indirect - github.com/lib/pq v1.10.9 // indirect github.com/lmittmann/tint v1.0.7 // indirect github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-sqlite3 v1.14.28 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -135,7 +136,6 @@ require ( github.com/shirou/gopsutil/v3 v3.24.5 // indirect github.com/shoenig/go-m1cpu v0.1.6 // indirect github.com/spf13/pflag v1.0.6 // indirect - github.com/sqlite3ent/sqlite3 v1.34.1 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect github.com/tklauser/go-sysconf v0.3.15 // indirect github.com/tklauser/numcpus v0.10.0 // indirect diff --git a/go.sum b/go.sum index 0b141332..e3ca1e13 100644 --- a/go.sum +++ b/go.sum @@ -1077,10 +1077,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/origadmin/contrib/consul v0.0.33 h1:yupFC4cc3d0wTrmg6AbKHWZJxHX6MnkBZ5kHyP8i24I= -github.com/origadmin/contrib/consul v0.0.33/go.mod h1:WN6/MhWc66afuacmxME/8bBfl/tjViECWVKhuMw+xd0= -github.com/origadmin/contrib/database v0.0.33 h1:8gp/s3y1oDyfDLGhAArDTMuUI+cw4vIQUmvq54zlacE= -github.com/origadmin/contrib/database v0.0.33/go.mod h1:C789sBJhECVWe/4095eHFaenjE9VOydwEGCdh+KK4Pg= +github.com/origadmin/contrib/database v0.0.34 h1:vh6nN4Kl85BWU73kTa/Q0+yEA72o1ZCh+HnUELJ9TXo= +github.com/origadmin/contrib/database v0.0.34/go.mod h1:C789sBJhECVWe/4095eHFaenjE9VOydwEGCdh+KK4Pg= github.com/origadmin/contrib/i18n v0.0.33 h1:d5i60H2cd1+aqoDPE3WIvznimCAiHBsTITg2aGNqg1s= github.com/origadmin/contrib/i18n v0.0.33/go.mod h1:dNURdi4+YbtKueS5cZyZmwT98FPKOfPwaDfhAtE/lr4= github.com/origadmin/contrib/replacer v0.0.33 h1:Zmc7n4Q8oOnUZu8xNLacHhOWGDpGH+MjZh2bs5MjNv0= diff --git a/internal/configs/bootstrap.pb.go b/internal/configs/bootstrap.pb.go index 794e897b..844e85c6 100644 --- a/internal/configs/bootstrap.pb.go +++ b/internal/configs/bootstrap.pb.go @@ -12,6 +12,7 @@ import ( v11 "github.com/origadmin/runtime/gen/go/middleware/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + services "origadmin/application/admin/internal/configs/services" reflect "reflect" sync "sync" unsafe "unsafe" @@ -139,10 +140,8 @@ type Bootstrap struct { Id string `protobuf:"bytes,100,opt,name=id,proto3" json:"id,omitempty"` Environment string `protobuf:"bytes,102,opt,name=environment,proto3" json:"environment,omitempty"` // 入口服务专属配置 - Entry *Bootstrap_Entry `protobuf:"bytes,103,opt,name=entry,proto3" json:"entry,omitempty"` - HttpGateway *v1.Service `protobuf:"bytes,104,opt,name=http_gateway,proto3" json:"http_gateway,omitempty"` - // 动态加载服务配置 - Services []*ServiceConfig `protobuf:"bytes,200,rep,name=services,proto3" json:"services,omitempty"` + Entry *Bootstrap_Entry `protobuf:"bytes,103,opt,name=entry,proto3" json:"entry,omitempty"` + Services []*services.Service `protobuf:"bytes,104,rep,name=services,proto3" json:"services,omitempty"` // 服务专用配置 Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` @@ -239,14 +238,7 @@ func (x *Bootstrap) GetEntry() *Bootstrap_Entry { return nil } -func (x *Bootstrap) GetHttpGateway() *v1.Service { - if x != nil { - return x.HttpGateway - } - return nil -} - -func (x *Bootstrap) GetServices() []*ServiceConfig { +func (x *Bootstrap) GetServices() []*services.Service { if x != nil { return x.Services } @@ -448,13 +440,13 @@ var File_configs_bootstrap_proto protoreflect.FileDescriptor const file_configs_bootstrap_proto_rawDesc = "" + "\n" + - "\x17configs/bootstrap.proto\x12\x15origadmin.configs.api\x1a\x16config/v1/logger.proto\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1dconfigs/security_config.proto\x1a\x1emiddleware/v1/middleware.proto\x1a\x17validate/validate.proto\"[\n" + + "\x17configs/bootstrap.proto\x12\vapi.configs\x1a\x16config/v1/logger.proto\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1dconfigs/security_config.proto\x1a\x1econfigs/services/service.proto\x1a\x1emiddleware/v1/middleware.proto\x1a\x17validate/validate.proto\"[\n" + "\x13EntrySelectorConfig\x12\x16\n" + "\x06global\x18\x02 \x01(\bR\x06global\x12\x12\n" + "\x04name\x18\x03 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x04 \x01(\tR\aversion\",\n" + "\rServiceConfig\x12\x1b\n" + - "\x04name\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x04name\"\xa5\a\n" + + "\x04name\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x04name\"\xc7\x06\n" + "\tBootstrap\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x02 \x01(\tR\aversion\x12 \n" + @@ -462,18 +454,17 @@ const file_configs_bootstrap_proto_rawDesc = "" + "\x04mode\x18\x05 \x01(\tB\x19\xfaB\x16r\x14R\tsingletonR\aclusterR\x04mode\x124\n" + "\x15enable_dynamic_config\x18\a \x01(\bR\x15enable_dynamic_config\x12\x0e\n" + "\x02id\x18d \x01(\tR\x02id\x122\n" + - "\venvironment\x18f \x01(\tB\x10\xfaB\rr\vR\x03devR\x04prodR\venvironment\x12<\n" + - "\x05entry\x18g \x01(\v2&.origadmin.configs.api.Bootstrap.EntryR\x05entry\x126\n" + - "\fhttp_gateway\x18h \x01(\v2\x12.config.v1.ServiceR\fhttp_gateway\x12A\n" + - "\bservices\x18\xc8\x01 \x03(\v2$.origadmin.configs.api.ServiceConfigR\bservices\x12-\n" + + "\venvironment\x18f \x01(\tB\x10\xfaB\rr\vR\x03devR\x04prodR\venvironment\x122\n" + + "\x05entry\x18g \x01(\v2\x1c.api.configs.Bootstrap.EntryR\x05entry\x129\n" + + "\bservices\x18h \x03(\v2\x1d.api.configs.services.ServiceR\bservices\x12-\n" + "\astorage\x18\xac\x02 \x01(\v2\x12.config.v1.StorageR\astorage\x120\n" + "\bregistry\x18\x90\x03 \x01(\v2\x13.config.v1.RegistryR\bregistry\x129\n" + "\n" + "middleware\x18\t \x01(\v2\x19.middleware.v1.MiddlewareR\n" + - "middleware\x12A\n" + + "middleware\x127\n" + "\bsecurity\x18\n" + - " \x01(\v2%.origadmin.configs.api.SecurityConfigR\bsecurity\x12Q\n" + - "\fhealth_check\x18\xeb\a \x01(\v2,.origadmin.configs.api.Bootstrap.HealthCheckR\fhealth_check\x12*\n" + + " \x01(\v2\x1b.api.configs.SecurityConfigR\bsecurity\x12G\n" + + "\fhealth_check\x18\xeb\a \x01(\v2\".api.configs.Bootstrap.HealthCheckR\fhealth_check\x12*\n" + "\x06logger\x18\xec\a \x01(\v2\x11.config.v1.LoggerR\x06logger\x1a;\n" + "\vHealthCheck\x12\x18\n" + "\atimeout\x18\x01 \x01(\x05R\atimeout\x12\x12\n" + @@ -498,35 +489,35 @@ func file_configs_bootstrap_proto_rawDescGZIP() []byte { var file_configs_bootstrap_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_configs_bootstrap_proto_goTypes = []any{ - (*EntrySelectorConfig)(nil), // 0: origadmin.configs.api.EntrySelectorConfig - (*ServiceConfig)(nil), // 1: origadmin.configs.api.ServiceConfig - (*Bootstrap)(nil), // 2: origadmin.configs.api.Bootstrap - (*Settings)(nil), // 3: origadmin.configs.api.Settings - (*Bootstrap_HealthCheck)(nil), // 4: origadmin.configs.api.Bootstrap.HealthCheck - (*Bootstrap_Entry)(nil), // 5: origadmin.configs.api.Bootstrap.Entry - (*v1.Service)(nil), // 6: config.v1.Service + (*EntrySelectorConfig)(nil), // 0: api.configs.EntrySelectorConfig + (*ServiceConfig)(nil), // 1: api.configs.ServiceConfig + (*Bootstrap)(nil), // 2: api.configs.Bootstrap + (*Settings)(nil), // 3: api.configs.Settings + (*Bootstrap_HealthCheck)(nil), // 4: api.configs.Bootstrap.HealthCheck + (*Bootstrap_Entry)(nil), // 5: api.configs.Bootstrap.Entry + (*services.Service)(nil), // 6: api.configs.services.Service (*v1.Storage)(nil), // 7: config.v1.Storage (*v1.Registry)(nil), // 8: config.v1.Registry (*v11.Middleware)(nil), // 9: middleware.v1.Middleware - (*SecurityConfig)(nil), // 10: origadmin.configs.api.SecurityConfig + (*SecurityConfig)(nil), // 10: api.configs.SecurityConfig (*v1.Logger)(nil), // 11: config.v1.Logger + (*v1.Service)(nil), // 12: config.v1.Service } var file_configs_bootstrap_proto_depIdxs = []int32{ - 5, // 0: origadmin.configs.api.Bootstrap.entry:type_name -> origadmin.configs.api.Bootstrap.Entry - 6, // 1: origadmin.configs.api.Bootstrap.http_gateway:type_name -> config.v1.Service - 1, // 2: origadmin.configs.api.Bootstrap.services:type_name -> origadmin.configs.api.ServiceConfig - 7, // 3: origadmin.configs.api.Bootstrap.storage:type_name -> config.v1.Storage - 8, // 4: origadmin.configs.api.Bootstrap.registry:type_name -> config.v1.Registry - 9, // 5: origadmin.configs.api.Bootstrap.middleware:type_name -> middleware.v1.Middleware - 10, // 6: origadmin.configs.api.Bootstrap.security:type_name -> origadmin.configs.api.SecurityConfig - 4, // 7: origadmin.configs.api.Bootstrap.health_check:type_name -> origadmin.configs.api.Bootstrap.HealthCheck - 11, // 8: origadmin.configs.api.Bootstrap.logger:type_name -> config.v1.Logger - 6, // 9: origadmin.configs.api.Bootstrap.Entry.server:type_name -> config.v1.Service - 10, // [10:10] is the sub-list for method output_type - 10, // [10:10] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name + 5, // 0: api.configs.Bootstrap.entry:type_name -> api.configs.Bootstrap.Entry + 6, // 1: api.configs.Bootstrap.services:type_name -> api.configs.services.Service + 7, // 2: api.configs.Bootstrap.storage:type_name -> config.v1.Storage + 8, // 3: api.configs.Bootstrap.registry:type_name -> config.v1.Registry + 9, // 4: api.configs.Bootstrap.middleware:type_name -> middleware.v1.Middleware + 10, // 5: api.configs.Bootstrap.security:type_name -> api.configs.SecurityConfig + 4, // 6: api.configs.Bootstrap.health_check:type_name -> api.configs.Bootstrap.HealthCheck + 11, // 7: api.configs.Bootstrap.logger:type_name -> config.v1.Logger + 12, // 8: api.configs.Bootstrap.Entry.server:type_name -> config.v1.Service + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_configs_bootstrap_proto_init() } diff --git a/internal/configs/bootstrap.pb.validate.go b/internal/configs/bootstrap.pb.validate.go index 4f1c8b0c..d2892f81 100644 --- a/internal/configs/bootstrap.pb.validate.go +++ b/internal/configs/bootstrap.pb.validate.go @@ -337,35 +337,6 @@ func (m *Bootstrap) validate(all bool) error { } } - if all { - switch v := interface{}(m.GetHttpGateway()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "HttpGateway", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "HttpGateway", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetHttpGateway()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "HttpGateway", - reason: "embedded message failed validation", - cause: err, - } - } - } - for idx, item := range m.GetServices() { _, _ = idx, item diff --git a/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto index f35b2aa1..19533f55 100644 --- a/internal/configs/bootstrap.proto +++ b/internal/configs/bootstrap.proto @@ -1,12 +1,13 @@ syntax = "proto3"; -package origadmin.configs.api; +package api.configs; import "config/v1/logger.proto"; import "config/v1/registry.proto"; import "config/v1/service.proto"; import "config/v1/storage.proto"; import "configs/security_config.proto"; +import "configs/services/service.proto"; import "middleware/v1/middleware.proto"; import "validate/validate.proto"; // Updated import statement @@ -68,10 +69,7 @@ message Bootstrap { // 入口服务专属配置 Entry entry = 103 [json_name = "entry"]; - config.v1.Service http_gateway = 104 [json_name = "http_gateway"]; - - // 动态加载服务配置 - repeated ServiceConfig services = 200 [json_name = "services"]; + repeated api.configs.services.Service services = 104 [json_name = "services"]; config.v1.Storage storage = 300 [json_name = "storage"]; config.v1.Registry registry = 400 [json_name = "registry"]; diff --git a/internal/configs/captcha.pb.go b/internal/configs/captcha.pb.go index 355e273f..32899f5e 100644 --- a/internal/configs/captcha.pb.go +++ b/internal/configs/captcha.pb.go @@ -102,7 +102,7 @@ var File_configs_captcha_proto protoreflect.FileDescriptor const file_configs_captcha_proto_rawDesc = "" + "\n" + - "\x15configs/captcha.proto\x12\x15origadmin.configs.api\x1a\x17config/v1/storage.proto\"\xa1\x01\n" + + "\x15configs/captcha.proto\x12\vapi.configs\x1a\x17config/v1/storage.proto\"\xa1\x01\n" + "\aCaptcha\x12\x16\n" + "\x06length\x18\x01 \x01(\x05R\x06length\x12\x14\n" + "\x05width\x18\x02 \x01(\x05R\x05width\x12\x16\n" + @@ -124,11 +124,11 @@ func file_configs_captcha_proto_rawDescGZIP() []byte { var file_configs_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_captcha_proto_goTypes = []any{ - (*Captcha)(nil), // 0: origadmin.configs.api.Captcha + (*Captcha)(nil), // 0: api.configs.Captcha (*v1.Storage)(nil), // 1: config.v1.Storage } var file_configs_captcha_proto_depIdxs = []int32{ - 1, // 0: origadmin.configs.api.Captcha.storage:type_name -> config.v1.Storage + 1, // 0: api.configs.Captcha.storage:type_name -> config.v1.Storage 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name diff --git a/internal/configs/captcha.proto b/internal/configs/captcha.proto index c8d8411b..e397d56f 100644 --- a/internal/configs/captcha.proto +++ b/internal/configs/captcha.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package origadmin.configs.api; +package api.configs; import "config/v1/storage.proto"; diff --git a/internal/configs/root_user.pb.go b/internal/configs/root_user.pb.go index 56f92d52..a9468f6b 100644 --- a/internal/configs/root_user.pb.go +++ b/internal/configs/root_user.pb.go @@ -166,7 +166,7 @@ var File_configs_root_user_proto protoreflect.FileDescriptor const file_configs_root_user_proto_rawDesc = "" + "\n" + - "\x17configs/root_user.proto\x12\x15origadmin.configs.api\x1a\x17validate/validate.proto\"\x8c\x03\n" + + "\x17configs/root_user.proto\x12\vapi.configs\x1a\x17validate/validate.proto\"\x8c\x03\n" + "\bRootUser\x12\x18\n" + "\aenabled\x18\x01 \x01(\bR\aenabled\x12\x17\n" + "\x02id\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x02id\x12#\n" + @@ -197,7 +197,7 @@ func file_configs_root_user_proto_rawDescGZIP() []byte { var file_configs_root_user_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_root_user_proto_goTypes = []any{ - (*RootUser)(nil), // 0: origadmin.configs.api.RootUser + (*RootUser)(nil), // 0: api.configs.RootUser } var file_configs_root_user_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type diff --git a/internal/configs/root_user.proto b/internal/configs/root_user.proto index 97562fab..c4bf035c 100644 --- a/internal/configs/root_user.proto +++ b/internal/configs/root_user.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package origadmin.configs.api; +package api.configs; import "validate/validate.proto"; diff --git a/internal/configs/security_config.pb.go b/internal/configs/security_config.pb.go index b38cbcbc..41bb1c84 100644 --- a/internal/configs/security_config.pb.go +++ b/internal/configs/security_config.pb.go @@ -86,10 +86,10 @@ var File_configs_security_config_proto protoreflect.FileDescriptor const file_configs_security_config_proto_rawDesc = "" + "\n" + - "\x1dconfigs/security_config.proto\x12\x15origadmin.configs.api\x1a\x18config/v1/security.proto\x1a\x15configs/captcha.proto\x1a\x17configs/root_user.proto\"\xba\x01\n" + - "\x0eSecurityConfig\x12=\n" + - "\troot_user\x18\x01 \x01(\v2\x1f.origadmin.configs.api.RootUserR\troot_user\x128\n" + - "\acaptcha\x18\x02 \x01(\v2\x1e.origadmin.configs.api.CaptchaR\acaptcha\x12/\n" + + "\x1dconfigs/security_config.proto\x12\vapi.configs\x1a\x18config/v1/security.proto\x1a\x15configs/captcha.proto\x1a\x17configs/root_user.proto\"\xa6\x01\n" + + "\x0eSecurityConfig\x123\n" + + "\troot_user\x18\x01 \x01(\v2\x15.api.configs.RootUserR\troot_user\x12.\n" + + "\acaptcha\x18\x02 \x01(\v2\x14.api.configs.CaptchaR\acaptcha\x12/\n" + "\bsecurity\x18\x03 \x01(\v2\x13.config.v1.SecurityR\bsecurityB.Z,origadmin/application/admin/internal/configsb\x06proto3" var ( @@ -106,15 +106,15 @@ func file_configs_security_config_proto_rawDescGZIP() []byte { var file_configs_security_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_security_config_proto_goTypes = []any{ - (*SecurityConfig)(nil), // 0: origadmin.configs.api.SecurityConfig - (*RootUser)(nil), // 1: origadmin.configs.api.RootUser - (*Captcha)(nil), // 2: origadmin.configs.api.Captcha + (*SecurityConfig)(nil), // 0: api.configs.SecurityConfig + (*RootUser)(nil), // 1: api.configs.RootUser + (*Captcha)(nil), // 2: api.configs.Captcha (*v1.Security)(nil), // 3: config.v1.Security } var file_configs_security_config_proto_depIdxs = []int32{ - 1, // 0: origadmin.configs.api.SecurityConfig.root_user:type_name -> origadmin.configs.api.RootUser - 2, // 1: origadmin.configs.api.SecurityConfig.captcha:type_name -> origadmin.configs.api.Captcha - 3, // 2: origadmin.configs.api.SecurityConfig.security:type_name -> config.v1.Security + 1, // 0: api.configs.SecurityConfig.root_user:type_name -> api.configs.RootUser + 2, // 1: api.configs.SecurityConfig.captcha:type_name -> api.configs.Captcha + 3, // 2: api.configs.SecurityConfig.security:type_name -> config.v1.Security 3, // [3:3] is the sub-list for method output_type 3, // [3:3] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name diff --git a/internal/configs/security_config.proto b/internal/configs/security_config.proto index 6e6ce20a..56fba8d6 100644 --- a/internal/configs/security_config.proto +++ b/internal/configs/security_config.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package origadmin.configs.api; +package api.configs; import "config/v1/security.proto"; import "configs/captcha.proto"; diff --git a/internal/configs/server.pb.go b/internal/configs/server.pb.go index b8bf3b28..77b4b86b 100644 --- a/internal/configs/server.pb.go +++ b/internal/configs/server.pb.go @@ -111,7 +111,7 @@ var File_configs_server_proto protoreflect.FileDescriptor const file_configs_server_proto_rawDesc = "" + "\n" + - "\x14configs/server.proto\x12\x1forigadmin.origadmin.configs.api\x1a\x17config/v1/storage.proto\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x1emiddleware/v1/middleware.proto\"\x81\x02\n" + + "\x14configs/server.proto\x12\x15origadmin.api.configs\x1a\x17config/v1/storage.proto\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x1emiddleware/v1/middleware.proto\"\x81\x02\n" + "\x06Server\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x02 \x01(\tR\aversion\x12-\n" + @@ -136,17 +136,17 @@ func file_configs_server_proto_rawDescGZIP() []byte { var file_configs_server_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_configs_server_proto_goTypes = []any{ - (*Server)(nil), // 0: origadmin.origadmin.configs.api.Server + (*Server)(nil), // 0: origadmin.api.configs.Server (*v1.Service)(nil), // 1: config.v1.Service (*v1.Storage)(nil), // 2: config.v1.Storage (*v1.Registry)(nil), // 3: config.v1.Registry (*v11.Middleware)(nil), // 4: middleware.v1.Middleware } var file_configs_server_proto_depIdxs = []int32{ - 1, // 0: origadmin.origadmin.configs.api.Server.service:type_name -> config.v1.Service - 2, // 1: origadmin.origadmin.configs.api.Server.storage:type_name -> config.v1.Storage - 3, // 2: origadmin.origadmin.configs.api.Server.registry:type_name -> config.v1.Registry - 4, // 3: origadmin.origadmin.configs.api.Server.middleware:type_name -> middleware.v1.Middleware + 1, // 0: origadmin.api.configs.Server.service:type_name -> config.v1.Service + 2, // 1: origadmin.api.configs.Server.storage:type_name -> config.v1.Storage + 3, // 2: origadmin.api.configs.Server.registry:type_name -> config.v1.Registry + 4, // 3: origadmin.api.configs.Server.middleware:type_name -> middleware.v1.Middleware 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name diff --git a/internal/configs/server.proto b/internal/configs/server.proto index 09dd14d8..9cbf5af5 100644 --- a/internal/configs/server.proto +++ b/internal/configs/server.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package origadmin.origadmin.configs.api; +package origadmin.api.configs; import "config/v1/storage.proto"; import "config/v1/registry.proto"; diff --git a/internal/configs/services/service.pb.go b/internal/configs/services/service.pb.go index c43d14e1..35c772a3 100644 --- a/internal/configs/services/service.pb.go +++ b/internal/configs/services/service.pb.go @@ -155,14 +155,14 @@ var File_configs_services_service_proto protoreflect.FileDescriptor const file_configs_services_service_proto_rawDesc = "" + "\n" + - "\x1econfigs/services/service.proto\x12\x1eorigadmin.configs.services.api\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1emiddleware/v1/middleware.proto\"\x9c\x01\n" + + "\x1econfigs/services/service.proto\x12\x14api.configs.services\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1emiddleware/v1/middleware.proto\"\x9c\x01\n" + "\vServiceCore\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x02 \x01(\tR\aversion\x12/\n" + "\bregistry\x18\x03 \x01(\v2\x13.config.v1.RegistryR\bregistry\x12.\n" + - "\bstorages\x18\x04 \x03(\v2\x12.config.v1.StorageR\bstorages\"\xb5\x01\n" + - "\aService\x12?\n" + - "\x04core\x18\x01 \x01(\v2+.origadmin.configs.services.api.ServiceCoreR\x04core\x12-\n" + + "\bstorages\x18\x04 \x03(\v2\x12.config.v1.StorageR\bstorages\"\xab\x01\n" + + "\aService\x125\n" + + "\x04core\x18\x01 \x01(\v2!.api.configs.services.ServiceCoreR\x04core\x12-\n" + "\aservice\x18\xc8\x01 \x01(\v2\x12.config.v1.ServiceR\aservice\x12:\n" + "\n" + "middleware\x18\xac\x02 \x01(\v2\x19.middleware.v1.MiddlewareR\n" + @@ -182,19 +182,19 @@ func file_configs_services_service_proto_rawDescGZIP() []byte { var file_configs_services_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_configs_services_service_proto_goTypes = []any{ - (*ServiceCore)(nil), // 0: origadmin.configs.services.api.ServiceCore - (*Service)(nil), // 1: origadmin.configs.services.api.Service + (*ServiceCore)(nil), // 0: api.configs.services.ServiceCore + (*Service)(nil), // 1: api.configs.services.Service (*v1.Registry)(nil), // 2: config.v1.Registry (*v1.Storage)(nil), // 3: config.v1.Storage (*v1.Service)(nil), // 4: config.v1.Service (*v11.Middleware)(nil), // 5: middleware.v1.Middleware } var file_configs_services_service_proto_depIdxs = []int32{ - 2, // 0: origadmin.configs.services.api.ServiceCore.registry:type_name -> config.v1.Registry - 3, // 1: origadmin.configs.services.api.ServiceCore.storages:type_name -> config.v1.Storage - 0, // 2: origadmin.configs.services.api.Service.core:type_name -> origadmin.configs.services.api.ServiceCore - 4, // 3: origadmin.configs.services.api.Service.service:type_name -> config.v1.Service - 5, // 4: origadmin.configs.services.api.Service.middleware:type_name -> middleware.v1.Middleware + 2, // 0: api.configs.services.ServiceCore.registry:type_name -> config.v1.Registry + 3, // 1: api.configs.services.ServiceCore.storages:type_name -> config.v1.Storage + 0, // 2: api.configs.services.Service.core:type_name -> api.configs.services.ServiceCore + 4, // 3: api.configs.services.Service.service:type_name -> config.v1.Service + 5, // 4: api.configs.services.Service.middleware:type_name -> middleware.v1.Middleware 5, // [5:5] is the sub-list for method output_type 5, // [5:5] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name diff --git a/internal/configs/services/service.proto b/internal/configs/services/service.proto index 6af2385f..57dde205 100644 --- a/internal/configs/services/service.proto +++ b/internal/configs/services/service.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package origadmin.configs.services.api; +package api.configs.services; import "config/v1/registry.proto"; import "config/v1/service.proto"; diff --git a/internal/data/data.go b/internal/data/data.go index c8af1a6f..bdd203e0 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -50,6 +50,7 @@ var ProviderSet = wire.NewSet( type Data struct { *ent.Database + Delimiter string } type LoginData struct { @@ -134,7 +135,8 @@ func NewData(r runtime.Runtime, bootstrap *configs.Bootstrap) (*Data, func(), er } data := &Data{ - Database: db, + Database: db, + Delimiter: TreePathDelimiter, } return data, func() { diff --git a/internal/loader/bootstrap.go b/internal/loader/bootstrap.go index d44d6843..ee213962 100644 --- a/internal/loader/bootstrap.go +++ b/internal/loader/bootstrap.go @@ -45,9 +45,11 @@ type ResolvedBootstrap struct { } func (r *ResolvedBootstrap) Resolve(config config.KConfig) (config.Resolved, error) { - if err := config.Scan(&r.bootstrap); err != nil { + var unknown map[string]any + if err := config.Scan(&unknown); err != nil { return nil, err } + log.NewHelper(log.DefaultLogger).Infof("bootstrap: %+v", unknown) return r, nil } @@ -99,6 +101,8 @@ func Bootstrap(ctx context.Context, flags *bootstrap.Bootstrap, newApp NewApp) e "trace.id", tracing.TraceID(), "span.id", tracing.SpanID(), ) + help := log.NewHelper(r.Logger()) + help.Infof("bootstrap: %+v", &rb.bootstrap) app, clean, err := newApp(r, &rb.bootstrap) if err != nil { return err diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go index 2dd18189..e8983112 100644 --- a/internal/loader/bootstrap_default.go +++ b/internal/loader/bootstrap_default.go @@ -18,6 +18,7 @@ import ( sjwtv1 "github.com/origadmin/runtime/gen/go/security/jwt/v1" "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/configs/services" ) const ( @@ -37,22 +38,42 @@ func DefaultBootstrap() *configs.Bootstrap { Entry: &configs.Bootstrap_Entry{ Scheme: "http", }, - Services: []*configs.ServiceConfig{ - //&configv1.Service{ - // Name: "", - // DynamicEndpoint: true, - // Grpc: DefaultServiceGrpc(), - // Http: DefaultServiceHttp(), - // Websocket: DefaultServiceWebsocket(), - // Message: DefaultServiceMessage(), - // Task: DefaultServiceTask(), - // Middleware: DefaultServiceMiddleware(), - // Selector: &configv1.Service_Selector{ - // Version: "v1.0.0", - // Builder: "bbr", - // }, - //} + Services: []*services.Service{ + { + Service: &configv1.Service{ + Name: "", + DynamicEndpoint: true, + Type: "grpc", + Grpc: DefaultServiceGrpc(), + //Http: DefaultServiceHttp(), + Websocket: DefaultServiceWebsocket(), + Message: DefaultServiceMessage(), + Task: DefaultServiceTask(), + Middleware: DefaultServiceMiddleware(), + Selector: &configv1.Service_Selector{ + Version: "v1.0.0", + Builder: "bbr", + }, + }, + }, + { + Service: &configv1.Service{ + Name: "", + DynamicEndpoint: true, + Type: "http", + Http: DefaultServiceHttp(), + Websocket: DefaultServiceWebsocket(), + Message: DefaultServiceMessage(), + Task: DefaultServiceTask(), + Middleware: DefaultServiceMiddleware(), + Selector: &configv1.Service_Selector{ + Version: "v1.0.0", + Builder: "bbr", + }, + }, + }, }, + Logger: DefaultLogger(), Storage: DefaultStorage(), Registry: DefaultRegistry(), Middleware: DefaultServiceMiddleware(), @@ -107,6 +128,31 @@ func DefaultBootstrap() *configs.Bootstrap { } } +func DefaultLogger() *configv1.Logger { + return &configv1.Logger{ + Disabled: false, + Develop: true, + Default: true, + Name: "output.log", + Format: "json", + Level: configv1.LoggerLevel_LOGGER_LEVEL_INFO, + Stdout: true, + DisableCaller: false, + CallerSkip: 0, + TimeFormat: "", + File: &configv1.Logger_File{ + Path: "logs", + Lumberjack: true, + Compress: false, + LocalTime: false, + MaxSize: 0, + MaxAge: 0, + MaxBackups: 0, + }, + DevLogger: nil, + } +} + func DefaultServiceWebsocket() *configv1.WebSocket { return &configv1.WebSocket{ Addr: "", diff --git a/internal/loader/bootstrap_test.go b/internal/loader/bootstrap_test.go index c0e35c1f..5dbcdaee 100644 --- a/internal/loader/bootstrap_test.go +++ b/internal/loader/bootstrap_test.go @@ -14,6 +14,7 @@ import ( "time" "github.com/go-kratos/kratos/v2/encoding" + _ "github.com/go-kratos/kratos/v2/encoding/proto" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/slog-kratos" @@ -189,12 +190,13 @@ func TestData_InitDataFromPath(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if tt.fields.Bootstrap == nil { - abs, err := filepath.Abs("../../resources/configs/system") + abs, err := filepath.Abs("D:\\workspace\\project\\golang\\origadmin\\backend\\internal\\loader\\test" + + "\\test.toml") if err != nil { return } log.Infof("abs: %s", abs) - bs, err := LoadLocalBootstrap(`D:\workspace\project\golang\origadmin\backend\internal\loader\test\test.toml`) + bs, err := LoadLocalBootstrap(abs) if err != nil { t.Fatal(err) return diff --git a/internal/loader/file.go b/internal/loader/file.go index c6b803d5..701d8a8a 100644 --- a/internal/loader/file.go +++ b/internal/loader/file.go @@ -8,16 +8,23 @@ package loader import ( "encoding/json" "os" + "path/filepath" "strings" + "github.com/go-kratos/kratos/v2/encoding" "github.com/goexts/generic/settings" "github.com/origadmin/contrib/replacer" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/config" "github.com/origadmin/runtime/config/file" configv1 "github.com/origadmin/runtime/gen/go/config/v1" + "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/codec" + "github.com/origadmin/toolkits/errors" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" + + "origadmin/application/admin/internal/configs" ) // SaveOption represents an option for saving configuration data. @@ -27,6 +34,10 @@ var ( r = replacer.New(replacer.WithStart("${"), replacer.WithEnd("}"), replacer.WithSeparator(":")) ) +func init() { + runtime.RegisterConfig("file", FileConfig(NewFileConfig)) +} + // SaveConfig saves the configuration data to the specified file path. func SaveConfig(path string, data any, opts ...SaveOption) error { if v, ok := data.(proto.Message); ok && strings.HasSuffix(path, ".json") { @@ -61,6 +72,12 @@ func ReplaceObject(s any, envs map[string]string) error { return json.Unmarshal(marshal, s) } +type FileConfig func(*configv1.SourceConfig, *config.Options) (config.KSource, error) + +func (f FileConfig) NewSource(sourceConfig *configv1.SourceConfig, _ *config.Options) (config.KSource, error) { + return f(sourceConfig, nil) +} + func NewFileConfig(sourceConfig *configv1.SourceConfig, _ *config.Options) (config.KSource, error) { cfg := sourceConfig.GetFile() if cfg == nil { @@ -70,5 +87,48 @@ func NewFileConfig(sourceConfig *configv1.SourceConfig, _ *config.Options) (conf if len(cfg.Ignores) > 0 { options = append(options, file.WithIgnores(cfg.Ignores...)) } + v := new(configs.Bootstrap) + options = append(options, file.WithFormatter(fileFormatter(v))) + path, _ := filepath.Abs(cfg.Path) + log.NewHelper(log.DefaultLogger).Infof("loading config from %s", path) return file.NewSource(cfg.Path, options...), nil } + +func fileFormatter(typo any) file.Formatter { + return func(key string, value []byte) (*config.KKeyValue, error) { + err := encoding.GetCodec(format(key)).Unmarshal(value, typo) + if err != nil { + return nil, errors.Wrap(err, "unmarshal config") + } + //if v, ok := typo.(proto.Message); ok { + // c := encoding.GetCodec("proto") + // marshal, err := c.Marshal(v) + // if err != nil { + // return nil, err + // } + // return &config.KKeyValue{ + // Key: key, + // Format: "proto", + // Value: marshal, + // }, nil + //} + j := encoding.GetCodec("json") + marshal, err := j.Marshal(typo) + if err != nil { + return nil, err + } + key = strings.TrimSuffix(key, filepath.Ext(key)) + return &config.KKeyValue{ + Key: key + ".json", + Format: "json", + Value: marshal, + }, nil + } +} + +func format(name string) string { + if p := strings.Split(name, "."); len(p) > 1 { + return p[len(p)-1] + } + return "" +} diff --git a/internal/loader/load.go b/internal/loader/load.go index 19d75a15..c00fc7fc 100644 --- a/internal/loader/load.go +++ b/internal/loader/load.go @@ -60,7 +60,6 @@ type Injector struct { func init() { runtime.RegisterConfigFunc("file", NewFileConfig) - //runtime.RegisterService(service.Service, service.DefaultServiceBuilder) } type loader struct { diff --git a/internal/mods/auth/dal/auth.dal.go b/internal/mods/auth/dal/auth.dal.go index 3d4de797..2bf596d3 100644 --- a/internal/mods/auth/dal/auth.dal.go +++ b/internal/mods/auth/dal/auth.dal.go @@ -13,13 +13,14 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/mods/system/dto" ) type authRepo struct { - DB *Data + DB *data.Data BufPool *sync.Pool Tokenizer security.Tokenizer Authorizer security.Authorizer @@ -99,7 +100,7 @@ func fromClaims(claims security.Claims, method, path string) security.Policy { } // NewAuthRepo . -func NewAuthRepo(db *Data, logger log.KLogger) dto.AuthRepo { +func NewAuthRepo(db *data.Data, logger log.KLogger) dto.AuthRepo { return &authRepo{ DB: db, BufPool: BufPool(), diff --git a/internal/mods/auth/dal/casbin.dal.go b/internal/mods/auth/dal/casbin.dal.go index 8a84bee9..c72c18d0 100644 --- a/internal/mods/auth/dal/casbin.dal.go +++ b/internal/mods/auth/dal/casbin.dal.go @@ -10,6 +10,7 @@ import ( "strconv" pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/mods/system/dto" ) @@ -20,7 +21,7 @@ type CasbinSourceConfig struct { type casbinSourceRepo struct { ctx context.Context - data *Data + data *data.Data config *CasbinSourceConfig } @@ -88,7 +89,7 @@ func (c casbinSourceRepo) ListGroupings(ctx context.Context, in *pb.ListGrouping } // NewCasbinSourceRepo returns a new CasbinSourceRepo -func NewCasbinSourceRepo(data *Data) (dto.CasbinSourceRepo, error) { +func NewCasbinSourceRepo(data *data.Data) (dto.CasbinSourceRepo, error) { c := &casbinSourceRepo{ data: data, config: &CasbinSourceConfig{ @@ -104,7 +105,7 @@ func NewCasbinSourceRepo(data *Data) (dto.CasbinSourceRepo, error) { // This method does not ensure the existence of database, user should create database manually. func NewCasbinSourceWithClient(client *ent.Client) (dto.CasbinSourceRepo, error) { c := &casbinSourceRepo{ - data: NewDataWithClient(client), + data: data.NewDataWithClient(client), config: &CasbinSourceConfig{ PrefixNumberID: func(prefix string, id int64) string { return prefix + "_" + strconv.FormatInt(id, 10) diff --git a/internal/mods/auth/dal/dal.go b/internal/mods/auth/dal/dal.go index a8ef32c9..25bfd1bf 100644 --- a/internal/mods/auth/dal/dal.go +++ b/internal/mods/auth/dal/dal.go @@ -15,20 +15,14 @@ import ( "time" "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/schema" "github.com/google/wire" "github.com/origadmin/entslog/v3" - "github.com/origadmin/runtime" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/codec" - "origadmin/application/admin/contrib/database" "origadmin/application/admin/helpers/db" "origadmin/application/admin/helpers/id" - "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/department" "origadmin/application/admin/internal/data/entity/ent/predicate" "origadmin/application/admin/internal/data/entity/ent/resource" @@ -40,24 +34,20 @@ const ( ) // Data . -type Data struct { - *ent.Database -} +//type Data struct { +// *ent.Database +// Delimiter string +//} // ProviderSet is data providers. var ProviderSet = wire.NewSet( - NewData, + //NewData, NewAuthRepo, NewLoginRepo, NewCasbinSourceRepo, RefreshTokenizer, ) -// NewTrans returns a transaction wit data -//func NewTrans(data *Data) database.Trans { -// return data -//} - const FKSuffix = "_fk=1" func FixSource(source string) string { @@ -87,65 +77,6 @@ func debugDatabase(driver dialect.Driver, debug bool) dialect.Driver { return driver } -// NewData . -func NewData(r runtime.Runtime, bootstrap *configs.Bootstrap) (*Data, func(), error) { - if bootstrap == nil { - return nil, nil, errors.New("bootstrap is nil") - } - - cfg := bootstrap.GetStorage().GetDatabase() - if cfg == nil { - return nil, nil, errors.New("data source not found") - } - - drv, err := database.Open(cfg) - log.Infow("msg", "connecting to database", "dialect", cfg.Dialect, "source", cfg.Source) - if err != nil { - log.Errorw("msg", "failed opening connection to database", "error", err) - return nil, nil, err - } - - // Run the auto migration tool. - //sqldb := debugDatabase(sql.OpenDB(cfg.Dialect, drv), cfg.Debug) - - db := ent.NewDatabase(ent.Driver(sql.OpenDB(cfg.Dialect, drv)), ent.WithDebug(func(driver dialect.Driver, f ...func(...any)) dialect.Driver { - return debugDatabase(driver, cfg.Debug) - })) - if true || cfg.GetMigration().GetEnabled() { - if err := db.Migration( - context.Background(), - schema.WithDropIndex(true), - schema.WithDropColumn(true), - schema.WithForeignKeys(false)); err != nil { - log.Errorw("msg", "failed creating schema resources", "error", err) - return nil, nil, err - } - } - - data := &Data{ - Database: db, - } - - // 初始化数据 - if err := data.InitDataFromPath(context.Background(), ""); err != nil { - log.Errorw("failed to init data", "error", err) - return nil, nil, err - } - - return data, func() { - log.Info("closing the data resources") - if err := drv.Close(); err != nil { - log.Error(err) - } - }, nil -} - -func NewDataWithClient(client *ent.Client) *Data { - return &Data{ - Database: ent.NewDatabaseWithClient(client), - } -} - func (obj *Data) InitDataFromPath(ctx context.Context, path string, filters ...string) error { type data struct { name string diff --git a/internal/mods/system/dal/login.dal.go b/internal/mods/system/dal/login.dal.go index a7eea36e..7a1340aa 100644 --- a/internal/mods/system/dal/login.dal.go +++ b/internal/mods/system/dal/login.dal.go @@ -416,7 +416,7 @@ func NewLoginRepo(r runtime.Runtime, data *LoginData) dto.LoginRepo { return &loginRepo{ bufpool: BufPool(), LoginData: data, - captcha: NewCaptcha(data.Captcha), + //captcha: NewCaptcha(data.Captcha), } } diff --git a/internal/mods/system/dal/resource.dal.go b/internal/mods/system/dal/resource.dal.go index 73946b79..7048503e 100644 --- a/internal/mods/system/dal/resource.dal.go +++ b/internal/mods/system/dal/resource.dal.go @@ -9,7 +9,6 @@ import ( "strconv" "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/db" @@ -51,7 +50,7 @@ func (repo resourceRepo) Create(ctx context.Context, resource *dto.ResourcePB, o if err != nil { return nil, err } - obj.TreePath = parent.TreePath + strconv.Itoa(int(parent.ID)) + TreePathDelimiter + obj.TreePath = parent.TreePath + strconv.Itoa(int(parent.ID)) + repo.db.Delimiter } create := repo.db.Resource(ctx).Create() diff --git a/internal/mods/system/server/grpc.go b/internal/mods/system/server/grpc.go index 0c8f51a3..58c5d219 100644 --- a/internal/mods/system/server/grpc.go +++ b/internal/mods/system/server/grpc.go @@ -5,17 +5,24 @@ package server import ( - "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/service" "origadmin/application/admin/internal/configs" ) // NewGRPCServer new a gRPC server. -func NewGRPCServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.ServerOption) *service.GRPCServer { - //srv, err := runtime.NewGRPCServiceServer(bootstrap.GetService(), ss...) - //if err != nil { - // panic(err) - //} - return srv +func NewGRPCServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.GRPCServer { + services := bootstrap.GetServices() + for _, config := range services { + serviceConfig := config.GetService() + if serviceConfig.GetType() == "grpc" { + grpcServer, err := r.Builder().NewGRPCServer(serviceConfig) + if err != nil { + return nil + } + return grpcServer + } + } + return nil } diff --git a/internal/mods/system/server/http.go b/internal/mods/system/server/http.go index 413833bd..9dcbd296 100644 --- a/internal/mods/system/server/http.go +++ b/internal/mods/system/server/http.go @@ -5,21 +5,24 @@ package server import ( - "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/service" "origadmin/application/admin/internal/configs" ) // NewHTTPServer new an HTTP server. -func NewHTTPServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.ServerOption) *service.HTTPServer { - //options := settings.ApplyZero(ss) - //for i, config := range bootstrap.GetServices() { - // srv, err := runtime.NewHTTPServiceServer(bootstrap.GetServices(), options.ToHTTP()) - // if err != nil { - // panic(err) - // } - // return srv - //} +func NewHTTPServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.HTTPServer { + services := bootstrap.GetServices() + for _, config := range services { + serviceConfig := config.GetService() + if serviceConfig.GetType() == "http" { + httpServer, err := r.Builder().NewHTTPServer(serviceConfig) + if err != nil { + return nil + } + return httpServer + } + } return nil } diff --git a/main.go b/main.go index 031fb136..bee37ea5 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,6 @@ var ( treeState = "" date = "" builtBy = "" - debug = false ) func buildVersion(version, commit, date, builtBy, treeState string) goversion.Info { diff --git a/resources/configs/system/logger.toml b/resources/configs/system/logger.toml new file mode 100644 index 00000000..919cd6ed --- /dev/null +++ b/resources/configs/system/logger.toml @@ -0,0 +1,19 @@ +[Logger] +Disabled = false +Develop = true +Default = true +Name = "output.log" +Format = "json" +Level = 2 +Stdout = true +DisableCaller = false +CallerSkip = 0 +TimeFormat = "" +[Logger.File] +Path = "logs" +Lumberjack = true +Compress = false +LocalTime = false +MaxSize = 0 +MaxAge = 0 +MaxBackups = 0 diff --git a/test/token_test.go b/test/token_test.go index 44b4a267..a7272af4 100644 --- a/test/token_test.go +++ b/test/token_test.go @@ -9,8 +9,8 @@ import ( "context" "testing" - _ "github.com/origadmin/contrib/consul/config" - _ "github.com/origadmin/contrib/consul/registry" + _ "origadmin/application/admin/contrib/consul/config" + _ "origadmin/application/admin/contrib/consul/registry" _ "github.com/origadmin/contrib/database" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/interfaces/security" From edd08ccc9a329b47639cc3ee0db4aa1889564305 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 27 May 2025 16:36:34 +0800 Subject: [PATCH 025/158] refactor(configs): remove ServiceConfig and refactor Bootstrap - Remove ServiceConfig message from bootstrap.proto - Refactor Bootstrap message to include ServiceServer and ServiceClient - Update import statements and adjust package paths - Remove unused validation logic for ServiceConfig --- buf.lock | 4 +- internal/configs/bootstrap.pb.go | 176 +++++------ internal/configs/bootstrap.pb.validate.go | 218 +++++--------- internal/configs/bootstrap.proto | 26 +- internal/configs/captcha.pb.go | 2 +- internal/configs/security_config.pb.go | 2 +- internal/configs/server.pb.go | 20 +- internal/configs/server.pb.validate.go | 10 +- internal/configs/server.proto | 4 +- internal/configs/service.pb.go | 275 ++++++++++++++++++ .../{services => }/service.pb.validate.go | 215 +++++++++++--- internal/configs/{services => }/service.proto | 14 +- internal/configs/services/service.pb.go | 227 --------------- internal/generate.go | 2 - internal/loader/bootstrap.go | 9 +- third_party/config/v1/cors.proto | 6 +- third_party/config/v1/customize.proto | 16 +- .../v1/{registry.proto => discovery.proto} | 15 +- third_party/config/v1/gateway.proto | 26 +- third_party/config/v1/logger.proto | 17 +- third_party/config/v1/mail.proto | 6 +- third_party/config/v1/message.proto | 4 +- third_party/config/v1/security.proto | 5 +- third_party/config/v1/service.proto | 27 +- third_party/config/v1/source.proto | 35 ++- third_party/config/v1/storage.proto | 5 +- third_party/config/v1/task.proto | 4 +- third_party/config/v1/tlsconfig.proto | 4 +- third_party/config/v1/tracer.proto | 4 +- third_party/config/v1/websocket.proto | 6 +- third_party/google/protobuf/descriptor.proto | 52 ++++ .../google/protobuf/java_features.proto | 47 ++- .../v1/circuitbreaker/circuitbreaker.proto | 48 +++ third_party/middleware/v1/jwt/jwt.proto | 37 +++ .../middleware/v1/metrics/metrics.proto | 57 ++++ third_party/middleware/v1/middleware.proto | 55 ++-- .../middleware/v1/ratelimit/ratelimiter.proto | 53 ++++ .../middleware/v1/selector/selector.proto | 20 ++ .../middleware/v1/validator/validator.proto | 25 ++ third_party/pagination/v1/pagination.proto | 8 +- third_party/security/casbin/v1/policy.proto | 4 +- third_party/security/jwt/v1/config.proto | 32 +- third_party/security/jwt/v1/token.proto | 6 +- third_party/security/v1/auth.proto | 8 +- third_party/security/v1/error.proto | 4 +- 45 files changed, 1137 insertions(+), 703 deletions(-) create mode 100644 internal/configs/service.pb.go rename internal/configs/{services => }/service.pb.validate.go (57%) rename internal/configs/{services => }/service.proto (71%) delete mode 100644 internal/configs/services/service.pb.go rename third_party/config/v1/{registry.proto => discovery.proto} (81%) create mode 100644 third_party/middleware/v1/circuitbreaker/circuitbreaker.proto create mode 100644 third_party/middleware/v1/jwt/jwt.proto create mode 100644 third_party/middleware/v1/metrics/metrics.proto create mode 100644 third_party/middleware/v1/ratelimit/ratelimiter.proto create mode 100644 third_party/middleware/v1/selector/selector.proto create mode 100644 third_party/middleware/v1/validator/validator.proto diff --git a/buf.lock b/buf.lock index 017d2883..d7a807f9 100644 --- a/buf.lock +++ b/buf.lock @@ -14,5 +14,5 @@ deps: commit: c2de25f14fa445a79a054214f31d17a8 digest: b5:3e4dac0d26ce9db17309aeb845f0efb38ec7db1af06ee3c6b8dce2f4f7f53f126d62233c4910410384ead7f0a0edb6448cb389e62d1e3da5e927c3a980828f0b - name: buf.build/origadmin/runtime - commit: d2bec5453e2743999effe8adee2bb328 - digest: b5:0f9a10fc5423ace00df29150f43ff21a5fe701e67c2ba059633eedc393344042d99a6ce08345e0acc6185cdb1ab04284a35ea782f0995998de81c7c58e552996 + commit: 67cc18c9322e48e78a0282fb854970bb + digest: b5:8d14f8cf309734eddd71f02c03b7c2612542fe1935ecc3329c5d2c949dec14f098360cf610a9d03e35ccb764740f37090b5c228b04ff3be539861a4cd39ed617 diff --git a/internal/configs/bootstrap.pb.go b/internal/configs/bootstrap.pb.go index 844e85c6..f8331b01 100644 --- a/internal/configs/bootstrap.pb.go +++ b/internal/configs/bootstrap.pb.go @@ -8,11 +8,10 @@ package configs import ( _ "github.com/envoyproxy/protoc-gen-validate/validate" - v1 "github.com/origadmin/runtime/gen/go/config/v1" - v11 "github.com/origadmin/runtime/gen/go/middleware/v1" + v1 "github.com/origadmin/runtime/api/gen/go/config/v1" + v11 "github.com/origadmin/runtime/api/gen/go/middleware/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - services "origadmin/application/admin/internal/configs/services" reflect "reflect" sync "sync" unsafe "unsafe" @@ -85,50 +84,6 @@ func (x *EntrySelectorConfig) GetVersion() string { return "" } -type ServiceConfig struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ServiceConfig) Reset() { - *x = ServiceConfig{} - mi := &file_configs_bootstrap_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ServiceConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServiceConfig) ProtoMessage() {} - -func (x *ServiceConfig) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[1] - 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 ServiceConfig.ProtoReflect.Descriptor instead. -func (*ServiceConfig) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{1} -} - -func (x *ServiceConfig) GetName() string { - if x != nil { - return x.Name - } - return "" -} - type Bootstrap struct { state protoimpl.MessageState `protogen:"open.v1"` // name is the application name or service name for used @@ -141,20 +96,21 @@ type Bootstrap struct { Environment string `protobuf:"bytes,102,opt,name=environment,proto3" json:"environment,omitempty"` // 入口服务专属配置 Entry *Bootstrap_Entry `protobuf:"bytes,103,opt,name=entry,proto3" json:"entry,omitempty"` - Services []*services.Service `protobuf:"bytes,104,rep,name=services,proto3" json:"services,omitempty"` // 服务专用配置 Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` - Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` + Discovery *v1.Discovery `protobuf:"bytes,400,opt,name=discovery,proto3" json:"discovery,omitempty"` Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` Security *SecurityConfig `protobuf:"bytes,10,opt,name=security,proto3" json:"security,omitempty"` HealthCheck *Bootstrap_HealthCheck `protobuf:"bytes,1003,opt,name=health_check,proto3" json:"health_check,omitempty"` Logger *v1.Logger `protobuf:"bytes,1004,opt,name=logger,proto3" json:"logger,omitempty"` + Server *ServiceServer `protobuf:"bytes,1005,opt,name=server,proto3" json:"server,omitempty"` + Clients []*ServiceClient `protobuf:"bytes,1006,rep,name=clients,proto3" json:"clients,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Bootstrap) Reset() { *x = Bootstrap{} - mi := &file_configs_bootstrap_proto_msgTypes[2] + mi := &file_configs_bootstrap_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -166,7 +122,7 @@ func (x *Bootstrap) String() string { func (*Bootstrap) ProtoMessage() {} func (x *Bootstrap) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[2] + mi := &file_configs_bootstrap_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -179,7 +135,7 @@ func (x *Bootstrap) ProtoReflect() protoreflect.Message { // Deprecated: Use Bootstrap.ProtoReflect.Descriptor instead. func (*Bootstrap) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{2} + return file_configs_bootstrap_proto_rawDescGZIP(), []int{1} } func (x *Bootstrap) GetName() string { @@ -238,13 +194,6 @@ func (x *Bootstrap) GetEntry() *Bootstrap_Entry { return nil } -func (x *Bootstrap) GetServices() []*services.Service { - if x != nil { - return x.Services - } - return nil -} - func (x *Bootstrap) GetStorage() *v1.Storage { if x != nil { return x.Storage @@ -252,9 +201,9 @@ func (x *Bootstrap) GetStorage() *v1.Storage { return nil } -func (x *Bootstrap) GetRegistry() *v1.Registry { +func (x *Bootstrap) GetDiscovery() *v1.Discovery { if x != nil { - return x.Registry + return x.Discovery } return nil } @@ -287,6 +236,20 @@ func (x *Bootstrap) GetLogger() *v1.Logger { return nil } +func (x *Bootstrap) GetServer() *ServiceServer { + if x != nil { + return x.Server + } + return nil +} + +func (x *Bootstrap) GetClients() []*ServiceClient { + if x != nil { + return x.Clients + } + return nil +} + type Settings struct { state protoimpl.MessageState `protogen:"open.v1"` CryptoType string `protobuf:"bytes,1,opt,name=crypto_type,proto3" json:"crypto_type,omitempty"` @@ -296,7 +259,7 @@ type Settings struct { func (x *Settings) Reset() { *x = Settings{} - mi := &file_configs_bootstrap_proto_msgTypes[3] + mi := &file_configs_bootstrap_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -308,7 +271,7 @@ func (x *Settings) String() string { func (*Settings) ProtoMessage() {} func (x *Settings) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[3] + mi := &file_configs_bootstrap_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -321,7 +284,7 @@ func (x *Settings) ProtoReflect() protoreflect.Message { // Deprecated: Use Settings.ProtoReflect.Descriptor instead. func (*Settings) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{3} + return file_configs_bootstrap_proto_rawDescGZIP(), []int{2} } func (x *Settings) GetCryptoType() string { @@ -341,7 +304,7 @@ type Bootstrap_HealthCheck struct { func (x *Bootstrap_HealthCheck) Reset() { *x = Bootstrap_HealthCheck{} - mi := &file_configs_bootstrap_proto_msgTypes[4] + mi := &file_configs_bootstrap_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -353,7 +316,7 @@ func (x *Bootstrap_HealthCheck) String() string { func (*Bootstrap_HealthCheck) ProtoMessage() {} func (x *Bootstrap_HealthCheck) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[4] + mi := &file_configs_bootstrap_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -366,7 +329,7 @@ func (x *Bootstrap_HealthCheck) ProtoReflect() protoreflect.Message { // Deprecated: Use Bootstrap_HealthCheck.ProtoReflect.Descriptor instead. func (*Bootstrap_HealthCheck) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{2, 0} + return file_configs_bootstrap_proto_rawDescGZIP(), []int{1, 0} } func (x *Bootstrap_HealthCheck) GetTimeout() int32 { @@ -394,7 +357,7 @@ type Bootstrap_Entry struct { func (x *Bootstrap_Entry) Reset() { *x = Bootstrap_Entry{} - mi := &file_configs_bootstrap_proto_msgTypes[5] + mi := &file_configs_bootstrap_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -406,7 +369,7 @@ func (x *Bootstrap_Entry) String() string { func (*Bootstrap_Entry) ProtoMessage() {} func (x *Bootstrap_Entry) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[5] + mi := &file_configs_bootstrap_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -419,7 +382,7 @@ func (x *Bootstrap_Entry) ProtoReflect() protoreflect.Message { // Deprecated: Use Bootstrap_Entry.ProtoReflect.Descriptor instead. func (*Bootstrap_Entry) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{2, 1} + return file_configs_bootstrap_proto_rawDescGZIP(), []int{1, 1} } func (x *Bootstrap_Entry) GetScheme() string { @@ -440,13 +403,11 @@ var File_configs_bootstrap_proto protoreflect.FileDescriptor const file_configs_bootstrap_proto_rawDesc = "" + "\n" + - "\x17configs/bootstrap.proto\x12\vapi.configs\x1a\x16config/v1/logger.proto\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1dconfigs/security_config.proto\x1a\x1econfigs/services/service.proto\x1a\x1emiddleware/v1/middleware.proto\x1a\x17validate/validate.proto\"[\n" + + "\x17configs/bootstrap.proto\x12\vapi.configs\x1a\x19config/v1/discovery.proto\x1a\x16config/v1/logger.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1dconfigs/security_config.proto\x1a\x15configs/service.proto\x1a\x1emiddleware/v1/middleware.proto\x1a\x17validate/validate.proto\"[\n" + "\x13EntrySelectorConfig\x12\x16\n" + "\x06global\x18\x02 \x01(\bR\x06global\x12\x12\n" + "\x04name\x18\x03 \x01(\tR\x04name\x12\x18\n" + - "\aversion\x18\x04 \x01(\tR\aversion\",\n" + - "\rServiceConfig\x12\x1b\n" + - "\x04name\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x04name\"\xc7\x06\n" + + "\aversion\x18\x04 \x01(\tR\aversion\"\xfb\x06\n" + "\tBootstrap\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x02 \x01(\tR\aversion\x12 \n" + @@ -455,17 +416,18 @@ const file_configs_bootstrap_proto_rawDesc = "" + "\x15enable_dynamic_config\x18\a \x01(\bR\x15enable_dynamic_config\x12\x0e\n" + "\x02id\x18d \x01(\tR\x02id\x122\n" + "\venvironment\x18f \x01(\tB\x10\xfaB\rr\vR\x03devR\x04prodR\venvironment\x122\n" + - "\x05entry\x18g \x01(\v2\x1c.api.configs.Bootstrap.EntryR\x05entry\x129\n" + - "\bservices\x18h \x03(\v2\x1d.api.configs.services.ServiceR\bservices\x12-\n" + - "\astorage\x18\xac\x02 \x01(\v2\x12.config.v1.StorageR\astorage\x120\n" + - "\bregistry\x18\x90\x03 \x01(\v2\x13.config.v1.RegistryR\bregistry\x129\n" + + "\x05entry\x18g \x01(\v2\x1c.api.configs.Bootstrap.EntryR\x05entry\x12-\n" + + "\astorage\x18\xac\x02 \x01(\v2\x12.config.v1.StorageR\astorage\x123\n" + + "\tdiscovery\x18\x90\x03 \x01(\v2\x14.config.v1.DiscoveryR\tdiscovery\x129\n" + "\n" + "middleware\x18\t \x01(\v2\x19.middleware.v1.MiddlewareR\n" + "middleware\x127\n" + "\bsecurity\x18\n" + " \x01(\v2\x1b.api.configs.SecurityConfigR\bsecurity\x12G\n" + "\fhealth_check\x18\xeb\a \x01(\v2\".api.configs.Bootstrap.HealthCheckR\fhealth_check\x12*\n" + - "\x06logger\x18\xec\a \x01(\v2\x11.config.v1.LoggerR\x06logger\x1a;\n" + + "\x06logger\x18\xec\a \x01(\v2\x11.config.v1.LoggerR\x06logger\x123\n" + + "\x06server\x18\xed\a \x01(\v2\x1a.api.configs.ServiceServerR\x06server\x125\n" + + "\aclients\x18\xee\a \x03(\v2\x1a.api.configs.ServiceClientR\aclients\x1a;\n" + "\vHealthCheck\x12\x18\n" + "\atimeout\x18\x01 \x01(\x05R\atimeout\x12\x12\n" + "\x04path\x18\x02 \x01(\tR\x04path\x1aK\n" + @@ -487,37 +449,38 @@ func file_configs_bootstrap_proto_rawDescGZIP() []byte { return file_configs_bootstrap_proto_rawDescData } -var file_configs_bootstrap_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_configs_bootstrap_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_configs_bootstrap_proto_goTypes = []any{ (*EntrySelectorConfig)(nil), // 0: api.configs.EntrySelectorConfig - (*ServiceConfig)(nil), // 1: api.configs.ServiceConfig - (*Bootstrap)(nil), // 2: api.configs.Bootstrap - (*Settings)(nil), // 3: api.configs.Settings - (*Bootstrap_HealthCheck)(nil), // 4: api.configs.Bootstrap.HealthCheck - (*Bootstrap_Entry)(nil), // 5: api.configs.Bootstrap.Entry - (*services.Service)(nil), // 6: api.configs.services.Service - (*v1.Storage)(nil), // 7: config.v1.Storage - (*v1.Registry)(nil), // 8: config.v1.Registry - (*v11.Middleware)(nil), // 9: middleware.v1.Middleware - (*SecurityConfig)(nil), // 10: api.configs.SecurityConfig - (*v1.Logger)(nil), // 11: config.v1.Logger + (*Bootstrap)(nil), // 1: api.configs.Bootstrap + (*Settings)(nil), // 2: api.configs.Settings + (*Bootstrap_HealthCheck)(nil), // 3: api.configs.Bootstrap.HealthCheck + (*Bootstrap_Entry)(nil), // 4: api.configs.Bootstrap.Entry + (*v1.Storage)(nil), // 5: config.v1.Storage + (*v1.Discovery)(nil), // 6: config.v1.Discovery + (*v11.Middleware)(nil), // 7: middleware.v1.Middleware + (*SecurityConfig)(nil), // 8: api.configs.SecurityConfig + (*v1.Logger)(nil), // 9: config.v1.Logger + (*ServiceServer)(nil), // 10: api.configs.ServiceServer + (*ServiceClient)(nil), // 11: api.configs.ServiceClient (*v1.Service)(nil), // 12: config.v1.Service } var file_configs_bootstrap_proto_depIdxs = []int32{ - 5, // 0: api.configs.Bootstrap.entry:type_name -> api.configs.Bootstrap.Entry - 6, // 1: api.configs.Bootstrap.services:type_name -> api.configs.services.Service - 7, // 2: api.configs.Bootstrap.storage:type_name -> config.v1.Storage - 8, // 3: api.configs.Bootstrap.registry:type_name -> config.v1.Registry - 9, // 4: api.configs.Bootstrap.middleware:type_name -> middleware.v1.Middleware - 10, // 5: api.configs.Bootstrap.security:type_name -> api.configs.SecurityConfig - 4, // 6: api.configs.Bootstrap.health_check:type_name -> api.configs.Bootstrap.HealthCheck - 11, // 7: api.configs.Bootstrap.logger:type_name -> config.v1.Logger - 12, // 8: api.configs.Bootstrap.Entry.server:type_name -> config.v1.Service - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 4, // 0: api.configs.Bootstrap.entry:type_name -> api.configs.Bootstrap.Entry + 5, // 1: api.configs.Bootstrap.storage:type_name -> config.v1.Storage + 6, // 2: api.configs.Bootstrap.discovery:type_name -> config.v1.Discovery + 7, // 3: api.configs.Bootstrap.middleware:type_name -> middleware.v1.Middleware + 8, // 4: api.configs.Bootstrap.security:type_name -> api.configs.SecurityConfig + 3, // 5: api.configs.Bootstrap.health_check:type_name -> api.configs.Bootstrap.HealthCheck + 9, // 6: api.configs.Bootstrap.logger:type_name -> config.v1.Logger + 10, // 7: api.configs.Bootstrap.server:type_name -> api.configs.ServiceServer + 11, // 8: api.configs.Bootstrap.clients:type_name -> api.configs.ServiceClient + 12, // 9: api.configs.Bootstrap.Entry.server:type_name -> config.v1.Service + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_configs_bootstrap_proto_init() } @@ -526,13 +489,14 @@ func file_configs_bootstrap_proto_init() { return } file_configs_security_config_proto_init() + file_configs_service_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_bootstrap_proto_rawDesc), len(file_configs_bootstrap_proto_rawDesc)), NumEnums: 0, - NumMessages: 6, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/configs/bootstrap.pb.validate.go b/internal/configs/bootstrap.pb.validate.go index d2892f81..c55447ed 100644 --- a/internal/configs/bootstrap.pb.validate.go +++ b/internal/configs/bootstrap.pb.validate.go @@ -143,117 +143,6 @@ var _ interface { ErrorName() string } = EntrySelectorConfigValidationError{} -// Validate checks the field values on ServiceConfig 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 *ServiceConfig) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ServiceConfig 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 ServiceConfigMultiError, or -// nil if none found. -func (m *ServiceConfig) ValidateAll() error { - return m.validate(true) -} - -func (m *ServiceConfig) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetName()) < 1 { - err := ServiceConfigValidationError{ - field: "Name", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return ServiceConfigMultiError(errors) - } - - return nil -} - -// ServiceConfigMultiError is an error wrapping multiple validation errors -// returned by ServiceConfig.ValidateAll() if the designated constraints -// aren't met. -type ServiceConfigMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ServiceConfigMultiError) 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 ServiceConfigMultiError) AllErrors() []error { return m } - -// ServiceConfigValidationError is the validation error returned by -// ServiceConfig.Validate if the designated constraints aren't met. -type ServiceConfigValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ServiceConfigValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ServiceConfigValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ServiceConfigValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ServiceConfigValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ServiceConfigValidationError) ErrorName() string { return "ServiceConfigValidationError" } - -// Error satisfies the builtin error interface -func (e ServiceConfigValidationError) 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 %sServiceConfig.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ServiceConfigValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ServiceConfigValidationError{} - // Validate checks the field values on Bootstrap 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. @@ -337,40 +226,6 @@ func (m *Bootstrap) validate(all bool) error { } } - for idx, item := range m.GetServices() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - if all { switch v := interface{}(m.GetStorage()).(type) { case interface{ ValidateAll() error }: @@ -401,11 +256,11 @@ func (m *Bootstrap) validate(all bool) error { } if all { - switch v := interface{}(m.GetRegistry()).(type) { + switch v := interface{}(m.GetDiscovery()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, BootstrapValidationError{ - field: "Registry", + field: "Discovery", reason: "embedded message failed validation", cause: err, }) @@ -413,16 +268,16 @@ func (m *Bootstrap) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, BootstrapValidationError{ - field: "Registry", + field: "Discovery", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetRegistry()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetDiscovery()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapValidationError{ - field: "Registry", + field: "Discovery", reason: "embedded message failed validation", cause: err, } @@ -545,6 +400,69 @@ func (m *Bootstrap) validate(all bool) error { } } + if all { + switch v := interface{}(m.GetServer()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Server", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Server", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetServer()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "Server", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetClients() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: fmt.Sprintf("Clients[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: fmt.Sprintf("Clients[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: fmt.Sprintf("Clients[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + if len(errors) > 0 { return BootstrapMultiError(errors) } diff --git a/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto index 19533f55..56129eb6 100644 --- a/internal/configs/bootstrap.proto +++ b/internal/configs/bootstrap.proto @@ -2,12 +2,12 @@ syntax = "proto3"; package api.configs; +import "config/v1/discovery.proto"; import "config/v1/logger.proto"; -import "config/v1/registry.proto"; import "config/v1/service.proto"; import "config/v1/storage.proto"; import "configs/security_config.proto"; -import "configs/services/service.proto"; +import "configs/service.proto"; import "middleware/v1/middleware.proto"; import "validate/validate.proto"; // Updated import statement @@ -19,14 +19,14 @@ message EntrySelectorConfig { string version = 4 [json_name = "version"]; } -message ServiceConfig { - string name = 1 [ - json_name = "name", - (validate.rules).string.min_len = 1 - ]; - // Entry entry = 2 [json_name = "entry"]; // 各服务独立入口配置 - // repeated config.v1.Service services = 3 [json_name = "services"]; // 服务专用配置 -} +//message ServiceServer { +// string name = 1 [ +// json_name = "name", +// (validate.rules).string.min_len = 1 +// ]; +// // Entry entry = 2 [json_name = "entry"]; // 各服务独立入口配置 +// // repeated config.v1.Service services = 3 [json_name = "services"]; // 服务专用配置 +//} message Bootstrap { // name is the application name or service name for used @@ -69,15 +69,17 @@ message Bootstrap { // 入口服务专属配置 Entry entry = 103 [json_name = "entry"]; - repeated api.configs.services.Service services = 104 [json_name = "services"]; config.v1.Storage storage = 300 [json_name = "storage"]; - config.v1.Registry registry = 400 [json_name = "registry"]; + config.v1.Discovery discovery = 400 [json_name = "discovery"]; middleware.v1.Middleware middleware = 9 [json_name = "middleware"]; SecurityConfig security = 10 [json_name = "security"]; HealthCheck health_check = 1003 [json_name = "health_check"]; config.v1.Logger logger = 1004 [json_name = "logger"]; + + ServiceServer server = 1005 [json_name = "server"]; + repeated ServiceClient clients = 1006 [json_name = "clients"]; } message Settings { diff --git a/internal/configs/captcha.pb.go b/internal/configs/captcha.pb.go index 32899f5e..65e3d3ed 100644 --- a/internal/configs/captcha.pb.go +++ b/internal/configs/captcha.pb.go @@ -7,7 +7,7 @@ package configs import ( - v1 "github.com/origadmin/runtime/gen/go/config/v1" + v1 "github.com/origadmin/runtime/api/gen/go/config/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" diff --git a/internal/configs/security_config.pb.go b/internal/configs/security_config.pb.go index 41bb1c84..58378593 100644 --- a/internal/configs/security_config.pb.go +++ b/internal/configs/security_config.pb.go @@ -7,7 +7,7 @@ package configs import ( - v1 "github.com/origadmin/runtime/gen/go/config/v1" + v1 "github.com/origadmin/runtime/api/gen/go/config/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" diff --git a/internal/configs/server.pb.go b/internal/configs/server.pb.go index 77b4b86b..9df38a54 100644 --- a/internal/configs/server.pb.go +++ b/internal/configs/server.pb.go @@ -7,8 +7,8 @@ package configs import ( - v1 "github.com/origadmin/runtime/gen/go/config/v1" - v11 "github.com/origadmin/runtime/gen/go/middleware/v1" + v1 "github.com/origadmin/runtime/api/gen/go/config/v1" + v11 "github.com/origadmin/runtime/api/gen/go/middleware/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -29,7 +29,7 @@ type Server struct { Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` - Registry *v1.Registry `protobuf:"bytes,400,opt,name=registry,proto3" json:"registry,omitempty"` + Discovery *v1.Discovery `protobuf:"bytes,400,opt,name=discovery,proto3" json:"discovery,omitempty"` Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -93,9 +93,9 @@ func (x *Server) GetStorage() *v1.Storage { return nil } -func (x *Server) GetRegistry() *v1.Registry { +func (x *Server) GetDiscovery() *v1.Discovery { if x != nil { - return x.Registry + return x.Discovery } return nil } @@ -111,13 +111,13 @@ var File_configs_server_proto protoreflect.FileDescriptor const file_configs_server_proto_rawDesc = "" + "\n" + - "\x14configs/server.proto\x12\x15origadmin.api.configs\x1a\x17config/v1/storage.proto\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x1emiddleware/v1/middleware.proto\"\x81\x02\n" + + "\x14configs/server.proto\x12\x15origadmin.api.configs\x1a\x17config/v1/storage.proto\x1a\x19config/v1/discovery.proto\x1a\x17config/v1/service.proto\x1a\x1emiddleware/v1/middleware.proto\"\x84\x02\n" + "\x06Server\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x02 \x01(\tR\aversion\x12-\n" + "\aservice\x18\xc8\x01 \x01(\v2\x12.config.v1.ServiceR\aservice\x12-\n" + - "\astorage\x18\xac\x02 \x01(\v2\x12.config.v1.StorageR\astorage\x120\n" + - "\bregistry\x18\x90\x03 \x01(\v2\x13.config.v1.RegistryR\bregistry\x129\n" + + "\astorage\x18\xac\x02 \x01(\v2\x12.config.v1.StorageR\astorage\x123\n" + + "\tdiscovery\x18\x90\x03 \x01(\v2\x14.config.v1.DiscoveryR\tdiscovery\x129\n" + "\n" + "middleware\x18\t \x01(\v2\x19.middleware.v1.MiddlewareR\n" + "middlewareB.Z,origadmin/application/admin/internal/configsb\x06proto3" @@ -139,13 +139,13 @@ var file_configs_server_proto_goTypes = []any{ (*Server)(nil), // 0: origadmin.api.configs.Server (*v1.Service)(nil), // 1: config.v1.Service (*v1.Storage)(nil), // 2: config.v1.Storage - (*v1.Registry)(nil), // 3: config.v1.Registry + (*v1.Discovery)(nil), // 3: config.v1.Discovery (*v11.Middleware)(nil), // 4: middleware.v1.Middleware } var file_configs_server_proto_depIdxs = []int32{ 1, // 0: origadmin.api.configs.Server.service:type_name -> config.v1.Service 2, // 1: origadmin.api.configs.Server.storage:type_name -> config.v1.Storage - 3, // 2: origadmin.api.configs.Server.registry:type_name -> config.v1.Registry + 3, // 2: origadmin.api.configs.Server.discovery:type_name -> config.v1.Discovery 4, // 3: origadmin.api.configs.Server.middleware:type_name -> middleware.v1.Middleware 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type diff --git a/internal/configs/server.pb.validate.go b/internal/configs/server.pb.validate.go index 066561b4..414bf880 100644 --- a/internal/configs/server.pb.validate.go +++ b/internal/configs/server.pb.validate.go @@ -119,11 +119,11 @@ func (m *Server) validate(all bool) error { } if all { - switch v := interface{}(m.GetRegistry()).(type) { + switch v := interface{}(m.GetDiscovery()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ServerValidationError{ - field: "Registry", + field: "Discovery", reason: "embedded message failed validation", cause: err, }) @@ -131,16 +131,16 @@ func (m *Server) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ServerValidationError{ - field: "Registry", + field: "Discovery", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetRegistry()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetDiscovery()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ServerValidationError{ - field: "Registry", + field: "Discovery", reason: "embedded message failed validation", cause: err, } diff --git a/internal/configs/server.proto b/internal/configs/server.proto index 9cbf5af5..e42e9f96 100644 --- a/internal/configs/server.proto +++ b/internal/configs/server.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package origadmin.api.configs; import "config/v1/storage.proto"; -import "config/v1/registry.proto"; +import "config/v1/discovery.proto"; import "config/v1/service.proto"; import "middleware/v1/middleware.proto"; @@ -14,6 +14,6 @@ message Server { config.v1.Service service = 200 [json_name = "service"]; config.v1.Storage storage = 300 [json_name = "storage"]; - config.v1.Registry registry = 400 [json_name = "registry"]; + config.v1.Discovery discovery = 400 [json_name = "discovery"]; middleware.v1.Middleware middleware = 9 [json_name = "middleware"]; } diff --git a/internal/configs/service.pb.go b/internal/configs/service.pb.go new file mode 100644 index 00000000..e0124b37 --- /dev/null +++ b/internal/configs/service.pb.go @@ -0,0 +1,275 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.28.3 +// source: configs/service.proto + +package configs + +import ( + v1 "github.com/origadmin/runtime/api/gen/go/config/v1" + v11 "github.com/origadmin/runtime/api/gen/go/middleware/v1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ServiceCore struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` + Discovery *v1.Discovery `protobuf:"bytes,3,opt,name=discovery,proto3" json:"discovery,omitempty"` + Storages []*v1.Storage `protobuf:"bytes,4,rep,name=storages,proto3" json:"storages,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ServiceCore) Reset() { + *x = ServiceCore{} + mi := &file_configs_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServiceCore) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServiceCore) ProtoMessage() {} + +func (x *ServiceCore) ProtoReflect() protoreflect.Message { + mi := &file_configs_service_proto_msgTypes[0] + 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 ServiceCore.ProtoReflect.Descriptor instead. +func (*ServiceCore) Descriptor() ([]byte, []int) { + return file_configs_service_proto_rawDescGZIP(), []int{0} +} + +func (x *ServiceCore) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ServiceCore) GetVersion() string { + if x != nil { + return x.Version + } + return "" +} + +func (x *ServiceCore) GetDiscovery() *v1.Discovery { + if x != nil { + return x.Discovery + } + return nil +} + +func (x *ServiceCore) GetStorages() []*v1.Storage { + if x != nil { + return x.Storages + } + return nil +} + +type ServiceServer struct { + state protoimpl.MessageState `protogen:"open.v1"` + Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` + Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` + Middleware *v11.Middleware `protobuf:"bytes,300,opt,name=middleware,proto3" json:"middleware,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ServiceServer) Reset() { + *x = ServiceServer{} + mi := &file_configs_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServiceServer) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServiceServer) ProtoMessage() {} + +func (x *ServiceServer) ProtoReflect() protoreflect.Message { + mi := &file_configs_service_proto_msgTypes[1] + 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 ServiceServer.ProtoReflect.Descriptor instead. +func (*ServiceServer) Descriptor() ([]byte, []int) { + return file_configs_service_proto_rawDescGZIP(), []int{1} +} + +func (x *ServiceServer) GetCore() *ServiceCore { + if x != nil { + return x.Core + } + return nil +} + +func (x *ServiceServer) GetService() *v1.Service { + if x != nil { + return x.Service + } + return nil +} + +func (x *ServiceServer) GetMiddleware() *v11.Middleware { + if x != nil { + return x.Middleware + } + return nil +} + +type ServiceClient struct { + state protoimpl.MessageState `protogen:"open.v1"` + Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ServiceClient) Reset() { + *x = ServiceClient{} + mi := &file_configs_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServiceClient) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServiceClient) ProtoMessage() {} + +func (x *ServiceClient) ProtoReflect() protoreflect.Message { + mi := &file_configs_service_proto_msgTypes[2] + 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 ServiceClient.ProtoReflect.Descriptor instead. +func (*ServiceClient) Descriptor() ([]byte, []int) { + return file_configs_service_proto_rawDescGZIP(), []int{2} +} + +func (x *ServiceClient) GetCore() *ServiceCore { + if x != nil { + return x.Core + } + return nil +} + +var File_configs_service_proto protoreflect.FileDescriptor + +const file_configs_service_proto_rawDesc = "" + + "\n" + + "\x15configs/service.proto\x12\vapi.configs\x1a\x19config/v1/discovery.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1emiddleware/v1/middleware.proto\"\x9f\x01\n" + + "\vServiceCore\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + + "\aversion\x18\x02 \x01(\tR\aversion\x122\n" + + "\tdiscovery\x18\x03 \x01(\v2\x14.config.v1.DiscoveryR\tdiscovery\x12.\n" + + "\bstorages\x18\x04 \x03(\v2\x12.config.v1.StorageR\bstorages\"\xa8\x01\n" + + "\rServiceServer\x12,\n" + + "\x04core\x18\x01 \x01(\v2\x18.api.configs.ServiceCoreR\x04core\x12-\n" + + "\aservice\x18\xc8\x01 \x01(\v2\x12.config.v1.ServiceR\aservice\x12:\n" + + "\n" + + "middleware\x18\xac\x02 \x01(\v2\x19.middleware.v1.MiddlewareR\n" + + "middleware\"=\n" + + "\rServiceClient\x12,\n" + + "\x04core\x18\x01 \x01(\v2\x18.api.configs.ServiceCoreR\x04coreB.Z,origadmin/application/admin/internal/configsb\x06proto3" + +var ( + file_configs_service_proto_rawDescOnce sync.Once + file_configs_service_proto_rawDescData []byte +) + +func file_configs_service_proto_rawDescGZIP() []byte { + file_configs_service_proto_rawDescOnce.Do(func() { + file_configs_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_service_proto_rawDesc), len(file_configs_service_proto_rawDesc))) + }) + return file_configs_service_proto_rawDescData +} + +var file_configs_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_configs_service_proto_goTypes = []any{ + (*ServiceCore)(nil), // 0: api.configs.ServiceCore + (*ServiceServer)(nil), // 1: api.configs.ServiceServer + (*ServiceClient)(nil), // 2: api.configs.ServiceClient + (*v1.Discovery)(nil), // 3: config.v1.Discovery + (*v1.Storage)(nil), // 4: config.v1.Storage + (*v1.Service)(nil), // 5: config.v1.Service + (*v11.Middleware)(nil), // 6: middleware.v1.Middleware +} +var file_configs_service_proto_depIdxs = []int32{ + 3, // 0: api.configs.ServiceCore.discovery:type_name -> config.v1.Discovery + 4, // 1: api.configs.ServiceCore.storages:type_name -> config.v1.Storage + 0, // 2: api.configs.ServiceServer.core:type_name -> api.configs.ServiceCore + 5, // 3: api.configs.ServiceServer.service:type_name -> config.v1.Service + 6, // 4: api.configs.ServiceServer.middleware:type_name -> middleware.v1.Middleware + 0, // 5: api.configs.ServiceClient.core:type_name -> api.configs.ServiceCore + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name +} + +func init() { file_configs_service_proto_init() } +func file_configs_service_proto_init() { + if File_configs_service_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_service_proto_rawDesc), len(file_configs_service_proto_rawDesc)), + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_configs_service_proto_goTypes, + DependencyIndexes: file_configs_service_proto_depIdxs, + MessageInfos: file_configs_service_proto_msgTypes, + }.Build() + File_configs_service_proto = out.File + file_configs_service_proto_goTypes = nil + file_configs_service_proto_depIdxs = nil +} diff --git a/internal/configs/services/service.pb.validate.go b/internal/configs/service.pb.validate.go similarity index 57% rename from internal/configs/services/service.pb.validate.go rename to internal/configs/service.pb.validate.go index fabb91d3..bd1ebe78 100644 --- a/internal/configs/services/service.pb.validate.go +++ b/internal/configs/service.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: configs/services/service.proto +// source: configs/service.proto -package services +package configs import ( "bytes" @@ -62,11 +62,11 @@ func (m *ServiceCore) validate(all bool) error { // no validation rules for Version if all { - switch v := interface{}(m.GetRegistry()).(type) { + switch v := interface{}(m.GetDiscovery()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ServiceCoreValidationError{ - field: "Registry", + field: "Discovery", reason: "embedded message failed validation", cause: err, }) @@ -74,16 +74,16 @@ func (m *ServiceCore) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ServiceCoreValidationError{ - field: "Registry", + field: "Discovery", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetRegistry()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetDiscovery()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ServiceCoreValidationError{ - field: "Registry", + field: "Discovery", reason: "embedded message failed validation", cause: err, } @@ -201,21 +201,22 @@ var _ interface { ErrorName() string } = ServiceCoreValidationError{} -// Validate checks the field values on Service with the rules defined in the -// proto definition for this message. If any rules are violated, the first +// Validate checks the field values on ServiceServer 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 *Service) Validate() error { +func (m *ServiceServer) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on Service 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 ServiceMultiError, or nil if none found. -func (m *Service) ValidateAll() error { +// ValidateAll checks the field values on ServiceServer 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 ServiceServerMultiError, or +// nil if none found. +func (m *ServiceServer) ValidateAll() error { return m.validate(true) } -func (m *Service) validate(all bool) error { +func (m *ServiceServer) validate(all bool) error { if m == nil { return nil } @@ -226,7 +227,7 @@ func (m *Service) validate(all bool) error { switch v := interface{}(m.GetCore()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceValidationError{ + errors = append(errors, ServiceServerValidationError{ field: "Core", reason: "embedded message failed validation", cause: err, @@ -234,7 +235,7 @@ func (m *Service) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, ServiceValidationError{ + errors = append(errors, ServiceServerValidationError{ field: "Core", reason: "embedded message failed validation", cause: err, @@ -243,7 +244,7 @@ func (m *Service) validate(all bool) error { } } else if v, ok := interface{}(m.GetCore()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return ServiceValidationError{ + return ServiceServerValidationError{ field: "Core", reason: "embedded message failed validation", cause: err, @@ -255,7 +256,7 @@ func (m *Service) validate(all bool) error { switch v := interface{}(m.GetService()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceValidationError{ + errors = append(errors, ServiceServerValidationError{ field: "Service", reason: "embedded message failed validation", cause: err, @@ -263,7 +264,7 @@ func (m *Service) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, ServiceValidationError{ + errors = append(errors, ServiceServerValidationError{ field: "Service", reason: "embedded message failed validation", cause: err, @@ -272,7 +273,7 @@ func (m *Service) validate(all bool) error { } } else if v, ok := interface{}(m.GetService()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return ServiceValidationError{ + return ServiceServerValidationError{ field: "Service", reason: "embedded message failed validation", cause: err, @@ -284,7 +285,7 @@ func (m *Service) validate(all bool) error { switch v := interface{}(m.GetMiddleware()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceValidationError{ + errors = append(errors, ServiceServerValidationError{ field: "Middleware", reason: "embedded message failed validation", cause: err, @@ -292,7 +293,7 @@ func (m *Service) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, ServiceValidationError{ + errors = append(errors, ServiceServerValidationError{ field: "Middleware", reason: "embedded message failed validation", cause: err, @@ -301,7 +302,7 @@ func (m *Service) validate(all bool) error { } } else if v, ok := interface{}(m.GetMiddleware()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return ServiceValidationError{ + return ServiceServerValidationError{ field: "Middleware", reason: "embedded message failed validation", cause: err, @@ -310,18 +311,148 @@ func (m *Service) validate(all bool) error { } if len(errors) > 0 { - return ServiceMultiError(errors) + return ServiceServerMultiError(errors) + } + + return nil +} + +// ServiceServerMultiError is an error wrapping multiple validation errors +// returned by ServiceServer.ValidateAll() if the designated constraints +// aren't met. +type ServiceServerMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ServiceServerMultiError) 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 ServiceServerMultiError) AllErrors() []error { return m } + +// ServiceServerValidationError is the validation error returned by +// ServiceServer.Validate if the designated constraints aren't met. +type ServiceServerValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ServiceServerValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ServiceServerValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ServiceServerValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ServiceServerValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ServiceServerValidationError) ErrorName() string { return "ServiceServerValidationError" } + +// Error satisfies the builtin error interface +func (e ServiceServerValidationError) 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 %sServiceServer.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ServiceServerValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ServiceServerValidationError{} + +// Validate checks the field values on ServiceClient 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 *ServiceClient) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ServiceClient 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 ServiceClientMultiError, or +// nil if none found. +func (m *ServiceClient) ValidateAll() error { + return m.validate(true) +} + +func (m *ServiceClient) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetCore()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ServiceClientValidationError{ + field: "Core", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ServiceClientValidationError{ + field: "Core", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCore()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ServiceClientValidationError{ + field: "Core", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ServiceClientMultiError(errors) } return nil } -// ServiceMultiError is an error wrapping multiple validation errors returned -// by Service.ValidateAll() if the designated constraints aren't met. -type ServiceMultiError []error +// ServiceClientMultiError is an error wrapping multiple validation errors +// returned by ServiceClient.ValidateAll() if the designated constraints +// aren't met. +type ServiceClientMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m ServiceMultiError) Error() string { +func (m ServiceClientMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -330,11 +461,11 @@ func (m ServiceMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m ServiceMultiError) AllErrors() []error { return m } +func (m ServiceClientMultiError) AllErrors() []error { return m } -// ServiceValidationError is the validation error returned by Service.Validate -// if the designated constraints aren't met. -type ServiceValidationError struct { +// ServiceClientValidationError is the validation error returned by +// ServiceClient.Validate if the designated constraints aren't met. +type ServiceClientValidationError struct { field string reason string cause error @@ -342,22 +473,22 @@ type ServiceValidationError struct { } // Field function returns field value. -func (e ServiceValidationError) Field() string { return e.field } +func (e ServiceClientValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e ServiceValidationError) Reason() string { return e.reason } +func (e ServiceClientValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e ServiceValidationError) Cause() error { return e.cause } +func (e ServiceClientValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e ServiceValidationError) Key() bool { return e.key } +func (e ServiceClientValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e ServiceValidationError) ErrorName() string { return "ServiceValidationError" } +func (e ServiceClientValidationError) ErrorName() string { return "ServiceClientValidationError" } // Error satisfies the builtin error interface -func (e ServiceValidationError) Error() string { +func (e ServiceClientValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -369,14 +500,14 @@ func (e ServiceValidationError) Error() string { } return fmt.Sprintf( - "invalid %sService.%s: %s%s", + "invalid %sServiceClient.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = ServiceValidationError{} +var _ error = ServiceClientValidationError{} var _ interface { Field() string @@ -384,4 +515,4 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = ServiceValidationError{} +} = ServiceClientValidationError{} diff --git a/internal/configs/services/service.proto b/internal/configs/service.proto similarity index 71% rename from internal/configs/services/service.proto rename to internal/configs/service.proto index 57dde205..1a878c57 100644 --- a/internal/configs/services/service.proto +++ b/internal/configs/service.proto @@ -1,23 +1,27 @@ syntax = "proto3"; -package api.configs.services; +package api.configs; -import "config/v1/registry.proto"; +import "config/v1/discovery.proto"; import "config/v1/service.proto"; import "config/v1/storage.proto"; import "middleware/v1/middleware.proto"; -option go_package = "origadmin/application/admin/internal/configs/services"; +option go_package = "origadmin/application/admin/internal/configs"; message ServiceCore { string name = 1 [json_name = "name"]; string version = 2 [json_name = "version"]; - config.v1.Registry registry = 3 [json_name = "registry"]; + config.v1.Discovery discovery = 3 [json_name = "discovery"]; repeated config.v1.Storage storages = 4 [json_name = "storages"]; } -message Service { +message ServiceServer { ServiceCore core = 1 [json_name = "core"]; config.v1.Service service = 200 [json_name = "service"]; middleware.v1.Middleware middleware = 300 [json_name = "middleware"]; } + +message ServiceClient { + ServiceCore core = 1 [json_name = "core"]; +} \ No newline at end of file diff --git a/internal/configs/services/service.pb.go b/internal/configs/services/service.pb.go deleted file mode 100644 index 35c772a3..00000000 --- a/internal/configs/services/service.pb.go +++ /dev/null @@ -1,227 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc v5.28.3 -// source: configs/services/service.proto - -package services - -import ( - v1 "github.com/origadmin/runtime/gen/go/config/v1" - v11 "github.com/origadmin/runtime/gen/go/middleware/v1" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ServiceCore struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Registry *v1.Registry `protobuf:"bytes,3,opt,name=registry,proto3" json:"registry,omitempty"` - Storages []*v1.Storage `protobuf:"bytes,4,rep,name=storages,proto3" json:"storages,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ServiceCore) Reset() { - *x = ServiceCore{} - mi := &file_configs_services_service_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ServiceCore) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServiceCore) ProtoMessage() {} - -func (x *ServiceCore) ProtoReflect() protoreflect.Message { - mi := &file_configs_services_service_proto_msgTypes[0] - 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 ServiceCore.ProtoReflect.Descriptor instead. -func (*ServiceCore) Descriptor() ([]byte, []int) { - return file_configs_services_service_proto_rawDescGZIP(), []int{0} -} - -func (x *ServiceCore) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *ServiceCore) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *ServiceCore) GetRegistry() *v1.Registry { - if x != nil { - return x.Registry - } - return nil -} - -func (x *ServiceCore) GetStorages() []*v1.Storage { - if x != nil { - return x.Storages - } - return nil -} - -type Service struct { - state protoimpl.MessageState `protogen:"open.v1"` - Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` - Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` - Middleware *v11.Middleware `protobuf:"bytes,300,opt,name=middleware,proto3" json:"middleware,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Service) Reset() { - *x = Service{} - mi := &file_configs_services_service_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Service) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Service) ProtoMessage() {} - -func (x *Service) ProtoReflect() protoreflect.Message { - mi := &file_configs_services_service_proto_msgTypes[1] - 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 Service.ProtoReflect.Descriptor instead. -func (*Service) Descriptor() ([]byte, []int) { - return file_configs_services_service_proto_rawDescGZIP(), []int{1} -} - -func (x *Service) GetCore() *ServiceCore { - if x != nil { - return x.Core - } - return nil -} - -func (x *Service) GetService() *v1.Service { - if x != nil { - return x.Service - } - return nil -} - -func (x *Service) GetMiddleware() *v11.Middleware { - if x != nil { - return x.Middleware - } - return nil -} - -var File_configs_services_service_proto protoreflect.FileDescriptor - -const file_configs_services_service_proto_rawDesc = "" + - "\n" + - "\x1econfigs/services/service.proto\x12\x14api.configs.services\x1a\x18config/v1/registry.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1emiddleware/v1/middleware.proto\"\x9c\x01\n" + - "\vServiceCore\x12\x12\n" + - "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + - "\aversion\x18\x02 \x01(\tR\aversion\x12/\n" + - "\bregistry\x18\x03 \x01(\v2\x13.config.v1.RegistryR\bregistry\x12.\n" + - "\bstorages\x18\x04 \x03(\v2\x12.config.v1.StorageR\bstorages\"\xab\x01\n" + - "\aService\x125\n" + - "\x04core\x18\x01 \x01(\v2!.api.configs.services.ServiceCoreR\x04core\x12-\n" + - "\aservice\x18\xc8\x01 \x01(\v2\x12.config.v1.ServiceR\aservice\x12:\n" + - "\n" + - "middleware\x18\xac\x02 \x01(\v2\x19.middleware.v1.MiddlewareR\n" + - "middlewareB7Z5origadmin/application/admin/internal/configs/servicesb\x06proto3" - -var ( - file_configs_services_service_proto_rawDescOnce sync.Once - file_configs_services_service_proto_rawDescData []byte -) - -func file_configs_services_service_proto_rawDescGZIP() []byte { - file_configs_services_service_proto_rawDescOnce.Do(func() { - file_configs_services_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_services_service_proto_rawDesc), len(file_configs_services_service_proto_rawDesc))) - }) - return file_configs_services_service_proto_rawDescData -} - -var file_configs_services_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_configs_services_service_proto_goTypes = []any{ - (*ServiceCore)(nil), // 0: api.configs.services.ServiceCore - (*Service)(nil), // 1: api.configs.services.Service - (*v1.Registry)(nil), // 2: config.v1.Registry - (*v1.Storage)(nil), // 3: config.v1.Storage - (*v1.Service)(nil), // 4: config.v1.Service - (*v11.Middleware)(nil), // 5: middleware.v1.Middleware -} -var file_configs_services_service_proto_depIdxs = []int32{ - 2, // 0: api.configs.services.ServiceCore.registry:type_name -> config.v1.Registry - 3, // 1: api.configs.services.ServiceCore.storages:type_name -> config.v1.Storage - 0, // 2: api.configs.services.Service.core:type_name -> api.configs.services.ServiceCore - 4, // 3: api.configs.services.Service.service:type_name -> config.v1.Service - 5, // 4: api.configs.services.Service.middleware:type_name -> middleware.v1.Middleware - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name -} - -func init() { file_configs_services_service_proto_init() } -func file_configs_services_service_proto_init() { - if File_configs_services_service_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_services_service_proto_rawDesc), len(file_configs_services_service_proto_rawDesc)), - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_configs_services_service_proto_goTypes, - DependencyIndexes: file_configs_services_service_proto_depIdxs, - MessageInfos: file_configs_services_service_proto_msgTypes, - }.Build() - File_configs_services_service_proto = out.File - file_configs_services_service_proto_goTypes = nil - file_configs_services_service_proto_depIdxs = nil -} diff --git a/internal/generate.go b/internal/generate.go index 1c9c5b35..6487238b 100644 --- a/internal/generate.go +++ b/internal/generate.go @@ -13,5 +13,3 @@ package internal // uncomment this line to generate the client code to the same directory //go:generate protoc -I. -I../third_party --go_out=paths=source_relative:../internal ./configs/*.proto //go:generate protoc -I. -I../third_party --validate_out=paths=source_relative,lang=go:../internal ./configs/*.proto -//go:generate protoc -I. -I../third_party --go_out=paths=source_relative:../internal ./configs/services/*.proto -//go:generate protoc -I. -I../third_party --validate_out=paths=source_relative,lang=go:../internal ./configs/services/*.proto diff --git a/internal/loader/bootstrap.go b/internal/loader/bootstrap.go index ee213962..70e4f7c3 100644 --- a/internal/loader/bootstrap.go +++ b/internal/loader/bootstrap.go @@ -45,11 +45,9 @@ type ResolvedBootstrap struct { } func (r *ResolvedBootstrap) Resolve(config config.KConfig) (config.Resolved, error) { - var unknown map[string]any - if err := config.Scan(&unknown); err != nil { + if err := config.Scan(&r.bootstrap); err != nil { return nil, err } - log.NewHelper(log.DefaultLogger).Infof("bootstrap: %+v", unknown) return r, nil } @@ -78,8 +76,7 @@ func (r *ResolvedBootstrap) Middleware() *middlewarev1.Middleware { } func (r *ResolvedBootstrap) Service() *configv1.Service { - panic("unimplemented") - //return r.bootstrap.GetService() + return r.bootstrap.GetServices() } func (r *ResolvedBootstrap) Logger() *configv1.Logger { @@ -101,8 +98,6 @@ func Bootstrap(ctx context.Context, flags *bootstrap.Bootstrap, newApp NewApp) e "trace.id", tracing.TraceID(), "span.id", tracing.SpanID(), ) - help := log.NewHelper(r.Logger()) - help.Infof("bootstrap: %+v", &rb.bootstrap) app, clean, err := newApp(r, &rb.bootstrap) if err != nil { return err diff --git a/third_party/config/v1/cors.proto b/third_party/config/v1/cors.proto index e653decd..98ceca9b 100644 --- a/third_party/config/v1/cors.proto +++ b/third_party/config/v1/cors.proto @@ -2,13 +2,11 @@ syntax = "proto3"; package config.v1; -import "google/protobuf/duration.proto"; - option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "CorsProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; // Cors diff --git a/third_party/config/v1/customize.proto b/third_party/config/v1/customize.proto index 594f548f..38191d5a 100644 --- a/third_party/config/v1/customize.proto +++ b/third_party/config/v1/customize.proto @@ -5,10 +5,10 @@ package config.v1; import "google/protobuf/any.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "CustomizeProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; // Customize @@ -16,12 +16,16 @@ message Customize { message Config { // enabled is used to enable or disable the custom config bool enabled = 1 [json_name = "enabled"]; - // type can be any type but defined in runtime - string type = 2 [json_name = "type"]; + // name can be any named with registered names + string name = 2 [json_name = "name"]; // value can be any type google.protobuf.Any value = 3 [json_name = "value"]; } - // configs is a map of custom configs - map configs = 1 [json_name = "configs"]; + // configs is a map of custom configs with type string + repeated Config configs = 1 [json_name = "configs"]; +} + +message CustomizeMap { + map types = 1 [json_name = "types"]; } diff --git a/third_party/config/v1/registry.proto b/third_party/config/v1/discovery.proto similarity index 81% rename from third_party/config/v1/registry.proto rename to third_party/config/v1/discovery.proto index fdedf67a..73221b67 100644 --- a/third_party/config/v1/registry.proto +++ b/third_party/config/v1/discovery.proto @@ -2,19 +2,18 @@ syntax = "proto3"; package config.v1; -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; +import "config/v1/customize.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "RegistryProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; -// Registry -message Registry { +// Discovery +message Discovery { // Consul message Consul { string address = 1 [json_name = "address"]; @@ -33,9 +32,6 @@ message Registry { message ETCD { repeated string endpoints = 1 [json_name = "endpoints"]; } - message Custom { - google.protobuf.Any config = 1 [json_name = "config"]; - } string type = 1 [(validate.rules).string = { in: [ @@ -50,6 +46,7 @@ message Registry { }]; // Type string service_name = 2 [json_name = "service_name"]; // ServiceName bool debug = 5 [json_name = "debug"]; + config.v1.Customize customize = 6 [json_name = "customize"]; optional Consul consul = 300 [json_name = "consul"]; // Consul optional ETCD etcd = 400 [json_name = "etcd"]; // ETCD diff --git a/third_party/config/v1/gateway.proto b/third_party/config/v1/gateway.proto index 4412c6e8..f6f3847b 100644 --- a/third_party/config/v1/gateway.proto +++ b/third_party/config/v1/gateway.proto @@ -2,14 +2,11 @@ syntax = "proto3"; package config.v1; -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; - option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "GatewayProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; message Gateway { @@ -50,7 +47,7 @@ message Endpoint { message Middleware { string name = 1; - google.protobuf.Any options = 2; + bytes options = 2; bool required = 3; } @@ -67,16 +64,17 @@ message Backend { } enum Protocol { - UNSPECIFIED = 0; - HTTP = 1; - GRPC = 2; - CUSTOM = 3; + PROTOCOL_UNSPECIFIED = 0; + PROTOCOL_HTTP = 1; + PROTOCOL_GRPC = 2; + PROTOCOL_CUSTOM = 3; } message HealthCheck { enum CheckType { - HTTP = 0; - TCP = 1; + CHECK_TYPE_UNSPECIFIED = 0; + CHECK_TYPE_HTTP = 1; + CHECK_TYPE_TCP = 2; } CheckType type = 1; string endpoint = 2; @@ -92,7 +90,7 @@ message Retry { } message Condition { - message header { + message Header { string name = 1; string value = 2; } @@ -100,6 +98,6 @@ message Condition { // "500-599", "429" string by_status_code = 1; // {"name": "grpc-status", "value": "14"} - header by_header = 2; + Header by_header = 2; } } diff --git a/third_party/config/v1/logger.proto b/third_party/config/v1/logger.proto index 43f419e2..419c271d 100644 --- a/third_party/config/v1/logger.proto +++ b/third_party/config/v1/logger.proto @@ -3,10 +3,10 @@ syntax = "proto3"; package config.v1; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "LoggerProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; // Logger level @@ -18,9 +18,10 @@ enum LoggerLevel { LOGGER_LEVEL_ERROR = 4; LOGGER_LEVEL_FATAL = 5; } + // Logger hook message message LoggerHookMessage { - LoggerLevel level = 1 [json_name = "level"]; + string level = 1 [json_name = "level"]; string message = 2 [json_name = "message"]; string stacktrace = 3 [json_name = "stacktrace"]; string error = 4 [json_name = "error"]; @@ -35,9 +36,9 @@ message Logger { bool lumberjack = 2 [json_name = "lumberjack"]; bool compress = 3 [json_name = "compress"]; bool local_time = 4 [json_name = "local_time"]; - string max_size = 5 [json_name = "max_size"]; - string max_age = 6 [json_name = "max_age"]; - string max_backups = 7 [json_name = "max_backups"]; + int32 max_size = 5 [json_name = "max_size"]; + int32 max_age = 6 [json_name = "max_age"]; + int32 max_backups = 7 [json_name = "max_backups"]; } // Dev logger @@ -65,7 +66,7 @@ message Logger { // Logger format json text or tint string format = 5 [json_name = "format"]; // Logger level - LoggerLevel level = 6 [json_name = "level"]; + string level = 6 [json_name = "level"]; // Logger output stdout bool stdout = 7 [json_name = "stdout"]; // Disable logger caller @@ -79,4 +80,4 @@ message Logger { File file = 100 [json_name = "file"]; // Logger dev logger config DevLogger dev_logger = 101 [json_name = "dev_logger"]; //DevLogger -} \ No newline at end of file +} diff --git a/third_party/config/v1/mail.proto b/third_party/config/v1/mail.proto index 0980471e..42f87ed9 100644 --- a/third_party/config/v1/mail.proto +++ b/third_party/config/v1/mail.proto @@ -2,13 +2,11 @@ syntax = "proto3"; package config.v1; -import "google/protobuf/duration.proto"; - option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "MailProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; // Mail diff --git a/third_party/config/v1/message.proto b/third_party/config/v1/message.proto index 1270a981..cf79c3da 100644 --- a/third_party/config/v1/message.proto +++ b/third_party/config/v1/message.proto @@ -5,10 +5,10 @@ package config.v1; import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "MessageProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; // Message diff --git a/third_party/config/v1/security.proto b/third_party/config/v1/security.proto index b7d22e6e..fedbe9e6 100644 --- a/third_party/config/v1/security.proto +++ b/third_party/config/v1/security.proto @@ -2,14 +2,13 @@ syntax = "proto3"; package config.v1; -import "google/protobuf/duration.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "SecurityProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; // AuthNConfig contains the configuration for authentication middleware. diff --git a/third_party/config/v1/service.proto b/third_party/config/v1/service.proto index 568633ce..df623436 100644 --- a/third_party/config/v1/service.proto +++ b/third_party/config/v1/service.proto @@ -4,15 +4,16 @@ package config.v1; import "config/v1/message.proto"; import "config/v1/task.proto"; +import "config/v1/tlsconfig.proto"; import "config/v1/websocket.proto"; -import "google/protobuf/duration.proto"; import "middleware/v1/middleware.proto"; +import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "ServiceProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; message Service { @@ -21,8 +22,7 @@ message Service { string network = 1; string addr = 2; bool use_tls = 3 [json_name = "use_tls"]; - string cert_file = 4 [json_name = "cert_file"]; - string key_file = 5 [json_name = "key_file"]; + TLSConfig tls_config = 4 [json_name = "tls_config"]; int64 timeout = 6 [json_name = "timeout"]; int64 shutdown_timeout = 7 [json_name = "shutdown_timeout"]; int64 read_timeout = 8 [json_name = "read_timeout"]; @@ -36,8 +36,7 @@ message Service { string network = 1; string addr = 2; bool use_tls = 3 [json_name = "use_tls"]; - string cert_file = 4 [json_name = "cert_file"]; - string key_file = 5 [json_name = "key_file"]; + TLSConfig tls_config = 4 [json_name = "tls_config"]; int64 timeout = 6 [json_name = "timeout"]; int64 shutdown_timeout = 7 [json_name = "shutdown_timeout"]; int64 read_timeout = 8 [json_name = "read_timeout"]; @@ -53,7 +52,19 @@ message Service { } // Service name for service discovery string name = 1 [json_name = "name"]; - bool dynamic_endpoint = 2 [json_name = "dynamic_endpoint"]; + string type = 2 [ + json_name = "type", + (validate.rules).string = { + in: [ + "http", + "grpc", + "websocket", + "message", + "task" + ] + } + ]; + bool dynamic_endpoint = 3 [json_name = "dynamic_endpoint"]; GRPC grpc = 10 [json_name = "grpc"]; HTTP http = 20 [json_name = "http"]; diff --git a/third_party/config/v1/source.proto b/third_party/config/v1/source.proto index 4951dc57..363d8a11 100644 --- a/third_party/config/v1/source.proto +++ b/third_party/config/v1/source.proto @@ -2,13 +2,14 @@ syntax = "proto3"; package config.v1; +import "config/v1/customize.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "SourceConfigProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; // SourceConfig is the source file for load configuration @@ -17,6 +18,7 @@ message SourceConfig { message File { string path = 1 [json_name = "path"]; string format = 2 [json_name = "format"]; + repeated string ignores = 3 [json_name = "ignores"]; } // Consul message Consul { @@ -36,25 +38,33 @@ message SourceConfig { repeated string endpoints = 1 [json_name = "endpoints"]; } - string type = 1 [ - json_name = "type", - (validate.rules).string = { + message Nacos {} + message Apollo {} + + message Kubernetes {} + + message Polaris {} + + repeated string types = 1 [ + json_name = "types", + (validate.rules).repeated.items.string = { in: [ - "none", "file", + "apollo", "consul", "etcd", - "nacos", - "apollo", "kubernetes", - "polaris" + "nacos", + "polaris", + "customize" ] } ]; // Type // name string name = 2 [json_name = "name"]; + string version = 3 [json_name = "version"]; // set the supported file format, if not set, all formats are supported - repeated string formats = 3 [json_name = "formats"]; + repeated string formats = 4 [json_name = "formats"]; bool env = 5 [json_name = "env"]; // set the environment variable name map env_args = 6 [json_name = "env_args"]; @@ -64,4 +74,9 @@ message SourceConfig { optional File file = 100 [json_name = "file"]; optional Consul consul = 200 [json_name = "consul"]; optional ETCD etcd = 300 [json_name = "etcd"]; + optional Nacos nacos = 400 [json_name = "nacos"]; // Nacos + optional Apollo apollo = 500 [json_name = "apollo"]; // Apollo + optional Kubernetes kubernetes = 600 [json_name = "kubernetes"]; // Kubernetes + optional Polaris polaris = 700 [json_name = "polaris"]; // Polaris + optional config.v1.Customize customize = 800 [json_name = "customize"]; // Customize } diff --git a/third_party/config/v1/storage.proto b/third_party/config/v1/storage.proto index e56e8edf..bdd6169e 100644 --- a/third_party/config/v1/storage.proto +++ b/third_party/config/v1/storage.proto @@ -3,14 +3,13 @@ syntax = "proto3"; package config.v1; import "gnostic/openapi/v3/annotations.proto"; -import "google/protobuf/duration.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "StorageProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; message Migration { diff --git a/third_party/config/v1/task.proto b/third_party/config/v1/task.proto index 0af5424d..6e10229a 100644 --- a/third_party/config/v1/task.proto +++ b/third_party/config/v1/task.proto @@ -5,10 +5,10 @@ package config.v1; import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "TaskProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; // Task config diff --git a/third_party/config/v1/tlsconfig.proto b/third_party/config/v1/tlsconfig.proto index 4df794a8..3fdb32c1 100644 --- a/third_party/config/v1/tlsconfig.proto +++ b/third_party/config/v1/tlsconfig.proto @@ -3,10 +3,10 @@ syntax = "proto3"; package config.v1; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "TlsConfigProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; // TLSConfig diff --git a/third_party/config/v1/tracer.proto b/third_party/config/v1/tracer.proto index fe51a438..0fc6a3d7 100644 --- a/third_party/config/v1/tracer.proto +++ b/third_party/config/v1/tracer.proto @@ -3,10 +3,10 @@ syntax = "proto3"; package config.v1; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "TraceProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; // Trace config. diff --git a/third_party/config/v1/websocket.proto b/third_party/config/v1/websocket.proto index 0f559111..47a7eec6 100644 --- a/third_party/config/v1/websocket.proto +++ b/third_party/config/v1/websocket.proto @@ -2,13 +2,11 @@ syntax = "proto3"; package config.v1; -import "google/protobuf/duration.proto"; - option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/config/v1;configv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; option java_multiple_files = true; option java_outer_classname = "WebSocketProto"; -option java_package = "com.github.origadmin.runtime.config.v1"; +option java_package = "com.github.origadmin.api.runtime.config.v1"; option objc_class_prefix = "ORC"; message WebSocket { diff --git a/third_party/google/protobuf/descriptor.proto b/third_party/google/protobuf/descriptor.proto index f63ff196..0be20ea7 100644 --- a/third_party/google/protobuf/descriptor.proto +++ b/third_party/google/protobuf/descriptor.proto @@ -113,6 +113,10 @@ message FileDescriptorProto { // For Google-internal migration only. Do not use. repeated int32 weak_dependency = 11; + // Names of files imported by this file purely for the purpose of providing + // option extensions. These are excluded from the dependency list above. + repeated string option_dependency = 15; + // All top-level definitions in this file. repeated DescriptorProto message_type = 4; repeated EnumDescriptorProto enum_type = 5; @@ -176,6 +180,9 @@ message DescriptorProto { // Reserved field names, which may not be used by fields in the same message. // A given name may only be reserved once. repeated string reserved_name = 10; + + // Support for `export` and `local` keywords on enums. + optional SymbolVisibility visibility = 11; } message ExtensionRangeOptions { @@ -372,6 +379,9 @@ message EnumDescriptorProto { // Reserved enum value names, which may not be reused. A given name may only // be reserved once. repeated string reserved_name = 5; + + // Support for `export` and `local` keywords on enums. + optional SymbolVisibility visibility = 6; } // Describes a value within an enum. @@ -1121,6 +1131,37 @@ message FeatureSet { edition_defaults = { edition: EDITION_2024, value: "STYLE2024" } ]; + message VisibilityFeature { + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0; + + // Default pre-EDITION_2024, all UNSET visibility are export. + EXPORT_ALL = 1; + + // All top-level symbols default to export, nested default to local. + EXPORT_TOP_LEVEL = 2; + + // All symbols default to local. + LOCAL_ALL = 3; + + // All symbols local by default. Nested types cannot be exported. + // With special case caveat for message { enum {} reserved 1 to max; } + // This is the recommended setting for new protos. + STRICT = 4; + } + reserved 1 to max; + } + optional VisibilityFeature.DefaultSymbolVisibility default_symbol_visibility = + 8 [ + retention = RETENTION_SOURCE, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "EXPORT_ALL" }, + edition_defaults = { edition: EDITION_2024, value: "EXPORT_TOP_LEVEL" } + ]; + reserved 999; extensions 1000 to 9994 [ @@ -1363,3 +1404,14 @@ message GeneratedCodeInfo { optional Semantic semantic = 5; } } + +// Describes the 'visibility' of a symbol with respect to the proto import +// system. Symbols can only be imported when the visibility rules do not prevent +// it (ex: local symbols cannot be imported). Visibility modifiers can only set +// on `message` and `enum` as they are the only types available to be referenced +// from other files. +enum SymbolVisibility { + VISIBILITY_UNSET = 0; + VISIBILITY_LOCAL = 1; + VISIBILITY_EXPORT = 2; +} diff --git a/third_party/google/protobuf/java_features.proto b/third_party/google/protobuf/java_features.proto index 3f8ee1a2..4fc6dc41 100644 --- a/third_party/google/protobuf/java_features.proto +++ b/third_party/google/protobuf/java_features.proto @@ -40,8 +40,7 @@ message JavaFeatures { edition_defaults = { edition: EDITION_PROTO3, value: "false" } ]; - // The UTF8 validation strategy to use. See go/editions-utf8-validation for - // more information on this feature. + // The UTF8 validation strategy to use. enum Utf8Validation { // Invalid default, which should never be used. UTF8_VALIDATION_UNKNOWN = 0; @@ -68,6 +67,18 @@ message JavaFeatures { edition_defaults = { edition: EDITION_LEGACY, value: "DEFAULT" } ]; + // Allows creation of large Java enums, extending beyond the standard + // constant limits imposed by the Java language. + optional bool large_enum = 3 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "false" } + ]; + // Whether to use the old default outer class name scheme, or the new feature // which adds a "Proto" suffix to the outer class name. // @@ -84,4 +95,36 @@ message JavaFeatures { edition_defaults = { edition: EDITION_LEGACY, value: "true" }, edition_defaults = { edition: EDITION_2024, value: "false" } ]; + + message NestInFileClassFeature { + enum NestInFileClass { + // Invalid default, which should never be used. + NEST_IN_FILE_CLASS_UNKNOWN = 0; + // Do not nest the generated class in the file class. + NO = 1; + // Nest the generated class in the file class. + YES = 2; + // Fall back to the `java_multiple_files` option. Users won't be able to + // set this option. + LEGACY = 3 [feature_support = { + edition_introduced: EDITION_2024 + edition_removed: EDITION_2024 + }]; + } + reserved 1 to max; + } + + // Whether to nest the generated class in the generated file class. This is + // only applicable to *top-level* messages, enums, and services. + optional NestInFileClassFeature.NestInFileClass nest_in_file_class = 5 [ + retention = RETENTION_SOURCE, + targets = TARGET_TYPE_MESSAGE, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_SERVICE, + feature_support = { + edition_introduced: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY" }, + edition_defaults = { edition: EDITION_2024, value: "NO" } + ]; } diff --git a/third_party/middleware/v1/circuitbreaker/circuitbreaker.proto b/third_party/middleware/v1/circuitbreaker/circuitbreaker.proto new file mode 100644 index 00000000..35420eaa --- /dev/null +++ b/third_party/middleware/v1/circuitbreaker/circuitbreaker.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package middleware.v1.circuitbreaker; + +import "config/v1/gateway.proto"; + +option cc_enable_arenas = true; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/circuitbreaker;circuitbreakerv1"; +option java_multiple_files = true; +option java_outer_classname = "CircuitBreakerProto"; +option java_package = "com.github.origadmin.api.runtime.middleware.v1.circuitbreaker"; +option objc_class_prefix = "OMC"; +option php_namespace = "OrigAdmin\\Runtime\\Middleware\\CircuitBreaker\\V1"; + +// CircuitBreaker middleware config. +message CircuitBreaker { + oneof trigger { + SuccessRatio success_ratio = 1; + int64 ratio = 2; + } + oneof action { + ResponseData response_data = 3; + BackupService backup_service = 4; + } + repeated config.v1.Condition assert_condtions = 5; +} + +message Header { + string key = 1; + repeated string value = 2; +} + +message ResponseData { + int32 status_code = 1; + repeated Header header = 2; + bytes body = 3; +} + +message BackupService { + config.v1.Endpoint endpoint = 1; +} + +message SuccessRatio { + double success = 1; + int32 request = 2; + int32 bucket = 3; + int64 window = 4; +} diff --git a/third_party/middleware/v1/jwt/jwt.proto b/third_party/middleware/v1/jwt/jwt.proto new file mode 100644 index 00000000..1888bfb0 --- /dev/null +++ b/third_party/middleware/v1/jwt/jwt.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +package middleware.v1.jwt; + +import "gnostic/openapi/v3/annotations.proto"; +import "security/jwt/v1/config.proto"; +import "validate/validate.proto"; + +option cc_enable_arenas = true; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/jwt;jwtv1"; +option java_multiple_files = true; +option java_outer_classname = "JWTProto"; +option java_package = "com.github.origadmin.api.runtime.middleware.v1.jwt"; +option objc_class_prefix = "OMM"; +option php_namespace = "OrigAdmin\\Runtime\\Middleware\\JWT\\V1"; + +// JSON Web Token +message JWT { + bool enabled = 1 [json_name = 'enabled']; + string subject = 2 [json_name = 'subject']; + string claim_type = 3 [ + json_name = 'claim_type', + (validate.rules).string = { + in: [ + "map", + "registered" + ] + }, + (gnostic.openapi.v3.property) = {description: "The type of the claim used to extract the token."} + ]; + map token_header = 4 [json_name = 'token_header']; + // The token used security.jwt.v1. + security.jwt.v1.Config config = 100 [ + json_name = "config", + (gnostic.openapi.v3.property) = {description: "The configuration used to create the token."} + ]; +} diff --git a/third_party/middleware/v1/metrics/metrics.proto b/third_party/middleware/v1/metrics/metrics.proto new file mode 100644 index 00000000..22eb54ed --- /dev/null +++ b/third_party/middleware/v1/metrics/metrics.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; + +package middleware.v1.metrics; + +option cc_enable_arenas = true; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/metrics;metricsv1"; +option java_multiple_files = true; +option java_outer_classname = "CircuitBreakerProto"; +option java_package = "com.github.origadmin.api.runtime.middleware.v1.metrics"; +option objc_class_prefix = "OMM"; +option php_namespace = "OrigAdmin\\Runtime\\Middleware\\Metric\\V1"; + +message UserMetric { + // Timestamp: indicates the time of indicator data + int64 timestamp = 1; + // Indicator name + string name = 2; + // Indicator value + double value = 3; + // Indicator label for classification or filtering + map labels = 4; + // Indicator unit + string unit = 5; + // Type of indicator (e.g. counter, timer, histogram, etc.) + enum MetricType { + METRIC_TYPE_UNSPECIFIED = 0; + METRIC_TYPE_COUNTER = 1; + METRIC_TYPE_GAUGE = 2; + METRIC_TYPE_HISTOGRAM = 3; + METRIC_TYPE_SUMMARY = 4; + } + MetricType type = 6; + // Description of indicators + string description = 7; + // Indicator context information + string context = 8; + // Additional information for metrics that can be used to store arbitrary metadata + map metadata = 9; +} + +// Metrics +message Metrics { + bool enabled = 1 [json_name = "enabled"]; + // System-generated timestamp for the metrics report + // int64 report_timestamp = 1 [json_name = "report_timestamp"]; + // System-generated unique identifier for the metrics report + // string report_id = 2 [json_name = "report_id"]; + // System-generated status code indicating the success or failure of the metrics collection + // int32 status_code = 3 [json_name = "status_code"]; + // System-generated message providing additional context about the metrics collection + // string status_message = 4 [json_name = "status_message"]; + + // Add a list of supported metrics for enabling or disabling specific metrics + repeated string supported_metrics = 5 [json_name = "supported_metrics"]; + // Repeated field for user-defined metrics + repeated UserMetric user_metrics = 6 [json_name = "user_metrics"]; +} diff --git a/third_party/middleware/v1/middleware.proto b/third_party/middleware/v1/middleware.proto index 19a4001b..1833607f 100644 --- a/third_party/middleware/v1/middleware.proto +++ b/third_party/middleware/v1/middleware.proto @@ -2,20 +2,17 @@ syntax = "proto3"; package middleware.v1; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "middleware/jwt/v1/jwt.proto"; -import "middleware/metrics/v1/metrics.proto"; -import "middleware/ratelimit/v1/ratelimiter.proto"; -import "middleware/selector/v1/selector.proto"; -import "middleware/validator/v1/validator.proto"; -import "validate/validate.proto"; +import "middleware/v1/jwt/jwt.proto"; +import "middleware/v1/metrics/metrics.proto"; +import "middleware/v1/ratelimit/ratelimiter.proto"; +import "middleware/v1/selector/selector.proto"; +import "middleware/v1/validator/validator.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/middleware/v1;middlewarev1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1;middlewarev1"; option java_multiple_files = true; option java_outer_classname = "MiddlewareProto"; -option java_package = "com.github.origadmin.runtime.middleware.v1"; +option java_package = "com.github.origadmin.api.runtime.middleware.v1"; option objc_class_prefix = "OMX"; option php_namespace = "OrigAdmin\\Runtime\\Middleware\\V1"; @@ -57,6 +54,21 @@ option php_namespace = "OrigAdmin\\Runtime\\Middleware\\V1"; // } // }; +enum MiddlewareName { + MIDDLEWARE_NAME_UNSPECIFIED = 0; + MIDDLEWARE_NAME_LOGGING = 1; + MIDDLEWARE_NAME_RECOVERY = 2; + MIDDLEWARE_NAME_TRACING = 3; + MIDDLEWARE_NAME_CIRCUIT_BREAKER = 4; + MIDDLEWARE_NAME_METADATA = 5; + MIDDLEWARE_NAME_JWT = 6; + MIDDLEWARE_NAME_RATE_LIMITER = 7; + MIDDLEWARE_NAME_METRICS = 8; + MIDDLEWARE_NAME_VALIDATOR = 9; + MIDDLEWARE_NAME_SELECTOR = 10; + MIDDLEWARE_NAME_CUSTOMIZE = 11; +} + // Middleware middleware is used to middlewareure middleware for entry message Middleware { // Metadata @@ -68,23 +80,12 @@ message Middleware { map data = 3 [json_name = "data"]; } - // Logging switch - bool logging = 1 [json_name = "logging"]; - // Recovery switch - bool recovery = 2 [json_name = "recovery"]; - // // tracing switch - bool tracing = 3 [json_name = "tracing"]; - // Circuit breaker switch - bool circuit_breaker = 4 [json_name = "circuit_breaker"]; - // // Metadata switch - // bool enable_metadata = 6 [json_name = "enable_metadata"]; - // // JWT switch - // bool enable_jwt = 7 [json_name = "jwt"]; + repeated string enabled_middlewares = 1 [json_name = "enabled_middlewares"]; Metadata metadata = 100 [json_name = "metadata"]; - middleware.ratelimit.v1.RateLimiter rate_limiter = 101 [json_name = "rate_limiter"]; - middleware.metrics.v1.Metrics metrics = 102 [json_name = "metrics"]; - middleware.validator.v1.Validator validator = 103 [json_name = "validator"]; - middleware.jwt.v1.JWT jwt = 104 [json_name = "jwt"]; - middleware.selector.v1.Selector selector = 105 [json_name = "selector"]; + middleware.v1.ratelimit.RateLimiter rate_limiter = 101 [json_name = "rate_limiter"]; + middleware.v1.metrics.Metrics metrics = 102 [json_name = "metrics"]; + middleware.v1.validator.Validator validator = 103 [json_name = "validator"]; + middleware.v1.jwt.JWT jwt = 104 [json_name = "jwt"]; + middleware.v1.selector.Selector selector = 105 [json_name = "selector"]; } diff --git a/third_party/middleware/v1/ratelimit/ratelimiter.proto b/third_party/middleware/v1/ratelimit/ratelimiter.proto new file mode 100644 index 00000000..5438502e --- /dev/null +++ b/third_party/middleware/v1/ratelimit/ratelimiter.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; + +package middleware.v1.ratelimit; + +import "validate/validate.proto"; + +option cc_enable_arenas = true; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/ratelimit;ratelimitv1"; +option java_multiple_files = true; +option java_outer_classname = "RateLimitProto"; +option java_package = "com.github.origadmin.api.runtime.middleware.v1.ratelimit"; +option objc_class_prefix = "OMM"; +option php_namespace = "OrigAdmin\\Runtime\\Middleware\\RateLimit\\V1"; + +// Rate limiter +message RateLimiter { + message Redis { + string addr = 1 [json_name = "addr"]; + string username = 2 [json_name = "username"]; + string password = 3 [json_name = "password"]; + int32 db = 4 [json_name = "db"]; + } + message Memory { + int64 expiration = 1 [json_name = "expiration"]; + int64 cleanup_interval = 2 [json_name = "cleanup_interval"]; + } + bool enabled = 1 [json_name = "enabled"]; + // rate limiter name, supported: bbr, memory, redis. + string name = 2 [ + json_name = "name", + (validate.rules).string = { + in: [ + "bbr", + "memory", + "redis" + ] + } + ]; + // The number of seconds in a rate limit window + int32 period = 3 [json_name = "period"]; + + // The number of requests allowed in a window of time + int32 x_ratelimit_limit = 5 [json_name = "x_ratelimit_limit"]; + // The number of requests that can still be made in the current window of time + int32 x_ratelimit_remaining = 6 [json_name = "x_ratelimit_remaining"]; + // The number of seconds until the current rate limit window completely resets + int32 x_ratelimit_reset = 7 [json_name = "x_ratelimit_reset"]; + // When rate limited, the number of seconds to wait before another request will be accepted + int32 retry_after = 8 [json_name = "retry_after"]; + + Memory memory = 101 [json_name = "memory"]; + Redis redis = 102 [json_name = "redis"]; +} diff --git a/third_party/middleware/v1/selector/selector.proto b/third_party/middleware/v1/selector/selector.proto new file mode 100644 index 00000000..7865e293 --- /dev/null +++ b/third_party/middleware/v1/selector/selector.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package middleware.v1.selector; + +option cc_enable_arenas = true; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/selector;selectorv1"; +option java_multiple_files = true; +option java_outer_classname = "SelectorProto"; +option java_package = "com.github.origadmin.api.runtime.middleware.v1.selector"; +option objc_class_prefix = "OMM"; +option php_namespace = "OrigAdmin\\Runtime\\Middleware\\Selector\\V1"; + +// Selector +message Selector { + bool enabled = 1 [json_name = "enabled"]; + repeated string names = 2 [json_name = "names"]; + repeated string paths = 3 [json_name = "paths"]; + string regex = 4 [json_name = "regex"]; + repeated string prefixes = 5 [json_name = "prefixes"]; +} diff --git a/third_party/middleware/v1/validator/validator.proto b/third_party/middleware/v1/validator/validator.proto new file mode 100644 index 00000000..6dd79aa5 --- /dev/null +++ b/third_party/middleware/v1/validator/validator.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package middleware.v1.validator; + +import "validate/validate.proto"; + +option cc_enable_arenas = true; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/validator;validatorv1"; +option java_multiple_files = true; +option java_outer_classname = "ValidatorProto"; +option java_package = "com.github.origadmin.api.runtime.middleware.v1.validator"; +option objc_class_prefix = "OMV"; +option php_namespace = "OrigAdmin\\Runtime\\Middleware\\Validator\\V1"; + +message Validator { + bool enabled = 1 [json_name = "enabled"]; + int32 version = 2 [ + json_name = "version", + (validate.rules).int32 = { + gt: 0 + lt: 3 + } + ]; + bool fail_fast = 3 [json_name = "fail_fast"]; +} diff --git a/third_party/pagination/v1/pagination.proto b/third_party/pagination/v1/pagination.proto index 3a21db01..9bbd9cfa 100644 --- a/third_party/pagination/v1/pagination.proto +++ b/third_party/pagination/v1/pagination.proto @@ -7,10 +7,10 @@ import "google/protobuf/any.proto"; import "google/protobuf/field_mask.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/pagination/v1;paginationv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/pagination/v1;paginationv1"; option java_multiple_files = true; option java_outer_classname = "PaginationProto"; -option java_package = "com.github.origadmin.runtime.pagination.v1"; +option java_package = "com.github.origadmin.api.runtime.pagination.v1"; option objc_class_prefix = "ORP"; option php_namespace = "OrigAdmin\\Runtime\\Pagination\\V1"; @@ -56,8 +56,8 @@ message PageRequest { } ]; // Field mask - google.protobuf.FieldMask update_mask = 7 [ - json_name = "update_mask", + google.protobuf.FieldMask field_mask = 7 [ + json_name = "field_mask", (gnostic.openapi.v3.property) = { description: "It is used to Update the request message, which is used to perform a partial update to the resource. This mask is related to the resource, not the request message." example: {yaml: "id,name,age"} diff --git a/third_party/security/casbin/v1/policy.proto b/third_party/security/casbin/v1/policy.proto index 818f3c02..9c21d12b 100644 --- a/third_party/security/casbin/v1/policy.proto +++ b/third_party/security/casbin/v1/policy.proto @@ -7,10 +7,10 @@ import "validate/validate.proto"; option cc_enable_arenas = true; option csharp_namespace = "OrigAdmin.Runtime.Security.Casbin.V1"; -option go_package = "github.com/origadmin/runtime/gen/go/security/casbin/v1;casbinv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/security/casbin/v1;casbinv1"; option java_multiple_files = true; option java_outer_classname = "CasbinProto"; -option java_package = "com.github.origadmin.runtime.security.casbin.v1"; +option java_package = "com.github.origadmin.api.runtime.security.casbin.v1"; option objc_class_prefix = "ORSC"; option php_namespace = "OrigAdmin\\Runtime\\Security\\Casbin\\V1"; diff --git a/third_party/security/jwt/v1/config.proto b/third_party/security/jwt/v1/config.proto index e399d042..768a363d 100644 --- a/third_party/security/jwt/v1/config.proto +++ b/third_party/security/jwt/v1/config.proto @@ -3,16 +3,14 @@ syntax = "proto3"; package security.jwt.v1; import "gnostic/openapi/v3/annotations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; option csharp_namespace = "OrigAdmin.Runtime.Security.JWT.V1"; -option go_package = "github.com/origadmin/runtime/gen/go/security/jwt/v1;jwtv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/security/jwt/v1;jwtv1"; option java_multiple_files = true; option java_outer_classname = "JWTProto"; -option java_package = "com.github.origadmin.runtime.security.jwt.v1"; +option java_package = "com.github.origadmin.api.runtime.security.jwt.v1"; option objc_class_prefix = "ORST"; option php_namespace = "OrigAdmin\\Runtime\\Security\\JWT\\V1"; @@ -20,10 +18,19 @@ option php_namespace = "OrigAdmin\\Runtime\\Security\\JWT\\V1"; message Config { string signing_method = 1 [ json_name = "signing_method", + (validate.rules).string = { + min_len: 1 + max_len: 1024 + pattern: "^[A-Z0-9]+$" + }, (gnostic.openapi.v3.property) = {description: "The signing method used for the token (e.g., HS256, RS256)."} ]; string key = 2 [ json_name = "key", + (validate.rules).string = { + min_len: 1 + max_len: 1024 + }, (gnostic.openapi.v3.property) = {description: "The key used for signing the token."} ]; string key2 = 3 [ @@ -32,10 +39,18 @@ message Config { ]; int64 access_token_lifetime = 5 [ json_name = "access_token_lifetime", + (validate.rules).int64 = { + gte: 1 + lte: 31536000 + }, (gnostic.openapi.v3.property) = {description: "The lifetime of the token."} ]; int64 refresh_token_lifetime = 6 [ json_name = "refresh_token_lifetime", + (validate.rules).int64 = { + gte: 1 + lte: 31536000 + }, (gnostic.openapi.v3.property) = {description: "The lifetime of the refresh token."} ]; string issuer = 7 [ @@ -44,10 +59,19 @@ message Config { ]; repeated string audience = 8 [ json_name = "audience", + (validate.rules).repeated = { + min_items: 1 + max_items: 1024, + unique: true, + }, (gnostic.openapi.v3.property) = {description: "The audience for which the token is intended."} ]; // Audience string token_type = 9 [ json_name = "token_type", + (validate.rules).string = { + min_len: 1 + max_len: 1024 + }, (gnostic.openapi.v3.property) = {description: "The type of the token (e.g., Bearer)."} ]; } diff --git a/third_party/security/jwt/v1/token.proto b/third_party/security/jwt/v1/token.proto index 0da764ed..064c07f4 100644 --- a/third_party/security/jwt/v1/token.proto +++ b/third_party/security/jwt/v1/token.proto @@ -3,16 +3,14 @@ syntax = "proto3"; package security.jwt.v1; import "gnostic/openapi/v3/annotations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; option csharp_namespace = "OrigAdmin.Runtime.Security.JWT.V1"; -option go_package = "github.com/origadmin/runtime/gen/go/security/jwt/v1;jwtv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/security/jwt/v1;jwtv1"; option java_multiple_files = true; option java_outer_classname = "JWTProto"; -option java_package = "com.github.origadmin.runtime.security.jwt.v1"; +option java_package = "com.github.origadmin.api.runtime.security.jwt.v1"; option objc_class_prefix = "ORST"; option php_namespace = "OrigAdmin\\Runtime\\Security\\JWT\\V1"; diff --git a/third_party/security/v1/auth.proto b/third_party/security/v1/auth.proto index c7934c1a..0665732a 100644 --- a/third_party/security/v1/auth.proto +++ b/third_party/security/v1/auth.proto @@ -3,18 +3,16 @@ syntax = "proto3"; package security.v1; import "gnostic/openapi/v3/annotations.proto"; -import "google/protobuf/any.proto"; -import "google/protobuf/timestamp.proto"; import "security/casbin/v1/policy.proto"; import "security/jwt/v1/token.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; option csharp_namespace = "OrigAdmin.Runtime.Security.V1"; -option go_package = "github.com/origadmin/runtime/gen/go/security/v1;securityv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/security/v1;securityv1"; option java_multiple_files = true; option java_outer_classname = "SecurityProto"; -option java_package = "com.github.origadmin.runtime.security.v1"; +option java_package = "com.github.origadmin.api.runtime.security.v1"; option objc_class_prefix = "ORS"; option php_namespace = "OrigAdmin\\Runtime\\Security\\V1"; @@ -181,7 +179,7 @@ message AuthN { json_name = "jwt", (gnostic.openapi.v3.property) = {description: "The JWT authentication details."} ]; - optional google.protobuf.Any additional = 16 [ + optional bytes additional = 16 [ json_name = "additional", (gnostic.openapi.v3.property) = {description: "Additional properties for the authentication."} ]; diff --git a/third_party/security/v1/error.proto b/third_party/security/v1/error.proto index 47158100..be6e1934 100644 --- a/third_party/security/v1/error.proto +++ b/third_party/security/v1/error.proto @@ -6,10 +6,10 @@ import "errors/errors.proto"; option cc_enable_arenas = true; option csharp_namespace = "OrigAdmin.Runtime.Security.V1"; -option go_package = "github.com/origadmin/runtime/gen/go/security/v1;securityv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/security/v1;securityv1"; option java_multiple_files = true; option java_outer_classname = "SecurityProto"; -option java_package = "com.github.origadmin.runtime.security.v1"; +option java_package = "com.github.origadmin.api.runtime.security.v1"; option objc_class_prefix = "ORS"; option php_namespace = "OrigAdmin\\Runtime\\Security\\V1"; From afaaf4e542332787c3d2206933097be00c7c622f Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 29 May 2025 14:42:16 +0800 Subject: [PATCH 026/158] refactor(configs): restructure service configuration and rename registry to discovery - Restructure ServiceServer to contain multiple services - Rename Registry to Discovery in configuration - Update related files to reflect these changes --- api/v1/services/system/login.pb.go | 2 +- cmd/system/main.go | 13 +- cmd/system/wire.go | 3 +- cmd/system/wire_gen.go | 23 +- contrib/consul/config/config.go | 2 +- contrib/consul/registry/registry.go | 20 +- contrib/database/database.go | 4 +- contrib/security/authn/jwt/authn_test.go | 4 +- contrib/security/authn/jwt/claims.go | 2 +- contrib/security/authn/jwt/jwt.go | 4 +- contrib/security/authz/casbin/casbin.go | 2 +- helpers/resp/result.go | 4 +- internal/configs/service.pb.go | 14 +- internal/configs/service.pb.validate.go | 47 ++- internal/configs/service.proto | 2 +- internal/data/data.go | 11 +- internal/loader/bootstrap.go | 26 +- internal/loader/bootstrap_default.go | 37 +- internal/loader/config.go | 2 +- internal/loader/config_test.go | 2 +- internal/loader/file.go | 4 +- internal/loader/load.go | 2 +- internal/loader/registry.go | 4 +- internal/loader/service_test.go | 385 +++++++++--------- internal/mods/agent/agent.go | 2 +- internal/mods/agent/auth_test.go | 2 +- internal/mods/auth/dal/login.dal.go | 4 +- .../{system => auth}/service/auth.agent.go | 0 .../{system => auth}/service/auth.grpc.go | 0 .../{system => auth}/service/auth.http.go | 0 .../{system => auth}/service/casbin.grpc.go | 0 .../{system => auth}/service/casbin.http.go | 0 .../{system => auth}/service/login.agent.go | 0 .../{system => auth}/service/login.grpc.go | 0 .../{system => auth}/service/login.http.go | 0 internal/mods/system/dal/login.dal.go | 4 +- internal/mods/system/server/grpc.go | 5 +- internal/mods/system/server/http.go | 5 +- internal/mods/system/server/server.go | 189 +++++---- internal/mods/system/service/gateway.go | 6 - .../service/{menu.agent.go => menu.bridge.go} | 34 +- internal/mods/system/service/menu.grpc.go | 14 +- internal/mods/system/service/menu.http.go | 14 +- ...rmission.agent.go => permission.bridge.go} | 32 +- .../mods/system/service/permission.grpc.go | 14 +- .../{personal.agent.go => personal.bridge.go} | 44 +- internal/mods/system/service/personal.grpc.go | 16 +- .../{resource.agent.go => resource.bridge.go} | 32 +- internal/mods/system/service/resource.grpc.go | 15 +- .../service/{role.agent.go => role.bridge.go} | 32 +- internal/mods/system/service/role.grpc.go | 15 +- internal/mods/system/service/service.go | 54 +-- .../service/{user.agent.go => user.bridge.go} | 40 +- internal/mods/system/service/user.grpc.go | 19 +- resources/configs/system/bootstrap.toml | 5 - .../system/{registry.toml => discovery.toml} | 4 +- resources/configs/system/logger.toml | 6 +- resources/configs/system/service.toml | 168 ++++++-- third_party/auth/v1/auth.proto | 2 +- third_party/config/v1/service.proto | 5 +- third_party/fileupload/v1/fileupload.proto | 2 +- .../circuitbreaker/v1/circuitbreaker.proto | 2 +- third_party/middleware/jwt/v1/jwt.proto | 2 +- .../middleware/metrics/v1/metrics.proto | 2 +- .../middleware/ratelimit/v1/ratelimiter.proto | 2 +- .../middleware/selector/v1/selector.proto | 2 +- .../middleware/validator/v1/validator.proto | 2 +- 67 files changed, 777 insertions(+), 638 deletions(-) rename internal/mods/{system => auth}/service/auth.agent.go (100%) rename internal/mods/{system => auth}/service/auth.grpc.go (100%) rename internal/mods/{system => auth}/service/auth.http.go (100%) rename internal/mods/{system => auth}/service/casbin.grpc.go (100%) rename internal/mods/{system => auth}/service/casbin.http.go (100%) rename internal/mods/{system => auth}/service/login.agent.go (100%) rename internal/mods/{system => auth}/service/login.grpc.go (100%) rename internal/mods/{system => auth}/service/login.http.go (100%) delete mode 100644 internal/mods/system/service/gateway.go rename internal/mods/system/service/{menu.agent.go => menu.bridge.go} (58%) rename internal/mods/system/service/{permission.agent.go => permission.bridge.go} (55%) rename internal/mods/system/service/{personal.agent.go => personal.bridge.go} (60%) rename internal/mods/system/service/{resource.agent.go => resource.bridge.go} (56%) rename internal/mods/system/service/{role.agent.go => role.bridge.go} (60%) rename internal/mods/system/service/{user.agent.go => user.bridge.go} (55%) rename resources/configs/system/{registry.toml => discovery.toml} (88%) diff --git a/api/v1/services/system/login.pb.go b/api/v1/services/system/login.pb.go index 8643d693..742d4a36 100644 --- a/api/v1/services/system/login.pb.go +++ b/api/v1/services/system/login.pb.go @@ -8,7 +8,7 @@ package system import ( _ "github.com/envoyproxy/protoc-gen-validate/validate" - v1 "github.com/origadmin/runtime/gen/go/security/jwt/v1" + v1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" diff --git a/cmd/system/main.go b/cmd/system/main.go index b1ec148b..7528abd2 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -7,15 +7,14 @@ package main import ( "context" "flag" - "fmt" "log/slog" "github.com/go-kratos/kratos/v2" "github.com/go-kratos/kratos/v2/encoding" + "github.com/go-kratos/kratos/v2/transport" "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/codec/toml" _ "origadmin/application/admin/contrib/consul/config" @@ -50,7 +49,6 @@ func main() { // the release mode, work dir sets to empty, use config path as work dir if debug { - fmt.Println("debug mode") flags.SetEnv("debug") flags.SetConfigPath("resources/configs/config.toml") flags.SetWorkDir(".") @@ -71,14 +69,15 @@ func main() { // "span.id", tracing.SpanID(), //) //log.SetLogger(l) - log.Infof("bootstrap flags: %+v\n", flags) + ll := log.NewHelper(log.GetLogger()) + ll.Infof("bootstrap flags: %+v", flags) if err := loader.Bootstrap(context.Background(), flags, buildInjectors); err != nil { - log.Fatalf("failed to bootstrap: %s", err.Error()) + ll.Infof("failed to bootstrap: %s", err.Error()) return } } // NewApp new app with runtime and injector -func NewApp(r runtime.Runtime, injector *loader.Injector) *kratos.App { - return r.CreateApp(injector.Servers...) +func NewApp(r runtime.Runtime, servers []transport.Server) *kratos.App { + return r.CreateApp(servers...) } diff --git a/cmd/system/wire.go b/cmd/system/wire.go index 5ed90286..58a63762 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -15,7 +15,6 @@ import ( "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/loader" systembiz "origadmin/application/admin/internal/mods/system/biz" systemdal "origadmin/application/admin/internal/mods/system/dal" systemserver "origadmin/application/admin/internal/mods/system/server" @@ -25,7 +24,7 @@ import ( // buildInjectors init kratos application. func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { panic(wire.Build( - loader.ProviderSet, + //loader.ProviderSet, data.ProviderSet, //authdal.ProviderSet, //basisbiz.ProviderSet, diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index 56f46048..279017fe 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -11,7 +11,6 @@ import ( "github.com/origadmin/runtime" "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/loader" "origadmin/application/admin/internal/mods/system/biz" "origadmin/application/admin/internal/mods/system/dal" "origadmin/application/admin/internal/mods/system/server" @@ -28,33 +27,25 @@ import ( // buildInjectors init kratos application. func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { - v, err := loader.NewRegistrar(bootstrap) - if err != nil { - return nil, nil, err - } dataData, cleanup, err := data.NewData(r, bootstrap) if err != nil { return nil, nil, err } resourceRepo := dal.NewResourceRepo(r, dataData) resourceServiceBiz := biz.NewResourceServiceBiz(r, resourceRepo) - resourceServiceServer := service.NewResourceServiceServerPB(resourceServiceBiz) + resourceServiceServer := service.NewResourceServiceServerPB(r, resourceServiceBiz) roleRepo := dal.NewRoleRepo(r, dataData) roleServiceBiz := biz.NewRoleServiceBiz(r, roleRepo) - roleServiceServer := service.NewRoleServiceServerPB(roleServiceBiz) + roleServiceServer := service.NewRoleServiceServerPB(r, roleServiceBiz) userRepo := dal.NewUserRepo(r, dataData) userServiceBiz := biz.NewUserServiceBiz(r, userRepo) - userServiceServer := service.NewUserServiceServerPB(userServiceBiz) + userServiceServer := service.NewUserServiceServerPB(r, userServiceBiz) permissionRepo := dal.NewPermissionRepo(r, dataData) permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) - permissionServiceServer := service.NewPermissionServiceServerPB(permissionServiceBiz) - v2 := server.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) - v3 := server.NewSystemServer(r, bootstrap, v2) - injector := &loader.Injector{ - Registrar: v, - Servers: v3, - } - app := NewApp(r, injector) + permissionServiceServer := service.NewPermissionServiceServerPB(r, permissionServiceBiz) + serverRegister := server.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + v := server.NewSystemServer(r, bootstrap, serverRegister) + app := NewApp(r, v) return app, func() { cleanup() }, nil diff --git a/contrib/consul/config/config.go b/contrib/consul/config/config.go index b819decf..af39397e 100644 --- a/contrib/consul/config/config.go +++ b/contrib/consul/config/config.go @@ -13,8 +13,8 @@ import ( "google.golang.org/protobuf/proto" "github.com/origadmin/runtime" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/config" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" ) func init() { diff --git a/contrib/consul/registry/registry.go b/contrib/consul/registry/registry.go index 5d612c98..0be3f368 100644 --- a/contrib/consul/registry/registry.go +++ b/contrib/consul/registry/registry.go @@ -7,9 +7,9 @@ package registry import ( "time" - "github.com/hashicorp/consul/api" + consulapi "github.com/hashicorp/consul/api" "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/registry" "github.com/origadmin/toolkits/errors" ) @@ -21,8 +21,8 @@ func init() { runtime.RegisterRegistry(Type, &consulBuilder{}) } -func configFromConfig(registry *configv1.Registry) *api.Config { - apiconfig := api.DefaultConfig() +func configFromConfig(registry *configv1.Discovery) *consulapi.Config { + apiconfig := consulapi.DefaultConfig() cfg := registry.GetConsul() if cfg == nil { return apiconfig @@ -42,10 +42,10 @@ func configFromConfig(registry *configv1.Registry) *api.Config { return apiconfig } -func optionsFromConfig(registry *configv1.Registry) []Option { +func optionsFromConfig(discovery *configv1.Discovery) []Option { var opts []Option - cfg := registry.GetConsul() + cfg := discovery.GetConsul() if cfg == nil { return opts } @@ -71,20 +71,20 @@ func optionsFromConfig(registry *configv1.Registry) []Option { return opts } -func (c *consulBuilder) NewDiscovery(cfg *configv1.Registry, opts ...registry.Option) (registry.KDiscovery, error) { +func (c *consulBuilder) NewDiscovery(cfg *configv1.Discovery, opts ...registry.Option) (registry.KDiscovery, error) { return c.Create(cfg, opts...) } -func (c *consulBuilder) NewRegistrar(cfg *configv1.Registry, opts ...registry.Option) (registry.KRegistrar, error) { +func (c *consulBuilder) NewRegistrar(cfg *configv1.Discovery, opts ...registry.Option) (registry.KRegistrar, error) { return c.Create(cfg, opts...) } -func (c *consulBuilder) Create(cfg *configv1.Registry, _ ...registry.Option) (registry.Registry, error) { +func (c *consulBuilder) Create(cfg *configv1.Discovery, _ ...registry.Option) (registry.Registry, error) { if cfg == nil || cfg.Consul == nil { return nil, errors.New("configuration: consul config is required") } apiConfig := configFromConfig(cfg) - apiClient, err := api.NewClient(apiConfig) + apiClient, err := consulapi.NewClient(apiConfig) if err != nil { return nil, errors.Wrap(err, "failed to create consul client") } diff --git a/contrib/database/database.go b/contrib/database/database.go index e4439716..a742e7d0 100644 --- a/contrib/database/database.go +++ b/contrib/database/database.go @@ -7,11 +7,10 @@ package database import ( "database/sql" - "fmt" "strings" "time" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/toolkits/errors" "origadmin/application/admin/contrib/database/internal/mysql" @@ -39,7 +38,6 @@ func Open(database *configv1.Database) (*sql.DB, error) { default: } - fmt.Printf("database: dialect: %s, source: %s\n", database.Dialect, database.Source) db, err := sql.Open(database.Dialect, database.Source) if err != nil { return nil, errors.Wrap(err, "database: open database error") diff --git a/contrib/security/authn/jwt/authn_test.go b/contrib/security/authn/jwt/authn_test.go index edaa2ee9..9b600867 100644 --- a/contrib/security/authn/jwt/authn_test.go +++ b/contrib/security/authn/jwt/authn_test.go @@ -15,8 +15,8 @@ import ( "github.com/go-kratos/kratos/v2/transport" jwtv5 "github.com/golang-jwt/jwt/v5" middlewaresecurity "github.com/origadmin/runtime/agent/middleware/security" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" - securityv1 "github.com/origadmin/runtime/gen/go/security/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" "github.com/origadmin/runtime/interfaces/security" "github.com/stretchr/testify/assert" ) diff --git a/contrib/security/authn/jwt/claims.go b/contrib/security/authn/jwt/claims.go index f816055d..a214f1d8 100644 --- a/contrib/security/authn/jwt/claims.go +++ b/contrib/security/authn/jwt/claims.go @@ -10,7 +10,7 @@ import ( "strings" jwtv5 "github.com/golang-jwt/jwt/v5" - securityv1 "github.com/origadmin/runtime/gen/go/security/v1" + securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" "github.com/origadmin/runtime/interfaces/security" ) diff --git a/contrib/security/authn/jwt/jwt.go b/contrib/security/authn/jwt/jwt.go index dd975081..d799ccee 100644 --- a/contrib/security/authn/jwt/jwt.go +++ b/contrib/security/authn/jwt/jwt.go @@ -14,8 +14,8 @@ import ( "github.com/dchest/uniuri" "github.com/goexts/generic/settings" jwtv5 "github.com/golang-jwt/jwt/v5" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" - securityv1 "github.com/origadmin/runtime/gen/go/security/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/interfaces/security" ) diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index 1bb2b153..3a803746 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -14,7 +14,7 @@ import ( "github.com/goexts/generic/maps" "github.com/goexts/generic/settings" "github.com/origadmin/runtime/context" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/errors" "github.com/origadmin/runtime/interfaces/security" diff --git a/helpers/resp/result.go b/helpers/resp/result.go index 76c97cae..e5b2a1fb 100644 --- a/helpers/resp/result.go +++ b/helpers/resp/result.go @@ -10,8 +10,8 @@ import ( "fmt" "net/http" - paginationv1 "github.com/origadmin/runtime/gen/go/pagination/v1" - jwtv1 "github.com/origadmin/runtime/gen/go/security/jwt/v1" + paginationv1 "github.com/origadmin/runtime/api/gen/go/pagination/v1" + jwtv1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" "github.com/origadmin/toolkits/errors/httperr" "google.golang.org/protobuf/proto" diff --git a/internal/configs/service.pb.go b/internal/configs/service.pb.go index e0124b37..567076ff 100644 --- a/internal/configs/service.pb.go +++ b/internal/configs/service.pb.go @@ -94,7 +94,7 @@ func (x *ServiceCore) GetStorages() []*v1.Storage { type ServiceServer struct { state protoimpl.MessageState `protogen:"open.v1"` Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` - Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` + Services []*v1.Service `protobuf:"bytes,200,rep,name=services,proto3" json:"services,omitempty"` Middleware *v11.Middleware `protobuf:"bytes,300,opt,name=middleware,proto3" json:"middleware,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -137,9 +137,9 @@ func (x *ServiceServer) GetCore() *ServiceCore { return nil } -func (x *ServiceServer) GetService() *v1.Service { +func (x *ServiceServer) GetServices() []*v1.Service { if x != nil { - return x.Service + return x.Services } return nil } @@ -204,10 +204,10 @@ const file_configs_service_proto_rawDesc = "" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x02 \x01(\tR\aversion\x122\n" + "\tdiscovery\x18\x03 \x01(\v2\x14.config.v1.DiscoveryR\tdiscovery\x12.\n" + - "\bstorages\x18\x04 \x03(\v2\x12.config.v1.StorageR\bstorages\"\xa8\x01\n" + + "\bstorages\x18\x04 \x03(\v2\x12.config.v1.StorageR\bstorages\"\xaa\x01\n" + "\rServiceServer\x12,\n" + - "\x04core\x18\x01 \x01(\v2\x18.api.configs.ServiceCoreR\x04core\x12-\n" + - "\aservice\x18\xc8\x01 \x01(\v2\x12.config.v1.ServiceR\aservice\x12:\n" + + "\x04core\x18\x01 \x01(\v2\x18.api.configs.ServiceCoreR\x04core\x12/\n" + + "\bservices\x18\xc8\x01 \x03(\v2\x12.config.v1.ServiceR\bservices\x12:\n" + "\n" + "middleware\x18\xac\x02 \x01(\v2\x19.middleware.v1.MiddlewareR\n" + "middleware\"=\n" + @@ -240,7 +240,7 @@ var file_configs_service_proto_depIdxs = []int32{ 3, // 0: api.configs.ServiceCore.discovery:type_name -> config.v1.Discovery 4, // 1: api.configs.ServiceCore.storages:type_name -> config.v1.Storage 0, // 2: api.configs.ServiceServer.core:type_name -> api.configs.ServiceCore - 5, // 3: api.configs.ServiceServer.service:type_name -> config.v1.Service + 5, // 3: api.configs.ServiceServer.services:type_name -> config.v1.Service 6, // 4: api.configs.ServiceServer.middleware:type_name -> middleware.v1.Middleware 0, // 5: api.configs.ServiceClient.core:type_name -> api.configs.ServiceCore 6, // [6:6] is the sub-list for method output_type diff --git a/internal/configs/service.pb.validate.go b/internal/configs/service.pb.validate.go index bd1ebe78..b4d9cf1c 100644 --- a/internal/configs/service.pb.validate.go +++ b/internal/configs/service.pb.validate.go @@ -252,33 +252,38 @@ func (m *ServiceServer) validate(all bool) error { } } - if all { - switch v := interface{}(m.GetService()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceServerValidationError{ - field: "Service", - reason: "embedded message failed validation", - cause: err, - }) + for idx, item := range m.GetServices() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ServiceServerValidationError{ + field: fmt.Sprintf("Services[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ServiceServerValidationError{ + field: fmt.Sprintf("Services[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } } - case interface{ Validate() error }: + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - errors = append(errors, ServiceServerValidationError{ - field: "Service", + return ServiceServerValidationError{ + field: fmt.Sprintf("Services[%v]", idx), reason: "embedded message failed validation", cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetService()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServiceServerValidationError{ - field: "Service", - reason: "embedded message failed validation", - cause: err, + } } } + } if all { diff --git a/internal/configs/service.proto b/internal/configs/service.proto index 1a878c57..94cf83c6 100644 --- a/internal/configs/service.proto +++ b/internal/configs/service.proto @@ -18,7 +18,7 @@ message ServiceCore { message ServiceServer { ServiceCore core = 1 [json_name = "core"]; - config.v1.Service service = 200 [json_name = "service"]; + repeated config.v1.Service services = 200 [json_name = "services"]; middleware.v1.Middleware middleware = 300 [json_name = "middleware"]; } diff --git a/internal/data/data.go b/internal/data/data.go index bdd203e0..f6c8c05c 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -51,6 +51,7 @@ var ProviderSet = wire.NewSet( type Data struct { *ent.Database Delimiter string + Log *log.KHelper } type LoginData struct { @@ -104,16 +105,17 @@ func NewData(r runtime.Runtime, bootstrap *configs.Bootstrap) (*Data, func(), er if bootstrap == nil { return nil, nil, errors.New("bootstrap is nil") } - fmt.Printf("bootstrap: %+v\n", bootstrap) + ll := log.NewHelper(r.WithLogger("module", "data")) + ll.Infow("msg", "bootstrap config", "value", bootstrap) cfg := bootstrap.GetStorage().GetDatabase() if cfg == nil { return nil, nil, errors.New("data source not found") } drv, err := database.Open(cfg) - log.Infow("msg", "connecting to database", "dialect", cfg.Dialect, "source", cfg.Source) + ll.Infow("msg", "connecting to database", "dialect", cfg.Dialect, "source", cfg.Source) if err != nil { - log.Errorw("msg", "failed opening connection to database", "error", err) + ll.Errorw("msg", "failed opening connection to database", "error", err) return nil, nil, err } @@ -135,12 +137,13 @@ func NewData(r runtime.Runtime, bootstrap *configs.Bootstrap) (*Data, func(), er } data := &Data{ + Log: ll, Database: db, Delimiter: TreePathDelimiter, } return data, func() { - log.Info("closing the data resources") + ll.Info("closing the data resources") if err := drv.Close(); err != nil { log.Error(err) } diff --git a/internal/loader/bootstrap.go b/internal/loader/bootstrap.go index 70e4f7c3..3512f30b 100644 --- a/internal/loader/bootstrap.go +++ b/internal/loader/bootstrap.go @@ -11,11 +11,12 @@ import ( "github.com/go-kratos/kratos/v2" "github.com/go-kratos/kratos/v2/middleware/tracing" + "github.com/goexts/generic/cmp" "github.com/origadmin/runtime" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + middlewarev1 "github.com/origadmin/runtime/api/gen/go/middleware/v1" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/config" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" - middlewarev1 "github.com/origadmin/runtime/gen/go/middleware/v1" "github.com/origadmin/runtime/log" "origadmin/application/admin/internal/configs" @@ -44,6 +45,18 @@ type ResolvedBootstrap struct { bootstrap configs.Bootstrap } +func (r *ResolvedBootstrap) FillServiceInfo(flags *bootstrap.Bootstrap) { + core := r.bootstrap.GetServer().GetCore() + name := cmp.Or(flags.ServiceName(), core.GetName()) + version := cmp.Or(flags.Version(), core.GetVersion()) + flags.SetServiceInfo(name, version) +} + +func (r *ResolvedBootstrap) Discovery() *configv1.Discovery { + log.NewHelper(log.GetLogger()).Infow("msg", "discovery config", "value", r.bootstrap.GetDiscovery()) + return r.bootstrap.GetDiscovery() +} + func (r *ResolvedBootstrap) Resolve(config config.KConfig) (config.Resolved, error) { if err := config.Scan(&r.bootstrap); err != nil { return nil, err @@ -67,16 +80,12 @@ func (r *ResolvedBootstrap) Value(name string) (any, error) { } -func (r *ResolvedBootstrap) Registry() *configv1.Registry { - return r.bootstrap.GetRegistry() -} - func (r *ResolvedBootstrap) Middleware() *middlewarev1.Middleware { return r.bootstrap.GetMiddleware() } -func (r *ResolvedBootstrap) Service() *configv1.Service { - return r.bootstrap.GetServices() +func (r *ResolvedBootstrap) Services() []*configv1.Service { + return r.bootstrap.GetServer().GetServices() } func (r *ResolvedBootstrap) Logger() *configv1.Logger { @@ -89,6 +98,7 @@ func Bootstrap(ctx context.Context, flags *bootstrap.Bootstrap, newApp NewApp) e if err != nil { return err } + rb.FillServiceInfo(flags) r = r.WithLoggerAttrs( "ts", log.DefaultTimestamp, "caller", log.DefaultCaller, diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go index e8983112..aa83cd37 100644 --- a/internal/loader/bootstrap_default.go +++ b/internal/loader/bootstrap_default.go @@ -8,17 +8,16 @@ package loader import ( "time" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" - jwtv1 "github.com/origadmin/runtime/gen/go/middleware/jwt/v1" - "github.com/origadmin/runtime/gen/go/middleware/metrics/v1" - "github.com/origadmin/runtime/gen/go/middleware/ratelimit/v1" - "github.com/origadmin/runtime/gen/go/middleware/selector/v1" - middlewarev1 "github.com/origadmin/runtime/gen/go/middleware/v1" - "github.com/origadmin/runtime/gen/go/middleware/validator/v1" - sjwtv1 "github.com/origadmin/runtime/gen/go/security/jwt/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + middlewarev1 "github.com/origadmin/runtime/api/gen/go/middleware/v1" + jwtv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/jwt" + "github.com/origadmin/runtime/api/gen/go/middleware/v1/metrics" + "github.com/origadmin/runtime/api/gen/go/middleware/v1/ratelimit" + "github.com/origadmin/runtime/api/gen/go/middleware/v1/selector" + "github.com/origadmin/runtime/api/gen/go/middleware/v1/validator" + sjwtv1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/configs/services" ) const ( @@ -38,9 +37,9 @@ func DefaultBootstrap() *configs.Bootstrap { Entry: &configs.Bootstrap_Entry{ Scheme: "http", }, - Services: []*services.Service{ - { - Service: &configv1.Service{ + Server: &configs.ServiceServer{ + Services: []*configv1.Service{ + { Name: "", DynamicEndpoint: true, Type: "grpc", @@ -55,9 +54,7 @@ func DefaultBootstrap() *configs.Bootstrap { Builder: "bbr", }, }, - }, - { - Service: &configv1.Service{ + { Name: "", DynamicEndpoint: true, Type: "http", @@ -75,7 +72,7 @@ func DefaultBootstrap() *configs.Bootstrap { }, Logger: DefaultLogger(), Storage: DefaultStorage(), - Registry: DefaultRegistry(), + Discovery: DefaultDiscovery(), Middleware: DefaultServiceMiddleware(), Security: &configs.SecurityConfig{ Security: &configv1.Security{ @@ -135,7 +132,7 @@ func DefaultLogger() *configv1.Logger { Default: true, Name: "output.log", Format: "json", - Level: configv1.LoggerLevel_LOGGER_LEVEL_INFO, + Level: "info", Stdout: true, DisableCaller: false, CallerSkip: 0, @@ -293,11 +290,11 @@ func DefaultServiceMessage() *configv1.Message { } } -func DefaultRegistry() *configv1.Registry { - return &configv1.Registry{ +func DefaultDiscovery() *configv1.Discovery { + return &configv1.Discovery{ Debug: false, Type: "consul", - Consul: &configv1.Registry_Consul{ + Consul: &configv1.Discovery_Consul{ Address: "${consul_address:127.0.0.1:8500}", Scheme: "http", Token: "", diff --git a/internal/loader/config.go b/internal/loader/config.go index dd6871a6..2a14eda3 100644 --- a/internal/loader/config.go +++ b/internal/loader/config.go @@ -7,7 +7,7 @@ package loader import ( "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "origadmin/application/admin/internal/configs" ) diff --git a/internal/loader/config_test.go b/internal/loader/config_test.go index ee79563e..b3e076a2 100644 --- a/internal/loader/config_test.go +++ b/internal/loader/config_test.go @@ -11,7 +11,7 @@ import ( "reflect" "testing" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/toolkits/codec" ) diff --git a/internal/loader/file.go b/internal/loader/file.go index 701d8a8a..5135ceb8 100644 --- a/internal/loader/file.go +++ b/internal/loader/file.go @@ -15,9 +15,9 @@ import ( "github.com/goexts/generic/settings" "github.com/origadmin/contrib/replacer" "github.com/origadmin/runtime" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/config" "github.com/origadmin/runtime/config/file" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/codec" "github.com/origadmin/toolkits/errors" @@ -90,7 +90,7 @@ func NewFileConfig(sourceConfig *configv1.SourceConfig, _ *config.Options) (conf v := new(configs.Bootstrap) options = append(options, file.WithFormatter(fileFormatter(v))) path, _ := filepath.Abs(cfg.Path) - log.NewHelper(log.DefaultLogger).Infof("loading config from %s", path) + log.NewHelper(log.GetLogger()).Infof("loading config from %s", path) return file.NewSource(cfg.Path, options...), nil } diff --git a/internal/loader/load.go b/internal/loader/load.go index c00fc7fc..80d47e04 100644 --- a/internal/loader/load.go +++ b/internal/loader/load.go @@ -13,7 +13,7 @@ import ( "github.com/origadmin/contrib/transport/gins" "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/registry" diff --git a/internal/loader/registry.go b/internal/loader/registry.go index 54143f71..a1cd7c7d 100644 --- a/internal/loader/registry.go +++ b/internal/loader/registry.go @@ -15,7 +15,7 @@ import ( ) func NewRegistrar(bootstrap *configs.Bootstrap) (registry.KRegistrar, error) { - cfg := bootstrap.GetRegistry() + cfg := bootstrap.GetDiscovery() if cfg == nil { return nil, errors.New("registry config is nil") } @@ -27,7 +27,7 @@ func NewRegistrar(bootstrap *configs.Bootstrap) (registry.KRegistrar, error) { } func NewDiscovery(bootstrap *configs.Bootstrap) (registry.KDiscovery, error) { - cfg := bootstrap.GetRegistry() + cfg := bootstrap.GetDiscovery() if cfg == nil { return nil, errors.New("registry config is nil") } diff --git a/internal/loader/service_test.go b/internal/loader/service_test.go index d0176132..19431c06 100644 --- a/internal/loader/service_test.go +++ b/internal/loader/service_test.go @@ -8,35 +8,36 @@ package loader import ( "testing" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" - jwtv1 "github.com/origadmin/runtime/gen/go/middleware/jwt/v1" - "github.com/origadmin/runtime/gen/go/middleware/metrics/v1" - "github.com/origadmin/runtime/gen/go/middleware/ratelimit/v1" - "github.com/origadmin/runtime/gen/go/middleware/selector/v1" - v11 "github.com/origadmin/runtime/gen/go/middleware/v1" - "github.com/origadmin/runtime/gen/go/middleware/validator/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + v11 "github.com/origadmin/runtime/api/gen/go/middleware/v1" + jwtv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/jwt" + metricsv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/metrics" + ratelimitv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/ratelimit" + selectorv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/selector" + validatorv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/validator" + "github.com/stretchr/testify/assert" - "origadmin/application/admin/internal/configs/services" + "origadmin/application/admin/internal/configs" ) func TestServiceDefaultOutput(t *testing.T) { // Test the default service configuration initialization - ss := make([]*services.Service, 0) + ss := make([]*configs.ServiceServer, 0) // Verify empty slice initialization assert.Empty(t, ss, "默认服务列表应为空") // 添加测试服务实例 - testService := &services.Service{ - Core: &services.ServiceCore{ + testService := &configs.ServiceServer{ + Core: &configs.ServiceCore{ Name: "test-service", Version: "v1.0.0", - Registry: &configv1.Registry{ + Discovery: &configv1.Discovery{ Type: "", ServiceName: "", Debug: false, - Consul: &configv1.Registry_Consul{ + Consul: &configv1.Discovery_Consul{ Address: "", Scheme: "", Token: "", @@ -47,201 +48,203 @@ func TestServiceDefaultOutput(t *testing.T) { Timeout: 0, DeregisterCriticalServiceAfter: 0, }, - Etcd: &configv1.Registry_ETCD{ + Etcd: &configv1.Discovery_ETCD{ Endpoints: nil, }, }, Storages: nil, }, - Service: &configv1.Service{ - Name: "", - DynamicEndpoint: false, - Grpc: &configv1.Service_GRPC{ - Network: "", - Addr: "", - UseTls: false, - TlsConfig: &configv1.TLSConfig{ - File: &configv1.TLSConfig_File{ - Cert: "", - Key: "", - Ca: "", - }, - Pem: &configv1.TLSConfig_PEM{ - Cert: nil, - Key: nil, - Ca: nil, + Services: []*configv1.Service{ + &configv1.Service{ + Name: "", + DynamicEndpoint: false, + Grpc: &configv1.Service_GRPC{ + Network: "", + Addr: "", + UseTls: false, + TlsConfig: &configv1.TLSConfig{ + File: &configv1.TLSConfig_File{ + Cert: "", + Key: "", + Ca: "", + }, + Pem: &configv1.TLSConfig_PEM{ + Cert: nil, + Key: nil, + Ca: nil, + }, }, + Timeout: 0, + ShutdownTimeout: 0, + ReadTimeout: 0, + WriteTimeout: 0, + IdleTimeout: 0, + Endpoint: "", }, - Timeout: 0, - ShutdownTimeout: 0, - ReadTimeout: 0, - WriteTimeout: 0, - IdleTimeout: 0, - Endpoint: "", - }, - Http: &configv1.Service_HTTP{ - Network: "", - Addr: "", - UseTls: false, - TlsConfig: &configv1.TLSConfig{ - File: &configv1.TLSConfig_File{ - Cert: "", - Key: "", - Ca: "", + Http: &configv1.Service_HTTP{ + Network: "", + Addr: "", + UseTls: false, + TlsConfig: &configv1.TLSConfig{ + File: &configv1.TLSConfig_File{ + Cert: "", + Key: "", + Ca: "", + }, + Pem: &configv1.TLSConfig_PEM{ + Cert: nil, + Key: nil, + Ca: nil, + }, }, - Pem: &configv1.TLSConfig_PEM{ - Cert: nil, - Key: nil, - Ca: nil, - }, - }, - Timeout: 0, - ShutdownTimeout: 0, - ReadTimeout: 0, - WriteTimeout: 0, - IdleTimeout: 0, - Endpoint: "", - }, - Websocket: &configv1.WebSocket{ - Network: "", - Addr: "", - Path: "", - Codec: "", - Timeout: 0, - }, - Message: &configv1.Message{ - Type: "", - Name: "", - Mqtt: &configv1.Message_MQTT{ - Endpoint: "", - Codec: "", - }, - Kafka: &configv1.Message_Kafka{ - Endpoint: "", - Codec: "", - }, - Rabbitmq: &configv1.Message_RabbitMQ{ - Endpoint: "", - Codec: "", - }, - Activemq: &configv1.Message_ActiveMQ{ - Endpoint: "", - Codec: "", - }, - Nats: &configv1.Message_NATS{ - Endpoint: "", - Codec: "", - }, - Nsq: &configv1.Message_NSQ{ - Endpoint: "", - Codec: "", - }, - Pulsar: &configv1.Message_Pulsar{ - Endpoint: "", - Codec: "", - }, - Redis: &configv1.Message_Redis{ - Endpoint: "", - Codec: "", - }, - Rocketmq: &configv1.Message_RocketMQ{ - Endpoint: "", - Codec: "", - EnableTrace: false, - NameServers: nil, - NameServerDomain: "", - AccessKey: "", - SecretKey: "", - SecurityToken: "", - Namespace: "", - InstanceName: "", - GroupName: "", - }, - }, - Task: &configv1.Task{ - Type: "", - Name: "", - Asynq: &configv1.Task_Asynq{ - Endpoint: "", - Password: "", - Db: 0, - Location: "", - }, - Machinery: &configv1.Task_Machinery{ - Brokers: nil, - Backends: nil, - }, - Cron: &configv1.Task_Cron{ - Addr: "", + Timeout: 0, + ShutdownTimeout: 0, + ReadTimeout: 0, + WriteTimeout: 0, + IdleTimeout: 0, + Endpoint: "", }, - }, - Middleware: &v11.Middleware{ - //Logging: false, - //Recovery: false, - //Tracing: false, - //CircuitBreaker: false, - Metadata: &v11.Middleware_Metadata{ - Enabled: false, - Prefix: "", - Data: nil, + Websocket: &configv1.WebSocket{ + Network: "", + Addr: "", + Path: "", + Codec: "", + Timeout: 0, }, - RateLimiter: &ratelimitv1.RateLimiter{ - Enabled: false, - Name: "", - Period: 0, - XRatelimitLimit: 0, - XRatelimitRemaining: 0, - XRatelimitReset: 0, - RetryAfter: 0, - Memory: &ratelimitv1.RateLimiter_Memory{ - Expiration: 0, - CleanupInterval: 0, + Message: &configv1.Message{ + Type: "", + Name: "", + Mqtt: &configv1.Message_MQTT{ + Endpoint: "", + Codec: "", + }, + Kafka: &configv1.Message_Kafka{ + Endpoint: "", + Codec: "", + }, + Rabbitmq: &configv1.Message_RabbitMQ{ + Endpoint: "", + Codec: "", + }, + Activemq: &configv1.Message_ActiveMQ{ + Endpoint: "", + Codec: "", + }, + Nats: &configv1.Message_NATS{ + Endpoint: "", + Codec: "", + }, + Nsq: &configv1.Message_NSQ{ + Endpoint: "", + Codec: "", }, - Redis: &ratelimitv1.RateLimiter_Redis{ - Addr: "", - Username: "", + Pulsar: &configv1.Message_Pulsar{ + Endpoint: "", + Codec: "", + }, + Redis: &configv1.Message_Redis{ + Endpoint: "", + Codec: "", + }, + Rocketmq: &configv1.Message_RocketMQ{ + Endpoint: "", + Codec: "", + EnableTrace: false, + NameServers: nil, + NameServerDomain: "", + AccessKey: "", + SecretKey: "", + SecurityToken: "", + Namespace: "", + InstanceName: "", + GroupName: "", + }, + }, + Task: &configv1.Task{ + Type: "", + Name: "", + Asynq: &configv1.Task_Asynq{ + Endpoint: "", Password: "", Db: 0, + Location: "", + }, + Machinery: &configv1.Task_Machinery{ + Brokers: nil, + Backends: nil, + }, + Cron: &configv1.Task_Cron{ + Addr: "", }, }, - Metrics: &metricsv1.Metrics{ - Enabled: false, - SupportedMetrics: nil, - UserMetrics: nil, - }, - Validator: &validatorv1.Validator{ - Enabled: false, - Version: 0, - FailFast: false, - }, - Jwt: &jwtv1.JWT{ - Enabled: false, - Subject: "", - ClaimType: "", - TokenHeader: nil, - //Config: &jwtv1.Config{ - // SigningMethod: "", - // Key: "", - // Key2: "", - // AccessTokenLifetime: 0, - // RefreshTokenLifetime: 0, - // Issuer: "", - // Audience: nil, - // TokenType: "", - //}, + Middleware: &v11.Middleware{ + //Logging: false, + //Recovery: false, + //Tracing: false, + //CircuitBreaker: false, + Metadata: &v11.Middleware_Metadata{ + Enabled: false, + Prefix: "", + Data: nil, + }, + RateLimiter: &ratelimitv1.RateLimiter{ + Enabled: false, + Name: "", + Period: 0, + XRatelimitLimit: 0, + XRatelimitRemaining: 0, + XRatelimitReset: 0, + RetryAfter: 0, + Memory: &ratelimitv1.RateLimiter_Memory{ + Expiration: 0, + CleanupInterval: 0, + }, + Redis: &ratelimitv1.RateLimiter_Redis{ + Addr: "", + Username: "", + Password: "", + Db: 0, + }, + }, + Metrics: &metricsv1.Metrics{ + Enabled: false, + SupportedMetrics: nil, + UserMetrics: nil, + }, + Validator: &validatorv1.Validator{ + Enabled: false, + Version: 0, + FailFast: false, + }, + Jwt: &jwtv1.JWT{ + Enabled: false, + Subject: "", + ClaimType: "", + TokenHeader: nil, + //Config: &jwtv1.Config{ + // SigningMethod: "", + // Key: "", + // Key2: "", + // AccessTokenLifetime: 0, + // RefreshTokenLifetime: 0, + // Issuer: "", + // Audience: nil, + // TokenType: "", + //}, + }, + Selector: &selectorv1.Selector{ + Enabled: false, + Names: nil, + Paths: nil, + Regex: "", + Prefixes: nil, + }, }, - Selector: &selectorv1.Selector{ - Enabled: false, - Names: nil, - Paths: nil, - Regex: "", - Prefixes: nil, + Selector: &configv1.Service_Selector{ + Version: "", + Builder: "", }, }, - Selector: &configv1.Service_Selector{ - Version: "", - Builder: "", - }, }, Middleware: &v11.Middleware{ //Logging: false, @@ -311,5 +314,5 @@ func TestServiceDefaultOutput(t *testing.T) { // 验证服务添加后的数量和内容 assert.Len(t, ss, 1, "添加服务后应包含一个元素") - assert.Equal(t, "test-service", ss[0].Service.Name, "服务名称不匹配") + assert.Equal(t, "test-service", ss[0].Services[0].Name, "服务名称不匹配") } diff --git a/internal/mods/agent/agent.go b/internal/mods/agent/agent.go index ec2f76c4..c4aab980 100644 --- a/internal/mods/agent/agent.go +++ b/internal/mods/agent/agent.go @@ -19,7 +19,7 @@ var ProviderSet = wire.NewSet( type ServerRegisterAgent service.ServerRegister -func NewRegisterAgent(s1 *systemserver.RegisterAgent) []ServerRegisterAgent { +func NewRegisterAgent(s1 *systemserver.RegisterBridge) []ServerRegisterAgent { return []ServerRegisterAgent{ s1, } diff --git a/internal/mods/agent/auth_test.go b/internal/mods/agent/auth_test.go index 36e017ca..3e58ca83 100644 --- a/internal/mods/agent/auth_test.go +++ b/internal/mods/agent/auth_test.go @@ -17,7 +17,7 @@ import ( "github.com/go-kratos/kratos/v2/transport" transhttp "github.com/go-kratos/kratos/v2/transport/http" "github.com/origadmin/runtime/context" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/log" kslog "github.com/origadmin/slog-kratos" "github.com/origadmin/runtime/interfaces/security" diff --git a/internal/mods/auth/dal/login.dal.go b/internal/mods/auth/dal/login.dal.go index 07887bf0..fed05357 100644 --- a/internal/mods/auth/dal/login.dal.go +++ b/internal/mods/auth/dal/login.dal.go @@ -11,8 +11,8 @@ import ( kerr "github.com/go-kratos/kratos/v2/errors" "github.com/origadmin/runtime/context" - jwtv1 "github.com/origadmin/runtime/gen/go/security/jwt/v1" - securityv1 "github.com/origadmin/runtime/gen/go/security/v1" + jwtv1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" + securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" diff --git a/internal/mods/system/service/auth.agent.go b/internal/mods/auth/service/auth.agent.go similarity index 100% rename from internal/mods/system/service/auth.agent.go rename to internal/mods/auth/service/auth.agent.go diff --git a/internal/mods/system/service/auth.grpc.go b/internal/mods/auth/service/auth.grpc.go similarity index 100% rename from internal/mods/system/service/auth.grpc.go rename to internal/mods/auth/service/auth.grpc.go diff --git a/internal/mods/system/service/auth.http.go b/internal/mods/auth/service/auth.http.go similarity index 100% rename from internal/mods/system/service/auth.http.go rename to internal/mods/auth/service/auth.http.go diff --git a/internal/mods/system/service/casbin.grpc.go b/internal/mods/auth/service/casbin.grpc.go similarity index 100% rename from internal/mods/system/service/casbin.grpc.go rename to internal/mods/auth/service/casbin.grpc.go diff --git a/internal/mods/system/service/casbin.http.go b/internal/mods/auth/service/casbin.http.go similarity index 100% rename from internal/mods/system/service/casbin.http.go rename to internal/mods/auth/service/casbin.http.go diff --git a/internal/mods/system/service/login.agent.go b/internal/mods/auth/service/login.agent.go similarity index 100% rename from internal/mods/system/service/login.agent.go rename to internal/mods/auth/service/login.agent.go diff --git a/internal/mods/system/service/login.grpc.go b/internal/mods/auth/service/login.grpc.go similarity index 100% rename from internal/mods/system/service/login.grpc.go rename to internal/mods/auth/service/login.grpc.go diff --git a/internal/mods/system/service/login.http.go b/internal/mods/auth/service/login.http.go similarity index 100% rename from internal/mods/system/service/login.http.go rename to internal/mods/auth/service/login.http.go diff --git a/internal/mods/system/dal/login.dal.go b/internal/mods/system/dal/login.dal.go index 7a1340aa..6e0589ad 100644 --- a/internal/mods/system/dal/login.dal.go +++ b/internal/mods/system/dal/login.dal.go @@ -12,8 +12,8 @@ import ( kerr "github.com/go-kratos/kratos/v2/errors" "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - jwtv1 "github.com/origadmin/runtime/gen/go/security/jwt/v1" - securityv1 "github.com/origadmin/runtime/gen/go/security/v1" + jwtv1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" + securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" diff --git a/internal/mods/system/server/grpc.go b/internal/mods/system/server/grpc.go index 58c5d219..43cb5ac0 100644 --- a/internal/mods/system/server/grpc.go +++ b/internal/mods/system/server/grpc.go @@ -13,9 +13,8 @@ import ( // NewGRPCServer new a gRPC server. func NewGRPCServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.GRPCServer { - services := bootstrap.GetServices() - for _, config := range services { - serviceConfig := config.GetService() + services := bootstrap.GetServer().GetServices() + for _, serviceConfig := range services { if serviceConfig.GetType() == "grpc" { grpcServer, err := r.Builder().NewGRPCServer(serviceConfig) if err != nil { diff --git a/internal/mods/system/server/http.go b/internal/mods/system/server/http.go index 9dcbd296..f1be2682 100644 --- a/internal/mods/system/server/http.go +++ b/internal/mods/system/server/http.go @@ -13,9 +13,8 @@ import ( // NewHTTPServer new an HTTP server. func NewHTTPServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.HTTPServer { - services := bootstrap.GetServices() - for _, config := range services { - serviceConfig := config.GetService() + services := bootstrap.GetServer().GetServices() + for _, serviceConfig := range services { if serviceConfig.GetType() == "http" { httpServer, err := r.Builder().NewHTTPServer(serviceConfig) if err != nil { diff --git a/internal/mods/system/server/server.go b/internal/mods/system/server/server.go index 18538206..226d0e46 100644 --- a/internal/mods/system/server/server.go +++ b/internal/mods/system/server/server.go @@ -10,12 +10,13 @@ import ( "github.com/google/wire" "github.com/origadmin/runtime" "github.com/origadmin/runtime/agent" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/context" - configv1 "github.com/origadmin/runtime/gen/go/config/v1" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/middleware" "github.com/origadmin/runtime/service" servicegrpc "github.com/origadmin/runtime/service/grpc" + servicehttp "github.com/origadmin/runtime/service/http" "github.com/origadmin/toolkits/errors" pb "origadmin/application/admin/api/v1/services/system" @@ -31,11 +32,10 @@ const ( var ( // ProviderSet is server providers. ProviderSet = wire.NewSet( - NewRegisterServer, NewSystemClient, NewSystemServer, NewSystemServiceAgentClient, - NewCasbinServiceClient, + //NewCasbinServiceClient, ) ) @@ -43,43 +43,53 @@ func init() { runtime.RegisterService(ServiceName, service.DefaultServiceFactory) } -func NewSystemServer(r runtime.Runtime, bootstrap *configs.Bootstrap, registers []service.ServerRegister) []transport. +func NewSystemServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc service.ServerRegistrar) []transport. Server { var servers []transport.Server - serviceConfig := bootstrap.GetServices() - if serviceConfig == nil { + serverConfig := bootstrap.GetServer() + if serverConfig == nil { return servers } - //if serviceConfig.Name == "" { - // serviceConfig.Name = ServiceName - //} - //ctx := context.Background() - //middlewares := middleware.NewServer(bootstrap.GetMiddleware()) - - //if serv, _ := runtime.NewGRPCServiceServer(bootstrap, l, service.WithGRPC( - // servicegrpc.WithMiddlewares(middlewares...), - // servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), - //)); serv != nil { - // for i := range registers { - // registers[i].GRPCServer(ctx, serv) - // } - // servers = append(servers, serv) - //} - //if serv := NewHTTPServer(bootstrap, l, service.WithHTTP( - // servicehttp.WithMiddlewares(middlewares...), - // servicehttp.WithPrefix(runtime.DefaultEnvPrefix), - //)); serv != nil { - // for i := range registers { - // registers[i].HTTPServer(ctx, serv) - // } - // servers = append(servers, serv) - //} + + ll := log.NewHelper(r.WithLogger("module", "system/server")) + middlewares := middleware.NewServer(bootstrap.GetServer().GetMiddleware()) + services := bootstrap.GetServer().GetServices() + coreinfo := bootstrap.GetServer().GetCore() + for _, serviceConfig := range services { + ll.Infow("msg", "service init", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) + switch serviceConfig.GetType() { + case "grpc": + options := []servicegrpc.Option{ + servicegrpc.WithMiddlewares(middlewares...), + servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), + } + grpcServer, err := r.Builder().NewGRPCServer(serviceConfig, options...) + if err != nil { + continue + } + ll.Infow("msg", "grpc server init", "name", coreinfo.GetName(), "version", + coreinfo.GetVersion()) + svc.Register(r.Context(), grpcServer) + servers = append(servers, grpcServer) + case "http": + options := []servicehttp.Option{ + servicehttp.WithMiddlewares(middlewares...), + servicehttp.WithPrefix(runtime.DefaultEnvPrefix), + } + httpServer, err := r.Builder().NewHTTPServer(serviceConfig, options...) + if err != nil { + continue + } + ll.Infow("msg", "http server init", "name", coreinfo.GetName(), "version", + coreinfo.GetVersion()) + svc.Register(r.Context(), httpServer) + servers = append(servers, httpServer) + } + } return servers } -type RegisterAgent struct { - Auth pb.AuthServiceAgent - Login pb.LoginServiceAgent +type RegisterBridge struct { Personal pb.PersonalServiceAgent Resource pb.ResourceServiceAgent Role pb.RoleServiceAgent @@ -87,15 +97,57 @@ type RegisterAgent struct { Permission pb.PermissionServiceAgent } -func (s RegisterAgent) GRPCServer(ctx context.Context, server *service.GRPCServer) { +func (s RegisterBridge) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { + //TODO implement me + panic("implement me") +} + +func (s RegisterBridge) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { + //TODO implement me + panic("implement me") +} + +func (s RegisterBridge) RegisterHTTPServer(ctx context.Context, server *service.HTTPServer) { + log.Info("http client system init") + ag := agent.NewHTTP(server) + pb.RegisterPersonalServiceAgent(ag, s.Personal) + pb.RegisterResourceServiceAgent(ag, s.Resource) + pb.RegisterRoleServiceAgent(ag, s.Role) + pb.RegisterUserServiceAgent(ag, s.User) + pb.RegisterPermissionServiceAgent(ag, s.Permission) +} + +func (s RegisterBridge) RegisterGRPCClient(ctx context.Context, client *service.GRPCClient) { + //TODO implement me + panic("implement me") +} + +func (s RegisterBridge) RegisterHTTPClient(ctx context.Context, client *service.HTTPClient) { + log.Info("http client system init") + //ag := agent.NewHTTP(client) + //pb.RegisterPersonalServiceAgent(ag, s.Personal) + //pb.RegisterResourceServiceAgent(ag, s.Resource) + //pb.RegisterRoleServiceAgent(ag, s.Role) + //pb.RegisterUserServiceAgent(ag, s.User) + //pb.RegisterPermissionServiceAgent(ag, s.Permission) +} + +func (s RegisterBridge) Register(ctx context.Context, svc any) { + switch v := svc.(type) { + case *service.GRPCServer: + s.RegisterGRPC(ctx, v) + case *service.HTTPServer: + s.RegisterHTTP(ctx, v) + } +} + +func (s RegisterBridge) GRPCServer(ctx context.Context, server *service.GRPCServer) { log.Info("grpc server system init") } -func (s RegisterAgent) HTTPServer(ctx context.Context, server *service.HTTPServer) { +func (s RegisterBridge) HTTPServer(ctx context.Context, server *service.HTTPServer) { log.Info("http server system init") ag := agent.NewHTTP(server) - pb.RegisterAuthServiceAgent(ag, s.Auth) - pb.RegisterLoginServiceAgent(ag, s.Login) pb.RegisterPersonalServiceAgent(ag, s.Personal) pb.RegisterResourceServiceAgent(ag, s.Resource) pb.RegisterRoleServiceAgent(ag, s.Role) @@ -103,15 +155,13 @@ func (s RegisterAgent) HTTPServer(ctx context.Context, server *service.HTTPServe pb.RegisterPermissionServiceAgent(ag, s.Permission) } -func (s RegisterAgent) Server(ctx context.Context, grpcServer *service.GRPCServer, httpServer *service.HTTPServer) { +func (s RegisterBridge) Server(ctx context.Context, grpcServer *service.GRPCServer, httpServer *service.HTTPServer) { s.HTTPServer(ctx, httpServer) s.GRPCServer(ctx, grpcServer) } -func NewSystemServiceAgentClient(client *service.GRPCClient, l log.KLogger) (*RegisterAgent, error) { - register := RegisterAgent{ - Auth: systemservice.NewAuthServiceAgentClient(client), - Login: systemservice.NewLoginServiceAgentClient(client), +func NewSystemServiceAgentClient(r runtime.Runtime, client *service.GRPCClient) (*RegisterBridge, error) { + register := RegisterBridge{ Personal: systemservice.NewPersonalServiceAgentClient(client), Resource: systemservice.NewResourceServiceAgentClient(client), Role: systemservice.NewRoleServiceAgentClient(client), @@ -121,23 +171,10 @@ func NewSystemServiceAgentClient(client *service.GRPCClient, l log.KLogger) (*Re return ®ister, nil } -func NewCasbinServiceClient(client *service.GRPCClient, l log.KLogger) pb.CasbinSourceServiceClient { - return systemservice.NewCasbinSourceServiceClient(client) -} - func NewSystemClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service.GRPCClient, error) { - entry := bootstrap.GetEntry() - if entry == nil { - return nil, errors.New("no entry") - } - - //servers := bootstrap.GetServers() - //if servers == nil { - // return nil, errors.New("no servers") - //} - registry := bootstrap.GetRegistry() - if registry == nil { - return nil, errors.New("no registry") + discovery := bootstrap.GetDiscovery() + if discovery == nil { + return nil, errors.New("no discovery") } serviceConfig := &configv1.Service{ Name: ServiceName, @@ -149,18 +186,18 @@ func NewSystemClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service. }, } //if v, ok := bootstrap.GetServices()[ServiceName]; ok { - // registry.ServiceName = ServiceName + // discovery.ServiceName = ServiceName //} helper := log.NewHelper(r.Logger()) - //registry.ServiceName = ServiceName - helper.Infof("service name: %s", registry.ServiceName) - discovery, err := runtime.NewDiscovery(registry) + //discovery.ServiceName = ServiceName + helper.Infof("service name: %s", discovery.ServiceName) + discover, err := runtime.NewDiscovery(discovery) if err != nil { return nil, errors.Wrap(err, "create discovery") } var ms []middleware.KMiddleware options := []servicegrpc.Option{ - servicegrpc.WithDiscovery(registry.ServiceName, discovery), + servicegrpc.WithDiscovery(discovery.ServiceName, discover), } ms = append(ms, middleware.NewClient(bootstrap.GetMiddleware())...) ms = append(ms, MiddlewareServer()) @@ -193,28 +230,4 @@ func MiddlewareServer() middleware.KMiddleware { } } -func NewRegisterServer( - Resource pb.ResourceServiceServer, - Role pb.RoleServiceServer, - User pb.UserServiceServer, -//Auth pb.AuthServiceServer, -//Login pb.LoginServiceServer, -//Personal pb.PersonalServiceServer, - Permission pb.PermissionServiceServer, -//Casbin pb.CasbinSourceServiceServer, -) []service.ServerRegister { - return []service.ServerRegister{ - &systemservice.RegisterServer{ - Resource: Resource, - Role: Role, - User: User, - //Auth: Auth, - //Login: Login, - //Personal: Personal, - Permission: Permission, - //Casbin: Casbin, - }, - } -} - -var _ service.ServerRegister = (*RegisterAgent)(nil) +var _ service.ServerRegistrar = (*RegisterBridge)(nil) diff --git a/internal/mods/system/service/gateway.go b/internal/mods/system/service/gateway.go deleted file mode 100644 index 542e09bd..00000000 --- a/internal/mods/system/service/gateway.go +++ /dev/null @@ -1,6 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package service implements the functions, types, and interfaces for the module. -package service diff --git a/internal/mods/system/service/menu.agent.go b/internal/mods/system/service/menu.bridge.go similarity index 58% rename from internal/mods/system/service/menu.agent.go rename to internal/mods/system/service/menu.bridge.go index c74d1dac..aa83bdc2 100644 --- a/internal/mods/system/service/menu.agent.go +++ b/internal/mods/system/service/menu.bridge.go @@ -15,14 +15,14 @@ import ( "origadmin/application/admin/helpers/resp" ) -// MenuServiceAgent is a menu service. -type MenuServiceAgent struct { - resp.Response +// MenuServiceBridge is a menu service. +type MenuServiceBridge struct { + pb.UnimplementedMenuServiceServer client pb.MenuServiceClient } -func (s MenuServiceAgent) CreateMenu(ctx context.Context, request *pb.CreateMenuRequest) (*pb.CreateMenuResponse, error) { +func (s MenuServiceBridge) CreateMenu(ctx context.Context, request *pb.CreateMenuRequest) (*pb.CreateMenuResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.CreateMenu(ctx, request) if err != nil { @@ -35,7 +35,7 @@ func (s MenuServiceAgent) CreateMenu(ctx context.Context, request *pb.CreateMenu return nil, nil } -func (s MenuServiceAgent) DeleteMenu(ctx context.Context, request *pb.DeleteMenuRequest) (*pb.DeleteMenuResponse, error) { +func (s MenuServiceBridge) DeleteMenu(ctx context.Context, request *pb.DeleteMenuRequest) (*pb.DeleteMenuResponse, error) { httpCtx := agent.FromHTTPContext(ctx) _, err := s.client.DeleteMenu(ctx, request) if err != nil { @@ -48,7 +48,7 @@ func (s MenuServiceAgent) DeleteMenu(ctx context.Context, request *pb.DeleteMenu return nil, nil } -func (s MenuServiceAgent) GetMenu(ctx context.Context, request *pb.GetMenuRequest) (*pb.GetMenuResponse, error) { +func (s MenuServiceBridge) GetMenu(ctx context.Context, request *pb.GetMenuRequest) (*pb.GetMenuResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.GetMenu(ctx, request) if err != nil { @@ -61,7 +61,7 @@ func (s MenuServiceAgent) GetMenu(ctx context.Context, request *pb.GetMenuReques return nil, nil } -func (s MenuServiceAgent) ListMenus(ctx context.Context, request *pb.ListMenusRequest) (*pb.ListMenusResponse, error) { +func (s MenuServiceBridge) ListMenus(ctx context.Context, request *pb.ListMenusRequest) (*pb.ListMenusResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.ListMenus(ctx, request) if err != nil { @@ -76,7 +76,7 @@ func (s MenuServiceAgent) ListMenus(ctx context.Context, request *pb.ListMenusRe return nil, nil } -func (s MenuServiceAgent) UpdateMenu(ctx context.Context, request *pb.UpdateMenuRequest) (*pb.UpdateMenuResponse, error) { +func (s MenuServiceBridge) UpdateMenu(ctx context.Context, request *pb.UpdateMenuRequest) (*pb.UpdateMenuResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.UpdateMenu(ctx, request) if err != nil { @@ -89,18 +89,18 @@ func (s MenuServiceAgent) UpdateMenu(ctx context.Context, request *pb.UpdateMenu return nil, nil } -// NewMenuServiceAgent new a menu service. -func NewMenuServiceAgent(client pb.MenuServiceClient) *MenuServiceAgent { - return &MenuServiceAgent{client: client} +// NewMenuServiceBridge new a menu service. +func NewMenuServiceBridge(client pb.MenuServiceClient) *MenuServiceBridge { + return &MenuServiceBridge{client: client} } -// NewMenuServiceAgentPB new a menu service. -func NewMenuServiceAgentPB(client pb.MenuServiceClient) pb.MenuServiceAgent { - return &MenuServiceAgent{client: client} +// NewMenuServiceBridgePB new a menu service. +func NewMenuServiceBridgePB(client pb.MenuServiceClient) pb.MenuServiceServer { + return &MenuServiceBridge{client: client} } -func NewMenuServiceAgentClient(client *service.GRPCClient) pb.MenuServiceAgent { +func NewMenuServiceBridgeClient(client *service.GRPCClient) pb.MenuServiceServer { cli := pb.NewMenuServiceClient(client) - return NewMenuServiceAgent(cli) + return NewMenuServiceBridge(cli) } -var _ pb.MenuServiceAgent = (*MenuServiceAgent)(nil) +var _ pb.MenuServiceServer = (*MenuServiceBridge)(nil) diff --git a/internal/mods/system/service/menu.grpc.go b/internal/mods/system/service/menu.grpc.go index e49556ff..fa487bd6 100644 --- a/internal/mods/system/service/menu.grpc.go +++ b/internal/mods/system/service/menu.grpc.go @@ -5,7 +5,9 @@ package service import ( + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" ) @@ -15,6 +17,7 @@ type MenuServiceServer struct { pb.UnimplementedMenuServiceServer client pb.MenuServiceClient + log *log.KHelper } func (s MenuServiceServer) ListMenus(ctx context.Context, request *pb.ListMenusRequest) (*pb.ListMenusResponse, error) { @@ -43,13 +46,16 @@ func (s MenuServiceServer) DeleteMenu(ctx context.Context, request *pb.DeleteMen //} // NewMenuServiceServer new a menu service. -func NewMenuServiceServer(client pb.MenuServiceClient) *MenuServiceServer { - return &MenuServiceServer{client: client} +func NewMenuServiceServer(client pb.MenuServiceClient, logger log.KLogger) *MenuServiceServer { + return &MenuServiceServer{ + log: log.NewHelper(logger), + client: client, + } } // NewMenuServiceServerPB new a menu service. -func NewMenuServiceServerPB(client pb.MenuServiceClient) pb.MenuServiceServer { - return &MenuServiceServer{client: client} +func NewMenuServiceServerPB(r runtime.Runtime, client pb.MenuServiceClient) pb.MenuServiceServer { + return NewMenuServiceServer(client, r.WithLogger("module", "service/menu")) } var _ pb.MenuServiceServer = (*MenuServiceServer)(nil) diff --git a/internal/mods/system/service/menu.http.go b/internal/mods/system/service/menu.http.go index 0a99a966..6c214465 100644 --- a/internal/mods/system/service/menu.http.go +++ b/internal/mods/system/service/menu.http.go @@ -5,7 +5,9 @@ package service import ( + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" ) @@ -15,6 +17,7 @@ type MenuServiceHTTPServer struct { pb.UnimplementedMenuServiceServer client pb.MenuServiceHTTPClient + log *log.KHelper } func (s MenuServiceHTTPServer) CreateMenu(ctx context.Context, request *pb.CreateMenuRequest) (*pb.CreateMenuResponse, error) { @@ -43,13 +46,16 @@ func (s MenuServiceHTTPServer) UpdateMenu(ctx context.Context, request *pb.Updat //} // NewMenuServiceHTTPServer new a menu service. -func NewMenuServiceHTTPServer(client pb.MenuServiceHTTPClient) *MenuServiceHTTPServer { - return &MenuServiceHTTPServer{client: client} +func NewMenuServiceHTTPServer(client pb.MenuServiceHTTPClient, logger log.KLogger) *MenuServiceHTTPServer { + return &MenuServiceHTTPServer{ + client: client, + log: log.NewHelper(logger), + } } // NewMenuServiceHTTPServerPB new a menu service. -func NewMenuServiceHTTPServerPB(client pb.MenuServiceHTTPClient) pb.MenuServiceHTTPServer { - return &MenuServiceHTTPServer{client: client} +func NewMenuServiceHTTPServerPB(r runtime.Runtime, client pb.MenuServiceHTTPClient) pb.MenuServiceHTTPServer { + return NewMenuServiceHTTPServer(client, r.WithLogger("module", "service/menu")) } var _ pb.MenuServiceServer = (*MenuServiceHTTPServer)(nil) diff --git a/internal/mods/system/service/permission.agent.go b/internal/mods/system/service/permission.bridge.go similarity index 55% rename from internal/mods/system/service/permission.agent.go rename to internal/mods/system/service/permission.bridge.go index f5338169..ac6e1350 100644 --- a/internal/mods/system/service/permission.agent.go +++ b/internal/mods/system/service/permission.bridge.go @@ -15,14 +15,14 @@ import ( "origadmin/application/admin/helpers/resp" ) -// PermissionServiceAgent is a menu service. -type PermissionServiceAgent struct { +// PermissionServiceBridge is a menu service. +type PermissionServiceBridge struct { resp.Response client pb.PermissionServiceClient } -func (s PermissionServiceAgent) CreatePermission(ctx context.Context, request *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { +func (s PermissionServiceBridge) CreatePermission(ctx context.Context, request *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.CreatePermission(ctx, request) if err != nil { @@ -35,7 +35,7 @@ func (s PermissionServiceAgent) CreatePermission(ctx context.Context, request *p return nil, nil } -func (s PermissionServiceAgent) DeletePermission(ctx context.Context, request *pb.DeletePermissionRequest) (*pb.DeletePermissionResponse, error) { +func (s PermissionServiceBridge) DeletePermission(ctx context.Context, request *pb.DeletePermissionRequest) (*pb.DeletePermissionResponse, error) { httpCtx := agent.FromHTTPContext(ctx) _, err := s.client.DeletePermission(ctx, request) if err != nil { @@ -48,7 +48,7 @@ func (s PermissionServiceAgent) DeletePermission(ctx context.Context, request *p return nil, nil } -func (s PermissionServiceAgent) GetPermission(ctx context.Context, request *pb.GetPermissionRequest) (*pb.GetPermissionResponse, error) { +func (s PermissionServiceBridge) GetPermission(ctx context.Context, request *pb.GetPermissionRequest) (*pb.GetPermissionResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.GetPermission(ctx, request) if err != nil { @@ -61,7 +61,7 @@ func (s PermissionServiceAgent) GetPermission(ctx context.Context, request *pb.G return nil, nil } -func (s PermissionServiceAgent) ListPermissions(ctx context.Context, request *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { +func (s PermissionServiceBridge) ListPermissions(ctx context.Context, request *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.ListPermissions(ctx, request) if err != nil { @@ -76,7 +76,7 @@ func (s PermissionServiceAgent) ListPermissions(ctx context.Context, request *pb return nil, nil } -func (s PermissionServiceAgent) UpdatePermission(ctx context.Context, request *pb.UpdatePermissionRequest) (*pb.UpdatePermissionResponse, error) { +func (s PermissionServiceBridge) UpdatePermission(ctx context.Context, request *pb.UpdatePermissionRequest) (*pb.UpdatePermissionResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.UpdatePermission(ctx, request) if err != nil { @@ -89,18 +89,18 @@ func (s PermissionServiceAgent) UpdatePermission(ctx context.Context, request *p return nil, nil } -// NewPermissionServiceAgent new a menu service. -func NewPermissionServiceAgent(client pb.PermissionServiceClient) *PermissionServiceAgent { - return &PermissionServiceAgent{client: client} +// NewPermissionServiceBridge new a menu service. +func NewPermissionServiceBridge(client pb.PermissionServiceClient) *PermissionServiceBridge { + return &PermissionServiceBridge{client: client} } -// NewPermissionServiceAgentPB new a menu service. -func NewPermissionServiceAgentPB(client pb.PermissionServiceClient) pb.PermissionServiceAgent { - return &PermissionServiceAgent{client: client} +// NewPermissionServiceBridgePB new a menu service. +func NewPermissionServiceBridgePB(client pb.PermissionServiceClient) pb.PermissionServiceBridge { + return &PermissionServiceBridge{client: client} } -func NewPermissionServiceAgentClient(client *service.GRPCClient) pb.PermissionServiceAgent { +func NewPermissionServiceBridgeClient(client *service.GRPCClient) pb.PermissionServiceBridge { cli := pb.NewPermissionServiceClient(client) - return NewPermissionServiceAgent(cli) + return NewPermissionServiceBridge(cli) } -var _ pb.PermissionServiceAgent = (*PermissionServiceAgent)(nil) +var _ pb.PermissionServiceBridge = (*PermissionServiceBridge)(nil) diff --git a/internal/mods/system/service/permission.grpc.go b/internal/mods/system/service/permission.grpc.go index 221f4394..6469f8d6 100644 --- a/internal/mods/system/service/permission.grpc.go +++ b/internal/mods/system/service/permission.grpc.go @@ -5,7 +5,9 @@ package service import ( + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/biz" @@ -16,6 +18,7 @@ type PermissionServiceServer struct { pb.UnimplementedPermissionServiceServer client *biz.PermissionServiceBiz + log *log.KHelper } func (s PermissionServiceServer) ListPermissions(ctx context.Context, request *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { @@ -44,13 +47,16 @@ func (s PermissionServiceServer) DeletePermission(ctx context.Context, request * //} // NewPermissionServiceServer new a menu service. -func NewPermissionServiceServer(client *biz.PermissionServiceBiz) *PermissionServiceServer { - return &PermissionServiceServer{client: client} +func NewPermissionServiceServer(r runtime.Runtime, client *biz.PermissionServiceBiz) *PermissionServiceServer { + return &PermissionServiceServer{ + log: log.NewHelper(r.WithLogger("module", "service/permission")), + client: client, + } } // NewPermissionServiceServerPB new a menu service. -func NewPermissionServiceServerPB(client *biz.PermissionServiceBiz) pb.PermissionServiceServer { - return &PermissionServiceServer{client: client} +func NewPermissionServiceServerPB(r runtime.Runtime, client *biz.PermissionServiceBiz) pb.PermissionServiceServer { + return NewPermissionServiceServer(r, client) } var _ pb.PermissionServiceServer = (*PermissionServiceServer)(nil) diff --git a/internal/mods/system/service/personal.agent.go b/internal/mods/system/service/personal.bridge.go similarity index 60% rename from internal/mods/system/service/personal.agent.go rename to internal/mods/system/service/personal.bridge.go index 89003108..5131aca9 100644 --- a/internal/mods/system/service/personal.agent.go +++ b/internal/mods/system/service/personal.bridge.go @@ -16,19 +16,19 @@ import ( "origadmin/application/admin/helpers/resp" ) -// PersonalServiceAgent is a Personal service. -type PersonalServiceAgent struct { +// PersonalServiceBridge is a Personal service. +type PersonalServiceBridge struct { resp.Response client pb.PersonalServiceClient } -func (s PersonalServiceAgent) RefreshPersonalToken(ctx context.Context, request *pb.RefreshPersonalTokenRequest) (*pb.RefreshPersonalTokenResponse, error) { +func (s PersonalServiceBridge) RefreshPersonalToken(ctx context.Context, request *pb.RefreshPersonalTokenRequest) (*pb.RefreshPersonalTokenResponse, error) { //TODO implement me panic("implement me") } -func (s PersonalServiceAgent) GetPersonalProfile(ctx context.Context, request *pb.GetPersonalProfileRequest) (*pb.GetPersonalProfileResponse, error) { +func (s PersonalServiceBridge) GetPersonalProfile(ctx context.Context, request *pb.GetPersonalProfileRequest) (*pb.GetPersonalProfileResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.GetPersonalProfile(ctx, request) if err != nil { @@ -42,7 +42,7 @@ func (s PersonalServiceAgent) GetPersonalProfile(ctx context.Context, request *p return nil, nil } -func (s PersonalServiceAgent) PersonalLogout(ctx context.Context, request *pb.PersonalLogoutRequest) (*pb.PersonalLogoutResponse, error) { +func (s PersonalServiceBridge) PersonalLogout(ctx context.Context, request *pb.PersonalLogoutRequest) (*pb.PersonalLogoutResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.PersonalLogout(ctx, request) if err != nil { @@ -56,7 +56,7 @@ func (s PersonalServiceAgent) PersonalLogout(ctx context.Context, request *pb.Pe return nil, nil } -func (s PersonalServiceAgent) ListPersonalResources(ctx context.Context, request *pb.ListPersonalResourcesRequest) (*pb.ListPersonalResourcesResponse, error) { +func (s PersonalServiceBridge) ListPersonalResources(ctx context.Context, request *pb.ListPersonalResourcesRequest) (*pb.ListPersonalResourcesResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.ListPersonalResources(ctx, request) if err != nil { @@ -71,7 +71,7 @@ func (s PersonalServiceAgent) ListPersonalResources(ctx context.Context, request return nil, nil } -func (s PersonalServiceAgent) ListPersonalRoles(ctx context.Context, request *pb.ListPersonalRolesRequest) (*pb.ListPersonalRolesResponse, error) { +func (s PersonalServiceBridge) ListPersonalRoles(ctx context.Context, request *pb.ListPersonalRolesRequest) (*pb.ListPersonalRolesResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.ListPersonalRoles(ctx, request) if err != nil { @@ -86,7 +86,7 @@ func (s PersonalServiceAgent) ListPersonalRoles(ctx context.Context, request *pb return nil, nil } -func (s PersonalServiceAgent) UpdatePersonalSetting(ctx context.Context, request *pb.UpdatePersonalSettingRequest) (*pb.UpdatePersonalSettingResponse, error) { +func (s PersonalServiceBridge) UpdatePersonalSetting(ctx context.Context, request *pb.UpdatePersonalSettingRequest) (*pb.UpdatePersonalSettingResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.UpdatePersonalSetting(ctx, request) if err != nil { @@ -100,7 +100,7 @@ func (s PersonalServiceAgent) UpdatePersonalSetting(ctx context.Context, request return nil, nil } -func (s PersonalServiceAgent) UpdatePersonalProfile(ctx context.Context, request *pb.UpdatePersonalProfileRequest) (*pb.UpdatePersonalProfileResponse, error) { +func (s PersonalServiceBridge) UpdatePersonalProfile(ctx context.Context, request *pb.UpdatePersonalProfileRequest) (*pb.UpdatePersonalProfileResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.UpdatePersonalProfile(ctx, request) if err != nil { @@ -114,7 +114,7 @@ func (s PersonalServiceAgent) UpdatePersonalProfile(ctx context.Context, request return nil, nil } -func (s PersonalServiceAgent) UpdatePersonalPassword(ctx context.Context, request *pb.UpdatePersonalPasswordRequest) (*pb.UpdatePersonalPasswordResponse, error) { +func (s PersonalServiceBridge) UpdatePersonalPassword(ctx context.Context, request *pb.UpdatePersonalPasswordRequest) (*pb.UpdatePersonalPasswordResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.UpdatePersonalPassword(ctx, request) if err != nil { @@ -128,7 +128,7 @@ func (s PersonalServiceAgent) UpdatePersonalPassword(ctx context.Context, reques return nil, nil } -//func (s PersonalServiceAgent) PersonalResources(ctx context.Context, request *pb.PersonalResourcesRequest) (*pb.PersonalResourcesResponse, error) { +//func (s PersonalServiceBridge) PersonalResources(ctx context.Context, request *pb.PersonalResourcesRequest) (*pb.PersonalResourcesResponse, error) { // response, err := s.client.PersonalResources(context, request) // if err != nil { // log.Errorf("PersonalResources error: %v", err) @@ -141,7 +141,7 @@ func (s PersonalServiceAgent) UpdatePersonalPassword(ctx context.Context, reques // return nil, nil //} -//func (s PersonalServiceAgent) PersonalProfile(ctx context.Context, request *pb.PersonalProfileRequest) (*pb.PersonalProfileResponse, error) { +//func (s PersonalServiceBridge) PersonalProfile(ctx context.Context, request *pb.PersonalProfileRequest) (*pb.PersonalProfileResponse, error) { // response, err := s.client.PersonalProfile(context, request) // if err != nil { // log.Errorf("PersonalProfile error: %v", err) @@ -154,7 +154,7 @@ func (s PersonalServiceAgent) UpdatePersonalPassword(ctx context.Context, reques // return nil, nil //} -//func (s PersonalServiceAgent) Logout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { +//func (s PersonalServiceBridge) Logout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { // response, err := s.client.Logout(context, request) // if err != nil { // log.Errorf("Logout error: %v", err) @@ -167,18 +167,18 @@ func (s PersonalServiceAgent) UpdatePersonalPassword(ctx context.Context, reques // return nil, nil //} -// NewPersonalServiceAgent new a Personal service. -func NewPersonalServiceAgent(client pb.PersonalServiceClient) *PersonalServiceAgent { - return &PersonalServiceAgent{client: client} +// NewPersonalServiceBridge new a Personal service. +func NewPersonalServiceBridge(client pb.PersonalServiceClient) *PersonalServiceBridge { + return &PersonalServiceBridge{client: client} } -// NewPersonalServiceAgentPB new a Personal service. -func NewPersonalServiceAgentPB(client pb.PersonalServiceClient) pb.PersonalServiceAgent { - return &PersonalServiceAgent{client: client} +// NewPersonalServiceBridgePB new a Personal service. +func NewPersonalServiceBridgePB(client pb.PersonalServiceClient) pb.PersonalServiceBridge { + return &PersonalServiceBridge{client: client} } -func NewPersonalServiceAgentClient(client *service.GRPCClient) pb.PersonalServiceAgent { +func NewPersonalServiceBridgeClient(client *service.GRPCClient) pb.PersonalServiceServer { cli := pb.NewPersonalServiceClient(client) - return NewPersonalServiceAgent(cli) + return NewPersonalServiceBridge(cli) } -var _ pb.PersonalServiceAgent = (*PersonalServiceAgent)(nil) +var _ pb.PersonalServiceBridge = (*PersonalServiceBridge)(nil) diff --git a/internal/mods/system/service/personal.grpc.go b/internal/mods/system/service/personal.grpc.go index 83e9293e..fb16d9fc 100644 --- a/internal/mods/system/service/personal.grpc.go +++ b/internal/mods/system/service/personal.grpc.go @@ -5,7 +5,9 @@ package service import ( + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/biz" @@ -16,6 +18,7 @@ type PersonalServiceServer struct { pb.UnimplementedPersonalServiceServer client *biz.PersonalServiceBiz + log *log.KHelper } func (s PersonalServiceServer) GetPersonalProfile(ctx context.Context, request *pb.GetPersonalProfileRequest) (*pb.GetPersonalProfileResponse, error) { @@ -51,13 +54,18 @@ func (s PersonalServiceServer) UpdatePersonalSetting(ctx context.Context, reques //} // NewPersonalServiceServer new a login service. -func NewPersonalServiceServer(client *biz.PersonalServiceBiz) *PersonalServiceServer { - return &PersonalServiceServer{client: client} +func NewPersonalServiceServer(r runtime.Runtime, client *biz.PersonalServiceBiz) *PersonalServiceServer { + return &PersonalServiceServer{ + log: log.NewHelper(r.WithLogger( + "module", "service/personal", + )), + client: client, + } } // NewPersonalServiceServerPB new a login service. -func NewPersonalServiceServerPB(client *biz.PersonalServiceBiz) pb.PersonalServiceServer { - return &PersonalServiceServer{client: client} +func NewPersonalServiceServerPB(r runtime.Runtime, client *biz.PersonalServiceBiz) pb.PersonalServiceServer { + return NewPersonalServiceServer(r, client) } var _ pb.PersonalServiceServer = (*PersonalServiceServer)(nil) diff --git a/internal/mods/system/service/resource.agent.go b/internal/mods/system/service/resource.bridge.go similarity index 56% rename from internal/mods/system/service/resource.agent.go rename to internal/mods/system/service/resource.bridge.go index 317a0100..bdd93ea9 100644 --- a/internal/mods/system/service/resource.agent.go +++ b/internal/mods/system/service/resource.bridge.go @@ -15,14 +15,14 @@ import ( "origadmin/application/admin/helpers/resp" ) -// ResourceServiceAgent is a menu service. -type ResourceServiceAgent struct { +// ResourceServiceBridge is a menu service. +type ResourceServiceBridge struct { resp.Response client pb.ResourceServiceClient } -func (s ResourceServiceAgent) CreateResource(ctx context.Context, request *pb.CreateResourceRequest) (*pb.CreateResourceResponse, error) { +func (s ResourceServiceBridge) CreateResource(ctx context.Context, request *pb.CreateResourceRequest) (*pb.CreateResourceResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.CreateResource(ctx, request) if err != nil { @@ -35,7 +35,7 @@ func (s ResourceServiceAgent) CreateResource(ctx context.Context, request *pb.Cr return nil, nil } -func (s ResourceServiceAgent) DeleteResource(ctx context.Context, request *pb.DeleteResourceRequest) (*pb.DeleteResourceResponse, error) { +func (s ResourceServiceBridge) DeleteResource(ctx context.Context, request *pb.DeleteResourceRequest) (*pb.DeleteResourceResponse, error) { httpCtx := agent.FromHTTPContext(ctx) _, err := s.client.DeleteResource(ctx, request) if err != nil { @@ -48,7 +48,7 @@ func (s ResourceServiceAgent) DeleteResource(ctx context.Context, request *pb.De return nil, nil } -func (s ResourceServiceAgent) GetResource(ctx context.Context, request *pb.GetResourceRequest) (*pb.GetResourceResponse, error) { +func (s ResourceServiceBridge) GetResource(ctx context.Context, request *pb.GetResourceRequest) (*pb.GetResourceResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.GetResource(ctx, request) if err != nil { @@ -61,7 +61,7 @@ func (s ResourceServiceAgent) GetResource(ctx context.Context, request *pb.GetRe return nil, nil } -func (s ResourceServiceAgent) ListResources(ctx context.Context, request *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { +func (s ResourceServiceBridge) ListResources(ctx context.Context, request *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.ListResources(ctx, request) if err != nil { @@ -76,7 +76,7 @@ func (s ResourceServiceAgent) ListResources(ctx context.Context, request *pb.Lis return nil, nil } -func (s ResourceServiceAgent) UpdateResource(ctx context.Context, request *pb.UpdateResourceRequest) (*pb.UpdateResourceResponse, error) { +func (s ResourceServiceBridge) UpdateResource(ctx context.Context, request *pb.UpdateResourceRequest) (*pb.UpdateResourceResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.UpdateResource(ctx, request) if err != nil { @@ -89,18 +89,18 @@ func (s ResourceServiceAgent) UpdateResource(ctx context.Context, request *pb.Up return nil, nil } -// NewResourceServiceAgent new a menu service. -func NewResourceServiceAgent(client pb.ResourceServiceClient) *ResourceServiceAgent { - return &ResourceServiceAgent{client: client} +// NewResourceServiceBridge new a menu service. +func NewResourceServiceBridge(client pb.ResourceServiceClient) *ResourceServiceBridge { + return &ResourceServiceBridge{client: client} } -// NewResourceServiceAgentPB new a menu service. -func NewResourceServiceAgentPB(client pb.ResourceServiceClient) pb.ResourceServiceAgent { - return &ResourceServiceAgent{client: client} +// NewResourceServiceBridgePB new a menu service. +func NewResourceServiceBridgePB(client pb.ResourceServiceClient) pb.ResourceServiceBridge { + return &ResourceServiceBridge{client: client} } -func NewResourceServiceAgentClient(client *service.GRPCClient) pb.ResourceServiceAgent { +func NewResourceServiceBridgeClient(client *service.GRPCClient) pb.ResourceServiceBridge { cli := pb.NewResourceServiceClient(client) - return NewResourceServiceAgent(cli) + return NewResourceServiceBridge(cli) } -var _ pb.ResourceServiceAgent = (*ResourceServiceAgent)(nil) +var _ pb.ResourceServiceBridge = (*ResourceServiceBridge)(nil) diff --git a/internal/mods/system/service/resource.grpc.go b/internal/mods/system/service/resource.grpc.go index 97661ccf..ac3f22a1 100644 --- a/internal/mods/system/service/resource.grpc.go +++ b/internal/mods/system/service/resource.grpc.go @@ -5,7 +5,9 @@ package service import ( + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/biz" @@ -14,8 +16,8 @@ import ( // ResourceServiceServer is a menu service. type ResourceServiceServer struct { pb.UnimplementedResourceServiceServer - client *biz.ResourceServiceBiz + log *log.KHelper } func (s ResourceServiceServer) ListResources(ctx context.Context, request *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { @@ -44,13 +46,16 @@ func (s ResourceServiceServer) DeleteResource(ctx context.Context, request *pb.D //} // NewResourceServiceServer new a menu service. -func NewResourceServiceServer(client *biz.ResourceServiceBiz) *ResourceServiceServer { - return &ResourceServiceServer{client: client} +func NewResourceServiceServer(r runtime.Runtime, client *biz.ResourceServiceBiz) *ResourceServiceServer { + return &ResourceServiceServer{ + log: log.NewHelper(r.WithLogger("module", "service/resource")), + client: client, + } } // NewResourceServiceServerPB new a menu service. -func NewResourceServiceServerPB(client *biz.ResourceServiceBiz) pb.ResourceServiceServer { - return &ResourceServiceServer{client: client} +func NewResourceServiceServerPB(r runtime.Runtime, client *biz.ResourceServiceBiz) pb.ResourceServiceServer { + return NewResourceServiceServer(r, client) } var _ pb.ResourceServiceServer = (*ResourceServiceServer)(nil) diff --git a/internal/mods/system/service/role.agent.go b/internal/mods/system/service/role.bridge.go similarity index 60% rename from internal/mods/system/service/role.agent.go rename to internal/mods/system/service/role.bridge.go index 86d89595..c8da0db8 100644 --- a/internal/mods/system/service/role.agent.go +++ b/internal/mods/system/service/role.bridge.go @@ -16,14 +16,14 @@ import ( "origadmin/application/admin/helpers/resp" ) -// RoleServiceAgent is a menu service. -type RoleServiceAgent struct { +// RoleServiceBridge is a menu service. +type RoleServiceBridge struct { resp.Response client pb.RoleServiceClient } -func (s RoleServiceAgent) CreateRole(ctx context.Context, request *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { +func (s RoleServiceBridge) CreateRole(ctx context.Context, request *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.CreateRole(ctx, request) if err != nil { @@ -36,7 +36,7 @@ func (s RoleServiceAgent) CreateRole(ctx context.Context, request *pb.CreateRole return nil, nil } -func (s RoleServiceAgent) DeleteRole(ctx context.Context, request *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { +func (s RoleServiceBridge) DeleteRole(ctx context.Context, request *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.DeleteRole(ctx, request) if err != nil { @@ -49,7 +49,7 @@ func (s RoleServiceAgent) DeleteRole(ctx context.Context, request *pb.DeleteRole return nil, nil } -func (s RoleServiceAgent) GetRole(ctx context.Context, request *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { +func (s RoleServiceBridge) GetRole(ctx context.Context, request *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.GetRole(ctx, request) if err != nil { @@ -62,7 +62,7 @@ func (s RoleServiceAgent) GetRole(ctx context.Context, request *pb.GetRoleReques return nil, nil } -func (s RoleServiceAgent) ListRoles(ctx context.Context, request *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { +func (s RoleServiceBridge) ListRoles(ctx context.Context, request *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.ListRoles(ctx, request) if err != nil { @@ -76,7 +76,7 @@ func (s RoleServiceAgent) ListRoles(ctx context.Context, request *pb.ListRolesRe return nil, nil } -func (s RoleServiceAgent) UpdateRole(ctx context.Context, request *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { +func (s RoleServiceBridge) UpdateRole(ctx context.Context, request *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.UpdateRole(ctx, request) if err != nil { @@ -89,18 +89,18 @@ func (s RoleServiceAgent) UpdateRole(ctx context.Context, request *pb.UpdateRole return nil, nil } -// NewRoleServiceAgent new a menu service. -func NewRoleServiceAgent(client pb.RoleServiceClient) *RoleServiceAgent { - return &RoleServiceAgent{client: client} +// NewRoleServiceBridge new a menu service. +func NewRoleServiceBridge(client pb.RoleServiceClient) *RoleServiceBridge { + return &RoleServiceBridge{client: client} } -// NewRoleServiceAgentPB new a menu service. -func NewRoleServiceAgentPB(client pb.RoleServiceClient) pb.RoleServiceAgent { - return &RoleServiceAgent{client: client} +// NewRoleServiceBridgePB new a menu service. +func NewRoleServiceBridgePB(client pb.RoleServiceClient) pb.RoleServiceBridge { + return &RoleServiceBridge{client: client} } -func NewRoleServiceAgentClient(client *service.GRPCClient) pb.RoleServiceAgent { +func NewRoleServiceBridgeClient(client *service.GRPCClient) pb.RoleServiceBridge { c := pb.NewRoleServiceClient(client) - return NewRoleServiceAgent(c) + return NewRoleServiceBridge(c) } -var _ pb.RoleServiceAgent = (*RoleServiceAgent)(nil) +var _ pb.RoleServiceBridge = (*RoleServiceBridge)(nil) diff --git a/internal/mods/system/service/role.grpc.go b/internal/mods/system/service/role.grpc.go index 7a979bc5..df9c3917 100644 --- a/internal/mods/system/service/role.grpc.go +++ b/internal/mods/system/service/role.grpc.go @@ -7,6 +7,9 @@ package service import ( "context" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/biz" ) @@ -15,6 +18,7 @@ type RoleServiceServer struct { pb.UnimplementedRoleServiceServer client *biz.RoleServiceBiz + log *log.KHelper } func (s RoleServiceServer) ListRoles(ctx context.Context, req *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { @@ -34,17 +38,18 @@ func (s RoleServiceServer) DeleteRole(ctx context.Context, req *pb.DeleteRoleReq } // NewRoleServiceServer new a user service. -func NewRoleServiceServer(client *biz.RoleServiceBiz) *RoleServiceServer { +func NewRoleServiceServer(r runtime.Runtime, client *biz.RoleServiceBiz) *RoleServiceServer { return &RoleServiceServer{ + log: log.NewHelper(r.WithLogger( + "module", "service/role", + )), client: client, } } // NewRoleServiceServerPB new a user service. -func NewRoleServiceServerPB(client *biz.RoleServiceBiz) pb.RoleServiceServer { - return &RoleServiceServer{ - client: client, - } +func NewRoleServiceServerPB(r runtime.Runtime, client *biz.RoleServiceBiz) pb.RoleServiceServer { + return NewRoleServiceServer(r, client) } var _ pb.RoleServiceServer = (*RoleServiceServer)(nil) diff --git a/internal/mods/system/service/service.go b/internal/mods/system/service/service.go index 68e86eff..3ea2056d 100644 --- a/internal/mods/system/service/service.go +++ b/internal/mods/system/service/service.go @@ -17,8 +17,6 @@ import ( // ProviderSet is service providers. var ProviderSet = wire.NewSet( wire.Struct(new(RegisterServer), "*"), - //NewLoginServiceServerPB, - //NewLoginServiceHTTPServerPB, NewResourceServiceServerPB, NewResourceServiceHTTPServerPB, NewRoleServiceServerPB, @@ -27,51 +25,55 @@ var ProviderSet = wire.NewSet( NewUserServiceHTTPServerPB, NewPersonalServiceServerPB, NewPersonalServiceHTTPServerPB, - //NewAuthServiceServerPB, - //NewAuthServiceHTTPServerPB, NewPermissionServiceServerPB, NewPermissionServiceHTTPServerPB, - //NewCasbinSourceServiceServerPB, + NewRegisterServer, ) type RegisterServer struct { - Resource pb.ResourceServiceServer - Role pb.RoleServiceServer - User pb.UserServiceServer - //Auth pb.AuthServiceServer - //Login pb.LoginServiceServer - //Personal pb.PersonalServiceServer + Resource pb.ResourceServiceServer + Role pb.RoleServiceServer + User pb.UserServiceServer Permission pb.PermissionServiceServer - //Casbin pb.CasbinSourceServiceServer } -func (s RegisterServer) GRPCServer(ctx context.Context, server *service.GRPCServer) { +func (s RegisterServer) Register(ctx context.Context, svc any) { + switch v := svc.(type) { + case *service.GRPCServer: + s.RegisterGRPC(ctx, v) + case *service.HTTPServer: + s.RegisterHTTP(ctx, v) + } +} + +func (s RegisterServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { log.Info("grpc server system init") pb.RegisterResourceServiceServer(server, s.Resource) pb.RegisterRoleServiceServer(server, s.Role) pb.RegisterUserServiceServer(server, s.User) - //pb.RegisterAuthServiceServer(server, s.Auth) - //pb.RegisterLoginServiceServer(server, s.Login) - //pb.RegisterPersonalServiceServer(server, s.Personal) pb.RegisterPermissionServiceServer(server, s.Permission) - //pb.RegisterCasbinSourceServiceServer(server, s.Casbin) } -func (s RegisterServer) HTTPServer(ctx context.Context, server *service.HTTPServer) { +func (s RegisterServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { log.Info("http server system init") pb.RegisterResourceServiceHTTPServer(server, s.Resource) pb.RegisterRoleServiceHTTPServer(server, s.Role) pb.RegisterUserServiceHTTPServer(server, s.User) - //pb.RegisterAuthServiceHTTPServer(server, s.Auth) - //pb.RegisterLoginServiceHTTPServer(server, s.Login) - //pb.RegisterPersonalServiceHTTPServer(server, s.Personal) pb.RegisterPermissionServiceHTTPServer(server, s.Permission) - //pb.RegisterCasbinSourceServiceHTTPServer(server, s.Casbin) } -func (s RegisterServer) Server(ctx context.Context, grpcServer *service.GRPCServer, httpServer *service.HTTPServer) { - s.HTTPServer(ctx, httpServer) - s.GRPCServer(ctx, grpcServer) +func NewRegisterServer( + Resource pb.ResourceServiceServer, + Role pb.RoleServiceServer, + User pb.UserServiceServer, + Permission pb.PermissionServiceServer, +) service.ServerRegistrar { + return &RegisterServer{ + Resource: Resource, + Role: Role, + User: User, + Permission: Permission, + } } -var _ service.ServerRegister = (*RegisterServer)(nil) +var _ service.ServerRegistrar = (*RegisterServer)(nil) diff --git a/internal/mods/system/service/user.agent.go b/internal/mods/system/service/user.bridge.go similarity index 55% rename from internal/mods/system/service/user.agent.go rename to internal/mods/system/service/user.bridge.go index 1a25e354..eb440b2d 100644 --- a/internal/mods/system/service/user.agent.go +++ b/internal/mods/system/service/user.bridge.go @@ -16,14 +16,14 @@ import ( "origadmin/application/admin/helpers/resp" ) -// UserServiceAgent is a menu service. -type UserServiceAgent struct { +// UserServiceBridge is a menu service. +type UserServiceBridge struct { resp.Response client pb.UserServiceClient } -func (s UserServiceAgent) ListUserResources(ctx context.Context, request *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { +func (s UserServiceBridge) ListUserResources(ctx context.Context, request *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.ListUserResources(ctx, request) if err != nil { @@ -36,22 +36,22 @@ func (s UserServiceAgent) ListUserResources(ctx context.Context, request *pb.Lis return nil, nil } -func (s UserServiceAgent) UpdateUserRoles(ctx context.Context, request *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { +func (s UserServiceBridge) UpdateUserRoles(ctx context.Context, request *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { //TODO implement me panic("implement me") } -func (s UserServiceAgent) ResetUserPassword(ctx context.Context, request *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { +func (s UserServiceBridge) ResetUserPassword(ctx context.Context, request *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { //TODO implement me panic("implement me") } -func (s UserServiceAgent) UpdateUserStatus(ctx context.Context, request *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { +func (s UserServiceBridge) UpdateUserStatus(ctx context.Context, request *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { //TODO implement me panic("implement me") } -func (s UserServiceAgent) CreateUser(ctx context.Context, request *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { +func (s UserServiceBridge) CreateUser(ctx context.Context, request *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.CreateUser(ctx, request) if err != nil { @@ -65,7 +65,7 @@ func (s UserServiceAgent) CreateUser(ctx context.Context, request *pb.CreateUser return nil, nil } -func (s UserServiceAgent) DeleteUser(ctx context.Context, request *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { +func (s UserServiceBridge) DeleteUser(ctx context.Context, request *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { httpCtx := agent.FromHTTPContext(ctx) _, err := s.client.DeleteUser(ctx, request) if err != nil { @@ -79,7 +79,7 @@ func (s UserServiceAgent) DeleteUser(ctx context.Context, request *pb.DeleteUser return nil, nil } -func (s UserServiceAgent) GetUser(ctx context.Context, request *pb.GetUserRequest) (*pb.GetUserResponse, error) { +func (s UserServiceBridge) GetUser(ctx context.Context, request *pb.GetUserRequest) (*pb.GetUserResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.GetUser(ctx, request) if err != nil { @@ -92,7 +92,7 @@ func (s UserServiceAgent) GetUser(ctx context.Context, request *pb.GetUserReques return nil, nil } -func (s UserServiceAgent) ListUsers(ctx context.Context, request *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { +func (s UserServiceBridge) ListUsers(ctx context.Context, request *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.ListUsers(ctx, request) if err != nil { @@ -106,7 +106,7 @@ func (s UserServiceAgent) ListUsers(ctx context.Context, request *pb.ListUsersRe return nil, nil } -func (s UserServiceAgent) UpdateUser(ctx context.Context, request *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { +func (s UserServiceBridge) UpdateUser(ctx context.Context, request *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.UpdateUser(ctx, request) if err != nil { @@ -119,18 +119,18 @@ func (s UserServiceAgent) UpdateUser(ctx context.Context, request *pb.UpdateUser return nil, nil } -// NewUserServiceAgent new a menu service. -func NewUserServiceAgent(client pb.UserServiceClient) *UserServiceAgent { - return &UserServiceAgent{client: client} +// NewUserServiceBridge new a menu service. +func NewUserServiceBridge(client pb.UserServiceClient) *UserServiceBridge { + return &UserServiceBridge{client: client} } -// NewUserServiceAgentPB new a menu service. -func NewUserServiceAgentPB(client pb.UserServiceClient) pb.UserServiceAgent { - return &UserServiceAgent{client: client} +// NewUserServiceBridgePB new a menu service. +func NewUserServiceBridgePB(client pb.UserServiceClient) pb.UserServiceBridge { + return &UserServiceBridge{client: client} } -func NewUserServiceAgentClient(client *service.GRPCClient) pb.UserServiceAgent { +func NewUserServiceBridgeClient(client *service.GRPCClient) pb.UserServiceBridge { c := pb.NewUserServiceClient(client) - return NewUserServiceAgent(c) + return NewUserServiceBridge(c) } -var _ pb.UserServiceAgent = (*UserServiceAgent)(nil) +var _ pb.UserServiceBridge = (*UserServiceBridge)(nil) diff --git a/internal/mods/system/service/user.grpc.go b/internal/mods/system/service/user.grpc.go index 09a14b47..00b617b3 100644 --- a/internal/mods/system/service/user.grpc.go +++ b/internal/mods/system/service/user.grpc.go @@ -7,6 +7,9 @@ package service import ( "context" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/mods/system/biz" ) @@ -15,6 +18,7 @@ type UserServiceServer struct { pb.UnimplementedUserServiceServer client *biz.UserServiceBiz + log *log.KHelper } func (s UserServiceServer) ListUserResources(ctx context.Context, request *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { @@ -62,15 +66,18 @@ func (s UserServiceServer) DeleteUser(ctx context.Context, req *pb.DeleteUserReq } // NewUserServiceServer new a user service. -func NewUserServiceServer(client *biz.UserServiceBiz) *UserServiceServer { - return &UserServiceServer{} -} - -// NewUserServiceServerPB new a user service. -func NewUserServiceServerPB(client *biz.UserServiceBiz) pb.UserServiceServer { +func NewUserServiceServer(r runtime.Runtime, client *biz.UserServiceBiz) *UserServiceServer { return &UserServiceServer{ + log: log.NewHelper(r.WithLogger( + "module", "service/user", + )), client: client, } } +// NewUserServiceServerPB new a user service. +func NewUserServiceServerPB(r runtime.Runtime, client *biz.UserServiceBiz) pb.UserServiceServer { + return NewUserServiceServer(r, client) +} + var _ pb.UserServiceServer = (*UserServiceServer)(nil) diff --git a/resources/configs/system/bootstrap.toml b/resources/configs/system/bootstrap.toml index c498cabc..ecfa5f02 100644 --- a/resources/configs/system/bootstrap.toml +++ b/resources/configs/system/bootstrap.toml @@ -7,8 +7,3 @@ Id = "" Environment = "" Services = [] -[Servers] -system = "origadmin.service.system.v1" - -[Entry] -Scheme = "http" \ No newline at end of file diff --git a/resources/configs/system/registry.toml b/resources/configs/system/discovery.toml similarity index 88% rename from resources/configs/system/registry.toml rename to resources/configs/system/discovery.toml index 0112e8be..c631db24 100644 --- a/resources/configs/system/registry.toml +++ b/resources/configs/system/discovery.toml @@ -1,8 +1,8 @@ -[Registry] +[Discovery] Type = "consul" ServiceName = "" Debug = false -[Registry.Consul] +[Discovery.Consul] Address = "${consul_address:127.0.0.1:8500}" Scheme = "http" Token = "" diff --git a/resources/configs/system/logger.toml b/resources/configs/system/logger.toml index 919cd6ed..af585f23 100644 --- a/resources/configs/system/logger.toml +++ b/resources/configs/system/logger.toml @@ -2,15 +2,15 @@ Disabled = false Develop = true Default = true -Name = "output.log" +Name = "" Format = "json" -Level = 2 +Level = "info" Stdout = true DisableCaller = false CallerSkip = 0 TimeFormat = "" [Logger.File] -Path = "logs" +Path = "logs/output.log" Lumberjack = true Compress = false LocalTime = false diff --git a/resources/configs/system/service.toml b/resources/configs/system/service.toml index cf9d8467..5a82f054 100644 --- a/resources/configs/system/service.toml +++ b/resources/configs/system/service.toml @@ -1,67 +1,158 @@ -[Servers] -system = "origadmin.service.system.v1" - -[Service] +[[Server.Services]] Name = "" +Type = "grpc" DynamicEndpoint = true -[Service.Grpc] +[Server.Services.Grpc] Network = "tcp" Addr = "${grpc_address:0.0.0.0:18000}" UseTls = false -CertFile = "" -KeyFile = "" Timeout = 0 ShutdownTimeout = 0 ReadTimeout = 0 WriteTimeout = 0 IdleTimeout = 0 Endpoint = "" -[Service.Http] +[Server.Services.Websocket] +Network = "" +Addr = "" +Path = "" +Codec = "" +Timeout = 0 +[Server.Services.Message] +Type = "none" +Name = "" +[Server.Services.Message.Mqtt] +Endpoint = "" +Codec = "" +[Server.Services.Message.Kafka] +Endpoint = "" +Codec = "" +[Server.Services.Message.Rabbitmq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Activemq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Nats] +Endpoint = "" +Codec = "" +[Server.Services.Message.Nsq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Pulsar] +Endpoint = "" +Codec = "" +[Server.Services.Message.Redis] +Endpoint = "" +Codec = "" +[Server.Services.Message.Rocketmq] +Endpoint = "" +Codec = "" +EnableTrace = false +NameServerDomain = "" +AccessKey = "" +SecretKey = "" +SecurityToken = "" +Namespace = "" +InstanceName = "" +GroupName = "" +[Server.Services.Task] +Type = "none" +Name = "" +[Server.Services.Task.Asynq] +Endpoint = "" +Password = "" +Db = 0 +Location = "" +[Server.Services.Task.Machinery] +[Server.Services.Task.Cron] +Addr = "" +[Server.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Server.Services.Middleware.Metadata] +Enabled = true +Prefix = "" +[Server.Services.Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Server.Services.Middleware.Metrics] +Enabled = true +[Server.Services.Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Server.Services.Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Server.Services.Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Server.Services.Middleware.Selector] +Enabled = false +Regex = "" +[Server.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" + +[[Server.Services]] +Name = "" +Type = "http" +DynamicEndpoint = true +[Server.Services.Http] Network = "tcp" Addr = "${http_address:0.0.0.0:18100}" UseTls = false -CertFile = "" -KeyFile = "" Timeout = 0 ShutdownTimeout = 0 ReadTimeout = 0 WriteTimeout = 0 IdleTimeout = 0 Endpoint = "" -[Service.Websocket] +[Server.Services.Websocket] Network = "" Addr = "" Path = "" Codec = "" Timeout = 0 -[Service.Message] +[Server.Services.Message] Type = "none" Name = "" -[Service.Message.Mqtt] +[Server.Services.Message.Mqtt] Endpoint = "" Codec = "" -[Service.Message.Kafka] +[Server.Services.Message.Kafka] Endpoint = "" Codec = "" -[Service.Message.Rabbitmq] +[Server.Services.Message.Rabbitmq] Endpoint = "" Codec = "" -[Service.Message.Activemq] +[Server.Services.Message.Activemq] Endpoint = "" Codec = "" -[Service.Message.Nats] +[Server.Services.Message.Nats] Endpoint = "" Codec = "" -[Service.Message.Nsq] +[Server.Services.Message.Nsq] Endpoint = "" Codec = "" -[Service.Message.Pulsar] +[Server.Services.Message.Pulsar] Endpoint = "" Codec = "" -[Service.Message.Redis] +[Server.Services.Message.Redis] Endpoint = "" Codec = "" -[Service.Message.Rocketmq] +[Server.Services.Message.Rocketmq] Endpoint = "" Codec = "" EnableTrace = false @@ -72,26 +163,23 @@ SecurityToken = "" Namespace = "" InstanceName = "" GroupName = "" -[Service.Task] +[Server.Services.Task] Type = "none" Name = "" -[Service.Task.Asynq] +[Server.Services.Task.Asynq] Endpoint = "" Password = "" Db = 0 Location = "" -[Service.Task.Machinery] -[Service.Task.Cron] +[Server.Services.Task.Machinery] +[Server.Services.Task.Cron] Addr = "" -[Service.Middleware] -Logging = true -Recovery = true -Tracing = true -CircuitBreaker = true -[Service.Middleware.Metadata] +[Server.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Server.Services.Middleware.Metadata] Enabled = true Prefix = "" -[Service.Middleware.RateLimiter] +[Server.Services.Middleware.RateLimiter] Enabled = true Name = "bbr" Period = 0 @@ -99,27 +187,27 @@ XRatelimitLimit = 0 XRatelimitRemaining = 0 XRatelimitReset = 0 RetryAfter = 0 -[Service.Middleware.Metrics] +[Server.Services.Middleware.Metrics] Enabled = true -[Service.Middleware.Validator] +[Server.Services.Middleware.Validator] Enabled = true Version = 1 FailFast = true -[Service.Middleware.Jwt] +[Server.Services.Middleware.Jwt] Enabled = false Subject = "" ClaimType = "" -[Service.Middleware.Jwt.Config] +[Server.Services.Middleware.Jwt.Config] SigningMethod = "HS512" -Key = "${middleware_jwt_key:12345678901234567890123456789012}" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" Key2 = "can empty next version fixed" AccessTokenLifetime = 900000000000 RefreshTokenLifetime = 259200000000000 Issuer = "localhost" TokenType = "Bearer" -[Service.Middleware.Selector] +[Server.Services.Middleware.Selector] Enabled = false Regex = "" -[Service.Selector] +[Server.Services.Selector] Version = "v1.0.0" -Builder = "bbr" \ No newline at end of file +Builder = "bbr" diff --git a/third_party/auth/v1/auth.proto b/third_party/auth/v1/auth.proto index 81cd71ac..b7a776ed 100644 --- a/third_party/auth/v1/auth.proto +++ b/third_party/auth/v1/auth.proto @@ -7,7 +7,7 @@ import "buf/validate/validate.proto"; option cc_enable_arenas = true; option csharp_namespace = "OrigAdmin.Runtime.Auth.V1"; -option go_package = "github.com/origadmin/runtime/gen/go/auth/v1;authv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/auth/v1;authv1"; option java_multiple_files = true; option java_outer_classname = "AuthProto"; option java_package = "com.github.origadmin.runtime.auth.v1"; diff --git a/third_party/config/v1/service.proto b/third_party/config/v1/service.proto index df623436..b911c14a 100644 --- a/third_party/config/v1/service.proto +++ b/third_party/config/v1/service.proto @@ -22,7 +22,7 @@ message Service { string network = 1; string addr = 2; bool use_tls = 3 [json_name = "use_tls"]; - TLSConfig tls_config = 4 [json_name = "tls_config"]; + config.v1.TLSConfig tls_config = 4 [json_name = "tls_config"]; int64 timeout = 6 [json_name = "timeout"]; int64 shutdown_timeout = 7 [json_name = "shutdown_timeout"]; int64 read_timeout = 8 [json_name = "read_timeout"]; @@ -36,7 +36,7 @@ message Service { string network = 1; string addr = 2; bool use_tls = 3 [json_name = "use_tls"]; - TLSConfig tls_config = 4 [json_name = "tls_config"]; + config.v1.TLSConfig tls_config = 4 [json_name = "tls_config"]; int64 timeout = 6 [json_name = "timeout"]; int64 shutdown_timeout = 7 [json_name = "shutdown_timeout"]; int64 read_timeout = 8 [json_name = "read_timeout"]; @@ -65,6 +65,7 @@ message Service { } ]; bool dynamic_endpoint = 3 [json_name = "dynamic_endpoint"]; + string version = 4 [json_name = "version"]; GRPC grpc = 10 [json_name = "grpc"]; HTTP http = 20 [json_name = "http"]; diff --git a/third_party/fileupload/v1/fileupload.proto b/third_party/fileupload/v1/fileupload.proto index 2fef83ac..e3919898 100644 --- a/third_party/fileupload/v1/fileupload.proto +++ b/third_party/fileupload/v1/fileupload.proto @@ -6,7 +6,7 @@ import "validate/validate.proto"; import "gnostic/openapi/v3/annotations.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/fileupload/v1;fileuploadv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/fileupload/v1;fileuploadv1"; option java_multiple_files = true; option java_outer_classname = "FileUploadProto"; option java_package = "com.github.origadmin.runtime.fileupload"; diff --git a/third_party/middleware/circuitbreaker/v1/circuitbreaker.proto b/third_party/middleware/circuitbreaker/v1/circuitbreaker.proto index 5faf4170..4800520a 100644 --- a/third_party/middleware/circuitbreaker/v1/circuitbreaker.proto +++ b/third_party/middleware/circuitbreaker/v1/circuitbreaker.proto @@ -6,7 +6,7 @@ import "config/v1/gateway.proto"; import "google/protobuf/duration.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/middleware/circuitbreaker/v1;circuitbreakerv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/circuitbreaker/v1;circuitbreakerv1"; option java_multiple_files = true; option java_outer_classname = "CircuitBreakerProto"; option java_package = "com.github.origadmin.runtime.middleware.circuitbreaker.v1"; diff --git a/third_party/middleware/jwt/v1/jwt.proto b/third_party/middleware/jwt/v1/jwt.proto index a62b1ee1..b7085d65 100644 --- a/third_party/middleware/jwt/v1/jwt.proto +++ b/third_party/middleware/jwt/v1/jwt.proto @@ -9,7 +9,7 @@ import "security/jwt/v1/config.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/middleware/jwt/v1;jwtv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/jwt/v1;jwtv1"; option java_multiple_files = true; option java_outer_classname = "JWTProto"; option java_package = "com.github.origadmin.runtime.middleware.jwt.v1"; diff --git a/third_party/middleware/metrics/v1/metrics.proto b/third_party/middleware/metrics/v1/metrics.proto index 3d9deac4..a8b0c487 100644 --- a/third_party/middleware/metrics/v1/metrics.proto +++ b/third_party/middleware/metrics/v1/metrics.proto @@ -5,7 +5,7 @@ package middleware.metrics.v1; import "google/protobuf/timestamp.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/middleware/metrics/v1;metricsv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/metrics/v1;metricsv1"; option java_multiple_files = true; option java_outer_classname = "CircuitBreakerProto"; option java_package = "com.github.origadmin.runtime.middleware.metrics.v1"; diff --git a/third_party/middleware/ratelimit/v1/ratelimiter.proto b/third_party/middleware/ratelimit/v1/ratelimiter.proto index b6f091eb..82a69f92 100644 --- a/third_party/middleware/ratelimit/v1/ratelimiter.proto +++ b/third_party/middleware/ratelimit/v1/ratelimiter.proto @@ -7,7 +7,7 @@ import "google/protobuf/timestamp.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/middleware/ratelimit/v1;ratelimitv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/ratelimit/v1;ratelimitv1"; option java_multiple_files = true; option java_outer_classname = "RateLimitProto"; option java_package = "com.github.origadmin.runtime.middleware.ratelimit.v1"; diff --git a/third_party/middleware/selector/v1/selector.proto b/third_party/middleware/selector/v1/selector.proto index ff8ea792..8893a88b 100644 --- a/third_party/middleware/selector/v1/selector.proto +++ b/third_party/middleware/selector/v1/selector.proto @@ -7,7 +7,7 @@ import "google/protobuf/timestamp.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/middleware/selector/v1;selectorv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/selector/v1;selectorv1"; option java_multiple_files = true; option java_outer_classname = "SelectorProto"; option java_package = "com.github.origadmin.runtime.middleware.selector.v1"; diff --git a/third_party/middleware/validator/v1/validator.proto b/third_party/middleware/validator/v1/validator.proto index aa001052..49a5b726 100644 --- a/third_party/middleware/validator/v1/validator.proto +++ b/third_party/middleware/validator/v1/validator.proto @@ -6,7 +6,7 @@ import "google/protobuf/timestamp.proto"; import "validate/validate.proto"; option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/gen/go/middleware/validator/v1;validatorv1"; +option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/validator/v1;validatorv1"; option java_multiple_files = true; option java_outer_classname = "ValidatorProto"; option java_package = "com.github.origadmin.runtime.middleware.validator.v1"; From b4aea8dfd967130f7879457b52f599484f17c137 Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 30 May 2025 15:46:02 +0800 Subject: [PATCH 027/158] refactor(api): update import paths and rename packages - Change import paths from "system/types.proto" to "types/system.proto" - Rename package "api.v1.services.system" to "api.v1.services.types" - Update service and message definitions across multiple proto files - Refactor type references to use new package names --- api/v1/proto/system/auth.proto | 16 +- api/v1/proto/system/casbin.proto | 21 +- api/v1/proto/system/department.proto | 24 +- api/v1/proto/system/menu.proto | 24 +- api/v1/proto/system/permission.proto | 24 +- api/v1/proto/system/personal.proto | 30 +- api/v1/proto/system/position.proto | 24 +- api/v1/proto/system/resource.proto | 24 +- api/v1/proto/system/role.proto | 24 +- api/v1/proto/system/user.proto | 24 +- .../types.proto => types/system.proto} | 14 +- api/v1/services/system/auth.pb.go | 18 +- api/v1/services/system/auth_agent.pb.go | 194 - api/v1/services/system/auth_bridge.pb.go | 345 + api/v1/services/system/casbin.pb.go | 5 +- api/v1/services/system/casbin_agent.pb.go | 104 - api/v1/services/system/casbin_bridge.pb.go | 195 + api/v1/services/system/department.pb.go | 78 +- api/v1/services/system/department_agent.pb.go | 169 - .../services/system/department_bridge.pb.go | 298 + api/v1/services/system/login_agent.pb.go | 241 - api/v1/services/system/login_bridge.pb.go | 427 ++ api/v1/services/system/menu.pb.go | 70 +- api/v1/services/system/menu_agent.pb.go | 169 - api/v1/services/system/menu_bridge.pb.go | 298 + api/v1/services/system/permission.pb.go | 78 +- api/v1/services/system/permission_agent.pb.go | 169 - .../services/system/permission_bridge.pb.go | 298 + api/v1/services/system/personal.pb.go | 58 +- api/v1/services/system/personal_agent.pb.go | 252 - api/v1/services/system/personal_bridge.pb.go | 446 ++ api/v1/services/system/position.pb.go | 70 +- api/v1/services/system/position_agent.pb.go | 169 - api/v1/services/system/position_bridge.pb.go | 298 + api/v1/services/system/resource.pb.go | 70 +- api/v1/services/system/resource_agent.pb.go | 169 - api/v1/services/system/resource_bridge.pb.go | 298 + api/v1/services/system/role.pb.go | 70 +- api/v1/services/system/role_agent.pb.go | 169 - api/v1/services/system/role_bridge.pb.go | 298 + api/v1/services/system/types.pb.go | 3206 ---------- api/v1/services/system/types.pb.validate.go | 5600 ----------------- api/v1/services/system/user.pb.go | 132 +- api/v1/services/system/user_agent.pb.go | 293 - api/v1/services/system/user_bridge.pb.go | 501 ++ buf.gen.yaml | 2 +- buf.lock | 3 + buf.yaml | 3 + internal/mods/system/service/role.bridge.go | 32 +- resources/docs/openapi/openapi.yaml | 494 +- 50 files changed, 4418 insertions(+), 11620 deletions(-) rename api/v1/proto/{system/types.proto => types/system.proto} (98%) delete mode 100644 api/v1/services/system/auth_agent.pb.go create mode 100644 api/v1/services/system/auth_bridge.pb.go delete mode 100644 api/v1/services/system/casbin_agent.pb.go create mode 100644 api/v1/services/system/casbin_bridge.pb.go delete mode 100644 api/v1/services/system/department_agent.pb.go create mode 100644 api/v1/services/system/department_bridge.pb.go delete mode 100644 api/v1/services/system/login_agent.pb.go create mode 100644 api/v1/services/system/login_bridge.pb.go delete mode 100644 api/v1/services/system/menu_agent.pb.go create mode 100644 api/v1/services/system/menu_bridge.pb.go delete mode 100644 api/v1/services/system/permission_agent.pb.go create mode 100644 api/v1/services/system/permission_bridge.pb.go delete mode 100644 api/v1/services/system/personal_agent.pb.go create mode 100644 api/v1/services/system/personal_bridge.pb.go delete mode 100644 api/v1/services/system/position_agent.pb.go create mode 100644 api/v1/services/system/position_bridge.pb.go delete mode 100644 api/v1/services/system/resource_agent.pb.go create mode 100644 api/v1/services/system/resource_bridge.pb.go delete mode 100644 api/v1/services/system/role_agent.pb.go create mode 100644 api/v1/services/system/role_bridge.pb.go delete mode 100644 api/v1/services/system/types.pb.go delete mode 100644 api/v1/services/system/types.pb.validate.go delete mode 100644 api/v1/services/system/user_agent.pb.go create mode 100644 api/v1/services/system/user_bridge.pb.go diff --git a/api/v1/proto/system/auth.proto b/api/v1/proto/system/auth.proto index dcd8ac7e..b96b1f48 100644 --- a/api/v1/proto/system/auth.proto +++ b/api/v1/proto/system/auth.proto @@ -4,7 +4,7 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; -import "system/types.proto"; +import "types/system.proto"; option go_package = "v1/services/system;system"; option java_multiple_files = true; @@ -13,11 +13,11 @@ option java_package = "com.origadmin.api.v1.services.system"; option objc_class_prefix = "APIServiceSystemAuth"; service AuthService { - rpc ListAuthResources (ListAuthResourcesRequest) returns (ListAuthResourcesResponse) { + rpc ListAuthResources(ListAuthResourcesRequest) returns (ListAuthResourcesResponse) { option (google.api.http) = {get: "/sys/auth/resources"}; } // CreateToken generates a new JWT token for the given user. - rpc CreateToken (CreateTokenRequest) returns (CreateTokenResponse) { + rpc CreateToken(CreateTokenRequest) returns (CreateTokenResponse) { option (google.api.http) = { post: "/sys/auth/token" body: "data" @@ -25,26 +25,26 @@ service AuthService { } // ValidateToken verifies the validity of a JWT token. - rpc ValidateToken (ValidateTokenRequest) returns (ValidateTokenResponse) { + rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse) { option (google.api.http) = {get: "/sys/auth/validate"}; } // DestroyToken invalidates a JWT token. - rpc DestroyToken (DestroyTokenRequest) returns (DestroyTokenResponse) { + rpc DestroyToken(DestroyTokenRequest) returns (DestroyTokenResponse) { option (google.api.http) = { post: "/sys/auth/destroy" body: "data" }; } - rpc Authenticate (AuthenticateRequest) returns (AuthenticateResponse) { + rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) { option (google.api.http) = { post: "/sys/auth/authenticate" body: "data" }; } - rpc AuthLogout (AuthLogoutRequest) returns (AuthLogoutResponse) { + rpc AuthLogout(AuthLogoutRequest) returns (AuthLogoutResponse) { option (google.api.http) = { post: "/sys/auth/logout" body: "data" @@ -76,7 +76,7 @@ message ListAuthResourcesRequest { message ListAuthResourcesResponse { // The list of Auths. - repeated Resource resources = 1 [json_name = "resources"]; + repeated api.v1.services.types.Resource resources = 1 [json_name = "resources"]; // The total number of Auths in the result set. int32 total_size = 2 [json_name = "total_size"]; } diff --git a/api/v1/proto/system/casbin.proto b/api/v1/proto/system/casbin.proto index 6e84dbb3..6d3c16d4 100644 --- a/api/v1/proto/system/casbin.proto +++ b/api/v1/proto/system/casbin.proto @@ -3,47 +3,44 @@ syntax = "proto3"; package api.v1.services.system; import "google/api/annotations.proto"; -import "google/protobuf/any.proto"; -import "google/protobuf/empty.proto"; -import "system/types.proto"; +//import "google/protobuf/any.proto"; +//import "google/protobuf/empty.proto"; +//import "types/system.proto"; option go_package = "v1/services/system;system"; option java_multiple_files = true; -option csharp_namespace = "CasbinOrg.Grpc"; option java_outer_classname = "APIServiceSystemCasbinProto"; option java_package = "com.origadmin.api.v1.services.system"; option objc_class_prefix = "APIServiceSystemCasbin"; // The Casbin source service definition. service CasbinSourceService { - rpc ListPolicies (ListPoliciesRequest) returns (ListPoliciesResponse) { + rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) { option (google.api.http) = { get: "/casbin/policies" response_body: "*" }; } - rpc ListGroupings (ListGroupingsRequest) returns (ListGroupingsResponse) { + rpc ListGroupings(ListGroupingsRequest) returns (ListGroupingsResponse) { option (google.api.http) = { get: "/casbin/groupings" response_body: "*" }; } - rpc WatchUpdate (WatchUpdateRequest) returns (WatchUpdateResponse) { + rpc WatchUpdate(WatchUpdateRequest) returns (WatchUpdateResponse) { option (google.api.http) = { get: "/casbin/watch" response_body: "*" }; } - rpc StreamRules (StreamRulesRequest) returns (stream StreamRulesResponse) { + rpc StreamRules(StreamRulesRequest) returns (stream StreamRulesResponse) { option (google.api.http) = { get: "/casbin/stream" response_body: "*" }; -// (google.api.method_signature) = "with_policies,with_groupings"; + // (google.api.method_signature) = "with_policies,with_groupings"; } - - } message ListPoliciesRequest {} @@ -86,4 +83,4 @@ message WatchUpdateRequest { message WatchUpdateResponse { int64 modified_date = 1 [json_name = "modified_date"]; -} \ No newline at end of file +} diff --git a/api/v1/proto/system/department.proto b/api/v1/proto/system/department.proto index 67ce2c1f..04e0365a 100644 --- a/api/v1/proto/system/department.proto +++ b/api/v1/proto/system/department.proto @@ -5,7 +5,7 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "system/types.proto"; +import "types/system.proto"; option go_package = "v1/services/system;system"; option java_multiple_files = true; @@ -15,25 +15,25 @@ option objc_class_prefix = "APIServiceSystemDepartment"; // The login service definition. service DepartmentService { - rpc ListDepartments (ListDepartmentsRequest) returns (ListDepartmentsResponse) { + rpc ListDepartments(ListDepartmentsRequest) returns (ListDepartmentsResponse) { option (google.api.http) = {get: "/sys/departments"}; } - rpc GetDepartment (GetDepartmentRequest) returns (GetDepartmentResponse) { + rpc GetDepartment(GetDepartmentRequest) returns (GetDepartmentResponse) { option (google.api.http) = {get: "/sys/departments/{id}"}; } - rpc CreateDepartment (CreateDepartmentRequest) returns (CreateDepartmentResponse) { + rpc CreateDepartment(CreateDepartmentRequest) returns (CreateDepartmentResponse) { option (google.api.http) = { post: "/sys/departments" body: "department" }; } - rpc UpdateDepartment (UpdateDepartmentRequest) returns (UpdateDepartmentResponse) { + rpc UpdateDepartment(UpdateDepartmentRequest) returns (UpdateDepartmentResponse) { option (google.api.http) = { put: "/sys/departments/{department.id}" body: "department" }; } - rpc DeleteDepartment (DeleteDepartmentRequest) returns (DeleteDepartmentResponse) { + rpc DeleteDepartment(DeleteDepartmentRequest) returns (DeleteDepartmentResponse) { option (google.api.http) = {delete: "/sys/departments/{id}"}; } } @@ -57,7 +57,7 @@ message ListDepartmentsResponse { // The total number of items in the list. int32 total_size = 1 [json_name = "total_size"]; // The paging menus - repeated Department departments = 2 [json_name = "departments"]; + repeated api.v1.services.types.Department departments = 2 [json_name = "departments"]; // The current page number. int32 current = 3 [json_name = "current"]; // The maximum number of items to return. @@ -77,7 +77,7 @@ message GetDepartmentRequest { } message GetDepartmentResponse { - Department department = 1 [json_name = "department"]; + api.v1.services.types.Department department = 1 [json_name = "department"]; } message CreateDepartmentRequest { @@ -89,22 +89,22 @@ message CreateDepartmentRequest { // The department resource to create. // The field id should match the Noun in the method id. - Department department = 2 [json_name = "department"]; + api.v1.services.types.Department department = 2 [json_name = "department"]; } message CreateDepartmentResponse { - Department department = 1 [json_name = "department"]; + api.v1.services.types.Department department = 1 [json_name = "department"]; } message UpdateDepartmentRequest { // The department id to use for this department. int64 id = 1 [json_name = "id"]; // The department resource which replaces the resource on the server. - Department department = 2 [json_name = "department"]; + api.v1.services.types.Department department = 2 [json_name = "department"]; } message UpdateDepartmentResponse { - Department department = 1 [json_name = "department"]; + api.v1.services.types.Department department = 1 [json_name = "department"]; } message DeleteDepartmentRequest { diff --git a/api/v1/proto/system/menu.proto b/api/v1/proto/system/menu.proto index 54691a40..3c3c80ce 100644 --- a/api/v1/proto/system/menu.proto +++ b/api/v1/proto/system/menu.proto @@ -5,7 +5,7 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "system/types.proto"; +import "types/system.proto"; option go_package = "v1/services/system;system"; option java_multiple_files = true; @@ -15,25 +15,25 @@ option objc_class_prefix = "APIServiceSystemMenu"; // The menu service definition. service MenuService { - rpc ListMenus (ListMenusRequest) returns (ListMenusResponse) { + rpc ListMenus(ListMenusRequest) returns (ListMenusResponse) { option (google.api.http) = {get: "/sys/menus"}; } - rpc GetMenu (GetMenuRequest) returns (GetMenuResponse) { + rpc GetMenu(GetMenuRequest) returns (GetMenuResponse) { option (google.api.http) = {get: "/sys/menus/{id}"}; } - rpc CreateMenu (CreateMenuRequest) returns (CreateMenuResponse) { + rpc CreateMenu(CreateMenuRequest) returns (CreateMenuResponse) { option (google.api.http) = { post: "/sys/menus" body: "menu" }; } - rpc UpdateMenu (UpdateMenuRequest) returns (UpdateMenuResponse) { + rpc UpdateMenu(UpdateMenuRequest) returns (UpdateMenuResponse) { option (google.api.http) = { put: "/sys/menus/{menu.id}" body: "menu" }; } - rpc DeleteMenu (DeleteMenuRequest) returns (DeleteMenuResponse) { + rpc DeleteMenu(DeleteMenuRequest) returns (DeleteMenuResponse) { option (google.api.http) = {delete: "/sys/menus/{id}"}; } } @@ -59,7 +59,7 @@ message ListMenusResponse { // The total number of items in the list. int32 total_size = 1 [json_name = "total_size"]; // The paging menus - repeated Menu menus = 2 [json_name = "menus"]; + repeated api.v1.services.types.Menu menus = 2 [json_name = "menus"]; // The current page number. int32 current = 3 [json_name = "current"]; // The maximum number of items to return. @@ -82,7 +82,7 @@ message GetMenuRequest { // GetMenuResponse is the response for the MenuService.GetMenu method. message GetMenuResponse { // The field id should match the Noun in the method id. - Menu menu = 1; + api.v1.services.types.Menu menu = 1; } // CreateMenuRequest is the request for the MenuService.CreateMenu method. @@ -95,23 +95,23 @@ message CreateMenuRequest { // The menu resource to create. // The field id should match the Noun in the method id. - Menu menu = 2; + api.v1.services.types.Menu menu = 2; } // CreateMenuResponse is the response for the MenuService.CreateMenu method. message CreateMenuResponse { - Menu menu = 1; + api.v1.services.types.Menu menu = 1; } // UpdateMenuRequest is the request for the MenuService.UpdateMenu method. message UpdateMenuRequest { // The menu resource which replaces the resource on the server. - Menu menu = 1; + api.v1.services.types.Menu menu = 1; } // UpdateMenuResponse is the response for the MenuService.UpdateMenu method. message UpdateMenuResponse { - Menu menu = 1; + api.v1.services.types.Menu menu = 1; } // DeleteMenuRequest is the request for the MenuService.DeleteMenu method. diff --git a/api/v1/proto/system/permission.proto b/api/v1/proto/system/permission.proto index 55350541..e7ca8dcd 100644 --- a/api/v1/proto/system/permission.proto +++ b/api/v1/proto/system/permission.proto @@ -5,7 +5,7 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "system/types.proto"; +import "types/system.proto"; option go_package = "v1/services/system;system"; option java_multiple_files = true; @@ -15,25 +15,25 @@ option objc_class_prefix = "APIServiceSystemPermission"; // The login service definition. service PermissionService { - rpc ListPermissions (ListPermissionsRequest) returns (ListPermissionsResponse) { + rpc ListPermissions(ListPermissionsRequest) returns (ListPermissionsResponse) { option (google.api.http) = {get: "/sys/permissions"}; } - rpc GetPermission (GetPermissionRequest) returns (GetPermissionResponse) { + rpc GetPermission(GetPermissionRequest) returns (GetPermissionResponse) { option (google.api.http) = {get: "/sys/permissions/{id}"}; } - rpc CreatePermission (CreatePermissionRequest) returns (CreatePermissionResponse) { + rpc CreatePermission(CreatePermissionRequest) returns (CreatePermissionResponse) { option (google.api.http) = { post: "/sys/permissions" body: "permission" }; } - rpc UpdatePermission (UpdatePermissionRequest) returns (UpdatePermissionResponse) { + rpc UpdatePermission(UpdatePermissionRequest) returns (UpdatePermissionResponse) { option (google.api.http) = { put: "/sys/permissions/{permission.id}" body: "permission" }; } - rpc DeletePermission (DeletePermissionRequest) returns (DeletePermissionResponse) { + rpc DeletePermission(DeletePermissionRequest) returns (DeletePermissionResponse) { option (google.api.http) = {delete: "/sys/permissions/{id}"}; } } @@ -59,7 +59,7 @@ message ListPermissionsResponse { // The total number of items in the list. int32 total_size = 1 [json_name = "total_size"]; // The paging menus - repeated Permission permissions = 2 [json_name = "permissions"]; + repeated api.v1.services.types.Permission permissions = 2 [json_name = "permissions"]; // The current page number. int32 current = 3 [json_name = "current"]; // The maximum number of items to return. @@ -79,7 +79,7 @@ message GetPermissionRequest { } message GetPermissionResponse { - Permission permission = 1 [json_name = "permission"]; + api.v1.services.types.Permission permission = 1 [json_name = "permission"]; } message CreatePermissionRequest { @@ -91,22 +91,22 @@ message CreatePermissionRequest { // The permission resource to create. // The field id should match the Noun in the method id. - Permission permission = 2 [json_name = "permission"]; + api.v1.services.types.Permission permission = 2 [json_name = "permission"]; } message CreatePermissionResponse { - Permission permission = 1 [json_name = "permission"]; + api.v1.services.types.Permission permission = 1 [json_name = "permission"]; } message UpdatePermissionRequest { // The resource name of the permission to update. int64 id = 1 [json_name = "id"]; // The permission resource which replaces the resource on the server. - Permission permission = 2 [json_name = "permission"]; + api.v1.services.types.Permission permission = 2 [json_name = "permission"]; } message UpdatePermissionResponse { - Permission permission = 1 [json_name = "permission"]; + api.v1.services.types.Permission permission = 1 [json_name = "permission"]; } message DeletePermissionRequest { diff --git a/api/v1/proto/system/personal.proto b/api/v1/proto/system/personal.proto index 469457bd..c8028421 100644 --- a/api/v1/proto/system/personal.proto +++ b/api/v1/proto/system/personal.proto @@ -4,7 +4,7 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; -import "system/types.proto"; +import "types/system.proto"; import "validate/validate.proto"; option go_package = "v1/services/system;system"; @@ -15,47 +15,47 @@ option java_package = "com.origadmin.api.v1.services.system"; // PersonalService Personal user service service PersonalService { // GetPersonalProfile Update the personal user information - rpc GetPersonalProfile (GetPersonalProfileRequest) returns (GetPersonalProfileResponse) { + rpc GetPersonalProfile(GetPersonalProfileRequest) returns (GetPersonalProfileResponse) { option (google.api.http) = {get: "/sys/personal/profile"}; } // ListPersonalResources List the personal user's menu - rpc ListPersonalResources (ListPersonalResourcesRequest) returns (ListPersonalResourcesResponse) { + rpc ListPersonalResources(ListPersonalResourcesRequest) returns (ListPersonalResourcesResponse) { option (google.api.http) = {get: "/sys/personal/resources"}; } // ListPersonalResources List the personal user's menu - rpc ListPersonalRoles (ListPersonalRolesRequest) returns (ListPersonalRolesResponse) { + rpc ListPersonalRoles(ListPersonalRolesRequest) returns (ListPersonalRolesResponse) { option (google.api.http) = {get: "/sys/personal/roles"}; } // PersonalLogout Personal user logs out - rpc PersonalLogout (PersonalLogoutRequest) returns (PersonalLogoutResponse) { + rpc PersonalLogout(PersonalLogoutRequest) returns (PersonalLogoutResponse) { option (google.api.http) = { post: "/sys/personal/logout" body: "data" }; } // RefreshPersonalToken Refresh the personal user's token - rpc RefreshPersonalToken (RefreshPersonalTokenRequest) returns (RefreshPersonalTokenResponse) { + rpc RefreshPersonalToken(RefreshPersonalTokenRequest) returns (RefreshPersonalTokenResponse) { option (google.api.http) = { post: "/sys/personal/token/refresh" body: "data" }; } // UpdatePersonalProfilePassword The user changes the password - rpc UpdatePersonalPassword (UpdatePersonalPasswordRequest) returns (UpdatePersonalPasswordResponse) { + rpc UpdatePersonalPassword(UpdatePersonalPasswordRequest) returns (UpdatePersonalPasswordResponse) { option (google.api.http) = { put: "/sys/personal/password" body: "data" }; } // UpdatePersonalProfile Update the personal user information - rpc UpdatePersonalProfile (UpdatePersonalProfileRequest) returns (UpdatePersonalProfileResponse) { + rpc UpdatePersonalProfile(UpdatePersonalProfileRequest) returns (UpdatePersonalProfileResponse) { option (google.api.http) = { put: "/sys/personal/profile" body: "data" }; } // UpdatePersonalSetting User settings are saved - rpc UpdatePersonalSetting (UpdatePersonalSettingRequest) returns (UpdatePersonalSettingResponse) { + rpc UpdatePersonalSetting(UpdatePersonalSettingRequest) returns (UpdatePersonalSettingResponse) { option (google.api.http) = { put: "/sys/personal/setting" body: "data" @@ -70,7 +70,7 @@ message UpdatePersonalSettingRequest { message UpdatePersonalSettingResponse {} message UpdatePersonalRoleRequest { - Role role = 1 [json_name = "role"]; + api.v1.services.types.Role role = 1 [json_name = "role"]; } message UpdatePersonalRoleResponse {} @@ -94,9 +94,9 @@ message ListPersonalResourcesResponse { // The total number of items in the list. int64 total_size = 1 [json_name = "total"]; // list of resources - repeated Resource resources = 2 [json_name = "resources"]; + repeated api.v1.services.types.Resource resources = 2 [json_name = "resources"]; // Token to retrieve the next page of results, or empty if there are no -// more results in the list. + // more results in the list. string next_page_token = 5 [json_name = "next_page_token"]; } @@ -132,13 +132,13 @@ message PersonalLogoutResponse { message ListPersonalRolesRequest {} message ListPersonalRolesResponse { - repeated Role roles = 1; + repeated api.v1.services.types.Role roles = 1; } message GetPersonalProfileRequest {} message GetPersonalProfileResponse { - User user = 1 [json_name = "user"]; + api.v1.services.types.User user = 1 [json_name = "user"]; } message RefreshPersonalTokenRequest { @@ -147,4 +147,4 @@ message RefreshPersonalTokenRequest { message RefreshPersonalTokenResponse { string token = 1 [json_name = "token"]; -} \ No newline at end of file +} diff --git a/api/v1/proto/system/position.proto b/api/v1/proto/system/position.proto index ba469ea6..002191b0 100644 --- a/api/v1/proto/system/position.proto +++ b/api/v1/proto/system/position.proto @@ -5,7 +5,7 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "system/types.proto"; +import "types/system.proto"; option go_package = "v1/services/system;system"; option java_multiple_files = true; @@ -15,25 +15,25 @@ option objc_class_prefix = "APIServiceSystemPosition"; // The login service definition. service PositionService { - rpc ListPositions (ListPositionsRequest) returns (ListPositionsResponse) { + rpc ListPositions(ListPositionsRequest) returns (ListPositionsResponse) { option (google.api.http) = {get: "/sys/positions"}; } - rpc GetPosition (GetPositionRequest) returns (GetPositionResponse) { + rpc GetPosition(GetPositionRequest) returns (GetPositionResponse) { option (google.api.http) = {get: "/sys/positions/{id}"}; } - rpc CreatePosition (CreatePositionRequest) returns (CreatePositionResponse) { + rpc CreatePosition(CreatePositionRequest) returns (CreatePositionResponse) { option (google.api.http) = { post: "/sys/positions" body: "position" }; } - rpc UpdatePosition (UpdatePositionRequest) returns (UpdatePositionResponse) { + rpc UpdatePosition(UpdatePositionRequest) returns (UpdatePositionResponse) { option (google.api.http) = { put: "/sys/positions/{position.id}" body: "position" }; } - rpc DeletePosition (DeletePositionRequest) returns (DeletePositionResponse) { + rpc DeletePosition(DeletePositionRequest) returns (DeletePositionResponse) { option (google.api.http) = {delete: "/sys/positions/{id}"}; } } @@ -57,7 +57,7 @@ message ListPositionsResponse { // The total number of items in the list. int32 total_size = 1 [json_name = "total_size"]; // The paging menus - repeated Position positions = 2 [json_name = "positions"]; + repeated api.v1.services.types.Position positions = 2 [json_name = "positions"]; // The current page number. int32 current = 3 [json_name = "current"]; // The maximum number of items to return. @@ -77,7 +77,7 @@ message GetPositionRequest { } message GetPositionResponse { - Position position = 1 [json_name = "position"]; + api.v1.services.types.Position position = 1 [json_name = "position"]; } message CreatePositionRequest { @@ -86,22 +86,22 @@ message CreatePositionRequest { // The position id to use for this position. string position_id = 2 [json_name = "position_id"]; // The position object to create. - Position position = 3 [json_name = "position"]; + api.v1.services.types.Position position = 3 [json_name = "position"]; } message CreatePositionResponse { - Position position = 1 [json_name = "position"]; + api.v1.services.types.Position position = 1 [json_name = "position"]; } message UpdatePositionRequest { // The id of the position resource to update. int64 id = 1 [json_name = "id"]; // The position resource which replaces the resource on the server. - Position position = 2 [json_name = "position"]; + api.v1.services.types.Position position = 2 [json_name = "position"]; } message UpdatePositionResponse { - Position position = 1 [json_name = "position"]; + api.v1.services.types.Position position = 1 [json_name = "position"]; } message DeletePositionRequest { diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index d29fab3d..2bf46674 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -5,7 +5,7 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "system/types.proto"; +import "types/system.proto"; option go_package = "v1/services/system;system"; option java_multiple_files = true; @@ -15,25 +15,25 @@ option objc_class_prefix = "APIServiceSystemResource"; // The resource service definition. service ResourceService { - rpc ListResources (ListResourcesRequest) returns (ListResourcesResponse) { + rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) { option (google.api.http) = {get: "/sys/resources"}; } - rpc GetResource (GetResourceRequest) returns (GetResourceResponse) { + rpc GetResource(GetResourceRequest) returns (GetResourceResponse) { option (google.api.http) = {get: "/sys/resources/{id}"}; } - rpc CreateResource (CreateResourceRequest) returns (CreateResourceResponse) { + rpc CreateResource(CreateResourceRequest) returns (CreateResourceResponse) { option (google.api.http) = { post: "/sys/resources" body: "resource" }; } - rpc UpdateResource (UpdateResourceRequest) returns (UpdateResourceResponse) { + rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) { option (google.api.http) = { put: "/sys/resources/{resource.id}" body: "resource" }; } - rpc DeleteResource (DeleteResourceRequest) returns (DeleteResourceResponse) { + rpc DeleteResource(DeleteResourceRequest) returns (DeleteResourceResponse) { option (google.api.http) = {delete: "/sys/resources/{id}"}; } } @@ -61,7 +61,7 @@ message ListResourcesResponse { // The total number of items in the list. int32 total_size = 1 [json_name = "total_size"]; // The paging resources - repeated Resource resources = 2 [json_name = "resources"]; + repeated api.v1.services.types.Resource resources = 2 [json_name = "resources"]; // The current page number. int32 current = 3 [json_name = "current"]; // The maximum number of items to return. @@ -84,7 +84,7 @@ message GetResourceRequest { // GetResourceResponse is the response for the ResourceService.GetResource method. message GetResourceResponse { // The field id should match the Noun in the method id. - Resource resource = 1 [json_name = "resource"]; + api.v1.services.types.Resource resource = 1 [json_name = "resource"]; } // CreateResourceRequest is the request for the ResourceService.CreateResource method. @@ -94,12 +94,12 @@ message CreateResourceRequest { // The resource id to use for this resource. string resource_id = 2 [json_name = "resource_id"]; // The resource object to create. - Resource resource = 3 [json_name = "resource"]; + api.v1.services.types.Resource resource = 3 [json_name = "resource"]; } // CreateResourceResponse is the response for the ResourceService.CreateResource method. message CreateResourceResponse { - Resource resource = 1 [json_name = "resource"]; + api.v1.services.types.Resource resource = 1 [json_name = "resource"]; } // UpdateResourceRequest is the request for the ResourceService.UpdateResource method. @@ -107,12 +107,12 @@ message UpdateResourceRequest { // The id of the resource object to update. int64 id = 1 [json_name = "id"]; // The resource object which replaces the resource on the server. - Resource resource = 2 [json_name = "resource"]; + api.v1.services.types.Resource resource = 2 [json_name = "resource"]; } // UpdateResourceResponse is the response for the ResourceService.UpdateResource method. message UpdateResourceResponse { - Resource resource = 1 [json_name = "resource"]; + api.v1.services.types.Resource resource = 1 [json_name = "resource"]; } // DeleteResourceRequest is the request for the ResourceService.DeleteResource method. diff --git a/api/v1/proto/system/role.proto b/api/v1/proto/system/role.proto index cc3747d5..2178e18d 100644 --- a/api/v1/proto/system/role.proto +++ b/api/v1/proto/system/role.proto @@ -5,7 +5,7 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "system/types.proto"; +import "types/system.proto"; option go_package = "v1/services/system;system"; option java_multiple_files = true; @@ -15,25 +15,25 @@ option objc_class_prefix = "APIServiceSystemRole"; // The login service definition. service RoleService { - rpc ListRoles (ListRolesRequest) returns (ListRolesResponse) { + rpc ListRoles(ListRolesRequest) returns (ListRolesResponse) { option (google.api.http) = {get: "/sys/roles"}; } - rpc GetRole (GetRoleRequest) returns (GetRoleResponse) { + rpc GetRole(GetRoleRequest) returns (GetRoleResponse) { option (google.api.http) = {get: "/sys/roles/{id}"}; } - rpc CreateRole (CreateRoleRequest) returns (CreateRoleResponse) { + rpc CreateRole(CreateRoleRequest) returns (CreateRoleResponse) { option (google.api.http) = { post: "/sys/roles" body: "role" }; } - rpc UpdateRole (UpdateRoleRequest) returns (UpdateRoleResponse) { + rpc UpdateRole(UpdateRoleRequest) returns (UpdateRoleResponse) { option (google.api.http) = { put: "/sys/roles/{role.id}" body: "role" }; } - rpc DeleteRole (DeleteRoleRequest) returns (DeleteRoleResponse) { + rpc DeleteRole(DeleteRoleRequest) returns (DeleteRoleResponse) { option (google.api.http) = {delete: "/sys/roles/{id}"}; } } @@ -57,7 +57,7 @@ message ListRolesResponse { // The total number of items in the list. int32 total_size = 1 [json_name = "total_size"]; // The paging menus - repeated Role roles = 2 [json_name = "roles"]; + repeated api.v1.services.types.Role roles = 2 [json_name = "roles"]; // The current page number. int32 current = 3 [json_name = "current"]; // The maximum number of items to return. @@ -77,7 +77,7 @@ message GetRoleRequest { } message GetRoleResponse { - Role role = 1 [json_name = "role"]; + api.v1.services.types.Role role = 1 [json_name = "role"]; } message CreateRoleRequest { @@ -89,22 +89,22 @@ message CreateRoleRequest { // The role resource to create. // The field id should match the Noun in the method id. - Role role = 2 [json_name = "role"]; + api.v1.services.types.Role role = 2 [json_name = "role"]; } message CreateRoleResponse { - Role role = 1 [json_name = "role"]; + api.v1.services.types.Role role = 1 [json_name = "role"]; } message UpdateRoleRequest { // The id of the role resource to update. int64 id = 1 [json_name = "id"]; // The role resource which replaces the resource on the server. - Role role = 2 [json_name = "role"]; + api.v1.services.types.Role role = 2 [json_name = "role"]; } message UpdateRoleResponse { - Role role = 1 [json_name = "role"]; + api.v1.services.types.Role role = 1 [json_name = "role"]; } message DeleteRoleRequest { diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index 97985dc8..de84b687 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -5,7 +5,7 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "system/types.proto"; +import "types/system.proto"; option go_package = "v1/services/system;system"; option java_multiple_files = true; @@ -72,11 +72,11 @@ message ListUserResourcesRequest { message ListUserResourcesResponse { int32 total_size = 1 [json_name = "total_size"]; - repeated Resource resources = 2 [json_name = "resources"]; + repeated api.v1.services.types.Resource resources = 2 [json_name = "resources"]; } message UpdateUserStatusRequest { - User user = 1 [json_name = "user"]; + api.v1.services.types.User user = 1 [json_name = "user"]; } message UpdateUserStatusResponse {} @@ -109,7 +109,7 @@ message ListUsersResponse { // The total number of items in the list. int32 total_size = 1 [json_name = "total_size"]; // The paging menus - repeated User users = 2 [json_name = "users"]; + repeated api.v1.services.types.User users = 2 [json_name = "users"]; // The current page number. int32 current = 3 [json_name = "current"]; // The maximum number of items to return. @@ -129,14 +129,14 @@ message GetUserRequest { } message GetUserResponse { - User user = 1; + api.v1.services.types.User user = 1; } message CreateUserRequest { // The parent resource id where the user is to be created. string parent = 1; // The user resource to be created. - User user = 2; + api.v1.services.types.User user = 2; // The user id to use for this user. string user_id = 3 [json_name = "user_id"]; // The user is_system to use for this user. @@ -146,12 +146,12 @@ message CreateUserRequest { } message CreateUserResponse { - User user = 1; + api.v1.services.types.User user = 1; } message UpdateUserRequest { // The user resource which replaces the resource on the server. - User user = 1; + api.v1.services.types.User user = 1; // The user id to use for this user. string user_id = 3 [json_name = "user_id"]; // The user is_system to use for this user. @@ -161,13 +161,13 @@ message UpdateUserRequest { } message UpdateUserResponse { - User user = 1; + api.v1.services.types.User user = 1; } message DeleteUserRequest { // The resource id of the user to be deleted, for example: // "shelves/shelf1/users/user2" - User user = 1; + api.v1.services.types.User user = 1; } message DeleteUserResponse { @@ -176,11 +176,11 @@ message DeleteUserResponse { message UpdateUserRolesRequest { int64 id = 1; - User user = 2 [json_name = "user"]; + api.v1.services.types.User user = 2 [json_name = "user"]; repeated int64 role_ids = 3 [json_name = "role_ids"]; // bool is_add = 5 [json_name = "is_add"]; } message UpdateUserRolesResponse { - User user = 1 [json_name = "user"]; + api.v1.services.types.User user = 1 [json_name = "user"]; } diff --git a/api/v1/proto/system/types.proto b/api/v1/proto/types/system.proto similarity index 98% rename from api/v1/proto/system/types.proto rename to api/v1/proto/types/system.proto index 472874bb..0ca3a7c0 100644 --- a/api/v1/proto/system/types.proto +++ b/api/v1/proto/types/system.proto @@ -1,14 +1,14 @@ syntax = "proto3"; -package api.v1.services.system; +package api.v1.services.types; import "google/protobuf/timestamp.proto"; -option go_package = "v1/services/system;system"; +option go_package = "v1/services/types;types"; option java_multiple_files = true; -option java_outer_classname = "APIServiceSystemTypeProto"; -option java_package = "com.origadmin.api.v1.services.system"; -option objc_class_prefix = "APIServiceSystemType"; +option java_outer_classname = "APIServiceTypeSystemProto"; +option java_package = "com.origadmin.api.v1.services.types"; +option objc_class_prefix = "APIServiceTypeSystem"; // Menu is the model entity for the Menu schema. message Menu { @@ -87,8 +87,8 @@ message Role { int32 sequence = 8 [json_name = "sequence"]; // role.field.status int32 status = 9 [json_name = "status"]; - // role.field.is_system - bool is_system = 10 [json_name = "is_system"]; + // role.field.is_types + bool is_types = 10 [json_name = "is_types"]; // Menus holds the value of the menus edge. repeated Menu menus = 21 [json_name = "menus"]; // Users holds the value of the users edge. diff --git a/api/v1/services/system/auth.pb.go b/api/v1/services/system/auth.pb.go index d938dea0..d4876653 100644 --- a/api/v1/services/system/auth.pb.go +++ b/api/v1/services/system/auth.pb.go @@ -14,6 +14,7 @@ import ( reflect "reflect" sync "sync" unsafe "unsafe" + types "v1/services/types" ) const ( @@ -186,7 +187,7 @@ func (x *ListAuthResourcesRequest) GetNoPaging() bool { type ListAuthResourcesResponse struct { state protoimpl.MessageState `protogen:"open.v1"` // The list of Auths. - Resources []*Resource `protobuf:"bytes,1,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*types.Resource `protobuf:"bytes,1,rep,name=resources,proto3" json:"resources,omitempty"` // The total number of Auths in the result set. TotalSize int32 `protobuf:"varint,2,opt,name=total_size,proto3" json:"total_size,omitempty"` unknownFields protoimpl.UnknownFields @@ -223,7 +224,7 @@ func (*ListAuthResourcesResponse) Descriptor() ([]byte, []int) { return file_system_auth_proto_rawDescGZIP(), []int{3} } -func (x *ListAuthResourcesResponse) GetResources() []*Resource { +func (x *ListAuthResourcesResponse) GetResources() []*types.Resource { if x != nil { return x.Resources } @@ -815,7 +816,7 @@ var File_system_auth_proto protoreflect.FileDescriptor const file_system_auth_proto_rawDesc = "" + "\n" + - "\x11system/auth.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"u\n" + + "\x11system/auth.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"u\n" + "\x11AuthLogoutRequest\x12B\n" + "\x04data\x18\x01 \x01(\v2..api.v1.services.system.AuthLogoutRequest.DataR\x04data\x1a\x1c\n" + "\x04Data\x12\x14\n" + @@ -828,9 +829,9 @@ const file_system_auth_proto_rawDesc = "" + "page_token\x18\x02 \x01(\tR\n" + "page_token\x12\x18\n" + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tno_paging\x18\x04 \x01(\bR\tno_paging\"{\n" + - "\x19ListAuthResourcesResponse\x12>\n" + - "\tresources\x18\x01 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x12\x1e\n" + + "\tno_paging\x18\x04 \x01(\bR\tno_paging\"z\n" + + "\x19ListAuthResourcesResponse\x12=\n" + + "\tresources\x18\x01 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x1e\n" + "\n" + "total_size\x18\x02 \x01(\x05R\n" + "total_size\"\x93\x01\n" + @@ -906,12 +907,12 @@ var file_system_auth_proto_goTypes = []any{ (*DestroyTokenRequest_Data)(nil), // 15: api.v1.services.system.DestroyTokenRequest.Data (*AuthenticateRequest_Data)(nil), // 16: api.v1.services.system.AuthenticateRequest.Data (*emptypb.Empty)(nil), // 17: google.protobuf.Empty - (*Resource)(nil), // 18: api.v1.services.system.Resource + (*types.Resource)(nil), // 18: api.v1.services.types.Resource } var file_system_auth_proto_depIdxs = []int32{ 12, // 0: api.v1.services.system.AuthLogoutRequest.data:type_name -> api.v1.services.system.AuthLogoutRequest.Data 17, // 1: api.v1.services.system.AuthLogoutResponse.empty:type_name -> google.protobuf.Empty - 18, // 2: api.v1.services.system.ListAuthResourcesResponse.resources:type_name -> api.v1.services.system.Resource + 18, // 2: api.v1.services.system.ListAuthResourcesResponse.resources:type_name -> api.v1.services.types.Resource 13, // 3: api.v1.services.system.CreateTokenRequest.data:type_name -> api.v1.services.system.CreateTokenRequest.Data 14, // 4: api.v1.services.system.ValidateTokenResponse.claims:type_name -> api.v1.services.system.ValidateTokenResponse.ClaimsEntry 15, // 5: api.v1.services.system.DestroyTokenRequest.data:type_name -> api.v1.services.system.DestroyTokenRequest.Data @@ -941,7 +942,6 @@ func file_system_auth_proto_init() { if File_system_auth_proto != nil { return } - file_system_types_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/api/v1/services/system/auth_agent.pb.go b/api/v1/services/system/auth_agent.pb.go deleted file mode 100644 index 1b500a31..00000000 --- a/api/v1/services/system/auth_agent.pb.go +++ /dev/null @@ -1,194 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/auth.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type AuthServiceAgent interface { - AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) - Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) - // CreateToken CreateToken generates a new JWT token for the given user. - CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) - // DestroyToken DestroyToken invalidates a JWT token. - DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) - ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) - // ValidateToken ValidateToken verifies the validity of a JWT token. - ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) -} - -func _AuthService_ListAuthResources0_HTTPAgent_Handler(srv AuthServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListAuthResourcesRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationAuthServiceListAuthResources) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListAuthResourcesResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _AuthService_CreateToken0_HTTPAgent_Handler(srv AuthServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CreateTokenRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationAuthServiceCreateToken) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CreateToken(ctx, req.(*CreateTokenRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CreateTokenResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _AuthService_ValidateToken0_HTTPAgent_Handler(srv AuthServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ValidateTokenRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationAuthServiceValidateToken) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ValidateToken(ctx, req.(*ValidateTokenRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ValidateTokenResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _AuthService_DestroyToken0_HTTPAgent_Handler(srv AuthServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in DestroyTokenRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationAuthServiceDestroyToken) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.DestroyToken(ctx, req.(*DestroyTokenRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*DestroyTokenResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _AuthService_Authenticate0_HTTPAgent_Handler(srv AuthServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in AuthenticateRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationAuthServiceAuthenticate) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.Authenticate(ctx, req.(*AuthenticateRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*AuthenticateResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _AuthService_AuthLogout0_HTTPAgent_Handler(srv AuthServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in AuthLogoutRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationAuthServiceAuthLogout) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.AuthLogout(ctx, req.(*AuthLogoutRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*AuthLogoutResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterAuthServiceAgent(ag agent.HTTPAgent, srv AuthServiceAgent) { - r := ag.Route() - r.GET("/sys/auth/resources", _AuthService_ListAuthResources0_HTTPAgent_Handler(srv)) - r.POST("/sys/auth/token", _AuthService_CreateToken0_HTTPAgent_Handler(srv)) - r.GET("/sys/auth/validate", _AuthService_ValidateToken0_HTTPAgent_Handler(srv)) - r.POST("/sys/auth/destroy", _AuthService_DestroyToken0_HTTPAgent_Handler(srv)) - r.POST("/sys/auth/authenticate", _AuthService_Authenticate0_HTTPAgent_Handler(srv)) - r.POST("/sys/auth/logout", _AuthService_AuthLogout0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/auth_bridge.pb.go b/api/v1/services/system/auth_bridge.pb.go new file mode 100644 index 00000000..9abbf8a8 --- /dev/null +++ b/api/v1/services/system/auth_bridge.pb.go @@ -0,0 +1,345 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/auth.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const AuthServiceAuthLogoutBridgeOperation = "/api.v1.services.system.AuthService/AuthLogout" +const AuthServiceAuthenticateBridgeOperation = "/api.v1.services.system.AuthService/Authenticate" +const AuthServiceCreateTokenBridgeOperation = "/api.v1.services.system.AuthService/CreateToken" +const AuthServiceDestroyTokenBridgeOperation = "/api.v1.services.system.AuthService/DestroyToken" +const AuthServiceListAuthResourcesBridgeOperation = "/api.v1.services.system.AuthService/ListAuthResources" +const AuthServiceValidateTokenBridgeOperation = "/api.v1.services.system.AuthService/ValidateToken" + +type AuthServiceBridger interface { + AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) + Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) + // CreateToken CreateToken generates a new JWT token for the given user. + CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) + // DestroyToken DestroyToken invalidates a JWT token. + DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) + ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) + // ValidateToken ValidateToken verifies the validity of a JWT token. + ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) +} + +type AuthServiceBridgeHooker interface { + AuthServiceBridger + BeforeAuthLogout(http.Context, *AuthLogoutRequest) (context.Context, error) + AuthLogoutResult(http.Context, *AuthLogoutRequest, *AuthLogoutResponse) error + BeforeAuthenticate(http.Context, *AuthenticateRequest) (context.Context, error) + AuthenticateResult(http.Context, *AuthenticateRequest, *AuthenticateResponse) error + // CreateToken CreateToken generates a new JWT token for the given user. + BeforeCreateToken(http.Context, *CreateTokenRequest) (context.Context, error) + CreateTokenResult(http.Context, *CreateTokenRequest, *CreateTokenResponse) error + // DestroyToken DestroyToken invalidates a JWT token. + BeforeDestroyToken(http.Context, *DestroyTokenRequest) (context.Context, error) + DestroyTokenResult(http.Context, *DestroyTokenRequest, *DestroyTokenResponse) error + BeforeListAuthResources(http.Context, *ListAuthResourcesRequest) (context.Context, error) + ListAuthResourcesResult(http.Context, *ListAuthResourcesRequest, *ListAuthResourcesResponse) error + // ValidateToken ValidateToken verifies the validity of a JWT token. + BeforeValidateToken(http.Context, *ValidateTokenRequest) (context.Context, error) + ValidateTokenResult(http.Context, *ValidateTokenRequest, *ValidateTokenResponse) error +} + +func RegisterAuthServiceBridger(s *http.Server, srv AuthServiceBridger) { + r := s.Route("/") + hook, ok := srv.(AuthServiceBridgeHooker) + if !ok { + hook = UnimplementedAuthServiceBridger{AuthServiceBridger: srv} + } + r.GET("/sys/auth/resources", _AuthService_ListAuthResources0_Bridge_Handler(hook)) + r.POST("/sys/auth/token", _AuthService_CreateToken0_Bridge_Handler(hook)) + r.GET("/sys/auth/validate", _AuthService_ValidateToken0_Bridge_Handler(hook)) + r.POST("/sys/auth/destroy", _AuthService_DestroyToken0_Bridge_Handler(hook)) + r.POST("/sys/auth/authenticate", _AuthService_Authenticate0_Bridge_Handler(hook)) + r.POST("/sys/auth/logout", _AuthService_AuthLogout0_Bridge_Handler(hook)) +} + +func _AuthService_ListAuthResources0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListAuthResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceListAuthResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) + }) + + newctx, err := srv.BeforeListAuthResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListAuthResourcesResult(ctx, &in, out.(*ListAuthResourcesResponse)) + } +} + +func _AuthService_CreateToken0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceCreateToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateToken(ctx, req.(*CreateTokenRequest)) + }) + + newctx, err := srv.BeforeCreateToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CreateTokenResult(ctx, &in, out.(*CreateTokenResponse)) + } +} + +func _AuthService_ValidateToken0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ValidateTokenRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceValidateToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ValidateToken(ctx, req.(*ValidateTokenRequest)) + }) + + newctx, err := srv.BeforeValidateToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ValidateTokenResult(ctx, &in, out.(*ValidateTokenResponse)) + } +} + +func _AuthService_DestroyToken0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DestroyTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceDestroyToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DestroyToken(ctx, req.(*DestroyTokenRequest)) + }) + + newctx, err := srv.BeforeDestroyToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.DestroyTokenResult(ctx, &in, out.(*DestroyTokenResponse)) + } +} + +func _AuthService_Authenticate0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in AuthenticateRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceAuthenticate) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Authenticate(ctx, req.(*AuthenticateRequest)) + }) + + newctx, err := srv.BeforeAuthenticate(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.AuthenticateResult(ctx, &in, out.(*AuthenticateResponse)) + } +} + +func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in AuthLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceAuthLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.AuthLogout(ctx, req.(*AuthLogoutRequest)) + }) + + newctx, err := srv.BeforeAuthLogout(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.AuthLogoutResult(ctx, &in, out.(*AuthLogoutResponse)) + } +} + +// UnimplementedAuthServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedAuthServiceBridger struct { + AuthServiceBridger +} + +func (UnimplementedAuthServiceBridger) BeforeAuthLogout(ctx http.Context, in *AuthLogoutRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceBridger) AuthLogoutResult(ctx http.Context, in *AuthLogoutRequest, out *AuthLogoutResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedAuthServiceBridger) BeforeAuthenticate(ctx http.Context, in *AuthenticateRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceBridger) AuthenticateResult(ctx http.Context, in *AuthenticateRequest, out *AuthenticateResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedAuthServiceBridger) BeforeCreateToken(ctx http.Context, in *CreateTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceBridger) CreateTokenResult(ctx http.Context, in *CreateTokenRequest, out *CreateTokenResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedAuthServiceBridger) BeforeDestroyToken(ctx http.Context, in *DestroyTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceBridger) DestroyTokenResult(ctx http.Context, in *DestroyTokenRequest, out *DestroyTokenResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedAuthServiceBridger) BeforeListAuthResources(ctx http.Context, in *ListAuthResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceBridger) ListAuthResourcesResult(ctx http.Context, in *ListAuthResourcesRequest, out *ListAuthResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedAuthServiceBridger) BeforeValidateToken(ctx http.Context, in *ValidateTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceBridger) ValidateTokenResult(ctx http.Context, in *ValidateTokenRequest, out *ValidateTokenResponse) error { + return ctx.Result(200, out) +} + +type AuthServiceHTTPBridgeImpl struct { + client AuthServiceHTTPClient +} + +func NewAuthServiceHTTPBridge(client *http.Client) AuthServiceHTTPServer { + return &AuthServiceHTTPBridgeImpl{client: NewAuthServiceHTTPClient(client)} +} + +func (c *AuthServiceHTTPBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { + return c.client.AuthLogout(ctx, in) +} + +func (c *AuthServiceHTTPBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { + return c.client.Authenticate(ctx, in) +} + +func (c *AuthServiceHTTPBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { + return c.client.CreateToken(ctx, in) +} + +func (c *AuthServiceHTTPBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { + return c.client.DestroyToken(ctx, in) +} + +func (c *AuthServiceHTTPBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { + return c.client.ListAuthResources(ctx, in) +} + +func (c *AuthServiceHTTPBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { + return c.client.ValidateToken(ctx, in) +} + +type AuthServiceBridgeImpl struct { + client AuthServiceClient +} + +func NewAuthServiceBridge(client grpc.ClientConnInterface) AuthServiceServer { + return &AuthServiceBridgeImpl{client: NewAuthServiceClient(client)} +} + +func (c *AuthServiceBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { + return c.client.AuthLogout(ctx, in) +} + +func (c *AuthServiceBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { + return c.client.Authenticate(ctx, in) +} + +func (c *AuthServiceBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { + return c.client.CreateToken(ctx, in) +} + +func (c *AuthServiceBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { + return c.client.DestroyToken(ctx, in) +} + +func (c *AuthServiceBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { + return c.client.ListAuthResources(ctx, in) +} + +func (c *AuthServiceBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { + return c.client.ValidateToken(ctx, in) +} + +func (c *AuthServiceBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} diff --git a/api/v1/services/system/casbin.pb.go b/api/v1/services/system/casbin.pb.go index 6edeefb9..b460505a 100644 --- a/api/v1/services/system/casbin.pb.go +++ b/api/v1/services/system/casbin.pb.go @@ -10,8 +10,6 @@ import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - _ "google.golang.org/protobuf/types/known/anypb" - _ "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" unsafe "unsafe" @@ -514,7 +512,7 @@ var File_system_casbin_proto protoreflect.FileDescriptor const file_system_casbin_proto_rawDesc = "" + "\n" + - "\x13system/casbin.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\x15\n" + + "\x13system/casbin.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\"\x15\n" + "\x13ListPoliciesRequest\"P\n" + "\x14ListPoliciesResponse\x128\n" + "\x05rules\x18\x01 \x03(\v2\".api.v1.services.system.PolicyRuleR\x05rules\"<\n" + @@ -596,7 +594,6 @@ func file_system_casbin_proto_init() { if File_system_casbin_proto != nil { return } - file_system_types_proto_init() file_system_casbin_proto_msgTypes[7].OneofWrappers = []any{ (*StreamRulesResponse_Policy)(nil), (*StreamRulesResponse_Grouping)(nil), diff --git a/api/v1/services/system/casbin_agent.pb.go b/api/v1/services/system/casbin_agent.pb.go deleted file mode 100644 index 433f5419..00000000 --- a/api/v1/services/system/casbin_agent.pb.go +++ /dev/null @@ -1,104 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/casbin.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type CasbinSourceServiceAgent interface { - ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) - ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) - WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) -} - -func _CasbinSourceService_ListPolicies0_HTTPAgent_Handler(srv CasbinSourceServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListPoliciesRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationCasbinSourceServiceListPolicies) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListPolicies(ctx, req.(*ListPoliciesRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListPoliciesResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _CasbinSourceService_ListGroupings0_HTTPAgent_Handler(srv CasbinSourceServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListGroupingsRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationCasbinSourceServiceListGroupings) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListGroupings(ctx, req.(*ListGroupingsRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListGroupingsResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _CasbinSourceService_WatchUpdate0_HTTPAgent_Handler(srv CasbinSourceServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in WatchUpdateRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationCasbinSourceServiceWatchUpdate) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.WatchUpdate(ctx, req.(*WatchUpdateRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*WatchUpdateResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterCasbinSourceServiceAgent(ag agent.HTTPAgent, srv CasbinSourceServiceAgent) { - r := ag.Route() - r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_HTTPAgent_Handler(srv)) - r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_HTTPAgent_Handler(srv)) - r.GET("/casbin/watch", _CasbinSourceService_WatchUpdate0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/casbin_bridge.pb.go b/api/v1/services/system/casbin_bridge.pb.go new file mode 100644 index 00000000..5219e347 --- /dev/null +++ b/api/v1/services/system/casbin_bridge.pb.go @@ -0,0 +1,195 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/casbin.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const CasbinSourceServiceListGroupingsBridgeOperation = "/api.v1.services.system.CasbinSourceService/ListGroupings" +const CasbinSourceServiceListPoliciesBridgeOperation = "/api.v1.services.system.CasbinSourceService/ListPolicies" +const CasbinSourceServiceWatchUpdateBridgeOperation = "/api.v1.services.system.CasbinSourceService/WatchUpdate" + +type CasbinSourceServiceBridger interface { + ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) + ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) + WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) +} + +type CasbinSourceServiceBridgeHooker interface { + CasbinSourceServiceBridger + BeforeListGroupings(http.Context, *ListGroupingsRequest) (context.Context, error) + ListGroupingsResult(http.Context, *ListGroupingsRequest, *ListGroupingsResponse) error + BeforeListPolicies(http.Context, *ListPoliciesRequest) (context.Context, error) + ListPoliciesResult(http.Context, *ListPoliciesRequest, *ListPoliciesResponse) error + BeforeWatchUpdate(http.Context, *WatchUpdateRequest) (context.Context, error) + WatchUpdateResult(http.Context, *WatchUpdateRequest, *WatchUpdateResponse) error +} + +func RegisterCasbinSourceServiceBridger(s *http.Server, srv CasbinSourceServiceBridger) { + r := s.Route("/") + hook, ok := srv.(CasbinSourceServiceBridgeHooker) + if !ok { + hook = UnimplementedCasbinSourceServiceBridger{CasbinSourceServiceBridger: srv} + } + r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_Bridge_Handler(hook)) + r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_Bridge_Handler(hook)) + r.GET("/casbin/watch", _CasbinSourceService_WatchUpdate0_Bridge_Handler(hook)) +} + +func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPoliciesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationCasbinSourceServiceListPolicies) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPolicies(ctx, req.(*ListPoliciesRequest)) + }) + + newctx, err := srv.BeforeListPolicies(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListPoliciesResult(ctx, &in, out.(*ListPoliciesResponse)) + } +} + +func _CasbinSourceService_ListGroupings0_Bridge_Handler(srv CasbinSourceServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListGroupingsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationCasbinSourceServiceListGroupings) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListGroupings(ctx, req.(*ListGroupingsRequest)) + }) + + newctx, err := srv.BeforeListGroupings(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListGroupingsResult(ctx, &in, out.(*ListGroupingsResponse)) + } +} + +func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in WatchUpdateRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationCasbinSourceServiceWatchUpdate) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.WatchUpdate(ctx, req.(*WatchUpdateRequest)) + }) + + newctx, err := srv.BeforeWatchUpdate(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.WatchUpdateResult(ctx, &in, out.(*WatchUpdateResponse)) + } +} + +// UnimplementedCasbinSourceServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedCasbinSourceServiceBridger struct { + CasbinSourceServiceBridger +} + +func (UnimplementedCasbinSourceServiceBridger) BeforeListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedCasbinSourceServiceBridger) ListGroupingsResult(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedCasbinSourceServiceBridger) BeforeListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedCasbinSourceServiceBridger) ListPoliciesResult(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedCasbinSourceServiceBridger) BeforeWatchUpdate(ctx http.Context, in *WatchUpdateRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedCasbinSourceServiceBridger) WatchUpdateResult(ctx http.Context, in *WatchUpdateRequest, out *WatchUpdateResponse) error { + return ctx.Result(200, out) +} + +type CasbinSourceServiceHTTPBridgeImpl struct { + client CasbinSourceServiceHTTPClient +} + +func NewCasbinSourceServiceHTTPBridge(client *http.Client) CasbinSourceServiceHTTPServer { + return &CasbinSourceServiceHTTPBridgeImpl{client: NewCasbinSourceServiceHTTPClient(client)} +} + +func (c *CasbinSourceServiceHTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + +func (c *CasbinSourceServiceHTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { + return c.client.ListPolicies(ctx, in) +} + +func (c *CasbinSourceServiceHTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { + return c.client.WatchUpdate(ctx, in) +} + +type CasbinSourceServiceBridgeImpl struct { + client CasbinSourceServiceClient +} + +func NewCasbinSourceServiceBridge(client grpc.ClientConnInterface) CasbinSourceServiceServer { + return &CasbinSourceServiceBridgeImpl{client: NewCasbinSourceServiceClient(client)} +} + +func (c *CasbinSourceServiceBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + +func (c *CasbinSourceServiceBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { + return c.client.ListPolicies(ctx, in) +} + +func (c *CasbinSourceServiceBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { + return c.client.WatchUpdate(ctx, in) +} + +func (c *CasbinSourceServiceBridgeImpl) mustEmbedUnimplementedCasbinSourceServiceServer() {} diff --git a/api/v1/services/system/department.pb.go b/api/v1/services/system/department.pb.go index 0a5adc7f..cefa38dc 100644 --- a/api/v1/services/system/department.pb.go +++ b/api/v1/services/system/department.pb.go @@ -15,6 +15,7 @@ import ( reflect "reflect" sync "sync" unsafe "unsafe" + types "v1/services/types" ) const ( @@ -119,7 +120,7 @@ type ListDepartmentsResponse struct { // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus - Departments []*Department `protobuf:"bytes,2,rep,name=departments,proto3" json:"departments,omitempty"` + Departments []*types.Department `protobuf:"bytes,2,rep,name=departments,proto3" json:"departments,omitempty"` // The current page number. Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` // The maximum number of items to return. @@ -171,7 +172,7 @@ func (x *ListDepartmentsResponse) GetTotalSize() int32 { return 0 } -func (x *ListDepartmentsResponse) GetDepartments() []*Department { +func (x *ListDepartmentsResponse) GetDepartments() []*types.Department { if x != nil { return x.Departments } @@ -254,7 +255,7 @@ func (x *GetDepartmentRequest) GetId() int64 { type GetDepartmentResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + Department *types.Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -289,7 +290,7 @@ func (*GetDepartmentResponse) Descriptor() ([]byte, []int) { return file_system_department_proto_rawDescGZIP(), []int{3} } -func (x *GetDepartmentResponse) GetDepartment() *Department { +func (x *GetDepartmentResponse) GetDepartment() *types.Department { if x != nil { return x.Department } @@ -304,7 +305,7 @@ type CreateDepartmentRequest struct { DepartmentId string `protobuf:"bytes,3,opt,name=department_id,proto3" json:"department_id,omitempty"` // The department resource to create. // The field id should match the Noun in the method id. - Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + Department *types.Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -353,7 +354,7 @@ func (x *CreateDepartmentRequest) GetDepartmentId() string { return "" } -func (x *CreateDepartmentRequest) GetDepartment() *Department { +func (x *CreateDepartmentRequest) GetDepartment() *types.Department { if x != nil { return x.Department } @@ -362,7 +363,7 @@ func (x *CreateDepartmentRequest) GetDepartment() *Department { type CreateDepartmentResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + Department *types.Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -397,7 +398,7 @@ func (*CreateDepartmentResponse) Descriptor() ([]byte, []int) { return file_system_department_proto_rawDescGZIP(), []int{5} } -func (x *CreateDepartmentResponse) GetDepartment() *Department { +func (x *CreateDepartmentResponse) GetDepartment() *types.Department { if x != nil { return x.Department } @@ -409,7 +410,7 @@ type UpdateDepartmentRequest struct { // The department id to use for this department. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The department resource which replaces the resource on the server. - Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + Department *types.Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -451,7 +452,7 @@ func (x *UpdateDepartmentRequest) GetId() int64 { return 0 } -func (x *UpdateDepartmentRequest) GetDepartment() *Department { +func (x *UpdateDepartmentRequest) GetDepartment() *types.Department { if x != nil { return x.Department } @@ -460,7 +461,7 @@ func (x *UpdateDepartmentRequest) GetDepartment() *Department { type UpdateDepartmentResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + Department *types.Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -495,7 +496,7 @@ func (*UpdateDepartmentResponse) Descriptor() ([]byte, []int) { return file_system_department_proto_rawDescGZIP(), []int{7} } -func (x *UpdateDepartmentResponse) GetDepartment() *Department { +func (x *UpdateDepartmentResponse) GetDepartment() *types.Department { if x != nil { return x.Department } @@ -596,7 +597,7 @@ var File_system_department_proto protoreflect.FileDescriptor const file_system_department_proto_rawDesc = "" + "\n" + - "\x17system/department.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xbe\x01\n" + + "\x17system/department.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xbe\x01\n" + "\x16ListDepartmentsRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + @@ -607,41 +608,41 @@ const file_system_department_proto_rawDesc = "" + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + "\n" + "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\x9c\x02\n" + + "only_count\"\x9b\x02\n" + "\x17ListDepartmentsResponse\x12\x1e\n" + "\n" + "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x12D\n" + - "\vdepartments\x18\x02 \x03(\v2\".api.v1.services.system.DepartmentR\vdepartments\x12\x18\n" + + "total_size\x12C\n" + + "\vdepartments\x18\x02 \x03(\v2!.api.v1.services.types.DepartmentR\vdepartments\x12\x18\n" + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + "\x06_extra\"&\n" + "\x14GetDepartmentRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"[\n" + - "\x15GetDepartmentResponse\x12B\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"Z\n" + + "\x15GetDepartmentResponse\x12A\n" + "\n" + - "department\x18\x01 \x01(\v2\".api.v1.services.system.DepartmentR\n" + - "department\"\x9b\x01\n" + + "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\"\x9a\x01\n" + "\x17CreateDepartmentRequest\x12\x16\n" + "\x06parent\x18\x01 \x01(\tR\x06parent\x12$\n" + - "\rdepartment_id\x18\x03 \x01(\tR\rdepartment_id\x12B\n" + + "\rdepartment_id\x18\x03 \x01(\tR\rdepartment_id\x12A\n" + "\n" + - "department\x18\x02 \x01(\v2\".api.v1.services.system.DepartmentR\n" + - "department\"^\n" + - "\x18CreateDepartmentResponse\x12B\n" + + "department\x18\x02 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\"]\n" + + "\x18CreateDepartmentResponse\x12A\n" + "\n" + - "department\x18\x01 \x01(\v2\".api.v1.services.system.DepartmentR\n" + - "department\"m\n" + + "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\"l\n" + "\x17UpdateDepartmentRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12B\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12A\n" + "\n" + - "department\x18\x02 \x01(\v2\".api.v1.services.system.DepartmentR\n" + - "department\"^\n" + - "\x18UpdateDepartmentResponse\x12B\n" + + "department\x18\x02 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\"]\n" + + "\x18UpdateDepartmentResponse\x12A\n" + "\n" + - "department\x18\x01 \x01(\v2\".api.v1.services.system.DepartmentR\n" + + "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + "department\")\n" + "\x17DeleteDepartmentRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + @@ -681,18 +682,18 @@ var file_system_department_proto_goTypes = []any{ (*UpdateDepartmentResponse)(nil), // 7: api.v1.services.system.UpdateDepartmentResponse (*DeleteDepartmentRequest)(nil), // 8: api.v1.services.system.DeleteDepartmentRequest (*DeleteDepartmentResponse)(nil), // 9: api.v1.services.system.DeleteDepartmentResponse - (*Department)(nil), // 10: api.v1.services.system.Department + (*types.Department)(nil), // 10: api.v1.services.types.Department (*anypb.Any)(nil), // 11: google.protobuf.Any (*emptypb.Empty)(nil), // 12: google.protobuf.Empty } var file_system_department_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListDepartmentsResponse.departments:type_name -> api.v1.services.system.Department + 10, // 0: api.v1.services.system.ListDepartmentsResponse.departments:type_name -> api.v1.services.types.Department 11, // 1: api.v1.services.system.ListDepartmentsResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetDepartmentResponse.department:type_name -> api.v1.services.system.Department - 10, // 3: api.v1.services.system.CreateDepartmentRequest.department:type_name -> api.v1.services.system.Department - 10, // 4: api.v1.services.system.CreateDepartmentResponse.department:type_name -> api.v1.services.system.Department - 10, // 5: api.v1.services.system.UpdateDepartmentRequest.department:type_name -> api.v1.services.system.Department - 10, // 6: api.v1.services.system.UpdateDepartmentResponse.department:type_name -> api.v1.services.system.Department + 10, // 2: api.v1.services.system.GetDepartmentResponse.department:type_name -> api.v1.services.types.Department + 10, // 3: api.v1.services.system.CreateDepartmentRequest.department:type_name -> api.v1.services.types.Department + 10, // 4: api.v1.services.system.CreateDepartmentResponse.department:type_name -> api.v1.services.types.Department + 10, // 5: api.v1.services.system.UpdateDepartmentRequest.department:type_name -> api.v1.services.types.Department + 10, // 6: api.v1.services.system.UpdateDepartmentResponse.department:type_name -> api.v1.services.types.Department 12, // 7: api.v1.services.system.DeleteDepartmentResponse.empty:type_name -> google.protobuf.Empty 0, // 8: api.v1.services.system.DepartmentService.ListDepartments:input_type -> api.v1.services.system.ListDepartmentsRequest 2, // 9: api.v1.services.system.DepartmentService.GetDepartment:input_type -> api.v1.services.system.GetDepartmentRequest @@ -716,7 +717,6 @@ func file_system_department_proto_init() { if File_system_department_proto != nil { return } - file_system_types_proto_init() file_system_department_proto_msgTypes[1].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ diff --git a/api/v1/services/system/department_agent.pb.go b/api/v1/services/system/department_agent.pb.go deleted file mode 100644 index 81fe1ae4..00000000 --- a/api/v1/services/system/department_agent.pb.go +++ /dev/null @@ -1,169 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/department.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type DepartmentServiceAgent interface { - CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) - DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) - GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) - ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) - UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) -} - -func _DepartmentService_ListDepartments0_HTTPAgent_Handler(srv DepartmentServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListDepartmentsRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationDepartmentServiceListDepartments) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListDepartments(ctx, req.(*ListDepartmentsRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListDepartmentsResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _DepartmentService_GetDepartment0_HTTPAgent_Handler(srv DepartmentServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in GetDepartmentRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationDepartmentServiceGetDepartment) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.GetDepartment(ctx, req.(*GetDepartmentRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*GetDepartmentResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _DepartmentService_CreateDepartment0_HTTPAgent_Handler(srv DepartmentServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CreateDepartmentRequest - if err := cctx.Bind(&in.Department); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationDepartmentServiceCreateDepartment) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CreateDepartment(ctx, req.(*CreateDepartmentRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CreateDepartmentResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _DepartmentService_UpdateDepartment0_HTTPAgent_Handler(srv DepartmentServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdateDepartmentRequest - if err := cctx.Bind(&in.Department); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationDepartmentServiceUpdateDepartment) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdateDepartment(ctx, req.(*UpdateDepartmentRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateDepartmentResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _DepartmentService_DeleteDepartment0_HTTPAgent_Handler(srv DepartmentServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in DeleteDepartmentRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationDepartmentServiceDeleteDepartment) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.DeleteDepartment(ctx, req.(*DeleteDepartmentRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteDepartmentResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterDepartmentServiceAgent(ag agent.HTTPAgent, srv DepartmentServiceAgent) { - r := ag.Route() - r.GET("/sys/departments", _DepartmentService_ListDepartments0_HTTPAgent_Handler(srv)) - r.GET("/sys/departments/{id}", _DepartmentService_GetDepartment0_HTTPAgent_Handler(srv)) - r.POST("/sys/departments", _DepartmentService_CreateDepartment0_HTTPAgent_Handler(srv)) - r.PUT("/sys/departments/{department.id}", _DepartmentService_UpdateDepartment0_HTTPAgent_Handler(srv)) - r.DELETE("/sys/departments/{id}", _DepartmentService_DeleteDepartment0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go new file mode 100644 index 00000000..289d83de --- /dev/null +++ b/api/v1/services/system/department_bridge.pb.go @@ -0,0 +1,298 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/department.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const DepartmentServiceCreateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/CreateDepartment" +const DepartmentServiceDeleteDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/DeleteDepartment" +const DepartmentServiceGetDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/GetDepartment" +const DepartmentServiceListDepartmentsBridgeOperation = "/api.v1.services.system.DepartmentService/ListDepartments" +const DepartmentServiceUpdateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/UpdateDepartment" + +type DepartmentServiceBridger interface { + CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) + DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) + GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) + ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) + UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) +} + +type DepartmentServiceBridgeHooker interface { + DepartmentServiceBridger + BeforeCreateDepartment(http.Context, *CreateDepartmentRequest) (context.Context, error) + CreateDepartmentResult(http.Context, *CreateDepartmentRequest, *CreateDepartmentResponse) error + BeforeDeleteDepartment(http.Context, *DeleteDepartmentRequest) (context.Context, error) + DeleteDepartmentResult(http.Context, *DeleteDepartmentRequest, *DeleteDepartmentResponse) error + BeforeGetDepartment(http.Context, *GetDepartmentRequest) (context.Context, error) + GetDepartmentResult(http.Context, *GetDepartmentRequest, *GetDepartmentResponse) error + BeforeListDepartments(http.Context, *ListDepartmentsRequest) (context.Context, error) + ListDepartmentsResult(http.Context, *ListDepartmentsRequest, *ListDepartmentsResponse) error + BeforeUpdateDepartment(http.Context, *UpdateDepartmentRequest) (context.Context, error) + UpdateDepartmentResult(http.Context, *UpdateDepartmentRequest, *UpdateDepartmentResponse) error +} + +func RegisterDepartmentServiceBridger(s *http.Server, srv DepartmentServiceBridger) { + r := s.Route("/") + hook, ok := srv.(DepartmentServiceBridgeHooker) + if !ok { + hook = UnimplementedDepartmentServiceBridger{DepartmentServiceBridger: srv} + } + r.GET("/sys/departments", _DepartmentService_ListDepartments0_Bridge_Handler(hook)) + r.GET("/sys/departments/:id", _DepartmentService_GetDepartment0_Bridge_Handler(hook)) + r.POST("/sys/departments", _DepartmentService_CreateDepartment0_Bridge_Handler(hook)) + r.PUT("/sys/departments/:department.id", _DepartmentService_UpdateDepartment0_Bridge_Handler(hook)) + r.DELETE("/sys/departments/:id", _DepartmentService_DeleteDepartment0_Bridge_Handler(hook)) +} + +func _DepartmentService_ListDepartments0_Bridge_Handler(srv DepartmentServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListDepartmentsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceListDepartments) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListDepartments(ctx, req.(*ListDepartmentsRequest)) + }) + + newctx, err := srv.BeforeListDepartments(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListDepartmentsResult(ctx, &in, out.(*ListDepartmentsResponse)) + } +} + +func _DepartmentService_GetDepartment0_Bridge_Handler(srv DepartmentServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetDepartmentRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceGetDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetDepartment(ctx, req.(*GetDepartmentRequest)) + }) + + newctx, err := srv.BeforeGetDepartment(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.GetDepartmentResult(ctx, &in, out.(*GetDepartmentResponse)) + } +} + +func _DepartmentService_CreateDepartment0_Bridge_Handler(srv DepartmentServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateDepartmentRequest + if err := ctx.Bind(&in.Department); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceCreateDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateDepartment(ctx, req.(*CreateDepartmentRequest)) + }) + + newctx, err := srv.BeforeCreateDepartment(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CreateDepartmentResult(ctx, &in, out.(*CreateDepartmentResponse)) + } +} + +func _DepartmentService_UpdateDepartment0_Bridge_Handler(srv DepartmentServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateDepartmentRequest + if err := ctx.Bind(&in.Department); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceUpdateDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateDepartment(ctx, req.(*UpdateDepartmentRequest)) + }) + + newctx, err := srv.BeforeUpdateDepartment(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdateDepartmentResult(ctx, &in, out.(*UpdateDepartmentResponse)) + } +} + +func _DepartmentService_DeleteDepartment0_Bridge_Handler(srv DepartmentServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteDepartmentRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceDeleteDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteDepartment(ctx, req.(*DeleteDepartmentRequest)) + }) + + newctx, err := srv.BeforeDeleteDepartment(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.DeleteDepartmentResult(ctx, &in, out.(*DeleteDepartmentResponse)) + } +} + +// UnimplementedDepartmentServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedDepartmentServiceBridger struct { + DepartmentServiceBridger +} + +func (UnimplementedDepartmentServiceBridger) BeforeCreateDepartment(ctx http.Context, in *CreateDepartmentRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDepartmentServiceBridger) CreateDepartmentResult(ctx http.Context, in *CreateDepartmentRequest, out *CreateDepartmentResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDepartmentServiceBridger) BeforeDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDepartmentServiceBridger) DeleteDepartmentResult(ctx http.Context, in *DeleteDepartmentRequest, out *DeleteDepartmentResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDepartmentServiceBridger) BeforeGetDepartment(ctx http.Context, in *GetDepartmentRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDepartmentServiceBridger) GetDepartmentResult(ctx http.Context, in *GetDepartmentRequest, out *GetDepartmentResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDepartmentServiceBridger) BeforeListDepartments(ctx http.Context, in *ListDepartmentsRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDepartmentServiceBridger) ListDepartmentsResult(ctx http.Context, in *ListDepartmentsRequest, out *ListDepartmentsResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDepartmentServiceBridger) BeforeUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDepartmentServiceBridger) UpdateDepartmentResult(ctx http.Context, in *UpdateDepartmentRequest, out *UpdateDepartmentResponse) error { + return ctx.Result(200, out) +} + +type DepartmentServiceHTTPBridgeImpl struct { + client DepartmentServiceHTTPClient +} + +func NewDepartmentServiceHTTPBridge(client *http.Client) DepartmentServiceHTTPServer { + return &DepartmentServiceHTTPBridgeImpl{client: NewDepartmentServiceHTTPClient(client)} +} + +func (c *DepartmentServiceHTTPBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTPBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTPBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { + return c.client.GetDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTPBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) +} + +func (c *DepartmentServiceHTTPBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { + return c.client.UpdateDepartment(ctx, in) +} + +type DepartmentServiceBridgeImpl struct { + client DepartmentServiceClient +} + +func NewDepartmentServiceBridge(client grpc.ClientConnInterface) DepartmentServiceServer { + return &DepartmentServiceBridgeImpl{client: NewDepartmentServiceClient(client)} +} + +func (c *DepartmentServiceBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) +} + +func (c *DepartmentServiceBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + +func (c *DepartmentServiceBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { + return c.client.GetDepartment(ctx, in) +} + +func (c *DepartmentServiceBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) +} + +func (c *DepartmentServiceBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { + return c.client.UpdateDepartment(ctx, in) +} + +func (c *DepartmentServiceBridgeImpl) mustEmbedUnimplementedDepartmentServiceServer() {} diff --git a/api/v1/services/system/login_agent.pb.go b/api/v1/services/system/login_agent.pb.go deleted file mode 100644 index 8b52035a..00000000 --- a/api/v1/services/system/login_agent.pb.go +++ /dev/null @@ -1,241 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/login.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type LoginServiceAgent interface { - Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) - CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) - CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) - CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) - Login(context.Context, *LoginRequest) (*LoginResponse, error) - Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) - Register(context.Context, *RegisterRequest) (*RegisterResponse, error) - TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) -} - -func _LoginService_Captcha0_HTTPAgent_Handler(srv LoginServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CaptchaRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationLoginServiceCaptcha) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.Captcha(ctx, req.(*CaptchaRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _LoginService_CaptchaId0_HTTPAgent_Handler(srv LoginServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CaptchaIdRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationLoginServiceCaptchaId) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CaptchaId(ctx, req.(*CaptchaIdRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaIdResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _LoginService_CaptchaImage0_HTTPAgent_Handler(srv LoginServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CaptchaImageRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationLoginServiceCaptchaImage) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CaptchaImage(ctx, req.(*CaptchaImageRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaImageResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _LoginService_CaptchaAudio0_HTTPAgent_Handler(srv LoginServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CaptchaAudioRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationLoginServiceCaptchaAudio) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaAudioResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _LoginService_Login0_HTTPAgent_Handler(srv LoginServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in LoginRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationLoginServiceLogin) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.Login(ctx, req.(*LoginRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*LoginResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _LoginService_Logout0_HTTPAgent_Handler(srv LoginServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in LogoutRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationLoginServiceLogout) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.Logout(ctx, req.(*LogoutRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*LogoutResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _LoginService_Register0_HTTPAgent_Handler(srv LoginServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in RegisterRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationLoginServiceRegister) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.Register(ctx, req.(*RegisterRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*RegisterResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _LoginService_TokenRefresh0_HTTPAgent_Handler(srv LoginServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in TokenRefreshRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationLoginServiceTokenRefresh) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.TokenRefresh(ctx, req.(*TokenRefreshRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*TokenRefreshResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterLoginServiceAgent(ag agent.HTTPAgent, srv LoginServiceAgent) { - r := ag.Route() - r.GET("/captcha", _LoginService_Captcha0_HTTPAgent_Handler(srv)) - r.GET("/captcha/id", _LoginService_CaptchaId0_HTTPAgent_Handler(srv)) - r.GET("/captcha/image", _LoginService_CaptchaImage0_HTTPAgent_Handler(srv)) - r.GET("/captcha/audio", _LoginService_CaptchaAudio0_HTTPAgent_Handler(srv)) - r.POST("/login", _LoginService_Login0_HTTPAgent_Handler(srv)) - r.POST("/logout", _LoginService_Logout0_HTTPAgent_Handler(srv)) - r.POST("/register", _LoginService_Register0_HTTPAgent_Handler(srv)) - r.POST("/token/refresh", _LoginService_TokenRefresh0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/login_bridge.pb.go b/api/v1/services/system/login_bridge.pb.go new file mode 100644 index 00000000..35db2ef5 --- /dev/null +++ b/api/v1/services/system/login_bridge.pb.go @@ -0,0 +1,427 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/login.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const LoginServiceCaptchaBridgeOperation = "/api.v1.services.system.LoginService/Captcha" +const LoginServiceCaptchaAudioBridgeOperation = "/api.v1.services.system.LoginService/CaptchaAudio" +const LoginServiceCaptchaIdBridgeOperation = "/api.v1.services.system.LoginService/CaptchaId" +const LoginServiceCaptchaImageBridgeOperation = "/api.v1.services.system.LoginService/CaptchaImage" +const LoginServiceLoginBridgeOperation = "/api.v1.services.system.LoginService/Login" +const LoginServiceLogoutBridgeOperation = "/api.v1.services.system.LoginService/Logout" +const LoginServiceRegisterBridgeOperation = "/api.v1.services.system.LoginService/Register" +const LoginServiceTokenRefreshBridgeOperation = "/api.v1.services.system.LoginService/TokenRefresh" + +type LoginServiceBridger interface { + Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) + CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) + CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) + CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) + Login(context.Context, *LoginRequest) (*LoginResponse, error) + Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) + Register(context.Context, *RegisterRequest) (*RegisterResponse, error) + TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) +} + +type LoginServiceBridgeHooker interface { + LoginServiceBridger + BeforeCaptcha(http.Context, *CaptchaRequest) (context.Context, error) + CaptchaResult(http.Context, *CaptchaRequest, *CaptchaResponse) error + BeforeCaptchaAudio(http.Context, *CaptchaAudioRequest) (context.Context, error) + CaptchaAudioResult(http.Context, *CaptchaAudioRequest, *CaptchaAudioResponse) error + BeforeCaptchaId(http.Context, *CaptchaIdRequest) (context.Context, error) + CaptchaIdResult(http.Context, *CaptchaIdRequest, *CaptchaIdResponse) error + BeforeCaptchaImage(http.Context, *CaptchaImageRequest) (context.Context, error) + CaptchaImageResult(http.Context, *CaptchaImageRequest, *CaptchaImageResponse) error + BeforeLogin(http.Context, *LoginRequest) (context.Context, error) + LoginResult(http.Context, *LoginRequest, *LoginResponse) error + BeforeLogout(http.Context, *LogoutRequest) (context.Context, error) + LogoutResult(http.Context, *LogoutRequest, *LogoutResponse) error + BeforeRegister(http.Context, *RegisterRequest) (context.Context, error) + RegisterResult(http.Context, *RegisterRequest, *RegisterResponse) error + BeforeTokenRefresh(http.Context, *TokenRefreshRequest) (context.Context, error) + TokenRefreshResult(http.Context, *TokenRefreshRequest, *TokenRefreshResponse) error +} + +func RegisterLoginServiceBridger(s *http.Server, srv LoginServiceBridger) { + r := s.Route("/") + hook, ok := srv.(LoginServiceBridgeHooker) + if !ok { + hook = UnimplementedLoginServiceBridger{LoginServiceBridger: srv} + } + r.GET("/captcha", _LoginService_Captcha0_Bridge_Handler(hook)) + r.GET("/captcha/id", _LoginService_CaptchaId0_Bridge_Handler(hook)) + r.GET("/captcha/image", _LoginService_CaptchaImage0_Bridge_Handler(hook)) + r.GET("/captcha/audio", _LoginService_CaptchaAudio0_Bridge_Handler(hook)) + r.POST("/login", _LoginService_Login0_Bridge_Handler(hook)) + r.POST("/logout", _LoginService_Logout0_Bridge_Handler(hook)) + r.POST("/register", _LoginService_Register0_Bridge_Handler(hook)) + r.POST("/token/refresh", _LoginService_TokenRefresh0_Bridge_Handler(hook)) +} + +func _LoginService_Captcha0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptcha) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Captcha(ctx, req.(*CaptchaRequest)) + }) + + newctx, err := srv.BeforeCaptcha(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CaptchaResult(ctx, &in, out.(*CaptchaResponse)) + } +} + +func _LoginService_CaptchaId0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaIdRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptchaId) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CaptchaId(ctx, req.(*CaptchaIdRequest)) + }) + + newctx, err := srv.BeforeCaptchaId(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CaptchaIdResult(ctx, &in, out.(*CaptchaIdResponse)) + } +} + +func _LoginService_CaptchaImage0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaImageRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptchaImage) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CaptchaImage(ctx, req.(*CaptchaImageRequest)) + }) + + newctx, err := srv.BeforeCaptchaImage(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CaptchaImageResult(ctx, &in, out.(*CaptchaImageResponse)) + } +} + +func _LoginService_CaptchaAudio0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaAudioRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptchaAudio) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) + }) + + newctx, err := srv.BeforeCaptchaAudio(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CaptchaAudioResult(ctx, &in, out.(*CaptchaAudioResponse)) + } +} + +func _LoginService_Login0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in LoginRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceLogin) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Login(ctx, req.(*LoginRequest)) + }) + + newctx, err := srv.BeforeLogin(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.LoginResult(ctx, &in, out.(*LoginResponse)) + } +} + +func _LoginService_Logout0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in LogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Logout(ctx, req.(*LogoutRequest)) + }) + + newctx, err := srv.BeforeLogout(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.LogoutResult(ctx, &in, out.(*LogoutResponse)) + } +} + +func _LoginService_Register0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RegisterRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceRegister) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Register(ctx, req.(*RegisterRequest)) + }) + + newctx, err := srv.BeforeRegister(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.RegisterResult(ctx, &in, out.(*RegisterResponse)) + } +} + +func _LoginService_TokenRefresh0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in TokenRefreshRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceTokenRefresh) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.TokenRefresh(ctx, req.(*TokenRefreshRequest)) + }) + + newctx, err := srv.BeforeTokenRefresh(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.TokenRefreshResult(ctx, &in, out.(*TokenRefreshResponse)) + } +} + +// UnimplementedLoginServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedLoginServiceBridger struct { + LoginServiceBridger +} + +func (UnimplementedLoginServiceBridger) BeforeCaptcha(ctx http.Context, in *CaptchaRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceBridger) CaptchaResult(ctx http.Context, in *CaptchaRequest, out *CaptchaResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceBridger) BeforeCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceBridger) CaptchaAudioResult(ctx http.Context, in *CaptchaAudioRequest, out *CaptchaAudioResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceBridger) BeforeCaptchaId(ctx http.Context, in *CaptchaIdRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceBridger) CaptchaIdResult(ctx http.Context, in *CaptchaIdRequest, out *CaptchaIdResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceBridger) BeforeCaptchaImage(ctx http.Context, in *CaptchaImageRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceBridger) CaptchaImageResult(ctx http.Context, in *CaptchaImageRequest, out *CaptchaImageResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceBridger) BeforeLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceBridger) LoginResult(ctx http.Context, in *LoginRequest, out *LoginResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceBridger) BeforeLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceBridger) LogoutResult(ctx http.Context, in *LogoutRequest, out *LogoutResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceBridger) BeforeRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceBridger) RegisterResult(ctx http.Context, in *RegisterRequest, out *RegisterResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceBridger) BeforeTokenRefresh(ctx http.Context, in *TokenRefreshRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceBridger) TokenRefreshResult(ctx http.Context, in *TokenRefreshRequest, out *TokenRefreshResponse) error { + return ctx.Result(200, out) +} + +type LoginServiceHTTPBridgeImpl struct { + client LoginServiceHTTPClient +} + +func NewLoginServiceHTTPBridge(client *http.Client) LoginServiceHTTPServer { + return &LoginServiceHTTPBridgeImpl{client: NewLoginServiceHTTPClient(client)} +} + +func (c *LoginServiceHTTPBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { + return c.client.Captcha(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { + return c.client.CaptchaAudio(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { + return c.client.CaptchaId(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { + return c.client.CaptchaImage(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { + return c.client.Logout(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { + return c.client.TokenRefresh(ctx, in) +} + +type LoginServiceBridgeImpl struct { + client LoginServiceClient +} + +func NewLoginServiceBridge(client grpc.ClientConnInterface) LoginServiceServer { + return &LoginServiceBridgeImpl{client: NewLoginServiceClient(client)} +} + +func (c *LoginServiceBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { + return c.client.Captcha(ctx, in) +} + +func (c *LoginServiceBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { + return c.client.CaptchaAudio(ctx, in) +} + +func (c *LoginServiceBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { + return c.client.CaptchaId(ctx, in) +} + +func (c *LoginServiceBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { + return c.client.CaptchaImage(ctx, in) +} + +func (c *LoginServiceBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *LoginServiceBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { + return c.client.Logout(ctx, in) +} + +func (c *LoginServiceBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) +} + +func (c *LoginServiceBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { + return c.client.TokenRefresh(ctx, in) +} + +func (c *LoginServiceBridgeImpl) mustEmbedUnimplementedLoginServiceServer() {} diff --git a/api/v1/services/system/menu.pb.go b/api/v1/services/system/menu.pb.go index a27bdba8..f2096c73 100644 --- a/api/v1/services/system/menu.pb.go +++ b/api/v1/services/system/menu.pb.go @@ -15,6 +15,7 @@ import ( reflect "reflect" sync "sync" unsafe "unsafe" + types "v1/services/types" ) const ( @@ -121,7 +122,7 @@ type ListMenusResponse struct { // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus - Menus []*Menu `protobuf:"bytes,2,rep,name=menus,proto3" json:"menus,omitempty"` + Menus []*types.Menu `protobuf:"bytes,2,rep,name=menus,proto3" json:"menus,omitempty"` // The current page number. Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` // The maximum number of items to return. @@ -173,7 +174,7 @@ func (x *ListMenusResponse) GetTotalSize() int32 { return 0 } -func (x *ListMenusResponse) GetMenus() []*Menu { +func (x *ListMenusResponse) GetMenus() []*types.Menu { if x != nil { return x.Menus } @@ -259,7 +260,7 @@ func (x *GetMenuRequest) GetId() int64 { type GetMenuResponse struct { state protoimpl.MessageState `protogen:"open.v1"` // The field id should match the Noun in the method id. - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -294,7 +295,7 @@ func (*GetMenuResponse) Descriptor() ([]byte, []int) { return file_system_menu_proto_rawDescGZIP(), []int{3} } -func (x *GetMenuResponse) GetMenu() *Menu { +func (x *GetMenuResponse) GetMenu() *types.Menu { if x != nil { return x.Menu } @@ -310,7 +311,7 @@ type CreateMenuRequest struct { MenuId string `protobuf:"bytes,3,opt,name=menu_id,json=menuId,proto3" json:"menu_id,omitempty"` // The menu resource to create. // The field id should match the Noun in the method id. - Menu *Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *types.Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -359,7 +360,7 @@ func (x *CreateMenuRequest) GetMenuId() string { return "" } -func (x *CreateMenuRequest) GetMenu() *Menu { +func (x *CreateMenuRequest) GetMenu() *types.Menu { if x != nil { return x.Menu } @@ -369,7 +370,7 @@ func (x *CreateMenuRequest) GetMenu() *Menu { // CreateMenuResponse is the response for the MenuService.CreateMenu method. type CreateMenuResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -404,7 +405,7 @@ func (*CreateMenuResponse) Descriptor() ([]byte, []int) { return file_system_menu_proto_rawDescGZIP(), []int{5} } -func (x *CreateMenuResponse) GetMenu() *Menu { +func (x *CreateMenuResponse) GetMenu() *types.Menu { if x != nil { return x.Menu } @@ -415,7 +416,7 @@ func (x *CreateMenuResponse) GetMenu() *Menu { type UpdateMenuRequest struct { state protoimpl.MessageState `protogen:"open.v1"` // The menu resource which replaces the resource on the server. - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -450,7 +451,7 @@ func (*UpdateMenuRequest) Descriptor() ([]byte, []int) { return file_system_menu_proto_rawDescGZIP(), []int{6} } -func (x *UpdateMenuRequest) GetMenu() *Menu { +func (x *UpdateMenuRequest) GetMenu() *types.Menu { if x != nil { return x.Menu } @@ -460,7 +461,7 @@ func (x *UpdateMenuRequest) GetMenu() *Menu { // UpdateMenuResponse is the response for the MenuService.UpdateMenu method. type UpdateMenuResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -495,7 +496,7 @@ func (*UpdateMenuResponse) Descriptor() ([]byte, []int) { return file_system_menu_proto_rawDescGZIP(), []int{7} } -func (x *UpdateMenuResponse) GetMenu() *Menu { +func (x *UpdateMenuResponse) GetMenu() *types.Menu { if x != nil { return x.Menu } @@ -599,7 +600,7 @@ var File_system_menu_proto protoreflect.FileDescriptor const file_system_menu_proto_rawDesc = "" + "\n" + - "\x11system/menu.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xb4\x01\n" + + "\x11system/menu.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xb4\x01\n" + "\x10ListMenusRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1b\n" + @@ -608,31 +609,31 @@ const file_system_menu_proto_rawDesc = "" + "page_token\x18\x04 \x01(\tR\tpageToken\x12\x1b\n" + "\tno_paging\x18\x05 \x01(\bR\bnoPaging\x12\x1d\n" + "\n" + - "only_count\x18\x06 \x01(\bR\tonlyCount\"\x84\x02\n" + + "only_count\x18\x06 \x01(\bR\tonlyCount\"\x83\x02\n" + "\x11ListMenusResponse\x12\x1e\n" + "\n" + "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x122\n" + - "\x05menus\x18\x02 \x03(\v2\x1c.api.v1.services.system.MenuR\x05menus\x12\x18\n" + + "total_size\x121\n" + + "\x05menus\x18\x02 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x12\x18\n" + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + "\x06_extra\" \n" + "\x0eGetMenuRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"C\n" + - "\x0fGetMenuResponse\x120\n" + - "\x04menu\x18\x01 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"v\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x0fGetMenuResponse\x12/\n" + + "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"u\n" + "\x11CreateMenuRequest\x12\x16\n" + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x17\n" + - "\amenu_id\x18\x03 \x01(\tR\x06menuId\x120\n" + - "\x04menu\x18\x02 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"F\n" + - "\x12CreateMenuResponse\x120\n" + - "\x04menu\x18\x01 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"E\n" + - "\x11UpdateMenuRequest\x120\n" + - "\x04menu\x18\x01 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"F\n" + - "\x12UpdateMenuResponse\x120\n" + - "\x04menu\x18\x01 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"#\n" + + "\amenu_id\x18\x03 \x01(\tR\x06menuId\x12/\n" + + "\x04menu\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"E\n" + + "\x12CreateMenuResponse\x12/\n" + + "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"D\n" + + "\x11UpdateMenuRequest\x12/\n" + + "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"E\n" + + "\x12UpdateMenuResponse\x12/\n" + + "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"#\n" + "\x11DeleteMenuRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + "\x12DeleteMenuResponse\x12,\n" + @@ -674,18 +675,18 @@ var file_system_menu_proto_goTypes = []any{ (*UpdateMenuResponse)(nil), // 7: api.v1.services.system.UpdateMenuResponse (*DeleteMenuRequest)(nil), // 8: api.v1.services.system.DeleteMenuRequest (*DeleteMenuResponse)(nil), // 9: api.v1.services.system.DeleteMenuResponse - (*Menu)(nil), // 10: api.v1.services.system.Menu + (*types.Menu)(nil), // 10: api.v1.services.types.Menu (*anypb.Any)(nil), // 11: google.protobuf.Any (*emptypb.Empty)(nil), // 12: google.protobuf.Empty } var file_system_menu_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListMenusResponse.menus:type_name -> api.v1.services.system.Menu + 10, // 0: api.v1.services.system.ListMenusResponse.menus:type_name -> api.v1.services.types.Menu 11, // 1: api.v1.services.system.ListMenusResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetMenuResponse.menu:type_name -> api.v1.services.system.Menu - 10, // 3: api.v1.services.system.CreateMenuRequest.menu:type_name -> api.v1.services.system.Menu - 10, // 4: api.v1.services.system.CreateMenuResponse.menu:type_name -> api.v1.services.system.Menu - 10, // 5: api.v1.services.system.UpdateMenuRequest.menu:type_name -> api.v1.services.system.Menu - 10, // 6: api.v1.services.system.UpdateMenuResponse.menu:type_name -> api.v1.services.system.Menu + 10, // 2: api.v1.services.system.GetMenuResponse.menu:type_name -> api.v1.services.types.Menu + 10, // 3: api.v1.services.system.CreateMenuRequest.menu:type_name -> api.v1.services.types.Menu + 10, // 4: api.v1.services.system.CreateMenuResponse.menu:type_name -> api.v1.services.types.Menu + 10, // 5: api.v1.services.system.UpdateMenuRequest.menu:type_name -> api.v1.services.types.Menu + 10, // 6: api.v1.services.system.UpdateMenuResponse.menu:type_name -> api.v1.services.types.Menu 12, // 7: api.v1.services.system.DeleteMenuResponse.empty:type_name -> google.protobuf.Empty 0, // 8: api.v1.services.system.MenuService.ListMenus:input_type -> api.v1.services.system.ListMenusRequest 2, // 9: api.v1.services.system.MenuService.GetMenu:input_type -> api.v1.services.system.GetMenuRequest @@ -709,7 +710,6 @@ func file_system_menu_proto_init() { if File_system_menu_proto != nil { return } - file_system_types_proto_init() file_system_menu_proto_msgTypes[1].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ diff --git a/api/v1/services/system/menu_agent.pb.go b/api/v1/services/system/menu_agent.pb.go deleted file mode 100644 index 5ceececc..00000000 --- a/api/v1/services/system/menu_agent.pb.go +++ /dev/null @@ -1,169 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/menu.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type MenuServiceAgent interface { - CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) - DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) - GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) - ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) - UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) -} - -func _MenuService_ListMenus0_HTTPAgent_Handler(srv MenuServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListMenusRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationMenuServiceListMenus) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListMenus(ctx, req.(*ListMenusRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListMenusResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _MenuService_GetMenu0_HTTPAgent_Handler(srv MenuServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in GetMenuRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationMenuServiceGetMenu) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.GetMenu(ctx, req.(*GetMenuRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*GetMenuResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _MenuService_CreateMenu0_HTTPAgent_Handler(srv MenuServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CreateMenuRequest - if err := cctx.Bind(&in.Menu); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationMenuServiceCreateMenu) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CreateMenu(ctx, req.(*CreateMenuRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CreateMenuResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _MenuService_UpdateMenu0_HTTPAgent_Handler(srv MenuServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdateMenuRequest - if err := cctx.Bind(&in.Menu); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationMenuServiceUpdateMenu) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdateMenu(ctx, req.(*UpdateMenuRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateMenuResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _MenuService_DeleteMenu0_HTTPAgent_Handler(srv MenuServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in DeleteMenuRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationMenuServiceDeleteMenu) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.DeleteMenu(ctx, req.(*DeleteMenuRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteMenuResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterMenuServiceAgent(ag agent.HTTPAgent, srv MenuServiceAgent) { - r := ag.Route() - r.GET("/sys/menus", _MenuService_ListMenus0_HTTPAgent_Handler(srv)) - r.GET("/sys/menus/{id}", _MenuService_GetMenu0_HTTPAgent_Handler(srv)) - r.POST("/sys/menus", _MenuService_CreateMenu0_HTTPAgent_Handler(srv)) - r.PUT("/sys/menus/{menu.id}", _MenuService_UpdateMenu0_HTTPAgent_Handler(srv)) - r.DELETE("/sys/menus/{id}", _MenuService_DeleteMenu0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/menu_bridge.pb.go b/api/v1/services/system/menu_bridge.pb.go new file mode 100644 index 00000000..f0176ce7 --- /dev/null +++ b/api/v1/services/system/menu_bridge.pb.go @@ -0,0 +1,298 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/menu.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const MenuServiceCreateMenuBridgeOperation = "/api.v1.services.system.MenuService/CreateMenu" +const MenuServiceDeleteMenuBridgeOperation = "/api.v1.services.system.MenuService/DeleteMenu" +const MenuServiceGetMenuBridgeOperation = "/api.v1.services.system.MenuService/GetMenu" +const MenuServiceListMenusBridgeOperation = "/api.v1.services.system.MenuService/ListMenus" +const MenuServiceUpdateMenuBridgeOperation = "/api.v1.services.system.MenuService/UpdateMenu" + +type MenuServiceBridger interface { + CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) + DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) + GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) + ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) + UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) +} + +type MenuServiceBridgeHooker interface { + MenuServiceBridger + BeforeCreateMenu(http.Context, *CreateMenuRequest) (context.Context, error) + CreateMenuResult(http.Context, *CreateMenuRequest, *CreateMenuResponse) error + BeforeDeleteMenu(http.Context, *DeleteMenuRequest) (context.Context, error) + DeleteMenuResult(http.Context, *DeleteMenuRequest, *DeleteMenuResponse) error + BeforeGetMenu(http.Context, *GetMenuRequest) (context.Context, error) + GetMenuResult(http.Context, *GetMenuRequest, *GetMenuResponse) error + BeforeListMenus(http.Context, *ListMenusRequest) (context.Context, error) + ListMenusResult(http.Context, *ListMenusRequest, *ListMenusResponse) error + BeforeUpdateMenu(http.Context, *UpdateMenuRequest) (context.Context, error) + UpdateMenuResult(http.Context, *UpdateMenuRequest, *UpdateMenuResponse) error +} + +func RegisterMenuServiceBridger(s *http.Server, srv MenuServiceBridger) { + r := s.Route("/") + hook, ok := srv.(MenuServiceBridgeHooker) + if !ok { + hook = UnimplementedMenuServiceBridger{MenuServiceBridger: srv} + } + r.GET("/sys/menus", _MenuService_ListMenus0_Bridge_Handler(hook)) + r.GET("/sys/menus/:id", _MenuService_GetMenu0_Bridge_Handler(hook)) + r.POST("/sys/menus", _MenuService_CreateMenu0_Bridge_Handler(hook)) + r.PUT("/sys/menus/:menu.id", _MenuService_UpdateMenu0_Bridge_Handler(hook)) + r.DELETE("/sys/menus/:id", _MenuService_DeleteMenu0_Bridge_Handler(hook)) +} + +func _MenuService_ListMenus0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListMenusRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceListMenus) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListMenus(ctx, req.(*ListMenusRequest)) + }) + + newctx, err := srv.BeforeListMenus(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListMenusResult(ctx, &in, out.(*ListMenusResponse)) + } +} + +func _MenuService_GetMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetMenuRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceGetMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetMenu(ctx, req.(*GetMenuRequest)) + }) + + newctx, err := srv.BeforeGetMenu(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.GetMenuResult(ctx, &in, out.(*GetMenuResponse)) + } +} + +func _MenuService_CreateMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateMenuRequest + if err := ctx.Bind(&in.Menu); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceCreateMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateMenu(ctx, req.(*CreateMenuRequest)) + }) + + newctx, err := srv.BeforeCreateMenu(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CreateMenuResult(ctx, &in, out.(*CreateMenuResponse)) + } +} + +func _MenuService_UpdateMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateMenuRequest + if err := ctx.Bind(&in.Menu); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceUpdateMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateMenu(ctx, req.(*UpdateMenuRequest)) + }) + + newctx, err := srv.BeforeUpdateMenu(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdateMenuResult(ctx, &in, out.(*UpdateMenuResponse)) + } +} + +func _MenuService_DeleteMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteMenuRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceDeleteMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteMenu(ctx, req.(*DeleteMenuRequest)) + }) + + newctx, err := srv.BeforeDeleteMenu(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.DeleteMenuResult(ctx, &in, out.(*DeleteMenuResponse)) + } +} + +// UnimplementedMenuServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMenuServiceBridger struct { + MenuServiceBridger +} + +func (UnimplementedMenuServiceBridger) BeforeCreateMenu(ctx http.Context, in *CreateMenuRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMenuServiceBridger) CreateMenuResult(ctx http.Context, in *CreateMenuRequest, out *CreateMenuResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedMenuServiceBridger) BeforeDeleteMenu(ctx http.Context, in *DeleteMenuRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMenuServiceBridger) DeleteMenuResult(ctx http.Context, in *DeleteMenuRequest, out *DeleteMenuResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedMenuServiceBridger) BeforeGetMenu(ctx http.Context, in *GetMenuRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMenuServiceBridger) GetMenuResult(ctx http.Context, in *GetMenuRequest, out *GetMenuResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedMenuServiceBridger) BeforeListMenus(ctx http.Context, in *ListMenusRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMenuServiceBridger) ListMenusResult(ctx http.Context, in *ListMenusRequest, out *ListMenusResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedMenuServiceBridger) BeforeUpdateMenu(ctx http.Context, in *UpdateMenuRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMenuServiceBridger) UpdateMenuResult(ctx http.Context, in *UpdateMenuRequest, out *UpdateMenuResponse) error { + return ctx.Result(200, out) +} + +type MenuServiceHTTPBridgeImpl struct { + client MenuServiceHTTPClient +} + +func NewMenuServiceHTTPBridge(client *http.Client) MenuServiceHTTPServer { + return &MenuServiceHTTPBridgeImpl{client: NewMenuServiceHTTPClient(client)} +} + +func (c *MenuServiceHTTPBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { + return c.client.CreateMenu(ctx, in) +} + +func (c *MenuServiceHTTPBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { + return c.client.DeleteMenu(ctx, in) +} + +func (c *MenuServiceHTTPBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { + return c.client.GetMenu(ctx, in) +} + +func (c *MenuServiceHTTPBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { + return c.client.ListMenus(ctx, in) +} + +func (c *MenuServiceHTTPBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { + return c.client.UpdateMenu(ctx, in) +} + +type MenuServiceBridgeImpl struct { + client MenuServiceClient +} + +func NewMenuServiceBridge(client grpc.ClientConnInterface) MenuServiceServer { + return &MenuServiceBridgeImpl{client: NewMenuServiceClient(client)} +} + +func (c *MenuServiceBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { + return c.client.CreateMenu(ctx, in) +} + +func (c *MenuServiceBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { + return c.client.DeleteMenu(ctx, in) +} + +func (c *MenuServiceBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { + return c.client.GetMenu(ctx, in) +} + +func (c *MenuServiceBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { + return c.client.ListMenus(ctx, in) +} + +func (c *MenuServiceBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { + return c.client.UpdateMenu(ctx, in) +} + +func (c *MenuServiceBridgeImpl) mustEmbedUnimplementedMenuServiceServer() {} diff --git a/api/v1/services/system/permission.pb.go b/api/v1/services/system/permission.pb.go index 1baf3503..44617a30 100644 --- a/api/v1/services/system/permission.pb.go +++ b/api/v1/services/system/permission.pb.go @@ -15,6 +15,7 @@ import ( reflect "reflect" sync "sync" unsafe "unsafe" + types "v1/services/types" ) const ( @@ -128,7 +129,7 @@ type ListPermissionsResponse struct { // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus - Permissions []*Permission `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty"` + Permissions []*types.Permission `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty"` // The current page number. Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` // The maximum number of items to return. @@ -180,7 +181,7 @@ func (x *ListPermissionsResponse) GetTotalSize() int32 { return 0 } -func (x *ListPermissionsResponse) GetPermissions() []*Permission { +func (x *ListPermissionsResponse) GetPermissions() []*types.Permission { if x != nil { return x.Permissions } @@ -263,7 +264,7 @@ func (x *GetPermissionRequest) GetId() int64 { type GetPermissionResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + Permission *types.Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -298,7 +299,7 @@ func (*GetPermissionResponse) Descriptor() ([]byte, []int) { return file_system_permission_proto_rawDescGZIP(), []int{3} } -func (x *GetPermissionResponse) GetPermission() *Permission { +func (x *GetPermissionResponse) GetPermission() *types.Permission { if x != nil { return x.Permission } @@ -313,7 +314,7 @@ type CreatePermissionRequest struct { PermissionId string `protobuf:"bytes,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` // The permission resource to create. // The field id should match the Noun in the method id. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + Permission *types.Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -362,7 +363,7 @@ func (x *CreatePermissionRequest) GetPermissionId() string { return "" } -func (x *CreatePermissionRequest) GetPermission() *Permission { +func (x *CreatePermissionRequest) GetPermission() *types.Permission { if x != nil { return x.Permission } @@ -371,7 +372,7 @@ func (x *CreatePermissionRequest) GetPermission() *Permission { type CreatePermissionResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + Permission *types.Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -406,7 +407,7 @@ func (*CreatePermissionResponse) Descriptor() ([]byte, []int) { return file_system_permission_proto_rawDescGZIP(), []int{5} } -func (x *CreatePermissionResponse) GetPermission() *Permission { +func (x *CreatePermissionResponse) GetPermission() *types.Permission { if x != nil { return x.Permission } @@ -418,7 +419,7 @@ type UpdatePermissionRequest struct { // The resource name of the permission to update. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The permission resource which replaces the resource on the server. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + Permission *types.Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -460,7 +461,7 @@ func (x *UpdatePermissionRequest) GetId() int64 { return 0 } -func (x *UpdatePermissionRequest) GetPermission() *Permission { +func (x *UpdatePermissionRequest) GetPermission() *types.Permission { if x != nil { return x.Permission } @@ -469,7 +470,7 @@ func (x *UpdatePermissionRequest) GetPermission() *Permission { type UpdatePermissionResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + Permission *types.Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -504,7 +505,7 @@ func (*UpdatePermissionResponse) Descriptor() ([]byte, []int) { return file_system_permission_proto_rawDescGZIP(), []int{7} } -func (x *UpdatePermissionResponse) GetPermission() *Permission { +func (x *UpdatePermissionResponse) GetPermission() *types.Permission { if x != nil { return x.Permission } @@ -605,7 +606,7 @@ var File_system_permission_proto protoreflect.FileDescriptor const file_system_permission_proto_rawDesc = "" + "\n" + - "\x17system/permission.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xe0\x01\n" + + "\x17system/permission.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xe0\x01\n" + "\x16ListPermissionsRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + @@ -617,41 +618,41 @@ const file_system_permission_proto_rawDesc = "" + "\n" + "only_count\x18\x06 \x01(\bR\n" + "only_count\x12 \n" + - "\vdata_scopes\x18\a \x03(\tR\vdata_scopes\"\x9c\x02\n" + + "\vdata_scopes\x18\a \x03(\tR\vdata_scopes\"\x9b\x02\n" + "\x17ListPermissionsResponse\x12\x1e\n" + "\n" + "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x12D\n" + - "\vpermissions\x18\x02 \x03(\v2\".api.v1.services.system.PermissionR\vpermissions\x12\x18\n" + + "total_size\x12C\n" + + "\vpermissions\x18\x02 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12\x18\n" + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + "\x06_extra\"&\n" + "\x14GetPermissionRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"[\n" + - "\x15GetPermissionResponse\x12B\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"Z\n" + + "\x15GetPermissionResponse\x12A\n" + "\n" + - "permission\x18\x01 \x01(\v2\".api.v1.services.system.PermissionR\n" + - "permission\"\x9b\x01\n" + + "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"\x9a\x01\n" + "\x17CreatePermissionRequest\x12\x16\n" + "\x06parent\x18\x01 \x01(\tR\x06parent\x12$\n" + - "\rpermission_id\x18\x03 \x01(\tR\rpermission_id\x12B\n" + + "\rpermission_id\x18\x03 \x01(\tR\rpermission_id\x12A\n" + "\n" + - "permission\x18\x02 \x01(\v2\".api.v1.services.system.PermissionR\n" + - "permission\"^\n" + - "\x18CreatePermissionResponse\x12B\n" + + "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"]\n" + + "\x18CreatePermissionResponse\x12A\n" + "\n" + - "permission\x18\x01 \x01(\v2\".api.v1.services.system.PermissionR\n" + - "permission\"m\n" + + "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"l\n" + "\x17UpdatePermissionRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12B\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12A\n" + "\n" + - "permission\x18\x02 \x01(\v2\".api.v1.services.system.PermissionR\n" + - "permission\"^\n" + - "\x18UpdatePermissionResponse\x12B\n" + + "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"]\n" + + "\x18UpdatePermissionResponse\x12A\n" + "\n" + - "permission\x18\x01 \x01(\v2\".api.v1.services.system.PermissionR\n" + + "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + "permission\")\n" + "\x17DeletePermissionRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + @@ -691,18 +692,18 @@ var file_system_permission_proto_goTypes = []any{ (*UpdatePermissionResponse)(nil), // 7: api.v1.services.system.UpdatePermissionResponse (*DeletePermissionRequest)(nil), // 8: api.v1.services.system.DeletePermissionRequest (*DeletePermissionResponse)(nil), // 9: api.v1.services.system.DeletePermissionResponse - (*Permission)(nil), // 10: api.v1.services.system.Permission + (*types.Permission)(nil), // 10: api.v1.services.types.Permission (*anypb.Any)(nil), // 11: google.protobuf.Any (*emptypb.Empty)(nil), // 12: google.protobuf.Empty } var file_system_permission_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListPermissionsResponse.permissions:type_name -> api.v1.services.system.Permission + 10, // 0: api.v1.services.system.ListPermissionsResponse.permissions:type_name -> api.v1.services.types.Permission 11, // 1: api.v1.services.system.ListPermissionsResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetPermissionResponse.permission:type_name -> api.v1.services.system.Permission - 10, // 3: api.v1.services.system.CreatePermissionRequest.permission:type_name -> api.v1.services.system.Permission - 10, // 4: api.v1.services.system.CreatePermissionResponse.permission:type_name -> api.v1.services.system.Permission - 10, // 5: api.v1.services.system.UpdatePermissionRequest.permission:type_name -> api.v1.services.system.Permission - 10, // 6: api.v1.services.system.UpdatePermissionResponse.permission:type_name -> api.v1.services.system.Permission + 10, // 2: api.v1.services.system.GetPermissionResponse.permission:type_name -> api.v1.services.types.Permission + 10, // 3: api.v1.services.system.CreatePermissionRequest.permission:type_name -> api.v1.services.types.Permission + 10, // 4: api.v1.services.system.CreatePermissionResponse.permission:type_name -> api.v1.services.types.Permission + 10, // 5: api.v1.services.system.UpdatePermissionRequest.permission:type_name -> api.v1.services.types.Permission + 10, // 6: api.v1.services.system.UpdatePermissionResponse.permission:type_name -> api.v1.services.types.Permission 12, // 7: api.v1.services.system.DeletePermissionResponse.empty:type_name -> google.protobuf.Empty 0, // 8: api.v1.services.system.PermissionService.ListPermissions:input_type -> api.v1.services.system.ListPermissionsRequest 2, // 9: api.v1.services.system.PermissionService.GetPermission:input_type -> api.v1.services.system.GetPermissionRequest @@ -726,7 +727,6 @@ func file_system_permission_proto_init() { if File_system_permission_proto != nil { return } - file_system_types_proto_init() file_system_permission_proto_msgTypes[1].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ diff --git a/api/v1/services/system/permission_agent.pb.go b/api/v1/services/system/permission_agent.pb.go deleted file mode 100644 index 9fe7e4c6..00000000 --- a/api/v1/services/system/permission_agent.pb.go +++ /dev/null @@ -1,169 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/permission.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type PermissionServiceAgent interface { - CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) - DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) - GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) - ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) - UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) -} - -func _PermissionService_ListPermissions0_HTTPAgent_Handler(srv PermissionServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListPermissionsRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPermissionServiceListPermissions) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListPermissions(ctx, req.(*ListPermissionsRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListPermissionsResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PermissionService_GetPermission0_HTTPAgent_Handler(srv PermissionServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in GetPermissionRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPermissionServiceGetPermission) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.GetPermission(ctx, req.(*GetPermissionRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*GetPermissionResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PermissionService_CreatePermission0_HTTPAgent_Handler(srv PermissionServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CreatePermissionRequest - if err := cctx.Bind(&in.Permission); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPermissionServiceCreatePermission) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CreatePermission(ctx, req.(*CreatePermissionRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CreatePermissionResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PermissionService_UpdatePermission0_HTTPAgent_Handler(srv PermissionServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdatePermissionRequest - if err := cctx.Bind(&in.Permission); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPermissionServiceUpdatePermission) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdatePermission(ctx, req.(*UpdatePermissionRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePermissionResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PermissionService_DeletePermission0_HTTPAgent_Handler(srv PermissionServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in DeletePermissionRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPermissionServiceDeletePermission) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.DeletePermission(ctx, req.(*DeletePermissionRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*DeletePermissionResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterPermissionServiceAgent(ag agent.HTTPAgent, srv PermissionServiceAgent) { - r := ag.Route() - r.GET("/sys/permissions", _PermissionService_ListPermissions0_HTTPAgent_Handler(srv)) - r.GET("/sys/permissions/{id}", _PermissionService_GetPermission0_HTTPAgent_Handler(srv)) - r.POST("/sys/permissions", _PermissionService_CreatePermission0_HTTPAgent_Handler(srv)) - r.PUT("/sys/permissions/{permission.id}", _PermissionService_UpdatePermission0_HTTPAgent_Handler(srv)) - r.DELETE("/sys/permissions/{id}", _PermissionService_DeletePermission0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go new file mode 100644 index 00000000..3150bd4f --- /dev/null +++ b/api/v1/services/system/permission_bridge.pb.go @@ -0,0 +1,298 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/permission.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const PermissionServiceCreatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/CreatePermission" +const PermissionServiceDeletePermissionBridgeOperation = "/api.v1.services.system.PermissionService/DeletePermission" +const PermissionServiceGetPermissionBridgeOperation = "/api.v1.services.system.PermissionService/GetPermission" +const PermissionServiceListPermissionsBridgeOperation = "/api.v1.services.system.PermissionService/ListPermissions" +const PermissionServiceUpdatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/UpdatePermission" + +type PermissionServiceBridger interface { + CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) + DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) + GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) + ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) + UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) +} + +type PermissionServiceBridgeHooker interface { + PermissionServiceBridger + BeforeCreatePermission(http.Context, *CreatePermissionRequest) (context.Context, error) + CreatePermissionResult(http.Context, *CreatePermissionRequest, *CreatePermissionResponse) error + BeforeDeletePermission(http.Context, *DeletePermissionRequest) (context.Context, error) + DeletePermissionResult(http.Context, *DeletePermissionRequest, *DeletePermissionResponse) error + BeforeGetPermission(http.Context, *GetPermissionRequest) (context.Context, error) + GetPermissionResult(http.Context, *GetPermissionRequest, *GetPermissionResponse) error + BeforeListPermissions(http.Context, *ListPermissionsRequest) (context.Context, error) + ListPermissionsResult(http.Context, *ListPermissionsRequest, *ListPermissionsResponse) error + BeforeUpdatePermission(http.Context, *UpdatePermissionRequest) (context.Context, error) + UpdatePermissionResult(http.Context, *UpdatePermissionRequest, *UpdatePermissionResponse) error +} + +func RegisterPermissionServiceBridger(s *http.Server, srv PermissionServiceBridger) { + r := s.Route("/") + hook, ok := srv.(PermissionServiceBridgeHooker) + if !ok { + hook = UnimplementedPermissionServiceBridger{PermissionServiceBridger: srv} + } + r.GET("/sys/permissions", _PermissionService_ListPermissions0_Bridge_Handler(hook)) + r.GET("/sys/permissions/:id", _PermissionService_GetPermission0_Bridge_Handler(hook)) + r.POST("/sys/permissions", _PermissionService_CreatePermission0_Bridge_Handler(hook)) + r.PUT("/sys/permissions/:permission.id", _PermissionService_UpdatePermission0_Bridge_Handler(hook)) + r.DELETE("/sys/permissions/:id", _PermissionService_DeletePermission0_Bridge_Handler(hook)) +} + +func _PermissionService_ListPermissions0_Bridge_Handler(srv PermissionServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPermissionsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceListPermissions) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPermissions(ctx, req.(*ListPermissionsRequest)) + }) + + newctx, err := srv.BeforeListPermissions(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListPermissionsResult(ctx, &in, out.(*ListPermissionsResponse)) + } +} + +func _PermissionService_GetPermission0_Bridge_Handler(srv PermissionServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPermissionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceGetPermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPermission(ctx, req.(*GetPermissionRequest)) + }) + + newctx, err := srv.BeforeGetPermission(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.GetPermissionResult(ctx, &in, out.(*GetPermissionResponse)) + } +} + +func _PermissionService_CreatePermission0_Bridge_Handler(srv PermissionServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreatePermissionRequest + if err := ctx.Bind(&in.Permission); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceCreatePermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreatePermission(ctx, req.(*CreatePermissionRequest)) + }) + + newctx, err := srv.BeforeCreatePermission(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CreatePermissionResult(ctx, &in, out.(*CreatePermissionResponse)) + } +} + +func _PermissionService_UpdatePermission0_Bridge_Handler(srv PermissionServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePermissionRequest + if err := ctx.Bind(&in.Permission); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceUpdatePermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePermission(ctx, req.(*UpdatePermissionRequest)) + }) + + newctx, err := srv.BeforeUpdatePermission(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdatePermissionResult(ctx, &in, out.(*UpdatePermissionResponse)) + } +} + +func _PermissionService_DeletePermission0_Bridge_Handler(srv PermissionServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeletePermissionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceDeletePermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeletePermission(ctx, req.(*DeletePermissionRequest)) + }) + + newctx, err := srv.BeforeDeletePermission(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.DeletePermissionResult(ctx, &in, out.(*DeletePermissionResponse)) + } +} + +// UnimplementedPermissionServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPermissionServiceBridger struct { + PermissionServiceBridger +} + +func (UnimplementedPermissionServiceBridger) BeforeCreatePermission(ctx http.Context, in *CreatePermissionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPermissionServiceBridger) CreatePermissionResult(ctx http.Context, in *CreatePermissionRequest, out *CreatePermissionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPermissionServiceBridger) BeforeDeletePermission(ctx http.Context, in *DeletePermissionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPermissionServiceBridger) DeletePermissionResult(ctx http.Context, in *DeletePermissionRequest, out *DeletePermissionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPermissionServiceBridger) BeforeGetPermission(ctx http.Context, in *GetPermissionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPermissionServiceBridger) GetPermissionResult(ctx http.Context, in *GetPermissionRequest, out *GetPermissionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPermissionServiceBridger) BeforeListPermissions(ctx http.Context, in *ListPermissionsRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPermissionServiceBridger) ListPermissionsResult(ctx http.Context, in *ListPermissionsRequest, out *ListPermissionsResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPermissionServiceBridger) BeforeUpdatePermission(ctx http.Context, in *UpdatePermissionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPermissionServiceBridger) UpdatePermissionResult(ctx http.Context, in *UpdatePermissionRequest, out *UpdatePermissionResponse) error { + return ctx.Result(200, out) +} + +type PermissionServiceHTTPBridgeImpl struct { + client PermissionServiceHTTPClient +} + +func NewPermissionServiceHTTPBridge(client *http.Client) PermissionServiceHTTPServer { + return &PermissionServiceHTTPBridgeImpl{client: NewPermissionServiceHTTPClient(client)} +} + +func (c *PermissionServiceHTTPBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) +} + +func (c *PermissionServiceHTTPBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + +func (c *PermissionServiceHTTPBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { + return c.client.GetPermission(ctx, in) +} + +func (c *PermissionServiceHTTPBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) +} + +func (c *PermissionServiceHTTPBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { + return c.client.UpdatePermission(ctx, in) +} + +type PermissionServiceBridgeImpl struct { + client PermissionServiceClient +} + +func NewPermissionServiceBridge(client grpc.ClientConnInterface) PermissionServiceServer { + return &PermissionServiceBridgeImpl{client: NewPermissionServiceClient(client)} +} + +func (c *PermissionServiceBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) +} + +func (c *PermissionServiceBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + +func (c *PermissionServiceBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { + return c.client.GetPermission(ctx, in) +} + +func (c *PermissionServiceBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) +} + +func (c *PermissionServiceBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { + return c.client.UpdatePermission(ctx, in) +} + +func (c *PermissionServiceBridgeImpl) mustEmbedUnimplementedPermissionServiceServer() {} diff --git a/api/v1/services/system/personal.pb.go b/api/v1/services/system/personal.pb.go index dba93957..06955179 100644 --- a/api/v1/services/system/personal.pb.go +++ b/api/v1/services/system/personal.pb.go @@ -15,6 +15,7 @@ import ( reflect "reflect" sync "sync" unsafe "unsafe" + types "v1/services/types" ) const ( @@ -106,7 +107,7 @@ func (*UpdatePersonalSettingResponse) Descriptor() ([]byte, []int) { type UpdatePersonalRoleRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -141,7 +142,7 @@ func (*UpdatePersonalRoleRequest) Descriptor() ([]byte, []int) { return file_system_personal_proto_rawDescGZIP(), []int{2} } -func (x *UpdatePersonalRoleRequest) GetRole() *Role { +func (x *UpdatePersonalRoleRequest) GetRole() *types.Role { if x != nil { return x.Role } @@ -279,7 +280,7 @@ type ListPersonalResourcesResponse struct { // The total number of items in the list. TotalSize int64 `protobuf:"varint,1,opt,name=total_size,json=total,proto3" json:"total_size,omitempty"` // list of resources - Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` // Token to retrieve the next page of results, or empty if there are no // more results in the list. NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` @@ -324,7 +325,7 @@ func (x *ListPersonalResourcesResponse) GetTotalSize() int64 { return 0 } -func (x *ListPersonalResourcesResponse) GetResources() []*Resource { +func (x *ListPersonalResourcesResponse) GetResources() []*types.Resource { if x != nil { return x.Resources } @@ -704,7 +705,7 @@ func (*ListPersonalRolesRequest) Descriptor() ([]byte, []int) { type ListPersonalRolesResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*types.Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -739,7 +740,7 @@ func (*ListPersonalRolesResponse) Descriptor() ([]byte, []int) { return file_system_personal_proto_rawDescGZIP(), []int{15} } -func (x *ListPersonalRolesResponse) GetRoles() []*Role { +func (x *ListPersonalRolesResponse) GetRoles() []*types.Role { if x != nil { return x.Roles } @@ -784,7 +785,7 @@ func (*GetPersonalProfileRequest) Descriptor() ([]byte, []int) { type GetPersonalProfileResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -819,7 +820,7 @@ func (*GetPersonalProfileResponse) Descriptor() ([]byte, []int) { return file_system_personal_proto_rawDescGZIP(), []int{17} } -func (x *GetPersonalProfileResponse) GetUser() *User { +func (x *GetPersonalProfileResponse) GetUser() *types.User { if x != nil { return x.User } @@ -918,12 +919,12 @@ var File_system_personal_proto protoreflect.FileDescriptor const file_system_personal_proto_rawDesc = "" + "\n" + - "\x15system/personal.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12system/types.proto\x1a\x17validate/validate.proto\"H\n" + + "\x15system/personal.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12types/system.proto\x1a\x17validate/validate.proto\"H\n" + "\x1cUpdatePersonalSettingRequest\x12(\n" + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + - "\x1dUpdatePersonalSettingResponse\"M\n" + - "\x19UpdatePersonalRoleRequest\x120\n" + - "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"\x1c\n" + + "\x1dUpdatePersonalSettingResponse\"L\n" + + "\x19UpdatePersonalRoleRequest\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\x1c\n" + "\x1aUpdatePersonalRoleResponse\"\xc4\x01\n" + "\x1cListPersonalResourcesRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + @@ -935,11 +936,11 @@ const file_system_personal_proto_rawDesc = "" + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + "\n" + "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\xa4\x01\n" + + "only_count\"\xa3\x01\n" + "\x1dListPersonalResourcesResponse\x12\x19\n" + "\n" + - "total_size\x18\x01 \x01(\x03R\x05total\x12>\n" + - "\tresources\x18\x02 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x12(\n" + + "total_size\x18\x01 \x01(\x03R\x05total\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12(\n" + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\"I\n" + "\x1dUpdatePersonalPasswordRequest\x12(\n" + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\" \n" + @@ -954,12 +955,12 @@ const file_system_personal_proto_rawDesc = "" + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"2\n" + "\x16PersonalLogoutResponse\x12\x18\n" + "\asuccess\x18\x01 \x01(\bR\asuccess\"\x1a\n" + - "\x18ListPersonalRolesRequest\"O\n" + - "\x19ListPersonalRolesResponse\x122\n" + - "\x05roles\x18\x01 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\"\x1b\n" + - "\x19GetPersonalProfileRequest\"N\n" + - "\x1aGetPersonalProfileResponse\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"G\n" + + "\x18ListPersonalRolesRequest\"N\n" + + "\x19ListPersonalRolesResponse\x121\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x1b\n" + + "\x19GetPersonalProfileRequest\"M\n" + + "\x1aGetPersonalProfileResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + "\x1bRefreshPersonalTokenRequest\x12(\n" + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"4\n" + "\x1cRefreshPersonalTokenResponse\x12\x14\n" + @@ -1011,19 +1012,19 @@ var file_system_personal_proto_goTypes = []any{ (*RefreshPersonalTokenRequest)(nil), // 18: api.v1.services.system.RefreshPersonalTokenRequest (*RefreshPersonalTokenResponse)(nil), // 19: api.v1.services.system.RefreshPersonalTokenResponse (*anypb.Any)(nil), // 20: google.protobuf.Any - (*Role)(nil), // 21: api.v1.services.system.Role - (*Resource)(nil), // 22: api.v1.services.system.Resource - (*User)(nil), // 23: api.v1.services.system.User + (*types.Role)(nil), // 21: api.v1.services.types.Role + (*types.Resource)(nil), // 22: api.v1.services.types.Resource + (*types.User)(nil), // 23: api.v1.services.types.User } var file_system_personal_proto_depIdxs = []int32{ 20, // 0: api.v1.services.system.UpdatePersonalSettingRequest.data:type_name -> google.protobuf.Any - 21, // 1: api.v1.services.system.UpdatePersonalRoleRequest.role:type_name -> api.v1.services.system.Role - 22, // 2: api.v1.services.system.ListPersonalResourcesResponse.resources:type_name -> api.v1.services.system.Resource + 21, // 1: api.v1.services.system.UpdatePersonalRoleRequest.role:type_name -> api.v1.services.types.Role + 22, // 2: api.v1.services.system.ListPersonalResourcesResponse.resources:type_name -> api.v1.services.types.Resource 20, // 3: api.v1.services.system.UpdatePersonalPasswordRequest.data:type_name -> google.protobuf.Any 20, // 4: api.v1.services.system.UpdatePersonalProfileRequest.data:type_name -> google.protobuf.Any 20, // 5: api.v1.services.system.PersonalLogoutRequest.data:type_name -> google.protobuf.Any - 21, // 6: api.v1.services.system.ListPersonalRolesResponse.roles:type_name -> api.v1.services.system.Role - 23, // 7: api.v1.services.system.GetPersonalProfileResponse.user:type_name -> api.v1.services.system.User + 21, // 6: api.v1.services.system.ListPersonalRolesResponse.roles:type_name -> api.v1.services.types.Role + 23, // 7: api.v1.services.system.GetPersonalProfileResponse.user:type_name -> api.v1.services.types.User 20, // 8: api.v1.services.system.RefreshPersonalTokenRequest.data:type_name -> google.protobuf.Any 16, // 9: api.v1.services.system.PersonalService.GetPersonalProfile:input_type -> api.v1.services.system.GetPersonalProfileRequest 4, // 10: api.v1.services.system.PersonalService.ListPersonalResources:input_type -> api.v1.services.system.ListPersonalResourcesRequest @@ -1053,7 +1054,6 @@ func file_system_personal_proto_init() { if File_system_personal_proto != nil { return } - file_system_types_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/api/v1/services/system/personal_agent.pb.go b/api/v1/services/system/personal_agent.pb.go deleted file mode 100644 index 327cfb0d..00000000 --- a/api/v1/services/system/personal_agent.pb.go +++ /dev/null @@ -1,252 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/personal.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type PersonalServiceAgent interface { - // GetPersonalProfile GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalRoles ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) -} - -func _PersonalService_GetPersonalProfile0_HTTPAgent_Handler(srv PersonalServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in GetPersonalProfileRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPersonalServiceGetPersonalProfile) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*GetPersonalProfileResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PersonalService_ListPersonalResources0_HTTPAgent_Handler(srv PersonalServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListPersonalResourcesRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPersonalServiceListPersonalResources) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListPersonalResourcesResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PersonalService_ListPersonalRoles0_HTTPAgent_Handler(srv PersonalServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListPersonalRolesRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPersonalServiceListPersonalRoles) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListPersonalRolesResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PersonalService_PersonalLogout0_HTTPAgent_Handler(srv PersonalServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in PersonalLogoutRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPersonalServicePersonalLogout) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*PersonalLogoutResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PersonalService_RefreshPersonalToken0_HTTPAgent_Handler(srv PersonalServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in RefreshPersonalTokenRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPersonalServiceRefreshPersonalToken) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*RefreshPersonalTokenResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalPassword0_HTTPAgent_Handler(srv PersonalServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdatePersonalPasswordRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPersonalServiceUpdatePersonalPassword) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalPasswordResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalProfile0_HTTPAgent_Handler(srv PersonalServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdatePersonalProfileRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPersonalServiceUpdatePersonalProfile) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalProfileResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalSetting0_HTTPAgent_Handler(srv PersonalServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdatePersonalSettingRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPersonalServiceUpdatePersonalSetting) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalSettingResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterPersonalServiceAgent(ag agent.HTTPAgent, srv PersonalServiceAgent) { - r := ag.Route() - r.GET("/sys/personal/profile", _PersonalService_GetPersonalProfile0_HTTPAgent_Handler(srv)) - r.GET("/sys/personal/resources", _PersonalService_ListPersonalResources0_HTTPAgent_Handler(srv)) - r.GET("/sys/personal/roles", _PersonalService_ListPersonalRoles0_HTTPAgent_Handler(srv)) - r.POST("/sys/personal/logout", _PersonalService_PersonalLogout0_HTTPAgent_Handler(srv)) - r.POST("/sys/personal/token/refresh", _PersonalService_RefreshPersonalToken0_HTTPAgent_Handler(srv)) - r.PUT("/sys/personal/password", _PersonalService_UpdatePersonalPassword0_HTTPAgent_Handler(srv)) - r.PUT("/sys/personal/profile", _PersonalService_UpdatePersonalProfile0_HTTPAgent_Handler(srv)) - r.PUT("/sys/personal/setting", _PersonalService_UpdatePersonalSetting0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/personal_bridge.pb.go b/api/v1/services/system/personal_bridge.pb.go new file mode 100644 index 00000000..6ed17ec0 --- /dev/null +++ b/api/v1/services/system/personal_bridge.pb.go @@ -0,0 +1,446 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/personal.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const PersonalServiceGetPersonalProfileBridgeOperation = "/api.v1.services.system.PersonalService/GetPersonalProfile" +const PersonalServiceListPersonalResourcesBridgeOperation = "/api.v1.services.system.PersonalService/ListPersonalResources" +const PersonalServiceListPersonalRolesBridgeOperation = "/api.v1.services.system.PersonalService/ListPersonalRoles" +const PersonalServicePersonalLogoutBridgeOperation = "/api.v1.services.system.PersonalService/PersonalLogout" +const PersonalServiceRefreshPersonalTokenBridgeOperation = "/api.v1.services.system.PersonalService/RefreshPersonalToken" +const PersonalServiceUpdatePersonalPasswordBridgeOperation = "/api.v1.services.system.PersonalService/UpdatePersonalPassword" +const PersonalServiceUpdatePersonalProfileBridgeOperation = "/api.v1.services.system.PersonalService/UpdatePersonalProfile" +const PersonalServiceUpdatePersonalSettingBridgeOperation = "/api.v1.services.system.PersonalService/UpdatePersonalSetting" + +type PersonalServiceBridger interface { + // GetPersonalProfile GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalRoles ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) +} + +type PersonalServiceBridgeHooker interface { + PersonalServiceBridger + // GetPersonalProfile GetPersonalProfile Update the personal user information + BeforeGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) + GetPersonalProfileResult(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error + // ListPersonalResources ListPersonalResources List the personal user's menu + BeforeListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) + ListPersonalResourcesResult(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error + // ListPersonalRoles ListPersonalResources List the personal user's menu + BeforeListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) + ListPersonalRolesResult(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error + // PersonalLogout PersonalLogout Personal user logs out + BeforePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) + PersonalLogoutResult(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error + // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token + BeforeRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) + RefreshPersonalTokenResult(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error + // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password + BeforeUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) + UpdatePersonalPasswordResult(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error + // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information + BeforeUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) + UpdatePersonalProfileResult(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error + // UpdatePersonalSetting UpdatePersonalSetting User settings are saved + BeforeUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) + UpdatePersonalSettingResult(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error +} + +func RegisterPersonalServiceBridger(s *http.Server, srv PersonalServiceBridger) { + r := s.Route("/") + hook, ok := srv.(PersonalServiceBridgeHooker) + if !ok { + hook = UnimplementedPersonalServiceBridger{PersonalServiceBridger: srv} + } + r.GET("/sys/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(hook)) + r.GET("/sys/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(hook)) + r.GET("/sys/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(hook)) + r.POST("/sys/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(hook)) + r.POST("/sys/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(hook)) + r.PUT("/sys/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(hook)) + r.PUT("/sys/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(hook)) + r.PUT("/sys/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(hook)) +} + +func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPersonalProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + }) + + newctx, err := srv.BeforeGetPersonalProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.GetPersonalProfileResult(ctx, &in, out.(*GetPersonalProfileResponse)) + } +} + +func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + }) + + newctx, err := srv.BeforeListPersonalResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListPersonalResourcesResult(ctx, &in, out.(*ListPersonalResourcesResponse)) + } +} + +func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + }) + + newctx, err := srv.BeforeListPersonalRoles(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListPersonalRolesResult(ctx, &in, out.(*ListPersonalRolesResponse)) + } +} + +func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in PersonalLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServicePersonalLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + }) + + newctx, err := srv.BeforePersonalLogout(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.PersonalLogoutResult(ctx, &in, out.(*PersonalLogoutResponse)) + } +} + +func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RefreshPersonalTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + }) + + newctx, err := srv.BeforeRefreshPersonalToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.RefreshPersonalTokenResult(ctx, &in, out.(*RefreshPersonalTokenResponse)) + } +} + +func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + }) + + newctx, err := srv.BeforeUpdatePersonalPassword(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdatePersonalPasswordResult(ctx, &in, out.(*UpdatePersonalPasswordResponse)) + } +} + +func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalProfileRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + }) + + newctx, err := srv.BeforeUpdatePersonalProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdatePersonalProfileResult(ctx, &in, out.(*UpdatePersonalProfileResponse)) + } +} + +func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalSettingRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + }) + + newctx, err := srv.BeforeUpdatePersonalSetting(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdatePersonalSettingResult(ctx, &in, out.(*UpdatePersonalSettingResponse)) + } +} + +// UnimplementedPersonalServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPersonalServiceBridger struct { + PersonalServiceBridger +} + +func (UnimplementedPersonalServiceBridger) BeforeGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceBridger) GetPersonalProfileResult(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceBridger) BeforeListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceBridger) ListPersonalResourcesResult(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceBridger) BeforeListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceBridger) ListPersonalRolesResult(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceBridger) BeforePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceBridger) PersonalLogoutResult(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceBridger) BeforeRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceBridger) RefreshPersonalTokenResult(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceBridger) BeforeUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceBridger) UpdatePersonalPasswordResult(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceBridger) BeforeUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceBridger) UpdatePersonalProfileResult(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceBridger) BeforeUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceBridger) UpdatePersonalSettingResult(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { + return ctx.Result(200, out) +} + +type PersonalServiceHTTPBridgeImpl struct { + client PersonalServiceHTTPClient +} + +func NewPersonalServiceHTTPBridge(client *http.Client) PersonalServiceHTTPServer { + return &PersonalServiceHTTPBridgeImpl{client: NewPersonalServiceHTTPClient(client)} +} + +func (c *PersonalServiceHTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +type PersonalServiceBridgeImpl struct { + client PersonalServiceClient +} + +func NewPersonalServiceBridge(client grpc.ClientConnInterface) PersonalServiceServer { + return &PersonalServiceBridgeImpl{client: NewPersonalServiceClient(client)} +} + +func (c *PersonalServiceBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} diff --git a/api/v1/services/system/position.pb.go b/api/v1/services/system/position.pb.go index d4f24e14..cad9f951 100644 --- a/api/v1/services/system/position.pb.go +++ b/api/v1/services/system/position.pb.go @@ -15,6 +15,7 @@ import ( reflect "reflect" sync "sync" unsafe "unsafe" + types "v1/services/types" ) const ( @@ -119,7 +120,7 @@ type ListPositionsResponse struct { // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus - Positions []*Position `protobuf:"bytes,2,rep,name=positions,proto3" json:"positions,omitempty"` + Positions []*types.Position `protobuf:"bytes,2,rep,name=positions,proto3" json:"positions,omitempty"` // The current page number. Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` // The maximum number of items to return. @@ -171,7 +172,7 @@ func (x *ListPositionsResponse) GetTotalSize() int32 { return 0 } -func (x *ListPositionsResponse) GetPositions() []*Position { +func (x *ListPositionsResponse) GetPositions() []*types.Position { if x != nil { return x.Positions } @@ -254,7 +255,7 @@ func (x *GetPositionRequest) GetId() int64 { type GetPositionResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + Position *types.Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -289,7 +290,7 @@ func (*GetPositionResponse) Descriptor() ([]byte, []int) { return file_system_position_proto_rawDescGZIP(), []int{3} } -func (x *GetPositionResponse) GetPosition() *Position { +func (x *GetPositionResponse) GetPosition() *types.Position { if x != nil { return x.Position } @@ -303,7 +304,7 @@ type CreatePositionRequest struct { // The position id to use for this position. PositionId string `protobuf:"bytes,2,opt,name=position_id,proto3" json:"position_id,omitempty"` // The position object to create. - Position *Position `protobuf:"bytes,3,opt,name=position,proto3" json:"position,omitempty"` + Position *types.Position `protobuf:"bytes,3,opt,name=position,proto3" json:"position,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -352,7 +353,7 @@ func (x *CreatePositionRequest) GetPositionId() string { return "" } -func (x *CreatePositionRequest) GetPosition() *Position { +func (x *CreatePositionRequest) GetPosition() *types.Position { if x != nil { return x.Position } @@ -361,7 +362,7 @@ func (x *CreatePositionRequest) GetPosition() *Position { type CreatePositionResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + Position *types.Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -396,7 +397,7 @@ func (*CreatePositionResponse) Descriptor() ([]byte, []int) { return file_system_position_proto_rawDescGZIP(), []int{5} } -func (x *CreatePositionResponse) GetPosition() *Position { +func (x *CreatePositionResponse) GetPosition() *types.Position { if x != nil { return x.Position } @@ -408,7 +409,7 @@ type UpdatePositionRequest struct { // The id of the position resource to update. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The position resource which replaces the resource on the server. - Position *Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` + Position *types.Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -450,7 +451,7 @@ func (x *UpdatePositionRequest) GetId() int64 { return 0 } -func (x *UpdatePositionRequest) GetPosition() *Position { +func (x *UpdatePositionRequest) GetPosition() *types.Position { if x != nil { return x.Position } @@ -459,7 +460,7 @@ func (x *UpdatePositionRequest) GetPosition() *Position { type UpdatePositionResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + Position *types.Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -494,7 +495,7 @@ func (*UpdatePositionResponse) Descriptor() ([]byte, []int) { return file_system_position_proto_rawDescGZIP(), []int{7} } -func (x *UpdatePositionResponse) GetPosition() *Position { +func (x *UpdatePositionResponse) GetPosition() *types.Position { if x != nil { return x.Position } @@ -595,7 +596,7 @@ var File_system_position_proto protoreflect.FileDescriptor const file_system_position_proto_rawDesc = "" + "\n" + - "\x15system/position.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xbc\x01\n" + + "\x15system/position.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xbc\x01\n" + "\x14ListPositionsRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + @@ -606,32 +607,32 @@ const file_system_position_proto_rawDesc = "" + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + "\n" + "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\x94\x02\n" + + "only_count\"\x93\x02\n" + "\x15ListPositionsResponse\x12\x1e\n" + "\n" + "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x12>\n" + - "\tpositions\x18\x02 \x03(\v2 .api.v1.services.system.PositionR\tpositions\x12\x18\n" + + "total_size\x12=\n" + + "\tpositions\x18\x02 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12\x18\n" + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + "\x06_extra\"$\n" + "\x12GetPositionRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"S\n" + - "\x13GetPositionResponse\x12<\n" + - "\bposition\x18\x01 \x01(\v2 .api.v1.services.system.PositionR\bposition\"\x8f\x01\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"R\n" + + "\x13GetPositionResponse\x12;\n" + + "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"\x8e\x01\n" + "\x15CreatePositionRequest\x12\x16\n" + "\x06parent\x18\x01 \x01(\tR\x06parent\x12 \n" + - "\vposition_id\x18\x02 \x01(\tR\vposition_id\x12<\n" + - "\bposition\x18\x03 \x01(\v2 .api.v1.services.system.PositionR\bposition\"V\n" + - "\x16CreatePositionResponse\x12<\n" + - "\bposition\x18\x01 \x01(\v2 .api.v1.services.system.PositionR\bposition\"e\n" + + "\vposition_id\x18\x02 \x01(\tR\vposition_id\x12;\n" + + "\bposition\x18\x03 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"U\n" + + "\x16CreatePositionResponse\x12;\n" + + "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"d\n" + "\x15UpdatePositionRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\bposition\x18\x02 \x01(\v2 .api.v1.services.system.PositionR\bposition\"V\n" + - "\x16UpdatePositionResponse\x12<\n" + - "\bposition\x18\x01 \x01(\v2 .api.v1.services.system.PositionR\bposition\"'\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12;\n" + + "\bposition\x18\x02 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"U\n" + + "\x16UpdatePositionResponse\x12;\n" + + "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"'\n" + "\x15DeletePositionRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + "\x16DeletePositionResponse\x12,\n" + @@ -668,18 +669,18 @@ var file_system_position_proto_goTypes = []any{ (*UpdatePositionResponse)(nil), // 7: api.v1.services.system.UpdatePositionResponse (*DeletePositionRequest)(nil), // 8: api.v1.services.system.DeletePositionRequest (*DeletePositionResponse)(nil), // 9: api.v1.services.system.DeletePositionResponse - (*Position)(nil), // 10: api.v1.services.system.Position + (*types.Position)(nil), // 10: api.v1.services.types.Position (*anypb.Any)(nil), // 11: google.protobuf.Any (*emptypb.Empty)(nil), // 12: google.protobuf.Empty } var file_system_position_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListPositionsResponse.positions:type_name -> api.v1.services.system.Position + 10, // 0: api.v1.services.system.ListPositionsResponse.positions:type_name -> api.v1.services.types.Position 11, // 1: api.v1.services.system.ListPositionsResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetPositionResponse.position:type_name -> api.v1.services.system.Position - 10, // 3: api.v1.services.system.CreatePositionRequest.position:type_name -> api.v1.services.system.Position - 10, // 4: api.v1.services.system.CreatePositionResponse.position:type_name -> api.v1.services.system.Position - 10, // 5: api.v1.services.system.UpdatePositionRequest.position:type_name -> api.v1.services.system.Position - 10, // 6: api.v1.services.system.UpdatePositionResponse.position:type_name -> api.v1.services.system.Position + 10, // 2: api.v1.services.system.GetPositionResponse.position:type_name -> api.v1.services.types.Position + 10, // 3: api.v1.services.system.CreatePositionRequest.position:type_name -> api.v1.services.types.Position + 10, // 4: api.v1.services.system.CreatePositionResponse.position:type_name -> api.v1.services.types.Position + 10, // 5: api.v1.services.system.UpdatePositionRequest.position:type_name -> api.v1.services.types.Position + 10, // 6: api.v1.services.system.UpdatePositionResponse.position:type_name -> api.v1.services.types.Position 12, // 7: api.v1.services.system.DeletePositionResponse.empty:type_name -> google.protobuf.Empty 0, // 8: api.v1.services.system.PositionService.ListPositions:input_type -> api.v1.services.system.ListPositionsRequest 2, // 9: api.v1.services.system.PositionService.GetPosition:input_type -> api.v1.services.system.GetPositionRequest @@ -703,7 +704,6 @@ func file_system_position_proto_init() { if File_system_position_proto != nil { return } - file_system_types_proto_init() file_system_position_proto_msgTypes[1].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ diff --git a/api/v1/services/system/position_agent.pb.go b/api/v1/services/system/position_agent.pb.go deleted file mode 100644 index 0fa1e3cf..00000000 --- a/api/v1/services/system/position_agent.pb.go +++ /dev/null @@ -1,169 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/position.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type PositionServiceAgent interface { - CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) - DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) - GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) - ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) - UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) -} - -func _PositionService_ListPositions0_HTTPAgent_Handler(srv PositionServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListPositionsRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPositionServiceListPositions) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListPositions(ctx, req.(*ListPositionsRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListPositionsResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PositionService_GetPosition0_HTTPAgent_Handler(srv PositionServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in GetPositionRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPositionServiceGetPosition) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.GetPosition(ctx, req.(*GetPositionRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*GetPositionResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PositionService_CreatePosition0_HTTPAgent_Handler(srv PositionServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CreatePositionRequest - if err := cctx.Bind(&in.Position); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPositionServiceCreatePosition) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CreatePosition(ctx, req.(*CreatePositionRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CreatePositionResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PositionService_UpdatePosition0_HTTPAgent_Handler(srv PositionServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdatePositionRequest - if err := cctx.Bind(&in.Position); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPositionServiceUpdatePosition) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdatePosition(ctx, req.(*UpdatePositionRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePositionResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _PositionService_DeletePosition0_HTTPAgent_Handler(srv PositionServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in DeletePositionRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationPositionServiceDeletePosition) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.DeletePosition(ctx, req.(*DeletePositionRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*DeletePositionResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterPositionServiceAgent(ag agent.HTTPAgent, srv PositionServiceAgent) { - r := ag.Route() - r.GET("/sys/positions", _PositionService_ListPositions0_HTTPAgent_Handler(srv)) - r.GET("/sys/positions/{id}", _PositionService_GetPosition0_HTTPAgent_Handler(srv)) - r.POST("/sys/positions", _PositionService_CreatePosition0_HTTPAgent_Handler(srv)) - r.PUT("/sys/positions/{position.id}", _PositionService_UpdatePosition0_HTTPAgent_Handler(srv)) - r.DELETE("/sys/positions/{id}", _PositionService_DeletePosition0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go new file mode 100644 index 00000000..d9897220 --- /dev/null +++ b/api/v1/services/system/position_bridge.pb.go @@ -0,0 +1,298 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/position.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const PositionServiceCreatePositionBridgeOperation = "/api.v1.services.system.PositionService/CreatePosition" +const PositionServiceDeletePositionBridgeOperation = "/api.v1.services.system.PositionService/DeletePosition" +const PositionServiceGetPositionBridgeOperation = "/api.v1.services.system.PositionService/GetPosition" +const PositionServiceListPositionsBridgeOperation = "/api.v1.services.system.PositionService/ListPositions" +const PositionServiceUpdatePositionBridgeOperation = "/api.v1.services.system.PositionService/UpdatePosition" + +type PositionServiceBridger interface { + CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) + DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) + GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) + ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) + UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) +} + +type PositionServiceBridgeHooker interface { + PositionServiceBridger + BeforeCreatePosition(http.Context, *CreatePositionRequest) (context.Context, error) + CreatePositionResult(http.Context, *CreatePositionRequest, *CreatePositionResponse) error + BeforeDeletePosition(http.Context, *DeletePositionRequest) (context.Context, error) + DeletePositionResult(http.Context, *DeletePositionRequest, *DeletePositionResponse) error + BeforeGetPosition(http.Context, *GetPositionRequest) (context.Context, error) + GetPositionResult(http.Context, *GetPositionRequest, *GetPositionResponse) error + BeforeListPositions(http.Context, *ListPositionsRequest) (context.Context, error) + ListPositionsResult(http.Context, *ListPositionsRequest, *ListPositionsResponse) error + BeforeUpdatePosition(http.Context, *UpdatePositionRequest) (context.Context, error) + UpdatePositionResult(http.Context, *UpdatePositionRequest, *UpdatePositionResponse) error +} + +func RegisterPositionServiceBridger(s *http.Server, srv PositionServiceBridger) { + r := s.Route("/") + hook, ok := srv.(PositionServiceBridgeHooker) + if !ok { + hook = UnimplementedPositionServiceBridger{PositionServiceBridger: srv} + } + r.GET("/sys/positions", _PositionService_ListPositions0_Bridge_Handler(hook)) + r.GET("/sys/positions/:id", _PositionService_GetPosition0_Bridge_Handler(hook)) + r.POST("/sys/positions", _PositionService_CreatePosition0_Bridge_Handler(hook)) + r.PUT("/sys/positions/:position.id", _PositionService_UpdatePosition0_Bridge_Handler(hook)) + r.DELETE("/sys/positions/:id", _PositionService_DeletePosition0_Bridge_Handler(hook)) +} + +func _PositionService_ListPositions0_Bridge_Handler(srv PositionServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPositionsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceListPositions) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPositions(ctx, req.(*ListPositionsRequest)) + }) + + newctx, err := srv.BeforeListPositions(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListPositionsResult(ctx, &in, out.(*ListPositionsResponse)) + } +} + +func _PositionService_GetPosition0_Bridge_Handler(srv PositionServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPositionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceGetPosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPosition(ctx, req.(*GetPositionRequest)) + }) + + newctx, err := srv.BeforeGetPosition(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.GetPositionResult(ctx, &in, out.(*GetPositionResponse)) + } +} + +func _PositionService_CreatePosition0_Bridge_Handler(srv PositionServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreatePositionRequest + if err := ctx.Bind(&in.Position); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceCreatePosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreatePosition(ctx, req.(*CreatePositionRequest)) + }) + + newctx, err := srv.BeforeCreatePosition(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CreatePositionResult(ctx, &in, out.(*CreatePositionResponse)) + } +} + +func _PositionService_UpdatePosition0_Bridge_Handler(srv PositionServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePositionRequest + if err := ctx.Bind(&in.Position); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceUpdatePosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePosition(ctx, req.(*UpdatePositionRequest)) + }) + + newctx, err := srv.BeforeUpdatePosition(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdatePositionResult(ctx, &in, out.(*UpdatePositionResponse)) + } +} + +func _PositionService_DeletePosition0_Bridge_Handler(srv PositionServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeletePositionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceDeletePosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeletePosition(ctx, req.(*DeletePositionRequest)) + }) + + newctx, err := srv.BeforeDeletePosition(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.DeletePositionResult(ctx, &in, out.(*DeletePositionResponse)) + } +} + +// UnimplementedPositionServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPositionServiceBridger struct { + PositionServiceBridger +} + +func (UnimplementedPositionServiceBridger) BeforeCreatePosition(ctx http.Context, in *CreatePositionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPositionServiceBridger) CreatePositionResult(ctx http.Context, in *CreatePositionRequest, out *CreatePositionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPositionServiceBridger) BeforeDeletePosition(ctx http.Context, in *DeletePositionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPositionServiceBridger) DeletePositionResult(ctx http.Context, in *DeletePositionRequest, out *DeletePositionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPositionServiceBridger) BeforeGetPosition(ctx http.Context, in *GetPositionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPositionServiceBridger) GetPositionResult(ctx http.Context, in *GetPositionRequest, out *GetPositionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPositionServiceBridger) BeforeListPositions(ctx http.Context, in *ListPositionsRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPositionServiceBridger) ListPositionsResult(ctx http.Context, in *ListPositionsRequest, out *ListPositionsResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPositionServiceBridger) BeforeUpdatePosition(ctx http.Context, in *UpdatePositionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPositionServiceBridger) UpdatePositionResult(ctx http.Context, in *UpdatePositionRequest, out *UpdatePositionResponse) error { + return ctx.Result(200, out) +} + +type PositionServiceHTTPBridgeImpl struct { + client PositionServiceHTTPClient +} + +func NewPositionServiceHTTPBridge(client *http.Client) PositionServiceHTTPServer { + return &PositionServiceHTTPBridgeImpl{client: NewPositionServiceHTTPClient(client)} +} + +func (c *PositionServiceHTTPBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) +} + +func (c *PositionServiceHTTPBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + +func (c *PositionServiceHTTPBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { + return c.client.GetPosition(ctx, in) +} + +func (c *PositionServiceHTTPBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) +} + +func (c *PositionServiceHTTPBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { + return c.client.UpdatePosition(ctx, in) +} + +type PositionServiceBridgeImpl struct { + client PositionServiceClient +} + +func NewPositionServiceBridge(client grpc.ClientConnInterface) PositionServiceServer { + return &PositionServiceBridgeImpl{client: NewPositionServiceClient(client)} +} + +func (c *PositionServiceBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) +} + +func (c *PositionServiceBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + +func (c *PositionServiceBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { + return c.client.GetPosition(ctx, in) +} + +func (c *PositionServiceBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) +} + +func (c *PositionServiceBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { + return c.client.UpdatePosition(ctx, in) +} + +func (c *PositionServiceBridgeImpl) mustEmbedUnimplementedPositionServiceServer() {} diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go index e2a9c541..0d1d0c74 100644 --- a/api/v1/services/system/resource.pb.go +++ b/api/v1/services/system/resource.pb.go @@ -15,6 +15,7 @@ import ( reflect "reflect" sync "sync" unsafe "unsafe" + types "v1/services/types" ) const ( @@ -130,7 +131,7 @@ type ListResourcesResponse struct { // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging resources - Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` // The current page number. Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` // The maximum number of items to return. @@ -182,7 +183,7 @@ func (x *ListResourcesResponse) GetTotalSize() int32 { return 0 } -func (x *ListResourcesResponse) GetResources() []*Resource { +func (x *ListResourcesResponse) GetResources() []*types.Resource { if x != nil { return x.Resources } @@ -268,7 +269,7 @@ func (x *GetResourceRequest) GetId() int64 { type GetResourceResponse struct { state protoimpl.MessageState `protogen:"open.v1"` // The field id should match the Noun in the method id. - Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -303,7 +304,7 @@ func (*GetResourceResponse) Descriptor() ([]byte, []int) { return file_system_resource_proto_rawDescGZIP(), []int{3} } -func (x *GetResourceResponse) GetResource() *Resource { +func (x *GetResourceResponse) GetResource() *types.Resource { if x != nil { return x.Resource } @@ -318,7 +319,7 @@ type CreateResourceRequest struct { // The resource id to use for this resource. ResourceId string `protobuf:"bytes,2,opt,name=resource_id,proto3" json:"resource_id,omitempty"` // The resource object to create. - Resource *Resource `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` + Resource *types.Resource `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -367,7 +368,7 @@ func (x *CreateResourceRequest) GetResourceId() string { return "" } -func (x *CreateResourceRequest) GetResource() *Resource { +func (x *CreateResourceRequest) GetResource() *types.Resource { if x != nil { return x.Resource } @@ -377,7 +378,7 @@ func (x *CreateResourceRequest) GetResource() *Resource { // CreateResourceResponse is the response for the ResourceService.CreateResource method. type CreateResourceResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -412,7 +413,7 @@ func (*CreateResourceResponse) Descriptor() ([]byte, []int) { return file_system_resource_proto_rawDescGZIP(), []int{5} } -func (x *CreateResourceResponse) GetResource() *Resource { +func (x *CreateResourceResponse) GetResource() *types.Resource { if x != nil { return x.Resource } @@ -425,7 +426,7 @@ type UpdateResourceRequest struct { // The id of the resource object to update. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The resource object which replaces the resource on the server. - Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` + Resource *types.Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -467,7 +468,7 @@ func (x *UpdateResourceRequest) GetId() int64 { return 0 } -func (x *UpdateResourceRequest) GetResource() *Resource { +func (x *UpdateResourceRequest) GetResource() *types.Resource { if x != nil { return x.Resource } @@ -477,7 +478,7 @@ func (x *UpdateResourceRequest) GetResource() *Resource { // UpdateResourceResponse is the response for the ResourceService.UpdateResource method. type UpdateResourceResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Resource *Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -512,7 +513,7 @@ func (*UpdateResourceResponse) Descriptor() ([]byte, []int) { return file_system_resource_proto_rawDescGZIP(), []int{7} } -func (x *UpdateResourceResponse) GetResource() *Resource { +func (x *UpdateResourceResponse) GetResource() *types.Resource { if x != nil { return x.Resource } @@ -616,7 +617,7 @@ var File_system_resource_proto protoreflect.FileDescriptor const file_system_resource_proto_rawDesc = "" + "\n" + - "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xd0\x01\n" + + "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xd0\x01\n" + "\x14ListResourcesRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + @@ -628,32 +629,32 @@ const file_system_resource_proto_rawDesc = "" + "\n" + "only_count\x18\x06 \x01(\bR\n" + "only_count\x12\x12\n" + - "\x04type\x18\a \x01(\tR\x04type\"\x94\x02\n" + + "\x04type\x18\a \x01(\tR\x04type\"\x93\x02\n" + "\x15ListResourcesResponse\x12\x1e\n" + "\n" + "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x12>\n" + - "\tresources\x18\x02 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x12\x18\n" + + "total_size\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x18\n" + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + "\x06_extra\"$\n" + "\x12GetResourceRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"S\n" + - "\x13GetResourceResponse\x12<\n" + - "\bresource\x18\x01 \x01(\v2 .api.v1.services.system.ResourceR\bresource\"\x8f\x01\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"R\n" + + "\x13GetResourceResponse\x12;\n" + + "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"\x8e\x01\n" + "\x15CreateResourceRequest\x12\x16\n" + "\x06parent\x18\x01 \x01(\tR\x06parent\x12 \n" + - "\vresource_id\x18\x02 \x01(\tR\vresource_id\x12<\n" + - "\bresource\x18\x03 \x01(\v2 .api.v1.services.system.ResourceR\bresource\"V\n" + - "\x16CreateResourceResponse\x12<\n" + - "\bresource\x18\x01 \x01(\v2 .api.v1.services.system.ResourceR\bresource\"e\n" + + "\vresource_id\x18\x02 \x01(\tR\vresource_id\x12;\n" + + "\bresource\x18\x03 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"U\n" + + "\x16CreateResourceResponse\x12;\n" + + "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"d\n" + "\x15UpdateResourceRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\bresource\x18\x02 \x01(\v2 .api.v1.services.system.ResourceR\bresource\"V\n" + - "\x16UpdateResourceResponse\x12<\n" + - "\bresource\x18\x01 \x01(\v2 .api.v1.services.system.ResourceR\bresource\"'\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12;\n" + + "\bresource\x18\x02 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"U\n" + + "\x16UpdateResourceResponse\x12;\n" + + "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"'\n" + "\x15DeleteResourceRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + "\x16DeleteResourceResponse\x12,\n" + @@ -690,18 +691,18 @@ var file_system_resource_proto_goTypes = []any{ (*UpdateResourceResponse)(nil), // 7: api.v1.services.system.UpdateResourceResponse (*DeleteResourceRequest)(nil), // 8: api.v1.services.system.DeleteResourceRequest (*DeleteResourceResponse)(nil), // 9: api.v1.services.system.DeleteResourceResponse - (*Resource)(nil), // 10: api.v1.services.system.Resource + (*types.Resource)(nil), // 10: api.v1.services.types.Resource (*anypb.Any)(nil), // 11: google.protobuf.Any (*emptypb.Empty)(nil), // 12: google.protobuf.Empty } var file_system_resource_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListResourcesResponse.resources:type_name -> api.v1.services.system.Resource + 10, // 0: api.v1.services.system.ListResourcesResponse.resources:type_name -> api.v1.services.types.Resource 11, // 1: api.v1.services.system.ListResourcesResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetResourceResponse.resource:type_name -> api.v1.services.system.Resource - 10, // 3: api.v1.services.system.CreateResourceRequest.resource:type_name -> api.v1.services.system.Resource - 10, // 4: api.v1.services.system.CreateResourceResponse.resource:type_name -> api.v1.services.system.Resource - 10, // 5: api.v1.services.system.UpdateResourceRequest.resource:type_name -> api.v1.services.system.Resource - 10, // 6: api.v1.services.system.UpdateResourceResponse.resource:type_name -> api.v1.services.system.Resource + 10, // 2: api.v1.services.system.GetResourceResponse.resource:type_name -> api.v1.services.types.Resource + 10, // 3: api.v1.services.system.CreateResourceRequest.resource:type_name -> api.v1.services.types.Resource + 10, // 4: api.v1.services.system.CreateResourceResponse.resource:type_name -> api.v1.services.types.Resource + 10, // 5: api.v1.services.system.UpdateResourceRequest.resource:type_name -> api.v1.services.types.Resource + 10, // 6: api.v1.services.system.UpdateResourceResponse.resource:type_name -> api.v1.services.types.Resource 12, // 7: api.v1.services.system.DeleteResourceResponse.empty:type_name -> google.protobuf.Empty 0, // 8: api.v1.services.system.ResourceService.ListResources:input_type -> api.v1.services.system.ListResourcesRequest 2, // 9: api.v1.services.system.ResourceService.GetResource:input_type -> api.v1.services.system.GetResourceRequest @@ -725,7 +726,6 @@ func file_system_resource_proto_init() { if File_system_resource_proto != nil { return } - file_system_types_proto_init() file_system_resource_proto_msgTypes[1].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ diff --git a/api/v1/services/system/resource_agent.pb.go b/api/v1/services/system/resource_agent.pb.go deleted file mode 100644 index 95d6d044..00000000 --- a/api/v1/services/system/resource_agent.pb.go +++ /dev/null @@ -1,169 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/resource.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type ResourceServiceAgent interface { - CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) - DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) - GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) - ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) - UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) -} - -func _ResourceService_ListResources0_HTTPAgent_Handler(srv ResourceServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListResourcesRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationResourceServiceListResources) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListResources(ctx, req.(*ListResourcesRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListResourcesResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _ResourceService_GetResource0_HTTPAgent_Handler(srv ResourceServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in GetResourceRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationResourceServiceGetResource) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.GetResource(ctx, req.(*GetResourceRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*GetResourceResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _ResourceService_CreateResource0_HTTPAgent_Handler(srv ResourceServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CreateResourceRequest - if err := cctx.Bind(&in.Resource); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationResourceServiceCreateResource) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CreateResource(ctx, req.(*CreateResourceRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CreateResourceResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _ResourceService_UpdateResource0_HTTPAgent_Handler(srv ResourceServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdateResourceRequest - if err := cctx.Bind(&in.Resource); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationResourceServiceUpdateResource) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdateResource(ctx, req.(*UpdateResourceRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateResourceResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _ResourceService_DeleteResource0_HTTPAgent_Handler(srv ResourceServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in DeleteResourceRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationResourceServiceDeleteResource) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.DeleteResource(ctx, req.(*DeleteResourceRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteResourceResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterResourceServiceAgent(ag agent.HTTPAgent, srv ResourceServiceAgent) { - r := ag.Route() - r.GET("/sys/resources", _ResourceService_ListResources0_HTTPAgent_Handler(srv)) - r.GET("/sys/resources/{id}", _ResourceService_GetResource0_HTTPAgent_Handler(srv)) - r.POST("/sys/resources", _ResourceService_CreateResource0_HTTPAgent_Handler(srv)) - r.PUT("/sys/resources/{resource.id}", _ResourceService_UpdateResource0_HTTPAgent_Handler(srv)) - r.DELETE("/sys/resources/{id}", _ResourceService_DeleteResource0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go new file mode 100644 index 00000000..c20a50a9 --- /dev/null +++ b/api/v1/services/system/resource_bridge.pb.go @@ -0,0 +1,298 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/resource.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const ResourceServiceCreateResourceBridgeOperation = "/api.v1.services.system.ResourceService/CreateResource" +const ResourceServiceDeleteResourceBridgeOperation = "/api.v1.services.system.ResourceService/DeleteResource" +const ResourceServiceGetResourceBridgeOperation = "/api.v1.services.system.ResourceService/GetResource" +const ResourceServiceListResourcesBridgeOperation = "/api.v1.services.system.ResourceService/ListResources" +const ResourceServiceUpdateResourceBridgeOperation = "/api.v1.services.system.ResourceService/UpdateResource" + +type ResourceServiceBridger interface { + CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) + DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) + GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) + ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) + UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) +} + +type ResourceServiceBridgeHooker interface { + ResourceServiceBridger + BeforeCreateResource(http.Context, *CreateResourceRequest) (context.Context, error) + CreateResourceResult(http.Context, *CreateResourceRequest, *CreateResourceResponse) error + BeforeDeleteResource(http.Context, *DeleteResourceRequest) (context.Context, error) + DeleteResourceResult(http.Context, *DeleteResourceRequest, *DeleteResourceResponse) error + BeforeGetResource(http.Context, *GetResourceRequest) (context.Context, error) + GetResourceResult(http.Context, *GetResourceRequest, *GetResourceResponse) error + BeforeListResources(http.Context, *ListResourcesRequest) (context.Context, error) + ListResourcesResult(http.Context, *ListResourcesRequest, *ListResourcesResponse) error + BeforeUpdateResource(http.Context, *UpdateResourceRequest) (context.Context, error) + UpdateResourceResult(http.Context, *UpdateResourceRequest, *UpdateResourceResponse) error +} + +func RegisterResourceServiceBridger(s *http.Server, srv ResourceServiceBridger) { + r := s.Route("/") + hook, ok := srv.(ResourceServiceBridgeHooker) + if !ok { + hook = UnimplementedResourceServiceBridger{ResourceServiceBridger: srv} + } + r.GET("/sys/resources", _ResourceService_ListResources0_Bridge_Handler(hook)) + r.GET("/sys/resources/:id", _ResourceService_GetResource0_Bridge_Handler(hook)) + r.POST("/sys/resources", _ResourceService_CreateResource0_Bridge_Handler(hook)) + r.PUT("/sys/resources/:resource.id", _ResourceService_UpdateResource0_Bridge_Handler(hook)) + r.DELETE("/sys/resources/:id", _ResourceService_DeleteResource0_Bridge_Handler(hook)) +} + +func _ResourceService_ListResources0_Bridge_Handler(srv ResourceServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceListResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListResources(ctx, req.(*ListResourcesRequest)) + }) + + newctx, err := srv.BeforeListResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListResourcesResult(ctx, &in, out.(*ListResourcesResponse)) + } +} + +func _ResourceService_GetResource0_Bridge_Handler(srv ResourceServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetResourceRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceGetResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetResource(ctx, req.(*GetResourceRequest)) + }) + + newctx, err := srv.BeforeGetResource(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.GetResourceResult(ctx, &in, out.(*GetResourceResponse)) + } +} + +func _ResourceService_CreateResource0_Bridge_Handler(srv ResourceServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateResourceRequest + if err := ctx.Bind(&in.Resource); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceCreateResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateResource(ctx, req.(*CreateResourceRequest)) + }) + + newctx, err := srv.BeforeCreateResource(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CreateResourceResult(ctx, &in, out.(*CreateResourceResponse)) + } +} + +func _ResourceService_UpdateResource0_Bridge_Handler(srv ResourceServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateResourceRequest + if err := ctx.Bind(&in.Resource); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceUpdateResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateResource(ctx, req.(*UpdateResourceRequest)) + }) + + newctx, err := srv.BeforeUpdateResource(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdateResourceResult(ctx, &in, out.(*UpdateResourceResponse)) + } +} + +func _ResourceService_DeleteResource0_Bridge_Handler(srv ResourceServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteResourceRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceDeleteResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteResource(ctx, req.(*DeleteResourceRequest)) + }) + + newctx, err := srv.BeforeDeleteResource(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.DeleteResourceResult(ctx, &in, out.(*DeleteResourceResponse)) + } +} + +// UnimplementedResourceServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedResourceServiceBridger struct { + ResourceServiceBridger +} + +func (UnimplementedResourceServiceBridger) BeforeCreateResource(ctx http.Context, in *CreateResourceRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedResourceServiceBridger) CreateResourceResult(ctx http.Context, in *CreateResourceRequest, out *CreateResourceResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedResourceServiceBridger) BeforeDeleteResource(ctx http.Context, in *DeleteResourceRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedResourceServiceBridger) DeleteResourceResult(ctx http.Context, in *DeleteResourceRequest, out *DeleteResourceResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedResourceServiceBridger) BeforeGetResource(ctx http.Context, in *GetResourceRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedResourceServiceBridger) GetResourceResult(ctx http.Context, in *GetResourceRequest, out *GetResourceResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedResourceServiceBridger) BeforeListResources(ctx http.Context, in *ListResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedResourceServiceBridger) ListResourcesResult(ctx http.Context, in *ListResourcesRequest, out *ListResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedResourceServiceBridger) BeforeUpdateResource(ctx http.Context, in *UpdateResourceRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedResourceServiceBridger) UpdateResourceResult(ctx http.Context, in *UpdateResourceRequest, out *UpdateResourceResponse) error { + return ctx.Result(200, out) +} + +type ResourceServiceHTTPBridgeImpl struct { + client ResourceServiceHTTPClient +} + +func NewResourceServiceHTTPBridge(client *http.Client) ResourceServiceHTTPServer { + return &ResourceServiceHTTPBridgeImpl{client: NewResourceServiceHTTPClient(client)} +} + +func (c *ResourceServiceHTTPBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) +} + +func (c *ResourceServiceHTTPBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + +func (c *ResourceServiceHTTPBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { + return c.client.GetResource(ctx, in) +} + +func (c *ResourceServiceHTTPBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) +} + +func (c *ResourceServiceHTTPBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { + return c.client.UpdateResource(ctx, in) +} + +type ResourceServiceBridgeImpl struct { + client ResourceServiceClient +} + +func NewResourceServiceBridge(client grpc.ClientConnInterface) ResourceServiceServer { + return &ResourceServiceBridgeImpl{client: NewResourceServiceClient(client)} +} + +func (c *ResourceServiceBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) +} + +func (c *ResourceServiceBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + +func (c *ResourceServiceBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { + return c.client.GetResource(ctx, in) +} + +func (c *ResourceServiceBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) +} + +func (c *ResourceServiceBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { + return c.client.UpdateResource(ctx, in) +} + +func (c *ResourceServiceBridgeImpl) mustEmbedUnimplementedResourceServiceServer() {} diff --git a/api/v1/services/system/role.pb.go b/api/v1/services/system/role.pb.go index 3cd48acd..1e6772ac 100644 --- a/api/v1/services/system/role.pb.go +++ b/api/v1/services/system/role.pb.go @@ -15,6 +15,7 @@ import ( reflect "reflect" sync "sync" unsafe "unsafe" + types "v1/services/types" ) const ( @@ -119,7 +120,7 @@ type ListRolesResponse struct { // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus - Roles []*Role `protobuf:"bytes,2,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*types.Role `protobuf:"bytes,2,rep,name=roles,proto3" json:"roles,omitempty"` // The current page number. Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` // The maximum number of items to return. @@ -171,7 +172,7 @@ func (x *ListRolesResponse) GetTotalSize() int32 { return 0 } -func (x *ListRolesResponse) GetRoles() []*Role { +func (x *ListRolesResponse) GetRoles() []*types.Role { if x != nil { return x.Roles } @@ -254,7 +255,7 @@ func (x *GetRoleRequest) GetId() int64 { type GetRoleResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -289,7 +290,7 @@ func (*GetRoleResponse) Descriptor() ([]byte, []int) { return file_system_role_proto_rawDescGZIP(), []int{3} } -func (x *GetRoleResponse) GetRole() *Role { +func (x *GetRoleResponse) GetRole() *types.Role { if x != nil { return x.Role } @@ -304,7 +305,7 @@ type CreateRoleRequest struct { RoleId string `protobuf:"bytes,3,opt,name=role_id,proto3" json:"role_id,omitempty"` // The role resource to create. // The field id should match the Noun in the method id. - Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + Role *types.Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -353,7 +354,7 @@ func (x *CreateRoleRequest) GetRoleId() string { return "" } -func (x *CreateRoleRequest) GetRole() *Role { +func (x *CreateRoleRequest) GetRole() *types.Role { if x != nil { return x.Role } @@ -362,7 +363,7 @@ func (x *CreateRoleRequest) GetRole() *Role { type CreateRoleResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -397,7 +398,7 @@ func (*CreateRoleResponse) Descriptor() ([]byte, []int) { return file_system_role_proto_rawDescGZIP(), []int{5} } -func (x *CreateRoleResponse) GetRole() *Role { +func (x *CreateRoleResponse) GetRole() *types.Role { if x != nil { return x.Role } @@ -409,7 +410,7 @@ type UpdateRoleRequest struct { // The id of the role resource to update. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // The role resource which replaces the resource on the server. - Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + Role *types.Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -451,7 +452,7 @@ func (x *UpdateRoleRequest) GetId() int64 { return 0 } -func (x *UpdateRoleRequest) GetRole() *Role { +func (x *UpdateRoleRequest) GetRole() *types.Role { if x != nil { return x.Role } @@ -460,7 +461,7 @@ func (x *UpdateRoleRequest) GetRole() *Role { type UpdateRoleResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -495,7 +496,7 @@ func (*UpdateRoleResponse) Descriptor() ([]byte, []int) { return file_system_role_proto_rawDescGZIP(), []int{7} } -func (x *UpdateRoleResponse) GetRole() *Role { +func (x *UpdateRoleResponse) GetRole() *types.Role { if x != nil { return x.Role } @@ -596,7 +597,7 @@ var File_system_role_proto protoreflect.FileDescriptor const file_system_role_proto_rawDesc = "" + "\n" + - "\x11system/role.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"\xb8\x01\n" + + "\x11system/role.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xb8\x01\n" + "\x10ListRolesRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + @@ -607,32 +608,32 @@ const file_system_role_proto_rawDesc = "" + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + "\n" + "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\x84\x02\n" + + "only_count\"\x83\x02\n" + "\x11ListRolesResponse\x12\x1e\n" + "\n" + "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x122\n" + - "\x05roles\x18\x02 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\x12\x18\n" + + "total_size\x121\n" + + "\x05roles\x18\x02 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x18\n" + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + "\x06_extra\" \n" + "\x0eGetRoleRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"C\n" + - "\x0fGetRoleResponse\x120\n" + - "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"w\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x0fGetRoleResponse\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"v\n" + "\x11CreateRoleRequest\x12\x16\n" + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x18\n" + - "\arole_id\x18\x03 \x01(\tR\arole_id\x120\n" + - "\x04role\x18\x02 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"F\n" + - "\x12CreateRoleResponse\x120\n" + - "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"U\n" + + "\arole_id\x18\x03 \x01(\tR\arole_id\x12/\n" + + "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"E\n" + + "\x12CreateRoleResponse\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"T\n" + "\x11UpdateRoleRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x120\n" + - "\x04role\x18\x02 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"F\n" + - "\x12UpdateRoleResponse\x120\n" + - "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"#\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12/\n" + + "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"E\n" + + "\x12UpdateRoleResponse\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"#\n" + "\x11DeleteRoleRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + "\x12DeleteRoleResponse\x12,\n" + @@ -674,18 +675,18 @@ var file_system_role_proto_goTypes = []any{ (*UpdateRoleResponse)(nil), // 7: api.v1.services.system.UpdateRoleResponse (*DeleteRoleRequest)(nil), // 8: api.v1.services.system.DeleteRoleRequest (*DeleteRoleResponse)(nil), // 9: api.v1.services.system.DeleteRoleResponse - (*Role)(nil), // 10: api.v1.services.system.Role + (*types.Role)(nil), // 10: api.v1.services.types.Role (*anypb.Any)(nil), // 11: google.protobuf.Any (*emptypb.Empty)(nil), // 12: google.protobuf.Empty } var file_system_role_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListRolesResponse.roles:type_name -> api.v1.services.system.Role + 10, // 0: api.v1.services.system.ListRolesResponse.roles:type_name -> api.v1.services.types.Role 11, // 1: api.v1.services.system.ListRolesResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetRoleResponse.role:type_name -> api.v1.services.system.Role - 10, // 3: api.v1.services.system.CreateRoleRequest.role:type_name -> api.v1.services.system.Role - 10, // 4: api.v1.services.system.CreateRoleResponse.role:type_name -> api.v1.services.system.Role - 10, // 5: api.v1.services.system.UpdateRoleRequest.role:type_name -> api.v1.services.system.Role - 10, // 6: api.v1.services.system.UpdateRoleResponse.role:type_name -> api.v1.services.system.Role + 10, // 2: api.v1.services.system.GetRoleResponse.role:type_name -> api.v1.services.types.Role + 10, // 3: api.v1.services.system.CreateRoleRequest.role:type_name -> api.v1.services.types.Role + 10, // 4: api.v1.services.system.CreateRoleResponse.role:type_name -> api.v1.services.types.Role + 10, // 5: api.v1.services.system.UpdateRoleRequest.role:type_name -> api.v1.services.types.Role + 10, // 6: api.v1.services.system.UpdateRoleResponse.role:type_name -> api.v1.services.types.Role 12, // 7: api.v1.services.system.DeleteRoleResponse.empty:type_name -> google.protobuf.Empty 0, // 8: api.v1.services.system.RoleService.ListRoles:input_type -> api.v1.services.system.ListRolesRequest 2, // 9: api.v1.services.system.RoleService.GetRole:input_type -> api.v1.services.system.GetRoleRequest @@ -709,7 +710,6 @@ func file_system_role_proto_init() { if File_system_role_proto != nil { return } - file_system_types_proto_init() file_system_role_proto_msgTypes[1].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ diff --git a/api/v1/services/system/role_agent.pb.go b/api/v1/services/system/role_agent.pb.go deleted file mode 100644 index 54004364..00000000 --- a/api/v1/services/system/role_agent.pb.go +++ /dev/null @@ -1,169 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/role.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type RoleServiceAgent interface { - CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) - DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) - GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) - ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) - UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) -} - -func _RoleService_ListRoles0_HTTPAgent_Handler(srv RoleServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListRolesRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationRoleServiceListRoles) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListRoles(ctx, req.(*ListRolesRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListRolesResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _RoleService_GetRole0_HTTPAgent_Handler(srv RoleServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in GetRoleRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationRoleServiceGetRole) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.GetRole(ctx, req.(*GetRoleRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*GetRoleResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _RoleService_CreateRole0_HTTPAgent_Handler(srv RoleServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CreateRoleRequest - if err := cctx.Bind(&in.Role); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationRoleServiceCreateRole) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CreateRole(ctx, req.(*CreateRoleRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CreateRoleResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _RoleService_UpdateRole0_HTTPAgent_Handler(srv RoleServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdateRoleRequest - if err := cctx.Bind(&in.Role); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationRoleServiceUpdateRole) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdateRole(ctx, req.(*UpdateRoleRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateRoleResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _RoleService_DeleteRole0_HTTPAgent_Handler(srv RoleServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in DeleteRoleRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationRoleServiceDeleteRole) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.DeleteRole(ctx, req.(*DeleteRoleRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteRoleResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterRoleServiceAgent(ag agent.HTTPAgent, srv RoleServiceAgent) { - r := ag.Route() - r.GET("/sys/roles", _RoleService_ListRoles0_HTTPAgent_Handler(srv)) - r.GET("/sys/roles/{id}", _RoleService_GetRole0_HTTPAgent_Handler(srv)) - r.POST("/sys/roles", _RoleService_CreateRole0_HTTPAgent_Handler(srv)) - r.PUT("/sys/roles/{role.id}", _RoleService_UpdateRole0_HTTPAgent_Handler(srv)) - r.DELETE("/sys/roles/{id}", _RoleService_DeleteRole0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go new file mode 100644 index 00000000..5c18e714 --- /dev/null +++ b/api/v1/services/system/role_bridge.pb.go @@ -0,0 +1,298 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/role.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const RoleServiceCreateRoleBridgeOperation = "/api.v1.services.system.RoleService/CreateRole" +const RoleServiceDeleteRoleBridgeOperation = "/api.v1.services.system.RoleService/DeleteRole" +const RoleServiceGetRoleBridgeOperation = "/api.v1.services.system.RoleService/GetRole" +const RoleServiceListRolesBridgeOperation = "/api.v1.services.system.RoleService/ListRoles" +const RoleServiceUpdateRoleBridgeOperation = "/api.v1.services.system.RoleService/UpdateRole" + +type RoleServiceBridger interface { + CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) + DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) + GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) + ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) + UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) +} + +type RoleServiceBridgeHooker interface { + RoleServiceBridger + BeforeCreateRole(http.Context, *CreateRoleRequest) (context.Context, error) + CreateRoleResult(http.Context, *CreateRoleRequest, *CreateRoleResponse) error + BeforeDeleteRole(http.Context, *DeleteRoleRequest) (context.Context, error) + DeleteRoleResult(http.Context, *DeleteRoleRequest, *DeleteRoleResponse) error + BeforeGetRole(http.Context, *GetRoleRequest) (context.Context, error) + GetRoleResult(http.Context, *GetRoleRequest, *GetRoleResponse) error + BeforeListRoles(http.Context, *ListRolesRequest) (context.Context, error) + ListRolesResult(http.Context, *ListRolesRequest, *ListRolesResponse) error + BeforeUpdateRole(http.Context, *UpdateRoleRequest) (context.Context, error) + UpdateRoleResult(http.Context, *UpdateRoleRequest, *UpdateRoleResponse) error +} + +func RegisterRoleServiceBridger(s *http.Server, srv RoleServiceBridger) { + r := s.Route("/") + hook, ok := srv.(RoleServiceBridgeHooker) + if !ok { + hook = UnimplementedRoleServiceBridger{RoleServiceBridger: srv} + } + r.GET("/sys/roles", _RoleService_ListRoles0_Bridge_Handler(hook)) + r.GET("/sys/roles/:id", _RoleService_GetRole0_Bridge_Handler(hook)) + r.POST("/sys/roles", _RoleService_CreateRole0_Bridge_Handler(hook)) + r.PUT("/sys/roles/:role.id", _RoleService_UpdateRole0_Bridge_Handler(hook)) + r.DELETE("/sys/roles/:id", _RoleService_DeleteRole0_Bridge_Handler(hook)) +} + +func _RoleService_ListRoles0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceListRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListRoles(ctx, req.(*ListRolesRequest)) + }) + + newctx, err := srv.BeforeListRoles(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListRolesResult(ctx, &in, out.(*ListRolesResponse)) + } +} + +func _RoleService_GetRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetRoleRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceGetRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetRole(ctx, req.(*GetRoleRequest)) + }) + + newctx, err := srv.BeforeGetRole(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.GetRoleResult(ctx, &in, out.(*GetRoleResponse)) + } +} + +func _RoleService_CreateRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateRoleRequest + if err := ctx.Bind(&in.Role); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceCreateRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateRole(ctx, req.(*CreateRoleRequest)) + }) + + newctx, err := srv.BeforeCreateRole(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CreateRoleResult(ctx, &in, out.(*CreateRoleResponse)) + } +} + +func _RoleService_UpdateRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateRoleRequest + if err := ctx.Bind(&in.Role); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceUpdateRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateRole(ctx, req.(*UpdateRoleRequest)) + }) + + newctx, err := srv.BeforeUpdateRole(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdateRoleResult(ctx, &in, out.(*UpdateRoleResponse)) + } +} + +func _RoleService_DeleteRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteRoleRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceDeleteRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteRole(ctx, req.(*DeleteRoleRequest)) + }) + + newctx, err := srv.BeforeDeleteRole(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.DeleteRoleResult(ctx, &in, out.(*DeleteRoleResponse)) + } +} + +// UnimplementedRoleServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedRoleServiceBridger struct { + RoleServiceBridger +} + +func (UnimplementedRoleServiceBridger) BeforeCreateRole(ctx http.Context, in *CreateRoleRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedRoleServiceBridger) CreateRoleResult(ctx http.Context, in *CreateRoleRequest, out *CreateRoleResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedRoleServiceBridger) BeforeDeleteRole(ctx http.Context, in *DeleteRoleRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedRoleServiceBridger) DeleteRoleResult(ctx http.Context, in *DeleteRoleRequest, out *DeleteRoleResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedRoleServiceBridger) BeforeGetRole(ctx http.Context, in *GetRoleRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedRoleServiceBridger) GetRoleResult(ctx http.Context, in *GetRoleRequest, out *GetRoleResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedRoleServiceBridger) BeforeListRoles(ctx http.Context, in *ListRolesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedRoleServiceBridger) ListRolesResult(ctx http.Context, in *ListRolesRequest, out *ListRolesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedRoleServiceBridger) BeforeUpdateRole(ctx http.Context, in *UpdateRoleRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedRoleServiceBridger) UpdateRoleResult(ctx http.Context, in *UpdateRoleRequest, out *UpdateRoleResponse) error { + return ctx.Result(200, out) +} + +type RoleServiceHTTPBridgeImpl struct { + client RoleServiceHTTPClient +} + +func NewRoleServiceHTTPBridge(client *http.Client) RoleServiceHTTPServer { + return &RoleServiceHTTPBridgeImpl{client: NewRoleServiceHTTPClient(client)} +} + +func (c *RoleServiceHTTPBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) +} + +func (c *RoleServiceHTTPBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + +func (c *RoleServiceHTTPBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { + return c.client.GetRole(ctx, in) +} + +func (c *RoleServiceHTTPBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) +} + +func (c *RoleServiceHTTPBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { + return c.client.UpdateRole(ctx, in) +} + +type RoleServiceBridgeImpl struct { + client RoleServiceClient +} + +func NewRoleServiceBridge(client grpc.ClientConnInterface) RoleServiceServer { + return &RoleServiceBridgeImpl{client: NewRoleServiceClient(client)} +} + +func (c *RoleServiceBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) +} + +func (c *RoleServiceBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + +func (c *RoleServiceBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { + return c.client.GetRole(ctx, in) +} + +func (c *RoleServiceBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) +} + +func (c *RoleServiceBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { + return c.client.UpdateRole(ctx, in) +} + +func (c *RoleServiceBridgeImpl) mustEmbedUnimplementedRoleServiceServer() {} diff --git a/api/v1/services/system/types.pb.go b/api/v1/services/system/types.pb.go deleted file mode 100644 index 5491d861..00000000 --- a/api/v1/services/system/types.pb.go +++ /dev/null @@ -1,3206 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc (unknown) -// source: system/types.proto - -package system - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Menu is the model entity for the Menu schema. -type Menu struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // Code holds the value of the "keyword" field. - Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` - // Name holds the value of the "name" field. - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - // I18nKey holds the value - I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` - // Description holds the value of the "description" field. - Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` - // Sequence holds the value of the "sequence" field. - Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` - // Type holds the value of the "type" field. - Type string `protobuf:"bytes,9,opt,name=type,proto3" json:"type,omitempty"` - // Icon holds the value of the "icon" field. - Icon string `protobuf:"bytes,10,opt,name=icon,proto3" json:"icon,omitempty"` - // Path holds the value of the "path" field. - Path string `protobuf:"bytes,11,opt,name=path,proto3" json:"path,omitempty"` - // Properties holds the value of the "properties" field. - Properties string `protobuf:"bytes,12,opt,name=properties,proto3" json:"properties,omitempty"` - // Status holds the value of the "status" field. - Status int32 `protobuf:"varint,13,opt,name=status,proto3" json:"status,omitempty"` - // ParentID holds the value of the "parent_id" field. - ParentId int64 `protobuf:"varint,14,opt,name=parent_id,proto3" json:"parent_id,omitempty"` - // ParentPath holds the value of the "parent_path" field. - ParentPath string `protobuf:"bytes,15,opt,name=parent_path,proto3" json:"parent_path,omitempty"` - // Children holds the value of the children edge. - Children []*Menu `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Menu `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Menu) Reset() { - *x = Menu{} - mi := &file_system_types_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Menu) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Menu) ProtoMessage() {} - -func (x *Menu) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[0] - 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 Menu.ProtoReflect.Descriptor instead. -func (*Menu) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{0} -} - -func (x *Menu) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Menu) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Menu) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Menu) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Menu) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Menu) GetI18NKey() string { - if x != nil { - return x.I18NKey - } - return "" -} - -func (x *Menu) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Menu) GetSequence() int32 { - if x != nil { - return x.Sequence - } - return 0 -} - -func (x *Menu) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Menu) GetIcon() string { - if x != nil { - return x.Icon - } - return "" -} - -func (x *Menu) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *Menu) GetProperties() string { - if x != nil { - return x.Properties - } - return "" -} - -func (x *Menu) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *Menu) GetParentId() int64 { - if x != nil { - return x.ParentId - } - return 0 -} - -func (x *Menu) GetParentPath() string { - if x != nil { - return x.ParentPath - } - return "" -} - -func (x *Menu) GetChildren() []*Menu { - if x != nil { - return x.Children - } - return nil -} - -func (x *Menu) GetParent() *Menu { - if x != nil { - return x.Parent - } - return nil -} - -func (x *Menu) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *Menu) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -// MenuEdges holds the relations/edges for other nodes in the graph. -type MenuEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Children holds the value of the children edge. - Children []*Menu `protobuf:"bytes,1,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Menu `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,3,rep,name=resources,proto3" json:"resources,omitempty"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,4,rep,name=roles,proto3" json:"roles,omitempty"` - // RoleMenu holds the value of the role_menu edge. - RoleMenus []*RoleMenu `protobuf:"bytes,5,rep,name=role_menus,proto3" json:"role_menus,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *MenuEdges) Reset() { - *x = MenuEdges{} - mi := &file_system_types_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *MenuEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MenuEdges) ProtoMessage() {} - -func (x *MenuEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[1] - 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 MenuEdges.ProtoReflect.Descriptor instead. -func (*MenuEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{1} -} - -func (x *MenuEdges) GetChildren() []*Menu { - if x != nil { - return x.Children - } - return nil -} - -func (x *MenuEdges) GetParent() *Menu { - if x != nil { - return x.Parent - } - return nil -} - -func (x *MenuEdges) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *MenuEdges) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *MenuEdges) GetRoleMenus() []*RoleMenu { - if x != nil { - return x.RoleMenus - } - return nil -} - -// Role is the model entity for the Role schema. -type Role struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // role.field.keyword - Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` - // role.field.name - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - // role.field.description - Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` - // role.field.type - Type int32 `protobuf:"varint,7,opt,name=type,proto3" json:"type,omitempty"` - // role.field.sequence - Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` - // role.field.status - Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"` - // role.field.is_system - IsSystem bool `protobuf:"varint,10,opt,name=is_system,proto3" json:"is_system,omitempty"` - // Menus holds the value of the menus edge. - Menus []*Menu `protobuf:"bytes,21,rep,name=menus,proto3" json:"menus,omitempty"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,22,rep,name=users,proto3" json:"users,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` - // Resource Ids holds the value of the resource_ids edge. - ResourceIds []int64 `protobuf:"varint,24,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` - // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,25,rep,name=permissions,proto3" json:"permissions,omitempty"` - // Permission Ids holds the value of the permission_ids edge. - PermissionIds []int64 `protobuf:"varint,26,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Role) Reset() { - *x = Role{} - mi := &file_system_types_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Role) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Role) ProtoMessage() {} - -func (x *Role) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[2] - 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 Role.ProtoReflect.Descriptor instead. -func (*Role) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{2} -} - -func (x *Role) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Role) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Role) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Role) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Role) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Role) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Role) GetType() int32 { - if x != nil { - return x.Type - } - return 0 -} - -func (x *Role) GetSequence() int32 { - if x != nil { - return x.Sequence - } - return 0 -} - -func (x *Role) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *Role) GetIsSystem() bool { - if x != nil { - return x.IsSystem - } - return false -} - -func (x *Role) GetMenus() []*Menu { - if x != nil { - return x.Menus - } - return nil -} - -func (x *Role) GetUsers() []*User { - if x != nil { - return x.Users - } - return nil -} - -func (x *Role) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *Role) GetResourceIds() []int64 { - if x != nil { - return x.ResourceIds - } - return nil -} - -func (x *Role) GetPermissions() []*Permission { - if x != nil { - return x.Permissions - } - return nil -} - -func (x *Role) GetPermissionIds() []int64 { - if x != nil { - return x.PermissionIds - } - return nil -} - -// RoleEdges holds the relations/edges for other nodes in the graph. -type RoleEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Menus holds the value of the menus edge. - Menus []*Menu `protobuf:"bytes,1,rep,name=menus,proto3" json:"menus,omitempty"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` - // RoleMenu holds the value of the role_menu edge. - RoleMenus []*RoleMenu `protobuf:"bytes,3,rep,name=role_menus,proto3" json:"role_menus,omitempty"` - // UserRole holds the value of the user_role edge. - UserRoles []*UserRole `protobuf:"bytes,4,rep,name=user_roles,proto3" json:"user_roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RoleEdges) Reset() { - *x = RoleEdges{} - mi := &file_system_types_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RoleEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RoleEdges) ProtoMessage() {} - -func (x *RoleEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[3] - 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 RoleEdges.ProtoReflect.Descriptor instead. -func (*RoleEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{3} -} - -func (x *RoleEdges) GetMenus() []*Menu { - if x != nil { - return x.Menus - } - return nil -} - -func (x *RoleEdges) GetUsers() []*User { - if x != nil { - return x.Users - } - return nil -} - -func (x *RoleEdges) GetRoleMenus() []*RoleMenu { - if x != nil { - return x.RoleMenus - } - return nil -} - -func (x *RoleEdges) GetUserRoles() []*UserRole { - if x != nil { - return x.UserRoles - } - return nil -} - -// User is the model entity for the User schema. -type User struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_author.field.comment - CreateAuthor int64 `protobuf:"varint,2,opt,name=create_author,proto3" json:"create_author,omitempty"` - // update_author.field.comment - UpdateAuthor int64 `protobuf:"varint,3,opt,name=update_author,proto3" json:"update_author,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=update_time,proto3" json:"update_time,omitempty"` - // user.field.uuid - Uuid string `protobuf:"bytes,6,opt,name=uuid,proto3" json:"uuid,omitempty"` - // user.field.allowed_ip - AllowedIp string `protobuf:"bytes,7,opt,name=allowed_ip,proto3" json:"allowed_ip,omitempty"` - // user.field.username - Username string `protobuf:"bytes,8,opt,name=username,proto3" json:"username,omitempty"` - // user.field.nickname - Nickname string `protobuf:"bytes,9,opt,name=nickname,proto3" json:"nickname,omitempty"` - // user.field.avatar - Avatar string `protobuf:"bytes,10,opt,name=avatar,proto3" json:"avatar,omitempty"` - // user.field.nickname - Name string `protobuf:"bytes,11,opt,name=name,proto3" json:"name,omitempty"` - // user.field.gender - Gender string `protobuf:"bytes,12,opt,name=gender,proto3" json:"gender,omitempty"` - // user.field.password - // @Decrypted don't show this field in response - Password string `protobuf:"bytes,13,opt,name=password,proto3" json:"password,omitempty"` - // user.field.confirm_password - ConfirmPassword string `protobuf:"bytes,14,opt,name=confirm_password,proto3" json:"confirm_password,omitempty"` - // user.field.salt - // @Decrypted don't show this field in response - Salt string `protobuf:"bytes,15,opt,name=salt,proto3" json:"salt,omitempty"` - // user.field.phone - Phone string `protobuf:"bytes,16,opt,name=phone,proto3" json:"phone,omitempty"` - // user.field.email - Email string `protobuf:"bytes,17,opt,name=email,proto3" json:"email,omitempty"` - // user.field.remark - Remark string `protobuf:"bytes,18,opt,name=remark,proto3" json:"remark,omitempty"` - // user.field.token - Token string `protobuf:"bytes,19,opt,name=token,proto3" json:"token,omitempty"` - // user.field.status - Status int32 `protobuf:"varint,20,opt,name=status,proto3" json:"status,omitempty"` - // user.field.last_login_ip - LastLoginIp string `protobuf:"bytes,21,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` - // user.field.last_login_time - LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` - // user.field.sanction_date - SanctionDate *timestamppb.Timestamp `protobuf:"bytes,23,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` - // user.field.manager_id - ManagerId int64 `protobuf:"varint,24,opt,name=manager_id,proto3" json:"manager_id,omitempty"` - // user.field.manager - Manager string `protobuf:"bytes,25,opt,name=manager,proto3" json:"manager,omitempty"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,26,rep,name=roles,proto3" json:"roles,omitempty"` - // Role Ids holds the value of the role_ids - RoleIds []int64 `protobuf:"varint,27,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *User) Reset() { - *x = User{} - mi := &file_system_types_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *User) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*User) ProtoMessage() {} - -func (x *User) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[4] - 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 User.ProtoReflect.Descriptor instead. -func (*User) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{4} -} - -func (x *User) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *User) GetCreateAuthor() int64 { - if x != nil { - return x.CreateAuthor - } - return 0 -} - -func (x *User) GetUpdateAuthor() int64 { - if x != nil { - return x.UpdateAuthor - } - return 0 -} - -func (x *User) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *User) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *User) GetUuid() string { - if x != nil { - return x.Uuid - } - return "" -} - -func (x *User) GetAllowedIp() string { - if x != nil { - return x.AllowedIp - } - return "" -} - -func (x *User) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *User) GetNickname() string { - if x != nil { - return x.Nickname - } - return "" -} - -func (x *User) GetAvatar() string { - if x != nil { - return x.Avatar - } - return "" -} - -func (x *User) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *User) GetGender() string { - if x != nil { - return x.Gender - } - return "" -} - -func (x *User) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -func (x *User) GetConfirmPassword() string { - if x != nil { - return x.ConfirmPassword - } - return "" -} - -func (x *User) GetSalt() string { - if x != nil { - return x.Salt - } - return "" -} - -func (x *User) GetPhone() string { - if x != nil { - return x.Phone - } - return "" -} - -func (x *User) GetEmail() string { - if x != nil { - return x.Email - } - return "" -} - -func (x *User) GetRemark() string { - if x != nil { - return x.Remark - } - return "" -} - -func (x *User) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -func (x *User) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *User) GetLastLoginIp() string { - if x != nil { - return x.LastLoginIp - } - return "" -} - -func (x *User) GetLastLoginTime() *timestamppb.Timestamp { - if x != nil { - return x.LastLoginTime - } - return nil -} - -func (x *User) GetSanctionDate() *timestamppb.Timestamp { - if x != nil { - return x.SanctionDate - } - return nil -} - -func (x *User) GetManagerId() int64 { - if x != nil { - return x.ManagerId - } - return 0 -} - -func (x *User) GetManager() string { - if x != nil { - return x.Manager - } - return "" -} - -func (x *User) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *User) GetRoleIds() []int64 { - if x != nil { - return x.RoleIds - } - return nil -} - -// UserEdges holds the relations/edges for other nodes in the graph. -type UserEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` - // UserRole holds the value of the user_role edge. - UserRoles []*UserRole `protobuf:"bytes,2,rep,name=user_roles,proto3" json:"user_roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserEdges) Reset() { - *x = UserEdges{} - mi := &file_system_types_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserEdges) ProtoMessage() {} - -func (x *UserEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[5] - 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 UserEdges.ProtoReflect.Descriptor instead. -func (*UserEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{5} -} - -func (x *UserEdges) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *UserEdges) GetUserRoles() []*UserRole { - if x != nil { - return x.UserRoles - } - return nil -} - -// UserRole is the model entity for the UserRole schema. -type UserRole struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // UserID holds the value of the "user_id" field. - UserId int64 `protobuf:"varint,4,opt,name=user_id,proto3" json:"user_id,omitempty"` - // RoleID holds the value of the "role_id" field. - RoleId int64 `protobuf:"varint,5,opt,name=role_id,proto3" json:"role_id,omitempty"` - // RoleName holds the value of the "role_name" field. - RoleName string `protobuf:"bytes,6,opt,name=role_name,proto3" json:"role_name,omitempty"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,21,opt,name=user,proto3" json:"user,omitempty"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,22,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserRole) Reset() { - *x = UserRole{} - mi := &file_system_types_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserRole) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserRole) ProtoMessage() {} - -func (x *UserRole) ProtoReflect() protoreflect.Message { - mi := &file_system_types_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 UserRole.ProtoReflect.Descriptor instead. -func (*UserRole) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{6} -} - -func (x *UserRole) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UserRole) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *UserRole) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *UserRole) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *UserRole) GetRoleId() int64 { - if x != nil { - return x.RoleId - } - return 0 -} - -func (x *UserRole) GetRoleName() string { - if x != nil { - return x.RoleName - } - return "" -} - -func (x *UserRole) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserRole) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -// UserRoleEdges holds the relations/edges for other nodes in the graph. -type UserRoleEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserRoleEdges) Reset() { - *x = UserRoleEdges{} - mi := &file_system_types_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserRoleEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserRoleEdges) ProtoMessage() {} - -func (x *UserRoleEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserRoleEdges.ProtoReflect.Descriptor instead. -func (*UserRoleEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{7} -} - -func (x *UserRoleEdges) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserRoleEdges) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -// RoleMenu is the model entity for the RoleMenu schema. -type RoleMenu struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // RoleID holds the value of the "role_id" field. - RoleId int64 `protobuf:"varint,4,opt,name=role_id,proto3" json:"role_id,omitempty"` - // MenuID holds the value of the "menu_id" field. - MenuId int64 `protobuf:"varint,5,opt,name=menu_id,proto3" json:"menu_id,omitempty"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,21,opt,name=role,proto3" json:"role,omitempty"` - // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,22,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RoleMenu) Reset() { - *x = RoleMenu{} - mi := &file_system_types_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RoleMenu) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RoleMenu) ProtoMessage() {} - -func (x *RoleMenu) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[8] - 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 RoleMenu.ProtoReflect.Descriptor instead. -func (*RoleMenu) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{8} -} - -func (x *RoleMenu) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *RoleMenu) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *RoleMenu) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *RoleMenu) GetRoleId() int64 { - if x != nil { - return x.RoleId - } - return 0 -} - -func (x *RoleMenu) GetMenuId() int64 { - if x != nil { - return x.MenuId - } - return 0 -} - -func (x *RoleMenu) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -func (x *RoleMenu) GetMenu() *Menu { - if x != nil { - return x.Menu - } - return nil -} - -// RoleMenuEdges holds the relations/edges for other nodes in the graph. -type RoleMenuEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RoleMenuEdges) Reset() { - *x = RoleMenuEdges{} - mi := &file_system_types_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RoleMenuEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RoleMenuEdges) ProtoMessage() {} - -func (x *RoleMenuEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[9] - 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 RoleMenuEdges.ProtoReflect.Descriptor instead. -func (*RoleMenuEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{9} -} - -func (x *RoleMenuEdges) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -func (x *RoleMenuEdges) GetMenu() *Menu { - if x != nil { - return x.Menu - } - return nil -} - -// Resource is the model entity for the Resource schema. -type Resource struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // resource.field.name - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - // resource.field.keyword - Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` - // resource.field.i18n_key - I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` - // resource.field.type - Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` - // resource.field.status - Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` - // resource.field.path - Path string `protobuf:"bytes,9,opt,name=path,proto3" json:"path,omitempty"` - // resource.field.operation - Operation string `protobuf:"bytes,10,opt,name=operation,proto3" json:"operation,omitempty"` - // resource.field.method - Method string `protobuf:"bytes,11,opt,name=method,proto3" json:"method,omitempty"` - // resource.field.component - Component string `protobuf:"bytes,12,opt,name=component,proto3" json:"component,omitempty"` - // resource.field.icon - Icon string `protobuf:"bytes,13,opt,name=icon,proto3" json:"icon,omitempty"` - // resource.field.sequence - Sequence int32 `protobuf:"varint,14,opt,name=sequence,proto3" json:"sequence,omitempty"` - // resource.field.visible - Visible bool `protobuf:"varint,15,opt,name=visible,proto3" json:"visible,omitempty"` - // resource.field.tree_path - TreePath string `protobuf:"bytes,16,opt,name=tree_path,proto3" json:"tree_path,omitempty"` - // resource.field.properties - Properties map[string]string `protobuf:"bytes,17,rep,name=properties,proto3" json:"properties,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - // resource.field.description - Description string `protobuf:"bytes,18,opt,name=description,proto3" json:"description,omitempty"` - // resource.field.parent_id - ParentId int64 `protobuf:"varint,19,opt,name=parent_id,proto3" json:"parent_id,omitempty"` - // Children holds the value of the children edge. - Children []*Resource `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Resource `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` - // Permission Ids holds the value of the permission_ids edge. - PermissionIds []int64 `protobuf:"varint,23,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` - // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,24,rep,name=permissions,proto3" json:"permissions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Resource) Reset() { - *x = Resource{} - mi := &file_system_types_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Resource) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Resource) ProtoMessage() {} - -func (x *Resource) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[10] - 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 Resource.ProtoReflect.Descriptor instead. -func (*Resource) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{10} -} - -func (x *Resource) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Resource) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Resource) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Resource) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Resource) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Resource) GetI18NKey() string { - if x != nil { - return x.I18NKey - } - return "" -} - -func (x *Resource) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Resource) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *Resource) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *Resource) GetOperation() string { - if x != nil { - return x.Operation - } - return "" -} - -func (x *Resource) GetMethod() string { - if x != nil { - return x.Method - } - return "" -} - -func (x *Resource) GetComponent() string { - if x != nil { - return x.Component - } - return "" -} - -func (x *Resource) GetIcon() string { - if x != nil { - return x.Icon - } - return "" -} - -func (x *Resource) GetSequence() int32 { - if x != nil { - return x.Sequence - } - return 0 -} - -func (x *Resource) GetVisible() bool { - if x != nil { - return x.Visible - } - return false -} - -func (x *Resource) GetTreePath() string { - if x != nil { - return x.TreePath - } - return "" -} - -func (x *Resource) GetProperties() map[string]string { - if x != nil { - return x.Properties - } - return nil -} - -func (x *Resource) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Resource) GetParentId() int64 { - if x != nil { - return x.ParentId - } - return 0 -} - -func (x *Resource) GetChildren() []*Resource { - if x != nil { - return x.Children - } - return nil -} - -func (x *Resource) GetParent() *Resource { - if x != nil { - return x.Parent - } - return nil -} - -func (x *Resource) GetPermissionIds() []int64 { - if x != nil { - return x.PermissionIds - } - return nil -} - -func (x *Resource) GetPermissions() []*Permission { - if x != nil { - return x.Permissions - } - return nil -} - -// ResourceEdges holds the relations/edges for other nodes in the graph. -type ResourceEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ResourceEdges) Reset() { - *x = ResourceEdges{} - mi := &file_system_types_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ResourceEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ResourceEdges) ProtoMessage() {} - -func (x *ResourceEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[11] - 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 ResourceEdges.ProtoReflect.Descriptor instead. -func (*ResourceEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{11} -} - -func (x *ResourceEdges) GetMenu() *Menu { - if x != nil { - return x.Menu - } - return nil -} - -// department.table.comment -type Department struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // department.field.keyword - Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` - // department.field.name - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - // menu.field.tree_path - TreePath string `protobuf:"bytes,6,opt,name=tree_path,proto3" json:"tree_path,omitempty"` - // department.field.sequence - Sequence int32 `protobuf:"varint,7,opt,name=sequence,proto3" json:"sequence,omitempty"` - // department.field.status - Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` - // department.field.level - Level int32 `protobuf:"varint,9,opt,name=level,proto3" json:"level,omitempty"` - // department.field.description - Description string `protobuf:"bytes,10,opt,name=description,proto3" json:"description,omitempty"` - // department.field.parent_id - ParentId int64 `protobuf:"varint,11,opt,name=parent_id,proto3" json:"parent_id,omitempty"` - // Children holds the value of the children edge. - Children []*Department `protobuf:"bytes,12,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Department `protobuf:"bytes,13,opt,name=parent,proto3" json:"parent,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Department) Reset() { - *x = Department{} - mi := &file_system_types_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Department) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Department) ProtoMessage() {} - -func (x *Department) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[12] - 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 Department.ProtoReflect.Descriptor instead. -func (*Department) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{12} -} - -func (x *Department) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Department) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Department) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Department) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Department) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Department) GetTreePath() string { - if x != nil { - return x.TreePath - } - return "" -} - -func (x *Department) GetSequence() int32 { - if x != nil { - return x.Sequence - } - return 0 -} - -func (x *Department) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *Department) GetLevel() int32 { - if x != nil { - return x.Level - } - return 0 -} - -func (x *Department) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Department) GetParentId() int64 { - if x != nil { - return x.ParentId - } - return 0 -} - -func (x *Department) GetChildren() []*Department { - if x != nil { - return x.Children - } - return nil -} - -func (x *Department) GetParent() *Department { - if x != nil { - return x.Parent - } - return nil -} - -type DepartmentEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` - // Positions holds the value of the positions edge. - Positions []*Position `protobuf:"bytes,2,rep,name=positions,proto3" json:"positions,omitempty"` - // Children holds the value of the children edge. - Children []*Department `protobuf:"bytes,3,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Department `protobuf:"bytes,4,opt,name=parent,proto3" json:"parent,omitempty"` - // UserDepartments holds the value of the user_departments edge. - UserDepartments []*UserDepartment `protobuf:"bytes,5,rep,name=user_departments,proto3" json:"user_departments,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DepartmentEdges) Reset() { - *x = DepartmentEdges{} - mi := &file_system_types_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DepartmentEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DepartmentEdges) ProtoMessage() {} - -func (x *DepartmentEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[13] - 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 DepartmentEdges.ProtoReflect.Descriptor instead. -func (*DepartmentEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{13} -} - -func (x *DepartmentEdges) GetUsers() []*User { - if x != nil { - return x.Users - } - return nil -} - -func (x *DepartmentEdges) GetPositions() []*Position { - if x != nil { - return x.Positions - } - return nil -} - -func (x *DepartmentEdges) GetChildren() []*Department { - if x != nil { - return x.Children - } - return nil -} - -func (x *DepartmentEdges) GetParent() *Department { - if x != nil { - return x.Parent - } - return nil -} - -func (x *DepartmentEdges) GetUserDepartments() []*UserDepartment { - if x != nil { - return x.UserDepartments - } - return nil -} - -// user_department.table.comment -type UserDepartment struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // field.foreign_key.comment - UserId int64 `protobuf:"varint,2,opt,name=user_id,proto3" json:"user_id,omitempty"` - // field.foreign_key.comment - DepartmentId int64 `protobuf:"varint,3,opt,name=department_id,proto3" json:"department_id,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the UserDepartmentQuery when eager-loading is set. - Edges *UserDepartmentEdges `protobuf:"bytes,4,opt,name=edges,proto3" json:"edges,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserDepartment) Reset() { - *x = UserDepartment{} - mi := &file_system_types_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserDepartment) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserDepartment) ProtoMessage() {} - -func (x *UserDepartment) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[14] - 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 UserDepartment.ProtoReflect.Descriptor instead. -func (*UserDepartment) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{14} -} - -func (x *UserDepartment) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UserDepartment) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *UserDepartment) GetDepartmentId() int64 { - if x != nil { - return x.DepartmentId - } - return 0 -} - -func (x *UserDepartment) GetEdges() *UserDepartmentEdges { - if x != nil { - return x.Edges - } - return nil -} - -// UserDepartmentEdges holds the relations/edges for other nodes in the graph. -type UserDepartmentEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // Department holds the value of the department edge. - Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserDepartmentEdges) Reset() { - *x = UserDepartmentEdges{} - mi := &file_system_types_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserDepartmentEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserDepartmentEdges) ProtoMessage() {} - -func (x *UserDepartmentEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[15] - 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 UserDepartmentEdges.ProtoReflect.Descriptor instead. -func (*UserDepartmentEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{15} -} - -func (x *UserDepartmentEdges) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserDepartmentEdges) GetDepartment() *Department { - if x != nil { - return x.Department - } - return nil -} - -// position.table.comment -type Position struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // position.field.name - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - // position.field.keyword - Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` - // position.field.description - Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` - // department.field.department_id - DepartmentId int64 `protobuf:"varint,7,opt,name=department_id,proto3" json:"department_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Position) Reset() { - *x = Position{} - mi := &file_system_types_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Position) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Position) ProtoMessage() {} - -func (x *Position) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[16] - 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 Position.ProtoReflect.Descriptor instead. -func (*Position) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{16} -} - -func (x *Position) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Position) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Position) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Position) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Position) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Position) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Position) GetDepartmentId() int64 { - if x != nil { - return x.DepartmentId - } - return 0 -} - -// PositionEdges holds the relations/edges for other nodes in the graph. -type PositionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Department holds the value of the department edge. - Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` - // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,3,rep,name=permissions,proto3" json:"permissions,omitempty"` - // UserPositions holds the value of the user_positions edge. - UserPositions []*UserPosition `protobuf:"bytes,4,rep,name=user_positions,proto3" json:"user_positions,omitempty"` - // PositionPermissions holds the value of the position_permissions edge. - PositionPermissions []*PositionPermission `protobuf:"bytes,5,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PositionEdges) Reset() { - *x = PositionEdges{} - mi := &file_system_types_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PositionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PositionEdges) ProtoMessage() {} - -func (x *PositionEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[17] - 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 PositionEdges.ProtoReflect.Descriptor instead. -func (*PositionEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{17} -} - -func (x *PositionEdges) GetDepartment() *Department { - if x != nil { - return x.Department - } - return nil -} - -func (x *PositionEdges) GetUsers() []*User { - if x != nil { - return x.Users - } - return nil -} - -func (x *PositionEdges) GetPermissions() []*Permission { - if x != nil { - return x.Permissions - } - return nil -} - -func (x *PositionEdges) GetUserPositions() []*UserPosition { - if x != nil { - return x.UserPositions - } - return nil -} - -func (x *PositionEdges) GetPositionPermissions() []*PositionPermission { - if x != nil { - return x.PositionPermissions - } - return nil -} - -// permission.table.comment -type Permission struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // permission.field.name - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - // permission.field.keyword - Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` - // permission.field.description - Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` - // permission.field.data_scope - DataScope string `protobuf:"bytes,7,opt,name=data_scope,proto3" json:"data_scope,omitempty"` - // permission.field.data_rules - DataRules map[string]string `protobuf:"bytes,8,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - // permission.field.resource_ids - ResourceIds []int64 `protobuf:"varint,9,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` - // permission.field.resources - Resources []*Resource `protobuf:"bytes,10,rep,name=resources,proto3" json:"resources,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Permission) Reset() { - *x = Permission{} - mi := &file_system_types_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Permission) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Permission) ProtoMessage() {} - -func (x *Permission) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[18] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Permission.ProtoReflect.Descriptor instead. -func (*Permission) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{18} -} - -func (x *Permission) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Permission) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Permission) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Permission) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Permission) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Permission) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Permission) GetDataScope() string { - if x != nil { - return x.DataScope - } - return "" -} - -func (x *Permission) GetDataRules() map[string]string { - if x != nil { - return x.DataRules - } - return nil -} - -func (x *Permission) GetResourceIds() []int64 { - if x != nil { - return x.ResourceIds - } - return nil -} - -func (x *Permission) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -// PermissionEdges holds the relations/edges for other nodes in the graph. -type PermissionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` - // Positions holds the value of the positions edge. - Positions []*Position `protobuf:"bytes,3,rep,name=positions,proto3" json:"positions,omitempty"` - // RolePermissions holds the value of the role_permissions edge. - RolePermissions []*RolePermission `protobuf:"bytes,4,rep,name=role_permissions,proto3" json:"role_permissions,omitempty"` - // PermissionResources holds the value of the permission_resources edge. - PermissionResources []*PermissionResource `protobuf:"bytes,5,rep,name=permission_resources,proto3" json:"permission_resources,omitempty"` - // PositionPermissions holds the value of the position_permissions edge. - PositionPermissions []*PositionPermission `protobuf:"bytes,6,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PermissionEdges) Reset() { - *x = PermissionEdges{} - mi := &file_system_types_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PermissionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PermissionEdges) ProtoMessage() {} - -func (x *PermissionEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PermissionEdges.ProtoReflect.Descriptor instead. -func (*PermissionEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{19} -} - -func (x *PermissionEdges) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *PermissionEdges) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *PermissionEdges) GetPositions() []*Position { - if x != nil { - return x.Positions - } - return nil -} - -func (x *PermissionEdges) GetRolePermissions() []*RolePermission { - if x != nil { - return x.RolePermissions - } - return nil -} - -func (x *PermissionEdges) GetPermissionResources() []*PermissionResource { - if x != nil { - return x.PermissionResources - } - return nil -} - -func (x *PermissionEdges) GetPositionPermissions() []*PositionPermission { - if x != nil { - return x.PositionPermissions - } - return nil -} - -// user_position.table.comment -type UserPosition struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // field.foreign_key.comment - UserId int64 `protobuf:"varint,2,opt,name=user_id,proto3" json:"user_id,omitempty"` - // field.foreign_key.comment - PositionId int64 `protobuf:"varint,3,opt,name=position_id,proto3" json:"position_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserPosition) Reset() { - *x = UserPosition{} - mi := &file_system_types_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserPosition) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserPosition) ProtoMessage() {} - -func (x *UserPosition) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[20] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserPosition.ProtoReflect.Descriptor instead. -func (*UserPosition) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{20} -} - -func (x *UserPosition) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UserPosition) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *UserPosition) GetPositionId() int64 { - if x != nil { - return x.PositionId - } - return 0 -} - -// UserPositionEdges holds the relations/edges for other nodes in the graph. -type UserPositionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // Position holds the value of the position edge. - Position *Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserPositionEdges) Reset() { - *x = UserPositionEdges{} - mi := &file_system_types_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserPositionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserPositionEdges) ProtoMessage() {} - -func (x *UserPositionEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[21] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserPositionEdges.ProtoReflect.Descriptor instead. -func (*UserPositionEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{21} -} - -func (x *UserPositionEdges) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserPositionEdges) GetPosition() *Position { - if x != nil { - return x.Position - } - return nil -} - -// position_permission.table.comment -type PositionPermission struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // position_permission.field.position_id - PositionId int64 `protobuf:"varint,2,opt,name=position_id,proto3" json:"position_id,omitempty"` - // position_permission.field.permission_id - PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PositionPermission) Reset() { - *x = PositionPermission{} - mi := &file_system_types_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PositionPermission) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PositionPermission) ProtoMessage() {} - -func (x *PositionPermission) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[22] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PositionPermission.ProtoReflect.Descriptor instead. -func (*PositionPermission) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{22} -} - -func (x *PositionPermission) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *PositionPermission) GetPositionId() int64 { - if x != nil { - return x.PositionId - } - return 0 -} - -func (x *PositionPermission) GetPermissionId() int64 { - if x != nil { - return x.PermissionId - } - return 0 -} - -// PositionPermissionEdges holds the relations/edges for other nodes in the graph. -type PositionPermissionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Position holds the value of the position edge. - Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` - // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PositionPermissionEdges) Reset() { - *x = PositionPermissionEdges{} - mi := &file_system_types_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PositionPermissionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PositionPermissionEdges) ProtoMessage() {} - -func (x *PositionPermissionEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[23] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PositionPermissionEdges.ProtoReflect.Descriptor instead. -func (*PositionPermissionEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{23} -} - -func (x *PositionPermissionEdges) GetPosition() *Position { - if x != nil { - return x.Position - } - return nil -} - -func (x *PositionPermissionEdges) GetPermission() *Permission { - if x != nil { - return x.Permission - } - return nil -} - -// role_permission.table.comment -type RolePermission struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // field.foreign_key.comment - RoleId int64 `protobuf:"varint,2,opt,name=role_id,proto3" json:"role_id,omitempty"` - // field.foreign_key.comment - PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RolePermission) Reset() { - *x = RolePermission{} - mi := &file_system_types_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RolePermission) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RolePermission) ProtoMessage() {} - -func (x *RolePermission) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[24] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RolePermission.ProtoReflect.Descriptor instead. -func (*RolePermission) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{24} -} - -func (x *RolePermission) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *RolePermission) GetRoleId() int64 { - if x != nil { - return x.RoleId - } - return 0 -} - -func (x *RolePermission) GetPermissionId() int64 { - if x != nil { - return x.PermissionId - } - return 0 -} - -// RolePermissionEdges holds the relations/edges for other nodes in the graph. -type RolePermissionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RolePermissionEdges) Reset() { - *x = RolePermissionEdges{} - mi := &file_system_types_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RolePermissionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RolePermissionEdges) ProtoMessage() {} - -func (x *RolePermissionEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_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 RolePermissionEdges.ProtoReflect.Descriptor instead. -func (*RolePermissionEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{25} -} - -func (x *RolePermissionEdges) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -func (x *RolePermissionEdges) GetPermission() *Permission { - if x != nil { - return x.Permission - } - return nil -} - -// permission_resource.table.comment -type PermissionResource struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // field.foreign_key.comment - PermissionId int64 `protobuf:"varint,2,opt,name=permission_id,proto3" json:"permission_id,omitempty"` - // field.foreign_key.comment - ResourceId int64 `protobuf:"varint,3,opt,name=resource_id,proto3" json:"resource_id,omitempty"` - // permission_resource.field.actions - Actions string `protobuf:"bytes,4,opt,name=actions,proto3" json:"actions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PermissionResource) Reset() { - *x = PermissionResource{} - mi := &file_system_types_proto_msgTypes[26] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PermissionResource) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PermissionResource) ProtoMessage() {} - -func (x *PermissionResource) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[26] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PermissionResource.ProtoReflect.Descriptor instead. -func (*PermissionResource) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{26} -} - -func (x *PermissionResource) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *PermissionResource) GetPermissionId() int64 { - if x != nil { - return x.PermissionId - } - return 0 -} - -func (x *PermissionResource) GetResourceId() int64 { - if x != nil { - return x.ResourceId - } - return 0 -} - -func (x *PermissionResource) GetActions() string { - if x != nil { - return x.Actions - } - return "" -} - -// PermissionResourceEdges holds the relations/edges for other nodes in the graph. -type PermissionResourceEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` - // Resource holds the value of the resource edge. - Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PermissionResourceEdges) Reset() { - *x = PermissionResourceEdges{} - mi := &file_system_types_proto_msgTypes[27] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PermissionResourceEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PermissionResourceEdges) ProtoMessage() {} - -func (x *PermissionResourceEdges) ProtoReflect() protoreflect.Message { - mi := &file_system_types_proto_msgTypes[27] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PermissionResourceEdges.ProtoReflect.Descriptor instead. -func (*PermissionResourceEdges) Descriptor() ([]byte, []int) { - return file_system_types_proto_rawDescGZIP(), []int{27} -} - -func (x *PermissionResourceEdges) GetPermission() *Permission { - if x != nil { - return x.Permission - } - return nil -} - -func (x *PermissionResourceEdges) GetResource() *Resource { - if x != nil { - return x.Resource - } - return nil -} - -var File_system_types_proto protoreflect.FileDescriptor - -const file_system_types_proto_rawDesc = "" + - "\n" + - "\x12system/types.proto\x12\x16api.v1.services.system\x1a\x1fgoogle/protobuf/timestamp.proto\"\xb2\x05\n" + - "\x04Menu\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\x05 \x01(\tR\x04name\x12\x1a\n" + - "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12 \n" + - "\vdescription\x18\a \x01(\tR\vdescription\x12\x1a\n" + - "\bsequence\x18\b \x01(\x05R\bsequence\x12\x12\n" + - "\x04type\x18\t \x01(\tR\x04type\x12\x12\n" + - "\x04icon\x18\n" + - " \x01(\tR\x04icon\x12\x12\n" + - "\x04path\x18\v \x01(\tR\x04path\x12\x1e\n" + - "\n" + - "properties\x18\f \x01(\tR\n" + - "properties\x12\x16\n" + - "\x06status\x18\r \x01(\x05R\x06status\x12\x1c\n" + - "\tparent_id\x18\x0e \x01(\x03R\tparent_id\x12 \n" + - "\vparent_path\x18\x0f \x01(\tR\vparent_path\x128\n" + - "\bchildren\x18\x15 \x03(\v2\x1c.api.v1.services.system.MenuR\bchildren\x124\n" + - "\x06parent\x18\x16 \x01(\v2\x1c.api.v1.services.system.MenuR\x06parent\x12>\n" + - "\tresources\x18\x17 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x122\n" + - "\x05roles\x18\x18 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\"\xb1\x02\n" + - "\tMenuEdges\x128\n" + - "\bchildren\x18\x01 \x03(\v2\x1c.api.v1.services.system.MenuR\bchildren\x124\n" + - "\x06parent\x18\x02 \x01(\v2\x1c.api.v1.services.system.MenuR\x06parent\x12>\n" + - "\tresources\x18\x03 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x122\n" + - "\x05roles\x18\x04 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\x12@\n" + - "\n" + - "role_menus\x18\x05 \x03(\v2 .api.v1.services.system.RoleMenuR\n" + - "role_menus\"\x82\x05\n" + - "\x04Role\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\x05 \x01(\tR\x04name\x12 \n" + - "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x12\n" + - "\x04type\x18\a \x01(\x05R\x04type\x12\x1a\n" + - "\bsequence\x18\b \x01(\x05R\bsequence\x12\x16\n" + - "\x06status\x18\t \x01(\x05R\x06status\x12\x1c\n" + - "\tis_system\x18\n" + - " \x01(\bR\tis_system\x122\n" + - "\x05menus\x18\x15 \x03(\v2\x1c.api.v1.services.system.MenuR\x05menus\x122\n" + - "\x05users\x18\x16 \x03(\v2\x1c.api.v1.services.system.UserR\x05users\x12>\n" + - "\tresources\x18\x17 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x12\"\n" + - "\fresource_ids\x18\x18 \x03(\x03R\fresource_ids\x12D\n" + - "\vpermissions\x18\x19 \x03(\v2\".api.v1.services.system.PermissionR\vpermissions\x12&\n" + - "\x0epermission_ids\x18\x1a \x03(\x03R\x0epermission_ids\"\xf7\x01\n" + - "\tRoleEdges\x122\n" + - "\x05menus\x18\x01 \x03(\v2\x1c.api.v1.services.system.MenuR\x05menus\x122\n" + - "\x05users\x18\x02 \x03(\v2\x1c.api.v1.services.system.UserR\x05users\x12@\n" + - "\n" + - "role_menus\x18\x03 \x03(\v2 .api.v1.services.system.RoleMenuR\n" + - "role_menus\x12@\n" + - "\n" + - "user_roles\x18\x04 \x03(\v2 .api.v1.services.system.UserRoleR\n" + - "user_roles\"\xab\a\n" + - "\x04User\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + - "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + - "\rupdate_author\x18\x03 \x01(\x03R\rupdate_author\x12<\n" + - "\vcreate_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04uuid\x18\x06 \x01(\tR\x04uuid\x12\x1e\n" + - "\n" + - "allowed_ip\x18\a \x01(\tR\n" + - "allowed_ip\x12\x1a\n" + - "\busername\x18\b \x01(\tR\busername\x12\x1a\n" + - "\bnickname\x18\t \x01(\tR\bnickname\x12\x16\n" + - "\x06avatar\x18\n" + - " \x01(\tR\x06avatar\x12\x12\n" + - "\x04name\x18\v \x01(\tR\x04name\x12\x16\n" + - "\x06gender\x18\f \x01(\tR\x06gender\x12\x1a\n" + - "\bpassword\x18\r \x01(\tR\bpassword\x12*\n" + - "\x10confirm_password\x18\x0e \x01(\tR\x10confirm_password\x12\x12\n" + - "\x04salt\x18\x0f \x01(\tR\x04salt\x12\x14\n" + - "\x05phone\x18\x10 \x01(\tR\x05phone\x12\x14\n" + - "\x05email\x18\x11 \x01(\tR\x05email\x12\x16\n" + - "\x06remark\x18\x12 \x01(\tR\x06remark\x12\x14\n" + - "\x05token\x18\x13 \x01(\tR\x05token\x12\x16\n" + - "\x06status\x18\x14 \x01(\x05R\x06status\x12$\n" + - "\rlast_login_ip\x18\x15 \x01(\tR\rlast_login_ip\x12D\n" + - "\x0flast_login_time\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12E\n" + - "\rsanction_date\x18\x17 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x12\x1e\n" + - "\n" + - "manager_id\x18\x18 \x01(\x03R\n" + - "manager_id\x12\x18\n" + - "\amanager\x18\x19 \x01(\tR\amanager\x122\n" + - "\x05roles\x18\x1a \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\x12\x1a\n" + - "\brole_ids\x18\x1b \x03(\x03R\brole_idsB\x10\n" + - "\x0e_sanction_date\"\x81\x01\n" + - "\tUserEdges\x122\n" + - "\x05roles\x18\x01 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\x12@\n" + - "\n" + - "user_roles\x18\x02 \x03(\v2 .api.v1.services.system.UserRoleR\n" + - "user_roles\"\xcc\x02\n" + - "\bUserRole\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\auser_id\x18\x04 \x01(\x03R\auser_id\x12\x18\n" + - "\arole_id\x18\x05 \x01(\x03R\arole_id\x12\x1c\n" + - "\trole_name\x18\x06 \x01(\tR\trole_name\x120\n" + - "\x04user\x18\x15 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x120\n" + - "\x04role\x18\x16 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"s\n" + - "\rUserRoleEdges\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x120\n" + - "\x04role\x18\x02 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\"\xae\x02\n" + - "\bRoleMenu\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\arole_id\x18\x04 \x01(\x03R\arole_id\x12\x18\n" + - "\amenu_id\x18\x05 \x01(\x03R\amenu_id\x120\n" + - "\x04role\x18\x15 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\x120\n" + - "\x04menu\x18\x16 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"s\n" + - "\rRoleMenuEdges\x120\n" + - "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\x120\n" + - "\x04menu\x18\x02 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"\x93\a\n" + - "\bResource\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x1a\n" + - "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12\x12\n" + - "\x04type\x18\a \x01(\tR\x04type\x12\x16\n" + - "\x06status\x18\b \x01(\x05R\x06status\x12\x12\n" + - "\x04path\x18\t \x01(\tR\x04path\x12\x1c\n" + - "\toperation\x18\n" + - " \x01(\tR\toperation\x12\x16\n" + - "\x06method\x18\v \x01(\tR\x06method\x12\x1c\n" + - "\tcomponent\x18\f \x01(\tR\tcomponent\x12\x12\n" + - "\x04icon\x18\r \x01(\tR\x04icon\x12\x1a\n" + - "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x18\n" + - "\avisible\x18\x0f \x01(\bR\avisible\x12\x1c\n" + - "\ttree_path\x18\x10 \x01(\tR\ttree_path\x12P\n" + - "\n" + - "properties\x18\x11 \x03(\v20.api.v1.services.system.Resource.PropertiesEntryR\n" + - "properties\x12 \n" + - "\vdescription\x18\x12 \x01(\tR\vdescription\x12\x1c\n" + - "\tparent_id\x18\x13 \x01(\x03R\tparent_id\x12<\n" + - "\bchildren\x18\x15 \x03(\v2 .api.v1.services.system.ResourceR\bchildren\x128\n" + - "\x06parent\x18\x16 \x01(\v2 .api.v1.services.system.ResourceR\x06parent\x12&\n" + - "\x0epermission_ids\x18\x17 \x03(\x03R\x0epermission_ids\x12D\n" + - "\vpermissions\x18\x18 \x03(\v2\".api.v1.services.system.PermissionR\vpermissions\x1a=\n" + - "\x0fPropertiesEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"A\n" + - "\rResourceEdges\x120\n" + - "\x04menu\x18\x01 \x01(\v2\x1c.api.v1.services.system.MenuR\x04menu\"\xea\x03\n" + - "\n" + - "Department\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\x05 \x01(\tR\x04name\x12\x1c\n" + - "\ttree_path\x18\x06 \x01(\tR\ttree_path\x12\x1a\n" + - "\bsequence\x18\a \x01(\x05R\bsequence\x12\x16\n" + - "\x06status\x18\b \x01(\x05R\x06status\x12\x14\n" + - "\x05level\x18\t \x01(\x05R\x05level\x12 \n" + - "\vdescription\x18\n" + - " \x01(\tR\vdescription\x12\x1c\n" + - "\tparent_id\x18\v \x01(\x03R\tparent_id\x12>\n" + - "\bchildren\x18\f \x03(\v2\".api.v1.services.system.DepartmentR\bchildren\x12:\n" + - "\x06parent\x18\r \x01(\v2\".api.v1.services.system.DepartmentR\x06parent\"\xd5\x02\n" + - "\x0fDepartmentEdges\x122\n" + - "\x05users\x18\x01 \x03(\v2\x1c.api.v1.services.system.UserR\x05users\x12>\n" + - "\tpositions\x18\x02 \x03(\v2 .api.v1.services.system.PositionR\tpositions\x12>\n" + - "\bchildren\x18\x03 \x03(\v2\".api.v1.services.system.DepartmentR\bchildren\x12:\n" + - "\x06parent\x18\x04 \x01(\v2\".api.v1.services.system.DepartmentR\x06parent\x12R\n" + - "\x10user_departments\x18\x05 \x03(\v2&.api.v1.services.system.UserDepartmentR\x10user_departments\"\xa3\x01\n" + - "\x0eUserDepartment\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\auser_id\x18\x02 \x01(\x03R\auser_id\x12$\n" + - "\rdepartment_id\x18\x03 \x01(\x03R\rdepartment_id\x12A\n" + - "\x05edges\x18\x04 \x01(\v2+.api.v1.services.system.UserDepartmentEdgesR\x05edges\"\x8b\x01\n" + - "\x13UserDepartmentEdges\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x12B\n" + - "\n" + - "department\x18\x02 \x01(\v2\".api.v1.services.system.DepartmentR\n" + - "department\"\x8c\x02\n" + - "\bPosition\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + - "\vdescription\x18\x06 \x01(\tR\vdescription\x12$\n" + - "\rdepartment_id\x18\a \x01(\x03R\rdepartment_id\"\xfb\x02\n" + - "\rPositionEdges\x12B\n" + - "\n" + - "department\x18\x01 \x01(\v2\".api.v1.services.system.DepartmentR\n" + - "department\x122\n" + - "\x05users\x18\x02 \x03(\v2\x1c.api.v1.services.system.UserR\x05users\x12D\n" + - "\vpermissions\x18\x03 \x03(\v2\".api.v1.services.system.PermissionR\vpermissions\x12L\n" + - "\x0euser_positions\x18\x04 \x03(\v2$.api.v1.services.system.UserPositionR\x0euser_positions\x12^\n" + - "\x14position_permissions\x18\x05 \x03(\v2*.api.v1.services.system.PositionPermissionR\x14position_permissions\"\xfd\x03\n" + - "\n" + - "Permission\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + - "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x1e\n" + - "\n" + - "data_scope\x18\a \x01(\tR\n" + - "data_scope\x12Q\n" + - "\n" + - "data_rules\x18\b \x03(\v21.api.v1.services.system.Permission.DataRulesEntryR\n" + - "data_rules\x12\"\n" + - "\fresource_ids\x18\t \x03(\x03R\fresource_ids\x12>\n" + - "\tresources\x18\n" + - " \x03(\v2 .api.v1.services.system.ResourceR\tresources\x1a<\n" + - "\x0eDataRulesEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xd9\x03\n" + - "\x0fPermissionEdges\x122\n" + - "\x05roles\x18\x01 \x03(\v2\x1c.api.v1.services.system.RoleR\x05roles\x12>\n" + - "\tresources\x18\x02 \x03(\v2 .api.v1.services.system.ResourceR\tresources\x12>\n" + - "\tpositions\x18\x03 \x03(\v2 .api.v1.services.system.PositionR\tpositions\x12R\n" + - "\x10role_permissions\x18\x04 \x03(\v2&.api.v1.services.system.RolePermissionR\x10role_permissions\x12^\n" + - "\x14permission_resources\x18\x05 \x03(\v2*.api.v1.services.system.PermissionResourceR\x14permission_resources\x12^\n" + - "\x14position_permissions\x18\x06 \x03(\v2*.api.v1.services.system.PositionPermissionR\x14position_permissions\"Z\n" + - "\fUserPosition\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\auser_id\x18\x02 \x01(\x03R\auser_id\x12 \n" + - "\vposition_id\x18\x03 \x01(\x03R\vposition_id\"\x83\x01\n" + - "\x11UserPositionEdges\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x12<\n" + - "\bposition\x18\x02 \x01(\v2 .api.v1.services.system.PositionR\bposition\"l\n" + - "\x12PositionPermission\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12 \n" + - "\vposition_id\x18\x02 \x01(\x03R\vposition_id\x12$\n" + - "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x9b\x01\n" + - "\x17PositionPermissionEdges\x12<\n" + - "\bposition\x18\x01 \x01(\v2 .api.v1.services.system.PositionR\bposition\x12B\n" + - "\n" + - "permission\x18\x02 \x01(\v2\".api.v1.services.system.PermissionR\n" + - "permission\"`\n" + - "\x0eRolePermission\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\arole_id\x18\x02 \x01(\x03R\arole_id\x12$\n" + - "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x8b\x01\n" + - "\x13RolePermissionEdges\x120\n" + - "\x04role\x18\x01 \x01(\v2\x1c.api.v1.services.system.RoleR\x04role\x12B\n" + - "\n" + - "permission\x18\x02 \x01(\v2\".api.v1.services.system.PermissionR\n" + - "permission\"\x86\x01\n" + - "\x12PermissionResource\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + - "\rpermission_id\x18\x02 \x01(\x03R\rpermission_id\x12 \n" + - "\vresource_id\x18\x03 \x01(\x03R\vresource_id\x12\x18\n" + - "\aactions\x18\x04 \x01(\tR\aactions\"\x9b\x01\n" + - "\x17PermissionResourceEdges\x12B\n" + - "\n" + - "permission\x18\x01 \x01(\v2\".api.v1.services.system.PermissionR\n" + - "permission\x12<\n" + - "\bresource\x18\x02 \x01(\v2 .api.v1.services.system.ResourceR\bresourceB\xbf\x01\n" + - "\x1acom.api.v1.services.systemB\n" + - "TypesProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_types_proto_rawDescOnce sync.Once - file_system_types_proto_rawDescData []byte -) - -func file_system_types_proto_rawDescGZIP() []byte { - file_system_types_proto_rawDescOnce.Do(func() { - file_system_types_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_types_proto_rawDesc), len(file_system_types_proto_rawDesc))) - }) - return file_system_types_proto_rawDescData -} - -var file_system_types_proto_msgTypes = make([]protoimpl.MessageInfo, 30) -var file_system_types_proto_goTypes = []any{ - (*Menu)(nil), // 0: api.v1.services.system.Menu - (*MenuEdges)(nil), // 1: api.v1.services.system.MenuEdges - (*Role)(nil), // 2: api.v1.services.system.Role - (*RoleEdges)(nil), // 3: api.v1.services.system.RoleEdges - (*User)(nil), // 4: api.v1.services.system.User - (*UserEdges)(nil), // 5: api.v1.services.system.UserEdges - (*UserRole)(nil), // 6: api.v1.services.system.UserRole - (*UserRoleEdges)(nil), // 7: api.v1.services.system.UserRoleEdges - (*RoleMenu)(nil), // 8: api.v1.services.system.RoleMenu - (*RoleMenuEdges)(nil), // 9: api.v1.services.system.RoleMenuEdges - (*Resource)(nil), // 10: api.v1.services.system.Resource - (*ResourceEdges)(nil), // 11: api.v1.services.system.ResourceEdges - (*Department)(nil), // 12: api.v1.services.system.Department - (*DepartmentEdges)(nil), // 13: api.v1.services.system.DepartmentEdges - (*UserDepartment)(nil), // 14: api.v1.services.system.UserDepartment - (*UserDepartmentEdges)(nil), // 15: api.v1.services.system.UserDepartmentEdges - (*Position)(nil), // 16: api.v1.services.system.Position - (*PositionEdges)(nil), // 17: api.v1.services.system.PositionEdges - (*Permission)(nil), // 18: api.v1.services.system.Permission - (*PermissionEdges)(nil), // 19: api.v1.services.system.PermissionEdges - (*UserPosition)(nil), // 20: api.v1.services.system.UserPosition - (*UserPositionEdges)(nil), // 21: api.v1.services.system.UserPositionEdges - (*PositionPermission)(nil), // 22: api.v1.services.system.PositionPermission - (*PositionPermissionEdges)(nil), // 23: api.v1.services.system.PositionPermissionEdges - (*RolePermission)(nil), // 24: api.v1.services.system.RolePermission - (*RolePermissionEdges)(nil), // 25: api.v1.services.system.RolePermissionEdges - (*PermissionResource)(nil), // 26: api.v1.services.system.PermissionResource - (*PermissionResourceEdges)(nil), // 27: api.v1.services.system.PermissionResourceEdges - nil, // 28: api.v1.services.system.Resource.PropertiesEntry - nil, // 29: api.v1.services.system.Permission.DataRulesEntry - (*timestamppb.Timestamp)(nil), // 30: google.protobuf.Timestamp -} -var file_system_types_proto_depIdxs = []int32{ - 30, // 0: api.v1.services.system.Menu.create_time:type_name -> google.protobuf.Timestamp - 30, // 1: api.v1.services.system.Menu.update_time:type_name -> google.protobuf.Timestamp - 0, // 2: api.v1.services.system.Menu.children:type_name -> api.v1.services.system.Menu - 0, // 3: api.v1.services.system.Menu.parent:type_name -> api.v1.services.system.Menu - 10, // 4: api.v1.services.system.Menu.resources:type_name -> api.v1.services.system.Resource - 2, // 5: api.v1.services.system.Menu.roles:type_name -> api.v1.services.system.Role - 0, // 6: api.v1.services.system.MenuEdges.children:type_name -> api.v1.services.system.Menu - 0, // 7: api.v1.services.system.MenuEdges.parent:type_name -> api.v1.services.system.Menu - 10, // 8: api.v1.services.system.MenuEdges.resources:type_name -> api.v1.services.system.Resource - 2, // 9: api.v1.services.system.MenuEdges.roles:type_name -> api.v1.services.system.Role - 8, // 10: api.v1.services.system.MenuEdges.role_menus:type_name -> api.v1.services.system.RoleMenu - 30, // 11: api.v1.services.system.Role.create_time:type_name -> google.protobuf.Timestamp - 30, // 12: api.v1.services.system.Role.update_time:type_name -> google.protobuf.Timestamp - 0, // 13: api.v1.services.system.Role.menus:type_name -> api.v1.services.system.Menu - 4, // 14: api.v1.services.system.Role.users:type_name -> api.v1.services.system.User - 10, // 15: api.v1.services.system.Role.resources:type_name -> api.v1.services.system.Resource - 18, // 16: api.v1.services.system.Role.permissions:type_name -> api.v1.services.system.Permission - 0, // 17: api.v1.services.system.RoleEdges.menus:type_name -> api.v1.services.system.Menu - 4, // 18: api.v1.services.system.RoleEdges.users:type_name -> api.v1.services.system.User - 8, // 19: api.v1.services.system.RoleEdges.role_menus:type_name -> api.v1.services.system.RoleMenu - 6, // 20: api.v1.services.system.RoleEdges.user_roles:type_name -> api.v1.services.system.UserRole - 30, // 21: api.v1.services.system.User.create_time:type_name -> google.protobuf.Timestamp - 30, // 22: api.v1.services.system.User.update_time:type_name -> google.protobuf.Timestamp - 30, // 23: api.v1.services.system.User.last_login_time:type_name -> google.protobuf.Timestamp - 30, // 24: api.v1.services.system.User.sanction_date:type_name -> google.protobuf.Timestamp - 2, // 25: api.v1.services.system.User.roles:type_name -> api.v1.services.system.Role - 2, // 26: api.v1.services.system.UserEdges.roles:type_name -> api.v1.services.system.Role - 6, // 27: api.v1.services.system.UserEdges.user_roles:type_name -> api.v1.services.system.UserRole - 30, // 28: api.v1.services.system.UserRole.create_time:type_name -> google.protobuf.Timestamp - 30, // 29: api.v1.services.system.UserRole.update_time:type_name -> google.protobuf.Timestamp - 4, // 30: api.v1.services.system.UserRole.user:type_name -> api.v1.services.system.User - 2, // 31: api.v1.services.system.UserRole.role:type_name -> api.v1.services.system.Role - 4, // 32: api.v1.services.system.UserRoleEdges.user:type_name -> api.v1.services.system.User - 2, // 33: api.v1.services.system.UserRoleEdges.role:type_name -> api.v1.services.system.Role - 30, // 34: api.v1.services.system.RoleMenu.create_time:type_name -> google.protobuf.Timestamp - 30, // 35: api.v1.services.system.RoleMenu.update_time:type_name -> google.protobuf.Timestamp - 2, // 36: api.v1.services.system.RoleMenu.role:type_name -> api.v1.services.system.Role - 0, // 37: api.v1.services.system.RoleMenu.menu:type_name -> api.v1.services.system.Menu - 2, // 38: api.v1.services.system.RoleMenuEdges.role:type_name -> api.v1.services.system.Role - 0, // 39: api.v1.services.system.RoleMenuEdges.menu:type_name -> api.v1.services.system.Menu - 30, // 40: api.v1.services.system.Resource.create_time:type_name -> google.protobuf.Timestamp - 30, // 41: api.v1.services.system.Resource.update_time:type_name -> google.protobuf.Timestamp - 28, // 42: api.v1.services.system.Resource.properties:type_name -> api.v1.services.system.Resource.PropertiesEntry - 10, // 43: api.v1.services.system.Resource.children:type_name -> api.v1.services.system.Resource - 10, // 44: api.v1.services.system.Resource.parent:type_name -> api.v1.services.system.Resource - 18, // 45: api.v1.services.system.Resource.permissions:type_name -> api.v1.services.system.Permission - 0, // 46: api.v1.services.system.ResourceEdges.menu:type_name -> api.v1.services.system.Menu - 30, // 47: api.v1.services.system.Department.create_time:type_name -> google.protobuf.Timestamp - 30, // 48: api.v1.services.system.Department.update_time:type_name -> google.protobuf.Timestamp - 12, // 49: api.v1.services.system.Department.children:type_name -> api.v1.services.system.Department - 12, // 50: api.v1.services.system.Department.parent:type_name -> api.v1.services.system.Department - 4, // 51: api.v1.services.system.DepartmentEdges.users:type_name -> api.v1.services.system.User - 16, // 52: api.v1.services.system.DepartmentEdges.positions:type_name -> api.v1.services.system.Position - 12, // 53: api.v1.services.system.DepartmentEdges.children:type_name -> api.v1.services.system.Department - 12, // 54: api.v1.services.system.DepartmentEdges.parent:type_name -> api.v1.services.system.Department - 14, // 55: api.v1.services.system.DepartmentEdges.user_departments:type_name -> api.v1.services.system.UserDepartment - 15, // 56: api.v1.services.system.UserDepartment.edges:type_name -> api.v1.services.system.UserDepartmentEdges - 4, // 57: api.v1.services.system.UserDepartmentEdges.user:type_name -> api.v1.services.system.User - 12, // 58: api.v1.services.system.UserDepartmentEdges.department:type_name -> api.v1.services.system.Department - 30, // 59: api.v1.services.system.Position.create_time:type_name -> google.protobuf.Timestamp - 30, // 60: api.v1.services.system.Position.update_time:type_name -> google.protobuf.Timestamp - 12, // 61: api.v1.services.system.PositionEdges.department:type_name -> api.v1.services.system.Department - 4, // 62: api.v1.services.system.PositionEdges.users:type_name -> api.v1.services.system.User - 18, // 63: api.v1.services.system.PositionEdges.permissions:type_name -> api.v1.services.system.Permission - 20, // 64: api.v1.services.system.PositionEdges.user_positions:type_name -> api.v1.services.system.UserPosition - 22, // 65: api.v1.services.system.PositionEdges.position_permissions:type_name -> api.v1.services.system.PositionPermission - 30, // 66: api.v1.services.system.Permission.create_time:type_name -> google.protobuf.Timestamp - 30, // 67: api.v1.services.system.Permission.update_time:type_name -> google.protobuf.Timestamp - 29, // 68: api.v1.services.system.Permission.data_rules:type_name -> api.v1.services.system.Permission.DataRulesEntry - 10, // 69: api.v1.services.system.Permission.resources:type_name -> api.v1.services.system.Resource - 2, // 70: api.v1.services.system.PermissionEdges.roles:type_name -> api.v1.services.system.Role - 10, // 71: api.v1.services.system.PermissionEdges.resources:type_name -> api.v1.services.system.Resource - 16, // 72: api.v1.services.system.PermissionEdges.positions:type_name -> api.v1.services.system.Position - 24, // 73: api.v1.services.system.PermissionEdges.role_permissions:type_name -> api.v1.services.system.RolePermission - 26, // 74: api.v1.services.system.PermissionEdges.permission_resources:type_name -> api.v1.services.system.PermissionResource - 22, // 75: api.v1.services.system.PermissionEdges.position_permissions:type_name -> api.v1.services.system.PositionPermission - 4, // 76: api.v1.services.system.UserPositionEdges.user:type_name -> api.v1.services.system.User - 16, // 77: api.v1.services.system.UserPositionEdges.position:type_name -> api.v1.services.system.Position - 16, // 78: api.v1.services.system.PositionPermissionEdges.position:type_name -> api.v1.services.system.Position - 18, // 79: api.v1.services.system.PositionPermissionEdges.permission:type_name -> api.v1.services.system.Permission - 2, // 80: api.v1.services.system.RolePermissionEdges.role:type_name -> api.v1.services.system.Role - 18, // 81: api.v1.services.system.RolePermissionEdges.permission:type_name -> api.v1.services.system.Permission - 18, // 82: api.v1.services.system.PermissionResourceEdges.permission:type_name -> api.v1.services.system.Permission - 10, // 83: api.v1.services.system.PermissionResourceEdges.resource:type_name -> api.v1.services.system.Resource - 84, // [84:84] is the sub-list for method output_type - 84, // [84:84] is the sub-list for method input_type - 84, // [84:84] is the sub-list for extension type_name - 84, // [84:84] is the sub-list for extension extendee - 0, // [0:84] is the sub-list for field type_name -} - -func init() { file_system_types_proto_init() } -func file_system_types_proto_init() { - if File_system_types_proto != nil { - return - } - file_system_types_proto_msgTypes[4].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_types_proto_rawDesc), len(file_system_types_proto_rawDesc)), - NumEnums: 0, - NumMessages: 30, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_system_types_proto_goTypes, - DependencyIndexes: file_system_types_proto_depIdxs, - MessageInfos: file_system_types_proto_msgTypes, - }.Build() - File_system_types_proto = out.File - file_system_types_proto_goTypes = nil - file_system_types_proto_depIdxs = nil -} diff --git a/api/v1/services/system/types.pb.validate.go b/api/v1/services/system/types.pb.validate.go deleted file mode 100644 index 31b35578..00000000 --- a/api/v1/services/system/types.pb.validate.go +++ /dev/null @@ -1,5600 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/types.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on Menu 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 *Menu) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Menu 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 MenuMultiError, or nil if none found. -func (m *Menu) ValidateAll() error { - return m.validate(true) -} - -func (m *Menu) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Keyword - - // no validation rules for Name - - // no validation rules for I18NKey - - // no validation rules for Description - - // no validation rules for Sequence - - // no validation rules for Type - - // no validation rules for Icon - - // no validation rules for Path - - // no validation rules for Properties - - // no validation rules for Status - - // no validation rules for ParentId - - // no validation rules for ParentPath - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return MenuMultiError(errors) - } - - return nil -} - -// MenuMultiError is an error wrapping multiple validation errors returned by -// Menu.ValidateAll() if the designated constraints aren't met. -type MenuMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m MenuMultiError) 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 MenuMultiError) AllErrors() []error { return m } - -// MenuValidationError is the validation error returned by Menu.Validate if the -// designated constraints aren't met. -type MenuValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e MenuValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e MenuValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e MenuValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e MenuValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e MenuValidationError) ErrorName() string { return "MenuValidationError" } - -// Error satisfies the builtin error interface -func (e MenuValidationError) 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 %sMenu.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = MenuValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = MenuValidationError{} - -// Validate checks the field values on MenuEdges 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 *MenuEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on MenuEdges 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 MenuEdgesMultiError, or nil -// if none found. -func (m *MenuEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *MenuEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoleMenus() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return MenuEdgesMultiError(errors) - } - - return nil -} - -// MenuEdgesMultiError is an error wrapping multiple validation errors returned -// by MenuEdges.ValidateAll() if the designated constraints aren't met. -type MenuEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m MenuEdgesMultiError) 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 MenuEdgesMultiError) AllErrors() []error { return m } - -// MenuEdgesValidationError is the validation error returned by -// MenuEdges.Validate if the designated constraints aren't met. -type MenuEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e MenuEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e MenuEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e MenuEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e MenuEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e MenuEdgesValidationError) ErrorName() string { return "MenuEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e MenuEdgesValidationError) 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 %sMenuEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = MenuEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = MenuEdgesValidationError{} - -// Validate checks the field values on Role 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 *Role) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Role 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 RoleMultiError, or nil if none found. -func (m *Role) ValidateAll() error { - return m.validate(true) -} - -func (m *Role) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Keyword - - // no validation rules for Name - - // no validation rules for Description - - // no validation rules for Type - - // no validation rules for Sequence - - // no validation rules for Status - - // no validation rules for IsSystem - - for idx, item := range m.GetMenus() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return RoleMultiError(errors) - } - - return nil -} - -// RoleMultiError is an error wrapping multiple validation errors returned by -// Role.ValidateAll() if the designated constraints aren't met. -type RoleMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RoleMultiError) 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 RoleMultiError) AllErrors() []error { return m } - -// RoleValidationError is the validation error returned by Role.Validate if the -// designated constraints aren't met. -type RoleValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RoleValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RoleValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RoleValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RoleValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RoleValidationError) ErrorName() string { return "RoleValidationError" } - -// Error satisfies the builtin error interface -func (e RoleValidationError) 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 %sRole.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RoleValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RoleValidationError{} - -// Validate checks the field values on RoleEdges 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 *RoleEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RoleEdges 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 RoleEdgesMultiError, or nil -// if none found. -func (m *RoleEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *RoleEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetMenus() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoleMenus() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUserRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return RoleEdgesMultiError(errors) - } - - return nil -} - -// RoleEdgesMultiError is an error wrapping multiple validation errors returned -// by RoleEdges.ValidateAll() if the designated constraints aren't met. -type RoleEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RoleEdgesMultiError) 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 RoleEdgesMultiError) AllErrors() []error { return m } - -// RoleEdgesValidationError is the validation error returned by -// RoleEdges.Validate if the designated constraints aren't met. -type RoleEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RoleEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RoleEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RoleEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RoleEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RoleEdgesValidationError) ErrorName() string { return "RoleEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e RoleEdgesValidationError) 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 %sRoleEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RoleEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RoleEdgesValidationError{} - -// Validate checks the field values on User 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 *User) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on User 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 UserMultiError, or nil if none found. -func (m *User) ValidateAll() error { - return m.validate(true) -} - -func (m *User) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for CreateAuthor - - // no validation rules for UpdateAuthor - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Uuid - - // no validation rules for AllowedIp - - // no validation rules for Username - - // no validation rules for Nickname - - // no validation rules for Avatar - - // no validation rules for Name - - // no validation rules for Gender - - // no validation rules for Password - - // no validation rules for ConfirmPassword - - // no validation rules for Salt - - // no validation rules for Phone - - // no validation rules for Email - - // no validation rules for Remark - - // no validation rules for Token - - // no validation rules for Status - - // no validation rules for LastLoginIp - - if all { - switch v := interface{}(m.GetLastLoginTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserValidationError{ - field: "LastLoginTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserValidationError{ - field: "LastLoginTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetLastLoginTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserValidationError{ - field: "LastLoginTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for ManagerId - - // no validation rules for Manager - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if m.SanctionDate != nil { - - if all { - switch v := interface{}(m.GetSanctionDate()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserValidationError{ - field: "SanctionDate", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserValidationError{ - field: "SanctionDate", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetSanctionDate()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserValidationError{ - field: "SanctionDate", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return UserMultiError(errors) - } - - return nil -} - -// UserMultiError is an error wrapping multiple validation errors returned by -// User.ValidateAll() if the designated constraints aren't met. -type UserMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserMultiError) 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 UserMultiError) AllErrors() []error { return m } - -// UserValidationError is the validation error returned by User.Validate if the -// designated constraints aren't met. -type UserValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserValidationError) ErrorName() string { return "UserValidationError" } - -// Error satisfies the builtin error interface -func (e UserValidationError) 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 %sUser.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserValidationError{} - -// Validate checks the field values on UserEdges 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 *UserEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserEdges 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 UserEdgesMultiError, or nil -// if none found. -func (m *UserEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUserRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return UserEdgesMultiError(errors) - } - - return nil -} - -// UserEdgesMultiError is an error wrapping multiple validation errors returned -// by UserEdges.ValidateAll() if the designated constraints aren't met. -type UserEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserEdgesMultiError) 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 UserEdgesMultiError) AllErrors() []error { return m } - -// UserEdgesValidationError is the validation error returned by -// UserEdges.Validate if the designated constraints aren't met. -type UserEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserEdgesValidationError) ErrorName() string { return "UserEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e UserEdgesValidationError) 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 %sUserEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserEdgesValidationError{} - -// Validate checks the field values on UserRole 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 *UserRole) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserRole 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 UserRoleMultiError, or nil -// if none found. -func (m *UserRole) ValidateAll() error { - return m.validate(true) -} - -func (m *UserRole) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for UserId - - // no validation rules for RoleId - - // no validation rules for RoleName - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserRoleMultiError(errors) - } - - return nil -} - -// UserRoleMultiError is an error wrapping multiple validation errors returned -// by UserRole.ValidateAll() if the designated constraints aren't met. -type UserRoleMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserRoleMultiError) 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 UserRoleMultiError) AllErrors() []error { return m } - -// UserRoleValidationError is the validation error returned by -// UserRole.Validate if the designated constraints aren't met. -type UserRoleValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserRoleValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserRoleValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserRoleValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserRoleValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserRoleValidationError) ErrorName() string { return "UserRoleValidationError" } - -// Error satisfies the builtin error interface -func (e UserRoleValidationError) 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 %sUserRole.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserRoleValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserRoleValidationError{} - -// Validate checks the field values on UserRoleEdges 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 *UserRoleEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserRoleEdges 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 UserRoleEdgesMultiError, or -// nil if none found. -func (m *UserRoleEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserRoleEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserRoleEdgesMultiError(errors) - } - - return nil -} - -// UserRoleEdgesMultiError is an error wrapping multiple validation errors -// returned by UserRoleEdges.ValidateAll() if the designated constraints -// aren't met. -type UserRoleEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserRoleEdgesMultiError) 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 UserRoleEdgesMultiError) AllErrors() []error { return m } - -// UserRoleEdgesValidationError is the validation error returned by -// UserRoleEdges.Validate if the designated constraints aren't met. -type UserRoleEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserRoleEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserRoleEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserRoleEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserRoleEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserRoleEdgesValidationError) ErrorName() string { return "UserRoleEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e UserRoleEdgesValidationError) 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 %sUserRoleEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserRoleEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserRoleEdgesValidationError{} - -// Validate checks the field values on RoleMenu 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 *RoleMenu) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RoleMenu 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 RoleMenuMultiError, or nil -// if none found. -func (m *RoleMenu) ValidateAll() error { - return m.validate(true) -} - -func (m *RoleMenu) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for RoleId - - // no validation rules for MenuId - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RoleMenuMultiError(errors) - } - - return nil -} - -// RoleMenuMultiError is an error wrapping multiple validation errors returned -// by RoleMenu.ValidateAll() if the designated constraints aren't met. -type RoleMenuMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RoleMenuMultiError) 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 RoleMenuMultiError) AllErrors() []error { return m } - -// RoleMenuValidationError is the validation error returned by -// RoleMenu.Validate if the designated constraints aren't met. -type RoleMenuValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RoleMenuValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RoleMenuValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RoleMenuValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RoleMenuValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RoleMenuValidationError) ErrorName() string { return "RoleMenuValidationError" } - -// Error satisfies the builtin error interface -func (e RoleMenuValidationError) 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 %sRoleMenu.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RoleMenuValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RoleMenuValidationError{} - -// Validate checks the field values on RoleMenuEdges 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 *RoleMenuEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RoleMenuEdges 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 RoleMenuEdgesMultiError, or -// nil if none found. -func (m *RoleMenuEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *RoleMenuEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RoleMenuEdgesMultiError(errors) - } - - return nil -} - -// RoleMenuEdgesMultiError is an error wrapping multiple validation errors -// returned by RoleMenuEdges.ValidateAll() if the designated constraints -// aren't met. -type RoleMenuEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RoleMenuEdgesMultiError) 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 RoleMenuEdgesMultiError) AllErrors() []error { return m } - -// RoleMenuEdgesValidationError is the validation error returned by -// RoleMenuEdges.Validate if the designated constraints aren't met. -type RoleMenuEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RoleMenuEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RoleMenuEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RoleMenuEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RoleMenuEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RoleMenuEdgesValidationError) ErrorName() string { return "RoleMenuEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e RoleMenuEdgesValidationError) 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 %sRoleMenuEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RoleMenuEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RoleMenuEdgesValidationError{} - -// Validate checks the field values on Resource 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 *Resource) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Resource 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 ResourceMultiError, or nil -// if none found. -func (m *Resource) ValidateAll() error { - return m.validate(true) -} - -func (m *Resource) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Name - - // no validation rules for Keyword - - // no validation rules for I18NKey - - // no validation rules for Type - - // no validation rules for Status - - // no validation rules for Path - - // no validation rules for Operation - - // no validation rules for Method - - // no validation rules for Component - - // no validation rules for Icon - - // no validation rules for Sequence - - // no validation rules for Visible - - // no validation rules for TreePath - - // no validation rules for Properties - - // no validation rules for Description - - // no validation rules for ParentId - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ResourceMultiError(errors) - } - - return nil -} - -// ResourceMultiError is an error wrapping multiple validation errors returned -// by Resource.ValidateAll() if the designated constraints aren't met. -type ResourceMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResourceMultiError) 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 ResourceMultiError) AllErrors() []error { return m } - -// ResourceValidationError is the validation error returned by -// Resource.Validate if the designated constraints aren't met. -type ResourceValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResourceValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResourceValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResourceValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResourceValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResourceValidationError) ErrorName() string { return "ResourceValidationError" } - -// Error satisfies the builtin error interface -func (e ResourceValidationError) 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 %sResource.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResourceValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResourceValidationError{} - -// Validate checks the field values on ResourceEdges 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 *ResourceEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ResourceEdges 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 ResourceEdgesMultiError, or -// nil if none found. -func (m *ResourceEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *ResourceEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ResourceEdgesMultiError(errors) - } - - return nil -} - -// ResourceEdgesMultiError is an error wrapping multiple validation errors -// returned by ResourceEdges.ValidateAll() if the designated constraints -// aren't met. -type ResourceEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResourceEdgesMultiError) 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 ResourceEdgesMultiError) AllErrors() []error { return m } - -// ResourceEdgesValidationError is the validation error returned by -// ResourceEdges.Validate if the designated constraints aren't met. -type ResourceEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResourceEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResourceEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResourceEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResourceEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResourceEdgesValidationError) ErrorName() string { return "ResourceEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e ResourceEdgesValidationError) 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 %sResourceEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResourceEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResourceEdgesValidationError{} - -// Validate checks the field values on Department 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 *Department) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Department 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 DepartmentMultiError, or -// nil if none found. -func (m *Department) ValidateAll() error { - return m.validate(true) -} - -func (m *Department) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Keyword - - // no validation rules for Name - - // no validation rules for TreePath - - // no validation rules for Sequence - - // no validation rules for Status - - // no validation rules for Level - - // no validation rules for Description - - // no validation rules for ParentId - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DepartmentMultiError(errors) - } - - return nil -} - -// DepartmentMultiError is an error wrapping multiple validation errors -// returned by Department.ValidateAll() if the designated constraints aren't met. -type DepartmentMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DepartmentMultiError) 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 DepartmentMultiError) AllErrors() []error { return m } - -// DepartmentValidationError is the validation error returned by -// Department.Validate if the designated constraints aren't met. -type DepartmentValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DepartmentValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DepartmentValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DepartmentValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DepartmentValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DepartmentValidationError) ErrorName() string { return "DepartmentValidationError" } - -// Error satisfies the builtin error interface -func (e DepartmentValidationError) 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 %sDepartment.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DepartmentValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DepartmentValidationError{} - -// Validate checks the field values on DepartmentEdges 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 *DepartmentEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DepartmentEdges 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 -// DepartmentEdgesMultiError, or nil if none found. -func (m *DepartmentEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *DepartmentEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetUserDepartments() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("UserDepartments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("UserDepartments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("UserDepartments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return DepartmentEdgesMultiError(errors) - } - - return nil -} - -// DepartmentEdgesMultiError is an error wrapping multiple validation errors -// returned by DepartmentEdges.ValidateAll() if the designated constraints -// aren't met. -type DepartmentEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DepartmentEdgesMultiError) 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 DepartmentEdgesMultiError) AllErrors() []error { return m } - -// DepartmentEdgesValidationError is the validation error returned by -// DepartmentEdges.Validate if the designated constraints aren't met. -type DepartmentEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DepartmentEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DepartmentEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DepartmentEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DepartmentEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DepartmentEdgesValidationError) ErrorName() string { return "DepartmentEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e DepartmentEdgesValidationError) 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 %sDepartmentEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DepartmentEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DepartmentEdgesValidationError{} - -// Validate checks the field values on UserDepartment 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 *UserDepartment) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserDepartment 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 UserDepartmentMultiError, -// or nil if none found. -func (m *UserDepartment) ValidateAll() error { - return m.validate(true) -} - -func (m *UserDepartment) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for UserId - - // no validation rules for DepartmentId - - if all { - switch v := interface{}(m.GetEdges()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserDepartmentValidationError{ - field: "Edges", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserDepartmentValidationError{ - field: "Edges", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEdges()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserDepartmentValidationError{ - field: "Edges", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserDepartmentMultiError(errors) - } - - return nil -} - -// UserDepartmentMultiError is an error wrapping multiple validation errors -// returned by UserDepartment.ValidateAll() if the designated constraints -// aren't met. -type UserDepartmentMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserDepartmentMultiError) 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 UserDepartmentMultiError) AllErrors() []error { return m } - -// UserDepartmentValidationError is the validation error returned by -// UserDepartment.Validate if the designated constraints aren't met. -type UserDepartmentValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserDepartmentValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserDepartmentValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserDepartmentValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserDepartmentValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserDepartmentValidationError) ErrorName() string { return "UserDepartmentValidationError" } - -// Error satisfies the builtin error interface -func (e UserDepartmentValidationError) 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 %sUserDepartment.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserDepartmentValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserDepartmentValidationError{} - -// Validate checks the field values on UserDepartmentEdges 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 *UserDepartmentEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserDepartmentEdges 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 -// UserDepartmentEdgesMultiError, or nil if none found. -func (m *UserDepartmentEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserDepartmentEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserDepartmentEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserDepartmentEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserDepartmentEdgesMultiError(errors) - } - - return nil -} - -// UserDepartmentEdgesMultiError is an error wrapping multiple validation -// errors returned by UserDepartmentEdges.ValidateAll() if the designated -// constraints aren't met. -type UserDepartmentEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserDepartmentEdgesMultiError) 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 UserDepartmentEdgesMultiError) AllErrors() []error { return m } - -// UserDepartmentEdgesValidationError is the validation error returned by -// UserDepartmentEdges.Validate if the designated constraints aren't met. -type UserDepartmentEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserDepartmentEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserDepartmentEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserDepartmentEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserDepartmentEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserDepartmentEdgesValidationError) ErrorName() string { - return "UserDepartmentEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e UserDepartmentEdgesValidationError) 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 %sUserDepartmentEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserDepartmentEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserDepartmentEdgesValidationError{} - -// Validate checks the field values on Position 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 *Position) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Position 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 PositionMultiError, or nil -// if none found. -func (m *Position) ValidateAll() error { - return m.validate(true) -} - -func (m *Position) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Name - - // no validation rules for Keyword - - // no validation rules for Description - - // no validation rules for DepartmentId - - if len(errors) > 0 { - return PositionMultiError(errors) - } - - return nil -} - -// PositionMultiError is an error wrapping multiple validation errors returned -// by Position.ValidateAll() if the designated constraints aren't met. -type PositionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionMultiError) 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 PositionMultiError) AllErrors() []error { return m } - -// PositionValidationError is the validation error returned by -// Position.Validate if the designated constraints aren't met. -type PositionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PositionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PositionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PositionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PositionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PositionValidationError) ErrorName() string { return "PositionValidationError" } - -// Error satisfies the builtin error interface -func (e PositionValidationError) 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 %sPosition.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PositionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PositionValidationError{} - -// Validate checks the field values on PositionEdges 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 *PositionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PositionEdges 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 PositionEdgesMultiError, or -// nil if none found. -func (m *PositionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *PositionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUserPositions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("UserPositions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("UserPositions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("UserPositions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositionPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return PositionEdgesMultiError(errors) - } - - return nil -} - -// PositionEdgesMultiError is an error wrapping multiple validation errors -// returned by PositionEdges.ValidateAll() if the designated constraints -// aren't met. -type PositionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionEdgesMultiError) 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 PositionEdgesMultiError) AllErrors() []error { return m } - -// PositionEdgesValidationError is the validation error returned by -// PositionEdges.Validate if the designated constraints aren't met. -type PositionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PositionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PositionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PositionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PositionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PositionEdgesValidationError) ErrorName() string { return "PositionEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e PositionEdgesValidationError) 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 %sPositionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PositionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PositionEdgesValidationError{} - -// Validate checks the field values on Permission 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 *Permission) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Permission 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 PermissionMultiError, or -// nil if none found. -func (m *Permission) ValidateAll() error { - return m.validate(true) -} - -func (m *Permission) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Name - - // no validation rules for Keyword - - // no validation rules for Description - - // no validation rules for DataScope - - // no validation rules for DataRules - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return PermissionMultiError(errors) - } - - return nil -} - -// PermissionMultiError is an error wrapping multiple validation errors -// returned by Permission.ValidateAll() if the designated constraints aren't met. -type PermissionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PermissionMultiError) 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 PermissionMultiError) AllErrors() []error { return m } - -// PermissionValidationError is the validation error returned by -// Permission.Validate if the designated constraints aren't met. -type PermissionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PermissionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PermissionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PermissionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PermissionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PermissionValidationError) ErrorName() string { return "PermissionValidationError" } - -// Error satisfies the builtin error interface -func (e PermissionValidationError) 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 %sPermission.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PermissionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PermissionValidationError{} - -// Validate checks the field values on PermissionEdges 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 *PermissionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PermissionEdges 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 -// PermissionEdgesMultiError, or nil if none found. -func (m *PermissionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *PermissionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRolePermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("RolePermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("RolePermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("RolePermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPermissionResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PermissionResources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PermissionResources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("PermissionResources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositionPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return PermissionEdgesMultiError(errors) - } - - return nil -} - -// PermissionEdgesMultiError is an error wrapping multiple validation errors -// returned by PermissionEdges.ValidateAll() if the designated constraints -// aren't met. -type PermissionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PermissionEdgesMultiError) 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 PermissionEdgesMultiError) AllErrors() []error { return m } - -// PermissionEdgesValidationError is the validation error returned by -// PermissionEdges.Validate if the designated constraints aren't met. -type PermissionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PermissionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PermissionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PermissionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PermissionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PermissionEdgesValidationError) ErrorName() string { return "PermissionEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e PermissionEdgesValidationError) 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 %sPermissionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PermissionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PermissionEdgesValidationError{} - -// Validate checks the field values on UserPosition 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 *UserPosition) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserPosition 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 UserPositionMultiError, or -// nil if none found. -func (m *UserPosition) ValidateAll() error { - return m.validate(true) -} - -func (m *UserPosition) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for UserId - - // no validation rules for PositionId - - if len(errors) > 0 { - return UserPositionMultiError(errors) - } - - return nil -} - -// UserPositionMultiError is an error wrapping multiple validation errors -// returned by UserPosition.ValidateAll() if the designated constraints aren't met. -type UserPositionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserPositionMultiError) 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 UserPositionMultiError) AllErrors() []error { return m } - -// UserPositionValidationError is the validation error returned by -// UserPosition.Validate if the designated constraints aren't met. -type UserPositionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserPositionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserPositionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserPositionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserPositionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserPositionValidationError) ErrorName() string { return "UserPositionValidationError" } - -// Error satisfies the builtin error interface -func (e UserPositionValidationError) 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 %sUserPosition.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserPositionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserPositionValidationError{} - -// Validate checks the field values on UserPositionEdges 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 *UserPositionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserPositionEdges 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 -// UserPositionEdgesMultiError, or nil if none found. -func (m *UserPositionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserPositionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserPositionEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetPosition()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserPositionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserPositionEdgesMultiError(errors) - } - - return nil -} - -// UserPositionEdgesMultiError is an error wrapping multiple validation errors -// returned by UserPositionEdges.ValidateAll() if the designated constraints -// aren't met. -type UserPositionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserPositionEdgesMultiError) 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 UserPositionEdgesMultiError) AllErrors() []error { return m } - -// UserPositionEdgesValidationError is the validation error returned by -// UserPositionEdges.Validate if the designated constraints aren't met. -type UserPositionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserPositionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserPositionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserPositionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserPositionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserPositionEdgesValidationError) ErrorName() string { - return "UserPositionEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e UserPositionEdgesValidationError) 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 %sUserPositionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserPositionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserPositionEdgesValidationError{} - -// Validate checks the field values on PositionPermission 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 *PositionPermission) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PositionPermission 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 -// PositionPermissionMultiError, or nil if none found. -func (m *PositionPermission) ValidateAll() error { - return m.validate(true) -} - -func (m *PositionPermission) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for PositionId - - // no validation rules for PermissionId - - if len(errors) > 0 { - return PositionPermissionMultiError(errors) - } - - return nil -} - -// PositionPermissionMultiError is an error wrapping multiple validation errors -// returned by PositionPermission.ValidateAll() if the designated constraints -// aren't met. -type PositionPermissionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionPermissionMultiError) 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 PositionPermissionMultiError) AllErrors() []error { return m } - -// PositionPermissionValidationError is the validation error returned by -// PositionPermission.Validate if the designated constraints aren't met. -type PositionPermissionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PositionPermissionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PositionPermissionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PositionPermissionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PositionPermissionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PositionPermissionValidationError) ErrorName() string { - return "PositionPermissionValidationError" -} - -// Error satisfies the builtin error interface -func (e PositionPermissionValidationError) 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 %sPositionPermission.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PositionPermissionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PositionPermissionValidationError{} - -// Validate checks the field values on PositionPermissionEdges 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 *PositionPermissionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PositionPermissionEdges 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 -// PositionPermissionEdgesMultiError, or nil if none found. -func (m *PositionPermissionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *PositionPermissionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPosition()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionPermissionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionPermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return PositionPermissionEdgesMultiError(errors) - } - - return nil -} - -// PositionPermissionEdgesMultiError is an error wrapping multiple validation -// errors returned by PositionPermissionEdges.ValidateAll() if the designated -// constraints aren't met. -type PositionPermissionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionPermissionEdgesMultiError) 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 PositionPermissionEdgesMultiError) AllErrors() []error { return m } - -// PositionPermissionEdgesValidationError is the validation error returned by -// PositionPermissionEdges.Validate if the designated constraints aren't met. -type PositionPermissionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PositionPermissionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PositionPermissionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PositionPermissionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PositionPermissionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PositionPermissionEdgesValidationError) ErrorName() string { - return "PositionPermissionEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e PositionPermissionEdgesValidationError) 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 %sPositionPermissionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PositionPermissionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PositionPermissionEdgesValidationError{} - -// Validate checks the field values on RolePermission 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 *RolePermission) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RolePermission 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 RolePermissionMultiError, -// or nil if none found. -func (m *RolePermission) ValidateAll() error { - return m.validate(true) -} - -func (m *RolePermission) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for RoleId - - // no validation rules for PermissionId - - if len(errors) > 0 { - return RolePermissionMultiError(errors) - } - - return nil -} - -// RolePermissionMultiError is an error wrapping multiple validation errors -// returned by RolePermission.ValidateAll() if the designated constraints -// aren't met. -type RolePermissionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RolePermissionMultiError) 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 RolePermissionMultiError) AllErrors() []error { return m } - -// RolePermissionValidationError is the validation error returned by -// RolePermission.Validate if the designated constraints aren't met. -type RolePermissionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RolePermissionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RolePermissionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RolePermissionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RolePermissionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RolePermissionValidationError) ErrorName() string { return "RolePermissionValidationError" } - -// Error satisfies the builtin error interface -func (e RolePermissionValidationError) 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 %sRolePermission.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RolePermissionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RolePermissionValidationError{} - -// Validate checks the field values on RolePermissionEdges 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 *RolePermissionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RolePermissionEdges 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 -// RolePermissionEdgesMultiError, or nil if none found. -func (m *RolePermissionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *RolePermissionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RolePermissionEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RolePermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RolePermissionEdgesMultiError(errors) - } - - return nil -} - -// RolePermissionEdgesMultiError is an error wrapping multiple validation -// errors returned by RolePermissionEdges.ValidateAll() if the designated -// constraints aren't met. -type RolePermissionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RolePermissionEdgesMultiError) 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 RolePermissionEdgesMultiError) AllErrors() []error { return m } - -// RolePermissionEdgesValidationError is the validation error returned by -// RolePermissionEdges.Validate if the designated constraints aren't met. -type RolePermissionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RolePermissionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RolePermissionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RolePermissionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RolePermissionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RolePermissionEdgesValidationError) ErrorName() string { - return "RolePermissionEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e RolePermissionEdgesValidationError) 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 %sRolePermissionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RolePermissionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RolePermissionEdgesValidationError{} - -// Validate checks the field values on PermissionResource 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 *PermissionResource) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PermissionResource 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 -// PermissionResourceMultiError, or nil if none found. -func (m *PermissionResource) ValidateAll() error { - return m.validate(true) -} - -func (m *PermissionResource) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for PermissionId - - // no validation rules for ResourceId - - // no validation rules for Actions - - if len(errors) > 0 { - return PermissionResourceMultiError(errors) - } - - return nil -} - -// PermissionResourceMultiError is an error wrapping multiple validation errors -// returned by PermissionResource.ValidateAll() if the designated constraints -// aren't met. -type PermissionResourceMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PermissionResourceMultiError) 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 PermissionResourceMultiError) AllErrors() []error { return m } - -// PermissionResourceValidationError is the validation error returned by -// PermissionResource.Validate if the designated constraints aren't met. -type PermissionResourceValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PermissionResourceValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PermissionResourceValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PermissionResourceValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PermissionResourceValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PermissionResourceValidationError) ErrorName() string { - return "PermissionResourceValidationError" -} - -// Error satisfies the builtin error interface -func (e PermissionResourceValidationError) 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 %sPermissionResource.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PermissionResourceValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PermissionResourceValidationError{} - -// Validate checks the field values on PermissionResourceEdges 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 *PermissionResourceEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PermissionResourceEdges 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 -// PermissionResourceEdgesMultiError, or nil if none found. -func (m *PermissionResourceEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *PermissionResourceEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionResourceEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetResource()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionResourceEdgesValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return PermissionResourceEdgesMultiError(errors) - } - - return nil -} - -// PermissionResourceEdgesMultiError is an error wrapping multiple validation -// errors returned by PermissionResourceEdges.ValidateAll() if the designated -// constraints aren't met. -type PermissionResourceEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PermissionResourceEdgesMultiError) 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 PermissionResourceEdgesMultiError) AllErrors() []error { return m } - -// PermissionResourceEdgesValidationError is the validation error returned by -// PermissionResourceEdges.Validate if the designated constraints aren't met. -type PermissionResourceEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PermissionResourceEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PermissionResourceEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PermissionResourceEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PermissionResourceEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PermissionResourceEdgesValidationError) ErrorName() string { - return "PermissionResourceEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e PermissionResourceEdgesValidationError) 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 %sPermissionResourceEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PermissionResourceEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PermissionResourceEdgesValidationError{} diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go index c9783b2c..d6374d0e 100644 --- a/api/v1/services/system/user.pb.go +++ b/api/v1/services/system/user.pb.go @@ -15,6 +15,7 @@ import ( reflect "reflect" sync "sync" unsafe "unsafe" + types "v1/services/types" ) const ( @@ -71,7 +72,7 @@ func (x *ListUserResourcesRequest) GetId() int64 { type ListUserResourcesResponse struct { state protoimpl.MessageState `protogen:"open.v1"` TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -113,7 +114,7 @@ func (x *ListUserResourcesResponse) GetTotalSize() int32 { return 0 } -func (x *ListUserResourcesResponse) GetResources() []*Resource { +func (x *ListUserResourcesResponse) GetResources() []*types.Resource { if x != nil { return x.Resources } @@ -122,7 +123,7 @@ func (x *ListUserResourcesResponse) GetResources() []*Resource { type UpdateUserStatusRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -157,7 +158,7 @@ func (*UpdateUserStatusRequest) Descriptor() ([]byte, []int) { return file_system_user_proto_rawDescGZIP(), []int{2} } -func (x *UpdateUserStatusRequest) GetUser() *User { +func (x *UpdateUserStatusRequest) GetUser() *types.User { if x != nil { return x.User } @@ -392,7 +393,7 @@ type ListUsersResponse struct { // The total number of items in the list. TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` // The paging menus - Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` + Users []*types.User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` // The current page number. Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` // The maximum number of items to return. @@ -444,7 +445,7 @@ func (x *ListUsersResponse) GetTotalSize() int32 { return 0 } -func (x *ListUsersResponse) GetUsers() []*User { +func (x *ListUsersResponse) GetUsers() []*types.User { if x != nil { return x.Users } @@ -527,7 +528,7 @@ func (x *GetUserRequest) GetId() int64 { type GetUserResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -562,7 +563,7 @@ func (*GetUserResponse) Descriptor() ([]byte, []int) { return file_system_user_proto_rawDescGZIP(), []int{9} } -func (x *GetUserResponse) GetUser() *User { +func (x *GetUserResponse) GetUser() *types.User { if x != nil { return x.User } @@ -574,7 +575,7 @@ type CreateUserRequest struct { // The parent resource id where the user is to be created. Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` // The user resource to be created. - User *User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` + User *types.User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` // The user id to use for this user. UserId string `protobuf:"bytes,3,opt,name=user_id,proto3" json:"user_id,omitempty"` // The user is_system to use for this user. @@ -622,7 +623,7 @@ func (x *CreateUserRequest) GetParent() string { return "" } -func (x *CreateUserRequest) GetUser() *User { +func (x *CreateUserRequest) GetUser() *types.User { if x != nil { return x.User } @@ -652,7 +653,7 @@ func (x *CreateUserRequest) GetRandomPassword() bool { type CreateUserResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -687,7 +688,7 @@ func (*CreateUserResponse) Descriptor() ([]byte, []int) { return file_system_user_proto_rawDescGZIP(), []int{11} } -func (x *CreateUserResponse) GetUser() *User { +func (x *CreateUserResponse) GetUser() *types.User { if x != nil { return x.User } @@ -697,7 +698,7 @@ func (x *CreateUserResponse) GetUser() *User { type UpdateUserRequest struct { state protoimpl.MessageState `protogen:"open.v1"` // The user resource which replaces the resource on the server. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` // The user id to use for this user. UserId string `protobuf:"bytes,3,opt,name=user_id,proto3" json:"user_id,omitempty"` // The user is_system to use for this user. @@ -738,7 +739,7 @@ func (*UpdateUserRequest) Descriptor() ([]byte, []int) { return file_system_user_proto_rawDescGZIP(), []int{12} } -func (x *UpdateUserRequest) GetUser() *User { +func (x *UpdateUserRequest) GetUser() *types.User { if x != nil { return x.User } @@ -768,7 +769,7 @@ func (x *UpdateUserRequest) GetRandomPassword() bool { type UpdateUserResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -803,7 +804,7 @@ func (*UpdateUserResponse) Descriptor() ([]byte, []int) { return file_system_user_proto_rawDescGZIP(), []int{13} } -func (x *UpdateUserResponse) GetUser() *User { +func (x *UpdateUserResponse) GetUser() *types.User { if x != nil { return x.User } @@ -814,7 +815,7 @@ type DeleteUserRequest struct { state protoimpl.MessageState `protogen:"open.v1"` // The resource id of the user to be deleted, for example: // "shelves/shelf1/users/user2" - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -849,7 +850,7 @@ func (*DeleteUserRequest) Descriptor() ([]byte, []int) { return file_system_user_proto_rawDescGZIP(), []int{14} } -func (x *DeleteUserRequest) GetUser() *User { +func (x *DeleteUserRequest) GetUser() *types.User { if x != nil { return x.User } @@ -903,7 +904,7 @@ func (x *DeleteUserResponse) GetEmpty() *emptypb.Empty { type UpdateUserRolesRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - User *User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` + User *types.User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` RoleIds []int64 `protobuf:"varint,3,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` // bool is_add = 5 [json_name = "is_add"]; unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -946,7 +947,7 @@ func (x *UpdateUserRolesRequest) GetId() int64 { return 0 } -func (x *UpdateUserRolesRequest) GetUser() *User { +func (x *UpdateUserRolesRequest) GetUser() *types.User { if x != nil { return x.User } @@ -962,7 +963,7 @@ func (x *UpdateUserRolesRequest) GetRoleIds() []int64 { type UpdateUserRolesResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -997,7 +998,7 @@ func (*UpdateUserRolesResponse) Descriptor() ([]byte, []int) { return file_system_user_proto_rawDescGZIP(), []int{17} } -func (x *UpdateUserRolesResponse) GetUser() *User { +func (x *UpdateUserRolesResponse) GetUser() *types.User { if x != nil { return x.User } @@ -1008,16 +1009,16 @@ var File_system_user_proto protoreflect.FileDescriptor const file_system_user_proto_rawDesc = "" + "\n" + - "\x11system/user.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12system/types.proto\"*\n" + + "\x11system/user.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"*\n" + "\x18ListUserResourcesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"{\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"z\n" + "\x19ListUserResourcesResponse\x12\x1e\n" + "\n" + "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x12>\n" + - "\tresources\x18\x02 \x03(\v2 .api.v1.services.system.ResourceR\tresources\"K\n" + - "\x17UpdateUserStatusRequest\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"\x1a\n" + + "total_size\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"J\n" + + "\x17UpdateUserStatusRequest\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\x1a\n" + "\x18UpdateUserStatusResponse\"T\n" + "\x18ResetUserPasswordRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12(\n" + @@ -1034,46 +1035,46 @@ const file_system_user_proto_rawDesc = "" + "\n" + "only_count\x18\x06 \x01(\bR\n" + "only_count\x12\x14\n" + - "\x05title\x18\a \x01(\tR\x05title\"\x84\x02\n" + + "\x05title\x18\a \x01(\tR\x05title\"\x83\x02\n" + "\x11ListUsersResponse\x12\x1e\n" + "\n" + "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x122\n" + - "\x05users\x18\x02 \x03(\v2\x1c.api.v1.services.system.UserR\x05users\x12\x18\n" + + "total_size\x121\n" + + "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12\x18\n" + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + "\x06_extra\" \n" + "\x0eGetUserRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"C\n" + - "\x0fGetUserResponse\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"\xbf\x01\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x0fGetUserResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\xbe\x01\n" + "\x11CreateUserRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x120\n" + - "\x04user\x18\x02 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x12\x18\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12/\n" + + "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x18\n" + "\auser_id\x18\x03 \x01(\tR\auser_id\x12\x1c\n" + "\tis_system\x18\x04 \x01(\bR\tis_system\x12(\n" + - "\x0frandom_password\x18\x05 \x01(\bR\x0frandom_password\"F\n" + - "\x12CreateUserResponse\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"\xa7\x01\n" + - "\x11UpdateUserRequest\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x12\x18\n" + + "\x0frandom_password\x18\x05 \x01(\bR\x0frandom_password\"E\n" + + "\x12CreateUserResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\xa6\x01\n" + + "\x11UpdateUserRequest\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x18\n" + "\auser_id\x18\x03 \x01(\tR\auser_id\x12\x1c\n" + "\tis_system\x18\x04 \x01(\bR\tis_system\x12(\n" + - "\x0frandom_password\x18\x02 \x01(\bR\x0frandom_password\"F\n" + - "\x12UpdateUserResponse\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"E\n" + - "\x11DeleteUserRequest\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\"B\n" + + "\x0frandom_password\x18\x02 \x01(\bR\x0frandom_password\"E\n" + + "\x12UpdateUserResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"D\n" + + "\x11DeleteUserRequest\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"B\n" + "\x12DeleteUserResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"v\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"u\n" + "\x16UpdateUserRolesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x120\n" + - "\x04user\x18\x02 \x01(\v2\x1c.api.v1.services.system.UserR\x04user\x12\x1a\n" + - "\brole_ids\x18\x03 \x03(\x03R\brole_ids\"K\n" + - "\x17UpdateUserRolesResponse\x120\n" + - "\x04user\x18\x01 \x01(\v2\x1c.api.v1.services.system.UserR\x04user2\x8e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12/\n" + + "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x1a\n" + + "\brole_ids\x18\x03 \x03(\x03R\brole_ids\"J\n" + + "\x17UpdateUserRolesResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\x8e\n" + "\n" + "\vUserService\x12t\n" + "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + @@ -1124,26 +1125,26 @@ var file_system_user_proto_goTypes = []any{ (*DeleteUserResponse)(nil), // 15: api.v1.services.system.DeleteUserResponse (*UpdateUserRolesRequest)(nil), // 16: api.v1.services.system.UpdateUserRolesRequest (*UpdateUserRolesResponse)(nil), // 17: api.v1.services.system.UpdateUserRolesResponse - (*Resource)(nil), // 18: api.v1.services.system.Resource - (*User)(nil), // 19: api.v1.services.system.User + (*types.Resource)(nil), // 18: api.v1.services.types.Resource + (*types.User)(nil), // 19: api.v1.services.types.User (*anypb.Any)(nil), // 20: google.protobuf.Any (*emptypb.Empty)(nil), // 21: google.protobuf.Empty } var file_system_user_proto_depIdxs = []int32{ - 18, // 0: api.v1.services.system.ListUserResourcesResponse.resources:type_name -> api.v1.services.system.Resource - 19, // 1: api.v1.services.system.UpdateUserStatusRequest.user:type_name -> api.v1.services.system.User + 18, // 0: api.v1.services.system.ListUserResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 19, // 1: api.v1.services.system.UpdateUserStatusRequest.user:type_name -> api.v1.services.types.User 20, // 2: api.v1.services.system.ResetUserPasswordRequest.data:type_name -> google.protobuf.Any - 19, // 3: api.v1.services.system.ListUsersResponse.users:type_name -> api.v1.services.system.User + 19, // 3: api.v1.services.system.ListUsersResponse.users:type_name -> api.v1.services.types.User 20, // 4: api.v1.services.system.ListUsersResponse.extra:type_name -> google.protobuf.Any - 19, // 5: api.v1.services.system.GetUserResponse.user:type_name -> api.v1.services.system.User - 19, // 6: api.v1.services.system.CreateUserRequest.user:type_name -> api.v1.services.system.User - 19, // 7: api.v1.services.system.CreateUserResponse.user:type_name -> api.v1.services.system.User - 19, // 8: api.v1.services.system.UpdateUserRequest.user:type_name -> api.v1.services.system.User - 19, // 9: api.v1.services.system.UpdateUserResponse.user:type_name -> api.v1.services.system.User - 19, // 10: api.v1.services.system.DeleteUserRequest.user:type_name -> api.v1.services.system.User + 19, // 5: api.v1.services.system.GetUserResponse.user:type_name -> api.v1.services.types.User + 19, // 6: api.v1.services.system.CreateUserRequest.user:type_name -> api.v1.services.types.User + 19, // 7: api.v1.services.system.CreateUserResponse.user:type_name -> api.v1.services.types.User + 19, // 8: api.v1.services.system.UpdateUserRequest.user:type_name -> api.v1.services.types.User + 19, // 9: api.v1.services.system.UpdateUserResponse.user:type_name -> api.v1.services.types.User + 19, // 10: api.v1.services.system.DeleteUserRequest.user:type_name -> api.v1.services.types.User 21, // 11: api.v1.services.system.DeleteUserResponse.empty:type_name -> google.protobuf.Empty - 19, // 12: api.v1.services.system.UpdateUserRolesRequest.user:type_name -> api.v1.services.system.User - 19, // 13: api.v1.services.system.UpdateUserRolesResponse.user:type_name -> api.v1.services.system.User + 19, // 12: api.v1.services.system.UpdateUserRolesRequest.user:type_name -> api.v1.services.types.User + 19, // 13: api.v1.services.system.UpdateUserRolesResponse.user:type_name -> api.v1.services.types.User 6, // 14: api.v1.services.system.UserService.ListUsers:input_type -> api.v1.services.system.ListUsersRequest 0, // 15: api.v1.services.system.UserService.ListUserResources:input_type -> api.v1.services.system.ListUserResourcesRequest 8, // 16: api.v1.services.system.UserService.GetUser:input_type -> api.v1.services.system.GetUserRequest @@ -1174,7 +1175,6 @@ func file_system_user_proto_init() { if File_system_user_proto != nil { return } - file_system_types_proto_init() file_system_user_proto_msgTypes[7].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ diff --git a/api/v1/services/system/user_agent.pb.go b/api/v1/services/system/user_agent.pb.go deleted file mode 100644 index 2d8fa075..00000000 --- a/api/v1/services/system/user_agent.pb.go +++ /dev/null @@ -1,293 +0,0 @@ -// Code generated by protoc-gen-go-agent. DO NOT EDIT. -// versions: -// - protoc-gen-go-agent unknown -// - protoc (unknown) -// source: system/user.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - agent "github.com/origadmin/runtime/agent" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 -const _ = agent.ApiVersionV1 - -type UserServiceAgent interface { - CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) - DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) - GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) - ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) - ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) - // ResetUserPassword ResetUserPassword reset the user s password - ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) - UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) - // UpdateUserRoles UpdateUserRoles update the user roles - UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) - // UpdateUserStatus UpdateUserStatus Update the status of the user information - UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) -} - -func _UserService_ListUsers0_HTTPAgent_Handler(srv UserServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListUsersRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationUserServiceListUsers) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListUsers(ctx, req.(*ListUsersRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListUsersResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _UserService_ListUserResources0_HTTPAgent_Handler(srv UserServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ListUserResourcesRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationUserServiceListUserResources) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ListUserResources(ctx, req.(*ListUserResourcesRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ListUserResourcesResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _UserService_GetUser0_HTTPAgent_Handler(srv UserServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in GetUserRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationUserServiceGetUser) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.GetUser(ctx, req.(*GetUserRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*GetUserResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _UserService_CreateUser0_HTTPAgent_Handler(srv UserServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in CreateUserRequest - if err := cctx.Bind(&in.User); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationUserServiceCreateUser) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.CreateUser(ctx, req.(*CreateUserRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*CreateUserResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _UserService_UpdateUser0_HTTPAgent_Handler(srv UserServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdateUserRequest - if err := cctx.Bind(&in.User); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationUserServiceUpdateUser) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdateUser(ctx, req.(*UpdateUserRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateUserResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _UserService_DeleteUser0_HTTPAgent_Handler(srv UserServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in DeleteUserRequest - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationUserServiceDeleteUser) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.DeleteUser(ctx, req.(*DeleteUserRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteUserResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _UserService_UpdateUserStatus0_HTTPAgent_Handler(srv UserServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdateUserStatusRequest - if err := cctx.Bind(&in.User); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationUserServiceUpdateUserStatus) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdateUserStatus(ctx, req.(*UpdateUserStatusRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateUserStatusResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _UserService_UpdateUserRoles0_HTTPAgent_Handler(srv UserServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in UpdateUserRolesRequest - if err := cctx.Bind(&in.User); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationUserServiceUpdateUserRoles) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.UpdateUserRoles(ctx, req.(*UpdateUserRolesRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateUserRolesResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func _UserService_ResetUserPassword0_HTTPAgent_Handler(srv UserServiceAgent) http.HandlerFunc { - return func(cctx http.Context) error { - var in ResetUserPasswordRequest - if err := cctx.Bind(&in.Data); err != nil { - return err - } - if err := cctx.BindQuery(&in); err != nil { - return err - } - if err := cctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(cctx, OperationUserServiceResetUserPassword) - h := cctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - ctx = agent.NewHTTPContext(ctx, cctx) - return srv.ResetUserPassword(ctx, req.(*ResetUserPasswordRequest)) - }) - out, err := h(cctx, &in) - if err != nil { - return err - } - reply := out.(*ResetUserPasswordResponse) - if reply == nil { - return nil - } - return cctx.Result(200, reply) - } -} - -func RegisterUserServiceAgent(ag agent.HTTPAgent, srv UserServiceAgent) { - r := ag.Route() - r.GET("/sys/users", _UserService_ListUsers0_HTTPAgent_Handler(srv)) - r.GET("/sys/users/{id}/resources", _UserService_ListUserResources0_HTTPAgent_Handler(srv)) - r.GET("/sys/users/{id}", _UserService_GetUser0_HTTPAgent_Handler(srv)) - r.POST("/sys/users", _UserService_CreateUser0_HTTPAgent_Handler(srv)) - r.PUT("/sys/users/{user.id}", _UserService_UpdateUser0_HTTPAgent_Handler(srv)) - r.DELETE("/sys/users/{user.id}", _UserService_DeleteUser0_HTTPAgent_Handler(srv)) - r.PUT("/sys/users/{user.id}/status", _UserService_UpdateUserStatus0_HTTPAgent_Handler(srv)) - r.PUT("/sys/users/{user.id}/roles", _UserService_UpdateUserRoles0_HTTPAgent_Handler(srv)) - r.POST("/sys/users/{id}/password/reset", _UserService_ResetUserPassword0_HTTPAgent_Handler(srv)) -} diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go new file mode 100644 index 00000000..490cd64c --- /dev/null +++ b/api/v1/services/system/user_bridge.pb.go @@ -0,0 +1,501 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/user.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +const UserServiceCreateUserBridgeOperation = "/api.v1.services.system.UserService/CreateUser" +const UserServiceDeleteUserBridgeOperation = "/api.v1.services.system.UserService/DeleteUser" +const UserServiceGetUserBridgeOperation = "/api.v1.services.system.UserService/GetUser" +const UserServiceListUserResourcesBridgeOperation = "/api.v1.services.system.UserService/ListUserResources" +const UserServiceListUsersBridgeOperation = "/api.v1.services.system.UserService/ListUsers" +const UserServiceResetUserPasswordBridgeOperation = "/api.v1.services.system.UserService/ResetUserPassword" +const UserServiceUpdateUserBridgeOperation = "/api.v1.services.system.UserService/UpdateUser" +const UserServiceUpdateUserRolesBridgeOperation = "/api.v1.services.system.UserService/UpdateUserRoles" +const UserServiceUpdateUserStatusBridgeOperation = "/api.v1.services.system.UserService/UpdateUserStatus" + +type UserServiceBridger interface { + CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) + DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) + GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) + ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) + ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) + // ResetUserPassword ResetUserPassword reset the user s password + ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) + UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) + // UpdateUserRoles UpdateUserRoles update the user roles + UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) + // UpdateUserStatus UpdateUserStatus Update the status of the user information + UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) +} + +type UserServiceBridgeHooker interface { + UserServiceBridger + BeforeCreateUser(http.Context, *CreateUserRequest) (context.Context, error) + CreateUserResult(http.Context, *CreateUserRequest, *CreateUserResponse) error + BeforeDeleteUser(http.Context, *DeleteUserRequest) (context.Context, error) + DeleteUserResult(http.Context, *DeleteUserRequest, *DeleteUserResponse) error + BeforeGetUser(http.Context, *GetUserRequest) (context.Context, error) + GetUserResult(http.Context, *GetUserRequest, *GetUserResponse) error + BeforeListUserResources(http.Context, *ListUserResourcesRequest) (context.Context, error) + ListUserResourcesResult(http.Context, *ListUserResourcesRequest, *ListUserResourcesResponse) error + BeforeListUsers(http.Context, *ListUsersRequest) (context.Context, error) + ListUsersResult(http.Context, *ListUsersRequest, *ListUsersResponse) error + // ResetUserPassword ResetUserPassword reset the user s password + BeforeResetUserPassword(http.Context, *ResetUserPasswordRequest) (context.Context, error) + ResetUserPasswordResult(http.Context, *ResetUserPasswordRequest, *ResetUserPasswordResponse) error + BeforeUpdateUser(http.Context, *UpdateUserRequest) (context.Context, error) + UpdateUserResult(http.Context, *UpdateUserRequest, *UpdateUserResponse) error + // UpdateUserRoles UpdateUserRoles update the user roles + BeforeUpdateUserRoles(http.Context, *UpdateUserRolesRequest) (context.Context, error) + UpdateUserRolesResult(http.Context, *UpdateUserRolesRequest, *UpdateUserRolesResponse) error + // UpdateUserStatus UpdateUserStatus Update the status of the user information + BeforeUpdateUserStatus(http.Context, *UpdateUserStatusRequest) (context.Context, error) + UpdateUserStatusResult(http.Context, *UpdateUserStatusRequest, *UpdateUserStatusResponse) error +} + +func RegisterUserServiceBridger(s *http.Server, srv UserServiceBridger) { + r := s.Route("/") + hook, ok := srv.(UserServiceBridgeHooker) + if !ok { + hook = UnimplementedUserServiceBridger{UserServiceBridger: srv} + } + r.GET("/sys/users", _UserService_ListUsers0_Bridge_Handler(hook)) + r.GET("/sys/users/:id/resources", _UserService_ListUserResources0_Bridge_Handler(hook)) + r.GET("/sys/users/:id", _UserService_GetUser0_Bridge_Handler(hook)) + r.POST("/sys/users", _UserService_CreateUser0_Bridge_Handler(hook)) + r.PUT("/sys/users/:user.id", _UserService_UpdateUser0_Bridge_Handler(hook)) + r.DELETE("/sys/users/:user.id", _UserService_DeleteUser0_Bridge_Handler(hook)) + r.PUT("/sys/users/:user.id/status", _UserService_UpdateUserStatus0_Bridge_Handler(hook)) + r.PUT("/sys/users/:user.id/roles", _UserService_UpdateUserRoles0_Bridge_Handler(hook)) + r.POST("/sys/users/:id/password/reset", _UserService_ResetUserPassword0_Bridge_Handler(hook)) +} + +func _UserService_ListUsers0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListUsersRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceListUsers) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUsers(ctx, req.(*ListUsersRequest)) + }) + + newctx, err := srv.BeforeListUsers(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListUsersResult(ctx, &in, out.(*ListUsersResponse)) + } +} + +func _UserService_ListUserResources0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListUserResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceListUserResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUserResources(ctx, req.(*ListUserResourcesRequest)) + }) + + newctx, err := srv.BeforeListUserResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ListUserResourcesResult(ctx, &in, out.(*ListUserResourcesResponse)) + } +} + +func _UserService_GetUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUserRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceGetUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUser(ctx, req.(*GetUserRequest)) + }) + + newctx, err := srv.BeforeGetUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.GetUserResult(ctx, &in, out.(*GetUserResponse)) + } +} + +func _UserService_CreateUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateUserRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceCreateUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateUser(ctx, req.(*CreateUserRequest)) + }) + + newctx, err := srv.BeforeCreateUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CreateUserResult(ctx, &in, out.(*CreateUserResponse)) + } +} + +func _UserService_UpdateUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUserRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceUpdateUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUser(ctx, req.(*UpdateUserRequest)) + }) + + newctx, err := srv.BeforeUpdateUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdateUserResult(ctx, &in, out.(*UpdateUserResponse)) + } +} + +func _UserService_DeleteUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteUserRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceDeleteUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteUser(ctx, req.(*DeleteUserRequest)) + }) + + newctx, err := srv.BeforeDeleteUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.DeleteUserResult(ctx, &in, out.(*DeleteUserResponse)) + } +} + +func _UserService_UpdateUserStatus0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUserStatusRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceUpdateUserStatus) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUserStatus(ctx, req.(*UpdateUserStatusRequest)) + }) + + newctx, err := srv.BeforeUpdateUserStatus(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdateUserStatusResult(ctx, &in, out.(*UpdateUserStatusResponse)) + } +} + +func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUserRolesRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceUpdateUserRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUserRoles(ctx, req.(*UpdateUserRolesRequest)) + }) + + newctx, err := srv.BeforeUpdateUserRoles(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.UpdateUserRolesResult(ctx, &in, out.(*UpdateUserRolesResponse)) + } +} + +func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ResetUserPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceResetUserPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ResetUserPassword(ctx, req.(*ResetUserPasswordRequest)) + }) + + newctx, err := srv.BeforeResetUserPassword(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.ResetUserPasswordResult(ctx, &in, out.(*ResetUserPasswordResponse)) + } +} + +// UnimplementedUserServiceBridger must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedUserServiceBridger struct { + UserServiceBridger +} + +func (UnimplementedUserServiceBridger) BeforeCreateUser(ctx http.Context, in *CreateUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceBridger) CreateUserResult(ctx http.Context, in *CreateUserRequest, out *CreateUserResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceBridger) BeforeDeleteUser(ctx http.Context, in *DeleteUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceBridger) DeleteUserResult(ctx http.Context, in *DeleteUserRequest, out *DeleteUserResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceBridger) BeforeGetUser(ctx http.Context, in *GetUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceBridger) GetUserResult(ctx http.Context, in *GetUserRequest, out *GetUserResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceBridger) BeforeListUserResources(ctx http.Context, in *ListUserResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceBridger) ListUserResourcesResult(ctx http.Context, in *ListUserResourcesRequest, out *ListUserResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceBridger) BeforeListUsers(ctx http.Context, in *ListUsersRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceBridger) ListUsersResult(ctx http.Context, in *ListUsersRequest, out *ListUsersResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceBridger) BeforeResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceBridger) ResetUserPasswordResult(ctx http.Context, in *ResetUserPasswordRequest, out *ResetUserPasswordResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceBridger) BeforeUpdateUser(ctx http.Context, in *UpdateUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceBridger) UpdateUserResult(ctx http.Context, in *UpdateUserRequest, out *UpdateUserResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceBridger) BeforeUpdateUserRoles(ctx http.Context, in *UpdateUserRolesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceBridger) UpdateUserRolesResult(ctx http.Context, in *UpdateUserRolesRequest, out *UpdateUserRolesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceBridger) BeforeUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceBridger) UpdateUserStatusResult(ctx http.Context, in *UpdateUserStatusRequest, out *UpdateUserStatusResponse) error { + return ctx.Result(200, out) +} + +type UserServiceHTTPBridgeImpl struct { + client UserServiceHTTPClient +} + +func NewUserServiceHTTPBridge(client *http.Client) UserServiceHTTPServer { + return &UserServiceHTTPBridgeImpl{client: NewUserServiceHTTPClient(client)} +} + +func (c *UserServiceHTTPBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { + return c.client.GetUser(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { + return c.client.UpdateUserRoles(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) +} + +type UserServiceBridgeImpl struct { + client UserServiceClient +} + +func NewUserServiceBridge(client grpc.ClientConnInterface) UserServiceServer { + return &UserServiceBridgeImpl{client: NewUserServiceClient(client)} +} + +func (c *UserServiceBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *UserServiceBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +func (c *UserServiceBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { + return c.client.GetUser(ctx, in) +} + +func (c *UserServiceBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) +} + +func (c *UserServiceBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *UserServiceBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) +} + +func (c *UserServiceBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *UserServiceBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { + return c.client.UpdateUserRoles(ctx, in) +} + +func (c *UserServiceBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) +} + +func (c *UserServiceBridgeImpl) mustEmbedUnimplementedUserServiceServer() {} diff --git a/buf.gen.yaml b/buf.gen.yaml index 1a06b476..8900a4c4 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -41,7 +41,7 @@ plugins: - local: protoc-gen-go-grpc out: api/v1/services opt: paths=source_relative - - local: protoc-gen-go-agent + - local: protoc-gen-go-bridge out: api/v1/services opt: paths=source_relative - local: protoc-gen-grpc-gateway diff --git a/buf.lock b/buf.lock index d7a807f9..fef6ea1f 100644 --- a/buf.lock +++ b/buf.lock @@ -16,3 +16,6 @@ deps: - name: buf.build/origadmin/runtime commit: 67cc18c9322e48e78a0282fb854970bb digest: b5:8d14f8cf309734eddd71f02c03b7c2612542fe1935ecc3329c5d2c949dec14f098360cf610a9d03e35ccb764740f37090b5c228b04ff3be539861a4cd39ed617 + - name: buf.build/protocolbuffers/wellknowntypes + commit: 3ddd61d1f53d485abd3d3a2b47a62b8e + digest: b5:09e4405493fa16fef2af6b667fcaea9d2280ec44ed4943eddb96fb5a32daa1e8a353331dd4ef33b7df3783d17e912a703d57b73b236cd749d6a87ce83f60e2c9 diff --git a/buf.yaml b/buf.yaml index 369a35cf..638504d2 100644 --- a/buf.yaml +++ b/buf.yaml @@ -16,6 +16,9 @@ breaking: use: - FILE deps: + - buf.build/protocolbuffers/wellknowntypes +# - buf.build/grpc/grpc-go +# - buf.build/grpc/grpc-gateway - buf.build/envoyproxy/protoc-gen-validate - buf.build/kratos/apis - buf.build/googleapis/googleapis diff --git a/internal/mods/system/service/role.bridge.go b/internal/mods/system/service/role.bridge.go index c8da0db8..74815b6e 100644 --- a/internal/mods/system/service/role.bridge.go +++ b/internal/mods/system/service/role.bridge.go @@ -16,14 +16,14 @@ import ( "origadmin/application/admin/helpers/resp" ) -// RoleServiceBridge is a menu service. -type RoleServiceBridge struct { +// RoleServiceAgent is a menu service. +type RoleServiceAgent struct { resp.Response client pb.RoleServiceClient } -func (s RoleServiceBridge) CreateRole(ctx context.Context, request *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { +func (s RoleServiceAgent) CreateRole(ctx context.Context, request *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.CreateRole(ctx, request) if err != nil { @@ -36,7 +36,7 @@ func (s RoleServiceBridge) CreateRole(ctx context.Context, request *pb.CreateRol return nil, nil } -func (s RoleServiceBridge) DeleteRole(ctx context.Context, request *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { +func (s RoleServiceAgent) DeleteRole(ctx context.Context, request *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.DeleteRole(ctx, request) if err != nil { @@ -49,7 +49,7 @@ func (s RoleServiceBridge) DeleteRole(ctx context.Context, request *pb.DeleteRol return nil, nil } -func (s RoleServiceBridge) GetRole(ctx context.Context, request *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { +func (s RoleServiceAgent) GetRole(ctx context.Context, request *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.GetRole(ctx, request) if err != nil { @@ -62,7 +62,7 @@ func (s RoleServiceBridge) GetRole(ctx context.Context, request *pb.GetRoleReque return nil, nil } -func (s RoleServiceBridge) ListRoles(ctx context.Context, request *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { +func (s RoleServiceAgent) ListRoles(ctx context.Context, request *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.ListRoles(ctx, request) if err != nil { @@ -76,7 +76,7 @@ func (s RoleServiceBridge) ListRoles(ctx context.Context, request *pb.ListRolesR return nil, nil } -func (s RoleServiceBridge) UpdateRole(ctx context.Context, request *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { +func (s RoleServiceAgent) UpdateRole(ctx context.Context, request *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { httpCtx := agent.FromHTTPContext(ctx) response, err := s.client.UpdateRole(ctx, request) if err != nil { @@ -89,18 +89,18 @@ func (s RoleServiceBridge) UpdateRole(ctx context.Context, request *pb.UpdateRol return nil, nil } -// NewRoleServiceBridge new a menu service. -func NewRoleServiceBridge(client pb.RoleServiceClient) *RoleServiceBridge { - return &RoleServiceBridge{client: client} +// NewRoleServiceAgent new a menu service. +func NewRoleServiceAgent(client pb.RoleServiceClient) *RoleServiceAgent { + return &RoleServiceAgent{client: client} } -// NewRoleServiceBridgePB new a menu service. -func NewRoleServiceBridgePB(client pb.RoleServiceClient) pb.RoleServiceBridge { - return &RoleServiceBridge{client: client} +// NewRoleServiceAgentPB new a menu service. +func NewRoleServiceAgentPB(client pb.RoleServiceClient) pb.RoleServiceBridger { + return &RoleServiceAgent{client: client} } -func NewRoleServiceBridgeClient(client *service.GRPCClient) pb.RoleServiceBridge { +func NewRoleServiceAgentClient(client *service.GRPCClient) pb.RoleServiceAgent { c := pb.NewRoleServiceClient(client) - return NewRoleServiceBridge(c) + return NewRoleServiceAgent(c) } -var _ pb.RoleServiceBridge = (*RoleServiceBridge)(nil) +var _ pb.RoleServiceAgent = (*RoleServiceAgent)(nil) diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index fb8ad2ca..8c7fff99 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -607,7 +607,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Department' + $ref: '#/components/schemas/api.v1.services.types.Department' required: true responses: "200": @@ -642,7 +642,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Department' + $ref: '#/components/schemas/api.v1.services.types.Department' required: true responses: "200": @@ -780,7 +780,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Menu' + $ref: '#/components/schemas/api.v1.services.types.Menu' required: true responses: "200": @@ -863,7 +863,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Menu' + $ref: '#/components/schemas/api.v1.services.types.Menu' required: true responses: "200": @@ -955,7 +955,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Permission' + $ref: '#/components/schemas/api.v1.services.types.Permission' required: true responses: "200": @@ -1043,7 +1043,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Permission' + $ref: '#/components/schemas/api.v1.services.types.Permission' required: true responses: "200": @@ -1342,7 +1342,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Position' + $ref: '#/components/schemas/api.v1.services.types.Position' required: true responses: "200": @@ -1430,7 +1430,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Position' + $ref: '#/components/schemas/api.v1.services.types.Position' required: true responses: "200": @@ -1520,7 +1520,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' required: true responses: "200": @@ -1608,7 +1608,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' required: true responses: "200": @@ -1693,7 +1693,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Role' + $ref: '#/components/schemas/api.v1.services.types.Role' required: true responses: "200": @@ -1781,7 +1781,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.Role' + $ref: '#/components/schemas/api.v1.services.types.Role' required: true responses: "200": @@ -1881,7 +1881,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.User' + $ref: '#/components/schemas/api.v1.services.types.User' required: true responses: "200": @@ -2008,7 +2008,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.User' + $ref: '#/components/schemas/api.v1.services.types.User' required: true responses: "200": @@ -2215,7 +2215,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.User' + $ref: '#/components/schemas/api.v1.services.types.User' required: true responses: "200": @@ -2246,7 +2246,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.User' + $ref: '#/components/schemas/api.v1.services.types.User' required: true responses: "200": @@ -2351,34 +2351,34 @@ components: type: object properties: department: - $ref: '#/components/schemas/api.v1.services.system.Department' + $ref: '#/components/schemas/api.v1.services.types.Department' api.v1.services.system.CreateMenuResponse: type: object properties: menu: - $ref: '#/components/schemas/api.v1.services.system.Menu' + $ref: '#/components/schemas/api.v1.services.types.Menu' description: CreateMenuResponse is the response for the MenuService.CreateMenu method. api.v1.services.system.CreatePermissionResponse: type: object properties: permission: - $ref: '#/components/schemas/api.v1.services.system.Permission' + $ref: '#/components/schemas/api.v1.services.types.Permission' api.v1.services.system.CreatePositionResponse: type: object properties: position: - $ref: '#/components/schemas/api.v1.services.system.Position' + $ref: '#/components/schemas/api.v1.services.types.Position' api.v1.services.system.CreateResourceResponse: type: object properties: resource: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' description: CreateResourceResponse is the response for the ResourceService.CreateResource method. api.v1.services.system.CreateRoleResponse: type: object properties: role: - $ref: '#/components/schemas/api.v1.services.system.Role' + $ref: '#/components/schemas/api.v1.services.types.Role' api.v1.services.system.CreateTokenRequest_Data: type: object properties: @@ -2398,7 +2398,7 @@ components: type: object properties: user: - $ref: '#/components/schemas/api.v1.services.system.User' + $ref: '#/components/schemas/api.v1.services.types.User' api.v1.services.system.DeleteDepartmentResponse: type: object properties: {} @@ -2422,59 +2422,6 @@ components: api.v1.services.system.DeleteUserResponse: type: object properties: {} - api.v1.services.system.Department: - type: object - properties: - id: - type: string - description: |- - ID of the ent. - field.primary_key.comment - create_time: - type: string - description: create_time.field.comment - format: date-time - update_time: - type: string - description: update_time.field.comment - format: date-time - keyword: - type: string - description: department.field.keyword - name: - type: string - description: department.field.name - tree_path: - type: string - description: menu.field.tree_path - sequence: - type: integer - description: department.field.sequence - format: int32 - status: - type: integer - description: department.field.status - format: int32 - level: - type: integer - description: department.field.level - format: int32 - description: - type: string - description: department.field.description - parent_id: - type: string - description: department.field.parent_id - children: - type: array - items: - $ref: '#/components/schemas/api.v1.services.system.Department' - description: Children holds the value of the children edge. - parent: - allOf: - - $ref: '#/components/schemas/api.v1.services.system.Department' - description: Parent holds the value of the parent edge. - description: department.table.comment api.v1.services.system.DestroyTokenRequest_Data: type: object properties: @@ -2488,48 +2435,48 @@ components: type: object properties: department: - $ref: '#/components/schemas/api.v1.services.system.Department' + $ref: '#/components/schemas/api.v1.services.types.Department' api.v1.services.system.GetMenuResponse: type: object properties: menu: allOf: - - $ref: '#/components/schemas/api.v1.services.system.Menu' + - $ref: '#/components/schemas/api.v1.services.types.Menu' description: The field id should match the Noun in the method id. description: GetMenuResponse is the response for the MenuService.GetMenu method. api.v1.services.system.GetPermissionResponse: type: object properties: permission: - $ref: '#/components/schemas/api.v1.services.system.Permission' + $ref: '#/components/schemas/api.v1.services.types.Permission' api.v1.services.system.GetPersonalProfileResponse: type: object properties: user: - $ref: '#/components/schemas/api.v1.services.system.User' + $ref: '#/components/schemas/api.v1.services.types.User' api.v1.services.system.GetPositionResponse: type: object properties: position: - $ref: '#/components/schemas/api.v1.services.system.Position' + $ref: '#/components/schemas/api.v1.services.types.Position' api.v1.services.system.GetResourceResponse: type: object properties: resource: allOf: - - $ref: '#/components/schemas/api.v1.services.system.Resource' + - $ref: '#/components/schemas/api.v1.services.types.Resource' description: The field id should match the Noun in the method id. description: GetResourceResponse is the response for the ResourceService.GetResource method. api.v1.services.system.GetRoleResponse: type: object properties: role: - $ref: '#/components/schemas/api.v1.services.system.Role' + $ref: '#/components/schemas/api.v1.services.types.Role' api.v1.services.system.GetUserResponse: type: object properties: user: - $ref: '#/components/schemas/api.v1.services.system.User' + $ref: '#/components/schemas/api.v1.services.types.User' api.v1.services.system.GroupingRule: type: object properties: @@ -2545,7 +2492,7 @@ components: resources: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' description: The list of Auths. total_size: type: integer @@ -2561,7 +2508,7 @@ components: departments: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Department' + $ref: '#/components/schemas/api.v1.services.types.Department' description: The paging menus current: type: integer @@ -2599,7 +2546,7 @@ components: menus: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Menu' + $ref: '#/components/schemas/api.v1.services.types.Menu' description: The paging menus current: type: integer @@ -2631,7 +2578,7 @@ components: permissions: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Permission' + $ref: '#/components/schemas/api.v1.services.types.Permission' description: The paging menus current: type: integer @@ -2661,7 +2608,7 @@ components: resources: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' description: list of resources next_page_token: type: string @@ -2672,7 +2619,7 @@ components: roles: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Role' + $ref: '#/components/schemas/api.v1.services.types.Role' api.v1.services.system.ListPoliciesResponse: type: object properties: @@ -2690,7 +2637,7 @@ components: positions: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Position' + $ref: '#/components/schemas/api.v1.services.types.Position' description: The paging menus current: type: integer @@ -2721,7 +2668,7 @@ components: resources: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' description: The paging resources current: type: integer @@ -2753,7 +2700,7 @@ components: roles: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Role' + $ref: '#/components/schemas/api.v1.services.types.Role' description: The paging menus current: type: integer @@ -2783,7 +2730,7 @@ components: resources: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' api.v1.services.system.ListUsersResponse: type: object properties: @@ -2794,7 +2741,7 @@ components: users: type: array items: - $ref: '#/components/schemas/api.v1.services.system.User' + $ref: '#/components/schemas/api.v1.services.types.User' description: The paging menus current: type: integer @@ -2836,7 +2783,191 @@ components: properties: success: type: boolean - api.v1.services.system.Menu: + api.v1.services.system.PersonalLogoutResponse: + type: object + properties: + success: + type: boolean + api.v1.services.system.PolicyRule: + type: object + properties: + p_type: + type: string + params: + type: array + items: + type: string + api.v1.services.system.RefreshPersonalTokenResponse: + type: object + properties: + token: + type: string + api.v1.services.system.RegisterRequest_Data: + type: object + properties: + username: + type: string + password: + type: string + captcha_id: + type: string + captcha_code: + type: string + api.v1.services.system.RegisterResponse: + type: object + properties: + success: + type: boolean + data: + $ref: '#/components/schemas/api.v1.services.system.RegisterResponse_Data' + api.v1.services.system.RegisterResponse_Data: + type: object + properties: + redirect: + type: string + api.v1.services.system.ResetUserPasswordResponse: + type: object + properties: {} + api.v1.services.system.StreamRulesResponse: + type: object + properties: + policy: + $ref: '#/components/schemas/api.v1.services.system.PolicyRule' + grouping: + $ref: '#/components/schemas/api.v1.services.system.GroupingRule' + api.v1.services.system.TokenRefreshRequest_Data: + type: object + properties: + refresh_token: + type: string + api.v1.services.system.TokenRefreshResponse: + type: object + properties: + token: + $ref: '#/components/schemas/security.jwt.v1.Token' + api.v1.services.system.UpdateDepartmentResponse: + type: object + properties: + department: + $ref: '#/components/schemas/api.v1.services.types.Department' + api.v1.services.system.UpdateMenuResponse: + type: object + properties: + menu: + $ref: '#/components/schemas/api.v1.services.types.Menu' + description: UpdateMenuResponse is the response for the MenuService.UpdateMenu method. + api.v1.services.system.UpdatePermissionResponse: + type: object + properties: + permission: + $ref: '#/components/schemas/api.v1.services.types.Permission' + api.v1.services.system.UpdatePersonalPasswordResponse: + type: object + properties: {} + api.v1.services.system.UpdatePersonalProfileResponse: + type: object + properties: {} + api.v1.services.system.UpdatePersonalSettingResponse: + type: object + properties: {} + api.v1.services.system.UpdatePositionResponse: + type: object + properties: + position: + $ref: '#/components/schemas/api.v1.services.types.Position' + api.v1.services.system.UpdateResourceResponse: + type: object + properties: + resource: + $ref: '#/components/schemas/api.v1.services.types.Resource' + description: UpdateResourceResponse is the response for the ResourceService.UpdateResource method. + api.v1.services.system.UpdateRoleResponse: + type: object + properties: + role: + $ref: '#/components/schemas/api.v1.services.types.Role' + api.v1.services.system.UpdateUserResponse: + type: object + properties: + user: + $ref: '#/components/schemas/api.v1.services.types.User' + api.v1.services.system.UpdateUserRolesResponse: + type: object + properties: + user: + $ref: '#/components/schemas/api.v1.services.types.User' + api.v1.services.system.UpdateUserStatusResponse: + type: object + properties: {} + api.v1.services.system.ValidateTokenResponse: + type: object + properties: + is_valid: + type: boolean + claims: + type: object + additionalProperties: + type: string + description: VerifyTokenResponse contains the result of the verification. + api.v1.services.system.WatchUpdateResponse: + type: object + properties: + modified_date: + type: string + api.v1.services.types.Department: + type: object + properties: + id: + type: string + description: |- + ID of the ent. + field.primary_key.comment + create_time: + type: string + description: create_time.field.comment + format: date-time + update_time: + type: string + description: update_time.field.comment + format: date-time + keyword: + type: string + description: department.field.keyword + name: + type: string + description: department.field.name + tree_path: + type: string + description: menu.field.tree_path + sequence: + type: integer + description: department.field.sequence + format: int32 + status: + type: integer + description: department.field.status + format: int32 + level: + type: integer + description: department.field.level + format: int32 + description: + type: string + description: department.field.description + parent_id: + type: string + description: department.field.parent_id + children: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.Department' + description: Children holds the value of the children edge. + parent: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.Department' + description: Parent holds the value of the parent edge. + description: department.table.comment + api.v1.services.types.Menu: type: object properties: id: @@ -2891,24 +3022,24 @@ components: children: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Menu' + $ref: '#/components/schemas/api.v1.services.types.Menu' description: Children holds the value of the children edge. parent: allOf: - - $ref: '#/components/schemas/api.v1.services.system.Menu' + - $ref: '#/components/schemas/api.v1.services.types.Menu' description: Parent holds the value of the parent edge. resources: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' description: Resources holds the value of the resources edge. roles: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Role' + $ref: '#/components/schemas/api.v1.services.types.Role' description: Roles holds the value of the roles edge. description: Menu is the model entity for the Menu schema. - api.v1.services.system.Permission: + api.v1.services.types.Permission: type: object properties: id: @@ -2949,24 +3080,10 @@ components: resources: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' description: permission.field.resources description: permission.table.comment - api.v1.services.system.PersonalLogoutResponse: - type: object - properties: - success: - type: boolean - api.v1.services.system.PolicyRule: - type: object - properties: - p_type: - type: string - params: - type: array - items: - type: string - api.v1.services.system.Position: + api.v1.services.types.Position: type: object properties: id: @@ -2995,38 +3112,7 @@ components: type: string description: department.field.department_id description: position.table.comment - api.v1.services.system.RefreshPersonalTokenResponse: - type: object - properties: - token: - type: string - api.v1.services.system.RegisterRequest_Data: - type: object - properties: - username: - type: string - password: - type: string - captcha_id: - type: string - captcha_code: - type: string - api.v1.services.system.RegisterResponse: - type: object - properties: - success: - type: boolean - data: - $ref: '#/components/schemas/api.v1.services.system.RegisterResponse_Data' - api.v1.services.system.RegisterResponse_Data: - type: object - properties: - redirect: - type: string - api.v1.services.system.ResetUserPasswordResponse: - type: object - properties: {} - api.v1.services.system.Resource: + api.v1.services.types.Resource: type: object properties: id: @@ -3097,11 +3183,11 @@ components: children: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' description: Children holds the value of the children edge. parent: allOf: - - $ref: '#/components/schemas/api.v1.services.system.Resource' + - $ref: '#/components/schemas/api.v1.services.types.Resource' description: Parent holds the value of the parent edge. permission_ids: type: array @@ -3111,10 +3197,10 @@ components: permissions: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Permission' + $ref: '#/components/schemas/api.v1.services.types.Permission' description: Permissions holds the value of the permissions edge. description: Resource is the model entity for the Resource schema. - api.v1.services.system.Role: + api.v1.services.types.Role: type: object properties: id: @@ -3151,23 +3237,23 @@ components: type: integer description: role.field.status format: int32 - is_system: + is_types: type: boolean - description: role.field.is_system + description: role.field.is_types menus: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Menu' + $ref: '#/components/schemas/api.v1.services.types.Menu' description: Menus holds the value of the menus edge. users: type: array items: - $ref: '#/components/schemas/api.v1.services.system.User' + $ref: '#/components/schemas/api.v1.services.types.User' description: Users holds the value of the users edge. resources: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Resource' + $ref: '#/components/schemas/api.v1.services.types.Resource' description: Resources holds the value of the resources edge. resource_ids: type: array @@ -3177,7 +3263,7 @@ components: permissions: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Permission' + $ref: '#/components/schemas/api.v1.services.types.Permission' description: Permissions holds the value of the permissions edge. permission_ids: type: array @@ -3185,78 +3271,7 @@ components: type: string description: Permission Ids holds the value of the permission_ids edge. description: Role is the model entity for the Role schema. - api.v1.services.system.StreamRulesResponse: - type: object - properties: - policy: - $ref: '#/components/schemas/api.v1.services.system.PolicyRule' - grouping: - $ref: '#/components/schemas/api.v1.services.system.GroupingRule' - api.v1.services.system.TokenRefreshRequest_Data: - type: object - properties: - refresh_token: - type: string - api.v1.services.system.TokenRefreshResponse: - type: object - properties: - token: - $ref: '#/components/schemas/security.jwt.v1.Token' - api.v1.services.system.UpdateDepartmentResponse: - type: object - properties: - department: - $ref: '#/components/schemas/api.v1.services.system.Department' - api.v1.services.system.UpdateMenuResponse: - type: object - properties: - menu: - $ref: '#/components/schemas/api.v1.services.system.Menu' - description: UpdateMenuResponse is the response for the MenuService.UpdateMenu method. - api.v1.services.system.UpdatePermissionResponse: - type: object - properties: - permission: - $ref: '#/components/schemas/api.v1.services.system.Permission' - api.v1.services.system.UpdatePersonalPasswordResponse: - type: object - properties: {} - api.v1.services.system.UpdatePersonalProfileResponse: - type: object - properties: {} - api.v1.services.system.UpdatePersonalSettingResponse: - type: object - properties: {} - api.v1.services.system.UpdatePositionResponse: - type: object - properties: - position: - $ref: '#/components/schemas/api.v1.services.system.Position' - api.v1.services.system.UpdateResourceResponse: - type: object - properties: - resource: - $ref: '#/components/schemas/api.v1.services.system.Resource' - description: UpdateResourceResponse is the response for the ResourceService.UpdateResource method. - api.v1.services.system.UpdateRoleResponse: - type: object - properties: - role: - $ref: '#/components/schemas/api.v1.services.system.Role' - api.v1.services.system.UpdateUserResponse: - type: object - properties: - user: - $ref: '#/components/schemas/api.v1.services.system.User' - api.v1.services.system.UpdateUserRolesResponse: - type: object - properties: - user: - $ref: '#/components/schemas/api.v1.services.system.User' - api.v1.services.system.UpdateUserStatusResponse: - type: object - properties: {} - api.v1.services.system.User: + api.v1.services.types.User: type: object properties: id: @@ -3348,7 +3363,7 @@ components: roles: type: array items: - $ref: '#/components/schemas/api.v1.services.system.Role' + $ref: '#/components/schemas/api.v1.services.types.Role' description: Roles holds the value of the roles edge. role_ids: type: array @@ -3356,21 +3371,6 @@ components: type: string description: Role Ids holds the value of the role_ids description: User is the model entity for the User schema. - api.v1.services.system.ValidateTokenResponse: - type: object - properties: - is_valid: - type: boolean - claims: - type: object - additionalProperties: - type: string - description: VerifyTokenResponse contains the result of the verification. - api.v1.services.system.WatchUpdateResponse: - type: object - properties: - modified_date: - type: string google.protobuf.Any: type: object properties: From bfaa5bad507b82025943da603280319015e0d809 Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 30 May 2025 15:48:31 +0800 Subject: [PATCH 028/158] refactor(api): rename auth-related proto files and update package structure - Move auth.proto and casbin.proto from system directory to auth directory - Update package name from api.v1.services.system to api.v1.services.auth - Adjust go_package, java_outer_classname, java_package, and objc_class_prefix options --- api/v1/proto/{system => auth}/auth.proto | 10 +- api/v1/proto/{system => auth}/casbin.proto | 10 +- api/v1/services/{system => auth}/auth.pb.go | 268 +++++++++--------- .../services/{system => auth}/auth.pb.gw.go | 30 +- .../{system => auth}/auth.pb.validate.go | 4 +- .../{system => auth}/auth_bridge.pb.go | 16 +- .../services/{system => auth}/auth_grpc.pb.go | 20 +- .../services/{system => auth}/auth_http.pb.go | 16 +- api/v1/services/{system => auth}/casbin.pb.go | 194 ++++++------- .../services/{system => auth}/casbin.pb.gw.go | 20 +- .../{system => auth}/casbin.pb.validate.go | 4 +- .../{system => auth}/casbin_bridge.pb.go | 10 +- .../{system => auth}/casbin_grpc.pb.go | 16 +- .../{system => auth}/casbin_http.pb.go | 10 +- resources/docs/openapi/openapi.yaml | 216 +++++++------- 15 files changed, 422 insertions(+), 422 deletions(-) rename api/v1/proto/{system => auth}/auth.proto (93%) rename api/v1/proto/{system => auth}/casbin.proto (88%) rename api/v1/services/{system => auth}/auth.pb.go (69%) rename api/v1/services/{system => auth}/auth.pb.gw.go (94%) rename api/v1/services/{system => auth}/auth.pb.validate.go (99%) rename api/v1/services/{system => auth}/auth_bridge.pb.go (97%) rename api/v1/services/{system => auth}/auth_grpc.pb.go (97%) rename api/v1/services/{system => auth}/auth_http.pb.go (94%) rename api/v1/services/{system => auth}/casbin.pb.go (66%) rename api/v1/services/{system => auth}/casbin.pb.gw.go (94%) rename api/v1/services/{system => auth}/casbin.pb.validate.go (99%) rename api/v1/services/{system => auth}/casbin_bridge.pb.go (97%) rename api/v1/services/{system => auth}/casbin_grpc.pb.go (96%) rename api/v1/services/{system => auth}/casbin_http.pb.go (96%) diff --git a/api/v1/proto/system/auth.proto b/api/v1/proto/auth/auth.proto similarity index 93% rename from api/v1/proto/system/auth.proto rename to api/v1/proto/auth/auth.proto index b96b1f48..2b4dd6e4 100644 --- a/api/v1/proto/system/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -1,16 +1,16 @@ syntax = "proto3"; -package api.v1.services.system; +package api.v1.services.auth; import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "v1/services/system;system"; +option go_package = "v1/services/auth;auth"; option java_multiple_files = true; -option java_outer_classname = "APIServiceSystemAuthProto"; -option java_package = "com.origadmin.api.v1.services.system"; -option objc_class_prefix = "APIServiceSystemAuth"; +option java_outer_classname = "APIServiceAuthAuthProto"; +option java_package = "com.origadmin.api.v1.services.auth"; +option objc_class_prefix = "APIServiceAuthAuth"; service AuthService { rpc ListAuthResources(ListAuthResourcesRequest) returns (ListAuthResourcesResponse) { diff --git a/api/v1/proto/system/casbin.proto b/api/v1/proto/auth/casbin.proto similarity index 88% rename from api/v1/proto/system/casbin.proto rename to api/v1/proto/auth/casbin.proto index 6d3c16d4..88d17154 100644 --- a/api/v1/proto/system/casbin.proto +++ b/api/v1/proto/auth/casbin.proto @@ -1,17 +1,17 @@ syntax = "proto3"; -package api.v1.services.system; +package api.v1.services.auth; import "google/api/annotations.proto"; //import "google/protobuf/any.proto"; //import "google/protobuf/empty.proto"; //import "types/system.proto"; -option go_package = "v1/services/system;system"; +option go_package = "v1/services/auth;auth"; option java_multiple_files = true; -option java_outer_classname = "APIServiceSystemCasbinProto"; -option java_package = "com.origadmin.api.v1.services.system"; -option objc_class_prefix = "APIServiceSystemCasbin"; +option java_outer_classname = "APIServiceAuthCasbinProto"; +option java_package = "com.origadmin.api.v1.services.auth"; +option objc_class_prefix = "APIServiceAuthCasbin"; // The Casbin source service definition. service CasbinSourceService { diff --git a/api/v1/services/system/auth.pb.go b/api/v1/services/auth/auth.pb.go similarity index 69% rename from api/v1/services/system/auth.pb.go rename to api/v1/services/auth/auth.pb.go index d4876653..6b1ba855 100644 --- a/api/v1/services/system/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.36.6 // protoc (unknown) -// source: system/auth.proto +// source: auth/auth.proto -package system +package auth import ( _ "google.golang.org/genproto/googleapis/api/annotations" @@ -33,7 +33,7 @@ type AuthLogoutRequest struct { func (x *AuthLogoutRequest) Reset() { *x = AuthLogoutRequest{} - mi := &file_system_auth_proto_msgTypes[0] + mi := &file_auth_auth_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -45,7 +45,7 @@ func (x *AuthLogoutRequest) String() string { func (*AuthLogoutRequest) ProtoMessage() {} func (x *AuthLogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[0] + mi := &file_auth_auth_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -58,7 +58,7 @@ func (x *AuthLogoutRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthLogoutRequest.ProtoReflect.Descriptor instead. func (*AuthLogoutRequest) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{0} + return file_auth_auth_proto_rawDescGZIP(), []int{0} } func (x *AuthLogoutRequest) GetData() *AuthLogoutRequest_Data { @@ -77,7 +77,7 @@ type AuthLogoutResponse struct { func (x *AuthLogoutResponse) Reset() { *x = AuthLogoutResponse{} - mi := &file_system_auth_proto_msgTypes[1] + mi := &file_auth_auth_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -89,7 +89,7 @@ func (x *AuthLogoutResponse) String() string { func (*AuthLogoutResponse) ProtoMessage() {} func (x *AuthLogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[1] + mi := &file_auth_auth_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -102,7 +102,7 @@ func (x *AuthLogoutResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthLogoutResponse.ProtoReflect.Descriptor instead. func (*AuthLogoutResponse) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{1} + return file_auth_auth_proto_rawDescGZIP(), []int{1} } func (x *AuthLogoutResponse) GetEmpty() *emptypb.Empty { @@ -128,7 +128,7 @@ type ListAuthResourcesRequest struct { func (x *ListAuthResourcesRequest) Reset() { *x = ListAuthResourcesRequest{} - mi := &file_system_auth_proto_msgTypes[2] + mi := &file_auth_auth_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -140,7 +140,7 @@ func (x *ListAuthResourcesRequest) String() string { func (*ListAuthResourcesRequest) ProtoMessage() {} func (x *ListAuthResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[2] + mi := &file_auth_auth_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -153,7 +153,7 @@ func (x *ListAuthResourcesRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListAuthResourcesRequest.ProtoReflect.Descriptor instead. func (*ListAuthResourcesRequest) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{2} + return file_auth_auth_proto_rawDescGZIP(), []int{2} } func (x *ListAuthResourcesRequest) GetPageSize() int32 { @@ -196,7 +196,7 @@ type ListAuthResourcesResponse struct { func (x *ListAuthResourcesResponse) Reset() { *x = ListAuthResourcesResponse{} - mi := &file_system_auth_proto_msgTypes[3] + mi := &file_auth_auth_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -208,7 +208,7 @@ func (x *ListAuthResourcesResponse) String() string { func (*ListAuthResourcesResponse) ProtoMessage() {} func (x *ListAuthResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[3] + mi := &file_auth_auth_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -221,7 +221,7 @@ func (x *ListAuthResourcesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListAuthResourcesResponse.ProtoReflect.Descriptor instead. func (*ListAuthResourcesResponse) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{3} + return file_auth_auth_proto_rawDescGZIP(), []int{3} } func (x *ListAuthResourcesResponse) GetResources() []*types.Resource { @@ -248,7 +248,7 @@ type CreateTokenRequest struct { func (x *CreateTokenRequest) Reset() { *x = CreateTokenRequest{} - mi := &file_system_auth_proto_msgTypes[4] + mi := &file_auth_auth_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -260,7 +260,7 @@ func (x *CreateTokenRequest) String() string { func (*CreateTokenRequest) ProtoMessage() {} func (x *CreateTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[4] + mi := &file_auth_auth_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -273,7 +273,7 @@ func (x *CreateTokenRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateTokenRequest.ProtoReflect.Descriptor instead. func (*CreateTokenRequest) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{4} + return file_auth_auth_proto_rawDescGZIP(), []int{4} } func (x *CreateTokenRequest) GetData() *CreateTokenRequest_Data { @@ -293,7 +293,7 @@ type CreateTokenResponse struct { func (x *CreateTokenResponse) Reset() { *x = CreateTokenResponse{} - mi := &file_system_auth_proto_msgTypes[5] + mi := &file_auth_auth_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -305,7 +305,7 @@ func (x *CreateTokenResponse) String() string { func (*CreateTokenResponse) ProtoMessage() {} func (x *CreateTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[5] + mi := &file_auth_auth_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -318,7 +318,7 @@ func (x *CreateTokenResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateTokenResponse.ProtoReflect.Descriptor instead. func (*CreateTokenResponse) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{5} + return file_auth_auth_proto_rawDescGZIP(), []int{5} } func (x *CreateTokenResponse) GetToken() string { @@ -338,7 +338,7 @@ type ValidateTokenRequest struct { func (x *ValidateTokenRequest) Reset() { *x = ValidateTokenRequest{} - mi := &file_system_auth_proto_msgTypes[6] + mi := &file_auth_auth_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -350,7 +350,7 @@ func (x *ValidateTokenRequest) String() string { func (*ValidateTokenRequest) ProtoMessage() {} func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[6] + mi := &file_auth_auth_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -363,7 +363,7 @@ func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ValidateTokenRequest.ProtoReflect.Descriptor instead. func (*ValidateTokenRequest) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{6} + return file_auth_auth_proto_rawDescGZIP(), []int{6} } func (x *ValidateTokenRequest) GetToken() string { @@ -384,7 +384,7 @@ type ValidateTokenResponse struct { func (x *ValidateTokenResponse) Reset() { *x = ValidateTokenResponse{} - mi := &file_system_auth_proto_msgTypes[7] + mi := &file_auth_auth_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -396,7 +396,7 @@ func (x *ValidateTokenResponse) String() string { func (*ValidateTokenResponse) ProtoMessage() {} func (x *ValidateTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[7] + mi := &file_auth_auth_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -409,7 +409,7 @@ func (x *ValidateTokenResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ValidateTokenResponse.ProtoReflect.Descriptor instead. func (*ValidateTokenResponse) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{7} + return file_auth_auth_proto_rawDescGZIP(), []int{7} } func (x *ValidateTokenResponse) GetIsValid() bool { @@ -436,7 +436,7 @@ type DestroyTokenRequest struct { func (x *DestroyTokenRequest) Reset() { *x = DestroyTokenRequest{} - mi := &file_system_auth_proto_msgTypes[8] + mi := &file_auth_auth_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -448,7 +448,7 @@ func (x *DestroyTokenRequest) String() string { func (*DestroyTokenRequest) ProtoMessage() {} func (x *DestroyTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[8] + mi := &file_auth_auth_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -461,7 +461,7 @@ func (x *DestroyTokenRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DestroyTokenRequest.ProtoReflect.Descriptor instead. func (*DestroyTokenRequest) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{8} + return file_auth_auth_proto_rawDescGZIP(), []int{8} } func (x *DestroyTokenRequest) GetData() *DestroyTokenRequest_Data { @@ -481,7 +481,7 @@ type DestroyTokenResponse struct { func (x *DestroyTokenResponse) Reset() { *x = DestroyTokenResponse{} - mi := &file_system_auth_proto_msgTypes[9] + mi := &file_auth_auth_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -493,7 +493,7 @@ func (x *DestroyTokenResponse) String() string { func (*DestroyTokenResponse) ProtoMessage() {} func (x *DestroyTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[9] + mi := &file_auth_auth_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -506,7 +506,7 @@ func (x *DestroyTokenResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DestroyTokenResponse.ProtoReflect.Descriptor instead. func (*DestroyTokenResponse) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{9} + return file_auth_auth_proto_rawDescGZIP(), []int{9} } func (x *DestroyTokenResponse) GetEmpty() *emptypb.Empty { @@ -525,7 +525,7 @@ type AuthenticateRequest struct { func (x *AuthenticateRequest) Reset() { *x = AuthenticateRequest{} - mi := &file_system_auth_proto_msgTypes[10] + mi := &file_auth_auth_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -537,7 +537,7 @@ func (x *AuthenticateRequest) String() string { func (*AuthenticateRequest) ProtoMessage() {} func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[10] + mi := &file_auth_auth_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -550,7 +550,7 @@ func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthenticateRequest.ProtoReflect.Descriptor instead. func (*AuthenticateRequest) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{10} + return file_auth_auth_proto_rawDescGZIP(), []int{10} } func (x *AuthenticateRequest) GetData() *AuthenticateRequest_Data { @@ -569,7 +569,7 @@ type AuthenticateResponse struct { func (x *AuthenticateResponse) Reset() { *x = AuthenticateResponse{} - mi := &file_system_auth_proto_msgTypes[11] + mi := &file_auth_auth_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -581,7 +581,7 @@ func (x *AuthenticateResponse) String() string { func (*AuthenticateResponse) ProtoMessage() {} func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[11] + mi := &file_auth_auth_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -594,7 +594,7 @@ func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthenticateResponse.ProtoReflect.Descriptor instead. func (*AuthenticateResponse) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{11} + return file_auth_auth_proto_rawDescGZIP(), []int{11} } func (x *AuthenticateResponse) GetIsValid() bool { @@ -613,7 +613,7 @@ type AuthLogoutRequest_Data struct { func (x *AuthLogoutRequest_Data) Reset() { *x = AuthLogoutRequest_Data{} - mi := &file_system_auth_proto_msgTypes[12] + mi := &file_auth_auth_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -625,7 +625,7 @@ func (x *AuthLogoutRequest_Data) String() string { func (*AuthLogoutRequest_Data) ProtoMessage() {} func (x *AuthLogoutRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[12] + mi := &file_auth_auth_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -638,7 +638,7 @@ func (x *AuthLogoutRequest_Data) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthLogoutRequest_Data.ProtoReflect.Descriptor instead. func (*AuthLogoutRequest_Data) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{0, 0} + return file_auth_auth_proto_rawDescGZIP(), []int{0, 0} } func (x *AuthLogoutRequest_Data) GetToken() string { @@ -658,7 +658,7 @@ type CreateTokenRequest_Data struct { func (x *CreateTokenRequest_Data) Reset() { *x = CreateTokenRequest_Data{} - mi := &file_system_auth_proto_msgTypes[13] + mi := &file_auth_auth_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -670,7 +670,7 @@ func (x *CreateTokenRequest_Data) String() string { func (*CreateTokenRequest_Data) ProtoMessage() {} func (x *CreateTokenRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[13] + mi := &file_auth_auth_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -683,7 +683,7 @@ func (x *CreateTokenRequest_Data) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateTokenRequest_Data.ProtoReflect.Descriptor instead. func (*CreateTokenRequest_Data) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{4, 0} + return file_auth_auth_proto_rawDescGZIP(), []int{4, 0} } func (x *CreateTokenRequest_Data) GetUserId() string { @@ -709,7 +709,7 @@ type DestroyTokenRequest_Data struct { func (x *DestroyTokenRequest_Data) Reset() { *x = DestroyTokenRequest_Data{} - mi := &file_system_auth_proto_msgTypes[15] + mi := &file_auth_auth_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -721,7 +721,7 @@ func (x *DestroyTokenRequest_Data) String() string { func (*DestroyTokenRequest_Data) ProtoMessage() {} func (x *DestroyTokenRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[15] + mi := &file_auth_auth_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -734,7 +734,7 @@ func (x *DestroyTokenRequest_Data) ProtoReflect() protoreflect.Message { // Deprecated: Use DestroyTokenRequest_Data.ProtoReflect.Descriptor instead. func (*DestroyTokenRequest_Data) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{8, 0} + return file_auth_auth_proto_rawDescGZIP(), []int{8, 0} } func (x *DestroyTokenRequest_Data) GetToken() string { @@ -756,7 +756,7 @@ type AuthenticateRequest_Data struct { func (x *AuthenticateRequest_Data) Reset() { *x = AuthenticateRequest_Data{} - mi := &file_system_auth_proto_msgTypes[16] + mi := &file_auth_auth_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -768,7 +768,7 @@ func (x *AuthenticateRequest_Data) String() string { func (*AuthenticateRequest_Data) ProtoMessage() {} func (x *AuthenticateRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_system_auth_proto_msgTypes[16] + mi := &file_auth_auth_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -781,7 +781,7 @@ func (x *AuthenticateRequest_Data) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthenticateRequest_Data.ProtoReflect.Descriptor instead. func (*AuthenticateRequest_Data) Descriptor() ([]byte, []int) { - return file_system_auth_proto_rawDescGZIP(), []int{10, 0} + return file_auth_auth_proto_rawDescGZIP(), []int{10, 0} } func (x *AuthenticateRequest_Data) GetToken() string { @@ -812,13 +812,13 @@ func (x *AuthenticateRequest_Data) GetOperation() string { return "" } -var File_system_auth_proto protoreflect.FileDescriptor +var File_auth_auth_proto protoreflect.FileDescriptor -const file_system_auth_proto_rawDesc = "" + +const file_auth_auth_proto_rawDesc = "" + "\n" + - "\x11system/auth.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"u\n" + - "\x11AuthLogoutRequest\x12B\n" + - "\x04data\x18\x01 \x01(\v2..api.v1.services.system.AuthLogoutRequest.DataR\x04data\x1a\x1c\n" + + "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"s\n" + + "\x11AuthLogoutRequest\x12@\n" + + "\x04data\x18\x01 \x01(\v2,.api.v1.services.auth.AuthLogoutRequest.DataR\x04data\x1a\x1c\n" + "\x04Data\x12\x14\n" + "\x05token\x18\x01 \x01(\tR\x05token\"B\n" + "\x12AuthLogoutResponse\x12,\n" + @@ -834,102 +834,102 @@ const file_system_auth_proto_rawDesc = "" + "\tresources\x18\x01 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x1e\n" + "\n" + "total_size\x18\x02 \x01(\x05R\n" + - "total_size\"\x93\x01\n" + - "\x12CreateTokenRequest\x12C\n" + - "\x04data\x18\x01 \x01(\v2/.api.v1.services.system.CreateTokenRequest.DataR\x04data\x1a8\n" + + "total_size\"\x91\x01\n" + + "\x12CreateTokenRequest\x12A\n" + + "\x04data\x18\x01 \x01(\v2-.api.v1.services.auth.CreateTokenRequest.DataR\x04data\x1a8\n" + "\x04Data\x12\x18\n" + "\auser_id\x18\x01 \x01(\tR\auser_id\x12\x16\n" + "\x06scopes\x18\x02 \x03(\tR\x06scopes\"+\n" + "\x13CreateTokenResponse\x12\x14\n" + "\x05token\x18\x01 \x01(\tR\x05token\",\n" + "\x14ValidateTokenRequest\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\"\xc1\x01\n" + + "\x05token\x18\x01 \x01(\tR\x05token\"\xbf\x01\n" + "\x15ValidateTokenResponse\x12\x1a\n" + - "\bis_valid\x18\x01 \x01(\bR\bis_valid\x12Q\n" + - "\x06claims\x18\x02 \x03(\v29.api.v1.services.system.ValidateTokenResponse.ClaimsEntryR\x06claims\x1a9\n" + + "\bis_valid\x18\x01 \x01(\bR\bis_valid\x12O\n" + + "\x06claims\x18\x02 \x03(\v27.api.v1.services.auth.ValidateTokenResponse.ClaimsEntryR\x06claims\x1a9\n" + "\vClaimsEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"y\n" + - "\x13DestroyTokenRequest\x12D\n" + - "\x04data\x18\x01 \x01(\v20.api.v1.services.system.DestroyTokenRequest.DataR\x04data\x1a\x1c\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"w\n" + + "\x13DestroyTokenRequest\x12B\n" + + "\x04data\x18\x01 \x01(\v2..api.v1.services.auth.DestroyTokenRequest.DataR\x04data\x1a\x1c\n" + "\x04Data\x12\x14\n" + "\x05token\x18\x01 \x01(\tR\x05token\"D\n" + "\x14DestroyTokenResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"\xc3\x01\n" + - "\x13AuthenticateRequest\x12D\n" + - "\x04data\x18\x01 \x01(\v20.api.v1.services.system.AuthenticateRequest.DataR\x04data\x1af\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"\xc1\x01\n" + + "\x13AuthenticateRequest\x12B\n" + + "\x04data\x18\x01 \x01(\v2..api.v1.services.auth.AuthenticateRequest.DataR\x04data\x1af\n" + "\x04Data\x12\x14\n" + "\x05token\x18\x01 \x01(\tR\x05token\x12\x12\n" + "\x04path\x18\x03 \x01(\tR\x04path\x12\x16\n" + "\x06method\x18\x04 \x01(\tR\x06method\x12\x1c\n" + "\toperation\x18\x05 \x01(\tR\toperation\"2\n" + "\x14AuthenticateResponse\x12\x1a\n" + - "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xdd\x06\n" + - "\vAuthService\x12\x95\x01\n" + - "\x11ListAuthResources\x120.api.v1.services.system.ListAuthResourcesRequest\x1a1.api.v1.services.system.ListAuthResourcesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/auth/resources\x12\x85\x01\n" + - "\vCreateToken\x12*.api.v1.services.system.CreateTokenRequest\x1a+.api.v1.services.system.CreateTokenResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x04data\"\x0f/sys/auth/token\x12\x88\x01\n" + - "\rValidateToken\x12,.api.v1.services.system.ValidateTokenRequest\x1a-.api.v1.services.system.ValidateTokenResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/sys/auth/validate\x12\x8a\x01\n" + - "\fDestroyToken\x12+.api.v1.services.system.DestroyTokenRequest\x1a,.api.v1.services.system.DestroyTokenResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x04data\"\x11/sys/auth/destroy\x12\x8f\x01\n" + - "\fAuthenticate\x12+.api.v1.services.system.AuthenticateRequest\x1a,.api.v1.services.system.AuthenticateResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\"\x16/sys/auth/authenticate\x12\x83\x01\n" + + "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xc4\x06\n" + + "\vAuthService\x12\x91\x01\n" + + "\x11ListAuthResources\x12..api.v1.services.auth.ListAuthResourcesRequest\x1a/.api.v1.services.auth.ListAuthResourcesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/auth/resources\x12\x81\x01\n" + + "\vCreateToken\x12(.api.v1.services.auth.CreateTokenRequest\x1a).api.v1.services.auth.CreateTokenResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x04data\"\x0f/sys/auth/token\x12\x84\x01\n" + + "\rValidateToken\x12*.api.v1.services.auth.ValidateTokenRequest\x1a+.api.v1.services.auth.ValidateTokenResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/sys/auth/validate\x12\x86\x01\n" + + "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x04data\"\x11/sys/auth/destroy\x12\x8b\x01\n" + + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\"\x16/sys/auth/authenticate\x12\x7f\n" + "\n" + - "AuthLogout\x12).api.v1.services.system.AuthLogoutRequest\x1a*.api.v1.services.system.AuthLogoutResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x04data\"\x10/sys/auth/logoutB\xbe\x01\n" + - "\x1acom.api.v1.services.systemB\tAuthProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x04data\"\x10/sys/auth/logoutB\xb0\x01\n" + + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z\x15v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( - file_system_auth_proto_rawDescOnce sync.Once - file_system_auth_proto_rawDescData []byte + file_auth_auth_proto_rawDescOnce sync.Once + file_auth_auth_proto_rawDescData []byte ) -func file_system_auth_proto_rawDescGZIP() []byte { - file_system_auth_proto_rawDescOnce.Do(func() { - file_system_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_auth_proto_rawDesc), len(file_system_auth_proto_rawDesc))) +func file_auth_auth_proto_rawDescGZIP() []byte { + file_auth_auth_proto_rawDescOnce.Do(func() { + file_auth_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_auth_proto_rawDesc), len(file_auth_auth_proto_rawDesc))) }) - return file_system_auth_proto_rawDescData -} - -var file_system_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 17) -var file_system_auth_proto_goTypes = []any{ - (*AuthLogoutRequest)(nil), // 0: api.v1.services.system.AuthLogoutRequest - (*AuthLogoutResponse)(nil), // 1: api.v1.services.system.AuthLogoutResponse - (*ListAuthResourcesRequest)(nil), // 2: api.v1.services.system.ListAuthResourcesRequest - (*ListAuthResourcesResponse)(nil), // 3: api.v1.services.system.ListAuthResourcesResponse - (*CreateTokenRequest)(nil), // 4: api.v1.services.system.CreateTokenRequest - (*CreateTokenResponse)(nil), // 5: api.v1.services.system.CreateTokenResponse - (*ValidateTokenRequest)(nil), // 6: api.v1.services.system.ValidateTokenRequest - (*ValidateTokenResponse)(nil), // 7: api.v1.services.system.ValidateTokenResponse - (*DestroyTokenRequest)(nil), // 8: api.v1.services.system.DestroyTokenRequest - (*DestroyTokenResponse)(nil), // 9: api.v1.services.system.DestroyTokenResponse - (*AuthenticateRequest)(nil), // 10: api.v1.services.system.AuthenticateRequest - (*AuthenticateResponse)(nil), // 11: api.v1.services.system.AuthenticateResponse - (*AuthLogoutRequest_Data)(nil), // 12: api.v1.services.system.AuthLogoutRequest.Data - (*CreateTokenRequest_Data)(nil), // 13: api.v1.services.system.CreateTokenRequest.Data - nil, // 14: api.v1.services.system.ValidateTokenResponse.ClaimsEntry - (*DestroyTokenRequest_Data)(nil), // 15: api.v1.services.system.DestroyTokenRequest.Data - (*AuthenticateRequest_Data)(nil), // 16: api.v1.services.system.AuthenticateRequest.Data + return file_auth_auth_proto_rawDescData +} + +var file_auth_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_auth_auth_proto_goTypes = []any{ + (*AuthLogoutRequest)(nil), // 0: api.v1.services.auth.AuthLogoutRequest + (*AuthLogoutResponse)(nil), // 1: api.v1.services.auth.AuthLogoutResponse + (*ListAuthResourcesRequest)(nil), // 2: api.v1.services.auth.ListAuthResourcesRequest + (*ListAuthResourcesResponse)(nil), // 3: api.v1.services.auth.ListAuthResourcesResponse + (*CreateTokenRequest)(nil), // 4: api.v1.services.auth.CreateTokenRequest + (*CreateTokenResponse)(nil), // 5: api.v1.services.auth.CreateTokenResponse + (*ValidateTokenRequest)(nil), // 6: api.v1.services.auth.ValidateTokenRequest + (*ValidateTokenResponse)(nil), // 7: api.v1.services.auth.ValidateTokenResponse + (*DestroyTokenRequest)(nil), // 8: api.v1.services.auth.DestroyTokenRequest + (*DestroyTokenResponse)(nil), // 9: api.v1.services.auth.DestroyTokenResponse + (*AuthenticateRequest)(nil), // 10: api.v1.services.auth.AuthenticateRequest + (*AuthenticateResponse)(nil), // 11: api.v1.services.auth.AuthenticateResponse + (*AuthLogoutRequest_Data)(nil), // 12: api.v1.services.auth.AuthLogoutRequest.Data + (*CreateTokenRequest_Data)(nil), // 13: api.v1.services.auth.CreateTokenRequest.Data + nil, // 14: api.v1.services.auth.ValidateTokenResponse.ClaimsEntry + (*DestroyTokenRequest_Data)(nil), // 15: api.v1.services.auth.DestroyTokenRequest.Data + (*AuthenticateRequest_Data)(nil), // 16: api.v1.services.auth.AuthenticateRequest.Data (*emptypb.Empty)(nil), // 17: google.protobuf.Empty (*types.Resource)(nil), // 18: api.v1.services.types.Resource } -var file_system_auth_proto_depIdxs = []int32{ - 12, // 0: api.v1.services.system.AuthLogoutRequest.data:type_name -> api.v1.services.system.AuthLogoutRequest.Data - 17, // 1: api.v1.services.system.AuthLogoutResponse.empty:type_name -> google.protobuf.Empty - 18, // 2: api.v1.services.system.ListAuthResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 13, // 3: api.v1.services.system.CreateTokenRequest.data:type_name -> api.v1.services.system.CreateTokenRequest.Data - 14, // 4: api.v1.services.system.ValidateTokenResponse.claims:type_name -> api.v1.services.system.ValidateTokenResponse.ClaimsEntry - 15, // 5: api.v1.services.system.DestroyTokenRequest.data:type_name -> api.v1.services.system.DestroyTokenRequest.Data - 17, // 6: api.v1.services.system.DestroyTokenResponse.empty:type_name -> google.protobuf.Empty - 16, // 7: api.v1.services.system.AuthenticateRequest.data:type_name -> api.v1.services.system.AuthenticateRequest.Data - 2, // 8: api.v1.services.system.AuthService.ListAuthResources:input_type -> api.v1.services.system.ListAuthResourcesRequest - 4, // 9: api.v1.services.system.AuthService.CreateToken:input_type -> api.v1.services.system.CreateTokenRequest - 6, // 10: api.v1.services.system.AuthService.ValidateToken:input_type -> api.v1.services.system.ValidateTokenRequest - 8, // 11: api.v1.services.system.AuthService.DestroyToken:input_type -> api.v1.services.system.DestroyTokenRequest - 10, // 12: api.v1.services.system.AuthService.Authenticate:input_type -> api.v1.services.system.AuthenticateRequest - 0, // 13: api.v1.services.system.AuthService.AuthLogout:input_type -> api.v1.services.system.AuthLogoutRequest - 3, // 14: api.v1.services.system.AuthService.ListAuthResources:output_type -> api.v1.services.system.ListAuthResourcesResponse - 5, // 15: api.v1.services.system.AuthService.CreateToken:output_type -> api.v1.services.system.CreateTokenResponse - 7, // 16: api.v1.services.system.AuthService.ValidateToken:output_type -> api.v1.services.system.ValidateTokenResponse - 9, // 17: api.v1.services.system.AuthService.DestroyToken:output_type -> api.v1.services.system.DestroyTokenResponse - 11, // 18: api.v1.services.system.AuthService.Authenticate:output_type -> api.v1.services.system.AuthenticateResponse - 1, // 19: api.v1.services.system.AuthService.AuthLogout:output_type -> api.v1.services.system.AuthLogoutResponse +var file_auth_auth_proto_depIdxs = []int32{ + 12, // 0: api.v1.services.auth.AuthLogoutRequest.data:type_name -> api.v1.services.auth.AuthLogoutRequest.Data + 17, // 1: api.v1.services.auth.AuthLogoutResponse.empty:type_name -> google.protobuf.Empty + 18, // 2: api.v1.services.auth.ListAuthResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 13, // 3: api.v1.services.auth.CreateTokenRequest.data:type_name -> api.v1.services.auth.CreateTokenRequest.Data + 14, // 4: api.v1.services.auth.ValidateTokenResponse.claims:type_name -> api.v1.services.auth.ValidateTokenResponse.ClaimsEntry + 15, // 5: api.v1.services.auth.DestroyTokenRequest.data:type_name -> api.v1.services.auth.DestroyTokenRequest.Data + 17, // 6: api.v1.services.auth.DestroyTokenResponse.empty:type_name -> google.protobuf.Empty + 16, // 7: api.v1.services.auth.AuthenticateRequest.data:type_name -> api.v1.services.auth.AuthenticateRequest.Data + 2, // 8: api.v1.services.auth.AuthService.ListAuthResources:input_type -> api.v1.services.auth.ListAuthResourcesRequest + 4, // 9: api.v1.services.auth.AuthService.CreateToken:input_type -> api.v1.services.auth.CreateTokenRequest + 6, // 10: api.v1.services.auth.AuthService.ValidateToken:input_type -> api.v1.services.auth.ValidateTokenRequest + 8, // 11: api.v1.services.auth.AuthService.DestroyToken:input_type -> api.v1.services.auth.DestroyTokenRequest + 10, // 12: api.v1.services.auth.AuthService.Authenticate:input_type -> api.v1.services.auth.AuthenticateRequest + 0, // 13: api.v1.services.auth.AuthService.AuthLogout:input_type -> api.v1.services.auth.AuthLogoutRequest + 3, // 14: api.v1.services.auth.AuthService.ListAuthResources:output_type -> api.v1.services.auth.ListAuthResourcesResponse + 5, // 15: api.v1.services.auth.AuthService.CreateToken:output_type -> api.v1.services.auth.CreateTokenResponse + 7, // 16: api.v1.services.auth.AuthService.ValidateToken:output_type -> api.v1.services.auth.ValidateTokenResponse + 9, // 17: api.v1.services.auth.AuthService.DestroyToken:output_type -> api.v1.services.auth.DestroyTokenResponse + 11, // 18: api.v1.services.auth.AuthService.Authenticate:output_type -> api.v1.services.auth.AuthenticateResponse + 1, // 19: api.v1.services.auth.AuthService.AuthLogout:output_type -> api.v1.services.auth.AuthLogoutResponse 14, // [14:20] is the sub-list for method output_type 8, // [8:14] is the sub-list for method input_type 8, // [8:8] is the sub-list for extension type_name @@ -937,26 +937,26 @@ var file_system_auth_proto_depIdxs = []int32{ 0, // [0:8] is the sub-list for field type_name } -func init() { file_system_auth_proto_init() } -func file_system_auth_proto_init() { - if File_system_auth_proto != nil { +func init() { file_auth_auth_proto_init() } +func file_auth_auth_proto_init() { + if File_auth_auth_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_auth_proto_rawDesc), len(file_system_auth_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_auth_proto_rawDesc), len(file_auth_auth_proto_rawDesc)), NumEnums: 0, NumMessages: 17, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_system_auth_proto_goTypes, - DependencyIndexes: file_system_auth_proto_depIdxs, - MessageInfos: file_system_auth_proto_msgTypes, + GoTypes: file_auth_auth_proto_goTypes, + DependencyIndexes: file_auth_auth_proto_depIdxs, + MessageInfos: file_auth_auth_proto_msgTypes, }.Build() - File_system_auth_proto = out.File - file_system_auth_proto_goTypes = nil - file_system_auth_proto_depIdxs = nil + File_auth_auth_proto = out.File + file_auth_auth_proto_goTypes = nil + file_auth_auth_proto_depIdxs = nil } diff --git a/api/v1/services/system/auth.pb.gw.go b/api/v1/services/auth/auth.pb.gw.go similarity index 94% rename from api/v1/services/system/auth.pb.gw.go rename to api/v1/services/auth/auth.pb.gw.go index 4ce4a2b5..086ad8fe 100644 --- a/api/v1/services/system/auth.pb.gw.go +++ b/api/v1/services/auth/auth.pb.gw.go @@ -1,12 +1,12 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/auth.proto +// source: auth/auth.proto /* -Package system is a reverse proxy. +Package auth is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ -package system +package auth import ( "context" @@ -209,7 +209,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/sys/auth/resources")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/sys/auth/resources")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -229,7 +229,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.AuthService/CreateToken", runtime.WithHTTPPathPattern("/sys/auth/token")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/sys/auth/token")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -249,7 +249,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/sys/auth/validate")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/sys/auth/validate")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -269,7 +269,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/sys/auth/destroy")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/sys/auth/destroy")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -289,7 +289,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.AuthService/Authenticate", runtime.WithHTTPPathPattern("/sys/auth/authenticate")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/sys/auth/authenticate")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -309,7 +309,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/sys/auth/logout")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/sys/auth/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -367,7 +367,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/sys/auth/resources")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/sys/auth/resources")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -384,7 +384,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.AuthService/CreateToken", runtime.WithHTTPPathPattern("/sys/auth/token")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/sys/auth/token")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -401,7 +401,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/sys/auth/validate")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/sys/auth/validate")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -418,7 +418,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/sys/auth/destroy")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/sys/auth/destroy")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -435,7 +435,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.AuthService/Authenticate", runtime.WithHTTPPathPattern("/sys/auth/authenticate")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/sys/auth/authenticate")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -452,7 +452,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/sys/auth/logout")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/sys/auth/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return diff --git a/api/v1/services/system/auth.pb.validate.go b/api/v1/services/auth/auth.pb.validate.go similarity index 99% rename from api/v1/services/system/auth.pb.validate.go rename to api/v1/services/auth/auth.pb.validate.go index 730b5486..3cc97d16 100644 --- a/api/v1/services/system/auth.pb.validate.go +++ b/api/v1/services/auth/auth.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/auth.proto +// source: auth/auth.proto -package system +package auth import ( "bytes" diff --git a/api/v1/services/system/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go similarity index 97% rename from api/v1/services/system/auth_bridge.pb.go rename to api/v1/services/auth/auth_bridge.pb.go index 9abbf8a8..71dfaf89 100644 --- a/api/v1/services/system/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-bridge unknown // - protoc (unknown) -// source: system/auth.proto +// source: auth/auth.proto -package system +package auth import ( context "context" @@ -19,12 +19,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 -const AuthServiceAuthLogoutBridgeOperation = "/api.v1.services.system.AuthService/AuthLogout" -const AuthServiceAuthenticateBridgeOperation = "/api.v1.services.system.AuthService/Authenticate" -const AuthServiceCreateTokenBridgeOperation = "/api.v1.services.system.AuthService/CreateToken" -const AuthServiceDestroyTokenBridgeOperation = "/api.v1.services.system.AuthService/DestroyToken" -const AuthServiceListAuthResourcesBridgeOperation = "/api.v1.services.system.AuthService/ListAuthResources" -const AuthServiceValidateTokenBridgeOperation = "/api.v1.services.system.AuthService/ValidateToken" +const AuthServiceAuthLogoutBridgeOperation = "/api.v1.services.auth.AuthService/AuthLogout" +const AuthServiceAuthenticateBridgeOperation = "/api.v1.services.auth.AuthService/Authenticate" +const AuthServiceCreateTokenBridgeOperation = "/api.v1.services.auth.AuthService/CreateToken" +const AuthServiceDestroyTokenBridgeOperation = "/api.v1.services.auth.AuthService/DestroyToken" +const AuthServiceListAuthResourcesBridgeOperation = "/api.v1.services.auth.AuthService/ListAuthResources" +const AuthServiceValidateTokenBridgeOperation = "/api.v1.services.auth.AuthService/ValidateToken" type AuthServiceBridger interface { AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) diff --git a/api/v1/services/system/auth_grpc.pb.go b/api/v1/services/auth/auth_grpc.pb.go similarity index 97% rename from api/v1/services/system/auth_grpc.pb.go rename to api/v1/services/auth/auth_grpc.pb.go index bdbc3697..daf79cd9 100644 --- a/api/v1/services/system/auth_grpc.pb.go +++ b/api/v1/services/auth/auth_grpc.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) -// source: system/auth.proto +// source: auth/auth.proto -package system +package auth import ( context "context" @@ -19,12 +19,12 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - AuthService_ListAuthResources_FullMethodName = "/api.v1.services.system.AuthService/ListAuthResources" - AuthService_CreateToken_FullMethodName = "/api.v1.services.system.AuthService/CreateToken" - AuthService_ValidateToken_FullMethodName = "/api.v1.services.system.AuthService/ValidateToken" - AuthService_DestroyToken_FullMethodName = "/api.v1.services.system.AuthService/DestroyToken" - AuthService_Authenticate_FullMethodName = "/api.v1.services.system.AuthService/Authenticate" - AuthService_AuthLogout_FullMethodName = "/api.v1.services.system.AuthService/AuthLogout" + AuthService_ListAuthResources_FullMethodName = "/api.v1.services.auth.AuthService/ListAuthResources" + AuthService_CreateToken_FullMethodName = "/api.v1.services.auth.AuthService/CreateToken" + AuthService_ValidateToken_FullMethodName = "/api.v1.services.auth.AuthService/ValidateToken" + AuthService_DestroyToken_FullMethodName = "/api.v1.services.auth.AuthService/DestroyToken" + AuthService_Authenticate_FullMethodName = "/api.v1.services.auth.AuthService/Authenticate" + AuthService_AuthLogout_FullMethodName = "/api.v1.services.auth.AuthService/AuthLogout" ) // AuthServiceClient is the client API for AuthService service. @@ -284,7 +284,7 @@ func _AuthService_AuthLogout_Handler(srv interface{}, ctx context.Context, dec f // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var AuthService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.AuthService", + ServiceName: "api.v1.services.auth.AuthService", HandlerType: (*AuthServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -313,5 +313,5 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "system/auth.proto", + Metadata: "auth/auth.proto", } diff --git a/api/v1/services/system/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go similarity index 94% rename from api/v1/services/system/auth_http.pb.go rename to api/v1/services/auth/auth_http.pb.go index fb7034d5..f35712a4 100644 --- a/api/v1/services/system/auth_http.pb.go +++ b/api/v1/services/auth/auth_http.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-http v2.8.4 // - protoc (unknown) -// source: system/auth.proto +// source: auth/auth.proto -package system +package auth import ( context "context" @@ -19,12 +19,12 @@ var _ = binding.EncodeURL const _ = http.SupportPackageIsVersion1 -const OperationAuthServiceAuthLogout = "/api.v1.services.system.AuthService/AuthLogout" -const OperationAuthServiceAuthenticate = "/api.v1.services.system.AuthService/Authenticate" -const OperationAuthServiceCreateToken = "/api.v1.services.system.AuthService/CreateToken" -const OperationAuthServiceDestroyToken = "/api.v1.services.system.AuthService/DestroyToken" -const OperationAuthServiceListAuthResources = "/api.v1.services.system.AuthService/ListAuthResources" -const OperationAuthServiceValidateToken = "/api.v1.services.system.AuthService/ValidateToken" +const OperationAuthServiceAuthLogout = "/api.v1.services.auth.AuthService/AuthLogout" +const OperationAuthServiceAuthenticate = "/api.v1.services.auth.AuthService/Authenticate" +const OperationAuthServiceCreateToken = "/api.v1.services.auth.AuthService/CreateToken" +const OperationAuthServiceDestroyToken = "/api.v1.services.auth.AuthService/DestroyToken" +const OperationAuthServiceListAuthResources = "/api.v1.services.auth.AuthService/ListAuthResources" +const OperationAuthServiceValidateToken = "/api.v1.services.auth.AuthService/ValidateToken" type AuthServiceHTTPServer interface { AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) diff --git a/api/v1/services/system/casbin.pb.go b/api/v1/services/auth/casbin.pb.go similarity index 66% rename from api/v1/services/system/casbin.pb.go rename to api/v1/services/auth/casbin.pb.go index b460505a..cc8301cd 100644 --- a/api/v1/services/system/casbin.pb.go +++ b/api/v1/services/auth/casbin.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.36.6 // protoc (unknown) -// source: system/casbin.proto +// source: auth/casbin.proto -package system +package auth import ( _ "google.golang.org/genproto/googleapis/api/annotations" @@ -30,7 +30,7 @@ type ListPoliciesRequest struct { func (x *ListPoliciesRequest) Reset() { *x = ListPoliciesRequest{} - mi := &file_system_casbin_proto_msgTypes[0] + mi := &file_auth_casbin_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -42,7 +42,7 @@ func (x *ListPoliciesRequest) String() string { func (*ListPoliciesRequest) ProtoMessage() {} func (x *ListPoliciesRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_casbin_proto_msgTypes[0] + mi := &file_auth_casbin_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -55,7 +55,7 @@ func (x *ListPoliciesRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPoliciesRequest.ProtoReflect.Descriptor instead. func (*ListPoliciesRequest) Descriptor() ([]byte, []int) { - return file_system_casbin_proto_rawDescGZIP(), []int{0} + return file_auth_casbin_proto_rawDescGZIP(), []int{0} } type ListPoliciesResponse struct { @@ -67,7 +67,7 @@ type ListPoliciesResponse struct { func (x *ListPoliciesResponse) Reset() { *x = ListPoliciesResponse{} - mi := &file_system_casbin_proto_msgTypes[1] + mi := &file_auth_casbin_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -79,7 +79,7 @@ func (x *ListPoliciesResponse) String() string { func (*ListPoliciesResponse) ProtoMessage() {} func (x *ListPoliciesResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_casbin_proto_msgTypes[1] + mi := &file_auth_casbin_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -92,7 +92,7 @@ func (x *ListPoliciesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPoliciesResponse.ProtoReflect.Descriptor instead. func (*ListPoliciesResponse) Descriptor() ([]byte, []int) { - return file_system_casbin_proto_rawDescGZIP(), []int{1} + return file_auth_casbin_proto_rawDescGZIP(), []int{1} } func (x *ListPoliciesResponse) GetRules() []*PolicyRule { @@ -112,7 +112,7 @@ type PolicyRule struct { func (x *PolicyRule) Reset() { *x = PolicyRule{} - mi := &file_system_casbin_proto_msgTypes[2] + mi := &file_auth_casbin_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -124,7 +124,7 @@ func (x *PolicyRule) String() string { func (*PolicyRule) ProtoMessage() {} func (x *PolicyRule) ProtoReflect() protoreflect.Message { - mi := &file_system_casbin_proto_msgTypes[2] + mi := &file_auth_casbin_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -137,7 +137,7 @@ func (x *PolicyRule) ProtoReflect() protoreflect.Message { // Deprecated: Use PolicyRule.ProtoReflect.Descriptor instead. func (*PolicyRule) Descriptor() ([]byte, []int) { - return file_system_casbin_proto_rawDescGZIP(), []int{2} + return file_auth_casbin_proto_rawDescGZIP(), []int{2} } func (x *PolicyRule) GetPType() string { @@ -162,7 +162,7 @@ type ListGroupingsRequest struct { func (x *ListGroupingsRequest) Reset() { *x = ListGroupingsRequest{} - mi := &file_system_casbin_proto_msgTypes[3] + mi := &file_auth_casbin_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -174,7 +174,7 @@ func (x *ListGroupingsRequest) String() string { func (*ListGroupingsRequest) ProtoMessage() {} func (x *ListGroupingsRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_casbin_proto_msgTypes[3] + mi := &file_auth_casbin_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -187,7 +187,7 @@ func (x *ListGroupingsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListGroupingsRequest.ProtoReflect.Descriptor instead. func (*ListGroupingsRequest) Descriptor() ([]byte, []int) { - return file_system_casbin_proto_rawDescGZIP(), []int{3} + return file_auth_casbin_proto_rawDescGZIP(), []int{3} } type ListGroupingsResponse struct { @@ -199,7 +199,7 @@ type ListGroupingsResponse struct { func (x *ListGroupingsResponse) Reset() { *x = ListGroupingsResponse{} - mi := &file_system_casbin_proto_msgTypes[4] + mi := &file_auth_casbin_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -211,7 +211,7 @@ func (x *ListGroupingsResponse) String() string { func (*ListGroupingsResponse) ProtoMessage() {} func (x *ListGroupingsResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_casbin_proto_msgTypes[4] + mi := &file_auth_casbin_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -224,7 +224,7 @@ func (x *ListGroupingsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListGroupingsResponse.ProtoReflect.Descriptor instead. func (*ListGroupingsResponse) Descriptor() ([]byte, []int) { - return file_system_casbin_proto_rawDescGZIP(), []int{4} + return file_auth_casbin_proto_rawDescGZIP(), []int{4} } func (x *ListGroupingsResponse) GetRules() []*GroupingRule { @@ -244,7 +244,7 @@ type GroupingRule struct { func (x *GroupingRule) Reset() { *x = GroupingRule{} - mi := &file_system_casbin_proto_msgTypes[5] + mi := &file_auth_casbin_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -256,7 +256,7 @@ func (x *GroupingRule) String() string { func (*GroupingRule) ProtoMessage() {} func (x *GroupingRule) ProtoReflect() protoreflect.Message { - mi := &file_system_casbin_proto_msgTypes[5] + mi := &file_auth_casbin_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -269,7 +269,7 @@ func (x *GroupingRule) ProtoReflect() protoreflect.Message { // Deprecated: Use GroupingRule.ProtoReflect.Descriptor instead. func (*GroupingRule) Descriptor() ([]byte, []int) { - return file_system_casbin_proto_rawDescGZIP(), []int{5} + return file_auth_casbin_proto_rawDescGZIP(), []int{5} } func (x *GroupingRule) GetPType() string { @@ -296,7 +296,7 @@ type StreamRulesRequest struct { func (x *StreamRulesRequest) Reset() { *x = StreamRulesRequest{} - mi := &file_system_casbin_proto_msgTypes[6] + mi := &file_auth_casbin_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -308,7 +308,7 @@ func (x *StreamRulesRequest) String() string { func (*StreamRulesRequest) ProtoMessage() {} func (x *StreamRulesRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_casbin_proto_msgTypes[6] + mi := &file_auth_casbin_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -321,7 +321,7 @@ func (x *StreamRulesRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use StreamRulesRequest.ProtoReflect.Descriptor instead. func (*StreamRulesRequest) Descriptor() ([]byte, []int) { - return file_system_casbin_proto_rawDescGZIP(), []int{6} + return file_auth_casbin_proto_rawDescGZIP(), []int{6} } func (x *StreamRulesRequest) GetWithPolicies() bool { @@ -351,7 +351,7 @@ type StreamRulesResponse struct { func (x *StreamRulesResponse) Reset() { *x = StreamRulesResponse{} - mi := &file_system_casbin_proto_msgTypes[7] + mi := &file_auth_casbin_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -363,7 +363,7 @@ func (x *StreamRulesResponse) String() string { func (*StreamRulesResponse) ProtoMessage() {} func (x *StreamRulesResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_casbin_proto_msgTypes[7] + mi := &file_auth_casbin_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -376,7 +376,7 @@ func (x *StreamRulesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use StreamRulesResponse.ProtoReflect.Descriptor instead. func (*StreamRulesResponse) Descriptor() ([]byte, []int) { - return file_system_casbin_proto_rawDescGZIP(), []int{7} + return file_auth_casbin_proto_rawDescGZIP(), []int{7} } func (x *StreamRulesResponse) GetRuleType() isStreamRulesResponse_RuleType { @@ -429,7 +429,7 @@ type WatchUpdateRequest struct { func (x *WatchUpdateRequest) Reset() { *x = WatchUpdateRequest{} - mi := &file_system_casbin_proto_msgTypes[8] + mi := &file_auth_casbin_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -441,7 +441,7 @@ func (x *WatchUpdateRequest) String() string { func (*WatchUpdateRequest) ProtoMessage() {} func (x *WatchUpdateRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_casbin_proto_msgTypes[8] + mi := &file_auth_casbin_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -454,7 +454,7 @@ func (x *WatchUpdateRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use WatchUpdateRequest.ProtoReflect.Descriptor instead. func (*WatchUpdateRequest) Descriptor() ([]byte, []int) { - return file_system_casbin_proto_rawDescGZIP(), []int{8} + return file_auth_casbin_proto_rawDescGZIP(), []int{8} } func (x *WatchUpdateRequest) GetLastModified() int64 { @@ -473,7 +473,7 @@ type WatchUpdateResponse struct { func (x *WatchUpdateResponse) Reset() { *x = WatchUpdateResponse{} - mi := &file_system_casbin_proto_msgTypes[9] + mi := &file_auth_casbin_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -485,7 +485,7 @@ func (x *WatchUpdateResponse) String() string { func (*WatchUpdateResponse) ProtoMessage() {} func (x *WatchUpdateResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_casbin_proto_msgTypes[9] + mi := &file_auth_casbin_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -498,7 +498,7 @@ func (x *WatchUpdateResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use WatchUpdateResponse.ProtoReflect.Descriptor instead. func (*WatchUpdateResponse) Descriptor() ([]byte, []int) { - return file_system_casbin_proto_rawDescGZIP(), []int{9} + return file_auth_casbin_proto_rawDescGZIP(), []int{9} } func (x *WatchUpdateResponse) GetModifiedDate() int64 { @@ -508,80 +508,80 @@ func (x *WatchUpdateResponse) GetModifiedDate() int64 { return 0 } -var File_system_casbin_proto protoreflect.FileDescriptor +var File_auth_casbin_proto protoreflect.FileDescriptor -const file_system_casbin_proto_rawDesc = "" + +const file_auth_casbin_proto_rawDesc = "" + "\n" + - "\x13system/casbin.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\"\x15\n" + - "\x13ListPoliciesRequest\"P\n" + - "\x14ListPoliciesResponse\x128\n" + - "\x05rules\x18\x01 \x03(\v2\".api.v1.services.system.PolicyRuleR\x05rules\"<\n" + + "\x11auth/casbin.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\"\x15\n" + + "\x13ListPoliciesRequest\"N\n" + + "\x14ListPoliciesResponse\x126\n" + + "\x05rules\x18\x01 \x03(\v2 .api.v1.services.auth.PolicyRuleR\x05rules\"<\n" + "\n" + "PolicyRule\x12\x16\n" + "\x06p_type\x18\x01 \x01(\tR\x06p_type\x12\x16\n" + "\x06params\x18\x02 \x03(\tR\x06params\"\x16\n" + - "\x14ListGroupingsRequest\"S\n" + - "\x15ListGroupingsResponse\x12:\n" + - "\x05rules\x18\x01 \x03(\v2$.api.v1.services.system.GroupingRuleR\x05rules\">\n" + + "\x14ListGroupingsRequest\"Q\n" + + "\x15ListGroupingsResponse\x128\n" + + "\x05rules\x18\x01 \x03(\v2\".api.v1.services.auth.GroupingRuleR\x05rules\">\n" + "\fGroupingRule\x12\x16\n" + "\x06p_type\x18\x01 \x01(\tR\x06p_type\x12\x16\n" + "\x06params\x18\x02 \x03(\tR\x06params\"b\n" + "\x12StreamRulesRequest\x12$\n" + "\rwith_policies\x18\x01 \x01(\bR\rwith_policies\x12&\n" + - "\x0ewith_groupings\x18\x02 \x01(\bR\x0ewith_groupings\"\xa4\x01\n" + - "\x13StreamRulesResponse\x12<\n" + - "\x06policy\x18\x01 \x01(\v2\".api.v1.services.system.PolicyRuleH\x00R\x06policy\x12B\n" + - "\bgrouping\x18\x02 \x01(\v2$.api.v1.services.system.GroupingRuleH\x00R\bgroupingB\v\n" + + "\x0ewith_groupings\x18\x02 \x01(\bR\x0ewith_groupings\"\xa0\x01\n" + + "\x13StreamRulesResponse\x12:\n" + + "\x06policy\x18\x01 \x01(\v2 .api.v1.services.auth.PolicyRuleH\x00R\x06policy\x12@\n" + + "\bgrouping\x18\x02 \x01(\v2\".api.v1.services.auth.GroupingRuleH\x00R\bgroupingB\v\n" + "\trule_type\":\n" + "\x12WatchUpdateRequest\x12$\n" + "\rlast_modified\x18\x01 \x01(\x03R\rlast_modified\";\n" + "\x13WatchUpdateResponse\x12$\n" + - "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\xb4\x04\n" + - "\x13CasbinSourceService\x12\x86\x01\n" + - "\fListPolicies\x12+.api.v1.services.system.ListPoliciesRequest\x1a,.api.v1.services.system.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x8a\x01\n" + - "\rListGroupings\x12,.api.v1.services.system.ListGroupingsRequest\x1a-.api.v1.services.system.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12\x80\x01\n" + - "\vWatchUpdate\x12*.api.v1.services.system.WatchUpdateRequest\x1a+.api.v1.services.system.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12\x83\x01\n" + - "\vStreamRules\x12*.api.v1.services.system.StreamRulesRequest\x1a+.api.v1.services.system.StreamRulesResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/casbin/stream0\x01B\xc0\x01\n" + - "\x1acom.api.v1.services.systemB\vCasbinProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\xa2\x04\n" + + "\x13CasbinSourceService\x12\x82\x01\n" + + "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x86\x01\n" + + "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12|\n" + + "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12\x7f\n" + + "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/casbin/stream0\x01B\xb2\x01\n" + + "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z\x15v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( - file_system_casbin_proto_rawDescOnce sync.Once - file_system_casbin_proto_rawDescData []byte + file_auth_casbin_proto_rawDescOnce sync.Once + file_auth_casbin_proto_rawDescData []byte ) -func file_system_casbin_proto_rawDescGZIP() []byte { - file_system_casbin_proto_rawDescOnce.Do(func() { - file_system_casbin_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_casbin_proto_rawDesc), len(file_system_casbin_proto_rawDesc))) +func file_auth_casbin_proto_rawDescGZIP() []byte { + file_auth_casbin_proto_rawDescOnce.Do(func() { + file_auth_casbin_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_casbin_proto_rawDesc), len(file_auth_casbin_proto_rawDesc))) }) - return file_system_casbin_proto_rawDescData -} - -var file_system_casbin_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_system_casbin_proto_goTypes = []any{ - (*ListPoliciesRequest)(nil), // 0: api.v1.services.system.ListPoliciesRequest - (*ListPoliciesResponse)(nil), // 1: api.v1.services.system.ListPoliciesResponse - (*PolicyRule)(nil), // 2: api.v1.services.system.PolicyRule - (*ListGroupingsRequest)(nil), // 3: api.v1.services.system.ListGroupingsRequest - (*ListGroupingsResponse)(nil), // 4: api.v1.services.system.ListGroupingsResponse - (*GroupingRule)(nil), // 5: api.v1.services.system.GroupingRule - (*StreamRulesRequest)(nil), // 6: api.v1.services.system.StreamRulesRequest - (*StreamRulesResponse)(nil), // 7: api.v1.services.system.StreamRulesResponse - (*WatchUpdateRequest)(nil), // 8: api.v1.services.system.WatchUpdateRequest - (*WatchUpdateResponse)(nil), // 9: api.v1.services.system.WatchUpdateResponse -} -var file_system_casbin_proto_depIdxs = []int32{ - 2, // 0: api.v1.services.system.ListPoliciesResponse.rules:type_name -> api.v1.services.system.PolicyRule - 5, // 1: api.v1.services.system.ListGroupingsResponse.rules:type_name -> api.v1.services.system.GroupingRule - 2, // 2: api.v1.services.system.StreamRulesResponse.policy:type_name -> api.v1.services.system.PolicyRule - 5, // 3: api.v1.services.system.StreamRulesResponse.grouping:type_name -> api.v1.services.system.GroupingRule - 0, // 4: api.v1.services.system.CasbinSourceService.ListPolicies:input_type -> api.v1.services.system.ListPoliciesRequest - 3, // 5: api.v1.services.system.CasbinSourceService.ListGroupings:input_type -> api.v1.services.system.ListGroupingsRequest - 8, // 6: api.v1.services.system.CasbinSourceService.WatchUpdate:input_type -> api.v1.services.system.WatchUpdateRequest - 6, // 7: api.v1.services.system.CasbinSourceService.StreamRules:input_type -> api.v1.services.system.StreamRulesRequest - 1, // 8: api.v1.services.system.CasbinSourceService.ListPolicies:output_type -> api.v1.services.system.ListPoliciesResponse - 4, // 9: api.v1.services.system.CasbinSourceService.ListGroupings:output_type -> api.v1.services.system.ListGroupingsResponse - 9, // 10: api.v1.services.system.CasbinSourceService.WatchUpdate:output_type -> api.v1.services.system.WatchUpdateResponse - 7, // 11: api.v1.services.system.CasbinSourceService.StreamRules:output_type -> api.v1.services.system.StreamRulesResponse + return file_auth_casbin_proto_rawDescData +} + +var file_auth_casbin_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_auth_casbin_proto_goTypes = []any{ + (*ListPoliciesRequest)(nil), // 0: api.v1.services.auth.ListPoliciesRequest + (*ListPoliciesResponse)(nil), // 1: api.v1.services.auth.ListPoliciesResponse + (*PolicyRule)(nil), // 2: api.v1.services.auth.PolicyRule + (*ListGroupingsRequest)(nil), // 3: api.v1.services.auth.ListGroupingsRequest + (*ListGroupingsResponse)(nil), // 4: api.v1.services.auth.ListGroupingsResponse + (*GroupingRule)(nil), // 5: api.v1.services.auth.GroupingRule + (*StreamRulesRequest)(nil), // 6: api.v1.services.auth.StreamRulesRequest + (*StreamRulesResponse)(nil), // 7: api.v1.services.auth.StreamRulesResponse + (*WatchUpdateRequest)(nil), // 8: api.v1.services.auth.WatchUpdateRequest + (*WatchUpdateResponse)(nil), // 9: api.v1.services.auth.WatchUpdateResponse +} +var file_auth_casbin_proto_depIdxs = []int32{ + 2, // 0: api.v1.services.auth.ListPoliciesResponse.rules:type_name -> api.v1.services.auth.PolicyRule + 5, // 1: api.v1.services.auth.ListGroupingsResponse.rules:type_name -> api.v1.services.auth.GroupingRule + 2, // 2: api.v1.services.auth.StreamRulesResponse.policy:type_name -> api.v1.services.auth.PolicyRule + 5, // 3: api.v1.services.auth.StreamRulesResponse.grouping:type_name -> api.v1.services.auth.GroupingRule + 0, // 4: api.v1.services.auth.CasbinSourceService.ListPolicies:input_type -> api.v1.services.auth.ListPoliciesRequest + 3, // 5: api.v1.services.auth.CasbinSourceService.ListGroupings:input_type -> api.v1.services.auth.ListGroupingsRequest + 8, // 6: api.v1.services.auth.CasbinSourceService.WatchUpdate:input_type -> api.v1.services.auth.WatchUpdateRequest + 6, // 7: api.v1.services.auth.CasbinSourceService.StreamRules:input_type -> api.v1.services.auth.StreamRulesRequest + 1, // 8: api.v1.services.auth.CasbinSourceService.ListPolicies:output_type -> api.v1.services.auth.ListPoliciesResponse + 4, // 9: api.v1.services.auth.CasbinSourceService.ListGroupings:output_type -> api.v1.services.auth.ListGroupingsResponse + 9, // 10: api.v1.services.auth.CasbinSourceService.WatchUpdate:output_type -> api.v1.services.auth.WatchUpdateResponse + 7, // 11: api.v1.services.auth.CasbinSourceService.StreamRules:output_type -> api.v1.services.auth.StreamRulesResponse 8, // [8:12] is the sub-list for method output_type 4, // [4:8] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name @@ -589,12 +589,12 @@ var file_system_casbin_proto_depIdxs = []int32{ 0, // [0:4] is the sub-list for field type_name } -func init() { file_system_casbin_proto_init() } -func file_system_casbin_proto_init() { - if File_system_casbin_proto != nil { +func init() { file_auth_casbin_proto_init() } +func file_auth_casbin_proto_init() { + if File_auth_casbin_proto != nil { return } - file_system_casbin_proto_msgTypes[7].OneofWrappers = []any{ + file_auth_casbin_proto_msgTypes[7].OneofWrappers = []any{ (*StreamRulesResponse_Policy)(nil), (*StreamRulesResponse_Grouping)(nil), } @@ -602,17 +602,17 @@ func file_system_casbin_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_casbin_proto_rawDesc), len(file_system_casbin_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_casbin_proto_rawDesc), len(file_auth_casbin_proto_rawDesc)), NumEnums: 0, NumMessages: 10, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_system_casbin_proto_goTypes, - DependencyIndexes: file_system_casbin_proto_depIdxs, - MessageInfos: file_system_casbin_proto_msgTypes, + GoTypes: file_auth_casbin_proto_goTypes, + DependencyIndexes: file_auth_casbin_proto_depIdxs, + MessageInfos: file_auth_casbin_proto_msgTypes, }.Build() - File_system_casbin_proto = out.File - file_system_casbin_proto_goTypes = nil - file_system_casbin_proto_depIdxs = nil + File_auth_casbin_proto = out.File + file_auth_casbin_proto_goTypes = nil + file_auth_casbin_proto_depIdxs = nil } diff --git a/api/v1/services/system/casbin.pb.gw.go b/api/v1/services/auth/casbin.pb.gw.go similarity index 94% rename from api/v1/services/system/casbin.pb.gw.go rename to api/v1/services/auth/casbin.pb.gw.go index b6b10852..fd9a0c2c 100644 --- a/api/v1/services/system/casbin.pb.gw.go +++ b/api/v1/services/auth/casbin.pb.gw.go @@ -1,12 +1,12 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/casbin.proto +// source: auth/casbin.proto /* -Package system is a reverse proxy. +Package auth is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ -package system +package auth import ( "context" @@ -144,7 +144,7 @@ func RegisterCasbinSourceServiceHandlerServer(ctx context.Context, mux *runtime. var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -164,7 +164,7 @@ func RegisterCasbinSourceServiceHandlerServer(ctx context.Context, mux *runtime. var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -184,7 +184,7 @@ func RegisterCasbinSourceServiceHandlerServer(ctx context.Context, mux *runtime. var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -249,7 +249,7 @@ func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime. ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -266,7 +266,7 @@ func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime. ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -283,7 +283,7 @@ func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime. ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -300,7 +300,7 @@ func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime. ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.CasbinSourceService/StreamRules", runtime.WithHTTPPathPattern("/casbin/stream")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/StreamRules", runtime.WithHTTPPathPattern("/casbin/stream")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return diff --git a/api/v1/services/system/casbin.pb.validate.go b/api/v1/services/auth/casbin.pb.validate.go similarity index 99% rename from api/v1/services/system/casbin.pb.validate.go rename to api/v1/services/auth/casbin.pb.validate.go index 61ddaec5..c40e5d7d 100644 --- a/api/v1/services/system/casbin.pb.validate.go +++ b/api/v1/services/auth/casbin.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/casbin.proto +// source: auth/casbin.proto -package system +package auth import ( "bytes" diff --git a/api/v1/services/system/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go similarity index 97% rename from api/v1/services/system/casbin_bridge.pb.go rename to api/v1/services/auth/casbin_bridge.pb.go index 5219e347..87832f2b 100644 --- a/api/v1/services/system/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-bridge unknown // - protoc (unknown) -// source: system/casbin.proto +// source: auth/casbin.proto -package system +package auth import ( context "context" @@ -19,9 +19,9 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 -const CasbinSourceServiceListGroupingsBridgeOperation = "/api.v1.services.system.CasbinSourceService/ListGroupings" -const CasbinSourceServiceListPoliciesBridgeOperation = "/api.v1.services.system.CasbinSourceService/ListPolicies" -const CasbinSourceServiceWatchUpdateBridgeOperation = "/api.v1.services.system.CasbinSourceService/WatchUpdate" +const CasbinSourceServiceListGroupingsBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListGroupings" +const CasbinSourceServiceListPoliciesBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListPolicies" +const CasbinSourceServiceWatchUpdateBridgeOperation = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" type CasbinSourceServiceBridger interface { ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) diff --git a/api/v1/services/system/casbin_grpc.pb.go b/api/v1/services/auth/casbin_grpc.pb.go similarity index 96% rename from api/v1/services/system/casbin_grpc.pb.go rename to api/v1/services/auth/casbin_grpc.pb.go index 29860dd9..86911a12 100644 --- a/api/v1/services/system/casbin_grpc.pb.go +++ b/api/v1/services/auth/casbin_grpc.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) -// source: system/casbin.proto +// source: auth/casbin.proto -package system +package auth import ( context "context" @@ -19,10 +19,10 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - CasbinSourceService_ListPolicies_FullMethodName = "/api.v1.services.system.CasbinSourceService/ListPolicies" - CasbinSourceService_ListGroupings_FullMethodName = "/api.v1.services.system.CasbinSourceService/ListGroupings" - CasbinSourceService_WatchUpdate_FullMethodName = "/api.v1.services.system.CasbinSourceService/WatchUpdate" - CasbinSourceService_StreamRules_FullMethodName = "/api.v1.services.system.CasbinSourceService/StreamRules" + CasbinSourceService_ListPolicies_FullMethodName = "/api.v1.services.auth.CasbinSourceService/ListPolicies" + CasbinSourceService_ListGroupings_FullMethodName = "/api.v1.services.auth.CasbinSourceService/ListGroupings" + CasbinSourceService_WatchUpdate_FullMethodName = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" + CasbinSourceService_StreamRules_FullMethodName = "/api.v1.services.auth.CasbinSourceService/StreamRules" ) // CasbinSourceServiceClient is the client API for CasbinSourceService service. @@ -216,7 +216,7 @@ type CasbinSourceService_StreamRulesServer = grpc.ServerStreamingServer[StreamRu // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var CasbinSourceService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.CasbinSourceService", + ServiceName: "api.v1.services.auth.CasbinSourceService", HandlerType: (*CasbinSourceServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -239,5 +239,5 @@ var CasbinSourceService_ServiceDesc = grpc.ServiceDesc{ ServerStreams: true, }, }, - Metadata: "system/casbin.proto", + Metadata: "auth/casbin.proto", } diff --git a/api/v1/services/system/casbin_http.pb.go b/api/v1/services/auth/casbin_http.pb.go similarity index 96% rename from api/v1/services/system/casbin_http.pb.go rename to api/v1/services/auth/casbin_http.pb.go index 66b93ee1..366708dc 100644 --- a/api/v1/services/system/casbin_http.pb.go +++ b/api/v1/services/auth/casbin_http.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-http v2.8.4 // - protoc (unknown) -// source: system/casbin.proto +// source: auth/casbin.proto -package system +package auth import ( context "context" @@ -19,9 +19,9 @@ var _ = binding.EncodeURL const _ = http.SupportPackageIsVersion1 -const OperationCasbinSourceServiceListGroupings = "/api.v1.services.system.CasbinSourceService/ListGroupings" -const OperationCasbinSourceServiceListPolicies = "/api.v1.services.system.CasbinSourceService/ListPolicies" -const OperationCasbinSourceServiceWatchUpdate = "/api.v1.services.system.CasbinSourceService/WatchUpdate" +const OperationCasbinSourceServiceListGroupings = "/api.v1.services.auth.CasbinSourceService/ListGroupings" +const OperationCasbinSourceServiceListPolicies = "/api.v1.services.auth.CasbinSourceService/ListPolicies" +const OperationCasbinSourceServiceWatchUpdate = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" type CasbinSourceServiceHTTPServer interface { ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 8c7fff99..407b6708 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -227,7 +227,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.ListGroupingsResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListGroupingsResponse' default: description: Default error response content: @@ -245,7 +245,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.ListPoliciesResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListPoliciesResponse' default: description: Default error response content: @@ -272,7 +272,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.StreamRulesResponse' + $ref: '#/components/schemas/api.v1.services.auth.StreamRulesResponse' default: description: Default error response content: @@ -295,7 +295,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.WatchUpdateResponse' + $ref: '#/components/schemas/api.v1.services.auth.WatchUpdateResponse' default: description: Default error response content: @@ -383,7 +383,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.AuthenticateRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.AuthenticateRequest_Data' required: true responses: "200": @@ -391,7 +391,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.AuthenticateResponse' + $ref: '#/components/schemas/api.v1.services.auth.AuthenticateResponse' default: description: Default error response content: @@ -408,7 +408,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.DestroyTokenRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.DestroyTokenRequest_Data' required: true responses: "200": @@ -416,7 +416,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.DestroyTokenResponse' + $ref: '#/components/schemas/api.v1.services.auth.DestroyTokenResponse' default: description: Default error response content: @@ -432,7 +432,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.AuthLogoutRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.AuthLogoutRequest_Data' required: true responses: "200": @@ -440,7 +440,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.AuthLogoutResponse' + $ref: '#/components/schemas/api.v1.services.auth.AuthLogoutResponse' default: description: Default error response content: @@ -481,7 +481,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.ListAuthResourcesResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListAuthResourcesResponse' default: description: Default error response content: @@ -498,7 +498,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.CreateTokenRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.CreateTokenRequest_Data' required: true responses: "200": @@ -506,7 +506,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.CreateTokenResponse' + $ref: '#/components/schemas/api.v1.services.auth.CreateTokenResponse' default: description: Default error response content: @@ -530,7 +530,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.ValidateTokenResponse' + $ref: '#/components/schemas/api.v1.services.auth.ValidateTokenResponse' default: description: Default error response content: @@ -2287,15 +2287,15 @@ paths: $ref: '#/components/schemas/google.rpc.Status' components: schemas: - api.v1.services.system.AuthLogoutRequest_Data: + api.v1.services.auth.AuthLogoutRequest_Data: type: object properties: token: type: string - api.v1.services.system.AuthLogoutResponse: + api.v1.services.auth.AuthLogoutResponse: type: object properties: {} - api.v1.services.system.AuthenticateRequest_Data: + api.v1.services.auth.AuthenticateRequest_Data: type: object properties: token: @@ -2306,11 +2306,101 @@ components: type: string operation: type: string - api.v1.services.system.AuthenticateResponse: + api.v1.services.auth.AuthenticateResponse: type: object properties: is_valid: type: boolean + api.v1.services.auth.CreateTokenRequest_Data: + type: object + properties: + user_id: + type: string + scopes: + type: array + items: + type: string + api.v1.services.auth.CreateTokenResponse: + type: object + properties: + token: + type: string + description: CreateTokenResponse contains the generated token. + api.v1.services.auth.DestroyTokenRequest_Data: + type: object + properties: + token: + type: string + api.v1.services.auth.DestroyTokenResponse: + type: object + properties: {} + description: DestroyTokenResponse contains the result of the invalidation. + api.v1.services.auth.GroupingRule: + type: object + properties: + p_type: + type: string + params: + type: array + items: + type: string + api.v1.services.auth.ListAuthResourcesResponse: + type: object + properties: + resources: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.Resource' + description: The list of Auths. + total_size: + type: integer + description: The total number of Auths in the result set. + format: int32 + api.v1.services.auth.ListGroupingsResponse: + type: object + properties: + rules: + type: array + items: + $ref: '#/components/schemas/api.v1.services.auth.GroupingRule' + api.v1.services.auth.ListPoliciesResponse: + type: object + properties: + rules: + type: array + items: + $ref: '#/components/schemas/api.v1.services.auth.PolicyRule' + api.v1.services.auth.PolicyRule: + type: object + properties: + p_type: + type: string + params: + type: array + items: + type: string + api.v1.services.auth.StreamRulesResponse: + type: object + properties: + policy: + $ref: '#/components/schemas/api.v1.services.auth.PolicyRule' + grouping: + $ref: '#/components/schemas/api.v1.services.auth.GroupingRule' + api.v1.services.auth.ValidateTokenResponse: + type: object + properties: + is_valid: + type: boolean + claims: + type: object + additionalProperties: + type: string + description: VerifyTokenResponse contains the result of the verification. + api.v1.services.auth.WatchUpdateResponse: + type: object + properties: + modified_date: + type: string api.v1.services.system.CaptchaAudioResponse: type: object properties: @@ -2379,21 +2469,6 @@ components: properties: role: $ref: '#/components/schemas/api.v1.services.types.Role' - api.v1.services.system.CreateTokenRequest_Data: - type: object - properties: - user_id: - type: string - scopes: - type: array - items: - type: string - api.v1.services.system.CreateTokenResponse: - type: object - properties: - token: - type: string - description: CreateTokenResponse contains the generated token. api.v1.services.system.CreateUserResponse: type: object properties: @@ -2422,15 +2497,6 @@ components: api.v1.services.system.DeleteUserResponse: type: object properties: {} - api.v1.services.system.DestroyTokenRequest_Data: - type: object - properties: - token: - type: string - api.v1.services.system.DestroyTokenResponse: - type: object - properties: {} - description: DestroyTokenResponse contains the result of the invalidation. api.v1.services.system.GetDepartmentResponse: type: object properties: @@ -2477,27 +2543,6 @@ components: properties: user: $ref: '#/components/schemas/api.v1.services.types.User' - api.v1.services.system.GroupingRule: - type: object - properties: - p_type: - type: string - params: - type: array - items: - type: string - api.v1.services.system.ListAuthResourcesResponse: - type: object - properties: - resources: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Resource' - description: The list of Auths. - total_size: - type: integer - description: The total number of Auths in the result set. - format: int32 api.v1.services.system.ListDepartmentsResponse: type: object properties: @@ -2529,13 +2574,6 @@ components: description: |- Additional information about this response. content to be added without destroying the current data format - api.v1.services.system.ListGroupingsResponse: - type: object - properties: - rules: - type: array - items: - $ref: '#/components/schemas/api.v1.services.system.GroupingRule' api.v1.services.system.ListMenusResponse: type: object properties: @@ -2620,13 +2658,6 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.types.Role' - api.v1.services.system.ListPoliciesResponse: - type: object - properties: - rules: - type: array - items: - $ref: '#/components/schemas/api.v1.services.system.PolicyRule' api.v1.services.system.ListPositionsResponse: type: object properties: @@ -2788,15 +2819,6 @@ components: properties: success: type: boolean - api.v1.services.system.PolicyRule: - type: object - properties: - p_type: - type: string - params: - type: array - items: - type: string api.v1.services.system.RefreshPersonalTokenResponse: type: object properties: @@ -2828,13 +2850,6 @@ components: api.v1.services.system.ResetUserPasswordResponse: type: object properties: {} - api.v1.services.system.StreamRulesResponse: - type: object - properties: - policy: - $ref: '#/components/schemas/api.v1.services.system.PolicyRule' - grouping: - $ref: '#/components/schemas/api.v1.services.system.GroupingRule' api.v1.services.system.TokenRefreshRequest_Data: type: object properties: @@ -2899,21 +2914,6 @@ components: api.v1.services.system.UpdateUserStatusResponse: type: object properties: {} - api.v1.services.system.ValidateTokenResponse: - type: object - properties: - is_valid: - type: boolean - claims: - type: object - additionalProperties: - type: string - description: VerifyTokenResponse contains the result of the verification. - api.v1.services.system.WatchUpdateResponse: - type: object - properties: - modified_date: - type: string api.v1.services.types.Department: type: object properties: From 0249a314200f0221984c6677241ec63e04bb2198 Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 30 May 2025 19:00:23 +0800 Subject: [PATCH 029/158] refactor(api): update go_package options and refactor auth and casbin services - Update go_package options in proto files to use api/v1/services package - Refactor auth and casbin services to use hook interfaces for better extensibility - Implement new hook interfaces for auth and casbin services - Update server registration and handler functions to use new hooked interfaces --- api/v1/proto/annotations.proto | 2 +- api/v1/proto/auth/auth.proto | 2 +- api/v1/proto/auth/casbin.proto | 2 +- api/v1/proto/system/department.proto | 2 +- api/v1/proto/system/error.proto | 2 +- api/v1/proto/system/login.proto | 2 +- api/v1/proto/system/menu.proto | 2 +- api/v1/proto/system/permission.proto | 2 +- api/v1/proto/system/personal.proto | 2 +- api/v1/proto/system/position.proto | 2 +- api/v1/proto/system/resource.proto | 2 +- api/v1/proto/system/role.proto | 2 +- api/v1/proto/system/user.proto | 2 +- api/v1/proto/types/system.proto | 2 +- api/v1/services/annotations.pb.go | 4 +- api/v1/services/auth/auth.pb.go | 6 +- api/v1/services/auth/auth_bridge.pb.go | 101 +- api/v1/services/auth/casbin.pb.go | 4 +- api/v1/services/auth/casbin_bridge.pb.go | 65 +- api/v1/services/system/department.pb.go | 6 +- .../services/system/department_bridge.pb.go | 87 +- api/v1/services/system/error.pb.go | 4 +- api/v1/services/system/login.pb.go | 4 +- api/v1/services/system/login_bridge.pb.go | 120 +- api/v1/services/system/menu.pb.go | 6 +- api/v1/services/system/menu_bridge.pb.go | 87 +- api/v1/services/system/permission.pb.go | 6 +- .../services/system/permission_bridge.pb.go | 87 +- api/v1/services/system/personal.pb.go | 6 +- api/v1/services/system/personal_bridge.pb.go | 128 +- api/v1/services/system/position.pb.go | 6 +- api/v1/services/system/position_bridge.pb.go | 87 +- api/v1/services/system/resource.pb.go | 6 +- api/v1/services/system/resource_bridge.pb.go | 87 +- api/v1/services/system/role.pb.go | 6 +- api/v1/services/system/role_bridge.pb.go | 87 +- api/v1/services/system/user.pb.go | 6 +- api/v1/services/system/user_bridge.pb.go | 138 +- api/v1/services/types/system.pb.go | 3205 ++++++++++ api/v1/services/types/system.pb.validate.go | 5600 +++++++++++++++++ buf.yaml | 3 +- cmd/system/wire_gen.go | 4 +- internal/mods/system/server/server.go | 89 - internal/mods/system/service/menu.bridge.go | 98 +- .../mods/system/service/permission.bridge.go | 101 +- .../mods/system/service/permission.http.go | 26 +- .../mods/system/service/personal.bridge.go | 262 +- .../mods/system/service/resource.bridge.go | 101 +- internal/mods/system/service/role.bridge.go | 103 +- internal/mods/system/service/user.bridge.go | 129 +- 50 files changed, 9889 insertions(+), 1004 deletions(-) create mode 100644 api/v1/services/types/system.pb.go create mode 100644 api/v1/services/types/system.pb.validate.go diff --git a/api/v1/proto/annotations.proto b/api/v1/proto/annotations.proto index e92a02ce..3bb83ad9 100644 --- a/api/v1/proto/annotations.proto +++ b/api/v1/proto/annotations.proto @@ -4,7 +4,7 @@ package api.v1.services; import "gnostic/openapi/v3/annotations.proto"; -option go_package = "v1/services;services"; +option go_package = "api/v1/services;services"; option (gnostic.openapi.v3.document) = { info: { title: "OrigAdmin API" diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index 2b4dd6e4..bbdf5a75 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -6,7 +6,7 @@ import "google/api/annotations.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "v1/services/auth;auth"; +option go_package = "api/v1/services/auth;auth"; option java_multiple_files = true; option java_outer_classname = "APIServiceAuthAuthProto"; option java_package = "com.origadmin.api.v1.services.auth"; diff --git a/api/v1/proto/auth/casbin.proto b/api/v1/proto/auth/casbin.proto index 88d17154..790beb44 100644 --- a/api/v1/proto/auth/casbin.proto +++ b/api/v1/proto/auth/casbin.proto @@ -7,7 +7,7 @@ import "google/api/annotations.proto"; //import "google/protobuf/empty.proto"; //import "types/system.proto"; -option go_package = "v1/services/auth;auth"; +option go_package = "api/v1/services/auth;auth"; option java_multiple_files = true; option java_outer_classname = "APIServiceAuthCasbinProto"; option java_package = "com.origadmin.api.v1.services.auth"; diff --git a/api/v1/proto/system/department.proto b/api/v1/proto/system/department.proto index 04e0365a..d26cd2f5 100644 --- a/api/v1/proto/system/department.proto +++ b/api/v1/proto/system/department.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "v1/services/system;system"; +option go_package = "api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemDepartmentProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/error.proto b/api/v1/proto/system/error.proto index a33e1eea..cbaef087 100644 --- a/api/v1/proto/system/error.proto +++ b/api/v1/proto/system/error.proto @@ -4,7 +4,7 @@ package api.v1.services.system; import "errors/errors.proto"; -option go_package = "v1/services/system;system"; +option go_package = "api/v1/services/system;system"; option java_multiple_files = true; option java_package = "com.origadmin.api.v1.services.system"; option objc_class_prefix = "APIV1ServicesSystem"; diff --git a/api/v1/proto/system/login.proto b/api/v1/proto/system/login.proto index f59926ab..b8e5342f 100644 --- a/api/v1/proto/system/login.proto +++ b/api/v1/proto/system/login.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "security/jwt/v1/token.proto"; import "validate/validate.proto"; -option go_package = "v1/services/system;system"; +option go_package = "api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIV1ServicesSystemProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/menu.proto b/api/v1/proto/system/menu.proto index 3c3c80ce..b04e0c2c 100644 --- a/api/v1/proto/system/menu.proto +++ b/api/v1/proto/system/menu.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "v1/services/system;system"; +option go_package = "api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemMenuProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/permission.proto b/api/v1/proto/system/permission.proto index e7ca8dcd..a7ec2ac6 100644 --- a/api/v1/proto/system/permission.proto +++ b/api/v1/proto/system/permission.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "v1/services/system;system"; +option go_package = "api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemPermissionProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/personal.proto b/api/v1/proto/system/personal.proto index c8028421..ef523f78 100644 --- a/api/v1/proto/system/personal.proto +++ b/api/v1/proto/system/personal.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "types/system.proto"; import "validate/validate.proto"; -option go_package = "v1/services/system;system"; +option go_package = "api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIV1ServicesSystemPersonalProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/position.proto b/api/v1/proto/system/position.proto index 002191b0..6012ba4a 100644 --- a/api/v1/proto/system/position.proto +++ b/api/v1/proto/system/position.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "v1/services/system;system"; +option go_package = "api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemPositionProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index 2bf46674..c8438765 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "v1/services/system;system"; +option go_package = "api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemResourceProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/role.proto b/api/v1/proto/system/role.proto index 2178e18d..684c65bf 100644 --- a/api/v1/proto/system/role.proto +++ b/api/v1/proto/system/role.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "v1/services/system;system"; +option go_package = "api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemRoleProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index de84b687..14335c73 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "v1/services/system;system"; +option go_package = "api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemUserProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index 0ca3a7c0..2247fa1b 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -4,7 +4,7 @@ package api.v1.services.types; import "google/protobuf/timestamp.proto"; -option go_package = "v1/services/types;types"; +option go_package = "origadmin/application/admin/api/v1/services/types;types"; option java_multiple_files = true; option java_outer_classname = "APIServiceTypeSystemProto"; option java_package = "com.origadmin.api.v1.services.types"; diff --git a/api/v1/services/annotations.pb.go b/api/v1/services/annotations.pb.go index 17679d70..74180403 100644 --- a/api/v1/services/annotations.pb.go +++ b/api/v1/services/annotations.pb.go @@ -25,7 +25,7 @@ var File_annotations_proto protoreflect.FileDescriptor const file_annotations_proto_rawDesc = "" + "\n" + - "\x11annotations.proto\x12\x0fapi.v1.services\x1a$gnostic/openapi/v3/annotations.protoB\xae\x04\xbaG\x8f\x03\x12\x8c\x02\n" + + "\x11annotations.proto\x12\x0fapi.v1.services\x1a$gnostic/openapi/v3/annotations.protoB\xb2\x04\xbaG\x8f\x03\x12\x8c\x02\n" + "\rOrigAdmin API\x12_A lightweight, flexible, elegant and full-featured RBAC scaffolding backend management project.\"@\n" + "\aGodCong\x12\x1chttps://github.com/origadmin\x1a\x17waitforadding@gmail.com*?\n" + "\x03MIT\x128https://github.com/origadmin/backend/blob/master/LICENSE2\x17Version from annotation\x1a\x18\n" + @@ -39,7 +39,7 @@ const file_annotations_proto_rawDesc = "" + "\x06Bearer\x12!\n" + "\x1f\n" + "\x06apiKey\x1a\rAuthorization\"\x06header\n" + - "\x13com.api.v1.servicesB\x10AnnotationsProtoP\x01Z\x14v1/services;services\xa2\x02\x03AVS\xaa\x02\x0fApi.V1.Services\xca\x02\x0fApi\\V1\\Services\xe2\x02\x1bApi\\V1\\Services\\GPBMetadata\xea\x02\x11Api::V1::Servicesb\x06proto3" + "\x13com.api.v1.servicesB\x10AnnotationsProtoP\x01Z\x18api/v1/services;services\xa2\x02\x03AVS\xaa\x02\x0fApi.V1.Services\xca\x02\x0fApi\\V1\\Services\xe2\x02\x1bApi\\V1\\Services\\GPBMetadata\xea\x02\x11Api::V1::Servicesb\x06proto3" var file_annotations_proto_goTypes = []any{} var file_annotations_proto_depIdxs = []int32{ diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index 6b1ba855..2a3269a1 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -11,10 +11,10 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" unsafe "unsafe" - types "v1/services/types" ) const ( @@ -872,8 +872,8 @@ const file_auth_auth_proto_rawDesc = "" + "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x04data\"\x11/sys/auth/destroy\x12\x8b\x01\n" + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\"\x16/sys/auth/authenticate\x12\x7f\n" + "\n" + - "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x04data\"\x10/sys/auth/logoutB\xb0\x01\n" + - "\x18com.api.v1.services.authB\tAuthProtoP\x01Z\x15v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x04data\"\x10/sys/auth/logoutB\xb4\x01\n" + + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_auth_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index 71dfaf89..07b2f22b 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -38,40 +38,55 @@ type AuthServiceBridger interface { ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) } -type AuthServiceBridgeHooker interface { +type AuthServiceHooker interface { + AuthServiceAuthLogoutHooker + AuthServiceAuthenticateHooker + AuthServiceCreateTokenHooker + AuthServiceDestroyTokenHooker + AuthServiceListAuthResourcesHooker + AuthServiceValidateTokenHooker +} + +type AuthServiceHookedBridger interface { + AuthServiceHooker AuthServiceBridger +} +type AuthServiceAuthLogoutHooker interface { BeforeAuthLogout(http.Context, *AuthLogoutRequest) (context.Context, error) AuthLogoutResult(http.Context, *AuthLogoutRequest, *AuthLogoutResponse) error +} +type AuthServiceAuthenticateHooker interface { BeforeAuthenticate(http.Context, *AuthenticateRequest) (context.Context, error) AuthenticateResult(http.Context, *AuthenticateRequest, *AuthenticateResponse) error - // CreateToken CreateToken generates a new JWT token for the given user. +} +type AuthServiceCreateTokenHooker interface { BeforeCreateToken(http.Context, *CreateTokenRequest) (context.Context, error) CreateTokenResult(http.Context, *CreateTokenRequest, *CreateTokenResponse) error - // DestroyToken DestroyToken invalidates a JWT token. +} +type AuthServiceDestroyTokenHooker interface { BeforeDestroyToken(http.Context, *DestroyTokenRequest) (context.Context, error) DestroyTokenResult(http.Context, *DestroyTokenRequest, *DestroyTokenResponse) error +} +type AuthServiceListAuthResourcesHooker interface { BeforeListAuthResources(http.Context, *ListAuthResourcesRequest) (context.Context, error) ListAuthResourcesResult(http.Context, *ListAuthResourcesRequest, *ListAuthResourcesResponse) error - // ValidateToken ValidateToken verifies the validity of a JWT token. +} +type AuthServiceValidateTokenHooker interface { BeforeValidateToken(http.Context, *ValidateTokenRequest) (context.Context, error) ValidateTokenResult(http.Context, *ValidateTokenRequest, *ValidateTokenResponse) error } -func RegisterAuthServiceBridger(s *http.Server, srv AuthServiceBridger) { +func RegisterAuthServiceBridger(s *http.Server, srv AuthServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(AuthServiceBridgeHooker) - if !ok { - hook = UnimplementedAuthServiceBridger{AuthServiceBridger: srv} - } - r.GET("/sys/auth/resources", _AuthService_ListAuthResources0_Bridge_Handler(hook)) - r.POST("/sys/auth/token", _AuthService_CreateToken0_Bridge_Handler(hook)) - r.GET("/sys/auth/validate", _AuthService_ValidateToken0_Bridge_Handler(hook)) - r.POST("/sys/auth/destroy", _AuthService_DestroyToken0_Bridge_Handler(hook)) - r.POST("/sys/auth/authenticate", _AuthService_Authenticate0_Bridge_Handler(hook)) - r.POST("/sys/auth/logout", _AuthService_AuthLogout0_Bridge_Handler(hook)) + r.GET("/sys/auth/resources", _AuthService_ListAuthResources0_Bridge_Handler(srv)) + r.POST("/sys/auth/token", _AuthService_CreateToken0_Bridge_Handler(srv)) + r.GET("/sys/auth/validate", _AuthService_ValidateToken0_Bridge_Handler(srv)) + r.POST("/sys/auth/destroy", _AuthService_DestroyToken0_Bridge_Handler(srv)) + r.POST("/sys/auth/authenticate", _AuthService_Authenticate0_Bridge_Handler(srv)) + r.POST("/sys/auth/logout", _AuthService_AuthLogout0_Bridge_Handler(srv)) } -func _AuthService_ListAuthResources0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { +func _AuthService_ListAuthResources0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListAuthResourcesRequest if err := ctx.BindQuery(&in); err != nil { @@ -94,7 +109,7 @@ func _AuthService_ListAuthResources0_Bridge_Handler(srv AuthServiceBridgeHooker) } } -func _AuthService_CreateToken0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { +func _AuthService_CreateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateTokenRequest if err := ctx.Bind(&in.Data); err != nil { @@ -120,7 +135,7 @@ func _AuthService_CreateToken0_Bridge_Handler(srv AuthServiceBridgeHooker) func( } } -func _AuthService_ValidateToken0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { +func _AuthService_ValidateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ValidateTokenRequest if err := ctx.BindQuery(&in); err != nil { @@ -143,7 +158,7 @@ func _AuthService_ValidateToken0_Bridge_Handler(srv AuthServiceBridgeHooker) fun } } -func _AuthService_DestroyToken0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { +func _AuthService_DestroyToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in DestroyTokenRequest if err := ctx.Bind(&in.Data); err != nil { @@ -169,7 +184,7 @@ func _AuthService_DestroyToken0_Bridge_Handler(srv AuthServiceBridgeHooker) func } } -func _AuthService_Authenticate0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { +func _AuthService_Authenticate0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in AuthenticateRequest if err := ctx.Bind(&in.Data); err != nil { @@ -195,7 +210,7 @@ func _AuthService_Authenticate0_Bridge_Handler(srv AuthServiceBridgeHooker) func } } -func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceBridgeHooker) func(ctx http.Context) error { +func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in AuthLogoutRequest if err := ctx.Bind(&in.Data); err != nil { @@ -221,63 +236,75 @@ func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceBridgeHooker) func(c } } -// UnimplementedAuthServiceBridger must be embedded to have +// UnimplementedAuthServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedAuthServiceBridger struct { - AuthServiceBridger -} +type UnimplementedAuthServiceHooked struct{} -func (UnimplementedAuthServiceBridger) BeforeAuthLogout(ctx http.Context, in *AuthLogoutRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) BeforeAuthLogout(ctx http.Context, in *AuthLogoutRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceBridger) AuthLogoutResult(ctx http.Context, in *AuthLogoutRequest, out *AuthLogoutResponse) error { +func (UnimplementedAuthServiceHooked) AuthLogoutResult(ctx http.Context, in *AuthLogoutRequest, out *AuthLogoutResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceBridger) BeforeAuthenticate(ctx http.Context, in *AuthenticateRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) BeforeAuthenticate(ctx http.Context, in *AuthenticateRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceBridger) AuthenticateResult(ctx http.Context, in *AuthenticateRequest, out *AuthenticateResponse) error { +func (UnimplementedAuthServiceHooked) AuthenticateResult(ctx http.Context, in *AuthenticateRequest, out *AuthenticateResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceBridger) BeforeCreateToken(ctx http.Context, in *CreateTokenRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) BeforeCreateToken(ctx http.Context, in *CreateTokenRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceBridger) CreateTokenResult(ctx http.Context, in *CreateTokenRequest, out *CreateTokenResponse) error { +func (UnimplementedAuthServiceHooked) CreateTokenResult(ctx http.Context, in *CreateTokenRequest, out *CreateTokenResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceBridger) BeforeDestroyToken(ctx http.Context, in *DestroyTokenRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) BeforeDestroyToken(ctx http.Context, in *DestroyTokenRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceBridger) DestroyTokenResult(ctx http.Context, in *DestroyTokenRequest, out *DestroyTokenResponse) error { +func (UnimplementedAuthServiceHooked) DestroyTokenResult(ctx http.Context, in *DestroyTokenRequest, out *DestroyTokenResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceBridger) BeforeListAuthResources(ctx http.Context, in *ListAuthResourcesRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) BeforeListAuthResources(ctx http.Context, in *ListAuthResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceBridger) ListAuthResourcesResult(ctx http.Context, in *ListAuthResourcesRequest, out *ListAuthResourcesResponse) error { +func (UnimplementedAuthServiceHooked) ListAuthResourcesResult(ctx http.Context, in *ListAuthResourcesRequest, out *ListAuthResourcesResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceBridger) BeforeValidateToken(ctx http.Context, in *ValidateTokenRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) BeforeValidateToken(ctx http.Context, in *ValidateTokenRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceBridger) ValidateTokenResult(ctx http.Context, in *ValidateTokenRequest, out *ValidateTokenResponse) error { +func (UnimplementedAuthServiceHooked) ValidateTokenResult(ctx http.Context, in *ValidateTokenRequest, out *ValidateTokenResponse) error { return ctx.Result(200, out) } +func WithAuthServiceHook(h AuthServiceHooker) func(AuthServiceBridger) AuthServiceHookedBridger { + return func(b AuthServiceBridger) AuthServiceHookedBridger { + return AuthServiceHookedBridge{AuthServiceBridger: b, AuthServiceHooker: h} + } +} + +// AuthServiceHookedBridge is a bridge between the HTTP and gRPC implementations of AuthService. +// It implements the HTTP and gRPC implementations of AuthService. +// It forwards requests and responses between the two implementations. +type AuthServiceHookedBridge struct { + AuthServiceBridger + AuthServiceHooker +} + type AuthServiceHTTPBridgeImpl struct { client AuthServiceHTTPClient } diff --git a/api/v1/services/auth/casbin.pb.go b/api/v1/services/auth/casbin.pb.go index cc8301cd..87ff2c98 100644 --- a/api/v1/services/auth/casbin.pb.go +++ b/api/v1/services/auth/casbin.pb.go @@ -541,8 +541,8 @@ const file_auth_casbin_proto_rawDesc = "" + "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x86\x01\n" + "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12|\n" + "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12\x7f\n" + - "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/casbin/stream0\x01B\xb2\x01\n" + - "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z\x15v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/casbin/stream0\x01B\xb6\x01\n" + + "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_casbin_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index 87832f2b..c41b2e89 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -29,28 +29,37 @@ type CasbinSourceServiceBridger interface { WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) } -type CasbinSourceServiceBridgeHooker interface { +type CasbinSourceServiceHooker interface { + CasbinSourceServiceListGroupingsHooker + CasbinSourceServiceListPoliciesHooker + CasbinSourceServiceWatchUpdateHooker +} + +type CasbinSourceServiceHookedBridger interface { + CasbinSourceServiceHooker CasbinSourceServiceBridger +} +type CasbinSourceServiceListGroupingsHooker interface { BeforeListGroupings(http.Context, *ListGroupingsRequest) (context.Context, error) ListGroupingsResult(http.Context, *ListGroupingsRequest, *ListGroupingsResponse) error +} +type CasbinSourceServiceListPoliciesHooker interface { BeforeListPolicies(http.Context, *ListPoliciesRequest) (context.Context, error) ListPoliciesResult(http.Context, *ListPoliciesRequest, *ListPoliciesResponse) error +} +type CasbinSourceServiceWatchUpdateHooker interface { BeforeWatchUpdate(http.Context, *WatchUpdateRequest) (context.Context, error) WatchUpdateResult(http.Context, *WatchUpdateRequest, *WatchUpdateResponse) error } -func RegisterCasbinSourceServiceBridger(s *http.Server, srv CasbinSourceServiceBridger) { +func RegisterCasbinSourceServiceBridger(s *http.Server, srv CasbinSourceServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(CasbinSourceServiceBridgeHooker) - if !ok { - hook = UnimplementedCasbinSourceServiceBridger{CasbinSourceServiceBridger: srv} - } - r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_Bridge_Handler(hook)) - r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_Bridge_Handler(hook)) - r.GET("/casbin/watch", _CasbinSourceService_WatchUpdate0_Bridge_Handler(hook)) + r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_Bridge_Handler(srv)) + r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_Bridge_Handler(srv)) + r.GET("/casbin/watch", _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv)) } -func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceBridgeHooker) func(ctx http.Context) error { +func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListPoliciesRequest if err := ctx.BindQuery(&in); err != nil { @@ -73,7 +82,7 @@ func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceBr } } -func _CasbinSourceService_ListGroupings0_Bridge_Handler(srv CasbinSourceServiceBridgeHooker) func(ctx http.Context) error { +func _CasbinSourceService_ListGroupings0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListGroupingsRequest if err := ctx.BindQuery(&in); err != nil { @@ -96,7 +105,7 @@ func _CasbinSourceService_ListGroupings0_Bridge_Handler(srv CasbinSourceServiceB } } -func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceBridgeHooker) func(ctx http.Context) error { +func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in WatchUpdateRequest if err := ctx.BindQuery(&in); err != nil { @@ -119,39 +128,51 @@ func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceBri } } -// UnimplementedCasbinSourceServiceBridger must be embedded to have +// UnimplementedCasbinSourceServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedCasbinSourceServiceBridger struct { - CasbinSourceServiceBridger -} +type UnimplementedCasbinSourceServiceHooked struct{} -func (UnimplementedCasbinSourceServiceBridger) BeforeListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { +func (UnimplementedCasbinSourceServiceHooked) BeforeListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceBridger) ListGroupingsResult(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { +func (UnimplementedCasbinSourceServiceHooked) ListGroupingsResult(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { return ctx.Result(200, out) } -func (UnimplementedCasbinSourceServiceBridger) BeforeListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { +func (UnimplementedCasbinSourceServiceHooked) BeforeListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceBridger) ListPoliciesResult(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { +func (UnimplementedCasbinSourceServiceHooked) ListPoliciesResult(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { return ctx.Result(200, out) } -func (UnimplementedCasbinSourceServiceBridger) BeforeWatchUpdate(ctx http.Context, in *WatchUpdateRequest) (context.Context, error) { +func (UnimplementedCasbinSourceServiceHooked) BeforeWatchUpdate(ctx http.Context, in *WatchUpdateRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceBridger) WatchUpdateResult(ctx http.Context, in *WatchUpdateRequest, out *WatchUpdateResponse) error { +func (UnimplementedCasbinSourceServiceHooked) WatchUpdateResult(ctx http.Context, in *WatchUpdateRequest, out *WatchUpdateResponse) error { return ctx.Result(200, out) } +func WithCasbinSourceServiceHook(h CasbinSourceServiceHooker) func(CasbinSourceServiceBridger) CasbinSourceServiceHookedBridger { + return func(b CasbinSourceServiceBridger) CasbinSourceServiceHookedBridger { + return CasbinSourceServiceHookedBridge{CasbinSourceServiceBridger: b, CasbinSourceServiceHooker: h} + } +} + +// CasbinSourceServiceHookedBridge is a bridge between the HTTP and gRPC implementations of CasbinSourceService. +// It implements the HTTP and gRPC implementations of CasbinSourceService. +// It forwards requests and responses between the two implementations. +type CasbinSourceServiceHookedBridge struct { + CasbinSourceServiceBridger + CasbinSourceServiceHooker +} + type CasbinSourceServiceHTTPBridgeImpl struct { client CasbinSourceServiceHTTPClient } diff --git a/api/v1/services/system/department.pb.go b/api/v1/services/system/department.pb.go index cefa38dc..7344a00b 100644 --- a/api/v1/services/system/department.pb.go +++ b/api/v1/services/system/department.pb.go @@ -12,10 +12,10 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" unsafe "unsafe" - types "v1/services/types" ) const ( @@ -655,8 +655,8 @@ const file_system_department_proto_rawDesc = "" + "department\"\x10/sys/departments\x12\xab\x01\n" + "\x10UpdateDepartment\x12/.api.v1.services.system.UpdateDepartmentRequest\x1a0.api.v1.services.system.UpdateDepartmentResponse\"4\x82\xd3\xe4\x93\x02.:\n" + "department\x1a /sys/departments/{department.id}\x12\x94\x01\n" + - "\x10DeleteDepartment\x12/.api.v1.services.system.DeleteDepartmentRequest\x1a0.api.v1.services.system.DeleteDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/departments/{id}B\xc4\x01\n" + - "\x1acom.api.v1.services.systemB\x0fDepartmentProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x10DeleteDepartment\x12/.api.v1.services.system.DeleteDepartmentRequest\x1a0.api.v1.services.system.DeleteDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/departments/{id}B\xc8\x01\n" + + "\x1acom.api.v1.services.systemB\x0fDepartmentProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_department_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go index 289d83de..f149294b 100644 --- a/api/v1/services/system/department_bridge.pb.go +++ b/api/v1/services/system/department_bridge.pb.go @@ -33,34 +33,49 @@ type DepartmentServiceBridger interface { UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) } -type DepartmentServiceBridgeHooker interface { +type DepartmentServiceHooker interface { + DepartmentServiceCreateDepartmentHooker + DepartmentServiceDeleteDepartmentHooker + DepartmentServiceGetDepartmentHooker + DepartmentServiceListDepartmentsHooker + DepartmentServiceUpdateDepartmentHooker +} + +type DepartmentServiceHookedBridger interface { + DepartmentServiceHooker DepartmentServiceBridger +} +type DepartmentServiceCreateDepartmentHooker interface { BeforeCreateDepartment(http.Context, *CreateDepartmentRequest) (context.Context, error) CreateDepartmentResult(http.Context, *CreateDepartmentRequest, *CreateDepartmentResponse) error +} +type DepartmentServiceDeleteDepartmentHooker interface { BeforeDeleteDepartment(http.Context, *DeleteDepartmentRequest) (context.Context, error) DeleteDepartmentResult(http.Context, *DeleteDepartmentRequest, *DeleteDepartmentResponse) error +} +type DepartmentServiceGetDepartmentHooker interface { BeforeGetDepartment(http.Context, *GetDepartmentRequest) (context.Context, error) GetDepartmentResult(http.Context, *GetDepartmentRequest, *GetDepartmentResponse) error +} +type DepartmentServiceListDepartmentsHooker interface { BeforeListDepartments(http.Context, *ListDepartmentsRequest) (context.Context, error) ListDepartmentsResult(http.Context, *ListDepartmentsRequest, *ListDepartmentsResponse) error +} +type DepartmentServiceUpdateDepartmentHooker interface { BeforeUpdateDepartment(http.Context, *UpdateDepartmentRequest) (context.Context, error) UpdateDepartmentResult(http.Context, *UpdateDepartmentRequest, *UpdateDepartmentResponse) error } -func RegisterDepartmentServiceBridger(s *http.Server, srv DepartmentServiceBridger) { +func RegisterDepartmentServiceBridger(s *http.Server, srv DepartmentServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(DepartmentServiceBridgeHooker) - if !ok { - hook = UnimplementedDepartmentServiceBridger{DepartmentServiceBridger: srv} - } - r.GET("/sys/departments", _DepartmentService_ListDepartments0_Bridge_Handler(hook)) - r.GET("/sys/departments/:id", _DepartmentService_GetDepartment0_Bridge_Handler(hook)) - r.POST("/sys/departments", _DepartmentService_CreateDepartment0_Bridge_Handler(hook)) - r.PUT("/sys/departments/:department.id", _DepartmentService_UpdateDepartment0_Bridge_Handler(hook)) - r.DELETE("/sys/departments/:id", _DepartmentService_DeleteDepartment0_Bridge_Handler(hook)) + r.GET("/sys/departments", _DepartmentService_ListDepartments0_Bridge_Handler(srv)) + r.GET("/sys/departments/:id", _DepartmentService_GetDepartment0_Bridge_Handler(srv)) + r.POST("/sys/departments", _DepartmentService_CreateDepartment0_Bridge_Handler(srv)) + r.PUT("/sys/departments/:department.id", _DepartmentService_UpdateDepartment0_Bridge_Handler(srv)) + r.DELETE("/sys/departments/:id", _DepartmentService_DeleteDepartment0_Bridge_Handler(srv)) } -func _DepartmentService_ListDepartments0_Bridge_Handler(srv DepartmentServiceBridgeHooker) func(ctx http.Context) error { +func _DepartmentService_ListDepartments0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListDepartmentsRequest if err := ctx.BindQuery(&in); err != nil { @@ -83,7 +98,7 @@ func _DepartmentService_ListDepartments0_Bridge_Handler(srv DepartmentServiceBri } } -func _DepartmentService_GetDepartment0_Bridge_Handler(srv DepartmentServiceBridgeHooker) func(ctx http.Context) error { +func _DepartmentService_GetDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetDepartmentRequest if err := ctx.BindQuery(&in); err != nil { @@ -109,7 +124,7 @@ func _DepartmentService_GetDepartment0_Bridge_Handler(srv DepartmentServiceBridg } } -func _DepartmentService_CreateDepartment0_Bridge_Handler(srv DepartmentServiceBridgeHooker) func(ctx http.Context) error { +func _DepartmentService_CreateDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateDepartmentRequest if err := ctx.Bind(&in.Department); err != nil { @@ -135,7 +150,7 @@ func _DepartmentService_CreateDepartment0_Bridge_Handler(srv DepartmentServiceBr } } -func _DepartmentService_UpdateDepartment0_Bridge_Handler(srv DepartmentServiceBridgeHooker) func(ctx http.Context) error { +func _DepartmentService_UpdateDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateDepartmentRequest if err := ctx.Bind(&in.Department); err != nil { @@ -164,7 +179,7 @@ func _DepartmentService_UpdateDepartment0_Bridge_Handler(srv DepartmentServiceBr } } -func _DepartmentService_DeleteDepartment0_Bridge_Handler(srv DepartmentServiceBridgeHooker) func(ctx http.Context) error { +func _DepartmentService_DeleteDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in DeleteDepartmentRequest if err := ctx.BindQuery(&in); err != nil { @@ -190,55 +205,67 @@ func _DepartmentService_DeleteDepartment0_Bridge_Handler(srv DepartmentServiceBr } } -// UnimplementedDepartmentServiceBridger must be embedded to have +// UnimplementedDepartmentServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedDepartmentServiceBridger struct { - DepartmentServiceBridger -} +type UnimplementedDepartmentServiceHooked struct{} -func (UnimplementedDepartmentServiceBridger) BeforeCreateDepartment(ctx http.Context, in *CreateDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) BeforeCreateDepartment(ctx http.Context, in *CreateDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceBridger) CreateDepartmentResult(ctx http.Context, in *CreateDepartmentRequest, out *CreateDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) CreateDepartmentResult(ctx http.Context, in *CreateDepartmentRequest, out *CreateDepartmentResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceBridger) BeforeDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) BeforeDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceBridger) DeleteDepartmentResult(ctx http.Context, in *DeleteDepartmentRequest, out *DeleteDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) DeleteDepartmentResult(ctx http.Context, in *DeleteDepartmentRequest, out *DeleteDepartmentResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceBridger) BeforeGetDepartment(ctx http.Context, in *GetDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) BeforeGetDepartment(ctx http.Context, in *GetDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceBridger) GetDepartmentResult(ctx http.Context, in *GetDepartmentRequest, out *GetDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) GetDepartmentResult(ctx http.Context, in *GetDepartmentRequest, out *GetDepartmentResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceBridger) BeforeListDepartments(ctx http.Context, in *ListDepartmentsRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) BeforeListDepartments(ctx http.Context, in *ListDepartmentsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceBridger) ListDepartmentsResult(ctx http.Context, in *ListDepartmentsRequest, out *ListDepartmentsResponse) error { +func (UnimplementedDepartmentServiceHooked) ListDepartmentsResult(ctx http.Context, in *ListDepartmentsRequest, out *ListDepartmentsResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceBridger) BeforeUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) BeforeUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceBridger) UpdateDepartmentResult(ctx http.Context, in *UpdateDepartmentRequest, out *UpdateDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) UpdateDepartmentResult(ctx http.Context, in *UpdateDepartmentRequest, out *UpdateDepartmentResponse) error { return ctx.Result(200, out) } +func WithDepartmentServiceHook(h DepartmentServiceHooker) func(DepartmentServiceBridger) DepartmentServiceHookedBridger { + return func(b DepartmentServiceBridger) DepartmentServiceHookedBridger { + return DepartmentServiceHookedBridge{DepartmentServiceBridger: b, DepartmentServiceHooker: h} + } +} + +// DepartmentServiceHookedBridge is a bridge between the HTTP and gRPC implementations of DepartmentService. +// It implements the HTTP and gRPC implementations of DepartmentService. +// It forwards requests and responses between the two implementations. +type DepartmentServiceHookedBridge struct { + DepartmentServiceBridger + DepartmentServiceHooker +} + type DepartmentServiceHTTPBridgeImpl struct { client DepartmentServiceHTTPClient } diff --git a/api/v1/services/system/error.pb.go b/api/v1/services/system/error.pb.go index 8485f61a..9953b447 100644 --- a/api/v1/services/system/error.pb.go +++ b/api/v1/services/system/error.pb.go @@ -143,9 +143,9 @@ const file_system_error_proto_rawDesc = "" + "&SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID\x10\xea\a\x1a\x04\xa8E\x90\x03\x123\n" + "(SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE\x10\xeb\a\x1a\x04\xa8E\x90\x03\x12/\n" + "$SYSTEM_ERROR_REASON_INVALID_USERNAME\x10\xed\a\x1a\x04\xa8E\x90\x03\x12/\n" + - "$SYSTEM_ERROR_REASON_INVALID_PASSWORD\x10\xee\a\x1a\x04\xa8E\x90\x03\x1a\x04\xa0E\xf4\x03B\xbf\x01\n" + + "$SYSTEM_ERROR_REASON_INVALID_PASSWORD\x10\xee\a\x1a\x04\xa8E\x90\x03\x1a\x04\xa0E\xf4\x03B\xc3\x01\n" + "\x1acom.api.v1.services.systemB\n" + - "ErrorProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "ErrorProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_error_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/login.pb.go b/api/v1/services/system/login.pb.go index 742d4a36..eb1084e2 100644 --- a/api/v1/services/system/login.pb.go +++ b/api/v1/services/system/login.pb.go @@ -1352,9 +1352,9 @@ const file_system_login_proto_rawDesc = "" + "\x05Login\x12$.api.v1.services.system.LoginRequest\x1a%.api.v1.services.system.LoginResponse\"\x14\x82\xd3\xe4\x93\x02\x0e:\x04data\"\x06/login\x12n\n" + "\x06Logout\x12%.api.v1.services.system.LogoutRequest\x1a&.api.v1.services.system.LogoutResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/logout\x12v\n" + "\bRegister\x12'.api.v1.services.system.RegisterRequest\x1a(.api.v1.services.system.RegisterResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x04data\"\t/register\x12\x87\x01\n" + - "\fTokenRefresh\x12+.api.v1.services.system.TokenRefreshRequest\x1a,.api.v1.services.system.TokenRefreshResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04data\"\x0e/token/refreshB\xbf\x01\n" + + "\fTokenRefresh\x12+.api.v1.services.system.TokenRefreshRequest\x1a,.api.v1.services.system.TokenRefreshResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04data\"\x0e/token/refreshB\xc3\x01\n" + "\x1acom.api.v1.services.systemB\n" + - "LoginProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "LoginProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_login_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/login_bridge.pb.go b/api/v1/services/system/login_bridge.pb.go index 35db2ef5..0afe3245 100644 --- a/api/v1/services/system/login_bridge.pb.go +++ b/api/v1/services/system/login_bridge.pb.go @@ -39,43 +39,67 @@ type LoginServiceBridger interface { TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) } -type LoginServiceBridgeHooker interface { +type LoginServiceHooker interface { + LoginServiceCaptchaHooker + LoginServiceCaptchaAudioHooker + LoginServiceCaptchaIdHooker + LoginServiceCaptchaImageHooker + LoginServiceLoginHooker + LoginServiceLogoutHooker + LoginServiceRegisterHooker + LoginServiceTokenRefreshHooker +} + +type LoginServiceHookedBridger interface { + LoginServiceHooker LoginServiceBridger +} +type LoginServiceCaptchaHooker interface { BeforeCaptcha(http.Context, *CaptchaRequest) (context.Context, error) CaptchaResult(http.Context, *CaptchaRequest, *CaptchaResponse) error +} +type LoginServiceCaptchaAudioHooker interface { BeforeCaptchaAudio(http.Context, *CaptchaAudioRequest) (context.Context, error) CaptchaAudioResult(http.Context, *CaptchaAudioRequest, *CaptchaAudioResponse) error +} +type LoginServiceCaptchaIdHooker interface { BeforeCaptchaId(http.Context, *CaptchaIdRequest) (context.Context, error) CaptchaIdResult(http.Context, *CaptchaIdRequest, *CaptchaIdResponse) error +} +type LoginServiceCaptchaImageHooker interface { BeforeCaptchaImage(http.Context, *CaptchaImageRequest) (context.Context, error) CaptchaImageResult(http.Context, *CaptchaImageRequest, *CaptchaImageResponse) error +} +type LoginServiceLoginHooker interface { BeforeLogin(http.Context, *LoginRequest) (context.Context, error) LoginResult(http.Context, *LoginRequest, *LoginResponse) error +} +type LoginServiceLogoutHooker interface { BeforeLogout(http.Context, *LogoutRequest) (context.Context, error) LogoutResult(http.Context, *LogoutRequest, *LogoutResponse) error +} +type LoginServiceRegisterHooker interface { BeforeRegister(http.Context, *RegisterRequest) (context.Context, error) RegisterResult(http.Context, *RegisterRequest, *RegisterResponse) error +} +type LoginServiceTokenRefreshHooker interface { BeforeTokenRefresh(http.Context, *TokenRefreshRequest) (context.Context, error) TokenRefreshResult(http.Context, *TokenRefreshRequest, *TokenRefreshResponse) error } -func RegisterLoginServiceBridger(s *http.Server, srv LoginServiceBridger) { +func RegisterLoginServiceBridger(s *http.Server, srv LoginServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(LoginServiceBridgeHooker) - if !ok { - hook = UnimplementedLoginServiceBridger{LoginServiceBridger: srv} - } - r.GET("/captcha", _LoginService_Captcha0_Bridge_Handler(hook)) - r.GET("/captcha/id", _LoginService_CaptchaId0_Bridge_Handler(hook)) - r.GET("/captcha/image", _LoginService_CaptchaImage0_Bridge_Handler(hook)) - r.GET("/captcha/audio", _LoginService_CaptchaAudio0_Bridge_Handler(hook)) - r.POST("/login", _LoginService_Login0_Bridge_Handler(hook)) - r.POST("/logout", _LoginService_Logout0_Bridge_Handler(hook)) - r.POST("/register", _LoginService_Register0_Bridge_Handler(hook)) - r.POST("/token/refresh", _LoginService_TokenRefresh0_Bridge_Handler(hook)) + r.GET("/captcha", _LoginService_Captcha0_Bridge_Handler(srv)) + r.GET("/captcha/id", _LoginService_CaptchaId0_Bridge_Handler(srv)) + r.GET("/captcha/image", _LoginService_CaptchaImage0_Bridge_Handler(srv)) + r.GET("/captcha/audio", _LoginService_CaptchaAudio0_Bridge_Handler(srv)) + r.POST("/login", _LoginService_Login0_Bridge_Handler(srv)) + r.POST("/logout", _LoginService_Logout0_Bridge_Handler(srv)) + r.POST("/register", _LoginService_Register0_Bridge_Handler(srv)) + r.POST("/token/refresh", _LoginService_TokenRefresh0_Bridge_Handler(srv)) } -func _LoginService_Captcha0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { +func _LoginService_Captcha0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CaptchaRequest if err := ctx.BindQuery(&in); err != nil { @@ -98,7 +122,7 @@ func _LoginService_Captcha0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ct } } -func _LoginService_CaptchaId0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { +func _LoginService_CaptchaId0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CaptchaIdRequest if err := ctx.BindQuery(&in); err != nil { @@ -121,7 +145,7 @@ func _LoginService_CaptchaId0_Bridge_Handler(srv LoginServiceBridgeHooker) func( } } -func _LoginService_CaptchaImage0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { +func _LoginService_CaptchaImage0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CaptchaImageRequest if err := ctx.BindQuery(&in); err != nil { @@ -144,7 +168,7 @@ func _LoginService_CaptchaImage0_Bridge_Handler(srv LoginServiceBridgeHooker) fu } } -func _LoginService_CaptchaAudio0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { +func _LoginService_CaptchaAudio0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CaptchaAudioRequest if err := ctx.BindQuery(&in); err != nil { @@ -167,7 +191,7 @@ func _LoginService_CaptchaAudio0_Bridge_Handler(srv LoginServiceBridgeHooker) fu } } -func _LoginService_Login0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { +func _LoginService_Login0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in LoginRequest if err := ctx.Bind(&in.Data); err != nil { @@ -193,7 +217,7 @@ func _LoginService_Login0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx } } -func _LoginService_Logout0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { +func _LoginService_Logout0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in LogoutRequest if err := ctx.Bind(&in.Data); err != nil { @@ -219,7 +243,7 @@ func _LoginService_Logout0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx } } -func _LoginService_Register0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { +func _LoginService_Register0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in RegisterRequest if err := ctx.Bind(&in.Data); err != nil { @@ -245,7 +269,7 @@ func _LoginService_Register0_Bridge_Handler(srv LoginServiceBridgeHooker) func(c } } -func _LoginService_TokenRefresh0_Bridge_Handler(srv LoginServiceBridgeHooker) func(ctx http.Context) error { +func _LoginService_TokenRefresh0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in TokenRefreshRequest if err := ctx.Bind(&in.Data); err != nil { @@ -271,79 +295,91 @@ func _LoginService_TokenRefresh0_Bridge_Handler(srv LoginServiceBridgeHooker) fu } } -// UnimplementedLoginServiceBridger must be embedded to have +// UnimplementedLoginServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedLoginServiceBridger struct { - LoginServiceBridger -} +type UnimplementedLoginServiceHooked struct{} -func (UnimplementedLoginServiceBridger) BeforeCaptcha(ctx http.Context, in *CaptchaRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) BeforeCaptcha(ctx http.Context, in *CaptchaRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceBridger) CaptchaResult(ctx http.Context, in *CaptchaRequest, out *CaptchaResponse) error { +func (UnimplementedLoginServiceHooked) CaptchaResult(ctx http.Context, in *CaptchaRequest, out *CaptchaResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceBridger) BeforeCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) BeforeCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceBridger) CaptchaAudioResult(ctx http.Context, in *CaptchaAudioRequest, out *CaptchaAudioResponse) error { +func (UnimplementedLoginServiceHooked) CaptchaAudioResult(ctx http.Context, in *CaptchaAudioRequest, out *CaptchaAudioResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceBridger) BeforeCaptchaId(ctx http.Context, in *CaptchaIdRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) BeforeCaptchaId(ctx http.Context, in *CaptchaIdRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceBridger) CaptchaIdResult(ctx http.Context, in *CaptchaIdRequest, out *CaptchaIdResponse) error { +func (UnimplementedLoginServiceHooked) CaptchaIdResult(ctx http.Context, in *CaptchaIdRequest, out *CaptchaIdResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceBridger) BeforeCaptchaImage(ctx http.Context, in *CaptchaImageRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) BeforeCaptchaImage(ctx http.Context, in *CaptchaImageRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceBridger) CaptchaImageResult(ctx http.Context, in *CaptchaImageRequest, out *CaptchaImageResponse) error { +func (UnimplementedLoginServiceHooked) CaptchaImageResult(ctx http.Context, in *CaptchaImageRequest, out *CaptchaImageResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceBridger) BeforeLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) BeforeLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceBridger) LoginResult(ctx http.Context, in *LoginRequest, out *LoginResponse) error { +func (UnimplementedLoginServiceHooked) LoginResult(ctx http.Context, in *LoginRequest, out *LoginResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceBridger) BeforeLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) BeforeLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceBridger) LogoutResult(ctx http.Context, in *LogoutRequest, out *LogoutResponse) error { +func (UnimplementedLoginServiceHooked) LogoutResult(ctx http.Context, in *LogoutRequest, out *LogoutResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceBridger) BeforeRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) BeforeRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceBridger) RegisterResult(ctx http.Context, in *RegisterRequest, out *RegisterResponse) error { +func (UnimplementedLoginServiceHooked) RegisterResult(ctx http.Context, in *RegisterRequest, out *RegisterResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceBridger) BeforeTokenRefresh(ctx http.Context, in *TokenRefreshRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) BeforeTokenRefresh(ctx http.Context, in *TokenRefreshRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceBridger) TokenRefreshResult(ctx http.Context, in *TokenRefreshRequest, out *TokenRefreshResponse) error { +func (UnimplementedLoginServiceHooked) TokenRefreshResult(ctx http.Context, in *TokenRefreshRequest, out *TokenRefreshResponse) error { return ctx.Result(200, out) } +func WithLoginServiceHook(h LoginServiceHooker) func(LoginServiceBridger) LoginServiceHookedBridger { + return func(b LoginServiceBridger) LoginServiceHookedBridger { + return LoginServiceHookedBridge{LoginServiceBridger: b, LoginServiceHooker: h} + } +} + +// LoginServiceHookedBridge is a bridge between the HTTP and gRPC implementations of LoginService. +// It implements the HTTP and gRPC implementations of LoginService. +// It forwards requests and responses between the two implementations. +type LoginServiceHookedBridge struct { + LoginServiceBridger + LoginServiceHooker +} + type LoginServiceHTTPBridgeImpl struct { client LoginServiceHTTPClient } diff --git a/api/v1/services/system/menu.pb.go b/api/v1/services/system/menu.pb.go index f2096c73..38a276f0 100644 --- a/api/v1/services/system/menu.pb.go +++ b/api/v1/services/system/menu.pb.go @@ -12,10 +12,10 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" unsafe "unsafe" - types "v1/services/types" ) const ( @@ -648,8 +648,8 @@ const file_system_menu_proto_rawDesc = "" + "\n" + "UpdateMenu\x12).api.v1.services.system.UpdateMenuRequest\x1a*.api.v1.services.system.UpdateMenuResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04menu\x1a\x14/sys/menus/{menu.id}\x12|\n" + "\n" + - "DeleteMenu\x12).api.v1.services.system.DeleteMenuRequest\x1a*.api.v1.services.system.DeleteMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/menus/{id}B\xbe\x01\n" + - "\x1acom.api.v1.services.systemB\tMenuProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "DeleteMenu\x12).api.v1.services.system.DeleteMenuRequest\x1a*.api.v1.services.system.DeleteMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/menus/{id}B\xc2\x01\n" + + "\x1acom.api.v1.services.systemB\tMenuProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_menu_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/menu_bridge.pb.go b/api/v1/services/system/menu_bridge.pb.go index f0176ce7..3683c8ae 100644 --- a/api/v1/services/system/menu_bridge.pb.go +++ b/api/v1/services/system/menu_bridge.pb.go @@ -33,34 +33,49 @@ type MenuServiceBridger interface { UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) } -type MenuServiceBridgeHooker interface { +type MenuServiceHooker interface { + MenuServiceCreateMenuHooker + MenuServiceDeleteMenuHooker + MenuServiceGetMenuHooker + MenuServiceListMenusHooker + MenuServiceUpdateMenuHooker +} + +type MenuServiceHookedBridger interface { + MenuServiceHooker MenuServiceBridger +} +type MenuServiceCreateMenuHooker interface { BeforeCreateMenu(http.Context, *CreateMenuRequest) (context.Context, error) CreateMenuResult(http.Context, *CreateMenuRequest, *CreateMenuResponse) error +} +type MenuServiceDeleteMenuHooker interface { BeforeDeleteMenu(http.Context, *DeleteMenuRequest) (context.Context, error) DeleteMenuResult(http.Context, *DeleteMenuRequest, *DeleteMenuResponse) error +} +type MenuServiceGetMenuHooker interface { BeforeGetMenu(http.Context, *GetMenuRequest) (context.Context, error) GetMenuResult(http.Context, *GetMenuRequest, *GetMenuResponse) error +} +type MenuServiceListMenusHooker interface { BeforeListMenus(http.Context, *ListMenusRequest) (context.Context, error) ListMenusResult(http.Context, *ListMenusRequest, *ListMenusResponse) error +} +type MenuServiceUpdateMenuHooker interface { BeforeUpdateMenu(http.Context, *UpdateMenuRequest) (context.Context, error) UpdateMenuResult(http.Context, *UpdateMenuRequest, *UpdateMenuResponse) error } -func RegisterMenuServiceBridger(s *http.Server, srv MenuServiceBridger) { +func RegisterMenuServiceBridger(s *http.Server, srv MenuServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(MenuServiceBridgeHooker) - if !ok { - hook = UnimplementedMenuServiceBridger{MenuServiceBridger: srv} - } - r.GET("/sys/menus", _MenuService_ListMenus0_Bridge_Handler(hook)) - r.GET("/sys/menus/:id", _MenuService_GetMenu0_Bridge_Handler(hook)) - r.POST("/sys/menus", _MenuService_CreateMenu0_Bridge_Handler(hook)) - r.PUT("/sys/menus/:menu.id", _MenuService_UpdateMenu0_Bridge_Handler(hook)) - r.DELETE("/sys/menus/:id", _MenuService_DeleteMenu0_Bridge_Handler(hook)) + r.GET("/sys/menus", _MenuService_ListMenus0_Bridge_Handler(srv)) + r.GET("/sys/menus/:id", _MenuService_GetMenu0_Bridge_Handler(srv)) + r.POST("/sys/menus", _MenuService_CreateMenu0_Bridge_Handler(srv)) + r.PUT("/sys/menus/:menu.id", _MenuService_UpdateMenu0_Bridge_Handler(srv)) + r.DELETE("/sys/menus/:id", _MenuService_DeleteMenu0_Bridge_Handler(srv)) } -func _MenuService_ListMenus0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx http.Context) error { +func _MenuService_ListMenus0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListMenusRequest if err := ctx.BindQuery(&in); err != nil { @@ -83,7 +98,7 @@ func _MenuService_ListMenus0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ct } } -func _MenuService_GetMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx http.Context) error { +func _MenuService_GetMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetMenuRequest if err := ctx.BindQuery(&in); err != nil { @@ -109,7 +124,7 @@ func _MenuService_GetMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx } } -func _MenuService_CreateMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx http.Context) error { +func _MenuService_CreateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateMenuRequest if err := ctx.Bind(&in.Menu); err != nil { @@ -135,7 +150,7 @@ func _MenuService_CreateMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(c } } -func _MenuService_UpdateMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx http.Context) error { +func _MenuService_UpdateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateMenuRequest if err := ctx.Bind(&in.Menu); err != nil { @@ -164,7 +179,7 @@ func _MenuService_UpdateMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(c } } -func _MenuService_DeleteMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(ctx http.Context) error { +func _MenuService_DeleteMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in DeleteMenuRequest if err := ctx.BindQuery(&in); err != nil { @@ -190,55 +205,67 @@ func _MenuService_DeleteMenu0_Bridge_Handler(srv MenuServiceBridgeHooker) func(c } } -// UnimplementedMenuServiceBridger must be embedded to have +// UnimplementedMenuServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedMenuServiceBridger struct { - MenuServiceBridger -} +type UnimplementedMenuServiceHooked struct{} -func (UnimplementedMenuServiceBridger) BeforeCreateMenu(ctx http.Context, in *CreateMenuRequest) (context.Context, error) { +func (UnimplementedMenuServiceHooked) BeforeCreateMenu(ctx http.Context, in *CreateMenuRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMenuServiceBridger) CreateMenuResult(ctx http.Context, in *CreateMenuRequest, out *CreateMenuResponse) error { +func (UnimplementedMenuServiceHooked) CreateMenuResult(ctx http.Context, in *CreateMenuRequest, out *CreateMenuResponse) error { return ctx.Result(200, out) } -func (UnimplementedMenuServiceBridger) BeforeDeleteMenu(ctx http.Context, in *DeleteMenuRequest) (context.Context, error) { +func (UnimplementedMenuServiceHooked) BeforeDeleteMenu(ctx http.Context, in *DeleteMenuRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMenuServiceBridger) DeleteMenuResult(ctx http.Context, in *DeleteMenuRequest, out *DeleteMenuResponse) error { +func (UnimplementedMenuServiceHooked) DeleteMenuResult(ctx http.Context, in *DeleteMenuRequest, out *DeleteMenuResponse) error { return ctx.Result(200, out) } -func (UnimplementedMenuServiceBridger) BeforeGetMenu(ctx http.Context, in *GetMenuRequest) (context.Context, error) { +func (UnimplementedMenuServiceHooked) BeforeGetMenu(ctx http.Context, in *GetMenuRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMenuServiceBridger) GetMenuResult(ctx http.Context, in *GetMenuRequest, out *GetMenuResponse) error { +func (UnimplementedMenuServiceHooked) GetMenuResult(ctx http.Context, in *GetMenuRequest, out *GetMenuResponse) error { return ctx.Result(200, out) } -func (UnimplementedMenuServiceBridger) BeforeListMenus(ctx http.Context, in *ListMenusRequest) (context.Context, error) { +func (UnimplementedMenuServiceHooked) BeforeListMenus(ctx http.Context, in *ListMenusRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMenuServiceBridger) ListMenusResult(ctx http.Context, in *ListMenusRequest, out *ListMenusResponse) error { +func (UnimplementedMenuServiceHooked) ListMenusResult(ctx http.Context, in *ListMenusRequest, out *ListMenusResponse) error { return ctx.Result(200, out) } -func (UnimplementedMenuServiceBridger) BeforeUpdateMenu(ctx http.Context, in *UpdateMenuRequest) (context.Context, error) { +func (UnimplementedMenuServiceHooked) BeforeUpdateMenu(ctx http.Context, in *UpdateMenuRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMenuServiceBridger) UpdateMenuResult(ctx http.Context, in *UpdateMenuRequest, out *UpdateMenuResponse) error { +func (UnimplementedMenuServiceHooked) UpdateMenuResult(ctx http.Context, in *UpdateMenuRequest, out *UpdateMenuResponse) error { return ctx.Result(200, out) } +func WithMenuServiceHook(h MenuServiceHooker) func(MenuServiceBridger) MenuServiceHookedBridger { + return func(b MenuServiceBridger) MenuServiceHookedBridger { + return MenuServiceHookedBridge{MenuServiceBridger: b, MenuServiceHooker: h} + } +} + +// MenuServiceHookedBridge is a bridge between the HTTP and gRPC implementations of MenuService. +// It implements the HTTP and gRPC implementations of MenuService. +// It forwards requests and responses between the two implementations. +type MenuServiceHookedBridge struct { + MenuServiceBridger + MenuServiceHooker +} + type MenuServiceHTTPBridgeImpl struct { client MenuServiceHTTPClient } diff --git a/api/v1/services/system/permission.pb.go b/api/v1/services/system/permission.pb.go index 44617a30..c949663c 100644 --- a/api/v1/services/system/permission.pb.go +++ b/api/v1/services/system/permission.pb.go @@ -12,10 +12,10 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" unsafe "unsafe" - types "v1/services/types" ) const ( @@ -665,8 +665,8 @@ const file_system_permission_proto_rawDesc = "" + "permission\"\x10/sys/permissions\x12\xab\x01\n" + "\x10UpdatePermission\x12/.api.v1.services.system.UpdatePermissionRequest\x1a0.api.v1.services.system.UpdatePermissionResponse\"4\x82\xd3\xe4\x93\x02.:\n" + "permission\x1a /sys/permissions/{permission.id}\x12\x94\x01\n" + - "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xc4\x01\n" + - "\x1acom.api.v1.services.systemB\x0fPermissionProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xc8\x01\n" + + "\x1acom.api.v1.services.systemB\x0fPermissionProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_permission_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go index 3150bd4f..16fdbe2f 100644 --- a/api/v1/services/system/permission_bridge.pb.go +++ b/api/v1/services/system/permission_bridge.pb.go @@ -33,34 +33,49 @@ type PermissionServiceBridger interface { UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) } -type PermissionServiceBridgeHooker interface { +type PermissionServiceHooker interface { + PermissionServiceCreatePermissionHooker + PermissionServiceDeletePermissionHooker + PermissionServiceGetPermissionHooker + PermissionServiceListPermissionsHooker + PermissionServiceUpdatePermissionHooker +} + +type PermissionServiceHookedBridger interface { + PermissionServiceHooker PermissionServiceBridger +} +type PermissionServiceCreatePermissionHooker interface { BeforeCreatePermission(http.Context, *CreatePermissionRequest) (context.Context, error) CreatePermissionResult(http.Context, *CreatePermissionRequest, *CreatePermissionResponse) error +} +type PermissionServiceDeletePermissionHooker interface { BeforeDeletePermission(http.Context, *DeletePermissionRequest) (context.Context, error) DeletePermissionResult(http.Context, *DeletePermissionRequest, *DeletePermissionResponse) error +} +type PermissionServiceGetPermissionHooker interface { BeforeGetPermission(http.Context, *GetPermissionRequest) (context.Context, error) GetPermissionResult(http.Context, *GetPermissionRequest, *GetPermissionResponse) error +} +type PermissionServiceListPermissionsHooker interface { BeforeListPermissions(http.Context, *ListPermissionsRequest) (context.Context, error) ListPermissionsResult(http.Context, *ListPermissionsRequest, *ListPermissionsResponse) error +} +type PermissionServiceUpdatePermissionHooker interface { BeforeUpdatePermission(http.Context, *UpdatePermissionRequest) (context.Context, error) UpdatePermissionResult(http.Context, *UpdatePermissionRequest, *UpdatePermissionResponse) error } -func RegisterPermissionServiceBridger(s *http.Server, srv PermissionServiceBridger) { +func RegisterPermissionServiceBridger(s *http.Server, srv PermissionServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(PermissionServiceBridgeHooker) - if !ok { - hook = UnimplementedPermissionServiceBridger{PermissionServiceBridger: srv} - } - r.GET("/sys/permissions", _PermissionService_ListPermissions0_Bridge_Handler(hook)) - r.GET("/sys/permissions/:id", _PermissionService_GetPermission0_Bridge_Handler(hook)) - r.POST("/sys/permissions", _PermissionService_CreatePermission0_Bridge_Handler(hook)) - r.PUT("/sys/permissions/:permission.id", _PermissionService_UpdatePermission0_Bridge_Handler(hook)) - r.DELETE("/sys/permissions/:id", _PermissionService_DeletePermission0_Bridge_Handler(hook)) + r.GET("/sys/permissions", _PermissionService_ListPermissions0_Bridge_Handler(srv)) + r.GET("/sys/permissions/:id", _PermissionService_GetPermission0_Bridge_Handler(srv)) + r.POST("/sys/permissions", _PermissionService_CreatePermission0_Bridge_Handler(srv)) + r.PUT("/sys/permissions/:permission.id", _PermissionService_UpdatePermission0_Bridge_Handler(srv)) + r.DELETE("/sys/permissions/:id", _PermissionService_DeletePermission0_Bridge_Handler(srv)) } -func _PermissionService_ListPermissions0_Bridge_Handler(srv PermissionServiceBridgeHooker) func(ctx http.Context) error { +func _PermissionService_ListPermissions0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListPermissionsRequest if err := ctx.BindQuery(&in); err != nil { @@ -83,7 +98,7 @@ func _PermissionService_ListPermissions0_Bridge_Handler(srv PermissionServiceBri } } -func _PermissionService_GetPermission0_Bridge_Handler(srv PermissionServiceBridgeHooker) func(ctx http.Context) error { +func _PermissionService_GetPermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetPermissionRequest if err := ctx.BindQuery(&in); err != nil { @@ -109,7 +124,7 @@ func _PermissionService_GetPermission0_Bridge_Handler(srv PermissionServiceBridg } } -func _PermissionService_CreatePermission0_Bridge_Handler(srv PermissionServiceBridgeHooker) func(ctx http.Context) error { +func _PermissionService_CreatePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreatePermissionRequest if err := ctx.Bind(&in.Permission); err != nil { @@ -135,7 +150,7 @@ func _PermissionService_CreatePermission0_Bridge_Handler(srv PermissionServiceBr } } -func _PermissionService_UpdatePermission0_Bridge_Handler(srv PermissionServiceBridgeHooker) func(ctx http.Context) error { +func _PermissionService_UpdatePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdatePermissionRequest if err := ctx.Bind(&in.Permission); err != nil { @@ -164,7 +179,7 @@ func _PermissionService_UpdatePermission0_Bridge_Handler(srv PermissionServiceBr } } -func _PermissionService_DeletePermission0_Bridge_Handler(srv PermissionServiceBridgeHooker) func(ctx http.Context) error { +func _PermissionService_DeletePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in DeletePermissionRequest if err := ctx.BindQuery(&in); err != nil { @@ -190,55 +205,67 @@ func _PermissionService_DeletePermission0_Bridge_Handler(srv PermissionServiceBr } } -// UnimplementedPermissionServiceBridger must be embedded to have +// UnimplementedPermissionServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedPermissionServiceBridger struct { - PermissionServiceBridger -} +type UnimplementedPermissionServiceHooked struct{} -func (UnimplementedPermissionServiceBridger) BeforeCreatePermission(ctx http.Context, in *CreatePermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) BeforeCreatePermission(ctx http.Context, in *CreatePermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceBridger) CreatePermissionResult(ctx http.Context, in *CreatePermissionRequest, out *CreatePermissionResponse) error { +func (UnimplementedPermissionServiceHooked) CreatePermissionResult(ctx http.Context, in *CreatePermissionRequest, out *CreatePermissionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceBridger) BeforeDeletePermission(ctx http.Context, in *DeletePermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) BeforeDeletePermission(ctx http.Context, in *DeletePermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceBridger) DeletePermissionResult(ctx http.Context, in *DeletePermissionRequest, out *DeletePermissionResponse) error { +func (UnimplementedPermissionServiceHooked) DeletePermissionResult(ctx http.Context, in *DeletePermissionRequest, out *DeletePermissionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceBridger) BeforeGetPermission(ctx http.Context, in *GetPermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) BeforeGetPermission(ctx http.Context, in *GetPermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceBridger) GetPermissionResult(ctx http.Context, in *GetPermissionRequest, out *GetPermissionResponse) error { +func (UnimplementedPermissionServiceHooked) GetPermissionResult(ctx http.Context, in *GetPermissionRequest, out *GetPermissionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceBridger) BeforeListPermissions(ctx http.Context, in *ListPermissionsRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) BeforeListPermissions(ctx http.Context, in *ListPermissionsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceBridger) ListPermissionsResult(ctx http.Context, in *ListPermissionsRequest, out *ListPermissionsResponse) error { +func (UnimplementedPermissionServiceHooked) ListPermissionsResult(ctx http.Context, in *ListPermissionsRequest, out *ListPermissionsResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceBridger) BeforeUpdatePermission(ctx http.Context, in *UpdatePermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) BeforeUpdatePermission(ctx http.Context, in *UpdatePermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceBridger) UpdatePermissionResult(ctx http.Context, in *UpdatePermissionRequest, out *UpdatePermissionResponse) error { +func (UnimplementedPermissionServiceHooked) UpdatePermissionResult(ctx http.Context, in *UpdatePermissionRequest, out *UpdatePermissionResponse) error { return ctx.Result(200, out) } +func WithPermissionServiceHook(h PermissionServiceHooker) func(PermissionServiceBridger) PermissionServiceHookedBridger { + return func(b PermissionServiceBridger) PermissionServiceHookedBridger { + return PermissionServiceHookedBridge{PermissionServiceBridger: b, PermissionServiceHooker: h} + } +} + +// PermissionServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PermissionService. +// It implements the HTTP and gRPC implementations of PermissionService. +// It forwards requests and responses between the two implementations. +type PermissionServiceHookedBridge struct { + PermissionServiceBridger + PermissionServiceHooker +} + type PermissionServiceHTTPBridgeImpl struct { client PermissionServiceHTTPClient } diff --git a/api/v1/services/system/personal.pb.go b/api/v1/services/system/personal.pb.go index 06955179..edaac956 100644 --- a/api/v1/services/system/personal.pb.go +++ b/api/v1/services/system/personal.pb.go @@ -12,10 +12,10 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" + types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" unsafe "unsafe" - types "v1/services/types" ) const ( @@ -974,8 +974,8 @@ const file_system_personal_proto_rawDesc = "" + "\x14RefreshPersonalToken\x123.api.v1.services.system.RefreshPersonalTokenRequest\x1a4.api.v1.services.system.RefreshPersonalTokenResponse\")\x82\xd3\xe4\x93\x02#:\x04data\"\x1b/sys/personal/token/refresh\x12\xad\x01\n" + "\x16UpdatePersonalPassword\x125.api.v1.services.system.UpdatePersonalPasswordRequest\x1a6.api.v1.services.system.UpdatePersonalPasswordResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/sys/personal/password\x12\xa9\x01\n" + "\x15UpdatePersonalProfile\x124.api.v1.services.system.UpdatePersonalProfileRequest\x1a5.api.v1.services.system.UpdatePersonalProfileResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\x1a\x15/sys/personal/profile\x12\xa9\x01\n" + - "\x15UpdatePersonalSetting\x124.api.v1.services.system.UpdatePersonalSettingRequest\x1a5.api.v1.services.system.UpdatePersonalSettingResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\x1a\x15/sys/personal/settingB\xc2\x01\n" + - "\x1acom.api.v1.services.systemB\rPersonalProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x15UpdatePersonalSetting\x124.api.v1.services.system.UpdatePersonalSettingRequest\x1a5.api.v1.services.system.UpdatePersonalSettingResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\x1a\x15/sys/personal/settingB\xc6\x01\n" + + "\x1acom.api.v1.services.systemB\rPersonalProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_personal_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/personal_bridge.pb.go b/api/v1/services/system/personal_bridge.pb.go index 6ed17ec0..87e1dfff 100644 --- a/api/v1/services/system/personal_bridge.pb.go +++ b/api/v1/services/system/personal_bridge.pb.go @@ -47,51 +47,67 @@ type PersonalServiceBridger interface { UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) } -type PersonalServiceBridgeHooker interface { +type PersonalServiceHooker interface { + PersonalServiceGetPersonalProfileHooker + PersonalServiceListPersonalResourcesHooker + PersonalServiceListPersonalRolesHooker + PersonalServicePersonalLogoutHooker + PersonalServiceRefreshPersonalTokenHooker + PersonalServiceUpdatePersonalPasswordHooker + PersonalServiceUpdatePersonalProfileHooker + PersonalServiceUpdatePersonalSettingHooker +} + +type PersonalServiceHookedBridger interface { + PersonalServiceHooker PersonalServiceBridger - // GetPersonalProfile GetPersonalProfile Update the personal user information +} +type PersonalServiceGetPersonalProfileHooker interface { BeforeGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) GetPersonalProfileResult(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error - // ListPersonalResources ListPersonalResources List the personal user's menu +} +type PersonalServiceListPersonalResourcesHooker interface { BeforeListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) ListPersonalResourcesResult(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error - // ListPersonalRoles ListPersonalResources List the personal user's menu +} +type PersonalServiceListPersonalRolesHooker interface { BeforeListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) ListPersonalRolesResult(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error - // PersonalLogout PersonalLogout Personal user logs out +} +type PersonalServicePersonalLogoutHooker interface { BeforePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) PersonalLogoutResult(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error - // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token +} +type PersonalServiceRefreshPersonalTokenHooker interface { BeforeRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) RefreshPersonalTokenResult(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error - // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password +} +type PersonalServiceUpdatePersonalPasswordHooker interface { BeforeUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) UpdatePersonalPasswordResult(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error - // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information +} +type PersonalServiceUpdatePersonalProfileHooker interface { BeforeUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) UpdatePersonalProfileResult(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error - // UpdatePersonalSetting UpdatePersonalSetting User settings are saved +} +type PersonalServiceUpdatePersonalSettingHooker interface { BeforeUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) UpdatePersonalSettingResult(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error } -func RegisterPersonalServiceBridger(s *http.Server, srv PersonalServiceBridger) { +func RegisterPersonalServiceBridger(s *http.Server, srv PersonalServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(PersonalServiceBridgeHooker) - if !ok { - hook = UnimplementedPersonalServiceBridger{PersonalServiceBridger: srv} - } - r.GET("/sys/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(hook)) - r.GET("/sys/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(hook)) - r.GET("/sys/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(hook)) - r.POST("/sys/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(hook)) - r.POST("/sys/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(hook)) - r.PUT("/sys/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(hook)) - r.PUT("/sys/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(hook)) - r.PUT("/sys/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(hook)) + r.GET("/sys/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) + r.GET("/sys/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) + r.GET("/sys/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) + r.POST("/sys/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(srv)) + r.POST("/sys/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv)) + r.PUT("/sys/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv)) + r.PUT("/sys/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv)) + r.PUT("/sys/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv)) } -func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { +func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetPersonalProfileRequest if err := ctx.BindQuery(&in); err != nil { @@ -114,7 +130,7 @@ func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceBrid } } -func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { +func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListPersonalResourcesRequest if err := ctx.BindQuery(&in); err != nil { @@ -137,7 +153,7 @@ func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceB } } -func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { +func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListPersonalRolesRequest if err := ctx.BindQuery(&in); err != nil { @@ -160,7 +176,7 @@ func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceBridg } } -func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { +func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in PersonalLogoutRequest if err := ctx.Bind(&in.Data); err != nil { @@ -186,7 +202,7 @@ func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceBridgeHo } } -func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { +func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in RefreshPersonalTokenRequest if err := ctx.Bind(&in.Data); err != nil { @@ -212,7 +228,7 @@ func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceBr } } -func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { +func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdatePersonalPasswordRequest if err := ctx.Bind(&in.Data); err != nil { @@ -238,7 +254,7 @@ func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalService } } -func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { +func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdatePersonalProfileRequest if err := ctx.Bind(&in.Data); err != nil { @@ -264,7 +280,7 @@ func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceB } } -func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceBridgeHooker) func(ctx http.Context) error { +func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdatePersonalSettingRequest if err := ctx.Bind(&in.Data); err != nil { @@ -290,79 +306,91 @@ func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceB } } -// UnimplementedPersonalServiceBridger must be embedded to have +// UnimplementedPersonalServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedPersonalServiceBridger struct { - PersonalServiceBridger -} +type UnimplementedPersonalServiceHooked struct{} -func (UnimplementedPersonalServiceBridger) BeforeGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) BeforeGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceBridger) GetPersonalProfileResult(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { +func (UnimplementedPersonalServiceHooked) GetPersonalProfileResult(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceBridger) BeforeListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) BeforeListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceBridger) ListPersonalResourcesResult(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { +func (UnimplementedPersonalServiceHooked) ListPersonalResourcesResult(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceBridger) BeforeListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) BeforeListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceBridger) ListPersonalRolesResult(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { +func (UnimplementedPersonalServiceHooked) ListPersonalRolesResult(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceBridger) BeforePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) BeforePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceBridger) PersonalLogoutResult(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { +func (UnimplementedPersonalServiceHooked) PersonalLogoutResult(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceBridger) BeforeRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) BeforeRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceBridger) RefreshPersonalTokenResult(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { +func (UnimplementedPersonalServiceHooked) RefreshPersonalTokenResult(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceBridger) BeforeUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) BeforeUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceBridger) UpdatePersonalPasswordResult(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { +func (UnimplementedPersonalServiceHooked) UpdatePersonalPasswordResult(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceBridger) BeforeUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) BeforeUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceBridger) UpdatePersonalProfileResult(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { +func (UnimplementedPersonalServiceHooked) UpdatePersonalProfileResult(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceBridger) BeforeUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) BeforeUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceBridger) UpdatePersonalSettingResult(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { +func (UnimplementedPersonalServiceHooked) UpdatePersonalSettingResult(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { return ctx.Result(200, out) } +func WithPersonalServiceHook(h PersonalServiceHooker) func(PersonalServiceBridger) PersonalServiceHookedBridger { + return func(b PersonalServiceBridger) PersonalServiceHookedBridger { + return PersonalServiceHookedBridge{PersonalServiceBridger: b, PersonalServiceHooker: h} + } +} + +// PersonalServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PersonalService. +// It implements the HTTP and gRPC implementations of PersonalService. +// It forwards requests and responses between the two implementations. +type PersonalServiceHookedBridge struct { + PersonalServiceBridger + PersonalServiceHooker +} + type PersonalServiceHTTPBridgeImpl struct { client PersonalServiceHTTPClient } diff --git a/api/v1/services/system/position.pb.go b/api/v1/services/system/position.pb.go index cad9f951..9c5c63c3 100644 --- a/api/v1/services/system/position.pb.go +++ b/api/v1/services/system/position.pb.go @@ -12,10 +12,10 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" unsafe "unsafe" - types "v1/services/types" ) const ( @@ -642,8 +642,8 @@ const file_system_position_proto_rawDesc = "" + "\vGetPosition\x12*.api.v1.services.system.GetPositionRequest\x1a+.api.v1.services.system.GetPositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/positions/{id}\x12\x91\x01\n" + "\x0eCreatePosition\x12-.api.v1.services.system.CreatePositionRequest\x1a..api.v1.services.system.CreatePositionResponse\" \x82\xd3\xe4\x93\x02\x1a:\bposition\"\x0e/sys/positions\x12\x9f\x01\n" + "\x0eUpdatePosition\x12-.api.v1.services.system.UpdatePositionRequest\x1a..api.v1.services.system.UpdatePositionResponse\".\x82\xd3\xe4\x93\x02(:\bposition\x1a\x1c/sys/positions/{position.id}\x12\x8c\x01\n" + - "\x0eDeletePosition\x12-.api.v1.services.system.DeletePositionRequest\x1a..api.v1.services.system.DeletePositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/positions/{id}B\xc2\x01\n" + - "\x1acom.api.v1.services.systemB\rPositionProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x0eDeletePosition\x12-.api.v1.services.system.DeletePositionRequest\x1a..api.v1.services.system.DeletePositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/positions/{id}B\xc6\x01\n" + + "\x1acom.api.v1.services.systemB\rPositionProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_position_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go index d9897220..e52f5772 100644 --- a/api/v1/services/system/position_bridge.pb.go +++ b/api/v1/services/system/position_bridge.pb.go @@ -33,34 +33,49 @@ type PositionServiceBridger interface { UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) } -type PositionServiceBridgeHooker interface { +type PositionServiceHooker interface { + PositionServiceCreatePositionHooker + PositionServiceDeletePositionHooker + PositionServiceGetPositionHooker + PositionServiceListPositionsHooker + PositionServiceUpdatePositionHooker +} + +type PositionServiceHookedBridger interface { + PositionServiceHooker PositionServiceBridger +} +type PositionServiceCreatePositionHooker interface { BeforeCreatePosition(http.Context, *CreatePositionRequest) (context.Context, error) CreatePositionResult(http.Context, *CreatePositionRequest, *CreatePositionResponse) error +} +type PositionServiceDeletePositionHooker interface { BeforeDeletePosition(http.Context, *DeletePositionRequest) (context.Context, error) DeletePositionResult(http.Context, *DeletePositionRequest, *DeletePositionResponse) error +} +type PositionServiceGetPositionHooker interface { BeforeGetPosition(http.Context, *GetPositionRequest) (context.Context, error) GetPositionResult(http.Context, *GetPositionRequest, *GetPositionResponse) error +} +type PositionServiceListPositionsHooker interface { BeforeListPositions(http.Context, *ListPositionsRequest) (context.Context, error) ListPositionsResult(http.Context, *ListPositionsRequest, *ListPositionsResponse) error +} +type PositionServiceUpdatePositionHooker interface { BeforeUpdatePosition(http.Context, *UpdatePositionRequest) (context.Context, error) UpdatePositionResult(http.Context, *UpdatePositionRequest, *UpdatePositionResponse) error } -func RegisterPositionServiceBridger(s *http.Server, srv PositionServiceBridger) { +func RegisterPositionServiceBridger(s *http.Server, srv PositionServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(PositionServiceBridgeHooker) - if !ok { - hook = UnimplementedPositionServiceBridger{PositionServiceBridger: srv} - } - r.GET("/sys/positions", _PositionService_ListPositions0_Bridge_Handler(hook)) - r.GET("/sys/positions/:id", _PositionService_GetPosition0_Bridge_Handler(hook)) - r.POST("/sys/positions", _PositionService_CreatePosition0_Bridge_Handler(hook)) - r.PUT("/sys/positions/:position.id", _PositionService_UpdatePosition0_Bridge_Handler(hook)) - r.DELETE("/sys/positions/:id", _PositionService_DeletePosition0_Bridge_Handler(hook)) + r.GET("/sys/positions", _PositionService_ListPositions0_Bridge_Handler(srv)) + r.GET("/sys/positions/:id", _PositionService_GetPosition0_Bridge_Handler(srv)) + r.POST("/sys/positions", _PositionService_CreatePosition0_Bridge_Handler(srv)) + r.PUT("/sys/positions/:position.id", _PositionService_UpdatePosition0_Bridge_Handler(srv)) + r.DELETE("/sys/positions/:id", _PositionService_DeletePosition0_Bridge_Handler(srv)) } -func _PositionService_ListPositions0_Bridge_Handler(srv PositionServiceBridgeHooker) func(ctx http.Context) error { +func _PositionService_ListPositions0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListPositionsRequest if err := ctx.BindQuery(&in); err != nil { @@ -83,7 +98,7 @@ func _PositionService_ListPositions0_Bridge_Handler(srv PositionServiceBridgeHoo } } -func _PositionService_GetPosition0_Bridge_Handler(srv PositionServiceBridgeHooker) func(ctx http.Context) error { +func _PositionService_GetPosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetPositionRequest if err := ctx.BindQuery(&in); err != nil { @@ -109,7 +124,7 @@ func _PositionService_GetPosition0_Bridge_Handler(srv PositionServiceBridgeHooke } } -func _PositionService_CreatePosition0_Bridge_Handler(srv PositionServiceBridgeHooker) func(ctx http.Context) error { +func _PositionService_CreatePosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreatePositionRequest if err := ctx.Bind(&in.Position); err != nil { @@ -135,7 +150,7 @@ func _PositionService_CreatePosition0_Bridge_Handler(srv PositionServiceBridgeHo } } -func _PositionService_UpdatePosition0_Bridge_Handler(srv PositionServiceBridgeHooker) func(ctx http.Context) error { +func _PositionService_UpdatePosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdatePositionRequest if err := ctx.Bind(&in.Position); err != nil { @@ -164,7 +179,7 @@ func _PositionService_UpdatePosition0_Bridge_Handler(srv PositionServiceBridgeHo } } -func _PositionService_DeletePosition0_Bridge_Handler(srv PositionServiceBridgeHooker) func(ctx http.Context) error { +func _PositionService_DeletePosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in DeletePositionRequest if err := ctx.BindQuery(&in); err != nil { @@ -190,55 +205,67 @@ func _PositionService_DeletePosition0_Bridge_Handler(srv PositionServiceBridgeHo } } -// UnimplementedPositionServiceBridger must be embedded to have +// UnimplementedPositionServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedPositionServiceBridger struct { - PositionServiceBridger -} +type UnimplementedPositionServiceHooked struct{} -func (UnimplementedPositionServiceBridger) BeforeCreatePosition(ctx http.Context, in *CreatePositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) BeforeCreatePosition(ctx http.Context, in *CreatePositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceBridger) CreatePositionResult(ctx http.Context, in *CreatePositionRequest, out *CreatePositionResponse) error { +func (UnimplementedPositionServiceHooked) CreatePositionResult(ctx http.Context, in *CreatePositionRequest, out *CreatePositionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceBridger) BeforeDeletePosition(ctx http.Context, in *DeletePositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) BeforeDeletePosition(ctx http.Context, in *DeletePositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceBridger) DeletePositionResult(ctx http.Context, in *DeletePositionRequest, out *DeletePositionResponse) error { +func (UnimplementedPositionServiceHooked) DeletePositionResult(ctx http.Context, in *DeletePositionRequest, out *DeletePositionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceBridger) BeforeGetPosition(ctx http.Context, in *GetPositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) BeforeGetPosition(ctx http.Context, in *GetPositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceBridger) GetPositionResult(ctx http.Context, in *GetPositionRequest, out *GetPositionResponse) error { +func (UnimplementedPositionServiceHooked) GetPositionResult(ctx http.Context, in *GetPositionRequest, out *GetPositionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceBridger) BeforeListPositions(ctx http.Context, in *ListPositionsRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) BeforeListPositions(ctx http.Context, in *ListPositionsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceBridger) ListPositionsResult(ctx http.Context, in *ListPositionsRequest, out *ListPositionsResponse) error { +func (UnimplementedPositionServiceHooked) ListPositionsResult(ctx http.Context, in *ListPositionsRequest, out *ListPositionsResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceBridger) BeforeUpdatePosition(ctx http.Context, in *UpdatePositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) BeforeUpdatePosition(ctx http.Context, in *UpdatePositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceBridger) UpdatePositionResult(ctx http.Context, in *UpdatePositionRequest, out *UpdatePositionResponse) error { +func (UnimplementedPositionServiceHooked) UpdatePositionResult(ctx http.Context, in *UpdatePositionRequest, out *UpdatePositionResponse) error { return ctx.Result(200, out) } +func WithPositionServiceHook(h PositionServiceHooker) func(PositionServiceBridger) PositionServiceHookedBridger { + return func(b PositionServiceBridger) PositionServiceHookedBridger { + return PositionServiceHookedBridge{PositionServiceBridger: b, PositionServiceHooker: h} + } +} + +// PositionServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PositionService. +// It implements the HTTP and gRPC implementations of PositionService. +// It forwards requests and responses between the two implementations. +type PositionServiceHookedBridge struct { + PositionServiceBridger + PositionServiceHooker +} + type PositionServiceHTTPBridgeImpl struct { client PositionServiceHTTPClient } diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go index 0d1d0c74..d9522140 100644 --- a/api/v1/services/system/resource.pb.go +++ b/api/v1/services/system/resource.pb.go @@ -12,10 +12,10 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" unsafe "unsafe" - types "v1/services/types" ) const ( @@ -664,8 +664,8 @@ const file_system_resource_proto_rawDesc = "" + "\vGetResource\x12*.api.v1.services.system.GetResourceRequest\x1a+.api.v1.services.system.GetResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/resources/{id}\x12\x91\x01\n" + "\x0eCreateResource\x12-.api.v1.services.system.CreateResourceRequest\x1a..api.v1.services.system.CreateResourceResponse\" \x82\xd3\xe4\x93\x02\x1a:\bresource\"\x0e/sys/resources\x12\x9f\x01\n" + "\x0eUpdateResource\x12-.api.v1.services.system.UpdateResourceRequest\x1a..api.v1.services.system.UpdateResourceResponse\".\x82\xd3\xe4\x93\x02(:\bresource\x1a\x1c/sys/resources/{resource.id}\x12\x8c\x01\n" + - "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xc2\x01\n" + - "\x1acom.api.v1.services.systemB\rResourceProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xc6\x01\n" + + "\x1acom.api.v1.services.systemB\rResourceProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_resource_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go index c20a50a9..de429c18 100644 --- a/api/v1/services/system/resource_bridge.pb.go +++ b/api/v1/services/system/resource_bridge.pb.go @@ -33,34 +33,49 @@ type ResourceServiceBridger interface { UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) } -type ResourceServiceBridgeHooker interface { +type ResourceServiceHooker interface { + ResourceServiceCreateResourceHooker + ResourceServiceDeleteResourceHooker + ResourceServiceGetResourceHooker + ResourceServiceListResourcesHooker + ResourceServiceUpdateResourceHooker +} + +type ResourceServiceHookedBridger interface { + ResourceServiceHooker ResourceServiceBridger +} +type ResourceServiceCreateResourceHooker interface { BeforeCreateResource(http.Context, *CreateResourceRequest) (context.Context, error) CreateResourceResult(http.Context, *CreateResourceRequest, *CreateResourceResponse) error +} +type ResourceServiceDeleteResourceHooker interface { BeforeDeleteResource(http.Context, *DeleteResourceRequest) (context.Context, error) DeleteResourceResult(http.Context, *DeleteResourceRequest, *DeleteResourceResponse) error +} +type ResourceServiceGetResourceHooker interface { BeforeGetResource(http.Context, *GetResourceRequest) (context.Context, error) GetResourceResult(http.Context, *GetResourceRequest, *GetResourceResponse) error +} +type ResourceServiceListResourcesHooker interface { BeforeListResources(http.Context, *ListResourcesRequest) (context.Context, error) ListResourcesResult(http.Context, *ListResourcesRequest, *ListResourcesResponse) error +} +type ResourceServiceUpdateResourceHooker interface { BeforeUpdateResource(http.Context, *UpdateResourceRequest) (context.Context, error) UpdateResourceResult(http.Context, *UpdateResourceRequest, *UpdateResourceResponse) error } -func RegisterResourceServiceBridger(s *http.Server, srv ResourceServiceBridger) { +func RegisterResourceServiceBridger(s *http.Server, srv ResourceServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(ResourceServiceBridgeHooker) - if !ok { - hook = UnimplementedResourceServiceBridger{ResourceServiceBridger: srv} - } - r.GET("/sys/resources", _ResourceService_ListResources0_Bridge_Handler(hook)) - r.GET("/sys/resources/:id", _ResourceService_GetResource0_Bridge_Handler(hook)) - r.POST("/sys/resources", _ResourceService_CreateResource0_Bridge_Handler(hook)) - r.PUT("/sys/resources/:resource.id", _ResourceService_UpdateResource0_Bridge_Handler(hook)) - r.DELETE("/sys/resources/:id", _ResourceService_DeleteResource0_Bridge_Handler(hook)) + r.GET("/sys/resources", _ResourceService_ListResources0_Bridge_Handler(srv)) + r.GET("/sys/resources/:id", _ResourceService_GetResource0_Bridge_Handler(srv)) + r.POST("/sys/resources", _ResourceService_CreateResource0_Bridge_Handler(srv)) + r.PUT("/sys/resources/:resource.id", _ResourceService_UpdateResource0_Bridge_Handler(srv)) + r.DELETE("/sys/resources/:id", _ResourceService_DeleteResource0_Bridge_Handler(srv)) } -func _ResourceService_ListResources0_Bridge_Handler(srv ResourceServiceBridgeHooker) func(ctx http.Context) error { +func _ResourceService_ListResources0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListResourcesRequest if err := ctx.BindQuery(&in); err != nil { @@ -83,7 +98,7 @@ func _ResourceService_ListResources0_Bridge_Handler(srv ResourceServiceBridgeHoo } } -func _ResourceService_GetResource0_Bridge_Handler(srv ResourceServiceBridgeHooker) func(ctx http.Context) error { +func _ResourceService_GetResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetResourceRequest if err := ctx.BindQuery(&in); err != nil { @@ -109,7 +124,7 @@ func _ResourceService_GetResource0_Bridge_Handler(srv ResourceServiceBridgeHooke } } -func _ResourceService_CreateResource0_Bridge_Handler(srv ResourceServiceBridgeHooker) func(ctx http.Context) error { +func _ResourceService_CreateResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateResourceRequest if err := ctx.Bind(&in.Resource); err != nil { @@ -135,7 +150,7 @@ func _ResourceService_CreateResource0_Bridge_Handler(srv ResourceServiceBridgeHo } } -func _ResourceService_UpdateResource0_Bridge_Handler(srv ResourceServiceBridgeHooker) func(ctx http.Context) error { +func _ResourceService_UpdateResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateResourceRequest if err := ctx.Bind(&in.Resource); err != nil { @@ -164,7 +179,7 @@ func _ResourceService_UpdateResource0_Bridge_Handler(srv ResourceServiceBridgeHo } } -func _ResourceService_DeleteResource0_Bridge_Handler(srv ResourceServiceBridgeHooker) func(ctx http.Context) error { +func _ResourceService_DeleteResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in DeleteResourceRequest if err := ctx.BindQuery(&in); err != nil { @@ -190,55 +205,67 @@ func _ResourceService_DeleteResource0_Bridge_Handler(srv ResourceServiceBridgeHo } } -// UnimplementedResourceServiceBridger must be embedded to have +// UnimplementedResourceServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedResourceServiceBridger struct { - ResourceServiceBridger -} +type UnimplementedResourceServiceHooked struct{} -func (UnimplementedResourceServiceBridger) BeforeCreateResource(ctx http.Context, in *CreateResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) BeforeCreateResource(ctx http.Context, in *CreateResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceBridger) CreateResourceResult(ctx http.Context, in *CreateResourceRequest, out *CreateResourceResponse) error { +func (UnimplementedResourceServiceHooked) CreateResourceResult(ctx http.Context, in *CreateResourceRequest, out *CreateResourceResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceBridger) BeforeDeleteResource(ctx http.Context, in *DeleteResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) BeforeDeleteResource(ctx http.Context, in *DeleteResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceBridger) DeleteResourceResult(ctx http.Context, in *DeleteResourceRequest, out *DeleteResourceResponse) error { +func (UnimplementedResourceServiceHooked) DeleteResourceResult(ctx http.Context, in *DeleteResourceRequest, out *DeleteResourceResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceBridger) BeforeGetResource(ctx http.Context, in *GetResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) BeforeGetResource(ctx http.Context, in *GetResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceBridger) GetResourceResult(ctx http.Context, in *GetResourceRequest, out *GetResourceResponse) error { +func (UnimplementedResourceServiceHooked) GetResourceResult(ctx http.Context, in *GetResourceRequest, out *GetResourceResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceBridger) BeforeListResources(ctx http.Context, in *ListResourcesRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) BeforeListResources(ctx http.Context, in *ListResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceBridger) ListResourcesResult(ctx http.Context, in *ListResourcesRequest, out *ListResourcesResponse) error { +func (UnimplementedResourceServiceHooked) ListResourcesResult(ctx http.Context, in *ListResourcesRequest, out *ListResourcesResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceBridger) BeforeUpdateResource(ctx http.Context, in *UpdateResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) BeforeUpdateResource(ctx http.Context, in *UpdateResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceBridger) UpdateResourceResult(ctx http.Context, in *UpdateResourceRequest, out *UpdateResourceResponse) error { +func (UnimplementedResourceServiceHooked) UpdateResourceResult(ctx http.Context, in *UpdateResourceRequest, out *UpdateResourceResponse) error { return ctx.Result(200, out) } +func WithResourceServiceHook(h ResourceServiceHooker) func(ResourceServiceBridger) ResourceServiceHookedBridger { + return func(b ResourceServiceBridger) ResourceServiceHookedBridger { + return ResourceServiceHookedBridge{ResourceServiceBridger: b, ResourceServiceHooker: h} + } +} + +// ResourceServiceHookedBridge is a bridge between the HTTP and gRPC implementations of ResourceService. +// It implements the HTTP and gRPC implementations of ResourceService. +// It forwards requests and responses between the two implementations. +type ResourceServiceHookedBridge struct { + ResourceServiceBridger + ResourceServiceHooker +} + type ResourceServiceHTTPBridgeImpl struct { client ResourceServiceHTTPClient } diff --git a/api/v1/services/system/role.pb.go b/api/v1/services/system/role.pb.go index 1e6772ac..703fa1b4 100644 --- a/api/v1/services/system/role.pb.go +++ b/api/v1/services/system/role.pb.go @@ -12,10 +12,10 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" unsafe "unsafe" - types "v1/services/types" ) const ( @@ -648,8 +648,8 @@ const file_system_role_proto_rawDesc = "" + "\n" + "UpdateRole\x12).api.v1.services.system.UpdateRoleRequest\x1a*.api.v1.services.system.UpdateRoleResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04role\x1a\x14/sys/roles/{role.id}\x12|\n" + "\n" + - "DeleteRole\x12).api.v1.services.system.DeleteRoleRequest\x1a*.api.v1.services.system.DeleteRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/roles/{id}B\xbe\x01\n" + - "\x1acom.api.v1.services.systemB\tRoleProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "DeleteRole\x12).api.v1.services.system.DeleteRoleRequest\x1a*.api.v1.services.system.DeleteRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/roles/{id}B\xc2\x01\n" + + "\x1acom.api.v1.services.systemB\tRoleProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_role_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go index 5c18e714..493963bb 100644 --- a/api/v1/services/system/role_bridge.pb.go +++ b/api/v1/services/system/role_bridge.pb.go @@ -33,34 +33,49 @@ type RoleServiceBridger interface { UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) } -type RoleServiceBridgeHooker interface { +type RoleServiceHooker interface { + RoleServiceCreateRoleHooker + RoleServiceDeleteRoleHooker + RoleServiceGetRoleHooker + RoleServiceListRolesHooker + RoleServiceUpdateRoleHooker +} + +type RoleServiceHookedBridger interface { + RoleServiceHooker RoleServiceBridger +} +type RoleServiceCreateRoleHooker interface { BeforeCreateRole(http.Context, *CreateRoleRequest) (context.Context, error) CreateRoleResult(http.Context, *CreateRoleRequest, *CreateRoleResponse) error +} +type RoleServiceDeleteRoleHooker interface { BeforeDeleteRole(http.Context, *DeleteRoleRequest) (context.Context, error) DeleteRoleResult(http.Context, *DeleteRoleRequest, *DeleteRoleResponse) error +} +type RoleServiceGetRoleHooker interface { BeforeGetRole(http.Context, *GetRoleRequest) (context.Context, error) GetRoleResult(http.Context, *GetRoleRequest, *GetRoleResponse) error +} +type RoleServiceListRolesHooker interface { BeforeListRoles(http.Context, *ListRolesRequest) (context.Context, error) ListRolesResult(http.Context, *ListRolesRequest, *ListRolesResponse) error +} +type RoleServiceUpdateRoleHooker interface { BeforeUpdateRole(http.Context, *UpdateRoleRequest) (context.Context, error) UpdateRoleResult(http.Context, *UpdateRoleRequest, *UpdateRoleResponse) error } -func RegisterRoleServiceBridger(s *http.Server, srv RoleServiceBridger) { +func RegisterRoleServiceBridger(s *http.Server, srv RoleServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(RoleServiceBridgeHooker) - if !ok { - hook = UnimplementedRoleServiceBridger{RoleServiceBridger: srv} - } - r.GET("/sys/roles", _RoleService_ListRoles0_Bridge_Handler(hook)) - r.GET("/sys/roles/:id", _RoleService_GetRole0_Bridge_Handler(hook)) - r.POST("/sys/roles", _RoleService_CreateRole0_Bridge_Handler(hook)) - r.PUT("/sys/roles/:role.id", _RoleService_UpdateRole0_Bridge_Handler(hook)) - r.DELETE("/sys/roles/:id", _RoleService_DeleteRole0_Bridge_Handler(hook)) + r.GET("/sys/roles", _RoleService_ListRoles0_Bridge_Handler(srv)) + r.GET("/sys/roles/:id", _RoleService_GetRole0_Bridge_Handler(srv)) + r.POST("/sys/roles", _RoleService_CreateRole0_Bridge_Handler(srv)) + r.PUT("/sys/roles/:role.id", _RoleService_UpdateRole0_Bridge_Handler(srv)) + r.DELETE("/sys/roles/:id", _RoleService_DeleteRole0_Bridge_Handler(srv)) } -func _RoleService_ListRoles0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx http.Context) error { +func _RoleService_ListRoles0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListRolesRequest if err := ctx.BindQuery(&in); err != nil { @@ -83,7 +98,7 @@ func _RoleService_ListRoles0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ct } } -func _RoleService_GetRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx http.Context) error { +func _RoleService_GetRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetRoleRequest if err := ctx.BindQuery(&in); err != nil { @@ -109,7 +124,7 @@ func _RoleService_GetRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx } } -func _RoleService_CreateRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx http.Context) error { +func _RoleService_CreateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateRoleRequest if err := ctx.Bind(&in.Role); err != nil { @@ -135,7 +150,7 @@ func _RoleService_CreateRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(c } } -func _RoleService_UpdateRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx http.Context) error { +func _RoleService_UpdateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateRoleRequest if err := ctx.Bind(&in.Role); err != nil { @@ -164,7 +179,7 @@ func _RoleService_UpdateRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(c } } -func _RoleService_DeleteRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(ctx http.Context) error { +func _RoleService_DeleteRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in DeleteRoleRequest if err := ctx.BindQuery(&in); err != nil { @@ -190,55 +205,67 @@ func _RoleService_DeleteRole0_Bridge_Handler(srv RoleServiceBridgeHooker) func(c } } -// UnimplementedRoleServiceBridger must be embedded to have +// UnimplementedRoleServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedRoleServiceBridger struct { - RoleServiceBridger -} +type UnimplementedRoleServiceHooked struct{} -func (UnimplementedRoleServiceBridger) BeforeCreateRole(ctx http.Context, in *CreateRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) BeforeCreateRole(ctx http.Context, in *CreateRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceBridger) CreateRoleResult(ctx http.Context, in *CreateRoleRequest, out *CreateRoleResponse) error { +func (UnimplementedRoleServiceHooked) CreateRoleResult(ctx http.Context, in *CreateRoleRequest, out *CreateRoleResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceBridger) BeforeDeleteRole(ctx http.Context, in *DeleteRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) BeforeDeleteRole(ctx http.Context, in *DeleteRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceBridger) DeleteRoleResult(ctx http.Context, in *DeleteRoleRequest, out *DeleteRoleResponse) error { +func (UnimplementedRoleServiceHooked) DeleteRoleResult(ctx http.Context, in *DeleteRoleRequest, out *DeleteRoleResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceBridger) BeforeGetRole(ctx http.Context, in *GetRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) BeforeGetRole(ctx http.Context, in *GetRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceBridger) GetRoleResult(ctx http.Context, in *GetRoleRequest, out *GetRoleResponse) error { +func (UnimplementedRoleServiceHooked) GetRoleResult(ctx http.Context, in *GetRoleRequest, out *GetRoleResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceBridger) BeforeListRoles(ctx http.Context, in *ListRolesRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) BeforeListRoles(ctx http.Context, in *ListRolesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceBridger) ListRolesResult(ctx http.Context, in *ListRolesRequest, out *ListRolesResponse) error { +func (UnimplementedRoleServiceHooked) ListRolesResult(ctx http.Context, in *ListRolesRequest, out *ListRolesResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceBridger) BeforeUpdateRole(ctx http.Context, in *UpdateRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) BeforeUpdateRole(ctx http.Context, in *UpdateRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceBridger) UpdateRoleResult(ctx http.Context, in *UpdateRoleRequest, out *UpdateRoleResponse) error { +func (UnimplementedRoleServiceHooked) UpdateRoleResult(ctx http.Context, in *UpdateRoleRequest, out *UpdateRoleResponse) error { return ctx.Result(200, out) } +func WithRoleServiceHook(h RoleServiceHooker) func(RoleServiceBridger) RoleServiceHookedBridger { + return func(b RoleServiceBridger) RoleServiceHookedBridger { + return RoleServiceHookedBridge{RoleServiceBridger: b, RoleServiceHooker: h} + } +} + +// RoleServiceHookedBridge is a bridge between the HTTP and gRPC implementations of RoleService. +// It implements the HTTP and gRPC implementations of RoleService. +// It forwards requests and responses between the two implementations. +type RoleServiceHookedBridge struct { + RoleServiceBridger + RoleServiceHooker +} + type RoleServiceHTTPBridgeImpl struct { client RoleServiceHTTPClient } diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go index d6374d0e..7b56430c 100644 --- a/api/v1/services/system/user.pb.go +++ b/api/v1/services/system/user.pb.go @@ -12,10 +12,10 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" unsafe "unsafe" - types "v1/services/types" ) const ( @@ -1090,8 +1090,8 @@ const file_system_user_proto_rawDesc = "" + "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x1c\x82\xd3\xe4\x93\x02\x16*\x14/sys/users/{user.id}\x12\xa0\x01\n" + "\x10UpdateUserStatus\x12/.api.v1.services.system.UpdateUserStatusRequest\x1a0.api.v1.services.system.UpdateUserStatusResponse\")\x82\xd3\xe4\x93\x02#:\x04user\x1a\x1b/sys/users/{user.id}/status\x12\x9c\x01\n" + "\x0fUpdateUserRoles\x12..api.v1.services.system.UpdateUserRolesRequest\x1a/.api.v1.services.system.UpdateUserRolesResponse\"(\x82\xd3\xe4\x93\x02\":\x04user\x1a\x1a/sys/users/{user.id}/roles\x12\xa6\x01\n" + - "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\",\x82\xd3\xe4\x93\x02&:\x04data\"\x1e/sys/users/{id}/password/resetB\xbe\x01\n" + - "\x1acom.api.v1.services.systemB\tUserProtoP\x01Z\x19v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\",\x82\xd3\xe4\x93\x02&:\x04data\"\x1e/sys/users/{id}/password/resetB\xc2\x01\n" + + "\x1acom.api.v1.services.systemB\tUserProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_user_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 490cd64c..8264ff66 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -44,49 +44,73 @@ type UserServiceBridger interface { UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) } -type UserServiceBridgeHooker interface { +type UserServiceHooker interface { + UserServiceCreateUserHooker + UserServiceDeleteUserHooker + UserServiceGetUserHooker + UserServiceListUserResourcesHooker + UserServiceListUsersHooker + UserServiceResetUserPasswordHooker + UserServiceUpdateUserHooker + UserServiceUpdateUserRolesHooker + UserServiceUpdateUserStatusHooker +} + +type UserServiceHookedBridger interface { + UserServiceHooker UserServiceBridger +} +type UserServiceCreateUserHooker interface { BeforeCreateUser(http.Context, *CreateUserRequest) (context.Context, error) CreateUserResult(http.Context, *CreateUserRequest, *CreateUserResponse) error +} +type UserServiceDeleteUserHooker interface { BeforeDeleteUser(http.Context, *DeleteUserRequest) (context.Context, error) DeleteUserResult(http.Context, *DeleteUserRequest, *DeleteUserResponse) error +} +type UserServiceGetUserHooker interface { BeforeGetUser(http.Context, *GetUserRequest) (context.Context, error) GetUserResult(http.Context, *GetUserRequest, *GetUserResponse) error +} +type UserServiceListUserResourcesHooker interface { BeforeListUserResources(http.Context, *ListUserResourcesRequest) (context.Context, error) ListUserResourcesResult(http.Context, *ListUserResourcesRequest, *ListUserResourcesResponse) error +} +type UserServiceListUsersHooker interface { BeforeListUsers(http.Context, *ListUsersRequest) (context.Context, error) ListUsersResult(http.Context, *ListUsersRequest, *ListUsersResponse) error - // ResetUserPassword ResetUserPassword reset the user s password +} +type UserServiceResetUserPasswordHooker interface { BeforeResetUserPassword(http.Context, *ResetUserPasswordRequest) (context.Context, error) ResetUserPasswordResult(http.Context, *ResetUserPasswordRequest, *ResetUserPasswordResponse) error +} +type UserServiceUpdateUserHooker interface { BeforeUpdateUser(http.Context, *UpdateUserRequest) (context.Context, error) UpdateUserResult(http.Context, *UpdateUserRequest, *UpdateUserResponse) error - // UpdateUserRoles UpdateUserRoles update the user roles +} +type UserServiceUpdateUserRolesHooker interface { BeforeUpdateUserRoles(http.Context, *UpdateUserRolesRequest) (context.Context, error) UpdateUserRolesResult(http.Context, *UpdateUserRolesRequest, *UpdateUserRolesResponse) error - // UpdateUserStatus UpdateUserStatus Update the status of the user information +} +type UserServiceUpdateUserStatusHooker interface { BeforeUpdateUserStatus(http.Context, *UpdateUserStatusRequest) (context.Context, error) UpdateUserStatusResult(http.Context, *UpdateUserStatusRequest, *UpdateUserStatusResponse) error } -func RegisterUserServiceBridger(s *http.Server, srv UserServiceBridger) { +func RegisterUserServiceBridger(s *http.Server, srv UserServiceHookedBridger) { r := s.Route("/") - hook, ok := srv.(UserServiceBridgeHooker) - if !ok { - hook = UnimplementedUserServiceBridger{UserServiceBridger: srv} - } - r.GET("/sys/users", _UserService_ListUsers0_Bridge_Handler(hook)) - r.GET("/sys/users/:id/resources", _UserService_ListUserResources0_Bridge_Handler(hook)) - r.GET("/sys/users/:id", _UserService_GetUser0_Bridge_Handler(hook)) - r.POST("/sys/users", _UserService_CreateUser0_Bridge_Handler(hook)) - r.PUT("/sys/users/:user.id", _UserService_UpdateUser0_Bridge_Handler(hook)) - r.DELETE("/sys/users/:user.id", _UserService_DeleteUser0_Bridge_Handler(hook)) - r.PUT("/sys/users/:user.id/status", _UserService_UpdateUserStatus0_Bridge_Handler(hook)) - r.PUT("/sys/users/:user.id/roles", _UserService_UpdateUserRoles0_Bridge_Handler(hook)) - r.POST("/sys/users/:id/password/reset", _UserService_ResetUserPassword0_Bridge_Handler(hook)) -} - -func _UserService_ListUsers0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { + r.GET("/sys/users", _UserService_ListUsers0_Bridge_Handler(srv)) + r.GET("/sys/users/:id/resources", _UserService_ListUserResources0_Bridge_Handler(srv)) + r.GET("/sys/users/:id", _UserService_GetUser0_Bridge_Handler(srv)) + r.POST("/sys/users", _UserService_CreateUser0_Bridge_Handler(srv)) + r.PUT("/sys/users/:user.id", _UserService_UpdateUser0_Bridge_Handler(srv)) + r.DELETE("/sys/users/:user.id", _UserService_DeleteUser0_Bridge_Handler(srv)) + r.PUT("/sys/users/:user.id/status", _UserService_UpdateUserStatus0_Bridge_Handler(srv)) + r.PUT("/sys/users/:user.id/roles", _UserService_UpdateUserRoles0_Bridge_Handler(srv)) + r.POST("/sys/users/:id/password/reset", _UserService_ResetUserPassword0_Bridge_Handler(srv)) +} + +func _UserService_ListUsers0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListUsersRequest if err := ctx.BindQuery(&in); err != nil { @@ -109,7 +133,7 @@ func _UserService_ListUsers0_Bridge_Handler(srv UserServiceBridgeHooker) func(ct } } -func _UserService_ListUserResources0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { +func _UserService_ListUserResources0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListUserResourcesRequest if err := ctx.BindQuery(&in); err != nil { @@ -135,7 +159,7 @@ func _UserService_ListUserResources0_Bridge_Handler(srv UserServiceBridgeHooker) } } -func _UserService_GetUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { +func _UserService_GetUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetUserRequest if err := ctx.BindQuery(&in); err != nil { @@ -161,7 +185,7 @@ func _UserService_GetUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx } } -func _UserService_CreateUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { +func _UserService_CreateUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateUserRequest if err := ctx.Bind(&in.User); err != nil { @@ -187,7 +211,7 @@ func _UserService_CreateUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(c } } -func _UserService_UpdateUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { +func _UserService_UpdateUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateUserRequest if err := ctx.Bind(&in.User); err != nil { @@ -216,7 +240,7 @@ func _UserService_UpdateUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(c } } -func _UserService_DeleteUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { +func _UserService_DeleteUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in DeleteUserRequest if err := ctx.BindQuery(&in); err != nil { @@ -242,7 +266,7 @@ func _UserService_DeleteUser0_Bridge_Handler(srv UserServiceBridgeHooker) func(c } } -func _UserService_UpdateUserStatus0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { +func _UserService_UpdateUserStatus0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateUserStatusRequest if err := ctx.Bind(&in.User); err != nil { @@ -271,7 +295,7 @@ func _UserService_UpdateUserStatus0_Bridge_Handler(srv UserServiceBridgeHooker) } } -func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { +func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateUserRolesRequest if err := ctx.Bind(&in.User); err != nil { @@ -300,7 +324,7 @@ func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceBridgeHooker) f } } -func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceBridgeHooker) func(ctx http.Context) error { +func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ResetUserPasswordRequest if err := ctx.Bind(&in.Data); err != nil { @@ -329,87 +353,99 @@ func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceBridgeHooker) } } -// UnimplementedUserServiceBridger must be embedded to have +// UnimplementedUserServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedUserServiceBridger struct { - UserServiceBridger -} +type UnimplementedUserServiceHooked struct{} -func (UnimplementedUserServiceBridger) BeforeCreateUser(ctx http.Context, in *CreateUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) BeforeCreateUser(ctx http.Context, in *CreateUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceBridger) CreateUserResult(ctx http.Context, in *CreateUserRequest, out *CreateUserResponse) error { +func (UnimplementedUserServiceHooked) CreateUserResult(ctx http.Context, in *CreateUserRequest, out *CreateUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceBridger) BeforeDeleteUser(ctx http.Context, in *DeleteUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) BeforeDeleteUser(ctx http.Context, in *DeleteUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceBridger) DeleteUserResult(ctx http.Context, in *DeleteUserRequest, out *DeleteUserResponse) error { +func (UnimplementedUserServiceHooked) DeleteUserResult(ctx http.Context, in *DeleteUserRequest, out *DeleteUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceBridger) BeforeGetUser(ctx http.Context, in *GetUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) BeforeGetUser(ctx http.Context, in *GetUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceBridger) GetUserResult(ctx http.Context, in *GetUserRequest, out *GetUserResponse) error { +func (UnimplementedUserServiceHooked) GetUserResult(ctx http.Context, in *GetUserRequest, out *GetUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceBridger) BeforeListUserResources(ctx http.Context, in *ListUserResourcesRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) BeforeListUserResources(ctx http.Context, in *ListUserResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceBridger) ListUserResourcesResult(ctx http.Context, in *ListUserResourcesRequest, out *ListUserResourcesResponse) error { +func (UnimplementedUserServiceHooked) ListUserResourcesResult(ctx http.Context, in *ListUserResourcesRequest, out *ListUserResourcesResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceBridger) BeforeListUsers(ctx http.Context, in *ListUsersRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) BeforeListUsers(ctx http.Context, in *ListUsersRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceBridger) ListUsersResult(ctx http.Context, in *ListUsersRequest, out *ListUsersResponse) error { +func (UnimplementedUserServiceHooked) ListUsersResult(ctx http.Context, in *ListUsersRequest, out *ListUsersResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceBridger) BeforeResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) BeforeResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceBridger) ResetUserPasswordResult(ctx http.Context, in *ResetUserPasswordRequest, out *ResetUserPasswordResponse) error { +func (UnimplementedUserServiceHooked) ResetUserPasswordResult(ctx http.Context, in *ResetUserPasswordRequest, out *ResetUserPasswordResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceBridger) BeforeUpdateUser(ctx http.Context, in *UpdateUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) BeforeUpdateUser(ctx http.Context, in *UpdateUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceBridger) UpdateUserResult(ctx http.Context, in *UpdateUserRequest, out *UpdateUserResponse) error { +func (UnimplementedUserServiceHooked) UpdateUserResult(ctx http.Context, in *UpdateUserRequest, out *UpdateUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceBridger) BeforeUpdateUserRoles(ctx http.Context, in *UpdateUserRolesRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) BeforeUpdateUserRoles(ctx http.Context, in *UpdateUserRolesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceBridger) UpdateUserRolesResult(ctx http.Context, in *UpdateUserRolesRequest, out *UpdateUserRolesResponse) error { +func (UnimplementedUserServiceHooked) UpdateUserRolesResult(ctx http.Context, in *UpdateUserRolesRequest, out *UpdateUserRolesResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceBridger) BeforeUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) BeforeUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceBridger) UpdateUserStatusResult(ctx http.Context, in *UpdateUserStatusRequest, out *UpdateUserStatusResponse) error { +func (UnimplementedUserServiceHooked) UpdateUserStatusResult(ctx http.Context, in *UpdateUserStatusRequest, out *UpdateUserStatusResponse) error { return ctx.Result(200, out) } +func WithUserServiceHook(h UserServiceHooker) func(UserServiceBridger) UserServiceHookedBridger { + return func(b UserServiceBridger) UserServiceHookedBridger { + return UserServiceHookedBridge{UserServiceBridger: b, UserServiceHooker: h} + } +} + +// UserServiceHookedBridge is a bridge between the HTTP and gRPC implementations of UserService. +// It implements the HTTP and gRPC implementations of UserService. +// It forwards requests and responses between the two implementations. +type UserServiceHookedBridge struct { + UserServiceBridger + UserServiceHooker +} + type UserServiceHTTPBridgeImpl struct { client UserServiceHTTPClient } diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go new file mode 100644 index 00000000..9fe125cb --- /dev/null +++ b/api/v1/services/types/system.pb.go @@ -0,0 +1,3205 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc (unknown) +// source: types/system.proto + +package types + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Menu is the model entity for the Menu schema. +type Menu struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // Code holds the value of the "keyword" field. + Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` + // Name holds the value of the "name" field. + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + // I18nKey holds the value + I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` + // Description holds the value of the "description" field. + Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` + // Sequence holds the value of the "sequence" field. + Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` + // Type holds the value of the "type" field. + Type string `protobuf:"bytes,9,opt,name=type,proto3" json:"type,omitempty"` + // Icon holds the value of the "icon" field. + Icon string `protobuf:"bytes,10,opt,name=icon,proto3" json:"icon,omitempty"` + // Path holds the value of the "path" field. + Path string `protobuf:"bytes,11,opt,name=path,proto3" json:"path,omitempty"` + // Properties holds the value of the "properties" field. + Properties string `protobuf:"bytes,12,opt,name=properties,proto3" json:"properties,omitempty"` + // Status holds the value of the "status" field. + Status int32 `protobuf:"varint,13,opt,name=status,proto3" json:"status,omitempty"` + // ParentID holds the value of the "parent_id" field. + ParentId int64 `protobuf:"varint,14,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + // ParentPath holds the value of the "parent_path" field. + ParentPath string `protobuf:"bytes,15,opt,name=parent_path,proto3" json:"parent_path,omitempty"` + // Children holds the value of the children edge. + Children []*Menu `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Menu `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` + // Resources holds the value of the resources edge. + Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` + // Roles holds the value of the roles edge. + Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Menu) Reset() { + *x = Menu{} + mi := &file_types_system_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Menu) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Menu) ProtoMessage() {} + +func (x *Menu) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[0] + 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 Menu.ProtoReflect.Descriptor instead. +func (*Menu) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{0} +} + +func (x *Menu) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Menu) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Menu) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Menu) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Menu) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Menu) GetI18NKey() string { + if x != nil { + return x.I18NKey + } + return "" +} + +func (x *Menu) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Menu) GetSequence() int32 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *Menu) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Menu) GetIcon() string { + if x != nil { + return x.Icon + } + return "" +} + +func (x *Menu) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *Menu) GetProperties() string { + if x != nil { + return x.Properties + } + return "" +} + +func (x *Menu) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *Menu) GetParentId() int64 { + if x != nil { + return x.ParentId + } + return 0 +} + +func (x *Menu) GetParentPath() string { + if x != nil { + return x.ParentPath + } + return "" +} + +func (x *Menu) GetChildren() []*Menu { + if x != nil { + return x.Children + } + return nil +} + +func (x *Menu) GetParent() *Menu { + if x != nil { + return x.Parent + } + return nil +} + +func (x *Menu) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *Menu) GetRoles() []*Role { + if x != nil { + return x.Roles + } + return nil +} + +// MenuEdges holds the relations/edges for other nodes in the graph. +type MenuEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Children holds the value of the children edge. + Children []*Menu `protobuf:"bytes,1,rep,name=children,proto3" json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Menu `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` + // Resources holds the value of the resources edge. + Resources []*Resource `protobuf:"bytes,3,rep,name=resources,proto3" json:"resources,omitempty"` + // Roles holds the value of the roles edge. + Roles []*Role `protobuf:"bytes,4,rep,name=roles,proto3" json:"roles,omitempty"` + // RoleMenu holds the value of the role_menu edge. + RoleMenus []*RoleMenu `protobuf:"bytes,5,rep,name=role_menus,proto3" json:"role_menus,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *MenuEdges) Reset() { + *x = MenuEdges{} + mi := &file_types_system_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *MenuEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MenuEdges) ProtoMessage() {} + +func (x *MenuEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[1] + 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 MenuEdges.ProtoReflect.Descriptor instead. +func (*MenuEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{1} +} + +func (x *MenuEdges) GetChildren() []*Menu { + if x != nil { + return x.Children + } + return nil +} + +func (x *MenuEdges) GetParent() *Menu { + if x != nil { + return x.Parent + } + return nil +} + +func (x *MenuEdges) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *MenuEdges) GetRoles() []*Role { + if x != nil { + return x.Roles + } + return nil +} + +func (x *MenuEdges) GetRoleMenus() []*RoleMenu { + if x != nil { + return x.RoleMenus + } + return nil +} + +// Role is the model entity for the Role schema. +type Role struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // role.field.keyword + Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` + // role.field.name + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + // role.field.description + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + // role.field.type + Type int32 `protobuf:"varint,7,opt,name=type,proto3" json:"type,omitempty"` + // role.field.sequence + Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` + // role.field.status + Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"` + // role.field.is_types + IsTypes bool `protobuf:"varint,10,opt,name=is_types,proto3" json:"is_types,omitempty"` + // Menus holds the value of the menus edge. + Menus []*Menu `protobuf:"bytes,21,rep,name=menus,proto3" json:"menus,omitempty"` + // Users holds the value of the users edge. + Users []*User `protobuf:"bytes,22,rep,name=users,proto3" json:"users,omitempty"` + // Resources holds the value of the resources edge. + Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` + // Resource Ids holds the value of the resource_ids edge. + ResourceIds []int64 `protobuf:"varint,24,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` + // Permissions holds the value of the permissions edge. + Permissions []*Permission `protobuf:"bytes,25,rep,name=permissions,proto3" json:"permissions,omitempty"` + // Permission Ids holds the value of the permission_ids edge. + PermissionIds []int64 `protobuf:"varint,26,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Role) Reset() { + *x = Role{} + mi := &file_types_system_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Role) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Role) ProtoMessage() {} + +func (x *Role) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[2] + 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 Role.ProtoReflect.Descriptor instead. +func (*Role) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{2} +} + +func (x *Role) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Role) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Role) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Role) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Role) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Role) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Role) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *Role) GetSequence() int32 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *Role) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *Role) GetIsTypes() bool { + if x != nil { + return x.IsTypes + } + return false +} + +func (x *Role) GetMenus() []*Menu { + if x != nil { + return x.Menus + } + return nil +} + +func (x *Role) GetUsers() []*User { + if x != nil { + return x.Users + } + return nil +} + +func (x *Role) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *Role) GetResourceIds() []int64 { + if x != nil { + return x.ResourceIds + } + return nil +} + +func (x *Role) GetPermissions() []*Permission { + if x != nil { + return x.Permissions + } + return nil +} + +func (x *Role) GetPermissionIds() []int64 { + if x != nil { + return x.PermissionIds + } + return nil +} + +// RoleEdges holds the relations/edges for other nodes in the graph. +type RoleEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Menus holds the value of the menus edge. + Menus []*Menu `protobuf:"bytes,1,rep,name=menus,proto3" json:"menus,omitempty"` + // Users holds the value of the users edge. + Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` + // RoleMenu holds the value of the role_menu edge. + RoleMenus []*RoleMenu `protobuf:"bytes,3,rep,name=role_menus,proto3" json:"role_menus,omitempty"` + // UserRole holds the value of the user_role edge. + UserRoles []*UserRole `protobuf:"bytes,4,rep,name=user_roles,proto3" json:"user_roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleEdges) Reset() { + *x = RoleEdges{} + mi := &file_types_system_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleEdges) ProtoMessage() {} + +func (x *RoleEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[3] + 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 RoleEdges.ProtoReflect.Descriptor instead. +func (*RoleEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{3} +} + +func (x *RoleEdges) GetMenus() []*Menu { + if x != nil { + return x.Menus + } + return nil +} + +func (x *RoleEdges) GetUsers() []*User { + if x != nil { + return x.Users + } + return nil +} + +func (x *RoleEdges) GetRoleMenus() []*RoleMenu { + if x != nil { + return x.RoleMenus + } + return nil +} + +func (x *RoleEdges) GetUserRoles() []*UserRole { + if x != nil { + return x.UserRoles + } + return nil +} + +// User is the model entity for the User schema. +type User struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_author.field.comment + CreateAuthor int64 `protobuf:"varint,2,opt,name=create_author,proto3" json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `protobuf:"varint,3,opt,name=update_author,proto3" json:"update_author,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=update_time,proto3" json:"update_time,omitempty"` + // user.field.uuid + Uuid string `protobuf:"bytes,6,opt,name=uuid,proto3" json:"uuid,omitempty"` + // user.field.allowed_ip + AllowedIp string `protobuf:"bytes,7,opt,name=allowed_ip,proto3" json:"allowed_ip,omitempty"` + // user.field.username + Username string `protobuf:"bytes,8,opt,name=username,proto3" json:"username,omitempty"` + // user.field.nickname + Nickname string `protobuf:"bytes,9,opt,name=nickname,proto3" json:"nickname,omitempty"` + // user.field.avatar + Avatar string `protobuf:"bytes,10,opt,name=avatar,proto3" json:"avatar,omitempty"` + // user.field.nickname + Name string `protobuf:"bytes,11,opt,name=name,proto3" json:"name,omitempty"` + // user.field.gender + Gender string `protobuf:"bytes,12,opt,name=gender,proto3" json:"gender,omitempty"` + // user.field.password + // @Decrypted don't show this field in response + Password string `protobuf:"bytes,13,opt,name=password,proto3" json:"password,omitempty"` + // user.field.confirm_password + ConfirmPassword string `protobuf:"bytes,14,opt,name=confirm_password,proto3" json:"confirm_password,omitempty"` + // user.field.salt + // @Decrypted don't show this field in response + Salt string `protobuf:"bytes,15,opt,name=salt,proto3" json:"salt,omitempty"` + // user.field.phone + Phone string `protobuf:"bytes,16,opt,name=phone,proto3" json:"phone,omitempty"` + // user.field.email + Email string `protobuf:"bytes,17,opt,name=email,proto3" json:"email,omitempty"` + // user.field.remark + Remark string `protobuf:"bytes,18,opt,name=remark,proto3" json:"remark,omitempty"` + // user.field.token + Token string `protobuf:"bytes,19,opt,name=token,proto3" json:"token,omitempty"` + // user.field.status + Status int32 `protobuf:"varint,20,opt,name=status,proto3" json:"status,omitempty"` + // user.field.last_login_ip + LastLoginIp string `protobuf:"bytes,21,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` + // user.field.last_login_time + LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` + // user.field.sanction_date + SanctionDate *timestamppb.Timestamp `protobuf:"bytes,23,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` + // user.field.manager_id + ManagerId int64 `protobuf:"varint,24,opt,name=manager_id,proto3" json:"manager_id,omitempty"` + // user.field.manager + Manager string `protobuf:"bytes,25,opt,name=manager,proto3" json:"manager,omitempty"` + // Roles holds the value of the roles edge. + Roles []*Role `protobuf:"bytes,26,rep,name=roles,proto3" json:"roles,omitempty"` + // Role Ids holds the value of the role_ids + RoleIds []int64 `protobuf:"varint,27,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *User) Reset() { + *x = User{} + mi := &file_types_system_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *User) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*User) ProtoMessage() {} + +func (x *User) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[4] + 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 User.ProtoReflect.Descriptor instead. +func (*User) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{4} +} + +func (x *User) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *User) GetCreateAuthor() int64 { + if x != nil { + return x.CreateAuthor + } + return 0 +} + +func (x *User) GetUpdateAuthor() int64 { + if x != nil { + return x.UpdateAuthor + } + return 0 +} + +func (x *User) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *User) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *User) GetUuid() string { + if x != nil { + return x.Uuid + } + return "" +} + +func (x *User) GetAllowedIp() string { + if x != nil { + return x.AllowedIp + } + return "" +} + +func (x *User) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *User) GetNickname() string { + if x != nil { + return x.Nickname + } + return "" +} + +func (x *User) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *User) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *User) GetGender() string { + if x != nil { + return x.Gender + } + return "" +} + +func (x *User) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *User) GetConfirmPassword() string { + if x != nil { + return x.ConfirmPassword + } + return "" +} + +func (x *User) GetSalt() string { + if x != nil { + return x.Salt + } + return "" +} + +func (x *User) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *User) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *User) GetRemark() string { + if x != nil { + return x.Remark + } + return "" +} + +func (x *User) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +func (x *User) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *User) GetLastLoginIp() string { + if x != nil { + return x.LastLoginIp + } + return "" +} + +func (x *User) GetLastLoginTime() *timestamppb.Timestamp { + if x != nil { + return x.LastLoginTime + } + return nil +} + +func (x *User) GetSanctionDate() *timestamppb.Timestamp { + if x != nil { + return x.SanctionDate + } + return nil +} + +func (x *User) GetManagerId() int64 { + if x != nil { + return x.ManagerId + } + return 0 +} + +func (x *User) GetManager() string { + if x != nil { + return x.Manager + } + return "" +} + +func (x *User) GetRoles() []*Role { + if x != nil { + return x.Roles + } + return nil +} + +func (x *User) GetRoleIds() []int64 { + if x != nil { + return x.RoleIds + } + return nil +} + +// UserEdges holds the relations/edges for other nodes in the graph. +type UserEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Roles holds the value of the roles edge. + Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + // UserRole holds the value of the user_role edge. + UserRoles []*UserRole `protobuf:"bytes,2,rep,name=user_roles,proto3" json:"user_roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserEdges) Reset() { + *x = UserEdges{} + mi := &file_types_system_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserEdges) ProtoMessage() {} + +func (x *UserEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[5] + 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 UserEdges.ProtoReflect.Descriptor instead. +func (*UserEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{5} +} + +func (x *UserEdges) GetRoles() []*Role { + if x != nil { + return x.Roles + } + return nil +} + +func (x *UserEdges) GetUserRoles() []*UserRole { + if x != nil { + return x.UserRoles + } + return nil +} + +// UserRole is the model entity for the UserRole schema. +type UserRole struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // UserID holds the value of the "user_id" field. + UserId int64 `protobuf:"varint,4,opt,name=user_id,proto3" json:"user_id,omitempty"` + // RoleID holds the value of the "role_id" field. + RoleId int64 `protobuf:"varint,5,opt,name=role_id,proto3" json:"role_id,omitempty"` + // RoleName holds the value of the "role_name" field. + RoleName string `protobuf:"bytes,6,opt,name=role_name,proto3" json:"role_name,omitempty"` + // User holds the value of the user edge. + User *User `protobuf:"bytes,21,opt,name=user,proto3" json:"user,omitempty"` + // Role holds the value of the role edge. + Role *Role `protobuf:"bytes,22,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserRole) Reset() { + *x = UserRole{} + mi := &file_types_system_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserRole) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserRole) ProtoMessage() {} + +func (x *UserRole) ProtoReflect() protoreflect.Message { + mi := &file_types_system_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 UserRole.ProtoReflect.Descriptor instead. +func (*UserRole) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{6} +} + +func (x *UserRole) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UserRole) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *UserRole) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *UserRole) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *UserRole) GetRoleId() int64 { + if x != nil { + return x.RoleId + } + return 0 +} + +func (x *UserRole) GetRoleName() string { + if x != nil { + return x.RoleName + } + return "" +} + +func (x *UserRole) GetUser() *User { + if x != nil { + return x.User + } + return nil +} + +func (x *UserRole) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +// UserRoleEdges holds the relations/edges for other nodes in the graph. +type UserRoleEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // User holds the value of the user edge. + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // Role holds the value of the role edge. + Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserRoleEdges) Reset() { + *x = UserRoleEdges{} + mi := &file_types_system_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserRoleEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserRoleEdges) ProtoMessage() {} + +func (x *UserRoleEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserRoleEdges.ProtoReflect.Descriptor instead. +func (*UserRoleEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{7} +} + +func (x *UserRoleEdges) GetUser() *User { + if x != nil { + return x.User + } + return nil +} + +func (x *UserRoleEdges) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +// RoleMenu is the model entity for the RoleMenu schema. +type RoleMenu struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // RoleID holds the value of the "role_id" field. + RoleId int64 `protobuf:"varint,4,opt,name=role_id,proto3" json:"role_id,omitempty"` + // MenuID holds the value of the "menu_id" field. + MenuId int64 `protobuf:"varint,5,opt,name=menu_id,proto3" json:"menu_id,omitempty"` + // Role holds the value of the role edge. + Role *Role `protobuf:"bytes,21,opt,name=role,proto3" json:"role,omitempty"` + // Menu holds the value of the menu edge. + Menu *Menu `protobuf:"bytes,22,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleMenu) Reset() { + *x = RoleMenu{} + mi := &file_types_system_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleMenu) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleMenu) ProtoMessage() {} + +func (x *RoleMenu) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[8] + 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 RoleMenu.ProtoReflect.Descriptor instead. +func (*RoleMenu) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{8} +} + +func (x *RoleMenu) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *RoleMenu) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *RoleMenu) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *RoleMenu) GetRoleId() int64 { + if x != nil { + return x.RoleId + } + return 0 +} + +func (x *RoleMenu) GetMenuId() int64 { + if x != nil { + return x.MenuId + } + return 0 +} + +func (x *RoleMenu) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +func (x *RoleMenu) GetMenu() *Menu { + if x != nil { + return x.Menu + } + return nil +} + +// RoleMenuEdges holds the relations/edges for other nodes in the graph. +type RoleMenuEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Role holds the value of the role edge. + Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + // Menu holds the value of the menu edge. + Menu *Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleMenuEdges) Reset() { + *x = RoleMenuEdges{} + mi := &file_types_system_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleMenuEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleMenuEdges) ProtoMessage() {} + +func (x *RoleMenuEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[9] + 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 RoleMenuEdges.ProtoReflect.Descriptor instead. +func (*RoleMenuEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{9} +} + +func (x *RoleMenuEdges) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +func (x *RoleMenuEdges) GetMenu() *Menu { + if x != nil { + return x.Menu + } + return nil +} + +// Resource is the model entity for the Resource schema. +type Resource struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // resource.field.name + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // resource.field.keyword + Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` + // resource.field.i18n_key + I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` + // resource.field.type + Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + // resource.field.status + Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` + // resource.field.path + Path string `protobuf:"bytes,9,opt,name=path,proto3" json:"path,omitempty"` + // resource.field.operation + Operation string `protobuf:"bytes,10,opt,name=operation,proto3" json:"operation,omitempty"` + // resource.field.method + Method string `protobuf:"bytes,11,opt,name=method,proto3" json:"method,omitempty"` + // resource.field.component + Component string `protobuf:"bytes,12,opt,name=component,proto3" json:"component,omitempty"` + // resource.field.icon + Icon string `protobuf:"bytes,13,opt,name=icon,proto3" json:"icon,omitempty"` + // resource.field.sequence + Sequence int32 `protobuf:"varint,14,opt,name=sequence,proto3" json:"sequence,omitempty"` + // resource.field.visible + Visible bool `protobuf:"varint,15,opt,name=visible,proto3" json:"visible,omitempty"` + // resource.field.tree_path + TreePath string `protobuf:"bytes,16,opt,name=tree_path,proto3" json:"tree_path,omitempty"` + // resource.field.properties + Properties map[string]string `protobuf:"bytes,17,rep,name=properties,proto3" json:"properties,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + // resource.field.description + Description string `protobuf:"bytes,18,opt,name=description,proto3" json:"description,omitempty"` + // resource.field.parent_id + ParentId int64 `protobuf:"varint,19,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + // Children holds the value of the children edge. + Children []*Resource `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Resource `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` + // Permission Ids holds the value of the permission_ids edge. + PermissionIds []int64 `protobuf:"varint,23,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` + // Permissions holds the value of the permissions edge. + Permissions []*Permission `protobuf:"bytes,24,rep,name=permissions,proto3" json:"permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Resource) Reset() { + *x = Resource{} + mi := &file_types_system_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Resource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resource) ProtoMessage() {} + +func (x *Resource) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[10] + 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 Resource.ProtoReflect.Descriptor instead. +func (*Resource) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{10} +} + +func (x *Resource) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Resource) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Resource) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Resource) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Resource) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Resource) GetI18NKey() string { + if x != nil { + return x.I18NKey + } + return "" +} + +func (x *Resource) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Resource) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *Resource) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *Resource) GetOperation() string { + if x != nil { + return x.Operation + } + return "" +} + +func (x *Resource) GetMethod() string { + if x != nil { + return x.Method + } + return "" +} + +func (x *Resource) GetComponent() string { + if x != nil { + return x.Component + } + return "" +} + +func (x *Resource) GetIcon() string { + if x != nil { + return x.Icon + } + return "" +} + +func (x *Resource) GetSequence() int32 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *Resource) GetVisible() bool { + if x != nil { + return x.Visible + } + return false +} + +func (x *Resource) GetTreePath() string { + if x != nil { + return x.TreePath + } + return "" +} + +func (x *Resource) GetProperties() map[string]string { + if x != nil { + return x.Properties + } + return nil +} + +func (x *Resource) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Resource) GetParentId() int64 { + if x != nil { + return x.ParentId + } + return 0 +} + +func (x *Resource) GetChildren() []*Resource { + if x != nil { + return x.Children + } + return nil +} + +func (x *Resource) GetParent() *Resource { + if x != nil { + return x.Parent + } + return nil +} + +func (x *Resource) GetPermissionIds() []int64 { + if x != nil { + return x.PermissionIds + } + return nil +} + +func (x *Resource) GetPermissions() []*Permission { + if x != nil { + return x.Permissions + } + return nil +} + +// ResourceEdges holds the relations/edges for other nodes in the graph. +type ResourceEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Menu holds the value of the menu edge. + Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ResourceEdges) Reset() { + *x = ResourceEdges{} + mi := &file_types_system_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResourceEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResourceEdges) ProtoMessage() {} + +func (x *ResourceEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[11] + 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 ResourceEdges.ProtoReflect.Descriptor instead. +func (*ResourceEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{11} +} + +func (x *ResourceEdges) GetMenu() *Menu { + if x != nil { + return x.Menu + } + return nil +} + +// department.table.comment +type Department struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // department.field.keyword + Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` + // department.field.name + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + // menu.field.tree_path + TreePath string `protobuf:"bytes,6,opt,name=tree_path,proto3" json:"tree_path,omitempty"` + // department.field.sequence + Sequence int32 `protobuf:"varint,7,opt,name=sequence,proto3" json:"sequence,omitempty"` + // department.field.status + Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` + // department.field.level + Level int32 `protobuf:"varint,9,opt,name=level,proto3" json:"level,omitempty"` + // department.field.description + Description string `protobuf:"bytes,10,opt,name=description,proto3" json:"description,omitempty"` + // department.field.parent_id + ParentId int64 `protobuf:"varint,11,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + // Children holds the value of the children edge. + Children []*Department `protobuf:"bytes,12,rep,name=children,proto3" json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Department `protobuf:"bytes,13,opt,name=parent,proto3" json:"parent,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Department) Reset() { + *x = Department{} + mi := &file_types_system_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Department) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Department) ProtoMessage() {} + +func (x *Department) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[12] + 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 Department.ProtoReflect.Descriptor instead. +func (*Department) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{12} +} + +func (x *Department) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Department) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Department) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Department) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Department) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Department) GetTreePath() string { + if x != nil { + return x.TreePath + } + return "" +} + +func (x *Department) GetSequence() int32 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *Department) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *Department) GetLevel() int32 { + if x != nil { + return x.Level + } + return 0 +} + +func (x *Department) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Department) GetParentId() int64 { + if x != nil { + return x.ParentId + } + return 0 +} + +func (x *Department) GetChildren() []*Department { + if x != nil { + return x.Children + } + return nil +} + +func (x *Department) GetParent() *Department { + if x != nil { + return x.Parent + } + return nil +} + +type DepartmentEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Users holds the value of the users edge. + Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` + // Positions holds the value of the positions edge. + Positions []*Position `protobuf:"bytes,2,rep,name=positions,proto3" json:"positions,omitempty"` + // Children holds the value of the children edge. + Children []*Department `protobuf:"bytes,3,rep,name=children,proto3" json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Department `protobuf:"bytes,4,opt,name=parent,proto3" json:"parent,omitempty"` + // UserDepartments holds the value of the user_departments edge. + UserDepartments []*UserDepartment `protobuf:"bytes,5,rep,name=user_departments,proto3" json:"user_departments,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DepartmentEdges) Reset() { + *x = DepartmentEdges{} + mi := &file_types_system_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DepartmentEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DepartmentEdges) ProtoMessage() {} + +func (x *DepartmentEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[13] + 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 DepartmentEdges.ProtoReflect.Descriptor instead. +func (*DepartmentEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{13} +} + +func (x *DepartmentEdges) GetUsers() []*User { + if x != nil { + return x.Users + } + return nil +} + +func (x *DepartmentEdges) GetPositions() []*Position { + if x != nil { + return x.Positions + } + return nil +} + +func (x *DepartmentEdges) GetChildren() []*Department { + if x != nil { + return x.Children + } + return nil +} + +func (x *DepartmentEdges) GetParent() *Department { + if x != nil { + return x.Parent + } + return nil +} + +func (x *DepartmentEdges) GetUserDepartments() []*UserDepartment { + if x != nil { + return x.UserDepartments + } + return nil +} + +// user_department.table.comment +type UserDepartment struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // field.foreign_key.comment + UserId int64 `protobuf:"varint,2,opt,name=user_id,proto3" json:"user_id,omitempty"` + // field.foreign_key.comment + DepartmentId int64 `protobuf:"varint,3,opt,name=department_id,proto3" json:"department_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the UserDepartmentQuery when eager-loading is set. + Edges *UserDepartmentEdges `protobuf:"bytes,4,opt,name=edges,proto3" json:"edges,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserDepartment) Reset() { + *x = UserDepartment{} + mi := &file_types_system_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserDepartment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserDepartment) ProtoMessage() {} + +func (x *UserDepartment) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[14] + 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 UserDepartment.ProtoReflect.Descriptor instead. +func (*UserDepartment) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{14} +} + +func (x *UserDepartment) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UserDepartment) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *UserDepartment) GetDepartmentId() int64 { + if x != nil { + return x.DepartmentId + } + return 0 +} + +func (x *UserDepartment) GetEdges() *UserDepartmentEdges { + if x != nil { + return x.Edges + } + return nil +} + +// UserDepartmentEdges holds the relations/edges for other nodes in the graph. +type UserDepartmentEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // User holds the value of the user edge. + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // Department holds the value of the department edge. + Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserDepartmentEdges) Reset() { + *x = UserDepartmentEdges{} + mi := &file_types_system_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserDepartmentEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserDepartmentEdges) ProtoMessage() {} + +func (x *UserDepartmentEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[15] + 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 UserDepartmentEdges.ProtoReflect.Descriptor instead. +func (*UserDepartmentEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{15} +} + +func (x *UserDepartmentEdges) GetUser() *User { + if x != nil { + return x.User + } + return nil +} + +func (x *UserDepartmentEdges) GetDepartment() *Department { + if x != nil { + return x.Department + } + return nil +} + +// position.table.comment +type Position struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // position.field.name + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // position.field.keyword + Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` + // position.field.description + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + // department.field.department_id + DepartmentId int64 `protobuf:"varint,7,opt,name=department_id,proto3" json:"department_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Position) Reset() { + *x = Position{} + mi := &file_types_system_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Position) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Position) ProtoMessage() {} + +func (x *Position) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[16] + 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 Position.ProtoReflect.Descriptor instead. +func (*Position) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{16} +} + +func (x *Position) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Position) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Position) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Position) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Position) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Position) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Position) GetDepartmentId() int64 { + if x != nil { + return x.DepartmentId + } + return 0 +} + +// PositionEdges holds the relations/edges for other nodes in the graph. +type PositionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Department holds the value of the department edge. + Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + // Users holds the value of the users edge. + Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` + // Permissions holds the value of the permissions edge. + Permissions []*Permission `protobuf:"bytes,3,rep,name=permissions,proto3" json:"permissions,omitempty"` + // UserPositions holds the value of the user_positions edge. + UserPositions []*UserPosition `protobuf:"bytes,4,rep,name=user_positions,proto3" json:"user_positions,omitempty"` + // PositionPermissions holds the value of the position_permissions edge. + PositionPermissions []*PositionPermission `protobuf:"bytes,5,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PositionEdges) Reset() { + *x = PositionEdges{} + mi := &file_types_system_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PositionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PositionEdges) ProtoMessage() {} + +func (x *PositionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[17] + 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 PositionEdges.ProtoReflect.Descriptor instead. +func (*PositionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{17} +} + +func (x *PositionEdges) GetDepartment() *Department { + if x != nil { + return x.Department + } + return nil +} + +func (x *PositionEdges) GetUsers() []*User { + if x != nil { + return x.Users + } + return nil +} + +func (x *PositionEdges) GetPermissions() []*Permission { + if x != nil { + return x.Permissions + } + return nil +} + +func (x *PositionEdges) GetUserPositions() []*UserPosition { + if x != nil { + return x.UserPositions + } + return nil +} + +func (x *PositionEdges) GetPositionPermissions() []*PositionPermission { + if x != nil { + return x.PositionPermissions + } + return nil +} + +// permission.table.comment +type Permission struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // permission.field.name + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // permission.field.keyword + Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` + // permission.field.description + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + // permission.field.data_scope + DataScope string `protobuf:"bytes,7,opt,name=data_scope,proto3" json:"data_scope,omitempty"` + // permission.field.data_rules + DataRules map[string]string `protobuf:"bytes,8,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + // permission.field.resource_ids + ResourceIds []int64 `protobuf:"varint,9,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` + // permission.field.resources + Resources []*Resource `protobuf:"bytes,10,rep,name=resources,proto3" json:"resources,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Permission) Reset() { + *x = Permission{} + mi := &file_types_system_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Permission) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Permission) ProtoMessage() {} + +func (x *Permission) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Permission.ProtoReflect.Descriptor instead. +func (*Permission) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{18} +} + +func (x *Permission) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Permission) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Permission) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Permission) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Permission) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Permission) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Permission) GetDataScope() string { + if x != nil { + return x.DataScope + } + return "" +} + +func (x *Permission) GetDataRules() map[string]string { + if x != nil { + return x.DataRules + } + return nil +} + +func (x *Permission) GetResourceIds() []int64 { + if x != nil { + return x.ResourceIds + } + return nil +} + +func (x *Permission) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +// PermissionEdges holds the relations/edges for other nodes in the graph. +type PermissionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Roles holds the value of the roles edge. + Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + // Resources holds the value of the resources edge. + Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + // Positions holds the value of the positions edge. + Positions []*Position `protobuf:"bytes,3,rep,name=positions,proto3" json:"positions,omitempty"` + // RolePermissions holds the value of the role_permissions edge. + RolePermissions []*RolePermission `protobuf:"bytes,4,rep,name=role_permissions,proto3" json:"role_permissions,omitempty"` + // PermissionResources holds the value of the permission_resources edge. + PermissionResources []*PermissionResource `protobuf:"bytes,5,rep,name=permission_resources,proto3" json:"permission_resources,omitempty"` + // PositionPermissions holds the value of the position_permissions edge. + PositionPermissions []*PositionPermission `protobuf:"bytes,6,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PermissionEdges) Reset() { + *x = PermissionEdges{} + mi := &file_types_system_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PermissionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PermissionEdges) ProtoMessage() {} + +func (x *PermissionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PermissionEdges.ProtoReflect.Descriptor instead. +func (*PermissionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{19} +} + +func (x *PermissionEdges) GetRoles() []*Role { + if x != nil { + return x.Roles + } + return nil +} + +func (x *PermissionEdges) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *PermissionEdges) GetPositions() []*Position { + if x != nil { + return x.Positions + } + return nil +} + +func (x *PermissionEdges) GetRolePermissions() []*RolePermission { + if x != nil { + return x.RolePermissions + } + return nil +} + +func (x *PermissionEdges) GetPermissionResources() []*PermissionResource { + if x != nil { + return x.PermissionResources + } + return nil +} + +func (x *PermissionEdges) GetPositionPermissions() []*PositionPermission { + if x != nil { + return x.PositionPermissions + } + return nil +} + +// user_position.table.comment +type UserPosition struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // field.foreign_key.comment + UserId int64 `protobuf:"varint,2,opt,name=user_id,proto3" json:"user_id,omitempty"` + // field.foreign_key.comment + PositionId int64 `protobuf:"varint,3,opt,name=position_id,proto3" json:"position_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserPosition) Reset() { + *x = UserPosition{} + mi := &file_types_system_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserPosition) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserPosition) ProtoMessage() {} + +func (x *UserPosition) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserPosition.ProtoReflect.Descriptor instead. +func (*UserPosition) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{20} +} + +func (x *UserPosition) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UserPosition) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *UserPosition) GetPositionId() int64 { + if x != nil { + return x.PositionId + } + return 0 +} + +// UserPositionEdges holds the relations/edges for other nodes in the graph. +type UserPositionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // User holds the value of the user edge. + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // Position holds the value of the position edge. + Position *Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserPositionEdges) Reset() { + *x = UserPositionEdges{} + mi := &file_types_system_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserPositionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserPositionEdges) ProtoMessage() {} + +func (x *UserPositionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[21] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserPositionEdges.ProtoReflect.Descriptor instead. +func (*UserPositionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{21} +} + +func (x *UserPositionEdges) GetUser() *User { + if x != nil { + return x.User + } + return nil +} + +func (x *UserPositionEdges) GetPosition() *Position { + if x != nil { + return x.Position + } + return nil +} + +// position_permission.table.comment +type PositionPermission struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // position_permission.field.position_id + PositionId int64 `protobuf:"varint,2,opt,name=position_id,proto3" json:"position_id,omitempty"` + // position_permission.field.permission_id + PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PositionPermission) Reset() { + *x = PositionPermission{} + mi := &file_types_system_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PositionPermission) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PositionPermission) ProtoMessage() {} + +func (x *PositionPermission) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[22] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PositionPermission.ProtoReflect.Descriptor instead. +func (*PositionPermission) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{22} +} + +func (x *PositionPermission) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *PositionPermission) GetPositionId() int64 { + if x != nil { + return x.PositionId + } + return 0 +} + +func (x *PositionPermission) GetPermissionId() int64 { + if x != nil { + return x.PermissionId + } + return 0 +} + +// PositionPermissionEdges holds the relations/edges for other nodes in the graph. +type PositionPermissionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Position holds the value of the position edge. + Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + // Permission holds the value of the permission edge. + Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PositionPermissionEdges) Reset() { + *x = PositionPermissionEdges{} + mi := &file_types_system_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PositionPermissionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PositionPermissionEdges) ProtoMessage() {} + +func (x *PositionPermissionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[23] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PositionPermissionEdges.ProtoReflect.Descriptor instead. +func (*PositionPermissionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{23} +} + +func (x *PositionPermissionEdges) GetPosition() *Position { + if x != nil { + return x.Position + } + return nil +} + +func (x *PositionPermissionEdges) GetPermission() *Permission { + if x != nil { + return x.Permission + } + return nil +} + +// role_permission.table.comment +type RolePermission struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // field.foreign_key.comment + RoleId int64 `protobuf:"varint,2,opt,name=role_id,proto3" json:"role_id,omitempty"` + // field.foreign_key.comment + PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RolePermission) Reset() { + *x = RolePermission{} + mi := &file_types_system_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RolePermission) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RolePermission) ProtoMessage() {} + +func (x *RolePermission) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[24] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RolePermission.ProtoReflect.Descriptor instead. +func (*RolePermission) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{24} +} + +func (x *RolePermission) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *RolePermission) GetRoleId() int64 { + if x != nil { + return x.RoleId + } + return 0 +} + +func (x *RolePermission) GetPermissionId() int64 { + if x != nil { + return x.PermissionId + } + return 0 +} + +// RolePermissionEdges holds the relations/edges for other nodes in the graph. +type RolePermissionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Role holds the value of the role edge. + Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + // Permission holds the value of the permission edge. + Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RolePermissionEdges) Reset() { + *x = RolePermissionEdges{} + mi := &file_types_system_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RolePermissionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RolePermissionEdges) ProtoMessage() {} + +func (x *RolePermissionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_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 RolePermissionEdges.ProtoReflect.Descriptor instead. +func (*RolePermissionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{25} +} + +func (x *RolePermissionEdges) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +func (x *RolePermissionEdges) GetPermission() *Permission { + if x != nil { + return x.Permission + } + return nil +} + +// permission_resource.table.comment +type PermissionResource struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // field.foreign_key.comment + PermissionId int64 `protobuf:"varint,2,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + // field.foreign_key.comment + ResourceId int64 `protobuf:"varint,3,opt,name=resource_id,proto3" json:"resource_id,omitempty"` + // permission_resource.field.actions + Actions string `protobuf:"bytes,4,opt,name=actions,proto3" json:"actions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PermissionResource) Reset() { + *x = PermissionResource{} + mi := &file_types_system_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PermissionResource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PermissionResource) ProtoMessage() {} + +func (x *PermissionResource) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[26] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PermissionResource.ProtoReflect.Descriptor instead. +func (*PermissionResource) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{26} +} + +func (x *PermissionResource) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *PermissionResource) GetPermissionId() int64 { + if x != nil { + return x.PermissionId + } + return 0 +} + +func (x *PermissionResource) GetResourceId() int64 { + if x != nil { + return x.ResourceId + } + return 0 +} + +func (x *PermissionResource) GetActions() string { + if x != nil { + return x.Actions + } + return "" +} + +// PermissionResourceEdges holds the relations/edges for other nodes in the graph. +type PermissionResourceEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Permission holds the value of the permission edge. + Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + // Resource holds the value of the resource edge. + Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PermissionResourceEdges) Reset() { + *x = PermissionResourceEdges{} + mi := &file_types_system_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PermissionResourceEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PermissionResourceEdges) ProtoMessage() {} + +func (x *PermissionResourceEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[27] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PermissionResourceEdges.ProtoReflect.Descriptor instead. +func (*PermissionResourceEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{27} +} + +func (x *PermissionResourceEdges) GetPermission() *Permission { + if x != nil { + return x.Permission + } + return nil +} + +func (x *PermissionResourceEdges) GetResource() *Resource { + if x != nil { + return x.Resource + } + return nil +} + +var File_types_system_proto protoreflect.FileDescriptor + +const file_types_system_proto_rawDesc = "" + + "\n" + + "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xae\x05\n" + + "\x04Menu\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12\x1a\n" + + "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12 \n" + + "\vdescription\x18\a \x01(\tR\vdescription\x12\x1a\n" + + "\bsequence\x18\b \x01(\x05R\bsequence\x12\x12\n" + + "\x04type\x18\t \x01(\tR\x04type\x12\x12\n" + + "\x04icon\x18\n" + + " \x01(\tR\x04icon\x12\x12\n" + + "\x04path\x18\v \x01(\tR\x04path\x12\x1e\n" + + "\n" + + "properties\x18\f \x01(\tR\n" + + "properties\x12\x16\n" + + "\x06status\x18\r \x01(\x05R\x06status\x12\x1c\n" + + "\tparent_id\x18\x0e \x01(\x03R\tparent_id\x12 \n" + + "\vparent_path\x18\x0f \x01(\tR\vparent_path\x127\n" + + "\bchildren\x18\x15 \x03(\v2\x1b.api.v1.services.types.MenuR\bchildren\x123\n" + + "\x06parent\x18\x16 \x01(\v2\x1b.api.v1.services.types.MenuR\x06parent\x12=\n" + + "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + + "\x05roles\x18\x18 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xac\x02\n" + + "\tMenuEdges\x127\n" + + "\bchildren\x18\x01 \x03(\v2\x1b.api.v1.services.types.MenuR\bchildren\x123\n" + + "\x06parent\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x06parent\x12=\n" + + "\tresources\x18\x03 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + + "\x05roles\x18\x04 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12?\n" + + "\n" + + "role_menus\x18\x05 \x03(\v2\x1f.api.v1.services.types.RoleMenuR\n" + + "role_menus\"\xfc\x04\n" + + "\x04Role\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x12\n" + + "\x04type\x18\a \x01(\x05R\x04type\x12\x1a\n" + + "\bsequence\x18\b \x01(\x05R\bsequence\x12\x16\n" + + "\x06status\x18\t \x01(\x05R\x06status\x12\x1a\n" + + "\bis_types\x18\n" + + " \x01(\bR\bis_types\x121\n" + + "\x05menus\x18\x15 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x121\n" + + "\x05users\x18\x16 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + + "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\"\n" + + "\fresource_ids\x18\x18 \x03(\x03R\fresource_ids\x12C\n" + + "\vpermissions\x18\x19 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12&\n" + + "\x0epermission_ids\x18\x1a \x03(\x03R\x0epermission_ids\"\xf3\x01\n" + + "\tRoleEdges\x121\n" + + "\x05menus\x18\x01 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x121\n" + + "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12?\n" + + "\n" + + "role_menus\x18\x03 \x03(\v2\x1f.api.v1.services.types.RoleMenuR\n" + + "role_menus\x12?\n" + + "\n" + + "user_roles\x18\x04 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + + "user_roles\"\xaa\a\n" + + "\x04User\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + + "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + + "\rupdate_author\x18\x03 \x01(\x03R\rupdate_author\x12<\n" + + "\vcreate_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04uuid\x18\x06 \x01(\tR\x04uuid\x12\x1e\n" + + "\n" + + "allowed_ip\x18\a \x01(\tR\n" + + "allowed_ip\x12\x1a\n" + + "\busername\x18\b \x01(\tR\busername\x12\x1a\n" + + "\bnickname\x18\t \x01(\tR\bnickname\x12\x16\n" + + "\x06avatar\x18\n" + + " \x01(\tR\x06avatar\x12\x12\n" + + "\x04name\x18\v \x01(\tR\x04name\x12\x16\n" + + "\x06gender\x18\f \x01(\tR\x06gender\x12\x1a\n" + + "\bpassword\x18\r \x01(\tR\bpassword\x12*\n" + + "\x10confirm_password\x18\x0e \x01(\tR\x10confirm_password\x12\x12\n" + + "\x04salt\x18\x0f \x01(\tR\x04salt\x12\x14\n" + + "\x05phone\x18\x10 \x01(\tR\x05phone\x12\x14\n" + + "\x05email\x18\x11 \x01(\tR\x05email\x12\x16\n" + + "\x06remark\x18\x12 \x01(\tR\x06remark\x12\x14\n" + + "\x05token\x18\x13 \x01(\tR\x05token\x12\x16\n" + + "\x06status\x18\x14 \x01(\x05R\x06status\x12$\n" + + "\rlast_login_ip\x18\x15 \x01(\tR\rlast_login_ip\x12D\n" + + "\x0flast_login_time\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12E\n" + + "\rsanction_date\x18\x17 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x12\x1e\n" + + "\n" + + "manager_id\x18\x18 \x01(\x03R\n" + + "manager_id\x12\x18\n" + + "\amanager\x18\x19 \x01(\tR\amanager\x121\n" + + "\x05roles\x18\x1a \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + + "\brole_ids\x18\x1b \x03(\x03R\brole_idsB\x10\n" + + "\x0e_sanction_date\"\x7f\n" + + "\tUserEdges\x121\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12?\n" + + "\n" + + "user_roles\x18\x02 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + + "user_roles\"\xca\x02\n" + + "\bUserRole\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\auser_id\x18\x04 \x01(\x03R\auser_id\x12\x18\n" + + "\arole_id\x18\x05 \x01(\x03R\arole_id\x12\x1c\n" + + "\trole_name\x18\x06 \x01(\tR\trole_name\x12/\n" + + "\x04user\x18\x15 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + + "\x04role\x18\x16 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"q\n" + + "\rUserRoleEdges\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + + "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\xac\x02\n" + + "\bRoleMenu\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\arole_id\x18\x04 \x01(\x03R\arole_id\x12\x18\n" + + "\amenu_id\x18\x05 \x01(\x03R\amenu_id\x12/\n" + + "\x04role\x18\x15 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + + "\x04menu\x18\x16 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"q\n" + + "\rRoleMenuEdges\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + + "\x04menu\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"\x8f\a\n" + + "\bResource\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x1a\n" + + "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12\x12\n" + + "\x04type\x18\a \x01(\tR\x04type\x12\x16\n" + + "\x06status\x18\b \x01(\x05R\x06status\x12\x12\n" + + "\x04path\x18\t \x01(\tR\x04path\x12\x1c\n" + + "\toperation\x18\n" + + " \x01(\tR\toperation\x12\x16\n" + + "\x06method\x18\v \x01(\tR\x06method\x12\x1c\n" + + "\tcomponent\x18\f \x01(\tR\tcomponent\x12\x12\n" + + "\x04icon\x18\r \x01(\tR\x04icon\x12\x1a\n" + + "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x18\n" + + "\avisible\x18\x0f \x01(\bR\avisible\x12\x1c\n" + + "\ttree_path\x18\x10 \x01(\tR\ttree_path\x12O\n" + + "\n" + + "properties\x18\x11 \x03(\v2/.api.v1.services.types.Resource.PropertiesEntryR\n" + + "properties\x12 \n" + + "\vdescription\x18\x12 \x01(\tR\vdescription\x12\x1c\n" + + "\tparent_id\x18\x13 \x01(\x03R\tparent_id\x12;\n" + + "\bchildren\x18\x15 \x03(\v2\x1f.api.v1.services.types.ResourceR\bchildren\x127\n" + + "\x06parent\x18\x16 \x01(\v2\x1f.api.v1.services.types.ResourceR\x06parent\x12&\n" + + "\x0epermission_ids\x18\x17 \x03(\x03R\x0epermission_ids\x12C\n" + + "\vpermissions\x18\x18 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x1a=\n" + + "\x0fPropertiesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"@\n" + + "\rResourceEdges\x12/\n" + + "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"\xe8\x03\n" + + "\n" + + "Department\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12\x1c\n" + + "\ttree_path\x18\x06 \x01(\tR\ttree_path\x12\x1a\n" + + "\bsequence\x18\a \x01(\x05R\bsequence\x12\x16\n" + + "\x06status\x18\b \x01(\x05R\x06status\x12\x14\n" + + "\x05level\x18\t \x01(\x05R\x05level\x12 \n" + + "\vdescription\x18\n" + + " \x01(\tR\vdescription\x12\x1c\n" + + "\tparent_id\x18\v \x01(\x03R\tparent_id\x12=\n" + + "\bchildren\x18\f \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + + "\x06parent\x18\r \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\"\xd0\x02\n" + + "\x0fDepartmentEdges\x121\n" + + "\x05users\x18\x01 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + + "\tpositions\x18\x02 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12=\n" + + "\bchildren\x18\x03 \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + + "\x06parent\x18\x04 \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\x12Q\n" + + "\x10user_departments\x18\x05 \x03(\v2%.api.v1.services.types.UserDepartmentR\x10user_departments\"\xa2\x01\n" + + "\x0eUserDepartment\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\auser_id\x18\x02 \x01(\x03R\auser_id\x12$\n" + + "\rdepartment_id\x18\x03 \x01(\x03R\rdepartment_id\x12@\n" + + "\x05edges\x18\x04 \x01(\v2*.api.v1.services.types.UserDepartmentEdgesR\x05edges\"\x89\x01\n" + + "\x13UserDepartmentEdges\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12A\n" + + "\n" + + "department\x18\x02 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\"\x8c\x02\n" + + "\bPosition\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12$\n" + + "\rdepartment_id\x18\a \x01(\x03R\rdepartment_id\"\xf6\x02\n" + + "\rPositionEdges\x12A\n" + + "\n" + + "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\x121\n" + + "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12C\n" + + "\vpermissions\x18\x03 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12K\n" + + "\x0euser_positions\x18\x04 \x03(\v2#.api.v1.services.types.UserPositionR\x0euser_positions\x12]\n" + + "\x14position_permissions\x18\x05 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"\xfb\x03\n" + + "\n" + + "Permission\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x1e\n" + + "\n" + + "data_scope\x18\a \x01(\tR\n" + + "data_scope\x12P\n" + + "\n" + + "data_rules\x18\b \x03(\v20.api.v1.services.types.Permission.DataRulesEntryR\n" + + "data_rules\x12\"\n" + + "\fresource_ids\x18\t \x03(\x03R\fresource_ids\x12=\n" + + "\tresources\x18\n" + + " \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x1a<\n" + + "\x0eDataRulesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xd3\x03\n" + + "\x0fPermissionEdges\x121\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12=\n" + + "\tpositions\x18\x03 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12Q\n" + + "\x10role_permissions\x18\x04 \x03(\v2%.api.v1.services.types.RolePermissionR\x10role_permissions\x12]\n" + + "\x14permission_resources\x18\x05 \x03(\v2).api.v1.services.types.PermissionResourceR\x14permission_resources\x12]\n" + + "\x14position_permissions\x18\x06 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"Z\n" + + "\fUserPosition\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\auser_id\x18\x02 \x01(\x03R\auser_id\x12 \n" + + "\vposition_id\x18\x03 \x01(\x03R\vposition_id\"\x81\x01\n" + + "\x11UserPositionEdges\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12;\n" + + "\bposition\x18\x02 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"l\n" + + "\x12PositionPermission\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12 \n" + + "\vposition_id\x18\x02 \x01(\x03R\vposition_id\x12$\n" + + "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x99\x01\n" + + "\x17PositionPermissionEdges\x12;\n" + + "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\x12A\n" + + "\n" + + "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"`\n" + + "\x0eRolePermission\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\arole_id\x18\x02 \x01(\x03R\arole_id\x12$\n" + + "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x89\x01\n" + + "\x13RolePermissionEdges\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12A\n" + + "\n" + + "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"\x86\x01\n" + + "\x12PermissionResource\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + + "\rpermission_id\x18\x02 \x01(\x03R\rpermission_id\x12 \n" + + "\vresource_id\x18\x03 \x01(\x03R\vresource_id\x12\x18\n" + + "\aactions\x18\x04 \x01(\tR\aactions\"\x99\x01\n" + + "\x17PermissionResourceEdges\x12A\n" + + "\n" + + "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\x12;\n" + + "\bresource\x18\x02 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresourceB\xd9\x01\n" + + "\x19com.api.v1.services.typesB\vSystemProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_system_proto_rawDescOnce sync.Once + file_types_system_proto_rawDescData []byte +) + +func file_types_system_proto_rawDescGZIP() []byte { + file_types_system_proto_rawDescOnce.Do(func() { + file_types_system_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_system_proto_rawDesc), len(file_types_system_proto_rawDesc))) + }) + return file_types_system_proto_rawDescData +} + +var file_types_system_proto_msgTypes = make([]protoimpl.MessageInfo, 30) +var file_types_system_proto_goTypes = []any{ + (*Menu)(nil), // 0: api.v1.services.types.Menu + (*MenuEdges)(nil), // 1: api.v1.services.types.MenuEdges + (*Role)(nil), // 2: api.v1.services.types.Role + (*RoleEdges)(nil), // 3: api.v1.services.types.RoleEdges + (*User)(nil), // 4: api.v1.services.types.User + (*UserEdges)(nil), // 5: api.v1.services.types.UserEdges + (*UserRole)(nil), // 6: api.v1.services.types.UserRole + (*UserRoleEdges)(nil), // 7: api.v1.services.types.UserRoleEdges + (*RoleMenu)(nil), // 8: api.v1.services.types.RoleMenu + (*RoleMenuEdges)(nil), // 9: api.v1.services.types.RoleMenuEdges + (*Resource)(nil), // 10: api.v1.services.types.Resource + (*ResourceEdges)(nil), // 11: api.v1.services.types.ResourceEdges + (*Department)(nil), // 12: api.v1.services.types.Department + (*DepartmentEdges)(nil), // 13: api.v1.services.types.DepartmentEdges + (*UserDepartment)(nil), // 14: api.v1.services.types.UserDepartment + (*UserDepartmentEdges)(nil), // 15: api.v1.services.types.UserDepartmentEdges + (*Position)(nil), // 16: api.v1.services.types.Position + (*PositionEdges)(nil), // 17: api.v1.services.types.PositionEdges + (*Permission)(nil), // 18: api.v1.services.types.Permission + (*PermissionEdges)(nil), // 19: api.v1.services.types.PermissionEdges + (*UserPosition)(nil), // 20: api.v1.services.types.UserPosition + (*UserPositionEdges)(nil), // 21: api.v1.services.types.UserPositionEdges + (*PositionPermission)(nil), // 22: api.v1.services.types.PositionPermission + (*PositionPermissionEdges)(nil), // 23: api.v1.services.types.PositionPermissionEdges + (*RolePermission)(nil), // 24: api.v1.services.types.RolePermission + (*RolePermissionEdges)(nil), // 25: api.v1.services.types.RolePermissionEdges + (*PermissionResource)(nil), // 26: api.v1.services.types.PermissionResource + (*PermissionResourceEdges)(nil), // 27: api.v1.services.types.PermissionResourceEdges + nil, // 28: api.v1.services.types.Resource.PropertiesEntry + nil, // 29: api.v1.services.types.Permission.DataRulesEntry + (*timestamppb.Timestamp)(nil), // 30: google.protobuf.Timestamp +} +var file_types_system_proto_depIdxs = []int32{ + 30, // 0: api.v1.services.types.Menu.create_time:type_name -> google.protobuf.Timestamp + 30, // 1: api.v1.services.types.Menu.update_time:type_name -> google.protobuf.Timestamp + 0, // 2: api.v1.services.types.Menu.children:type_name -> api.v1.services.types.Menu + 0, // 3: api.v1.services.types.Menu.parent:type_name -> api.v1.services.types.Menu + 10, // 4: api.v1.services.types.Menu.resources:type_name -> api.v1.services.types.Resource + 2, // 5: api.v1.services.types.Menu.roles:type_name -> api.v1.services.types.Role + 0, // 6: api.v1.services.types.MenuEdges.children:type_name -> api.v1.services.types.Menu + 0, // 7: api.v1.services.types.MenuEdges.parent:type_name -> api.v1.services.types.Menu + 10, // 8: api.v1.services.types.MenuEdges.resources:type_name -> api.v1.services.types.Resource + 2, // 9: api.v1.services.types.MenuEdges.roles:type_name -> api.v1.services.types.Role + 8, // 10: api.v1.services.types.MenuEdges.role_menus:type_name -> api.v1.services.types.RoleMenu + 30, // 11: api.v1.services.types.Role.create_time:type_name -> google.protobuf.Timestamp + 30, // 12: api.v1.services.types.Role.update_time:type_name -> google.protobuf.Timestamp + 0, // 13: api.v1.services.types.Role.menus:type_name -> api.v1.services.types.Menu + 4, // 14: api.v1.services.types.Role.users:type_name -> api.v1.services.types.User + 10, // 15: api.v1.services.types.Role.resources:type_name -> api.v1.services.types.Resource + 18, // 16: api.v1.services.types.Role.permissions:type_name -> api.v1.services.types.Permission + 0, // 17: api.v1.services.types.RoleEdges.menus:type_name -> api.v1.services.types.Menu + 4, // 18: api.v1.services.types.RoleEdges.users:type_name -> api.v1.services.types.User + 8, // 19: api.v1.services.types.RoleEdges.role_menus:type_name -> api.v1.services.types.RoleMenu + 6, // 20: api.v1.services.types.RoleEdges.user_roles:type_name -> api.v1.services.types.UserRole + 30, // 21: api.v1.services.types.User.create_time:type_name -> google.protobuf.Timestamp + 30, // 22: api.v1.services.types.User.update_time:type_name -> google.protobuf.Timestamp + 30, // 23: api.v1.services.types.User.last_login_time:type_name -> google.protobuf.Timestamp + 30, // 24: api.v1.services.types.User.sanction_date:type_name -> google.protobuf.Timestamp + 2, // 25: api.v1.services.types.User.roles:type_name -> api.v1.services.types.Role + 2, // 26: api.v1.services.types.UserEdges.roles:type_name -> api.v1.services.types.Role + 6, // 27: api.v1.services.types.UserEdges.user_roles:type_name -> api.v1.services.types.UserRole + 30, // 28: api.v1.services.types.UserRole.create_time:type_name -> google.protobuf.Timestamp + 30, // 29: api.v1.services.types.UserRole.update_time:type_name -> google.protobuf.Timestamp + 4, // 30: api.v1.services.types.UserRole.user:type_name -> api.v1.services.types.User + 2, // 31: api.v1.services.types.UserRole.role:type_name -> api.v1.services.types.Role + 4, // 32: api.v1.services.types.UserRoleEdges.user:type_name -> api.v1.services.types.User + 2, // 33: api.v1.services.types.UserRoleEdges.role:type_name -> api.v1.services.types.Role + 30, // 34: api.v1.services.types.RoleMenu.create_time:type_name -> google.protobuf.Timestamp + 30, // 35: api.v1.services.types.RoleMenu.update_time:type_name -> google.protobuf.Timestamp + 2, // 36: api.v1.services.types.RoleMenu.role:type_name -> api.v1.services.types.Role + 0, // 37: api.v1.services.types.RoleMenu.menu:type_name -> api.v1.services.types.Menu + 2, // 38: api.v1.services.types.RoleMenuEdges.role:type_name -> api.v1.services.types.Role + 0, // 39: api.v1.services.types.RoleMenuEdges.menu:type_name -> api.v1.services.types.Menu + 30, // 40: api.v1.services.types.Resource.create_time:type_name -> google.protobuf.Timestamp + 30, // 41: api.v1.services.types.Resource.update_time:type_name -> google.protobuf.Timestamp + 28, // 42: api.v1.services.types.Resource.properties:type_name -> api.v1.services.types.Resource.PropertiesEntry + 10, // 43: api.v1.services.types.Resource.children:type_name -> api.v1.services.types.Resource + 10, // 44: api.v1.services.types.Resource.parent:type_name -> api.v1.services.types.Resource + 18, // 45: api.v1.services.types.Resource.permissions:type_name -> api.v1.services.types.Permission + 0, // 46: api.v1.services.types.ResourceEdges.menu:type_name -> api.v1.services.types.Menu + 30, // 47: api.v1.services.types.Department.create_time:type_name -> google.protobuf.Timestamp + 30, // 48: api.v1.services.types.Department.update_time:type_name -> google.protobuf.Timestamp + 12, // 49: api.v1.services.types.Department.children:type_name -> api.v1.services.types.Department + 12, // 50: api.v1.services.types.Department.parent:type_name -> api.v1.services.types.Department + 4, // 51: api.v1.services.types.DepartmentEdges.users:type_name -> api.v1.services.types.User + 16, // 52: api.v1.services.types.DepartmentEdges.positions:type_name -> api.v1.services.types.Position + 12, // 53: api.v1.services.types.DepartmentEdges.children:type_name -> api.v1.services.types.Department + 12, // 54: api.v1.services.types.DepartmentEdges.parent:type_name -> api.v1.services.types.Department + 14, // 55: api.v1.services.types.DepartmentEdges.user_departments:type_name -> api.v1.services.types.UserDepartment + 15, // 56: api.v1.services.types.UserDepartment.edges:type_name -> api.v1.services.types.UserDepartmentEdges + 4, // 57: api.v1.services.types.UserDepartmentEdges.user:type_name -> api.v1.services.types.User + 12, // 58: api.v1.services.types.UserDepartmentEdges.department:type_name -> api.v1.services.types.Department + 30, // 59: api.v1.services.types.Position.create_time:type_name -> google.protobuf.Timestamp + 30, // 60: api.v1.services.types.Position.update_time:type_name -> google.protobuf.Timestamp + 12, // 61: api.v1.services.types.PositionEdges.department:type_name -> api.v1.services.types.Department + 4, // 62: api.v1.services.types.PositionEdges.users:type_name -> api.v1.services.types.User + 18, // 63: api.v1.services.types.PositionEdges.permissions:type_name -> api.v1.services.types.Permission + 20, // 64: api.v1.services.types.PositionEdges.user_positions:type_name -> api.v1.services.types.UserPosition + 22, // 65: api.v1.services.types.PositionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission + 30, // 66: api.v1.services.types.Permission.create_time:type_name -> google.protobuf.Timestamp + 30, // 67: api.v1.services.types.Permission.update_time:type_name -> google.protobuf.Timestamp + 29, // 68: api.v1.services.types.Permission.data_rules:type_name -> api.v1.services.types.Permission.DataRulesEntry + 10, // 69: api.v1.services.types.Permission.resources:type_name -> api.v1.services.types.Resource + 2, // 70: api.v1.services.types.PermissionEdges.roles:type_name -> api.v1.services.types.Role + 10, // 71: api.v1.services.types.PermissionEdges.resources:type_name -> api.v1.services.types.Resource + 16, // 72: api.v1.services.types.PermissionEdges.positions:type_name -> api.v1.services.types.Position + 24, // 73: api.v1.services.types.PermissionEdges.role_permissions:type_name -> api.v1.services.types.RolePermission + 26, // 74: api.v1.services.types.PermissionEdges.permission_resources:type_name -> api.v1.services.types.PermissionResource + 22, // 75: api.v1.services.types.PermissionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission + 4, // 76: api.v1.services.types.UserPositionEdges.user:type_name -> api.v1.services.types.User + 16, // 77: api.v1.services.types.UserPositionEdges.position:type_name -> api.v1.services.types.Position + 16, // 78: api.v1.services.types.PositionPermissionEdges.position:type_name -> api.v1.services.types.Position + 18, // 79: api.v1.services.types.PositionPermissionEdges.permission:type_name -> api.v1.services.types.Permission + 2, // 80: api.v1.services.types.RolePermissionEdges.role:type_name -> api.v1.services.types.Role + 18, // 81: api.v1.services.types.RolePermissionEdges.permission:type_name -> api.v1.services.types.Permission + 18, // 82: api.v1.services.types.PermissionResourceEdges.permission:type_name -> api.v1.services.types.Permission + 10, // 83: api.v1.services.types.PermissionResourceEdges.resource:type_name -> api.v1.services.types.Resource + 84, // [84:84] is the sub-list for method output_type + 84, // [84:84] is the sub-list for method input_type + 84, // [84:84] is the sub-list for extension type_name + 84, // [84:84] is the sub-list for extension extendee + 0, // [0:84] is the sub-list for field type_name +} + +func init() { file_types_system_proto_init() } +func file_types_system_proto_init() { + if File_types_system_proto != nil { + return + } + file_types_system_proto_msgTypes[4].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_system_proto_rawDesc), len(file_types_system_proto_rawDesc)), + NumEnums: 0, + NumMessages: 30, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_system_proto_goTypes, + DependencyIndexes: file_types_system_proto_depIdxs, + MessageInfos: file_types_system_proto_msgTypes, + }.Build() + File_types_system_proto = out.File + file_types_system_proto_goTypes = nil + file_types_system_proto_depIdxs = nil +} diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go new file mode 100644 index 00000000..f9a8dc81 --- /dev/null +++ b/api/v1/services/types/system.pb.validate.go @@ -0,0 +1,5600 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/system.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on Menu 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 *Menu) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Menu 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 MenuMultiError, or nil if none found. +func (m *Menu) ValidateAll() error { + return m.validate(true) +} + +func (m *Menu) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Keyword + + // no validation rules for Name + + // no validation rules for I18NKey + + // no validation rules for Description + + // no validation rules for Sequence + + // no validation rules for Type + + // no validation rules for Icon + + // no validation rules for Path + + // no validation rules for Properties + + // no validation rules for Status + + // no validation rules for ParentId + + // no validation rules for ParentPath + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetParent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return MenuMultiError(errors) + } + + return nil +} + +// MenuMultiError is an error wrapping multiple validation errors returned by +// Menu.ValidateAll() if the designated constraints aren't met. +type MenuMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m MenuMultiError) 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 MenuMultiError) AllErrors() []error { return m } + +// MenuValidationError is the validation error returned by Menu.Validate if the +// designated constraints aren't met. +type MenuValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e MenuValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e MenuValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e MenuValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e MenuValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e MenuValidationError) ErrorName() string { return "MenuValidationError" } + +// Error satisfies the builtin error interface +func (e MenuValidationError) 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 %sMenu.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = MenuValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = MenuValidationError{} + +// Validate checks the field values on MenuEdges 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 *MenuEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on MenuEdges 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 MenuEdgesMultiError, or nil +// if none found. +func (m *MenuEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *MenuEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetParent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetRoleMenus() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return MenuEdgesMultiError(errors) + } + + return nil +} + +// MenuEdgesMultiError is an error wrapping multiple validation errors returned +// by MenuEdges.ValidateAll() if the designated constraints aren't met. +type MenuEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m MenuEdgesMultiError) 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 MenuEdgesMultiError) AllErrors() []error { return m } + +// MenuEdgesValidationError is the validation error returned by +// MenuEdges.Validate if the designated constraints aren't met. +type MenuEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e MenuEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e MenuEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e MenuEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e MenuEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e MenuEdgesValidationError) ErrorName() string { return "MenuEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e MenuEdgesValidationError) 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 %sMenuEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = MenuEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = MenuEdgesValidationError{} + +// Validate checks the field values on Role 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 *Role) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Role 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 RoleMultiError, or nil if none found. +func (m *Role) ValidateAll() error { + return m.validate(true) +} + +func (m *Role) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Keyword + + // no validation rules for Name + + // no validation rules for Description + + // no validation rules for Type + + // no validation rules for Sequence + + // no validation rules for Status + + // no validation rules for IsTypes + + for idx, item := range m.GetMenus() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUsers() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return RoleMultiError(errors) + } + + return nil +} + +// RoleMultiError is an error wrapping multiple validation errors returned by +// Role.ValidateAll() if the designated constraints aren't met. +type RoleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RoleMultiError) 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 RoleMultiError) AllErrors() []error { return m } + +// RoleValidationError is the validation error returned by Role.Validate if the +// designated constraints aren't met. +type RoleValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RoleValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RoleValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RoleValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RoleValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RoleValidationError) ErrorName() string { return "RoleValidationError" } + +// Error satisfies the builtin error interface +func (e RoleValidationError) 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 %sRole.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RoleValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RoleValidationError{} + +// Validate checks the field values on RoleEdges 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 *RoleEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RoleEdges 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 RoleEdgesMultiError, or nil +// if none found. +func (m *RoleEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *RoleEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetMenus() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleEdgesValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUsers() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetRoleMenus() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUserRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return RoleEdgesMultiError(errors) + } + + return nil +} + +// RoleEdgesMultiError is an error wrapping multiple validation errors returned +// by RoleEdges.ValidateAll() if the designated constraints aren't met. +type RoleEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RoleEdgesMultiError) 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 RoleEdgesMultiError) AllErrors() []error { return m } + +// RoleEdgesValidationError is the validation error returned by +// RoleEdges.Validate if the designated constraints aren't met. +type RoleEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RoleEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RoleEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RoleEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RoleEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RoleEdgesValidationError) ErrorName() string { return "RoleEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e RoleEdgesValidationError) 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 %sRoleEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RoleEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RoleEdgesValidationError{} + +// Validate checks the field values on User 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 *User) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on User 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 UserMultiError, or nil if none found. +func (m *User) ValidateAll() error { + return m.validate(true) +} + +func (m *User) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for CreateAuthor + + // no validation rules for UpdateAuthor + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Uuid + + // no validation rules for AllowedIp + + // no validation rules for Username + + // no validation rules for Nickname + + // no validation rules for Avatar + + // no validation rules for Name + + // no validation rules for Gender + + // no validation rules for Password + + // no validation rules for ConfirmPassword + + // no validation rules for Salt + + // no validation rules for Phone + + // no validation rules for Email + + // no validation rules for Remark + + // no validation rules for Token + + // no validation rules for Status + + // no validation rules for LastLoginIp + + if all { + switch v := interface{}(m.GetLastLoginTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "LastLoginTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "LastLoginTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetLastLoginTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: "LastLoginTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for ManagerId + + // no validation rules for Manager + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if m.SanctionDate != nil { + + if all { + switch v := interface{}(m.GetSanctionDate()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "SanctionDate", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "SanctionDate", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSanctionDate()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: "SanctionDate", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return UserMultiError(errors) + } + + return nil +} + +// UserMultiError is an error wrapping multiple validation errors returned by +// User.ValidateAll() if the designated constraints aren't met. +type UserMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserMultiError) 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 UserMultiError) AllErrors() []error { return m } + +// UserValidationError is the validation error returned by User.Validate if the +// designated constraints aren't met. +type UserValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserValidationError) ErrorName() string { return "UserValidationError" } + +// Error satisfies the builtin error interface +func (e UserValidationError) 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 %sUser.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserValidationError{} + +// Validate checks the field values on UserEdges 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 *UserEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserEdges 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 UserEdgesMultiError, or nil +// if none found. +func (m *UserEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *UserEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUserRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return UserEdgesMultiError(errors) + } + + return nil +} + +// UserEdgesMultiError is an error wrapping multiple validation errors returned +// by UserEdges.ValidateAll() if the designated constraints aren't met. +type UserEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserEdgesMultiError) 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 UserEdgesMultiError) AllErrors() []error { return m } + +// UserEdgesValidationError is the validation error returned by +// UserEdges.Validate if the designated constraints aren't met. +type UserEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserEdgesValidationError) ErrorName() string { return "UserEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e UserEdgesValidationError) 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 %sUserEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserEdgesValidationError{} + +// Validate checks the field values on UserRole 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 *UserRole) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserRole 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 UserRoleMultiError, or nil +// if none found. +func (m *UserRole) ValidateAll() error { + return m.validate(true) +} + +func (m *UserRole) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for UserId + + // no validation rules for RoleId + + // no validation rules for RoleName + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UserRoleMultiError(errors) + } + + return nil +} + +// UserRoleMultiError is an error wrapping multiple validation errors returned +// by UserRole.ValidateAll() if the designated constraints aren't met. +type UserRoleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserRoleMultiError) 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 UserRoleMultiError) AllErrors() []error { return m } + +// UserRoleValidationError is the validation error returned by +// UserRole.Validate if the designated constraints aren't met. +type UserRoleValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserRoleValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserRoleValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserRoleValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserRoleValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserRoleValidationError) ErrorName() string { return "UserRoleValidationError" } + +// Error satisfies the builtin error interface +func (e UserRoleValidationError) 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 %sUserRole.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserRoleValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserRoleValidationError{} + +// Validate checks the field values on UserRoleEdges 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 *UserRoleEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserRoleEdges 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 UserRoleEdgesMultiError, or +// nil if none found. +func (m *UserRoleEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *UserRoleEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UserRoleEdgesMultiError(errors) + } + + return nil +} + +// UserRoleEdgesMultiError is an error wrapping multiple validation errors +// returned by UserRoleEdges.ValidateAll() if the designated constraints +// aren't met. +type UserRoleEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserRoleEdgesMultiError) 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 UserRoleEdgesMultiError) AllErrors() []error { return m } + +// UserRoleEdgesValidationError is the validation error returned by +// UserRoleEdges.Validate if the designated constraints aren't met. +type UserRoleEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserRoleEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserRoleEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserRoleEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserRoleEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserRoleEdgesValidationError) ErrorName() string { return "UserRoleEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e UserRoleEdgesValidationError) 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 %sUserRoleEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserRoleEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserRoleEdgesValidationError{} + +// Validate checks the field values on RoleMenu 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 *RoleMenu) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RoleMenu 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 RoleMenuMultiError, or nil +// if none found. +func (m *RoleMenu) ValidateAll() error { + return m.validate(true) +} + +func (m *RoleMenu) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for RoleId + + // no validation rules for MenuId + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RoleMenuMultiError(errors) + } + + return nil +} + +// RoleMenuMultiError is an error wrapping multiple validation errors returned +// by RoleMenu.ValidateAll() if the designated constraints aren't met. +type RoleMenuMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RoleMenuMultiError) 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 RoleMenuMultiError) AllErrors() []error { return m } + +// RoleMenuValidationError is the validation error returned by +// RoleMenu.Validate if the designated constraints aren't met. +type RoleMenuValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RoleMenuValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RoleMenuValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RoleMenuValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RoleMenuValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RoleMenuValidationError) ErrorName() string { return "RoleMenuValidationError" } + +// Error satisfies the builtin error interface +func (e RoleMenuValidationError) 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 %sRoleMenu.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RoleMenuValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RoleMenuValidationError{} + +// Validate checks the field values on RoleMenuEdges 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 *RoleMenuEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RoleMenuEdges 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 RoleMenuEdgesMultiError, or +// nil if none found. +func (m *RoleMenuEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *RoleMenuEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RoleMenuEdgesMultiError(errors) + } + + return nil +} + +// RoleMenuEdgesMultiError is an error wrapping multiple validation errors +// returned by RoleMenuEdges.ValidateAll() if the designated constraints +// aren't met. +type RoleMenuEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RoleMenuEdgesMultiError) 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 RoleMenuEdgesMultiError) AllErrors() []error { return m } + +// RoleMenuEdgesValidationError is the validation error returned by +// RoleMenuEdges.Validate if the designated constraints aren't met. +type RoleMenuEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RoleMenuEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RoleMenuEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RoleMenuEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RoleMenuEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RoleMenuEdgesValidationError) ErrorName() string { return "RoleMenuEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e RoleMenuEdgesValidationError) 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 %sRoleMenuEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RoleMenuEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RoleMenuEdgesValidationError{} + +// Validate checks the field values on Resource 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 *Resource) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Resource 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 ResourceMultiError, or nil +// if none found. +func (m *Resource) ValidateAll() error { + return m.validate(true) +} + +func (m *Resource) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Name + + // no validation rules for Keyword + + // no validation rules for I18NKey + + // no validation rules for Type + + // no validation rules for Status + + // no validation rules for Path + + // no validation rules for Operation + + // no validation rules for Method + + // no validation rules for Component + + // no validation rules for Icon + + // no validation rules for Sequence + + // no validation rules for Visible + + // no validation rules for TreePath + + // no validation rules for Properties + + // no validation rules for Description + + // no validation rules for ParentId + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetParent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ResourceMultiError(errors) + } + + return nil +} + +// ResourceMultiError is an error wrapping multiple validation errors returned +// by Resource.ValidateAll() if the designated constraints aren't met. +type ResourceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResourceMultiError) 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 ResourceMultiError) AllErrors() []error { return m } + +// ResourceValidationError is the validation error returned by +// Resource.Validate if the designated constraints aren't met. +type ResourceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResourceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResourceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResourceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResourceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResourceValidationError) ErrorName() string { return "ResourceValidationError" } + +// Error satisfies the builtin error interface +func (e ResourceValidationError) 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 %sResource.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResourceValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResourceValidationError{} + +// Validate checks the field values on ResourceEdges 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 *ResourceEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ResourceEdges 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 ResourceEdgesMultiError, or +// nil if none found. +func (m *ResourceEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *ResourceEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ResourceEdgesMultiError(errors) + } + + return nil +} + +// ResourceEdgesMultiError is an error wrapping multiple validation errors +// returned by ResourceEdges.ValidateAll() if the designated constraints +// aren't met. +type ResourceEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResourceEdgesMultiError) 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 ResourceEdgesMultiError) AllErrors() []error { return m } + +// ResourceEdgesValidationError is the validation error returned by +// ResourceEdges.Validate if the designated constraints aren't met. +type ResourceEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResourceEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResourceEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResourceEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResourceEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResourceEdgesValidationError) ErrorName() string { return "ResourceEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e ResourceEdgesValidationError) 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 %sResourceEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResourceEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResourceEdgesValidationError{} + +// Validate checks the field values on Department 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 *Department) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Department 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 DepartmentMultiError, or +// nil if none found. +func (m *Department) ValidateAll() error { + return m.validate(true) +} + +func (m *Department) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Keyword + + // no validation rules for Name + + // no validation rules for TreePath + + // no validation rules for Sequence + + // no validation rules for Status + + // no validation rules for Level + + // no validation rules for Description + + // no validation rules for ParentId + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetParent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DepartmentMultiError(errors) + } + + return nil +} + +// DepartmentMultiError is an error wrapping multiple validation errors +// returned by Department.ValidateAll() if the designated constraints aren't met. +type DepartmentMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DepartmentMultiError) 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 DepartmentMultiError) AllErrors() []error { return m } + +// DepartmentValidationError is the validation error returned by +// Department.Validate if the designated constraints aren't met. +type DepartmentValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DepartmentValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DepartmentValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DepartmentValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DepartmentValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DepartmentValidationError) ErrorName() string { return "DepartmentValidationError" } + +// Error satisfies the builtin error interface +func (e DepartmentValidationError) 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 %sDepartment.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DepartmentValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DepartmentValidationError{} + +// Validate checks the field values on DepartmentEdges 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 *DepartmentEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DepartmentEdges 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 +// DepartmentEdgesMultiError, or nil if none found. +func (m *DepartmentEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *DepartmentEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetUsers() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPositions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetParent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetUserDepartments() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("UserDepartments[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("UserDepartments[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentEdgesValidationError{ + field: fmt.Sprintf("UserDepartments[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return DepartmentEdgesMultiError(errors) + } + + return nil +} + +// DepartmentEdgesMultiError is an error wrapping multiple validation errors +// returned by DepartmentEdges.ValidateAll() if the designated constraints +// aren't met. +type DepartmentEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DepartmentEdgesMultiError) 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 DepartmentEdgesMultiError) AllErrors() []error { return m } + +// DepartmentEdgesValidationError is the validation error returned by +// DepartmentEdges.Validate if the designated constraints aren't met. +type DepartmentEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DepartmentEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DepartmentEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DepartmentEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DepartmentEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DepartmentEdgesValidationError) ErrorName() string { return "DepartmentEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e DepartmentEdgesValidationError) 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 %sDepartmentEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DepartmentEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DepartmentEdgesValidationError{} + +// Validate checks the field values on UserDepartment 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 *UserDepartment) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserDepartment 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 UserDepartmentMultiError, +// or nil if none found. +func (m *UserDepartment) ValidateAll() error { + return m.validate(true) +} + +func (m *UserDepartment) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for UserId + + // no validation rules for DepartmentId + + if all { + switch v := interface{}(m.GetEdges()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserDepartmentValidationError{ + field: "Edges", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserDepartmentValidationError{ + field: "Edges", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEdges()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserDepartmentValidationError{ + field: "Edges", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UserDepartmentMultiError(errors) + } + + return nil +} + +// UserDepartmentMultiError is an error wrapping multiple validation errors +// returned by UserDepartment.ValidateAll() if the designated constraints +// aren't met. +type UserDepartmentMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserDepartmentMultiError) 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 UserDepartmentMultiError) AllErrors() []error { return m } + +// UserDepartmentValidationError is the validation error returned by +// UserDepartment.Validate if the designated constraints aren't met. +type UserDepartmentValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserDepartmentValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserDepartmentValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserDepartmentValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserDepartmentValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserDepartmentValidationError) ErrorName() string { return "UserDepartmentValidationError" } + +// Error satisfies the builtin error interface +func (e UserDepartmentValidationError) 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 %sUserDepartment.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserDepartmentValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserDepartmentValidationError{} + +// Validate checks the field values on UserDepartmentEdges 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 *UserDepartmentEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserDepartmentEdges 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 +// UserDepartmentEdgesMultiError, or nil if none found. +func (m *UserDepartmentEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *UserDepartmentEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserDepartmentEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserDepartmentEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserDepartmentEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetDepartment()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserDepartmentEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserDepartmentEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserDepartmentEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UserDepartmentEdgesMultiError(errors) + } + + return nil +} + +// UserDepartmentEdgesMultiError is an error wrapping multiple validation +// errors returned by UserDepartmentEdges.ValidateAll() if the designated +// constraints aren't met. +type UserDepartmentEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserDepartmentEdgesMultiError) 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 UserDepartmentEdgesMultiError) AllErrors() []error { return m } + +// UserDepartmentEdgesValidationError is the validation error returned by +// UserDepartmentEdges.Validate if the designated constraints aren't met. +type UserDepartmentEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserDepartmentEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserDepartmentEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserDepartmentEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserDepartmentEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserDepartmentEdgesValidationError) ErrorName() string { + return "UserDepartmentEdgesValidationError" +} + +// Error satisfies the builtin error interface +func (e UserDepartmentEdgesValidationError) 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 %sUserDepartmentEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserDepartmentEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserDepartmentEdgesValidationError{} + +// Validate checks the field values on Position 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 *Position) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Position 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 PositionMultiError, or nil +// if none found. +func (m *Position) ValidateAll() error { + return m.validate(true) +} + +func (m *Position) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Name + + // no validation rules for Keyword + + // no validation rules for Description + + // no validation rules for DepartmentId + + if len(errors) > 0 { + return PositionMultiError(errors) + } + + return nil +} + +// PositionMultiError is an error wrapping multiple validation errors returned +// by Position.ValidateAll() if the designated constraints aren't met. +type PositionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PositionMultiError) 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 PositionMultiError) AllErrors() []error { return m } + +// PositionValidationError is the validation error returned by +// Position.Validate if the designated constraints aren't met. +type PositionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PositionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PositionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PositionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PositionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PositionValidationError) ErrorName() string { return "PositionValidationError" } + +// Error satisfies the builtin error interface +func (e PositionValidationError) 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 %sPosition.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PositionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PositionValidationError{} + +// Validate checks the field values on PositionEdges 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 *PositionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PositionEdges 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 PositionEdgesMultiError, or +// nil if none found. +func (m *PositionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *PositionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetDepartment()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetUsers() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUserPositions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("UserPositions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("UserPositions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("UserPositions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPositionPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return PositionEdgesMultiError(errors) + } + + return nil +} + +// PositionEdgesMultiError is an error wrapping multiple validation errors +// returned by PositionEdges.ValidateAll() if the designated constraints +// aren't met. +type PositionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PositionEdgesMultiError) 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 PositionEdgesMultiError) AllErrors() []error { return m } + +// PositionEdgesValidationError is the validation error returned by +// PositionEdges.Validate if the designated constraints aren't met. +type PositionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PositionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PositionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PositionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PositionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PositionEdgesValidationError) ErrorName() string { return "PositionEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e PositionEdgesValidationError) 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 %sPositionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PositionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PositionEdgesValidationError{} + +// Validate checks the field values on Permission 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 *Permission) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Permission 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 PermissionMultiError, or +// nil if none found. +func (m *Permission) ValidateAll() error { + return m.validate(true) +} + +func (m *Permission) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Name + + // no validation rules for Keyword + + // no validation rules for Description + + // no validation rules for DataScope + + // no validation rules for DataRules + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return PermissionMultiError(errors) + } + + return nil +} + +// PermissionMultiError is an error wrapping multiple validation errors +// returned by Permission.ValidateAll() if the designated constraints aren't met. +type PermissionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PermissionMultiError) 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 PermissionMultiError) AllErrors() []error { return m } + +// PermissionValidationError is the validation error returned by +// Permission.Validate if the designated constraints aren't met. +type PermissionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PermissionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PermissionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PermissionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PermissionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PermissionValidationError) ErrorName() string { return "PermissionValidationError" } + +// Error satisfies the builtin error interface +func (e PermissionValidationError) 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 %sPermission.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PermissionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PermissionValidationError{} + +// Validate checks the field values on PermissionEdges 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 *PermissionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PermissionEdges 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 +// PermissionEdgesMultiError, or nil if none found. +func (m *PermissionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *PermissionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPositions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetRolePermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("RolePermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("RolePermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("RolePermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPermissionResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("PermissionResources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("PermissionResources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("PermissionResources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPositionPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return PermissionEdgesMultiError(errors) + } + + return nil +} + +// PermissionEdgesMultiError is an error wrapping multiple validation errors +// returned by PermissionEdges.ValidateAll() if the designated constraints +// aren't met. +type PermissionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PermissionEdgesMultiError) 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 PermissionEdgesMultiError) AllErrors() []error { return m } + +// PermissionEdgesValidationError is the validation error returned by +// PermissionEdges.Validate if the designated constraints aren't met. +type PermissionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PermissionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PermissionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PermissionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PermissionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PermissionEdgesValidationError) ErrorName() string { return "PermissionEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e PermissionEdgesValidationError) 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 %sPermissionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PermissionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PermissionEdgesValidationError{} + +// Validate checks the field values on UserPosition 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 *UserPosition) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserPosition 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 UserPositionMultiError, or +// nil if none found. +func (m *UserPosition) ValidateAll() error { + return m.validate(true) +} + +func (m *UserPosition) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for UserId + + // no validation rules for PositionId + + if len(errors) > 0 { + return UserPositionMultiError(errors) + } + + return nil +} + +// UserPositionMultiError is an error wrapping multiple validation errors +// returned by UserPosition.ValidateAll() if the designated constraints aren't met. +type UserPositionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserPositionMultiError) 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 UserPositionMultiError) AllErrors() []error { return m } + +// UserPositionValidationError is the validation error returned by +// UserPosition.Validate if the designated constraints aren't met. +type UserPositionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserPositionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserPositionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserPositionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserPositionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserPositionValidationError) ErrorName() string { return "UserPositionValidationError" } + +// Error satisfies the builtin error interface +func (e UserPositionValidationError) 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 %sUserPosition.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserPositionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserPositionValidationError{} + +// Validate checks the field values on UserPositionEdges 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 *UserPositionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserPositionEdges 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 +// UserPositionEdgesMultiError, or nil if none found. +func (m *UserPositionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *UserPositionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserPositionEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserPositionEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserPositionEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetPosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserPositionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserPositionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserPositionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UserPositionEdgesMultiError(errors) + } + + return nil +} + +// UserPositionEdgesMultiError is an error wrapping multiple validation errors +// returned by UserPositionEdges.ValidateAll() if the designated constraints +// aren't met. +type UserPositionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserPositionEdgesMultiError) 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 UserPositionEdgesMultiError) AllErrors() []error { return m } + +// UserPositionEdgesValidationError is the validation error returned by +// UserPositionEdges.Validate if the designated constraints aren't met. +type UserPositionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserPositionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserPositionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserPositionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserPositionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserPositionEdgesValidationError) ErrorName() string { + return "UserPositionEdgesValidationError" +} + +// Error satisfies the builtin error interface +func (e UserPositionEdgesValidationError) 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 %sUserPositionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserPositionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserPositionEdgesValidationError{} + +// Validate checks the field values on PositionPermission 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 *PositionPermission) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PositionPermission 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 +// PositionPermissionMultiError, or nil if none found. +func (m *PositionPermission) ValidateAll() error { + return m.validate(true) +} + +func (m *PositionPermission) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for PositionId + + // no validation rules for PermissionId + + if len(errors) > 0 { + return PositionPermissionMultiError(errors) + } + + return nil +} + +// PositionPermissionMultiError is an error wrapping multiple validation errors +// returned by PositionPermission.ValidateAll() if the designated constraints +// aren't met. +type PositionPermissionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PositionPermissionMultiError) 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 PositionPermissionMultiError) AllErrors() []error { return m } + +// PositionPermissionValidationError is the validation error returned by +// PositionPermission.Validate if the designated constraints aren't met. +type PositionPermissionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PositionPermissionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PositionPermissionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PositionPermissionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PositionPermissionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PositionPermissionValidationError) ErrorName() string { + return "PositionPermissionValidationError" +} + +// Error satisfies the builtin error interface +func (e PositionPermissionValidationError) 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 %sPositionPermission.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PositionPermissionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PositionPermissionValidationError{} + +// Validate checks the field values on PositionPermissionEdges 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 *PositionPermissionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PositionPermissionEdges 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 +// PositionPermissionEdgesMultiError, or nil if none found. +func (m *PositionPermissionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *PositionPermissionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetPosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionPermissionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionPermissionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionPermissionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionPermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionPermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionPermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return PositionPermissionEdgesMultiError(errors) + } + + return nil +} + +// PositionPermissionEdgesMultiError is an error wrapping multiple validation +// errors returned by PositionPermissionEdges.ValidateAll() if the designated +// constraints aren't met. +type PositionPermissionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PositionPermissionEdgesMultiError) 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 PositionPermissionEdgesMultiError) AllErrors() []error { return m } + +// PositionPermissionEdgesValidationError is the validation error returned by +// PositionPermissionEdges.Validate if the designated constraints aren't met. +type PositionPermissionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PositionPermissionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PositionPermissionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PositionPermissionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PositionPermissionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PositionPermissionEdgesValidationError) ErrorName() string { + return "PositionPermissionEdgesValidationError" +} + +// Error satisfies the builtin error interface +func (e PositionPermissionEdgesValidationError) 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 %sPositionPermissionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PositionPermissionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PositionPermissionEdgesValidationError{} + +// Validate checks the field values on RolePermission 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 *RolePermission) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RolePermission 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 RolePermissionMultiError, +// or nil if none found. +func (m *RolePermission) ValidateAll() error { + return m.validate(true) +} + +func (m *RolePermission) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for RoleId + + // no validation rules for PermissionId + + if len(errors) > 0 { + return RolePermissionMultiError(errors) + } + + return nil +} + +// RolePermissionMultiError is an error wrapping multiple validation errors +// returned by RolePermission.ValidateAll() if the designated constraints +// aren't met. +type RolePermissionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RolePermissionMultiError) 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 RolePermissionMultiError) AllErrors() []error { return m } + +// RolePermissionValidationError is the validation error returned by +// RolePermission.Validate if the designated constraints aren't met. +type RolePermissionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RolePermissionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RolePermissionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RolePermissionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RolePermissionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RolePermissionValidationError) ErrorName() string { return "RolePermissionValidationError" } + +// Error satisfies the builtin error interface +func (e RolePermissionValidationError) 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 %sRolePermission.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RolePermissionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RolePermissionValidationError{} + +// Validate checks the field values on RolePermissionEdges 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 *RolePermissionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RolePermissionEdges 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 +// RolePermissionEdgesMultiError, or nil if none found. +func (m *RolePermissionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *RolePermissionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RolePermissionEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RolePermissionEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RolePermissionEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RolePermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RolePermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RolePermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RolePermissionEdgesMultiError(errors) + } + + return nil +} + +// RolePermissionEdgesMultiError is an error wrapping multiple validation +// errors returned by RolePermissionEdges.ValidateAll() if the designated +// constraints aren't met. +type RolePermissionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RolePermissionEdgesMultiError) 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 RolePermissionEdgesMultiError) AllErrors() []error { return m } + +// RolePermissionEdgesValidationError is the validation error returned by +// RolePermissionEdges.Validate if the designated constraints aren't met. +type RolePermissionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RolePermissionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RolePermissionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RolePermissionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RolePermissionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RolePermissionEdgesValidationError) ErrorName() string { + return "RolePermissionEdgesValidationError" +} + +// Error satisfies the builtin error interface +func (e RolePermissionEdgesValidationError) 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 %sRolePermissionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RolePermissionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RolePermissionEdgesValidationError{} + +// Validate checks the field values on PermissionResource 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 *PermissionResource) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PermissionResource 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 +// PermissionResourceMultiError, or nil if none found. +func (m *PermissionResource) ValidateAll() error { + return m.validate(true) +} + +func (m *PermissionResource) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for PermissionId + + // no validation rules for ResourceId + + // no validation rules for Actions + + if len(errors) > 0 { + return PermissionResourceMultiError(errors) + } + + return nil +} + +// PermissionResourceMultiError is an error wrapping multiple validation errors +// returned by PermissionResource.ValidateAll() if the designated constraints +// aren't met. +type PermissionResourceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PermissionResourceMultiError) 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 PermissionResourceMultiError) AllErrors() []error { return m } + +// PermissionResourceValidationError is the validation error returned by +// PermissionResource.Validate if the designated constraints aren't met. +type PermissionResourceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PermissionResourceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PermissionResourceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PermissionResourceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PermissionResourceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PermissionResourceValidationError) ErrorName() string { + return "PermissionResourceValidationError" +} + +// Error satisfies the builtin error interface +func (e PermissionResourceValidationError) 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 %sPermissionResource.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PermissionResourceValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PermissionResourceValidationError{} + +// Validate checks the field values on PermissionResourceEdges 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 *PermissionResourceEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PermissionResourceEdges 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 +// PermissionResourceEdgesMultiError, or nil if none found. +func (m *PermissionResourceEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *PermissionResourceEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionResourceEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionResourceEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionResourceEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetResource()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionResourceEdgesValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionResourceEdgesValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionResourceEdgesValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return PermissionResourceEdgesMultiError(errors) + } + + return nil +} + +// PermissionResourceEdgesMultiError is an error wrapping multiple validation +// errors returned by PermissionResourceEdges.ValidateAll() if the designated +// constraints aren't met. +type PermissionResourceEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PermissionResourceEdgesMultiError) 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 PermissionResourceEdgesMultiError) AllErrors() []error { return m } + +// PermissionResourceEdgesValidationError is the validation error returned by +// PermissionResourceEdges.Validate if the designated constraints aren't met. +type PermissionResourceEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PermissionResourceEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PermissionResourceEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PermissionResourceEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PermissionResourceEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PermissionResourceEdgesValidationError) ErrorName() string { + return "PermissionResourceEdgesValidationError" +} + +// Error satisfies the builtin error interface +func (e PermissionResourceEdgesValidationError) 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 %sPermissionResourceEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PermissionResourceEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PermissionResourceEdgesValidationError{} diff --git a/buf.yaml b/buf.yaml index 638504d2..9fc6b181 100644 --- a/buf.yaml +++ b/buf.yaml @@ -3,8 +3,7 @@ version: v2 modules: - path: api/v1/proto -# includes: -# - api/v1/proto + lint: use: - STANDARD diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index 279017fe..92312c14 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -43,8 +43,8 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap permissionRepo := dal.NewPermissionRepo(r, dataData) permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) permissionServiceServer := service.NewPermissionServiceServerPB(r, permissionServiceBiz) - serverRegister := server.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) - v := server.NewSystemServer(r, bootstrap, serverRegister) + serverRegistrar := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + v := server.NewSystemServer(r, bootstrap, serverRegistrar) app := NewApp(r, v) return app, func() { cleanup() diff --git a/internal/mods/system/server/server.go b/internal/mods/system/server/server.go index 226d0e46..963f7da4 100644 --- a/internal/mods/system/server/server.go +++ b/internal/mods/system/server/server.go @@ -9,7 +9,6 @@ import ( "github.com/go-kratos/kratos/v2/transport" "github.com/google/wire" "github.com/origadmin/runtime" - "github.com/origadmin/runtime/agent" configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/log" @@ -19,9 +18,7 @@ import ( servicehttp "github.com/origadmin/runtime/service/http" "github.com/origadmin/toolkits/errors" - pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/configs" - systemservice "origadmin/application/admin/internal/mods/system/service" ) const ( @@ -34,8 +31,6 @@ var ( ProviderSet = wire.NewSet( NewSystemClient, NewSystemServer, - NewSystemServiceAgentClient, - //NewCasbinServiceClient, ) ) @@ -89,88 +84,6 @@ Server { return servers } -type RegisterBridge struct { - Personal pb.PersonalServiceAgent - Resource pb.ResourceServiceAgent - Role pb.RoleServiceAgent - User pb.UserServiceAgent - Permission pb.PermissionServiceAgent -} - -func (s RegisterBridge) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { - //TODO implement me - panic("implement me") -} - -func (s RegisterBridge) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { - //TODO implement me - panic("implement me") -} - -func (s RegisterBridge) RegisterHTTPServer(ctx context.Context, server *service.HTTPServer) { - log.Info("http client system init") - ag := agent.NewHTTP(server) - pb.RegisterPersonalServiceAgent(ag, s.Personal) - pb.RegisterResourceServiceAgent(ag, s.Resource) - pb.RegisterRoleServiceAgent(ag, s.Role) - pb.RegisterUserServiceAgent(ag, s.User) - pb.RegisterPermissionServiceAgent(ag, s.Permission) -} - -func (s RegisterBridge) RegisterGRPCClient(ctx context.Context, client *service.GRPCClient) { - //TODO implement me - panic("implement me") -} - -func (s RegisterBridge) RegisterHTTPClient(ctx context.Context, client *service.HTTPClient) { - log.Info("http client system init") - //ag := agent.NewHTTP(client) - //pb.RegisterPersonalServiceAgent(ag, s.Personal) - //pb.RegisterResourceServiceAgent(ag, s.Resource) - //pb.RegisterRoleServiceAgent(ag, s.Role) - //pb.RegisterUserServiceAgent(ag, s.User) - //pb.RegisterPermissionServiceAgent(ag, s.Permission) -} - -func (s RegisterBridge) Register(ctx context.Context, svc any) { - switch v := svc.(type) { - case *service.GRPCServer: - s.RegisterGRPC(ctx, v) - case *service.HTTPServer: - s.RegisterHTTP(ctx, v) - } -} - -func (s RegisterBridge) GRPCServer(ctx context.Context, server *service.GRPCServer) { - log.Info("grpc server system init") -} - -func (s RegisterBridge) HTTPServer(ctx context.Context, server *service.HTTPServer) { - log.Info("http server system init") - ag := agent.NewHTTP(server) - pb.RegisterPersonalServiceAgent(ag, s.Personal) - pb.RegisterResourceServiceAgent(ag, s.Resource) - pb.RegisterRoleServiceAgent(ag, s.Role) - pb.RegisterUserServiceAgent(ag, s.User) - pb.RegisterPermissionServiceAgent(ag, s.Permission) -} - -func (s RegisterBridge) Server(ctx context.Context, grpcServer *service.GRPCServer, httpServer *service.HTTPServer) { - s.HTTPServer(ctx, httpServer) - s.GRPCServer(ctx, grpcServer) -} - -func NewSystemServiceAgentClient(r runtime.Runtime, client *service.GRPCClient) (*RegisterBridge, error) { - register := RegisterBridge{ - Personal: systemservice.NewPersonalServiceAgentClient(client), - Resource: systemservice.NewResourceServiceAgentClient(client), - Role: systemservice.NewRoleServiceAgentClient(client), - User: systemservice.NewUserServiceAgentClient(client), - Permission: systemservice.NewPermissionServiceAgentClient(client), - } - return ®ister, nil -} - func NewSystemClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service.GRPCClient, error) { discovery := bootstrap.GetDiscovery() if discovery == nil { @@ -229,5 +142,3 @@ func MiddlewareServer() middleware.KMiddleware { } } } - -var _ service.ServerRegistrar = (*RegisterBridge)(nil) diff --git a/internal/mods/system/service/menu.bridge.go b/internal/mods/system/service/menu.bridge.go index aa83bdc2..df210d2f 100644 --- a/internal/mods/system/service/menu.bridge.go +++ b/internal/mods/system/service/menu.bridge.go @@ -5,102 +5,90 @@ package service import ( + "encoding/json" "net/http" - "github.com/origadmin/runtime/agent" - "github.com/origadmin/runtime/context" + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/resp" ) -// MenuServiceBridge is a menu service. -type MenuServiceBridge struct { - pb.UnimplementedMenuServiceServer - - client pb.MenuServiceClient +// MenuServiceHookedBridge is a menu service. +type MenuServiceHookedBridge struct { + pb.UnimplementedMenuServiceHooked + log *log.KHelper } -func (s MenuServiceBridge) CreateMenu(ctx context.Context, request *pb.CreateMenuRequest) (*pb.CreateMenuResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.CreateMenu(ctx, request) +func (h MenuServiceHookedBridge) CreateMenuResult(ctx transhttp.Context, request *pb.CreateMenuRequest, response *pb.CreateMenuResponse) error { + marshal, err := json.Marshal(response.Menu) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Menu), + Data: marshal, }) - return nil, nil } -func (s MenuServiceBridge) DeleteMenu(ctx context.Context, request *pb.DeleteMenuRequest) (*pb.DeleteMenuResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - _, err := s.client.DeleteMenu(ctx, request) - if err != nil { - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ +func (h MenuServiceHookedBridge) DeleteMenuResult(ctx transhttp.Context, request *pb.DeleteMenuRequest, response *pb.DeleteMenuResponse) error { + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, Data: nil, }) - return nil, nil } -func (s MenuServiceBridge) GetMenu(ctx context.Context, request *pb.GetMenuRequest) (*pb.GetMenuResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.GetMenu(ctx, request) +func (h MenuServiceHookedBridge) GetMenuResult(ctx transhttp.Context, request *pb.GetMenuRequest, response *pb.GetMenuResponse) error { + marshal, err := json.Marshal(response.Menu) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Menu), + Data: marshal, }) - return nil, nil } -func (s MenuServiceBridge) ListMenus(ctx context.Context, request *pb.ListMenusRequest) (*pb.ListMenusResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.ListMenus(ctx, request) +func (h MenuServiceHookedBridge) ListMenusResult(ctx transhttp.Context, request *pb.ListMenusRequest, response *pb.ListMenusResponse) error { + marshal, err := json.Marshal(response.Menus) if err != nil { - return nil, err + return err } - - s.JSON(httpCtx, http.StatusOK, &resp.Page{ + return ctx.JSON(http.StatusOK, &resp.SourcePage{ Success: true, - Total: response.TotalSize, - Data: resp.Proto2AnyPBArray(response.Menus...), + Total: response.GetTotalSize(), + Data: marshal, }) - return nil, nil } -func (s MenuServiceBridge) UpdateMenu(ctx context.Context, request *pb.UpdateMenuRequest) (*pb.UpdateMenuResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.UpdateMenu(ctx, request) +func (h MenuServiceHookedBridge) UpdateMenuResult(ctx transhttp.Context, request *pb.UpdateMenuRequest, response *pb.UpdateMenuResponse) error { + marshal, err := json.Marshal(response.Menu) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Menu), + Data: marshal, }) - return nil, nil } -// NewMenuServiceBridge new a menu service. -func NewMenuServiceBridge(client pb.MenuServiceClient) *MenuServiceBridge { - return &MenuServiceBridge{client: client} +func NewMenuServiceHookedBridge(r runtime.Runtime, client pb.MenuServiceHTTPServer) pb.MenuServiceHookedBridger { + return pb.WithMenuServiceHook(&MenuServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/menu")), + })(client) } -// NewMenuServiceBridgePB new a menu service. -func NewMenuServiceBridgePB(client pb.MenuServiceClient) pb.MenuServiceServer { - return &MenuServiceBridge{client: client} +// NewMenuServiceBridge new a menu service. +func NewMenuServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.MenuServiceServer { + return pb.NewMenuServiceBridge(client) } -func NewMenuServiceBridgeClient(client *service.GRPCClient) pb.MenuServiceServer { - cli := pb.NewMenuServiceClient(client) - return NewMenuServiceBridge(cli) + +// NewMenuServiceHTTPBridge new a menu service. +func NewMenuServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.MenuServiceHTTPServer { + return pb.NewMenuServiceHTTPBridge(client) } -var _ pb.MenuServiceServer = (*MenuServiceBridge)(nil) +var _ pb.MenuServiceHooker = (*MenuServiceHookedBridge)(nil) diff --git a/internal/mods/system/service/permission.bridge.go b/internal/mods/system/service/permission.bridge.go index ac6e1350..0cb7ec43 100644 --- a/internal/mods/system/service/permission.bridge.go +++ b/internal/mods/system/service/permission.bridge.go @@ -5,102 +5,93 @@ package service import ( + "encoding/json" "net/http" - "github.com/origadmin/runtime/agent" - "github.com/origadmin/runtime/context" + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/resp" ) -// PermissionServiceBridge is a menu service. -type PermissionServiceBridge struct { - resp.Response - - client pb.PermissionServiceClient +// PermissionServiceHookedBridge is a menu service. +type PermissionServiceHookedBridge struct { + pb.UnimplementedPermissionServiceHooked + log *log.KHelper } -func (s PermissionServiceBridge) CreatePermission(ctx context.Context, request *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.CreatePermission(ctx, request) +func (h PermissionServiceHookedBridge) CreatePermissionResult(ctx transhttp.Context, request *pb.CreatePermissionRequest, response *pb.CreatePermissionResponse) error { + marshal, err := json.Marshal(response.Permission) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Permission), + Data: marshal, }) - return nil, nil } -func (s PermissionServiceBridge) DeletePermission(ctx context.Context, request *pb.DeletePermissionRequest) (*pb.DeletePermissionResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - _, err := s.client.DeletePermission(ctx, request) - if err != nil { - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ +func (h PermissionServiceHookedBridge) DeletePermissionResult(ctx transhttp.Context, request *pb.DeletePermissionRequest, response *pb.DeletePermissionResponse) error { + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, Data: nil, }) - return nil, nil } -func (s PermissionServiceBridge) GetPermission(ctx context.Context, request *pb.GetPermissionRequest) (*pb.GetPermissionResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.GetPermission(ctx, request) +func (h PermissionServiceHookedBridge) GetPermissionResult(ctx transhttp.Context, request *pb.GetPermissionRequest, response *pb.GetPermissionResponse) error { + marshal, err := json.Marshal(response.Permission) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Permission), + Data: marshal, }) - return nil, nil } -func (s PermissionServiceBridge) ListPermissions(ctx context.Context, request *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.ListPermissions(ctx, request) +func (h PermissionServiceHookedBridge) ListPermissionsResult(ctx transhttp.Context, request *pb.ListPermissionsRequest, response *pb.ListPermissionsResponse) error { + marshal, err := json.Marshal(response.Permissions) if err != nil { - return nil, err + return err } - - s.JSON(httpCtx, http.StatusOK, &resp.Page{ + return ctx.JSON(http.StatusOK, &resp.SourcePage{ Success: true, - Total: response.TotalSize, - Data: resp.Proto2AnyPBArray(response.Permissions...), + Total: response.GetTotalSize(), + Data: marshal, + //Current: request.GetCurrent(), + //PageSize: nil, + //Extra: "", }) - return nil, nil } -func (s PermissionServiceBridge) UpdatePermission(ctx context.Context, request *pb.UpdatePermissionRequest) (*pb.UpdatePermissionResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.UpdatePermission(ctx, request) +func (h PermissionServiceHookedBridge) UpdatePermissionResult(ctx transhttp.Context, request *pb.UpdatePermissionRequest, response *pb.UpdatePermissionResponse) error { + marshal, err := json.Marshal(response.Permission) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Permission), + Data: marshal, }) - return nil, nil } -// NewPermissionServiceBridge new a menu service. -func NewPermissionServiceBridge(client pb.PermissionServiceClient) *PermissionServiceBridge { - return &PermissionServiceBridge{client: client} +func NewPermissionServiceHookedBridge(r runtime.Runtime, client pb.PermissionServiceHTTPServer) pb.PermissionServiceHookedBridger { + return pb.WithPermissionServiceHook(&PermissionServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/permission")), + })(client) } -// NewPermissionServiceBridgePB new a menu service. -func NewPermissionServiceBridgePB(client pb.PermissionServiceClient) pb.PermissionServiceBridge { - return &PermissionServiceBridge{client: client} +// NewPermissionServiceBridge new a menu service. +func NewPermissionServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.PermissionServiceServer { + return pb.NewPermissionServiceBridge(client) } -func NewPermissionServiceBridgeClient(client *service.GRPCClient) pb.PermissionServiceBridge { - cli := pb.NewPermissionServiceClient(client) - return NewPermissionServiceBridge(cli) + +// NewPermissionServiceHTTPBridge new a menu service. +func NewPermissionServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.PermissionServiceHTTPServer { + return pb.NewPermissionServiceHTTPBridge(client) } -var _ pb.PermissionServiceBridge = (*PermissionServiceBridge)(nil) +var _ pb.PermissionServiceHooker = (*PermissionServiceHookedBridge)(nil) diff --git a/internal/mods/system/service/permission.http.go b/internal/mods/system/service/permission.http.go index 2fce23ee..b194006f 100644 --- a/internal/mods/system/service/permission.http.go +++ b/internal/mods/system/service/permission.http.go @@ -5,16 +5,18 @@ package service import ( + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/biz" ) // PermissionServiceHTTPServer is a menu service. type PermissionServiceHTTPServer struct { - pb.UnimplementedPermissionServiceServer - - client pb.PermissionServiceHTTPClient + client *biz.PermissionServiceBiz + log *log.KHelper } func (s PermissionServiceHTTPServer) CreatePermission(ctx context.Context, request *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { @@ -37,19 +39,17 @@ func (s PermissionServiceHTTPServer) UpdatePermission(ctx context.Context, reque return s.client.UpdatePermission(ctx, request) } -//func (m PermissionServiceHTTPServer) mustEmbedUnimplementedPermissionServiceHTTPServer() { -// //TODO implement me -// panic("implement me") -//} - // NewPermissionServiceHTTPServer new a menu service. -func NewPermissionServiceHTTPServer(client pb.PermissionServiceHTTPClient) *PermissionServiceHTTPServer { - return &PermissionServiceHTTPServer{client: client} +func NewPermissionServiceHTTPServer(r runtime.Runtime, client *biz.PermissionServiceBiz) *PermissionServiceHTTPServer { + return &PermissionServiceHTTPServer{ + log: log.NewHelper(r.WithLogger("module", "service/permission")), + client: client, + } } // NewPermissionServiceHTTPServerPB new a menu service. -func NewPermissionServiceHTTPServerPB(client pb.PermissionServiceHTTPClient) pb.PermissionServiceHTTPServer { - return &PermissionServiceHTTPServer{client: client} +func NewPermissionServiceHTTPServerPB(r runtime.Runtime, client *biz.PermissionServiceBiz) pb.PermissionServiceHTTPServer { + return NewPermissionServiceHTTPServer(r, client) } -var _ pb.PermissionServiceServer = (*PermissionServiceHTTPServer)(nil) +var _ pb.PermissionServiceHTTPServer = (*PermissionServiceHTTPServer)(nil) diff --git a/internal/mods/system/service/personal.bridge.go b/internal/mods/system/service/personal.bridge.go index 5131aca9..e74b61cc 100644 --- a/internal/mods/system/service/personal.bridge.go +++ b/internal/mods/system/service/personal.bridge.go @@ -5,180 +5,118 @@ package service import ( - "net/http" + "context" - "github.com/origadmin/runtime/agent" - "github.com/origadmin/runtime/context" + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/resp" ) -// PersonalServiceBridge is a Personal service. -type PersonalServiceBridge struct { - resp.Response +// PersonalServiceHookedBridge is a menu service. +type PersonalServiceHookedBridge struct { + pb.UnimplementedPersonalServiceHooked + client pb.PersonalServiceHTTPServer + log *log.KHelper +} - client pb.PersonalServiceClient +func (p PersonalServiceHookedBridge) BeforeGetPersonalProfile(context transhttp.Context, request *pb.GetPersonalProfileRequest) (context.Context, error) { + //TODO implement me + panic("implement me") } -func (s PersonalServiceBridge) RefreshPersonalToken(ctx context.Context, request *pb.RefreshPersonalTokenRequest) (*pb.RefreshPersonalTokenResponse, error) { +func (p PersonalServiceHookedBridge) GetPersonalProfileResult(context transhttp.Context, request *pb.GetPersonalProfileRequest, response *pb.GetPersonalProfileResponse) error { //TODO implement me panic("implement me") } -func (s PersonalServiceBridge) GetPersonalProfile(ctx context.Context, request *pb.GetPersonalProfileRequest) (*pb.GetPersonalProfileResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.GetPersonalProfile(ctx, request) - if err != nil { - log.Errorf("GetPersonalProfile error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) - return nil, nil -} - -func (s PersonalServiceBridge) PersonalLogout(ctx context.Context, request *pb.PersonalLogoutRequest) (*pb.PersonalLogoutResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.PersonalLogout(ctx, request) - if err != nil { - log.Errorf("PersonalResources error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) - return nil, nil -} - -func (s PersonalServiceBridge) ListPersonalResources(ctx context.Context, request *pb.ListPersonalResourcesRequest) (*pb.ListPersonalResourcesResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.ListPersonalResources(ctx, request) - if err != nil { - log.Errorf("PersonalResources error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Page{ - Success: true, - Total: int32(response.TotalSize), - Data: resp.Proto2AnyPBArray(response.Resources...), - }) - return nil, nil -} - -func (s PersonalServiceBridge) ListPersonalRoles(ctx context.Context, request *pb.ListPersonalRolesRequest) (*pb.ListPersonalRolesResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.ListPersonalRoles(ctx, request) - if err != nil { - log.Errorf("PersonalResources error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Page{ - Success: true, - //Total: int32(response.TotalSize), - Data: resp.Proto2AnyPBArray(response.Roles...), - }) - return nil, nil -} - -func (s PersonalServiceBridge) UpdatePersonalSetting(ctx context.Context, request *pb.UpdatePersonalSettingRequest) (*pb.UpdatePersonalSettingResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.UpdatePersonalSetting(ctx, request) - if err != nil { - log.Errorf("PersonalResources error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) - return nil, nil -} - -func (s PersonalServiceBridge) UpdatePersonalProfile(ctx context.Context, request *pb.UpdatePersonalProfileRequest) (*pb.UpdatePersonalProfileResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.UpdatePersonalProfile(ctx, request) - if err != nil { - log.Errorf("PersonalResources error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) - return nil, nil -} - -func (s PersonalServiceBridge) UpdatePersonalPassword(ctx context.Context, request *pb.UpdatePersonalPasswordRequest) (*pb.UpdatePersonalPasswordResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.UpdatePersonalPassword(ctx, request) - if err != nil { - log.Errorf("PersonalResources error: %v", err) - return nil, err +func (p PersonalServiceHookedBridge) BeforeListPersonalResources(context transhttp.Context, request *pb.ListPersonalResourcesRequest) (context.Context, error) { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) ListPersonalResourcesResult(context transhttp.Context, request *pb.ListPersonalResourcesRequest, response *pb.ListPersonalResourcesResponse) error { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) BeforeListPersonalRoles(context transhttp.Context, request *pb.ListPersonalRolesRequest) (context.Context, error) { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) ListPersonalRolesResult(context transhttp.Context, request *pb.ListPersonalRolesRequest, response *pb.ListPersonalRolesResponse) error { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) BeforePersonalLogout(context transhttp.Context, request *pb.PersonalLogoutRequest) (context.Context, error) { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) PersonalLogoutResult(context transhttp.Context, request *pb.PersonalLogoutRequest, response *pb.PersonalLogoutResponse) error { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) BeforeRefreshPersonalToken(context transhttp.Context, request *pb.RefreshPersonalTokenRequest) (context.Context, error) { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) RefreshPersonalTokenResult(context transhttp.Context, request *pb.RefreshPersonalTokenRequest, response *pb.RefreshPersonalTokenResponse) error { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) BeforeUpdatePersonalPassword(context transhttp.Context, request *pb.UpdatePersonalPasswordRequest) (context.Context, error) { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) UpdatePersonalPasswordResult(context transhttp.Context, request *pb.UpdatePersonalPasswordRequest, response *pb.UpdatePersonalPasswordResponse) error { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) BeforeUpdatePersonalProfile(context transhttp.Context, request *pb.UpdatePersonalProfileRequest) (context.Context, error) { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) UpdatePersonalProfileResult(context transhttp.Context, request *pb.UpdatePersonalProfileRequest, response *pb.UpdatePersonalProfileResponse) error { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) BeforeUpdatePersonalSetting(context transhttp.Context, request *pb.UpdatePersonalSettingRequest) (context.Context, error) { + //TODO implement me + panic("implement me") +} + +func (p PersonalServiceHookedBridge) UpdatePersonalSettingResult(context transhttp.Context, request *pb.UpdatePersonalSettingRequest, response *pb.UpdatePersonalSettingResponse) error { + //TODO implement me + panic("implement me") +} + +func NewPersonalServiceHookedBridge(r runtime.Runtime, client pb.PersonalServiceHTTPServer) pb.PersonalServiceHooker { + return &PersonalServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/permission")), + client: client, } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) - return nil, nil -} - -//func (s PersonalServiceBridge) PersonalResources(ctx context.Context, request *pb.PersonalResourcesRequest) (*pb.PersonalResourcesResponse, error) { -// response, err := s.client.PersonalResources(context, request) -// if err != nil { -// log.Errorf("PersonalResources error: %v", err) -// return nil, err -// } -// s.JSON(context, http.StatusOK, &resp.Data{ -// Success: true, -// Data: response, -// }) -// return nil, nil -//} - -//func (s PersonalServiceBridge) PersonalProfile(ctx context.Context, request *pb.PersonalProfileRequest) (*pb.PersonalProfileResponse, error) { -// response, err := s.client.PersonalProfile(context, request) -// if err != nil { -// log.Errorf("PersonalProfile error: %v", err) -// return nil, err -// } -// s.JSON(context, http.StatusOK, &resp.Data{ -// Success: true, -// Data: response, -// }) -// return nil, nil -//} - -//func (s PersonalServiceBridge) Logout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { -// response, err := s.client.Logout(context, request) -// if err != nil { -// log.Errorf("Logout error: %v", err) -// return nil, err -// } -// s.JSON(context, http.StatusOK, &resp.Data{ -// Success: true, -// Data: response, -// }) -// return nil, nil -//} - -// NewPersonalServiceBridge new a Personal service. -func NewPersonalServiceBridge(client pb.PersonalServiceClient) *PersonalServiceBridge { - return &PersonalServiceBridge{client: client} -} - -// NewPersonalServiceBridgePB new a Personal service. -func NewPersonalServiceBridgePB(client pb.PersonalServiceClient) pb.PersonalServiceBridge { - return &PersonalServiceBridge{client: client} -} -func NewPersonalServiceBridgeClient(client *service.GRPCClient) pb.PersonalServiceServer { - cli := pb.NewPersonalServiceClient(client) - return NewPersonalServiceBridge(cli) -} - -var _ pb.PersonalServiceBridge = (*PersonalServiceBridge)(nil) +} + +// NewPersonalServiceBridge new a menu service. +func NewPersonalServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.PersonalServiceServer { + return pb.NewPersonalServiceBridge(client) +} + +// NewPersonalServiceHTTPBridge new a menu service. +func NewPersonalServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.PersonalServiceHTTPServer { + return pb.NewPersonalServiceHTTPBridge(client) +} + +var _ pb.PersonalServiceHooker = (*PersonalServiceHookedBridge)(nil) diff --git a/internal/mods/system/service/resource.bridge.go b/internal/mods/system/service/resource.bridge.go index bdd93ea9..9af701cd 100644 --- a/internal/mods/system/service/resource.bridge.go +++ b/internal/mods/system/service/resource.bridge.go @@ -5,102 +5,93 @@ package service import ( + "encoding/json" "net/http" - "github.com/origadmin/runtime/agent" - "github.com/origadmin/runtime/context" + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/resp" ) -// ResourceServiceBridge is a menu service. -type ResourceServiceBridge struct { - resp.Response - - client pb.ResourceServiceClient +// ResourceServiceHookedBridge is a menu service. +type ResourceServiceHookedBridge struct { + pb.UnimplementedResourceServiceHooked + log *log.KHelper } -func (s ResourceServiceBridge) CreateResource(ctx context.Context, request *pb.CreateResourceRequest) (*pb.CreateResourceResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.CreateResource(ctx, request) +func (h ResourceServiceHookedBridge) CreateResourceResult(ctx transhttp.Context, request *pb.CreateResourceRequest, response *pb.CreateResourceResponse) error { + marshal, err := json.Marshal(response.Resource) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Resource), + Data: marshal, }) - return nil, nil } -func (s ResourceServiceBridge) DeleteResource(ctx context.Context, request *pb.DeleteResourceRequest) (*pb.DeleteResourceResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - _, err := s.client.DeleteResource(ctx, request) - if err != nil { - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ +func (h ResourceServiceHookedBridge) DeleteResourceResult(ctx transhttp.Context, request *pb.DeleteResourceRequest, response *pb.DeleteResourceResponse) error { + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, Data: nil, }) - return nil, nil } -func (s ResourceServiceBridge) GetResource(ctx context.Context, request *pb.GetResourceRequest) (*pb.GetResourceResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.GetResource(ctx, request) +func (h ResourceServiceHookedBridge) GetResourceResult(ctx transhttp.Context, request *pb.GetResourceRequest, response *pb.GetResourceResponse) error { + marshal, err := json.Marshal(response.Resource) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Resource), + Data: marshal, }) - return nil, nil } -func (s ResourceServiceBridge) ListResources(ctx context.Context, request *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.ListResources(ctx, request) +func (h ResourceServiceHookedBridge) ListResourcesResult(ctx transhttp.Context, request *pb.ListResourcesRequest, response *pb.ListResourcesResponse) error { + marshal, err := json.Marshal(response.Resources) if err != nil { - return nil, err + return err } - - s.JSON(httpCtx, http.StatusOK, &resp.Page{ + return ctx.JSON(http.StatusOK, &resp.SourcePage{ Success: true, - Total: response.TotalSize, - Data: resp.Proto2AnyPBArray(response.Resources...), + Total: response.GetTotalSize(), + Data: marshal, + //Current: request.GetCurrent(), + //PageSize: nil, + //Extra: "", }) - return nil, nil } -func (s ResourceServiceBridge) UpdateResource(ctx context.Context, request *pb.UpdateResourceRequest) (*pb.UpdateResourceResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.UpdateResource(ctx, request) +func (h ResourceServiceHookedBridge) UpdateResourceResult(ctx transhttp.Context, request *pb.UpdateResourceRequest, response *pb.UpdateResourceResponse) error { + marshal, err := json.Marshal(response.Resource) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Resource), + Data: marshal, }) - return nil, nil } -// NewResourceServiceBridge new a menu service. -func NewResourceServiceBridge(client pb.ResourceServiceClient) *ResourceServiceBridge { - return &ResourceServiceBridge{client: client} +func NewResourceServiceHookedBridge(r runtime.Runtime, client pb.ResourceServiceHTTPServer) pb.ResourceServiceHookedBridger { + return pb.WithResourceServiceHook(&ResourceServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/resource")), + })(client) } -// NewResourceServiceBridgePB new a menu service. -func NewResourceServiceBridgePB(client pb.ResourceServiceClient) pb.ResourceServiceBridge { - return &ResourceServiceBridge{client: client} +// NewResourceServiceBridge new a menu service. +func NewResourceServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.ResourceServiceServer { + return pb.NewResourceServiceBridge(client) } -func NewResourceServiceBridgeClient(client *service.GRPCClient) pb.ResourceServiceBridge { - cli := pb.NewResourceServiceClient(client) - return NewResourceServiceBridge(cli) + +// NewResourceServiceHTTPBridge new a menu service. +func NewResourceServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.ResourceServiceHTTPServer { + return pb.NewResourceServiceHTTPBridge(client) } -var _ pb.ResourceServiceBridge = (*ResourceServiceBridge)(nil) +var _ pb.ResourceServiceHooker = (*ResourceServiceHookedBridge)(nil) diff --git a/internal/mods/system/service/role.bridge.go b/internal/mods/system/service/role.bridge.go index 74815b6e..8aeca9ee 100644 --- a/internal/mods/system/service/role.bridge.go +++ b/internal/mods/system/service/role.bridge.go @@ -2,105 +2,96 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package service implements the functions, types, and interfaces for the module. package service import ( + "encoding/json" "net/http" - "github.com/origadmin/runtime/agent" - "github.com/origadmin/runtime/context" + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/resp" ) -// RoleServiceAgent is a menu service. -type RoleServiceAgent struct { - resp.Response - - client pb.RoleServiceClient +// RoleServiceHookedBridge is a menu service. +type RoleServiceHookedBridge struct { + pb.UnimplementedRoleServiceHooked + log *log.KHelper } -func (s RoleServiceAgent) CreateRole(ctx context.Context, request *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.CreateRole(ctx, request) +func (h RoleServiceHookedBridge) CreateRoleResult(ctx transhttp.Context, request *pb.CreateRoleRequest, response *pb.CreateRoleResponse) error { + marshal, err := json.Marshal(response.Role) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Role), + Data: marshal, }) - return nil, nil } -func (s RoleServiceAgent) DeleteRole(ctx context.Context, request *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.DeleteRole(ctx, request) - if err != nil { - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ +func (h RoleServiceHookedBridge) DeleteRoleResult(ctx transhttp.Context, request *pb.DeleteRoleRequest, response *pb.DeleteRoleResponse) error { + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Empty), + Data: nil, }) - return nil, nil } -func (s RoleServiceAgent) GetRole(ctx context.Context, request *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.GetRole(ctx, request) +func (h RoleServiceHookedBridge) GetRoleResult(ctx transhttp.Context, request *pb.GetRoleRequest, response *pb.GetRoleResponse) error { + marshal, err := json.Marshal(response.Role) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Role), + Data: marshal, }) - return nil, nil } -func (s RoleServiceAgent) ListRoles(ctx context.Context, request *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.ListRoles(ctx, request) +func (h RoleServiceHookedBridge) ListRolesResult(ctx transhttp.Context, request *pb.ListRolesRequest, response *pb.ListRolesResponse) error { + marshal, err := json.Marshal(response.Roles) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Page{ + return ctx.JSON(http.StatusOK, &resp.SourcePage{ Success: true, - Total: response.TotalSize, - Data: resp.Proto2AnyPBArray(response.Roles...), + Total: response.GetTotalSize(), + Data: marshal, + //Current: request.GetCurrent(), + //PageSize: nil, + //Extra: "", }) - return nil, nil } -func (s RoleServiceAgent) UpdateRole(ctx context.Context, request *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.UpdateRole(ctx, request) +func (h RoleServiceHookedBridge) UpdateRoleResult(ctx transhttp.Context, request *pb.UpdateRoleRequest, response *pb.UpdateRoleResponse) error { + marshal, err := json.Marshal(response.Role) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.Role), + Data: marshal, }) - return nil, nil } -// NewRoleServiceAgent new a menu service. -func NewRoleServiceAgent(client pb.RoleServiceClient) *RoleServiceAgent { - return &RoleServiceAgent{client: client} +func NewRoleServiceHookedBridge(r runtime.Runtime, client pb.RoleServiceHTTPServer) pb.RoleServiceHookedBridger { + return pb.WithRoleServiceHook(&RoleServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/permission")), + })(client) } -// NewRoleServiceAgentPB new a menu service. -func NewRoleServiceAgentPB(client pb.RoleServiceClient) pb.RoleServiceBridger { - return &RoleServiceAgent{client: client} +// NewRoleServiceBridge new a menu service. +func NewRoleServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.RoleServiceServer { + return pb.NewRoleServiceBridge(client) } -func NewRoleServiceAgentClient(client *service.GRPCClient) pb.RoleServiceAgent { - c := pb.NewRoleServiceClient(client) - return NewRoleServiceAgent(c) + +// NewRoleServiceHTTPBridge new a menu service. +func NewRoleServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.RoleServiceHTTPServer { + return pb.NewRoleServiceHTTPBridge(client) } -var _ pb.RoleServiceAgent = (*RoleServiceAgent)(nil) +var _ pb.RoleServiceHooker = (*RoleServiceHookedBridge)(nil) diff --git a/internal/mods/system/service/user.bridge.go b/internal/mods/system/service/user.bridge.go index eb440b2d..35e6f471 100644 --- a/internal/mods/system/service/user.bridge.go +++ b/internal/mods/system/service/user.bridge.go @@ -2,135 +2,96 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package service implements the functions, types, and interfaces for the module. package service import ( + "encoding/json" "net/http" - "github.com/origadmin/runtime/agent" - "github.com/origadmin/runtime/context" + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/resp" ) -// UserServiceBridge is a menu service. -type UserServiceBridge struct { - resp.Response - - client pb.UserServiceClient +// UserServiceHookedBridge is a menu service. +type UserServiceHookedBridge struct { + pb.UnimplementedUserServiceHooked + log *log.KHelper } -func (s UserServiceBridge) ListUserResources(ctx context.Context, request *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.ListUserResources(ctx, request) +func (h UserServiceHookedBridge) CreateUserResult(ctx transhttp.Context, request *pb.CreateUserRequest, response *pb.CreateUserResponse) error { + marshal, err := json.Marshal(response.User) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.DataArray{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2AnyPBArray(response.Resources...), + Data: marshal, }) - return nil, nil -} - -func (s UserServiceBridge) UpdateUserRoles(ctx context.Context, request *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (s UserServiceBridge) ResetUserPassword(ctx context.Context, request *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { - //TODO implement me - panic("implement me") } -func (s UserServiceBridge) UpdateUserStatus(ctx context.Context, request *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { - //TODO implement me - panic("implement me") -} - -func (s UserServiceBridge) CreateUser(ctx context.Context, request *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.CreateUser(ctx, request) - if err != nil { - return nil, err - } - - s.JSON(httpCtx, http.StatusOK, &resp.Data{ +func (h UserServiceHookedBridge) DeleteUserResult(ctx transhttp.Context, request *pb.DeleteUserRequest, response *pb.DeleteUserResponse) error { + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: resp.Proto2Any(response.User), + Data: nil, }) - return nil, nil } -func (s UserServiceBridge) DeleteUser(ctx context.Context, request *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - _, err := s.client.DeleteUser(ctx, request) +func (h UserServiceHookedBridge) GetUserResult(ctx transhttp.Context, request *pb.GetUserRequest, response *pb.GetUserResponse) error { + marshal, err := json.Marshal(response.User) if err != nil { - return nil, err + return err } - - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Data: nil, + Data: marshal, }) - return nil, nil } -func (s UserServiceBridge) GetUser(ctx context.Context, request *pb.GetUserRequest) (*pb.GetUserResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.GetUser(ctx, request) +func (h UserServiceHookedBridge) ListUsersResult(ctx transhttp.Context, request *pb.ListUsersRequest, response *pb.ListUsersResponse) error { + marshal, err := json.Marshal(response.Users) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ + return ctx.JSON(http.StatusOK, &resp.SourcePage{ Success: true, - Data: resp.Proto2Any(response.User), + Total: response.GetTotalSize(), + Data: marshal, + //Current: request.GetCurrent(), + //PageSize: nil, + //Extra: "", }) - return nil, nil } -func (s UserServiceBridge) ListUsers(ctx context.Context, request *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.ListUsers(ctx, request) +func (h UserServiceHookedBridge) UpdateUserResult(ctx transhttp.Context, request *pb.UpdateUserRequest, response *pb.UpdateUserResponse) error { + marshal, err := json.Marshal(response.User) if err != nil { - return nil, err + return err } - s.JSON(httpCtx, http.StatusOK, &resp.Page{ + return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, - Total: response.TotalSize, - Data: resp.Proto2AnyPBArray(response.Users...), + Data: marshal, }) - return nil, nil } -func (s UserServiceBridge) UpdateUser(ctx context.Context, request *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.UpdateUser(ctx, request) - if err != nil { - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response.User), - }) - return nil, nil +func NewUserServiceHookedBridge(r runtime.Runtime, client pb.UserServiceBridger) pb.UserServiceHookedBridger { + return pb.WithUserServiceHook(&UserServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/permission")), + })(client) } // NewUserServiceBridge new a menu service. -func NewUserServiceBridge(client pb.UserServiceClient) *UserServiceBridge { - return &UserServiceBridge{client: client} +func NewUserServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.UserServiceServer { + return pb.NewUserServiceBridge(client) } -// NewUserServiceBridgePB new a menu service. -func NewUserServiceBridgePB(client pb.UserServiceClient) pb.UserServiceBridge { - return &UserServiceBridge{client: client} -} -func NewUserServiceBridgeClient(client *service.GRPCClient) pb.UserServiceBridge { - c := pb.NewUserServiceClient(client) - return NewUserServiceBridge(c) +// NewUserServiceHTTPBridge new a menu service. +func NewUserServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.UserServiceHTTPServer { + return pb.NewUserServiceHTTPBridge(client) } -var _ pb.UserServiceBridge = (*UserServiceBridge)(nil) +var _ pb.UserServiceHooker = (*UserServiceHookedBridge)(nil) From 7da084ec61e64197b981855a25c56234e9df1c73 Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 30 May 2025 21:33:48 +0800 Subject: [PATCH 030/158] refactor(api): rename login service package and update casbin bridge implementation - Rename login service package from 'system' to 'auth' - Update package name in login.proto file - Modify casbin_bridge.pb.go to include new streaming method --- api/v1/proto/{system => auth}/login.proto | 9 +- api/v1/services/auth/casbin_bridge.pb.go | 27 +- api/v1/services/{system => auth}/login.pb.go | 370 +++--- .../services/{system => auth}/login.pb.gw.go | 38 +- .../{system => auth}/login.pb.validate.go | 4 +- .../{system => auth}/login_bridge.pb.go | 20 +- .../{system => auth}/login_grpc.pb.go | 24 +- .../{system => auth}/login_http.pb.go | 20 +- contrib/security/authz/casbin/option.go | 2 +- contrib/security/authz/casbin/update.go | 4 +- internal/mods/auth/biz/auth.biz.go | 6 +- internal/mods/auth/biz/biz.go | 10 - internal/mods/auth/biz/casbin.biz.go | 8 +- internal/mods/auth/biz/login.biz.go | 8 +- internal/mods/auth/dal/auth.dal.go | 4 +- internal/mods/auth/dal/casbin.dal.go | 4 +- internal/mods/auth/dal/dal.go | 2 +- internal/mods/auth/dal/login.dal.go | 10 +- internal/mods/auth/dal/user.dal.go | 4 +- internal/mods/{system => auth}/dto/auth.go | 4 +- internal/mods/{system => auth}/dto/casbin.go | 2 +- internal/mods/auth/dto/dto.go | 1020 +++++++++++++++++ internal/mods/{system => auth}/dto/login.go | 0 internal/mods/auth/service/auth.agent.go | 2 +- internal/mods/auth/service/auth.grpc.go | 4 +- internal/mods/auth/service/auth.http.go | 2 +- internal/mods/auth/service/casbin.grpc.go | 4 +- internal/mods/auth/service/casbin.http.go | 2 +- internal/mods/auth/service/login.agent.go | 2 +- internal/mods/auth/service/login.grpc.go | 4 +- internal/mods/auth/service/login.http.go | 2 +- internal/mods/system/biz/auth.biz.go | 4 +- internal/mods/system/dto/dto.go | 61 +- internal/mods/system/dto/role.go | 3 +- internal/mods/system/dto/user.go | 7 +- resources/docs/openapi/openapi.yaml | 202 ++-- 36 files changed, 1467 insertions(+), 432 deletions(-) rename api/v1/proto/{system => auth}/login.proto (95%) rename api/v1/services/{system => auth}/login.pb.go (72%) rename api/v1/services/{system => auth}/login.pb.gw.go (94%) rename api/v1/services/{system => auth}/login.pb.validate.go (99%) rename api/v1/services/{system => auth}/login_bridge.pb.go (96%) rename api/v1/services/{system => auth}/login_grpc.pb.go (94%) rename api/v1/services/{system => auth}/login_http.pb.go (93%) rename internal/mods/{system => auth}/dto/auth.go (92%) rename internal/mods/{system => auth}/dto/casbin.go (93%) create mode 100644 internal/mods/auth/dto/dto.go rename internal/mods/{system => auth}/dto/login.go (100%) diff --git a/api/v1/proto/system/login.proto b/api/v1/proto/auth/login.proto similarity index 95% rename from api/v1/proto/system/login.proto rename to api/v1/proto/auth/login.proto index b8e5342f..e41c5072 100644 --- a/api/v1/proto/system/login.proto +++ b/api/v1/proto/auth/login.proto @@ -1,16 +1,17 @@ syntax = "proto3"; -package api.v1.services.system; +package api.v1.services.auth; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "security/jwt/v1/token.proto"; import "validate/validate.proto"; -option go_package = "api/v1/services/system;system"; +option go_package = "api/v1/services/auth;auth"; option java_multiple_files = true; -option java_outer_classname = "APIV1ServicesSystemProto"; -option java_package = "com.origadmin.api.v1.services.system"; +option java_outer_classname = "APIV1ServicesAuthLoginProto"; +option java_package = "com.origadmin.api.v1.services.auth"; +option objc_class_prefix = "APIServiceAuthLogin"; // The login service definition. service LoginService { diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index c41b2e89..2600aaa9 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -7,9 +7,11 @@ package auth import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" + "context" + "io" + + "github.com/go-kratos/kratos/v2/transport/http" + "google.golang.org/grpc" ) // This is a compile-time assertion to ensure that this generated file @@ -201,6 +203,25 @@ func NewCasbinSourceServiceBridge(client grpc.ClientConnInterface) CasbinSourceS return &CasbinSourceServiceBridgeImpl{client: NewCasbinSourceServiceClient(client)} } +func (c *CasbinSourceServiceBridgeImpl) StreamRules(req *StreamRulesRequest, srv grpc.ServerStreamingServer[StreamRulesResponse]) error { + client, err := c.client.StreamRules(srv.Context(), req) + if err != nil { + return err + } + for { + resp, err := client.Recv() + if err != nil { + if err == io.EOF { + return nil + } + return err + } + if err := srv.Send(resp); err != nil { + return err + } + } +} + func (c *CasbinSourceServiceBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { return c.client.ListGroupings(ctx, in) } diff --git a/api/v1/services/system/login.pb.go b/api/v1/services/auth/login.pb.go similarity index 72% rename from api/v1/services/system/login.pb.go rename to api/v1/services/auth/login.pb.go index eb1084e2..93d34a71 100644 --- a/api/v1/services/system/login.pb.go +++ b/api/v1/services/auth/login.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.36.6 // protoc (unknown) -// source: system/login.proto +// source: auth/login.proto -package system +package auth import ( _ "github.com/envoyproxy/protoc-gen-validate/validate" @@ -34,7 +34,7 @@ type TokenRefreshRequest struct { func (x *TokenRefreshRequest) Reset() { *x = TokenRefreshRequest{} - mi := &file_system_login_proto_msgTypes[0] + mi := &file_auth_login_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -46,7 +46,7 @@ func (x *TokenRefreshRequest) String() string { func (*TokenRefreshRequest) ProtoMessage() {} func (x *TokenRefreshRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[0] + mi := &file_auth_login_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -59,7 +59,7 @@ func (x *TokenRefreshRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use TokenRefreshRequest.ProtoReflect.Descriptor instead. func (*TokenRefreshRequest) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{0} + return file_auth_login_proto_rawDescGZIP(), []int{0} } func (x *TokenRefreshRequest) GetData() *TokenRefreshRequest_Data { @@ -78,7 +78,7 @@ type TokenRefreshResponse struct { func (x *TokenRefreshResponse) Reset() { *x = TokenRefreshResponse{} - mi := &file_system_login_proto_msgTypes[1] + mi := &file_auth_login_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -90,7 +90,7 @@ func (x *TokenRefreshResponse) String() string { func (*TokenRefreshResponse) ProtoMessage() {} func (x *TokenRefreshResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[1] + mi := &file_auth_login_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -103,7 +103,7 @@ func (x *TokenRefreshResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use TokenRefreshResponse.ProtoReflect.Descriptor instead. func (*TokenRefreshResponse) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{1} + return file_auth_login_proto_rawDescGZIP(), []int{1} } func (x *TokenRefreshResponse) GetToken() *v1.Token { @@ -122,7 +122,7 @@ type LoginRequest struct { func (x *LoginRequest) Reset() { *x = LoginRequest{} - mi := &file_system_login_proto_msgTypes[2] + mi := &file_auth_login_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -134,7 +134,7 @@ func (x *LoginRequest) String() string { func (*LoginRequest) ProtoMessage() {} func (x *LoginRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[2] + mi := &file_auth_login_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -147,7 +147,7 @@ func (x *LoginRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. func (*LoginRequest) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{2} + return file_auth_login_proto_rawDescGZIP(), []int{2} } func (x *LoginRequest) GetData() *LoginRequest_Data { @@ -166,7 +166,7 @@ type LoginResponse struct { func (x *LoginResponse) Reset() { *x = LoginResponse{} - mi := &file_system_login_proto_msgTypes[3] + mi := &file_auth_login_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -178,7 +178,7 @@ func (x *LoginResponse) String() string { func (*LoginResponse) ProtoMessage() {} func (x *LoginResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[3] + mi := &file_auth_login_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -191,7 +191,7 @@ func (x *LoginResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. func (*LoginResponse) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{3} + return file_auth_login_proto_rawDescGZIP(), []int{3} } func (x *LoginResponse) GetToken() *v1.Token { @@ -210,7 +210,7 @@ type CurrentUserRequestQuery struct { func (x *CurrentUserRequestQuery) Reset() { *x = CurrentUserRequestQuery{} - mi := &file_system_login_proto_msgTypes[4] + mi := &file_auth_login_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -222,7 +222,7 @@ func (x *CurrentUserRequestQuery) String() string { func (*CurrentUserRequestQuery) ProtoMessage() {} func (x *CurrentUserRequestQuery) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[4] + mi := &file_auth_login_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -235,7 +235,7 @@ func (x *CurrentUserRequestQuery) ProtoReflect() protoreflect.Message { // Deprecated: Use CurrentUserRequestQuery.ProtoReflect.Descriptor instead. func (*CurrentUserRequestQuery) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{4} + return file_auth_login_proto_rawDescGZIP(), []int{4} } func (x *CurrentUserRequestQuery) GetUserId() int64 { @@ -254,7 +254,7 @@ type CurrentUserRequest struct { func (x *CurrentUserRequest) Reset() { *x = CurrentUserRequest{} - mi := &file_system_login_proto_msgTypes[5] + mi := &file_auth_login_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -266,7 +266,7 @@ func (x *CurrentUserRequest) String() string { func (*CurrentUserRequest) ProtoMessage() {} func (x *CurrentUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[5] + mi := &file_auth_login_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -279,7 +279,7 @@ func (x *CurrentUserRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CurrentUserRequest.ProtoReflect.Descriptor instead. func (*CurrentUserRequest) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{5} + return file_auth_login_proto_rawDescGZIP(), []int{5} } func (x *CurrentUserRequest) GetData() *CurrentUserRequestQuery { @@ -299,7 +299,7 @@ type CurrentUserResponse struct { func (x *CurrentUserResponse) Reset() { *x = CurrentUserResponse{} - mi := &file_system_login_proto_msgTypes[6] + mi := &file_auth_login_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -311,7 +311,7 @@ func (x *CurrentUserResponse) String() string { func (*CurrentUserResponse) ProtoMessage() {} func (x *CurrentUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[6] + mi := &file_auth_login_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -324,7 +324,7 @@ func (x *CurrentUserResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CurrentUserResponse.ProtoReflect.Descriptor instead. func (*CurrentUserResponse) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{6} + return file_auth_login_proto_rawDescGZIP(), []int{6} } func (x *CurrentUserResponse) GetSuccess() bool { @@ -352,7 +352,7 @@ type CaptchaIdRequest struct { func (x *CaptchaIdRequest) Reset() { *x = CaptchaIdRequest{} - mi := &file_system_login_proto_msgTypes[7] + mi := &file_auth_login_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -364,7 +364,7 @@ func (x *CaptchaIdRequest) String() string { func (*CaptchaIdRequest) ProtoMessage() {} func (x *CaptchaIdRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[7] + mi := &file_auth_login_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -377,7 +377,7 @@ func (x *CaptchaIdRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CaptchaIdRequest.ProtoReflect.Descriptor instead. func (*CaptchaIdRequest) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{7} + return file_auth_login_proto_rawDescGZIP(), []int{7} } func (x *CaptchaIdRequest) GetTs() string { @@ -403,7 +403,7 @@ type CaptchaIdResponse struct { func (x *CaptchaIdResponse) Reset() { *x = CaptchaIdResponse{} - mi := &file_system_login_proto_msgTypes[8] + mi := &file_auth_login_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -415,7 +415,7 @@ func (x *CaptchaIdResponse) String() string { func (*CaptchaIdResponse) ProtoMessage() {} func (x *CaptchaIdResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[8] + mi := &file_auth_login_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -428,7 +428,7 @@ func (x *CaptchaIdResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CaptchaIdResponse.ProtoReflect.Descriptor instead. func (*CaptchaIdResponse) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{8} + return file_auth_login_proto_rawDescGZIP(), []int{8} } func (x *CaptchaIdResponse) GetData() string { @@ -450,7 +450,7 @@ type CaptchaImageRequest struct { func (x *CaptchaImageRequest) Reset() { *x = CaptchaImageRequest{} - mi := &file_system_login_proto_msgTypes[9] + mi := &file_auth_login_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -462,7 +462,7 @@ func (x *CaptchaImageRequest) String() string { func (*CaptchaImageRequest) ProtoMessage() {} func (x *CaptchaImageRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[9] + mi := &file_auth_login_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -475,7 +475,7 @@ func (x *CaptchaImageRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CaptchaImageRequest.ProtoReflect.Descriptor instead. func (*CaptchaImageRequest) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{9} + return file_auth_login_proto_rawDescGZIP(), []int{9} } func (x *CaptchaImageRequest) GetId() string { @@ -509,7 +509,7 @@ type CaptchaData struct { func (x *CaptchaData) Reset() { *x = CaptchaData{} - mi := &file_system_login_proto_msgTypes[10] + mi := &file_auth_login_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -521,7 +521,7 @@ func (x *CaptchaData) String() string { func (*CaptchaData) ProtoMessage() {} func (x *CaptchaData) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[10] + mi := &file_auth_login_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -534,7 +534,7 @@ func (x *CaptchaData) ProtoReflect() protoreflect.Message { // Deprecated: Use CaptchaData.ProtoReflect.Descriptor instead. func (*CaptchaData) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{10} + return file_auth_login_proto_rawDescGZIP(), []int{10} } func (x *CaptchaData) GetCaptchaId() string { @@ -562,7 +562,7 @@ type CaptchaImageResponse struct { func (x *CaptchaImageResponse) Reset() { *x = CaptchaImageResponse{} - mi := &file_system_login_proto_msgTypes[11] + mi := &file_auth_login_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -574,7 +574,7 @@ func (x *CaptchaImageResponse) String() string { func (*CaptchaImageResponse) ProtoMessage() {} func (x *CaptchaImageResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[11] + mi := &file_auth_login_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -587,7 +587,7 @@ func (x *CaptchaImageResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CaptchaImageResponse.ProtoReflect.Descriptor instead. func (*CaptchaImageResponse) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{11} + return file_auth_login_proto_rawDescGZIP(), []int{11} } func (x *CaptchaImageResponse) GetHeaders() map[string]string { @@ -616,7 +616,7 @@ type CaptchaAudioRequest struct { func (x *CaptchaAudioRequest) Reset() { *x = CaptchaAudioRequest{} - mi := &file_system_login_proto_msgTypes[12] + mi := &file_auth_login_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -628,7 +628,7 @@ func (x *CaptchaAudioRequest) String() string { func (*CaptchaAudioRequest) ProtoMessage() {} func (x *CaptchaAudioRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[12] + mi := &file_auth_login_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -641,7 +641,7 @@ func (x *CaptchaAudioRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CaptchaAudioRequest.ProtoReflect.Descriptor instead. func (*CaptchaAudioRequest) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{12} + return file_auth_login_proto_rawDescGZIP(), []int{12} } func (x *CaptchaAudioRequest) GetId() string { @@ -676,7 +676,7 @@ type CaptchaAudioResponse struct { func (x *CaptchaAudioResponse) Reset() { *x = CaptchaAudioResponse{} - mi := &file_system_login_proto_msgTypes[13] + mi := &file_auth_login_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -688,7 +688,7 @@ func (x *CaptchaAudioResponse) String() string { func (*CaptchaAudioResponse) ProtoMessage() {} func (x *CaptchaAudioResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[13] + mi := &file_auth_login_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -701,7 +701,7 @@ func (x *CaptchaAudioResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CaptchaAudioResponse.ProtoReflect.Descriptor instead. func (*CaptchaAudioResponse) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{13} + return file_auth_login_proto_rawDescGZIP(), []int{13} } func (x *CaptchaAudioResponse) GetHeaders() map[string]string { @@ -734,7 +734,7 @@ type CaptchaRequest struct { func (x *CaptchaRequest) Reset() { *x = CaptchaRequest{} - mi := &file_system_login_proto_msgTypes[14] + mi := &file_auth_login_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -746,7 +746,7 @@ func (x *CaptchaRequest) String() string { func (*CaptchaRequest) ProtoMessage() {} func (x *CaptchaRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[14] + mi := &file_auth_login_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -759,7 +759,7 @@ func (x *CaptchaRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CaptchaRequest.ProtoReflect.Descriptor instead. func (*CaptchaRequest) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{14} + return file_auth_login_proto_rawDescGZIP(), []int{14} } func (x *CaptchaRequest) GetId() string { @@ -801,7 +801,7 @@ type CaptchaResponse struct { func (x *CaptchaResponse) Reset() { *x = CaptchaResponse{} - mi := &file_system_login_proto_msgTypes[15] + mi := &file_auth_login_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -813,7 +813,7 @@ func (x *CaptchaResponse) String() string { func (*CaptchaResponse) ProtoMessage() {} func (x *CaptchaResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[15] + mi := &file_auth_login_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -826,7 +826,7 @@ func (x *CaptchaResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CaptchaResponse.ProtoReflect.Descriptor instead. func (*CaptchaResponse) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{15} + return file_auth_login_proto_rawDescGZIP(), []int{15} } func (x *CaptchaResponse) GetId() string { @@ -859,7 +859,7 @@ type RegisterRequest struct { func (x *RegisterRequest) Reset() { *x = RegisterRequest{} - mi := &file_system_login_proto_msgTypes[16] + mi := &file_auth_login_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -871,7 +871,7 @@ func (x *RegisterRequest) String() string { func (*RegisterRequest) ProtoMessage() {} func (x *RegisterRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[16] + mi := &file_auth_login_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -884,7 +884,7 @@ func (x *RegisterRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. func (*RegisterRequest) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{16} + return file_auth_login_proto_rawDescGZIP(), []int{16} } func (x *RegisterRequest) GetData() *RegisterRequest_Data { @@ -904,7 +904,7 @@ type RegisterResponse struct { func (x *RegisterResponse) Reset() { *x = RegisterResponse{} - mi := &file_system_login_proto_msgTypes[17] + mi := &file_auth_login_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -916,7 +916,7 @@ func (x *RegisterResponse) String() string { func (*RegisterResponse) ProtoMessage() {} func (x *RegisterResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[17] + mi := &file_auth_login_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -929,7 +929,7 @@ func (x *RegisterResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. func (*RegisterResponse) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{17} + return file_auth_login_proto_rawDescGZIP(), []int{17} } func (x *RegisterResponse) GetSuccess() bool { @@ -955,7 +955,7 @@ type LogoutRequest struct { func (x *LogoutRequest) Reset() { *x = LogoutRequest{} - mi := &file_system_login_proto_msgTypes[18] + mi := &file_auth_login_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -967,7 +967,7 @@ func (x *LogoutRequest) String() string { func (*LogoutRequest) ProtoMessage() {} func (x *LogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[18] + mi := &file_auth_login_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -980,7 +980,7 @@ func (x *LogoutRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. func (*LogoutRequest) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{18} + return file_auth_login_proto_rawDescGZIP(), []int{18} } func (x *LogoutRequest) GetData() *anypb.Any { @@ -999,7 +999,7 @@ type LogoutResponse struct { func (x *LogoutResponse) Reset() { *x = LogoutResponse{} - mi := &file_system_login_proto_msgTypes[19] + mi := &file_auth_login_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1011,7 +1011,7 @@ func (x *LogoutResponse) String() string { func (*LogoutResponse) ProtoMessage() {} func (x *LogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[19] + mi := &file_auth_login_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1024,7 +1024,7 @@ func (x *LogoutResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead. func (*LogoutResponse) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{19} + return file_auth_login_proto_rawDescGZIP(), []int{19} } func (x *LogoutResponse) GetSuccess() bool { @@ -1043,7 +1043,7 @@ type TokenRefreshRequest_Data struct { func (x *TokenRefreshRequest_Data) Reset() { *x = TokenRefreshRequest_Data{} - mi := &file_system_login_proto_msgTypes[20] + mi := &file_auth_login_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1055,7 +1055,7 @@ func (x *TokenRefreshRequest_Data) String() string { func (*TokenRefreshRequest_Data) ProtoMessage() {} func (x *TokenRefreshRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[20] + mi := &file_auth_login_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1068,7 +1068,7 @@ func (x *TokenRefreshRequest_Data) ProtoReflect() protoreflect.Message { // Deprecated: Use TokenRefreshRequest_Data.ProtoReflect.Descriptor instead. func (*TokenRefreshRequest_Data) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{0, 0} + return file_auth_login_proto_rawDescGZIP(), []int{0, 0} } func (x *TokenRefreshRequest_Data) GetRefreshToken() string { @@ -1090,7 +1090,7 @@ type LoginRequest_Data struct { func (x *LoginRequest_Data) Reset() { *x = LoginRequest_Data{} - mi := &file_system_login_proto_msgTypes[21] + mi := &file_auth_login_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1102,7 +1102,7 @@ func (x *LoginRequest_Data) String() string { func (*LoginRequest_Data) ProtoMessage() {} func (x *LoginRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[21] + mi := &file_auth_login_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1115,7 +1115,7 @@ func (x *LoginRequest_Data) ProtoReflect() protoreflect.Message { // Deprecated: Use LoginRequest_Data.ProtoReflect.Descriptor instead. func (*LoginRequest_Data) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{2, 0} + return file_auth_login_proto_rawDescGZIP(), []int{2, 0} } func (x *LoginRequest_Data) GetUsername() string { @@ -1158,7 +1158,7 @@ type RegisterRequest_Data struct { func (x *RegisterRequest_Data) Reset() { *x = RegisterRequest_Data{} - mi := &file_system_login_proto_msgTypes[24] + mi := &file_auth_login_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1170,7 +1170,7 @@ func (x *RegisterRequest_Data) String() string { func (*RegisterRequest_Data) ProtoMessage() {} func (x *RegisterRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[24] + mi := &file_auth_login_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1183,7 +1183,7 @@ func (x *RegisterRequest_Data) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterRequest_Data.ProtoReflect.Descriptor instead. func (*RegisterRequest_Data) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{16, 0} + return file_auth_login_proto_rawDescGZIP(), []int{16, 0} } func (x *RegisterRequest_Data) GetUsername() string { @@ -1223,7 +1223,7 @@ type RegisterResponse_Data struct { func (x *RegisterResponse_Data) Reset() { *x = RegisterResponse_Data{} - mi := &file_system_login_proto_msgTypes[25] + mi := &file_auth_login_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1235,7 +1235,7 @@ func (x *RegisterResponse_Data) String() string { func (*RegisterResponse_Data) ProtoMessage() {} func (x *RegisterResponse_Data) ProtoReflect() protoreflect.Message { - mi := &file_system_login_proto_msgTypes[25] + mi := &file_auth_login_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1248,7 +1248,7 @@ func (x *RegisterResponse_Data) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterResponse_Data.ProtoReflect.Descriptor instead. func (*RegisterResponse_Data) Descriptor() ([]byte, []int) { - return file_system_login_proto_rawDescGZIP(), []int{17, 0} + return file_auth_login_proto_rawDescGZIP(), []int{17, 0} } func (x *RegisterResponse_Data) GetRedirect() string { @@ -1258,19 +1258,19 @@ func (x *RegisterResponse_Data) GetRedirect() string { return "" } -var File_system_login_proto protoreflect.FileDescriptor +var File_auth_login_proto protoreflect.FileDescriptor -const file_system_login_proto_rawDesc = "" + +const file_auth_login_proto_rawDesc = "" + "\n" + - "\x12system/login.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bsecurity/jwt/v1/token.proto\x1a\x17validate/validate.proto\"\x92\x01\n" + - "\x13TokenRefreshRequest\x12D\n" + - "\x04data\x18\x02 \x01(\v20.api.v1.services.system.TokenRefreshRequest.DataR\x04data\x1a5\n" + + "\x10auth/login.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bsecurity/jwt/v1/token.proto\x1a\x17validate/validate.proto\"\x90\x01\n" + + "\x13TokenRefreshRequest\x12B\n" + + "\x04data\x18\x02 \x01(\v2..api.v1.services.auth.TokenRefreshRequest.DataR\x04data\x1a5\n" + "\x04Data\x12-\n" + "\rrefresh_token\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\rrefresh_token\"D\n" + "\x14TokenRefreshResponse\x12,\n" + - "\x05token\x18\x01 \x01(\v2\x16.security.jwt.v1.TokenR\x05token\"\xf6\x01\n" + - "\fLoginRequest\x12=\n" + - "\x04data\x18\x02 \x01(\v2).api.v1.services.system.LoginRequest.DataR\x04data\x1a\xa6\x01\n" + + "\x05token\x18\x01 \x01(\v2\x16.security.jwt.v1.TokenR\x05token\"\xf4\x01\n" + + "\fLoginRequest\x12;\n" + + "\x04data\x18\x02 \x01(\v2'.api.v1.services.auth.LoginRequest.DataR\x04data\x1a\xa6\x01\n" + "\x04Data\x12#\n" + "\busername\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12#\n" + "\bpassword\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\bpassword\x12'\n" + @@ -1281,9 +1281,9 @@ const file_system_login_proto_rawDesc = "" + "\rLoginResponse\x12,\n" + "\x05token\x18\x01 \x01(\v2\x16.security.jwt.v1.TokenR\x05token\"3\n" + "\x17CurrentUserRequestQuery\x12\x18\n" + - "\auser_id\x18\x01 \x01(\x03R\auser_id\"Y\n" + - "\x12CurrentUserRequest\x12C\n" + - "\x04data\x18\x01 \x01(\v2/.api.v1.services.system.CurrentUserRequestQueryR\x04data\"Y\n" + + "\auser_id\x18\x01 \x01(\x03R\auser_id\"W\n" + + "\x12CurrentUserRequest\x12A\n" + + "\x04data\x18\x01 \x01(\v2-.api.v1.services.auth.CurrentUserRequestQueryR\x04data\"Y\n" + "\x13CurrentUserResponse\x12\x18\n" + "\asuccess\x18\x01 \x01(\bR\asuccess\x12(\n" + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\":\n" + @@ -1300,9 +1300,9 @@ const file_system_login_proto_rawDesc = "" + "\n" + "captcha_id\x18\x01 \x01(\tR\tcaptchaId\x12\x1f\n" + "\vcaptcha_img\x18\x02 \x01(\tR\n" + - "captchaImg\"\xbd\x01\n" + - "\x14CaptchaImageResponse\x12S\n" + - "\aheaders\x18\x01 \x03(\v29.api.v1.services.system.CaptchaImageResponse.HeadersEntryR\aheaders\x12\x14\n" + + "captchaImg\"\xbb\x01\n" + + "\x14CaptchaImageResponse\x12Q\n" + + "\aheaders\x18\x01 \x03(\v27.api.v1.services.auth.CaptchaImageResponse.HeadersEntryR\aheaders\x12\x14\n" + "\x05image\x18\x02 \x01(\fR\x05image\x1a:\n" + "\fHeadersEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + @@ -1310,9 +1310,9 @@ const file_system_login_proto_rawDesc = "" + "\x13CaptchaAudioRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" + "\x06reload\x18\x02 \x01(\tR\x06reload\x12(\n" + - "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\xbd\x01\n" + - "\x14CaptchaAudioResponse\x12S\n" + - "\aheaders\x18\x01 \x03(\v29.api.v1.services.system.CaptchaAudioResponse.HeadersEntryR\aheaders\x12\x14\n" + + "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\xbb\x01\n" + + "\x14CaptchaAudioResponse\x12Q\n" + + "\aheaders\x18\x01 \x03(\v27.api.v1.services.auth.CaptchaAudioResponse.HeadersEntryR\aheaders\x12\x14\n" + "\x05audio\x18\x02 \x01(\fR\x05audio\x1a:\n" + "\fHeadersEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + @@ -1325,110 +1325,110 @@ const file_system_login_proto_rawDesc = "" + "\x0fCaptchaResponse\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + "\x04type\x18\x02 \x01(\tR\x04type\x12\x12\n" + - "\x04data\x18\x03 \x01(\tR\x04data\"\xfc\x01\n" + - "\x0fRegisterRequest\x12@\n" + - "\x04data\x18\x02 \x01(\v2,.api.v1.services.system.RegisterRequest.DataR\x04data\x1a\xa6\x01\n" + + "\x04data\x18\x03 \x01(\tR\x04data\"\xfa\x01\n" + + "\x0fRegisterRequest\x12>\n" + + "\x04data\x18\x02 \x01(\v2*.api.v1.services.auth.RegisterRequest.DataR\x04data\x1a\xa6\x01\n" + "\x04Data\x12#\n" + "\busername\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12#\n" + "\bpassword\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\bpassword\x12'\n" + "\n" + "captcha_id\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\n" + "captcha_id\x12+\n" + - "\fcaptcha_code\x18\x04 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\fcaptcha_code\"\x93\x01\n" + + "\fcaptcha_code\x18\x04 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\fcaptcha_code\"\x91\x01\n" + "\x10RegisterResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\x12A\n" + - "\x04data\x18\x02 \x01(\v2-.api.v1.services.system.RegisterResponse.DataR\x04data\x1a\"\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12?\n" + + "\x04data\x18\x02 \x01(\v2+.api.v1.services.auth.RegisterResponse.DataR\x04data\x1a\"\n" + "\x04Data\x12\x1a\n" + "\bredirect\x18\x01 \x01(\tR\bredirect\"9\n" + "\rLogoutRequest\x12(\n" + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"*\n" + "\x0eLogoutResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess2\xe2\a\n" + - "\fLoginService\x12o\n" + - "\aCaptcha\x12&.api.v1.services.system.CaptchaRequest\x1a'.api.v1.services.system.CaptchaResponse\"\x13\x82\xd3\xe4\x93\x02\rb\x01*\x12\b/captcha\x12u\n" + - "\tCaptchaId\x12(.api.v1.services.system.CaptchaIdRequest\x1a).api.v1.services.system.CaptchaIdResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/captcha/id\x12\x84\x01\n" + - "\fCaptchaImage\x12+.api.v1.services.system.CaptchaImageRequest\x1a,.api.v1.services.system.CaptchaImageResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/image\x12\x84\x01\n" + - "\fCaptchaAudio\x12+.api.v1.services.system.CaptchaAudioRequest\x1a,.api.v1.services.system.CaptchaAudioResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/audio\x12j\n" + - "\x05Login\x12$.api.v1.services.system.LoginRequest\x1a%.api.v1.services.system.LoginResponse\"\x14\x82\xd3\xe4\x93\x02\x0e:\x04data\"\x06/login\x12n\n" + - "\x06Logout\x12%.api.v1.services.system.LogoutRequest\x1a&.api.v1.services.system.LogoutResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/logout\x12v\n" + - "\bRegister\x12'.api.v1.services.system.RegisterRequest\x1a(.api.v1.services.system.RegisterResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x04data\"\t/register\x12\x87\x01\n" + - "\fTokenRefresh\x12+.api.v1.services.system.TokenRefreshRequest\x1a,.api.v1.services.system.TokenRefreshResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04data\"\x0e/token/refreshB\xc3\x01\n" + - "\x1acom.api.v1.services.systemB\n" + - "LoginProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\asuccess\x18\x01 \x01(\bR\asuccess2\xc2\a\n" + + "\fLoginService\x12k\n" + + "\aCaptcha\x12$.api.v1.services.auth.CaptchaRequest\x1a%.api.v1.services.auth.CaptchaResponse\"\x13\x82\xd3\xe4\x93\x02\rb\x01*\x12\b/captcha\x12q\n" + + "\tCaptchaId\x12&.api.v1.services.auth.CaptchaIdRequest\x1a'.api.v1.services.auth.CaptchaIdResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/captcha/id\x12\x80\x01\n" + + "\fCaptchaImage\x12).api.v1.services.auth.CaptchaImageRequest\x1a*.api.v1.services.auth.CaptchaImageResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/image\x12\x80\x01\n" + + "\fCaptchaAudio\x12).api.v1.services.auth.CaptchaAudioRequest\x1a*.api.v1.services.auth.CaptchaAudioResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/audio\x12f\n" + + "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x14\x82\xd3\xe4\x93\x02\x0e:\x04data\"\x06/login\x12j\n" + + "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/logout\x12r\n" + + "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a&.api.v1.services.auth.RegisterResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x04data\"\t/register\x12\x83\x01\n" + + "\fTokenRefresh\x12).api.v1.services.auth.TokenRefreshRequest\x1a*.api.v1.services.auth.TokenRefreshResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04data\"\x0e/token/refreshB\xb5\x01\n" + + "\x18com.api.v1.services.authB\n" + + "LoginProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( - file_system_login_proto_rawDescOnce sync.Once - file_system_login_proto_rawDescData []byte + file_auth_login_proto_rawDescOnce sync.Once + file_auth_login_proto_rawDescData []byte ) -func file_system_login_proto_rawDescGZIP() []byte { - file_system_login_proto_rawDescOnce.Do(func() { - file_system_login_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_login_proto_rawDesc), len(file_system_login_proto_rawDesc))) +func file_auth_login_proto_rawDescGZIP() []byte { + file_auth_login_proto_rawDescOnce.Do(func() { + file_auth_login_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_login_proto_rawDesc), len(file_auth_login_proto_rawDesc))) }) - return file_system_login_proto_rawDescData -} - -var file_system_login_proto_msgTypes = make([]protoimpl.MessageInfo, 26) -var file_system_login_proto_goTypes = []any{ - (*TokenRefreshRequest)(nil), // 0: api.v1.services.system.TokenRefreshRequest - (*TokenRefreshResponse)(nil), // 1: api.v1.services.system.TokenRefreshResponse - (*LoginRequest)(nil), // 2: api.v1.services.system.LoginRequest - (*LoginResponse)(nil), // 3: api.v1.services.system.LoginResponse - (*CurrentUserRequestQuery)(nil), // 4: api.v1.services.system.CurrentUserRequestQuery - (*CurrentUserRequest)(nil), // 5: api.v1.services.system.CurrentUserRequest - (*CurrentUserResponse)(nil), // 6: api.v1.services.system.CurrentUserResponse - (*CaptchaIdRequest)(nil), // 7: api.v1.services.system.CaptchaIdRequest - (*CaptchaIdResponse)(nil), // 8: api.v1.services.system.CaptchaIdResponse - (*CaptchaImageRequest)(nil), // 9: api.v1.services.system.CaptchaImageRequest - (*CaptchaData)(nil), // 10: api.v1.services.system.CaptchaData - (*CaptchaImageResponse)(nil), // 11: api.v1.services.system.CaptchaImageResponse - (*CaptchaAudioRequest)(nil), // 12: api.v1.services.system.CaptchaAudioRequest - (*CaptchaAudioResponse)(nil), // 13: api.v1.services.system.CaptchaAudioResponse - (*CaptchaRequest)(nil), // 14: api.v1.services.system.CaptchaRequest - (*CaptchaResponse)(nil), // 15: api.v1.services.system.CaptchaResponse - (*RegisterRequest)(nil), // 16: api.v1.services.system.RegisterRequest - (*RegisterResponse)(nil), // 17: api.v1.services.system.RegisterResponse - (*LogoutRequest)(nil), // 18: api.v1.services.system.LogoutRequest - (*LogoutResponse)(nil), // 19: api.v1.services.system.LogoutResponse - (*TokenRefreshRequest_Data)(nil), // 20: api.v1.services.system.TokenRefreshRequest.Data - (*LoginRequest_Data)(nil), // 21: api.v1.services.system.LoginRequest.Data - nil, // 22: api.v1.services.system.CaptchaImageResponse.HeadersEntry - nil, // 23: api.v1.services.system.CaptchaAudioResponse.HeadersEntry - (*RegisterRequest_Data)(nil), // 24: api.v1.services.system.RegisterRequest.Data - (*RegisterResponse_Data)(nil), // 25: api.v1.services.system.RegisterResponse.Data + return file_auth_login_proto_rawDescData +} + +var file_auth_login_proto_msgTypes = make([]protoimpl.MessageInfo, 26) +var file_auth_login_proto_goTypes = []any{ + (*TokenRefreshRequest)(nil), // 0: api.v1.services.auth.TokenRefreshRequest + (*TokenRefreshResponse)(nil), // 1: api.v1.services.auth.TokenRefreshResponse + (*LoginRequest)(nil), // 2: api.v1.services.auth.LoginRequest + (*LoginResponse)(nil), // 3: api.v1.services.auth.LoginResponse + (*CurrentUserRequestQuery)(nil), // 4: api.v1.services.auth.CurrentUserRequestQuery + (*CurrentUserRequest)(nil), // 5: api.v1.services.auth.CurrentUserRequest + (*CurrentUserResponse)(nil), // 6: api.v1.services.auth.CurrentUserResponse + (*CaptchaIdRequest)(nil), // 7: api.v1.services.auth.CaptchaIdRequest + (*CaptchaIdResponse)(nil), // 8: api.v1.services.auth.CaptchaIdResponse + (*CaptchaImageRequest)(nil), // 9: api.v1.services.auth.CaptchaImageRequest + (*CaptchaData)(nil), // 10: api.v1.services.auth.CaptchaData + (*CaptchaImageResponse)(nil), // 11: api.v1.services.auth.CaptchaImageResponse + (*CaptchaAudioRequest)(nil), // 12: api.v1.services.auth.CaptchaAudioRequest + (*CaptchaAudioResponse)(nil), // 13: api.v1.services.auth.CaptchaAudioResponse + (*CaptchaRequest)(nil), // 14: api.v1.services.auth.CaptchaRequest + (*CaptchaResponse)(nil), // 15: api.v1.services.auth.CaptchaResponse + (*RegisterRequest)(nil), // 16: api.v1.services.auth.RegisterRequest + (*RegisterResponse)(nil), // 17: api.v1.services.auth.RegisterResponse + (*LogoutRequest)(nil), // 18: api.v1.services.auth.LogoutRequest + (*LogoutResponse)(nil), // 19: api.v1.services.auth.LogoutResponse + (*TokenRefreshRequest_Data)(nil), // 20: api.v1.services.auth.TokenRefreshRequest.Data + (*LoginRequest_Data)(nil), // 21: api.v1.services.auth.LoginRequest.Data + nil, // 22: api.v1.services.auth.CaptchaImageResponse.HeadersEntry + nil, // 23: api.v1.services.auth.CaptchaAudioResponse.HeadersEntry + (*RegisterRequest_Data)(nil), // 24: api.v1.services.auth.RegisterRequest.Data + (*RegisterResponse_Data)(nil), // 25: api.v1.services.auth.RegisterResponse.Data (*v1.Token)(nil), // 26: security.jwt.v1.Token (*anypb.Any)(nil), // 27: google.protobuf.Any } -var file_system_login_proto_depIdxs = []int32{ - 20, // 0: api.v1.services.system.TokenRefreshRequest.data:type_name -> api.v1.services.system.TokenRefreshRequest.Data - 26, // 1: api.v1.services.system.TokenRefreshResponse.token:type_name -> security.jwt.v1.Token - 21, // 2: api.v1.services.system.LoginRequest.data:type_name -> api.v1.services.system.LoginRequest.Data - 26, // 3: api.v1.services.system.LoginResponse.token:type_name -> security.jwt.v1.Token - 4, // 4: api.v1.services.system.CurrentUserRequest.data:type_name -> api.v1.services.system.CurrentUserRequestQuery - 27, // 5: api.v1.services.system.CurrentUserResponse.data:type_name -> google.protobuf.Any - 27, // 6: api.v1.services.system.CaptchaImageRequest.data:type_name -> google.protobuf.Any - 22, // 7: api.v1.services.system.CaptchaImageResponse.headers:type_name -> api.v1.services.system.CaptchaImageResponse.HeadersEntry - 27, // 8: api.v1.services.system.CaptchaAudioRequest.data:type_name -> google.protobuf.Any - 23, // 9: api.v1.services.system.CaptchaAudioResponse.headers:type_name -> api.v1.services.system.CaptchaAudioResponse.HeadersEntry - 24, // 10: api.v1.services.system.RegisterRequest.data:type_name -> api.v1.services.system.RegisterRequest.Data - 25, // 11: api.v1.services.system.RegisterResponse.data:type_name -> api.v1.services.system.RegisterResponse.Data - 27, // 12: api.v1.services.system.LogoutRequest.data:type_name -> google.protobuf.Any - 14, // 13: api.v1.services.system.LoginService.Captcha:input_type -> api.v1.services.system.CaptchaRequest - 7, // 14: api.v1.services.system.LoginService.CaptchaId:input_type -> api.v1.services.system.CaptchaIdRequest - 9, // 15: api.v1.services.system.LoginService.CaptchaImage:input_type -> api.v1.services.system.CaptchaImageRequest - 12, // 16: api.v1.services.system.LoginService.CaptchaAudio:input_type -> api.v1.services.system.CaptchaAudioRequest - 2, // 17: api.v1.services.system.LoginService.Login:input_type -> api.v1.services.system.LoginRequest - 18, // 18: api.v1.services.system.LoginService.Logout:input_type -> api.v1.services.system.LogoutRequest - 16, // 19: api.v1.services.system.LoginService.Register:input_type -> api.v1.services.system.RegisterRequest - 0, // 20: api.v1.services.system.LoginService.TokenRefresh:input_type -> api.v1.services.system.TokenRefreshRequest - 15, // 21: api.v1.services.system.LoginService.Captcha:output_type -> api.v1.services.system.CaptchaResponse - 8, // 22: api.v1.services.system.LoginService.CaptchaId:output_type -> api.v1.services.system.CaptchaIdResponse - 11, // 23: api.v1.services.system.LoginService.CaptchaImage:output_type -> api.v1.services.system.CaptchaImageResponse - 13, // 24: api.v1.services.system.LoginService.CaptchaAudio:output_type -> api.v1.services.system.CaptchaAudioResponse - 3, // 25: api.v1.services.system.LoginService.Login:output_type -> api.v1.services.system.LoginResponse - 19, // 26: api.v1.services.system.LoginService.Logout:output_type -> api.v1.services.system.LogoutResponse - 17, // 27: api.v1.services.system.LoginService.Register:output_type -> api.v1.services.system.RegisterResponse - 1, // 28: api.v1.services.system.LoginService.TokenRefresh:output_type -> api.v1.services.system.TokenRefreshResponse +var file_auth_login_proto_depIdxs = []int32{ + 20, // 0: api.v1.services.auth.TokenRefreshRequest.data:type_name -> api.v1.services.auth.TokenRefreshRequest.Data + 26, // 1: api.v1.services.auth.TokenRefreshResponse.token:type_name -> security.jwt.v1.Token + 21, // 2: api.v1.services.auth.LoginRequest.data:type_name -> api.v1.services.auth.LoginRequest.Data + 26, // 3: api.v1.services.auth.LoginResponse.token:type_name -> security.jwt.v1.Token + 4, // 4: api.v1.services.auth.CurrentUserRequest.data:type_name -> api.v1.services.auth.CurrentUserRequestQuery + 27, // 5: api.v1.services.auth.CurrentUserResponse.data:type_name -> google.protobuf.Any + 27, // 6: api.v1.services.auth.CaptchaImageRequest.data:type_name -> google.protobuf.Any + 22, // 7: api.v1.services.auth.CaptchaImageResponse.headers:type_name -> api.v1.services.auth.CaptchaImageResponse.HeadersEntry + 27, // 8: api.v1.services.auth.CaptchaAudioRequest.data:type_name -> google.protobuf.Any + 23, // 9: api.v1.services.auth.CaptchaAudioResponse.headers:type_name -> api.v1.services.auth.CaptchaAudioResponse.HeadersEntry + 24, // 10: api.v1.services.auth.RegisterRequest.data:type_name -> api.v1.services.auth.RegisterRequest.Data + 25, // 11: api.v1.services.auth.RegisterResponse.data:type_name -> api.v1.services.auth.RegisterResponse.Data + 27, // 12: api.v1.services.auth.LogoutRequest.data:type_name -> google.protobuf.Any + 14, // 13: api.v1.services.auth.LoginService.Captcha:input_type -> api.v1.services.auth.CaptchaRequest + 7, // 14: api.v1.services.auth.LoginService.CaptchaId:input_type -> api.v1.services.auth.CaptchaIdRequest + 9, // 15: api.v1.services.auth.LoginService.CaptchaImage:input_type -> api.v1.services.auth.CaptchaImageRequest + 12, // 16: api.v1.services.auth.LoginService.CaptchaAudio:input_type -> api.v1.services.auth.CaptchaAudioRequest + 2, // 17: api.v1.services.auth.LoginService.Login:input_type -> api.v1.services.auth.LoginRequest + 18, // 18: api.v1.services.auth.LoginService.Logout:input_type -> api.v1.services.auth.LogoutRequest + 16, // 19: api.v1.services.auth.LoginService.Register:input_type -> api.v1.services.auth.RegisterRequest + 0, // 20: api.v1.services.auth.LoginService.TokenRefresh:input_type -> api.v1.services.auth.TokenRefreshRequest + 15, // 21: api.v1.services.auth.LoginService.Captcha:output_type -> api.v1.services.auth.CaptchaResponse + 8, // 22: api.v1.services.auth.LoginService.CaptchaId:output_type -> api.v1.services.auth.CaptchaIdResponse + 11, // 23: api.v1.services.auth.LoginService.CaptchaImage:output_type -> api.v1.services.auth.CaptchaImageResponse + 13, // 24: api.v1.services.auth.LoginService.CaptchaAudio:output_type -> api.v1.services.auth.CaptchaAudioResponse + 3, // 25: api.v1.services.auth.LoginService.Login:output_type -> api.v1.services.auth.LoginResponse + 19, // 26: api.v1.services.auth.LoginService.Logout:output_type -> api.v1.services.auth.LogoutResponse + 17, // 27: api.v1.services.auth.LoginService.Register:output_type -> api.v1.services.auth.RegisterResponse + 1, // 28: api.v1.services.auth.LoginService.TokenRefresh:output_type -> api.v1.services.auth.TokenRefreshResponse 21, // [21:29] is the sub-list for method output_type 13, // [13:21] is the sub-list for method input_type 13, // [13:13] is the sub-list for extension type_name @@ -1436,26 +1436,26 @@ var file_system_login_proto_depIdxs = []int32{ 0, // [0:13] is the sub-list for field type_name } -func init() { file_system_login_proto_init() } -func file_system_login_proto_init() { - if File_system_login_proto != nil { +func init() { file_auth_login_proto_init() } +func file_auth_login_proto_init() { + if File_auth_login_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_login_proto_rawDesc), len(file_system_login_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_login_proto_rawDesc), len(file_auth_login_proto_rawDesc)), NumEnums: 0, NumMessages: 26, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_system_login_proto_goTypes, - DependencyIndexes: file_system_login_proto_depIdxs, - MessageInfos: file_system_login_proto_msgTypes, + GoTypes: file_auth_login_proto_goTypes, + DependencyIndexes: file_auth_login_proto_depIdxs, + MessageInfos: file_auth_login_proto_msgTypes, }.Build() - File_system_login_proto = out.File - file_system_login_proto_goTypes = nil - file_system_login_proto_depIdxs = nil + File_auth_login_proto = out.File + file_auth_login_proto_goTypes = nil + file_auth_login_proto_depIdxs = nil } diff --git a/api/v1/services/system/login.pb.gw.go b/api/v1/services/auth/login.pb.gw.go similarity index 94% rename from api/v1/services/system/login.pb.gw.go rename to api/v1/services/auth/login.pb.gw.go index 5a8e1420..6c520321 100644 --- a/api/v1/services/system/login.pb.gw.go +++ b/api/v1/services/auth/login.pb.gw.go @@ -1,12 +1,12 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/login.proto +// source: auth/login.proto /* -Package system is a reverse proxy. +Package auth is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ -package system +package auth import ( "context" @@ -275,7 +275,7 @@ func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.LoginService/Captcha", runtime.WithHTTPPathPattern("/captcha")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Captcha", runtime.WithHTTPPathPattern("/captcha")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -295,7 +295,7 @@ func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.LoginService/CaptchaId", runtime.WithHTTPPathPattern("/captcha/id")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaId", runtime.WithHTTPPathPattern("/captcha/id")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -315,7 +315,7 @@ func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.LoginService/CaptchaImage", runtime.WithHTTPPathPattern("/captcha/image")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaImage", runtime.WithHTTPPathPattern("/captcha/image")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -335,7 +335,7 @@ func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.LoginService/CaptchaAudio", runtime.WithHTTPPathPattern("/captcha/audio")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaAudio", runtime.WithHTTPPathPattern("/captcha/audio")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -355,7 +355,7 @@ func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.LoginService/Login", runtime.WithHTTPPathPattern("/login")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Login", runtime.WithHTTPPathPattern("/login")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -375,7 +375,7 @@ func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.LoginService/Logout", runtime.WithHTTPPathPattern("/logout")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Logout", runtime.WithHTTPPathPattern("/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -395,7 +395,7 @@ func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.LoginService/Register", runtime.WithHTTPPathPattern("/register")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Register", runtime.WithHTTPPathPattern("/register")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -415,7 +415,7 @@ func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMu var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.LoginService/TokenRefresh", runtime.WithHTTPPathPattern("/token/refresh")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/TokenRefresh", runtime.WithHTTPPathPattern("/token/refresh")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -473,7 +473,7 @@ func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.LoginService/Captcha", runtime.WithHTTPPathPattern("/captcha")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Captcha", runtime.WithHTTPPathPattern("/captcha")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -490,7 +490,7 @@ func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.LoginService/CaptchaId", runtime.WithHTTPPathPattern("/captcha/id")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaId", runtime.WithHTTPPathPattern("/captcha/id")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -507,7 +507,7 @@ func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.LoginService/CaptchaImage", runtime.WithHTTPPathPattern("/captcha/image")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaImage", runtime.WithHTTPPathPattern("/captcha/image")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -524,7 +524,7 @@ func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.LoginService/CaptchaAudio", runtime.WithHTTPPathPattern("/captcha/audio")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaAudio", runtime.WithHTTPPathPattern("/captcha/audio")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -541,7 +541,7 @@ func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.LoginService/Login", runtime.WithHTTPPathPattern("/login")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Login", runtime.WithHTTPPathPattern("/login")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -558,7 +558,7 @@ func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.LoginService/Logout", runtime.WithHTTPPathPattern("/logout")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Logout", runtime.WithHTTPPathPattern("/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -575,7 +575,7 @@ func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.LoginService/Register", runtime.WithHTTPPathPattern("/register")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Register", runtime.WithHTTPPathPattern("/register")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -592,7 +592,7 @@ func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMu ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.LoginService/TokenRefresh", runtime.WithHTTPPathPattern("/token/refresh")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/TokenRefresh", runtime.WithHTTPPathPattern("/token/refresh")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return diff --git a/api/v1/services/system/login.pb.validate.go b/api/v1/services/auth/login.pb.validate.go similarity index 99% rename from api/v1/services/system/login.pb.validate.go rename to api/v1/services/auth/login.pb.validate.go index 1352f700..45969891 100644 --- a/api/v1/services/system/login.pb.validate.go +++ b/api/v1/services/auth/login.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/login.proto +// source: auth/login.proto -package system +package auth import ( "bytes" diff --git a/api/v1/services/system/login_bridge.pb.go b/api/v1/services/auth/login_bridge.pb.go similarity index 96% rename from api/v1/services/system/login_bridge.pb.go rename to api/v1/services/auth/login_bridge.pb.go index 0afe3245..bcdbae69 100644 --- a/api/v1/services/system/login_bridge.pb.go +++ b/api/v1/services/auth/login_bridge.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-bridge unknown // - protoc (unknown) -// source: system/login.proto +// source: auth/login.proto -package system +package auth import ( context "context" @@ -19,14 +19,14 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 -const LoginServiceCaptchaBridgeOperation = "/api.v1.services.system.LoginService/Captcha" -const LoginServiceCaptchaAudioBridgeOperation = "/api.v1.services.system.LoginService/CaptchaAudio" -const LoginServiceCaptchaIdBridgeOperation = "/api.v1.services.system.LoginService/CaptchaId" -const LoginServiceCaptchaImageBridgeOperation = "/api.v1.services.system.LoginService/CaptchaImage" -const LoginServiceLoginBridgeOperation = "/api.v1.services.system.LoginService/Login" -const LoginServiceLogoutBridgeOperation = "/api.v1.services.system.LoginService/Logout" -const LoginServiceRegisterBridgeOperation = "/api.v1.services.system.LoginService/Register" -const LoginServiceTokenRefreshBridgeOperation = "/api.v1.services.system.LoginService/TokenRefresh" +const LoginServiceCaptchaBridgeOperation = "/api.v1.services.auth.LoginService/Captcha" +const LoginServiceCaptchaAudioBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaAudio" +const LoginServiceCaptchaIdBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaId" +const LoginServiceCaptchaImageBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaImage" +const LoginServiceLoginBridgeOperation = "/api.v1.services.auth.LoginService/Login" +const LoginServiceLogoutBridgeOperation = "/api.v1.services.auth.LoginService/Logout" +const LoginServiceRegisterBridgeOperation = "/api.v1.services.auth.LoginService/Register" +const LoginServiceTokenRefreshBridgeOperation = "/api.v1.services.auth.LoginService/TokenRefresh" type LoginServiceBridger interface { Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) diff --git a/api/v1/services/system/login_grpc.pb.go b/api/v1/services/auth/login_grpc.pb.go similarity index 94% rename from api/v1/services/system/login_grpc.pb.go rename to api/v1/services/auth/login_grpc.pb.go index ea59f169..dbb951a2 100644 --- a/api/v1/services/system/login_grpc.pb.go +++ b/api/v1/services/auth/login_grpc.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) -// source: system/login.proto +// source: auth/login.proto -package system +package auth import ( context "context" @@ -19,14 +19,14 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - LoginService_Captcha_FullMethodName = "/api.v1.services.system.LoginService/Captcha" - LoginService_CaptchaId_FullMethodName = "/api.v1.services.system.LoginService/CaptchaId" - LoginService_CaptchaImage_FullMethodName = "/api.v1.services.system.LoginService/CaptchaImage" - LoginService_CaptchaAudio_FullMethodName = "/api.v1.services.system.LoginService/CaptchaAudio" - LoginService_Login_FullMethodName = "/api.v1.services.system.LoginService/Login" - LoginService_Logout_FullMethodName = "/api.v1.services.system.LoginService/Logout" - LoginService_Register_FullMethodName = "/api.v1.services.system.LoginService/Register" - LoginService_TokenRefresh_FullMethodName = "/api.v1.services.system.LoginService/TokenRefresh" + LoginService_Captcha_FullMethodName = "/api.v1.services.auth.LoginService/Captcha" + LoginService_CaptchaId_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaId" + LoginService_CaptchaImage_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaImage" + LoginService_CaptchaAudio_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaAudio" + LoginService_Login_FullMethodName = "/api.v1.services.auth.LoginService/Login" + LoginService_Logout_FullMethodName = "/api.v1.services.auth.LoginService/Logout" + LoginService_Register_FullMethodName = "/api.v1.services.auth.LoginService/Register" + LoginService_TokenRefresh_FullMethodName = "/api.v1.services.auth.LoginService/TokenRefresh" ) // LoginServiceClient is the client API for LoginService service. @@ -350,7 +350,7 @@ func _LoginService_TokenRefresh_Handler(srv interface{}, ctx context.Context, de // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var LoginService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.LoginService", + ServiceName: "api.v1.services.auth.LoginService", HandlerType: (*LoginServiceServer)(nil), Methods: []grpc.MethodDesc{ { @@ -387,5 +387,5 @@ var LoginService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "system/login.proto", + Metadata: "auth/login.proto", } diff --git a/api/v1/services/system/login_http.pb.go b/api/v1/services/auth/login_http.pb.go similarity index 93% rename from api/v1/services/system/login_http.pb.go rename to api/v1/services/auth/login_http.pb.go index 17da8f95..b5de8ab2 100644 --- a/api/v1/services/system/login_http.pb.go +++ b/api/v1/services/auth/login_http.pb.go @@ -2,9 +2,9 @@ // versions: // - protoc-gen-go-http v2.8.4 // - protoc (unknown) -// source: system/login.proto +// source: auth/login.proto -package system +package auth import ( context "context" @@ -19,14 +19,14 @@ var _ = binding.EncodeURL const _ = http.SupportPackageIsVersion1 -const OperationLoginServiceCaptcha = "/api.v1.services.system.LoginService/Captcha" -const OperationLoginServiceCaptchaAudio = "/api.v1.services.system.LoginService/CaptchaAudio" -const OperationLoginServiceCaptchaId = "/api.v1.services.system.LoginService/CaptchaId" -const OperationLoginServiceCaptchaImage = "/api.v1.services.system.LoginService/CaptchaImage" -const OperationLoginServiceLogin = "/api.v1.services.system.LoginService/Login" -const OperationLoginServiceLogout = "/api.v1.services.system.LoginService/Logout" -const OperationLoginServiceRegister = "/api.v1.services.system.LoginService/Register" -const OperationLoginServiceTokenRefresh = "/api.v1.services.system.LoginService/TokenRefresh" +const OperationLoginServiceCaptcha = "/api.v1.services.auth.LoginService/Captcha" +const OperationLoginServiceCaptchaAudio = "/api.v1.services.auth.LoginService/CaptchaAudio" +const OperationLoginServiceCaptchaId = "/api.v1.services.auth.LoginService/CaptchaId" +const OperationLoginServiceCaptchaImage = "/api.v1.services.auth.LoginService/CaptchaImage" +const OperationLoginServiceLogin = "/api.v1.services.auth.LoginService/Login" +const OperationLoginServiceLogout = "/api.v1.services.auth.LoginService/Logout" +const OperationLoginServiceRegister = "/api.v1.services.auth.LoginService/Register" +const OperationLoginServiceTokenRefresh = "/api.v1.services.auth.LoginService/TokenRefresh" type LoginServiceHTTPServer interface { Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) diff --git a/contrib/security/authz/casbin/option.go b/contrib/security/authz/casbin/option.go index 10a93363..aa8d9c0f 100644 --- a/contrib/security/authz/casbin/option.go +++ b/contrib/security/authz/casbin/option.go @@ -11,7 +11,7 @@ import ( casbinmodel "github.com/casbin/casbin/v2/model" "github.com/casbin/casbin/v2/persist" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/contrib/security/authz/casbin/internal/model" ) diff --git a/contrib/security/authz/casbin/update.go b/contrib/security/authz/casbin/update.go index d2bb3c8a..be6d4ec2 100644 --- a/contrib/security/authz/casbin/update.go +++ b/contrib/security/authz/casbin/update.go @@ -15,11 +15,11 @@ import ( "github.com/casbin/casbin/v2" "github.com/casbin/casbin/v2/persist" "github.com/goexts/generic/maps" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/runtime/log" "google.golang.org/grpc/status" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" ) type PolicyUpdater struct { diff --git a/internal/mods/auth/biz/auth.biz.go b/internal/mods/auth/biz/auth.biz.go index 9c86efe9..3004a1ec 100644 --- a/internal/mods/auth/biz/auth.biz.go +++ b/internal/mods/auth/biz/auth.biz.go @@ -2,7 +2,7 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package biz is a biz layer for the system module of OrigAdmin. +// Package biz is a biz layer for the auth module of OrigAdmin. package biz import ( @@ -11,8 +11,8 @@ import ( "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/mods/auth/dto" ) // AuthServiceBiz is a Auth use case. diff --git a/internal/mods/auth/biz/biz.go b/internal/mods/auth/biz/biz.go index 617e105d..c92144e1 100644 --- a/internal/mods/auth/biz/biz.go +++ b/internal/mods/auth/biz/biz.go @@ -5,13 +5,8 @@ package biz import ( - "net/http" - "github.com/google/wire" "github.com/origadmin/runtime/interfaces/pagination" - "github.com/origadmin/toolkits/errors/httperr" - - pb "origadmin/application/admin/api/v1/services/system" ) // ProviderSet is biz providers. @@ -21,11 +16,6 @@ var ProviderSet = wire.NewSet( NewCasbinSourceServiceBiz, ) -var ( - // ErrUserNotFound is user not found. - ErrUserNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") -) - var ( defaultLimiter = pagination.DefaultLimiter() ) diff --git a/internal/mods/auth/biz/casbin.biz.go b/internal/mods/auth/biz/casbin.biz.go index 828973d6..99ac3760 100644 --- a/internal/mods/auth/biz/casbin.biz.go +++ b/internal/mods/auth/biz/casbin.biz.go @@ -2,7 +2,7 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package biz is a biz layer for the system module of OrigAdmin. +// Package biz is a biz layer for the auth module of OrigAdmin. package biz import ( @@ -10,12 +10,12 @@ import ( "sync/atomic" "time" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" "google.golang.org/grpc" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/mods/auth/dto" ) // CasbinSourceServiceBiz is a CasbinSource use case. diff --git a/internal/mods/auth/biz/login.biz.go b/internal/mods/auth/biz/login.biz.go index d39bf20f..c619949b 100644 --- a/internal/mods/auth/biz/login.biz.go +++ b/internal/mods/auth/biz/login.biz.go @@ -2,17 +2,17 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package biz is a biz layer for the system module of OrigAdmin. +// Package biz is a biz layer for the auth module of OrigAdmin. package biz import ( "context" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/mods/auth/dto" ) // LoginServiceBiz is a Login use case. diff --git a/internal/mods/auth/dal/auth.dal.go b/internal/mods/auth/dal/auth.dal.go index 2bf596d3..6f039228 100644 --- a/internal/mods/auth/dal/auth.dal.go +++ b/internal/mods/auth/dal/auth.dal.go @@ -12,11 +12,11 @@ import ( "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" _ "origadmin/application/admin/internal/data/entity/ent/runtime" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/mods/auth/dto" ) type authRepo struct { diff --git a/internal/mods/auth/dal/casbin.dal.go b/internal/mods/auth/dal/casbin.dal.go index c72c18d0..c663ea09 100644 --- a/internal/mods/auth/dal/casbin.dal.go +++ b/internal/mods/auth/dal/casbin.dal.go @@ -9,10 +9,10 @@ import ( "context" "strconv" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/mods/auth/dto" ) type CasbinSourceConfig struct { diff --git a/internal/mods/auth/dal/dal.go b/internal/mods/auth/dal/dal.go index 25bfd1bf..f98c6fb2 100644 --- a/internal/mods/auth/dal/dal.go +++ b/internal/mods/auth/dal/dal.go @@ -26,7 +26,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/department" "origadmin/application/admin/internal/data/entity/ent/predicate" "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/mods/auth/dto" ) const ( diff --git a/internal/mods/auth/dal/login.dal.go b/internal/mods/auth/dal/login.dal.go index fed05357..a7fb0209 100644 --- a/internal/mods/auth/dal/login.dal.go +++ b/internal/mods/auth/dal/login.dal.go @@ -22,12 +22,12 @@ import ( "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/helpers/captcha" "origadmin/application/admin/helpers/resp" "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/mods/system/dto" - systemdto "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/mods/auth/dto" + authdto "origadmin/application/admin/internal/mods/auth/dto" ) type loginRepo struct { @@ -57,7 +57,7 @@ func (repo loginRepo) Register(ctx context.Context, in *dto.RegisterRequest) (*d return &dto.RegisterResponse{ Success: true, - Data: &system.RegisterResponse_Data{ + Data: &auth.RegisterResponse_Data{ Redirect: "", }, }, nil @@ -103,7 +103,7 @@ func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.Log case userData == nil: log.Warnf("User not found with username %s", data.Username) return nil, dto.ErrInvalidUsername - case userData.Status != systemdto.UserStatusActive: + case userData.Status != authdto.UserStatusActive: log.Warnf("User %s is not activated", data.Username) return nil, httperr.New("unknown", 400, "User status is not activated, please contact the administrator") default: diff --git a/internal/mods/auth/dal/user.dal.go b/internal/mods/auth/dal/user.dal.go index 4f9c1ba9..46c17d08 100644 --- a/internal/mods/auth/dal/user.dal.go +++ b/internal/mods/auth/dal/user.dal.go @@ -13,12 +13,12 @@ import ( "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/helpers/db" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/mods/auth/dto" ) type userRepo struct { diff --git a/internal/mods/system/dto/auth.go b/internal/mods/auth/dto/auth.go similarity index 92% rename from internal/mods/system/dto/auth.go rename to internal/mods/auth/dto/auth.go index 81dc7026..8a28c04e 100644 --- a/internal/mods/system/dto/auth.go +++ b/internal/mods/auth/dto/auth.go @@ -2,7 +2,7 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package dto is the data transfer object package for the system module. +// Package dto is the data transfer object package for the auth module. package dto import ( @@ -10,7 +10,7 @@ import ( "github.com/origadmin/runtime/interfaces/pagination" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" ) type ( diff --git a/internal/mods/system/dto/casbin.go b/internal/mods/auth/dto/casbin.go similarity index 93% rename from internal/mods/system/dto/casbin.go rename to internal/mods/auth/dto/casbin.go index 37b39e42..16be5b21 100644 --- a/internal/mods/system/dto/casbin.go +++ b/internal/mods/auth/dto/casbin.go @@ -8,7 +8,7 @@ package dto import ( "context" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" ) type ( diff --git a/internal/mods/auth/dto/dto.go b/internal/mods/auth/dto/dto.go new file mode 100644 index 00000000..86a43531 --- /dev/null +++ b/internal/mods/auth/dto/dto.go @@ -0,0 +1,1020 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto is the data transfer object package for the auth module. +package dto + +import ( + "net/http" + + "github.com/origadmin/toolkits/errors/httperr" + "google.golang.org/protobuf/types/known/timestamppb" + + pb "origadmin/application/admin/api/v1/services/auth" + typespb "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/schema/types" + "origadmin/application/admin/internal/data/entity/ent/user" +) + +var ( + // ErrUserNotFound is user not found. + ErrUserNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") + ErrInvalidCaptchaID = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") + ErrInvalidPassword = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") + ErrInvalidUsername = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") + ErrCaptchaIDNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") +) + +const ( + UserStatusActive = types.Active + UserStatusFrozen = types.Frozen +) + +const ( + ResourceStatusEnabled = types.Enabled + ResourceStatusDisabled = types.Disabled +) + +type ( + // User 用户类型 + // @Convert( + // target = "UserPB", + // direction = "both", + // ignoreFields = ["password", "salt"] + // ) + User = ent.User + // UserPB + // @Convert( + // target="User", + // direction="both" + // ) + UserPB = typespb.User +) + +// ConvertUser2PB user.table.comment +func ConvertUser2PB(goModel *User) (pbModel *UserPB) { + pbModel = &UserPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.CreateAuthor = int64(goModel.CreateAuthor) + pbModel.UpdateAuthor = int64(goModel.UpdateAuthor) + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Uuid = goModel.UUID + pbModel.AllowedIp = goModel.AllowedIP + pbModel.Username = goModel.Username + pbModel.Nickname = goModel.Nickname + pbModel.Avatar = goModel.Avatar + pbModel.Name = goModel.Name + pbModel.Gender = ConvertGender2PB(goModel.Gender) + //pbModel.Password = goModel.EncryptedPassword + //pbModel.Salt = goModel.Salt + pbModel.Phone = goModel.Phone + pbModel.Email = goModel.Email + pbModel.Remark = goModel.Remark + pbModel.Token = goModel.Token + pbModel.Status = int32(goModel.Status) + pbModel.LastLoginIp = goModel.LastLoginIP + pbModel.LastLoginTime = timestamppb.New(goModel.LastLoginTime) + pbModel.SanctionDate = timestamppb.New(goModel.SanctionDate) + pbModel.ManagerId = int64(goModel.ManagerID) + pbModel.Manager = goModel.Manager + //pbModel.Roles = ConvertRoles(goModel.Edges.Roles) + for _, role := range goModel.Edges.Roles { + pbModel.RoleIds = append(pbModel.RoleIds, role.ID) + } + pbModel.Roles = ConvertRoles(goModel.Edges.Roles) + return pbModel +} + +func ConvertGender2PB(gender user.Gender) string { + return gender.String() +} + +// ConvertUserPB2Object user.table.comment +func ConvertUserPB2Object(pbModel *UserPB) (goModel *User) { + goModel = &User{} + if pbModel == nil { + return goModel + } + + goModel.ID = int64(pbModel.Id) + goModel.CreateAuthor = int64(pbModel.CreateAuthor) + goModel.UpdateAuthor = int64(pbModel.UpdateAuthor) + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.UUID = pbModel.Uuid + goModel.AllowedIP = pbModel.AllowedIp + goModel.Username = pbModel.Username + goModel.Nickname = pbModel.Nickname + goModel.Avatar = pbModel.Avatar + goModel.Name = pbModel.Name + goModel.Gender = user.Gender(pbModel.Gender) + //goModel.Password = pbModel.Password + //goModel.Salt = pbModel.Salt + goModel.Phone = pbModel.Phone + goModel.Email = pbModel.Email + goModel.Remark = pbModel.Remark + goModel.Token = pbModel.Token + goModel.Status = int8(pbModel.Status) + goModel.LastLoginIP = pbModel.LastLoginIp + goModel.LastLoginTime = pbModel.LastLoginTime.AsTime() + goModel.SanctionDate = pbModel.SanctionDate.AsTime() + goModel.ManagerID = pbModel.ManagerId + goModel.Manager = pbModel.Manager + return goModel +} + +type ( + Resource = ent.Resource + ResourcePB = typespb.Resource +) + +func ConvertResource2PB(goModel *Resource) (pbModel *ResourcePB) { + pbModel = &ResourcePB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = goModel.ID + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Name = goModel.Name + pbModel.Keyword = goModel.Keyword + pbModel.I18NKey = goModel.I18nKey + pbModel.Type = goModel.Type + pbModel.Status = int32(goModel.Status) + pbModel.Path = goModel.Path + pbModel.Operation = goModel.Operation + pbModel.Method = goModel.Method + pbModel.Component = goModel.Component + pbModel.Icon = goModel.Icon + pbModel.Sequence = int32(goModel.Sequence) + pbModel.Visible = goModel.Visible + pbModel.TreePath = goModel.TreePath + pbModel.Properties = goModel.Properties + pbModel.Description = goModel.Description + pbModel.ParentId = int64(goModel.ParentID) + return pbModel +} + +func ConvertResourcePB2Object(pbModel *ResourcePB) (goModel *Resource) { + goModel = &Resource{} + if pbModel == nil { + return goModel + } + + goModel.ID = pbModel.Id + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.Name = pbModel.Name + goModel.Keyword = pbModel.Keyword + goModel.I18nKey = pbModel.I18NKey + goModel.Type = pbModel.Type + goModel.Status = int8(pbModel.Status) + goModel.Path = pbModel.Path + goModel.Operation = pbModel.Operation + goModel.Method = pbModel.Method + goModel.Component = pbModel.Component + goModel.Icon = pbModel.Icon + goModel.Sequence = int(pbModel.Sequence) + goModel.Visible = pbModel.Visible + goModel.TreePath = pbModel.TreePath + goModel.Properties = pbModel.Properties + goModel.Description = pbModel.Description + goModel.ParentID = pbModel.ParentId + return goModel +} + +type ( + Role = ent.Role + RolePB = typespb.Role +) + +// ConvertRole2PB role.table.comment +func ConvertRole2PB(goModel *Role) (pbModel *RolePB) { + pbModel = &RolePB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = goModel.ID + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Keyword = goModel.Keyword + pbModel.Name = goModel.Name + pbModel.Description = goModel.Description + pbModel.Type = int32(goModel.Type) + pbModel.Sequence = int32(goModel.Sequence) + pbModel.Status = int32(goModel.Status) + for _, permission := range goModel.Edges.Permissions { + pbModel.PermissionIds = append(pbModel.PermissionIds, int64(permission.ID)) + } + pbModel.Permissions = ConvertPermissions(goModel.Edges.Permissions) + //pbModel.IsSystem = goModel.IsSystem + return pbModel +} + +// ConvertRolePB2Object role.table.comment +func ConvertRolePB2Object(pbModel *RolePB) (goModel *Role) { + goModel = &Role{} + if pbModel == nil { + return goModel + } + + goModel.ID = pbModel.Id + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.Keyword = pbModel.Keyword + goModel.Name = pbModel.Name + goModel.Description = pbModel.Description + goModel.Type = int8(pbModel.Type) + goModel.Sequence = int(pbModel.Sequence) + goModel.Status = int8(pbModel.Status) + + //goModel.IsSystem = pbModel.IsSystem + return goModel +} + +type ( + Department = ent.Department + DepartmentPB = typespb.Department +) + +// ConvertDepartment2PB department.table.comment +func ConvertDepartment2PB(goModel *Department) (pbModel *DepartmentPB) { + pbModel = &DepartmentPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = goModel.ID + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Keyword = goModel.Keyword + pbModel.Name = goModel.Name + pbModel.Description = goModel.Description + pbModel.Sequence = int32(goModel.Sequence) + pbModel.Status = int32(goModel.Status) + pbModel.Level = int32(goModel.Level) + pbModel.ParentId = goModel.ParentID + return pbModel +} + +// ConvertDepartmentPB2Object department.table.comment +func ConvertDepartmentPB2Object(pbModel *DepartmentPB) (goModel *Department) { + goModel = &Department{} + if pbModel == nil { + return goModel + } + + goModel.ID = pbModel.Id + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.Keyword = pbModel.Keyword + goModel.Name = pbModel.Name + goModel.TreePath = pbModel.TreePath + goModel.Description = pbModel.Description + goModel.Sequence = int(pbModel.Sequence) + goModel.Status = int8(pbModel.Status) + goModel.Level = int(pbModel.Level) + goModel.ParentID = pbModel.ParentId + return goModel +} + +type ( + Departments = []*ent.Department + DepartmentsPB = []*typespb.Department +) + +// ConvertDepartments2PB Children holds the value of the children edge. +func ConvertDepartments2PB(gosModel Departments) (pbsModel DepartmentsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertDepartment2PB(model)) + } + return pbsModel +} + +// ConvertDepartmentsPB2Object Children holds the value of the children edge. +func ConvertDepartmentsPB2Object(pbsModel DepartmentsPB) (gosModel Departments) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertDepartmentPB2Object(model)) + } + return gosModel +} + +type ( + UserDepartments = []*ent.UserDepartment + UserDepartmentsPB = []*typespb.UserDepartment +) + +// ConvertUserDepartments2PB UserDepartments holds the value of the user_departments edge. +func ConvertUserDepartments2PB(gosModel UserDepartments) (pbsModel UserDepartmentsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertUserDepartment2PB(model)) + } + return pbsModel +} + +// ConvertUserDepartmentsPB2Object UserDepartments holds the value of the user_departments edge. +func ConvertUserDepartmentsPB2Object(pbsModel UserDepartmentsPB) (gosModel UserDepartments) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertUserDepartmentPB2Object(model)) + } + return gosModel +} + +type ( + DepartmentEdges = ent.DepartmentEdges + DepartmentEdgesPB = typespb.DepartmentEdges +) + +// ConvertDepartmentEdges2PB DepartmentEdges holds the relations/edges for other nodes in the graph. +func ConvertDepartmentEdges2PB(goModel *DepartmentEdges) (pbModel *DepartmentEdgesPB) { + pbModel = &DepartmentEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Users = ConvertUsers2PB(goModel.Users) + pbModel.Positions = ConvertPositions2PB(goModel.Positions) + pbModel.Children = ConvertDepartments2PB(goModel.Children) + pbModel.Parent = ConvertDepartment2PB(goModel.Parent) + pbModel.UserDepartments = ConvertUserDepartments2PB(goModel.UserDepartments) + return pbModel +} + +// ConvertDepartmentEdgesPB2Object DepartmentEdges holds the relations/edges for other nodes in the graph. +func ConvertDepartmentEdgesPB2Object(pbModel *DepartmentEdgesPB) (goModel *DepartmentEdges) { + goModel = &DepartmentEdges{} + if pbModel == nil { + return goModel + } + + goModel.Users = ConvertUsersPB2Object(pbModel.Users) + goModel.Positions = ConvertPositionsPB2Object(pbModel.Positions) + goModel.Children = ConvertDepartmentsPB2Object(pbModel.Children) + goModel.Parent = ConvertDepartmentPB2Object(pbModel.Parent) + goModel.UserDepartments = ConvertUserDepartmentsPB2Object(pbModel.UserDepartments) + return goModel +} + +type ( + UserDepartment = ent.UserDepartment + UserDepartmentPB = typespb.UserDepartment +) + +// ConvertUserDepartment2PB user_department.table.comment +func ConvertUserDepartment2PB(goModel *UserDepartment) (pbModel *UserDepartmentPB) { + pbModel = &UserDepartmentPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.UserId = int64(goModel.UserID) + pbModel.DepartmentId = int64(goModel.DepartmentID) + return pbModel +} + +// ConvertUserDepartmentPB2Object user_department.table.comment +func ConvertUserDepartmentPB2Object(pbModel *UserDepartmentPB) (goModel *UserDepartment) { + goModel = &UserDepartment{} + if pbModel == nil { + return goModel + } + + //goModel.ID = int64(pbModel.Id) + goModel.UserID = int64(pbModel.UserId) + goModel.DepartmentID = int64(pbModel.DepartmentId) + return goModel +} + +type ( + UserDepartmentEdges = ent.UserDepartmentEdges + UserDepartmentEdgesPB = typespb.UserDepartmentEdges +) + +// ConvertUserDepartmentEdges2PB UserDepartmentEdges holds the relations/edges for other nodes in the graph. +func ConvertUserDepartmentEdges2PB(goModel *UserDepartmentEdges) (pbModel *UserDepartmentEdgesPB) { + pbModel = &UserDepartmentEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.User = ConvertUser2PB(goModel.User) + pbModel.Department = ConvertDepartment2PB(goModel.Department) + return pbModel +} + +// ConvertUserDepartmentEdgesPB2Object UserDepartmentEdges holds the relations/edges for other nodes in the graph. +func ConvertUserDepartmentEdgesPB2Object(pbModel *UserDepartmentEdgesPB) (goModel *UserDepartmentEdges) { + goModel = &UserDepartmentEdges{} + if pbModel == nil { + return goModel + } + + goModel.User = ConvertUserPB2Object(pbModel.User) + goModel.Department = ConvertDepartmentPB2Object(pbModel.Department) + return goModel +} + +type ( + Position = ent.Position + PositionPB = typespb.Position +) + +// ConvertPosition2PB position.table.comment +func ConvertPosition2PB(goModel *Position) (pbModel *PositionPB) { + pbModel = &PositionPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Name = goModel.Name + pbModel.Description = goModel.Description + pbModel.DepartmentId = int64(goModel.DepartmentID) + return pbModel +} + +// ConvertPositionPB2Object position.table.comment +func ConvertPositionPB2Object(pbModel *PositionPB) (goModel *Position) { + goModel = &Position{} + if pbModel == nil { + return goModel + } + + goModel.ID = int64(pbModel.Id) + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.Name = pbModel.Name + goModel.Description = pbModel.Description + goModel.DepartmentID = int64(pbModel.DepartmentId) + return goModel +} + +type ( + Users = []*ent.User + UsersPB = []*typespb.User +) + +// ConvertUsers2PB Users holds the value of the users edge. +func ConvertUsers2PB(gosModel Users) (pbsModel UsersPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertUser2PB(model)) + } + return pbsModel +} + +// ConvertUsersPB2Object Users holds the value of the users edge. +func ConvertUsersPB2Object(pbsModel UsersPB) (gosModel Users) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertUserPB2Object(model)) + } + return gosModel +} + +type ( + Permissions = []*ent.Permission + PermissionsPB = []*typespb.Permission +) + +// ConvertPermissions2PB Permissions holds the value of the permissions edge. +func ConvertPermissions2PB(gosModel Permissions) (pbsModel PermissionsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertPermission2PB(model)) + } + return pbsModel +} + +// ConvertPermissionsPB2Object Permissions holds the value of the permissions edge. +func ConvertPermissionsPB2Object(pbsModel PermissionsPB) (gosModel Permissions) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertPermissionPB2Object(model)) + } + return gosModel +} + +type ( + UserPositions = []*ent.UserPosition + UserPositionsPB = []*typespb.UserPosition +) + +// ConvertUserPositions2PB UserPositions holds the value of the user_positions edge. +func ConvertUserPositions2PB(gosModel UserPositions) (pbsModel UserPositionsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertUserPosition2PB(model)) + } + return pbsModel +} + +// ConvertUserPositionsPB2Object UserPositions holds the value of the user_positions edge. +func ConvertUserPositionsPB2Object(pbsModel UserPositionsPB) (gosModel UserPositions) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertUserPositionPB2Object(model)) + } + return gosModel +} + +type ( + PositionEdges = ent.PositionEdges + PositionEdgesPB = typespb.PositionEdges +) + +// ConvertPositionEdges2PB PositionEdges holds the relations/edges for other nodes in the graph. +func ConvertPositionEdges2PB(goModel *PositionEdges) (pbModel *PositionEdgesPB) { + pbModel = &PositionEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Department = ConvertDepartment2PB(goModel.Department) + pbModel.Users = ConvertUsers2PB(goModel.Users) + pbModel.Permissions = ConvertPermissions2PB(goModel.Permissions) + pbModel.UserPositions = ConvertUserPositions2PB(goModel.UserPositions) + pbModel.PositionPermissions = ConvertPositionPermissions2PB(goModel.PositionPermissions) + return pbModel +} + +// ConvertPositionEdgesPB2Object PositionEdges holds the relations/edges for other nodes in the graph. +func ConvertPositionEdgesPB2Object(pbModel *PositionEdgesPB) (goModel *PositionEdges) { + goModel = &PositionEdges{} + if pbModel == nil { + return goModel + } + + goModel.Department = ConvertDepartmentPB2Object(pbModel.Department) + goModel.Users = ConvertUsersPB2Object(pbModel.Users) + goModel.Permissions = ConvertPermissionsPB2Object(pbModel.Permissions) + goModel.UserPositions = ConvertUserPositionsPB2Object(pbModel.UserPositions) + goModel.PositionPermissions = ConvertPositionPermissionsPB2Object(pbModel.PositionPermissions) + return goModel +} + +// ConvertDataRules2PB permission.field.data_rules +func ConvertDataRules2PB(gosModel map[string]string) map[string]string { + return gosModel +} + +// ConvertDataRulesPB2Object permission.field.data_rules +func ConvertDataRulesPB2Object(pbsModel map[string]string) map[string]string { + return pbsModel +} + +type ( + Permission = ent.Permission + PermissionPB = typespb.Permission +) + +// ConvertPermission2PB permission.table.comment +func ConvertPermission2PB(goModel *Permission) (pbModel *PermissionPB) { + pbModel = &PermissionPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Name = goModel.Name + pbModel.Keyword = goModel.Keyword + pbModel.Description = goModel.Description + pbModel.DataScope = goModel.DataScope + pbModel.DataRules = ConvertDataRules2PB(goModel.DataRules) + for _, resource := range goModel.Edges.Resources { + pbModel.ResourceIds = append(pbModel.ResourceIds, resource.ID) + } + pbModel.Resources = ConvertResources2PB(goModel.Edges.Resources) + return pbModel +} + +// ConvertPermissionPB2Object permission.table.comment +func ConvertPermissionPB2Object(pbModel *PermissionPB) (goModel *Permission) { + goModel = &Permission{} + if pbModel == nil { + return goModel + } + + goModel.ID = int64(pbModel.Id) + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.Name = pbModel.Name + goModel.Keyword = pbModel.Keyword + goModel.Description = pbModel.Description + goModel.DataScope = pbModel.DataScope + goModel.DataRules = ConvertDataRulesPB2Object(pbModel.DataRules) + return goModel +} + +type ( + Roles = []*ent.Role + RolesPB = []*typespb.Role +) + +// ConvertRoles2PB Roles holds the value of the roles edge. +func ConvertRoles2PB(gosModel Roles) (pbsModel RolesPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertRole2PB(model)) + } + return pbsModel +} + +// ConvertRolesPB2Object Roles holds the value of the roles edge. +func ConvertRolesPB2Object(pbsModel RolesPB) (gosModel Roles) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertRolePB2Object(model)) + } + return gosModel +} + +type ( + Resources = []*ent.Resource + ResourcesPB = []*typespb.Resource +) + +// ConvertResources2PB Resources holds the value of the resources edge. +func ConvertResources2PB(gosModel Resources) (pbsModel ResourcesPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertResource2PB(model)) + } + return pbsModel +} + +// ConvertResourcesPB2Object Resources holds the value of the resources edge. +func ConvertResourcesPB2Object(pbsModel ResourcesPB) (gosModel Resources) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertResourcePB2Object(model)) + } + return gosModel +} + +type ( + Positions = []*ent.Position + PositionsPB = []*typespb.Position +) + +// ConvertPositions2PB Positions holds the value of the positions edge. +func ConvertPositions2PB(gosModel Positions) (pbsModel PositionsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertPosition2PB(model)) + } + return pbsModel +} + +// ConvertPositionsPB2Object Positions holds the value of the positions edge. +func ConvertPositionsPB2Object(pbsModel PositionsPB) (gosModel Positions) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertPositionPB2Object(model)) + } + return gosModel +} + +type ( + RolePermissions = []*ent.RolePermission + RolePermissionsPB = []*typespb.RolePermission +) + +// ConvertRolePermissions2PB RolePermissions holds the value of the role_permissions edge. +func ConvertRolePermissions2PB(gosModel RolePermissions) (pbsModel RolePermissionsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertRolePermission2PB(model)) + } + return pbsModel +} + +// ConvertRolePermissionsPB2Object RolePermissions holds the value of the role_permissions edge. +func ConvertRolePermissionsPB2Object(pbsModel RolePermissionsPB) (gosModel RolePermissions) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertRolePermissionPB2Object(model)) + } + return gosModel +} + +type ( + PermissionResources = []*ent.PermissionResource + PermissionResourcesPB = []*typespb.PermissionResource +) + +// ConvertPermissionResources2PB PermissionResources holds the value of the permission_resources edge. +func ConvertPermissionResources2PB(gosModel PermissionResources) (pbsModel PermissionResourcesPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertPermissionResource2PB(model)) + } + return pbsModel +} + +// ConvertPermissionResourcesPB2Object PermissionResources holds the value of the permission_resources edge. +func ConvertPermissionResourcesPB2Object(pbsModel PermissionResourcesPB) (gosModel PermissionResources) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertPermissionResourcePB2Object(model)) + } + return gosModel +} + +type ( + PositionPermissions = []*ent.PositionPermission + PositionPermissionsPB = []*typespb.PositionPermission +) + +// ConvertPositionPermissions2PB PositionPermissions holds the value of the position_permissions edge. +func ConvertPositionPermissions2PB(gosModel PositionPermissions) (pbsModel PositionPermissionsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertPositionPermission2PB(model)) + } + return pbsModel +} + +// ConvertPositionPermissionsPB2Object PositionPermissions holds the value of the position_permissions edge. +func ConvertPositionPermissionsPB2Object(pbsModel PositionPermissionsPB) (gosModel PositionPermissions) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertPositionPermissionPB2Object(model)) + } + return gosModel +} + +type ( + PermissionEdges = ent.PermissionEdges + PermissionEdgesPB = typespb.PermissionEdges +) + +// ConvertPermissionEdges2PB PermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertPermissionEdges2PB(goModel *PermissionEdges) (pbModel *PermissionEdgesPB) { + pbModel = &PermissionEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Roles = ConvertRoles2PB(goModel.Roles) + pbModel.Resources = ConvertResources2PB(goModel.Resources) + pbModel.Positions = ConvertPositions2PB(goModel.Positions) + pbModel.RolePermissions = ConvertRolePermissions2PB(goModel.RolePermissions) + pbModel.PermissionResources = ConvertPermissionResources2PB(goModel.PermissionResources) + pbModel.PositionPermissions = ConvertPositionPermissions2PB(goModel.PositionPermissions) + return pbModel +} + +// ConvertPermissionEdgesPB2Object PermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertPermissionEdgesPB2Object(pbModel *PermissionEdgesPB) (goModel *PermissionEdges) { + goModel = &PermissionEdges{} + if pbModel == nil { + return goModel + } + + goModel.Roles = ConvertRolesPB2Object(pbModel.Roles) + goModel.Resources = ConvertResourcesPB2Object(pbModel.Resources) + goModel.Positions = ConvertPositionsPB2Object(pbModel.Positions) + goModel.RolePermissions = ConvertRolePermissionsPB2Object(pbModel.RolePermissions) + goModel.PermissionResources = ConvertPermissionResourcesPB2Object(pbModel.PermissionResources) + goModel.PositionPermissions = ConvertPositionPermissionsPB2Object(pbModel.PositionPermissions) + return goModel +} + +type ( + UserPosition = ent.UserPosition + UserPositionPB = typespb.UserPosition +) + +// ConvertUserPosition2PB user_position.table.comment +func ConvertUserPosition2PB(goModel *UserPosition) (pbModel *UserPositionPB) { + pbModel = &UserPositionPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.UserId = int64(goModel.UserID) + pbModel.PositionId = int64(goModel.PositionID) + return pbModel +} + +// ConvertUserPositionPB2Object user_position.table.comment +func ConvertUserPositionPB2Object(pbModel *UserPositionPB) (goModel *UserPosition) { + goModel = &UserPosition{} + if pbModel == nil { + return goModel + } + + //goModel.ID = int64(pbModel.Id) + goModel.UserID = int64(pbModel.UserId) + goModel.PositionID = int64(pbModel.PositionId) + return goModel +} + +type ( + UserPositionEdges = ent.UserPositionEdges + UserPositionEdgesPB = typespb.UserPositionEdges +) + +// ConvertUserPositionEdges2PB UserPositionEdges holds the relations/edges for other nodes in the graph. +func ConvertUserPositionEdges2PB(goModel *UserPositionEdges) (pbModel *UserPositionEdgesPB) { + pbModel = &UserPositionEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.User = ConvertUser2PB(goModel.User) + pbModel.Position = ConvertPosition2PB(goModel.Position) + return pbModel +} + +// ConvertUserPositionEdgesPB2Object UserPositionEdges holds the relations/edges for other nodes in the graph. +func ConvertUserPositionEdgesPB2Object(pbModel *UserPositionEdgesPB) (goModel *UserPositionEdges) { + goModel = &UserPositionEdges{} + if pbModel == nil { + return goModel + } + + goModel.User = ConvertUserPB2Object(pbModel.User) + goModel.Position = ConvertPositionPB2Object(pbModel.Position) + return goModel +} + +type ( + PositionPermission = ent.PositionPermission + PositionPermissionPB = typespb.PositionPermission +) + +// ConvertPositionPermission2PB position_permission.table.comment +func ConvertPositionPermission2PB(goModel *PositionPermission) (pbModel *PositionPermissionPB) { + pbModel = &PositionPermissionPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.PositionId = int64(goModel.PositionID) + pbModel.PermissionId = int64(goModel.PermissionID) + return pbModel +} + +// ConvertPositionPermissionPB2Object position_permission.table.comment +func ConvertPositionPermissionPB2Object(pbModel *PositionPermissionPB) (goModel *PositionPermission) { + goModel = &PositionPermission{} + if pbModel == nil { + return goModel + } + + //goModel.ID = int64(pbModel.Id) + goModel.PositionID = int64(pbModel.PositionId) + goModel.PermissionID = int64(pbModel.PermissionId) + return goModel +} + +type ( + PositionPermissionEdges = ent.PositionPermissionEdges + PositionPermissionEdgesPB = typespb.PositionPermissionEdges +) + +// ConvertPositionPermissionEdges2PB PositionPermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertPositionPermissionEdges2PB(goModel *PositionPermissionEdges) (pbModel *PositionPermissionEdgesPB) { + pbModel = &PositionPermissionEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Position = ConvertPosition2PB(goModel.Position) + pbModel.Permission = ConvertPermission2PB(goModel.Permission) + return pbModel +} + +// ConvertPositionPermissionEdgesPB2Object PositionPermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertPositionPermissionEdgesPB2Object(pbModel *PositionPermissionEdgesPB) (goModel *PositionPermissionEdges) { + goModel = &PositionPermissionEdges{} + if pbModel == nil { + return goModel + } + + goModel.Position = ConvertPositionPB2Object(pbModel.Position) + goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) + return goModel +} + +type ( + RolePermission = ent.RolePermission + RolePermissionPB = typespb.RolePermission +) + +// ConvertRolePermission2PB role_permission.table.comment +func ConvertRolePermission2PB(goModel *RolePermission) (pbModel *RolePermissionPB) { + pbModel = &RolePermissionPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.RoleId = int64(goModel.RoleID) + pbModel.PermissionId = int64(goModel.PermissionID) + return pbModel +} + +// ConvertRolePermissionPB2Object role_permission.table.comment +func ConvertRolePermissionPB2Object(pbModel *RolePermissionPB) (goModel *RolePermission) { + goModel = &RolePermission{} + if pbModel == nil { + return goModel + } + + //goModel.ID = int64(pbModel.Id) + goModel.RoleID = int64(pbModel.RoleId) + goModel.PermissionID = int64(pbModel.PermissionId) + return goModel +} + +type ( + RolePermissionEdges = ent.RolePermissionEdges + RolePermissionEdgesPB = typespb.RolePermissionEdges +) + +// ConvertRolePermissionEdges2PB RolePermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertRolePermissionEdges2PB(goModel *RolePermissionEdges) (pbModel *RolePermissionEdgesPB) { + pbModel = &RolePermissionEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Role = ConvertRole2PB(goModel.Role) + pbModel.Permission = ConvertPermission2PB(goModel.Permission) + return pbModel +} + +// ConvertRolePermissionEdgesPB2Object RolePermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertRolePermissionEdgesPB2Object(pbModel *RolePermissionEdgesPB) (goModel *RolePermissionEdges) { + goModel = &RolePermissionEdges{} + if pbModel == nil { + return goModel + } + + goModel.Role = ConvertRolePB2Object(pbModel.Role) + goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) + return goModel +} + +type ( + PermissionResource = ent.PermissionResource + PermissionResourcePB = typespb.PermissionResource +) + +// ConvertPermissionResource2PB permission_resource.table.comment +func ConvertPermissionResource2PB(goModel *PermissionResource) (pbModel *PermissionResourcePB) { + pbModel = &PermissionResourcePB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.PermissionId = int64(goModel.PermissionID) + pbModel.ResourceId = int64(goModel.ResourceID) + //pbModel.Actions = goModel.Actions + return pbModel +} + +// ConvertPermissionResourcePB2Object permission_resource.table.comment +func ConvertPermissionResourcePB2Object(pbModel *PermissionResourcePB) (goModel *PermissionResource) { + goModel = &PermissionResource{} + if pbModel == nil { + return goModel + } + + //goModel.ID = int64(pbModel.Id) + goModel.PermissionID = int64(pbModel.PermissionId) + goModel.ResourceID = int64(pbModel.ResourceId) + //goModel.Actions = pbModel.Actions + return goModel +} + +type ( + PermissionResourceEdges = ent.PermissionResourceEdges + PermissionResourceEdgesPB = typespb.PermissionResourceEdges +) + +// ConvertPermissionResourceEdges2PB PermissionResourceEdges holds the relations/edges for other nodes in the graph. +func ConvertPermissionResourceEdges2PB(goModel *PermissionResourceEdges) (pbModel *PermissionResourceEdgesPB) { + pbModel = &PermissionResourceEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Permission = ConvertPermission2PB(goModel.Permission) + pbModel.Resource = ConvertResource2PB(goModel.Resource) + return pbModel +} + +// ConvertPermissionResourceEdgesPB2Object PermissionResourceEdges holds the relations/edges for other nodes in the graph. +func ConvertPermissionResourceEdgesPB2Object(pbModel *PermissionResourceEdgesPB) (goModel *PermissionResourceEdges) { + goModel = &PermissionResourceEdges{} + if pbModel == nil { + return goModel + } + + goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) + goModel.Resource = ConvertResourcePB2Object(pbModel.Resource) + return goModel +} diff --git a/internal/mods/system/dto/login.go b/internal/mods/auth/dto/login.go similarity index 100% rename from internal/mods/system/dto/login.go rename to internal/mods/auth/dto/login.go diff --git a/internal/mods/auth/service/auth.agent.go b/internal/mods/auth/service/auth.agent.go index 74e3e60e..098dfe0b 100644 --- a/internal/mods/auth/service/auth.agent.go +++ b/internal/mods/auth/service/auth.agent.go @@ -11,7 +11,7 @@ import ( "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/service" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/helpers/resp" ) diff --git a/internal/mods/auth/service/auth.grpc.go b/internal/mods/auth/service/auth.grpc.go index b5ca8e51..0f0f97fe 100644 --- a/internal/mods/auth/service/auth.grpc.go +++ b/internal/mods/auth/service/auth.grpc.go @@ -7,8 +7,8 @@ package service import ( "github.com/origadmin/runtime/context" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/mods/auth/biz" ) // AuthServiceServer is a menu service. diff --git a/internal/mods/auth/service/auth.http.go b/internal/mods/auth/service/auth.http.go index fe2d8fa0..85619501 100644 --- a/internal/mods/auth/service/auth.http.go +++ b/internal/mods/auth/service/auth.http.go @@ -7,7 +7,7 @@ package service import ( "github.com/origadmin/runtime/context" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" ) // AuthServiceHTTPServer is a menu service. diff --git a/internal/mods/auth/service/casbin.grpc.go b/internal/mods/auth/service/casbin.grpc.go index 20ad37c5..c6b1dd93 100644 --- a/internal/mods/auth/service/casbin.grpc.go +++ b/internal/mods/auth/service/casbin.grpc.go @@ -12,8 +12,8 @@ import ( "github.com/origadmin/runtime/service" "google.golang.org/grpc" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/mods/auth/biz" ) type CasbinSourceServiceServer struct { diff --git a/internal/mods/auth/service/casbin.http.go b/internal/mods/auth/service/casbin.http.go index bf2cd169..4be092b0 100644 --- a/internal/mods/auth/service/casbin.http.go +++ b/internal/mods/auth/service/casbin.http.go @@ -7,7 +7,7 @@ package service import ( "github.com/origadmin/runtime/context" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" ) // CasbinServiceHTTPServer is a login service. diff --git a/internal/mods/auth/service/login.agent.go b/internal/mods/auth/service/login.agent.go index 0d80dfd1..3e2ae353 100644 --- a/internal/mods/auth/service/login.agent.go +++ b/internal/mods/auth/service/login.agent.go @@ -12,7 +12,7 @@ import ( "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/helpers/resp" ) diff --git a/internal/mods/auth/service/login.grpc.go b/internal/mods/auth/service/login.grpc.go index 57c71a74..7cdf6540 100644 --- a/internal/mods/auth/service/login.grpc.go +++ b/internal/mods/auth/service/login.grpc.go @@ -7,8 +7,8 @@ package service import ( "golang.org/x/net/context" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/mods/auth/biz" ) // LoginServiceServer is a login service. diff --git a/internal/mods/auth/service/login.http.go b/internal/mods/auth/service/login.http.go index 51d56bd1..f8c53803 100644 --- a/internal/mods/auth/service/login.http.go +++ b/internal/mods/auth/service/login.http.go @@ -7,7 +7,7 @@ package service import ( "context" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" ) // LoginServiceHTTPServer is a login service. diff --git a/internal/mods/system/biz/auth.biz.go b/internal/mods/system/biz/auth.biz.go index 9c86efe9..c3611226 100644 --- a/internal/mods/system/biz/auth.biz.go +++ b/internal/mods/system/biz/auth.biz.go @@ -11,8 +11,8 @@ import ( "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/mods/auth/dto" ) // AuthServiceBiz is a Auth use case. diff --git a/internal/mods/system/dto/dto.go b/internal/mods/system/dto/dto.go index 68e41bec..b19e29aa 100644 --- a/internal/mods/system/dto/dto.go +++ b/internal/mods/system/dto/dto.go @@ -12,6 +12,7 @@ import ( "google.golang.org/protobuf/types/known/timestamppb" pb "origadmin/application/admin/api/v1/services/system" + typespb "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/schema/types" "origadmin/application/admin/internal/data/entity/ent/user" @@ -49,7 +50,7 @@ type ( // target="User", // direction="both" // ) - UserPB = pb.User + UserPB = typespb.User ) // ConvertUser2PB user.table.comment @@ -131,7 +132,7 @@ func ConvertUserPB2Object(pbModel *UserPB) (goModel *User) { type ( Resource = ent.Resource - ResourcePB = pb.Resource + ResourcePB = typespb.Resource ) func ConvertResource2PB(goModel *Resource) (pbModel *ResourcePB) { @@ -192,7 +193,7 @@ func ConvertResourcePB2Object(pbModel *ResourcePB) (goModel *Resource) { type ( Role = ent.Role - RolePB = pb.Role + RolePB = typespb.Role ) // ConvertRole2PB role.table.comment @@ -242,7 +243,7 @@ func ConvertRolePB2Object(pbModel *RolePB) (goModel *Role) { type ( Department = ent.Department - DepartmentPB = pb.Department + DepartmentPB = typespb.Department ) // ConvertDepartment2PB department.table.comment @@ -288,7 +289,7 @@ func ConvertDepartmentPB2Object(pbModel *DepartmentPB) (goModel *Department) { type ( Departments = []*ent.Department - DepartmentsPB = []*pb.Department + DepartmentsPB = []*typespb.Department ) // ConvertDepartments2PB Children holds the value of the children edge. @@ -309,7 +310,7 @@ func ConvertDepartmentsPB2Object(pbsModel DepartmentsPB) (gosModel Departments) type ( UserDepartments = []*ent.UserDepartment - UserDepartmentsPB = []*pb.UserDepartment + UserDepartmentsPB = []*typespb.UserDepartment ) // ConvertUserDepartments2PB UserDepartments holds the value of the user_departments edge. @@ -330,7 +331,7 @@ func ConvertUserDepartmentsPB2Object(pbsModel UserDepartmentsPB) (gosModel UserD type ( DepartmentEdges = ent.DepartmentEdges - DepartmentEdgesPB = pb.DepartmentEdges + DepartmentEdgesPB = typespb.DepartmentEdges ) // ConvertDepartmentEdges2PB DepartmentEdges holds the relations/edges for other nodes in the graph. @@ -365,7 +366,7 @@ func ConvertDepartmentEdgesPB2Object(pbModel *DepartmentEdgesPB) (goModel *Depar type ( UserDepartment = ent.UserDepartment - UserDepartmentPB = pb.UserDepartment + UserDepartmentPB = typespb.UserDepartment ) // ConvertUserDepartment2PB user_department.table.comment @@ -396,7 +397,7 @@ func ConvertUserDepartmentPB2Object(pbModel *UserDepartmentPB) (goModel *UserDep type ( UserDepartmentEdges = ent.UserDepartmentEdges - UserDepartmentEdgesPB = pb.UserDepartmentEdges + UserDepartmentEdgesPB = typespb.UserDepartmentEdges ) // ConvertUserDepartmentEdges2PB UserDepartmentEdges holds the relations/edges for other nodes in the graph. @@ -425,7 +426,7 @@ func ConvertUserDepartmentEdgesPB2Object(pbModel *UserDepartmentEdgesPB) (goMode type ( Position = ent.Position - PositionPB = pb.Position + PositionPB = typespb.Position ) // ConvertPosition2PB position.table.comment @@ -462,7 +463,7 @@ func ConvertPositionPB2Object(pbModel *PositionPB) (goModel *Position) { type ( Users = []*ent.User - UsersPB = []*pb.User + UsersPB = []*typespb.User ) // ConvertUsers2PB Users holds the value of the users edge. @@ -483,7 +484,7 @@ func ConvertUsersPB2Object(pbsModel UsersPB) (gosModel Users) { type ( Permissions = []*ent.Permission - PermissionsPB = []*pb.Permission + PermissionsPB = []*typespb.Permission ) // ConvertPermissions2PB Permissions holds the value of the permissions edge. @@ -504,7 +505,7 @@ func ConvertPermissionsPB2Object(pbsModel PermissionsPB) (gosModel Permissions) type ( UserPositions = []*ent.UserPosition - UserPositionsPB = []*pb.UserPosition + UserPositionsPB = []*typespb.UserPosition ) // ConvertUserPositions2PB UserPositions holds the value of the user_positions edge. @@ -525,7 +526,7 @@ func ConvertUserPositionsPB2Object(pbsModel UserPositionsPB) (gosModel UserPosit type ( PositionEdges = ent.PositionEdges - PositionEdgesPB = pb.PositionEdges + PositionEdgesPB = typespb.PositionEdges ) // ConvertPositionEdges2PB PositionEdges holds the relations/edges for other nodes in the graph. @@ -570,7 +571,7 @@ func ConvertDataRulesPB2Object(pbsModel map[string]string) map[string]string { type ( Permission = ent.Permission - PermissionPB = pb.Permission + PermissionPB = typespb.Permission ) // ConvertPermission2PB permission.table.comment @@ -615,7 +616,7 @@ func ConvertPermissionPB2Object(pbModel *PermissionPB) (goModel *Permission) { type ( Roles = []*ent.Role - RolesPB = []*pb.Role + RolesPB = []*typespb.Role ) // ConvertRoles2PB Roles holds the value of the roles edge. @@ -636,7 +637,7 @@ func ConvertRolesPB2Object(pbsModel RolesPB) (gosModel Roles) { type ( Resources = []*ent.Resource - ResourcesPB = []*pb.Resource + ResourcesPB = []*typespb.Resource ) // ConvertResources2PB Resources holds the value of the resources edge. @@ -657,7 +658,7 @@ func ConvertResourcesPB2Object(pbsModel ResourcesPB) (gosModel Resources) { type ( Positions = []*ent.Position - PositionsPB = []*pb.Position + PositionsPB = []*typespb.Position ) // ConvertPositions2PB Positions holds the value of the positions edge. @@ -678,7 +679,7 @@ func ConvertPositionsPB2Object(pbsModel PositionsPB) (gosModel Positions) { type ( RolePermissions = []*ent.RolePermission - RolePermissionsPB = []*pb.RolePermission + RolePermissionsPB = []*typespb.RolePermission ) // ConvertRolePermissions2PB RolePermissions holds the value of the role_permissions edge. @@ -699,7 +700,7 @@ func ConvertRolePermissionsPB2Object(pbsModel RolePermissionsPB) (gosModel RoleP type ( PermissionResources = []*ent.PermissionResource - PermissionResourcesPB = []*pb.PermissionResource + PermissionResourcesPB = []*typespb.PermissionResource ) // ConvertPermissionResources2PB PermissionResources holds the value of the permission_resources edge. @@ -720,7 +721,7 @@ func ConvertPermissionResourcesPB2Object(pbsModel PermissionResourcesPB) (gosMod type ( PositionPermissions = []*ent.PositionPermission - PositionPermissionsPB = []*pb.PositionPermission + PositionPermissionsPB = []*typespb.PositionPermission ) // ConvertPositionPermissions2PB PositionPermissions holds the value of the position_permissions edge. @@ -741,7 +742,7 @@ func ConvertPositionPermissionsPB2Object(pbsModel PositionPermissionsPB) (gosMod type ( PermissionEdges = ent.PermissionEdges - PermissionEdgesPB = pb.PermissionEdges + PermissionEdgesPB = typespb.PermissionEdges ) // ConvertPermissionEdges2PB PermissionEdges holds the relations/edges for other nodes in the graph. @@ -778,7 +779,7 @@ func ConvertPermissionEdgesPB2Object(pbModel *PermissionEdgesPB) (goModel *Permi type ( UserPosition = ent.UserPosition - UserPositionPB = pb.UserPosition + UserPositionPB = typespb.UserPosition ) // ConvertUserPosition2PB user_position.table.comment @@ -809,7 +810,7 @@ func ConvertUserPositionPB2Object(pbModel *UserPositionPB) (goModel *UserPositio type ( UserPositionEdges = ent.UserPositionEdges - UserPositionEdgesPB = pb.UserPositionEdges + UserPositionEdgesPB = typespb.UserPositionEdges ) // ConvertUserPositionEdges2PB UserPositionEdges holds the relations/edges for other nodes in the graph. @@ -838,7 +839,7 @@ func ConvertUserPositionEdgesPB2Object(pbModel *UserPositionEdgesPB) (goModel *U type ( PositionPermission = ent.PositionPermission - PositionPermissionPB = pb.PositionPermission + PositionPermissionPB = typespb.PositionPermission ) // ConvertPositionPermission2PB position_permission.table.comment @@ -869,7 +870,7 @@ func ConvertPositionPermissionPB2Object(pbModel *PositionPermissionPB) (goModel type ( PositionPermissionEdges = ent.PositionPermissionEdges - PositionPermissionEdgesPB = pb.PositionPermissionEdges + PositionPermissionEdgesPB = typespb.PositionPermissionEdges ) // ConvertPositionPermissionEdges2PB PositionPermissionEdges holds the relations/edges for other nodes in the graph. @@ -898,7 +899,7 @@ func ConvertPositionPermissionEdgesPB2Object(pbModel *PositionPermissionEdgesPB) type ( RolePermission = ent.RolePermission - RolePermissionPB = pb.RolePermission + RolePermissionPB = typespb.RolePermission ) // ConvertRolePermission2PB role_permission.table.comment @@ -929,7 +930,7 @@ func ConvertRolePermissionPB2Object(pbModel *RolePermissionPB) (goModel *RolePer type ( RolePermissionEdges = ent.RolePermissionEdges - RolePermissionEdgesPB = pb.RolePermissionEdges + RolePermissionEdgesPB = typespb.RolePermissionEdges ) // ConvertRolePermissionEdges2PB RolePermissionEdges holds the relations/edges for other nodes in the graph. @@ -958,7 +959,7 @@ func ConvertRolePermissionEdgesPB2Object(pbModel *RolePermissionEdgesPB) (goMode type ( PermissionResource = ent.PermissionResource - PermissionResourcePB = pb.PermissionResource + PermissionResourcePB = typespb.PermissionResource ) // ConvertPermissionResource2PB permission_resource.table.comment @@ -991,7 +992,7 @@ func ConvertPermissionResourcePB2Object(pbModel *PermissionResourcePB) (goModel type ( PermissionResourceEdges = ent.PermissionResourceEdges - PermissionResourceEdgesPB = pb.PermissionResourceEdges + PermissionResourceEdgesPB = typespb.PermissionResourceEdges ) // ConvertPermissionResourceEdges2PB PermissionResourceEdges holds the relations/edges for other nodes in the graph. diff --git a/internal/mods/system/dto/role.go b/internal/mods/system/dto/role.go index 157b6950..0ddbc33c 100644 --- a/internal/mods/system/dto/role.go +++ b/internal/mods/system/dto/role.go @@ -13,13 +13,14 @@ import ( "google.golang.org/protobuf/proto" pb "origadmin/application/admin/api/v1/services/system" + typespb "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/helpers/resp" "origadmin/application/admin/internal/data/entity/ent" ) type ( RoleEdges = ent.RoleEdges - RoleEdgesPB = pb.RoleEdges + RoleEdgesPB = typespb.RoleEdges ListRolesRequest = pb.ListRolesRequest ListRolesResponse = pb.ListRolesResponse diff --git a/internal/mods/system/dto/user.go b/internal/mods/system/dto/user.go index 29316be3..b9eb649b 100644 --- a/internal/mods/system/dto/user.go +++ b/internal/mods/system/dto/user.go @@ -9,12 +9,13 @@ import ( "context" "github.com/google/uuid" + "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/rand" - "github.com/origadmin/runtime/interfaces/pagination" pb "origadmin/application/admin/api/v1/services/system" + typespb "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/helpers/id" "origadmin/application/admin/helpers/resp" "origadmin/application/admin/internal/data/entity/ent" @@ -22,9 +23,9 @@ import ( type ( UserRole = ent.UserRole - UserRolePB = pb.UserRole + UserRolePB = typespb.UserRole UserRoleEdges = ent.UserRoleEdges - UserRoleEdgesPB = pb.UserRoleEdges + UserRoleEdgesPB = typespb.UserRoleEdges ListUsersRequest = pb.ListUsersRequest ListUsersResponse = pb.ListUsersResponse diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 407b6708..a2b796e4 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -49,7 +49,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.CaptchaResponse' + $ref: '#/components/schemas/api.v1.services.auth.CaptchaResponse' default: description: Default error response content: @@ -115,7 +115,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.CaptchaAudioResponse' + $ref: '#/components/schemas/api.v1.services.auth.CaptchaAudioResponse' default: description: Default error response content: @@ -143,7 +143,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.CaptchaIdResponse' + $ref: '#/components/schemas/api.v1.services.auth.CaptchaIdResponse' default: description: Default error response content: @@ -209,7 +209,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.CaptchaImageResponse' + $ref: '#/components/schemas/api.v1.services.auth.CaptchaImageResponse' default: description: Default error response content: @@ -311,7 +311,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.LoginRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.LoginRequest_Data' required: true responses: "200": @@ -319,7 +319,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.LoginResponse' + $ref: '#/components/schemas/api.v1.services.auth.LoginResponse' default: description: Default error response content: @@ -343,7 +343,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.LogoutResponse' + $ref: '#/components/schemas/api.v1.services.auth.LogoutResponse' default: description: Default error response content: @@ -359,7 +359,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.RegisterRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.RegisterRequest_Data' required: true responses: "200": @@ -367,7 +367,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.RegisterResponse' + $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse' default: description: Default error response content: @@ -2270,7 +2270,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.TokenRefreshRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.TokenRefreshRequest_Data' required: true responses: "200": @@ -2278,7 +2278,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.TokenRefreshResponse' + $ref: '#/components/schemas/api.v1.services.auth.TokenRefreshResponse' default: description: Default error response content: @@ -2311,6 +2311,42 @@ components: properties: is_valid: type: boolean + api.v1.services.auth.CaptchaAudioResponse: + type: object + properties: + headers: + type: object + additionalProperties: + type: string + audio: + type: string + format: bytes + description: The response message containing the greetings + api.v1.services.auth.CaptchaIdResponse: + type: object + properties: + data: + type: string + api.v1.services.auth.CaptchaImageResponse: + type: object + properties: + headers: + type: object + additionalProperties: + type: string + image: + type: string + format: bytes + description: The response message containing the greetings + api.v1.services.auth.CaptchaResponse: + type: object + properties: + id: + type: string + type: + type: string + data: + type: string api.v1.services.auth.CreateTokenRequest_Data: type: object properties: @@ -2370,6 +2406,27 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.auth.PolicyRule' + api.v1.services.auth.LoginRequest_Data: + type: object + properties: + username: + type: string + password: + type: string + captcha_id: + type: string + captcha_code: + type: string + api.v1.services.auth.LoginResponse: + type: object + properties: + token: + $ref: '#/components/schemas/security.jwt.v1.Token' + api.v1.services.auth.LogoutResponse: + type: object + properties: + success: + type: boolean api.v1.services.auth.PolicyRule: type: object properties: @@ -2379,6 +2436,29 @@ components: type: array items: type: string + api.v1.services.auth.RegisterRequest_Data: + type: object + properties: + username: + type: string + password: + type: string + captcha_id: + type: string + captcha_code: + type: string + api.v1.services.auth.RegisterResponse: + type: object + properties: + success: + type: boolean + data: + $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse_Data' + api.v1.services.auth.RegisterResponse_Data: + type: object + properties: + redirect: + type: string api.v1.services.auth.StreamRulesResponse: type: object properties: @@ -2386,6 +2466,16 @@ components: $ref: '#/components/schemas/api.v1.services.auth.PolicyRule' grouping: $ref: '#/components/schemas/api.v1.services.auth.GroupingRule' + api.v1.services.auth.TokenRefreshRequest_Data: + type: object + properties: + refresh_token: + type: string + api.v1.services.auth.TokenRefreshResponse: + type: object + properties: + token: + $ref: '#/components/schemas/security.jwt.v1.Token' api.v1.services.auth.ValidateTokenResponse: type: object properties: @@ -2401,42 +2491,6 @@ components: properties: modified_date: type: string - api.v1.services.system.CaptchaAudioResponse: - type: object - properties: - headers: - type: object - additionalProperties: - type: string - audio: - type: string - format: bytes - description: The response message containing the greetings - api.v1.services.system.CaptchaIdResponse: - type: object - properties: - data: - type: string - api.v1.services.system.CaptchaImageResponse: - type: object - properties: - headers: - type: object - additionalProperties: - type: string - image: - type: string - format: bytes - description: The response message containing the greetings - api.v1.services.system.CaptchaResponse: - type: object - properties: - id: - type: string - type: - type: string - data: - type: string api.v1.services.system.CreateDepartmentResponse: type: object properties: @@ -2793,27 +2847,6 @@ components: description: |- Additional information about this response. content to be added without destroying the current data format - api.v1.services.system.LoginRequest_Data: - type: object - properties: - username: - type: string - password: - type: string - captcha_id: - type: string - captcha_code: - type: string - api.v1.services.system.LoginResponse: - type: object - properties: - token: - $ref: '#/components/schemas/security.jwt.v1.Token' - api.v1.services.system.LogoutResponse: - type: object - properties: - success: - type: boolean api.v1.services.system.PersonalLogoutResponse: type: object properties: @@ -2824,42 +2857,9 @@ components: properties: token: type: string - api.v1.services.system.RegisterRequest_Data: - type: object - properties: - username: - type: string - password: - type: string - captcha_id: - type: string - captcha_code: - type: string - api.v1.services.system.RegisterResponse: - type: object - properties: - success: - type: boolean - data: - $ref: '#/components/schemas/api.v1.services.system.RegisterResponse_Data' - api.v1.services.system.RegisterResponse_Data: - type: object - properties: - redirect: - type: string api.v1.services.system.ResetUserPasswordResponse: type: object properties: {} - api.v1.services.system.TokenRefreshRequest_Data: - type: object - properties: - refresh_token: - type: string - api.v1.services.system.TokenRefreshResponse: - type: object - properties: - token: - $ref: '#/components/schemas/security.jwt.v1.Token' api.v1.services.system.UpdateDepartmentResponse: type: object properties: From cde5cb256bd2ccf30b5a6f21e218ad5253dd0897 Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 30 May 2025 22:12:50 +0800 Subject: [PATCH 031/158] refactor(internal): remove unused auth, casbin, and login related code - Removed auth, casbin, and login related DTOs and biz logic - Deleted multiple files related to auth, casbin, and login functionality - Updated personal profile related code to use typespb.User instead of pb.User --- internal/mods/auth/dto/dto.go | 17 +- internal/mods/auth/dto/login.go | 2 +- internal/mods/system/biz/auth.biz.go | 61 ---- internal/mods/system/biz/casbin.biz.go | 111 ------ internal/mods/system/biz/login.biz.go | 74 ---- internal/mods/system/dal/auth.dal.go | 182 ---------- internal/mods/system/dal/casbin.dal.go | 118 ------- internal/mods/system/dal/login.dal.go | 429 ----------------------- internal/mods/system/dal/personal.dal.go | 3 +- 9 files changed, 5 insertions(+), 992 deletions(-) delete mode 100644 internal/mods/system/biz/auth.biz.go delete mode 100644 internal/mods/system/biz/casbin.biz.go delete mode 100644 internal/mods/system/biz/login.biz.go delete mode 100644 internal/mods/system/dal/auth.dal.go delete mode 100644 internal/mods/system/dal/casbin.dal.go delete mode 100644 internal/mods/system/dal/login.dal.go diff --git a/internal/mods/auth/dto/dto.go b/internal/mods/auth/dto/dto.go index 86a43531..fa2f1000 100644 --- a/internal/mods/auth/dto/dto.go +++ b/internal/mods/auth/dto/dto.go @@ -6,27 +6,14 @@ package dto import ( - "net/http" - - "github.com/origadmin/toolkits/errors/httperr" "google.golang.org/protobuf/types/known/timestamppb" - pb "origadmin/application/admin/api/v1/services/auth" typespb "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/schema/types" "origadmin/application/admin/internal/data/entity/ent/user" ) -var ( - // ErrUserNotFound is user not found. - ErrUserNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") - ErrInvalidCaptchaID = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") - ErrInvalidPassword = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") - ErrInvalidUsername = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") - ErrCaptchaIDNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") -) - const ( UserStatusActive = types.Active UserStatusFrozen = types.Frozen @@ -88,7 +75,7 @@ func ConvertUser2PB(goModel *User) (pbModel *UserPB) { for _, role := range goModel.Edges.Roles { pbModel.RoleIds = append(pbModel.RoleIds, role.ID) } - pbModel.Roles = ConvertRoles(goModel.Edges.Roles) + pbModel.Roles = ConvertRoles2PB(goModel.Edges.Roles) return pbModel } @@ -215,7 +202,7 @@ func ConvertRole2PB(goModel *Role) (pbModel *RolePB) { for _, permission := range goModel.Edges.Permissions { pbModel.PermissionIds = append(pbModel.PermissionIds, int64(permission.ID)) } - pbModel.Permissions = ConvertPermissions(goModel.Edges.Permissions) + pbModel.Permissions = ConvertPermissions2PB(goModel.Edges.Permissions) //pbModel.IsSystem = goModel.IsSystem return pbModel } diff --git a/internal/mods/auth/dto/login.go b/internal/mods/auth/dto/login.go index 75bb0062..69e25ed2 100644 --- a/internal/mods/auth/dto/login.go +++ b/internal/mods/auth/dto/login.go @@ -8,7 +8,7 @@ package dto import ( "context" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" ) type ( diff --git a/internal/mods/system/biz/auth.biz.go b/internal/mods/system/biz/auth.biz.go deleted file mode 100644 index c3611226..00000000 --- a/internal/mods/system/biz/auth.biz.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/pagination" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/mods/auth/dto" -) - -// AuthServiceBiz is a Auth use case. -type AuthServiceBiz struct { - dao dto.AuthRepo - limiter pagination.PageLimiter - log *log.KHelper -} - -func (biz AuthServiceBiz) AuthLogout(ctx context.Context, in *pb.AuthLogoutRequest) (*pb.AuthLogoutResponse, error) { - return biz.dao.AuthLogout(ctx, in) -} - -func (biz AuthServiceBiz) CreateToken(ctx context.Context, in *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error) { - return biz.dao.CreateToken(ctx, in) -} - -func (biz AuthServiceBiz) ValidateToken(ctx context.Context, in *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) { - return biz.dao.ValidateToken(ctx, in) -} - -func (biz AuthServiceBiz) DestroyToken(ctx context.Context, in *pb.DestroyTokenRequest) (*pb.DestroyTokenResponse, error) { - return biz.dao.DestroyToken(ctx, in) -} - -func (biz AuthServiceBiz) Authenticate(ctx context.Context, in *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) { - return biz.dao.Authenticate(ctx, in) -} - -func (biz AuthServiceBiz) ListAuthResources(ctx context.Context, in *pb.ListAuthResourcesRequest) (*pb.ListAuthResourcesResponse, error) { - var option dto.AuthResourceQueryOption - if err := option.FromListRequest(in, biz.limiter); err != nil { - return nil, err - } - biz.log.Info("ListAuths") - result, total, err := biz.dao.ListAuthResources(ctx, in, option) - if err != nil { - return nil, err - } - return dto.ToListAuthResourcesResponse(result, in, total) -} - -// NewAuthServiceBiz new Auth use case. -func NewAuthServiceBiz(r runtime.Runtime, repo dto.AuthRepo) *AuthServiceBiz { - return &AuthServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.WithLogger("module", "biz/auth"))} -} diff --git a/internal/mods/system/biz/casbin.biz.go b/internal/mods/system/biz/casbin.biz.go deleted file mode 100644 index 9440ca51..00000000 --- a/internal/mods/system/biz/casbin.biz.go +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "context" - "sync/atomic" - "time" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/interfaces/pagination" - "github.com/origadmin/runtime/log" - "google.golang.org/grpc" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" -) - -// CasbinSourceServiceBiz is a CasbinSource use case. -type CasbinSourceServiceBiz struct { - dao dto.CasbinSourceRepo - limiter pagination.PageLimiter - log *log.KHelper - lastModified *atomic.Int64 -} - -func (c CasbinSourceServiceBiz) StreamRules(request *pb.StreamRulesRequest, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { - log.Info("StreamRules") - ctx := stream.Context() - if request.WithPolicies { - if err := c.streamPolicies(ctx, stream); err != nil { - return err - } - } - - if request.WithGroupings { - if err := c.streamGroupings(ctx, stream); err != nil { - return err - } - } - return nil -} - -func (c CasbinSourceServiceBiz) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { - log.Info("ListPolicies") - return c.dao.ListPolicies(ctx, in) -} - -func (c CasbinSourceServiceBiz) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { - log.Info("ListGroupings") - return c.dao.ListGroupings(ctx, in) -} - -func (c CasbinSourceServiceBiz) WatchUpdate(_ context.Context, - request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { - log.Info("WatchUpdate") - return &pb.WatchUpdateResponse{ModifiedDate: c.lastModified.Load()}, nil -} - -func (c CasbinSourceServiceBiz) UpdateRules() { - // todo: load from db - c.lastModified.Store(time.Now().Unix()) -} - -func (c CasbinSourceServiceBiz) streamPolicies(ctx context.Context, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { - policies, err := c.ListPolicies(ctx, &pb.ListPoliciesRequest{}) - if err != nil { - return err - } - for _, rule := range policies.Rules { - if err := stream.Send(newPolicyResponse(rule)); err != nil { - return err - } - } - return nil -} - -func (c CasbinSourceServiceBiz) streamGroupings(ctx context.Context, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { - groupings, err := c.ListGroupings(ctx, &pb.ListGroupingsRequest{}) - if err != nil { - return err - } - for _, rule := range groupings.Rules { - if err := stream.Send(newGroupingResponse(rule)); err != nil { - return err - } - } - return nil -} - -func newPolicyResponse(rule *pb.PolicyRule) *pb.StreamRulesResponse { - return &pb.StreamRulesResponse{ - RuleType: &pb.StreamRulesResponse_Policy{Policy: rule}, - } -} - -func newGroupingResponse(rule *pb.GroupingRule) *pb.StreamRulesResponse { - return &pb.StreamRulesResponse{ - RuleType: &pb.StreamRulesResponse_Grouping{Grouping: rule}, - } -} - -// NewCasbinSourceServiceBiz new a CasbinSource use case. - -func NewCasbinSourceServiceBiz(r runtime.Runtime, repo dto.CasbinSourceRepo) *CasbinSourceServiceBiz { - return &CasbinSourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger()), - lastModified: &atomic.Int64{}} -} diff --git a/internal/mods/system/biz/login.biz.go b/internal/mods/system/biz/login.biz.go deleted file mode 100644 index 79ac7679..00000000 --- a/internal/mods/system/biz/login.biz.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "context" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/interfaces/pagination" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" -) - -// LoginServiceBiz is a Login use case. -type LoginServiceBiz struct { - dao dto.LoginRepo - limiter pagination.PageLimiter - log *log.KHelper -} - -func (biz LoginServiceBiz) CaptchaId(ctx context.Context, in *pb.CaptchaIdRequest) (*pb.CaptchaIdResponse, error) { - log.Info("CaptchaId") - return biz.dao.CaptchaID(ctx, in) -} - -func (biz LoginServiceBiz) Register(ctx context.Context, in *pb.RegisterRequest) (*pb.RegisterResponse, error) { - log.Info("Register") - return biz.dao.Register(ctx, in) -} - -func (biz LoginServiceBiz) Captcha(ctx context.Context, in *pb.CaptchaRequest) (*pb.CaptchaResponse, error) { - log.Info("Captcha") - return biz.dao.Captcha(ctx, in) -} - -func (biz LoginServiceBiz) CaptchaImage(ctx context.Context, in *dto.CaptchaImageRequest) (*dto.CaptchaImageResponse, error) { - log.Info("CaptchaImage") - return biz.dao.CaptchaImage(ctx, in.Id, in.Reload == "1" || in.Reload == "true") -} - -func (biz LoginServiceBiz) CaptchaAudio(ctx context.Context, in *pb.CaptchaAudioRequest) (*pb.CaptchaAudioResponse, error) { - log.Info("CaptchaAudio") - return biz.dao.CaptchaAudio(ctx, in.Id, in.Reload == "1" || in.Reload == "true") -} - -func (biz LoginServiceBiz) Login(ctx context.Context, in *dto.LoginRequest) (*dto.LoginResponse, error) { - log.Info("Login") - return biz.dao.Login(ctx, in) -} - -func (biz LoginServiceBiz) Logout(ctx context.Context, in *dto.LogoutRequest) (*dto.LogoutResponse, error) { - log.Info("Logout") - return biz.dao.Logout(ctx, in) -} - -func (biz LoginServiceBiz) CurrentUser(ctx context.Context, in *dto.CurrentUserRequest) (*dto.CurrentUserResponse, error) { - log.Info("CurrentUser") - return biz.dao.CurrentUser(ctx, in) -} - -func (biz LoginServiceBiz) TokenRefresh(ctx context.Context, in *pb.TokenRefreshRequest) (*pb.TokenRefreshResponse, error) { - log.Info("TokenRefresh") - return biz.dao.TokenRefresh(ctx, in) -} - -// NewLoginServiceBiz new a Login use case. -func NewLoginServiceBiz(r runtime.Runtime, repo dto.LoginRepo) *LoginServiceBiz { - return &LoginServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} -} diff --git a/internal/mods/system/dal/auth.dal.go b/internal/mods/system/dal/auth.dal.go deleted file mode 100644 index d41ca114..00000000 --- a/internal/mods/system/dal/auth.dal.go +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "context" - "errors" - "sync" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/interfaces/security" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - _ "origadmin/application/admin/internal/data/entity/ent/runtime" - "origadmin/application/admin/internal/mods/system/dto" -) - -type authRepo struct { - DB *data.Data - BufPool *sync.Pool - Tokenizer security.Tokenizer - Authorizer security.Authorizer -} - -func (repo authRepo) AuthLogout(ctx context.Context, request *pb.AuthLogoutRequest) (*pb.AuthLogoutResponse, error) { - //TODO implement me - panic("implement me") -} - -func (repo authRepo) CreateToken(ctx context.Context, request *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error) { - claims := security.ClaimsFromContext(ctx) - token, err := repo.Tokenizer.CreateToken(ctx, claims) - if err != nil { - return nil, err - } - return &pb.CreateTokenResponse{ - Token: token, - }, nil -} - -func (repo authRepo) ValidateToken(ctx context.Context, request *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) { - valid, err := repo.Tokenizer.Validate(ctx, request.Token) - if err != nil { - return nil, err - } - return &pb.ValidateTokenResponse{ - IsValid: valid, - }, nil -} - -func (repo authRepo) DestroyToken(ctx context.Context, request *pb.DestroyTokenRequest) (*pb.DestroyTokenResponse, error) { - //err := repo.Tokenizer.DestroyToken(ctx, request.Token) - //if err != nil { - // return nil, err - //} - return &pb.DestroyTokenResponse{}, nil -} - -func (repo authRepo) Authenticate(ctx context.Context, request *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) { - claims, err := repo.Tokenizer.ParseClaims(ctx, request.GetData().GetToken()) - if err != nil { - return nil, err - } - authorized, err := repo.Authorizer.Authorized( - ctx, - fromClaims(claims, "", ""), - request.GetData().GetMethod(), - request.GetData().GetPath()) - if err != nil { - return nil, err - } - return &pb.AuthenticateResponse{ - IsValid: authorized, - //Claims: fromClaims(claims), - }, nil -} - -func (repo authRepo) ListAuthResources(ctx context.Context, in *dto.ListAuthResourcesRequest, options ...dto.AuthResourceQueryOption) ([]*dto.ResourcePB, int32, error) { - var option dto.AuthResourceQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.DB.Resource(ctx).Query() - return authResourcePageQuery(ctx, query, in, option) -} - -func fromClaims(claims security.Claims, method, path string) security.Policy { - return &security.RegisteredPolicy{ - Subject: claims.GetSubject(), - Object: path, - Action: method, - Domain: claims.GetIssuer(), - Roles: nil, - Permissions: nil, - } -} - -// NewAuthRepo . -func NewAuthRepo(r runtime.Runtime, db *data.Data) dto.AuthRepo { - return &authRepo{ - DB: db, - BufPool: BufPool(), - } -} - -func authResourcePageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.ListAuthResourcesRequest, option dto.AuthResourceQueryOption) ([]*dto.ResourcePB, int32, error) { - query = authResourceQueryPage(query, in) - query = authResourceQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - result, err := query.All(ctx) - return dto.ConvertResources(result), int32(count), err -} - -func authResourceQueryPage(query *ent.ResourceQuery, in *pb.ListAuthResourcesRequest) *ent.ResourceQuery { - if in.NoPaging { - pageSize := in.PageSize - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - return query - } - - pageSize := in.PageSize - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - current := in.Current - if current > 0 { - query = query.Offset(int((current - 1) * pageSize)) - } - return query -} - -func authResourceQueryOptions(query *ent.ResourceQuery, option dto.AuthResourceQueryOption) *ent.ResourceQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).ResourceQuery - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).ResourceQuery - } - if len(option.OrderFields) > 0 { - query = query.Order(resourceOrderBy(option.OrderFields)...) - } - return query -} - -type refreshTokenizer struct { - tokenizer security.Tokenizer -} - -func (r refreshTokenizer) CreateClaims(ctx context.Context, s string) (security.Claims, error) { - return r.tokenizer.CreateClaims(ctx, s) -} - -func (r refreshTokenizer) CreateToken(ctx context.Context, claims security.Claims) (string, error) { - return r.tokenizer.CreateToken(ctx, claims) -} - -func (r refreshTokenizer) ParseClaims(ctx context.Context, s string) (security.Claims, error) { - return r.tokenizer.ParseClaims(ctx, s) -} - -func (r refreshTokenizer) Validate(ctx context.Context, s string) (bool, error) { - return r.tokenizer.Validate(ctx, s) -} - -func (r refreshTokenizer) CreateRefreshClaims(ctx context.Context, s string) (security.Claims, error) { - return nil, errors.New("not implemented") -} - -func wrapRefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { - return &refreshTokenizer{ - tokenizer: tokenizer, - } -} diff --git a/internal/mods/system/dal/casbin.dal.go b/internal/mods/system/dal/casbin.dal.go deleted file mode 100644 index 9720ef77..00000000 --- a/internal/mods/system/dal/casbin.dal.go +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dal implements the functions, types, and interfaces for the module. -package dal - -import ( - "context" - "strconv" - - "github.com/origadmin/runtime" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/mods/system/dto" -) - -type CasbinSourceConfig struct { - PrefixNumberID func(prefix string, id int64) string -} - -type casbinSourceRepo struct { - ctx context.Context - data *data.Data - config *CasbinSourceConfig -} - -func (c casbinSourceRepo) mustEmbedUnimplementedCasbinSourceServiceServer() { - // This method is useless, - // it is just automatically generated when using the inheritance implementation interface -} - -func permissionResourceQuery(query *ent.PermissionQuery) { - query.WithResources() -} -func (c casbinSourceRepo) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { - rolePermissions, err := c.data.RolePermission(ctx).Query().WithPermission(permissionResourceQuery).WithRole().All(ctx) - if err != nil { - return nil, err - } - var rules []*pb.PolicyRule - for _, rolePermission := range rolePermissions { - permission, err := rolePermission.Edges.PermissionOrErr() - if err != nil { - continue - } - resources, err := permission.Edges.ResourcesOrErr() - if err != nil { - continue - } - for _, resource := range resources { - if resource.Type != "A" && resource.Type != "B" { - continue - } - rules = append(rules, &pb.PolicyRule{ - PType: "p", - Params: []string{ - c.config.PrefixNumberID("role", rolePermission.RoleID), - resource.Path, - resource.Method, - "*", - }, - }) - } - } - return &pb.ListPoliciesResponse{Rules: rules}, nil -} - -func (c casbinSourceRepo) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { - userRoles, err := c.data.UserRole(ctx).Query().All(ctx) - if err != nil { - return nil, err - } - var rules []*pb.GroupingRule - for _, userRole := range userRoles { - rules = append(rules, &pb.GroupingRule{ - PType: "g", - Params: []string{ - c.config.PrefixNumberID("user", userRole.UserID), - c.config.PrefixNumberID("role", userRole.RoleID), - //todo: add domain support - "*", - }, - }) - } - return &pb.ListGroupingsResponse{ - Rules: rules, - }, nil -} - -// NewCasbinSourceRepo returns a new CasbinSourceRepo -func NewCasbinSourceRepo(r runtime.Runtime, db *data.Data) (dto.CasbinSourceRepo, error) { - c := &casbinSourceRepo{ - data: db, - config: &CasbinSourceConfig{ - PrefixNumberID: func(prefix string, id int64) string { - return prefix + "_" + strconv.FormatInt(id, 10) - }, - }, - } - return c, nil -} - -// NewCasbinSourceWithClient create a new CasbinSourceRepo with given client. -// This method does not ensure the existence of database, user should create database manually. -func NewCasbinSourceWithClient(client *ent.Client) (dto.CasbinSourceRepo, error) { - c := &casbinSourceRepo{ - data: data.NewDataWithClient(client), - config: &CasbinSourceConfig{ - PrefixNumberID: func(prefix string, id int64) string { - return prefix + "_" + strconv.FormatInt(id, 10) - }, - }, - } - return c, nil -} diff --git a/internal/mods/system/dal/login.dal.go b/internal/mods/system/dal/login.dal.go deleted file mode 100644 index 6e0589ad..00000000 --- a/internal/mods/system/dal/login.dal.go +++ /dev/null @@ -1,429 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "bytes" - "fmt" - "sync" - - kerr "github.com/go-kratos/kratos/v2/errors" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - jwtv1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" - securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" - "github.com/origadmin/runtime/interfaces/security" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/rand" - "github.com/origadmin/toolkits/errors/httperr" - - "origadmin/application/admin/internal/data/entity/ent/user" - - "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/captcha" - "origadmin/application/admin/helpers/resp" - "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/mods/system/dto" - systemdto "origadmin/application/admin/internal/mods/system/dto" -) - -type loginRepo struct { - *LoginData - captcha *captcha.Captcha - bufpool *sync.Pool -} - -func (repo loginRepo) TokenRefresh(ctx context.Context, in *dto.TokenRefreshRequest) (*dto.TokenRefreshResponse, error) { - log.Debugf("Token refresh request received with data: %+v", in.GetData()) - return repo.refreshToken(ctx, in.GetData().GetRefreshToken()) -} - -func (repo loginRepo) Register(ctx context.Context, in *dto.RegisterRequest) (*dto.RegisterResponse, error) { - log.Debugf("Register request received with data: %+v", in.GetData()) - data := in.GetData() - var err error - createUser := new(dto.UserPB) - createUser, _, err = dto.MakeCreateUser(createUser, data.GetUsername(), data.GetPassword(), dto.UserMutationOption{}) - if err != nil { - return nil, err - } - if _, err := repo.User.Create(ctx, createUser); err != nil { - return nil, err - } - - return &dto.RegisterResponse{ - Success: true, - Data: &system.RegisterResponse_Data{ - Redirect: "", - }, - }, nil -} - -func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.LoginResponse, error) { - log.Debugf("Login request received with data: %+v", in.GetData()) - data := in.GetData() - - // verify captcha - log.Debugf("Verifying captcha with id %s and code %s", data.CaptchaId, data.CaptchaCode) - if !repo.captcha.Store.Verify(data.CaptchaId, data.CaptchaCode, true) { - log.Warnf("Invalid captcha id %s or code %s", data.CaptchaId, data.CaptchaCode) - return nil, dto.ErrInvalidCaptchaID - } - - if root := repo.rootUser(); root.GetEnabled() { - log.Debugf("Root userData is enabled, checking if username matches") - // login by root - username := root.Username - if data.Username == username { - log.Debugf("Username matches, checking password") - if err := hash.Verify(root.Password, data.Password); err != nil { - log.Warnf("Invalid password for root userData") - return nil, dto.ErrInvalidPassword - } - - userID := root.Id - ctx = context.NewID(ctx, root.Id) - log.Infof("Login by root successful, userData ID: %s", userID) - return repo.genToken(ctx, userID) - } - } - - // get user info - log.Debugf("Getting userData info for username %s", data.Username) - userData, err := repo.User.GetByUsername(ctx, data.Username, user.FieldID, user.FieldEncryptedPassword, user.FieldStatus) - if err != nil { - log.Errorf("Error getting userData info: %v", err) - return nil, err - } - switch { - case userData == nil: - log.Warnf("User not found with username %s", data.Username) - return nil, dto.ErrInvalidUsername - case userData.Status != systemdto.UserStatusActive: - log.Warnf("User %s is not activated", data.Username) - return nil, httperr.New("unknown", 400, "User status is not activated, please contact the administrator") - default: - log.Debugf("User found with ID %d and status %d", userData.Id, userData.Status) - } - - // check password - log.Debugf("Comparing password for userData %s", data.Username) - if err := hash.Verify(userData.EncryptedPassword, data.Password); err != nil { - log.Warnf("Invalid password for userData %s", data.Username) - return nil, dto.ErrInvalidPassword - } - - userUUID := userData.Uuid - username := userData.Username - ctx = context.NewID(ctx, userUUID) - - // set userData cache with role ids - log.Debugf("Getting role IDs for userData %s", username) - roleIDs, err := repo.User.GetRoleIDs(ctx, userData.Id) - if err != nil { - log.Errorf("Error getting role IDs: %v", err) - return nil, kerr.Newf(404, "UNKNOWN", "failed to get userData role ids: %v", err) - } - - log.Infof("User %s logged in successfully with role ids: %v", username, roleIDs) - // generate token - log.Debugf("Generating token for userData %s", username) - return repo.genToken(ctx, userUUID) -} -func (repo loginRepo) CaptchaAudio(ctx context.Context, id string, reload bool) (*dto.CaptchaAudioResponse, error) { - var err error - log.Debugf("Generating captcha audio with id %s and reload %v", id, reload) - if reload && !repo.captcha.Reload(captcha.TypeAudio, id) { - log.Warnf("Captcha id %s not found during reload, regenerating", id) - id, err = repo.getCaptchaID() - if err != nil { - return nil, err - } - } - content := repo.captcha.Store.Get(id, false) - item, err := repo.captcha.DriverAudio.Driver.DrawCaptcha(content) - if err != nil { - return nil, err - } - buf := repo.getBuf() - _, err = item.WriteTo(buf) - if err != nil { - return nil, err - } - response := new(dto.CaptchaAudioResponse) - response.Headers = map[string]string{ - "Cache-Control": "no-cache, no-store, must-revalidate", - "Pragma": "no-cache", - "Expires": "0", - "Content-Type": captcha.MimeTypeAudio, - } - response.Audio = buf.Bytes() - return response, nil -} - -func (repo loginRepo) CaptchaImage(ctx context.Context, id string, reload bool) (*dto.CaptchaImageResponse, error) { - log.Debugf("Generating captcha image with id %s and reload %v", id, reload) - var err error - if reload && !repo.captcha.Reload(captcha.TypeDigit, id) { - log.Warnf("Captcha id %s not found during reload, regenerating", id) - id, err = repo.getCaptchaID() - if err != nil { - return nil, err - } - } - content := repo.captcha.Store.Get(id, false) - item, err := repo.captcha.DriverDigit.Driver.DrawCaptcha(content) - if err != nil { - return nil, err - } - buf := repo.getBuf() - _, err = item.WriteTo(buf) - if err != nil { - return nil, err - } - log.Debugf("Captcha image generated successfully") - response := new(dto.CaptchaImageResponse) - response.Headers = map[string]string{ - "Cache-Control": "no-cache, no-store, must-revalidate", - "Pragma": "no-cache", - "Expires": "0", - "Content-Type": captcha.MimeTypeImage, - } - response.Image = buf.Bytes() - log.Debugf("Returning captcha image response with headers: %+v", response.Headers) - return response, nil -} - -func (repo loginRepo) CurrentUser(ctx context.Context, in *dto.CurrentUserRequest) (*dto.CurrentUserResponse, error) { - current, err := repo.User.Current(ctx, in.GetData().GetUserId()) - if err != nil { - return nil, err - } - return &dto.CurrentUserResponse{ - Data: resp.Any(current), - }, nil -} - -func (repo loginRepo) Logout(ctx context.Context, in *dto.LogoutRequest) (*dto.LogoutResponse, error) { - return &dto.LogoutResponse{}, nil -} - -func (repo loginRepo) CaptchaID(ctx context.Context, in *dto.CaptchaIDRequest) (*dto.CaptchaIDResponse, error) { - id, err := repo.getCaptchaID() - if err != nil { - return nil, err - } - return &dto.CaptchaIDResponse{ - Data: id, - }, nil -} - -func (repo loginRepo) Captcha(ctx context.Context, in *dto.CaptchaRequest) (*dto.CaptchaResponse, error) { - var err error - var id = in.Id - if id == "" { - id, err = repo.getCaptchaID() - if err != nil { - return nil, err - } - } - driver, err := repo.getCaptchaDriver(in.Type) - if err != nil { - return nil, err - } - if in.Reload && in.Id != "" && !repo.captcha.Reload(in.Type, in.Id) { - log.Warnf("Captcha id %s not found during reload, regenerating id", id) - id, err = repo.getCaptchaID() - if err != nil { - return nil, err - } - } - data, err := repo.getCaptchaData(driver, id) - if err != nil { - return nil, err - } - return &dto.CaptchaResponse{ - Id: id, - Type: in.Type, - Data: data, - }, nil -} - -func (repo loginRepo) getCaptchaID() (string, error) { - id, _, answ, err := repo.captcha.DriverDigit.Generate() - if err != nil { - return "", err - } - log.Debugf("Generated captcha with id %s and answer %s", id, answ) - return id, nil -} - -func (repo loginRepo) FreeBuf(buf *bytes.Buffer) { - repo.putBuf(buf) -} - -func (repo loginRepo) getBuf() *bytes.Buffer { - return repo.bufpool.Get().(*bytes.Buffer) -} - -func (repo loginRepo) putBuf(buf *bytes.Buffer) { - buf.Reset() - repo.bufpool.Put(buf) -} - -func (repo loginRepo) refreshToken(ctx context.Context, token string) (*dto.TokenRefreshResponse, error) { - claims, err := repo.Tokenizer.ParseClaims(ctx, token) - if err != nil { - return nil, err - } - genToken, err := repo.genToken(ctx, claims.GetSubject()) - if err != nil { - return nil, err - } - return &dto.TokenRefreshResponse{ - Token: genToken.Token, - }, nil -} - -func (repo loginRepo) genToken(ctx context.Context, id string) (*dto.LoginResponse, error) { - claims, err := repo.Tokenizer.CreateClaims(ctx, id) - if err != nil { - return nil, err - } - token, err := repo.Tokenizer.CreateToken(ctx, claims) - if err != nil { - return nil, err - } - refreshClaims, err := repo.Tokenizer.CreateRefreshClaims(ctx, id) - if err != nil { - return nil, err - } - refreshToken, err := repo.Tokenizer.CreateToken(ctx, refreshClaims) - if err != nil { - return nil, err - } - return &dto.LoginResponse{ - Token: &jwtv1.Token{ - UserId: id, - AccessToken: token, - RefreshToken: refreshToken, - ExpirationTime: claims.GetExpiration(), - }, - }, nil -} - -func fromSecurityClaims(claims security.Claims) *securityv1.Claims { - return &securityv1.Claims{ - Sub: claims.GetSubject(), - Iss: claims.GetIssuer(), - Aud: claims.GetAudience(), - Exp: claims.GetExpiration(), - Nbf: claims.GetNotBefore(), - Iat: claims.GetIssuedAt(), - Jti: claims.GetID(), - Scopes: claims.GetScopes(), - } -} - -func RefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { - if rt, ok := tokenizer.(security.RefreshTokenizer); ok { - return rt - } - return wrapRefreshTokenizer(tokenizer) -} - -func (repo loginRepo) rootUser() *configs.RootUser { - return repo.LoginData.RootUser -} - -func (repo loginRepo) getCaptchaDriver(typ string) (captcha.Driver, error) { - var driver captcha.Driver - switch typ { - case captcha.TypeAudio: - driver = repo.captcha.DriverAudio.Driver - default: - driver = repo.captcha.DriverDigit.Driver - } - log.Debugf("Captcha audio generated successfully") - return driver, nil -} - -func (repo loginRepo) getCaptchaData(driver captcha.Driver, id string) (string, error) { - content := repo.captcha.Store.Get(id, false) - item, err := driver.DrawCaptcha(content) - if err != nil { - return "", err - } - return item.EncodeB64string(), nil -} - -func (repo loginRepo) getCaptchaAudio(id string) (string, error) { - log.Debugf("Writing captcha audio to buffer with id %s", id) - content := repo.captcha.Store.Get(id, false) - item, err := repo.captcha.DriverAudio.Driver.DrawCaptcha(content) - if err != nil { - return "", err - } - log.Debugf("Captcha audio generated successfully") - return item.EncodeB64string(), nil -} - -func (repo loginRepo) getCaptchaImage(id string) (string, error) { - log.Debugf("Writing captcha image to buffer with id %s", id) - content := repo.captcha.Store.Get(id, false) - item, err := repo.captcha.DriverDigit.Driver.DrawCaptcha(content) - if err != nil { - return "", err - } - log.Debugf("Captcha image generated successfully") - return item.EncodeB64string(), nil -} - -type LoginData struct { - Captcha *configs.Captcha - RootUser *configs.RootUser - Tokenizer security.RefreshTokenizer - Resource systemdto.ResourceRepo - Role systemdto.RoleRepo - User systemdto.UserRepo -} - -// NewLoginRepo . -func NewLoginRepo(r runtime.Runtime, data *LoginData) dto.LoginRepo { - var err error - cfg := data.RootUser - // todo: generate random password for root user if not exists - if cfg.RandomPassword { - passwd := rand.GenerateRandom(12) - cfg.Password, err = hash.Generate(passwd) - if err == nil { - fmt.Println("Root user password:", passwd) - } else { - log.Errorf("Error generating password: %v", err) - cfg.RandomPassword = false - } - } - if cfg.Id == "" { - cfg.Id = cfg.Username - } - //authenticator, err := jwt.NewAuthenticator(&configv1.Security{}) - //if err != nil { - // panic(err) - //} - return &loginRepo{ - bufpool: BufPool(), - LoginData: data, - //captcha: NewCaptcha(data.Captcha), - } -} - -func BufPool() *sync.Pool { - return &sync.Pool{ - New: func() interface{} { - return &bytes.Buffer{} - }, - } -} diff --git a/internal/mods/system/dal/personal.dal.go b/internal/mods/system/dal/personal.dal.go index 7ea4c065..b07ca0d6 100644 --- a/internal/mods/system/dal/personal.dal.go +++ b/internal/mods/system/dal/personal.dal.go @@ -12,6 +12,7 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" + typespb "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/helpers/securityx" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" @@ -31,7 +32,7 @@ func (repo personalRepo) GetPersonalProfile(ctx context.Context, in *pb.GetPerso } if userid == "admin" { return &pb.GetPersonalProfileResponse{ - User: &pb.User{ + User: &typespb.User{ Id: 0, Uuid: "admin", Username: "admin", From e9946625eea78491398a2624878a1b3741ab9d22 Mon Sep 17 00:00:00 2001 From: godcong Date: Sat, 31 May 2025 04:23:37 +0800 Subject: [PATCH 032/158] refactor(configs): rename and restructure configuration files - Rename bootstrap.toml from system to admin directory - Update service name in bootstrap.toml from "origadmin.agent.service.admin.v1" to "origadmin.proxy.service.admin.v1" - Add new configuration files for admin, auth, common, and storage - Update middleware configuration to use new structure - Adjust security settings to use casbin for authorization and jwt for authentication --- .../configs/{system => admin}/bootstrap.toml | 2 +- .../configs/{system => admin}/discovery.toml | 0 .../configs/{system => admin}/logger.toml | 0 .../configs/{system => admin}/middleware.toml | 0 .../configs/{system => admin}/security.toml | 0 resources/configs/admin/service.toml | 213 ++++++++++++++++++ .../configs/{system => admin}/storage.toml | 0 resources/configs/auth/service.toml | 213 ++++++++++++++++++ resources/configs/common/bootstrap.toml | 9 + resources/configs/common/discovery.toml | 14 ++ resources/configs/common/logger.toml | 19 ++ resources/configs/common/middleware.toml | 34 +++ resources/configs/common/security.toml | 19 ++ resources/configs/common/storage.toml | 46 ++++ 14 files changed, 568 insertions(+), 1 deletion(-) rename resources/configs/{system => admin}/bootstrap.toml (75%) rename resources/configs/{system => admin}/discovery.toml (100%) rename resources/configs/{system => admin}/logger.toml (100%) rename resources/configs/{system => admin}/middleware.toml (100%) rename resources/configs/{system => admin}/security.toml (100%) create mode 100644 resources/configs/admin/service.toml rename resources/configs/{system => admin}/storage.toml (100%) create mode 100644 resources/configs/auth/service.toml create mode 100644 resources/configs/common/bootstrap.toml create mode 100644 resources/configs/common/discovery.toml create mode 100644 resources/configs/common/logger.toml create mode 100644 resources/configs/common/middleware.toml create mode 100644 resources/configs/common/security.toml create mode 100644 resources/configs/common/storage.toml diff --git a/resources/configs/system/bootstrap.toml b/resources/configs/admin/bootstrap.toml similarity index 75% rename from resources/configs/system/bootstrap.toml rename to resources/configs/admin/bootstrap.toml index ecfa5f02..fcc935f9 100644 --- a/resources/configs/system/bootstrap.toml +++ b/resources/configs/admin/bootstrap.toml @@ -1,4 +1,4 @@ -Name = "origadmin.agent.service.admin.v1" +Name = "origadmin.proxy.service.admin.v1" Version = "v1.0.0" CryptoType = "argon2" Mode = "singleton" diff --git a/resources/configs/system/discovery.toml b/resources/configs/admin/discovery.toml similarity index 100% rename from resources/configs/system/discovery.toml rename to resources/configs/admin/discovery.toml diff --git a/resources/configs/system/logger.toml b/resources/configs/admin/logger.toml similarity index 100% rename from resources/configs/system/logger.toml rename to resources/configs/admin/logger.toml diff --git a/resources/configs/system/middleware.toml b/resources/configs/admin/middleware.toml similarity index 100% rename from resources/configs/system/middleware.toml rename to resources/configs/admin/middleware.toml diff --git a/resources/configs/system/security.toml b/resources/configs/admin/security.toml similarity index 100% rename from resources/configs/system/security.toml rename to resources/configs/admin/security.toml diff --git a/resources/configs/admin/service.toml b/resources/configs/admin/service.toml new file mode 100644 index 00000000..5a82f054 --- /dev/null +++ b/resources/configs/admin/service.toml @@ -0,0 +1,213 @@ +[[Server.Services]] +Name = "" +Type = "grpc" +DynamicEndpoint = true +[Server.Services.Grpc] +Network = "tcp" +Addr = "${grpc_address:0.0.0.0:18000}" +UseTls = false +Timeout = 0 +ShutdownTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +IdleTimeout = 0 +Endpoint = "" +[Server.Services.Websocket] +Network = "" +Addr = "" +Path = "" +Codec = "" +Timeout = 0 +[Server.Services.Message] +Type = "none" +Name = "" +[Server.Services.Message.Mqtt] +Endpoint = "" +Codec = "" +[Server.Services.Message.Kafka] +Endpoint = "" +Codec = "" +[Server.Services.Message.Rabbitmq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Activemq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Nats] +Endpoint = "" +Codec = "" +[Server.Services.Message.Nsq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Pulsar] +Endpoint = "" +Codec = "" +[Server.Services.Message.Redis] +Endpoint = "" +Codec = "" +[Server.Services.Message.Rocketmq] +Endpoint = "" +Codec = "" +EnableTrace = false +NameServerDomain = "" +AccessKey = "" +SecretKey = "" +SecurityToken = "" +Namespace = "" +InstanceName = "" +GroupName = "" +[Server.Services.Task] +Type = "none" +Name = "" +[Server.Services.Task.Asynq] +Endpoint = "" +Password = "" +Db = 0 +Location = "" +[Server.Services.Task.Machinery] +[Server.Services.Task.Cron] +Addr = "" +[Server.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Server.Services.Middleware.Metadata] +Enabled = true +Prefix = "" +[Server.Services.Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Server.Services.Middleware.Metrics] +Enabled = true +[Server.Services.Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Server.Services.Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Server.Services.Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Server.Services.Middleware.Selector] +Enabled = false +Regex = "" +[Server.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" + +[[Server.Services]] +Name = "" +Type = "http" +DynamicEndpoint = true +[Server.Services.Http] +Network = "tcp" +Addr = "${http_address:0.0.0.0:18100}" +UseTls = false +Timeout = 0 +ShutdownTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +IdleTimeout = 0 +Endpoint = "" +[Server.Services.Websocket] +Network = "" +Addr = "" +Path = "" +Codec = "" +Timeout = 0 +[Server.Services.Message] +Type = "none" +Name = "" +[Server.Services.Message.Mqtt] +Endpoint = "" +Codec = "" +[Server.Services.Message.Kafka] +Endpoint = "" +Codec = "" +[Server.Services.Message.Rabbitmq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Activemq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Nats] +Endpoint = "" +Codec = "" +[Server.Services.Message.Nsq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Pulsar] +Endpoint = "" +Codec = "" +[Server.Services.Message.Redis] +Endpoint = "" +Codec = "" +[Server.Services.Message.Rocketmq] +Endpoint = "" +Codec = "" +EnableTrace = false +NameServerDomain = "" +AccessKey = "" +SecretKey = "" +SecurityToken = "" +Namespace = "" +InstanceName = "" +GroupName = "" +[Server.Services.Task] +Type = "none" +Name = "" +[Server.Services.Task.Asynq] +Endpoint = "" +Password = "" +Db = 0 +Location = "" +[Server.Services.Task.Machinery] +[Server.Services.Task.Cron] +Addr = "" +[Server.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Server.Services.Middleware.Metadata] +Enabled = true +Prefix = "" +[Server.Services.Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Server.Services.Middleware.Metrics] +Enabled = true +[Server.Services.Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Server.Services.Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Server.Services.Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Server.Services.Middleware.Selector] +Enabled = false +Regex = "" +[Server.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" diff --git a/resources/configs/system/storage.toml b/resources/configs/admin/storage.toml similarity index 100% rename from resources/configs/system/storage.toml rename to resources/configs/admin/storage.toml diff --git a/resources/configs/auth/service.toml b/resources/configs/auth/service.toml new file mode 100644 index 00000000..5a82f054 --- /dev/null +++ b/resources/configs/auth/service.toml @@ -0,0 +1,213 @@ +[[Server.Services]] +Name = "" +Type = "grpc" +DynamicEndpoint = true +[Server.Services.Grpc] +Network = "tcp" +Addr = "${grpc_address:0.0.0.0:18000}" +UseTls = false +Timeout = 0 +ShutdownTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +IdleTimeout = 0 +Endpoint = "" +[Server.Services.Websocket] +Network = "" +Addr = "" +Path = "" +Codec = "" +Timeout = 0 +[Server.Services.Message] +Type = "none" +Name = "" +[Server.Services.Message.Mqtt] +Endpoint = "" +Codec = "" +[Server.Services.Message.Kafka] +Endpoint = "" +Codec = "" +[Server.Services.Message.Rabbitmq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Activemq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Nats] +Endpoint = "" +Codec = "" +[Server.Services.Message.Nsq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Pulsar] +Endpoint = "" +Codec = "" +[Server.Services.Message.Redis] +Endpoint = "" +Codec = "" +[Server.Services.Message.Rocketmq] +Endpoint = "" +Codec = "" +EnableTrace = false +NameServerDomain = "" +AccessKey = "" +SecretKey = "" +SecurityToken = "" +Namespace = "" +InstanceName = "" +GroupName = "" +[Server.Services.Task] +Type = "none" +Name = "" +[Server.Services.Task.Asynq] +Endpoint = "" +Password = "" +Db = 0 +Location = "" +[Server.Services.Task.Machinery] +[Server.Services.Task.Cron] +Addr = "" +[Server.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Server.Services.Middleware.Metadata] +Enabled = true +Prefix = "" +[Server.Services.Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Server.Services.Middleware.Metrics] +Enabled = true +[Server.Services.Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Server.Services.Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Server.Services.Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Server.Services.Middleware.Selector] +Enabled = false +Regex = "" +[Server.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" + +[[Server.Services]] +Name = "" +Type = "http" +DynamicEndpoint = true +[Server.Services.Http] +Network = "tcp" +Addr = "${http_address:0.0.0.0:18100}" +UseTls = false +Timeout = 0 +ShutdownTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +IdleTimeout = 0 +Endpoint = "" +[Server.Services.Websocket] +Network = "" +Addr = "" +Path = "" +Codec = "" +Timeout = 0 +[Server.Services.Message] +Type = "none" +Name = "" +[Server.Services.Message.Mqtt] +Endpoint = "" +Codec = "" +[Server.Services.Message.Kafka] +Endpoint = "" +Codec = "" +[Server.Services.Message.Rabbitmq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Activemq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Nats] +Endpoint = "" +Codec = "" +[Server.Services.Message.Nsq] +Endpoint = "" +Codec = "" +[Server.Services.Message.Pulsar] +Endpoint = "" +Codec = "" +[Server.Services.Message.Redis] +Endpoint = "" +Codec = "" +[Server.Services.Message.Rocketmq] +Endpoint = "" +Codec = "" +EnableTrace = false +NameServerDomain = "" +AccessKey = "" +SecretKey = "" +SecurityToken = "" +Namespace = "" +InstanceName = "" +GroupName = "" +[Server.Services.Task] +Type = "none" +Name = "" +[Server.Services.Task.Asynq] +Endpoint = "" +Password = "" +Db = 0 +Location = "" +[Server.Services.Task.Machinery] +[Server.Services.Task.Cron] +Addr = "" +[Server.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Server.Services.Middleware.Metadata] +Enabled = true +Prefix = "" +[Server.Services.Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Server.Services.Middleware.Metrics] +Enabled = true +[Server.Services.Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Server.Services.Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Server.Services.Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Server.Services.Middleware.Selector] +Enabled = false +Regex = "" +[Server.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" diff --git a/resources/configs/common/bootstrap.toml b/resources/configs/common/bootstrap.toml new file mode 100644 index 00000000..fcc935f9 --- /dev/null +++ b/resources/configs/common/bootstrap.toml @@ -0,0 +1,9 @@ +Name = "origadmin.proxy.service.admin.v1" +Version = "v1.0.0" +CryptoType = "argon2" +Mode = "singleton" +EnableDynamicConfig = false +Id = "" +Environment = "" +Services = [] + diff --git a/resources/configs/common/discovery.toml b/resources/configs/common/discovery.toml new file mode 100644 index 00000000..c631db24 --- /dev/null +++ b/resources/configs/common/discovery.toml @@ -0,0 +1,14 @@ +[Discovery] +Type = "consul" +ServiceName = "" +Debug = false +[Discovery.Consul] +Address = "${consul_address:127.0.0.1:8500}" +Scheme = "http" +Token = "" +HeartBeat = true +HealthCheck = true +Datacenter = "" +HealthCheckInterval = 30 +Timeout = 0 +DeregisterCriticalServiceAfter = 0 \ No newline at end of file diff --git a/resources/configs/common/logger.toml b/resources/configs/common/logger.toml new file mode 100644 index 00000000..af585f23 --- /dev/null +++ b/resources/configs/common/logger.toml @@ -0,0 +1,19 @@ +[Logger] +Disabled = false +Develop = true +Default = true +Name = "" +Format = "json" +Level = "info" +Stdout = true +DisableCaller = false +CallerSkip = 0 +TimeFormat = "" +[Logger.File] +Path = "logs/output.log" +Lumberjack = true +Compress = false +LocalTime = false +MaxSize = 0 +MaxAge = 0 +MaxBackups = 0 diff --git a/resources/configs/common/middleware.toml b/resources/configs/common/middleware.toml new file mode 100644 index 00000000..d50d0680 --- /dev/null +++ b/resources/configs/common/middleware.toml @@ -0,0 +1,34 @@ +[Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Middleware.Metadata] +Enabled = true +Prefix = "" +[Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Middleware.Metrics] +Enabled = true +[Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "wSX^6C1d2HM%K9D_H6I*YPZVMa3^Gvhj" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Middleware.Selector] +Enabled = false +Regex = "" diff --git a/resources/configs/common/security.toml b/resources/configs/common/security.toml new file mode 100644 index 00000000..34bc19e0 --- /dev/null +++ b/resources/configs/common/security.toml @@ -0,0 +1,19 @@ +[Security] +[Security.Security] +PublicPaths = ["/swagger/*", "/api/v1/health", "/api/v1/health/*", "/api/v1/captcha", "/api/v1/captcha/*", "/api/v1/login", "/api/v1/register", "/api/v1/current/logout", "/api/v1/refresh_token", "/api.v1.services.system.LoginAPI/CaptchaId", "/api.v1.services.system.LoginAPI/CaptchaImage", "/api.v1.services.system.LoginAPI/CaptchaResource", "/api.v1.services.system.LoginAPI/CaptchaResources", "/api.v1.services.system.LoginAPI/Login", "/api.v1.services.system.LoginAPI/Register", "/api.v1.services.system.LoginAPI/Refresh"] +[Security.Security.Authz] +Disabled = false +Type = "casbin" +[Security.Security.Authz.Casbin] +PolicyFile = "" +ModelFile = "" +[Security.Security.Authn] +Disabled = false +Type = "jwt" +[Security.Security.Authn.Jwt] +Algorithm = "HS512" +SigningKey = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +OldSigningKey = "" +ExpireTime = 0 +RefreshTime = 0 +CacheName = "" diff --git a/resources/configs/common/storage.toml b/resources/configs/common/storage.toml new file mode 100644 index 00000000..15906e90 --- /dev/null +++ b/resources/configs/common/storage.toml @@ -0,0 +1,46 @@ +[Storage] +Name = "" +Type = "" +[Storage.Database] +Debug = false +Dialect = "sqlite3" +Source = "data/admin.db" +EnableTrace = false +EnableMetrics = false +MaxIdleConnections = 0 +MaxOpenConnections = 0 +ConnectionMaxLifetime = 0 +ConnectionMaxIdleTime = 0 +[Storage.Database.Migration] +Enabled = false +Path = "" +Version = "" +Mode = "" +[Storage.Cache] +Driver = "memory" +Name = "" +[Storage.Cache.Memcached] +Addr = "" +Username = "" +Password = "" +MaxIdle = 0 +Timeout = 0 +[Storage.Cache.Memory] +Size = 0 +Capacity = 0 +Expiration = 0 +CleanupInterval = 0 +[Storage.Cache.Redis] +Network = "" +Addr = "" +Password = "" +Db = 0 +DialTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +[Storage.Cache.Badger] +Path = "" +SyncWrites = false +ValueLogFileSize = 0 +InMemory = false +LogLevel = 0 \ No newline at end of file From 0b37d9e09cc719fea2d1df86ecb5ef870f5e01b7 Mon Sep 17 00:00:00 2001 From: godcong Date: Sat, 31 May 2025 04:35:18 +0800 Subject: [PATCH 033/158] config: update database settings and API server port - Update database configuration to use environment variables --- resources/configs/common/storage.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/configs/common/storage.toml b/resources/configs/common/storage.toml index 15906e90..6734f091 100644 --- a/resources/configs/common/storage.toml +++ b/resources/configs/common/storage.toml @@ -3,8 +3,8 @@ Name = "" Type = "" [Storage.Database] Debug = false -Dialect = "sqlite3" -Source = "data/admin.db" +Dialect = "${database_dialect:sqlite3}" +Source = "${database_source:data/admin.db}" EnableTrace = false EnableMetrics = false MaxIdleConnections = 0 From 4980033d37dedd87764768f5c8cdc01a6b9664cb Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 3 Jun 2025 14:13:45 +0800 Subject: [PATCH 034/158] refactor(api): rename and restructure API services - Rename system package to types for better naming convention - Update API services to use new package structure - Remove unused error.proto file - Add new auth command and wire configuration --- api/v1/proto/{system => types}/error.proto | 9 +- api/v1/proto/types/system.proto | 2 +- api/v1/services/auth/casbin_bridge.pb.go | 27 +- api/v1/services/system/error.pb.go | 196 ----- api/v1/services/system/error.pb.validate.go | 36 - api/v1/services/system/error_errors.pb.go | 240 ------ cmd/auth/main.go | 83 ++ cmd/auth/wire.go | 40 + cmd/auth/wire.work.go | 12 + cmd/auth/wire_gen.go | 52 ++ cmd/internal/start/start.go | 4 +- internal/mods/auth/dal/dal.go | 800 ++++++++++---------- internal/mods/auth/dal/login.dal.go | 2 +- internal/mods/auth/dto/dto.go | 13 + internal/mods/auth/dto/login.go | 63 ++ internal/mods/auth/server/README.md | 4 + internal/mods/auth/server/gins.go | 67 ++ internal/mods/auth/server/grpc.go | 27 + internal/mods/auth/server/http.go | 27 + internal/mods/auth/server/server.go | 138 ++++ internal/mods/auth/service/casbin.http.go | 22 +- internal/mods/auth/service/service.go | 70 ++ 22 files changed, 1033 insertions(+), 901 deletions(-) rename api/v1/proto/{system => types}/error.proto (84%) delete mode 100644 api/v1/services/system/error.pb.go delete mode 100644 api/v1/services/system/error.pb.validate.go delete mode 100644 api/v1/services/system/error_errors.pb.go create mode 100644 cmd/auth/main.go create mode 100644 cmd/auth/wire.go create mode 100644 cmd/auth/wire.work.go create mode 100644 cmd/auth/wire_gen.go create mode 100644 internal/mods/auth/server/README.md create mode 100644 internal/mods/auth/server/gins.go create mode 100644 internal/mods/auth/server/grpc.go create mode 100644 internal/mods/auth/server/http.go create mode 100644 internal/mods/auth/server/server.go create mode 100644 internal/mods/auth/service/service.go diff --git a/api/v1/proto/system/error.proto b/api/v1/proto/types/error.proto similarity index 84% rename from api/v1/proto/system/error.proto rename to api/v1/proto/types/error.proto index cbaef087..b66749aa 100644 --- a/api/v1/proto/system/error.proto +++ b/api/v1/proto/types/error.proto @@ -1,13 +1,14 @@ syntax = "proto3"; -package api.v1.services.system; +package api.v1.services.types; import "errors/errors.proto"; -option go_package = "api/v1/services/system;system"; +option go_package = "origadmin/application/admin/api/v1/services/types;types"; option java_multiple_files = true; -option java_package = "com.origadmin.api.v1.services.system"; -option objc_class_prefix = "APIV1ServicesSystem"; +option java_outer_classname = "APIServiceTypeSystemProto"; +option java_package = "com.origadmin.api.v1.services.types"; +option objc_class_prefix = "APIServiceType"; enum SystemErrorReason { option (errors.default_code) = 500; diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index 2247fa1b..f7d3b3d3 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -8,7 +8,7 @@ option go_package = "origadmin/application/admin/api/v1/services/types;types"; option java_multiple_files = true; option java_outer_classname = "APIServiceTypeSystemProto"; option java_package = "com.origadmin.api.v1.services.types"; -option objc_class_prefix = "APIServiceTypeSystem"; +option objc_class_prefix = "APIServiceType"; // Menu is the model entity for the Menu schema. message Menu { diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index 2600aaa9..c41b2e89 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -7,11 +7,9 @@ package auth import ( - "context" - "io" - - "github.com/go-kratos/kratos/v2/transport/http" - "google.golang.org/grpc" + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" ) // This is a compile-time assertion to ensure that this generated file @@ -203,25 +201,6 @@ func NewCasbinSourceServiceBridge(client grpc.ClientConnInterface) CasbinSourceS return &CasbinSourceServiceBridgeImpl{client: NewCasbinSourceServiceClient(client)} } -func (c *CasbinSourceServiceBridgeImpl) StreamRules(req *StreamRulesRequest, srv grpc.ServerStreamingServer[StreamRulesResponse]) error { - client, err := c.client.StreamRules(srv.Context(), req) - if err != nil { - return err - } - for { - resp, err := client.Recv() - if err != nil { - if err == io.EOF { - return nil - } - return err - } - if err := srv.Send(resp); err != nil { - return err - } - } -} - func (c *CasbinSourceServiceBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { return c.client.ListGroupings(ctx, in) } diff --git a/api/v1/services/system/error.pb.go b/api/v1/services/system/error.pb.go deleted file mode 100644 index 9953b447..00000000 --- a/api/v1/services/system/error.pb.go +++ /dev/null @@ -1,196 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc (unknown) -// source: system/error.proto - -package system - -import ( - _ "github.com/go-kratos/kratos/v2/errors" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type SystemErrorReason int32 - -const ( - SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED SystemErrorReason = 0 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND SystemErrorReason = 2001 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS SystemErrorReason = 2002 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN SystemErrorReason = 2003 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT SystemErrorReason = 2004 - SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED SystemErrorReason = 2005 - SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND SystemErrorReason = 2006 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN SystemErrorReason = 2007 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS SystemErrorReason = 2008 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION SystemErrorReason = 2009 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION SystemErrorReason = 2010 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST SystemErrorReason = 2011 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE SystemErrorReason = 2012 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER SystemErrorReason = 2013 - SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND SystemErrorReason = 1001 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID SystemErrorReason = 1002 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE SystemErrorReason = 1003 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME SystemErrorReason = 1005 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD SystemErrorReason = 1006 -) - -// Enum value maps for SystemErrorReason. -var ( - SystemErrorReason_name = map[int32]string{ - 0: "SYSTEM_ERROR_REASON_UNSPECIFIED", - 2001: "SYSTEM_ERROR_REASON_USER_NOT_FOUND", - 2002: "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS", - 2003: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN", - 2004: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT", - 2005: "SYSTEM_ERROR_REASON_TOKEN_EXPIRED", - 2006: "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND", - 2007: "SYSTEM_ERROR_REASON_INVALID_TOKEN", - 2008: "SYSTEM_ERROR_REASON_INVALID_CLAIMS", - 2009: "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION", - 2010: "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION", - 2011: "SYSTEM_ERROR_REASON_INVALID_REQUEST", - 2012: "SYSTEM_ERROR_REASON_INVALID_RESPONSE", - 2013: "SYSTEM_ERROR_REASON_INVALID_SERVER", - 1001: "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND", - 1002: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID", - 1003: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE", - 1005: "SYSTEM_ERROR_REASON_INVALID_USERNAME", - 1006: "SYSTEM_ERROR_REASON_INVALID_PASSWORD", - } - SystemErrorReason_value = map[string]int32{ - "SYSTEM_ERROR_REASON_UNSPECIFIED": 0, - "SYSTEM_ERROR_REASON_USER_NOT_FOUND": 2001, - "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS": 2002, - "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN": 2003, - "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT": 2004, - "SYSTEM_ERROR_REASON_TOKEN_EXPIRED": 2005, - "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND": 2006, - "SYSTEM_ERROR_REASON_INVALID_TOKEN": 2007, - "SYSTEM_ERROR_REASON_INVALID_CLAIMS": 2008, - "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION": 2009, - "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION": 2010, - "SYSTEM_ERROR_REASON_INVALID_REQUEST": 2011, - "SYSTEM_ERROR_REASON_INVALID_RESPONSE": 2012, - "SYSTEM_ERROR_REASON_INVALID_SERVER": 2013, - "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND": 1001, - "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID": 1002, - "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE": 1003, - "SYSTEM_ERROR_REASON_INVALID_USERNAME": 1005, - "SYSTEM_ERROR_REASON_INVALID_PASSWORD": 1006, - } -) - -func (x SystemErrorReason) Enum() *SystemErrorReason { - p := new(SystemErrorReason) - *p = x - return p -} - -func (x SystemErrorReason) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SystemErrorReason) Descriptor() protoreflect.EnumDescriptor { - return file_system_error_proto_enumTypes[0].Descriptor() -} - -func (SystemErrorReason) Type() protoreflect.EnumType { - return &file_system_error_proto_enumTypes[0] -} - -func (x SystemErrorReason) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use SystemErrorReason.Descriptor instead. -func (SystemErrorReason) EnumDescriptor() ([]byte, []int) { - return file_system_error_proto_rawDescGZIP(), []int{0} -} - -var File_system_error_proto protoreflect.FileDescriptor - -const file_system_error_proto_rawDesc = "" + - "\n" + - "\x12system/error.proto\x12\x16api.v1.services.system\x1a\x13errors/errors.proto*\xbf\a\n" + - "\x11SystemErrorReason\x12#\n" + - "\x1fSYSTEM_ERROR_REASON_UNSPECIFIED\x10\x00\x12-\n" + - "\"SYSTEM_ERROR_REASON_USER_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x122\n" + - "'SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS\x10\xd2\x0f\x1a\x04\xa8E\x99\x03\x121\n" + - "&SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN\x10\xd3\x0f\x1a\x04\xa8E\x91\x03\x122\n" + - "'SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT\x10\xd4\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + - "!SYSTEM_ERROR_REASON_TOKEN_EXPIRED\x10\xd5\x0f\x1a\x04\xa8E\x91\x03\x12.\n" + - "#SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND\x10\xd6\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + - "!SYSTEM_ERROR_REASON_INVALID_TOKEN\x10\xd7\x0f\x1a\x04\xa8E\x91\x03\x12-\n" + - "\"SYSTEM_ERROR_REASON_INVALID_CLAIMS\x10\xd8\x0f\x1a\x04\xa8E\x91\x03\x125\n" + - "*SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION\x10\xd9\x0f\x1a\x04\xa8E\x91\x03\x124\n" + - ")SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION\x10\xda\x0f\x1a\x04\xa8E\x93\x03\x12.\n" + - "#SYSTEM_ERROR_REASON_INVALID_REQUEST\x10\xdb\x0f\x1a\x04\xa8E\x90\x03\x12/\n" + - "$SYSTEM_ERROR_REASON_INVALID_RESPONSE\x10\xdc\x0f\x1a\x04\xa8E\xf4\x03\x12-\n" + - "\"SYSTEM_ERROR_REASON_INVALID_SERVER\x10\xdd\x0f\x1a\x04\xa8E\xf4\x03\x123\n" + - "(SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND\x10\xe9\a\x1a\x04\xa8E\x94\x03\x121\n" + - "&SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID\x10\xea\a\x1a\x04\xa8E\x90\x03\x123\n" + - "(SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE\x10\xeb\a\x1a\x04\xa8E\x90\x03\x12/\n" + - "$SYSTEM_ERROR_REASON_INVALID_USERNAME\x10\xed\a\x1a\x04\xa8E\x90\x03\x12/\n" + - "$SYSTEM_ERROR_REASON_INVALID_PASSWORD\x10\xee\a\x1a\x04\xa8E\x90\x03\x1a\x04\xa0E\xf4\x03B\xc3\x01\n" + - "\x1acom.api.v1.services.systemB\n" + - "ErrorProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_error_proto_rawDescOnce sync.Once - file_system_error_proto_rawDescData []byte -) - -func file_system_error_proto_rawDescGZIP() []byte { - file_system_error_proto_rawDescOnce.Do(func() { - file_system_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_error_proto_rawDesc), len(file_system_error_proto_rawDesc))) - }) - return file_system_error_proto_rawDescData -} - -var file_system_error_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_system_error_proto_goTypes = []any{ - (SystemErrorReason)(0), // 0: api.v1.services.system.SystemErrorReason -} -var file_system_error_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_system_error_proto_init() } -func file_system_error_proto_init() { - if File_system_error_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_error_proto_rawDesc), len(file_system_error_proto_rawDesc)), - NumEnums: 1, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_system_error_proto_goTypes, - DependencyIndexes: file_system_error_proto_depIdxs, - EnumInfos: file_system_error_proto_enumTypes, - }.Build() - File_system_error_proto = out.File - file_system_error_proto_goTypes = nil - file_system_error_proto_depIdxs = nil -} diff --git a/api/v1/services/system/error.pb.validate.go b/api/v1/services/system/error.pb.validate.go deleted file mode 100644 index 9a39c359..00000000 --- a/api/v1/services/system/error.pb.validate.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/error.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) diff --git a/api/v1/services/system/error_errors.pb.go b/api/v1/services/system/error_errors.pb.go deleted file mode 100644 index d7232134..00000000 --- a/api/v1/services/system/error_errors.pb.go +++ /dev/null @@ -1,240 +0,0 @@ -// Code generated by protoc-gen-go-errors. DO NOT EDIT. - -package system - -import ( - fmt "fmt" - errors "github.com/go-kratos/kratos/v2/errors" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -const _ = errors.SupportPackageIsVersion1 - -func IsSystemErrorReasonUnspecified(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 -} - -func ErrorSystemErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { - return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserNotFound(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String() && e.Code == 404 -} - -func ErrorSystemErrorReasonUserNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserAlreadyExists(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String() && e.Code == 409 -} - -func ErrorSystemErrorReasonUserAlreadyExists(format string, args ...interface{}) *errors.Error { - return errors.New(409, SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserNotLoggedIn(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonUserNotLoggedIn(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserNotLoggedOut(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonUserNotLoggedOut(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonTokenExpired(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonTokenNotFound(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonTokenNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidToken(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonInvalidToken(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidClaims(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonInvalidClaims(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidAuthentication(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonInvalidAuthentication(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidAuthorization(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String() && e.Code == 403 -} - -func ErrorSystemErrorReasonInvalidAuthorization(format string, args ...interface{}) *errors.Error { - return errors.New(403, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidRequest(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidRequest(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidResponse(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String() && e.Code == 500 -} - -func ErrorSystemErrorReasonInvalidResponse(format string, args ...interface{}) *errors.Error { - return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidServer(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String() && e.Code == 500 -} - -func ErrorSystemErrorReasonInvalidServer(format string, args ...interface{}) *errors.Error { - return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonCaptchaIdNotFound(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String() && e.Code == 404 -} - -func ErrorSystemErrorReasonCaptchaIdNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidCaptchaId(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidCaptchaId(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidCaptchaCode(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidCaptchaCode(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidUsername(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidUsername(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidPassword(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidPassword(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), fmt.Sprintf(format, args...)) -} diff --git a/cmd/auth/main.go b/cmd/auth/main.go new file mode 100644 index 00000000..e87cf55f --- /dev/null +++ b/cmd/auth/main.go @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package main + +import ( + "context" + "flag" + "log/slog" + + "github.com/go-kratos/kratos/v2" + "github.com/go-kratos/kratos/v2/encoding" + "github.com/go-kratos/kratos/v2/transport" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/bootstrap" + "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/codec/toml" + + _ "origadmin/application/admin/contrib/consul/config" + _ "origadmin/application/admin/contrib/consul/registry" + _ "origadmin/application/admin/contrib/database" + "origadmin/application/admin/internal/loader" +) + +// go build -ldflags "-X main.Version=vx.y.z -X main.Name=origadmin.service.auth.v1" +var ( + // Name is the Name of the compiled software. + Name = "origadmin.service.auth.v1" + // Version is the Version of the compiled software. + Version = "v1.0.0" + // boot are the bootstrap boot. + flags = bootstrap.New() + // debug mode + debug = false + // configPath is the config path, default is config.toml + configPath = "" +) + +func init() { + encoding.RegisterCodec(toml.Codec) + flags.SetServiceInfo(Name, Version) + flag.BoolVar(&debug, "debug", false, "set environment, eg: -debug") + flag.StringVar(&configPath, "c", "config.toml", "config path, eg: -c config.toml") +} + +func main() { + flag.Parse() + + // the release mode, work dir sets to empty, use config path as work dir + if debug { + flags.SetEnv("debug") + flags.SetConfigPath("resources/configs/config.toml") + flags.SetWorkDir(".") + slog.SetLogLoggerLevel(slog.LevelDebug) + } + + //r, err := runtime.Load(flags) + //if err != nil { + // return + //} + //l := r.Logger( + // "ts", log.DefaultTimestamp, + // "caller", log.DefaultCaller, + // "service.id", flags.ServiceID(), + // "service.name", flags.ServiceName(), + // "service.version", flags.Version(), + // "trace.id", tracing.TraceID(), + // "span.id", tracing.SpanID(), + //) + //log.SetLogger(l) + ll := log.NewHelper(log.GetLogger()) + ll.Infof("bootstrap flags: %+v", flags) + if err := loader.Bootstrap(context.Background(), flags, buildInjectors); err != nil { + ll.Infof("failed to bootstrap: %s", err.Error()) + return + } +} + +// NewApp new app with runtime and injector +func NewApp(r runtime.Runtime, servers []transport.Server) *kratos.App { + return r.CreateApp(servers...) +} diff --git a/cmd/auth/wire.go b/cmd/auth/wire.go new file mode 100644 index 00000000..e6c69ff3 --- /dev/null +++ b/cmd/auth/wire.go @@ -0,0 +1,40 @@ +//go:build wireinject +// +build wireinject + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// The build tag makes sure the stub is not built in the final build. +package main + +import ( + "github.com/go-kratos/kratos/v2" + "github.com/google/wire" + "github.com/origadmin/runtime" + + "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/data" + authbiz "origadmin/application/admin/internal/mods/auth/biz" + authdal "origadmin/application/admin/internal/mods/auth/dal" + authserver "origadmin/application/admin/internal/mods/auth/server" + authservice "origadmin/application/admin/internal/mods/auth/service" +) + +// buildInjectors init kratos application. +func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { + panic(wire.Build( + //loader.ProviderSet, + data.ProviderSet, + //authdal.ProviderSet, + //basisbiz.ProviderSet, + //basisservice.ProviderSet, + //basisserver.ProviderSet, + authdal.ProviderSet, + authbiz.ProviderSet, + authservice.ProviderSet, + authserver.ProviderSet, + /* add your providers here */ + NewApp, + )) +} diff --git a/cmd/auth/wire.work.go b/cmd/auth/wire.work.go new file mode 100644 index 00000000..059f2257 --- /dev/null +++ b/cmd/auth/wire.work.go @@ -0,0 +1,12 @@ +//go:build !wireinject && GOWORK +// +build !wireinject,GOWORK + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// The build tag makes sure the stub is not built in the final build. +//go:generate go run github.com/google/wire/cmd/wire + +// Package main is a main package +package main diff --git a/cmd/auth/wire_gen.go b/cmd/auth/wire_gen.go new file mode 100644 index 00000000..981a8fb9 --- /dev/null +++ b/cmd/auth/wire_gen.go @@ -0,0 +1,52 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate go run -mod=mod github.com/google/wire/cmd/wire +//go:build !wireinject +// +build !wireinject + +package main + +import ( + "github.com/go-kratos/kratos/v2" + "github.com/origadmin/runtime" + "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/mods/auth/biz" + "origadmin/application/admin/internal/mods/auth/dal" + "origadmin/application/admin/internal/mods/auth/server" + "origadmin/application/admin/internal/mods/auth/service" +) + +import ( + _ "origadmin/application/admin/contrib/consul/config" + _ "origadmin/application/admin/contrib/consul/registry" + _ "origadmin/application/admin/contrib/database" +) + +// Injectors from wire.go: + +// buildInjectors init kratos application. +func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { + dataData, cleanup, err := data.NewData(r, bootstrap) + if err != nil { + return nil, nil, err + } + resourceRepo := dal.NewResourceRepo(r, dataData) + resourceServiceBiz := biz.NewResourceServiceBiz(r, resourceRepo) + resourceServiceServer := service.NewResourceServiceServerPB(r, resourceServiceBiz) + roleRepo := dal.NewRoleRepo(r, dataData) + roleServiceBiz := biz.NewRoleServiceBiz(r, roleRepo) + roleServiceServer := service.NewRoleServiceServerPB(r, roleServiceBiz) + userRepo := dal.NewUserRepo(r, dataData) + userServiceBiz := biz.NewUserServiceBiz(r, userRepo) + userServiceServer := service.NewUserServiceServerPB(r, userServiceBiz) + permissionRepo := dal.NewPermissionRepo(r, dataData) + permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) + permissionServiceServer := service.NewPermissionServiceServerPB(r, permissionServiceBiz) + serverRegistrar := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + v := server.NewSystemServer(r, bootstrap, serverRegistrar) + app := NewApp(r, v) + return app, func() { + cleanup() + }, nil +} diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index 0a2ec513..8a2582f8 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -7,12 +7,12 @@ package start import ( "github.com/go-kratos/kratos/v2" - _ "origadmin/application/admin/contrib/consul/config" - _ "origadmin/contrib/consul/registry" "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" "github.com/spf13/cobra" + _ "origadmin/application/admin/contrib/consul/config" + _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" "origadmin/application/admin/internal/loader" ) diff --git a/internal/mods/auth/dal/dal.go b/internal/mods/auth/dal/dal.go index f98c6fb2..8a0d0289 100644 --- a/internal/mods/auth/dal/dal.go +++ b/internal/mods/auth/dal/dal.go @@ -6,38 +6,28 @@ package dal import ( "context" - "errors" - "fmt" - "os" "path/filepath" - "strconv" "strings" - "time" "entgo.io/ent/dialect" + "github.com/google/uuid" "github.com/google/wire" "github.com/origadmin/entslog/v3" "github.com/origadmin/runtime/interfaces/security" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/codec" + "github.com/origadmin/toolkits/crypto/hash" + "github.com/origadmin/toolkits/crypto/rand" - "origadmin/application/admin/helpers/db" "origadmin/application/admin/helpers/id" - "origadmin/application/admin/internal/data/entity/ent/department" - "origadmin/application/admin/internal/data/entity/ent/predicate" - "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/mods/auth/dto" + "origadmin/application/admin/internal/data" ) const ( TreePathDelimiter = "." ) -// Data . -//type Data struct { -// *ent.Database -// Delimiter string -//} +type Data struct { + *data.Data +} // ProviderSet is data providers. var ProviderSet = wire.NewSet( @@ -127,376 +117,377 @@ func (obj *Data) InitDataFromPath(ctx context.Context, path string, filters ...s return nil } -func (obj *Data) InitResourceFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var resources []*dto.ResourceNode - err = codec.DecodeFromFile(abs, &resources) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Resource data file not found, skip init resource data from file", "file", abs) - return nil - } - return err - } - for i, pb := range resources { - log.Infow("msg", "Processing resource", "index", i, "resourceId", pb.Id, "resourceKeyword", pb.Keyword, "resourceName", pb.Name) - if pb.Children != nil { - for i2, child := range pb.Children { - log.Infow("msg", "Processing child", "index", i2, "childId", child.Id, "childKeyword", child.Keyword, "childName", child.Name) - } - } - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createResourceBatchWithParent(ctx, resources, nil) - }) -} - -func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto.ResourceNode, parent *dto.ResourcePB) error { - total := len(items) - log.Infow("msg", "Starting createResourceBatchWithParent", "totalItems", total) - - for i, item := range items { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - var pid int64 - if parent != nil { - pid = parent.Id - log.Infow("msg", "Parent ID set", "parentId", pid) - } - founded := false - switch { - case item.Id != 0: - log.Infow("Checking item by ID", "itemId", item.Id) - exists, err := obj.Resource(ctx).Query().Where(resource.ID(item.Id)).Exist(ctx) - if err != nil { - log.Errorw("msg", "Error checking item by ID", "itemId", item.Id, "error", err) - return err - } - if exists { - log.Infow("msg", "Item already exists by ID", "itemId", item.Id) - continue - } - case item.Keyword != "": - log.Infow("msg", "Checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid) - var wheres = []predicate.Resource{ - resource.Keyword(item.Keyword), - } - if pid != 0 { - wheres = append(wheres, resource.ParentID(pid)) - } - exists, err := obj.Resource(ctx).Query().Where(wheres...).Exist(ctx) - if err != nil { - log.Errorw("msg", "Error checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) - return err - } - if exists { - resourceItem, err := obj.Resource(ctx).Query().Where(wheres...).First(ctx) - if err != nil { - log.Errorw("msg", "Error fetching item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) - return err - } - founded = true - item.Id = resourceItem.ID - log.Infow("msg", "Item found by Keyword", "itemKeyword", item.Keyword, "itemId", item.Id) - } - case item.Name != "": - log.Infow("msg", "Checking item by Name", "itemName", item.Name, "parentId", pid) - var conditions = []predicate.Resource{ - resource.Name(item.Name), - } - if pid != 0 { - conditions = append(conditions, resource.ParentID(pid)) - } - exists, err := obj.Resource(ctx).Query().Where(conditions...).Exist(ctx) - if err != nil { - log.Errorw("msg", "Error checking item by Name", "itemName", item.Name, "parentId", pid, "error", err) - return err - } - if exists { - resourceItem, err := obj.Resource(ctx).Query().Where(conditions...).First(ctx) - if err != nil { - log.Errorw("msg", "Error fetching item by Name", "itemName", item.Name, "parentId", pid, "error", err) - return err - } - founded = true - item.Id = resourceItem.ID - log.Infow("msg", "Item found by Name", "itemName", item.Name, "itemId", item.Id) - } - default: - log.Infow("msg", "No ID, Keyword, or Name provided for item") - } - - if !founded { - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if item.Status == 0 { - item.Status = int32(dto.UserStatusActive) - log.Infow("msg", "Setting default status for item", "itemId", item.Id, "status", item.Status) - } - if item.Sequence == 0 { - item.Sequence = int32(total - i) - log.Infow("msg", "Setting default sequence for item", "itemId", item.Id, "sequence", item.Sequence) - } - - item.ParentId = pid - if parent != nil { - item.TreePath = parent.TreePath + strconv.Itoa(int(pid)) + TreePathDelimiter - log.Infow("msg", "Setting parent path for item", "itemId", item.Id, "treePath", item.TreePath) - } - itemObj := dto.ConvertResourcePB2Object(&item.ResourcePB) - itemObj.UpdateTime = time.Now() - itemObj.CreateTime = time.Now() - if _, err := obj.Resource(ctx).Create().SetResource(itemObj).Save(ctx); err != nil { - log.Errorw("msg", "Error creating resource item", "itemId", item.Id, "sequence", item.Sequence, "error", err) - return err - } - log.Infow("msg", "Resource item created successfully", "itemId", item.Id) - } - - if len(item.Children) != 0 { - log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) - if err := obj.createResourceBatchWithParent(ctx, item.Children, &item.ResourcePB); err != nil { - log.Errorw("Error processing children", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Children processed successfully", "itemId", item.Id) - } - } - log.Infow("msg", "Finished createResourceBatchWithParent") - return nil -} - -func (obj *Data) InitUserFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var users []*dto.UserNode - err = codec.DecodeFromFile(abs, &users) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("User data file not found, skip init user data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createUserBatch(ctx, users) - }) -} - -func (obj *Data) createUserBatch(ctx context.Context, users []*dto.UserNode) error { - total := len(users) - log.Infow("msg", "Starting createUserBatch", "totalItems", total) - for i, item := range users { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemUsername", item.Username, "itemNickname", item.Nickname) - user, ps, err := dto.MakeCreateUser(&item.UserPB, item.Username, item.Password, dto.UserMutationOption{}) - if err != nil { - return err - } - fmt.Println("generate user: ", user.Username, "with password: ", ps) - if _, err := obj.User(ctx).Create().SetIsSystem(item.IsSystem).SetUser(dto.ConvertUserPB2Object(user)). - Save(ctx); err != nil { - log.Errorw("msg", "Error creating user item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "User item created successfully", "itemId", item.Id, "itemUuid", item.Uuid) - } - log.Infow("msg", "Finished createUserBatch") - return nil -} - -func (obj *Data) InitRoleFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var roles []*dto.RolePB - err = codec.DecodeFromFile(abs, &roles) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Role data file not found, skip init role data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createRoleBatch(ctx, roles) - }) -} - -func (obj *Data) createRoleBatch(ctx context.Context, roles []*dto.RolePB) error { - total := len(roles) - log.Infow("msg", "Starting createRoleBatch", "totalItems", total) - for i, item := range roles { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if _, err := obj.Role(ctx).Create().SetRole(dto.ConvertRolePB2Object(item)).Save(ctx); err != nil { - log.Errorw("msg", "Error creating role item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Role item created successfully", "itemId", item.Id) - } - log.Infow("msg", "Finished createRoleBatch") - return nil -} - -func (obj *Data) InitDepartmentFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var departments []*dto.DepartmentNode - err = codec.DecodeFromFile(abs, &departments) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Department data file not found, skip init department data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createDepartmentBatch(ctx, departments, nil) - }) -} - -func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.DepartmentNode, parent *dto.DepartmentPB) error { - total := len(departments) - log.Infow("msg", "Starting createDepartmentBatch", "totalItems", total) - for i, item := range departments { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if parent != nil { - item.ParentId = parent.Id - item.TreePath = parent.TreePath + strconv.Itoa(int(parent.Id)) + TreePathDelimiter - } - - if _, err := obj.Department(ctx).Create(). - SetDepartment(dto.ConvertDepartmentPB2Object(&item.DepartmentPB)). - Save(ctx); err != nil { - log.Errorw("msg", "Error creating department item", "itemId", item.Id, "error", err) - return err - } - - log.Infow("msg", "Department item created successfully", "itemId", item.Id) - if len(item.Children) != 0 { - log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) - if err := obj.createDepartmentBatch(ctx, item.Children, &item.DepartmentPB); err != nil { - log.Errorw("Error processing children", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Children processed successfully", "itemId", item.Id) - } - } - log.Infow("msg", "Finished createDepartmentBatch") - return nil -} - -func (obj *Data) InitPositionFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var positions []*dto.PositionNode - err = codec.DecodeFromFile(abs, &positions) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Position data file not found, skip init position data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createPositionBatch(ctx, positions) - }) -} - -func (obj *Data) createPositionBatch(ctx context.Context, positions []*dto.PositionNode) error { - total := len(positions) - log.Infow("msg", "Starting createPositionBatch", "totalItems", total) - for i, item := range positions { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - dept, err := obj.Department(ctx).Query().Where(department.Keyword(item.DepartmentKeyword)).Only(ctx) - if err != nil { - return err - } - - if _, err := obj.Position(ctx).Create().SetPosition(&dto.Position{ - ID: item.Id, - CreateTime: time.Now(), - UpdateTime: time.Now(), - Name: item.Name, - Keyword: item.Keyword, - Description: item.Description, - DepartmentID: dept.ID, - }).Save(ctx); err != nil { - log.Errorw("msg", "Error creating position item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Position item created successfully", "itemId", item.Id) - } - log.Infow("msg", "Finished createPositionBatch") - return nil -} - -func (obj *Data) InitPermissionFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var permissions []*dto.PermissionNode - err = codec.DecodeFromFile(abs, &permissions) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Permission data file not found, skip init permission data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createPermissionBatch(ctx, permissions) - }) -} - -func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.PermissionNode) error { - total := len(permissions) - log.Infow("msg", "Starting createPermissionBatch", "totalItems", total) - for i, item := range permissions { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if _, err := obj.Permission(ctx).Create(). - SetPermission(dto.ConvertPermissionPB2Object(&item.PermissionPB)). - Save(ctx); err != nil { - log.Errorw("msg", "Error creating permission item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Permission item created successfully", "itemId", item.Id) - } - log.Infow("msg", "Finished createPermissionBatch") - return nil -} - -func resourceOrderBy(orders []string) []resource.OrderOption { - return db.OrderBy[resource.OrderOption](orders) -} +//func (obj *Data) InitResourceFromFile(ctx context.Context, filename string) error { +// abs, err := filepath.Abs(filename) +// if err != nil { +// return err +// } +// var resources []*dto.ResourceNode +// err = codec.DecodeFromFile(abs, &resources) +// if err != nil { +// if errors.Is(err, os.ErrNotExist) { +// log.Warnw("Resource data file not found, skip init resource data from file", "file", abs) +// return nil +// } +// return err +// } +// for i, pb := range resources { +// log.Infow("msg", "Processing resource", "index", i, "resourceId", pb.Id, "resourceKeyword", pb.Keyword, "resourceName", pb.Name) +// if pb.Children != nil { +// for i2, child := range pb.Children { +// log.Infow("msg", "Processing child", "index", i2, "childId", child.Id, "childKeyword", child.Keyword, "childName", child.Name) +// } +// } +// } +// return obj.Tx(ctx, func(ctx context.Context) error { +// return obj.createResourceBatchWithParent(ctx, resources, nil) +// }) +//} +// +//func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto.ResourceNode, parent *dto.ResourcePB) error { +// total := len(items) +// log.Infow("msg", "Starting createResourceBatchWithParent", "totalItems", total) +// +// for i, item := range items { +// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) +// var pid int64 +// if parent != nil { +// pid = parent.Id +// log.Infow("msg", "Parent ID set", "parentId", pid) +// } +// founded := false +// switch { +// case item.Id != 0: +// log.Infow("Checking item by ID", "itemId", item.Id) +// exists, err := obj.Resource(ctx).Query().Where(resource.ID(item.Id)).Exist(ctx) +// if err != nil { +// log.Errorw("msg", "Error checking item by ID", "itemId", item.Id, "error", err) +// return err +// } +// if exists { +// log.Infow("msg", "Item already exists by ID", "itemId", item.Id) +// continue +// } +// case item.Keyword != "": +// log.Infow("msg", "Checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid) +// var wheres = []predicate.Resource{ +// resource.Keyword(item.Keyword), +// } +// if pid != 0 { +// wheres = append(wheres, resource.ParentID(pid)) +// } +// exists, err := obj.Resource(ctx).Query().Where(wheres...).Exist(ctx) +// if err != nil { +// log.Errorw("msg", "Error checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) +// return err +// } +// if exists { +// resourceItem, err := obj.Resource(ctx).Query().Where(wheres...).First(ctx) +// if err != nil { +// log.Errorw("msg", "Error fetching item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) +// return err +// } +// founded = true +// item.Id = resourceItem.ID +// log.Infow("msg", "Item found by Keyword", "itemKeyword", item.Keyword, "itemId", item.Id) +// } +// case item.Name != "": +// log.Infow("msg", "Checking item by Name", "itemName", item.Name, "parentId", pid) +// var conditions = []predicate.Resource{ +// resource.Name(item.Name), +// } +// if pid != 0 { +// conditions = append(conditions, resource.ParentID(pid)) +// } +// exists, err := obj.Resource(ctx).Query().Where(conditions...).Exist(ctx) +// if err != nil { +// log.Errorw("msg", "Error checking item by Name", "itemName", item.Name, "parentId", pid, "error", err) +// return err +// } +// if exists { +// resourceItem, err := obj.Resource(ctx).Query().Where(conditions...).First(ctx) +// if err != nil { +// log.Errorw("msg", "Error fetching item by Name", "itemName", item.Name, "parentId", pid, "error", err) +// return err +// } +// founded = true +// item.Id = resourceItem.ID +// log.Infow("msg", "Item found by Name", "itemName", item.Name, "itemId", item.Id) +// } +// default: +// log.Infow("msg", "No ID, Keyword, or Name provided for item") +// } +// +// if !founded { +// if item.Id == 0 { +// item.Id = id.Gen() +// log.Infow("msg", "Generated new ID for item", "itemId", item.Id) +// } +// if item.Status == 0 { +// item.Status = int32(dto.UserStatusActive) +// log.Infow("msg", "Setting default status for item", "itemId", item.Id, "status", item.Status) +// } +// if item.Sequence == 0 { +// item.Sequence = int32(total - i) +// log.Infow("msg", "Setting default sequence for item", "itemId", item.Id, "sequence", item.Sequence) +// } +// +// item.ParentId = pid +// if parent != nil { +// item.TreePath = parent.TreePath + strconv.Itoa(int(pid)) + TreePathDelimiter +// log.Infow("msg", "Setting parent path for item", "itemId", item.Id, "treePath", item.TreePath) +// } +// itemObj := dto.ConvertResourcePB2Object(&item.ResourcePB) +// itemObj.UpdateTime = time.Now() +// itemObj.CreateTime = time.Now() +// if _, err := obj.Resource(ctx).Create().SetResource(itemObj).Save(ctx); err != nil { +// log.Errorw("msg", "Error creating resource item", "itemId", item.Id, "sequence", item.Sequence, "error", err) +// return err +// } +// log.Infow("msg", "Resource item created successfully", "itemId", item.Id) +// } +// +// if len(item.Children) != 0 { +// log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) +// if err := obj.createResourceBatchWithParent(ctx, item.Children, &item.ResourcePB); err != nil { +// log.Errorw("Error processing children", "itemId", item.Id, "error", err) +// return err +// } +// log.Infow("msg", "Children processed successfully", "itemId", item.Id) +// } +// } +// log.Infow("msg", "Finished createResourceBatchWithParent") +// return nil +//} +// +//func (obj *Data) InitUserFromFile(ctx context.Context, filename string) error { +// abs, err := filepath.Abs(filename) +// if err != nil { +// return err +// } +// var users []*dto.UserNode +// err = codec.DecodeFromFile(abs, &users) +// if err != nil { +// if errors.Is(err, os.ErrNotExist) { +// log.Warnw("User data file not found, skip init user data from file", "file", abs) +// return nil +// } +// return err +// } +// return obj.Tx(ctx, func(ctx context.Context) error { +// return obj.createUserBatch(ctx, users) +// }) +//} +// +//func (obj *Data) createUserBatch(ctx context.Context, users []*dto.UserNode) error { +// total := len(users) +// log.Infow("msg", "Starting createUserBatch", "totalItems", total) +// for i, item := range users { +// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemUsername", item.Username, "itemNickname", item.Nickname) +// user, ps, err := dto.MakeCreateUser(&item.UserPB, item.Username, item.Password, dto.UserMutationOption{}) +// if err != nil { +// return err +// } +// fmt.Println("generate user: ", user.Username, "with password: ", ps) +// if _, err := obj.User(ctx).Create().SetIsSystem(item.IsSystem).SetUser(dto.ConvertUserPB2Object(user)). +// Save(ctx); err != nil { +// log.Errorw("msg", "Error creating user item", "itemId", item.Id, "error", err) +// return err +// } +// log.Infow("msg", "User item created successfully", "itemId", item.Id, "itemUuid", item.Uuid) +// } +// log.Infow("msg", "Finished createUserBatch") +// return nil +//} +// +//func (obj *Data) InitRoleFromFile(ctx context.Context, filename string) error { +// abs, err := filepath.Abs(filename) +// if err != nil { +// return err +// } +// var roles []*dto.RolePB +// err = codec.DecodeFromFile(abs, &roles) +// if err != nil { +// if errors.Is(err, os.ErrNotExist) { +// log.Warnw("Role data file not found, skip init role data from file", "file", abs) +// return nil +// } +// return err +// } +// return obj.Tx(ctx, func(ctx context.Context) error { +// return obj.createRoleBatch(ctx, roles) +// }) +//} +// +//func (obj *Data) createRoleBatch(ctx context.Context, roles []*dto.RolePB) error { +// total := len(roles) +// log.Infow("msg", "Starting createRoleBatch", "totalItems", total) +// for i, item := range roles { +// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) +// if item.Id == 0 { +// item.Id = id.Gen() +// log.Infow("msg", "Generated new ID for item", "itemId", item.Id) +// } +// if _, err := obj.Role(ctx).Create().SetRole(dto.ConvertRolePB2Object(item)).Save(ctx); err != nil { +// log.Errorw("msg", "Error creating role item", "itemId", item.Id, "error", err) +// return err +// } +// log.Infow("msg", "Role item created successfully", "itemId", item.Id) +// } +// log.Infow("msg", "Finished createRoleBatch") +// return nil +//} +// +//func (obj *Data) InitDepartmentFromFile(ctx context.Context, filename string) error { +// abs, err := filepath.Abs(filename) +// if err != nil { +// return err +// } +// var departments []*dto.DepartmentNode +// err = codec.DecodeFromFile(abs, &departments) +// if err != nil { +// if errors.Is(err, os.ErrNotExist) { +// log.Warnw("Department data file not found, skip init department data from file", "file", abs) +// return nil +// } +// return err +// } +// return obj.Tx(ctx, func(ctx context.Context) error { +// return obj.createDepartmentBatch(ctx, departments, nil) +// }) +//} +// +//func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.DepartmentNode, parent *dto.DepartmentPB) error { +// total := len(departments) +// log.Infow("msg", "Starting createDepartmentBatch", "totalItems", total) +// for i, item := range departments { +// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) +// if item.Id == 0 { +// item.Id = id.Gen() +// log.Infow("msg", "Generated new ID for item", "itemId", item.Id) +// } +// if parent != nil { +// item.ParentId = parent.Id +// item.TreePath = parent.TreePath + strconv.Itoa(int(parent.Id)) + TreePathDelimiter +// } +// +// if _, err := obj.Department(ctx).Create(). +// SetDepartment(dto.ConvertDepartmentPB2Object(&item.DepartmentPB)). +// Save(ctx); err != nil { +// log.Errorw("msg", "Error creating department item", "itemId", item.Id, "error", err) +// return err +// } +// +// log.Infow("msg", "Department item created successfully", "itemId", item.Id) +// if len(item.Children) != 0 { +// log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) +// if err := obj.createDepartmentBatch(ctx, item.Children, &item.DepartmentPB); err != nil { +// log.Errorw("Error processing children", "itemId", item.Id, "error", err) +// return err +// } +// log.Infow("msg", "Children processed successfully", "itemId", item.Id) +// } +// } +// log.Infow("msg", "Finished createDepartmentBatch") +// return nil +//} +// +//func (obj *Data) InitPositionFromFile(ctx context.Context, filename string) error { +// abs, err := filepath.Abs(filename) +// if err != nil { +// return err +// } +// var positions []*dto.PositionNode +// err = codec.DecodeFromFile(abs, &positions) +// if err != nil { +// if errors.Is(err, os.ErrNotExist) { +// log.Warnw("Position data file not found, skip init position data from file", "file", abs) +// return nil +// } +// return err +// } +// return obj.Tx(ctx, func(ctx context.Context) error { +// return obj.createPositionBatch(ctx, positions) +// }) +//} +// +//func (obj *Data) createPositionBatch(ctx context.Context, positions []*dto.PositionNode) error { +// total := len(positions) +// log.Infow("msg", "Starting createPositionBatch", "totalItems", total) +// for i, item := range positions { +// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) +// if item.Id == 0 { +// item.Id = id.Gen() +// log.Infow("msg", "Generated new ID for item", "itemId", item.Id) +// } +// dept, err := obj.Department(ctx).Query().Where(department.Keyword(item.DepartmentKeyword)).Only(ctx) +// if err != nil { +// return err +// } +// +// if _, err := obj.Position(ctx).Create().SetPosition(&dto.Position{ +// ID: item.Id, +// CreateTime: time.Now(), +// UpdateTime: time.Now(), +// Name: item.Name, +// Keyword: item.Keyword, +// Description: item.Description, +// DepartmentID: dept.ID, +// }).Save(ctx); err != nil { +// log.Errorw("msg", "Error creating position item", "itemId", item.Id, "error", err) +// return err +// } +// log.Infow("msg", "Position item created successfully", "itemId", item.Id) +// } +// log.Infow("msg", "Finished createPositionBatch") +// return nil +//} +// +//func (obj *Data) InitPermissionFromFile(ctx context.Context, filename string) error { +// abs, err := filepath.Abs(filename) +// if err != nil { +// return err +// } +// var permissions []*dto.PermissionNode +// err = codec.DecodeFromFile(abs, &permissions) +// if err != nil { +// if errors.Is(err, os.ErrNotExist) { +// log.Warnw("Permission data file not found, skip init permission data from file", "file", abs) +// return nil +// } +// return err +// } +// return obj.Tx(ctx, func(ctx context.Context) error { +// return obj.createPermissionBatch(ctx, permissions) +// }) +//} +// +//func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.PermissionNode) error { +// total := len(permissions) +// log.Infow("msg", "Starting createPermissionBatch", "totalItems", total) +// for i, item := range permissions { +// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) +// if item.Id == 0 { +// item.Id = id.Gen() +// log.Infow("msg", "Generated new ID for item", "itemId", item.Id) +// } +// if _, err := obj.Permission(ctx).Create(). +// SetPermission(dto.ConvertPermissionPB2Object(&item.PermissionPB)). +// Save(ctx); err != nil { +// log.Errorw("msg", "Error creating permission item", "itemId", item.Id, "error", err) +// return err +// } +// log.Infow("msg", "Permission item created successfully", "itemId", item.Id) +// } +// log.Infow("msg", "Finished createPermissionBatch") +// return nil +//} +// +//func resourceOrderBy(orders []string) []resource.OrderOption { +// return db.OrderBy[resource.OrderOption](orders) +//} +// func wrapRefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { return &refreshTokenizer{ tokenizer: tokenizer, @@ -509,3 +500,40 @@ func RefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { } return wrapRefreshTokenizer(tokenizer) } + +// MakeCreateUser functions are used to create new users +func MakeCreateUser(user *UserPB, username, password string, option UserMutationOption) (*UserPB, string, error) { + log.Debugf("Creating user with options: %+v", option) + if !option.NoPasswd { + log.Debugf("NoPasswd is false, checking for RandomPasswd") + if option.RandomPasswd && (user.Email != "" || user.Phone != "") { + log.Debugf("RandomPasswd is true and user has email or phone, generating random password") + password = rand.GenerateRandom(8) + log.Debugf("Generated random password: %s", password) + } else { + log.Debugf("RandomPasswd is false or user has no email or phone") + } + } else { + log.Debugf("NoPasswd is true, setting password to empty string") + password = "" + } + var err error + if password != "" { + log.Debugf("Password is not empty, generating salt") + //user.Salt = rand.GenerateSalt() + //log.Debugf("Generated salt: %s", user.Salt) + user.Password, err = hash.Generate(password) + if err != nil { + log.Errorf("Error generating password hash: %v", err) + return nil, "", err + } + log.Debugf("Generated password hash: %s", user.Password) + } + registerID := id.Gen() + user.Id = registerID + user.Uuid = uuid.Must(uuid.NewRandom()).String() + user.Username = username + user.Name = "user_" + random.RandString(8) + user.Status = 1 + return user, password, nil +} diff --git a/internal/mods/auth/dal/login.dal.go b/internal/mods/auth/dal/login.dal.go index a7fb0209..2df94c66 100644 --- a/internal/mods/auth/dal/login.dal.go +++ b/internal/mods/auth/dal/login.dal.go @@ -10,9 +10,9 @@ import ( "sync" kerr "github.com/go-kratos/kratos/v2/errors" - "github.com/origadmin/runtime/context" jwtv1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" + "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" diff --git a/internal/mods/auth/dto/dto.go b/internal/mods/auth/dto/dto.go index fa2f1000..ac751276 100644 --- a/internal/mods/auth/dto/dto.go +++ b/internal/mods/auth/dto/dto.go @@ -6,8 +6,12 @@ package dto import ( + "net/http" + + "github.com/origadmin/toolkits/errors/httperr" "google.golang.org/protobuf/types/known/timestamppb" + pb "origadmin/application/admin/api/v1/services/system" typespb "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/schema/types" @@ -40,6 +44,15 @@ type ( UserPB = typespb.User ) +var ( + // ErrUserNotFound is user not found. + ErrUserNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") + ErrInvalidCaptchaID = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") + ErrInvalidPassword = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") + ErrInvalidUsername = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") + ErrCaptchaIDNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") +) + // ConvertUser2PB user.table.comment func ConvertUser2PB(goModel *User) (pbModel *UserPB) { pbModel = &UserPB{} diff --git a/internal/mods/auth/dto/login.go b/internal/mods/auth/dto/login.go index 69e25ed2..8d563db0 100644 --- a/internal/mods/auth/dto/login.go +++ b/internal/mods/auth/dto/login.go @@ -8,7 +8,13 @@ package dto import ( "context" + "github.com/google/uuid" + "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/crypto/hash" + "github.com/origadmin/toolkits/crypto/rand" + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/helpers/id" ) type ( @@ -44,3 +50,60 @@ type LoginRepo interface { Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) } + +type UserMutationOption struct { + RandomPasswd bool + NoPasswd bool + Fields []string +} + +type UserQueryOption struct { + IncludeRoles bool + IsSystem bool + NoPasswd bool + RandomPasswd bool + Status int8 `form:"status" json:"status,omitempty"` + SelectFields []string + OmitFields []string + OrderFields []string + Fields []string +} + +// MakeCreateUser functions are used to create new users +func MakeCreateUser(user *UserPB, username, password string, option UserMutationOption) (*UserPB, string, error) { + log.Debugf("Creating user with options: %+v", option) + if !option.NoPasswd { + log.Debugf("NoPasswd is false, checking for RandomPasswd") + if option.RandomPasswd && (user.Email != "" || user.Phone != "") { + log.Debugf("RandomPasswd is true and user has email or phone, generating random password") + password = rand.GenerateRandom(8) + log.Debugf("Generated random password: %s", password) + } else { + log.Debugf("RandomPasswd is false or user has no email or phone") + } + } else { + log.Debugf("NoPasswd is true, setting password to empty string") + password = "" + } + var err error + if password != "" { + log.Debugf("Password is not empty, generating salt") + //user.Salt = rand.GenerateSalt() + //log.Debugf("Generated salt: %s", user.Salt) + user.Password, err = hash.Generate(password) + if err != nil { + log.Errorf("Error generating password hash: %v", err) + return nil, "", err + } + log.Debugf("Generated password hash: %s", user.Password) + } + registerID := id.Gen() + user.Id = registerID + user.Uuid = uuid.Must(uuid.NewRandom()).String() + user.Username = username + user.Name = "user_" + random.RandString(8) + user.Status = 1 + return user, password, nil +} + +var random = rand.NewRand(rand.KindDigit | rand.KindLowerCase | rand.KindUpperCase) diff --git a/internal/mods/auth/server/README.md b/internal/mods/auth/server/README.md new file mode 100644 index 00000000..be23f4ff --- /dev/null +++ b/internal/mods/auth/server/README.md @@ -0,0 +1,4 @@ +# Server + +This directory contains the server code. + diff --git a/internal/mods/auth/server/gins.go b/internal/mods/auth/server/gins.go new file mode 100644 index 00000000..26373997 --- /dev/null +++ b/internal/mods/auth/server/gins.go @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package server + +import ( + "net/url" + + "github.com/origadmin/contrib/transport/gins" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/middleware" + "github.com/origadmin/runtime/service" + "github.com/origadmin/toolkits/env" + "github.com/origadmin/toolkits/net" + + "origadmin/application/admin/internal/configs" +) + +// NewGINSServer new a gin server. +func NewGINSServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.ServerOption) *gins.Server { + ms := middleware.NewServer(bootstrap.GetMiddleware()) + //option := settings.ApplyOrZero(ss...) + var opts = []gins.ServerOption{ + gins.Middleware(ms...), + } + //serviceConfig := bootstrap.GetService() + //cfg := serviceConfig.GetGins() + //if cfg == nil { + // return nil + //} + // + //if cfg.Network != "" { + // opts = append(opts, gins.Network(cfg.Network)) + //} + //if cfg.Addr != "" { + // opts = append(opts, gins.Address(cfg.Addr)) + //} + //if cfg.Timeout != nil { + // opts = append(opts, gins.Timeout(cfg.Timeout.AsDuration())) + //} + + //middlewares, err := bootstrap.LoadMiddlewares(bootstrap.GetServiceName(), bootstrap, l) + //if err == nil && len(middlewares) > 0 { + // opts = append(opts, http.Middleware(middlewares...)) + //} + + if l != nil { + opts = append(opts, gins.WithLogger(log.With(l, "module", "gins"))) + } + log.Infof("GetHostName: %s", env.Var(runtime.DefaultEnvPrefix, "host")) + hostVar := env.Var(runtime.DefaultEnvPrefix, "host") + hostIP := env.GetEnv(env.Var(runtime.DefaultEnvPrefix, "host_ip")) + if hostIP == "" { + log.Debugf("HostIP is empty, replacing with HostAddr: %s", hostVar) + hostIP = net.HostAddr(net.WithEnvVar(hostVar)) + log.Debugf("HostIP after replacement: %s", hostIP) + } + + var endpoint string + log.Debugf("GINS.Endpoint: %v", endpoint) + ep, _ := url.Parse(endpoint) + opts = append(opts, gins.Endpoint(ep)) + srv := gins.NewServer(opts...) + return srv +} diff --git a/internal/mods/auth/server/grpc.go b/internal/mods/auth/server/grpc.go new file mode 100644 index 00000000..43cb5ac0 --- /dev/null +++ b/internal/mods/auth/server/grpc.go @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package server + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/service" + + "origadmin/application/admin/internal/configs" +) + +// NewGRPCServer new a gRPC server. +func NewGRPCServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.GRPCServer { + services := bootstrap.GetServer().GetServices() + for _, serviceConfig := range services { + if serviceConfig.GetType() == "grpc" { + grpcServer, err := r.Builder().NewGRPCServer(serviceConfig) + if err != nil { + return nil + } + return grpcServer + } + } + return nil +} diff --git a/internal/mods/auth/server/http.go b/internal/mods/auth/server/http.go new file mode 100644 index 00000000..f1be2682 --- /dev/null +++ b/internal/mods/auth/server/http.go @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package server + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/service" + + "origadmin/application/admin/internal/configs" +) + +// NewHTTPServer new an HTTP server. +func NewHTTPServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.HTTPServer { + services := bootstrap.GetServer().GetServices() + for _, serviceConfig := range services { + if serviceConfig.GetType() == "http" { + httpServer, err := r.Builder().NewHTTPServer(serviceConfig) + if err != nil { + return nil + } + return httpServer + } + } + return nil +} diff --git a/internal/mods/auth/server/server.go b/internal/mods/auth/server/server.go new file mode 100644 index 00000000..2391608b --- /dev/null +++ b/internal/mods/auth/server/server.go @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package server + +import ( + "github.com/go-kratos/kratos/v2/metadata" + "github.com/go-kratos/kratos/v2/transport" + "github.com/google/wire" + "github.com/origadmin/runtime" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/middleware" + "github.com/origadmin/runtime/service" + servicegrpc "github.com/origadmin/runtime/service/grpc" + servicehttp "github.com/origadmin/runtime/service/http" + "github.com/origadmin/toolkits/errors" + + "origadmin/application/admin/internal/configs" +) + +const ( + // ServiceName is service name. + ServiceName = "auth" +) + +var ( + // ProviderSet is server providers. + ProviderSet = wire.NewSet( + NewAuthClient, + NewAuthServer, + ) +) + +func init() { + runtime.RegisterService(ServiceName, service.DefaultServiceFactory) +} + +func NewAuthServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc service.ServerRegistrar) []transport. +Server { + var servers []transport.Server + serverConfig := bootstrap.GetServer() + if serverConfig == nil { + return servers + } + + ll := log.NewHelper(r.WithLogger("module", "auth/server")) + middlewares := middleware.NewServer(bootstrap.GetServer().GetMiddleware()) + services := bootstrap.GetServer().GetServices() + coreinfo := bootstrap.GetServer().GetCore() + for _, serviceConfig := range services { + ll.Infow("msg", "service init", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) + switch serviceConfig.GetType() { + case "grpc": + options := []servicegrpc.Option{ + servicegrpc.WithMiddlewares(middlewares...), + servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), + } + grpcServer, err := r.Builder().NewGRPCServer(serviceConfig, options...) + if err != nil { + continue + } + ll.Infow("msg", "grpc server init", "name", coreinfo.GetName(), "version", + coreinfo.GetVersion()) + svc.Register(r.Context(), grpcServer) + servers = append(servers, grpcServer) + case "http": + options := []servicehttp.Option{ + servicehttp.WithMiddlewares(middlewares...), + servicehttp.WithPrefix(runtime.DefaultEnvPrefix), + } + httpServer, err := r.Builder().NewHTTPServer(serviceConfig, options...) + if err != nil { + continue + } + ll.Infow("msg", "http server init", "name", coreinfo.GetName(), "version", + coreinfo.GetVersion()) + svc.Register(r.Context(), httpServer) + servers = append(servers, httpServer) + } + } + return servers +} + +func NewAuthClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service.GRPCClient, error) { + discovery := bootstrap.GetDiscovery() + if discovery == nil { + return nil, errors.New("no discovery") + } + serviceConfig := &configv1.Service{ + Name: ServiceName, + Selector: &configv1.Service_Selector{ + Version: "v1.0.0", + Builder: "bbr", + }, + } + helper := log.NewHelper(r.Logger()) + helper.Infof("service name: %s", discovery.ServiceName) + discover, err := runtime.NewDiscovery(discovery) + if err != nil { + return nil, errors.Wrap(err, "create discovery") + } + var ms []middleware.KMiddleware + options := []servicegrpc.Option{ + servicegrpc.WithDiscovery(discovery.ServiceName, discover), + } + ms = append(ms, middleware.NewClient(bootstrap.GetMiddleware())...) + ms = append(ms, MiddlewareServer()) + if len(ms) > 0 { + options = append(options, servicegrpc.WithMiddlewares(ms...)) + } + client, err := runtime.NewGRPCServiceClient(context.Background(), serviceConfig, options...) + if err != nil { + return nil, errors.Wrap(err, "create menu grpc client") + } + return client, nil +} + +func MiddlewareServer() middleware.KMiddleware { + return func(handler middleware.KHandler) middleware.KHandler { + return func(ctx context.Context, req interface{}) (reply interface{}, err error) { + if md, ok := metadata.FromClientContext(ctx); ok { + log.Debugf("MiddlewareServer: found client context metadata: %+v", md) + } else { + log.Debugf("MiddlewareServer: no client context metadata found") + } + if md, ok := metadata.FromServerContext(ctx); ok { + log.Debugf("MiddlewareServer: found server context metadata: %+v", md) + } else { + log.Debugf("MiddlewareServer: no server context metadata found") + } + reply, err = handler(ctx, req) + return + } + } +} diff --git a/internal/mods/auth/service/casbin.http.go b/internal/mods/auth/service/casbin.http.go index 4be092b0..e4b0399b 100644 --- a/internal/mods/auth/service/casbin.http.go +++ b/internal/mods/auth/service/casbin.http.go @@ -10,36 +10,36 @@ import ( pb "origadmin/application/admin/api/v1/services/auth" ) -// CasbinServiceHTTPServer is a login service. -type CasbinServiceHTTPServer struct { +// CasbinSourceServiceHTTPServer is a login service. +type CasbinSourceServiceHTTPServer struct { pb.UnimplementedCasbinSourceServiceServer client pb.CasbinSourceServiceHTTPClient } -func (c CasbinServiceHTTPServer) ListGroupings(ctx context.Context, request *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { +func (c CasbinSourceServiceHTTPServer) ListGroupings(ctx context.Context, request *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { //TODO implement me panic("implement me") } -func (c CasbinServiceHTTPServer) ListPolicies(ctx context.Context, request *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { +func (c CasbinSourceServiceHTTPServer) ListPolicies(ctx context.Context, request *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { //TODO implement me panic("implement me") } -func (c CasbinServiceHTTPServer) WatchUpdate(ctx context.Context, request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { +func (c CasbinSourceServiceHTTPServer) WatchUpdate(ctx context.Context, request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { //TODO implement me panic("implement me") } // NewCasbinServiceHTTPServer new a login service. -func NewCasbinServiceHTTPServer(client pb.CasbinSourceServiceHTTPClient) *CasbinServiceHTTPServer { - return &CasbinServiceHTTPServer{client: client} +func NewCasbinServiceHTTPServer(client pb.CasbinSourceServiceHTTPClient) *CasbinSourceServiceHTTPServer { + return &CasbinSourceServiceHTTPServer{client: client} } -// NewCasbinServiceHTTPServerPB new a login service. -func NewCasbinServiceHTTPServerPB(client pb.CasbinSourceServiceHTTPClient) pb.CasbinSourceServiceServer { - return &CasbinServiceHTTPServer{client: client} +// NewCasbinSourceServiceHTTPServerPB new a login service. +func NewCasbinSourceServiceHTTPServerPB(client pb.CasbinSourceServiceHTTPClient) pb.CasbinSourceServiceServer { + return &CasbinSourceServiceHTTPServer{client: client} } -var _ pb.CasbinSourceServiceHTTPServer = (*CasbinServiceHTTPServer)(nil) +var _ pb.CasbinSourceServiceHTTPServer = (*CasbinSourceServiceHTTPServer)(nil) diff --git a/internal/mods/auth/service/service.go b/internal/mods/auth/service/service.go new file mode 100644 index 00000000..ba57affe --- /dev/null +++ b/internal/mods/auth/service/service.go @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + + "github.com/google/wire" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + + pb "origadmin/application/admin/api/v1/services/auth" +) + +// ProviderSet is service providers. +var ProviderSet = wire.NewSet( + wire.Struct(new(RegisterServer), "*"), + NewAuthServiceServerPB, + //NewAuthServiceHTTPServerPB, + NewCasbinSourceServiceServerPB, + //NewCasbinSourceServiceHTTPServerPB, + NewLoginServiceServerPB, + //NewLoginServiceHTTPServerPB, + NewRegisterServer, +) + +type RegisterServer struct { + Auth pb.AuthServiceServer + Casbin pb.CasbinSourceServiceServer + Login pb.LoginServiceServer +} + +func (s RegisterServer) Register(ctx context.Context, svc any) { + switch v := svc.(type) { + case *service.GRPCServer: + s.RegisterGRPC(ctx, v) + case *service.HTTPServer: + s.RegisterHTTP(ctx, v) + } +} + +func (s RegisterServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { + log.Info("grpc server system init") + pb.RegisterAuthServiceServer(server, s.Auth) + pb.RegisterCasbinSourceServiceServer(server, s.Casbin) + pb.RegisterLoginServiceServer(server, s.Login) +} + +func (s RegisterServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { + log.Info("http server system init") + pb.RegisterAuthServiceHTTPServer(server, s.Auth) + pb.RegisterCasbinSourceServiceHTTPServer(server, s.Casbin) + pb.RegisterLoginServiceHTTPServer(server, s.Login) +} + +func NewRegisterServer( + Auth pb.AuthServiceServer, + Casbin pb.CasbinSourceServiceServer, + Login pb.LoginServiceServer, +) service.ServerRegistrar { + return &RegisterServer{ + Auth: Auth, + Casbin: Casbin, + Login: Login, + } +} + +var _ service.ServerRegistrar = (*RegisterServer)(nil) From 6febadbc61cbf9e1e4c0d3093bc38c6c0e466162 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 4 Jun 2025 14:57:22 +0800 Subject: [PATCH 035/158] feat(api): add GRPC and HTTP bridge implementations for various services - Add GRPC2HTTP and HTTP2GRPC bridge implementations for AuthService, CasbinSourceService, LoginService, DepartmentService, MenuService, PermissionService, PersonalService, PositionService, and ResourceService - Update generated protobuf files to include new bridge structs and functions - Add support for streaming operations in CasbinSourceService --- api/v1/services/auth/auth_bridge.pb.go | 75 ++++++++++++++ api/v1/services/auth/casbin_bridge.pb.go | 75 ++++++++++++++ api/v1/services/auth/login_bridge.pb.go | 91 +++++++++++++++++ .../services/system/department_bridge.pb.go | 67 +++++++++++++ api/v1/services/system/menu_bridge.pb.go | 67 +++++++++++++ .../services/system/permission_bridge.pb.go | 67 +++++++++++++ api/v1/services/system/personal_bridge.pb.go | 91 +++++++++++++++++ api/v1/services/system/position_bridge.pb.go | 67 +++++++++++++ api/v1/services/system/resource_bridge.pb.go | 67 +++++++++++++ api/v1/services/system/role_bridge.pb.go | 67 +++++++++++++ api/v1/services/system/user_bridge.pb.go | 99 +++++++++++++++++++ internal/mods/auth/dto/dto.go | 11 +-- internal/mods/system/biz/biz.go | 4 +- internal/mods/system/dto/dto.go | 11 +-- 14 files changed, 845 insertions(+), 14 deletions(-) diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index 07b2f22b..50d397ec 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const AuthServiceAuthLogoutBridgeOperation = "/api.v1.services.auth.AuthService/AuthLogout" const AuthServiceAuthenticateBridgeOperation = "/api.v1.services.auth.AuthService/Authenticate" const AuthServiceCreateTokenBridgeOperation = "/api.v1.services.auth.AuthService/CreateToken" @@ -370,3 +379,69 @@ func (c *AuthServiceBridgeImpl) ValidateToken(ctx context.Context, in *ValidateT } func (c *AuthServiceBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} + +type AuthServiceGRPC2HTTPBridgeImpl struct { + client AuthServiceClient +} + +func NewAuthServiceGRPC2HTTP(client grpc.ClientConnInterface) AuthServiceHTTPServer { + return &AuthServiceGRPC2HTTPBridgeImpl{client: NewAuthServiceClient(client)} +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { + return c.client.AuthLogout(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { + return c.client.Authenticate(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { + return c.client.CreateToken(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { + return c.client.DestroyToken(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { + return c.client.ListAuthResources(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { + return c.client.ValidateToken(ctx, in) +} + +type AuthServiceHTTP2GRPCBridgeImpl struct { + client AuthServiceHTTPClient +} + +func NewAuthServiceHTTP2GRPC(client *http.Client) AuthServiceServer { + return &AuthServiceHTTP2GRPCBridgeImpl{client: NewAuthServiceHTTPClient(client)} +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { + return c.client.AuthLogout(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { + return c.client.Authenticate(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { + return c.client.CreateToken(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { + return c.client.DestroyToken(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { + return c.client.ListAuthResources(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { + return c.client.ValidateToken(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index c41b2e89..a41d9300 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const CasbinSourceServiceListGroupingsBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListGroupings" const CasbinSourceServiceListPoliciesBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListPolicies" const CasbinSourceServiceWatchUpdateBridgeOperation = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" @@ -213,4 +222,70 @@ func (c *CasbinSourceServiceBridgeImpl) WatchUpdate(ctx context.Context, in *Wat return c.client.WatchUpdate(ctx, in) } +func (c *CasbinSourceServiceBridgeImpl) StreamRules(request *StreamRulesRequest, g grpc.ServerStreamingServer[StreamRulesResponse]) error { + stream, err := c.client.StreamRules(g.Context(), request) + if err != nil { + return err + } + for { + rule, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return status.Errorf(status.Code(err), "received stream error: %v", err) + } + if err := g.Send(rule); err != nil { + return err + } + } + return nil +} + func (c *CasbinSourceServiceBridgeImpl) mustEmbedUnimplementedCasbinSourceServiceServer() {} + +type CasbinSourceServiceGRPC2HTTPBridgeImpl struct { + client CasbinSourceServiceClient +} + +func NewCasbinSourceServiceGRPC2HTTP(client grpc.ClientConnInterface) CasbinSourceServiceHTTPServer { + return &CasbinSourceServiceGRPC2HTTPBridgeImpl{client: NewCasbinSourceServiceClient(client)} +} + +func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + +func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { + return c.client.ListPolicies(ctx, in) +} + +func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { + return c.client.WatchUpdate(ctx, in) +} + +type CasbinSourceServiceHTTP2GRPCBridgeImpl struct { + client CasbinSourceServiceHTTPClient +} + +func NewCasbinSourceServiceHTTP2GRPC(client *http.Client) CasbinSourceServiceServer { + return &CasbinSourceServiceHTTP2GRPCBridgeImpl{client: NewCasbinSourceServiceHTTPClient(client)} +} + +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { + return c.client.ListPolicies(ctx, in) +} + +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { + return c.client.WatchUpdate(ctx, in) +} + +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) StreamRules(request *StreamRulesRequest, g grpc.ServerStreamingServer[StreamRulesResponse]) error { + return status.Errorf(codes.Unimplemented, "StreamRules not implemented") +} + +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedCasbinSourceServiceServer() {} diff --git a/api/v1/services/auth/login_bridge.pb.go b/api/v1/services/auth/login_bridge.pb.go index bcdbae69..9002a4f3 100644 --- a/api/v1/services/auth/login_bridge.pb.go +++ b/api/v1/services/auth/login_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const LoginServiceCaptchaBridgeOperation = "/api.v1.services.auth.LoginService/Captcha" const LoginServiceCaptchaAudioBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaAudio" const LoginServiceCaptchaIdBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaId" @@ -461,3 +470,85 @@ func (c *LoginServiceBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefr } func (c *LoginServiceBridgeImpl) mustEmbedUnimplementedLoginServiceServer() {} + +type LoginServiceGRPC2HTTPBridgeImpl struct { + client LoginServiceClient +} + +func NewLoginServiceGRPC2HTTP(client grpc.ClientConnInterface) LoginServiceHTTPServer { + return &LoginServiceGRPC2HTTPBridgeImpl{client: NewLoginServiceClient(client)} +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { + return c.client.Captcha(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { + return c.client.CaptchaAudio(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { + return c.client.CaptchaId(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { + return c.client.CaptchaImage(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { + return c.client.Logout(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { + return c.client.TokenRefresh(ctx, in) +} + +type LoginServiceHTTP2GRPCBridgeImpl struct { + client LoginServiceHTTPClient +} + +func NewLoginServiceHTTP2GRPC(client *http.Client) LoginServiceServer { + return &LoginServiceHTTP2GRPCBridgeImpl{client: NewLoginServiceHTTPClient(client)} +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { + return c.client.Captcha(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { + return c.client.CaptchaAudio(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { + return c.client.CaptchaId(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { + return c.client.CaptchaImage(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { + return c.client.Logout(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { + return c.client.TokenRefresh(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedLoginServiceServer() {} diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go index f149294b..fb6d01d5 100644 --- a/api/v1/services/system/department_bridge.pb.go +++ b/api/v1/services/system/department_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const DepartmentServiceCreateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/CreateDepartment" const DepartmentServiceDeleteDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/DeleteDepartment" const DepartmentServiceGetDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/GetDepartment" @@ -323,3 +332,61 @@ func (c *DepartmentServiceBridgeImpl) UpdateDepartment(ctx context.Context, in * } func (c *DepartmentServiceBridgeImpl) mustEmbedUnimplementedDepartmentServiceServer() {} + +type DepartmentServiceGRPC2HTTPBridgeImpl struct { + client DepartmentServiceClient +} + +func NewDepartmentServiceGRPC2HTTP(client grpc.ClientConnInterface) DepartmentServiceHTTPServer { + return &DepartmentServiceGRPC2HTTPBridgeImpl{client: NewDepartmentServiceClient(client)} +} + +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) +} + +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { + return c.client.GetDepartment(ctx, in) +} + +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) +} + +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { + return c.client.UpdateDepartment(ctx, in) +} + +type DepartmentServiceHTTP2GRPCBridgeImpl struct { + client DepartmentServiceHTTPClient +} + +func NewDepartmentServiceHTTP2GRPC(client *http.Client) DepartmentServiceServer { + return &DepartmentServiceHTTP2GRPCBridgeImpl{client: NewDepartmentServiceHTTPClient(client)} +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { + return c.client.GetDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { + return c.client.UpdateDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedDepartmentServiceServer() {} diff --git a/api/v1/services/system/menu_bridge.pb.go b/api/v1/services/system/menu_bridge.pb.go index 3683c8ae..6062c3cd 100644 --- a/api/v1/services/system/menu_bridge.pb.go +++ b/api/v1/services/system/menu_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const MenuServiceCreateMenuBridgeOperation = "/api.v1.services.system.MenuService/CreateMenu" const MenuServiceDeleteMenuBridgeOperation = "/api.v1.services.system.MenuService/DeleteMenu" const MenuServiceGetMenuBridgeOperation = "/api.v1.services.system.MenuService/GetMenu" @@ -323,3 +332,61 @@ func (c *MenuServiceBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRe } func (c *MenuServiceBridgeImpl) mustEmbedUnimplementedMenuServiceServer() {} + +type MenuServiceGRPC2HTTPBridgeImpl struct { + client MenuServiceClient +} + +func NewMenuServiceGRPC2HTTP(client grpc.ClientConnInterface) MenuServiceHTTPServer { + return &MenuServiceGRPC2HTTPBridgeImpl{client: NewMenuServiceClient(client)} +} + +func (c *MenuServiceGRPC2HTTPBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { + return c.client.CreateMenu(ctx, in) +} + +func (c *MenuServiceGRPC2HTTPBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { + return c.client.DeleteMenu(ctx, in) +} + +func (c *MenuServiceGRPC2HTTPBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { + return c.client.GetMenu(ctx, in) +} + +func (c *MenuServiceGRPC2HTTPBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { + return c.client.ListMenus(ctx, in) +} + +func (c *MenuServiceGRPC2HTTPBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { + return c.client.UpdateMenu(ctx, in) +} + +type MenuServiceHTTP2GRPCBridgeImpl struct { + client MenuServiceHTTPClient +} + +func NewMenuServiceHTTP2GRPC(client *http.Client) MenuServiceServer { + return &MenuServiceHTTP2GRPCBridgeImpl{client: NewMenuServiceHTTPClient(client)} +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { + return c.client.CreateMenu(ctx, in) +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { + return c.client.DeleteMenu(ctx, in) +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { + return c.client.GetMenu(ctx, in) +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { + return c.client.ListMenus(ctx, in) +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { + return c.client.UpdateMenu(ctx, in) +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedMenuServiceServer() {} diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go index 16fdbe2f..da923ceb 100644 --- a/api/v1/services/system/permission_bridge.pb.go +++ b/api/v1/services/system/permission_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const PermissionServiceCreatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/CreatePermission" const PermissionServiceDeletePermissionBridgeOperation = "/api.v1.services.system.PermissionService/DeletePermission" const PermissionServiceGetPermissionBridgeOperation = "/api.v1.services.system.PermissionService/GetPermission" @@ -323,3 +332,61 @@ func (c *PermissionServiceBridgeImpl) UpdatePermission(ctx context.Context, in * } func (c *PermissionServiceBridgeImpl) mustEmbedUnimplementedPermissionServiceServer() {} + +type PermissionServiceGRPC2HTTPBridgeImpl struct { + client PermissionServiceClient +} + +func NewPermissionServiceGRPC2HTTP(client grpc.ClientConnInterface) PermissionServiceHTTPServer { + return &PermissionServiceGRPC2HTTPBridgeImpl{client: NewPermissionServiceClient(client)} +} + +func (c *PermissionServiceGRPC2HTTPBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) +} + +func (c *PermissionServiceGRPC2HTTPBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + +func (c *PermissionServiceGRPC2HTTPBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { + return c.client.GetPermission(ctx, in) +} + +func (c *PermissionServiceGRPC2HTTPBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) +} + +func (c *PermissionServiceGRPC2HTTPBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { + return c.client.UpdatePermission(ctx, in) +} + +type PermissionServiceHTTP2GRPCBridgeImpl struct { + client PermissionServiceHTTPClient +} + +func NewPermissionServiceHTTP2GRPC(client *http.Client) PermissionServiceServer { + return &PermissionServiceHTTP2GRPCBridgeImpl{client: NewPermissionServiceHTTPClient(client)} +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { + return c.client.GetPermission(ctx, in) +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { + return c.client.UpdatePermission(ctx, in) +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPermissionServiceServer() {} diff --git a/api/v1/services/system/personal_bridge.pb.go b/api/v1/services/system/personal_bridge.pb.go index 87e1dfff..8ed40281 100644 --- a/api/v1/services/system/personal_bridge.pb.go +++ b/api/v1/services/system/personal_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const PersonalServiceGetPersonalProfileBridgeOperation = "/api.v1.services.system.PersonalService/GetPersonalProfile" const PersonalServiceListPersonalResourcesBridgeOperation = "/api.v1.services.system.PersonalService/ListPersonalResources" const PersonalServiceListPersonalRolesBridgeOperation = "/api.v1.services.system.PersonalService/ListPersonalRoles" @@ -472,3 +481,85 @@ func (c *PersonalServiceBridgeImpl) UpdatePersonalSetting(ctx context.Context, i } func (c *PersonalServiceBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} + +type PersonalServiceGRPC2HTTPBridgeImpl struct { + client PersonalServiceClient +} + +func NewPersonalServiceGRPC2HTTP(client grpc.ClientConnInterface) PersonalServiceHTTPServer { + return &PersonalServiceGRPC2HTTPBridgeImpl{client: NewPersonalServiceClient(client)} +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +type PersonalServiceHTTP2GRPCBridgeImpl struct { + client PersonalServiceHTTPClient +} + +func NewPersonalServiceHTTP2GRPC(client *http.Client) PersonalServiceServer { + return &PersonalServiceHTTP2GRPCBridgeImpl{client: NewPersonalServiceHTTPClient(client)} +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go index e52f5772..7466940a 100644 --- a/api/v1/services/system/position_bridge.pb.go +++ b/api/v1/services/system/position_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const PositionServiceCreatePositionBridgeOperation = "/api.v1.services.system.PositionService/CreatePosition" const PositionServiceDeletePositionBridgeOperation = "/api.v1.services.system.PositionService/DeletePosition" const PositionServiceGetPositionBridgeOperation = "/api.v1.services.system.PositionService/GetPosition" @@ -323,3 +332,61 @@ func (c *PositionServiceBridgeImpl) UpdatePosition(ctx context.Context, in *Upda } func (c *PositionServiceBridgeImpl) mustEmbedUnimplementedPositionServiceServer() {} + +type PositionServiceGRPC2HTTPBridgeImpl struct { + client PositionServiceClient +} + +func NewPositionServiceGRPC2HTTP(client grpc.ClientConnInterface) PositionServiceHTTPServer { + return &PositionServiceGRPC2HTTPBridgeImpl{client: NewPositionServiceClient(client)} +} + +func (c *PositionServiceGRPC2HTTPBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) +} + +func (c *PositionServiceGRPC2HTTPBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + +func (c *PositionServiceGRPC2HTTPBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { + return c.client.GetPosition(ctx, in) +} + +func (c *PositionServiceGRPC2HTTPBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) +} + +func (c *PositionServiceGRPC2HTTPBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { + return c.client.UpdatePosition(ctx, in) +} + +type PositionServiceHTTP2GRPCBridgeImpl struct { + client PositionServiceHTTPClient +} + +func NewPositionServiceHTTP2GRPC(client *http.Client) PositionServiceServer { + return &PositionServiceHTTP2GRPCBridgeImpl{client: NewPositionServiceHTTPClient(client)} +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { + return c.client.GetPosition(ctx, in) +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { + return c.client.UpdatePosition(ctx, in) +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPositionServiceServer() {} diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go index de429c18..c2ea1b3a 100644 --- a/api/v1/services/system/resource_bridge.pb.go +++ b/api/v1/services/system/resource_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const ResourceServiceCreateResourceBridgeOperation = "/api.v1.services.system.ResourceService/CreateResource" const ResourceServiceDeleteResourceBridgeOperation = "/api.v1.services.system.ResourceService/DeleteResource" const ResourceServiceGetResourceBridgeOperation = "/api.v1.services.system.ResourceService/GetResource" @@ -323,3 +332,61 @@ func (c *ResourceServiceBridgeImpl) UpdateResource(ctx context.Context, in *Upda } func (c *ResourceServiceBridgeImpl) mustEmbedUnimplementedResourceServiceServer() {} + +type ResourceServiceGRPC2HTTPBridgeImpl struct { + client ResourceServiceClient +} + +func NewResourceServiceGRPC2HTTP(client grpc.ClientConnInterface) ResourceServiceHTTPServer { + return &ResourceServiceGRPC2HTTPBridgeImpl{client: NewResourceServiceClient(client)} +} + +func (c *ResourceServiceGRPC2HTTPBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) +} + +func (c *ResourceServiceGRPC2HTTPBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + +func (c *ResourceServiceGRPC2HTTPBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { + return c.client.GetResource(ctx, in) +} + +func (c *ResourceServiceGRPC2HTTPBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) +} + +func (c *ResourceServiceGRPC2HTTPBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { + return c.client.UpdateResource(ctx, in) +} + +type ResourceServiceHTTP2GRPCBridgeImpl struct { + client ResourceServiceHTTPClient +} + +func NewResourceServiceHTTP2GRPC(client *http.Client) ResourceServiceServer { + return &ResourceServiceHTTP2GRPCBridgeImpl{client: NewResourceServiceHTTPClient(client)} +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { + return c.client.GetResource(ctx, in) +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { + return c.client.UpdateResource(ctx, in) +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedResourceServiceServer() {} diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go index 493963bb..f0a52636 100644 --- a/api/v1/services/system/role_bridge.pb.go +++ b/api/v1/services/system/role_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const RoleServiceCreateRoleBridgeOperation = "/api.v1.services.system.RoleService/CreateRole" const RoleServiceDeleteRoleBridgeOperation = "/api.v1.services.system.RoleService/DeleteRole" const RoleServiceGetRoleBridgeOperation = "/api.v1.services.system.RoleService/GetRole" @@ -323,3 +332,61 @@ func (c *RoleServiceBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRe } func (c *RoleServiceBridgeImpl) mustEmbedUnimplementedRoleServiceServer() {} + +type RoleServiceGRPC2HTTPBridgeImpl struct { + client RoleServiceClient +} + +func NewRoleServiceGRPC2HTTP(client grpc.ClientConnInterface) RoleServiceHTTPServer { + return &RoleServiceGRPC2HTTPBridgeImpl{client: NewRoleServiceClient(client)} +} + +func (c *RoleServiceGRPC2HTTPBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) +} + +func (c *RoleServiceGRPC2HTTPBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + +func (c *RoleServiceGRPC2HTTPBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { + return c.client.GetRole(ctx, in) +} + +func (c *RoleServiceGRPC2HTTPBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) +} + +func (c *RoleServiceGRPC2HTTPBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { + return c.client.UpdateRole(ctx, in) +} + +type RoleServiceHTTP2GRPCBridgeImpl struct { + client RoleServiceHTTPClient +} + +func NewRoleServiceHTTP2GRPC(client *http.Client) RoleServiceServer { + return &RoleServiceHTTP2GRPCBridgeImpl{client: NewRoleServiceHTTPClient(client)} +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { + return c.client.GetRole(ctx, in) +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { + return c.client.UpdateRole(ctx, in) +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedRoleServiceServer() {} diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 8264ff66..147696fb 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -10,6 +10,9 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" ) // This is a compile-time assertion to ensure that this generated file @@ -19,6 +22,12 @@ var _ = new(context.Context) const _ = http.SupportPackageIsVersion1 const _ = grpc.SupportPackageIsVersion9 +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + const UserServiceCreateUserBridgeOperation = "/api.v1.services.system.UserService/CreateUser" const UserServiceDeleteUserBridgeOperation = "/api.v1.services.system.UserService/DeleteUser" const UserServiceGetUserBridgeOperation = "/api.v1.services.system.UserService/GetUser" @@ -535,3 +544,93 @@ func (c *UserServiceBridgeImpl) UpdateUserStatus(ctx context.Context, in *Update } func (c *UserServiceBridgeImpl) mustEmbedUnimplementedUserServiceServer() {} + +type UserServiceGRPC2HTTPBridgeImpl struct { + client UserServiceClient +} + +func NewUserServiceGRPC2HTTP(client grpc.ClientConnInterface) UserServiceHTTPServer { + return &UserServiceGRPC2HTTPBridgeImpl{client: NewUserServiceClient(client)} +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { + return c.client.GetUser(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { + return c.client.UpdateUserRoles(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) +} + +type UserServiceHTTP2GRPCBridgeImpl struct { + client UserServiceHTTPClient +} + +func NewUserServiceHTTP2GRPC(client *http.Client) UserServiceServer { + return &UserServiceHTTP2GRPCBridgeImpl{client: NewUserServiceHTTPClient(client)} +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { + return c.client.GetUser(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { + return c.client.UpdateUserRoles(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedUserServiceServer() {} diff --git a/internal/mods/auth/dto/dto.go b/internal/mods/auth/dto/dto.go index ac751276..afdbbd9f 100644 --- a/internal/mods/auth/dto/dto.go +++ b/internal/mods/auth/dto/dto.go @@ -11,7 +11,6 @@ import ( "github.com/origadmin/toolkits/errors/httperr" "google.golang.org/protobuf/types/known/timestamppb" - pb "origadmin/application/admin/api/v1/services/system" typespb "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/schema/types" @@ -46,11 +45,11 @@ type ( var ( // ErrUserNotFound is user not found. - ErrUserNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") - ErrInvalidCaptchaID = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") - ErrInvalidPassword = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") - ErrInvalidUsername = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") - ErrCaptchaIDNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") + ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") + ErrInvalidCaptchaID = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") + ErrInvalidPassword = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") + ErrInvalidUsername = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") + ErrCaptchaIDNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") ) // ConvertUser2PB user.table.comment diff --git a/internal/mods/system/biz/biz.go b/internal/mods/system/biz/biz.go index f2a98457..39c864e0 100644 --- a/internal/mods/system/biz/biz.go +++ b/internal/mods/system/biz/biz.go @@ -11,7 +11,7 @@ import ( "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/toolkits/errors/httperr" - pb "origadmin/application/admin/api/v1/services/system" + typespb "origadmin/application/admin/api/v1/services/types" ) // ProviderSet is biz providers. @@ -28,7 +28,7 @@ var ProviderSet = wire.NewSet( var ( // ErrUserNotFound is user not found. - ErrUserNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") + ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") ) var ( diff --git a/internal/mods/system/dto/dto.go b/internal/mods/system/dto/dto.go index b19e29aa..bdca763d 100644 --- a/internal/mods/system/dto/dto.go +++ b/internal/mods/system/dto/dto.go @@ -11,7 +11,6 @@ import ( "github.com/origadmin/toolkits/errors/httperr" "google.golang.org/protobuf/types/known/timestamppb" - pb "origadmin/application/admin/api/v1/services/system" typespb "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/schema/types" @@ -20,11 +19,11 @@ import ( var ( // ErrUserNotFound is user not found. - ErrUserNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") - ErrInvalidCaptchaID = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") - ErrInvalidPassword = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") - ErrInvalidUsername = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") - ErrCaptchaIDNotFound = httperr.New("http.response.status."+pb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") + ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") + ErrInvalidCaptchaID = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") + ErrInvalidPassword = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") + ErrInvalidUsername = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") + ErrCaptchaIDNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") ) const ( From 45d128eba735e30eb542ecec3d38280f64f80d0e Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 4 Jun 2025 15:37:27 +0800 Subject: [PATCH 036/158] refactor(auth): rebuild auth module structure and implement login functionality - Restructure auth module to align with clean architecture principles - Implement login functionality, including user registration and authentication - Update database access layer to use new data models and repositories - Refactor business logic to improve code organization and maintainability - Remove unnecessary mock implementations and test code --- cmd/auth/main.go | 2 +- cmd/auth/wire_gen.go | 36 +-- cmd/system/main.go | 2 +- internal/loader/bootstrap_default.go | 2 + internal/mods/agent/agent.go | 26 -- internal/mods/agent/auth_test.go | 263 --------------------- internal/mods/agent/ginhttp.go | 60 ----- internal/mods/agent/http.go | 155 ------------ internal/mods/agent/mock.go | 70 ------ internal/mods/auth/biz/casbin.biz.go | 5 +- internal/mods/auth/biz/login.biz.go | 5 +- internal/mods/auth/dal/auth.dal.go | 25 +- internal/mods/auth/dal/dal.go | 6 +- internal/mods/auth/dal/login.dal.go | 28 ++- internal/mods/auth/dal/user.dal.go | 259 ++++++++++---------- internal/mods/auth/service/auth.agent.go | 116 --------- internal/mods/auth/service/auth.bridge.go | 178 ++++++++++++++ internal/mods/auth/service/login.agent.go | 177 -------------- internal/mods/auth/service/login.bridge.go | 251 ++++++++++++++++++++ 19 files changed, 635 insertions(+), 1031 deletions(-) delete mode 100644 internal/mods/agent/agent.go delete mode 100644 internal/mods/agent/auth_test.go delete mode 100644 internal/mods/agent/ginhttp.go delete mode 100644 internal/mods/agent/http.go delete mode 100644 internal/mods/agent/mock.go delete mode 100644 internal/mods/auth/service/auth.agent.go create mode 100644 internal/mods/auth/service/auth.bridge.go delete mode 100644 internal/mods/auth/service/login.agent.go create mode 100644 internal/mods/auth/service/login.bridge.go diff --git a/cmd/auth/main.go b/cmd/auth/main.go index e87cf55f..da7b15c3 100644 --- a/cmd/auth/main.go +++ b/cmd/auth/main.go @@ -50,7 +50,7 @@ func main() { // the release mode, work dir sets to empty, use config path as work dir if debug { flags.SetEnv("debug") - flags.SetConfigPath("resources/configs/config.toml") + flags.SetConfigPath("resources/configs/auth_config.toml") flags.SetWorkDir(".") slog.SetLogLoggerLevel(slog.LevelDebug) } diff --git a/cmd/auth/wire_gen.go b/cmd/auth/wire_gen.go index 981a8fb9..02b5b940 100644 --- a/cmd/auth/wire_gen.go +++ b/cmd/auth/wire_gen.go @@ -31,20 +31,28 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap if err != nil { return nil, nil, err } - resourceRepo := dal.NewResourceRepo(r, dataData) - resourceServiceBiz := biz.NewResourceServiceBiz(r, resourceRepo) - resourceServiceServer := service.NewResourceServiceServerPB(r, resourceServiceBiz) - roleRepo := dal.NewRoleRepo(r, dataData) - roleServiceBiz := biz.NewRoleServiceBiz(r, roleRepo) - roleServiceServer := service.NewRoleServiceServerPB(r, roleServiceBiz) - userRepo := dal.NewUserRepo(r, dataData) - userServiceBiz := biz.NewUserServiceBiz(r, userRepo) - userServiceServer := service.NewUserServiceServerPB(r, userServiceBiz) - permissionRepo := dal.NewPermissionRepo(r, dataData) - permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) - permissionServiceServer := service.NewPermissionServiceServerPB(r, permissionServiceBiz) - serverRegistrar := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) - v := server.NewSystemServer(r, bootstrap, serverRegistrar) + authRepo := dal.NewAuthRepo(r, dataData) + authServiceBiz := biz.NewAuthServiceBiz(r, authRepo) + authServiceServer := service.NewAuthServiceServerPB(authServiceBiz) + casbinSourceRepo, err := dal.NewCasbinSourceRepo(dataData) + if err != nil { + cleanup() + return nil, nil, err + } + casbinSourceServiceBiz := biz.NewCasbinSourceServiceBiz(r, casbinSourceRepo) + casbinSourceServiceServer := service.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) + tokenizer, err := data.NewTokenizer(bootstrap) + if err != nil { + cleanup() + return nil, nil, err + } + refreshTokenizer := dal.RefreshTokenizer(tokenizer) + loginData := data.NewLoginData(bootstrap, refreshTokenizer) + loginRepo := dal.NewLoginRepo(dataData, loginData) + loginServiceBiz := biz.NewLoginServiceBiz(r, loginRepo) + loginServiceServer := service.NewLoginServiceServerPB(loginServiceBiz) + serverRegistrar := service.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer) + v := server.NewAuthServer(r, bootstrap, serverRegistrar) app := NewApp(r, v) return app, func() { cleanup() diff --git a/cmd/system/main.go b/cmd/system/main.go index 7528abd2..9bd198a9 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -50,7 +50,7 @@ func main() { // the release mode, work dir sets to empty, use config path as work dir if debug { flags.SetEnv("debug") - flags.SetConfigPath("resources/configs/config.toml") + flags.SetConfigPath("resources/configs/system_config.toml") flags.SetWorkDir(".") slog.SetLogLoggerLevel(slog.LevelDebug) } diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go index aa83cd37..c89da621 100644 --- a/internal/loader/bootstrap_default.go +++ b/internal/loader/bootstrap_default.go @@ -75,6 +75,8 @@ func DefaultBootstrap() *configs.Bootstrap { Discovery: DefaultDiscovery(), Middleware: DefaultServiceMiddleware(), Security: &configs.SecurityConfig{ + RootUser: DefaultRootUser(), + Captcha: DefaultCaptcha(), Security: &configv1.Security{ PublicPaths: []string{ "/swagger/*", diff --git a/internal/mods/agent/agent.go b/internal/mods/agent/agent.go deleted file mode 100644 index c4aab980..00000000 --- a/internal/mods/agent/agent.go +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package agent implements the functions, types, and interfaces for the module. -package agent - -import ( - "github.com/google/wire" - "github.com/origadmin/runtime/service" - - systemserver "origadmin/application/admin/internal/mods/system/server" -) - -var ProviderSet = wire.NewSet( - NewRegisterAgent, - NewHTTPServerAgent, -) - -type ServerRegisterAgent service.ServerRegister - -func NewRegisterAgent(s1 *systemserver.RegisterBridge) []ServerRegisterAgent { - return []ServerRegisterAgent{ - s1, - } -} diff --git a/internal/mods/agent/auth_test.go b/internal/mods/agent/auth_test.go deleted file mode 100644 index 3e58ca83..00000000 --- a/internal/mods/agent/auth_test.go +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package agent implements the functions, types, and interfaces for the module. -package agent - -import ( - "fmt" - "log/slog" - "net/http" - "net/http/httptest" - "testing" - - "github.com/go-kratos/kratos/v2/middleware/selector" - "github.com/go-kratos/kratos/v2/middleware/tracing" - "github.com/go-kratos/kratos/v2/transport" - transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/origadmin/runtime/context" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/runtime/log" - kslog "github.com/origadmin/slog-kratos" - "github.com/origadmin/runtime/interfaces/security" - "github.com/stretchr/testify/assert" - - "origadmin/application/admin/helpers/securityx" - "origadmin/application/admin/internal/configs" -) - -var bridge = securityx.SecurityBridge{ - Authenticator: mockAuthenticator{}, - Authorizer: mockAuthorizer{}, - Scheme: security.SchemeBearer, - AuthenticationHeader: security.HeaderAuthorize, - Skipper: func(path string) bool { - fmt.Println("path:", path) - return path == "/login" - }, - IsRoot: func(ctx context.Context, claims security.Claims) bool { - return claims.GetSubject() == "admin" - }, - Provider: mockData{}, - //TokenParser: func(ctx context.Context) string { - // if tr, ok := transport.FromServerContext(ctx); ok { - // return tr.RequestHeader().Get("Authorization") - // } - // return "" - //}, - PolicyParser: func(ctx context.Context, claims security.Claims) (security.Policy, error) { - return &security.RegisteredPolicy{ - Subject: claims.GetSubject(), - Object: "/api/v1/users", - Action: "GET", - Domain: claims.GetIssuer(), - Roles: []string{"admin"}, - Permissions: []string{"users:read"}, - }, nil - }, - // Initialize other fields... -} - -func init() { - fmt.Println("debug mode") - slog.SetLogLoggerLevel(slog.LevelDebug) - l := log.With(kslog.NewLogger(), - "ts", log.DefaultTimestamp, - "caller", log.DefaultCaller, - "trace.id", tracing.TraceID(), - "span.id", tracing.SpanID(), - ) - log.SetLogger(l) -} - -// Test authenticator -func TestAuthenticator(t *testing.T) { - // Initialize test bootstrap configuration - cfg := &configs.Bootstrap{ - Security: &configv1.Security{ - Authn: &configv1.AuthNConfig{ - Type: "jwt", - Jwt: &configv1.AuthNConfig_JWTConfig{ - Algorithm: "HS512", - SigningKey: "test_key", - }, - }, - }, - /* Fill in test configuration */} - - auth, err := securityx.NewAuthenticator(cfg) - if err != nil { - t.Fatalf("Failed to create authenticator: %v", err) - } - tk, err := securityx.NewTokenizer(cfg) - if err != nil { - t.Fatalf("Failed to create tokenizer: %v", err) - } - // Test valid token - t.Run("valid token", func(t *testing.T) { - cc, err := tk.CreateClaims(context.Background(), "valid_token") - if err != nil { - t.Fatalf("Failed to create claims: %v", err) - } - ct, err := tk.CreateToken(context.Background(), cc) - if err != nil { - t.Fatalf("Failed to create token: %v", err) - } - claims, err := auth.Authenticate(context.Background(), ct) - if err != nil { - t.Errorf("Expected authentication to succeed, but failed: %v", err) - } - t.Logf("Authentication result: %+v", claims) - assert.Equal(t, "valid_token", claims.GetSubject()) - }) - - // Test invalid token - t.Run("invalid token", func(t *testing.T) { - _, err := auth.Authenticate(context.Background(), "invalid_token") - if err == nil { - t.Error("Expected authentication to fail, but succeeded") - } - }) -} - -// Test security middleware chain -func TestSecurityMiddlewareChain(t *testing.T) { - // Create test middleware chain - chain := selector.Server(bridge.Middleware()).Match(func(ctx context.Context, operation string) bool { - fmt.Println("operation:", operation) - return operation == "/protected" - }).Build() - - // Create test router - router := transhttp.NewServer() - router.HandleFunc("/protected", func(writer http.ResponseWriter, request *http.Request) { - _, err := chain(func(ctx context.Context, req interface{}) (interface{}, error) { - //debug.PrintStack() - // Test logic can be added here - writer.WriteHeader(200) - writer.Write([]byte("Hello, World!")) - return nil, nil - })(testContextWithToken(request), nil) - if err != nil { - writer.WriteHeader(401) - writer.Write([]byte("Authentication failed")) - } - }) - - // Test server - ts := httptest.NewServer(router) - defer ts.Close() - - t.Run("unauthorized request", func(t *testing.T) { - resp, _ := http.Get(ts.URL + "/protected") - if resp.StatusCode != 401 { - t.Errorf("Expected status code 401, but got %d", resp.StatusCode) - } - }) - - t.Run("authorized request", func(t *testing.T) { - req, _ := http.NewRequest("GET", ts.URL+"/protected", nil) - req.Header.Add("Authorization", "Bearer valid_token") - - resp, _ := http.DefaultClient.Do(req) - if resp.StatusCode != 200 { - t.Errorf("Expected status code 200, but got %d", resp.StatusCode) - } - }) -} - -// Test skipper logic -func TestSkipperLogic(t *testing.T) { - - testCases := []struct { - path string - expected bool - }{ - {"/login", true}, - {"/api/secret", false}, - } - - for _, tc := range testCases { - got := bridge.Skipper(tc.path) - if got != tc.expected { - t.Errorf("Path %s expected %v but got %v", tc.path, tc.expected, got) - } - } -} - -// Test is root logic -func TestIsRoot(t *testing.T) { - testClaims := &security.RegisteredClaims{ - Subject: "admin", - } - - if !bridge.IsRoot(context.Background(), testClaims) { - t.Error("Admin user should be identified as root") - } -} - -// Create test context -func testContextWithToken(req *http.Request) context.Context { - ctx := context.Background() - return transport.NewServerContext(ctx, &mockTransport{md: headerCarrier(req.Header), req: req}) -} - -type mockTransport struct { - md headerCarrier - req *http.Request -} - -func (m mockTransport) Kind() transport.Kind { - //TODO implement me - panic("implement me") -} - -func (m mockTransport) Endpoint() string { - //TODO implement me - panic("implement me") -} - -func (m mockTransport) Operation() string { - return "/protected" -} - -func (m mockTransport) RequestHeader() transport.Header { - fmt.Println("request header:", m.md, m.md.Get("Authorization")) - return m.md -} - -func (m mockTransport) ReplyHeader() transport.Header { - return m.md -} - -type headerCarrier http.Header - -// Get returns the value associated with the passed key. -func (hc headerCarrier) Get(key string) string { - return http.Header(hc).Get(key) -} - -// Set stores the key-value pair. -func (hc headerCarrier) Set(key string, value string) { - http.Header(hc).Set(key, value) -} - -// Add append value to key-values pair. -func (hc headerCarrier) Add(key string, value string) { - http.Header(hc).Add(key, value) -} - -// Keys lists the keys stored in this carrier. -func (hc headerCarrier) Keys() []string { - keys := make([]string, 0, len(hc)) - for k := range http.Header(hc) { - keys = append(keys, k) - } - return keys -} - -// Values returns a slice of values associated with the passed key. -func (hc headerCarrier) Values(key string) []string { - return http.Header(hc).Values(key) -} diff --git a/internal/mods/agent/ginhttp.go b/internal/mods/agent/ginhttp.go deleted file mode 100644 index 6d29c2ef..00000000 --- a/internal/mods/agent/ginhttp.go +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package agent - -import ( - "github.com/gin-gonic/gin" - "github.com/go-kratos/kratos/v2/transport/http" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/middleware" - - "origadmin/application/admin/internal/configs" -) - -func NewGinServer(bootstrap *configs.Bootstrap, l log.KLogger) *gin.Engine { - //gin.SetMode(gin.ReleaseMode) - return gin.New() -} - -func NewHTTPServerAgentX(bootstrap *configs.Bootstrap, l log.KLogger) *http.Server { - ms := middleware.NewClient(bootstrap.GetMiddleware()) - var opts = []http.ServerOption{ - http.Middleware(ms...), - } - //service := bootstrap.GetService() - //cfg := service.GetGins() - //if cfg == nil { - // return nil - //} - // - //if cfg.Network != "" { - // opts = append(opts, http.Network(cfg.Network)) - //} - //if cfg.Addr != "" { - // opts = append(opts, http.Address(cfg.Addr)) - //} - //if cfg.Timeout != nil { - // opts = append(opts, http.Timeout(cfg.Timeout.AsDuration())) - //} - - //var endpoint string - //if cfg.Endpoint == "" { - // endpoint, _ = helpers.ServiceEndpoint("http", net.HostAddr(service.Host), cfg.Addr) - //} else { - // endpoint = cfg.Endpoint - //} - // - //log.Infof("Register.GinHttp.Endpoint: %v", endpoint) - //ep, _ := url.Parse(endpoint) - //opts = append(opts, http.Endpoint(ep)) - srv := http.NewServer(opts...) - //srv.Server = &stdhttp.Server{ - // Addr: cfg.Addr, - // ReadTimeout: cfg.ReadTimeout.AsDuration(), - // WriteTimeout: cfg.WriteTimeout.AsDuration(), - // IdleTimeout: cfg.IdleTimeout.AsDuration(), - //} - return srv -} diff --git a/internal/mods/agent/http.go b/internal/mods/agent/http.go deleted file mode 100644 index 95fc1250..00000000 --- a/internal/mods/agent/http.go +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package agent implements the functions, types, and interfaces for the module. -package agent - -import ( - "strings" - - "github.com/go-kratos/kratos/v2/middleware/recovery" - "github.com/go-kratos/kratos/v2/middleware/selector" - "github.com/go-kratos/kratos/v2/transport" - "github.com/go-kratos/kratos/v2/transport/http" - "github.com/goexts/generic/types" - "github.com/gorilla/handlers" - "github.com/origadmin/runtime" - msecurity "github.com/origadmin/runtime/agent/middleware/security" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/security" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/service" - servicehttp "github.com/origadmin/runtime/service/http" - - "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/contrib/security/authz/casbin" - "origadmin/application/admin/helpers/resp" - "origadmin/application/admin/helpers/securityx" - "origadmin/application/admin/internal/configs" -) - -type data struct { -} - -func (d data) QueryRoles(ctx context.Context, subject string) ([]string, error) { - return []string{}, nil -} - -func (d data) QueryPermissions(ctx context.Context, subject string) ([]string, error) { - return []string{}, nil -} - -// NewHTTPServerAgent new an HTTP server. -func NewHTTPServerAgent(bootstrap *configs.Bootstrap, registrars []ServerRegisterAgent, - client system.CasbinSourceServiceClient, l log.KLogger) *service.HTTPServer { - serviceConfig := bootstrap.GetService() - if serviceConfig == nil { - panic("no service config") - } - paths := bootstrap.GetSecurity().GetPublicPaths() - paths = append(DefaultPaths(), paths...) - ms := []middleware.KMiddleware{ - recovery.Recovery(), - } - authenticator, err := securityx.NewAuthenticator(bootstrap) - if err != nil { - panic(err) - } - - opts := []casbin.AuthorizerOption{casbin.WithServiceClient(client)} - - authorizer, err := securityx.NewAuthorizer(bootstrap, opts...) - if err != nil { - panic(err) - } - bridge := securityx.SecurityBridge{ - TokenSource: security.TokenSourceHeader, - Scheme: security.SchemeBearer, - AuthenticationHeader: security.HeaderAuthorize, - Authenticator: authenticator, - Authorizer: authorizer, - SkipKey: msecurity.MetadataSecuritySkipKey, - PublicPaths: nil, - Skipper: func(path string) bool { - return false - }, - IsRoot: func(ctx context.Context, claims security.Claims) bool { - return claims.GetSubject() == "root" || claims.GetSubject() == "admin" - }, - Provider: &data{}, - TokenParser: nil, - } - serv := selector.Server(bridge.Middleware()).Match(func(ctx context.Context, operation string) bool { - for _, p := range paths { - if strings.HasPrefix(operation, p) { - log.Debugf("Operation '%s' matches public path '%s', returning true", operation, p) - return false - } - } - log.Debugf("Operation '%s' no matches public path '%s'", operation, "*") - return true - }) - ms = append(ms, serv.Build(), CallLoggerMiddleware()) - - serviceConfig.Name = types.ZeroOr(serviceConfig.Name, "ORIGADMIN_SERVICE") - srv, err := runtime.NewHTTPServiceServer(bootstrap.GetService(), service.WithHTTP( - servicehttp.WithServerOptions( - http.ErrorEncoder(resp.ResponseErrorEncoder), - http.Filter(handlers.CORS( - handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), - handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS"}), - handlers.AllowedOrigins([]string{"*"}), - ))), - servicehttp.WithMiddlewares(ms...), - servicehttp.WithPrefix(runtime.DefaultEnvPrefix), - )) - if err != nil { - panic(err) - } - ctx := context.Background() - for _, registrar := range registrars { - registrar.HTTPServer(ctx, srv) - } - srv.WalkRoute(func(info http.RouteInfo) error { - log.Infof("Registered HTTP route: %s %s", info.Method, info.Path) - return nil - }) - - return srv -} - -func DefaultPaths() []string { - return []string{ - system.OperationLoginServiceCaptchaId, - system.OperationLoginServiceCaptcha, - system.OperationLoginServiceCaptchaImage, - system.OperationLoginServiceCaptchaAudio, - system.OperationLoginServiceLogin, - system.OperationLoginServiceRegister, - system.OperationLoginServiceTokenRefresh, - } -} - -func CallLoggerMiddleware() middleware.KMiddleware { - return func(handler middleware.KHandler) middleware.KHandler { - return func(ctx context.Context, req interface{}) (reply interface{}, err error) { - log.Infof("CallLoggerMiddleware: %+v", ctx) - tr, ok := transport.FromServerContext(ctx) - log.Infof("Caller Server: %+v, ok: %+v", tr, ok) - tr, ok = transport.FromClientContext(ctx) - log.Infof("Caller ServiceClient: %+v, ok: %+v", tr, ok) - return handler(ctx, req) - } - } -} - -func CorsMiddleware() middleware.KMiddleware { - return func(handler middleware.KHandler) middleware.KHandler { - return func(ctx context.Context, req interface{}) (reply interface{}, err error) { - log.Infof("CorsMiddleware: %+v", ctx) - return handler(ctx, req) - } - } -} diff --git a/internal/mods/agent/mock.go b/internal/mods/agent/mock.go deleted file mode 100644 index 4b5bb093..00000000 --- a/internal/mods/agent/mock.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package agent implements the functions, types, and interfaces for the module. -package agent - -import ( - "errors" - "fmt" - - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/security" -) - -type mockAuthenticator struct { -} - -func (m mockAuthenticator) Authenticate(ctx context.Context, s string) (security.Claims, error) { - fmt.Println("token:", s) - if s == "valid_token" { - return &security.RegisteredClaims{ - Subject: "valid_token", - }, nil - } - return nil, errors.New("invalid token") -} - -func (m mockAuthenticator) AuthenticateContext(ctx context.Context, source security.TokenSource) (security.Claims, error) { - //TODO implement me - panic("implement me") -} - -func (m mockAuthenticator) DestroyToken(ctx context.Context, s string) error { - //TODO implement me - panic("implement me") -} - -func (m mockAuthenticator) DestroyRefreshToken(ctx context.Context, s string) error { - //TODO implement me - panic("implement me") -} - -type mockAuthorizer struct { -} - -func (m mockAuthorizer) Authorized(ctx context.Context, policy security.Policy, object string, action string) (bool, error) { - return policy.GetSubject() == "valid_token", nil -} - -func (m mockAuthorizer) AuthorizedWithDomain(ctx context.Context, policy security.Policy, object string, action string, domain string) (bool, error) { - //TODO implement me - panic("implement me") -} - -func (m mockAuthorizer) AuthorizedWithExtra(ctx context.Context, data security.ExtraData) (bool, error) { - //TODO implement me - panic("implement me") -} - -type mockData struct { -} - -func (m mockData) QueryRoles(ctx context.Context, subject string) ([]string, error) { - return []string{"admin"}, nil -} - -func (m mockData) QueryPermissions(ctx context.Context, subject string) ([]string, error) { - return []string{"admin"}, nil -} diff --git a/internal/mods/auth/biz/casbin.biz.go b/internal/mods/auth/biz/casbin.biz.go index 99ac3760..dc4c7544 100644 --- a/internal/mods/auth/biz/casbin.biz.go +++ b/internal/mods/auth/biz/casbin.biz.go @@ -10,6 +10,7 @@ import ( "sync/atomic" "time" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" "google.golang.org/grpc" @@ -103,7 +104,7 @@ func newGroupingResponse(rule *pb.GroupingRule) *pb.StreamRulesResponse { } // NewCasbinSourceServiceBiz new a CasbinSource use case. -func NewCasbinSourceServiceBiz(repo dto.CasbinSourceRepo, logger log.KLogger) *CasbinSourceServiceBiz { - return &CasbinSourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger), +func NewCasbinSourceServiceBiz(r runtime.Runtime, repo dto.CasbinSourceRepo) *CasbinSourceServiceBiz { + return &CasbinSourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.WithLogger("module", "biz/casbin")), lastModified: &atomic.Int64{}} } diff --git a/internal/mods/auth/biz/login.biz.go b/internal/mods/auth/biz/login.biz.go index c619949b..124d3bf4 100644 --- a/internal/mods/auth/biz/login.biz.go +++ b/internal/mods/auth/biz/login.biz.go @@ -8,6 +8,7 @@ package biz import ( "context" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" @@ -68,6 +69,6 @@ func (biz LoginServiceBiz) TokenRefresh(ctx context.Context, in *pb.TokenRefresh } // NewLoginServiceBiz new a Login use case. -func NewLoginServiceBiz(repo dto.LoginRepo, logger log.KLogger) *LoginServiceBiz { - return &LoginServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(logger)} +func NewLoginServiceBiz(r runtime.Runtime, repo dto.LoginRepo) *LoginServiceBiz { + return &LoginServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.WithLogger("module", "biz/login"))} } diff --git a/internal/mods/auth/dal/auth.dal.go b/internal/mods/auth/dal/auth.dal.go index 6f039228..6894fca2 100644 --- a/internal/mods/auth/dal/auth.dal.go +++ b/internal/mods/auth/dal/auth.dal.go @@ -9,12 +9,14 @@ import ( "errors" "sync" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/interfaces/security" - "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/helpers/db" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/resource" _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/mods/auth/dto" ) @@ -100,7 +102,7 @@ func fromClaims(claims security.Claims, method, path string) security.Policy { } // NewAuthRepo . -func NewAuthRepo(db *data.Data, logger log.KLogger) dto.AuthRepo { +func NewAuthRepo(r runtime.Runtime, db *data.Data) dto.AuthRepo { return &authRepo{ DB: db, BufPool: BufPool(), @@ -115,7 +117,7 @@ func authResourcePageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb return nil, 0, err } result, err := query.All(ctx) - return dto.ConvertResources(result), int32(count), err + return dto.ConvertResources2PB(result), int32(count), err } func authResourceQueryPage(query *ent.ResourceQuery, in *pb.ListAuthResourcesRequest) *ent.ResourceQuery { @@ -174,3 +176,20 @@ func (r refreshTokenizer) Validate(ctx context.Context, s string) (bool, error) func (r refreshTokenizer) CreateRefreshClaims(ctx context.Context, s string) (security.Claims, error) { return nil, errors.New("not implemented") } + +func resourceOrderBy(orders []string) []resource.OrderOption { + return db.OrderBy[resource.OrderOption](orders) +} + +//func resourceQueryOptions(query *ent.ResourceQuery, option dto.ResourceQueryOption) *ent.ResourceQuery { +// if len(option.SelectFields) > 0 { +// query = query.Select(option.SelectFields...).ResourceQuery +// } +// if len(option.OmitFields) > 0 { +// query = query.Omit(option.OmitFields...).ResourceQuery +// } +// if len(option.OrderFields) > 0 { +// query = query.Order(resourceOrderBy(option.OrderFields)...) +// } +// return query +//} diff --git a/internal/mods/auth/dal/dal.go b/internal/mods/auth/dal/dal.go index 8a0d0289..2f88470b 100644 --- a/internal/mods/auth/dal/dal.go +++ b/internal/mods/auth/dal/dal.go @@ -14,11 +14,13 @@ import ( "github.com/google/wire" "github.com/origadmin/entslog/v3" "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/rand" "origadmin/application/admin/helpers/id" "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/mods/auth/dto" ) const ( @@ -40,6 +42,8 @@ var ProviderSet = wire.NewSet( const FKSuffix = "_fk=1" +var random = rand.NewRand(rand.KindDigit | rand.KindLowerCase | rand.KindUpperCase) + func FixSource(source string) string { // Check if the source already contains the FK parameter if strings.Contains(source, FKSuffix) { @@ -502,7 +506,7 @@ func RefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { } // MakeCreateUser functions are used to create new users -func MakeCreateUser(user *UserPB, username, password string, option UserMutationOption) (*UserPB, string, error) { +func MakeCreateUser(user *dto.UserPB, username, password string, option dto.UserMutationOption) (*dto.UserPB, string, error) { log.Debugf("Creating user with options: %+v", option) if !option.NoPasswd { log.Debugf("NoPasswd is false, checking for RandomPasswd") diff --git a/internal/mods/auth/dal/login.dal.go b/internal/mods/auth/dal/login.dal.go index 2df94c66..9a4c30c2 100644 --- a/internal/mods/auth/dal/login.dal.go +++ b/internal/mods/auth/dal/login.dal.go @@ -32,7 +32,7 @@ import ( type loginRepo struct { *data.LoginData - User *userRepo + *data.Data captcha *captcha.Captcha bufpool *sync.Pool } @@ -42,6 +42,10 @@ func (repo loginRepo) TokenRefresh(ctx context.Context, in *dto.TokenRefreshRequ return repo.refreshToken(ctx, in.GetData().GetRefreshToken()) } +func (repo loginRepo) CreateUser(ctx context.Context, userPB *dto.UserPB) (int, error) { + panic("implement me") +} + func (repo loginRepo) Register(ctx context.Context, in *dto.RegisterRequest) (*dto.RegisterResponse, error) { log.Debugf("Register request received with data: %+v", in.GetData()) data := in.GetData() @@ -51,7 +55,7 @@ func (repo loginRepo) Register(ctx context.Context, in *dto.RegisterRequest) (*d if err != nil { return nil, err } - if _, err := repo.User.Create(ctx, createUser); err != nil { + if _, err := repo.CreateUser(ctx, createUser); err != nil { return nil, err } @@ -63,6 +67,10 @@ func (repo loginRepo) Register(ctx context.Context, in *dto.RegisterRequest) (*d }, nil } +func (repo loginRepo) GetUserByUsername(ctx context.Context, username string, fields ...string) (*dto.User, error) { + panic("implement me") +} + func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.LoginResponse, error) { log.Debugf("Login request received with data: %+v", in.GetData()) data := in.GetData() @@ -94,7 +102,7 @@ func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.Log // get user info log.Debugf("Getting userData info for username %s", data.Username) - userData, err := repo.User.GetByUsername(ctx, data.Username, user.FieldID, user.FieldEncryptedPassword, user.FieldStatus) + userData, err := repo.GetUserByUsername(ctx, data.Username, user.FieldID, user.FieldEncryptedPassword, user.FieldStatus) if err != nil { log.Errorf("Error getting userData info: %v", err) return nil, err @@ -107,7 +115,7 @@ func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.Log log.Warnf("User %s is not activated", data.Username) return nil, httperr.New("unknown", 400, "User status is not activated, please contact the administrator") default: - log.Debugf("User found with ID %d and status %d", userData.Id, userData.Status) + log.Debugf("User found with ID %d and status %d", userData.ID, userData.Status) } // check password @@ -117,13 +125,13 @@ func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.Log return nil, dto.ErrInvalidPassword } - userUUID := userData.Uuid + userUUID := userData.UUID username := userData.Username ctx = context.NewID(ctx, userUUID) // set userData cache with role ids log.Debugf("Getting role IDs for userData %s", username) - roleIDs, err := repo.User.GetRoleIDs(ctx, userData.Id) + roleIDs, err := repo.GetUserRoleIDs(ctx, userData.ID) if err != nil { log.Errorf("Error getting role IDs: %v", err) return nil, kerr.Newf(404, "UNKNOWN", "failed to get userData role ids: %v", err) @@ -199,7 +207,7 @@ func (repo loginRepo) CaptchaImage(ctx context.Context, id string, reload bool) } func (repo loginRepo) CurrentUser(ctx context.Context, in *dto.CurrentUserRequest) (*dto.CurrentUserResponse, error) { - current, err := repo.User.Current(ctx, in.GetData().GetUserId()) + current, err := repo.User(ctx).Get(ctx, in.GetData().GetUserId()) if err != nil { return nil, err } @@ -376,6 +384,10 @@ func (repo loginRepo) getCaptchaImage(id string) (string, error) { return item.EncodeB64string(), nil } +func (repo loginRepo) GetUserRoleIDs(ctx context.Context, id int64) ([]string, error) { + panic("implement me") +} + func NewCaptcha(cfg *configs.Captcha) *captcha.Captcha { return captcha.NewCaptcha(&captcha.Config{ DriverDigit: &captcha.DriverDigit{ @@ -411,9 +423,9 @@ func NewLoginRepo(dd *data.Data, ld *data.LoginData) dto.LoginRepo { // panic(err) //} return &loginRepo{ + Data: dd, bufpool: BufPool(), LoginData: ld, - User: &userRepo{db: dd}, captcha: NewCaptcha(ld.Captcha), } } diff --git a/internal/mods/auth/dal/user.dal.go b/internal/mods/auth/dal/user.dal.go index 46c17d08..e30b728e 100644 --- a/internal/mods/auth/dal/user.dal.go +++ b/internal/mods/auth/dal/user.dal.go @@ -9,14 +9,9 @@ import ( "errors" "time" - "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/helpers/db" "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/mods/auth/dto" ) @@ -25,66 +20,66 @@ type userRepo struct { db *data.Data } -func (repo userRepo) AddRoleIDs(ctx context.Context, i int64, int64s []int64, option ...dto.UserMutationOption) error { - //TODO implement me - panic("implement me") -} - -func (repo userRepo) UpdateUserStatus(ctx context.Context, id int64, status int8, options ...dto.UserQueryOption) error { - err := repo.db.User(ctx).UpdateOneID(id).SetStatus(status).Exec(ctx) - if err != nil { - return err - } - return nil -} - -func (repo userRepo) Current(ctx context.Context, id int64) (*dto.UserPB, error) { - return repo.Get(ctx, id) -} - -func (repo userRepo) ListResourceByUserID(ctx context.Context, id int64, - option ...dto.UserQueryOption) ([]*dto.ResourcePB, error) { - resources, err := repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResources(resources), nil -} - -func (repo userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*dto.UserNode, error) { - query := repo.db.User(ctx).Query().Where(user.UsernameEQ(username)) - var option dto.UserQueryOption - if len(fields) > 0 { - option.SelectFields = fields - } - query = userQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return &dto.UserNode{ - UserPB: *dto.ConvertUser2PB(result), - EncryptedPassword: result.EncryptedPassword, - }, nil -} - -func (repo userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { - return repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().IDs(ctx) -} - -func (repo userRepo) Get(ctx context.Context, id int64, options ...dto.UserQueryOption) (*dto.UserPB, error) { - var option dto.UserQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.User(ctx).Query().Where(user.ID(id)) - query = userQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return dto.ConvertUser2PB(result), nil -} +//func (repo userRepo) AddRoleIDs(ctx context.Context, i int64, int64s []int64, option ...dto.UserMutationOption) error { +// //TODO implement me +// panic("implement me") +//} +// +//func (repo userRepo) UpdateUserStatus(ctx context.Context, id int64, status int8, options ...dto.UserQueryOption) error { +// err := repo.db.User(ctx).UpdateOneID(id).SetStatus(status).Exec(ctx) +// if err != nil { +// return err +// } +// return nil +//} +// +//func (repo userRepo) Current(ctx context.Context, id int64) (*dto.UserPB, error) { +// return repo.Get(ctx, id) +//} +// +//func (repo userRepo) ListResourceByUserID(ctx context.Context, id int64, +// option ...dto.UserQueryOption) ([]*dto.ResourcePB, error) { +// resources, err := repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) +// if err != nil { +// return nil, err +// } +// return dto.ConvertResources2PB(resources), nil +//} + +//func (repo userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*dto.UserNode, error) { +// query := repo.db.User(ctx).Query().Where(user.UsernameEQ(username)) +// var option dto.UserQueryOption +// if len(fields) > 0 { +// option.SelectFields = fields +// } +// query = userQueryOptions(query, option) +// result, err := query.First(ctx) +// if err != nil { +// return nil, err +// } +// return &dto.UserNode{ +// UserPB: *dto.ConvertUser2PB(result), +// EncryptedPassword: result.EncryptedPassword, +// }, nil +//} + +//func (repo userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { +// return repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().IDs(ctx) +//} +// +//func (repo userRepo) Get(ctx context.Context, id int64, options ...dto.UserQueryOption) (*dto.UserPB, error) { +// var option dto.UserQueryOption +// if len(options) > 0 { +// option = options[0] +// } +// query := repo.db.User(ctx).Query().Where(user.ID(id)) +// query = userQueryOptions(query, option) +// result, err := query.First(ctx) +// if err != nil { +// return nil, err +// } +// return dto.ConvertUser2PB(result), nil +//} func (repo userRepo) Create(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { var option dto.UserMutationOption @@ -158,70 +153,70 @@ func (repo userRepo) Update(ctx context.Context, userPB *dto.UserPB, options ... return userPB, nil } -func (repo userRepo) List(ctx context.Context, in *pb.ListUsersRequest, options ...dto.UserQueryOption) ([]*dto.UserPB, int32, error) { - var option dto.UserQueryOption - if len(options) > 0 { - option = options[0] - } - - query := repo.db.User(ctx).Query() - if option.IncludeRoles { - query = query.WithRoles() - } - if in.Title != "" { - query = query.Where(user.Or(user.UsernameContainsFold(in.Title), user.PhoneContainsFold(in.Title), user.EmailContainsFold(in.Title))) - } - - if v := option.Status; v > 0 { - query = query.Where(user.StatusEQ(v)) - } - - return userPageQuery(ctx, query, in, option) -} - -// NewUserRepo . -func NewUserRepo(r runtime.Runtime, db *data.Data) dto.UserRepo { - return &userRepo{ - db: db, - } -} - -func userPageQuery(ctx context.Context, query *ent.UserQuery, in *pb.ListUsersRequest, option dto.UserQueryOption) ([]*dto.UserPB, int32, error) { - if in.OnlyCount { - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - return nil, int32(count), nil - } - - query = userQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - query = db.PaginationQuery(query, in, !in.NoPaging) - result, err := query.All(ctx) - return dto.ConvertUsers(result), int32(count), err -} - -func userQueryOptions(query *ent.UserQuery, option dto.UserQueryOption) *ent.UserQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).UserQuery - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).UserQuery - } - if len(option.OrderFields) > 0 { - query = query.Order(userOrderBy(option.OrderFields)...) - } - return query -} - -func userOrderBy(fields []string, opts ...sql.OrderTermOption) []user.OrderOption { - var orders []user.OrderOption - for _, field := range fields { - orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) - } - return orders -} +//func (repo userRepo) List(ctx context.Context, in *pb.ListUsersRequest, options ...dto.UserQueryOption) ([]*dto.UserPB, int32, error) { +// var option dto.UserQueryOption +// if len(options) > 0 { +// option = options[0] +// } +// +// query := repo.db.User(ctx).Query() +// if option.IncludeRoles { +// query = query.WithRoles() +// } +// if in.Title != "" { +// query = query.Where(user.Or(user.UsernameContainsFold(in.Title), user.PhoneContainsFold(in.Title), user.EmailContainsFold(in.Title))) +// } +// +// if v := option.Status; v > 0 { +// query = query.Where(user.StatusEQ(v)) +// } +// +// return userPageQuery(ctx, query, in, option) +//} +// +//// NewUserRepo . +//func NewUserRepo(r runtime.Runtime, db *data.Data) dto.UserRepo { +// return &userRepo{ +// db: db, +// } +//} +// +//func userPageQuery(ctx context.Context, query *ent.UserQuery, in *pb.ListUsersRequest, option dto.UserQueryOption) ([]*dto.UserPB, int32, error) { +// if in.OnlyCount { +// count, err := query.Count(ctx) +// if err != nil { +// return nil, 0, err +// } +// return nil, int32(count), nil +// } +// +// query = userQueryOptions(query, option) +// count, err := query.Count(ctx) +// if err != nil { +// return nil, 0, err +// } +// query = db.PaginationQuery(query, in, !in.NoPaging) +// result, err := query.All(ctx) +// return dto.ConvertUsers(result), int32(count), err +//} +// +//func userQueryOptions(query *ent.UserQuery, option dto.UserQueryOption) *ent.UserQuery { +// if len(option.SelectFields) > 0 { +// query = query.Select(option.SelectFields...).UserQuery +// } +// if len(option.OmitFields) > 0 { +// query = query.Omit(option.OmitFields...).UserQuery +// } +// if len(option.OrderFields) > 0 { +// query = query.Order(userOrderBy(option.OrderFields)...) +// } +// return query +//} +// +//func userOrderBy(fields []string, opts ...sql.OrderTermOption) []user.OrderOption { +// var orders []user.OrderOption +// for _, field := range fields { +// orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) +// } +// return orders +//} diff --git a/internal/mods/auth/service/auth.agent.go b/internal/mods/auth/service/auth.agent.go deleted file mode 100644 index 098dfe0b..00000000 --- a/internal/mods/auth/service/auth.agent.go +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "net/http" - - "github.com/origadmin/runtime/agent" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/helpers/resp" -) - -var ( - ErrorInvalidToken = pb.ErrorSystemErrorReasonInvalidToken("invalid token") -) - -// AuthServiceAgent is a menu service. -type AuthServiceAgent struct { - resp.Response - - client pb.AuthServiceClient -} - -func (s AuthServiceAgent) AuthLogout(ctx context.Context, request *pb.AuthLogoutRequest) (*pb.AuthLogoutResponse, error) { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceAgent) Authenticate(ctx context.Context, request *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.Authenticate(ctx, request) - if err != nil { - return nil, err - } - if !response.IsValid { - return nil, ErrorInvalidToken - } - s.JSON(httpCtx, http.StatusOK, &resp.Result{ - Success: true, - }) - return nil, nil -} - -func (s AuthServiceAgent) CreateToken(ctx context.Context, request *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.CreateToken(ctx, request) - if err != nil { - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Result{ - Success: true, - Data: response, - }) - return nil, nil -} - -func (s AuthServiceAgent) DestroyToken(ctx context.Context, request *pb.DestroyTokenRequest) (*pb.DestroyTokenResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.DestroyToken(ctx, request) - if err != nil { - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Result{ - Success: true, - Data: response, - }) - return nil, nil -} - -func (s AuthServiceAgent) ValidateToken(ctx context.Context, request *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.ValidateToken(ctx, request) - if err != nil { - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Result{ - Success: true, - Data: response, - }) - return nil, nil -} - -func (s AuthServiceAgent) ListAuthResources(ctx context.Context, request *pb.ListAuthResourcesRequest) (*pb.ListAuthResourcesResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.ListAuthResources(ctx, request) - if err != nil { - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Page{ - Success: true, - Total: response.TotalSize, - Data: resp.Proto2AnyPBArray(response.Resources...), - }) - return nil, nil -} - -// NewAuthServiceAgent new a menu service. -func NewAuthServiceAgent(client pb.AuthServiceClient) *AuthServiceAgent { - return &AuthServiceAgent{client: client} -} - -// NewAuthServiceAgentPB new a menu service. -func NewAuthServiceAgentPB(client pb.AuthServiceClient) pb.AuthServiceAgent { - return &AuthServiceAgent{client: client} -} -func NewAuthServiceAgentClient(client *service.GRPCClient) pb.AuthServiceAgent { - cli := pb.NewAuthServiceClient(client) - return NewAuthServiceAgent(cli) -} - -var _ pb.AuthServiceAgent = (*AuthServiceAgent)(nil) diff --git a/internal/mods/auth/service/auth.bridge.go b/internal/mods/auth/service/auth.bridge.go new file mode 100644 index 00000000..f3e9040c --- /dev/null +++ b/internal/mods/auth/service/auth.bridge.go @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + context2 "context" + "net/http" + + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + + pb "origadmin/application/admin/api/v1/services/auth" + typespb "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/helpers/resp" +) + +var ( + ErrorInvalidToken = typespb.ErrorSystemErrorReasonInvalidToken("invalid token") +) + +// AuthServiceHookedBridge is a menu service. +type AuthServiceHookedBridge struct { + pb.UnimplementedAuthServiceHooked + log *log.KHelper +} + +func (s AuthServiceHookedBridge) BeforeAuthLogout(h transhttp.Context, request *pb.AuthLogoutRequest) (context2.Context, error) { + //TODO implement me + panic("implement me") +} + +func (s AuthServiceHookedBridge) AuthLogoutResult(h transhttp.Context, request *pb.AuthLogoutRequest, response *pb.AuthLogoutResponse) error { + //TODO implement me + panic("implement me") +} + +func (s AuthServiceHookedBridge) AuthenticateResult(h transhttp.Context, request *pb.AuthenticateRequest, response *pb.AuthenticateResponse) error { + if !response.IsValid { + return ErrorInvalidToken + } + return h.JSON(http.StatusOK, &resp.Result{ + Success: true, + }) +} + +func (s AuthServiceHookedBridge) BeforeCreateToken(h transhttp.Context, request *pb.CreateTokenRequest) (context2.Context, error) { + //TODO implement me + panic("implement me") +} + +func (s AuthServiceHookedBridge) CreateTokenResult(h transhttp.Context, request *pb.CreateTokenRequest, response *pb.CreateTokenResponse) error { + //TODO implement me + panic("implement me") +} + +func (s AuthServiceHookedBridge) BeforeDestroyToken(h transhttp.Context, request *pb.DestroyTokenRequest) (context2.Context, error) { + //TODO implement me + panic("implement me") +} + +func (s AuthServiceHookedBridge) DestroyTokenResult(h transhttp.Context, request *pb.DestroyTokenRequest, response *pb.DestroyTokenResponse) error { + //TODO implement me + panic("implement me") +} + +func (s AuthServiceHookedBridge) BeforeListAuthResources(h transhttp.Context, request *pb.ListAuthResourcesRequest) (context2.Context, error) { + //TODO implement me + panic("implement me") +} + +func (s AuthServiceHookedBridge) ListAuthResourcesResult(h transhttp.Context, request *pb.ListAuthResourcesRequest, response *pb.ListAuthResourcesResponse) error { + //TODO implement me + panic("implement me") +} + +func (s AuthServiceHookedBridge) BeforeValidateToken(h transhttp.Context, request *pb.ValidateTokenRequest) (context2.Context, error) { + //TODO implement me + panic("implement me") +} + +func (s AuthServiceHookedBridge) ValidateTokenResult(h transhttp.Context, request *pb.ValidateTokenRequest, response *pb.ValidateTokenResponse) error { + //TODO implement me + panic("implement me") +} + +func (s AuthServiceHookedBridge) AuthLogout(ctx context.Context, request *pb.AuthLogoutRequest) (*pb.AuthLogoutResponse, error) { + //TODO implement me + panic("implement me") +} + +//func (s AuthServiceHookedBridge) Authenticate(ctx context.Context, request *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Authenticate(ctx, request) +// if err != nil { +// return nil, err +// } +// if !response.IsValid { +// return nil, ErrorInvalidToken +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Result{ +// Success: true, +// }) +// return nil, nil +//} +// +//func (s AuthServiceHookedBridge) CreateToken(ctx context.Context, request *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.CreateToken(ctx, request) +// if err != nil { +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Result{ +// Success: true, +// Data: response, +// }) +// return nil, nil +//} +// +//func (s AuthServiceHookedBridge) DestroyToken(ctx context.Context, request *pb.DestroyTokenRequest) (*pb.DestroyTokenResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.DestroyToken(ctx, request) +// if err != nil { +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Result{ +// Success: true, +// Data: response, +// }) +// return nil, nil +//} +// +//func (s AuthServiceHookedBridge) ValidateToken(ctx context.Context, request *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.ValidateToken(ctx, request) +// if err != nil { +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Result{ +// Success: true, +// Data: response, +// }) +// return nil, nil +//} +// +//func (s AuthServiceHookedBridge) ListAuthResources(ctx context.Context, request *pb.ListAuthResourcesRequest) (*pb.ListAuthResourcesResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.ListAuthResources(ctx, request) +// if err != nil { +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Page{ +// Success: true, +// Total: response.TotalSize, +// Data: resp.Proto2AnyPBArray(response.Resources...), +// }) +// return nil, nil +//} + +func NewAuthServiceHookedBridge(r runtime.Runtime, client pb.AuthServiceHTTPServer) pb.AuthServiceHookedBridger { + return pb.WithAuthServiceHook(&AuthServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/permission")), + })(client) +} + +// NewAuthServiceBridge new a menu service. +func NewAuthServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.AuthServiceServer { + return pb.NewAuthServiceBridge(client) +} + +// NewAuthServiceHTTPBridge new a menu service. +func NewAuthServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.AuthServiceHTTPServer { + return pb.NewAuthServiceHTTPBridge(client) +} diff --git a/internal/mods/auth/service/login.agent.go b/internal/mods/auth/service/login.agent.go deleted file mode 100644 index 3e2ae353..00000000 --- a/internal/mods/auth/service/login.agent.go +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "net/http" - - "github.com/origadmin/runtime/agent" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/helpers/resp" -) - -// LoginServiceAgent is a Login service. -type LoginServiceAgent struct { - resp.Response - - client pb.LoginServiceClient -} - -func (s LoginServiceAgent) PersonalLogout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.Logout(ctx, request) - if err != nil { - log.Errorf("Logout error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) - return nil, nil -} - -func (s LoginServiceAgent) Register(ctx context.Context, request *pb.RegisterRequest) (*pb.RegisterResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.Register(ctx, request) - if err != nil { - log.Errorf("Register error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) - return nil, nil -} - -func (s LoginServiceAgent) Captcha(ctx context.Context, request *pb.CaptchaRequest) (*pb.CaptchaResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.Captcha(ctx, request) - if err != nil { - log.Errorf("Captcha error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) - return nil, nil -} - -func (s LoginServiceAgent) CaptchaId(ctx context.Context, request *pb.CaptchaIdRequest) (*pb.CaptchaIdResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - log.Debugf("CaptchaId: Request:%+v", request) - response, err := s.client.CaptchaId(ctx, request) - log.Debugf("CaptchaId: Response:%+v, Error:%+v", response, err) - if err != nil { - log.Errorf("CaptchaImage error: %v", err) - return nil, err - } - - s.JSON(httpCtx, http.StatusOK, &resp.StringResult{ - Success: true, - Data: response.Data, - }) - return nil, nil -} - -func (s LoginServiceAgent) CaptchaAudio(ctx context.Context, request *pb.CaptchaAudioRequest) (*pb.CaptchaAudioResponse, error) { - _, err := s.client.CaptchaAudio(ctx, request) - if err != nil { - log.Errorf("Logout error: %v", err) - return nil, err - } - return nil, nil -} -func (s LoginServiceAgent) CaptchaImage(ctx context.Context, request *pb.CaptchaImageRequest) (*pb.CaptchaImageResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - log.Debugf("CaptchaImage: Request:%+v", request) - response, err := s.client.CaptchaImage(ctx, request) - log.Debugf("CaptchaImage: Response:%+v, Error:%+v", response, err) - if err != nil { - log.Errorf("CaptchaImage error: %v", err) - return nil, err - } - log.Debugf("CaptchaImage: Setting headers: %+v", response.Headers) - for k, v := range response.Headers { - httpCtx.Response().Header().Set(k, v) - } - log.Debugf("CaptchaImage: Writing response headers") - httpCtx.Response().WriteHeader(http.StatusOK) - log.Debugf("CaptchaImage: Writing response image") - if _, err := httpCtx.Response().Write(response.Image); err != nil { - log.Errorf("CaptchaImage error writing response: %v", err) - return nil, err - } - //log.Debugf("CaptchaImage: Flushing response writer") - //context.Response().Flush() - log.Debugf("CaptchaImage: Completed successfully") - return nil, nil -} - -func (s LoginServiceAgent) TokenRefresh(ctx context.Context, request *pb.TokenRefreshRequest) (*pb.TokenRefreshResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.TokenRefresh(ctx, request) - if err != nil { - log.Errorf("Refresh error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(resp.FromToken(response.Token)), - }) - return nil, nil -} - -func (s LoginServiceAgent) Login(ctx context.Context, request *pb.LoginRequest) (*pb.LoginResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.Login(ctx, request) - if err != nil { - log.Errorf("Login error: %v", err) - return nil, err - } - token := resp.FromToken(response.Token) - log.Debugf("Login: Token:%+v", token) - s.JSON(httpCtx, http.StatusOK, &resp.Result{ - Success: true, - Data: token, - }) - return nil, nil -} - -func (s LoginServiceAgent) Logout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { - httpCtx := agent.FromHTTPContext(ctx) - response, err := s.client.Logout(ctx, request) - if err != nil { - log.Errorf("Logout error: %v", err) - return nil, err - } - s.JSON(httpCtx, http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) - return nil, nil -} - -// NewLoginServiceAgent new a Login service. -func NewLoginServiceAgent(client pb.LoginServiceClient) *LoginServiceAgent { - return &LoginServiceAgent{client: client} -} - -// NewLoginServiceAgentPB new a Login service. -func NewLoginServiceAgentPB(client pb.LoginServiceClient) pb.LoginServiceAgent { - return &LoginServiceAgent{client: client} -} -func NewLoginServiceAgentClient(client *service.GRPCClient) pb.LoginServiceAgent { - cli := pb.NewLoginServiceClient(client) - return NewLoginServiceAgent(cli) -} - -var _ pb.LoginServiceAgent = (*LoginServiceAgent)(nil) diff --git a/internal/mods/auth/service/login.bridge.go b/internal/mods/auth/service/login.bridge.go new file mode 100644 index 00000000..713fecf6 --- /dev/null +++ b/internal/mods/auth/service/login.bridge.go @@ -0,0 +1,251 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + context2 "context" + "net/http" + + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/helpers/resp" +) + +// LoginServiceHookedBridge is a Login service. +type LoginServiceHookedBridge struct { + pb.UnimplementedLoginServiceHooked + log *log.KHelper +} + +func (s LoginServiceHookedBridge) CaptchaResult(h transhttp.Context, request *pb.CaptchaRequest, response *pb.CaptchaResponse) error { + return h.JSON(http.StatusOK, &resp.Data{ + Success: true, + Data: resp.Proto2Any(response), + }) +} + +func (s LoginServiceHookedBridge) CaptchaAudioResult(h transhttp.Context, request *pb.CaptchaAudioRequest, response *pb.CaptchaAudioResponse) error { + return h.JSON(http.StatusOK, &resp.Data{ + Success: true, + Data: resp.Proto2Any(response), + }) +} + +func (s LoginServiceHookedBridge) CaptchaIdResult(h transhttp.Context, request *pb.CaptchaIdRequest, response *pb.CaptchaIdResponse) error { + return h.JSON(http.StatusOK, &resp.Data{ + Success: true, + Data: resp.Proto2Any(response), + }) +} + +func (s LoginServiceHookedBridge) CaptchaImageResult(h transhttp.Context, request *pb.CaptchaImageRequest, response *pb.CaptchaImageResponse) error { + s.log.Debugf("CaptchaImage: Setting headers: %+v", response.Headers) + for k, v := range response.Headers { + h.Response().Header().Set(k, v) + } + s.log.Debugf("CaptchaImage: Writing response headers") + h.Response().WriteHeader(http.StatusOK) + s.log.Debugf("CaptchaImage: Writing response image") + if _, err := h.Response().Write(response.Image); err != nil { + log.Errorf("CaptchaImage error writing response: %v", err) + return err + } + s.log.Debugf("CaptchaImage: Completed successfully") + return nil +} + +func (s LoginServiceHookedBridge) BeforeLogin(h transhttp.Context, request *pb.LoginRequest) (context2.Context, error) { + //TODO implement me + panic("implement me") +} + +func (s LoginServiceHookedBridge) LoginResult(h transhttp.Context, request *pb.LoginRequest, response *pb.LoginResponse) error { + //TODO implement me + panic("implement me") +} + +func (s LoginServiceHookedBridge) BeforeLogout(h transhttp.Context, request *pb.LogoutRequest) (context2.Context, error) { + //TODO implement me + panic("implement me") +} + +func (s LoginServiceHookedBridge) LogoutResult(h transhttp.Context, request *pb.LogoutRequest, response *pb.LogoutResponse) error { + //TODO implement me + panic("implement me") +} + +func (s LoginServiceHookedBridge) BeforeRegister(h transhttp.Context, request *pb.RegisterRequest) (context2.Context, error) { + //TODO implement me + panic("implement me") +} + +func (s LoginServiceHookedBridge) RegisterResult(h transhttp.Context, request *pb.RegisterRequest, response *pb.RegisterResponse) error { + //TODO implement me + panic("implement me") +} + +func (s LoginServiceHookedBridge) TokenRefreshResult(h transhttp.Context, request *pb.TokenRefreshRequest, response *pb.TokenRefreshResponse) error { + return h.JSON(http.StatusOK, &resp.Data{ + Success: true, + Data: resp.Proto2Any(resp.FromToken(response.Token)), + }) +} + +//func (s LoginServiceHookedBridge) PersonalLogout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Logout(ctx, request) +// if err != nil { +// log.Errorf("Logout error: %v", err) +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Data{ +// Success: true, +// Data: resp.Proto2Any(response), +// }) +// return nil, nil +//} +// +//func (s LoginServiceHookedBridge) Register(ctx context.Context, request *pb.RegisterRequest) (*pb.RegisterResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Register(ctx, request) +// if err != nil { +// log.Errorf("Register error: %v", err) +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Data{ +// Success: true, +// Data: resp.Proto2Any(response), +// }) +// return nil, nil +//} +// +//func (s LoginServiceHookedBridge) Captcha(ctx context.Context, request *pb.CaptchaRequest) (*pb.CaptchaResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Captcha(ctx, request) +// if err != nil { +// log.Errorf("Captcha error: %v", err) +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Data{ +// Success: true, +// Data: resp.Proto2Any(response), +// }) +// return nil, nil +//} +// +//func (s LoginServiceHookedBridge) CaptchaId(ctx context.Context, request *pb.CaptchaIdRequest) (*pb.CaptchaIdResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// log.Debugf("CaptchaId: Request:%+v", request) +// response, err := s.client.CaptchaId(ctx, request) +// log.Debugf("CaptchaId: Response:%+v, Error:%+v", response, err) +// if err != nil { +// log.Errorf("CaptchaImage error: %v", err) +// return nil, err +// } +// +// s.JSON(httpCtx, http.StatusOK, &resp.StringResult{ +// Success: true, +// Data: response.Data, +// }) +// return nil, nil +//} +// +//func (s LoginServiceHookedBridge) CaptchaAudio(ctx context.Context, request *pb.CaptchaAudioRequest) (*pb.CaptchaAudioResponse, error) { +// _, err := s.client.CaptchaAudio(ctx, request) +// if err != nil { +// log.Errorf("Logout error: %v", err) +// return nil, err +// } +// return nil, nil +//} +//func (s LoginServiceHookedBridge) CaptchaImage(ctx context.Context, request *pb.CaptchaImageRequest) (*pb.CaptchaImageResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// log.Debugf("CaptchaImage: Request:%+v", request) +// response, err := s.client.CaptchaImage(ctx, request) +// log.Debugf("CaptchaImage: Response:%+v, Error:%+v", response, err) +// if err != nil { +// log.Errorf("CaptchaImage error: %v", err) +// return nil, err +// } +// log.Debugf("CaptchaImage: Setting headers: %+v", response.Headers) +// for k, v := range response.Headers { +// httpCtx.Response().Header().Set(k, v) +// } +// log.Debugf("CaptchaImage: Writing response headers") +// httpCtx.Response().WriteHeader(http.StatusOK) +// log.Debugf("CaptchaImage: Writing response image") +// if _, err := httpCtx.Response().Write(response.Image); err != nil { +// log.Errorf("CaptchaImage error writing response: %v", err) +// return nil, err +// } +// //log.Debugf("CaptchaImage: Flushing response writer") +// //context.Response().Flush() +// log.Debugf("CaptchaImage: Completed successfully") +// return nil, nil +//} +// +//func (s LoginServiceHookedBridge) TokenRefresh(ctx context.Context, request *pb.TokenRefreshRequest) (*pb.TokenRefreshResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.TokenRefresh(ctx, request) +// if err != nil { +// log.Errorf("Refresh error: %v", err) +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Data{ +// Success: true, +// Data: resp.Proto2Any(resp.FromToken(response.Token)), +// }) +// return nil, nil +//} +// +//func (s LoginServiceHookedBridge) Login(ctx context.Context, request *pb.LoginRequest) (*pb.LoginResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Login(ctx, request) +// if err != nil { +// log.Errorf("Login error: %v", err) +// return nil, err +// } +// token := resp.FromToken(response.Token) +// log.Debugf("Login: Token:%+v", token) +// s.JSON(httpCtx, http.StatusOK, &resp.Result{ +// Success: true, +// Data: token, +// }) +// return nil, nil +//} +// +//func (s LoginServiceHookedBridge) Logout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Logout(ctx, request) +// if err != nil { +// log.Errorf("Logout error: %v", err) +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Data{ +// Success: true, +// Data: resp.Proto2Any(response), +// }) +// return nil, nil +//} + +func NewLoginServiceHookedBridge(r runtime.Runtime, client pb.LoginServiceHTTPServer) pb.LoginServiceHookedBridger { + return pb.WithLoginServiceHook(&LoginServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/permission")), + })(client) +} + +// NewLoginServiceBridge new a menu service. +func NewLoginServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.LoginServiceServer { + return pb.NewLoginServiceBridge(client) +} + +// NewLoginServiceHTTPBridge new a menu service. +func NewLoginServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.LoginServiceHTTPServer { + return pb.NewLoginServiceHTTPBridge(client) +} From 0f88c43741b941127943bd4ed163fb68441a5282 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 4 Jun 2025 16:07:09 +0800 Subject: [PATCH 037/158] refactor(auth): update API and remove unused endpoints - Remove unused StreamRules endpoint from Casbin service - Add descriptions to AuthService methods in proto file - Update API gateway and HTTP handlers to reflect changes - Remove unnecessary comments and improve code readability --- ...igadmin_application_admin_cmd_auth.run.xml | 12 +++++ api/v1/proto/auth/auth.proto | 3 ++ api/v1/proto/auth/casbin.proto | 10 ++-- api/v1/proto/auth/login.proto | 2 - api/v1/services/auth/auth_bridge.pb.go | 9 ++-- api/v1/services/auth/auth_grpc.pb.go | 6 +++ api/v1/services/auth/auth_http.pb.go | 3 ++ api/v1/services/auth/casbin.pb.go | 6 +-- api/v1/services/auth/casbin.pb.gw.go | 52 ------------------- api/v1/services/system/personal_bridge.pb.go | 16 +++--- api/v1/services/system/user_bridge.pb.go | 6 +-- resources/docs/openapi/openapi.yaml | 37 ++----------- 12 files changed, 52 insertions(+), 110 deletions(-) create mode 100644 .run/go build origadmin_application_admin_cmd_auth.run.xml diff --git a/.run/go build origadmin_application_admin_cmd_auth.run.xml b/.run/go build origadmin_application_admin_cmd_auth.run.xml new file mode 100644 index 00000000..ceb79f01 --- /dev/null +++ b/.run/go build origadmin_application_admin_cmd_auth.run.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index bbdf5a75..17fec1d5 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -13,6 +13,7 @@ option java_package = "com.origadmin.api.v1.services.auth"; option objc_class_prefix = "APIServiceAuthAuth"; service AuthService { + // ListAuthResources returns a list of Auths. rpc ListAuthResources(ListAuthResourcesRequest) returns (ListAuthResourcesResponse) { option (google.api.http) = {get: "/sys/auth/resources"}; } @@ -37,6 +38,7 @@ service AuthService { }; } + // Authenticate authenticates a user. rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) { option (google.api.http) = { post: "/sys/auth/authenticate" @@ -44,6 +46,7 @@ service AuthService { }; } + // AuthLogout logs out a user. rpc AuthLogout(AuthLogoutRequest) returns (AuthLogoutResponse) { option (google.api.http) = { post: "/sys/auth/logout" diff --git a/api/v1/proto/auth/casbin.proto b/api/v1/proto/auth/casbin.proto index 790beb44..0fc566ef 100644 --- a/api/v1/proto/auth/casbin.proto +++ b/api/v1/proto/auth/casbin.proto @@ -35,11 +35,11 @@ service CasbinSourceService { } rpc StreamRules(StreamRulesRequest) returns (stream StreamRulesResponse) { - option (google.api.http) = { - get: "/casbin/stream" - response_body: "*" - }; - // (google.api.method_signature) = "with_policies,with_groupings"; +// option (google.api.http) = { +// get: "/casbin/stream" +// response_body: "*" +// }; +// (google.api.method_signature) = "with_policies,with_groupings"; } } diff --git a/api/v1/proto/auth/login.proto b/api/v1/proto/auth/login.proto index e41c5072..c141988a 100644 --- a/api/v1/proto/auth/login.proto +++ b/api/v1/proto/auth/login.proto @@ -36,7 +36,6 @@ service LoginService { response_body: "*" }; } - rpc Login (LoginRequest) returns (LoginResponse) { option (google.api.http) = { post: "/login" @@ -55,7 +54,6 @@ service LoginService { body: "data" }; } - rpc TokenRefresh (TokenRefreshRequest) returns (TokenRefreshResponse) { option (google.api.http) = { post: "/token/refresh" diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index 50d397ec..3ba9be0e 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -36,14 +36,17 @@ const AuthServiceListAuthResourcesBridgeOperation = "/api.v1.services.auth.AuthS const AuthServiceValidateTokenBridgeOperation = "/api.v1.services.auth.AuthService/ValidateToken" type AuthServiceBridger interface { + // AuthLogout logs out a user. AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) + // Authenticate authenticates a user. Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) - // CreateToken CreateToken generates a new JWT token for the given user. + // CreateToken generates a new JWT token for the given user. CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) - // DestroyToken DestroyToken invalidates a JWT token. + // DestroyToken invalidates a JWT token. DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) + // ListAuthResources returns a list of Auths. ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) - // ValidateToken ValidateToken verifies the validity of a JWT token. + // ValidateToken verifies the validity of a JWT token. ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) } diff --git a/api/v1/services/auth/auth_grpc.pb.go b/api/v1/services/auth/auth_grpc.pb.go index daf79cd9..fcac5f0b 100644 --- a/api/v1/services/auth/auth_grpc.pb.go +++ b/api/v1/services/auth/auth_grpc.pb.go @@ -31,6 +31,7 @@ const ( // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type AuthServiceClient interface { + // ListAuthResources returns a list of Auths. ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...grpc.CallOption) (*ListAuthResourcesResponse, error) // CreateToken generates a new JWT token for the given user. CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...grpc.CallOption) (*CreateTokenResponse, error) @@ -38,7 +39,9 @@ type AuthServiceClient interface { ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*ValidateTokenResponse, error) // DestroyToken invalidates a JWT token. DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...grpc.CallOption) (*DestroyTokenResponse, error) + // Authenticate authenticates a user. Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) + // AuthLogout logs out a user. AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...grpc.CallOption) (*AuthLogoutResponse, error) } @@ -114,6 +117,7 @@ func (c *authServiceClient) AuthLogout(ctx context.Context, in *AuthLogoutReques // All implementations must embed UnimplementedAuthServiceServer // for forward compatibility. type AuthServiceServer interface { + // ListAuthResources returns a list of Auths. ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) // CreateToken generates a new JWT token for the given user. CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) @@ -121,7 +125,9 @@ type AuthServiceServer interface { ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) // DestroyToken invalidates a JWT token. DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) + // Authenticate authenticates a user. Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) + // AuthLogout logs out a user. AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) mustEmbedUnimplementedAuthServiceServer() } diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go index f35712a4..96f13b45 100644 --- a/api/v1/services/auth/auth_http.pb.go +++ b/api/v1/services/auth/auth_http.pb.go @@ -27,12 +27,15 @@ const OperationAuthServiceListAuthResources = "/api.v1.services.auth.AuthService const OperationAuthServiceValidateToken = "/api.v1.services.auth.AuthService/ValidateToken" type AuthServiceHTTPServer interface { + // AuthLogout AuthLogout logs out a user. AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) + // Authenticate Authenticate authenticates a user. Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) // CreateToken CreateToken generates a new JWT token for the given user. CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) // DestroyToken DestroyToken invalidates a JWT token. DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) + // ListAuthResources ListAuthResources returns a list of Auths. ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) // ValidateToken ValidateToken verifies the validity of a JWT token. ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) diff --git a/api/v1/services/auth/casbin.pb.go b/api/v1/services/auth/casbin.pb.go index 87ff2c98..3bda3719 100644 --- a/api/v1/services/auth/casbin.pb.go +++ b/api/v1/services/auth/casbin.pb.go @@ -536,12 +536,12 @@ const file_auth_casbin_proto_rawDesc = "" + "\x12WatchUpdateRequest\x12$\n" + "\rlast_modified\x18\x01 \x01(\x03R\rlast_modified\";\n" + "\x13WatchUpdateResponse\x12$\n" + - "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\xa2\x04\n" + + "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\x89\x04\n" + "\x13CasbinSourceService\x12\x82\x01\n" + "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x86\x01\n" + "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12|\n" + - "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12\x7f\n" + - "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/casbin/stream0\x01B\xb6\x01\n" + + "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12f\n" + + "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xb6\x01\n" + "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( diff --git a/api/v1/services/auth/casbin.pb.gw.go b/api/v1/services/auth/casbin.pb.gw.go index fd9a0c2c..b20ef61b 100644 --- a/api/v1/services/auth/casbin.pb.gw.go +++ b/api/v1/services/auth/casbin.pb.gw.go @@ -106,32 +106,6 @@ func local_request_CasbinSourceService_WatchUpdate_0(ctx context.Context, marsha return msg, metadata, err } -var filter_CasbinSourceService_StreamRules_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_CasbinSourceService_StreamRules_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinSourceServiceClient, req *http.Request, pathParams map[string]string) (CasbinSourceService_StreamRulesClient, runtime.ServerMetadata, error) { - var ( - protoReq StreamRulesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CasbinSourceService_StreamRules_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - stream, err := client.StreamRules(ctx, &protoReq) - if err != nil { - return nil, metadata, err - } - header, err := stream.Header() - if err != nil { - return nil, metadata, err - } - metadata.HeaderMD = header - return stream, metadata, nil -} - // RegisterCasbinSourceServiceHandlerServer registers the http handlers for service CasbinSourceService to "mux". // UnaryRPC :call CasbinSourceServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -199,13 +173,6 @@ func RegisterCasbinSourceServiceHandlerServer(ctx context.Context, mux *runtime. forward_CasbinSourceService_WatchUpdate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_CasbinSourceService_StreamRules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport") - _, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - }) - return nil } @@ -296,23 +263,6 @@ func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime. } forward_CasbinSourceService_WatchUpdate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_CasbinSourceService_StreamRules_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/StreamRules", runtime.WithHTTPPathPattern("/casbin/stream")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_CasbinSourceService_StreamRules_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_CasbinSourceService_StreamRules_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...) - }) return nil } @@ -320,12 +270,10 @@ var ( pattern_CasbinSourceService_ListPolicies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "policies"}, "")) pattern_CasbinSourceService_ListGroupings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "groupings"}, "")) pattern_CasbinSourceService_WatchUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "watch"}, "")) - pattern_CasbinSourceService_StreamRules_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "stream"}, "")) ) var ( forward_CasbinSourceService_ListPolicies_0 = runtime.ForwardResponseMessage forward_CasbinSourceService_ListGroupings_0 = runtime.ForwardResponseMessage forward_CasbinSourceService_WatchUpdate_0 = runtime.ForwardResponseMessage - forward_CasbinSourceService_StreamRules_0 = runtime.ForwardResponseStream ) diff --git a/api/v1/services/system/personal_bridge.pb.go b/api/v1/services/system/personal_bridge.pb.go index 8ed40281..217edaf0 100644 --- a/api/v1/services/system/personal_bridge.pb.go +++ b/api/v1/services/system/personal_bridge.pb.go @@ -38,21 +38,21 @@ const PersonalServiceUpdatePersonalProfileBridgeOperation = "/api.v1.services.sy const PersonalServiceUpdatePersonalSettingBridgeOperation = "/api.v1.services.system.PersonalService/UpdatePersonalSetting" type PersonalServiceBridger interface { - // GetPersonalProfile GetPersonalProfile Update the personal user information + // GetPersonalProfile Update the personal user information GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources ListPersonalResources List the personal user's menu + // ListPersonalResources List the personal user's menu ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalRoles ListPersonalResources List the personal user's menu + // ListPersonalResources List the personal user's menu ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout PersonalLogout Personal user logs out + // PersonalLogout Personal user logs out PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token + // RefreshPersonalToken Refresh the personal user's token RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password + // UpdatePersonalProfilePassword The user changes the password UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information + // UpdatePersonalProfile Update the personal user information UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting UpdatePersonalSetting User settings are saved + // UpdatePersonalSetting User settings are saved UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) } diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 147696fb..945fdcbb 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -44,12 +44,12 @@ type UserServiceBridger interface { GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) - // ResetUserPassword ResetUserPassword reset the user s password + // ResetUserPassword reset the user s password ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) - // UpdateUserRoles UpdateUserRoles update the user roles + // UpdateUserRoles update the user roles UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) - // UpdateUserStatus UpdateUserStatus Update the status of the user information + // UpdateUserStatus Update the status of the user information UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) } diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index a2b796e4..e9346867 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -252,33 +252,6 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /casbin/stream: - get: - tags: - - CasbinSourceService - operationId: CasbinSourceService_StreamRules - parameters: - - name: with_policies - in: query - schema: - type: boolean - - name: with_groupings - in: query - schema: - type: boolean - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.StreamRulesResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' /casbin/watch: get: tags: @@ -378,6 +351,7 @@ paths: post: tags: - AuthService + description: Authenticate authenticates a user. operationId: AuthService_Authenticate requestBody: content: @@ -427,6 +401,7 @@ paths: post: tags: - AuthService + description: AuthLogout logs out a user. operationId: AuthService_AuthLogout requestBody: content: @@ -451,6 +426,7 @@ paths: get: tags: - AuthService + description: ListAuthResources returns a list of Auths. operationId: AuthService_ListAuthResources parameters: - name: page_size @@ -2459,13 +2435,6 @@ components: properties: redirect: type: string - api.v1.services.auth.StreamRulesResponse: - type: object - properties: - policy: - $ref: '#/components/schemas/api.v1.services.auth.PolicyRule' - grouping: - $ref: '#/components/schemas/api.v1.services.auth.GroupingRule' api.v1.services.auth.TokenRefreshRequest_Data: type: object properties: From e6ca58893bc8ad6e2fb19107e48ad9ae54e1e38e Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 5 Jun 2025 15:17:51 +0800 Subject: [PATCH 038/158] refactor(api): rename hook methods for consistency and clarity - Rename Before* methods to Prepare* for better naming convention - Rename *Result methods to Complete* to improve clarity - Update method names across multiple service interfaces for consistency - Add AuthErrorReason enum to error.proto for authentication errors --- api/v1/proto/types/error.proto | 7 + api/v1/services/auth/auth_bridge.pb.go | 72 ++++---- api/v1/services/auth/casbin_bridge.pb.go | 36 ++-- api/v1/services/auth/login_bridge.pb.go | 96 +++++------ .../services/system/department_bridge.pb.go | 60 +++---- api/v1/services/system/menu_bridge.pb.go | 60 +++---- .../services/system/permission_bridge.pb.go | 60 +++---- api/v1/services/system/personal_bridge.pb.go | 96 +++++------ api/v1/services/system/position_bridge.pb.go | 60 +++---- api/v1/services/system/resource_bridge.pb.go | 60 +++---- api/v1/services/system/role_bridge.pb.go | 60 +++---- api/v1/services/system/user_bridge.pb.go | 108 ++++++------ cmd/internal/start/start.go | 27 ++- cmd/internal/start/wire.go | 7 +- cmd/internal/start/wire_gen.go | 2 +- helpers/captcha/captcha.go | 8 +- helpers/db/db.go | 20 ++- internal/loader/bootstrap.go | 20 ++- internal/loader/config.go | 6 +- internal/loader/load.go | 4 +- internal/loader/proxy.go | 159 ++++++++++++++++++ internal/mods/auth/service/auth.bridge.go | 22 +-- internal/mods/auth/service/login.bridge.go | 22 +-- internal/mods/system/dal/permission.dal.go | 2 +- internal/mods/system/dal/resource.dal.go | 2 +- internal/mods/system/dal/role.dal.go | 2 +- internal/mods/system/dal/user.dal.go | 2 +- internal/mods/system/service/menu.bridge.go | 10 +- .../mods/system/service/permission.bridge.go | 10 +- .../mods/system/service/personal.bridge.go | 32 ++-- .../mods/system/service/resource.bridge.go | 10 +- internal/mods/system/service/role.bridge.go | 10 +- internal/mods/system/service/service.go | 6 + internal/mods/system/service/user.bridge.go | 10 +- 34 files changed, 687 insertions(+), 481 deletions(-) create mode 100644 internal/loader/proxy.go diff --git a/api/v1/proto/types/error.proto b/api/v1/proto/types/error.proto index b66749aa..2100cadd 100644 --- a/api/v1/proto/types/error.proto +++ b/api/v1/proto/types/error.proto @@ -33,3 +33,10 @@ enum SystemErrorReason { SYSTEM_ERROR_REASON_INVALID_USERNAME = 1005 [(errors.code) = 400]; SYSTEM_ERROR_REASON_INVALID_PASSWORD = 1006 [(errors.code) = 400]; } + +enum AuthErrorReason { + option (errors.default_code) = 500; + AUTH_ERROR_REASON_UNSPECIFIED = 0; + AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND = 2001 [(errors.code) = 404]; +} + diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index 3ba9be0e..b63f2642 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -64,28 +64,28 @@ type AuthServiceHookedBridger interface { AuthServiceBridger } type AuthServiceAuthLogoutHooker interface { - BeforeAuthLogout(http.Context, *AuthLogoutRequest) (context.Context, error) - AuthLogoutResult(http.Context, *AuthLogoutRequest, *AuthLogoutResponse) error + PrepareAuthLogout(http.Context, *AuthLogoutRequest) (context.Context, error) + CompleteAuthLogout(http.Context, *AuthLogoutRequest, *AuthLogoutResponse) error } type AuthServiceAuthenticateHooker interface { - BeforeAuthenticate(http.Context, *AuthenticateRequest) (context.Context, error) - AuthenticateResult(http.Context, *AuthenticateRequest, *AuthenticateResponse) error + PrepareAuthenticate(http.Context, *AuthenticateRequest) (context.Context, error) + CompleteAuthenticate(http.Context, *AuthenticateRequest, *AuthenticateResponse) error } type AuthServiceCreateTokenHooker interface { - BeforeCreateToken(http.Context, *CreateTokenRequest) (context.Context, error) - CreateTokenResult(http.Context, *CreateTokenRequest, *CreateTokenResponse) error + PrepareCreateToken(http.Context, *CreateTokenRequest) (context.Context, error) + CompleteCreateToken(http.Context, *CreateTokenRequest, *CreateTokenResponse) error } type AuthServiceDestroyTokenHooker interface { - BeforeDestroyToken(http.Context, *DestroyTokenRequest) (context.Context, error) - DestroyTokenResult(http.Context, *DestroyTokenRequest, *DestroyTokenResponse) error + PrepareDestroyToken(http.Context, *DestroyTokenRequest) (context.Context, error) + CompleteDestroyToken(http.Context, *DestroyTokenRequest, *DestroyTokenResponse) error } type AuthServiceListAuthResourcesHooker interface { - BeforeListAuthResources(http.Context, *ListAuthResourcesRequest) (context.Context, error) - ListAuthResourcesResult(http.Context, *ListAuthResourcesRequest, *ListAuthResourcesResponse) error + PrepareListAuthResources(http.Context, *ListAuthResourcesRequest) (context.Context, error) + CompleteListAuthResources(http.Context, *ListAuthResourcesRequest, *ListAuthResourcesResponse) error } type AuthServiceValidateTokenHooker interface { - BeforeValidateToken(http.Context, *ValidateTokenRequest) (context.Context, error) - ValidateTokenResult(http.Context, *ValidateTokenRequest, *ValidateTokenResponse) error + PrepareValidateToken(http.Context, *ValidateTokenRequest) (context.Context, error) + CompleteValidateToken(http.Context, *ValidateTokenRequest, *ValidateTokenResponse) error } func RegisterAuthServiceBridger(s *http.Server, srv AuthServiceHookedBridger) { @@ -109,7 +109,7 @@ func _AuthService_ListAuthResources0_Bridge_Handler(srv AuthServiceHookedBridger return srv.ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) }) - newctx, err := srv.BeforeListAuthResources(ctx, &in) + newctx, err := srv.PrepareListAuthResources(ctx, &in) if err != nil { return err } @@ -117,7 +117,7 @@ func _AuthService_ListAuthResources0_Bridge_Handler(srv AuthServiceHookedBridger if err != nil { return err } - return srv.ListAuthResourcesResult(ctx, &in, out.(*ListAuthResourcesResponse)) + return srv.CompleteListAuthResources(ctx, &in, out.(*ListAuthResourcesResponse)) } } @@ -135,7 +135,7 @@ func _AuthService_CreateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func return srv.CreateToken(ctx, req.(*CreateTokenRequest)) }) - newctx, err := srv.BeforeCreateToken(ctx, &in) + newctx, err := srv.PrepareCreateToken(ctx, &in) if err != nil { return err } @@ -143,7 +143,7 @@ func _AuthService_CreateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func if err != nil { return err } - return srv.CreateTokenResult(ctx, &in, out.(*CreateTokenResponse)) + return srv.CompleteCreateToken(ctx, &in, out.(*CreateTokenResponse)) } } @@ -158,7 +158,7 @@ func _AuthService_ValidateToken0_Bridge_Handler(srv AuthServiceHookedBridger) fu return srv.ValidateToken(ctx, req.(*ValidateTokenRequest)) }) - newctx, err := srv.BeforeValidateToken(ctx, &in) + newctx, err := srv.PrepareValidateToken(ctx, &in) if err != nil { return err } @@ -166,7 +166,7 @@ func _AuthService_ValidateToken0_Bridge_Handler(srv AuthServiceHookedBridger) fu if err != nil { return err } - return srv.ValidateTokenResult(ctx, &in, out.(*ValidateTokenResponse)) + return srv.CompleteValidateToken(ctx, &in, out.(*ValidateTokenResponse)) } } @@ -184,7 +184,7 @@ func _AuthService_DestroyToken0_Bridge_Handler(srv AuthServiceHookedBridger) fun return srv.DestroyToken(ctx, req.(*DestroyTokenRequest)) }) - newctx, err := srv.BeforeDestroyToken(ctx, &in) + newctx, err := srv.PrepareDestroyToken(ctx, &in) if err != nil { return err } @@ -192,7 +192,7 @@ func _AuthService_DestroyToken0_Bridge_Handler(srv AuthServiceHookedBridger) fun if err != nil { return err } - return srv.DestroyTokenResult(ctx, &in, out.(*DestroyTokenResponse)) + return srv.CompleteDestroyToken(ctx, &in, out.(*DestroyTokenResponse)) } } @@ -210,7 +210,7 @@ func _AuthService_Authenticate0_Bridge_Handler(srv AuthServiceHookedBridger) fun return srv.Authenticate(ctx, req.(*AuthenticateRequest)) }) - newctx, err := srv.BeforeAuthenticate(ctx, &in) + newctx, err := srv.PrepareAuthenticate(ctx, &in) if err != nil { return err } @@ -218,7 +218,7 @@ func _AuthService_Authenticate0_Bridge_Handler(srv AuthServiceHookedBridger) fun if err != nil { return err } - return srv.AuthenticateResult(ctx, &in, out.(*AuthenticateResponse)) + return srv.CompleteAuthenticate(ctx, &in, out.(*AuthenticateResponse)) } } @@ -236,7 +236,7 @@ func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceHookedBridger) func( return srv.AuthLogout(ctx, req.(*AuthLogoutRequest)) }) - newctx, err := srv.BeforeAuthLogout(ctx, &in) + newctx, err := srv.PrepareAuthLogout(ctx, &in) if err != nil { return err } @@ -244,7 +244,7 @@ func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceHookedBridger) func( if err != nil { return err } - return srv.AuthLogoutResult(ctx, &in, out.(*AuthLogoutResponse)) + return srv.CompleteAuthLogout(ctx, &in, out.(*AuthLogoutResponse)) } } @@ -255,51 +255,51 @@ func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceHookedBridger) func( // pointer dereference when methods are called. type UnimplementedAuthServiceHooked struct{} -func (UnimplementedAuthServiceHooked) BeforeAuthLogout(ctx http.Context, in *AuthLogoutRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareAuthLogout(ctx http.Context, in *AuthLogoutRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) AuthLogoutResult(ctx http.Context, in *AuthLogoutRequest, out *AuthLogoutResponse) error { +func (UnimplementedAuthServiceHooked) CompleteAuthLogout(ctx http.Context, in *AuthLogoutRequest, out *AuthLogoutResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceHooked) BeforeAuthenticate(ctx http.Context, in *AuthenticateRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareAuthenticate(ctx http.Context, in *AuthenticateRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) AuthenticateResult(ctx http.Context, in *AuthenticateRequest, out *AuthenticateResponse) error { +func (UnimplementedAuthServiceHooked) CompleteAuthenticate(ctx http.Context, in *AuthenticateRequest, out *AuthenticateResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceHooked) BeforeCreateToken(ctx http.Context, in *CreateTokenRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareCreateToken(ctx http.Context, in *CreateTokenRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) CreateTokenResult(ctx http.Context, in *CreateTokenRequest, out *CreateTokenResponse) error { +func (UnimplementedAuthServiceHooked) CompleteCreateToken(ctx http.Context, in *CreateTokenRequest, out *CreateTokenResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceHooked) BeforeDestroyToken(ctx http.Context, in *DestroyTokenRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareDestroyToken(ctx http.Context, in *DestroyTokenRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) DestroyTokenResult(ctx http.Context, in *DestroyTokenRequest, out *DestroyTokenResponse) error { +func (UnimplementedAuthServiceHooked) CompleteDestroyToken(ctx http.Context, in *DestroyTokenRequest, out *DestroyTokenResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceHooked) BeforeListAuthResources(ctx http.Context, in *ListAuthResourcesRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareListAuthResources(ctx http.Context, in *ListAuthResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) ListAuthResourcesResult(ctx http.Context, in *ListAuthResourcesRequest, out *ListAuthResourcesResponse) error { +func (UnimplementedAuthServiceHooked) CompleteListAuthResources(ctx http.Context, in *ListAuthResourcesRequest, out *ListAuthResourcesResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceHooked) BeforeValidateToken(ctx http.Context, in *ValidateTokenRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareValidateToken(ctx http.Context, in *ValidateTokenRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) ValidateTokenResult(ctx http.Context, in *ValidateTokenRequest, out *ValidateTokenResponse) error { +func (UnimplementedAuthServiceHooked) CompleteValidateToken(ctx http.Context, in *ValidateTokenRequest, out *ValidateTokenResponse) error { return ctx.Result(200, out) } diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index a41d9300..c8762bdf 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -49,16 +49,16 @@ type CasbinSourceServiceHookedBridger interface { CasbinSourceServiceBridger } type CasbinSourceServiceListGroupingsHooker interface { - BeforeListGroupings(http.Context, *ListGroupingsRequest) (context.Context, error) - ListGroupingsResult(http.Context, *ListGroupingsRequest, *ListGroupingsResponse) error + PrepareListGroupings(http.Context, *ListGroupingsRequest) (context.Context, error) + CompleteListGroupings(http.Context, *ListGroupingsRequest, *ListGroupingsResponse) error } type CasbinSourceServiceListPoliciesHooker interface { - BeforeListPolicies(http.Context, *ListPoliciesRequest) (context.Context, error) - ListPoliciesResult(http.Context, *ListPoliciesRequest, *ListPoliciesResponse) error + PrepareListPolicies(http.Context, *ListPoliciesRequest) (context.Context, error) + CompleteListPolicies(http.Context, *ListPoliciesRequest, *ListPoliciesResponse) error } type CasbinSourceServiceWatchUpdateHooker interface { - BeforeWatchUpdate(http.Context, *WatchUpdateRequest) (context.Context, error) - WatchUpdateResult(http.Context, *WatchUpdateRequest, *WatchUpdateResponse) error + PrepareWatchUpdate(http.Context, *WatchUpdateRequest) (context.Context, error) + CompleteWatchUpdate(http.Context, *WatchUpdateRequest, *WatchUpdateResponse) error } func RegisterCasbinSourceServiceBridger(s *http.Server, srv CasbinSourceServiceHookedBridger) { @@ -79,7 +79,7 @@ func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceHo return srv.ListPolicies(ctx, req.(*ListPoliciesRequest)) }) - newctx, err := srv.BeforeListPolicies(ctx, &in) + newctx, err := srv.PrepareListPolicies(ctx, &in) if err != nil { return err } @@ -87,7 +87,7 @@ func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceHo if err != nil { return err } - return srv.ListPoliciesResult(ctx, &in, out.(*ListPoliciesResponse)) + return srv.CompleteListPolicies(ctx, &in, out.(*ListPoliciesResponse)) } } @@ -102,7 +102,7 @@ func _CasbinSourceService_ListGroupings0_Bridge_Handler(srv CasbinSourceServiceH return srv.ListGroupings(ctx, req.(*ListGroupingsRequest)) }) - newctx, err := srv.BeforeListGroupings(ctx, &in) + newctx, err := srv.PrepareListGroupings(ctx, &in) if err != nil { return err } @@ -110,7 +110,7 @@ func _CasbinSourceService_ListGroupings0_Bridge_Handler(srv CasbinSourceServiceH if err != nil { return err } - return srv.ListGroupingsResult(ctx, &in, out.(*ListGroupingsResponse)) + return srv.CompleteListGroupings(ctx, &in, out.(*ListGroupingsResponse)) } } @@ -125,7 +125,7 @@ func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceHoo return srv.WatchUpdate(ctx, req.(*WatchUpdateRequest)) }) - newctx, err := srv.BeforeWatchUpdate(ctx, &in) + newctx, err := srv.PrepareWatchUpdate(ctx, &in) if err != nil { return err } @@ -133,7 +133,7 @@ func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceHoo if err != nil { return err } - return srv.WatchUpdateResult(ctx, &in, out.(*WatchUpdateResponse)) + return srv.CompleteWatchUpdate(ctx, &in, out.(*WatchUpdateResponse)) } } @@ -144,27 +144,27 @@ func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceHoo // pointer dereference when methods are called. type UnimplementedCasbinSourceServiceHooked struct{} -func (UnimplementedCasbinSourceServiceHooked) BeforeListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { +func (UnimplementedCasbinSourceServiceHooked) PrepareListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceHooked) ListGroupingsResult(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { +func (UnimplementedCasbinSourceServiceHooked) CompleteListGroupings(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { return ctx.Result(200, out) } -func (UnimplementedCasbinSourceServiceHooked) BeforeListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { +func (UnimplementedCasbinSourceServiceHooked) PrepareListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceHooked) ListPoliciesResult(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { +func (UnimplementedCasbinSourceServiceHooked) CompleteListPolicies(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { return ctx.Result(200, out) } -func (UnimplementedCasbinSourceServiceHooked) BeforeWatchUpdate(ctx http.Context, in *WatchUpdateRequest) (context.Context, error) { +func (UnimplementedCasbinSourceServiceHooked) PrepareWatchUpdate(ctx http.Context, in *WatchUpdateRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceHooked) WatchUpdateResult(ctx http.Context, in *WatchUpdateRequest, out *WatchUpdateResponse) error { +func (UnimplementedCasbinSourceServiceHooked) CompleteWatchUpdate(ctx http.Context, in *WatchUpdateRequest, out *WatchUpdateResponse) error { return ctx.Result(200, out) } diff --git a/api/v1/services/auth/login_bridge.pb.go b/api/v1/services/auth/login_bridge.pb.go index 9002a4f3..7d0b5265 100644 --- a/api/v1/services/auth/login_bridge.pb.go +++ b/api/v1/services/auth/login_bridge.pb.go @@ -64,36 +64,36 @@ type LoginServiceHookedBridger interface { LoginServiceBridger } type LoginServiceCaptchaHooker interface { - BeforeCaptcha(http.Context, *CaptchaRequest) (context.Context, error) - CaptchaResult(http.Context, *CaptchaRequest, *CaptchaResponse) error + PrepareCaptcha(http.Context, *CaptchaRequest) (context.Context, error) + CompleteCaptcha(http.Context, *CaptchaRequest, *CaptchaResponse) error } type LoginServiceCaptchaAudioHooker interface { - BeforeCaptchaAudio(http.Context, *CaptchaAudioRequest) (context.Context, error) - CaptchaAudioResult(http.Context, *CaptchaAudioRequest, *CaptchaAudioResponse) error + PrepareCaptchaAudio(http.Context, *CaptchaAudioRequest) (context.Context, error) + CompleteCaptchaAudio(http.Context, *CaptchaAudioRequest, *CaptchaAudioResponse) error } type LoginServiceCaptchaIdHooker interface { - BeforeCaptchaId(http.Context, *CaptchaIdRequest) (context.Context, error) - CaptchaIdResult(http.Context, *CaptchaIdRequest, *CaptchaIdResponse) error + PrepareCaptchaId(http.Context, *CaptchaIdRequest) (context.Context, error) + CompleteCaptchaId(http.Context, *CaptchaIdRequest, *CaptchaIdResponse) error } type LoginServiceCaptchaImageHooker interface { - BeforeCaptchaImage(http.Context, *CaptchaImageRequest) (context.Context, error) - CaptchaImageResult(http.Context, *CaptchaImageRequest, *CaptchaImageResponse) error + PrepareCaptchaImage(http.Context, *CaptchaImageRequest) (context.Context, error) + CompleteCaptchaImage(http.Context, *CaptchaImageRequest, *CaptchaImageResponse) error } type LoginServiceLoginHooker interface { - BeforeLogin(http.Context, *LoginRequest) (context.Context, error) - LoginResult(http.Context, *LoginRequest, *LoginResponse) error + PrepareLogin(http.Context, *LoginRequest) (context.Context, error) + CompleteLogin(http.Context, *LoginRequest, *LoginResponse) error } type LoginServiceLogoutHooker interface { - BeforeLogout(http.Context, *LogoutRequest) (context.Context, error) - LogoutResult(http.Context, *LogoutRequest, *LogoutResponse) error + PrepareLogout(http.Context, *LogoutRequest) (context.Context, error) + CompleteLogout(http.Context, *LogoutRequest, *LogoutResponse) error } type LoginServiceRegisterHooker interface { - BeforeRegister(http.Context, *RegisterRequest) (context.Context, error) - RegisterResult(http.Context, *RegisterRequest, *RegisterResponse) error + PrepareRegister(http.Context, *RegisterRequest) (context.Context, error) + CompleteRegister(http.Context, *RegisterRequest, *RegisterResponse) error } type LoginServiceTokenRefreshHooker interface { - BeforeTokenRefresh(http.Context, *TokenRefreshRequest) (context.Context, error) - TokenRefreshResult(http.Context, *TokenRefreshRequest, *TokenRefreshResponse) error + PrepareTokenRefresh(http.Context, *TokenRefreshRequest) (context.Context, error) + CompleteTokenRefresh(http.Context, *TokenRefreshRequest, *TokenRefreshResponse) error } func RegisterLoginServiceBridger(s *http.Server, srv LoginServiceHookedBridger) { @@ -119,7 +119,7 @@ func _LoginService_Captcha0_Bridge_Handler(srv LoginServiceHookedBridger) func(c return srv.Captcha(ctx, req.(*CaptchaRequest)) }) - newctx, err := srv.BeforeCaptcha(ctx, &in) + newctx, err := srv.PrepareCaptcha(ctx, &in) if err != nil { return err } @@ -127,7 +127,7 @@ func _LoginService_Captcha0_Bridge_Handler(srv LoginServiceHookedBridger) func(c if err != nil { return err } - return srv.CaptchaResult(ctx, &in, out.(*CaptchaResponse)) + return srv.CompleteCaptcha(ctx, &in, out.(*CaptchaResponse)) } } @@ -142,7 +142,7 @@ func _LoginService_CaptchaId0_Bridge_Handler(srv LoginServiceHookedBridger) func return srv.CaptchaId(ctx, req.(*CaptchaIdRequest)) }) - newctx, err := srv.BeforeCaptchaId(ctx, &in) + newctx, err := srv.PrepareCaptchaId(ctx, &in) if err != nil { return err } @@ -150,7 +150,7 @@ func _LoginService_CaptchaId0_Bridge_Handler(srv LoginServiceHookedBridger) func if err != nil { return err } - return srv.CaptchaIdResult(ctx, &in, out.(*CaptchaIdResponse)) + return srv.CompleteCaptchaId(ctx, &in, out.(*CaptchaIdResponse)) } } @@ -165,7 +165,7 @@ func _LoginService_CaptchaImage0_Bridge_Handler(srv LoginServiceHookedBridger) f return srv.CaptchaImage(ctx, req.(*CaptchaImageRequest)) }) - newctx, err := srv.BeforeCaptchaImage(ctx, &in) + newctx, err := srv.PrepareCaptchaImage(ctx, &in) if err != nil { return err } @@ -173,7 +173,7 @@ func _LoginService_CaptchaImage0_Bridge_Handler(srv LoginServiceHookedBridger) f if err != nil { return err } - return srv.CaptchaImageResult(ctx, &in, out.(*CaptchaImageResponse)) + return srv.CompleteCaptchaImage(ctx, &in, out.(*CaptchaImageResponse)) } } @@ -188,7 +188,7 @@ func _LoginService_CaptchaAudio0_Bridge_Handler(srv LoginServiceHookedBridger) f return srv.CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) }) - newctx, err := srv.BeforeCaptchaAudio(ctx, &in) + newctx, err := srv.PrepareCaptchaAudio(ctx, &in) if err != nil { return err } @@ -196,7 +196,7 @@ func _LoginService_CaptchaAudio0_Bridge_Handler(srv LoginServiceHookedBridger) f if err != nil { return err } - return srv.CaptchaAudioResult(ctx, &in, out.(*CaptchaAudioResponse)) + return srv.CompleteCaptchaAudio(ctx, &in, out.(*CaptchaAudioResponse)) } } @@ -214,7 +214,7 @@ func _LoginService_Login0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx return srv.Login(ctx, req.(*LoginRequest)) }) - newctx, err := srv.BeforeLogin(ctx, &in) + newctx, err := srv.PrepareLogin(ctx, &in) if err != nil { return err } @@ -222,7 +222,7 @@ func _LoginService_Login0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx if err != nil { return err } - return srv.LoginResult(ctx, &in, out.(*LoginResponse)) + return srv.CompleteLogin(ctx, &in, out.(*LoginResponse)) } } @@ -240,7 +240,7 @@ func _LoginService_Logout0_Bridge_Handler(srv LoginServiceHookedBridger) func(ct return srv.Logout(ctx, req.(*LogoutRequest)) }) - newctx, err := srv.BeforeLogout(ctx, &in) + newctx, err := srv.PrepareLogout(ctx, &in) if err != nil { return err } @@ -248,7 +248,7 @@ func _LoginService_Logout0_Bridge_Handler(srv LoginServiceHookedBridger) func(ct if err != nil { return err } - return srv.LogoutResult(ctx, &in, out.(*LogoutResponse)) + return srv.CompleteLogout(ctx, &in, out.(*LogoutResponse)) } } @@ -266,7 +266,7 @@ func _LoginService_Register0_Bridge_Handler(srv LoginServiceHookedBridger) func( return srv.Register(ctx, req.(*RegisterRequest)) }) - newctx, err := srv.BeforeRegister(ctx, &in) + newctx, err := srv.PrepareRegister(ctx, &in) if err != nil { return err } @@ -274,7 +274,7 @@ func _LoginService_Register0_Bridge_Handler(srv LoginServiceHookedBridger) func( if err != nil { return err } - return srv.RegisterResult(ctx, &in, out.(*RegisterResponse)) + return srv.CompleteRegister(ctx, &in, out.(*RegisterResponse)) } } @@ -292,7 +292,7 @@ func _LoginService_TokenRefresh0_Bridge_Handler(srv LoginServiceHookedBridger) f return srv.TokenRefresh(ctx, req.(*TokenRefreshRequest)) }) - newctx, err := srv.BeforeTokenRefresh(ctx, &in) + newctx, err := srv.PrepareTokenRefresh(ctx, &in) if err != nil { return err } @@ -300,7 +300,7 @@ func _LoginService_TokenRefresh0_Bridge_Handler(srv LoginServiceHookedBridger) f if err != nil { return err } - return srv.TokenRefreshResult(ctx, &in, out.(*TokenRefreshResponse)) + return srv.CompleteTokenRefresh(ctx, &in, out.(*TokenRefreshResponse)) } } @@ -311,67 +311,67 @@ func _LoginService_TokenRefresh0_Bridge_Handler(srv LoginServiceHookedBridger) f // pointer dereference when methods are called. type UnimplementedLoginServiceHooked struct{} -func (UnimplementedLoginServiceHooked) BeforeCaptcha(ctx http.Context, in *CaptchaRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) PrepareCaptcha(ctx http.Context, in *CaptchaRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceHooked) CaptchaResult(ctx http.Context, in *CaptchaRequest, out *CaptchaResponse) error { +func (UnimplementedLoginServiceHooked) CompleteCaptcha(ctx http.Context, in *CaptchaRequest, out *CaptchaResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceHooked) BeforeCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) PrepareCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceHooked) CaptchaAudioResult(ctx http.Context, in *CaptchaAudioRequest, out *CaptchaAudioResponse) error { +func (UnimplementedLoginServiceHooked) CompleteCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest, out *CaptchaAudioResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceHooked) BeforeCaptchaId(ctx http.Context, in *CaptchaIdRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) PrepareCaptchaId(ctx http.Context, in *CaptchaIdRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceHooked) CaptchaIdResult(ctx http.Context, in *CaptchaIdRequest, out *CaptchaIdResponse) error { +func (UnimplementedLoginServiceHooked) CompleteCaptchaId(ctx http.Context, in *CaptchaIdRequest, out *CaptchaIdResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceHooked) BeforeCaptchaImage(ctx http.Context, in *CaptchaImageRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) PrepareCaptchaImage(ctx http.Context, in *CaptchaImageRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceHooked) CaptchaImageResult(ctx http.Context, in *CaptchaImageRequest, out *CaptchaImageResponse) error { +func (UnimplementedLoginServiceHooked) CompleteCaptchaImage(ctx http.Context, in *CaptchaImageRequest, out *CaptchaImageResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceHooked) BeforeLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) PrepareLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceHooked) LoginResult(ctx http.Context, in *LoginRequest, out *LoginResponse) error { +func (UnimplementedLoginServiceHooked) CompleteLogin(ctx http.Context, in *LoginRequest, out *LoginResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceHooked) BeforeLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) PrepareLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceHooked) LogoutResult(ctx http.Context, in *LogoutRequest, out *LogoutResponse) error { +func (UnimplementedLoginServiceHooked) CompleteLogout(ctx http.Context, in *LogoutRequest, out *LogoutResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceHooked) BeforeRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) PrepareRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceHooked) RegisterResult(ctx http.Context, in *RegisterRequest, out *RegisterResponse) error { +func (UnimplementedLoginServiceHooked) CompleteRegister(ctx http.Context, in *RegisterRequest, out *RegisterResponse) error { return ctx.Result(200, out) } -func (UnimplementedLoginServiceHooked) BeforeTokenRefresh(ctx http.Context, in *TokenRefreshRequest) (context.Context, error) { +func (UnimplementedLoginServiceHooked) PrepareTokenRefresh(ctx http.Context, in *TokenRefreshRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedLoginServiceHooked) TokenRefreshResult(ctx http.Context, in *TokenRefreshRequest, out *TokenRefreshResponse) error { +func (UnimplementedLoginServiceHooked) CompleteTokenRefresh(ctx http.Context, in *TokenRefreshRequest, out *TokenRefreshResponse) error { return ctx.Result(200, out) } diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go index fb6d01d5..45ba65ad 100644 --- a/api/v1/services/system/department_bridge.pb.go +++ b/api/v1/services/system/department_bridge.pb.go @@ -55,24 +55,24 @@ type DepartmentServiceHookedBridger interface { DepartmentServiceBridger } type DepartmentServiceCreateDepartmentHooker interface { - BeforeCreateDepartment(http.Context, *CreateDepartmentRequest) (context.Context, error) - CreateDepartmentResult(http.Context, *CreateDepartmentRequest, *CreateDepartmentResponse) error + PrepareCreateDepartment(http.Context, *CreateDepartmentRequest) (context.Context, error) + CompleteCreateDepartment(http.Context, *CreateDepartmentRequest, *CreateDepartmentResponse) error } type DepartmentServiceDeleteDepartmentHooker interface { - BeforeDeleteDepartment(http.Context, *DeleteDepartmentRequest) (context.Context, error) - DeleteDepartmentResult(http.Context, *DeleteDepartmentRequest, *DeleteDepartmentResponse) error + PrepareDeleteDepartment(http.Context, *DeleteDepartmentRequest) (context.Context, error) + CompleteDeleteDepartment(http.Context, *DeleteDepartmentRequest, *DeleteDepartmentResponse) error } type DepartmentServiceGetDepartmentHooker interface { - BeforeGetDepartment(http.Context, *GetDepartmentRequest) (context.Context, error) - GetDepartmentResult(http.Context, *GetDepartmentRequest, *GetDepartmentResponse) error + PrepareGetDepartment(http.Context, *GetDepartmentRequest) (context.Context, error) + CompleteGetDepartment(http.Context, *GetDepartmentRequest, *GetDepartmentResponse) error } type DepartmentServiceListDepartmentsHooker interface { - BeforeListDepartments(http.Context, *ListDepartmentsRequest) (context.Context, error) - ListDepartmentsResult(http.Context, *ListDepartmentsRequest, *ListDepartmentsResponse) error + PrepareListDepartments(http.Context, *ListDepartmentsRequest) (context.Context, error) + CompleteListDepartments(http.Context, *ListDepartmentsRequest, *ListDepartmentsResponse) error } type DepartmentServiceUpdateDepartmentHooker interface { - BeforeUpdateDepartment(http.Context, *UpdateDepartmentRequest) (context.Context, error) - UpdateDepartmentResult(http.Context, *UpdateDepartmentRequest, *UpdateDepartmentResponse) error + PrepareUpdateDepartment(http.Context, *UpdateDepartmentRequest) (context.Context, error) + CompleteUpdateDepartment(http.Context, *UpdateDepartmentRequest, *UpdateDepartmentResponse) error } func RegisterDepartmentServiceBridger(s *http.Server, srv DepartmentServiceHookedBridger) { @@ -95,7 +95,7 @@ func _DepartmentService_ListDepartments0_Bridge_Handler(srv DepartmentServiceHoo return srv.ListDepartments(ctx, req.(*ListDepartmentsRequest)) }) - newctx, err := srv.BeforeListDepartments(ctx, &in) + newctx, err := srv.PrepareListDepartments(ctx, &in) if err != nil { return err } @@ -103,7 +103,7 @@ func _DepartmentService_ListDepartments0_Bridge_Handler(srv DepartmentServiceHoo if err != nil { return err } - return srv.ListDepartmentsResult(ctx, &in, out.(*ListDepartmentsResponse)) + return srv.CompleteListDepartments(ctx, &in, out.(*ListDepartmentsResponse)) } } @@ -121,7 +121,7 @@ func _DepartmentService_GetDepartment0_Bridge_Handler(srv DepartmentServiceHooke return srv.GetDepartment(ctx, req.(*GetDepartmentRequest)) }) - newctx, err := srv.BeforeGetDepartment(ctx, &in) + newctx, err := srv.PrepareGetDepartment(ctx, &in) if err != nil { return err } @@ -129,7 +129,7 @@ func _DepartmentService_GetDepartment0_Bridge_Handler(srv DepartmentServiceHooke if err != nil { return err } - return srv.GetDepartmentResult(ctx, &in, out.(*GetDepartmentResponse)) + return srv.CompleteGetDepartment(ctx, &in, out.(*GetDepartmentResponse)) } } @@ -147,7 +147,7 @@ func _DepartmentService_CreateDepartment0_Bridge_Handler(srv DepartmentServiceHo return srv.CreateDepartment(ctx, req.(*CreateDepartmentRequest)) }) - newctx, err := srv.BeforeCreateDepartment(ctx, &in) + newctx, err := srv.PrepareCreateDepartment(ctx, &in) if err != nil { return err } @@ -155,7 +155,7 @@ func _DepartmentService_CreateDepartment0_Bridge_Handler(srv DepartmentServiceHo if err != nil { return err } - return srv.CreateDepartmentResult(ctx, &in, out.(*CreateDepartmentResponse)) + return srv.CompleteCreateDepartment(ctx, &in, out.(*CreateDepartmentResponse)) } } @@ -176,7 +176,7 @@ func _DepartmentService_UpdateDepartment0_Bridge_Handler(srv DepartmentServiceHo return srv.UpdateDepartment(ctx, req.(*UpdateDepartmentRequest)) }) - newctx, err := srv.BeforeUpdateDepartment(ctx, &in) + newctx, err := srv.PrepareUpdateDepartment(ctx, &in) if err != nil { return err } @@ -184,7 +184,7 @@ func _DepartmentService_UpdateDepartment0_Bridge_Handler(srv DepartmentServiceHo if err != nil { return err } - return srv.UpdateDepartmentResult(ctx, &in, out.(*UpdateDepartmentResponse)) + return srv.CompleteUpdateDepartment(ctx, &in, out.(*UpdateDepartmentResponse)) } } @@ -202,7 +202,7 @@ func _DepartmentService_DeleteDepartment0_Bridge_Handler(srv DepartmentServiceHo return srv.DeleteDepartment(ctx, req.(*DeleteDepartmentRequest)) }) - newctx, err := srv.BeforeDeleteDepartment(ctx, &in) + newctx, err := srv.PrepareDeleteDepartment(ctx, &in) if err != nil { return err } @@ -210,7 +210,7 @@ func _DepartmentService_DeleteDepartment0_Bridge_Handler(srv DepartmentServiceHo if err != nil { return err } - return srv.DeleteDepartmentResult(ctx, &in, out.(*DeleteDepartmentResponse)) + return srv.CompleteDeleteDepartment(ctx, &in, out.(*DeleteDepartmentResponse)) } } @@ -221,43 +221,43 @@ func _DepartmentService_DeleteDepartment0_Bridge_Handler(srv DepartmentServiceHo // pointer dereference when methods are called. type UnimplementedDepartmentServiceHooked struct{} -func (UnimplementedDepartmentServiceHooked) BeforeCreateDepartment(ctx http.Context, in *CreateDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) PrepareCreateDepartment(ctx http.Context, in *CreateDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceHooked) CreateDepartmentResult(ctx http.Context, in *CreateDepartmentRequest, out *CreateDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) CompleteCreateDepartment(ctx http.Context, in *CreateDepartmentRequest, out *CreateDepartmentResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceHooked) BeforeDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) PrepareDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceHooked) DeleteDepartmentResult(ctx http.Context, in *DeleteDepartmentRequest, out *DeleteDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) CompleteDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest, out *DeleteDepartmentResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceHooked) BeforeGetDepartment(ctx http.Context, in *GetDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) PrepareGetDepartment(ctx http.Context, in *GetDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceHooked) GetDepartmentResult(ctx http.Context, in *GetDepartmentRequest, out *GetDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) CompleteGetDepartment(ctx http.Context, in *GetDepartmentRequest, out *GetDepartmentResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceHooked) BeforeListDepartments(ctx http.Context, in *ListDepartmentsRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) PrepareListDepartments(ctx http.Context, in *ListDepartmentsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceHooked) ListDepartmentsResult(ctx http.Context, in *ListDepartmentsRequest, out *ListDepartmentsResponse) error { +func (UnimplementedDepartmentServiceHooked) CompleteListDepartments(ctx http.Context, in *ListDepartmentsRequest, out *ListDepartmentsResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceHooked) BeforeUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) PrepareUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceHooked) UpdateDepartmentResult(ctx http.Context, in *UpdateDepartmentRequest, out *UpdateDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) CompleteUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest, out *UpdateDepartmentResponse) error { return ctx.Result(200, out) } diff --git a/api/v1/services/system/menu_bridge.pb.go b/api/v1/services/system/menu_bridge.pb.go index 6062c3cd..33811543 100644 --- a/api/v1/services/system/menu_bridge.pb.go +++ b/api/v1/services/system/menu_bridge.pb.go @@ -55,24 +55,24 @@ type MenuServiceHookedBridger interface { MenuServiceBridger } type MenuServiceCreateMenuHooker interface { - BeforeCreateMenu(http.Context, *CreateMenuRequest) (context.Context, error) - CreateMenuResult(http.Context, *CreateMenuRequest, *CreateMenuResponse) error + PrepareCreateMenu(http.Context, *CreateMenuRequest) (context.Context, error) + CompleteCreateMenu(http.Context, *CreateMenuRequest, *CreateMenuResponse) error } type MenuServiceDeleteMenuHooker interface { - BeforeDeleteMenu(http.Context, *DeleteMenuRequest) (context.Context, error) - DeleteMenuResult(http.Context, *DeleteMenuRequest, *DeleteMenuResponse) error + PrepareDeleteMenu(http.Context, *DeleteMenuRequest) (context.Context, error) + CompleteDeleteMenu(http.Context, *DeleteMenuRequest, *DeleteMenuResponse) error } type MenuServiceGetMenuHooker interface { - BeforeGetMenu(http.Context, *GetMenuRequest) (context.Context, error) - GetMenuResult(http.Context, *GetMenuRequest, *GetMenuResponse) error + PrepareGetMenu(http.Context, *GetMenuRequest) (context.Context, error) + CompleteGetMenu(http.Context, *GetMenuRequest, *GetMenuResponse) error } type MenuServiceListMenusHooker interface { - BeforeListMenus(http.Context, *ListMenusRequest) (context.Context, error) - ListMenusResult(http.Context, *ListMenusRequest, *ListMenusResponse) error + PrepareListMenus(http.Context, *ListMenusRequest) (context.Context, error) + CompleteListMenus(http.Context, *ListMenusRequest, *ListMenusResponse) error } type MenuServiceUpdateMenuHooker interface { - BeforeUpdateMenu(http.Context, *UpdateMenuRequest) (context.Context, error) - UpdateMenuResult(http.Context, *UpdateMenuRequest, *UpdateMenuResponse) error + PrepareUpdateMenu(http.Context, *UpdateMenuRequest) (context.Context, error) + CompleteUpdateMenu(http.Context, *UpdateMenuRequest, *UpdateMenuResponse) error } func RegisterMenuServiceBridger(s *http.Server, srv MenuServiceHookedBridger) { @@ -95,7 +95,7 @@ func _MenuService_ListMenus0_Bridge_Handler(srv MenuServiceHookedBridger) func(c return srv.ListMenus(ctx, req.(*ListMenusRequest)) }) - newctx, err := srv.BeforeListMenus(ctx, &in) + newctx, err := srv.PrepareListMenus(ctx, &in) if err != nil { return err } @@ -103,7 +103,7 @@ func _MenuService_ListMenus0_Bridge_Handler(srv MenuServiceHookedBridger) func(c if err != nil { return err } - return srv.ListMenusResult(ctx, &in, out.(*ListMenusResponse)) + return srv.CompleteListMenus(ctx, &in, out.(*ListMenusResponse)) } } @@ -121,7 +121,7 @@ func _MenuService_GetMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx return srv.GetMenu(ctx, req.(*GetMenuRequest)) }) - newctx, err := srv.BeforeGetMenu(ctx, &in) + newctx, err := srv.PrepareGetMenu(ctx, &in) if err != nil { return err } @@ -129,7 +129,7 @@ func _MenuService_GetMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx if err != nil { return err } - return srv.GetMenuResult(ctx, &in, out.(*GetMenuResponse)) + return srv.CompleteGetMenu(ctx, &in, out.(*GetMenuResponse)) } } @@ -147,7 +147,7 @@ func _MenuService_CreateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func( return srv.CreateMenu(ctx, req.(*CreateMenuRequest)) }) - newctx, err := srv.BeforeCreateMenu(ctx, &in) + newctx, err := srv.PrepareCreateMenu(ctx, &in) if err != nil { return err } @@ -155,7 +155,7 @@ func _MenuService_CreateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func( if err != nil { return err } - return srv.CreateMenuResult(ctx, &in, out.(*CreateMenuResponse)) + return srv.CompleteCreateMenu(ctx, &in, out.(*CreateMenuResponse)) } } @@ -176,7 +176,7 @@ func _MenuService_UpdateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func( return srv.UpdateMenu(ctx, req.(*UpdateMenuRequest)) }) - newctx, err := srv.BeforeUpdateMenu(ctx, &in) + newctx, err := srv.PrepareUpdateMenu(ctx, &in) if err != nil { return err } @@ -184,7 +184,7 @@ func _MenuService_UpdateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func( if err != nil { return err } - return srv.UpdateMenuResult(ctx, &in, out.(*UpdateMenuResponse)) + return srv.CompleteUpdateMenu(ctx, &in, out.(*UpdateMenuResponse)) } } @@ -202,7 +202,7 @@ func _MenuService_DeleteMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func( return srv.DeleteMenu(ctx, req.(*DeleteMenuRequest)) }) - newctx, err := srv.BeforeDeleteMenu(ctx, &in) + newctx, err := srv.PrepareDeleteMenu(ctx, &in) if err != nil { return err } @@ -210,7 +210,7 @@ func _MenuService_DeleteMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func( if err != nil { return err } - return srv.DeleteMenuResult(ctx, &in, out.(*DeleteMenuResponse)) + return srv.CompleteDeleteMenu(ctx, &in, out.(*DeleteMenuResponse)) } } @@ -221,43 +221,43 @@ func _MenuService_DeleteMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func( // pointer dereference when methods are called. type UnimplementedMenuServiceHooked struct{} -func (UnimplementedMenuServiceHooked) BeforeCreateMenu(ctx http.Context, in *CreateMenuRequest) (context.Context, error) { +func (UnimplementedMenuServiceHooked) PrepareCreateMenu(ctx http.Context, in *CreateMenuRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMenuServiceHooked) CreateMenuResult(ctx http.Context, in *CreateMenuRequest, out *CreateMenuResponse) error { +func (UnimplementedMenuServiceHooked) CompleteCreateMenu(ctx http.Context, in *CreateMenuRequest, out *CreateMenuResponse) error { return ctx.Result(200, out) } -func (UnimplementedMenuServiceHooked) BeforeDeleteMenu(ctx http.Context, in *DeleteMenuRequest) (context.Context, error) { +func (UnimplementedMenuServiceHooked) PrepareDeleteMenu(ctx http.Context, in *DeleteMenuRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMenuServiceHooked) DeleteMenuResult(ctx http.Context, in *DeleteMenuRequest, out *DeleteMenuResponse) error { +func (UnimplementedMenuServiceHooked) CompleteDeleteMenu(ctx http.Context, in *DeleteMenuRequest, out *DeleteMenuResponse) error { return ctx.Result(200, out) } -func (UnimplementedMenuServiceHooked) BeforeGetMenu(ctx http.Context, in *GetMenuRequest) (context.Context, error) { +func (UnimplementedMenuServiceHooked) PrepareGetMenu(ctx http.Context, in *GetMenuRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMenuServiceHooked) GetMenuResult(ctx http.Context, in *GetMenuRequest, out *GetMenuResponse) error { +func (UnimplementedMenuServiceHooked) CompleteGetMenu(ctx http.Context, in *GetMenuRequest, out *GetMenuResponse) error { return ctx.Result(200, out) } -func (UnimplementedMenuServiceHooked) BeforeListMenus(ctx http.Context, in *ListMenusRequest) (context.Context, error) { +func (UnimplementedMenuServiceHooked) PrepareListMenus(ctx http.Context, in *ListMenusRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMenuServiceHooked) ListMenusResult(ctx http.Context, in *ListMenusRequest, out *ListMenusResponse) error { +func (UnimplementedMenuServiceHooked) CompleteListMenus(ctx http.Context, in *ListMenusRequest, out *ListMenusResponse) error { return ctx.Result(200, out) } -func (UnimplementedMenuServiceHooked) BeforeUpdateMenu(ctx http.Context, in *UpdateMenuRequest) (context.Context, error) { +func (UnimplementedMenuServiceHooked) PrepareUpdateMenu(ctx http.Context, in *UpdateMenuRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMenuServiceHooked) UpdateMenuResult(ctx http.Context, in *UpdateMenuRequest, out *UpdateMenuResponse) error { +func (UnimplementedMenuServiceHooked) CompleteUpdateMenu(ctx http.Context, in *UpdateMenuRequest, out *UpdateMenuResponse) error { return ctx.Result(200, out) } diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go index da923ceb..b8e5eb71 100644 --- a/api/v1/services/system/permission_bridge.pb.go +++ b/api/v1/services/system/permission_bridge.pb.go @@ -55,24 +55,24 @@ type PermissionServiceHookedBridger interface { PermissionServiceBridger } type PermissionServiceCreatePermissionHooker interface { - BeforeCreatePermission(http.Context, *CreatePermissionRequest) (context.Context, error) - CreatePermissionResult(http.Context, *CreatePermissionRequest, *CreatePermissionResponse) error + PrepareCreatePermission(http.Context, *CreatePermissionRequest) (context.Context, error) + CompleteCreatePermission(http.Context, *CreatePermissionRequest, *CreatePermissionResponse) error } type PermissionServiceDeletePermissionHooker interface { - BeforeDeletePermission(http.Context, *DeletePermissionRequest) (context.Context, error) - DeletePermissionResult(http.Context, *DeletePermissionRequest, *DeletePermissionResponse) error + PrepareDeletePermission(http.Context, *DeletePermissionRequest) (context.Context, error) + CompleteDeletePermission(http.Context, *DeletePermissionRequest, *DeletePermissionResponse) error } type PermissionServiceGetPermissionHooker interface { - BeforeGetPermission(http.Context, *GetPermissionRequest) (context.Context, error) - GetPermissionResult(http.Context, *GetPermissionRequest, *GetPermissionResponse) error + PrepareGetPermission(http.Context, *GetPermissionRequest) (context.Context, error) + CompleteGetPermission(http.Context, *GetPermissionRequest, *GetPermissionResponse) error } type PermissionServiceListPermissionsHooker interface { - BeforeListPermissions(http.Context, *ListPermissionsRequest) (context.Context, error) - ListPermissionsResult(http.Context, *ListPermissionsRequest, *ListPermissionsResponse) error + PrepareListPermissions(http.Context, *ListPermissionsRequest) (context.Context, error) + CompleteListPermissions(http.Context, *ListPermissionsRequest, *ListPermissionsResponse) error } type PermissionServiceUpdatePermissionHooker interface { - BeforeUpdatePermission(http.Context, *UpdatePermissionRequest) (context.Context, error) - UpdatePermissionResult(http.Context, *UpdatePermissionRequest, *UpdatePermissionResponse) error + PrepareUpdatePermission(http.Context, *UpdatePermissionRequest) (context.Context, error) + CompleteUpdatePermission(http.Context, *UpdatePermissionRequest, *UpdatePermissionResponse) error } func RegisterPermissionServiceBridger(s *http.Server, srv PermissionServiceHookedBridger) { @@ -95,7 +95,7 @@ func _PermissionService_ListPermissions0_Bridge_Handler(srv PermissionServiceHoo return srv.ListPermissions(ctx, req.(*ListPermissionsRequest)) }) - newctx, err := srv.BeforeListPermissions(ctx, &in) + newctx, err := srv.PrepareListPermissions(ctx, &in) if err != nil { return err } @@ -103,7 +103,7 @@ func _PermissionService_ListPermissions0_Bridge_Handler(srv PermissionServiceHoo if err != nil { return err } - return srv.ListPermissionsResult(ctx, &in, out.(*ListPermissionsResponse)) + return srv.CompleteListPermissions(ctx, &in, out.(*ListPermissionsResponse)) } } @@ -121,7 +121,7 @@ func _PermissionService_GetPermission0_Bridge_Handler(srv PermissionServiceHooke return srv.GetPermission(ctx, req.(*GetPermissionRequest)) }) - newctx, err := srv.BeforeGetPermission(ctx, &in) + newctx, err := srv.PrepareGetPermission(ctx, &in) if err != nil { return err } @@ -129,7 +129,7 @@ func _PermissionService_GetPermission0_Bridge_Handler(srv PermissionServiceHooke if err != nil { return err } - return srv.GetPermissionResult(ctx, &in, out.(*GetPermissionResponse)) + return srv.CompleteGetPermission(ctx, &in, out.(*GetPermissionResponse)) } } @@ -147,7 +147,7 @@ func _PermissionService_CreatePermission0_Bridge_Handler(srv PermissionServiceHo return srv.CreatePermission(ctx, req.(*CreatePermissionRequest)) }) - newctx, err := srv.BeforeCreatePermission(ctx, &in) + newctx, err := srv.PrepareCreatePermission(ctx, &in) if err != nil { return err } @@ -155,7 +155,7 @@ func _PermissionService_CreatePermission0_Bridge_Handler(srv PermissionServiceHo if err != nil { return err } - return srv.CreatePermissionResult(ctx, &in, out.(*CreatePermissionResponse)) + return srv.CompleteCreatePermission(ctx, &in, out.(*CreatePermissionResponse)) } } @@ -176,7 +176,7 @@ func _PermissionService_UpdatePermission0_Bridge_Handler(srv PermissionServiceHo return srv.UpdatePermission(ctx, req.(*UpdatePermissionRequest)) }) - newctx, err := srv.BeforeUpdatePermission(ctx, &in) + newctx, err := srv.PrepareUpdatePermission(ctx, &in) if err != nil { return err } @@ -184,7 +184,7 @@ func _PermissionService_UpdatePermission0_Bridge_Handler(srv PermissionServiceHo if err != nil { return err } - return srv.UpdatePermissionResult(ctx, &in, out.(*UpdatePermissionResponse)) + return srv.CompleteUpdatePermission(ctx, &in, out.(*UpdatePermissionResponse)) } } @@ -202,7 +202,7 @@ func _PermissionService_DeletePermission0_Bridge_Handler(srv PermissionServiceHo return srv.DeletePermission(ctx, req.(*DeletePermissionRequest)) }) - newctx, err := srv.BeforeDeletePermission(ctx, &in) + newctx, err := srv.PrepareDeletePermission(ctx, &in) if err != nil { return err } @@ -210,7 +210,7 @@ func _PermissionService_DeletePermission0_Bridge_Handler(srv PermissionServiceHo if err != nil { return err } - return srv.DeletePermissionResult(ctx, &in, out.(*DeletePermissionResponse)) + return srv.CompleteDeletePermission(ctx, &in, out.(*DeletePermissionResponse)) } } @@ -221,43 +221,43 @@ func _PermissionService_DeletePermission0_Bridge_Handler(srv PermissionServiceHo // pointer dereference when methods are called. type UnimplementedPermissionServiceHooked struct{} -func (UnimplementedPermissionServiceHooked) BeforeCreatePermission(ctx http.Context, in *CreatePermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) PrepareCreatePermission(ctx http.Context, in *CreatePermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceHooked) CreatePermissionResult(ctx http.Context, in *CreatePermissionRequest, out *CreatePermissionResponse) error { +func (UnimplementedPermissionServiceHooked) CompleteCreatePermission(ctx http.Context, in *CreatePermissionRequest, out *CreatePermissionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceHooked) BeforeDeletePermission(ctx http.Context, in *DeletePermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) PrepareDeletePermission(ctx http.Context, in *DeletePermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceHooked) DeletePermissionResult(ctx http.Context, in *DeletePermissionRequest, out *DeletePermissionResponse) error { +func (UnimplementedPermissionServiceHooked) CompleteDeletePermission(ctx http.Context, in *DeletePermissionRequest, out *DeletePermissionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceHooked) BeforeGetPermission(ctx http.Context, in *GetPermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) PrepareGetPermission(ctx http.Context, in *GetPermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceHooked) GetPermissionResult(ctx http.Context, in *GetPermissionRequest, out *GetPermissionResponse) error { +func (UnimplementedPermissionServiceHooked) CompleteGetPermission(ctx http.Context, in *GetPermissionRequest, out *GetPermissionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceHooked) BeforeListPermissions(ctx http.Context, in *ListPermissionsRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) PrepareListPermissions(ctx http.Context, in *ListPermissionsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceHooked) ListPermissionsResult(ctx http.Context, in *ListPermissionsRequest, out *ListPermissionsResponse) error { +func (UnimplementedPermissionServiceHooked) CompleteListPermissions(ctx http.Context, in *ListPermissionsRequest, out *ListPermissionsResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceHooked) BeforeUpdatePermission(ctx http.Context, in *UpdatePermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) PrepareUpdatePermission(ctx http.Context, in *UpdatePermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceHooked) UpdatePermissionResult(ctx http.Context, in *UpdatePermissionRequest, out *UpdatePermissionResponse) error { +func (UnimplementedPermissionServiceHooked) CompleteUpdatePermission(ctx http.Context, in *UpdatePermissionRequest, out *UpdatePermissionResponse) error { return ctx.Result(200, out) } diff --git a/api/v1/services/system/personal_bridge.pb.go b/api/v1/services/system/personal_bridge.pb.go index 217edaf0..5d7c8773 100644 --- a/api/v1/services/system/personal_bridge.pb.go +++ b/api/v1/services/system/personal_bridge.pb.go @@ -72,36 +72,36 @@ type PersonalServiceHookedBridger interface { PersonalServiceBridger } type PersonalServiceGetPersonalProfileHooker interface { - BeforeGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) - GetPersonalProfileResult(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error + PrepareGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) + CompleteGetPersonalProfile(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error } type PersonalServiceListPersonalResourcesHooker interface { - BeforeListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) - ListPersonalResourcesResult(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error + PrepareListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) + CompleteListPersonalResources(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error } type PersonalServiceListPersonalRolesHooker interface { - BeforeListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) - ListPersonalRolesResult(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error + PrepareListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) + CompleteListPersonalRoles(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error } type PersonalServicePersonalLogoutHooker interface { - BeforePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) - PersonalLogoutResult(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error + PreparePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) + CompletePersonalLogout(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error } type PersonalServiceRefreshPersonalTokenHooker interface { - BeforeRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) - RefreshPersonalTokenResult(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error + PrepareRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) + CompleteRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error } type PersonalServiceUpdatePersonalPasswordHooker interface { - BeforeUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) - UpdatePersonalPasswordResult(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error + PrepareUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) + CompleteUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error } type PersonalServiceUpdatePersonalProfileHooker interface { - BeforeUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) - UpdatePersonalProfileResult(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error + PrepareUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) + CompleteUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error } type PersonalServiceUpdatePersonalSettingHooker interface { - BeforeUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) - UpdatePersonalSettingResult(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error + PrepareUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) + CompleteUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error } func RegisterPersonalServiceBridger(s *http.Server, srv PersonalServiceHookedBridger) { @@ -127,7 +127,7 @@ func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHook return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) }) - newctx, err := srv.BeforeGetPersonalProfile(ctx, &in) + newctx, err := srv.PrepareGetPersonalProfile(ctx, &in) if err != nil { return err } @@ -135,7 +135,7 @@ func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHook if err != nil { return err } - return srv.GetPersonalProfileResult(ctx, &in, out.(*GetPersonalProfileResponse)) + return srv.CompleteGetPersonalProfile(ctx, &in, out.(*GetPersonalProfileResponse)) } } @@ -150,7 +150,7 @@ func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceH return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) }) - newctx, err := srv.BeforeListPersonalResources(ctx, &in) + newctx, err := srv.PrepareListPersonalResources(ctx, &in) if err != nil { return err } @@ -158,7 +158,7 @@ func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceH if err != nil { return err } - return srv.ListPersonalResourcesResult(ctx, &in, out.(*ListPersonalResourcesResponse)) + return srv.CompleteListPersonalResources(ctx, &in, out.(*ListPersonalResourcesResponse)) } } @@ -173,7 +173,7 @@ func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHooke return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) }) - newctx, err := srv.BeforeListPersonalRoles(ctx, &in) + newctx, err := srv.PrepareListPersonalRoles(ctx, &in) if err != nil { return err } @@ -181,7 +181,7 @@ func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHooke if err != nil { return err } - return srv.ListPersonalRolesResult(ctx, &in, out.(*ListPersonalRolesResponse)) + return srv.CompleteListPersonalRoles(ctx, &in, out.(*ListPersonalRolesResponse)) } } @@ -199,7 +199,7 @@ func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBr return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) }) - newctx, err := srv.BeforePersonalLogout(ctx, &in) + newctx, err := srv.PreparePersonalLogout(ctx, &in) if err != nil { return err } @@ -207,7 +207,7 @@ func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBr if err != nil { return err } - return srv.PersonalLogoutResult(ctx, &in, out.(*PersonalLogoutResponse)) + return srv.CompletePersonalLogout(ctx, &in, out.(*PersonalLogoutResponse)) } } @@ -225,7 +225,7 @@ func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHo return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) }) - newctx, err := srv.BeforeRefreshPersonalToken(ctx, &in) + newctx, err := srv.PrepareRefreshPersonalToken(ctx, &in) if err != nil { return err } @@ -233,7 +233,7 @@ func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHo if err != nil { return err } - return srv.RefreshPersonalTokenResult(ctx, &in, out.(*RefreshPersonalTokenResponse)) + return srv.CompleteRefreshPersonalToken(ctx, &in, out.(*RefreshPersonalTokenResponse)) } } @@ -251,7 +251,7 @@ func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalService return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) }) - newctx, err := srv.BeforeUpdatePersonalPassword(ctx, &in) + newctx, err := srv.PrepareUpdatePersonalPassword(ctx, &in) if err != nil { return err } @@ -259,7 +259,7 @@ func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalService if err != nil { return err } - return srv.UpdatePersonalPasswordResult(ctx, &in, out.(*UpdatePersonalPasswordResponse)) + return srv.CompleteUpdatePersonalPassword(ctx, &in, out.(*UpdatePersonalPasswordResponse)) } } @@ -277,7 +277,7 @@ func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceH return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) }) - newctx, err := srv.BeforeUpdatePersonalProfile(ctx, &in) + newctx, err := srv.PrepareUpdatePersonalProfile(ctx, &in) if err != nil { return err } @@ -285,7 +285,7 @@ func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceH if err != nil { return err } - return srv.UpdatePersonalProfileResult(ctx, &in, out.(*UpdatePersonalProfileResponse)) + return srv.CompleteUpdatePersonalProfile(ctx, &in, out.(*UpdatePersonalProfileResponse)) } } @@ -303,7 +303,7 @@ func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceH return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) }) - newctx, err := srv.BeforeUpdatePersonalSetting(ctx, &in) + newctx, err := srv.PrepareUpdatePersonalSetting(ctx, &in) if err != nil { return err } @@ -311,7 +311,7 @@ func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceH if err != nil { return err } - return srv.UpdatePersonalSettingResult(ctx, &in, out.(*UpdatePersonalSettingResponse)) + return srv.CompleteUpdatePersonalSetting(ctx, &in, out.(*UpdatePersonalSettingResponse)) } } @@ -322,67 +322,67 @@ func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceH // pointer dereference when methods are called. type UnimplementedPersonalServiceHooked struct{} -func (UnimplementedPersonalServiceHooked) BeforeGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) PrepareGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceHooked) GetPersonalProfileResult(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { +func (UnimplementedPersonalServiceHooked) CompleteGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceHooked) BeforeListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) PrepareListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceHooked) ListPersonalResourcesResult(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { +func (UnimplementedPersonalServiceHooked) CompleteListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceHooked) BeforeListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) PrepareListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceHooked) ListPersonalRolesResult(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { +func (UnimplementedPersonalServiceHooked) CompleteListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceHooked) BeforePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) PreparePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceHooked) PersonalLogoutResult(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { +func (UnimplementedPersonalServiceHooked) CompletePersonalLogout(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceHooked) BeforeRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) PrepareRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceHooked) RefreshPersonalTokenResult(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { +func (UnimplementedPersonalServiceHooked) CompleteRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceHooked) BeforeUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceHooked) UpdatePersonalPasswordResult(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceHooked) BeforeUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceHooked) UpdatePersonalProfileResult(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { return ctx.Result(200, out) } -func (UnimplementedPersonalServiceHooked) BeforeUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPersonalServiceHooked) UpdatePersonalSettingResult(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { return ctx.Result(200, out) } diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go index 7466940a..af3ce519 100644 --- a/api/v1/services/system/position_bridge.pb.go +++ b/api/v1/services/system/position_bridge.pb.go @@ -55,24 +55,24 @@ type PositionServiceHookedBridger interface { PositionServiceBridger } type PositionServiceCreatePositionHooker interface { - BeforeCreatePosition(http.Context, *CreatePositionRequest) (context.Context, error) - CreatePositionResult(http.Context, *CreatePositionRequest, *CreatePositionResponse) error + PrepareCreatePosition(http.Context, *CreatePositionRequest) (context.Context, error) + CompleteCreatePosition(http.Context, *CreatePositionRequest, *CreatePositionResponse) error } type PositionServiceDeletePositionHooker interface { - BeforeDeletePosition(http.Context, *DeletePositionRequest) (context.Context, error) - DeletePositionResult(http.Context, *DeletePositionRequest, *DeletePositionResponse) error + PrepareDeletePosition(http.Context, *DeletePositionRequest) (context.Context, error) + CompleteDeletePosition(http.Context, *DeletePositionRequest, *DeletePositionResponse) error } type PositionServiceGetPositionHooker interface { - BeforeGetPosition(http.Context, *GetPositionRequest) (context.Context, error) - GetPositionResult(http.Context, *GetPositionRequest, *GetPositionResponse) error + PrepareGetPosition(http.Context, *GetPositionRequest) (context.Context, error) + CompleteGetPosition(http.Context, *GetPositionRequest, *GetPositionResponse) error } type PositionServiceListPositionsHooker interface { - BeforeListPositions(http.Context, *ListPositionsRequest) (context.Context, error) - ListPositionsResult(http.Context, *ListPositionsRequest, *ListPositionsResponse) error + PrepareListPositions(http.Context, *ListPositionsRequest) (context.Context, error) + CompleteListPositions(http.Context, *ListPositionsRequest, *ListPositionsResponse) error } type PositionServiceUpdatePositionHooker interface { - BeforeUpdatePosition(http.Context, *UpdatePositionRequest) (context.Context, error) - UpdatePositionResult(http.Context, *UpdatePositionRequest, *UpdatePositionResponse) error + PrepareUpdatePosition(http.Context, *UpdatePositionRequest) (context.Context, error) + CompleteUpdatePosition(http.Context, *UpdatePositionRequest, *UpdatePositionResponse) error } func RegisterPositionServiceBridger(s *http.Server, srv PositionServiceHookedBridger) { @@ -95,7 +95,7 @@ func _PositionService_ListPositions0_Bridge_Handler(srv PositionServiceHookedBri return srv.ListPositions(ctx, req.(*ListPositionsRequest)) }) - newctx, err := srv.BeforeListPositions(ctx, &in) + newctx, err := srv.PrepareListPositions(ctx, &in) if err != nil { return err } @@ -103,7 +103,7 @@ func _PositionService_ListPositions0_Bridge_Handler(srv PositionServiceHookedBri if err != nil { return err } - return srv.ListPositionsResult(ctx, &in, out.(*ListPositionsResponse)) + return srv.CompleteListPositions(ctx, &in, out.(*ListPositionsResponse)) } } @@ -121,7 +121,7 @@ func _PositionService_GetPosition0_Bridge_Handler(srv PositionServiceHookedBridg return srv.GetPosition(ctx, req.(*GetPositionRequest)) }) - newctx, err := srv.BeforeGetPosition(ctx, &in) + newctx, err := srv.PrepareGetPosition(ctx, &in) if err != nil { return err } @@ -129,7 +129,7 @@ func _PositionService_GetPosition0_Bridge_Handler(srv PositionServiceHookedBridg if err != nil { return err } - return srv.GetPositionResult(ctx, &in, out.(*GetPositionResponse)) + return srv.CompleteGetPosition(ctx, &in, out.(*GetPositionResponse)) } } @@ -147,7 +147,7 @@ func _PositionService_CreatePosition0_Bridge_Handler(srv PositionServiceHookedBr return srv.CreatePosition(ctx, req.(*CreatePositionRequest)) }) - newctx, err := srv.BeforeCreatePosition(ctx, &in) + newctx, err := srv.PrepareCreatePosition(ctx, &in) if err != nil { return err } @@ -155,7 +155,7 @@ func _PositionService_CreatePosition0_Bridge_Handler(srv PositionServiceHookedBr if err != nil { return err } - return srv.CreatePositionResult(ctx, &in, out.(*CreatePositionResponse)) + return srv.CompleteCreatePosition(ctx, &in, out.(*CreatePositionResponse)) } } @@ -176,7 +176,7 @@ func _PositionService_UpdatePosition0_Bridge_Handler(srv PositionServiceHookedBr return srv.UpdatePosition(ctx, req.(*UpdatePositionRequest)) }) - newctx, err := srv.BeforeUpdatePosition(ctx, &in) + newctx, err := srv.PrepareUpdatePosition(ctx, &in) if err != nil { return err } @@ -184,7 +184,7 @@ func _PositionService_UpdatePosition0_Bridge_Handler(srv PositionServiceHookedBr if err != nil { return err } - return srv.UpdatePositionResult(ctx, &in, out.(*UpdatePositionResponse)) + return srv.CompleteUpdatePosition(ctx, &in, out.(*UpdatePositionResponse)) } } @@ -202,7 +202,7 @@ func _PositionService_DeletePosition0_Bridge_Handler(srv PositionServiceHookedBr return srv.DeletePosition(ctx, req.(*DeletePositionRequest)) }) - newctx, err := srv.BeforeDeletePosition(ctx, &in) + newctx, err := srv.PrepareDeletePosition(ctx, &in) if err != nil { return err } @@ -210,7 +210,7 @@ func _PositionService_DeletePosition0_Bridge_Handler(srv PositionServiceHookedBr if err != nil { return err } - return srv.DeletePositionResult(ctx, &in, out.(*DeletePositionResponse)) + return srv.CompleteDeletePosition(ctx, &in, out.(*DeletePositionResponse)) } } @@ -221,43 +221,43 @@ func _PositionService_DeletePosition0_Bridge_Handler(srv PositionServiceHookedBr // pointer dereference when methods are called. type UnimplementedPositionServiceHooked struct{} -func (UnimplementedPositionServiceHooked) BeforeCreatePosition(ctx http.Context, in *CreatePositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) PrepareCreatePosition(ctx http.Context, in *CreatePositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceHooked) CreatePositionResult(ctx http.Context, in *CreatePositionRequest, out *CreatePositionResponse) error { +func (UnimplementedPositionServiceHooked) CompleteCreatePosition(ctx http.Context, in *CreatePositionRequest, out *CreatePositionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceHooked) BeforeDeletePosition(ctx http.Context, in *DeletePositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) PrepareDeletePosition(ctx http.Context, in *DeletePositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceHooked) DeletePositionResult(ctx http.Context, in *DeletePositionRequest, out *DeletePositionResponse) error { +func (UnimplementedPositionServiceHooked) CompleteDeletePosition(ctx http.Context, in *DeletePositionRequest, out *DeletePositionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceHooked) BeforeGetPosition(ctx http.Context, in *GetPositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) PrepareGetPosition(ctx http.Context, in *GetPositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceHooked) GetPositionResult(ctx http.Context, in *GetPositionRequest, out *GetPositionResponse) error { +func (UnimplementedPositionServiceHooked) CompleteGetPosition(ctx http.Context, in *GetPositionRequest, out *GetPositionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceHooked) BeforeListPositions(ctx http.Context, in *ListPositionsRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) PrepareListPositions(ctx http.Context, in *ListPositionsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceHooked) ListPositionsResult(ctx http.Context, in *ListPositionsRequest, out *ListPositionsResponse) error { +func (UnimplementedPositionServiceHooked) CompleteListPositions(ctx http.Context, in *ListPositionsRequest, out *ListPositionsResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceHooked) BeforeUpdatePosition(ctx http.Context, in *UpdatePositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) PrepareUpdatePosition(ctx http.Context, in *UpdatePositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceHooked) UpdatePositionResult(ctx http.Context, in *UpdatePositionRequest, out *UpdatePositionResponse) error { +func (UnimplementedPositionServiceHooked) CompleteUpdatePosition(ctx http.Context, in *UpdatePositionRequest, out *UpdatePositionResponse) error { return ctx.Result(200, out) } diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go index c2ea1b3a..b31aba9b 100644 --- a/api/v1/services/system/resource_bridge.pb.go +++ b/api/v1/services/system/resource_bridge.pb.go @@ -55,24 +55,24 @@ type ResourceServiceHookedBridger interface { ResourceServiceBridger } type ResourceServiceCreateResourceHooker interface { - BeforeCreateResource(http.Context, *CreateResourceRequest) (context.Context, error) - CreateResourceResult(http.Context, *CreateResourceRequest, *CreateResourceResponse) error + PrepareCreateResource(http.Context, *CreateResourceRequest) (context.Context, error) + CompleteCreateResource(http.Context, *CreateResourceRequest, *CreateResourceResponse) error } type ResourceServiceDeleteResourceHooker interface { - BeforeDeleteResource(http.Context, *DeleteResourceRequest) (context.Context, error) - DeleteResourceResult(http.Context, *DeleteResourceRequest, *DeleteResourceResponse) error + PrepareDeleteResource(http.Context, *DeleteResourceRequest) (context.Context, error) + CompleteDeleteResource(http.Context, *DeleteResourceRequest, *DeleteResourceResponse) error } type ResourceServiceGetResourceHooker interface { - BeforeGetResource(http.Context, *GetResourceRequest) (context.Context, error) - GetResourceResult(http.Context, *GetResourceRequest, *GetResourceResponse) error + PrepareGetResource(http.Context, *GetResourceRequest) (context.Context, error) + CompleteGetResource(http.Context, *GetResourceRequest, *GetResourceResponse) error } type ResourceServiceListResourcesHooker interface { - BeforeListResources(http.Context, *ListResourcesRequest) (context.Context, error) - ListResourcesResult(http.Context, *ListResourcesRequest, *ListResourcesResponse) error + PrepareListResources(http.Context, *ListResourcesRequest) (context.Context, error) + CompleteListResources(http.Context, *ListResourcesRequest, *ListResourcesResponse) error } type ResourceServiceUpdateResourceHooker interface { - BeforeUpdateResource(http.Context, *UpdateResourceRequest) (context.Context, error) - UpdateResourceResult(http.Context, *UpdateResourceRequest, *UpdateResourceResponse) error + PrepareUpdateResource(http.Context, *UpdateResourceRequest) (context.Context, error) + CompleteUpdateResource(http.Context, *UpdateResourceRequest, *UpdateResourceResponse) error } func RegisterResourceServiceBridger(s *http.Server, srv ResourceServiceHookedBridger) { @@ -95,7 +95,7 @@ func _ResourceService_ListResources0_Bridge_Handler(srv ResourceServiceHookedBri return srv.ListResources(ctx, req.(*ListResourcesRequest)) }) - newctx, err := srv.BeforeListResources(ctx, &in) + newctx, err := srv.PrepareListResources(ctx, &in) if err != nil { return err } @@ -103,7 +103,7 @@ func _ResourceService_ListResources0_Bridge_Handler(srv ResourceServiceHookedBri if err != nil { return err } - return srv.ListResourcesResult(ctx, &in, out.(*ListResourcesResponse)) + return srv.CompleteListResources(ctx, &in, out.(*ListResourcesResponse)) } } @@ -121,7 +121,7 @@ func _ResourceService_GetResource0_Bridge_Handler(srv ResourceServiceHookedBridg return srv.GetResource(ctx, req.(*GetResourceRequest)) }) - newctx, err := srv.BeforeGetResource(ctx, &in) + newctx, err := srv.PrepareGetResource(ctx, &in) if err != nil { return err } @@ -129,7 +129,7 @@ func _ResourceService_GetResource0_Bridge_Handler(srv ResourceServiceHookedBridg if err != nil { return err } - return srv.GetResourceResult(ctx, &in, out.(*GetResourceResponse)) + return srv.CompleteGetResource(ctx, &in, out.(*GetResourceResponse)) } } @@ -147,7 +147,7 @@ func _ResourceService_CreateResource0_Bridge_Handler(srv ResourceServiceHookedBr return srv.CreateResource(ctx, req.(*CreateResourceRequest)) }) - newctx, err := srv.BeforeCreateResource(ctx, &in) + newctx, err := srv.PrepareCreateResource(ctx, &in) if err != nil { return err } @@ -155,7 +155,7 @@ func _ResourceService_CreateResource0_Bridge_Handler(srv ResourceServiceHookedBr if err != nil { return err } - return srv.CreateResourceResult(ctx, &in, out.(*CreateResourceResponse)) + return srv.CompleteCreateResource(ctx, &in, out.(*CreateResourceResponse)) } } @@ -176,7 +176,7 @@ func _ResourceService_UpdateResource0_Bridge_Handler(srv ResourceServiceHookedBr return srv.UpdateResource(ctx, req.(*UpdateResourceRequest)) }) - newctx, err := srv.BeforeUpdateResource(ctx, &in) + newctx, err := srv.PrepareUpdateResource(ctx, &in) if err != nil { return err } @@ -184,7 +184,7 @@ func _ResourceService_UpdateResource0_Bridge_Handler(srv ResourceServiceHookedBr if err != nil { return err } - return srv.UpdateResourceResult(ctx, &in, out.(*UpdateResourceResponse)) + return srv.CompleteUpdateResource(ctx, &in, out.(*UpdateResourceResponse)) } } @@ -202,7 +202,7 @@ func _ResourceService_DeleteResource0_Bridge_Handler(srv ResourceServiceHookedBr return srv.DeleteResource(ctx, req.(*DeleteResourceRequest)) }) - newctx, err := srv.BeforeDeleteResource(ctx, &in) + newctx, err := srv.PrepareDeleteResource(ctx, &in) if err != nil { return err } @@ -210,7 +210,7 @@ func _ResourceService_DeleteResource0_Bridge_Handler(srv ResourceServiceHookedBr if err != nil { return err } - return srv.DeleteResourceResult(ctx, &in, out.(*DeleteResourceResponse)) + return srv.CompleteDeleteResource(ctx, &in, out.(*DeleteResourceResponse)) } } @@ -221,43 +221,43 @@ func _ResourceService_DeleteResource0_Bridge_Handler(srv ResourceServiceHookedBr // pointer dereference when methods are called. type UnimplementedResourceServiceHooked struct{} -func (UnimplementedResourceServiceHooked) BeforeCreateResource(ctx http.Context, in *CreateResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) PrepareCreateResource(ctx http.Context, in *CreateResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceHooked) CreateResourceResult(ctx http.Context, in *CreateResourceRequest, out *CreateResourceResponse) error { +func (UnimplementedResourceServiceHooked) CompleteCreateResource(ctx http.Context, in *CreateResourceRequest, out *CreateResourceResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceHooked) BeforeDeleteResource(ctx http.Context, in *DeleteResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) PrepareDeleteResource(ctx http.Context, in *DeleteResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceHooked) DeleteResourceResult(ctx http.Context, in *DeleteResourceRequest, out *DeleteResourceResponse) error { +func (UnimplementedResourceServiceHooked) CompleteDeleteResource(ctx http.Context, in *DeleteResourceRequest, out *DeleteResourceResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceHooked) BeforeGetResource(ctx http.Context, in *GetResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) PrepareGetResource(ctx http.Context, in *GetResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceHooked) GetResourceResult(ctx http.Context, in *GetResourceRequest, out *GetResourceResponse) error { +func (UnimplementedResourceServiceHooked) CompleteGetResource(ctx http.Context, in *GetResourceRequest, out *GetResourceResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceHooked) BeforeListResources(ctx http.Context, in *ListResourcesRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) PrepareListResources(ctx http.Context, in *ListResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceHooked) ListResourcesResult(ctx http.Context, in *ListResourcesRequest, out *ListResourcesResponse) error { +func (UnimplementedResourceServiceHooked) CompleteListResources(ctx http.Context, in *ListResourcesRequest, out *ListResourcesResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceHooked) BeforeUpdateResource(ctx http.Context, in *UpdateResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) PrepareUpdateResource(ctx http.Context, in *UpdateResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceHooked) UpdateResourceResult(ctx http.Context, in *UpdateResourceRequest, out *UpdateResourceResponse) error { +func (UnimplementedResourceServiceHooked) CompleteUpdateResource(ctx http.Context, in *UpdateResourceRequest, out *UpdateResourceResponse) error { return ctx.Result(200, out) } diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go index f0a52636..186f05ef 100644 --- a/api/v1/services/system/role_bridge.pb.go +++ b/api/v1/services/system/role_bridge.pb.go @@ -55,24 +55,24 @@ type RoleServiceHookedBridger interface { RoleServiceBridger } type RoleServiceCreateRoleHooker interface { - BeforeCreateRole(http.Context, *CreateRoleRequest) (context.Context, error) - CreateRoleResult(http.Context, *CreateRoleRequest, *CreateRoleResponse) error + PrepareCreateRole(http.Context, *CreateRoleRequest) (context.Context, error) + CompleteCreateRole(http.Context, *CreateRoleRequest, *CreateRoleResponse) error } type RoleServiceDeleteRoleHooker interface { - BeforeDeleteRole(http.Context, *DeleteRoleRequest) (context.Context, error) - DeleteRoleResult(http.Context, *DeleteRoleRequest, *DeleteRoleResponse) error + PrepareDeleteRole(http.Context, *DeleteRoleRequest) (context.Context, error) + CompleteDeleteRole(http.Context, *DeleteRoleRequest, *DeleteRoleResponse) error } type RoleServiceGetRoleHooker interface { - BeforeGetRole(http.Context, *GetRoleRequest) (context.Context, error) - GetRoleResult(http.Context, *GetRoleRequest, *GetRoleResponse) error + PrepareGetRole(http.Context, *GetRoleRequest) (context.Context, error) + CompleteGetRole(http.Context, *GetRoleRequest, *GetRoleResponse) error } type RoleServiceListRolesHooker interface { - BeforeListRoles(http.Context, *ListRolesRequest) (context.Context, error) - ListRolesResult(http.Context, *ListRolesRequest, *ListRolesResponse) error + PrepareListRoles(http.Context, *ListRolesRequest) (context.Context, error) + CompleteListRoles(http.Context, *ListRolesRequest, *ListRolesResponse) error } type RoleServiceUpdateRoleHooker interface { - BeforeUpdateRole(http.Context, *UpdateRoleRequest) (context.Context, error) - UpdateRoleResult(http.Context, *UpdateRoleRequest, *UpdateRoleResponse) error + PrepareUpdateRole(http.Context, *UpdateRoleRequest) (context.Context, error) + CompleteUpdateRole(http.Context, *UpdateRoleRequest, *UpdateRoleResponse) error } func RegisterRoleServiceBridger(s *http.Server, srv RoleServiceHookedBridger) { @@ -95,7 +95,7 @@ func _RoleService_ListRoles0_Bridge_Handler(srv RoleServiceHookedBridger) func(c return srv.ListRoles(ctx, req.(*ListRolesRequest)) }) - newctx, err := srv.BeforeListRoles(ctx, &in) + newctx, err := srv.PrepareListRoles(ctx, &in) if err != nil { return err } @@ -103,7 +103,7 @@ func _RoleService_ListRoles0_Bridge_Handler(srv RoleServiceHookedBridger) func(c if err != nil { return err } - return srv.ListRolesResult(ctx, &in, out.(*ListRolesResponse)) + return srv.CompleteListRoles(ctx, &in, out.(*ListRolesResponse)) } } @@ -121,7 +121,7 @@ func _RoleService_GetRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx return srv.GetRole(ctx, req.(*GetRoleRequest)) }) - newctx, err := srv.BeforeGetRole(ctx, &in) + newctx, err := srv.PrepareGetRole(ctx, &in) if err != nil { return err } @@ -129,7 +129,7 @@ func _RoleService_GetRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx if err != nil { return err } - return srv.GetRoleResult(ctx, &in, out.(*GetRoleResponse)) + return srv.CompleteGetRole(ctx, &in, out.(*GetRoleResponse)) } } @@ -147,7 +147,7 @@ func _RoleService_CreateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func( return srv.CreateRole(ctx, req.(*CreateRoleRequest)) }) - newctx, err := srv.BeforeCreateRole(ctx, &in) + newctx, err := srv.PrepareCreateRole(ctx, &in) if err != nil { return err } @@ -155,7 +155,7 @@ func _RoleService_CreateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func( if err != nil { return err } - return srv.CreateRoleResult(ctx, &in, out.(*CreateRoleResponse)) + return srv.CompleteCreateRole(ctx, &in, out.(*CreateRoleResponse)) } } @@ -176,7 +176,7 @@ func _RoleService_UpdateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func( return srv.UpdateRole(ctx, req.(*UpdateRoleRequest)) }) - newctx, err := srv.BeforeUpdateRole(ctx, &in) + newctx, err := srv.PrepareUpdateRole(ctx, &in) if err != nil { return err } @@ -184,7 +184,7 @@ func _RoleService_UpdateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func( if err != nil { return err } - return srv.UpdateRoleResult(ctx, &in, out.(*UpdateRoleResponse)) + return srv.CompleteUpdateRole(ctx, &in, out.(*UpdateRoleResponse)) } } @@ -202,7 +202,7 @@ func _RoleService_DeleteRole0_Bridge_Handler(srv RoleServiceHookedBridger) func( return srv.DeleteRole(ctx, req.(*DeleteRoleRequest)) }) - newctx, err := srv.BeforeDeleteRole(ctx, &in) + newctx, err := srv.PrepareDeleteRole(ctx, &in) if err != nil { return err } @@ -210,7 +210,7 @@ func _RoleService_DeleteRole0_Bridge_Handler(srv RoleServiceHookedBridger) func( if err != nil { return err } - return srv.DeleteRoleResult(ctx, &in, out.(*DeleteRoleResponse)) + return srv.CompleteDeleteRole(ctx, &in, out.(*DeleteRoleResponse)) } } @@ -221,43 +221,43 @@ func _RoleService_DeleteRole0_Bridge_Handler(srv RoleServiceHookedBridger) func( // pointer dereference when methods are called. type UnimplementedRoleServiceHooked struct{} -func (UnimplementedRoleServiceHooked) BeforeCreateRole(ctx http.Context, in *CreateRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) PrepareCreateRole(ctx http.Context, in *CreateRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceHooked) CreateRoleResult(ctx http.Context, in *CreateRoleRequest, out *CreateRoleResponse) error { +func (UnimplementedRoleServiceHooked) CompleteCreateRole(ctx http.Context, in *CreateRoleRequest, out *CreateRoleResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceHooked) BeforeDeleteRole(ctx http.Context, in *DeleteRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) PrepareDeleteRole(ctx http.Context, in *DeleteRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceHooked) DeleteRoleResult(ctx http.Context, in *DeleteRoleRequest, out *DeleteRoleResponse) error { +func (UnimplementedRoleServiceHooked) CompleteDeleteRole(ctx http.Context, in *DeleteRoleRequest, out *DeleteRoleResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceHooked) BeforeGetRole(ctx http.Context, in *GetRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) PrepareGetRole(ctx http.Context, in *GetRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceHooked) GetRoleResult(ctx http.Context, in *GetRoleRequest, out *GetRoleResponse) error { +func (UnimplementedRoleServiceHooked) CompleteGetRole(ctx http.Context, in *GetRoleRequest, out *GetRoleResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceHooked) BeforeListRoles(ctx http.Context, in *ListRolesRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) PrepareListRoles(ctx http.Context, in *ListRolesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceHooked) ListRolesResult(ctx http.Context, in *ListRolesRequest, out *ListRolesResponse) error { +func (UnimplementedRoleServiceHooked) CompleteListRoles(ctx http.Context, in *ListRolesRequest, out *ListRolesResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceHooked) BeforeUpdateRole(ctx http.Context, in *UpdateRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) PrepareUpdateRole(ctx http.Context, in *UpdateRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceHooked) UpdateRoleResult(ctx http.Context, in *UpdateRoleRequest, out *UpdateRoleResponse) error { +func (UnimplementedRoleServiceHooked) CompleteUpdateRole(ctx http.Context, in *UpdateRoleRequest, out *UpdateRoleResponse) error { return ctx.Result(200, out) } diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 945fdcbb..ddc0da78 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -70,40 +70,40 @@ type UserServiceHookedBridger interface { UserServiceBridger } type UserServiceCreateUserHooker interface { - BeforeCreateUser(http.Context, *CreateUserRequest) (context.Context, error) - CreateUserResult(http.Context, *CreateUserRequest, *CreateUserResponse) error + PrepareCreateUser(http.Context, *CreateUserRequest) (context.Context, error) + CompleteCreateUser(http.Context, *CreateUserRequest, *CreateUserResponse) error } type UserServiceDeleteUserHooker interface { - BeforeDeleteUser(http.Context, *DeleteUserRequest) (context.Context, error) - DeleteUserResult(http.Context, *DeleteUserRequest, *DeleteUserResponse) error + PrepareDeleteUser(http.Context, *DeleteUserRequest) (context.Context, error) + CompleteDeleteUser(http.Context, *DeleteUserRequest, *DeleteUserResponse) error } type UserServiceGetUserHooker interface { - BeforeGetUser(http.Context, *GetUserRequest) (context.Context, error) - GetUserResult(http.Context, *GetUserRequest, *GetUserResponse) error + PrepareGetUser(http.Context, *GetUserRequest) (context.Context, error) + CompleteGetUser(http.Context, *GetUserRequest, *GetUserResponse) error } type UserServiceListUserResourcesHooker interface { - BeforeListUserResources(http.Context, *ListUserResourcesRequest) (context.Context, error) - ListUserResourcesResult(http.Context, *ListUserResourcesRequest, *ListUserResourcesResponse) error + PrepareListUserResources(http.Context, *ListUserResourcesRequest) (context.Context, error) + CompleteListUserResources(http.Context, *ListUserResourcesRequest, *ListUserResourcesResponse) error } type UserServiceListUsersHooker interface { - BeforeListUsers(http.Context, *ListUsersRequest) (context.Context, error) - ListUsersResult(http.Context, *ListUsersRequest, *ListUsersResponse) error + PrepareListUsers(http.Context, *ListUsersRequest) (context.Context, error) + CompleteListUsers(http.Context, *ListUsersRequest, *ListUsersResponse) error } type UserServiceResetUserPasswordHooker interface { - BeforeResetUserPassword(http.Context, *ResetUserPasswordRequest) (context.Context, error) - ResetUserPasswordResult(http.Context, *ResetUserPasswordRequest, *ResetUserPasswordResponse) error + PrepareResetUserPassword(http.Context, *ResetUserPasswordRequest) (context.Context, error) + CompleteResetUserPassword(http.Context, *ResetUserPasswordRequest, *ResetUserPasswordResponse) error } type UserServiceUpdateUserHooker interface { - BeforeUpdateUser(http.Context, *UpdateUserRequest) (context.Context, error) - UpdateUserResult(http.Context, *UpdateUserRequest, *UpdateUserResponse) error + PrepareUpdateUser(http.Context, *UpdateUserRequest) (context.Context, error) + CompleteUpdateUser(http.Context, *UpdateUserRequest, *UpdateUserResponse) error } type UserServiceUpdateUserRolesHooker interface { - BeforeUpdateUserRoles(http.Context, *UpdateUserRolesRequest) (context.Context, error) - UpdateUserRolesResult(http.Context, *UpdateUserRolesRequest, *UpdateUserRolesResponse) error + PrepareUpdateUserRoles(http.Context, *UpdateUserRolesRequest) (context.Context, error) + CompleteUpdateUserRoles(http.Context, *UpdateUserRolesRequest, *UpdateUserRolesResponse) error } type UserServiceUpdateUserStatusHooker interface { - BeforeUpdateUserStatus(http.Context, *UpdateUserStatusRequest) (context.Context, error) - UpdateUserStatusResult(http.Context, *UpdateUserStatusRequest, *UpdateUserStatusResponse) error + PrepareUpdateUserStatus(http.Context, *UpdateUserStatusRequest) (context.Context, error) + CompleteUpdateUserStatus(http.Context, *UpdateUserStatusRequest, *UpdateUserStatusResponse) error } func RegisterUserServiceBridger(s *http.Server, srv UserServiceHookedBridger) { @@ -130,7 +130,7 @@ func _UserService_ListUsers0_Bridge_Handler(srv UserServiceHookedBridger) func(c return srv.ListUsers(ctx, req.(*ListUsersRequest)) }) - newctx, err := srv.BeforeListUsers(ctx, &in) + newctx, err := srv.PrepareListUsers(ctx, &in) if err != nil { return err } @@ -138,7 +138,7 @@ func _UserService_ListUsers0_Bridge_Handler(srv UserServiceHookedBridger) func(c if err != nil { return err } - return srv.ListUsersResult(ctx, &in, out.(*ListUsersResponse)) + return srv.CompleteListUsers(ctx, &in, out.(*ListUsersResponse)) } } @@ -156,7 +156,7 @@ func _UserService_ListUserResources0_Bridge_Handler(srv UserServiceHookedBridger return srv.ListUserResources(ctx, req.(*ListUserResourcesRequest)) }) - newctx, err := srv.BeforeListUserResources(ctx, &in) + newctx, err := srv.PrepareListUserResources(ctx, &in) if err != nil { return err } @@ -164,7 +164,7 @@ func _UserService_ListUserResources0_Bridge_Handler(srv UserServiceHookedBridger if err != nil { return err } - return srv.ListUserResourcesResult(ctx, &in, out.(*ListUserResourcesResponse)) + return srv.CompleteListUserResources(ctx, &in, out.(*ListUserResourcesResponse)) } } @@ -182,7 +182,7 @@ func _UserService_GetUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx return srv.GetUser(ctx, req.(*GetUserRequest)) }) - newctx, err := srv.BeforeGetUser(ctx, &in) + newctx, err := srv.PrepareGetUser(ctx, &in) if err != nil { return err } @@ -190,7 +190,7 @@ func _UserService_GetUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx if err != nil { return err } - return srv.GetUserResult(ctx, &in, out.(*GetUserResponse)) + return srv.CompleteGetUser(ctx, &in, out.(*GetUserResponse)) } } @@ -208,7 +208,7 @@ func _UserService_CreateUser0_Bridge_Handler(srv UserServiceHookedBridger) func( return srv.CreateUser(ctx, req.(*CreateUserRequest)) }) - newctx, err := srv.BeforeCreateUser(ctx, &in) + newctx, err := srv.PrepareCreateUser(ctx, &in) if err != nil { return err } @@ -216,7 +216,7 @@ func _UserService_CreateUser0_Bridge_Handler(srv UserServiceHookedBridger) func( if err != nil { return err } - return srv.CreateUserResult(ctx, &in, out.(*CreateUserResponse)) + return srv.CompleteCreateUser(ctx, &in, out.(*CreateUserResponse)) } } @@ -237,7 +237,7 @@ func _UserService_UpdateUser0_Bridge_Handler(srv UserServiceHookedBridger) func( return srv.UpdateUser(ctx, req.(*UpdateUserRequest)) }) - newctx, err := srv.BeforeUpdateUser(ctx, &in) + newctx, err := srv.PrepareUpdateUser(ctx, &in) if err != nil { return err } @@ -245,7 +245,7 @@ func _UserService_UpdateUser0_Bridge_Handler(srv UserServiceHookedBridger) func( if err != nil { return err } - return srv.UpdateUserResult(ctx, &in, out.(*UpdateUserResponse)) + return srv.CompleteUpdateUser(ctx, &in, out.(*UpdateUserResponse)) } } @@ -263,7 +263,7 @@ func _UserService_DeleteUser0_Bridge_Handler(srv UserServiceHookedBridger) func( return srv.DeleteUser(ctx, req.(*DeleteUserRequest)) }) - newctx, err := srv.BeforeDeleteUser(ctx, &in) + newctx, err := srv.PrepareDeleteUser(ctx, &in) if err != nil { return err } @@ -271,7 +271,7 @@ func _UserService_DeleteUser0_Bridge_Handler(srv UserServiceHookedBridger) func( if err != nil { return err } - return srv.DeleteUserResult(ctx, &in, out.(*DeleteUserResponse)) + return srv.CompleteDeleteUser(ctx, &in, out.(*DeleteUserResponse)) } } @@ -292,7 +292,7 @@ func _UserService_UpdateUserStatus0_Bridge_Handler(srv UserServiceHookedBridger) return srv.UpdateUserStatus(ctx, req.(*UpdateUserStatusRequest)) }) - newctx, err := srv.BeforeUpdateUserStatus(ctx, &in) + newctx, err := srv.PrepareUpdateUserStatus(ctx, &in) if err != nil { return err } @@ -300,7 +300,7 @@ func _UserService_UpdateUserStatus0_Bridge_Handler(srv UserServiceHookedBridger) if err != nil { return err } - return srv.UpdateUserStatusResult(ctx, &in, out.(*UpdateUserStatusResponse)) + return srv.CompleteUpdateUserStatus(ctx, &in, out.(*UpdateUserStatusResponse)) } } @@ -321,7 +321,7 @@ func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceHookedBridger) return srv.UpdateUserRoles(ctx, req.(*UpdateUserRolesRequest)) }) - newctx, err := srv.BeforeUpdateUserRoles(ctx, &in) + newctx, err := srv.PrepareUpdateUserRoles(ctx, &in) if err != nil { return err } @@ -329,7 +329,7 @@ func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceHookedBridger) if err != nil { return err } - return srv.UpdateUserRolesResult(ctx, &in, out.(*UpdateUserRolesResponse)) + return srv.CompleteUpdateUserRoles(ctx, &in, out.(*UpdateUserRolesResponse)) } } @@ -350,7 +350,7 @@ func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceHookedBridger return srv.ResetUserPassword(ctx, req.(*ResetUserPasswordRequest)) }) - newctx, err := srv.BeforeResetUserPassword(ctx, &in) + newctx, err := srv.PrepareResetUserPassword(ctx, &in) if err != nil { return err } @@ -358,7 +358,7 @@ func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceHookedBridger if err != nil { return err } - return srv.ResetUserPasswordResult(ctx, &in, out.(*ResetUserPasswordResponse)) + return srv.CompleteResetUserPassword(ctx, &in, out.(*ResetUserPasswordResponse)) } } @@ -369,75 +369,75 @@ func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceHookedBridger // pointer dereference when methods are called. type UnimplementedUserServiceHooked struct{} -func (UnimplementedUserServiceHooked) BeforeCreateUser(ctx http.Context, in *CreateUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareCreateUser(ctx http.Context, in *CreateUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) CreateUserResult(ctx http.Context, in *CreateUserRequest, out *CreateUserResponse) error { +func (UnimplementedUserServiceHooked) CompleteCreateUser(ctx http.Context, in *CreateUserRequest, out *CreateUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) BeforeDeleteUser(ctx http.Context, in *DeleteUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareDeleteUser(ctx http.Context, in *DeleteUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) DeleteUserResult(ctx http.Context, in *DeleteUserRequest, out *DeleteUserResponse) error { +func (UnimplementedUserServiceHooked) CompleteDeleteUser(ctx http.Context, in *DeleteUserRequest, out *DeleteUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) BeforeGetUser(ctx http.Context, in *GetUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareGetUser(ctx http.Context, in *GetUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) GetUserResult(ctx http.Context, in *GetUserRequest, out *GetUserResponse) error { +func (UnimplementedUserServiceHooked) CompleteGetUser(ctx http.Context, in *GetUserRequest, out *GetUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) BeforeListUserResources(ctx http.Context, in *ListUserResourcesRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareListUserResources(ctx http.Context, in *ListUserResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) ListUserResourcesResult(ctx http.Context, in *ListUserResourcesRequest, out *ListUserResourcesResponse) error { +func (UnimplementedUserServiceHooked) CompleteListUserResources(ctx http.Context, in *ListUserResourcesRequest, out *ListUserResourcesResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) BeforeListUsers(ctx http.Context, in *ListUsersRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareListUsers(ctx http.Context, in *ListUsersRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) ListUsersResult(ctx http.Context, in *ListUsersRequest, out *ListUsersResponse) error { +func (UnimplementedUserServiceHooked) CompleteListUsers(ctx http.Context, in *ListUsersRequest, out *ListUsersResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) BeforeResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) ResetUserPasswordResult(ctx http.Context, in *ResetUserPasswordRequest, out *ResetUserPasswordResponse) error { +func (UnimplementedUserServiceHooked) CompleteResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest, out *ResetUserPasswordResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) BeforeUpdateUser(ctx http.Context, in *UpdateUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareUpdateUser(ctx http.Context, in *UpdateUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) UpdateUserResult(ctx http.Context, in *UpdateUserRequest, out *UpdateUserResponse) error { +func (UnimplementedUserServiceHooked) CompleteUpdateUser(ctx http.Context, in *UpdateUserRequest, out *UpdateUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) BeforeUpdateUserRoles(ctx http.Context, in *UpdateUserRolesRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareUpdateUserRoles(ctx http.Context, in *UpdateUserRolesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) UpdateUserRolesResult(ctx http.Context, in *UpdateUserRolesRequest, out *UpdateUserRolesResponse) error { +func (UnimplementedUserServiceHooked) CompleteUpdateUserRoles(ctx http.Context, in *UpdateUserRolesRequest, out *UpdateUserRolesResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) BeforeUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) UpdateUserStatusResult(ctx http.Context, in *UpdateUserStatusRequest, out *UpdateUserStatusResponse) error { +func (UnimplementedUserServiceHooked) CompleteUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest, out *UpdateUserStatusResponse) error { return ctx.Result(200, out) } diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index 8a2582f8..c4c94d85 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -6,9 +6,13 @@ package start import ( + "log/slog" + "github.com/go-kratos/kratos/v2" + "github.com/go-kratos/kratos/v2/transport" "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" + "github.com/origadmin/runtime/log" "github.com/spf13/cobra" _ "origadmin/application/admin/contrib/consul/config" @@ -58,8 +62,15 @@ func Cmd() *cobra.Command { } func startCommandRun(cmd *cobra.Command, args []string) error { - if err := loader.Bootstrap(cmd.Context(), flags, buildInjectors); err != nil { - return err + debug, err := cmd.Flags().GetBool(startDebug) + if err != nil { + debug = false + } + if debug { + flags.SetEnv("debug") + flags.SetConfigPath("resources/configs/system_config.toml") + flags.SetWorkDir(".") + slog.SetLogLoggerLevel(slog.LevelDebug) } //var registrar registry.KRegistrar //if flags.IsMainService() { @@ -76,9 +87,17 @@ func startCommandRun(cmd *cobra.Command, args []string) error { // Version: flags.Version(), // Server: grpcServer, //}) + ll := log.NewHelper(log.GetLogger()) + ll.Infof("bootstrap flags: %+v", flags) + if err := loader.Bootstrap(cmd.Context(), flags, buildInjectors); err != nil { + ll.Infof("failed to bootstrap: %s", err.Error()) + return err + } + return nil } -func NewAppProvider(r runtime.Runtime, injector *loader.InjectorClient) *kratos.App { - return r.CreateApp(injector.Server) +func NewApp(r runtime.Runtime, servers []transport.Server) *kratos.App { + r = r.Client() + return r.CreateApp(servers...) } diff --git a/cmd/internal/start/wire.go b/cmd/internal/start/wire.go index 86cd8816..aea25a7c 100644 --- a/cmd/internal/start/wire.go +++ b/cmd/internal/start/wire.go @@ -15,6 +15,8 @@ import ( "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/loader" + authservice "origadmin/application/admin/internal/mods/auth/service" + systemservice "origadmin/application/admin/internal/mods/system/service" ) // buildInjectors init kratos application. @@ -22,7 +24,8 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap panic(wire.Build( loader.ProviderSet, //agent.ProviderSet, - //server.ProviderSet, + systemservice.ProviderSet, + authservice.ProviderSet, //basisserver.ProviderSet, - NewAppProvider)) + NewApp)) } diff --git a/cmd/internal/start/wire_gen.go b/cmd/internal/start/wire_gen.go index ce20202e..e5ec4d25 100644 --- a/cmd/internal/start/wire_gen.go +++ b/cmd/internal/start/wire_gen.go @@ -27,7 +27,7 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap injectorClient := &loader.InjectorClient{ Server: server, } - app := NewAppProvider(r, injectorClient) + app := NewApp(r, injectorClient) return app, func() { }, nil } diff --git a/helpers/captcha/captcha.go b/helpers/captcha/captcha.go index 70dc7984..518416f7 100644 --- a/helpers/captcha/captcha.go +++ b/helpers/captcha/captcha.go @@ -6,13 +6,17 @@ package captcha import ( - "errors" "net/http" "github.com/mojocn/base64Captcha" + "github.com/origadmin/toolkits/errors/httperr" + + typespb "origadmin/application/admin/api/v1/services/types" ) -var ErrNotFound = errors.New("captcha not found") +var ( + ErrNotFound = httperr.New("http.response.status."+typespb.AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), http.StatusBadRequest, "captcha not found") +) const ( TypeAudio = "audio" diff --git a/helpers/db/db.go b/helpers/db/db.go index a60ecf4a..cb4039ca 100644 --- a/helpers/db/db.go +++ b/helpers/db/db.go @@ -13,7 +13,7 @@ import ( "github.com/origadmin/runtime/interfaces/pagination" ) -type QueryPager[T any] interface { +type Paginator[T any] interface { Limit(int) T Offset(int) T } @@ -27,14 +27,14 @@ type FieldSelector[T any] interface { Omit(...string) T } -func PaginationQuery[Q QueryPager[Q]](query Q, in pagination.PageRequest, paging bool) Q { +func Query[P Paginator[P]](query P, in pagination.PageRequest, paging bool) P { if !paging { - return NoPageQuery(query, in) + return QueryNoPage(query, in) } - return PageQuery(query, in) + return QueryPage(query, in) } -func NoPageQuery[Q QueryPager[Q]](query Q, in pagination.PageSizeGetter) Q { +func QueryNoPage[P Paginator[P]](query P, in pagination.PageSizeGetter) P { pageSize := in.GetPageSize() if pageSize > 0 { query = query.Limit(int(pageSize)) @@ -42,7 +42,7 @@ func NoPageQuery[Q QueryPager[Q]](query Q, in pagination.PageSizeGetter) Q { return query } -func handleTokenPagination[Q QueryPager[Q]](query Q, token string) Q { +func handleTokenPagination[P Paginator[P]](query P, token string) P { // TODO: 实现游标分页逻辑 // 示例伪代码: // decodedToken := decodeToken(token) @@ -50,7 +50,7 @@ func handleTokenPagination[Q QueryPager[Q]](query Q, token string) Q { return query } -func PageQuery[Q QueryPager[Q]](query Q, in pagination.PageRequest) Q { +func QueryPage[P Paginator[P]](query P, in pagination.PageRequest) P { pageSize := in.GetPageSize() if pageSize > 0 { query = query.Limit(int(pageSize)) @@ -75,7 +75,11 @@ func PageCount[Q QueryCounter[Q]](ctx context.Context, query Q) (int32, error) { return int32(count), nil } -func OrderBy[T ~func(*sql.Selector)](fields []string, orders ...T) []T { +type Order interface { + ~func(*sql.Selector) +} + +func OrderBy[T Order](fields []string, orders ...T) []T { for _, field := range fields { parts := strings.Split(field, ",") fieldName := parts[0] diff --git a/internal/loader/bootstrap.go b/internal/loader/bootstrap.go index 3512f30b..323d4471 100644 --- a/internal/loader/bootstrap.go +++ b/internal/loader/bootstrap.go @@ -25,14 +25,16 @@ import ( type NewApp func(runtime.Runtime, *configs.Bootstrap) (*kratos.App, func(), error) func Resolve(config config.KConfig) (config.Resolved, error) { - var rb ResolvedBootstrap + rb := &ResolvedBootstrap{ + bootstrap: DefaultBootstrap(), + } if err := config.Load(); err != nil { return nil, err } - if err := config.Scan(&rb.bootstrap); err != nil { + if err := config.Scan(rb.bootstrap); err != nil { return nil, err } - return &rb, nil + return rb, nil } type BootstrapConfig func(config config.KConfig) (config.Resolved, error) @@ -42,7 +44,7 @@ func (b BootstrapConfig) Resolve(config config.KConfig) (config.Resolved, error) } type ResolvedBootstrap struct { - bootstrap configs.Bootstrap + bootstrap *configs.Bootstrap } func (r *ResolvedBootstrap) FillServiceInfo(flags *bootstrap.Bootstrap) { @@ -58,7 +60,7 @@ func (r *ResolvedBootstrap) Discovery() *configv1.Discovery { } func (r *ResolvedBootstrap) Resolve(config config.KConfig) (config.Resolved, error) { - if err := config.Scan(&r.bootstrap); err != nil { + if err := config.Scan(r.bootstrap); err != nil { return nil, err } return r, nil @@ -93,8 +95,10 @@ func (r *ResolvedBootstrap) Logger() *configv1.Logger { } func Bootstrap(ctx context.Context, flags *bootstrap.Bootstrap, newApp NewApp) error { - var rb ResolvedBootstrap - r, err := runtime.Load(flags, runtime.WithResolver(&rb), runtime.WithContext(ctx)) + rb := &ResolvedBootstrap{ + bootstrap: DefaultBootstrap(), + } + r, err := runtime.Load(flags, runtime.WithResolver(rb), runtime.WithContext(ctx)) if err != nil { return err } @@ -108,7 +112,7 @@ func Bootstrap(ctx context.Context, flags *bootstrap.Bootstrap, newApp NewApp) e "trace.id", tracing.TraceID(), "span.id", tracing.SpanID(), ) - app, clean, err := newApp(r, &rb.bootstrap) + app, clean, err := newApp(r, rb.bootstrap) if err != nil { return err } diff --git a/internal/loader/config.go b/internal/loader/config.go index 2a14eda3..c2f772cc 100644 --- a/internal/loader/config.go +++ b/internal/loader/config.go @@ -20,11 +20,11 @@ func LoadBootstrap(cfg *configv1.SourceConfig) (*configs.Bootstrap, error) { if err := source.Load(); err != nil { return nil, err } - var bs configs.Bootstrap - if err := source.Scan(&bs); err != nil { + bs := DefaultBootstrap() + if err := source.Scan(bs); err != nil { return nil, err } - return &bs, nil + return bs, nil } func LoadLocalBootstrap(path string) (*configs.Bootstrap, error) { diff --git a/internal/loader/load.go b/internal/loader/load.go index 80d47e04..2d53979c 100644 --- a/internal/loader/load.go +++ b/internal/loader/load.go @@ -12,8 +12,8 @@ import ( "github.com/google/wire" "github.com/origadmin/contrib/transport/gins" "github.com/origadmin/runtime" - "github.com/origadmin/runtime/bootstrap" configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/registry" @@ -33,7 +33,7 @@ type AppOptions struct { var ( ProviderSet = wire.NewSet( NewRegistrar, - MockHttpServer, + NewProxyServer, wire.Struct(new(Injector), "*"), wire.Struct(new(InjectorClient), "*"), ) diff --git a/internal/loader/proxy.go b/internal/loader/proxy.go new file mode 100644 index 00000000..bec8370d --- /dev/null +++ b/internal/loader/proxy.go @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package loader implements the functions, types, and interfaces for the module. +package loader + +import ( + "strings" + + "github.com/go-kratos/kratos/v2/middleware/recovery" + "github.com/go-kratos/kratos/v2/middleware/selector" + "github.com/go-kratos/kratos/v2/transport" + "github.com/go-kratos/kratos/v2/transport/http" + "github.com/gorilla/handlers" + "github.com/origadmin/runtime" + msecurity "github.com/origadmin/runtime/agent/middleware/security" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/middleware" + "github.com/origadmin/runtime/service" + servicehttp "github.com/origadmin/runtime/service/http" + + "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/contrib/security/authz/casbin" + "origadmin/application/admin/helpers/resp" + "origadmin/application/admin/helpers/securityx" + "origadmin/application/admin/internal/configs" +) + +type data struct { +} + +func (d data) QueryRoles(ctx context.Context, subject string) ([]string, error) { + //TODO implement me + panic("implement me") +} + +func (d data) QueryPermissions(ctx context.Context, subject string) ([]string, error) { + //TODO implement me + panic("implement me") +} + +// NewProxyServer creates a new proxy server. +func NewProxyServer(r runtime.Runtime, bootstrap *configs.Bootstrap, registrars []service.ServerRegistrar, + client auth.CasbinSourceServiceClient) []transport.Server { + clients := bootstrap.GetClients() + if clients == nil { + panic("no service config") + } + paths := bootstrap.GetSecurity().GetSecurity().GetPublicPaths() + paths = append(DefaultPaths(), paths...) + ms := []middleware.KMiddleware{ + recovery.Recovery(), + } + authenticator, err := securityx.NewAuthenticator(bootstrap) + if err != nil { + panic(err) + } + + opts := []casbin.AuthorizerOption{casbin.WithServiceClient(client)} + + authorizer, err := securityx.NewAuthorizer(bootstrap, opts...) + if err != nil { + panic(err) + } + bridge := securityx.SecurityBridge{ + TokenSource: security.TokenSourceHeader, + Scheme: security.SchemeBearer, + AuthenticationHeader: security.HeaderAuthorize, + Authenticator: authenticator, + Authorizer: authorizer, + SkipKey: msecurity.MetadataSecuritySkipKey, + PublicPaths: nil, + Skipper: func(path string) bool { + return false + }, + IsRoot: func(ctx context.Context, claims security.Claims) bool { + return claims.GetSubject() == "root" || claims.GetSubject() == "admin" + }, + Provider: &data{}, + TokenParser: nil, + } + serv := selector.Server(bridge.Middleware()).Match(func(ctx context.Context, operation string) bool { + for _, p := range paths { + if strings.HasPrefix(operation, p) { + log.Debugf("Operation '%s' matches public path '%s', returning true", operation, p) + return false + } + } + log.Debugf("Operation '%s' no matches public path '%s'", operation, "*") + return true + }) + ms = append(ms, serv.Build(), CallLoggerMiddleware()) + //clients.Get + for i := range clients { + clients[i].GetCore().GetName() + + } + //clients.Name = types.ZeroOr(clients.Name, "ORIGADMIN_SERVICE") + srv, err := runtime.NewHTTPServiceServer(bootstrap.GetEntry().GetServer(), + servicehttp.WithServerOptions( + http.ErrorEncoder(resp.ResponseErrorEncoder), + http.Filter(handlers.CORS( + handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), + handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS"}), + handlers.AllowedOrigins([]string{"*"}), + ))), + servicehttp.WithMiddlewares(ms...), + servicehttp.WithPrefix(runtime.DefaultEnvPrefix), + ) + if err != nil { + panic(err) + } + for _, registrar := range registrars { + registrar.Register(r.Context(), srv) + } + srv.WalkRoute(func(info http.RouteInfo) error { + log.Infof("Registered HTTP route: %s %s", info.Method, info.Path) + return nil + }) + + return []transport.Server{srv} +} + +func DefaultPaths() []string { + return []string{ + auth.OperationLoginServiceCaptchaId, + auth.OperationLoginServiceCaptcha, + auth.OperationLoginServiceCaptchaImage, + auth.OperationLoginServiceCaptchaAudio, + auth.OperationLoginServiceLogin, + auth.OperationLoginServiceRegister, + auth.OperationLoginServiceTokenRefresh, + } +} + +func CallLoggerMiddleware() middleware.KMiddleware { + return func(handler middleware.KHandler) middleware.KHandler { + return func(ctx context.Context, req interface{}) (reply interface{}, err error) { + log.Infof("CallLoggerMiddleware: %+v", ctx) + tr, ok := transport.FromServerContext(ctx) + log.Infof("Caller Server: %+v, ok: %+v", tr, ok) + tr, ok = transport.FromClientContext(ctx) + log.Infof("Caller ServiceClient: %+v, ok: %+v", tr, ok) + return handler(ctx, req) + } + } +} + +func CorsMiddleware() middleware.KMiddleware { + return func(handler middleware.KHandler) middleware.KHandler { + return func(ctx context.Context, req interface{}) (reply interface{}, err error) { + log.Infof("CorsMiddleware: %+v", ctx) + return handler(ctx, req) + } + } +} diff --git a/internal/mods/auth/service/auth.bridge.go b/internal/mods/auth/service/auth.bridge.go index f3e9040c..c0d75df9 100644 --- a/internal/mods/auth/service/auth.bridge.go +++ b/internal/mods/auth/service/auth.bridge.go @@ -29,17 +29,17 @@ type AuthServiceHookedBridge struct { log *log.KHelper } -func (s AuthServiceHookedBridge) BeforeAuthLogout(h transhttp.Context, request *pb.AuthLogoutRequest) (context2.Context, error) { +func (s AuthServiceHookedBridge) PrepareAuthLogout(h transhttp.Context, request *pb.AuthLogoutRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) AuthLogoutResult(h transhttp.Context, request *pb.AuthLogoutRequest, response *pb.AuthLogoutResponse) error { +func (s AuthServiceHookedBridge) CompleteAuthLogout(h transhttp.Context, request *pb.AuthLogoutRequest, response *pb.AuthLogoutResponse) error { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) AuthenticateResult(h transhttp.Context, request *pb.AuthenticateRequest, response *pb.AuthenticateResponse) error { +func (s AuthServiceHookedBridge) CompleteAuthenticate(h transhttp.Context, request *pb.AuthenticateRequest, response *pb.AuthenticateResponse) error { if !response.IsValid { return ErrorInvalidToken } @@ -48,42 +48,42 @@ func (s AuthServiceHookedBridge) AuthenticateResult(h transhttp.Context, request }) } -func (s AuthServiceHookedBridge) BeforeCreateToken(h transhttp.Context, request *pb.CreateTokenRequest) (context2.Context, error) { +func (s AuthServiceHookedBridge) PrepareCreateToken(h transhttp.Context, request *pb.CreateTokenRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) CreateTokenResult(h transhttp.Context, request *pb.CreateTokenRequest, response *pb.CreateTokenResponse) error { +func (s AuthServiceHookedBridge) CompleteCreateToken(h transhttp.Context, request *pb.CreateTokenRequest, response *pb.CreateTokenResponse) error { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) BeforeDestroyToken(h transhttp.Context, request *pb.DestroyTokenRequest) (context2.Context, error) { +func (s AuthServiceHookedBridge) PrepareDestroyToken(h transhttp.Context, request *pb.DestroyTokenRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) DestroyTokenResult(h transhttp.Context, request *pb.DestroyTokenRequest, response *pb.DestroyTokenResponse) error { +func (s AuthServiceHookedBridge) CompleteDestroyToken(h transhttp.Context, request *pb.DestroyTokenRequest, response *pb.DestroyTokenResponse) error { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) BeforeListAuthResources(h transhttp.Context, request *pb.ListAuthResourcesRequest) (context2.Context, error) { +func (s AuthServiceHookedBridge) PrepareListAuthResources(h transhttp.Context, request *pb.ListAuthResourcesRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) ListAuthResourcesResult(h transhttp.Context, request *pb.ListAuthResourcesRequest, response *pb.ListAuthResourcesResponse) error { +func (s AuthServiceHookedBridge) CompleteListAuthResources(h transhttp.Context, request *pb.ListAuthResourcesRequest, response *pb.ListAuthResourcesResponse) error { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) BeforeValidateToken(h transhttp.Context, request *pb.ValidateTokenRequest) (context2.Context, error) { +func (s AuthServiceHookedBridge) PrepareValidateToken(h transhttp.Context, request *pb.ValidateTokenRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) ValidateTokenResult(h transhttp.Context, request *pb.ValidateTokenRequest, response *pb.ValidateTokenResponse) error { +func (s AuthServiceHookedBridge) CompleteValidateToken(h transhttp.Context, request *pb.ValidateTokenRequest, response *pb.ValidateTokenResponse) error { //TODO implement me panic("implement me") } diff --git a/internal/mods/auth/service/login.bridge.go b/internal/mods/auth/service/login.bridge.go index 713fecf6..28d6d521 100644 --- a/internal/mods/auth/service/login.bridge.go +++ b/internal/mods/auth/service/login.bridge.go @@ -23,28 +23,28 @@ type LoginServiceHookedBridge struct { log *log.KHelper } -func (s LoginServiceHookedBridge) CaptchaResult(h transhttp.Context, request *pb.CaptchaRequest, response *pb.CaptchaResponse) error { +func (s LoginServiceHookedBridge) CompleteCaptcha(h transhttp.Context, request *pb.CaptchaRequest, response *pb.CaptchaResponse) error { return h.JSON(http.StatusOK, &resp.Data{ Success: true, Data: resp.Proto2Any(response), }) } -func (s LoginServiceHookedBridge) CaptchaAudioResult(h transhttp.Context, request *pb.CaptchaAudioRequest, response *pb.CaptchaAudioResponse) error { +func (s LoginServiceHookedBridge) CompleteCaptchaAudio(h transhttp.Context, request *pb.CaptchaAudioRequest, response *pb.CaptchaAudioResponse) error { return h.JSON(http.StatusOK, &resp.Data{ Success: true, Data: resp.Proto2Any(response), }) } -func (s LoginServiceHookedBridge) CaptchaIdResult(h transhttp.Context, request *pb.CaptchaIdRequest, response *pb.CaptchaIdResponse) error { +func (s LoginServiceHookedBridge) CompleteCaptchaId(h transhttp.Context, request *pb.CaptchaIdRequest, response *pb.CaptchaIdResponse) error { return h.JSON(http.StatusOK, &resp.Data{ Success: true, Data: resp.Proto2Any(response), }) } -func (s LoginServiceHookedBridge) CaptchaImageResult(h transhttp.Context, request *pb.CaptchaImageRequest, response *pb.CaptchaImageResponse) error { +func (s LoginServiceHookedBridge) CompleteCaptchaImage(h transhttp.Context, request *pb.CaptchaImageRequest, response *pb.CaptchaImageResponse) error { s.log.Debugf("CaptchaImage: Setting headers: %+v", response.Headers) for k, v := range response.Headers { h.Response().Header().Set(k, v) @@ -60,37 +60,37 @@ func (s LoginServiceHookedBridge) CaptchaImageResult(h transhttp.Context, reques return nil } -func (s LoginServiceHookedBridge) BeforeLogin(h transhttp.Context, request *pb.LoginRequest) (context2.Context, error) { +func (s LoginServiceHookedBridge) PrepareLogin(h transhttp.Context, request *pb.LoginRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s LoginServiceHookedBridge) LoginResult(h transhttp.Context, request *pb.LoginRequest, response *pb.LoginResponse) error { +func (s LoginServiceHookedBridge) CompleteLogin(h transhttp.Context, request *pb.LoginRequest, response *pb.LoginResponse) error { //TODO implement me panic("implement me") } -func (s LoginServiceHookedBridge) BeforeLogout(h transhttp.Context, request *pb.LogoutRequest) (context2.Context, error) { +func (s LoginServiceHookedBridge) PrepareLogout(h transhttp.Context, request *pb.LogoutRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s LoginServiceHookedBridge) LogoutResult(h transhttp.Context, request *pb.LogoutRequest, response *pb.LogoutResponse) error { +func (s LoginServiceHookedBridge) CompleteLogout(h transhttp.Context, request *pb.LogoutRequest, response *pb.LogoutResponse) error { //TODO implement me panic("implement me") } -func (s LoginServiceHookedBridge) BeforeRegister(h transhttp.Context, request *pb.RegisterRequest) (context2.Context, error) { +func (s LoginServiceHookedBridge) PrepareRegister(h transhttp.Context, request *pb.RegisterRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s LoginServiceHookedBridge) RegisterResult(h transhttp.Context, request *pb.RegisterRequest, response *pb.RegisterResponse) error { +func (s LoginServiceHookedBridge) CompleteRegister(h transhttp.Context, request *pb.RegisterRequest, response *pb.RegisterResponse) error { //TODO implement me panic("implement me") } -func (s LoginServiceHookedBridge) TokenRefreshResult(h transhttp.Context, request *pb.TokenRefreshRequest, response *pb.TokenRefreshResponse) error { +func (s LoginServiceHookedBridge) CompleteTokenRefresh(h transhttp.Context, request *pb.TokenRefreshRequest, response *pb.TokenRefreshResponse) error { return h.JSON(http.StatusOK, &resp.Data{ Success: true, Data: resp.Proto2Any(resp.FromToken(response.Token)), diff --git a/internal/mods/system/dal/permission.dal.go b/internal/mods/system/dal/permission.dal.go index b2e05729..ebeb9958 100644 --- a/internal/mods/system/dal/permission.dal.go +++ b/internal/mods/system/dal/permission.dal.go @@ -125,7 +125,7 @@ func permissionPageQuery(ctx context.Context, query *ent.PermissionQuery, in *pb if err != nil { return nil, 0, err } - query = db.PaginationQuery(query, in, !in.NoPaging) + query = db.Query(query, in, !in.NoPaging) result, err := query.All(ctx) return dto.ConvertPermissions(result), int32(count), err } diff --git a/internal/mods/system/dal/resource.dal.go b/internal/mods/system/dal/resource.dal.go index 7048503e..86a69c22 100644 --- a/internal/mods/system/dal/resource.dal.go +++ b/internal/mods/system/dal/resource.dal.go @@ -129,7 +129,7 @@ func resourcePageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.Lis if err != nil { return nil, 0, err } - query = db.PaginationQuery(query, in, !in.NoPaging) + query = db.Query(query, in, !in.NoPaging) result, err := query.All(ctx) return dto.ConvertResources(result), int32(count), err } diff --git a/internal/mods/system/dal/role.dal.go b/internal/mods/system/dal/role.dal.go index 9ed8df41..843bfd61 100644 --- a/internal/mods/system/dal/role.dal.go +++ b/internal/mods/system/dal/role.dal.go @@ -149,7 +149,7 @@ func rolePageQuery(ctx context.Context, query *ent.RoleQuery, in *pb.ListRolesRe if err != nil { return nil, 0, err } - query = db.PaginationQuery(query, in, !in.NoPaging) + query = db.Query(query, in, !in.NoPaging) result, err := query.All(ctx) return dto.ConvertRoles(result), int32(count), err } diff --git a/internal/mods/system/dal/user.dal.go b/internal/mods/system/dal/user.dal.go index 4f9c1ba9..216df004 100644 --- a/internal/mods/system/dal/user.dal.go +++ b/internal/mods/system/dal/user.dal.go @@ -200,7 +200,7 @@ func userPageQuery(ctx context.Context, query *ent.UserQuery, in *pb.ListUsersRe if err != nil { return nil, 0, err } - query = db.PaginationQuery(query, in, !in.NoPaging) + query = db.Query(query, in, !in.NoPaging) result, err := query.All(ctx) return dto.ConvertUsers(result), int32(count), err } diff --git a/internal/mods/system/service/menu.bridge.go b/internal/mods/system/service/menu.bridge.go index df210d2f..68081e58 100644 --- a/internal/mods/system/service/menu.bridge.go +++ b/internal/mods/system/service/menu.bridge.go @@ -23,7 +23,7 @@ type MenuServiceHookedBridge struct { log *log.KHelper } -func (h MenuServiceHookedBridge) CreateMenuResult(ctx transhttp.Context, request *pb.CreateMenuRequest, response *pb.CreateMenuResponse) error { +func (h MenuServiceHookedBridge) CompleteCreateMenu(ctx transhttp.Context, request *pb.CreateMenuRequest, response *pb.CreateMenuResponse) error { marshal, err := json.Marshal(response.Menu) if err != nil { return err @@ -34,14 +34,14 @@ func (h MenuServiceHookedBridge) CreateMenuResult(ctx transhttp.Context, request }) } -func (h MenuServiceHookedBridge) DeleteMenuResult(ctx transhttp.Context, request *pb.DeleteMenuRequest, response *pb.DeleteMenuResponse) error { +func (h MenuServiceHookedBridge) CompleteDeleteMenu(ctx transhttp.Context, request *pb.DeleteMenuRequest, response *pb.DeleteMenuResponse) error { return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, Data: nil, }) } -func (h MenuServiceHookedBridge) GetMenuResult(ctx transhttp.Context, request *pb.GetMenuRequest, response *pb.GetMenuResponse) error { +func (h MenuServiceHookedBridge) CompleteGetMenu(ctx transhttp.Context, request *pb.GetMenuRequest, response *pb.GetMenuResponse) error { marshal, err := json.Marshal(response.Menu) if err != nil { return err @@ -52,7 +52,7 @@ func (h MenuServiceHookedBridge) GetMenuResult(ctx transhttp.Context, request *p }) } -func (h MenuServiceHookedBridge) ListMenusResult(ctx transhttp.Context, request *pb.ListMenusRequest, response *pb.ListMenusResponse) error { +func (h MenuServiceHookedBridge) CompleteListMenus(ctx transhttp.Context, request *pb.ListMenusRequest, response *pb.ListMenusResponse) error { marshal, err := json.Marshal(response.Menus) if err != nil { return err @@ -64,7 +64,7 @@ func (h MenuServiceHookedBridge) ListMenusResult(ctx transhttp.Context, request }) } -func (h MenuServiceHookedBridge) UpdateMenuResult(ctx transhttp.Context, request *pb.UpdateMenuRequest, response *pb.UpdateMenuResponse) error { +func (h MenuServiceHookedBridge) CompleteUpdateMenu(ctx transhttp.Context, request *pb.UpdateMenuRequest, response *pb.UpdateMenuResponse) error { marshal, err := json.Marshal(response.Menu) if err != nil { return err diff --git a/internal/mods/system/service/permission.bridge.go b/internal/mods/system/service/permission.bridge.go index 0cb7ec43..af32d102 100644 --- a/internal/mods/system/service/permission.bridge.go +++ b/internal/mods/system/service/permission.bridge.go @@ -23,7 +23,7 @@ type PermissionServiceHookedBridge struct { log *log.KHelper } -func (h PermissionServiceHookedBridge) CreatePermissionResult(ctx transhttp.Context, request *pb.CreatePermissionRequest, response *pb.CreatePermissionResponse) error { +func (h PermissionServiceHookedBridge) CompleteCreatePermission(ctx transhttp.Context, request *pb.CreatePermissionRequest, response *pb.CreatePermissionResponse) error { marshal, err := json.Marshal(response.Permission) if err != nil { return err @@ -34,14 +34,14 @@ func (h PermissionServiceHookedBridge) CreatePermissionResult(ctx transhttp.Cont }) } -func (h PermissionServiceHookedBridge) DeletePermissionResult(ctx transhttp.Context, request *pb.DeletePermissionRequest, response *pb.DeletePermissionResponse) error { +func (h PermissionServiceHookedBridge) CompleteDeletePermission(ctx transhttp.Context, request *pb.DeletePermissionRequest, response *pb.DeletePermissionResponse) error { return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, Data: nil, }) } -func (h PermissionServiceHookedBridge) GetPermissionResult(ctx transhttp.Context, request *pb.GetPermissionRequest, response *pb.GetPermissionResponse) error { +func (h PermissionServiceHookedBridge) CompleteGetPermission(ctx transhttp.Context, request *pb.GetPermissionRequest, response *pb.GetPermissionResponse) error { marshal, err := json.Marshal(response.Permission) if err != nil { return err @@ -52,7 +52,7 @@ func (h PermissionServiceHookedBridge) GetPermissionResult(ctx transhttp.Context }) } -func (h PermissionServiceHookedBridge) ListPermissionsResult(ctx transhttp.Context, request *pb.ListPermissionsRequest, response *pb.ListPermissionsResponse) error { +func (h PermissionServiceHookedBridge) CompleteListPermissions(ctx transhttp.Context, request *pb.ListPermissionsRequest, response *pb.ListPermissionsResponse) error { marshal, err := json.Marshal(response.Permissions) if err != nil { return err @@ -67,7 +67,7 @@ func (h PermissionServiceHookedBridge) ListPermissionsResult(ctx transhttp.Conte }) } -func (h PermissionServiceHookedBridge) UpdatePermissionResult(ctx transhttp.Context, request *pb.UpdatePermissionRequest, response *pb.UpdatePermissionResponse) error { +func (h PermissionServiceHookedBridge) CompleteUpdatePermission(ctx transhttp.Context, request *pb.UpdatePermissionRequest, response *pb.UpdatePermissionResponse) error { marshal, err := json.Marshal(response.Permission) if err != nil { return err diff --git a/internal/mods/system/service/personal.bridge.go b/internal/mods/system/service/personal.bridge.go index e74b61cc..7b8aa520 100644 --- a/internal/mods/system/service/personal.bridge.go +++ b/internal/mods/system/service/personal.bridge.go @@ -22,82 +22,82 @@ type PersonalServiceHookedBridge struct { log *log.KHelper } -func (p PersonalServiceHookedBridge) BeforeGetPersonalProfile(context transhttp.Context, request *pb.GetPersonalProfileRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareGetPersonalProfile(context transhttp.Context, request *pb.GetPersonalProfileRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) GetPersonalProfileResult(context transhttp.Context, request *pb.GetPersonalProfileRequest, response *pb.GetPersonalProfileResponse) error { +func (p PersonalServiceHookedBridge) CompleteGetPersonalProfile(context transhttp.Context, request *pb.GetPersonalProfileRequest, response *pb.GetPersonalProfileResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) BeforeListPersonalResources(context transhttp.Context, request *pb.ListPersonalResourcesRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareListPersonalResources(context transhttp.Context, request *pb.ListPersonalResourcesRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) ListPersonalResourcesResult(context transhttp.Context, request *pb.ListPersonalResourcesRequest, response *pb.ListPersonalResourcesResponse) error { +func (p PersonalServiceHookedBridge) CompleteListPersonalResources(context transhttp.Context, request *pb.ListPersonalResourcesRequest, response *pb.ListPersonalResourcesResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) BeforeListPersonalRoles(context transhttp.Context, request *pb.ListPersonalRolesRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareListPersonalRoles(context transhttp.Context, request *pb.ListPersonalRolesRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) ListPersonalRolesResult(context transhttp.Context, request *pb.ListPersonalRolesRequest, response *pb.ListPersonalRolesResponse) error { +func (p PersonalServiceHookedBridge) CompleteListPersonalRoles(context transhttp.Context, request *pb.ListPersonalRolesRequest, response *pb.ListPersonalRolesResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) BeforePersonalLogout(context transhttp.Context, request *pb.PersonalLogoutRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PreparePersonalLogout(context transhttp.Context, request *pb.PersonalLogoutRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) PersonalLogoutResult(context transhttp.Context, request *pb.PersonalLogoutRequest, response *pb.PersonalLogoutResponse) error { +func (p PersonalServiceHookedBridge) CompletePersonalLogout(context transhttp.Context, request *pb.PersonalLogoutRequest, response *pb.PersonalLogoutResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) BeforeRefreshPersonalToken(context transhttp.Context, request *pb.RefreshPersonalTokenRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareRefreshPersonalToken(context transhttp.Context, request *pb.RefreshPersonalTokenRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) RefreshPersonalTokenResult(context transhttp.Context, request *pb.RefreshPersonalTokenRequest, response *pb.RefreshPersonalTokenResponse) error { +func (p PersonalServiceHookedBridge) CompleteRefreshPersonalToken(context transhttp.Context, request *pb.RefreshPersonalTokenRequest, response *pb.RefreshPersonalTokenResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) BeforeUpdatePersonalPassword(context transhttp.Context, request *pb.UpdatePersonalPasswordRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareUpdatePersonalPassword(context transhttp.Context, request *pb.UpdatePersonalPasswordRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) UpdatePersonalPasswordResult(context transhttp.Context, request *pb.UpdatePersonalPasswordRequest, response *pb.UpdatePersonalPasswordResponse) error { +func (p PersonalServiceHookedBridge) CompleteUpdatePersonalPassword(context transhttp.Context, request *pb.UpdatePersonalPasswordRequest, response *pb.UpdatePersonalPasswordResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) BeforeUpdatePersonalProfile(context transhttp.Context, request *pb.UpdatePersonalProfileRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareUpdatePersonalProfile(context transhttp.Context, request *pb.UpdatePersonalProfileRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) UpdatePersonalProfileResult(context transhttp.Context, request *pb.UpdatePersonalProfileRequest, response *pb.UpdatePersonalProfileResponse) error { +func (p PersonalServiceHookedBridge) CompleteUpdatePersonalProfile(context transhttp.Context, request *pb.UpdatePersonalProfileRequest, response *pb.UpdatePersonalProfileResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) BeforeUpdatePersonalSetting(context transhttp.Context, request *pb.UpdatePersonalSettingRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareUpdatePersonalSetting(context transhttp.Context, request *pb.UpdatePersonalSettingRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) UpdatePersonalSettingResult(context transhttp.Context, request *pb.UpdatePersonalSettingRequest, response *pb.UpdatePersonalSettingResponse) error { +func (p PersonalServiceHookedBridge) CompleteUpdatePersonalSetting(context transhttp.Context, request *pb.UpdatePersonalSettingRequest, response *pb.UpdatePersonalSettingResponse) error { //TODO implement me panic("implement me") } diff --git a/internal/mods/system/service/resource.bridge.go b/internal/mods/system/service/resource.bridge.go index 9af701cd..34fafc99 100644 --- a/internal/mods/system/service/resource.bridge.go +++ b/internal/mods/system/service/resource.bridge.go @@ -23,7 +23,7 @@ type ResourceServiceHookedBridge struct { log *log.KHelper } -func (h ResourceServiceHookedBridge) CreateResourceResult(ctx transhttp.Context, request *pb.CreateResourceRequest, response *pb.CreateResourceResponse) error { +func (h ResourceServiceHookedBridge) CompleteCreateResource(ctx transhttp.Context, request *pb.CreateResourceRequest, response *pb.CreateResourceResponse) error { marshal, err := json.Marshal(response.Resource) if err != nil { return err @@ -34,14 +34,14 @@ func (h ResourceServiceHookedBridge) CreateResourceResult(ctx transhttp.Context, }) } -func (h ResourceServiceHookedBridge) DeleteResourceResult(ctx transhttp.Context, request *pb.DeleteResourceRequest, response *pb.DeleteResourceResponse) error { +func (h ResourceServiceHookedBridge) CompleteDeleteResource(ctx transhttp.Context, request *pb.DeleteResourceRequest, response *pb.DeleteResourceResponse) error { return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, Data: nil, }) } -func (h ResourceServiceHookedBridge) GetResourceResult(ctx transhttp.Context, request *pb.GetResourceRequest, response *pb.GetResourceResponse) error { +func (h ResourceServiceHookedBridge) CompleteGetResource(ctx transhttp.Context, request *pb.GetResourceRequest, response *pb.GetResourceResponse) error { marshal, err := json.Marshal(response.Resource) if err != nil { return err @@ -52,7 +52,7 @@ func (h ResourceServiceHookedBridge) GetResourceResult(ctx transhttp.Context, re }) } -func (h ResourceServiceHookedBridge) ListResourcesResult(ctx transhttp.Context, request *pb.ListResourcesRequest, response *pb.ListResourcesResponse) error { +func (h ResourceServiceHookedBridge) CompleteListResources(ctx transhttp.Context, request *pb.ListResourcesRequest, response *pb.ListResourcesResponse) error { marshal, err := json.Marshal(response.Resources) if err != nil { return err @@ -67,7 +67,7 @@ func (h ResourceServiceHookedBridge) ListResourcesResult(ctx transhttp.Context, }) } -func (h ResourceServiceHookedBridge) UpdateResourceResult(ctx transhttp.Context, request *pb.UpdateResourceRequest, response *pb.UpdateResourceResponse) error { +func (h ResourceServiceHookedBridge) CompleteUpdateResource(ctx transhttp.Context, request *pb.UpdateResourceRequest, response *pb.UpdateResourceResponse) error { marshal, err := json.Marshal(response.Resource) if err != nil { return err diff --git a/internal/mods/system/service/role.bridge.go b/internal/mods/system/service/role.bridge.go index 8aeca9ee..3bc2448d 100644 --- a/internal/mods/system/service/role.bridge.go +++ b/internal/mods/system/service/role.bridge.go @@ -23,7 +23,7 @@ type RoleServiceHookedBridge struct { log *log.KHelper } -func (h RoleServiceHookedBridge) CreateRoleResult(ctx transhttp.Context, request *pb.CreateRoleRequest, response *pb.CreateRoleResponse) error { +func (h RoleServiceHookedBridge) CompleteCreateRole(ctx transhttp.Context, request *pb.CreateRoleRequest, response *pb.CreateRoleResponse) error { marshal, err := json.Marshal(response.Role) if err != nil { return err @@ -34,14 +34,14 @@ func (h RoleServiceHookedBridge) CreateRoleResult(ctx transhttp.Context, request }) } -func (h RoleServiceHookedBridge) DeleteRoleResult(ctx transhttp.Context, request *pb.DeleteRoleRequest, response *pb.DeleteRoleResponse) error { +func (h RoleServiceHookedBridge) CompleteDeleteRole(ctx transhttp.Context, request *pb.DeleteRoleRequest, response *pb.DeleteRoleResponse) error { return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, Data: nil, }) } -func (h RoleServiceHookedBridge) GetRoleResult(ctx transhttp.Context, request *pb.GetRoleRequest, response *pb.GetRoleResponse) error { +func (h RoleServiceHookedBridge) CompleteGetRole(ctx transhttp.Context, request *pb.GetRoleRequest, response *pb.GetRoleResponse) error { marshal, err := json.Marshal(response.Role) if err != nil { return err @@ -52,7 +52,7 @@ func (h RoleServiceHookedBridge) GetRoleResult(ctx transhttp.Context, request *p }) } -func (h RoleServiceHookedBridge) ListRolesResult(ctx transhttp.Context, request *pb.ListRolesRequest, response *pb.ListRolesResponse) error { +func (h RoleServiceHookedBridge) CompleteListRoles(ctx transhttp.Context, request *pb.ListRolesRequest, response *pb.ListRolesResponse) error { marshal, err := json.Marshal(response.Roles) if err != nil { return err @@ -67,7 +67,7 @@ func (h RoleServiceHookedBridge) ListRolesResult(ctx transhttp.Context, request }) } -func (h RoleServiceHookedBridge) UpdateRoleResult(ctx transhttp.Context, request *pb.UpdateRoleRequest, response *pb.UpdateRoleResponse) error { +func (h RoleServiceHookedBridge) CompleteUpdateRole(ctx transhttp.Context, request *pb.UpdateRoleRequest, response *pb.UpdateRoleResponse) error { marshal, err := json.Marshal(response.Role) if err != nil { return err diff --git a/internal/mods/system/service/service.go b/internal/mods/system/service/service.go index 3ea2056d..97e15e62 100644 --- a/internal/mods/system/service/service.go +++ b/internal/mods/system/service/service.go @@ -17,17 +17,23 @@ import ( // ProviderSet is service providers. var ProviderSet = wire.NewSet( wire.Struct(new(RegisterServer), "*"), + NewResourceServiceBridge, NewResourceServiceServerPB, NewResourceServiceHTTPServerPB, + NewRoleServiceBridge, NewRoleServiceServerPB, NewRoleServiceHTTPServerPB, + NewUserServiceBridge, NewUserServiceServerPB, NewUserServiceHTTPServerPB, + NewPersonalServiceBridge, NewPersonalServiceServerPB, NewPersonalServiceHTTPServerPB, + NewPermissionServiceBridge, NewPermissionServiceServerPB, NewPermissionServiceHTTPServerPB, NewRegisterServer, + ) type RegisterServer struct { diff --git a/internal/mods/system/service/user.bridge.go b/internal/mods/system/service/user.bridge.go index 35e6f471..90a0e032 100644 --- a/internal/mods/system/service/user.bridge.go +++ b/internal/mods/system/service/user.bridge.go @@ -23,7 +23,7 @@ type UserServiceHookedBridge struct { log *log.KHelper } -func (h UserServiceHookedBridge) CreateUserResult(ctx transhttp.Context, request *pb.CreateUserRequest, response *pb.CreateUserResponse) error { +func (h UserServiceHookedBridge) CompleteCreateUser(ctx transhttp.Context, request *pb.CreateUserRequest, response *pb.CreateUserResponse) error { marshal, err := json.Marshal(response.User) if err != nil { return err @@ -34,14 +34,14 @@ func (h UserServiceHookedBridge) CreateUserResult(ctx transhttp.Context, request }) } -func (h UserServiceHookedBridge) DeleteUserResult(ctx transhttp.Context, request *pb.DeleteUserRequest, response *pb.DeleteUserResponse) error { +func (h UserServiceHookedBridge) CompleteDeleteUser(ctx transhttp.Context, request *pb.DeleteUserRequest, response *pb.DeleteUserResponse) error { return ctx.JSON(http.StatusOK, &resp.SourceData{ Success: true, Data: nil, }) } -func (h UserServiceHookedBridge) GetUserResult(ctx transhttp.Context, request *pb.GetUserRequest, response *pb.GetUserResponse) error { +func (h UserServiceHookedBridge) CompleteGetUser(ctx transhttp.Context, request *pb.GetUserRequest, response *pb.GetUserResponse) error { marshal, err := json.Marshal(response.User) if err != nil { return err @@ -52,7 +52,7 @@ func (h UserServiceHookedBridge) GetUserResult(ctx transhttp.Context, request *p }) } -func (h UserServiceHookedBridge) ListUsersResult(ctx transhttp.Context, request *pb.ListUsersRequest, response *pb.ListUsersResponse) error { +func (h UserServiceHookedBridge) CompleteListUsers(ctx transhttp.Context, request *pb.ListUsersRequest, response *pb.ListUsersResponse) error { marshal, err := json.Marshal(response.Users) if err != nil { return err @@ -67,7 +67,7 @@ func (h UserServiceHookedBridge) ListUsersResult(ctx transhttp.Context, request }) } -func (h UserServiceHookedBridge) UpdateUserResult(ctx transhttp.Context, request *pb.UpdateUserRequest, response *pb.UpdateUserResponse) error { +func (h UserServiceHookedBridge) CompleteUpdateUser(ctx transhttp.Context, request *pb.UpdateUserRequest, response *pb.UpdateUserResponse) error { marshal, err := json.Marshal(response.User) if err != nil { return err From df9771928aa804b079d639907fce1f7d18024bf1 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 10 Jun 2025 12:46:13 +0800 Subject: [PATCH 039/158] refactor(auth): update API routes and rename personal.proto - Update API routes for auth-related endpoints - Rename personal.proto from system to auth package - Adjust package and import statements in personal.proto - Add new error reason for token expiration --- Makefile | 3 +- api/v1/proto/auth/auth.proto | 8 +- api/v1/proto/{system => auth}/personal.proto | 24 +- api/v1/proto/types/error.proto | 2 +- api/v1/services/auth/auth.pb.go | 14 +- api/v1/services/auth/auth.pb.gw.go | 24 +- api/v1/services/auth/auth_bridge.pb.go | 8 +- api/v1/services/auth/auth_http.pb.go | 16 +- api/v1/services/system/personal.pb.go | 1074 -------- api/v1/services/system/personal.pb.gw.go | 594 ---- .../services/system/personal.pb.validate.go | 2390 ----------------- api/v1/services/system/personal_bridge.pb.go | 565 ---- api/v1/services/system/personal_grpc.pb.go | 407 --- api/v1/services/system/personal_http.pb.go | 350 --- cmd/auth/wire_gen.go | 7 +- cmd/internal/start/start.go | 17 +- cmd/internal/start/wire.go | 23 +- cmd/internal/start/wire_gen.go | 87 +- cmd/system/wire.go | 4 - cmd/system/wire_gen.go | 4 +- contrib/security/authn/jwt/jwt.go | 2 +- contrib/security/authz/casbin/casbin.go | 10 +- contrib/security/authz/casbin/option.go | 13 +- contrib/security/authz/casbin/update.go | 17 +- helpers/securityx/security.go | 17 +- internal/configs/bootstrap.pb.go | 16 +- internal/configs/bootstrap.pb.validate.go | 47 +- internal/configs/bootstrap.proto | 2 +- internal/configs/service.pb.go | 24 +- internal/configs/service.pb.validate.go | 34 + internal/configs/service.proto | 1 + internal/data/casbin-adapter.dal.go | 55 +- internal/loader/bootstrap_default.go | 91 +- internal/loader/file.go | 3 + internal/loader/load.go | 33 +- internal/loader/proxy.go | 191 +- internal/mods/auth/biz/biz.go | 1 + internal/mods/auth/biz/casbin.biz.go | 8 +- internal/mods/auth/biz/casbin_stream.biz.go | 103 + .../mods/{system => auth}/biz/personal.biz.go | 6 +- internal/mods/auth/dal/dal.go | 1 + .../mods/{system => auth}/dal/personal.dal.go | 126 +- internal/mods/auth/dto/login.go | 2 +- .../mods/{system => auth}/dto/personal.go | 4 +- internal/mods/auth/server/server.go | 3 +- internal/mods/auth/service/auth.bridge.go | 8 + internal/mods/auth/service/casbin.bridge.go | 209 ++ internal/mods/auth/service/casbin.go | 117 + internal/mods/auth/service/casbin.grpc.go | 4 +- internal/mods/auth/service/casbin.http.go | 1 - internal/mods/auth/service/login.bridge.go | 8 + .../service/personal.bridge.go | 20 +- .../{system => auth}/service/personal.grpc.go | 4 +- .../{system => auth}/service/personal.http.go | 2 +- internal/mods/auth/service/service.go | 40 +- internal/mods/system/server/server.go | 3 +- internal/mods/system/service/menu.bridge.go | 8 + .../mods/system/service/permission.bridge.go | 8 + .../mods/system/service/resource.bridge.go | 8 + internal/mods/system/service/role.bridge.go | 8 + internal/mods/system/service/service.go | 23 +- internal/mods/system/service/user.bridge.go | 8 + internal/mods/system/service/user.http.go | 28 +- internal/mods/system/service/user.service.go | 25 + resources/configs/admin/bootstrap.toml | 106 + resources/configs/admin/clients.toml | 465 ++++ resources/configs/admin/security.toml | 22 + resources/configs/admin/service.toml | 213 -- resources/configs/admin/storage.toml | 4 +- resources/docs/openapi/openapi.yaml | 1222 ++++----- test/token_test.go | 2 +- 71 files changed, 2398 insertions(+), 6599 deletions(-) rename api/v1/proto/{system => auth}/personal.proto (87%) delete mode 100644 api/v1/services/system/personal.pb.go delete mode 100644 api/v1/services/system/personal.pb.gw.go delete mode 100644 api/v1/services/system/personal.pb.validate.go delete mode 100644 api/v1/services/system/personal_bridge.pb.go delete mode 100644 api/v1/services/system/personal_grpc.pb.go delete mode 100644 api/v1/services/system/personal_http.pb.go create mode 100644 internal/mods/auth/biz/casbin_stream.biz.go rename internal/mods/{system => auth}/biz/personal.biz.go (92%) rename internal/mods/{system => auth}/dal/personal.dal.go (55%) rename internal/mods/{system => auth}/dto/personal.go (84%) create mode 100644 internal/mods/auth/service/casbin.bridge.go create mode 100644 internal/mods/auth/service/casbin.go rename internal/mods/{system => auth}/service/personal.bridge.go (89%) rename internal/mods/{system => auth}/service/personal.grpc.go (95%) rename internal/mods/{system => auth}/service/personal.http.go (97%) create mode 100644 internal/mods/system/service/user.service.go create mode 100644 resources/configs/admin/clients.toml delete mode 100644 resources/configs/admin/service.toml diff --git a/Makefile b/Makefile index d8db61dd..c115c68a 100644 --- a/Makefile +++ b/Makefile @@ -186,8 +186,9 @@ gen: go generate ./internal/generate.go - go generate ./internal/mods/system/dal/entity/ent/generate.go + go generate ./internal/data/entity/ent/generate.go go generate ./cmd/system + go generate ./cmd/auth go generate ./cmd/internal/start diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index 17fec1d5..b0aaaea0 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -20,7 +20,7 @@ service AuthService { // CreateToken generates a new JWT token for the given user. rpc CreateToken(CreateTokenRequest) returns (CreateTokenResponse) { option (google.api.http) = { - post: "/sys/auth/token" + post: "/auth/token" body: "data" }; } @@ -33,7 +33,7 @@ service AuthService { // DestroyToken invalidates a JWT token. rpc DestroyToken(DestroyTokenRequest) returns (DestroyTokenResponse) { option (google.api.http) = { - post: "/sys/auth/destroy" + post: "/auth/destroy" body: "data" }; } @@ -41,7 +41,7 @@ service AuthService { // Authenticate authenticates a user. rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) { option (google.api.http) = { - post: "/sys/auth/authenticate" + post: "/auth/authenticate" body: "data" }; } @@ -49,7 +49,7 @@ service AuthService { // AuthLogout logs out a user. rpc AuthLogout(AuthLogoutRequest) returns (AuthLogoutResponse) { option (google.api.http) = { - post: "/sys/auth/logout" + post: "/auth/logout" body: "data" }; } diff --git a/api/v1/proto/system/personal.proto b/api/v1/proto/auth/personal.proto similarity index 87% rename from api/v1/proto/system/personal.proto rename to api/v1/proto/auth/personal.proto index ef523f78..54c61082 100644 --- a/api/v1/proto/system/personal.proto +++ b/api/v1/proto/auth/personal.proto @@ -1,63 +1,63 @@ syntax = "proto3"; -package api.v1.services.system; +package api.v1.services.auth; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "types/system.proto"; import "validate/validate.proto"; -option go_package = "api/v1/services/system;system"; +option go_package = "api/v1/services/auth;auth"; option java_multiple_files = true; -option java_outer_classname = "APIV1ServicesSystemPersonalProto"; -option java_package = "com.origadmin.api.v1.services.system"; +option java_outer_classname = "APIV1ServicesAuthPersonalProto"; +option java_package = "com.origadmin.api.v1.services.auth"; // PersonalService Personal user service service PersonalService { // GetPersonalProfile Update the personal user information rpc GetPersonalProfile(GetPersonalProfileRequest) returns (GetPersonalProfileResponse) { - option (google.api.http) = {get: "/sys/personal/profile"}; + option (google.api.http) = {get: "/auth/personal/profile"}; } // ListPersonalResources List the personal user's menu rpc ListPersonalResources(ListPersonalResourcesRequest) returns (ListPersonalResourcesResponse) { - option (google.api.http) = {get: "/sys/personal/resources"}; + option (google.api.http) = {get: "/auth/personal/resources"}; } // ListPersonalResources List the personal user's menu rpc ListPersonalRoles(ListPersonalRolesRequest) returns (ListPersonalRolesResponse) { - option (google.api.http) = {get: "/sys/personal/roles"}; + option (google.api.http) = {get: "/auth/personal/roles"}; } // PersonalLogout Personal user logs out rpc PersonalLogout(PersonalLogoutRequest) returns (PersonalLogoutResponse) { option (google.api.http) = { - post: "/sys/personal/logout" + post: "/auth/personal/logout" body: "data" }; } // RefreshPersonalToken Refresh the personal user's token rpc RefreshPersonalToken(RefreshPersonalTokenRequest) returns (RefreshPersonalTokenResponse) { option (google.api.http) = { - post: "/sys/personal/token/refresh" + post: "/auth/personal/token/refresh" body: "data" }; } // UpdatePersonalProfilePassword The user changes the password rpc UpdatePersonalPassword(UpdatePersonalPasswordRequest) returns (UpdatePersonalPasswordResponse) { option (google.api.http) = { - put: "/sys/personal/password" + put: "/auth/personal/password" body: "data" }; } // UpdatePersonalProfile Update the personal user information rpc UpdatePersonalProfile(UpdatePersonalProfileRequest) returns (UpdatePersonalProfileResponse) { option (google.api.http) = { - put: "/sys/personal/profile" + put: "/auth/personal/profile" body: "data" }; } // UpdatePersonalSetting User settings are saved rpc UpdatePersonalSetting(UpdatePersonalSettingRequest) returns (UpdatePersonalSettingResponse) { option (google.api.http) = { - put: "/sys/personal/setting" + put: "/auth/personal/setting" body: "data" }; } diff --git a/api/v1/proto/types/error.proto b/api/v1/proto/types/error.proto index 2100cadd..b30a922d 100644 --- a/api/v1/proto/types/error.proto +++ b/api/v1/proto/types/error.proto @@ -38,5 +38,5 @@ enum AuthErrorReason { option (errors.default_code) = 500; AUTH_ERROR_REASON_UNSPECIFIED = 0; AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND = 2001 [(errors.code) = 404]; + AUTH_ERROR_REASON_TOKEN_EXPIRED = 2002 [(errors.code) = 401]; } - diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index 2a3269a1..77ec7420 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -864,15 +864,15 @@ const file_auth_auth_proto_rawDesc = "" + "\x06method\x18\x04 \x01(\tR\x06method\x12\x1c\n" + "\toperation\x18\x05 \x01(\tR\toperation\"2\n" + "\x14AuthenticateResponse\x12\x1a\n" + - "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xc4\x06\n" + + "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xb3\x06\n" + "\vAuthService\x12\x91\x01\n" + - "\x11ListAuthResources\x12..api.v1.services.auth.ListAuthResourcesRequest\x1a/.api.v1.services.auth.ListAuthResourcesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/auth/resources\x12\x81\x01\n" + - "\vCreateToken\x12(.api.v1.services.auth.CreateTokenRequest\x1a).api.v1.services.auth.CreateTokenResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x04data\"\x0f/sys/auth/token\x12\x84\x01\n" + - "\rValidateToken\x12*.api.v1.services.auth.ValidateTokenRequest\x1a+.api.v1.services.auth.ValidateTokenResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/sys/auth/validate\x12\x86\x01\n" + - "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x04data\"\x11/sys/auth/destroy\x12\x8b\x01\n" + - "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\"\x16/sys/auth/authenticate\x12\x7f\n" + + "\x11ListAuthResources\x12..api.v1.services.auth.ListAuthResourcesRequest\x1a/.api.v1.services.auth.ListAuthResourcesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/auth/resources\x12}\n" + + "\vCreateToken\x12(.api.v1.services.auth.CreateTokenRequest\x1a).api.v1.services.auth.CreateTokenResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x04data\"\v/auth/token\x12\x84\x01\n" + + "\rValidateToken\x12*.api.v1.services.auth.ValidateTokenRequest\x1a+.api.v1.services.auth.ValidateTokenResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/sys/auth/validate\x12\x82\x01\n" + + "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x04data\"\r/auth/destroy\x12\x87\x01\n" + + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\" \x82\xd3\xe4\x93\x02\x1a:\x04data\"\x12/auth/authenticate\x12{\n" + "\n" + - "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x04data\"\x10/sys/auth/logoutB\xb4\x01\n" + + "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x04data\"\f/auth/logoutB\xb4\x01\n" + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( diff --git a/api/v1/services/auth/auth.pb.gw.go b/api/v1/services/auth/auth.pb.gw.go index 086ad8fe..cbb5f3ff 100644 --- a/api/v1/services/auth/auth.pb.gw.go +++ b/api/v1/services/auth/auth.pb.gw.go @@ -229,7 +229,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/sys/auth/token")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/auth/token")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -269,7 +269,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/sys/auth/destroy")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/auth/destroy")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -289,7 +289,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/sys/auth/authenticate")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/auth/authenticate")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -309,7 +309,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/sys/auth/logout")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/auth/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -384,7 +384,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/sys/auth/token")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/auth/token")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -418,7 +418,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/sys/auth/destroy")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/auth/destroy")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -435,7 +435,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/sys/auth/authenticate")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/auth/authenticate")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -452,7 +452,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/sys/auth/logout")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/auth/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -470,11 +470,11 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux var ( pattern_AuthService_ListAuthResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "auth", "resources"}, "")) - pattern_AuthService_CreateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "auth", "token"}, "")) + pattern_AuthService_CreateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "token"}, "")) pattern_AuthService_ValidateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "auth", "validate"}, "")) - pattern_AuthService_DestroyToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "auth", "destroy"}, "")) - pattern_AuthService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "auth", "authenticate"}, "")) - pattern_AuthService_AuthLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "auth", "logout"}, "")) + pattern_AuthService_DestroyToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "destroy"}, "")) + pattern_AuthService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "authenticate"}, "")) + pattern_AuthService_AuthLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "logout"}, "")) ) var ( diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index b63f2642..026606f1 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -91,11 +91,11 @@ type AuthServiceValidateTokenHooker interface { func RegisterAuthServiceBridger(s *http.Server, srv AuthServiceHookedBridger) { r := s.Route("/") r.GET("/sys/auth/resources", _AuthService_ListAuthResources0_Bridge_Handler(srv)) - r.POST("/sys/auth/token", _AuthService_CreateToken0_Bridge_Handler(srv)) + r.POST("/auth/token", _AuthService_CreateToken0_Bridge_Handler(srv)) r.GET("/sys/auth/validate", _AuthService_ValidateToken0_Bridge_Handler(srv)) - r.POST("/sys/auth/destroy", _AuthService_DestroyToken0_Bridge_Handler(srv)) - r.POST("/sys/auth/authenticate", _AuthService_Authenticate0_Bridge_Handler(srv)) - r.POST("/sys/auth/logout", _AuthService_AuthLogout0_Bridge_Handler(srv)) + r.POST("/auth/destroy", _AuthService_DestroyToken0_Bridge_Handler(srv)) + r.POST("/auth/authenticate", _AuthService_Authenticate0_Bridge_Handler(srv)) + r.POST("/auth/logout", _AuthService_AuthLogout0_Bridge_Handler(srv)) } func _AuthService_ListAuthResources0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go index 96f13b45..61e24494 100644 --- a/api/v1/services/auth/auth_http.pb.go +++ b/api/v1/services/auth/auth_http.pb.go @@ -44,11 +44,11 @@ type AuthServiceHTTPServer interface { func RegisterAuthServiceHTTPServer(s *http.Server, srv AuthServiceHTTPServer) { r := s.Route("/") r.GET("/sys/auth/resources", _AuthService_ListAuthResources0_HTTP_Handler(srv)) - r.POST("/sys/auth/token", _AuthService_CreateToken0_HTTP_Handler(srv)) + r.POST("/auth/token", _AuthService_CreateToken0_HTTP_Handler(srv)) r.GET("/sys/auth/validate", _AuthService_ValidateToken0_HTTP_Handler(srv)) - r.POST("/sys/auth/destroy", _AuthService_DestroyToken0_HTTP_Handler(srv)) - r.POST("/sys/auth/authenticate", _AuthService_Authenticate0_HTTP_Handler(srv)) - r.POST("/sys/auth/logout", _AuthService_AuthLogout0_HTTP_Handler(srv)) + r.POST("/auth/destroy", _AuthService_DestroyToken0_HTTP_Handler(srv)) + r.POST("/auth/authenticate", _AuthService_Authenticate0_HTTP_Handler(srv)) + r.POST("/auth/logout", _AuthService_AuthLogout0_HTTP_Handler(srv)) } func _AuthService_ListAuthResources0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { @@ -196,7 +196,7 @@ func NewAuthServiceHTTPClient(client *http.Client) AuthServiceHTTPClient { func (c *AuthServiceHTTPClientImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...http.CallOption) (*AuthLogoutResponse, error) { var out AuthLogoutResponse - pattern := "/sys/auth/logout" + pattern := "/auth/logout" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationAuthServiceAuthLogout)) opts = append(opts, http.PathTemplate(pattern)) @@ -209,7 +209,7 @@ func (c *AuthServiceHTTPClientImpl) AuthLogout(ctx context.Context, in *AuthLogo func (c *AuthServiceHTTPClientImpl) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...http.CallOption) (*AuthenticateResponse, error) { var out AuthenticateResponse - pattern := "/sys/auth/authenticate" + pattern := "/auth/authenticate" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationAuthServiceAuthenticate)) opts = append(opts, http.PathTemplate(pattern)) @@ -222,7 +222,7 @@ func (c *AuthServiceHTTPClientImpl) Authenticate(ctx context.Context, in *Authen func (c *AuthServiceHTTPClientImpl) CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...http.CallOption) (*CreateTokenResponse, error) { var out CreateTokenResponse - pattern := "/sys/auth/token" + pattern := "/auth/token" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationAuthServiceCreateToken)) opts = append(opts, http.PathTemplate(pattern)) @@ -235,7 +235,7 @@ func (c *AuthServiceHTTPClientImpl) CreateToken(ctx context.Context, in *CreateT func (c *AuthServiceHTTPClientImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...http.CallOption) (*DestroyTokenResponse, error) { var out DestroyTokenResponse - pattern := "/sys/auth/destroy" + pattern := "/auth/destroy" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationAuthServiceDestroyToken)) opts = append(opts, http.PathTemplate(pattern)) diff --git a/api/v1/services/system/personal.pb.go b/api/v1/services/system/personal.pb.go deleted file mode 100644 index edaac956..00000000 --- a/api/v1/services/system/personal.pb.go +++ /dev/null @@ -1,1074 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc (unknown) -// source: system/personal.proto - -package system - -import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type UpdatePersonalSettingRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalSettingRequest) Reset() { - *x = UpdatePersonalSettingRequest{} - mi := &file_system_personal_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalSettingRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalSettingRequest) ProtoMessage() {} - -func (x *UpdatePersonalSettingRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[0] - 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 UpdatePersonalSettingRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalSettingRequest) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{0} -} - -func (x *UpdatePersonalSettingRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalSettingResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalSettingResponse) Reset() { - *x = UpdatePersonalSettingResponse{} - mi := &file_system_personal_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalSettingResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalSettingResponse) ProtoMessage() {} - -func (x *UpdatePersonalSettingResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[1] - 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 UpdatePersonalSettingResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalSettingResponse) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{1} -} - -type UpdatePersonalRoleRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalRoleRequest) Reset() { - *x = UpdatePersonalRoleRequest{} - mi := &file_system_personal_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalRoleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalRoleRequest) ProtoMessage() {} - -func (x *UpdatePersonalRoleRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[2] - 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 UpdatePersonalRoleRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalRoleRequest) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{2} -} - -func (x *UpdatePersonalRoleRequest) GetRole() *types.Role { - if x != nil { - return x.Role - } - return nil -} - -type UpdatePersonalRoleResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalRoleResponse) Reset() { - *x = UpdatePersonalRoleResponse{} - mi := &file_system_personal_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalRoleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalRoleResponse) ProtoMessage() {} - -func (x *UpdatePersonalRoleResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[3] - 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 UpdatePersonalRoleResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalRoleResponse) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{3} -} - -type ListPersonalResourcesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalResourcesRequest) Reset() { - *x = ListPersonalResourcesRequest{} - mi := &file_system_personal_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalResourcesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalResourcesRequest) ProtoMessage() {} - -func (x *ListPersonalResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[4] - 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 ListPersonalResourcesRequest.ProtoReflect.Descriptor instead. -func (*ListPersonalResourcesRequest) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{4} -} - -func (x *ListPersonalResourcesRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListPersonalResourcesRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListPersonalResourcesRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -type ListPersonalResourcesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int64 `protobuf:"varint,1,opt,name=total_size,json=total,proto3" json:"total_size,omitempty"` - // list of resources - Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalResourcesResponse) Reset() { - *x = ListPersonalResourcesResponse{} - mi := &file_system_personal_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalResourcesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalResourcesResponse) ProtoMessage() {} - -func (x *ListPersonalResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[5] - 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 ListPersonalResourcesResponse.ProtoReflect.Descriptor instead. -func (*ListPersonalResourcesResponse) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{5} -} - -func (x *ListPersonalResourcesResponse) GetTotalSize() int64 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListPersonalResourcesResponse) GetResources() []*types.Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *ListPersonalResourcesResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -type UpdatePersonalPasswordRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalPasswordRequest) Reset() { - *x = UpdatePersonalPasswordRequest{} - mi := &file_system_personal_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalPasswordRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalPasswordRequest) ProtoMessage() {} - -func (x *UpdatePersonalPasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_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 UpdatePersonalPasswordRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalPasswordRequest) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdatePersonalPasswordRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalPasswordResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalPasswordResponse) Reset() { - *x = UpdatePersonalPasswordResponse{} - mi := &file_system_personal_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalPasswordResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalPasswordResponse) ProtoMessage() {} - -func (x *UpdatePersonalPasswordResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdatePersonalPasswordResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalPasswordResponse) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{7} -} - -type PersonalPasswordRestRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalPasswordRestRequest) Reset() { - *x = PersonalPasswordRestRequest{} - mi := &file_system_personal_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalPasswordRestRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalPasswordRestRequest) ProtoMessage() {} - -func (x *PersonalPasswordRestRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[8] - 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 PersonalPasswordRestRequest.ProtoReflect.Descriptor instead. -func (*PersonalPasswordRestRequest) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{8} -} - -func (x *PersonalPasswordRestRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type PersonalPasswordRestResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalPasswordRestResponse) Reset() { - *x = PersonalPasswordRestResponse{} - mi := &file_system_personal_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalPasswordRestResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalPasswordRestResponse) ProtoMessage() {} - -func (x *PersonalPasswordRestResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[9] - 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 PersonalPasswordRestResponse.ProtoReflect.Descriptor instead. -func (*PersonalPasswordRestResponse) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{9} -} - -type UpdatePersonalProfileRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalProfileRequest) Reset() { - *x = UpdatePersonalProfileRequest{} - mi := &file_system_personal_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalProfileRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalProfileRequest) ProtoMessage() {} - -func (x *UpdatePersonalProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[10] - 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 UpdatePersonalProfileRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalProfileRequest) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{10} -} - -func (x *UpdatePersonalProfileRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalProfileResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalProfileResponse) Reset() { - *x = UpdatePersonalProfileResponse{} - mi := &file_system_personal_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalProfileResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalProfileResponse) ProtoMessage() {} - -func (x *UpdatePersonalProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[11] - 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 UpdatePersonalProfileResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalProfileResponse) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{11} -} - -type PersonalLogoutRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalLogoutRequest) Reset() { - *x = PersonalLogoutRequest{} - mi := &file_system_personal_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalLogoutRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalLogoutRequest) ProtoMessage() {} - -func (x *PersonalLogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[12] - 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 PersonalLogoutRequest.ProtoReflect.Descriptor instead. -func (*PersonalLogoutRequest) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{12} -} - -func (x *PersonalLogoutRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type PersonalLogoutResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalLogoutResponse) Reset() { - *x = PersonalLogoutResponse{} - mi := &file_system_personal_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalLogoutResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalLogoutResponse) ProtoMessage() {} - -func (x *PersonalLogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[13] - 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 PersonalLogoutResponse.ProtoReflect.Descriptor instead. -func (*PersonalLogoutResponse) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{13} -} - -func (x *PersonalLogoutResponse) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -type ListPersonalRolesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalRolesRequest) Reset() { - *x = ListPersonalRolesRequest{} - mi := &file_system_personal_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalRolesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalRolesRequest) ProtoMessage() {} - -func (x *ListPersonalRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[14] - 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 ListPersonalRolesRequest.ProtoReflect.Descriptor instead. -func (*ListPersonalRolesRequest) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{14} -} - -type ListPersonalRolesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Roles []*types.Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalRolesResponse) Reset() { - *x = ListPersonalRolesResponse{} - mi := &file_system_personal_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalRolesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalRolesResponse) ProtoMessage() {} - -func (x *ListPersonalRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[15] - 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 ListPersonalRolesResponse.ProtoReflect.Descriptor instead. -func (*ListPersonalRolesResponse) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{15} -} - -func (x *ListPersonalRolesResponse) GetRoles() []*types.Role { - if x != nil { - return x.Roles - } - return nil -} - -type GetPersonalProfileRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPersonalProfileRequest) Reset() { - *x = GetPersonalProfileRequest{} - mi := &file_system_personal_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPersonalProfileRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPersonalProfileRequest) ProtoMessage() {} - -func (x *GetPersonalProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[16] - 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 GetPersonalProfileRequest.ProtoReflect.Descriptor instead. -func (*GetPersonalProfileRequest) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{16} -} - -type GetPersonalProfileResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPersonalProfileResponse) Reset() { - *x = GetPersonalProfileResponse{} - mi := &file_system_personal_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPersonalProfileResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPersonalProfileResponse) ProtoMessage() {} - -func (x *GetPersonalProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[17] - 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 GetPersonalProfileResponse.ProtoReflect.Descriptor instead. -func (*GetPersonalProfileResponse) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{17} -} - -func (x *GetPersonalProfileResponse) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -type RefreshPersonalTokenRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RefreshPersonalTokenRequest) Reset() { - *x = RefreshPersonalTokenRequest{} - mi := &file_system_personal_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RefreshPersonalTokenRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RefreshPersonalTokenRequest) ProtoMessage() {} - -func (x *RefreshPersonalTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[18] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RefreshPersonalTokenRequest.ProtoReflect.Descriptor instead. -func (*RefreshPersonalTokenRequest) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{18} -} - -func (x *RefreshPersonalTokenRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type RefreshPersonalTokenResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RefreshPersonalTokenResponse) Reset() { - *x = RefreshPersonalTokenResponse{} - mi := &file_system_personal_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RefreshPersonalTokenResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RefreshPersonalTokenResponse) ProtoMessage() {} - -func (x *RefreshPersonalTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_personal_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RefreshPersonalTokenResponse.ProtoReflect.Descriptor instead. -func (*RefreshPersonalTokenResponse) Descriptor() ([]byte, []int) { - return file_system_personal_proto_rawDescGZIP(), []int{19} -} - -func (x *RefreshPersonalTokenResponse) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -var File_system_personal_proto protoreflect.FileDescriptor - -const file_system_personal_proto_rawDesc = "" + - "\n" + - "\x15system/personal.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12types/system.proto\x1a\x17validate/validate.proto\"H\n" + - "\x1cUpdatePersonalSettingRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + - "\x1dUpdatePersonalSettingResponse\"L\n" + - "\x19UpdatePersonalRoleRequest\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\x1c\n" + - "\x1aUpdatePersonalRoleResponse\"\xc4\x01\n" + - "\x1cListPersonalResourcesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\xa3\x01\n" + - "\x1dListPersonalResourcesResponse\x12\x19\n" + - "\n" + - "total_size\x18\x01 \x01(\x03R\x05total\x12=\n" + - "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\"I\n" + - "\x1dUpdatePersonalPasswordRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\" \n" + - "\x1eUpdatePersonalPasswordResponse\"6\n" + - "\x1bPersonalPasswordRestRequest\x12\x17\n" + - "\x02id\x18\x01 \x01(\x03B\a\xfaB\x04\"\x02 \x00R\x02id\"\x1e\n" + - "\x1cPersonalPasswordRestResponse\"H\n" + - "\x1cUpdatePersonalProfileRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + - "\x1dUpdatePersonalProfileResponse\"A\n" + - "\x15PersonalLogoutRequest\x12(\n" + - "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"2\n" + - "\x16PersonalLogoutResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\"\x1a\n" + - "\x18ListPersonalRolesRequest\"N\n" + - "\x19ListPersonalRolesResponse\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x1b\n" + - "\x19GetPersonalProfileRequest\"M\n" + - "\x1aGetPersonalProfileResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + - "\x1bRefreshPersonalTokenRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"4\n" + - "\x1cRefreshPersonalTokenResponse\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token2\xbb\n" + - "\n" + - "\x0fPersonalService\x12\x9a\x01\n" + - "\x12GetPersonalProfile\x121.api.v1.services.system.GetPersonalProfileRequest\x1a2.api.v1.services.system.GetPersonalProfileResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/personal/profile\x12\xa5\x01\n" + - "\x15ListPersonalResources\x124.api.v1.services.system.ListPersonalResourcesRequest\x1a5.api.v1.services.system.ListPersonalResourcesResponse\"\x1f\x82\xd3\xe4\x93\x02\x19\x12\x17/sys/personal/resources\x12\x95\x01\n" + - "\x11ListPersonalRoles\x120.api.v1.services.system.ListPersonalRolesRequest\x1a1.api.v1.services.system.ListPersonalRolesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/personal/roles\x12\x93\x01\n" + - "\x0ePersonalLogout\x12-.api.v1.services.system.PersonalLogoutRequest\x1a..api.v1.services.system.PersonalLogoutResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04data\"\x14/sys/personal/logout\x12\xac\x01\n" + - "\x14RefreshPersonalToken\x123.api.v1.services.system.RefreshPersonalTokenRequest\x1a4.api.v1.services.system.RefreshPersonalTokenResponse\")\x82\xd3\xe4\x93\x02#:\x04data\"\x1b/sys/personal/token/refresh\x12\xad\x01\n" + - "\x16UpdatePersonalPassword\x125.api.v1.services.system.UpdatePersonalPasswordRequest\x1a6.api.v1.services.system.UpdatePersonalPasswordResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/sys/personal/password\x12\xa9\x01\n" + - "\x15UpdatePersonalProfile\x124.api.v1.services.system.UpdatePersonalProfileRequest\x1a5.api.v1.services.system.UpdatePersonalProfileResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\x1a\x15/sys/personal/profile\x12\xa9\x01\n" + - "\x15UpdatePersonalSetting\x124.api.v1.services.system.UpdatePersonalSettingRequest\x1a5.api.v1.services.system.UpdatePersonalSettingResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\x1a\x15/sys/personal/settingB\xc6\x01\n" + - "\x1acom.api.v1.services.systemB\rPersonalProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_personal_proto_rawDescOnce sync.Once - file_system_personal_proto_rawDescData []byte -) - -func file_system_personal_proto_rawDescGZIP() []byte { - file_system_personal_proto_rawDescOnce.Do(func() { - file_system_personal_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_personal_proto_rawDesc), len(file_system_personal_proto_rawDesc))) - }) - return file_system_personal_proto_rawDescData -} - -var file_system_personal_proto_msgTypes = make([]protoimpl.MessageInfo, 20) -var file_system_personal_proto_goTypes = []any{ - (*UpdatePersonalSettingRequest)(nil), // 0: api.v1.services.system.UpdatePersonalSettingRequest - (*UpdatePersonalSettingResponse)(nil), // 1: api.v1.services.system.UpdatePersonalSettingResponse - (*UpdatePersonalRoleRequest)(nil), // 2: api.v1.services.system.UpdatePersonalRoleRequest - (*UpdatePersonalRoleResponse)(nil), // 3: api.v1.services.system.UpdatePersonalRoleResponse - (*ListPersonalResourcesRequest)(nil), // 4: api.v1.services.system.ListPersonalResourcesRequest - (*ListPersonalResourcesResponse)(nil), // 5: api.v1.services.system.ListPersonalResourcesResponse - (*UpdatePersonalPasswordRequest)(nil), // 6: api.v1.services.system.UpdatePersonalPasswordRequest - (*UpdatePersonalPasswordResponse)(nil), // 7: api.v1.services.system.UpdatePersonalPasswordResponse - (*PersonalPasswordRestRequest)(nil), // 8: api.v1.services.system.PersonalPasswordRestRequest - (*PersonalPasswordRestResponse)(nil), // 9: api.v1.services.system.PersonalPasswordRestResponse - (*UpdatePersonalProfileRequest)(nil), // 10: api.v1.services.system.UpdatePersonalProfileRequest - (*UpdatePersonalProfileResponse)(nil), // 11: api.v1.services.system.UpdatePersonalProfileResponse - (*PersonalLogoutRequest)(nil), // 12: api.v1.services.system.PersonalLogoutRequest - (*PersonalLogoutResponse)(nil), // 13: api.v1.services.system.PersonalLogoutResponse - (*ListPersonalRolesRequest)(nil), // 14: api.v1.services.system.ListPersonalRolesRequest - (*ListPersonalRolesResponse)(nil), // 15: api.v1.services.system.ListPersonalRolesResponse - (*GetPersonalProfileRequest)(nil), // 16: api.v1.services.system.GetPersonalProfileRequest - (*GetPersonalProfileResponse)(nil), // 17: api.v1.services.system.GetPersonalProfileResponse - (*RefreshPersonalTokenRequest)(nil), // 18: api.v1.services.system.RefreshPersonalTokenRequest - (*RefreshPersonalTokenResponse)(nil), // 19: api.v1.services.system.RefreshPersonalTokenResponse - (*anypb.Any)(nil), // 20: google.protobuf.Any - (*types.Role)(nil), // 21: api.v1.services.types.Role - (*types.Resource)(nil), // 22: api.v1.services.types.Resource - (*types.User)(nil), // 23: api.v1.services.types.User -} -var file_system_personal_proto_depIdxs = []int32{ - 20, // 0: api.v1.services.system.UpdatePersonalSettingRequest.data:type_name -> google.protobuf.Any - 21, // 1: api.v1.services.system.UpdatePersonalRoleRequest.role:type_name -> api.v1.services.types.Role - 22, // 2: api.v1.services.system.ListPersonalResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 20, // 3: api.v1.services.system.UpdatePersonalPasswordRequest.data:type_name -> google.protobuf.Any - 20, // 4: api.v1.services.system.UpdatePersonalProfileRequest.data:type_name -> google.protobuf.Any - 20, // 5: api.v1.services.system.PersonalLogoutRequest.data:type_name -> google.protobuf.Any - 21, // 6: api.v1.services.system.ListPersonalRolesResponse.roles:type_name -> api.v1.services.types.Role - 23, // 7: api.v1.services.system.GetPersonalProfileResponse.user:type_name -> api.v1.services.types.User - 20, // 8: api.v1.services.system.RefreshPersonalTokenRequest.data:type_name -> google.protobuf.Any - 16, // 9: api.v1.services.system.PersonalService.GetPersonalProfile:input_type -> api.v1.services.system.GetPersonalProfileRequest - 4, // 10: api.v1.services.system.PersonalService.ListPersonalResources:input_type -> api.v1.services.system.ListPersonalResourcesRequest - 14, // 11: api.v1.services.system.PersonalService.ListPersonalRoles:input_type -> api.v1.services.system.ListPersonalRolesRequest - 12, // 12: api.v1.services.system.PersonalService.PersonalLogout:input_type -> api.v1.services.system.PersonalLogoutRequest - 18, // 13: api.v1.services.system.PersonalService.RefreshPersonalToken:input_type -> api.v1.services.system.RefreshPersonalTokenRequest - 6, // 14: api.v1.services.system.PersonalService.UpdatePersonalPassword:input_type -> api.v1.services.system.UpdatePersonalPasswordRequest - 10, // 15: api.v1.services.system.PersonalService.UpdatePersonalProfile:input_type -> api.v1.services.system.UpdatePersonalProfileRequest - 0, // 16: api.v1.services.system.PersonalService.UpdatePersonalSetting:input_type -> api.v1.services.system.UpdatePersonalSettingRequest - 17, // 17: api.v1.services.system.PersonalService.GetPersonalProfile:output_type -> api.v1.services.system.GetPersonalProfileResponse - 5, // 18: api.v1.services.system.PersonalService.ListPersonalResources:output_type -> api.v1.services.system.ListPersonalResourcesResponse - 15, // 19: api.v1.services.system.PersonalService.ListPersonalRoles:output_type -> api.v1.services.system.ListPersonalRolesResponse - 13, // 20: api.v1.services.system.PersonalService.PersonalLogout:output_type -> api.v1.services.system.PersonalLogoutResponse - 19, // 21: api.v1.services.system.PersonalService.RefreshPersonalToken:output_type -> api.v1.services.system.RefreshPersonalTokenResponse - 7, // 22: api.v1.services.system.PersonalService.UpdatePersonalPassword:output_type -> api.v1.services.system.UpdatePersonalPasswordResponse - 11, // 23: api.v1.services.system.PersonalService.UpdatePersonalProfile:output_type -> api.v1.services.system.UpdatePersonalProfileResponse - 1, // 24: api.v1.services.system.PersonalService.UpdatePersonalSetting:output_type -> api.v1.services.system.UpdatePersonalSettingResponse - 17, // [17:25] is the sub-list for method output_type - 9, // [9:17] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name -} - -func init() { file_system_personal_proto_init() } -func file_system_personal_proto_init() { - if File_system_personal_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_personal_proto_rawDesc), len(file_system_personal_proto_rawDesc)), - NumEnums: 0, - NumMessages: 20, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_system_personal_proto_goTypes, - DependencyIndexes: file_system_personal_proto_depIdxs, - MessageInfos: file_system_personal_proto_msgTypes, - }.Build() - File_system_personal_proto = out.File - file_system_personal_proto_goTypes = nil - file_system_personal_proto_depIdxs = nil -} diff --git a/api/v1/services/system/personal.pb.gw.go b/api/v1/services/system/personal.pb.gw.go deleted file mode 100644 index 240e7757..00000000 --- a/api/v1/services/system/personal.pb.gw.go +++ /dev/null @@ -1,594 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/personal.proto - -/* -Package system is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package system - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -func request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPersonalProfileRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.GetPersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPersonalProfileRequest - metadata runtime.ServerMetadata - ) - msg, err := server.GetPersonalProfile(ctx, &protoReq) - return msg, metadata, err -} - -var filter_PersonalService_ListPersonalResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalResourcesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListPersonalResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalResourcesRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListPersonalResources(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalRolesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.ListPersonalRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalRolesRequest - metadata runtime.ServerMetadata - ) - msg, err := server.ListPersonalRoles(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq PersonalLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.PersonalLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq PersonalLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.PersonalLogout(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RefreshPersonalTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.RefreshPersonalToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RefreshPersonalTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.RefreshPersonalToken(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalPasswordRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalPasswordRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalPassword(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalProfileRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalProfileRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalProfile(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalSettingRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalSetting(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalSettingRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalSetting(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterPersonalServiceHandlerServer registers the http handlers for service PersonalService to "mux". -// UnaryRPC :call PersonalServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPersonalServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterPersonalServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PersonalServiceServer) error { - mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/sys/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/sys/personal/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/sys/personal/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/sys/personal/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/sys/personal/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/sys/personal/password")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/sys/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/sys/personal/setting")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterPersonalServiceHandlerFromEndpoint is same as RegisterPersonalServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterPersonalServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterPersonalServiceHandler(ctx, mux, conn) -} - -// RegisterPersonalServiceHandler registers the http handlers for service PersonalService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterPersonalServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterPersonalServiceHandlerClient(ctx, mux, NewPersonalServiceClient(conn)) -} - -// RegisterPersonalServiceHandlerClient registers the http handlers for service PersonalService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PersonalServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PersonalServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "PersonalServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterPersonalServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PersonalServiceClient) error { - mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/sys/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/sys/personal/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/sys/personal/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/sys/personal/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/sys/personal/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/sys/personal/password")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/sys/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/sys/personal/setting")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_PersonalService_GetPersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "personal", "profile"}, "")) - pattern_PersonalService_ListPersonalResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "personal", "resources"}, "")) - pattern_PersonalService_ListPersonalRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "personal", "roles"}, "")) - pattern_PersonalService_PersonalLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "personal", "logout"}, "")) - pattern_PersonalService_RefreshPersonalToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sys", "personal", "token", "refresh"}, "")) - pattern_PersonalService_UpdatePersonalPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "personal", "password"}, "")) - pattern_PersonalService_UpdatePersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "personal", "profile"}, "")) - pattern_PersonalService_UpdatePersonalSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "personal", "setting"}, "")) -) - -var ( - forward_PersonalService_GetPersonalProfile_0 = runtime.ForwardResponseMessage - forward_PersonalService_ListPersonalResources_0 = runtime.ForwardResponseMessage - forward_PersonalService_ListPersonalRoles_0 = runtime.ForwardResponseMessage - forward_PersonalService_PersonalLogout_0 = runtime.ForwardResponseMessage - forward_PersonalService_RefreshPersonalToken_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalPassword_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalProfile_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalSetting_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/system/personal.pb.validate.go b/api/v1/services/system/personal.pb.validate.go deleted file mode 100644 index 00d0e6b7..00000000 --- a/api/v1/services/system/personal.pb.validate.go +++ /dev/null @@ -1,2390 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/personal.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on UpdatePersonalSettingRequest 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 *UpdatePersonalSettingRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalSettingRequest 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 -// UpdatePersonalSettingRequestMultiError, or nil if none found. -func (m *UpdatePersonalSettingRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalSettingRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalSettingRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalSettingRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalSettingRequest.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalSettingRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalSettingRequestMultiError) 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 UpdatePersonalSettingRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalSettingRequestValidationError is the validation error returned -// by UpdatePersonalSettingRequest.Validate if the designated constraints -// aren't met. -type UpdatePersonalSettingRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalSettingRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalSettingRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalSettingRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalSettingRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalSettingRequestValidationError) ErrorName() string { - return "UpdatePersonalSettingRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalSettingRequestValidationError) 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 %sUpdatePersonalSettingRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalSettingRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalSettingRequestValidationError{} - -// Validate checks the field values on UpdatePersonalSettingResponse 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 *UpdatePersonalSettingResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalSettingResponse 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 -// UpdatePersonalSettingResponseMultiError, or nil if none found. -func (m *UpdatePersonalSettingResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalSettingResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalSettingResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalSettingResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalSettingResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalSettingResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalSettingResponseMultiError) 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 UpdatePersonalSettingResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalSettingResponseValidationError is the validation error -// returned by UpdatePersonalSettingResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalSettingResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalSettingResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalSettingResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalSettingResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalSettingResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalSettingResponseValidationError) ErrorName() string { - return "UpdatePersonalSettingResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalSettingResponseValidationError) 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 %sUpdatePersonalSettingResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalSettingResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalSettingResponseValidationError{} - -// Validate checks the field values on UpdatePersonalRoleRequest 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 *UpdatePersonalRoleRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalRoleRequest 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 -// UpdatePersonalRoleRequestMultiError, or nil if none found. -func (m *UpdatePersonalRoleRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalRoleRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalRoleRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalRoleRequestMultiError is an error wrapping multiple validation -// errors returned by UpdatePersonalRoleRequest.ValidateAll() if the -// designated constraints aren't met. -type UpdatePersonalRoleRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalRoleRequestMultiError) 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 UpdatePersonalRoleRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalRoleRequestValidationError is the validation error returned by -// UpdatePersonalRoleRequest.Validate if the designated constraints aren't met. -type UpdatePersonalRoleRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalRoleRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalRoleRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalRoleRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalRoleRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalRoleRequestValidationError) ErrorName() string { - return "UpdatePersonalRoleRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalRoleRequestValidationError) 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 %sUpdatePersonalRoleRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalRoleRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalRoleRequestValidationError{} - -// Validate checks the field values on UpdatePersonalRoleResponse 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 *UpdatePersonalRoleResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalRoleResponse 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 -// UpdatePersonalRoleResponseMultiError, or nil if none found. -func (m *UpdatePersonalRoleResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalRoleResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalRoleResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalRoleResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalRoleResponse.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalRoleResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalRoleResponseMultiError) 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 UpdatePersonalRoleResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalRoleResponseValidationError is the validation error returned -// by UpdatePersonalRoleResponse.Validate if the designated constraints aren't met. -type UpdatePersonalRoleResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalRoleResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalRoleResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalRoleResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalRoleResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalRoleResponseValidationError) ErrorName() string { - return "UpdatePersonalRoleResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalRoleResponseValidationError) 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 %sUpdatePersonalRoleResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalRoleResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalRoleResponseValidationError{} - -// Validate checks the field values on ListPersonalResourcesRequest 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 *ListPersonalResourcesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalResourcesRequest 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 -// ListPersonalResourcesRequestMultiError, or nil if none found. -func (m *ListPersonalResourcesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalResourcesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - if len(errors) > 0 { - return ListPersonalResourcesRequestMultiError(errors) - } - - return nil -} - -// ListPersonalResourcesRequestMultiError is an error wrapping multiple -// validation errors returned by ListPersonalResourcesRequest.ValidateAll() if -// the designated constraints aren't met. -type ListPersonalResourcesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalResourcesRequestMultiError) 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 ListPersonalResourcesRequestMultiError) AllErrors() []error { return m } - -// ListPersonalResourcesRequestValidationError is the validation error returned -// by ListPersonalResourcesRequest.Validate if the designated constraints -// aren't met. -type ListPersonalResourcesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalResourcesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalResourcesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalResourcesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalResourcesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalResourcesRequestValidationError) ErrorName() string { - return "ListPersonalResourcesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalResourcesRequestValidationError) 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 %sListPersonalResourcesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalResourcesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalResourcesRequestValidationError{} - -// Validate checks the field values on ListPersonalResourcesResponse 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 *ListPersonalResourcesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalResourcesResponse 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 -// ListPersonalResourcesResponseMultiError, or nil if none found. -func (m *ListPersonalResourcesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalResourcesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for NextPageToken - - if len(errors) > 0 { - return ListPersonalResourcesResponseMultiError(errors) - } - - return nil -} - -// ListPersonalResourcesResponseMultiError is an error wrapping multiple -// validation errors returned by ListPersonalResourcesResponse.ValidateAll() -// if the designated constraints aren't met. -type ListPersonalResourcesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalResourcesResponseMultiError) 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 ListPersonalResourcesResponseMultiError) AllErrors() []error { return m } - -// ListPersonalResourcesResponseValidationError is the validation error -// returned by ListPersonalResourcesResponse.Validate if the designated -// constraints aren't met. -type ListPersonalResourcesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalResourcesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalResourcesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalResourcesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalResourcesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalResourcesResponseValidationError) ErrorName() string { - return "ListPersonalResourcesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalResourcesResponseValidationError) 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 %sListPersonalResourcesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalResourcesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalResourcesResponseValidationError{} - -// Validate checks the field values on UpdatePersonalPasswordRequest 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 *UpdatePersonalPasswordRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalPasswordRequest 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 -// UpdatePersonalPasswordRequestMultiError, or nil if none found. -func (m *UpdatePersonalPasswordRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalPasswordRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalPasswordRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalPasswordRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalPasswordRequest.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalPasswordRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalPasswordRequestMultiError) 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 UpdatePersonalPasswordRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalPasswordRequestValidationError is the validation error -// returned by UpdatePersonalPasswordRequest.Validate if the designated -// constraints aren't met. -type UpdatePersonalPasswordRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalPasswordRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalPasswordRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalPasswordRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalPasswordRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalPasswordRequestValidationError) ErrorName() string { - return "UpdatePersonalPasswordRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalPasswordRequestValidationError) 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 %sUpdatePersonalPasswordRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalPasswordRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalPasswordRequestValidationError{} - -// Validate checks the field values on UpdatePersonalPasswordResponse 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 *UpdatePersonalPasswordResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalPasswordResponse 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 -// UpdatePersonalPasswordResponseMultiError, or nil if none found. -func (m *UpdatePersonalPasswordResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalPasswordResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalPasswordResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalPasswordResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalPasswordResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalPasswordResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalPasswordResponseMultiError) 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 UpdatePersonalPasswordResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalPasswordResponseValidationError is the validation error -// returned by UpdatePersonalPasswordResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalPasswordResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalPasswordResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalPasswordResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalPasswordResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalPasswordResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalPasswordResponseValidationError) ErrorName() string { - return "UpdatePersonalPasswordResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalPasswordResponseValidationError) 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 %sUpdatePersonalPasswordResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalPasswordResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalPasswordResponseValidationError{} - -// Validate checks the field values on PersonalPasswordRestRequest 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 *PersonalPasswordRestRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalPasswordRestRequest 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 -// PersonalPasswordRestRequestMultiError, or nil if none found. -func (m *PersonalPasswordRestRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalPasswordRestRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetId() <= 0 { - err := PersonalPasswordRestRequestValidationError{ - field: "Id", - reason: "value must be greater than 0", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return PersonalPasswordRestRequestMultiError(errors) - } - - return nil -} - -// PersonalPasswordRestRequestMultiError is an error wrapping multiple -// validation errors returned by PersonalPasswordRestRequest.ValidateAll() if -// the designated constraints aren't met. -type PersonalPasswordRestRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalPasswordRestRequestMultiError) 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 PersonalPasswordRestRequestMultiError) AllErrors() []error { return m } - -// PersonalPasswordRestRequestValidationError is the validation error returned -// by PersonalPasswordRestRequest.Validate if the designated constraints -// aren't met. -type PersonalPasswordRestRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalPasswordRestRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalPasswordRestRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalPasswordRestRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalPasswordRestRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalPasswordRestRequestValidationError) ErrorName() string { - return "PersonalPasswordRestRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalPasswordRestRequestValidationError) 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 %sPersonalPasswordRestRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalPasswordRestRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalPasswordRestRequestValidationError{} - -// Validate checks the field values on PersonalPasswordRestResponse 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 *PersonalPasswordRestResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalPasswordRestResponse 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 -// PersonalPasswordRestResponseMultiError, or nil if none found. -func (m *PersonalPasswordRestResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalPasswordRestResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return PersonalPasswordRestResponseMultiError(errors) - } - - return nil -} - -// PersonalPasswordRestResponseMultiError is an error wrapping multiple -// validation errors returned by PersonalPasswordRestResponse.ValidateAll() if -// the designated constraints aren't met. -type PersonalPasswordRestResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalPasswordRestResponseMultiError) 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 PersonalPasswordRestResponseMultiError) AllErrors() []error { return m } - -// PersonalPasswordRestResponseValidationError is the validation error returned -// by PersonalPasswordRestResponse.Validate if the designated constraints -// aren't met. -type PersonalPasswordRestResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalPasswordRestResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalPasswordRestResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalPasswordRestResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalPasswordRestResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalPasswordRestResponseValidationError) ErrorName() string { - return "PersonalPasswordRestResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalPasswordRestResponseValidationError) 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 %sPersonalPasswordRestResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalPasswordRestResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalPasswordRestResponseValidationError{} - -// Validate checks the field values on UpdatePersonalProfileRequest 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 *UpdatePersonalProfileRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalProfileRequest 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 -// UpdatePersonalProfileRequestMultiError, or nil if none found. -func (m *UpdatePersonalProfileRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalProfileRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalProfileRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalProfileRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalProfileRequest.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalProfileRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalProfileRequestMultiError) 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 UpdatePersonalProfileRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalProfileRequestValidationError is the validation error returned -// by UpdatePersonalProfileRequest.Validate if the designated constraints -// aren't met. -type UpdatePersonalProfileRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalProfileRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalProfileRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalProfileRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalProfileRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalProfileRequestValidationError) ErrorName() string { - return "UpdatePersonalProfileRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalProfileRequestValidationError) 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 %sUpdatePersonalProfileRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalProfileRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalProfileRequestValidationError{} - -// Validate checks the field values on UpdatePersonalProfileResponse 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 *UpdatePersonalProfileResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalProfileResponse 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 -// UpdatePersonalProfileResponseMultiError, or nil if none found. -func (m *UpdatePersonalProfileResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalProfileResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalProfileResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalProfileResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalProfileResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalProfileResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalProfileResponseMultiError) 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 UpdatePersonalProfileResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalProfileResponseValidationError is the validation error -// returned by UpdatePersonalProfileResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalProfileResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalProfileResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalProfileResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalProfileResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalProfileResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalProfileResponseValidationError) ErrorName() string { - return "UpdatePersonalProfileResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalProfileResponseValidationError) 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 %sUpdatePersonalProfileResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalProfileResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalProfileResponseValidationError{} - -// Validate checks the field values on PersonalLogoutRequest 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 *PersonalLogoutRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalLogoutRequest 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 -// PersonalLogoutRequestMultiError, or nil if none found. -func (m *PersonalLogoutRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalLogoutRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return PersonalLogoutRequestMultiError(errors) - } - - return nil -} - -// PersonalLogoutRequestMultiError is an error wrapping multiple validation -// errors returned by PersonalLogoutRequest.ValidateAll() if the designated -// constraints aren't met. -type PersonalLogoutRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalLogoutRequestMultiError) 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 PersonalLogoutRequestMultiError) AllErrors() []error { return m } - -// PersonalLogoutRequestValidationError is the validation error returned by -// PersonalLogoutRequest.Validate if the designated constraints aren't met. -type PersonalLogoutRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalLogoutRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalLogoutRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalLogoutRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalLogoutRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalLogoutRequestValidationError) ErrorName() string { - return "PersonalLogoutRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalLogoutRequestValidationError) 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 %sPersonalLogoutRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalLogoutRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalLogoutRequestValidationError{} - -// Validate checks the field values on PersonalLogoutResponse 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 *PersonalLogoutResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalLogoutResponse 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 -// PersonalLogoutResponseMultiError, or nil if none found. -func (m *PersonalLogoutResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalLogoutResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Success - - if len(errors) > 0 { - return PersonalLogoutResponseMultiError(errors) - } - - return nil -} - -// PersonalLogoutResponseMultiError is an error wrapping multiple validation -// errors returned by PersonalLogoutResponse.ValidateAll() if the designated -// constraints aren't met. -type PersonalLogoutResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalLogoutResponseMultiError) 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 PersonalLogoutResponseMultiError) AllErrors() []error { return m } - -// PersonalLogoutResponseValidationError is the validation error returned by -// PersonalLogoutResponse.Validate if the designated constraints aren't met. -type PersonalLogoutResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalLogoutResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalLogoutResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalLogoutResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalLogoutResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalLogoutResponseValidationError) ErrorName() string { - return "PersonalLogoutResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalLogoutResponseValidationError) 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 %sPersonalLogoutResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalLogoutResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalLogoutResponseValidationError{} - -// Validate checks the field values on ListPersonalRolesRequest 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 *ListPersonalRolesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalRolesRequest 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 -// ListPersonalRolesRequestMultiError, or nil if none found. -func (m *ListPersonalRolesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalRolesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return ListPersonalRolesRequestMultiError(errors) - } - - return nil -} - -// ListPersonalRolesRequestMultiError is an error wrapping multiple validation -// errors returned by ListPersonalRolesRequest.ValidateAll() if the designated -// constraints aren't met. -type ListPersonalRolesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalRolesRequestMultiError) 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 ListPersonalRolesRequestMultiError) AllErrors() []error { return m } - -// ListPersonalRolesRequestValidationError is the validation error returned by -// ListPersonalRolesRequest.Validate if the designated constraints aren't met. -type ListPersonalRolesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalRolesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalRolesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalRolesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalRolesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalRolesRequestValidationError) ErrorName() string { - return "ListPersonalRolesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalRolesRequestValidationError) 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 %sListPersonalRolesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalRolesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalRolesRequestValidationError{} - -// Validate checks the field values on ListPersonalRolesResponse 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 *ListPersonalRolesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalRolesResponse 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 -// ListPersonalRolesResponseMultiError, or nil if none found. -func (m *ListPersonalRolesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalRolesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListPersonalRolesResponseMultiError(errors) - } - - return nil -} - -// ListPersonalRolesResponseMultiError is an error wrapping multiple validation -// errors returned by ListPersonalRolesResponse.ValidateAll() if the -// designated constraints aren't met. -type ListPersonalRolesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalRolesResponseMultiError) 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 ListPersonalRolesResponseMultiError) AllErrors() []error { return m } - -// ListPersonalRolesResponseValidationError is the validation error returned by -// ListPersonalRolesResponse.Validate if the designated constraints aren't met. -type ListPersonalRolesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalRolesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalRolesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalRolesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalRolesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalRolesResponseValidationError) ErrorName() string { - return "ListPersonalRolesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalRolesResponseValidationError) 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 %sListPersonalRolesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalRolesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalRolesResponseValidationError{} - -// Validate checks the field values on GetPersonalProfileRequest 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 *GetPersonalProfileRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPersonalProfileRequest 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 -// GetPersonalProfileRequestMultiError, or nil if none found. -func (m *GetPersonalProfileRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPersonalProfileRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return GetPersonalProfileRequestMultiError(errors) - } - - return nil -} - -// GetPersonalProfileRequestMultiError is an error wrapping multiple validation -// errors returned by GetPersonalProfileRequest.ValidateAll() if the -// designated constraints aren't met. -type GetPersonalProfileRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPersonalProfileRequestMultiError) 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 GetPersonalProfileRequestMultiError) AllErrors() []error { return m } - -// GetPersonalProfileRequestValidationError is the validation error returned by -// GetPersonalProfileRequest.Validate if the designated constraints aren't met. -type GetPersonalProfileRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPersonalProfileRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPersonalProfileRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPersonalProfileRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPersonalProfileRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPersonalProfileRequestValidationError) ErrorName() string { - return "GetPersonalProfileRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPersonalProfileRequestValidationError) 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 %sGetPersonalProfileRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPersonalProfileRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPersonalProfileRequestValidationError{} - -// Validate checks the field values on GetPersonalProfileResponse 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 *GetPersonalProfileResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPersonalProfileResponse 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 -// GetPersonalProfileResponseMultiError, or nil if none found. -func (m *GetPersonalProfileResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPersonalProfileResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetPersonalProfileResponseMultiError(errors) - } - - return nil -} - -// GetPersonalProfileResponseMultiError is an error wrapping multiple -// validation errors returned by GetPersonalProfileResponse.ValidateAll() if -// the designated constraints aren't met. -type GetPersonalProfileResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPersonalProfileResponseMultiError) 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 GetPersonalProfileResponseMultiError) AllErrors() []error { return m } - -// GetPersonalProfileResponseValidationError is the validation error returned -// by GetPersonalProfileResponse.Validate if the designated constraints aren't met. -type GetPersonalProfileResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPersonalProfileResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPersonalProfileResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPersonalProfileResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPersonalProfileResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPersonalProfileResponseValidationError) ErrorName() string { - return "GetPersonalProfileResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPersonalProfileResponseValidationError) 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 %sGetPersonalProfileResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPersonalProfileResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPersonalProfileResponseValidationError{} - -// Validate checks the field values on RefreshPersonalTokenRequest 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 *RefreshPersonalTokenRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RefreshPersonalTokenRequest 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 -// RefreshPersonalTokenRequestMultiError, or nil if none found. -func (m *RefreshPersonalTokenRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *RefreshPersonalTokenRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RefreshPersonalTokenRequestMultiError(errors) - } - - return nil -} - -// RefreshPersonalTokenRequestMultiError is an error wrapping multiple -// validation errors returned by RefreshPersonalTokenRequest.ValidateAll() if -// the designated constraints aren't met. -type RefreshPersonalTokenRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RefreshPersonalTokenRequestMultiError) 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 RefreshPersonalTokenRequestMultiError) AllErrors() []error { return m } - -// RefreshPersonalTokenRequestValidationError is the validation error returned -// by RefreshPersonalTokenRequest.Validate if the designated constraints -// aren't met. -type RefreshPersonalTokenRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RefreshPersonalTokenRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RefreshPersonalTokenRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RefreshPersonalTokenRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RefreshPersonalTokenRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RefreshPersonalTokenRequestValidationError) ErrorName() string { - return "RefreshPersonalTokenRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e RefreshPersonalTokenRequestValidationError) 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 %sRefreshPersonalTokenRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RefreshPersonalTokenRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RefreshPersonalTokenRequestValidationError{} - -// Validate checks the field values on RefreshPersonalTokenResponse 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 *RefreshPersonalTokenResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RefreshPersonalTokenResponse 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 -// RefreshPersonalTokenResponseMultiError, or nil if none found. -func (m *RefreshPersonalTokenResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *RefreshPersonalTokenResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - if len(errors) > 0 { - return RefreshPersonalTokenResponseMultiError(errors) - } - - return nil -} - -// RefreshPersonalTokenResponseMultiError is an error wrapping multiple -// validation errors returned by RefreshPersonalTokenResponse.ValidateAll() if -// the designated constraints aren't met. -type RefreshPersonalTokenResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RefreshPersonalTokenResponseMultiError) 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 RefreshPersonalTokenResponseMultiError) AllErrors() []error { return m } - -// RefreshPersonalTokenResponseValidationError is the validation error returned -// by RefreshPersonalTokenResponse.Validate if the designated constraints -// aren't met. -type RefreshPersonalTokenResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RefreshPersonalTokenResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RefreshPersonalTokenResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RefreshPersonalTokenResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RefreshPersonalTokenResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RefreshPersonalTokenResponseValidationError) ErrorName() string { - return "RefreshPersonalTokenResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e RefreshPersonalTokenResponseValidationError) 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 %sRefreshPersonalTokenResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RefreshPersonalTokenResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RefreshPersonalTokenResponseValidationError{} diff --git a/api/v1/services/system/personal_bridge.pb.go b/api/v1/services/system/personal_bridge.pb.go deleted file mode 100644 index 5d7c8773..00000000 --- a/api/v1/services/system/personal_bridge.pb.go +++ /dev/null @@ -1,565 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: system/personal.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const PersonalServiceGetPersonalProfileBridgeOperation = "/api.v1.services.system.PersonalService/GetPersonalProfile" -const PersonalServiceListPersonalResourcesBridgeOperation = "/api.v1.services.system.PersonalService/ListPersonalResources" -const PersonalServiceListPersonalRolesBridgeOperation = "/api.v1.services.system.PersonalService/ListPersonalRoles" -const PersonalServicePersonalLogoutBridgeOperation = "/api.v1.services.system.PersonalService/PersonalLogout" -const PersonalServiceRefreshPersonalTokenBridgeOperation = "/api.v1.services.system.PersonalService/RefreshPersonalToken" -const PersonalServiceUpdatePersonalPasswordBridgeOperation = "/api.v1.services.system.PersonalService/UpdatePersonalPassword" -const PersonalServiceUpdatePersonalProfileBridgeOperation = "/api.v1.services.system.PersonalService/UpdatePersonalProfile" -const PersonalServiceUpdatePersonalSettingBridgeOperation = "/api.v1.services.system.PersonalService/UpdatePersonalSetting" - -type PersonalServiceBridger interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) -} - -type PersonalServiceHooker interface { - PersonalServiceGetPersonalProfileHooker - PersonalServiceListPersonalResourcesHooker - PersonalServiceListPersonalRolesHooker - PersonalServicePersonalLogoutHooker - PersonalServiceRefreshPersonalTokenHooker - PersonalServiceUpdatePersonalPasswordHooker - PersonalServiceUpdatePersonalProfileHooker - PersonalServiceUpdatePersonalSettingHooker -} - -type PersonalServiceHookedBridger interface { - PersonalServiceHooker - PersonalServiceBridger -} -type PersonalServiceGetPersonalProfileHooker interface { - PrepareGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) - CompleteGetPersonalProfile(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error -} -type PersonalServiceListPersonalResourcesHooker interface { - PrepareListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) - CompleteListPersonalResources(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error -} -type PersonalServiceListPersonalRolesHooker interface { - PrepareListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) - CompleteListPersonalRoles(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error -} -type PersonalServicePersonalLogoutHooker interface { - PreparePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) - CompletePersonalLogout(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error -} -type PersonalServiceRefreshPersonalTokenHooker interface { - PrepareRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) - CompleteRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error -} -type PersonalServiceUpdatePersonalPasswordHooker interface { - PrepareUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) - CompleteUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error -} -type PersonalServiceUpdatePersonalProfileHooker interface { - PrepareUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) - CompleteUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error -} -type PersonalServiceUpdatePersonalSettingHooker interface { - PrepareUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) - CompleteUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error -} - -func RegisterPersonalServiceBridger(s *http.Server, srv PersonalServiceHookedBridger) { - r := s.Route("/") - r.GET("/sys/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) - r.GET("/sys/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) - r.GET("/sys/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) - r.POST("/sys/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(srv)) - r.POST("/sys/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv)) - r.PUT("/sys/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv)) - r.PUT("/sys/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv)) - r.PUT("/sys/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv)) -} - -func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPersonalProfileRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - }) - - newctx, err := srv.PrepareGetPersonalProfile(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetPersonalProfile(ctx, &in, out.(*GetPersonalProfileResponse)) - } -} - -func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - }) - - newctx, err := srv.PrepareListPersonalResources(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPersonalResources(ctx, &in, out.(*ListPersonalResourcesResponse)) - } -} - -func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalRolesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - }) - - newctx, err := srv.PrepareListPersonalRoles(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPersonalRoles(ctx, &in, out.(*ListPersonalRolesResponse)) - } -} - -func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in PersonalLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServicePersonalLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - }) - - newctx, err := srv.PreparePersonalLogout(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompletePersonalLogout(ctx, &in, out.(*PersonalLogoutResponse)) - } -} - -func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RefreshPersonalTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - }) - - newctx, err := srv.PrepareRefreshPersonalToken(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteRefreshPersonalToken(ctx, &in, out.(*RefreshPersonalTokenResponse)) - } -} - -func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalPassword(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalPassword(ctx, &in, out.(*UpdatePersonalPasswordResponse)) - } -} - -func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalProfileRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalProfile(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalProfile(ctx, &in, out.(*UpdatePersonalProfileResponse)) - } -} - -func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalSettingRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalSetting(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalSetting(ctx, &in, out.(*UpdatePersonalSettingResponse)) - } -} - -// UnimplementedPersonalServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPersonalServiceHooked struct{} - -func (UnimplementedPersonalServiceHooked) PrepareGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PreparePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompletePersonalLogout(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { - return ctx.Result(200, out) -} - -func WithPersonalServiceHook(h PersonalServiceHooker) func(PersonalServiceBridger) PersonalServiceHookedBridger { - return func(b PersonalServiceBridger) PersonalServiceHookedBridger { - return PersonalServiceHookedBridge{PersonalServiceBridger: b, PersonalServiceHooker: h} - } -} - -// PersonalServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PersonalService. -// It implements the HTTP and gRPC implementations of PersonalService. -// It forwards requests and responses between the two implementations. -type PersonalServiceHookedBridge struct { - PersonalServiceBridger - PersonalServiceHooker -} - -type PersonalServiceHTTPBridgeImpl struct { - client PersonalServiceHTTPClient -} - -func NewPersonalServiceHTTPBridge(client *http.Client) PersonalServiceHTTPServer { - return &PersonalServiceHTTPBridgeImpl{client: NewPersonalServiceHTTPClient(client)} -} - -func (c *PersonalServiceHTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -type PersonalServiceBridgeImpl struct { - client PersonalServiceClient -} - -func NewPersonalServiceBridge(client grpc.ClientConnInterface) PersonalServiceServer { - return &PersonalServiceBridgeImpl{client: NewPersonalServiceClient(client)} -} - -func (c *PersonalServiceBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} - -type PersonalServiceGRPC2HTTPBridgeImpl struct { - client PersonalServiceClient -} - -func NewPersonalServiceGRPC2HTTP(client grpc.ClientConnInterface) PersonalServiceHTTPServer { - return &PersonalServiceGRPC2HTTPBridgeImpl{client: NewPersonalServiceClient(client)} -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -type PersonalServiceHTTP2GRPCBridgeImpl struct { - client PersonalServiceHTTPClient -} - -func NewPersonalServiceHTTP2GRPC(client *http.Client) PersonalServiceServer { - return &PersonalServiceHTTP2GRPCBridgeImpl{client: NewPersonalServiceHTTPClient(client)} -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} diff --git a/api/v1/services/system/personal_grpc.pb.go b/api/v1/services/system/personal_grpc.pb.go deleted file mode 100644 index e3333bf0..00000000 --- a/api/v1/services/system/personal_grpc.pb.go +++ /dev/null @@ -1,407 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: system/personal.proto - -package system - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - PersonalService_GetPersonalProfile_FullMethodName = "/api.v1.services.system.PersonalService/GetPersonalProfile" - PersonalService_ListPersonalResources_FullMethodName = "/api.v1.services.system.PersonalService/ListPersonalResources" - PersonalService_ListPersonalRoles_FullMethodName = "/api.v1.services.system.PersonalService/ListPersonalRoles" - PersonalService_PersonalLogout_FullMethodName = "/api.v1.services.system.PersonalService/PersonalLogout" - PersonalService_RefreshPersonalToken_FullMethodName = "/api.v1.services.system.PersonalService/RefreshPersonalToken" - PersonalService_UpdatePersonalPassword_FullMethodName = "/api.v1.services.system.PersonalService/UpdatePersonalPassword" - PersonalService_UpdatePersonalProfile_FullMethodName = "/api.v1.services.system.PersonalService/UpdatePersonalProfile" - PersonalService_UpdatePersonalSetting_FullMethodName = "/api.v1.services.system.PersonalService/UpdatePersonalSetting" -) - -// PersonalServiceClient is the client API for PersonalService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// PersonalService Personal user service -type PersonalServiceClient interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) -} - -type personalServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewPersonalServiceClient(cc grpc.ClientConnInterface) PersonalServiceClient { - return &personalServiceClient{cc} -} - -func (c *personalServiceClient) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetPersonalProfileResponse) - err := c.cc.Invoke(ctx, PersonalService_GetPersonalProfile_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPersonalResourcesResponse) - err := c.cc.Invoke(ctx, PersonalService_ListPersonalResources_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPersonalRolesResponse) - err := c.cc.Invoke(ctx, PersonalService_ListPersonalRoles_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(PersonalLogoutResponse) - err := c.cc.Invoke(ctx, PersonalService_PersonalLogout_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(RefreshPersonalTokenResponse) - err := c.cc.Invoke(ctx, PersonalService_RefreshPersonalToken_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalPasswordResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalPassword_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalProfileResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalProfile_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalSettingResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalSetting_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// PersonalServiceServer is the server API for PersonalService service. -// All implementations must embed UnimplementedPersonalServiceServer -// for forward compatibility. -// -// PersonalService Personal user service -type PersonalServiceServer interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) - mustEmbedUnimplementedPersonalServiceServer() -} - -// UnimplementedPersonalServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPersonalServiceServer struct{} - -func (UnimplementedPersonalServiceServer) GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetPersonalProfile not implemented") -} -func (UnimplementedPersonalServiceServer) ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPersonalResources not implemented") -} -func (UnimplementedPersonalServiceServer) ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPersonalRoles not implemented") -} -func (UnimplementedPersonalServiceServer) PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PersonalLogout not implemented") -} -func (UnimplementedPersonalServiceServer) RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RefreshPersonalToken not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalPassword not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalProfile not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalSetting not implemented") -} -func (UnimplementedPersonalServiceServer) mustEmbedUnimplementedPersonalServiceServer() {} -func (UnimplementedPersonalServiceServer) testEmbeddedByValue() {} - -// UnsafePersonalServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to PersonalServiceServer will -// result in compilation errors. -type UnsafePersonalServiceServer interface { - mustEmbedUnimplementedPersonalServiceServer() -} - -func RegisterPersonalServiceServer(s grpc.ServiceRegistrar, srv PersonalServiceServer) { - // If the following call pancis, it indicates UnimplementedPersonalServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&PersonalService_ServiceDesc, srv) -} - -func _PersonalService_GetPersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPersonalProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).GetPersonalProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_GetPersonalProfile_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_ListPersonalResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPersonalResourcesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).ListPersonalResources(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_ListPersonalResources_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_ListPersonalRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPersonalRolesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).ListPersonalRoles(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_ListPersonalRoles_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_PersonalLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PersonalLogoutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).PersonalLogout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_PersonalLogout_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_RefreshPersonalToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RefreshPersonalTokenRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_RefreshPersonalToken_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalPasswordRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalPassword_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalProfile_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalSettingRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalSetting_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// PersonalService_ServiceDesc is the grpc.ServiceDesc for PersonalService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var PersonalService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.PersonalService", - HandlerType: (*PersonalServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetPersonalProfile", - Handler: _PersonalService_GetPersonalProfile_Handler, - }, - { - MethodName: "ListPersonalResources", - Handler: _PersonalService_ListPersonalResources_Handler, - }, - { - MethodName: "ListPersonalRoles", - Handler: _PersonalService_ListPersonalRoles_Handler, - }, - { - MethodName: "PersonalLogout", - Handler: _PersonalService_PersonalLogout_Handler, - }, - { - MethodName: "RefreshPersonalToken", - Handler: _PersonalService_RefreshPersonalToken_Handler, - }, - { - MethodName: "UpdatePersonalPassword", - Handler: _PersonalService_UpdatePersonalPassword_Handler, - }, - { - MethodName: "UpdatePersonalProfile", - Handler: _PersonalService_UpdatePersonalProfile_Handler, - }, - { - MethodName: "UpdatePersonalSetting", - Handler: _PersonalService_UpdatePersonalSetting_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "system/personal.proto", -} diff --git a/api/v1/services/system/personal_http.pb.go b/api/v1/services/system/personal_http.pb.go deleted file mode 100644 index b38d3c36..00000000 --- a/api/v1/services/system/personal_http.pb.go +++ /dev/null @@ -1,350 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.8.4 -// - protoc (unknown) -// source: system/personal.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationPersonalServiceGetPersonalProfile = "/api.v1.services.system.PersonalService/GetPersonalProfile" -const OperationPersonalServiceListPersonalResources = "/api.v1.services.system.PersonalService/ListPersonalResources" -const OperationPersonalServiceListPersonalRoles = "/api.v1.services.system.PersonalService/ListPersonalRoles" -const OperationPersonalServicePersonalLogout = "/api.v1.services.system.PersonalService/PersonalLogout" -const OperationPersonalServiceRefreshPersonalToken = "/api.v1.services.system.PersonalService/RefreshPersonalToken" -const OperationPersonalServiceUpdatePersonalPassword = "/api.v1.services.system.PersonalService/UpdatePersonalPassword" -const OperationPersonalServiceUpdatePersonalProfile = "/api.v1.services.system.PersonalService/UpdatePersonalProfile" -const OperationPersonalServiceUpdatePersonalSetting = "/api.v1.services.system.PersonalService/UpdatePersonalSetting" - -type PersonalServiceHTTPServer interface { - // GetPersonalProfile GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalRoles ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) -} - -func RegisterPersonalServiceHTTPServer(s *http.Server, srv PersonalServiceHTTPServer) { - r := s.Route("/") - r.GET("/sys/personal/profile", _PersonalService_GetPersonalProfile0_HTTP_Handler(srv)) - r.GET("/sys/personal/resources", _PersonalService_ListPersonalResources0_HTTP_Handler(srv)) - r.GET("/sys/personal/roles", _PersonalService_ListPersonalRoles0_HTTP_Handler(srv)) - r.POST("/sys/personal/logout", _PersonalService_PersonalLogout0_HTTP_Handler(srv)) - r.POST("/sys/personal/token/refresh", _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv)) - r.PUT("/sys/personal/password", _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv)) - r.PUT("/sys/personal/profile", _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv)) - r.PUT("/sys/personal/setting", _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv)) -} - -func _PersonalService_GetPersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPersonalProfileRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetPersonalProfileResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_ListPersonalResources0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPersonalResourcesResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_ListPersonalRoles0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalRolesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPersonalRolesResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_PersonalLogout0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in PersonalLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServicePersonalLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*PersonalLogoutResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RefreshPersonalTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*RefreshPersonalTokenResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalPasswordResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalProfileRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalProfileResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalSettingRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalSettingResponse) - return ctx.Result(200, reply) - } -} - -type PersonalServiceHTTPClient interface { - GetPersonalProfile(ctx context.Context, req *GetPersonalProfileRequest, opts ...http.CallOption) (rsp *GetPersonalProfileResponse, err error) - ListPersonalResources(ctx context.Context, req *ListPersonalResourcesRequest, opts ...http.CallOption) (rsp *ListPersonalResourcesResponse, err error) - ListPersonalRoles(ctx context.Context, req *ListPersonalRolesRequest, opts ...http.CallOption) (rsp *ListPersonalRolesResponse, err error) - PersonalLogout(ctx context.Context, req *PersonalLogoutRequest, opts ...http.CallOption) (rsp *PersonalLogoutResponse, err error) - RefreshPersonalToken(ctx context.Context, req *RefreshPersonalTokenRequest, opts ...http.CallOption) (rsp *RefreshPersonalTokenResponse, err error) - UpdatePersonalPassword(ctx context.Context, req *UpdatePersonalPasswordRequest, opts ...http.CallOption) (rsp *UpdatePersonalPasswordResponse, err error) - UpdatePersonalProfile(ctx context.Context, req *UpdatePersonalProfileRequest, opts ...http.CallOption) (rsp *UpdatePersonalProfileResponse, err error) - UpdatePersonalSetting(ctx context.Context, req *UpdatePersonalSettingRequest, opts ...http.CallOption) (rsp *UpdatePersonalSettingResponse, err error) -} - -type PersonalServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewPersonalServiceHTTPClient(client *http.Client) PersonalServiceHTTPClient { - return &PersonalServiceHTTPClientImpl{client} -} - -func (c *PersonalServiceHTTPClientImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...http.CallOption) (*GetPersonalProfileResponse, error) { - var out GetPersonalProfileResponse - pattern := "/sys/personal/profile" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceGetPersonalProfile)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PersonalServiceHTTPClientImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...http.CallOption) (*ListPersonalResourcesResponse, error) { - var out ListPersonalResourcesResponse - pattern := "/sys/personal/resources" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceListPersonalResources)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PersonalServiceHTTPClientImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...http.CallOption) (*ListPersonalRolesResponse, error) { - var out ListPersonalRolesResponse - pattern := "/sys/personal/roles" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceListPersonalRoles)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PersonalServiceHTTPClientImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...http.CallOption) (*PersonalLogoutResponse, error) { - var out PersonalLogoutResponse - pattern := "/sys/personal/logout" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServicePersonalLogout)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PersonalServiceHTTPClientImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...http.CallOption) (*RefreshPersonalTokenResponse, error) { - var out RefreshPersonalTokenResponse - pattern := "/sys/personal/token/refresh" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceRefreshPersonalToken)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...http.CallOption) (*UpdatePersonalPasswordResponse, error) { - var out UpdatePersonalPasswordResponse - pattern := "/sys/personal/password" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalPassword)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...http.CallOption) (*UpdatePersonalProfileResponse, error) { - var out UpdatePersonalProfileResponse - pattern := "/sys/personal/profile" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalProfile)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...http.CallOption) (*UpdatePersonalSettingResponse, error) { - var out UpdatePersonalSettingResponse - pattern := "/sys/personal/setting" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalSetting)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/cmd/auth/wire_gen.go b/cmd/auth/wire_gen.go index 02b5b940..11603dbc 100644 --- a/cmd/auth/wire_gen.go +++ b/cmd/auth/wire_gen.go @@ -51,8 +51,11 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap loginRepo := dal.NewLoginRepo(dataData, loginData) loginServiceBiz := biz.NewLoginServiceBiz(r, loginRepo) loginServiceServer := service.NewLoginServiceServerPB(loginServiceBiz) - serverRegistrar := service.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer) - v := server.NewAuthServer(r, bootstrap, serverRegistrar) + personalRepo := dal.NewPersonalRepo(r, dataData) + personalServiceBiz := biz.NewPersonalServiceBiz(r, personalRepo) + personalServiceServer := service.NewPersonalServiceServerPB(r, personalServiceBiz) + registerServer := service.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) + v := server.NewAuthServer(r, bootstrap, registerServer) app := NewApp(r, v) return app, func() { cleanup() diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index c4c94d85..955d10df 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -9,15 +9,18 @@ import ( "log/slog" "github.com/go-kratos/kratos/v2" + "github.com/go-kratos/kratos/v2/encoding" "github.com/go-kratos/kratos/v2/transport" "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/codec/toml" "github.com/spf13/cobra" _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" + "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/loader" ) @@ -46,6 +49,7 @@ var cmd = &cobra.Command{ } func init() { + encoding.RegisterCodec(toml.Codec) flags.SetServiceInfo(Name, Version) } @@ -68,7 +72,7 @@ func startCommandRun(cmd *cobra.Command, args []string) error { } if debug { flags.SetEnv("debug") - flags.SetConfigPath("resources/configs/system_config.toml") + flags.SetConfigPath("resources/configs/config.toml") flags.SetWorkDir(".") slog.SetLogLoggerLevel(slog.LevelDebug) } @@ -101,3 +105,14 @@ func NewApp(r runtime.Runtime, servers []transport.Server) *kratos.App { r = r.Client() return r.CreateApp(servers...) } + +func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { + ll := log.NewHelper(r.Logger()) + if bootstrap.GetMode() == "cluster" { + ll.Infof("start cluster mode") + return buildRemoteInjectors(r, bootstrap) + } else { + ll.Infof("start local mode") + return buildLocalInjectors(r, bootstrap) + } +} diff --git a/cmd/internal/start/wire.go b/cmd/internal/start/wire.go index aea25a7c..6eb0d662 100644 --- a/cmd/internal/start/wire.go +++ b/cmd/internal/start/wire.go @@ -14,18 +14,37 @@ import ( "github.com/origadmin/runtime" "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/loader" + authbiz "origadmin/application/admin/internal/mods/auth/biz" + authdal "origadmin/application/admin/internal/mods/auth/dal" authservice "origadmin/application/admin/internal/mods/auth/service" + systembiz "origadmin/application/admin/internal/mods/system/biz" + systemdal "origadmin/application/admin/internal/mods/system/dal" systemservice "origadmin/application/admin/internal/mods/system/service" ) // buildInjectors init kratos application. -func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { +func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { panic(wire.Build( loader.ProviderSet, //agent.ProviderSet, + data.ProviderSet, + systemdal.ProviderSet, + systembiz.ProviderSet, systemservice.ProviderSet, + //systemserver.ProviderSet, + authdal.ProviderSet, + authbiz.ProviderSet, authservice.ProviderSet, - //basisserver.ProviderSet, NewApp)) } + +func buildRemoteInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { + panic(wire.Build( + loader.ProviderSet, + systemservice.RemoteProviderSet, + authservice.RemoteProviderSet, + NewApp, + )) +} diff --git a/cmd/internal/start/wire_gen.go b/cmd/internal/start/wire_gen.go index e5ec4d25..77fd03ee 100644 --- a/cmd/internal/start/wire_gen.go +++ b/cmd/internal/start/wire_gen.go @@ -10,7 +10,14 @@ import ( "github.com/go-kratos/kratos/v2" "github.com/origadmin/runtime" "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/loader" + biz2 "origadmin/application/admin/internal/mods/auth/biz" + dal2 "origadmin/application/admin/internal/mods/auth/dal" + service2 "origadmin/application/admin/internal/mods/auth/service" + "origadmin/application/admin/internal/mods/system/biz" + "origadmin/application/admin/internal/mods/system/dal" + "origadmin/application/admin/internal/mods/system/service" ) import ( @@ -22,12 +29,82 @@ import ( // Injectors from wire.go: // buildInjectors init kratos application. -func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { - server := loader.MockHttpServer() - injectorClient := &loader.InjectorClient{ - Server: server, +func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { + dataData, cleanup, err := data.NewData(r, bootstrap) + if err != nil { + return nil, nil, err } - app := NewApp(r, injectorClient) + resourceRepo := dal.NewResourceRepo(r, dataData) + resourceServiceBiz := biz.NewResourceServiceBiz(r, resourceRepo) + resourceServiceServer := service.NewResourceServiceServerPB(r, resourceServiceBiz) + roleRepo := dal.NewRoleRepo(r, dataData) + roleServiceBiz := biz.NewRoleServiceBiz(r, roleRepo) + roleServiceServer := service.NewRoleServiceServerPB(r, roleServiceBiz) + userRepo := dal.NewUserRepo(r, dataData) + userServiceBiz := biz.NewUserServiceBiz(r, userRepo) + userServiceServer := service.NewUserServiceServerPB(r, userServiceBiz) + permissionRepo := dal.NewPermissionRepo(r, dataData) + permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) + permissionServiceServer := service.NewPermissionServiceServerPB(r, permissionServiceBiz) + registerServer := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + authRepo := dal2.NewAuthRepo(r, dataData) + authServiceBiz := biz2.NewAuthServiceBiz(r, authRepo) + authServiceServer := service2.NewAuthServiceServerPB(authServiceBiz) + casbinSourceRepo, err := dal2.NewCasbinSourceRepo(dataData) + if err != nil { + cleanup() + return nil, nil, err + } + casbinSourceServiceBiz := biz2.NewCasbinSourceServiceBiz(r, casbinSourceRepo) + casbinSourceServiceServer := service2.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) + tokenizer, err := data.NewTokenizer(bootstrap) + if err != nil { + cleanup() + return nil, nil, err + } + refreshTokenizer := dal2.RefreshTokenizer(tokenizer) + loginData := data.NewLoginData(bootstrap, refreshTokenizer) + loginRepo := dal2.NewLoginRepo(dataData, loginData) + loginServiceBiz := biz2.NewLoginServiceBiz(r, loginRepo) + loginServiceServer := service2.NewLoginServiceServerPB(loginServiceBiz) + personalRepo := dal2.NewPersonalRepo(r, dataData) + personalServiceBiz := biz2.NewPersonalServiceBiz(r, personalRepo) + personalServiceServer := service2.NewPersonalServiceServerPB(r, personalServiceBiz) + serviceRegisterServer := service2.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) + v := loader.NewServiceServerRegistrars(registerServer, serviceRegisterServer) + ruleSource := service2.NewCasbinSourceBiz(r, casbinSourceServiceBiz) + proxyOptions, err := loader.NewProxyOptions(r, bootstrap, ruleSource) + if err != nil { + cleanup() + return nil, nil, err + } + v2 := loader.NewProxyServer(r, bootstrap, v, proxyOptions) + app := NewApp(r, v2) + return app, func() { + cleanup() + }, nil +} + +func buildRemoteInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { + v := loader.NewProxyGRPCClients(r, bootstrap) + resourceServiceServer := service.NewResourceServiceBridgeClient(r, v) + roleServiceServer := service.NewRoleServiceBridgeClient(r, v) + userServiceServer := service.NewUserServiceBridgeClient(r, v) + permissionServiceServer := service.NewPermissionServiceBridgeClient(r, v) + registerServer := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + authServiceServer := service2.NewAuthServiceBridgeClient(r, v) + casbinSourceServiceServer := service2.NewCasbinServiceBridgeClient(r, v) + loginServiceServer := service2.NewLoginServiceBridgeClient(r, v) + personalServiceServer := service2.NewPersonalServiceBridgeClient(r, v) + serviceRegisterServer := service2.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) + v2 := loader.NewServiceServerRegistrars(registerServer, serviceRegisterServer) + ruleSource := service2.NewCasbinSourceClient(r, v) + proxyOptions, err := loader.NewProxyOptions(r, bootstrap, ruleSource) + if err != nil { + return nil, nil, err + } + v3 := loader.NewProxyServer(r, bootstrap, v2, proxyOptions) + app := NewApp(r, v3) return app, func() { }, nil } diff --git a/cmd/system/wire.go b/cmd/system/wire.go index 58a63762..680ec4f5 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -26,10 +26,6 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap panic(wire.Build( //loader.ProviderSet, data.ProviderSet, - //authdal.ProviderSet, - //basisbiz.ProviderSet, - //basisservice.ProviderSet, - //basisserver.ProviderSet, systemdal.ProviderSet, systembiz.ProviderSet, systemservice.ProviderSet, diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index 92312c14..b82cd904 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -43,8 +43,8 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap permissionRepo := dal.NewPermissionRepo(r, dataData) permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) permissionServiceServer := service.NewPermissionServiceServerPB(r, permissionServiceBiz) - serverRegistrar := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) - v := server.NewSystemServer(r, bootstrap, serverRegistrar) + registerServer := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + v := server.NewSystemServer(r, bootstrap, registerServer) app := NewApp(r, v) return app, func() { cleanup() diff --git a/contrib/security/authn/jwt/jwt.go b/contrib/security/authn/jwt/jwt.go index d799ccee..9211230f 100644 --- a/contrib/security/authn/jwt/jwt.go +++ b/contrib/security/authn/jwt/jwt.go @@ -16,8 +16,8 @@ import ( jwtv5 "github.com/golang-jwt/jwt/v5" configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/runtime/log" ) const ( diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index 3a803746..4e02e01d 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -13,11 +13,11 @@ import ( "github.com/goexts/generic/cmp" "github.com/goexts/generic/maps" "github.com/goexts/generic/settings" - "github.com/origadmin/runtime/context" configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/errors" - "github.com/origadmin/runtime/interfaces/security" "github.com/prometheus/client_golang/prometheus" ) @@ -139,8 +139,8 @@ func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Aut } options := settings.ApplyDefault(DefaultAuthorizerOptions, ss) - if options.ServiceClient == nil { - return nil, errors.New("authorizer casbin client is empty") + if options.Source == nil { + return nil, errors.New("authorizer casbin source is empty") } err := options.Setup() if err != nil { @@ -148,7 +148,7 @@ func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Aut } updater := &PolicyUpdater{ - client: options.ServiceClient, + source: options.Source, adapter: options.Adapter, interval: options.SyncInterval, metric: options.EnablePrometheus, diff --git a/contrib/security/authz/casbin/option.go b/contrib/security/authz/casbin/option.go index aa8d9c0f..216f833a 100644 --- a/contrib/security/authz/casbin/option.go +++ b/contrib/security/authz/casbin/option.go @@ -11,7 +11,6 @@ import ( casbinmodel "github.com/casbin/casbin/v2/model" "github.com/casbin/casbin/v2/persist" - pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/contrib/security/authz/casbin/internal/model" ) @@ -21,7 +20,7 @@ import ( // Watcher: Optional, policy change watcher // Enforcer: Optional, existing synced enforcer instance // SyncInterval: Optional, policy sync interval (default 5s) -// ServiceClient: gRPC client for policy data service +// Source: gRPC source for policy data service // WildcardItem: Permission matching wildcard (default "*") type AuthorizerOptions struct { Model casbinmodel.Model @@ -29,7 +28,7 @@ type AuthorizerOptions struct { Watcher persist.Watcher Enforcer *casbin.SyncedEnforcer SyncInterval time.Duration - ServiceClient pb.CasbinSourceServiceClient + Source RuleSource WildcardItem string EnablePrometheus bool } @@ -128,11 +127,11 @@ func WithWildcardItem(item string) AuthorizerOption { } } -// WithServiceClient sets gRPC policy source service client -// client: gRPC client implementing CasbinSourceService -func WithServiceClient(client pb.CasbinSourceServiceClient) AuthorizerOption { +// WithSource sets gRPC policy source service source +// source: gRPC source implementing CasbinSourceService +func WithSource(source RuleSource) AuthorizerOption { return func(s *AuthorizerOptions) { - s.ServiceClient = client + s.Source = source } } diff --git a/contrib/security/authz/casbin/update.go b/contrib/security/authz/casbin/update.go index be6d4ec2..46958792 100644 --- a/contrib/security/authz/casbin/update.go +++ b/contrib/security/authz/casbin/update.go @@ -17,13 +17,21 @@ import ( "github.com/goexts/generic/maps" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" + "google.golang.org/grpc" "google.golang.org/grpc/status" pb "origadmin/application/admin/api/v1/services/auth" ) +type RuleSource interface { + ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) + ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) + WatchUpdate(ctx context.Context, in *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) + StreamRules(ctx context.Context, in *pb.StreamRulesRequest) (grpc.ServerStreamingClient[pb.StreamRulesResponse], error) +} + type PolicyUpdater struct { - client pb.CasbinSourceServiceClient + source RuleSource adapter persist.Adapter enforcer *casbin.SyncedEnforcer lastModified int64 @@ -39,7 +47,7 @@ func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { } }() - update, err := u.client.WatchUpdate(ctx, &pb.WatchUpdateRequest{ + update, err := u.source.WatchUpdate(ctx, &pb.WatchUpdateRequest{ LastModified: u.lastModified, }) if err != nil { @@ -49,7 +57,8 @@ func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { return false, nil } fmt.Printf("Received update: %v to %v\n", u.lastModified, update.ModifiedDate) - stream, err := u.client.StreamRules(ctx, &pb.StreamRulesRequest{ + + stream, err := u.source.StreamRules(ctx, &pb.StreamRulesRequest{ WithGroupings: true, WithPolicies: true, }) @@ -115,7 +124,7 @@ func (u *PolicyUpdater) Watch(ctx context.Context, notifier persist.Watcher) { select { case <-ticker.C: if update, err := u.Sync(ctx); err != nil || !update { - log.Errorf("Policy sync failed: err(%v) update(%t)", err, update) + //log.Errorf("Policy sync failed: err(%v) update(%t)", err, update) continue } _ = notifier.Update() diff --git a/helpers/securityx/security.go b/helpers/securityx/security.go index bd946a79..857abbc4 100644 --- a/helpers/securityx/security.go +++ b/helpers/securityx/security.go @@ -273,20 +273,35 @@ func FromTransportServer(authorize string, scheme string) func(ctx context.Conte } } +type provider struct { +} + +func (p provider) QueryRoles(ctx context.Context, subject string) ([]string, error) { + return []string{}, nil +} + +func (p provider) QueryPermissions(ctx context.Context, subject string) ([]string, error) { + return []string{}, nil +} + func DefaultBridge() *SecurityBridge { bridge := SecurityBridge{ TokenSource: security.TokenSourceHeader, Scheme: security.SchemeBearer, AuthenticationHeader: security.HeaderAuthorize, + Authenticator: nil, + Authorizer: nil, SkipKey: msecurity.MetadataSecuritySkipKey, PublicPaths: nil, + Provider: &provider{}, Skipper: func(path string) bool { return false }, IsRoot: func(ctx context.Context, claims security.Claims) bool { return claims.GetSubject() == "root" || claims.GetSubject() == "admin" }, - TokenParser: nil, + TokenParser: nil, + PolicyParser: nil, } return &bridge } diff --git a/internal/configs/bootstrap.pb.go b/internal/configs/bootstrap.pb.go index f8331b01..389b925e 100644 --- a/internal/configs/bootstrap.pb.go +++ b/internal/configs/bootstrap.pb.go @@ -350,7 +350,7 @@ func (x *Bootstrap_HealthCheck) GetPath() string { type Bootstrap_Entry struct { state protoimpl.MessageState `protogen:"open.v1"` Scheme string `protobuf:"bytes,1,opt,name=scheme,proto3" json:"scheme,omitempty"` - Server *v1.Service `protobuf:"bytes,2,opt,name=server,proto3" json:"server,omitempty"` + Services []*v1.Service `protobuf:"bytes,2,rep,name=services,proto3" json:"services,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -392,9 +392,9 @@ func (x *Bootstrap_Entry) GetScheme() string { return "" } -func (x *Bootstrap_Entry) GetServer() *v1.Service { +func (x *Bootstrap_Entry) GetServices() []*v1.Service { if x != nil { - return x.Server + return x.Services } return nil } @@ -407,7 +407,7 @@ const file_configs_bootstrap_proto_rawDesc = "" + "\x13EntrySelectorConfig\x12\x16\n" + "\x06global\x18\x02 \x01(\bR\x06global\x12\x12\n" + "\x04name\x18\x03 \x01(\tR\x04name\x12\x18\n" + - "\aversion\x18\x04 \x01(\tR\aversion\"\xfb\x06\n" + + "\aversion\x18\x04 \x01(\tR\aversion\"\xff\x06\n" + "\tBootstrap\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x02 \x01(\tR\aversion\x12 \n" + @@ -430,10 +430,10 @@ const file_configs_bootstrap_proto_rawDesc = "" + "\aclients\x18\xee\a \x03(\v2\x1a.api.configs.ServiceClientR\aclients\x1a;\n" + "\vHealthCheck\x12\x18\n" + "\atimeout\x18\x01 \x01(\x05R\atimeout\x12\x12\n" + - "\x04path\x18\x02 \x01(\tR\x04path\x1aK\n" + + "\x04path\x18\x02 \x01(\tR\x04path\x1aO\n" + "\x05Entry\x12\x16\n" + - "\x06scheme\x18\x01 \x01(\tR\x06scheme\x12*\n" + - "\x06server\x18\x02 \x01(\v2\x12.config.v1.ServiceR\x06server\",\n" + + "\x06scheme\x18\x01 \x01(\tR\x06scheme\x12.\n" + + "\bservices\x18\x02 \x03(\v2\x12.config.v1.ServiceR\bservices\",\n" + "\bSettings\x12 \n" + "\vcrypto_type\x18\x01 \x01(\tR\vcrypto_typeB.Z,origadmin/application/admin/internal/configsb\x06proto3" @@ -475,7 +475,7 @@ var file_configs_bootstrap_proto_depIdxs = []int32{ 9, // 6: api.configs.Bootstrap.logger:type_name -> config.v1.Logger 10, // 7: api.configs.Bootstrap.server:type_name -> api.configs.ServiceServer 11, // 8: api.configs.Bootstrap.clients:type_name -> api.configs.ServiceClient - 12, // 9: api.configs.Bootstrap.Entry.server:type_name -> config.v1.Service + 12, // 9: api.configs.Bootstrap.Entry.services:type_name -> config.v1.Service 10, // [10:10] is the sub-list for method output_type 10, // [10:10] is the sub-list for method input_type 10, // [10:10] is the sub-list for extension type_name diff --git a/internal/configs/bootstrap.pb.validate.go b/internal/configs/bootstrap.pb.validate.go index c55447ed..37ec2308 100644 --- a/internal/configs/bootstrap.pb.validate.go +++ b/internal/configs/bootstrap.pb.validate.go @@ -781,33 +781,38 @@ func (m *Bootstrap_Entry) validate(all bool) error { // no validation rules for Scheme - if all { - switch v := interface{}(m.GetServer()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, Bootstrap_EntryValidationError{ - field: "Server", - reason: "embedded message failed validation", - cause: err, - }) + for idx, item := range m.GetServices() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, Bootstrap_EntryValidationError{ + field: fmt.Sprintf("Services[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, Bootstrap_EntryValidationError{ + field: fmt.Sprintf("Services[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } } - case interface{ Validate() error }: + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - errors = append(errors, Bootstrap_EntryValidationError{ - field: "Server", + return Bootstrap_EntryValidationError{ + field: fmt.Sprintf("Services[%v]", idx), reason: "embedded message failed validation", cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetServer()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return Bootstrap_EntryValidationError{ - field: "Server", - reason: "embedded message failed validation", - cause: err, + } } } + } if len(errors) > 0 { diff --git a/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto index 56129eb6..7637a145 100644 --- a/internal/configs/bootstrap.proto +++ b/internal/configs/bootstrap.proto @@ -53,7 +53,7 @@ message Bootstrap { // Entry message Entry { string scheme = 1 [json_name = "scheme"]; - config.v1.Service server = 2 [json_name = "server"]; + repeated config.v1.Service services = 2 [json_name = "services"]; } string id = 100 [json_name = "id"]; diff --git a/internal/configs/service.pb.go b/internal/configs/service.pb.go index 567076ff..b14745f1 100644 --- a/internal/configs/service.pb.go +++ b/internal/configs/service.pb.go @@ -154,6 +154,7 @@ func (x *ServiceServer) GetMiddleware() *v11.Middleware { type ServiceClient struct { state protoimpl.MessageState `protogen:"open.v1"` Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` + Services []*v1.Service `protobuf:"bytes,200,rep,name=services,proto3" json:"services,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -195,6 +196,13 @@ func (x *ServiceClient) GetCore() *ServiceCore { return nil } +func (x *ServiceClient) GetServices() []*v1.Service { + if x != nil { + return x.Services + } + return nil +} + var File_configs_service_proto protoreflect.FileDescriptor const file_configs_service_proto_rawDesc = "" + @@ -210,9 +218,10 @@ const file_configs_service_proto_rawDesc = "" + "\bservices\x18\xc8\x01 \x03(\v2\x12.config.v1.ServiceR\bservices\x12:\n" + "\n" + "middleware\x18\xac\x02 \x01(\v2\x19.middleware.v1.MiddlewareR\n" + - "middleware\"=\n" + + "middleware\"n\n" + "\rServiceClient\x12,\n" + - "\x04core\x18\x01 \x01(\v2\x18.api.configs.ServiceCoreR\x04coreB.Z,origadmin/application/admin/internal/configsb\x06proto3" + "\x04core\x18\x01 \x01(\v2\x18.api.configs.ServiceCoreR\x04core\x12/\n" + + "\bservices\x18\xc8\x01 \x03(\v2\x12.config.v1.ServiceR\bservicesB.Z,origadmin/application/admin/internal/configsb\x06proto3" var ( file_configs_service_proto_rawDescOnce sync.Once @@ -243,11 +252,12 @@ var file_configs_service_proto_depIdxs = []int32{ 5, // 3: api.configs.ServiceServer.services:type_name -> config.v1.Service 6, // 4: api.configs.ServiceServer.middleware:type_name -> middleware.v1.Middleware 0, // 5: api.configs.ServiceClient.core:type_name -> api.configs.ServiceCore - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 5, // 6: api.configs.ServiceClient.services:type_name -> config.v1.Service + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_configs_service_proto_init() } diff --git a/internal/configs/service.pb.validate.go b/internal/configs/service.pb.validate.go index b4d9cf1c..94c7011d 100644 --- a/internal/configs/service.pb.validate.go +++ b/internal/configs/service.pb.validate.go @@ -444,6 +444,40 @@ func (m *ServiceClient) validate(all bool) error { } } + for idx, item := range m.GetServices() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ServiceClientValidationError{ + field: fmt.Sprintf("Services[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ServiceClientValidationError{ + field: fmt.Sprintf("Services[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ServiceClientValidationError{ + field: fmt.Sprintf("Services[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + if len(errors) > 0 { return ServiceClientMultiError(errors) } diff --git a/internal/configs/service.proto b/internal/configs/service.proto index 94cf83c6..da6a417c 100644 --- a/internal/configs/service.proto +++ b/internal/configs/service.proto @@ -24,4 +24,5 @@ message ServiceServer { message ServiceClient { ServiceCore core = 1 [json_name = "core"]; + repeated config.v1.Service services = 200 [json_name = "services"]; } \ No newline at end of file diff --git a/internal/data/casbin-adapter.dal.go b/internal/data/casbin-adapter.dal.go index c49cca72..489fd092 100644 --- a/internal/data/casbin-adapter.dal.go +++ b/internal/data/casbin-adapter.dal.go @@ -15,6 +15,7 @@ import ( entsql "entgo.io/ent/dialect/sql" "github.com/casbin/casbin/v2/model" "github.com/casbin/casbin/v2/persist" + "github.com/goexts/generic/settings" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/casbinrule" @@ -26,20 +27,20 @@ const ( DefaultDatabase = "casbin" ) -type casbinAdapterRepo struct { +type casbinRepo struct { ctx context.Context data *Data filtered bool } -type CasbinAdapterSetting struct { +type CasbinOptions struct { filtered bool } -type Option = func(a *CasbinAdapterSetting) error +type Option = func(a *CasbinOptions) error func WithFiltered(filtered bool) Option { - return func(a *CasbinAdapterSetting) error { + return func(a *CasbinOptions) error { a.filtered = filtered return nil } @@ -71,27 +72,25 @@ func open(driverName, dataSourceName string) (*ent.Client, error) { // NewAdapter returns an adapter by driver name and data source string. func NewAdapter(data *Data, options ...Option) (persist.Adapter, error) { - a := &casbinAdapterRepo{ + a := &casbinRepo{ data: data, filtered: false, } - var setting CasbinAdapterSetting - for _, option := range options { - if err := option(&setting); err != nil { - return nil, err - } + opts, err := settings.ApplyE(&CasbinOptions{}, options) + if err != nil { + return nil, err } - a.filtered = setting.filtered + a.filtered = opts.filtered return a, nil } // NewAdapterWithClient create an adapter with client passed in. // This method does not ensure the existence of database, user should create database manually. func NewAdapterWithClient(client *ent.Client, options ...Option) (persist.Adapter, error) { - a := &casbinAdapterRepo{ + a := &casbinRepo{ data: NewDataWithClient(client), } - var setting CasbinAdapterSetting + var setting CasbinOptions for _, option := range options { if err := option(&setting); err != nil { return nil, err @@ -102,7 +101,7 @@ func NewAdapterWithClient(client *ent.Client, options ...Option) (persist.Adapte } // LoadPolicy loads all policy rules from the storage. -func (repo *casbinAdapterRepo) LoadPolicy(model model.Model) error { +func (repo *casbinRepo) LoadPolicy(model model.Model) error { policies, err := repo.data.CasbinRule(repo.ctx).Query().Order(ent.Asc("id")).All(repo.ctx) if err != nil { return err @@ -115,7 +114,7 @@ func (repo *casbinAdapterRepo) LoadPolicy(model model.Model) error { // LoadFilteredPolicy loads only policy rules that match the filter. // Filter parameter here is a Filter structure -func (repo *casbinAdapterRepo) LoadFilteredPolicy(model model.Model, filter interface{}) error { +func (repo *casbinRepo) LoadFilteredPolicy(model model.Model, filter interface{}) error { filterValue, ok := filter.(Filter) if !ok { return fmt.Errorf("invalid filter type: %v", reflect.TypeOf(filter)) @@ -157,12 +156,12 @@ func (repo *casbinAdapterRepo) LoadFilteredPolicy(model model.Model, filter inte } // IsFiltered returns true if the loaded policy has been filtered. -func (repo *casbinAdapterRepo) IsFiltered() bool { +func (repo *casbinRepo) IsFiltered() bool { return repo.filtered } // SavePolicy saves all policy rules to the storage. -func (repo *casbinAdapterRepo) SavePolicy(model model.Model) error { +func (repo *casbinRepo) SavePolicy(model model.Model) error { return repo.data.Tx(repo.ctx, func(ctx context.Context) error { if _, err := repo.data.CasbinRule(ctx).Delete().Exec(repo.ctx); err != nil { return err @@ -191,7 +190,7 @@ func (repo *casbinAdapterRepo) SavePolicy(model model.Model) error { // AddPolicy adds a policy rule to the storage. // This is part of the Auto-Save feature. -func (repo *casbinAdapterRepo) AddPolicy(sec string, ptype string, rule []string) error { +func (repo *casbinRepo) AddPolicy(sec string, ptype string, rule []string) error { return repo.data.Tx(repo.ctx, func(ctx context.Context) error { _, err := repo.savePolicyLine(ctx, ptype, rule).Save(repo.ctx) return err @@ -200,7 +199,7 @@ func (repo *casbinAdapterRepo) AddPolicy(sec string, ptype string, rule []string // RemovePolicy removes a policy rule from the storage. // This is part of the Auto-Save feature. -func (repo *casbinAdapterRepo) RemovePolicy(sec string, ptype string, rule []string) error { +func (repo *casbinRepo) RemovePolicy(sec string, ptype string, rule []string) error { return repo.data.Tx(repo.ctx, func(ctx context.Context) error { instance := repo.toInstance(ptype, rule) _, err := repo.data.CasbinRule(ctx).Delete().Where( @@ -218,7 +217,7 @@ func (repo *casbinAdapterRepo) RemovePolicy(sec string, ptype string, rule []str // RemoveFilteredPolicy removes policy rules that match the filter from the storage. // This is part of the Auto-Save feature. -func (repo *casbinAdapterRepo) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error { +func (repo *casbinRepo) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error { return repo.data.Tx(repo.ctx, func(ctx context.Context) error { cond := make([]predicate.CasbinRule, 0) cond = append(cond, casbinrule.PtypeEQ(ptype)) @@ -247,7 +246,7 @@ func (repo *casbinAdapterRepo) RemoveFilteredPolicy(sec string, ptype string, fi // AddPolicies adds policy rules to the storage. // This is part of the Auto-Save feature. -func (repo *casbinAdapterRepo) AddPolicies(sec string, ptype string, rules [][]string) error { +func (repo *casbinRepo) AddPolicies(sec string, ptype string, rules [][]string) error { return repo.data.Tx(repo.ctx, func(ctx context.Context) error { return repo.createPolicies(ctx, ptype, rules) }) @@ -255,7 +254,7 @@ func (repo *casbinAdapterRepo) AddPolicies(sec string, ptype string, rules [][]s // RemovePolicies removes policy rules from the storage. // This is part of the Auto-Save feature. -func (repo *casbinAdapterRepo) RemovePolicies(sec string, ptype string, rules [][]string) error { +func (repo *casbinRepo) RemovePolicies(sec string, ptype string, rules [][]string) error { return repo.data.Tx(repo.ctx, func(ctx context.Context) error { for _, rule := range rules { instance := repo.toInstance(ptype, rule) @@ -299,7 +298,7 @@ func loadPolicyLine(line *ent.CasbinRule, model model.Model) { persist.LoadPolicyLine(lineText, model) } -func (repo *casbinAdapterRepo) toInstance(ptype string, rule []string) *ent.CasbinRule { +func (repo *casbinRepo) toInstance(ptype string, rule []string) *ent.CasbinRule { instance := &ent.CasbinRule{} instance.Ptype = ptype @@ -325,7 +324,7 @@ func (repo *casbinAdapterRepo) toInstance(ptype string, rule []string) *ent.Casb return instance } -func (repo *casbinAdapterRepo) savePolicyLine(ctx context.Context, ptype string, rule []string) *ent.CasbinRuleCreate { +func (repo *casbinRepo) savePolicyLine(ctx context.Context, ptype string, rule []string) *ent.CasbinRuleCreate { line := repo.data.CasbinRule(ctx).Create() line.SetPtype(ptype) @@ -353,7 +352,7 @@ func (repo *casbinAdapterRepo) savePolicyLine(ctx context.Context, ptype string, // UpdatePolicy updates a policy rule from storage. // This is part of the Auto-Save feature. -func (repo *casbinAdapterRepo) UpdatePolicy(sec string, ptype string, oldRule, newPolicy []string) error { +func (repo *casbinRepo) UpdatePolicy(sec string, ptype string, oldRule, newPolicy []string) error { return repo.data.Tx(repo.ctx, func(ctx context.Context) error { rule := repo.toInstance(ptype, oldRule) line := repo.data.CasbinRule(ctx).Update().Where( @@ -378,7 +377,7 @@ func (repo *casbinAdapterRepo) UpdatePolicy(sec string, ptype string, oldRule, n } // UpdatePolicies updates some policy rules to storage, like db, redis. -func (repo *casbinAdapterRepo) UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) error { +func (repo *casbinRepo) UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) error { return repo.data.Tx(repo.ctx, func(ctx context.Context) error { for _, policy := range oldRules { rule := repo.toInstance(ptype, policy) @@ -406,7 +405,7 @@ func (repo *casbinAdapterRepo) UpdatePolicies(sec string, ptype string, oldRules } // UpdateFilteredPolicies deletes old rules and adds new rules. -func (repo *casbinAdapterRepo) UpdateFilteredPolicies(sec string, ptype string, newPolicies [][]string, fieldIndex int, +func (repo *casbinRepo) UpdateFilteredPolicies(sec string, ptype string, newPolicies [][]string, fieldIndex int, fieldValues ...string) ([][]string, error) { oldPolicies := make([][]string, 0) err := repo.data.Tx(repo.ctx, func(ctx context.Context) error { @@ -460,7 +459,7 @@ func (repo *casbinAdapterRepo) UpdateFilteredPolicies(sec string, ptype string, return oldPolicies, nil } -func (repo *casbinAdapterRepo) createPolicies(ctx context.Context, ptype string, policies [][]string) error { +func (repo *casbinRepo) createPolicies(ctx context.Context, ptype string, policies [][]string) error { lines := make([]*ent.CasbinRuleCreate, 0) for _, policy := range policies { lines = append(lines, repo.savePolicyLine(ctx, ptype, policy)) diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go index c89da621..e44acf68 100644 --- a/internal/loader/bootstrap_default.go +++ b/internal/loader/bootstrap_default.go @@ -26,7 +26,7 @@ const ( func DefaultBootstrap() *configs.Bootstrap { return &configs.Bootstrap{ - Name: "origadmin.agent.service.admin.v1", + Name: "origadmin.service.admin.v1", Mode: "singleton", Version: "v1.0.0", CryptoType: "argon2", @@ -35,41 +35,13 @@ func DefaultBootstrap() *configs.Bootstrap { //}, Id: "", Entry: &configs.Bootstrap_Entry{ - Scheme: "http", + Scheme: "http", + Services: DefaultServices(), }, Server: &configs.ServiceServer{ - Services: []*configv1.Service{ - { - Name: "", - DynamicEndpoint: true, - Type: "grpc", - Grpc: DefaultServiceGrpc(), - //Http: DefaultServiceHttp(), - Websocket: DefaultServiceWebsocket(), - Message: DefaultServiceMessage(), - Task: DefaultServiceTask(), - Middleware: DefaultServiceMiddleware(), - Selector: &configv1.Service_Selector{ - Version: "v1.0.0", - Builder: "bbr", - }, - }, - { - Name: "", - DynamicEndpoint: true, - Type: "http", - Http: DefaultServiceHttp(), - Websocket: DefaultServiceWebsocket(), - Message: DefaultServiceMessage(), - Task: DefaultServiceTask(), - Middleware: DefaultServiceMiddleware(), - Selector: &configv1.Service_Selector{ - Version: "v1.0.0", - Builder: "bbr", - }, - }, - }, + Services: DefaultServices(), }, + Clients: DefaultServiceClients(), Logger: DefaultLogger(), Storage: DefaultStorage(), Discovery: DefaultDiscovery(), @@ -127,6 +99,59 @@ func DefaultBootstrap() *configs.Bootstrap { } } +func DefaultServices() []*configv1.Service { + return []*configv1.Service{ + { + Name: "", + DynamicEndpoint: true, + Type: "grpc", + Grpc: DefaultServiceGrpc(), + Websocket: DefaultServiceWebsocket(), + Message: DefaultServiceMessage(), + Task: DefaultServiceTask(), + Middleware: DefaultServiceMiddleware(), + Selector: &configv1.Service_Selector{ + Version: "v1.0.0", + Builder: "bbr", + }, + }, + { + Name: "", + DynamicEndpoint: true, + Type: "http", + Http: DefaultServiceHttp(), + Websocket: DefaultServiceWebsocket(), + Message: DefaultServiceMessage(), + Task: DefaultServiceTask(), + Middleware: DefaultServiceMiddleware(), + Selector: &configv1.Service_Selector{ + Version: "v1.0.0", + Builder: "bbr", + }, + }, + } +} + +func DefaultServiceClients() []*configs.ServiceClient { + serviceNames := map[string]string{ + "system": "origadmin.service.system.v1", + "auth": "origadmin.service.auth.v1", + } + clients := make([]*configs.ServiceClient, 0, len(serviceNames)) + for name, serviceName := range serviceNames { + core := &configs.ServiceCore{ + Name: name, + Discovery: DefaultDiscovery(), + } + core.Discovery.ServiceName = serviceName + clients = append(clients, &configs.ServiceClient{ + Core: core, + Services: DefaultServices(), + }) + } + return clients +} + func DefaultLogger() *configv1.Logger { return &configv1.Logger{ Disabled: false, diff --git a/internal/loader/file.go b/internal/loader/file.go index 5135ceb8..77870163 100644 --- a/internal/loader/file.go +++ b/internal/loader/file.go @@ -7,6 +7,7 @@ package loader import ( "encoding/json" + "fmt" "os" "path/filepath" "strings" @@ -96,6 +97,8 @@ func NewFileConfig(sourceConfig *configv1.SourceConfig, _ *config.Options) (conf func fileFormatter(typo any) file.Formatter { return func(key string, value []byte) (*config.KKeyValue, error) { + fmt.Printf("loading config from %s\n", key) + // Don't forget to register the codec err := encoding.GetCodec(format(key)).Unmarshal(value, typo) if err != nil { return nil, errors.Wrap(err, "unmarshal config") diff --git a/internal/loader/load.go b/internal/loader/load.go index 2d53979c..4e586afd 100644 --- a/internal/loader/load.go +++ b/internal/loader/load.go @@ -15,9 +15,11 @@ import ( configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/registry" + "github.com/origadmin/runtime/service" "origadmin/application/admin/internal/configs" + authservice "origadmin/application/admin/internal/mods/auth/service" + systemservice "origadmin/application/admin/internal/mods/system/service" ) // AppOptions 包含微服务核心配置 @@ -32,10 +34,11 @@ type AppOptions struct { var ( ProviderSet = wire.NewSet( - NewRegistrar, + NewServiceServerRegistrars, + NewProxyOptions, NewProxyServer, - wire.Struct(new(Injector), "*"), - wire.Struct(new(InjectorClient), "*"), + NewProxyGRPCClients, + NewProxyHTTPClients, ) ) @@ -45,6 +48,16 @@ var ( _ *grpc.Server ) +func NewServiceServerRegistrars( + system *systemservice.RegisterServer, + auth *authservice.RegisterServer, +) []service.ServerRegistrar { + return []service.ServerRegistrar{ + system, + auth, + } +} + type Loader interface { SetupEnv() error } @@ -53,10 +66,10 @@ type InjectorClient struct { Server *http.Server } -type Injector struct { - Registrar registry.KRegistrar - Servers []transport.Server -} +//type Injector struct { +// Registrar registry.KRegistrar +// Registrars []service.ServerRegistrar +//} func init() { runtime.RegisterConfigFunc("file", NewFileConfig) @@ -84,7 +97,3 @@ func NewLoader(bs *bootstrap.Bootstrap) (Loader, error) { } return load, nil } - -func MockHttpServer() *http.Server { - return http.NewServer() -} diff --git a/internal/loader/proxy.go b/internal/loader/proxy.go index bec8370d..96eb171d 100644 --- a/internal/loader/proxy.go +++ b/internal/loader/proxy.go @@ -14,12 +14,12 @@ import ( "github.com/go-kratos/kratos/v2/transport/http" "github.com/gorilla/handlers" "github.com/origadmin/runtime" - msecurity "github.com/origadmin/runtime/agent/middleware/security" "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/middleware" "github.com/origadmin/runtime/service" + servicegrpc "github.com/origadmin/runtime/service/grpc" servicehttp "github.com/origadmin/runtime/service/http" "origadmin/application/admin/api/v1/services/auth" @@ -29,58 +29,48 @@ import ( "origadmin/application/admin/internal/configs" ) -type data struct { +type ProxyOptions struct { + Authenticator security.Authenticator + Authorizer security.Authorizer } -func (d data) QueryRoles(ctx context.Context, subject string) ([]string, error) { - //TODO implement me - panic("implement me") -} +func NewProxyOptions(r runtime.Runtime, bootstrap *configs.Bootstrap, + source casbin.RuleSource) (*ProxyOptions, error) { + authenticator, err := securityx.NewAuthenticator(bootstrap) + if err != nil { + return nil, err + } + opts := []casbin.AuthorizerOption{ + casbin.WithSource(source), + } -func (d data) QueryPermissions(ctx context.Context, subject string) ([]string, error) { - //TODO implement me - panic("implement me") + authorizer, err := securityx.NewAuthorizer(bootstrap, opts...) + if err != nil { + return nil, err + } + return &ProxyOptions{ + Authenticator: authenticator, + Authorizer: authorizer, + }, nil } // NewProxyServer creates a new proxy server. -func NewProxyServer(r runtime.Runtime, bootstrap *configs.Bootstrap, registrars []service.ServerRegistrar, - client auth.CasbinSourceServiceClient) []transport.Server { - clients := bootstrap.GetClients() - if clients == nil { - panic("no service config") - } +func NewProxyServer( + r runtime.Runtime, + bootstrap *configs.Bootstrap, + registrars []service.ServerRegistrar, + opts *ProxyOptions) []transport.Server { paths := bootstrap.GetSecurity().GetSecurity().GetPublicPaths() paths = append(DefaultPaths(), paths...) ms := []middleware.KMiddleware{ recovery.Recovery(), } - authenticator, err := securityx.NewAuthenticator(bootstrap) - if err != nil { - panic(err) - } - - opts := []casbin.AuthorizerOption{casbin.WithServiceClient(client)} - authorizer, err := securityx.NewAuthorizer(bootstrap, opts...) - if err != nil { - panic(err) - } - bridge := securityx.SecurityBridge{ - TokenSource: security.TokenSourceHeader, - Scheme: security.SchemeBearer, - AuthenticationHeader: security.HeaderAuthorize, - Authenticator: authenticator, - Authorizer: authorizer, - SkipKey: msecurity.MetadataSecuritySkipKey, - PublicPaths: nil, - Skipper: func(path string) bool { - return false - }, - IsRoot: func(ctx context.Context, claims security.Claims) bool { - return claims.GetSubject() == "root" || claims.GetSubject() == "admin" - }, - Provider: &data{}, - TokenParser: nil, + bridge := securityx.DefaultBridge() + bridge.Authenticator = opts.Authenticator + bridge.Authorizer = opts.Authorizer + bridge.IsRoot = func(ctx context.Context, claims security.Claims) bool { + return claims.GetSubject() == "root" || claims.GetSubject() == "admin" } serv := selector.Server(bridge.Middleware()).Match(func(ctx context.Context, operation string) bool { for _, p := range paths { @@ -94,34 +84,42 @@ func NewProxyServer(r runtime.Runtime, bootstrap *configs.Bootstrap, registrars }) ms = append(ms, serv.Build(), CallLoggerMiddleware()) //clients.Get - for i := range clients { - clients[i].GetCore().GetName() - - } + //for i := range clients { + // clients[i].GetCore().GetName() + // + //} //clients.Name = types.ZeroOr(clients.Name, "ORIGADMIN_SERVICE") - srv, err := runtime.NewHTTPServiceServer(bootstrap.GetEntry().GetServer(), - servicehttp.WithServerOptions( - http.ErrorEncoder(resp.ResponseErrorEncoder), - http.Filter(handlers.CORS( - handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), - handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS"}), - handlers.AllowedOrigins([]string{"*"}), - ))), - servicehttp.WithMiddlewares(ms...), - servicehttp.WithPrefix(runtime.DefaultEnvPrefix), - ) - if err != nil { - panic(err) - } - for _, registrar := range registrars { - registrar.Register(r.Context(), srv) + var servers []transport.Server + services := bootstrap.GetEntry().GetServices() + for i := range services { + if services[i].GetType() != "http" { + continue + } + srv, err := runtime.NewHTTPServiceServer(services[i], + servicehttp.WithServerOptions( + http.PathPrefix("/api/v1"), + http.ErrorEncoder(resp.ResponseErrorEncoder), + http.Filter(handlers.CORS( + handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), + handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS"}), + handlers.AllowedOrigins([]string{"*"}), + ))), + servicehttp.WithMiddlewares(ms...), + servicehttp.WithPrefix(runtime.DefaultEnvPrefix), + ) + if err != nil { + panic(err) + } + for _, registrar := range registrars { + registrar.Register(r.Context(), srv) + } + srv.WalkRoute(func(info http.RouteInfo) error { + log.Infof("Registered HTTP route: %s %s", info.Method, info.Path) + return nil + }) + servers = append(servers, srv) } - srv.WalkRoute(func(info http.RouteInfo) error { - log.Infof("Registered HTTP route: %s %s", info.Method, info.Path) - return nil - }) - - return []transport.Server{srv} + return servers } func DefaultPaths() []string { @@ -143,7 +141,7 @@ func CallLoggerMiddleware() middleware.KMiddleware { tr, ok := transport.FromServerContext(ctx) log.Infof("Caller Server: %+v, ok: %+v", tr, ok) tr, ok = transport.FromClientContext(ctx) - log.Infof("Caller ServiceClient: %+v, ok: %+v", tr, ok) + log.Infof("Caller ServiceServer: %+v, ok: %+v", tr, ok) return handler(ctx, req) } } @@ -157,3 +155,60 @@ func CorsMiddleware() middleware.KMiddleware { } } } + +func NewProxyGRPCClients(r runtime.Runtime, bootstrap *configs.Bootstrap) map[string]*service.GRPCClient { + ll := log.NewHelper(r.WithLogger("module", "proxy")) + clients := bootstrap.GetClients() + clientServices := make(map[string]*service.GRPCClient, len(clients)) + for i := range clients { + services := clients[i].GetServices() + if len(services) == 0 { + continue + } + var options []service.GRPCOption + discovery, err := r.Builder().NewDiscovery(clients[i].GetCore().GetDiscovery()) + if err == nil { + options = append(options, servicegrpc.WithDiscovery(clients[i].GetCore().GetDiscovery().GetServiceName(), + discovery)) + } + for idx := range services { + if services[idx].GetType() == "grpc" { + client, err := r.Builder().NewGRPCClient(r.Context(), services[idx], options...) + if err != nil { + ll.Warnf("NewGRPCClient failed: %v", err) + continue + } + clientServices[services[idx].GetName()] = client + } + } + } + return clientServices +} + +func NewProxyHTTPClients(r runtime.Runtime, bootstrap *configs.Bootstrap) map[string]*service.HTTPClient { + ll := log.NewHelper(r.WithLogger("module", "proxy")) + clients := bootstrap.GetClients() + clientServices := make(map[string]*service.HTTPClient, len(clients)) + for i := range clients { + services := clients[i].GetServices() + if len(services) == 0 { + continue + } + var options []service.HTTPOption + discovery, err := r.Builder().NewDiscovery(clients[i].GetCore().GetDiscovery()) + if err == nil { + options = append(options, servicehttp.WithDiscovery(clients[i].GetCore().GetDiscovery().GetServiceName(), discovery)) + } + for idx := range services { + if services[idx].GetType() == "http" { + client, err := r.Builder().NewHTTPClient(r.Context(), services[idx], options...) + if err != nil { + ll.Warnf("NewHTTPClient failed: %v", err) + continue + } + clientServices[services[idx].GetName()] = client + } + } + } + return clientServices +} diff --git a/internal/mods/auth/biz/biz.go b/internal/mods/auth/biz/biz.go index c92144e1..f2c33884 100644 --- a/internal/mods/auth/biz/biz.go +++ b/internal/mods/auth/biz/biz.go @@ -13,6 +13,7 @@ import ( var ProviderSet = wire.NewSet( NewAuthServiceBiz, NewLoginServiceBiz, + NewPersonalServiceBiz, NewCasbinSourceServiceBiz, ) diff --git a/internal/mods/auth/biz/casbin.biz.go b/internal/mods/auth/biz/casbin.biz.go index dc4c7544..9dc73ca5 100644 --- a/internal/mods/auth/biz/casbin.biz.go +++ b/internal/mods/auth/biz/casbin.biz.go @@ -28,7 +28,7 @@ type CasbinSourceServiceBiz struct { } func (c CasbinSourceServiceBiz) StreamRules(request *pb.StreamRulesRequest, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { - log.Info("StreamRules") + c.log.Debug("StreamRules") ctx := stream.Context() if request.WithPolicies { if err := c.streamPolicies(ctx, stream); err != nil { @@ -45,18 +45,18 @@ func (c CasbinSourceServiceBiz) StreamRules(request *pb.StreamRulesRequest, stre } func (c CasbinSourceServiceBiz) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { - log.Info("ListPolicies") + c.log.Debug("ListPolicies") return c.dao.ListPolicies(ctx, in) } func (c CasbinSourceServiceBiz) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { - log.Info("ListGroupings") + c.log.Debug("ListGroupings") return c.dao.ListGroupings(ctx, in) } func (c CasbinSourceServiceBiz) WatchUpdate(_ context.Context, request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { - log.Info("WatchUpdate") + c.log.Debug("WatchUpdate") return &pb.WatchUpdateResponse{ModifiedDate: c.lastModified.Load()}, nil } diff --git a/internal/mods/auth/biz/casbin_stream.biz.go b/internal/mods/auth/biz/casbin_stream.biz.go new file mode 100644 index 00000000..a86f248b --- /dev/null +++ b/internal/mods/auth/biz/casbin_stream.biz.go @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the auth module of OrigAdmin. +package biz + +import ( + "context" + "errors" + "io" + + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" + + pb "origadmin/application/admin/api/v1/services/auth" +) + +// CasbinRuleStream is a CasbinSource use case. +type CasbinRuleStream struct { + ctx context.Context + cancel context.CancelFunc + receiver chan *pb.StreamRulesResponse + client *CasbinSourceServiceBiz +} + +func (c CasbinRuleStream) Recv() (*pb.StreamRulesResponse, error) { + select { + case msg := <-c.receiver: + c.client.log.Infof("received message: %v", msg) + if msg == nil { + c.client.log.Info("stream closed") + return nil, io.EOF + } + return msg, nil + case <-c.ctx.Done(): + c.client.log.Info("no message received") + return nil, c.ctx.Err() + } +} + +func (c CasbinRuleStream) Header() (metadata.MD, error) { + return metadata.MD{}, errors.New("not implemented") +} + +func (c CasbinRuleStream) Trailer() metadata.MD { + return metadata.MD{} +} + +func (c CasbinRuleStream) CloseSend() error { + return errors.New("not implemented") +} + +func (c CasbinRuleStream) Context() context.Context { + return c.ctx +} + +func (c CasbinRuleStream) SendMsg(m any) error { + return errors.New("not implemented") +} + +func (c CasbinRuleStream) RecvMsg(m any) error { + return errors.New("not implemented") +} + +func (c CasbinRuleStream) Start(request *pb.StreamRulesRequest) error { + defer close(c.receiver) + c.client.log.Infof("sending request: %v", request) + if request.WithPolicies { + policies, err := c.client.ListPolicies(c.ctx, &pb.ListPoliciesRequest{}) + if err != nil { + return err + } + c.client.log.Infof("sending %d policies", len(policies.Rules)) + for _, rule := range policies.Rules { + c.receiver <- newPolicyResponse(rule) + } + } + + if request.WithGroupings { + groupings, err := c.client.ListGroupings(c.ctx, &pb.ListGroupingsRequest{}) + if err != nil { + return err + } + c.client.log.Infof("sending %d groupings", len(groupings.Rules)) + for _, grouping := range groupings.Rules { + c.receiver <- newGroupingResponse(grouping) + } + } + return nil +} + +func NewCasbinRuleStream(ctx context.Context, client *CasbinSourceServiceBiz) *CasbinRuleStream { + ctx, cancel := context.WithCancel(ctx) + return &CasbinRuleStream{ + ctx: ctx, + cancel: cancel, + receiver: make(chan *pb.StreamRulesResponse, 1), + client: client, + } +} + +var _ grpc.ServerStreamingClient[pb.StreamRulesResponse] = (*CasbinRuleStream)(nil) diff --git a/internal/mods/system/biz/personal.biz.go b/internal/mods/auth/biz/personal.biz.go similarity index 92% rename from internal/mods/system/biz/personal.biz.go rename to internal/mods/auth/biz/personal.biz.go index 5734af1a..830b840b 100644 --- a/internal/mods/system/biz/personal.biz.go +++ b/internal/mods/auth/biz/personal.biz.go @@ -2,7 +2,7 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package biz is a biz layer for the system module of OrigAdmin. +// Package biz is a biz layer for the auth module of OrigAdmin. package biz import ( @@ -12,8 +12,8 @@ import ( "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/mods/auth/dto" ) // PersonalServiceBiz is a Personal use case. diff --git a/internal/mods/auth/dal/dal.go b/internal/mods/auth/dal/dal.go index 2f88470b..2aed6c31 100644 --- a/internal/mods/auth/dal/dal.go +++ b/internal/mods/auth/dal/dal.go @@ -37,6 +37,7 @@ var ProviderSet = wire.NewSet( NewAuthRepo, NewLoginRepo, NewCasbinSourceRepo, + NewPersonalRepo, RefreshTokenizer, ) diff --git a/internal/mods/system/dal/personal.dal.go b/internal/mods/auth/dal/personal.dal.go similarity index 55% rename from internal/mods/system/dal/personal.dal.go rename to internal/mods/auth/dal/personal.dal.go index b07ca0d6..515d17e7 100644 --- a/internal/mods/system/dal/personal.dal.go +++ b/internal/mods/auth/dal/personal.dal.go @@ -7,18 +7,16 @@ package dal import ( "context" - "entgo.io/ent/dialect/sql" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" typespb "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/helpers/securityx" "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/mods/auth/dto" ) type personalRepo struct { @@ -81,18 +79,18 @@ func (repo personalRepo) ListPersonalResources(ctx context.Context, in *pb.ListP } return &pb.ListPersonalResourcesResponse{ TotalSize: int64(len(resources)), - Resources: dto.ConvertResources(resources), + Resources: dto.ConvertResources2PB(resources), }, nil } -func (repo personalRepo) ListResources(ctx context.Context, in *dto.ListResourcesRequest, options ...dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { - var option dto.ResourceQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.Resource(ctx).Query() - return personalPageQuery(ctx, query, in, option) -} +//func (repo personalRepo) ListResources(ctx context.Context, in *dto.ListResourcesRequest, options ...dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { +// var option dto.ResourceQueryOption +// if len(options) > 0 { +// option = options[0] +// } +// query := repo.db.Resource(ctx).Query() +// return personalPageQuery(ctx, query, in, option) +//} // NewPersonalRepo . func NewPersonalRepo(r runtime.Runtime, db *data.Data) dto.PersonalRepo { @@ -101,54 +99,54 @@ func NewPersonalRepo(r runtime.Runtime, db *data.Data) dto.PersonalRepo { } } -func personalPageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.ListResourcesRequest, option dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { - query = personalQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - query = personalQueryPage(query, in) - result, err := query.All(ctx) - return dto.ConvertResources(result), int32(count), err -} - -func personalQueryPage(query *ent.ResourceQuery, in *pb.ListResourcesRequest) *ent.ResourceQuery { - if in.NoPaging { - pageSize := in.PageSize - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - return query - } - - pageSize := in.PageSize - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - current := in.Current - if current > 0 { - query = query.Offset(int((current - 1) * pageSize)) - } - return query -} - -func personalQueryOptions(query *ent.ResourceQuery, option dto.ResourceQueryOption) *ent.ResourceQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).ResourceQuery - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).ResourceQuery - } - if len(option.OrderFields) > 0 { - query = query.Order(personalOrderBy(option.OrderFields)...) - } - return query -} - -func personalOrderBy(fields []string, opts ...sql.OrderTermOption) []resource.OrderOption { - var orders []resource.OrderOption - for _, field := range fields { - orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) - } - return orders -} +//func personalPageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.ListResourcesRequest, option dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { +// query = personalQueryOptions(query, option) +// count, err := query.Count(ctx) +// if err != nil { +// return nil, 0, err +// } +// query = personalQueryPage(query, in) +// result, err := query.All(ctx) +// return dto.ConvertResources2PB(result), int32(count), err +//} +// +//func personalQueryPage(query *ent.ResourceQuery, in *pb.ListResourcesRequest) *ent.ResourceQuery { +// if in.NoPaging { +// pageSize := in.PageSize +// if pageSize > 0 { +// query = query.Limit(int(pageSize)) +// } +// return query +// } +// +// pageSize := in.PageSize +// if pageSize > 0 { +// query = query.Limit(int(pageSize)) +// } +// current := in.Current +// if current > 0 { +// query = query.Offset(int((current - 1) * pageSize)) +// } +// return query +//} + +//func personalQueryOptions(query *ent.ResourceQuery, option dto.ResourceQueryOption) *ent.ResourceQuery { +// if len(option.SelectFields) > 0 { +// query = query.Select(option.SelectFields...).ResourceQuery +// } +// if len(option.OmitFields) > 0 { +// query = query.Omit(option.OmitFields...).ResourceQuery +// } +// if len(option.OrderFields) > 0 { +// query = query.Order(personalOrderBy(option.OrderFields)...) +// } +// return query +//} + +//func personalOrderBy(fields []string, opts ...sql.OrderTermOption) []resource.OrderOption { +// var orders []resource.OrderOption +// for _, field := range fields { +// orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) +// } +// return orders +//} diff --git a/internal/mods/auth/dto/login.go b/internal/mods/auth/dto/login.go index 8d563db0..8c667c22 100644 --- a/internal/mods/auth/dto/login.go +++ b/internal/mods/auth/dto/login.go @@ -2,7 +2,7 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package dto is the data transfer object package for the system module. +// Package dto is the data transfer object package for the auth module. package dto import ( diff --git a/internal/mods/system/dto/personal.go b/internal/mods/auth/dto/personal.go similarity index 84% rename from internal/mods/system/dto/personal.go rename to internal/mods/auth/dto/personal.go index 2bec56b7..c2ea4660 100644 --- a/internal/mods/system/dto/personal.go +++ b/internal/mods/auth/dto/personal.go @@ -2,13 +2,13 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package dto is the data transfer object package for the system module. +// Package dto is the data transfer object package for the auth module. package dto import ( "context" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" ) type PersonalRepo interface { diff --git a/internal/mods/auth/server/server.go b/internal/mods/auth/server/server.go index 2391608b..1a932718 100644 --- a/internal/mods/auth/server/server.go +++ b/internal/mods/auth/server/server.go @@ -19,6 +19,7 @@ import ( "github.com/origadmin/toolkits/errors" "origadmin/application/admin/internal/configs" + authservice "origadmin/application/admin/internal/mods/auth/service" ) const ( @@ -38,7 +39,7 @@ func init() { runtime.RegisterService(ServiceName, service.DefaultServiceFactory) } -func NewAuthServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc service.ServerRegistrar) []transport. +func NewAuthServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc *authservice.RegisterServer) []transport. Server { var servers []transport.Server serverConfig := bootstrap.GetServer() diff --git a/internal/mods/auth/service/auth.bridge.go b/internal/mods/auth/service/auth.bridge.go index c0d75df9..dc5a9517 100644 --- a/internal/mods/auth/service/auth.bridge.go +++ b/internal/mods/auth/service/auth.bridge.go @@ -172,6 +172,14 @@ func NewAuthServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.Auth return pb.NewAuthServiceBridge(client) } +func NewAuthServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.AuthServiceServer { + if v, ok := clients["auth"]; ok { + return NewAuthServiceBridge(r, v) + } else { + return pb.UnimplementedAuthServiceServer{} + } +} + // NewAuthServiceHTTPBridge new a menu service. func NewAuthServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.AuthServiceHTTPServer { return pb.NewAuthServiceHTTPBridge(client) diff --git a/internal/mods/auth/service/casbin.bridge.go b/internal/mods/auth/service/casbin.bridge.go new file mode 100644 index 00000000..7b7dd740 --- /dev/null +++ b/internal/mods/auth/service/casbin.bridge.go @@ -0,0 +1,209 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + + "github.com/go-kratos/kratos/v2/transport/http" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + + pb "origadmin/application/admin/api/v1/services/auth" +) + +// CasbinServiceHookedBridge is a Casbin service. +type CasbinServiceHookedBridge struct { + pb.UnimplementedCasbinSourceServiceHooked + log *log.KHelper +} + +func (c CasbinServiceHookedBridge) CompleteListGroupings(context http.Context, request *pb.ListGroupingsRequest, response *pb.ListGroupingsResponse) error { + //TODO implement me + panic("implement me") +} + +func (c CasbinServiceHookedBridge) PrepareListPolicies(context http.Context, request *pb.ListPoliciesRequest) (context.Context, error) { + //TODO implement me + panic("implement me") +} + +func (c CasbinServiceHookedBridge) CompleteListPolicies(context http.Context, request *pb.ListPoliciesRequest, response *pb.ListPoliciesResponse) error { + //TODO implement me + panic("implement me") +} + +func (c CasbinServiceHookedBridge) PrepareWatchUpdate(context http.Context, request *pb.WatchUpdateRequest) (context.Context, error) { + //TODO implement me + panic("implement me") +} + +func (c CasbinServiceHookedBridge) CompleteWatchUpdate(context http.Context, request *pb.WatchUpdateRequest, response *pb.WatchUpdateResponse) error { + //TODO implement me + panic("implement me") +} + +//func (s CasbinServiceHookedBridge) PersonalLogout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Logout(ctx, request) +// if err != nil { +// log.Errorf("Logout error: %v", err) +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Data{ +// Success: true, +// Data: resp.Proto2Any(response), +// }) +// return nil, nil +//} +// +//func (s CasbinServiceHookedBridge) Register(ctx context.Context, request *pb.RegisterRequest) (*pb.RegisterResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Register(ctx, request) +// if err != nil { +// log.Errorf("Register error: %v", err) +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Data{ +// Success: true, +// Data: resp.Proto2Any(response), +// }) +// return nil, nil +//} +// +//func (s CasbinServiceHookedBridge) Captcha(ctx context.Context, request *pb.CaptchaRequest) (*pb.CaptchaResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Captcha(ctx, request) +// if err != nil { +// log.Errorf("Captcha error: %v", err) +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Data{ +// Success: true, +// Data: resp.Proto2Any(response), +// }) +// return nil, nil +//} +// +//func (s CasbinServiceHookedBridge) CaptchaId(ctx context.Context, request *pb.CaptchaIdRequest) (*pb.CaptchaIdResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// log.Debugf("CaptchaId: Request:%+v", request) +// response, err := s.client.CaptchaId(ctx, request) +// log.Debugf("CaptchaId: Response:%+v, Error:%+v", response, err) +// if err != nil { +// log.Errorf("CaptchaImage error: %v", err) +// return nil, err +// } +// +// s.JSON(httpCtx, http.StatusOK, &resp.StringResult{ +// Success: true, +// Data: response.Data, +// }) +// return nil, nil +//} +// +//func (s CasbinServiceHookedBridge) CaptchaAudio(ctx context.Context, request *pb.CaptchaAudioRequest) (*pb.CaptchaAudioResponse, error) { +// _, err := s.client.CaptchaAudio(ctx, request) +// if err != nil { +// log.Errorf("Logout error: %v", err) +// return nil, err +// } +// return nil, nil +//} +//func (s CasbinServiceHookedBridge) CaptchaImage(ctx context.Context, request *pb.CaptchaImageRequest) (*pb.CaptchaImageResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// log.Debugf("CaptchaImage: Request:%+v", request) +// response, err := s.client.CaptchaImage(ctx, request) +// log.Debugf("CaptchaImage: Response:%+v, Error:%+v", response, err) +// if err != nil { +// log.Errorf("CaptchaImage error: %v", err) +// return nil, err +// } +// log.Debugf("CaptchaImage: Setting headers: %+v", response.Headers) +// for k, v := range response.Headers { +// httpCtx.Response().Header().Set(k, v) +// } +// log.Debugf("CaptchaImage: Writing response headers") +// httpCtx.Response().WriteHeader(http.StatusOK) +// log.Debugf("CaptchaImage: Writing response image") +// if _, err := httpCtx.Response().Write(response.Image); err != nil { +// log.Errorf("CaptchaImage error writing response: %v", err) +// return nil, err +// } +// //log.Debugf("CaptchaImage: Flushing response writer") +// //context.Response().Flush() +// log.Debugf("CaptchaImage: Completed successfully") +// return nil, nil +//} +// +//func (s CasbinServiceHookedBridge) TokenRefresh(ctx context.Context, request *pb.TokenRefreshRequest) (*pb.TokenRefreshResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.TokenRefresh(ctx, request) +// if err != nil { +// log.Errorf("Refresh error: %v", err) +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Data{ +// Success: true, +// Data: resp.Proto2Any(resp.FromToken(response.Token)), +// }) +// return nil, nil +//} +// +//func (s CasbinServiceHookedBridge) Casbin(ctx context.Context, request *pb.CasbinRequest) (*pb.CasbinResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Casbin(ctx, request) +// if err != nil { +// log.Errorf("Casbin error: %v", err) +// return nil, err +// } +// token := resp.FromToken(response.Token) +// log.Debugf("Casbin: Token:%+v", token) +// s.JSON(httpCtx, http.StatusOK, &resp.Result{ +// Success: true, +// Data: token, +// }) +// return nil, nil +//} +// +//func (s CasbinServiceHookedBridge) Logout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { +// httpCtx := agent.FromHTTPContext(ctx) +// response, err := s.client.Logout(ctx, request) +// if err != nil { +// log.Errorf("Logout error: %v", err) +// return nil, err +// } +// s.JSON(httpCtx, http.StatusOK, &resp.Data{ +// Success: true, +// Data: resp.Proto2Any(response), +// }) +// return nil, nil +//} + +func NewCasbinServiceHookedBridge(r runtime.Runtime, client pb.CasbinSourceServiceHTTPServer) pb. +CasbinSourceServiceHookedBridger { + return pb.WithCasbinSourceServiceHook(&CasbinServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/permission")), + })(client) +} + +// NewCasbinServiceBridge new a menu service. +func NewCasbinServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.CasbinSourceServiceServer { + return pb.NewCasbinSourceServiceBridge(client) +} + +func NewCasbinServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.CasbinSourceServiceServer { + if v, ok := clients["auth"]; ok { + return NewCasbinServiceBridge(r, v) + } else { + return pb.UnimplementedCasbinSourceServiceServer{} + } +} + +// NewCasbinServiceHTTPBridge new a menu service. +func NewCasbinServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.CasbinSourceServiceHTTPServer { + return pb.NewCasbinSourceServiceHTTPBridge(client) +} diff --git a/internal/mods/auth/service/casbin.go b/internal/mods/auth/service/casbin.go new file mode 100644 index 00000000..43f18ef2 --- /dev/null +++ b/internal/mods/auth/service/casbin.go @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + "google.golang.org/grpc" + "google.golang.org/grpc/status" + + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/contrib/security/authz/casbin" + "origadmin/application/admin/internal/mods/auth/biz" +) + +// CasbinSourceBiz is a Casbin rule source service. +type CasbinSourceBiz struct { + client *biz.CasbinSourceServiceBiz + log *log.KHelper +} + +func (c CasbinSourceBiz) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { + return c.client.ListPolicies(ctx, in) +} + +func (c CasbinSourceBiz) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + +func (c CasbinSourceBiz) WatchUpdate(ctx context.Context, in *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { + return c.client.WatchUpdate(ctx, in) +} + +func (c CasbinSourceBiz) StreamRules(ctx context.Context, in *pb.StreamRulesRequest) (grpc.ServerStreamingClient[pb.StreamRulesResponse], error) { + stream := biz.NewCasbinRuleStream(ctx, c.client) + go func() { + err := stream.Start(in) + if err != nil { + c.log.Error("stream error", "error", err) + } + }() + return stream, nil +} + +func NewCasbinSourceBiz(r runtime.Runtime, client *biz.CasbinSourceServiceBiz) casbin.RuleSource { + return &CasbinSourceBiz{ + client: client, + log: log.NewHelper(r.WithLogger("module", "service/casbin")), + } +} + +// CasbinSourceClient is a Casbin rule source service. +type CasbinSourceClient struct { + client pb.CasbinSourceServiceClient + log *log.KHelper +} + +func (c CasbinSourceClient) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { + return c.client.ListPolicies(ctx, in) +} + +func (c CasbinSourceClient) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + +func (c CasbinSourceClient) WatchUpdate(ctx context.Context, in *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { + return c.client.WatchUpdate(ctx, in) +} + +func (c CasbinSourceClient) StreamRules(ctx context.Context, in *pb.StreamRulesRequest) (grpc.ServerStreamingClient[pb.StreamRulesResponse], error) { + return c.client.StreamRules(ctx, in) +} + +// NewCasbinSourceClient new a menu service. +func NewCasbinSourceClient(r runtime.Runtime, clients map[string]*service.GRPCClient) casbin.RuleSource { + client, ok := clients["auth"] + if ok { + return &CasbinSourceClient{ + client: pb.NewCasbinSourceServiceClient(client), + log: log.NewHelper(r.WithLogger("module", "service/casbin")), + } + } + return &CasbinSourceClient{ + client: UnimplementedCasbinSource{ + log: log.NewHelper(r.WithLogger("module", "service/casbin")), + }, + } +} + +type UnimplementedCasbinSource struct { + log *log.KHelper +} + +func (u UnimplementedCasbinSource) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest, opts ...grpc.CallOption) (*pb.ListPoliciesResponse, error) { + u.log.Error("ListPolicies not implemented") + return &pb.ListPoliciesResponse{}, nil +} + +func (u UnimplementedCasbinSource) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest, opts ...grpc.CallOption) (*pb.ListGroupingsResponse, error) { + u.log.Error("ListGroupings not implemented") + return &pb.ListGroupingsResponse{}, nil +} + +func (u UnimplementedCasbinSource) WatchUpdate(ctx context.Context, in *pb.WatchUpdateRequest, opts ...grpc.CallOption) (*pb.WatchUpdateResponse, error) { + u.log.Error("WatchUpdate not implemented") + return &pb.WatchUpdateResponse{}, nil +} + +func (u UnimplementedCasbinSource) StreamRules(ctx context.Context, in *pb.StreamRulesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[pb.StreamRulesResponse], error) { + u.log.Error("StreamRules not implemented") + return nil, status.Error(400, "not implemented") +} diff --git a/internal/mods/auth/service/casbin.grpc.go b/internal/mods/auth/service/casbin.grpc.go index c6b1dd93..a596212b 100644 --- a/internal/mods/auth/service/casbin.grpc.go +++ b/internal/mods/auth/service/casbin.grpc.go @@ -8,7 +8,6 @@ package service import ( "context" - "github.com/casbin/casbin/v2" "github.com/origadmin/runtime/service" "google.golang.org/grpc" @@ -18,8 +17,7 @@ import ( type CasbinSourceServiceServer struct { pb.UnimplementedCasbinSourceServiceServer - client *biz.CasbinSourceServiceBiz - enforcer *casbin.Enforcer + client *biz.CasbinSourceServiceBiz } func (c *CasbinSourceServiceServer) WatchUpdate(ctx context.Context, request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { diff --git a/internal/mods/auth/service/casbin.http.go b/internal/mods/auth/service/casbin.http.go index e4b0399b..5aa321ca 100644 --- a/internal/mods/auth/service/casbin.http.go +++ b/internal/mods/auth/service/casbin.http.go @@ -13,7 +13,6 @@ import ( // CasbinSourceServiceHTTPServer is a login service. type CasbinSourceServiceHTTPServer struct { pb.UnimplementedCasbinSourceServiceServer - client pb.CasbinSourceServiceHTTPClient } diff --git a/internal/mods/auth/service/login.bridge.go b/internal/mods/auth/service/login.bridge.go index 28d6d521..8d68d472 100644 --- a/internal/mods/auth/service/login.bridge.go +++ b/internal/mods/auth/service/login.bridge.go @@ -245,6 +245,14 @@ func NewLoginServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.Log return pb.NewLoginServiceBridge(client) } +func NewLoginServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.LoginServiceServer { + if v, ok := clients["auth"]; ok { + return NewLoginServiceBridge(r, v) + } else { + return pb.UnimplementedLoginServiceServer{} + } +} + // NewLoginServiceHTTPBridge new a menu service. func NewLoginServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.LoginServiceHTTPServer { return pb.NewLoginServiceHTTPBridge(client) diff --git a/internal/mods/system/service/personal.bridge.go b/internal/mods/auth/service/personal.bridge.go similarity index 89% rename from internal/mods/system/service/personal.bridge.go rename to internal/mods/auth/service/personal.bridge.go index 7b8aa520..5a6a83f3 100644 --- a/internal/mods/system/service/personal.bridge.go +++ b/internal/mods/auth/service/personal.bridge.go @@ -12,7 +12,7 @@ import ( "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" ) // PersonalServiceHookedBridge is a menu service. @@ -32,16 +32,6 @@ func (p PersonalServiceHookedBridge) CompleteGetPersonalProfile(context transhtt panic("implement me") } -func (p PersonalServiceHookedBridge) PrepareListPersonalResources(context transhttp.Context, request *pb.ListPersonalResourcesRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) CompleteListPersonalResources(context transhttp.Context, request *pb.ListPersonalResourcesRequest, response *pb.ListPersonalResourcesResponse) error { - //TODO implement me - panic("implement me") -} - func (p PersonalServiceHookedBridge) PrepareListPersonalRoles(context transhttp.Context, request *pb.ListPersonalRolesRequest) (context.Context, error) { //TODO implement me panic("implement me") @@ -114,6 +104,14 @@ func NewPersonalServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb. return pb.NewPersonalServiceBridge(client) } +func NewPersonalServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.PersonalServiceServer { + if c, ok := clients["auth"]; ok { + return pb.NewPersonalServiceBridge(c) + } else { + return pb.UnimplementedPersonalServiceServer{} + } +} + // NewPersonalServiceHTTPBridge new a menu service. func NewPersonalServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.PersonalServiceHTTPServer { return pb.NewPersonalServiceHTTPBridge(client) diff --git a/internal/mods/system/service/personal.grpc.go b/internal/mods/auth/service/personal.grpc.go similarity index 95% rename from internal/mods/system/service/personal.grpc.go rename to internal/mods/auth/service/personal.grpc.go index fb16d9fc..5d5915b8 100644 --- a/internal/mods/system/service/personal.grpc.go +++ b/internal/mods/auth/service/personal.grpc.go @@ -9,8 +9,8 @@ import ( "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/log" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/mods/auth/biz" ) // PersonalServiceServer is a login service. diff --git a/internal/mods/system/service/personal.http.go b/internal/mods/auth/service/personal.http.go similarity index 97% rename from internal/mods/system/service/personal.http.go rename to internal/mods/auth/service/personal.http.go index 6e54bcd9..7f4ebba7 100644 --- a/internal/mods/system/service/personal.http.go +++ b/internal/mods/auth/service/personal.http.go @@ -7,7 +7,7 @@ package service import ( "context" - pb "origadmin/application/admin/api/v1/services/system" + pb "origadmin/application/admin/api/v1/services/auth" ) // PersonalServiceHTTPServer is a login service. diff --git a/internal/mods/auth/service/service.go b/internal/mods/auth/service/service.go index ba57affe..2800faf1 100644 --- a/internal/mods/auth/service/service.go +++ b/internal/mods/auth/service/service.go @@ -16,20 +16,30 @@ import ( // ProviderSet is service providers. var ProviderSet = wire.NewSet( - wire.Struct(new(RegisterServer), "*"), + NewRegisterServer, NewAuthServiceServerPB, - //NewAuthServiceHTTPServerPB, NewCasbinSourceServiceServerPB, - //NewCasbinSourceServiceHTTPServerPB, NewLoginServiceServerPB, - //NewLoginServiceHTTPServerPB, + NewPersonalServiceServerPB, + NewPersonalServiceHTTPServerPB, + NewCasbinSourceBiz, +) + +var RemoteProviderSet = wire.NewSet( NewRegisterServer, + NewAuthServiceBridgeClient, + NewCasbinServiceBridgeClient, + NewLoginServiceBridgeClient, + NewPersonalServiceBridgeClient, + NewCasbinSourceClient, + ) type RegisterServer struct { - Auth pb.AuthServiceServer - Casbin pb.CasbinSourceServiceServer - Login pb.LoginServiceServer + Auth pb.AuthServiceServer + Casbin pb.CasbinSourceServiceServer + Login pb.LoginServiceServer + Personal pb.PersonalServiceServer } func (s RegisterServer) Register(ctx context.Context, svc any) { @@ -42,28 +52,32 @@ func (s RegisterServer) Register(ctx context.Context, svc any) { } func (s RegisterServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { - log.Info("grpc server system init") + log.Info("grpc server auth init") pb.RegisterAuthServiceServer(server, s.Auth) pb.RegisterCasbinSourceServiceServer(server, s.Casbin) pb.RegisterLoginServiceServer(server, s.Login) + pb.RegisterPersonalServiceServer(server, s.Personal) } func (s RegisterServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { - log.Info("http server system init") + log.Info("http server auth init") pb.RegisterAuthServiceHTTPServer(server, s.Auth) pb.RegisterCasbinSourceServiceHTTPServer(server, s.Casbin) pb.RegisterLoginServiceHTTPServer(server, s.Login) + pb.RegisterPersonalServiceHTTPServer(server, s.Personal) } func NewRegisterServer( Auth pb.AuthServiceServer, Casbin pb.CasbinSourceServiceServer, Login pb.LoginServiceServer, -) service.ServerRegistrar { + Personal pb.PersonalServiceServer, +) *RegisterServer { return &RegisterServer{ - Auth: Auth, - Casbin: Casbin, - Login: Login, + Auth: Auth, + Casbin: Casbin, + Login: Login, + Personal: Personal, } } diff --git a/internal/mods/system/server/server.go b/internal/mods/system/server/server.go index 963f7da4..06e7274c 100644 --- a/internal/mods/system/server/server.go +++ b/internal/mods/system/server/server.go @@ -19,6 +19,7 @@ import ( "github.com/origadmin/toolkits/errors" "origadmin/application/admin/internal/configs" + systemservice "origadmin/application/admin/internal/mods/system/service" ) const ( @@ -38,7 +39,7 @@ func init() { runtime.RegisterService(ServiceName, service.DefaultServiceFactory) } -func NewSystemServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc service.ServerRegistrar) []transport. +func NewSystemServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc *systemservice.RegisterServer) []transport. Server { var servers []transport.Server serverConfig := bootstrap.GetServer() diff --git a/internal/mods/system/service/menu.bridge.go b/internal/mods/system/service/menu.bridge.go index 68081e58..c3c8b69b 100644 --- a/internal/mods/system/service/menu.bridge.go +++ b/internal/mods/system/service/menu.bridge.go @@ -86,6 +86,14 @@ func NewMenuServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.Menu return pb.NewMenuServiceBridge(client) } +func NewMenuServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.MenuServiceServer { + if c, ok := clients["system"]; ok { + return pb.NewMenuServiceBridge(c) + } else { + return pb.UnimplementedMenuServiceServer{} + } +} + // NewMenuServiceHTTPBridge new a menu service. func NewMenuServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.MenuServiceHTTPServer { return pb.NewMenuServiceHTTPBridge(client) diff --git a/internal/mods/system/service/permission.bridge.go b/internal/mods/system/service/permission.bridge.go index af32d102..3a27a931 100644 --- a/internal/mods/system/service/permission.bridge.go +++ b/internal/mods/system/service/permission.bridge.go @@ -89,6 +89,14 @@ func NewPermissionServiceBridge(r runtime.Runtime, client *service.GRPCClient) p return pb.NewPermissionServiceBridge(client) } +func NewPermissionServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.PermissionServiceServer { + if c, ok := clients["system"]; ok { + return pb.NewPermissionServiceBridge(c) + } else { + return pb.UnimplementedPermissionServiceServer{} + } +} + // NewPermissionServiceHTTPBridge new a menu service. func NewPermissionServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.PermissionServiceHTTPServer { return pb.NewPermissionServiceHTTPBridge(client) diff --git a/internal/mods/system/service/resource.bridge.go b/internal/mods/system/service/resource.bridge.go index 34fafc99..26aedea2 100644 --- a/internal/mods/system/service/resource.bridge.go +++ b/internal/mods/system/service/resource.bridge.go @@ -89,6 +89,14 @@ func NewResourceServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb. return pb.NewResourceServiceBridge(client) } +func NewResourceServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.ResourceServiceServer { + if c, ok := clients["system"]; ok { + return pb.NewResourceServiceBridge(c) + } else { + return pb.UnimplementedResourceServiceServer{} + } +} + // NewResourceServiceHTTPBridge new a menu service. func NewResourceServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.ResourceServiceHTTPServer { return pb.NewResourceServiceHTTPBridge(client) diff --git a/internal/mods/system/service/role.bridge.go b/internal/mods/system/service/role.bridge.go index 3bc2448d..009966ba 100644 --- a/internal/mods/system/service/role.bridge.go +++ b/internal/mods/system/service/role.bridge.go @@ -89,6 +89,14 @@ func NewRoleServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.Role return pb.NewRoleServiceBridge(client) } +func NewRoleServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.RoleServiceServer { + if v, ok := clients["system"]; ok { + return NewRoleServiceBridge(r, v) + } else { + return pb.UnimplementedRoleServiceServer{} + } +} + // NewRoleServiceHTTPBridge new a menu service. func NewRoleServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.RoleServiceHTTPServer { return pb.NewRoleServiceHTTPBridge(client) diff --git a/internal/mods/system/service/service.go b/internal/mods/system/service/service.go index 97e15e62..84bec40a 100644 --- a/internal/mods/system/service/service.go +++ b/internal/mods/system/service/service.go @@ -16,24 +16,27 @@ import ( // ProviderSet is service providers. var ProviderSet = wire.NewSet( - wire.Struct(new(RegisterServer), "*"), - NewResourceServiceBridge, + NewRegisterServer, NewResourceServiceServerPB, NewResourceServiceHTTPServerPB, - NewRoleServiceBridge, NewRoleServiceServerPB, NewRoleServiceHTTPServerPB, - NewUserServiceBridge, NewUserServiceServerPB, NewUserServiceHTTPServerPB, - NewPersonalServiceBridge, - NewPersonalServiceServerPB, - NewPersonalServiceHTTPServerPB, - NewPermissionServiceBridge, NewPermissionServiceServerPB, NewPermissionServiceHTTPServerPB, - NewRegisterServer, +) +var RemoteProviderSet = wire.NewSet( + NewRegisterServer, + NewResourceServiceBridgeClient, + //NewResourceServiceBridge, + NewRoleServiceBridgeClient, + //NewRoleServiceBridge, + NewUserServiceBridgeClient, + //NewUserServiceBridge, + NewPermissionServiceBridgeClient, + //NewPermissionServiceBridge, ) type RegisterServer struct { @@ -73,7 +76,7 @@ func NewRegisterServer( Role pb.RoleServiceServer, User pb.UserServiceServer, Permission pb.PermissionServiceServer, -) service.ServerRegistrar { +) *RegisterServer { return &RegisterServer{ Resource: Resource, Role: Role, diff --git a/internal/mods/system/service/user.bridge.go b/internal/mods/system/service/user.bridge.go index 90a0e032..d85dd80e 100644 --- a/internal/mods/system/service/user.bridge.go +++ b/internal/mods/system/service/user.bridge.go @@ -89,6 +89,14 @@ func NewUserServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.User return pb.NewUserServiceBridge(client) } +func NewUserServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.UserServiceServer { + if c, ok := clients["system"]; ok { + return pb.NewUserServiceBridge(c) + } else { + return pb.UnimplementedUserServiceServer{} + } +} + // NewUserServiceHTTPBridge new a menu service. func NewUserServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.UserServiceHTTPServer { return pb.NewUserServiceHTTPBridge(client) diff --git a/internal/mods/system/service/user.http.go b/internal/mods/system/service/user.http.go index 01a821e1..44afa0ad 100644 --- a/internal/mods/system/service/user.http.go +++ b/internal/mods/system/service/user.http.go @@ -10,63 +10,63 @@ import ( pb "origadmin/application/admin/api/v1/services/system" ) -type UserServiceHTTPService struct { +type UserServiceHTTPServer struct { pb.UnimplementedUserServiceServer client pb.UserServiceHTTPClient } -func (s UserServiceHTTPService) ListUserResources(ctx context.Context, request *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { +func (s UserServiceHTTPServer) ListUserResources(ctx context.Context, request *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { return s.client.ListUserResources(ctx, request) } -func (s UserServiceHTTPService) ResetUserPassword(ctx context.Context, request *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { +func (s UserServiceHTTPServer) ResetUserPassword(ctx context.Context, request *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { //TODO implement me panic("implement me") } -func (s UserServiceHTTPService) UpdateUserRoles(ctx context.Context, request *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { +func (s UserServiceHTTPServer) UpdateUserRoles(ctx context.Context, request *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { //TODO implement me panic("implement me") } -func (s UserServiceHTTPService) UpdateUserStatus(ctx context.Context, request *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { +func (s UserServiceHTTPServer) UpdateUserStatus(ctx context.Context, request *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { //TODO implement me panic("implement me") } -func (s UserServiceHTTPService) ListUsers(ctx context.Context, req *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { +func (s UserServiceHTTPServer) ListUsers(ctx context.Context, req *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { return s.client.ListUsers(ctx, req) } -func (s UserServiceHTTPService) GetUser(ctx context.Context, req *pb.GetUserRequest) (*pb.GetUserResponse, error) { +func (s UserServiceHTTPServer) GetUser(ctx context.Context, req *pb.GetUserRequest) (*pb.GetUserResponse, error) { return s.client.GetUser(ctx, req) } -func (s UserServiceHTTPService) CreateUser(ctx context.Context, req *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { +func (s UserServiceHTTPServer) CreateUser(ctx context.Context, req *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { return s.client.CreateUser(ctx, req) } -func (s UserServiceHTTPService) UpdateUser(ctx context.Context, req *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { +func (s UserServiceHTTPServer) UpdateUser(ctx context.Context, req *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { return s.client.UpdateUser(ctx, req) } -func (s UserServiceHTTPService) DeleteUser(ctx context.Context, req *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { +func (s UserServiceHTTPServer) DeleteUser(ctx context.Context, req *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { return s.client.DeleteUser(ctx, req) } // NewUserServiceHTTPServer new a user service. -func NewUserServiceHTTPServer(client pb.UserServiceHTTPClient) *UserServiceHTTPService { - return &UserServiceHTTPService{ +func NewUserServiceHTTPServer(client pb.UserServiceHTTPClient) *UserServiceHTTPServer { + return &UserServiceHTTPServer{ client: client, } } // NewUserServiceHTTPServerPB new a user service. func NewUserServiceHTTPServerPB(client pb.UserServiceHTTPClient) pb.UserServiceHTTPServer { - return &UserServiceHTTPService{ + return &UserServiceHTTPServer{ client: client, } } -var _ pb.UserServiceServer = (*UserServiceHTTPService)(nil) +var _ pb.UserServiceServer = (*UserServiceHTTPServer)(nil) diff --git a/internal/mods/system/service/user.service.go b/internal/mods/system/service/user.service.go new file mode 100644 index 00000000..be6dc11f --- /dev/null +++ b/internal/mods/system/service/user.service.go @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "github.com/origadmin/runtime/service" + + "origadmin/application/admin/internal/mods/system/biz" +) + +type UserService struct { + grpcClient *service.GRPCClient + httpClient *service.HTTPClient + biz *biz.UserServiceBiz `wire:"-"` + grpc *UserServiceServer `wire:"-"` + http *UserServiceHTTPServer `wire:"-"` +} + +//func NewUserService(r runtime.Runtime, bootstrap *configs.Bootstrap, service *UserService) pb.UserServiceServer { +// if r.IsClient() { +// return NewUserServiceBridge(r, service.grpcClient) +// } +//} diff --git a/resources/configs/admin/bootstrap.toml b/resources/configs/admin/bootstrap.toml index fcc935f9..e78882b0 100644 --- a/resources/configs/admin/bootstrap.toml +++ b/resources/configs/admin/bootstrap.toml @@ -7,3 +7,109 @@ Id = "" Environment = "" Services = [] +[[Entry.Services]] +Name = "" +Type = "http" +DynamicEndpoint = true +[Entry.Services.Http] +Network = "tcp" +Addr = "${http_address:0.0.0.0:25100}" +UseTls = false +Timeout = 0 +ShutdownTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +IdleTimeout = 0 +Endpoint = "" +[Entry.Services.Websocket] +Network = "" +Addr = "" +Path = "" +Codec = "" +Timeout = 0 +[Entry.Services.Message] +Type = "none" +Name = "" +[Entry.Services.Message.Mqtt] +Endpoint = "" +Codec = "" +[Entry.Services.Message.Kafka] +Endpoint = "" +Codec = "" +[Entry.Services.Message.Rabbitmq] +Endpoint = "" +Codec = "" +[Entry.Services.Message.Activemq] +Endpoint = "" +Codec = "" +[Entry.Services.Message.Nats] +Endpoint = "" +Codec = "" +[Entry.Services.Message.Nsq] +Endpoint = "" +Codec = "" +[Entry.Services.Message.Pulsar] +Endpoint = "" +Codec = "" +[Entry.Services.Message.Redis] +Endpoint = "" +Codec = "" +[Entry.Services.Message.Rocketmq] +Endpoint = "" +Codec = "" +EnableTrace = false +NameServerDomain = "" +AccessKey = "" +SecretKey = "" +SecurityToken = "" +Namespace = "" +InstanceName = "" +GroupName = "" +[Entry.Services.Task] +Type = "none" +Name = "" +[Entry.Services.Task.Asynq] +Endpoint = "" +Password = "" +Db = 0 +Location = "" +[Entry.Services.Task.Machinery] +[Entry.Services.Task.Cron] +Addr = "" +[Entry.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Entry.Services.Middleware.Metadata] +Enabled = true +Prefix = "" +[Entry.Services.Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Entry.Services.Middleware.Metrics] +Enabled = true +[Entry.Services.Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Entry.Services.Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Entry.Services.Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Entry.Services.Middleware.Selector] +Enabled = false +Regex = "" +[Entry.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" diff --git a/resources/configs/admin/clients.toml b/resources/configs/admin/clients.toml new file mode 100644 index 00000000..76321bb9 --- /dev/null +++ b/resources/configs/admin/clients.toml @@ -0,0 +1,465 @@ +[[Clients]] +[Clients.Core] +Name = "system" +Version = "" +[Clients.Core.Discovery] +Type = "consul" +ServiceName = "origadmin.service.system.v1" +Debug = false +[Clients.Core.Discovery.Consul] +Address = "${consul_address:127.0.0.1:8500}" +Scheme = "http" +Token = "" +HeartBeat = true +HealthCheck = true +Datacenter = "" +HealthCheckInterval = 30 +Timeout = 0 +DeregisterCriticalServiceAfter = 0 + +[[Clients.Services]] +Name = "" +Type = "grpc" +DynamicEndpoint = true +[Clients.Services.Grpc] +Network = "tcp" +Addr = "${grpc_address:0.0.0.0:18000}" +UseTls = false +Timeout = 0 +ShutdownTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +IdleTimeout = 0 +Endpoint = "" +[Clients.Services.Websocket] +Network = "" +Addr = "" +Path = "" +Codec = "" +Timeout = 0 +[Clients.Services.Message] +Type = "none" +Name = "" +[Clients.Services.Message.Mqtt] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Kafka] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Rabbitmq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Activemq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Nats] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Nsq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Pulsar] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Redis] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Rocketmq] +Endpoint = "" +Codec = "" +EnableTrace = false +NameServerDomain = "" +AccessKey = "" +SecretKey = "" +SecurityToken = "" +Namespace = "" +InstanceName = "" +GroupName = "" +[Clients.Services.Task] +Type = "none" +Name = "" +[Clients.Services.Task.Asynq] +Endpoint = "" +Password = "" +Db = 0 +Location = "" +[Clients.Services.Task.Machinery] +[Clients.Services.Task.Cron] +Addr = "" +[Clients.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Clients.Services.Middleware.Metadata] +Enabled = true +Prefix = "" +[Clients.Services.Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Clients.Services.Middleware.Metrics] +Enabled = true +[Clients.Services.Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Clients.Services.Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Clients.Services.Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Clients.Services.Middleware.Selector] +Enabled = false +Regex = "" +[Clients.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" + +[[Clients.Services]] +Name = "" +Type = "http" +DynamicEndpoint = true +[Clients.Services.Http] +Network = "tcp" +Addr = "${http_address:0.0.0.0:18100}" +UseTls = false +Timeout = 0 +ShutdownTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +IdleTimeout = 0 +Endpoint = "" +[Clients.Services.Websocket] +Network = "" +Addr = "" +Path = "" +Codec = "" +Timeout = 0 +[Clients.Services.Message] +Type = "none" +Name = "" +[Clients.Services.Message.Mqtt] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Kafka] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Rabbitmq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Activemq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Nats] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Nsq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Pulsar] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Redis] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Rocketmq] +Endpoint = "" +Codec = "" +EnableTrace = false +NameServerDomain = "" +AccessKey = "" +SecretKey = "" +SecurityToken = "" +Namespace = "" +InstanceName = "" +GroupName = "" +[Clients.Services.Task] +Type = "none" +Name = "" +[Clients.Services.Task.Asynq] +Endpoint = "" +Password = "" +Db = 0 +Location = "" +[Clients.Services.Task.Machinery] +[Clients.Services.Task.Cron] +Addr = "" +[Clients.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Clients.Services.Middleware.Metadata] +Enabled = true +Prefix = "" +[Clients.Services.Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Clients.Services.Middleware.Metrics] +Enabled = true +[Clients.Services.Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Clients.Services.Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Clients.Services.Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Clients.Services.Middleware.Selector] +Enabled = false +Regex = "" +[Clients.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" + +[[Clients]] +[Clients.Core] +Name = "auth" +Version = "" +[Clients.Core.Discovery] +Type = "consul" +ServiceName = "origadmin.service.auth.v1" +Debug = false +[Clients.Core.Discovery.Consul] +Address = "${consul_address:127.0.0.1:8500}" +Scheme = "http" +Token = "" +HeartBeat = true +HealthCheck = true +Datacenter = "" +HealthCheckInterval = 30 +Timeout = 0 +DeregisterCriticalServiceAfter = 0 + +[[Clients.Services]] +Name = "" +Type = "grpc" +DynamicEndpoint = true +[Clients.Services.Grpc] +Network = "tcp" +Addr = "${grpc_address:0.0.0.0:18000}" +UseTls = false +Timeout = 0 +ShutdownTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +IdleTimeout = 0 +Endpoint = "" +[Clients.Services.Websocket] +Network = "" +Addr = "" +Path = "" +Codec = "" +Timeout = 0 +[Clients.Services.Message] +Type = "none" +Name = "" +[Clients.Services.Message.Mqtt] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Kafka] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Rabbitmq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Activemq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Nats] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Nsq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Pulsar] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Redis] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Rocketmq] +Endpoint = "" +Codec = "" +EnableTrace = false +NameServerDomain = "" +AccessKey = "" +SecretKey = "" +SecurityToken = "" +Namespace = "" +InstanceName = "" +GroupName = "" +[Clients.Services.Task] +Type = "none" +Name = "" +[Clients.Services.Task.Asynq] +Endpoint = "" +Password = "" +Db = 0 +Location = "" +[Clients.Services.Task.Machinery] +[Clients.Services.Task.Cron] +Addr = "" +[Clients.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Clients.Services.Middleware.Metadata] +Enabled = true +Prefix = "" +[Clients.Services.Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Clients.Services.Middleware.Metrics] +Enabled = true +[Clients.Services.Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Clients.Services.Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Clients.Services.Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Clients.Services.Middleware.Selector] +Enabled = false +Regex = "" +[Clients.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" + +[[Clients.Services]] +Name = "" +Type = "http" +DynamicEndpoint = true +[Clients.Services.Http] +Network = "tcp" +Addr = "${http_address:0.0.0.0:18100}" +UseTls = false +Timeout = 0 +ShutdownTimeout = 0 +ReadTimeout = 0 +WriteTimeout = 0 +IdleTimeout = 0 +Endpoint = "" +[Clients.Services.Websocket] +Network = "" +Addr = "" +Path = "" +Codec = "" +Timeout = 0 +[Clients.Services.Message] +Type = "none" +Name = "" +[Clients.Services.Message.Mqtt] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Kafka] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Rabbitmq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Activemq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Nats] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Nsq] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Pulsar] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Redis] +Endpoint = "" +Codec = "" +[Clients.Services.Message.Rocketmq] +Endpoint = "" +Codec = "" +EnableTrace = false +NameServerDomain = "" +AccessKey = "" +SecretKey = "" +SecurityToken = "" +Namespace = "" +InstanceName = "" +GroupName = "" +[Clients.Services.Task] +Type = "none" +Name = "" +[Clients.Services.Task.Asynq] +Endpoint = "" +Password = "" +Db = 0 +Location = "" +[Clients.Services.Task.Machinery] +[Clients.Services.Task.Cron] +Addr = "" +[Clients.Services.Middleware] +EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] +[Clients.Services.Middleware.Metadata] +Enabled = true +Prefix = "" +[Clients.Services.Middleware.RateLimiter] +Enabled = true +Name = "bbr" +Period = 0 +XRatelimitLimit = 0 +XRatelimitRemaining = 0 +XRatelimitReset = 0 +RetryAfter = 0 +[Clients.Services.Middleware.Metrics] +Enabled = true +[Clients.Services.Middleware.Validator] +Enabled = true +Version = 1 +FailFast = true +[Clients.Services.Middleware.Jwt] +Enabled = false +Subject = "" +ClaimType = "" +[Clients.Services.Middleware.Jwt.Config] +SigningMethod = "HS512" +Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" +Key2 = "can empty next version fixed" +AccessTokenLifetime = 900000000000 +RefreshTokenLifetime = 259200000000000 +Issuer = "localhost" +TokenType = "Bearer" +[Clients.Services.Middleware.Selector] +Enabled = false +Regex = "" +[Clients.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" diff --git a/resources/configs/admin/security.toml b/resources/configs/admin/security.toml index 34bc19e0..a24deb5b 100644 --- a/resources/configs/admin/security.toml +++ b/resources/configs/admin/security.toml @@ -1,4 +1,26 @@ [Security] +[Security.RootUser] +Enabled = true +Id = "" +Username = "admin" +Password = "admin" +Salt = "" +Name = "admin" +Email = "admin@admin.com" +Nickname = "admin" +Avatar = "" +Mobile = "1380000000" +Description = "" +AutoCreate = false +RandomPassword = true +[Security.Captcha] +Length = 4 +Width = 400 +Height = 160 +StorageName = "captcha" +[Security.Captcha.Storage] +Name = "" +Type = "" [Security.Security] PublicPaths = ["/swagger/*", "/api/v1/health", "/api/v1/health/*", "/api/v1/captcha", "/api/v1/captcha/*", "/api/v1/login", "/api/v1/register", "/api/v1/current/logout", "/api/v1/refresh_token", "/api.v1.services.system.LoginAPI/CaptchaId", "/api.v1.services.system.LoginAPI/CaptchaImage", "/api.v1.services.system.LoginAPI/CaptchaResource", "/api.v1.services.system.LoginAPI/CaptchaResources", "/api.v1.services.system.LoginAPI/Login", "/api.v1.services.system.LoginAPI/Register", "/api.v1.services.system.LoginAPI/Refresh"] [Security.Security.Authz] diff --git a/resources/configs/admin/service.toml b/resources/configs/admin/service.toml deleted file mode 100644 index 5a82f054..00000000 --- a/resources/configs/admin/service.toml +++ /dev/null @@ -1,213 +0,0 @@ -[[Server.Services]] -Name = "" -Type = "grpc" -DynamicEndpoint = true -[Server.Services.Grpc] -Network = "tcp" -Addr = "${grpc_address:0.0.0.0:18000}" -UseTls = false -Timeout = 0 -ShutdownTimeout = 0 -ReadTimeout = 0 -WriteTimeout = 0 -IdleTimeout = 0 -Endpoint = "" -[Server.Services.Websocket] -Network = "" -Addr = "" -Path = "" -Codec = "" -Timeout = 0 -[Server.Services.Message] -Type = "none" -Name = "" -[Server.Services.Message.Mqtt] -Endpoint = "" -Codec = "" -[Server.Services.Message.Kafka] -Endpoint = "" -Codec = "" -[Server.Services.Message.Rabbitmq] -Endpoint = "" -Codec = "" -[Server.Services.Message.Activemq] -Endpoint = "" -Codec = "" -[Server.Services.Message.Nats] -Endpoint = "" -Codec = "" -[Server.Services.Message.Nsq] -Endpoint = "" -Codec = "" -[Server.Services.Message.Pulsar] -Endpoint = "" -Codec = "" -[Server.Services.Message.Redis] -Endpoint = "" -Codec = "" -[Server.Services.Message.Rocketmq] -Endpoint = "" -Codec = "" -EnableTrace = false -NameServerDomain = "" -AccessKey = "" -SecretKey = "" -SecurityToken = "" -Namespace = "" -InstanceName = "" -GroupName = "" -[Server.Services.Task] -Type = "none" -Name = "" -[Server.Services.Task.Asynq] -Endpoint = "" -Password = "" -Db = 0 -Location = "" -[Server.Services.Task.Machinery] -[Server.Services.Task.Cron] -Addr = "" -[Server.Services.Middleware] -EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] -[Server.Services.Middleware.Metadata] -Enabled = true -Prefix = "" -[Server.Services.Middleware.RateLimiter] -Enabled = true -Name = "bbr" -Period = 0 -XRatelimitLimit = 0 -XRatelimitRemaining = 0 -XRatelimitReset = 0 -RetryAfter = 0 -[Server.Services.Middleware.Metrics] -Enabled = true -[Server.Services.Middleware.Validator] -Enabled = true -Version = 1 -FailFast = true -[Server.Services.Middleware.Jwt] -Enabled = false -Subject = "" -ClaimType = "" -[Server.Services.Middleware.Jwt.Config] -SigningMethod = "HS512" -Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" -Key2 = "can empty next version fixed" -AccessTokenLifetime = 900000000000 -RefreshTokenLifetime = 259200000000000 -Issuer = "localhost" -TokenType = "Bearer" -[Server.Services.Middleware.Selector] -Enabled = false -Regex = "" -[Server.Services.Selector] -Version = "v1.0.0" -Builder = "bbr" - -[[Server.Services]] -Name = "" -Type = "http" -DynamicEndpoint = true -[Server.Services.Http] -Network = "tcp" -Addr = "${http_address:0.0.0.0:18100}" -UseTls = false -Timeout = 0 -ShutdownTimeout = 0 -ReadTimeout = 0 -WriteTimeout = 0 -IdleTimeout = 0 -Endpoint = "" -[Server.Services.Websocket] -Network = "" -Addr = "" -Path = "" -Codec = "" -Timeout = 0 -[Server.Services.Message] -Type = "none" -Name = "" -[Server.Services.Message.Mqtt] -Endpoint = "" -Codec = "" -[Server.Services.Message.Kafka] -Endpoint = "" -Codec = "" -[Server.Services.Message.Rabbitmq] -Endpoint = "" -Codec = "" -[Server.Services.Message.Activemq] -Endpoint = "" -Codec = "" -[Server.Services.Message.Nats] -Endpoint = "" -Codec = "" -[Server.Services.Message.Nsq] -Endpoint = "" -Codec = "" -[Server.Services.Message.Pulsar] -Endpoint = "" -Codec = "" -[Server.Services.Message.Redis] -Endpoint = "" -Codec = "" -[Server.Services.Message.Rocketmq] -Endpoint = "" -Codec = "" -EnableTrace = false -NameServerDomain = "" -AccessKey = "" -SecretKey = "" -SecurityToken = "" -Namespace = "" -InstanceName = "" -GroupName = "" -[Server.Services.Task] -Type = "none" -Name = "" -[Server.Services.Task.Asynq] -Endpoint = "" -Password = "" -Db = 0 -Location = "" -[Server.Services.Task.Machinery] -[Server.Services.Task.Cron] -Addr = "" -[Server.Services.Middleware] -EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] -[Server.Services.Middleware.Metadata] -Enabled = true -Prefix = "" -[Server.Services.Middleware.RateLimiter] -Enabled = true -Name = "bbr" -Period = 0 -XRatelimitLimit = 0 -XRatelimitRemaining = 0 -XRatelimitReset = 0 -RetryAfter = 0 -[Server.Services.Middleware.Metrics] -Enabled = true -[Server.Services.Middleware.Validator] -Enabled = true -Version = 1 -FailFast = true -[Server.Services.Middleware.Jwt] -Enabled = false -Subject = "" -ClaimType = "" -[Server.Services.Middleware.Jwt.Config] -SigningMethod = "HS512" -Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" -Key2 = "can empty next version fixed" -AccessTokenLifetime = 900000000000 -RefreshTokenLifetime = 259200000000000 -Issuer = "localhost" -TokenType = "Bearer" -[Server.Services.Middleware.Selector] -Enabled = false -Regex = "" -[Server.Services.Selector] -Version = "v1.0.0" -Builder = "bbr" diff --git a/resources/configs/admin/storage.toml b/resources/configs/admin/storage.toml index 15906e90..6734f091 100644 --- a/resources/configs/admin/storage.toml +++ b/resources/configs/admin/storage.toml @@ -3,8 +3,8 @@ Name = "" Type = "" [Storage.Database] Debug = false -Dialect = "sqlite3" -Source = "data/admin.db" +Dialect = "${database_dialect:sqlite3}" +Source = "${database_source:data/admin.db}" EnableTrace = false EnableMetrics = false MaxIdleConnections = 0 diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index e9346867..32c87bed 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -17,293 +17,155 @@ servers: - url: http://localhost:10080 - url: https://localhost:10080 paths: - /captcha: - get: - tags: - - LoginService - operationId: LoginService_Captcha - parameters: - - name: id - in: query - description: The id of the captcha - schema: - type: string - - name: type - in: query - description: The type of the captcha - schema: - type: string - - name: reload - in: query - description: The reload is used to reload the captcha - schema: - type: boolean - - name: ts - in: query - description: The timestamp of the request prevent caching of the same result - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.CaptchaResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /captcha/audio: - get: + /auth/authenticate: + post: tags: - - LoginService - operationId: LoginService_CaptchaAudio - parameters: - - name: id - in: query - schema: - type: string - - name: reload - in: query - schema: - type: string - - name: data.type_url - in: query - description: |- - A URL/resource name that uniquely identifies the type of the serialized - protocol buffer message. This string must contain at least - one "/" character. The last segment of the URL's path must represent - the fully qualified name of the type (as in - `path/google.protobuf.Duration`). The name should be in a canonical form - (e.g., leading "." is not accepted). - - In practice, teams usually precompile into the binary all types that they - expect it to use in the context of Any. However, for URLs which use the - scheme `http`, `https`, or no scheme, one can optionally set up a type - server that maps type URLs to message definitions as follows: - - * If no scheme is provided, `https` is assumed. - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the official - protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. As of May 2023, there are no widely used type server - implementations and no plans to implement one. - - Schemes other than `http`, `https` (or the empty scheme) might be - used with implementation specific semantics. - schema: - type: string - - name: data.value - in: query - description: Must be a valid serialized protocol buffer of the above specified type. - schema: - type: string - format: bytes + - AuthService + description: Authenticate authenticates a user. + operationId: AuthService_Authenticate + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.AuthenticateRequest_Data' + required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.CaptchaAudioResponse' + $ref: '#/components/schemas/api.v1.services.auth.AuthenticateResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /captcha/id: - get: + /auth/destroy: + post: tags: - - LoginService - operationId: LoginService_CaptchaId - parameters: - - name: ts - in: query - description: The timestamp of the request prevent caching of the same result - schema: - type: string - - name: reload - in: query - schema: - type: boolean + - AuthService + description: DestroyToken invalidates a JWT token. + operationId: AuthService_DestroyToken + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.DestroyTokenRequest_Data' + required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.CaptchaIdResponse' + $ref: '#/components/schemas/api.v1.services.auth.DestroyTokenResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /captcha/image: - get: + /auth/logout: + post: tags: - - LoginService - operationId: LoginService_CaptchaImage - parameters: - - name: id - in: query - schema: - type: string - - name: reload - in: query - schema: - type: string - - name: data.type_url - in: query - description: |- - A URL/resource name that uniquely identifies the type of the serialized - protocol buffer message. This string must contain at least - one "/" character. The last segment of the URL's path must represent - the fully qualified name of the type (as in - `path/google.protobuf.Duration`). The name should be in a canonical form - (e.g., leading "." is not accepted). - - In practice, teams usually precompile into the binary all types that they - expect it to use in the context of Any. However, for URLs which use the - scheme `http`, `https`, or no scheme, one can optionally set up a type - server that maps type URLs to message definitions as follows: - - * If no scheme is provided, `https` is assumed. - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the official - protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. As of May 2023, there are no widely used type server - implementations and no plans to implement one. - - Schemes other than `http`, `https` (or the empty scheme) might be - used with implementation specific semantics. - schema: - type: string - - name: data.value - in: query - description: Must be a valid serialized protocol buffer of the above specified type. - schema: - type: string - format: bytes + - AuthService + description: AuthLogout logs out a user. + operationId: AuthService_AuthLogout + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.AuthLogoutRequest_Data' + required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.CaptchaImageResponse' + $ref: '#/components/schemas/api.v1.services.auth.AuthLogoutResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /casbin/groupings: - get: + /auth/personal/logout: + post: tags: - - CasbinSourceService - operationId: CasbinSourceService_ListGroupings + - PersonalService + description: PersonalLogout Personal user logs out + operationId: PersonalService_PersonalLogout + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/google.protobuf.Any' + required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.ListGroupingsResponse' + $ref: '#/components/schemas/api.v1.services.auth.PersonalLogoutResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /casbin/policies: - get: + /auth/personal/password: + put: tags: - - CasbinSourceService - operationId: CasbinSourceService_ListPolicies + - PersonalService + description: UpdatePersonalProfilePassword The user changes the password + operationId: PersonalService_UpdatePersonalPassword + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/google.protobuf.Any' + required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.ListPoliciesResponse' + $ref: '#/components/schemas/api.v1.services.auth.UpdatePersonalPasswordResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /casbin/watch: + /auth/personal/profile: get: tags: - - CasbinSourceService - operationId: CasbinSourceService_WatchUpdate - parameters: - - name: last_modified - in: query - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.WatchUpdateResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /login: - post: - tags: - - LoginService - operationId: LoginService_Login - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.LoginRequest_Data' - required: true + - PersonalService + description: GetPersonalProfile Update the personal user information + operationId: PersonalService_GetPersonalProfile responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.LoginResponse' + $ref: '#/components/schemas/api.v1.services.auth.GetPersonalProfileResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /logout: - post: + put: tags: - - LoginService - operationId: LoginService_Logout + - PersonalService + description: UpdatePersonalProfile Update the personal user information + operationId: PersonalService_UpdatePersonalProfile requestBody: content: application/json: @@ -316,73 +178,95 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.LogoutResponse' + $ref: '#/components/schemas/api.v1.services.auth.UpdatePersonalProfileResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /register: - post: + /auth/personal/resources: + get: tags: - - LoginService - operationId: LoginService_Register - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.RegisterRequest_Data' - required: true + - PersonalService + description: ListPersonalResources List the personal user's menu + operationId: PersonalService_ListPersonalResources + parameters: + - name: id + in: query + description: The parent resource id, for example, "shelves/shelf1". + schema: + type: string + - name: current + in: query + description: The current page number. + schema: + type: integer + format: int32 + - name: page_size + in: query + description: The maximum number of items to return. + schema: + type: integer + format: int32 + - name: page_token + in: query + description: The next_page_token value returned from a previous List request, if any. + schema: + type: string + - name: no_paging + in: query + description: The no_paging is used to disable pagination. + schema: + type: boolean + - name: only_count + in: query + description: The only_count is the query parameter for set only to query the total number + schema: + type: boolean responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListPersonalResourcesResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/auth/authenticate: - post: + /auth/personal/roles: + get: tags: - - AuthService - description: Authenticate authenticates a user. - operationId: AuthService_Authenticate - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.AuthenticateRequest_Data' - required: true + - PersonalService + description: ListPersonalResources List the personal user's menu + operationId: PersonalService_ListPersonalRoles responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.AuthenticateResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListPersonalRolesResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/auth/destroy: - post: + /auth/personal/setting: + put: tags: - - AuthService - description: DestroyToken invalidates a JWT token. - operationId: AuthService_DestroyToken + - PersonalService + description: UpdatePersonalSetting User settings are saved + operationId: PersonalService_UpdatePersonalSetting requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.DestroyTokenRequest_Data' + $ref: '#/components/schemas/google.protobuf.Any' required: true responses: "200": @@ -390,24 +274,24 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.DestroyTokenResponse' + $ref: '#/components/schemas/api.v1.services.auth.UpdatePersonalSettingResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/auth/logout: + /auth/personal/token/refresh: post: tags: - - AuthService - description: AuthLogout logs out a user. - operationId: AuthService_AuthLogout + - PersonalService + description: RefreshPersonalToken Refresh the personal user's token + operationId: PersonalService_RefreshPersonalToken requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.AuthLogoutRequest_Data' + $ref: '#/components/schemas/google.protobuf.Any' required: true responses: "200": @@ -415,56 +299,14 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.AuthLogoutResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /sys/auth/resources: - get: - tags: - - AuthService - description: ListAuthResources returns a list of Auths. - operationId: AuthService_ListAuthResources - parameters: - - name: page_size - in: query - description: The maximum number of Auths to return. - schema: - type: integer - format: int32 - - name: page_token - in: query - description: The next_page_token value returned from a previous List request, if any. - schema: - type: string - - name: current - in: query - description: The current page number. - schema: - type: integer - format: int32 - - name: no_paging - in: query - description: The no_paging is used to disable pagination. - schema: - type: boolean - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.ListAuthResourcesResponse' + $ref: '#/components/schemas/api.v1.services.auth.RefreshPersonalTokenResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/auth/token: + /auth/token: post: tags: - AuthService @@ -489,15 +331,30 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/auth/validate: - get: - tags: - - AuthService - description: ValidateToken verifies the validity of a JWT token. - operationId: AuthService_ValidateToken + /captcha: + get: + tags: + - LoginService + operationId: LoginService_Captcha parameters: - - name: token + - name: id + in: query + description: The id of the captcha + schema: + type: string + - name: type + in: query + description: The type of the captcha + schema: + type: string + - name: reload in: query + description: The reload is used to reload the captcha + schema: + type: boolean + - name: ts + in: query + description: The timestamp of the request prevent caching of the same result schema: type: string responses: @@ -506,257 +363,266 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.ValidateTokenResponse' + $ref: '#/components/schemas/api.v1.services.auth.CaptchaResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/departments: + /captcha/audio: get: tags: - - DepartmentService - operationId: DepartmentService_ListDepartments + - LoginService + operationId: LoginService_CaptchaAudio parameters: - name: id in: query - description: The parent resource id, for example, "shelves/shelf1". schema: type: string - - name: current - in: query - description: The current page number. - schema: - type: integer - format: int32 - - name: page_size - in: query - description: The maximum number of items to return. - schema: - type: integer - format: int32 - - name: page_token + - name: reload in: query - description: The next_page_token value returned from a previous List request, if any. schema: type: string - - name: no_paging + - name: data.type_url in: query - description: The no_paging is used to disable pagination. + description: |- + A URL/resource name that uniquely identifies the type of the serialized + protocol buffer message. This string must contain at least + one "/" character. The last segment of the URL's path must represent + the fully qualified name of the type (as in + `path/google.protobuf.Duration`). The name should be in a canonical form + (e.g., leading "." is not accepted). + + In practice, teams usually precompile into the binary all types that they + expect it to use in the context of Any. However, for URLs which use the + scheme `http`, `https`, or no scheme, one can optionally set up a type + server that maps type URLs to message definitions as follows: + + * If no scheme is provided, `https` is assumed. + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in the official + protobuf release, and it is not used for type URLs beginning with + type.googleapis.com. As of May 2023, there are no widely used type server + implementations and no plans to implement one. + + Schemes other than `http`, `https` (or the empty scheme) might be + used with implementation specific semantics. schema: - type: boolean - - name: only_count + type: string + - name: data.value in: query - description: The only_count is the query parameter for set only to query the total number + description: Must be a valid serialized protocol buffer of the above specified type. schema: - type: boolean + type: string + format: bytes responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.ListDepartmentsResponse' + $ref: '#/components/schemas/api.v1.services.auth.CaptchaAudioResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - post: + /captcha/id: + get: tags: - - DepartmentService - operationId: DepartmentService_CreateDepartment + - LoginService + operationId: LoginService_CaptchaId parameters: - - name: parent + - name: ts in: query - description: The parent resource id where the department is to be created. + description: The timestamp of the request prevent caching of the same result schema: type: string - - name: department_id + - name: reload in: query - description: The department id to use for this department. schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.types.Department' - required: true + type: boolean responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.CreateDepartmentResponse' + $ref: '#/components/schemas/api.v1.services.auth.CaptchaIdResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/departments/{department.id}: - put: + /captcha/image: + get: tags: - - DepartmentService - operationId: DepartmentService_UpdateDepartment + - LoginService + operationId: LoginService_CaptchaImage parameters: - - name: department.id - in: path - required: true + - name: id + in: query schema: type: string - - name: id + - name: reload in: query - description: The department id to use for this department. schema: type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.types.Department' - required: true + - name: data.type_url + in: query + description: |- + A URL/resource name that uniquely identifies the type of the serialized + protocol buffer message. This string must contain at least + one "/" character. The last segment of the URL's path must represent + the fully qualified name of the type (as in + `path/google.protobuf.Duration`). The name should be in a canonical form + (e.g., leading "." is not accepted). + + In practice, teams usually precompile into the binary all types that they + expect it to use in the context of Any. However, for URLs which use the + scheme `http`, `https`, or no scheme, one can optionally set up a type + server that maps type URLs to message definitions as follows: + + * If no scheme is provided, `https` is assumed. + * An HTTP GET on the URL must yield a [google.protobuf.Type][] + value in binary format, or produce an error. + * Applications are allowed to cache lookup results based on the + URL, or have them precompiled into a binary to avoid any + lookup. Therefore, binary compatibility needs to be preserved + on changes to types. (Use versioned type names to manage + breaking changes.) + + Note: this functionality is not currently available in the official + protobuf release, and it is not used for type URLs beginning with + type.googleapis.com. As of May 2023, there are no widely used type server + implementations and no plans to implement one. + + Schemes other than `http`, `https` (or the empty scheme) might be + used with implementation specific semantics. + schema: + type: string + - name: data.value + in: query + description: Must be a valid serialized protocol buffer of the above specified type. + schema: + type: string + format: bytes responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.UpdateDepartmentResponse' + $ref: '#/components/schemas/api.v1.services.auth.CaptchaImageResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/departments/{id}: + /casbin/groupings: get: tags: - - DepartmentService - operationId: DepartmentService_GetDepartment - parameters: - - name: id - in: path - description: |- - The field will contain id of the resource requested, for example: - "shelves/shelf1/departments/department2" - required: true - schema: - type: string + - CasbinSourceService + operationId: CasbinSourceService_ListGroupings responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.GetDepartmentResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListGroupingsResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - delete: + /casbin/policies: + get: tags: - - DepartmentService - operationId: DepartmentService_DeleteDepartment - parameters: - - name: id - in: path - description: |- - The resource id of the department to be deleted, for example: - "shelves/shelf1/departments/department2" - required: true - schema: - type: string + - CasbinSourceService + operationId: CasbinSourceService_ListPolicies responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.DeleteDepartmentResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListPoliciesResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/menus: + /casbin/watch: get: tags: - - MenuService - operationId: MenuService_ListMenus + - CasbinSourceService + operationId: CasbinSourceService_WatchUpdate parameters: - - name: id - in: query - description: The parent resource id, for example, "shelves/shelf1". - schema: - type: string - - name: current - in: query - description: The current page number. - schema: - type: integer - format: int32 - - name: page_size - in: query - description: The maximum number of items to return. - schema: - type: integer - format: int32 - - name: page_token + - name: last_modified in: query - description: The next_page_token value returned from a previous List request, if any. schema: type: string - - name: no_paging - in: query - description: The no_paging is used to disable pagination. - schema: - type: boolean - - name: only_count - in: query - description: The only_count is the query parameter for set only to query the total number - schema: - type: boolean responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.ListMenusResponse' + $ref: '#/components/schemas/api.v1.services.auth.WatchUpdateResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /login: + post: + tags: + - LoginService + operationId: LoginService_Login + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.LoginRequest_Data' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.LoginResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' + /logout: post: tags: - - MenuService - operationId: MenuService_CreateMenu - parameters: - - name: parent - in: query - description: The parent resource id where the menu is to be created. - schema: - type: string - - name: menu_id - in: query - description: The menu id to use for this menu. - schema: - type: string + - LoginService + operationId: LoginService_Logout requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Menu' + $ref: '#/components/schemas/google.protobuf.Any' required: true responses: "200": @@ -764,101 +630,108 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.CreateMenuResponse' + $ref: '#/components/schemas/api.v1.services.auth.LogoutResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/menus/{id}: - get: + /register: + post: tags: - - MenuService - operationId: MenuService_GetMenu - parameters: - - name: id - in: path - description: |- - The field will contain id of the resource requested, for example: - "shelves/shelf1/menus/menu2" - required: true - schema: - type: string + - LoginService + operationId: LoginService_Register + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.RegisterRequest_Data' + required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.GetMenuResponse' + $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - delete: + /sys/auth/resources: + get: tags: - - MenuService - operationId: MenuService_DeleteMenu + - AuthService + description: ListAuthResources returns a list of Auths. + operationId: AuthService_ListAuthResources parameters: - - name: id - in: path - description: |- - The resource id of the menu to be deleted, for example: - "shelves/shelf1/menus/menu2" - required: true + - name: page_size + in: query + description: The maximum number of Auths to return. + schema: + type: integer + format: int32 + - name: page_token + in: query + description: The next_page_token value returned from a previous List request, if any. schema: type: string + - name: current + in: query + description: The current page number. + schema: + type: integer + format: int32 + - name: no_paging + in: query + description: The no_paging is used to disable pagination. + schema: + type: boolean responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.DeleteMenuResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListAuthResourcesResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/menus/{menu.id}: - put: + /sys/auth/validate: + get: tags: - - MenuService - operationId: MenuService_UpdateMenu + - AuthService + description: ValidateToken verifies the validity of a JWT token. + operationId: AuthService_ValidateToken parameters: - - name: menu.id - in: path - required: true + - name: token + in: query schema: type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.types.Menu' - required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.UpdateMenuResponse' + $ref: '#/components/schemas/api.v1.services.auth.ValidateTokenResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/permissions: + /sys/departments: get: tags: - - PermissionService - operationId: PermissionService_ListPermissions + - DepartmentService + operationId: DepartmentService_ListDepartments parameters: - name: id in: query @@ -892,20 +765,13 @@ paths: description: The only_count is the query parameter for set only to query the total number schema: type: boolean - - name: data_scopes - in: query - description: The data_scopes is used to query the permission by data scopes. - schema: - type: array - items: - type: string responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.ListPermissionsResponse' + $ref: '#/components/schemas/api.v1.services.system.ListDepartmentsResponse' default: description: Default error response content: @@ -914,24 +780,24 @@ paths: $ref: '#/components/schemas/google.rpc.Status' post: tags: - - PermissionService - operationId: PermissionService_CreatePermission + - DepartmentService + operationId: DepartmentService_CreateDepartment parameters: - name: parent in: query - description: The parent resource id where the permission is to be created. + description: The parent resource id where the department is to be created. schema: type: string - - name: permission_id + - name: department_id in: query - description: The permission id to use for this permission. + description: The department id to use for this department. schema: type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Permission' + $ref: '#/components/schemas/api.v1.services.types.Department' required: true responses: "200": @@ -939,24 +805,59 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.CreatePermissionResponse' + $ref: '#/components/schemas/api.v1.services.system.CreateDepartmentResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/permissions/{id}: + /sys/departments/{department.id}: + put: + tags: + - DepartmentService + operationId: DepartmentService_UpdateDepartment + parameters: + - name: department.id + in: path + required: true + schema: + type: string + - name: id + in: query + description: The department id to use for this department. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.types.Department' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.UpdateDepartmentResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /sys/departments/{id}: get: tags: - - PermissionService - operationId: PermissionService_GetPermission + - DepartmentService + operationId: DepartmentService_GetDepartment parameters: - name: id in: path description: |- The field will contain id of the resource requested, for example: - "shelves/shelf1/permissions/permission2" + "shelves/shelf1/departments/department2" required: true schema: type: string @@ -966,7 +867,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.GetPermissionResponse' + $ref: '#/components/schemas/api.v1.services.system.GetDepartmentResponse' default: description: Default error response content: @@ -975,14 +876,14 @@ paths: $ref: '#/components/schemas/google.rpc.Status' delete: tags: - - PermissionService - operationId: PermissionService_DeletePermission + - DepartmentService + operationId: DepartmentService_DeleteDepartment parameters: - name: id in: path description: |- - The resource id of the permission to be deleted, for example: - "shelves/shelf1/permissions/permission2" + The resource id of the department to be deleted, for example: + "shelves/shelf1/departments/department2" required: true schema: type: string @@ -992,59 +893,84 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.DeletePermissionResponse' + $ref: '#/components/schemas/api.v1.services.system.DeleteDepartmentResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/permissions/{permission.id}: - put: + /sys/menus: + get: tags: - - PermissionService - operationId: PermissionService_UpdatePermission + - MenuService + operationId: MenuService_ListMenus parameters: - - name: permission.id - in: path - required: true + - name: id + in: query + description: The parent resource id, for example, "shelves/shelf1". schema: type: string - - name: id + - name: current in: query - description: The resource name of the permission to update. + description: The current page number. + schema: + type: integer + format: int32 + - name: page_size + in: query + description: The maximum number of items to return. + schema: + type: integer + format: int32 + - name: page_token + in: query + description: The next_page_token value returned from a previous List request, if any. schema: type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.types.Permission' - required: true + - name: no_paging + in: query + description: The no_paging is used to disable pagination. + schema: + type: boolean + - name: only_count + in: query + description: The only_count is the query parameter for set only to query the total number + schema: + type: boolean responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.UpdatePermissionResponse' + $ref: '#/components/schemas/api.v1.services.system.ListMenusResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/personal/logout: post: - tags: - - PersonalService - description: PersonalLogout Personal user logs out - operationId: PersonalService_PersonalLogout + tags: + - MenuService + operationId: MenuService_CreateMenu + parameters: + - name: parent + in: query + description: The parent resource id where the menu is to be created. + schema: + type: string + - name: menu_id + in: query + description: The menu id to use for this menu. + schema: + type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/google.protobuf.Any' + $ref: '#/components/schemas/api.v1.services.types.Menu' required: true responses: "200": @@ -1052,67 +978,82 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.PersonalLogoutResponse' + $ref: '#/components/schemas/api.v1.services.system.CreateMenuResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/personal/password: - put: + /sys/menus/{id}: + get: tags: - - PersonalService - description: UpdatePersonalProfilePassword The user changes the password - operationId: PersonalService_UpdatePersonalPassword - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.protobuf.Any' - required: true + - MenuService + operationId: MenuService_GetMenu + parameters: + - name: id + in: path + description: |- + The field will contain id of the resource requested, for example: + "shelves/shelf1/menus/menu2" + required: true + schema: + type: string responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.UpdatePersonalPasswordResponse' + $ref: '#/components/schemas/api.v1.services.system.GetMenuResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/personal/profile: - get: + delete: tags: - - PersonalService - description: GetPersonalProfile Update the personal user information - operationId: PersonalService_GetPersonalProfile + - MenuService + operationId: MenuService_DeleteMenu + parameters: + - name: id + in: path + description: |- + The resource id of the menu to be deleted, for example: + "shelves/shelf1/menus/menu2" + required: true + schema: + type: string responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.GetPersonalProfileResponse' + $ref: '#/components/schemas/api.v1.services.system.DeleteMenuResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' + /sys/menus/{menu.id}: put: tags: - - PersonalService - description: UpdatePersonalProfile Update the personal user information - operationId: PersonalService_UpdatePersonalProfile + - MenuService + operationId: MenuService_UpdateMenu + parameters: + - name: menu.id + in: path + required: true + schema: + type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/google.protobuf.Any' + $ref: '#/components/schemas/api.v1.services.types.Menu' required: true responses: "200": @@ -1120,19 +1061,18 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.UpdatePersonalProfileResponse' + $ref: '#/components/schemas/api.v1.services.system.UpdateMenuResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/personal/resources: + /sys/permissions: get: tags: - - PersonalService - description: ListPersonalResources List the personal user's menu - operationId: PersonalService_ListPersonalResources + - PermissionService + operationId: PermissionService_ListPermissions parameters: - name: id in: query @@ -1166,74 +1106,134 @@ paths: description: The only_count is the query parameter for set only to query the total number schema: type: boolean + - name: data_scopes + in: query + description: The data_scopes is used to query the permission by data scopes. + schema: + type: array + items: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.ListPermissionsResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + post: + tags: + - PermissionService + operationId: PermissionService_CreatePermission + parameters: + - name: parent + in: query + description: The parent resource id where the permission is to be created. + schema: + type: string + - name: permission_id + in: query + description: The permission id to use for this permission. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.types.Permission' + required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.ListPersonalResourcesResponse' + $ref: '#/components/schemas/api.v1.services.system.CreatePermissionResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/personal/roles: + /sys/permissions/{id}: get: tags: - - PersonalService - description: ListPersonalResources List the personal user's menu - operationId: PersonalService_ListPersonalRoles + - PermissionService + operationId: PermissionService_GetPermission + parameters: + - name: id + in: path + description: |- + The field will contain id of the resource requested, for example: + "shelves/shelf1/permissions/permission2" + required: true + schema: + type: string responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.ListPersonalRolesResponse' + $ref: '#/components/schemas/api.v1.services.system.GetPermissionResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/personal/setting: - put: + delete: tags: - - PersonalService - description: UpdatePersonalSetting User settings are saved - operationId: PersonalService_UpdatePersonalSetting - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.protobuf.Any' - required: true + - PermissionService + operationId: PermissionService_DeletePermission + parameters: + - name: id + in: path + description: |- + The resource id of the permission to be deleted, for example: + "shelves/shelf1/permissions/permission2" + required: true + schema: + type: string responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.UpdatePersonalSettingResponse' + $ref: '#/components/schemas/api.v1.services.system.DeletePermissionResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/personal/token/refresh: - post: + /sys/permissions/{permission.id}: + put: tags: - - PersonalService - description: RefreshPersonalToken Refresh the personal user's token - operationId: PersonalService_RefreshPersonalToken + - PermissionService + operationId: PermissionService_UpdatePermission + parameters: + - name: permission.id + in: path + required: true + schema: + type: string + - name: id + in: query + description: The resource name of the permission to update. + schema: + type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/google.protobuf.Any' + $ref: '#/components/schemas/api.v1.services.types.Permission' required: true responses: "200": @@ -1241,7 +1241,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.RefreshPersonalTokenResponse' + $ref: '#/components/schemas/api.v1.services.system.UpdatePermissionResponse' default: description: Default error response content: @@ -2347,6 +2347,11 @@ components: type: object properties: {} description: DestroyTokenResponse contains the result of the invalidation. + api.v1.services.auth.GetPersonalProfileResponse: + type: object + properties: + user: + $ref: '#/components/schemas/api.v1.services.types.User' api.v1.services.auth.GroupingRule: type: object properties: @@ -2375,6 +2380,27 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.auth.GroupingRule' + api.v1.services.auth.ListPersonalResourcesResponse: + type: object + properties: + total_size: + type: string + description: The total number of items in the list. + resources: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.Resource' + description: list of resources + next_page_token: + type: string + description: "Token to retrieve the next page of results, or empty if there are no\r\n more results in the list." + api.v1.services.auth.ListPersonalRolesResponse: + type: object + properties: + roles: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.Role' api.v1.services.auth.ListPoliciesResponse: type: object properties: @@ -2403,6 +2429,11 @@ components: properties: success: type: boolean + api.v1.services.auth.PersonalLogoutResponse: + type: object + properties: + success: + type: boolean api.v1.services.auth.PolicyRule: type: object properties: @@ -2412,6 +2443,11 @@ components: type: array items: type: string + api.v1.services.auth.RefreshPersonalTokenResponse: + type: object + properties: + token: + type: string api.v1.services.auth.RegisterRequest_Data: type: object properties: @@ -2445,6 +2481,15 @@ components: properties: token: $ref: '#/components/schemas/security.jwt.v1.Token' + api.v1.services.auth.UpdatePersonalPasswordResponse: + type: object + properties: {} + api.v1.services.auth.UpdatePersonalProfileResponse: + type: object + properties: {} + api.v1.services.auth.UpdatePersonalSettingResponse: + type: object + properties: {} api.v1.services.auth.ValidateTokenResponse: type: object properties: @@ -2538,11 +2583,6 @@ components: properties: permission: $ref: '#/components/schemas/api.v1.services.types.Permission' - api.v1.services.system.GetPersonalProfileResponse: - type: object - properties: - user: - $ref: '#/components/schemas/api.v1.services.types.User' api.v1.services.system.GetPositionResponse: type: object properties: @@ -2660,27 +2700,6 @@ components: description: |- Additional information about this response. content to be added without destroying the current data format - api.v1.services.system.ListPersonalResourcesResponse: - type: object - properties: - total_size: - type: string - description: The total number of items in the list. - resources: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Resource' - description: list of resources - next_page_token: - type: string - description: "Token to retrieve the next page of results, or empty if there are no\r\n more results in the list." - api.v1.services.system.ListPersonalRolesResponse: - type: object - properties: - roles: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Role' api.v1.services.system.ListPositionsResponse: type: object properties: @@ -2816,16 +2835,6 @@ components: description: |- Additional information about this response. content to be added without destroying the current data format - api.v1.services.system.PersonalLogoutResponse: - type: object - properties: - success: - type: boolean - api.v1.services.system.RefreshPersonalTokenResponse: - type: object - properties: - token: - type: string api.v1.services.system.ResetUserPasswordResponse: type: object properties: {} @@ -2845,15 +2854,6 @@ components: properties: permission: $ref: '#/components/schemas/api.v1.services.types.Permission' - api.v1.services.system.UpdatePersonalPasswordResponse: - type: object - properties: {} - api.v1.services.system.UpdatePersonalProfileResponse: - type: object - properties: {} - api.v1.services.system.UpdatePersonalSettingResponse: - type: object - properties: {} api.v1.services.system.UpdatePositionResponse: type: object properties: diff --git a/test/token_test.go b/test/token_test.go index a7272af4..3009b294 100644 --- a/test/token_test.go +++ b/test/token_test.go @@ -106,7 +106,7 @@ func TestGenerateToken(t *testing.T) { panic(err) } //adapter := casbin.NewAdapter() - authorizer, err := securityx.NewAuthorizer(bs, casbin.WithServiceClient(casbinSourceServiceClient)) + authorizer, err := securityx.NewAuthorizer(bs, casbin.WithSource(casbinSourceServiceClient)) if err != nil { panic(err) } From 5dba47d844caa67230c5f518712e8981fd4ef7ef Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 10 Jun 2025 13:45:53 +0800 Subject: [PATCH 040/158] refactor(api): update auth service API paths - Change HTTP paths for auth service methods: - ListAuthResources: /sys/auth/resources -> /auth/resources - ValidateToken: /sys/auth/validate -> /auth/validate - Update related files to reflect these path changes: - auth.proto - auth.pb.go - auth.pb.gw.go - auth_bridge.pb.go - auth_http.pb.go - casbin_bridge.pb.go - login_bridge.pb.go --- api/v1/proto/auth/auth.proto | 4 +- api/v1/services/auth/auth.pb.go | 10 +- api/v1/services/auth/auth.pb.gw.go | 12 +- api/v1/services/auth/auth_bridge.pb.go | 18 +- api/v1/services/auth/auth_http.pb.go | 8 +- api/v1/services/auth/casbin_bridge.pb.go | 14 +- api/v1/services/auth/login_bridge.pb.go | 14 +- api/v1/services/auth/personal.pb.go | 1074 ++++++++ api/v1/services/auth/personal.pb.gw.go | 594 ++++ api/v1/services/auth/personal.pb.validate.go | 2390 +++++++++++++++++ api/v1/services/auth/personal_bridge.pb.go | 565 ++++ api/v1/services/auth/personal_grpc.pb.go | 407 +++ api/v1/services/auth/personal_http.pb.go | 350 +++ .../services/system/department_bridge.pb.go | 14 +- api/v1/services/system/menu_bridge.pb.go | 14 +- .../services/system/permission_bridge.pb.go | 14 +- api/v1/services/system/position_bridge.pb.go | 14 +- api/v1/services/system/resource_bridge.pb.go | 14 +- api/v1/services/system/role_bridge.pb.go | 14 +- api/v1/services/system/user_bridge.pb.go | 14 +- cmd/internal/start/wire.go | 2 +- internal/mods/auth/service/auth.bridge.go | 4 +- internal/mods/auth/service/auth.grpc.go | 5 - internal/mods/auth/service/casbin.bridge.go | 2 +- internal/mods/auth/service/login.bridge.go | 2 +- internal/mods/auth/service/personal.bridge.go | 9 +- internal/mods/auth/service/service.go | 47 + internal/mods/system/service/menu.bridge.go | 2 +- internal/mods/system/service/menu.grpc.go | 2 +- internal/mods/system/service/menu.http.go | 2 +- .../mods/system/service/permission.bridge.go | 2 +- .../mods/system/service/permission.grpc.go | 2 +- .../mods/system/service/permission.http.go | 2 +- .../mods/system/service/resource.bridge.go | 2 +- internal/mods/system/service/resource.grpc.go | 2 +- internal/mods/system/service/role.bridge.go | 2 +- internal/mods/system/service/role.grpc.go | 2 +- internal/mods/system/service/service.go | 62 +- internal/mods/system/service/user.bridge.go | 4 +- internal/mods/system/service/user.grpc.go | 2 +- resources/docs/openapi/openapi.yaml | 132 +- 41 files changed, 5665 insertions(+), 184 deletions(-) create mode 100644 api/v1/services/auth/personal.pb.go create mode 100644 api/v1/services/auth/personal.pb.gw.go create mode 100644 api/v1/services/auth/personal.pb.validate.go create mode 100644 api/v1/services/auth/personal_bridge.pb.go create mode 100644 api/v1/services/auth/personal_grpc.pb.go create mode 100644 api/v1/services/auth/personal_http.pb.go diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index b0aaaea0..ab4f0c57 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -15,7 +15,7 @@ option objc_class_prefix = "APIServiceAuthAuth"; service AuthService { // ListAuthResources returns a list of Auths. rpc ListAuthResources(ListAuthResourcesRequest) returns (ListAuthResourcesResponse) { - option (google.api.http) = {get: "/sys/auth/resources"}; + option (google.api.http) = {get: "/auth/resources"}; } // CreateToken generates a new JWT token for the given user. rpc CreateToken(CreateTokenRequest) returns (CreateTokenResponse) { @@ -27,7 +27,7 @@ service AuthService { // ValidateToken verifies the validity of a JWT token. rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse) { - option (google.api.http) = {get: "/sys/auth/validate"}; + option (google.api.http) = {get: "/auth/validate"}; } // DestroyToken invalidates a JWT token. diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index 77ec7420..79cee26f 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -864,11 +864,11 @@ const file_auth_auth_proto_rawDesc = "" + "\x06method\x18\x04 \x01(\tR\x06method\x12\x1c\n" + "\toperation\x18\x05 \x01(\tR\toperation\"2\n" + "\x14AuthenticateResponse\x12\x1a\n" + - "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xb3\x06\n" + - "\vAuthService\x12\x91\x01\n" + - "\x11ListAuthResources\x12..api.v1.services.auth.ListAuthResourcesRequest\x1a/.api.v1.services.auth.ListAuthResourcesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/auth/resources\x12}\n" + - "\vCreateToken\x12(.api.v1.services.auth.CreateTokenRequest\x1a).api.v1.services.auth.CreateTokenResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x04data\"\v/auth/token\x12\x84\x01\n" + - "\rValidateToken\x12*.api.v1.services.auth.ValidateTokenRequest\x1a+.api.v1.services.auth.ValidateTokenResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/sys/auth/validate\x12\x82\x01\n" + + "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xab\x06\n" + + "\vAuthService\x12\x8d\x01\n" + + "\x11ListAuthResources\x12..api.v1.services.auth.ListAuthResourcesRequest\x1a/.api.v1.services.auth.ListAuthResourcesResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/auth/resources\x12}\n" + + "\vCreateToken\x12(.api.v1.services.auth.CreateTokenRequest\x1a).api.v1.services.auth.CreateTokenResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x04data\"\v/auth/token\x12\x80\x01\n" + + "\rValidateToken\x12*.api.v1.services.auth.ValidateTokenRequest\x1a+.api.v1.services.auth.ValidateTokenResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/auth/validate\x12\x82\x01\n" + "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x04data\"\r/auth/destroy\x12\x87\x01\n" + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\" \x82\xd3\xe4\x93\x02\x1a:\x04data\"\x12/auth/authenticate\x12{\n" + "\n" + diff --git a/api/v1/services/auth/auth.pb.gw.go b/api/v1/services/auth/auth.pb.gw.go index cbb5f3ff..40545037 100644 --- a/api/v1/services/auth/auth.pb.gw.go +++ b/api/v1/services/auth/auth.pb.gw.go @@ -209,7 +209,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/sys/auth/resources")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/auth/resources")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -249,7 +249,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/sys/auth/validate")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/auth/validate")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -367,7 +367,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/sys/auth/resources")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/auth/resources")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -401,7 +401,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/sys/auth/validate")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/auth/validate")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -469,9 +469,9 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux } var ( - pattern_AuthService_ListAuthResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "auth", "resources"}, "")) + pattern_AuthService_ListAuthResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "resources"}, "")) pattern_AuthService_CreateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "token"}, "")) - pattern_AuthService_ValidateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"sys", "auth", "validate"}, "")) + pattern_AuthService_ValidateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "validate"}, "")) pattern_AuthService_DestroyToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "destroy"}, "")) pattern_AuthService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "authenticate"}, "")) pattern_AuthService_AuthLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "logout"}, "")) diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index 026606f1..e2e5322b 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -35,7 +35,7 @@ const AuthServiceDestroyTokenBridgeOperation = "/api.v1.services.auth.AuthServic const AuthServiceListAuthResourcesBridgeOperation = "/api.v1.services.auth.AuthService/ListAuthResources" const AuthServiceValidateTokenBridgeOperation = "/api.v1.services.auth.AuthService/ValidateToken" -type AuthServiceBridger interface { +type AuthServiceBridgeServer interface { // AuthLogout logs out a user. AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) // Authenticate authenticates a user. @@ -61,7 +61,7 @@ type AuthServiceHooker interface { type AuthServiceHookedBridger interface { AuthServiceHooker - AuthServiceBridger + AuthServiceBridgeServer } type AuthServiceAuthLogoutHooker interface { PrepareAuthLogout(http.Context, *AuthLogoutRequest) (context.Context, error) @@ -88,11 +88,11 @@ type AuthServiceValidateTokenHooker interface { CompleteValidateToken(http.Context, *ValidateTokenRequest, *ValidateTokenResponse) error } -func RegisterAuthServiceBridger(s *http.Server, srv AuthServiceHookedBridger) { +func RegisterAuthServiceBridgeServer(s *http.Server, srv AuthServiceHookedBridger) { r := s.Route("/") - r.GET("/sys/auth/resources", _AuthService_ListAuthResources0_Bridge_Handler(srv)) + r.GET("/auth/resources", _AuthService_ListAuthResources0_Bridge_Handler(srv)) r.POST("/auth/token", _AuthService_CreateToken0_Bridge_Handler(srv)) - r.GET("/sys/auth/validate", _AuthService_ValidateToken0_Bridge_Handler(srv)) + r.GET("/auth/validate", _AuthService_ValidateToken0_Bridge_Handler(srv)) r.POST("/auth/destroy", _AuthService_DestroyToken0_Bridge_Handler(srv)) r.POST("/auth/authenticate", _AuthService_Authenticate0_Bridge_Handler(srv)) r.POST("/auth/logout", _AuthService_AuthLogout0_Bridge_Handler(srv)) @@ -303,9 +303,9 @@ func (UnimplementedAuthServiceHooked) CompleteValidateToken(ctx http.Context, in return ctx.Result(200, out) } -func WithAuthServiceHook(h AuthServiceHooker) func(AuthServiceBridger) AuthServiceHookedBridger { - return func(b AuthServiceBridger) AuthServiceHookedBridger { - return AuthServiceHookedBridge{AuthServiceBridger: b, AuthServiceHooker: h} +func WithAuthServiceHook(h AuthServiceHooker) func(AuthServiceBridgeServer) AuthServiceHookedBridger { + return func(srv AuthServiceBridgeServer) AuthServiceHookedBridger { + return AuthServiceHookedBridge{AuthServiceBridgeServer: srv, AuthServiceHooker: h} } } @@ -313,7 +313,7 @@ func WithAuthServiceHook(h AuthServiceHooker) func(AuthServiceBridger) AuthServi // It implements the HTTP and gRPC implementations of AuthService. // It forwards requests and responses between the two implementations. type AuthServiceHookedBridge struct { - AuthServiceBridger + AuthServiceBridgeServer AuthServiceHooker } diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go index 61e24494..0f0b3994 100644 --- a/api/v1/services/auth/auth_http.pb.go +++ b/api/v1/services/auth/auth_http.pb.go @@ -43,9 +43,9 @@ type AuthServiceHTTPServer interface { func RegisterAuthServiceHTTPServer(s *http.Server, srv AuthServiceHTTPServer) { r := s.Route("/") - r.GET("/sys/auth/resources", _AuthService_ListAuthResources0_HTTP_Handler(srv)) + r.GET("/auth/resources", _AuthService_ListAuthResources0_HTTP_Handler(srv)) r.POST("/auth/token", _AuthService_CreateToken0_HTTP_Handler(srv)) - r.GET("/sys/auth/validate", _AuthService_ValidateToken0_HTTP_Handler(srv)) + r.GET("/auth/validate", _AuthService_ValidateToken0_HTTP_Handler(srv)) r.POST("/auth/destroy", _AuthService_DestroyToken0_HTTP_Handler(srv)) r.POST("/auth/authenticate", _AuthService_Authenticate0_HTTP_Handler(srv)) r.POST("/auth/logout", _AuthService_AuthLogout0_HTTP_Handler(srv)) @@ -248,7 +248,7 @@ func (c *AuthServiceHTTPClientImpl) DestroyToken(ctx context.Context, in *Destro func (c *AuthServiceHTTPClientImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...http.CallOption) (*ListAuthResourcesResponse, error) { var out ListAuthResourcesResponse - pattern := "/sys/auth/resources" + pattern := "/auth/resources" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationAuthServiceListAuthResources)) opts = append(opts, http.PathTemplate(pattern)) @@ -261,7 +261,7 @@ func (c *AuthServiceHTTPClientImpl) ListAuthResources(ctx context.Context, in *L func (c *AuthServiceHTTPClientImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...http.CallOption) (*ValidateTokenResponse, error) { var out ValidateTokenResponse - pattern := "/sys/auth/validate" + pattern := "/auth/validate" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationAuthServiceValidateToken)) opts = append(opts, http.PathTemplate(pattern)) diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index c8762bdf..9e7e573b 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -32,7 +32,7 @@ const CasbinSourceServiceListGroupingsBridgeOperation = "/api.v1.services.auth.C const CasbinSourceServiceListPoliciesBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListPolicies" const CasbinSourceServiceWatchUpdateBridgeOperation = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" -type CasbinSourceServiceBridger interface { +type CasbinSourceServiceBridgeServer interface { ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) @@ -46,7 +46,7 @@ type CasbinSourceServiceHooker interface { type CasbinSourceServiceHookedBridger interface { CasbinSourceServiceHooker - CasbinSourceServiceBridger + CasbinSourceServiceBridgeServer } type CasbinSourceServiceListGroupingsHooker interface { PrepareListGroupings(http.Context, *ListGroupingsRequest) (context.Context, error) @@ -61,7 +61,7 @@ type CasbinSourceServiceWatchUpdateHooker interface { CompleteWatchUpdate(http.Context, *WatchUpdateRequest, *WatchUpdateResponse) error } -func RegisterCasbinSourceServiceBridger(s *http.Server, srv CasbinSourceServiceHookedBridger) { +func RegisterCasbinSourceServiceBridgeServer(s *http.Server, srv CasbinSourceServiceHookedBridger) { r := s.Route("/") r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_Bridge_Handler(srv)) r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_Bridge_Handler(srv)) @@ -168,9 +168,9 @@ func (UnimplementedCasbinSourceServiceHooked) CompleteWatchUpdate(ctx http.Conte return ctx.Result(200, out) } -func WithCasbinSourceServiceHook(h CasbinSourceServiceHooker) func(CasbinSourceServiceBridger) CasbinSourceServiceHookedBridger { - return func(b CasbinSourceServiceBridger) CasbinSourceServiceHookedBridger { - return CasbinSourceServiceHookedBridge{CasbinSourceServiceBridger: b, CasbinSourceServiceHooker: h} +func WithCasbinSourceServiceHook(h CasbinSourceServiceHooker) func(CasbinSourceServiceBridgeServer) CasbinSourceServiceHookedBridger { + return func(srv CasbinSourceServiceBridgeServer) CasbinSourceServiceHookedBridger { + return CasbinSourceServiceHookedBridge{CasbinSourceServiceBridgeServer: srv, CasbinSourceServiceHooker: h} } } @@ -178,7 +178,7 @@ func WithCasbinSourceServiceHook(h CasbinSourceServiceHooker) func(CasbinSourceS // It implements the HTTP and gRPC implementations of CasbinSourceService. // It forwards requests and responses between the two implementations. type CasbinSourceServiceHookedBridge struct { - CasbinSourceServiceBridger + CasbinSourceServiceBridgeServer CasbinSourceServiceHooker } diff --git a/api/v1/services/auth/login_bridge.pb.go b/api/v1/services/auth/login_bridge.pb.go index 7d0b5265..de674202 100644 --- a/api/v1/services/auth/login_bridge.pb.go +++ b/api/v1/services/auth/login_bridge.pb.go @@ -37,7 +37,7 @@ const LoginServiceLogoutBridgeOperation = "/api.v1.services.auth.LoginService/Lo const LoginServiceRegisterBridgeOperation = "/api.v1.services.auth.LoginService/Register" const LoginServiceTokenRefreshBridgeOperation = "/api.v1.services.auth.LoginService/TokenRefresh" -type LoginServiceBridger interface { +type LoginServiceBridgeServer interface { Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) @@ -61,7 +61,7 @@ type LoginServiceHooker interface { type LoginServiceHookedBridger interface { LoginServiceHooker - LoginServiceBridger + LoginServiceBridgeServer } type LoginServiceCaptchaHooker interface { PrepareCaptcha(http.Context, *CaptchaRequest) (context.Context, error) @@ -96,7 +96,7 @@ type LoginServiceTokenRefreshHooker interface { CompleteTokenRefresh(http.Context, *TokenRefreshRequest, *TokenRefreshResponse) error } -func RegisterLoginServiceBridger(s *http.Server, srv LoginServiceHookedBridger) { +func RegisterLoginServiceBridgeServer(s *http.Server, srv LoginServiceHookedBridger) { r := s.Route("/") r.GET("/captcha", _LoginService_Captcha0_Bridge_Handler(srv)) r.GET("/captcha/id", _LoginService_CaptchaId0_Bridge_Handler(srv)) @@ -375,9 +375,9 @@ func (UnimplementedLoginServiceHooked) CompleteTokenRefresh(ctx http.Context, in return ctx.Result(200, out) } -func WithLoginServiceHook(h LoginServiceHooker) func(LoginServiceBridger) LoginServiceHookedBridger { - return func(b LoginServiceBridger) LoginServiceHookedBridger { - return LoginServiceHookedBridge{LoginServiceBridger: b, LoginServiceHooker: h} +func WithLoginServiceHook(h LoginServiceHooker) func(LoginServiceBridgeServer) LoginServiceHookedBridger { + return func(srv LoginServiceBridgeServer) LoginServiceHookedBridger { + return LoginServiceHookedBridge{LoginServiceBridgeServer: srv, LoginServiceHooker: h} } } @@ -385,7 +385,7 @@ func WithLoginServiceHook(h LoginServiceHooker) func(LoginServiceBridger) LoginS // It implements the HTTP and gRPC implementations of LoginService. // It forwards requests and responses between the two implementations. type LoginServiceHookedBridge struct { - LoginServiceBridger + LoginServiceBridgeServer LoginServiceHooker } diff --git a/api/v1/services/auth/personal.pb.go b/api/v1/services/auth/personal.pb.go new file mode 100644 index 00000000..ffe4e38f --- /dev/null +++ b/api/v1/services/auth/personal.pb.go @@ -0,0 +1,1074 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc (unknown) +// source: auth/personal.proto + +package auth + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UpdatePersonalSettingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalSettingRequest) Reset() { + *x = UpdatePersonalSettingRequest{} + mi := &file_auth_personal_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalSettingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalSettingRequest) ProtoMessage() {} + +func (x *UpdatePersonalSettingRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[0] + 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 UpdatePersonalSettingRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalSettingRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{0} +} + +func (x *UpdatePersonalSettingRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalSettingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalSettingResponse) Reset() { + *x = UpdatePersonalSettingResponse{} + mi := &file_auth_personal_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalSettingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalSettingResponse) ProtoMessage() {} + +func (x *UpdatePersonalSettingResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[1] + 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 UpdatePersonalSettingResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalSettingResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{1} +} + +type UpdatePersonalRoleRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalRoleRequest) Reset() { + *x = UpdatePersonalRoleRequest{} + mi := &file_auth_personal_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalRoleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalRoleRequest) ProtoMessage() {} + +func (x *UpdatePersonalRoleRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[2] + 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 UpdatePersonalRoleRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalRoleRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{2} +} + +func (x *UpdatePersonalRoleRequest) GetRole() *types.Role { + if x != nil { + return x.Role + } + return nil +} + +type UpdatePersonalRoleResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalRoleResponse) Reset() { + *x = UpdatePersonalRoleResponse{} + mi := &file_auth_personal_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalRoleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalRoleResponse) ProtoMessage() {} + +func (x *UpdatePersonalRoleResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[3] + 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 UpdatePersonalRoleResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalRoleResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{3} +} + +type ListPersonalResourcesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalResourcesRequest) Reset() { + *x = ListPersonalResourcesRequest{} + mi := &file_auth_personal_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalResourcesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalResourcesRequest) ProtoMessage() {} + +func (x *ListPersonalResourcesRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[4] + 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 ListPersonalResourcesRequest.ProtoReflect.Descriptor instead. +func (*ListPersonalResourcesRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{4} +} + +func (x *ListPersonalResourcesRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListPersonalResourcesRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListPersonalResourcesRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +type ListPersonalResourcesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + TotalSize int64 `protobuf:"varint,1,opt,name=total_size,json=total,proto3" json:"total_size,omitempty"` + // list of resources + Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalResourcesResponse) Reset() { + *x = ListPersonalResourcesResponse{} + mi := &file_auth_personal_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalResourcesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalResourcesResponse) ProtoMessage() {} + +func (x *ListPersonalResourcesResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[5] + 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 ListPersonalResourcesResponse.ProtoReflect.Descriptor instead. +func (*ListPersonalResourcesResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{5} +} + +func (x *ListPersonalResourcesResponse) GetTotalSize() int64 { + if x != nil { + return x.TotalSize + } + return 0 +} + +func (x *ListPersonalResourcesResponse) GetResources() []*types.Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *ListPersonalResourcesResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +type UpdatePersonalPasswordRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalPasswordRequest) Reset() { + *x = UpdatePersonalPasswordRequest{} + mi := &file_auth_personal_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalPasswordRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalPasswordRequest) ProtoMessage() {} + +func (x *UpdatePersonalPasswordRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_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 UpdatePersonalPasswordRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalPasswordRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdatePersonalPasswordRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalPasswordResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalPasswordResponse) Reset() { + *x = UpdatePersonalPasswordResponse{} + mi := &file_auth_personal_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalPasswordResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalPasswordResponse) ProtoMessage() {} + +func (x *UpdatePersonalPasswordResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdatePersonalPasswordResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalPasswordResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{7} +} + +type PersonalPasswordRestRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalPasswordRestRequest) Reset() { + *x = PersonalPasswordRestRequest{} + mi := &file_auth_personal_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalPasswordRestRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalPasswordRestRequest) ProtoMessage() {} + +func (x *PersonalPasswordRestRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[8] + 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 PersonalPasswordRestRequest.ProtoReflect.Descriptor instead. +func (*PersonalPasswordRestRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{8} +} + +func (x *PersonalPasswordRestRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type PersonalPasswordRestResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalPasswordRestResponse) Reset() { + *x = PersonalPasswordRestResponse{} + mi := &file_auth_personal_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalPasswordRestResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalPasswordRestResponse) ProtoMessage() {} + +func (x *PersonalPasswordRestResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[9] + 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 PersonalPasswordRestResponse.ProtoReflect.Descriptor instead. +func (*PersonalPasswordRestResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{9} +} + +type UpdatePersonalProfileRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalProfileRequest) Reset() { + *x = UpdatePersonalProfileRequest{} + mi := &file_auth_personal_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalProfileRequest) ProtoMessage() {} + +func (x *UpdatePersonalProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[10] + 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 UpdatePersonalProfileRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalProfileRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{10} +} + +func (x *UpdatePersonalProfileRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalProfileResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalProfileResponse) Reset() { + *x = UpdatePersonalProfileResponse{} + mi := &file_auth_personal_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalProfileResponse) ProtoMessage() {} + +func (x *UpdatePersonalProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[11] + 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 UpdatePersonalProfileResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalProfileResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{11} +} + +type PersonalLogoutRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalLogoutRequest) Reset() { + *x = PersonalLogoutRequest{} + mi := &file_auth_personal_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalLogoutRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalLogoutRequest) ProtoMessage() {} + +func (x *PersonalLogoutRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[12] + 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 PersonalLogoutRequest.ProtoReflect.Descriptor instead. +func (*PersonalLogoutRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{12} +} + +func (x *PersonalLogoutRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type PersonalLogoutResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalLogoutResponse) Reset() { + *x = PersonalLogoutResponse{} + mi := &file_auth_personal_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalLogoutResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalLogoutResponse) ProtoMessage() {} + +func (x *PersonalLogoutResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[13] + 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 PersonalLogoutResponse.ProtoReflect.Descriptor instead. +func (*PersonalLogoutResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{13} +} + +func (x *PersonalLogoutResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +type ListPersonalRolesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalRolesRequest) Reset() { + *x = ListPersonalRolesRequest{} + mi := &file_auth_personal_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalRolesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalRolesRequest) ProtoMessage() {} + +func (x *ListPersonalRolesRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[14] + 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 ListPersonalRolesRequest.ProtoReflect.Descriptor instead. +func (*ListPersonalRolesRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{14} +} + +type ListPersonalRolesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Roles []*types.Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalRolesResponse) Reset() { + *x = ListPersonalRolesResponse{} + mi := &file_auth_personal_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalRolesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalRolesResponse) ProtoMessage() {} + +func (x *ListPersonalRolesResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[15] + 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 ListPersonalRolesResponse.ProtoReflect.Descriptor instead. +func (*ListPersonalRolesResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{15} +} + +func (x *ListPersonalRolesResponse) GetRoles() []*types.Role { + if x != nil { + return x.Roles + } + return nil +} + +type GetPersonalProfileRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPersonalProfileRequest) Reset() { + *x = GetPersonalProfileRequest{} + mi := &file_auth_personal_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPersonalProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPersonalProfileRequest) ProtoMessage() {} + +func (x *GetPersonalProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[16] + 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 GetPersonalProfileRequest.ProtoReflect.Descriptor instead. +func (*GetPersonalProfileRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{16} +} + +type GetPersonalProfileResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPersonalProfileResponse) Reset() { + *x = GetPersonalProfileResponse{} + mi := &file_auth_personal_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPersonalProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPersonalProfileResponse) ProtoMessage() {} + +func (x *GetPersonalProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[17] + 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 GetPersonalProfileResponse.ProtoReflect.Descriptor instead. +func (*GetPersonalProfileResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{17} +} + +func (x *GetPersonalProfileResponse) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +type RefreshPersonalTokenRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshPersonalTokenRequest) Reset() { + *x = RefreshPersonalTokenRequest{} + mi := &file_auth_personal_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshPersonalTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshPersonalTokenRequest) ProtoMessage() {} + +func (x *RefreshPersonalTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshPersonalTokenRequest.ProtoReflect.Descriptor instead. +func (*RefreshPersonalTokenRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{18} +} + +func (x *RefreshPersonalTokenRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type RefreshPersonalTokenResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshPersonalTokenResponse) Reset() { + *x = RefreshPersonalTokenResponse{} + mi := &file_auth_personal_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshPersonalTokenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshPersonalTokenResponse) ProtoMessage() {} + +func (x *RefreshPersonalTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshPersonalTokenResponse.ProtoReflect.Descriptor instead. +func (*RefreshPersonalTokenResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{19} +} + +func (x *RefreshPersonalTokenResponse) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +var File_auth_personal_proto protoreflect.FileDescriptor + +const file_auth_personal_proto_rawDesc = "" + + "\n" + + "\x13auth/personal.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12types/system.proto\x1a\x17validate/validate.proto\"H\n" + + "\x1cUpdatePersonalSettingRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + + "\x1dUpdatePersonalSettingResponse\"L\n" + + "\x19UpdatePersonalRoleRequest\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\x1c\n" + + "\x1aUpdatePersonalRoleResponse\"\xc4\x01\n" + + "\x1cListPersonalResourcesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\"\xa3\x01\n" + + "\x1dListPersonalResourcesResponse\x12\x19\n" + + "\n" + + "total_size\x18\x01 \x01(\x03R\x05total\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\"I\n" + + "\x1dUpdatePersonalPasswordRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\" \n" + + "\x1eUpdatePersonalPasswordResponse\"6\n" + + "\x1bPersonalPasswordRestRequest\x12\x17\n" + + "\x02id\x18\x01 \x01(\x03B\a\xfaB\x04\"\x02 \x00R\x02id\"\x1e\n" + + "\x1cPersonalPasswordRestResponse\"H\n" + + "\x1cUpdatePersonalProfileRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + + "\x1dUpdatePersonalProfileResponse\"A\n" + + "\x15PersonalLogoutRequest\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"2\n" + + "\x16PersonalLogoutResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\"\x1a\n" + + "\x18ListPersonalRolesRequest\"N\n" + + "\x19ListPersonalRolesResponse\x121\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x1b\n" + + "\x19GetPersonalProfileRequest\"M\n" + + "\x1aGetPersonalProfileResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + + "\x1bRefreshPersonalTokenRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"4\n" + + "\x1cRefreshPersonalTokenResponse\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token2\xa3\n" + + "\n" + + "\x0fPersonalService\x12\x97\x01\n" + + "\x12GetPersonalProfile\x12/.api.v1.services.auth.GetPersonalProfileRequest\x1a0.api.v1.services.auth.GetPersonalProfileResponse\"\x1e\x82\xd3\xe4\x93\x02\x18\x12\x16/auth/personal/profile\x12\xa2\x01\n" + + "\x15ListPersonalResources\x122.api.v1.services.auth.ListPersonalResourcesRequest\x1a3.api.v1.services.auth.ListPersonalResourcesResponse\" \x82\xd3\xe4\x93\x02\x1a\x12\x18/auth/personal/resources\x12\x92\x01\n" + + "\x11ListPersonalRoles\x12..api.v1.services.auth.ListPersonalRolesRequest\x1a/.api.v1.services.auth.ListPersonalRolesResponse\"\x1c\x82\xd3\xe4\x93\x02\x16\x12\x14/auth/personal/roles\x12\x90\x01\n" + + "\x0ePersonalLogout\x12+.api.v1.services.auth.PersonalLogoutRequest\x1a,.api.v1.services.auth.PersonalLogoutResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\"\x15/auth/personal/logout\x12\xa9\x01\n" + + "\x14RefreshPersonalToken\x121.api.v1.services.auth.RefreshPersonalTokenRequest\x1a2.api.v1.services.auth.RefreshPersonalTokenResponse\"*\x82\xd3\xe4\x93\x02$:\x04data\"\x1c/auth/personal/token/refresh\x12\xaa\x01\n" + + "\x16UpdatePersonalPassword\x123.api.v1.services.auth.UpdatePersonalPasswordRequest\x1a4.api.v1.services.auth.UpdatePersonalPasswordResponse\"%\x82\xd3\xe4\x93\x02\x1f:\x04data\x1a\x17/auth/personal/password\x12\xa6\x01\n" + + "\x15UpdatePersonalProfile\x122.api.v1.services.auth.UpdatePersonalProfileRequest\x1a3.api.v1.services.auth.UpdatePersonalProfileResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/profile\x12\xa6\x01\n" + + "\x15UpdatePersonalSetting\x122.api.v1.services.auth.UpdatePersonalSettingRequest\x1a3.api.v1.services.auth.UpdatePersonalSettingResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/settingB\xb8\x01\n" + + "\x18com.api.v1.services.authB\rPersonalProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + +var ( + file_auth_personal_proto_rawDescOnce sync.Once + file_auth_personal_proto_rawDescData []byte +) + +func file_auth_personal_proto_rawDescGZIP() []byte { + file_auth_personal_proto_rawDescOnce.Do(func() { + file_auth_personal_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_personal_proto_rawDesc), len(file_auth_personal_proto_rawDesc))) + }) + return file_auth_personal_proto_rawDescData +} + +var file_auth_personal_proto_msgTypes = make([]protoimpl.MessageInfo, 20) +var file_auth_personal_proto_goTypes = []any{ + (*UpdatePersonalSettingRequest)(nil), // 0: api.v1.services.auth.UpdatePersonalSettingRequest + (*UpdatePersonalSettingResponse)(nil), // 1: api.v1.services.auth.UpdatePersonalSettingResponse + (*UpdatePersonalRoleRequest)(nil), // 2: api.v1.services.auth.UpdatePersonalRoleRequest + (*UpdatePersonalRoleResponse)(nil), // 3: api.v1.services.auth.UpdatePersonalRoleResponse + (*ListPersonalResourcesRequest)(nil), // 4: api.v1.services.auth.ListPersonalResourcesRequest + (*ListPersonalResourcesResponse)(nil), // 5: api.v1.services.auth.ListPersonalResourcesResponse + (*UpdatePersonalPasswordRequest)(nil), // 6: api.v1.services.auth.UpdatePersonalPasswordRequest + (*UpdatePersonalPasswordResponse)(nil), // 7: api.v1.services.auth.UpdatePersonalPasswordResponse + (*PersonalPasswordRestRequest)(nil), // 8: api.v1.services.auth.PersonalPasswordRestRequest + (*PersonalPasswordRestResponse)(nil), // 9: api.v1.services.auth.PersonalPasswordRestResponse + (*UpdatePersonalProfileRequest)(nil), // 10: api.v1.services.auth.UpdatePersonalProfileRequest + (*UpdatePersonalProfileResponse)(nil), // 11: api.v1.services.auth.UpdatePersonalProfileResponse + (*PersonalLogoutRequest)(nil), // 12: api.v1.services.auth.PersonalLogoutRequest + (*PersonalLogoutResponse)(nil), // 13: api.v1.services.auth.PersonalLogoutResponse + (*ListPersonalRolesRequest)(nil), // 14: api.v1.services.auth.ListPersonalRolesRequest + (*ListPersonalRolesResponse)(nil), // 15: api.v1.services.auth.ListPersonalRolesResponse + (*GetPersonalProfileRequest)(nil), // 16: api.v1.services.auth.GetPersonalProfileRequest + (*GetPersonalProfileResponse)(nil), // 17: api.v1.services.auth.GetPersonalProfileResponse + (*RefreshPersonalTokenRequest)(nil), // 18: api.v1.services.auth.RefreshPersonalTokenRequest + (*RefreshPersonalTokenResponse)(nil), // 19: api.v1.services.auth.RefreshPersonalTokenResponse + (*anypb.Any)(nil), // 20: google.protobuf.Any + (*types.Role)(nil), // 21: api.v1.services.types.Role + (*types.Resource)(nil), // 22: api.v1.services.types.Resource + (*types.User)(nil), // 23: api.v1.services.types.User +} +var file_auth_personal_proto_depIdxs = []int32{ + 20, // 0: api.v1.services.auth.UpdatePersonalSettingRequest.data:type_name -> google.protobuf.Any + 21, // 1: api.v1.services.auth.UpdatePersonalRoleRequest.role:type_name -> api.v1.services.types.Role + 22, // 2: api.v1.services.auth.ListPersonalResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 20, // 3: api.v1.services.auth.UpdatePersonalPasswordRequest.data:type_name -> google.protobuf.Any + 20, // 4: api.v1.services.auth.UpdatePersonalProfileRequest.data:type_name -> google.protobuf.Any + 20, // 5: api.v1.services.auth.PersonalLogoutRequest.data:type_name -> google.protobuf.Any + 21, // 6: api.v1.services.auth.ListPersonalRolesResponse.roles:type_name -> api.v1.services.types.Role + 23, // 7: api.v1.services.auth.GetPersonalProfileResponse.user:type_name -> api.v1.services.types.User + 20, // 8: api.v1.services.auth.RefreshPersonalTokenRequest.data:type_name -> google.protobuf.Any + 16, // 9: api.v1.services.auth.PersonalService.GetPersonalProfile:input_type -> api.v1.services.auth.GetPersonalProfileRequest + 4, // 10: api.v1.services.auth.PersonalService.ListPersonalResources:input_type -> api.v1.services.auth.ListPersonalResourcesRequest + 14, // 11: api.v1.services.auth.PersonalService.ListPersonalRoles:input_type -> api.v1.services.auth.ListPersonalRolesRequest + 12, // 12: api.v1.services.auth.PersonalService.PersonalLogout:input_type -> api.v1.services.auth.PersonalLogoutRequest + 18, // 13: api.v1.services.auth.PersonalService.RefreshPersonalToken:input_type -> api.v1.services.auth.RefreshPersonalTokenRequest + 6, // 14: api.v1.services.auth.PersonalService.UpdatePersonalPassword:input_type -> api.v1.services.auth.UpdatePersonalPasswordRequest + 10, // 15: api.v1.services.auth.PersonalService.UpdatePersonalProfile:input_type -> api.v1.services.auth.UpdatePersonalProfileRequest + 0, // 16: api.v1.services.auth.PersonalService.UpdatePersonalSetting:input_type -> api.v1.services.auth.UpdatePersonalSettingRequest + 17, // 17: api.v1.services.auth.PersonalService.GetPersonalProfile:output_type -> api.v1.services.auth.GetPersonalProfileResponse + 5, // 18: api.v1.services.auth.PersonalService.ListPersonalResources:output_type -> api.v1.services.auth.ListPersonalResourcesResponse + 15, // 19: api.v1.services.auth.PersonalService.ListPersonalRoles:output_type -> api.v1.services.auth.ListPersonalRolesResponse + 13, // 20: api.v1.services.auth.PersonalService.PersonalLogout:output_type -> api.v1.services.auth.PersonalLogoutResponse + 19, // 21: api.v1.services.auth.PersonalService.RefreshPersonalToken:output_type -> api.v1.services.auth.RefreshPersonalTokenResponse + 7, // 22: api.v1.services.auth.PersonalService.UpdatePersonalPassword:output_type -> api.v1.services.auth.UpdatePersonalPasswordResponse + 11, // 23: api.v1.services.auth.PersonalService.UpdatePersonalProfile:output_type -> api.v1.services.auth.UpdatePersonalProfileResponse + 1, // 24: api.v1.services.auth.PersonalService.UpdatePersonalSetting:output_type -> api.v1.services.auth.UpdatePersonalSettingResponse + 17, // [17:25] is the sub-list for method output_type + 9, // [9:17] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_auth_personal_proto_init() } +func file_auth_personal_proto_init() { + if File_auth_personal_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_personal_proto_rawDesc), len(file_auth_personal_proto_rawDesc)), + NumEnums: 0, + NumMessages: 20, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_auth_personal_proto_goTypes, + DependencyIndexes: file_auth_personal_proto_depIdxs, + MessageInfos: file_auth_personal_proto_msgTypes, + }.Build() + File_auth_personal_proto = out.File + file_auth_personal_proto_goTypes = nil + file_auth_personal_proto_depIdxs = nil +} diff --git a/api/v1/services/auth/personal.pb.gw.go b/api/v1/services/auth/personal.pb.gw.go new file mode 100644 index 00000000..fb8ce2cc --- /dev/null +++ b/api/v1/services/auth/personal.pb.gw.go @@ -0,0 +1,594 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: auth/personal.proto + +/* +Package auth is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package auth + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +func request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPersonalProfileRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.GetPersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPersonalProfileRequest + metadata runtime.ServerMetadata + ) + msg, err := server.GetPersonalProfile(ctx, &protoReq) + return msg, metadata, err +} + +var filter_PersonalService_ListPersonalResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalResourcesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListPersonalResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalResourcesRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListPersonalResources(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalRolesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.ListPersonalRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalRolesRequest + metadata runtime.ServerMetadata + ) + msg, err := server.ListPersonalRoles(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq PersonalLogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.PersonalLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq PersonalLogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.PersonalLogout(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RefreshPersonalTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.RefreshPersonalToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RefreshPersonalTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.RefreshPersonalToken(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalPasswordRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalPasswordRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalPassword(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalProfileRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalProfileRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalProfile(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalSettingRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalSetting(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalSettingRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalSetting(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterPersonalServiceHandlerServer registers the http handlers for service PersonalService to "mux". +// UnaryRPC :call PersonalServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPersonalServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterPersonalServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PersonalServiceServer) error { + mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/auth/personal/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/auth/personal/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/auth/personal/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/auth/personal/token/refresh")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/auth/personal/password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/auth/personal/setting")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterPersonalServiceHandlerFromEndpoint is same as RegisterPersonalServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterPersonalServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterPersonalServiceHandler(ctx, mux, conn) +} + +// RegisterPersonalServiceHandler registers the http handlers for service PersonalService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterPersonalServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterPersonalServiceHandlerClient(ctx, mux, NewPersonalServiceClient(conn)) +} + +// RegisterPersonalServiceHandlerClient registers the http handlers for service PersonalService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PersonalServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PersonalServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "PersonalServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterPersonalServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PersonalServiceClient) error { + mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/auth/personal/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/auth/personal/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/auth/personal/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/auth/personal/token/refresh")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/auth/personal/password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/auth/personal/setting")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_PersonalService_GetPersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "profile"}, "")) + pattern_PersonalService_ListPersonalResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "resources"}, "")) + pattern_PersonalService_ListPersonalRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "roles"}, "")) + pattern_PersonalService_PersonalLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "logout"}, "")) + pattern_PersonalService_RefreshPersonalToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"auth", "personal", "token", "refresh"}, "")) + pattern_PersonalService_UpdatePersonalPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "password"}, "")) + pattern_PersonalService_UpdatePersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "profile"}, "")) + pattern_PersonalService_UpdatePersonalSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "setting"}, "")) +) + +var ( + forward_PersonalService_GetPersonalProfile_0 = runtime.ForwardResponseMessage + forward_PersonalService_ListPersonalResources_0 = runtime.ForwardResponseMessage + forward_PersonalService_ListPersonalRoles_0 = runtime.ForwardResponseMessage + forward_PersonalService_PersonalLogout_0 = runtime.ForwardResponseMessage + forward_PersonalService_RefreshPersonalToken_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalPassword_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalProfile_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalSetting_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/auth/personal.pb.validate.go b/api/v1/services/auth/personal.pb.validate.go new file mode 100644 index 00000000..92933952 --- /dev/null +++ b/api/v1/services/auth/personal.pb.validate.go @@ -0,0 +1,2390 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: auth/personal.proto + +package auth + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on UpdatePersonalSettingRequest 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 *UpdatePersonalSettingRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalSettingRequest 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 +// UpdatePersonalSettingRequestMultiError, or nil if none found. +func (m *UpdatePersonalSettingRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalSettingRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalSettingRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalSettingRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalSettingRequest.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalSettingRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalSettingRequestMultiError) 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 UpdatePersonalSettingRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalSettingRequestValidationError is the validation error returned +// by UpdatePersonalSettingRequest.Validate if the designated constraints +// aren't met. +type UpdatePersonalSettingRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalSettingRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalSettingRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalSettingRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalSettingRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalSettingRequestValidationError) ErrorName() string { + return "UpdatePersonalSettingRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalSettingRequestValidationError) 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 %sUpdatePersonalSettingRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalSettingRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalSettingRequestValidationError{} + +// Validate checks the field values on UpdatePersonalSettingResponse 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 *UpdatePersonalSettingResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalSettingResponse 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 +// UpdatePersonalSettingResponseMultiError, or nil if none found. +func (m *UpdatePersonalSettingResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalSettingResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalSettingResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalSettingResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalSettingResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalSettingResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalSettingResponseMultiError) 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 UpdatePersonalSettingResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalSettingResponseValidationError is the validation error +// returned by UpdatePersonalSettingResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalSettingResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalSettingResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalSettingResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalSettingResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalSettingResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalSettingResponseValidationError) ErrorName() string { + return "UpdatePersonalSettingResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalSettingResponseValidationError) 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 %sUpdatePersonalSettingResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalSettingResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalSettingResponseValidationError{} + +// Validate checks the field values on UpdatePersonalRoleRequest 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 *UpdatePersonalRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalRoleRequest 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 +// UpdatePersonalRoleRequestMultiError, or nil if none found. +func (m *UpdatePersonalRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalRoleRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalRoleRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalRoleRequestMultiError is an error wrapping multiple validation +// errors returned by UpdatePersonalRoleRequest.ValidateAll() if the +// designated constraints aren't met. +type UpdatePersonalRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalRoleRequestMultiError) 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 UpdatePersonalRoleRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalRoleRequestValidationError is the validation error returned by +// UpdatePersonalRoleRequest.Validate if the designated constraints aren't met. +type UpdatePersonalRoleRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalRoleRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalRoleRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalRoleRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalRoleRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalRoleRequestValidationError) ErrorName() string { + return "UpdatePersonalRoleRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalRoleRequestValidationError) 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 %sUpdatePersonalRoleRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalRoleRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalRoleRequestValidationError{} + +// Validate checks the field values on UpdatePersonalRoleResponse 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 *UpdatePersonalRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalRoleResponse 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 +// UpdatePersonalRoleResponseMultiError, or nil if none found. +func (m *UpdatePersonalRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalRoleResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalRoleResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalRoleResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalRoleResponse.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalRoleResponseMultiError) 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 UpdatePersonalRoleResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalRoleResponseValidationError is the validation error returned +// by UpdatePersonalRoleResponse.Validate if the designated constraints aren't met. +type UpdatePersonalRoleResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalRoleResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalRoleResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalRoleResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalRoleResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalRoleResponseValidationError) ErrorName() string { + return "UpdatePersonalRoleResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalRoleResponseValidationError) 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 %sUpdatePersonalRoleResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalRoleResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalRoleResponseValidationError{} + +// Validate checks the field values on ListPersonalResourcesRequest 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 *ListPersonalResourcesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalResourcesRequest 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 +// ListPersonalResourcesRequestMultiError, or nil if none found. +func (m *ListPersonalResourcesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalResourcesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + if len(errors) > 0 { + return ListPersonalResourcesRequestMultiError(errors) + } + + return nil +} + +// ListPersonalResourcesRequestMultiError is an error wrapping multiple +// validation errors returned by ListPersonalResourcesRequest.ValidateAll() if +// the designated constraints aren't met. +type ListPersonalResourcesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalResourcesRequestMultiError) 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 ListPersonalResourcesRequestMultiError) AllErrors() []error { return m } + +// ListPersonalResourcesRequestValidationError is the validation error returned +// by ListPersonalResourcesRequest.Validate if the designated constraints +// aren't met. +type ListPersonalResourcesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalResourcesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalResourcesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalResourcesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalResourcesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalResourcesRequestValidationError) ErrorName() string { + return "ListPersonalResourcesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalResourcesRequestValidationError) 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 %sListPersonalResourcesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalResourcesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalResourcesRequestValidationError{} + +// Validate checks the field values on ListPersonalResourcesResponse 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 *ListPersonalResourcesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalResourcesResponse 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 +// ListPersonalResourcesResponseMultiError, or nil if none found. +func (m *ListPersonalResourcesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalResourcesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TotalSize + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for NextPageToken + + if len(errors) > 0 { + return ListPersonalResourcesResponseMultiError(errors) + } + + return nil +} + +// ListPersonalResourcesResponseMultiError is an error wrapping multiple +// validation errors returned by ListPersonalResourcesResponse.ValidateAll() +// if the designated constraints aren't met. +type ListPersonalResourcesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalResourcesResponseMultiError) 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 ListPersonalResourcesResponseMultiError) AllErrors() []error { return m } + +// ListPersonalResourcesResponseValidationError is the validation error +// returned by ListPersonalResourcesResponse.Validate if the designated +// constraints aren't met. +type ListPersonalResourcesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalResourcesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalResourcesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalResourcesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalResourcesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalResourcesResponseValidationError) ErrorName() string { + return "ListPersonalResourcesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalResourcesResponseValidationError) 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 %sListPersonalResourcesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalResourcesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalResourcesResponseValidationError{} + +// Validate checks the field values on UpdatePersonalPasswordRequest 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 *UpdatePersonalPasswordRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalPasswordRequest 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 +// UpdatePersonalPasswordRequestMultiError, or nil if none found. +func (m *UpdatePersonalPasswordRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalPasswordRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalPasswordRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalPasswordRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalPasswordRequest.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalPasswordRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalPasswordRequestMultiError) 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 UpdatePersonalPasswordRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalPasswordRequestValidationError is the validation error +// returned by UpdatePersonalPasswordRequest.Validate if the designated +// constraints aren't met. +type UpdatePersonalPasswordRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalPasswordRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalPasswordRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalPasswordRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalPasswordRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalPasswordRequestValidationError) ErrorName() string { + return "UpdatePersonalPasswordRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalPasswordRequestValidationError) 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 %sUpdatePersonalPasswordRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalPasswordRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalPasswordRequestValidationError{} + +// Validate checks the field values on UpdatePersonalPasswordResponse 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 *UpdatePersonalPasswordResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalPasswordResponse 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 +// UpdatePersonalPasswordResponseMultiError, or nil if none found. +func (m *UpdatePersonalPasswordResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalPasswordResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalPasswordResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalPasswordResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalPasswordResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalPasswordResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalPasswordResponseMultiError) 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 UpdatePersonalPasswordResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalPasswordResponseValidationError is the validation error +// returned by UpdatePersonalPasswordResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalPasswordResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalPasswordResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalPasswordResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalPasswordResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalPasswordResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalPasswordResponseValidationError) ErrorName() string { + return "UpdatePersonalPasswordResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalPasswordResponseValidationError) 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 %sUpdatePersonalPasswordResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalPasswordResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalPasswordResponseValidationError{} + +// Validate checks the field values on PersonalPasswordRestRequest 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 *PersonalPasswordRestRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalPasswordRestRequest 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 +// PersonalPasswordRestRequestMultiError, or nil if none found. +func (m *PersonalPasswordRestRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalPasswordRestRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetId() <= 0 { + err := PersonalPasswordRestRequestValidationError{ + field: "Id", + reason: "value must be greater than 0", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return PersonalPasswordRestRequestMultiError(errors) + } + + return nil +} + +// PersonalPasswordRestRequestMultiError is an error wrapping multiple +// validation errors returned by PersonalPasswordRestRequest.ValidateAll() if +// the designated constraints aren't met. +type PersonalPasswordRestRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalPasswordRestRequestMultiError) 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 PersonalPasswordRestRequestMultiError) AllErrors() []error { return m } + +// PersonalPasswordRestRequestValidationError is the validation error returned +// by PersonalPasswordRestRequest.Validate if the designated constraints +// aren't met. +type PersonalPasswordRestRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalPasswordRestRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalPasswordRestRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalPasswordRestRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalPasswordRestRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalPasswordRestRequestValidationError) ErrorName() string { + return "PersonalPasswordRestRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalPasswordRestRequestValidationError) 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 %sPersonalPasswordRestRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalPasswordRestRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalPasswordRestRequestValidationError{} + +// Validate checks the field values on PersonalPasswordRestResponse 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 *PersonalPasswordRestResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalPasswordRestResponse 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 +// PersonalPasswordRestResponseMultiError, or nil if none found. +func (m *PersonalPasswordRestResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalPasswordRestResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return PersonalPasswordRestResponseMultiError(errors) + } + + return nil +} + +// PersonalPasswordRestResponseMultiError is an error wrapping multiple +// validation errors returned by PersonalPasswordRestResponse.ValidateAll() if +// the designated constraints aren't met. +type PersonalPasswordRestResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalPasswordRestResponseMultiError) 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 PersonalPasswordRestResponseMultiError) AllErrors() []error { return m } + +// PersonalPasswordRestResponseValidationError is the validation error returned +// by PersonalPasswordRestResponse.Validate if the designated constraints +// aren't met. +type PersonalPasswordRestResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalPasswordRestResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalPasswordRestResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalPasswordRestResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalPasswordRestResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalPasswordRestResponseValidationError) ErrorName() string { + return "PersonalPasswordRestResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalPasswordRestResponseValidationError) 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 %sPersonalPasswordRestResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalPasswordRestResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalPasswordRestResponseValidationError{} + +// Validate checks the field values on UpdatePersonalProfileRequest 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 *UpdatePersonalProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalProfileRequest 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 +// UpdatePersonalProfileRequestMultiError, or nil if none found. +func (m *UpdatePersonalProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalProfileRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalProfileRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalProfileRequest.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalProfileRequestMultiError) 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 UpdatePersonalProfileRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalProfileRequestValidationError is the validation error returned +// by UpdatePersonalProfileRequest.Validate if the designated constraints +// aren't met. +type UpdatePersonalProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalProfileRequestValidationError) ErrorName() string { + return "UpdatePersonalProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalProfileRequestValidationError) 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 %sUpdatePersonalProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalProfileRequestValidationError{} + +// Validate checks the field values on UpdatePersonalProfileResponse 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 *UpdatePersonalProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalProfileResponse 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 +// UpdatePersonalProfileResponseMultiError, or nil if none found. +func (m *UpdatePersonalProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalProfileResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalProfileResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalProfileResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalProfileResponseMultiError) 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 UpdatePersonalProfileResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalProfileResponseValidationError is the validation error +// returned by UpdatePersonalProfileResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalProfileResponseValidationError) ErrorName() string { + return "UpdatePersonalProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalProfileResponseValidationError) 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 %sUpdatePersonalProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalProfileResponseValidationError{} + +// Validate checks the field values on PersonalLogoutRequest 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 *PersonalLogoutRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalLogoutRequest 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 +// PersonalLogoutRequestMultiError, or nil if none found. +func (m *PersonalLogoutRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalLogoutRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return PersonalLogoutRequestMultiError(errors) + } + + return nil +} + +// PersonalLogoutRequestMultiError is an error wrapping multiple validation +// errors returned by PersonalLogoutRequest.ValidateAll() if the designated +// constraints aren't met. +type PersonalLogoutRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalLogoutRequestMultiError) 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 PersonalLogoutRequestMultiError) AllErrors() []error { return m } + +// PersonalLogoutRequestValidationError is the validation error returned by +// PersonalLogoutRequest.Validate if the designated constraints aren't met. +type PersonalLogoutRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalLogoutRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalLogoutRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalLogoutRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalLogoutRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalLogoutRequestValidationError) ErrorName() string { + return "PersonalLogoutRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalLogoutRequestValidationError) 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 %sPersonalLogoutRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalLogoutRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalLogoutRequestValidationError{} + +// Validate checks the field values on PersonalLogoutResponse 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 *PersonalLogoutResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalLogoutResponse 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 +// PersonalLogoutResponseMultiError, or nil if none found. +func (m *PersonalLogoutResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalLogoutResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Success + + if len(errors) > 0 { + return PersonalLogoutResponseMultiError(errors) + } + + return nil +} + +// PersonalLogoutResponseMultiError is an error wrapping multiple validation +// errors returned by PersonalLogoutResponse.ValidateAll() if the designated +// constraints aren't met. +type PersonalLogoutResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalLogoutResponseMultiError) 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 PersonalLogoutResponseMultiError) AllErrors() []error { return m } + +// PersonalLogoutResponseValidationError is the validation error returned by +// PersonalLogoutResponse.Validate if the designated constraints aren't met. +type PersonalLogoutResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalLogoutResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalLogoutResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalLogoutResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalLogoutResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalLogoutResponseValidationError) ErrorName() string { + return "PersonalLogoutResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalLogoutResponseValidationError) 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 %sPersonalLogoutResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalLogoutResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalLogoutResponseValidationError{} + +// Validate checks the field values on ListPersonalRolesRequest 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 *ListPersonalRolesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalRolesRequest 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 +// ListPersonalRolesRequestMultiError, or nil if none found. +func (m *ListPersonalRolesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalRolesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return ListPersonalRolesRequestMultiError(errors) + } + + return nil +} + +// ListPersonalRolesRequestMultiError is an error wrapping multiple validation +// errors returned by ListPersonalRolesRequest.ValidateAll() if the designated +// constraints aren't met. +type ListPersonalRolesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalRolesRequestMultiError) 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 ListPersonalRolesRequestMultiError) AllErrors() []error { return m } + +// ListPersonalRolesRequestValidationError is the validation error returned by +// ListPersonalRolesRequest.Validate if the designated constraints aren't met. +type ListPersonalRolesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalRolesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalRolesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalRolesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalRolesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalRolesRequestValidationError) ErrorName() string { + return "ListPersonalRolesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalRolesRequestValidationError) 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 %sListPersonalRolesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalRolesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalRolesRequestValidationError{} + +// Validate checks the field values on ListPersonalRolesResponse 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 *ListPersonalRolesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalRolesResponse 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 +// ListPersonalRolesResponseMultiError, or nil if none found. +func (m *ListPersonalRolesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalRolesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListPersonalRolesResponseMultiError(errors) + } + + return nil +} + +// ListPersonalRolesResponseMultiError is an error wrapping multiple validation +// errors returned by ListPersonalRolesResponse.ValidateAll() if the +// designated constraints aren't met. +type ListPersonalRolesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalRolesResponseMultiError) 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 ListPersonalRolesResponseMultiError) AllErrors() []error { return m } + +// ListPersonalRolesResponseValidationError is the validation error returned by +// ListPersonalRolesResponse.Validate if the designated constraints aren't met. +type ListPersonalRolesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalRolesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalRolesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalRolesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalRolesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalRolesResponseValidationError) ErrorName() string { + return "ListPersonalRolesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalRolesResponseValidationError) 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 %sListPersonalRolesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalRolesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalRolesResponseValidationError{} + +// Validate checks the field values on GetPersonalProfileRequest 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 *GetPersonalProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPersonalProfileRequest 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 +// GetPersonalProfileRequestMultiError, or nil if none found. +func (m *GetPersonalProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPersonalProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetPersonalProfileRequestMultiError(errors) + } + + return nil +} + +// GetPersonalProfileRequestMultiError is an error wrapping multiple validation +// errors returned by GetPersonalProfileRequest.ValidateAll() if the +// designated constraints aren't met. +type GetPersonalProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPersonalProfileRequestMultiError) 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 GetPersonalProfileRequestMultiError) AllErrors() []error { return m } + +// GetPersonalProfileRequestValidationError is the validation error returned by +// GetPersonalProfileRequest.Validate if the designated constraints aren't met. +type GetPersonalProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPersonalProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPersonalProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPersonalProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPersonalProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPersonalProfileRequestValidationError) ErrorName() string { + return "GetPersonalProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPersonalProfileRequestValidationError) 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 %sGetPersonalProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPersonalProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPersonalProfileRequestValidationError{} + +// Validate checks the field values on GetPersonalProfileResponse 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 *GetPersonalProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPersonalProfileResponse 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 +// GetPersonalProfileResponseMultiError, or nil if none found. +func (m *GetPersonalProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPersonalProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetPersonalProfileResponseMultiError(errors) + } + + return nil +} + +// GetPersonalProfileResponseMultiError is an error wrapping multiple +// validation errors returned by GetPersonalProfileResponse.ValidateAll() if +// the designated constraints aren't met. +type GetPersonalProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPersonalProfileResponseMultiError) 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 GetPersonalProfileResponseMultiError) AllErrors() []error { return m } + +// GetPersonalProfileResponseValidationError is the validation error returned +// by GetPersonalProfileResponse.Validate if the designated constraints aren't met. +type GetPersonalProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPersonalProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPersonalProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPersonalProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPersonalProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPersonalProfileResponseValidationError) ErrorName() string { + return "GetPersonalProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPersonalProfileResponseValidationError) 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 %sGetPersonalProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPersonalProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPersonalProfileResponseValidationError{} + +// Validate checks the field values on RefreshPersonalTokenRequest 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 *RefreshPersonalTokenRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RefreshPersonalTokenRequest 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 +// RefreshPersonalTokenRequestMultiError, or nil if none found. +func (m *RefreshPersonalTokenRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *RefreshPersonalTokenRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RefreshPersonalTokenRequestMultiError(errors) + } + + return nil +} + +// RefreshPersonalTokenRequestMultiError is an error wrapping multiple +// validation errors returned by RefreshPersonalTokenRequest.ValidateAll() if +// the designated constraints aren't met. +type RefreshPersonalTokenRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RefreshPersonalTokenRequestMultiError) 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 RefreshPersonalTokenRequestMultiError) AllErrors() []error { return m } + +// RefreshPersonalTokenRequestValidationError is the validation error returned +// by RefreshPersonalTokenRequest.Validate if the designated constraints +// aren't met. +type RefreshPersonalTokenRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RefreshPersonalTokenRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RefreshPersonalTokenRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RefreshPersonalTokenRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RefreshPersonalTokenRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RefreshPersonalTokenRequestValidationError) ErrorName() string { + return "RefreshPersonalTokenRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e RefreshPersonalTokenRequestValidationError) 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 %sRefreshPersonalTokenRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RefreshPersonalTokenRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RefreshPersonalTokenRequestValidationError{} + +// Validate checks the field values on RefreshPersonalTokenResponse 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 *RefreshPersonalTokenResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RefreshPersonalTokenResponse 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 +// RefreshPersonalTokenResponseMultiError, or nil if none found. +func (m *RefreshPersonalTokenResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *RefreshPersonalTokenResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Token + + if len(errors) > 0 { + return RefreshPersonalTokenResponseMultiError(errors) + } + + return nil +} + +// RefreshPersonalTokenResponseMultiError is an error wrapping multiple +// validation errors returned by RefreshPersonalTokenResponse.ValidateAll() if +// the designated constraints aren't met. +type RefreshPersonalTokenResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RefreshPersonalTokenResponseMultiError) 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 RefreshPersonalTokenResponseMultiError) AllErrors() []error { return m } + +// RefreshPersonalTokenResponseValidationError is the validation error returned +// by RefreshPersonalTokenResponse.Validate if the designated constraints +// aren't met. +type RefreshPersonalTokenResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RefreshPersonalTokenResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RefreshPersonalTokenResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RefreshPersonalTokenResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RefreshPersonalTokenResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RefreshPersonalTokenResponseValidationError) ErrorName() string { + return "RefreshPersonalTokenResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e RefreshPersonalTokenResponseValidationError) 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 %sRefreshPersonalTokenResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RefreshPersonalTokenResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RefreshPersonalTokenResponseValidationError{} diff --git a/api/v1/services/auth/personal_bridge.pb.go b/api/v1/services/auth/personal_bridge.pb.go new file mode 100644 index 00000000..25b430e6 --- /dev/null +++ b/api/v1/services/auth/personal_bridge.pb.go @@ -0,0 +1,565 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: auth/personal.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const PersonalServiceGetPersonalProfileBridgeOperation = "/api.v1.services.auth.PersonalService/GetPersonalProfile" +const PersonalServiceListPersonalResourcesBridgeOperation = "/api.v1.services.auth.PersonalService/ListPersonalResources" +const PersonalServiceListPersonalRolesBridgeOperation = "/api.v1.services.auth.PersonalService/ListPersonalRoles" +const PersonalServicePersonalLogoutBridgeOperation = "/api.v1.services.auth.PersonalService/PersonalLogout" +const PersonalServiceRefreshPersonalTokenBridgeOperation = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" +const PersonalServiceUpdatePersonalPasswordBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" +const PersonalServiceUpdatePersonalProfileBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" +const PersonalServiceUpdatePersonalSettingBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" + +type PersonalServiceBridgeServer interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) +} + +type PersonalServiceHooker interface { + PersonalServiceGetPersonalProfileHooker + PersonalServiceListPersonalResourcesHooker + PersonalServiceListPersonalRolesHooker + PersonalServicePersonalLogoutHooker + PersonalServiceRefreshPersonalTokenHooker + PersonalServiceUpdatePersonalPasswordHooker + PersonalServiceUpdatePersonalProfileHooker + PersonalServiceUpdatePersonalSettingHooker +} + +type PersonalServiceHookedBridger interface { + PersonalServiceHooker + PersonalServiceBridgeServer +} +type PersonalServiceGetPersonalProfileHooker interface { + PrepareGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) + CompleteGetPersonalProfile(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error +} +type PersonalServiceListPersonalResourcesHooker interface { + PrepareListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) + CompleteListPersonalResources(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error +} +type PersonalServiceListPersonalRolesHooker interface { + PrepareListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) + CompleteListPersonalRoles(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error +} +type PersonalServicePersonalLogoutHooker interface { + PreparePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) + CompletePersonalLogout(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error +} +type PersonalServiceRefreshPersonalTokenHooker interface { + PrepareRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) + CompleteRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error +} +type PersonalServiceUpdatePersonalPasswordHooker interface { + PrepareUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) + CompleteUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error +} +type PersonalServiceUpdatePersonalProfileHooker interface { + PrepareUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) + CompleteUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error +} +type PersonalServiceUpdatePersonalSettingHooker interface { + PrepareUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) + CompleteUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error +} + +func RegisterPersonalServiceBridgeServer(s *http.Server, srv PersonalServiceHookedBridger) { + r := s.Route("/") + r.GET("/auth/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) + r.GET("/auth/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) + r.GET("/auth/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) + r.POST("/auth/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(srv)) + r.POST("/auth/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv)) + r.PUT("/auth/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv)) + r.PUT("/auth/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv)) + r.PUT("/auth/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv)) +} + +func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPersonalProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + }) + + newctx, err := srv.PrepareGetPersonalProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetPersonalProfile(ctx, &in, out.(*GetPersonalProfileResponse)) + } +} + +func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + }) + + newctx, err := srv.PrepareListPersonalResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPersonalResources(ctx, &in, out.(*ListPersonalResourcesResponse)) + } +} + +func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + }) + + newctx, err := srv.PrepareListPersonalRoles(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPersonalRoles(ctx, &in, out.(*ListPersonalRolesResponse)) + } +} + +func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in PersonalLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServicePersonalLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + }) + + newctx, err := srv.PreparePersonalLogout(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompletePersonalLogout(ctx, &in, out.(*PersonalLogoutResponse)) + } +} + +func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RefreshPersonalTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + }) + + newctx, err := srv.PrepareRefreshPersonalToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteRefreshPersonalToken(ctx, &in, out.(*RefreshPersonalTokenResponse)) + } +} + +func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalPassword(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalPassword(ctx, &in, out.(*UpdatePersonalPasswordResponse)) + } +} + +func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalProfileRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalProfile(ctx, &in, out.(*UpdatePersonalProfileResponse)) + } +} + +func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalSettingRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalSetting(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalSetting(ctx, &in, out.(*UpdatePersonalSettingResponse)) + } +} + +// UnimplementedPersonalServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPersonalServiceHooked struct{} + +func (UnimplementedPersonalServiceHooked) PrepareGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PreparePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompletePersonalLogout(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { + return ctx.Result(200, out) +} + +func WithPersonalServiceHook(h PersonalServiceHooker) func(PersonalServiceBridgeServer) PersonalServiceHookedBridger { + return func(srv PersonalServiceBridgeServer) PersonalServiceHookedBridger { + return PersonalServiceHookedBridge{PersonalServiceBridgeServer: srv, PersonalServiceHooker: h} + } +} + +// PersonalServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PersonalService. +// It implements the HTTP and gRPC implementations of PersonalService. +// It forwards requests and responses between the two implementations. +type PersonalServiceHookedBridge struct { + PersonalServiceBridgeServer + PersonalServiceHooker +} + +type PersonalServiceHTTPBridgeImpl struct { + client PersonalServiceHTTPClient +} + +func NewPersonalServiceHTTPBridge(client *http.Client) PersonalServiceHTTPServer { + return &PersonalServiceHTTPBridgeImpl{client: NewPersonalServiceHTTPClient(client)} +} + +func (c *PersonalServiceHTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +type PersonalServiceBridgeImpl struct { + client PersonalServiceClient +} + +func NewPersonalServiceBridge(client grpc.ClientConnInterface) PersonalServiceServer { + return &PersonalServiceBridgeImpl{client: NewPersonalServiceClient(client)} +} + +func (c *PersonalServiceBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} + +type PersonalServiceGRPC2HTTPBridgeImpl struct { + client PersonalServiceClient +} + +func NewPersonalServiceGRPC2HTTP(client grpc.ClientConnInterface) PersonalServiceHTTPServer { + return &PersonalServiceGRPC2HTTPBridgeImpl{client: NewPersonalServiceClient(client)} +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +type PersonalServiceHTTP2GRPCBridgeImpl struct { + client PersonalServiceHTTPClient +} + +func NewPersonalServiceHTTP2GRPC(client *http.Client) PersonalServiceServer { + return &PersonalServiceHTTP2GRPCBridgeImpl{client: NewPersonalServiceHTTPClient(client)} +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} diff --git a/api/v1/services/auth/personal_grpc.pb.go b/api/v1/services/auth/personal_grpc.pb.go new file mode 100644 index 00000000..6f4d95e8 --- /dev/null +++ b/api/v1/services/auth/personal_grpc.pb.go @@ -0,0 +1,407 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: auth/personal.proto + +package auth + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + PersonalService_GetPersonalProfile_FullMethodName = "/api.v1.services.auth.PersonalService/GetPersonalProfile" + PersonalService_ListPersonalResources_FullMethodName = "/api.v1.services.auth.PersonalService/ListPersonalResources" + PersonalService_ListPersonalRoles_FullMethodName = "/api.v1.services.auth.PersonalService/ListPersonalRoles" + PersonalService_PersonalLogout_FullMethodName = "/api.v1.services.auth.PersonalService/PersonalLogout" + PersonalService_RefreshPersonalToken_FullMethodName = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" + PersonalService_UpdatePersonalPassword_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" + PersonalService_UpdatePersonalProfile_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" + PersonalService_UpdatePersonalSetting_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" +) + +// PersonalServiceClient is the client API for PersonalService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// PersonalService Personal user service +type PersonalServiceClient interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) +} + +type personalServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPersonalServiceClient(cc grpc.ClientConnInterface) PersonalServiceClient { + return &personalServiceClient{cc} +} + +func (c *personalServiceClient) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetPersonalProfileResponse) + err := c.cc.Invoke(ctx, PersonalService_GetPersonalProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPersonalResourcesResponse) + err := c.cc.Invoke(ctx, PersonalService_ListPersonalResources_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPersonalRolesResponse) + err := c.cc.Invoke(ctx, PersonalService_ListPersonalRoles_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(PersonalLogoutResponse) + err := c.cc.Invoke(ctx, PersonalService_PersonalLogout_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RefreshPersonalTokenResponse) + err := c.cc.Invoke(ctx, PersonalService_RefreshPersonalToken_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalPasswordResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalPassword_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalProfileResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalSettingResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalSetting_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PersonalServiceServer is the server API for PersonalService service. +// All implementations must embed UnimplementedPersonalServiceServer +// for forward compatibility. +// +// PersonalService Personal user service +type PersonalServiceServer interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) + mustEmbedUnimplementedPersonalServiceServer() +} + +// UnimplementedPersonalServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPersonalServiceServer struct{} + +func (UnimplementedPersonalServiceServer) GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPersonalProfile not implemented") +} +func (UnimplementedPersonalServiceServer) ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPersonalResources not implemented") +} +func (UnimplementedPersonalServiceServer) ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPersonalRoles not implemented") +} +func (UnimplementedPersonalServiceServer) PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PersonalLogout not implemented") +} +func (UnimplementedPersonalServiceServer) RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RefreshPersonalToken not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalPassword not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalProfile not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalSetting not implemented") +} +func (UnimplementedPersonalServiceServer) mustEmbedUnimplementedPersonalServiceServer() {} +func (UnimplementedPersonalServiceServer) testEmbeddedByValue() {} + +// UnsafePersonalServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PersonalServiceServer will +// result in compilation errors. +type UnsafePersonalServiceServer interface { + mustEmbedUnimplementedPersonalServiceServer() +} + +func RegisterPersonalServiceServer(s grpc.ServiceRegistrar, srv PersonalServiceServer) { + // If the following call pancis, it indicates UnimplementedPersonalServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&PersonalService_ServiceDesc, srv) +} + +func _PersonalService_GetPersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPersonalProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).GetPersonalProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_GetPersonalProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_ListPersonalResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPersonalResourcesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).ListPersonalResources(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_ListPersonalResources_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_ListPersonalRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPersonalRolesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).ListPersonalRoles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_ListPersonalRoles_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_PersonalLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PersonalLogoutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).PersonalLogout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_PersonalLogout_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_RefreshPersonalToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RefreshPersonalTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_RefreshPersonalToken_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalPasswordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalPassword_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalSettingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalSetting_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// PersonalService_ServiceDesc is the grpc.ServiceDesc for PersonalService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PersonalService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.auth.PersonalService", + HandlerType: (*PersonalServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetPersonalProfile", + Handler: _PersonalService_GetPersonalProfile_Handler, + }, + { + MethodName: "ListPersonalResources", + Handler: _PersonalService_ListPersonalResources_Handler, + }, + { + MethodName: "ListPersonalRoles", + Handler: _PersonalService_ListPersonalRoles_Handler, + }, + { + MethodName: "PersonalLogout", + Handler: _PersonalService_PersonalLogout_Handler, + }, + { + MethodName: "RefreshPersonalToken", + Handler: _PersonalService_RefreshPersonalToken_Handler, + }, + { + MethodName: "UpdatePersonalPassword", + Handler: _PersonalService_UpdatePersonalPassword_Handler, + }, + { + MethodName: "UpdatePersonalProfile", + Handler: _PersonalService_UpdatePersonalProfile_Handler, + }, + { + MethodName: "UpdatePersonalSetting", + Handler: _PersonalService_UpdatePersonalSetting_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "auth/personal.proto", +} diff --git a/api/v1/services/auth/personal_http.pb.go b/api/v1/services/auth/personal_http.pb.go new file mode 100644 index 00000000..c14326b3 --- /dev/null +++ b/api/v1/services/auth/personal_http.pb.go @@ -0,0 +1,350 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.8.4 +// - protoc (unknown) +// source: auth/personal.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationPersonalServiceGetPersonalProfile = "/api.v1.services.auth.PersonalService/GetPersonalProfile" +const OperationPersonalServiceListPersonalResources = "/api.v1.services.auth.PersonalService/ListPersonalResources" +const OperationPersonalServiceListPersonalRoles = "/api.v1.services.auth.PersonalService/ListPersonalRoles" +const OperationPersonalServicePersonalLogout = "/api.v1.services.auth.PersonalService/PersonalLogout" +const OperationPersonalServiceRefreshPersonalToken = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" +const OperationPersonalServiceUpdatePersonalPassword = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" +const OperationPersonalServiceUpdatePersonalProfile = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" +const OperationPersonalServiceUpdatePersonalSetting = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" + +type PersonalServiceHTTPServer interface { + // GetPersonalProfile GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalRoles ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) +} + +func RegisterPersonalServiceHTTPServer(s *http.Server, srv PersonalServiceHTTPServer) { + r := s.Route("/") + r.GET("/auth/personal/profile", _PersonalService_GetPersonalProfile0_HTTP_Handler(srv)) + r.GET("/auth/personal/resources", _PersonalService_ListPersonalResources0_HTTP_Handler(srv)) + r.GET("/auth/personal/roles", _PersonalService_ListPersonalRoles0_HTTP_Handler(srv)) + r.POST("/auth/personal/logout", _PersonalService_PersonalLogout0_HTTP_Handler(srv)) + r.POST("/auth/personal/token/refresh", _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv)) + r.PUT("/auth/personal/password", _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv)) + r.PUT("/auth/personal/profile", _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv)) + r.PUT("/auth/personal/setting", _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv)) +} + +func _PersonalService_GetPersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPersonalProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetPersonalProfileResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_ListPersonalResources0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPersonalResourcesResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_ListPersonalRoles0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPersonalRolesResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_PersonalLogout0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in PersonalLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServicePersonalLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*PersonalLogoutResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RefreshPersonalTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*RefreshPersonalTokenResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalPasswordResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalProfileRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalProfileResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalSettingRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalSettingResponse) + return ctx.Result(200, reply) + } +} + +type PersonalServiceHTTPClient interface { + GetPersonalProfile(ctx context.Context, req *GetPersonalProfileRequest, opts ...http.CallOption) (rsp *GetPersonalProfileResponse, err error) + ListPersonalResources(ctx context.Context, req *ListPersonalResourcesRequest, opts ...http.CallOption) (rsp *ListPersonalResourcesResponse, err error) + ListPersonalRoles(ctx context.Context, req *ListPersonalRolesRequest, opts ...http.CallOption) (rsp *ListPersonalRolesResponse, err error) + PersonalLogout(ctx context.Context, req *PersonalLogoutRequest, opts ...http.CallOption) (rsp *PersonalLogoutResponse, err error) + RefreshPersonalToken(ctx context.Context, req *RefreshPersonalTokenRequest, opts ...http.CallOption) (rsp *RefreshPersonalTokenResponse, err error) + UpdatePersonalPassword(ctx context.Context, req *UpdatePersonalPasswordRequest, opts ...http.CallOption) (rsp *UpdatePersonalPasswordResponse, err error) + UpdatePersonalProfile(ctx context.Context, req *UpdatePersonalProfileRequest, opts ...http.CallOption) (rsp *UpdatePersonalProfileResponse, err error) + UpdatePersonalSetting(ctx context.Context, req *UpdatePersonalSettingRequest, opts ...http.CallOption) (rsp *UpdatePersonalSettingResponse, err error) +} + +type PersonalServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewPersonalServiceHTTPClient(client *http.Client) PersonalServiceHTTPClient { + return &PersonalServiceHTTPClientImpl{client} +} + +func (c *PersonalServiceHTTPClientImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...http.CallOption) (*GetPersonalProfileResponse, error) { + var out GetPersonalProfileResponse + pattern := "/auth/personal/profile" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceGetPersonalProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PersonalServiceHTTPClientImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...http.CallOption) (*ListPersonalResourcesResponse, error) { + var out ListPersonalResourcesResponse + pattern := "/auth/personal/resources" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceListPersonalResources)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PersonalServiceHTTPClientImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...http.CallOption) (*ListPersonalRolesResponse, error) { + var out ListPersonalRolesResponse + pattern := "/auth/personal/roles" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceListPersonalRoles)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PersonalServiceHTTPClientImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...http.CallOption) (*PersonalLogoutResponse, error) { + var out PersonalLogoutResponse + pattern := "/auth/personal/logout" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServicePersonalLogout)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PersonalServiceHTTPClientImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...http.CallOption) (*RefreshPersonalTokenResponse, error) { + var out RefreshPersonalTokenResponse + pattern := "/auth/personal/token/refresh" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceRefreshPersonalToken)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...http.CallOption) (*UpdatePersonalPasswordResponse, error) { + var out UpdatePersonalPasswordResponse + pattern := "/auth/personal/password" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalPassword)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...http.CallOption) (*UpdatePersonalProfileResponse, error) { + var out UpdatePersonalProfileResponse + pattern := "/auth/personal/profile" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...http.CallOption) (*UpdatePersonalSettingResponse, error) { + var out UpdatePersonalSettingResponse + pattern := "/auth/personal/setting" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalSetting)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go index 45ba65ad..65ca7403 100644 --- a/api/v1/services/system/department_bridge.pb.go +++ b/api/v1/services/system/department_bridge.pb.go @@ -34,7 +34,7 @@ const DepartmentServiceGetDepartmentBridgeOperation = "/api.v1.services.system.D const DepartmentServiceListDepartmentsBridgeOperation = "/api.v1.services.system.DepartmentService/ListDepartments" const DepartmentServiceUpdateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/UpdateDepartment" -type DepartmentServiceBridger interface { +type DepartmentServiceBridgeServer interface { CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) @@ -52,7 +52,7 @@ type DepartmentServiceHooker interface { type DepartmentServiceHookedBridger interface { DepartmentServiceHooker - DepartmentServiceBridger + DepartmentServiceBridgeServer } type DepartmentServiceCreateDepartmentHooker interface { PrepareCreateDepartment(http.Context, *CreateDepartmentRequest) (context.Context, error) @@ -75,7 +75,7 @@ type DepartmentServiceUpdateDepartmentHooker interface { CompleteUpdateDepartment(http.Context, *UpdateDepartmentRequest, *UpdateDepartmentResponse) error } -func RegisterDepartmentServiceBridger(s *http.Server, srv DepartmentServiceHookedBridger) { +func RegisterDepartmentServiceBridgeServer(s *http.Server, srv DepartmentServiceHookedBridger) { r := s.Route("/") r.GET("/sys/departments", _DepartmentService_ListDepartments0_Bridge_Handler(srv)) r.GET("/sys/departments/:id", _DepartmentService_GetDepartment0_Bridge_Handler(srv)) @@ -261,9 +261,9 @@ func (UnimplementedDepartmentServiceHooked) CompleteUpdateDepartment(ctx http.Co return ctx.Result(200, out) } -func WithDepartmentServiceHook(h DepartmentServiceHooker) func(DepartmentServiceBridger) DepartmentServiceHookedBridger { - return func(b DepartmentServiceBridger) DepartmentServiceHookedBridger { - return DepartmentServiceHookedBridge{DepartmentServiceBridger: b, DepartmentServiceHooker: h} +func WithDepartmentServiceHook(h DepartmentServiceHooker) func(DepartmentServiceBridgeServer) DepartmentServiceHookedBridger { + return func(srv DepartmentServiceBridgeServer) DepartmentServiceHookedBridger { + return DepartmentServiceHookedBridge{DepartmentServiceBridgeServer: srv, DepartmentServiceHooker: h} } } @@ -271,7 +271,7 @@ func WithDepartmentServiceHook(h DepartmentServiceHooker) func(DepartmentService // It implements the HTTP and gRPC implementations of DepartmentService. // It forwards requests and responses between the two implementations. type DepartmentServiceHookedBridge struct { - DepartmentServiceBridger + DepartmentServiceBridgeServer DepartmentServiceHooker } diff --git a/api/v1/services/system/menu_bridge.pb.go b/api/v1/services/system/menu_bridge.pb.go index 33811543..03afbf8b 100644 --- a/api/v1/services/system/menu_bridge.pb.go +++ b/api/v1/services/system/menu_bridge.pb.go @@ -34,7 +34,7 @@ const MenuServiceGetMenuBridgeOperation = "/api.v1.services.system.MenuService/G const MenuServiceListMenusBridgeOperation = "/api.v1.services.system.MenuService/ListMenus" const MenuServiceUpdateMenuBridgeOperation = "/api.v1.services.system.MenuService/UpdateMenu" -type MenuServiceBridger interface { +type MenuServiceBridgeServer interface { CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) @@ -52,7 +52,7 @@ type MenuServiceHooker interface { type MenuServiceHookedBridger interface { MenuServiceHooker - MenuServiceBridger + MenuServiceBridgeServer } type MenuServiceCreateMenuHooker interface { PrepareCreateMenu(http.Context, *CreateMenuRequest) (context.Context, error) @@ -75,7 +75,7 @@ type MenuServiceUpdateMenuHooker interface { CompleteUpdateMenu(http.Context, *UpdateMenuRequest, *UpdateMenuResponse) error } -func RegisterMenuServiceBridger(s *http.Server, srv MenuServiceHookedBridger) { +func RegisterMenuServiceBridgeServer(s *http.Server, srv MenuServiceHookedBridger) { r := s.Route("/") r.GET("/sys/menus", _MenuService_ListMenus0_Bridge_Handler(srv)) r.GET("/sys/menus/:id", _MenuService_GetMenu0_Bridge_Handler(srv)) @@ -261,9 +261,9 @@ func (UnimplementedMenuServiceHooked) CompleteUpdateMenu(ctx http.Context, in *U return ctx.Result(200, out) } -func WithMenuServiceHook(h MenuServiceHooker) func(MenuServiceBridger) MenuServiceHookedBridger { - return func(b MenuServiceBridger) MenuServiceHookedBridger { - return MenuServiceHookedBridge{MenuServiceBridger: b, MenuServiceHooker: h} +func WithMenuServiceHook(h MenuServiceHooker) func(MenuServiceBridgeServer) MenuServiceHookedBridger { + return func(srv MenuServiceBridgeServer) MenuServiceHookedBridger { + return MenuServiceHookedBridge{MenuServiceBridgeServer: srv, MenuServiceHooker: h} } } @@ -271,7 +271,7 @@ func WithMenuServiceHook(h MenuServiceHooker) func(MenuServiceBridger) MenuServi // It implements the HTTP and gRPC implementations of MenuService. // It forwards requests and responses between the two implementations. type MenuServiceHookedBridge struct { - MenuServiceBridger + MenuServiceBridgeServer MenuServiceHooker } diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go index b8e5eb71..9648b59b 100644 --- a/api/v1/services/system/permission_bridge.pb.go +++ b/api/v1/services/system/permission_bridge.pb.go @@ -34,7 +34,7 @@ const PermissionServiceGetPermissionBridgeOperation = "/api.v1.services.system.P const PermissionServiceListPermissionsBridgeOperation = "/api.v1.services.system.PermissionService/ListPermissions" const PermissionServiceUpdatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/UpdatePermission" -type PermissionServiceBridger interface { +type PermissionServiceBridgeServer interface { CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) @@ -52,7 +52,7 @@ type PermissionServiceHooker interface { type PermissionServiceHookedBridger interface { PermissionServiceHooker - PermissionServiceBridger + PermissionServiceBridgeServer } type PermissionServiceCreatePermissionHooker interface { PrepareCreatePermission(http.Context, *CreatePermissionRequest) (context.Context, error) @@ -75,7 +75,7 @@ type PermissionServiceUpdatePermissionHooker interface { CompleteUpdatePermission(http.Context, *UpdatePermissionRequest, *UpdatePermissionResponse) error } -func RegisterPermissionServiceBridger(s *http.Server, srv PermissionServiceHookedBridger) { +func RegisterPermissionServiceBridgeServer(s *http.Server, srv PermissionServiceHookedBridger) { r := s.Route("/") r.GET("/sys/permissions", _PermissionService_ListPermissions0_Bridge_Handler(srv)) r.GET("/sys/permissions/:id", _PermissionService_GetPermission0_Bridge_Handler(srv)) @@ -261,9 +261,9 @@ func (UnimplementedPermissionServiceHooked) CompleteUpdatePermission(ctx http.Co return ctx.Result(200, out) } -func WithPermissionServiceHook(h PermissionServiceHooker) func(PermissionServiceBridger) PermissionServiceHookedBridger { - return func(b PermissionServiceBridger) PermissionServiceHookedBridger { - return PermissionServiceHookedBridge{PermissionServiceBridger: b, PermissionServiceHooker: h} +func WithPermissionServiceHook(h PermissionServiceHooker) func(PermissionServiceBridgeServer) PermissionServiceHookedBridger { + return func(srv PermissionServiceBridgeServer) PermissionServiceHookedBridger { + return PermissionServiceHookedBridge{PermissionServiceBridgeServer: srv, PermissionServiceHooker: h} } } @@ -271,7 +271,7 @@ func WithPermissionServiceHook(h PermissionServiceHooker) func(PermissionService // It implements the HTTP and gRPC implementations of PermissionService. // It forwards requests and responses between the two implementations. type PermissionServiceHookedBridge struct { - PermissionServiceBridger + PermissionServiceBridgeServer PermissionServiceHooker } diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go index af3ce519..037f1db0 100644 --- a/api/v1/services/system/position_bridge.pb.go +++ b/api/v1/services/system/position_bridge.pb.go @@ -34,7 +34,7 @@ const PositionServiceGetPositionBridgeOperation = "/api.v1.services.system.Posit const PositionServiceListPositionsBridgeOperation = "/api.v1.services.system.PositionService/ListPositions" const PositionServiceUpdatePositionBridgeOperation = "/api.v1.services.system.PositionService/UpdatePosition" -type PositionServiceBridger interface { +type PositionServiceBridgeServer interface { CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) @@ -52,7 +52,7 @@ type PositionServiceHooker interface { type PositionServiceHookedBridger interface { PositionServiceHooker - PositionServiceBridger + PositionServiceBridgeServer } type PositionServiceCreatePositionHooker interface { PrepareCreatePosition(http.Context, *CreatePositionRequest) (context.Context, error) @@ -75,7 +75,7 @@ type PositionServiceUpdatePositionHooker interface { CompleteUpdatePosition(http.Context, *UpdatePositionRequest, *UpdatePositionResponse) error } -func RegisterPositionServiceBridger(s *http.Server, srv PositionServiceHookedBridger) { +func RegisterPositionServiceBridgeServer(s *http.Server, srv PositionServiceHookedBridger) { r := s.Route("/") r.GET("/sys/positions", _PositionService_ListPositions0_Bridge_Handler(srv)) r.GET("/sys/positions/:id", _PositionService_GetPosition0_Bridge_Handler(srv)) @@ -261,9 +261,9 @@ func (UnimplementedPositionServiceHooked) CompleteUpdatePosition(ctx http.Contex return ctx.Result(200, out) } -func WithPositionServiceHook(h PositionServiceHooker) func(PositionServiceBridger) PositionServiceHookedBridger { - return func(b PositionServiceBridger) PositionServiceHookedBridger { - return PositionServiceHookedBridge{PositionServiceBridger: b, PositionServiceHooker: h} +func WithPositionServiceHook(h PositionServiceHooker) func(PositionServiceBridgeServer) PositionServiceHookedBridger { + return func(srv PositionServiceBridgeServer) PositionServiceHookedBridger { + return PositionServiceHookedBridge{PositionServiceBridgeServer: srv, PositionServiceHooker: h} } } @@ -271,7 +271,7 @@ func WithPositionServiceHook(h PositionServiceHooker) func(PositionServiceBridge // It implements the HTTP and gRPC implementations of PositionService. // It forwards requests and responses between the two implementations. type PositionServiceHookedBridge struct { - PositionServiceBridger + PositionServiceBridgeServer PositionServiceHooker } diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go index b31aba9b..4b19f3e1 100644 --- a/api/v1/services/system/resource_bridge.pb.go +++ b/api/v1/services/system/resource_bridge.pb.go @@ -34,7 +34,7 @@ const ResourceServiceGetResourceBridgeOperation = "/api.v1.services.system.Resou const ResourceServiceListResourcesBridgeOperation = "/api.v1.services.system.ResourceService/ListResources" const ResourceServiceUpdateResourceBridgeOperation = "/api.v1.services.system.ResourceService/UpdateResource" -type ResourceServiceBridger interface { +type ResourceServiceBridgeServer interface { CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) @@ -52,7 +52,7 @@ type ResourceServiceHooker interface { type ResourceServiceHookedBridger interface { ResourceServiceHooker - ResourceServiceBridger + ResourceServiceBridgeServer } type ResourceServiceCreateResourceHooker interface { PrepareCreateResource(http.Context, *CreateResourceRequest) (context.Context, error) @@ -75,7 +75,7 @@ type ResourceServiceUpdateResourceHooker interface { CompleteUpdateResource(http.Context, *UpdateResourceRequest, *UpdateResourceResponse) error } -func RegisterResourceServiceBridger(s *http.Server, srv ResourceServiceHookedBridger) { +func RegisterResourceServiceBridgeServer(s *http.Server, srv ResourceServiceHookedBridger) { r := s.Route("/") r.GET("/sys/resources", _ResourceService_ListResources0_Bridge_Handler(srv)) r.GET("/sys/resources/:id", _ResourceService_GetResource0_Bridge_Handler(srv)) @@ -261,9 +261,9 @@ func (UnimplementedResourceServiceHooked) CompleteUpdateResource(ctx http.Contex return ctx.Result(200, out) } -func WithResourceServiceHook(h ResourceServiceHooker) func(ResourceServiceBridger) ResourceServiceHookedBridger { - return func(b ResourceServiceBridger) ResourceServiceHookedBridger { - return ResourceServiceHookedBridge{ResourceServiceBridger: b, ResourceServiceHooker: h} +func WithResourceServiceHook(h ResourceServiceHooker) func(ResourceServiceBridgeServer) ResourceServiceHookedBridger { + return func(srv ResourceServiceBridgeServer) ResourceServiceHookedBridger { + return ResourceServiceHookedBridge{ResourceServiceBridgeServer: srv, ResourceServiceHooker: h} } } @@ -271,7 +271,7 @@ func WithResourceServiceHook(h ResourceServiceHooker) func(ResourceServiceBridge // It implements the HTTP and gRPC implementations of ResourceService. // It forwards requests and responses between the two implementations. type ResourceServiceHookedBridge struct { - ResourceServiceBridger + ResourceServiceBridgeServer ResourceServiceHooker } diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go index 186f05ef..bb313daf 100644 --- a/api/v1/services/system/role_bridge.pb.go +++ b/api/v1/services/system/role_bridge.pb.go @@ -34,7 +34,7 @@ const RoleServiceGetRoleBridgeOperation = "/api.v1.services.system.RoleService/G const RoleServiceListRolesBridgeOperation = "/api.v1.services.system.RoleService/ListRoles" const RoleServiceUpdateRoleBridgeOperation = "/api.v1.services.system.RoleService/UpdateRole" -type RoleServiceBridger interface { +type RoleServiceBridgeServer interface { CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) @@ -52,7 +52,7 @@ type RoleServiceHooker interface { type RoleServiceHookedBridger interface { RoleServiceHooker - RoleServiceBridger + RoleServiceBridgeServer } type RoleServiceCreateRoleHooker interface { PrepareCreateRole(http.Context, *CreateRoleRequest) (context.Context, error) @@ -75,7 +75,7 @@ type RoleServiceUpdateRoleHooker interface { CompleteUpdateRole(http.Context, *UpdateRoleRequest, *UpdateRoleResponse) error } -func RegisterRoleServiceBridger(s *http.Server, srv RoleServiceHookedBridger) { +func RegisterRoleServiceBridgeServer(s *http.Server, srv RoleServiceHookedBridger) { r := s.Route("/") r.GET("/sys/roles", _RoleService_ListRoles0_Bridge_Handler(srv)) r.GET("/sys/roles/:id", _RoleService_GetRole0_Bridge_Handler(srv)) @@ -261,9 +261,9 @@ func (UnimplementedRoleServiceHooked) CompleteUpdateRole(ctx http.Context, in *U return ctx.Result(200, out) } -func WithRoleServiceHook(h RoleServiceHooker) func(RoleServiceBridger) RoleServiceHookedBridger { - return func(b RoleServiceBridger) RoleServiceHookedBridger { - return RoleServiceHookedBridge{RoleServiceBridger: b, RoleServiceHooker: h} +func WithRoleServiceHook(h RoleServiceHooker) func(RoleServiceBridgeServer) RoleServiceHookedBridger { + return func(srv RoleServiceBridgeServer) RoleServiceHookedBridger { + return RoleServiceHookedBridge{RoleServiceBridgeServer: srv, RoleServiceHooker: h} } } @@ -271,7 +271,7 @@ func WithRoleServiceHook(h RoleServiceHooker) func(RoleServiceBridger) RoleServi // It implements the HTTP and gRPC implementations of RoleService. // It forwards requests and responses between the two implementations. type RoleServiceHookedBridge struct { - RoleServiceBridger + RoleServiceBridgeServer RoleServiceHooker } diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index ddc0da78..85075ca1 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -38,7 +38,7 @@ const UserServiceUpdateUserBridgeOperation = "/api.v1.services.system.UserServic const UserServiceUpdateUserRolesBridgeOperation = "/api.v1.services.system.UserService/UpdateUserRoles" const UserServiceUpdateUserStatusBridgeOperation = "/api.v1.services.system.UserService/UpdateUserStatus" -type UserServiceBridger interface { +type UserServiceBridgeServer interface { CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) @@ -67,7 +67,7 @@ type UserServiceHooker interface { type UserServiceHookedBridger interface { UserServiceHooker - UserServiceBridger + UserServiceBridgeServer } type UserServiceCreateUserHooker interface { PrepareCreateUser(http.Context, *CreateUserRequest) (context.Context, error) @@ -106,7 +106,7 @@ type UserServiceUpdateUserStatusHooker interface { CompleteUpdateUserStatus(http.Context, *UpdateUserStatusRequest, *UpdateUserStatusResponse) error } -func RegisterUserServiceBridger(s *http.Server, srv UserServiceHookedBridger) { +func RegisterUserServiceBridgeServer(s *http.Server, srv UserServiceHookedBridger) { r := s.Route("/") r.GET("/sys/users", _UserService_ListUsers0_Bridge_Handler(srv)) r.GET("/sys/users/:id/resources", _UserService_ListUserResources0_Bridge_Handler(srv)) @@ -441,9 +441,9 @@ func (UnimplementedUserServiceHooked) CompleteUpdateUserStatus(ctx http.Context, return ctx.Result(200, out) } -func WithUserServiceHook(h UserServiceHooker) func(UserServiceBridger) UserServiceHookedBridger { - return func(b UserServiceBridger) UserServiceHookedBridger { - return UserServiceHookedBridge{UserServiceBridger: b, UserServiceHooker: h} +func WithUserServiceHook(h UserServiceHooker) func(UserServiceBridgeServer) UserServiceHookedBridger { + return func(srv UserServiceBridgeServer) UserServiceHookedBridger { + return UserServiceHookedBridge{UserServiceBridgeServer: srv, UserServiceHooker: h} } } @@ -451,7 +451,7 @@ func WithUserServiceHook(h UserServiceHooker) func(UserServiceBridger) UserServi // It implements the HTTP and gRPC implementations of UserService. // It forwards requests and responses between the two implementations. type UserServiceHookedBridge struct { - UserServiceBridger + UserServiceBridgeServer UserServiceHooker } diff --git a/cmd/internal/start/wire.go b/cmd/internal/start/wire.go index 6eb0d662..4fe4007b 100644 --- a/cmd/internal/start/wire.go +++ b/cmd/internal/start/wire.go @@ -32,7 +32,7 @@ func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*krat data.ProviderSet, systemdal.ProviderSet, systembiz.ProviderSet, - systemservice.ProviderSet, + systemservice.LocalProviderSet, //systemserver.ProviderSet, authdal.ProviderSet, authbiz.ProviderSet, diff --git a/internal/mods/auth/service/auth.bridge.go b/internal/mods/auth/service/auth.bridge.go index dc5a9517..324b2b2b 100644 --- a/internal/mods/auth/service/auth.bridge.go +++ b/internal/mods/auth/service/auth.bridge.go @@ -161,9 +161,9 @@ func (s AuthServiceHookedBridge) AuthLogout(ctx context.Context, request *pb.Aut // return nil, nil //} -func NewAuthServiceHookedBridge(r runtime.Runtime, client pb.AuthServiceHTTPServer) pb.AuthServiceHookedBridger { +func NewAuthServiceHookedBridge(r runtime.Runtime, client pb.AuthServiceServer) pb.AuthServiceHookedBridger { return pb.WithAuthServiceHook(&AuthServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/permission")), + log: log.NewHelper(r.WithLogger("module", "service/auth")), })(client) } diff --git a/internal/mods/auth/service/auth.grpc.go b/internal/mods/auth/service/auth.grpc.go index 0f0f97fe..078501cc 100644 --- a/internal/mods/auth/service/auth.grpc.go +++ b/internal/mods/auth/service/auth.grpc.go @@ -22,11 +22,6 @@ func (s AuthServiceServer) ListAuthResources(ctx context.Context, request *pb.Li return s.client.ListAuthResources(ctx, request) } -//func (m AuthServiceServer) mustEmbedUnimplementedAuthServiceServer() { -// //TODO implement me -// panic("implement me") -//} - // NewAuthServiceServerPB new a menu service. func NewAuthServiceServerPB(client *biz.AuthServiceBiz) pb.AuthServiceServer { return &AuthServiceServer{client: client} diff --git a/internal/mods/auth/service/casbin.bridge.go b/internal/mods/auth/service/casbin.bridge.go index 7b7dd740..70bc4b93 100644 --- a/internal/mods/auth/service/casbin.bridge.go +++ b/internal/mods/auth/service/casbin.bridge.go @@ -186,7 +186,7 @@ func (c CasbinServiceHookedBridge) CompleteWatchUpdate(context http.Context, req func NewCasbinServiceHookedBridge(r runtime.Runtime, client pb.CasbinSourceServiceHTTPServer) pb. CasbinSourceServiceHookedBridger { return pb.WithCasbinSourceServiceHook(&CasbinServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/permission")), + log: log.NewHelper(r.WithLogger("module", "service/auth")), })(client) } diff --git a/internal/mods/auth/service/login.bridge.go b/internal/mods/auth/service/login.bridge.go index 8d68d472..b2ce13b8 100644 --- a/internal/mods/auth/service/login.bridge.go +++ b/internal/mods/auth/service/login.bridge.go @@ -236,7 +236,7 @@ func (s LoginServiceHookedBridge) CompleteTokenRefresh(h transhttp.Context, requ func NewLoginServiceHookedBridge(r runtime.Runtime, client pb.LoginServiceHTTPServer) pb.LoginServiceHookedBridger { return pb.WithLoginServiceHook(&LoginServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/permission")), + log: log.NewHelper(r.WithLogger("module", "service/auth")), })(client) } diff --git a/internal/mods/auth/service/personal.bridge.go b/internal/mods/auth/service/personal.bridge.go index 5a6a83f3..04aa97c5 100644 --- a/internal/mods/auth/service/personal.bridge.go +++ b/internal/mods/auth/service/personal.bridge.go @@ -92,11 +92,10 @@ func (p PersonalServiceHookedBridge) CompleteUpdatePersonalSetting(context trans panic("implement me") } -func NewPersonalServiceHookedBridge(r runtime.Runtime, client pb.PersonalServiceHTTPServer) pb.PersonalServiceHooker { - return &PersonalServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/permission")), - client: client, - } +func NewPersonalServiceHookedBridge(r runtime.Runtime, client pb.PersonalServiceHTTPServer) pb.PersonalServiceHookedBridger { + return pb.WithPersonalServiceHook(&PersonalServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/auth")), + })(client) } // NewPersonalServiceBridge new a menu service. diff --git a/internal/mods/auth/service/service.go b/internal/mods/auth/service/service.go index 2800faf1..f99afdfe 100644 --- a/internal/mods/auth/service/service.go +++ b/internal/mods/auth/service/service.go @@ -8,6 +8,7 @@ import ( "context" "github.com/google/wire" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -81,4 +82,50 @@ func NewRegisterServer( } } +type RegisterBridgeServer struct { + Auth pb.AuthServiceHookedBridger + Casbin pb.CasbinSourceServiceHookedBridger + Login pb.LoginServiceHookedBridger + Personal pb.PersonalServiceHookedBridger +} + +func (s RegisterBridgeServer) Register(ctx context.Context, svc any) { + switch v := svc.(type) { + case *service.GRPCServer: + s.RegisterGRPC(ctx, v) + case *service.HTTPServer: + s.RegisterHTTP(ctx, v) + } +} + +func (s RegisterBridgeServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { + log.Info("http server auth init") + pb.RegisterAuthServiceBridgeServer(server, s.Auth) + pb.RegisterCasbinSourceServiceBridgeServer(server, s.Casbin) + pb.RegisterLoginServiceBridgeServer(server, s.Login) + pb.RegisterPersonalServiceBridgeServer(server, s.Personal) +} + +func (s RegisterBridgeServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { + log.Info("http server system init") + //pb.RegisterResourceServiceBridgeServer(server, s.Resource) + //pb.RegisterRoleServiceBridgeServer(server, s.Role) + //pb.RegisterUserServiceBridgeServer(server, s.User) + //pb.RegisterPermissionServiceBridgeServer(server, s.Permission) +} + +func NewRegisterBridgeServer(r runtime.Runtime, + Auth pb.AuthServiceServer, + Casbin pb.CasbinSourceServiceServer, + Login pb.LoginServiceServer, + Personal pb.PersonalServiceServer, +) *RegisterBridgeServer { + return &RegisterBridgeServer{ + Auth: NewAuthServiceHookedBridge(r, Auth), + Casbin: NewCasbinServiceHookedBridge(r, Casbin), + Login: NewLoginServiceHookedBridge(r, Login), + Personal: NewPersonalServiceHookedBridge(r, Personal), + } +} + var _ service.ServerRegistrar = (*RegisterServer)(nil) diff --git a/internal/mods/system/service/menu.bridge.go b/internal/mods/system/service/menu.bridge.go index c3c8b69b..24f384d0 100644 --- a/internal/mods/system/service/menu.bridge.go +++ b/internal/mods/system/service/menu.bridge.go @@ -77,7 +77,7 @@ func (h MenuServiceHookedBridge) CompleteUpdateMenu(ctx transhttp.Context, reque func NewMenuServiceHookedBridge(r runtime.Runtime, client pb.MenuServiceHTTPServer) pb.MenuServiceHookedBridger { return pb.WithMenuServiceHook(&MenuServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/menu")), + log: log.NewHelper(r.WithLogger("module", "service/system")), })(client) } diff --git a/internal/mods/system/service/menu.grpc.go b/internal/mods/system/service/menu.grpc.go index fa487bd6..8100b343 100644 --- a/internal/mods/system/service/menu.grpc.go +++ b/internal/mods/system/service/menu.grpc.go @@ -55,7 +55,7 @@ func NewMenuServiceServer(client pb.MenuServiceClient, logger log.KLogger) *Menu // NewMenuServiceServerPB new a menu service. func NewMenuServiceServerPB(r runtime.Runtime, client pb.MenuServiceClient) pb.MenuServiceServer { - return NewMenuServiceServer(client, r.WithLogger("module", "service/menu")) + return NewMenuServiceServer(client, r.WithLogger("module", "service/system")) } var _ pb.MenuServiceServer = (*MenuServiceServer)(nil) diff --git a/internal/mods/system/service/menu.http.go b/internal/mods/system/service/menu.http.go index 6c214465..1ee6e627 100644 --- a/internal/mods/system/service/menu.http.go +++ b/internal/mods/system/service/menu.http.go @@ -55,7 +55,7 @@ func NewMenuServiceHTTPServer(client pb.MenuServiceHTTPClient, logger log.KLogge // NewMenuServiceHTTPServerPB new a menu service. func NewMenuServiceHTTPServerPB(r runtime.Runtime, client pb.MenuServiceHTTPClient) pb.MenuServiceHTTPServer { - return NewMenuServiceHTTPServer(client, r.WithLogger("module", "service/menu")) + return NewMenuServiceHTTPServer(client, r.WithLogger("module", "service/system")) } var _ pb.MenuServiceServer = (*MenuServiceHTTPServer)(nil) diff --git a/internal/mods/system/service/permission.bridge.go b/internal/mods/system/service/permission.bridge.go index 3a27a931..0e4dfcca 100644 --- a/internal/mods/system/service/permission.bridge.go +++ b/internal/mods/system/service/permission.bridge.go @@ -80,7 +80,7 @@ func (h PermissionServiceHookedBridge) CompleteUpdatePermission(ctx transhttp.Co func NewPermissionServiceHookedBridge(r runtime.Runtime, client pb.PermissionServiceHTTPServer) pb.PermissionServiceHookedBridger { return pb.WithPermissionServiceHook(&PermissionServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/permission")), + log: log.NewHelper(r.WithLogger("module", "service/system")), })(client) } diff --git a/internal/mods/system/service/permission.grpc.go b/internal/mods/system/service/permission.grpc.go index 6469f8d6..5a4d716c 100644 --- a/internal/mods/system/service/permission.grpc.go +++ b/internal/mods/system/service/permission.grpc.go @@ -49,7 +49,7 @@ func (s PermissionServiceServer) DeletePermission(ctx context.Context, request * // NewPermissionServiceServer new a menu service. func NewPermissionServiceServer(r runtime.Runtime, client *biz.PermissionServiceBiz) *PermissionServiceServer { return &PermissionServiceServer{ - log: log.NewHelper(r.WithLogger("module", "service/permission")), + log: log.NewHelper(r.WithLogger("module", "service/system")), client: client, } } diff --git a/internal/mods/system/service/permission.http.go b/internal/mods/system/service/permission.http.go index b194006f..e16657f0 100644 --- a/internal/mods/system/service/permission.http.go +++ b/internal/mods/system/service/permission.http.go @@ -42,7 +42,7 @@ func (s PermissionServiceHTTPServer) UpdatePermission(ctx context.Context, reque // NewPermissionServiceHTTPServer new a menu service. func NewPermissionServiceHTTPServer(r runtime.Runtime, client *biz.PermissionServiceBiz) *PermissionServiceHTTPServer { return &PermissionServiceHTTPServer{ - log: log.NewHelper(r.WithLogger("module", "service/permission")), + log: log.NewHelper(r.WithLogger("module", "service/system")), client: client, } } diff --git a/internal/mods/system/service/resource.bridge.go b/internal/mods/system/service/resource.bridge.go index 26aedea2..35cf41b6 100644 --- a/internal/mods/system/service/resource.bridge.go +++ b/internal/mods/system/service/resource.bridge.go @@ -80,7 +80,7 @@ func (h ResourceServiceHookedBridge) CompleteUpdateResource(ctx transhttp.Contex func NewResourceServiceHookedBridge(r runtime.Runtime, client pb.ResourceServiceHTTPServer) pb.ResourceServiceHookedBridger { return pb.WithResourceServiceHook(&ResourceServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/resource")), + log: log.NewHelper(r.WithLogger("module", "service/system")), })(client) } diff --git a/internal/mods/system/service/resource.grpc.go b/internal/mods/system/service/resource.grpc.go index ac3f22a1..dc570f60 100644 --- a/internal/mods/system/service/resource.grpc.go +++ b/internal/mods/system/service/resource.grpc.go @@ -48,7 +48,7 @@ func (s ResourceServiceServer) DeleteResource(ctx context.Context, request *pb.D // NewResourceServiceServer new a menu service. func NewResourceServiceServer(r runtime.Runtime, client *biz.ResourceServiceBiz) *ResourceServiceServer { return &ResourceServiceServer{ - log: log.NewHelper(r.WithLogger("module", "service/resource")), + log: log.NewHelper(r.WithLogger("module", "service/system")), client: client, } } diff --git a/internal/mods/system/service/role.bridge.go b/internal/mods/system/service/role.bridge.go index 009966ba..e60832f7 100644 --- a/internal/mods/system/service/role.bridge.go +++ b/internal/mods/system/service/role.bridge.go @@ -80,7 +80,7 @@ func (h RoleServiceHookedBridge) CompleteUpdateRole(ctx transhttp.Context, reque func NewRoleServiceHookedBridge(r runtime.Runtime, client pb.RoleServiceHTTPServer) pb.RoleServiceHookedBridger { return pb.WithRoleServiceHook(&RoleServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/permission")), + log: log.NewHelper(r.WithLogger("module", "service/system")), })(client) } diff --git a/internal/mods/system/service/role.grpc.go b/internal/mods/system/service/role.grpc.go index df9c3917..8bc01690 100644 --- a/internal/mods/system/service/role.grpc.go +++ b/internal/mods/system/service/role.grpc.go @@ -41,7 +41,7 @@ func (s RoleServiceServer) DeleteRole(ctx context.Context, req *pb.DeleteRoleReq func NewRoleServiceServer(r runtime.Runtime, client *biz.RoleServiceBiz) *RoleServiceServer { return &RoleServiceServer{ log: log.NewHelper(r.WithLogger( - "module", "service/role", + "module", "service/system", )), client: client, } diff --git a/internal/mods/system/service/service.go b/internal/mods/system/service/service.go index 84bec40a..4aea6731 100644 --- a/internal/mods/system/service/service.go +++ b/internal/mods/system/service/service.go @@ -8,6 +8,7 @@ import ( "context" "github.com/google/wire" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -27,8 +28,21 @@ var ProviderSet = wire.NewSet( NewPermissionServiceHTTPServerPB, ) +// LocalProviderSet is service providers. +var LocalProviderSet = wire.NewSet( + NewRegisterBridgeServer, + NewResourceServiceServerPB, + NewResourceServiceHTTPServerPB, + NewRoleServiceServerPB, + NewRoleServiceHTTPServerPB, + NewUserServiceServerPB, + NewUserServiceHTTPServerPB, + NewPermissionServiceServerPB, + NewPermissionServiceHTTPServerPB, +) + var RemoteProviderSet = wire.NewSet( - NewRegisterServer, + NewRegisterBridgeServer, NewResourceServiceBridgeClient, //NewResourceServiceBridge, NewRoleServiceBridgeClient, @@ -85,4 +99,50 @@ func NewRegisterServer( } } +type RegisterBridgeServer struct { + Resource pb.ResourceServiceHookedBridger + Role pb.RoleServiceHookedBridger + User pb.UserServiceHookedBridger + Permission pb.PermissionServiceHookedBridger +} + +func (s RegisterBridgeServer) Register(ctx context.Context, svc any) { + switch v := svc.(type) { + case *service.GRPCServer: + s.RegisterGRPC(ctx, v) + case *service.HTTPServer: + s.RegisterHTTP(ctx, v) + } +} + +func (s RegisterBridgeServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { + log.Info("http server system init") + pb.RegisterResourceServiceBridgeServer(server, s.Resource) + pb.RegisterRoleServiceBridgeServer(server, s.Role) + pb.RegisterUserServiceBridgeServer(server, s.User) + pb.RegisterPermissionServiceBridgeServer(server, s.Permission) +} + +func (s RegisterBridgeServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { + log.Info("grpc server system init") + //pb.RegisterResourceServiceBridgeServer(server, s.Resource) + //pb.RegisterRoleServiceBridgeServer(server, s.Role) + //pb.RegisterUserServiceBridgeServer(server, s.User) + //pb.RegisterPermissionServiceBridgeServer(server, s.Permission) +} + +func NewRegisterBridgeServer(r runtime.Runtime, + Resource pb.ResourceServiceServer, + Role pb.RoleServiceServer, + User pb.UserServiceServer, + Permission pb.PermissionServiceServer, +) *RegisterBridgeServer { + return &RegisterBridgeServer{ + Resource: NewResourceServiceHookedBridge(r, Resource), + Role: NewRoleServiceHookedBridge(r, Role), + User: NewUserServiceHookedBridge(r, User), + Permission: NewPermissionServiceHookedBridge(r, Permission), + } +} + var _ service.ServerRegistrar = (*RegisterServer)(nil) diff --git a/internal/mods/system/service/user.bridge.go b/internal/mods/system/service/user.bridge.go index d85dd80e..530b4200 100644 --- a/internal/mods/system/service/user.bridge.go +++ b/internal/mods/system/service/user.bridge.go @@ -78,9 +78,9 @@ func (h UserServiceHookedBridge) CompleteUpdateUser(ctx transhttp.Context, reque }) } -func NewUserServiceHookedBridge(r runtime.Runtime, client pb.UserServiceBridger) pb.UserServiceHookedBridger { +func NewUserServiceHookedBridge(r runtime.Runtime, client pb.UserServiceHTTPServer) pb.UserServiceHookedBridger { return pb.WithUserServiceHook(&UserServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/permission")), + log: log.NewHelper(r.WithLogger("module", "service/system")), })(client) } diff --git a/internal/mods/system/service/user.grpc.go b/internal/mods/system/service/user.grpc.go index 00b617b3..9a50871e 100644 --- a/internal/mods/system/service/user.grpc.go +++ b/internal/mods/system/service/user.grpc.go @@ -69,7 +69,7 @@ func (s UserServiceServer) DeleteUser(ctx context.Context, req *pb.DeleteUserReq func NewUserServiceServer(r runtime.Runtime, client *biz.UserServiceBiz) *UserServiceServer { return &UserServiceServer{ log: log.NewHelper(r.WithLogger( - "module", "service/user", + "module", "service/system", )), client: client, } diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 32c87bed..647200d3 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -306,6 +306,48 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' + /auth/resources: + get: + tags: + - AuthService + description: ListAuthResources returns a list of Auths. + operationId: AuthService_ListAuthResources + parameters: + - name: page_size + in: query + description: The maximum number of Auths to return. + schema: + type: integer + format: int32 + - name: page_token + in: query + description: The next_page_token value returned from a previous List request, if any. + schema: + type: string + - name: current + in: query + description: The current page number. + schema: + type: integer + format: int32 + - name: no_paging + in: query + description: The no_paging is used to disable pagination. + schema: + type: boolean + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.ListAuthResourcesResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' /auth/token: post: tags: @@ -331,6 +373,30 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' + /auth/validate: + get: + tags: + - AuthService + description: ValidateToken verifies the validity of a JWT token. + operationId: AuthService_ValidateToken + parameters: + - name: token + in: query + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.ValidateTokenResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' /captcha: get: tags: @@ -661,72 +727,6 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/auth/resources: - get: - tags: - - AuthService - description: ListAuthResources returns a list of Auths. - operationId: AuthService_ListAuthResources - parameters: - - name: page_size - in: query - description: The maximum number of Auths to return. - schema: - type: integer - format: int32 - - name: page_token - in: query - description: The next_page_token value returned from a previous List request, if any. - schema: - type: string - - name: current - in: query - description: The current page number. - schema: - type: integer - format: int32 - - name: no_paging - in: query - description: The no_paging is used to disable pagination. - schema: - type: boolean - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.ListAuthResourcesResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /sys/auth/validate: - get: - tags: - - AuthService - description: ValidateToken verifies the validity of a JWT token. - operationId: AuthService_ValidateToken - parameters: - - name: token - in: query - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.ValidateTokenResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' /sys/departments: get: tags: From 62664a84458806b0eb3f83c24deae12e6555db00 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 10 Jun 2025 16:31:12 +0800 Subject: [PATCH 041/158] refactor(admin): update service layer and introduce new concepts - Rename and restructure service providers for authentication and system modules - Introduce SystemServerRegistrar and AuthServerRegistrar types - Update wire.go and wire_gen.go to use new provider sets and registrar types - Modify helpers/resp to support JSON marshaling of protocol buffers - Update logging in casbin_stream.biz.go - Refactor authentication and login handlers to use new response structures - Update personal service to include new ListPersonalResources method - Standardize response handling across all services - Update database template for consistency --- cmd/internal/start/wire.go | 2 +- cmd/internal/start/wire_gen.go | 12 ++-- helpers/resp/marshal.go | 16 +++++ helpers/resp/result.go | 21 ++++--- internal/loader/load.go | 4 +- internal/mods/auth/biz/casbin_stream.biz.go | 12 ++-- internal/mods/auth/service/auth.bridge.go | 24 ++++---- internal/mods/auth/service/login.bridge.go | 58 ++++++++++--------- internal/mods/auth/service/personal.bridge.go | 49 +++++++++++----- internal/mods/auth/service/service.go | 20 +++++-- internal/mods/system/service/menu.bridge.go | 18 ++++-- .../mods/system/service/permission.bridge.go | 21 ++++--- .../mods/system/service/resource.bridge.go | 21 ++++--- internal/mods/system/service/role.bridge.go | 21 ++++--- internal/mods/system/service/service.go | 6 +- internal/mods/system/service/user.bridge.go | 21 ++++--- 16 files changed, 207 insertions(+), 119 deletions(-) diff --git a/cmd/internal/start/wire.go b/cmd/internal/start/wire.go index 4fe4007b..b6db8d6f 100644 --- a/cmd/internal/start/wire.go +++ b/cmd/internal/start/wire.go @@ -36,7 +36,7 @@ func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*krat //systemserver.ProviderSet, authdal.ProviderSet, authbiz.ProviderSet, - authservice.ProviderSet, + authservice.LocalProviderSet, NewApp)) } diff --git a/cmd/internal/start/wire_gen.go b/cmd/internal/start/wire_gen.go index 77fd03ee..8129e130 100644 --- a/cmd/internal/start/wire_gen.go +++ b/cmd/internal/start/wire_gen.go @@ -46,7 +46,7 @@ func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*krat permissionRepo := dal.NewPermissionRepo(r, dataData) permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) permissionServiceServer := service.NewPermissionServiceServerPB(r, permissionServiceBiz) - registerServer := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + systemServerRegistrar := service.NewRegisterBridgeServer(r, resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) authRepo := dal2.NewAuthRepo(r, dataData) authServiceBiz := biz2.NewAuthServiceBiz(r, authRepo) authServiceServer := service2.NewAuthServiceServerPB(authServiceBiz) @@ -70,8 +70,8 @@ func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*krat personalRepo := dal2.NewPersonalRepo(r, dataData) personalServiceBiz := biz2.NewPersonalServiceBiz(r, personalRepo) personalServiceServer := service2.NewPersonalServiceServerPB(r, personalServiceBiz) - serviceRegisterServer := service2.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) - v := loader.NewServiceServerRegistrars(registerServer, serviceRegisterServer) + authServerRegistrar := service2.NewRegisterBridgeServer(r, authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) + v := loader.NewServiceServerRegistrars(systemServerRegistrar, authServerRegistrar) ruleSource := service2.NewCasbinSourceBiz(r, casbinSourceServiceBiz) proxyOptions, err := loader.NewProxyOptions(r, bootstrap, ruleSource) if err != nil { @@ -91,13 +91,13 @@ func buildRemoteInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kra roleServiceServer := service.NewRoleServiceBridgeClient(r, v) userServiceServer := service.NewUserServiceBridgeClient(r, v) permissionServiceServer := service.NewPermissionServiceBridgeClient(r, v) - registerServer := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + systemServerRegistrar := service.NewRegisterBridgeServer(r, resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) authServiceServer := service2.NewAuthServiceBridgeClient(r, v) casbinSourceServiceServer := service2.NewCasbinServiceBridgeClient(r, v) loginServiceServer := service2.NewLoginServiceBridgeClient(r, v) personalServiceServer := service2.NewPersonalServiceBridgeClient(r, v) - serviceRegisterServer := service2.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) - v2 := loader.NewServiceServerRegistrars(registerServer, serviceRegisterServer) + authServerRegistrar := service2.NewRegisterBridgeServer(r, authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) + v2 := loader.NewServiceServerRegistrars(systemServerRegistrar, authServerRegistrar) ruleSource := service2.NewCasbinSourceClient(r, v) proxyOptions, err := loader.NewProxyOptions(r, bootstrap, ruleSource) if err != nil { diff --git a/helpers/resp/marshal.go b/helpers/resp/marshal.go index 39698da6..97e8ca6a 100644 --- a/helpers/resp/marshal.go +++ b/helpers/resp/marshal.go @@ -122,3 +122,19 @@ func Proto2JSONArray[T proto.Message](msgs ...T) ([]json.RawMessage, error) { } return arr, nil } + +func Proto2JSON[T proto.Message](msgs ...T) (json.RawMessage, error) { + var arr []json.RawMessage + for _, msg := range msgs { + b, err := protojson.Marshal(msg) + if err != nil { + return nil, err + } + arr = append(arr, b) + } + marshal, err := json.Marshal(arr) + if err != nil { + return nil, err + } + return marshal, nil +} diff --git a/helpers/resp/result.go b/helpers/resp/result.go index e5b2a1fb..4ebaf9ea 100644 --- a/helpers/resp/result.go +++ b/helpers/resp/result.go @@ -34,18 +34,21 @@ type Token = datav1.Token type StringResult = datav1.StringData type Result struct { - Success bool `json:"success,omitempty"` - Total int32 `json:"total,omitempty"` - Data any `json:"data,omitempty"` - Error *httperr.Error `json:"error,omitempty"` - Extra any `json:"extra,omitempty"` + Success bool `json:"success,omitempty"` + Total int32 `json:"total,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` + Data json.RawMessage `json:"data,omitempty"` + Extra json.RawMessage `json:"extra,omitempty"` + Error *httperr.Error `json:"error,omitempty"` } type ResultBytes struct { - Success bool `json:"success,omitempty"` - Data []byte `json:"data,omitempty"` - Error []byte `json:"error,omitempty"` - Extra []byte `json:"extra,omitempty"` + Success bool `json:"success,omitempty"` + Total int32 `json:"total,omitempty"` + NextPageToken *string `json:"next_page_token,omitempty"` + Data []byte `json:"data,omitempty"` + Error []byte `json:"error,omitempty"` + Extra []byte `json:"extra,omitempty"` } type PageResponse struct { diff --git a/internal/loader/load.go b/internal/loader/load.go index 4e586afd..84ad2e64 100644 --- a/internal/loader/load.go +++ b/internal/loader/load.go @@ -49,8 +49,8 @@ var ( ) func NewServiceServerRegistrars( - system *systemservice.RegisterServer, - auth *authservice.RegisterServer, + system systemservice.SystemServerRegistrar, + auth authservice.AuthServerRegistrar, ) []service.ServerRegistrar { return []service.ServerRegistrar{ system, diff --git a/internal/mods/auth/biz/casbin_stream.biz.go b/internal/mods/auth/biz/casbin_stream.biz.go index a86f248b..d595a591 100644 --- a/internal/mods/auth/biz/casbin_stream.biz.go +++ b/internal/mods/auth/biz/casbin_stream.biz.go @@ -27,14 +27,14 @@ type CasbinRuleStream struct { func (c CasbinRuleStream) Recv() (*pb.StreamRulesResponse, error) { select { case msg := <-c.receiver: - c.client.log.Infof("received message: %v", msg) + c.client.log.Debugf("received message: %v", msg) if msg == nil { - c.client.log.Info("stream closed") + c.client.log.Debugf("stream closed") return nil, io.EOF } return msg, nil case <-c.ctx.Done(): - c.client.log.Info("no message received") + c.client.log.Debugf("no message received") return nil, c.ctx.Err() } } @@ -65,13 +65,13 @@ func (c CasbinRuleStream) RecvMsg(m any) error { func (c CasbinRuleStream) Start(request *pb.StreamRulesRequest) error { defer close(c.receiver) - c.client.log.Infof("sending request: %v", request) + //c.client.log.Infof("sending request: %v", request) if request.WithPolicies { policies, err := c.client.ListPolicies(c.ctx, &pb.ListPoliciesRequest{}) if err != nil { return err } - c.client.log.Infof("sending %d policies", len(policies.Rules)) + //c.client.log.Infof("sending %d policies", len(policies.Rules)) for _, rule := range policies.Rules { c.receiver <- newPolicyResponse(rule) } @@ -82,7 +82,7 @@ func (c CasbinRuleStream) Start(request *pb.StreamRulesRequest) error { if err != nil { return err } - c.client.log.Infof("sending %d groupings", len(groupings.Rules)) + //c.client.log.Infof("sending %d groupings", len(groupings.Rules)) for _, grouping := range groupings.Rules { c.receiver <- newGroupingResponse(grouping) } diff --git a/internal/mods/auth/service/auth.bridge.go b/internal/mods/auth/service/auth.bridge.go index 324b2b2b..5a43582a 100644 --- a/internal/mods/auth/service/auth.bridge.go +++ b/internal/mods/auth/service/auth.bridge.go @@ -29,61 +29,61 @@ type AuthServiceHookedBridge struct { log *log.KHelper } -func (s AuthServiceHookedBridge) PrepareAuthLogout(h transhttp.Context, request *pb.AuthLogoutRequest) (context2.Context, error) { +func (s AuthServiceHookedBridge) PrepareAuthLogout(ctx transhttp.Context, request *pb.AuthLogoutRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) CompleteAuthLogout(h transhttp.Context, request *pb.AuthLogoutRequest, response *pb.AuthLogoutResponse) error { +func (s AuthServiceHookedBridge) CompleteAuthLogout(ctx transhttp.Context, request *pb.AuthLogoutRequest, response *pb.AuthLogoutResponse) error { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) CompleteAuthenticate(h transhttp.Context, request *pb.AuthenticateRequest, response *pb.AuthenticateResponse) error { +func (s AuthServiceHookedBridge) CompleteAuthenticate(ctx transhttp.Context, request *pb.AuthenticateRequest, response *pb.AuthenticateResponse) error { if !response.IsValid { return ErrorInvalidToken } - return h.JSON(http.StatusOK, &resp.Result{ + return ctx.JSON(http.StatusOK, &resp.Result{ Success: true, }) } -func (s AuthServiceHookedBridge) PrepareCreateToken(h transhttp.Context, request *pb.CreateTokenRequest) (context2.Context, error) { +func (s AuthServiceHookedBridge) PrepareCreateToken(ctx transhttp.Context, request *pb.CreateTokenRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) CompleteCreateToken(h transhttp.Context, request *pb.CreateTokenRequest, response *pb.CreateTokenResponse) error { +func (s AuthServiceHookedBridge) CompleteCreateToken(ctx transhttp.Context, request *pb.CreateTokenRequest, response *pb.CreateTokenResponse) error { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) PrepareDestroyToken(h transhttp.Context, request *pb.DestroyTokenRequest) (context2.Context, error) { +func (s AuthServiceHookedBridge) PrepareDestroyToken(ctx transhttp.Context, request *pb.DestroyTokenRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) CompleteDestroyToken(h transhttp.Context, request *pb.DestroyTokenRequest, response *pb.DestroyTokenResponse) error { +func (s AuthServiceHookedBridge) CompleteDestroyToken(ctx transhttp.Context, request *pb.DestroyTokenRequest, response *pb.DestroyTokenResponse) error { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) PrepareListAuthResources(h transhttp.Context, request *pb.ListAuthResourcesRequest) (context2.Context, error) { +func (s AuthServiceHookedBridge) PrepareListAuthResources(ctx transhttp.Context, request *pb.ListAuthResourcesRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) CompleteListAuthResources(h transhttp.Context, request *pb.ListAuthResourcesRequest, response *pb.ListAuthResourcesResponse) error { +func (s AuthServiceHookedBridge) CompleteListAuthResources(ctx transhttp.Context, request *pb.ListAuthResourcesRequest, response *pb.ListAuthResourcesResponse) error { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) PrepareValidateToken(h transhttp.Context, request *pb.ValidateTokenRequest) (context2.Context, error) { +func (s AuthServiceHookedBridge) PrepareValidateToken(ctx transhttp.Context, request *pb.ValidateTokenRequest) (context2.Context, error) { //TODO implement me panic("implement me") } -func (s AuthServiceHookedBridge) CompleteValidateToken(h transhttp.Context, request *pb.ValidateTokenRequest, response *pb.ValidateTokenResponse) error { +func (s AuthServiceHookedBridge) CompleteValidateToken(ctx transhttp.Context, request *pb.ValidateTokenRequest, response *pb.ValidateTokenResponse) error { //TODO implement me panic("implement me") } diff --git a/internal/mods/auth/service/login.bridge.go b/internal/mods/auth/service/login.bridge.go index b2ce13b8..400bb8e0 100644 --- a/internal/mods/auth/service/login.bridge.go +++ b/internal/mods/auth/service/login.bridge.go @@ -5,13 +5,14 @@ package service import ( - context2 "context" + "context" "net/http" transhttp "github.com/go-kratos/kratos/v2/transport/http" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" + "google.golang.org/protobuf/encoding/protojson" pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/helpers/resp" @@ -23,36 +24,40 @@ type LoginServiceHookedBridge struct { log *log.KHelper } -func (s LoginServiceHookedBridge) CompleteCaptcha(h transhttp.Context, request *pb.CaptchaRequest, response *pb.CaptchaResponse) error { - return h.JSON(http.StatusOK, &resp.Data{ +func (s LoginServiceHookedBridge) CompleteCaptcha(ctx transhttp.Context, request *pb.CaptchaRequest, response *pb.CaptchaResponse) error { + marshal, err := protojson.Marshal(response) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.Result{ Success: true, - Data: resp.Proto2Any(response), + Data: marshal, }) } -func (s LoginServiceHookedBridge) CompleteCaptchaAudio(h transhttp.Context, request *pb.CaptchaAudioRequest, response *pb.CaptchaAudioResponse) error { - return h.JSON(http.StatusOK, &resp.Data{ +func (s LoginServiceHookedBridge) CompleteCaptchaAudio(ctx transhttp.Context, request *pb.CaptchaAudioRequest, response *pb.CaptchaAudioResponse) error { + return ctx.JSON(http.StatusOK, &resp.Data{ Success: true, Data: resp.Proto2Any(response), }) } -func (s LoginServiceHookedBridge) CompleteCaptchaId(h transhttp.Context, request *pb.CaptchaIdRequest, response *pb.CaptchaIdResponse) error { - return h.JSON(http.StatusOK, &resp.Data{ +func (s LoginServiceHookedBridge) CompleteCaptchaId(ctx transhttp.Context, request *pb.CaptchaIdRequest, response *pb.CaptchaIdResponse) error { + return ctx.JSON(http.StatusOK, &resp.Data{ Success: true, Data: resp.Proto2Any(response), }) } -func (s LoginServiceHookedBridge) CompleteCaptchaImage(h transhttp.Context, request *pb.CaptchaImageRequest, response *pb.CaptchaImageResponse) error { +func (s LoginServiceHookedBridge) CompleteCaptchaImage(ctx transhttp.Context, request *pb.CaptchaImageRequest, response *pb.CaptchaImageResponse) error { s.log.Debugf("CaptchaImage: Setting headers: %+v", response.Headers) for k, v := range response.Headers { - h.Response().Header().Set(k, v) + ctx.Response().Header().Set(k, v) } s.log.Debugf("CaptchaImage: Writing response headers") - h.Response().WriteHeader(http.StatusOK) + ctx.Response().WriteHeader(http.StatusOK) s.log.Debugf("CaptchaImage: Writing response image") - if _, err := h.Response().Write(response.Image); err != nil { + if _, err := ctx.Response().Write(response.Image); err != nil { log.Errorf("CaptchaImage error writing response: %v", err) return err } @@ -60,38 +65,39 @@ func (s LoginServiceHookedBridge) CompleteCaptchaImage(h transhttp.Context, requ return nil } -func (s LoginServiceHookedBridge) PrepareLogin(h transhttp.Context, request *pb.LoginRequest) (context2.Context, error) { - //TODO implement me - panic("implement me") -} - -func (s LoginServiceHookedBridge) CompleteLogin(h transhttp.Context, request *pb.LoginRequest, response *pb.LoginResponse) error { - //TODO implement me - panic("implement me") +func (s LoginServiceHookedBridge) CompleteLogin(ctx transhttp.Context, request *pb.LoginRequest, response *pb.LoginResponse) error { + marshal, err := protojson.Marshal(resp.FromToken(response.Token)) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + }) } -func (s LoginServiceHookedBridge) PrepareLogout(h transhttp.Context, request *pb.LogoutRequest) (context2.Context, error) { +func (s LoginServiceHookedBridge) PrepareLogout(ctx transhttp.Context, request *pb.LogoutRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (s LoginServiceHookedBridge) CompleteLogout(h transhttp.Context, request *pb.LogoutRequest, response *pb.LogoutResponse) error { +func (s LoginServiceHookedBridge) CompleteLogout(ctx transhttp.Context, request *pb.LogoutRequest, response *pb.LogoutResponse) error { //TODO implement me panic("implement me") } -func (s LoginServiceHookedBridge) PrepareRegister(h transhttp.Context, request *pb.RegisterRequest) (context2.Context, error) { +func (s LoginServiceHookedBridge) PrepareRegister(ctx transhttp.Context, request *pb.RegisterRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (s LoginServiceHookedBridge) CompleteRegister(h transhttp.Context, request *pb.RegisterRequest, response *pb.RegisterResponse) error { +func (s LoginServiceHookedBridge) CompleteRegister(ctx transhttp.Context, request *pb.RegisterRequest, response *pb.RegisterResponse) error { //TODO implement me panic("implement me") } -func (s LoginServiceHookedBridge) CompleteTokenRefresh(h transhttp.Context, request *pb.TokenRefreshRequest, response *pb.TokenRefreshResponse) error { - return h.JSON(http.StatusOK, &resp.Data{ +func (s LoginServiceHookedBridge) CompleteTokenRefresh(ctx transhttp.Context, request *pb.TokenRefreshRequest, response *pb.TokenRefreshResponse) error { + return ctx.JSON(http.StatusOK, &resp.Data{ Success: true, Data: resp.Proto2Any(resp.FromToken(response.Token)), }) diff --git a/internal/mods/auth/service/personal.bridge.go b/internal/mods/auth/service/personal.bridge.go index 04aa97c5..21fbd257 100644 --- a/internal/mods/auth/service/personal.bridge.go +++ b/internal/mods/auth/service/personal.bridge.go @@ -6,13 +6,16 @@ package service import ( "context" + "net/http" transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/helpers/resp" ) // PersonalServiceHookedBridge is a menu service. @@ -22,72 +25,90 @@ type PersonalServiceHookedBridge struct { log *log.KHelper } -func (p PersonalServiceHookedBridge) PrepareGetPersonalProfile(context transhttp.Context, request *pb.GetPersonalProfileRequest) (context.Context, error) { +//func (p PersonalServiceHookedBridge) PrepareListPersonalResources(ctx transhttp.Context, request *pb.ListPersonalResourcesRequest) (context.Context, error) { +// //TODO implement me +// panic("implement me") +//} + +func (p PersonalServiceHookedBridge) CompleteListPersonalResources(ctx transhttp.Context, request *pb.ListPersonalResourcesRequest, response *pb.ListPersonalResourcesResponse) error { + marshal, err := resp.Proto2JSON(response.Resources...) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: int32(response.TotalSize), + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), + }) +} + +func (p PersonalServiceHookedBridge) PrepareGetPersonalProfile(ctx transhttp.Context, request *pb.GetPersonalProfileRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) CompleteGetPersonalProfile(context transhttp.Context, request *pb.GetPersonalProfileRequest, response *pb.GetPersonalProfileResponse) error { +func (p PersonalServiceHookedBridge) CompleteGetPersonalProfile(ctx transhttp.Context, request *pb.GetPersonalProfileRequest, response *pb.GetPersonalProfileResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) PrepareListPersonalRoles(context transhttp.Context, request *pb.ListPersonalRolesRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareListPersonalRoles(ctx transhttp.Context, request *pb.ListPersonalRolesRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) CompleteListPersonalRoles(context transhttp.Context, request *pb.ListPersonalRolesRequest, response *pb.ListPersonalRolesResponse) error { +func (p PersonalServiceHookedBridge) CompleteListPersonalRoles(ctx transhttp.Context, request *pb.ListPersonalRolesRequest, response *pb.ListPersonalRolesResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) PreparePersonalLogout(context transhttp.Context, request *pb.PersonalLogoutRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PreparePersonalLogout(ctx transhttp.Context, request *pb.PersonalLogoutRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) CompletePersonalLogout(context transhttp.Context, request *pb.PersonalLogoutRequest, response *pb.PersonalLogoutResponse) error { +func (p PersonalServiceHookedBridge) CompletePersonalLogout(ctx transhttp.Context, request *pb.PersonalLogoutRequest, response *pb.PersonalLogoutResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) PrepareRefreshPersonalToken(context transhttp.Context, request *pb.RefreshPersonalTokenRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareRefreshPersonalToken(ctx transhttp.Context, request *pb.RefreshPersonalTokenRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) CompleteRefreshPersonalToken(context transhttp.Context, request *pb.RefreshPersonalTokenRequest, response *pb.RefreshPersonalTokenResponse) error { +func (p PersonalServiceHookedBridge) CompleteRefreshPersonalToken(ctx transhttp.Context, request *pb.RefreshPersonalTokenRequest, response *pb.RefreshPersonalTokenResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) PrepareUpdatePersonalPassword(context transhttp.Context, request *pb.UpdatePersonalPasswordRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareUpdatePersonalPassword(ctx transhttp.Context, request *pb.UpdatePersonalPasswordRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) CompleteUpdatePersonalPassword(context transhttp.Context, request *pb.UpdatePersonalPasswordRequest, response *pb.UpdatePersonalPasswordResponse) error { +func (p PersonalServiceHookedBridge) CompleteUpdatePersonalPassword(ctx transhttp.Context, request *pb.UpdatePersonalPasswordRequest, response *pb.UpdatePersonalPasswordResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) PrepareUpdatePersonalProfile(context transhttp.Context, request *pb.UpdatePersonalProfileRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareUpdatePersonalProfile(ctx transhttp.Context, request *pb.UpdatePersonalProfileRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) CompleteUpdatePersonalProfile(context transhttp.Context, request *pb.UpdatePersonalProfileRequest, response *pb.UpdatePersonalProfileResponse) error { +func (p PersonalServiceHookedBridge) CompleteUpdatePersonalProfile(ctx transhttp.Context, request *pb.UpdatePersonalProfileRequest, response *pb.UpdatePersonalProfileResponse) error { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) PrepareUpdatePersonalSetting(context transhttp.Context, request *pb.UpdatePersonalSettingRequest) (context.Context, error) { +func (p PersonalServiceHookedBridge) PrepareUpdatePersonalSetting(ctx transhttp.Context, request *pb.UpdatePersonalSettingRequest) (context.Context, error) { //TODO implement me panic("implement me") } -func (p PersonalServiceHookedBridge) CompleteUpdatePersonalSetting(context transhttp.Context, request *pb.UpdatePersonalSettingRequest, response *pb.UpdatePersonalSettingResponse) error { +func (p PersonalServiceHookedBridge) CompleteUpdatePersonalSetting(ctx transhttp.Context, request *pb.UpdatePersonalSettingRequest, response *pb.UpdatePersonalSettingResponse) error { //TODO implement me panic("implement me") } diff --git a/internal/mods/auth/service/service.go b/internal/mods/auth/service/service.go index f99afdfe..8ce40c1a 100644 --- a/internal/mods/auth/service/service.go +++ b/internal/mods/auth/service/service.go @@ -26,16 +26,28 @@ var ProviderSet = wire.NewSet( NewCasbinSourceBiz, ) +// LocalProviderSet is service providers. +var LocalProviderSet = wire.NewSet( + NewRegisterBridgeServer, + NewAuthServiceServerPB, + NewCasbinSourceServiceServerPB, + NewLoginServiceServerPB, + NewPersonalServiceServerPB, + NewPersonalServiceHTTPServerPB, + NewCasbinSourceBiz, +) + var RemoteProviderSet = wire.NewSet( - NewRegisterServer, + NewRegisterBridgeServer, NewAuthServiceBridgeClient, NewCasbinServiceBridgeClient, NewLoginServiceBridgeClient, NewPersonalServiceBridgeClient, NewCasbinSourceClient, - ) +type AuthServerRegistrar service.ServerRegistrar + type RegisterServer struct { Auth pb.AuthServiceServer Casbin pb.CasbinSourceServiceServer @@ -73,7 +85,7 @@ func NewRegisterServer( Casbin pb.CasbinSourceServiceServer, Login pb.LoginServiceServer, Personal pb.PersonalServiceServer, -) *RegisterServer { +) AuthServerRegistrar { return &RegisterServer{ Auth: Auth, Casbin: Casbin, @@ -119,7 +131,7 @@ func NewRegisterBridgeServer(r runtime.Runtime, Casbin pb.CasbinSourceServiceServer, Login pb.LoginServiceServer, Personal pb.PersonalServiceServer, -) *RegisterBridgeServer { +) AuthServerRegistrar { return &RegisterBridgeServer{ Auth: NewAuthServiceHookedBridge(r, Auth), Casbin: NewCasbinServiceHookedBridge(r, Casbin), diff --git a/internal/mods/system/service/menu.bridge.go b/internal/mods/system/service/menu.bridge.go index 24f384d0..a125a63b 100644 --- a/internal/mods/system/service/menu.bridge.go +++ b/internal/mods/system/service/menu.bridge.go @@ -9,6 +9,7 @@ import ( "net/http" transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -53,14 +54,21 @@ func (h MenuServiceHookedBridge) CompleteGetMenu(ctx transhttp.Context, request } func (h MenuServiceHookedBridge) CompleteListMenus(ctx transhttp.Context, request *pb.ListMenusRequest, response *pb.ListMenusResponse) error { - marshal, err := json.Marshal(response.Menus) + if response == nil { + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: false, + Data: nil, + }) + } + marshal, err := resp.Proto2JSON(response.Menus...) if err != nil { return err } - return ctx.JSON(http.StatusOK, &resp.SourcePage{ - Success: true, - Total: response.GetTotalSize(), - Data: marshal, + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: response.TotalSize, + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), }) } diff --git a/internal/mods/system/service/permission.bridge.go b/internal/mods/system/service/permission.bridge.go index 0e4dfcca..d575a36d 100644 --- a/internal/mods/system/service/permission.bridge.go +++ b/internal/mods/system/service/permission.bridge.go @@ -9,6 +9,7 @@ import ( "net/http" transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -53,17 +54,21 @@ func (h PermissionServiceHookedBridge) CompleteGetPermission(ctx transhttp.Conte } func (h PermissionServiceHookedBridge) CompleteListPermissions(ctx transhttp.Context, request *pb.ListPermissionsRequest, response *pb.ListPermissionsResponse) error { - marshal, err := json.Marshal(response.Permissions) + if response == nil { + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: false, + Data: nil, + }) + } + marshal, err := resp.Proto2JSON(response.Permissions...) if err != nil { return err } - return ctx.JSON(http.StatusOK, &resp.SourcePage{ - Success: true, - Total: response.GetTotalSize(), - Data: marshal, - //Current: request.GetCurrent(), - //PageSize: nil, - //Extra: "", + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: response.TotalSize, + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), }) } diff --git a/internal/mods/system/service/resource.bridge.go b/internal/mods/system/service/resource.bridge.go index 35cf41b6..e24d35e0 100644 --- a/internal/mods/system/service/resource.bridge.go +++ b/internal/mods/system/service/resource.bridge.go @@ -9,6 +9,7 @@ import ( "net/http" transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -53,17 +54,21 @@ func (h ResourceServiceHookedBridge) CompleteGetResource(ctx transhttp.Context, } func (h ResourceServiceHookedBridge) CompleteListResources(ctx transhttp.Context, request *pb.ListResourcesRequest, response *pb.ListResourcesResponse) error { - marshal, err := json.Marshal(response.Resources) + if response == nil { + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: false, + Data: nil, + }) + } + marshal, err := resp.Proto2JSON(response.Resources...) if err != nil { return err } - return ctx.JSON(http.StatusOK, &resp.SourcePage{ - Success: true, - Total: response.GetTotalSize(), - Data: marshal, - //Current: request.GetCurrent(), - //PageSize: nil, - //Extra: "", + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: response.TotalSize, + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), }) } diff --git a/internal/mods/system/service/role.bridge.go b/internal/mods/system/service/role.bridge.go index e60832f7..1e55304c 100644 --- a/internal/mods/system/service/role.bridge.go +++ b/internal/mods/system/service/role.bridge.go @@ -9,6 +9,7 @@ import ( "net/http" transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -53,17 +54,21 @@ func (h RoleServiceHookedBridge) CompleteGetRole(ctx transhttp.Context, request } func (h RoleServiceHookedBridge) CompleteListRoles(ctx transhttp.Context, request *pb.ListRolesRequest, response *pb.ListRolesResponse) error { - marshal, err := json.Marshal(response.Roles) + if response == nil { + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: false, + Data: nil, + }) + } + marshal, err := resp.Proto2JSON(response.Roles...) if err != nil { return err } - return ctx.JSON(http.StatusOK, &resp.SourcePage{ - Success: true, - Total: response.GetTotalSize(), - Data: marshal, - //Current: request.GetCurrent(), - //PageSize: nil, - //Extra: "", + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: response.TotalSize, + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), }) } diff --git a/internal/mods/system/service/service.go b/internal/mods/system/service/service.go index 4aea6731..c153a798 100644 --- a/internal/mods/system/service/service.go +++ b/internal/mods/system/service/service.go @@ -53,6 +53,8 @@ var RemoteProviderSet = wire.NewSet( //NewPermissionServiceBridge, ) +type SystemServerRegistrar service.ServerRegistrar + type RegisterServer struct { Resource pb.ResourceServiceServer Role pb.RoleServiceServer @@ -90,7 +92,7 @@ func NewRegisterServer( Role pb.RoleServiceServer, User pb.UserServiceServer, Permission pb.PermissionServiceServer, -) *RegisterServer { +) SystemServerRegistrar { return &RegisterServer{ Resource: Resource, Role: Role, @@ -136,7 +138,7 @@ func NewRegisterBridgeServer(r runtime.Runtime, Role pb.RoleServiceServer, User pb.UserServiceServer, Permission pb.PermissionServiceServer, -) *RegisterBridgeServer { +) SystemServerRegistrar { return &RegisterBridgeServer{ Resource: NewResourceServiceHookedBridge(r, Resource), Role: NewRoleServiceHookedBridge(r, Role), diff --git a/internal/mods/system/service/user.bridge.go b/internal/mods/system/service/user.bridge.go index 530b4200..b06a7663 100644 --- a/internal/mods/system/service/user.bridge.go +++ b/internal/mods/system/service/user.bridge.go @@ -9,6 +9,7 @@ import ( "net/http" transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -53,17 +54,21 @@ func (h UserServiceHookedBridge) CompleteGetUser(ctx transhttp.Context, request } func (h UserServiceHookedBridge) CompleteListUsers(ctx transhttp.Context, request *pb.ListUsersRequest, response *pb.ListUsersResponse) error { - marshal, err := json.Marshal(response.Users) + if response == nil { + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: false, + Data: nil, + }) + } + marshal, err := resp.Proto2JSON(response.Users...) if err != nil { return err } - return ctx.JSON(http.StatusOK, &resp.SourcePage{ - Success: true, - Total: response.GetTotalSize(), - Data: marshal, - //Current: request.GetCurrent(), - //PageSize: nil, - //Extra: "", + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: response.TotalSize, + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), }) } From 194ed89841482c2b1a3831f5730186f189cc4edd Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 10 Jun 2025 17:05:15 +0800 Subject: [PATCH 042/158] fix(internal): fix proxy client initialization and update casbin service - Add logging for proxy client initialization - Fix client map key usage in NewProxyGRPCClients - Refactor CasbinSourceClient initialization - Update HTTP server interface for CasbinSourceService - Add HTTP server implementations for auth services --- internal/loader/proxy.go | 7 +++++-- internal/mods/auth/service/casbin.go | 18 +++++++++++------- internal/mods/auth/service/casbin.http.go | 2 +- internal/mods/auth/service/service.go | 6 ++++++ resources/configs/admin/bootstrap.toml | 2 +- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/internal/loader/proxy.go b/internal/loader/proxy.go index 96eb171d..14d8c9f0 100644 --- a/internal/loader/proxy.go +++ b/internal/loader/proxy.go @@ -158,6 +158,7 @@ func CorsMiddleware() middleware.KMiddleware { func NewProxyGRPCClients(r runtime.Runtime, bootstrap *configs.Bootstrap) map[string]*service.GRPCClient { ll := log.NewHelper(r.WithLogger("module", "proxy")) + ll.Infof("NewProxyGRPCClients bootstrap: %+v", bootstrap) clients := bootstrap.GetClients() clientServices := make(map[string]*service.GRPCClient, len(clients)) for i := range clients { @@ -165,6 +166,7 @@ func NewProxyGRPCClients(r runtime.Runtime, bootstrap *configs.Bootstrap) map[st if len(services) == 0 { continue } + ll.Infof("NewProxyGRPCClients: %+v", clients[i].GetCore().GetName()) var options []service.GRPCOption discovery, err := r.Builder().NewDiscovery(clients[i].GetCore().GetDiscovery()) if err == nil { @@ -178,7 +180,8 @@ func NewProxyGRPCClients(r runtime.Runtime, bootstrap *configs.Bootstrap) map[st ll.Warnf("NewGRPCClient failed: %v", err) continue } - clientServices[services[idx].GetName()] = client + ll.Infof("NewProxyGRPCClients: %+v", clients[i].GetCore().GetName()) + clientServices[clients[i].GetCore().GetName()] = client } } } @@ -206,7 +209,7 @@ func NewProxyHTTPClients(r runtime.Runtime, bootstrap *configs.Bootstrap) map[st ll.Warnf("NewHTTPClient failed: %v", err) continue } - clientServices[services[idx].GetName()] = client + clientServices[clients[i].GetCore().GetName()] = client } } } diff --git a/internal/mods/auth/service/casbin.go b/internal/mods/auth/service/casbin.go index 43f18ef2..1e1bba03 100644 --- a/internal/mods/auth/service/casbin.go +++ b/internal/mods/auth/service/casbin.go @@ -78,17 +78,21 @@ func (c CasbinSourceClient) StreamRules(ctx context.Context, in *pb.StreamRulesR // NewCasbinSourceClient new a menu service. func NewCasbinSourceClient(r runtime.Runtime, clients map[string]*service.GRPCClient) casbin.RuleSource { + ll := log.NewHelper(r.WithLogger("module", "service/casbin")) client, ok := clients["auth"] + c := NewUnimplementedCasbinSource(r) if ok { - return &CasbinSourceClient{ - client: pb.NewCasbinSourceServiceClient(client), - log: log.NewHelper(r.WithLogger("module", "service/casbin")), - } + c = pb.NewCasbinSourceServiceClient(client) } return &CasbinSourceClient{ - client: UnimplementedCasbinSource{ - log: log.NewHelper(r.WithLogger("module", "service/casbin")), - }, + client: c, + log: ll, + } +} + +func NewUnimplementedCasbinSource(r runtime.Runtime) pb.CasbinSourceServiceClient { + return UnimplementedCasbinSource{ + log: log.NewHelper(r.WithLogger("module", "service/casbin")), } } diff --git a/internal/mods/auth/service/casbin.http.go b/internal/mods/auth/service/casbin.http.go index 5aa321ca..aa8eccb1 100644 --- a/internal/mods/auth/service/casbin.http.go +++ b/internal/mods/auth/service/casbin.http.go @@ -37,7 +37,7 @@ func NewCasbinServiceHTTPServer(client pb.CasbinSourceServiceHTTPClient) *Casbin } // NewCasbinSourceServiceHTTPServerPB new a login service. -func NewCasbinSourceServiceHTTPServerPB(client pb.CasbinSourceServiceHTTPClient) pb.CasbinSourceServiceServer { +func NewCasbinSourceServiceHTTPServerPB(client pb.CasbinSourceServiceHTTPClient) pb.CasbinSourceServiceHTTPServer { return &CasbinSourceServiceHTTPServer{client: client} } diff --git a/internal/mods/auth/service/service.go b/internal/mods/auth/service/service.go index 8ce40c1a..d3346e34 100644 --- a/internal/mods/auth/service/service.go +++ b/internal/mods/auth/service/service.go @@ -19,8 +19,11 @@ import ( var ProviderSet = wire.NewSet( NewRegisterServer, NewAuthServiceServerPB, + NewAuthServiceHTTPServerPB, NewCasbinSourceServiceServerPB, + NewCasbinSourceServiceHTTPServerPB, NewLoginServiceServerPB, + NewLoginServiceHTTPServerPB, NewPersonalServiceServerPB, NewPersonalServiceHTTPServerPB, NewCasbinSourceBiz, @@ -30,8 +33,11 @@ var ProviderSet = wire.NewSet( var LocalProviderSet = wire.NewSet( NewRegisterBridgeServer, NewAuthServiceServerPB, + NewAuthServiceHTTPServerPB, NewCasbinSourceServiceServerPB, + NewCasbinSourceServiceHTTPServerPB, NewLoginServiceServerPB, + NewLoginServiceHTTPServerPB, NewPersonalServiceServerPB, NewPersonalServiceHTTPServerPB, NewCasbinSourceBiz, diff --git a/resources/configs/admin/bootstrap.toml b/resources/configs/admin/bootstrap.toml index e78882b0..febd59ef 100644 --- a/resources/configs/admin/bootstrap.toml +++ b/resources/configs/admin/bootstrap.toml @@ -1,7 +1,7 @@ Name = "origadmin.proxy.service.admin.v1" Version = "v1.0.0" CryptoType = "argon2" -Mode = "singleton" +Mode = "cluster" EnableDynamicConfig = false Id = "" Environment = "" From 88506d079e1e5ae6590802faf1982e4714fc009f Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 12 Jun 2025 19:15:17 +0800 Subject: [PATCH 043/158] feat(auth): add error handling and improve security features - Add error handling for authentication and authorization - Implement system and auth error reasons - Update JWT authentication logic - Adjust error response handling- Remove unused client context metadata retrieval --- api/v1/proto/auth/auth.proto | 2 + api/v1/services/auth/auth.pb.go | 6 +- api/v1/services/types/error.pb.go | 250 +++++++++++++++++ api/v1/services/types/error.pb.validate.go | 36 +++ api/v1/services/types/error_errors.pb.go | 276 +++++++++++++++++++ buf.gen.yaml | 1 + cmd/auth/main.go | 1 + cmd/internal/start/start.go | 1 + cmd/system/main.go | 1 + contrib/security/authn/jwt/jwt.go | 16 ++ contrib/security/authz/casbin/option.go | 2 +- go.mod | 17 +- go.sum | 30 ++ helpers/resp/error.go | 13 +- helpers/resp/resp.go | 2 + helpers/securityx/user.go | 6 +- internal/configs/service.pb.go | 26 +- internal/configs/service.pb.validate.go | 29 ++ internal/configs/service.proto | 1 + internal/loader/bootstrap_default.go | 12 +- internal/loader/proxy.go | 29 +- internal/loader/service_test.go | 73 +---- internal/mods/auth/dal/personal.dal.go | 4 + internal/mods/auth/server/server.go | 48 ++-- internal/mods/auth/service/login.bridge.go | 8 +- internal/mods/system/server/server.go | 42 +-- internal/mods/system/service/user.service.go | 25 -- resources/configs/admin/clients.toml | 114 ++------ resources/docs/openapi/openapi.yaml | 3 +- 29 files changed, 814 insertions(+), 260 deletions(-) create mode 100644 api/v1/services/types/error.pb.go create mode 100644 api/v1/services/types/error.pb.validate.go create mode 100644 api/v1/services/types/error_errors.pb.go delete mode 100644 internal/mods/system/service/user.service.go diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index ab4f0c57..a64e7ea0 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package api.v1.services.auth; import "google/api/annotations.proto"; +import "google/api/client.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; @@ -13,6 +14,7 @@ option java_package = "com.origadmin.api.v1.services.auth"; option objc_class_prefix = "APIServiceAuthAuth"; service AuthService { + option (google.api.default_host) = "api.foo.com"; // ListAuthResources returns a list of Auths. rpc ListAuthResources(ListAuthResourcesRequest) returns (ListAuthResourcesResponse) { option (google.api.http) = {get: "/auth/resources"}; diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index 79cee26f..db4d2099 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -816,7 +816,7 @@ var File_auth_auth_proto protoreflect.FileDescriptor const file_auth_auth_proto_rawDesc = "" + "\n" + - "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"s\n" + + "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"s\n" + "\x11AuthLogoutRequest\x12@\n" + "\x04data\x18\x01 \x01(\v2,.api.v1.services.auth.AuthLogoutRequest.DataR\x04data\x1a\x1c\n" + "\x04Data\x12\x14\n" + @@ -864,7 +864,7 @@ const file_auth_auth_proto_rawDesc = "" + "\x06method\x18\x04 \x01(\tR\x06method\x12\x1c\n" + "\toperation\x18\x05 \x01(\tR\toperation\"2\n" + "\x14AuthenticateResponse\x12\x1a\n" + - "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xab\x06\n" + + "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xbb\x06\n" + "\vAuthService\x12\x8d\x01\n" + "\x11ListAuthResources\x12..api.v1.services.auth.ListAuthResourcesRequest\x1a/.api.v1.services.auth.ListAuthResourcesResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/auth/resources\x12}\n" + "\vCreateToken\x12(.api.v1.services.auth.CreateTokenRequest\x1a).api.v1.services.auth.CreateTokenResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x04data\"\v/auth/token\x12\x80\x01\n" + @@ -872,7 +872,7 @@ const file_auth_auth_proto_rawDesc = "" + "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x04data\"\r/auth/destroy\x12\x87\x01\n" + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\" \x82\xd3\xe4\x93\x02\x1a:\x04data\"\x12/auth/authenticate\x12{\n" + "\n" + - "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x04data\"\f/auth/logoutB\xb4\x01\n" + + "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x04data\"\f/auth/logout\x1a\x0e\xcaA\vapi.foo.comB\xb4\x01\n" + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( diff --git a/api/v1/services/types/error.pb.go b/api/v1/services/types/error.pb.go new file mode 100644 index 00000000..da95d5a6 --- /dev/null +++ b/api/v1/services/types/error.pb.go @@ -0,0 +1,250 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc (unknown) +// source: types/error.proto + +package types + +import ( + _ "github.com/go-kratos/kratos/v2/errors" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SystemErrorReason int32 + +const ( + SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED SystemErrorReason = 0 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND SystemErrorReason = 2001 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS SystemErrorReason = 2002 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN SystemErrorReason = 2003 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT SystemErrorReason = 2004 + SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED SystemErrorReason = 2005 + SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND SystemErrorReason = 2006 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN SystemErrorReason = 2007 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS SystemErrorReason = 2008 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION SystemErrorReason = 2009 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION SystemErrorReason = 2010 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST SystemErrorReason = 2011 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE SystemErrorReason = 2012 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER SystemErrorReason = 2013 + SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND SystemErrorReason = 1001 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID SystemErrorReason = 1002 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE SystemErrorReason = 1003 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME SystemErrorReason = 1005 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD SystemErrorReason = 1006 +) + +// Enum value maps for SystemErrorReason. +var ( + SystemErrorReason_name = map[int32]string{ + 0: "SYSTEM_ERROR_REASON_UNSPECIFIED", + 2001: "SYSTEM_ERROR_REASON_USER_NOT_FOUND", + 2002: "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS", + 2003: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN", + 2004: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT", + 2005: "SYSTEM_ERROR_REASON_TOKEN_EXPIRED", + 2006: "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND", + 2007: "SYSTEM_ERROR_REASON_INVALID_TOKEN", + 2008: "SYSTEM_ERROR_REASON_INVALID_CLAIMS", + 2009: "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION", + 2010: "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION", + 2011: "SYSTEM_ERROR_REASON_INVALID_REQUEST", + 2012: "SYSTEM_ERROR_REASON_INVALID_RESPONSE", + 2013: "SYSTEM_ERROR_REASON_INVALID_SERVER", + 1001: "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND", + 1002: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID", + 1003: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE", + 1005: "SYSTEM_ERROR_REASON_INVALID_USERNAME", + 1006: "SYSTEM_ERROR_REASON_INVALID_PASSWORD", + } + SystemErrorReason_value = map[string]int32{ + "SYSTEM_ERROR_REASON_UNSPECIFIED": 0, + "SYSTEM_ERROR_REASON_USER_NOT_FOUND": 2001, + "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS": 2002, + "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN": 2003, + "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT": 2004, + "SYSTEM_ERROR_REASON_TOKEN_EXPIRED": 2005, + "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND": 2006, + "SYSTEM_ERROR_REASON_INVALID_TOKEN": 2007, + "SYSTEM_ERROR_REASON_INVALID_CLAIMS": 2008, + "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION": 2009, + "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION": 2010, + "SYSTEM_ERROR_REASON_INVALID_REQUEST": 2011, + "SYSTEM_ERROR_REASON_INVALID_RESPONSE": 2012, + "SYSTEM_ERROR_REASON_INVALID_SERVER": 2013, + "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND": 1001, + "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID": 1002, + "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE": 1003, + "SYSTEM_ERROR_REASON_INVALID_USERNAME": 1005, + "SYSTEM_ERROR_REASON_INVALID_PASSWORD": 1006, + } +) + +func (x SystemErrorReason) Enum() *SystemErrorReason { + p := new(SystemErrorReason) + *p = x + return p +} + +func (x SystemErrorReason) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SystemErrorReason) Descriptor() protoreflect.EnumDescriptor { + return file_types_error_proto_enumTypes[0].Descriptor() +} + +func (SystemErrorReason) Type() protoreflect.EnumType { + return &file_types_error_proto_enumTypes[0] +} + +func (x SystemErrorReason) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SystemErrorReason.Descriptor instead. +func (SystemErrorReason) EnumDescriptor() ([]byte, []int) { + return file_types_error_proto_rawDescGZIP(), []int{0} +} + +type AuthErrorReason int32 + +const ( + AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED AuthErrorReason = 0 + AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND AuthErrorReason = 2001 + AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED AuthErrorReason = 2002 +) + +// Enum value maps for AuthErrorReason. +var ( + AuthErrorReason_name = map[int32]string{ + 0: "AUTH_ERROR_REASON_UNSPECIFIED", + 2001: "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND", + 2002: "AUTH_ERROR_REASON_TOKEN_EXPIRED", + } + AuthErrorReason_value = map[string]int32{ + "AUTH_ERROR_REASON_UNSPECIFIED": 0, + "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND": 2001, + "AUTH_ERROR_REASON_TOKEN_EXPIRED": 2002, + } +) + +func (x AuthErrorReason) Enum() *AuthErrorReason { + p := new(AuthErrorReason) + *p = x + return p +} + +func (x AuthErrorReason) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (AuthErrorReason) Descriptor() protoreflect.EnumDescriptor { + return file_types_error_proto_enumTypes[1].Descriptor() +} + +func (AuthErrorReason) Type() protoreflect.EnumType { + return &file_types_error_proto_enumTypes[1] +} + +func (x AuthErrorReason) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use AuthErrorReason.Descriptor instead. +func (AuthErrorReason) EnumDescriptor() ([]byte, []int) { + return file_types_error_proto_rawDescGZIP(), []int{1} +} + +var File_types_error_proto protoreflect.FileDescriptor + +const file_types_error_proto_rawDesc = "" + + "\n" + + "\x11types/error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*\xbf\a\n" + + "\x11SystemErrorReason\x12#\n" + + "\x1fSYSTEM_ERROR_REASON_UNSPECIFIED\x10\x00\x12-\n" + + "\"SYSTEM_ERROR_REASON_USER_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x122\n" + + "'SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS\x10\xd2\x0f\x1a\x04\xa8E\x99\x03\x121\n" + + "&SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN\x10\xd3\x0f\x1a\x04\xa8E\x91\x03\x122\n" + + "'SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT\x10\xd4\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + + "!SYSTEM_ERROR_REASON_TOKEN_EXPIRED\x10\xd5\x0f\x1a\x04\xa8E\x91\x03\x12.\n" + + "#SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND\x10\xd6\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + + "!SYSTEM_ERROR_REASON_INVALID_TOKEN\x10\xd7\x0f\x1a\x04\xa8E\x91\x03\x12-\n" + + "\"SYSTEM_ERROR_REASON_INVALID_CLAIMS\x10\xd8\x0f\x1a\x04\xa8E\x91\x03\x125\n" + + "*SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION\x10\xd9\x0f\x1a\x04\xa8E\x91\x03\x124\n" + + ")SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION\x10\xda\x0f\x1a\x04\xa8E\x93\x03\x12.\n" + + "#SYSTEM_ERROR_REASON_INVALID_REQUEST\x10\xdb\x0f\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_RESPONSE\x10\xdc\x0f\x1a\x04\xa8E\xf4\x03\x12-\n" + + "\"SYSTEM_ERROR_REASON_INVALID_SERVER\x10\xdd\x0f\x1a\x04\xa8E\xf4\x03\x123\n" + + "(SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND\x10\xe9\a\x1a\x04\xa8E\x94\x03\x121\n" + + "&SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID\x10\xea\a\x1a\x04\xa8E\x90\x03\x123\n" + + "(SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE\x10\xeb\a\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_USERNAME\x10\xed\a\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_PASSWORD\x10\xee\a\x1a\x04\xa8E\x90\x03\x1a\x04\xa0E\xf4\x03*\x96\x01\n" + + "\x0fAuthErrorReason\x12!\n" + + "\x1dAUTH_ERROR_REASON_UNSPECIFIED\x10\x00\x12.\n" + + "#AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x12*\n" + + "\x1fAUTH_ERROR_REASON_TOKEN_EXPIRED\x10\xd2\x0f\x1a\x04\xa8E\x91\x03\x1a\x04\xa0E\xf4\x03B\xd8\x01\n" + + "\x19com.api.v1.services.typesB\n" + + "ErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_error_proto_rawDescOnce sync.Once + file_types_error_proto_rawDescData []byte +) + +func file_types_error_proto_rawDescGZIP() []byte { + file_types_error_proto_rawDescOnce.Do(func() { + file_types_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_error_proto_rawDesc), len(file_types_error_proto_rawDesc))) + }) + return file_types_error_proto_rawDescData +} + +var file_types_error_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_types_error_proto_goTypes = []any{ + (SystemErrorReason)(0), // 0: api.v1.services.types.SystemErrorReason + (AuthErrorReason)(0), // 1: api.v1.services.types.AuthErrorReason +} +var file_types_error_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_types_error_proto_init() } +func file_types_error_proto_init() { + if File_types_error_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_error_proto_rawDesc), len(file_types_error_proto_rawDesc)), + NumEnums: 2, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_error_proto_goTypes, + DependencyIndexes: file_types_error_proto_depIdxs, + EnumInfos: file_types_error_proto_enumTypes, + }.Build() + File_types_error_proto = out.File + file_types_error_proto_goTypes = nil + file_types_error_proto_depIdxs = nil +} diff --git a/api/v1/services/types/error.pb.validate.go b/api/v1/services/types/error.pb.validate.go new file mode 100644 index 00000000..c78c8d37 --- /dev/null +++ b/api/v1/services/types/error.pb.validate.go @@ -0,0 +1,36 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/error.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) diff --git a/api/v1/services/types/error_errors.pb.go b/api/v1/services/types/error_errors.pb.go new file mode 100644 index 00000000..f18742c9 --- /dev/null +++ b/api/v1/services/types/error_errors.pb.go @@ -0,0 +1,276 @@ +// Code generated by protoc-gen-go-errors. DO NOT EDIT. + +package types + +import ( + fmt "fmt" + errors "github.com/go-kratos/kratos/v2/errors" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +const _ = errors.SupportPackageIsVersion1 + +func IsSystemErrorReasonUnspecified(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 +} + +func ErrorSystemErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { + return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String() && e.Code == 404 +} + +func ErrorSystemErrorReasonUserNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserAlreadyExists(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String() && e.Code == 409 +} + +func ErrorSystemErrorReasonUserAlreadyExists(format string, args ...interface{}) *errors.Error { + return errors.New(409, SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserNotLoggedIn(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonUserNotLoggedIn(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserNotLoggedOut(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonUserNotLoggedOut(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonTokenExpired(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonTokenNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonTokenNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidToken(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonInvalidToken(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidClaims(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonInvalidClaims(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidAuthentication(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonInvalidAuthentication(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidAuthorization(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String() && e.Code == 403 +} + +func ErrorSystemErrorReasonInvalidAuthorization(format string, args ...interface{}) *errors.Error { + return errors.New(403, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidRequest(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidRequest(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidResponse(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String() && e.Code == 500 +} + +func ErrorSystemErrorReasonInvalidResponse(format string, args ...interface{}) *errors.Error { + return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidServer(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String() && e.Code == 500 +} + +func ErrorSystemErrorReasonInvalidServer(format string, args ...interface{}) *errors.Error { + return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonCaptchaIdNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String() && e.Code == 404 +} + +func ErrorSystemErrorReasonCaptchaIdNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidCaptchaId(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidCaptchaId(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidCaptchaCode(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidCaptchaCode(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidUsername(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidUsername(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidPassword(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidPassword(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), fmt.Sprintf(format, args...)) +} + +func IsAuthErrorReasonUnspecified(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 +} + +func ErrorAuthErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { + return errors.New(500, AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) +} + +func IsAuthErrorReasonCaptchaNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String() && e.Code == 404 +} + +func ErrorAuthErrorReasonCaptchaNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(404, AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsAuthErrorReasonTokenExpired(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 +} + +func ErrorAuthErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { + return errors.New(401, AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) +} diff --git a/buf.gen.yaml b/buf.gen.yaml index 8900a4c4..f9036627 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -47,6 +47,7 @@ plugins: - local: protoc-gen-grpc-gateway out: api/v1/services opt: paths=source_relative + # - local: protoc-gen-ent # out: database diff --git a/cmd/auth/main.go b/cmd/auth/main.go index da7b15c3..ad5b9e4c 100644 --- a/cmd/auth/main.go +++ b/cmd/auth/main.go @@ -20,6 +20,7 @@ import ( _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/loader" ) diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index 955d10df..72aef38f 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -21,6 +21,7 @@ import ( _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" "origadmin/application/admin/internal/configs" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/loader" ) diff --git a/cmd/system/main.go b/cmd/system/main.go index 9bd198a9..3e81257e 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -20,6 +20,7 @@ import ( _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/loader" ) diff --git a/contrib/security/authn/jwt/jwt.go b/contrib/security/authn/jwt/jwt.go index 9211230f..82c90cfb 100644 --- a/contrib/security/authn/jwt/jwt.go +++ b/contrib/security/authn/jwt/jwt.go @@ -276,4 +276,20 @@ func NewTokenizer(cfg *configv1.Security, ss ...Setting) (security.RefreshTokeni return tokenizer, nil } +func jwt2SecurityError(err error) error { + //if errors.Is(err, jwtv5.ErrTokenExpired) { + return securityv1.ErrorSecurityErrorReasonInvalidAuthentication(err.Error()) + //} + //if errors.Is(err, jwtv5.ErrTokenMalformed) { + // return securityv1.ErrorSecurityErrorReasonTokenMalformed(err.Error()) + //} + //if errors.Is(err, jwtv5.ErrTokenSignatureInvalid) { + // return securityv1.ErrorSecurityErrorReasonTokenSignatureInvalid(err.Error()) + //} + //if errors.Is(err, jwtv5.ErrTokenNotValidYet) { + // return securityv1.ErrorSecurityErrorReasonTokenNotValidYet(err.Error()) + //} + //return err +} + var _ security.RefreshTokenizer = (*Tokenizer)(nil) diff --git a/contrib/security/authz/casbin/option.go b/contrib/security/authz/casbin/option.go index 216f833a..41324b91 100644 --- a/contrib/security/authz/casbin/option.go +++ b/contrib/security/authz/casbin/option.go @@ -44,7 +44,7 @@ type AuthorizerOption = func(*AuthorizerOptions) var ( DefaultAuthorizerOptions = AuthorizerOptions{ Watcher: NewWatcher(), - SyncInterval: 5 * time.Second, + SyncInterval: 30 * time.Second, WildcardItem: "*", } ) diff --git a/go.mod b/go.mod index a54ea131..b2cf6251 100644 --- a/go.mod +++ b/go.mod @@ -46,8 +46,8 @@ require ( github.com/sqlite3ent/sqlite3 v1.34.1 github.com/stretchr/testify v1.10.0 golang.org/x/net v0.40.0 - google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34 - google.golang.org/grpc v1.72.0 + google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 + google.golang.org/grpc v1.72.1 google.golang.org/protobuf v1.36.6 ) @@ -56,6 +56,8 @@ require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 // indirect buf.build/go/protovalidate v0.12.0 // indirect cel.dev/expr v0.23.1 // indirect + cloud.google.com/go/iam v1.5.2 // indirect + cloud.google.com/go/longrunning v0.6.7 // indirect dario.cat/mergo v1.0.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/BurntSushi/toml v1.5.0 // indirect @@ -77,6 +79,7 @@ require ( github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/gabriel-vasile/mimetype v1.4.9 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/gin-contrib/sse v1.1.0 // indirect github.com/go-kratos/aegis v0.2.0 // indirect github.com/go-logr/logr v1.4.2 // indirect @@ -95,6 +98,7 @@ require ( github.com/google/cel-go v0.25.0 // indirect github.com/google/gnostic-models v0.6.9 // indirect github.com/google/go-cmp v0.7.0 // indirect + github.com/googleapis/gapic-generator-go v0.53.1 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect @@ -144,6 +148,11 @@ require ( github.com/yusufpapurcu/wmi v1.2.4 // indirect github.com/zclconf/go-cty v1.16.2 // indirect github.com/zclconf/go-cty-yaml v1.1.0 // indirect + gitlab.com/golang-commonmark/html v0.0.0-20191124015941-a22733972181 // indirect + gitlab.com/golang-commonmark/linkify v0.0.0-20200225224916-64bca66f6ad3 // indirect + gitlab.com/golang-commonmark/markdown v0.0.0-20211110145824-bf3e522c626a // indirect + gitlab.com/golang-commonmark/mdurl v0.0.0-20191124015652-932350d1cb84 // indirect + gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/otel v1.35.0 // indirect go.opentelemetry.io/otel/metric v1.35.0 // indirect @@ -157,9 +166,11 @@ require ( golang.org/x/sys v0.33.0 // indirect golang.org/x/text v0.25.0 // indirect golang.org/x/tools v0.33.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34 // indirect + google.golang.org/genproto v0.0.0-20250519155744-55703ea1f237 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect modernc.org/libc v1.64.0 // indirect modernc.org/mathutil v1.7.1 // indirect diff --git a/go.sum b/go.sum index e3ca1e13..f9450ac4 100644 --- a/go.sum +++ b/go.sum @@ -316,6 +316,8 @@ cloud.google.com/go/iam v0.8.0/go.mod h1:lga0/y3iH6CX7sYqypWJ33hf7kkfXJag67naqGE cloud.google.com/go/iam v0.11.0/go.mod h1:9PiLDanza5D+oWFZiH1uG+RnRCfEGKoyl6yo4cgWZGY= cloud.google.com/go/iam v0.12.0/go.mod h1:knyHGviacl11zrtZUoDuYpDgLjvr28sLQaG0YB2GYAY= cloud.google.com/go/iam v0.13.0/go.mod h1:ljOg+rcNfzZ5d6f1nAUJ8ZIxOaZUVoS14bKCtaLZ/D0= +cloud.google.com/go/iam v1.5.2 h1:qgFRAGEmd8z6dJ/qyEchAuL9jpswyODjA2lS+w234g8= +cloud.google.com/go/iam v1.5.2/go.mod h1:SE1vg0N81zQqLzQEwxL2WI6yhetBdbNQuTvIKCSkUHE= cloud.google.com/go/iap v1.4.0/go.mod h1:RGFwRJdihTINIe4wZ2iCP0zF/qu18ZwyKxrhMhygBEc= cloud.google.com/go/iap v1.5.0/go.mod h1:UH/CGgKd4KyohZL5Pt0jSKE4m3FR51qg6FKQ/z/Ix9A= cloud.google.com/go/iap v1.6.0/go.mod h1:NSuvI9C/j7UdjGjIde7t7HBz+QTwBcapPE07+sSRcLk= @@ -348,6 +350,8 @@ cloud.google.com/go/logging v1.7.0/go.mod h1:3xjP2CjkM3ZkO73aj4ASA5wRPGGCRrPIAeN cloud.google.com/go/longrunning v0.1.1/go.mod h1:UUFxuDWkv22EuY93jjmDMFT5GPQKeFVJBIF6QlTqdsE= cloud.google.com/go/longrunning v0.3.0/go.mod h1:qth9Y41RRSUE69rDcOn6DdK3HfQfsUI0YSmW3iIlLJc= cloud.google.com/go/longrunning v0.4.1/go.mod h1:4iWDqhBZ70CvZ6BfETbvam3T8FMvLK+eFj0E6AaRQTo= +cloud.google.com/go/longrunning v0.6.7 h1:IGtfDWHhQCgCjwQjV9iiLnUta9LBCo8R9QmAFsS/PrE= +cloud.google.com/go/longrunning v0.6.7/go.mod h1:EAFV3IZAKmM56TyiE6VAP3VoTzhZzySwI/YI1s/nRsY= cloud.google.com/go/managedidentities v1.3.0/go.mod h1:UzlW3cBOiPrzucO5qWkNkh0w33KFtBJU281hacNvsdE= cloud.google.com/go/managedidentities v1.4.0/go.mod h1:NWSBYbEMgqmbZsLIyKvxrYbtqOsxY1ZrGM+9RgDqInM= cloud.google.com/go/managedidentities v1.5.0/go.mod h1:+dWcZ0JlUmpuxpIDfyP5pP5y0bLdRwOS4Lp7gMni/LA= @@ -740,6 +744,7 @@ github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY= github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w= github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM= @@ -917,6 +922,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= +github.com/googleapis/gapic-generator-go v0.53.1 h1:Pd5hB9uegjh5T131ew5ddsTpRW5RDPJ34CcSHZSUAzE= +github.com/googleapis/gapic-generator-go v0.53.1/go.mod h1:bpi4lyj6DRGfEZcf6YiywBHon4NEC1+VdENKNKmrBqU= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= @@ -1163,6 +1170,7 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= @@ -1239,6 +1247,18 @@ github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWB github.com/zclconf/go-cty-yaml v1.1.0/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs= github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= +gitlab.com/golang-commonmark/html v0.0.0-20191124015941-a22733972181 h1:K+bMSIx9A7mLES1rtG+qKduLIXq40DAzYHtb0XuCukA= +gitlab.com/golang-commonmark/html v0.0.0-20191124015941-a22733972181/go.mod h1:dzYhVIwWCtzPAa4QP98wfB9+mzt33MSmM8wsKiMi2ow= +gitlab.com/golang-commonmark/linkify v0.0.0-20191026162114-a0c2df6c8f82/go.mod h1:Gn+LZmCrhPECMD3SOKlE+BOHwhOYD9j7WT9NUtkCrC8= +gitlab.com/golang-commonmark/linkify v0.0.0-20200225224916-64bca66f6ad3 h1:1Coh5BsUBlXoEJmIEaNzVAWrtg9k7/eJzailMQr1grw= +gitlab.com/golang-commonmark/linkify v0.0.0-20200225224916-64bca66f6ad3/go.mod h1:Gn+LZmCrhPECMD3SOKlE+BOHwhOYD9j7WT9NUtkCrC8= +gitlab.com/golang-commonmark/markdown v0.0.0-20211110145824-bf3e522c626a h1:O85GKETcmnCNAfv4Aym9tepU8OE0NmcZNqPlXcsBKBs= +gitlab.com/golang-commonmark/markdown v0.0.0-20211110145824-bf3e522c626a/go.mod h1:LaSIs30YPGs1H5jwGgPhLzc8vkNc/k0rDX/fEZqiU/M= +gitlab.com/golang-commonmark/mdurl v0.0.0-20191124015652-932350d1cb84 h1:qqjvoVXdWIcZCLPMlzgA7P9FZWdPGPvP/l3ef8GzV6o= +gitlab.com/golang-commonmark/mdurl v0.0.0-20191124015652-932350d1cb84/go.mod h1:IJZ+fdMvbW2qW6htJx7sLJ04FEs4Ldl/MDsJtMKywfw= +gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f h1:Wku8eEdeJqIOFHtrfkYUByc4bCaTeA6fL0UJgfEiFMI= +gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f/go.mod h1:Tiuhl+njh/JIg0uS/sOJVYi0x2HEa5rc1OAaVsb5tAs= +gitlab.com/opennota/wd v0.0.0-20180912061657-c5d65f63c638/go.mod h1:EGRJaqe2eO9XGmFtQCvV3Lm9NLico3UhFwUpCG/+mVU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -1257,6 +1277,7 @@ go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7W go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= +go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o= go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs= go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= @@ -1877,14 +1898,20 @@ google.golang.org/genproto v0.0.0-20230330154414-c0448cd141ea/go.mod h1:UUQDJDOl google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= google.golang.org/genproto v0.0.0-20230525234025-438c736192d0/go.mod h1:9ExIQyXL5hZrHzQceCwuSYwZZ5QZBazOcprJ5rgs3lY= google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54/go.mod h1:zqTuNwFlFRsw5zIts5VnzLQxSRqh+CGOTVMlYbY0Eyk= +google.golang.org/genproto v0.0.0-20250519155744-55703ea1f237 h1:2zGWyk04EwQ3mmV4dd4M4U7P/igHi5p7CBJEg1rI6A8= +google.golang.org/genproto v0.0.0-20250519155744-55703ea1f237/go.mod h1:LhI4bRmX3rqllzQ+BGneexULkEjBf2gsAfkbeCA8IbU= google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go.mod h1:ts19tUU+Z0ZShN1y3aPyq2+O3d5FUNNgT6FtOzmrNn8= google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34 h1:0PeQib/pH3nB/5pEmFeVQJotzGohV0dq4Vcp09H5yhE= google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34/go.mod h1:0awUlEkap+Pb1UMeJwJQQAdJQrt3moU7J2moTy69irI= +google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 h1:Kog3KlB4xevJlAcbbbzPfRG0+X9fdoGM+UBRKVz6Wr0= +google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237/go.mod h1:ezi0AVyMKDWy5xAncvjLWH7UcLBB5n7y2fQ8MzjJcto= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34 h1:h6p3mQqrmT1XkHVTfzLdNz1u7IhINeZkz67/xTbOuWs= google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 h1:cJfm9zPbe1e873mHJzmQ1nwVEeRDU/T1wXDK2kUSU34= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1926,6 +1953,8 @@ google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwS google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= +google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1964,6 +1993,7 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/helpers/resp/error.go b/helpers/resp/error.go index 8df9dfea..d9105c29 100644 --- a/helpers/resp/error.go +++ b/helpers/resp/error.go @@ -16,7 +16,7 @@ import ( func decodeError(alwaysSucceed bool, code int, err error) (int, *Error) { var ierr *Error - var status int + status := code if ok := errors.As(err, &ierr); ok { status = int(ierr.Code) } else if ke := kerr.FromError(err); ke != nil { @@ -43,11 +43,8 @@ func decodeError(alwaysSucceed bool, code int, err error) (int, *Error) { if alwaysSucceed { status = http.StatusOK } - if !alwaysSucceed && code != status { - ierr.Code = int32(status) - } - if code == 0 { - code = status - } - return code, ierr + //if !alwaysSucceed && code != status { + // ierr.Code = int32(status) + //} + return status, ierr } diff --git a/helpers/resp/resp.go b/helpers/resp/resp.go index 14a0bf81..9c0f8aa5 100644 --- a/helpers/resp/resp.go +++ b/helpers/resp/resp.go @@ -10,6 +10,7 @@ import ( "net/http" transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/origadmin/runtime/log" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" @@ -99,6 +100,7 @@ func (r Response) Any(context transhttp.Context, status int, data any, err error } func ResponseErrorEncoder(writer http.ResponseWriter, request *http.Request, err error) { + log.NewHelper(log.DefaultLogger).Errorf("ResponseErrorEncoder: %+v", err) ResultError(writer, http.StatusInternalServerError, err) return } diff --git a/helpers/securityx/user.go b/helpers/securityx/user.go index 86d777f7..7d8c5f7b 100644 --- a/helpers/securityx/user.go +++ b/helpers/securityx/user.go @@ -22,8 +22,8 @@ func GetUserID(ctx context.Context) string { if md, ok := metadata.FromServerContext(ctx); ok { return md.Get(GlobalSecurityUserID) } - if md, ok := metadata.FromClientContext(ctx); ok { - return md.Get(GlobalSecurityUserID) - } + //if md, ok := metadata.FromClientContext(ctx); ok { + // return md.Get(GlobalSecurityUserID) + //} return "" } diff --git a/internal/configs/service.pb.go b/internal/configs/service.pb.go index b14745f1..79046f66 100644 --- a/internal/configs/service.pb.go +++ b/internal/configs/service.pb.go @@ -155,6 +155,7 @@ type ServiceClient struct { state protoimpl.MessageState `protogen:"open.v1"` Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` Services []*v1.Service `protobuf:"bytes,200,rep,name=services,proto3" json:"services,omitempty"` + Middleware *v11.Middleware `protobuf:"bytes,300,opt,name=middleware,proto3" json:"middleware,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -203,6 +204,13 @@ func (x *ServiceClient) GetServices() []*v1.Service { return nil } +func (x *ServiceClient) GetMiddleware() *v11.Middleware { + if x != nil { + return x.Middleware + } + return nil +} + var File_configs_service_proto protoreflect.FileDescriptor const file_configs_service_proto_rawDesc = "" + @@ -218,10 +226,13 @@ const file_configs_service_proto_rawDesc = "" + "\bservices\x18\xc8\x01 \x03(\v2\x12.config.v1.ServiceR\bservices\x12:\n" + "\n" + "middleware\x18\xac\x02 \x01(\v2\x19.middleware.v1.MiddlewareR\n" + - "middleware\"n\n" + + "middleware\"\xaa\x01\n" + "\rServiceClient\x12,\n" + "\x04core\x18\x01 \x01(\v2\x18.api.configs.ServiceCoreR\x04core\x12/\n" + - "\bservices\x18\xc8\x01 \x03(\v2\x12.config.v1.ServiceR\bservicesB.Z,origadmin/application/admin/internal/configsb\x06proto3" + "\bservices\x18\xc8\x01 \x03(\v2\x12.config.v1.ServiceR\bservices\x12:\n" + + "\n" + + "middleware\x18\xac\x02 \x01(\v2\x19.middleware.v1.MiddlewareR\n" + + "middlewareB.Z,origadmin/application/admin/internal/configsb\x06proto3" var ( file_configs_service_proto_rawDescOnce sync.Once @@ -253,11 +264,12 @@ var file_configs_service_proto_depIdxs = []int32{ 6, // 4: api.configs.ServiceServer.middleware:type_name -> middleware.v1.Middleware 0, // 5: api.configs.ServiceClient.core:type_name -> api.configs.ServiceCore 5, // 6: api.configs.ServiceClient.services:type_name -> config.v1.Service - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 6, // 7: api.configs.ServiceClient.middleware:type_name -> middleware.v1.Middleware + 8, // [8:8] is the sub-list for method output_type + 8, // [8:8] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_configs_service_proto_init() } diff --git a/internal/configs/service.pb.validate.go b/internal/configs/service.pb.validate.go index 94c7011d..7db5efe8 100644 --- a/internal/configs/service.pb.validate.go +++ b/internal/configs/service.pb.validate.go @@ -478,6 +478,35 @@ func (m *ServiceClient) validate(all bool) error { } + if all { + switch v := interface{}(m.GetMiddleware()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ServiceClientValidationError{ + field: "Middleware", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ServiceClientValidationError{ + field: "Middleware", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMiddleware()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ServiceClientValidationError{ + field: "Middleware", + reason: "embedded message failed validation", + cause: err, + } + } + } + if len(errors) > 0 { return ServiceClientMultiError(errors) } diff --git a/internal/configs/service.proto b/internal/configs/service.proto index da6a417c..88bd191d 100644 --- a/internal/configs/service.proto +++ b/internal/configs/service.proto @@ -25,4 +25,5 @@ message ServiceServer { message ServiceClient { ServiceCore core = 1 [json_name = "core"]; repeated config.v1.Service services = 200 [json_name = "services"]; + middleware.v1.Middleware middleware = 300 [json_name = "middleware"]; } \ No newline at end of file diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go index e44acf68..b368bb4a 100644 --- a/internal/loader/bootstrap_default.go +++ b/internal/loader/bootstrap_default.go @@ -39,7 +39,8 @@ func DefaultBootstrap() *configs.Bootstrap { Services: DefaultServices(), }, Server: &configs.ServiceServer{ - Services: DefaultServices(), + Services: DefaultServices(), + Middleware: DefaultServiceMiddleware(), }, Clients: DefaultServiceClients(), Logger: DefaultLogger(), @@ -109,7 +110,7 @@ func DefaultServices() []*configv1.Service { Websocket: DefaultServiceWebsocket(), Message: DefaultServiceMessage(), Task: DefaultServiceTask(), - Middleware: DefaultServiceMiddleware(), + //Middleware: DefaultServiceMiddleware(), Selector: &configv1.Service_Selector{ Version: "v1.0.0", Builder: "bbr", @@ -123,7 +124,7 @@ func DefaultServices() []*configv1.Service { Websocket: DefaultServiceWebsocket(), Message: DefaultServiceMessage(), Task: DefaultServiceTask(), - Middleware: DefaultServiceMiddleware(), + //Middleware: DefaultServiceMiddleware(), Selector: &configv1.Service_Selector{ Version: "v1.0.0", Builder: "bbr", @@ -145,8 +146,9 @@ func DefaultServiceClients() []*configs.ServiceClient { } core.Discovery.ServiceName = serviceName clients = append(clients, &configs.ServiceClient{ - Core: core, - Services: DefaultServices(), + Core: core, + Services: DefaultServices(), + Middleware: DefaultServiceMiddleware(), }) } return clients diff --git a/internal/loader/proxy.go b/internal/loader/proxy.go index 14d8c9f0..466713b8 100644 --- a/internal/loader/proxy.go +++ b/internal/loader/proxy.go @@ -8,6 +8,7 @@ package loader import ( "strings" + "github.com/go-kratos/kratos/v2/metadata" "github.com/go-kratos/kratos/v2/middleware/recovery" "github.com/go-kratos/kratos/v2/middleware/selector" "github.com/go-kratos/kratos/v2/transport" @@ -79,7 +80,7 @@ func NewProxyServer( return false } } - log.Debugf("Operation '%s' no matches public path '%s'", operation, "*") + log.Infof("Operation '%s' no matches public path '%s'", operation, "*") return true }) ms = append(ms, serv.Build(), CallLoggerMiddleware()) @@ -141,16 +142,26 @@ func CallLoggerMiddleware() middleware.KMiddleware { tr, ok := transport.FromServerContext(ctx) log.Infof("Caller Server: %+v, ok: %+v", tr, ok) tr, ok = transport.FromClientContext(ctx) - log.Infof("Caller ServiceServer: %+v, ok: %+v", tr, ok) + log.Infof("Caller Client: %+v, ok: %+v", tr, ok) return handler(ctx, req) } } } -func CorsMiddleware() middleware.KMiddleware { +func BridgeMiddleware() middleware.KMiddleware { return func(handler middleware.KHandler) middleware.KHandler { return func(ctx context.Context, req interface{}) (reply interface{}, err error) { - log.Infof("CorsMiddleware: %+v", ctx) + meta, _ := metadata.FromClientContext(ctx) + log.Infof("Caller Client Metadata: %+v", meta) + smd, ok := metadata.FromServerContext(ctx) + if !ok { + smd = metadata.New(nil) + } + log.Infof("Caller Server Metadata: %+v", smd) + for k, v := range meta { + smd[k] = v + } + ctx = metadata.NewServerContext(ctx, smd) return handler(ctx, req) } } @@ -175,6 +186,11 @@ func NewProxyGRPCClients(r runtime.Runtime, bootstrap *configs.Bootstrap) map[st } for idx := range services { if services[idx].GetType() == "grpc" { + ll.Infof("NewProxyGRPCClient Middleware: %+v", clients[i].GetMiddleware()) + ms := r.Builder().NewMiddlewaresClient(clients[i].GetMiddleware()) + if len(ms) > 0 { + options = append(options, servicegrpc.WithMiddlewares(ms...)) + } client, err := r.Builder().NewGRPCClient(r.Context(), services[idx], options...) if err != nil { ll.Warnf("NewGRPCClient failed: %v", err) @@ -204,6 +220,11 @@ func NewProxyHTTPClients(r runtime.Runtime, bootstrap *configs.Bootstrap) map[st } for idx := range services { if services[idx].GetType() == "http" { + ll.Infof("NewProxyHTTPClient Middleware: %+v", clients[i].GetMiddleware()) + ms := r.Builder().NewMiddlewaresClient(clients[i].GetMiddleware()) + if len(ms) > 0 { + options = append(options, servicehttp.WithMiddlewares(ms...)) + } client, err := r.Builder().NewHTTPClient(r.Context(), services[idx], options...) if err != nil { ll.Warnf("NewHTTPClient failed: %v", err) diff --git a/internal/loader/service_test.go b/internal/loader/service_test.go index 19431c06..0c1a097a 100644 --- a/internal/loader/service_test.go +++ b/internal/loader/service_test.go @@ -177,73 +177,6 @@ func TestServiceDefaultOutput(t *testing.T) { Addr: "", }, }, - Middleware: &v11.Middleware{ - //Logging: false, - //Recovery: false, - //Tracing: false, - //CircuitBreaker: false, - Metadata: &v11.Middleware_Metadata{ - Enabled: false, - Prefix: "", - Data: nil, - }, - RateLimiter: &ratelimitv1.RateLimiter{ - Enabled: false, - Name: "", - Period: 0, - XRatelimitLimit: 0, - XRatelimitRemaining: 0, - XRatelimitReset: 0, - RetryAfter: 0, - Memory: &ratelimitv1.RateLimiter_Memory{ - Expiration: 0, - CleanupInterval: 0, - }, - Redis: &ratelimitv1.RateLimiter_Redis{ - Addr: "", - Username: "", - Password: "", - Db: 0, - }, - }, - Metrics: &metricsv1.Metrics{ - Enabled: false, - SupportedMetrics: nil, - UserMetrics: nil, - }, - Validator: &validatorv1.Validator{ - Enabled: false, - Version: 0, - FailFast: false, - }, - Jwt: &jwtv1.JWT{ - Enabled: false, - Subject: "", - ClaimType: "", - TokenHeader: nil, - //Config: &jwtv1.Config{ - // SigningMethod: "", - // Key: "", - // Key2: "", - // AccessTokenLifetime: 0, - // RefreshTokenLifetime: 0, - // Issuer: "", - // Audience: nil, - // TokenType: "", - //}, - }, - Selector: &selectorv1.Selector{ - Enabled: false, - Names: nil, - Paths: nil, - Regex: "", - Prefixes: nil, - }, - }, - Selector: &configv1.Service_Selector{ - Version: "", - Builder: "", - }, }, }, Middleware: &v11.Middleware{ @@ -252,9 +185,9 @@ func TestServiceDefaultOutput(t *testing.T) { //Tracing: false, //CircuitBreaker: false, Metadata: &v11.Middleware_Metadata{ - Enabled: false, - Prefix: "", - Data: nil, + Enabled: false, + Prefixes: nil, + Data: nil, }, RateLimiter: &ratelimitv1.RateLimiter{ Enabled: false, diff --git a/internal/mods/auth/dal/personal.dal.go b/internal/mods/auth/dal/personal.dal.go index 515d17e7..1af72a9e 100644 --- a/internal/mods/auth/dal/personal.dal.go +++ b/internal/mods/auth/dal/personal.dal.go @@ -7,6 +7,7 @@ package dal import ( "context" + "github.com/go-kratos/kratos/v2/transport" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" @@ -67,6 +68,9 @@ func (repo personalRepo) UpdatePersonalProfile(ctx context.Context, in *pb.Updat } func (repo personalRepo) ListPersonalResources(ctx context.Context, in *pb.ListPersonalResourcesRequest) (*pb.ListPersonalResourcesResponse, error) { + tr, ok := transport.FromServerContext(ctx) + log.Infof("tr: %+v", tr.RequestHeader()) + log.Infof("ok: %+v", ok) uid := securityx.GetUserID(ctx) log.Infof("uid: %+v", uid) resourceQuery := repo.db.Resource(ctx).Query() diff --git a/internal/mods/auth/server/server.go b/internal/mods/auth/server/server.go index 1a932718..9aefdb9a 100644 --- a/internal/mods/auth/server/server.go +++ b/internal/mods/auth/server/server.go @@ -39,7 +39,7 @@ func init() { runtime.RegisterService(ServiceName, service.DefaultServiceFactory) } -func NewAuthServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc *authservice.RegisterServer) []transport. +func NewAuthServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc authservice.AuthServerRegistrar) []transport. Server { var servers []transport.Server serverConfig := bootstrap.GetServer() @@ -53,34 +53,48 @@ Server { coreinfo := bootstrap.GetServer().GetCore() for _, serviceConfig := range services { ll.Infow("msg", "service init", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) + var option service.ServerOption switch serviceConfig.GetType() { case "grpc": options := []servicegrpc.Option{ servicegrpc.WithMiddlewares(middlewares...), servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), } - grpcServer, err := r.Builder().NewGRPCServer(serviceConfig, options...) - if err != nil { - continue - } - ll.Infow("msg", "grpc server init", "name", coreinfo.GetName(), "version", - coreinfo.GetVersion()) - svc.Register(r.Context(), grpcServer) - servers = append(servers, grpcServer) + option = service.WithGRPC(options...) + //grpcServer, err := r.Builder().NewGRPCServer(serviceConfig, options...) + //if err != nil { + // continue + //} + //ll.Infow("msg", "grpc server init", "name", coreinfo.GetName(), "version", + // coreinfo.GetVersion()) + //svc.Register(r.Context(), grpcServer) + //servers = append(servers, grpcServer) case "http": options := []servicehttp.Option{ servicehttp.WithMiddlewares(middlewares...), servicehttp.WithPrefix(runtime.DefaultEnvPrefix), } - httpServer, err := r.Builder().NewHTTPServer(serviceConfig, options...) - if err != nil { - continue - } - ll.Infow("msg", "http server init", "name", coreinfo.GetName(), "version", - coreinfo.GetVersion()) - svc.Register(r.Context(), httpServer) - servers = append(servers, httpServer) + option = service.WithHTTP(options...) + //httpServer, err := r.Builder().NewHTTPServer(serviceConfig, options...) + //if err != nil { + // continue + //} + //ll.Infow("msg", "http server init", "name", coreinfo.GetName(), "version", + // coreinfo.GetVersion()) + //svc.Register(r.Context(), httpServer) + //servers = append(servers, httpServer) + default: + ll.Warnw("msg", "service type not support", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) + continue + } + httpServer, err := r.Builder().NewServer("auth", serviceConfig, option) + if err != nil { + continue } + ll.Infow("msg", "auth server init", "name", coreinfo.GetName(), "version", + coreinfo.GetVersion()) + svc.Register(r.Context(), httpServer) + servers = append(servers, httpServer) } return servers } diff --git a/internal/mods/auth/service/login.bridge.go b/internal/mods/auth/service/login.bridge.go index 400bb8e0..4318dd02 100644 --- a/internal/mods/auth/service/login.bridge.go +++ b/internal/mods/auth/service/login.bridge.go @@ -97,9 +97,13 @@ func (s LoginServiceHookedBridge) CompleteRegister(ctx transhttp.Context, reques } func (s LoginServiceHookedBridge) CompleteTokenRefresh(ctx transhttp.Context, request *pb.TokenRefreshRequest, response *pb.TokenRefreshResponse) error { - return ctx.JSON(http.StatusOK, &resp.Data{ + marshal, err := protojson.Marshal(resp.FromToken(response.Token)) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.Result{ Success: true, - Data: resp.Proto2Any(resp.FromToken(response.Token)), + Data: marshal, }) } diff --git a/internal/mods/system/server/server.go b/internal/mods/system/server/server.go index 06e7274c..1fc8a7bd 100644 --- a/internal/mods/system/server/server.go +++ b/internal/mods/system/server/server.go @@ -39,7 +39,7 @@ func init() { runtime.RegisterService(ServiceName, service.DefaultServiceFactory) } -func NewSystemServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc *systemservice.RegisterServer) []transport. +func NewSystemServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc systemservice.SystemServerRegistrar) []transport. Server { var servers []transport.Server serverConfig := bootstrap.GetServer() @@ -48,39 +48,45 @@ Server { } ll := log.NewHelper(r.WithLogger("module", "system/server")) - middlewares := middleware.NewServer(bootstrap.GetServer().GetMiddleware()) + middlewares := r.Builder().Middleware().BuildServer(bootstrap.GetServer().GetMiddleware()) services := bootstrap.GetServer().GetServices() coreinfo := bootstrap.GetServer().GetCore() for _, serviceConfig := range services { ll.Infow("msg", "service init", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) + var option service.ServerOption switch serviceConfig.GetType() { case "grpc": options := []servicegrpc.Option{ servicegrpc.WithMiddlewares(middlewares...), servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), } - grpcServer, err := r.Builder().NewGRPCServer(serviceConfig, options...) - if err != nil { - continue - } - ll.Infow("msg", "grpc server init", "name", coreinfo.GetName(), "version", - coreinfo.GetVersion()) - svc.Register(r.Context(), grpcServer) - servers = append(servers, grpcServer) + option = service.WithGRPC(options...) case "http": options := []servicehttp.Option{ servicehttp.WithMiddlewares(middlewares...), servicehttp.WithPrefix(runtime.DefaultEnvPrefix), } - httpServer, err := r.Builder().NewHTTPServer(serviceConfig, options...) - if err != nil { - continue - } - ll.Infow("msg", "http server init", "name", coreinfo.GetName(), "version", - coreinfo.GetVersion()) - svc.Register(r.Context(), httpServer) - servers = append(servers, httpServer) + //httpServer, err := r.Builder().NewServer(serviceConfig, options...) + //if err != nil { + // continue + //} + //ll.Infow("msg", "http server init", "name", coreinfo.GetName(), "version", + // coreinfo.GetVersion()) + //svc.Register(r.Context(), httpServer) + //servers = append(servers, httpServer) + option = service.WithHTTP(options...) + default: + ll.Warnw("msg", "service type not support", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) + continue + } + grpcServer, err := r.Builder().NewServer("system", serviceConfig, option) + if err != nil { + continue } + ll.Infow("msg", "system server init", "name", coreinfo.GetName(), "version", + coreinfo.GetVersion()) + svc.Register(r.Context(), grpcServer) + servers = append(servers, grpcServer) } return servers } diff --git a/internal/mods/system/service/user.service.go b/internal/mods/system/service/user.service.go deleted file mode 100644 index be6dc11f..00000000 --- a/internal/mods/system/service/user.service.go +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime/service" - - "origadmin/application/admin/internal/mods/system/biz" -) - -type UserService struct { - grpcClient *service.GRPCClient - httpClient *service.HTTPClient - biz *biz.UserServiceBiz `wire:"-"` - grpc *UserServiceServer `wire:"-"` - http *UserServiceHTTPServer `wire:"-"` -} - -//func NewUserService(r runtime.Runtime, bootstrap *configs.Bootstrap, service *UserService) pb.UserServiceServer { -// if r.IsClient() { -// return NewUserServiceBridge(r, service.grpcClient) -// } -//} diff --git a/resources/configs/admin/clients.toml b/resources/configs/admin/clients.toml index 76321bb9..84a38d7f 100644 --- a/resources/configs/admin/clients.toml +++ b/resources/configs/admin/clients.toml @@ -86,40 +86,6 @@ Location = "" [Clients.Services.Task.Machinery] [Clients.Services.Task.Cron] Addr = "" -[Clients.Services.Middleware] -EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] -[Clients.Services.Middleware.Metadata] -Enabled = true -Prefix = "" -[Clients.Services.Middleware.RateLimiter] -Enabled = true -Name = "bbr" -Period = 0 -XRatelimitLimit = 0 -XRatelimitRemaining = 0 -XRatelimitReset = 0 -RetryAfter = 0 -[Clients.Services.Middleware.Metrics] -Enabled = true -[Clients.Services.Middleware.Validator] -Enabled = true -Version = 1 -FailFast = true -[Clients.Services.Middleware.Jwt] -Enabled = false -Subject = "" -ClaimType = "" -[Clients.Services.Middleware.Jwt.Config] -SigningMethod = "HS512" -Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" -Key2 = "can empty next version fixed" -AccessTokenLifetime = 900000000000 -RefreshTokenLifetime = 259200000000000 -Issuer = "localhost" -TokenType = "Bearer" -[Clients.Services.Middleware.Selector] -Enabled = false -Regex = "" [Clients.Services.Selector] Version = "v1.0.0" Builder = "bbr" @@ -193,12 +159,14 @@ Location = "" [Clients.Services.Task.Machinery] [Clients.Services.Task.Cron] Addr = "" -[Clients.Services.Middleware] +[Clients.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" +[Clients.Middleware] EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] -[Clients.Services.Middleware.Metadata] +[Clients.Middleware.Metadata] Enabled = true -Prefix = "" -[Clients.Services.Middleware.RateLimiter] +[Clients.Middleware.RateLimiter] Enabled = true Name = "bbr" Period = 0 @@ -206,17 +174,17 @@ XRatelimitLimit = 0 XRatelimitRemaining = 0 XRatelimitReset = 0 RetryAfter = 0 -[Clients.Services.Middleware.Metrics] +[Clients.Middleware.Metrics] Enabled = true -[Clients.Services.Middleware.Validator] +[Clients.Middleware.Validator] Enabled = true Version = 1 FailFast = true -[Clients.Services.Middleware.Jwt] +[Clients.Middleware.Jwt] Enabled = false Subject = "" ClaimType = "" -[Clients.Services.Middleware.Jwt.Config] +[Clients.Middleware.Jwt.Config] SigningMethod = "HS512" Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" Key2 = "can empty next version fixed" @@ -224,12 +192,9 @@ AccessTokenLifetime = 900000000000 RefreshTokenLifetime = 259200000000000 Issuer = "localhost" TokenType = "Bearer" -[Clients.Services.Middleware.Selector] +[Clients.Middleware.Selector] Enabled = false Regex = "" -[Clients.Services.Selector] -Version = "v1.0.0" -Builder = "bbr" [[Clients]] [Clients.Core] @@ -319,40 +284,6 @@ Location = "" [Clients.Services.Task.Machinery] [Clients.Services.Task.Cron] Addr = "" -[Clients.Services.Middleware] -EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] -[Clients.Services.Middleware.Metadata] -Enabled = true -Prefix = "" -[Clients.Services.Middleware.RateLimiter] -Enabled = true -Name = "bbr" -Period = 0 -XRatelimitLimit = 0 -XRatelimitRemaining = 0 -XRatelimitReset = 0 -RetryAfter = 0 -[Clients.Services.Middleware.Metrics] -Enabled = true -[Clients.Services.Middleware.Validator] -Enabled = true -Version = 1 -FailFast = true -[Clients.Services.Middleware.Jwt] -Enabled = false -Subject = "" -ClaimType = "" -[Clients.Services.Middleware.Jwt.Config] -SigningMethod = "HS512" -Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" -Key2 = "can empty next version fixed" -AccessTokenLifetime = 900000000000 -RefreshTokenLifetime = 259200000000000 -Issuer = "localhost" -TokenType = "Bearer" -[Clients.Services.Middleware.Selector] -Enabled = false -Regex = "" [Clients.Services.Selector] Version = "v1.0.0" Builder = "bbr" @@ -426,12 +357,14 @@ Location = "" [Clients.Services.Task.Machinery] [Clients.Services.Task.Cron] Addr = "" -[Clients.Services.Middleware] +[Clients.Services.Selector] +Version = "v1.0.0" +Builder = "bbr" +[Clients.Middleware] EnabledMiddlewares = ["logging", "recovery", "tracing", "circuit_breaker", "metadata", "rate_limiter", "metrics", "validator", "jwt", "selector"] -[Clients.Services.Middleware.Metadata] +[Clients.Middleware.Metadata] Enabled = true -Prefix = "" -[Clients.Services.Middleware.RateLimiter] +[Clients.Middleware.RateLimiter] Enabled = true Name = "bbr" Period = 0 @@ -439,17 +372,17 @@ XRatelimitLimit = 0 XRatelimitRemaining = 0 XRatelimitReset = 0 RetryAfter = 0 -[Clients.Services.Middleware.Metrics] +[Clients.Middleware.Metrics] Enabled = true -[Clients.Services.Middleware.Validator] +[Clients.Middleware.Validator] Enabled = true Version = 1 FailFast = true -[Clients.Services.Middleware.Jwt] +[Clients.Middleware.Jwt] Enabled = false Subject = "" ClaimType = "" -[Clients.Services.Middleware.Jwt.Config] +[Clients.Middleware.Jwt.Config] SigningMethod = "HS512" Key = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" Key2 = "can empty next version fixed" @@ -457,9 +390,6 @@ AccessTokenLifetime = 900000000000 RefreshTokenLifetime = 259200000000000 Issuer = "localhost" TokenType = "Bearer" -[Clients.Services.Middleware.Selector] +[Clients.Middleware.Selector] Enabled = false Regex = "" -[Clients.Services.Selector] -Version = "v1.0.0" -Builder = "bbr" diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 647200d3..3d0be376 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -14,8 +14,7 @@ info: url: https://github.com/origadmin/backend/blob/master/LICENSE version: Version from annotation servers: - - url: http://localhost:10080 - - url: https://localhost:10080 + - url: https://api.foo.com paths: /auth/authenticate: post: From 928cecc7df2710e04a83aaad5771d4a1ff4cc3cd Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 16 Jun 2025 17:15:02 +0800 Subject: [PATCH 044/158] refactor(security): implement custom token management and authentication - Add new token.go, token_metadata.go, and token_transport.go files in contrib/security - Update authn.go to use new token management functions - Modify security.go to use new authentication logic - Update dependencies and adjust import statements --- contrib/security/authn/jwt/authn.go | 5 +- contrib/security/token.go | 109 ++++++++++++++++++++++++++++ contrib/security/token_metadata.go | 74 +++++++++++++++++++ contrib/security/token_transport.go | 61 ++++++++++++++++ go.mod | 46 ++++++------ go.sum | 44 +++++++++++ helpers/securityx/security.go | 32 ++++---- internal/loader/proxy.go | 2 +- 8 files changed, 334 insertions(+), 39 deletions(-) create mode 100644 contrib/security/token.go create mode 100644 contrib/security/token_metadata.go create mode 100644 contrib/security/token_transport.go diff --git a/contrib/security/authn/jwt/authn.go b/contrib/security/authn/jwt/authn.go index e454a3be..91aff198 100644 --- a/contrib/security/authn/jwt/authn.go +++ b/contrib/security/authn/jwt/authn.go @@ -9,9 +9,10 @@ import ( "context" "github.com/goexts/generic/settings" - msecurity "github.com/origadmin/runtime/agent/middleware/security" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/interfaces/security/token" + + contribsecurity "origadmin/application/admin/contrib/security" ) type Authenticator struct { @@ -29,7 +30,7 @@ func (obj Authenticator) Authenticate(ctx context.Context, s string) (security.C } func (obj Authenticator) AuthenticateContext(ctx context.Context, tokenType security.TokenSource) (security.Claims, error) { - token, err := msecurity.TokenFromContext(ctx, tokenType, obj.Scheme.String()) + token, err := contribsecurity.TokenFromContext(ctx, tokenType, obj.Scheme.String()) if err != nil { return nil, err } diff --git a/contrib/security/token.go b/contrib/security/token.go new file mode 100644 index 00000000..8ad9ea34 --- /dev/null +++ b/contrib/security/token.go @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package securityx implements the functions, types, and interfaces for the module. +package security + +import ( + "fmt" + "strings" + + "github.com/go-kratos/kratos/v2/transport" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/security" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// TokenToContext . +func TokenToContext(ctx context.Context, tokenType security.TokenSource, scheme string, token string) context.Context { + switch tokenType { + case security.TokenSourceMetadata: + return injectTokenMetadataContext(ctx, scheme, token) + case security.TokenSourceMetadataClient: + return injectTokenMetadataClientContext(ctx, scheme, token) + case security.TokenSourceMetadataServer: + return injectTokenMetadataServerContext(ctx, scheme, token) + case security.TokenSourceHeader: + return injectHeaderTransportContext(ctx, scheme, token) + case security.TokenSourceServerHeader: + return injectServerTransportContext(ctx, scheme, token) + case security.TokenSourceClientHeader: + return injectClientTransportContext(ctx, scheme, token) + case security.TokenSourceContext: + return security.NewTokenContext(ctx, formatToken(scheme, token)) + default: + return injectTokenMetadataContext(ctx, scheme, token) + } +} + +func extractTokenFromContext(ctx context.Context, tokenType security.TokenSource) string { + switch tokenType { + case security.TokenSourceMetadata: + return extractTokenMetadataContext(ctx) + case security.TokenSourceMetadataClient: + return extractTokenMetadataClientContext(ctx) + case security.TokenSourceMetadataServer: + return extractTokenMetadataServerContext(ctx) + case security.TokenSourceHeader: + return extractHeaderTransportContext(ctx) + case security.TokenSourceServerHeader: + return extractServerTransportContext(ctx) + case security.TokenSourceClientHeader: + return extractClientTransportContext(ctx) + case security.TokenSourceContext: + return security.TokenFromContext(ctx) + default: + return extractTokenMetadataContext(ctx) + } +} + +// TokenFromContext . +func TokenFromContext(ctx context.Context, tokenType security.TokenSource, scheme string) (string, error) { + val := extractTokenFromContext(ctx, tokenType) + if val == "" { + return "", status.Errorf(codes.Unauthenticated, "Request unauthenticated with "+scheme) + } + + splits := strings.SplitN(val, " ", 2) + if len(splits) < 2 { + return "", status.Errorf(codes.Unauthenticated, "Bad authorization string") + } + + if !strings.EqualFold(splits[0], scheme) { + return "", status.Errorf(codes.Unauthenticated, "Request unauthenticated with "+scheme) + } + + return splits[1], nil +} + +func formatToken(scheme string, tokenStr string) string { + return fmt.Sprintf("%s %s", scheme, tokenStr) +} + +func TokenFromTransportClient(authorize string, scheme string) func(ctx context.Context) string { + return func(ctx context.Context) string { + if tr, ok := transport.FromClientContext(ctx); ok { + token := tr.RequestHeader().Get(authorize) + splits := strings.SplitN(token, " ", 2) + if len(splits) > 1 && strings.EqualFold(splits[0], scheme) { + return splits[1] + } + } + return "" + } +} + +func TokenFromTransportServer(authorize string, scheme string) func(ctx context.Context) string { + return func(ctx context.Context) string { + if tr, ok := transport.FromServerContext(ctx); ok { + token := tr.RequestHeader().Get(authorize) + splits := strings.SplitN(token, " ", 2) + if len(splits) > 1 && strings.EqualFold(splits[0], scheme) { + return splits[1] + } + } + return "" + } +} diff --git a/contrib/security/token_metadata.go b/contrib/security/token_metadata.go new file mode 100644 index 00000000..7e08158c --- /dev/null +++ b/contrib/security/token_metadata.go @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package securityx implements the functions, types, and interfaces for the module. +package security + +import ( + kmetadata "github.com/go-kratos/kratos/v2/metadata" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/security" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +func injectTokenMetadataContext(ctx context.Context, scheme string, token string) context.Context { + md, ok := metadata.FromOutgoingContext(ctx) + if !ok { + // Use pairs to create a new one. + md = metadata.Pairs() + } + md.Set(security.HeaderAuthorize, formatToken(scheme, token)) + return ctx +} + +func injectTokenMetadataServerContext(ctx context.Context, scheme string, token string) context.Context { + md, ok := kmetadata.FromServerContext(ctx) + if !ok { + // Use make to create a new one. + md = make(kmetadata.Metadata) + } + md.Set(security.HeaderAuthorize, formatToken(scheme, token)) + return ctx +} + +func injectTokenMetadataClientContext(ctx context.Context, scheme string, token string) context.Context { + md, ok := kmetadata.FromClientContext(ctx) + if !ok { + // Use make to create a new one. + md = make(kmetadata.Metadata) + } + md.Set(security.HeaderAuthorize, formatToken(scheme, token)) + return ctx +} + +func extractTokenMetadataContext(ctx context.Context) string { + if md, ok := metadata.FromIncomingContext(ctx); ok { + return md.Get(security.HeaderAuthorize)[0] + } + return "" +} + +func extractTokenMetadataServerContext(ctx context.Context) string { + if meta, ok := kmetadata.FromServerContext(ctx); ok { + return meta.Get(security.HeaderAuthorize) + } + return "" +} + +func extractTokenMetadataClientContext(ctx context.Context) string { + if meta, ok := kmetadata.FromClientContext(ctx); ok { + return meta.Get(security.HeaderAuthorize) + } + return "" +} + +func ClaimFromTokenTypeContext(ctx context.Context, tokenType security.TokenSource) (security.Claims, error) { + switch tokenType { + case security.TokenSourceContext: + return security.ClaimsFromContext(ctx), nil + } + return nil, status.Errorf(codes.Unauthenticated, "Request unauthenticated with "+tokenType.String()) +} diff --git a/contrib/security/token_transport.go b/contrib/security/token_transport.go new file mode 100644 index 00000000..22b855a4 --- /dev/null +++ b/contrib/security/token_transport.go @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package securityx implements the functions, types, and interfaces for the module. +package security + +import ( + "github.com/go-kratos/kratos/v2/transport" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/security" +) + +func injectHeaderTransportContext(ctx context.Context, scheme string, token string) context.Context { + if header, ok := transport.FromServerContext(ctx); ok { + header.RequestHeader().Set(security.HeaderAuthorize, formatToken(scheme, token)) + return transport.NewServerContext(ctx, header) + } + if header, ok := transport.FromClientContext(ctx); ok { + header.RequestHeader().Set(security.HeaderAuthorize, formatToken(scheme, token)) + return transport.NewClientContext(ctx, header) + } + return ctx +} +func extractHeaderTransportContext(ctx context.Context) string { + if header, ok := transport.FromServerContext(ctx); ok { + return header.RequestHeader().Get(security.HeaderAuthorize) + } + if header, ok := transport.FromClientContext(ctx); ok { + return header.RequestHeader().Get(security.HeaderAuthorize) + } + return "" +} + +func injectServerTransportContext(ctx context.Context, scheme string, token string) context.Context { + if header, ok := transport.FromServerContext(ctx); ok { + header.RequestHeader().Set(security.HeaderAuthorize, formatToken(scheme, token)) + return transport.NewServerContext(ctx, header) + } + return ctx +} +func extractServerTransportContext(ctx context.Context) string { + if header, ok := transport.FromServerContext(ctx); ok { + return header.RequestHeader().Get(security.HeaderAuthorize) + } + return "" +} +func injectClientTransportContext(ctx context.Context, scheme string, token string) context.Context { + if header, ok := transport.FromClientContext(ctx); ok { + header.RequestHeader().Set(security.HeaderAuthorize, formatToken(scheme, token)) + return transport.NewClientContext(ctx, header) + } + return ctx +} + +func extractClientTransportContext(ctx context.Context) string { + if header, ok := transport.FromClientContext(ctx); ok { + return header.RequestHeader().Get(security.HeaderAuthorize) + } + return "" +} diff --git a/go.mod b/go.mod index b2cf6251..f688d85e 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/origadmin/contrib/replacer v0.0.33 github.com/origadmin/contrib/transport/gins v0.0.33 github.com/origadmin/entslog/v3 v3.1.0 - github.com/origadmin/runtime v0.2.0 + github.com/origadmin/runtime v0.2.3 github.com/origadmin/slog-kratos v1.0.4 github.com/origadmin/toolkits v0.3.16 github.com/origadmin/toolkits/codec v0.3.16 @@ -45,20 +45,20 @@ require ( github.com/spf13/cobra v1.9.1 github.com/sqlite3ent/sqlite3 v1.34.1 github.com/stretchr/testify v1.10.0 - golang.org/x/net v0.40.0 - google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 - google.golang.org/grpc v1.72.1 + golang.org/x/net v0.41.0 + google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 + google.golang.org/grpc v1.73.0 google.golang.org/protobuf v1.36.6 ) require ( ariga.io/atlas v0.32.0 // indirect - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 // indirect - buf.build/go/protovalidate v0.12.0 // indirect - cel.dev/expr v0.23.1 // indirect + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250613055000-fd99550722dc.1 // indirect + buf.build/go/protovalidate v0.13.0 // indirect + cel.dev/expr v0.24.0 // indirect cloud.google.com/go/iam v1.5.2 // indirect cloud.google.com/go/longrunning v0.6.7 // indirect - dario.cat/mergo v1.0.1 // indirect + dario.cat/mergo v1.0.2 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/BurntSushi/toml v1.5.0 // indirect github.com/agext/levenshtein v1.2.3 // indirect @@ -68,7 +68,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect - github.com/bytedance/sonic v1.13.2 // indirect + github.com/bytedance/sonic v1.13.3 // indirect github.com/bytedance/sonic/loader v0.2.4 // indirect github.com/casbin/govaluate v1.3.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -82,7 +82,7 @@ require ( github.com/ghodss/yaml v1.0.0 // indirect github.com/gin-contrib/sse v1.1.0 // indirect github.com/go-kratos/aegis v0.2.0 // indirect - github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-openapi/inflect v0.21.2 // indirect @@ -91,7 +91,7 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.26.0 // indirect github.com/goccy/go-json v0.10.5 // indirect - github.com/golang-cz/devslog v0.0.13 // indirect + github.com/golang-cz/devslog v0.0.14 // indirect github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect @@ -117,7 +117,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/leodido/go-urn v1.4.0 // indirect - github.com/lmittmann/tint v1.0.7 // indirect + github.com/lmittmann/tint v1.1.2 // indirect github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect @@ -154,20 +154,20 @@ require ( gitlab.com/golang-commonmark/mdurl v0.0.0-20191124015652-932350d1cb84 // indirect gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect - go.opentelemetry.io/otel v1.35.0 // indirect - go.opentelemetry.io/otel/metric v1.35.0 // indirect - go.opentelemetry.io/otel/trace v1.35.0 // indirect - golang.org/x/arch v0.17.0 // indirect - golang.org/x/crypto v0.38.0 // indirect - golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect + go.opentelemetry.io/otel v1.36.0 // indirect + go.opentelemetry.io/otel/metric v1.36.0 // indirect + go.opentelemetry.io/otel/trace v1.36.0 // indirect + golang.org/x/arch v0.18.0 // indirect + golang.org/x/crypto v0.39.0 // indirect + golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 // indirect golang.org/x/image v0.26.0 // indirect - golang.org/x/mod v0.24.0 // indirect - golang.org/x/sync v0.14.0 // indirect + golang.org/x/mod v0.25.0 // indirect + golang.org/x/sync v0.15.0 // indirect golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.25.0 // indirect - golang.org/x/tools v0.33.0 // indirect + golang.org/x/text v0.26.0 // indirect + golang.org/x/tools v0.34.0 // indirect google.golang.org/genproto v0.0.0-20250519155744-55703ea1f237 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index f9450ac4..8cc0c554 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,16 @@ ariga.io/atlas v0.32.0 h1:y+77nueMrExLiKlz1CcPKh/nU7VSlWfBbwCShsJyvCw= ariga.io/atlas v0.32.0/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 h1:YhMSc48s25kr7kv31Z8vf7sPUIq5YJva9z1mn/hAt0M= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250613055000-fd99550722dc.1 h1:27bzfkfQ3baaLXt1yrLOUplBRUqy8sptpNqRl+Pb5/A= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250613055000-fd99550722dc.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U= buf.build/go/protovalidate v0.12.0 h1:4GKJotbspQjRCcqZMGVSuC8SjwZ/FmgtSuKDpKUTZew= buf.build/go/protovalidate v0.12.0/go.mod h1:q3PFfbzI05LeqxSwq+begW2syjy2Z6hLxZSkP1OH/D0= +buf.build/go/protovalidate v0.13.0 h1:t7nC2w79q8M2KaZfFTaXmyFhnYWTPbGFtZS2rebdIQM= +buf.build/go/protovalidate v0.13.0/go.mod h1:b0ZWMqcwgx2sa1IXTFT9EpJlMp03ESY4f8t9yulcykg= cel.dev/expr v0.23.1 h1:K4KOtPCJQjVggkARsjG9RWXP6O4R73aHeJMa/dmCQQg= cel.dev/expr v0.23.1/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= +cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY= +cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -605,6 +611,8 @@ cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcPALq2CxzdePw= dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= +dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= entgo.io/ent v0.14.4 h1:/DhDraSLXIkBhyiVoJeSshr4ZYi7femzhj6/TckzZuI= entgo.io/ent v0.14.4/go.mod h1:aDPE/OziPEu8+OWbzy4UlvWmD2/kbRuWfK2A40hcxJM= @@ -659,6 +667,8 @@ github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= +github.com/bytedance/sonic v1.13.3 h1:MS8gmaH16Gtirygw7jV91pDCN33NyMrPbN7qiYhEsF0= +github.com/bytedance/sonic v1.13.3/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY= github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= @@ -699,6 +709,7 @@ github.com/cncf/xds/go v0.0.0-20220314180256-7f1daf1720fc/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 h1:Om6kYQYDUk5wWbT0t0q6pvyM49i9XZAv9dDrkDA7gjk= github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= +github.com/cncf/xds/go v0.0.0-20250326154945-ae57f3c0d45f h1:C5bqEmzEPLsHm9Mv73lSE9e9bKV23aB1vxOsmZrkl3k= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -777,6 +788,8 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= @@ -810,6 +823,8 @@ github.com/goexts/generic v0.3.0/go.mod h1:SZddH3gsbpBCE8JezA87mLXvM0aVrHivRWmnT github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang-cz/devslog v0.0.13 h1:JkJ6PPNSOCBpYyU03v3xw7WgpChQ3AYFqgRbYBhUk/Y= github.com/golang-cz/devslog v0.0.13/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= +github.com/golang-cz/devslog v0.0.14 h1:hZY6VuZ/+MmG4djP9X1YDSmX/z5zPDDVgFlO0fyb+CY= +github.com/golang-cz/devslog v0.0.14/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= @@ -1041,6 +1056,8 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lmittmann/tint v1.0.7 h1:D/0OqWZ0YOGZ6AyC+5Y2kD8PBEzBk6rFHVSfOqCkF9Y= github.com/lmittmann/tint v1.0.7/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= +github.com/lmittmann/tint v1.1.2 h1:2CQzrL6rslrsyjqLDwD11bZ5OpLBPU+g3G/r5LSfS8w= +github.com/lmittmann/tint v1.1.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr325bN2FD2ISlRRztXibcX6e8f5FR5Dc= github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= @@ -1271,8 +1288,12 @@ go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJyS go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= +go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg= +go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E= go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M= go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= +go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE= +go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs= go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= @@ -1280,10 +1301,14 @@ go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6Yv go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o= go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs= go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= +go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w= +go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= golang.org/x/arch v0.17.0 h1:4O3dfLzd+lQewptAHqjewQZQDyEdejz3VwgeYwkZneU= golang.org/x/arch v0.17.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= +golang.org/x/arch v0.18.0 h1:WN9poc33zL4AzGxqf8VtpKUnGvMi8O9lhNyBMF/85qc= +golang.org/x/arch v0.18.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -1302,6 +1327,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= +golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= +golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1319,6 +1346,8 @@ golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMk golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI= golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ= +golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 h1:bsqhLWFR6G6xiQcb+JoGqdKdRU6WzPWmK8E0jxTjzo4= +golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1369,6 +1398,7 @@ golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= +golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1436,6 +1466,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= +golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1486,6 +1518,8 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= +golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1614,6 +1648,8 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= +golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1685,6 +1721,8 @@ golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= +golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo= +golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1906,12 +1944,16 @@ google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34 h1: google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34/go.mod h1:0awUlEkap+Pb1UMeJwJQQAdJQrt3moU7J2moTy69irI= google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 h1:Kog3KlB4xevJlAcbbbzPfRG0+X9fdoGM+UBRKVz6Wr0= google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237/go.mod h1:ezi0AVyMKDWy5xAncvjLWH7UcLBB5n7y2fQ8MzjJcto= +google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 h1:oWVWY3NzT7KJppx2UKhKmzPq4SRe0LdCijVRwvGeikY= +google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822/go.mod h1:h3c4v36UTKzUiuaOKQ6gr3S+0hovBtUrXzTG/i3+XEc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34 h1:h6p3mQqrmT1XkHVTfzLdNz1u7IhINeZkz67/xTbOuWs= google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 h1:cJfm9zPbe1e873mHJzmQ1nwVEeRDU/T1wXDK2kUSU34= google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 h1:fc6jSaCT0vBduLYZHYrBBNY4dsWuvgyff9noRNDdBeE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -1955,6 +1997,8 @@ google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok= +google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/helpers/securityx/security.go b/helpers/securityx/security.go index 857abbc4..c02c8118 100644 --- a/helpers/securityx/security.go +++ b/helpers/securityx/security.go @@ -6,21 +6,28 @@ package securityx import ( - "context" "strings" "github.com/go-kratos/kratos/v2/transport" transhttp "github.com/go-kratos/kratos/v2/transport/http" - msecurity "github.com/origadmin/runtime/agent/middleware/security" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/middleware" + "origadmin/application/admin/api/v1/services/types" + contribsecurity "origadmin/application/admin/contrib/security" "origadmin/application/admin/contrib/security/authn/jwt" "origadmin/application/admin/contrib/security/authz/casbin" "origadmin/application/admin/internal/configs" ) +var ( + ErrInvalidToken = types.ErrorSystemErrorReasonInvalidToken("invalid token") + ErrInvalidAuthorization = types.ErrorSystemErrorReasonInvalidAuthorization("invalid authorization") +) + func NewAuthenticator(bootstrap *configs.Bootstrap, ss ...jwt.Setting) (security.Authenticator, error) { tokenizer, err := jwt.NewTokenizer(bootstrap.GetSecurity().GetSecurity(), ss...) if err != nil { @@ -85,7 +92,7 @@ type SecurityBridge struct { // Authorizer is the authorizer used for the authorization header. Authorizer security.Authorizer // SkipKey is the key used to skip authentication. - SkipKey string + //SkipKey string // PublicPaths are the public paths that do not require authentication. PublicPaths []string // Provider is the role/permission data from the database. @@ -101,7 +108,7 @@ type SecurityBridge struct { } func (obj SecurityBridge) SkipFromContext(ctx context.Context) (context.Context, bool) { - if msecurity.IsSkipped(ctx, obj.SkipKey) { + if context.IsSkipped(ctx) { log.Debugf("NewAuthN: skipping request due to skip key") return ctx, true } @@ -113,7 +120,7 @@ func (obj SecurityBridge) SkipFromContext(ctx context.Context) (context.Context, log.Debugf("NewAuthNServer ServerContext: checking skipper for operation: %+v", tr.Operation()) if obj.Skipper(tr.Operation()) { log.Debugf("NewAuthNServer: skipping request") - ctx := msecurity.WithSkipContextServer(msecurity.NewSkipContext(ctx), obj.SkipKey) + ctx := context.NewSkip(ctx) return ctx, true } } @@ -121,7 +128,7 @@ func (obj SecurityBridge) SkipFromContext(ctx context.Context) (context.Context, log.Debugf("NewAuthNServer ClientContext: checking skipper for operation: %+v", tr.Operation()) if obj.Skipper(tr.Operation()) { log.Debugf("NewAuthNServer: skipping request") - ctx := msecurity.WithSkipContextClient(msecurity.NewSkipContext(ctx), obj.SkipKey) + ctx := context.NewSkip(ctx) return ctx, true } } @@ -170,7 +177,7 @@ func (obj SecurityBridge) Middleware() middleware.KMiddleware { token := obj.TokenParser(ctx) if token == "" { log.Errorf("NewAuthN: missing token, returning error") - return nil, msecurity.ErrInvalidToken + return nil, types.ErrorSystemErrorReasonInvalidToken("missing token") } log.Debugf("NewAuthN: authenticating token") @@ -195,10 +202,10 @@ func (obj SecurityBridge) Middleware() middleware.KMiddleware { } if ok, err := obj.Authorizer.Authorized(ctx, policy, policy.GetAction(), policy.GetObject()); err != nil { log.Errorf("NewAuthN: authorization failed") - return nil, msecurity.ErrInvalidAuthorization + return nil, ErrInvalidAuthorization } else if !ok { log.Errorf("NewAuthN: authorization check failed") - return nil, msecurity.ErrInvalidAuthorization + return nil, ErrInvalidAuthorization } else { log.Debugf("NewAuthN: authorization successful, proceeding with request") } @@ -210,7 +217,7 @@ func (obj SecurityBridge) Middleware() middleware.KMiddleware { } func (obj SecurityBridge) TokenTo(ctx context.Context, token string) context.Context { - return msecurity.TokenToContext(ctx, obj.TokenSource, obj.schemeString(), token) + return contribsecurity.TokenToContext(ctx, obj.TokenSource, obj.schemeString(), token) } func (obj SecurityBridge) policyParser(ctx context.Context, claims security.Claims) (security.Policy, error) { if obj.PolicyParser != nil { @@ -232,8 +239,8 @@ func (obj SecurityBridge) policyParser(ctx context.Context, claims security.Clai req, ok := transhttp.RequestFromServerContext(ctx) if !ok { - log.Errorf("PolicyParser: failed to get request from server context, error: %s", msecurity.ErrInvalidToken.Error()) - return nil, msecurity.ErrInvalidToken + log.Errorf("PolicyParser: failed to get request from server context, error: %s", ErrInvalidToken.Error()) + return nil, ErrInvalidToken } policy := security.RegisteredPolicy{ Subject: claims.GetSubject(), @@ -291,7 +298,6 @@ func DefaultBridge() *SecurityBridge { AuthenticationHeader: security.HeaderAuthorize, Authenticator: nil, Authorizer: nil, - SkipKey: msecurity.MetadataSecuritySkipKey, PublicPaths: nil, Provider: &provider{}, Skipper: func(path string) bool { diff --git a/internal/loader/proxy.go b/internal/loader/proxy.go index 466713b8..679d27af 100644 --- a/internal/loader/proxy.go +++ b/internal/loader/proxy.go @@ -96,7 +96,7 @@ func NewProxyServer( if services[i].GetType() != "http" { continue } - srv, err := runtime.NewHTTPServiceServer(services[i], + srv, err := r.Builder().NewHTTPServer(services[i], servicehttp.WithServerOptions( http.PathPrefix("/api/v1"), http.ErrorEncoder(resp.ResponseErrorEncoder), From d13240a47343acca0be13c8d1354a791e82e9f5b Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 16 Jun 2025 19:03:55 +0800 Subject: [PATCH 045/158] feat(config): add CORS configuration to bootstrap - Add CORS (Cross-Origin Resource Sharing) configuration to Bootstrap_Entry - Update bootstrap.proto to include CORS message- Modify bootstrap_default.go to provide default CORS settings - Adjust proxy.go to use CORS configuration from bootstrap --- internal/configs/bootstrap.pb.go | 37 +++++++++++++++-------- internal/configs/bootstrap.pb.validate.go | 29 ++++++++++++++++++ internal/configs/bootstrap.proto | 4 ++- internal/loader/bootstrap_default.go | 12 ++++++++ internal/loader/proxy.go | 35 ++++++++++++++++++--- 5 files changed, 98 insertions(+), 19 deletions(-) diff --git a/internal/configs/bootstrap.pb.go b/internal/configs/bootstrap.pb.go index 389b925e..85656aab 100644 --- a/internal/configs/bootstrap.pb.go +++ b/internal/configs/bootstrap.pb.go @@ -350,7 +350,8 @@ func (x *Bootstrap_HealthCheck) GetPath() string { type Bootstrap_Entry struct { state protoimpl.MessageState `protogen:"open.v1"` Scheme string `protobuf:"bytes,1,opt,name=scheme,proto3" json:"scheme,omitempty"` - Services []*v1.Service `protobuf:"bytes,2,rep,name=services,proto3" json:"services,omitempty"` + Cors *v1.Cors `protobuf:"bytes,2,opt,name=cors,proto3" json:"cors,omitempty"` + Services []*v1.Service `protobuf:"bytes,3,rep,name=services,proto3" json:"services,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -392,6 +393,13 @@ func (x *Bootstrap_Entry) GetScheme() string { return "" } +func (x *Bootstrap_Entry) GetCors() *v1.Cors { + if x != nil { + return x.Cors + } + return nil +} + func (x *Bootstrap_Entry) GetServices() []*v1.Service { if x != nil { return x.Services @@ -403,11 +411,11 @@ var File_configs_bootstrap_proto protoreflect.FileDescriptor const file_configs_bootstrap_proto_rawDesc = "" + "\n" + - "\x17configs/bootstrap.proto\x12\vapi.configs\x1a\x19config/v1/discovery.proto\x1a\x16config/v1/logger.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1dconfigs/security_config.proto\x1a\x15configs/service.proto\x1a\x1emiddleware/v1/middleware.proto\x1a\x17validate/validate.proto\"[\n" + + "\x17configs/bootstrap.proto\x12\vapi.configs\x1a\x14config/v1/cors.proto\x1a\x19config/v1/discovery.proto\x1a\x16config/v1/logger.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1dconfigs/security_config.proto\x1a\x15configs/service.proto\x1a\x1emiddleware/v1/middleware.proto\x1a\x17validate/validate.proto\"[\n" + "\x13EntrySelectorConfig\x12\x16\n" + "\x06global\x18\x02 \x01(\bR\x06global\x12\x12\n" + "\x04name\x18\x03 \x01(\tR\x04name\x12\x18\n" + - "\aversion\x18\x04 \x01(\tR\aversion\"\xff\x06\n" + + "\aversion\x18\x04 \x01(\tR\aversion\"\xa4\a\n" + "\tBootstrap\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x02 \x01(\tR\aversion\x12 \n" + @@ -430,10 +438,11 @@ const file_configs_bootstrap_proto_rawDesc = "" + "\aclients\x18\xee\a \x03(\v2\x1a.api.configs.ServiceClientR\aclients\x1a;\n" + "\vHealthCheck\x12\x18\n" + "\atimeout\x18\x01 \x01(\x05R\atimeout\x12\x12\n" + - "\x04path\x18\x02 \x01(\tR\x04path\x1aO\n" + + "\x04path\x18\x02 \x01(\tR\x04path\x1at\n" + "\x05Entry\x12\x16\n" + - "\x06scheme\x18\x01 \x01(\tR\x06scheme\x12.\n" + - "\bservices\x18\x02 \x03(\v2\x12.config.v1.ServiceR\bservices\",\n" + + "\x06scheme\x18\x01 \x01(\tR\x06scheme\x12#\n" + + "\x04cors\x18\x02 \x01(\v2\x0f.config.v1.CorsR\x04cors\x12.\n" + + "\bservices\x18\x03 \x03(\v2\x12.config.v1.ServiceR\bservices\",\n" + "\bSettings\x12 \n" + "\vcrypto_type\x18\x01 \x01(\tR\vcrypto_typeB.Z,origadmin/application/admin/internal/configsb\x06proto3" @@ -463,7 +472,8 @@ var file_configs_bootstrap_proto_goTypes = []any{ (*v1.Logger)(nil), // 9: config.v1.Logger (*ServiceServer)(nil), // 10: api.configs.ServiceServer (*ServiceClient)(nil), // 11: api.configs.ServiceClient - (*v1.Service)(nil), // 12: config.v1.Service + (*v1.Cors)(nil), // 12: config.v1.Cors + (*v1.Service)(nil), // 13: config.v1.Service } var file_configs_bootstrap_proto_depIdxs = []int32{ 4, // 0: api.configs.Bootstrap.entry:type_name -> api.configs.Bootstrap.Entry @@ -475,12 +485,13 @@ var file_configs_bootstrap_proto_depIdxs = []int32{ 9, // 6: api.configs.Bootstrap.logger:type_name -> config.v1.Logger 10, // 7: api.configs.Bootstrap.server:type_name -> api.configs.ServiceServer 11, // 8: api.configs.Bootstrap.clients:type_name -> api.configs.ServiceClient - 12, // 9: api.configs.Bootstrap.Entry.services:type_name -> config.v1.Service - 10, // [10:10] is the sub-list for method output_type - 10, // [10:10] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name + 12, // 9: api.configs.Bootstrap.Entry.cors:type_name -> config.v1.Cors + 13, // 10: api.configs.Bootstrap.Entry.services:type_name -> config.v1.Service + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_configs_bootstrap_proto_init() } diff --git a/internal/configs/bootstrap.pb.validate.go b/internal/configs/bootstrap.pb.validate.go index 37ec2308..9f958490 100644 --- a/internal/configs/bootstrap.pb.validate.go +++ b/internal/configs/bootstrap.pb.validate.go @@ -781,6 +781,35 @@ func (m *Bootstrap_Entry) validate(all bool) error { // no validation rules for Scheme + if all { + switch v := interface{}(m.GetCors()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, Bootstrap_EntryValidationError{ + field: "Cors", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, Bootstrap_EntryValidationError{ + field: "Cors", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCors()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return Bootstrap_EntryValidationError{ + field: "Cors", + reason: "embedded message failed validation", + cause: err, + } + } + } + for idx, item := range m.GetServices() { _, _ = idx, item diff --git a/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto index 7637a145..e7f90d94 100644 --- a/internal/configs/bootstrap.proto +++ b/internal/configs/bootstrap.proto @@ -2,6 +2,7 @@ syntax = "proto3"; package api.configs; +import "config/v1/cors.proto"; import "config/v1/discovery.proto"; import "config/v1/logger.proto"; import "config/v1/service.proto"; @@ -53,7 +54,8 @@ message Bootstrap { // Entry message Entry { string scheme = 1 [json_name = "scheme"]; - repeated config.v1.Service services = 2 [json_name = "services"]; + config.v1.Cors cors = 2 [json_name = "cors"]; + repeated config.v1.Service services = 3 [json_name = "services"]; } string id = 100 [json_name = "id"]; diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go index b368bb4a..fb93c820 100644 --- a/internal/loader/bootstrap_default.go +++ b/internal/loader/bootstrap_default.go @@ -37,6 +37,7 @@ func DefaultBootstrap() *configs.Bootstrap { Entry: &configs.Bootstrap_Entry{ Scheme: "http", Services: DefaultServices(), + Cors: DefaultEntryCors(), }, Server: &configs.ServiceServer{ Services: DefaultServices(), @@ -100,6 +101,17 @@ func DefaultBootstrap() *configs.Bootstrap { } } +func DefaultEntryCors() *configv1.Cors { + return &configv1.Cors{ + AllowOrigins: []string{"*"}, + AllowMethods: []string{"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS"}, + AllowHeaders: []string{"X-Requested-With", "Content-Type", "Authorization"}, + ExposeHeaders: []string{"*"}, + AllowCredentials: false, + MaxAge: 0, + } +} + func DefaultServices() []*configv1.Service { return []*configv1.Service{ { diff --git a/internal/loader/proxy.go b/internal/loader/proxy.go index 679d27af..fe05bd48 100644 --- a/internal/loader/proxy.go +++ b/internal/loader/proxy.go @@ -15,6 +15,7 @@ import ( "github.com/go-kratos/kratos/v2/transport/http" "github.com/gorilla/handlers" "github.com/origadmin/runtime" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" @@ -100,11 +101,7 @@ func NewProxyServer( servicehttp.WithServerOptions( http.PathPrefix("/api/v1"), http.ErrorEncoder(resp.ResponseErrorEncoder), - http.Filter(handlers.CORS( - handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), - handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS"}), - handlers.AllowedOrigins([]string{"*"}), - ))), + http.Filter(BuildProxyCors(bootstrap.GetEntry().GetCors()))), servicehttp.WithMiddlewares(ms...), servicehttp.WithPrefix(runtime.DefaultEnvPrefix), ) @@ -123,6 +120,34 @@ func NewProxyServer( return servers } +func BuildProxyCors(cors *configv1.Cors) http.FilterFunc { + if cors == nil { + return nil + } + options := []handlers.CORSOption{ + handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), + handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS"}), + handlers.AllowedOrigins([]string{"*"}), + } + if cors.GetAllowCredentials() { + options = append(options, handlers.AllowCredentials()) + } + if cors.GetMaxAge() > 0 { + options = append(options, handlers.MaxAge(int(cors.GetMaxAge()))) + } + if len(cors.GetAllowHeaders()) > 0 { + options = append(options, handlers.AllowedHeaders(cors.GetAllowHeaders())) + } + if len(cors.GetAllowMethods()) > 0 { + options = append(options, handlers.AllowedMethods(cors.GetAllowMethods())) + } + + if len(cors.GetAllowOrigins()) > 0 { + options = append(options, handlers.AllowedOrigins(cors.GetAllowOrigins())) + } + return handlers.CORS(options...) +} + func DefaultPaths() []string { return []string{ auth.OperationLoginServiceCaptchaId, From 80fa1a014fae552665676d0e8881a7d55b5f7b54 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 17 Jun 2025 14:34:04 +0800 Subject: [PATCH 046/158] test(auth): refactor token generation and authentication process - Reorganized test structure to use new data and service modules - Implemented mock data for testing instead of using actual database - Updated token generation process to use new auth service - Improved code readability and reduced complexity in test setup --- test/token_test.go | 135 ++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 68 deletions(-) diff --git a/test/token_test.go b/test/token_test.go index 3009b294..dd5590d9 100644 --- a/test/token_test.go +++ b/test/token_test.go @@ -9,104 +9,96 @@ import ( "context" "testing" - _ "origadmin/application/admin/contrib/consul/config" - _ "origadmin/application/admin/contrib/consul/registry" - _ "github.com/origadmin/contrib/database" - "github.com/origadmin/runtime/bootstrap" + "github.com/go-kratos/kratos/v2/encoding" + "github.com/origadmin/runtime" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/toolkits/codec/toml" + pb "origadmin/application/admin/api/v1/services/auth" + _ "origadmin/application/admin/contrib/consul/config" + _ "origadmin/application/admin/contrib/consul/registry" + _ "origadmin/application/admin/contrib/database" "origadmin/application/admin/contrib/security/authz/casbin" "origadmin/application/admin/helpers/securityx" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/loader" - "origadmin/application/admin/internal/mods/system/dal" - "origadmin/application/admin/internal/mods/system/server" + "origadmin/application/admin/internal/mods/auth/dal" + "origadmin/application/admin/internal/mods/auth/service" ) -type data struct { +type mockData struct { } -func (d data) QueryRoles(ctx context.Context, subject string) ([]string, error) { +func (d mockData) QueryRoles(ctx context.Context, subject string) ([]string, error) { return []string{ "role_1", }, nil } -func (d data) QueryPermissions(ctx context.Context, subject string) ([]string, error) { +func (d mockData) QueryPermissions(ctx context.Context, subject string) ([]string, error) { return []string{ "user_1", }, nil } +func init() { + encoding.RegisterCodec(toml.Codec) +} + func TestGenerateToken(t *testing.T) { - bs, err := loader.LoadBootstrap(&loader.Bootstrap{ - Flags: bootstrap.Flags{}, - WorkDir: "", - ConfigPath: "D:\\workspace\\project\\golang\\origadmin\\backend\\resources\\configs\\config_test.toml", - Env: "", - Daemon: false, - }) + sourceConfig := &configv1.SourceConfig{ + Types: []string{"file"}, + File: &configv1.SourceConfig_File{ + Path: "..\\resources\\configs\\config_test.toml", + }, + } + bootstrap, err := loader.LoadBootstrap(sourceConfig) if err != nil { t.Fatalf("failed to load bootstrap: %v", err) } - dd, cleanup, err := dal.NewData(bs, nil) + r := runtime.Global() + dataData, cleanup, err := data.NewData(r, bootstrap) if err != nil { - t.Fatalf("failed to new dd: %v", err) + return } defer cleanup() - //casbinRepo, err := dal.NewCasbinSourceRepo(dd) + authRepo := dal.NewAuthRepo(r, dataData) + //authServiceBiz := biz.NewAuthServiceBiz(r, authRepo) + //authServiceServer := service.NewAuthServiceServerPB(authServiceBiz) + //casbinSourceRepo, err := dal.NewCasbinSourceRepo(dataData) //if err != nil { - // t.Fatalf("failed to new casbin source repo: %v", err) + // cleanup() + // return //} - resourceRepo := dal.NewResourceRepo(dd, nil) - roleRepo := dal.NewRoleRepo(dd, nil) - userRepo := dal.NewUserRepo(dd, nil) - basisConfig := loader.NewBasisConfig(bs) - //v, err := server.NewSystemClient(bs, nil) + //casbinSourceServiceBiz := biz.NewCasbinSourceServiceBiz(r, casbinSourceRepo) + //casbinSourceServiceServer := service.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) + //tokenizer, err := data.NewTokenizer(bootstrap) //if err != nil { - // t.Fatalf("failed to new system client: %v", err) + // cleanup() + // return //} - //auth := system.NewAuthServiceClient(v) - tokenizer, err := loader.NewTokenizer(bs) + //refreshTokenizer := dal.RefreshTokenizer(tokenizer) + //loginData := data.NewLoginData(bootstrap, refreshTokenizer) + //loginRepo := dal.NewLoginRepo(dataData, loginData) + //loginServiceBiz := biz.NewLoginServiceBiz(r, loginRepo) + //loginServiceServer := service.NewLoginServiceServerPB(loginServiceBiz) + //personalRepo := dal.NewPersonalRepo(r, dataData) + //personalServiceBiz := biz.NewPersonalServiceBiz(r, personalRepo) + //personalServiceServer := service.NewPersonalServiceServerPB(r, personalServiceBiz) + //registerServer := service.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) + //v := server.NewAuthServer(r, bootstrap, registerServer) + authenticator, err := securityx.NewAuthenticator(bootstrap) if err != nil { - t.Fatalf("failed to new tokenizer: %v", err) + panic(err) } - refreshTokenizer := dal.RefreshTokenizer(tokenizer) - loginData := &dal.LoginData{ - Tokenizer: refreshTokenizer, - Resource: resourceRepo, - Role: roleRepo, - User: userRepo, + clients := loader.NewProxyGRPCClients(r, bootstrap) + ruleSource := service.NewCasbinSourceClient(r, clients) + opts := []casbin.AuthorizerOption{ + casbin.WithSource(ruleSource), } - ctx := context.Background() - claims, err := loginData.Tokenizer.CreateClaims(ctx, "user_1") - if err != nil { - return - } - token, err := loginData.Tokenizer.CreateToken(ctx, claims) - if err != nil { - t.Fatalf("failed to create token: %v", err) - } - t.Logf("token: %s", token) - v, err := server.NewSystemClient(bs, nil) - if err != nil { - t.Fatalf("failed to new system client: %v", err) - } - //registerAgent, err := server.NewSystemServiceAgentClient(v, nil) - //if err != nil { - // t.Fatalf("failed to new system service agent client: %v", err) - //} - //_ := agent.NewRegisterAgent(registerAgent) - casbinSourceServiceClient := server.NewCasbinServiceClient(v, nil) - _ = casbinSourceServiceClient - //casbinBiz := biz.NewCasbinSourceServiceBiz(casbinRepo, nil) - //client := service.NewCasbinSourceServiceServerPB(casbinBiz) - authenticator, err := securityx.NewAuthenticator(bs) - if err != nil { - panic(err) - } - //adapter := casbin.NewAdapter() - authorizer, err := securityx.NewAuthorizer(bs, casbin.WithSource(casbinSourceServiceClient)) + authorizer, err := securityx.NewAuthorizer(bootstrap, opts...) if err != nil { panic(err) } @@ -117,17 +109,24 @@ func TestGenerateToken(t *testing.T) { Object: "/api/v1/sys/users", Action: "GET", Domain: "*", - //Roles: roles, - //Permissions: permissions, }, nil } bridge.Authenticator = authenticator bridge.Authorizer = authorizer - claims2, err := bridge.Authenticator.Authenticate(ctx, token) + ctx := context.Background() + token, err := authRepo.CreateToken(ctx, &pb.CreateTokenRequest{ + Data: &pb.CreateTokenRequest_Data{ + UserId: "user_1", + }, + }) + if err != nil { + t.Fatalf("failed to create token: %v", err) + } + claims, err := bridge.Authenticator.Authenticate(ctx, token.GetToken()) if err != nil { t.Fatalf("failed to authenticate: %v", err) } - policy, err := bridge.PolicyParser(ctx, claims2) + policy, err := bridge.PolicyParser(ctx, claims) if err != nil { t.Fatalf("failed to parse policy: %v", err) } From 2eed19ca09115ec979ef13cf8d297ef005128711 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 17 Jun 2025 16:18:54 +0800 Subject: [PATCH 047/158] refactor(admin): modularize wire providers for auth and system modules - Separated wire providers into individual modules for auth and system - Created new provider.go files to consolidate module-specific providers - Updated wire_gen.go files to use new module-specific provider sets - Renamed loader to gateway for better naming convention - Removed redundant provider sets from service and dal packages --- cmd/auth/wire_gen.go | 5 ++- cmd/internal/start/wire.go | 3 ++ cmd/internal/start/wire_gen.go | 12 +++--- cmd/system/wire_gen.go | 5 ++- internal/loader/load.go | 10 ----- internal/loader/provider.go | 14 +++++++ internal/mods/auth/biz/biz.go | 9 ---- internal/mods/auth/biz/provider.go | 18 ++++++++ internal/mods/auth/dal/dal.go | 11 ----- internal/mods/auth/dal/provider.go | 20 +++++++++ internal/mods/auth/service/provider.go | 47 +++++++++++++++++++++ internal/mods/auth/service/service.go | 38 ----------------- internal/{loader => mods/gateway}/proxy.go | 12 +++++- internal/mods/system/biz/biz.go | 13 ------ internal/mods/system/biz/provider.go | 22 ++++++++++ internal/mods/system/dal/dal.go | 14 ------- internal/mods/system/dal/provider.go | 24 +++++++++++ internal/mods/system/service/provider.go | 48 ++++++++++++++++++++++ internal/mods/system/service/service.go | 39 ------------------ 19 files changed, 220 insertions(+), 144 deletions(-) create mode 100644 internal/loader/provider.go create mode 100644 internal/mods/auth/biz/provider.go create mode 100644 internal/mods/auth/dal/provider.go create mode 100644 internal/mods/auth/service/provider.go rename internal/{loader => mods/gateway}/proxy.go (98%) create mode 100644 internal/mods/system/biz/provider.go create mode 100644 internal/mods/system/dal/provider.go create mode 100644 internal/mods/system/service/provider.go diff --git a/cmd/auth/wire_gen.go b/cmd/auth/wire_gen.go index 11603dbc..5534ae47 100644 --- a/cmd/auth/wire_gen.go +++ b/cmd/auth/wire_gen.go @@ -21,6 +21,7 @@ import ( _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" ) // Injectors from wire.go: @@ -54,8 +55,8 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap personalRepo := dal.NewPersonalRepo(r, dataData) personalServiceBiz := biz.NewPersonalServiceBiz(r, personalRepo) personalServiceServer := service.NewPersonalServiceServerPB(r, personalServiceBiz) - registerServer := service.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) - v := server.NewAuthServer(r, bootstrap, registerServer) + authServerRegistrar := service.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) + v := server.NewAuthServer(r, bootstrap, authServerRegistrar) app := NewApp(r, v) return app, func() { cleanup() diff --git a/cmd/internal/start/wire.go b/cmd/internal/start/wire.go index b6db8d6f..a6ba65db 100644 --- a/cmd/internal/start/wire.go +++ b/cmd/internal/start/wire.go @@ -19,6 +19,7 @@ import ( authbiz "origadmin/application/admin/internal/mods/auth/biz" authdal "origadmin/application/admin/internal/mods/auth/dal" authservice "origadmin/application/admin/internal/mods/auth/service" + "origadmin/application/admin/internal/mods/gateway" systembiz "origadmin/application/admin/internal/mods/system/biz" systemdal "origadmin/application/admin/internal/mods/system/dal" systemservice "origadmin/application/admin/internal/mods/system/service" @@ -37,6 +38,7 @@ func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*krat authdal.ProviderSet, authbiz.ProviderSet, authservice.LocalProviderSet, + gateway.ProviderSet, NewApp)) } @@ -45,6 +47,7 @@ func buildRemoteInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kra loader.ProviderSet, systemservice.RemoteProviderSet, authservice.RemoteProviderSet, + gateway.ProviderSet, NewApp, )) } diff --git a/cmd/internal/start/wire_gen.go b/cmd/internal/start/wire_gen.go index 8129e130..673a3972 100644 --- a/cmd/internal/start/wire_gen.go +++ b/cmd/internal/start/wire_gen.go @@ -15,6 +15,7 @@ import ( biz2 "origadmin/application/admin/internal/mods/auth/biz" dal2 "origadmin/application/admin/internal/mods/auth/dal" service2 "origadmin/application/admin/internal/mods/auth/service" + "origadmin/application/admin/internal/mods/gateway" "origadmin/application/admin/internal/mods/system/biz" "origadmin/application/admin/internal/mods/system/dal" "origadmin/application/admin/internal/mods/system/service" @@ -24,6 +25,7 @@ import ( _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" ) // Injectors from wire.go: @@ -73,12 +75,12 @@ func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*krat authServerRegistrar := service2.NewRegisterBridgeServer(r, authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) v := loader.NewServiceServerRegistrars(systemServerRegistrar, authServerRegistrar) ruleSource := service2.NewCasbinSourceBiz(r, casbinSourceServiceBiz) - proxyOptions, err := loader.NewProxyOptions(r, bootstrap, ruleSource) + proxyOptions, err := gateway.NewProxyOptions(r, bootstrap, ruleSource) if err != nil { cleanup() return nil, nil, err } - v2 := loader.NewProxyServer(r, bootstrap, v, proxyOptions) + v2 := gateway.NewProxyServer(r, bootstrap, v, proxyOptions) app := NewApp(r, v2) return app, func() { cleanup() @@ -86,7 +88,7 @@ func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*krat } func buildRemoteInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { - v := loader.NewProxyGRPCClients(r, bootstrap) + v := gateway.NewProxyGRPCClients(r, bootstrap) resourceServiceServer := service.NewResourceServiceBridgeClient(r, v) roleServiceServer := service.NewRoleServiceBridgeClient(r, v) userServiceServer := service.NewUserServiceBridgeClient(r, v) @@ -99,11 +101,11 @@ func buildRemoteInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kra authServerRegistrar := service2.NewRegisterBridgeServer(r, authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) v2 := loader.NewServiceServerRegistrars(systemServerRegistrar, authServerRegistrar) ruleSource := service2.NewCasbinSourceClient(r, v) - proxyOptions, err := loader.NewProxyOptions(r, bootstrap, ruleSource) + proxyOptions, err := gateway.NewProxyOptions(r, bootstrap, ruleSource) if err != nil { return nil, nil, err } - v3 := loader.NewProxyServer(r, bootstrap, v2, proxyOptions) + v3 := gateway.NewProxyServer(r, bootstrap, v2, proxyOptions) app := NewApp(r, v3) return app, func() { }, nil diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index b82cd904..5f4ba22c 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -21,6 +21,7 @@ import ( _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" ) // Injectors from wire.go: @@ -43,8 +44,8 @@ func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.Ap permissionRepo := dal.NewPermissionRepo(r, dataData) permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) permissionServiceServer := service.NewPermissionServiceServerPB(r, permissionServiceBiz) - registerServer := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) - v := server.NewSystemServer(r, bootstrap, registerServer) + systemServerRegistrar := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + v := server.NewSystemServer(r, bootstrap, systemServerRegistrar) app := NewApp(r, v) return app, func() { cleanup() diff --git a/internal/loader/load.go b/internal/loader/load.go index 84ad2e64..ceada333 100644 --- a/internal/loader/load.go +++ b/internal/loader/load.go @@ -32,16 +32,6 @@ type AppOptions struct { Server transport.Server } -var ( - ProviderSet = wire.NewSet( - NewServiceServerRegistrars, - NewProxyOptions, - NewProxyServer, - NewProxyGRPCClients, - NewProxyHTTPClients, - ) -) - var ( _ *gins.Server _ *http.Server diff --git a/internal/loader/provider.go b/internal/loader/provider.go new file mode 100644 index 00000000..4dd7bbb6 --- /dev/null +++ b/internal/loader/provider.go @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package loader implements the functions, types, and interfaces for the module. +package loader + +import ( + "github.com/google/wire" +) + +var ProviderSet = wire.NewSet( + NewServiceServerRegistrars, +) diff --git a/internal/mods/auth/biz/biz.go b/internal/mods/auth/biz/biz.go index f2c33884..ea170208 100644 --- a/internal/mods/auth/biz/biz.go +++ b/internal/mods/auth/biz/biz.go @@ -5,18 +5,9 @@ package biz import ( - "github.com/google/wire" "github.com/origadmin/runtime/interfaces/pagination" ) -// ProviderSet is biz providers. -var ProviderSet = wire.NewSet( - NewAuthServiceBiz, - NewLoginServiceBiz, - NewPersonalServiceBiz, - NewCasbinSourceServiceBiz, -) - var ( defaultLimiter = pagination.DefaultLimiter() ) diff --git a/internal/mods/auth/biz/provider.go b/internal/mods/auth/biz/provider.go new file mode 100644 index 00000000..82359c2a --- /dev/null +++ b/internal/mods/auth/biz/provider.go @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz implements the functions, types, and interfaces for the module. +package biz + +import ( + "github.com/google/wire" +) + +// ProviderSet is biz providers. +var ProviderSet = wire.NewSet( + NewAuthServiceBiz, + NewLoginServiceBiz, + NewPersonalServiceBiz, + NewCasbinSourceServiceBiz, +) diff --git a/internal/mods/auth/dal/dal.go b/internal/mods/auth/dal/dal.go index 2aed6c31..6d771a97 100644 --- a/internal/mods/auth/dal/dal.go +++ b/internal/mods/auth/dal/dal.go @@ -11,7 +11,6 @@ import ( "entgo.io/ent/dialect" "github.com/google/uuid" - "github.com/google/wire" "github.com/origadmin/entslog/v3" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" @@ -31,16 +30,6 @@ type Data struct { *data.Data } -// ProviderSet is data providers. -var ProviderSet = wire.NewSet( - //NewData, - NewAuthRepo, - NewLoginRepo, - NewCasbinSourceRepo, - NewPersonalRepo, - RefreshTokenizer, -) - const FKSuffix = "_fk=1" var random = rand.NewRand(rand.KindDigit | rand.KindLowerCase | rand.KindUpperCase) diff --git a/internal/mods/auth/dal/provider.go b/internal/mods/auth/dal/provider.go new file mode 100644 index 00000000..70d8ceda --- /dev/null +++ b/internal/mods/auth/dal/provider.go @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dal implements the functions, types, and interfaces for the module. +package dal + +import ( + "github.com/google/wire" +) + +// ProviderSet is data providers. +var ProviderSet = wire.NewSet( + //NewData, + NewAuthRepo, + NewLoginRepo, + NewCasbinSourceRepo, + NewPersonalRepo, + RefreshTokenizer, +) diff --git a/internal/mods/auth/service/provider.go b/internal/mods/auth/service/provider.go new file mode 100644 index 00000000..6b2a4dad --- /dev/null +++ b/internal/mods/auth/service/provider.go @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package service implements the functions, types, and interfaces for the module. +package service + +import ( + "github.com/google/wire" +) + +// ProviderSet is service providers. +var ProviderSet = wire.NewSet( + NewRegisterServer, + NewAuthServiceServerPB, + NewAuthServiceHTTPServerPB, + NewCasbinSourceServiceServerPB, + NewCasbinSourceServiceHTTPServerPB, + NewLoginServiceServerPB, + NewLoginServiceHTTPServerPB, + NewPersonalServiceServerPB, + NewPersonalServiceHTTPServerPB, + NewCasbinSourceBiz, +) + +// LocalProviderSet is service providers. +var LocalProviderSet = wire.NewSet( + NewRegisterBridgeServer, + NewAuthServiceServerPB, + NewAuthServiceHTTPServerPB, + NewCasbinSourceServiceServerPB, + NewCasbinSourceServiceHTTPServerPB, + NewLoginServiceServerPB, + NewLoginServiceHTTPServerPB, + NewPersonalServiceServerPB, + NewPersonalServiceHTTPServerPB, + NewCasbinSourceBiz, +) + +var RemoteProviderSet = wire.NewSet( + NewRegisterBridgeServer, + NewAuthServiceBridgeClient, + NewCasbinServiceBridgeClient, + NewLoginServiceBridgeClient, + NewPersonalServiceBridgeClient, + NewCasbinSourceClient, +) diff --git a/internal/mods/auth/service/service.go b/internal/mods/auth/service/service.go index d3346e34..9bcfac99 100644 --- a/internal/mods/auth/service/service.go +++ b/internal/mods/auth/service/service.go @@ -7,7 +7,6 @@ package service import ( "context" - "github.com/google/wire" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -15,43 +14,6 @@ import ( pb "origadmin/application/admin/api/v1/services/auth" ) -// ProviderSet is service providers. -var ProviderSet = wire.NewSet( - NewRegisterServer, - NewAuthServiceServerPB, - NewAuthServiceHTTPServerPB, - NewCasbinSourceServiceServerPB, - NewCasbinSourceServiceHTTPServerPB, - NewLoginServiceServerPB, - NewLoginServiceHTTPServerPB, - NewPersonalServiceServerPB, - NewPersonalServiceHTTPServerPB, - NewCasbinSourceBiz, -) - -// LocalProviderSet is service providers. -var LocalProviderSet = wire.NewSet( - NewRegisterBridgeServer, - NewAuthServiceServerPB, - NewAuthServiceHTTPServerPB, - NewCasbinSourceServiceServerPB, - NewCasbinSourceServiceHTTPServerPB, - NewLoginServiceServerPB, - NewLoginServiceHTTPServerPB, - NewPersonalServiceServerPB, - NewPersonalServiceHTTPServerPB, - NewCasbinSourceBiz, -) - -var RemoteProviderSet = wire.NewSet( - NewRegisterBridgeServer, - NewAuthServiceBridgeClient, - NewCasbinServiceBridgeClient, - NewLoginServiceBridgeClient, - NewPersonalServiceBridgeClient, - NewCasbinSourceClient, -) - type AuthServerRegistrar service.ServerRegistrar type RegisterServer struct { diff --git a/internal/loader/proxy.go b/internal/mods/gateway/proxy.go similarity index 98% rename from internal/loader/proxy.go rename to internal/mods/gateway/proxy.go index fe05bd48..1fd2893b 100644 --- a/internal/loader/proxy.go +++ b/internal/mods/gateway/proxy.go @@ -3,7 +3,7 @@ */ // Package loader implements the functions, types, and interfaces for the module. -package loader +package gateway import ( "strings" @@ -13,6 +13,7 @@ import ( "github.com/go-kratos/kratos/v2/middleware/selector" "github.com/go-kratos/kratos/v2/transport" "github.com/go-kratos/kratos/v2/transport/http" + "github.com/google/wire" "github.com/gorilla/handlers" "github.com/origadmin/runtime" configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" @@ -31,6 +32,15 @@ import ( "origadmin/application/admin/internal/configs" ) +var ( + ProviderSet = wire.NewSet( + NewProxyOptions, + NewProxyServer, + NewProxyGRPCClients, + NewProxyHTTPClients, + ) +) + type ProxyOptions struct { Authenticator security.Authenticator Authorizer security.Authorizer diff --git a/internal/mods/system/biz/biz.go b/internal/mods/system/biz/biz.go index 39c864e0..0e4b98d9 100644 --- a/internal/mods/system/biz/biz.go +++ b/internal/mods/system/biz/biz.go @@ -7,25 +7,12 @@ package biz import ( "net/http" - "github.com/google/wire" "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/toolkits/errors/httperr" typespb "origadmin/application/admin/api/v1/services/types" ) -// ProviderSet is biz providers. -var ProviderSet = wire.NewSet( - //NewAuthServiceBiz, - //NewLoginServiceBiz, - //NewPersonalServiceBiz, - NewResourceServiceBiz, - NewRoleServiceBiz, - NewUserServiceBiz, - NewPermissionServiceBiz, - //NewCasbinSourceServiceBiz, -) - var ( // ErrUserNotFound is user not found. ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") diff --git a/internal/mods/system/biz/provider.go b/internal/mods/system/biz/provider.go new file mode 100644 index 00000000..8e15c2fc --- /dev/null +++ b/internal/mods/system/biz/provider.go @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz implements the functions, types, and interfaces for the module. +package biz + +import ( + "github.com/google/wire" +) + +// ProviderSet is biz providers. +var ProviderSet = wire.NewSet( + //NewAuthServiceBiz, + //NewLoginServiceBiz, + //NewPersonalServiceBiz, + NewResourceServiceBiz, + NewRoleServiceBiz, + NewUserServiceBiz, + NewPermissionServiceBiz, + //NewCasbinSourceServiceBiz, +) diff --git a/internal/mods/system/dal/dal.go b/internal/mods/system/dal/dal.go index 7814e1f7..18173605 100644 --- a/internal/mods/system/dal/dal.go +++ b/internal/mods/system/dal/dal.go @@ -7,17 +7,3 @@ package dal import ( "github.com/google/wire" ) - -// ProviderSet is data providers. -var ProviderSet = wire.NewSet( - //NewAuthRepo, - //NewLoginRepo, - //NewPersonalRepo, - NewMenuRepo, - NewResourceRepo, - NewRoleRepo, - NewUserRepo, - NewPermissionRepo, - //NewCasbinSourceRepo, - //RefreshTokenizer, -) diff --git a/internal/mods/system/dal/provider.go b/internal/mods/system/dal/provider.go new file mode 100644 index 00000000..e013feb9 --- /dev/null +++ b/internal/mods/system/dal/provider.go @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dal implements the functions, types, and interfaces for the module. +package dal + +import ( + "github.com/google/wire" +) + +// ProviderSet is data providers. +var ProviderSet = wire.NewSet( + //NewAuthRepo, + //NewLoginRepo, + //NewPersonalRepo, + NewMenuRepo, + NewResourceRepo, + NewRoleRepo, + NewUserRepo, + NewPermissionRepo, + //NewCasbinSourceRepo, + //RefreshTokenizer, +) diff --git a/internal/mods/system/service/provider.go b/internal/mods/system/service/provider.go new file mode 100644 index 00000000..99a2a1d1 --- /dev/null +++ b/internal/mods/system/service/provider.go @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package service implements the functions, types, and interfaces for the module. +package service + +import ( + "github.com/google/wire" +) + +// ProviderSet is service providers. +var ProviderSet = wire.NewSet( + NewRegisterServer, + NewResourceServiceServerPB, + NewResourceServiceHTTPServerPB, + NewRoleServiceServerPB, + NewRoleServiceHTTPServerPB, + NewUserServiceServerPB, + NewUserServiceHTTPServerPB, + NewPermissionServiceServerPB, + NewPermissionServiceHTTPServerPB, +) + +// LocalProviderSet is service providers. +var LocalProviderSet = wire.NewSet( + NewRegisterBridgeServer, + NewResourceServiceServerPB, + NewResourceServiceHTTPServerPB, + NewRoleServiceServerPB, + NewRoleServiceHTTPServerPB, + NewUserServiceServerPB, + NewUserServiceHTTPServerPB, + NewPermissionServiceServerPB, + NewPermissionServiceHTTPServerPB, +) + +var RemoteProviderSet = wire.NewSet( + NewRegisterBridgeServer, + NewResourceServiceBridgeClient, + //NewResourceServiceBridge, + NewRoleServiceBridgeClient, + //NewRoleServiceBridge, + NewUserServiceBridgeClient, + //NewUserServiceBridge, + NewPermissionServiceBridgeClient, + //NewPermissionServiceBridge, +) diff --git a/internal/mods/system/service/service.go b/internal/mods/system/service/service.go index c153a798..8bca0e67 100644 --- a/internal/mods/system/service/service.go +++ b/internal/mods/system/service/service.go @@ -7,7 +7,6 @@ package service import ( "context" - "github.com/google/wire" "github.com/origadmin/runtime" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" @@ -15,44 +14,6 @@ import ( pb "origadmin/application/admin/api/v1/services/system" ) -// ProviderSet is service providers. -var ProviderSet = wire.NewSet( - NewRegisterServer, - NewResourceServiceServerPB, - NewResourceServiceHTTPServerPB, - NewRoleServiceServerPB, - NewRoleServiceHTTPServerPB, - NewUserServiceServerPB, - NewUserServiceHTTPServerPB, - NewPermissionServiceServerPB, - NewPermissionServiceHTTPServerPB, -) - -// LocalProviderSet is service providers. -var LocalProviderSet = wire.NewSet( - NewRegisterBridgeServer, - NewResourceServiceServerPB, - NewResourceServiceHTTPServerPB, - NewRoleServiceServerPB, - NewRoleServiceHTTPServerPB, - NewUserServiceServerPB, - NewUserServiceHTTPServerPB, - NewPermissionServiceServerPB, - NewPermissionServiceHTTPServerPB, -) - -var RemoteProviderSet = wire.NewSet( - NewRegisterBridgeServer, - NewResourceServiceBridgeClient, - //NewResourceServiceBridge, - NewRoleServiceBridgeClient, - //NewRoleServiceBridge, - NewUserServiceBridgeClient, - //NewUserServiceBridge, - NewPermissionServiceBridgeClient, - //NewPermissionServiceBridge, -) - type SystemServerRegistrar service.ServerRegistrar type RegisterServer struct { From 4cc0fa935b25dc4a48a51145fa20127e9e035f98 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 17 Jun 2025 18:30:55 +0800 Subject: [PATCH 048/158] refactor(wire_gen): reorganize package imports and update entity definitions - Reorder package imports for better readability - Update entity definition for department to use ent framework - Adjust variable names and package references across the file --- cmd/internal/start/wire_gen.go | 98 +- .../data/entity/ent/department/department.go | 358 ++++ internal/data/entity/ent/department/where.go | 726 +++++++ .../data/entity/ent/permission/permission.go | 403 ++++ internal/data/entity/ent/permission/where.go | 609 ++++++ .../permissionresource/permissionresource.go | 171 ++ .../entity/ent/permissionresource/where.go | 166 ++ internal/data/entity/ent/position/position.go | 323 +++ internal/data/entity/ent/position/where.go | 511 +++++ .../positionpermission/positionpermission.go | 171 ++ .../entity/ent/positionpermission/where.go | 166 ++ internal/data/entity/ent/resource/resource.go | 427 ++++ internal/data/entity/ent/resource/where.go | 1218 +++++++++++ internal/data/entity/ent/role/role.go | 322 +++ internal/data/entity/ent/role/where.go | 598 ++++++ .../ent/rolepermission/rolepermission.go | 171 ++ .../data/entity/ent/rolepermission/where.go | 166 ++ internal/data/entity/ent/user/user.go | 625 ++++++ internal/data/entity/ent/user/where.go | 1794 +++++++++++++++++ .../ent/userdepartment/userdepartment.go | 171 ++ .../data/entity/ent/userdepartment/where.go | 166 ++ .../entity/ent/userposition/userposition.go | 171 ++ .../data/entity/ent/userposition/where.go | 166 ++ internal/data/entity/ent/userrole/userrole.go | 171 ++ internal/data/entity/ent/userrole/where.go | 166 ++ internal/mods/gateway/proxy.go | 13 +- 26 files changed, 9989 insertions(+), 58 deletions(-) create mode 100644 internal/data/entity/ent/department/department.go create mode 100644 internal/data/entity/ent/department/where.go create mode 100644 internal/data/entity/ent/permission/permission.go create mode 100644 internal/data/entity/ent/permission/where.go create mode 100644 internal/data/entity/ent/permissionresource/permissionresource.go create mode 100644 internal/data/entity/ent/permissionresource/where.go create mode 100644 internal/data/entity/ent/position/position.go create mode 100644 internal/data/entity/ent/position/where.go create mode 100644 internal/data/entity/ent/positionpermission/positionpermission.go create mode 100644 internal/data/entity/ent/positionpermission/where.go create mode 100644 internal/data/entity/ent/resource/resource.go create mode 100644 internal/data/entity/ent/resource/where.go create mode 100644 internal/data/entity/ent/role/role.go create mode 100644 internal/data/entity/ent/role/where.go create mode 100644 internal/data/entity/ent/rolepermission/rolepermission.go create mode 100644 internal/data/entity/ent/rolepermission/where.go create mode 100644 internal/data/entity/ent/user/user.go create mode 100644 internal/data/entity/ent/user/where.go create mode 100644 internal/data/entity/ent/userdepartment/userdepartment.go create mode 100644 internal/data/entity/ent/userdepartment/where.go create mode 100644 internal/data/entity/ent/userposition/userposition.go create mode 100644 internal/data/entity/ent/userposition/where.go create mode 100644 internal/data/entity/ent/userrole/userrole.go create mode 100644 internal/data/entity/ent/userrole/where.go diff --git a/cmd/internal/start/wire_gen.go b/cmd/internal/start/wire_gen.go index 673a3972..b21abf97 100644 --- a/cmd/internal/start/wire_gen.go +++ b/cmd/internal/start/wire_gen.go @@ -12,13 +12,13 @@ import ( "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/loader" - biz2 "origadmin/application/admin/internal/mods/auth/biz" - dal2 "origadmin/application/admin/internal/mods/auth/dal" - service2 "origadmin/application/admin/internal/mods/auth/service" + "origadmin/application/admin/internal/mods/auth/biz" + "origadmin/application/admin/internal/mods/auth/dal" + "origadmin/application/admin/internal/mods/auth/service" "origadmin/application/admin/internal/mods/gateway" - "origadmin/application/admin/internal/mods/system/biz" - "origadmin/application/admin/internal/mods/system/dal" - "origadmin/application/admin/internal/mods/system/service" + biz2 "origadmin/application/admin/internal/mods/system/biz" + dal2 "origadmin/application/admin/internal/mods/system/dal" + service2 "origadmin/application/admin/internal/mods/system/service" ) import ( @@ -36,51 +36,51 @@ func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*krat if err != nil { return nil, nil, err } - resourceRepo := dal.NewResourceRepo(r, dataData) - resourceServiceBiz := biz.NewResourceServiceBiz(r, resourceRepo) - resourceServiceServer := service.NewResourceServiceServerPB(r, resourceServiceBiz) - roleRepo := dal.NewRoleRepo(r, dataData) - roleServiceBiz := biz.NewRoleServiceBiz(r, roleRepo) - roleServiceServer := service.NewRoleServiceServerPB(r, roleServiceBiz) - userRepo := dal.NewUserRepo(r, dataData) - userServiceBiz := biz.NewUserServiceBiz(r, userRepo) - userServiceServer := service.NewUserServiceServerPB(r, userServiceBiz) - permissionRepo := dal.NewPermissionRepo(r, dataData) - permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) - permissionServiceServer := service.NewPermissionServiceServerPB(r, permissionServiceBiz) - systemServerRegistrar := service.NewRegisterBridgeServer(r, resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) - authRepo := dal2.NewAuthRepo(r, dataData) - authServiceBiz := biz2.NewAuthServiceBiz(r, authRepo) - authServiceServer := service2.NewAuthServiceServerPB(authServiceBiz) - casbinSourceRepo, err := dal2.NewCasbinSourceRepo(dataData) + casbinSourceRepo, err := dal.NewCasbinSourceRepo(dataData) if err != nil { cleanup() return nil, nil, err } - casbinSourceServiceBiz := biz2.NewCasbinSourceServiceBiz(r, casbinSourceRepo) - casbinSourceServiceServer := service2.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) + casbinSourceServiceBiz := biz.NewCasbinSourceServiceBiz(r, casbinSourceRepo) + ruleSource := service.NewCasbinSourceBiz(r, casbinSourceServiceBiz) + resourceRepo := dal2.NewResourceRepo(r, dataData) + resourceServiceBiz := biz2.NewResourceServiceBiz(r, resourceRepo) + resourceServiceServer := service2.NewResourceServiceServerPB(r, resourceServiceBiz) + roleRepo := dal2.NewRoleRepo(r, dataData) + roleServiceBiz := biz2.NewRoleServiceBiz(r, roleRepo) + roleServiceServer := service2.NewRoleServiceServerPB(r, roleServiceBiz) + userRepo := dal2.NewUserRepo(r, dataData) + userServiceBiz := biz2.NewUserServiceBiz(r, userRepo) + userServiceServer := service2.NewUserServiceServerPB(r, userServiceBiz) + permissionRepo := dal2.NewPermissionRepo(r, dataData) + permissionServiceBiz := biz2.NewPermissionServiceBiz(r, permissionRepo) + permissionServiceServer := service2.NewPermissionServiceServerPB(r, permissionServiceBiz) + systemServerRegistrar := service2.NewRegisterBridgeServer(r, resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + authRepo := dal.NewAuthRepo(r, dataData) + authServiceBiz := biz.NewAuthServiceBiz(r, authRepo) + authServiceServer := service.NewAuthServiceServerPB(authServiceBiz) + casbinSourceServiceServer := service.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) tokenizer, err := data.NewTokenizer(bootstrap) if err != nil { cleanup() return nil, nil, err } - refreshTokenizer := dal2.RefreshTokenizer(tokenizer) + refreshTokenizer := dal.RefreshTokenizer(tokenizer) loginData := data.NewLoginData(bootstrap, refreshTokenizer) - loginRepo := dal2.NewLoginRepo(dataData, loginData) - loginServiceBiz := biz2.NewLoginServiceBiz(r, loginRepo) - loginServiceServer := service2.NewLoginServiceServerPB(loginServiceBiz) - personalRepo := dal2.NewPersonalRepo(r, dataData) - personalServiceBiz := biz2.NewPersonalServiceBiz(r, personalRepo) - personalServiceServer := service2.NewPersonalServiceServerPB(r, personalServiceBiz) - authServerRegistrar := service2.NewRegisterBridgeServer(r, authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) + loginRepo := dal.NewLoginRepo(dataData, loginData) + loginServiceBiz := biz.NewLoginServiceBiz(r, loginRepo) + loginServiceServer := service.NewLoginServiceServerPB(loginServiceBiz) + personalRepo := dal.NewPersonalRepo(r, dataData) + personalServiceBiz := biz.NewPersonalServiceBiz(r, personalRepo) + personalServiceServer := service.NewPersonalServiceServerPB(r, personalServiceBiz) + authServerRegistrar := service.NewRegisterBridgeServer(r, authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) v := loader.NewServiceServerRegistrars(systemServerRegistrar, authServerRegistrar) - ruleSource := service2.NewCasbinSourceBiz(r, casbinSourceServiceBiz) - proxyOptions, err := gateway.NewProxyOptions(r, bootstrap, ruleSource) + proxyOptions, err := gateway.NewProxyOptions(r, bootstrap, ruleSource, v) if err != nil { cleanup() return nil, nil, err } - v2 := gateway.NewProxyServer(r, bootstrap, v, proxyOptions) + v2 := gateway.NewProxyServer(r, bootstrap, proxyOptions) app := NewApp(r, v2) return app, func() { cleanup() @@ -89,23 +89,23 @@ func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*krat func buildRemoteInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { v := gateway.NewProxyGRPCClients(r, bootstrap) - resourceServiceServer := service.NewResourceServiceBridgeClient(r, v) - roleServiceServer := service.NewRoleServiceBridgeClient(r, v) - userServiceServer := service.NewUserServiceBridgeClient(r, v) - permissionServiceServer := service.NewPermissionServiceBridgeClient(r, v) - systemServerRegistrar := service.NewRegisterBridgeServer(r, resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) - authServiceServer := service2.NewAuthServiceBridgeClient(r, v) - casbinSourceServiceServer := service2.NewCasbinServiceBridgeClient(r, v) - loginServiceServer := service2.NewLoginServiceBridgeClient(r, v) - personalServiceServer := service2.NewPersonalServiceBridgeClient(r, v) - authServerRegistrar := service2.NewRegisterBridgeServer(r, authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) + ruleSource := service.NewCasbinSourceClient(r, v) + resourceServiceServer := service2.NewResourceServiceBridgeClient(r, v) + roleServiceServer := service2.NewRoleServiceBridgeClient(r, v) + userServiceServer := service2.NewUserServiceBridgeClient(r, v) + permissionServiceServer := service2.NewPermissionServiceBridgeClient(r, v) + systemServerRegistrar := service2.NewRegisterBridgeServer(r, resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) + authServiceServer := service.NewAuthServiceBridgeClient(r, v) + casbinSourceServiceServer := service.NewCasbinServiceBridgeClient(r, v) + loginServiceServer := service.NewLoginServiceBridgeClient(r, v) + personalServiceServer := service.NewPersonalServiceBridgeClient(r, v) + authServerRegistrar := service.NewRegisterBridgeServer(r, authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) v2 := loader.NewServiceServerRegistrars(systemServerRegistrar, authServerRegistrar) - ruleSource := service2.NewCasbinSourceClient(r, v) - proxyOptions, err := gateway.NewProxyOptions(r, bootstrap, ruleSource) + proxyOptions, err := gateway.NewProxyOptions(r, bootstrap, ruleSource, v2) if err != nil { return nil, nil, err } - v3 := gateway.NewProxyServer(r, bootstrap, v2, proxyOptions) + v3 := gateway.NewProxyServer(r, bootstrap, proxyOptions) app := NewApp(r, v3) return app, func() { }, nil diff --git a/internal/data/entity/ent/department/department.go b/internal/data/entity/ent/department/department.go new file mode 100644 index 00000000..ea3a35e2 --- /dev/null +++ b/internal/data/entity/ent/department/department.go @@ -0,0 +1,358 @@ +// Code generated by ent, DO NOT EDIT. + +package department + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the department type in the database. + Label = "department" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldKeyword holds the string denoting the keyword field in the database. + FieldKeyword = "keyword" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldTreePath holds the string denoting the tree_path field in the database. + FieldTreePath = "tree_path" + // FieldSequence holds the string denoting the sequence field in the database. + FieldSequence = "sequence" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldLevel holds the string denoting the level field in the database. + FieldLevel = "level" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldParentID holds the string denoting the parent_id field in the database. + FieldParentID = "parent_id" + // EdgeUsers holds the string denoting the users edge name in mutations. + EdgeUsers = "users" + // EdgePositions holds the string denoting the positions edge name in mutations. + EdgePositions = "positions" + // EdgeParent holds the string denoting the parent edge name in mutations. + EdgeParent = "parent" + // EdgeChildren holds the string denoting the children edge name in mutations. + EdgeChildren = "children" + // EdgeUserDepartments holds the string denoting the user_departments edge name in mutations. + EdgeUserDepartments = "user_departments" + // Table holds the table name of the department in the database. + Table = "sys_departments" + // UsersTable is the table that holds the users relation/edge. The primary key declared below. + UsersTable = "sys_user_departments" + // UsersInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UsersInverseTable = "sys_users" + // PositionsTable is the table that holds the positions relation/edge. + PositionsTable = "sys_positions" + // PositionsInverseTable is the table name for the Position entity. + // It exists in this package in order to avoid circular dependency with the "position" package. + PositionsInverseTable = "sys_positions" + // PositionsColumn is the table column denoting the positions relation/edge. + PositionsColumn = "department_id" + // ParentTable is the table that holds the parent relation/edge. + ParentTable = "sys_departments" + // ParentColumn is the table column denoting the parent relation/edge. + ParentColumn = "parent_id" + // ChildrenTable is the table that holds the children relation/edge. + ChildrenTable = "sys_departments" + // ChildrenColumn is the table column denoting the children relation/edge. + ChildrenColumn = "parent_id" + // UserDepartmentsTable is the table that holds the user_departments relation/edge. + UserDepartmentsTable = "sys_user_departments" + // UserDepartmentsInverseTable is the table name for the UserDepartment entity. + // It exists in this package in order to avoid circular dependency with the "userdepartment" package. + UserDepartmentsInverseTable = "sys_user_departments" + // UserDepartmentsColumn is the table column denoting the user_departments relation/edge. + UserDepartmentsColumn = "department_id" +) + +// Columns holds all SQL columns for department fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldKeyword, + FieldName, + FieldTreePath, + FieldSequence, + FieldStatus, + FieldLevel, + FieldDescription, + FieldParentID, +} + +var ( + // UsersPrimaryKey and UsersColumn2 are the table columns denoting the + // primary key for the users relation (M2M). + UsersPrimaryKey = []string{"user_id", "department_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + KeywordValidator func(string) error + // DefaultName holds the default value on creation for the "name" field. + DefaultName string + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultTreePath holds the default value on creation for the "tree_path" field. + DefaultTreePath string + // TreePathValidator is a validator for the "tree_path" field. It is called by the builders before save. + TreePathValidator func(string) error + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int8 + // DefaultLevel holds the default value on creation for the "level" field. + DefaultLevel int + // DefaultDescription holds the default value on creation for the "description" field. + DefaultDescription string + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error + // ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. + ParentIDValidator func(int64) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int64) error +) + +// OrderOption defines the ordering options for the Department queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByKeyword orders the results by the keyword field. +func ByKeyword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKeyword, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByTreePath orders the results by the tree_path field. +func ByTreePath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTreePath, opts...).ToFunc() +} + +// BySequence orders the results by the sequence field. +func BySequence(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSequence, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByLevel orders the results by the level field. +func ByLevel(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLevel, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByParentID orders the results by the parent_id field. +func ByParentID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldParentID, opts...).ToFunc() +} + +// ByUsersCount orders the results by users count. +func ByUsersCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...) + } +} + +// ByUsers orders the results by users terms. +func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPositionsCount orders the results by positions count. +func ByPositionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPositionsStep(), opts...) + } +} + +// ByPositions orders the results by positions terms. +func ByPositions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPositionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByParentField orders the results by parent field. +func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) + } +} + +// ByChildrenCount orders the results by children count. +func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) + } +} + +// ByChildren orders the results by children terms. +func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByUserDepartmentsCount orders the results by user_departments count. +func ByUserDepartmentsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserDepartmentsStep(), opts...) + } +} + +// ByUserDepartments orders the results by user_departments terms. +func ByUserDepartments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserDepartmentsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newUsersStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UsersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), + ) +} +func newPositionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PositionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, PositionsTable, PositionsColumn), + ) +} +func newParentStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) +} +func newChildrenStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) +} +func newUserDepartmentsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserDepartmentsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserDepartmentsTable, UserDepartmentsColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/department/where.go b/internal/data/entity/ent/department/where.go new file mode 100644 index 00000000..fb65a09e --- /dev/null +++ b/internal/data/entity/ent/department/where.go @@ -0,0 +1,726 @@ +// Code generated by ent, DO NOT EDIT. + +package department + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.Department { + return predicate.Department(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.Department { + return predicate.Department(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.Department { + return predicate.Department(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.Department { + return predicate.Department(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.Department { + return predicate.Department(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. +func Keyword(v string) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldKeyword, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldName, v)) +} + +// TreePath applies equality check predicate on the "tree_path" field. It's identical to TreePathEQ. +func TreePath(v string) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldTreePath, v)) +} + +// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. +func Sequence(v int) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldSequence, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int8) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldStatus, v)) +} + +// Level applies equality check predicate on the "level" field. It's identical to LevelEQ. +func Level(v int) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldLevel, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldDescription, v)) +} + +// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ. +func ParentID(v int64) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldParentID, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Department { + return predicate.Department(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Department { + return predicate.Department(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Department { + return predicate.Department(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Department { + return predicate.Department(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Department { + return predicate.Department(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Department { + return predicate.Department(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Department { + return predicate.Department(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Department { + return predicate.Department(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Department { + return predicate.Department(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Department { + return predicate.Department(sql.FieldLTE(FieldUpdateTime, v)) +} + +// KeywordEQ applies the EQ predicate on the "keyword" field. +func KeywordEQ(v string) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldKeyword, v)) +} + +// KeywordNEQ applies the NEQ predicate on the "keyword" field. +func KeywordNEQ(v string) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldKeyword, v)) +} + +// KeywordIn applies the In predicate on the "keyword" field. +func KeywordIn(vs ...string) predicate.Department { + return predicate.Department(sql.FieldIn(FieldKeyword, vs...)) +} + +// KeywordNotIn applies the NotIn predicate on the "keyword" field. +func KeywordNotIn(vs ...string) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldKeyword, vs...)) +} + +// KeywordGT applies the GT predicate on the "keyword" field. +func KeywordGT(v string) predicate.Department { + return predicate.Department(sql.FieldGT(FieldKeyword, v)) +} + +// KeywordGTE applies the GTE predicate on the "keyword" field. +func KeywordGTE(v string) predicate.Department { + return predicate.Department(sql.FieldGTE(FieldKeyword, v)) +} + +// KeywordLT applies the LT predicate on the "keyword" field. +func KeywordLT(v string) predicate.Department { + return predicate.Department(sql.FieldLT(FieldKeyword, v)) +} + +// KeywordLTE applies the LTE predicate on the "keyword" field. +func KeywordLTE(v string) predicate.Department { + return predicate.Department(sql.FieldLTE(FieldKeyword, v)) +} + +// KeywordContains applies the Contains predicate on the "keyword" field. +func KeywordContains(v string) predicate.Department { + return predicate.Department(sql.FieldContains(FieldKeyword, v)) +} + +// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. +func KeywordHasPrefix(v string) predicate.Department { + return predicate.Department(sql.FieldHasPrefix(FieldKeyword, v)) +} + +// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. +func KeywordHasSuffix(v string) predicate.Department { + return predicate.Department(sql.FieldHasSuffix(FieldKeyword, v)) +} + +// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. +func KeywordEqualFold(v string) predicate.Department { + return predicate.Department(sql.FieldEqualFold(FieldKeyword, v)) +} + +// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. +func KeywordContainsFold(v string) predicate.Department { + return predicate.Department(sql.FieldContainsFold(FieldKeyword, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Department { + return predicate.Department(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Department { + return predicate.Department(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Department { + return predicate.Department(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Department { + return predicate.Department(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Department { + return predicate.Department(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Department { + return predicate.Department(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Department { + return predicate.Department(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Department { + return predicate.Department(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Department { + return predicate.Department(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Department { + return predicate.Department(sql.FieldContainsFold(FieldName, v)) +} + +// TreePathEQ applies the EQ predicate on the "tree_path" field. +func TreePathEQ(v string) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldTreePath, v)) +} + +// TreePathNEQ applies the NEQ predicate on the "tree_path" field. +func TreePathNEQ(v string) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldTreePath, v)) +} + +// TreePathIn applies the In predicate on the "tree_path" field. +func TreePathIn(vs ...string) predicate.Department { + return predicate.Department(sql.FieldIn(FieldTreePath, vs...)) +} + +// TreePathNotIn applies the NotIn predicate on the "tree_path" field. +func TreePathNotIn(vs ...string) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldTreePath, vs...)) +} + +// TreePathGT applies the GT predicate on the "tree_path" field. +func TreePathGT(v string) predicate.Department { + return predicate.Department(sql.FieldGT(FieldTreePath, v)) +} + +// TreePathGTE applies the GTE predicate on the "tree_path" field. +func TreePathGTE(v string) predicate.Department { + return predicate.Department(sql.FieldGTE(FieldTreePath, v)) +} + +// TreePathLT applies the LT predicate on the "tree_path" field. +func TreePathLT(v string) predicate.Department { + return predicate.Department(sql.FieldLT(FieldTreePath, v)) +} + +// TreePathLTE applies the LTE predicate on the "tree_path" field. +func TreePathLTE(v string) predicate.Department { + return predicate.Department(sql.FieldLTE(FieldTreePath, v)) +} + +// TreePathContains applies the Contains predicate on the "tree_path" field. +func TreePathContains(v string) predicate.Department { + return predicate.Department(sql.FieldContains(FieldTreePath, v)) +} + +// TreePathHasPrefix applies the HasPrefix predicate on the "tree_path" field. +func TreePathHasPrefix(v string) predicate.Department { + return predicate.Department(sql.FieldHasPrefix(FieldTreePath, v)) +} + +// TreePathHasSuffix applies the HasSuffix predicate on the "tree_path" field. +func TreePathHasSuffix(v string) predicate.Department { + return predicate.Department(sql.FieldHasSuffix(FieldTreePath, v)) +} + +// TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. +func TreePathEqualFold(v string) predicate.Department { + return predicate.Department(sql.FieldEqualFold(FieldTreePath, v)) +} + +// TreePathContainsFold applies the ContainsFold predicate on the "tree_path" field. +func TreePathContainsFold(v string) predicate.Department { + return predicate.Department(sql.FieldContainsFold(FieldTreePath, v)) +} + +// SequenceEQ applies the EQ predicate on the "sequence" field. +func SequenceEQ(v int) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldSequence, v)) +} + +// SequenceNEQ applies the NEQ predicate on the "sequence" field. +func SequenceNEQ(v int) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldSequence, v)) +} + +// SequenceIn applies the In predicate on the "sequence" field. +func SequenceIn(vs ...int) predicate.Department { + return predicate.Department(sql.FieldIn(FieldSequence, vs...)) +} + +// SequenceNotIn applies the NotIn predicate on the "sequence" field. +func SequenceNotIn(vs ...int) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldSequence, vs...)) +} + +// SequenceGT applies the GT predicate on the "sequence" field. +func SequenceGT(v int) predicate.Department { + return predicate.Department(sql.FieldGT(FieldSequence, v)) +} + +// SequenceGTE applies the GTE predicate on the "sequence" field. +func SequenceGTE(v int) predicate.Department { + return predicate.Department(sql.FieldGTE(FieldSequence, v)) +} + +// SequenceLT applies the LT predicate on the "sequence" field. +func SequenceLT(v int) predicate.Department { + return predicate.Department(sql.FieldLT(FieldSequence, v)) +} + +// SequenceLTE applies the LTE predicate on the "sequence" field. +func SequenceLTE(v int) predicate.Department { + return predicate.Department(sql.FieldLTE(FieldSequence, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int8) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int8) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int8) predicate.Department { + return predicate.Department(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int8) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int8) predicate.Department { + return predicate.Department(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int8) predicate.Department { + return predicate.Department(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int8) predicate.Department { + return predicate.Department(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int8) predicate.Department { + return predicate.Department(sql.FieldLTE(FieldStatus, v)) +} + +// LevelEQ applies the EQ predicate on the "level" field. +func LevelEQ(v int) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldLevel, v)) +} + +// LevelNEQ applies the NEQ predicate on the "level" field. +func LevelNEQ(v int) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldLevel, v)) +} + +// LevelIn applies the In predicate on the "level" field. +func LevelIn(vs ...int) predicate.Department { + return predicate.Department(sql.FieldIn(FieldLevel, vs...)) +} + +// LevelNotIn applies the NotIn predicate on the "level" field. +func LevelNotIn(vs ...int) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldLevel, vs...)) +} + +// LevelGT applies the GT predicate on the "level" field. +func LevelGT(v int) predicate.Department { + return predicate.Department(sql.FieldGT(FieldLevel, v)) +} + +// LevelGTE applies the GTE predicate on the "level" field. +func LevelGTE(v int) predicate.Department { + return predicate.Department(sql.FieldGTE(FieldLevel, v)) +} + +// LevelLT applies the LT predicate on the "level" field. +func LevelLT(v int) predicate.Department { + return predicate.Department(sql.FieldLT(FieldLevel, v)) +} + +// LevelLTE applies the LTE predicate on the "level" field. +func LevelLTE(v int) predicate.Department { + return predicate.Department(sql.FieldLTE(FieldLevel, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Department { + return predicate.Department(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Department { + return predicate.Department(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Department { + return predicate.Department(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Department { + return predicate.Department(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Department { + return predicate.Department(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Department { + return predicate.Department(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Department { + return predicate.Department(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Department { + return predicate.Department(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Department { + return predicate.Department(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Department { + return predicate.Department(sql.FieldContainsFold(FieldDescription, v)) +} + +// ParentIDEQ applies the EQ predicate on the "parent_id" field. +func ParentIDEQ(v int64) predicate.Department { + return predicate.Department(sql.FieldEQ(FieldParentID, v)) +} + +// ParentIDNEQ applies the NEQ predicate on the "parent_id" field. +func ParentIDNEQ(v int64) predicate.Department { + return predicate.Department(sql.FieldNEQ(FieldParentID, v)) +} + +// ParentIDIn applies the In predicate on the "parent_id" field. +func ParentIDIn(vs ...int64) predicate.Department { + return predicate.Department(sql.FieldIn(FieldParentID, vs...)) +} + +// ParentIDNotIn applies the NotIn predicate on the "parent_id" field. +func ParentIDNotIn(vs ...int64) predicate.Department { + return predicate.Department(sql.FieldNotIn(FieldParentID, vs...)) +} + +// ParentIDIsNil applies the IsNil predicate on the "parent_id" field. +func ParentIDIsNil() predicate.Department { + return predicate.Department(sql.FieldIsNull(FieldParentID)) +} + +// ParentIDNotNil applies the NotNil predicate on the "parent_id" field. +func ParentIDNotNil() predicate.Department { + return predicate.Department(sql.FieldNotNull(FieldParentID)) +} + +// HasUsers applies the HasEdge predicate on the "users" edge. +func HasUsers() predicate.Department { + return predicate.Department(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUsersWith applies the HasEdge predicate on the "users" edge with a given conditions (other predicates). +func HasUsersWith(preds ...predicate.User) predicate.Department { + return predicate.Department(func(s *sql.Selector) { + step := newUsersStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPositions applies the HasEdge predicate on the "positions" edge. +func HasPositions() predicate.Department { + return predicate.Department(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, PositionsTable, PositionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPositionsWith applies the HasEdge predicate on the "positions" edge with a given conditions (other predicates). +func HasPositionsWith(preds ...predicate.Position) predicate.Department { + return predicate.Department(func(s *sql.Selector) { + step := newPositionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasParent applies the HasEdge predicate on the "parent" edge. +func HasParent() predicate.Department { + return predicate.Department(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). +func HasParentWith(preds ...predicate.Department) predicate.Department { + return predicate.Department(func(s *sql.Selector) { + step := newParentStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasChildren applies the HasEdge predicate on the "children" edge. +func HasChildren() predicate.Department { + return predicate.Department(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates). +func HasChildrenWith(preds ...predicate.Department) predicate.Department { + return predicate.Department(func(s *sql.Selector) { + step := newChildrenStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasUserDepartments applies the HasEdge predicate on the "user_departments" edge. +func HasUserDepartments() predicate.Department { + return predicate.Department(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserDepartmentsTable, UserDepartmentsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserDepartmentsWith applies the HasEdge predicate on the "user_departments" edge with a given conditions (other predicates). +func HasUserDepartmentsWith(preds ...predicate.UserDepartment) predicate.Department { + return predicate.Department(func(s *sql.Selector) { + step := newUserDepartmentsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Department) predicate.Department { + return predicate.Department(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Department) predicate.Department { + return predicate.Department(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Department) predicate.Department { + return predicate.Department(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/permission/permission.go b/internal/data/entity/ent/permission/permission.go new file mode 100644 index 00000000..45cd170f --- /dev/null +++ b/internal/data/entity/ent/permission/permission.go @@ -0,0 +1,403 @@ +// Code generated by ent, DO NOT EDIT. + +package permission + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the permission type in the database. + Label = "permission" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldKeyword holds the string denoting the keyword field in the database. + FieldKeyword = "keyword" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldDataScope holds the string denoting the data_scope field in the database. + FieldDataScope = "data_scope" + // FieldDataRules holds the string denoting the data_rules field in the database. + FieldDataRules = "data_rules" + // FieldActions holds the string denoting the actions field in the database. + FieldActions = "actions" + // EdgeRoles holds the string denoting the roles edge name in mutations. + EdgeRoles = "roles" + // EdgePositions holds the string denoting the positions edge name in mutations. + EdgePositions = "positions" + // EdgeResources holds the string denoting the resources edge name in mutations. + EdgeResources = "resources" + // EdgeRolePermissions holds the string denoting the role_permissions edge name in mutations. + EdgeRolePermissions = "role_permissions" + // EdgePositionPermissions holds the string denoting the position_permissions edge name in mutations. + EdgePositionPermissions = "position_permissions" + // EdgePermissionResources holds the string denoting the permission_resources edge name in mutations. + EdgePermissionResources = "permission_resources" + // Table holds the table name of the permission in the database. + Table = "sys_permissions" + // RolesTable is the table that holds the roles relation/edge. The primary key declared below. + RolesTable = "sys_role_permissions" + // RolesInverseTable is the table name for the Role entity. + // It exists in this package in order to avoid circular dependency with the "role" package. + RolesInverseTable = "sys_roles" + // PositionsTable is the table that holds the positions relation/edge. The primary key declared below. + PositionsTable = "sys_position_permissions" + // PositionsInverseTable is the table name for the Position entity. + // It exists in this package in order to avoid circular dependency with the "position" package. + PositionsInverseTable = "sys_positions" + // ResourcesTable is the table that holds the resources relation/edge. The primary key declared below. + ResourcesTable = "sys_permission_resources" + // ResourcesInverseTable is the table name for the Resource entity. + // It exists in this package in order to avoid circular dependency with the "resource" package. + ResourcesInverseTable = "sys_resources" + // RolePermissionsTable is the table that holds the role_permissions relation/edge. + RolePermissionsTable = "sys_role_permissions" + // RolePermissionsInverseTable is the table name for the RolePermission entity. + // It exists in this package in order to avoid circular dependency with the "rolepermission" package. + RolePermissionsInverseTable = "sys_role_permissions" + // RolePermissionsColumn is the table column denoting the role_permissions relation/edge. + RolePermissionsColumn = "permission_id" + // PositionPermissionsTable is the table that holds the position_permissions relation/edge. + PositionPermissionsTable = "sys_position_permissions" + // PositionPermissionsInverseTable is the table name for the PositionPermission entity. + // It exists in this package in order to avoid circular dependency with the "positionpermission" package. + PositionPermissionsInverseTable = "sys_position_permissions" + // PositionPermissionsColumn is the table column denoting the position_permissions relation/edge. + PositionPermissionsColumn = "permission_id" + // PermissionResourcesTable is the table that holds the permission_resources relation/edge. + PermissionResourcesTable = "sys_permission_resources" + // PermissionResourcesInverseTable is the table name for the PermissionResource entity. + // It exists in this package in order to avoid circular dependency with the "permissionresource" package. + PermissionResourcesInverseTable = "sys_permission_resources" + // PermissionResourcesColumn is the table column denoting the permission_resources relation/edge. + PermissionResourcesColumn = "permission_id" +) + +// Columns holds all SQL columns for permission fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldName, + FieldKeyword, + FieldDescription, + FieldDataScope, + FieldDataRules, + FieldActions, +} + +var ( + // RolesPrimaryKey and RolesColumn2 are the table columns denoting the + // primary key for the roles relation (M2M). + RolesPrimaryKey = []string{"role_id", "permission_id"} + // PositionsPrimaryKey and PositionsColumn2 are the table columns denoting the + // primary key for the positions relation (M2M). + PositionsPrimaryKey = []string{"position_id", "permission_id"} + // ResourcesPrimaryKey and ResourcesColumn2 are the table columns denoting the + // primary key for the resources relation (M2M). + ResourcesPrimaryKey = []string{"permission_id", "resource_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // DefaultName holds the default value on creation for the "name" field. + DefaultName string + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + KeywordValidator func(string) error + // DefaultDescription holds the default value on creation for the "description" field. + DefaultDescription string + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error + // DefaultDataScope holds the default value on creation for the "data_scope" field. + DefaultDataScope string + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int64) error +) + +// Actions defines the type for the "actions" enum field. +type Actions string + +// ActionsRead is the default value of the Actions enum. +const DefaultActions = ActionsRead + +// Actions values. +const ( + ActionsRead Actions = "read" + ActionsWrite Actions = "write" + ActionsDelete Actions = "delete" + ActionsManage Actions = "manage" +) + +func (a Actions) String() string { + return string(a) +} + +// ActionsValidator is a validator for the "actions" field enum values. It is called by the builders before save. +func ActionsValidator(a Actions) error { + switch a { + case ActionsRead, ActionsWrite, ActionsDelete, ActionsManage: + return nil + default: + return fmt.Errorf("permission: invalid enum value for actions field: %q", a) + } +} + +// OrderOption defines the ordering options for the Permission queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByKeyword orders the results by the keyword field. +func ByKeyword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKeyword, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByDataScope orders the results by the data_scope field. +func ByDataScope(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDataScope, opts...).ToFunc() +} + +// ByActions orders the results by the actions field. +func ByActions(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldActions, opts...).ToFunc() +} + +// ByRolesCount orders the results by roles count. +func ByRolesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...) + } +} + +// ByRoles orders the results by roles terms. +func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPositionsCount orders the results by positions count. +func ByPositionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPositionsStep(), opts...) + } +} + +// ByPositions orders the results by positions terms. +func ByPositions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPositionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByResourcesCount orders the results by resources count. +func ByResourcesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newResourcesStep(), opts...) + } +} + +// ByResources orders the results by resources terms. +func ByResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByRolePermissionsCount orders the results by role_permissions count. +func ByRolePermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRolePermissionsStep(), opts...) + } +} + +// ByRolePermissions orders the results by role_permissions terms. +func ByRolePermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRolePermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPositionPermissionsCount orders the results by position_permissions count. +func ByPositionPermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPositionPermissionsStep(), opts...) + } +} + +// ByPositionPermissions orders the results by position_permissions terms. +func ByPositionPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPositionPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPermissionResourcesCount orders the results by permission_resources count. +func ByPermissionResourcesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPermissionResourcesStep(), opts...) + } +} + +// ByPermissionResources orders the results by permission_resources terms. +func ByPermissionResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newRolesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RolesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, RolesTable, RolesPrimaryKey...), + ) +} +func newPositionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PositionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, PositionsTable, PositionsPrimaryKey...), + ) +} +func newResourcesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ResourcesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), + ) +} +func newRolePermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RolePermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), + ) +} +func newPositionPermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PositionPermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PositionPermissionsTable, PositionPermissionsColumn), + ) +} +func newPermissionResourcesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionResourcesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/permission/where.go b/internal/data/entity/ent/permission/where.go new file mode 100644 index 00000000..9b6ec847 --- /dev/null +++ b/internal/data/entity/ent/permission/where.go @@ -0,0 +1,609 @@ +// Code generated by ent, DO NOT EDIT. + +package permission + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldName, v)) +} + +// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. +func Keyword(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldKeyword, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldDescription, v)) +} + +// DataScope applies equality check predicate on the "data_scope" field. It's identical to DataScopeEQ. +func DataScope(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldDataScope, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldUpdateTime, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Permission { + return predicate.Permission(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldContainsFold(FieldName, v)) +} + +// KeywordEQ applies the EQ predicate on the "keyword" field. +func KeywordEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldKeyword, v)) +} + +// KeywordNEQ applies the NEQ predicate on the "keyword" field. +func KeywordNEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldKeyword, v)) +} + +// KeywordIn applies the In predicate on the "keyword" field. +func KeywordIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldKeyword, vs...)) +} + +// KeywordNotIn applies the NotIn predicate on the "keyword" field. +func KeywordNotIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldKeyword, vs...)) +} + +// KeywordGT applies the GT predicate on the "keyword" field. +func KeywordGT(v string) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldKeyword, v)) +} + +// KeywordGTE applies the GTE predicate on the "keyword" field. +func KeywordGTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldKeyword, v)) +} + +// KeywordLT applies the LT predicate on the "keyword" field. +func KeywordLT(v string) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldKeyword, v)) +} + +// KeywordLTE applies the LTE predicate on the "keyword" field. +func KeywordLTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldKeyword, v)) +} + +// KeywordContains applies the Contains predicate on the "keyword" field. +func KeywordContains(v string) predicate.Permission { + return predicate.Permission(sql.FieldContains(FieldKeyword, v)) +} + +// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. +func KeywordHasPrefix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasPrefix(FieldKeyword, v)) +} + +// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. +func KeywordHasSuffix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasSuffix(FieldKeyword, v)) +} + +// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. +func KeywordEqualFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldEqualFold(FieldKeyword, v)) +} + +// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. +func KeywordContainsFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldContainsFold(FieldKeyword, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Permission { + return predicate.Permission(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldContainsFold(FieldDescription, v)) +} + +// DataScopeEQ applies the EQ predicate on the "data_scope" field. +func DataScopeEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldDataScope, v)) +} + +// DataScopeNEQ applies the NEQ predicate on the "data_scope" field. +func DataScopeNEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldDataScope, v)) +} + +// DataScopeIn applies the In predicate on the "data_scope" field. +func DataScopeIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldDataScope, vs...)) +} + +// DataScopeNotIn applies the NotIn predicate on the "data_scope" field. +func DataScopeNotIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldDataScope, vs...)) +} + +// DataScopeGT applies the GT predicate on the "data_scope" field. +func DataScopeGT(v string) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldDataScope, v)) +} + +// DataScopeGTE applies the GTE predicate on the "data_scope" field. +func DataScopeGTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldDataScope, v)) +} + +// DataScopeLT applies the LT predicate on the "data_scope" field. +func DataScopeLT(v string) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldDataScope, v)) +} + +// DataScopeLTE applies the LTE predicate on the "data_scope" field. +func DataScopeLTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldDataScope, v)) +} + +// DataScopeContains applies the Contains predicate on the "data_scope" field. +func DataScopeContains(v string) predicate.Permission { + return predicate.Permission(sql.FieldContains(FieldDataScope, v)) +} + +// DataScopeHasPrefix applies the HasPrefix predicate on the "data_scope" field. +func DataScopeHasPrefix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasPrefix(FieldDataScope, v)) +} + +// DataScopeHasSuffix applies the HasSuffix predicate on the "data_scope" field. +func DataScopeHasSuffix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasSuffix(FieldDataScope, v)) +} + +// DataScopeEqualFold applies the EqualFold predicate on the "data_scope" field. +func DataScopeEqualFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldEqualFold(FieldDataScope, v)) +} + +// DataScopeContainsFold applies the ContainsFold predicate on the "data_scope" field. +func DataScopeContainsFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldContainsFold(FieldDataScope, v)) +} + +// DataRulesIsNil applies the IsNil predicate on the "data_rules" field. +func DataRulesIsNil() predicate.Permission { + return predicate.Permission(sql.FieldIsNull(FieldDataRules)) +} + +// DataRulesNotNil applies the NotNil predicate on the "data_rules" field. +func DataRulesNotNil() predicate.Permission { + return predicate.Permission(sql.FieldNotNull(FieldDataRules)) +} + +// ActionsEQ applies the EQ predicate on the "actions" field. +func ActionsEQ(v Actions) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldActions, v)) +} + +// ActionsNEQ applies the NEQ predicate on the "actions" field. +func ActionsNEQ(v Actions) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldActions, v)) +} + +// ActionsIn applies the In predicate on the "actions" field. +func ActionsIn(vs ...Actions) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldActions, vs...)) +} + +// ActionsNotIn applies the NotIn predicate on the "actions" field. +func ActionsNotIn(vs ...Actions) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldActions, vs...)) +} + +// HasRoles applies the HasEdge predicate on the "roles" edge. +func HasRoles() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, RolesTable, RolesPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRolesWith applies the HasEdge predicate on the "roles" edge with a given conditions (other predicates). +func HasRolesWith(preds ...predicate.Role) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newRolesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPositions applies the HasEdge predicate on the "positions" edge. +func HasPositions() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, PositionsTable, PositionsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPositionsWith applies the HasEdge predicate on the "positions" edge with a given conditions (other predicates). +func HasPositionsWith(preds ...predicate.Position) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newPositionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasResources applies the HasEdge predicate on the "resources" edge. +func HasResources() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasResourcesWith applies the HasEdge predicate on the "resources" edge with a given conditions (other predicates). +func HasResourcesWith(preds ...predicate.Resource) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newResourcesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasRolePermissions applies the HasEdge predicate on the "role_permissions" edge. +func HasRolePermissions() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRolePermissionsWith applies the HasEdge predicate on the "role_permissions" edge with a given conditions (other predicates). +func HasRolePermissionsWith(preds ...predicate.RolePermission) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newRolePermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPositionPermissions applies the HasEdge predicate on the "position_permissions" edge. +func HasPositionPermissions() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PositionPermissionsTable, PositionPermissionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPositionPermissionsWith applies the HasEdge predicate on the "position_permissions" edge with a given conditions (other predicates). +func HasPositionPermissionsWith(preds ...predicate.PositionPermission) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newPositionPermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermissionResources applies the HasEdge predicate on the "permission_resources" edge. +func HasPermissionResources() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionResourcesWith applies the HasEdge predicate on the "permission_resources" edge with a given conditions (other predicates). +func HasPermissionResourcesWith(preds ...predicate.PermissionResource) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newPermissionResourcesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Permission) predicate.Permission { + return predicate.Permission(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Permission) predicate.Permission { + return predicate.Permission(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Permission) predicate.Permission { + return predicate.Permission(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/permissionresource/permissionresource.go b/internal/data/entity/ent/permissionresource/permissionresource.go new file mode 100644 index 00000000..22d0c165 --- /dev/null +++ b/internal/data/entity/ent/permissionresource/permissionresource.go @@ -0,0 +1,171 @@ +// Code generated by ent, DO NOT EDIT. + +package permissionresource + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the permissionresource type in the database. + Label = "permission_resource" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldPermissionID holds the string denoting the permission_id field in the database. + FieldPermissionID = "permission_id" + // FieldResourceID holds the string denoting the resource_id field in the database. + FieldResourceID = "resource_id" + // EdgePermission holds the string denoting the permission edge name in mutations. + EdgePermission = "permission" + // EdgeResource holds the string denoting the resource edge name in mutations. + EdgeResource = "resource" + // Table holds the table name of the permissionresource in the database. + Table = "sys_permission_resources" + // PermissionTable is the table that holds the permission relation/edge. + PermissionTable = "sys_permission_resources" + // PermissionInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionInverseTable = "sys_permissions" + // PermissionColumn is the table column denoting the permission relation/edge. + PermissionColumn = "permission_id" + // ResourceTable is the table that holds the resource relation/edge. + ResourceTable = "sys_permission_resources" + // ResourceInverseTable is the table name for the Resource entity. + // It exists in this package in order to avoid circular dependency with the "resource" package. + ResourceInverseTable = "sys_resources" + // ResourceColumn is the table column denoting the resource relation/edge. + ResourceColumn = "resource_id" +) + +// Columns holds all SQL columns for permissionresource fields. +var Columns = []string{ + FieldID, + FieldPermissionID, + FieldResourceID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // PermissionIDValidator is a validator for the "permission_id" field. It is called by the builders before save. + PermissionIDValidator func(int64) error + // ResourceIDValidator is a validator for the "resource_id" field. It is called by the builders before save. + ResourceIDValidator func(int64) error +) + +// OrderOption defines the ordering options for the PermissionResource queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByPermissionID orders the results by the permission_id field. +func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPermissionID, opts...).ToFunc() +} + +// ByResourceID orders the results by the resource_id field. +func ByResourceID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldResourceID, opts...).ToFunc() +} + +// ByPermissionField orders the results by permission field. +func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) + } +} + +// ByResourceField orders the results by resource field. +func ByResourceField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newResourceStep(), sql.OrderByField(field, opts...)) + } +} +func newPermissionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) +} +func newResourceStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ResourceInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ResourceTable, ResourceColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/permissionresource/where.go b/internal/data/entity/ent/permissionresource/where.go new file mode 100644 index 00000000..33959714 --- /dev/null +++ b/internal/data/entity/ent/permissionresource/where.go @@ -0,0 +1,166 @@ +// Code generated by ent, DO NOT EDIT. + +package permissionresource + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldLTE(FieldID, id)) +} + +// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. +func PermissionID(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldPermissionID, v)) +} + +// ResourceID applies equality check predicate on the "resource_id" field. It's identical to ResourceIDEQ. +func ResourceID(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldResourceID, v)) +} + +// PermissionIDEQ applies the EQ predicate on the "permission_id" field. +func PermissionIDEQ(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldPermissionID, v)) +} + +// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. +func PermissionIDNEQ(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNEQ(FieldPermissionID, v)) +} + +// PermissionIDIn applies the In predicate on the "permission_id" field. +func PermissionIDIn(vs ...int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldIn(FieldPermissionID, vs...)) +} + +// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. +func PermissionIDNotIn(vs ...int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNotIn(FieldPermissionID, vs...)) +} + +// ResourceIDEQ applies the EQ predicate on the "resource_id" field. +func ResourceIDEQ(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldResourceID, v)) +} + +// ResourceIDNEQ applies the NEQ predicate on the "resource_id" field. +func ResourceIDNEQ(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNEQ(FieldResourceID, v)) +} + +// ResourceIDIn applies the In predicate on the "resource_id" field. +func ResourceIDIn(vs ...int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldIn(FieldResourceID, vs...)) +} + +// ResourceIDNotIn applies the NotIn predicate on the "resource_id" field. +func ResourceIDNotIn(vs ...int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNotIn(FieldResourceID, vs...)) +} + +// HasPermission applies the HasEdge predicate on the "permission" edge. +func HasPermission() predicate.PermissionResource { + return predicate.PermissionResource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). +func HasPermissionWith(preds ...predicate.Permission) predicate.PermissionResource { + return predicate.PermissionResource(func(s *sql.Selector) { + step := newPermissionStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasResource applies the HasEdge predicate on the "resource" edge. +func HasResource() predicate.PermissionResource { + return predicate.PermissionResource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ResourceTable, ResourceColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasResourceWith applies the HasEdge predicate on the "resource" edge with a given conditions (other predicates). +func HasResourceWith(preds ...predicate.Resource) predicate.PermissionResource { + return predicate.PermissionResource(func(s *sql.Selector) { + step := newResourceStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PermissionResource) predicate.PermissionResource { + return predicate.PermissionResource(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PermissionResource) predicate.PermissionResource { + return predicate.PermissionResource(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PermissionResource) predicate.PermissionResource { + return predicate.PermissionResource(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/position/position.go b/internal/data/entity/ent/position/position.go new file mode 100644 index 00000000..c376960e --- /dev/null +++ b/internal/data/entity/ent/position/position.go @@ -0,0 +1,323 @@ +// Code generated by ent, DO NOT EDIT. + +package position + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the position type in the database. + Label = "position" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldKeyword holds the string denoting the keyword field in the database. + FieldKeyword = "keyword" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldDepartmentID holds the string denoting the department_id field in the database. + FieldDepartmentID = "department_id" + // EdgeDepartment holds the string denoting the department edge name in mutations. + EdgeDepartment = "department" + // EdgeUsers holds the string denoting the users edge name in mutations. + EdgeUsers = "users" + // EdgePermissions holds the string denoting the permissions edge name in mutations. + EdgePermissions = "permissions" + // EdgeUserPositions holds the string denoting the user_positions edge name in mutations. + EdgeUserPositions = "user_positions" + // EdgePositionPermissions holds the string denoting the position_permissions edge name in mutations. + EdgePositionPermissions = "position_permissions" + // Table holds the table name of the position in the database. + Table = "sys_positions" + // DepartmentTable is the table that holds the department relation/edge. + DepartmentTable = "sys_positions" + // DepartmentInverseTable is the table name for the Department entity. + // It exists in this package in order to avoid circular dependency with the "department" package. + DepartmentInverseTable = "sys_departments" + // DepartmentColumn is the table column denoting the department relation/edge. + DepartmentColumn = "department_id" + // UsersTable is the table that holds the users relation/edge. The primary key declared below. + UsersTable = "sys_user_positions" + // UsersInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UsersInverseTable = "sys_users" + // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. + PermissionsTable = "sys_position_permissions" + // PermissionsInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionsInverseTable = "sys_permissions" + // UserPositionsTable is the table that holds the user_positions relation/edge. + UserPositionsTable = "sys_user_positions" + // UserPositionsInverseTable is the table name for the UserPosition entity. + // It exists in this package in order to avoid circular dependency with the "userposition" package. + UserPositionsInverseTable = "sys_user_positions" + // UserPositionsColumn is the table column denoting the user_positions relation/edge. + UserPositionsColumn = "position_id" + // PositionPermissionsTable is the table that holds the position_permissions relation/edge. + PositionPermissionsTable = "sys_position_permissions" + // PositionPermissionsInverseTable is the table name for the PositionPermission entity. + // It exists in this package in order to avoid circular dependency with the "positionpermission" package. + PositionPermissionsInverseTable = "sys_position_permissions" + // PositionPermissionsColumn is the table column denoting the position_permissions relation/edge. + PositionPermissionsColumn = "position_id" +) + +// Columns holds all SQL columns for position fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldName, + FieldKeyword, + FieldDescription, + FieldDepartmentID, +} + +var ( + // UsersPrimaryKey and UsersColumn2 are the table columns denoting the + // primary key for the users relation (M2M). + UsersPrimaryKey = []string{"user_id", "position_id"} + // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the + // primary key for the permissions relation (M2M). + PermissionsPrimaryKey = []string{"position_id", "permission_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + KeywordValidator func(string) error + // DefaultDescription holds the default value on creation for the "description" field. + DefaultDescription string + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error + // DepartmentIDValidator is a validator for the "department_id" field. It is called by the builders before save. + DepartmentIDValidator func(int64) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int64) error +) + +// OrderOption defines the ordering options for the Position queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByKeyword orders the results by the keyword field. +func ByKeyword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKeyword, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByDepartmentID orders the results by the department_id field. +func ByDepartmentID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDepartmentID, opts...).ToFunc() +} + +// ByDepartmentField orders the results by department field. +func ByDepartmentField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newDepartmentStep(), sql.OrderByField(field, opts...)) + } +} + +// ByUsersCount orders the results by users count. +func ByUsersCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...) + } +} + +// ByUsers orders the results by users terms. +func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPermissionsCount orders the results by permissions count. +func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) + } +} + +// ByPermissions orders the results by permissions terms. +func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByUserPositionsCount orders the results by user_positions count. +func ByUserPositionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserPositionsStep(), opts...) + } +} + +// ByUserPositions orders the results by user_positions terms. +func ByUserPositions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserPositionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPositionPermissionsCount orders the results by position_permissions count. +func ByPositionPermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPositionPermissionsStep(), opts...) + } +} + +// ByPositionPermissions orders the results by position_permissions terms. +func ByPositionPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPositionPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newDepartmentStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(DepartmentInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, DepartmentTable, DepartmentColumn), + ) +} +func newUsersStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UsersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), + ) +} +func newPermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), + ) +} +func newUserPositionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserPositionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserPositionsTable, UserPositionsColumn), + ) +} +func newPositionPermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PositionPermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PositionPermissionsTable, PositionPermissionsColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/position/where.go b/internal/data/entity/ent/position/where.go new file mode 100644 index 00000000..a276d704 --- /dev/null +++ b/internal/data/entity/ent/position/where.go @@ -0,0 +1,511 @@ +// Code generated by ent, DO NOT EDIT. + +package position + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.Position { + return predicate.Position(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.Position { + return predicate.Position(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.Position { + return predicate.Position(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.Position { + return predicate.Position(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.Position { + return predicate.Position(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.Position { + return predicate.Position(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.Position { + return predicate.Position(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldName, v)) +} + +// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. +func Keyword(v string) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldKeyword, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldDescription, v)) +} + +// DepartmentID applies equality check predicate on the "department_id" field. It's identical to DepartmentIDEQ. +func DepartmentID(v int64) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldDepartmentID, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Position { + return predicate.Position(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Position { + return predicate.Position(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Position { + return predicate.Position(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Position { + return predicate.Position(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Position { + return predicate.Position(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Position { + return predicate.Position(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Position { + return predicate.Position(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Position { + return predicate.Position(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Position { + return predicate.Position(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Position { + return predicate.Position(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Position { + return predicate.Position(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Position { + return predicate.Position(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Position { + return predicate.Position(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Position { + return predicate.Position(sql.FieldLTE(FieldUpdateTime, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Position { + return predicate.Position(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Position { + return predicate.Position(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Position { + return predicate.Position(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Position { + return predicate.Position(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Position { + return predicate.Position(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Position { + return predicate.Position(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Position { + return predicate.Position(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Position { + return predicate.Position(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Position { + return predicate.Position(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Position { + return predicate.Position(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Position { + return predicate.Position(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Position { + return predicate.Position(sql.FieldContainsFold(FieldName, v)) +} + +// KeywordEQ applies the EQ predicate on the "keyword" field. +func KeywordEQ(v string) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldKeyword, v)) +} + +// KeywordNEQ applies the NEQ predicate on the "keyword" field. +func KeywordNEQ(v string) predicate.Position { + return predicate.Position(sql.FieldNEQ(FieldKeyword, v)) +} + +// KeywordIn applies the In predicate on the "keyword" field. +func KeywordIn(vs ...string) predicate.Position { + return predicate.Position(sql.FieldIn(FieldKeyword, vs...)) +} + +// KeywordNotIn applies the NotIn predicate on the "keyword" field. +func KeywordNotIn(vs ...string) predicate.Position { + return predicate.Position(sql.FieldNotIn(FieldKeyword, vs...)) +} + +// KeywordGT applies the GT predicate on the "keyword" field. +func KeywordGT(v string) predicate.Position { + return predicate.Position(sql.FieldGT(FieldKeyword, v)) +} + +// KeywordGTE applies the GTE predicate on the "keyword" field. +func KeywordGTE(v string) predicate.Position { + return predicate.Position(sql.FieldGTE(FieldKeyword, v)) +} + +// KeywordLT applies the LT predicate on the "keyword" field. +func KeywordLT(v string) predicate.Position { + return predicate.Position(sql.FieldLT(FieldKeyword, v)) +} + +// KeywordLTE applies the LTE predicate on the "keyword" field. +func KeywordLTE(v string) predicate.Position { + return predicate.Position(sql.FieldLTE(FieldKeyword, v)) +} + +// KeywordContains applies the Contains predicate on the "keyword" field. +func KeywordContains(v string) predicate.Position { + return predicate.Position(sql.FieldContains(FieldKeyword, v)) +} + +// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. +func KeywordHasPrefix(v string) predicate.Position { + return predicate.Position(sql.FieldHasPrefix(FieldKeyword, v)) +} + +// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. +func KeywordHasSuffix(v string) predicate.Position { + return predicate.Position(sql.FieldHasSuffix(FieldKeyword, v)) +} + +// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. +func KeywordEqualFold(v string) predicate.Position { + return predicate.Position(sql.FieldEqualFold(FieldKeyword, v)) +} + +// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. +func KeywordContainsFold(v string) predicate.Position { + return predicate.Position(sql.FieldContainsFold(FieldKeyword, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Position { + return predicate.Position(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Position { + return predicate.Position(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Position { + return predicate.Position(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Position { + return predicate.Position(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Position { + return predicate.Position(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Position { + return predicate.Position(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Position { + return predicate.Position(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Position { + return predicate.Position(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Position { + return predicate.Position(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Position { + return predicate.Position(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Position { + return predicate.Position(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Position { + return predicate.Position(sql.FieldContainsFold(FieldDescription, v)) +} + +// DepartmentIDEQ applies the EQ predicate on the "department_id" field. +func DepartmentIDEQ(v int64) predicate.Position { + return predicate.Position(sql.FieldEQ(FieldDepartmentID, v)) +} + +// DepartmentIDNEQ applies the NEQ predicate on the "department_id" field. +func DepartmentIDNEQ(v int64) predicate.Position { + return predicate.Position(sql.FieldNEQ(FieldDepartmentID, v)) +} + +// DepartmentIDIn applies the In predicate on the "department_id" field. +func DepartmentIDIn(vs ...int64) predicate.Position { + return predicate.Position(sql.FieldIn(FieldDepartmentID, vs...)) +} + +// DepartmentIDNotIn applies the NotIn predicate on the "department_id" field. +func DepartmentIDNotIn(vs ...int64) predicate.Position { + return predicate.Position(sql.FieldNotIn(FieldDepartmentID, vs...)) +} + +// HasDepartment applies the HasEdge predicate on the "department" edge. +func HasDepartment() predicate.Position { + return predicate.Position(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, DepartmentTable, DepartmentColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasDepartmentWith applies the HasEdge predicate on the "department" edge with a given conditions (other predicates). +func HasDepartmentWith(preds ...predicate.Department) predicate.Position { + return predicate.Position(func(s *sql.Selector) { + step := newDepartmentStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasUsers applies the HasEdge predicate on the "users" edge. +func HasUsers() predicate.Position { + return predicate.Position(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUsersWith applies the HasEdge predicate on the "users" edge with a given conditions (other predicates). +func HasUsersWith(preds ...predicate.User) predicate.Position { + return predicate.Position(func(s *sql.Selector) { + step := newUsersStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermissions applies the HasEdge predicate on the "permissions" edge. +func HasPermissions() predicate.Position { + return predicate.Position(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). +func HasPermissionsWith(preds ...predicate.Permission) predicate.Position { + return predicate.Position(func(s *sql.Selector) { + step := newPermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasUserPositions applies the HasEdge predicate on the "user_positions" edge. +func HasUserPositions() predicate.Position { + return predicate.Position(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserPositionsTable, UserPositionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserPositionsWith applies the HasEdge predicate on the "user_positions" edge with a given conditions (other predicates). +func HasUserPositionsWith(preds ...predicate.UserPosition) predicate.Position { + return predicate.Position(func(s *sql.Selector) { + step := newUserPositionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPositionPermissions applies the HasEdge predicate on the "position_permissions" edge. +func HasPositionPermissions() predicate.Position { + return predicate.Position(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PositionPermissionsTable, PositionPermissionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPositionPermissionsWith applies the HasEdge predicate on the "position_permissions" edge with a given conditions (other predicates). +func HasPositionPermissionsWith(preds ...predicate.PositionPermission) predicate.Position { + return predicate.Position(func(s *sql.Selector) { + step := newPositionPermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Position) predicate.Position { + return predicate.Position(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Position) predicate.Position { + return predicate.Position(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Position) predicate.Position { + return predicate.Position(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/positionpermission/positionpermission.go b/internal/data/entity/ent/positionpermission/positionpermission.go new file mode 100644 index 00000000..17b96808 --- /dev/null +++ b/internal/data/entity/ent/positionpermission/positionpermission.go @@ -0,0 +1,171 @@ +// Code generated by ent, DO NOT EDIT. + +package positionpermission + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the positionpermission type in the database. + Label = "position_permission" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldPositionID holds the string denoting the position_id field in the database. + FieldPositionID = "position_id" + // FieldPermissionID holds the string denoting the permission_id field in the database. + FieldPermissionID = "permission_id" + // EdgePosition holds the string denoting the position edge name in mutations. + EdgePosition = "position" + // EdgePermission holds the string denoting the permission edge name in mutations. + EdgePermission = "permission" + // Table holds the table name of the positionpermission in the database. + Table = "sys_position_permissions" + // PositionTable is the table that holds the position relation/edge. + PositionTable = "sys_position_permissions" + // PositionInverseTable is the table name for the Position entity. + // It exists in this package in order to avoid circular dependency with the "position" package. + PositionInverseTable = "sys_positions" + // PositionColumn is the table column denoting the position relation/edge. + PositionColumn = "position_id" + // PermissionTable is the table that holds the permission relation/edge. + PermissionTable = "sys_position_permissions" + // PermissionInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionInverseTable = "sys_permissions" + // PermissionColumn is the table column denoting the permission relation/edge. + PermissionColumn = "permission_id" +) + +// Columns holds all SQL columns for positionpermission fields. +var Columns = []string{ + FieldID, + FieldPositionID, + FieldPermissionID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // PositionIDValidator is a validator for the "position_id" field. It is called by the builders before save. + PositionIDValidator func(int64) error + // PermissionIDValidator is a validator for the "permission_id" field. It is called by the builders before save. + PermissionIDValidator func(int64) error +) + +// OrderOption defines the ordering options for the PositionPermission queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByPositionID orders the results by the position_id field. +func ByPositionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPositionID, opts...).ToFunc() +} + +// ByPermissionID orders the results by the permission_id field. +func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPermissionID, opts...).ToFunc() +} + +// ByPositionField orders the results by position field. +func ByPositionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPositionStep(), sql.OrderByField(field, opts...)) + } +} + +// ByPermissionField orders the results by permission field. +func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) + } +} +func newPositionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PositionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PositionTable, PositionColumn), + ) +} +func newPermissionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/positionpermission/where.go b/internal/data/entity/ent/positionpermission/where.go new file mode 100644 index 00000000..7256c58a --- /dev/null +++ b/internal/data/entity/ent/positionpermission/where.go @@ -0,0 +1,166 @@ +// Code generated by ent, DO NOT EDIT. + +package positionpermission + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldLTE(FieldID, id)) +} + +// PositionID applies equality check predicate on the "position_id" field. It's identical to PositionIDEQ. +func PositionID(v int64) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldEQ(FieldPositionID, v)) +} + +// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. +func PermissionID(v int64) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldEQ(FieldPermissionID, v)) +} + +// PositionIDEQ applies the EQ predicate on the "position_id" field. +func PositionIDEQ(v int64) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldEQ(FieldPositionID, v)) +} + +// PositionIDNEQ applies the NEQ predicate on the "position_id" field. +func PositionIDNEQ(v int64) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldNEQ(FieldPositionID, v)) +} + +// PositionIDIn applies the In predicate on the "position_id" field. +func PositionIDIn(vs ...int64) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldIn(FieldPositionID, vs...)) +} + +// PositionIDNotIn applies the NotIn predicate on the "position_id" field. +func PositionIDNotIn(vs ...int64) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldNotIn(FieldPositionID, vs...)) +} + +// PermissionIDEQ applies the EQ predicate on the "permission_id" field. +func PermissionIDEQ(v int64) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldEQ(FieldPermissionID, v)) +} + +// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. +func PermissionIDNEQ(v int64) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldNEQ(FieldPermissionID, v)) +} + +// PermissionIDIn applies the In predicate on the "permission_id" field. +func PermissionIDIn(vs ...int64) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldIn(FieldPermissionID, vs...)) +} + +// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. +func PermissionIDNotIn(vs ...int64) predicate.PositionPermission { + return predicate.PositionPermission(sql.FieldNotIn(FieldPermissionID, vs...)) +} + +// HasPosition applies the HasEdge predicate on the "position" edge. +func HasPosition() predicate.PositionPermission { + return predicate.PositionPermission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PositionTable, PositionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPositionWith applies the HasEdge predicate on the "position" edge with a given conditions (other predicates). +func HasPositionWith(preds ...predicate.Position) predicate.PositionPermission { + return predicate.PositionPermission(func(s *sql.Selector) { + step := newPositionStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermission applies the HasEdge predicate on the "permission" edge. +func HasPermission() predicate.PositionPermission { + return predicate.PositionPermission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). +func HasPermissionWith(preds ...predicate.Permission) predicate.PositionPermission { + return predicate.PositionPermission(func(s *sql.Selector) { + step := newPermissionStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PositionPermission) predicate.PositionPermission { + return predicate.PositionPermission(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PositionPermission) predicate.PositionPermission { + return predicate.PositionPermission(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PositionPermission) predicate.PositionPermission { + return predicate.PositionPermission(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/resource/resource.go b/internal/data/entity/ent/resource/resource.go new file mode 100644 index 00000000..9dc8240a --- /dev/null +++ b/internal/data/entity/ent/resource/resource.go @@ -0,0 +1,427 @@ +// Code generated by ent, DO NOT EDIT. + +package resource + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the resource type in the database. + Label = "resource" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldKeyword holds the string denoting the keyword field in the database. + FieldKeyword = "keyword" + // FieldI18nKey holds the string denoting the i18n_key field in the database. + FieldI18nKey = "i18n_key" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldPath holds the string denoting the path field in the database. + FieldPath = "path" + // FieldOperation holds the string denoting the operation field in the database. + FieldOperation = "operation" + // FieldMethod holds the string denoting the method field in the database. + FieldMethod = "method" + // FieldComponent holds the string denoting the component field in the database. + FieldComponent = "component" + // FieldIcon holds the string denoting the icon field in the database. + FieldIcon = "icon" + // FieldSequence holds the string denoting the sequence field in the database. + FieldSequence = "sequence" + // FieldVisible holds the string denoting the visible field in the database. + FieldVisible = "visible" + // FieldLevel holds the string denoting the level field in the database. + FieldLevel = "level" + // FieldTreePath holds the string denoting the tree_path field in the database. + FieldTreePath = "tree_path" + // FieldProperties holds the string denoting the properties field in the database. + FieldProperties = "properties" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldParentID holds the string denoting the parent_id field in the database. + FieldParentID = "parent_id" + // EdgeChildren holds the string denoting the children edge name in mutations. + EdgeChildren = "children" + // EdgeParent holds the string denoting the parent edge name in mutations. + EdgeParent = "parent" + // EdgePermissions holds the string denoting the permissions edge name in mutations. + EdgePermissions = "permissions" + // EdgePermissionResources holds the string denoting the permission_resources edge name in mutations. + EdgePermissionResources = "permission_resources" + // Table holds the table name of the resource in the database. + Table = "sys_resources" + // ChildrenTable is the table that holds the children relation/edge. + ChildrenTable = "sys_resources" + // ChildrenColumn is the table column denoting the children relation/edge. + ChildrenColumn = "parent_id" + // ParentTable is the table that holds the parent relation/edge. + ParentTable = "sys_resources" + // ParentColumn is the table column denoting the parent relation/edge. + ParentColumn = "parent_id" + // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. + PermissionsTable = "sys_permission_resources" + // PermissionsInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionsInverseTable = "sys_permissions" + // PermissionResourcesTable is the table that holds the permission_resources relation/edge. + PermissionResourcesTable = "sys_permission_resources" + // PermissionResourcesInverseTable is the table name for the PermissionResource entity. + // It exists in this package in order to avoid circular dependency with the "permissionresource" package. + PermissionResourcesInverseTable = "sys_permission_resources" + // PermissionResourcesColumn is the table column denoting the permission_resources relation/edge. + PermissionResourcesColumn = "resource_id" +) + +// Columns holds all SQL columns for resource fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldName, + FieldKeyword, + FieldI18nKey, + FieldType, + FieldStatus, + FieldPath, + FieldOperation, + FieldMethod, + FieldComponent, + FieldIcon, + FieldSequence, + FieldVisible, + FieldLevel, + FieldTreePath, + FieldProperties, + FieldDescription, + FieldParentID, +} + +var ( + // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the + // primary key for the permissions relation (M2M). + PermissionsPrimaryKey = []string{"permission_id", "resource_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // DefaultName holds the default value on creation for the "name" field. + DefaultName string + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + KeywordValidator func(string) error + // DefaultI18nKey holds the default value on creation for the "i18n_key" field. + DefaultI18nKey string + // I18nKeyValidator is a validator for the "i18n_key" field. It is called by the builders before save. + I18nKeyValidator func(string) error + // DefaultType holds the default value on creation for the "type" field. + DefaultType string + // TypeValidator is a validator for the "type" field. It is called by the builders before save. + TypeValidator func(string) error + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int8 + // DefaultPath holds the default value on creation for the "path" field. + DefaultPath string + // PathValidator is a validator for the "path" field. It is called by the builders before save. + PathValidator func(string) error + // DefaultOperation holds the default value on creation for the "operation" field. + DefaultOperation string + // OperationValidator is a validator for the "operation" field. It is called by the builders before save. + OperationValidator func(string) error + // DefaultMethod holds the default value on creation for the "method" field. + DefaultMethod string + // MethodValidator is a validator for the "method" field. It is called by the builders before save. + MethodValidator func(string) error + // DefaultComponent holds the default value on creation for the "component" field. + DefaultComponent string + // ComponentValidator is a validator for the "component" field. It is called by the builders before save. + ComponentValidator func(string) error + // DefaultIcon holds the default value on creation for the "icon" field. + DefaultIcon string + // IconValidator is a validator for the "icon" field. It is called by the builders before save. + IconValidator func(string) error + // DefaultSequence holds the default value on creation for the "sequence" field. + DefaultSequence int + // DefaultVisible holds the default value on creation for the "visible" field. + DefaultVisible bool + // DefaultLevel holds the default value on creation for the "level" field. + DefaultLevel int8 + // DefaultTreePath holds the default value on creation for the "tree_path" field. + DefaultTreePath string + // TreePathValidator is a validator for the "tree_path" field. It is called by the builders before save. + TreePathValidator func(string) error + // DefaultDescription holds the default value on creation for the "description" field. + DefaultDescription string + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error + // ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. + ParentIDValidator func(int64) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int64) error +) + +// OrderOption defines the ordering options for the Resource queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByKeyword orders the results by the keyword field. +func ByKeyword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKeyword, opts...).ToFunc() +} + +// ByI18nKey orders the results by the i18n_key field. +func ByI18nKey(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldI18nKey, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByPath orders the results by the path field. +func ByPath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPath, opts...).ToFunc() +} + +// ByOperation orders the results by the operation field. +func ByOperation(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOperation, opts...).ToFunc() +} + +// ByMethod orders the results by the method field. +func ByMethod(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldMethod, opts...).ToFunc() +} + +// ByComponent orders the results by the component field. +func ByComponent(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldComponent, opts...).ToFunc() +} + +// ByIcon orders the results by the icon field. +func ByIcon(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIcon, opts...).ToFunc() +} + +// BySequence orders the results by the sequence field. +func BySequence(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSequence, opts...).ToFunc() +} + +// ByVisible orders the results by the visible field. +func ByVisible(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVisible, opts...).ToFunc() +} + +// ByLevel orders the results by the level field. +func ByLevel(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLevel, opts...).ToFunc() +} + +// ByTreePath orders the results by the tree_path field. +func ByTreePath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTreePath, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByParentID orders the results by the parent_id field. +func ByParentID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldParentID, opts...).ToFunc() +} + +// ByChildrenCount orders the results by children count. +func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) + } +} + +// ByChildren orders the results by children terms. +func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByParentField orders the results by parent field. +func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) + } +} + +// ByPermissionsCount orders the results by permissions count. +func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) + } +} + +// ByPermissions orders the results by permissions terms. +func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPermissionResourcesCount orders the results by permission_resources count. +func ByPermissionResourcesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPermissionResourcesStep(), opts...) + } +} + +// ByPermissionResources orders the results by permission_resources terms. +func ByPermissionResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newChildrenStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) +} +func newParentStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) +} +func newPermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), + ) +} +func newPermissionResourcesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionResourcesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/resource/where.go b/internal/data/entity/ent/resource/where.go new file mode 100644 index 00000000..6040258b --- /dev/null +++ b/internal/data/entity/ent/resource/where.go @@ -0,0 +1,1218 @@ +// Code generated by ent, DO NOT EDIT. + +package resource + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldName, v)) +} + +// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. +func Keyword(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) +} + +// I18nKey applies equality check predicate on the "i18n_key" field. It's identical to I18nKeyEQ. +func I18nKey(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldI18nKey, v)) +} + +// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. +func Type(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldType, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int8) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldStatus, v)) +} + +// Path applies equality check predicate on the "path" field. It's identical to PathEQ. +func Path(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldPath, v)) +} + +// Operation applies equality check predicate on the "operation" field. It's identical to OperationEQ. +func Operation(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldOperation, v)) +} + +// Method applies equality check predicate on the "method" field. It's identical to MethodEQ. +func Method(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldMethod, v)) +} + +// Component applies equality check predicate on the "component" field. It's identical to ComponentEQ. +func Component(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldComponent, v)) +} + +// Icon applies equality check predicate on the "icon" field. It's identical to IconEQ. +func Icon(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldIcon, v)) +} + +// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. +func Sequence(v int) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldSequence, v)) +} + +// Visible applies equality check predicate on the "visible" field. It's identical to VisibleEQ. +func Visible(v bool) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldVisible, v)) +} + +// Level applies equality check predicate on the "level" field. It's identical to LevelEQ. +func Level(v int8) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldLevel, v)) +} + +// TreePath applies equality check predicate on the "tree_path" field. It's identical to TreePathEQ. +func TreePath(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldDescription, v)) +} + +// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ. +func ParentID(v int64) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldParentID, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldUpdateTime, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldName, v)) +} + +// KeywordEQ applies the EQ predicate on the "keyword" field. +func KeywordEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) +} + +// KeywordNEQ applies the NEQ predicate on the "keyword" field. +func KeywordNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldKeyword, v)) +} + +// KeywordIn applies the In predicate on the "keyword" field. +func KeywordIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldKeyword, vs...)) +} + +// KeywordNotIn applies the NotIn predicate on the "keyword" field. +func KeywordNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldKeyword, vs...)) +} + +// KeywordGT applies the GT predicate on the "keyword" field. +func KeywordGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldKeyword, v)) +} + +// KeywordGTE applies the GTE predicate on the "keyword" field. +func KeywordGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldKeyword, v)) +} + +// KeywordLT applies the LT predicate on the "keyword" field. +func KeywordLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldKeyword, v)) +} + +// KeywordLTE applies the LTE predicate on the "keyword" field. +func KeywordLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldKeyword, v)) +} + +// KeywordContains applies the Contains predicate on the "keyword" field. +func KeywordContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldKeyword, v)) +} + +// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. +func KeywordHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldKeyword, v)) +} + +// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. +func KeywordHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldKeyword, v)) +} + +// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. +func KeywordEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldKeyword, v)) +} + +// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. +func KeywordContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldKeyword, v)) +} + +// I18nKeyEQ applies the EQ predicate on the "i18n_key" field. +func I18nKeyEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldI18nKey, v)) +} + +// I18nKeyNEQ applies the NEQ predicate on the "i18n_key" field. +func I18nKeyNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldI18nKey, v)) +} + +// I18nKeyIn applies the In predicate on the "i18n_key" field. +func I18nKeyIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldI18nKey, vs...)) +} + +// I18nKeyNotIn applies the NotIn predicate on the "i18n_key" field. +func I18nKeyNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldI18nKey, vs...)) +} + +// I18nKeyGT applies the GT predicate on the "i18n_key" field. +func I18nKeyGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldI18nKey, v)) +} + +// I18nKeyGTE applies the GTE predicate on the "i18n_key" field. +func I18nKeyGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldI18nKey, v)) +} + +// I18nKeyLT applies the LT predicate on the "i18n_key" field. +func I18nKeyLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldI18nKey, v)) +} + +// I18nKeyLTE applies the LTE predicate on the "i18n_key" field. +func I18nKeyLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldI18nKey, v)) +} + +// I18nKeyContains applies the Contains predicate on the "i18n_key" field. +func I18nKeyContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldI18nKey, v)) +} + +// I18nKeyHasPrefix applies the HasPrefix predicate on the "i18n_key" field. +func I18nKeyHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldI18nKey, v)) +} + +// I18nKeyHasSuffix applies the HasSuffix predicate on the "i18n_key" field. +func I18nKeyHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldI18nKey, v)) +} + +// I18nKeyEqualFold applies the EqualFold predicate on the "i18n_key" field. +func I18nKeyEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldI18nKey, v)) +} + +// I18nKeyContainsFold applies the ContainsFold predicate on the "i18n_key" field. +func I18nKeyContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldI18nKey, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldType, vs...)) +} + +// TypeGT applies the GT predicate on the "type" field. +func TypeGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldType, v)) +} + +// TypeGTE applies the GTE predicate on the "type" field. +func TypeGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldType, v)) +} + +// TypeLT applies the LT predicate on the "type" field. +func TypeLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldType, v)) +} + +// TypeLTE applies the LTE predicate on the "type" field. +func TypeLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldType, v)) +} + +// TypeContains applies the Contains predicate on the "type" field. +func TypeContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldType, v)) +} + +// TypeHasPrefix applies the HasPrefix predicate on the "type" field. +func TypeHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldType, v)) +} + +// TypeHasSuffix applies the HasSuffix predicate on the "type" field. +func TypeHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldType, v)) +} + +// TypeEqualFold applies the EqualFold predicate on the "type" field. +func TypeEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldType, v)) +} + +// TypeContainsFold applies the ContainsFold predicate on the "type" field. +func TypeContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldType, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int8) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int8) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int8) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int8) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int8) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int8) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int8) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int8) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldStatus, v)) +} + +// PathEQ applies the EQ predicate on the "path" field. +func PathEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldPath, v)) +} + +// PathNEQ applies the NEQ predicate on the "path" field. +func PathNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldPath, v)) +} + +// PathIn applies the In predicate on the "path" field. +func PathIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldPath, vs...)) +} + +// PathNotIn applies the NotIn predicate on the "path" field. +func PathNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldPath, vs...)) +} + +// PathGT applies the GT predicate on the "path" field. +func PathGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldPath, v)) +} + +// PathGTE applies the GTE predicate on the "path" field. +func PathGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldPath, v)) +} + +// PathLT applies the LT predicate on the "path" field. +func PathLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldPath, v)) +} + +// PathLTE applies the LTE predicate on the "path" field. +func PathLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldPath, v)) +} + +// PathContains applies the Contains predicate on the "path" field. +func PathContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldPath, v)) +} + +// PathHasPrefix applies the HasPrefix predicate on the "path" field. +func PathHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldPath, v)) +} + +// PathHasSuffix applies the HasSuffix predicate on the "path" field. +func PathHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldPath, v)) +} + +// PathEqualFold applies the EqualFold predicate on the "path" field. +func PathEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldPath, v)) +} + +// PathContainsFold applies the ContainsFold predicate on the "path" field. +func PathContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldPath, v)) +} + +// OperationEQ applies the EQ predicate on the "operation" field. +func OperationEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldOperation, v)) +} + +// OperationNEQ applies the NEQ predicate on the "operation" field. +func OperationNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldOperation, v)) +} + +// OperationIn applies the In predicate on the "operation" field. +func OperationIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldOperation, vs...)) +} + +// OperationNotIn applies the NotIn predicate on the "operation" field. +func OperationNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldOperation, vs...)) +} + +// OperationGT applies the GT predicate on the "operation" field. +func OperationGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldOperation, v)) +} + +// OperationGTE applies the GTE predicate on the "operation" field. +func OperationGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldOperation, v)) +} + +// OperationLT applies the LT predicate on the "operation" field. +func OperationLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldOperation, v)) +} + +// OperationLTE applies the LTE predicate on the "operation" field. +func OperationLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldOperation, v)) +} + +// OperationContains applies the Contains predicate on the "operation" field. +func OperationContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldOperation, v)) +} + +// OperationHasPrefix applies the HasPrefix predicate on the "operation" field. +func OperationHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldOperation, v)) +} + +// OperationHasSuffix applies the HasSuffix predicate on the "operation" field. +func OperationHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldOperation, v)) +} + +// OperationEqualFold applies the EqualFold predicate on the "operation" field. +func OperationEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldOperation, v)) +} + +// OperationContainsFold applies the ContainsFold predicate on the "operation" field. +func OperationContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldOperation, v)) +} + +// MethodEQ applies the EQ predicate on the "method" field. +func MethodEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldMethod, v)) +} + +// MethodNEQ applies the NEQ predicate on the "method" field. +func MethodNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldMethod, v)) +} + +// MethodIn applies the In predicate on the "method" field. +func MethodIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldMethod, vs...)) +} + +// MethodNotIn applies the NotIn predicate on the "method" field. +func MethodNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldMethod, vs...)) +} + +// MethodGT applies the GT predicate on the "method" field. +func MethodGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldMethod, v)) +} + +// MethodGTE applies the GTE predicate on the "method" field. +func MethodGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldMethod, v)) +} + +// MethodLT applies the LT predicate on the "method" field. +func MethodLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldMethod, v)) +} + +// MethodLTE applies the LTE predicate on the "method" field. +func MethodLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldMethod, v)) +} + +// MethodContains applies the Contains predicate on the "method" field. +func MethodContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldMethod, v)) +} + +// MethodHasPrefix applies the HasPrefix predicate on the "method" field. +func MethodHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldMethod, v)) +} + +// MethodHasSuffix applies the HasSuffix predicate on the "method" field. +func MethodHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldMethod, v)) +} + +// MethodEqualFold applies the EqualFold predicate on the "method" field. +func MethodEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldMethod, v)) +} + +// MethodContainsFold applies the ContainsFold predicate on the "method" field. +func MethodContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldMethod, v)) +} + +// ComponentEQ applies the EQ predicate on the "component" field. +func ComponentEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldComponent, v)) +} + +// ComponentNEQ applies the NEQ predicate on the "component" field. +func ComponentNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldComponent, v)) +} + +// ComponentIn applies the In predicate on the "component" field. +func ComponentIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldComponent, vs...)) +} + +// ComponentNotIn applies the NotIn predicate on the "component" field. +func ComponentNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldComponent, vs...)) +} + +// ComponentGT applies the GT predicate on the "component" field. +func ComponentGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldComponent, v)) +} + +// ComponentGTE applies the GTE predicate on the "component" field. +func ComponentGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldComponent, v)) +} + +// ComponentLT applies the LT predicate on the "component" field. +func ComponentLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldComponent, v)) +} + +// ComponentLTE applies the LTE predicate on the "component" field. +func ComponentLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldComponent, v)) +} + +// ComponentContains applies the Contains predicate on the "component" field. +func ComponentContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldComponent, v)) +} + +// ComponentHasPrefix applies the HasPrefix predicate on the "component" field. +func ComponentHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldComponent, v)) +} + +// ComponentHasSuffix applies the HasSuffix predicate on the "component" field. +func ComponentHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldComponent, v)) +} + +// ComponentEqualFold applies the EqualFold predicate on the "component" field. +func ComponentEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldComponent, v)) +} + +// ComponentContainsFold applies the ContainsFold predicate on the "component" field. +func ComponentContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldComponent, v)) +} + +// IconEQ applies the EQ predicate on the "icon" field. +func IconEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldIcon, v)) +} + +// IconNEQ applies the NEQ predicate on the "icon" field. +func IconNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldIcon, v)) +} + +// IconIn applies the In predicate on the "icon" field. +func IconIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldIcon, vs...)) +} + +// IconNotIn applies the NotIn predicate on the "icon" field. +func IconNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldIcon, vs...)) +} + +// IconGT applies the GT predicate on the "icon" field. +func IconGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldIcon, v)) +} + +// IconGTE applies the GTE predicate on the "icon" field. +func IconGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldIcon, v)) +} + +// IconLT applies the LT predicate on the "icon" field. +func IconLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldIcon, v)) +} + +// IconLTE applies the LTE predicate on the "icon" field. +func IconLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldIcon, v)) +} + +// IconContains applies the Contains predicate on the "icon" field. +func IconContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldIcon, v)) +} + +// IconHasPrefix applies the HasPrefix predicate on the "icon" field. +func IconHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldIcon, v)) +} + +// IconHasSuffix applies the HasSuffix predicate on the "icon" field. +func IconHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldIcon, v)) +} + +// IconEqualFold applies the EqualFold predicate on the "icon" field. +func IconEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldIcon, v)) +} + +// IconContainsFold applies the ContainsFold predicate on the "icon" field. +func IconContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldIcon, v)) +} + +// SequenceEQ applies the EQ predicate on the "sequence" field. +func SequenceEQ(v int) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldSequence, v)) +} + +// SequenceNEQ applies the NEQ predicate on the "sequence" field. +func SequenceNEQ(v int) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldSequence, v)) +} + +// SequenceIn applies the In predicate on the "sequence" field. +func SequenceIn(vs ...int) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldSequence, vs...)) +} + +// SequenceNotIn applies the NotIn predicate on the "sequence" field. +func SequenceNotIn(vs ...int) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldSequence, vs...)) +} + +// SequenceGT applies the GT predicate on the "sequence" field. +func SequenceGT(v int) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldSequence, v)) +} + +// SequenceGTE applies the GTE predicate on the "sequence" field. +func SequenceGTE(v int) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldSequence, v)) +} + +// SequenceLT applies the LT predicate on the "sequence" field. +func SequenceLT(v int) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldSequence, v)) +} + +// SequenceLTE applies the LTE predicate on the "sequence" field. +func SequenceLTE(v int) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldSequence, v)) +} + +// VisibleEQ applies the EQ predicate on the "visible" field. +func VisibleEQ(v bool) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldVisible, v)) +} + +// VisibleNEQ applies the NEQ predicate on the "visible" field. +func VisibleNEQ(v bool) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldVisible, v)) +} + +// LevelEQ applies the EQ predicate on the "level" field. +func LevelEQ(v int8) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldLevel, v)) +} + +// LevelNEQ applies the NEQ predicate on the "level" field. +func LevelNEQ(v int8) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldLevel, v)) +} + +// LevelIn applies the In predicate on the "level" field. +func LevelIn(vs ...int8) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldLevel, vs...)) +} + +// LevelNotIn applies the NotIn predicate on the "level" field. +func LevelNotIn(vs ...int8) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldLevel, vs...)) +} + +// LevelGT applies the GT predicate on the "level" field. +func LevelGT(v int8) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldLevel, v)) +} + +// LevelGTE applies the GTE predicate on the "level" field. +func LevelGTE(v int8) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldLevel, v)) +} + +// LevelLT applies the LT predicate on the "level" field. +func LevelLT(v int8) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldLevel, v)) +} + +// LevelLTE applies the LTE predicate on the "level" field. +func LevelLTE(v int8) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldLevel, v)) +} + +// TreePathEQ applies the EQ predicate on the "tree_path" field. +func TreePathEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) +} + +// TreePathNEQ applies the NEQ predicate on the "tree_path" field. +func TreePathNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldTreePath, v)) +} + +// TreePathIn applies the In predicate on the "tree_path" field. +func TreePathIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldTreePath, vs...)) +} + +// TreePathNotIn applies the NotIn predicate on the "tree_path" field. +func TreePathNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldTreePath, vs...)) +} + +// TreePathGT applies the GT predicate on the "tree_path" field. +func TreePathGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldTreePath, v)) +} + +// TreePathGTE applies the GTE predicate on the "tree_path" field. +func TreePathGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldTreePath, v)) +} + +// TreePathLT applies the LT predicate on the "tree_path" field. +func TreePathLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldTreePath, v)) +} + +// TreePathLTE applies the LTE predicate on the "tree_path" field. +func TreePathLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldTreePath, v)) +} + +// TreePathContains applies the Contains predicate on the "tree_path" field. +func TreePathContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldTreePath, v)) +} + +// TreePathHasPrefix applies the HasPrefix predicate on the "tree_path" field. +func TreePathHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldTreePath, v)) +} + +// TreePathHasSuffix applies the HasSuffix predicate on the "tree_path" field. +func TreePathHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldTreePath, v)) +} + +// TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. +func TreePathEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldTreePath, v)) +} + +// TreePathContainsFold applies the ContainsFold predicate on the "tree_path" field. +func TreePathContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldTreePath, v)) +} + +// PropertiesIsNil applies the IsNil predicate on the "properties" field. +func PropertiesIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldProperties)) +} + +// PropertiesNotNil applies the NotNil predicate on the "properties" field. +func PropertiesNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldProperties)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldDescription, v)) +} + +// ParentIDEQ applies the EQ predicate on the "parent_id" field. +func ParentIDEQ(v int64) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldParentID, v)) +} + +// ParentIDNEQ applies the NEQ predicate on the "parent_id" field. +func ParentIDNEQ(v int64) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldParentID, v)) +} + +// ParentIDIn applies the In predicate on the "parent_id" field. +func ParentIDIn(vs ...int64) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldParentID, vs...)) +} + +// ParentIDNotIn applies the NotIn predicate on the "parent_id" field. +func ParentIDNotIn(vs ...int64) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldParentID, vs...)) +} + +// ParentIDIsNil applies the IsNil predicate on the "parent_id" field. +func ParentIDIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldParentID)) +} + +// ParentIDNotNil applies the NotNil predicate on the "parent_id" field. +func ParentIDNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldParentID)) +} + +// HasChildren applies the HasEdge predicate on the "children" edge. +func HasChildren() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates). +func HasChildrenWith(preds ...predicate.Resource) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newChildrenStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasParent applies the HasEdge predicate on the "parent" edge. +func HasParent() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). +func HasParentWith(preds ...predicate.Resource) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newParentStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermissions applies the HasEdge predicate on the "permissions" edge. +func HasPermissions() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). +func HasPermissionsWith(preds ...predicate.Permission) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newPermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermissionResources applies the HasEdge predicate on the "permission_resources" edge. +func HasPermissionResources() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionResourcesWith applies the HasEdge predicate on the "permission_resources" edge with a given conditions (other predicates). +func HasPermissionResourcesWith(preds ...predicate.PermissionResource) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newPermissionResourcesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Resource) predicate.Resource { + return predicate.Resource(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Resource) predicate.Resource { + return predicate.Resource(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Resource) predicate.Resource { + return predicate.Resource(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/role/role.go b/internal/data/entity/ent/role/role.go new file mode 100644 index 00000000..a09ff5e5 --- /dev/null +++ b/internal/data/entity/ent/role/role.go @@ -0,0 +1,322 @@ +// Code generated by ent, DO NOT EDIT. + +package role + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the role type in the database. + Label = "role" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldKeyword holds the string denoting the keyword field in the database. + FieldKeyword = "keyword" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldSequence holds the string denoting the sequence field in the database. + FieldSequence = "sequence" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // EdgeUsers holds the string denoting the users edge name in mutations. + EdgeUsers = "users" + // EdgePermissions holds the string denoting the permissions edge name in mutations. + EdgePermissions = "permissions" + // EdgeUserRoles holds the string denoting the user_roles edge name in mutations. + EdgeUserRoles = "user_roles" + // EdgeRolePermissions holds the string denoting the role_permissions edge name in mutations. + EdgeRolePermissions = "role_permissions" + // Table holds the table name of the role in the database. + Table = "sys_roles" + // UsersTable is the table that holds the users relation/edge. The primary key declared below. + UsersTable = "sys_user_roles" + // UsersInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UsersInverseTable = "sys_users" + // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. + PermissionsTable = "sys_role_permissions" + // PermissionsInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionsInverseTable = "sys_permissions" + // UserRolesTable is the table that holds the user_roles relation/edge. + UserRolesTable = "sys_user_roles" + // UserRolesInverseTable is the table name for the UserRole entity. + // It exists in this package in order to avoid circular dependency with the "userrole" package. + UserRolesInverseTable = "sys_user_roles" + // UserRolesColumn is the table column denoting the user_roles relation/edge. + UserRolesColumn = "role_id" + // RolePermissionsTable is the table that holds the role_permissions relation/edge. + RolePermissionsTable = "sys_role_permissions" + // RolePermissionsInverseTable is the table name for the RolePermission entity. + // It exists in this package in order to avoid circular dependency with the "rolepermission" package. + RolePermissionsInverseTable = "sys_role_permissions" + // RolePermissionsColumn is the table column denoting the role_permissions relation/edge. + RolePermissionsColumn = "role_id" +) + +// Columns holds all SQL columns for role fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldKeyword, + FieldName, + FieldDescription, + FieldType, + FieldSequence, + FieldStatus, +} + +var ( + // UsersPrimaryKey and UsersColumn2 are the table columns denoting the + // primary key for the users relation (M2M). + UsersPrimaryKey = []string{"user_id", "role_id"} + // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the + // primary key for the permissions relation (M2M). + PermissionsPrimaryKey = []string{"role_id", "permission_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + KeywordValidator func(string) error + // DefaultName holds the default value on creation for the "name" field. + DefaultName string + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultDescription holds the default value on creation for the "description" field. + DefaultDescription string + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error + // DefaultType holds the default value on creation for the "type" field. + DefaultType int8 + // DefaultSequence holds the default value on creation for the "sequence" field. + DefaultSequence int + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int8 + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int64) error +) + +// OrderOption defines the ordering options for the Role queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByKeyword orders the results by the keyword field. +func ByKeyword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKeyword, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// BySequence orders the results by the sequence field. +func BySequence(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSequence, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByUsersCount orders the results by users count. +func ByUsersCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...) + } +} + +// ByUsers orders the results by users terms. +func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPermissionsCount orders the results by permissions count. +func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) + } +} + +// ByPermissions orders the results by permissions terms. +func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByUserRolesCount orders the results by user_roles count. +func ByUserRolesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserRolesStep(), opts...) + } +} + +// ByUserRoles orders the results by user_roles terms. +func ByUserRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserRolesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByRolePermissionsCount orders the results by role_permissions count. +func ByRolePermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRolePermissionsStep(), opts...) + } +} + +// ByRolePermissions orders the results by role_permissions terms. +func ByRolePermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRolePermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newUsersStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UsersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), + ) +} +func newPermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), + ) +} +func newUserRolesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserRolesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), + ) +} +func newRolePermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RolePermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/role/where.go b/internal/data/entity/ent/role/where.go new file mode 100644 index 00000000..d308036e --- /dev/null +++ b/internal/data/entity/ent/role/where.go @@ -0,0 +1,598 @@ +// Code generated by ent, DO NOT EDIT. + +package role + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.Role { + return predicate.Role(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.Role { + return predicate.Role(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.Role { + return predicate.Role(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. +func Keyword(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldKeyword, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldName, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldDescription, v)) +} + +// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. +func Type(v int8) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldType, v)) +} + +// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. +func Sequence(v int) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldSequence, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int8) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldStatus, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Role { + return predicate.Role(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Role { + return predicate.Role(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Role { + return predicate.Role(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Role { + return predicate.Role(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Role { + return predicate.Role(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Role { + return predicate.Role(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldUpdateTime, v)) +} + +// KeywordEQ applies the EQ predicate on the "keyword" field. +func KeywordEQ(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldKeyword, v)) +} + +// KeywordNEQ applies the NEQ predicate on the "keyword" field. +func KeywordNEQ(v string) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldKeyword, v)) +} + +// KeywordIn applies the In predicate on the "keyword" field. +func KeywordIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldIn(FieldKeyword, vs...)) +} + +// KeywordNotIn applies the NotIn predicate on the "keyword" field. +func KeywordNotIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldKeyword, vs...)) +} + +// KeywordGT applies the GT predicate on the "keyword" field. +func KeywordGT(v string) predicate.Role { + return predicate.Role(sql.FieldGT(FieldKeyword, v)) +} + +// KeywordGTE applies the GTE predicate on the "keyword" field. +func KeywordGTE(v string) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldKeyword, v)) +} + +// KeywordLT applies the LT predicate on the "keyword" field. +func KeywordLT(v string) predicate.Role { + return predicate.Role(sql.FieldLT(FieldKeyword, v)) +} + +// KeywordLTE applies the LTE predicate on the "keyword" field. +func KeywordLTE(v string) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldKeyword, v)) +} + +// KeywordContains applies the Contains predicate on the "keyword" field. +func KeywordContains(v string) predicate.Role { + return predicate.Role(sql.FieldContains(FieldKeyword, v)) +} + +// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. +func KeywordHasPrefix(v string) predicate.Role { + return predicate.Role(sql.FieldHasPrefix(FieldKeyword, v)) +} + +// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. +func KeywordHasSuffix(v string) predicate.Role { + return predicate.Role(sql.FieldHasSuffix(FieldKeyword, v)) +} + +// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. +func KeywordEqualFold(v string) predicate.Role { + return predicate.Role(sql.FieldEqualFold(FieldKeyword, v)) +} + +// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. +func KeywordContainsFold(v string) predicate.Role { + return predicate.Role(sql.FieldContainsFold(FieldKeyword, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Role { + return predicate.Role(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Role { + return predicate.Role(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Role { + return predicate.Role(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Role { + return predicate.Role(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Role { + return predicate.Role(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Role { + return predicate.Role(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Role { + return predicate.Role(sql.FieldContainsFold(FieldName, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Role { + return predicate.Role(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Role { + return predicate.Role(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Role { + return predicate.Role(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Role { + return predicate.Role(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Role { + return predicate.Role(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Role { + return predicate.Role(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Role { + return predicate.Role(sql.FieldContainsFold(FieldDescription, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v int8) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v int8) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...int8) predicate.Role { + return predicate.Role(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...int8) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldType, vs...)) +} + +// TypeGT applies the GT predicate on the "type" field. +func TypeGT(v int8) predicate.Role { + return predicate.Role(sql.FieldGT(FieldType, v)) +} + +// TypeGTE applies the GTE predicate on the "type" field. +func TypeGTE(v int8) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldType, v)) +} + +// TypeLT applies the LT predicate on the "type" field. +func TypeLT(v int8) predicate.Role { + return predicate.Role(sql.FieldLT(FieldType, v)) +} + +// TypeLTE applies the LTE predicate on the "type" field. +func TypeLTE(v int8) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldType, v)) +} + +// SequenceEQ applies the EQ predicate on the "sequence" field. +func SequenceEQ(v int) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldSequence, v)) +} + +// SequenceNEQ applies the NEQ predicate on the "sequence" field. +func SequenceNEQ(v int) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldSequence, v)) +} + +// SequenceIn applies the In predicate on the "sequence" field. +func SequenceIn(vs ...int) predicate.Role { + return predicate.Role(sql.FieldIn(FieldSequence, vs...)) +} + +// SequenceNotIn applies the NotIn predicate on the "sequence" field. +func SequenceNotIn(vs ...int) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldSequence, vs...)) +} + +// SequenceGT applies the GT predicate on the "sequence" field. +func SequenceGT(v int) predicate.Role { + return predicate.Role(sql.FieldGT(FieldSequence, v)) +} + +// SequenceGTE applies the GTE predicate on the "sequence" field. +func SequenceGTE(v int) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldSequence, v)) +} + +// SequenceLT applies the LT predicate on the "sequence" field. +func SequenceLT(v int) predicate.Role { + return predicate.Role(sql.FieldLT(FieldSequence, v)) +} + +// SequenceLTE applies the LTE predicate on the "sequence" field. +func SequenceLTE(v int) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldSequence, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int8) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int8) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int8) predicate.Role { + return predicate.Role(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int8) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int8) predicate.Role { + return predicate.Role(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int8) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int8) predicate.Role { + return predicate.Role(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int8) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldStatus, v)) +} + +// HasUsers applies the HasEdge predicate on the "users" edge. +func HasUsers() predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUsersWith applies the HasEdge predicate on the "users" edge with a given conditions (other predicates). +func HasUsersWith(preds ...predicate.User) predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := newUsersStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermissions applies the HasEdge predicate on the "permissions" edge. +func HasPermissions() predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). +func HasPermissionsWith(preds ...predicate.Permission) predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := newPermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasUserRoles applies the HasEdge predicate on the "user_roles" edge. +func HasUserRoles() predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserRolesWith applies the HasEdge predicate on the "user_roles" edge with a given conditions (other predicates). +func HasUserRolesWith(preds ...predicate.UserRole) predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := newUserRolesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasRolePermissions applies the HasEdge predicate on the "role_permissions" edge. +func HasRolePermissions() predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRolePermissionsWith applies the HasEdge predicate on the "role_permissions" edge with a given conditions (other predicates). +func HasRolePermissionsWith(preds ...predicate.RolePermission) predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := newRolePermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Role) predicate.Role { + return predicate.Role(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Role) predicate.Role { + return predicate.Role(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Role) predicate.Role { + return predicate.Role(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/rolepermission/rolepermission.go b/internal/data/entity/ent/rolepermission/rolepermission.go new file mode 100644 index 00000000..f5e2fac3 --- /dev/null +++ b/internal/data/entity/ent/rolepermission/rolepermission.go @@ -0,0 +1,171 @@ +// Code generated by ent, DO NOT EDIT. + +package rolepermission + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the rolepermission type in the database. + Label = "role_permission" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldRoleID holds the string denoting the role_id field in the database. + FieldRoleID = "role_id" + // FieldPermissionID holds the string denoting the permission_id field in the database. + FieldPermissionID = "permission_id" + // EdgeRole holds the string denoting the role edge name in mutations. + EdgeRole = "role" + // EdgePermission holds the string denoting the permission edge name in mutations. + EdgePermission = "permission" + // Table holds the table name of the rolepermission in the database. + Table = "sys_role_permissions" + // RoleTable is the table that holds the role relation/edge. + RoleTable = "sys_role_permissions" + // RoleInverseTable is the table name for the Role entity. + // It exists in this package in order to avoid circular dependency with the "role" package. + RoleInverseTable = "sys_roles" + // RoleColumn is the table column denoting the role relation/edge. + RoleColumn = "role_id" + // PermissionTable is the table that holds the permission relation/edge. + PermissionTable = "sys_role_permissions" + // PermissionInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionInverseTable = "sys_permissions" + // PermissionColumn is the table column denoting the permission relation/edge. + PermissionColumn = "permission_id" +) + +// Columns holds all SQL columns for rolepermission fields. +var Columns = []string{ + FieldID, + FieldRoleID, + FieldPermissionID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // RoleIDValidator is a validator for the "role_id" field. It is called by the builders before save. + RoleIDValidator func(int64) error + // PermissionIDValidator is a validator for the "permission_id" field. It is called by the builders before save. + PermissionIDValidator func(int64) error +) + +// OrderOption defines the ordering options for the RolePermission queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByRoleID orders the results by the role_id field. +func ByRoleID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRoleID, opts...).ToFunc() +} + +// ByPermissionID orders the results by the permission_id field. +func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPermissionID, opts...).ToFunc() +} + +// ByRoleField orders the results by role field. +func ByRoleField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRoleStep(), sql.OrderByField(field, opts...)) + } +} + +// ByPermissionField orders the results by permission field. +func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) + } +} +func newRoleStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RoleInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), + ) +} +func newPermissionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/rolepermission/where.go b/internal/data/entity/ent/rolepermission/where.go new file mode 100644 index 00000000..b11efee6 --- /dev/null +++ b/internal/data/entity/ent/rolepermission/where.go @@ -0,0 +1,166 @@ +// Code generated by ent, DO NOT EDIT. + +package rolepermission + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldLTE(FieldID, id)) +} + +// RoleID applies equality check predicate on the "role_id" field. It's identical to RoleIDEQ. +func RoleID(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldRoleID, v)) +} + +// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. +func PermissionID(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldPermissionID, v)) +} + +// RoleIDEQ applies the EQ predicate on the "role_id" field. +func RoleIDEQ(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldRoleID, v)) +} + +// RoleIDNEQ applies the NEQ predicate on the "role_id" field. +func RoleIDNEQ(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNEQ(FieldRoleID, v)) +} + +// RoleIDIn applies the In predicate on the "role_id" field. +func RoleIDIn(vs ...int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldIn(FieldRoleID, vs...)) +} + +// RoleIDNotIn applies the NotIn predicate on the "role_id" field. +func RoleIDNotIn(vs ...int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNotIn(FieldRoleID, vs...)) +} + +// PermissionIDEQ applies the EQ predicate on the "permission_id" field. +func PermissionIDEQ(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldPermissionID, v)) +} + +// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. +func PermissionIDNEQ(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNEQ(FieldPermissionID, v)) +} + +// PermissionIDIn applies the In predicate on the "permission_id" field. +func PermissionIDIn(vs ...int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldIn(FieldPermissionID, vs...)) +} + +// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. +func PermissionIDNotIn(vs ...int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNotIn(FieldPermissionID, vs...)) +} + +// HasRole applies the HasEdge predicate on the "role" edge. +func HasRole() predicate.RolePermission { + return predicate.RolePermission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRoleWith applies the HasEdge predicate on the "role" edge with a given conditions (other predicates). +func HasRoleWith(preds ...predicate.Role) predicate.RolePermission { + return predicate.RolePermission(func(s *sql.Selector) { + step := newRoleStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermission applies the HasEdge predicate on the "permission" edge. +func HasPermission() predicate.RolePermission { + return predicate.RolePermission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). +func HasPermissionWith(preds ...predicate.Permission) predicate.RolePermission { + return predicate.RolePermission(func(s *sql.Selector) { + step := newPermissionStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.RolePermission) predicate.RolePermission { + return predicate.RolePermission(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.RolePermission) predicate.RolePermission { + return predicate.RolePermission(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.RolePermission) predicate.RolePermission { + return predicate.RolePermission(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/user/user.go b/internal/data/entity/ent/user/user.go new file mode 100644 index 00000000..abbf2a13 --- /dev/null +++ b/internal/data/entity/ent/user/user.go @@ -0,0 +1,625 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +import ( + "fmt" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the user type in the database. + Label = "user" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateAuthor holds the string denoting the create_author field in the database. + FieldCreateAuthor = "create_author" + // FieldUpdateAuthor holds the string denoting the update_author field in the database. + FieldUpdateAuthor = "update_author" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldDeleteTime holds the string denoting the delete_time field in the database. + FieldDeleteTime = "delete_time" + // FieldUUID holds the string denoting the uuid field in the database. + FieldUUID = "uuid" + // FieldAllowedIP holds the string denoting the allowed_ip field in the database. + FieldAllowedIP = "allowed_ip" + // FieldUsername holds the string denoting the username field in the database. + FieldUsername = "username" + // FieldNickname holds the string denoting the nickname field in the database. + FieldNickname = "nickname" + // FieldAvatar holds the string denoting the avatar field in the database. + FieldAvatar = "avatar" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldGender holds the string denoting the gender field in the database. + FieldGender = "gender" + // FieldEncryptedPassword holds the string denoting the encrypted_password field in the database. + FieldEncryptedPassword = "encrypted_password" + // FieldSalt holds the string denoting the salt field in the database. + FieldSalt = "salt" + // FieldPhone holds the string denoting the phone field in the database. + FieldPhone = "phone" + // FieldEmail holds the string denoting the email field in the database. + FieldEmail = "email" + // FieldDepartment holds the string denoting the department field in the database. + FieldDepartment = "department" + // FieldRemark holds the string denoting the remark field in the database. + FieldRemark = "remark" + // FieldToken holds the string denoting the token field in the database. + FieldToken = "token" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldIsSystem holds the string denoting the is_system field in the database. + FieldIsSystem = "is_system" + // FieldLastLoginIP holds the string denoting the last_login_ip field in the database. + FieldLastLoginIP = "last_login_ip" + // FieldLastLoginTime holds the string denoting the last_login_time field in the database. + FieldLastLoginTime = "last_login_time" + // FieldLoginTime holds the string denoting the login_time field in the database. + FieldLoginTime = "login_time" + // FieldSanctionDate holds the string denoting the sanction_date field in the database. + FieldSanctionDate = "sanction_date" + // FieldManagerID holds the string denoting the manager_id field in the database. + FieldManagerID = "manager_id" + // FieldManager holds the string denoting the manager field in the database. + FieldManager = "manager" + // EdgeRoles holds the string denoting the roles edge name in mutations. + EdgeRoles = "roles" + // EdgePositions holds the string denoting the positions edge name in mutations. + EdgePositions = "positions" + // EdgeDepartments holds the string denoting the departments edge name in mutations. + EdgeDepartments = "departments" + // EdgeUserRoles holds the string denoting the user_roles edge name in mutations. + EdgeUserRoles = "user_roles" + // EdgeUserPositions holds the string denoting the user_positions edge name in mutations. + EdgeUserPositions = "user_positions" + // EdgeUserDepartments holds the string denoting the user_departments edge name in mutations. + EdgeUserDepartments = "user_departments" + // Table holds the table name of the user in the database. + Table = "sys_users" + // RolesTable is the table that holds the roles relation/edge. The primary key declared below. + RolesTable = "sys_user_roles" + // RolesInverseTable is the table name for the Role entity. + // It exists in this package in order to avoid circular dependency with the "role" package. + RolesInverseTable = "sys_roles" + // PositionsTable is the table that holds the positions relation/edge. The primary key declared below. + PositionsTable = "sys_user_positions" + // PositionsInverseTable is the table name for the Position entity. + // It exists in this package in order to avoid circular dependency with the "position" package. + PositionsInverseTable = "sys_positions" + // DepartmentsTable is the table that holds the departments relation/edge. The primary key declared below. + DepartmentsTable = "sys_user_departments" + // DepartmentsInverseTable is the table name for the Department entity. + // It exists in this package in order to avoid circular dependency with the "department" package. + DepartmentsInverseTable = "sys_departments" + // UserRolesTable is the table that holds the user_roles relation/edge. + UserRolesTable = "sys_user_roles" + // UserRolesInverseTable is the table name for the UserRole entity. + // It exists in this package in order to avoid circular dependency with the "userrole" package. + UserRolesInverseTable = "sys_user_roles" + // UserRolesColumn is the table column denoting the user_roles relation/edge. + UserRolesColumn = "user_id" + // UserPositionsTable is the table that holds the user_positions relation/edge. + UserPositionsTable = "sys_user_positions" + // UserPositionsInverseTable is the table name for the UserPosition entity. + // It exists in this package in order to avoid circular dependency with the "userposition" package. + UserPositionsInverseTable = "sys_user_positions" + // UserPositionsColumn is the table column denoting the user_positions relation/edge. + UserPositionsColumn = "user_id" + // UserDepartmentsTable is the table that holds the user_departments relation/edge. + UserDepartmentsTable = "sys_user_departments" + // UserDepartmentsInverseTable is the table name for the UserDepartment entity. + // It exists in this package in order to avoid circular dependency with the "userdepartment" package. + UserDepartmentsInverseTable = "sys_user_departments" + // UserDepartmentsColumn is the table column denoting the user_departments relation/edge. + UserDepartmentsColumn = "user_id" +) + +// Columns holds all SQL columns for user fields. +var Columns = []string{ + FieldID, + FieldCreateAuthor, + FieldUpdateAuthor, + FieldCreateTime, + FieldUpdateTime, + FieldDeleteTime, + FieldUUID, + FieldAllowedIP, + FieldUsername, + FieldNickname, + FieldAvatar, + FieldName, + FieldGender, + FieldEncryptedPassword, + FieldPhone, + FieldEmail, + FieldDepartment, + FieldRemark, + FieldToken, + FieldStatus, + FieldIsSystem, + FieldLastLoginIP, + FieldLastLoginTime, + FieldLoginTime, + FieldSanctionDate, + FieldManagerID, + FieldManager, +} + +var ( + // RolesPrimaryKey and RolesColumn2 are the table columns denoting the + // primary key for the roles relation (M2M). + RolesPrimaryKey = []string{"user_id", "role_id"} + // PositionsPrimaryKey and PositionsColumn2 are the table columns denoting the + // primary key for the positions relation (M2M). + PositionsPrimaryKey = []string{"user_id", "position_id"} + // DepartmentsPrimaryKey and DepartmentsColumn2 are the table columns denoting the + // primary key for the departments relation (M2M). + DepartmentsPrimaryKey = []string{"user_id", "department_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + for _, f := range [...]string{FieldSalt} { + if column == f { + return true + } + } + return false +} + +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "origadmin/application/admin/internal/data/entity/ent/runtime" +var ( + Hooks [2]ent.Hook + Interceptors [1]ent.Interceptor + // DefaultCreateAuthor holds the default value on creation for the "create_author" field. + DefaultCreateAuthor int64 + // DefaultUpdateAuthor holds the default value on creation for the "update_author" field. + DefaultUpdateAuthor int64 + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // UUIDValidator is a validator for the "uuid" field. It is called by the builders before save. + UUIDValidator func(string) error + // DefaultAllowedIP holds the default value on creation for the "allowed_ip" field. + DefaultAllowedIP string + // UsernameValidator is a validator for the "username" field. It is called by the builders before save. + UsernameValidator func(string) error + // DefaultNickname holds the default value on creation for the "nickname" field. + DefaultNickname string + // NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. + NicknameValidator func(string) error + // DefaultAvatar holds the default value on creation for the "avatar" field. + DefaultAvatar string + // AvatarValidator is a validator for the "avatar" field. It is called by the builders before save. + AvatarValidator func(string) error + // DefaultName holds the default value on creation for the "name" field. + DefaultName string + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultEncryptedPassword holds the default value on creation for the "encrypted_password" field. + DefaultEncryptedPassword string + // EncryptedPasswordValidator is a validator for the "encrypted_password" field. It is called by the builders before save. + EncryptedPasswordValidator func(string) error + // DefaultSalt holds the default value on creation for the "salt" field. + DefaultSalt string + // SaltValidator is a validator for the "salt" field. It is called by the builders before save. + SaltValidator func(string) error + // DefaultPhone holds the default value on creation for the "phone" field. + DefaultPhone string + // PhoneValidator is a validator for the "phone" field. It is called by the builders before save. + PhoneValidator func(string) error + // DefaultEmail holds the default value on creation for the "email" field. + DefaultEmail string + // EmailValidator is a validator for the "email" field. It is called by the builders before save. + EmailValidator func(string) error + // DefaultDepartment holds the default value on creation for the "department" field. + DefaultDepartment string + // DepartmentValidator is a validator for the "department" field. It is called by the builders before save. + DepartmentValidator func(string) error + // DefaultRemark holds the default value on creation for the "remark" field. + DefaultRemark string + // RemarkValidator is a validator for the "remark" field. It is called by the builders before save. + RemarkValidator func(string) error + // DefaultToken holds the default value on creation for the "token" field. + DefaultToken string + // TokenValidator is a validator for the "token" field. It is called by the builders before save. + TokenValidator func(string) error + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int8 + // DefaultIsSystem holds the default value on creation for the "is_system" field. + DefaultIsSystem bool + // DefaultLastLoginIP holds the default value on creation for the "last_login_ip" field. + DefaultLastLoginIP string + // LastLoginIPValidator is a validator for the "last_login_ip" field. It is called by the builders before save. + LastLoginIPValidator func(string) error + // DefaultLastLoginTime holds the default value on creation for the "last_login_time" field. + DefaultLastLoginTime func() time.Time + // DefaultLoginTime holds the default value on creation for the "login_time" field. + DefaultLoginTime func() time.Time + // ManagerIDValidator is a validator for the "manager_id" field. It is called by the builders before save. + ManagerIDValidator func(int64) error + // DefaultManager holds the default value on creation for the "manager" field. + DefaultManager string + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int64) error +) + +// Gender defines the type for the "gender" enum field. +type Gender string + +// GenderUnknown is the default value of the Gender enum. +const DefaultGender = GenderUnknown + +// Gender values. +const ( + GenderMale Gender = "male" + GenderFemale Gender = "female" + GenderUnknown Gender = "unknown" +) + +func (ge Gender) String() string { + return string(ge) +} + +// GenderValidator is a validator for the "gender" field enum values. It is called by the builders before save. +func GenderValidator(ge Gender) error { + switch ge { + case GenderMale, GenderFemale, GenderUnknown: + return nil + default: + return fmt.Errorf("user: invalid enum value for gender field: %q", ge) + } +} + +// OrderOption defines the ordering options for the User queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateAuthor orders the results by the create_author field. +func ByCreateAuthor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateAuthor, opts...).ToFunc() +} + +// ByUpdateAuthor orders the results by the update_author field. +func ByUpdateAuthor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateAuthor, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByDeleteTime orders the results by the delete_time field. +func ByDeleteTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDeleteTime, opts...).ToFunc() +} + +// ByUUID orders the results by the uuid field. +func ByUUID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUUID, opts...).ToFunc() +} + +// ByAllowedIP orders the results by the allowed_ip field. +func ByAllowedIP(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAllowedIP, opts...).ToFunc() +} + +// ByUsername orders the results by the username field. +func ByUsername(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUsername, opts...).ToFunc() +} + +// ByNickname orders the results by the nickname field. +func ByNickname(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNickname, opts...).ToFunc() +} + +// ByAvatar orders the results by the avatar field. +func ByAvatar(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAvatar, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByGender orders the results by the gender field. +func ByGender(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGender, opts...).ToFunc() +} + +// ByEncryptedPassword orders the results by the encrypted_password field. +func ByEncryptedPassword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEncryptedPassword, opts...).ToFunc() +} + +// BySalt orders the results by the salt field. +func BySalt(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSalt, opts...).ToFunc() +} + +// ByPhone orders the results by the phone field. +func ByPhone(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPhone, opts...).ToFunc() +} + +// ByEmail orders the results by the email field. +func ByEmail(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEmail, opts...).ToFunc() +} + +// ByDepartment orders the results by the department field. +func ByDepartment(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDepartment, opts...).ToFunc() +} + +// ByRemark orders the results by the remark field. +func ByRemark(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRemark, opts...).ToFunc() +} + +// ByToken orders the results by the token field. +func ByToken(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldToken, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByIsSystem orders the results by the is_system field. +func ByIsSystem(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsSystem, opts...).ToFunc() +} + +// ByLastLoginIP orders the results by the last_login_ip field. +func ByLastLoginIP(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastLoginIP, opts...).ToFunc() +} + +// ByLastLoginTime orders the results by the last_login_time field. +func ByLastLoginTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastLoginTime, opts...).ToFunc() +} + +// ByLoginTime orders the results by the login_time field. +func ByLoginTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginTime, opts...).ToFunc() +} + +// BySanctionDate orders the results by the sanction_date field. +func BySanctionDate(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSanctionDate, opts...).ToFunc() +} + +// ByManagerID orders the results by the manager_id field. +func ByManagerID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldManagerID, opts...).ToFunc() +} + +// ByManager orders the results by the manager field. +func ByManager(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldManager, opts...).ToFunc() +} + +// ByRolesCount orders the results by roles count. +func ByRolesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...) + } +} + +// ByRoles orders the results by roles terms. +func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPositionsCount orders the results by positions count. +func ByPositionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPositionsStep(), opts...) + } +} + +// ByPositions orders the results by positions terms. +func ByPositions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPositionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByDepartmentsCount orders the results by departments count. +func ByDepartmentsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newDepartmentsStep(), opts...) + } +} + +// ByDepartments orders the results by departments terms. +func ByDepartments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newDepartmentsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByUserRolesCount orders the results by user_roles count. +func ByUserRolesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserRolesStep(), opts...) + } +} + +// ByUserRoles orders the results by user_roles terms. +func ByUserRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserRolesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByUserPositionsCount orders the results by user_positions count. +func ByUserPositionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserPositionsStep(), opts...) + } +} + +// ByUserPositions orders the results by user_positions terms. +func ByUserPositions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserPositionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByUserDepartmentsCount orders the results by user_departments count. +func ByUserDepartmentsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserDepartmentsStep(), opts...) + } +} + +// ByUserDepartments orders the results by user_departments terms. +func ByUserDepartments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserDepartmentsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newRolesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RolesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...), + ) +} +func newPositionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PositionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, PositionsTable, PositionsPrimaryKey...), + ) +} +func newDepartmentsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(DepartmentsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, DepartmentsTable, DepartmentsPrimaryKey...), + ) +} +func newUserRolesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserRolesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), + ) +} +func newUserPositionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserPositionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserPositionsTable, UserPositionsColumn), + ) +} +func newUserDepartmentsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserDepartmentsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserDepartmentsTable, UserDepartmentsColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/user/where.go b/internal/data/entity/ent/user/where.go new file mode 100644 index 00000000..4e88c5ed --- /dev/null +++ b/internal/data/entity/ent/user/where.go @@ -0,0 +1,1794 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.User { + return predicate.User(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.User { + return predicate.User(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.User { + return predicate.User(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.User { + return predicate.User(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.User { + return predicate.User(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.User { + return predicate.User(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.User { + return predicate.User(sql.FieldLTE(FieldID, id)) +} + +// CreateAuthor applies equality check predicate on the "create_author" field. It's identical to CreateAuthorEQ. +func CreateAuthor(v int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreateAuthor, v)) +} + +// UpdateAuthor applies equality check predicate on the "update_author" field. It's identical to UpdateAuthorEQ. +func UpdateAuthor(v int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdateAuthor, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdateTime, v)) +} + +// DeleteTime applies equality check predicate on the "delete_time" field. It's identical to DeleteTimeEQ. +func DeleteTime(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldDeleteTime, v)) +} + +// UUID applies equality check predicate on the "uuid" field. It's identical to UUIDEQ. +func UUID(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUUID, v)) +} + +// AllowedIP applies equality check predicate on the "allowed_ip" field. It's identical to AllowedIPEQ. +func AllowedIP(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAllowedIP, v)) +} + +// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. +func Username(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUsername, v)) +} + +// Nickname applies equality check predicate on the "nickname" field. It's identical to NicknameEQ. +func Nickname(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldNickname, v)) +} + +// Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ. +func Avatar(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAvatar, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldName, v)) +} + +// EncryptedPassword applies equality check predicate on the "encrypted_password" field. It's identical to EncryptedPasswordEQ. +func EncryptedPassword(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEncryptedPassword, v)) +} + +// Salt applies equality check predicate on the "salt" field. It's identical to SaltEQ. +func Salt(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldSalt, v)) +} + +// Phone applies equality check predicate on the "phone" field. It's identical to PhoneEQ. +func Phone(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldPhone, v)) +} + +// Email applies equality check predicate on the "email" field. It's identical to EmailEQ. +func Email(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEmail, v)) +} + +// Department applies equality check predicate on the "department" field. It's identical to DepartmentEQ. +func Department(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldDepartment, v)) +} + +// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ. +func Remark(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldRemark, v)) +} + +// Token applies equality check predicate on the "token" field. It's identical to TokenEQ. +func Token(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldToken, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int8) predicate.User { + return predicate.User(sql.FieldEQ(FieldStatus, v)) +} + +// IsSystem applies equality check predicate on the "is_system" field. It's identical to IsSystemEQ. +func IsSystem(v bool) predicate.User { + return predicate.User(sql.FieldEQ(FieldIsSystem, v)) +} + +// LastLoginIP applies equality check predicate on the "last_login_ip" field. It's identical to LastLoginIPEQ. +func LastLoginIP(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldLastLoginIP, v)) +} + +// LastLoginTime applies equality check predicate on the "last_login_time" field. It's identical to LastLoginTimeEQ. +func LastLoginTime(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldLastLoginTime, v)) +} + +// LoginTime applies equality check predicate on the "login_time" field. It's identical to LoginTimeEQ. +func LoginTime(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldLoginTime, v)) +} + +// SanctionDate applies equality check predicate on the "sanction_date" field. It's identical to SanctionDateEQ. +func SanctionDate(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldSanctionDate, v)) +} + +// ManagerID applies equality check predicate on the "manager_id" field. It's identical to ManagerIDEQ. +func ManagerID(v int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldManagerID, v)) +} + +// Manager applies equality check predicate on the "manager" field. It's identical to ManagerEQ. +func Manager(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldManager, v)) +} + +// CreateAuthorEQ applies the EQ predicate on the "create_author" field. +func CreateAuthorEQ(v int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreateAuthor, v)) +} + +// CreateAuthorNEQ applies the NEQ predicate on the "create_author" field. +func CreateAuthorNEQ(v int64) predicate.User { + return predicate.User(sql.FieldNEQ(FieldCreateAuthor, v)) +} + +// CreateAuthorIn applies the In predicate on the "create_author" field. +func CreateAuthorIn(vs ...int64) predicate.User { + return predicate.User(sql.FieldIn(FieldCreateAuthor, vs...)) +} + +// CreateAuthorNotIn applies the NotIn predicate on the "create_author" field. +func CreateAuthorNotIn(vs ...int64) predicate.User { + return predicate.User(sql.FieldNotIn(FieldCreateAuthor, vs...)) +} + +// CreateAuthorGT applies the GT predicate on the "create_author" field. +func CreateAuthorGT(v int64) predicate.User { + return predicate.User(sql.FieldGT(FieldCreateAuthor, v)) +} + +// CreateAuthorGTE applies the GTE predicate on the "create_author" field. +func CreateAuthorGTE(v int64) predicate.User { + return predicate.User(sql.FieldGTE(FieldCreateAuthor, v)) +} + +// CreateAuthorLT applies the LT predicate on the "create_author" field. +func CreateAuthorLT(v int64) predicate.User { + return predicate.User(sql.FieldLT(FieldCreateAuthor, v)) +} + +// CreateAuthorLTE applies the LTE predicate on the "create_author" field. +func CreateAuthorLTE(v int64) predicate.User { + return predicate.User(sql.FieldLTE(FieldCreateAuthor, v)) +} + +// CreateAuthorIsNil applies the IsNil predicate on the "create_author" field. +func CreateAuthorIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldCreateAuthor)) +} + +// CreateAuthorNotNil applies the NotNil predicate on the "create_author" field. +func CreateAuthorNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldCreateAuthor)) +} + +// UpdateAuthorEQ applies the EQ predicate on the "update_author" field. +func UpdateAuthorEQ(v int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdateAuthor, v)) +} + +// UpdateAuthorNEQ applies the NEQ predicate on the "update_author" field. +func UpdateAuthorNEQ(v int64) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUpdateAuthor, v)) +} + +// UpdateAuthorIn applies the In predicate on the "update_author" field. +func UpdateAuthorIn(vs ...int64) predicate.User { + return predicate.User(sql.FieldIn(FieldUpdateAuthor, vs...)) +} + +// UpdateAuthorNotIn applies the NotIn predicate on the "update_author" field. +func UpdateAuthorNotIn(vs ...int64) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUpdateAuthor, vs...)) +} + +// UpdateAuthorGT applies the GT predicate on the "update_author" field. +func UpdateAuthorGT(v int64) predicate.User { + return predicate.User(sql.FieldGT(FieldUpdateAuthor, v)) +} + +// UpdateAuthorGTE applies the GTE predicate on the "update_author" field. +func UpdateAuthorGTE(v int64) predicate.User { + return predicate.User(sql.FieldGTE(FieldUpdateAuthor, v)) +} + +// UpdateAuthorLT applies the LT predicate on the "update_author" field. +func UpdateAuthorLT(v int64) predicate.User { + return predicate.User(sql.FieldLT(FieldUpdateAuthor, v)) +} + +// UpdateAuthorLTE applies the LTE predicate on the "update_author" field. +func UpdateAuthorLTE(v int64) predicate.User { + return predicate.User(sql.FieldLTE(FieldUpdateAuthor, v)) +} + +// UpdateAuthorIsNil applies the IsNil predicate on the "update_author" field. +func UpdateAuthorIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldUpdateAuthor)) +} + +// UpdateAuthorNotNil applies the NotNil predicate on the "update_author" field. +func UpdateAuthorNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldUpdateAuthor)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldUpdateTime, v)) +} + +// DeleteTimeEQ applies the EQ predicate on the "delete_time" field. +func DeleteTimeEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldDeleteTime, v)) +} + +// DeleteTimeNEQ applies the NEQ predicate on the "delete_time" field. +func DeleteTimeNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldDeleteTime, v)) +} + +// DeleteTimeIn applies the In predicate on the "delete_time" field. +func DeleteTimeIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldDeleteTime, vs...)) +} + +// DeleteTimeNotIn applies the NotIn predicate on the "delete_time" field. +func DeleteTimeNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldDeleteTime, vs...)) +} + +// DeleteTimeGT applies the GT predicate on the "delete_time" field. +func DeleteTimeGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldDeleteTime, v)) +} + +// DeleteTimeGTE applies the GTE predicate on the "delete_time" field. +func DeleteTimeGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldDeleteTime, v)) +} + +// DeleteTimeLT applies the LT predicate on the "delete_time" field. +func DeleteTimeLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldDeleteTime, v)) +} + +// DeleteTimeLTE applies the LTE predicate on the "delete_time" field. +func DeleteTimeLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldDeleteTime, v)) +} + +// DeleteTimeIsNil applies the IsNil predicate on the "delete_time" field. +func DeleteTimeIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldDeleteTime)) +} + +// DeleteTimeNotNil applies the NotNil predicate on the "delete_time" field. +func DeleteTimeNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldDeleteTime)) +} + +// UUIDEQ applies the EQ predicate on the "uuid" field. +func UUIDEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUUID, v)) +} + +// UUIDNEQ applies the NEQ predicate on the "uuid" field. +func UUIDNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUUID, v)) +} + +// UUIDIn applies the In predicate on the "uuid" field. +func UUIDIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldUUID, vs...)) +} + +// UUIDNotIn applies the NotIn predicate on the "uuid" field. +func UUIDNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUUID, vs...)) +} + +// UUIDGT applies the GT predicate on the "uuid" field. +func UUIDGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldUUID, v)) +} + +// UUIDGTE applies the GTE predicate on the "uuid" field. +func UUIDGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldUUID, v)) +} + +// UUIDLT applies the LT predicate on the "uuid" field. +func UUIDLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldUUID, v)) +} + +// UUIDLTE applies the LTE predicate on the "uuid" field. +func UUIDLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldUUID, v)) +} + +// UUIDContains applies the Contains predicate on the "uuid" field. +func UUIDContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldUUID, v)) +} + +// UUIDHasPrefix applies the HasPrefix predicate on the "uuid" field. +func UUIDHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldUUID, v)) +} + +// UUIDHasSuffix applies the HasSuffix predicate on the "uuid" field. +func UUIDHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldUUID, v)) +} + +// UUIDEqualFold applies the EqualFold predicate on the "uuid" field. +func UUIDEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldUUID, v)) +} + +// UUIDContainsFold applies the ContainsFold predicate on the "uuid" field. +func UUIDContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldUUID, v)) +} + +// AllowedIPEQ applies the EQ predicate on the "allowed_ip" field. +func AllowedIPEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAllowedIP, v)) +} + +// AllowedIPNEQ applies the NEQ predicate on the "allowed_ip" field. +func AllowedIPNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldAllowedIP, v)) +} + +// AllowedIPIn applies the In predicate on the "allowed_ip" field. +func AllowedIPIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldAllowedIP, vs...)) +} + +// AllowedIPNotIn applies the NotIn predicate on the "allowed_ip" field. +func AllowedIPNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldAllowedIP, vs...)) +} + +// AllowedIPGT applies the GT predicate on the "allowed_ip" field. +func AllowedIPGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldAllowedIP, v)) +} + +// AllowedIPGTE applies the GTE predicate on the "allowed_ip" field. +func AllowedIPGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldAllowedIP, v)) +} + +// AllowedIPLT applies the LT predicate on the "allowed_ip" field. +func AllowedIPLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldAllowedIP, v)) +} + +// AllowedIPLTE applies the LTE predicate on the "allowed_ip" field. +func AllowedIPLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldAllowedIP, v)) +} + +// AllowedIPContains applies the Contains predicate on the "allowed_ip" field. +func AllowedIPContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldAllowedIP, v)) +} + +// AllowedIPHasPrefix applies the HasPrefix predicate on the "allowed_ip" field. +func AllowedIPHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldAllowedIP, v)) +} + +// AllowedIPHasSuffix applies the HasSuffix predicate on the "allowed_ip" field. +func AllowedIPHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldAllowedIP, v)) +} + +// AllowedIPEqualFold applies the EqualFold predicate on the "allowed_ip" field. +func AllowedIPEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldAllowedIP, v)) +} + +// AllowedIPContainsFold applies the ContainsFold predicate on the "allowed_ip" field. +func AllowedIPContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldAllowedIP, v)) +} + +// UsernameEQ applies the EQ predicate on the "username" field. +func UsernameEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUsername, v)) +} + +// UsernameNEQ applies the NEQ predicate on the "username" field. +func UsernameNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUsername, v)) +} + +// UsernameIn applies the In predicate on the "username" field. +func UsernameIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldUsername, vs...)) +} + +// UsernameNotIn applies the NotIn predicate on the "username" field. +func UsernameNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUsername, vs...)) +} + +// UsernameGT applies the GT predicate on the "username" field. +func UsernameGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldUsername, v)) +} + +// UsernameGTE applies the GTE predicate on the "username" field. +func UsernameGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldUsername, v)) +} + +// UsernameLT applies the LT predicate on the "username" field. +func UsernameLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldUsername, v)) +} + +// UsernameLTE applies the LTE predicate on the "username" field. +func UsernameLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldUsername, v)) +} + +// UsernameContains applies the Contains predicate on the "username" field. +func UsernameContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldUsername, v)) +} + +// UsernameHasPrefix applies the HasPrefix predicate on the "username" field. +func UsernameHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldUsername, v)) +} + +// UsernameHasSuffix applies the HasSuffix predicate on the "username" field. +func UsernameHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldUsername, v)) +} + +// UsernameEqualFold applies the EqualFold predicate on the "username" field. +func UsernameEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldUsername, v)) +} + +// UsernameContainsFold applies the ContainsFold predicate on the "username" field. +func UsernameContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldUsername, v)) +} + +// NicknameEQ applies the EQ predicate on the "nickname" field. +func NicknameEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldNickname, v)) +} + +// NicknameNEQ applies the NEQ predicate on the "nickname" field. +func NicknameNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldNickname, v)) +} + +// NicknameIn applies the In predicate on the "nickname" field. +func NicknameIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldNickname, vs...)) +} + +// NicknameNotIn applies the NotIn predicate on the "nickname" field. +func NicknameNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldNickname, vs...)) +} + +// NicknameGT applies the GT predicate on the "nickname" field. +func NicknameGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldNickname, v)) +} + +// NicknameGTE applies the GTE predicate on the "nickname" field. +func NicknameGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldNickname, v)) +} + +// NicknameLT applies the LT predicate on the "nickname" field. +func NicknameLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldNickname, v)) +} + +// NicknameLTE applies the LTE predicate on the "nickname" field. +func NicknameLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldNickname, v)) +} + +// NicknameContains applies the Contains predicate on the "nickname" field. +func NicknameContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldNickname, v)) +} + +// NicknameHasPrefix applies the HasPrefix predicate on the "nickname" field. +func NicknameHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldNickname, v)) +} + +// NicknameHasSuffix applies the HasSuffix predicate on the "nickname" field. +func NicknameHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldNickname, v)) +} + +// NicknameEqualFold applies the EqualFold predicate on the "nickname" field. +func NicknameEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldNickname, v)) +} + +// NicknameContainsFold applies the ContainsFold predicate on the "nickname" field. +func NicknameContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldNickname, v)) +} + +// AvatarEQ applies the EQ predicate on the "avatar" field. +func AvatarEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAvatar, v)) +} + +// AvatarNEQ applies the NEQ predicate on the "avatar" field. +func AvatarNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldAvatar, v)) +} + +// AvatarIn applies the In predicate on the "avatar" field. +func AvatarIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldAvatar, vs...)) +} + +// AvatarNotIn applies the NotIn predicate on the "avatar" field. +func AvatarNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldAvatar, vs...)) +} + +// AvatarGT applies the GT predicate on the "avatar" field. +func AvatarGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldAvatar, v)) +} + +// AvatarGTE applies the GTE predicate on the "avatar" field. +func AvatarGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldAvatar, v)) +} + +// AvatarLT applies the LT predicate on the "avatar" field. +func AvatarLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldAvatar, v)) +} + +// AvatarLTE applies the LTE predicate on the "avatar" field. +func AvatarLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldAvatar, v)) +} + +// AvatarContains applies the Contains predicate on the "avatar" field. +func AvatarContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldAvatar, v)) +} + +// AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field. +func AvatarHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldAvatar, v)) +} + +// AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field. +func AvatarHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldAvatar, v)) +} + +// AvatarEqualFold applies the EqualFold predicate on the "avatar" field. +func AvatarEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldAvatar, v)) +} + +// AvatarContainsFold applies the ContainsFold predicate on the "avatar" field. +func AvatarContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldAvatar, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldName, v)) +} + +// GenderEQ applies the EQ predicate on the "gender" field. +func GenderEQ(v Gender) predicate.User { + return predicate.User(sql.FieldEQ(FieldGender, v)) +} + +// GenderNEQ applies the NEQ predicate on the "gender" field. +func GenderNEQ(v Gender) predicate.User { + return predicate.User(sql.FieldNEQ(FieldGender, v)) +} + +// GenderIn applies the In predicate on the "gender" field. +func GenderIn(vs ...Gender) predicate.User { + return predicate.User(sql.FieldIn(FieldGender, vs...)) +} + +// GenderNotIn applies the NotIn predicate on the "gender" field. +func GenderNotIn(vs ...Gender) predicate.User { + return predicate.User(sql.FieldNotIn(FieldGender, vs...)) +} + +// EncryptedPasswordEQ applies the EQ predicate on the "encrypted_password" field. +func EncryptedPasswordEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEncryptedPassword, v)) +} + +// EncryptedPasswordNEQ applies the NEQ predicate on the "encrypted_password" field. +func EncryptedPasswordNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldEncryptedPassword, v)) +} + +// EncryptedPasswordIn applies the In predicate on the "encrypted_password" field. +func EncryptedPasswordIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldEncryptedPassword, vs...)) +} + +// EncryptedPasswordNotIn applies the NotIn predicate on the "encrypted_password" field. +func EncryptedPasswordNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldEncryptedPassword, vs...)) +} + +// EncryptedPasswordGT applies the GT predicate on the "encrypted_password" field. +func EncryptedPasswordGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldEncryptedPassword, v)) +} + +// EncryptedPasswordGTE applies the GTE predicate on the "encrypted_password" field. +func EncryptedPasswordGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldEncryptedPassword, v)) +} + +// EncryptedPasswordLT applies the LT predicate on the "encrypted_password" field. +func EncryptedPasswordLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldEncryptedPassword, v)) +} + +// EncryptedPasswordLTE applies the LTE predicate on the "encrypted_password" field. +func EncryptedPasswordLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldEncryptedPassword, v)) +} + +// EncryptedPasswordContains applies the Contains predicate on the "encrypted_password" field. +func EncryptedPasswordContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldEncryptedPassword, v)) +} + +// EncryptedPasswordHasPrefix applies the HasPrefix predicate on the "encrypted_password" field. +func EncryptedPasswordHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldEncryptedPassword, v)) +} + +// EncryptedPasswordHasSuffix applies the HasSuffix predicate on the "encrypted_password" field. +func EncryptedPasswordHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldEncryptedPassword, v)) +} + +// EncryptedPasswordEqualFold applies the EqualFold predicate on the "encrypted_password" field. +func EncryptedPasswordEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldEncryptedPassword, v)) +} + +// EncryptedPasswordContainsFold applies the ContainsFold predicate on the "encrypted_password" field. +func EncryptedPasswordContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldEncryptedPassword, v)) +} + +// SaltEQ applies the EQ predicate on the "salt" field. +func SaltEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldSalt, v)) +} + +// SaltNEQ applies the NEQ predicate on the "salt" field. +func SaltNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldSalt, v)) +} + +// SaltIn applies the In predicate on the "salt" field. +func SaltIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldSalt, vs...)) +} + +// SaltNotIn applies the NotIn predicate on the "salt" field. +func SaltNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldSalt, vs...)) +} + +// SaltGT applies the GT predicate on the "salt" field. +func SaltGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldSalt, v)) +} + +// SaltGTE applies the GTE predicate on the "salt" field. +func SaltGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldSalt, v)) +} + +// SaltLT applies the LT predicate on the "salt" field. +func SaltLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldSalt, v)) +} + +// SaltLTE applies the LTE predicate on the "salt" field. +func SaltLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldSalt, v)) +} + +// SaltContains applies the Contains predicate on the "salt" field. +func SaltContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldSalt, v)) +} + +// SaltHasPrefix applies the HasPrefix predicate on the "salt" field. +func SaltHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldSalt, v)) +} + +// SaltHasSuffix applies the HasSuffix predicate on the "salt" field. +func SaltHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldSalt, v)) +} + +// SaltEqualFold applies the EqualFold predicate on the "salt" field. +func SaltEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldSalt, v)) +} + +// SaltContainsFold applies the ContainsFold predicate on the "salt" field. +func SaltContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldSalt, v)) +} + +// PhoneEQ applies the EQ predicate on the "phone" field. +func PhoneEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldPhone, v)) +} + +// PhoneNEQ applies the NEQ predicate on the "phone" field. +func PhoneNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldPhone, v)) +} + +// PhoneIn applies the In predicate on the "phone" field. +func PhoneIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldPhone, vs...)) +} + +// PhoneNotIn applies the NotIn predicate on the "phone" field. +func PhoneNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldPhone, vs...)) +} + +// PhoneGT applies the GT predicate on the "phone" field. +func PhoneGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldPhone, v)) +} + +// PhoneGTE applies the GTE predicate on the "phone" field. +func PhoneGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldPhone, v)) +} + +// PhoneLT applies the LT predicate on the "phone" field. +func PhoneLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldPhone, v)) +} + +// PhoneLTE applies the LTE predicate on the "phone" field. +func PhoneLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldPhone, v)) +} + +// PhoneContains applies the Contains predicate on the "phone" field. +func PhoneContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldPhone, v)) +} + +// PhoneHasPrefix applies the HasPrefix predicate on the "phone" field. +func PhoneHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldPhone, v)) +} + +// PhoneHasSuffix applies the HasSuffix predicate on the "phone" field. +func PhoneHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldPhone, v)) +} + +// PhoneEqualFold applies the EqualFold predicate on the "phone" field. +func PhoneEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldPhone, v)) +} + +// PhoneContainsFold applies the ContainsFold predicate on the "phone" field. +func PhoneContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldPhone, v)) +} + +// EmailEQ applies the EQ predicate on the "email" field. +func EmailEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEmail, v)) +} + +// EmailNEQ applies the NEQ predicate on the "email" field. +func EmailNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldEmail, v)) +} + +// EmailIn applies the In predicate on the "email" field. +func EmailIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldEmail, vs...)) +} + +// EmailNotIn applies the NotIn predicate on the "email" field. +func EmailNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldEmail, vs...)) +} + +// EmailGT applies the GT predicate on the "email" field. +func EmailGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldEmail, v)) +} + +// EmailGTE applies the GTE predicate on the "email" field. +func EmailGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldEmail, v)) +} + +// EmailLT applies the LT predicate on the "email" field. +func EmailLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldEmail, v)) +} + +// EmailLTE applies the LTE predicate on the "email" field. +func EmailLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldEmail, v)) +} + +// EmailContains applies the Contains predicate on the "email" field. +func EmailContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldEmail, v)) +} + +// EmailHasPrefix applies the HasPrefix predicate on the "email" field. +func EmailHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldEmail, v)) +} + +// EmailHasSuffix applies the HasSuffix predicate on the "email" field. +func EmailHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldEmail, v)) +} + +// EmailEqualFold applies the EqualFold predicate on the "email" field. +func EmailEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldEmail, v)) +} + +// EmailContainsFold applies the ContainsFold predicate on the "email" field. +func EmailContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldEmail, v)) +} + +// DepartmentEQ applies the EQ predicate on the "department" field. +func DepartmentEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldDepartment, v)) +} + +// DepartmentNEQ applies the NEQ predicate on the "department" field. +func DepartmentNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldDepartment, v)) +} + +// DepartmentIn applies the In predicate on the "department" field. +func DepartmentIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldDepartment, vs...)) +} + +// DepartmentNotIn applies the NotIn predicate on the "department" field. +func DepartmentNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldDepartment, vs...)) +} + +// DepartmentGT applies the GT predicate on the "department" field. +func DepartmentGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldDepartment, v)) +} + +// DepartmentGTE applies the GTE predicate on the "department" field. +func DepartmentGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldDepartment, v)) +} + +// DepartmentLT applies the LT predicate on the "department" field. +func DepartmentLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldDepartment, v)) +} + +// DepartmentLTE applies the LTE predicate on the "department" field. +func DepartmentLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldDepartment, v)) +} + +// DepartmentContains applies the Contains predicate on the "department" field. +func DepartmentContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldDepartment, v)) +} + +// DepartmentHasPrefix applies the HasPrefix predicate on the "department" field. +func DepartmentHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldDepartment, v)) +} + +// DepartmentHasSuffix applies the HasSuffix predicate on the "department" field. +func DepartmentHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldDepartment, v)) +} + +// DepartmentEqualFold applies the EqualFold predicate on the "department" field. +func DepartmentEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldDepartment, v)) +} + +// DepartmentContainsFold applies the ContainsFold predicate on the "department" field. +func DepartmentContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldDepartment, v)) +} + +// RemarkEQ applies the EQ predicate on the "remark" field. +func RemarkEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldRemark, v)) +} + +// RemarkNEQ applies the NEQ predicate on the "remark" field. +func RemarkNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldRemark, v)) +} + +// RemarkIn applies the In predicate on the "remark" field. +func RemarkIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldRemark, vs...)) +} + +// RemarkNotIn applies the NotIn predicate on the "remark" field. +func RemarkNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldRemark, vs...)) +} + +// RemarkGT applies the GT predicate on the "remark" field. +func RemarkGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldRemark, v)) +} + +// RemarkGTE applies the GTE predicate on the "remark" field. +func RemarkGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldRemark, v)) +} + +// RemarkLT applies the LT predicate on the "remark" field. +func RemarkLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldRemark, v)) +} + +// RemarkLTE applies the LTE predicate on the "remark" field. +func RemarkLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldRemark, v)) +} + +// RemarkContains applies the Contains predicate on the "remark" field. +func RemarkContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldRemark, v)) +} + +// RemarkHasPrefix applies the HasPrefix predicate on the "remark" field. +func RemarkHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldRemark, v)) +} + +// RemarkHasSuffix applies the HasSuffix predicate on the "remark" field. +func RemarkHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldRemark, v)) +} + +// RemarkEqualFold applies the EqualFold predicate on the "remark" field. +func RemarkEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldRemark, v)) +} + +// RemarkContainsFold applies the ContainsFold predicate on the "remark" field. +func RemarkContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldRemark, v)) +} + +// TokenEQ applies the EQ predicate on the "token" field. +func TokenEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldToken, v)) +} + +// TokenNEQ applies the NEQ predicate on the "token" field. +func TokenNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldToken, v)) +} + +// TokenIn applies the In predicate on the "token" field. +func TokenIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldToken, vs...)) +} + +// TokenNotIn applies the NotIn predicate on the "token" field. +func TokenNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldToken, vs...)) +} + +// TokenGT applies the GT predicate on the "token" field. +func TokenGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldToken, v)) +} + +// TokenGTE applies the GTE predicate on the "token" field. +func TokenGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldToken, v)) +} + +// TokenLT applies the LT predicate on the "token" field. +func TokenLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldToken, v)) +} + +// TokenLTE applies the LTE predicate on the "token" field. +func TokenLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldToken, v)) +} + +// TokenContains applies the Contains predicate on the "token" field. +func TokenContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldToken, v)) +} + +// TokenHasPrefix applies the HasPrefix predicate on the "token" field. +func TokenHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldToken, v)) +} + +// TokenHasSuffix applies the HasSuffix predicate on the "token" field. +func TokenHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldToken, v)) +} + +// TokenEqualFold applies the EqualFold predicate on the "token" field. +func TokenEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldToken, v)) +} + +// TokenContainsFold applies the ContainsFold predicate on the "token" field. +func TokenContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldToken, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int8) predicate.User { + return predicate.User(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int8) predicate.User { + return predicate.User(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int8) predicate.User { + return predicate.User(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int8) predicate.User { + return predicate.User(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int8) predicate.User { + return predicate.User(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int8) predicate.User { + return predicate.User(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int8) predicate.User { + return predicate.User(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int8) predicate.User { + return predicate.User(sql.FieldLTE(FieldStatus, v)) +} + +// IsSystemEQ applies the EQ predicate on the "is_system" field. +func IsSystemEQ(v bool) predicate.User { + return predicate.User(sql.FieldEQ(FieldIsSystem, v)) +} + +// IsSystemNEQ applies the NEQ predicate on the "is_system" field. +func IsSystemNEQ(v bool) predicate.User { + return predicate.User(sql.FieldNEQ(FieldIsSystem, v)) +} + +// LastLoginIPEQ applies the EQ predicate on the "last_login_ip" field. +func LastLoginIPEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldLastLoginIP, v)) +} + +// LastLoginIPNEQ applies the NEQ predicate on the "last_login_ip" field. +func LastLoginIPNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldLastLoginIP, v)) +} + +// LastLoginIPIn applies the In predicate on the "last_login_ip" field. +func LastLoginIPIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldLastLoginIP, vs...)) +} + +// LastLoginIPNotIn applies the NotIn predicate on the "last_login_ip" field. +func LastLoginIPNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldLastLoginIP, vs...)) +} + +// LastLoginIPGT applies the GT predicate on the "last_login_ip" field. +func LastLoginIPGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldLastLoginIP, v)) +} + +// LastLoginIPGTE applies the GTE predicate on the "last_login_ip" field. +func LastLoginIPGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldLastLoginIP, v)) +} + +// LastLoginIPLT applies the LT predicate on the "last_login_ip" field. +func LastLoginIPLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldLastLoginIP, v)) +} + +// LastLoginIPLTE applies the LTE predicate on the "last_login_ip" field. +func LastLoginIPLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldLastLoginIP, v)) +} + +// LastLoginIPContains applies the Contains predicate on the "last_login_ip" field. +func LastLoginIPContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldLastLoginIP, v)) +} + +// LastLoginIPHasPrefix applies the HasPrefix predicate on the "last_login_ip" field. +func LastLoginIPHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldLastLoginIP, v)) +} + +// LastLoginIPHasSuffix applies the HasSuffix predicate on the "last_login_ip" field. +func LastLoginIPHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldLastLoginIP, v)) +} + +// LastLoginIPEqualFold applies the EqualFold predicate on the "last_login_ip" field. +func LastLoginIPEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldLastLoginIP, v)) +} + +// LastLoginIPContainsFold applies the ContainsFold predicate on the "last_login_ip" field. +func LastLoginIPContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldLastLoginIP, v)) +} + +// LastLoginTimeEQ applies the EQ predicate on the "last_login_time" field. +func LastLoginTimeEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldLastLoginTime, v)) +} + +// LastLoginTimeNEQ applies the NEQ predicate on the "last_login_time" field. +func LastLoginTimeNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldLastLoginTime, v)) +} + +// LastLoginTimeIn applies the In predicate on the "last_login_time" field. +func LastLoginTimeIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldLastLoginTime, vs...)) +} + +// LastLoginTimeNotIn applies the NotIn predicate on the "last_login_time" field. +func LastLoginTimeNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldLastLoginTime, vs...)) +} + +// LastLoginTimeGT applies the GT predicate on the "last_login_time" field. +func LastLoginTimeGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldLastLoginTime, v)) +} + +// LastLoginTimeGTE applies the GTE predicate on the "last_login_time" field. +func LastLoginTimeGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldLastLoginTime, v)) +} + +// LastLoginTimeLT applies the LT predicate on the "last_login_time" field. +func LastLoginTimeLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldLastLoginTime, v)) +} + +// LastLoginTimeLTE applies the LTE predicate on the "last_login_time" field. +func LastLoginTimeLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldLastLoginTime, v)) +} + +// LoginTimeEQ applies the EQ predicate on the "login_time" field. +func LoginTimeEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldLoginTime, v)) +} + +// LoginTimeNEQ applies the NEQ predicate on the "login_time" field. +func LoginTimeNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldLoginTime, v)) +} + +// LoginTimeIn applies the In predicate on the "login_time" field. +func LoginTimeIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldLoginTime, vs...)) +} + +// LoginTimeNotIn applies the NotIn predicate on the "login_time" field. +func LoginTimeNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldLoginTime, vs...)) +} + +// LoginTimeGT applies the GT predicate on the "login_time" field. +func LoginTimeGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldLoginTime, v)) +} + +// LoginTimeGTE applies the GTE predicate on the "login_time" field. +func LoginTimeGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldLoginTime, v)) +} + +// LoginTimeLT applies the LT predicate on the "login_time" field. +func LoginTimeLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldLoginTime, v)) +} + +// LoginTimeLTE applies the LTE predicate on the "login_time" field. +func LoginTimeLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldLoginTime, v)) +} + +// SanctionDateEQ applies the EQ predicate on the "sanction_date" field. +func SanctionDateEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldSanctionDate, v)) +} + +// SanctionDateNEQ applies the NEQ predicate on the "sanction_date" field. +func SanctionDateNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldSanctionDate, v)) +} + +// SanctionDateIn applies the In predicate on the "sanction_date" field. +func SanctionDateIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldSanctionDate, vs...)) +} + +// SanctionDateNotIn applies the NotIn predicate on the "sanction_date" field. +func SanctionDateNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldSanctionDate, vs...)) +} + +// SanctionDateGT applies the GT predicate on the "sanction_date" field. +func SanctionDateGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldSanctionDate, v)) +} + +// SanctionDateGTE applies the GTE predicate on the "sanction_date" field. +func SanctionDateGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldSanctionDate, v)) +} + +// SanctionDateLT applies the LT predicate on the "sanction_date" field. +func SanctionDateLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldSanctionDate, v)) +} + +// SanctionDateLTE applies the LTE predicate on the "sanction_date" field. +func SanctionDateLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldSanctionDate, v)) +} + +// SanctionDateIsNil applies the IsNil predicate on the "sanction_date" field. +func SanctionDateIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldSanctionDate)) +} + +// SanctionDateNotNil applies the NotNil predicate on the "sanction_date" field. +func SanctionDateNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldSanctionDate)) +} + +// ManagerIDEQ applies the EQ predicate on the "manager_id" field. +func ManagerIDEQ(v int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldManagerID, v)) +} + +// ManagerIDNEQ applies the NEQ predicate on the "manager_id" field. +func ManagerIDNEQ(v int64) predicate.User { + return predicate.User(sql.FieldNEQ(FieldManagerID, v)) +} + +// ManagerIDIn applies the In predicate on the "manager_id" field. +func ManagerIDIn(vs ...int64) predicate.User { + return predicate.User(sql.FieldIn(FieldManagerID, vs...)) +} + +// ManagerIDNotIn applies the NotIn predicate on the "manager_id" field. +func ManagerIDNotIn(vs ...int64) predicate.User { + return predicate.User(sql.FieldNotIn(FieldManagerID, vs...)) +} + +// ManagerIDGT applies the GT predicate on the "manager_id" field. +func ManagerIDGT(v int64) predicate.User { + return predicate.User(sql.FieldGT(FieldManagerID, v)) +} + +// ManagerIDGTE applies the GTE predicate on the "manager_id" field. +func ManagerIDGTE(v int64) predicate.User { + return predicate.User(sql.FieldGTE(FieldManagerID, v)) +} + +// ManagerIDLT applies the LT predicate on the "manager_id" field. +func ManagerIDLT(v int64) predicate.User { + return predicate.User(sql.FieldLT(FieldManagerID, v)) +} + +// ManagerIDLTE applies the LTE predicate on the "manager_id" field. +func ManagerIDLTE(v int64) predicate.User { + return predicate.User(sql.FieldLTE(FieldManagerID, v)) +} + +// ManagerIDIsNil applies the IsNil predicate on the "manager_id" field. +func ManagerIDIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldManagerID)) +} + +// ManagerIDNotNil applies the NotNil predicate on the "manager_id" field. +func ManagerIDNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldManagerID)) +} + +// ManagerEQ applies the EQ predicate on the "manager" field. +func ManagerEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldManager, v)) +} + +// ManagerNEQ applies the NEQ predicate on the "manager" field. +func ManagerNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldManager, v)) +} + +// ManagerIn applies the In predicate on the "manager" field. +func ManagerIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldManager, vs...)) +} + +// ManagerNotIn applies the NotIn predicate on the "manager" field. +func ManagerNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldManager, vs...)) +} + +// ManagerGT applies the GT predicate on the "manager" field. +func ManagerGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldManager, v)) +} + +// ManagerGTE applies the GTE predicate on the "manager" field. +func ManagerGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldManager, v)) +} + +// ManagerLT applies the LT predicate on the "manager" field. +func ManagerLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldManager, v)) +} + +// ManagerLTE applies the LTE predicate on the "manager" field. +func ManagerLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldManager, v)) +} + +// ManagerContains applies the Contains predicate on the "manager" field. +func ManagerContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldManager, v)) +} + +// ManagerHasPrefix applies the HasPrefix predicate on the "manager" field. +func ManagerHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldManager, v)) +} + +// ManagerHasSuffix applies the HasSuffix predicate on the "manager" field. +func ManagerHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldManager, v)) +} + +// ManagerEqualFold applies the EqualFold predicate on the "manager" field. +func ManagerEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldManager, v)) +} + +// ManagerContainsFold applies the ContainsFold predicate on the "manager" field. +func ManagerContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldManager, v)) +} + +// HasRoles applies the HasEdge predicate on the "roles" edge. +func HasRoles() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRolesWith applies the HasEdge predicate on the "roles" edge with a given conditions (other predicates). +func HasRolesWith(preds ...predicate.Role) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newRolesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPositions applies the HasEdge predicate on the "positions" edge. +func HasPositions() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, PositionsTable, PositionsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPositionsWith applies the HasEdge predicate on the "positions" edge with a given conditions (other predicates). +func HasPositionsWith(preds ...predicate.Position) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newPositionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasDepartments applies the HasEdge predicate on the "departments" edge. +func HasDepartments() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, DepartmentsTable, DepartmentsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasDepartmentsWith applies the HasEdge predicate on the "departments" edge with a given conditions (other predicates). +func HasDepartmentsWith(preds ...predicate.Department) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newDepartmentsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasUserRoles applies the HasEdge predicate on the "user_roles" edge. +func HasUserRoles() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserRolesWith applies the HasEdge predicate on the "user_roles" edge with a given conditions (other predicates). +func HasUserRolesWith(preds ...predicate.UserRole) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newUserRolesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasUserPositions applies the HasEdge predicate on the "user_positions" edge. +func HasUserPositions() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserPositionsTable, UserPositionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserPositionsWith applies the HasEdge predicate on the "user_positions" edge with a given conditions (other predicates). +func HasUserPositionsWith(preds ...predicate.UserPosition) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newUserPositionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasUserDepartments applies the HasEdge predicate on the "user_departments" edge. +func HasUserDepartments() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserDepartmentsTable, UserDepartmentsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserDepartmentsWith applies the HasEdge predicate on the "user_departments" edge with a given conditions (other predicates). +func HasUserDepartmentsWith(preds ...predicate.UserDepartment) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newUserDepartmentsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.User) predicate.User { + return predicate.User(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.User) predicate.User { + return predicate.User(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.User) predicate.User { + return predicate.User(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/userdepartment/userdepartment.go b/internal/data/entity/ent/userdepartment/userdepartment.go new file mode 100644 index 00000000..92e3ac17 --- /dev/null +++ b/internal/data/entity/ent/userdepartment/userdepartment.go @@ -0,0 +1,171 @@ +// Code generated by ent, DO NOT EDIT. + +package userdepartment + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the userdepartment type in the database. + Label = "user_department" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldDepartmentID holds the string denoting the department_id field in the database. + FieldDepartmentID = "department_id" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // EdgeDepartment holds the string denoting the department edge name in mutations. + EdgeDepartment = "department" + // Table holds the table name of the userdepartment in the database. + Table = "sys_user_departments" + // UserTable is the table that holds the user relation/edge. + UserTable = "sys_user_departments" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "sys_users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_id" + // DepartmentTable is the table that holds the department relation/edge. + DepartmentTable = "sys_user_departments" + // DepartmentInverseTable is the table name for the Department entity. + // It exists in this package in order to avoid circular dependency with the "department" package. + DepartmentInverseTable = "sys_departments" + // DepartmentColumn is the table column denoting the department relation/edge. + DepartmentColumn = "department_id" +) + +// Columns holds all SQL columns for userdepartment fields. +var Columns = []string{ + FieldID, + FieldUserID, + FieldDepartmentID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + UserIDValidator func(int64) error + // DepartmentIDValidator is a validator for the "department_id" field. It is called by the builders before save. + DepartmentIDValidator func(int64) error +) + +// OrderOption defines the ordering options for the UserDepartment queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByDepartmentID orders the results by the department_id field. +func ByDepartmentID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDepartmentID, opts...).ToFunc() +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) + } +} + +// ByDepartmentField orders the results by department field. +func ByDepartmentField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newDepartmentStep(), sql.OrderByField(field, opts...)) + } +} +func newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) +} +func newDepartmentStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(DepartmentInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, DepartmentTable, DepartmentColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/userdepartment/where.go b/internal/data/entity/ent/userdepartment/where.go new file mode 100644 index 00000000..f721e07e --- /dev/null +++ b/internal/data/entity/ent/userdepartment/where.go @@ -0,0 +1,166 @@ +// Code generated by ent, DO NOT EDIT. + +package userdepartment + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldLTE(FieldID, id)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v int64) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldEQ(FieldUserID, v)) +} + +// DepartmentID applies equality check predicate on the "department_id" field. It's identical to DepartmentIDEQ. +func DepartmentID(v int64) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldEQ(FieldDepartmentID, v)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v int64) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v int64) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...int64) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...int64) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldNotIn(FieldUserID, vs...)) +} + +// DepartmentIDEQ applies the EQ predicate on the "department_id" field. +func DepartmentIDEQ(v int64) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldEQ(FieldDepartmentID, v)) +} + +// DepartmentIDNEQ applies the NEQ predicate on the "department_id" field. +func DepartmentIDNEQ(v int64) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldNEQ(FieldDepartmentID, v)) +} + +// DepartmentIDIn applies the In predicate on the "department_id" field. +func DepartmentIDIn(vs ...int64) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldIn(FieldDepartmentID, vs...)) +} + +// DepartmentIDNotIn applies the NotIn predicate on the "department_id" field. +func DepartmentIDNotIn(vs ...int64) predicate.UserDepartment { + return predicate.UserDepartment(sql.FieldNotIn(FieldDepartmentID, vs...)) +} + +// HasUser applies the HasEdge predicate on the "user" edge. +func HasUser() predicate.UserDepartment { + return predicate.UserDepartment(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.UserDepartment { + return predicate.UserDepartment(func(s *sql.Selector) { + step := newUserStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasDepartment applies the HasEdge predicate on the "department" edge. +func HasDepartment() predicate.UserDepartment { + return predicate.UserDepartment(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, DepartmentTable, DepartmentColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasDepartmentWith applies the HasEdge predicate on the "department" edge with a given conditions (other predicates). +func HasDepartmentWith(preds ...predicate.Department) predicate.UserDepartment { + return predicate.UserDepartment(func(s *sql.Selector) { + step := newDepartmentStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.UserDepartment) predicate.UserDepartment { + return predicate.UserDepartment(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserDepartment) predicate.UserDepartment { + return predicate.UserDepartment(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserDepartment) predicate.UserDepartment { + return predicate.UserDepartment(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/userposition/userposition.go b/internal/data/entity/ent/userposition/userposition.go new file mode 100644 index 00000000..6ec7d185 --- /dev/null +++ b/internal/data/entity/ent/userposition/userposition.go @@ -0,0 +1,171 @@ +// Code generated by ent, DO NOT EDIT. + +package userposition + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the userposition type in the database. + Label = "user_position" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldPositionID holds the string denoting the position_id field in the database. + FieldPositionID = "position_id" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // EdgePosition holds the string denoting the position edge name in mutations. + EdgePosition = "position" + // Table holds the table name of the userposition in the database. + Table = "sys_user_positions" + // UserTable is the table that holds the user relation/edge. + UserTable = "sys_user_positions" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "sys_users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_id" + // PositionTable is the table that holds the position relation/edge. + PositionTable = "sys_user_positions" + // PositionInverseTable is the table name for the Position entity. + // It exists in this package in order to avoid circular dependency with the "position" package. + PositionInverseTable = "sys_positions" + // PositionColumn is the table column denoting the position relation/edge. + PositionColumn = "position_id" +) + +// Columns holds all SQL columns for userposition fields. +var Columns = []string{ + FieldID, + FieldUserID, + FieldPositionID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + UserIDValidator func(int64) error + // PositionIDValidator is a validator for the "position_id" field. It is called by the builders before save. + PositionIDValidator func(int64) error +) + +// OrderOption defines the ordering options for the UserPosition queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByPositionID orders the results by the position_id field. +func ByPositionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPositionID, opts...).ToFunc() +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) + } +} + +// ByPositionField orders the results by position field. +func ByPositionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPositionStep(), sql.OrderByField(field, opts...)) + } +} +func newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) +} +func newPositionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PositionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PositionTable, PositionColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/userposition/where.go b/internal/data/entity/ent/userposition/where.go new file mode 100644 index 00000000..e5aab88c --- /dev/null +++ b/internal/data/entity/ent/userposition/where.go @@ -0,0 +1,166 @@ +// Code generated by ent, DO NOT EDIT. + +package userposition + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.UserPosition { + return predicate.UserPosition(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.UserPosition { + return predicate.UserPosition(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.UserPosition { + return predicate.UserPosition(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.UserPosition { + return predicate.UserPosition(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.UserPosition { + return predicate.UserPosition(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.UserPosition { + return predicate.UserPosition(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.UserPosition { + return predicate.UserPosition(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.UserPosition { + return predicate.UserPosition(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.UserPosition { + return predicate.UserPosition(sql.FieldLTE(FieldID, id)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v int64) predicate.UserPosition { + return predicate.UserPosition(sql.FieldEQ(FieldUserID, v)) +} + +// PositionID applies equality check predicate on the "position_id" field. It's identical to PositionIDEQ. +func PositionID(v int64) predicate.UserPosition { + return predicate.UserPosition(sql.FieldEQ(FieldPositionID, v)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v int64) predicate.UserPosition { + return predicate.UserPosition(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v int64) predicate.UserPosition { + return predicate.UserPosition(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...int64) predicate.UserPosition { + return predicate.UserPosition(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...int64) predicate.UserPosition { + return predicate.UserPosition(sql.FieldNotIn(FieldUserID, vs...)) +} + +// PositionIDEQ applies the EQ predicate on the "position_id" field. +func PositionIDEQ(v int64) predicate.UserPosition { + return predicate.UserPosition(sql.FieldEQ(FieldPositionID, v)) +} + +// PositionIDNEQ applies the NEQ predicate on the "position_id" field. +func PositionIDNEQ(v int64) predicate.UserPosition { + return predicate.UserPosition(sql.FieldNEQ(FieldPositionID, v)) +} + +// PositionIDIn applies the In predicate on the "position_id" field. +func PositionIDIn(vs ...int64) predicate.UserPosition { + return predicate.UserPosition(sql.FieldIn(FieldPositionID, vs...)) +} + +// PositionIDNotIn applies the NotIn predicate on the "position_id" field. +func PositionIDNotIn(vs ...int64) predicate.UserPosition { + return predicate.UserPosition(sql.FieldNotIn(FieldPositionID, vs...)) +} + +// HasUser applies the HasEdge predicate on the "user" edge. +func HasUser() predicate.UserPosition { + return predicate.UserPosition(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.UserPosition { + return predicate.UserPosition(func(s *sql.Selector) { + step := newUserStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPosition applies the HasEdge predicate on the "position" edge. +func HasPosition() predicate.UserPosition { + return predicate.UserPosition(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PositionTable, PositionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPositionWith applies the HasEdge predicate on the "position" edge with a given conditions (other predicates). +func HasPositionWith(preds ...predicate.Position) predicate.UserPosition { + return predicate.UserPosition(func(s *sql.Selector) { + step := newPositionStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.UserPosition) predicate.UserPosition { + return predicate.UserPosition(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserPosition) predicate.UserPosition { + return predicate.UserPosition(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserPosition) predicate.UserPosition { + return predicate.UserPosition(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/userrole/userrole.go b/internal/data/entity/ent/userrole/userrole.go new file mode 100644 index 00000000..b3956f7f --- /dev/null +++ b/internal/data/entity/ent/userrole/userrole.go @@ -0,0 +1,171 @@ +// Code generated by ent, DO NOT EDIT. + +package userrole + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the userrole type in the database. + Label = "user_role" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldRoleID holds the string denoting the role_id field in the database. + FieldRoleID = "role_id" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // EdgeRole holds the string denoting the role edge name in mutations. + EdgeRole = "role" + // Table holds the table name of the userrole in the database. + Table = "sys_user_roles" + // UserTable is the table that holds the user relation/edge. + UserTable = "sys_user_roles" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "sys_users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_id" + // RoleTable is the table that holds the role relation/edge. + RoleTable = "sys_user_roles" + // RoleInverseTable is the table name for the Role entity. + // It exists in this package in order to avoid circular dependency with the "role" package. + RoleInverseTable = "sys_roles" + // RoleColumn is the table column denoting the role relation/edge. + RoleColumn = "role_id" +) + +// Columns holds all SQL columns for userrole fields. +var Columns = []string{ + FieldID, + FieldUserID, + FieldRoleID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // UserIDValidator is a validator for the "user_id" field. It is called by the builders before save. + UserIDValidator func(int64) error + // RoleIDValidator is a validator for the "role_id" field. It is called by the builders before save. + RoleIDValidator func(int64) error +) + +// OrderOption defines the ordering options for the UserRole queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByRoleID orders the results by the role_id field. +func ByRoleID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRoleID, opts...).ToFunc() +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) + } +} + +// ByRoleField orders the results by role field. +func ByRoleField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRoleStep(), sql.OrderByField(field, opts...)) + } +} +func newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) +} +func newRoleStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RoleInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/userrole/where.go b/internal/data/entity/ent/userrole/where.go new file mode 100644 index 00000000..98d6f46c --- /dev/null +++ b/internal/data/entity/ent/userrole/where.go @@ -0,0 +1,166 @@ +// Code generated by ent, DO NOT EDIT. + +package userrole + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.UserRole { + return predicate.UserRole(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.UserRole { + return predicate.UserRole(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldLTE(FieldID, id)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldUserID, v)) +} + +// RoleID applies equality check predicate on the "role_id" field. It's identical to RoleIDEQ. +func RoleID(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldRoleID, v)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...int64) predicate.UserRole { + return predicate.UserRole(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...int64) predicate.UserRole { + return predicate.UserRole(sql.FieldNotIn(FieldUserID, vs...)) +} + +// RoleIDEQ applies the EQ predicate on the "role_id" field. +func RoleIDEQ(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldRoleID, v)) +} + +// RoleIDNEQ applies the NEQ predicate on the "role_id" field. +func RoleIDNEQ(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldNEQ(FieldRoleID, v)) +} + +// RoleIDIn applies the In predicate on the "role_id" field. +func RoleIDIn(vs ...int64) predicate.UserRole { + return predicate.UserRole(sql.FieldIn(FieldRoleID, vs...)) +} + +// RoleIDNotIn applies the NotIn predicate on the "role_id" field. +func RoleIDNotIn(vs ...int64) predicate.UserRole { + return predicate.UserRole(sql.FieldNotIn(FieldRoleID, vs...)) +} + +// HasUser applies the HasEdge predicate on the "user" edge. +func HasUser() predicate.UserRole { + return predicate.UserRole(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.UserRole { + return predicate.UserRole(func(s *sql.Selector) { + step := newUserStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasRole applies the HasEdge predicate on the "role" edge. +func HasRole() predicate.UserRole { + return predicate.UserRole(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRoleWith applies the HasEdge predicate on the "role" edge with a given conditions (other predicates). +func HasRoleWith(preds ...predicate.Role) predicate.UserRole { + return predicate.UserRole(func(s *sql.Selector) { + step := newRoleStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.UserRole) predicate.UserRole { + return predicate.UserRole(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserRole) predicate.UserRole { + return predicate.UserRole(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserRole) predicate.UserRole { + return predicate.UserRole(sql.NotPredicates(p)) +} diff --git a/internal/mods/gateway/proxy.go b/internal/mods/gateway/proxy.go index 1fd2893b..4880505a 100644 --- a/internal/mods/gateway/proxy.go +++ b/internal/mods/gateway/proxy.go @@ -44,10 +44,11 @@ var ( type ProxyOptions struct { Authenticator security.Authenticator Authorizer security.Authorizer + Registrars []service.ServerRegistrar } func NewProxyOptions(r runtime.Runtime, bootstrap *configs.Bootstrap, - source casbin.RuleSource) (*ProxyOptions, error) { + source casbin.RuleSource, registrars []service.ServerRegistrar) (*ProxyOptions, error) { authenticator, err := securityx.NewAuthenticator(bootstrap) if err != nil { return nil, err @@ -63,6 +64,7 @@ func NewProxyOptions(r runtime.Runtime, bootstrap *configs.Bootstrap, return &ProxyOptions{ Authenticator: authenticator, Authorizer: authorizer, + Registrars: registrars, }, nil } @@ -70,7 +72,6 @@ func NewProxyOptions(r runtime.Runtime, bootstrap *configs.Bootstrap, func NewProxyServer( r runtime.Runtime, bootstrap *configs.Bootstrap, - registrars []service.ServerRegistrar, opts *ProxyOptions) []transport.Server { paths := bootstrap.GetSecurity().GetSecurity().GetPublicPaths() paths = append(DefaultPaths(), paths...) @@ -95,12 +96,6 @@ func NewProxyServer( return true }) ms = append(ms, serv.Build(), CallLoggerMiddleware()) - //clients.Get - //for i := range clients { - // clients[i].GetCore().GetName() - // - //} - //clients.Name = types.ZeroOr(clients.Name, "ORIGADMIN_SERVICE") var servers []transport.Server services := bootstrap.GetEntry().GetServices() for i := range services { @@ -118,7 +113,7 @@ func NewProxyServer( if err != nil { panic(err) } - for _, registrar := range registrars { + for _, registrar := range opts.Registrars { registrar.Register(r.Context(), srv) } srv.WalkRoute(func(info http.RouteInfo) error { From 4b089f45a379e0de47c4054d45d0494f9ee217bb Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 23 Jun 2025 16:34:04 +0800 Subject: [PATCH 049/158] feat(database): add notification service and update related components - Add notification service to the API - Create notification schema and migration - Implement notification client and database methods - Update hooks, interceptors, and query contexts to support notifications - Refactor client initialization to include notification service --- api/v1/proto/message/message.proto | 150 +++ api/v1/proto/types/message.proto | 19 + internal/data/entity/ent/client.go | 172 +++- internal/data/entity/ent/database.go | 5 + internal/data/entity/ent/ent.go | 2 + internal/data/entity/ent/generate.go | 2 +- internal/data/entity/ent/hook/hook.go | 12 + .../data/entity/ent/intercept/intercept.go | 30 + internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 61 +- internal/data/entity/ent/mutation.go | 890 ++++++++++++++++++ internal/data/entity/ent/mutation_fields.go | 88 ++ internal/data/entity/ent/notification.go | 184 ++++ .../entity/ent/notification/notification.go | 192 ++++ .../data/entity/ent/notification/where.go | 500 ++++++++++ .../data/entity/ent/notification_create.go | 413 ++++++++ .../data/entity/ent/notification_delete.go | 88 ++ .../data/entity/ent/notification_query.go | 621 ++++++++++++ .../data/entity/ent/notification_update.go | 630 +++++++++++++ .../data/entity/ent/predicate/predicate.go | 3 + internal/data/entity/ent/role.go | 12 +- internal/data/entity/ent/runtime/runtime.go | 55 +- .../data/entity/ent/schema/notification.go | 52 + internal/data/entity/ent/schema/role.go | 12 +- .../data/entity/ent/schema/types/constants.go | 1 + internal/data/entity/ent/schema/user.go | 4 +- internal/data/entity/ent/tx.go | 3 + internal/data/entity/ent/user.go | 4 +- 28 files changed, 4161 insertions(+), 46 deletions(-) create mode 100644 api/v1/proto/message/message.proto create mode 100644 api/v1/proto/types/message.proto create mode 100644 internal/data/entity/ent/notification.go create mode 100644 internal/data/entity/ent/notification/notification.go create mode 100644 internal/data/entity/ent/notification/where.go create mode 100644 internal/data/entity/ent/notification_create.go create mode 100644 internal/data/entity/ent/notification_delete.go create mode 100644 internal/data/entity/ent/notification_query.go create mode 100644 internal/data/entity/ent/notification_update.go create mode 100644 internal/data/entity/ent/schema/notification.go diff --git a/api/v1/proto/message/message.proto b/api/v1/proto/message/message.proto new file mode 100644 index 00000000..bb39cc8b --- /dev/null +++ b/api/v1/proto/message/message.proto @@ -0,0 +1,150 @@ +syntax = "proto3"; + +package api.v1.services.message; + +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "types/system.proto"; +import "validate/validate.proto"; + +option go_package = "api/v1/services/message;message"; +option java_multiple_files = true; +option java_outer_classname = "APIV1ServicesMessagePersonalProto"; +option java_package = "com.origadmin.api.v1.services.message"; + +// PersonalService Personal user service +service PersonalService { + // GetPersonalProfile Update the personal user information + rpc GetPersonalProfile(GetPersonalProfileRequest) returns (GetPersonalProfileResponse) { + option (google.api.http) = {get: "/message/personal/profile"}; + } + // ListPersonalResources List the personal user's menu + rpc ListPersonalResources(ListPersonalResourcesRequest) returns (ListPersonalResourcesResponse) { + option (google.api.http) = {get: "/message/personal/resources"}; + } + // ListPersonalResources List the personal user's menu + rpc ListPersonalRoles(ListPersonalRolesRequest) returns (ListPersonalRolesResponse) { + option (google.api.http) = {get: "/message/personal/roles"}; + } + // PersonalLogout Personal user logs out + rpc PersonalLogout(PersonalLogoutRequest) returns (PersonalLogoutResponse) { + option (google.api.http) = { + post: "/message/personal/logout" + body: "data" + }; + } + // RefreshPersonalToken Refresh the personal user's token + rpc RefreshPersonalToken(RefreshPersonalTokenRequest) returns (RefreshPersonalTokenResponse) { + option (google.api.http) = { + post: "/message/personal/token/refresh" + body: "data" + }; + } + // UpdatePersonalProfilePassword The user changes the password + rpc UpdatePersonalPassword(UpdatePersonalPasswordRequest) returns (UpdatePersonalPasswordResponse) { + option (google.api.http) = { + put: "/message/personal/password" + body: "data" + }; + } + // UpdatePersonalProfile Update the personal user information + rpc UpdatePersonalProfile(UpdatePersonalProfileRequest) returns (UpdatePersonalProfileResponse) { + option (google.api.http) = { + put: "/message/personal/profile" + body: "data" + }; + } + // UpdatePersonalSetting User settings are saved + rpc UpdatePersonalSetting(UpdatePersonalSettingRequest) returns (UpdatePersonalSettingResponse) { + option (google.api.http) = { + put: "/message/personal/setting" + body: "data" + }; + } +} + +message UpdatePersonalSettingRequest { + google.protobuf.Any data = 1 [json_name = "data"]; +} + +message UpdatePersonalSettingResponse {} + +message UpdatePersonalRoleRequest { + api.v1.services.types.Role role = 1 [json_name = "role"]; +} + +message UpdatePersonalRoleResponse {} + +message ListPersonalResourcesRequest { + // The parent resource id, for example, "shelves/shelf1". + int64 id = 1 [json_name = "id"]; + // The current page number. + int32 current = 2 [json_name = "current"]; + // The maximum number of items to return. + int32 page_size = 3 [json_name = "page_size"]; + // The next_page_token value returned from a previous List request, if any. + string page_token = 4 [json_name = "page_token"]; + // The no_paging is used to disable pagination. + bool no_paging = 5 [json_name = "no_paging"]; + // The only_count is the query parameter for set only to query the total number + bool only_count = 6 [json_name = "only_count"]; +} + +message ListPersonalResourcesResponse { + // The total number of items in the list. + int64 total_size = 1 [json_name = "total"]; + // list of resources + repeated api.v1.services.types.Resource resources = 2 [json_name = "resources"]; + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 5 [json_name = "next_page_token"]; +} + +message UpdatePersonalPasswordRequest { + google.protobuf.Any data = 1 [json_name = "data"]; +} + +message UpdatePersonalPasswordResponse {} + +message PersonalPasswordRestRequest { + int64 id = 1 [ + json_name = "id", + (validate.rules).int64 = {gt: 0} + ]; +} + +message PersonalPasswordRestResponse {} + +message UpdatePersonalProfileRequest { + google.protobuf.Any data = 1 [json_name = "data"]; +} + +message UpdatePersonalProfileResponse {} + +message PersonalLogoutRequest { + google.protobuf.Any data = 2 [json_name = "data"]; +} + +message PersonalLogoutResponse { + bool success = 1; +} + +message ListPersonalRolesRequest {} + +message ListPersonalRolesResponse { + repeated api.v1.services.types.Role roles = 1; +} + +message GetPersonalProfileRequest {} + +message GetPersonalProfileResponse { + api.v1.services.types.User user = 1 [json_name = "user"]; +} + +message RefreshPersonalTokenRequest { + google.protobuf.Any data = 1 [json_name = "data"]; +} + +message RefreshPersonalTokenResponse { + string token = 1 [json_name = "token"]; +} diff --git a/api/v1/proto/types/message.proto b/api/v1/proto/types/message.proto new file mode 100644 index 00000000..d5864c47 --- /dev/null +++ b/api/v1/proto/types/message.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +package api.v1.services.types; + +import "google/protobuf/timestamp.proto"; + +option go_package = "origadmin/application/admin/api/v1/services/types;types"; +option java_multiple_files = true; +option java_outer_classname = "APIServiceTypeMessageProto"; +option java_package = "com.origadmin.api.v1.services.types"; +option objc_class_prefix = "APIServiceType"; + +// Menu is the model entity for the Menu schema. +message Message { + // ID of the ent. + int64 id = 1 [json_name = "id"]; + + +} diff --git a/internal/data/entity/ent/client.go b/internal/data/entity/ent/client.go index dc5e94dd..47d2a740 100644 --- a/internal/data/entity/ent/client.go +++ b/internal/data/entity/ent/client.go @@ -13,6 +13,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/casbinrule" "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/notification" "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/data/entity/ent/permissionresource" "origadmin/application/admin/internal/data/entity/ent/position" @@ -40,6 +41,8 @@ type Client struct { CasbinRule *CasbinRuleClient // Department is the client for interacting with the Department builders. Department *DepartmentClient + // Notification is the client for interacting with the Notification builders. + Notification *NotificationClient // Permission is the client for interacting with the Permission builders. Permission *PermissionClient // PermissionResource is the client for interacting with the PermissionResource builders. @@ -75,6 +78,7 @@ func (c *Client) init() { c.Schema = migrate.NewSchema(c.driver) c.CasbinRule = NewCasbinRuleClient(c.config) c.Department = NewDepartmentClient(c.config) + c.Notification = NewNotificationClient(c.config) c.Permission = NewPermissionClient(c.config) c.PermissionResource = NewPermissionResourceClient(c.config) c.Position = NewPositionClient(c.config) @@ -94,7 +98,7 @@ type ( // driver used for executing database requests. driver dialect.Driver // debug enable a debug logging. - debug func(dialect.Driver, ...func(...any)) dialect.Driver + debug bool // log used for logging on debug mode. log func(...any) // hooks to execute on mutations. @@ -118,22 +122,15 @@ func (c *config) options(opts ...Option) { for _, opt := range opts { opt(c) } - if c.debug != nil { - c.driver = c.debug(c.driver, c.log) + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) } } // Debug enables debug logging on the ent.Driver. func Debug() Option { return func(c *config) { - c.debug = dialect.Debug - } -} - -// WithDebug configures the debug function. -func WithDebug(fn func(dialect.Driver, ...func(...any)) dialect.Driver) Option { - return func(c *config) { - c.debug = fn + c.debug = true } } @@ -187,6 +184,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { config: cfg, CasbinRule: NewCasbinRuleClient(cfg), Department: NewDepartmentClient(cfg), + Notification: NewNotificationClient(cfg), Permission: NewPermissionClient(cfg), PermissionResource: NewPermissionResourceClient(cfg), Position: NewPositionClient(cfg), @@ -219,6 +217,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) config: cfg, CasbinRule: NewCasbinRuleClient(cfg), Department: NewDepartmentClient(cfg), + Notification: NewNotificationClient(cfg), Permission: NewPermissionClient(cfg), PermissionResource: NewPermissionResourceClient(cfg), Position: NewPositionClient(cfg), @@ -240,11 +239,11 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) // Query(). // Count(ctx) func (c *Client) Debug() *Client { - if c.debug != nil { + if c.debug { return c } cfg := c.config - cfg.driver = c.debug(c.driver, c.log) + cfg.driver = dialect.Debug(c.driver, c.log) client := &Client{config: cfg} client.init() return client @@ -259,8 +258,8 @@ func (c *Client) Close() error { // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ - c.CasbinRule, c.Department, c.Permission, c.PermissionResource, c.Position, - c.PositionPermission, c.Resource, c.Role, c.RolePermission, c.User, + c.CasbinRule, c.Department, c.Notification, c.Permission, c.PermissionResource, + c.Position, c.PositionPermission, c.Resource, c.Role, c.RolePermission, c.User, c.UserDepartment, c.UserPosition, c.UserRole, } { n.Use(hooks...) @@ -271,8 +270,8 @@ func (c *Client) Use(hooks ...Hook) { // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ - c.CasbinRule, c.Department, c.Permission, c.PermissionResource, c.Position, - c.PositionPermission, c.Resource, c.Role, c.RolePermission, c.User, + c.CasbinRule, c.Department, c.Notification, c.Permission, c.PermissionResource, + c.Position, c.PositionPermission, c.Resource, c.Role, c.RolePermission, c.User, c.UserDepartment, c.UserPosition, c.UserRole, } { n.Intercept(interceptors...) @@ -286,6 +285,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.CasbinRule.mutate(ctx, m) case *DepartmentMutation: return c.Department.mutate(ctx, m) + case *NotificationMutation: + return c.Notification.mutate(ctx, m) case *PermissionMutation: return c.Permission.mutate(ctx, m) case *PermissionResourceMutation: @@ -659,6 +660,139 @@ func (c *DepartmentClient) mutate(ctx context.Context, m *DepartmentMutation) (V } } +// NotificationClient is a client for the Notification schema. +type NotificationClient struct { + config +} + +// NewNotificationClient returns a client for the Notification from the given config. +func NewNotificationClient(c config) *NotificationClient { + return &NotificationClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `notification.Hooks(f(g(h())))`. +func (c *NotificationClient) Use(hooks ...Hook) { + c.hooks.Notification = append(c.hooks.Notification, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `notification.Intercept(f(g(h())))`. +func (c *NotificationClient) Intercept(interceptors ...Interceptor) { + c.inters.Notification = append(c.inters.Notification, interceptors...) +} + +// Create returns a builder for creating a Notification entity. +func (c *NotificationClient) Create() *NotificationCreate { + mutation := newNotificationMutation(c.config, OpCreate) + return &NotificationCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Notification entities. +func (c *NotificationClient) CreateBulk(builders ...*NotificationCreate) *NotificationCreateBulk { + return &NotificationCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *NotificationClient) MapCreateBulk(slice any, setFunc func(*NotificationCreate, int)) *NotificationCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &NotificationCreateBulk{err: fmt.Errorf("calling to NotificationClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*NotificationCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &NotificationCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Notification. +func (c *NotificationClient) Update() *NotificationUpdate { + mutation := newNotificationMutation(c.config, OpUpdate) + return &NotificationUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *NotificationClient) UpdateOne(n *Notification) *NotificationUpdateOne { + mutation := newNotificationMutation(c.config, OpUpdateOne, withNotification(n)) + return &NotificationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *NotificationClient) UpdateOneID(id int64) *NotificationUpdateOne { + mutation := newNotificationMutation(c.config, OpUpdateOne, withNotificationID(id)) + return &NotificationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Notification. +func (c *NotificationClient) Delete() *NotificationDelete { + mutation := newNotificationMutation(c.config, OpDelete) + return &NotificationDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *NotificationClient) DeleteOne(n *Notification) *NotificationDeleteOne { + return c.DeleteOneID(n.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *NotificationClient) DeleteOneID(id int64) *NotificationDeleteOne { + builder := c.Delete().Where(notification.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &NotificationDeleteOne{builder} +} + +// Query returns a query builder for Notification. +func (c *NotificationClient) Query() *NotificationQuery { + return &NotificationQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeNotification}, + inters: c.Interceptors(), + } +} + +// Get returns a Notification entity by its id. +func (c *NotificationClient) Get(ctx context.Context, id int64) (*Notification, error) { + return c.Query().Where(notification.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *NotificationClient) GetX(ctx context.Context, id int64) *Notification { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *NotificationClient) Hooks() []Hook { + return c.hooks.Notification +} + +// Interceptors returns the client interceptors. +func (c *NotificationClient) Interceptors() []Interceptor { + return c.inters.Notification +} + +func (c *NotificationClient) mutate(ctx context.Context, m *NotificationMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&NotificationCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&NotificationUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&NotificationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&NotificationDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Notification mutation op: %q", m.Op()) + } +} + // PermissionClient is a client for the Permission schema. type PermissionClient struct { config @@ -2719,12 +2853,12 @@ func (c *UserRoleClient) mutate(ctx context.Context, m *UserRoleMutation) (Value // hooks and interceptors per client, for fast access. type ( hooks struct { - CasbinRule, Department, Permission, PermissionResource, Position, + CasbinRule, Department, Notification, Permission, PermissionResource, Position, PositionPermission, Resource, Role, RolePermission, User, UserDepartment, UserPosition, UserRole []ent.Hook } inters struct { - CasbinRule, Department, Permission, PermissionResource, Position, + CasbinRule, Department, Notification, Permission, PermissionResource, Position, PositionPermission, Resource, Role, RolePermission, User, UserDepartment, UserPosition, UserRole []ent.Interceptor } diff --git a/internal/data/entity/ent/database.go b/internal/data/entity/ent/database.go index f59473ab..8d3b61b1 100644 --- a/internal/data/entity/ent/database.go +++ b/internal/data/entity/ent/database.go @@ -119,6 +119,11 @@ func (db *Database) Department(ctx context.Context) *DepartmentClient { return db.Client(ctx).Department } +// Notification is the client for interacting with the Notification builders. +func (db *Database) Notification(ctx context.Context) *NotificationClient { + return db.Client(ctx).Notification +} + // Permission is the client for interacting with the Permission builders. func (db *Database) Permission(ctx context.Context) *PermissionClient { return db.Client(ctx).Permission diff --git a/internal/data/entity/ent/ent.go b/internal/data/entity/ent/ent.go index e530c768..af73f78b 100644 --- a/internal/data/entity/ent/ent.go +++ b/internal/data/entity/ent/ent.go @@ -8,6 +8,7 @@ import ( "fmt" "origadmin/application/admin/internal/data/entity/ent/casbinrule" "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/notification" "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/data/entity/ent/permissionresource" "origadmin/application/admin/internal/data/entity/ent/position" @@ -87,6 +88,7 @@ func checkColumn(table, column string) error { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ casbinrule.Table: casbinrule.ValidColumn, department.Table: department.ValidColumn, + notification.Table: notification.ValidColumn, permission.Table: permission.ValidColumn, permissionresource.Table: permissionresource.ValidColumn, position.Table: position.ValidColumn, diff --git a/internal/data/entity/ent/generate.go b/internal/data/entity/ent/generate.go index 63845bbc..30225e2e 100644 --- a/internal/data/entity/ent/generate.go +++ b/internal/data/entity/ent/generate.go @@ -5,4 +5,4 @@ // Package ent is the data access object for SYS. package ent -//go:generate ./ent generate --template ./template --feature intercept --feature schema/snapshot --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema +//go:generate ent generate --template ./template --feature intercept --feature schema/snapshot --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema diff --git a/internal/data/entity/ent/hook/hook.go b/internal/data/entity/ent/hook/hook.go index 43ead7fd..122bef9d 100644 --- a/internal/data/entity/ent/hook/hook.go +++ b/internal/data/entity/ent/hook/hook.go @@ -32,6 +32,18 @@ func (f DepartmentFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.DepartmentMutation", m) } +// The NotificationFunc type is an adapter to allow the use of ordinary +// function as Notification mutator. +type NotificationFunc func(context.Context, *ent.NotificationMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f NotificationFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.NotificationMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.NotificationMutation", m) +} + // The PermissionFunc type is an adapter to allow the use of ordinary // function as Permission mutator. type PermissionFunc func(context.Context, *ent.PermissionMutation) (ent.Value, error) diff --git a/internal/data/entity/ent/intercept/intercept.go b/internal/data/entity/ent/intercept/intercept.go index e35adb18..fb629178 100644 --- a/internal/data/entity/ent/intercept/intercept.go +++ b/internal/data/entity/ent/intercept/intercept.go @@ -9,6 +9,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/casbinrule" "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/notification" "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/data/entity/ent/permissionresource" "origadmin/application/admin/internal/data/entity/ent/position" @@ -135,6 +136,33 @@ func (f TraverseDepartment) Traverse(ctx context.Context, q ent.Query) error { return fmt.Errorf("unexpected query type %T. expect *ent.DepartmentQuery", q) } +// The NotificationFunc type is an adapter to allow the use of ordinary function as a Querier. +type NotificationFunc func(context.Context, *ent.NotificationQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f NotificationFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.NotificationQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.NotificationQuery", q) +} + +// The TraverseNotification type is an adapter to allow the use of ordinary function as Traverser. +type TraverseNotification func(context.Context, *ent.NotificationQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseNotification) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseNotification) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.NotificationQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.NotificationQuery", q) +} + // The PermissionFunc type is an adapter to allow the use of ordinary function as a Querier. type PermissionFunc func(context.Context, *ent.PermissionQuery) (ent.Value, error) @@ -439,6 +467,8 @@ func NewQuery(q ent.Query) (Query, error) { return &query[*ent.CasbinRuleQuery, predicate.CasbinRule, casbinrule.OrderOption]{typ: ent.TypeCasbinRule, tq: q}, nil case *ent.DepartmentQuery: return &query[*ent.DepartmentQuery, predicate.Department, department.OrderOption]{typ: ent.TypeDepartment, tq: q}, nil + case *ent.NotificationQuery: + return &query[*ent.NotificationQuery, predicate.Notification, notification.OrderOption]{typ: ent.TypeNotification, tq: q}, nil case *ent.PermissionQuery: return &query[*ent.PermissionQuery, predicate.Permission, permission.OrderOption]{typ: ent.TypePermission, tq: q}, nil case *ent.PermissionResourceQuery: diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index dfb7c20e..61db98b6 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"children\",\"type\":\"Resource\"},{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref_name\":\"children\",\"unique\":true,\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"i18n_key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n_key\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2,\"default\":true,\"default_value\":\"M\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.component\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.icon\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.visible\"},{\"name\":\"level\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.level\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"properties\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"resource.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"parent_id\"]},{\"fields\":[\"level\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"delete_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"children\",\"type\":\"Resource\"},{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref_name\":\"children\",\"unique\":true,\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"i18n_key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n_key\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2,\"default\":true,\"default_value\":\"M\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.component\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.icon\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.visible\"},{\"name\":\"level\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.level\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"properties\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"resource.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"parent_id\"]},{\"fields\":[\"level\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"delete_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index 8337e072..efbb21fa 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -87,6 +87,47 @@ var ( }, }, } + // MsgNotificationsColumns holds the columns for the "msg_notifications" table. + MsgNotificationsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, + {Name: "create_author", Type: field.TypeInt64, Nullable: true, Comment: "create_author.field.comment", Default: 0}, + {Name: "update_author", Type: field.TypeInt64, Nullable: true, Comment: "update_author.field.comment", Default: 0}, + {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, + {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, + {Name: "subject", Type: field.TypeString, Comment: "entity.notification.field.subject", Default: ""}, + {Name: "content", Type: field.TypeString, Comment: "entity.notification.field.content", Default: ""}, + {Name: "status", Type: field.TypeInt8, Comment: "entity.notification.field.status", Default: 0}, + {Name: "category_id", Type: field.TypeInt64, Comment: "entity.notification.field.category_id"}, + } + // MsgNotificationsTable holds the schema information for the "msg_notifications" table. + MsgNotificationsTable = &schema.Table{ + Name: "msg_notifications", + Comment: "entity.notification.table.comment", + Columns: MsgNotificationsColumns, + PrimaryKey: []*schema.Column{MsgNotificationsColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "notification_create_author", + Unique: false, + Columns: []*schema.Column{MsgNotificationsColumns[1]}, + }, + { + Name: "notification_update_author", + Unique: false, + Columns: []*schema.Column{MsgNotificationsColumns[2]}, + }, + { + Name: "notification_create_time", + Unique: false, + Columns: []*schema.Column{MsgNotificationsColumns[3]}, + }, + { + Name: "notification_update_time", + Unique: false, + Columns: []*schema.Column{MsgNotificationsColumns[4]}, + }, + }, + } // SysPermissionsColumns holds the columns for the "sys_permissions" table. SysPermissionsColumns = []*schema.Column{ {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, @@ -298,12 +339,12 @@ var ( {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 32, Comment: "role.field.keyword"}, - {Name: "name", Type: field.TypeString, Size: 128, Comment: "role.field.name", Default: ""}, - {Name: "description", Type: field.TypeString, Size: 1024, Comment: "role.field.description", Default: ""}, - {Name: "type", Type: field.TypeInt8, Comment: "role.field.type", Default: 2}, - {Name: "sequence", Type: field.TypeInt, Comment: "role.field.sequence", Default: 0}, - {Name: "status", Type: field.TypeInt8, Comment: "role.field.status", Default: 1}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 32, Comment: "entity.role.field.keyword"}, + {Name: "name", Type: field.TypeString, Size: 128, Comment: "entity.role.field.name", Default: ""}, + {Name: "description", Type: field.TypeString, Size: 1024, Comment: "entity.role.field.description", Default: ""}, + {Name: "type", Type: field.TypeInt8, Comment: "entity.role.field.type", Default: 2}, + {Name: "sequence", Type: field.TypeInt, Comment: "entity.role.field.sequence", Default: 0}, + {Name: "status", Type: field.TypeInt8, Comment: "entity.role.field.status", Default: 1}, } // SysRolesTable holds the schema information for the "sys_roles" table. SysRolesTable = &schema.Table{ @@ -400,7 +441,7 @@ var ( {Name: "allowed_ip", Type: field.TypeString, Comment: "entity.user.field.allowed_ip", Default: "0.0.0.0"}, {Name: "username", Type: field.TypeString, Unique: true, Size: 32, Comment: "entity.user.field.username"}, {Name: "nickname", Type: field.TypeString, Size: 64, Comment: "entity.user.field.nickname", Default: ""}, - {Name: "avatar", Type: field.TypeString, Size: 256, Comment: "user.field.avatar", Default: ""}, + {Name: "avatar", Type: field.TypeString, Size: 256, Comment: "entity.user.field.avatar", Default: ""}, {Name: "name", Type: field.TypeString, Size: 64, Comment: "entity.user.field.nickname", Default: ""}, {Name: "gender", Type: field.TypeEnum, Comment: "entity.user.field.gender", Enums: []string{"male", "female", "unknown"}, Default: "unknown"}, {Name: "encrypted_password", Type: field.TypeString, Size: 256, Comment: "entity.user.field.encrypted_password", Default: ""}, @@ -411,7 +452,7 @@ var ( {Name: "remark", Type: field.TypeString, Size: 1024, Comment: "entity.user.field.remark", Default: ""}, {Name: "token", Type: field.TypeString, Size: 512, Comment: "entity.user.field.token", Default: ""}, {Name: "status", Type: field.TypeInt8, Comment: "entity.user.field.status", Default: 1}, - {Name: "is_system", Type: field.TypeBool, Comment: "user.field.is_system", Default: false}, + {Name: "is_system", Type: field.TypeBool, Comment: "entity.user.field.is_system", Default: false}, {Name: "last_login_ip", Type: field.TypeString, Size: 32, Comment: "entity.user.field.last_login_ip", Default: ""}, {Name: "last_login_time", Type: field.TypeTime, Comment: "entity.user.field.last_login_time", SchemaType: map[string]string{"mysql": "datetime"}}, {Name: "login_time", Type: field.TypeTime, Comment: "entity.user.field.login_time", SchemaType: map[string]string{"mysql": "datetime"}}, @@ -609,6 +650,7 @@ var ( Tables = []*schema.Table{ CasbinRulesTable, SysDepartmentsTable, + MsgNotificationsTable, SysPermissionsTable, SysPermissionResourcesTable, SysPositionsTable, @@ -628,6 +670,9 @@ func init() { SysDepartmentsTable.Annotation = &entsql.Annotation{ Table: "sys_departments", } + MsgNotificationsTable.Annotation = &entsql.Annotation{ + Table: "msg_notifications", + } SysPermissionsTable.Annotation = &entsql.Annotation{ Table: "sys_permissions", } diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index 7f5df561..d60b40d2 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -8,6 +8,7 @@ import ( "fmt" "origadmin/application/admin/internal/data/entity/ent/casbinrule" "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/notification" "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/data/entity/ent/permissionresource" "origadmin/application/admin/internal/data/entity/ent/position" @@ -38,6 +39,7 @@ const ( // Node types. TypeCasbinRule = "CasbinRule" TypeDepartment = "Department" + TypeNotification = "Notification" TypePermission = "Permission" TypePermissionResource = "PermissionResource" TypePosition = "Position" @@ -2031,6 +2033,894 @@ func (m *DepartmentMutation) ResetEdge(name string) error { return fmt.Errorf("unknown Department edge %s", name) } +// NotificationMutation represents an operation that mutates the Notification nodes in the graph. +type NotificationMutation struct { + config + op Op + typ string + id *int64 + create_author *int64 + addcreate_author *int64 + update_author *int64 + addupdate_author *int64 + create_time *time.Time + update_time *time.Time + subject *string + content *string + status *int8 + addstatus *int8 + category_id *int64 + addcategory_id *int64 + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Notification, error) + predicates []predicate.Notification +} + +var _ ent.Mutation = (*NotificationMutation)(nil) + +// notificationOption allows management of the mutation configuration using functional options. +type notificationOption func(*NotificationMutation) + +// newNotificationMutation creates new mutation for the Notification entity. +func newNotificationMutation(c config, op Op, opts ...notificationOption) *NotificationMutation { + m := &NotificationMutation{ + config: c, + op: op, + typ: TypeNotification, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withNotificationID sets the ID field of the mutation. +func withNotificationID(id int64) notificationOption { + return func(m *NotificationMutation) { + var ( + err error + once sync.Once + value *Notification + ) + m.oldValue = func(ctx context.Context) (*Notification, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Notification.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withNotification sets the old Notification of the mutation. +func withNotification(node *Notification) notificationOption { + return func(m *NotificationMutation) { + m.oldValue = func(context.Context) (*Notification, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m NotificationMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m NotificationMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Notification entities. +func (m *NotificationMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *NotificationMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *NotificationMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Notification.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateAuthor sets the "create_author" field. +func (m *NotificationMutation) SetCreateAuthor(i int64) { + m.create_author = &i + m.addcreate_author = nil +} + +// CreateAuthor returns the value of the "create_author" field in the mutation. +func (m *NotificationMutation) CreateAuthor() (r int64, exists bool) { + v := m.create_author + if v == nil { + return + } + return *v, true +} + +// OldCreateAuthor returns the old "create_author" field's value of the Notification entity. +// If the Notification object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotificationMutation) OldCreateAuthor(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateAuthor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateAuthor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateAuthor: %w", err) + } + return oldValue.CreateAuthor, nil +} + +// AddCreateAuthor adds i to the "create_author" field. +func (m *NotificationMutation) AddCreateAuthor(i int64) { + if m.addcreate_author != nil { + *m.addcreate_author += i + } else { + m.addcreate_author = &i + } +} + +// AddedCreateAuthor returns the value that was added to the "create_author" field in this mutation. +func (m *NotificationMutation) AddedCreateAuthor() (r int64, exists bool) { + v := m.addcreate_author + if v == nil { + return + } + return *v, true +} + +// ClearCreateAuthor clears the value of the "create_author" field. +func (m *NotificationMutation) ClearCreateAuthor() { + m.create_author = nil + m.addcreate_author = nil + m.clearedFields[notification.FieldCreateAuthor] = struct{}{} +} + +// CreateAuthorCleared returns if the "create_author" field was cleared in this mutation. +func (m *NotificationMutation) CreateAuthorCleared() bool { + _, ok := m.clearedFields[notification.FieldCreateAuthor] + return ok +} + +// ResetCreateAuthor resets all changes to the "create_author" field. +func (m *NotificationMutation) ResetCreateAuthor() { + m.create_author = nil + m.addcreate_author = nil + delete(m.clearedFields, notification.FieldCreateAuthor) +} + +// SetUpdateAuthor sets the "update_author" field. +func (m *NotificationMutation) SetUpdateAuthor(i int64) { + m.update_author = &i + m.addupdate_author = nil +} + +// UpdateAuthor returns the value of the "update_author" field in the mutation. +func (m *NotificationMutation) UpdateAuthor() (r int64, exists bool) { + v := m.update_author + if v == nil { + return + } + return *v, true +} + +// OldUpdateAuthor returns the old "update_author" field's value of the Notification entity. +// If the Notification object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotificationMutation) OldUpdateAuthor(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateAuthor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateAuthor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateAuthor: %w", err) + } + return oldValue.UpdateAuthor, nil +} + +// AddUpdateAuthor adds i to the "update_author" field. +func (m *NotificationMutation) AddUpdateAuthor(i int64) { + if m.addupdate_author != nil { + *m.addupdate_author += i + } else { + m.addupdate_author = &i + } +} + +// AddedUpdateAuthor returns the value that was added to the "update_author" field in this mutation. +func (m *NotificationMutation) AddedUpdateAuthor() (r int64, exists bool) { + v := m.addupdate_author + if v == nil { + return + } + return *v, true +} + +// ClearUpdateAuthor clears the value of the "update_author" field. +func (m *NotificationMutation) ClearUpdateAuthor() { + m.update_author = nil + m.addupdate_author = nil + m.clearedFields[notification.FieldUpdateAuthor] = struct{}{} +} + +// UpdateAuthorCleared returns if the "update_author" field was cleared in this mutation. +func (m *NotificationMutation) UpdateAuthorCleared() bool { + _, ok := m.clearedFields[notification.FieldUpdateAuthor] + return ok +} + +// ResetUpdateAuthor resets all changes to the "update_author" field. +func (m *NotificationMutation) ResetUpdateAuthor() { + m.update_author = nil + m.addupdate_author = nil + delete(m.clearedFields, notification.FieldUpdateAuthor) +} + +// SetCreateTime sets the "create_time" field. +func (m *NotificationMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *NotificationMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Notification entity. +// If the Notification object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotificationMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *NotificationMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *NotificationMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *NotificationMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Notification entity. +// If the Notification object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotificationMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *NotificationMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetSubject sets the "subject" field. +func (m *NotificationMutation) SetSubject(s string) { + m.subject = &s +} + +// Subject returns the value of the "subject" field in the mutation. +func (m *NotificationMutation) Subject() (r string, exists bool) { + v := m.subject + if v == nil { + return + } + return *v, true +} + +// OldSubject returns the old "subject" field's value of the Notification entity. +// If the Notification object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotificationMutation) OldSubject(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSubject is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSubject requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSubject: %w", err) + } + return oldValue.Subject, nil +} + +// ResetSubject resets all changes to the "subject" field. +func (m *NotificationMutation) ResetSubject() { + m.subject = nil +} + +// SetContent sets the "content" field. +func (m *NotificationMutation) SetContent(s string) { + m.content = &s +} + +// Content returns the value of the "content" field in the mutation. +func (m *NotificationMutation) Content() (r string, exists bool) { + v := m.content + if v == nil { + return + } + return *v, true +} + +// OldContent returns the old "content" field's value of the Notification entity. +// If the Notification object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotificationMutation) OldContent(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldContent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldContent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldContent: %w", err) + } + return oldValue.Content, nil +} + +// ResetContent resets all changes to the "content" field. +func (m *NotificationMutation) ResetContent() { + m.content = nil +} + +// SetStatus sets the "status" field. +func (m *NotificationMutation) SetStatus(i int8) { + m.status = &i + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *NotificationMutation) Status() (r int8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the Notification entity. +// If the Notification object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotificationMutation) OldStatus(ctx context.Context) (v int8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds i to the "status" field. +func (m *NotificationMutation) AddStatus(i int8) { + if m.addstatus != nil { + *m.addstatus += i + } else { + m.addstatus = &i + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *NotificationMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ResetStatus resets all changes to the "status" field. +func (m *NotificationMutation) ResetStatus() { + m.status = nil + m.addstatus = nil +} + +// SetCategoryID sets the "category_id" field. +func (m *NotificationMutation) SetCategoryID(i int64) { + m.category_id = &i + m.addcategory_id = nil +} + +// CategoryID returns the value of the "category_id" field in the mutation. +func (m *NotificationMutation) CategoryID() (r int64, exists bool) { + v := m.category_id + if v == nil { + return + } + return *v, true +} + +// OldCategoryID returns the old "category_id" field's value of the Notification entity. +// If the Notification object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NotificationMutation) OldCategoryID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCategoryID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCategoryID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCategoryID: %w", err) + } + return oldValue.CategoryID, nil +} + +// AddCategoryID adds i to the "category_id" field. +func (m *NotificationMutation) AddCategoryID(i int64) { + if m.addcategory_id != nil { + *m.addcategory_id += i + } else { + m.addcategory_id = &i + } +} + +// AddedCategoryID returns the value that was added to the "category_id" field in this mutation. +func (m *NotificationMutation) AddedCategoryID() (r int64, exists bool) { + v := m.addcategory_id + if v == nil { + return + } + return *v, true +} + +// ResetCategoryID resets all changes to the "category_id" field. +func (m *NotificationMutation) ResetCategoryID() { + m.category_id = nil + m.addcategory_id = nil +} + +// Where appends a list predicates to the NotificationMutation builder. +func (m *NotificationMutation) Where(ps ...predicate.Notification) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the NotificationMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *NotificationMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Notification, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *NotificationMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *NotificationMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Notification). +func (m *NotificationMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *NotificationMutation) Fields() []string { + fields := make([]string, 0, 8) + if m.create_author != nil { + fields = append(fields, notification.FieldCreateAuthor) + } + if m.update_author != nil { + fields = append(fields, notification.FieldUpdateAuthor) + } + if m.create_time != nil { + fields = append(fields, notification.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, notification.FieldUpdateTime) + } + if m.subject != nil { + fields = append(fields, notification.FieldSubject) + } + if m.content != nil { + fields = append(fields, notification.FieldContent) + } + if m.status != nil { + fields = append(fields, notification.FieldStatus) + } + if m.category_id != nil { + fields = append(fields, notification.FieldCategoryID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *NotificationMutation) Field(name string) (ent.Value, bool) { + switch name { + case notification.FieldCreateAuthor: + return m.CreateAuthor() + case notification.FieldUpdateAuthor: + return m.UpdateAuthor() + case notification.FieldCreateTime: + return m.CreateTime() + case notification.FieldUpdateTime: + return m.UpdateTime() + case notification.FieldSubject: + return m.Subject() + case notification.FieldContent: + return m.Content() + case notification.FieldStatus: + return m.Status() + case notification.FieldCategoryID: + return m.CategoryID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *NotificationMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case notification.FieldCreateAuthor: + return m.OldCreateAuthor(ctx) + case notification.FieldUpdateAuthor: + return m.OldUpdateAuthor(ctx) + case notification.FieldCreateTime: + return m.OldCreateTime(ctx) + case notification.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case notification.FieldSubject: + return m.OldSubject(ctx) + case notification.FieldContent: + return m.OldContent(ctx) + case notification.FieldStatus: + return m.OldStatus(ctx) + case notification.FieldCategoryID: + return m.OldCategoryID(ctx) + } + return nil, fmt.Errorf("unknown Notification field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *NotificationMutation) SetField(name string, value ent.Value) error { + switch name { + case notification.FieldCreateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateAuthor(v) + return nil + case notification.FieldUpdateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateAuthor(v) + return nil + case notification.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case notification.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case notification.FieldSubject: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSubject(v) + return nil + case notification.FieldContent: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetContent(v) + return nil + case notification.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case notification.FieldCategoryID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCategoryID(v) + return nil + } + return fmt.Errorf("unknown Notification field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *NotificationMutation) AddedFields() []string { + var fields []string + if m.addcreate_author != nil { + fields = append(fields, notification.FieldCreateAuthor) + } + if m.addupdate_author != nil { + fields = append(fields, notification.FieldUpdateAuthor) + } + if m.addstatus != nil { + fields = append(fields, notification.FieldStatus) + } + if m.addcategory_id != nil { + fields = append(fields, notification.FieldCategoryID) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *NotificationMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case notification.FieldCreateAuthor: + return m.AddedCreateAuthor() + case notification.FieldUpdateAuthor: + return m.AddedUpdateAuthor() + case notification.FieldStatus: + return m.AddedStatus() + case notification.FieldCategoryID: + return m.AddedCategoryID() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *NotificationMutation) AddField(name string, value ent.Value) error { + switch name { + case notification.FieldCreateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCreateAuthor(v) + return nil + case notification.FieldUpdateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUpdateAuthor(v) + return nil + case notification.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case notification.FieldCategoryID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCategoryID(v) + return nil + } + return fmt.Errorf("unknown Notification numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *NotificationMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(notification.FieldCreateAuthor) { + fields = append(fields, notification.FieldCreateAuthor) + } + if m.FieldCleared(notification.FieldUpdateAuthor) { + fields = append(fields, notification.FieldUpdateAuthor) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *NotificationMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *NotificationMutation) ClearField(name string) error { + switch name { + case notification.FieldCreateAuthor: + m.ClearCreateAuthor() + return nil + case notification.FieldUpdateAuthor: + m.ClearUpdateAuthor() + return nil + } + return fmt.Errorf("unknown Notification nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *NotificationMutation) ResetField(name string) error { + switch name { + case notification.FieldCreateAuthor: + m.ResetCreateAuthor() + return nil + case notification.FieldUpdateAuthor: + m.ResetUpdateAuthor() + return nil + case notification.FieldCreateTime: + m.ResetCreateTime() + return nil + case notification.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case notification.FieldSubject: + m.ResetSubject() + return nil + case notification.FieldContent: + m.ResetContent() + return nil + case notification.FieldStatus: + m.ResetStatus() + return nil + case notification.FieldCategoryID: + m.ResetCategoryID() + return nil + } + return fmt.Errorf("unknown Notification field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *NotificationMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *NotificationMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *NotificationMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *NotificationMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *NotificationMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *NotificationMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *NotificationMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Notification unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *NotificationMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Notification edge %s", name) +} + // PermissionMutation represents an operation that mutates the Permission nodes in the graph. type PermissionMutation struct { config diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index 37a5e8d9..80a753a6 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -6,6 +6,7 @@ import ( "fmt" "origadmin/application/admin/internal/data/entity/ent/casbinrule" "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/notification" "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/data/entity/ent/permissionresource" "origadmin/application/admin/internal/data/entity/ent/position" @@ -195,6 +196,93 @@ func (m *DepartmentMutation) SetFieldsWithZero(input *Department, fields ...stri return nil } +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *NotificationMutation) SetFields(input *Notification, fields ...string) error { + for i := range fields { + switch fields[i] { + case notification.FieldCreateAuthor: + // check int64 with sql.NullInt64 if it is zero + if input.CreateAuthor != 0 { + m.SetCreateAuthor(input.CreateAuthor) + } + case notification.FieldUpdateAuthor: + // check int64 with sql.NullInt64 if it is zero + if input.UpdateAuthor != 0 { + m.SetUpdateAuthor(input.UpdateAuthor) + } + case notification.FieldCreateTime: + if input.CreateTime.Unix() != 0 { + m.SetCreateTime(input.CreateTime) + } + case notification.FieldUpdateTime: + if input.UpdateTime.Unix() != 0 { + m.SetUpdateTime(input.UpdateTime) + } + case notification.FieldSubject: + // check string with sql.NullString if it is empty + if input.Subject != "" { + m.SetSubject(input.Subject) + } + case notification.FieldContent: + // check string with sql.NullString if it is empty + if input.Content != "" { + m.SetContent(input.Content) + } + case notification.FieldStatus: + // check int8 with sql.NullInt64 if it is zero + if input.Status != 0 { + m.SetStatus(input.Status) + } + case notification.FieldCategoryID: + // check int64 with sql.NullInt64 if it is zero + if input.CategoryID != 0 { + m.SetCategoryID(input.CategoryID) + } + case notification.FieldID: + // check int64 with sql.NullInt64 if it is zero + if input.ID != 0 { + m.SetID(input.ID) + } + default: + return fmt.Errorf("unknown Notification field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *NotificationMutation) SetFieldsWithZero(input *Notification, fields ...string) error { + for i := range fields { + switch fields[i] { + case notification.FieldCreateAuthor: + m.SetCreateAuthor(input.CreateAuthor) + case notification.FieldUpdateAuthor: + m.SetUpdateAuthor(input.UpdateAuthor) + case notification.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case notification.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case notification.FieldSubject: + m.SetSubject(input.Subject) + case notification.FieldContent: + m.SetContent(input.Content) + case notification.FieldStatus: + m.SetStatus(input.Status) + case notification.FieldCategoryID: + m.SetCategoryID(input.CategoryID) + case notification.FieldID: + m.SetID(input.ID) + default: + return fmt.Errorf("unknown Notification field %s", fields[i]) + } + } + return nil +} + // SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the // field type. diff --git a/internal/data/entity/ent/notification.go b/internal/data/entity/ent/notification.go new file mode 100644 index 00000000..3cc39350 --- /dev/null +++ b/internal/data/entity/ent/notification.go @@ -0,0 +1,184 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "origadmin/application/admin/internal/data/entity/ent/notification" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// entity.notification.table.comment +type Notification struct { + config `json:"-"` + // ID of the ent. + // field.primary_key.comment + ID int64 `json:"id,omitempty"` + // create_author.field.comment + CreateAuthor int64 `json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `json:"update_author,omitempty"` + // create_time.field.comment + CreateTime time.Time `json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime time.Time `json:"update_time,omitempty"` + // entity.notification.field.subject + Subject string `json:"subject,omitempty"` + // entity.notification.field.content + Content string `json:"content,omitempty"` + // entity.notification.field.status + Status int8 `json:"status,omitempty"` + // entity.notification.field.category_id + CategoryID int64 `json:"category_id,omitempty"` + selectValues sql.SelectValues +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Notification) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case notification.FieldID, notification.FieldCreateAuthor, notification.FieldUpdateAuthor, notification.FieldStatus, notification.FieldCategoryID: + values[i] = new(sql.NullInt64) + case notification.FieldSubject, notification.FieldContent: + values[i] = new(sql.NullString) + case notification.FieldCreateTime, notification.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Notification fields. +func (n *Notification) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case notification.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + n.ID = int64(value.Int64) + case notification.FieldCreateAuthor: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field create_author", values[i]) + } else if value.Valid { + n.CreateAuthor = value.Int64 + } + case notification.FieldUpdateAuthor: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field update_author", values[i]) + } else if value.Valid { + n.UpdateAuthor = value.Int64 + } + case notification.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + n.CreateTime = value.Time + } + case notification.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + n.UpdateTime = value.Time + } + case notification.FieldSubject: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field subject", values[i]) + } else if value.Valid { + n.Subject = value.String + } + case notification.FieldContent: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field content", values[i]) + } else if value.Valid { + n.Content = value.String + } + case notification.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + n.Status = int8(value.Int64) + } + case notification.FieldCategoryID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field category_id", values[i]) + } else if value.Valid { + n.CategoryID = value.Int64 + } + default: + n.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Notification. +// This includes values selected through modifiers, order, etc. +func (n *Notification) Value(name string) (ent.Value, error) { + return n.selectValues.Get(name) +} + +// Update returns a builder for updating this Notification. +// Note that you need to call Notification.Unwrap() before calling this method if this Notification +// was returned from a transaction, and the transaction was committed or rolled back. +func (n *Notification) Update() *NotificationUpdateOne { + return NewNotificationClient(n.config).UpdateOne(n) +} + +// Unwrap unwraps the Notification entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (n *Notification) Unwrap() *Notification { + _tx, ok := n.config.driver.(*txDriver) + if !ok { + panic("ent: Notification is not a transactional entity") + } + n.config.driver = _tx.drv + return n +} + +// String implements the fmt.Stringer. +func (n *Notification) String() string { + var builder strings.Builder + builder.WriteString("Notification(") + builder.WriteString(fmt.Sprintf("id=%v, ", n.ID)) + builder.WriteString("create_author=") + builder.WriteString(fmt.Sprintf("%v", n.CreateAuthor)) + builder.WriteString(", ") + builder.WriteString("update_author=") + builder.WriteString(fmt.Sprintf("%v", n.UpdateAuthor)) + builder.WriteString(", ") + builder.WriteString("create_time=") + builder.WriteString(n.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(n.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("subject=") + builder.WriteString(n.Subject) + builder.WriteString(", ") + builder.WriteString("content=") + builder.WriteString(n.Content) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", n.Status)) + builder.WriteString(", ") + builder.WriteString("category_id=") + builder.WriteString(fmt.Sprintf("%v", n.CategoryID)) + builder.WriteByte(')') + return builder.String() +} + +// Notifications is a parsable slice of Notification. +type Notifications []*Notification diff --git a/internal/data/entity/ent/notification/notification.go b/internal/data/entity/ent/notification/notification.go new file mode 100644 index 00000000..54c36347 --- /dev/null +++ b/internal/data/entity/ent/notification/notification.go @@ -0,0 +1,192 @@ +// Code generated by ent, DO NOT EDIT. + +package notification + +import ( + "time" + + "entgo.io/ent/dialect/sql" +) + +const ( + // Label holds the string label denoting the notification type in the database. + Label = "notification" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateAuthor holds the string denoting the create_author field in the database. + FieldCreateAuthor = "create_author" + // FieldUpdateAuthor holds the string denoting the update_author field in the database. + FieldUpdateAuthor = "update_author" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldSubject holds the string denoting the subject field in the database. + FieldSubject = "subject" + // FieldContent holds the string denoting the content field in the database. + FieldContent = "content" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldCategoryID holds the string denoting the category_id field in the database. + FieldCategoryID = "category_id" + // Table holds the table name of the notification in the database. + Table = "msg_notifications" +) + +// Columns holds all SQL columns for notification fields. +var Columns = []string{ + FieldID, + FieldCreateAuthor, + FieldUpdateAuthor, + FieldCreateTime, + FieldUpdateTime, + FieldSubject, + FieldContent, + FieldStatus, + FieldCategoryID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateAuthor holds the default value on creation for the "create_author" field. + DefaultCreateAuthor int64 + // DefaultUpdateAuthor holds the default value on creation for the "update_author" field. + DefaultUpdateAuthor int64 + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // DefaultSubject holds the default value on creation for the "subject" field. + DefaultSubject string + // DefaultContent holds the default value on creation for the "content" field. + DefaultContent string + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int8 + // CategoryIDValidator is a validator for the "category_id" field. It is called by the builders before save. + CategoryIDValidator func(int64) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int64) error +) + +// OrderOption defines the ordering options for the Notification queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateAuthor orders the results by the create_author field. +func ByCreateAuthor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateAuthor, opts...).ToFunc() +} + +// ByUpdateAuthor orders the results by the update_author field. +func ByUpdateAuthor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateAuthor, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// BySubject orders the results by the subject field. +func BySubject(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSubject, opts...).ToFunc() +} + +// ByContent orders the results by the content field. +func ByContent(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldContent, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByCategoryID orders the results by the category_id field. +func ByCategoryID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCategoryID, opts...).ToFunc() +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/notification/where.go b/internal/data/entity/ent/notification/where.go new file mode 100644 index 00000000..11f751f2 --- /dev/null +++ b/internal/data/entity/ent/notification/where.go @@ -0,0 +1,500 @@ +// Code generated by ent, DO NOT EDIT. + +package notification + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.Notification { + return predicate.Notification(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.Notification { + return predicate.Notification(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.Notification { + return predicate.Notification(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.Notification { + return predicate.Notification(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.Notification { + return predicate.Notification(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.Notification { + return predicate.Notification(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.Notification { + return predicate.Notification(sql.FieldLTE(FieldID, id)) +} + +// CreateAuthor applies equality check predicate on the "create_author" field. It's identical to CreateAuthorEQ. +func CreateAuthor(v int64) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldCreateAuthor, v)) +} + +// UpdateAuthor applies equality check predicate on the "update_author" field. It's identical to UpdateAuthorEQ. +func UpdateAuthor(v int64) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldUpdateAuthor, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Subject applies equality check predicate on the "subject" field. It's identical to SubjectEQ. +func Subject(v string) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldSubject, v)) +} + +// Content applies equality check predicate on the "content" field. It's identical to ContentEQ. +func Content(v string) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldContent, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int8) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldStatus, v)) +} + +// CategoryID applies equality check predicate on the "category_id" field. It's identical to CategoryIDEQ. +func CategoryID(v int64) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldCategoryID, v)) +} + +// CreateAuthorEQ applies the EQ predicate on the "create_author" field. +func CreateAuthorEQ(v int64) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldCreateAuthor, v)) +} + +// CreateAuthorNEQ applies the NEQ predicate on the "create_author" field. +func CreateAuthorNEQ(v int64) predicate.Notification { + return predicate.Notification(sql.FieldNEQ(FieldCreateAuthor, v)) +} + +// CreateAuthorIn applies the In predicate on the "create_author" field. +func CreateAuthorIn(vs ...int64) predicate.Notification { + return predicate.Notification(sql.FieldIn(FieldCreateAuthor, vs...)) +} + +// CreateAuthorNotIn applies the NotIn predicate on the "create_author" field. +func CreateAuthorNotIn(vs ...int64) predicate.Notification { + return predicate.Notification(sql.FieldNotIn(FieldCreateAuthor, vs...)) +} + +// CreateAuthorGT applies the GT predicate on the "create_author" field. +func CreateAuthorGT(v int64) predicate.Notification { + return predicate.Notification(sql.FieldGT(FieldCreateAuthor, v)) +} + +// CreateAuthorGTE applies the GTE predicate on the "create_author" field. +func CreateAuthorGTE(v int64) predicate.Notification { + return predicate.Notification(sql.FieldGTE(FieldCreateAuthor, v)) +} + +// CreateAuthorLT applies the LT predicate on the "create_author" field. +func CreateAuthorLT(v int64) predicate.Notification { + return predicate.Notification(sql.FieldLT(FieldCreateAuthor, v)) +} + +// CreateAuthorLTE applies the LTE predicate on the "create_author" field. +func CreateAuthorLTE(v int64) predicate.Notification { + return predicate.Notification(sql.FieldLTE(FieldCreateAuthor, v)) +} + +// CreateAuthorIsNil applies the IsNil predicate on the "create_author" field. +func CreateAuthorIsNil() predicate.Notification { + return predicate.Notification(sql.FieldIsNull(FieldCreateAuthor)) +} + +// CreateAuthorNotNil applies the NotNil predicate on the "create_author" field. +func CreateAuthorNotNil() predicate.Notification { + return predicate.Notification(sql.FieldNotNull(FieldCreateAuthor)) +} + +// UpdateAuthorEQ applies the EQ predicate on the "update_author" field. +func UpdateAuthorEQ(v int64) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldUpdateAuthor, v)) +} + +// UpdateAuthorNEQ applies the NEQ predicate on the "update_author" field. +func UpdateAuthorNEQ(v int64) predicate.Notification { + return predicate.Notification(sql.FieldNEQ(FieldUpdateAuthor, v)) +} + +// UpdateAuthorIn applies the In predicate on the "update_author" field. +func UpdateAuthorIn(vs ...int64) predicate.Notification { + return predicate.Notification(sql.FieldIn(FieldUpdateAuthor, vs...)) +} + +// UpdateAuthorNotIn applies the NotIn predicate on the "update_author" field. +func UpdateAuthorNotIn(vs ...int64) predicate.Notification { + return predicate.Notification(sql.FieldNotIn(FieldUpdateAuthor, vs...)) +} + +// UpdateAuthorGT applies the GT predicate on the "update_author" field. +func UpdateAuthorGT(v int64) predicate.Notification { + return predicate.Notification(sql.FieldGT(FieldUpdateAuthor, v)) +} + +// UpdateAuthorGTE applies the GTE predicate on the "update_author" field. +func UpdateAuthorGTE(v int64) predicate.Notification { + return predicate.Notification(sql.FieldGTE(FieldUpdateAuthor, v)) +} + +// UpdateAuthorLT applies the LT predicate on the "update_author" field. +func UpdateAuthorLT(v int64) predicate.Notification { + return predicate.Notification(sql.FieldLT(FieldUpdateAuthor, v)) +} + +// UpdateAuthorLTE applies the LTE predicate on the "update_author" field. +func UpdateAuthorLTE(v int64) predicate.Notification { + return predicate.Notification(sql.FieldLTE(FieldUpdateAuthor, v)) +} + +// UpdateAuthorIsNil applies the IsNil predicate on the "update_author" field. +func UpdateAuthorIsNil() predicate.Notification { + return predicate.Notification(sql.FieldIsNull(FieldUpdateAuthor)) +} + +// UpdateAuthorNotNil applies the NotNil predicate on the "update_author" field. +func UpdateAuthorNotNil() predicate.Notification { + return predicate.Notification(sql.FieldNotNull(FieldUpdateAuthor)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Notification { + return predicate.Notification(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Notification { + return predicate.Notification(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Notification { + return predicate.Notification(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Notification { + return predicate.Notification(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Notification { + return predicate.Notification(sql.FieldLTE(FieldUpdateTime, v)) +} + +// SubjectEQ applies the EQ predicate on the "subject" field. +func SubjectEQ(v string) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldSubject, v)) +} + +// SubjectNEQ applies the NEQ predicate on the "subject" field. +func SubjectNEQ(v string) predicate.Notification { + return predicate.Notification(sql.FieldNEQ(FieldSubject, v)) +} + +// SubjectIn applies the In predicate on the "subject" field. +func SubjectIn(vs ...string) predicate.Notification { + return predicate.Notification(sql.FieldIn(FieldSubject, vs...)) +} + +// SubjectNotIn applies the NotIn predicate on the "subject" field. +func SubjectNotIn(vs ...string) predicate.Notification { + return predicate.Notification(sql.FieldNotIn(FieldSubject, vs...)) +} + +// SubjectGT applies the GT predicate on the "subject" field. +func SubjectGT(v string) predicate.Notification { + return predicate.Notification(sql.FieldGT(FieldSubject, v)) +} + +// SubjectGTE applies the GTE predicate on the "subject" field. +func SubjectGTE(v string) predicate.Notification { + return predicate.Notification(sql.FieldGTE(FieldSubject, v)) +} + +// SubjectLT applies the LT predicate on the "subject" field. +func SubjectLT(v string) predicate.Notification { + return predicate.Notification(sql.FieldLT(FieldSubject, v)) +} + +// SubjectLTE applies the LTE predicate on the "subject" field. +func SubjectLTE(v string) predicate.Notification { + return predicate.Notification(sql.FieldLTE(FieldSubject, v)) +} + +// SubjectContains applies the Contains predicate on the "subject" field. +func SubjectContains(v string) predicate.Notification { + return predicate.Notification(sql.FieldContains(FieldSubject, v)) +} + +// SubjectHasPrefix applies the HasPrefix predicate on the "subject" field. +func SubjectHasPrefix(v string) predicate.Notification { + return predicate.Notification(sql.FieldHasPrefix(FieldSubject, v)) +} + +// SubjectHasSuffix applies the HasSuffix predicate on the "subject" field. +func SubjectHasSuffix(v string) predicate.Notification { + return predicate.Notification(sql.FieldHasSuffix(FieldSubject, v)) +} + +// SubjectEqualFold applies the EqualFold predicate on the "subject" field. +func SubjectEqualFold(v string) predicate.Notification { + return predicate.Notification(sql.FieldEqualFold(FieldSubject, v)) +} + +// SubjectContainsFold applies the ContainsFold predicate on the "subject" field. +func SubjectContainsFold(v string) predicate.Notification { + return predicate.Notification(sql.FieldContainsFold(FieldSubject, v)) +} + +// ContentEQ applies the EQ predicate on the "content" field. +func ContentEQ(v string) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldContent, v)) +} + +// ContentNEQ applies the NEQ predicate on the "content" field. +func ContentNEQ(v string) predicate.Notification { + return predicate.Notification(sql.FieldNEQ(FieldContent, v)) +} + +// ContentIn applies the In predicate on the "content" field. +func ContentIn(vs ...string) predicate.Notification { + return predicate.Notification(sql.FieldIn(FieldContent, vs...)) +} + +// ContentNotIn applies the NotIn predicate on the "content" field. +func ContentNotIn(vs ...string) predicate.Notification { + return predicate.Notification(sql.FieldNotIn(FieldContent, vs...)) +} + +// ContentGT applies the GT predicate on the "content" field. +func ContentGT(v string) predicate.Notification { + return predicate.Notification(sql.FieldGT(FieldContent, v)) +} + +// ContentGTE applies the GTE predicate on the "content" field. +func ContentGTE(v string) predicate.Notification { + return predicate.Notification(sql.FieldGTE(FieldContent, v)) +} + +// ContentLT applies the LT predicate on the "content" field. +func ContentLT(v string) predicate.Notification { + return predicate.Notification(sql.FieldLT(FieldContent, v)) +} + +// ContentLTE applies the LTE predicate on the "content" field. +func ContentLTE(v string) predicate.Notification { + return predicate.Notification(sql.FieldLTE(FieldContent, v)) +} + +// ContentContains applies the Contains predicate on the "content" field. +func ContentContains(v string) predicate.Notification { + return predicate.Notification(sql.FieldContains(FieldContent, v)) +} + +// ContentHasPrefix applies the HasPrefix predicate on the "content" field. +func ContentHasPrefix(v string) predicate.Notification { + return predicate.Notification(sql.FieldHasPrefix(FieldContent, v)) +} + +// ContentHasSuffix applies the HasSuffix predicate on the "content" field. +func ContentHasSuffix(v string) predicate.Notification { + return predicate.Notification(sql.FieldHasSuffix(FieldContent, v)) +} + +// ContentEqualFold applies the EqualFold predicate on the "content" field. +func ContentEqualFold(v string) predicate.Notification { + return predicate.Notification(sql.FieldEqualFold(FieldContent, v)) +} + +// ContentContainsFold applies the ContainsFold predicate on the "content" field. +func ContentContainsFold(v string) predicate.Notification { + return predicate.Notification(sql.FieldContainsFold(FieldContent, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int8) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int8) predicate.Notification { + return predicate.Notification(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int8) predicate.Notification { + return predicate.Notification(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int8) predicate.Notification { + return predicate.Notification(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int8) predicate.Notification { + return predicate.Notification(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int8) predicate.Notification { + return predicate.Notification(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int8) predicate.Notification { + return predicate.Notification(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int8) predicate.Notification { + return predicate.Notification(sql.FieldLTE(FieldStatus, v)) +} + +// CategoryIDEQ applies the EQ predicate on the "category_id" field. +func CategoryIDEQ(v int64) predicate.Notification { + return predicate.Notification(sql.FieldEQ(FieldCategoryID, v)) +} + +// CategoryIDNEQ applies the NEQ predicate on the "category_id" field. +func CategoryIDNEQ(v int64) predicate.Notification { + return predicate.Notification(sql.FieldNEQ(FieldCategoryID, v)) +} + +// CategoryIDIn applies the In predicate on the "category_id" field. +func CategoryIDIn(vs ...int64) predicate.Notification { + return predicate.Notification(sql.FieldIn(FieldCategoryID, vs...)) +} + +// CategoryIDNotIn applies the NotIn predicate on the "category_id" field. +func CategoryIDNotIn(vs ...int64) predicate.Notification { + return predicate.Notification(sql.FieldNotIn(FieldCategoryID, vs...)) +} + +// CategoryIDGT applies the GT predicate on the "category_id" field. +func CategoryIDGT(v int64) predicate.Notification { + return predicate.Notification(sql.FieldGT(FieldCategoryID, v)) +} + +// CategoryIDGTE applies the GTE predicate on the "category_id" field. +func CategoryIDGTE(v int64) predicate.Notification { + return predicate.Notification(sql.FieldGTE(FieldCategoryID, v)) +} + +// CategoryIDLT applies the LT predicate on the "category_id" field. +func CategoryIDLT(v int64) predicate.Notification { + return predicate.Notification(sql.FieldLT(FieldCategoryID, v)) +} + +// CategoryIDLTE applies the LTE predicate on the "category_id" field. +func CategoryIDLTE(v int64) predicate.Notification { + return predicate.Notification(sql.FieldLTE(FieldCategoryID, v)) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Notification) predicate.Notification { + return predicate.Notification(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Notification) predicate.Notification { + return predicate.Notification(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Notification) predicate.Notification { + return predicate.Notification(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/notification_create.go b/internal/data/entity/ent/notification_create.go new file mode 100644 index 00000000..04dfb0b1 --- /dev/null +++ b/internal/data/entity/ent/notification_create.go @@ -0,0 +1,413 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/data/entity/ent/notification" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// NotificationCreate is the builder for creating a Notification entity. +type NotificationCreate struct { + config + mutation *NotificationMutation + hooks []Hook +} + +// SetCreateAuthor sets the "create_author" field. +func (nc *NotificationCreate) SetCreateAuthor(i int64) *NotificationCreate { + nc.mutation.SetCreateAuthor(i) + return nc +} + +// SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. +func (nc *NotificationCreate) SetNillableCreateAuthor(i *int64) *NotificationCreate { + if i != nil { + nc.SetCreateAuthor(*i) + } + return nc +} + +// SetUpdateAuthor sets the "update_author" field. +func (nc *NotificationCreate) SetUpdateAuthor(i int64) *NotificationCreate { + nc.mutation.SetUpdateAuthor(i) + return nc +} + +// SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. +func (nc *NotificationCreate) SetNillableUpdateAuthor(i *int64) *NotificationCreate { + if i != nil { + nc.SetUpdateAuthor(*i) + } + return nc +} + +// SetCreateTime sets the "create_time" field. +func (nc *NotificationCreate) SetCreateTime(t time.Time) *NotificationCreate { + nc.mutation.SetCreateTime(t) + return nc +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (nc *NotificationCreate) SetNillableCreateTime(t *time.Time) *NotificationCreate { + if t != nil { + nc.SetCreateTime(*t) + } + return nc +} + +// SetUpdateTime sets the "update_time" field. +func (nc *NotificationCreate) SetUpdateTime(t time.Time) *NotificationCreate { + nc.mutation.SetUpdateTime(t) + return nc +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (nc *NotificationCreate) SetNillableUpdateTime(t *time.Time) *NotificationCreate { + if t != nil { + nc.SetUpdateTime(*t) + } + return nc +} + +// SetSubject sets the "subject" field. +func (nc *NotificationCreate) SetSubject(s string) *NotificationCreate { + nc.mutation.SetSubject(s) + return nc +} + +// SetNillableSubject sets the "subject" field if the given value is not nil. +func (nc *NotificationCreate) SetNillableSubject(s *string) *NotificationCreate { + if s != nil { + nc.SetSubject(*s) + } + return nc +} + +// SetContent sets the "content" field. +func (nc *NotificationCreate) SetContent(s string) *NotificationCreate { + nc.mutation.SetContent(s) + return nc +} + +// SetNillableContent sets the "content" field if the given value is not nil. +func (nc *NotificationCreate) SetNillableContent(s *string) *NotificationCreate { + if s != nil { + nc.SetContent(*s) + } + return nc +} + +// SetStatus sets the "status" field. +func (nc *NotificationCreate) SetStatus(i int8) *NotificationCreate { + nc.mutation.SetStatus(i) + return nc +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (nc *NotificationCreate) SetNillableStatus(i *int8) *NotificationCreate { + if i != nil { + nc.SetStatus(*i) + } + return nc +} + +// SetCategoryID sets the "category_id" field. +func (nc *NotificationCreate) SetCategoryID(i int64) *NotificationCreate { + nc.mutation.SetCategoryID(i) + return nc +} + +// SetID sets the "id" field. +func (nc *NotificationCreate) SetID(i int64) *NotificationCreate { + nc.mutation.SetID(i) + return nc +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (nc *NotificationCreate) SetNillableID(i *int64) *NotificationCreate { + if i != nil { + nc.SetID(*i) + } + return nc +} + +// Mutation returns the NotificationMutation object of the builder. +func (nc *NotificationCreate) Mutation() *NotificationMutation { + return nc.mutation +} + +// Save creates the Notification in the database. +func (nc *NotificationCreate) Save(ctx context.Context) (*Notification, error) { + nc.defaults() + return withHooks(ctx, nc.sqlSave, nc.mutation, nc.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (nc *NotificationCreate) SaveX(ctx context.Context) *Notification { + v, err := nc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (nc *NotificationCreate) Exec(ctx context.Context) error { + _, err := nc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (nc *NotificationCreate) ExecX(ctx context.Context) { + if err := nc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (nc *NotificationCreate) defaults() { + if _, ok := nc.mutation.CreateAuthor(); !ok { + v := notification.DefaultCreateAuthor + nc.mutation.SetCreateAuthor(v) + } + if _, ok := nc.mutation.UpdateAuthor(); !ok { + v := notification.DefaultUpdateAuthor + nc.mutation.SetUpdateAuthor(v) + } + if _, ok := nc.mutation.CreateTime(); !ok { + v := notification.DefaultCreateTime() + nc.mutation.SetCreateTime(v) + } + if _, ok := nc.mutation.UpdateTime(); !ok { + v := notification.DefaultUpdateTime() + nc.mutation.SetUpdateTime(v) + } + if _, ok := nc.mutation.Subject(); !ok { + v := notification.DefaultSubject + nc.mutation.SetSubject(v) + } + if _, ok := nc.mutation.Content(); !ok { + v := notification.DefaultContent + nc.mutation.SetContent(v) + } + if _, ok := nc.mutation.Status(); !ok { + v := notification.DefaultStatus + nc.mutation.SetStatus(v) + } + if _, ok := nc.mutation.ID(); !ok { + v := notification.DefaultID() + nc.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (nc *NotificationCreate) check() error { + if _, ok := nc.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Notification.create_time"`)} + } + if _, ok := nc.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Notification.update_time"`)} + } + if _, ok := nc.mutation.Subject(); !ok { + return &ValidationError{Name: "subject", err: errors.New(`ent: missing required field "Notification.subject"`)} + } + if _, ok := nc.mutation.Content(); !ok { + return &ValidationError{Name: "content", err: errors.New(`ent: missing required field "Notification.content"`)} + } + if _, ok := nc.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Notification.status"`)} + } + if _, ok := nc.mutation.CategoryID(); !ok { + return &ValidationError{Name: "category_id", err: errors.New(`ent: missing required field "Notification.category_id"`)} + } + if v, ok := nc.mutation.CategoryID(); ok { + if err := notification.CategoryIDValidator(v); err != nil { + return &ValidationError{Name: "category_id", err: fmt.Errorf(`ent: validator failed for field "Notification.category_id": %w`, err)} + } + } + if v, ok := nc.mutation.ID(); ok { + if err := notification.IDValidator(v); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Notification.id": %w`, err)} + } + } + return nil +} + +func (nc *NotificationCreate) sqlSave(ctx context.Context) (*Notification, error) { + if err := nc.check(); err != nil { + return nil, err + } + _node, _spec := nc.createSpec() + if err := sqlgraph.CreateNode(ctx, nc.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + nc.mutation.id = &_node.ID + nc.mutation.done = true + return _node, nil +} + +func (nc *NotificationCreate) createSpec() (*Notification, *sqlgraph.CreateSpec) { + var ( + _node = &Notification{config: nc.config} + _spec = sqlgraph.NewCreateSpec(notification.Table, sqlgraph.NewFieldSpec(notification.FieldID, field.TypeInt64)) + ) + if id, ok := nc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := nc.mutation.CreateAuthor(); ok { + _spec.SetField(notification.FieldCreateAuthor, field.TypeInt64, value) + _node.CreateAuthor = value + } + if value, ok := nc.mutation.UpdateAuthor(); ok { + _spec.SetField(notification.FieldUpdateAuthor, field.TypeInt64, value) + _node.UpdateAuthor = value + } + if value, ok := nc.mutation.CreateTime(); ok { + _spec.SetField(notification.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := nc.mutation.UpdateTime(); ok { + _spec.SetField(notification.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if value, ok := nc.mutation.Subject(); ok { + _spec.SetField(notification.FieldSubject, field.TypeString, value) + _node.Subject = value + } + if value, ok := nc.mutation.Content(); ok { + _spec.SetField(notification.FieldContent, field.TypeString, value) + _node.Content = value + } + if value, ok := nc.mutation.Status(); ok { + _spec.SetField(notification.FieldStatus, field.TypeInt8, value) + _node.Status = value + } + if value, ok := nc.mutation.CategoryID(); ok { + _spec.SetField(notification.FieldCategoryID, field.TypeInt64, value) + _node.CategoryID = value + } + return _node, _spec +} + +// SetNotification set the Notification +func (nc *NotificationCreate) SetNotification(input *Notification, fields ...string) *NotificationCreate { + m := nc.mutation + if len(fields) == 0 { + fields = notification.Columns + } + _ = m.SetFields(input, fields...) + return nc +} + +// SetNotificationWithZero set the Notification +func (nc *NotificationCreate) SetNotificationWithZero(input *Notification, fields ...string) *NotificationCreate { + m := nc.mutation + if len(fields) == 0 { + fields = notification.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return nc +} + +// NotificationCreateBulk is the builder for creating many Notification entities in bulk. +type NotificationCreateBulk struct { + config + err error + builders []*NotificationCreate +} + +// Save creates the Notification entities in the database. +func (ncb *NotificationCreateBulk) Save(ctx context.Context) ([]*Notification, error) { + if ncb.err != nil { + return nil, ncb.err + } + specs := make([]*sqlgraph.CreateSpec, len(ncb.builders)) + nodes := make([]*Notification, len(ncb.builders)) + mutators := make([]Mutator, len(ncb.builders)) + for i := range ncb.builders { + func(i int, root context.Context) { + builder := ncb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*NotificationMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, ncb.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, ncb.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, ncb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ncb *NotificationCreateBulk) SaveX(ctx context.Context) []*Notification { + v, err := ncb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ncb *NotificationCreateBulk) Exec(ctx context.Context) error { + _, err := ncb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ncb *NotificationCreateBulk) ExecX(ctx context.Context) { + if err := ncb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/data/entity/ent/notification_delete.go b/internal/data/entity/ent/notification_delete.go new file mode 100644 index 00000000..815faac6 --- /dev/null +++ b/internal/data/entity/ent/notification_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/data/entity/ent/notification" + "origadmin/application/admin/internal/data/entity/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// NotificationDelete is the builder for deleting a Notification entity. +type NotificationDelete struct { + config + hooks []Hook + mutation *NotificationMutation +} + +// Where appends a list predicates to the NotificationDelete builder. +func (nd *NotificationDelete) Where(ps ...predicate.Notification) *NotificationDelete { + nd.mutation.Where(ps...) + return nd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (nd *NotificationDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, nd.sqlExec, nd.mutation, nd.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (nd *NotificationDelete) ExecX(ctx context.Context) int { + n, err := nd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (nd *NotificationDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(notification.Table, sqlgraph.NewFieldSpec(notification.FieldID, field.TypeInt64)) + if ps := nd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, nd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + nd.mutation.done = true + return affected, err +} + +// NotificationDeleteOne is the builder for deleting a single Notification entity. +type NotificationDeleteOne struct { + nd *NotificationDelete +} + +// Where appends a list predicates to the NotificationDelete builder. +func (ndo *NotificationDeleteOne) Where(ps ...predicate.Notification) *NotificationDeleteOne { + ndo.nd.mutation.Where(ps...) + return ndo +} + +// Exec executes the deletion query. +func (ndo *NotificationDeleteOne) Exec(ctx context.Context) error { + n, err := ndo.nd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{notification.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (ndo *NotificationDeleteOne) ExecX(ctx context.Context) { + if err := ndo.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/data/entity/ent/notification_query.go b/internal/data/entity/ent/notification_query.go new file mode 100644 index 00000000..79e41516 --- /dev/null +++ b/internal/data/entity/ent/notification_query.go @@ -0,0 +1,621 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "origadmin/application/admin/internal/data/entity/ent/notification" + "origadmin/application/admin/internal/data/entity/ent/predicate" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// NotificationQuery is the builder for querying Notification entities. +type NotificationQuery struct { + config + ctx *QueryContext + order []notification.OrderOption + inters []Interceptor + predicates []predicate.Notification + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the NotificationQuery builder. +func (nq *NotificationQuery) Where(ps ...predicate.Notification) *NotificationQuery { + nq.predicates = append(nq.predicates, ps...) + return nq +} + +// Limit the number of records to be returned by this query. +func (nq *NotificationQuery) Limit(limit int) *NotificationQuery { + nq.ctx.Limit = &limit + return nq +} + +// Offset to start from. +func (nq *NotificationQuery) Offset(offset int) *NotificationQuery { + nq.ctx.Offset = &offset + return nq +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (nq *NotificationQuery) Unique(unique bool) *NotificationQuery { + nq.ctx.Unique = &unique + return nq +} + +// Order specifies how the records should be ordered. +func (nq *NotificationQuery) Order(o ...notification.OrderOption) *NotificationQuery { + nq.order = append(nq.order, o...) + return nq +} + +// First returns the first Notification entity from the query. +// Returns a *NotFoundError when no Notification was found. +func (nq *NotificationQuery) First(ctx context.Context) (*Notification, error) { + nodes, err := nq.Limit(1).All(setContextOp(ctx, nq.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{notification.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (nq *NotificationQuery) FirstX(ctx context.Context) *Notification { + node, err := nq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Notification ID from the query. +// Returns a *NotFoundError when no Notification ID was found. +func (nq *NotificationQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = nq.Limit(1).IDs(setContextOp(ctx, nq.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{notification.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (nq *NotificationQuery) FirstIDX(ctx context.Context) int64 { + id, err := nq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Notification entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Notification entity is found. +// Returns a *NotFoundError when no Notification entities are found. +func (nq *NotificationQuery) Only(ctx context.Context) (*Notification, error) { + nodes, err := nq.Limit(2).All(setContextOp(ctx, nq.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{notification.Label} + default: + return nil, &NotSingularError{notification.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (nq *NotificationQuery) OnlyX(ctx context.Context) *Notification { + node, err := nq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Notification ID in the query. +// Returns a *NotSingularError when more than one Notification ID is found. +// Returns a *NotFoundError when no entities are found. +func (nq *NotificationQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = nq.Limit(2).IDs(setContextOp(ctx, nq.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{notification.Label} + default: + err = &NotSingularError{notification.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (nq *NotificationQuery) OnlyIDX(ctx context.Context) int64 { + id, err := nq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Notifications. +func (nq *NotificationQuery) All(ctx context.Context) ([]*Notification, error) { + ctx = setContextOp(ctx, nq.ctx, ent.OpQueryAll) + if err := nq.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Notification, *NotificationQuery]() + return withInterceptors[[]*Notification](ctx, nq, qr, nq.inters) +} + +// AllX is like All, but panics if an error occurs. +func (nq *NotificationQuery) AllX(ctx context.Context) []*Notification { + nodes, err := nq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Notification IDs. +func (nq *NotificationQuery) IDs(ctx context.Context) (ids []int64, err error) { + if nq.ctx.Unique == nil && nq.path != nil { + nq.Unique(true) + } + ctx = setContextOp(ctx, nq.ctx, ent.OpQueryIDs) + if err = nq.Select(notification.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (nq *NotificationQuery) IDsX(ctx context.Context) []int64 { + ids, err := nq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (nq *NotificationQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, nq.ctx, ent.OpQueryCount) + if err := nq.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, nq, querierCount[*NotificationQuery](), nq.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (nq *NotificationQuery) CountX(ctx context.Context) int { + count, err := nq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (nq *NotificationQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, nq.ctx, ent.OpQueryExist) + switch _, err := nq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (nq *NotificationQuery) ExistX(ctx context.Context) bool { + exist, err := nq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the NotificationQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (nq *NotificationQuery) Clone() *NotificationQuery { + if nq == nil { + return nil + } + return &NotificationQuery{ + config: nq.config, + ctx: nq.ctx.Clone(), + order: append([]notification.OrderOption{}, nq.order...), + inters: append([]Interceptor{}, nq.inters...), + predicates: append([]predicate.Notification{}, nq.predicates...), + // clone intermediate query. + sql: nq.sql.Clone(), + path: nq.path, + modifiers: append([]func(*sql.Selector){}, nq.modifiers...), + } +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreateAuthor int64 `json:"create_author,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Notification.Query(). +// GroupBy(notification.FieldCreateAuthor). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (nq *NotificationQuery) GroupBy(field string, fields ...string) *NotificationGroupBy { + nq.ctx.Fields = append([]string{field}, fields...) + grbuild := &NotificationGroupBy{build: nq} + grbuild.flds = &nq.ctx.Fields + grbuild.label = notification.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreateAuthor int64 `json:"create_author,omitempty"` +// } +// +// client.Notification.Query(). +// Select(notification.FieldCreateAuthor). +// Scan(ctx, &v) +func (nq *NotificationQuery) Select(fields ...string) *NotificationSelect { + nq.ctx.Fields = append(nq.ctx.Fields, fields...) + sbuild := &NotificationSelect{NotificationQuery: nq} + sbuild.label = notification.Label + sbuild.flds, sbuild.scan = &nq.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a NotificationSelect configured with the given aggregations. +func (nq *NotificationQuery) Aggregate(fns ...AggregateFunc) *NotificationSelect { + return nq.Select().Aggregate(fns...) +} + +func (nq *NotificationQuery) prepareQuery(ctx context.Context) error { + for _, inter := range nq.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, nq); err != nil { + return err + } + } + } + for _, f := range nq.ctx.Fields { + if !notification.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if nq.path != nil { + prev, err := nq.path(ctx) + if err != nil { + return err + } + nq.sql = prev + } + return nil +} + +func (nq *NotificationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Notification, error) { + var ( + nodes = []*Notification{} + _spec = nq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Notification).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Notification{config: nq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + if len(nq.modifiers) > 0 { + _spec.Modifiers = nq.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, nq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (nq *NotificationQuery) sqlCount(ctx context.Context) (int, error) { + _spec := nq.querySpec() + if len(nq.modifiers) > 0 { + _spec.Modifiers = nq.modifiers + } + _spec.Node.Columns = nq.ctx.Fields + if len(nq.ctx.Fields) > 0 { + _spec.Unique = nq.ctx.Unique != nil && *nq.ctx.Unique + } + return sqlgraph.CountNodes(ctx, nq.driver, _spec) +} + +func (nq *NotificationQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(notification.Table, notification.Columns, sqlgraph.NewFieldSpec(notification.FieldID, field.TypeInt64)) + _spec.From = nq.sql + if unique := nq.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if nq.path != nil { + _spec.Unique = true + } + if fields := nq.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, notification.FieldID) + for i := range fields { + if fields[i] != notification.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := nq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := nq.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := nq.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := nq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (nq *NotificationQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(nq.driver.Dialect()) + t1 := builder.Table(notification.Table) + columns := nq.ctx.Fields + if len(columns) == 0 { + columns = notification.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if nq.sql != nil { + selector = nq.sql + selector.Select(selector.Columns(columns...)...) + } + if nq.ctx.Unique != nil && *nq.ctx.Unique { + selector.Distinct() + } + for _, m := range nq.modifiers { + m(selector) + } + for _, p := range nq.predicates { + p(selector) + } + for _, p := range nq.order { + p(selector) + } + if offset := nq.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := nq.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (nq *NotificationQuery) ForUpdate(opts ...sql.LockOption) *NotificationQuery { + if nq.driver.Dialect() == dialect.Postgres { + nq.Unique(false) + } + nq.modifiers = append(nq.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return nq +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (nq *NotificationQuery) ForShare(opts ...sql.LockOption) *NotificationQuery { + if nq.driver.Dialect() == dialect.Postgres { + nq.Unique(false) + } + nq.modifiers = append(nq.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return nq +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (nq *NotificationQuery) Modify(modifiers ...func(s *sql.Selector)) *NotificationSelect { + nq.modifiers = append(nq.modifiers, modifiers...) + return nq.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// CreateAuthor int64 `json:"create_author,omitempty"` +// UpdateAuthor int64 `json:"update_author,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` +// UpdateTime time.Time `json:"update_time,omitempty"` +// Subject string `json:"subject,omitempty"` +// Content string `json:"content,omitempty"` +// Status int8 `json:"status,omitempty"` +// CategoryID int64 `json:"category_id,omitempty"` +// } +// +// client.Notification.Query(). +// Omit( +// notification.FieldCreateAuthor, +// notification.FieldUpdateAuthor, +// notification.FieldCreateTime, +// notification.FieldUpdateTime, +// notification.FieldSubject, +// notification.FieldContent, +// notification.FieldStatus, +// notification.FieldCategoryID, +// ). +// Scan(ctx, &v) +func (nq *NotificationQuery) Omit(fields ...string) *NotificationSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range notification.Columns { + if _, ok := omits[col]; !ok { + nq.ctx.Fields = append(nq.ctx.Fields, col) + } + } + + sbuild := &NotificationSelect{NotificationQuery: nq} + sbuild.label = notification.Label + sbuild.flds, sbuild.scan = &nq.ctx.Fields, sbuild.Scan + return sbuild +} + +// NotificationGroupBy is the group-by builder for Notification entities. +type NotificationGroupBy struct { + selector + build *NotificationQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (ngb *NotificationGroupBy) Aggregate(fns ...AggregateFunc) *NotificationGroupBy { + ngb.fns = append(ngb.fns, fns...) + return ngb +} + +// Scan applies the selector query and scans the result into the given value. +func (ngb *NotificationGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ngb.build.ctx, ent.OpQueryGroupBy) + if err := ngb.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*NotificationQuery, *NotificationGroupBy](ctx, ngb.build, ngb, ngb.build.inters, v) +} + +func (ngb *NotificationGroupBy) sqlScan(ctx context.Context, root *NotificationQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(ngb.fns)) + for _, fn := range ngb.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*ngb.flds)+len(ngb.fns)) + for _, f := range *ngb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*ngb.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ngb.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// NotificationSelect is the builder for selecting fields of Notification entities. +type NotificationSelect struct { + *NotificationQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (ns *NotificationSelect) Aggregate(fns ...AggregateFunc) *NotificationSelect { + ns.fns = append(ns.fns, fns...) + return ns +} + +// Scan applies the selector query and scans the result into the given value. +func (ns *NotificationSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, ns.ctx, ent.OpQuerySelect) + if err := ns.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*NotificationQuery, *NotificationSelect](ctx, ns.NotificationQuery, ns, ns.inters, v) +} + +func (ns *NotificationSelect) sqlScan(ctx context.Context, root *NotificationQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(ns.fns)) + for _, fn := range ns.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*ns.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ns.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (ns *NotificationSelect) Modify(modifiers ...func(s *sql.Selector)) *NotificationSelect { + ns.modifiers = append(ns.modifiers, modifiers...) + return ns +} diff --git a/internal/data/entity/ent/notification_update.go b/internal/data/entity/ent/notification_update.go new file mode 100644 index 00000000..515d7c0e --- /dev/null +++ b/internal/data/entity/ent/notification_update.go @@ -0,0 +1,630 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/data/entity/ent/notification" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// NotificationUpdate is the builder for updating Notification entities. +type NotificationUpdate struct { + config + hooks []Hook + mutation *NotificationMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the NotificationUpdate builder. +func (nu *NotificationUpdate) Where(ps ...predicate.Notification) *NotificationUpdate { + nu.mutation.Where(ps...) + return nu +} + +// SetCreateAuthor sets the "create_author" field. +func (nu *NotificationUpdate) SetCreateAuthor(i int64) *NotificationUpdate { + nu.mutation.ResetCreateAuthor() + nu.mutation.SetCreateAuthor(i) + return nu +} + +// SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. +func (nu *NotificationUpdate) SetNillableCreateAuthor(i *int64) *NotificationUpdate { + if i != nil { + nu.SetCreateAuthor(*i) + } + return nu +} + +// AddCreateAuthor adds i to the "create_author" field. +func (nu *NotificationUpdate) AddCreateAuthor(i int64) *NotificationUpdate { + nu.mutation.AddCreateAuthor(i) + return nu +} + +// ClearCreateAuthor clears the value of the "create_author" field. +func (nu *NotificationUpdate) ClearCreateAuthor() *NotificationUpdate { + nu.mutation.ClearCreateAuthor() + return nu +} + +// SetUpdateAuthor sets the "update_author" field. +func (nu *NotificationUpdate) SetUpdateAuthor(i int64) *NotificationUpdate { + nu.mutation.ResetUpdateAuthor() + nu.mutation.SetUpdateAuthor(i) + return nu +} + +// SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. +func (nu *NotificationUpdate) SetNillableUpdateAuthor(i *int64) *NotificationUpdate { + if i != nil { + nu.SetUpdateAuthor(*i) + } + return nu +} + +// AddUpdateAuthor adds i to the "update_author" field. +func (nu *NotificationUpdate) AddUpdateAuthor(i int64) *NotificationUpdate { + nu.mutation.AddUpdateAuthor(i) + return nu +} + +// ClearUpdateAuthor clears the value of the "update_author" field. +func (nu *NotificationUpdate) ClearUpdateAuthor() *NotificationUpdate { + nu.mutation.ClearUpdateAuthor() + return nu +} + +// SetUpdateTime sets the "update_time" field. +func (nu *NotificationUpdate) SetUpdateTime(t time.Time) *NotificationUpdate { + nu.mutation.SetUpdateTime(t) + return nu +} + +// SetSubject sets the "subject" field. +func (nu *NotificationUpdate) SetSubject(s string) *NotificationUpdate { + nu.mutation.SetSubject(s) + return nu +} + +// SetNillableSubject sets the "subject" field if the given value is not nil. +func (nu *NotificationUpdate) SetNillableSubject(s *string) *NotificationUpdate { + if s != nil { + nu.SetSubject(*s) + } + return nu +} + +// SetContent sets the "content" field. +func (nu *NotificationUpdate) SetContent(s string) *NotificationUpdate { + nu.mutation.SetContent(s) + return nu +} + +// SetNillableContent sets the "content" field if the given value is not nil. +func (nu *NotificationUpdate) SetNillableContent(s *string) *NotificationUpdate { + if s != nil { + nu.SetContent(*s) + } + return nu +} + +// SetStatus sets the "status" field. +func (nu *NotificationUpdate) SetStatus(i int8) *NotificationUpdate { + nu.mutation.ResetStatus() + nu.mutation.SetStatus(i) + return nu +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (nu *NotificationUpdate) SetNillableStatus(i *int8) *NotificationUpdate { + if i != nil { + nu.SetStatus(*i) + } + return nu +} + +// AddStatus adds i to the "status" field. +func (nu *NotificationUpdate) AddStatus(i int8) *NotificationUpdate { + nu.mutation.AddStatus(i) + return nu +} + +// SetCategoryID sets the "category_id" field. +func (nu *NotificationUpdate) SetCategoryID(i int64) *NotificationUpdate { + nu.mutation.ResetCategoryID() + nu.mutation.SetCategoryID(i) + return nu +} + +// SetNillableCategoryID sets the "category_id" field if the given value is not nil. +func (nu *NotificationUpdate) SetNillableCategoryID(i *int64) *NotificationUpdate { + if i != nil { + nu.SetCategoryID(*i) + } + return nu +} + +// AddCategoryID adds i to the "category_id" field. +func (nu *NotificationUpdate) AddCategoryID(i int64) *NotificationUpdate { + nu.mutation.AddCategoryID(i) + return nu +} + +// Mutation returns the NotificationMutation object of the builder. +func (nu *NotificationUpdate) Mutation() *NotificationMutation { + return nu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (nu *NotificationUpdate) Save(ctx context.Context) (int, error) { + nu.defaults() + return withHooks(ctx, nu.sqlSave, nu.mutation, nu.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (nu *NotificationUpdate) SaveX(ctx context.Context) int { + affected, err := nu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (nu *NotificationUpdate) Exec(ctx context.Context) error { + _, err := nu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (nu *NotificationUpdate) ExecX(ctx context.Context) { + if err := nu.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (nu *NotificationUpdate) defaults() { + if _, ok := nu.mutation.UpdateTime(); !ok { + v := notification.UpdateDefaultUpdateTime() + nu.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (nu *NotificationUpdate) check() error { + if v, ok := nu.mutation.CategoryID(); ok { + if err := notification.CategoryIDValidator(v); err != nil { + return &ValidationError{Name: "category_id", err: fmt.Errorf(`ent: validator failed for field "Notification.category_id": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (nu *NotificationUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NotificationUpdate { + nu.modifiers = append(nu.modifiers, modifiers...) + return nu +} + +func (nu *NotificationUpdate) sqlSave(ctx context.Context) (n int, err error) { + if err := nu.check(); err != nil { + return n, err + } + _spec := sqlgraph.NewUpdateSpec(notification.Table, notification.Columns, sqlgraph.NewFieldSpec(notification.FieldID, field.TypeInt64)) + if ps := nu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := nu.mutation.CreateAuthor(); ok { + _spec.SetField(notification.FieldCreateAuthor, field.TypeInt64, value) + } + if value, ok := nu.mutation.AddedCreateAuthor(); ok { + _spec.AddField(notification.FieldCreateAuthor, field.TypeInt64, value) + } + if nu.mutation.CreateAuthorCleared() { + _spec.ClearField(notification.FieldCreateAuthor, field.TypeInt64) + } + if value, ok := nu.mutation.UpdateAuthor(); ok { + _spec.SetField(notification.FieldUpdateAuthor, field.TypeInt64, value) + } + if value, ok := nu.mutation.AddedUpdateAuthor(); ok { + _spec.AddField(notification.FieldUpdateAuthor, field.TypeInt64, value) + } + if nu.mutation.UpdateAuthorCleared() { + _spec.ClearField(notification.FieldUpdateAuthor, field.TypeInt64) + } + if value, ok := nu.mutation.UpdateTime(); ok { + _spec.SetField(notification.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := nu.mutation.Subject(); ok { + _spec.SetField(notification.FieldSubject, field.TypeString, value) + } + if value, ok := nu.mutation.Content(); ok { + _spec.SetField(notification.FieldContent, field.TypeString, value) + } + if value, ok := nu.mutation.Status(); ok { + _spec.SetField(notification.FieldStatus, field.TypeInt8, value) + } + if value, ok := nu.mutation.AddedStatus(); ok { + _spec.AddField(notification.FieldStatus, field.TypeInt8, value) + } + if value, ok := nu.mutation.CategoryID(); ok { + _spec.SetField(notification.FieldCategoryID, field.TypeInt64, value) + } + if value, ok := nu.mutation.AddedCategoryID(); ok { + _spec.AddField(notification.FieldCategoryID, field.TypeInt64, value) + } + _spec.AddModifiers(nu.modifiers...) + if n, err = sqlgraph.UpdateNodes(ctx, nu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{notification.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + nu.mutation.done = true + return n, nil +} + +// NotificationUpdateOne is the builder for updating a single Notification entity. +type NotificationUpdateOne struct { + config + fields []string + hooks []Hook + mutation *NotificationMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetCreateAuthor sets the "create_author" field. +func (nuo *NotificationUpdateOne) SetCreateAuthor(i int64) *NotificationUpdateOne { + nuo.mutation.ResetCreateAuthor() + nuo.mutation.SetCreateAuthor(i) + return nuo +} + +// SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. +func (nuo *NotificationUpdateOne) SetNillableCreateAuthor(i *int64) *NotificationUpdateOne { + if i != nil { + nuo.SetCreateAuthor(*i) + } + return nuo +} + +// AddCreateAuthor adds i to the "create_author" field. +func (nuo *NotificationUpdateOne) AddCreateAuthor(i int64) *NotificationUpdateOne { + nuo.mutation.AddCreateAuthor(i) + return nuo +} + +// ClearCreateAuthor clears the value of the "create_author" field. +func (nuo *NotificationUpdateOne) ClearCreateAuthor() *NotificationUpdateOne { + nuo.mutation.ClearCreateAuthor() + return nuo +} + +// SetUpdateAuthor sets the "update_author" field. +func (nuo *NotificationUpdateOne) SetUpdateAuthor(i int64) *NotificationUpdateOne { + nuo.mutation.ResetUpdateAuthor() + nuo.mutation.SetUpdateAuthor(i) + return nuo +} + +// SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. +func (nuo *NotificationUpdateOne) SetNillableUpdateAuthor(i *int64) *NotificationUpdateOne { + if i != nil { + nuo.SetUpdateAuthor(*i) + } + return nuo +} + +// AddUpdateAuthor adds i to the "update_author" field. +func (nuo *NotificationUpdateOne) AddUpdateAuthor(i int64) *NotificationUpdateOne { + nuo.mutation.AddUpdateAuthor(i) + return nuo +} + +// ClearUpdateAuthor clears the value of the "update_author" field. +func (nuo *NotificationUpdateOne) ClearUpdateAuthor() *NotificationUpdateOne { + nuo.mutation.ClearUpdateAuthor() + return nuo +} + +// SetUpdateTime sets the "update_time" field. +func (nuo *NotificationUpdateOne) SetUpdateTime(t time.Time) *NotificationUpdateOne { + nuo.mutation.SetUpdateTime(t) + return nuo +} + +// SetSubject sets the "subject" field. +func (nuo *NotificationUpdateOne) SetSubject(s string) *NotificationUpdateOne { + nuo.mutation.SetSubject(s) + return nuo +} + +// SetNillableSubject sets the "subject" field if the given value is not nil. +func (nuo *NotificationUpdateOne) SetNillableSubject(s *string) *NotificationUpdateOne { + if s != nil { + nuo.SetSubject(*s) + } + return nuo +} + +// SetContent sets the "content" field. +func (nuo *NotificationUpdateOne) SetContent(s string) *NotificationUpdateOne { + nuo.mutation.SetContent(s) + return nuo +} + +// SetNillableContent sets the "content" field if the given value is not nil. +func (nuo *NotificationUpdateOne) SetNillableContent(s *string) *NotificationUpdateOne { + if s != nil { + nuo.SetContent(*s) + } + return nuo +} + +// SetStatus sets the "status" field. +func (nuo *NotificationUpdateOne) SetStatus(i int8) *NotificationUpdateOne { + nuo.mutation.ResetStatus() + nuo.mutation.SetStatus(i) + return nuo +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (nuo *NotificationUpdateOne) SetNillableStatus(i *int8) *NotificationUpdateOne { + if i != nil { + nuo.SetStatus(*i) + } + return nuo +} + +// AddStatus adds i to the "status" field. +func (nuo *NotificationUpdateOne) AddStatus(i int8) *NotificationUpdateOne { + nuo.mutation.AddStatus(i) + return nuo +} + +// SetCategoryID sets the "category_id" field. +func (nuo *NotificationUpdateOne) SetCategoryID(i int64) *NotificationUpdateOne { + nuo.mutation.ResetCategoryID() + nuo.mutation.SetCategoryID(i) + return nuo +} + +// SetNillableCategoryID sets the "category_id" field if the given value is not nil. +func (nuo *NotificationUpdateOne) SetNillableCategoryID(i *int64) *NotificationUpdateOne { + if i != nil { + nuo.SetCategoryID(*i) + } + return nuo +} + +// AddCategoryID adds i to the "category_id" field. +func (nuo *NotificationUpdateOne) AddCategoryID(i int64) *NotificationUpdateOne { + nuo.mutation.AddCategoryID(i) + return nuo +} + +// Mutation returns the NotificationMutation object of the builder. +func (nuo *NotificationUpdateOne) Mutation() *NotificationMutation { + return nuo.mutation +} + +// Where appends a list predicates to the NotificationUpdate builder. +func (nuo *NotificationUpdateOne) Where(ps ...predicate.Notification) *NotificationUpdateOne { + nuo.mutation.Where(ps...) + return nuo +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (nuo *NotificationUpdateOne) Select(field string, fields ...string) *NotificationUpdateOne { + nuo.fields = append([]string{field}, fields...) + return nuo +} + +// Save executes the query and returns the updated Notification entity. +func (nuo *NotificationUpdateOne) Save(ctx context.Context) (*Notification, error) { + nuo.defaults() + return withHooks(ctx, nuo.sqlSave, nuo.mutation, nuo.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (nuo *NotificationUpdateOne) SaveX(ctx context.Context) *Notification { + node, err := nuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (nuo *NotificationUpdateOne) Exec(ctx context.Context) error { + _, err := nuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (nuo *NotificationUpdateOne) ExecX(ctx context.Context) { + if err := nuo.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (nuo *NotificationUpdateOne) defaults() { + if _, ok := nuo.mutation.UpdateTime(); !ok { + v := notification.UpdateDefaultUpdateTime() + nuo.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (nuo *NotificationUpdateOne) check() error { + if v, ok := nuo.mutation.CategoryID(); ok { + if err := notification.CategoryIDValidator(v); err != nil { + return &ValidationError{Name: "category_id", err: fmt.Errorf(`ent: validator failed for field "Notification.category_id": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (nuo *NotificationUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NotificationUpdateOne { + nuo.modifiers = append(nuo.modifiers, modifiers...) + return nuo +} + +func (nuo *NotificationUpdateOne) sqlSave(ctx context.Context) (_node *Notification, err error) { + if err := nuo.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(notification.Table, notification.Columns, sqlgraph.NewFieldSpec(notification.FieldID, field.TypeInt64)) + id, ok := nuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Notification.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := nuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, notification.FieldID) + for _, f := range fields { + if !notification.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != notification.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := nuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := nuo.mutation.CreateAuthor(); ok { + _spec.SetField(notification.FieldCreateAuthor, field.TypeInt64, value) + } + if value, ok := nuo.mutation.AddedCreateAuthor(); ok { + _spec.AddField(notification.FieldCreateAuthor, field.TypeInt64, value) + } + if nuo.mutation.CreateAuthorCleared() { + _spec.ClearField(notification.FieldCreateAuthor, field.TypeInt64) + } + if value, ok := nuo.mutation.UpdateAuthor(); ok { + _spec.SetField(notification.FieldUpdateAuthor, field.TypeInt64, value) + } + if value, ok := nuo.mutation.AddedUpdateAuthor(); ok { + _spec.AddField(notification.FieldUpdateAuthor, field.TypeInt64, value) + } + if nuo.mutation.UpdateAuthorCleared() { + _spec.ClearField(notification.FieldUpdateAuthor, field.TypeInt64) + } + if value, ok := nuo.mutation.UpdateTime(); ok { + _spec.SetField(notification.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := nuo.mutation.Subject(); ok { + _spec.SetField(notification.FieldSubject, field.TypeString, value) + } + if value, ok := nuo.mutation.Content(); ok { + _spec.SetField(notification.FieldContent, field.TypeString, value) + } + if value, ok := nuo.mutation.Status(); ok { + _spec.SetField(notification.FieldStatus, field.TypeInt8, value) + } + if value, ok := nuo.mutation.AddedStatus(); ok { + _spec.AddField(notification.FieldStatus, field.TypeInt8, value) + } + if value, ok := nuo.mutation.CategoryID(); ok { + _spec.SetField(notification.FieldCategoryID, field.TypeInt64, value) + } + if value, ok := nuo.mutation.AddedCategoryID(); ok { + _spec.AddField(notification.FieldCategoryID, field.TypeInt64, value) + } + _spec.AddModifiers(nuo.modifiers...) + _node = &Notification{config: nuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, nuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{notification.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + nuo.mutation.done = true + return _node, nil +} + +// SetNotification set the Notification +func (nu *NotificationUpdate) SetNotification(input *Notification, fields ...string) *NotificationUpdate { + m := nu.mutation + if len(fields) == 0 { + fields = notification.OmitColumns(notification.FieldID) + } + _ = m.SetFields(input, fields...) + return nu +} + +// SetNotificationWithZero set the Notification +func (nu *NotificationUpdate) SetNotificationWithZero(input *Notification, fields ...string) *NotificationUpdate { + m := nu.mutation + if len(fields) == 0 { + fields = notification.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return nu +} + +// SetNotification set the Notification +func (nuo *NotificationUpdateOne) SetNotification(input *Notification, fields ...string) *NotificationUpdateOne { + m := nuo.mutation + if len(fields) == 0 { + fields = notification.OmitColumns(notification.FieldID) + } + _ = m.SetFields(input, fields...) + return nuo +} + +// SetNotificationWithZero set the Notification +func (nuo *NotificationUpdateOne) SetNotificationWithZero(input *Notification, fields ...string) *NotificationUpdateOne { + m := nuo.mutation + if len(fields) == 0 { + fields = notification.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return nuo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (nuo *NotificationUpdateOne) Omit(fields ...string) *NotificationUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + nuo.fields = []string(nil) + for _, col := range notification.Columns { + if _, ok := omits[col]; !ok { + nuo.fields = append(nuo.fields, col) + } + } + return nuo +} diff --git a/internal/data/entity/ent/predicate/predicate.go b/internal/data/entity/ent/predicate/predicate.go index c2bd1e13..acf692b3 100644 --- a/internal/data/entity/ent/predicate/predicate.go +++ b/internal/data/entity/ent/predicate/predicate.go @@ -12,6 +12,9 @@ type CasbinRule func(*sql.Selector) // Department is the predicate function for department builders. type Department func(*sql.Selector) +// Notification is the predicate function for notification builders. +type Notification func(*sql.Selector) + // Permission is the predicate function for permission builders. type Permission func(*sql.Selector) diff --git a/internal/data/entity/ent/role.go b/internal/data/entity/ent/role.go index b6a0dff4..5703d67b 100644 --- a/internal/data/entity/ent/role.go +++ b/internal/data/entity/ent/role.go @@ -22,17 +22,17 @@ type Role struct { CreateTime time.Time `json:"create_time,omitempty"` // update_time.field.comment UpdateTime time.Time `json:"update_time,omitempty"` - // role.field.keyword + // entity.role.field.keyword Keyword string `json:"keyword,omitempty"` - // role.field.name + // entity.role.field.name Name string `json:"name,omitempty"` - // role.field.description + // entity.role.field.description Description string `json:"description,omitempty"` - // role.field.type + // entity.role.field.type Type int8 `json:"type,omitempty"` - // role.field.sequence + // entity.role.field.sequence Sequence int `json:"sequence,omitempty"` - // role.field.status + // entity.role.field.status Status int8 `json:"status,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the RoleQuery when eager-loading is set. diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index 0194d480..027fd4fc 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -5,6 +5,7 @@ package runtime import ( "origadmin/application/admin/internal/data/entity/ent/casbinrule" "origadmin/application/admin/internal/data/entity/ent/department" + "origadmin/application/admin/internal/data/entity/ent/notification" "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/data/entity/ent/permissionresource" "origadmin/application/admin/internal/data/entity/ent/position" @@ -113,6 +114,57 @@ func init() { department.DefaultID = departmentDescID.Default.(func() int64) // department.IDValidator is a validator for the "id" field. It is called by the builders before save. department.IDValidator = departmentDescID.Validators[0].(func(int64) error) + notificationMixin := schema.Notification{}.Mixin() + notificationMixinFields0 := notificationMixin[0].Fields() + _ = notificationMixinFields0 + notificationMixinFields1 := notificationMixin[1].Fields() + _ = notificationMixinFields1 + notificationMixinFields2 := notificationMixin[2].Fields() + _ = notificationMixinFields2 + notificationMixinFields3 := notificationMixin[3].Fields() + _ = notificationMixinFields3 + notificationFields := schema.Notification{}.Fields() + _ = notificationFields + // notificationDescCreateAuthor is the schema descriptor for create_author field. + notificationDescCreateAuthor := notificationMixinFields1[0].Descriptor() + // notification.DefaultCreateAuthor holds the default value on creation for the create_author field. + notification.DefaultCreateAuthor = notificationDescCreateAuthor.Default.(int64) + // notificationDescUpdateAuthor is the schema descriptor for update_author field. + notificationDescUpdateAuthor := notificationMixinFields1[1].Descriptor() + // notification.DefaultUpdateAuthor holds the default value on creation for the update_author field. + notification.DefaultUpdateAuthor = notificationDescUpdateAuthor.Default.(int64) + // notificationDescCreateTime is the schema descriptor for create_time field. + notificationDescCreateTime := notificationMixinFields2[0].Descriptor() + // notification.DefaultCreateTime holds the default value on creation for the create_time field. + notification.DefaultCreateTime = notificationDescCreateTime.Default.(func() time.Time) + // notificationDescUpdateTime is the schema descriptor for update_time field. + notificationDescUpdateTime := notificationMixinFields3[0].Descriptor() + // notification.DefaultUpdateTime holds the default value on creation for the update_time field. + notification.DefaultUpdateTime = notificationDescUpdateTime.Default.(func() time.Time) + // notification.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + notification.UpdateDefaultUpdateTime = notificationDescUpdateTime.UpdateDefault.(func() time.Time) + // notificationDescSubject is the schema descriptor for subject field. + notificationDescSubject := notificationFields[0].Descriptor() + // notification.DefaultSubject holds the default value on creation for the subject field. + notification.DefaultSubject = notificationDescSubject.Default.(string) + // notificationDescContent is the schema descriptor for content field. + notificationDescContent := notificationFields[1].Descriptor() + // notification.DefaultContent holds the default value on creation for the content field. + notification.DefaultContent = notificationDescContent.Default.(string) + // notificationDescStatus is the schema descriptor for status field. + notificationDescStatus := notificationFields[2].Descriptor() + // notification.DefaultStatus holds the default value on creation for the status field. + notification.DefaultStatus = notificationDescStatus.Default.(int8) + // notificationDescCategoryID is the schema descriptor for category_id field. + notificationDescCategoryID := notificationFields[3].Descriptor() + // notification.CategoryIDValidator is a validator for the "category_id" field. It is called by the builders before save. + notification.CategoryIDValidator = notificationDescCategoryID.Validators[0].(func(int64) error) + // notificationDescID is the schema descriptor for id field. + notificationDescID := notificationMixinFields0[0].Descriptor() + // notification.DefaultID holds the default value on creation for the id field. + notification.DefaultID = notificationDescID.Default.(func() int64) + // notification.IDValidator is a validator for the "id" field. It is called by the builders before save. + notification.IDValidator = notificationDescID.Validators[0].(func(int64) error) permissionMixin := schema.Permission{}.Mixin() permissionMixinFields0 := permissionMixin[0].Fields() _ = permissionMixinFields0 @@ -569,5 +621,6 @@ func init() { } const ( - Version = "(devel)" // Version of ent codegen. + Version = "v0.14.4" // Version of ent codegen. + Sum = "h1:/DhDraSLXIkBhyiVoJeSshr4ZYi7femzhj6/TckzZuI=" // Sum of ent codegen. ) diff --git a/internal/data/entity/ent/schema/notification.go b/internal/data/entity/ent/schema/notification.go new file mode 100644 index 00000000..757de96d --- /dev/null +++ b/internal/data/entity/ent/schema/notification.go @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package schema implements the functions, types, and interfaces for the module. +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/field" + + "origadmin/application/admin/helpers/ent/mixin" + "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/data/entity/ent/schema/types" +) + +// Notification holds the schema definition for the Notification entity. +type Notification struct { + ent.Schema +} + +// Fields of the Notification. +func (Notification) Fields() []ent.Field { + return []ent.Field{ + field.String("subject"). + Default(""). + Comment(i18n.Text("entity.notification.field.subject")), + field.String("content"). + Default(""). + Comment(i18n.Text("entity.notification.field.content")), + field.Int8("status"). + Default(types.Unknown). + Comment(i18n.Text("entity.notification.field.status")), + mixin.FK("category_id", "entity.notification.field.category_id"), + } +} + +// Annotations of the Notification. +func (Notification) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("msg_notifications"), + entsql.WithComments(true), + schema.Comment(i18n.Text("entity.notification.table.comment")), + } +} + +// Mixin of the Notification. +func (Notification) Mixin() []ent.Mixin { + return mixin.AuditModelMixin +} diff --git a/internal/data/entity/ent/schema/role.go b/internal/data/entity/ent/schema/role.go index 377ba28e..10642b69 100644 --- a/internal/data/entity/ent/schema/role.go +++ b/internal/data/entity/ent/schema/role.go @@ -35,24 +35,24 @@ func (Role) Fields() []ent.Field { field.String("keyword"). MaxLen(32). Unique(). - Comment("role.field.keyword"), // keyword of role (unique) + Comment("entity.role.field.keyword"), // keyword of role (unique) field.String("name"). MaxLen(128). Default(""). - Comment("role.field.name"), // Display name of role + Comment("entity.role.field.name"), // Display name of role field.String("description"). MaxLen(1024). Default(""). - Comment("role.field.description"), // Details about role + Comment("entity.role.field.description"), // Details about role field.Int8("type"). Default(RoleTypeUser). - Comment("role.field.type"), //("Role type: 1 - System role 2 - User role 3 - Department role"), + Comment("entity.role.field.type"), //("Role type: 1 - System role 2 - User role 3 - Department role"), field.Int("sequence"). Default(0). - Comment("role.field.sequence"), // Sequence for sorting + Comment("entity.role.field.sequence"), // Sequence for sorting field.Int8("status"). Default(types.Active). - Comment("role.field.status"), + Comment("entity.role.field.status"), } } diff --git a/internal/data/entity/ent/schema/types/constants.go b/internal/data/entity/ent/schema/types/constants.go index ac2281b5..501e16dc 100644 --- a/internal/data/entity/ent/schema/types/constants.go +++ b/internal/data/entity/ent/schema/types/constants.go @@ -10,6 +10,7 @@ const ( Enabled = 1 Disabled = 2 + Unknown = Invalid Active = Enabled Inactive = Disabled Frozen = Disabled diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 4365b497..66ff5335 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -54,7 +54,7 @@ func (User) Fields() []ent.Field { field.String("avatar"). MaxLen(256). Default(""). - Comment("user.field.avatar"), // Avatar display avatar of user + Comment("entity.user.field.avatar"), // Avatar display avatar of user field.String("name"). MaxLen(64). Default(""). @@ -97,7 +97,7 @@ func (User) Fields() []ent.Field { Comment(i18n.Text("entity.user.field.status")), field.Bool("is_system"). Default(false). - Comment("user.field.is_system"), // Whether the system is built-in (the built-in user cannot be deleted, but can be disabled) + Comment("entity.user.field.is_system"), // Whether the system is built-in (the built-in user cannot be deleted, but can be disabled) field.String("last_login_ip"). MaxLen(32). Default(""). diff --git a/internal/data/entity/ent/tx.go b/internal/data/entity/ent/tx.go index 3c91384b..e496ec72 100644 --- a/internal/data/entity/ent/tx.go +++ b/internal/data/entity/ent/tx.go @@ -16,6 +16,8 @@ type Tx struct { CasbinRule *CasbinRuleClient // Department is the client for interacting with the Department builders. Department *DepartmentClient + // Notification is the client for interacting with the Notification builders. + Notification *NotificationClient // Permission is the client for interacting with the Permission builders. Permission *PermissionClient // PermissionResource is the client for interacting with the PermissionResource builders. @@ -171,6 +173,7 @@ func (tx *Tx) Client() *Client { func (tx *Tx) init() { tx.CasbinRule = NewCasbinRuleClient(tx.config) tx.Department = NewDepartmentClient(tx.config) + tx.Notification = NewNotificationClient(tx.config) tx.Permission = NewPermissionClient(tx.config) tx.PermissionResource = NewPermissionResourceClient(tx.config) tx.Position = NewPositionClient(tx.config) diff --git a/internal/data/entity/ent/user.go b/internal/data/entity/ent/user.go index a8a0a124..436bdf10 100644 --- a/internal/data/entity/ent/user.go +++ b/internal/data/entity/ent/user.go @@ -36,7 +36,7 @@ type User struct { Username string `json:"username,omitempty"` // entity.user.field.nickname Nickname string `json:"nickname,omitempty"` - // user.field.avatar + // entity.user.field.avatar Avatar string `json:"avatar,omitempty"` // entity.user.field.nickname Name string `json:"name,omitempty"` @@ -60,7 +60,7 @@ type User struct { Token string `json:"token,omitempty"` // entity.user.field.status Status int8 `json:"status,omitempty"` - // user.field.is_system + // entity.user.field.is_system IsSystem bool `json:"is_system,omitempty"` // entity.user.field.last_login_ip LastLoginIP string `json:"last_login_ip,omitempty"` From 7f7188ac65d957ccca775aef1815e5ef1663cb46 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 24 Jun 2025 15:19:16 +0800 Subject: [PATCH 050/158] refactor(api): split error types into separate proto files - Move AuthErrorReason to auth_error.proto - Create system_error.proto for SystemErrorReason - Update error.proto to only include generic ErrorReason - Remove redundant error handling code - Adjust package and class names for better organization --- api/v1/proto/types/auth_error.proto | 18 ++ api/v1/proto/types/error.proto | 33 +-- api/v1/proto/types/system_error.proto | 35 +++ api/v1/services/types/error.pb.go | 172 +++------------ api/v1/services/types/error_errors.pb.go | 256 +--------------------- resources/docs/openapi/openapi.yaml | 261 +++++++++++++++++++++++ 6 files changed, 351 insertions(+), 424 deletions(-) create mode 100644 api/v1/proto/types/auth_error.proto create mode 100644 api/v1/proto/types/system_error.proto diff --git a/api/v1/proto/types/auth_error.proto b/api/v1/proto/types/auth_error.proto new file mode 100644 index 00000000..1845b3b1 --- /dev/null +++ b/api/v1/proto/types/auth_error.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package api.v1.services.types; + +import "errors/errors.proto"; + +option go_package = "origadmin/application/admin/api/v1/services/types;types"; +option java_multiple_files = true; +option java_outer_classname = "APIServiceTypeAuthErrorProto"; +option java_package = "com.origadmin.api.v1.services.types"; +option objc_class_prefix = "APIServiceType"; + +enum AuthErrorReason { + option (errors.default_code) = 500; + AUTH_ERROR_REASON_UNSPECIFIED = 0; + AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND = 2001 [(errors.code) = 404]; + AUTH_ERROR_REASON_TOKEN_EXPIRED = 2002 [(errors.code) = 401]; +} diff --git a/api/v1/proto/types/error.proto b/api/v1/proto/types/error.proto index b30a922d..7f362abd 100644 --- a/api/v1/proto/types/error.proto +++ b/api/v1/proto/types/error.proto @@ -6,37 +6,12 @@ import "errors/errors.proto"; option go_package = "origadmin/application/admin/api/v1/services/types;types"; option java_multiple_files = true; -option java_outer_classname = "APIServiceTypeSystemProto"; +option java_outer_classname = "APIServiceTypeErrorProto"; option java_package = "com.origadmin.api.v1.services.types"; option objc_class_prefix = "APIServiceType"; -enum SystemErrorReason { +enum ErrorReason { option (errors.default_code) = 500; - SYSTEM_ERROR_REASON_UNSPECIFIED = 0; - SYSTEM_ERROR_REASON_USER_NOT_FOUND = 2001 [(errors.code) = 404]; - SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS = 2002 [(errors.code) = 409]; - SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN = 2003 [(errors.code) = 401]; - SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT = 2004 [(errors.code) = 401]; - SYSTEM_ERROR_REASON_TOKEN_EXPIRED = 2005 [(errors.code) = 401]; - SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND = 2006 [(errors.code) = 401]; - SYSTEM_ERROR_REASON_INVALID_TOKEN = 2007 [(errors.code) = 401]; - SYSTEM_ERROR_REASON_INVALID_CLAIMS = 2008 [(errors.code) = 401]; - SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION = 2009 [(errors.code) = 401]; - SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION = 2010 [(errors.code) = 403]; - SYSTEM_ERROR_REASON_INVALID_REQUEST = 2011 [(errors.code) = 400]; - SYSTEM_ERROR_REASON_INVALID_RESPONSE = 2012 [(errors.code) = 500]; - SYSTEM_ERROR_REASON_INVALID_SERVER = 2013 [(errors.code) = 500]; - - SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND = 1001 [(errors.code) = 404]; - SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID = 1002 [(errors.code) = 400]; - SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE = 1003 [(errors.code) = 400]; - SYSTEM_ERROR_REASON_INVALID_USERNAME = 1005 [(errors.code) = 400]; - SYSTEM_ERROR_REASON_INVALID_PASSWORD = 1006 [(errors.code) = 400]; -} - -enum AuthErrorReason { - option (errors.default_code) = 500; - AUTH_ERROR_REASON_UNSPECIFIED = 0; - AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND = 2001 [(errors.code) = 404]; - AUTH_ERROR_REASON_TOKEN_EXPIRED = 2002 [(errors.code) = 401]; + ERROR_REASON_UNSPECIFIED = 0; + ERROR_REASON_CUSTOMIZED = 1000; } diff --git a/api/v1/proto/types/system_error.proto b/api/v1/proto/types/system_error.proto new file mode 100644 index 00000000..86535d2b --- /dev/null +++ b/api/v1/proto/types/system_error.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; + +package api.v1.services.types; + +import "errors/errors.proto"; + +option go_package = "origadmin/application/admin/api/v1/services/types;types"; +option java_multiple_files = true; +option java_outer_classname = "APIServiceTypeSystemErrorProto"; +option java_package = "com.origadmin.api.v1.services.types"; +option objc_class_prefix = "APIServiceType"; + +enum SystemErrorReason { + option (errors.default_code) = 500; + SYSTEM_ERROR_REASON_UNSPECIFIED = 0; + SYSTEM_ERROR_REASON_USER_NOT_FOUND = 2001 [(errors.code) = 404]; + SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS = 2002 [(errors.code) = 409]; + SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN = 2003 [(errors.code) = 401]; + SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT = 2004 [(errors.code) = 401]; + SYSTEM_ERROR_REASON_TOKEN_EXPIRED = 2005 [(errors.code) = 401]; + SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND = 2006 [(errors.code) = 401]; + SYSTEM_ERROR_REASON_INVALID_TOKEN = 2007 [(errors.code) = 401]; + SYSTEM_ERROR_REASON_INVALID_CLAIMS = 2008 [(errors.code) = 401]; + SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION = 2009 [(errors.code) = 401]; + SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION = 2010 [(errors.code) = 403]; + SYSTEM_ERROR_REASON_INVALID_REQUEST = 2011 [(errors.code) = 400]; + SYSTEM_ERROR_REASON_INVALID_RESPONSE = 2012 [(errors.code) = 500]; + SYSTEM_ERROR_REASON_INVALID_SERVER = 2013 [(errors.code) = 500]; + + SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND = 3001 [(errors.code) = 404]; + SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID = 3002 [(errors.code) = 400]; + SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE = 3003 [(errors.code) = 400]; + SYSTEM_ERROR_REASON_INVALID_USERNAME = 3005 [(errors.code) = 400]; + SYSTEM_ERROR_REASON_INVALID_PASSWORD = 3006 [(errors.code) = 400]; +} diff --git a/api/v1/services/types/error.pb.go b/api/v1/services/types/error.pb.go index da95d5a6..e541222e 100644 --- a/api/v1/services/types/error.pb.go +++ b/api/v1/services/types/error.pb.go @@ -22,181 +22,60 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type SystemErrorReason int32 +type ErrorReason int32 const ( - SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED SystemErrorReason = 0 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND SystemErrorReason = 2001 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS SystemErrorReason = 2002 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN SystemErrorReason = 2003 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT SystemErrorReason = 2004 - SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED SystemErrorReason = 2005 - SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND SystemErrorReason = 2006 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN SystemErrorReason = 2007 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS SystemErrorReason = 2008 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION SystemErrorReason = 2009 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION SystemErrorReason = 2010 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST SystemErrorReason = 2011 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE SystemErrorReason = 2012 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER SystemErrorReason = 2013 - SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND SystemErrorReason = 1001 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID SystemErrorReason = 1002 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE SystemErrorReason = 1003 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME SystemErrorReason = 1005 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD SystemErrorReason = 1006 + ErrorReason_ERROR_REASON_UNSPECIFIED ErrorReason = 0 + ErrorReason_ERROR_REASON_CUSTOMIZED ErrorReason = 1000 ) -// Enum value maps for SystemErrorReason. +// Enum value maps for ErrorReason. var ( - SystemErrorReason_name = map[int32]string{ - 0: "SYSTEM_ERROR_REASON_UNSPECIFIED", - 2001: "SYSTEM_ERROR_REASON_USER_NOT_FOUND", - 2002: "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS", - 2003: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN", - 2004: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT", - 2005: "SYSTEM_ERROR_REASON_TOKEN_EXPIRED", - 2006: "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND", - 2007: "SYSTEM_ERROR_REASON_INVALID_TOKEN", - 2008: "SYSTEM_ERROR_REASON_INVALID_CLAIMS", - 2009: "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION", - 2010: "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION", - 2011: "SYSTEM_ERROR_REASON_INVALID_REQUEST", - 2012: "SYSTEM_ERROR_REASON_INVALID_RESPONSE", - 2013: "SYSTEM_ERROR_REASON_INVALID_SERVER", - 1001: "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND", - 1002: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID", - 1003: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE", - 1005: "SYSTEM_ERROR_REASON_INVALID_USERNAME", - 1006: "SYSTEM_ERROR_REASON_INVALID_PASSWORD", + ErrorReason_name = map[int32]string{ + 0: "ERROR_REASON_UNSPECIFIED", + 1000: "ERROR_REASON_CUSTOMIZED", } - SystemErrorReason_value = map[string]int32{ - "SYSTEM_ERROR_REASON_UNSPECIFIED": 0, - "SYSTEM_ERROR_REASON_USER_NOT_FOUND": 2001, - "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS": 2002, - "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN": 2003, - "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT": 2004, - "SYSTEM_ERROR_REASON_TOKEN_EXPIRED": 2005, - "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND": 2006, - "SYSTEM_ERROR_REASON_INVALID_TOKEN": 2007, - "SYSTEM_ERROR_REASON_INVALID_CLAIMS": 2008, - "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION": 2009, - "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION": 2010, - "SYSTEM_ERROR_REASON_INVALID_REQUEST": 2011, - "SYSTEM_ERROR_REASON_INVALID_RESPONSE": 2012, - "SYSTEM_ERROR_REASON_INVALID_SERVER": 2013, - "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND": 1001, - "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID": 1002, - "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE": 1003, - "SYSTEM_ERROR_REASON_INVALID_USERNAME": 1005, - "SYSTEM_ERROR_REASON_INVALID_PASSWORD": 1006, + ErrorReason_value = map[string]int32{ + "ERROR_REASON_UNSPECIFIED": 0, + "ERROR_REASON_CUSTOMIZED": 1000, } ) -func (x SystemErrorReason) Enum() *SystemErrorReason { - p := new(SystemErrorReason) +func (x ErrorReason) Enum() *ErrorReason { + p := new(ErrorReason) *p = x return p } -func (x SystemErrorReason) String() string { +func (x ErrorReason) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (SystemErrorReason) Descriptor() protoreflect.EnumDescriptor { +func (ErrorReason) Descriptor() protoreflect.EnumDescriptor { return file_types_error_proto_enumTypes[0].Descriptor() } -func (SystemErrorReason) Type() protoreflect.EnumType { +func (ErrorReason) Type() protoreflect.EnumType { return &file_types_error_proto_enumTypes[0] } -func (x SystemErrorReason) Number() protoreflect.EnumNumber { +func (x ErrorReason) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use SystemErrorReason.Descriptor instead. -func (SystemErrorReason) EnumDescriptor() ([]byte, []int) { +// Deprecated: Use ErrorReason.Descriptor instead. +func (ErrorReason) EnumDescriptor() ([]byte, []int) { return file_types_error_proto_rawDescGZIP(), []int{0} } -type AuthErrorReason int32 - -const ( - AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED AuthErrorReason = 0 - AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND AuthErrorReason = 2001 - AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED AuthErrorReason = 2002 -) - -// Enum value maps for AuthErrorReason. -var ( - AuthErrorReason_name = map[int32]string{ - 0: "AUTH_ERROR_REASON_UNSPECIFIED", - 2001: "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND", - 2002: "AUTH_ERROR_REASON_TOKEN_EXPIRED", - } - AuthErrorReason_value = map[string]int32{ - "AUTH_ERROR_REASON_UNSPECIFIED": 0, - "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND": 2001, - "AUTH_ERROR_REASON_TOKEN_EXPIRED": 2002, - } -) - -func (x AuthErrorReason) Enum() *AuthErrorReason { - p := new(AuthErrorReason) - *p = x - return p -} - -func (x AuthErrorReason) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AuthErrorReason) Descriptor() protoreflect.EnumDescriptor { - return file_types_error_proto_enumTypes[1].Descriptor() -} - -func (AuthErrorReason) Type() protoreflect.EnumType { - return &file_types_error_proto_enumTypes[1] -} - -func (x AuthErrorReason) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AuthErrorReason.Descriptor instead. -func (AuthErrorReason) EnumDescriptor() ([]byte, []int) { - return file_types_error_proto_rawDescGZIP(), []int{1} -} - var File_types_error_proto protoreflect.FileDescriptor const file_types_error_proto_rawDesc = "" + "\n" + - "\x11types/error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*\xbf\a\n" + - "\x11SystemErrorReason\x12#\n" + - "\x1fSYSTEM_ERROR_REASON_UNSPECIFIED\x10\x00\x12-\n" + - "\"SYSTEM_ERROR_REASON_USER_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x122\n" + - "'SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS\x10\xd2\x0f\x1a\x04\xa8E\x99\x03\x121\n" + - "&SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN\x10\xd3\x0f\x1a\x04\xa8E\x91\x03\x122\n" + - "'SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT\x10\xd4\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + - "!SYSTEM_ERROR_REASON_TOKEN_EXPIRED\x10\xd5\x0f\x1a\x04\xa8E\x91\x03\x12.\n" + - "#SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND\x10\xd6\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + - "!SYSTEM_ERROR_REASON_INVALID_TOKEN\x10\xd7\x0f\x1a\x04\xa8E\x91\x03\x12-\n" + - "\"SYSTEM_ERROR_REASON_INVALID_CLAIMS\x10\xd8\x0f\x1a\x04\xa8E\x91\x03\x125\n" + - "*SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION\x10\xd9\x0f\x1a\x04\xa8E\x91\x03\x124\n" + - ")SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION\x10\xda\x0f\x1a\x04\xa8E\x93\x03\x12.\n" + - "#SYSTEM_ERROR_REASON_INVALID_REQUEST\x10\xdb\x0f\x1a\x04\xa8E\x90\x03\x12/\n" + - "$SYSTEM_ERROR_REASON_INVALID_RESPONSE\x10\xdc\x0f\x1a\x04\xa8E\xf4\x03\x12-\n" + - "\"SYSTEM_ERROR_REASON_INVALID_SERVER\x10\xdd\x0f\x1a\x04\xa8E\xf4\x03\x123\n" + - "(SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND\x10\xe9\a\x1a\x04\xa8E\x94\x03\x121\n" + - "&SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID\x10\xea\a\x1a\x04\xa8E\x90\x03\x123\n" + - "(SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE\x10\xeb\a\x1a\x04\xa8E\x90\x03\x12/\n" + - "$SYSTEM_ERROR_REASON_INVALID_USERNAME\x10\xed\a\x1a\x04\xa8E\x90\x03\x12/\n" + - "$SYSTEM_ERROR_REASON_INVALID_PASSWORD\x10\xee\a\x1a\x04\xa8E\x90\x03\x1a\x04\xa0E\xf4\x03*\x96\x01\n" + - "\x0fAuthErrorReason\x12!\n" + - "\x1dAUTH_ERROR_REASON_UNSPECIFIED\x10\x00\x12.\n" + - "#AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x12*\n" + - "\x1fAUTH_ERROR_REASON_TOKEN_EXPIRED\x10\xd2\x0f\x1a\x04\xa8E\x91\x03\x1a\x04\xa0E\xf4\x03B\xd8\x01\n" + + "\x11types/error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*O\n" + + "\vErrorReason\x12\x1c\n" + + "\x18ERROR_REASON_UNSPECIFIED\x10\x00\x12\x1c\n" + + "\x17ERROR_REASON_CUSTOMIZED\x10\xe8\a\x1a\x04\xa0E\xf4\x03B\xd8\x01\n" + "\x19com.api.v1.services.typesB\n" + "ErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" @@ -212,10 +91,9 @@ func file_types_error_proto_rawDescGZIP() []byte { return file_types_error_proto_rawDescData } -var file_types_error_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_types_error_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_types_error_proto_goTypes = []any{ - (SystemErrorReason)(0), // 0: api.v1.services.types.SystemErrorReason - (AuthErrorReason)(0), // 1: api.v1.services.types.AuthErrorReason + (ErrorReason)(0), // 0: api.v1.services.types.ErrorReason } var file_types_error_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -235,7 +113,7 @@ func file_types_error_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_error_proto_rawDesc), len(file_types_error_proto_rawDesc)), - NumEnums: 2, + NumEnums: 1, NumMessages: 0, NumExtensions: 0, NumServices: 0, diff --git a/api/v1/services/types/error_errors.pb.go b/api/v1/services/types/error_errors.pb.go index f18742c9..ff776353 100644 --- a/api/v1/services/types/error_errors.pb.go +++ b/api/v1/services/types/error_errors.pb.go @@ -11,266 +11,26 @@ import ( // is compatible with the kratos package it is being compiled against. const _ = errors.SupportPackageIsVersion1 -func IsSystemErrorReasonUnspecified(err error) bool { +func IsErrorReasonUnspecified(err error) bool { if err == nil { return false } e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 + return e.Reason == ErrorReason_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 } -func ErrorSystemErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { - return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) +func ErrorErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { + return errors.New(500, ErrorReason_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) } -func IsSystemErrorReasonUserNotFound(err error) bool { +func IsErrorReasonCustomized(err error) bool { if err == nil { return false } e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String() && e.Code == 404 + return e.Reason == ErrorReason_ERROR_REASON_CUSTOMIZED.String() && e.Code == 500 } -func ErrorSystemErrorReasonUserNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserAlreadyExists(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String() && e.Code == 409 -} - -func ErrorSystemErrorReasonUserAlreadyExists(format string, args ...interface{}) *errors.Error { - return errors.New(409, SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserNotLoggedIn(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonUserNotLoggedIn(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserNotLoggedOut(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonUserNotLoggedOut(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonTokenExpired(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonTokenNotFound(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonTokenNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidToken(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonInvalidToken(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidClaims(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonInvalidClaims(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidAuthentication(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonInvalidAuthentication(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidAuthorization(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String() && e.Code == 403 -} - -func ErrorSystemErrorReasonInvalidAuthorization(format string, args ...interface{}) *errors.Error { - return errors.New(403, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidRequest(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidRequest(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidResponse(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String() && e.Code == 500 -} - -func ErrorSystemErrorReasonInvalidResponse(format string, args ...interface{}) *errors.Error { - return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidServer(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String() && e.Code == 500 -} - -func ErrorSystemErrorReasonInvalidServer(format string, args ...interface{}) *errors.Error { - return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonCaptchaIdNotFound(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String() && e.Code == 404 -} - -func ErrorSystemErrorReasonCaptchaIdNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidCaptchaId(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidCaptchaId(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidCaptchaCode(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidCaptchaCode(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidUsername(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidUsername(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidPassword(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidPassword(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), fmt.Sprintf(format, args...)) -} - -func IsAuthErrorReasonUnspecified(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 -} - -func ErrorAuthErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { - return errors.New(500, AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) -} - -func IsAuthErrorReasonCaptchaNotFound(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String() && e.Code == 404 -} - -func ErrorAuthErrorReasonCaptchaNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(404, AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsAuthErrorReasonTokenExpired(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 -} - -func ErrorAuthErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { - return errors.New(401, AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) +func ErrorErrorReasonCustomized(format string, args ...interface{}) *errors.Error { + return errors.New(500, ErrorReason_ERROR_REASON_CUSTOMIZED.String(), fmt.Sprintf(format, args...)) } diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 3d0be376..92fb0505 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -702,6 +702,220 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' + /message/personal/logout: + post: + tags: + - PersonalService + description: PersonalLogout Personal user logs out + operationId: PersonalService_PersonalLogout + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/google.protobuf.Any' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.message.PersonalLogoutResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /message/personal/password: + put: + tags: + - PersonalService + description: UpdatePersonalProfilePassword The user changes the password + operationId: PersonalService_UpdatePersonalPassword + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/google.protobuf.Any' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.message.UpdatePersonalPasswordResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /message/personal/profile: + get: + tags: + - PersonalService + description: GetPersonalProfile Update the personal user information + operationId: PersonalService_GetPersonalProfile + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.message.GetPersonalProfileResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + put: + tags: + - PersonalService + description: UpdatePersonalProfile Update the personal user information + operationId: PersonalService_UpdatePersonalProfile + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/google.protobuf.Any' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.message.UpdatePersonalProfileResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /message/personal/resources: + get: + tags: + - PersonalService + description: ListPersonalResources List the personal user's menu + operationId: PersonalService_ListPersonalResources + parameters: + - name: id + in: query + description: The parent resource id, for example, "shelves/shelf1". + schema: + type: string + - name: current + in: query + description: The current page number. + schema: + type: integer + format: int32 + - name: page_size + in: query + description: The maximum number of items to return. + schema: + type: integer + format: int32 + - name: page_token + in: query + description: The next_page_token value returned from a previous List request, if any. + schema: + type: string + - name: no_paging + in: query + description: The no_paging is used to disable pagination. + schema: + type: boolean + - name: only_count + in: query + description: The only_count is the query parameter for set only to query the total number + schema: + type: boolean + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.message.ListPersonalResourcesResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /message/personal/roles: + get: + tags: + - PersonalService + description: ListPersonalResources List the personal user's menu + operationId: PersonalService_ListPersonalRoles + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.message.ListPersonalRolesResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /message/personal/setting: + put: + tags: + - PersonalService + description: UpdatePersonalSetting User settings are saved + operationId: PersonalService_UpdatePersonalSetting + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/google.protobuf.Any' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.message.UpdatePersonalSettingResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /message/personal/token/refresh: + post: + tags: + - PersonalService + description: RefreshPersonalToken Refresh the personal user's token + operationId: PersonalService_RefreshPersonalToken + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/google.protobuf.Any' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.message.RefreshPersonalTokenResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' /register: post: tags: @@ -2504,6 +2718,51 @@ components: properties: modified_date: type: string + api.v1.services.message.GetPersonalProfileResponse: + type: object + properties: + user: + $ref: '#/components/schemas/api.v1.services.types.User' + api.v1.services.message.ListPersonalResourcesResponse: + type: object + properties: + total_size: + type: string + description: The total number of items in the list. + resources: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.Resource' + description: list of resources + next_page_token: + type: string + description: "Token to retrieve the next page of results, or empty if there are no\r\n more results in the list." + api.v1.services.message.ListPersonalRolesResponse: + type: object + properties: + roles: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.Role' + api.v1.services.message.PersonalLogoutResponse: + type: object + properties: + success: + type: boolean + api.v1.services.message.RefreshPersonalTokenResponse: + type: object + properties: + token: + type: string + api.v1.services.message.UpdatePersonalPasswordResponse: + type: object + properties: {} + api.v1.services.message.UpdatePersonalProfileResponse: + type: object + properties: {} + api.v1.services.message.UpdatePersonalSettingResponse: + type: object + properties: {} api.v1.services.system.CreateDepartmentResponse: type: object properties: @@ -3404,6 +3663,8 @@ tags: description: The login service definition. - name: PersonalService description: PersonalService Personal user service + - name: PersonalService + description: PersonalService Personal user service - name: PositionService description: The login service definition. - name: ResourceService From a205e20c59c6180154a65faa394251602cdb5c5d Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 24 Jun 2025 15:24:31 +0800 Subject: [PATCH 051/158] feat(api): add new error types and message structure - Add auth_error.proto, message.proto, and system_error.proto definitions - Generate corresponding Go code for the new types - Include validation code for the new message structure - Add error handling functions for specific error reasons --- api/v1/services/types/auth_error.pb.go | 131 ++++++++++ .../services/types/auth_error.pb.validate.go | 36 +++ api/v1/services/types/auth_error_errors.pb.go | 48 ++++ api/v1/services/types/message.pb.go | 126 +++++++++ api/v1/services/types/message.pb.validate.go | 136 ++++++++++ api/v1/services/types/system_error.pb.go | 195 ++++++++++++++ .../types/system_error.pb.validate.go | 36 +++ .../services/types/system_error_errors.pb.go | 240 ++++++++++++++++++ 8 files changed, 948 insertions(+) create mode 100644 api/v1/services/types/auth_error.pb.go create mode 100644 api/v1/services/types/auth_error.pb.validate.go create mode 100644 api/v1/services/types/auth_error_errors.pb.go create mode 100644 api/v1/services/types/message.pb.go create mode 100644 api/v1/services/types/message.pb.validate.go create mode 100644 api/v1/services/types/system_error.pb.go create mode 100644 api/v1/services/types/system_error.pb.validate.go create mode 100644 api/v1/services/types/system_error_errors.pb.go diff --git a/api/v1/services/types/auth_error.pb.go b/api/v1/services/types/auth_error.pb.go new file mode 100644 index 00000000..fd5e0795 --- /dev/null +++ b/api/v1/services/types/auth_error.pb.go @@ -0,0 +1,131 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc (unknown) +// source: types/auth_error.proto + +package types + +import ( + _ "github.com/go-kratos/kratos/v2/errors" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type AuthErrorReason int32 + +const ( + AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED AuthErrorReason = 0 + AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND AuthErrorReason = 2001 + AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED AuthErrorReason = 2002 +) + +// Enum value maps for AuthErrorReason. +var ( + AuthErrorReason_name = map[int32]string{ + 0: "AUTH_ERROR_REASON_UNSPECIFIED", + 2001: "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND", + 2002: "AUTH_ERROR_REASON_TOKEN_EXPIRED", + } + AuthErrorReason_value = map[string]int32{ + "AUTH_ERROR_REASON_UNSPECIFIED": 0, + "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND": 2001, + "AUTH_ERROR_REASON_TOKEN_EXPIRED": 2002, + } +) + +func (x AuthErrorReason) Enum() *AuthErrorReason { + p := new(AuthErrorReason) + *p = x + return p +} + +func (x AuthErrorReason) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (AuthErrorReason) Descriptor() protoreflect.EnumDescriptor { + return file_types_auth_error_proto_enumTypes[0].Descriptor() +} + +func (AuthErrorReason) Type() protoreflect.EnumType { + return &file_types_auth_error_proto_enumTypes[0] +} + +func (x AuthErrorReason) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use AuthErrorReason.Descriptor instead. +func (AuthErrorReason) EnumDescriptor() ([]byte, []int) { + return file_types_auth_error_proto_rawDescGZIP(), []int{0} +} + +var File_types_auth_error_proto protoreflect.FileDescriptor + +const file_types_auth_error_proto_rawDesc = "" + + "\n" + + "\x16types/auth_error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*\x96\x01\n" + + "\x0fAuthErrorReason\x12!\n" + + "\x1dAUTH_ERROR_REASON_UNSPECIFIED\x10\x00\x12.\n" + + "#AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x12*\n" + + "\x1fAUTH_ERROR_REASON_TOKEN_EXPIRED\x10\xd2\x0f\x1a\x04\xa8E\x91\x03\x1a\x04\xa0E\xf4\x03B\xdc\x01\n" + + "\x19com.api.v1.services.typesB\x0eAuthErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_auth_error_proto_rawDescOnce sync.Once + file_types_auth_error_proto_rawDescData []byte +) + +func file_types_auth_error_proto_rawDescGZIP() []byte { + file_types_auth_error_proto_rawDescOnce.Do(func() { + file_types_auth_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_auth_error_proto_rawDesc), len(file_types_auth_error_proto_rawDesc))) + }) + return file_types_auth_error_proto_rawDescData +} + +var file_types_auth_error_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_types_auth_error_proto_goTypes = []any{ + (AuthErrorReason)(0), // 0: api.v1.services.types.AuthErrorReason +} +var file_types_auth_error_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_types_auth_error_proto_init() } +func file_types_auth_error_proto_init() { + if File_types_auth_error_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_auth_error_proto_rawDesc), len(file_types_auth_error_proto_rawDesc)), + NumEnums: 1, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_auth_error_proto_goTypes, + DependencyIndexes: file_types_auth_error_proto_depIdxs, + EnumInfos: file_types_auth_error_proto_enumTypes, + }.Build() + File_types_auth_error_proto = out.File + file_types_auth_error_proto_goTypes = nil + file_types_auth_error_proto_depIdxs = nil +} diff --git a/api/v1/services/types/auth_error.pb.validate.go b/api/v1/services/types/auth_error.pb.validate.go new file mode 100644 index 00000000..f8f94fbd --- /dev/null +++ b/api/v1/services/types/auth_error.pb.validate.go @@ -0,0 +1,36 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/auth_error.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) diff --git a/api/v1/services/types/auth_error_errors.pb.go b/api/v1/services/types/auth_error_errors.pb.go new file mode 100644 index 00000000..b4915c00 --- /dev/null +++ b/api/v1/services/types/auth_error_errors.pb.go @@ -0,0 +1,48 @@ +// Code generated by protoc-gen-go-errors. DO NOT EDIT. + +package types + +import ( + fmt "fmt" + errors "github.com/go-kratos/kratos/v2/errors" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +const _ = errors.SupportPackageIsVersion1 + +func IsAuthErrorReasonUnspecified(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 +} + +func ErrorAuthErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { + return errors.New(500, AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) +} + +func IsAuthErrorReasonCaptchaNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String() && e.Code == 404 +} + +func ErrorAuthErrorReasonCaptchaNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(404, AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsAuthErrorReasonTokenExpired(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 +} + +func ErrorAuthErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { + return errors.New(401, AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) +} diff --git a/api/v1/services/types/message.pb.go b/api/v1/services/types/message.pb.go new file mode 100644 index 00000000..0e31bac9 --- /dev/null +++ b/api/v1/services/types/message.pb.go @@ -0,0 +1,126 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc (unknown) +// source: types/message.proto + +package types + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + _ "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Menu is the model entity for the Menu schema. +type Message struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Message) Reset() { + *x = Message{} + mi := &file_types_message_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_types_message_proto_msgTypes[0] + 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 Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_types_message_proto_rawDescGZIP(), []int{0} +} + +func (x *Message) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +var File_types_message_proto protoreflect.FileDescriptor + +const file_types_message_proto_rawDesc = "" + + "\n" + + "\x13types/message.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x19\n" + + "\aMessage\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02idB\xda\x01\n" + + "\x19com.api.v1.services.typesB\fMessageProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_message_proto_rawDescOnce sync.Once + file_types_message_proto_rawDescData []byte +) + +func file_types_message_proto_rawDescGZIP() []byte { + file_types_message_proto_rawDescOnce.Do(func() { + file_types_message_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_message_proto_rawDesc), len(file_types_message_proto_rawDesc))) + }) + return file_types_message_proto_rawDescData +} + +var file_types_message_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_types_message_proto_goTypes = []any{ + (*Message)(nil), // 0: api.v1.services.types.Message +} +var file_types_message_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_types_message_proto_init() } +func file_types_message_proto_init() { + if File_types_message_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_message_proto_rawDesc), len(file_types_message_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_message_proto_goTypes, + DependencyIndexes: file_types_message_proto_depIdxs, + MessageInfos: file_types_message_proto_msgTypes, + }.Build() + File_types_message_proto = out.File + file_types_message_proto_goTypes = nil + file_types_message_proto_depIdxs = nil +} diff --git a/api/v1/services/types/message.pb.validate.go b/api/v1/services/types/message.pb.validate.go new file mode 100644 index 00000000..e03ac545 --- /dev/null +++ b/api/v1/services/types/message.pb.validate.go @@ -0,0 +1,136 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/message.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on Message 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 *Message) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Message 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 MessageMultiError, or nil if none found. +func (m *Message) ValidateAll() error { + return m.validate(true) +} + +func (m *Message) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return MessageMultiError(errors) + } + + return nil +} + +// MessageMultiError is an error wrapping multiple validation errors returned +// by Message.ValidateAll() if the designated constraints aren't met. +type MessageMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m MessageMultiError) 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 MessageMultiError) AllErrors() []error { return m } + +// MessageValidationError is the validation error returned by Message.Validate +// if the designated constraints aren't met. +type MessageValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e MessageValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e MessageValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e MessageValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e MessageValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e MessageValidationError) ErrorName() string { return "MessageValidationError" } + +// Error satisfies the builtin error interface +func (e MessageValidationError) 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 %sMessage.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = MessageValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = MessageValidationError{} diff --git a/api/v1/services/types/system_error.pb.go b/api/v1/services/types/system_error.pb.go new file mode 100644 index 00000000..42aeaf6e --- /dev/null +++ b/api/v1/services/types/system_error.pb.go @@ -0,0 +1,195 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc (unknown) +// source: types/system_error.proto + +package types + +import ( + _ "github.com/go-kratos/kratos/v2/errors" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SystemErrorReason int32 + +const ( + SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED SystemErrorReason = 0 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND SystemErrorReason = 2001 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS SystemErrorReason = 2002 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN SystemErrorReason = 2003 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT SystemErrorReason = 2004 + SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED SystemErrorReason = 2005 + SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND SystemErrorReason = 2006 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN SystemErrorReason = 2007 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS SystemErrorReason = 2008 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION SystemErrorReason = 2009 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION SystemErrorReason = 2010 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST SystemErrorReason = 2011 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE SystemErrorReason = 2012 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER SystemErrorReason = 2013 + SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND SystemErrorReason = 3001 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID SystemErrorReason = 3002 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE SystemErrorReason = 3003 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME SystemErrorReason = 3005 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD SystemErrorReason = 3006 +) + +// Enum value maps for SystemErrorReason. +var ( + SystemErrorReason_name = map[int32]string{ + 0: "SYSTEM_ERROR_REASON_UNSPECIFIED", + 2001: "SYSTEM_ERROR_REASON_USER_NOT_FOUND", + 2002: "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS", + 2003: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN", + 2004: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT", + 2005: "SYSTEM_ERROR_REASON_TOKEN_EXPIRED", + 2006: "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND", + 2007: "SYSTEM_ERROR_REASON_INVALID_TOKEN", + 2008: "SYSTEM_ERROR_REASON_INVALID_CLAIMS", + 2009: "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION", + 2010: "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION", + 2011: "SYSTEM_ERROR_REASON_INVALID_REQUEST", + 2012: "SYSTEM_ERROR_REASON_INVALID_RESPONSE", + 2013: "SYSTEM_ERROR_REASON_INVALID_SERVER", + 3001: "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND", + 3002: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID", + 3003: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE", + 3005: "SYSTEM_ERROR_REASON_INVALID_USERNAME", + 3006: "SYSTEM_ERROR_REASON_INVALID_PASSWORD", + } + SystemErrorReason_value = map[string]int32{ + "SYSTEM_ERROR_REASON_UNSPECIFIED": 0, + "SYSTEM_ERROR_REASON_USER_NOT_FOUND": 2001, + "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS": 2002, + "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN": 2003, + "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT": 2004, + "SYSTEM_ERROR_REASON_TOKEN_EXPIRED": 2005, + "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND": 2006, + "SYSTEM_ERROR_REASON_INVALID_TOKEN": 2007, + "SYSTEM_ERROR_REASON_INVALID_CLAIMS": 2008, + "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION": 2009, + "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION": 2010, + "SYSTEM_ERROR_REASON_INVALID_REQUEST": 2011, + "SYSTEM_ERROR_REASON_INVALID_RESPONSE": 2012, + "SYSTEM_ERROR_REASON_INVALID_SERVER": 2013, + "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND": 3001, + "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID": 3002, + "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE": 3003, + "SYSTEM_ERROR_REASON_INVALID_USERNAME": 3005, + "SYSTEM_ERROR_REASON_INVALID_PASSWORD": 3006, + } +) + +func (x SystemErrorReason) Enum() *SystemErrorReason { + p := new(SystemErrorReason) + *p = x + return p +} + +func (x SystemErrorReason) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SystemErrorReason) Descriptor() protoreflect.EnumDescriptor { + return file_types_system_error_proto_enumTypes[0].Descriptor() +} + +func (SystemErrorReason) Type() protoreflect.EnumType { + return &file_types_system_error_proto_enumTypes[0] +} + +func (x SystemErrorReason) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SystemErrorReason.Descriptor instead. +func (SystemErrorReason) EnumDescriptor() ([]byte, []int) { + return file_types_system_error_proto_rawDescGZIP(), []int{0} +} + +var File_types_system_error_proto protoreflect.FileDescriptor + +const file_types_system_error_proto_rawDesc = "" + + "\n" + + "\x18types/system_error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*\xbf\a\n" + + "\x11SystemErrorReason\x12#\n" + + "\x1fSYSTEM_ERROR_REASON_UNSPECIFIED\x10\x00\x12-\n" + + "\"SYSTEM_ERROR_REASON_USER_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x122\n" + + "'SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS\x10\xd2\x0f\x1a\x04\xa8E\x99\x03\x121\n" + + "&SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN\x10\xd3\x0f\x1a\x04\xa8E\x91\x03\x122\n" + + "'SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT\x10\xd4\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + + "!SYSTEM_ERROR_REASON_TOKEN_EXPIRED\x10\xd5\x0f\x1a\x04\xa8E\x91\x03\x12.\n" + + "#SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND\x10\xd6\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + + "!SYSTEM_ERROR_REASON_INVALID_TOKEN\x10\xd7\x0f\x1a\x04\xa8E\x91\x03\x12-\n" + + "\"SYSTEM_ERROR_REASON_INVALID_CLAIMS\x10\xd8\x0f\x1a\x04\xa8E\x91\x03\x125\n" + + "*SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION\x10\xd9\x0f\x1a\x04\xa8E\x91\x03\x124\n" + + ")SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION\x10\xda\x0f\x1a\x04\xa8E\x93\x03\x12.\n" + + "#SYSTEM_ERROR_REASON_INVALID_REQUEST\x10\xdb\x0f\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_RESPONSE\x10\xdc\x0f\x1a\x04\xa8E\xf4\x03\x12-\n" + + "\"SYSTEM_ERROR_REASON_INVALID_SERVER\x10\xdd\x0f\x1a\x04\xa8E\xf4\x03\x123\n" + + "(SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND\x10\xb9\x17\x1a\x04\xa8E\x94\x03\x121\n" + + "&SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID\x10\xba\x17\x1a\x04\xa8E\x90\x03\x123\n" + + "(SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE\x10\xbb\x17\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_USERNAME\x10\xbd\x17\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_PASSWORD\x10\xbe\x17\x1a\x04\xa8E\x90\x03\x1a\x04\xa0E\xf4\x03B\xde\x01\n" + + "\x19com.api.v1.services.typesB\x10SystemErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_system_error_proto_rawDescOnce sync.Once + file_types_system_error_proto_rawDescData []byte +) + +func file_types_system_error_proto_rawDescGZIP() []byte { + file_types_system_error_proto_rawDescOnce.Do(func() { + file_types_system_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_system_error_proto_rawDesc), len(file_types_system_error_proto_rawDesc))) + }) + return file_types_system_error_proto_rawDescData +} + +var file_types_system_error_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_types_system_error_proto_goTypes = []any{ + (SystemErrorReason)(0), // 0: api.v1.services.types.SystemErrorReason +} +var file_types_system_error_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_types_system_error_proto_init() } +func file_types_system_error_proto_init() { + if File_types_system_error_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_system_error_proto_rawDesc), len(file_types_system_error_proto_rawDesc)), + NumEnums: 1, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_system_error_proto_goTypes, + DependencyIndexes: file_types_system_error_proto_depIdxs, + EnumInfos: file_types_system_error_proto_enumTypes, + }.Build() + File_types_system_error_proto = out.File + file_types_system_error_proto_goTypes = nil + file_types_system_error_proto_depIdxs = nil +} diff --git a/api/v1/services/types/system_error.pb.validate.go b/api/v1/services/types/system_error.pb.validate.go new file mode 100644 index 00000000..ffc4ec92 --- /dev/null +++ b/api/v1/services/types/system_error.pb.validate.go @@ -0,0 +1,36 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/system_error.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) diff --git a/api/v1/services/types/system_error_errors.pb.go b/api/v1/services/types/system_error_errors.pb.go new file mode 100644 index 00000000..b5fa9310 --- /dev/null +++ b/api/v1/services/types/system_error_errors.pb.go @@ -0,0 +1,240 @@ +// Code generated by protoc-gen-go-errors. DO NOT EDIT. + +package types + +import ( + fmt "fmt" + errors "github.com/go-kratos/kratos/v2/errors" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +const _ = errors.SupportPackageIsVersion1 + +func IsSystemErrorReasonUnspecified(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 +} + +func ErrorSystemErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { + return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String() && e.Code == 404 +} + +func ErrorSystemErrorReasonUserNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserAlreadyExists(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String() && e.Code == 409 +} + +func ErrorSystemErrorReasonUserAlreadyExists(format string, args ...interface{}) *errors.Error { + return errors.New(409, SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserNotLoggedIn(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonUserNotLoggedIn(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserNotLoggedOut(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonUserNotLoggedOut(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonTokenExpired(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonTokenNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonTokenNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidToken(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonInvalidToken(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidClaims(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonInvalidClaims(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidAuthentication(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonInvalidAuthentication(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidAuthorization(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String() && e.Code == 403 +} + +func ErrorSystemErrorReasonInvalidAuthorization(format string, args ...interface{}) *errors.Error { + return errors.New(403, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidRequest(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidRequest(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidResponse(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String() && e.Code == 500 +} + +func ErrorSystemErrorReasonInvalidResponse(format string, args ...interface{}) *errors.Error { + return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidServer(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String() && e.Code == 500 +} + +func ErrorSystemErrorReasonInvalidServer(format string, args ...interface{}) *errors.Error { + return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonCaptchaIdNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String() && e.Code == 404 +} + +func ErrorSystemErrorReasonCaptchaIdNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidCaptchaId(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidCaptchaId(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidCaptchaCode(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidCaptchaCode(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidUsername(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidUsername(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidPassword(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidPassword(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), fmt.Sprintf(format, args...)) +} From 9052d590310091b42440dabf3dc499117416fdcc Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 24 Jun 2025 17:43:06 +0800 Subject: [PATCH 052/158] refactor(database): rename package to drivers and move files to new directory - Rename package 'database' to 'drivers' - Move files from 'contrib/database' to 'contrib/database/drivers' - Update package comments in all files to reflect the new package name --- contrib/database/{ => drivers}/const.go | 4 ++-- contrib/database/{ => drivers}/database.go | 4 ++-- contrib/database/{ => drivers}/everyone.go | 4 ++-- contrib/database/{ => drivers}/mssql.go | 4 ++-- contrib/database/{ => drivers}/mysql.go | 4 ++-- contrib/database/{ => drivers}/pgx.go | 4 ++-- contrib/database/{ => drivers}/postgres.go | 4 ++-- contrib/database/{ => drivers}/sqlite3_cgo.go | 4 ++-- contrib/database/{ => drivers}/sqlite3_go.go | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) rename contrib/database/{ => drivers}/const.go (83%) rename contrib/database/{ => drivers}/database.go (93%) rename contrib/database/{ => drivers}/everyone.go (82%) rename contrib/database/{ => drivers}/mssql.go (61%) rename contrib/database/{ => drivers}/mysql.go (68%) rename contrib/database/{ => drivers}/pgx.go (61%) rename contrib/database/{ => drivers}/postgres.go (68%) rename contrib/database/{ => drivers}/sqlite3_cgo.go (70%) rename contrib/database/{ => drivers}/sqlite3_go.go (70%) diff --git a/contrib/database/const.go b/contrib/database/drivers/const.go similarity index 83% rename from contrib/database/const.go rename to contrib/database/drivers/const.go index a4de500b..27f6a5dc 100644 --- a/contrib/database/const.go +++ b/contrib/database/drivers/const.go @@ -2,8 +2,8 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package database implements the functions, types, and interfaces for the module. -package database +// Package drivers is the database client wrapper +package drivers import ( "context" diff --git a/contrib/database/database.go b/contrib/database/drivers/database.go similarity index 93% rename from contrib/database/database.go rename to contrib/database/drivers/database.go index a742e7d0..66dc1ffe 100644 --- a/contrib/database/database.go +++ b/contrib/database/drivers/database.go @@ -2,8 +2,8 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package database implements the functions, types, and interfaces for the module. -package database +// Package drivers is the database client wrapper +package drivers import ( "database/sql" diff --git a/contrib/database/everyone.go b/contrib/database/drivers/everyone.go similarity index 82% rename from contrib/database/everyone.go rename to contrib/database/drivers/everyone.go index d79f296e..31ba4c3c 100644 --- a/contrib/database/everyone.go +++ b/contrib/database/drivers/everyone.go @@ -4,8 +4,8 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package database is the database client wrapper -package database +// Package drivers is the database client wrapper +package drivers import ( _ "github.com/denisenkom/go-mssqldb" diff --git a/contrib/database/mssql.go b/contrib/database/drivers/mssql.go similarity index 61% rename from contrib/database/mssql.go rename to contrib/database/drivers/mssql.go index 7016af03..8c61bf9e 100644 --- a/contrib/database/mssql.go +++ b/contrib/database/drivers/mssql.go @@ -4,8 +4,8 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package database implements the functions, types, and interfaces for the module. -package database +// Package drivers is the database client wrapper +package drivers import ( _ "github.com/denisenkom/go-mssqldb" diff --git a/contrib/database/mysql.go b/contrib/database/drivers/mysql.go similarity index 68% rename from contrib/database/mysql.go rename to contrib/database/drivers/mysql.go index d66e004b..dedf110d 100644 --- a/contrib/database/mysql.go +++ b/contrib/database/drivers/mysql.go @@ -4,8 +4,8 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package database is the database client wrapper -package database +// Package drivers is the database client wrapper +package drivers import ( _ "github.com/go-sql-driver/mysql" diff --git a/contrib/database/pgx.go b/contrib/database/drivers/pgx.go similarity index 61% rename from contrib/database/pgx.go rename to contrib/database/drivers/pgx.go index a2656f74..e4559344 100644 --- a/contrib/database/pgx.go +++ b/contrib/database/drivers/pgx.go @@ -4,8 +4,8 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package database implements the functions, types, and interfaces for the module. -package database +// Package drivers is the database client wrapper +package drivers import ( _ "github.com/jackc/pgx/v5/stdlib" diff --git a/contrib/database/postgres.go b/contrib/database/drivers/postgres.go similarity index 68% rename from contrib/database/postgres.go rename to contrib/database/drivers/postgres.go index e78aafd3..66e49776 100644 --- a/contrib/database/postgres.go +++ b/contrib/database/drivers/postgres.go @@ -4,8 +4,8 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package database is the database client wrapper -package database +// Package drivers is the database client wrapper +package drivers import ( _ "github.com/lib/pq" diff --git a/contrib/database/sqlite3_cgo.go b/contrib/database/drivers/sqlite3_cgo.go similarity index 70% rename from contrib/database/sqlite3_cgo.go rename to contrib/database/drivers/sqlite3_cgo.go index 3ab1312f..255d59dd 100644 --- a/contrib/database/sqlite3_cgo.go +++ b/contrib/database/drivers/sqlite3_cgo.go @@ -4,8 +4,8 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package database is the database client wrapper -package database +// Package drivers is the database client wrapper +package drivers import ( _ "github.com/mattn/go-sqlite3" diff --git a/contrib/database/sqlite3_go.go b/contrib/database/drivers/sqlite3_go.go similarity index 70% rename from contrib/database/sqlite3_go.go rename to contrib/database/drivers/sqlite3_go.go index 9463adab..a0fad9c1 100644 --- a/contrib/database/sqlite3_go.go +++ b/contrib/database/drivers/sqlite3_go.go @@ -4,8 +4,8 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package database is the database client wrapper -package database +// Package drivers is the database client wrapper +package drivers import ( _ "github.com/sqlite3ent/sqlite3" From ebeb2b119c24e20d1d44fd8881e4f3f81e10f8e9 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 24 Jun 2025 17:46:17 +0800 Subject: [PATCH 053/158] chore(build): update database package import path - Change import path for database package from "contrib/database" to "contrib/database/drivers" - This change affects multiple files: - cmd/auth/main.go - cmd/internal/start/start.go - cmd/system/main.go --- cmd/auth/main.go | 2 +- cmd/internal/start/start.go | 2 +- cmd/system/main.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/auth/main.go b/cmd/auth/main.go index ad5b9e4c..cc13d593 100644 --- a/cmd/auth/main.go +++ b/cmd/auth/main.go @@ -19,7 +19,7 @@ import ( _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" - _ "origadmin/application/admin/contrib/database" + _ "origadmin/application/admin/contrib/database/drivers" _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/loader" ) diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index 72aef38f..ac075132 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -19,7 +19,7 @@ import ( _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" - _ "origadmin/application/admin/contrib/database" + _ "origadmin/application/admin/contrib/database/drivers" "origadmin/application/admin/internal/configs" _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/loader" diff --git a/cmd/system/main.go b/cmd/system/main.go index 3e81257e..93e975d8 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -19,7 +19,7 @@ import ( _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" - _ "origadmin/application/admin/contrib/database" + _ "origadmin/application/admin/contrib/database/drivers" _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/loader" ) From 2403463e106bcd05632bf4eb37d493562ab6ae9b Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 24 Jun 2025 18:15:11 +0800 Subject: [PATCH 054/158] refactor(database): rename package from drivers to database - Move database.go from contrib/database/drivers/ to contrib/database/ - Update package name from "drivers" to "database" - Update package documentation to reflect new package name --- contrib/database/{drivers => }/database.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename contrib/database/{drivers => }/database.go (93%) diff --git a/contrib/database/drivers/database.go b/contrib/database/database.go similarity index 93% rename from contrib/database/drivers/database.go rename to contrib/database/database.go index 66dc1ffe..a742e7d0 100644 --- a/contrib/database/drivers/database.go +++ b/contrib/database/database.go @@ -2,8 +2,8 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package drivers is the database client wrapper -package drivers +// Package database implements the functions, types, and interfaces for the module. +package database import ( "database/sql" From 7555daff219159fcd2287c364a1428c8f95109e0 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 24 Jun 2025 21:19:47 +0800 Subject: [PATCH 055/158] feat(datastore): add proto definitions and initial implementation - Add datastore.proto and types.proto files for API definitions - Implement initial version of DatastoreService with CRUD operations - Add Permission, Resource, Role, and User services in biz layer - Implement DAL for Permission, Resource, Role, and User - Add wire providers for biz and dal layers --- Makefile | 2 - api/v1/proto/datastore/datastore.proto | 129 +++ api/v1/proto/types/datastore.proto | 31 + internal/mods/datastore/biz/README.md | 3 + internal/mods/datastore/biz/biz.go | 27 + internal/mods/datastore/biz/permission.biz.go | 91 ++ internal/mods/datastore/biz/provider.go | 22 + internal/mods/datastore/biz/resource.biz.go | 100 ++ internal/mods/datastore/biz/role.biz.go | 103 ++ internal/mods/datastore/biz/user.biz.go | 178 +++ internal/mods/datastore/dal/README.md | 3 + internal/mods/datastore/dal/dal.go | 9 + internal/mods/datastore/dal/menu.dal.go | 177 +++ internal/mods/datastore/dal/permission.dal.go | 172 +++ internal/mods/datastore/dal/provider.go | 24 + internal/mods/datastore/dal/resource.dal.go | 152 +++ internal/mods/datastore/dal/role.dal.go | 176 +++ internal/mods/datastore/dal/user.dal.go | 227 ++++ internal/mods/datastore/dto/README.md | 5 + internal/mods/datastore/dto/department.go | 12 + internal/mods/datastore/dto/dto.go | 1019 +++++++++++++++++ internal/mods/datastore/dto/menu.go | 75 ++ internal/mods/datastore/dto/permission.go | 83 ++ internal/mods/datastore/dto/position.go | 12 + internal/mods/datastore/dto/resource.go | 83 ++ internal/mods/datastore/dto/resource_type.go | 65 ++ internal/mods/datastore/dto/role.go | 109 ++ internal/mods/datastore/dto/user.go | 146 +++ internal/mods/datastore/server/README.md | 4 + internal/mods/datastore/server/gins.go | 67 ++ internal/mods/datastore/server/grpc.go | 27 + internal/mods/datastore/server/http.go | 27 + internal/mods/datastore/server/server.go | 151 +++ internal/mods/datastore/service/README.md | 3 + .../mods/datastore/service/menu.bridge.go | 110 ++ internal/mods/datastore/service/menu.grpc.go | 61 + internal/mods/datastore/service/menu.http.go | 61 + .../datastore/service/permission.bridge.go | 110 ++ .../mods/datastore/service/permission.grpc.go | 62 + .../mods/datastore/service/permission.http.go | 55 + internal/mods/datastore/service/provider.go | 48 + .../mods/datastore/service/resource.bridge.go | 110 ++ .../mods/datastore/service/resource.grpc.go | 61 + .../mods/datastore/service/resource.http.go | 55 + .../mods/datastore/service/role.bridge.go | 110 ++ internal/mods/datastore/service/role.grpc.go | 55 + internal/mods/datastore/service/role.http.go | 49 + internal/mods/datastore/service/service.go | 111 ++ .../mods/datastore/service/user.bridge.go | 110 ++ internal/mods/datastore/service/user.grpc.go | 83 ++ internal/mods/datastore/service/user.http.go | 72 ++ resources/docs/openapi/openapi.yaml | 262 +++++ 52 files changed, 5097 insertions(+), 2 deletions(-) create mode 100644 api/v1/proto/datastore/datastore.proto create mode 100644 api/v1/proto/types/datastore.proto create mode 100644 internal/mods/datastore/biz/README.md create mode 100644 internal/mods/datastore/biz/biz.go create mode 100644 internal/mods/datastore/biz/permission.biz.go create mode 100644 internal/mods/datastore/biz/provider.go create mode 100644 internal/mods/datastore/biz/resource.biz.go create mode 100644 internal/mods/datastore/biz/role.biz.go create mode 100644 internal/mods/datastore/biz/user.biz.go create mode 100644 internal/mods/datastore/dal/README.md create mode 100644 internal/mods/datastore/dal/dal.go create mode 100644 internal/mods/datastore/dal/menu.dal.go create mode 100644 internal/mods/datastore/dal/permission.dal.go create mode 100644 internal/mods/datastore/dal/provider.go create mode 100644 internal/mods/datastore/dal/resource.dal.go create mode 100644 internal/mods/datastore/dal/role.dal.go create mode 100644 internal/mods/datastore/dal/user.dal.go create mode 100644 internal/mods/datastore/dto/README.md create mode 100644 internal/mods/datastore/dto/department.go create mode 100644 internal/mods/datastore/dto/dto.go create mode 100644 internal/mods/datastore/dto/menu.go create mode 100644 internal/mods/datastore/dto/permission.go create mode 100644 internal/mods/datastore/dto/position.go create mode 100644 internal/mods/datastore/dto/resource.go create mode 100644 internal/mods/datastore/dto/resource_type.go create mode 100644 internal/mods/datastore/dto/role.go create mode 100644 internal/mods/datastore/dto/user.go create mode 100644 internal/mods/datastore/server/README.md create mode 100644 internal/mods/datastore/server/gins.go create mode 100644 internal/mods/datastore/server/grpc.go create mode 100644 internal/mods/datastore/server/http.go create mode 100644 internal/mods/datastore/server/server.go create mode 100644 internal/mods/datastore/service/README.md create mode 100644 internal/mods/datastore/service/menu.bridge.go create mode 100644 internal/mods/datastore/service/menu.grpc.go create mode 100644 internal/mods/datastore/service/menu.http.go create mode 100644 internal/mods/datastore/service/permission.bridge.go create mode 100644 internal/mods/datastore/service/permission.grpc.go create mode 100644 internal/mods/datastore/service/permission.http.go create mode 100644 internal/mods/datastore/service/provider.go create mode 100644 internal/mods/datastore/service/resource.bridge.go create mode 100644 internal/mods/datastore/service/resource.grpc.go create mode 100644 internal/mods/datastore/service/resource.http.go create mode 100644 internal/mods/datastore/service/role.bridge.go create mode 100644 internal/mods/datastore/service/role.grpc.go create mode 100644 internal/mods/datastore/service/role.http.go create mode 100644 internal/mods/datastore/service/service.go create mode 100644 internal/mods/datastore/service/user.bridge.go create mode 100644 internal/mods/datastore/service/user.grpc.go create mode 100644 internal/mods/datastore/service/user.http.go diff --git a/Makefile b/Makefile index c115c68a..0610624c 100644 --- a/Makefile +++ b/Makefile @@ -192,8 +192,6 @@ gen: go generate ./cmd/internal/start - - .PHONY: all # generate all all: diff --git a/api/v1/proto/datastore/datastore.proto b/api/v1/proto/datastore/datastore.proto new file mode 100644 index 00000000..4d396a96 --- /dev/null +++ b/api/v1/proto/datastore/datastore.proto @@ -0,0 +1,129 @@ +syntax = "proto3"; + +package api.v1.services.datastore; + +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/empty.proto"; +import "types/datastore.proto"; +import "validate/validate.proto"; + +option go_package = "api/v1/services/datastore;datastore"; +option java_multiple_files = true; +option java_outer_classname = "APIV1ServicesDatastoreProto"; +option java_package = "com.origadmin.api.v1.services.datastore"; + +// The data service definition. +service DatastoreService { + rpc ListDatastore(ListDatastoreRequest) returns (ListDatastoreResponse) { + option (google.api.http) = {get: "/datastore"}; + } + rpc GetDatastore(GetDatastoreRequest) returns (GetDatastoreResponse) { + option (google.api.http) = {get: "/datastore/{id}"}; + } + rpc CreateDatastore(CreateDatastoreRequest) returns (CreateDatastoreResponse) { + option (google.api.http) = { + post: "/datastore" + body: "data" + }; + } + rpc UpdateDatastore(UpdateDatastoreRequest) returns (UpdateDatastoreResponse) { + option (google.api.http) = { + put: "/datastore/{data.id}" + body: "data" + }; + } + rpc DeleteDatastore(DeleteDatastoreRequest) returns (DeleteDatastoreResponse) { + option (google.api.http) = {delete: "/datastore/{id}"}; + } +} + +// ListDatastoreRequest is the request for the DatastoreService.ListDatastore method. +message ListDatastoreRequest { + // The parent data id, for example, "shelves/shelf1". + int64 id = 1 [json_name = "id"]; + // The current page number. + int32 current = 2 [json_name = "current"]; + // The maximum number of items to return. + int32 page_size = 3 [json_name = "page_size"]; + // The next_page_token value returned from a previous List request, if any. + string page_token = 4 [json_name = "page_token"]; + // The no_paging is used to disable pagination. + bool no_paging = 5 [json_name = "no_paging"]; + // The only_count is the query parameter for set only to query the total number + bool only_count = 6 [json_name = "only_count"]; + // data type + string type = 7 [json_name = "type"]; +} + +// ListDatastoreResponse is the response for the DatastoreService.ListDatastore method. +message ListDatastoreResponse { + // The total number of items in the list. + int32 total_size = 1 [json_name = "total_size"]; + // The paging datastore + repeated api.v1.services.types.DataObject data = 2 [json_name = "data"]; + // The current page number. + int32 current = 3 [json_name = "current"]; + // The maximum number of items to return. + int32 page_size = 4 [json_name = "page_size"]; + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 5 [json_name = "next_page_token"]; + // Additional information about this response. + // content to be added without destroying the current data format + optional google.protobuf.Any extra = 6 [json_name = "extra"]; +} + +// GetDatastoreRequest is the request for the DatastoreService.GetDatastore method. +message GetDatastoreRequest { + // The field will contain id of the data requested, for example: + // "shelves/shelf1/datastore/data2" + int64 id = 1 [json_name = "id"]; +} + +// GetDatastoreResponse is the response for the DatastoreService.GetDatastore method. +message GetDatastoreResponse { + // The field id should match the Noun in the method id. + api.v1.services.types.DataObject data = 1 [json_name = "data"]; +} + +// CreateDatastoreRequest is the request for the DatastoreService.CreateDatastore method. +message CreateDatastoreRequest { + // The parent data id where the data is to be created. + string parent = 1 [json_name = "parent"]; + // The data id to use for this data. + string data_id = 2 [json_name = "data_id"]; + // The data object to create. + api.v1.services.types.DataObject data = 3 [json_name = "data"]; +} + +// CreateDatastoreResponse is the response for the DatastoreService.CreateDatastore method. +message CreateDatastoreResponse { + api.v1.services.types.DataObject data = 1 [json_name = "data"]; +} + +// UpdateDatastoreRequest is the request for the DatastoreService.UpdateDatastore method. +message UpdateDatastoreRequest { + // The id of the data object to update. + int64 id = 1 [json_name = "id"]; + // The data object which replaces the data on the server. + api.v1.services.types.DataObject data = 2 [json_name = "data"]; +} + +// UpdateDatastoreResponse is the response for the DatastoreService.UpdateDatastore method. +message UpdateDatastoreResponse { + api.v1.services.types.DataObject data = 1 [json_name = "data"]; +} + +// DeleteDatastoreRequest is the request for the DatastoreService.DeleteDatastore method. +message DeleteDatastoreRequest { + // The data id of the data to be deleted, for example: + // "shelves/shelf1/datastore/data2" + int64 id = 1 [json_name = "id"]; +} + +// DeleteDatastoreResponse is the response for the DatastoreService.DeleteDatastore method. +message DeleteDatastoreResponse { + // or Datastore data = 1; or google.protobuf.Empty empty = 1; + google.protobuf.Empty empty = 1; +} diff --git a/api/v1/proto/types/datastore.proto b/api/v1/proto/types/datastore.proto new file mode 100644 index 00000000..b5c12c1c --- /dev/null +++ b/api/v1/proto/types/datastore.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package api.v1.services.types; + +import "google/protobuf/timestamp.proto"; + +option go_package = "origadmin/application/admin/api/v1/services/types;types"; +option java_multiple_files = true; +option java_outer_classname = "APIServiceTypeMessageProto"; +option java_package = "com.origadmin.api.v1.services.types"; +option objc_class_prefix = "APIServiceType"; + +// Menu is the model entity for the Menu schema. +message DataObject { + // ID of the ent. + string id = 1 [json_name = "id"]; + // CreateTime holds the value of the "create_time" field. + google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; + // UpdateTime holds the value of the "update_time" field. + google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; + // DeleteTime holds the value of the "delete_time" field. + google.protobuf.Timestamp delete_time = 4 [json_name = "delete_time"]; + // Version holds the value of the "version" field. + int64 version = 5 [json_name = "version"]; + // OwnerID holds the value of the "owner_id" field. + string owner_id = 6 [json_name = "owner_id"]; + // Metadata holds the value of the "metadata" field. + map metadata = 7 [json_name = "metadata"]; + // Payload holds the value of the "payload" field. + bytes payload = 8 [json_name = "payload"]; +} diff --git a/internal/mods/datastore/biz/README.md b/internal/mods/datastore/biz/README.md new file mode 100644 index 00000000..c68e603d --- /dev/null +++ b/internal/mods/datastore/biz/README.md @@ -0,0 +1,3 @@ +# Biz + +This directory contains the business logic of the service. \ No newline at end of file diff --git a/internal/mods/datastore/biz/biz.go b/internal/mods/datastore/biz/biz.go new file mode 100644 index 00000000..0e4b98d9 --- /dev/null +++ b/internal/mods/datastore/biz/biz.go @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package biz + +import ( + "net/http" + + "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/toolkits/errors/httperr" + + typespb "origadmin/application/admin/api/v1/services/types" +) + +var ( + // ErrUserNotFound is user not found. + ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") +) + +var ( + defaultLimiter = pagination.DefaultLimiter() +) + +type UpdateHooker interface { + UpdateRules() +} diff --git a/internal/mods/datastore/biz/permission.biz.go b/internal/mods/datastore/biz/permission.biz.go new file mode 100644 index 00000000..df9acc06 --- /dev/null +++ b/internal/mods/datastore/biz/permission.biz.go @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/dto" +) + +// PermissionServiceBiz is a PermissionPB use case. +type PermissionServiceBiz struct { + dao dto.PermissionRepo + limiter pagination.PageLimiter + log *log.KHelper +} + +func (biz PermissionServiceBiz) ListPermissions(ctx context.Context, in *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { + var option dto.PermissionQueryOption + if err := option.FromListRequest(in, biz.limiter); err != nil { + return nil, err + } + option.IncludeResources = true + log.Info("ListPermissions") + result, total, err := biz.dao.List(ctx, in, option) + if err != nil { + return nil, err + } + return dto.ToListPermissionsResponse(result, in, total) +} + +func (biz PermissionServiceBiz) GetPermission(ctx context.Context, in *pb.GetPermissionRequest) (*pb.GetPermissionResponse, error) { + var option dto.PermissionQueryOption + if err := option.FromGetRequest(in, biz.limiter); err != nil { + return nil, err + } + log.Info("GetPermission") + result, err := biz.dao.Get(ctx, in.GetId(), option) + if err != nil { + return nil, err + } + return &pb.GetPermissionResponse{ + Permission: result, + }, nil +} + +func (biz PermissionServiceBiz) CreatePermission(ctx context.Context, in *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { + var option dto.PermissionQueryOption + if err := option.FromCreateRequest(in, biz.limiter); err != nil { + return nil, err + } + log.Info("CreatePermission") + result, err := biz.dao.Create(ctx, in.Permission, option) + if err != nil { + return nil, err + } + return &pb.CreatePermissionResponse{ + Permission: result, + }, nil +} + +func (biz PermissionServiceBiz) UpdatePermission(ctx context.Context, in *pb.UpdatePermissionRequest) (*pb.UpdatePermissionResponse, error) { + log.Info("UpdatePermission") + result, err := biz.dao.Update(ctx, in.Permission) + if err != nil { + return nil, err + } + return &pb.UpdatePermissionResponse{ + Permission: result, + }, nil +} + +func (biz PermissionServiceBiz) DeletePermission(ctx context.Context, in *pb.DeletePermissionRequest) (*pb.DeletePermissionResponse, error) { + log.Info("DeletePermission") + if err := biz.dao.Delete(ctx, in.GetId()); err != nil { + return nil, err + } + return &pb.DeletePermissionResponse{}, nil +} + +// NewPermissionServiceBiz new a PermissionPB use case. +func NewPermissionServiceBiz(r runtime.Runtime, repo dto.PermissionRepo) *PermissionServiceBiz { + return &PermissionServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} +} diff --git a/internal/mods/datastore/biz/provider.go b/internal/mods/datastore/biz/provider.go new file mode 100644 index 00000000..8e15c2fc --- /dev/null +++ b/internal/mods/datastore/biz/provider.go @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz implements the functions, types, and interfaces for the module. +package biz + +import ( + "github.com/google/wire" +) + +// ProviderSet is biz providers. +var ProviderSet = wire.NewSet( + //NewAuthServiceBiz, + //NewLoginServiceBiz, + //NewPersonalServiceBiz, + NewResourceServiceBiz, + NewRoleServiceBiz, + NewUserServiceBiz, + NewPermissionServiceBiz, + //NewCasbinSourceServiceBiz, +) diff --git a/internal/mods/datastore/biz/resource.biz.go b/internal/mods/datastore/biz/resource.biz.go new file mode 100644 index 00000000..2b980143 --- /dev/null +++ b/internal/mods/datastore/biz/resource.biz.go @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/mods/system/dto" +) + +// ResourceServiceBiz is a ResourcePB use case. +type ResourceServiceBiz struct { + dao dto.ResourceRepo + limiter pagination.PageLimiter + log *log.KHelper +} + +func (biz ResourceServiceBiz) ListResources(ctx context.Context, in *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { + var option dto.ResourceQueryOption + if err := option.FromListRequest(in, biz.limiter); err != nil { + return nil, err + } + log.Info("ListResources") + result, total, err := biz.dao.List(ctx, in, option) + if err != nil { + return nil, err + } + return dto.ToListResourcesResponse(result, in, total) +} + +func (biz ResourceServiceBiz) GetResource(ctx context.Context, in *pb.GetResourceRequest) (*pb.GetResourceResponse, error) { + var option dto.ResourceQueryOption + if err := option.FromGetRequest(in, biz.limiter); err != nil { + return nil, err + } + log.Info("GetResource") + result, err := biz.dao.Get(ctx, in.GetId(), option) + if err != nil { + return nil, err + } + return &pb.GetResourceResponse{ + Resource: result, + }, nil +} + +func (biz ResourceServiceBiz) CreateResource(ctx context.Context, in *pb.CreateResourceRequest) (*pb.CreateResourceResponse, error) { + var option dto.ResourceQueryOption + if err := option.FromCreateRequest(in, biz.limiter); err != nil { + return nil, err + } + log.Info("CreateResource") + result, err := biz.dao.Create(ctx, in.Resource, option) + if err != nil { + return nil, err + } + return &pb.CreateResourceResponse{ + Resource: result, + }, nil +} + +var updateFields = []string{ + resource.FieldIcon, resource.FieldType, resource.FieldStatus, + resource.FieldName, resource.FieldPath, resource.FieldKeyword, + resource.FieldSequence, resource.FieldProperties, resource.FieldDescription, +} + +func (biz ResourceServiceBiz) UpdateResource(ctx context.Context, in *pb.UpdateResourceRequest) (*pb.UpdateResourceResponse, error) { + var option dto.ResourceQueryOption + + log.Info("UpdateResource") + option.Fields = resource.SelectColumns(updateFields) + result, err := biz.dao.Update(ctx, in.Resource, option) + if err != nil { + return nil, err + } + return &pb.UpdateResourceResponse{ + Resource: result, + }, nil +} + +func (biz ResourceServiceBiz) DeleteResource(ctx context.Context, in *pb.DeleteResourceRequest) (*pb.DeleteResourceResponse, error) { + log.Info("DeleteResource") + if err := biz.dao.Delete(ctx, in.GetId()); err != nil { + return nil, err + } + return &pb.DeleteResourceResponse{}, nil +} + +// NewResourceServiceBiz new a ResourcePB use case. +func NewResourceServiceBiz(r runtime.Runtime, repo dto.ResourceRepo) *ResourceServiceBiz { + return &ResourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} +} diff --git a/internal/mods/datastore/biz/role.biz.go b/internal/mods/datastore/biz/role.biz.go new file mode 100644 index 00000000..78afc8d2 --- /dev/null +++ b/internal/mods/datastore/biz/role.biz.go @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/dto" +) + +// RoleServiceBiz is a RolePB use case. +type RoleServiceBiz struct { + dao dto.RoleRepo + limiter pagination.PageLimiter + log *log.KHelper +} + +func (biz RoleServiceBiz) ListRoles(ctx context.Context, in *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { + var option dto.RoleQueryOption + if err := option.FromListRequest(in, biz.limiter); err != nil { + return nil, err + } + log.Info("ListRoles") + option.IncludePermissions = true + result, total, err := biz.dao.List(ctx, in, option) + if err != nil { + return nil, err + } + return dto.ToListRolesResponse(result, in, total) +} + +func (biz RoleServiceBiz) GetRole(ctx context.Context, in *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { + var option dto.RoleQueryOption + if err := option.FromGetRequest(in, biz.limiter); err != nil { + return nil, err + } + log.Info("GetRole") + result, err := biz.dao.Get(ctx, in.GetId(), option) + if err != nil { + return nil, err + } + return &pb.GetRoleResponse{ + Role: result, + }, nil +} + +func (biz RoleServiceBiz) CreateRole(ctx context.Context, in *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { + var option dto.RoleUpdateOption + if err := option.FromCreateRequest(in); err != nil { + return nil, err + } + log.Info("CreateRole") + result, err := biz.dao.Create(ctx, in.Role, option) + if err != nil { + return nil, err + } + return &pb.CreateRoleResponse{ + Role: result, + }, nil +} + +func (biz RoleServiceBiz) UpdateRole(ctx context.Context, in *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { + //var option dto.UpdateRoleOption + //if err := option.FromListRequest(in, biz.limiter); err != nil { + // return nil, err + //} + log.Info("UpdateRole") + result, err := biz.dao.Update(ctx, in.Role) + if err != nil { + return nil, err + } + return &pb.UpdateRoleResponse{ + Role: result, + }, nil +} + +func (biz RoleServiceBiz) DeleteRole(ctx context.Context, in *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { + //var option dto.DeleteRoleOption + //if err := option.FromListRequest(in, biz.limiter); err != nil { + // return nil, err + //} + //_, err := biz.dao.Get(ctx, in.GetId()) + //if err != nil { + // return nil, err + //} + log.Info("DeleteRole") + if err := biz.dao.Delete(ctx, in.GetId()); err != nil { + return nil, err + } + return &pb.DeleteRoleResponse{}, nil +} + +// NewRoleServiceBiz new a RolePB use case. +func NewRoleServiceBiz(r runtime.Runtime, repo dto.RoleRepo) *RoleServiceBiz { + return &RoleServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} +} diff --git a/internal/mods/datastore/biz/user.biz.go b/internal/mods/datastore/biz/user.biz.go new file mode 100644 index 00000000..ad8ddc0b --- /dev/null +++ b/internal/mods/datastore/biz/user.biz.go @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "fmt" + + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/dto" +) + +// UserServiceBiz is a UserPB use case. +type UserServiceBiz struct { + dao dto.UserRepo + limiter pagination.PageLimiter + log *log.KHelper +} + +func (biz UserServiceBiz) ListUserResources(ctx context.Context, in *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { + var option dto.UserQueryOption + //if err := option.FromListRequest(in, biz.limiter); err != nil { + // return nil, err + //} + log.Info("ListUserResources") + //option.IncludeRoles = true + result, err := biz.dao.ListResourceByUserID(ctx, in.GetId(), option) + if err != nil { + return nil, err + } + log.Info("ListUserResources result:", result) + //return dto.ToListResourcesResponse(result, in, total) + return &pb.ListUserResourcesResponse{ + TotalSize: int32(len(result)), + //Current: in.Current, + //PageSize: in.PageSize, + Resources: result, + //Extra: resp.Any(args...), + }, nil +} + +func (biz UserServiceBiz) UpdateUserRoles(ctx context.Context, in *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { + var option dto.UserMutationOption + //if err := option.FromListRequest(in, biz.limiter); err != nil { + // return nil, err + //} + log.Info("UpdateUserRoles") + //option.IncludeRoles = true + err := biz.dao.AddRoleIDs(ctx, in.GetUser().GetId(), in.GetRoleIds(), option) + if err != nil { + return nil, err + } + return &pb.UpdateUserRolesResponse{ + //User: result, + }, nil +} + +func (biz UserServiceBiz) UpdateUserStatus(ctx context.Context, in *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { + var option dto.UserQueryOption + //if err := option.FromListRequest(in, biz.limiter); err != nil { + // return nil, err + //} + log.Info("UpdateUserStatus") + option.Fields = []string{"status"} + //option.IncludeRoles = true + err := biz.dao.UpdateUserStatus(ctx, in.GetUser().GetId(), int8(in.GetUser().GetStatus()), option) + if err != nil { + return nil, err + } + return &pb.UpdateUserStatusResponse{ + //User: result, + }, nil +} + +func (biz UserServiceBiz) ResetUserPassword(ctx context.Context, in *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { + var option dto.UserQueryOption + //if err := option.FromListRequest(in, biz.limiter); err != nil { + // return nil, err + //} + log.Info("ResetUserPassword") + option.IncludeRoles = true + //result, total, err := biz.dao.ResetUserPassword(ctx, in, option) + //if err != nil { + // return nil, err + //} + //return dto.ToListUsersResponse(result, in, total) + return &pb.ResetUserPasswordResponse{}, nil +} + +func (biz UserServiceBiz) ListUsers(ctx context.Context, in *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { + var option dto.UserQueryOption + if err := option.FromListRequest(in, biz.limiter); err != nil { + return nil, err + } + log.Info("ListUsers") + option.IncludeRoles = true + result, total, err := biz.dao.List(ctx, in, option) + if err != nil { + return nil, err + } + return dto.ToListUsersResponse(result, in, total) +} + +func (biz UserServiceBiz) GetUser(ctx context.Context, in *pb.GetUserRequest) (*pb.GetUserResponse, error) { + var option dto.UserQueryOption + if err := option.FromGetRequest(in, biz.limiter); err != nil { + return nil, err + } + log.Info("GetUser") + result, err := biz.dao.Get(ctx, in.GetId(), option) + if err != nil { + return nil, err + } + return &pb.GetUserResponse{ + User: result, + }, nil +} + +func (biz UserServiceBiz) CreateUser(ctx context.Context, in *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { + var option dto.UserMutationOption + if err := option.FromCreateRequest(in, biz.limiter); err != nil { + return nil, err + } + log.Info("MakeCreateUser") + username := in.GetUser().GetUsername() + password := in.GetUser().GetPassword() + createUser, ps, err := dto.MakeCreateUser(in.User, username, password, option) + if err != nil { + return nil, err + } + // TODO: Send email or sms to user + _ = ps + fmt.Println("Create new user username:", username, "password:", ps) + + result, err := biz.dao.Create(ctx, createUser, option) + if err != nil { + return nil, err + } + return &pb.CreateUserResponse{ + User: result, + }, nil +} + +func (biz UserServiceBiz) UpdateUser(ctx context.Context, in *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { + //var option dto.UpdateUserOption + //if err := option.FromListRequest(in, biz.limiter); err != nil { + // return nil, err + //} + log.Info("UpdateUser") + result, err := biz.dao.Update(ctx, in.User) + if err != nil { + return nil, err + } + return &pb.UpdateUserResponse{ + User: result, + }, nil +} + +func (biz UserServiceBiz) DeleteUser(ctx context.Context, in *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { + log.Info("DeleteUser") + if err := biz.dao.Delete(ctx, in.GetUser().GetId()); err != nil { + return nil, err + } + return &pb.DeleteUserResponse{}, nil +} + +// NewUserServiceBiz new a UserPB use case. + +func NewUserServiceBiz(r runtime.Runtime, repo dto.UserRepo) *UserServiceBiz { + return &UserServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} +} diff --git a/internal/mods/datastore/dal/README.md b/internal/mods/datastore/dal/README.md new file mode 100644 index 00000000..0f77dee7 --- /dev/null +++ b/internal/mods/datastore/dal/README.md @@ -0,0 +1,3 @@ +# Dal + +This directory contains the data access layer (DAL) for the service. diff --git a/internal/mods/datastore/dal/dal.go b/internal/mods/datastore/dal/dal.go new file mode 100644 index 00000000..18173605 --- /dev/null +++ b/internal/mods/datastore/dal/dal.go @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "github.com/google/wire" +) diff --git a/internal/mods/datastore/dal/menu.dal.go b/internal/mods/datastore/dal/menu.dal.go new file mode 100644 index 00000000..e37e4e8e --- /dev/null +++ b/internal/mods/datastore/dal/menu.dal.go @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "github.com/origadmin/runtime" + + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/mods/system/dto" +) + +type menuRepo struct { + db *data.Data +} + +// +//func (repo menuRepo) Get(ctx context.Context, id int64, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { +// var option dto.MenuQueryOption +// if len(options) > 0 { +// option = options[0] +// } +// query := repo.db.Menu(ctx).Query().Where(menu.ID(id)) +// query = menuQueryOptions(query, option) +// result, err := query.First(ctx) +// if err != nil { +// return nil, err +// } +// return dto.ConvertMenu2PB(result), nil +//} +// +//func (repo menuRepo) Create(ctx context.Context, menuPB *dto.MenuPB, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { +// var option dto.MenuQueryOption +// if len(options) > 0 { +// option = options[0] +// } +// err := repo.db.Tx(ctx, func(ctx context.Context) error { +// create := repo.db.Menu(ctx).Create() +// create.SetMenu(dto.ConvertMenuPB2Object(menuPB), option.Fields...) +// saved, err := create.Save(ctx) +// if err != nil { +// return err +// } +// menuPB = dto.ConvertMenu2PB(saved) +// return nil +// }) +// if err != nil { +// return nil, err +// } +// return menuPB, nil +//} +// +//func (repo menuRepo) Delete(ctx context.Context, id int64) error { +// return repo.db.Tx(ctx, func(ctx context.Context) error { +// return repo.db.Menu(ctx).DeleteOneID(id).Exec(ctx) +// }) +//} +// +//func (repo menuRepo) Update(ctx context.Context, menuPB *dto.MenuPB, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { +// err := repo.db.Tx(ctx, func(ctx context.Context) error { +// update := repo.db.Menu(ctx).UpdateOneID(menuPB.Id) +// update.SetMenu(dto.ConvertMenuPB2Object(menuPB)) +// saved, err := update.Save(ctx) +// if err != nil { +// return err +// } +// menuPB = dto.ConvertMenu2PB(saved) +// return nil +// }) +// if err != nil { +// return nil, err +// } +// return menuPB, nil +//} +// +//func (repo menuRepo) List(ctx context.Context, in *dto.ListMenusRequest, options ...dto.MenuQueryOption) ([]*dto.MenuPB, int32, error) { +// var option dto.MenuQueryOption +// if len(options) > 0 { +// option = options[0] +// } +// +// query := repo.db.Menu(ctx).Query() +// if option.IncludeResources { +// query = query.WithResources() +// } +// if v := option.UserID; v > 0 { +// query = query.Where(menu.HasRolesWith(role.HasUsersWith(user.ID(v)))) +// } +// if v := option.RoleID; v > 0 { +// query = query.Where(menu.HasRolesWith(role.ID(v))) +// } +// if v := option.InIDs; len(v) > 0 { +// query = query.Where(menu.IDIn(v...)) +// } +// if v := option.Name; len(v) > 0 { +// query = query.Where(menu.ParentPathContains(v)) +// } +// if v := option.Status; v > 0 { +// query = query.Where(menu.StatusEQ(v)) +// } +// if v := option.ParentID; v > 0 { +// query = query.Where(menu.ParentID(v)) +// } +// if v := option.ParentPathPrefix; len(v) > 0 { +// query = query.Where(menu.ParentPathHasPrefix(v)) +// } +// +// return menuPageQuery(ctx, query, in, option) +//} + +// NewMenuRepo . +func NewMenuRepo(r runtime.Runtime, db *data.Data) dto.MenuRepo { + return &menuRepo{ + db: db, + } +} + +// +//func menuPageQuery(ctx context.Context, query *ent.MenuQuery, in *pb.ListMenusRequest, option dto.MenuQueryOption) ([]*dto.MenuPB, int32, error) { +// if in.OnlyCount { +// count, err := query.Count(ctx) +// if err != nil { +// return nil, 0, err +// } +// return nil, int32(count), nil +// } +// count, err := query.Clone().Count(ctx) +// if err != nil { +// return nil, 0, err +// } +// query = menuQueryPage(query, in) +// query = menuQueryOptions(query, option) +// result, err := query.Clone().All(ctx) +// return dto.ConvertMenus(result), int32(count), err +//} +// +//func menuQueryPage(query *ent.MenuQuery, in *pb.ListMenusRequest) *ent.MenuQuery { +// if in.NoPaging { +// pageSize := in.PageSize +// if pageSize > 0 { +// query = query.Limit(int(pageSize)) +// } +// return query +// } +// +// pageSize := in.PageSize +// if pageSize > 0 { +// query = query.Limit(int(pageSize)) +// } +// current := in.Current +// if current > 0 { +// query = query.Offset(int((current - 1) * pageSize)) +// } +// return query +//} +// +//func menuQueryOptions(query *ent.MenuQuery, option dto.MenuQueryOption) *ent.MenuQuery { +// if len(option.SelectFields) > 0 { +// query = query.Select(option.SelectFields...).MenuQuery +// } +// if len(option.OmitFields) > 0 { +// query = query.Omit(option.OmitFields...).MenuQuery +// } +// if len(option.OrderFields) > 0 { +// query = query.Order(menuOrderBy(option.OrderFields)...) +// } +// return query +//} +// +//func menuOrderBy(fields []string, opts ...sql.OrderTermOption) []menu.OrderOption { +// var orders []menu.OrderOption +// for _, field := range fields { +// orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) +// } +// return orders +//} diff --git a/internal/mods/datastore/dal/permission.dal.go b/internal/mods/datastore/dal/permission.dal.go new file mode 100644 index 00000000..ebeb9958 --- /dev/null +++ b/internal/mods/datastore/dal/permission.dal.go @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "context" + + "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/db" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/mods/system/dto" +) + +type permissionRepo struct { + db *data.Data +} + +func (repo permissionRepo) Get(ctx context.Context, id int64, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { + var option dto.PermissionQueryOption + if len(options) > 0 { + option = options[0] + } + query := repo.db.Permission(ctx).Query().Where(permission.ID(id)) + query = permissionQueryOptions(query, option) + result, err := query.First(ctx) + if err != nil { + return nil, err + } + return dto.ConvertPermission2PB(result), nil +} + +func (repo permissionRepo) Create(ctx context.Context, permission *dto.PermissionPB, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { + var option dto.PermissionQueryOption + if len(options) > 0 { + option = options[0] + } + obj := dto.ConvertPermissionPB2Object(permission) + create := repo.db.Permission(ctx).Create() + if len(permission.ResourceIds) > 0 { + create.AddResourceIDs(permission.ResourceIds...) + } + if len(permission.Resources) > 0 { + create.AddResources(dto.ConvertResourcesPB2Object(permission.Resources)...) + } + create.SetPermission(obj, option.Fields...) + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertPermission2PB(saved), nil +} + +func (repo permissionRepo) Delete(ctx context.Context, id int64) error { + return repo.db.Permission(ctx).DeleteOneID(id).Exec(ctx) +} + +func (repo permissionRepo) Update(ctx context.Context, permission *dto.PermissionPB, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { + var option dto.PermissionQueryOption + if len(options) > 0 { + option = options[0] + } + + update := repo.db.Permission(ctx).UpdateOneID(permission.Id) + obj := dto.ConvertPermissionPB2Object(permission) + if len(permission.ResourceIds) > 0 { + update.ClearResources() + update.AddResourceIDs(permission.ResourceIds...) + } + if len(permission.Resources) > 0 { + update.ClearResources() + update.AddResources(dto.ConvertResourcesPB2Object(permission.Resources)...) + } + update.SetPermission(obj, option.Fields...) + saved, err := update.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertPermission2PB(saved), nil +} + +func (repo permissionRepo) List(ctx context.Context, in *dto.ListPermissionsRequest, options ...dto.PermissionQueryOption) ([]*dto.PermissionPB, int32, error) { + var option dto.PermissionQueryOption + if len(options) > 0 { + option = options[0] + } + + query := repo.db.Permission(ctx).Query() + if option.IncludeResources { + query = query.WithResources() + } + if option.IncludeRoles { + query = query.WithRoles() + } + if len(in.DataScopes) > 0 { + query = query.Where(permission.DataScopeIn(in.DataScopes...)) + } + return permissionPageQuery(ctx, query, in, option) +} + +// NewPermissionRepo . +func NewPermissionRepo(r runtime.Runtime, db *data.Data) dto.PermissionRepo { + return &permissionRepo{ + db: db, + } +} + +func permissionPageQuery(ctx context.Context, query *ent.PermissionQuery, in *pb.ListPermissionsRequest, option dto.PermissionQueryOption) ([]*dto.PermissionPB, int32, error) { + if in.OnlyCount { + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + return nil, int32(count), nil + } + + query = permissionQueryOptions(query, option) + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + query = db.Query(query, in, !in.NoPaging) + result, err := query.All(ctx) + return dto.ConvertPermissions(result), int32(count), err +} + +func permissionQueryPage(query *ent.PermissionQuery, in *pb.ListPermissionsRequest) *ent.PermissionQuery { + if in.NoPaging { + pageSize := in.PageSize + if pageSize > 0 { + query = query.Limit(int(pageSize)) + } + return query + } + + pageSize := in.PageSize + if pageSize > 0 { + query = query.Limit(int(pageSize)) + } + current := in.Current + if current > 0 { + query = query.Offset(int((current - 1) * pageSize)) + } + return query +} + +func permissionQueryOptions(query *ent.PermissionQuery, option dto.PermissionQueryOption) *ent.PermissionQuery { + if len(option.SelectFields) > 0 { + query = query.Select(option.SelectFields...).PermissionQuery + } + if len(option.OmitFields) > 0 { + query = query.Omit(option.OmitFields...).PermissionQuery + } + if len(option.OrderFields) > 0 { + query = query.Order(permissionOrderBy(option.OrderFields)...) + } + return query +} + +func permissionOrderBy(fields []string, opts ...sql.OrderTermOption) []permission.OrderOption { + var orders []permission.OrderOption + for _, field := range fields { + orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) + } + return orders +} diff --git a/internal/mods/datastore/dal/provider.go b/internal/mods/datastore/dal/provider.go new file mode 100644 index 00000000..e013feb9 --- /dev/null +++ b/internal/mods/datastore/dal/provider.go @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dal implements the functions, types, and interfaces for the module. +package dal + +import ( + "github.com/google/wire" +) + +// ProviderSet is data providers. +var ProviderSet = wire.NewSet( + //NewAuthRepo, + //NewLoginRepo, + //NewPersonalRepo, + NewMenuRepo, + NewResourceRepo, + NewRoleRepo, + NewUserRepo, + NewPermissionRepo, + //NewCasbinSourceRepo, + //RefreshTokenizer, +) diff --git a/internal/mods/datastore/dal/resource.dal.go b/internal/mods/datastore/dal/resource.dal.go new file mode 100644 index 00000000..86a69c22 --- /dev/null +++ b/internal/mods/datastore/dal/resource.dal.go @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "context" + "strconv" + + "github.com/origadmin/runtime" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/db" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/mods/system/dto" +) + +type resourceRepo struct { + db *data.Data +} + +func (repo resourceRepo) Get(ctx context.Context, id int64, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { + var option dto.ResourceQueryOption + if len(options) > 0 { + option = options[0] + } + query := repo.db.Resource(ctx).Query().Where(resource.ID(id)) + query = resourceQueryOptions(query, option) + if option.IncludePermissions { + query.WithPermissions() + } + result, err := query.First(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResource2PB(result), nil +} + +func (repo resourceRepo) Create(ctx context.Context, resource *dto.ResourcePB, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { + var option dto.ResourceQueryOption + if len(options) > 0 { + option = options[0] + } + obj := dto.ConvertResourcePB2Object(resource) + if obj.ParentID > 0 { + parent, err := repo.db.Resource(ctx).Get(ctx, obj.ParentID) + if err != nil { + return nil, err + } + obj.TreePath = parent.TreePath + strconv.Itoa(int(parent.ID)) + repo.db.Delimiter + } + + create := repo.db.Resource(ctx).Create() + create.SetResource(obj, option.Fields...) + if len(resource.PermissionIds) > 0 { + create.AddPermissionIDs(resource.PermissionIds...) + } + if len(resource.Permissions) > 0 { + create.AddPermissions(dto.ConvertPermissionsPB2Object(resource.Permissions)...) + } + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResource2PB(saved), nil +} + +func (repo resourceRepo) Delete(ctx context.Context, id int64) error { + return repo.db.Resource(ctx).DeleteOneID(id).Exec(ctx) +} + +func (repo resourceRepo) Update(ctx context.Context, resource *dto.ResourcePB, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { + var option dto.ResourceQueryOption + if len(options) > 0 { + option = options[0] + } + err := repo.db.Tx(ctx, func(ctx context.Context) error { + update := repo.db.Resource(ctx).UpdateOneID(resource.Id) + update.SetResourceWithZero(dto.ConvertResourcePB2Object(resource), option.Fields...) + if len(resource.PermissionIds) > 0 { + update.AddPermissionIDs(resource.PermissionIds...) + } + if len(resource.Permissions) > 0 { + update.AddPermissions(dto.ConvertPermissionsPB2Object(resource.Permissions)...) + } + saved, err := update.Save(ctx) + if err != nil { + return err + } + resource = dto.ConvertResource2PB(saved) + return nil + }) + if err != nil { + return nil, err + } + return resource, nil +} + +func (repo resourceRepo) List(ctx context.Context, in *dto.ListResourcesRequest, options ...dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { + var option dto.ResourceQueryOption + if len(options) > 0 { + option = options[0] + } + + query := repo.db.Resource(ctx).Query() + return resourcePageQuery(ctx, query, in, option) +} + +// NewResourceRepo . +func NewResourceRepo(r runtime.Runtime, db *data.Data) dto.ResourceRepo { + return &resourceRepo{ + db: db, + } +} + +func resourcePageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.ListResourcesRequest, option dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { + if in.OnlyCount { + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + return nil, int32(count), nil + } + query = resourceQueryOptions(query, option) + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + query = db.Query(query, in, !in.NoPaging) + result, err := query.All(ctx) + return dto.ConvertResources(result), int32(count), err +} + +func resourceOrderBy(orders []string) []resource.OrderOption { + return db.OrderBy[resource.OrderOption](orders) +} + +func resourceQueryOptions(query *ent.ResourceQuery, option dto.ResourceQueryOption) *ent.ResourceQuery { + if len(option.SelectFields) > 0 { + query = query.Select(option.SelectFields...).ResourceQuery + } + if len(option.OmitFields) > 0 { + query = query.Omit(option.OmitFields...).ResourceQuery + } + if len(option.OrderFields) > 0 { + query = query.Order(resourceOrderBy(option.OrderFields)...) + } + return query +} diff --git a/internal/mods/datastore/dal/role.dal.go b/internal/mods/datastore/dal/role.dal.go new file mode 100644 index 00000000..843bfd61 --- /dev/null +++ b/internal/mods/datastore/dal/role.dal.go @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dal is the data access object +package dal + +import ( + "errors" + + "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/toolkits/crypto/rand" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/db" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/mods/system/dto" +) + +type roleRepo struct { + gen *rand.Rand + db *data.Data +} + +func (repo roleRepo) Get(ctx context.Context, id int64, options ...dto.RoleQueryOption) (*dto.RolePB, error) { + var option dto.RoleQueryOption + if len(options) > 0 { + option = options[0] + } + query := repo.db.Role(ctx).Query().Where(role.ID(id)) + query = roleQueryOptions(query, option) + result, err := query.First(ctx) + if err != nil { + return nil, err + } + return dto.ConvertRole2PB(result), nil +} + +func (repo roleRepo) Create(ctx context.Context, rolePB *dto.RolePB, options ...dto.RoleUpdateOption) (*dto.RolePB, error) { + var option dto.RoleUpdateOption + if len(options) > 0 { + option = options[0] + } + obj := dto.ConvertRolePB2Object(rolePB) + if obj.Keyword == "" { + obj.Keyword = "system:role:" + repo.gen.RandString(12) + } + exist, err := repo.db.Role(ctx).Query().Where(role.KeywordEqualFold(rolePB.Keyword)).Exist(ctx) + if err != nil || exist { + return nil, errors.New("role keyword already exists") + } + err = repo.db.Tx(ctx, func(ctx context.Context) error { + create := repo.db.Role(ctx).Create() + create.SetRole(obj, option.Fields...) + saved, err := create.Save(ctx) + if err != nil { + return err + } + rolePB = dto.ConvertRole2PB(saved) + return nil + }) + if err != nil { + return nil, err + } + return rolePB, nil +} + +func (repo roleRepo) Delete(ctx context.Context, id int64) error { + return repo.db.Tx(ctx, func(ctx context.Context) error { + err := repo.db.Role(ctx).DeleteOneID(id).Exec(ctx) + if err != nil { + return err + } + return nil + }) +} + +func (repo roleRepo) Update(ctx context.Context, rolePB *dto.RolePB, options ...dto.RoleUpdateOption) (*dto.RolePB, error) { + var option dto.RoleUpdateOption + if len(options) > 0 { + option = options[0] + } + update := repo.db.Role(ctx).UpdateOneID(rolePB.Id) + if len(rolePB.PermissionIds) > 0 { + update.ClearPermissions() + update.AddPermissionIDs(rolePB.PermissionIds...) + } + if len(rolePB.Permissions) > 0 { + update.ClearPermissions() + update.AddPermissions(dto.ConvertPermissionsPB2Object(rolePB.Permissions)...) + } + saved, err := update.SetRoleWithZero(dto.ConvertRolePB2Object(rolePB), option.Fields...).Save(ctx) + if err != nil { + return nil, err + } + rolePB = dto.ConvertRole2PB(saved) + return rolePB, nil +} + +func (repo roleRepo) List(ctx context.Context, in *pb.ListRolesRequest, options ...dto.RoleQueryOption) ([]*dto.RolePB, int32, error) { + var option dto.RoleQueryOption + if len(options) > 0 { + option = options[0] + } + + query := repo.db.Role(ctx).Query() + if option.IncludePermissions { + query = query.WithPermissions() + } + if v := option.InIDs; len(v) > 0 { + query = query.Where(role.IDIn(v...)) + } + if v := option.Name; len(v) > 0 { + query = query.Where(role.NameContains(v)) + } + if v := option.Status; v > 0 { + query = query.Where(role.StatusEQ(v)) + } + if v := option.UpdateTimeGT; v != nil { + query = query.Where(role.UpdateTimeGT(*v)) + } + + return rolePageQuery(ctx, query, in, option) +} + +// NewRoleRepo . +func NewRoleRepo(r runtime.Runtime, db *data.Data) dto.RoleRepo { + return &roleRepo{ + gen: rand.DigitAndLowerCase, + db: db, + } +} + +func rolePageQuery(ctx context.Context, query *ent.RoleQuery, in *pb.ListRolesRequest, option dto.RoleQueryOption) ([]*dto.RolePB, int32, error) { + if in.OnlyCount { + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + return nil, int32(count), nil + } + + query = roleQueryOptions(query, option) + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + query = db.Query(query, in, !in.NoPaging) + result, err := query.All(ctx) + return dto.ConvertRoles(result), int32(count), err +} + +func roleQueryOptions(query *ent.RoleQuery, option dto.RoleQueryOption) *ent.RoleQuery { + if len(option.SelectFields) > 0 { + query = query.Select(option.SelectFields...).RoleQuery + } + if len(option.OmitFields) > 0 { + query = query.Omit(option.OmitFields...).RoleQuery + } + if len(option.OrderFields) > 0 { + query = query.Order(roleOrderBy(option.OrderFields)...) + } + return query +} + +func roleOrderBy(fields []string, opts ...sql.OrderTermOption) []role.OrderOption { + var orders []role.OrderOption + for _, field := range fields { + orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) + } + return orders +} diff --git a/internal/mods/datastore/dal/user.dal.go b/internal/mods/datastore/dal/user.dal.go new file mode 100644 index 00000000..216df004 --- /dev/null +++ b/internal/mods/datastore/dal/user.dal.go @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dal is the data access object +package dal + +import ( + "errors" + "time" + + "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/db" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/mods/system/dto" +) + +type userRepo struct { + db *data.Data +} + +func (repo userRepo) AddRoleIDs(ctx context.Context, i int64, int64s []int64, option ...dto.UserMutationOption) error { + //TODO implement me + panic("implement me") +} + +func (repo userRepo) UpdateUserStatus(ctx context.Context, id int64, status int8, options ...dto.UserQueryOption) error { + err := repo.db.User(ctx).UpdateOneID(id).SetStatus(status).Exec(ctx) + if err != nil { + return err + } + return nil +} + +func (repo userRepo) Current(ctx context.Context, id int64) (*dto.UserPB, error) { + return repo.Get(ctx, id) +} + +func (repo userRepo) ListResourceByUserID(ctx context.Context, id int64, + option ...dto.UserQueryOption) ([]*dto.ResourcePB, error) { + resources, err := repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResources(resources), nil +} + +func (repo userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*dto.UserNode, error) { + query := repo.db.User(ctx).Query().Where(user.UsernameEQ(username)) + var option dto.UserQueryOption + if len(fields) > 0 { + option.SelectFields = fields + } + query = userQueryOptions(query, option) + result, err := query.First(ctx) + if err != nil { + return nil, err + } + return &dto.UserNode{ + UserPB: *dto.ConvertUser2PB(result), + EncryptedPassword: result.EncryptedPassword, + }, nil +} + +func (repo userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { + return repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().IDs(ctx) +} + +func (repo userRepo) Get(ctx context.Context, id int64, options ...dto.UserQueryOption) (*dto.UserPB, error) { + var option dto.UserQueryOption + if len(options) > 0 { + option = options[0] + } + query := repo.db.User(ctx).Query().Where(user.ID(id)) + query = userQueryOptions(query, option) + result, err := query.First(ctx) + if err != nil { + return nil, err + } + return dto.ConvertUser2PB(result), nil +} + +func (repo userRepo) Create(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { + var option dto.UserMutationOption + if len(options) > 0 { + option = options[0] + } + + var err error + exist, err := repo.db.User(ctx).Query().Where(user.UsernameEQ(userPB.Username)).Exist(ctx) + if err != nil || exist { + return nil, errors.New("user already exists") + } + obj := dto.ConvertUserPB2Object(userPB) + obj.CreateTime = time.Now() + obj.UpdateTime = time.Now() + err = repo.db.Tx(ctx, func(ctx context.Context) error { + create := repo.db.User(ctx).Create() + create.SetUser(obj, option.Fields...) + saved, err := create.Save(ctx) + if err != nil { + return err + } + userPB = dto.ConvertUser2PB(saved) + return nil + }) + if err != nil { + return nil, err + } + return userPB, nil +} + +func (repo userRepo) Delete(ctx context.Context, id int64) error { + return repo.db.Tx(ctx, func(ctx context.Context) error { + return repo.db.User(ctx).DeleteOneID(id).Exec(ctx) + }) +} + +func (repo userRepo) Update(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { + obj := dto.ConvertUserPB2Object(userPB) + obj.UpdateTime = time.Now() + err := repo.db.Tx(ctx, func(ctx context.Context) error { + update := repo.db.User(ctx).UpdateOneID(userPB.Id) + if len(userPB.Roles) > 0 { + update.ClearRoles() + update.AddRoles(dto.ConvertRolesPB2Object(userPB.Roles)...) + } else { + update.ClearRoles() + } + if len(userPB.RoleIds) > 0 { + update.ClearRoles() + update.AddRoleIDs(userPB.RoleIds...) + } else { + update.ClearRoles() + } + update.SetUser(obj, user.SelectColumns([]string{ + user.FieldNickname, + user.FieldUsername, + user.FieldPhone, + user.FieldEmail, + user.FieldUpdateTime})...) + saved, err := update.Save(ctx) + if err != nil { + return err + } + userPB = dto.ConvertUser2PB(saved) + return nil + }) + if err != nil { + return nil, err + } + return userPB, nil +} + +func (repo userRepo) List(ctx context.Context, in *pb.ListUsersRequest, options ...dto.UserQueryOption) ([]*dto.UserPB, int32, error) { + var option dto.UserQueryOption + if len(options) > 0 { + option = options[0] + } + + query := repo.db.User(ctx).Query() + if option.IncludeRoles { + query = query.WithRoles() + } + if in.Title != "" { + query = query.Where(user.Or(user.UsernameContainsFold(in.Title), user.PhoneContainsFold(in.Title), user.EmailContainsFold(in.Title))) + } + + if v := option.Status; v > 0 { + query = query.Where(user.StatusEQ(v)) + } + + return userPageQuery(ctx, query, in, option) +} + +// NewUserRepo . +func NewUserRepo(r runtime.Runtime, db *data.Data) dto.UserRepo { + return &userRepo{ + db: db, + } +} + +func userPageQuery(ctx context.Context, query *ent.UserQuery, in *pb.ListUsersRequest, option dto.UserQueryOption) ([]*dto.UserPB, int32, error) { + if in.OnlyCount { + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + return nil, int32(count), nil + } + + query = userQueryOptions(query, option) + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + query = db.Query(query, in, !in.NoPaging) + result, err := query.All(ctx) + return dto.ConvertUsers(result), int32(count), err +} + +func userQueryOptions(query *ent.UserQuery, option dto.UserQueryOption) *ent.UserQuery { + if len(option.SelectFields) > 0 { + query = query.Select(option.SelectFields...).UserQuery + } + if len(option.OmitFields) > 0 { + query = query.Omit(option.OmitFields...).UserQuery + } + if len(option.OrderFields) > 0 { + query = query.Order(userOrderBy(option.OrderFields)...) + } + return query +} + +func userOrderBy(fields []string, opts ...sql.OrderTermOption) []user.OrderOption { + var orders []user.OrderOption + for _, field := range fields { + orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) + } + return orders +} diff --git a/internal/mods/datastore/dto/README.md b/internal/mods/datastore/dto/README.md new file mode 100644 index 00000000..4e251bc1 --- /dev/null +++ b/internal/mods/datastore/dto/README.md @@ -0,0 +1,5 @@ +# Dto + +This directory contains the data transfer object (DTO) for the service. +The DTO is used to transfer data between the `biz` and `dal`. + diff --git a/internal/mods/datastore/dto/department.go b/internal/mods/datastore/dto/department.go new file mode 100644 index 00000000..1e1fad52 --- /dev/null +++ b/internal/mods/datastore/dto/department.go @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto implements the functions, types, and interfaces for the module. +package dto + +type DepartmentNode struct { + DepartmentPB + Children []*DepartmentNode `json:"children"` + PositionKeywords []string `json:"position_keywords"` +} diff --git a/internal/mods/datastore/dto/dto.go b/internal/mods/datastore/dto/dto.go new file mode 100644 index 00000000..bdca763d --- /dev/null +++ b/internal/mods/datastore/dto/dto.go @@ -0,0 +1,1019 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto is the data transfer object package for the system module. +package dto + +import ( + "net/http" + + "github.com/origadmin/toolkits/errors/httperr" + "google.golang.org/protobuf/types/known/timestamppb" + + typespb "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/schema/types" + "origadmin/application/admin/internal/data/entity/ent/user" +) + +var ( + // ErrUserNotFound is user not found. + ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") + ErrInvalidCaptchaID = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") + ErrInvalidPassword = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") + ErrInvalidUsername = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") + ErrCaptchaIDNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") +) + +const ( + UserStatusActive = types.Active + UserStatusFrozen = types.Frozen +) + +const ( + ResourceStatusEnabled = types.Enabled + ResourceStatusDisabled = types.Disabled +) + +type ( + // User 用户类型 + // @Convert( + // target = "UserPB", + // direction = "both", + // ignoreFields = ["password", "salt"] + // ) + User = ent.User + // UserPB + // @Convert( + // target="User", + // direction="both" + // ) + UserPB = typespb.User +) + +// ConvertUser2PB user.table.comment +func ConvertUser2PB(goModel *User) (pbModel *UserPB) { + pbModel = &UserPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.CreateAuthor = int64(goModel.CreateAuthor) + pbModel.UpdateAuthor = int64(goModel.UpdateAuthor) + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Uuid = goModel.UUID + pbModel.AllowedIp = goModel.AllowedIP + pbModel.Username = goModel.Username + pbModel.Nickname = goModel.Nickname + pbModel.Avatar = goModel.Avatar + pbModel.Name = goModel.Name + pbModel.Gender = ConvertGender2PB(goModel.Gender) + //pbModel.Password = goModel.EncryptedPassword + //pbModel.Salt = goModel.Salt + pbModel.Phone = goModel.Phone + pbModel.Email = goModel.Email + pbModel.Remark = goModel.Remark + pbModel.Token = goModel.Token + pbModel.Status = int32(goModel.Status) + pbModel.LastLoginIp = goModel.LastLoginIP + pbModel.LastLoginTime = timestamppb.New(goModel.LastLoginTime) + pbModel.SanctionDate = timestamppb.New(goModel.SanctionDate) + pbModel.ManagerId = int64(goModel.ManagerID) + pbModel.Manager = goModel.Manager + //pbModel.Roles = ConvertRoles(goModel.Edges.Roles) + for _, role := range goModel.Edges.Roles { + pbModel.RoleIds = append(pbModel.RoleIds, role.ID) + } + pbModel.Roles = ConvertRoles(goModel.Edges.Roles) + return pbModel +} + +func ConvertGender2PB(gender user.Gender) string { + return gender.String() +} + +// ConvertUserPB2Object user.table.comment +func ConvertUserPB2Object(pbModel *UserPB) (goModel *User) { + goModel = &User{} + if pbModel == nil { + return goModel + } + + goModel.ID = int64(pbModel.Id) + goModel.CreateAuthor = int64(pbModel.CreateAuthor) + goModel.UpdateAuthor = int64(pbModel.UpdateAuthor) + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.UUID = pbModel.Uuid + goModel.AllowedIP = pbModel.AllowedIp + goModel.Username = pbModel.Username + goModel.Nickname = pbModel.Nickname + goModel.Avatar = pbModel.Avatar + goModel.Name = pbModel.Name + goModel.Gender = user.Gender(pbModel.Gender) + //goModel.Password = pbModel.Password + //goModel.Salt = pbModel.Salt + goModel.Phone = pbModel.Phone + goModel.Email = pbModel.Email + goModel.Remark = pbModel.Remark + goModel.Token = pbModel.Token + goModel.Status = int8(pbModel.Status) + goModel.LastLoginIP = pbModel.LastLoginIp + goModel.LastLoginTime = pbModel.LastLoginTime.AsTime() + goModel.SanctionDate = pbModel.SanctionDate.AsTime() + goModel.ManagerID = pbModel.ManagerId + goModel.Manager = pbModel.Manager + return goModel +} + +type ( + Resource = ent.Resource + ResourcePB = typespb.Resource +) + +func ConvertResource2PB(goModel *Resource) (pbModel *ResourcePB) { + pbModel = &ResourcePB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = goModel.ID + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Name = goModel.Name + pbModel.Keyword = goModel.Keyword + pbModel.I18NKey = goModel.I18nKey + pbModel.Type = goModel.Type + pbModel.Status = int32(goModel.Status) + pbModel.Path = goModel.Path + pbModel.Operation = goModel.Operation + pbModel.Method = goModel.Method + pbModel.Component = goModel.Component + pbModel.Icon = goModel.Icon + pbModel.Sequence = int32(goModel.Sequence) + pbModel.Visible = goModel.Visible + pbModel.TreePath = goModel.TreePath + pbModel.Properties = goModel.Properties + pbModel.Description = goModel.Description + pbModel.ParentId = int64(goModel.ParentID) + return pbModel +} + +func ConvertResourcePB2Object(pbModel *ResourcePB) (goModel *Resource) { + goModel = &Resource{} + if pbModel == nil { + return goModel + } + + goModel.ID = pbModel.Id + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.Name = pbModel.Name + goModel.Keyword = pbModel.Keyword + goModel.I18nKey = pbModel.I18NKey + goModel.Type = pbModel.Type + goModel.Status = int8(pbModel.Status) + goModel.Path = pbModel.Path + goModel.Operation = pbModel.Operation + goModel.Method = pbModel.Method + goModel.Component = pbModel.Component + goModel.Icon = pbModel.Icon + goModel.Sequence = int(pbModel.Sequence) + goModel.Visible = pbModel.Visible + goModel.TreePath = pbModel.TreePath + goModel.Properties = pbModel.Properties + goModel.Description = pbModel.Description + goModel.ParentID = pbModel.ParentId + return goModel +} + +type ( + Role = ent.Role + RolePB = typespb.Role +) + +// ConvertRole2PB role.table.comment +func ConvertRole2PB(goModel *Role) (pbModel *RolePB) { + pbModel = &RolePB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = goModel.ID + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Keyword = goModel.Keyword + pbModel.Name = goModel.Name + pbModel.Description = goModel.Description + pbModel.Type = int32(goModel.Type) + pbModel.Sequence = int32(goModel.Sequence) + pbModel.Status = int32(goModel.Status) + for _, permission := range goModel.Edges.Permissions { + pbModel.PermissionIds = append(pbModel.PermissionIds, int64(permission.ID)) + } + pbModel.Permissions = ConvertPermissions(goModel.Edges.Permissions) + //pbModel.IsSystem = goModel.IsSystem + return pbModel +} + +// ConvertRolePB2Object role.table.comment +func ConvertRolePB2Object(pbModel *RolePB) (goModel *Role) { + goModel = &Role{} + if pbModel == nil { + return goModel + } + + goModel.ID = pbModel.Id + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.Keyword = pbModel.Keyword + goModel.Name = pbModel.Name + goModel.Description = pbModel.Description + goModel.Type = int8(pbModel.Type) + goModel.Sequence = int(pbModel.Sequence) + goModel.Status = int8(pbModel.Status) + + //goModel.IsSystem = pbModel.IsSystem + return goModel +} + +type ( + Department = ent.Department + DepartmentPB = typespb.Department +) + +// ConvertDepartment2PB department.table.comment +func ConvertDepartment2PB(goModel *Department) (pbModel *DepartmentPB) { + pbModel = &DepartmentPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = goModel.ID + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Keyword = goModel.Keyword + pbModel.Name = goModel.Name + pbModel.Description = goModel.Description + pbModel.Sequence = int32(goModel.Sequence) + pbModel.Status = int32(goModel.Status) + pbModel.Level = int32(goModel.Level) + pbModel.ParentId = goModel.ParentID + return pbModel +} + +// ConvertDepartmentPB2Object department.table.comment +func ConvertDepartmentPB2Object(pbModel *DepartmentPB) (goModel *Department) { + goModel = &Department{} + if pbModel == nil { + return goModel + } + + goModel.ID = pbModel.Id + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.Keyword = pbModel.Keyword + goModel.Name = pbModel.Name + goModel.TreePath = pbModel.TreePath + goModel.Description = pbModel.Description + goModel.Sequence = int(pbModel.Sequence) + goModel.Status = int8(pbModel.Status) + goModel.Level = int(pbModel.Level) + goModel.ParentID = pbModel.ParentId + return goModel +} + +type ( + Departments = []*ent.Department + DepartmentsPB = []*typespb.Department +) + +// ConvertDepartments2PB Children holds the value of the children edge. +func ConvertDepartments2PB(gosModel Departments) (pbsModel DepartmentsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertDepartment2PB(model)) + } + return pbsModel +} + +// ConvertDepartmentsPB2Object Children holds the value of the children edge. +func ConvertDepartmentsPB2Object(pbsModel DepartmentsPB) (gosModel Departments) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertDepartmentPB2Object(model)) + } + return gosModel +} + +type ( + UserDepartments = []*ent.UserDepartment + UserDepartmentsPB = []*typespb.UserDepartment +) + +// ConvertUserDepartments2PB UserDepartments holds the value of the user_departments edge. +func ConvertUserDepartments2PB(gosModel UserDepartments) (pbsModel UserDepartmentsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertUserDepartment2PB(model)) + } + return pbsModel +} + +// ConvertUserDepartmentsPB2Object UserDepartments holds the value of the user_departments edge. +func ConvertUserDepartmentsPB2Object(pbsModel UserDepartmentsPB) (gosModel UserDepartments) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertUserDepartmentPB2Object(model)) + } + return gosModel +} + +type ( + DepartmentEdges = ent.DepartmentEdges + DepartmentEdgesPB = typespb.DepartmentEdges +) + +// ConvertDepartmentEdges2PB DepartmentEdges holds the relations/edges for other nodes in the graph. +func ConvertDepartmentEdges2PB(goModel *DepartmentEdges) (pbModel *DepartmentEdgesPB) { + pbModel = &DepartmentEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Users = ConvertUsers2PB(goModel.Users) + pbModel.Positions = ConvertPositions2PB(goModel.Positions) + pbModel.Children = ConvertDepartments2PB(goModel.Children) + pbModel.Parent = ConvertDepartment2PB(goModel.Parent) + pbModel.UserDepartments = ConvertUserDepartments2PB(goModel.UserDepartments) + return pbModel +} + +// ConvertDepartmentEdgesPB2Object DepartmentEdges holds the relations/edges for other nodes in the graph. +func ConvertDepartmentEdgesPB2Object(pbModel *DepartmentEdgesPB) (goModel *DepartmentEdges) { + goModel = &DepartmentEdges{} + if pbModel == nil { + return goModel + } + + goModel.Users = ConvertUsersPB2Object(pbModel.Users) + goModel.Positions = ConvertPositionsPB2Object(pbModel.Positions) + goModel.Children = ConvertDepartmentsPB2Object(pbModel.Children) + goModel.Parent = ConvertDepartmentPB2Object(pbModel.Parent) + goModel.UserDepartments = ConvertUserDepartmentsPB2Object(pbModel.UserDepartments) + return goModel +} + +type ( + UserDepartment = ent.UserDepartment + UserDepartmentPB = typespb.UserDepartment +) + +// ConvertUserDepartment2PB user_department.table.comment +func ConvertUserDepartment2PB(goModel *UserDepartment) (pbModel *UserDepartmentPB) { + pbModel = &UserDepartmentPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.UserId = int64(goModel.UserID) + pbModel.DepartmentId = int64(goModel.DepartmentID) + return pbModel +} + +// ConvertUserDepartmentPB2Object user_department.table.comment +func ConvertUserDepartmentPB2Object(pbModel *UserDepartmentPB) (goModel *UserDepartment) { + goModel = &UserDepartment{} + if pbModel == nil { + return goModel + } + + //goModel.ID = int64(pbModel.Id) + goModel.UserID = int64(pbModel.UserId) + goModel.DepartmentID = int64(pbModel.DepartmentId) + return goModel +} + +type ( + UserDepartmentEdges = ent.UserDepartmentEdges + UserDepartmentEdgesPB = typespb.UserDepartmentEdges +) + +// ConvertUserDepartmentEdges2PB UserDepartmentEdges holds the relations/edges for other nodes in the graph. +func ConvertUserDepartmentEdges2PB(goModel *UserDepartmentEdges) (pbModel *UserDepartmentEdgesPB) { + pbModel = &UserDepartmentEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.User = ConvertUser2PB(goModel.User) + pbModel.Department = ConvertDepartment2PB(goModel.Department) + return pbModel +} + +// ConvertUserDepartmentEdgesPB2Object UserDepartmentEdges holds the relations/edges for other nodes in the graph. +func ConvertUserDepartmentEdgesPB2Object(pbModel *UserDepartmentEdgesPB) (goModel *UserDepartmentEdges) { + goModel = &UserDepartmentEdges{} + if pbModel == nil { + return goModel + } + + goModel.User = ConvertUserPB2Object(pbModel.User) + goModel.Department = ConvertDepartmentPB2Object(pbModel.Department) + return goModel +} + +type ( + Position = ent.Position + PositionPB = typespb.Position +) + +// ConvertPosition2PB position.table.comment +func ConvertPosition2PB(goModel *Position) (pbModel *PositionPB) { + pbModel = &PositionPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Name = goModel.Name + pbModel.Description = goModel.Description + pbModel.DepartmentId = int64(goModel.DepartmentID) + return pbModel +} + +// ConvertPositionPB2Object position.table.comment +func ConvertPositionPB2Object(pbModel *PositionPB) (goModel *Position) { + goModel = &Position{} + if pbModel == nil { + return goModel + } + + goModel.ID = int64(pbModel.Id) + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.Name = pbModel.Name + goModel.Description = pbModel.Description + goModel.DepartmentID = int64(pbModel.DepartmentId) + return goModel +} + +type ( + Users = []*ent.User + UsersPB = []*typespb.User +) + +// ConvertUsers2PB Users holds the value of the users edge. +func ConvertUsers2PB(gosModel Users) (pbsModel UsersPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertUser2PB(model)) + } + return pbsModel +} + +// ConvertUsersPB2Object Users holds the value of the users edge. +func ConvertUsersPB2Object(pbsModel UsersPB) (gosModel Users) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertUserPB2Object(model)) + } + return gosModel +} + +type ( + Permissions = []*ent.Permission + PermissionsPB = []*typespb.Permission +) + +// ConvertPermissions2PB Permissions holds the value of the permissions edge. +func ConvertPermissions2PB(gosModel Permissions) (pbsModel PermissionsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertPermission2PB(model)) + } + return pbsModel +} + +// ConvertPermissionsPB2Object Permissions holds the value of the permissions edge. +func ConvertPermissionsPB2Object(pbsModel PermissionsPB) (gosModel Permissions) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertPermissionPB2Object(model)) + } + return gosModel +} + +type ( + UserPositions = []*ent.UserPosition + UserPositionsPB = []*typespb.UserPosition +) + +// ConvertUserPositions2PB UserPositions holds the value of the user_positions edge. +func ConvertUserPositions2PB(gosModel UserPositions) (pbsModel UserPositionsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertUserPosition2PB(model)) + } + return pbsModel +} + +// ConvertUserPositionsPB2Object UserPositions holds the value of the user_positions edge. +func ConvertUserPositionsPB2Object(pbsModel UserPositionsPB) (gosModel UserPositions) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertUserPositionPB2Object(model)) + } + return gosModel +} + +type ( + PositionEdges = ent.PositionEdges + PositionEdgesPB = typespb.PositionEdges +) + +// ConvertPositionEdges2PB PositionEdges holds the relations/edges for other nodes in the graph. +func ConvertPositionEdges2PB(goModel *PositionEdges) (pbModel *PositionEdgesPB) { + pbModel = &PositionEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Department = ConvertDepartment2PB(goModel.Department) + pbModel.Users = ConvertUsers2PB(goModel.Users) + pbModel.Permissions = ConvertPermissions2PB(goModel.Permissions) + pbModel.UserPositions = ConvertUserPositions2PB(goModel.UserPositions) + pbModel.PositionPermissions = ConvertPositionPermissions2PB(goModel.PositionPermissions) + return pbModel +} + +// ConvertPositionEdgesPB2Object PositionEdges holds the relations/edges for other nodes in the graph. +func ConvertPositionEdgesPB2Object(pbModel *PositionEdgesPB) (goModel *PositionEdges) { + goModel = &PositionEdges{} + if pbModel == nil { + return goModel + } + + goModel.Department = ConvertDepartmentPB2Object(pbModel.Department) + goModel.Users = ConvertUsersPB2Object(pbModel.Users) + goModel.Permissions = ConvertPermissionsPB2Object(pbModel.Permissions) + goModel.UserPositions = ConvertUserPositionsPB2Object(pbModel.UserPositions) + goModel.PositionPermissions = ConvertPositionPermissionsPB2Object(pbModel.PositionPermissions) + return goModel +} + +// ConvertDataRules2PB permission.field.data_rules +func ConvertDataRules2PB(gosModel map[string]string) map[string]string { + return gosModel +} + +// ConvertDataRulesPB2Object permission.field.data_rules +func ConvertDataRulesPB2Object(pbsModel map[string]string) map[string]string { + return pbsModel +} + +type ( + Permission = ent.Permission + PermissionPB = typespb.Permission +) + +// ConvertPermission2PB permission.table.comment +func ConvertPermission2PB(goModel *Permission) (pbModel *PermissionPB) { + pbModel = &PermissionPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.CreateTime = timestamppb.New(goModel.CreateTime) + pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) + pbModel.Name = goModel.Name + pbModel.Keyword = goModel.Keyword + pbModel.Description = goModel.Description + pbModel.DataScope = goModel.DataScope + pbModel.DataRules = ConvertDataRules2PB(goModel.DataRules) + for _, resource := range goModel.Edges.Resources { + pbModel.ResourceIds = append(pbModel.ResourceIds, resource.ID) + } + pbModel.Resources = ConvertResources2PB(goModel.Edges.Resources) + return pbModel +} + +// ConvertPermissionPB2Object permission.table.comment +func ConvertPermissionPB2Object(pbModel *PermissionPB) (goModel *Permission) { + goModel = &Permission{} + if pbModel == nil { + return goModel + } + + goModel.ID = int64(pbModel.Id) + goModel.CreateTime = pbModel.CreateTime.AsTime() + goModel.UpdateTime = pbModel.UpdateTime.AsTime() + goModel.Name = pbModel.Name + goModel.Keyword = pbModel.Keyword + goModel.Description = pbModel.Description + goModel.DataScope = pbModel.DataScope + goModel.DataRules = ConvertDataRulesPB2Object(pbModel.DataRules) + return goModel +} + +type ( + Roles = []*ent.Role + RolesPB = []*typespb.Role +) + +// ConvertRoles2PB Roles holds the value of the roles edge. +func ConvertRoles2PB(gosModel Roles) (pbsModel RolesPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertRole2PB(model)) + } + return pbsModel +} + +// ConvertRolesPB2Object Roles holds the value of the roles edge. +func ConvertRolesPB2Object(pbsModel RolesPB) (gosModel Roles) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertRolePB2Object(model)) + } + return gosModel +} + +type ( + Resources = []*ent.Resource + ResourcesPB = []*typespb.Resource +) + +// ConvertResources2PB Resources holds the value of the resources edge. +func ConvertResources2PB(gosModel Resources) (pbsModel ResourcesPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertResource2PB(model)) + } + return pbsModel +} + +// ConvertResourcesPB2Object Resources holds the value of the resources edge. +func ConvertResourcesPB2Object(pbsModel ResourcesPB) (gosModel Resources) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertResourcePB2Object(model)) + } + return gosModel +} + +type ( + Positions = []*ent.Position + PositionsPB = []*typespb.Position +) + +// ConvertPositions2PB Positions holds the value of the positions edge. +func ConvertPositions2PB(gosModel Positions) (pbsModel PositionsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertPosition2PB(model)) + } + return pbsModel +} + +// ConvertPositionsPB2Object Positions holds the value of the positions edge. +func ConvertPositionsPB2Object(pbsModel PositionsPB) (gosModel Positions) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertPositionPB2Object(model)) + } + return gosModel +} + +type ( + RolePermissions = []*ent.RolePermission + RolePermissionsPB = []*typespb.RolePermission +) + +// ConvertRolePermissions2PB RolePermissions holds the value of the role_permissions edge. +func ConvertRolePermissions2PB(gosModel RolePermissions) (pbsModel RolePermissionsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertRolePermission2PB(model)) + } + return pbsModel +} + +// ConvertRolePermissionsPB2Object RolePermissions holds the value of the role_permissions edge. +func ConvertRolePermissionsPB2Object(pbsModel RolePermissionsPB) (gosModel RolePermissions) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertRolePermissionPB2Object(model)) + } + return gosModel +} + +type ( + PermissionResources = []*ent.PermissionResource + PermissionResourcesPB = []*typespb.PermissionResource +) + +// ConvertPermissionResources2PB PermissionResources holds the value of the permission_resources edge. +func ConvertPermissionResources2PB(gosModel PermissionResources) (pbsModel PermissionResourcesPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertPermissionResource2PB(model)) + } + return pbsModel +} + +// ConvertPermissionResourcesPB2Object PermissionResources holds the value of the permission_resources edge. +func ConvertPermissionResourcesPB2Object(pbsModel PermissionResourcesPB) (gosModel PermissionResources) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertPermissionResourcePB2Object(model)) + } + return gosModel +} + +type ( + PositionPermissions = []*ent.PositionPermission + PositionPermissionsPB = []*typespb.PositionPermission +) + +// ConvertPositionPermissions2PB PositionPermissions holds the value of the position_permissions edge. +func ConvertPositionPermissions2PB(gosModel PositionPermissions) (pbsModel PositionPermissionsPB) { + for _, model := range gosModel { + pbsModel = append(pbsModel, ConvertPositionPermission2PB(model)) + } + return pbsModel +} + +// ConvertPositionPermissionsPB2Object PositionPermissions holds the value of the position_permissions edge. +func ConvertPositionPermissionsPB2Object(pbsModel PositionPermissionsPB) (gosModel PositionPermissions) { + for _, model := range pbsModel { + gosModel = append(gosModel, ConvertPositionPermissionPB2Object(model)) + } + return gosModel +} + +type ( + PermissionEdges = ent.PermissionEdges + PermissionEdgesPB = typespb.PermissionEdges +) + +// ConvertPermissionEdges2PB PermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertPermissionEdges2PB(goModel *PermissionEdges) (pbModel *PermissionEdgesPB) { + pbModel = &PermissionEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Roles = ConvertRoles2PB(goModel.Roles) + pbModel.Resources = ConvertResources2PB(goModel.Resources) + pbModel.Positions = ConvertPositions2PB(goModel.Positions) + pbModel.RolePermissions = ConvertRolePermissions2PB(goModel.RolePermissions) + pbModel.PermissionResources = ConvertPermissionResources2PB(goModel.PermissionResources) + pbModel.PositionPermissions = ConvertPositionPermissions2PB(goModel.PositionPermissions) + return pbModel +} + +// ConvertPermissionEdgesPB2Object PermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertPermissionEdgesPB2Object(pbModel *PermissionEdgesPB) (goModel *PermissionEdges) { + goModel = &PermissionEdges{} + if pbModel == nil { + return goModel + } + + goModel.Roles = ConvertRolesPB2Object(pbModel.Roles) + goModel.Resources = ConvertResourcesPB2Object(pbModel.Resources) + goModel.Positions = ConvertPositionsPB2Object(pbModel.Positions) + goModel.RolePermissions = ConvertRolePermissionsPB2Object(pbModel.RolePermissions) + goModel.PermissionResources = ConvertPermissionResourcesPB2Object(pbModel.PermissionResources) + goModel.PositionPermissions = ConvertPositionPermissionsPB2Object(pbModel.PositionPermissions) + return goModel +} + +type ( + UserPosition = ent.UserPosition + UserPositionPB = typespb.UserPosition +) + +// ConvertUserPosition2PB user_position.table.comment +func ConvertUserPosition2PB(goModel *UserPosition) (pbModel *UserPositionPB) { + pbModel = &UserPositionPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.UserId = int64(goModel.UserID) + pbModel.PositionId = int64(goModel.PositionID) + return pbModel +} + +// ConvertUserPositionPB2Object user_position.table.comment +func ConvertUserPositionPB2Object(pbModel *UserPositionPB) (goModel *UserPosition) { + goModel = &UserPosition{} + if pbModel == nil { + return goModel + } + + //goModel.ID = int64(pbModel.Id) + goModel.UserID = int64(pbModel.UserId) + goModel.PositionID = int64(pbModel.PositionId) + return goModel +} + +type ( + UserPositionEdges = ent.UserPositionEdges + UserPositionEdgesPB = typespb.UserPositionEdges +) + +// ConvertUserPositionEdges2PB UserPositionEdges holds the relations/edges for other nodes in the graph. +func ConvertUserPositionEdges2PB(goModel *UserPositionEdges) (pbModel *UserPositionEdgesPB) { + pbModel = &UserPositionEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.User = ConvertUser2PB(goModel.User) + pbModel.Position = ConvertPosition2PB(goModel.Position) + return pbModel +} + +// ConvertUserPositionEdgesPB2Object UserPositionEdges holds the relations/edges for other nodes in the graph. +func ConvertUserPositionEdgesPB2Object(pbModel *UserPositionEdgesPB) (goModel *UserPositionEdges) { + goModel = &UserPositionEdges{} + if pbModel == nil { + return goModel + } + + goModel.User = ConvertUserPB2Object(pbModel.User) + goModel.Position = ConvertPositionPB2Object(pbModel.Position) + return goModel +} + +type ( + PositionPermission = ent.PositionPermission + PositionPermissionPB = typespb.PositionPermission +) + +// ConvertPositionPermission2PB position_permission.table.comment +func ConvertPositionPermission2PB(goModel *PositionPermission) (pbModel *PositionPermissionPB) { + pbModel = &PositionPermissionPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.PositionId = int64(goModel.PositionID) + pbModel.PermissionId = int64(goModel.PermissionID) + return pbModel +} + +// ConvertPositionPermissionPB2Object position_permission.table.comment +func ConvertPositionPermissionPB2Object(pbModel *PositionPermissionPB) (goModel *PositionPermission) { + goModel = &PositionPermission{} + if pbModel == nil { + return goModel + } + + //goModel.ID = int64(pbModel.Id) + goModel.PositionID = int64(pbModel.PositionId) + goModel.PermissionID = int64(pbModel.PermissionId) + return goModel +} + +type ( + PositionPermissionEdges = ent.PositionPermissionEdges + PositionPermissionEdgesPB = typespb.PositionPermissionEdges +) + +// ConvertPositionPermissionEdges2PB PositionPermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertPositionPermissionEdges2PB(goModel *PositionPermissionEdges) (pbModel *PositionPermissionEdgesPB) { + pbModel = &PositionPermissionEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Position = ConvertPosition2PB(goModel.Position) + pbModel.Permission = ConvertPermission2PB(goModel.Permission) + return pbModel +} + +// ConvertPositionPermissionEdgesPB2Object PositionPermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertPositionPermissionEdgesPB2Object(pbModel *PositionPermissionEdgesPB) (goModel *PositionPermissionEdges) { + goModel = &PositionPermissionEdges{} + if pbModel == nil { + return goModel + } + + goModel.Position = ConvertPositionPB2Object(pbModel.Position) + goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) + return goModel +} + +type ( + RolePermission = ent.RolePermission + RolePermissionPB = typespb.RolePermission +) + +// ConvertRolePermission2PB role_permission.table.comment +func ConvertRolePermission2PB(goModel *RolePermission) (pbModel *RolePermissionPB) { + pbModel = &RolePermissionPB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.RoleId = int64(goModel.RoleID) + pbModel.PermissionId = int64(goModel.PermissionID) + return pbModel +} + +// ConvertRolePermissionPB2Object role_permission.table.comment +func ConvertRolePermissionPB2Object(pbModel *RolePermissionPB) (goModel *RolePermission) { + goModel = &RolePermission{} + if pbModel == nil { + return goModel + } + + //goModel.ID = int64(pbModel.Id) + goModel.RoleID = int64(pbModel.RoleId) + goModel.PermissionID = int64(pbModel.PermissionId) + return goModel +} + +type ( + RolePermissionEdges = ent.RolePermissionEdges + RolePermissionEdgesPB = typespb.RolePermissionEdges +) + +// ConvertRolePermissionEdges2PB RolePermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertRolePermissionEdges2PB(goModel *RolePermissionEdges) (pbModel *RolePermissionEdgesPB) { + pbModel = &RolePermissionEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Role = ConvertRole2PB(goModel.Role) + pbModel.Permission = ConvertPermission2PB(goModel.Permission) + return pbModel +} + +// ConvertRolePermissionEdgesPB2Object RolePermissionEdges holds the relations/edges for other nodes in the graph. +func ConvertRolePermissionEdgesPB2Object(pbModel *RolePermissionEdgesPB) (goModel *RolePermissionEdges) { + goModel = &RolePermissionEdges{} + if pbModel == nil { + return goModel + } + + goModel.Role = ConvertRolePB2Object(pbModel.Role) + goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) + return goModel +} + +type ( + PermissionResource = ent.PermissionResource + PermissionResourcePB = typespb.PermissionResource +) + +// ConvertPermissionResource2PB permission_resource.table.comment +func ConvertPermissionResource2PB(goModel *PermissionResource) (pbModel *PermissionResourcePB) { + pbModel = &PermissionResourcePB{} + if goModel == nil { + return pbModel + } + + pbModel.Id = int64(goModel.ID) + pbModel.PermissionId = int64(goModel.PermissionID) + pbModel.ResourceId = int64(goModel.ResourceID) + //pbModel.Actions = goModel.Actions + return pbModel +} + +// ConvertPermissionResourcePB2Object permission_resource.table.comment +func ConvertPermissionResourcePB2Object(pbModel *PermissionResourcePB) (goModel *PermissionResource) { + goModel = &PermissionResource{} + if pbModel == nil { + return goModel + } + + //goModel.ID = int64(pbModel.Id) + goModel.PermissionID = int64(pbModel.PermissionId) + goModel.ResourceID = int64(pbModel.ResourceId) + //goModel.Actions = pbModel.Actions + return goModel +} + +type ( + PermissionResourceEdges = ent.PermissionResourceEdges + PermissionResourceEdgesPB = typespb.PermissionResourceEdges +) + +// ConvertPermissionResourceEdges2PB PermissionResourceEdges holds the relations/edges for other nodes in the graph. +func ConvertPermissionResourceEdges2PB(goModel *PermissionResourceEdges) (pbModel *PermissionResourceEdgesPB) { + pbModel = &PermissionResourceEdgesPB{} + if goModel == nil { + return pbModel + } + + pbModel.Permission = ConvertPermission2PB(goModel.Permission) + pbModel.Resource = ConvertResource2PB(goModel.Resource) + return pbModel +} + +// ConvertPermissionResourceEdgesPB2Object PermissionResourceEdges holds the relations/edges for other nodes in the graph. +func ConvertPermissionResourceEdgesPB2Object(pbModel *PermissionResourceEdgesPB) (goModel *PermissionResourceEdges) { + goModel = &PermissionResourceEdges{} + if pbModel == nil { + return goModel + } + + goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) + goModel.Resource = ConvertResourcePB2Object(pbModel.Resource) + return goModel +} diff --git a/internal/mods/datastore/dto/menu.go b/internal/mods/datastore/dto/menu.go new file mode 100644 index 00000000..9568d083 --- /dev/null +++ b/internal/mods/datastore/dto/menu.go @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto is the data transfer object package for the system module. +package dto + +import ( + "github.com/origadmin/runtime/interfaces/pagination" + + pb "origadmin/application/admin/api/v1/services/system" +) + +type ( + ListMenusRequest = pb.ListMenusRequest + ListMenusResponse = pb.ListMenusResponse +) + +// MenuRepo is a Menu repository interface. +type MenuRepo interface { + //Get(context.Context, int64, ...MenuQueryOption) (*MenuPB, error) + //Create(context.Context, *MenuPB, ...MenuQueryOption) (*MenuPB, error) + //Delete(context.Context, int64) error + //Update(context.Context, *MenuPB, ...MenuQueryOption) (*MenuPB, error) + //List(context.Context, *ListMenusRequest, ...MenuQueryOption) ([]*MenuPB, int32, error) +} + +type MenuQueryOption struct { + Name string `form:"name" json:"name,omitempty"` + Status int8 `form:"status" json:"status,omitempty"` + InIDs []int64 `form:"-" json:"-"` + UserID int64 `form:"-" json:"-"` // UserPB ID + RoleID int64 `form:"-" json:"-"` // RolePB ID + ParentID int64 `form:"-" json:"-"` // Parent ID + ParentPathPrefix string `form:"-" json:"-"` + IncludeResources bool `form:"-" json:"-"` // Include resources + SelectFields []string + OmitFields []string + OrderFields []string + Fields []string +} + +func (o MenuQueryOption) FromListRequest(in *ListMenusRequest, limiter pagination.PageLimiter) error { + in.Current = limiter.Current(in.Current) + in.PageSize = limiter.PerPage(in.PageSize) + return nil +} + +func (o MenuQueryOption) FromGetRequest(in *pb.GetMenuRequest, limiter pagination.PageLimiter) error { + return nil +} + +func (o MenuQueryOption) FromCreateRequest(in *pb.CreateMenuRequest, limiter pagination.PageLimiter) error { + return nil +} + +// +//func ToListMenusResponse(result []*MenuPB, in *ListMenusRequest, total int32, args ...any) (*ListMenusResponse, error) { +// response := &ListMenusResponse{ +// TotalSize: total, +// Current: in.Current, +// PageSize: in.PageSize, +// Menus: result, +// Extra: resp.Any(args...), +// } +// return response, nil +//} +// +//func ConvertMenus(menus []*Menu) []*MenuPB { +// var result []*MenuPB +// for _, menu := range menus { +// result = append(result, ConvertMenu2PB(menu)) +// } +// return result +//} diff --git a/internal/mods/datastore/dto/permission.go b/internal/mods/datastore/dto/permission.go new file mode 100644 index 00000000..39dd6487 --- /dev/null +++ b/internal/mods/datastore/dto/permission.go @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto is the data transfer object package for the system module. +package dto + +import ( + "context" + + "github.com/origadmin/runtime/interfaces/pagination" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/resp" +) + +type ( + ListPermissionsRequest = pb.ListPermissionsRequest + ListPermissionsResponse = pb.ListPermissionsResponse +) + +type PermissionNode struct { + PermissionPB + ResourceKeywords []string `json:"resource_keywords"` +} + +// PermissionRepo is a Permission repository interface. +type PermissionRepo interface { + Get(context.Context, int64, ...PermissionQueryOption) (*PermissionPB, error) + Create(context.Context, *PermissionPB, ...PermissionQueryOption) (*PermissionPB, error) + Delete(context.Context, int64) error + Update(context.Context, *PermissionPB, ...PermissionQueryOption) (*PermissionPB, error) + List(context.Context, *ListPermissionsRequest, ...PermissionQueryOption) ([]*PermissionPB, int32, error) +} + +type PermissionQueryOption struct { + Name string `form:"name" json:"name,omitempty"` + Status int8 `form:"status" json:"status,omitempty"` + InIDs []string `form:"-" json:"-"` + UserID string `form:"-" json:"-"` // UserPB ID + RoleID string `form:"-" json:"-"` // RolePB ID + ParentID string `form:"-" json:"-"` // Parent ID + ParentPathPrefix string `form:"-" json:"-"` + SelectFields []string + OmitFields []string + OrderFields []string + Fields []string + IncludeResources bool + IncludeRoles bool +} + +func (o PermissionQueryOption) FromListRequest(in *ListPermissionsRequest, limiter pagination.PageLimiter) error { + in.Current = limiter.Current(in.Current) + in.PageSize = limiter.PerPage(in.PageSize) + return nil +} + +func (o PermissionQueryOption) FromGetRequest(in *pb.GetPermissionRequest, limiter pagination.PageLimiter) error { + return nil +} + +func (o PermissionQueryOption) FromCreateRequest(in *pb.CreatePermissionRequest, limiter pagination.PageLimiter) error { + return nil +} + +func ToListPermissionsResponse(result []*PermissionPB, in *ListPermissionsRequest, total int32, args ...any) (*ListPermissionsResponse, error) { + response := &ListPermissionsResponse{ + TotalSize: total, + Current: in.Current, + PageSize: in.PageSize, + Permissions: result, + Extra: resp.Any(args...), + } + return response, nil +} + +func ConvertPermissions(permissions []*Permission) []*PermissionPB { + var result []*PermissionPB + for _, permission := range permissions { + result = append(result, ConvertPermission2PB(permission)) + } + return result +} diff --git a/internal/mods/datastore/dto/position.go b/internal/mods/datastore/dto/position.go new file mode 100644 index 00000000..6d294141 --- /dev/null +++ b/internal/mods/datastore/dto/position.go @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto implements the functions, types, and interfaces for the module. +package dto + +// PositionNode position.table.comment +type PositionNode struct { + PositionPB + DepartmentKeyword string `json:"department_keyword,omitempty"` +} diff --git a/internal/mods/datastore/dto/resource.go b/internal/mods/datastore/dto/resource.go new file mode 100644 index 00000000..74a0c30a --- /dev/null +++ b/internal/mods/datastore/dto/resource.go @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto is the data transfer object package for the system module. +package dto + +import ( + "context" + + "github.com/origadmin/runtime/interfaces/pagination" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/resp" +) + +type ( + ListResourcesRequest = pb.ListResourcesRequest + ListResourcesResponse = pb.ListResourcesResponse +) + +type ResourceNode struct { + ResourcePB + Children []*ResourceNode `json:"children"` +} + +// ResourceRepo is a Resource repository interface. +type ResourceRepo interface { + Get(context.Context, int64, ...ResourceQueryOption) (*ResourcePB, error) + Create(context.Context, *ResourcePB, ...ResourceQueryOption) (*ResourcePB, error) + Delete(context.Context, int64) error + Update(context.Context, *ResourcePB, ...ResourceQueryOption) (*ResourcePB, error) + List(context.Context, *ListResourcesRequest, ...ResourceQueryOption) ([]*ResourcePB, int32, error) +} + +type ResourceQueryOption struct { + Name string `form:"name" json:"name,omitempty"` + Status int8 `form:"status" json:"status,omitempty"` + InIDs []string `form:"-" json:"-"` + UserID string `form:"-" json:"-"` // UserPB ID + RoleID string `form:"-" json:"-"` // RolePB ID + ParentID string `form:"-" json:"-"` // Parent ID + ParentPathPrefix string `form:"-" json:"-"` + IncludeResources bool `form:"-" json:"-"` // Include resources + IncludePermissions bool `form:"-" json:"-"` + SelectFields []string + OmitFields []string + OrderFields []string + Fields []string +} + +func (o ResourceQueryOption) FromListRequest(in *ListResourcesRequest, limiter pagination.PageLimiter) error { + in.Current = limiter.Current(in.Current) + in.PageSize = limiter.PerPage(in.PageSize) + return nil +} + +func (o ResourceQueryOption) FromGetRequest(in *pb.GetResourceRequest, limiter pagination.PageLimiter) error { + return nil +} + +func (o ResourceQueryOption) FromCreateRequest(in *pb.CreateResourceRequest, limiter pagination.PageLimiter) error { + return nil +} + +func ToListResourcesResponse(result []*ResourcePB, in *ListResourcesRequest, total int32, args ...any) (*ListResourcesResponse, error) { + response := &ListResourcesResponse{ + TotalSize: total, + Current: in.Current, + PageSize: in.PageSize, + Resources: result, + Extra: resp.Any(args...), + } + return response, nil +} + +func ConvertResources(resources []*Resource) []*ResourcePB { + var result []*ResourcePB + for _, resource := range resources { + result = append(result, ConvertResource2PB(resource)) + } + return result +} diff --git a/internal/mods/datastore/dto/resource_type.go b/internal/mods/datastore/dto/resource_type.go new file mode 100644 index 00000000..f3b265fa --- /dev/null +++ b/internal/mods/datastore/dto/resource_type.go @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto implements the functions, types, and interfaces for the module. +package dto + +import ( + "origadmin/application/admin/internal/data/entity/ent/schema" +) + +const ( + ResourceTypeRoot = schema.ResourceTypeRoot + ResourceTypeGroup = schema.ResourceTypeGroup + ResourceTypeMenu = schema.ResourceTypeMenu + ResourceTypePage = schema.ResourceTypePage + ResourceTypeButton = schema.ResourceTypeButton + ResourceTypeAPI = schema.ResourceTypeAPI + ResourceTypeRedirect = schema.ResourceTypeRedirect + ResourceTypeUnknown = schema.ResourceTypeUnknown +) + +// ResourceTypeName returns the name of the resource type +func ResourceTypeName(str string) string { + switch str { + case ResourceTypeMenu: + return "Menu" + case ResourceTypePage: + return "Page" + case ResourceTypeButton: + return "Button" + case ResourceTypeAPI: + return "API" + case ResourceTypeRedirect: + return "Redirect" + case ResourceTypeRoot: + return "ROOT" + case ResourceTypeGroup: + return "Group" + default: + return "Unknown" + } +} + +// ResourceTypeCode returns the code of the resource type +func ResourceTypeCode(s string) string { + switch s { + case "Menu": + return ResourceTypeMenu + case "Page": + return ResourceTypePage + case "Button": + return ResourceTypeButton + case "API": + return ResourceTypeAPI + case "Redirect": + return ResourceTypeRedirect + case "ROOT": + return ResourceTypeRoot + case "Group": + return ResourceTypeGroup + default: + return ResourceTypeUnknown + } +} diff --git a/internal/mods/datastore/dto/role.go b/internal/mods/datastore/dto/role.go new file mode 100644 index 00000000..0ddbc33c --- /dev/null +++ b/internal/mods/datastore/dto/role.go @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto is the data transfer object package for the system module. +package dto + +import ( + "context" + "time" + + "github.com/origadmin/runtime/interfaces/pagination" + "google.golang.org/protobuf/proto" + + pb "origadmin/application/admin/api/v1/services/system" + typespb "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/helpers/resp" + "origadmin/application/admin/internal/data/entity/ent" +) + +type ( + RoleEdges = ent.RoleEdges + RoleEdgesPB = typespb.RoleEdges + + ListRolesRequest = pb.ListRolesRequest + ListRolesResponse = pb.ListRolesResponse +) + +// RoleRepo is a RolePB repository interface. +type RoleRepo interface { + Get(context.Context, int64, ...RoleQueryOption) (*RolePB, error) + List(context.Context, *ListRolesRequest, ...RoleQueryOption) ([]*RolePB, int32, error) + Create(context.Context, *RolePB, ...RoleUpdateOption) (*RolePB, error) + Update(context.Context, *RolePB, ...RoleUpdateOption) (*RolePB, error) + Delete(context.Context, int64) error +} + +type RoleQueryOption struct { + Name string `form:"name" json:"name,omitempty"` + Status int8 `form:"status" json:"status,omitempty"` + InIDs []int64 `form:"-" json:"-"` + UpdateTimeGT *time.Time + SelectFields []string + OmitFields []string + OrderFields []string + Fields []string + IncludePermissions bool +} + +func (o RoleQueryOption) FromListRequest(in *ListRolesRequest, limiter pagination.PageLimiter) error { + in.Current = limiter.Current(in.Current) + in.PageSize = limiter.PerPage(in.PageSize) + return nil +} + +func (o RoleQueryOption) FromGetRequest(in *pb.GetRoleRequest, limiter pagination.PageLimiter) error { + return nil +} + +func (o RoleQueryOption) FromCreateRequest(in *pb.CreateRoleRequest, limiter pagination.PageLimiter) error { + return nil +} + +// RoleUpdateOption is used for creating and updating roles. +type RoleUpdateOption struct { + Name string `form:"name" json:"name,omitempty"` + Status int8 `form:"status" json:"status,omitempty"` + UpdateTimeGT *time.Time + SelectFields []string + OmitFields []string + OrderFields []string + Fields []string + IncludePermissions bool +} + +func (o RoleUpdateOption) FromCreateRequest(in *pb.CreateRoleRequest) error { + return nil +} + +func (o RoleUpdateOption) FromUpdateRequest(in *pb.UpdateRoleRequest) error { + return nil +} + +func ToListRolesResponse(result []*RolePB, in *ListRolesRequest, total int32, args ...any) (*ListRolesResponse, error) { + response := &ListRolesResponse{ + TotalSize: total, + Current: in.Current, + PageSize: in.PageSize, + Roles: result, + Extra: resp.Any(args...), + } + return response, nil +} + +func ConvertRoles(roles []*Role) []*RolePB { + var result []*RolePB + for _, role := range roles { + result = append(result, ConvertRole2PB(role)) + } + return result +} + +type RoleQueryResult struct { + Current int `json:"current"` + PageSize int `json:"page_size"` + Data []*RolePB `json:"data"` + Total int64 `json:"total"` + Args map[string]proto.Message `json:"args"` +} diff --git a/internal/mods/datastore/dto/user.go b/internal/mods/datastore/dto/user.go new file mode 100644 index 00000000..b9eb649b --- /dev/null +++ b/internal/mods/datastore/dto/user.go @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto is the data transfer object package for the system module. +package dto + +import ( + "context" + + "github.com/google/uuid" + "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/crypto/hash" + "github.com/origadmin/toolkits/crypto/rand" + + pb "origadmin/application/admin/api/v1/services/system" + typespb "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/helpers/id" + "origadmin/application/admin/helpers/resp" + "origadmin/application/admin/internal/data/entity/ent" +) + +type ( + UserRole = ent.UserRole + UserRolePB = typespb.UserRole + UserRoleEdges = ent.UserRoleEdges + UserRoleEdgesPB = typespb.UserRoleEdges + + ListUsersRequest = pb.ListUsersRequest + ListUsersResponse = pb.ListUsersResponse +) + +type UserNode struct { + UserPB + IsSystem bool `json:"is_system"` + RoleKeywords []string `json:"role_keywords"` + EncryptedPassword string `json:"encrypted_password"` +} + +// UserRepo is a UserPB repository interface. +type UserRepo interface { + Get(context.Context, int64, ...UserQueryOption) (*UserPB, error) + Create(context.Context, *UserPB, ...UserMutationOption) (*UserPB, error) + Delete(context.Context, int64) error + Update(context.Context, *UserPB, ...UserMutationOption) (*UserPB, error) + List(context.Context, *ListUsersRequest, ...UserQueryOption) ([]*UserPB, int32, error) + AddRoleIDs(context.Context, int64, []int64, ...UserMutationOption) error + GetByUsername(context.Context, string, ...string) (*UserNode, error) + GetRoleIDs(context.Context, int64) ([]int64, error) + ListResourceByUserID(context.Context, int64, ...UserQueryOption) ([]*ResourcePB, error) + Current(context.Context, int64) (*UserPB, error) + UpdateUserStatus(ctx context.Context, id int64, status int8, options ...UserQueryOption) error +} + +type UserMutationOption struct { + RandomPasswd bool + NoPasswd bool + Fields []string +} + +type UserQueryOption struct { + IncludeRoles bool + IsSystem bool + NoPasswd bool + RandomPasswd bool + Status int8 `form:"status" json:"status,omitempty"` + SelectFields []string + OmitFields []string + OrderFields []string + Fields []string +} + +func (o *UserQueryOption) FromListRequest(in *ListUsersRequest, limiter pagination.PageLimiter) error { + in.Current = limiter.Current(in.Current) + in.PageSize = limiter.PerPage(in.PageSize) + return nil +} + +func (o *UserQueryOption) FromGetRequest(in *pb.GetUserRequest, limiter pagination.PageLimiter) error { + return nil +} + +func (o *UserMutationOption) FromCreateRequest(in *pb.CreateUserRequest, limiter pagination.PageLimiter) error { + o.RandomPasswd = in.RandomPassword + return nil +} + +func ToListUsersResponse(result []*UserPB, in *ListUsersRequest, total int32, args ...any) (*ListUsersResponse, error) { + response := &ListUsersResponse{ + TotalSize: total, + Current: in.Current, + PageSize: in.PageSize, + Users: result, + Extra: resp.Any(args...), + } + + return response, nil +} + +func ConvertUsers(users []*User) []*UserPB { + var result []*UserPB + for _, user := range users { + result = append(result, ConvertUser2PB(user)) + } + return result +} + +// MakeCreateUser functions are used to create new users +func MakeCreateUser(user *UserPB, username, password string, option UserMutationOption) (*UserPB, string, error) { + log.Debugf("Creating user with options: %+v", option) + if !option.NoPasswd { + log.Debugf("NoPasswd is false, checking for RandomPasswd") + if option.RandomPasswd && (user.Email != "" || user.Phone != "") { + log.Debugf("RandomPasswd is true and user has email or phone, generating random password") + password = rand.GenerateRandom(8) + log.Debugf("Generated random password: %s", password) + } else { + log.Debugf("RandomPasswd is false or user has no email or phone") + } + } else { + log.Debugf("NoPasswd is true, setting password to empty string") + password = "" + } + var err error + if password != "" { + log.Debugf("Password is not empty, generating salt") + //user.Salt = rand.GenerateSalt() + //log.Debugf("Generated salt: %s", user.Salt) + user.Password, err = hash.Generate(password) + if err != nil { + log.Errorf("Error generating password hash: %v", err) + return nil, "", err + } + log.Debugf("Generated password hash: %s", user.Password) + } + registerID := id.Gen() + user.Id = registerID + user.Uuid = uuid.Must(uuid.NewRandom()).String() + user.Username = username + user.Name = "user_" + random.RandString(8) + user.Status = 1 + return user, password, nil +} + +var random = rand.NewRand(rand.KindDigit | rand.KindLowerCase | rand.KindUpperCase) diff --git a/internal/mods/datastore/server/README.md b/internal/mods/datastore/server/README.md new file mode 100644 index 00000000..be23f4ff --- /dev/null +++ b/internal/mods/datastore/server/README.md @@ -0,0 +1,4 @@ +# Server + +This directory contains the server code. + diff --git a/internal/mods/datastore/server/gins.go b/internal/mods/datastore/server/gins.go new file mode 100644 index 00000000..26373997 --- /dev/null +++ b/internal/mods/datastore/server/gins.go @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package server + +import ( + "net/url" + + "github.com/origadmin/contrib/transport/gins" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/middleware" + "github.com/origadmin/runtime/service" + "github.com/origadmin/toolkits/env" + "github.com/origadmin/toolkits/net" + + "origadmin/application/admin/internal/configs" +) + +// NewGINSServer new a gin server. +func NewGINSServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.ServerOption) *gins.Server { + ms := middleware.NewServer(bootstrap.GetMiddleware()) + //option := settings.ApplyOrZero(ss...) + var opts = []gins.ServerOption{ + gins.Middleware(ms...), + } + //serviceConfig := bootstrap.GetService() + //cfg := serviceConfig.GetGins() + //if cfg == nil { + // return nil + //} + // + //if cfg.Network != "" { + // opts = append(opts, gins.Network(cfg.Network)) + //} + //if cfg.Addr != "" { + // opts = append(opts, gins.Address(cfg.Addr)) + //} + //if cfg.Timeout != nil { + // opts = append(opts, gins.Timeout(cfg.Timeout.AsDuration())) + //} + + //middlewares, err := bootstrap.LoadMiddlewares(bootstrap.GetServiceName(), bootstrap, l) + //if err == nil && len(middlewares) > 0 { + // opts = append(opts, http.Middleware(middlewares...)) + //} + + if l != nil { + opts = append(opts, gins.WithLogger(log.With(l, "module", "gins"))) + } + log.Infof("GetHostName: %s", env.Var(runtime.DefaultEnvPrefix, "host")) + hostVar := env.Var(runtime.DefaultEnvPrefix, "host") + hostIP := env.GetEnv(env.Var(runtime.DefaultEnvPrefix, "host_ip")) + if hostIP == "" { + log.Debugf("HostIP is empty, replacing with HostAddr: %s", hostVar) + hostIP = net.HostAddr(net.WithEnvVar(hostVar)) + log.Debugf("HostIP after replacement: %s", hostIP) + } + + var endpoint string + log.Debugf("GINS.Endpoint: %v", endpoint) + ep, _ := url.Parse(endpoint) + opts = append(opts, gins.Endpoint(ep)) + srv := gins.NewServer(opts...) + return srv +} diff --git a/internal/mods/datastore/server/grpc.go b/internal/mods/datastore/server/grpc.go new file mode 100644 index 00000000..43cb5ac0 --- /dev/null +++ b/internal/mods/datastore/server/grpc.go @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package server + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/service" + + "origadmin/application/admin/internal/configs" +) + +// NewGRPCServer new a gRPC server. +func NewGRPCServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.GRPCServer { + services := bootstrap.GetServer().GetServices() + for _, serviceConfig := range services { + if serviceConfig.GetType() == "grpc" { + grpcServer, err := r.Builder().NewGRPCServer(serviceConfig) + if err != nil { + return nil + } + return grpcServer + } + } + return nil +} diff --git a/internal/mods/datastore/server/http.go b/internal/mods/datastore/server/http.go new file mode 100644 index 00000000..f1be2682 --- /dev/null +++ b/internal/mods/datastore/server/http.go @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package server + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/service" + + "origadmin/application/admin/internal/configs" +) + +// NewHTTPServer new an HTTP server. +func NewHTTPServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.HTTPServer { + services := bootstrap.GetServer().GetServices() + for _, serviceConfig := range services { + if serviceConfig.GetType() == "http" { + httpServer, err := r.Builder().NewHTTPServer(serviceConfig) + if err != nil { + return nil + } + return httpServer + } + } + return nil +} diff --git a/internal/mods/datastore/server/server.go b/internal/mods/datastore/server/server.go new file mode 100644 index 00000000..1fc8a7bd --- /dev/null +++ b/internal/mods/datastore/server/server.go @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package server + +import ( + "github.com/go-kratos/kratos/v2/metadata" + "github.com/go-kratos/kratos/v2/transport" + "github.com/google/wire" + "github.com/origadmin/runtime" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/middleware" + "github.com/origadmin/runtime/service" + servicegrpc "github.com/origadmin/runtime/service/grpc" + servicehttp "github.com/origadmin/runtime/service/http" + "github.com/origadmin/toolkits/errors" + + "origadmin/application/admin/internal/configs" + systemservice "origadmin/application/admin/internal/mods/system/service" +) + +const ( + // ServiceName is service name. + ServiceName = "system" +) + +var ( + // ProviderSet is server providers. + ProviderSet = wire.NewSet( + NewSystemClient, + NewSystemServer, + ) +) + +func init() { + runtime.RegisterService(ServiceName, service.DefaultServiceFactory) +} + +func NewSystemServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc systemservice.SystemServerRegistrar) []transport. +Server { + var servers []transport.Server + serverConfig := bootstrap.GetServer() + if serverConfig == nil { + return servers + } + + ll := log.NewHelper(r.WithLogger("module", "system/server")) + middlewares := r.Builder().Middleware().BuildServer(bootstrap.GetServer().GetMiddleware()) + services := bootstrap.GetServer().GetServices() + coreinfo := bootstrap.GetServer().GetCore() + for _, serviceConfig := range services { + ll.Infow("msg", "service init", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) + var option service.ServerOption + switch serviceConfig.GetType() { + case "grpc": + options := []servicegrpc.Option{ + servicegrpc.WithMiddlewares(middlewares...), + servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), + } + option = service.WithGRPC(options...) + case "http": + options := []servicehttp.Option{ + servicehttp.WithMiddlewares(middlewares...), + servicehttp.WithPrefix(runtime.DefaultEnvPrefix), + } + //httpServer, err := r.Builder().NewServer(serviceConfig, options...) + //if err != nil { + // continue + //} + //ll.Infow("msg", "http server init", "name", coreinfo.GetName(), "version", + // coreinfo.GetVersion()) + //svc.Register(r.Context(), httpServer) + //servers = append(servers, httpServer) + option = service.WithHTTP(options...) + default: + ll.Warnw("msg", "service type not support", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) + continue + } + grpcServer, err := r.Builder().NewServer("system", serviceConfig, option) + if err != nil { + continue + } + ll.Infow("msg", "system server init", "name", coreinfo.GetName(), "version", + coreinfo.GetVersion()) + svc.Register(r.Context(), grpcServer) + servers = append(servers, grpcServer) + } + return servers +} + +func NewSystemClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service.GRPCClient, error) { + discovery := bootstrap.GetDiscovery() + if discovery == nil { + return nil, errors.New("no discovery") + } + serviceConfig := &configv1.Service{ + Name: ServiceName, + //Grpc: entry.GetGrpc(), + //Http: entry.GetHttp(), + Selector: &configv1.Service_Selector{ + Version: "v1.0.0", + Builder: "bbr", + }, + } + //if v, ok := bootstrap.GetServices()[ServiceName]; ok { + // discovery.ServiceName = ServiceName + //} + helper := log.NewHelper(r.Logger()) + //discovery.ServiceName = ServiceName + helper.Infof("service name: %s", discovery.ServiceName) + discover, err := runtime.NewDiscovery(discovery) + if err != nil { + return nil, errors.Wrap(err, "create discovery") + } + var ms []middleware.KMiddleware + options := []servicegrpc.Option{ + servicegrpc.WithDiscovery(discovery.ServiceName, discover), + } + ms = append(ms, middleware.NewClient(bootstrap.GetMiddleware())...) + ms = append(ms, MiddlewareServer()) + if len(ms) > 0 { + options = append(options, servicegrpc.WithMiddlewares(ms...)) + } + client, err := runtime.NewGRPCServiceClient(context.Background(), serviceConfig, options...) + if err != nil { + return nil, errors.Wrap(err, "create menu grpc client") + } + return client, nil +} + +func MiddlewareServer() middleware.KMiddleware { + return func(handler middleware.KHandler) middleware.KHandler { + return func(ctx context.Context, req interface{}) (reply interface{}, err error) { + if md, ok := metadata.FromClientContext(ctx); ok { + log.Debugf("MiddlewareServer: found client context metadata: %+v", md) + } else { + log.Debugf("MiddlewareServer: no client context metadata found") + } + if md, ok := metadata.FromServerContext(ctx); ok { + log.Debugf("MiddlewareServer: found server context metadata: %+v", md) + } else { + log.Debugf("MiddlewareServer: no server context metadata found") + } + reply, err = handler(ctx, req) + return + } + } +} diff --git a/internal/mods/datastore/service/README.md b/internal/mods/datastore/service/README.md new file mode 100644 index 00000000..5748d401 --- /dev/null +++ b/internal/mods/datastore/service/README.md @@ -0,0 +1,3 @@ +# Service + +This directory contains the business logic for the service. diff --git a/internal/mods/datastore/service/menu.bridge.go b/internal/mods/datastore/service/menu.bridge.go new file mode 100644 index 00000000..a125a63b --- /dev/null +++ b/internal/mods/datastore/service/menu.bridge.go @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "encoding/json" + "net/http" + + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/resp" +) + +// MenuServiceHookedBridge is a menu service. +type MenuServiceHookedBridge struct { + pb.UnimplementedMenuServiceHooked + log *log.KHelper +} + +func (h MenuServiceHookedBridge) CompleteCreateMenu(ctx transhttp.Context, request *pb.CreateMenuRequest, response *pb.CreateMenuResponse) error { + marshal, err := json.Marshal(response.Menu) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func (h MenuServiceHookedBridge) CompleteDeleteMenu(ctx transhttp.Context, request *pb.DeleteMenuRequest, response *pb.DeleteMenuResponse) error { + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: nil, + }) +} + +func (h MenuServiceHookedBridge) CompleteGetMenu(ctx transhttp.Context, request *pb.GetMenuRequest, response *pb.GetMenuResponse) error { + marshal, err := json.Marshal(response.Menu) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func (h MenuServiceHookedBridge) CompleteListMenus(ctx transhttp.Context, request *pb.ListMenusRequest, response *pb.ListMenusResponse) error { + if response == nil { + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: false, + Data: nil, + }) + } + marshal, err := resp.Proto2JSON(response.Menus...) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: response.TotalSize, + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), + }) +} + +func (h MenuServiceHookedBridge) CompleteUpdateMenu(ctx transhttp.Context, request *pb.UpdateMenuRequest, response *pb.UpdateMenuResponse) error { + marshal, err := json.Marshal(response.Menu) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func NewMenuServiceHookedBridge(r runtime.Runtime, client pb.MenuServiceHTTPServer) pb.MenuServiceHookedBridger { + return pb.WithMenuServiceHook(&MenuServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/system")), + })(client) +} + +// NewMenuServiceBridge new a menu service. +func NewMenuServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.MenuServiceServer { + return pb.NewMenuServiceBridge(client) +} + +func NewMenuServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.MenuServiceServer { + if c, ok := clients["system"]; ok { + return pb.NewMenuServiceBridge(c) + } else { + return pb.UnimplementedMenuServiceServer{} + } +} + +// NewMenuServiceHTTPBridge new a menu service. +func NewMenuServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.MenuServiceHTTPServer { + return pb.NewMenuServiceHTTPBridge(client) +} + +var _ pb.MenuServiceHooker = (*MenuServiceHookedBridge)(nil) diff --git a/internal/mods/datastore/service/menu.grpc.go b/internal/mods/datastore/service/menu.grpc.go new file mode 100644 index 00000000..8100b343 --- /dev/null +++ b/internal/mods/datastore/service/menu.grpc.go @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" +) + +// MenuServiceServer is a menu service. +type MenuServiceServer struct { + pb.UnimplementedMenuServiceServer + + client pb.MenuServiceClient + log *log.KHelper +} + +func (s MenuServiceServer) ListMenus(ctx context.Context, request *pb.ListMenusRequest) (*pb.ListMenusResponse, error) { + return s.client.ListMenus(ctx, request) +} + +func (s MenuServiceServer) GetMenu(ctx context.Context, request *pb.GetMenuRequest) (*pb.GetMenuResponse, error) { + return s.client.GetMenu(ctx, request) +} + +func (s MenuServiceServer) CreateMenu(ctx context.Context, request *pb.CreateMenuRequest) (*pb.CreateMenuResponse, error) { + return s.client.CreateMenu(ctx, request) +} + +func (s MenuServiceServer) UpdateMenu(ctx context.Context, request *pb.UpdateMenuRequest) (*pb.UpdateMenuResponse, error) { + return s.client.UpdateMenu(ctx, request) +} + +func (s MenuServiceServer) DeleteMenu(ctx context.Context, request *pb.DeleteMenuRequest) (*pb.DeleteMenuResponse, error) { + return s.client.DeleteMenu(ctx, request) +} + +//func (m MenuServiceServer) mustEmbedUnimplementedMenuServiceServer() { +// //TODO implement me +// panic("implement me") +//} + +// NewMenuServiceServer new a menu service. +func NewMenuServiceServer(client pb.MenuServiceClient, logger log.KLogger) *MenuServiceServer { + return &MenuServiceServer{ + log: log.NewHelper(logger), + client: client, + } +} + +// NewMenuServiceServerPB new a menu service. +func NewMenuServiceServerPB(r runtime.Runtime, client pb.MenuServiceClient) pb.MenuServiceServer { + return NewMenuServiceServer(client, r.WithLogger("module", "service/system")) +} + +var _ pb.MenuServiceServer = (*MenuServiceServer)(nil) diff --git a/internal/mods/datastore/service/menu.http.go b/internal/mods/datastore/service/menu.http.go new file mode 100644 index 00000000..1ee6e627 --- /dev/null +++ b/internal/mods/datastore/service/menu.http.go @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" +) + +// MenuServiceHTTPServer is a menu service. +type MenuServiceHTTPServer struct { + pb.UnimplementedMenuServiceServer + + client pb.MenuServiceHTTPClient + log *log.KHelper +} + +func (s MenuServiceHTTPServer) CreateMenu(ctx context.Context, request *pb.CreateMenuRequest) (*pb.CreateMenuResponse, error) { + return s.client.CreateMenu(ctx, request) +} + +func (s MenuServiceHTTPServer) DeleteMenu(ctx context.Context, request *pb.DeleteMenuRequest) (*pb.DeleteMenuResponse, error) { + return s.client.DeleteMenu(ctx, request) +} + +func (s MenuServiceHTTPServer) GetMenu(ctx context.Context, request *pb.GetMenuRequest) (*pb.GetMenuResponse, error) { + return s.client.GetMenu(ctx, request) +} + +func (s MenuServiceHTTPServer) ListMenus(ctx context.Context, request *pb.ListMenusRequest) (*pb.ListMenusResponse, error) { + return s.client.ListMenus(ctx, request) +} + +func (s MenuServiceHTTPServer) UpdateMenu(ctx context.Context, request *pb.UpdateMenuRequest) (*pb.UpdateMenuResponse, error) { + return s.client.UpdateMenu(ctx, request) +} + +//func (m MenuServiceHTTPServer) mustEmbedUnimplementedMenuServiceHTTPServer() { +// //TODO implement me +// panic("implement me") +//} + +// NewMenuServiceHTTPServer new a menu service. +func NewMenuServiceHTTPServer(client pb.MenuServiceHTTPClient, logger log.KLogger) *MenuServiceHTTPServer { + return &MenuServiceHTTPServer{ + client: client, + log: log.NewHelper(logger), + } +} + +// NewMenuServiceHTTPServerPB new a menu service. +func NewMenuServiceHTTPServerPB(r runtime.Runtime, client pb.MenuServiceHTTPClient) pb.MenuServiceHTTPServer { + return NewMenuServiceHTTPServer(client, r.WithLogger("module", "service/system")) +} + +var _ pb.MenuServiceServer = (*MenuServiceHTTPServer)(nil) diff --git a/internal/mods/datastore/service/permission.bridge.go b/internal/mods/datastore/service/permission.bridge.go new file mode 100644 index 00000000..d575a36d --- /dev/null +++ b/internal/mods/datastore/service/permission.bridge.go @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "encoding/json" + "net/http" + + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/resp" +) + +// PermissionServiceHookedBridge is a menu service. +type PermissionServiceHookedBridge struct { + pb.UnimplementedPermissionServiceHooked + log *log.KHelper +} + +func (h PermissionServiceHookedBridge) CompleteCreatePermission(ctx transhttp.Context, request *pb.CreatePermissionRequest, response *pb.CreatePermissionResponse) error { + marshal, err := json.Marshal(response.Permission) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func (h PermissionServiceHookedBridge) CompleteDeletePermission(ctx transhttp.Context, request *pb.DeletePermissionRequest, response *pb.DeletePermissionResponse) error { + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: nil, + }) +} + +func (h PermissionServiceHookedBridge) CompleteGetPermission(ctx transhttp.Context, request *pb.GetPermissionRequest, response *pb.GetPermissionResponse) error { + marshal, err := json.Marshal(response.Permission) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func (h PermissionServiceHookedBridge) CompleteListPermissions(ctx transhttp.Context, request *pb.ListPermissionsRequest, response *pb.ListPermissionsResponse) error { + if response == nil { + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: false, + Data: nil, + }) + } + marshal, err := resp.Proto2JSON(response.Permissions...) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: response.TotalSize, + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), + }) +} + +func (h PermissionServiceHookedBridge) CompleteUpdatePermission(ctx transhttp.Context, request *pb.UpdatePermissionRequest, response *pb.UpdatePermissionResponse) error { + marshal, err := json.Marshal(response.Permission) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func NewPermissionServiceHookedBridge(r runtime.Runtime, client pb.PermissionServiceHTTPServer) pb.PermissionServiceHookedBridger { + return pb.WithPermissionServiceHook(&PermissionServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/system")), + })(client) +} + +// NewPermissionServiceBridge new a menu service. +func NewPermissionServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.PermissionServiceServer { + return pb.NewPermissionServiceBridge(client) +} + +func NewPermissionServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.PermissionServiceServer { + if c, ok := clients["system"]; ok { + return pb.NewPermissionServiceBridge(c) + } else { + return pb.UnimplementedPermissionServiceServer{} + } +} + +// NewPermissionServiceHTTPBridge new a menu service. +func NewPermissionServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.PermissionServiceHTTPServer { + return pb.NewPermissionServiceHTTPBridge(client) +} + +var _ pb.PermissionServiceHooker = (*PermissionServiceHookedBridge)(nil) diff --git a/internal/mods/datastore/service/permission.grpc.go b/internal/mods/datastore/service/permission.grpc.go new file mode 100644 index 00000000..5a4d716c --- /dev/null +++ b/internal/mods/datastore/service/permission.grpc.go @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/biz" +) + +// PermissionServiceServer is a menu service. +type PermissionServiceServer struct { + pb.UnimplementedPermissionServiceServer + + client *biz.PermissionServiceBiz + log *log.KHelper +} + +func (s PermissionServiceServer) ListPermissions(ctx context.Context, request *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { + return s.client.ListPermissions(ctx, request) +} + +func (s PermissionServiceServer) GetPermission(ctx context.Context, request *pb.GetPermissionRequest) (*pb.GetPermissionResponse, error) { + return s.client.GetPermission(ctx, request) +} + +func (s PermissionServiceServer) CreatePermission(ctx context.Context, request *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { + return s.client.CreatePermission(ctx, request) +} + +func (s PermissionServiceServer) UpdatePermission(ctx context.Context, request *pb.UpdatePermissionRequest) (*pb.UpdatePermissionResponse, error) { + return s.client.UpdatePermission(ctx, request) +} + +func (s PermissionServiceServer) DeletePermission(ctx context.Context, request *pb.DeletePermissionRequest) (*pb.DeletePermissionResponse, error) { + return s.client.DeletePermission(ctx, request) +} + +//func (m PermissionServiceServer) mustEmbedUnimplementedPermissionServiceServer() { +// //TODO implement me +// panic("implement me") +//} + +// NewPermissionServiceServer new a menu service. +func NewPermissionServiceServer(r runtime.Runtime, client *biz.PermissionServiceBiz) *PermissionServiceServer { + return &PermissionServiceServer{ + log: log.NewHelper(r.WithLogger("module", "service/system")), + client: client, + } +} + +// NewPermissionServiceServerPB new a menu service. +func NewPermissionServiceServerPB(r runtime.Runtime, client *biz.PermissionServiceBiz) pb.PermissionServiceServer { + return NewPermissionServiceServer(r, client) +} + +var _ pb.PermissionServiceServer = (*PermissionServiceServer)(nil) diff --git a/internal/mods/datastore/service/permission.http.go b/internal/mods/datastore/service/permission.http.go new file mode 100644 index 00000000..e16657f0 --- /dev/null +++ b/internal/mods/datastore/service/permission.http.go @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/biz" +) + +// PermissionServiceHTTPServer is a menu service. +type PermissionServiceHTTPServer struct { + client *biz.PermissionServiceBiz + log *log.KHelper +} + +func (s PermissionServiceHTTPServer) CreatePermission(ctx context.Context, request *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { + return s.client.CreatePermission(ctx, request) +} + +func (s PermissionServiceHTTPServer) DeletePermission(ctx context.Context, request *pb.DeletePermissionRequest) (*pb.DeletePermissionResponse, error) { + return s.client.DeletePermission(ctx, request) +} + +func (s PermissionServiceHTTPServer) GetPermission(ctx context.Context, request *pb.GetPermissionRequest) (*pb.GetPermissionResponse, error) { + return s.client.GetPermission(ctx, request) +} + +func (s PermissionServiceHTTPServer) ListPermissions(ctx context.Context, request *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { + return s.client.ListPermissions(ctx, request) +} + +func (s PermissionServiceHTTPServer) UpdatePermission(ctx context.Context, request *pb.UpdatePermissionRequest) (*pb.UpdatePermissionResponse, error) { + return s.client.UpdatePermission(ctx, request) +} + +// NewPermissionServiceHTTPServer new a menu service. +func NewPermissionServiceHTTPServer(r runtime.Runtime, client *biz.PermissionServiceBiz) *PermissionServiceHTTPServer { + return &PermissionServiceHTTPServer{ + log: log.NewHelper(r.WithLogger("module", "service/system")), + client: client, + } +} + +// NewPermissionServiceHTTPServerPB new a menu service. +func NewPermissionServiceHTTPServerPB(r runtime.Runtime, client *biz.PermissionServiceBiz) pb.PermissionServiceHTTPServer { + return NewPermissionServiceHTTPServer(r, client) +} + +var _ pb.PermissionServiceHTTPServer = (*PermissionServiceHTTPServer)(nil) diff --git a/internal/mods/datastore/service/provider.go b/internal/mods/datastore/service/provider.go new file mode 100644 index 00000000..99a2a1d1 --- /dev/null +++ b/internal/mods/datastore/service/provider.go @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package service implements the functions, types, and interfaces for the module. +package service + +import ( + "github.com/google/wire" +) + +// ProviderSet is service providers. +var ProviderSet = wire.NewSet( + NewRegisterServer, + NewResourceServiceServerPB, + NewResourceServiceHTTPServerPB, + NewRoleServiceServerPB, + NewRoleServiceHTTPServerPB, + NewUserServiceServerPB, + NewUserServiceHTTPServerPB, + NewPermissionServiceServerPB, + NewPermissionServiceHTTPServerPB, +) + +// LocalProviderSet is service providers. +var LocalProviderSet = wire.NewSet( + NewRegisterBridgeServer, + NewResourceServiceServerPB, + NewResourceServiceHTTPServerPB, + NewRoleServiceServerPB, + NewRoleServiceHTTPServerPB, + NewUserServiceServerPB, + NewUserServiceHTTPServerPB, + NewPermissionServiceServerPB, + NewPermissionServiceHTTPServerPB, +) + +var RemoteProviderSet = wire.NewSet( + NewRegisterBridgeServer, + NewResourceServiceBridgeClient, + //NewResourceServiceBridge, + NewRoleServiceBridgeClient, + //NewRoleServiceBridge, + NewUserServiceBridgeClient, + //NewUserServiceBridge, + NewPermissionServiceBridgeClient, + //NewPermissionServiceBridge, +) diff --git a/internal/mods/datastore/service/resource.bridge.go b/internal/mods/datastore/service/resource.bridge.go new file mode 100644 index 00000000..e24d35e0 --- /dev/null +++ b/internal/mods/datastore/service/resource.bridge.go @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "encoding/json" + "net/http" + + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/resp" +) + +// ResourceServiceHookedBridge is a menu service. +type ResourceServiceHookedBridge struct { + pb.UnimplementedResourceServiceHooked + log *log.KHelper +} + +func (h ResourceServiceHookedBridge) CompleteCreateResource(ctx transhttp.Context, request *pb.CreateResourceRequest, response *pb.CreateResourceResponse) error { + marshal, err := json.Marshal(response.Resource) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func (h ResourceServiceHookedBridge) CompleteDeleteResource(ctx transhttp.Context, request *pb.DeleteResourceRequest, response *pb.DeleteResourceResponse) error { + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: nil, + }) +} + +func (h ResourceServiceHookedBridge) CompleteGetResource(ctx transhttp.Context, request *pb.GetResourceRequest, response *pb.GetResourceResponse) error { + marshal, err := json.Marshal(response.Resource) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func (h ResourceServiceHookedBridge) CompleteListResources(ctx transhttp.Context, request *pb.ListResourcesRequest, response *pb.ListResourcesResponse) error { + if response == nil { + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: false, + Data: nil, + }) + } + marshal, err := resp.Proto2JSON(response.Resources...) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: response.TotalSize, + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), + }) +} + +func (h ResourceServiceHookedBridge) CompleteUpdateResource(ctx transhttp.Context, request *pb.UpdateResourceRequest, response *pb.UpdateResourceResponse) error { + marshal, err := json.Marshal(response.Resource) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func NewResourceServiceHookedBridge(r runtime.Runtime, client pb.ResourceServiceHTTPServer) pb.ResourceServiceHookedBridger { + return pb.WithResourceServiceHook(&ResourceServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/system")), + })(client) +} + +// NewResourceServiceBridge new a menu service. +func NewResourceServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.ResourceServiceServer { + return pb.NewResourceServiceBridge(client) +} + +func NewResourceServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.ResourceServiceServer { + if c, ok := clients["system"]; ok { + return pb.NewResourceServiceBridge(c) + } else { + return pb.UnimplementedResourceServiceServer{} + } +} + +// NewResourceServiceHTTPBridge new a menu service. +func NewResourceServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.ResourceServiceHTTPServer { + return pb.NewResourceServiceHTTPBridge(client) +} + +var _ pb.ResourceServiceHooker = (*ResourceServiceHookedBridge)(nil) diff --git a/internal/mods/datastore/service/resource.grpc.go b/internal/mods/datastore/service/resource.grpc.go new file mode 100644 index 00000000..dc570f60 --- /dev/null +++ b/internal/mods/datastore/service/resource.grpc.go @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/biz" +) + +// ResourceServiceServer is a menu service. +type ResourceServiceServer struct { + pb.UnimplementedResourceServiceServer + client *biz.ResourceServiceBiz + log *log.KHelper +} + +func (s ResourceServiceServer) ListResources(ctx context.Context, request *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { + return s.client.ListResources(ctx, request) +} + +func (s ResourceServiceServer) GetResource(ctx context.Context, request *pb.GetResourceRequest) (*pb.GetResourceResponse, error) { + return s.client.GetResource(ctx, request) +} + +func (s ResourceServiceServer) CreateResource(ctx context.Context, request *pb.CreateResourceRequest) (*pb.CreateResourceResponse, error) { + return s.client.CreateResource(ctx, request) +} + +func (s ResourceServiceServer) UpdateResource(ctx context.Context, request *pb.UpdateResourceRequest) (*pb.UpdateResourceResponse, error) { + return s.client.UpdateResource(ctx, request) +} + +func (s ResourceServiceServer) DeleteResource(ctx context.Context, request *pb.DeleteResourceRequest) (*pb.DeleteResourceResponse, error) { + return s.client.DeleteResource(ctx, request) +} + +//func (m ResourceServiceServer) mustEmbedUnimplementedResourceServiceServer() { +// //TODO implement me +// panic("implement me") +//} + +// NewResourceServiceServer new a menu service. +func NewResourceServiceServer(r runtime.Runtime, client *biz.ResourceServiceBiz) *ResourceServiceServer { + return &ResourceServiceServer{ + log: log.NewHelper(r.WithLogger("module", "service/system")), + client: client, + } +} + +// NewResourceServiceServerPB new a menu service. +func NewResourceServiceServerPB(r runtime.Runtime, client *biz.ResourceServiceBiz) pb.ResourceServiceServer { + return NewResourceServiceServer(r, client) +} + +var _ pb.ResourceServiceServer = (*ResourceServiceServer)(nil) diff --git a/internal/mods/datastore/service/resource.http.go b/internal/mods/datastore/service/resource.http.go new file mode 100644 index 00000000..1160bfb8 --- /dev/null +++ b/internal/mods/datastore/service/resource.http.go @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "github.com/origadmin/runtime/context" + + pb "origadmin/application/admin/api/v1/services/system" +) + +// ResourceServiceHTTPServer is a menu service. +type ResourceServiceHTTPServer struct { + pb.UnimplementedResourceServiceServer + + client pb.ResourceServiceHTTPClient +} + +func (s ResourceServiceHTTPServer) CreateResource(ctx context.Context, request *pb.CreateResourceRequest) (*pb.CreateResourceResponse, error) { + return s.client.CreateResource(ctx, request) +} + +func (s ResourceServiceHTTPServer) DeleteResource(ctx context.Context, request *pb.DeleteResourceRequest) (*pb.DeleteResourceResponse, error) { + return s.client.DeleteResource(ctx, request) +} + +func (s ResourceServiceHTTPServer) GetResource(ctx context.Context, request *pb.GetResourceRequest) (*pb.GetResourceResponse, error) { + return s.client.GetResource(ctx, request) +} + +func (s ResourceServiceHTTPServer) ListResources(ctx context.Context, request *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { + return s.client.ListResources(ctx, request) +} + +func (s ResourceServiceHTTPServer) UpdateResource(ctx context.Context, request *pb.UpdateResourceRequest) (*pb.UpdateResourceResponse, error) { + return s.client.UpdateResource(ctx, request) +} + +//func (m ResourceServiceHTTPServer) mustEmbedUnimplementedResourceServiceHTTPServer() { +// //TODO implement me +// panic("implement me") +//} + +// NewResourceServiceHTTPServer new a menu service. +func NewResourceServiceHTTPServer(client pb.ResourceServiceHTTPClient) *ResourceServiceHTTPServer { + return &ResourceServiceHTTPServer{client: client} +} + +// NewResourceServiceHTTPServerPB new a menu service. +func NewResourceServiceHTTPServerPB(client pb.ResourceServiceHTTPClient) pb.ResourceServiceHTTPServer { + return &ResourceServiceHTTPServer{client: client} +} + +var _ pb.ResourceServiceServer = (*ResourceServiceHTTPServer)(nil) diff --git a/internal/mods/datastore/service/role.bridge.go b/internal/mods/datastore/service/role.bridge.go new file mode 100644 index 00000000..1e55304c --- /dev/null +++ b/internal/mods/datastore/service/role.bridge.go @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "encoding/json" + "net/http" + + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/resp" +) + +// RoleServiceHookedBridge is a menu service. +type RoleServiceHookedBridge struct { + pb.UnimplementedRoleServiceHooked + log *log.KHelper +} + +func (h RoleServiceHookedBridge) CompleteCreateRole(ctx transhttp.Context, request *pb.CreateRoleRequest, response *pb.CreateRoleResponse) error { + marshal, err := json.Marshal(response.Role) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func (h RoleServiceHookedBridge) CompleteDeleteRole(ctx transhttp.Context, request *pb.DeleteRoleRequest, response *pb.DeleteRoleResponse) error { + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: nil, + }) +} + +func (h RoleServiceHookedBridge) CompleteGetRole(ctx transhttp.Context, request *pb.GetRoleRequest, response *pb.GetRoleResponse) error { + marshal, err := json.Marshal(response.Role) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func (h RoleServiceHookedBridge) CompleteListRoles(ctx transhttp.Context, request *pb.ListRolesRequest, response *pb.ListRolesResponse) error { + if response == nil { + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: false, + Data: nil, + }) + } + marshal, err := resp.Proto2JSON(response.Roles...) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: response.TotalSize, + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), + }) +} + +func (h RoleServiceHookedBridge) CompleteUpdateRole(ctx transhttp.Context, request *pb.UpdateRoleRequest, response *pb.UpdateRoleResponse) error { + marshal, err := json.Marshal(response.Role) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func NewRoleServiceHookedBridge(r runtime.Runtime, client pb.RoleServiceHTTPServer) pb.RoleServiceHookedBridger { + return pb.WithRoleServiceHook(&RoleServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/system")), + })(client) +} + +// NewRoleServiceBridge new a menu service. +func NewRoleServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.RoleServiceServer { + return pb.NewRoleServiceBridge(client) +} + +func NewRoleServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.RoleServiceServer { + if v, ok := clients["system"]; ok { + return NewRoleServiceBridge(r, v) + } else { + return pb.UnimplementedRoleServiceServer{} + } +} + +// NewRoleServiceHTTPBridge new a menu service. +func NewRoleServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.RoleServiceHTTPServer { + return pb.NewRoleServiceHTTPBridge(client) +} + +var _ pb.RoleServiceHooker = (*RoleServiceHookedBridge)(nil) diff --git a/internal/mods/datastore/service/role.grpc.go b/internal/mods/datastore/service/role.grpc.go new file mode 100644 index 00000000..8bc01690 --- /dev/null +++ b/internal/mods/datastore/service/role.grpc.go @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/biz" +) + +type RoleServiceServer struct { + pb.UnimplementedRoleServiceServer + + client *biz.RoleServiceBiz + log *log.KHelper +} + +func (s RoleServiceServer) ListRoles(ctx context.Context, req *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { + return s.client.ListRoles(ctx, req) +} +func (s RoleServiceServer) GetRole(ctx context.Context, req *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { + return s.client.GetRole(ctx, req) +} +func (s RoleServiceServer) CreateRole(ctx context.Context, req *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { + return s.client.CreateRole(ctx, req) +} +func (s RoleServiceServer) UpdateRole(ctx context.Context, req *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { + return s.client.UpdateRole(ctx, req) +} +func (s RoleServiceServer) DeleteRole(ctx context.Context, req *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { + return s.client.DeleteRole(ctx, req) +} + +// NewRoleServiceServer new a user service. +func NewRoleServiceServer(r runtime.Runtime, client *biz.RoleServiceBiz) *RoleServiceServer { + return &RoleServiceServer{ + log: log.NewHelper(r.WithLogger( + "module", "service/system", + )), + client: client, + } +} + +// NewRoleServiceServerPB new a user service. +func NewRoleServiceServerPB(r runtime.Runtime, client *biz.RoleServiceBiz) pb.RoleServiceServer { + return NewRoleServiceServer(r, client) +} + +var _ pb.RoleServiceServer = (*RoleServiceServer)(nil) diff --git a/internal/mods/datastore/service/role.http.go b/internal/mods/datastore/service/role.http.go new file mode 100644 index 00000000..60089f9b --- /dev/null +++ b/internal/mods/datastore/service/role.http.go @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + + pb "origadmin/application/admin/api/v1/services/system" +) + +type RoleServiceHTTPServer struct { + pb.UnimplementedRoleServiceServer + + client pb.RoleServiceHTTPClient +} + +func (s RoleServiceHTTPServer) ListRoles(ctx context.Context, req *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { + return s.client.ListRoles(ctx, req) +} +func (s RoleServiceHTTPServer) GetRole(ctx context.Context, req *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { + return s.client.GetRole(ctx, req) +} +func (s RoleServiceHTTPServer) CreateRole(ctx context.Context, req *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { + return s.client.CreateRole(ctx, req) +} +func (s RoleServiceHTTPServer) UpdateRole(ctx context.Context, req *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { + return s.client.UpdateRole(ctx, req) +} +func (s RoleServiceHTTPServer) DeleteRole(ctx context.Context, req *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { + return s.client.DeleteRole(ctx, req) +} + +// NewRoleServiceHTTPServer new a role service. +func NewRoleServiceHTTPServer(client pb.RoleServiceHTTPClient) *RoleServiceHTTPServer { + return &RoleServiceHTTPServer{ + client: client, + } +} + +// NewRoleServiceHTTPServerPB new a role service. +func NewRoleServiceHTTPServerPB(client pb.RoleServiceHTTPClient) pb.RoleServiceHTTPServer { + return &RoleServiceHTTPServer{ + client: client, + } +} + +var _ pb.RoleServiceServer = (*RoleServiceHTTPServer)(nil) diff --git a/internal/mods/datastore/service/service.go b/internal/mods/datastore/service/service.go new file mode 100644 index 00000000..8bca0e67 --- /dev/null +++ b/internal/mods/datastore/service/service.go @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + + pb "origadmin/application/admin/api/v1/services/system" +) + +type SystemServerRegistrar service.ServerRegistrar + +type RegisterServer struct { + Resource pb.ResourceServiceServer + Role pb.RoleServiceServer + User pb.UserServiceServer + Permission pb.PermissionServiceServer +} + +func (s RegisterServer) Register(ctx context.Context, svc any) { + switch v := svc.(type) { + case *service.GRPCServer: + s.RegisterGRPC(ctx, v) + case *service.HTTPServer: + s.RegisterHTTP(ctx, v) + } +} + +func (s RegisterServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { + log.Info("grpc server system init") + pb.RegisterResourceServiceServer(server, s.Resource) + pb.RegisterRoleServiceServer(server, s.Role) + pb.RegisterUserServiceServer(server, s.User) + pb.RegisterPermissionServiceServer(server, s.Permission) +} + +func (s RegisterServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { + log.Info("http server system init") + pb.RegisterResourceServiceHTTPServer(server, s.Resource) + pb.RegisterRoleServiceHTTPServer(server, s.Role) + pb.RegisterUserServiceHTTPServer(server, s.User) + pb.RegisterPermissionServiceHTTPServer(server, s.Permission) +} + +func NewRegisterServer( + Resource pb.ResourceServiceServer, + Role pb.RoleServiceServer, + User pb.UserServiceServer, + Permission pb.PermissionServiceServer, +) SystemServerRegistrar { + return &RegisterServer{ + Resource: Resource, + Role: Role, + User: User, + Permission: Permission, + } +} + +type RegisterBridgeServer struct { + Resource pb.ResourceServiceHookedBridger + Role pb.RoleServiceHookedBridger + User pb.UserServiceHookedBridger + Permission pb.PermissionServiceHookedBridger +} + +func (s RegisterBridgeServer) Register(ctx context.Context, svc any) { + switch v := svc.(type) { + case *service.GRPCServer: + s.RegisterGRPC(ctx, v) + case *service.HTTPServer: + s.RegisterHTTP(ctx, v) + } +} + +func (s RegisterBridgeServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { + log.Info("http server system init") + pb.RegisterResourceServiceBridgeServer(server, s.Resource) + pb.RegisterRoleServiceBridgeServer(server, s.Role) + pb.RegisterUserServiceBridgeServer(server, s.User) + pb.RegisterPermissionServiceBridgeServer(server, s.Permission) +} + +func (s RegisterBridgeServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { + log.Info("grpc server system init") + //pb.RegisterResourceServiceBridgeServer(server, s.Resource) + //pb.RegisterRoleServiceBridgeServer(server, s.Role) + //pb.RegisterUserServiceBridgeServer(server, s.User) + //pb.RegisterPermissionServiceBridgeServer(server, s.Permission) +} + +func NewRegisterBridgeServer(r runtime.Runtime, + Resource pb.ResourceServiceServer, + Role pb.RoleServiceServer, + User pb.UserServiceServer, + Permission pb.PermissionServiceServer, +) SystemServerRegistrar { + return &RegisterBridgeServer{ + Resource: NewResourceServiceHookedBridge(r, Resource), + Role: NewRoleServiceHookedBridge(r, Role), + User: NewUserServiceHookedBridge(r, User), + Permission: NewPermissionServiceHookedBridge(r, Permission), + } +} + +var _ service.ServerRegistrar = (*RegisterServer)(nil) diff --git a/internal/mods/datastore/service/user.bridge.go b/internal/mods/datastore/service/user.bridge.go new file mode 100644 index 00000000..b06a7663 --- /dev/null +++ b/internal/mods/datastore/service/user.bridge.go @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "encoding/json" + "net/http" + + transhttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/cmp" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/helpers/resp" +) + +// UserServiceHookedBridge is a menu service. +type UserServiceHookedBridge struct { + pb.UnimplementedUserServiceHooked + log *log.KHelper +} + +func (h UserServiceHookedBridge) CompleteCreateUser(ctx transhttp.Context, request *pb.CreateUserRequest, response *pb.CreateUserResponse) error { + marshal, err := json.Marshal(response.User) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func (h UserServiceHookedBridge) CompleteDeleteUser(ctx transhttp.Context, request *pb.DeleteUserRequest, response *pb.DeleteUserResponse) error { + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: nil, + }) +} + +func (h UserServiceHookedBridge) CompleteGetUser(ctx transhttp.Context, request *pb.GetUserRequest, response *pb.GetUserResponse) error { + marshal, err := json.Marshal(response.User) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func (h UserServiceHookedBridge) CompleteListUsers(ctx transhttp.Context, request *pb.ListUsersRequest, response *pb.ListUsersResponse) error { + if response == nil { + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: false, + Data: nil, + }) + } + marshal, err := resp.Proto2JSON(response.Users...) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.Result{ + Success: true, + Data: marshal, + Total: response.TotalSize, + NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), + }) +} + +func (h UserServiceHookedBridge) CompleteUpdateUser(ctx transhttp.Context, request *pb.UpdateUserRequest, response *pb.UpdateUserResponse) error { + marshal, err := json.Marshal(response.User) + if err != nil { + return err + } + return ctx.JSON(http.StatusOK, &resp.SourceData{ + Success: true, + Data: marshal, + }) +} + +func NewUserServiceHookedBridge(r runtime.Runtime, client pb.UserServiceHTTPServer) pb.UserServiceHookedBridger { + return pb.WithUserServiceHook(&UserServiceHookedBridge{ + log: log.NewHelper(r.WithLogger("module", "service/system")), + })(client) +} + +// NewUserServiceBridge new a menu service. +func NewUserServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.UserServiceServer { + return pb.NewUserServiceBridge(client) +} + +func NewUserServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.UserServiceServer { + if c, ok := clients["system"]; ok { + return pb.NewUserServiceBridge(c) + } else { + return pb.UnimplementedUserServiceServer{} + } +} + +// NewUserServiceHTTPBridge new a menu service. +func NewUserServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.UserServiceHTTPServer { + return pb.NewUserServiceHTTPBridge(client) +} + +var _ pb.UserServiceHooker = (*UserServiceHookedBridge)(nil) diff --git a/internal/mods/datastore/service/user.grpc.go b/internal/mods/datastore/service/user.grpc.go new file mode 100644 index 00000000..9a50871e --- /dev/null +++ b/internal/mods/datastore/service/user.grpc.go @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + + pb "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/mods/system/biz" +) + +type UserServiceServer struct { + pb.UnimplementedUserServiceServer + + client *biz.UserServiceBiz + log *log.KHelper +} + +func (s UserServiceServer) ListUserResources(ctx context.Context, request *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { + return s.client.ListUserResources(ctx, request) +} + +func (s UserServiceServer) UpdateUserStatus(ctx context.Context, request *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { + //TODO implement me + panic("implement me") +} + +func (s UserServiceServer) UpdateUserRoles(ctx context.Context, request *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { + //TODO implement me + panic("implement me") +} + +func (s UserServiceServer) ResetUserPassword(ctx context.Context, request *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { + //TODO implement me + panic("implement me") +} + +func (s UserServiceServer) mustEmbedUnimplementedUserServiceServer() { + //TODO implement me + panic("implement me") +} + +func (s UserServiceServer) ListUsers(ctx context.Context, req *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { + return s.client.ListUsers(ctx, req) +} + +func (s UserServiceServer) GetUser(ctx context.Context, req *pb.GetUserRequest) (*pb.GetUserResponse, error) { + return s.client.GetUser(ctx, req) +} + +func (s UserServiceServer) CreateUser(ctx context.Context, req *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { + return s.client.CreateUser(ctx, req) +} + +func (s UserServiceServer) UpdateUser(ctx context.Context, req *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { + return s.client.UpdateUser(ctx, req) +} + +func (s UserServiceServer) DeleteUser(ctx context.Context, req *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { + return s.client.DeleteUser(ctx, req) +} + +// NewUserServiceServer new a user service. +func NewUserServiceServer(r runtime.Runtime, client *biz.UserServiceBiz) *UserServiceServer { + return &UserServiceServer{ + log: log.NewHelper(r.WithLogger( + "module", "service/system", + )), + client: client, + } +} + +// NewUserServiceServerPB new a user service. +func NewUserServiceServerPB(r runtime.Runtime, client *biz.UserServiceBiz) pb.UserServiceServer { + return NewUserServiceServer(r, client) +} + +var _ pb.UserServiceServer = (*UserServiceServer)(nil) diff --git a/internal/mods/datastore/service/user.http.go b/internal/mods/datastore/service/user.http.go new file mode 100644 index 00000000..44afa0ad --- /dev/null +++ b/internal/mods/datastore/service/user.http.go @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + + pb "origadmin/application/admin/api/v1/services/system" +) + +type UserServiceHTTPServer struct { + pb.UnimplementedUserServiceServer + + client pb.UserServiceHTTPClient +} + +func (s UserServiceHTTPServer) ListUserResources(ctx context.Context, request *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { + return s.client.ListUserResources(ctx, request) +} + +func (s UserServiceHTTPServer) ResetUserPassword(ctx context.Context, request *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { + //TODO implement me + panic("implement me") +} + +func (s UserServiceHTTPServer) UpdateUserRoles(ctx context.Context, request *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { + //TODO implement me + panic("implement me") +} + +func (s UserServiceHTTPServer) UpdateUserStatus(ctx context.Context, request *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { + //TODO implement me + panic("implement me") +} + +func (s UserServiceHTTPServer) ListUsers(ctx context.Context, req *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { + return s.client.ListUsers(ctx, req) +} + +func (s UserServiceHTTPServer) GetUser(ctx context.Context, req *pb.GetUserRequest) (*pb.GetUserResponse, error) { + return s.client.GetUser(ctx, req) +} + +func (s UserServiceHTTPServer) CreateUser(ctx context.Context, req *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { + return s.client.CreateUser(ctx, req) +} + +func (s UserServiceHTTPServer) UpdateUser(ctx context.Context, req *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { + return s.client.UpdateUser(ctx, req) +} + +func (s UserServiceHTTPServer) DeleteUser(ctx context.Context, req *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { + return s.client.DeleteUser(ctx, req) +} + +// NewUserServiceHTTPServer new a user service. +func NewUserServiceHTTPServer(client pb.UserServiceHTTPClient) *UserServiceHTTPServer { + return &UserServiceHTTPServer{ + client: client, + } +} + +// NewUserServiceHTTPServerPB new a user service. +func NewUserServiceHTTPServerPB(client pb.UserServiceHTTPClient) pb.UserServiceHTTPServer { + return &UserServiceHTTPServer{ + client: client, + } +} + +var _ pb.UserServiceServer = (*UserServiceHTTPServer)(nil) diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 92fb0505..8b804723 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -654,6 +654,180 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' + /datastore: + get: + tags: + - DatastoreService + operationId: DatastoreService_ListDatastore + parameters: + - name: id + in: query + description: The parent data id, for example, "shelves/shelf1". + schema: + type: string + - name: current + in: query + description: The current page number. + schema: + type: integer + format: int32 + - name: page_size + in: query + description: The maximum number of items to return. + schema: + type: integer + format: int32 + - name: page_token + in: query + description: The next_page_token value returned from a previous List request, if any. + schema: + type: string + - name: no_paging + in: query + description: The no_paging is used to disable pagination. + schema: + type: boolean + - name: only_count + in: query + description: The only_count is the query parameter for set only to query the total number + schema: + type: boolean + - name: type + in: query + description: data type + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.datastore.ListDatastoreResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + post: + tags: + - DatastoreService + operationId: DatastoreService_CreateDatastore + parameters: + - name: parent + in: query + description: The parent data id where the data is to be created. + schema: + type: string + - name: data_id + in: query + description: The data id to use for this data. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.datastore.CreateDatastoreResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /datastore/{data.id}: + put: + tags: + - DatastoreService + operationId: DatastoreService_UpdateDatastore + parameters: + - name: data.id + in: path + required: true + schema: + type: string + - name: id + in: query + description: The id of the data object to update. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.datastore.UpdateDatastoreResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /datastore/{id}: + get: + tags: + - DatastoreService + operationId: DatastoreService_GetDatastore + parameters: + - name: id + in: path + description: "The field will contain id of the data requested, for example:\r\n \"shelves/shelf1/datastore/data2\"" + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.datastore.GetDatastoreResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + delete: + tags: + - DatastoreService + operationId: DatastoreService_DeleteDatastore + parameters: + - name: id + in: path + description: "The data id of the data to be deleted, for example:\r\n \"shelves/shelf1/datastore/data2\"" + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.datastore.DeleteDatastoreResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' /login: post: tags: @@ -2718,6 +2892,58 @@ components: properties: modified_date: type: string + api.v1.services.datastore.CreateDatastoreResponse: + type: object + properties: + data: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: CreateDatastoreResponse is the response for the DatastoreService.CreateDatastore method. + api.v1.services.datastore.DeleteDatastoreResponse: + type: object + properties: {} + description: DeleteDatastoreResponse is the response for the DatastoreService.DeleteDatastore method. + api.v1.services.datastore.GetDatastoreResponse: + type: object + properties: + data: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: The field id should match the Noun in the method id. + description: GetDatastoreResponse is the response for the DatastoreService.GetDatastore method. + api.v1.services.datastore.ListDatastoreResponse: + type: object + properties: + total_size: + type: integer + description: The total number of items in the list. + format: int32 + data: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: The paging datastore + current: + type: integer + description: The current page number. + format: int32 + page_size: + type: integer + description: The maximum number of items to return. + format: int32 + next_page_token: + type: string + description: "Token to retrieve the next page of results, or empty if there are no\r\n more results in the list." + extra: + allOf: + - $ref: '#/components/schemas/google.protobuf.Any' + description: "Additional information about this response.\r\n content to be added without destroying the current data format" + description: ListDatastoreResponse is the response for the DatastoreService.ListDatastore method. + api.v1.services.datastore.UpdateDatastoreResponse: + type: object + properties: + data: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: UpdateDatastoreResponse is the response for the DatastoreService.UpdateDatastore method. api.v1.services.message.GetPersonalProfileResponse: type: object properties: @@ -3141,6 +3367,40 @@ components: api.v1.services.system.UpdateUserStatusResponse: type: object properties: {} + api.v1.services.types.DataObject: + type: object + properties: + id: + type: string + description: ID of the ent. + create_time: + type: string + description: CreateTime holds the value of the "create_time" field. + format: date-time + update_time: + type: string + description: UpdateTime holds the value of the "update_time" field. + format: date-time + delete_time: + type: string + description: DeleteTime holds the value of the "delete_time" field. + format: date-time + version: + type: string + description: Version holds the value of the "version" field. + owner_id: + type: string + description: OwnerID holds the value of the "owner_id" field. + metadata: + type: object + additionalProperties: + type: string + description: Metadata holds the value of the "metadata" field. + payload: + type: string + description: Payload holds the value of the "payload" field. + format: bytes + description: Menu is the model entity for the Menu schema. api.v1.services.types.Department: type: object properties: @@ -3653,6 +3913,8 @@ tags: - name: AuthService - name: CasbinSourceService description: The Casbin source service definition. + - name: DatastoreService + description: The data service definition. - name: DepartmentService description: The login service definition. - name: LoginService From a7321272f92df611040be9821b29e5db0555baa2 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 4 Aug 2025 15:39:05 +0800 Subject: [PATCH 056/158] feat(backend): add upload service API - Create UploadService with CRUD operations for upload data - Define request and response messages for each API method - Implement pagination support in ListUpload endpoint - Add options for disabling pagination and querying total count - Use google.protobuf.Any for extensibility in responses --- api/v1/proto/datastore/upload.proto | 129 ++ api/v1/services/datastore/datastore.pb.go | 750 ++++++++++ api/v1/services/datastore/datastore.pb.gw.go | 487 ++++++ .../datastore/datastore.pb.validate.go | 1329 +++++++++++++++++ .../services/datastore/datastore_bridge.pb.go | 392 +++++ .../services/datastore/datastore_grpc.pb.go | 277 ++++ .../services/datastore/datastore_http.pb.go | 234 +++ helpers/i18n/i18n.go | 1 - .../biz/{permission.biz.go => datastore.go} | 0 internal/mods/datastore/biz/resource.biz.go | 100 -- internal/mods/datastore/biz/role.biz.go | 103 -- internal/mods/datastore/biz/user.biz.go | 178 --- internal/mods/system/service/service.go | 1 + 13 files changed, 3599 insertions(+), 382 deletions(-) create mode 100644 api/v1/proto/datastore/upload.proto create mode 100644 api/v1/services/datastore/datastore.pb.go create mode 100644 api/v1/services/datastore/datastore.pb.gw.go create mode 100644 api/v1/services/datastore/datastore.pb.validate.go create mode 100644 api/v1/services/datastore/datastore_bridge.pb.go create mode 100644 api/v1/services/datastore/datastore_grpc.pb.go create mode 100644 api/v1/services/datastore/datastore_http.pb.go rename internal/mods/datastore/biz/{permission.biz.go => datastore.go} (100%) delete mode 100644 internal/mods/datastore/biz/resource.biz.go delete mode 100644 internal/mods/datastore/biz/role.biz.go delete mode 100644 internal/mods/datastore/biz/user.biz.go diff --git a/api/v1/proto/datastore/upload.proto b/api/v1/proto/datastore/upload.proto new file mode 100644 index 00000000..6acb4cc9 --- /dev/null +++ b/api/v1/proto/datastore/upload.proto @@ -0,0 +1,129 @@ +syntax = "proto3"; + +package api.v1.services.upload; + +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/empty.proto"; +import "types/upload.proto"; +import "validate/validate.proto"; + +option go_package = "api/v1/services/upload;upload"; +option java_multiple_files = true; +option java_outer_classname = "APIV1ServicesUploadProto"; +option java_package = "com.origadmin.api.v1.services.upload"; + +// The data service definition. +service UploadService { + rpc ListUpload(ListUploadRequest) returns (ListUploadResponse) { + option (google.api.http) = {get: "/upload"}; + } + rpc GetUpload(GetUploadRequest) returns (GetUploadResponse) { + option (google.api.http) = {get: "/upload/{id}"}; + } + rpc CreateUpload(CreateUploadRequest) returns (CreateUploadResponse) { + option (google.api.http) = { + post: "/upload" + body: "data" + }; + } + rpc UpdateUpload(UpdateUploadRequest) returns (UpdateUploadResponse) { + option (google.api.http) = { + put: "/upload/{data.id}" + body: "data" + }; + } + rpc DeleteUpload(DeleteUploadRequest) returns (DeleteUploadResponse) { + option (google.api.http) = {delete: "/upload/{id}"}; + } +} + +// ListUploadRequest is the request for the UploadService.ListUpload method. +message ListUploadRequest { + // The parent data id, for example, "shelves/shelf1". + int64 id = 1 [json_name = "id"]; + // The current page number. + int32 current = 2 [json_name = "current"]; + // The maximum number of items to return. + int32 page_size = 3 [json_name = "page_size"]; + // The next_page_token value returned from a previous List request, if any. + string page_token = 4 [json_name = "page_token"]; + // The no_paging is used to disable pagination. + bool no_paging = 5 [json_name = "no_paging"]; + // The only_count is the query parameter for set only to query the total number + bool only_count = 6 [json_name = "only_count"]; + // data type + string type = 7 [json_name = "type"]; +} + +// ListUploadResponse is the response for the UploadService.ListUpload method. +message ListUploadResponse { + // The total number of items in the list. + int32 total_size = 1 [json_name = "total_size"]; + // The paging upload + repeated api.v1.services.types.DataObject data = 2 [json_name = "data"]; + // The current page number. + int32 current = 3 [json_name = "current"]; + // The maximum number of items to return. + int32 page_size = 4 [json_name = "page_size"]; + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + string next_page_token = 5 [json_name = "next_page_token"]; + // Additional information about this response. + // content to be added without destroying the current data format + optional google.protobuf.Any extra = 6 [json_name = "extra"]; +} + +// GetUploadRequest is the request for the UploadService.GetUpload method. +message GetUploadRequest { + // The field will contain id of the data requested, for example: + // "shelves/shelf1/upload/data2" + int64 id = 1 [json_name = "id"]; +} + +// GetUploadResponse is the response for the UploadService.GetUpload method. +message GetUploadResponse { + // The field id should match the Noun in the method id. + api.v1.services.types.DataObject data = 1 [json_name = "data"]; +} + +// CreateUploadRequest is the request for the UploadService.CreateUpload method. +message CreateUploadRequest { + // The parent data id where the data is to be created. + string parent = 1 [json_name = "parent"]; + // The data id to use for this data. + string data_id = 2 [json_name = "data_id"]; + // The data object to create. + api.v1.services.types.DataObject data = 3 [json_name = "data"]; +} + +// CreateUploadResponse is the response for the UploadService.CreateUpload method. +message CreateUploadResponse { + api.v1.services.types.DataObject data = 1 [json_name = "data"]; +} + +// UpdateUploadRequest is the request for the UploadService.UpdateUpload method. +message UpdateUploadRequest { + // The id of the data object to update. + int64 id = 1 [json_name = "id"]; + // The data object which replaces the data on the server. + api.v1.services.types.DataObject data = 2 [json_name = "data"]; +} + +// UpdateUploadResponse is the response for the UploadService.UpdateUpload method. +message UpdateUploadResponse { + api.v1.services.types.DataObject data = 1 [json_name = "data"]; +} + +// DeleteUploadRequest is the request for the UploadService.DeleteUpload method. +message DeleteUploadRequest { + // The data id of the data to be deleted, for example: + // "shelves/shelf1/upload/data2" + int64 id = 1 [json_name = "id"]; +} + +// DeleteUploadResponse is the response for the UploadService.DeleteUpload method. +message DeleteUploadResponse { + // or Upload data = 1; or google.protobuf.Empty empty = 1; + google.protobuf.Empty empty = 1; +} diff --git a/api/v1/services/datastore/datastore.pb.go b/api/v1/services/datastore/datastore.pb.go new file mode 100644 index 00000000..771681ea --- /dev/null +++ b/api/v1/services/datastore/datastore.pb.go @@ -0,0 +1,750 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc (unknown) +// source: datastore/datastore.proto + +package datastore + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// ListDatastoreRequest is the request for the DatastoreService.ListDatastore method. +type ListDatastoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent data id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // data type + Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListDatastoreRequest) Reset() { + *x = ListDatastoreRequest{} + mi := &file_datastore_datastore_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListDatastoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDatastoreRequest) ProtoMessage() {} + +func (x *ListDatastoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[0] + 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 ListDatastoreRequest.ProtoReflect.Descriptor instead. +func (*ListDatastoreRequest) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{0} +} + +func (x *ListDatastoreRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListDatastoreRequest) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListDatastoreRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListDatastoreRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListDatastoreRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListDatastoreRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListDatastoreRequest) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +// ListDatastoreResponse is the response for the DatastoreService.ListDatastore method. +type ListDatastoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` + // The paging datastore + Data []*types.DataObject `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the current data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListDatastoreResponse) Reset() { + *x = ListDatastoreResponse{} + mi := &file_datastore_datastore_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListDatastoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDatastoreResponse) ProtoMessage() {} + +func (x *ListDatastoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[1] + 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 ListDatastoreResponse.ProtoReflect.Descriptor instead. +func (*ListDatastoreResponse) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{1} +} + +func (x *ListDatastoreResponse) GetTotalSize() int32 { + if x != nil { + return x.TotalSize + } + return 0 +} + +func (x *ListDatastoreResponse) GetData() []*types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +func (x *ListDatastoreResponse) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListDatastoreResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListDatastoreResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListDatastoreResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +// GetDatastoreRequest is the request for the DatastoreService.GetDatastore method. +type GetDatastoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the data requested, for example: + // "shelves/shelf1/datastore/data2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDatastoreRequest) Reset() { + *x = GetDatastoreRequest{} + mi := &file_datastore_datastore_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDatastoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDatastoreRequest) ProtoMessage() {} + +func (x *GetDatastoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[2] + 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 GetDatastoreRequest.ProtoReflect.Descriptor instead. +func (*GetDatastoreRequest) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{2} +} + +func (x *GetDatastoreRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// GetDatastoreResponse is the response for the DatastoreService.GetDatastore method. +type GetDatastoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field id should match the Noun in the method id. + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDatastoreResponse) Reset() { + *x = GetDatastoreResponse{} + mi := &file_datastore_datastore_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDatastoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDatastoreResponse) ProtoMessage() {} + +func (x *GetDatastoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[3] + 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 GetDatastoreResponse.ProtoReflect.Descriptor instead. +func (*GetDatastoreResponse) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{3} +} + +func (x *GetDatastoreResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// CreateDatastoreRequest is the request for the DatastoreService.CreateDatastore method. +type CreateDatastoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent data id where the data is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The data id to use for this data. + DataId string `protobuf:"bytes,2,opt,name=data_id,proto3" json:"data_id,omitempty"` + // The data object to create. + Data *types.DataObject `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateDatastoreRequest) Reset() { + *x = CreateDatastoreRequest{} + mi := &file_datastore_datastore_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateDatastoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateDatastoreRequest) ProtoMessage() {} + +func (x *CreateDatastoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[4] + 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 CreateDatastoreRequest.ProtoReflect.Descriptor instead. +func (*CreateDatastoreRequest) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateDatastoreRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateDatastoreRequest) GetDataId() string { + if x != nil { + return x.DataId + } + return "" +} + +func (x *CreateDatastoreRequest) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// CreateDatastoreResponse is the response for the DatastoreService.CreateDatastore method. +type CreateDatastoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateDatastoreResponse) Reset() { + *x = CreateDatastoreResponse{} + mi := &file_datastore_datastore_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateDatastoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateDatastoreResponse) ProtoMessage() {} + +func (x *CreateDatastoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[5] + 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 CreateDatastoreResponse.ProtoReflect.Descriptor instead. +func (*CreateDatastoreResponse) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateDatastoreResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// UpdateDatastoreRequest is the request for the DatastoreService.UpdateDatastore method. +type UpdateDatastoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The id of the data object to update. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The data object which replaces the data on the server. + Data *types.DataObject `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateDatastoreRequest) Reset() { + *x = UpdateDatastoreRequest{} + mi := &file_datastore_datastore_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateDatastoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateDatastoreRequest) ProtoMessage() {} + +func (x *UpdateDatastoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_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 UpdateDatastoreRequest.ProtoReflect.Descriptor instead. +func (*UpdateDatastoreRequest) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateDatastoreRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateDatastoreRequest) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// UpdateDatastoreResponse is the response for the DatastoreService.UpdateDatastore method. +type UpdateDatastoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateDatastoreResponse) Reset() { + *x = UpdateDatastoreResponse{} + mi := &file_datastore_datastore_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateDatastoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateDatastoreResponse) ProtoMessage() {} + +func (x *UpdateDatastoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateDatastoreResponse.ProtoReflect.Descriptor instead. +func (*UpdateDatastoreResponse) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateDatastoreResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// DeleteDatastoreRequest is the request for the DatastoreService.DeleteDatastore method. +type DeleteDatastoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The data id of the data to be deleted, for example: + // "shelves/shelf1/datastore/data2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteDatastoreRequest) Reset() { + *x = DeleteDatastoreRequest{} + mi := &file_datastore_datastore_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteDatastoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteDatastoreRequest) ProtoMessage() {} + +func (x *DeleteDatastoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[8] + 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 DeleteDatastoreRequest.ProtoReflect.Descriptor instead. +func (*DeleteDatastoreRequest) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteDatastoreRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// DeleteDatastoreResponse is the response for the DatastoreService.DeleteDatastore method. +type DeleteDatastoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // or Datastore data = 1; or google.protobuf.Empty empty = 1; + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteDatastoreResponse) Reset() { + *x = DeleteDatastoreResponse{} + mi := &file_datastore_datastore_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteDatastoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteDatastoreResponse) ProtoMessage() {} + +func (x *DeleteDatastoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[9] + 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 DeleteDatastoreResponse.ProtoReflect.Descriptor instead. +func (*DeleteDatastoreResponse) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{9} +} + +func (x *DeleteDatastoreResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_datastore_datastore_proto protoreflect.FileDescriptor + +const file_datastore_datastore_proto_rawDesc = "" + + "\n" + + "\x19datastore/datastore.proto\x12\x19api.v1.services.datastore\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15types/datastore.proto\x1a\x17validate/validate.proto\"\xd0\x01\n" + + "\x14ListDatastoreRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x12\n" + + "\x04type\x18\a \x01(\tR\x04type\"\x8b\x02\n" + + "\x15ListDatastoreResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x125\n" + + "\x04data\x18\x02 \x03(\v2!.api.v1.services.types.DataObjectR\x04data\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"%\n" + + "\x13GetDatastoreRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"M\n" + + "\x14GetDatastoreResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"\x81\x01\n" + + "\x16CreateDatastoreRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x18\n" + + "\adata_id\x18\x02 \x01(\tR\adata_id\x125\n" + + "\x04data\x18\x03 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"P\n" + + "\x17CreateDatastoreResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"_\n" + + "\x16UpdateDatastoreRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x125\n" + + "\x04data\x18\x02 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"P\n" + + "\x17UpdateDatastoreResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"(\n" + + "\x16DeleteDatastoreRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"G\n" + + "\x17DeleteDatastoreResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xee\x05\n" + + "\x10DatastoreService\x12\x86\x01\n" + + "\rListDatastore\x12/.api.v1.services.datastore.ListDatastoreRequest\x1a0.api.v1.services.datastore.ListDatastoreResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + + "/datastore\x12\x88\x01\n" + + "\fGetDatastore\x12..api.v1.services.datastore.GetDatastoreRequest\x1a/.api.v1.services.datastore.GetDatastoreResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/datastore/{id}\x12\x92\x01\n" + + "\x0fCreateDatastore\x121.api.v1.services.datastore.CreateDatastoreRequest\x1a2.api.v1.services.datastore.CreateDatastoreResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04data\"\n" + + "/datastore\x12\x9c\x01\n" + + "\x0fUpdateDatastore\x121.api.v1.services.datastore.UpdateDatastoreRequest\x1a2.api.v1.services.datastore.UpdateDatastoreResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04data\x1a\x14/datastore/{data.id}\x12\x91\x01\n" + + "\x0fDeleteDatastore\x121.api.v1.services.datastore.DeleteDatastoreRequest\x1a2.api.v1.services.datastore.DeleteDatastoreResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/datastore/{id}B\xdc\x01\n" + + "\x1dcom.api.v1.services.datastoreB\x0eDatastoreProtoP\x01Z#api/v1/services/datastore;datastore\xa2\x02\x04AVSD\xaa\x02\x19Api.V1.Services.Datastore\xca\x02\x19Api\\V1\\Services\\Datastore\xe2\x02%Api\\V1\\Services\\Datastore\\GPBMetadata\xea\x02\x1cApi::V1::Services::Datastoreb\x06proto3" + +var ( + file_datastore_datastore_proto_rawDescOnce sync.Once + file_datastore_datastore_proto_rawDescData []byte +) + +func file_datastore_datastore_proto_rawDescGZIP() []byte { + file_datastore_datastore_proto_rawDescOnce.Do(func() { + file_datastore_datastore_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_datastore_datastore_proto_rawDesc), len(file_datastore_datastore_proto_rawDesc))) + }) + return file_datastore_datastore_proto_rawDescData +} + +var file_datastore_datastore_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_datastore_datastore_proto_goTypes = []any{ + (*ListDatastoreRequest)(nil), // 0: api.v1.services.datastore.ListDatastoreRequest + (*ListDatastoreResponse)(nil), // 1: api.v1.services.datastore.ListDatastoreResponse + (*GetDatastoreRequest)(nil), // 2: api.v1.services.datastore.GetDatastoreRequest + (*GetDatastoreResponse)(nil), // 3: api.v1.services.datastore.GetDatastoreResponse + (*CreateDatastoreRequest)(nil), // 4: api.v1.services.datastore.CreateDatastoreRequest + (*CreateDatastoreResponse)(nil), // 5: api.v1.services.datastore.CreateDatastoreResponse + (*UpdateDatastoreRequest)(nil), // 6: api.v1.services.datastore.UpdateDatastoreRequest + (*UpdateDatastoreResponse)(nil), // 7: api.v1.services.datastore.UpdateDatastoreResponse + (*DeleteDatastoreRequest)(nil), // 8: api.v1.services.datastore.DeleteDatastoreRequest + (*DeleteDatastoreResponse)(nil), // 9: api.v1.services.datastore.DeleteDatastoreResponse + (*types.DataObject)(nil), // 10: api.v1.services.types.DataObject + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_datastore_datastore_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.datastore.ListDatastoreResponse.data:type_name -> api.v1.services.types.DataObject + 11, // 1: api.v1.services.datastore.ListDatastoreResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.datastore.GetDatastoreResponse.data:type_name -> api.v1.services.types.DataObject + 10, // 3: api.v1.services.datastore.CreateDatastoreRequest.data:type_name -> api.v1.services.types.DataObject + 10, // 4: api.v1.services.datastore.CreateDatastoreResponse.data:type_name -> api.v1.services.types.DataObject + 10, // 5: api.v1.services.datastore.UpdateDatastoreRequest.data:type_name -> api.v1.services.types.DataObject + 10, // 6: api.v1.services.datastore.UpdateDatastoreResponse.data:type_name -> api.v1.services.types.DataObject + 12, // 7: api.v1.services.datastore.DeleteDatastoreResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.datastore.DatastoreService.ListDatastore:input_type -> api.v1.services.datastore.ListDatastoreRequest + 2, // 9: api.v1.services.datastore.DatastoreService.GetDatastore:input_type -> api.v1.services.datastore.GetDatastoreRequest + 4, // 10: api.v1.services.datastore.DatastoreService.CreateDatastore:input_type -> api.v1.services.datastore.CreateDatastoreRequest + 6, // 11: api.v1.services.datastore.DatastoreService.UpdateDatastore:input_type -> api.v1.services.datastore.UpdateDatastoreRequest + 8, // 12: api.v1.services.datastore.DatastoreService.DeleteDatastore:input_type -> api.v1.services.datastore.DeleteDatastoreRequest + 1, // 13: api.v1.services.datastore.DatastoreService.ListDatastore:output_type -> api.v1.services.datastore.ListDatastoreResponse + 3, // 14: api.v1.services.datastore.DatastoreService.GetDatastore:output_type -> api.v1.services.datastore.GetDatastoreResponse + 5, // 15: api.v1.services.datastore.DatastoreService.CreateDatastore:output_type -> api.v1.services.datastore.CreateDatastoreResponse + 7, // 16: api.v1.services.datastore.DatastoreService.UpdateDatastore:output_type -> api.v1.services.datastore.UpdateDatastoreResponse + 9, // 17: api.v1.services.datastore.DatastoreService.DeleteDatastore:output_type -> api.v1.services.datastore.DeleteDatastoreResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_datastore_datastore_proto_init() } +func file_datastore_datastore_proto_init() { + if File_datastore_datastore_proto != nil { + return + } + file_datastore_datastore_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_datastore_datastore_proto_rawDesc), len(file_datastore_datastore_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_datastore_datastore_proto_goTypes, + DependencyIndexes: file_datastore_datastore_proto_depIdxs, + MessageInfos: file_datastore_datastore_proto_msgTypes, + }.Build() + File_datastore_datastore_proto = out.File + file_datastore_datastore_proto_goTypes = nil + file_datastore_datastore_proto_depIdxs = nil +} diff --git a/api/v1/services/datastore/datastore.pb.gw.go b/api/v1/services/datastore/datastore.pb.gw.go new file mode 100644 index 00000000..bcf43768 --- /dev/null +++ b/api/v1/services/datastore/datastore.pb.gw.go @@ -0,0 +1,487 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: datastore/datastore.proto + +/* +Package datastore is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package datastore + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_DatastoreService_ListDatastore_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_DatastoreService_ListDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListDatastoreRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_ListDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DatastoreService_ListDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListDatastoreRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_ListDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListDatastore(ctx, &protoReq) + return msg, metadata, err +} + +func request_DatastoreService_GetDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DatastoreService_GetDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetDatastore(ctx, &protoReq) + return msg, metadata, err +} + +var filter_DatastoreService_CreateDatastore_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_DatastoreService_CreateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateDatastoreRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_CreateDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DatastoreService_CreateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateDatastoreRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_CreateDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateDatastore(ctx, &protoReq) + return msg, metadata, err +} + +var filter_DatastoreService_UpdateDatastore_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_DatastoreService_UpdateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["data.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_UpdateDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DatastoreService_UpdateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["data.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_UpdateDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateDatastore(ctx, &protoReq) + return msg, metadata, err +} + +func request_DatastoreService_DeleteDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DatastoreService_DeleteDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteDatastore(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterDatastoreServiceHandlerServer registers the http handlers for service DatastoreService to "mux". +// UnaryRPC :call DatastoreServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterDatastoreServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterDatastoreServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DatastoreServiceServer) error { + mux.Handle(http.MethodGet, pattern_DatastoreService_ListDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/ListDatastore", runtime.WithHTTPPathPattern("/datastore")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DatastoreService_ListDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_ListDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_DatastoreService_GetDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/GetDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DatastoreService_GetDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_GetDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_DatastoreService_CreateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/CreateDatastore", runtime.WithHTTPPathPattern("/datastore")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DatastoreService_CreateDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_CreateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_DatastoreService_UpdateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/UpdateDatastore", runtime.WithHTTPPathPattern("/datastore/{data.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DatastoreService_UpdateDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_UpdateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_DatastoreService_DeleteDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/DeleteDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DatastoreService_DeleteDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_DeleteDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterDatastoreServiceHandlerFromEndpoint is same as RegisterDatastoreServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterDatastoreServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterDatastoreServiceHandler(ctx, mux, conn) +} + +// RegisterDatastoreServiceHandler registers the http handlers for service DatastoreService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterDatastoreServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterDatastoreServiceHandlerClient(ctx, mux, NewDatastoreServiceClient(conn)) +} + +// RegisterDatastoreServiceHandlerClient registers the http handlers for service DatastoreService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DatastoreServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DatastoreServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "DatastoreServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterDatastoreServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DatastoreServiceClient) error { + mux.Handle(http.MethodGet, pattern_DatastoreService_ListDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/ListDatastore", runtime.WithHTTPPathPattern("/datastore")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DatastoreService_ListDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_ListDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_DatastoreService_GetDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/GetDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DatastoreService_GetDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_GetDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_DatastoreService_CreateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/CreateDatastore", runtime.WithHTTPPathPattern("/datastore")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DatastoreService_CreateDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_CreateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_DatastoreService_UpdateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/UpdateDatastore", runtime.WithHTTPPathPattern("/datastore/{data.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DatastoreService_UpdateDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_UpdateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_DatastoreService_DeleteDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/DeleteDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DatastoreService_DeleteDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_DeleteDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_DatastoreService_ListDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"datastore"}, "")) + pattern_DatastoreService_GetDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"datastore", "id"}, "")) + pattern_DatastoreService_CreateDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"datastore"}, "")) + pattern_DatastoreService_UpdateDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"datastore", "data.id"}, "")) + pattern_DatastoreService_DeleteDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"datastore", "id"}, "")) +) + +var ( + forward_DatastoreService_ListDatastore_0 = runtime.ForwardResponseMessage + forward_DatastoreService_GetDatastore_0 = runtime.ForwardResponseMessage + forward_DatastoreService_CreateDatastore_0 = runtime.ForwardResponseMessage + forward_DatastoreService_UpdateDatastore_0 = runtime.ForwardResponseMessage + forward_DatastoreService_DeleteDatastore_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/datastore/datastore.pb.validate.go b/api/v1/services/datastore/datastore.pb.validate.go new file mode 100644 index 00000000..330c520f --- /dev/null +++ b/api/v1/services/datastore/datastore.pb.validate.go @@ -0,0 +1,1329 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: datastore/datastore.proto + +package datastore + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListDatastoreRequest 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 *ListDatastoreRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListDatastoreRequest 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 +// ListDatastoreRequestMultiError, or nil if none found. +func (m *ListDatastoreRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListDatastoreRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Type + + if len(errors) > 0 { + return ListDatastoreRequestMultiError(errors) + } + + return nil +} + +// ListDatastoreRequestMultiError is an error wrapping multiple validation +// errors returned by ListDatastoreRequest.ValidateAll() if the designated +// constraints aren't met. +type ListDatastoreRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListDatastoreRequestMultiError) 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 ListDatastoreRequestMultiError) AllErrors() []error { return m } + +// ListDatastoreRequestValidationError is the validation error returned by +// ListDatastoreRequest.Validate if the designated constraints aren't met. +type ListDatastoreRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListDatastoreRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListDatastoreRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListDatastoreRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListDatastoreRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListDatastoreRequestValidationError) ErrorName() string { + return "ListDatastoreRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListDatastoreRequestValidationError) 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 %sListDatastoreRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListDatastoreRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListDatastoreRequestValidationError{} + +// Validate checks the field values on ListDatastoreResponse 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 *ListDatastoreResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListDatastoreResponse 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 +// ListDatastoreResponseMultiError, or nil if none found. +func (m *ListDatastoreResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListDatastoreResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TotalSize + + for idx, item := range m.GetData() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListDatastoreResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListDatastoreResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListDatastoreResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListDatastoreResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListDatastoreResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListDatastoreResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListDatastoreResponseMultiError(errors) + } + + return nil +} + +// ListDatastoreResponseMultiError is an error wrapping multiple validation +// errors returned by ListDatastoreResponse.ValidateAll() if the designated +// constraints aren't met. +type ListDatastoreResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListDatastoreResponseMultiError) 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 ListDatastoreResponseMultiError) AllErrors() []error { return m } + +// ListDatastoreResponseValidationError is the validation error returned by +// ListDatastoreResponse.Validate if the designated constraints aren't met. +type ListDatastoreResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListDatastoreResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListDatastoreResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListDatastoreResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListDatastoreResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListDatastoreResponseValidationError) ErrorName() string { + return "ListDatastoreResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListDatastoreResponseValidationError) 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 %sListDatastoreResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListDatastoreResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListDatastoreResponseValidationError{} + +// Validate checks the field values on GetDatastoreRequest 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 *GetDatastoreRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDatastoreRequest 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 +// GetDatastoreRequestMultiError, or nil if none found. +func (m *GetDatastoreRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDatastoreRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetDatastoreRequestMultiError(errors) + } + + return nil +} + +// GetDatastoreRequestMultiError is an error wrapping multiple validation +// errors returned by GetDatastoreRequest.ValidateAll() if the designated +// constraints aren't met. +type GetDatastoreRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDatastoreRequestMultiError) 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 GetDatastoreRequestMultiError) AllErrors() []error { return m } + +// GetDatastoreRequestValidationError is the validation error returned by +// GetDatastoreRequest.Validate if the designated constraints aren't met. +type GetDatastoreRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDatastoreRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDatastoreRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDatastoreRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDatastoreRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDatastoreRequestValidationError) ErrorName() string { + return "GetDatastoreRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDatastoreRequestValidationError) 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 %sGetDatastoreRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDatastoreRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDatastoreRequestValidationError{} + +// Validate checks the field values on GetDatastoreResponse 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 *GetDatastoreResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDatastoreResponse 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 +// GetDatastoreResponseMultiError, or nil if none found. +func (m *GetDatastoreResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDatastoreResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetDatastoreResponseMultiError(errors) + } + + return nil +} + +// GetDatastoreResponseMultiError is an error wrapping multiple validation +// errors returned by GetDatastoreResponse.ValidateAll() if the designated +// constraints aren't met. +type GetDatastoreResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDatastoreResponseMultiError) 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 GetDatastoreResponseMultiError) AllErrors() []error { return m } + +// GetDatastoreResponseValidationError is the validation error returned by +// GetDatastoreResponse.Validate if the designated constraints aren't met. +type GetDatastoreResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDatastoreResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDatastoreResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDatastoreResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDatastoreResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDatastoreResponseValidationError) ErrorName() string { + return "GetDatastoreResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDatastoreResponseValidationError) 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 %sGetDatastoreResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDatastoreResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDatastoreResponseValidationError{} + +// Validate checks the field values on CreateDatastoreRequest 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 *CreateDatastoreRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateDatastoreRequest 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 +// CreateDatastoreRequestMultiError, or nil if none found. +func (m *CreateDatastoreRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateDatastoreRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for DataId + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateDatastoreRequestMultiError(errors) + } + + return nil +} + +// CreateDatastoreRequestMultiError is an error wrapping multiple validation +// errors returned by CreateDatastoreRequest.ValidateAll() if the designated +// constraints aren't met. +type CreateDatastoreRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateDatastoreRequestMultiError) 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 CreateDatastoreRequestMultiError) AllErrors() []error { return m } + +// CreateDatastoreRequestValidationError is the validation error returned by +// CreateDatastoreRequest.Validate if the designated constraints aren't met. +type CreateDatastoreRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateDatastoreRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateDatastoreRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateDatastoreRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateDatastoreRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateDatastoreRequestValidationError) ErrorName() string { + return "CreateDatastoreRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateDatastoreRequestValidationError) 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 %sCreateDatastoreRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateDatastoreRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateDatastoreRequestValidationError{} + +// Validate checks the field values on CreateDatastoreResponse 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 *CreateDatastoreResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateDatastoreResponse 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 +// CreateDatastoreResponseMultiError, or nil if none found. +func (m *CreateDatastoreResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateDatastoreResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateDatastoreResponseMultiError(errors) + } + + return nil +} + +// CreateDatastoreResponseMultiError is an error wrapping multiple validation +// errors returned by CreateDatastoreResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateDatastoreResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateDatastoreResponseMultiError) 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 CreateDatastoreResponseMultiError) AllErrors() []error { return m } + +// CreateDatastoreResponseValidationError is the validation error returned by +// CreateDatastoreResponse.Validate if the designated constraints aren't met. +type CreateDatastoreResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateDatastoreResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateDatastoreResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateDatastoreResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateDatastoreResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateDatastoreResponseValidationError) ErrorName() string { + return "CreateDatastoreResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateDatastoreResponseValidationError) 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 %sCreateDatastoreResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateDatastoreResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateDatastoreResponseValidationError{} + +// Validate checks the field values on UpdateDatastoreRequest 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 *UpdateDatastoreRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateDatastoreRequest 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 +// UpdateDatastoreRequestMultiError, or nil if none found. +func (m *UpdateDatastoreRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateDatastoreRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateDatastoreRequestMultiError(errors) + } + + return nil +} + +// UpdateDatastoreRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateDatastoreRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateDatastoreRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateDatastoreRequestMultiError) 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 UpdateDatastoreRequestMultiError) AllErrors() []error { return m } + +// UpdateDatastoreRequestValidationError is the validation error returned by +// UpdateDatastoreRequest.Validate if the designated constraints aren't met. +type UpdateDatastoreRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateDatastoreRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateDatastoreRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateDatastoreRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateDatastoreRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateDatastoreRequestValidationError) ErrorName() string { + return "UpdateDatastoreRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateDatastoreRequestValidationError) 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 %sUpdateDatastoreRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateDatastoreRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateDatastoreRequestValidationError{} + +// Validate checks the field values on UpdateDatastoreResponse 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 *UpdateDatastoreResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateDatastoreResponse 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 +// UpdateDatastoreResponseMultiError, or nil if none found. +func (m *UpdateDatastoreResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateDatastoreResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateDatastoreResponseMultiError(errors) + } + + return nil +} + +// UpdateDatastoreResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateDatastoreResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateDatastoreResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateDatastoreResponseMultiError) 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 UpdateDatastoreResponseMultiError) AllErrors() []error { return m } + +// UpdateDatastoreResponseValidationError is the validation error returned by +// UpdateDatastoreResponse.Validate if the designated constraints aren't met. +type UpdateDatastoreResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateDatastoreResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateDatastoreResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateDatastoreResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateDatastoreResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateDatastoreResponseValidationError) ErrorName() string { + return "UpdateDatastoreResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateDatastoreResponseValidationError) 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 %sUpdateDatastoreResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateDatastoreResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateDatastoreResponseValidationError{} + +// Validate checks the field values on DeleteDatastoreRequest 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 *DeleteDatastoreRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteDatastoreRequest 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 +// DeleteDatastoreRequestMultiError, or nil if none found. +func (m *DeleteDatastoreRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteDatastoreRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeleteDatastoreRequestMultiError(errors) + } + + return nil +} + +// DeleteDatastoreRequestMultiError is an error wrapping multiple validation +// errors returned by DeleteDatastoreRequest.ValidateAll() if the designated +// constraints aren't met. +type DeleteDatastoreRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteDatastoreRequestMultiError) 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 DeleteDatastoreRequestMultiError) AllErrors() []error { return m } + +// DeleteDatastoreRequestValidationError is the validation error returned by +// DeleteDatastoreRequest.Validate if the designated constraints aren't met. +type DeleteDatastoreRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteDatastoreRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteDatastoreRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteDatastoreRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteDatastoreRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteDatastoreRequestValidationError) ErrorName() string { + return "DeleteDatastoreRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteDatastoreRequestValidationError) 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 %sDeleteDatastoreRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteDatastoreRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteDatastoreRequestValidationError{} + +// Validate checks the field values on DeleteDatastoreResponse 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 *DeleteDatastoreResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteDatastoreResponse 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 +// DeleteDatastoreResponseMultiError, or nil if none found. +func (m *DeleteDatastoreResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteDatastoreResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteDatastoreResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteDatastoreResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteDatastoreResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteDatastoreResponseMultiError(errors) + } + + return nil +} + +// DeleteDatastoreResponseMultiError is an error wrapping multiple validation +// errors returned by DeleteDatastoreResponse.ValidateAll() if the designated +// constraints aren't met. +type DeleteDatastoreResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteDatastoreResponseMultiError) 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 DeleteDatastoreResponseMultiError) AllErrors() []error { return m } + +// DeleteDatastoreResponseValidationError is the validation error returned by +// DeleteDatastoreResponse.Validate if the designated constraints aren't met. +type DeleteDatastoreResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteDatastoreResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteDatastoreResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteDatastoreResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteDatastoreResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteDatastoreResponseValidationError) ErrorName() string { + return "DeleteDatastoreResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteDatastoreResponseValidationError) 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 %sDeleteDatastoreResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteDatastoreResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteDatastoreResponseValidationError{} diff --git a/api/v1/services/datastore/datastore_bridge.pb.go b/api/v1/services/datastore/datastore_bridge.pb.go new file mode 100644 index 00000000..34b94072 --- /dev/null +++ b/api/v1/services/datastore/datastore_bridge.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: datastore/datastore.proto + +package datastore + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const DatastoreServiceCreateDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/CreateDatastore" +const DatastoreServiceDeleteDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" +const DatastoreServiceGetDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/GetDatastore" +const DatastoreServiceListDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/ListDatastore" +const DatastoreServiceUpdateDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/UpdateDatastore" + +type DatastoreServiceBridgeServer interface { + CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) + DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) + GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) + ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) + UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) +} + +type DatastoreServiceHooker interface { + DatastoreServiceCreateDatastoreHooker + DatastoreServiceDeleteDatastoreHooker + DatastoreServiceGetDatastoreHooker + DatastoreServiceListDatastoreHooker + DatastoreServiceUpdateDatastoreHooker +} + +type DatastoreServiceHookedBridger interface { + DatastoreServiceHooker + DatastoreServiceBridgeServer +} +type DatastoreServiceCreateDatastoreHooker interface { + PrepareCreateDatastore(http.Context, *CreateDatastoreRequest) (context.Context, error) + CompleteCreateDatastore(http.Context, *CreateDatastoreRequest, *CreateDatastoreResponse) error +} +type DatastoreServiceDeleteDatastoreHooker interface { + PrepareDeleteDatastore(http.Context, *DeleteDatastoreRequest) (context.Context, error) + CompleteDeleteDatastore(http.Context, *DeleteDatastoreRequest, *DeleteDatastoreResponse) error +} +type DatastoreServiceGetDatastoreHooker interface { + PrepareGetDatastore(http.Context, *GetDatastoreRequest) (context.Context, error) + CompleteGetDatastore(http.Context, *GetDatastoreRequest, *GetDatastoreResponse) error +} +type DatastoreServiceListDatastoreHooker interface { + PrepareListDatastore(http.Context, *ListDatastoreRequest) (context.Context, error) + CompleteListDatastore(http.Context, *ListDatastoreRequest, *ListDatastoreResponse) error +} +type DatastoreServiceUpdateDatastoreHooker interface { + PrepareUpdateDatastore(http.Context, *UpdateDatastoreRequest) (context.Context, error) + CompleteUpdateDatastore(http.Context, *UpdateDatastoreRequest, *UpdateDatastoreResponse) error +} + +func RegisterDatastoreServiceBridgeServer(s *http.Server, srv DatastoreServiceHookedBridger) { + r := s.Route("/") + r.GET("/datastore", _DatastoreService_ListDatastore0_Bridge_Handler(srv)) + r.GET("/datastore/:id", _DatastoreService_GetDatastore0_Bridge_Handler(srv)) + r.POST("/datastore", _DatastoreService_CreateDatastore0_Bridge_Handler(srv)) + r.PUT("/datastore/:data.id", _DatastoreService_UpdateDatastore0_Bridge_Handler(srv)) + r.DELETE("/datastore/:id", _DatastoreService_DeleteDatastore0_Bridge_Handler(srv)) +} + +func _DatastoreService_ListDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceListDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListDatastore(ctx, req.(*ListDatastoreRequest)) + }) + + newctx, err := srv.PrepareListDatastore(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListDatastore(ctx, &in, out.(*ListDatastoreResponse)) + } +} + +func _DatastoreService_GetDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceGetDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetDatastore(ctx, req.(*GetDatastoreRequest)) + }) + + newctx, err := srv.PrepareGetDatastore(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetDatastore(ctx, &in, out.(*GetDatastoreResponse)) + } +} + +func _DatastoreService_CreateDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateDatastoreRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceCreateDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateDatastore(ctx, req.(*CreateDatastoreRequest)) + }) + + newctx, err := srv.PrepareCreateDatastore(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateDatastore(ctx, &in, out.(*CreateDatastoreResponse)) + } +} + +func _DatastoreService_UpdateDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateDatastoreRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceUpdateDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateDatastore(ctx, req.(*UpdateDatastoreRequest)) + }) + + newctx, err := srv.PrepareUpdateDatastore(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateDatastore(ctx, &in, out.(*UpdateDatastoreResponse)) + } +} + +func _DatastoreService_DeleteDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceDeleteDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteDatastore(ctx, req.(*DeleteDatastoreRequest)) + }) + + newctx, err := srv.PrepareDeleteDatastore(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteDatastore(ctx, &in, out.(*DeleteDatastoreResponse)) + } +} + +// UnimplementedDatastoreServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedDatastoreServiceHooked struct{} + +func (UnimplementedDatastoreServiceHooked) PrepareCreateDatastore(ctx http.Context, in *CreateDatastoreRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDatastoreServiceHooked) CompleteCreateDatastore(ctx http.Context, in *CreateDatastoreRequest, out *CreateDatastoreResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDatastoreServiceHooked) PrepareDeleteDatastore(ctx http.Context, in *DeleteDatastoreRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDatastoreServiceHooked) CompleteDeleteDatastore(ctx http.Context, in *DeleteDatastoreRequest, out *DeleteDatastoreResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDatastoreServiceHooked) PrepareGetDatastore(ctx http.Context, in *GetDatastoreRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDatastoreServiceHooked) CompleteGetDatastore(ctx http.Context, in *GetDatastoreRequest, out *GetDatastoreResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDatastoreServiceHooked) PrepareListDatastore(ctx http.Context, in *ListDatastoreRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDatastoreServiceHooked) CompleteListDatastore(ctx http.Context, in *ListDatastoreRequest, out *ListDatastoreResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDatastoreServiceHooked) PrepareUpdateDatastore(ctx http.Context, in *UpdateDatastoreRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDatastoreServiceHooked) CompleteUpdateDatastore(ctx http.Context, in *UpdateDatastoreRequest, out *UpdateDatastoreResponse) error { + return ctx.Result(200, out) +} + +func WithDatastoreServiceHook(h DatastoreServiceHooker) func(DatastoreServiceBridgeServer) DatastoreServiceHookedBridger { + return func(srv DatastoreServiceBridgeServer) DatastoreServiceHookedBridger { + return DatastoreServiceHookedBridge{DatastoreServiceBridgeServer: srv, DatastoreServiceHooker: h} + } +} + +// DatastoreServiceHookedBridge is a bridge between the HTTP and gRPC implementations of DatastoreService. +// It implements the HTTP and gRPC implementations of DatastoreService. +// It forwards requests and responses between the two implementations. +type DatastoreServiceHookedBridge struct { + DatastoreServiceBridgeServer + DatastoreServiceHooker +} + +type DatastoreServiceHTTPBridgeImpl struct { + client DatastoreServiceHTTPClient +} + +func NewDatastoreServiceHTTPBridge(client *http.Client) DatastoreServiceHTTPServer { + return &DatastoreServiceHTTPBridgeImpl{client: NewDatastoreServiceHTTPClient(client)} +} + +func (c *DatastoreServiceHTTPBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTPBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTPBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { + return c.client.GetDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTPBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTPBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { + return c.client.UpdateDatastore(ctx, in) +} + +type DatastoreServiceBridgeImpl struct { + client DatastoreServiceClient +} + +func NewDatastoreServiceBridge(client grpc.ClientConnInterface) DatastoreServiceServer { + return &DatastoreServiceBridgeImpl{client: NewDatastoreServiceClient(client)} +} + +func (c *DatastoreServiceBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) +} + +func (c *DatastoreServiceBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + +func (c *DatastoreServiceBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { + return c.client.GetDatastore(ctx, in) +} + +func (c *DatastoreServiceBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) +} + +func (c *DatastoreServiceBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { + return c.client.UpdateDatastore(ctx, in) +} + +func (c *DatastoreServiceBridgeImpl) mustEmbedUnimplementedDatastoreServiceServer() {} + +type DatastoreServiceGRPC2HTTPBridgeImpl struct { + client DatastoreServiceClient +} + +func NewDatastoreServiceGRPC2HTTP(client grpc.ClientConnInterface) DatastoreServiceHTTPServer { + return &DatastoreServiceGRPC2HTTPBridgeImpl{client: NewDatastoreServiceClient(client)} +} + +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) +} + +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { + return c.client.GetDatastore(ctx, in) +} + +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) +} + +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { + return c.client.UpdateDatastore(ctx, in) +} + +type DatastoreServiceHTTP2GRPCBridgeImpl struct { + client DatastoreServiceHTTPClient +} + +func NewDatastoreServiceHTTP2GRPC(client *http.Client) DatastoreServiceServer { + return &DatastoreServiceHTTP2GRPCBridgeImpl{client: NewDatastoreServiceHTTPClient(client)} +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { + return c.client.GetDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { + return c.client.UpdateDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedDatastoreServiceServer() {} diff --git a/api/v1/services/datastore/datastore_grpc.pb.go b/api/v1/services/datastore/datastore_grpc.pb.go new file mode 100644 index 00000000..94daa542 --- /dev/null +++ b/api/v1/services/datastore/datastore_grpc.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: datastore/datastore.proto + +package datastore + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + DatastoreService_ListDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/ListDatastore" + DatastoreService_GetDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/GetDatastore" + DatastoreService_CreateDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/CreateDatastore" + DatastoreService_UpdateDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/UpdateDatastore" + DatastoreService_DeleteDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" +) + +// DatastoreServiceClient is the client API for DatastoreService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The data service definition. +type DatastoreServiceClient interface { + ListDatastore(ctx context.Context, in *ListDatastoreRequest, opts ...grpc.CallOption) (*ListDatastoreResponse, error) + GetDatastore(ctx context.Context, in *GetDatastoreRequest, opts ...grpc.CallOption) (*GetDatastoreResponse, error) + CreateDatastore(ctx context.Context, in *CreateDatastoreRequest, opts ...grpc.CallOption) (*CreateDatastoreResponse, error) + UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest, opts ...grpc.CallOption) (*UpdateDatastoreResponse, error) + DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest, opts ...grpc.CallOption) (*DeleteDatastoreResponse, error) +} + +type datastoreServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewDatastoreServiceClient(cc grpc.ClientConnInterface) DatastoreServiceClient { + return &datastoreServiceClient{cc} +} + +func (c *datastoreServiceClient) ListDatastore(ctx context.Context, in *ListDatastoreRequest, opts ...grpc.CallOption) (*ListDatastoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListDatastoreResponse) + err := c.cc.Invoke(ctx, DatastoreService_ListDatastore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *datastoreServiceClient) GetDatastore(ctx context.Context, in *GetDatastoreRequest, opts ...grpc.CallOption) (*GetDatastoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetDatastoreResponse) + err := c.cc.Invoke(ctx, DatastoreService_GetDatastore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *datastoreServiceClient) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest, opts ...grpc.CallOption) (*CreateDatastoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateDatastoreResponse) + err := c.cc.Invoke(ctx, DatastoreService_CreateDatastore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *datastoreServiceClient) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest, opts ...grpc.CallOption) (*UpdateDatastoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateDatastoreResponse) + err := c.cc.Invoke(ctx, DatastoreService_UpdateDatastore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *datastoreServiceClient) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest, opts ...grpc.CallOption) (*DeleteDatastoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteDatastoreResponse) + err := c.cc.Invoke(ctx, DatastoreService_DeleteDatastore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DatastoreServiceServer is the server API for DatastoreService service. +// All implementations must embed UnimplementedDatastoreServiceServer +// for forward compatibility. +// +// The data service definition. +type DatastoreServiceServer interface { + ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) + GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) + CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) + UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) + DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) + mustEmbedUnimplementedDatastoreServiceServer() +} + +// UnimplementedDatastoreServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedDatastoreServiceServer struct{} + +func (UnimplementedDatastoreServiceServer) ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListDatastore not implemented") +} +func (UnimplementedDatastoreServiceServer) GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDatastore not implemented") +} +func (UnimplementedDatastoreServiceServer) CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateDatastore not implemented") +} +func (UnimplementedDatastoreServiceServer) UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateDatastore not implemented") +} +func (UnimplementedDatastoreServiceServer) DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteDatastore not implemented") +} +func (UnimplementedDatastoreServiceServer) mustEmbedUnimplementedDatastoreServiceServer() {} +func (UnimplementedDatastoreServiceServer) testEmbeddedByValue() {} + +// UnsafeDatastoreServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to DatastoreServiceServer will +// result in compilation errors. +type UnsafeDatastoreServiceServer interface { + mustEmbedUnimplementedDatastoreServiceServer() +} + +func RegisterDatastoreServiceServer(s grpc.ServiceRegistrar, srv DatastoreServiceServer) { + // If the following call pancis, it indicates UnimplementedDatastoreServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&DatastoreService_ServiceDesc, srv) +} + +func _DatastoreService_ListDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListDatastoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DatastoreServiceServer).ListDatastore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DatastoreService_ListDatastore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DatastoreServiceServer).ListDatastore(ctx, req.(*ListDatastoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DatastoreService_GetDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetDatastoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DatastoreServiceServer).GetDatastore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DatastoreService_GetDatastore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DatastoreServiceServer).GetDatastore(ctx, req.(*GetDatastoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DatastoreService_CreateDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateDatastoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DatastoreServiceServer).CreateDatastore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DatastoreService_CreateDatastore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DatastoreServiceServer).CreateDatastore(ctx, req.(*CreateDatastoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DatastoreService_UpdateDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateDatastoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DatastoreServiceServer).UpdateDatastore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DatastoreService_UpdateDatastore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DatastoreServiceServer).UpdateDatastore(ctx, req.(*UpdateDatastoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DatastoreService_DeleteDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteDatastoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DatastoreServiceServer).DeleteDatastore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DatastoreService_DeleteDatastore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DatastoreServiceServer).DeleteDatastore(ctx, req.(*DeleteDatastoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// DatastoreService_ServiceDesc is the grpc.ServiceDesc for DatastoreService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var DatastoreService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.datastore.DatastoreService", + HandlerType: (*DatastoreServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListDatastore", + Handler: _DatastoreService_ListDatastore_Handler, + }, + { + MethodName: "GetDatastore", + Handler: _DatastoreService_GetDatastore_Handler, + }, + { + MethodName: "CreateDatastore", + Handler: _DatastoreService_CreateDatastore_Handler, + }, + { + MethodName: "UpdateDatastore", + Handler: _DatastoreService_UpdateDatastore_Handler, + }, + { + MethodName: "DeleteDatastore", + Handler: _DatastoreService_DeleteDatastore_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "datastore/datastore.proto", +} diff --git a/api/v1/services/datastore/datastore_http.pb.go b/api/v1/services/datastore/datastore_http.pb.go new file mode 100644 index 00000000..7b8497ff --- /dev/null +++ b/api/v1/services/datastore/datastore_http.pb.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.8.4 +// - protoc (unknown) +// source: datastore/datastore.proto + +package datastore + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationDatastoreServiceCreateDatastore = "/api.v1.services.datastore.DatastoreService/CreateDatastore" +const OperationDatastoreServiceDeleteDatastore = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" +const OperationDatastoreServiceGetDatastore = "/api.v1.services.datastore.DatastoreService/GetDatastore" +const OperationDatastoreServiceListDatastore = "/api.v1.services.datastore.DatastoreService/ListDatastore" +const OperationDatastoreServiceUpdateDatastore = "/api.v1.services.datastore.DatastoreService/UpdateDatastore" + +type DatastoreServiceHTTPServer interface { + CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) + DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) + GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) + ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) + UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) +} + +func RegisterDatastoreServiceHTTPServer(s *http.Server, srv DatastoreServiceHTTPServer) { + r := s.Route("/") + r.GET("/datastore", _DatastoreService_ListDatastore0_HTTP_Handler(srv)) + r.GET("/datastore/{id}", _DatastoreService_GetDatastore0_HTTP_Handler(srv)) + r.POST("/datastore", _DatastoreService_CreateDatastore0_HTTP_Handler(srv)) + r.PUT("/datastore/{data.id}", _DatastoreService_UpdateDatastore0_HTTP_Handler(srv)) + r.DELETE("/datastore/{id}", _DatastoreService_DeleteDatastore0_HTTP_Handler(srv)) +} + +func _DatastoreService_ListDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceListDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListDatastore(ctx, req.(*ListDatastoreRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListDatastoreResponse) + return ctx.Result(200, reply) + } +} + +func _DatastoreService_GetDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceGetDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetDatastore(ctx, req.(*GetDatastoreRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetDatastoreResponse) + return ctx.Result(200, reply) + } +} + +func _DatastoreService_CreateDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateDatastoreRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceCreateDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateDatastore(ctx, req.(*CreateDatastoreRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateDatastoreResponse) + return ctx.Result(200, reply) + } +} + +func _DatastoreService_UpdateDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateDatastoreRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceUpdateDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateDatastore(ctx, req.(*UpdateDatastoreRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateDatastoreResponse) + return ctx.Result(200, reply) + } +} + +func _DatastoreService_DeleteDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceDeleteDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteDatastore(ctx, req.(*DeleteDatastoreRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeleteDatastoreResponse) + return ctx.Result(200, reply) + } +} + +type DatastoreServiceHTTPClient interface { + CreateDatastore(ctx context.Context, req *CreateDatastoreRequest, opts ...http.CallOption) (rsp *CreateDatastoreResponse, err error) + DeleteDatastore(ctx context.Context, req *DeleteDatastoreRequest, opts ...http.CallOption) (rsp *DeleteDatastoreResponse, err error) + GetDatastore(ctx context.Context, req *GetDatastoreRequest, opts ...http.CallOption) (rsp *GetDatastoreResponse, err error) + ListDatastore(ctx context.Context, req *ListDatastoreRequest, opts ...http.CallOption) (rsp *ListDatastoreResponse, err error) + UpdateDatastore(ctx context.Context, req *UpdateDatastoreRequest, opts ...http.CallOption) (rsp *UpdateDatastoreResponse, err error) +} + +type DatastoreServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewDatastoreServiceHTTPClient(client *http.Client) DatastoreServiceHTTPClient { + return &DatastoreServiceHTTPClientImpl{client} +} + +func (c *DatastoreServiceHTTPClientImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest, opts ...http.CallOption) (*CreateDatastoreResponse, error) { + var out CreateDatastoreResponse + pattern := "/datastore" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationDatastoreServiceCreateDatastore)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DatastoreServiceHTTPClientImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest, opts ...http.CallOption) (*DeleteDatastoreResponse, error) { + var out DeleteDatastoreResponse + pattern := "/datastore/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDatastoreServiceDeleteDatastore)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DatastoreServiceHTTPClientImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest, opts ...http.CallOption) (*GetDatastoreResponse, error) { + var out GetDatastoreResponse + pattern := "/datastore/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDatastoreServiceGetDatastore)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DatastoreServiceHTTPClientImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest, opts ...http.CallOption) (*ListDatastoreResponse, error) { + var out ListDatastoreResponse + pattern := "/datastore" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDatastoreServiceListDatastore)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DatastoreServiceHTTPClientImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest, opts ...http.CallOption) (*UpdateDatastoreResponse, error) { + var out UpdateDatastoreResponse + pattern := "/datastore/{data.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationDatastoreServiceUpdateDatastore)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/helpers/i18n/i18n.go b/helpers/i18n/i18n.go index 67546bc1..da1845e8 100644 --- a/helpers/i18n/i18n.go +++ b/helpers/i18n/i18n.go @@ -118,7 +118,6 @@ func LocaleText(locale string, key string) string { return text } } - //fmt.Println("locale.", "default", "key.", key, "text.", "default") return key } diff --git a/internal/mods/datastore/biz/permission.biz.go b/internal/mods/datastore/biz/datastore.go similarity index 100% rename from internal/mods/datastore/biz/permission.biz.go rename to internal/mods/datastore/biz/datastore.go diff --git a/internal/mods/datastore/biz/resource.biz.go b/internal/mods/datastore/biz/resource.biz.go deleted file mode 100644 index 2b980143..00000000 --- a/internal/mods/datastore/biz/resource.biz.go +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/pagination" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dto" -) - -// ResourceServiceBiz is a ResourcePB use case. -type ResourceServiceBiz struct { - dao dto.ResourceRepo - limiter pagination.PageLimiter - log *log.KHelper -} - -func (biz ResourceServiceBiz) ListResources(ctx context.Context, in *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { - var option dto.ResourceQueryOption - if err := option.FromListRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("ListResources") - result, total, err := biz.dao.List(ctx, in, option) - if err != nil { - return nil, err - } - return dto.ToListResourcesResponse(result, in, total) -} - -func (biz ResourceServiceBiz) GetResource(ctx context.Context, in *pb.GetResourceRequest) (*pb.GetResourceResponse, error) { - var option dto.ResourceQueryOption - if err := option.FromGetRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("GetResource") - result, err := biz.dao.Get(ctx, in.GetId(), option) - if err != nil { - return nil, err - } - return &pb.GetResourceResponse{ - Resource: result, - }, nil -} - -func (biz ResourceServiceBiz) CreateResource(ctx context.Context, in *pb.CreateResourceRequest) (*pb.CreateResourceResponse, error) { - var option dto.ResourceQueryOption - if err := option.FromCreateRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("CreateResource") - result, err := biz.dao.Create(ctx, in.Resource, option) - if err != nil { - return nil, err - } - return &pb.CreateResourceResponse{ - Resource: result, - }, nil -} - -var updateFields = []string{ - resource.FieldIcon, resource.FieldType, resource.FieldStatus, - resource.FieldName, resource.FieldPath, resource.FieldKeyword, - resource.FieldSequence, resource.FieldProperties, resource.FieldDescription, -} - -func (biz ResourceServiceBiz) UpdateResource(ctx context.Context, in *pb.UpdateResourceRequest) (*pb.UpdateResourceResponse, error) { - var option dto.ResourceQueryOption - - log.Info("UpdateResource") - option.Fields = resource.SelectColumns(updateFields) - result, err := biz.dao.Update(ctx, in.Resource, option) - if err != nil { - return nil, err - } - return &pb.UpdateResourceResponse{ - Resource: result, - }, nil -} - -func (biz ResourceServiceBiz) DeleteResource(ctx context.Context, in *pb.DeleteResourceRequest) (*pb.DeleteResourceResponse, error) { - log.Info("DeleteResource") - if err := biz.dao.Delete(ctx, in.GetId()); err != nil { - return nil, err - } - return &pb.DeleteResourceResponse{}, nil -} - -// NewResourceServiceBiz new a ResourcePB use case. -func NewResourceServiceBiz(r runtime.Runtime, repo dto.ResourceRepo) *ResourceServiceBiz { - return &ResourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} -} diff --git a/internal/mods/datastore/biz/role.biz.go b/internal/mods/datastore/biz/role.biz.go deleted file mode 100644 index 78afc8d2..00000000 --- a/internal/mods/datastore/biz/role.biz.go +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/pagination" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" -) - -// RoleServiceBiz is a RolePB use case. -type RoleServiceBiz struct { - dao dto.RoleRepo - limiter pagination.PageLimiter - log *log.KHelper -} - -func (biz RoleServiceBiz) ListRoles(ctx context.Context, in *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { - var option dto.RoleQueryOption - if err := option.FromListRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("ListRoles") - option.IncludePermissions = true - result, total, err := biz.dao.List(ctx, in, option) - if err != nil { - return nil, err - } - return dto.ToListRolesResponse(result, in, total) -} - -func (biz RoleServiceBiz) GetRole(ctx context.Context, in *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { - var option dto.RoleQueryOption - if err := option.FromGetRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("GetRole") - result, err := biz.dao.Get(ctx, in.GetId(), option) - if err != nil { - return nil, err - } - return &pb.GetRoleResponse{ - Role: result, - }, nil -} - -func (biz RoleServiceBiz) CreateRole(ctx context.Context, in *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { - var option dto.RoleUpdateOption - if err := option.FromCreateRequest(in); err != nil { - return nil, err - } - log.Info("CreateRole") - result, err := biz.dao.Create(ctx, in.Role, option) - if err != nil { - return nil, err - } - return &pb.CreateRoleResponse{ - Role: result, - }, nil -} - -func (biz RoleServiceBiz) UpdateRole(ctx context.Context, in *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { - //var option dto.UpdateRoleOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("UpdateRole") - result, err := biz.dao.Update(ctx, in.Role) - if err != nil { - return nil, err - } - return &pb.UpdateRoleResponse{ - Role: result, - }, nil -} - -func (biz RoleServiceBiz) DeleteRole(ctx context.Context, in *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { - //var option dto.DeleteRoleOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - //_, err := biz.dao.Get(ctx, in.GetId()) - //if err != nil { - // return nil, err - //} - log.Info("DeleteRole") - if err := biz.dao.Delete(ctx, in.GetId()); err != nil { - return nil, err - } - return &pb.DeleteRoleResponse{}, nil -} - -// NewRoleServiceBiz new a RolePB use case. -func NewRoleServiceBiz(r runtime.Runtime, repo dto.RoleRepo) *RoleServiceBiz { - return &RoleServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} -} diff --git a/internal/mods/datastore/biz/user.biz.go b/internal/mods/datastore/biz/user.biz.go deleted file mode 100644 index ad8ddc0b..00000000 --- a/internal/mods/datastore/biz/user.biz.go +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "fmt" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/pagination" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" -) - -// UserServiceBiz is a UserPB use case. -type UserServiceBiz struct { - dao dto.UserRepo - limiter pagination.PageLimiter - log *log.KHelper -} - -func (biz UserServiceBiz) ListUserResources(ctx context.Context, in *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { - var option dto.UserQueryOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("ListUserResources") - //option.IncludeRoles = true - result, err := biz.dao.ListResourceByUserID(ctx, in.GetId(), option) - if err != nil { - return nil, err - } - log.Info("ListUserResources result:", result) - //return dto.ToListResourcesResponse(result, in, total) - return &pb.ListUserResourcesResponse{ - TotalSize: int32(len(result)), - //Current: in.Current, - //PageSize: in.PageSize, - Resources: result, - //Extra: resp.Any(args...), - }, nil -} - -func (biz UserServiceBiz) UpdateUserRoles(ctx context.Context, in *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { - var option dto.UserMutationOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("UpdateUserRoles") - //option.IncludeRoles = true - err := biz.dao.AddRoleIDs(ctx, in.GetUser().GetId(), in.GetRoleIds(), option) - if err != nil { - return nil, err - } - return &pb.UpdateUserRolesResponse{ - //User: result, - }, nil -} - -func (biz UserServiceBiz) UpdateUserStatus(ctx context.Context, in *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { - var option dto.UserQueryOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("UpdateUserStatus") - option.Fields = []string{"status"} - //option.IncludeRoles = true - err := biz.dao.UpdateUserStatus(ctx, in.GetUser().GetId(), int8(in.GetUser().GetStatus()), option) - if err != nil { - return nil, err - } - return &pb.UpdateUserStatusResponse{ - //User: result, - }, nil -} - -func (biz UserServiceBiz) ResetUserPassword(ctx context.Context, in *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { - var option dto.UserQueryOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("ResetUserPassword") - option.IncludeRoles = true - //result, total, err := biz.dao.ResetUserPassword(ctx, in, option) - //if err != nil { - // return nil, err - //} - //return dto.ToListUsersResponse(result, in, total) - return &pb.ResetUserPasswordResponse{}, nil -} - -func (biz UserServiceBiz) ListUsers(ctx context.Context, in *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { - var option dto.UserQueryOption - if err := option.FromListRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("ListUsers") - option.IncludeRoles = true - result, total, err := biz.dao.List(ctx, in, option) - if err != nil { - return nil, err - } - return dto.ToListUsersResponse(result, in, total) -} - -func (biz UserServiceBiz) GetUser(ctx context.Context, in *pb.GetUserRequest) (*pb.GetUserResponse, error) { - var option dto.UserQueryOption - if err := option.FromGetRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("GetUser") - result, err := biz.dao.Get(ctx, in.GetId(), option) - if err != nil { - return nil, err - } - return &pb.GetUserResponse{ - User: result, - }, nil -} - -func (biz UserServiceBiz) CreateUser(ctx context.Context, in *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { - var option dto.UserMutationOption - if err := option.FromCreateRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("MakeCreateUser") - username := in.GetUser().GetUsername() - password := in.GetUser().GetPassword() - createUser, ps, err := dto.MakeCreateUser(in.User, username, password, option) - if err != nil { - return nil, err - } - // TODO: Send email or sms to user - _ = ps - fmt.Println("Create new user username:", username, "password:", ps) - - result, err := biz.dao.Create(ctx, createUser, option) - if err != nil { - return nil, err - } - return &pb.CreateUserResponse{ - User: result, - }, nil -} - -func (biz UserServiceBiz) UpdateUser(ctx context.Context, in *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { - //var option dto.UpdateUserOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("UpdateUser") - result, err := biz.dao.Update(ctx, in.User) - if err != nil { - return nil, err - } - return &pb.UpdateUserResponse{ - User: result, - }, nil -} - -func (biz UserServiceBiz) DeleteUser(ctx context.Context, in *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { - log.Info("DeleteUser") - if err := biz.dao.Delete(ctx, in.GetUser().GetId()); err != nil { - return nil, err - } - return &pb.DeleteUserResponse{}, nil -} - -// NewUserServiceBiz new a UserPB use case. - -func NewUserServiceBiz(r runtime.Runtime, repo dto.UserRepo) *UserServiceBiz { - return &UserServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} -} diff --git a/internal/mods/system/service/service.go b/internal/mods/system/service/service.go index 8bca0e67..e398a718 100644 --- a/internal/mods/system/service/service.go +++ b/internal/mods/system/service/service.go @@ -42,6 +42,7 @@ func (s RegisterServer) RegisterGRPC(ctx context.Context, server *service.GRPCSe func (s RegisterServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { log.Info("http server system init") + server.Route("/sys") pb.RegisterResourceServiceHTTPServer(server, s.Resource) pb.RegisterRoleServiceHTTPServer(server, s.Role) pb.RegisterUserServiceHTTPServer(server, s.User) From b7325f6f5689991b1df25115453f7d49de3b9665 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 22 Sep 2025 14:16:48 +0800 Subject: [PATCH 057/158] feat(loader): update config types and transport configurations - Replace configv1 types with configs types for consistency - Add TLSConfig support using securityv1 and transportv1 - Introduce durationpb for timeout fields in GRPCServer and HTTPServer - Remove unused configv1 import - Update DefaultServiceGrpc and DefaultServiceHttp to use transportv1 types - Adjust DefaultServices and related functions to align with new types - Remove deprecated bootstrap_bak package files - Update integration test comments to English --- internal/loader/bootstrap_default.go | 146 ++++++++++++--------------- 1 file changed, 66 insertions(+), 80 deletions(-) diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go index fb93c820..62a2379f 100644 --- a/internal/loader/bootstrap_default.go +++ b/internal/loader/bootstrap_default.go @@ -1,14 +1,9 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. package loader import ( "time" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + // configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" // REMOVE middlewarev1 "github.com/origadmin/runtime/api/gen/go/middleware/v1" jwtv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/jwt" "github.com/origadmin/runtime/api/gen/go/middleware/v1/metrics" @@ -16,8 +11,11 @@ import ( "github.com/origadmin/runtime/api/gen/go/middleware/v1/selector" "github.com/origadmin/runtime/api/gen/go/middleware/v1/validator" sjwtv1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" + securityv1 "github.com/origadmin/runtime/api/gen/go/security/transport/v1" // ADD for TLSConfig + transportv1 "github.com/origadmin/runtime/api/gen/go/transport/v1" // ADD "origadmin/application/admin/internal/configs" + "google.golang.org/protobuf/types/known/durationpb" ) const ( @@ -36,11 +34,11 @@ func DefaultBootstrap() *configs.Bootstrap { Id: "", Entry: &configs.Bootstrap_Entry{ Scheme: "http", - Services: DefaultServices(), + Services: DefaultServices(), // This will cause a type mismatch after this change Cors: DefaultEntryCors(), }, Server: &configs.ServiceServer{ - Services: DefaultServices(), + Services: DefaultServices(), // This will cause a type mismatch after this change Middleware: DefaultServiceMiddleware(), }, Clients: DefaultServiceClients(), @@ -51,7 +49,7 @@ func DefaultBootstrap() *configs.Bootstrap { Security: &configs.SecurityConfig{ RootUser: DefaultRootUser(), Captcha: DefaultCaptcha(), - Security: &configv1.Security{ + Security: &configs.Security{ PublicPaths: []string{ "/swagger/*", "/api/v1/health", @@ -73,21 +71,21 @@ func DefaultBootstrap() *configs.Bootstrap { //"/api.v1.services.basis.LoginAPI/CurrentUser", //"/api.v1.services.basis.LoginAPI/CurrentMenus", }, - Authz: &configv1.AuthZConfig{ + Authz: &configs.AuthZConfig{ Disabled: false, PublicPaths: nil, Type: "casbin", - Casbin: &configv1.AuthZConfig_CasbinConfig{ + Casbin: &configs.AuthZConfig_CasbinConfig{ PolicyFile: "", ModelFile: "", }, Opa: nil, Zanzibar: nil, }, - Authn: &configv1.AuthNConfig{ + Authn: &configs.AuthNConfig{ Disabled: false, Type: "jwt", - Jwt: &configv1.AuthNConfig_JWTConfig{ + Jwt: &configs.AuthNConfig_JWTConfig{ Algorithm: "HS512", SigningKey: SigningKey, OldSigningKey: "", @@ -101,8 +99,8 @@ func DefaultBootstrap() *configs.Bootstrap { } } -func DefaultEntryCors() *configv1.Cors { - return &configv1.Cors{ +func DefaultEntryCors() *configs.Cors { + return &configs.Cors{ AllowOrigins: []string{"*"}, AllowMethods: []string{"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS"}, AllowHeaders: []string{"X-Requested-With", "Content-Type", "Authorization"}, @@ -112,18 +110,18 @@ func DefaultEntryCors() *configv1.Cors { } } -func DefaultServices() []*configv1.Service { - return []*configv1.Service{ +func DefaultServices() []*configs.Service { + return []*configs.Service{ { Name: "", DynamicEndpoint: true, Type: "grpc", - Grpc: DefaultServiceGrpc(), + Grpc: DefaultServiceGrpc(), // This will cause a type mismatch Websocket: DefaultServiceWebsocket(), Message: DefaultServiceMessage(), Task: DefaultServiceTask(), //Middleware: DefaultServiceMiddleware(), - Selector: &configv1.Service_Selector{ + Selector: &configs.Service_Selector{ Version: "v1.0.0", Builder: "bbr", }, @@ -132,12 +130,12 @@ func DefaultServices() []*configv1.Service { Name: "", DynamicEndpoint: true, Type: "http", - Http: DefaultServiceHttp(), + Http: DefaultServiceHttp(), // This will cause a type mismatch Websocket: DefaultServiceWebsocket(), Message: DefaultServiceMessage(), Task: DefaultServiceTask(), //Middleware: DefaultServiceMiddleware(), - Selector: &configv1.Service_Selector{ + Selector: &configs.Service_Selector{ Version: "v1.0.0", Builder: "bbr", }, @@ -159,15 +157,15 @@ func DefaultServiceClients() []*configs.ServiceClient { core.Discovery.ServiceName = serviceName clients = append(clients, &configs.ServiceClient{ Core: core, - Services: DefaultServices(), + Services: DefaultServices(), // This will cause a type mismatch after this change Middleware: DefaultServiceMiddleware(), }) } return clients } -func DefaultLogger() *configv1.Logger { - return &configv1.Logger{ +func DefaultLogger() *configs.Logger { + return &configs.Logger{ Disabled: false, Develop: true, Default: true, @@ -178,7 +176,7 @@ func DefaultLogger() *configv1.Logger { DisableCaller: false, CallerSkip: 0, TimeFormat: "", - File: &configv1.Logger_File{ + File: &configs.Logger_File{ Path: "logs", Lumberjack: true, Compress: false, @@ -191,22 +189,22 @@ func DefaultLogger() *configv1.Logger { } } -func DefaultServiceWebsocket() *configv1.WebSocket { - return &configv1.WebSocket{ +func DefaultServiceWebsocket() *configs.WebSocket { + return &configs.WebSocket{ Addr: "", Path: "", } } -func DefaultStorage() *configv1.Storage { - return &configv1.Storage{ +func DefaultStorage() *configs.Storage { + return &configs.Storage{ Name: "", Type: "", - Database: &configv1.Database{ + Database: &configs.Database{ Debug: false, Dialect: "sqlite3", Source: "data/admin.db", - Migration: &configv1.Migration{ + Migration: &configs.Migration{ Enabled: false, Path: "", Names: nil, @@ -220,22 +218,22 @@ func DefaultStorage() *configv1.Storage { ConnectionMaxLifetime: 0, ConnectionMaxIdleTime: 0, }, - Cache: &configv1.Cache{ + Cache: &configs.Cache{ Driver: "memory", //["none", "redis", "memcached", "memory"] [string.in] - Memcached: &configv1.Memcached{ + Memcached: &configs.Memcached{ Addr: "", Username: "", Password: "", MaxIdle: 0, Timeout: 0, }, - Memory: &configv1.Memory{ + Memory: &configs.Memory{ Size: 0, Capacity: 0, Expiration: 0, CleanupInterval: 0, }, - Redis: &configv1.Redis{ + Redis: &configs.Redis{ Network: "", Addr: "", Password: "", @@ -244,7 +242,7 @@ func DefaultStorage() *configv1.Storage { ReadTimeout: 0, WriteTimeout: 0, }, - Badger: &configv1.BadgerDS{ + Badger: &configs.BadgerDS{ Path: "", SyncWrites: false, ValueLogFileSize: 0, @@ -259,71 +257,69 @@ func DefaultStorage() *configv1.Storage { } } -func DefaultServiceTask() *configv1.Task { - return &configv1.Task{ +func DefaultServiceTask() *configs.Task { + return &configs.Task{ Type: "none", //["none", "asynq", "machinery", "cron"] [string.in] Name: "", - Asynq: &configv1.Task_Asynq{ + Asynq: &configs.Task_Asynq{ Endpoint: "", Password: "", Db: 0, Location: "", }, - Machinery: &configv1.Task_Machinery{ + Machinery: &configs.Task_Machinery{ Brokers: nil, Backends: nil, }, - Cron: &configv1.Task_Cron{ + Cron: &configs.Task_Cron{ Addr: "", }, } } -func DefaultServiceMessage() *configv1.Message { - return &configv1.Message{ +func DefaultServiceMessage() *configs.Message { + return &configs.Message{ Type: "none", //["none", "mqtt", "kafka", "rabbitmq", "activemq", "nats", "nsq", "pulsar", "redis", "rocketmq"] Name: "", - Mqtt: &configv1.Message_MQTT{ + Mqtt: &configs.Message_MQTT{ Endpoint: "", Codec: "", }, - Kafka: &configv1.Message_Kafka{ + Kafka: &configs.Message_Kafka{ Endpoint: "", Codec: "", }, - Rabbitmq: &configv1.Message_RabbitMQ{ - Endpoint: "", - Codec: "", + Rabbitmq: &configs.Message_RabbitMQ{ + Endpoint: "", Codec: "", }, - Activemq: &configv1.Message_ActiveMQ{ + Activemq: &configs.Message_ActiveMQ{ Endpoint: "", Codec: "", }, - Nats: &configv1.Message_NATS{ + Nats: &configs.Message_NATS{ Endpoint: "", Codec: "", }, - Nsq: &configv1.Message_NSQ{ + Nsq: &configs.Message_NSQ{ Endpoint: "", Codec: "", }, - Pulsar: &configv1.Message_Pulsar{ + Pulsar: &configs.Message_Pulsar{ Endpoint: "", Codec: "", }, - Redis: &configv1.Message_Redis{ + Redis: &configs.Message_Redis{ Endpoint: "", Codec: "", }, - Rocketmq: &configv1.Message_RocketMQ{ + Rocketmq: &configs.Message_RocketMQ{ Endpoint: "", Codec: "", EnableTrace: false, NameServers: nil, NameServerDomain: "", AccessKey: "", - SecretKey: "", - SecurityToken: "", + SecretKey: "", SecurityToken: "", Namespace: "", InstanceName: "", GroupName: "", @@ -331,11 +327,11 @@ func DefaultServiceMessage() *configv1.Message { } } -func DefaultDiscovery() *configv1.Discovery { - return &configv1.Discovery{ +func DefaultDiscovery() *configs.Discovery { + return &configs.Discovery{ Debug: false, Type: "consul", - Consul: &configv1.Discovery_Consul{ + Consul: &configs.Discovery_Consul{ Address: "${consul_address:127.0.0.1:8500}", Scheme: "http", Token: "", @@ -404,34 +400,24 @@ func DefaultServiceMiddleware() *middlewarev1.Middleware { } } -func DefaultServiceGrpc() *configv1.Service_GRPC { - return &configv1.Service_GRPC{ +func DefaultServiceGrpc() *transportv1.GRPCServer { + return &transportv1.GRPCServer{ Network: "tcp", Addr: "${grpc_address:0.0.0.0:18000}", - UseTls: false, - //CertFile: "", - //KeyFile: "", - Timeout: 0, - ShutdownTimeout: 0, - ReadTimeout: 0, - WriteTimeout: 0, - IdleTimeout: 0, + Tls: &securityv1.TLSConfig{Enabled: false}, // Replaced UseTls + Timeout: &durationpb.Duration{}, // Use durationpb.Duration + ShutdownTimeout: &durationpb.Duration{}, // Use durationpb.Duration Endpoint: "", } } -func DefaultServiceHttp() *configv1.Service_HTTP { - return &configv1.Service_HTTP{ +func DefaultServiceHttp() *transportv1.HTTPServer { + return &transportv1.HTTPServer{ Network: "tcp", Addr: "${http_address:0.0.0.0:18100}", - UseTls: false, - //CertFile: "", - //KeyFile: "", - Timeout: 0, - ShutdownTimeout: 0, - ReadTimeout: 0, - WriteTimeout: 0, - IdleTimeout: 0, + Tls: &securityv1.TLSConfig{Enabled: false}, // Replaced UseTls + Timeout: &durationpb.Duration{}, // Use durationpb.Duration + ShutdownTimeout: &durationpb.Duration{}, // Use durationpb.Duration Endpoint: "", } } @@ -448,7 +434,7 @@ func DefaultCaptcha() *configs.Captcha { Width: 400, Height: 160, StorageName: "captcha", - Storage: &configv1.Storage{}, + Storage: &configs.Storage{}, } } From 2b5b6c96a3796f6462fda2e3171bd7d3ea789544 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 24 Sep 2025 17:40:11 +0800 Subject: [PATCH 058/158] refactor(slogx): extract default options to function and use configure.Apply for options --- contrib/consul/config/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/consul/config/config.go b/contrib/consul/config/config.go index af39397e..27045f31 100644 --- a/contrib/consul/config/config.go +++ b/contrib/consul/config/config.go @@ -53,8 +53,8 @@ func NewConsulConfig(ccfg *configv1.SourceConfig, options *config.Options) (conf //} // //options.Sources = append(options.Sources, configSources...) - //if options.Decoder != nil { - // options.ConfigOptions = append(options.ConfigOptions, config.WithDecoder(options.Decoder)) + //if options.Config != nil { + // options.ConfigOptions = append(options.ConfigOptions, config.WithDecoder(options.Config)) //} return source, nil } From a9b9aa9c0a45b1bf61296dbb4dd0258ea75e294b Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Sep 2025 17:47:35 +0800 Subject: [PATCH 059/158] chore(issue-templates): Refactor and standardize GitHub issue templates --- go.mod | 2 +- go.sum | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index f688d85e..a21e1089 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module origadmin/application/admin -go 1.23.7 +go 1.23.1 replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0.5.4 diff --git a/go.sum b/go.sum index 8cc0c554..e6283942 100644 --- a/go.sum +++ b/go.sum @@ -1115,6 +1115,7 @@ github.com/origadmin/go-metrics v0.5.4 h1:odg6zeZUGkTCl6cGJ/bS5GlvjZ3x3GU2zyw9Wt github.com/origadmin/go-metrics v0.5.4/go.mod h1:KiuAdjBbuXAkjTjy7p7F4g6sjO6WuvH+6hTlMKUxPkg= github.com/origadmin/runtime v0.2.0 h1:4FbuNYqJbQZFZrKQB6l/L5RXlC3hr40uWFKjUMUYMgA= github.com/origadmin/runtime v0.2.0/go.mod h1:b+TK2xaJlTsna1RESE4+y9Do+qz80Wnz2+KqrA4gLnI= +github.com/origadmin/runtime v0.2.3/go.mod h1:rgOxokXjWXXbzzHr2ICXW3KNsQ8KNGFqjMcpGo54aOM= github.com/origadmin/slog-kratos v1.0.4 h1:1et3TBy61Uwf5N1ZbEBFhMqCjgxqfRXmz2w0Q1dujG0= github.com/origadmin/slog-kratos v1.0.4/go.mod h1:WUdhcWLyN0i8TbdemqE2Y/muoj0GaZ86OcdpumAWHPo= github.com/origadmin/toolkits v0.3.16 h1:R/Ws2S2W64ZScSkBz4QQ8HPXWpuH/ac+z1z0iHPyG0M= From 62abe1f7899ca2ad1ead93c8af7da73aa9398dae Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 28 Oct 2025 02:52:49 +0800 Subject: [PATCH 060/158] chore(security): Refactor settings to configure package in authn and authz modules --- contrib/security/authn/jwt/authn.go | 4 ++-- contrib/security/authn/jwt/jwt.go | 4 ++-- contrib/security/authz/casbin/casbin.go | 4 ++-- helpers/securityx/auth.go | 5 ++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/contrib/security/authn/jwt/authn.go b/contrib/security/authn/jwt/authn.go index 91aff198..c57725d9 100644 --- a/contrib/security/authn/jwt/authn.go +++ b/contrib/security/authn/jwt/authn.go @@ -8,7 +8,7 @@ package jwt import ( "context" - "github.com/goexts/generic/settings" + "github.com/goexts/generic/configure" "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/interfaces/security/token" @@ -52,7 +52,7 @@ func (obj Authenticator) key(ns, token string) string { type AuthenticatorSetting = func(*Authenticator) func NewAuthenticator(tokenizer security.Tokenizer, ss ...AuthenticatorSetting) security.Authenticator { - return settings.Apply(&Authenticator{ + return configure.Apply(&Authenticator{ Tokenizer: tokenizer, Cache: token.New(), Scheme: security.SchemeBearer, diff --git a/contrib/security/authn/jwt/jwt.go b/contrib/security/authn/jwt/jwt.go index 82c90cfb..4cb535bb 100644 --- a/contrib/security/authn/jwt/jwt.go +++ b/contrib/security/authn/jwt/jwt.go @@ -12,7 +12,7 @@ import ( "time" "github.com/dchest/uniuri" - "github.com/goexts/generic/settings" + "github.com/goexts/generic/configure" jwtv5 "github.com/golang-jwt/jwt/v5" configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" @@ -261,7 +261,7 @@ func NewTokenizer(cfg *configv1.Security, ss ...Setting) (security.RefreshTokeni if config == nil { return nil, errors.New("authenticator jwt config is empty") } - option := settings.Apply(&Option{ + option := configure.Apply(&Option{ issuer: defaultIssuerDomain, }, ss) tokenizer := &Tokenizer{ diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go index 4e02e01d..ad92f22d 100644 --- a/contrib/security/authz/casbin/casbin.go +++ b/contrib/security/authz/casbin/casbin.go @@ -11,8 +11,8 @@ import ( casbinmodel "github.com/casbin/casbin/v2/model" "github.com/casbin/casbin/v2/persist" "github.com/goexts/generic/cmp" + "github.com/goexts/generic/configure" "github.com/goexts/generic/maps" - "github.com/goexts/generic/settings" configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/interfaces/security" @@ -138,7 +138,7 @@ func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Aut return nil, errors.New("authorizer casbin config is empty") } - options := settings.ApplyDefault(DefaultAuthorizerOptions, ss) + options := configure.ApplyDefault(DefaultAuthorizerOptions, ss) if options.Source == nil { return nil, errors.New("authorizer casbin source is empty") } diff --git a/helpers/securityx/auth.go b/helpers/securityx/auth.go index 101c71d7..be4154ff 100644 --- a/helpers/securityx/auth.go +++ b/helpers/securityx/auth.go @@ -6,7 +6,7 @@ package securityx import ( - "github.com/goexts/generic/settings" + "github.com/goexts/generic/configure" "github.com/origadmin/runtime/interfaces/security" ) @@ -18,11 +18,10 @@ type authSecurity struct { } func NewSecurity(authenticator security.Authenticator, authorizer security.Authorizer, ss ...AuthenticatorSetting) security.Security { - t := settings.Apply(&authSecurity{ + return configure.Apply(&authSecurity{ Authenticator: authenticator, Authorizer: authorizer, }, ss) - return t } var _ security.Security = (*authSecurity)(nil) From 4bd5feacbdebeb10fe1224cec68871167f0d3941 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 5 Nov 2025 17:22:10 +0800 Subject: [PATCH 061/158] chore(ent): Update ent codegen version to v0.14.5 and refactor receiver variable names in CasbinRule methods --- internal/data/entity/ent/casbinrule.go | 54 +- internal/data/entity/ent/casbinrule_create.go | 244 +-- internal/data/entity/ent/casbinrule_delete.go | 38 +- internal/data/entity/ent/casbinrule_query.go | 316 +-- internal/data/entity/ent/casbinrule_update.go | 322 ++-- internal/data/entity/ent/client.go | 364 ++-- internal/data/entity/ent/department.go | 86 +- internal/data/entity/ent/department_create.go | 388 ++-- internal/data/entity/ent/department_delete.go | 38 +- internal/data/entity/ent/department_query.go | 458 ++--- internal/data/entity/ent/department_update.go | 876 ++++----- internal/data/entity/ent/ent.go | 4 +- internal/data/entity/ent/notification.go | 58 +- .../data/entity/ent/notification_create.go | 274 +-- .../data/entity/ent/notification_delete.go | 38 +- .../data/entity/ent/notification_query.go | 316 +-- .../data/entity/ent/notification_update.go | 464 ++--- internal/data/entity/ent/permission.go | 82 +- internal/data/entity/ent/permission_create.go | 378 ++-- internal/data/entity/ent/permission_delete.go | 38 +- internal/data/entity/ent/permission_query.go | 484 ++--- internal/data/entity/ent/permission_update.go | 876 ++++----- .../data/entity/ent/permissionresource.go | 42 +- .../entity/ent/permissionresource_create.go | 120 +- .../entity/ent/permissionresource_delete.go | 38 +- .../entity/ent/permissionresource_query.go | 376 ++-- .../entity/ent/permissionresource_update.go | 236 +-- internal/data/entity/ent/position.go | 70 +- internal/data/entity/ent/position_create.go | 294 +-- internal/data/entity/ent/position_delete.go | 38 +- internal/data/entity/ent/position_query.go | 458 ++--- internal/data/entity/ent/position_update.go | 664 +++---- .../data/entity/ent/positionpermission.go | 42 +- .../entity/ent/positionpermission_create.go | 120 +- .../entity/ent/positionpermission_delete.go | 38 +- .../entity/ent/positionpermission_query.go | 376 ++-- .../entity/ent/positionpermission_update.go | 236 +-- internal/data/entity/ent/resource.go | 118 +- internal/data/entity/ent/resource_create.go | 580 +++--- internal/data/entity/ent/resource_delete.go | 38 +- internal/data/entity/ent/resource_query.go | 430 ++--- internal/data/entity/ent/resource_update.go | 1104 +++++------ internal/data/entity/ent/role.go | 74 +- internal/data/entity/ent/role_create.go | 354 ++-- internal/data/entity/ent/role_delete.go | 38 +- internal/data/entity/ent/role_query.go | 428 ++--- internal/data/entity/ent/role_update.go | 768 ++++---- internal/data/entity/ent/rolepermission.go | 42 +- .../data/entity/ent/rolepermission_create.go | 120 +- .../data/entity/ent/rolepermission_delete.go | 38 +- .../data/entity/ent/rolepermission_query.go | 376 ++-- .../data/entity/ent/rolepermission_update.go | 236 +-- internal/data/entity/ent/runtime/runtime.go | 4 +- internal/data/entity/ent/user.go | 160 +- internal/data/entity/ent/user_create.go | 798 ++++---- internal/data/entity/ent/user_delete.go | 38 +- internal/data/entity/ent/user_query.go | 484 ++--- internal/data/entity/ent/user_update.go | 1704 ++++++++--------- internal/data/entity/ent/userdepartment.go | 42 +- .../data/entity/ent/userdepartment_create.go | 120 +- .../data/entity/ent/userdepartment_delete.go | 38 +- .../data/entity/ent/userdepartment_query.go | 376 ++-- .../data/entity/ent/userdepartment_update.go | 236 +-- internal/data/entity/ent/userposition.go | 42 +- .../data/entity/ent/userposition_create.go | 120 +- .../data/entity/ent/userposition_delete.go | 38 +- .../data/entity/ent/userposition_query.go | 376 ++-- .../data/entity/ent/userposition_update.go | 236 +-- internal/data/entity/ent/userrole.go | 42 +- internal/data/entity/ent/userrole_create.go | 120 +- internal/data/entity/ent/userrole_delete.go | 38 +- internal/data/entity/ent/userrole_query.go | 376 ++-- internal/data/entity/ent/userrole_update.go | 236 +-- 73 files changed, 9856 insertions(+), 9856 deletions(-) diff --git a/internal/data/entity/ent/casbinrule.go b/internal/data/entity/ent/casbinrule.go index f495842c..38dd01cb 100644 --- a/internal/data/entity/ent/casbinrule.go +++ b/internal/data/entity/ent/casbinrule.go @@ -51,7 +51,7 @@ func (*CasbinRule) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the CasbinRule fields. -func (cr *CasbinRule) assignValues(columns []string, values []any) error { +func (_m *CasbinRule) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -62,51 +62,51 @@ func (cr *CasbinRule) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - cr.ID = int(value.Int64) + _m.ID = int(value.Int64) case casbinrule.FieldPtype: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field Ptype", values[i]) } else if value.Valid { - cr.Ptype = value.String + _m.Ptype = value.String } case casbinrule.FieldV0: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field V0", values[i]) } else if value.Valid { - cr.V0 = value.String + _m.V0 = value.String } case casbinrule.FieldV1: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field V1", values[i]) } else if value.Valid { - cr.V1 = value.String + _m.V1 = value.String } case casbinrule.FieldV2: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field V2", values[i]) } else if value.Valid { - cr.V2 = value.String + _m.V2 = value.String } case casbinrule.FieldV3: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field V3", values[i]) } else if value.Valid { - cr.V3 = value.String + _m.V3 = value.String } case casbinrule.FieldV4: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field V4", values[i]) } else if value.Valid { - cr.V4 = value.String + _m.V4 = value.String } case casbinrule.FieldV5: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field V5", values[i]) } else if value.Valid { - cr.V5 = value.String + _m.V5 = value.String } default: - cr.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -114,53 +114,53 @@ func (cr *CasbinRule) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the CasbinRule. // This includes values selected through modifiers, order, etc. -func (cr *CasbinRule) Value(name string) (ent.Value, error) { - return cr.selectValues.Get(name) +func (_m *CasbinRule) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // Update returns a builder for updating this CasbinRule. // Note that you need to call CasbinRule.Unwrap() before calling this method if this CasbinRule // was returned from a transaction, and the transaction was committed or rolled back. -func (cr *CasbinRule) Update() *CasbinRuleUpdateOne { - return NewCasbinRuleClient(cr.config).UpdateOne(cr) +func (_m *CasbinRule) Update() *CasbinRuleUpdateOne { + return NewCasbinRuleClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the CasbinRule entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (cr *CasbinRule) Unwrap() *CasbinRule { - _tx, ok := cr.config.driver.(*txDriver) +func (_m *CasbinRule) Unwrap() *CasbinRule { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: CasbinRule is not a transactional entity") } - cr.config.driver = _tx.drv - return cr + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (cr *CasbinRule) String() string { +func (_m *CasbinRule) String() string { var builder strings.Builder builder.WriteString("CasbinRule(") - builder.WriteString(fmt.Sprintf("id=%v, ", cr.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("Ptype=") - builder.WriteString(cr.Ptype) + builder.WriteString(_m.Ptype) builder.WriteString(", ") builder.WriteString("V0=") - builder.WriteString(cr.V0) + builder.WriteString(_m.V0) builder.WriteString(", ") builder.WriteString("V1=") - builder.WriteString(cr.V1) + builder.WriteString(_m.V1) builder.WriteString(", ") builder.WriteString("V2=") - builder.WriteString(cr.V2) + builder.WriteString(_m.V2) builder.WriteString(", ") builder.WriteString("V3=") - builder.WriteString(cr.V3) + builder.WriteString(_m.V3) builder.WriteString(", ") builder.WriteString("V4=") - builder.WriteString(cr.V4) + builder.WriteString(_m.V4) builder.WriteString(", ") builder.WriteString("V5=") - builder.WriteString(cr.V5) + builder.WriteString(_m.V5) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/casbinrule_create.go b/internal/data/entity/ent/casbinrule_create.go index 9a8fb02f..28a449da 100644 --- a/internal/data/entity/ent/casbinrule_create.go +++ b/internal/data/entity/ent/casbinrule_create.go @@ -20,117 +20,117 @@ type CasbinRuleCreate struct { } // SetPtype sets the "Ptype" field. -func (crc *CasbinRuleCreate) SetPtype(s string) *CasbinRuleCreate { - crc.mutation.SetPtype(s) - return crc +func (_c *CasbinRuleCreate) SetPtype(v string) *CasbinRuleCreate { + _c.mutation.SetPtype(v) + return _c } // SetNillablePtype sets the "Ptype" field if the given value is not nil. -func (crc *CasbinRuleCreate) SetNillablePtype(s *string) *CasbinRuleCreate { - if s != nil { - crc.SetPtype(*s) +func (_c *CasbinRuleCreate) SetNillablePtype(v *string) *CasbinRuleCreate { + if v != nil { + _c.SetPtype(*v) } - return crc + return _c } // SetV0 sets the "V0" field. -func (crc *CasbinRuleCreate) SetV0(s string) *CasbinRuleCreate { - crc.mutation.SetV0(s) - return crc +func (_c *CasbinRuleCreate) SetV0(v string) *CasbinRuleCreate { + _c.mutation.SetV0(v) + return _c } // SetNillableV0 sets the "V0" field if the given value is not nil. -func (crc *CasbinRuleCreate) SetNillableV0(s *string) *CasbinRuleCreate { - if s != nil { - crc.SetV0(*s) +func (_c *CasbinRuleCreate) SetNillableV0(v *string) *CasbinRuleCreate { + if v != nil { + _c.SetV0(*v) } - return crc + return _c } // SetV1 sets the "V1" field. -func (crc *CasbinRuleCreate) SetV1(s string) *CasbinRuleCreate { - crc.mutation.SetV1(s) - return crc +func (_c *CasbinRuleCreate) SetV1(v string) *CasbinRuleCreate { + _c.mutation.SetV1(v) + return _c } // SetNillableV1 sets the "V1" field if the given value is not nil. -func (crc *CasbinRuleCreate) SetNillableV1(s *string) *CasbinRuleCreate { - if s != nil { - crc.SetV1(*s) +func (_c *CasbinRuleCreate) SetNillableV1(v *string) *CasbinRuleCreate { + if v != nil { + _c.SetV1(*v) } - return crc + return _c } // SetV2 sets the "V2" field. -func (crc *CasbinRuleCreate) SetV2(s string) *CasbinRuleCreate { - crc.mutation.SetV2(s) - return crc +func (_c *CasbinRuleCreate) SetV2(v string) *CasbinRuleCreate { + _c.mutation.SetV2(v) + return _c } // SetNillableV2 sets the "V2" field if the given value is not nil. -func (crc *CasbinRuleCreate) SetNillableV2(s *string) *CasbinRuleCreate { - if s != nil { - crc.SetV2(*s) +func (_c *CasbinRuleCreate) SetNillableV2(v *string) *CasbinRuleCreate { + if v != nil { + _c.SetV2(*v) } - return crc + return _c } // SetV3 sets the "V3" field. -func (crc *CasbinRuleCreate) SetV3(s string) *CasbinRuleCreate { - crc.mutation.SetV3(s) - return crc +func (_c *CasbinRuleCreate) SetV3(v string) *CasbinRuleCreate { + _c.mutation.SetV3(v) + return _c } // SetNillableV3 sets the "V3" field if the given value is not nil. -func (crc *CasbinRuleCreate) SetNillableV3(s *string) *CasbinRuleCreate { - if s != nil { - crc.SetV3(*s) +func (_c *CasbinRuleCreate) SetNillableV3(v *string) *CasbinRuleCreate { + if v != nil { + _c.SetV3(*v) } - return crc + return _c } // SetV4 sets the "V4" field. -func (crc *CasbinRuleCreate) SetV4(s string) *CasbinRuleCreate { - crc.mutation.SetV4(s) - return crc +func (_c *CasbinRuleCreate) SetV4(v string) *CasbinRuleCreate { + _c.mutation.SetV4(v) + return _c } // SetNillableV4 sets the "V4" field if the given value is not nil. -func (crc *CasbinRuleCreate) SetNillableV4(s *string) *CasbinRuleCreate { - if s != nil { - crc.SetV4(*s) +func (_c *CasbinRuleCreate) SetNillableV4(v *string) *CasbinRuleCreate { + if v != nil { + _c.SetV4(*v) } - return crc + return _c } // SetV5 sets the "V5" field. -func (crc *CasbinRuleCreate) SetV5(s string) *CasbinRuleCreate { - crc.mutation.SetV5(s) - return crc +func (_c *CasbinRuleCreate) SetV5(v string) *CasbinRuleCreate { + _c.mutation.SetV5(v) + return _c } // SetNillableV5 sets the "V5" field if the given value is not nil. -func (crc *CasbinRuleCreate) SetNillableV5(s *string) *CasbinRuleCreate { - if s != nil { - crc.SetV5(*s) +func (_c *CasbinRuleCreate) SetNillableV5(v *string) *CasbinRuleCreate { + if v != nil { + _c.SetV5(*v) } - return crc + return _c } // Mutation returns the CasbinRuleMutation object of the builder. -func (crc *CasbinRuleCreate) Mutation() *CasbinRuleMutation { - return crc.mutation +func (_c *CasbinRuleCreate) Mutation() *CasbinRuleMutation { + return _c.mutation } // Save creates the CasbinRule in the database. -func (crc *CasbinRuleCreate) Save(ctx context.Context) (*CasbinRule, error) { - crc.defaults() - return withHooks(ctx, crc.sqlSave, crc.mutation, crc.hooks) +func (_c *CasbinRuleCreate) Save(ctx context.Context) (*CasbinRule, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (crc *CasbinRuleCreate) SaveX(ctx context.Context) *CasbinRule { - v, err := crc.Save(ctx) +func (_c *CasbinRuleCreate) SaveX(ctx context.Context) *CasbinRule { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -138,82 +138,82 @@ func (crc *CasbinRuleCreate) SaveX(ctx context.Context) *CasbinRule { } // Exec executes the query. -func (crc *CasbinRuleCreate) Exec(ctx context.Context) error { - _, err := crc.Save(ctx) +func (_c *CasbinRuleCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (crc *CasbinRuleCreate) ExecX(ctx context.Context) { - if err := crc.Exec(ctx); err != nil { +func (_c *CasbinRuleCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (crc *CasbinRuleCreate) defaults() { - if _, ok := crc.mutation.Ptype(); !ok { +func (_c *CasbinRuleCreate) defaults() { + if _, ok := _c.mutation.Ptype(); !ok { v := casbinrule.DefaultPtype - crc.mutation.SetPtype(v) + _c.mutation.SetPtype(v) } - if _, ok := crc.mutation.V0(); !ok { + if _, ok := _c.mutation.V0(); !ok { v := casbinrule.DefaultV0 - crc.mutation.SetV0(v) + _c.mutation.SetV0(v) } - if _, ok := crc.mutation.V1(); !ok { + if _, ok := _c.mutation.V1(); !ok { v := casbinrule.DefaultV1 - crc.mutation.SetV1(v) + _c.mutation.SetV1(v) } - if _, ok := crc.mutation.V2(); !ok { + if _, ok := _c.mutation.V2(); !ok { v := casbinrule.DefaultV2 - crc.mutation.SetV2(v) + _c.mutation.SetV2(v) } - if _, ok := crc.mutation.V3(); !ok { + if _, ok := _c.mutation.V3(); !ok { v := casbinrule.DefaultV3 - crc.mutation.SetV3(v) + _c.mutation.SetV3(v) } - if _, ok := crc.mutation.V4(); !ok { + if _, ok := _c.mutation.V4(); !ok { v := casbinrule.DefaultV4 - crc.mutation.SetV4(v) + _c.mutation.SetV4(v) } - if _, ok := crc.mutation.V5(); !ok { + if _, ok := _c.mutation.V5(); !ok { v := casbinrule.DefaultV5 - crc.mutation.SetV5(v) + _c.mutation.SetV5(v) } } // check runs all checks and user-defined validators on the builder. -func (crc *CasbinRuleCreate) check() error { - if _, ok := crc.mutation.Ptype(); !ok { +func (_c *CasbinRuleCreate) check() error { + if _, ok := _c.mutation.Ptype(); !ok { return &ValidationError{Name: "Ptype", err: errors.New(`ent: missing required field "CasbinRule.Ptype"`)} } - if _, ok := crc.mutation.V0(); !ok { + if _, ok := _c.mutation.V0(); !ok { return &ValidationError{Name: "V0", err: errors.New(`ent: missing required field "CasbinRule.V0"`)} } - if _, ok := crc.mutation.V1(); !ok { + if _, ok := _c.mutation.V1(); !ok { return &ValidationError{Name: "V1", err: errors.New(`ent: missing required field "CasbinRule.V1"`)} } - if _, ok := crc.mutation.V2(); !ok { + if _, ok := _c.mutation.V2(); !ok { return &ValidationError{Name: "V2", err: errors.New(`ent: missing required field "CasbinRule.V2"`)} } - if _, ok := crc.mutation.V3(); !ok { + if _, ok := _c.mutation.V3(); !ok { return &ValidationError{Name: "V3", err: errors.New(`ent: missing required field "CasbinRule.V3"`)} } - if _, ok := crc.mutation.V4(); !ok { + if _, ok := _c.mutation.V4(); !ok { return &ValidationError{Name: "V4", err: errors.New(`ent: missing required field "CasbinRule.V4"`)} } - if _, ok := crc.mutation.V5(); !ok { + if _, ok := _c.mutation.V5(); !ok { return &ValidationError{Name: "V5", err: errors.New(`ent: missing required field "CasbinRule.V5"`)} } return nil } -func (crc *CasbinRuleCreate) sqlSave(ctx context.Context) (*CasbinRule, error) { - if err := crc.check(); err != nil { +func (_c *CasbinRuleCreate) sqlSave(ctx context.Context) (*CasbinRule, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := crc.createSpec() - if err := sqlgraph.CreateNode(ctx, crc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -221,41 +221,41 @@ func (crc *CasbinRuleCreate) sqlSave(ctx context.Context) (*CasbinRule, error) { } id := _spec.ID.Value.(int64) _node.ID = int(id) - crc.mutation.id = &_node.ID - crc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (crc *CasbinRuleCreate) createSpec() (*CasbinRule, *sqlgraph.CreateSpec) { +func (_c *CasbinRuleCreate) createSpec() (*CasbinRule, *sqlgraph.CreateSpec) { var ( - _node = &CasbinRule{config: crc.config} + _node = &CasbinRule{config: _c.config} _spec = sqlgraph.NewCreateSpec(casbinrule.Table, sqlgraph.NewFieldSpec(casbinrule.FieldID, field.TypeInt)) ) - if value, ok := crc.mutation.Ptype(); ok { + if value, ok := _c.mutation.Ptype(); ok { _spec.SetField(casbinrule.FieldPtype, field.TypeString, value) _node.Ptype = value } - if value, ok := crc.mutation.V0(); ok { + if value, ok := _c.mutation.V0(); ok { _spec.SetField(casbinrule.FieldV0, field.TypeString, value) _node.V0 = value } - if value, ok := crc.mutation.V1(); ok { + if value, ok := _c.mutation.V1(); ok { _spec.SetField(casbinrule.FieldV1, field.TypeString, value) _node.V1 = value } - if value, ok := crc.mutation.V2(); ok { + if value, ok := _c.mutation.V2(); ok { _spec.SetField(casbinrule.FieldV2, field.TypeString, value) _node.V2 = value } - if value, ok := crc.mutation.V3(); ok { + if value, ok := _c.mutation.V3(); ok { _spec.SetField(casbinrule.FieldV3, field.TypeString, value) _node.V3 = value } - if value, ok := crc.mutation.V4(); ok { + if value, ok := _c.mutation.V4(); ok { _spec.SetField(casbinrule.FieldV4, field.TypeString, value) _node.V4 = value } - if value, ok := crc.mutation.V5(); ok { + if value, ok := _c.mutation.V5(); ok { _spec.SetField(casbinrule.FieldV5, field.TypeString, value) _node.V5 = value } @@ -263,23 +263,23 @@ func (crc *CasbinRuleCreate) createSpec() (*CasbinRule, *sqlgraph.CreateSpec) { } // SetCasbinRule set the CasbinRule -func (crc *CasbinRuleCreate) SetCasbinRule(input *CasbinRule, fields ...string) *CasbinRuleCreate { - m := crc.mutation +func (_c *CasbinRuleCreate) SetCasbinRule(input *CasbinRule, fields ...string) *CasbinRuleCreate { + m := _c.mutation if len(fields) == 0 { fields = casbinrule.Columns } _ = m.SetFields(input, fields...) - return crc + return _c } // SetCasbinRuleWithZero set the CasbinRule -func (crc *CasbinRuleCreate) SetCasbinRuleWithZero(input *CasbinRule, fields ...string) *CasbinRuleCreate { - m := crc.mutation +func (_c *CasbinRuleCreate) SetCasbinRuleWithZero(input *CasbinRule, fields ...string) *CasbinRuleCreate { + m := _c.mutation if len(fields) == 0 { fields = casbinrule.Columns } _ = m.SetFieldsWithZero(input, fields...) - return crc + return _c } // CasbinRuleCreateBulk is the builder for creating many CasbinRule entities in bulk. @@ -290,16 +290,16 @@ type CasbinRuleCreateBulk struct { } // Save creates the CasbinRule entities in the database. -func (crcb *CasbinRuleCreateBulk) Save(ctx context.Context) ([]*CasbinRule, error) { - if crcb.err != nil { - return nil, crcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(crcb.builders)) - nodes := make([]*CasbinRule, len(crcb.builders)) - mutators := make([]Mutator, len(crcb.builders)) - for i := range crcb.builders { +func (_c *CasbinRuleCreateBulk) Save(ctx context.Context) ([]*CasbinRule, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*CasbinRule, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := crcb.builders[i] + builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*CasbinRuleMutation) @@ -313,11 +313,11 @@ func (crcb *CasbinRuleCreateBulk) Save(ctx context.Context) ([]*CasbinRule, erro var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, crcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, crcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -341,7 +341,7 @@ func (crcb *CasbinRuleCreateBulk) Save(ctx context.Context) ([]*CasbinRule, erro }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, crcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -349,8 +349,8 @@ func (crcb *CasbinRuleCreateBulk) Save(ctx context.Context) ([]*CasbinRule, erro } // SaveX is like Save, but panics if an error occurs. -func (crcb *CasbinRuleCreateBulk) SaveX(ctx context.Context) []*CasbinRule { - v, err := crcb.Save(ctx) +func (_c *CasbinRuleCreateBulk) SaveX(ctx context.Context) []*CasbinRule { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -358,14 +358,14 @@ func (crcb *CasbinRuleCreateBulk) SaveX(ctx context.Context) []*CasbinRule { } // Exec executes the query. -func (crcb *CasbinRuleCreateBulk) Exec(ctx context.Context) error { - _, err := crcb.Save(ctx) +func (_c *CasbinRuleCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (crcb *CasbinRuleCreateBulk) ExecX(ctx context.Context) { - if err := crcb.Exec(ctx); err != nil { +func (_c *CasbinRuleCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/casbinrule_delete.go b/internal/data/entity/ent/casbinrule_delete.go index 8512a6e0..4ce26fcb 100644 --- a/internal/data/entity/ent/casbinrule_delete.go +++ b/internal/data/entity/ent/casbinrule_delete.go @@ -20,56 +20,56 @@ type CasbinRuleDelete struct { } // Where appends a list predicates to the CasbinRuleDelete builder. -func (crd *CasbinRuleDelete) Where(ps ...predicate.CasbinRule) *CasbinRuleDelete { - crd.mutation.Where(ps...) - return crd +func (_d *CasbinRuleDelete) Where(ps ...predicate.CasbinRule) *CasbinRuleDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (crd *CasbinRuleDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, crd.sqlExec, crd.mutation, crd.hooks) +func (_d *CasbinRuleDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (crd *CasbinRuleDelete) ExecX(ctx context.Context) int { - n, err := crd.Exec(ctx) +func (_d *CasbinRuleDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (crd *CasbinRuleDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *CasbinRuleDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(casbinrule.Table, sqlgraph.NewFieldSpec(casbinrule.FieldID, field.TypeInt)) - if ps := crd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, crd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - crd.mutation.done = true + _d.mutation.done = true return affected, err } // CasbinRuleDeleteOne is the builder for deleting a single CasbinRule entity. type CasbinRuleDeleteOne struct { - crd *CasbinRuleDelete + _d *CasbinRuleDelete } // Where appends a list predicates to the CasbinRuleDelete builder. -func (crdo *CasbinRuleDeleteOne) Where(ps ...predicate.CasbinRule) *CasbinRuleDeleteOne { - crdo.crd.mutation.Where(ps...) - return crdo +func (_d *CasbinRuleDeleteOne) Where(ps ...predicate.CasbinRule) *CasbinRuleDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (crdo *CasbinRuleDeleteOne) Exec(ctx context.Context) error { - n, err := crdo.crd.Exec(ctx) +func (_d *CasbinRuleDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (crdo *CasbinRuleDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (crdo *CasbinRuleDeleteOne) ExecX(ctx context.Context) { - if err := crdo.Exec(ctx); err != nil { +func (_d *CasbinRuleDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/casbinrule_query.go b/internal/data/entity/ent/casbinrule_query.go index 5e8b2676..7c765867 100644 --- a/internal/data/entity/ent/casbinrule_query.go +++ b/internal/data/entity/ent/casbinrule_query.go @@ -30,40 +30,40 @@ type CasbinRuleQuery struct { } // Where adds a new predicate for the CasbinRuleQuery builder. -func (crq *CasbinRuleQuery) Where(ps ...predicate.CasbinRule) *CasbinRuleQuery { - crq.predicates = append(crq.predicates, ps...) - return crq +func (_q *CasbinRuleQuery) Where(ps ...predicate.CasbinRule) *CasbinRuleQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (crq *CasbinRuleQuery) Limit(limit int) *CasbinRuleQuery { - crq.ctx.Limit = &limit - return crq +func (_q *CasbinRuleQuery) Limit(limit int) *CasbinRuleQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (crq *CasbinRuleQuery) Offset(offset int) *CasbinRuleQuery { - crq.ctx.Offset = &offset - return crq +func (_q *CasbinRuleQuery) Offset(offset int) *CasbinRuleQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (crq *CasbinRuleQuery) Unique(unique bool) *CasbinRuleQuery { - crq.ctx.Unique = &unique - return crq +func (_q *CasbinRuleQuery) Unique(unique bool) *CasbinRuleQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (crq *CasbinRuleQuery) Order(o ...casbinrule.OrderOption) *CasbinRuleQuery { - crq.order = append(crq.order, o...) - return crq +func (_q *CasbinRuleQuery) Order(o ...casbinrule.OrderOption) *CasbinRuleQuery { + _q.order = append(_q.order, o...) + return _q } // First returns the first CasbinRule entity from the query. // Returns a *NotFoundError when no CasbinRule was found. -func (crq *CasbinRuleQuery) First(ctx context.Context) (*CasbinRule, error) { - nodes, err := crq.Limit(1).All(setContextOp(ctx, crq.ctx, ent.OpQueryFirst)) +func (_q *CasbinRuleQuery) First(ctx context.Context) (*CasbinRule, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -74,8 +74,8 @@ func (crq *CasbinRuleQuery) First(ctx context.Context) (*CasbinRule, error) { } // FirstX is like First, but panics if an error occurs. -func (crq *CasbinRuleQuery) FirstX(ctx context.Context) *CasbinRule { - node, err := crq.First(ctx) +func (_q *CasbinRuleQuery) FirstX(ctx context.Context) *CasbinRule { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -84,9 +84,9 @@ func (crq *CasbinRuleQuery) FirstX(ctx context.Context) *CasbinRule { // FirstID returns the first CasbinRule ID from the query. // Returns a *NotFoundError when no CasbinRule ID was found. -func (crq *CasbinRuleQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *CasbinRuleQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = crq.Limit(1).IDs(setContextOp(ctx, crq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -97,8 +97,8 @@ func (crq *CasbinRuleQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (crq *CasbinRuleQuery) FirstIDX(ctx context.Context) int { - id, err := crq.FirstID(ctx) +func (_q *CasbinRuleQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -108,8 +108,8 @@ func (crq *CasbinRuleQuery) FirstIDX(ctx context.Context) int { // Only returns a single CasbinRule entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one CasbinRule entity is found. // Returns a *NotFoundError when no CasbinRule entities are found. -func (crq *CasbinRuleQuery) Only(ctx context.Context) (*CasbinRule, error) { - nodes, err := crq.Limit(2).All(setContextOp(ctx, crq.ctx, ent.OpQueryOnly)) +func (_q *CasbinRuleQuery) Only(ctx context.Context) (*CasbinRule, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -124,8 +124,8 @@ func (crq *CasbinRuleQuery) Only(ctx context.Context) (*CasbinRule, error) { } // OnlyX is like Only, but panics if an error occurs. -func (crq *CasbinRuleQuery) OnlyX(ctx context.Context) *CasbinRule { - node, err := crq.Only(ctx) +func (_q *CasbinRuleQuery) OnlyX(ctx context.Context) *CasbinRule { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -135,9 +135,9 @@ func (crq *CasbinRuleQuery) OnlyX(ctx context.Context) *CasbinRule { // OnlyID is like Only, but returns the only CasbinRule ID in the query. // Returns a *NotSingularError when more than one CasbinRule ID is found. // Returns a *NotFoundError when no entities are found. -func (crq *CasbinRuleQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *CasbinRuleQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = crq.Limit(2).IDs(setContextOp(ctx, crq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -152,8 +152,8 @@ func (crq *CasbinRuleQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (crq *CasbinRuleQuery) OnlyIDX(ctx context.Context) int { - id, err := crq.OnlyID(ctx) +func (_q *CasbinRuleQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -161,18 +161,18 @@ func (crq *CasbinRuleQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of CasbinRules. -func (crq *CasbinRuleQuery) All(ctx context.Context) ([]*CasbinRule, error) { - ctx = setContextOp(ctx, crq.ctx, ent.OpQueryAll) - if err := crq.prepareQuery(ctx); err != nil { +func (_q *CasbinRuleQuery) All(ctx context.Context) ([]*CasbinRule, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*CasbinRule, *CasbinRuleQuery]() - return withInterceptors[[]*CasbinRule](ctx, crq, qr, crq.inters) + return withInterceptors[[]*CasbinRule](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (crq *CasbinRuleQuery) AllX(ctx context.Context) []*CasbinRule { - nodes, err := crq.All(ctx) +func (_q *CasbinRuleQuery) AllX(ctx context.Context) []*CasbinRule { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -180,20 +180,20 @@ func (crq *CasbinRuleQuery) AllX(ctx context.Context) []*CasbinRule { } // IDs executes the query and returns a list of CasbinRule IDs. -func (crq *CasbinRuleQuery) IDs(ctx context.Context) (ids []int, err error) { - if crq.ctx.Unique == nil && crq.path != nil { - crq.Unique(true) +func (_q *CasbinRuleQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, crq.ctx, ent.OpQueryIDs) - if err = crq.Select(casbinrule.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(casbinrule.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (crq *CasbinRuleQuery) IDsX(ctx context.Context) []int { - ids, err := crq.IDs(ctx) +func (_q *CasbinRuleQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -201,17 +201,17 @@ func (crq *CasbinRuleQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (crq *CasbinRuleQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, crq.ctx, ent.OpQueryCount) - if err := crq.prepareQuery(ctx); err != nil { +func (_q *CasbinRuleQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, crq, querierCount[*CasbinRuleQuery](), crq.inters) + return withInterceptors[int](ctx, _q, querierCount[*CasbinRuleQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (crq *CasbinRuleQuery) CountX(ctx context.Context) int { - count, err := crq.Count(ctx) +func (_q *CasbinRuleQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -219,9 +219,9 @@ func (crq *CasbinRuleQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (crq *CasbinRuleQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, crq.ctx, ent.OpQueryExist) - switch _, err := crq.FirstID(ctx); { +func (_q *CasbinRuleQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -232,8 +232,8 @@ func (crq *CasbinRuleQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (crq *CasbinRuleQuery) ExistX(ctx context.Context) bool { - exist, err := crq.Exist(ctx) +func (_q *CasbinRuleQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -242,20 +242,20 @@ func (crq *CasbinRuleQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the CasbinRuleQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (crq *CasbinRuleQuery) Clone() *CasbinRuleQuery { - if crq == nil { +func (_q *CasbinRuleQuery) Clone() *CasbinRuleQuery { + if _q == nil { return nil } return &CasbinRuleQuery{ - config: crq.config, - ctx: crq.ctx.Clone(), - order: append([]casbinrule.OrderOption{}, crq.order...), - inters: append([]Interceptor{}, crq.inters...), - predicates: append([]predicate.CasbinRule{}, crq.predicates...), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]casbinrule.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.CasbinRule{}, _q.predicates...), // clone intermediate query. - sql: crq.sql.Clone(), - path: crq.path, - modifiers: append([]func(*sql.Selector){}, crq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } @@ -273,10 +273,10 @@ func (crq *CasbinRuleQuery) Clone() *CasbinRuleQuery { // GroupBy(casbinrule.FieldPtype). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (crq *CasbinRuleQuery) GroupBy(field string, fields ...string) *CasbinRuleGroupBy { - crq.ctx.Fields = append([]string{field}, fields...) - grbuild := &CasbinRuleGroupBy{build: crq} - grbuild.flds = &crq.ctx.Fields +func (_q *CasbinRuleQuery) GroupBy(field string, fields ...string) *CasbinRuleGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &CasbinRuleGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = casbinrule.Label grbuild.scan = grbuild.Scan return grbuild @@ -294,65 +294,65 @@ func (crq *CasbinRuleQuery) GroupBy(field string, fields ...string) *CasbinRuleG // client.CasbinRule.Query(). // Select(casbinrule.FieldPtype). // Scan(ctx, &v) -func (crq *CasbinRuleQuery) Select(fields ...string) *CasbinRuleSelect { - crq.ctx.Fields = append(crq.ctx.Fields, fields...) - sbuild := &CasbinRuleSelect{CasbinRuleQuery: crq} +func (_q *CasbinRuleQuery) Select(fields ...string) *CasbinRuleSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &CasbinRuleSelect{CasbinRuleQuery: _q} sbuild.label = casbinrule.Label - sbuild.flds, sbuild.scan = &crq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a CasbinRuleSelect configured with the given aggregations. -func (crq *CasbinRuleQuery) Aggregate(fns ...AggregateFunc) *CasbinRuleSelect { - return crq.Select().Aggregate(fns...) +func (_q *CasbinRuleQuery) Aggregate(fns ...AggregateFunc) *CasbinRuleSelect { + return _q.Select().Aggregate(fns...) } -func (crq *CasbinRuleQuery) prepareQuery(ctx context.Context) error { - for _, inter := range crq.inters { +func (_q *CasbinRuleQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, crq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range crq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !casbinrule.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if crq.path != nil { - prev, err := crq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - crq.sql = prev + _q.sql = prev } return nil } -func (crq *CasbinRuleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*CasbinRule, error) { +func (_q *CasbinRuleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*CasbinRule, error) { var ( nodes = []*CasbinRule{} - _spec = crq.querySpec() + _spec = _q.querySpec() ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*CasbinRule).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &CasbinRule{config: crq.config} + node := &CasbinRule{config: _q.config} nodes = append(nodes, node) return node.assignValues(columns, values) } - if len(crq.modifiers) > 0 { - _spec.Modifiers = crq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, crq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { @@ -361,27 +361,27 @@ func (crq *CasbinRuleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]* return nodes, nil } -func (crq *CasbinRuleQuery) sqlCount(ctx context.Context) (int, error) { - _spec := crq.querySpec() - if len(crq.modifiers) > 0 { - _spec.Modifiers = crq.modifiers +func (_q *CasbinRuleQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = crq.ctx.Fields - if len(crq.ctx.Fields) > 0 { - _spec.Unique = crq.ctx.Unique != nil && *crq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, crq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (crq *CasbinRuleQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *CasbinRuleQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(casbinrule.Table, casbinrule.Columns, sqlgraph.NewFieldSpec(casbinrule.FieldID, field.TypeInt)) - _spec.From = crq.sql - if unique := crq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if crq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := crq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, casbinrule.FieldID) for i := range fields { @@ -390,20 +390,20 @@ func (crq *CasbinRuleQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := crq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := crq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := crq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := crq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -413,36 +413,36 @@ func (crq *CasbinRuleQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (crq *CasbinRuleQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(crq.driver.Dialect()) +func (_q *CasbinRuleQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(casbinrule.Table) - columns := crq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = casbinrule.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if crq.sql != nil { - selector = crq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if crq.ctx.Unique != nil && *crq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range crq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range crq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range crq.order { + for _, p := range _q.order { p(selector) } - if offset := crq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := crq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -451,33 +451,33 @@ func (crq *CasbinRuleQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (crq *CasbinRuleQuery) ForUpdate(opts ...sql.LockOption) *CasbinRuleQuery { - if crq.driver.Dialect() == dialect.Postgres { - crq.Unique(false) +func (_q *CasbinRuleQuery) ForUpdate(opts ...sql.LockOption) *CasbinRuleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - crq.modifiers = append(crq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return crq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (crq *CasbinRuleQuery) ForShare(opts ...sql.LockOption) *CasbinRuleQuery { - if crq.driver.Dialect() == dialect.Postgres { - crq.Unique(false) +func (_q *CasbinRuleQuery) ForShare(opts ...sql.LockOption) *CasbinRuleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - crq.modifiers = append(crq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return crq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (crq *CasbinRuleQuery) Modify(modifiers ...func(s *sql.Selector)) *CasbinRuleSelect { - crq.modifiers = append(crq.modifiers, modifiers...) - return crq.Select() +func (_q *CasbinRuleQuery) Modify(modifiers ...func(s *sql.Selector)) *CasbinRuleSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -529,41 +529,41 @@ type CasbinRuleGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (crgb *CasbinRuleGroupBy) Aggregate(fns ...AggregateFunc) *CasbinRuleGroupBy { - crgb.fns = append(crgb.fns, fns...) - return crgb +func (_g *CasbinRuleGroupBy) Aggregate(fns ...AggregateFunc) *CasbinRuleGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (crgb *CasbinRuleGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, crgb.build.ctx, ent.OpQueryGroupBy) - if err := crgb.build.prepareQuery(ctx); err != nil { +func (_g *CasbinRuleGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*CasbinRuleQuery, *CasbinRuleGroupBy](ctx, crgb.build, crgb, crgb.build.inters, v) + return scanWithInterceptors[*CasbinRuleQuery, *CasbinRuleGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (crgb *CasbinRuleGroupBy) sqlScan(ctx context.Context, root *CasbinRuleQuery, v any) error { +func (_g *CasbinRuleGroupBy) sqlScan(ctx context.Context, root *CasbinRuleQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(crgb.fns)) - for _, fn := range crgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*crgb.flds)+len(crgb.fns)) - for _, f := range *crgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*crgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := crgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -577,27 +577,27 @@ type CasbinRuleSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (crs *CasbinRuleSelect) Aggregate(fns ...AggregateFunc) *CasbinRuleSelect { - crs.fns = append(crs.fns, fns...) - return crs +func (_s *CasbinRuleSelect) Aggregate(fns ...AggregateFunc) *CasbinRuleSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (crs *CasbinRuleSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, crs.ctx, ent.OpQuerySelect) - if err := crs.prepareQuery(ctx); err != nil { +func (_s *CasbinRuleSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*CasbinRuleQuery, *CasbinRuleSelect](ctx, crs.CasbinRuleQuery, crs, crs.inters, v) + return scanWithInterceptors[*CasbinRuleQuery, *CasbinRuleSelect](ctx, _s.CasbinRuleQuery, _s, _s.inters, v) } -func (crs *CasbinRuleSelect) sqlScan(ctx context.Context, root *CasbinRuleQuery, v any) error { +func (_s *CasbinRuleSelect) sqlScan(ctx context.Context, root *CasbinRuleQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(crs.fns)) - for _, fn := range crs.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*crs.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -605,7 +605,7 @@ func (crs *CasbinRuleSelect) sqlScan(ctx context.Context, root *CasbinRuleQuery, } rows := &sql.Rows{} query, args := selector.Query() - if err := crs.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -613,7 +613,7 @@ func (crs *CasbinRuleSelect) sqlScan(ctx context.Context, root *CasbinRuleQuery, } // Modify adds a query modifier for attaching custom logic to queries. -func (crs *CasbinRuleSelect) Modify(modifiers ...func(s *sql.Selector)) *CasbinRuleSelect { - crs.modifiers = append(crs.modifiers, modifiers...) - return crs +func (_s *CasbinRuleSelect) Modify(modifiers ...func(s *sql.Selector)) *CasbinRuleSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/casbinrule_update.go b/internal/data/entity/ent/casbinrule_update.go index f0d72f88..fdb871d1 100644 --- a/internal/data/entity/ent/casbinrule_update.go +++ b/internal/data/entity/ent/casbinrule_update.go @@ -23,122 +23,122 @@ type CasbinRuleUpdate struct { } // Where appends a list predicates to the CasbinRuleUpdate builder. -func (cru *CasbinRuleUpdate) Where(ps ...predicate.CasbinRule) *CasbinRuleUpdate { - cru.mutation.Where(ps...) - return cru +func (_u *CasbinRuleUpdate) Where(ps ...predicate.CasbinRule) *CasbinRuleUpdate { + _u.mutation.Where(ps...) + return _u } // SetPtype sets the "Ptype" field. -func (cru *CasbinRuleUpdate) SetPtype(s string) *CasbinRuleUpdate { - cru.mutation.SetPtype(s) - return cru +func (_u *CasbinRuleUpdate) SetPtype(v string) *CasbinRuleUpdate { + _u.mutation.SetPtype(v) + return _u } // SetNillablePtype sets the "Ptype" field if the given value is not nil. -func (cru *CasbinRuleUpdate) SetNillablePtype(s *string) *CasbinRuleUpdate { - if s != nil { - cru.SetPtype(*s) +func (_u *CasbinRuleUpdate) SetNillablePtype(v *string) *CasbinRuleUpdate { + if v != nil { + _u.SetPtype(*v) } - return cru + return _u } // SetV0 sets the "V0" field. -func (cru *CasbinRuleUpdate) SetV0(s string) *CasbinRuleUpdate { - cru.mutation.SetV0(s) - return cru +func (_u *CasbinRuleUpdate) SetV0(v string) *CasbinRuleUpdate { + _u.mutation.SetV0(v) + return _u } // SetNillableV0 sets the "V0" field if the given value is not nil. -func (cru *CasbinRuleUpdate) SetNillableV0(s *string) *CasbinRuleUpdate { - if s != nil { - cru.SetV0(*s) +func (_u *CasbinRuleUpdate) SetNillableV0(v *string) *CasbinRuleUpdate { + if v != nil { + _u.SetV0(*v) } - return cru + return _u } // SetV1 sets the "V1" field. -func (cru *CasbinRuleUpdate) SetV1(s string) *CasbinRuleUpdate { - cru.mutation.SetV1(s) - return cru +func (_u *CasbinRuleUpdate) SetV1(v string) *CasbinRuleUpdate { + _u.mutation.SetV1(v) + return _u } // SetNillableV1 sets the "V1" field if the given value is not nil. -func (cru *CasbinRuleUpdate) SetNillableV1(s *string) *CasbinRuleUpdate { - if s != nil { - cru.SetV1(*s) +func (_u *CasbinRuleUpdate) SetNillableV1(v *string) *CasbinRuleUpdate { + if v != nil { + _u.SetV1(*v) } - return cru + return _u } // SetV2 sets the "V2" field. -func (cru *CasbinRuleUpdate) SetV2(s string) *CasbinRuleUpdate { - cru.mutation.SetV2(s) - return cru +func (_u *CasbinRuleUpdate) SetV2(v string) *CasbinRuleUpdate { + _u.mutation.SetV2(v) + return _u } // SetNillableV2 sets the "V2" field if the given value is not nil. -func (cru *CasbinRuleUpdate) SetNillableV2(s *string) *CasbinRuleUpdate { - if s != nil { - cru.SetV2(*s) +func (_u *CasbinRuleUpdate) SetNillableV2(v *string) *CasbinRuleUpdate { + if v != nil { + _u.SetV2(*v) } - return cru + return _u } // SetV3 sets the "V3" field. -func (cru *CasbinRuleUpdate) SetV3(s string) *CasbinRuleUpdate { - cru.mutation.SetV3(s) - return cru +func (_u *CasbinRuleUpdate) SetV3(v string) *CasbinRuleUpdate { + _u.mutation.SetV3(v) + return _u } // SetNillableV3 sets the "V3" field if the given value is not nil. -func (cru *CasbinRuleUpdate) SetNillableV3(s *string) *CasbinRuleUpdate { - if s != nil { - cru.SetV3(*s) +func (_u *CasbinRuleUpdate) SetNillableV3(v *string) *CasbinRuleUpdate { + if v != nil { + _u.SetV3(*v) } - return cru + return _u } // SetV4 sets the "V4" field. -func (cru *CasbinRuleUpdate) SetV4(s string) *CasbinRuleUpdate { - cru.mutation.SetV4(s) - return cru +func (_u *CasbinRuleUpdate) SetV4(v string) *CasbinRuleUpdate { + _u.mutation.SetV4(v) + return _u } // SetNillableV4 sets the "V4" field if the given value is not nil. -func (cru *CasbinRuleUpdate) SetNillableV4(s *string) *CasbinRuleUpdate { - if s != nil { - cru.SetV4(*s) +func (_u *CasbinRuleUpdate) SetNillableV4(v *string) *CasbinRuleUpdate { + if v != nil { + _u.SetV4(*v) } - return cru + return _u } // SetV5 sets the "V5" field. -func (cru *CasbinRuleUpdate) SetV5(s string) *CasbinRuleUpdate { - cru.mutation.SetV5(s) - return cru +func (_u *CasbinRuleUpdate) SetV5(v string) *CasbinRuleUpdate { + _u.mutation.SetV5(v) + return _u } // SetNillableV5 sets the "V5" field if the given value is not nil. -func (cru *CasbinRuleUpdate) SetNillableV5(s *string) *CasbinRuleUpdate { - if s != nil { - cru.SetV5(*s) +func (_u *CasbinRuleUpdate) SetNillableV5(v *string) *CasbinRuleUpdate { + if v != nil { + _u.SetV5(*v) } - return cru + return _u } // Mutation returns the CasbinRuleMutation object of the builder. -func (cru *CasbinRuleUpdate) Mutation() *CasbinRuleMutation { - return cru.mutation +func (_u *CasbinRuleUpdate) Mutation() *CasbinRuleMutation { + return _u.mutation } // Save executes the query and returns the number of nodes affected by the update operation. -func (cru *CasbinRuleUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, cru.sqlSave, cru.mutation, cru.hooks) +func (_u *CasbinRuleUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (cru *CasbinRuleUpdate) SaveX(ctx context.Context) int { - affected, err := cru.Save(ctx) +func (_u *CasbinRuleUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -146,56 +146,56 @@ func (cru *CasbinRuleUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (cru *CasbinRuleUpdate) Exec(ctx context.Context) error { - _, err := cru.Save(ctx) +func (_u *CasbinRuleUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (cru *CasbinRuleUpdate) ExecX(ctx context.Context) { - if err := cru.Exec(ctx); err != nil { +func (_u *CasbinRuleUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (cru *CasbinRuleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CasbinRuleUpdate { - cru.modifiers = append(cru.modifiers, modifiers...) - return cru +func (_u *CasbinRuleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CasbinRuleUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (cru *CasbinRuleUpdate) sqlSave(ctx context.Context) (n int, err error) { +func (_u *CasbinRuleUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec := sqlgraph.NewUpdateSpec(casbinrule.Table, casbinrule.Columns, sqlgraph.NewFieldSpec(casbinrule.FieldID, field.TypeInt)) - if ps := cru.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := cru.mutation.Ptype(); ok { + if value, ok := _u.mutation.Ptype(); ok { _spec.SetField(casbinrule.FieldPtype, field.TypeString, value) } - if value, ok := cru.mutation.V0(); ok { + if value, ok := _u.mutation.V0(); ok { _spec.SetField(casbinrule.FieldV0, field.TypeString, value) } - if value, ok := cru.mutation.V1(); ok { + if value, ok := _u.mutation.V1(); ok { _spec.SetField(casbinrule.FieldV1, field.TypeString, value) } - if value, ok := cru.mutation.V2(); ok { + if value, ok := _u.mutation.V2(); ok { _spec.SetField(casbinrule.FieldV2, field.TypeString, value) } - if value, ok := cru.mutation.V3(); ok { + if value, ok := _u.mutation.V3(); ok { _spec.SetField(casbinrule.FieldV3, field.TypeString, value) } - if value, ok := cru.mutation.V4(); ok { + if value, ok := _u.mutation.V4(); ok { _spec.SetField(casbinrule.FieldV4, field.TypeString, value) } - if value, ok := cru.mutation.V5(); ok { + if value, ok := _u.mutation.V5(); ok { _spec.SetField(casbinrule.FieldV5, field.TypeString, value) } - _spec.AddModifiers(cru.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, cru.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{casbinrule.Label} } else if sqlgraph.IsConstraintError(err) { @@ -203,8 +203,8 @@ func (cru *CasbinRuleUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - cru.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // CasbinRuleUpdateOne is the builder for updating a single CasbinRule entity. @@ -217,129 +217,129 @@ type CasbinRuleUpdateOne struct { } // SetPtype sets the "Ptype" field. -func (cruo *CasbinRuleUpdateOne) SetPtype(s string) *CasbinRuleUpdateOne { - cruo.mutation.SetPtype(s) - return cruo +func (_u *CasbinRuleUpdateOne) SetPtype(v string) *CasbinRuleUpdateOne { + _u.mutation.SetPtype(v) + return _u } // SetNillablePtype sets the "Ptype" field if the given value is not nil. -func (cruo *CasbinRuleUpdateOne) SetNillablePtype(s *string) *CasbinRuleUpdateOne { - if s != nil { - cruo.SetPtype(*s) +func (_u *CasbinRuleUpdateOne) SetNillablePtype(v *string) *CasbinRuleUpdateOne { + if v != nil { + _u.SetPtype(*v) } - return cruo + return _u } // SetV0 sets the "V0" field. -func (cruo *CasbinRuleUpdateOne) SetV0(s string) *CasbinRuleUpdateOne { - cruo.mutation.SetV0(s) - return cruo +func (_u *CasbinRuleUpdateOne) SetV0(v string) *CasbinRuleUpdateOne { + _u.mutation.SetV0(v) + return _u } // SetNillableV0 sets the "V0" field if the given value is not nil. -func (cruo *CasbinRuleUpdateOne) SetNillableV0(s *string) *CasbinRuleUpdateOne { - if s != nil { - cruo.SetV0(*s) +func (_u *CasbinRuleUpdateOne) SetNillableV0(v *string) *CasbinRuleUpdateOne { + if v != nil { + _u.SetV0(*v) } - return cruo + return _u } // SetV1 sets the "V1" field. -func (cruo *CasbinRuleUpdateOne) SetV1(s string) *CasbinRuleUpdateOne { - cruo.mutation.SetV1(s) - return cruo +func (_u *CasbinRuleUpdateOne) SetV1(v string) *CasbinRuleUpdateOne { + _u.mutation.SetV1(v) + return _u } // SetNillableV1 sets the "V1" field if the given value is not nil. -func (cruo *CasbinRuleUpdateOne) SetNillableV1(s *string) *CasbinRuleUpdateOne { - if s != nil { - cruo.SetV1(*s) +func (_u *CasbinRuleUpdateOne) SetNillableV1(v *string) *CasbinRuleUpdateOne { + if v != nil { + _u.SetV1(*v) } - return cruo + return _u } // SetV2 sets the "V2" field. -func (cruo *CasbinRuleUpdateOne) SetV2(s string) *CasbinRuleUpdateOne { - cruo.mutation.SetV2(s) - return cruo +func (_u *CasbinRuleUpdateOne) SetV2(v string) *CasbinRuleUpdateOne { + _u.mutation.SetV2(v) + return _u } // SetNillableV2 sets the "V2" field if the given value is not nil. -func (cruo *CasbinRuleUpdateOne) SetNillableV2(s *string) *CasbinRuleUpdateOne { - if s != nil { - cruo.SetV2(*s) +func (_u *CasbinRuleUpdateOne) SetNillableV2(v *string) *CasbinRuleUpdateOne { + if v != nil { + _u.SetV2(*v) } - return cruo + return _u } // SetV3 sets the "V3" field. -func (cruo *CasbinRuleUpdateOne) SetV3(s string) *CasbinRuleUpdateOne { - cruo.mutation.SetV3(s) - return cruo +func (_u *CasbinRuleUpdateOne) SetV3(v string) *CasbinRuleUpdateOne { + _u.mutation.SetV3(v) + return _u } // SetNillableV3 sets the "V3" field if the given value is not nil. -func (cruo *CasbinRuleUpdateOne) SetNillableV3(s *string) *CasbinRuleUpdateOne { - if s != nil { - cruo.SetV3(*s) +func (_u *CasbinRuleUpdateOne) SetNillableV3(v *string) *CasbinRuleUpdateOne { + if v != nil { + _u.SetV3(*v) } - return cruo + return _u } // SetV4 sets the "V4" field. -func (cruo *CasbinRuleUpdateOne) SetV4(s string) *CasbinRuleUpdateOne { - cruo.mutation.SetV4(s) - return cruo +func (_u *CasbinRuleUpdateOne) SetV4(v string) *CasbinRuleUpdateOne { + _u.mutation.SetV4(v) + return _u } // SetNillableV4 sets the "V4" field if the given value is not nil. -func (cruo *CasbinRuleUpdateOne) SetNillableV4(s *string) *CasbinRuleUpdateOne { - if s != nil { - cruo.SetV4(*s) +func (_u *CasbinRuleUpdateOne) SetNillableV4(v *string) *CasbinRuleUpdateOne { + if v != nil { + _u.SetV4(*v) } - return cruo + return _u } // SetV5 sets the "V5" field. -func (cruo *CasbinRuleUpdateOne) SetV5(s string) *CasbinRuleUpdateOne { - cruo.mutation.SetV5(s) - return cruo +func (_u *CasbinRuleUpdateOne) SetV5(v string) *CasbinRuleUpdateOne { + _u.mutation.SetV5(v) + return _u } // SetNillableV5 sets the "V5" field if the given value is not nil. -func (cruo *CasbinRuleUpdateOne) SetNillableV5(s *string) *CasbinRuleUpdateOne { - if s != nil { - cruo.SetV5(*s) +func (_u *CasbinRuleUpdateOne) SetNillableV5(v *string) *CasbinRuleUpdateOne { + if v != nil { + _u.SetV5(*v) } - return cruo + return _u } // Mutation returns the CasbinRuleMutation object of the builder. -func (cruo *CasbinRuleUpdateOne) Mutation() *CasbinRuleMutation { - return cruo.mutation +func (_u *CasbinRuleUpdateOne) Mutation() *CasbinRuleMutation { + return _u.mutation } // Where appends a list predicates to the CasbinRuleUpdate builder. -func (cruo *CasbinRuleUpdateOne) Where(ps ...predicate.CasbinRule) *CasbinRuleUpdateOne { - cruo.mutation.Where(ps...) - return cruo +func (_u *CasbinRuleUpdateOne) Where(ps ...predicate.CasbinRule) *CasbinRuleUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (cruo *CasbinRuleUpdateOne) Select(field string, fields ...string) *CasbinRuleUpdateOne { - cruo.fields = append([]string{field}, fields...) - return cruo +func (_u *CasbinRuleUpdateOne) Select(field string, fields ...string) *CasbinRuleUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated CasbinRule entity. -func (cruo *CasbinRuleUpdateOne) Save(ctx context.Context) (*CasbinRule, error) { - return withHooks(ctx, cruo.sqlSave, cruo.mutation, cruo.hooks) +func (_u *CasbinRuleUpdateOne) Save(ctx context.Context) (*CasbinRule, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (cruo *CasbinRuleUpdateOne) SaveX(ctx context.Context) *CasbinRule { - node, err := cruo.Save(ctx) +func (_u *CasbinRuleUpdateOne) SaveX(ctx context.Context) *CasbinRule { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -347,32 +347,32 @@ func (cruo *CasbinRuleUpdateOne) SaveX(ctx context.Context) *CasbinRule { } // Exec executes the query on the entity. -func (cruo *CasbinRuleUpdateOne) Exec(ctx context.Context) error { - _, err := cruo.Save(ctx) +func (_u *CasbinRuleUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (cruo *CasbinRuleUpdateOne) ExecX(ctx context.Context) { - if err := cruo.Exec(ctx); err != nil { +func (_u *CasbinRuleUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (cruo *CasbinRuleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CasbinRuleUpdateOne { - cruo.modifiers = append(cruo.modifiers, modifiers...) - return cruo +func (_u *CasbinRuleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *CasbinRuleUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (cruo *CasbinRuleUpdateOne) sqlSave(ctx context.Context) (_node *CasbinRule, err error) { +func (_u *CasbinRuleUpdateOne) sqlSave(ctx context.Context) (_node *CasbinRule, err error) { _spec := sqlgraph.NewUpdateSpec(casbinrule.Table, casbinrule.Columns, sqlgraph.NewFieldSpec(casbinrule.FieldID, field.TypeInt)) - id, ok := cruo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "CasbinRule.id" for update`)} } _spec.Node.ID.Value = id - if fields := cruo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, casbinrule.FieldID) for _, f := range fields { @@ -384,39 +384,39 @@ func (cruo *CasbinRuleUpdateOne) sqlSave(ctx context.Context) (_node *CasbinRule } } } - if ps := cruo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := cruo.mutation.Ptype(); ok { + if value, ok := _u.mutation.Ptype(); ok { _spec.SetField(casbinrule.FieldPtype, field.TypeString, value) } - if value, ok := cruo.mutation.V0(); ok { + if value, ok := _u.mutation.V0(); ok { _spec.SetField(casbinrule.FieldV0, field.TypeString, value) } - if value, ok := cruo.mutation.V1(); ok { + if value, ok := _u.mutation.V1(); ok { _spec.SetField(casbinrule.FieldV1, field.TypeString, value) } - if value, ok := cruo.mutation.V2(); ok { + if value, ok := _u.mutation.V2(); ok { _spec.SetField(casbinrule.FieldV2, field.TypeString, value) } - if value, ok := cruo.mutation.V3(); ok { + if value, ok := _u.mutation.V3(); ok { _spec.SetField(casbinrule.FieldV3, field.TypeString, value) } - if value, ok := cruo.mutation.V4(); ok { + if value, ok := _u.mutation.V4(); ok { _spec.SetField(casbinrule.FieldV4, field.TypeString, value) } - if value, ok := cruo.mutation.V5(); ok { + if value, ok := _u.mutation.V5(); ok { _spec.SetField(casbinrule.FieldV5, field.TypeString, value) } - _spec.AddModifiers(cruo.modifiers...) - _node = &CasbinRule{config: cruo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &CasbinRule{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, cruo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{casbinrule.Label} } else if sqlgraph.IsConstraintError(err) { @@ -424,7 +424,7 @@ func (cruo *CasbinRuleUpdateOne) sqlSave(ctx context.Context) (_node *CasbinRule } return nil, err } - cruo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/client.go b/internal/data/entity/ent/client.go index 47d2a740..2883d92d 100644 --- a/internal/data/entity/ent/client.go +++ b/internal/data/entity/ent/client.go @@ -369,8 +369,8 @@ func (c *CasbinRuleClient) Update() *CasbinRuleUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *CasbinRuleClient) UpdateOne(cr *CasbinRule) *CasbinRuleUpdateOne { - mutation := newCasbinRuleMutation(c.config, OpUpdateOne, withCasbinRule(cr)) +func (c *CasbinRuleClient) UpdateOne(_m *CasbinRule) *CasbinRuleUpdateOne { + mutation := newCasbinRuleMutation(c.config, OpUpdateOne, withCasbinRule(_m)) return &CasbinRuleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -387,8 +387,8 @@ func (c *CasbinRuleClient) Delete() *CasbinRuleDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *CasbinRuleClient) DeleteOne(cr *CasbinRule) *CasbinRuleDeleteOne { - return c.DeleteOneID(cr.ID) +func (c *CasbinRuleClient) DeleteOne(_m *CasbinRule) *CasbinRuleDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -502,8 +502,8 @@ func (c *DepartmentClient) Update() *DepartmentUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *DepartmentClient) UpdateOne(d *Department) *DepartmentUpdateOne { - mutation := newDepartmentMutation(c.config, OpUpdateOne, withDepartment(d)) +func (c *DepartmentClient) UpdateOne(_m *Department) *DepartmentUpdateOne { + mutation := newDepartmentMutation(c.config, OpUpdateOne, withDepartment(_m)) return &DepartmentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -520,8 +520,8 @@ func (c *DepartmentClient) Delete() *DepartmentDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *DepartmentClient) DeleteOne(d *Department) *DepartmentDeleteOne { - return c.DeleteOneID(d.ID) +func (c *DepartmentClient) DeleteOne(_m *Department) *DepartmentDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -556,80 +556,80 @@ func (c *DepartmentClient) GetX(ctx context.Context, id int64) *Department { } // QueryUsers queries the users edge of a Department. -func (c *DepartmentClient) QueryUsers(d *Department) *UserQuery { +func (c *DepartmentClient) QueryUsers(_m *Department) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := d.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(department.Table, department.FieldID, id), sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, department.UsersTable, department.UsersPrimaryKey...), ) - fromV = sqlgraph.Neighbors(d.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPositions queries the positions edge of a Department. -func (c *DepartmentClient) QueryPositions(d *Department) *PositionQuery { +func (c *DepartmentClient) QueryPositions(_m *Department) *PositionQuery { query := (&PositionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := d.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(department.Table, department.FieldID, id), sqlgraph.To(position.Table, position.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, department.PositionsTable, department.PositionsColumn), ) - fromV = sqlgraph.Neighbors(d.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryParent queries the parent edge of a Department. -func (c *DepartmentClient) QueryParent(d *Department) *DepartmentQuery { +func (c *DepartmentClient) QueryParent(_m *Department) *DepartmentQuery { query := (&DepartmentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := d.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(department.Table, department.FieldID, id), sqlgraph.To(department.Table, department.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, department.ParentTable, department.ParentColumn), ) - fromV = sqlgraph.Neighbors(d.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryChildren queries the children edge of a Department. -func (c *DepartmentClient) QueryChildren(d *Department) *DepartmentQuery { +func (c *DepartmentClient) QueryChildren(_m *Department) *DepartmentQuery { query := (&DepartmentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := d.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(department.Table, department.FieldID, id), sqlgraph.To(department.Table, department.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, department.ChildrenTable, department.ChildrenColumn), ) - fromV = sqlgraph.Neighbors(d.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryUserDepartments queries the user_departments edge of a Department. -func (c *DepartmentClient) QueryUserDepartments(d *Department) *UserDepartmentQuery { +func (c *DepartmentClient) QueryUserDepartments(_m *Department) *UserDepartmentQuery { query := (&UserDepartmentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := d.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(department.Table, department.FieldID, id), sqlgraph.To(userdepartment.Table, userdepartment.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, department.UserDepartmentsTable, department.UserDepartmentsColumn), ) - fromV = sqlgraph.Neighbors(d.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -715,8 +715,8 @@ func (c *NotificationClient) Update() *NotificationUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *NotificationClient) UpdateOne(n *Notification) *NotificationUpdateOne { - mutation := newNotificationMutation(c.config, OpUpdateOne, withNotification(n)) +func (c *NotificationClient) UpdateOne(_m *Notification) *NotificationUpdateOne { + mutation := newNotificationMutation(c.config, OpUpdateOne, withNotification(_m)) return &NotificationUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -733,8 +733,8 @@ func (c *NotificationClient) Delete() *NotificationDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *NotificationClient) DeleteOne(n *Notification) *NotificationDeleteOne { - return c.DeleteOneID(n.ID) +func (c *NotificationClient) DeleteOne(_m *Notification) *NotificationDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -848,8 +848,8 @@ func (c *PermissionClient) Update() *PermissionUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *PermissionClient) UpdateOne(pe *Permission) *PermissionUpdateOne { - mutation := newPermissionMutation(c.config, OpUpdateOne, withPermission(pe)) +func (c *PermissionClient) UpdateOne(_m *Permission) *PermissionUpdateOne { + mutation := newPermissionMutation(c.config, OpUpdateOne, withPermission(_m)) return &PermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -866,8 +866,8 @@ func (c *PermissionClient) Delete() *PermissionDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *PermissionClient) DeleteOne(pe *Permission) *PermissionDeleteOne { - return c.DeleteOneID(pe.ID) +func (c *PermissionClient) DeleteOne(_m *Permission) *PermissionDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -902,96 +902,96 @@ func (c *PermissionClient) GetX(ctx context.Context, id int64) *Permission { } // QueryRoles queries the roles edge of a Permission. -func (c *PermissionClient) QueryRoles(pe *Permission) *RoleQuery { +func (c *PermissionClient) QueryRoles(_m *Permission) *RoleQuery { query := (&RoleClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pe.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(permission.Table, permission.FieldID, id), sqlgraph.To(role.Table, role.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, permission.RolesTable, permission.RolesPrimaryKey...), ) - fromV = sqlgraph.Neighbors(pe.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPositions queries the positions edge of a Permission. -func (c *PermissionClient) QueryPositions(pe *Permission) *PositionQuery { +func (c *PermissionClient) QueryPositions(_m *Permission) *PositionQuery { query := (&PositionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pe.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(permission.Table, permission.FieldID, id), sqlgraph.To(position.Table, position.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, permission.PositionsTable, permission.PositionsPrimaryKey...), ) - fromV = sqlgraph.Neighbors(pe.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryResources queries the resources edge of a Permission. -func (c *PermissionClient) QueryResources(pe *Permission) *ResourceQuery { +func (c *PermissionClient) QueryResources(_m *Permission) *ResourceQuery { query := (&ResourceClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pe.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(permission.Table, permission.FieldID, id), sqlgraph.To(resource.Table, resource.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, permission.ResourcesTable, permission.ResourcesPrimaryKey...), ) - fromV = sqlgraph.Neighbors(pe.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryRolePermissions queries the role_permissions edge of a Permission. -func (c *PermissionClient) QueryRolePermissions(pe *Permission) *RolePermissionQuery { +func (c *PermissionClient) QueryRolePermissions(_m *Permission) *RolePermissionQuery { query := (&RolePermissionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pe.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(permission.Table, permission.FieldID, id), sqlgraph.To(rolepermission.Table, rolepermission.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, permission.RolePermissionsTable, permission.RolePermissionsColumn), ) - fromV = sqlgraph.Neighbors(pe.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPositionPermissions queries the position_permissions edge of a Permission. -func (c *PermissionClient) QueryPositionPermissions(pe *Permission) *PositionPermissionQuery { +func (c *PermissionClient) QueryPositionPermissions(_m *Permission) *PositionPermissionQuery { query := (&PositionPermissionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pe.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(permission.Table, permission.FieldID, id), sqlgraph.To(positionpermission.Table, positionpermission.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, permission.PositionPermissionsTable, permission.PositionPermissionsColumn), ) - fromV = sqlgraph.Neighbors(pe.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPermissionResources queries the permission_resources edge of a Permission. -func (c *PermissionClient) QueryPermissionResources(pe *Permission) *PermissionResourceQuery { +func (c *PermissionClient) QueryPermissionResources(_m *Permission) *PermissionResourceQuery { query := (&PermissionResourceClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pe.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(permission.Table, permission.FieldID, id), sqlgraph.To(permissionresource.Table, permissionresource.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, permission.PermissionResourcesTable, permission.PermissionResourcesColumn), ) - fromV = sqlgraph.Neighbors(pe.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -1077,8 +1077,8 @@ func (c *PermissionResourceClient) Update() *PermissionResourceUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *PermissionResourceClient) UpdateOne(pr *PermissionResource) *PermissionResourceUpdateOne { - mutation := newPermissionResourceMutation(c.config, OpUpdateOne, withPermissionResource(pr)) +func (c *PermissionResourceClient) UpdateOne(_m *PermissionResource) *PermissionResourceUpdateOne { + mutation := newPermissionResourceMutation(c.config, OpUpdateOne, withPermissionResource(_m)) return &PermissionResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1095,8 +1095,8 @@ func (c *PermissionResourceClient) Delete() *PermissionResourceDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *PermissionResourceClient) DeleteOne(pr *PermissionResource) *PermissionResourceDeleteOne { - return c.DeleteOneID(pr.ID) +func (c *PermissionResourceClient) DeleteOne(_m *PermissionResource) *PermissionResourceDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -1131,32 +1131,32 @@ func (c *PermissionResourceClient) GetX(ctx context.Context, id int) *Permission } // QueryPermission queries the permission edge of a PermissionResource. -func (c *PermissionResourceClient) QueryPermission(pr *PermissionResource) *PermissionQuery { +func (c *PermissionResourceClient) QueryPermission(_m *PermissionResource) *PermissionQuery { query := (&PermissionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pr.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(permissionresource.Table, permissionresource.FieldID, id), sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.PermissionTable, permissionresource.PermissionColumn), ) - fromV = sqlgraph.Neighbors(pr.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryResource queries the resource edge of a PermissionResource. -func (c *PermissionResourceClient) QueryResource(pr *PermissionResource) *ResourceQuery { +func (c *PermissionResourceClient) QueryResource(_m *PermissionResource) *ResourceQuery { query := (&ResourceClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pr.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(permissionresource.Table, permissionresource.FieldID, id), sqlgraph.To(resource.Table, resource.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.ResourceTable, permissionresource.ResourceColumn), ) - fromV = sqlgraph.Neighbors(pr.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -1242,8 +1242,8 @@ func (c *PositionClient) Update() *PositionUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *PositionClient) UpdateOne(po *Position) *PositionUpdateOne { - mutation := newPositionMutation(c.config, OpUpdateOne, withPosition(po)) +func (c *PositionClient) UpdateOne(_m *Position) *PositionUpdateOne { + mutation := newPositionMutation(c.config, OpUpdateOne, withPosition(_m)) return &PositionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1260,8 +1260,8 @@ func (c *PositionClient) Delete() *PositionDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *PositionClient) DeleteOne(po *Position) *PositionDeleteOne { - return c.DeleteOneID(po.ID) +func (c *PositionClient) DeleteOne(_m *Position) *PositionDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -1296,80 +1296,80 @@ func (c *PositionClient) GetX(ctx context.Context, id int64) *Position { } // QueryDepartment queries the department edge of a Position. -func (c *PositionClient) QueryDepartment(po *Position) *DepartmentQuery { +func (c *PositionClient) QueryDepartment(_m *Position) *DepartmentQuery { query := (&DepartmentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := po.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(position.Table, position.FieldID, id), sqlgraph.To(department.Table, department.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, position.DepartmentTable, position.DepartmentColumn), ) - fromV = sqlgraph.Neighbors(po.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryUsers queries the users edge of a Position. -func (c *PositionClient) QueryUsers(po *Position) *UserQuery { +func (c *PositionClient) QueryUsers(_m *Position) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := po.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(position.Table, position.FieldID, id), sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, position.UsersTable, position.UsersPrimaryKey...), ) - fromV = sqlgraph.Neighbors(po.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPermissions queries the permissions edge of a Position. -func (c *PositionClient) QueryPermissions(po *Position) *PermissionQuery { +func (c *PositionClient) QueryPermissions(_m *Position) *PermissionQuery { query := (&PermissionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := po.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(position.Table, position.FieldID, id), sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, position.PermissionsTable, position.PermissionsPrimaryKey...), ) - fromV = sqlgraph.Neighbors(po.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryUserPositions queries the user_positions edge of a Position. -func (c *PositionClient) QueryUserPositions(po *Position) *UserPositionQuery { +func (c *PositionClient) QueryUserPositions(_m *Position) *UserPositionQuery { query := (&UserPositionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := po.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(position.Table, position.FieldID, id), sqlgraph.To(userposition.Table, userposition.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, position.UserPositionsTable, position.UserPositionsColumn), ) - fromV = sqlgraph.Neighbors(po.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPositionPermissions queries the position_permissions edge of a Position. -func (c *PositionClient) QueryPositionPermissions(po *Position) *PositionPermissionQuery { +func (c *PositionClient) QueryPositionPermissions(_m *Position) *PositionPermissionQuery { query := (&PositionPermissionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := po.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(position.Table, position.FieldID, id), sqlgraph.To(positionpermission.Table, positionpermission.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, position.PositionPermissionsTable, position.PositionPermissionsColumn), ) - fromV = sqlgraph.Neighbors(po.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -1455,8 +1455,8 @@ func (c *PositionPermissionClient) Update() *PositionPermissionUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *PositionPermissionClient) UpdateOne(pp *PositionPermission) *PositionPermissionUpdateOne { - mutation := newPositionPermissionMutation(c.config, OpUpdateOne, withPositionPermission(pp)) +func (c *PositionPermissionClient) UpdateOne(_m *PositionPermission) *PositionPermissionUpdateOne { + mutation := newPositionPermissionMutation(c.config, OpUpdateOne, withPositionPermission(_m)) return &PositionPermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1473,8 +1473,8 @@ func (c *PositionPermissionClient) Delete() *PositionPermissionDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *PositionPermissionClient) DeleteOne(pp *PositionPermission) *PositionPermissionDeleteOne { - return c.DeleteOneID(pp.ID) +func (c *PositionPermissionClient) DeleteOne(_m *PositionPermission) *PositionPermissionDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -1509,32 +1509,32 @@ func (c *PositionPermissionClient) GetX(ctx context.Context, id int) *PositionPe } // QueryPosition queries the position edge of a PositionPermission. -func (c *PositionPermissionClient) QueryPosition(pp *PositionPermission) *PositionQuery { +func (c *PositionPermissionClient) QueryPosition(_m *PositionPermission) *PositionQuery { query := (&PositionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pp.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(positionpermission.Table, positionpermission.FieldID, id), sqlgraph.To(position.Table, position.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, positionpermission.PositionTable, positionpermission.PositionColumn), ) - fromV = sqlgraph.Neighbors(pp.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPermission queries the permission edge of a PositionPermission. -func (c *PositionPermissionClient) QueryPermission(pp *PositionPermission) *PermissionQuery { +func (c *PositionPermissionClient) QueryPermission(_m *PositionPermission) *PermissionQuery { query := (&PermissionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pp.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(positionpermission.Table, positionpermission.FieldID, id), sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, positionpermission.PermissionTable, positionpermission.PermissionColumn), ) - fromV = sqlgraph.Neighbors(pp.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -1620,8 +1620,8 @@ func (c *ResourceClient) Update() *ResourceUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *ResourceClient) UpdateOne(r *Resource) *ResourceUpdateOne { - mutation := newResourceMutation(c.config, OpUpdateOne, withResource(r)) +func (c *ResourceClient) UpdateOne(_m *Resource) *ResourceUpdateOne { + mutation := newResourceMutation(c.config, OpUpdateOne, withResource(_m)) return &ResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1638,8 +1638,8 @@ func (c *ResourceClient) Delete() *ResourceDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *ResourceClient) DeleteOne(r *Resource) *ResourceDeleteOne { - return c.DeleteOneID(r.ID) +func (c *ResourceClient) DeleteOne(_m *Resource) *ResourceDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -1674,64 +1674,64 @@ func (c *ResourceClient) GetX(ctx context.Context, id int64) *Resource { } // QueryChildren queries the children edge of a Resource. -func (c *ResourceClient) QueryChildren(r *Resource) *ResourceQuery { +func (c *ResourceClient) QueryChildren(_m *Resource) *ResourceQuery { query := (&ResourceClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := r.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(resource.Table, resource.FieldID, id), sqlgraph.To(resource.Table, resource.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, resource.ChildrenTable, resource.ChildrenColumn), ) - fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryParent queries the parent edge of a Resource. -func (c *ResourceClient) QueryParent(r *Resource) *ResourceQuery { +func (c *ResourceClient) QueryParent(_m *Resource) *ResourceQuery { query := (&ResourceClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := r.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(resource.Table, resource.FieldID, id), sqlgraph.To(resource.Table, resource.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, resource.ParentTable, resource.ParentColumn), ) - fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPermissions queries the permissions edge of a Resource. -func (c *ResourceClient) QueryPermissions(r *Resource) *PermissionQuery { +func (c *ResourceClient) QueryPermissions(_m *Resource) *PermissionQuery { query := (&PermissionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := r.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(resource.Table, resource.FieldID, id), sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, resource.PermissionsTable, resource.PermissionsPrimaryKey...), ) - fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPermissionResources queries the permission_resources edge of a Resource. -func (c *ResourceClient) QueryPermissionResources(r *Resource) *PermissionResourceQuery { +func (c *ResourceClient) QueryPermissionResources(_m *Resource) *PermissionResourceQuery { query := (&PermissionResourceClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := r.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(resource.Table, resource.FieldID, id), sqlgraph.To(permissionresource.Table, permissionresource.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, resource.PermissionResourcesTable, resource.PermissionResourcesColumn), ) - fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -1817,8 +1817,8 @@ func (c *RoleClient) Update() *RoleUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *RoleClient) UpdateOne(r *Role) *RoleUpdateOne { - mutation := newRoleMutation(c.config, OpUpdateOne, withRole(r)) +func (c *RoleClient) UpdateOne(_m *Role) *RoleUpdateOne { + mutation := newRoleMutation(c.config, OpUpdateOne, withRole(_m)) return &RoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1835,8 +1835,8 @@ func (c *RoleClient) Delete() *RoleDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *RoleClient) DeleteOne(r *Role) *RoleDeleteOne { - return c.DeleteOneID(r.ID) +func (c *RoleClient) DeleteOne(_m *Role) *RoleDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -1871,64 +1871,64 @@ func (c *RoleClient) GetX(ctx context.Context, id int64) *Role { } // QueryUsers queries the users edge of a Role. -func (c *RoleClient) QueryUsers(r *Role) *UserQuery { +func (c *RoleClient) QueryUsers(_m *Role) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := r.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(role.Table, role.FieldID, id), sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, role.UsersTable, role.UsersPrimaryKey...), ) - fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPermissions queries the permissions edge of a Role. -func (c *RoleClient) QueryPermissions(r *Role) *PermissionQuery { +func (c *RoleClient) QueryPermissions(_m *Role) *PermissionQuery { query := (&PermissionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := r.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(role.Table, role.FieldID, id), sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, role.PermissionsTable, role.PermissionsPrimaryKey...), ) - fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryUserRoles queries the user_roles edge of a Role. -func (c *RoleClient) QueryUserRoles(r *Role) *UserRoleQuery { +func (c *RoleClient) QueryUserRoles(_m *Role) *UserRoleQuery { query := (&UserRoleClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := r.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(role.Table, role.FieldID, id), sqlgraph.To(userrole.Table, userrole.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, role.UserRolesTable, role.UserRolesColumn), ) - fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryRolePermissions queries the role_permissions edge of a Role. -func (c *RoleClient) QueryRolePermissions(r *Role) *RolePermissionQuery { +func (c *RoleClient) QueryRolePermissions(_m *Role) *RolePermissionQuery { query := (&RolePermissionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := r.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(role.Table, role.FieldID, id), sqlgraph.To(rolepermission.Table, rolepermission.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, role.RolePermissionsTable, role.RolePermissionsColumn), ) - fromV = sqlgraph.Neighbors(r.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -2014,8 +2014,8 @@ func (c *RolePermissionClient) Update() *RolePermissionUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *RolePermissionClient) UpdateOne(rp *RolePermission) *RolePermissionUpdateOne { - mutation := newRolePermissionMutation(c.config, OpUpdateOne, withRolePermission(rp)) +func (c *RolePermissionClient) UpdateOne(_m *RolePermission) *RolePermissionUpdateOne { + mutation := newRolePermissionMutation(c.config, OpUpdateOne, withRolePermission(_m)) return &RolePermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -2032,8 +2032,8 @@ func (c *RolePermissionClient) Delete() *RolePermissionDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *RolePermissionClient) DeleteOne(rp *RolePermission) *RolePermissionDeleteOne { - return c.DeleteOneID(rp.ID) +func (c *RolePermissionClient) DeleteOne(_m *RolePermission) *RolePermissionDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -2068,32 +2068,32 @@ func (c *RolePermissionClient) GetX(ctx context.Context, id int) *RolePermission } // QueryRole queries the role edge of a RolePermission. -func (c *RolePermissionClient) QueryRole(rp *RolePermission) *RoleQuery { +func (c *RolePermissionClient) QueryRole(_m *RolePermission) *RoleQuery { query := (&RoleClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := rp.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(rolepermission.Table, rolepermission.FieldID, id), sqlgraph.To(role.Table, role.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.RoleTable, rolepermission.RoleColumn), ) - fromV = sqlgraph.Neighbors(rp.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPermission queries the permission edge of a RolePermission. -func (c *RolePermissionClient) QueryPermission(rp *RolePermission) *PermissionQuery { +func (c *RolePermissionClient) QueryPermission(_m *RolePermission) *PermissionQuery { query := (&PermissionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := rp.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(rolepermission.Table, rolepermission.FieldID, id), sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.PermissionTable, rolepermission.PermissionColumn), ) - fromV = sqlgraph.Neighbors(rp.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -2179,8 +2179,8 @@ func (c *UserClient) Update() *UserUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *UserClient) UpdateOne(u *User) *UserUpdateOne { - mutation := newUserMutation(c.config, OpUpdateOne, withUser(u)) +func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUser(_m)) return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -2197,8 +2197,8 @@ func (c *UserClient) Delete() *UserDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *UserClient) DeleteOne(u *User) *UserDeleteOne { - return c.DeleteOneID(u.ID) +func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -2233,96 +2233,96 @@ func (c *UserClient) GetX(ctx context.Context, id int64) *User { } // QueryRoles queries the roles edge of a User. -func (c *UserClient) QueryRoles(u *User) *RoleQuery { +func (c *UserClient) QueryRoles(_m *User) *RoleQuery { query := (&RoleClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := u.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(user.Table, user.FieldID, id), sqlgraph.To(role.Table, role.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, user.RolesTable, user.RolesPrimaryKey...), ) - fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPositions queries the positions edge of a User. -func (c *UserClient) QueryPositions(u *User) *PositionQuery { +func (c *UserClient) QueryPositions(_m *User) *PositionQuery { query := (&PositionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := u.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(user.Table, user.FieldID, id), sqlgraph.To(position.Table, position.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, user.PositionsTable, user.PositionsPrimaryKey...), ) - fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryDepartments queries the departments edge of a User. -func (c *UserClient) QueryDepartments(u *User) *DepartmentQuery { +func (c *UserClient) QueryDepartments(_m *User) *DepartmentQuery { query := (&DepartmentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := u.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(user.Table, user.FieldID, id), sqlgraph.To(department.Table, department.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, user.DepartmentsTable, user.DepartmentsPrimaryKey...), ) - fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryUserRoles queries the user_roles edge of a User. -func (c *UserClient) QueryUserRoles(u *User) *UserRoleQuery { +func (c *UserClient) QueryUserRoles(_m *User) *UserRoleQuery { query := (&UserRoleClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := u.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(user.Table, user.FieldID, id), sqlgraph.To(userrole.Table, userrole.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, user.UserRolesTable, user.UserRolesColumn), ) - fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryUserPositions queries the user_positions edge of a User. -func (c *UserClient) QueryUserPositions(u *User) *UserPositionQuery { +func (c *UserClient) QueryUserPositions(_m *User) *UserPositionQuery { query := (&UserPositionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := u.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(user.Table, user.FieldID, id), sqlgraph.To(userposition.Table, userposition.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, user.UserPositionsTable, user.UserPositionsColumn), ) - fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryUserDepartments queries the user_departments edge of a User. -func (c *UserClient) QueryUserDepartments(u *User) *UserDepartmentQuery { +func (c *UserClient) QueryUserDepartments(_m *User) *UserDepartmentQuery { query := (&UserDepartmentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := u.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(user.Table, user.FieldID, id), sqlgraph.To(userdepartment.Table, userdepartment.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, user.UserDepartmentsTable, user.UserDepartmentsColumn), ) - fromV = sqlgraph.Neighbors(u.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -2410,8 +2410,8 @@ func (c *UserDepartmentClient) Update() *UserDepartmentUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *UserDepartmentClient) UpdateOne(ud *UserDepartment) *UserDepartmentUpdateOne { - mutation := newUserDepartmentMutation(c.config, OpUpdateOne, withUserDepartment(ud)) +func (c *UserDepartmentClient) UpdateOne(_m *UserDepartment) *UserDepartmentUpdateOne { + mutation := newUserDepartmentMutation(c.config, OpUpdateOne, withUserDepartment(_m)) return &UserDepartmentUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -2428,8 +2428,8 @@ func (c *UserDepartmentClient) Delete() *UserDepartmentDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *UserDepartmentClient) DeleteOne(ud *UserDepartment) *UserDepartmentDeleteOne { - return c.DeleteOneID(ud.ID) +func (c *UserDepartmentClient) DeleteOne(_m *UserDepartment) *UserDepartmentDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -2464,32 +2464,32 @@ func (c *UserDepartmentClient) GetX(ctx context.Context, id int) *UserDepartment } // QueryUser queries the user edge of a UserDepartment. -func (c *UserDepartmentClient) QueryUser(ud *UserDepartment) *UserQuery { +func (c *UserDepartmentClient) QueryUser(_m *UserDepartment) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := ud.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(userdepartment.Table, userdepartment.FieldID, id), sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userdepartment.UserTable, userdepartment.UserColumn), ) - fromV = sqlgraph.Neighbors(ud.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryDepartment queries the department edge of a UserDepartment. -func (c *UserDepartmentClient) QueryDepartment(ud *UserDepartment) *DepartmentQuery { +func (c *UserDepartmentClient) QueryDepartment(_m *UserDepartment) *DepartmentQuery { query := (&DepartmentClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := ud.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(userdepartment.Table, userdepartment.FieldID, id), sqlgraph.To(department.Table, department.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userdepartment.DepartmentTable, userdepartment.DepartmentColumn), ) - fromV = sqlgraph.Neighbors(ud.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -2575,8 +2575,8 @@ func (c *UserPositionClient) Update() *UserPositionUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *UserPositionClient) UpdateOne(up *UserPosition) *UserPositionUpdateOne { - mutation := newUserPositionMutation(c.config, OpUpdateOne, withUserPosition(up)) +func (c *UserPositionClient) UpdateOne(_m *UserPosition) *UserPositionUpdateOne { + mutation := newUserPositionMutation(c.config, OpUpdateOne, withUserPosition(_m)) return &UserPositionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -2593,8 +2593,8 @@ func (c *UserPositionClient) Delete() *UserPositionDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *UserPositionClient) DeleteOne(up *UserPosition) *UserPositionDeleteOne { - return c.DeleteOneID(up.ID) +func (c *UserPositionClient) DeleteOne(_m *UserPosition) *UserPositionDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -2629,32 +2629,32 @@ func (c *UserPositionClient) GetX(ctx context.Context, id int) *UserPosition { } // QueryUser queries the user edge of a UserPosition. -func (c *UserPositionClient) QueryUser(up *UserPosition) *UserQuery { +func (c *UserPositionClient) QueryUser(_m *UserPosition) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := up.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(userposition.Table, userposition.FieldID, id), sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userposition.UserTable, userposition.UserColumn), ) - fromV = sqlgraph.Neighbors(up.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPosition queries the position edge of a UserPosition. -func (c *UserPositionClient) QueryPosition(up *UserPosition) *PositionQuery { +func (c *UserPositionClient) QueryPosition(_m *UserPosition) *PositionQuery { query := (&PositionClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := up.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(userposition.Table, userposition.FieldID, id), sqlgraph.To(position.Table, position.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userposition.PositionTable, userposition.PositionColumn), ) - fromV = sqlgraph.Neighbors(up.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -2740,8 +2740,8 @@ func (c *UserRoleClient) Update() *UserRoleUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *UserRoleClient) UpdateOne(ur *UserRole) *UserRoleUpdateOne { - mutation := newUserRoleMutation(c.config, OpUpdateOne, withUserRole(ur)) +func (c *UserRoleClient) UpdateOne(_m *UserRole) *UserRoleUpdateOne { + mutation := newUserRoleMutation(c.config, OpUpdateOne, withUserRole(_m)) return &UserRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -2758,8 +2758,8 @@ func (c *UserRoleClient) Delete() *UserRoleDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *UserRoleClient) DeleteOne(ur *UserRole) *UserRoleDeleteOne { - return c.DeleteOneID(ur.ID) +func (c *UserRoleClient) DeleteOne(_m *UserRole) *UserRoleDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -2794,32 +2794,32 @@ func (c *UserRoleClient) GetX(ctx context.Context, id int) *UserRole { } // QueryUser queries the user edge of a UserRole. -func (c *UserRoleClient) QueryUser(ur *UserRole) *UserQuery { +func (c *UserRoleClient) QueryUser(_m *UserRole) *UserQuery { query := (&UserClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := ur.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(userrole.Table, userrole.FieldID, id), sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userrole.UserTable, userrole.UserColumn), ) - fromV = sqlgraph.Neighbors(ur.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryRole queries the role edge of a UserRole. -func (c *UserRoleClient) QueryRole(ur *UserRole) *RoleQuery { +func (c *UserRoleClient) QueryRole(_m *UserRole) *RoleQuery { query := (&RoleClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := ur.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(userrole.Table, userrole.FieldID, id), sqlgraph.To(role.Table, role.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userrole.RoleTable, userrole.RoleColumn), ) - fromV = sqlgraph.Neighbors(ur.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query diff --git a/internal/data/entity/ent/department.go b/internal/data/entity/ent/department.go index 2d145c6c..de14be39 100644 --- a/internal/data/entity/ent/department.go +++ b/internal/data/entity/ent/department.go @@ -128,7 +128,7 @@ func (*Department) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Department fields. -func (d *Department) assignValues(columns []string, values []any) error { +func (_m *Department) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -139,69 +139,69 @@ func (d *Department) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - d.ID = int64(value.Int64) + _m.ID = int64(value.Int64) case department.FieldCreateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field create_time", values[i]) } else if value.Valid { - d.CreateTime = value.Time + _m.CreateTime = value.Time } case department.FieldUpdateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field update_time", values[i]) } else if value.Valid { - d.UpdateTime = value.Time + _m.UpdateTime = value.Time } case department.FieldKeyword: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field keyword", values[i]) } else if value.Valid { - d.Keyword = value.String + _m.Keyword = value.String } case department.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { - d.Name = value.String + _m.Name = value.String } case department.FieldTreePath: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field tree_path", values[i]) } else if value.Valid { - d.TreePath = value.String + _m.TreePath = value.String } case department.FieldSequence: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field sequence", values[i]) } else if value.Valid { - d.Sequence = int(value.Int64) + _m.Sequence = int(value.Int64) } case department.FieldStatus: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - d.Status = int8(value.Int64) + _m.Status = int8(value.Int64) } case department.FieldLevel: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field level", values[i]) } else if value.Valid { - d.Level = int(value.Int64) + _m.Level = int(value.Int64) } case department.FieldDescription: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field description", values[i]) } else if value.Valid { - d.Description = value.String + _m.Description = value.String } case department.FieldParentID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field parent_id", values[i]) } else if value.Valid { - d.ParentID = value.Int64 + _m.ParentID = value.Int64 } default: - d.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -209,87 +209,87 @@ func (d *Department) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Department. // This includes values selected through modifiers, order, etc. -func (d *Department) Value(name string) (ent.Value, error) { - return d.selectValues.Get(name) +func (_m *Department) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryUsers queries the "users" edge of the Department entity. -func (d *Department) QueryUsers() *UserQuery { - return NewDepartmentClient(d.config).QueryUsers(d) +func (_m *Department) QueryUsers() *UserQuery { + return NewDepartmentClient(_m.config).QueryUsers(_m) } // QueryPositions queries the "positions" edge of the Department entity. -func (d *Department) QueryPositions() *PositionQuery { - return NewDepartmentClient(d.config).QueryPositions(d) +func (_m *Department) QueryPositions() *PositionQuery { + return NewDepartmentClient(_m.config).QueryPositions(_m) } // QueryParent queries the "parent" edge of the Department entity. -func (d *Department) QueryParent() *DepartmentQuery { - return NewDepartmentClient(d.config).QueryParent(d) +func (_m *Department) QueryParent() *DepartmentQuery { + return NewDepartmentClient(_m.config).QueryParent(_m) } // QueryChildren queries the "children" edge of the Department entity. -func (d *Department) QueryChildren() *DepartmentQuery { - return NewDepartmentClient(d.config).QueryChildren(d) +func (_m *Department) QueryChildren() *DepartmentQuery { + return NewDepartmentClient(_m.config).QueryChildren(_m) } // QueryUserDepartments queries the "user_departments" edge of the Department entity. -func (d *Department) QueryUserDepartments() *UserDepartmentQuery { - return NewDepartmentClient(d.config).QueryUserDepartments(d) +func (_m *Department) QueryUserDepartments() *UserDepartmentQuery { + return NewDepartmentClient(_m.config).QueryUserDepartments(_m) } // Update returns a builder for updating this Department. // Note that you need to call Department.Unwrap() before calling this method if this Department // was returned from a transaction, and the transaction was committed or rolled back. -func (d *Department) Update() *DepartmentUpdateOne { - return NewDepartmentClient(d.config).UpdateOne(d) +func (_m *Department) Update() *DepartmentUpdateOne { + return NewDepartmentClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Department entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (d *Department) Unwrap() *Department { - _tx, ok := d.config.driver.(*txDriver) +func (_m *Department) Unwrap() *Department { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Department is not a transactional entity") } - d.config.driver = _tx.drv - return d + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (d *Department) String() string { +func (_m *Department) String() string { var builder strings.Builder builder.WriteString("Department(") - builder.WriteString(fmt.Sprintf("id=%v, ", d.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("create_time=") - builder.WriteString(d.CreateTime.Format(time.ANSIC)) + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("update_time=") - builder.WriteString(d.UpdateTime.Format(time.ANSIC)) + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("keyword=") - builder.WriteString(d.Keyword) + builder.WriteString(_m.Keyword) builder.WriteString(", ") builder.WriteString("name=") - builder.WriteString(d.Name) + builder.WriteString(_m.Name) builder.WriteString(", ") builder.WriteString("tree_path=") - builder.WriteString(d.TreePath) + builder.WriteString(_m.TreePath) builder.WriteString(", ") builder.WriteString("sequence=") - builder.WriteString(fmt.Sprintf("%v", d.Sequence)) + builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) builder.WriteString(", ") builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", d.Status)) + builder.WriteString(fmt.Sprintf("%v", _m.Status)) builder.WriteString(", ") builder.WriteString("level=") - builder.WriteString(fmt.Sprintf("%v", d.Level)) + builder.WriteString(fmt.Sprintf("%v", _m.Level)) builder.WriteString(", ") builder.WriteString("description=") - builder.WriteString(d.Description) + builder.WriteString(_m.Description) builder.WriteString(", ") builder.WriteString("parent_id=") - builder.WriteString(fmt.Sprintf("%v", d.ParentID)) + builder.WriteString(fmt.Sprintf("%v", _m.ParentID)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/department_create.go b/internal/data/entity/ent/department_create.go index c05a492f..1bc73169 100644 --- a/internal/data/entity/ent/department_create.go +++ b/internal/data/entity/ent/department_create.go @@ -24,222 +24,222 @@ type DepartmentCreate struct { } // SetCreateTime sets the "create_time" field. -func (dc *DepartmentCreate) SetCreateTime(t time.Time) *DepartmentCreate { - dc.mutation.SetCreateTime(t) - return dc +func (_c *DepartmentCreate) SetCreateTime(v time.Time) *DepartmentCreate { + _c.mutation.SetCreateTime(v) + return _c } // SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (dc *DepartmentCreate) SetNillableCreateTime(t *time.Time) *DepartmentCreate { - if t != nil { - dc.SetCreateTime(*t) +func (_c *DepartmentCreate) SetNillableCreateTime(v *time.Time) *DepartmentCreate { + if v != nil { + _c.SetCreateTime(*v) } - return dc + return _c } // SetUpdateTime sets the "update_time" field. -func (dc *DepartmentCreate) SetUpdateTime(t time.Time) *DepartmentCreate { - dc.mutation.SetUpdateTime(t) - return dc +func (_c *DepartmentCreate) SetUpdateTime(v time.Time) *DepartmentCreate { + _c.mutation.SetUpdateTime(v) + return _c } // SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (dc *DepartmentCreate) SetNillableUpdateTime(t *time.Time) *DepartmentCreate { - if t != nil { - dc.SetUpdateTime(*t) +func (_c *DepartmentCreate) SetNillableUpdateTime(v *time.Time) *DepartmentCreate { + if v != nil { + _c.SetUpdateTime(*v) } - return dc + return _c } // SetKeyword sets the "keyword" field. -func (dc *DepartmentCreate) SetKeyword(s string) *DepartmentCreate { - dc.mutation.SetKeyword(s) - return dc +func (_c *DepartmentCreate) SetKeyword(v string) *DepartmentCreate { + _c.mutation.SetKeyword(v) + return _c } // SetName sets the "name" field. -func (dc *DepartmentCreate) SetName(s string) *DepartmentCreate { - dc.mutation.SetName(s) - return dc +func (_c *DepartmentCreate) SetName(v string) *DepartmentCreate { + _c.mutation.SetName(v) + return _c } // SetNillableName sets the "name" field if the given value is not nil. -func (dc *DepartmentCreate) SetNillableName(s *string) *DepartmentCreate { - if s != nil { - dc.SetName(*s) +func (_c *DepartmentCreate) SetNillableName(v *string) *DepartmentCreate { + if v != nil { + _c.SetName(*v) } - return dc + return _c } // SetTreePath sets the "tree_path" field. -func (dc *DepartmentCreate) SetTreePath(s string) *DepartmentCreate { - dc.mutation.SetTreePath(s) - return dc +func (_c *DepartmentCreate) SetTreePath(v string) *DepartmentCreate { + _c.mutation.SetTreePath(v) + return _c } // SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (dc *DepartmentCreate) SetNillableTreePath(s *string) *DepartmentCreate { - if s != nil { - dc.SetTreePath(*s) +func (_c *DepartmentCreate) SetNillableTreePath(v *string) *DepartmentCreate { + if v != nil { + _c.SetTreePath(*v) } - return dc + return _c } // SetSequence sets the "sequence" field. -func (dc *DepartmentCreate) SetSequence(i int) *DepartmentCreate { - dc.mutation.SetSequence(i) - return dc +func (_c *DepartmentCreate) SetSequence(v int) *DepartmentCreate { + _c.mutation.SetSequence(v) + return _c } // SetStatus sets the "status" field. -func (dc *DepartmentCreate) SetStatus(i int8) *DepartmentCreate { - dc.mutation.SetStatus(i) - return dc +func (_c *DepartmentCreate) SetStatus(v int8) *DepartmentCreate { + _c.mutation.SetStatus(v) + return _c } // SetNillableStatus sets the "status" field if the given value is not nil. -func (dc *DepartmentCreate) SetNillableStatus(i *int8) *DepartmentCreate { - if i != nil { - dc.SetStatus(*i) +func (_c *DepartmentCreate) SetNillableStatus(v *int8) *DepartmentCreate { + if v != nil { + _c.SetStatus(*v) } - return dc + return _c } // SetLevel sets the "level" field. -func (dc *DepartmentCreate) SetLevel(i int) *DepartmentCreate { - dc.mutation.SetLevel(i) - return dc +func (_c *DepartmentCreate) SetLevel(v int) *DepartmentCreate { + _c.mutation.SetLevel(v) + return _c } // SetNillableLevel sets the "level" field if the given value is not nil. -func (dc *DepartmentCreate) SetNillableLevel(i *int) *DepartmentCreate { - if i != nil { - dc.SetLevel(*i) +func (_c *DepartmentCreate) SetNillableLevel(v *int) *DepartmentCreate { + if v != nil { + _c.SetLevel(*v) } - return dc + return _c } // SetDescription sets the "description" field. -func (dc *DepartmentCreate) SetDescription(s string) *DepartmentCreate { - dc.mutation.SetDescription(s) - return dc +func (_c *DepartmentCreate) SetDescription(v string) *DepartmentCreate { + _c.mutation.SetDescription(v) + return _c } // SetNillableDescription sets the "description" field if the given value is not nil. -func (dc *DepartmentCreate) SetNillableDescription(s *string) *DepartmentCreate { - if s != nil { - dc.SetDescription(*s) +func (_c *DepartmentCreate) SetNillableDescription(v *string) *DepartmentCreate { + if v != nil { + _c.SetDescription(*v) } - return dc + return _c } // SetParentID sets the "parent_id" field. -func (dc *DepartmentCreate) SetParentID(i int64) *DepartmentCreate { - dc.mutation.SetParentID(i) - return dc +func (_c *DepartmentCreate) SetParentID(v int64) *DepartmentCreate { + _c.mutation.SetParentID(v) + return _c } // SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (dc *DepartmentCreate) SetNillableParentID(i *int64) *DepartmentCreate { - if i != nil { - dc.SetParentID(*i) +func (_c *DepartmentCreate) SetNillableParentID(v *int64) *DepartmentCreate { + if v != nil { + _c.SetParentID(*v) } - return dc + return _c } // SetID sets the "id" field. -func (dc *DepartmentCreate) SetID(i int64) *DepartmentCreate { - dc.mutation.SetID(i) - return dc +func (_c *DepartmentCreate) SetID(v int64) *DepartmentCreate { + _c.mutation.SetID(v) + return _c } // SetNillableID sets the "id" field if the given value is not nil. -func (dc *DepartmentCreate) SetNillableID(i *int64) *DepartmentCreate { - if i != nil { - dc.SetID(*i) +func (_c *DepartmentCreate) SetNillableID(v *int64) *DepartmentCreate { + if v != nil { + _c.SetID(*v) } - return dc + return _c } // AddUserIDs adds the "users" edge to the User entity by IDs. -func (dc *DepartmentCreate) AddUserIDs(ids ...int64) *DepartmentCreate { - dc.mutation.AddUserIDs(ids...) - return dc +func (_c *DepartmentCreate) AddUserIDs(ids ...int64) *DepartmentCreate { + _c.mutation.AddUserIDs(ids...) + return _c } // AddUsers adds the "users" edges to the User entity. -func (dc *DepartmentCreate) AddUsers(u ...*User) *DepartmentCreate { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_c *DepartmentCreate) AddUsers(v ...*User) *DepartmentCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return dc.AddUserIDs(ids...) + return _c.AddUserIDs(ids...) } // AddPositionIDs adds the "positions" edge to the Position entity by IDs. -func (dc *DepartmentCreate) AddPositionIDs(ids ...int64) *DepartmentCreate { - dc.mutation.AddPositionIDs(ids...) - return dc +func (_c *DepartmentCreate) AddPositionIDs(ids ...int64) *DepartmentCreate { + _c.mutation.AddPositionIDs(ids...) + return _c } // AddPositions adds the "positions" edges to the Position entity. -func (dc *DepartmentCreate) AddPositions(p ...*Position) *DepartmentCreate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *DepartmentCreate) AddPositions(v ...*Position) *DepartmentCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return dc.AddPositionIDs(ids...) + return _c.AddPositionIDs(ids...) } // SetParent sets the "parent" edge to the Department entity. -func (dc *DepartmentCreate) SetParent(d *Department) *DepartmentCreate { - return dc.SetParentID(d.ID) +func (_c *DepartmentCreate) SetParent(v *Department) *DepartmentCreate { + return _c.SetParentID(v.ID) } // AddChildIDs adds the "children" edge to the Department entity by IDs. -func (dc *DepartmentCreate) AddChildIDs(ids ...int64) *DepartmentCreate { - dc.mutation.AddChildIDs(ids...) - return dc +func (_c *DepartmentCreate) AddChildIDs(ids ...int64) *DepartmentCreate { + _c.mutation.AddChildIDs(ids...) + return _c } // AddChildren adds the "children" edges to the Department entity. -func (dc *DepartmentCreate) AddChildren(d ...*Department) *DepartmentCreate { - ids := make([]int64, len(d)) - for i := range d { - ids[i] = d[i].ID +func (_c *DepartmentCreate) AddChildren(v ...*Department) *DepartmentCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return dc.AddChildIDs(ids...) + return _c.AddChildIDs(ids...) } // AddUserDepartmentIDs adds the "user_departments" edge to the UserDepartment entity by IDs. -func (dc *DepartmentCreate) AddUserDepartmentIDs(ids ...int) *DepartmentCreate { - dc.mutation.AddUserDepartmentIDs(ids...) - return dc +func (_c *DepartmentCreate) AddUserDepartmentIDs(ids ...int) *DepartmentCreate { + _c.mutation.AddUserDepartmentIDs(ids...) + return _c } // AddUserDepartments adds the "user_departments" edges to the UserDepartment entity. -func (dc *DepartmentCreate) AddUserDepartments(u ...*UserDepartment) *DepartmentCreate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_c *DepartmentCreate) AddUserDepartments(v ...*UserDepartment) *DepartmentCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return dc.AddUserDepartmentIDs(ids...) + return _c.AddUserDepartmentIDs(ids...) } // Mutation returns the DepartmentMutation object of the builder. -func (dc *DepartmentCreate) Mutation() *DepartmentMutation { - return dc.mutation +func (_c *DepartmentCreate) Mutation() *DepartmentMutation { + return _c.mutation } // Save creates the Department in the database. -func (dc *DepartmentCreate) Save(ctx context.Context) (*Department, error) { - dc.defaults() - return withHooks(ctx, dc.sqlSave, dc.mutation, dc.hooks) +func (_c *DepartmentCreate) Save(ctx context.Context) (*Department, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (dc *DepartmentCreate) SaveX(ctx context.Context) *Department { - v, err := dc.Save(ctx) +func (_c *DepartmentCreate) SaveX(ctx context.Context) *Department { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -247,109 +247,109 @@ func (dc *DepartmentCreate) SaveX(ctx context.Context) *Department { } // Exec executes the query. -func (dc *DepartmentCreate) Exec(ctx context.Context) error { - _, err := dc.Save(ctx) +func (_c *DepartmentCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (dc *DepartmentCreate) ExecX(ctx context.Context) { - if err := dc.Exec(ctx); err != nil { +func (_c *DepartmentCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (dc *DepartmentCreate) defaults() { - if _, ok := dc.mutation.CreateTime(); !ok { +func (_c *DepartmentCreate) defaults() { + if _, ok := _c.mutation.CreateTime(); !ok { v := department.DefaultCreateTime() - dc.mutation.SetCreateTime(v) + _c.mutation.SetCreateTime(v) } - if _, ok := dc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { v := department.DefaultUpdateTime() - dc.mutation.SetUpdateTime(v) + _c.mutation.SetUpdateTime(v) } - if _, ok := dc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { v := department.DefaultName - dc.mutation.SetName(v) + _c.mutation.SetName(v) } - if _, ok := dc.mutation.TreePath(); !ok { + if _, ok := _c.mutation.TreePath(); !ok { v := department.DefaultTreePath - dc.mutation.SetTreePath(v) + _c.mutation.SetTreePath(v) } - if _, ok := dc.mutation.Status(); !ok { + if _, ok := _c.mutation.Status(); !ok { v := department.DefaultStatus - dc.mutation.SetStatus(v) + _c.mutation.SetStatus(v) } - if _, ok := dc.mutation.Level(); !ok { + if _, ok := _c.mutation.Level(); !ok { v := department.DefaultLevel - dc.mutation.SetLevel(v) + _c.mutation.SetLevel(v) } - if _, ok := dc.mutation.Description(); !ok { + if _, ok := _c.mutation.Description(); !ok { v := department.DefaultDescription - dc.mutation.SetDescription(v) + _c.mutation.SetDescription(v) } - if _, ok := dc.mutation.ID(); !ok { + if _, ok := _c.mutation.ID(); !ok { v := department.DefaultID() - dc.mutation.SetID(v) + _c.mutation.SetID(v) } } // check runs all checks and user-defined validators on the builder. -func (dc *DepartmentCreate) check() error { - if _, ok := dc.mutation.CreateTime(); !ok { +func (_c *DepartmentCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Department.create_time"`)} } - if _, ok := dc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Department.update_time"`)} } - if _, ok := dc.mutation.Keyword(); !ok { + if _, ok := _c.mutation.Keyword(); !ok { return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Department.keyword"`)} } - if v, ok := dc.mutation.Keyword(); ok { + if v, ok := _c.mutation.Keyword(); ok { if err := department.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Department.keyword": %w`, err)} } } - if _, ok := dc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Department.name"`)} } - if v, ok := dc.mutation.Name(); ok { + if v, ok := _c.mutation.Name(); ok { if err := department.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Department.name": %w`, err)} } } - if _, ok := dc.mutation.TreePath(); !ok { + if _, ok := _c.mutation.TreePath(); !ok { return &ValidationError{Name: "tree_path", err: errors.New(`ent: missing required field "Department.tree_path"`)} } - if v, ok := dc.mutation.TreePath(); ok { + if v, ok := _c.mutation.TreePath(); ok { if err := department.TreePathValidator(v); err != nil { return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Department.tree_path": %w`, err)} } } - if _, ok := dc.mutation.Sequence(); !ok { + if _, ok := _c.mutation.Sequence(); !ok { return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "Department.sequence"`)} } - if _, ok := dc.mutation.Status(); !ok { + if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Department.status"`)} } - if _, ok := dc.mutation.Level(); !ok { + if _, ok := _c.mutation.Level(); !ok { return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "Department.level"`)} } - if _, ok := dc.mutation.Description(); !ok { + if _, ok := _c.mutation.Description(); !ok { return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Department.description"`)} } - if v, ok := dc.mutation.Description(); ok { + if v, ok := _c.mutation.Description(); ok { if err := department.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Department.description": %w`, err)} } } - if v, ok := dc.mutation.ParentID(); ok { + if v, ok := _c.mutation.ParentID(); ok { if err := department.ParentIDValidator(v); err != nil { return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Department.parent_id": %w`, err)} } } - if v, ok := dc.mutation.ID(); ok { + if v, ok := _c.mutation.ID(); ok { if err := department.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Department.id": %w`, err)} } @@ -357,12 +357,12 @@ func (dc *DepartmentCreate) check() error { return nil } -func (dc *DepartmentCreate) sqlSave(ctx context.Context) (*Department, error) { - if err := dc.check(); err != nil { +func (_c *DepartmentCreate) sqlSave(ctx context.Context) (*Department, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := dc.createSpec() - if err := sqlgraph.CreateNode(ctx, dc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -372,57 +372,57 @@ func (dc *DepartmentCreate) sqlSave(ctx context.Context) (*Department, error) { id := _spec.ID.Value.(int64) _node.ID = int64(id) } - dc.mutation.id = &_node.ID - dc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (dc *DepartmentCreate) createSpec() (*Department, *sqlgraph.CreateSpec) { +func (_c *DepartmentCreate) createSpec() (*Department, *sqlgraph.CreateSpec) { var ( - _node = &Department{config: dc.config} + _node = &Department{config: _c.config} _spec = sqlgraph.NewCreateSpec(department.Table, sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64)) ) - if id, ok := dc.mutation.ID(); ok { + if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } - if value, ok := dc.mutation.CreateTime(); ok { + if value, ok := _c.mutation.CreateTime(); ok { _spec.SetField(department.FieldCreateTime, field.TypeTime, value) _node.CreateTime = value } - if value, ok := dc.mutation.UpdateTime(); ok { + if value, ok := _c.mutation.UpdateTime(); ok { _spec.SetField(department.FieldUpdateTime, field.TypeTime, value) _node.UpdateTime = value } - if value, ok := dc.mutation.Keyword(); ok { + if value, ok := _c.mutation.Keyword(); ok { _spec.SetField(department.FieldKeyword, field.TypeString, value) _node.Keyword = value } - if value, ok := dc.mutation.Name(); ok { + if value, ok := _c.mutation.Name(); ok { _spec.SetField(department.FieldName, field.TypeString, value) _node.Name = value } - if value, ok := dc.mutation.TreePath(); ok { + if value, ok := _c.mutation.TreePath(); ok { _spec.SetField(department.FieldTreePath, field.TypeString, value) _node.TreePath = value } - if value, ok := dc.mutation.Sequence(); ok { + if value, ok := _c.mutation.Sequence(); ok { _spec.SetField(department.FieldSequence, field.TypeInt, value) _node.Sequence = value } - if value, ok := dc.mutation.Status(); ok { + if value, ok := _c.mutation.Status(); ok { _spec.SetField(department.FieldStatus, field.TypeInt8, value) _node.Status = value } - if value, ok := dc.mutation.Level(); ok { + if value, ok := _c.mutation.Level(); ok { _spec.SetField(department.FieldLevel, field.TypeInt, value) _node.Level = value } - if value, ok := dc.mutation.Description(); ok { + if value, ok := _c.mutation.Description(); ok { _spec.SetField(department.FieldDescription, field.TypeString, value) _node.Description = value } - if nodes := dc.mutation.UsersIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UsersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -438,7 +438,7 @@ func (dc *DepartmentCreate) createSpec() (*Department, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := dc.mutation.PositionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -454,7 +454,7 @@ func (dc *DepartmentCreate) createSpec() (*Department, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := dc.mutation.ParentIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -471,7 +471,7 @@ func (dc *DepartmentCreate) createSpec() (*Department, *sqlgraph.CreateSpec) { _node.ParentID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := dc.mutation.ChildrenIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -487,7 +487,7 @@ func (dc *DepartmentCreate) createSpec() (*Department, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := dc.mutation.UserDepartmentsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UserDepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -507,23 +507,23 @@ func (dc *DepartmentCreate) createSpec() (*Department, *sqlgraph.CreateSpec) { } // SetDepartment set the Department -func (dc *DepartmentCreate) SetDepartment(input *Department, fields ...string) *DepartmentCreate { - m := dc.mutation +func (_c *DepartmentCreate) SetDepartment(input *Department, fields ...string) *DepartmentCreate { + m := _c.mutation if len(fields) == 0 { fields = department.Columns } _ = m.SetFields(input, fields...) - return dc + return _c } // SetDepartmentWithZero set the Department -func (dc *DepartmentCreate) SetDepartmentWithZero(input *Department, fields ...string) *DepartmentCreate { - m := dc.mutation +func (_c *DepartmentCreate) SetDepartmentWithZero(input *Department, fields ...string) *DepartmentCreate { + m := _c.mutation if len(fields) == 0 { fields = department.Columns } _ = m.SetFieldsWithZero(input, fields...) - return dc + return _c } // DepartmentCreateBulk is the builder for creating many Department entities in bulk. @@ -534,16 +534,16 @@ type DepartmentCreateBulk struct { } // Save creates the Department entities in the database. -func (dcb *DepartmentCreateBulk) Save(ctx context.Context) ([]*Department, error) { - if dcb.err != nil { - return nil, dcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(dcb.builders)) - nodes := make([]*Department, len(dcb.builders)) - mutators := make([]Mutator, len(dcb.builders)) - for i := range dcb.builders { +func (_c *DepartmentCreateBulk) Save(ctx context.Context) ([]*Department, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Department, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := dcb.builders[i] + builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*DepartmentMutation) @@ -557,11 +557,11 @@ func (dcb *DepartmentCreateBulk) Save(ctx context.Context) ([]*Department, error var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, dcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, dcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -585,7 +585,7 @@ func (dcb *DepartmentCreateBulk) Save(ctx context.Context) ([]*Department, error }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, dcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -593,8 +593,8 @@ func (dcb *DepartmentCreateBulk) Save(ctx context.Context) ([]*Department, error } // SaveX is like Save, but panics if an error occurs. -func (dcb *DepartmentCreateBulk) SaveX(ctx context.Context) []*Department { - v, err := dcb.Save(ctx) +func (_c *DepartmentCreateBulk) SaveX(ctx context.Context) []*Department { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -602,14 +602,14 @@ func (dcb *DepartmentCreateBulk) SaveX(ctx context.Context) []*Department { } // Exec executes the query. -func (dcb *DepartmentCreateBulk) Exec(ctx context.Context) error { - _, err := dcb.Save(ctx) +func (_c *DepartmentCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (dcb *DepartmentCreateBulk) ExecX(ctx context.Context) { - if err := dcb.Exec(ctx); err != nil { +func (_c *DepartmentCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/department_delete.go b/internal/data/entity/ent/department_delete.go index 90ea30a3..e8ba54b0 100644 --- a/internal/data/entity/ent/department_delete.go +++ b/internal/data/entity/ent/department_delete.go @@ -20,56 +20,56 @@ type DepartmentDelete struct { } // Where appends a list predicates to the DepartmentDelete builder. -func (dd *DepartmentDelete) Where(ps ...predicate.Department) *DepartmentDelete { - dd.mutation.Where(ps...) - return dd +func (_d *DepartmentDelete) Where(ps ...predicate.Department) *DepartmentDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (dd *DepartmentDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, dd.sqlExec, dd.mutation, dd.hooks) +func (_d *DepartmentDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (dd *DepartmentDelete) ExecX(ctx context.Context) int { - n, err := dd.Exec(ctx) +func (_d *DepartmentDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (dd *DepartmentDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *DepartmentDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(department.Table, sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64)) - if ps := dd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, dd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - dd.mutation.done = true + _d.mutation.done = true return affected, err } // DepartmentDeleteOne is the builder for deleting a single Department entity. type DepartmentDeleteOne struct { - dd *DepartmentDelete + _d *DepartmentDelete } // Where appends a list predicates to the DepartmentDelete builder. -func (ddo *DepartmentDeleteOne) Where(ps ...predicate.Department) *DepartmentDeleteOne { - ddo.dd.mutation.Where(ps...) - return ddo +func (_d *DepartmentDeleteOne) Where(ps ...predicate.Department) *DepartmentDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (ddo *DepartmentDeleteOne) Exec(ctx context.Context) error { - n, err := ddo.dd.Exec(ctx) +func (_d *DepartmentDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (ddo *DepartmentDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (ddo *DepartmentDeleteOne) ExecX(ctx context.Context) { - if err := ddo.Exec(ctx); err != nil { +func (_d *DepartmentDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/department_query.go b/internal/data/entity/ent/department_query.go index 6aa920ea..9bbdd136 100644 --- a/internal/data/entity/ent/department_query.go +++ b/internal/data/entity/ent/department_query.go @@ -39,44 +39,44 @@ type DepartmentQuery struct { } // Where adds a new predicate for the DepartmentQuery builder. -func (dq *DepartmentQuery) Where(ps ...predicate.Department) *DepartmentQuery { - dq.predicates = append(dq.predicates, ps...) - return dq +func (_q *DepartmentQuery) Where(ps ...predicate.Department) *DepartmentQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (dq *DepartmentQuery) Limit(limit int) *DepartmentQuery { - dq.ctx.Limit = &limit - return dq +func (_q *DepartmentQuery) Limit(limit int) *DepartmentQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (dq *DepartmentQuery) Offset(offset int) *DepartmentQuery { - dq.ctx.Offset = &offset - return dq +func (_q *DepartmentQuery) Offset(offset int) *DepartmentQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (dq *DepartmentQuery) Unique(unique bool) *DepartmentQuery { - dq.ctx.Unique = &unique - return dq +func (_q *DepartmentQuery) Unique(unique bool) *DepartmentQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (dq *DepartmentQuery) Order(o ...department.OrderOption) *DepartmentQuery { - dq.order = append(dq.order, o...) - return dq +func (_q *DepartmentQuery) Order(o ...department.OrderOption) *DepartmentQuery { + _q.order = append(_q.order, o...) + return _q } // QueryUsers chains the current query on the "users" edge. -func (dq *DepartmentQuery) QueryUsers() *UserQuery { - query := (&UserClient{config: dq.config}).Query() +func (_q *DepartmentQuery) QueryUsers() *UserQuery { + query := (&UserClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := dq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := dq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -85,20 +85,20 @@ func (dq *DepartmentQuery) QueryUsers() *UserQuery { sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, department.UsersTable, department.UsersPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(dq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPositions chains the current query on the "positions" edge. -func (dq *DepartmentQuery) QueryPositions() *PositionQuery { - query := (&PositionClient{config: dq.config}).Query() +func (_q *DepartmentQuery) QueryPositions() *PositionQuery { + query := (&PositionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := dq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := dq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -107,20 +107,20 @@ func (dq *DepartmentQuery) QueryPositions() *PositionQuery { sqlgraph.To(position.Table, position.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, department.PositionsTable, department.PositionsColumn), ) - fromU = sqlgraph.SetNeighbors(dq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryParent chains the current query on the "parent" edge. -func (dq *DepartmentQuery) QueryParent() *DepartmentQuery { - query := (&DepartmentClient{config: dq.config}).Query() +func (_q *DepartmentQuery) QueryParent() *DepartmentQuery { + query := (&DepartmentClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := dq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := dq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -129,20 +129,20 @@ func (dq *DepartmentQuery) QueryParent() *DepartmentQuery { sqlgraph.To(department.Table, department.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, department.ParentTable, department.ParentColumn), ) - fromU = sqlgraph.SetNeighbors(dq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryChildren chains the current query on the "children" edge. -func (dq *DepartmentQuery) QueryChildren() *DepartmentQuery { - query := (&DepartmentClient{config: dq.config}).Query() +func (_q *DepartmentQuery) QueryChildren() *DepartmentQuery { + query := (&DepartmentClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := dq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := dq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -151,20 +151,20 @@ func (dq *DepartmentQuery) QueryChildren() *DepartmentQuery { sqlgraph.To(department.Table, department.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, department.ChildrenTable, department.ChildrenColumn), ) - fromU = sqlgraph.SetNeighbors(dq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryUserDepartments chains the current query on the "user_departments" edge. -func (dq *DepartmentQuery) QueryUserDepartments() *UserDepartmentQuery { - query := (&UserDepartmentClient{config: dq.config}).Query() +func (_q *DepartmentQuery) QueryUserDepartments() *UserDepartmentQuery { + query := (&UserDepartmentClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := dq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := dq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -173,7 +173,7 @@ func (dq *DepartmentQuery) QueryUserDepartments() *UserDepartmentQuery { sqlgraph.To(userdepartment.Table, userdepartment.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, department.UserDepartmentsTable, department.UserDepartmentsColumn), ) - fromU = sqlgraph.SetNeighbors(dq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -181,8 +181,8 @@ func (dq *DepartmentQuery) QueryUserDepartments() *UserDepartmentQuery { // First returns the first Department entity from the query. // Returns a *NotFoundError when no Department was found. -func (dq *DepartmentQuery) First(ctx context.Context) (*Department, error) { - nodes, err := dq.Limit(1).All(setContextOp(ctx, dq.ctx, ent.OpQueryFirst)) +func (_q *DepartmentQuery) First(ctx context.Context) (*Department, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -193,8 +193,8 @@ func (dq *DepartmentQuery) First(ctx context.Context) (*Department, error) { } // FirstX is like First, but panics if an error occurs. -func (dq *DepartmentQuery) FirstX(ctx context.Context) *Department { - node, err := dq.First(ctx) +func (_q *DepartmentQuery) FirstX(ctx context.Context) *Department { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -203,9 +203,9 @@ func (dq *DepartmentQuery) FirstX(ctx context.Context) *Department { // FirstID returns the first Department ID from the query. // Returns a *NotFoundError when no Department ID was found. -func (dq *DepartmentQuery) FirstID(ctx context.Context) (id int64, err error) { +func (_q *DepartmentQuery) FirstID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = dq.Limit(1).IDs(setContextOp(ctx, dq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -216,8 +216,8 @@ func (dq *DepartmentQuery) FirstID(ctx context.Context) (id int64, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (dq *DepartmentQuery) FirstIDX(ctx context.Context) int64 { - id, err := dq.FirstID(ctx) +func (_q *DepartmentQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -227,8 +227,8 @@ func (dq *DepartmentQuery) FirstIDX(ctx context.Context) int64 { // Only returns a single Department entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Department entity is found. // Returns a *NotFoundError when no Department entities are found. -func (dq *DepartmentQuery) Only(ctx context.Context) (*Department, error) { - nodes, err := dq.Limit(2).All(setContextOp(ctx, dq.ctx, ent.OpQueryOnly)) +func (_q *DepartmentQuery) Only(ctx context.Context) (*Department, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -243,8 +243,8 @@ func (dq *DepartmentQuery) Only(ctx context.Context) (*Department, error) { } // OnlyX is like Only, but panics if an error occurs. -func (dq *DepartmentQuery) OnlyX(ctx context.Context) *Department { - node, err := dq.Only(ctx) +func (_q *DepartmentQuery) OnlyX(ctx context.Context) *Department { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -254,9 +254,9 @@ func (dq *DepartmentQuery) OnlyX(ctx context.Context) *Department { // OnlyID is like Only, but returns the only Department ID in the query. // Returns a *NotSingularError when more than one Department ID is found. // Returns a *NotFoundError when no entities are found. -func (dq *DepartmentQuery) OnlyID(ctx context.Context) (id int64, err error) { +func (_q *DepartmentQuery) OnlyID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = dq.Limit(2).IDs(setContextOp(ctx, dq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -271,8 +271,8 @@ func (dq *DepartmentQuery) OnlyID(ctx context.Context) (id int64, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (dq *DepartmentQuery) OnlyIDX(ctx context.Context) int64 { - id, err := dq.OnlyID(ctx) +func (_q *DepartmentQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -280,18 +280,18 @@ func (dq *DepartmentQuery) OnlyIDX(ctx context.Context) int64 { } // All executes the query and returns a list of Departments. -func (dq *DepartmentQuery) All(ctx context.Context) ([]*Department, error) { - ctx = setContextOp(ctx, dq.ctx, ent.OpQueryAll) - if err := dq.prepareQuery(ctx); err != nil { +func (_q *DepartmentQuery) All(ctx context.Context) ([]*Department, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Department, *DepartmentQuery]() - return withInterceptors[[]*Department](ctx, dq, qr, dq.inters) + return withInterceptors[[]*Department](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (dq *DepartmentQuery) AllX(ctx context.Context) []*Department { - nodes, err := dq.All(ctx) +func (_q *DepartmentQuery) AllX(ctx context.Context) []*Department { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -299,20 +299,20 @@ func (dq *DepartmentQuery) AllX(ctx context.Context) []*Department { } // IDs executes the query and returns a list of Department IDs. -func (dq *DepartmentQuery) IDs(ctx context.Context) (ids []int64, err error) { - if dq.ctx.Unique == nil && dq.path != nil { - dq.Unique(true) +func (_q *DepartmentQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, dq.ctx, ent.OpQueryIDs) - if err = dq.Select(department.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(department.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (dq *DepartmentQuery) IDsX(ctx context.Context) []int64 { - ids, err := dq.IDs(ctx) +func (_q *DepartmentQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -320,17 +320,17 @@ func (dq *DepartmentQuery) IDsX(ctx context.Context) []int64 { } // Count returns the count of the given query. -func (dq *DepartmentQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, dq.ctx, ent.OpQueryCount) - if err := dq.prepareQuery(ctx); err != nil { +func (_q *DepartmentQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, dq, querierCount[*DepartmentQuery](), dq.inters) + return withInterceptors[int](ctx, _q, querierCount[*DepartmentQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (dq *DepartmentQuery) CountX(ctx context.Context) int { - count, err := dq.Count(ctx) +func (_q *DepartmentQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -338,9 +338,9 @@ func (dq *DepartmentQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (dq *DepartmentQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, dq.ctx, ent.OpQueryExist) - switch _, err := dq.FirstID(ctx); { +func (_q *DepartmentQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -351,8 +351,8 @@ func (dq *DepartmentQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (dq *DepartmentQuery) ExistX(ctx context.Context) bool { - exist, err := dq.Exist(ctx) +func (_q *DepartmentQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -361,81 +361,81 @@ func (dq *DepartmentQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the DepartmentQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (dq *DepartmentQuery) Clone() *DepartmentQuery { - if dq == nil { +func (_q *DepartmentQuery) Clone() *DepartmentQuery { + if _q == nil { return nil } return &DepartmentQuery{ - config: dq.config, - ctx: dq.ctx.Clone(), - order: append([]department.OrderOption{}, dq.order...), - inters: append([]Interceptor{}, dq.inters...), - predicates: append([]predicate.Department{}, dq.predicates...), - withUsers: dq.withUsers.Clone(), - withPositions: dq.withPositions.Clone(), - withParent: dq.withParent.Clone(), - withChildren: dq.withChildren.Clone(), - withUserDepartments: dq.withUserDepartments.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]department.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Department{}, _q.predicates...), + withUsers: _q.withUsers.Clone(), + withPositions: _q.withPositions.Clone(), + withParent: _q.withParent.Clone(), + withChildren: _q.withChildren.Clone(), + withUserDepartments: _q.withUserDepartments.Clone(), // clone intermediate query. - sql: dq.sql.Clone(), - path: dq.path, - modifiers: append([]func(*sql.Selector){}, dq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithUsers tells the query-builder to eager-load the nodes that are connected to // the "users" edge. The optional arguments are used to configure the query builder of the edge. -func (dq *DepartmentQuery) WithUsers(opts ...func(*UserQuery)) *DepartmentQuery { - query := (&UserClient{config: dq.config}).Query() +func (_q *DepartmentQuery) WithUsers(opts ...func(*UserQuery)) *DepartmentQuery { + query := (&UserClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - dq.withUsers = query - return dq + _q.withUsers = query + return _q } // WithPositions tells the query-builder to eager-load the nodes that are connected to // the "positions" edge. The optional arguments are used to configure the query builder of the edge. -func (dq *DepartmentQuery) WithPositions(opts ...func(*PositionQuery)) *DepartmentQuery { - query := (&PositionClient{config: dq.config}).Query() +func (_q *DepartmentQuery) WithPositions(opts ...func(*PositionQuery)) *DepartmentQuery { + query := (&PositionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - dq.withPositions = query - return dq + _q.withPositions = query + return _q } // WithParent tells the query-builder to eager-load the nodes that are connected to // the "parent" edge. The optional arguments are used to configure the query builder of the edge. -func (dq *DepartmentQuery) WithParent(opts ...func(*DepartmentQuery)) *DepartmentQuery { - query := (&DepartmentClient{config: dq.config}).Query() +func (_q *DepartmentQuery) WithParent(opts ...func(*DepartmentQuery)) *DepartmentQuery { + query := (&DepartmentClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - dq.withParent = query - return dq + _q.withParent = query + return _q } // WithChildren tells the query-builder to eager-load the nodes that are connected to // the "children" edge. The optional arguments are used to configure the query builder of the edge. -func (dq *DepartmentQuery) WithChildren(opts ...func(*DepartmentQuery)) *DepartmentQuery { - query := (&DepartmentClient{config: dq.config}).Query() +func (_q *DepartmentQuery) WithChildren(opts ...func(*DepartmentQuery)) *DepartmentQuery { + query := (&DepartmentClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - dq.withChildren = query - return dq + _q.withChildren = query + return _q } // WithUserDepartments tells the query-builder to eager-load the nodes that are connected to // the "user_departments" edge. The optional arguments are used to configure the query builder of the edge. -func (dq *DepartmentQuery) WithUserDepartments(opts ...func(*UserDepartmentQuery)) *DepartmentQuery { - query := (&UserDepartmentClient{config: dq.config}).Query() +func (_q *DepartmentQuery) WithUserDepartments(opts ...func(*UserDepartmentQuery)) *DepartmentQuery { + query := (&UserDepartmentClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - dq.withUserDepartments = query - return dq + _q.withUserDepartments = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -452,10 +452,10 @@ func (dq *DepartmentQuery) WithUserDepartments(opts ...func(*UserDepartmentQuery // GroupBy(department.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (dq *DepartmentQuery) GroupBy(field string, fields ...string) *DepartmentGroupBy { - dq.ctx.Fields = append([]string{field}, fields...) - grbuild := &DepartmentGroupBy{build: dq} - grbuild.flds = &dq.ctx.Fields +func (_q *DepartmentQuery) GroupBy(field string, fields ...string) *DepartmentGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &DepartmentGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = department.Label grbuild.scan = grbuild.Scan return grbuild @@ -473,107 +473,107 @@ func (dq *DepartmentQuery) GroupBy(field string, fields ...string) *DepartmentGr // client.Department.Query(). // Select(department.FieldCreateTime). // Scan(ctx, &v) -func (dq *DepartmentQuery) Select(fields ...string) *DepartmentSelect { - dq.ctx.Fields = append(dq.ctx.Fields, fields...) - sbuild := &DepartmentSelect{DepartmentQuery: dq} +func (_q *DepartmentQuery) Select(fields ...string) *DepartmentSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &DepartmentSelect{DepartmentQuery: _q} sbuild.label = department.Label - sbuild.flds, sbuild.scan = &dq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a DepartmentSelect configured with the given aggregations. -func (dq *DepartmentQuery) Aggregate(fns ...AggregateFunc) *DepartmentSelect { - return dq.Select().Aggregate(fns...) +func (_q *DepartmentQuery) Aggregate(fns ...AggregateFunc) *DepartmentSelect { + return _q.Select().Aggregate(fns...) } -func (dq *DepartmentQuery) prepareQuery(ctx context.Context) error { - for _, inter := range dq.inters { +func (_q *DepartmentQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, dq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range dq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !department.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if dq.path != nil { - prev, err := dq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - dq.sql = prev + _q.sql = prev } return nil } -func (dq *DepartmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Department, error) { +func (_q *DepartmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Department, error) { var ( nodes = []*Department{} - _spec = dq.querySpec() + _spec = _q.querySpec() loadedTypes = [5]bool{ - dq.withUsers != nil, - dq.withPositions != nil, - dq.withParent != nil, - dq.withChildren != nil, - dq.withUserDepartments != nil, + _q.withUsers != nil, + _q.withPositions != nil, + _q.withParent != nil, + _q.withChildren != nil, + _q.withUserDepartments != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Department).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Department{config: dq.config} + node := &Department{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(dq.modifiers) > 0 { - _spec.Modifiers = dq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, dq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := dq.withUsers; query != nil { - if err := dq.loadUsers(ctx, query, nodes, + if query := _q.withUsers; query != nil { + if err := _q.loadUsers(ctx, query, nodes, func(n *Department) { n.Edges.Users = []*User{} }, func(n *Department, e *User) { n.Edges.Users = append(n.Edges.Users, e) }); err != nil { return nil, err } } - if query := dq.withPositions; query != nil { - if err := dq.loadPositions(ctx, query, nodes, + if query := _q.withPositions; query != nil { + if err := _q.loadPositions(ctx, query, nodes, func(n *Department) { n.Edges.Positions = []*Position{} }, func(n *Department, e *Position) { n.Edges.Positions = append(n.Edges.Positions, e) }); err != nil { return nil, err } } - if query := dq.withParent; query != nil { - if err := dq.loadParent(ctx, query, nodes, nil, + if query := _q.withParent; query != nil { + if err := _q.loadParent(ctx, query, nodes, nil, func(n *Department, e *Department) { n.Edges.Parent = e }); err != nil { return nil, err } } - if query := dq.withChildren; query != nil { - if err := dq.loadChildren(ctx, query, nodes, + if query := _q.withChildren; query != nil { + if err := _q.loadChildren(ctx, query, nodes, func(n *Department) { n.Edges.Children = []*Department{} }, func(n *Department, e *Department) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil { return nil, err } } - if query := dq.withUserDepartments; query != nil { - if err := dq.loadUserDepartments(ctx, query, nodes, + if query := _q.withUserDepartments; query != nil { + if err := _q.loadUserDepartments(ctx, query, nodes, func(n *Department) { n.Edges.UserDepartments = []*UserDepartment{} }, func(n *Department, e *UserDepartment) { n.Edges.UserDepartments = append(n.Edges.UserDepartments, e) }); err != nil { return nil, err @@ -582,7 +582,7 @@ func (dq *DepartmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*D return nodes, nil } -func (dq *DepartmentQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*Department, init func(*Department), assign func(*Department, *User)) error { +func (_q *DepartmentQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*Department, init func(*Department), assign func(*Department, *User)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*Department) nids := make(map[int64]map[*Department]struct{}) @@ -643,7 +643,7 @@ func (dq *DepartmentQuery) loadUsers(ctx context.Context, query *UserQuery, node } return nil } -func (dq *DepartmentQuery) loadPositions(ctx context.Context, query *PositionQuery, nodes []*Department, init func(*Department), assign func(*Department, *Position)) error { +func (_q *DepartmentQuery) loadPositions(ctx context.Context, query *PositionQuery, nodes []*Department, init func(*Department), assign func(*Department, *Position)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Department) for i := range nodes { @@ -673,7 +673,7 @@ func (dq *DepartmentQuery) loadPositions(ctx context.Context, query *PositionQue } return nil } -func (dq *DepartmentQuery) loadParent(ctx context.Context, query *DepartmentQuery, nodes []*Department, init func(*Department), assign func(*Department, *Department)) error { +func (_q *DepartmentQuery) loadParent(ctx context.Context, query *DepartmentQuery, nodes []*Department, init func(*Department), assign func(*Department, *Department)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*Department) for i := range nodes { @@ -702,7 +702,7 @@ func (dq *DepartmentQuery) loadParent(ctx context.Context, query *DepartmentQuer } return nil } -func (dq *DepartmentQuery) loadChildren(ctx context.Context, query *DepartmentQuery, nodes []*Department, init func(*Department), assign func(*Department, *Department)) error { +func (_q *DepartmentQuery) loadChildren(ctx context.Context, query *DepartmentQuery, nodes []*Department, init func(*Department), assign func(*Department, *Department)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Department) for i := range nodes { @@ -732,7 +732,7 @@ func (dq *DepartmentQuery) loadChildren(ctx context.Context, query *DepartmentQu } return nil } -func (dq *DepartmentQuery) loadUserDepartments(ctx context.Context, query *UserDepartmentQuery, nodes []*Department, init func(*Department), assign func(*Department, *UserDepartment)) error { +func (_q *DepartmentQuery) loadUserDepartments(ctx context.Context, query *UserDepartmentQuery, nodes []*Department, init func(*Department), assign func(*Department, *UserDepartment)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Department) for i := range nodes { @@ -763,27 +763,27 @@ func (dq *DepartmentQuery) loadUserDepartments(ctx context.Context, query *UserD return nil } -func (dq *DepartmentQuery) sqlCount(ctx context.Context) (int, error) { - _spec := dq.querySpec() - if len(dq.modifiers) > 0 { - _spec.Modifiers = dq.modifiers +func (_q *DepartmentQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = dq.ctx.Fields - if len(dq.ctx.Fields) > 0 { - _spec.Unique = dq.ctx.Unique != nil && *dq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, dq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (dq *DepartmentQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *DepartmentQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(department.Table, department.Columns, sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64)) - _spec.From = dq.sql - if unique := dq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if dq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := dq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, department.FieldID) for i := range fields { @@ -791,24 +791,24 @@ func (dq *DepartmentQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if dq.withParent != nil { + if _q.withParent != nil { _spec.Node.AddColumnOnce(department.FieldParentID) } } - if ps := dq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := dq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := dq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := dq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -818,36 +818,36 @@ func (dq *DepartmentQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (dq *DepartmentQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(dq.driver.Dialect()) +func (_q *DepartmentQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(department.Table) - columns := dq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = department.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if dq.sql != nil { - selector = dq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if dq.ctx.Unique != nil && *dq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range dq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range dq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range dq.order { + for _, p := range _q.order { p(selector) } - if offset := dq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := dq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -856,33 +856,33 @@ func (dq *DepartmentQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (dq *DepartmentQuery) ForUpdate(opts ...sql.LockOption) *DepartmentQuery { - if dq.driver.Dialect() == dialect.Postgres { - dq.Unique(false) +func (_q *DepartmentQuery) ForUpdate(opts ...sql.LockOption) *DepartmentQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - dq.modifiers = append(dq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return dq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (dq *DepartmentQuery) ForShare(opts ...sql.LockOption) *DepartmentQuery { - if dq.driver.Dialect() == dialect.Postgres { - dq.Unique(false) +func (_q *DepartmentQuery) ForShare(opts ...sql.LockOption) *DepartmentQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - dq.modifiers = append(dq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return dq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (dq *DepartmentQuery) Modify(modifiers ...func(s *sql.Selector)) *DepartmentSelect { - dq.modifiers = append(dq.modifiers, modifiers...) - return dq.Select() +func (_q *DepartmentQuery) Modify(modifiers ...func(s *sql.Selector)) *DepartmentSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -940,41 +940,41 @@ type DepartmentGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (dgb *DepartmentGroupBy) Aggregate(fns ...AggregateFunc) *DepartmentGroupBy { - dgb.fns = append(dgb.fns, fns...) - return dgb +func (_g *DepartmentGroupBy) Aggregate(fns ...AggregateFunc) *DepartmentGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (dgb *DepartmentGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, dgb.build.ctx, ent.OpQueryGroupBy) - if err := dgb.build.prepareQuery(ctx); err != nil { +func (_g *DepartmentGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*DepartmentQuery, *DepartmentGroupBy](ctx, dgb.build, dgb, dgb.build.inters, v) + return scanWithInterceptors[*DepartmentQuery, *DepartmentGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (dgb *DepartmentGroupBy) sqlScan(ctx context.Context, root *DepartmentQuery, v any) error { +func (_g *DepartmentGroupBy) sqlScan(ctx context.Context, root *DepartmentQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(dgb.fns)) - for _, fn := range dgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*dgb.flds)+len(dgb.fns)) - for _, f := range *dgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*dgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := dgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -988,27 +988,27 @@ type DepartmentSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (ds *DepartmentSelect) Aggregate(fns ...AggregateFunc) *DepartmentSelect { - ds.fns = append(ds.fns, fns...) - return ds +func (_s *DepartmentSelect) Aggregate(fns ...AggregateFunc) *DepartmentSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (ds *DepartmentSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ds.ctx, ent.OpQuerySelect) - if err := ds.prepareQuery(ctx); err != nil { +func (_s *DepartmentSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*DepartmentQuery, *DepartmentSelect](ctx, ds.DepartmentQuery, ds, ds.inters, v) + return scanWithInterceptors[*DepartmentQuery, *DepartmentSelect](ctx, _s.DepartmentQuery, _s, _s.inters, v) } -func (ds *DepartmentSelect) sqlScan(ctx context.Context, root *DepartmentQuery, v any) error { +func (_s *DepartmentSelect) sqlScan(ctx context.Context, root *DepartmentQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ds.fns)) - for _, fn := range ds.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*ds.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -1016,7 +1016,7 @@ func (ds *DepartmentSelect) sqlScan(ctx context.Context, root *DepartmentQuery, } rows := &sql.Rows{} query, args := selector.Query() - if err := ds.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -1024,7 +1024,7 @@ func (ds *DepartmentSelect) sqlScan(ctx context.Context, root *DepartmentQuery, } // Modify adds a query modifier for attaching custom logic to queries. -func (ds *DepartmentSelect) Modify(modifiers ...func(s *sql.Selector)) *DepartmentSelect { - ds.modifiers = append(ds.modifiers, modifiers...) - return ds +func (_s *DepartmentSelect) Modify(modifiers ...func(s *sql.Selector)) *DepartmentSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/department_update.go b/internal/data/entity/ent/department_update.go index 16fd6a7f..c3aec8cd 100644 --- a/internal/data/entity/ent/department_update.go +++ b/internal/data/entity/ent/department_update.go @@ -27,325 +27,325 @@ type DepartmentUpdate struct { } // Where appends a list predicates to the DepartmentUpdate builder. -func (du *DepartmentUpdate) Where(ps ...predicate.Department) *DepartmentUpdate { - du.mutation.Where(ps...) - return du +func (_u *DepartmentUpdate) Where(ps ...predicate.Department) *DepartmentUpdate { + _u.mutation.Where(ps...) + return _u } // SetUpdateTime sets the "update_time" field. -func (du *DepartmentUpdate) SetUpdateTime(t time.Time) *DepartmentUpdate { - du.mutation.SetUpdateTime(t) - return du +func (_u *DepartmentUpdate) SetUpdateTime(v time.Time) *DepartmentUpdate { + _u.mutation.SetUpdateTime(v) + return _u } // SetKeyword sets the "keyword" field. -func (du *DepartmentUpdate) SetKeyword(s string) *DepartmentUpdate { - du.mutation.SetKeyword(s) - return du +func (_u *DepartmentUpdate) SetKeyword(v string) *DepartmentUpdate { + _u.mutation.SetKeyword(v) + return _u } // SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (du *DepartmentUpdate) SetNillableKeyword(s *string) *DepartmentUpdate { - if s != nil { - du.SetKeyword(*s) +func (_u *DepartmentUpdate) SetNillableKeyword(v *string) *DepartmentUpdate { + if v != nil { + _u.SetKeyword(*v) } - return du + return _u } // SetName sets the "name" field. -func (du *DepartmentUpdate) SetName(s string) *DepartmentUpdate { - du.mutation.SetName(s) - return du +func (_u *DepartmentUpdate) SetName(v string) *DepartmentUpdate { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (du *DepartmentUpdate) SetNillableName(s *string) *DepartmentUpdate { - if s != nil { - du.SetName(*s) +func (_u *DepartmentUpdate) SetNillableName(v *string) *DepartmentUpdate { + if v != nil { + _u.SetName(*v) } - return du + return _u } // SetTreePath sets the "tree_path" field. -func (du *DepartmentUpdate) SetTreePath(s string) *DepartmentUpdate { - du.mutation.SetTreePath(s) - return du +func (_u *DepartmentUpdate) SetTreePath(v string) *DepartmentUpdate { + _u.mutation.SetTreePath(v) + return _u } // SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (du *DepartmentUpdate) SetNillableTreePath(s *string) *DepartmentUpdate { - if s != nil { - du.SetTreePath(*s) +func (_u *DepartmentUpdate) SetNillableTreePath(v *string) *DepartmentUpdate { + if v != nil { + _u.SetTreePath(*v) } - return du + return _u } // SetSequence sets the "sequence" field. -func (du *DepartmentUpdate) SetSequence(i int) *DepartmentUpdate { - du.mutation.ResetSequence() - du.mutation.SetSequence(i) - return du +func (_u *DepartmentUpdate) SetSequence(v int) *DepartmentUpdate { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u } // SetNillableSequence sets the "sequence" field if the given value is not nil. -func (du *DepartmentUpdate) SetNillableSequence(i *int) *DepartmentUpdate { - if i != nil { - du.SetSequence(*i) +func (_u *DepartmentUpdate) SetNillableSequence(v *int) *DepartmentUpdate { + if v != nil { + _u.SetSequence(*v) } - return du + return _u } -// AddSequence adds i to the "sequence" field. -func (du *DepartmentUpdate) AddSequence(i int) *DepartmentUpdate { - du.mutation.AddSequence(i) - return du +// AddSequence adds value to the "sequence" field. +func (_u *DepartmentUpdate) AddSequence(v int) *DepartmentUpdate { + _u.mutation.AddSequence(v) + return _u } // SetStatus sets the "status" field. -func (du *DepartmentUpdate) SetStatus(i int8) *DepartmentUpdate { - du.mutation.ResetStatus() - du.mutation.SetStatus(i) - return du +func (_u *DepartmentUpdate) SetStatus(v int8) *DepartmentUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (du *DepartmentUpdate) SetNillableStatus(i *int8) *DepartmentUpdate { - if i != nil { - du.SetStatus(*i) +func (_u *DepartmentUpdate) SetNillableStatus(v *int8) *DepartmentUpdate { + if v != nil { + _u.SetStatus(*v) } - return du + return _u } -// AddStatus adds i to the "status" field. -func (du *DepartmentUpdate) AddStatus(i int8) *DepartmentUpdate { - du.mutation.AddStatus(i) - return du +// AddStatus adds value to the "status" field. +func (_u *DepartmentUpdate) AddStatus(v int8) *DepartmentUpdate { + _u.mutation.AddStatus(v) + return _u } // SetLevel sets the "level" field. -func (du *DepartmentUpdate) SetLevel(i int) *DepartmentUpdate { - du.mutation.ResetLevel() - du.mutation.SetLevel(i) - return du +func (_u *DepartmentUpdate) SetLevel(v int) *DepartmentUpdate { + _u.mutation.ResetLevel() + _u.mutation.SetLevel(v) + return _u } // SetNillableLevel sets the "level" field if the given value is not nil. -func (du *DepartmentUpdate) SetNillableLevel(i *int) *DepartmentUpdate { - if i != nil { - du.SetLevel(*i) +func (_u *DepartmentUpdate) SetNillableLevel(v *int) *DepartmentUpdate { + if v != nil { + _u.SetLevel(*v) } - return du + return _u } -// AddLevel adds i to the "level" field. -func (du *DepartmentUpdate) AddLevel(i int) *DepartmentUpdate { - du.mutation.AddLevel(i) - return du +// AddLevel adds value to the "level" field. +func (_u *DepartmentUpdate) AddLevel(v int) *DepartmentUpdate { + _u.mutation.AddLevel(v) + return _u } // SetDescription sets the "description" field. -func (du *DepartmentUpdate) SetDescription(s string) *DepartmentUpdate { - du.mutation.SetDescription(s) - return du +func (_u *DepartmentUpdate) SetDescription(v string) *DepartmentUpdate { + _u.mutation.SetDescription(v) + return _u } // SetNillableDescription sets the "description" field if the given value is not nil. -func (du *DepartmentUpdate) SetNillableDescription(s *string) *DepartmentUpdate { - if s != nil { - du.SetDescription(*s) +func (_u *DepartmentUpdate) SetNillableDescription(v *string) *DepartmentUpdate { + if v != nil { + _u.SetDescription(*v) } - return du + return _u } // SetParentID sets the "parent_id" field. -func (du *DepartmentUpdate) SetParentID(i int64) *DepartmentUpdate { - du.mutation.SetParentID(i) - return du +func (_u *DepartmentUpdate) SetParentID(v int64) *DepartmentUpdate { + _u.mutation.SetParentID(v) + return _u } // SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (du *DepartmentUpdate) SetNillableParentID(i *int64) *DepartmentUpdate { - if i != nil { - du.SetParentID(*i) +func (_u *DepartmentUpdate) SetNillableParentID(v *int64) *DepartmentUpdate { + if v != nil { + _u.SetParentID(*v) } - return du + return _u } // ClearParentID clears the value of the "parent_id" field. -func (du *DepartmentUpdate) ClearParentID() *DepartmentUpdate { - du.mutation.ClearParentID() - return du +func (_u *DepartmentUpdate) ClearParentID() *DepartmentUpdate { + _u.mutation.ClearParentID() + return _u } // AddUserIDs adds the "users" edge to the User entity by IDs. -func (du *DepartmentUpdate) AddUserIDs(ids ...int64) *DepartmentUpdate { - du.mutation.AddUserIDs(ids...) - return du +func (_u *DepartmentUpdate) AddUserIDs(ids ...int64) *DepartmentUpdate { + _u.mutation.AddUserIDs(ids...) + return _u } // AddUsers adds the "users" edges to the User entity. -func (du *DepartmentUpdate) AddUsers(u ...*User) *DepartmentUpdate { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *DepartmentUpdate) AddUsers(v ...*User) *DepartmentUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return du.AddUserIDs(ids...) + return _u.AddUserIDs(ids...) } // AddPositionIDs adds the "positions" edge to the Position entity by IDs. -func (du *DepartmentUpdate) AddPositionIDs(ids ...int64) *DepartmentUpdate { - du.mutation.AddPositionIDs(ids...) - return du +func (_u *DepartmentUpdate) AddPositionIDs(ids ...int64) *DepartmentUpdate { + _u.mutation.AddPositionIDs(ids...) + return _u } // AddPositions adds the "positions" edges to the Position entity. -func (du *DepartmentUpdate) AddPositions(p ...*Position) *DepartmentUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *DepartmentUpdate) AddPositions(v ...*Position) *DepartmentUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return du.AddPositionIDs(ids...) + return _u.AddPositionIDs(ids...) } // SetParent sets the "parent" edge to the Department entity. -func (du *DepartmentUpdate) SetParent(d *Department) *DepartmentUpdate { - return du.SetParentID(d.ID) +func (_u *DepartmentUpdate) SetParent(v *Department) *DepartmentUpdate { + return _u.SetParentID(v.ID) } // AddChildIDs adds the "children" edge to the Department entity by IDs. -func (du *DepartmentUpdate) AddChildIDs(ids ...int64) *DepartmentUpdate { - du.mutation.AddChildIDs(ids...) - return du +func (_u *DepartmentUpdate) AddChildIDs(ids ...int64) *DepartmentUpdate { + _u.mutation.AddChildIDs(ids...) + return _u } // AddChildren adds the "children" edges to the Department entity. -func (du *DepartmentUpdate) AddChildren(d ...*Department) *DepartmentUpdate { - ids := make([]int64, len(d)) - for i := range d { - ids[i] = d[i].ID +func (_u *DepartmentUpdate) AddChildren(v ...*Department) *DepartmentUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return du.AddChildIDs(ids...) + return _u.AddChildIDs(ids...) } // AddUserDepartmentIDs adds the "user_departments" edge to the UserDepartment entity by IDs. -func (du *DepartmentUpdate) AddUserDepartmentIDs(ids ...int) *DepartmentUpdate { - du.mutation.AddUserDepartmentIDs(ids...) - return du +func (_u *DepartmentUpdate) AddUserDepartmentIDs(ids ...int) *DepartmentUpdate { + _u.mutation.AddUserDepartmentIDs(ids...) + return _u } // AddUserDepartments adds the "user_departments" edges to the UserDepartment entity. -func (du *DepartmentUpdate) AddUserDepartments(u ...*UserDepartment) *DepartmentUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *DepartmentUpdate) AddUserDepartments(v ...*UserDepartment) *DepartmentUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return du.AddUserDepartmentIDs(ids...) + return _u.AddUserDepartmentIDs(ids...) } // Mutation returns the DepartmentMutation object of the builder. -func (du *DepartmentUpdate) Mutation() *DepartmentMutation { - return du.mutation +func (_u *DepartmentUpdate) Mutation() *DepartmentMutation { + return _u.mutation } // ClearUsers clears all "users" edges to the User entity. -func (du *DepartmentUpdate) ClearUsers() *DepartmentUpdate { - du.mutation.ClearUsers() - return du +func (_u *DepartmentUpdate) ClearUsers() *DepartmentUpdate { + _u.mutation.ClearUsers() + return _u } // RemoveUserIDs removes the "users" edge to User entities by IDs. -func (du *DepartmentUpdate) RemoveUserIDs(ids ...int64) *DepartmentUpdate { - du.mutation.RemoveUserIDs(ids...) - return du +func (_u *DepartmentUpdate) RemoveUserIDs(ids ...int64) *DepartmentUpdate { + _u.mutation.RemoveUserIDs(ids...) + return _u } // RemoveUsers removes "users" edges to User entities. -func (du *DepartmentUpdate) RemoveUsers(u ...*User) *DepartmentUpdate { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *DepartmentUpdate) RemoveUsers(v ...*User) *DepartmentUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return du.RemoveUserIDs(ids...) + return _u.RemoveUserIDs(ids...) } // ClearPositions clears all "positions" edges to the Position entity. -func (du *DepartmentUpdate) ClearPositions() *DepartmentUpdate { - du.mutation.ClearPositions() - return du +func (_u *DepartmentUpdate) ClearPositions() *DepartmentUpdate { + _u.mutation.ClearPositions() + return _u } // RemovePositionIDs removes the "positions" edge to Position entities by IDs. -func (du *DepartmentUpdate) RemovePositionIDs(ids ...int64) *DepartmentUpdate { - du.mutation.RemovePositionIDs(ids...) - return du +func (_u *DepartmentUpdate) RemovePositionIDs(ids ...int64) *DepartmentUpdate { + _u.mutation.RemovePositionIDs(ids...) + return _u } // RemovePositions removes "positions" edges to Position entities. -func (du *DepartmentUpdate) RemovePositions(p ...*Position) *DepartmentUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *DepartmentUpdate) RemovePositions(v ...*Position) *DepartmentUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return du.RemovePositionIDs(ids...) + return _u.RemovePositionIDs(ids...) } // ClearParent clears the "parent" edge to the Department entity. -func (du *DepartmentUpdate) ClearParent() *DepartmentUpdate { - du.mutation.ClearParent() - return du +func (_u *DepartmentUpdate) ClearParent() *DepartmentUpdate { + _u.mutation.ClearParent() + return _u } // ClearChildren clears all "children" edges to the Department entity. -func (du *DepartmentUpdate) ClearChildren() *DepartmentUpdate { - du.mutation.ClearChildren() - return du +func (_u *DepartmentUpdate) ClearChildren() *DepartmentUpdate { + _u.mutation.ClearChildren() + return _u } // RemoveChildIDs removes the "children" edge to Department entities by IDs. -func (du *DepartmentUpdate) RemoveChildIDs(ids ...int64) *DepartmentUpdate { - du.mutation.RemoveChildIDs(ids...) - return du +func (_u *DepartmentUpdate) RemoveChildIDs(ids ...int64) *DepartmentUpdate { + _u.mutation.RemoveChildIDs(ids...) + return _u } // RemoveChildren removes "children" edges to Department entities. -func (du *DepartmentUpdate) RemoveChildren(d ...*Department) *DepartmentUpdate { - ids := make([]int64, len(d)) - for i := range d { - ids[i] = d[i].ID +func (_u *DepartmentUpdate) RemoveChildren(v ...*Department) *DepartmentUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return du.RemoveChildIDs(ids...) + return _u.RemoveChildIDs(ids...) } // ClearUserDepartments clears all "user_departments" edges to the UserDepartment entity. -func (du *DepartmentUpdate) ClearUserDepartments() *DepartmentUpdate { - du.mutation.ClearUserDepartments() - return du +func (_u *DepartmentUpdate) ClearUserDepartments() *DepartmentUpdate { + _u.mutation.ClearUserDepartments() + return _u } // RemoveUserDepartmentIDs removes the "user_departments" edge to UserDepartment entities by IDs. -func (du *DepartmentUpdate) RemoveUserDepartmentIDs(ids ...int) *DepartmentUpdate { - du.mutation.RemoveUserDepartmentIDs(ids...) - return du +func (_u *DepartmentUpdate) RemoveUserDepartmentIDs(ids ...int) *DepartmentUpdate { + _u.mutation.RemoveUserDepartmentIDs(ids...) + return _u } // RemoveUserDepartments removes "user_departments" edges to UserDepartment entities. -func (du *DepartmentUpdate) RemoveUserDepartments(u ...*UserDepartment) *DepartmentUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *DepartmentUpdate) RemoveUserDepartments(v ...*UserDepartment) *DepartmentUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return du.RemoveUserDepartmentIDs(ids...) + return _u.RemoveUserDepartmentIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. -func (du *DepartmentUpdate) Save(ctx context.Context) (int, error) { - du.defaults() - return withHooks(ctx, du.sqlSave, du.mutation, du.hooks) +func (_u *DepartmentUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (du *DepartmentUpdate) SaveX(ctx context.Context) int { - affected, err := du.Save(ctx) +func (_u *DepartmentUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -353,49 +353,49 @@ func (du *DepartmentUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (du *DepartmentUpdate) Exec(ctx context.Context) error { - _, err := du.Save(ctx) +func (_u *DepartmentUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (du *DepartmentUpdate) ExecX(ctx context.Context) { - if err := du.Exec(ctx); err != nil { +func (_u *DepartmentUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (du *DepartmentUpdate) defaults() { - if _, ok := du.mutation.UpdateTime(); !ok { +func (_u *DepartmentUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := department.UpdateDefaultUpdateTime() - du.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (du *DepartmentUpdate) check() error { - if v, ok := du.mutation.Keyword(); ok { +func (_u *DepartmentUpdate) check() error { + if v, ok := _u.mutation.Keyword(); ok { if err := department.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Department.keyword": %w`, err)} } } - if v, ok := du.mutation.Name(); ok { + if v, ok := _u.mutation.Name(); ok { if err := department.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Department.name": %w`, err)} } } - if v, ok := du.mutation.TreePath(); ok { + if v, ok := _u.mutation.TreePath(); ok { if err := department.TreePathValidator(v); err != nil { return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Department.tree_path": %w`, err)} } } - if v, ok := du.mutation.Description(); ok { + if v, ok := _u.mutation.Description(); ok { if err := department.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Department.description": %w`, err)} } } - if v, ok := du.mutation.ParentID(); ok { + if v, ok := _u.mutation.ParentID(); ok { if err := department.ParentIDValidator(v); err != nil { return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Department.parent_id": %w`, err)} } @@ -404,57 +404,57 @@ func (du *DepartmentUpdate) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (du *DepartmentUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *DepartmentUpdate { - du.modifiers = append(du.modifiers, modifiers...) - return du +func (_u *DepartmentUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *DepartmentUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := du.check(); err != nil { - return n, err +func (_u *DepartmentUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(department.Table, department.Columns, sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64)) - if ps := du.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := du.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(department.FieldUpdateTime, field.TypeTime, value) } - if value, ok := du.mutation.Keyword(); ok { + if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(department.FieldKeyword, field.TypeString, value) } - if value, ok := du.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(department.FieldName, field.TypeString, value) } - if value, ok := du.mutation.TreePath(); ok { + if value, ok := _u.mutation.TreePath(); ok { _spec.SetField(department.FieldTreePath, field.TypeString, value) } - if value, ok := du.mutation.Sequence(); ok { + if value, ok := _u.mutation.Sequence(); ok { _spec.SetField(department.FieldSequence, field.TypeInt, value) } - if value, ok := du.mutation.AddedSequence(); ok { + if value, ok := _u.mutation.AddedSequence(); ok { _spec.AddField(department.FieldSequence, field.TypeInt, value) } - if value, ok := du.mutation.Status(); ok { + if value, ok := _u.mutation.Status(); ok { _spec.SetField(department.FieldStatus, field.TypeInt8, value) } - if value, ok := du.mutation.AddedStatus(); ok { + if value, ok := _u.mutation.AddedStatus(); ok { _spec.AddField(department.FieldStatus, field.TypeInt8, value) } - if value, ok := du.mutation.Level(); ok { + if value, ok := _u.mutation.Level(); ok { _spec.SetField(department.FieldLevel, field.TypeInt, value) } - if value, ok := du.mutation.AddedLevel(); ok { + if value, ok := _u.mutation.AddedLevel(); ok { _spec.AddField(department.FieldLevel, field.TypeInt, value) } - if value, ok := du.mutation.Description(); ok { + if value, ok := _u.mutation.Description(); ok { _spec.SetField(department.FieldDescription, field.TypeString, value) } - if du.mutation.UsersCleared() { + if _u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -467,7 +467,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := du.mutation.RemovedUsersIDs(); len(nodes) > 0 && !du.mutation.UsersCleared() { + if nodes := _u.mutation.RemovedUsersIDs(); len(nodes) > 0 && !_u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -483,7 +483,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := du.mutation.UsersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UsersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -499,7 +499,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if du.mutation.PositionsCleared() { + if _u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -512,7 +512,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := du.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !du.mutation.PositionsCleared() { + if nodes := _u.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !_u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -528,7 +528,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := du.mutation.PositionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -544,7 +544,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if du.mutation.ParentCleared() { + if _u.mutation.ParentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -557,7 +557,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := du.mutation.ParentIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -573,7 +573,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if du.mutation.ChildrenCleared() { + if _u.mutation.ChildrenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -586,7 +586,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := du.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !du.mutation.ChildrenCleared() { + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -602,7 +602,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := du.mutation.ChildrenIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -618,7 +618,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if du.mutation.UserDepartmentsCleared() { + if _u.mutation.UserDepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -631,7 +631,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := du.mutation.RemovedUserDepartmentsIDs(); len(nodes) > 0 && !du.mutation.UserDepartmentsCleared() { + if nodes := _u.mutation.RemovedUserDepartmentsIDs(); len(nodes) > 0 && !_u.mutation.UserDepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -647,7 +647,7 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := du.mutation.UserDepartmentsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserDepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -663,8 +663,8 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(du.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, du.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{department.Label} } else if sqlgraph.IsConstraintError(err) { @@ -672,8 +672,8 @@ func (du *DepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - du.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // DepartmentUpdateOne is the builder for updating a single Department entity. @@ -686,332 +686,332 @@ type DepartmentUpdateOne struct { } // SetUpdateTime sets the "update_time" field. -func (duo *DepartmentUpdateOne) SetUpdateTime(t time.Time) *DepartmentUpdateOne { - duo.mutation.SetUpdateTime(t) - return duo +func (_u *DepartmentUpdateOne) SetUpdateTime(v time.Time) *DepartmentUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u } // SetKeyword sets the "keyword" field. -func (duo *DepartmentUpdateOne) SetKeyword(s string) *DepartmentUpdateOne { - duo.mutation.SetKeyword(s) - return duo +func (_u *DepartmentUpdateOne) SetKeyword(v string) *DepartmentUpdateOne { + _u.mutation.SetKeyword(v) + return _u } // SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (duo *DepartmentUpdateOne) SetNillableKeyword(s *string) *DepartmentUpdateOne { - if s != nil { - duo.SetKeyword(*s) +func (_u *DepartmentUpdateOne) SetNillableKeyword(v *string) *DepartmentUpdateOne { + if v != nil { + _u.SetKeyword(*v) } - return duo + return _u } // SetName sets the "name" field. -func (duo *DepartmentUpdateOne) SetName(s string) *DepartmentUpdateOne { - duo.mutation.SetName(s) - return duo +func (_u *DepartmentUpdateOne) SetName(v string) *DepartmentUpdateOne { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (duo *DepartmentUpdateOne) SetNillableName(s *string) *DepartmentUpdateOne { - if s != nil { - duo.SetName(*s) +func (_u *DepartmentUpdateOne) SetNillableName(v *string) *DepartmentUpdateOne { + if v != nil { + _u.SetName(*v) } - return duo + return _u } // SetTreePath sets the "tree_path" field. -func (duo *DepartmentUpdateOne) SetTreePath(s string) *DepartmentUpdateOne { - duo.mutation.SetTreePath(s) - return duo +func (_u *DepartmentUpdateOne) SetTreePath(v string) *DepartmentUpdateOne { + _u.mutation.SetTreePath(v) + return _u } // SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (duo *DepartmentUpdateOne) SetNillableTreePath(s *string) *DepartmentUpdateOne { - if s != nil { - duo.SetTreePath(*s) +func (_u *DepartmentUpdateOne) SetNillableTreePath(v *string) *DepartmentUpdateOne { + if v != nil { + _u.SetTreePath(*v) } - return duo + return _u } // SetSequence sets the "sequence" field. -func (duo *DepartmentUpdateOne) SetSequence(i int) *DepartmentUpdateOne { - duo.mutation.ResetSequence() - duo.mutation.SetSequence(i) - return duo +func (_u *DepartmentUpdateOne) SetSequence(v int) *DepartmentUpdateOne { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u } // SetNillableSequence sets the "sequence" field if the given value is not nil. -func (duo *DepartmentUpdateOne) SetNillableSequence(i *int) *DepartmentUpdateOne { - if i != nil { - duo.SetSequence(*i) +func (_u *DepartmentUpdateOne) SetNillableSequence(v *int) *DepartmentUpdateOne { + if v != nil { + _u.SetSequence(*v) } - return duo + return _u } -// AddSequence adds i to the "sequence" field. -func (duo *DepartmentUpdateOne) AddSequence(i int) *DepartmentUpdateOne { - duo.mutation.AddSequence(i) - return duo +// AddSequence adds value to the "sequence" field. +func (_u *DepartmentUpdateOne) AddSequence(v int) *DepartmentUpdateOne { + _u.mutation.AddSequence(v) + return _u } // SetStatus sets the "status" field. -func (duo *DepartmentUpdateOne) SetStatus(i int8) *DepartmentUpdateOne { - duo.mutation.ResetStatus() - duo.mutation.SetStatus(i) - return duo +func (_u *DepartmentUpdateOne) SetStatus(v int8) *DepartmentUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (duo *DepartmentUpdateOne) SetNillableStatus(i *int8) *DepartmentUpdateOne { - if i != nil { - duo.SetStatus(*i) +func (_u *DepartmentUpdateOne) SetNillableStatus(v *int8) *DepartmentUpdateOne { + if v != nil { + _u.SetStatus(*v) } - return duo + return _u } -// AddStatus adds i to the "status" field. -func (duo *DepartmentUpdateOne) AddStatus(i int8) *DepartmentUpdateOne { - duo.mutation.AddStatus(i) - return duo +// AddStatus adds value to the "status" field. +func (_u *DepartmentUpdateOne) AddStatus(v int8) *DepartmentUpdateOne { + _u.mutation.AddStatus(v) + return _u } // SetLevel sets the "level" field. -func (duo *DepartmentUpdateOne) SetLevel(i int) *DepartmentUpdateOne { - duo.mutation.ResetLevel() - duo.mutation.SetLevel(i) - return duo +func (_u *DepartmentUpdateOne) SetLevel(v int) *DepartmentUpdateOne { + _u.mutation.ResetLevel() + _u.mutation.SetLevel(v) + return _u } // SetNillableLevel sets the "level" field if the given value is not nil. -func (duo *DepartmentUpdateOne) SetNillableLevel(i *int) *DepartmentUpdateOne { - if i != nil { - duo.SetLevel(*i) +func (_u *DepartmentUpdateOne) SetNillableLevel(v *int) *DepartmentUpdateOne { + if v != nil { + _u.SetLevel(*v) } - return duo + return _u } -// AddLevel adds i to the "level" field. -func (duo *DepartmentUpdateOne) AddLevel(i int) *DepartmentUpdateOne { - duo.mutation.AddLevel(i) - return duo +// AddLevel adds value to the "level" field. +func (_u *DepartmentUpdateOne) AddLevel(v int) *DepartmentUpdateOne { + _u.mutation.AddLevel(v) + return _u } // SetDescription sets the "description" field. -func (duo *DepartmentUpdateOne) SetDescription(s string) *DepartmentUpdateOne { - duo.mutation.SetDescription(s) - return duo +func (_u *DepartmentUpdateOne) SetDescription(v string) *DepartmentUpdateOne { + _u.mutation.SetDescription(v) + return _u } // SetNillableDescription sets the "description" field if the given value is not nil. -func (duo *DepartmentUpdateOne) SetNillableDescription(s *string) *DepartmentUpdateOne { - if s != nil { - duo.SetDescription(*s) +func (_u *DepartmentUpdateOne) SetNillableDescription(v *string) *DepartmentUpdateOne { + if v != nil { + _u.SetDescription(*v) } - return duo + return _u } // SetParentID sets the "parent_id" field. -func (duo *DepartmentUpdateOne) SetParentID(i int64) *DepartmentUpdateOne { - duo.mutation.SetParentID(i) - return duo +func (_u *DepartmentUpdateOne) SetParentID(v int64) *DepartmentUpdateOne { + _u.mutation.SetParentID(v) + return _u } // SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (duo *DepartmentUpdateOne) SetNillableParentID(i *int64) *DepartmentUpdateOne { - if i != nil { - duo.SetParentID(*i) +func (_u *DepartmentUpdateOne) SetNillableParentID(v *int64) *DepartmentUpdateOne { + if v != nil { + _u.SetParentID(*v) } - return duo + return _u } // ClearParentID clears the value of the "parent_id" field. -func (duo *DepartmentUpdateOne) ClearParentID() *DepartmentUpdateOne { - duo.mutation.ClearParentID() - return duo +func (_u *DepartmentUpdateOne) ClearParentID() *DepartmentUpdateOne { + _u.mutation.ClearParentID() + return _u } // AddUserIDs adds the "users" edge to the User entity by IDs. -func (duo *DepartmentUpdateOne) AddUserIDs(ids ...int64) *DepartmentUpdateOne { - duo.mutation.AddUserIDs(ids...) - return duo +func (_u *DepartmentUpdateOne) AddUserIDs(ids ...int64) *DepartmentUpdateOne { + _u.mutation.AddUserIDs(ids...) + return _u } // AddUsers adds the "users" edges to the User entity. -func (duo *DepartmentUpdateOne) AddUsers(u ...*User) *DepartmentUpdateOne { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *DepartmentUpdateOne) AddUsers(v ...*User) *DepartmentUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return duo.AddUserIDs(ids...) + return _u.AddUserIDs(ids...) } // AddPositionIDs adds the "positions" edge to the Position entity by IDs. -func (duo *DepartmentUpdateOne) AddPositionIDs(ids ...int64) *DepartmentUpdateOne { - duo.mutation.AddPositionIDs(ids...) - return duo +func (_u *DepartmentUpdateOne) AddPositionIDs(ids ...int64) *DepartmentUpdateOne { + _u.mutation.AddPositionIDs(ids...) + return _u } // AddPositions adds the "positions" edges to the Position entity. -func (duo *DepartmentUpdateOne) AddPositions(p ...*Position) *DepartmentUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *DepartmentUpdateOne) AddPositions(v ...*Position) *DepartmentUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return duo.AddPositionIDs(ids...) + return _u.AddPositionIDs(ids...) } // SetParent sets the "parent" edge to the Department entity. -func (duo *DepartmentUpdateOne) SetParent(d *Department) *DepartmentUpdateOne { - return duo.SetParentID(d.ID) +func (_u *DepartmentUpdateOne) SetParent(v *Department) *DepartmentUpdateOne { + return _u.SetParentID(v.ID) } // AddChildIDs adds the "children" edge to the Department entity by IDs. -func (duo *DepartmentUpdateOne) AddChildIDs(ids ...int64) *DepartmentUpdateOne { - duo.mutation.AddChildIDs(ids...) - return duo +func (_u *DepartmentUpdateOne) AddChildIDs(ids ...int64) *DepartmentUpdateOne { + _u.mutation.AddChildIDs(ids...) + return _u } // AddChildren adds the "children" edges to the Department entity. -func (duo *DepartmentUpdateOne) AddChildren(d ...*Department) *DepartmentUpdateOne { - ids := make([]int64, len(d)) - for i := range d { - ids[i] = d[i].ID +func (_u *DepartmentUpdateOne) AddChildren(v ...*Department) *DepartmentUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return duo.AddChildIDs(ids...) + return _u.AddChildIDs(ids...) } // AddUserDepartmentIDs adds the "user_departments" edge to the UserDepartment entity by IDs. -func (duo *DepartmentUpdateOne) AddUserDepartmentIDs(ids ...int) *DepartmentUpdateOne { - duo.mutation.AddUserDepartmentIDs(ids...) - return duo +func (_u *DepartmentUpdateOne) AddUserDepartmentIDs(ids ...int) *DepartmentUpdateOne { + _u.mutation.AddUserDepartmentIDs(ids...) + return _u } // AddUserDepartments adds the "user_departments" edges to the UserDepartment entity. -func (duo *DepartmentUpdateOne) AddUserDepartments(u ...*UserDepartment) *DepartmentUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *DepartmentUpdateOne) AddUserDepartments(v ...*UserDepartment) *DepartmentUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return duo.AddUserDepartmentIDs(ids...) + return _u.AddUserDepartmentIDs(ids...) } // Mutation returns the DepartmentMutation object of the builder. -func (duo *DepartmentUpdateOne) Mutation() *DepartmentMutation { - return duo.mutation +func (_u *DepartmentUpdateOne) Mutation() *DepartmentMutation { + return _u.mutation } // ClearUsers clears all "users" edges to the User entity. -func (duo *DepartmentUpdateOne) ClearUsers() *DepartmentUpdateOne { - duo.mutation.ClearUsers() - return duo +func (_u *DepartmentUpdateOne) ClearUsers() *DepartmentUpdateOne { + _u.mutation.ClearUsers() + return _u } // RemoveUserIDs removes the "users" edge to User entities by IDs. -func (duo *DepartmentUpdateOne) RemoveUserIDs(ids ...int64) *DepartmentUpdateOne { - duo.mutation.RemoveUserIDs(ids...) - return duo +func (_u *DepartmentUpdateOne) RemoveUserIDs(ids ...int64) *DepartmentUpdateOne { + _u.mutation.RemoveUserIDs(ids...) + return _u } // RemoveUsers removes "users" edges to User entities. -func (duo *DepartmentUpdateOne) RemoveUsers(u ...*User) *DepartmentUpdateOne { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *DepartmentUpdateOne) RemoveUsers(v ...*User) *DepartmentUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return duo.RemoveUserIDs(ids...) + return _u.RemoveUserIDs(ids...) } // ClearPositions clears all "positions" edges to the Position entity. -func (duo *DepartmentUpdateOne) ClearPositions() *DepartmentUpdateOne { - duo.mutation.ClearPositions() - return duo +func (_u *DepartmentUpdateOne) ClearPositions() *DepartmentUpdateOne { + _u.mutation.ClearPositions() + return _u } // RemovePositionIDs removes the "positions" edge to Position entities by IDs. -func (duo *DepartmentUpdateOne) RemovePositionIDs(ids ...int64) *DepartmentUpdateOne { - duo.mutation.RemovePositionIDs(ids...) - return duo +func (_u *DepartmentUpdateOne) RemovePositionIDs(ids ...int64) *DepartmentUpdateOne { + _u.mutation.RemovePositionIDs(ids...) + return _u } // RemovePositions removes "positions" edges to Position entities. -func (duo *DepartmentUpdateOne) RemovePositions(p ...*Position) *DepartmentUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *DepartmentUpdateOne) RemovePositions(v ...*Position) *DepartmentUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return duo.RemovePositionIDs(ids...) + return _u.RemovePositionIDs(ids...) } // ClearParent clears the "parent" edge to the Department entity. -func (duo *DepartmentUpdateOne) ClearParent() *DepartmentUpdateOne { - duo.mutation.ClearParent() - return duo +func (_u *DepartmentUpdateOne) ClearParent() *DepartmentUpdateOne { + _u.mutation.ClearParent() + return _u } // ClearChildren clears all "children" edges to the Department entity. -func (duo *DepartmentUpdateOne) ClearChildren() *DepartmentUpdateOne { - duo.mutation.ClearChildren() - return duo +func (_u *DepartmentUpdateOne) ClearChildren() *DepartmentUpdateOne { + _u.mutation.ClearChildren() + return _u } // RemoveChildIDs removes the "children" edge to Department entities by IDs. -func (duo *DepartmentUpdateOne) RemoveChildIDs(ids ...int64) *DepartmentUpdateOne { - duo.mutation.RemoveChildIDs(ids...) - return duo +func (_u *DepartmentUpdateOne) RemoveChildIDs(ids ...int64) *DepartmentUpdateOne { + _u.mutation.RemoveChildIDs(ids...) + return _u } // RemoveChildren removes "children" edges to Department entities. -func (duo *DepartmentUpdateOne) RemoveChildren(d ...*Department) *DepartmentUpdateOne { - ids := make([]int64, len(d)) - for i := range d { - ids[i] = d[i].ID +func (_u *DepartmentUpdateOne) RemoveChildren(v ...*Department) *DepartmentUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return duo.RemoveChildIDs(ids...) + return _u.RemoveChildIDs(ids...) } // ClearUserDepartments clears all "user_departments" edges to the UserDepartment entity. -func (duo *DepartmentUpdateOne) ClearUserDepartments() *DepartmentUpdateOne { - duo.mutation.ClearUserDepartments() - return duo +func (_u *DepartmentUpdateOne) ClearUserDepartments() *DepartmentUpdateOne { + _u.mutation.ClearUserDepartments() + return _u } // RemoveUserDepartmentIDs removes the "user_departments" edge to UserDepartment entities by IDs. -func (duo *DepartmentUpdateOne) RemoveUserDepartmentIDs(ids ...int) *DepartmentUpdateOne { - duo.mutation.RemoveUserDepartmentIDs(ids...) - return duo +func (_u *DepartmentUpdateOne) RemoveUserDepartmentIDs(ids ...int) *DepartmentUpdateOne { + _u.mutation.RemoveUserDepartmentIDs(ids...) + return _u } // RemoveUserDepartments removes "user_departments" edges to UserDepartment entities. -func (duo *DepartmentUpdateOne) RemoveUserDepartments(u ...*UserDepartment) *DepartmentUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *DepartmentUpdateOne) RemoveUserDepartments(v ...*UserDepartment) *DepartmentUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return duo.RemoveUserDepartmentIDs(ids...) + return _u.RemoveUserDepartmentIDs(ids...) } // Where appends a list predicates to the DepartmentUpdate builder. -func (duo *DepartmentUpdateOne) Where(ps ...predicate.Department) *DepartmentUpdateOne { - duo.mutation.Where(ps...) - return duo +func (_u *DepartmentUpdateOne) Where(ps ...predicate.Department) *DepartmentUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (duo *DepartmentUpdateOne) Select(field string, fields ...string) *DepartmentUpdateOne { - duo.fields = append([]string{field}, fields...) - return duo +func (_u *DepartmentUpdateOne) Select(field string, fields ...string) *DepartmentUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Department entity. -func (duo *DepartmentUpdateOne) Save(ctx context.Context) (*Department, error) { - duo.defaults() - return withHooks(ctx, duo.sqlSave, duo.mutation, duo.hooks) +func (_u *DepartmentUpdateOne) Save(ctx context.Context) (*Department, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (duo *DepartmentUpdateOne) SaveX(ctx context.Context) *Department { - node, err := duo.Save(ctx) +func (_u *DepartmentUpdateOne) SaveX(ctx context.Context) *Department { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -1019,49 +1019,49 @@ func (duo *DepartmentUpdateOne) SaveX(ctx context.Context) *Department { } // Exec executes the query on the entity. -func (duo *DepartmentUpdateOne) Exec(ctx context.Context) error { - _, err := duo.Save(ctx) +func (_u *DepartmentUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (duo *DepartmentUpdateOne) ExecX(ctx context.Context) { - if err := duo.Exec(ctx); err != nil { +func (_u *DepartmentUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (duo *DepartmentUpdateOne) defaults() { - if _, ok := duo.mutation.UpdateTime(); !ok { +func (_u *DepartmentUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := department.UpdateDefaultUpdateTime() - duo.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (duo *DepartmentUpdateOne) check() error { - if v, ok := duo.mutation.Keyword(); ok { +func (_u *DepartmentUpdateOne) check() error { + if v, ok := _u.mutation.Keyword(); ok { if err := department.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Department.keyword": %w`, err)} } } - if v, ok := duo.mutation.Name(); ok { + if v, ok := _u.mutation.Name(); ok { if err := department.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Department.name": %w`, err)} } } - if v, ok := duo.mutation.TreePath(); ok { + if v, ok := _u.mutation.TreePath(); ok { if err := department.TreePathValidator(v); err != nil { return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Department.tree_path": %w`, err)} } } - if v, ok := duo.mutation.Description(); ok { + if v, ok := _u.mutation.Description(); ok { if err := department.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Department.description": %w`, err)} } } - if v, ok := duo.mutation.ParentID(); ok { + if v, ok := _u.mutation.ParentID(); ok { if err := department.ParentIDValidator(v); err != nil { return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Department.parent_id": %w`, err)} } @@ -1070,22 +1070,22 @@ func (duo *DepartmentUpdateOne) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (duo *DepartmentUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *DepartmentUpdateOne { - duo.modifiers = append(duo.modifiers, modifiers...) - return duo +func (_u *DepartmentUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *DepartmentUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, err error) { - if err := duo.check(); err != nil { +func (_u *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(department.Table, department.Columns, sqlgraph.NewFieldSpec(department.FieldID, field.TypeInt64)) - id, ok := duo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Department.id" for update`)} } _spec.Node.ID.Value = id - if fields := duo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, department.FieldID) for _, f := range fields { @@ -1097,47 +1097,47 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } } } - if ps := duo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := duo.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(department.FieldUpdateTime, field.TypeTime, value) } - if value, ok := duo.mutation.Keyword(); ok { + if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(department.FieldKeyword, field.TypeString, value) } - if value, ok := duo.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(department.FieldName, field.TypeString, value) } - if value, ok := duo.mutation.TreePath(); ok { + if value, ok := _u.mutation.TreePath(); ok { _spec.SetField(department.FieldTreePath, field.TypeString, value) } - if value, ok := duo.mutation.Sequence(); ok { + if value, ok := _u.mutation.Sequence(); ok { _spec.SetField(department.FieldSequence, field.TypeInt, value) } - if value, ok := duo.mutation.AddedSequence(); ok { + if value, ok := _u.mutation.AddedSequence(); ok { _spec.AddField(department.FieldSequence, field.TypeInt, value) } - if value, ok := duo.mutation.Status(); ok { + if value, ok := _u.mutation.Status(); ok { _spec.SetField(department.FieldStatus, field.TypeInt8, value) } - if value, ok := duo.mutation.AddedStatus(); ok { + if value, ok := _u.mutation.AddedStatus(); ok { _spec.AddField(department.FieldStatus, field.TypeInt8, value) } - if value, ok := duo.mutation.Level(); ok { + if value, ok := _u.mutation.Level(); ok { _spec.SetField(department.FieldLevel, field.TypeInt, value) } - if value, ok := duo.mutation.AddedLevel(); ok { + if value, ok := _u.mutation.AddedLevel(); ok { _spec.AddField(department.FieldLevel, field.TypeInt, value) } - if value, ok := duo.mutation.Description(); ok { + if value, ok := _u.mutation.Description(); ok { _spec.SetField(department.FieldDescription, field.TypeString, value) } - if duo.mutation.UsersCleared() { + if _u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1150,7 +1150,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := duo.mutation.RemovedUsersIDs(); len(nodes) > 0 && !duo.mutation.UsersCleared() { + if nodes := _u.mutation.RemovedUsersIDs(); len(nodes) > 0 && !_u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1166,7 +1166,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := duo.mutation.UsersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UsersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1182,7 +1182,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if duo.mutation.PositionsCleared() { + if _u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1195,7 +1195,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := duo.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !duo.mutation.PositionsCleared() { + if nodes := _u.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !_u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1211,7 +1211,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := duo.mutation.PositionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1227,7 +1227,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if duo.mutation.ParentCleared() { + if _u.mutation.ParentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -1240,7 +1240,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := duo.mutation.ParentIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -1256,7 +1256,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if duo.mutation.ChildrenCleared() { + if _u.mutation.ChildrenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1269,7 +1269,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := duo.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !duo.mutation.ChildrenCleared() { + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1285,7 +1285,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := duo.mutation.ChildrenIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1301,7 +1301,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if duo.mutation.UserDepartmentsCleared() { + if _u.mutation.UserDepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1314,7 +1314,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := duo.mutation.RemovedUserDepartmentsIDs(); len(nodes) > 0 && !duo.mutation.UserDepartmentsCleared() { + if nodes := _u.mutation.RemovedUserDepartmentsIDs(); len(nodes) > 0 && !_u.mutation.UserDepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1330,7 +1330,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := duo.mutation.UserDepartmentsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserDepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1346,11 +1346,11 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(duo.modifiers...) - _node = &Department{config: duo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Department{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, duo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{department.Label} } else if sqlgraph.IsConstraintError(err) { @@ -1358,7 +1358,7 @@ func (duo *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, } return nil, err } - duo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/ent.go b/internal/data/entity/ent/ent.go index af73f78b..ed679869 100644 --- a/internal/data/entity/ent/ent.go +++ b/internal/data/entity/ent/ent.go @@ -83,7 +83,7 @@ var ( ) // checkColumn checks if the column exists in the given table. -func checkColumn(table, column string) error { +func checkColumn(t, c string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ casbinrule.Table: casbinrule.ValidColumn, @@ -102,7 +102,7 @@ func checkColumn(table, column string) error { userrole.Table: userrole.ValidColumn, }) }) - return columnCheck(table, column) + return columnCheck(t, c) } // Asc applies the given fields in ASC order. diff --git a/internal/data/entity/ent/notification.go b/internal/data/entity/ent/notification.go index 3cc39350..3ba29436 100644 --- a/internal/data/entity/ent/notification.go +++ b/internal/data/entity/ent/notification.go @@ -57,7 +57,7 @@ func (*Notification) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Notification fields. -func (n *Notification) assignValues(columns []string, values []any) error { +func (_m *Notification) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -68,57 +68,57 @@ func (n *Notification) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - n.ID = int64(value.Int64) + _m.ID = int64(value.Int64) case notification.FieldCreateAuthor: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field create_author", values[i]) } else if value.Valid { - n.CreateAuthor = value.Int64 + _m.CreateAuthor = value.Int64 } case notification.FieldUpdateAuthor: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field update_author", values[i]) } else if value.Valid { - n.UpdateAuthor = value.Int64 + _m.UpdateAuthor = value.Int64 } case notification.FieldCreateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field create_time", values[i]) } else if value.Valid { - n.CreateTime = value.Time + _m.CreateTime = value.Time } case notification.FieldUpdateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field update_time", values[i]) } else if value.Valid { - n.UpdateTime = value.Time + _m.UpdateTime = value.Time } case notification.FieldSubject: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field subject", values[i]) } else if value.Valid { - n.Subject = value.String + _m.Subject = value.String } case notification.FieldContent: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field content", values[i]) } else if value.Valid { - n.Content = value.String + _m.Content = value.String } case notification.FieldStatus: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - n.Status = int8(value.Int64) + _m.Status = int8(value.Int64) } case notification.FieldCategoryID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field category_id", values[i]) } else if value.Valid { - n.CategoryID = value.Int64 + _m.CategoryID = value.Int64 } default: - n.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -126,56 +126,56 @@ func (n *Notification) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Notification. // This includes values selected through modifiers, order, etc. -func (n *Notification) Value(name string) (ent.Value, error) { - return n.selectValues.Get(name) +func (_m *Notification) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // Update returns a builder for updating this Notification. // Note that you need to call Notification.Unwrap() before calling this method if this Notification // was returned from a transaction, and the transaction was committed or rolled back. -func (n *Notification) Update() *NotificationUpdateOne { - return NewNotificationClient(n.config).UpdateOne(n) +func (_m *Notification) Update() *NotificationUpdateOne { + return NewNotificationClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Notification entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (n *Notification) Unwrap() *Notification { - _tx, ok := n.config.driver.(*txDriver) +func (_m *Notification) Unwrap() *Notification { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Notification is not a transactional entity") } - n.config.driver = _tx.drv - return n + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (n *Notification) String() string { +func (_m *Notification) String() string { var builder strings.Builder builder.WriteString("Notification(") - builder.WriteString(fmt.Sprintf("id=%v, ", n.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("create_author=") - builder.WriteString(fmt.Sprintf("%v", n.CreateAuthor)) + builder.WriteString(fmt.Sprintf("%v", _m.CreateAuthor)) builder.WriteString(", ") builder.WriteString("update_author=") - builder.WriteString(fmt.Sprintf("%v", n.UpdateAuthor)) + builder.WriteString(fmt.Sprintf("%v", _m.UpdateAuthor)) builder.WriteString(", ") builder.WriteString("create_time=") - builder.WriteString(n.CreateTime.Format(time.ANSIC)) + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("update_time=") - builder.WriteString(n.UpdateTime.Format(time.ANSIC)) + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("subject=") - builder.WriteString(n.Subject) + builder.WriteString(_m.Subject) builder.WriteString(", ") builder.WriteString("content=") - builder.WriteString(n.Content) + builder.WriteString(_m.Content) builder.WriteString(", ") builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", n.Status)) + builder.WriteString(fmt.Sprintf("%v", _m.Status)) builder.WriteString(", ") builder.WriteString("category_id=") - builder.WriteString(fmt.Sprintf("%v", n.CategoryID)) + builder.WriteString(fmt.Sprintf("%v", _m.CategoryID)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/notification_create.go b/internal/data/entity/ent/notification_create.go index 04dfb0b1..1f5dc888 100644 --- a/internal/data/entity/ent/notification_create.go +++ b/internal/data/entity/ent/notification_create.go @@ -21,137 +21,137 @@ type NotificationCreate struct { } // SetCreateAuthor sets the "create_author" field. -func (nc *NotificationCreate) SetCreateAuthor(i int64) *NotificationCreate { - nc.mutation.SetCreateAuthor(i) - return nc +func (_c *NotificationCreate) SetCreateAuthor(v int64) *NotificationCreate { + _c.mutation.SetCreateAuthor(v) + return _c } // SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. -func (nc *NotificationCreate) SetNillableCreateAuthor(i *int64) *NotificationCreate { - if i != nil { - nc.SetCreateAuthor(*i) +func (_c *NotificationCreate) SetNillableCreateAuthor(v *int64) *NotificationCreate { + if v != nil { + _c.SetCreateAuthor(*v) } - return nc + return _c } // SetUpdateAuthor sets the "update_author" field. -func (nc *NotificationCreate) SetUpdateAuthor(i int64) *NotificationCreate { - nc.mutation.SetUpdateAuthor(i) - return nc +func (_c *NotificationCreate) SetUpdateAuthor(v int64) *NotificationCreate { + _c.mutation.SetUpdateAuthor(v) + return _c } // SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. -func (nc *NotificationCreate) SetNillableUpdateAuthor(i *int64) *NotificationCreate { - if i != nil { - nc.SetUpdateAuthor(*i) +func (_c *NotificationCreate) SetNillableUpdateAuthor(v *int64) *NotificationCreate { + if v != nil { + _c.SetUpdateAuthor(*v) } - return nc + return _c } // SetCreateTime sets the "create_time" field. -func (nc *NotificationCreate) SetCreateTime(t time.Time) *NotificationCreate { - nc.mutation.SetCreateTime(t) - return nc +func (_c *NotificationCreate) SetCreateTime(v time.Time) *NotificationCreate { + _c.mutation.SetCreateTime(v) + return _c } // SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (nc *NotificationCreate) SetNillableCreateTime(t *time.Time) *NotificationCreate { - if t != nil { - nc.SetCreateTime(*t) +func (_c *NotificationCreate) SetNillableCreateTime(v *time.Time) *NotificationCreate { + if v != nil { + _c.SetCreateTime(*v) } - return nc + return _c } // SetUpdateTime sets the "update_time" field. -func (nc *NotificationCreate) SetUpdateTime(t time.Time) *NotificationCreate { - nc.mutation.SetUpdateTime(t) - return nc +func (_c *NotificationCreate) SetUpdateTime(v time.Time) *NotificationCreate { + _c.mutation.SetUpdateTime(v) + return _c } // SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (nc *NotificationCreate) SetNillableUpdateTime(t *time.Time) *NotificationCreate { - if t != nil { - nc.SetUpdateTime(*t) +func (_c *NotificationCreate) SetNillableUpdateTime(v *time.Time) *NotificationCreate { + if v != nil { + _c.SetUpdateTime(*v) } - return nc + return _c } // SetSubject sets the "subject" field. -func (nc *NotificationCreate) SetSubject(s string) *NotificationCreate { - nc.mutation.SetSubject(s) - return nc +func (_c *NotificationCreate) SetSubject(v string) *NotificationCreate { + _c.mutation.SetSubject(v) + return _c } // SetNillableSubject sets the "subject" field if the given value is not nil. -func (nc *NotificationCreate) SetNillableSubject(s *string) *NotificationCreate { - if s != nil { - nc.SetSubject(*s) +func (_c *NotificationCreate) SetNillableSubject(v *string) *NotificationCreate { + if v != nil { + _c.SetSubject(*v) } - return nc + return _c } // SetContent sets the "content" field. -func (nc *NotificationCreate) SetContent(s string) *NotificationCreate { - nc.mutation.SetContent(s) - return nc +func (_c *NotificationCreate) SetContent(v string) *NotificationCreate { + _c.mutation.SetContent(v) + return _c } // SetNillableContent sets the "content" field if the given value is not nil. -func (nc *NotificationCreate) SetNillableContent(s *string) *NotificationCreate { - if s != nil { - nc.SetContent(*s) +func (_c *NotificationCreate) SetNillableContent(v *string) *NotificationCreate { + if v != nil { + _c.SetContent(*v) } - return nc + return _c } // SetStatus sets the "status" field. -func (nc *NotificationCreate) SetStatus(i int8) *NotificationCreate { - nc.mutation.SetStatus(i) - return nc +func (_c *NotificationCreate) SetStatus(v int8) *NotificationCreate { + _c.mutation.SetStatus(v) + return _c } // SetNillableStatus sets the "status" field if the given value is not nil. -func (nc *NotificationCreate) SetNillableStatus(i *int8) *NotificationCreate { - if i != nil { - nc.SetStatus(*i) +func (_c *NotificationCreate) SetNillableStatus(v *int8) *NotificationCreate { + if v != nil { + _c.SetStatus(*v) } - return nc + return _c } // SetCategoryID sets the "category_id" field. -func (nc *NotificationCreate) SetCategoryID(i int64) *NotificationCreate { - nc.mutation.SetCategoryID(i) - return nc +func (_c *NotificationCreate) SetCategoryID(v int64) *NotificationCreate { + _c.mutation.SetCategoryID(v) + return _c } // SetID sets the "id" field. -func (nc *NotificationCreate) SetID(i int64) *NotificationCreate { - nc.mutation.SetID(i) - return nc +func (_c *NotificationCreate) SetID(v int64) *NotificationCreate { + _c.mutation.SetID(v) + return _c } // SetNillableID sets the "id" field if the given value is not nil. -func (nc *NotificationCreate) SetNillableID(i *int64) *NotificationCreate { - if i != nil { - nc.SetID(*i) +func (_c *NotificationCreate) SetNillableID(v *int64) *NotificationCreate { + if v != nil { + _c.SetID(*v) } - return nc + return _c } // Mutation returns the NotificationMutation object of the builder. -func (nc *NotificationCreate) Mutation() *NotificationMutation { - return nc.mutation +func (_c *NotificationCreate) Mutation() *NotificationMutation { + return _c.mutation } // Save creates the Notification in the database. -func (nc *NotificationCreate) Save(ctx context.Context) (*Notification, error) { - nc.defaults() - return withHooks(ctx, nc.sqlSave, nc.mutation, nc.hooks) +func (_c *NotificationCreate) Save(ctx context.Context) (*Notification, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (nc *NotificationCreate) SaveX(ctx context.Context) *Notification { - v, err := nc.Save(ctx) +func (_c *NotificationCreate) SaveX(ctx context.Context) *Notification { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -159,80 +159,80 @@ func (nc *NotificationCreate) SaveX(ctx context.Context) *Notification { } // Exec executes the query. -func (nc *NotificationCreate) Exec(ctx context.Context) error { - _, err := nc.Save(ctx) +func (_c *NotificationCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (nc *NotificationCreate) ExecX(ctx context.Context) { - if err := nc.Exec(ctx); err != nil { +func (_c *NotificationCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (nc *NotificationCreate) defaults() { - if _, ok := nc.mutation.CreateAuthor(); !ok { +func (_c *NotificationCreate) defaults() { + if _, ok := _c.mutation.CreateAuthor(); !ok { v := notification.DefaultCreateAuthor - nc.mutation.SetCreateAuthor(v) + _c.mutation.SetCreateAuthor(v) } - if _, ok := nc.mutation.UpdateAuthor(); !ok { + if _, ok := _c.mutation.UpdateAuthor(); !ok { v := notification.DefaultUpdateAuthor - nc.mutation.SetUpdateAuthor(v) + _c.mutation.SetUpdateAuthor(v) } - if _, ok := nc.mutation.CreateTime(); !ok { + if _, ok := _c.mutation.CreateTime(); !ok { v := notification.DefaultCreateTime() - nc.mutation.SetCreateTime(v) + _c.mutation.SetCreateTime(v) } - if _, ok := nc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { v := notification.DefaultUpdateTime() - nc.mutation.SetUpdateTime(v) + _c.mutation.SetUpdateTime(v) } - if _, ok := nc.mutation.Subject(); !ok { + if _, ok := _c.mutation.Subject(); !ok { v := notification.DefaultSubject - nc.mutation.SetSubject(v) + _c.mutation.SetSubject(v) } - if _, ok := nc.mutation.Content(); !ok { + if _, ok := _c.mutation.Content(); !ok { v := notification.DefaultContent - nc.mutation.SetContent(v) + _c.mutation.SetContent(v) } - if _, ok := nc.mutation.Status(); !ok { + if _, ok := _c.mutation.Status(); !ok { v := notification.DefaultStatus - nc.mutation.SetStatus(v) + _c.mutation.SetStatus(v) } - if _, ok := nc.mutation.ID(); !ok { + if _, ok := _c.mutation.ID(); !ok { v := notification.DefaultID() - nc.mutation.SetID(v) + _c.mutation.SetID(v) } } // check runs all checks and user-defined validators on the builder. -func (nc *NotificationCreate) check() error { - if _, ok := nc.mutation.CreateTime(); !ok { +func (_c *NotificationCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Notification.create_time"`)} } - if _, ok := nc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Notification.update_time"`)} } - if _, ok := nc.mutation.Subject(); !ok { + if _, ok := _c.mutation.Subject(); !ok { return &ValidationError{Name: "subject", err: errors.New(`ent: missing required field "Notification.subject"`)} } - if _, ok := nc.mutation.Content(); !ok { + if _, ok := _c.mutation.Content(); !ok { return &ValidationError{Name: "content", err: errors.New(`ent: missing required field "Notification.content"`)} } - if _, ok := nc.mutation.Status(); !ok { + if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Notification.status"`)} } - if _, ok := nc.mutation.CategoryID(); !ok { + if _, ok := _c.mutation.CategoryID(); !ok { return &ValidationError{Name: "category_id", err: errors.New(`ent: missing required field "Notification.category_id"`)} } - if v, ok := nc.mutation.CategoryID(); ok { + if v, ok := _c.mutation.CategoryID(); ok { if err := notification.CategoryIDValidator(v); err != nil { return &ValidationError{Name: "category_id", err: fmt.Errorf(`ent: validator failed for field "Notification.category_id": %w`, err)} } } - if v, ok := nc.mutation.ID(); ok { + if v, ok := _c.mutation.ID(); ok { if err := notification.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Notification.id": %w`, err)} } @@ -240,12 +240,12 @@ func (nc *NotificationCreate) check() error { return nil } -func (nc *NotificationCreate) sqlSave(ctx context.Context) (*Notification, error) { - if err := nc.check(); err != nil { +func (_c *NotificationCreate) sqlSave(ctx context.Context) (*Notification, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := nc.createSpec() - if err := sqlgraph.CreateNode(ctx, nc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -255,49 +255,49 @@ func (nc *NotificationCreate) sqlSave(ctx context.Context) (*Notification, error id := _spec.ID.Value.(int64) _node.ID = int64(id) } - nc.mutation.id = &_node.ID - nc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (nc *NotificationCreate) createSpec() (*Notification, *sqlgraph.CreateSpec) { +func (_c *NotificationCreate) createSpec() (*Notification, *sqlgraph.CreateSpec) { var ( - _node = &Notification{config: nc.config} + _node = &Notification{config: _c.config} _spec = sqlgraph.NewCreateSpec(notification.Table, sqlgraph.NewFieldSpec(notification.FieldID, field.TypeInt64)) ) - if id, ok := nc.mutation.ID(); ok { + if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } - if value, ok := nc.mutation.CreateAuthor(); ok { + if value, ok := _c.mutation.CreateAuthor(); ok { _spec.SetField(notification.FieldCreateAuthor, field.TypeInt64, value) _node.CreateAuthor = value } - if value, ok := nc.mutation.UpdateAuthor(); ok { + if value, ok := _c.mutation.UpdateAuthor(); ok { _spec.SetField(notification.FieldUpdateAuthor, field.TypeInt64, value) _node.UpdateAuthor = value } - if value, ok := nc.mutation.CreateTime(); ok { + if value, ok := _c.mutation.CreateTime(); ok { _spec.SetField(notification.FieldCreateTime, field.TypeTime, value) _node.CreateTime = value } - if value, ok := nc.mutation.UpdateTime(); ok { + if value, ok := _c.mutation.UpdateTime(); ok { _spec.SetField(notification.FieldUpdateTime, field.TypeTime, value) _node.UpdateTime = value } - if value, ok := nc.mutation.Subject(); ok { + if value, ok := _c.mutation.Subject(); ok { _spec.SetField(notification.FieldSubject, field.TypeString, value) _node.Subject = value } - if value, ok := nc.mutation.Content(); ok { + if value, ok := _c.mutation.Content(); ok { _spec.SetField(notification.FieldContent, field.TypeString, value) _node.Content = value } - if value, ok := nc.mutation.Status(); ok { + if value, ok := _c.mutation.Status(); ok { _spec.SetField(notification.FieldStatus, field.TypeInt8, value) _node.Status = value } - if value, ok := nc.mutation.CategoryID(); ok { + if value, ok := _c.mutation.CategoryID(); ok { _spec.SetField(notification.FieldCategoryID, field.TypeInt64, value) _node.CategoryID = value } @@ -305,23 +305,23 @@ func (nc *NotificationCreate) createSpec() (*Notification, *sqlgraph.CreateSpec) } // SetNotification set the Notification -func (nc *NotificationCreate) SetNotification(input *Notification, fields ...string) *NotificationCreate { - m := nc.mutation +func (_c *NotificationCreate) SetNotification(input *Notification, fields ...string) *NotificationCreate { + m := _c.mutation if len(fields) == 0 { fields = notification.Columns } _ = m.SetFields(input, fields...) - return nc + return _c } // SetNotificationWithZero set the Notification -func (nc *NotificationCreate) SetNotificationWithZero(input *Notification, fields ...string) *NotificationCreate { - m := nc.mutation +func (_c *NotificationCreate) SetNotificationWithZero(input *Notification, fields ...string) *NotificationCreate { + m := _c.mutation if len(fields) == 0 { fields = notification.Columns } _ = m.SetFieldsWithZero(input, fields...) - return nc + return _c } // NotificationCreateBulk is the builder for creating many Notification entities in bulk. @@ -332,16 +332,16 @@ type NotificationCreateBulk struct { } // Save creates the Notification entities in the database. -func (ncb *NotificationCreateBulk) Save(ctx context.Context) ([]*Notification, error) { - if ncb.err != nil { - return nil, ncb.err - } - specs := make([]*sqlgraph.CreateSpec, len(ncb.builders)) - nodes := make([]*Notification, len(ncb.builders)) - mutators := make([]Mutator, len(ncb.builders)) - for i := range ncb.builders { +func (_c *NotificationCreateBulk) Save(ctx context.Context) ([]*Notification, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Notification, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := ncb.builders[i] + builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*NotificationMutation) @@ -355,11 +355,11 @@ func (ncb *NotificationCreateBulk) Save(ctx context.Context) ([]*Notification, e var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, ncb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, ncb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -383,7 +383,7 @@ func (ncb *NotificationCreateBulk) Save(ctx context.Context) ([]*Notification, e }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, ncb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -391,8 +391,8 @@ func (ncb *NotificationCreateBulk) Save(ctx context.Context) ([]*Notification, e } // SaveX is like Save, but panics if an error occurs. -func (ncb *NotificationCreateBulk) SaveX(ctx context.Context) []*Notification { - v, err := ncb.Save(ctx) +func (_c *NotificationCreateBulk) SaveX(ctx context.Context) []*Notification { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -400,14 +400,14 @@ func (ncb *NotificationCreateBulk) SaveX(ctx context.Context) []*Notification { } // Exec executes the query. -func (ncb *NotificationCreateBulk) Exec(ctx context.Context) error { - _, err := ncb.Save(ctx) +func (_c *NotificationCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ncb *NotificationCreateBulk) ExecX(ctx context.Context) { - if err := ncb.Exec(ctx); err != nil { +func (_c *NotificationCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/notification_delete.go b/internal/data/entity/ent/notification_delete.go index 815faac6..a29763aa 100644 --- a/internal/data/entity/ent/notification_delete.go +++ b/internal/data/entity/ent/notification_delete.go @@ -20,56 +20,56 @@ type NotificationDelete struct { } // Where appends a list predicates to the NotificationDelete builder. -func (nd *NotificationDelete) Where(ps ...predicate.Notification) *NotificationDelete { - nd.mutation.Where(ps...) - return nd +func (_d *NotificationDelete) Where(ps ...predicate.Notification) *NotificationDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (nd *NotificationDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, nd.sqlExec, nd.mutation, nd.hooks) +func (_d *NotificationDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (nd *NotificationDelete) ExecX(ctx context.Context) int { - n, err := nd.Exec(ctx) +func (_d *NotificationDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (nd *NotificationDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *NotificationDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(notification.Table, sqlgraph.NewFieldSpec(notification.FieldID, field.TypeInt64)) - if ps := nd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, nd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - nd.mutation.done = true + _d.mutation.done = true return affected, err } // NotificationDeleteOne is the builder for deleting a single Notification entity. type NotificationDeleteOne struct { - nd *NotificationDelete + _d *NotificationDelete } // Where appends a list predicates to the NotificationDelete builder. -func (ndo *NotificationDeleteOne) Where(ps ...predicate.Notification) *NotificationDeleteOne { - ndo.nd.mutation.Where(ps...) - return ndo +func (_d *NotificationDeleteOne) Where(ps ...predicate.Notification) *NotificationDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (ndo *NotificationDeleteOne) Exec(ctx context.Context) error { - n, err := ndo.nd.Exec(ctx) +func (_d *NotificationDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (ndo *NotificationDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (ndo *NotificationDeleteOne) ExecX(ctx context.Context) { - if err := ndo.Exec(ctx); err != nil { +func (_d *NotificationDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/notification_query.go b/internal/data/entity/ent/notification_query.go index 79e41516..019f2615 100644 --- a/internal/data/entity/ent/notification_query.go +++ b/internal/data/entity/ent/notification_query.go @@ -30,40 +30,40 @@ type NotificationQuery struct { } // Where adds a new predicate for the NotificationQuery builder. -func (nq *NotificationQuery) Where(ps ...predicate.Notification) *NotificationQuery { - nq.predicates = append(nq.predicates, ps...) - return nq +func (_q *NotificationQuery) Where(ps ...predicate.Notification) *NotificationQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (nq *NotificationQuery) Limit(limit int) *NotificationQuery { - nq.ctx.Limit = &limit - return nq +func (_q *NotificationQuery) Limit(limit int) *NotificationQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (nq *NotificationQuery) Offset(offset int) *NotificationQuery { - nq.ctx.Offset = &offset - return nq +func (_q *NotificationQuery) Offset(offset int) *NotificationQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (nq *NotificationQuery) Unique(unique bool) *NotificationQuery { - nq.ctx.Unique = &unique - return nq +func (_q *NotificationQuery) Unique(unique bool) *NotificationQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (nq *NotificationQuery) Order(o ...notification.OrderOption) *NotificationQuery { - nq.order = append(nq.order, o...) - return nq +func (_q *NotificationQuery) Order(o ...notification.OrderOption) *NotificationQuery { + _q.order = append(_q.order, o...) + return _q } // First returns the first Notification entity from the query. // Returns a *NotFoundError when no Notification was found. -func (nq *NotificationQuery) First(ctx context.Context) (*Notification, error) { - nodes, err := nq.Limit(1).All(setContextOp(ctx, nq.ctx, ent.OpQueryFirst)) +func (_q *NotificationQuery) First(ctx context.Context) (*Notification, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -74,8 +74,8 @@ func (nq *NotificationQuery) First(ctx context.Context) (*Notification, error) { } // FirstX is like First, but panics if an error occurs. -func (nq *NotificationQuery) FirstX(ctx context.Context) *Notification { - node, err := nq.First(ctx) +func (_q *NotificationQuery) FirstX(ctx context.Context) *Notification { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -84,9 +84,9 @@ func (nq *NotificationQuery) FirstX(ctx context.Context) *Notification { // FirstID returns the first Notification ID from the query. // Returns a *NotFoundError when no Notification ID was found. -func (nq *NotificationQuery) FirstID(ctx context.Context) (id int64, err error) { +func (_q *NotificationQuery) FirstID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = nq.Limit(1).IDs(setContextOp(ctx, nq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -97,8 +97,8 @@ func (nq *NotificationQuery) FirstID(ctx context.Context) (id int64, err error) } // FirstIDX is like FirstID, but panics if an error occurs. -func (nq *NotificationQuery) FirstIDX(ctx context.Context) int64 { - id, err := nq.FirstID(ctx) +func (_q *NotificationQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -108,8 +108,8 @@ func (nq *NotificationQuery) FirstIDX(ctx context.Context) int64 { // Only returns a single Notification entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Notification entity is found. // Returns a *NotFoundError when no Notification entities are found. -func (nq *NotificationQuery) Only(ctx context.Context) (*Notification, error) { - nodes, err := nq.Limit(2).All(setContextOp(ctx, nq.ctx, ent.OpQueryOnly)) +func (_q *NotificationQuery) Only(ctx context.Context) (*Notification, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -124,8 +124,8 @@ func (nq *NotificationQuery) Only(ctx context.Context) (*Notification, error) { } // OnlyX is like Only, but panics if an error occurs. -func (nq *NotificationQuery) OnlyX(ctx context.Context) *Notification { - node, err := nq.Only(ctx) +func (_q *NotificationQuery) OnlyX(ctx context.Context) *Notification { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -135,9 +135,9 @@ func (nq *NotificationQuery) OnlyX(ctx context.Context) *Notification { // OnlyID is like Only, but returns the only Notification ID in the query. // Returns a *NotSingularError when more than one Notification ID is found. // Returns a *NotFoundError when no entities are found. -func (nq *NotificationQuery) OnlyID(ctx context.Context) (id int64, err error) { +func (_q *NotificationQuery) OnlyID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = nq.Limit(2).IDs(setContextOp(ctx, nq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -152,8 +152,8 @@ func (nq *NotificationQuery) OnlyID(ctx context.Context) (id int64, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (nq *NotificationQuery) OnlyIDX(ctx context.Context) int64 { - id, err := nq.OnlyID(ctx) +func (_q *NotificationQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -161,18 +161,18 @@ func (nq *NotificationQuery) OnlyIDX(ctx context.Context) int64 { } // All executes the query and returns a list of Notifications. -func (nq *NotificationQuery) All(ctx context.Context) ([]*Notification, error) { - ctx = setContextOp(ctx, nq.ctx, ent.OpQueryAll) - if err := nq.prepareQuery(ctx); err != nil { +func (_q *NotificationQuery) All(ctx context.Context) ([]*Notification, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Notification, *NotificationQuery]() - return withInterceptors[[]*Notification](ctx, nq, qr, nq.inters) + return withInterceptors[[]*Notification](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (nq *NotificationQuery) AllX(ctx context.Context) []*Notification { - nodes, err := nq.All(ctx) +func (_q *NotificationQuery) AllX(ctx context.Context) []*Notification { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -180,20 +180,20 @@ func (nq *NotificationQuery) AllX(ctx context.Context) []*Notification { } // IDs executes the query and returns a list of Notification IDs. -func (nq *NotificationQuery) IDs(ctx context.Context) (ids []int64, err error) { - if nq.ctx.Unique == nil && nq.path != nil { - nq.Unique(true) +func (_q *NotificationQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, nq.ctx, ent.OpQueryIDs) - if err = nq.Select(notification.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(notification.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (nq *NotificationQuery) IDsX(ctx context.Context) []int64 { - ids, err := nq.IDs(ctx) +func (_q *NotificationQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -201,17 +201,17 @@ func (nq *NotificationQuery) IDsX(ctx context.Context) []int64 { } // Count returns the count of the given query. -func (nq *NotificationQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, nq.ctx, ent.OpQueryCount) - if err := nq.prepareQuery(ctx); err != nil { +func (_q *NotificationQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, nq, querierCount[*NotificationQuery](), nq.inters) + return withInterceptors[int](ctx, _q, querierCount[*NotificationQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (nq *NotificationQuery) CountX(ctx context.Context) int { - count, err := nq.Count(ctx) +func (_q *NotificationQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -219,9 +219,9 @@ func (nq *NotificationQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (nq *NotificationQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, nq.ctx, ent.OpQueryExist) - switch _, err := nq.FirstID(ctx); { +func (_q *NotificationQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -232,8 +232,8 @@ func (nq *NotificationQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (nq *NotificationQuery) ExistX(ctx context.Context) bool { - exist, err := nq.Exist(ctx) +func (_q *NotificationQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -242,20 +242,20 @@ func (nq *NotificationQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the NotificationQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (nq *NotificationQuery) Clone() *NotificationQuery { - if nq == nil { +func (_q *NotificationQuery) Clone() *NotificationQuery { + if _q == nil { return nil } return &NotificationQuery{ - config: nq.config, - ctx: nq.ctx.Clone(), - order: append([]notification.OrderOption{}, nq.order...), - inters: append([]Interceptor{}, nq.inters...), - predicates: append([]predicate.Notification{}, nq.predicates...), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]notification.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Notification{}, _q.predicates...), // clone intermediate query. - sql: nq.sql.Clone(), - path: nq.path, - modifiers: append([]func(*sql.Selector){}, nq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } @@ -273,10 +273,10 @@ func (nq *NotificationQuery) Clone() *NotificationQuery { // GroupBy(notification.FieldCreateAuthor). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (nq *NotificationQuery) GroupBy(field string, fields ...string) *NotificationGroupBy { - nq.ctx.Fields = append([]string{field}, fields...) - grbuild := &NotificationGroupBy{build: nq} - grbuild.flds = &nq.ctx.Fields +func (_q *NotificationQuery) GroupBy(field string, fields ...string) *NotificationGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &NotificationGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = notification.Label grbuild.scan = grbuild.Scan return grbuild @@ -294,65 +294,65 @@ func (nq *NotificationQuery) GroupBy(field string, fields ...string) *Notificati // client.Notification.Query(). // Select(notification.FieldCreateAuthor). // Scan(ctx, &v) -func (nq *NotificationQuery) Select(fields ...string) *NotificationSelect { - nq.ctx.Fields = append(nq.ctx.Fields, fields...) - sbuild := &NotificationSelect{NotificationQuery: nq} +func (_q *NotificationQuery) Select(fields ...string) *NotificationSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &NotificationSelect{NotificationQuery: _q} sbuild.label = notification.Label - sbuild.flds, sbuild.scan = &nq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a NotificationSelect configured with the given aggregations. -func (nq *NotificationQuery) Aggregate(fns ...AggregateFunc) *NotificationSelect { - return nq.Select().Aggregate(fns...) +func (_q *NotificationQuery) Aggregate(fns ...AggregateFunc) *NotificationSelect { + return _q.Select().Aggregate(fns...) } -func (nq *NotificationQuery) prepareQuery(ctx context.Context) error { - for _, inter := range nq.inters { +func (_q *NotificationQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, nq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range nq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !notification.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if nq.path != nil { - prev, err := nq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - nq.sql = prev + _q.sql = prev } return nil } -func (nq *NotificationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Notification, error) { +func (_q *NotificationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Notification, error) { var ( nodes = []*Notification{} - _spec = nq.querySpec() + _spec = _q.querySpec() ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Notification).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Notification{config: nq.config} + node := &Notification{config: _q.config} nodes = append(nodes, node) return node.assignValues(columns, values) } - if len(nq.modifiers) > 0 { - _spec.Modifiers = nq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, nq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { @@ -361,27 +361,27 @@ func (nq *NotificationQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] return nodes, nil } -func (nq *NotificationQuery) sqlCount(ctx context.Context) (int, error) { - _spec := nq.querySpec() - if len(nq.modifiers) > 0 { - _spec.Modifiers = nq.modifiers +func (_q *NotificationQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = nq.ctx.Fields - if len(nq.ctx.Fields) > 0 { - _spec.Unique = nq.ctx.Unique != nil && *nq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, nq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (nq *NotificationQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *NotificationQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(notification.Table, notification.Columns, sqlgraph.NewFieldSpec(notification.FieldID, field.TypeInt64)) - _spec.From = nq.sql - if unique := nq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if nq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := nq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, notification.FieldID) for i := range fields { @@ -390,20 +390,20 @@ func (nq *NotificationQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := nq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := nq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := nq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := nq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -413,36 +413,36 @@ func (nq *NotificationQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (nq *NotificationQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(nq.driver.Dialect()) +func (_q *NotificationQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(notification.Table) - columns := nq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = notification.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if nq.sql != nil { - selector = nq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if nq.ctx.Unique != nil && *nq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range nq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range nq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range nq.order { + for _, p := range _q.order { p(selector) } - if offset := nq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := nq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -451,33 +451,33 @@ func (nq *NotificationQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (nq *NotificationQuery) ForUpdate(opts ...sql.LockOption) *NotificationQuery { - if nq.driver.Dialect() == dialect.Postgres { - nq.Unique(false) +func (_q *NotificationQuery) ForUpdate(opts ...sql.LockOption) *NotificationQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - nq.modifiers = append(nq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return nq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (nq *NotificationQuery) ForShare(opts ...sql.LockOption) *NotificationQuery { - if nq.driver.Dialect() == dialect.Postgres { - nq.Unique(false) +func (_q *NotificationQuery) ForShare(opts ...sql.LockOption) *NotificationQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - nq.modifiers = append(nq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return nq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (nq *NotificationQuery) Modify(modifiers ...func(s *sql.Selector)) *NotificationSelect { - nq.modifiers = append(nq.modifiers, modifiers...) - return nq.Select() +func (_q *NotificationQuery) Modify(modifiers ...func(s *sql.Selector)) *NotificationSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -531,41 +531,41 @@ type NotificationGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (ngb *NotificationGroupBy) Aggregate(fns ...AggregateFunc) *NotificationGroupBy { - ngb.fns = append(ngb.fns, fns...) - return ngb +func (_g *NotificationGroupBy) Aggregate(fns ...AggregateFunc) *NotificationGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (ngb *NotificationGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ngb.build.ctx, ent.OpQueryGroupBy) - if err := ngb.build.prepareQuery(ctx); err != nil { +func (_g *NotificationGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*NotificationQuery, *NotificationGroupBy](ctx, ngb.build, ngb, ngb.build.inters, v) + return scanWithInterceptors[*NotificationQuery, *NotificationGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (ngb *NotificationGroupBy) sqlScan(ctx context.Context, root *NotificationQuery, v any) error { +func (_g *NotificationGroupBy) sqlScan(ctx context.Context, root *NotificationQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(ngb.fns)) - for _, fn := range ngb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*ngb.flds)+len(ngb.fns)) - for _, f := range *ngb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*ngb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := ngb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -579,27 +579,27 @@ type NotificationSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (ns *NotificationSelect) Aggregate(fns ...AggregateFunc) *NotificationSelect { - ns.fns = append(ns.fns, fns...) - return ns +func (_s *NotificationSelect) Aggregate(fns ...AggregateFunc) *NotificationSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (ns *NotificationSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ns.ctx, ent.OpQuerySelect) - if err := ns.prepareQuery(ctx); err != nil { +func (_s *NotificationSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*NotificationQuery, *NotificationSelect](ctx, ns.NotificationQuery, ns, ns.inters, v) + return scanWithInterceptors[*NotificationQuery, *NotificationSelect](ctx, _s.NotificationQuery, _s, _s.inters, v) } -func (ns *NotificationSelect) sqlScan(ctx context.Context, root *NotificationQuery, v any) error { +func (_s *NotificationSelect) sqlScan(ctx context.Context, root *NotificationQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ns.fns)) - for _, fn := range ns.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*ns.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -607,7 +607,7 @@ func (ns *NotificationSelect) sqlScan(ctx context.Context, root *NotificationQue } rows := &sql.Rows{} query, args := selector.Query() - if err := ns.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -615,7 +615,7 @@ func (ns *NotificationSelect) sqlScan(ctx context.Context, root *NotificationQue } // Modify adds a query modifier for attaching custom logic to queries. -func (ns *NotificationSelect) Modify(modifiers ...func(s *sql.Selector)) *NotificationSelect { - ns.modifiers = append(ns.modifiers, modifiers...) - return ns +func (_s *NotificationSelect) Modify(modifiers ...func(s *sql.Selector)) *NotificationSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/notification_update.go b/internal/data/entity/ent/notification_update.go index 515d7c0e..6d245c9b 100644 --- a/internal/data/entity/ent/notification_update.go +++ b/internal/data/entity/ent/notification_update.go @@ -24,155 +24,155 @@ type NotificationUpdate struct { } // Where appends a list predicates to the NotificationUpdate builder. -func (nu *NotificationUpdate) Where(ps ...predicate.Notification) *NotificationUpdate { - nu.mutation.Where(ps...) - return nu +func (_u *NotificationUpdate) Where(ps ...predicate.Notification) *NotificationUpdate { + _u.mutation.Where(ps...) + return _u } // SetCreateAuthor sets the "create_author" field. -func (nu *NotificationUpdate) SetCreateAuthor(i int64) *NotificationUpdate { - nu.mutation.ResetCreateAuthor() - nu.mutation.SetCreateAuthor(i) - return nu +func (_u *NotificationUpdate) SetCreateAuthor(v int64) *NotificationUpdate { + _u.mutation.ResetCreateAuthor() + _u.mutation.SetCreateAuthor(v) + return _u } // SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. -func (nu *NotificationUpdate) SetNillableCreateAuthor(i *int64) *NotificationUpdate { - if i != nil { - nu.SetCreateAuthor(*i) +func (_u *NotificationUpdate) SetNillableCreateAuthor(v *int64) *NotificationUpdate { + if v != nil { + _u.SetCreateAuthor(*v) } - return nu + return _u } -// AddCreateAuthor adds i to the "create_author" field. -func (nu *NotificationUpdate) AddCreateAuthor(i int64) *NotificationUpdate { - nu.mutation.AddCreateAuthor(i) - return nu +// AddCreateAuthor adds value to the "create_author" field. +func (_u *NotificationUpdate) AddCreateAuthor(v int64) *NotificationUpdate { + _u.mutation.AddCreateAuthor(v) + return _u } // ClearCreateAuthor clears the value of the "create_author" field. -func (nu *NotificationUpdate) ClearCreateAuthor() *NotificationUpdate { - nu.mutation.ClearCreateAuthor() - return nu +func (_u *NotificationUpdate) ClearCreateAuthor() *NotificationUpdate { + _u.mutation.ClearCreateAuthor() + return _u } // SetUpdateAuthor sets the "update_author" field. -func (nu *NotificationUpdate) SetUpdateAuthor(i int64) *NotificationUpdate { - nu.mutation.ResetUpdateAuthor() - nu.mutation.SetUpdateAuthor(i) - return nu +func (_u *NotificationUpdate) SetUpdateAuthor(v int64) *NotificationUpdate { + _u.mutation.ResetUpdateAuthor() + _u.mutation.SetUpdateAuthor(v) + return _u } // SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. -func (nu *NotificationUpdate) SetNillableUpdateAuthor(i *int64) *NotificationUpdate { - if i != nil { - nu.SetUpdateAuthor(*i) +func (_u *NotificationUpdate) SetNillableUpdateAuthor(v *int64) *NotificationUpdate { + if v != nil { + _u.SetUpdateAuthor(*v) } - return nu + return _u } -// AddUpdateAuthor adds i to the "update_author" field. -func (nu *NotificationUpdate) AddUpdateAuthor(i int64) *NotificationUpdate { - nu.mutation.AddUpdateAuthor(i) - return nu +// AddUpdateAuthor adds value to the "update_author" field. +func (_u *NotificationUpdate) AddUpdateAuthor(v int64) *NotificationUpdate { + _u.mutation.AddUpdateAuthor(v) + return _u } // ClearUpdateAuthor clears the value of the "update_author" field. -func (nu *NotificationUpdate) ClearUpdateAuthor() *NotificationUpdate { - nu.mutation.ClearUpdateAuthor() - return nu +func (_u *NotificationUpdate) ClearUpdateAuthor() *NotificationUpdate { + _u.mutation.ClearUpdateAuthor() + return _u } // SetUpdateTime sets the "update_time" field. -func (nu *NotificationUpdate) SetUpdateTime(t time.Time) *NotificationUpdate { - nu.mutation.SetUpdateTime(t) - return nu +func (_u *NotificationUpdate) SetUpdateTime(v time.Time) *NotificationUpdate { + _u.mutation.SetUpdateTime(v) + return _u } // SetSubject sets the "subject" field. -func (nu *NotificationUpdate) SetSubject(s string) *NotificationUpdate { - nu.mutation.SetSubject(s) - return nu +func (_u *NotificationUpdate) SetSubject(v string) *NotificationUpdate { + _u.mutation.SetSubject(v) + return _u } // SetNillableSubject sets the "subject" field if the given value is not nil. -func (nu *NotificationUpdate) SetNillableSubject(s *string) *NotificationUpdate { - if s != nil { - nu.SetSubject(*s) +func (_u *NotificationUpdate) SetNillableSubject(v *string) *NotificationUpdate { + if v != nil { + _u.SetSubject(*v) } - return nu + return _u } // SetContent sets the "content" field. -func (nu *NotificationUpdate) SetContent(s string) *NotificationUpdate { - nu.mutation.SetContent(s) - return nu +func (_u *NotificationUpdate) SetContent(v string) *NotificationUpdate { + _u.mutation.SetContent(v) + return _u } // SetNillableContent sets the "content" field if the given value is not nil. -func (nu *NotificationUpdate) SetNillableContent(s *string) *NotificationUpdate { - if s != nil { - nu.SetContent(*s) +func (_u *NotificationUpdate) SetNillableContent(v *string) *NotificationUpdate { + if v != nil { + _u.SetContent(*v) } - return nu + return _u } // SetStatus sets the "status" field. -func (nu *NotificationUpdate) SetStatus(i int8) *NotificationUpdate { - nu.mutation.ResetStatus() - nu.mutation.SetStatus(i) - return nu +func (_u *NotificationUpdate) SetStatus(v int8) *NotificationUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (nu *NotificationUpdate) SetNillableStatus(i *int8) *NotificationUpdate { - if i != nil { - nu.SetStatus(*i) +func (_u *NotificationUpdate) SetNillableStatus(v *int8) *NotificationUpdate { + if v != nil { + _u.SetStatus(*v) } - return nu + return _u } -// AddStatus adds i to the "status" field. -func (nu *NotificationUpdate) AddStatus(i int8) *NotificationUpdate { - nu.mutation.AddStatus(i) - return nu +// AddStatus adds value to the "status" field. +func (_u *NotificationUpdate) AddStatus(v int8) *NotificationUpdate { + _u.mutation.AddStatus(v) + return _u } // SetCategoryID sets the "category_id" field. -func (nu *NotificationUpdate) SetCategoryID(i int64) *NotificationUpdate { - nu.mutation.ResetCategoryID() - nu.mutation.SetCategoryID(i) - return nu +func (_u *NotificationUpdate) SetCategoryID(v int64) *NotificationUpdate { + _u.mutation.ResetCategoryID() + _u.mutation.SetCategoryID(v) + return _u } // SetNillableCategoryID sets the "category_id" field if the given value is not nil. -func (nu *NotificationUpdate) SetNillableCategoryID(i *int64) *NotificationUpdate { - if i != nil { - nu.SetCategoryID(*i) +func (_u *NotificationUpdate) SetNillableCategoryID(v *int64) *NotificationUpdate { + if v != nil { + _u.SetCategoryID(*v) } - return nu + return _u } -// AddCategoryID adds i to the "category_id" field. -func (nu *NotificationUpdate) AddCategoryID(i int64) *NotificationUpdate { - nu.mutation.AddCategoryID(i) - return nu +// AddCategoryID adds value to the "category_id" field. +func (_u *NotificationUpdate) AddCategoryID(v int64) *NotificationUpdate { + _u.mutation.AddCategoryID(v) + return _u } // Mutation returns the NotificationMutation object of the builder. -func (nu *NotificationUpdate) Mutation() *NotificationMutation { - return nu.mutation +func (_u *NotificationUpdate) Mutation() *NotificationMutation { + return _u.mutation } // Save executes the query and returns the number of nodes affected by the update operation. -func (nu *NotificationUpdate) Save(ctx context.Context) (int, error) { - nu.defaults() - return withHooks(ctx, nu.sqlSave, nu.mutation, nu.hooks) +func (_u *NotificationUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (nu *NotificationUpdate) SaveX(ctx context.Context) int { - affected, err := nu.Save(ctx) +func (_u *NotificationUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -180,29 +180,29 @@ func (nu *NotificationUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (nu *NotificationUpdate) Exec(ctx context.Context) error { - _, err := nu.Save(ctx) +func (_u *NotificationUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (nu *NotificationUpdate) ExecX(ctx context.Context) { - if err := nu.Exec(ctx); err != nil { +func (_u *NotificationUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (nu *NotificationUpdate) defaults() { - if _, ok := nu.mutation.UpdateTime(); !ok { +func (_u *NotificationUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := notification.UpdateDefaultUpdateTime() - nu.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (nu *NotificationUpdate) check() error { - if v, ok := nu.mutation.CategoryID(); ok { +func (_u *NotificationUpdate) check() error { + if v, ok := _u.mutation.CategoryID(); ok { if err := notification.CategoryIDValidator(v); err != nil { return &ValidationError{Name: "category_id", err: fmt.Errorf(`ent: validator failed for field "Notification.category_id": %w`, err)} } @@ -211,64 +211,64 @@ func (nu *NotificationUpdate) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (nu *NotificationUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NotificationUpdate { - nu.modifiers = append(nu.modifiers, modifiers...) - return nu +func (_u *NotificationUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NotificationUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (nu *NotificationUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := nu.check(); err != nil { - return n, err +func (_u *NotificationUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(notification.Table, notification.Columns, sqlgraph.NewFieldSpec(notification.FieldID, field.TypeInt64)) - if ps := nu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := nu.mutation.CreateAuthor(); ok { + if value, ok := _u.mutation.CreateAuthor(); ok { _spec.SetField(notification.FieldCreateAuthor, field.TypeInt64, value) } - if value, ok := nu.mutation.AddedCreateAuthor(); ok { + if value, ok := _u.mutation.AddedCreateAuthor(); ok { _spec.AddField(notification.FieldCreateAuthor, field.TypeInt64, value) } - if nu.mutation.CreateAuthorCleared() { + if _u.mutation.CreateAuthorCleared() { _spec.ClearField(notification.FieldCreateAuthor, field.TypeInt64) } - if value, ok := nu.mutation.UpdateAuthor(); ok { + if value, ok := _u.mutation.UpdateAuthor(); ok { _spec.SetField(notification.FieldUpdateAuthor, field.TypeInt64, value) } - if value, ok := nu.mutation.AddedUpdateAuthor(); ok { + if value, ok := _u.mutation.AddedUpdateAuthor(); ok { _spec.AddField(notification.FieldUpdateAuthor, field.TypeInt64, value) } - if nu.mutation.UpdateAuthorCleared() { + if _u.mutation.UpdateAuthorCleared() { _spec.ClearField(notification.FieldUpdateAuthor, field.TypeInt64) } - if value, ok := nu.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(notification.FieldUpdateTime, field.TypeTime, value) } - if value, ok := nu.mutation.Subject(); ok { + if value, ok := _u.mutation.Subject(); ok { _spec.SetField(notification.FieldSubject, field.TypeString, value) } - if value, ok := nu.mutation.Content(); ok { + if value, ok := _u.mutation.Content(); ok { _spec.SetField(notification.FieldContent, field.TypeString, value) } - if value, ok := nu.mutation.Status(); ok { + if value, ok := _u.mutation.Status(); ok { _spec.SetField(notification.FieldStatus, field.TypeInt8, value) } - if value, ok := nu.mutation.AddedStatus(); ok { + if value, ok := _u.mutation.AddedStatus(); ok { _spec.AddField(notification.FieldStatus, field.TypeInt8, value) } - if value, ok := nu.mutation.CategoryID(); ok { + if value, ok := _u.mutation.CategoryID(); ok { _spec.SetField(notification.FieldCategoryID, field.TypeInt64, value) } - if value, ok := nu.mutation.AddedCategoryID(); ok { + if value, ok := _u.mutation.AddedCategoryID(); ok { _spec.AddField(notification.FieldCategoryID, field.TypeInt64, value) } - _spec.AddModifiers(nu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, nu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{notification.Label} } else if sqlgraph.IsConstraintError(err) { @@ -276,8 +276,8 @@ func (nu *NotificationUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - nu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // NotificationUpdateOne is the builder for updating a single Notification entity. @@ -290,162 +290,162 @@ type NotificationUpdateOne struct { } // SetCreateAuthor sets the "create_author" field. -func (nuo *NotificationUpdateOne) SetCreateAuthor(i int64) *NotificationUpdateOne { - nuo.mutation.ResetCreateAuthor() - nuo.mutation.SetCreateAuthor(i) - return nuo +func (_u *NotificationUpdateOne) SetCreateAuthor(v int64) *NotificationUpdateOne { + _u.mutation.ResetCreateAuthor() + _u.mutation.SetCreateAuthor(v) + return _u } // SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. -func (nuo *NotificationUpdateOne) SetNillableCreateAuthor(i *int64) *NotificationUpdateOne { - if i != nil { - nuo.SetCreateAuthor(*i) +func (_u *NotificationUpdateOne) SetNillableCreateAuthor(v *int64) *NotificationUpdateOne { + if v != nil { + _u.SetCreateAuthor(*v) } - return nuo + return _u } -// AddCreateAuthor adds i to the "create_author" field. -func (nuo *NotificationUpdateOne) AddCreateAuthor(i int64) *NotificationUpdateOne { - nuo.mutation.AddCreateAuthor(i) - return nuo +// AddCreateAuthor adds value to the "create_author" field. +func (_u *NotificationUpdateOne) AddCreateAuthor(v int64) *NotificationUpdateOne { + _u.mutation.AddCreateAuthor(v) + return _u } // ClearCreateAuthor clears the value of the "create_author" field. -func (nuo *NotificationUpdateOne) ClearCreateAuthor() *NotificationUpdateOne { - nuo.mutation.ClearCreateAuthor() - return nuo +func (_u *NotificationUpdateOne) ClearCreateAuthor() *NotificationUpdateOne { + _u.mutation.ClearCreateAuthor() + return _u } // SetUpdateAuthor sets the "update_author" field. -func (nuo *NotificationUpdateOne) SetUpdateAuthor(i int64) *NotificationUpdateOne { - nuo.mutation.ResetUpdateAuthor() - nuo.mutation.SetUpdateAuthor(i) - return nuo +func (_u *NotificationUpdateOne) SetUpdateAuthor(v int64) *NotificationUpdateOne { + _u.mutation.ResetUpdateAuthor() + _u.mutation.SetUpdateAuthor(v) + return _u } // SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. -func (nuo *NotificationUpdateOne) SetNillableUpdateAuthor(i *int64) *NotificationUpdateOne { - if i != nil { - nuo.SetUpdateAuthor(*i) +func (_u *NotificationUpdateOne) SetNillableUpdateAuthor(v *int64) *NotificationUpdateOne { + if v != nil { + _u.SetUpdateAuthor(*v) } - return nuo + return _u } -// AddUpdateAuthor adds i to the "update_author" field. -func (nuo *NotificationUpdateOne) AddUpdateAuthor(i int64) *NotificationUpdateOne { - nuo.mutation.AddUpdateAuthor(i) - return nuo +// AddUpdateAuthor adds value to the "update_author" field. +func (_u *NotificationUpdateOne) AddUpdateAuthor(v int64) *NotificationUpdateOne { + _u.mutation.AddUpdateAuthor(v) + return _u } // ClearUpdateAuthor clears the value of the "update_author" field. -func (nuo *NotificationUpdateOne) ClearUpdateAuthor() *NotificationUpdateOne { - nuo.mutation.ClearUpdateAuthor() - return nuo +func (_u *NotificationUpdateOne) ClearUpdateAuthor() *NotificationUpdateOne { + _u.mutation.ClearUpdateAuthor() + return _u } // SetUpdateTime sets the "update_time" field. -func (nuo *NotificationUpdateOne) SetUpdateTime(t time.Time) *NotificationUpdateOne { - nuo.mutation.SetUpdateTime(t) - return nuo +func (_u *NotificationUpdateOne) SetUpdateTime(v time.Time) *NotificationUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u } // SetSubject sets the "subject" field. -func (nuo *NotificationUpdateOne) SetSubject(s string) *NotificationUpdateOne { - nuo.mutation.SetSubject(s) - return nuo +func (_u *NotificationUpdateOne) SetSubject(v string) *NotificationUpdateOne { + _u.mutation.SetSubject(v) + return _u } // SetNillableSubject sets the "subject" field if the given value is not nil. -func (nuo *NotificationUpdateOne) SetNillableSubject(s *string) *NotificationUpdateOne { - if s != nil { - nuo.SetSubject(*s) +func (_u *NotificationUpdateOne) SetNillableSubject(v *string) *NotificationUpdateOne { + if v != nil { + _u.SetSubject(*v) } - return nuo + return _u } // SetContent sets the "content" field. -func (nuo *NotificationUpdateOne) SetContent(s string) *NotificationUpdateOne { - nuo.mutation.SetContent(s) - return nuo +func (_u *NotificationUpdateOne) SetContent(v string) *NotificationUpdateOne { + _u.mutation.SetContent(v) + return _u } // SetNillableContent sets the "content" field if the given value is not nil. -func (nuo *NotificationUpdateOne) SetNillableContent(s *string) *NotificationUpdateOne { - if s != nil { - nuo.SetContent(*s) +func (_u *NotificationUpdateOne) SetNillableContent(v *string) *NotificationUpdateOne { + if v != nil { + _u.SetContent(*v) } - return nuo + return _u } // SetStatus sets the "status" field. -func (nuo *NotificationUpdateOne) SetStatus(i int8) *NotificationUpdateOne { - nuo.mutation.ResetStatus() - nuo.mutation.SetStatus(i) - return nuo +func (_u *NotificationUpdateOne) SetStatus(v int8) *NotificationUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (nuo *NotificationUpdateOne) SetNillableStatus(i *int8) *NotificationUpdateOne { - if i != nil { - nuo.SetStatus(*i) +func (_u *NotificationUpdateOne) SetNillableStatus(v *int8) *NotificationUpdateOne { + if v != nil { + _u.SetStatus(*v) } - return nuo + return _u } -// AddStatus adds i to the "status" field. -func (nuo *NotificationUpdateOne) AddStatus(i int8) *NotificationUpdateOne { - nuo.mutation.AddStatus(i) - return nuo +// AddStatus adds value to the "status" field. +func (_u *NotificationUpdateOne) AddStatus(v int8) *NotificationUpdateOne { + _u.mutation.AddStatus(v) + return _u } // SetCategoryID sets the "category_id" field. -func (nuo *NotificationUpdateOne) SetCategoryID(i int64) *NotificationUpdateOne { - nuo.mutation.ResetCategoryID() - nuo.mutation.SetCategoryID(i) - return nuo +func (_u *NotificationUpdateOne) SetCategoryID(v int64) *NotificationUpdateOne { + _u.mutation.ResetCategoryID() + _u.mutation.SetCategoryID(v) + return _u } // SetNillableCategoryID sets the "category_id" field if the given value is not nil. -func (nuo *NotificationUpdateOne) SetNillableCategoryID(i *int64) *NotificationUpdateOne { - if i != nil { - nuo.SetCategoryID(*i) +func (_u *NotificationUpdateOne) SetNillableCategoryID(v *int64) *NotificationUpdateOne { + if v != nil { + _u.SetCategoryID(*v) } - return nuo + return _u } -// AddCategoryID adds i to the "category_id" field. -func (nuo *NotificationUpdateOne) AddCategoryID(i int64) *NotificationUpdateOne { - nuo.mutation.AddCategoryID(i) - return nuo +// AddCategoryID adds value to the "category_id" field. +func (_u *NotificationUpdateOne) AddCategoryID(v int64) *NotificationUpdateOne { + _u.mutation.AddCategoryID(v) + return _u } // Mutation returns the NotificationMutation object of the builder. -func (nuo *NotificationUpdateOne) Mutation() *NotificationMutation { - return nuo.mutation +func (_u *NotificationUpdateOne) Mutation() *NotificationMutation { + return _u.mutation } // Where appends a list predicates to the NotificationUpdate builder. -func (nuo *NotificationUpdateOne) Where(ps ...predicate.Notification) *NotificationUpdateOne { - nuo.mutation.Where(ps...) - return nuo +func (_u *NotificationUpdateOne) Where(ps ...predicate.Notification) *NotificationUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (nuo *NotificationUpdateOne) Select(field string, fields ...string) *NotificationUpdateOne { - nuo.fields = append([]string{field}, fields...) - return nuo +func (_u *NotificationUpdateOne) Select(field string, fields ...string) *NotificationUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Notification entity. -func (nuo *NotificationUpdateOne) Save(ctx context.Context) (*Notification, error) { - nuo.defaults() - return withHooks(ctx, nuo.sqlSave, nuo.mutation, nuo.hooks) +func (_u *NotificationUpdateOne) Save(ctx context.Context) (*Notification, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (nuo *NotificationUpdateOne) SaveX(ctx context.Context) *Notification { - node, err := nuo.Save(ctx) +func (_u *NotificationUpdateOne) SaveX(ctx context.Context) *Notification { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -453,29 +453,29 @@ func (nuo *NotificationUpdateOne) SaveX(ctx context.Context) *Notification { } // Exec executes the query on the entity. -func (nuo *NotificationUpdateOne) Exec(ctx context.Context) error { - _, err := nuo.Save(ctx) +func (_u *NotificationUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (nuo *NotificationUpdateOne) ExecX(ctx context.Context) { - if err := nuo.Exec(ctx); err != nil { +func (_u *NotificationUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (nuo *NotificationUpdateOne) defaults() { - if _, ok := nuo.mutation.UpdateTime(); !ok { +func (_u *NotificationUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := notification.UpdateDefaultUpdateTime() - nuo.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (nuo *NotificationUpdateOne) check() error { - if v, ok := nuo.mutation.CategoryID(); ok { +func (_u *NotificationUpdateOne) check() error { + if v, ok := _u.mutation.CategoryID(); ok { if err := notification.CategoryIDValidator(v); err != nil { return &ValidationError{Name: "category_id", err: fmt.Errorf(`ent: validator failed for field "Notification.category_id": %w`, err)} } @@ -484,22 +484,22 @@ func (nuo *NotificationUpdateOne) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (nuo *NotificationUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NotificationUpdateOne { - nuo.modifiers = append(nuo.modifiers, modifiers...) - return nuo +func (_u *NotificationUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *NotificationUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (nuo *NotificationUpdateOne) sqlSave(ctx context.Context) (_node *Notification, err error) { - if err := nuo.check(); err != nil { +func (_u *NotificationUpdateOne) sqlSave(ctx context.Context) (_node *Notification, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(notification.Table, notification.Columns, sqlgraph.NewFieldSpec(notification.FieldID, field.TypeInt64)) - id, ok := nuo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Notification.id" for update`)} } _spec.Node.ID.Value = id - if fields := nuo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, notification.FieldID) for _, f := range fields { @@ -511,57 +511,57 @@ func (nuo *NotificationUpdateOne) sqlSave(ctx context.Context) (_node *Notificat } } } - if ps := nuo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := nuo.mutation.CreateAuthor(); ok { + if value, ok := _u.mutation.CreateAuthor(); ok { _spec.SetField(notification.FieldCreateAuthor, field.TypeInt64, value) } - if value, ok := nuo.mutation.AddedCreateAuthor(); ok { + if value, ok := _u.mutation.AddedCreateAuthor(); ok { _spec.AddField(notification.FieldCreateAuthor, field.TypeInt64, value) } - if nuo.mutation.CreateAuthorCleared() { + if _u.mutation.CreateAuthorCleared() { _spec.ClearField(notification.FieldCreateAuthor, field.TypeInt64) } - if value, ok := nuo.mutation.UpdateAuthor(); ok { + if value, ok := _u.mutation.UpdateAuthor(); ok { _spec.SetField(notification.FieldUpdateAuthor, field.TypeInt64, value) } - if value, ok := nuo.mutation.AddedUpdateAuthor(); ok { + if value, ok := _u.mutation.AddedUpdateAuthor(); ok { _spec.AddField(notification.FieldUpdateAuthor, field.TypeInt64, value) } - if nuo.mutation.UpdateAuthorCleared() { + if _u.mutation.UpdateAuthorCleared() { _spec.ClearField(notification.FieldUpdateAuthor, field.TypeInt64) } - if value, ok := nuo.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(notification.FieldUpdateTime, field.TypeTime, value) } - if value, ok := nuo.mutation.Subject(); ok { + if value, ok := _u.mutation.Subject(); ok { _spec.SetField(notification.FieldSubject, field.TypeString, value) } - if value, ok := nuo.mutation.Content(); ok { + if value, ok := _u.mutation.Content(); ok { _spec.SetField(notification.FieldContent, field.TypeString, value) } - if value, ok := nuo.mutation.Status(); ok { + if value, ok := _u.mutation.Status(); ok { _spec.SetField(notification.FieldStatus, field.TypeInt8, value) } - if value, ok := nuo.mutation.AddedStatus(); ok { + if value, ok := _u.mutation.AddedStatus(); ok { _spec.AddField(notification.FieldStatus, field.TypeInt8, value) } - if value, ok := nuo.mutation.CategoryID(); ok { + if value, ok := _u.mutation.CategoryID(); ok { _spec.SetField(notification.FieldCategoryID, field.TypeInt64, value) } - if value, ok := nuo.mutation.AddedCategoryID(); ok { + if value, ok := _u.mutation.AddedCategoryID(); ok { _spec.AddField(notification.FieldCategoryID, field.TypeInt64, value) } - _spec.AddModifiers(nuo.modifiers...) - _node = &Notification{config: nuo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Notification{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, nuo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{notification.Label} } else if sqlgraph.IsConstraintError(err) { @@ -569,7 +569,7 @@ func (nuo *NotificationUpdateOne) sqlSave(ctx context.Context) (_node *Notificat } return nil, err } - nuo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/permission.go b/internal/data/entity/ent/permission.go index d2a28ce4..6b0784e9 100644 --- a/internal/data/entity/ent/permission.go +++ b/internal/data/entity/ent/permission.go @@ -136,7 +136,7 @@ func (*Permission) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Permission fields. -func (pe *Permission) assignValues(columns []string, values []any) error { +func (_m *Permission) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -147,48 +147,48 @@ func (pe *Permission) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - pe.ID = int64(value.Int64) + _m.ID = int64(value.Int64) case permission.FieldCreateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field create_time", values[i]) } else if value.Valid { - pe.CreateTime = value.Time + _m.CreateTime = value.Time } case permission.FieldUpdateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field update_time", values[i]) } else if value.Valid { - pe.UpdateTime = value.Time + _m.UpdateTime = value.Time } case permission.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { - pe.Name = value.String + _m.Name = value.String } case permission.FieldKeyword: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field keyword", values[i]) } else if value.Valid { - pe.Keyword = value.String + _m.Keyword = value.String } case permission.FieldDescription: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field description", values[i]) } else if value.Valid { - pe.Description = value.String + _m.Description = value.String } case permission.FieldDataScope: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field data_scope", values[i]) } else if value.Valid { - pe.DataScope = value.String + _m.DataScope = value.String } case permission.FieldDataRules: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field data_rules", values[i]) } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &pe.DataRules); err != nil { + if err := json.Unmarshal(*value, &_m.DataRules); err != nil { return fmt.Errorf("unmarshal field data_rules: %w", err) } } @@ -196,10 +196,10 @@ func (pe *Permission) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field actions", values[i]) } else if value.Valid { - pe.Actions = permission.Actions(value.String) + _m.Actions = permission.Actions(value.String) } default: - pe.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -207,86 +207,86 @@ func (pe *Permission) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Permission. // This includes values selected through modifiers, order, etc. -func (pe *Permission) Value(name string) (ent.Value, error) { - return pe.selectValues.Get(name) +func (_m *Permission) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryRoles queries the "roles" edge of the Permission entity. -func (pe *Permission) QueryRoles() *RoleQuery { - return NewPermissionClient(pe.config).QueryRoles(pe) +func (_m *Permission) QueryRoles() *RoleQuery { + return NewPermissionClient(_m.config).QueryRoles(_m) } // QueryPositions queries the "positions" edge of the Permission entity. -func (pe *Permission) QueryPositions() *PositionQuery { - return NewPermissionClient(pe.config).QueryPositions(pe) +func (_m *Permission) QueryPositions() *PositionQuery { + return NewPermissionClient(_m.config).QueryPositions(_m) } // QueryResources queries the "resources" edge of the Permission entity. -func (pe *Permission) QueryResources() *ResourceQuery { - return NewPermissionClient(pe.config).QueryResources(pe) +func (_m *Permission) QueryResources() *ResourceQuery { + return NewPermissionClient(_m.config).QueryResources(_m) } // QueryRolePermissions queries the "role_permissions" edge of the Permission entity. -func (pe *Permission) QueryRolePermissions() *RolePermissionQuery { - return NewPermissionClient(pe.config).QueryRolePermissions(pe) +func (_m *Permission) QueryRolePermissions() *RolePermissionQuery { + return NewPermissionClient(_m.config).QueryRolePermissions(_m) } // QueryPositionPermissions queries the "position_permissions" edge of the Permission entity. -func (pe *Permission) QueryPositionPermissions() *PositionPermissionQuery { - return NewPermissionClient(pe.config).QueryPositionPermissions(pe) +func (_m *Permission) QueryPositionPermissions() *PositionPermissionQuery { + return NewPermissionClient(_m.config).QueryPositionPermissions(_m) } // QueryPermissionResources queries the "permission_resources" edge of the Permission entity. -func (pe *Permission) QueryPermissionResources() *PermissionResourceQuery { - return NewPermissionClient(pe.config).QueryPermissionResources(pe) +func (_m *Permission) QueryPermissionResources() *PermissionResourceQuery { + return NewPermissionClient(_m.config).QueryPermissionResources(_m) } // Update returns a builder for updating this Permission. // Note that you need to call Permission.Unwrap() before calling this method if this Permission // was returned from a transaction, and the transaction was committed or rolled back. -func (pe *Permission) Update() *PermissionUpdateOne { - return NewPermissionClient(pe.config).UpdateOne(pe) +func (_m *Permission) Update() *PermissionUpdateOne { + return NewPermissionClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Permission entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (pe *Permission) Unwrap() *Permission { - _tx, ok := pe.config.driver.(*txDriver) +func (_m *Permission) Unwrap() *Permission { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Permission is not a transactional entity") } - pe.config.driver = _tx.drv - return pe + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (pe *Permission) String() string { +func (_m *Permission) String() string { var builder strings.Builder builder.WriteString("Permission(") - builder.WriteString(fmt.Sprintf("id=%v, ", pe.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("create_time=") - builder.WriteString(pe.CreateTime.Format(time.ANSIC)) + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("update_time=") - builder.WriteString(pe.UpdateTime.Format(time.ANSIC)) + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("name=") - builder.WriteString(pe.Name) + builder.WriteString(_m.Name) builder.WriteString(", ") builder.WriteString("keyword=") - builder.WriteString(pe.Keyword) + builder.WriteString(_m.Keyword) builder.WriteString(", ") builder.WriteString("description=") - builder.WriteString(pe.Description) + builder.WriteString(_m.Description) builder.WriteString(", ") builder.WriteString("data_scope=") - builder.WriteString(pe.DataScope) + builder.WriteString(_m.DataScope) builder.WriteString(", ") builder.WriteString("data_rules=") - builder.WriteString(fmt.Sprintf("%v", pe.DataRules)) + builder.WriteString(fmt.Sprintf("%v", _m.DataRules)) builder.WriteString(", ") builder.WriteString("actions=") - builder.WriteString(fmt.Sprintf("%v", pe.Actions)) + builder.WriteString(fmt.Sprintf("%v", _m.Actions)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/permission_create.go b/internal/data/entity/ent/permission_create.go index f1504abc..f13dabca 100644 --- a/internal/data/entity/ent/permission_create.go +++ b/internal/data/entity/ent/permission_create.go @@ -27,219 +27,219 @@ type PermissionCreate struct { } // SetCreateTime sets the "create_time" field. -func (pc *PermissionCreate) SetCreateTime(t time.Time) *PermissionCreate { - pc.mutation.SetCreateTime(t) - return pc +func (_c *PermissionCreate) SetCreateTime(v time.Time) *PermissionCreate { + _c.mutation.SetCreateTime(v) + return _c } // SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (pc *PermissionCreate) SetNillableCreateTime(t *time.Time) *PermissionCreate { - if t != nil { - pc.SetCreateTime(*t) +func (_c *PermissionCreate) SetNillableCreateTime(v *time.Time) *PermissionCreate { + if v != nil { + _c.SetCreateTime(*v) } - return pc + return _c } // SetUpdateTime sets the "update_time" field. -func (pc *PermissionCreate) SetUpdateTime(t time.Time) *PermissionCreate { - pc.mutation.SetUpdateTime(t) - return pc +func (_c *PermissionCreate) SetUpdateTime(v time.Time) *PermissionCreate { + _c.mutation.SetUpdateTime(v) + return _c } // SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (pc *PermissionCreate) SetNillableUpdateTime(t *time.Time) *PermissionCreate { - if t != nil { - pc.SetUpdateTime(*t) +func (_c *PermissionCreate) SetNillableUpdateTime(v *time.Time) *PermissionCreate { + if v != nil { + _c.SetUpdateTime(*v) } - return pc + return _c } // SetName sets the "name" field. -func (pc *PermissionCreate) SetName(s string) *PermissionCreate { - pc.mutation.SetName(s) - return pc +func (_c *PermissionCreate) SetName(v string) *PermissionCreate { + _c.mutation.SetName(v) + return _c } // SetNillableName sets the "name" field if the given value is not nil. -func (pc *PermissionCreate) SetNillableName(s *string) *PermissionCreate { - if s != nil { - pc.SetName(*s) +func (_c *PermissionCreate) SetNillableName(v *string) *PermissionCreate { + if v != nil { + _c.SetName(*v) } - return pc + return _c } // SetKeyword sets the "keyword" field. -func (pc *PermissionCreate) SetKeyword(s string) *PermissionCreate { - pc.mutation.SetKeyword(s) - return pc +func (_c *PermissionCreate) SetKeyword(v string) *PermissionCreate { + _c.mutation.SetKeyword(v) + return _c } // SetDescription sets the "description" field. -func (pc *PermissionCreate) SetDescription(s string) *PermissionCreate { - pc.mutation.SetDescription(s) - return pc +func (_c *PermissionCreate) SetDescription(v string) *PermissionCreate { + _c.mutation.SetDescription(v) + return _c } // SetNillableDescription sets the "description" field if the given value is not nil. -func (pc *PermissionCreate) SetNillableDescription(s *string) *PermissionCreate { - if s != nil { - pc.SetDescription(*s) +func (_c *PermissionCreate) SetNillableDescription(v *string) *PermissionCreate { + if v != nil { + _c.SetDescription(*v) } - return pc + return _c } // SetDataScope sets the "data_scope" field. -func (pc *PermissionCreate) SetDataScope(s string) *PermissionCreate { - pc.mutation.SetDataScope(s) - return pc +func (_c *PermissionCreate) SetDataScope(v string) *PermissionCreate { + _c.mutation.SetDataScope(v) + return _c } // SetNillableDataScope sets the "data_scope" field if the given value is not nil. -func (pc *PermissionCreate) SetNillableDataScope(s *string) *PermissionCreate { - if s != nil { - pc.SetDataScope(*s) +func (_c *PermissionCreate) SetNillableDataScope(v *string) *PermissionCreate { + if v != nil { + _c.SetDataScope(*v) } - return pc + return _c } // SetDataRules sets the "data_rules" field. -func (pc *PermissionCreate) SetDataRules(m map[string]string) *PermissionCreate { - pc.mutation.SetDataRules(m) - return pc +func (_c *PermissionCreate) SetDataRules(v map[string]string) *PermissionCreate { + _c.mutation.SetDataRules(v) + return _c } // SetActions sets the "actions" field. -func (pc *PermissionCreate) SetActions(pe permission.Actions) *PermissionCreate { - pc.mutation.SetActions(pe) - return pc +func (_c *PermissionCreate) SetActions(v permission.Actions) *PermissionCreate { + _c.mutation.SetActions(v) + return _c } // SetNillableActions sets the "actions" field if the given value is not nil. -func (pc *PermissionCreate) SetNillableActions(pe *permission.Actions) *PermissionCreate { - if pe != nil { - pc.SetActions(*pe) +func (_c *PermissionCreate) SetNillableActions(v *permission.Actions) *PermissionCreate { + if v != nil { + _c.SetActions(*v) } - return pc + return _c } // SetID sets the "id" field. -func (pc *PermissionCreate) SetID(i int64) *PermissionCreate { - pc.mutation.SetID(i) - return pc +func (_c *PermissionCreate) SetID(v int64) *PermissionCreate { + _c.mutation.SetID(v) + return _c } // SetNillableID sets the "id" field if the given value is not nil. -func (pc *PermissionCreate) SetNillableID(i *int64) *PermissionCreate { - if i != nil { - pc.SetID(*i) +func (_c *PermissionCreate) SetNillableID(v *int64) *PermissionCreate { + if v != nil { + _c.SetID(*v) } - return pc + return _c } // AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (pc *PermissionCreate) AddRoleIDs(ids ...int64) *PermissionCreate { - pc.mutation.AddRoleIDs(ids...) - return pc +func (_c *PermissionCreate) AddRoleIDs(ids ...int64) *PermissionCreate { + _c.mutation.AddRoleIDs(ids...) + return _c } // AddRoles adds the "roles" edges to the Role entity. -func (pc *PermissionCreate) AddRoles(r ...*Role) *PermissionCreate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_c *PermissionCreate) AddRoles(v ...*Role) *PermissionCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddRoleIDs(ids...) + return _c.AddRoleIDs(ids...) } // AddPositionIDs adds the "positions" edge to the Position entity by IDs. -func (pc *PermissionCreate) AddPositionIDs(ids ...int64) *PermissionCreate { - pc.mutation.AddPositionIDs(ids...) - return pc +func (_c *PermissionCreate) AddPositionIDs(ids ...int64) *PermissionCreate { + _c.mutation.AddPositionIDs(ids...) + return _c } // AddPositions adds the "positions" edges to the Position entity. -func (pc *PermissionCreate) AddPositions(p ...*Position) *PermissionCreate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *PermissionCreate) AddPositions(v ...*Position) *PermissionCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddPositionIDs(ids...) + return _c.AddPositionIDs(ids...) } // AddResourceIDs adds the "resources" edge to the Resource entity by IDs. -func (pc *PermissionCreate) AddResourceIDs(ids ...int64) *PermissionCreate { - pc.mutation.AddResourceIDs(ids...) - return pc +func (_c *PermissionCreate) AddResourceIDs(ids ...int64) *PermissionCreate { + _c.mutation.AddResourceIDs(ids...) + return _c } // AddResources adds the "resources" edges to the Resource entity. -func (pc *PermissionCreate) AddResources(r ...*Resource) *PermissionCreate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_c *PermissionCreate) AddResources(v ...*Resource) *PermissionCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddResourceIDs(ids...) + return _c.AddResourceIDs(ids...) } // AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (pc *PermissionCreate) AddRolePermissionIDs(ids ...int) *PermissionCreate { - pc.mutation.AddRolePermissionIDs(ids...) - return pc +func (_c *PermissionCreate) AddRolePermissionIDs(ids ...int) *PermissionCreate { + _c.mutation.AddRolePermissionIDs(ids...) + return _c } // AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (pc *PermissionCreate) AddRolePermissions(r ...*RolePermission) *PermissionCreate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_c *PermissionCreate) AddRolePermissions(v ...*RolePermission) *PermissionCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddRolePermissionIDs(ids...) + return _c.AddRolePermissionIDs(ids...) } // AddPositionPermissionIDs adds the "position_permissions" edge to the PositionPermission entity by IDs. -func (pc *PermissionCreate) AddPositionPermissionIDs(ids ...int) *PermissionCreate { - pc.mutation.AddPositionPermissionIDs(ids...) - return pc +func (_c *PermissionCreate) AddPositionPermissionIDs(ids ...int) *PermissionCreate { + _c.mutation.AddPositionPermissionIDs(ids...) + return _c } // AddPositionPermissions adds the "position_permissions" edges to the PositionPermission entity. -func (pc *PermissionCreate) AddPositionPermissions(p ...*PositionPermission) *PermissionCreate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *PermissionCreate) AddPositionPermissions(v ...*PositionPermission) *PermissionCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddPositionPermissionIDs(ids...) + return _c.AddPositionPermissionIDs(ids...) } // AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (pc *PermissionCreate) AddPermissionResourceIDs(ids ...int) *PermissionCreate { - pc.mutation.AddPermissionResourceIDs(ids...) - return pc +func (_c *PermissionCreate) AddPermissionResourceIDs(ids ...int) *PermissionCreate { + _c.mutation.AddPermissionResourceIDs(ids...) + return _c } // AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (pc *PermissionCreate) AddPermissionResources(p ...*PermissionResource) *PermissionCreate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *PermissionCreate) AddPermissionResources(v ...*PermissionResource) *PermissionCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddPermissionResourceIDs(ids...) + return _c.AddPermissionResourceIDs(ids...) } // Mutation returns the PermissionMutation object of the builder. -func (pc *PermissionCreate) Mutation() *PermissionMutation { - return pc.mutation +func (_c *PermissionCreate) Mutation() *PermissionMutation { + return _c.mutation } // Save creates the Permission in the database. -func (pc *PermissionCreate) Save(ctx context.Context) (*Permission, error) { - pc.defaults() - return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) +func (_c *PermissionCreate) Save(ctx context.Context) (*Permission, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (pc *PermissionCreate) SaveX(ctx context.Context) *Permission { - v, err := pc.Save(ctx) +func (_c *PermissionCreate) SaveX(ctx context.Context) *Permission { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -247,94 +247,94 @@ func (pc *PermissionCreate) SaveX(ctx context.Context) *Permission { } // Exec executes the query. -func (pc *PermissionCreate) Exec(ctx context.Context) error { - _, err := pc.Save(ctx) +func (_c *PermissionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pc *PermissionCreate) ExecX(ctx context.Context) { - if err := pc.Exec(ctx); err != nil { +func (_c *PermissionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (pc *PermissionCreate) defaults() { - if _, ok := pc.mutation.CreateTime(); !ok { +func (_c *PermissionCreate) defaults() { + if _, ok := _c.mutation.CreateTime(); !ok { v := permission.DefaultCreateTime() - pc.mutation.SetCreateTime(v) + _c.mutation.SetCreateTime(v) } - if _, ok := pc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { v := permission.DefaultUpdateTime() - pc.mutation.SetUpdateTime(v) + _c.mutation.SetUpdateTime(v) } - if _, ok := pc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { v := permission.DefaultName - pc.mutation.SetName(v) + _c.mutation.SetName(v) } - if _, ok := pc.mutation.Description(); !ok { + if _, ok := _c.mutation.Description(); !ok { v := permission.DefaultDescription - pc.mutation.SetDescription(v) + _c.mutation.SetDescription(v) } - if _, ok := pc.mutation.DataScope(); !ok { + if _, ok := _c.mutation.DataScope(); !ok { v := permission.DefaultDataScope - pc.mutation.SetDataScope(v) + _c.mutation.SetDataScope(v) } - if _, ok := pc.mutation.Actions(); !ok { + if _, ok := _c.mutation.Actions(); !ok { v := permission.DefaultActions - pc.mutation.SetActions(v) + _c.mutation.SetActions(v) } - if _, ok := pc.mutation.ID(); !ok { + if _, ok := _c.mutation.ID(); !ok { v := permission.DefaultID() - pc.mutation.SetID(v) + _c.mutation.SetID(v) } } // check runs all checks and user-defined validators on the builder. -func (pc *PermissionCreate) check() error { - if _, ok := pc.mutation.CreateTime(); !ok { +func (_c *PermissionCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Permission.create_time"`)} } - if _, ok := pc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Permission.update_time"`)} } - if _, ok := pc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Permission.name"`)} } - if v, ok := pc.mutation.Name(); ok { + if v, ok := _c.mutation.Name(); ok { if err := permission.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Permission.name": %w`, err)} } } - if _, ok := pc.mutation.Keyword(); !ok { + if _, ok := _c.mutation.Keyword(); !ok { return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Permission.keyword"`)} } - if v, ok := pc.mutation.Keyword(); ok { + if v, ok := _c.mutation.Keyword(); ok { if err := permission.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Permission.keyword": %w`, err)} } } - if _, ok := pc.mutation.Description(); !ok { + if _, ok := _c.mutation.Description(); !ok { return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Permission.description"`)} } - if v, ok := pc.mutation.Description(); ok { + if v, ok := _c.mutation.Description(); ok { if err := permission.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} } } - if _, ok := pc.mutation.DataScope(); !ok { + if _, ok := _c.mutation.DataScope(); !ok { return &ValidationError{Name: "data_scope", err: errors.New(`ent: missing required field "Permission.data_scope"`)} } - if _, ok := pc.mutation.Actions(); !ok { + if _, ok := _c.mutation.Actions(); !ok { return &ValidationError{Name: "actions", err: errors.New(`ent: missing required field "Permission.actions"`)} } - if v, ok := pc.mutation.Actions(); ok { + if v, ok := _c.mutation.Actions(); ok { if err := permission.ActionsValidator(v); err != nil { return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} } } - if v, ok := pc.mutation.ID(); ok { + if v, ok := _c.mutation.ID(); ok { if err := permission.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Permission.id": %w`, err)} } @@ -342,12 +342,12 @@ func (pc *PermissionCreate) check() error { return nil } -func (pc *PermissionCreate) sqlSave(ctx context.Context) (*Permission, error) { - if err := pc.check(); err != nil { +func (_c *PermissionCreate) sqlSave(ctx context.Context) (*Permission, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := pc.createSpec() - if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -357,53 +357,53 @@ func (pc *PermissionCreate) sqlSave(ctx context.Context) (*Permission, error) { id := _spec.ID.Value.(int64) _node.ID = int64(id) } - pc.mutation.id = &_node.ID - pc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (pc *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { +func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { var ( - _node = &Permission{config: pc.config} + _node = &Permission{config: _c.config} _spec = sqlgraph.NewCreateSpec(permission.Table, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) ) - if id, ok := pc.mutation.ID(); ok { + if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } - if value, ok := pc.mutation.CreateTime(); ok { + if value, ok := _c.mutation.CreateTime(); ok { _spec.SetField(permission.FieldCreateTime, field.TypeTime, value) _node.CreateTime = value } - if value, ok := pc.mutation.UpdateTime(); ok { + if value, ok := _c.mutation.UpdateTime(); ok { _spec.SetField(permission.FieldUpdateTime, field.TypeTime, value) _node.UpdateTime = value } - if value, ok := pc.mutation.Name(); ok { + if value, ok := _c.mutation.Name(); ok { _spec.SetField(permission.FieldName, field.TypeString, value) _node.Name = value } - if value, ok := pc.mutation.Keyword(); ok { + if value, ok := _c.mutation.Keyword(); ok { _spec.SetField(permission.FieldKeyword, field.TypeString, value) _node.Keyword = value } - if value, ok := pc.mutation.Description(); ok { + if value, ok := _c.mutation.Description(); ok { _spec.SetField(permission.FieldDescription, field.TypeString, value) _node.Description = value } - if value, ok := pc.mutation.DataScope(); ok { + if value, ok := _c.mutation.DataScope(); ok { _spec.SetField(permission.FieldDataScope, field.TypeString, value) _node.DataScope = value } - if value, ok := pc.mutation.DataRules(); ok { + if value, ok := _c.mutation.DataRules(); ok { _spec.SetField(permission.FieldDataRules, field.TypeJSON, value) _node.DataRules = value } - if value, ok := pc.mutation.Actions(); ok { + if value, ok := _c.mutation.Actions(); ok { _spec.SetField(permission.FieldActions, field.TypeEnum, value) _node.Actions = value } - if nodes := pc.mutation.RolesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.RolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -419,7 +419,7 @@ func (pc *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := pc.mutation.PositionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -435,7 +435,7 @@ func (pc *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := pc.mutation.ResourcesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -451,7 +451,7 @@ func (pc *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := pc.mutation.RolePermissionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.RolePermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -467,7 +467,7 @@ func (pc *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := pc.mutation.PositionPermissionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PositionPermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -483,7 +483,7 @@ func (pc *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := pc.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PermissionResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -503,23 +503,23 @@ func (pc *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { } // SetPermission set the Permission -func (pc *PermissionCreate) SetPermission(input *Permission, fields ...string) *PermissionCreate { - m := pc.mutation +func (_c *PermissionCreate) SetPermission(input *Permission, fields ...string) *PermissionCreate { + m := _c.mutation if len(fields) == 0 { fields = permission.Columns } _ = m.SetFields(input, fields...) - return pc + return _c } // SetPermissionWithZero set the Permission -func (pc *PermissionCreate) SetPermissionWithZero(input *Permission, fields ...string) *PermissionCreate { - m := pc.mutation +func (_c *PermissionCreate) SetPermissionWithZero(input *Permission, fields ...string) *PermissionCreate { + m := _c.mutation if len(fields) == 0 { fields = permission.Columns } _ = m.SetFieldsWithZero(input, fields...) - return pc + return _c } // PermissionCreateBulk is the builder for creating many Permission entities in bulk. @@ -530,16 +530,16 @@ type PermissionCreateBulk struct { } // Save creates the Permission entities in the database. -func (pcb *PermissionCreateBulk) Save(ctx context.Context) ([]*Permission, error) { - if pcb.err != nil { - return nil, pcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) - nodes := make([]*Permission, len(pcb.builders)) - mutators := make([]Mutator, len(pcb.builders)) - for i := range pcb.builders { +func (_c *PermissionCreateBulk) Save(ctx context.Context) ([]*Permission, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Permission, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := pcb.builders[i] + builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*PermissionMutation) @@ -553,11 +553,11 @@ func (pcb *PermissionCreateBulk) Save(ctx context.Context) ([]*Permission, error var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -581,7 +581,7 @@ func (pcb *PermissionCreateBulk) Save(ctx context.Context) ([]*Permission, error }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, pcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -589,8 +589,8 @@ func (pcb *PermissionCreateBulk) Save(ctx context.Context) ([]*Permission, error } // SaveX is like Save, but panics if an error occurs. -func (pcb *PermissionCreateBulk) SaveX(ctx context.Context) []*Permission { - v, err := pcb.Save(ctx) +func (_c *PermissionCreateBulk) SaveX(ctx context.Context) []*Permission { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -598,14 +598,14 @@ func (pcb *PermissionCreateBulk) SaveX(ctx context.Context) []*Permission { } // Exec executes the query. -func (pcb *PermissionCreateBulk) Exec(ctx context.Context) error { - _, err := pcb.Save(ctx) +func (_c *PermissionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pcb *PermissionCreateBulk) ExecX(ctx context.Context) { - if err := pcb.Exec(ctx); err != nil { +func (_c *PermissionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/permission_delete.go b/internal/data/entity/ent/permission_delete.go index 5f02f37b..68fc66b6 100644 --- a/internal/data/entity/ent/permission_delete.go +++ b/internal/data/entity/ent/permission_delete.go @@ -20,56 +20,56 @@ type PermissionDelete struct { } // Where appends a list predicates to the PermissionDelete builder. -func (pd *PermissionDelete) Where(ps ...predicate.Permission) *PermissionDelete { - pd.mutation.Where(ps...) - return pd +func (_d *PermissionDelete) Where(ps ...predicate.Permission) *PermissionDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (pd *PermissionDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) +func (_d *PermissionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (pd *PermissionDelete) ExecX(ctx context.Context) int { - n, err := pd.Exec(ctx) +func (_d *PermissionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (pd *PermissionDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *PermissionDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(permission.Table, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) - if ps := pd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, pd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - pd.mutation.done = true + _d.mutation.done = true return affected, err } // PermissionDeleteOne is the builder for deleting a single Permission entity. type PermissionDeleteOne struct { - pd *PermissionDelete + _d *PermissionDelete } // Where appends a list predicates to the PermissionDelete builder. -func (pdo *PermissionDeleteOne) Where(ps ...predicate.Permission) *PermissionDeleteOne { - pdo.pd.mutation.Where(ps...) - return pdo +func (_d *PermissionDeleteOne) Where(ps ...predicate.Permission) *PermissionDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (pdo *PermissionDeleteOne) Exec(ctx context.Context) error { - n, err := pdo.pd.Exec(ctx) +func (_d *PermissionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (pdo *PermissionDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (pdo *PermissionDeleteOne) ExecX(ctx context.Context) { - if err := pdo.Exec(ctx); err != nil { +func (_d *PermissionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/permission_query.go b/internal/data/entity/ent/permission_query.go index 8cc24de7..7bc8ba03 100644 --- a/internal/data/entity/ent/permission_query.go +++ b/internal/data/entity/ent/permission_query.go @@ -43,44 +43,44 @@ type PermissionQuery struct { } // Where adds a new predicate for the PermissionQuery builder. -func (pq *PermissionQuery) Where(ps ...predicate.Permission) *PermissionQuery { - pq.predicates = append(pq.predicates, ps...) - return pq +func (_q *PermissionQuery) Where(ps ...predicate.Permission) *PermissionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (pq *PermissionQuery) Limit(limit int) *PermissionQuery { - pq.ctx.Limit = &limit - return pq +func (_q *PermissionQuery) Limit(limit int) *PermissionQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (pq *PermissionQuery) Offset(offset int) *PermissionQuery { - pq.ctx.Offset = &offset - return pq +func (_q *PermissionQuery) Offset(offset int) *PermissionQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (pq *PermissionQuery) Unique(unique bool) *PermissionQuery { - pq.ctx.Unique = &unique - return pq +func (_q *PermissionQuery) Unique(unique bool) *PermissionQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (pq *PermissionQuery) Order(o ...permission.OrderOption) *PermissionQuery { - pq.order = append(pq.order, o...) - return pq +func (_q *PermissionQuery) Order(o ...permission.OrderOption) *PermissionQuery { + _q.order = append(_q.order, o...) + return _q } // QueryRoles chains the current query on the "roles" edge. -func (pq *PermissionQuery) QueryRoles() *RoleQuery { - query := (&RoleClient{config: pq.config}).Query() +func (_q *PermissionQuery) QueryRoles() *RoleQuery { + query := (&RoleClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -89,20 +89,20 @@ func (pq *PermissionQuery) QueryRoles() *RoleQuery { sqlgraph.To(role.Table, role.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, permission.RolesTable, permission.RolesPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPositions chains the current query on the "positions" edge. -func (pq *PermissionQuery) QueryPositions() *PositionQuery { - query := (&PositionClient{config: pq.config}).Query() +func (_q *PermissionQuery) QueryPositions() *PositionQuery { + query := (&PositionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -111,20 +111,20 @@ func (pq *PermissionQuery) QueryPositions() *PositionQuery { sqlgraph.To(position.Table, position.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, permission.PositionsTable, permission.PositionsPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryResources chains the current query on the "resources" edge. -func (pq *PermissionQuery) QueryResources() *ResourceQuery { - query := (&ResourceClient{config: pq.config}).Query() +func (_q *PermissionQuery) QueryResources() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -133,20 +133,20 @@ func (pq *PermissionQuery) QueryResources() *ResourceQuery { sqlgraph.To(resource.Table, resource.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, permission.ResourcesTable, permission.ResourcesPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryRolePermissions chains the current query on the "role_permissions" edge. -func (pq *PermissionQuery) QueryRolePermissions() *RolePermissionQuery { - query := (&RolePermissionClient{config: pq.config}).Query() +func (_q *PermissionQuery) QueryRolePermissions() *RolePermissionQuery { + query := (&RolePermissionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -155,20 +155,20 @@ func (pq *PermissionQuery) QueryRolePermissions() *RolePermissionQuery { sqlgraph.To(rolepermission.Table, rolepermission.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, permission.RolePermissionsTable, permission.RolePermissionsColumn), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPositionPermissions chains the current query on the "position_permissions" edge. -func (pq *PermissionQuery) QueryPositionPermissions() *PositionPermissionQuery { - query := (&PositionPermissionClient{config: pq.config}).Query() +func (_q *PermissionQuery) QueryPositionPermissions() *PositionPermissionQuery { + query := (&PositionPermissionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -177,20 +177,20 @@ func (pq *PermissionQuery) QueryPositionPermissions() *PositionPermissionQuery { sqlgraph.To(positionpermission.Table, positionpermission.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, permission.PositionPermissionsTable, permission.PositionPermissionsColumn), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPermissionResources chains the current query on the "permission_resources" edge. -func (pq *PermissionQuery) QueryPermissionResources() *PermissionResourceQuery { - query := (&PermissionResourceClient{config: pq.config}).Query() +func (_q *PermissionQuery) QueryPermissionResources() *PermissionResourceQuery { + query := (&PermissionResourceClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -199,7 +199,7 @@ func (pq *PermissionQuery) QueryPermissionResources() *PermissionResourceQuery { sqlgraph.To(permissionresource.Table, permissionresource.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, permission.PermissionResourcesTable, permission.PermissionResourcesColumn), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -207,8 +207,8 @@ func (pq *PermissionQuery) QueryPermissionResources() *PermissionResourceQuery { // First returns the first Permission entity from the query. // Returns a *NotFoundError when no Permission was found. -func (pq *PermissionQuery) First(ctx context.Context) (*Permission, error) { - nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, ent.OpQueryFirst)) +func (_q *PermissionQuery) First(ctx context.Context) (*Permission, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -219,8 +219,8 @@ func (pq *PermissionQuery) First(ctx context.Context) (*Permission, error) { } // FirstX is like First, but panics if an error occurs. -func (pq *PermissionQuery) FirstX(ctx context.Context) *Permission { - node, err := pq.First(ctx) +func (_q *PermissionQuery) FirstX(ctx context.Context) *Permission { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -229,9 +229,9 @@ func (pq *PermissionQuery) FirstX(ctx context.Context) *Permission { // FirstID returns the first Permission ID from the query. // Returns a *NotFoundError when no Permission ID was found. -func (pq *PermissionQuery) FirstID(ctx context.Context) (id int64, err error) { +func (_q *PermissionQuery) FirstID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -242,8 +242,8 @@ func (pq *PermissionQuery) FirstID(ctx context.Context) (id int64, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (pq *PermissionQuery) FirstIDX(ctx context.Context) int64 { - id, err := pq.FirstID(ctx) +func (_q *PermissionQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -253,8 +253,8 @@ func (pq *PermissionQuery) FirstIDX(ctx context.Context) int64 { // Only returns a single Permission entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Permission entity is found. // Returns a *NotFoundError when no Permission entities are found. -func (pq *PermissionQuery) Only(ctx context.Context) (*Permission, error) { - nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, ent.OpQueryOnly)) +func (_q *PermissionQuery) Only(ctx context.Context) (*Permission, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -269,8 +269,8 @@ func (pq *PermissionQuery) Only(ctx context.Context) (*Permission, error) { } // OnlyX is like Only, but panics if an error occurs. -func (pq *PermissionQuery) OnlyX(ctx context.Context) *Permission { - node, err := pq.Only(ctx) +func (_q *PermissionQuery) OnlyX(ctx context.Context) *Permission { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -280,9 +280,9 @@ func (pq *PermissionQuery) OnlyX(ctx context.Context) *Permission { // OnlyID is like Only, but returns the only Permission ID in the query. // Returns a *NotSingularError when more than one Permission ID is found. // Returns a *NotFoundError when no entities are found. -func (pq *PermissionQuery) OnlyID(ctx context.Context) (id int64, err error) { +func (_q *PermissionQuery) OnlyID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -297,8 +297,8 @@ func (pq *PermissionQuery) OnlyID(ctx context.Context) (id int64, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (pq *PermissionQuery) OnlyIDX(ctx context.Context) int64 { - id, err := pq.OnlyID(ctx) +func (_q *PermissionQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -306,18 +306,18 @@ func (pq *PermissionQuery) OnlyIDX(ctx context.Context) int64 { } // All executes the query and returns a list of Permissions. -func (pq *PermissionQuery) All(ctx context.Context) ([]*Permission, error) { - ctx = setContextOp(ctx, pq.ctx, ent.OpQueryAll) - if err := pq.prepareQuery(ctx); err != nil { +func (_q *PermissionQuery) All(ctx context.Context) ([]*Permission, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Permission, *PermissionQuery]() - return withInterceptors[[]*Permission](ctx, pq, qr, pq.inters) + return withInterceptors[[]*Permission](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (pq *PermissionQuery) AllX(ctx context.Context) []*Permission { - nodes, err := pq.All(ctx) +func (_q *PermissionQuery) AllX(ctx context.Context) []*Permission { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -325,20 +325,20 @@ func (pq *PermissionQuery) AllX(ctx context.Context) []*Permission { } // IDs executes the query and returns a list of Permission IDs. -func (pq *PermissionQuery) IDs(ctx context.Context) (ids []int64, err error) { - if pq.ctx.Unique == nil && pq.path != nil { - pq.Unique(true) +func (_q *PermissionQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, pq.ctx, ent.OpQueryIDs) - if err = pq.Select(permission.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(permission.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (pq *PermissionQuery) IDsX(ctx context.Context) []int64 { - ids, err := pq.IDs(ctx) +func (_q *PermissionQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -346,17 +346,17 @@ func (pq *PermissionQuery) IDsX(ctx context.Context) []int64 { } // Count returns the count of the given query. -func (pq *PermissionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, pq.ctx, ent.OpQueryCount) - if err := pq.prepareQuery(ctx); err != nil { +func (_q *PermissionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, pq, querierCount[*PermissionQuery](), pq.inters) + return withInterceptors[int](ctx, _q, querierCount[*PermissionQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (pq *PermissionQuery) CountX(ctx context.Context) int { - count, err := pq.Count(ctx) +func (_q *PermissionQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -364,9 +364,9 @@ func (pq *PermissionQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (pq *PermissionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, pq.ctx, ent.OpQueryExist) - switch _, err := pq.FirstID(ctx); { +func (_q *PermissionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -377,8 +377,8 @@ func (pq *PermissionQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (pq *PermissionQuery) ExistX(ctx context.Context) bool { - exist, err := pq.Exist(ctx) +func (_q *PermissionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -387,93 +387,93 @@ func (pq *PermissionQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the PermissionQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (pq *PermissionQuery) Clone() *PermissionQuery { - if pq == nil { +func (_q *PermissionQuery) Clone() *PermissionQuery { + if _q == nil { return nil } return &PermissionQuery{ - config: pq.config, - ctx: pq.ctx.Clone(), - order: append([]permission.OrderOption{}, pq.order...), - inters: append([]Interceptor{}, pq.inters...), - predicates: append([]predicate.Permission{}, pq.predicates...), - withRoles: pq.withRoles.Clone(), - withPositions: pq.withPositions.Clone(), - withResources: pq.withResources.Clone(), - withRolePermissions: pq.withRolePermissions.Clone(), - withPositionPermissions: pq.withPositionPermissions.Clone(), - withPermissionResources: pq.withPermissionResources.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]permission.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Permission{}, _q.predicates...), + withRoles: _q.withRoles.Clone(), + withPositions: _q.withPositions.Clone(), + withResources: _q.withResources.Clone(), + withRolePermissions: _q.withRolePermissions.Clone(), + withPositionPermissions: _q.withPositionPermissions.Clone(), + withPermissionResources: _q.withPermissionResources.Clone(), // clone intermediate query. - sql: pq.sql.Clone(), - path: pq.path, - modifiers: append([]func(*sql.Selector){}, pq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithRoles tells the query-builder to eager-load the nodes that are connected to // the "roles" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PermissionQuery) WithRoles(opts ...func(*RoleQuery)) *PermissionQuery { - query := (&RoleClient{config: pq.config}).Query() +func (_q *PermissionQuery) WithRoles(opts ...func(*RoleQuery)) *PermissionQuery { + query := (&RoleClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withRoles = query - return pq + _q.withRoles = query + return _q } // WithPositions tells the query-builder to eager-load the nodes that are connected to // the "positions" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PermissionQuery) WithPositions(opts ...func(*PositionQuery)) *PermissionQuery { - query := (&PositionClient{config: pq.config}).Query() +func (_q *PermissionQuery) WithPositions(opts ...func(*PositionQuery)) *PermissionQuery { + query := (&PositionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withPositions = query - return pq + _q.withPositions = query + return _q } // WithResources tells the query-builder to eager-load the nodes that are connected to // the "resources" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PermissionQuery) WithResources(opts ...func(*ResourceQuery)) *PermissionQuery { - query := (&ResourceClient{config: pq.config}).Query() +func (_q *PermissionQuery) WithResources(opts ...func(*ResourceQuery)) *PermissionQuery { + query := (&ResourceClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withResources = query - return pq + _q.withResources = query + return _q } // WithRolePermissions tells the query-builder to eager-load the nodes that are connected to // the "role_permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PermissionQuery) WithRolePermissions(opts ...func(*RolePermissionQuery)) *PermissionQuery { - query := (&RolePermissionClient{config: pq.config}).Query() +func (_q *PermissionQuery) WithRolePermissions(opts ...func(*RolePermissionQuery)) *PermissionQuery { + query := (&RolePermissionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withRolePermissions = query - return pq + _q.withRolePermissions = query + return _q } // WithPositionPermissions tells the query-builder to eager-load the nodes that are connected to // the "position_permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PermissionQuery) WithPositionPermissions(opts ...func(*PositionPermissionQuery)) *PermissionQuery { - query := (&PositionPermissionClient{config: pq.config}).Query() +func (_q *PermissionQuery) WithPositionPermissions(opts ...func(*PositionPermissionQuery)) *PermissionQuery { + query := (&PositionPermissionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withPositionPermissions = query - return pq + _q.withPositionPermissions = query + return _q } // WithPermissionResources tells the query-builder to eager-load the nodes that are connected to // the "permission_resources" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PermissionQuery) WithPermissionResources(opts ...func(*PermissionResourceQuery)) *PermissionQuery { - query := (&PermissionResourceClient{config: pq.config}).Query() +func (_q *PermissionQuery) WithPermissionResources(opts ...func(*PermissionResourceQuery)) *PermissionQuery { + query := (&PermissionResourceClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withPermissionResources = query - return pq + _q.withPermissionResources = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -490,10 +490,10 @@ func (pq *PermissionQuery) WithPermissionResources(opts ...func(*PermissionResou // GroupBy(permission.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (pq *PermissionQuery) GroupBy(field string, fields ...string) *PermissionGroupBy { - pq.ctx.Fields = append([]string{field}, fields...) - grbuild := &PermissionGroupBy{build: pq} - grbuild.flds = &pq.ctx.Fields +func (_q *PermissionQuery) GroupBy(field string, fields ...string) *PermissionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PermissionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = permission.Label grbuild.scan = grbuild.Scan return grbuild @@ -511,109 +511,109 @@ func (pq *PermissionQuery) GroupBy(field string, fields ...string) *PermissionGr // client.Permission.Query(). // Select(permission.FieldCreateTime). // Scan(ctx, &v) -func (pq *PermissionQuery) Select(fields ...string) *PermissionSelect { - pq.ctx.Fields = append(pq.ctx.Fields, fields...) - sbuild := &PermissionSelect{PermissionQuery: pq} +func (_q *PermissionQuery) Select(fields ...string) *PermissionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PermissionSelect{PermissionQuery: _q} sbuild.label = permission.Label - sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a PermissionSelect configured with the given aggregations. -func (pq *PermissionQuery) Aggregate(fns ...AggregateFunc) *PermissionSelect { - return pq.Select().Aggregate(fns...) +func (_q *PermissionQuery) Aggregate(fns ...AggregateFunc) *PermissionSelect { + return _q.Select().Aggregate(fns...) } -func (pq *PermissionQuery) prepareQuery(ctx context.Context) error { - for _, inter := range pq.inters { +func (_q *PermissionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, pq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range pq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !permission.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if pq.path != nil { - prev, err := pq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - pq.sql = prev + _q.sql = prev } return nil } -func (pq *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Permission, error) { +func (_q *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Permission, error) { var ( nodes = []*Permission{} - _spec = pq.querySpec() + _spec = _q.querySpec() loadedTypes = [6]bool{ - pq.withRoles != nil, - pq.withPositions != nil, - pq.withResources != nil, - pq.withRolePermissions != nil, - pq.withPositionPermissions != nil, - pq.withPermissionResources != nil, + _q.withRoles != nil, + _q.withPositions != nil, + _q.withResources != nil, + _q.withRolePermissions != nil, + _q.withPositionPermissions != nil, + _q.withPermissionResources != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Permission).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Permission{config: pq.config} + node := &Permission{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(pq.modifiers) > 0 { - _spec.Modifiers = pq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, pq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := pq.withRoles; query != nil { - if err := pq.loadRoles(ctx, query, nodes, + if query := _q.withRoles; query != nil { + if err := _q.loadRoles(ctx, query, nodes, func(n *Permission) { n.Edges.Roles = []*Role{} }, func(n *Permission, e *Role) { n.Edges.Roles = append(n.Edges.Roles, e) }); err != nil { return nil, err } } - if query := pq.withPositions; query != nil { - if err := pq.loadPositions(ctx, query, nodes, + if query := _q.withPositions; query != nil { + if err := _q.loadPositions(ctx, query, nodes, func(n *Permission) { n.Edges.Positions = []*Position{} }, func(n *Permission, e *Position) { n.Edges.Positions = append(n.Edges.Positions, e) }); err != nil { return nil, err } } - if query := pq.withResources; query != nil { - if err := pq.loadResources(ctx, query, nodes, + if query := _q.withResources; query != nil { + if err := _q.loadResources(ctx, query, nodes, func(n *Permission) { n.Edges.Resources = []*Resource{} }, func(n *Permission, e *Resource) { n.Edges.Resources = append(n.Edges.Resources, e) }); err != nil { return nil, err } } - if query := pq.withRolePermissions; query != nil { - if err := pq.loadRolePermissions(ctx, query, nodes, + if query := _q.withRolePermissions; query != nil { + if err := _q.loadRolePermissions(ctx, query, nodes, func(n *Permission) { n.Edges.RolePermissions = []*RolePermission{} }, func(n *Permission, e *RolePermission) { n.Edges.RolePermissions = append(n.Edges.RolePermissions, e) }); err != nil { return nil, err } } - if query := pq.withPositionPermissions; query != nil { - if err := pq.loadPositionPermissions(ctx, query, nodes, + if query := _q.withPositionPermissions; query != nil { + if err := _q.loadPositionPermissions(ctx, query, nodes, func(n *Permission) { n.Edges.PositionPermissions = []*PositionPermission{} }, func(n *Permission, e *PositionPermission) { n.Edges.PositionPermissions = append(n.Edges.PositionPermissions, e) @@ -621,8 +621,8 @@ func (pq *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*P return nil, err } } - if query := pq.withPermissionResources; query != nil { - if err := pq.loadPermissionResources(ctx, query, nodes, + if query := _q.withPermissionResources; query != nil { + if err := _q.loadPermissionResources(ctx, query, nodes, func(n *Permission) { n.Edges.PermissionResources = []*PermissionResource{} }, func(n *Permission, e *PermissionResource) { n.Edges.PermissionResources = append(n.Edges.PermissionResources, e) @@ -633,7 +633,7 @@ func (pq *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*P return nodes, nil } -func (pq *PermissionQuery) loadRoles(ctx context.Context, query *RoleQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *Role)) error { +func (_q *PermissionQuery) loadRoles(ctx context.Context, query *RoleQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *Role)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*Permission) nids := make(map[int64]map[*Permission]struct{}) @@ -694,7 +694,7 @@ func (pq *PermissionQuery) loadRoles(ctx context.Context, query *RoleQuery, node } return nil } -func (pq *PermissionQuery) loadPositions(ctx context.Context, query *PositionQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *Position)) error { +func (_q *PermissionQuery) loadPositions(ctx context.Context, query *PositionQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *Position)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*Permission) nids := make(map[int64]map[*Permission]struct{}) @@ -755,7 +755,7 @@ func (pq *PermissionQuery) loadPositions(ctx context.Context, query *PositionQue } return nil } -func (pq *PermissionQuery) loadResources(ctx context.Context, query *ResourceQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *Resource)) error { +func (_q *PermissionQuery) loadResources(ctx context.Context, query *ResourceQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *Resource)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*Permission) nids := make(map[int64]map[*Permission]struct{}) @@ -816,7 +816,7 @@ func (pq *PermissionQuery) loadResources(ctx context.Context, query *ResourceQue } return nil } -func (pq *PermissionQuery) loadRolePermissions(ctx context.Context, query *RolePermissionQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *RolePermission)) error { +func (_q *PermissionQuery) loadRolePermissions(ctx context.Context, query *RolePermissionQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *RolePermission)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Permission) for i := range nodes { @@ -846,7 +846,7 @@ func (pq *PermissionQuery) loadRolePermissions(ctx context.Context, query *RoleP } return nil } -func (pq *PermissionQuery) loadPositionPermissions(ctx context.Context, query *PositionPermissionQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *PositionPermission)) error { +func (_q *PermissionQuery) loadPositionPermissions(ctx context.Context, query *PositionPermissionQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *PositionPermission)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Permission) for i := range nodes { @@ -876,7 +876,7 @@ func (pq *PermissionQuery) loadPositionPermissions(ctx context.Context, query *P } return nil } -func (pq *PermissionQuery) loadPermissionResources(ctx context.Context, query *PermissionResourceQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *PermissionResource)) error { +func (_q *PermissionQuery) loadPermissionResources(ctx context.Context, query *PermissionResourceQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *PermissionResource)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Permission) for i := range nodes { @@ -907,27 +907,27 @@ func (pq *PermissionQuery) loadPermissionResources(ctx context.Context, query *P return nil } -func (pq *PermissionQuery) sqlCount(ctx context.Context) (int, error) { - _spec := pq.querySpec() - if len(pq.modifiers) > 0 { - _spec.Modifiers = pq.modifiers +func (_q *PermissionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = pq.ctx.Fields - if len(pq.ctx.Fields) > 0 { - _spec.Unique = pq.ctx.Unique != nil && *pq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, pq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (pq *PermissionQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *PermissionQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(permission.Table, permission.Columns, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) - _spec.From = pq.sql - if unique := pq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if pq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := pq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, permission.FieldID) for i := range fields { @@ -936,20 +936,20 @@ func (pq *PermissionQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := pq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := pq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := pq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := pq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -959,36 +959,36 @@ func (pq *PermissionQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (pq *PermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(pq.driver.Dialect()) +func (_q *PermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(permission.Table) - columns := pq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = permission.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if pq.sql != nil { - selector = pq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if pq.ctx.Unique != nil && *pq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range pq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range pq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range pq.order { + for _, p := range _q.order { p(selector) } - if offset := pq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := pq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -997,33 +997,33 @@ func (pq *PermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (pq *PermissionQuery) ForUpdate(opts ...sql.LockOption) *PermissionQuery { - if pq.driver.Dialect() == dialect.Postgres { - pq.Unique(false) +func (_q *PermissionQuery) ForUpdate(opts ...sql.LockOption) *PermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - pq.modifiers = append(pq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return pq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (pq *PermissionQuery) ForShare(opts ...sql.LockOption) *PermissionQuery { - if pq.driver.Dialect() == dialect.Postgres { - pq.Unique(false) +func (_q *PermissionQuery) ForShare(opts ...sql.LockOption) *PermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - pq.modifiers = append(pq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return pq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (pq *PermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *PermissionSelect { - pq.modifiers = append(pq.modifiers, modifiers...) - return pq.Select() +func (_q *PermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *PermissionSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -1077,41 +1077,41 @@ type PermissionGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (pgb *PermissionGroupBy) Aggregate(fns ...AggregateFunc) *PermissionGroupBy { - pgb.fns = append(pgb.fns, fns...) - return pgb +func (_g *PermissionGroupBy) Aggregate(fns ...AggregateFunc) *PermissionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (pgb *PermissionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, pgb.build.ctx, ent.OpQueryGroupBy) - if err := pgb.build.prepareQuery(ctx); err != nil { +func (_g *PermissionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*PermissionQuery, *PermissionGroupBy](ctx, pgb.build, pgb, pgb.build.inters, v) + return scanWithInterceptors[*PermissionQuery, *PermissionGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (pgb *PermissionGroupBy) sqlScan(ctx context.Context, root *PermissionQuery, v any) error { +func (_g *PermissionGroupBy) sqlScan(ctx context.Context, root *PermissionQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(pgb.fns)) - for _, fn := range pgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*pgb.flds)+len(pgb.fns)) - for _, f := range *pgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*pgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := pgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -1125,27 +1125,27 @@ type PermissionSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (ps *PermissionSelect) Aggregate(fns ...AggregateFunc) *PermissionSelect { - ps.fns = append(ps.fns, fns...) - return ps +func (_s *PermissionSelect) Aggregate(fns ...AggregateFunc) *PermissionSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (ps *PermissionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ps.ctx, ent.OpQuerySelect) - if err := ps.prepareQuery(ctx); err != nil { +func (_s *PermissionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*PermissionQuery, *PermissionSelect](ctx, ps.PermissionQuery, ps, ps.inters, v) + return scanWithInterceptors[*PermissionQuery, *PermissionSelect](ctx, _s.PermissionQuery, _s, _s.inters, v) } -func (ps *PermissionSelect) sqlScan(ctx context.Context, root *PermissionQuery, v any) error { +func (_s *PermissionSelect) sqlScan(ctx context.Context, root *PermissionQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ps.fns)) - for _, fn := range ps.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*ps.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -1153,7 +1153,7 @@ func (ps *PermissionSelect) sqlScan(ctx context.Context, root *PermissionQuery, } rows := &sql.Rows{} query, args := selector.Query() - if err := ps.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -1161,7 +1161,7 @@ func (ps *PermissionSelect) sqlScan(ctx context.Context, root *PermissionQuery, } // Modify adds a query modifier for attaching custom logic to queries. -func (ps *PermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *PermissionSelect { - ps.modifiers = append(ps.modifiers, modifiers...) - return ps +func (_s *PermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *PermissionSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/permission_update.go b/internal/data/entity/ent/permission_update.go index 26cbcd84..546e9e70 100644 --- a/internal/data/entity/ent/permission_update.go +++ b/internal/data/entity/ent/permission_update.go @@ -30,329 +30,329 @@ type PermissionUpdate struct { } // Where appends a list predicates to the PermissionUpdate builder. -func (pu *PermissionUpdate) Where(ps ...predicate.Permission) *PermissionUpdate { - pu.mutation.Where(ps...) - return pu +func (_u *PermissionUpdate) Where(ps ...predicate.Permission) *PermissionUpdate { + _u.mutation.Where(ps...) + return _u } // SetUpdateTime sets the "update_time" field. -func (pu *PermissionUpdate) SetUpdateTime(t time.Time) *PermissionUpdate { - pu.mutation.SetUpdateTime(t) - return pu +func (_u *PermissionUpdate) SetUpdateTime(v time.Time) *PermissionUpdate { + _u.mutation.SetUpdateTime(v) + return _u } // SetName sets the "name" field. -func (pu *PermissionUpdate) SetName(s string) *PermissionUpdate { - pu.mutation.SetName(s) - return pu +func (_u *PermissionUpdate) SetName(v string) *PermissionUpdate { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (pu *PermissionUpdate) SetNillableName(s *string) *PermissionUpdate { - if s != nil { - pu.SetName(*s) +func (_u *PermissionUpdate) SetNillableName(v *string) *PermissionUpdate { + if v != nil { + _u.SetName(*v) } - return pu + return _u } // SetKeyword sets the "keyword" field. -func (pu *PermissionUpdate) SetKeyword(s string) *PermissionUpdate { - pu.mutation.SetKeyword(s) - return pu +func (_u *PermissionUpdate) SetKeyword(v string) *PermissionUpdate { + _u.mutation.SetKeyword(v) + return _u } // SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (pu *PermissionUpdate) SetNillableKeyword(s *string) *PermissionUpdate { - if s != nil { - pu.SetKeyword(*s) +func (_u *PermissionUpdate) SetNillableKeyword(v *string) *PermissionUpdate { + if v != nil { + _u.SetKeyword(*v) } - return pu + return _u } // SetDescription sets the "description" field. -func (pu *PermissionUpdate) SetDescription(s string) *PermissionUpdate { - pu.mutation.SetDescription(s) - return pu +func (_u *PermissionUpdate) SetDescription(v string) *PermissionUpdate { + _u.mutation.SetDescription(v) + return _u } // SetNillableDescription sets the "description" field if the given value is not nil. -func (pu *PermissionUpdate) SetNillableDescription(s *string) *PermissionUpdate { - if s != nil { - pu.SetDescription(*s) +func (_u *PermissionUpdate) SetNillableDescription(v *string) *PermissionUpdate { + if v != nil { + _u.SetDescription(*v) } - return pu + return _u } // SetDataScope sets the "data_scope" field. -func (pu *PermissionUpdate) SetDataScope(s string) *PermissionUpdate { - pu.mutation.SetDataScope(s) - return pu +func (_u *PermissionUpdate) SetDataScope(v string) *PermissionUpdate { + _u.mutation.SetDataScope(v) + return _u } // SetNillableDataScope sets the "data_scope" field if the given value is not nil. -func (pu *PermissionUpdate) SetNillableDataScope(s *string) *PermissionUpdate { - if s != nil { - pu.SetDataScope(*s) +func (_u *PermissionUpdate) SetNillableDataScope(v *string) *PermissionUpdate { + if v != nil { + _u.SetDataScope(*v) } - return pu + return _u } // SetDataRules sets the "data_rules" field. -func (pu *PermissionUpdate) SetDataRules(m map[string]string) *PermissionUpdate { - pu.mutation.SetDataRules(m) - return pu +func (_u *PermissionUpdate) SetDataRules(v map[string]string) *PermissionUpdate { + _u.mutation.SetDataRules(v) + return _u } // ClearDataRules clears the value of the "data_rules" field. -func (pu *PermissionUpdate) ClearDataRules() *PermissionUpdate { - pu.mutation.ClearDataRules() - return pu +func (_u *PermissionUpdate) ClearDataRules() *PermissionUpdate { + _u.mutation.ClearDataRules() + return _u } // SetActions sets the "actions" field. -func (pu *PermissionUpdate) SetActions(pe permission.Actions) *PermissionUpdate { - pu.mutation.SetActions(pe) - return pu +func (_u *PermissionUpdate) SetActions(v permission.Actions) *PermissionUpdate { + _u.mutation.SetActions(v) + return _u } // SetNillableActions sets the "actions" field if the given value is not nil. -func (pu *PermissionUpdate) SetNillableActions(pe *permission.Actions) *PermissionUpdate { - if pe != nil { - pu.SetActions(*pe) +func (_u *PermissionUpdate) SetNillableActions(v *permission.Actions) *PermissionUpdate { + if v != nil { + _u.SetActions(*v) } - return pu + return _u } // AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (pu *PermissionUpdate) AddRoleIDs(ids ...int64) *PermissionUpdate { - pu.mutation.AddRoleIDs(ids...) - return pu +func (_u *PermissionUpdate) AddRoleIDs(ids ...int64) *PermissionUpdate { + _u.mutation.AddRoleIDs(ids...) + return _u } // AddRoles adds the "roles" edges to the Role entity. -func (pu *PermissionUpdate) AddRoles(r ...*Role) *PermissionUpdate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdate) AddRoles(v ...*Role) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddRoleIDs(ids...) + return _u.AddRoleIDs(ids...) } // AddPositionIDs adds the "positions" edge to the Position entity by IDs. -func (pu *PermissionUpdate) AddPositionIDs(ids ...int64) *PermissionUpdate { - pu.mutation.AddPositionIDs(ids...) - return pu +func (_u *PermissionUpdate) AddPositionIDs(ids ...int64) *PermissionUpdate { + _u.mutation.AddPositionIDs(ids...) + return _u } // AddPositions adds the "positions" edges to the Position entity. -func (pu *PermissionUpdate) AddPositions(p ...*Position) *PermissionUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdate) AddPositions(v ...*Position) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddPositionIDs(ids...) + return _u.AddPositionIDs(ids...) } // AddResourceIDs adds the "resources" edge to the Resource entity by IDs. -func (pu *PermissionUpdate) AddResourceIDs(ids ...int64) *PermissionUpdate { - pu.mutation.AddResourceIDs(ids...) - return pu +func (_u *PermissionUpdate) AddResourceIDs(ids ...int64) *PermissionUpdate { + _u.mutation.AddResourceIDs(ids...) + return _u } // AddResources adds the "resources" edges to the Resource entity. -func (pu *PermissionUpdate) AddResources(r ...*Resource) *PermissionUpdate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdate) AddResources(v ...*Resource) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddResourceIDs(ids...) + return _u.AddResourceIDs(ids...) } // AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (pu *PermissionUpdate) AddRolePermissionIDs(ids ...int) *PermissionUpdate { - pu.mutation.AddRolePermissionIDs(ids...) - return pu +func (_u *PermissionUpdate) AddRolePermissionIDs(ids ...int) *PermissionUpdate { + _u.mutation.AddRolePermissionIDs(ids...) + return _u } // AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (pu *PermissionUpdate) AddRolePermissions(r ...*RolePermission) *PermissionUpdate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdate) AddRolePermissions(v ...*RolePermission) *PermissionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddRolePermissionIDs(ids...) + return _u.AddRolePermissionIDs(ids...) } // AddPositionPermissionIDs adds the "position_permissions" edge to the PositionPermission entity by IDs. -func (pu *PermissionUpdate) AddPositionPermissionIDs(ids ...int) *PermissionUpdate { - pu.mutation.AddPositionPermissionIDs(ids...) - return pu +func (_u *PermissionUpdate) AddPositionPermissionIDs(ids ...int) *PermissionUpdate { + _u.mutation.AddPositionPermissionIDs(ids...) + return _u } // AddPositionPermissions adds the "position_permissions" edges to the PositionPermission entity. -func (pu *PermissionUpdate) AddPositionPermissions(p ...*PositionPermission) *PermissionUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdate) AddPositionPermissions(v ...*PositionPermission) *PermissionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddPositionPermissionIDs(ids...) + return _u.AddPositionPermissionIDs(ids...) } // AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (pu *PermissionUpdate) AddPermissionResourceIDs(ids ...int) *PermissionUpdate { - pu.mutation.AddPermissionResourceIDs(ids...) - return pu +func (_u *PermissionUpdate) AddPermissionResourceIDs(ids ...int) *PermissionUpdate { + _u.mutation.AddPermissionResourceIDs(ids...) + return _u } // AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (pu *PermissionUpdate) AddPermissionResources(p ...*PermissionResource) *PermissionUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdate) AddPermissionResources(v ...*PermissionResource) *PermissionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddPermissionResourceIDs(ids...) + return _u.AddPermissionResourceIDs(ids...) } // Mutation returns the PermissionMutation object of the builder. -func (pu *PermissionUpdate) Mutation() *PermissionMutation { - return pu.mutation +func (_u *PermissionUpdate) Mutation() *PermissionMutation { + return _u.mutation } // ClearRoles clears all "roles" edges to the Role entity. -func (pu *PermissionUpdate) ClearRoles() *PermissionUpdate { - pu.mutation.ClearRoles() - return pu +func (_u *PermissionUpdate) ClearRoles() *PermissionUpdate { + _u.mutation.ClearRoles() + return _u } // RemoveRoleIDs removes the "roles" edge to Role entities by IDs. -func (pu *PermissionUpdate) RemoveRoleIDs(ids ...int64) *PermissionUpdate { - pu.mutation.RemoveRoleIDs(ids...) - return pu +func (_u *PermissionUpdate) RemoveRoleIDs(ids ...int64) *PermissionUpdate { + _u.mutation.RemoveRoleIDs(ids...) + return _u } // RemoveRoles removes "roles" edges to Role entities. -func (pu *PermissionUpdate) RemoveRoles(r ...*Role) *PermissionUpdate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdate) RemoveRoles(v ...*Role) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemoveRoleIDs(ids...) + return _u.RemoveRoleIDs(ids...) } // ClearPositions clears all "positions" edges to the Position entity. -func (pu *PermissionUpdate) ClearPositions() *PermissionUpdate { - pu.mutation.ClearPositions() - return pu +func (_u *PermissionUpdate) ClearPositions() *PermissionUpdate { + _u.mutation.ClearPositions() + return _u } // RemovePositionIDs removes the "positions" edge to Position entities by IDs. -func (pu *PermissionUpdate) RemovePositionIDs(ids ...int64) *PermissionUpdate { - pu.mutation.RemovePositionIDs(ids...) - return pu +func (_u *PermissionUpdate) RemovePositionIDs(ids ...int64) *PermissionUpdate { + _u.mutation.RemovePositionIDs(ids...) + return _u } // RemovePositions removes "positions" edges to Position entities. -func (pu *PermissionUpdate) RemovePositions(p ...*Position) *PermissionUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdate) RemovePositions(v ...*Position) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemovePositionIDs(ids...) + return _u.RemovePositionIDs(ids...) } // ClearResources clears all "resources" edges to the Resource entity. -func (pu *PermissionUpdate) ClearResources() *PermissionUpdate { - pu.mutation.ClearResources() - return pu +func (_u *PermissionUpdate) ClearResources() *PermissionUpdate { + _u.mutation.ClearResources() + return _u } // RemoveResourceIDs removes the "resources" edge to Resource entities by IDs. -func (pu *PermissionUpdate) RemoveResourceIDs(ids ...int64) *PermissionUpdate { - pu.mutation.RemoveResourceIDs(ids...) - return pu +func (_u *PermissionUpdate) RemoveResourceIDs(ids ...int64) *PermissionUpdate { + _u.mutation.RemoveResourceIDs(ids...) + return _u } // RemoveResources removes "resources" edges to Resource entities. -func (pu *PermissionUpdate) RemoveResources(r ...*Resource) *PermissionUpdate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdate) RemoveResources(v ...*Resource) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemoveResourceIDs(ids...) + return _u.RemoveResourceIDs(ids...) } // ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. -func (pu *PermissionUpdate) ClearRolePermissions() *PermissionUpdate { - pu.mutation.ClearRolePermissions() - return pu +func (_u *PermissionUpdate) ClearRolePermissions() *PermissionUpdate { + _u.mutation.ClearRolePermissions() + return _u } // RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. -func (pu *PermissionUpdate) RemoveRolePermissionIDs(ids ...int) *PermissionUpdate { - pu.mutation.RemoveRolePermissionIDs(ids...) - return pu +func (_u *PermissionUpdate) RemoveRolePermissionIDs(ids ...int) *PermissionUpdate { + _u.mutation.RemoveRolePermissionIDs(ids...) + return _u } // RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. -func (pu *PermissionUpdate) RemoveRolePermissions(r ...*RolePermission) *PermissionUpdate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdate) RemoveRolePermissions(v ...*RolePermission) *PermissionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemoveRolePermissionIDs(ids...) + return _u.RemoveRolePermissionIDs(ids...) } // ClearPositionPermissions clears all "position_permissions" edges to the PositionPermission entity. -func (pu *PermissionUpdate) ClearPositionPermissions() *PermissionUpdate { - pu.mutation.ClearPositionPermissions() - return pu +func (_u *PermissionUpdate) ClearPositionPermissions() *PermissionUpdate { + _u.mutation.ClearPositionPermissions() + return _u } // RemovePositionPermissionIDs removes the "position_permissions" edge to PositionPermission entities by IDs. -func (pu *PermissionUpdate) RemovePositionPermissionIDs(ids ...int) *PermissionUpdate { - pu.mutation.RemovePositionPermissionIDs(ids...) - return pu +func (_u *PermissionUpdate) RemovePositionPermissionIDs(ids ...int) *PermissionUpdate { + _u.mutation.RemovePositionPermissionIDs(ids...) + return _u } // RemovePositionPermissions removes "position_permissions" edges to PositionPermission entities. -func (pu *PermissionUpdate) RemovePositionPermissions(p ...*PositionPermission) *PermissionUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdate) RemovePositionPermissions(v ...*PositionPermission) *PermissionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemovePositionPermissionIDs(ids...) + return _u.RemovePositionPermissionIDs(ids...) } // ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. -func (pu *PermissionUpdate) ClearPermissionResources() *PermissionUpdate { - pu.mutation.ClearPermissionResources() - return pu +func (_u *PermissionUpdate) ClearPermissionResources() *PermissionUpdate { + _u.mutation.ClearPermissionResources() + return _u } // RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. -func (pu *PermissionUpdate) RemovePermissionResourceIDs(ids ...int) *PermissionUpdate { - pu.mutation.RemovePermissionResourceIDs(ids...) - return pu +func (_u *PermissionUpdate) RemovePermissionResourceIDs(ids ...int) *PermissionUpdate { + _u.mutation.RemovePermissionResourceIDs(ids...) + return _u } // RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. -func (pu *PermissionUpdate) RemovePermissionResources(p ...*PermissionResource) *PermissionUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdate) RemovePermissionResources(v ...*PermissionResource) *PermissionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemovePermissionResourceIDs(ids...) + return _u.RemovePermissionResourceIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. -func (pu *PermissionUpdate) Save(ctx context.Context) (int, error) { - pu.defaults() - return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) +func (_u *PermissionUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (pu *PermissionUpdate) SaveX(ctx context.Context) int { - affected, err := pu.Save(ctx) +func (_u *PermissionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -360,44 +360,44 @@ func (pu *PermissionUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (pu *PermissionUpdate) Exec(ctx context.Context) error { - _, err := pu.Save(ctx) +func (_u *PermissionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pu *PermissionUpdate) ExecX(ctx context.Context) { - if err := pu.Exec(ctx); err != nil { +func (_u *PermissionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (pu *PermissionUpdate) defaults() { - if _, ok := pu.mutation.UpdateTime(); !ok { +func (_u *PermissionUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := permission.UpdateDefaultUpdateTime() - pu.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (pu *PermissionUpdate) check() error { - if v, ok := pu.mutation.Name(); ok { +func (_u *PermissionUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { if err := permission.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Permission.name": %w`, err)} } } - if v, ok := pu.mutation.Keyword(); ok { + if v, ok := _u.mutation.Keyword(); ok { if err := permission.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Permission.keyword": %w`, err)} } } - if v, ok := pu.mutation.Description(); ok { + if v, ok := _u.mutation.Description(); ok { if err := permission.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} } } - if v, ok := pu.mutation.Actions(); ok { + if v, ok := _u.mutation.Actions(); ok { if err := permission.ActionsValidator(v); err != nil { return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} } @@ -406,48 +406,48 @@ func (pu *PermissionUpdate) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (pu *PermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionUpdate { - pu.modifiers = append(pu.modifiers, modifiers...) - return pu +func (_u *PermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := pu.check(); err != nil { - return n, err +func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(permission.Table, permission.Columns, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) - if ps := pu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := pu.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(permission.FieldUpdateTime, field.TypeTime, value) } - if value, ok := pu.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(permission.FieldName, field.TypeString, value) } - if value, ok := pu.mutation.Keyword(); ok { + if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(permission.FieldKeyword, field.TypeString, value) } - if value, ok := pu.mutation.Description(); ok { + if value, ok := _u.mutation.Description(); ok { _spec.SetField(permission.FieldDescription, field.TypeString, value) } - if value, ok := pu.mutation.DataScope(); ok { + if value, ok := _u.mutation.DataScope(); ok { _spec.SetField(permission.FieldDataScope, field.TypeString, value) } - if value, ok := pu.mutation.DataRules(); ok { + if value, ok := _u.mutation.DataRules(); ok { _spec.SetField(permission.FieldDataRules, field.TypeJSON, value) } - if pu.mutation.DataRulesCleared() { + if _u.mutation.DataRulesCleared() { _spec.ClearField(permission.FieldDataRules, field.TypeJSON) } - if value, ok := pu.mutation.Actions(); ok { + if value, ok := _u.mutation.Actions(); ok { _spec.SetField(permission.FieldActions, field.TypeEnum, value) } - if pu.mutation.RolesCleared() { + if _u.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -460,7 +460,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedRolesIDs(); len(nodes) > 0 && !pu.mutation.RolesCleared() { + if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -476,7 +476,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RolesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -492,7 +492,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pu.mutation.PositionsCleared() { + if _u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -505,7 +505,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !pu.mutation.PositionsCleared() { + if nodes := _u.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !_u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -521,7 +521,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.PositionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -537,7 +537,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pu.mutation.ResourcesCleared() { + if _u.mutation.ResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -550,7 +550,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !pu.mutation.ResourcesCleared() { + if nodes := _u.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !_u.mutation.ResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -566,7 +566,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.ResourcesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -582,7 +582,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pu.mutation.RolePermissionsCleared() { + if _u.mutation.RolePermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -595,7 +595,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !pu.mutation.RolePermissionsCleared() { + if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -611,7 +611,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RolePermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -627,7 +627,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pu.mutation.PositionPermissionsCleared() { + if _u.mutation.PositionPermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -640,7 +640,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedPositionPermissionsIDs(); len(nodes) > 0 && !pu.mutation.PositionPermissionsCleared() { + if nodes := _u.mutation.RemovedPositionPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PositionPermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -656,7 +656,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.PositionPermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionPermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -672,7 +672,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pu.mutation.PermissionResourcesCleared() { + if _u.mutation.PermissionResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -685,7 +685,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !pu.mutation.PermissionResourcesCleared() { + if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -701,7 +701,7 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -717,8 +717,8 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(pu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{permission.Label} } else if sqlgraph.IsConstraintError(err) { @@ -726,8 +726,8 @@ func (pu *PermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - pu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // PermissionUpdateOne is the builder for updating a single Permission entity. @@ -740,336 +740,336 @@ type PermissionUpdateOne struct { } // SetUpdateTime sets the "update_time" field. -func (puo *PermissionUpdateOne) SetUpdateTime(t time.Time) *PermissionUpdateOne { - puo.mutation.SetUpdateTime(t) - return puo +func (_u *PermissionUpdateOne) SetUpdateTime(v time.Time) *PermissionUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u } // SetName sets the "name" field. -func (puo *PermissionUpdateOne) SetName(s string) *PermissionUpdateOne { - puo.mutation.SetName(s) - return puo +func (_u *PermissionUpdateOne) SetName(v string) *PermissionUpdateOne { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (puo *PermissionUpdateOne) SetNillableName(s *string) *PermissionUpdateOne { - if s != nil { - puo.SetName(*s) +func (_u *PermissionUpdateOne) SetNillableName(v *string) *PermissionUpdateOne { + if v != nil { + _u.SetName(*v) } - return puo + return _u } // SetKeyword sets the "keyword" field. -func (puo *PermissionUpdateOne) SetKeyword(s string) *PermissionUpdateOne { - puo.mutation.SetKeyword(s) - return puo +func (_u *PermissionUpdateOne) SetKeyword(v string) *PermissionUpdateOne { + _u.mutation.SetKeyword(v) + return _u } // SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (puo *PermissionUpdateOne) SetNillableKeyword(s *string) *PermissionUpdateOne { - if s != nil { - puo.SetKeyword(*s) +func (_u *PermissionUpdateOne) SetNillableKeyword(v *string) *PermissionUpdateOne { + if v != nil { + _u.SetKeyword(*v) } - return puo + return _u } // SetDescription sets the "description" field. -func (puo *PermissionUpdateOne) SetDescription(s string) *PermissionUpdateOne { - puo.mutation.SetDescription(s) - return puo +func (_u *PermissionUpdateOne) SetDescription(v string) *PermissionUpdateOne { + _u.mutation.SetDescription(v) + return _u } // SetNillableDescription sets the "description" field if the given value is not nil. -func (puo *PermissionUpdateOne) SetNillableDescription(s *string) *PermissionUpdateOne { - if s != nil { - puo.SetDescription(*s) +func (_u *PermissionUpdateOne) SetNillableDescription(v *string) *PermissionUpdateOne { + if v != nil { + _u.SetDescription(*v) } - return puo + return _u } // SetDataScope sets the "data_scope" field. -func (puo *PermissionUpdateOne) SetDataScope(s string) *PermissionUpdateOne { - puo.mutation.SetDataScope(s) - return puo +func (_u *PermissionUpdateOne) SetDataScope(v string) *PermissionUpdateOne { + _u.mutation.SetDataScope(v) + return _u } // SetNillableDataScope sets the "data_scope" field if the given value is not nil. -func (puo *PermissionUpdateOne) SetNillableDataScope(s *string) *PermissionUpdateOne { - if s != nil { - puo.SetDataScope(*s) +func (_u *PermissionUpdateOne) SetNillableDataScope(v *string) *PermissionUpdateOne { + if v != nil { + _u.SetDataScope(*v) } - return puo + return _u } // SetDataRules sets the "data_rules" field. -func (puo *PermissionUpdateOne) SetDataRules(m map[string]string) *PermissionUpdateOne { - puo.mutation.SetDataRules(m) - return puo +func (_u *PermissionUpdateOne) SetDataRules(v map[string]string) *PermissionUpdateOne { + _u.mutation.SetDataRules(v) + return _u } // ClearDataRules clears the value of the "data_rules" field. -func (puo *PermissionUpdateOne) ClearDataRules() *PermissionUpdateOne { - puo.mutation.ClearDataRules() - return puo +func (_u *PermissionUpdateOne) ClearDataRules() *PermissionUpdateOne { + _u.mutation.ClearDataRules() + return _u } // SetActions sets the "actions" field. -func (puo *PermissionUpdateOne) SetActions(pe permission.Actions) *PermissionUpdateOne { - puo.mutation.SetActions(pe) - return puo +func (_u *PermissionUpdateOne) SetActions(v permission.Actions) *PermissionUpdateOne { + _u.mutation.SetActions(v) + return _u } // SetNillableActions sets the "actions" field if the given value is not nil. -func (puo *PermissionUpdateOne) SetNillableActions(pe *permission.Actions) *PermissionUpdateOne { - if pe != nil { - puo.SetActions(*pe) +func (_u *PermissionUpdateOne) SetNillableActions(v *permission.Actions) *PermissionUpdateOne { + if v != nil { + _u.SetActions(*v) } - return puo + return _u } // AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (puo *PermissionUpdateOne) AddRoleIDs(ids ...int64) *PermissionUpdateOne { - puo.mutation.AddRoleIDs(ids...) - return puo +func (_u *PermissionUpdateOne) AddRoleIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.AddRoleIDs(ids...) + return _u } // AddRoles adds the "roles" edges to the Role entity. -func (puo *PermissionUpdateOne) AddRoles(r ...*Role) *PermissionUpdateOne { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdateOne) AddRoles(v ...*Role) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddRoleIDs(ids...) + return _u.AddRoleIDs(ids...) } // AddPositionIDs adds the "positions" edge to the Position entity by IDs. -func (puo *PermissionUpdateOne) AddPositionIDs(ids ...int64) *PermissionUpdateOne { - puo.mutation.AddPositionIDs(ids...) - return puo +func (_u *PermissionUpdateOne) AddPositionIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.AddPositionIDs(ids...) + return _u } // AddPositions adds the "positions" edges to the Position entity. -func (puo *PermissionUpdateOne) AddPositions(p ...*Position) *PermissionUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdateOne) AddPositions(v ...*Position) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddPositionIDs(ids...) + return _u.AddPositionIDs(ids...) } // AddResourceIDs adds the "resources" edge to the Resource entity by IDs. -func (puo *PermissionUpdateOne) AddResourceIDs(ids ...int64) *PermissionUpdateOne { - puo.mutation.AddResourceIDs(ids...) - return puo +func (_u *PermissionUpdateOne) AddResourceIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.AddResourceIDs(ids...) + return _u } // AddResources adds the "resources" edges to the Resource entity. -func (puo *PermissionUpdateOne) AddResources(r ...*Resource) *PermissionUpdateOne { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdateOne) AddResources(v ...*Resource) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddResourceIDs(ids...) + return _u.AddResourceIDs(ids...) } // AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (puo *PermissionUpdateOne) AddRolePermissionIDs(ids ...int) *PermissionUpdateOne { - puo.mutation.AddRolePermissionIDs(ids...) - return puo +func (_u *PermissionUpdateOne) AddRolePermissionIDs(ids ...int) *PermissionUpdateOne { + _u.mutation.AddRolePermissionIDs(ids...) + return _u } // AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (puo *PermissionUpdateOne) AddRolePermissions(r ...*RolePermission) *PermissionUpdateOne { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdateOne) AddRolePermissions(v ...*RolePermission) *PermissionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddRolePermissionIDs(ids...) + return _u.AddRolePermissionIDs(ids...) } // AddPositionPermissionIDs adds the "position_permissions" edge to the PositionPermission entity by IDs. -func (puo *PermissionUpdateOne) AddPositionPermissionIDs(ids ...int) *PermissionUpdateOne { - puo.mutation.AddPositionPermissionIDs(ids...) - return puo +func (_u *PermissionUpdateOne) AddPositionPermissionIDs(ids ...int) *PermissionUpdateOne { + _u.mutation.AddPositionPermissionIDs(ids...) + return _u } // AddPositionPermissions adds the "position_permissions" edges to the PositionPermission entity. -func (puo *PermissionUpdateOne) AddPositionPermissions(p ...*PositionPermission) *PermissionUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdateOne) AddPositionPermissions(v ...*PositionPermission) *PermissionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddPositionPermissionIDs(ids...) + return _u.AddPositionPermissionIDs(ids...) } // AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (puo *PermissionUpdateOne) AddPermissionResourceIDs(ids ...int) *PermissionUpdateOne { - puo.mutation.AddPermissionResourceIDs(ids...) - return puo +func (_u *PermissionUpdateOne) AddPermissionResourceIDs(ids ...int) *PermissionUpdateOne { + _u.mutation.AddPermissionResourceIDs(ids...) + return _u } // AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (puo *PermissionUpdateOne) AddPermissionResources(p ...*PermissionResource) *PermissionUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdateOne) AddPermissionResources(v ...*PermissionResource) *PermissionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddPermissionResourceIDs(ids...) + return _u.AddPermissionResourceIDs(ids...) } // Mutation returns the PermissionMutation object of the builder. -func (puo *PermissionUpdateOne) Mutation() *PermissionMutation { - return puo.mutation +func (_u *PermissionUpdateOne) Mutation() *PermissionMutation { + return _u.mutation } // ClearRoles clears all "roles" edges to the Role entity. -func (puo *PermissionUpdateOne) ClearRoles() *PermissionUpdateOne { - puo.mutation.ClearRoles() - return puo +func (_u *PermissionUpdateOne) ClearRoles() *PermissionUpdateOne { + _u.mutation.ClearRoles() + return _u } // RemoveRoleIDs removes the "roles" edge to Role entities by IDs. -func (puo *PermissionUpdateOne) RemoveRoleIDs(ids ...int64) *PermissionUpdateOne { - puo.mutation.RemoveRoleIDs(ids...) - return puo +func (_u *PermissionUpdateOne) RemoveRoleIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.RemoveRoleIDs(ids...) + return _u } // RemoveRoles removes "roles" edges to Role entities. -func (puo *PermissionUpdateOne) RemoveRoles(r ...*Role) *PermissionUpdateOne { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdateOne) RemoveRoles(v ...*Role) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemoveRoleIDs(ids...) + return _u.RemoveRoleIDs(ids...) } // ClearPositions clears all "positions" edges to the Position entity. -func (puo *PermissionUpdateOne) ClearPositions() *PermissionUpdateOne { - puo.mutation.ClearPositions() - return puo +func (_u *PermissionUpdateOne) ClearPositions() *PermissionUpdateOne { + _u.mutation.ClearPositions() + return _u } // RemovePositionIDs removes the "positions" edge to Position entities by IDs. -func (puo *PermissionUpdateOne) RemovePositionIDs(ids ...int64) *PermissionUpdateOne { - puo.mutation.RemovePositionIDs(ids...) - return puo +func (_u *PermissionUpdateOne) RemovePositionIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.RemovePositionIDs(ids...) + return _u } // RemovePositions removes "positions" edges to Position entities. -func (puo *PermissionUpdateOne) RemovePositions(p ...*Position) *PermissionUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdateOne) RemovePositions(v ...*Position) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemovePositionIDs(ids...) + return _u.RemovePositionIDs(ids...) } // ClearResources clears all "resources" edges to the Resource entity. -func (puo *PermissionUpdateOne) ClearResources() *PermissionUpdateOne { - puo.mutation.ClearResources() - return puo +func (_u *PermissionUpdateOne) ClearResources() *PermissionUpdateOne { + _u.mutation.ClearResources() + return _u } // RemoveResourceIDs removes the "resources" edge to Resource entities by IDs. -func (puo *PermissionUpdateOne) RemoveResourceIDs(ids ...int64) *PermissionUpdateOne { - puo.mutation.RemoveResourceIDs(ids...) - return puo +func (_u *PermissionUpdateOne) RemoveResourceIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.RemoveResourceIDs(ids...) + return _u } // RemoveResources removes "resources" edges to Resource entities. -func (puo *PermissionUpdateOne) RemoveResources(r ...*Resource) *PermissionUpdateOne { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdateOne) RemoveResources(v ...*Resource) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemoveResourceIDs(ids...) + return _u.RemoveResourceIDs(ids...) } // ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. -func (puo *PermissionUpdateOne) ClearRolePermissions() *PermissionUpdateOne { - puo.mutation.ClearRolePermissions() - return puo +func (_u *PermissionUpdateOne) ClearRolePermissions() *PermissionUpdateOne { + _u.mutation.ClearRolePermissions() + return _u } // RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. -func (puo *PermissionUpdateOne) RemoveRolePermissionIDs(ids ...int) *PermissionUpdateOne { - puo.mutation.RemoveRolePermissionIDs(ids...) - return puo +func (_u *PermissionUpdateOne) RemoveRolePermissionIDs(ids ...int) *PermissionUpdateOne { + _u.mutation.RemoveRolePermissionIDs(ids...) + return _u } // RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. -func (puo *PermissionUpdateOne) RemoveRolePermissions(r ...*RolePermission) *PermissionUpdateOne { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *PermissionUpdateOne) RemoveRolePermissions(v ...*RolePermission) *PermissionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemoveRolePermissionIDs(ids...) + return _u.RemoveRolePermissionIDs(ids...) } // ClearPositionPermissions clears all "position_permissions" edges to the PositionPermission entity. -func (puo *PermissionUpdateOne) ClearPositionPermissions() *PermissionUpdateOne { - puo.mutation.ClearPositionPermissions() - return puo +func (_u *PermissionUpdateOne) ClearPositionPermissions() *PermissionUpdateOne { + _u.mutation.ClearPositionPermissions() + return _u } // RemovePositionPermissionIDs removes the "position_permissions" edge to PositionPermission entities by IDs. -func (puo *PermissionUpdateOne) RemovePositionPermissionIDs(ids ...int) *PermissionUpdateOne { - puo.mutation.RemovePositionPermissionIDs(ids...) - return puo +func (_u *PermissionUpdateOne) RemovePositionPermissionIDs(ids ...int) *PermissionUpdateOne { + _u.mutation.RemovePositionPermissionIDs(ids...) + return _u } // RemovePositionPermissions removes "position_permissions" edges to PositionPermission entities. -func (puo *PermissionUpdateOne) RemovePositionPermissions(p ...*PositionPermission) *PermissionUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdateOne) RemovePositionPermissions(v ...*PositionPermission) *PermissionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemovePositionPermissionIDs(ids...) + return _u.RemovePositionPermissionIDs(ids...) } // ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. -func (puo *PermissionUpdateOne) ClearPermissionResources() *PermissionUpdateOne { - puo.mutation.ClearPermissionResources() - return puo +func (_u *PermissionUpdateOne) ClearPermissionResources() *PermissionUpdateOne { + _u.mutation.ClearPermissionResources() + return _u } // RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. -func (puo *PermissionUpdateOne) RemovePermissionResourceIDs(ids ...int) *PermissionUpdateOne { - puo.mutation.RemovePermissionResourceIDs(ids...) - return puo +func (_u *PermissionUpdateOne) RemovePermissionResourceIDs(ids ...int) *PermissionUpdateOne { + _u.mutation.RemovePermissionResourceIDs(ids...) + return _u } // RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. -func (puo *PermissionUpdateOne) RemovePermissionResources(p ...*PermissionResource) *PermissionUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PermissionUpdateOne) RemovePermissionResources(v ...*PermissionResource) *PermissionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemovePermissionResourceIDs(ids...) + return _u.RemovePermissionResourceIDs(ids...) } // Where appends a list predicates to the PermissionUpdate builder. -func (puo *PermissionUpdateOne) Where(ps ...predicate.Permission) *PermissionUpdateOne { - puo.mutation.Where(ps...) - return puo +func (_u *PermissionUpdateOne) Where(ps ...predicate.Permission) *PermissionUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (puo *PermissionUpdateOne) Select(field string, fields ...string) *PermissionUpdateOne { - puo.fields = append([]string{field}, fields...) - return puo +func (_u *PermissionUpdateOne) Select(field string, fields ...string) *PermissionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Permission entity. -func (puo *PermissionUpdateOne) Save(ctx context.Context) (*Permission, error) { - puo.defaults() - return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) +func (_u *PermissionUpdateOne) Save(ctx context.Context) (*Permission, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (puo *PermissionUpdateOne) SaveX(ctx context.Context) *Permission { - node, err := puo.Save(ctx) +func (_u *PermissionUpdateOne) SaveX(ctx context.Context) *Permission { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -1077,44 +1077,44 @@ func (puo *PermissionUpdateOne) SaveX(ctx context.Context) *Permission { } // Exec executes the query on the entity. -func (puo *PermissionUpdateOne) Exec(ctx context.Context) error { - _, err := puo.Save(ctx) +func (_u *PermissionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (puo *PermissionUpdateOne) ExecX(ctx context.Context) { - if err := puo.Exec(ctx); err != nil { +func (_u *PermissionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (puo *PermissionUpdateOne) defaults() { - if _, ok := puo.mutation.UpdateTime(); !ok { +func (_u *PermissionUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := permission.UpdateDefaultUpdateTime() - puo.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (puo *PermissionUpdateOne) check() error { - if v, ok := puo.mutation.Name(); ok { +func (_u *PermissionUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { if err := permission.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Permission.name": %w`, err)} } } - if v, ok := puo.mutation.Keyword(); ok { + if v, ok := _u.mutation.Keyword(); ok { if err := permission.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Permission.keyword": %w`, err)} } } - if v, ok := puo.mutation.Description(); ok { + if v, ok := _u.mutation.Description(); ok { if err := permission.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} } } - if v, ok := puo.mutation.Actions(); ok { + if v, ok := _u.mutation.Actions(); ok { if err := permission.ActionsValidator(v); err != nil { return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} } @@ -1123,22 +1123,22 @@ func (puo *PermissionUpdateOne) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (puo *PermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionUpdateOne { - puo.modifiers = append(puo.modifiers, modifiers...) - return puo +func (_u *PermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, err error) { - if err := puo.check(); err != nil { +func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(permission.Table, permission.Columns, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) - id, ok := puo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Permission.id" for update`)} } _spec.Node.ID.Value = id - if fields := puo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, permission.FieldID) for _, f := range fields { @@ -1150,38 +1150,38 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } } } - if ps := puo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := puo.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(permission.FieldUpdateTime, field.TypeTime, value) } - if value, ok := puo.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(permission.FieldName, field.TypeString, value) } - if value, ok := puo.mutation.Keyword(); ok { + if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(permission.FieldKeyword, field.TypeString, value) } - if value, ok := puo.mutation.Description(); ok { + if value, ok := _u.mutation.Description(); ok { _spec.SetField(permission.FieldDescription, field.TypeString, value) } - if value, ok := puo.mutation.DataScope(); ok { + if value, ok := _u.mutation.DataScope(); ok { _spec.SetField(permission.FieldDataScope, field.TypeString, value) } - if value, ok := puo.mutation.DataRules(); ok { + if value, ok := _u.mutation.DataRules(); ok { _spec.SetField(permission.FieldDataRules, field.TypeJSON, value) } - if puo.mutation.DataRulesCleared() { + if _u.mutation.DataRulesCleared() { _spec.ClearField(permission.FieldDataRules, field.TypeJSON) } - if value, ok := puo.mutation.Actions(); ok { + if value, ok := _u.mutation.Actions(); ok { _spec.SetField(permission.FieldActions, field.TypeEnum, value) } - if puo.mutation.RolesCleared() { + if _u.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1194,7 +1194,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedRolesIDs(); len(nodes) > 0 && !puo.mutation.RolesCleared() { + if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1210,7 +1210,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RolesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1226,7 +1226,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if puo.mutation.PositionsCleared() { + if _u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1239,7 +1239,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !puo.mutation.PositionsCleared() { + if nodes := _u.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !_u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1255,7 +1255,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.PositionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1271,7 +1271,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if puo.mutation.ResourcesCleared() { + if _u.mutation.ResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1284,7 +1284,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !puo.mutation.ResourcesCleared() { + if nodes := _u.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !_u.mutation.ResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1300,7 +1300,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.ResourcesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1316,7 +1316,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if puo.mutation.RolePermissionsCleared() { + if _u.mutation.RolePermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1329,7 +1329,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !puo.mutation.RolePermissionsCleared() { + if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1345,7 +1345,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RolePermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1361,7 +1361,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if puo.mutation.PositionPermissionsCleared() { + if _u.mutation.PositionPermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1374,7 +1374,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedPositionPermissionsIDs(); len(nodes) > 0 && !puo.mutation.PositionPermissionsCleared() { + if nodes := _u.mutation.RemovedPositionPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PositionPermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1390,7 +1390,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.PositionPermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionPermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1406,7 +1406,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if puo.mutation.PermissionResourcesCleared() { + if _u.mutation.PermissionResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1419,7 +1419,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !puo.mutation.PermissionResourcesCleared() { + if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1435,7 +1435,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1451,11 +1451,11 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(puo.modifiers...) - _node = &Permission{config: puo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Permission{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{permission.Label} } else if sqlgraph.IsConstraintError(err) { @@ -1463,7 +1463,7 @@ func (puo *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } return nil, err } - puo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/permissionresource.go b/internal/data/entity/ent/permissionresource.go index 44ee86dd..f0b9b08c 100644 --- a/internal/data/entity/ent/permissionresource.go +++ b/internal/data/entity/ent/permissionresource.go @@ -77,7 +77,7 @@ func (*PermissionResource) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the PermissionResource fields. -func (pr *PermissionResource) assignValues(columns []string, values []any) error { +func (_m *PermissionResource) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -88,21 +88,21 @@ func (pr *PermissionResource) assignValues(columns []string, values []any) error if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - pr.ID = int(value.Int64) + _m.ID = int(value.Int64) case permissionresource.FieldPermissionID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field permission_id", values[i]) } else if value.Valid { - pr.PermissionID = value.Int64 + _m.PermissionID = value.Int64 } case permissionresource.FieldResourceID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field resource_id", values[i]) } else if value.Valid { - pr.ResourceID = value.Int64 + _m.ResourceID = value.Int64 } default: - pr.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -110,48 +110,48 @@ func (pr *PermissionResource) assignValues(columns []string, values []any) error // Value returns the ent.Value that was dynamically selected and assigned to the PermissionResource. // This includes values selected through modifiers, order, etc. -func (pr *PermissionResource) Value(name string) (ent.Value, error) { - return pr.selectValues.Get(name) +func (_m *PermissionResource) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryPermission queries the "permission" edge of the PermissionResource entity. -func (pr *PermissionResource) QueryPermission() *PermissionQuery { - return NewPermissionResourceClient(pr.config).QueryPermission(pr) +func (_m *PermissionResource) QueryPermission() *PermissionQuery { + return NewPermissionResourceClient(_m.config).QueryPermission(_m) } // QueryResource queries the "resource" edge of the PermissionResource entity. -func (pr *PermissionResource) QueryResource() *ResourceQuery { - return NewPermissionResourceClient(pr.config).QueryResource(pr) +func (_m *PermissionResource) QueryResource() *ResourceQuery { + return NewPermissionResourceClient(_m.config).QueryResource(_m) } // Update returns a builder for updating this PermissionResource. // Note that you need to call PermissionResource.Unwrap() before calling this method if this PermissionResource // was returned from a transaction, and the transaction was committed or rolled back. -func (pr *PermissionResource) Update() *PermissionResourceUpdateOne { - return NewPermissionResourceClient(pr.config).UpdateOne(pr) +func (_m *PermissionResource) Update() *PermissionResourceUpdateOne { + return NewPermissionResourceClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the PermissionResource entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (pr *PermissionResource) Unwrap() *PermissionResource { - _tx, ok := pr.config.driver.(*txDriver) +func (_m *PermissionResource) Unwrap() *PermissionResource { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: PermissionResource is not a transactional entity") } - pr.config.driver = _tx.drv - return pr + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (pr *PermissionResource) String() string { +func (_m *PermissionResource) String() string { var builder strings.Builder builder.WriteString("PermissionResource(") - builder.WriteString(fmt.Sprintf("id=%v, ", pr.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("permission_id=") - builder.WriteString(fmt.Sprintf("%v", pr.PermissionID)) + builder.WriteString(fmt.Sprintf("%v", _m.PermissionID)) builder.WriteString(", ") builder.WriteString("resource_id=") - builder.WriteString(fmt.Sprintf("%v", pr.ResourceID)) + builder.WriteString(fmt.Sprintf("%v", _m.ResourceID)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/permissionresource_create.go b/internal/data/entity/ent/permissionresource_create.go index 16db9732..6cde80eb 100644 --- a/internal/data/entity/ent/permissionresource_create.go +++ b/internal/data/entity/ent/permissionresource_create.go @@ -22,40 +22,40 @@ type PermissionResourceCreate struct { } // SetPermissionID sets the "permission_id" field. -func (prc *PermissionResourceCreate) SetPermissionID(i int64) *PermissionResourceCreate { - prc.mutation.SetPermissionID(i) - return prc +func (_c *PermissionResourceCreate) SetPermissionID(v int64) *PermissionResourceCreate { + _c.mutation.SetPermissionID(v) + return _c } // SetResourceID sets the "resource_id" field. -func (prc *PermissionResourceCreate) SetResourceID(i int64) *PermissionResourceCreate { - prc.mutation.SetResourceID(i) - return prc +func (_c *PermissionResourceCreate) SetResourceID(v int64) *PermissionResourceCreate { + _c.mutation.SetResourceID(v) + return _c } // SetPermission sets the "permission" edge to the Permission entity. -func (prc *PermissionResourceCreate) SetPermission(p *Permission) *PermissionResourceCreate { - return prc.SetPermissionID(p.ID) +func (_c *PermissionResourceCreate) SetPermission(v *Permission) *PermissionResourceCreate { + return _c.SetPermissionID(v.ID) } // SetResource sets the "resource" edge to the Resource entity. -func (prc *PermissionResourceCreate) SetResource(r *Resource) *PermissionResourceCreate { - return prc.SetResourceID(r.ID) +func (_c *PermissionResourceCreate) SetResource(v *Resource) *PermissionResourceCreate { + return _c.SetResourceID(v.ID) } // Mutation returns the PermissionResourceMutation object of the builder. -func (prc *PermissionResourceCreate) Mutation() *PermissionResourceMutation { - return prc.mutation +func (_c *PermissionResourceCreate) Mutation() *PermissionResourceMutation { + return _c.mutation } // Save creates the PermissionResource in the database. -func (prc *PermissionResourceCreate) Save(ctx context.Context) (*PermissionResource, error) { - return withHooks(ctx, prc.sqlSave, prc.mutation, prc.hooks) +func (_c *PermissionResourceCreate) Save(ctx context.Context) (*PermissionResource, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (prc *PermissionResourceCreate) SaveX(ctx context.Context) *PermissionResource { - v, err := prc.Save(ctx) +func (_c *PermissionResourceCreate) SaveX(ctx context.Context) *PermissionResource { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -63,51 +63,51 @@ func (prc *PermissionResourceCreate) SaveX(ctx context.Context) *PermissionResou } // Exec executes the query. -func (prc *PermissionResourceCreate) Exec(ctx context.Context) error { - _, err := prc.Save(ctx) +func (_c *PermissionResourceCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (prc *PermissionResourceCreate) ExecX(ctx context.Context) { - if err := prc.Exec(ctx); err != nil { +func (_c *PermissionResourceCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (prc *PermissionResourceCreate) check() error { - if _, ok := prc.mutation.PermissionID(); !ok { +func (_c *PermissionResourceCreate) check() error { + if _, ok := _c.mutation.PermissionID(); !ok { return &ValidationError{Name: "permission_id", err: errors.New(`ent: missing required field "PermissionResource.permission_id"`)} } - if v, ok := prc.mutation.PermissionID(); ok { + if v, ok := _c.mutation.PermissionID(); ok { if err := permissionresource.PermissionIDValidator(v); err != nil { return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "PermissionResource.permission_id": %w`, err)} } } - if _, ok := prc.mutation.ResourceID(); !ok { + if _, ok := _c.mutation.ResourceID(); !ok { return &ValidationError{Name: "resource_id", err: errors.New(`ent: missing required field "PermissionResource.resource_id"`)} } - if v, ok := prc.mutation.ResourceID(); ok { + if v, ok := _c.mutation.ResourceID(); ok { if err := permissionresource.ResourceIDValidator(v); err != nil { return &ValidationError{Name: "resource_id", err: fmt.Errorf(`ent: validator failed for field "PermissionResource.resource_id": %w`, err)} } } - if len(prc.mutation.PermissionIDs()) == 0 { + if len(_c.mutation.PermissionIDs()) == 0 { return &ValidationError{Name: "permission", err: errors.New(`ent: missing required edge "PermissionResource.permission"`)} } - if len(prc.mutation.ResourceIDs()) == 0 { + if len(_c.mutation.ResourceIDs()) == 0 { return &ValidationError{Name: "resource", err: errors.New(`ent: missing required edge "PermissionResource.resource"`)} } return nil } -func (prc *PermissionResourceCreate) sqlSave(ctx context.Context) (*PermissionResource, error) { - if err := prc.check(); err != nil { +func (_c *PermissionResourceCreate) sqlSave(ctx context.Context) (*PermissionResource, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := prc.createSpec() - if err := sqlgraph.CreateNode(ctx, prc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -115,17 +115,17 @@ func (prc *PermissionResourceCreate) sqlSave(ctx context.Context) (*PermissionRe } id := _spec.ID.Value.(int64) _node.ID = int(id) - prc.mutation.id = &_node.ID - prc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (prc *PermissionResourceCreate) createSpec() (*PermissionResource, *sqlgraph.CreateSpec) { +func (_c *PermissionResourceCreate) createSpec() (*PermissionResource, *sqlgraph.CreateSpec) { var ( - _node = &PermissionResource{config: prc.config} + _node = &PermissionResource{config: _c.config} _spec = sqlgraph.NewCreateSpec(permissionresource.Table, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) ) - if nodes := prc.mutation.PermissionIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PermissionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -142,7 +142,7 @@ func (prc *PermissionResourceCreate) createSpec() (*PermissionResource, *sqlgrap _node.PermissionID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := prc.mutation.ResourceIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ResourceIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -163,23 +163,23 @@ func (prc *PermissionResourceCreate) createSpec() (*PermissionResource, *sqlgrap } // SetPermissionResource set the PermissionResource -func (prc *PermissionResourceCreate) SetPermissionResource(input *PermissionResource, fields ...string) *PermissionResourceCreate { - m := prc.mutation +func (_c *PermissionResourceCreate) SetPermissionResource(input *PermissionResource, fields ...string) *PermissionResourceCreate { + m := _c.mutation if len(fields) == 0 { fields = permissionresource.Columns } _ = m.SetFields(input, fields...) - return prc + return _c } // SetPermissionResourceWithZero set the PermissionResource -func (prc *PermissionResourceCreate) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceCreate { - m := prc.mutation +func (_c *PermissionResourceCreate) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceCreate { + m := _c.mutation if len(fields) == 0 { fields = permissionresource.Columns } _ = m.SetFieldsWithZero(input, fields...) - return prc + return _c } // PermissionResourceCreateBulk is the builder for creating many PermissionResource entities in bulk. @@ -190,16 +190,16 @@ type PermissionResourceCreateBulk struct { } // Save creates the PermissionResource entities in the database. -func (prcb *PermissionResourceCreateBulk) Save(ctx context.Context) ([]*PermissionResource, error) { - if prcb.err != nil { - return nil, prcb.err +func (_c *PermissionResourceCreateBulk) Save(ctx context.Context) ([]*PermissionResource, error) { + if _c.err != nil { + return nil, _c.err } - specs := make([]*sqlgraph.CreateSpec, len(prcb.builders)) - nodes := make([]*PermissionResource, len(prcb.builders)) - mutators := make([]Mutator, len(prcb.builders)) - for i := range prcb.builders { + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*PermissionResource, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := prcb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*PermissionResourceMutation) if !ok { @@ -212,11 +212,11 @@ func (prcb *PermissionResourceCreateBulk) Save(ctx context.Context) ([]*Permissi var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, prcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, prcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -240,7 +240,7 @@ func (prcb *PermissionResourceCreateBulk) Save(ctx context.Context) ([]*Permissi }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, prcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -248,8 +248,8 @@ func (prcb *PermissionResourceCreateBulk) Save(ctx context.Context) ([]*Permissi } // SaveX is like Save, but panics if an error occurs. -func (prcb *PermissionResourceCreateBulk) SaveX(ctx context.Context) []*PermissionResource { - v, err := prcb.Save(ctx) +func (_c *PermissionResourceCreateBulk) SaveX(ctx context.Context) []*PermissionResource { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -257,14 +257,14 @@ func (prcb *PermissionResourceCreateBulk) SaveX(ctx context.Context) []*Permissi } // Exec executes the query. -func (prcb *PermissionResourceCreateBulk) Exec(ctx context.Context) error { - _, err := prcb.Save(ctx) +func (_c *PermissionResourceCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (prcb *PermissionResourceCreateBulk) ExecX(ctx context.Context) { - if err := prcb.Exec(ctx); err != nil { +func (_c *PermissionResourceCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/permissionresource_delete.go b/internal/data/entity/ent/permissionresource_delete.go index d2d61f5c..f62ebae9 100644 --- a/internal/data/entity/ent/permissionresource_delete.go +++ b/internal/data/entity/ent/permissionresource_delete.go @@ -20,56 +20,56 @@ type PermissionResourceDelete struct { } // Where appends a list predicates to the PermissionResourceDelete builder. -func (prd *PermissionResourceDelete) Where(ps ...predicate.PermissionResource) *PermissionResourceDelete { - prd.mutation.Where(ps...) - return prd +func (_d *PermissionResourceDelete) Where(ps ...predicate.PermissionResource) *PermissionResourceDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (prd *PermissionResourceDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, prd.sqlExec, prd.mutation, prd.hooks) +func (_d *PermissionResourceDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (prd *PermissionResourceDelete) ExecX(ctx context.Context) int { - n, err := prd.Exec(ctx) +func (_d *PermissionResourceDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (prd *PermissionResourceDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *PermissionResourceDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(permissionresource.Table, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) - if ps := prd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, prd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - prd.mutation.done = true + _d.mutation.done = true return affected, err } // PermissionResourceDeleteOne is the builder for deleting a single PermissionResource entity. type PermissionResourceDeleteOne struct { - prd *PermissionResourceDelete + _d *PermissionResourceDelete } // Where appends a list predicates to the PermissionResourceDelete builder. -func (prdo *PermissionResourceDeleteOne) Where(ps ...predicate.PermissionResource) *PermissionResourceDeleteOne { - prdo.prd.mutation.Where(ps...) - return prdo +func (_d *PermissionResourceDeleteOne) Where(ps ...predicate.PermissionResource) *PermissionResourceDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (prdo *PermissionResourceDeleteOne) Exec(ctx context.Context) error { - n, err := prdo.prd.Exec(ctx) +func (_d *PermissionResourceDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (prdo *PermissionResourceDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (prdo *PermissionResourceDeleteOne) ExecX(ctx context.Context) { - if err := prdo.Exec(ctx); err != nil { +func (_d *PermissionResourceDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/permissionresource_query.go b/internal/data/entity/ent/permissionresource_query.go index aeac5c2c..3aca3327 100644 --- a/internal/data/entity/ent/permissionresource_query.go +++ b/internal/data/entity/ent/permissionresource_query.go @@ -34,44 +34,44 @@ type PermissionResourceQuery struct { } // Where adds a new predicate for the PermissionResourceQuery builder. -func (prq *PermissionResourceQuery) Where(ps ...predicate.PermissionResource) *PermissionResourceQuery { - prq.predicates = append(prq.predicates, ps...) - return prq +func (_q *PermissionResourceQuery) Where(ps ...predicate.PermissionResource) *PermissionResourceQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (prq *PermissionResourceQuery) Limit(limit int) *PermissionResourceQuery { - prq.ctx.Limit = &limit - return prq +func (_q *PermissionResourceQuery) Limit(limit int) *PermissionResourceQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (prq *PermissionResourceQuery) Offset(offset int) *PermissionResourceQuery { - prq.ctx.Offset = &offset - return prq +func (_q *PermissionResourceQuery) Offset(offset int) *PermissionResourceQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (prq *PermissionResourceQuery) Unique(unique bool) *PermissionResourceQuery { - prq.ctx.Unique = &unique - return prq +func (_q *PermissionResourceQuery) Unique(unique bool) *PermissionResourceQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (prq *PermissionResourceQuery) Order(o ...permissionresource.OrderOption) *PermissionResourceQuery { - prq.order = append(prq.order, o...) - return prq +func (_q *PermissionResourceQuery) Order(o ...permissionresource.OrderOption) *PermissionResourceQuery { + _q.order = append(_q.order, o...) + return _q } // QueryPermission chains the current query on the "permission" edge. -func (prq *PermissionResourceQuery) QueryPermission() *PermissionQuery { - query := (&PermissionClient{config: prq.config}).Query() +func (_q *PermissionResourceQuery) QueryPermission() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := prq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := prq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -80,20 +80,20 @@ func (prq *PermissionResourceQuery) QueryPermission() *PermissionQuery { sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.PermissionTable, permissionresource.PermissionColumn), ) - fromU = sqlgraph.SetNeighbors(prq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryResource chains the current query on the "resource" edge. -func (prq *PermissionResourceQuery) QueryResource() *ResourceQuery { - query := (&ResourceClient{config: prq.config}).Query() +func (_q *PermissionResourceQuery) QueryResource() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := prq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := prq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -102,7 +102,7 @@ func (prq *PermissionResourceQuery) QueryResource() *ResourceQuery { sqlgraph.To(resource.Table, resource.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.ResourceTable, permissionresource.ResourceColumn), ) - fromU = sqlgraph.SetNeighbors(prq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -110,8 +110,8 @@ func (prq *PermissionResourceQuery) QueryResource() *ResourceQuery { // First returns the first PermissionResource entity from the query. // Returns a *NotFoundError when no PermissionResource was found. -func (prq *PermissionResourceQuery) First(ctx context.Context) (*PermissionResource, error) { - nodes, err := prq.Limit(1).All(setContextOp(ctx, prq.ctx, ent.OpQueryFirst)) +func (_q *PermissionResourceQuery) First(ctx context.Context) (*PermissionResource, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -122,8 +122,8 @@ func (prq *PermissionResourceQuery) First(ctx context.Context) (*PermissionResou } // FirstX is like First, but panics if an error occurs. -func (prq *PermissionResourceQuery) FirstX(ctx context.Context) *PermissionResource { - node, err := prq.First(ctx) +func (_q *PermissionResourceQuery) FirstX(ctx context.Context) *PermissionResource { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -132,9 +132,9 @@ func (prq *PermissionResourceQuery) FirstX(ctx context.Context) *PermissionResou // FirstID returns the first PermissionResource ID from the query. // Returns a *NotFoundError when no PermissionResource ID was found. -func (prq *PermissionResourceQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *PermissionResourceQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = prq.Limit(1).IDs(setContextOp(ctx, prq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -145,8 +145,8 @@ func (prq *PermissionResourceQuery) FirstID(ctx context.Context) (id int, err er } // FirstIDX is like FirstID, but panics if an error occurs. -func (prq *PermissionResourceQuery) FirstIDX(ctx context.Context) int { - id, err := prq.FirstID(ctx) +func (_q *PermissionResourceQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -156,8 +156,8 @@ func (prq *PermissionResourceQuery) FirstIDX(ctx context.Context) int { // Only returns a single PermissionResource entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one PermissionResource entity is found. // Returns a *NotFoundError when no PermissionResource entities are found. -func (prq *PermissionResourceQuery) Only(ctx context.Context) (*PermissionResource, error) { - nodes, err := prq.Limit(2).All(setContextOp(ctx, prq.ctx, ent.OpQueryOnly)) +func (_q *PermissionResourceQuery) Only(ctx context.Context) (*PermissionResource, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -172,8 +172,8 @@ func (prq *PermissionResourceQuery) Only(ctx context.Context) (*PermissionResour } // OnlyX is like Only, but panics if an error occurs. -func (prq *PermissionResourceQuery) OnlyX(ctx context.Context) *PermissionResource { - node, err := prq.Only(ctx) +func (_q *PermissionResourceQuery) OnlyX(ctx context.Context) *PermissionResource { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -183,9 +183,9 @@ func (prq *PermissionResourceQuery) OnlyX(ctx context.Context) *PermissionResour // OnlyID is like Only, but returns the only PermissionResource ID in the query. // Returns a *NotSingularError when more than one PermissionResource ID is found. // Returns a *NotFoundError when no entities are found. -func (prq *PermissionResourceQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *PermissionResourceQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = prq.Limit(2).IDs(setContextOp(ctx, prq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -200,8 +200,8 @@ func (prq *PermissionResourceQuery) OnlyID(ctx context.Context) (id int, err err } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (prq *PermissionResourceQuery) OnlyIDX(ctx context.Context) int { - id, err := prq.OnlyID(ctx) +func (_q *PermissionResourceQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -209,18 +209,18 @@ func (prq *PermissionResourceQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of PermissionResources. -func (prq *PermissionResourceQuery) All(ctx context.Context) ([]*PermissionResource, error) { - ctx = setContextOp(ctx, prq.ctx, ent.OpQueryAll) - if err := prq.prepareQuery(ctx); err != nil { +func (_q *PermissionResourceQuery) All(ctx context.Context) ([]*PermissionResource, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*PermissionResource, *PermissionResourceQuery]() - return withInterceptors[[]*PermissionResource](ctx, prq, qr, prq.inters) + return withInterceptors[[]*PermissionResource](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (prq *PermissionResourceQuery) AllX(ctx context.Context) []*PermissionResource { - nodes, err := prq.All(ctx) +func (_q *PermissionResourceQuery) AllX(ctx context.Context) []*PermissionResource { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -228,20 +228,20 @@ func (prq *PermissionResourceQuery) AllX(ctx context.Context) []*PermissionResou } // IDs executes the query and returns a list of PermissionResource IDs. -func (prq *PermissionResourceQuery) IDs(ctx context.Context) (ids []int, err error) { - if prq.ctx.Unique == nil && prq.path != nil { - prq.Unique(true) +func (_q *PermissionResourceQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, prq.ctx, ent.OpQueryIDs) - if err = prq.Select(permissionresource.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(permissionresource.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (prq *PermissionResourceQuery) IDsX(ctx context.Context) []int { - ids, err := prq.IDs(ctx) +func (_q *PermissionResourceQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -249,17 +249,17 @@ func (prq *PermissionResourceQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (prq *PermissionResourceQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, prq.ctx, ent.OpQueryCount) - if err := prq.prepareQuery(ctx); err != nil { +func (_q *PermissionResourceQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, prq, querierCount[*PermissionResourceQuery](), prq.inters) + return withInterceptors[int](ctx, _q, querierCount[*PermissionResourceQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (prq *PermissionResourceQuery) CountX(ctx context.Context) int { - count, err := prq.Count(ctx) +func (_q *PermissionResourceQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -267,9 +267,9 @@ func (prq *PermissionResourceQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (prq *PermissionResourceQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, prq.ctx, ent.OpQueryExist) - switch _, err := prq.FirstID(ctx); { +func (_q *PermissionResourceQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -280,8 +280,8 @@ func (prq *PermissionResourceQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (prq *PermissionResourceQuery) ExistX(ctx context.Context) bool { - exist, err := prq.Exist(ctx) +func (_q *PermissionResourceQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -290,45 +290,45 @@ func (prq *PermissionResourceQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the PermissionResourceQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (prq *PermissionResourceQuery) Clone() *PermissionResourceQuery { - if prq == nil { +func (_q *PermissionResourceQuery) Clone() *PermissionResourceQuery { + if _q == nil { return nil } return &PermissionResourceQuery{ - config: prq.config, - ctx: prq.ctx.Clone(), - order: append([]permissionresource.OrderOption{}, prq.order...), - inters: append([]Interceptor{}, prq.inters...), - predicates: append([]predicate.PermissionResource{}, prq.predicates...), - withPermission: prq.withPermission.Clone(), - withResource: prq.withResource.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]permissionresource.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.PermissionResource{}, _q.predicates...), + withPermission: _q.withPermission.Clone(), + withResource: _q.withResource.Clone(), // clone intermediate query. - sql: prq.sql.Clone(), - path: prq.path, - modifiers: append([]func(*sql.Selector){}, prq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithPermission tells the query-builder to eager-load the nodes that are connected to // the "permission" edge. The optional arguments are used to configure the query builder of the edge. -func (prq *PermissionResourceQuery) WithPermission(opts ...func(*PermissionQuery)) *PermissionResourceQuery { - query := (&PermissionClient{config: prq.config}).Query() +func (_q *PermissionResourceQuery) WithPermission(opts ...func(*PermissionQuery)) *PermissionResourceQuery { + query := (&PermissionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - prq.withPermission = query - return prq + _q.withPermission = query + return _q } // WithResource tells the query-builder to eager-load the nodes that are connected to // the "resource" edge. The optional arguments are used to configure the query builder of the edge. -func (prq *PermissionResourceQuery) WithResource(opts ...func(*ResourceQuery)) *PermissionResourceQuery { - query := (&ResourceClient{config: prq.config}).Query() +func (_q *PermissionResourceQuery) WithResource(opts ...func(*ResourceQuery)) *PermissionResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - prq.withResource = query - return prq + _q.withResource = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -345,10 +345,10 @@ func (prq *PermissionResourceQuery) WithResource(opts ...func(*ResourceQuery)) * // GroupBy(permissionresource.FieldPermissionID). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (prq *PermissionResourceQuery) GroupBy(field string, fields ...string) *PermissionResourceGroupBy { - prq.ctx.Fields = append([]string{field}, fields...) - grbuild := &PermissionResourceGroupBy{build: prq} - grbuild.flds = &prq.ctx.Fields +func (_q *PermissionResourceQuery) GroupBy(field string, fields ...string) *PermissionResourceGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PermissionResourceGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = permissionresource.Label grbuild.scan = grbuild.Scan return grbuild @@ -366,83 +366,83 @@ func (prq *PermissionResourceQuery) GroupBy(field string, fields ...string) *Per // client.PermissionResource.Query(). // Select(permissionresource.FieldPermissionID). // Scan(ctx, &v) -func (prq *PermissionResourceQuery) Select(fields ...string) *PermissionResourceSelect { - prq.ctx.Fields = append(prq.ctx.Fields, fields...) - sbuild := &PermissionResourceSelect{PermissionResourceQuery: prq} +func (_q *PermissionResourceQuery) Select(fields ...string) *PermissionResourceSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PermissionResourceSelect{PermissionResourceQuery: _q} sbuild.label = permissionresource.Label - sbuild.flds, sbuild.scan = &prq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a PermissionResourceSelect configured with the given aggregations. -func (prq *PermissionResourceQuery) Aggregate(fns ...AggregateFunc) *PermissionResourceSelect { - return prq.Select().Aggregate(fns...) +func (_q *PermissionResourceQuery) Aggregate(fns ...AggregateFunc) *PermissionResourceSelect { + return _q.Select().Aggregate(fns...) } -func (prq *PermissionResourceQuery) prepareQuery(ctx context.Context) error { - for _, inter := range prq.inters { +func (_q *PermissionResourceQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, prq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range prq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !permissionresource.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if prq.path != nil { - prev, err := prq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - prq.sql = prev + _q.sql = prev } return nil } -func (prq *PermissionResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PermissionResource, error) { +func (_q *PermissionResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PermissionResource, error) { var ( nodes = []*PermissionResource{} - _spec = prq.querySpec() + _spec = _q.querySpec() loadedTypes = [2]bool{ - prq.withPermission != nil, - prq.withResource != nil, + _q.withPermission != nil, + _q.withResource != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*PermissionResource).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &PermissionResource{config: prq.config} + node := &PermissionResource{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(prq.modifiers) > 0 { - _spec.Modifiers = prq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, prq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := prq.withPermission; query != nil { - if err := prq.loadPermission(ctx, query, nodes, nil, + if query := _q.withPermission; query != nil { + if err := _q.loadPermission(ctx, query, nodes, nil, func(n *PermissionResource, e *Permission) { n.Edges.Permission = e }); err != nil { return nil, err } } - if query := prq.withResource; query != nil { - if err := prq.loadResource(ctx, query, nodes, nil, + if query := _q.withResource; query != nil { + if err := _q.loadResource(ctx, query, nodes, nil, func(n *PermissionResource, e *Resource) { n.Edges.Resource = e }); err != nil { return nil, err } @@ -450,7 +450,7 @@ func (prq *PermissionResourceQuery) sqlAll(ctx context.Context, hooks ...queryHo return nodes, nil } -func (prq *PermissionResourceQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*PermissionResource, init func(*PermissionResource), assign func(*PermissionResource, *Permission)) error { +func (_q *PermissionResourceQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*PermissionResource, init func(*PermissionResource), assign func(*PermissionResource, *Permission)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*PermissionResource) for i := range nodes { @@ -479,7 +479,7 @@ func (prq *PermissionResourceQuery) loadPermission(ctx context.Context, query *P } return nil } -func (prq *PermissionResourceQuery) loadResource(ctx context.Context, query *ResourceQuery, nodes []*PermissionResource, init func(*PermissionResource), assign func(*PermissionResource, *Resource)) error { +func (_q *PermissionResourceQuery) loadResource(ctx context.Context, query *ResourceQuery, nodes []*PermissionResource, init func(*PermissionResource), assign func(*PermissionResource, *Resource)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*PermissionResource) for i := range nodes { @@ -509,27 +509,27 @@ func (prq *PermissionResourceQuery) loadResource(ctx context.Context, query *Res return nil } -func (prq *PermissionResourceQuery) sqlCount(ctx context.Context) (int, error) { - _spec := prq.querySpec() - if len(prq.modifiers) > 0 { - _spec.Modifiers = prq.modifiers +func (_q *PermissionResourceQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = prq.ctx.Fields - if len(prq.ctx.Fields) > 0 { - _spec.Unique = prq.ctx.Unique != nil && *prq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, prq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (prq *PermissionResourceQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *PermissionResourceQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(permissionresource.Table, permissionresource.Columns, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) - _spec.From = prq.sql - if unique := prq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if prq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := prq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, permissionresource.FieldID) for i := range fields { @@ -537,27 +537,27 @@ func (prq *PermissionResourceQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if prq.withPermission != nil { + if _q.withPermission != nil { _spec.Node.AddColumnOnce(permissionresource.FieldPermissionID) } - if prq.withResource != nil { + if _q.withResource != nil { _spec.Node.AddColumnOnce(permissionresource.FieldResourceID) } } - if ps := prq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := prq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := prq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := prq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -567,36 +567,36 @@ func (prq *PermissionResourceQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (prq *PermissionResourceQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(prq.driver.Dialect()) +func (_q *PermissionResourceQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(permissionresource.Table) - columns := prq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = permissionresource.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if prq.sql != nil { - selector = prq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if prq.ctx.Unique != nil && *prq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range prq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range prq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range prq.order { + for _, p := range _q.order { p(selector) } - if offset := prq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := prq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -605,33 +605,33 @@ func (prq *PermissionResourceQuery) sqlQuery(ctx context.Context) *sql.Selector // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (prq *PermissionResourceQuery) ForUpdate(opts ...sql.LockOption) *PermissionResourceQuery { - if prq.driver.Dialect() == dialect.Postgres { - prq.Unique(false) +func (_q *PermissionResourceQuery) ForUpdate(opts ...sql.LockOption) *PermissionResourceQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - prq.modifiers = append(prq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return prq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (prq *PermissionResourceQuery) ForShare(opts ...sql.LockOption) *PermissionResourceQuery { - if prq.driver.Dialect() == dialect.Postgres { - prq.Unique(false) +func (_q *PermissionResourceQuery) ForShare(opts ...sql.LockOption) *PermissionResourceQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - prq.modifiers = append(prq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return prq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (prq *PermissionResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *PermissionResourceSelect { - prq.modifiers = append(prq.modifiers, modifiers...) - return prq.Select() +func (_q *PermissionResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *PermissionResourceSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -673,41 +673,41 @@ type PermissionResourceGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (prgb *PermissionResourceGroupBy) Aggregate(fns ...AggregateFunc) *PermissionResourceGroupBy { - prgb.fns = append(prgb.fns, fns...) - return prgb +func (_g *PermissionResourceGroupBy) Aggregate(fns ...AggregateFunc) *PermissionResourceGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (prgb *PermissionResourceGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, prgb.build.ctx, ent.OpQueryGroupBy) - if err := prgb.build.prepareQuery(ctx); err != nil { +func (_g *PermissionResourceGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*PermissionResourceQuery, *PermissionResourceGroupBy](ctx, prgb.build, prgb, prgb.build.inters, v) + return scanWithInterceptors[*PermissionResourceQuery, *PermissionResourceGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (prgb *PermissionResourceGroupBy) sqlScan(ctx context.Context, root *PermissionResourceQuery, v any) error { +func (_g *PermissionResourceGroupBy) sqlScan(ctx context.Context, root *PermissionResourceQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(prgb.fns)) - for _, fn := range prgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*prgb.flds)+len(prgb.fns)) - for _, f := range *prgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*prgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := prgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -721,27 +721,27 @@ type PermissionResourceSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (prs *PermissionResourceSelect) Aggregate(fns ...AggregateFunc) *PermissionResourceSelect { - prs.fns = append(prs.fns, fns...) - return prs +func (_s *PermissionResourceSelect) Aggregate(fns ...AggregateFunc) *PermissionResourceSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (prs *PermissionResourceSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, prs.ctx, ent.OpQuerySelect) - if err := prs.prepareQuery(ctx); err != nil { +func (_s *PermissionResourceSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*PermissionResourceQuery, *PermissionResourceSelect](ctx, prs.PermissionResourceQuery, prs, prs.inters, v) + return scanWithInterceptors[*PermissionResourceQuery, *PermissionResourceSelect](ctx, _s.PermissionResourceQuery, _s, _s.inters, v) } -func (prs *PermissionResourceSelect) sqlScan(ctx context.Context, root *PermissionResourceQuery, v any) error { +func (_s *PermissionResourceSelect) sqlScan(ctx context.Context, root *PermissionResourceQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(prs.fns)) - for _, fn := range prs.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*prs.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -749,7 +749,7 @@ func (prs *PermissionResourceSelect) sqlScan(ctx context.Context, root *Permissi } rows := &sql.Rows{} query, args := selector.Query() - if err := prs.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -757,7 +757,7 @@ func (prs *PermissionResourceSelect) sqlScan(ctx context.Context, root *Permissi } // Modify adds a query modifier for attaching custom logic to queries. -func (prs *PermissionResourceSelect) Modify(modifiers ...func(s *sql.Selector)) *PermissionResourceSelect { - prs.modifiers = append(prs.modifiers, modifiers...) - return prs +func (_s *PermissionResourceSelect) Modify(modifiers ...func(s *sql.Selector)) *PermissionResourceSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/permissionresource_update.go b/internal/data/entity/ent/permissionresource_update.go index 70b40ef8..e8059d4e 100644 --- a/internal/data/entity/ent/permissionresource_update.go +++ b/internal/data/entity/ent/permissionresource_update.go @@ -25,74 +25,74 @@ type PermissionResourceUpdate struct { } // Where appends a list predicates to the PermissionResourceUpdate builder. -func (pru *PermissionResourceUpdate) Where(ps ...predicate.PermissionResource) *PermissionResourceUpdate { - pru.mutation.Where(ps...) - return pru +func (_u *PermissionResourceUpdate) Where(ps ...predicate.PermissionResource) *PermissionResourceUpdate { + _u.mutation.Where(ps...) + return _u } // SetPermissionID sets the "permission_id" field. -func (pru *PermissionResourceUpdate) SetPermissionID(i int64) *PermissionResourceUpdate { - pru.mutation.SetPermissionID(i) - return pru +func (_u *PermissionResourceUpdate) SetPermissionID(v int64) *PermissionResourceUpdate { + _u.mutation.SetPermissionID(v) + return _u } // SetNillablePermissionID sets the "permission_id" field if the given value is not nil. -func (pru *PermissionResourceUpdate) SetNillablePermissionID(i *int64) *PermissionResourceUpdate { - if i != nil { - pru.SetPermissionID(*i) +func (_u *PermissionResourceUpdate) SetNillablePermissionID(v *int64) *PermissionResourceUpdate { + if v != nil { + _u.SetPermissionID(*v) } - return pru + return _u } // SetResourceID sets the "resource_id" field. -func (pru *PermissionResourceUpdate) SetResourceID(i int64) *PermissionResourceUpdate { - pru.mutation.SetResourceID(i) - return pru +func (_u *PermissionResourceUpdate) SetResourceID(v int64) *PermissionResourceUpdate { + _u.mutation.SetResourceID(v) + return _u } // SetNillableResourceID sets the "resource_id" field if the given value is not nil. -func (pru *PermissionResourceUpdate) SetNillableResourceID(i *int64) *PermissionResourceUpdate { - if i != nil { - pru.SetResourceID(*i) +func (_u *PermissionResourceUpdate) SetNillableResourceID(v *int64) *PermissionResourceUpdate { + if v != nil { + _u.SetResourceID(*v) } - return pru + return _u } // SetPermission sets the "permission" edge to the Permission entity. -func (pru *PermissionResourceUpdate) SetPermission(p *Permission) *PermissionResourceUpdate { - return pru.SetPermissionID(p.ID) +func (_u *PermissionResourceUpdate) SetPermission(v *Permission) *PermissionResourceUpdate { + return _u.SetPermissionID(v.ID) } // SetResource sets the "resource" edge to the Resource entity. -func (pru *PermissionResourceUpdate) SetResource(r *Resource) *PermissionResourceUpdate { - return pru.SetResourceID(r.ID) +func (_u *PermissionResourceUpdate) SetResource(v *Resource) *PermissionResourceUpdate { + return _u.SetResourceID(v.ID) } // Mutation returns the PermissionResourceMutation object of the builder. -func (pru *PermissionResourceUpdate) Mutation() *PermissionResourceMutation { - return pru.mutation +func (_u *PermissionResourceUpdate) Mutation() *PermissionResourceMutation { + return _u.mutation } // ClearPermission clears the "permission" edge to the Permission entity. -func (pru *PermissionResourceUpdate) ClearPermission() *PermissionResourceUpdate { - pru.mutation.ClearPermission() - return pru +func (_u *PermissionResourceUpdate) ClearPermission() *PermissionResourceUpdate { + _u.mutation.ClearPermission() + return _u } // ClearResource clears the "resource" edge to the Resource entity. -func (pru *PermissionResourceUpdate) ClearResource() *PermissionResourceUpdate { - pru.mutation.ClearResource() - return pru +func (_u *PermissionResourceUpdate) ClearResource() *PermissionResourceUpdate { + _u.mutation.ClearResource() + return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (pru *PermissionResourceUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, pru.sqlSave, pru.mutation, pru.hooks) +func (_u *PermissionResourceUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (pru *PermissionResourceUpdate) SaveX(ctx context.Context) int { - affected, err := pru.Save(ctx) +func (_u *PermissionResourceUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -100,58 +100,58 @@ func (pru *PermissionResourceUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (pru *PermissionResourceUpdate) Exec(ctx context.Context) error { - _, err := pru.Save(ctx) +func (_u *PermissionResourceUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pru *PermissionResourceUpdate) ExecX(ctx context.Context) { - if err := pru.Exec(ctx); err != nil { +func (_u *PermissionResourceUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (pru *PermissionResourceUpdate) check() error { - if v, ok := pru.mutation.PermissionID(); ok { +func (_u *PermissionResourceUpdate) check() error { + if v, ok := _u.mutation.PermissionID(); ok { if err := permissionresource.PermissionIDValidator(v); err != nil { return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "PermissionResource.permission_id": %w`, err)} } } - if v, ok := pru.mutation.ResourceID(); ok { + if v, ok := _u.mutation.ResourceID(); ok { if err := permissionresource.ResourceIDValidator(v); err != nil { return &ValidationError{Name: "resource_id", err: fmt.Errorf(`ent: validator failed for field "PermissionResource.resource_id": %w`, err)} } } - if pru.mutation.PermissionCleared() && len(pru.mutation.PermissionIDs()) > 0 { + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "PermissionResource.permission"`) } - if pru.mutation.ResourceCleared() && len(pru.mutation.ResourceIDs()) > 0 { + if _u.mutation.ResourceCleared() && len(_u.mutation.ResourceIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "PermissionResource.resource"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (pru *PermissionResourceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionResourceUpdate { - pru.modifiers = append(pru.modifiers, modifiers...) - return pru +func (_u *PermissionResourceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionResourceUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (pru *PermissionResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := pru.check(); err != nil { - return n, err +func (_u *PermissionResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(permissionresource.Table, permissionresource.Columns, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) - if ps := pru.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if pru.mutation.PermissionCleared() { + if _u.mutation.PermissionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -164,7 +164,7 @@ func (pru *PermissionResourceUpdate) sqlSave(ctx context.Context) (n int, err er } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pru.mutation.PermissionIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -180,7 +180,7 @@ func (pru *PermissionResourceUpdate) sqlSave(ctx context.Context) (n int, err er } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pru.mutation.ResourceCleared() { + if _u.mutation.ResourceCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -193,7 +193,7 @@ func (pru *PermissionResourceUpdate) sqlSave(ctx context.Context) (n int, err er } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pru.mutation.ResourceIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ResourceIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -209,8 +209,8 @@ func (pru *PermissionResourceUpdate) sqlSave(ctx context.Context) (n int, err er } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(pru.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, pru.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{permissionresource.Label} } else if sqlgraph.IsConstraintError(err) { @@ -218,8 +218,8 @@ func (pru *PermissionResourceUpdate) sqlSave(ctx context.Context) (n int, err er } return 0, err } - pru.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // PermissionResourceUpdateOne is the builder for updating a single PermissionResource entity. @@ -232,81 +232,81 @@ type PermissionResourceUpdateOne struct { } // SetPermissionID sets the "permission_id" field. -func (pruo *PermissionResourceUpdateOne) SetPermissionID(i int64) *PermissionResourceUpdateOne { - pruo.mutation.SetPermissionID(i) - return pruo +func (_u *PermissionResourceUpdateOne) SetPermissionID(v int64) *PermissionResourceUpdateOne { + _u.mutation.SetPermissionID(v) + return _u } // SetNillablePermissionID sets the "permission_id" field if the given value is not nil. -func (pruo *PermissionResourceUpdateOne) SetNillablePermissionID(i *int64) *PermissionResourceUpdateOne { - if i != nil { - pruo.SetPermissionID(*i) +func (_u *PermissionResourceUpdateOne) SetNillablePermissionID(v *int64) *PermissionResourceUpdateOne { + if v != nil { + _u.SetPermissionID(*v) } - return pruo + return _u } // SetResourceID sets the "resource_id" field. -func (pruo *PermissionResourceUpdateOne) SetResourceID(i int64) *PermissionResourceUpdateOne { - pruo.mutation.SetResourceID(i) - return pruo +func (_u *PermissionResourceUpdateOne) SetResourceID(v int64) *PermissionResourceUpdateOne { + _u.mutation.SetResourceID(v) + return _u } // SetNillableResourceID sets the "resource_id" field if the given value is not nil. -func (pruo *PermissionResourceUpdateOne) SetNillableResourceID(i *int64) *PermissionResourceUpdateOne { - if i != nil { - pruo.SetResourceID(*i) +func (_u *PermissionResourceUpdateOne) SetNillableResourceID(v *int64) *PermissionResourceUpdateOne { + if v != nil { + _u.SetResourceID(*v) } - return pruo + return _u } // SetPermission sets the "permission" edge to the Permission entity. -func (pruo *PermissionResourceUpdateOne) SetPermission(p *Permission) *PermissionResourceUpdateOne { - return pruo.SetPermissionID(p.ID) +func (_u *PermissionResourceUpdateOne) SetPermission(v *Permission) *PermissionResourceUpdateOne { + return _u.SetPermissionID(v.ID) } // SetResource sets the "resource" edge to the Resource entity. -func (pruo *PermissionResourceUpdateOne) SetResource(r *Resource) *PermissionResourceUpdateOne { - return pruo.SetResourceID(r.ID) +func (_u *PermissionResourceUpdateOne) SetResource(v *Resource) *PermissionResourceUpdateOne { + return _u.SetResourceID(v.ID) } // Mutation returns the PermissionResourceMutation object of the builder. -func (pruo *PermissionResourceUpdateOne) Mutation() *PermissionResourceMutation { - return pruo.mutation +func (_u *PermissionResourceUpdateOne) Mutation() *PermissionResourceMutation { + return _u.mutation } // ClearPermission clears the "permission" edge to the Permission entity. -func (pruo *PermissionResourceUpdateOne) ClearPermission() *PermissionResourceUpdateOne { - pruo.mutation.ClearPermission() - return pruo +func (_u *PermissionResourceUpdateOne) ClearPermission() *PermissionResourceUpdateOne { + _u.mutation.ClearPermission() + return _u } // ClearResource clears the "resource" edge to the Resource entity. -func (pruo *PermissionResourceUpdateOne) ClearResource() *PermissionResourceUpdateOne { - pruo.mutation.ClearResource() - return pruo +func (_u *PermissionResourceUpdateOne) ClearResource() *PermissionResourceUpdateOne { + _u.mutation.ClearResource() + return _u } // Where appends a list predicates to the PermissionResourceUpdate builder. -func (pruo *PermissionResourceUpdateOne) Where(ps ...predicate.PermissionResource) *PermissionResourceUpdateOne { - pruo.mutation.Where(ps...) - return pruo +func (_u *PermissionResourceUpdateOne) Where(ps ...predicate.PermissionResource) *PermissionResourceUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (pruo *PermissionResourceUpdateOne) Select(field string, fields ...string) *PermissionResourceUpdateOne { - pruo.fields = append([]string{field}, fields...) - return pruo +func (_u *PermissionResourceUpdateOne) Select(field string, fields ...string) *PermissionResourceUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated PermissionResource entity. -func (pruo *PermissionResourceUpdateOne) Save(ctx context.Context) (*PermissionResource, error) { - return withHooks(ctx, pruo.sqlSave, pruo.mutation, pruo.hooks) +func (_u *PermissionResourceUpdateOne) Save(ctx context.Context) (*PermissionResource, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (pruo *PermissionResourceUpdateOne) SaveX(ctx context.Context) *PermissionResource { - node, err := pruo.Save(ctx) +func (_u *PermissionResourceUpdateOne) SaveX(ctx context.Context) *PermissionResource { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -314,56 +314,56 @@ func (pruo *PermissionResourceUpdateOne) SaveX(ctx context.Context) *PermissionR } // Exec executes the query on the entity. -func (pruo *PermissionResourceUpdateOne) Exec(ctx context.Context) error { - _, err := pruo.Save(ctx) +func (_u *PermissionResourceUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pruo *PermissionResourceUpdateOne) ExecX(ctx context.Context) { - if err := pruo.Exec(ctx); err != nil { +func (_u *PermissionResourceUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (pruo *PermissionResourceUpdateOne) check() error { - if v, ok := pruo.mutation.PermissionID(); ok { +func (_u *PermissionResourceUpdateOne) check() error { + if v, ok := _u.mutation.PermissionID(); ok { if err := permissionresource.PermissionIDValidator(v); err != nil { return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "PermissionResource.permission_id": %w`, err)} } } - if v, ok := pruo.mutation.ResourceID(); ok { + if v, ok := _u.mutation.ResourceID(); ok { if err := permissionresource.ResourceIDValidator(v); err != nil { return &ValidationError{Name: "resource_id", err: fmt.Errorf(`ent: validator failed for field "PermissionResource.resource_id": %w`, err)} } } - if pruo.mutation.PermissionCleared() && len(pruo.mutation.PermissionIDs()) > 0 { + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "PermissionResource.permission"`) } - if pruo.mutation.ResourceCleared() && len(pruo.mutation.ResourceIDs()) > 0 { + if _u.mutation.ResourceCleared() && len(_u.mutation.ResourceIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "PermissionResource.resource"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (pruo *PermissionResourceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionResourceUpdateOne { - pruo.modifiers = append(pruo.modifiers, modifiers...) - return pruo +func (_u *PermissionResourceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionResourceUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (pruo *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *PermissionResource, err error) { - if err := pruo.check(); err != nil { +func (_u *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *PermissionResource, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(permissionresource.Table, permissionresource.Columns, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) - id, ok := pruo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PermissionResource.id" for update`)} } _spec.Node.ID.Value = id - if fields := pruo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, permissionresource.FieldID) for _, f := range fields { @@ -375,14 +375,14 @@ func (pruo *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *Pe } } } - if ps := pruo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if pruo.mutation.PermissionCleared() { + if _u.mutation.PermissionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -395,7 +395,7 @@ func (pruo *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *Pe } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pruo.mutation.PermissionIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -411,7 +411,7 @@ func (pruo *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *Pe } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pruo.mutation.ResourceCleared() { + if _u.mutation.ResourceCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -424,7 +424,7 @@ func (pruo *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *Pe } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pruo.mutation.ResourceIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ResourceIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -440,11 +440,11 @@ func (pruo *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *Pe } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(pruo.modifiers...) - _node = &PermissionResource{config: pruo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &PermissionResource{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, pruo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{permissionresource.Label} } else if sqlgraph.IsConstraintError(err) { @@ -452,7 +452,7 @@ func (pruo *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *Pe } return nil, err } - pruo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/position.go b/internal/data/entity/ent/position.go index 847e7555..0e316192 100644 --- a/internal/data/entity/ent/position.go +++ b/internal/data/entity/ent/position.go @@ -121,7 +121,7 @@ func (*Position) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Position fields. -func (po *Position) assignValues(columns []string, values []any) error { +func (_m *Position) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -132,45 +132,45 @@ func (po *Position) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - po.ID = int64(value.Int64) + _m.ID = int64(value.Int64) case position.FieldCreateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field create_time", values[i]) } else if value.Valid { - po.CreateTime = value.Time + _m.CreateTime = value.Time } case position.FieldUpdateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field update_time", values[i]) } else if value.Valid { - po.UpdateTime = value.Time + _m.UpdateTime = value.Time } case position.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { - po.Name = value.String + _m.Name = value.String } case position.FieldKeyword: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field keyword", values[i]) } else if value.Valid { - po.Keyword = value.String + _m.Keyword = value.String } case position.FieldDescription: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field description", values[i]) } else if value.Valid { - po.Description = value.String + _m.Description = value.String } case position.FieldDepartmentID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field department_id", values[i]) } else if value.Valid { - po.DepartmentID = value.Int64 + _m.DepartmentID = value.Int64 } default: - po.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -178,75 +178,75 @@ func (po *Position) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Position. // This includes values selected through modifiers, order, etc. -func (po *Position) Value(name string) (ent.Value, error) { - return po.selectValues.Get(name) +func (_m *Position) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryDepartment queries the "department" edge of the Position entity. -func (po *Position) QueryDepartment() *DepartmentQuery { - return NewPositionClient(po.config).QueryDepartment(po) +func (_m *Position) QueryDepartment() *DepartmentQuery { + return NewPositionClient(_m.config).QueryDepartment(_m) } // QueryUsers queries the "users" edge of the Position entity. -func (po *Position) QueryUsers() *UserQuery { - return NewPositionClient(po.config).QueryUsers(po) +func (_m *Position) QueryUsers() *UserQuery { + return NewPositionClient(_m.config).QueryUsers(_m) } // QueryPermissions queries the "permissions" edge of the Position entity. -func (po *Position) QueryPermissions() *PermissionQuery { - return NewPositionClient(po.config).QueryPermissions(po) +func (_m *Position) QueryPermissions() *PermissionQuery { + return NewPositionClient(_m.config).QueryPermissions(_m) } // QueryUserPositions queries the "user_positions" edge of the Position entity. -func (po *Position) QueryUserPositions() *UserPositionQuery { - return NewPositionClient(po.config).QueryUserPositions(po) +func (_m *Position) QueryUserPositions() *UserPositionQuery { + return NewPositionClient(_m.config).QueryUserPositions(_m) } // QueryPositionPermissions queries the "position_permissions" edge of the Position entity. -func (po *Position) QueryPositionPermissions() *PositionPermissionQuery { - return NewPositionClient(po.config).QueryPositionPermissions(po) +func (_m *Position) QueryPositionPermissions() *PositionPermissionQuery { + return NewPositionClient(_m.config).QueryPositionPermissions(_m) } // Update returns a builder for updating this Position. // Note that you need to call Position.Unwrap() before calling this method if this Position // was returned from a transaction, and the transaction was committed or rolled back. -func (po *Position) Update() *PositionUpdateOne { - return NewPositionClient(po.config).UpdateOne(po) +func (_m *Position) Update() *PositionUpdateOne { + return NewPositionClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Position entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (po *Position) Unwrap() *Position { - _tx, ok := po.config.driver.(*txDriver) +func (_m *Position) Unwrap() *Position { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Position is not a transactional entity") } - po.config.driver = _tx.drv - return po + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (po *Position) String() string { +func (_m *Position) String() string { var builder strings.Builder builder.WriteString("Position(") - builder.WriteString(fmt.Sprintf("id=%v, ", po.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("create_time=") - builder.WriteString(po.CreateTime.Format(time.ANSIC)) + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("update_time=") - builder.WriteString(po.UpdateTime.Format(time.ANSIC)) + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("name=") - builder.WriteString(po.Name) + builder.WriteString(_m.Name) builder.WriteString(", ") builder.WriteString("keyword=") - builder.WriteString(po.Keyword) + builder.WriteString(_m.Keyword) builder.WriteString(", ") builder.WriteString("description=") - builder.WriteString(po.Description) + builder.WriteString(_m.Description) builder.WriteString(", ") builder.WriteString("department_id=") - builder.WriteString(fmt.Sprintf("%v", po.DepartmentID)) + builder.WriteString(fmt.Sprintf("%v", _m.DepartmentID)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/position_create.go b/internal/data/entity/ent/position_create.go index 3236b4c5..109e68c7 100644 --- a/internal/data/entity/ent/position_create.go +++ b/internal/data/entity/ent/position_create.go @@ -26,158 +26,158 @@ type PositionCreate struct { } // SetCreateTime sets the "create_time" field. -func (pc *PositionCreate) SetCreateTime(t time.Time) *PositionCreate { - pc.mutation.SetCreateTime(t) - return pc +func (_c *PositionCreate) SetCreateTime(v time.Time) *PositionCreate { + _c.mutation.SetCreateTime(v) + return _c } // SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (pc *PositionCreate) SetNillableCreateTime(t *time.Time) *PositionCreate { - if t != nil { - pc.SetCreateTime(*t) +func (_c *PositionCreate) SetNillableCreateTime(v *time.Time) *PositionCreate { + if v != nil { + _c.SetCreateTime(*v) } - return pc + return _c } // SetUpdateTime sets the "update_time" field. -func (pc *PositionCreate) SetUpdateTime(t time.Time) *PositionCreate { - pc.mutation.SetUpdateTime(t) - return pc +func (_c *PositionCreate) SetUpdateTime(v time.Time) *PositionCreate { + _c.mutation.SetUpdateTime(v) + return _c } // SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (pc *PositionCreate) SetNillableUpdateTime(t *time.Time) *PositionCreate { - if t != nil { - pc.SetUpdateTime(*t) +func (_c *PositionCreate) SetNillableUpdateTime(v *time.Time) *PositionCreate { + if v != nil { + _c.SetUpdateTime(*v) } - return pc + return _c } // SetName sets the "name" field. -func (pc *PositionCreate) SetName(s string) *PositionCreate { - pc.mutation.SetName(s) - return pc +func (_c *PositionCreate) SetName(v string) *PositionCreate { + _c.mutation.SetName(v) + return _c } // SetKeyword sets the "keyword" field. -func (pc *PositionCreate) SetKeyword(s string) *PositionCreate { - pc.mutation.SetKeyword(s) - return pc +func (_c *PositionCreate) SetKeyword(v string) *PositionCreate { + _c.mutation.SetKeyword(v) + return _c } // SetDescription sets the "description" field. -func (pc *PositionCreate) SetDescription(s string) *PositionCreate { - pc.mutation.SetDescription(s) - return pc +func (_c *PositionCreate) SetDescription(v string) *PositionCreate { + _c.mutation.SetDescription(v) + return _c } // SetNillableDescription sets the "description" field if the given value is not nil. -func (pc *PositionCreate) SetNillableDescription(s *string) *PositionCreate { - if s != nil { - pc.SetDescription(*s) +func (_c *PositionCreate) SetNillableDescription(v *string) *PositionCreate { + if v != nil { + _c.SetDescription(*v) } - return pc + return _c } // SetDepartmentID sets the "department_id" field. -func (pc *PositionCreate) SetDepartmentID(i int64) *PositionCreate { - pc.mutation.SetDepartmentID(i) - return pc +func (_c *PositionCreate) SetDepartmentID(v int64) *PositionCreate { + _c.mutation.SetDepartmentID(v) + return _c } // SetID sets the "id" field. -func (pc *PositionCreate) SetID(i int64) *PositionCreate { - pc.mutation.SetID(i) - return pc +func (_c *PositionCreate) SetID(v int64) *PositionCreate { + _c.mutation.SetID(v) + return _c } // SetNillableID sets the "id" field if the given value is not nil. -func (pc *PositionCreate) SetNillableID(i *int64) *PositionCreate { - if i != nil { - pc.SetID(*i) +func (_c *PositionCreate) SetNillableID(v *int64) *PositionCreate { + if v != nil { + _c.SetID(*v) } - return pc + return _c } // SetDepartment sets the "department" edge to the Department entity. -func (pc *PositionCreate) SetDepartment(d *Department) *PositionCreate { - return pc.SetDepartmentID(d.ID) +func (_c *PositionCreate) SetDepartment(v *Department) *PositionCreate { + return _c.SetDepartmentID(v.ID) } // AddUserIDs adds the "users" edge to the User entity by IDs. -func (pc *PositionCreate) AddUserIDs(ids ...int64) *PositionCreate { - pc.mutation.AddUserIDs(ids...) - return pc +func (_c *PositionCreate) AddUserIDs(ids ...int64) *PositionCreate { + _c.mutation.AddUserIDs(ids...) + return _c } // AddUsers adds the "users" edges to the User entity. -func (pc *PositionCreate) AddUsers(u ...*User) *PositionCreate { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_c *PositionCreate) AddUsers(v ...*User) *PositionCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddUserIDs(ids...) + return _c.AddUserIDs(ids...) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (pc *PositionCreate) AddPermissionIDs(ids ...int64) *PositionCreate { - pc.mutation.AddPermissionIDs(ids...) - return pc +func (_c *PositionCreate) AddPermissionIDs(ids ...int64) *PositionCreate { + _c.mutation.AddPermissionIDs(ids...) + return _c } // AddPermissions adds the "permissions" edges to the Permission entity. -func (pc *PositionCreate) AddPermissions(p ...*Permission) *PositionCreate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *PositionCreate) AddPermissions(v ...*Permission) *PositionCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddPermissionIDs(ids...) + return _c.AddPermissionIDs(ids...) } // AddUserPositionIDs adds the "user_positions" edge to the UserPosition entity by IDs. -func (pc *PositionCreate) AddUserPositionIDs(ids ...int) *PositionCreate { - pc.mutation.AddUserPositionIDs(ids...) - return pc +func (_c *PositionCreate) AddUserPositionIDs(ids ...int) *PositionCreate { + _c.mutation.AddUserPositionIDs(ids...) + return _c } // AddUserPositions adds the "user_positions" edges to the UserPosition entity. -func (pc *PositionCreate) AddUserPositions(u ...*UserPosition) *PositionCreate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_c *PositionCreate) AddUserPositions(v ...*UserPosition) *PositionCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddUserPositionIDs(ids...) + return _c.AddUserPositionIDs(ids...) } // AddPositionPermissionIDs adds the "position_permissions" edge to the PositionPermission entity by IDs. -func (pc *PositionCreate) AddPositionPermissionIDs(ids ...int) *PositionCreate { - pc.mutation.AddPositionPermissionIDs(ids...) - return pc +func (_c *PositionCreate) AddPositionPermissionIDs(ids ...int) *PositionCreate { + _c.mutation.AddPositionPermissionIDs(ids...) + return _c } // AddPositionPermissions adds the "position_permissions" edges to the PositionPermission entity. -func (pc *PositionCreate) AddPositionPermissions(p ...*PositionPermission) *PositionCreate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *PositionCreate) AddPositionPermissions(v ...*PositionPermission) *PositionCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddPositionPermissionIDs(ids...) + return _c.AddPositionPermissionIDs(ids...) } // Mutation returns the PositionMutation object of the builder. -func (pc *PositionCreate) Mutation() *PositionMutation { - return pc.mutation +func (_c *PositionCreate) Mutation() *PositionMutation { + return _c.mutation } // Save creates the Position in the database. -func (pc *PositionCreate) Save(ctx context.Context) (*Position, error) { - pc.defaults() - return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) +func (_c *PositionCreate) Save(ctx context.Context) (*Position, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (pc *PositionCreate) SaveX(ctx context.Context) *Position { - v, err := pc.Save(ctx) +func (_c *PositionCreate) SaveX(ctx context.Context) *Position { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -185,95 +185,95 @@ func (pc *PositionCreate) SaveX(ctx context.Context) *Position { } // Exec executes the query. -func (pc *PositionCreate) Exec(ctx context.Context) error { - _, err := pc.Save(ctx) +func (_c *PositionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pc *PositionCreate) ExecX(ctx context.Context) { - if err := pc.Exec(ctx); err != nil { +func (_c *PositionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (pc *PositionCreate) defaults() { - if _, ok := pc.mutation.CreateTime(); !ok { +func (_c *PositionCreate) defaults() { + if _, ok := _c.mutation.CreateTime(); !ok { v := position.DefaultCreateTime() - pc.mutation.SetCreateTime(v) + _c.mutation.SetCreateTime(v) } - if _, ok := pc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { v := position.DefaultUpdateTime() - pc.mutation.SetUpdateTime(v) + _c.mutation.SetUpdateTime(v) } - if _, ok := pc.mutation.Description(); !ok { + if _, ok := _c.mutation.Description(); !ok { v := position.DefaultDescription - pc.mutation.SetDescription(v) + _c.mutation.SetDescription(v) } - if _, ok := pc.mutation.ID(); !ok { + if _, ok := _c.mutation.ID(); !ok { v := position.DefaultID() - pc.mutation.SetID(v) + _c.mutation.SetID(v) } } // check runs all checks and user-defined validators on the builder. -func (pc *PositionCreate) check() error { - if _, ok := pc.mutation.CreateTime(); !ok { +func (_c *PositionCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Position.create_time"`)} } - if _, ok := pc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Position.update_time"`)} } - if _, ok := pc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Position.name"`)} } - if v, ok := pc.mutation.Name(); ok { + if v, ok := _c.mutation.Name(); ok { if err := position.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Position.name": %w`, err)} } } - if _, ok := pc.mutation.Keyword(); !ok { + if _, ok := _c.mutation.Keyword(); !ok { return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Position.keyword"`)} } - if v, ok := pc.mutation.Keyword(); ok { + if v, ok := _c.mutation.Keyword(); ok { if err := position.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Position.keyword": %w`, err)} } } - if _, ok := pc.mutation.Description(); !ok { + if _, ok := _c.mutation.Description(); !ok { return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Position.description"`)} } - if v, ok := pc.mutation.Description(); ok { + if v, ok := _c.mutation.Description(); ok { if err := position.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Position.description": %w`, err)} } } - if _, ok := pc.mutation.DepartmentID(); !ok { + if _, ok := _c.mutation.DepartmentID(); !ok { return &ValidationError{Name: "department_id", err: errors.New(`ent: missing required field "Position.department_id"`)} } - if v, ok := pc.mutation.DepartmentID(); ok { + if v, ok := _c.mutation.DepartmentID(); ok { if err := position.DepartmentIDValidator(v); err != nil { return &ValidationError{Name: "department_id", err: fmt.Errorf(`ent: validator failed for field "Position.department_id": %w`, err)} } } - if v, ok := pc.mutation.ID(); ok { + if v, ok := _c.mutation.ID(); ok { if err := position.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Position.id": %w`, err)} } } - if len(pc.mutation.DepartmentIDs()) == 0 { + if len(_c.mutation.DepartmentIDs()) == 0 { return &ValidationError{Name: "department", err: errors.New(`ent: missing required edge "Position.department"`)} } return nil } -func (pc *PositionCreate) sqlSave(ctx context.Context) (*Position, error) { - if err := pc.check(); err != nil { +func (_c *PositionCreate) sqlSave(ctx context.Context) (*Position, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := pc.createSpec() - if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -283,41 +283,41 @@ func (pc *PositionCreate) sqlSave(ctx context.Context) (*Position, error) { id := _spec.ID.Value.(int64) _node.ID = int64(id) } - pc.mutation.id = &_node.ID - pc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (pc *PositionCreate) createSpec() (*Position, *sqlgraph.CreateSpec) { +func (_c *PositionCreate) createSpec() (*Position, *sqlgraph.CreateSpec) { var ( - _node = &Position{config: pc.config} + _node = &Position{config: _c.config} _spec = sqlgraph.NewCreateSpec(position.Table, sqlgraph.NewFieldSpec(position.FieldID, field.TypeInt64)) ) - if id, ok := pc.mutation.ID(); ok { + if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } - if value, ok := pc.mutation.CreateTime(); ok { + if value, ok := _c.mutation.CreateTime(); ok { _spec.SetField(position.FieldCreateTime, field.TypeTime, value) _node.CreateTime = value } - if value, ok := pc.mutation.UpdateTime(); ok { + if value, ok := _c.mutation.UpdateTime(); ok { _spec.SetField(position.FieldUpdateTime, field.TypeTime, value) _node.UpdateTime = value } - if value, ok := pc.mutation.Name(); ok { + if value, ok := _c.mutation.Name(); ok { _spec.SetField(position.FieldName, field.TypeString, value) _node.Name = value } - if value, ok := pc.mutation.Keyword(); ok { + if value, ok := _c.mutation.Keyword(); ok { _spec.SetField(position.FieldKeyword, field.TypeString, value) _node.Keyword = value } - if value, ok := pc.mutation.Description(); ok { + if value, ok := _c.mutation.Description(); ok { _spec.SetField(position.FieldDescription, field.TypeString, value) _node.Description = value } - if nodes := pc.mutation.DepartmentIDs(); len(nodes) > 0 { + if nodes := _c.mutation.DepartmentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -334,7 +334,7 @@ func (pc *PositionCreate) createSpec() (*Position, *sqlgraph.CreateSpec) { _node.DepartmentID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := pc.mutation.UsersIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UsersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -350,7 +350,7 @@ func (pc *PositionCreate) createSpec() (*Position, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := pc.mutation.PermissionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -366,7 +366,7 @@ func (pc *PositionCreate) createSpec() (*Position, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := pc.mutation.UserPositionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UserPositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -382,7 +382,7 @@ func (pc *PositionCreate) createSpec() (*Position, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := pc.mutation.PositionPermissionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PositionPermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -402,23 +402,23 @@ func (pc *PositionCreate) createSpec() (*Position, *sqlgraph.CreateSpec) { } // SetPosition set the Position -func (pc *PositionCreate) SetPosition(input *Position, fields ...string) *PositionCreate { - m := pc.mutation +func (_c *PositionCreate) SetPosition(input *Position, fields ...string) *PositionCreate { + m := _c.mutation if len(fields) == 0 { fields = position.Columns } _ = m.SetFields(input, fields...) - return pc + return _c } // SetPositionWithZero set the Position -func (pc *PositionCreate) SetPositionWithZero(input *Position, fields ...string) *PositionCreate { - m := pc.mutation +func (_c *PositionCreate) SetPositionWithZero(input *Position, fields ...string) *PositionCreate { + m := _c.mutation if len(fields) == 0 { fields = position.Columns } _ = m.SetFieldsWithZero(input, fields...) - return pc + return _c } // PositionCreateBulk is the builder for creating many Position entities in bulk. @@ -429,16 +429,16 @@ type PositionCreateBulk struct { } // Save creates the Position entities in the database. -func (pcb *PositionCreateBulk) Save(ctx context.Context) ([]*Position, error) { - if pcb.err != nil { - return nil, pcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) - nodes := make([]*Position, len(pcb.builders)) - mutators := make([]Mutator, len(pcb.builders)) - for i := range pcb.builders { +func (_c *PositionCreateBulk) Save(ctx context.Context) ([]*Position, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Position, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := pcb.builders[i] + builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*PositionMutation) @@ -452,11 +452,11 @@ func (pcb *PositionCreateBulk) Save(ctx context.Context) ([]*Position, error) { var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -480,7 +480,7 @@ func (pcb *PositionCreateBulk) Save(ctx context.Context) ([]*Position, error) { }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, pcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -488,8 +488,8 @@ func (pcb *PositionCreateBulk) Save(ctx context.Context) ([]*Position, error) { } // SaveX is like Save, but panics if an error occurs. -func (pcb *PositionCreateBulk) SaveX(ctx context.Context) []*Position { - v, err := pcb.Save(ctx) +func (_c *PositionCreateBulk) SaveX(ctx context.Context) []*Position { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -497,14 +497,14 @@ func (pcb *PositionCreateBulk) SaveX(ctx context.Context) []*Position { } // Exec executes the query. -func (pcb *PositionCreateBulk) Exec(ctx context.Context) error { - _, err := pcb.Save(ctx) +func (_c *PositionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pcb *PositionCreateBulk) ExecX(ctx context.Context) { - if err := pcb.Exec(ctx); err != nil { +func (_c *PositionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/position_delete.go b/internal/data/entity/ent/position_delete.go index 5d2d5fa4..ad21dfad 100644 --- a/internal/data/entity/ent/position_delete.go +++ b/internal/data/entity/ent/position_delete.go @@ -20,56 +20,56 @@ type PositionDelete struct { } // Where appends a list predicates to the PositionDelete builder. -func (pd *PositionDelete) Where(ps ...predicate.Position) *PositionDelete { - pd.mutation.Where(ps...) - return pd +func (_d *PositionDelete) Where(ps ...predicate.Position) *PositionDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (pd *PositionDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) +func (_d *PositionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (pd *PositionDelete) ExecX(ctx context.Context) int { - n, err := pd.Exec(ctx) +func (_d *PositionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (pd *PositionDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *PositionDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(position.Table, sqlgraph.NewFieldSpec(position.FieldID, field.TypeInt64)) - if ps := pd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, pd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - pd.mutation.done = true + _d.mutation.done = true return affected, err } // PositionDeleteOne is the builder for deleting a single Position entity. type PositionDeleteOne struct { - pd *PositionDelete + _d *PositionDelete } // Where appends a list predicates to the PositionDelete builder. -func (pdo *PositionDeleteOne) Where(ps ...predicate.Position) *PositionDeleteOne { - pdo.pd.mutation.Where(ps...) - return pdo +func (_d *PositionDeleteOne) Where(ps ...predicate.Position) *PositionDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (pdo *PositionDeleteOne) Exec(ctx context.Context) error { - n, err := pdo.pd.Exec(ctx) +func (_d *PositionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (pdo *PositionDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (pdo *PositionDeleteOne) ExecX(ctx context.Context) { - if err := pdo.Exec(ctx); err != nil { +func (_d *PositionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/position_query.go b/internal/data/entity/ent/position_query.go index ca67bf2f..a1899539 100644 --- a/internal/data/entity/ent/position_query.go +++ b/internal/data/entity/ent/position_query.go @@ -41,44 +41,44 @@ type PositionQuery struct { } // Where adds a new predicate for the PositionQuery builder. -func (pq *PositionQuery) Where(ps ...predicate.Position) *PositionQuery { - pq.predicates = append(pq.predicates, ps...) - return pq +func (_q *PositionQuery) Where(ps ...predicate.Position) *PositionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (pq *PositionQuery) Limit(limit int) *PositionQuery { - pq.ctx.Limit = &limit - return pq +func (_q *PositionQuery) Limit(limit int) *PositionQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (pq *PositionQuery) Offset(offset int) *PositionQuery { - pq.ctx.Offset = &offset - return pq +func (_q *PositionQuery) Offset(offset int) *PositionQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (pq *PositionQuery) Unique(unique bool) *PositionQuery { - pq.ctx.Unique = &unique - return pq +func (_q *PositionQuery) Unique(unique bool) *PositionQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (pq *PositionQuery) Order(o ...position.OrderOption) *PositionQuery { - pq.order = append(pq.order, o...) - return pq +func (_q *PositionQuery) Order(o ...position.OrderOption) *PositionQuery { + _q.order = append(_q.order, o...) + return _q } // QueryDepartment chains the current query on the "department" edge. -func (pq *PositionQuery) QueryDepartment() *DepartmentQuery { - query := (&DepartmentClient{config: pq.config}).Query() +func (_q *PositionQuery) QueryDepartment() *DepartmentQuery { + query := (&DepartmentClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -87,20 +87,20 @@ func (pq *PositionQuery) QueryDepartment() *DepartmentQuery { sqlgraph.To(department.Table, department.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, position.DepartmentTable, position.DepartmentColumn), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryUsers chains the current query on the "users" edge. -func (pq *PositionQuery) QueryUsers() *UserQuery { - query := (&UserClient{config: pq.config}).Query() +func (_q *PositionQuery) QueryUsers() *UserQuery { + query := (&UserClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -109,20 +109,20 @@ func (pq *PositionQuery) QueryUsers() *UserQuery { sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, position.UsersTable, position.UsersPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPermissions chains the current query on the "permissions" edge. -func (pq *PositionQuery) QueryPermissions() *PermissionQuery { - query := (&PermissionClient{config: pq.config}).Query() +func (_q *PositionQuery) QueryPermissions() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -131,20 +131,20 @@ func (pq *PositionQuery) QueryPermissions() *PermissionQuery { sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, position.PermissionsTable, position.PermissionsPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryUserPositions chains the current query on the "user_positions" edge. -func (pq *PositionQuery) QueryUserPositions() *UserPositionQuery { - query := (&UserPositionClient{config: pq.config}).Query() +func (_q *PositionQuery) QueryUserPositions() *UserPositionQuery { + query := (&UserPositionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -153,20 +153,20 @@ func (pq *PositionQuery) QueryUserPositions() *UserPositionQuery { sqlgraph.To(userposition.Table, userposition.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, position.UserPositionsTable, position.UserPositionsColumn), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPositionPermissions chains the current query on the "position_permissions" edge. -func (pq *PositionQuery) QueryPositionPermissions() *PositionPermissionQuery { - query := (&PositionPermissionClient{config: pq.config}).Query() +func (_q *PositionQuery) QueryPositionPermissions() *PositionPermissionQuery { + query := (&PositionPermissionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -175,7 +175,7 @@ func (pq *PositionQuery) QueryPositionPermissions() *PositionPermissionQuery { sqlgraph.To(positionpermission.Table, positionpermission.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, position.PositionPermissionsTable, position.PositionPermissionsColumn), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -183,8 +183,8 @@ func (pq *PositionQuery) QueryPositionPermissions() *PositionPermissionQuery { // First returns the first Position entity from the query. // Returns a *NotFoundError when no Position was found. -func (pq *PositionQuery) First(ctx context.Context) (*Position, error) { - nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, ent.OpQueryFirst)) +func (_q *PositionQuery) First(ctx context.Context) (*Position, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -195,8 +195,8 @@ func (pq *PositionQuery) First(ctx context.Context) (*Position, error) { } // FirstX is like First, but panics if an error occurs. -func (pq *PositionQuery) FirstX(ctx context.Context) *Position { - node, err := pq.First(ctx) +func (_q *PositionQuery) FirstX(ctx context.Context) *Position { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -205,9 +205,9 @@ func (pq *PositionQuery) FirstX(ctx context.Context) *Position { // FirstID returns the first Position ID from the query. // Returns a *NotFoundError when no Position ID was found. -func (pq *PositionQuery) FirstID(ctx context.Context) (id int64, err error) { +func (_q *PositionQuery) FirstID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -218,8 +218,8 @@ func (pq *PositionQuery) FirstID(ctx context.Context) (id int64, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (pq *PositionQuery) FirstIDX(ctx context.Context) int64 { - id, err := pq.FirstID(ctx) +func (_q *PositionQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -229,8 +229,8 @@ func (pq *PositionQuery) FirstIDX(ctx context.Context) int64 { // Only returns a single Position entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Position entity is found. // Returns a *NotFoundError when no Position entities are found. -func (pq *PositionQuery) Only(ctx context.Context) (*Position, error) { - nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, ent.OpQueryOnly)) +func (_q *PositionQuery) Only(ctx context.Context) (*Position, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -245,8 +245,8 @@ func (pq *PositionQuery) Only(ctx context.Context) (*Position, error) { } // OnlyX is like Only, but panics if an error occurs. -func (pq *PositionQuery) OnlyX(ctx context.Context) *Position { - node, err := pq.Only(ctx) +func (_q *PositionQuery) OnlyX(ctx context.Context) *Position { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -256,9 +256,9 @@ func (pq *PositionQuery) OnlyX(ctx context.Context) *Position { // OnlyID is like Only, but returns the only Position ID in the query. // Returns a *NotSingularError when more than one Position ID is found. // Returns a *NotFoundError when no entities are found. -func (pq *PositionQuery) OnlyID(ctx context.Context) (id int64, err error) { +func (_q *PositionQuery) OnlyID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -273,8 +273,8 @@ func (pq *PositionQuery) OnlyID(ctx context.Context) (id int64, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (pq *PositionQuery) OnlyIDX(ctx context.Context) int64 { - id, err := pq.OnlyID(ctx) +func (_q *PositionQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -282,18 +282,18 @@ func (pq *PositionQuery) OnlyIDX(ctx context.Context) int64 { } // All executes the query and returns a list of Positions. -func (pq *PositionQuery) All(ctx context.Context) ([]*Position, error) { - ctx = setContextOp(ctx, pq.ctx, ent.OpQueryAll) - if err := pq.prepareQuery(ctx); err != nil { +func (_q *PositionQuery) All(ctx context.Context) ([]*Position, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Position, *PositionQuery]() - return withInterceptors[[]*Position](ctx, pq, qr, pq.inters) + return withInterceptors[[]*Position](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (pq *PositionQuery) AllX(ctx context.Context) []*Position { - nodes, err := pq.All(ctx) +func (_q *PositionQuery) AllX(ctx context.Context) []*Position { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -301,20 +301,20 @@ func (pq *PositionQuery) AllX(ctx context.Context) []*Position { } // IDs executes the query and returns a list of Position IDs. -func (pq *PositionQuery) IDs(ctx context.Context) (ids []int64, err error) { - if pq.ctx.Unique == nil && pq.path != nil { - pq.Unique(true) +func (_q *PositionQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, pq.ctx, ent.OpQueryIDs) - if err = pq.Select(position.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(position.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (pq *PositionQuery) IDsX(ctx context.Context) []int64 { - ids, err := pq.IDs(ctx) +func (_q *PositionQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -322,17 +322,17 @@ func (pq *PositionQuery) IDsX(ctx context.Context) []int64 { } // Count returns the count of the given query. -func (pq *PositionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, pq.ctx, ent.OpQueryCount) - if err := pq.prepareQuery(ctx); err != nil { +func (_q *PositionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, pq, querierCount[*PositionQuery](), pq.inters) + return withInterceptors[int](ctx, _q, querierCount[*PositionQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (pq *PositionQuery) CountX(ctx context.Context) int { - count, err := pq.Count(ctx) +func (_q *PositionQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -340,9 +340,9 @@ func (pq *PositionQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (pq *PositionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, pq.ctx, ent.OpQueryExist) - switch _, err := pq.FirstID(ctx); { +func (_q *PositionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -353,8 +353,8 @@ func (pq *PositionQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (pq *PositionQuery) ExistX(ctx context.Context) bool { - exist, err := pq.Exist(ctx) +func (_q *PositionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -363,81 +363,81 @@ func (pq *PositionQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the PositionQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (pq *PositionQuery) Clone() *PositionQuery { - if pq == nil { +func (_q *PositionQuery) Clone() *PositionQuery { + if _q == nil { return nil } return &PositionQuery{ - config: pq.config, - ctx: pq.ctx.Clone(), - order: append([]position.OrderOption{}, pq.order...), - inters: append([]Interceptor{}, pq.inters...), - predicates: append([]predicate.Position{}, pq.predicates...), - withDepartment: pq.withDepartment.Clone(), - withUsers: pq.withUsers.Clone(), - withPermissions: pq.withPermissions.Clone(), - withUserPositions: pq.withUserPositions.Clone(), - withPositionPermissions: pq.withPositionPermissions.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]position.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Position{}, _q.predicates...), + withDepartment: _q.withDepartment.Clone(), + withUsers: _q.withUsers.Clone(), + withPermissions: _q.withPermissions.Clone(), + withUserPositions: _q.withUserPositions.Clone(), + withPositionPermissions: _q.withPositionPermissions.Clone(), // clone intermediate query. - sql: pq.sql.Clone(), - path: pq.path, - modifiers: append([]func(*sql.Selector){}, pq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithDepartment tells the query-builder to eager-load the nodes that are connected to // the "department" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PositionQuery) WithDepartment(opts ...func(*DepartmentQuery)) *PositionQuery { - query := (&DepartmentClient{config: pq.config}).Query() +func (_q *PositionQuery) WithDepartment(opts ...func(*DepartmentQuery)) *PositionQuery { + query := (&DepartmentClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withDepartment = query - return pq + _q.withDepartment = query + return _q } // WithUsers tells the query-builder to eager-load the nodes that are connected to // the "users" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PositionQuery) WithUsers(opts ...func(*UserQuery)) *PositionQuery { - query := (&UserClient{config: pq.config}).Query() +func (_q *PositionQuery) WithUsers(opts ...func(*UserQuery)) *PositionQuery { + query := (&UserClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withUsers = query - return pq + _q.withUsers = query + return _q } // WithPermissions tells the query-builder to eager-load the nodes that are connected to // the "permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PositionQuery) WithPermissions(opts ...func(*PermissionQuery)) *PositionQuery { - query := (&PermissionClient{config: pq.config}).Query() +func (_q *PositionQuery) WithPermissions(opts ...func(*PermissionQuery)) *PositionQuery { + query := (&PermissionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withPermissions = query - return pq + _q.withPermissions = query + return _q } // WithUserPositions tells the query-builder to eager-load the nodes that are connected to // the "user_positions" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PositionQuery) WithUserPositions(opts ...func(*UserPositionQuery)) *PositionQuery { - query := (&UserPositionClient{config: pq.config}).Query() +func (_q *PositionQuery) WithUserPositions(opts ...func(*UserPositionQuery)) *PositionQuery { + query := (&UserPositionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withUserPositions = query - return pq + _q.withUserPositions = query + return _q } // WithPositionPermissions tells the query-builder to eager-load the nodes that are connected to // the "position_permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PositionQuery) WithPositionPermissions(opts ...func(*PositionPermissionQuery)) *PositionQuery { - query := (&PositionPermissionClient{config: pq.config}).Query() +func (_q *PositionQuery) WithPositionPermissions(opts ...func(*PositionPermissionQuery)) *PositionQuery { + query := (&PositionPermissionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withPositionPermissions = query - return pq + _q.withPositionPermissions = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -454,10 +454,10 @@ func (pq *PositionQuery) WithPositionPermissions(opts ...func(*PositionPermissio // GroupBy(position.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (pq *PositionQuery) GroupBy(field string, fields ...string) *PositionGroupBy { - pq.ctx.Fields = append([]string{field}, fields...) - grbuild := &PositionGroupBy{build: pq} - grbuild.flds = &pq.ctx.Fields +func (_q *PositionQuery) GroupBy(field string, fields ...string) *PositionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PositionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = position.Label grbuild.scan = grbuild.Scan return grbuild @@ -475,107 +475,107 @@ func (pq *PositionQuery) GroupBy(field string, fields ...string) *PositionGroupB // client.Position.Query(). // Select(position.FieldCreateTime). // Scan(ctx, &v) -func (pq *PositionQuery) Select(fields ...string) *PositionSelect { - pq.ctx.Fields = append(pq.ctx.Fields, fields...) - sbuild := &PositionSelect{PositionQuery: pq} +func (_q *PositionQuery) Select(fields ...string) *PositionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PositionSelect{PositionQuery: _q} sbuild.label = position.Label - sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a PositionSelect configured with the given aggregations. -func (pq *PositionQuery) Aggregate(fns ...AggregateFunc) *PositionSelect { - return pq.Select().Aggregate(fns...) +func (_q *PositionQuery) Aggregate(fns ...AggregateFunc) *PositionSelect { + return _q.Select().Aggregate(fns...) } -func (pq *PositionQuery) prepareQuery(ctx context.Context) error { - for _, inter := range pq.inters { +func (_q *PositionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, pq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range pq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !position.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if pq.path != nil { - prev, err := pq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - pq.sql = prev + _q.sql = prev } return nil } -func (pq *PositionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Position, error) { +func (_q *PositionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Position, error) { var ( nodes = []*Position{} - _spec = pq.querySpec() + _spec = _q.querySpec() loadedTypes = [5]bool{ - pq.withDepartment != nil, - pq.withUsers != nil, - pq.withPermissions != nil, - pq.withUserPositions != nil, - pq.withPositionPermissions != nil, + _q.withDepartment != nil, + _q.withUsers != nil, + _q.withPermissions != nil, + _q.withUserPositions != nil, + _q.withPositionPermissions != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Position).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Position{config: pq.config} + node := &Position{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(pq.modifiers) > 0 { - _spec.Modifiers = pq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, pq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := pq.withDepartment; query != nil { - if err := pq.loadDepartment(ctx, query, nodes, nil, + if query := _q.withDepartment; query != nil { + if err := _q.loadDepartment(ctx, query, nodes, nil, func(n *Position, e *Department) { n.Edges.Department = e }); err != nil { return nil, err } } - if query := pq.withUsers; query != nil { - if err := pq.loadUsers(ctx, query, nodes, + if query := _q.withUsers; query != nil { + if err := _q.loadUsers(ctx, query, nodes, func(n *Position) { n.Edges.Users = []*User{} }, func(n *Position, e *User) { n.Edges.Users = append(n.Edges.Users, e) }); err != nil { return nil, err } } - if query := pq.withPermissions; query != nil { - if err := pq.loadPermissions(ctx, query, nodes, + if query := _q.withPermissions; query != nil { + if err := _q.loadPermissions(ctx, query, nodes, func(n *Position) { n.Edges.Permissions = []*Permission{} }, func(n *Position, e *Permission) { n.Edges.Permissions = append(n.Edges.Permissions, e) }); err != nil { return nil, err } } - if query := pq.withUserPositions; query != nil { - if err := pq.loadUserPositions(ctx, query, nodes, + if query := _q.withUserPositions; query != nil { + if err := _q.loadUserPositions(ctx, query, nodes, func(n *Position) { n.Edges.UserPositions = []*UserPosition{} }, func(n *Position, e *UserPosition) { n.Edges.UserPositions = append(n.Edges.UserPositions, e) }); err != nil { return nil, err } } - if query := pq.withPositionPermissions; query != nil { - if err := pq.loadPositionPermissions(ctx, query, nodes, + if query := _q.withPositionPermissions; query != nil { + if err := _q.loadPositionPermissions(ctx, query, nodes, func(n *Position) { n.Edges.PositionPermissions = []*PositionPermission{} }, func(n *Position, e *PositionPermission) { n.Edges.PositionPermissions = append(n.Edges.PositionPermissions, e) @@ -586,7 +586,7 @@ func (pq *PositionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Pos return nodes, nil } -func (pq *PositionQuery) loadDepartment(ctx context.Context, query *DepartmentQuery, nodes []*Position, init func(*Position), assign func(*Position, *Department)) error { +func (_q *PositionQuery) loadDepartment(ctx context.Context, query *DepartmentQuery, nodes []*Position, init func(*Position), assign func(*Position, *Department)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*Position) for i := range nodes { @@ -615,7 +615,7 @@ func (pq *PositionQuery) loadDepartment(ctx context.Context, query *DepartmentQu } return nil } -func (pq *PositionQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*Position, init func(*Position), assign func(*Position, *User)) error { +func (_q *PositionQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*Position, init func(*Position), assign func(*Position, *User)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*Position) nids := make(map[int64]map[*Position]struct{}) @@ -676,7 +676,7 @@ func (pq *PositionQuery) loadUsers(ctx context.Context, query *UserQuery, nodes } return nil } -func (pq *PositionQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*Position, init func(*Position), assign func(*Position, *Permission)) error { +func (_q *PositionQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*Position, init func(*Position), assign func(*Position, *Permission)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*Position) nids := make(map[int64]map[*Position]struct{}) @@ -737,7 +737,7 @@ func (pq *PositionQuery) loadPermissions(ctx context.Context, query *PermissionQ } return nil } -func (pq *PositionQuery) loadUserPositions(ctx context.Context, query *UserPositionQuery, nodes []*Position, init func(*Position), assign func(*Position, *UserPosition)) error { +func (_q *PositionQuery) loadUserPositions(ctx context.Context, query *UserPositionQuery, nodes []*Position, init func(*Position), assign func(*Position, *UserPosition)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Position) for i := range nodes { @@ -767,7 +767,7 @@ func (pq *PositionQuery) loadUserPositions(ctx context.Context, query *UserPosit } return nil } -func (pq *PositionQuery) loadPositionPermissions(ctx context.Context, query *PositionPermissionQuery, nodes []*Position, init func(*Position), assign func(*Position, *PositionPermission)) error { +func (_q *PositionQuery) loadPositionPermissions(ctx context.Context, query *PositionPermissionQuery, nodes []*Position, init func(*Position), assign func(*Position, *PositionPermission)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Position) for i := range nodes { @@ -798,27 +798,27 @@ func (pq *PositionQuery) loadPositionPermissions(ctx context.Context, query *Pos return nil } -func (pq *PositionQuery) sqlCount(ctx context.Context) (int, error) { - _spec := pq.querySpec() - if len(pq.modifiers) > 0 { - _spec.Modifiers = pq.modifiers +func (_q *PositionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = pq.ctx.Fields - if len(pq.ctx.Fields) > 0 { - _spec.Unique = pq.ctx.Unique != nil && *pq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, pq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (pq *PositionQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *PositionQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(position.Table, position.Columns, sqlgraph.NewFieldSpec(position.FieldID, field.TypeInt64)) - _spec.From = pq.sql - if unique := pq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if pq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := pq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, position.FieldID) for i := range fields { @@ -826,24 +826,24 @@ func (pq *PositionQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if pq.withDepartment != nil { + if _q.withDepartment != nil { _spec.Node.AddColumnOnce(position.FieldDepartmentID) } } - if ps := pq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := pq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := pq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := pq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -853,36 +853,36 @@ func (pq *PositionQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (pq *PositionQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(pq.driver.Dialect()) +func (_q *PositionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(position.Table) - columns := pq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = position.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if pq.sql != nil { - selector = pq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if pq.ctx.Unique != nil && *pq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range pq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range pq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range pq.order { + for _, p := range _q.order { p(selector) } - if offset := pq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := pq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -891,33 +891,33 @@ func (pq *PositionQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (pq *PositionQuery) ForUpdate(opts ...sql.LockOption) *PositionQuery { - if pq.driver.Dialect() == dialect.Postgres { - pq.Unique(false) +func (_q *PositionQuery) ForUpdate(opts ...sql.LockOption) *PositionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - pq.modifiers = append(pq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return pq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (pq *PositionQuery) ForShare(opts ...sql.LockOption) *PositionQuery { - if pq.driver.Dialect() == dialect.Postgres { - pq.Unique(false) +func (_q *PositionQuery) ForShare(opts ...sql.LockOption) *PositionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - pq.modifiers = append(pq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return pq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (pq *PositionQuery) Modify(modifiers ...func(s *sql.Selector)) *PositionSelect { - pq.modifiers = append(pq.modifiers, modifiers...) - return pq.Select() +func (_q *PositionQuery) Modify(modifiers ...func(s *sql.Selector)) *PositionSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -967,41 +967,41 @@ type PositionGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (pgb *PositionGroupBy) Aggregate(fns ...AggregateFunc) *PositionGroupBy { - pgb.fns = append(pgb.fns, fns...) - return pgb +func (_g *PositionGroupBy) Aggregate(fns ...AggregateFunc) *PositionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (pgb *PositionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, pgb.build.ctx, ent.OpQueryGroupBy) - if err := pgb.build.prepareQuery(ctx); err != nil { +func (_g *PositionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*PositionQuery, *PositionGroupBy](ctx, pgb.build, pgb, pgb.build.inters, v) + return scanWithInterceptors[*PositionQuery, *PositionGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (pgb *PositionGroupBy) sqlScan(ctx context.Context, root *PositionQuery, v any) error { +func (_g *PositionGroupBy) sqlScan(ctx context.Context, root *PositionQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(pgb.fns)) - for _, fn := range pgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*pgb.flds)+len(pgb.fns)) - for _, f := range *pgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*pgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := pgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -1015,27 +1015,27 @@ type PositionSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (ps *PositionSelect) Aggregate(fns ...AggregateFunc) *PositionSelect { - ps.fns = append(ps.fns, fns...) - return ps +func (_s *PositionSelect) Aggregate(fns ...AggregateFunc) *PositionSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (ps *PositionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ps.ctx, ent.OpQuerySelect) - if err := ps.prepareQuery(ctx); err != nil { +func (_s *PositionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*PositionQuery, *PositionSelect](ctx, ps.PositionQuery, ps, ps.inters, v) + return scanWithInterceptors[*PositionQuery, *PositionSelect](ctx, _s.PositionQuery, _s, _s.inters, v) } -func (ps *PositionSelect) sqlScan(ctx context.Context, root *PositionQuery, v any) error { +func (_s *PositionSelect) sqlScan(ctx context.Context, root *PositionQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ps.fns)) - for _, fn := range ps.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*ps.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -1043,7 +1043,7 @@ func (ps *PositionSelect) sqlScan(ctx context.Context, root *PositionQuery, v an } rows := &sql.Rows{} query, args := selector.Query() - if err := ps.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -1051,7 +1051,7 @@ func (ps *PositionSelect) sqlScan(ctx context.Context, root *PositionQuery, v an } // Modify adds a query modifier for attaching custom logic to queries. -func (ps *PositionSelect) Modify(modifiers ...func(s *sql.Selector)) *PositionSelect { - ps.modifiers = append(ps.modifiers, modifiers...) - return ps +func (_s *PositionSelect) Modify(modifiers ...func(s *sql.Selector)) *PositionSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/position_update.go b/internal/data/entity/ent/position_update.go index e42e7faf..8a7765d6 100644 --- a/internal/data/entity/ent/position_update.go +++ b/internal/data/entity/ent/position_update.go @@ -29,242 +29,242 @@ type PositionUpdate struct { } // Where appends a list predicates to the PositionUpdate builder. -func (pu *PositionUpdate) Where(ps ...predicate.Position) *PositionUpdate { - pu.mutation.Where(ps...) - return pu +func (_u *PositionUpdate) Where(ps ...predicate.Position) *PositionUpdate { + _u.mutation.Where(ps...) + return _u } // SetUpdateTime sets the "update_time" field. -func (pu *PositionUpdate) SetUpdateTime(t time.Time) *PositionUpdate { - pu.mutation.SetUpdateTime(t) - return pu +func (_u *PositionUpdate) SetUpdateTime(v time.Time) *PositionUpdate { + _u.mutation.SetUpdateTime(v) + return _u } // SetName sets the "name" field. -func (pu *PositionUpdate) SetName(s string) *PositionUpdate { - pu.mutation.SetName(s) - return pu +func (_u *PositionUpdate) SetName(v string) *PositionUpdate { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (pu *PositionUpdate) SetNillableName(s *string) *PositionUpdate { - if s != nil { - pu.SetName(*s) +func (_u *PositionUpdate) SetNillableName(v *string) *PositionUpdate { + if v != nil { + _u.SetName(*v) } - return pu + return _u } // SetKeyword sets the "keyword" field. -func (pu *PositionUpdate) SetKeyword(s string) *PositionUpdate { - pu.mutation.SetKeyword(s) - return pu +func (_u *PositionUpdate) SetKeyword(v string) *PositionUpdate { + _u.mutation.SetKeyword(v) + return _u } // SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (pu *PositionUpdate) SetNillableKeyword(s *string) *PositionUpdate { - if s != nil { - pu.SetKeyword(*s) +func (_u *PositionUpdate) SetNillableKeyword(v *string) *PositionUpdate { + if v != nil { + _u.SetKeyword(*v) } - return pu + return _u } // SetDescription sets the "description" field. -func (pu *PositionUpdate) SetDescription(s string) *PositionUpdate { - pu.mutation.SetDescription(s) - return pu +func (_u *PositionUpdate) SetDescription(v string) *PositionUpdate { + _u.mutation.SetDescription(v) + return _u } // SetNillableDescription sets the "description" field if the given value is not nil. -func (pu *PositionUpdate) SetNillableDescription(s *string) *PositionUpdate { - if s != nil { - pu.SetDescription(*s) +func (_u *PositionUpdate) SetNillableDescription(v *string) *PositionUpdate { + if v != nil { + _u.SetDescription(*v) } - return pu + return _u } // SetDepartmentID sets the "department_id" field. -func (pu *PositionUpdate) SetDepartmentID(i int64) *PositionUpdate { - pu.mutation.SetDepartmentID(i) - return pu +func (_u *PositionUpdate) SetDepartmentID(v int64) *PositionUpdate { + _u.mutation.SetDepartmentID(v) + return _u } // SetNillableDepartmentID sets the "department_id" field if the given value is not nil. -func (pu *PositionUpdate) SetNillableDepartmentID(i *int64) *PositionUpdate { - if i != nil { - pu.SetDepartmentID(*i) +func (_u *PositionUpdate) SetNillableDepartmentID(v *int64) *PositionUpdate { + if v != nil { + _u.SetDepartmentID(*v) } - return pu + return _u } // SetDepartment sets the "department" edge to the Department entity. -func (pu *PositionUpdate) SetDepartment(d *Department) *PositionUpdate { - return pu.SetDepartmentID(d.ID) +func (_u *PositionUpdate) SetDepartment(v *Department) *PositionUpdate { + return _u.SetDepartmentID(v.ID) } // AddUserIDs adds the "users" edge to the User entity by IDs. -func (pu *PositionUpdate) AddUserIDs(ids ...int64) *PositionUpdate { - pu.mutation.AddUserIDs(ids...) - return pu +func (_u *PositionUpdate) AddUserIDs(ids ...int64) *PositionUpdate { + _u.mutation.AddUserIDs(ids...) + return _u } // AddUsers adds the "users" edges to the User entity. -func (pu *PositionUpdate) AddUsers(u ...*User) *PositionUpdate { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *PositionUpdate) AddUsers(v ...*User) *PositionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddUserIDs(ids...) + return _u.AddUserIDs(ids...) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (pu *PositionUpdate) AddPermissionIDs(ids ...int64) *PositionUpdate { - pu.mutation.AddPermissionIDs(ids...) - return pu +func (_u *PositionUpdate) AddPermissionIDs(ids ...int64) *PositionUpdate { + _u.mutation.AddPermissionIDs(ids...) + return _u } // AddPermissions adds the "permissions" edges to the Permission entity. -func (pu *PositionUpdate) AddPermissions(p ...*Permission) *PositionUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PositionUpdate) AddPermissions(v ...*Permission) *PositionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddPermissionIDs(ids...) + return _u.AddPermissionIDs(ids...) } // AddUserPositionIDs adds the "user_positions" edge to the UserPosition entity by IDs. -func (pu *PositionUpdate) AddUserPositionIDs(ids ...int) *PositionUpdate { - pu.mutation.AddUserPositionIDs(ids...) - return pu +func (_u *PositionUpdate) AddUserPositionIDs(ids ...int) *PositionUpdate { + _u.mutation.AddUserPositionIDs(ids...) + return _u } // AddUserPositions adds the "user_positions" edges to the UserPosition entity. -func (pu *PositionUpdate) AddUserPositions(u ...*UserPosition) *PositionUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *PositionUpdate) AddUserPositions(v ...*UserPosition) *PositionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddUserPositionIDs(ids...) + return _u.AddUserPositionIDs(ids...) } // AddPositionPermissionIDs adds the "position_permissions" edge to the PositionPermission entity by IDs. -func (pu *PositionUpdate) AddPositionPermissionIDs(ids ...int) *PositionUpdate { - pu.mutation.AddPositionPermissionIDs(ids...) - return pu +func (_u *PositionUpdate) AddPositionPermissionIDs(ids ...int) *PositionUpdate { + _u.mutation.AddPositionPermissionIDs(ids...) + return _u } // AddPositionPermissions adds the "position_permissions" edges to the PositionPermission entity. -func (pu *PositionUpdate) AddPositionPermissions(p ...*PositionPermission) *PositionUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PositionUpdate) AddPositionPermissions(v ...*PositionPermission) *PositionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddPositionPermissionIDs(ids...) + return _u.AddPositionPermissionIDs(ids...) } // Mutation returns the PositionMutation object of the builder. -func (pu *PositionUpdate) Mutation() *PositionMutation { - return pu.mutation +func (_u *PositionUpdate) Mutation() *PositionMutation { + return _u.mutation } // ClearDepartment clears the "department" edge to the Department entity. -func (pu *PositionUpdate) ClearDepartment() *PositionUpdate { - pu.mutation.ClearDepartment() - return pu +func (_u *PositionUpdate) ClearDepartment() *PositionUpdate { + _u.mutation.ClearDepartment() + return _u } // ClearUsers clears all "users" edges to the User entity. -func (pu *PositionUpdate) ClearUsers() *PositionUpdate { - pu.mutation.ClearUsers() - return pu +func (_u *PositionUpdate) ClearUsers() *PositionUpdate { + _u.mutation.ClearUsers() + return _u } // RemoveUserIDs removes the "users" edge to User entities by IDs. -func (pu *PositionUpdate) RemoveUserIDs(ids ...int64) *PositionUpdate { - pu.mutation.RemoveUserIDs(ids...) - return pu +func (_u *PositionUpdate) RemoveUserIDs(ids ...int64) *PositionUpdate { + _u.mutation.RemoveUserIDs(ids...) + return _u } // RemoveUsers removes "users" edges to User entities. -func (pu *PositionUpdate) RemoveUsers(u ...*User) *PositionUpdate { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *PositionUpdate) RemoveUsers(v ...*User) *PositionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemoveUserIDs(ids...) + return _u.RemoveUserIDs(ids...) } // ClearPermissions clears all "permissions" edges to the Permission entity. -func (pu *PositionUpdate) ClearPermissions() *PositionUpdate { - pu.mutation.ClearPermissions() - return pu +func (_u *PositionUpdate) ClearPermissions() *PositionUpdate { + _u.mutation.ClearPermissions() + return _u } // RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. -func (pu *PositionUpdate) RemovePermissionIDs(ids ...int64) *PositionUpdate { - pu.mutation.RemovePermissionIDs(ids...) - return pu +func (_u *PositionUpdate) RemovePermissionIDs(ids ...int64) *PositionUpdate { + _u.mutation.RemovePermissionIDs(ids...) + return _u } // RemovePermissions removes "permissions" edges to Permission entities. -func (pu *PositionUpdate) RemovePermissions(p ...*Permission) *PositionUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PositionUpdate) RemovePermissions(v ...*Permission) *PositionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemovePermissionIDs(ids...) + return _u.RemovePermissionIDs(ids...) } // ClearUserPositions clears all "user_positions" edges to the UserPosition entity. -func (pu *PositionUpdate) ClearUserPositions() *PositionUpdate { - pu.mutation.ClearUserPositions() - return pu +func (_u *PositionUpdate) ClearUserPositions() *PositionUpdate { + _u.mutation.ClearUserPositions() + return _u } // RemoveUserPositionIDs removes the "user_positions" edge to UserPosition entities by IDs. -func (pu *PositionUpdate) RemoveUserPositionIDs(ids ...int) *PositionUpdate { - pu.mutation.RemoveUserPositionIDs(ids...) - return pu +func (_u *PositionUpdate) RemoveUserPositionIDs(ids ...int) *PositionUpdate { + _u.mutation.RemoveUserPositionIDs(ids...) + return _u } // RemoveUserPositions removes "user_positions" edges to UserPosition entities. -func (pu *PositionUpdate) RemoveUserPositions(u ...*UserPosition) *PositionUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *PositionUpdate) RemoveUserPositions(v ...*UserPosition) *PositionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemoveUserPositionIDs(ids...) + return _u.RemoveUserPositionIDs(ids...) } // ClearPositionPermissions clears all "position_permissions" edges to the PositionPermission entity. -func (pu *PositionUpdate) ClearPositionPermissions() *PositionUpdate { - pu.mutation.ClearPositionPermissions() - return pu +func (_u *PositionUpdate) ClearPositionPermissions() *PositionUpdate { + _u.mutation.ClearPositionPermissions() + return _u } // RemovePositionPermissionIDs removes the "position_permissions" edge to PositionPermission entities by IDs. -func (pu *PositionUpdate) RemovePositionPermissionIDs(ids ...int) *PositionUpdate { - pu.mutation.RemovePositionPermissionIDs(ids...) - return pu +func (_u *PositionUpdate) RemovePositionPermissionIDs(ids ...int) *PositionUpdate { + _u.mutation.RemovePositionPermissionIDs(ids...) + return _u } // RemovePositionPermissions removes "position_permissions" edges to PositionPermission entities. -func (pu *PositionUpdate) RemovePositionPermissions(p ...*PositionPermission) *PositionUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PositionUpdate) RemovePositionPermissions(v ...*PositionPermission) *PositionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemovePositionPermissionIDs(ids...) + return _u.RemovePositionPermissionIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. -func (pu *PositionUpdate) Save(ctx context.Context) (int, error) { - pu.defaults() - return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) +func (_u *PositionUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (pu *PositionUpdate) SaveX(ctx context.Context) int { - affected, err := pu.Save(ctx) +func (_u *PositionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -272,85 +272,85 @@ func (pu *PositionUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (pu *PositionUpdate) Exec(ctx context.Context) error { - _, err := pu.Save(ctx) +func (_u *PositionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pu *PositionUpdate) ExecX(ctx context.Context) { - if err := pu.Exec(ctx); err != nil { +func (_u *PositionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (pu *PositionUpdate) defaults() { - if _, ok := pu.mutation.UpdateTime(); !ok { +func (_u *PositionUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := position.UpdateDefaultUpdateTime() - pu.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (pu *PositionUpdate) check() error { - if v, ok := pu.mutation.Name(); ok { +func (_u *PositionUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { if err := position.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Position.name": %w`, err)} } } - if v, ok := pu.mutation.Keyword(); ok { + if v, ok := _u.mutation.Keyword(); ok { if err := position.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Position.keyword": %w`, err)} } } - if v, ok := pu.mutation.Description(); ok { + if v, ok := _u.mutation.Description(); ok { if err := position.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Position.description": %w`, err)} } } - if v, ok := pu.mutation.DepartmentID(); ok { + if v, ok := _u.mutation.DepartmentID(); ok { if err := position.DepartmentIDValidator(v); err != nil { return &ValidationError{Name: "department_id", err: fmt.Errorf(`ent: validator failed for field "Position.department_id": %w`, err)} } } - if pu.mutation.DepartmentCleared() && len(pu.mutation.DepartmentIDs()) > 0 { + if _u.mutation.DepartmentCleared() && len(_u.mutation.DepartmentIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Position.department"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (pu *PositionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PositionUpdate { - pu.modifiers = append(pu.modifiers, modifiers...) - return pu +func (_u *PositionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PositionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := pu.check(); err != nil { - return n, err +func (_u *PositionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(position.Table, position.Columns, sqlgraph.NewFieldSpec(position.FieldID, field.TypeInt64)) - if ps := pu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := pu.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(position.FieldUpdateTime, field.TypeTime, value) } - if value, ok := pu.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(position.FieldName, field.TypeString, value) } - if value, ok := pu.mutation.Keyword(); ok { + if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(position.FieldKeyword, field.TypeString, value) } - if value, ok := pu.mutation.Description(); ok { + if value, ok := _u.mutation.Description(); ok { _spec.SetField(position.FieldDescription, field.TypeString, value) } - if pu.mutation.DepartmentCleared() { + if _u.mutation.DepartmentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -363,7 +363,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.DepartmentIDs(); len(nodes) > 0 { + if nodes := _u.mutation.DepartmentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -379,7 +379,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pu.mutation.UsersCleared() { + if _u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -392,7 +392,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedUsersIDs(); len(nodes) > 0 && !pu.mutation.UsersCleared() { + if nodes := _u.mutation.RemovedUsersIDs(); len(nodes) > 0 && !_u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -408,7 +408,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.UsersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UsersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -424,7 +424,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pu.mutation.PermissionsCleared() { + if _u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -437,7 +437,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !pu.mutation.PermissionsCleared() { + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -453,7 +453,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.PermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -469,7 +469,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pu.mutation.UserPositionsCleared() { + if _u.mutation.UserPositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -482,7 +482,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedUserPositionsIDs(); len(nodes) > 0 && !pu.mutation.UserPositionsCleared() { + if nodes := _u.mutation.RemovedUserPositionsIDs(); len(nodes) > 0 && !_u.mutation.UserPositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -498,7 +498,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.UserPositionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserPositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -514,7 +514,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pu.mutation.PositionPermissionsCleared() { + if _u.mutation.PositionPermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -527,7 +527,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedPositionPermissionsIDs(); len(nodes) > 0 && !pu.mutation.PositionPermissionsCleared() { + if nodes := _u.mutation.RemovedPositionPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PositionPermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -543,7 +543,7 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.PositionPermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionPermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -559,8 +559,8 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(pu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{position.Label} } else if sqlgraph.IsConstraintError(err) { @@ -568,8 +568,8 @@ func (pu *PositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - pu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // PositionUpdateOne is the builder for updating a single Position entity. @@ -582,249 +582,249 @@ type PositionUpdateOne struct { } // SetUpdateTime sets the "update_time" field. -func (puo *PositionUpdateOne) SetUpdateTime(t time.Time) *PositionUpdateOne { - puo.mutation.SetUpdateTime(t) - return puo +func (_u *PositionUpdateOne) SetUpdateTime(v time.Time) *PositionUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u } // SetName sets the "name" field. -func (puo *PositionUpdateOne) SetName(s string) *PositionUpdateOne { - puo.mutation.SetName(s) - return puo +func (_u *PositionUpdateOne) SetName(v string) *PositionUpdateOne { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (puo *PositionUpdateOne) SetNillableName(s *string) *PositionUpdateOne { - if s != nil { - puo.SetName(*s) +func (_u *PositionUpdateOne) SetNillableName(v *string) *PositionUpdateOne { + if v != nil { + _u.SetName(*v) } - return puo + return _u } // SetKeyword sets the "keyword" field. -func (puo *PositionUpdateOne) SetKeyword(s string) *PositionUpdateOne { - puo.mutation.SetKeyword(s) - return puo +func (_u *PositionUpdateOne) SetKeyword(v string) *PositionUpdateOne { + _u.mutation.SetKeyword(v) + return _u } // SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (puo *PositionUpdateOne) SetNillableKeyword(s *string) *PositionUpdateOne { - if s != nil { - puo.SetKeyword(*s) +func (_u *PositionUpdateOne) SetNillableKeyword(v *string) *PositionUpdateOne { + if v != nil { + _u.SetKeyword(*v) } - return puo + return _u } // SetDescription sets the "description" field. -func (puo *PositionUpdateOne) SetDescription(s string) *PositionUpdateOne { - puo.mutation.SetDescription(s) - return puo +func (_u *PositionUpdateOne) SetDescription(v string) *PositionUpdateOne { + _u.mutation.SetDescription(v) + return _u } // SetNillableDescription sets the "description" field if the given value is not nil. -func (puo *PositionUpdateOne) SetNillableDescription(s *string) *PositionUpdateOne { - if s != nil { - puo.SetDescription(*s) +func (_u *PositionUpdateOne) SetNillableDescription(v *string) *PositionUpdateOne { + if v != nil { + _u.SetDescription(*v) } - return puo + return _u } // SetDepartmentID sets the "department_id" field. -func (puo *PositionUpdateOne) SetDepartmentID(i int64) *PositionUpdateOne { - puo.mutation.SetDepartmentID(i) - return puo +func (_u *PositionUpdateOne) SetDepartmentID(v int64) *PositionUpdateOne { + _u.mutation.SetDepartmentID(v) + return _u } // SetNillableDepartmentID sets the "department_id" field if the given value is not nil. -func (puo *PositionUpdateOne) SetNillableDepartmentID(i *int64) *PositionUpdateOne { - if i != nil { - puo.SetDepartmentID(*i) +func (_u *PositionUpdateOne) SetNillableDepartmentID(v *int64) *PositionUpdateOne { + if v != nil { + _u.SetDepartmentID(*v) } - return puo + return _u } // SetDepartment sets the "department" edge to the Department entity. -func (puo *PositionUpdateOne) SetDepartment(d *Department) *PositionUpdateOne { - return puo.SetDepartmentID(d.ID) +func (_u *PositionUpdateOne) SetDepartment(v *Department) *PositionUpdateOne { + return _u.SetDepartmentID(v.ID) } // AddUserIDs adds the "users" edge to the User entity by IDs. -func (puo *PositionUpdateOne) AddUserIDs(ids ...int64) *PositionUpdateOne { - puo.mutation.AddUserIDs(ids...) - return puo +func (_u *PositionUpdateOne) AddUserIDs(ids ...int64) *PositionUpdateOne { + _u.mutation.AddUserIDs(ids...) + return _u } // AddUsers adds the "users" edges to the User entity. -func (puo *PositionUpdateOne) AddUsers(u ...*User) *PositionUpdateOne { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *PositionUpdateOne) AddUsers(v ...*User) *PositionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddUserIDs(ids...) + return _u.AddUserIDs(ids...) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (puo *PositionUpdateOne) AddPermissionIDs(ids ...int64) *PositionUpdateOne { - puo.mutation.AddPermissionIDs(ids...) - return puo +func (_u *PositionUpdateOne) AddPermissionIDs(ids ...int64) *PositionUpdateOne { + _u.mutation.AddPermissionIDs(ids...) + return _u } // AddPermissions adds the "permissions" edges to the Permission entity. -func (puo *PositionUpdateOne) AddPermissions(p ...*Permission) *PositionUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PositionUpdateOne) AddPermissions(v ...*Permission) *PositionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddPermissionIDs(ids...) + return _u.AddPermissionIDs(ids...) } // AddUserPositionIDs adds the "user_positions" edge to the UserPosition entity by IDs. -func (puo *PositionUpdateOne) AddUserPositionIDs(ids ...int) *PositionUpdateOne { - puo.mutation.AddUserPositionIDs(ids...) - return puo +func (_u *PositionUpdateOne) AddUserPositionIDs(ids ...int) *PositionUpdateOne { + _u.mutation.AddUserPositionIDs(ids...) + return _u } // AddUserPositions adds the "user_positions" edges to the UserPosition entity. -func (puo *PositionUpdateOne) AddUserPositions(u ...*UserPosition) *PositionUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *PositionUpdateOne) AddUserPositions(v ...*UserPosition) *PositionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddUserPositionIDs(ids...) + return _u.AddUserPositionIDs(ids...) } // AddPositionPermissionIDs adds the "position_permissions" edge to the PositionPermission entity by IDs. -func (puo *PositionUpdateOne) AddPositionPermissionIDs(ids ...int) *PositionUpdateOne { - puo.mutation.AddPositionPermissionIDs(ids...) - return puo +func (_u *PositionUpdateOne) AddPositionPermissionIDs(ids ...int) *PositionUpdateOne { + _u.mutation.AddPositionPermissionIDs(ids...) + return _u } // AddPositionPermissions adds the "position_permissions" edges to the PositionPermission entity. -func (puo *PositionUpdateOne) AddPositionPermissions(p ...*PositionPermission) *PositionUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PositionUpdateOne) AddPositionPermissions(v ...*PositionPermission) *PositionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddPositionPermissionIDs(ids...) + return _u.AddPositionPermissionIDs(ids...) } // Mutation returns the PositionMutation object of the builder. -func (puo *PositionUpdateOne) Mutation() *PositionMutation { - return puo.mutation +func (_u *PositionUpdateOne) Mutation() *PositionMutation { + return _u.mutation } // ClearDepartment clears the "department" edge to the Department entity. -func (puo *PositionUpdateOne) ClearDepartment() *PositionUpdateOne { - puo.mutation.ClearDepartment() - return puo +func (_u *PositionUpdateOne) ClearDepartment() *PositionUpdateOne { + _u.mutation.ClearDepartment() + return _u } // ClearUsers clears all "users" edges to the User entity. -func (puo *PositionUpdateOne) ClearUsers() *PositionUpdateOne { - puo.mutation.ClearUsers() - return puo +func (_u *PositionUpdateOne) ClearUsers() *PositionUpdateOne { + _u.mutation.ClearUsers() + return _u } // RemoveUserIDs removes the "users" edge to User entities by IDs. -func (puo *PositionUpdateOne) RemoveUserIDs(ids ...int64) *PositionUpdateOne { - puo.mutation.RemoveUserIDs(ids...) - return puo +func (_u *PositionUpdateOne) RemoveUserIDs(ids ...int64) *PositionUpdateOne { + _u.mutation.RemoveUserIDs(ids...) + return _u } // RemoveUsers removes "users" edges to User entities. -func (puo *PositionUpdateOne) RemoveUsers(u ...*User) *PositionUpdateOne { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *PositionUpdateOne) RemoveUsers(v ...*User) *PositionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemoveUserIDs(ids...) + return _u.RemoveUserIDs(ids...) } // ClearPermissions clears all "permissions" edges to the Permission entity. -func (puo *PositionUpdateOne) ClearPermissions() *PositionUpdateOne { - puo.mutation.ClearPermissions() - return puo +func (_u *PositionUpdateOne) ClearPermissions() *PositionUpdateOne { + _u.mutation.ClearPermissions() + return _u } // RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. -func (puo *PositionUpdateOne) RemovePermissionIDs(ids ...int64) *PositionUpdateOne { - puo.mutation.RemovePermissionIDs(ids...) - return puo +func (_u *PositionUpdateOne) RemovePermissionIDs(ids ...int64) *PositionUpdateOne { + _u.mutation.RemovePermissionIDs(ids...) + return _u } // RemovePermissions removes "permissions" edges to Permission entities. -func (puo *PositionUpdateOne) RemovePermissions(p ...*Permission) *PositionUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PositionUpdateOne) RemovePermissions(v ...*Permission) *PositionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemovePermissionIDs(ids...) + return _u.RemovePermissionIDs(ids...) } // ClearUserPositions clears all "user_positions" edges to the UserPosition entity. -func (puo *PositionUpdateOne) ClearUserPositions() *PositionUpdateOne { - puo.mutation.ClearUserPositions() - return puo +func (_u *PositionUpdateOne) ClearUserPositions() *PositionUpdateOne { + _u.mutation.ClearUserPositions() + return _u } // RemoveUserPositionIDs removes the "user_positions" edge to UserPosition entities by IDs. -func (puo *PositionUpdateOne) RemoveUserPositionIDs(ids ...int) *PositionUpdateOne { - puo.mutation.RemoveUserPositionIDs(ids...) - return puo +func (_u *PositionUpdateOne) RemoveUserPositionIDs(ids ...int) *PositionUpdateOne { + _u.mutation.RemoveUserPositionIDs(ids...) + return _u } // RemoveUserPositions removes "user_positions" edges to UserPosition entities. -func (puo *PositionUpdateOne) RemoveUserPositions(u ...*UserPosition) *PositionUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *PositionUpdateOne) RemoveUserPositions(v ...*UserPosition) *PositionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemoveUserPositionIDs(ids...) + return _u.RemoveUserPositionIDs(ids...) } // ClearPositionPermissions clears all "position_permissions" edges to the PositionPermission entity. -func (puo *PositionUpdateOne) ClearPositionPermissions() *PositionUpdateOne { - puo.mutation.ClearPositionPermissions() - return puo +func (_u *PositionUpdateOne) ClearPositionPermissions() *PositionUpdateOne { + _u.mutation.ClearPositionPermissions() + return _u } // RemovePositionPermissionIDs removes the "position_permissions" edge to PositionPermission entities by IDs. -func (puo *PositionUpdateOne) RemovePositionPermissionIDs(ids ...int) *PositionUpdateOne { - puo.mutation.RemovePositionPermissionIDs(ids...) - return puo +func (_u *PositionUpdateOne) RemovePositionPermissionIDs(ids ...int) *PositionUpdateOne { + _u.mutation.RemovePositionPermissionIDs(ids...) + return _u } // RemovePositionPermissions removes "position_permissions" edges to PositionPermission entities. -func (puo *PositionUpdateOne) RemovePositionPermissions(p ...*PositionPermission) *PositionUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *PositionUpdateOne) RemovePositionPermissions(v ...*PositionPermission) *PositionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemovePositionPermissionIDs(ids...) + return _u.RemovePositionPermissionIDs(ids...) } // Where appends a list predicates to the PositionUpdate builder. -func (puo *PositionUpdateOne) Where(ps ...predicate.Position) *PositionUpdateOne { - puo.mutation.Where(ps...) - return puo +func (_u *PositionUpdateOne) Where(ps ...predicate.Position) *PositionUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (puo *PositionUpdateOne) Select(field string, fields ...string) *PositionUpdateOne { - puo.fields = append([]string{field}, fields...) - return puo +func (_u *PositionUpdateOne) Select(field string, fields ...string) *PositionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Position entity. -func (puo *PositionUpdateOne) Save(ctx context.Context) (*Position, error) { - puo.defaults() - return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) +func (_u *PositionUpdateOne) Save(ctx context.Context) (*Position, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (puo *PositionUpdateOne) SaveX(ctx context.Context) *Position { - node, err := puo.Save(ctx) +func (_u *PositionUpdateOne) SaveX(ctx context.Context) *Position { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -832,71 +832,71 @@ func (puo *PositionUpdateOne) SaveX(ctx context.Context) *Position { } // Exec executes the query on the entity. -func (puo *PositionUpdateOne) Exec(ctx context.Context) error { - _, err := puo.Save(ctx) +func (_u *PositionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (puo *PositionUpdateOne) ExecX(ctx context.Context) { - if err := puo.Exec(ctx); err != nil { +func (_u *PositionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (puo *PositionUpdateOne) defaults() { - if _, ok := puo.mutation.UpdateTime(); !ok { +func (_u *PositionUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := position.UpdateDefaultUpdateTime() - puo.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (puo *PositionUpdateOne) check() error { - if v, ok := puo.mutation.Name(); ok { +func (_u *PositionUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { if err := position.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Position.name": %w`, err)} } } - if v, ok := puo.mutation.Keyword(); ok { + if v, ok := _u.mutation.Keyword(); ok { if err := position.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Position.keyword": %w`, err)} } } - if v, ok := puo.mutation.Description(); ok { + if v, ok := _u.mutation.Description(); ok { if err := position.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Position.description": %w`, err)} } } - if v, ok := puo.mutation.DepartmentID(); ok { + if v, ok := _u.mutation.DepartmentID(); ok { if err := position.DepartmentIDValidator(v); err != nil { return &ValidationError{Name: "department_id", err: fmt.Errorf(`ent: validator failed for field "Position.department_id": %w`, err)} } } - if puo.mutation.DepartmentCleared() && len(puo.mutation.DepartmentIDs()) > 0 { + if _u.mutation.DepartmentCleared() && len(_u.mutation.DepartmentIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "Position.department"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (puo *PositionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PositionUpdateOne { - puo.modifiers = append(puo.modifiers, modifiers...) - return puo +func (_u *PositionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PositionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err error) { - if err := puo.check(); err != nil { +func (_u *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(position.Table, position.Columns, sqlgraph.NewFieldSpec(position.FieldID, field.TypeInt64)) - id, ok := puo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Position.id" for update`)} } _spec.Node.ID.Value = id - if fields := puo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, position.FieldID) for _, f := range fields { @@ -908,26 +908,26 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } } } - if ps := puo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := puo.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(position.FieldUpdateTime, field.TypeTime, value) } - if value, ok := puo.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(position.FieldName, field.TypeString, value) } - if value, ok := puo.mutation.Keyword(); ok { + if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(position.FieldKeyword, field.TypeString, value) } - if value, ok := puo.mutation.Description(); ok { + if value, ok := _u.mutation.Description(); ok { _spec.SetField(position.FieldDescription, field.TypeString, value) } - if puo.mutation.DepartmentCleared() { + if _u.mutation.DepartmentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -940,7 +940,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.DepartmentIDs(); len(nodes) > 0 { + if nodes := _u.mutation.DepartmentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -956,7 +956,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if puo.mutation.UsersCleared() { + if _u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -969,7 +969,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedUsersIDs(); len(nodes) > 0 && !puo.mutation.UsersCleared() { + if nodes := _u.mutation.RemovedUsersIDs(); len(nodes) > 0 && !_u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -985,7 +985,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.UsersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UsersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1001,7 +1001,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if puo.mutation.PermissionsCleared() { + if _u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1014,7 +1014,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !puo.mutation.PermissionsCleared() { + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1030,7 +1030,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.PermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1046,7 +1046,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if puo.mutation.UserPositionsCleared() { + if _u.mutation.UserPositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1059,7 +1059,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedUserPositionsIDs(); len(nodes) > 0 && !puo.mutation.UserPositionsCleared() { + if nodes := _u.mutation.RemovedUserPositionsIDs(); len(nodes) > 0 && !_u.mutation.UserPositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1075,7 +1075,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.UserPositionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserPositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1091,7 +1091,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if puo.mutation.PositionPermissionsCleared() { + if _u.mutation.PositionPermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1104,7 +1104,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedPositionPermissionsIDs(); len(nodes) > 0 && !puo.mutation.PositionPermissionsCleared() { + if nodes := _u.mutation.RemovedPositionPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PositionPermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1120,7 +1120,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.PositionPermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionPermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1136,11 +1136,11 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(puo.modifiers...) - _node = &Position{config: puo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Position{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{position.Label} } else if sqlgraph.IsConstraintError(err) { @@ -1148,7 +1148,7 @@ func (puo *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err } return nil, err } - puo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/positionpermission.go b/internal/data/entity/ent/positionpermission.go index b0efc10f..a3065687 100644 --- a/internal/data/entity/ent/positionpermission.go +++ b/internal/data/entity/ent/positionpermission.go @@ -77,7 +77,7 @@ func (*PositionPermission) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the PositionPermission fields. -func (pp *PositionPermission) assignValues(columns []string, values []any) error { +func (_m *PositionPermission) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -88,21 +88,21 @@ func (pp *PositionPermission) assignValues(columns []string, values []any) error if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - pp.ID = int(value.Int64) + _m.ID = int(value.Int64) case positionpermission.FieldPositionID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field position_id", values[i]) } else if value.Valid { - pp.PositionID = value.Int64 + _m.PositionID = value.Int64 } case positionpermission.FieldPermissionID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field permission_id", values[i]) } else if value.Valid { - pp.PermissionID = value.Int64 + _m.PermissionID = value.Int64 } default: - pp.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -110,48 +110,48 @@ func (pp *PositionPermission) assignValues(columns []string, values []any) error // Value returns the ent.Value that was dynamically selected and assigned to the PositionPermission. // This includes values selected through modifiers, order, etc. -func (pp *PositionPermission) Value(name string) (ent.Value, error) { - return pp.selectValues.Get(name) +func (_m *PositionPermission) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryPosition queries the "position" edge of the PositionPermission entity. -func (pp *PositionPermission) QueryPosition() *PositionQuery { - return NewPositionPermissionClient(pp.config).QueryPosition(pp) +func (_m *PositionPermission) QueryPosition() *PositionQuery { + return NewPositionPermissionClient(_m.config).QueryPosition(_m) } // QueryPermission queries the "permission" edge of the PositionPermission entity. -func (pp *PositionPermission) QueryPermission() *PermissionQuery { - return NewPositionPermissionClient(pp.config).QueryPermission(pp) +func (_m *PositionPermission) QueryPermission() *PermissionQuery { + return NewPositionPermissionClient(_m.config).QueryPermission(_m) } // Update returns a builder for updating this PositionPermission. // Note that you need to call PositionPermission.Unwrap() before calling this method if this PositionPermission // was returned from a transaction, and the transaction was committed or rolled back. -func (pp *PositionPermission) Update() *PositionPermissionUpdateOne { - return NewPositionPermissionClient(pp.config).UpdateOne(pp) +func (_m *PositionPermission) Update() *PositionPermissionUpdateOne { + return NewPositionPermissionClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the PositionPermission entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (pp *PositionPermission) Unwrap() *PositionPermission { - _tx, ok := pp.config.driver.(*txDriver) +func (_m *PositionPermission) Unwrap() *PositionPermission { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: PositionPermission is not a transactional entity") } - pp.config.driver = _tx.drv - return pp + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (pp *PositionPermission) String() string { +func (_m *PositionPermission) String() string { var builder strings.Builder builder.WriteString("PositionPermission(") - builder.WriteString(fmt.Sprintf("id=%v, ", pp.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("position_id=") - builder.WriteString(fmt.Sprintf("%v", pp.PositionID)) + builder.WriteString(fmt.Sprintf("%v", _m.PositionID)) builder.WriteString(", ") builder.WriteString("permission_id=") - builder.WriteString(fmt.Sprintf("%v", pp.PermissionID)) + builder.WriteString(fmt.Sprintf("%v", _m.PermissionID)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/positionpermission_create.go b/internal/data/entity/ent/positionpermission_create.go index 1e41ae36..96ea8b88 100644 --- a/internal/data/entity/ent/positionpermission_create.go +++ b/internal/data/entity/ent/positionpermission_create.go @@ -22,40 +22,40 @@ type PositionPermissionCreate struct { } // SetPositionID sets the "position_id" field. -func (ppc *PositionPermissionCreate) SetPositionID(i int64) *PositionPermissionCreate { - ppc.mutation.SetPositionID(i) - return ppc +func (_c *PositionPermissionCreate) SetPositionID(v int64) *PositionPermissionCreate { + _c.mutation.SetPositionID(v) + return _c } // SetPermissionID sets the "permission_id" field. -func (ppc *PositionPermissionCreate) SetPermissionID(i int64) *PositionPermissionCreate { - ppc.mutation.SetPermissionID(i) - return ppc +func (_c *PositionPermissionCreate) SetPermissionID(v int64) *PositionPermissionCreate { + _c.mutation.SetPermissionID(v) + return _c } // SetPosition sets the "position" edge to the Position entity. -func (ppc *PositionPermissionCreate) SetPosition(p *Position) *PositionPermissionCreate { - return ppc.SetPositionID(p.ID) +func (_c *PositionPermissionCreate) SetPosition(v *Position) *PositionPermissionCreate { + return _c.SetPositionID(v.ID) } // SetPermission sets the "permission" edge to the Permission entity. -func (ppc *PositionPermissionCreate) SetPermission(p *Permission) *PositionPermissionCreate { - return ppc.SetPermissionID(p.ID) +func (_c *PositionPermissionCreate) SetPermission(v *Permission) *PositionPermissionCreate { + return _c.SetPermissionID(v.ID) } // Mutation returns the PositionPermissionMutation object of the builder. -func (ppc *PositionPermissionCreate) Mutation() *PositionPermissionMutation { - return ppc.mutation +func (_c *PositionPermissionCreate) Mutation() *PositionPermissionMutation { + return _c.mutation } // Save creates the PositionPermission in the database. -func (ppc *PositionPermissionCreate) Save(ctx context.Context) (*PositionPermission, error) { - return withHooks(ctx, ppc.sqlSave, ppc.mutation, ppc.hooks) +func (_c *PositionPermissionCreate) Save(ctx context.Context) (*PositionPermission, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (ppc *PositionPermissionCreate) SaveX(ctx context.Context) *PositionPermission { - v, err := ppc.Save(ctx) +func (_c *PositionPermissionCreate) SaveX(ctx context.Context) *PositionPermission { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -63,51 +63,51 @@ func (ppc *PositionPermissionCreate) SaveX(ctx context.Context) *PositionPermiss } // Exec executes the query. -func (ppc *PositionPermissionCreate) Exec(ctx context.Context) error { - _, err := ppc.Save(ctx) +func (_c *PositionPermissionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ppc *PositionPermissionCreate) ExecX(ctx context.Context) { - if err := ppc.Exec(ctx); err != nil { +func (_c *PositionPermissionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (ppc *PositionPermissionCreate) check() error { - if _, ok := ppc.mutation.PositionID(); !ok { +func (_c *PositionPermissionCreate) check() error { + if _, ok := _c.mutation.PositionID(); !ok { return &ValidationError{Name: "position_id", err: errors.New(`ent: missing required field "PositionPermission.position_id"`)} } - if v, ok := ppc.mutation.PositionID(); ok { + if v, ok := _c.mutation.PositionID(); ok { if err := positionpermission.PositionIDValidator(v); err != nil { return &ValidationError{Name: "position_id", err: fmt.Errorf(`ent: validator failed for field "PositionPermission.position_id": %w`, err)} } } - if _, ok := ppc.mutation.PermissionID(); !ok { + if _, ok := _c.mutation.PermissionID(); !ok { return &ValidationError{Name: "permission_id", err: errors.New(`ent: missing required field "PositionPermission.permission_id"`)} } - if v, ok := ppc.mutation.PermissionID(); ok { + if v, ok := _c.mutation.PermissionID(); ok { if err := positionpermission.PermissionIDValidator(v); err != nil { return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "PositionPermission.permission_id": %w`, err)} } } - if len(ppc.mutation.PositionIDs()) == 0 { + if len(_c.mutation.PositionIDs()) == 0 { return &ValidationError{Name: "position", err: errors.New(`ent: missing required edge "PositionPermission.position"`)} } - if len(ppc.mutation.PermissionIDs()) == 0 { + if len(_c.mutation.PermissionIDs()) == 0 { return &ValidationError{Name: "permission", err: errors.New(`ent: missing required edge "PositionPermission.permission"`)} } return nil } -func (ppc *PositionPermissionCreate) sqlSave(ctx context.Context) (*PositionPermission, error) { - if err := ppc.check(); err != nil { +func (_c *PositionPermissionCreate) sqlSave(ctx context.Context) (*PositionPermission, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := ppc.createSpec() - if err := sqlgraph.CreateNode(ctx, ppc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -115,17 +115,17 @@ func (ppc *PositionPermissionCreate) sqlSave(ctx context.Context) (*PositionPerm } id := _spec.ID.Value.(int64) _node.ID = int(id) - ppc.mutation.id = &_node.ID - ppc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (ppc *PositionPermissionCreate) createSpec() (*PositionPermission, *sqlgraph.CreateSpec) { +func (_c *PositionPermissionCreate) createSpec() (*PositionPermission, *sqlgraph.CreateSpec) { var ( - _node = &PositionPermission{config: ppc.config} + _node = &PositionPermission{config: _c.config} _spec = sqlgraph.NewCreateSpec(positionpermission.Table, sqlgraph.NewFieldSpec(positionpermission.FieldID, field.TypeInt)) ) - if nodes := ppc.mutation.PositionIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PositionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -142,7 +142,7 @@ func (ppc *PositionPermissionCreate) createSpec() (*PositionPermission, *sqlgrap _node.PositionID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := ppc.mutation.PermissionIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PermissionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -163,23 +163,23 @@ func (ppc *PositionPermissionCreate) createSpec() (*PositionPermission, *sqlgrap } // SetPositionPermission set the PositionPermission -func (ppc *PositionPermissionCreate) SetPositionPermission(input *PositionPermission, fields ...string) *PositionPermissionCreate { - m := ppc.mutation +func (_c *PositionPermissionCreate) SetPositionPermission(input *PositionPermission, fields ...string) *PositionPermissionCreate { + m := _c.mutation if len(fields) == 0 { fields = positionpermission.Columns } _ = m.SetFields(input, fields...) - return ppc + return _c } // SetPositionPermissionWithZero set the PositionPermission -func (ppc *PositionPermissionCreate) SetPositionPermissionWithZero(input *PositionPermission, fields ...string) *PositionPermissionCreate { - m := ppc.mutation +func (_c *PositionPermissionCreate) SetPositionPermissionWithZero(input *PositionPermission, fields ...string) *PositionPermissionCreate { + m := _c.mutation if len(fields) == 0 { fields = positionpermission.Columns } _ = m.SetFieldsWithZero(input, fields...) - return ppc + return _c } // PositionPermissionCreateBulk is the builder for creating many PositionPermission entities in bulk. @@ -190,16 +190,16 @@ type PositionPermissionCreateBulk struct { } // Save creates the PositionPermission entities in the database. -func (ppcb *PositionPermissionCreateBulk) Save(ctx context.Context) ([]*PositionPermission, error) { - if ppcb.err != nil { - return nil, ppcb.err +func (_c *PositionPermissionCreateBulk) Save(ctx context.Context) ([]*PositionPermission, error) { + if _c.err != nil { + return nil, _c.err } - specs := make([]*sqlgraph.CreateSpec, len(ppcb.builders)) - nodes := make([]*PositionPermission, len(ppcb.builders)) - mutators := make([]Mutator, len(ppcb.builders)) - for i := range ppcb.builders { + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*PositionPermission, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := ppcb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*PositionPermissionMutation) if !ok { @@ -212,11 +212,11 @@ func (ppcb *PositionPermissionCreateBulk) Save(ctx context.Context) ([]*Position var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, ppcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, ppcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -240,7 +240,7 @@ func (ppcb *PositionPermissionCreateBulk) Save(ctx context.Context) ([]*Position }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, ppcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -248,8 +248,8 @@ func (ppcb *PositionPermissionCreateBulk) Save(ctx context.Context) ([]*Position } // SaveX is like Save, but panics if an error occurs. -func (ppcb *PositionPermissionCreateBulk) SaveX(ctx context.Context) []*PositionPermission { - v, err := ppcb.Save(ctx) +func (_c *PositionPermissionCreateBulk) SaveX(ctx context.Context) []*PositionPermission { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -257,14 +257,14 @@ func (ppcb *PositionPermissionCreateBulk) SaveX(ctx context.Context) []*Position } // Exec executes the query. -func (ppcb *PositionPermissionCreateBulk) Exec(ctx context.Context) error { - _, err := ppcb.Save(ctx) +func (_c *PositionPermissionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ppcb *PositionPermissionCreateBulk) ExecX(ctx context.Context) { - if err := ppcb.Exec(ctx); err != nil { +func (_c *PositionPermissionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/positionpermission_delete.go b/internal/data/entity/ent/positionpermission_delete.go index 955b446a..3a002efb 100644 --- a/internal/data/entity/ent/positionpermission_delete.go +++ b/internal/data/entity/ent/positionpermission_delete.go @@ -20,56 +20,56 @@ type PositionPermissionDelete struct { } // Where appends a list predicates to the PositionPermissionDelete builder. -func (ppd *PositionPermissionDelete) Where(ps ...predicate.PositionPermission) *PositionPermissionDelete { - ppd.mutation.Where(ps...) - return ppd +func (_d *PositionPermissionDelete) Where(ps ...predicate.PositionPermission) *PositionPermissionDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (ppd *PositionPermissionDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, ppd.sqlExec, ppd.mutation, ppd.hooks) +func (_d *PositionPermissionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (ppd *PositionPermissionDelete) ExecX(ctx context.Context) int { - n, err := ppd.Exec(ctx) +func (_d *PositionPermissionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (ppd *PositionPermissionDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *PositionPermissionDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(positionpermission.Table, sqlgraph.NewFieldSpec(positionpermission.FieldID, field.TypeInt)) - if ps := ppd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, ppd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - ppd.mutation.done = true + _d.mutation.done = true return affected, err } // PositionPermissionDeleteOne is the builder for deleting a single PositionPermission entity. type PositionPermissionDeleteOne struct { - ppd *PositionPermissionDelete + _d *PositionPermissionDelete } // Where appends a list predicates to the PositionPermissionDelete builder. -func (ppdo *PositionPermissionDeleteOne) Where(ps ...predicate.PositionPermission) *PositionPermissionDeleteOne { - ppdo.ppd.mutation.Where(ps...) - return ppdo +func (_d *PositionPermissionDeleteOne) Where(ps ...predicate.PositionPermission) *PositionPermissionDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (ppdo *PositionPermissionDeleteOne) Exec(ctx context.Context) error { - n, err := ppdo.ppd.Exec(ctx) +func (_d *PositionPermissionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (ppdo *PositionPermissionDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (ppdo *PositionPermissionDeleteOne) ExecX(ctx context.Context) { - if err := ppdo.Exec(ctx); err != nil { +func (_d *PositionPermissionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/positionpermission_query.go b/internal/data/entity/ent/positionpermission_query.go index 341b3613..277d64b2 100644 --- a/internal/data/entity/ent/positionpermission_query.go +++ b/internal/data/entity/ent/positionpermission_query.go @@ -34,44 +34,44 @@ type PositionPermissionQuery struct { } // Where adds a new predicate for the PositionPermissionQuery builder. -func (ppq *PositionPermissionQuery) Where(ps ...predicate.PositionPermission) *PositionPermissionQuery { - ppq.predicates = append(ppq.predicates, ps...) - return ppq +func (_q *PositionPermissionQuery) Where(ps ...predicate.PositionPermission) *PositionPermissionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (ppq *PositionPermissionQuery) Limit(limit int) *PositionPermissionQuery { - ppq.ctx.Limit = &limit - return ppq +func (_q *PositionPermissionQuery) Limit(limit int) *PositionPermissionQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (ppq *PositionPermissionQuery) Offset(offset int) *PositionPermissionQuery { - ppq.ctx.Offset = &offset - return ppq +func (_q *PositionPermissionQuery) Offset(offset int) *PositionPermissionQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (ppq *PositionPermissionQuery) Unique(unique bool) *PositionPermissionQuery { - ppq.ctx.Unique = &unique - return ppq +func (_q *PositionPermissionQuery) Unique(unique bool) *PositionPermissionQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (ppq *PositionPermissionQuery) Order(o ...positionpermission.OrderOption) *PositionPermissionQuery { - ppq.order = append(ppq.order, o...) - return ppq +func (_q *PositionPermissionQuery) Order(o ...positionpermission.OrderOption) *PositionPermissionQuery { + _q.order = append(_q.order, o...) + return _q } // QueryPosition chains the current query on the "position" edge. -func (ppq *PositionPermissionQuery) QueryPosition() *PositionQuery { - query := (&PositionClient{config: ppq.config}).Query() +func (_q *PositionPermissionQuery) QueryPosition() *PositionQuery { + query := (&PositionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := ppq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := ppq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -80,20 +80,20 @@ func (ppq *PositionPermissionQuery) QueryPosition() *PositionQuery { sqlgraph.To(position.Table, position.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, positionpermission.PositionTable, positionpermission.PositionColumn), ) - fromU = sqlgraph.SetNeighbors(ppq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPermission chains the current query on the "permission" edge. -func (ppq *PositionPermissionQuery) QueryPermission() *PermissionQuery { - query := (&PermissionClient{config: ppq.config}).Query() +func (_q *PositionPermissionQuery) QueryPermission() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := ppq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := ppq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -102,7 +102,7 @@ func (ppq *PositionPermissionQuery) QueryPermission() *PermissionQuery { sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, positionpermission.PermissionTable, positionpermission.PermissionColumn), ) - fromU = sqlgraph.SetNeighbors(ppq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -110,8 +110,8 @@ func (ppq *PositionPermissionQuery) QueryPermission() *PermissionQuery { // First returns the first PositionPermission entity from the query. // Returns a *NotFoundError when no PositionPermission was found. -func (ppq *PositionPermissionQuery) First(ctx context.Context) (*PositionPermission, error) { - nodes, err := ppq.Limit(1).All(setContextOp(ctx, ppq.ctx, ent.OpQueryFirst)) +func (_q *PositionPermissionQuery) First(ctx context.Context) (*PositionPermission, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -122,8 +122,8 @@ func (ppq *PositionPermissionQuery) First(ctx context.Context) (*PositionPermiss } // FirstX is like First, but panics if an error occurs. -func (ppq *PositionPermissionQuery) FirstX(ctx context.Context) *PositionPermission { - node, err := ppq.First(ctx) +func (_q *PositionPermissionQuery) FirstX(ctx context.Context) *PositionPermission { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -132,9 +132,9 @@ func (ppq *PositionPermissionQuery) FirstX(ctx context.Context) *PositionPermiss // FirstID returns the first PositionPermission ID from the query. // Returns a *NotFoundError when no PositionPermission ID was found. -func (ppq *PositionPermissionQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *PositionPermissionQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = ppq.Limit(1).IDs(setContextOp(ctx, ppq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -145,8 +145,8 @@ func (ppq *PositionPermissionQuery) FirstID(ctx context.Context) (id int, err er } // FirstIDX is like FirstID, but panics if an error occurs. -func (ppq *PositionPermissionQuery) FirstIDX(ctx context.Context) int { - id, err := ppq.FirstID(ctx) +func (_q *PositionPermissionQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -156,8 +156,8 @@ func (ppq *PositionPermissionQuery) FirstIDX(ctx context.Context) int { // Only returns a single PositionPermission entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one PositionPermission entity is found. // Returns a *NotFoundError when no PositionPermission entities are found. -func (ppq *PositionPermissionQuery) Only(ctx context.Context) (*PositionPermission, error) { - nodes, err := ppq.Limit(2).All(setContextOp(ctx, ppq.ctx, ent.OpQueryOnly)) +func (_q *PositionPermissionQuery) Only(ctx context.Context) (*PositionPermission, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -172,8 +172,8 @@ func (ppq *PositionPermissionQuery) Only(ctx context.Context) (*PositionPermissi } // OnlyX is like Only, but panics if an error occurs. -func (ppq *PositionPermissionQuery) OnlyX(ctx context.Context) *PositionPermission { - node, err := ppq.Only(ctx) +func (_q *PositionPermissionQuery) OnlyX(ctx context.Context) *PositionPermission { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -183,9 +183,9 @@ func (ppq *PositionPermissionQuery) OnlyX(ctx context.Context) *PositionPermissi // OnlyID is like Only, but returns the only PositionPermission ID in the query. // Returns a *NotSingularError when more than one PositionPermission ID is found. // Returns a *NotFoundError when no entities are found. -func (ppq *PositionPermissionQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *PositionPermissionQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = ppq.Limit(2).IDs(setContextOp(ctx, ppq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -200,8 +200,8 @@ func (ppq *PositionPermissionQuery) OnlyID(ctx context.Context) (id int, err err } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (ppq *PositionPermissionQuery) OnlyIDX(ctx context.Context) int { - id, err := ppq.OnlyID(ctx) +func (_q *PositionPermissionQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -209,18 +209,18 @@ func (ppq *PositionPermissionQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of PositionPermissions. -func (ppq *PositionPermissionQuery) All(ctx context.Context) ([]*PositionPermission, error) { - ctx = setContextOp(ctx, ppq.ctx, ent.OpQueryAll) - if err := ppq.prepareQuery(ctx); err != nil { +func (_q *PositionPermissionQuery) All(ctx context.Context) ([]*PositionPermission, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*PositionPermission, *PositionPermissionQuery]() - return withInterceptors[[]*PositionPermission](ctx, ppq, qr, ppq.inters) + return withInterceptors[[]*PositionPermission](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (ppq *PositionPermissionQuery) AllX(ctx context.Context) []*PositionPermission { - nodes, err := ppq.All(ctx) +func (_q *PositionPermissionQuery) AllX(ctx context.Context) []*PositionPermission { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -228,20 +228,20 @@ func (ppq *PositionPermissionQuery) AllX(ctx context.Context) []*PositionPermiss } // IDs executes the query and returns a list of PositionPermission IDs. -func (ppq *PositionPermissionQuery) IDs(ctx context.Context) (ids []int, err error) { - if ppq.ctx.Unique == nil && ppq.path != nil { - ppq.Unique(true) +func (_q *PositionPermissionQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, ppq.ctx, ent.OpQueryIDs) - if err = ppq.Select(positionpermission.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(positionpermission.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (ppq *PositionPermissionQuery) IDsX(ctx context.Context) []int { - ids, err := ppq.IDs(ctx) +func (_q *PositionPermissionQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -249,17 +249,17 @@ func (ppq *PositionPermissionQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (ppq *PositionPermissionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, ppq.ctx, ent.OpQueryCount) - if err := ppq.prepareQuery(ctx); err != nil { +func (_q *PositionPermissionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, ppq, querierCount[*PositionPermissionQuery](), ppq.inters) + return withInterceptors[int](ctx, _q, querierCount[*PositionPermissionQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (ppq *PositionPermissionQuery) CountX(ctx context.Context) int { - count, err := ppq.Count(ctx) +func (_q *PositionPermissionQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -267,9 +267,9 @@ func (ppq *PositionPermissionQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (ppq *PositionPermissionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, ppq.ctx, ent.OpQueryExist) - switch _, err := ppq.FirstID(ctx); { +func (_q *PositionPermissionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -280,8 +280,8 @@ func (ppq *PositionPermissionQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (ppq *PositionPermissionQuery) ExistX(ctx context.Context) bool { - exist, err := ppq.Exist(ctx) +func (_q *PositionPermissionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -290,45 +290,45 @@ func (ppq *PositionPermissionQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the PositionPermissionQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (ppq *PositionPermissionQuery) Clone() *PositionPermissionQuery { - if ppq == nil { +func (_q *PositionPermissionQuery) Clone() *PositionPermissionQuery { + if _q == nil { return nil } return &PositionPermissionQuery{ - config: ppq.config, - ctx: ppq.ctx.Clone(), - order: append([]positionpermission.OrderOption{}, ppq.order...), - inters: append([]Interceptor{}, ppq.inters...), - predicates: append([]predicate.PositionPermission{}, ppq.predicates...), - withPosition: ppq.withPosition.Clone(), - withPermission: ppq.withPermission.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]positionpermission.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.PositionPermission{}, _q.predicates...), + withPosition: _q.withPosition.Clone(), + withPermission: _q.withPermission.Clone(), // clone intermediate query. - sql: ppq.sql.Clone(), - path: ppq.path, - modifiers: append([]func(*sql.Selector){}, ppq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithPosition tells the query-builder to eager-load the nodes that are connected to // the "position" edge. The optional arguments are used to configure the query builder of the edge. -func (ppq *PositionPermissionQuery) WithPosition(opts ...func(*PositionQuery)) *PositionPermissionQuery { - query := (&PositionClient{config: ppq.config}).Query() +func (_q *PositionPermissionQuery) WithPosition(opts ...func(*PositionQuery)) *PositionPermissionQuery { + query := (&PositionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - ppq.withPosition = query - return ppq + _q.withPosition = query + return _q } // WithPermission tells the query-builder to eager-load the nodes that are connected to // the "permission" edge. The optional arguments are used to configure the query builder of the edge. -func (ppq *PositionPermissionQuery) WithPermission(opts ...func(*PermissionQuery)) *PositionPermissionQuery { - query := (&PermissionClient{config: ppq.config}).Query() +func (_q *PositionPermissionQuery) WithPermission(opts ...func(*PermissionQuery)) *PositionPermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - ppq.withPermission = query - return ppq + _q.withPermission = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -345,10 +345,10 @@ func (ppq *PositionPermissionQuery) WithPermission(opts ...func(*PermissionQuery // GroupBy(positionpermission.FieldPositionID). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (ppq *PositionPermissionQuery) GroupBy(field string, fields ...string) *PositionPermissionGroupBy { - ppq.ctx.Fields = append([]string{field}, fields...) - grbuild := &PositionPermissionGroupBy{build: ppq} - grbuild.flds = &ppq.ctx.Fields +func (_q *PositionPermissionQuery) GroupBy(field string, fields ...string) *PositionPermissionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PositionPermissionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = positionpermission.Label grbuild.scan = grbuild.Scan return grbuild @@ -366,83 +366,83 @@ func (ppq *PositionPermissionQuery) GroupBy(field string, fields ...string) *Pos // client.PositionPermission.Query(). // Select(positionpermission.FieldPositionID). // Scan(ctx, &v) -func (ppq *PositionPermissionQuery) Select(fields ...string) *PositionPermissionSelect { - ppq.ctx.Fields = append(ppq.ctx.Fields, fields...) - sbuild := &PositionPermissionSelect{PositionPermissionQuery: ppq} +func (_q *PositionPermissionQuery) Select(fields ...string) *PositionPermissionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PositionPermissionSelect{PositionPermissionQuery: _q} sbuild.label = positionpermission.Label - sbuild.flds, sbuild.scan = &ppq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a PositionPermissionSelect configured with the given aggregations. -func (ppq *PositionPermissionQuery) Aggregate(fns ...AggregateFunc) *PositionPermissionSelect { - return ppq.Select().Aggregate(fns...) +func (_q *PositionPermissionQuery) Aggregate(fns ...AggregateFunc) *PositionPermissionSelect { + return _q.Select().Aggregate(fns...) } -func (ppq *PositionPermissionQuery) prepareQuery(ctx context.Context) error { - for _, inter := range ppq.inters { +func (_q *PositionPermissionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, ppq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range ppq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !positionpermission.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if ppq.path != nil { - prev, err := ppq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - ppq.sql = prev + _q.sql = prev } return nil } -func (ppq *PositionPermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PositionPermission, error) { +func (_q *PositionPermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PositionPermission, error) { var ( nodes = []*PositionPermission{} - _spec = ppq.querySpec() + _spec = _q.querySpec() loadedTypes = [2]bool{ - ppq.withPosition != nil, - ppq.withPermission != nil, + _q.withPosition != nil, + _q.withPermission != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*PositionPermission).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &PositionPermission{config: ppq.config} + node := &PositionPermission{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(ppq.modifiers) > 0 { - _spec.Modifiers = ppq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, ppq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := ppq.withPosition; query != nil { - if err := ppq.loadPosition(ctx, query, nodes, nil, + if query := _q.withPosition; query != nil { + if err := _q.loadPosition(ctx, query, nodes, nil, func(n *PositionPermission, e *Position) { n.Edges.Position = e }); err != nil { return nil, err } } - if query := ppq.withPermission; query != nil { - if err := ppq.loadPermission(ctx, query, nodes, nil, + if query := _q.withPermission; query != nil { + if err := _q.loadPermission(ctx, query, nodes, nil, func(n *PositionPermission, e *Permission) { n.Edges.Permission = e }); err != nil { return nil, err } @@ -450,7 +450,7 @@ func (ppq *PositionPermissionQuery) sqlAll(ctx context.Context, hooks ...queryHo return nodes, nil } -func (ppq *PositionPermissionQuery) loadPosition(ctx context.Context, query *PositionQuery, nodes []*PositionPermission, init func(*PositionPermission), assign func(*PositionPermission, *Position)) error { +func (_q *PositionPermissionQuery) loadPosition(ctx context.Context, query *PositionQuery, nodes []*PositionPermission, init func(*PositionPermission), assign func(*PositionPermission, *Position)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*PositionPermission) for i := range nodes { @@ -479,7 +479,7 @@ func (ppq *PositionPermissionQuery) loadPosition(ctx context.Context, query *Pos } return nil } -func (ppq *PositionPermissionQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*PositionPermission, init func(*PositionPermission), assign func(*PositionPermission, *Permission)) error { +func (_q *PositionPermissionQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*PositionPermission, init func(*PositionPermission), assign func(*PositionPermission, *Permission)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*PositionPermission) for i := range nodes { @@ -509,27 +509,27 @@ func (ppq *PositionPermissionQuery) loadPermission(ctx context.Context, query *P return nil } -func (ppq *PositionPermissionQuery) sqlCount(ctx context.Context) (int, error) { - _spec := ppq.querySpec() - if len(ppq.modifiers) > 0 { - _spec.Modifiers = ppq.modifiers +func (_q *PositionPermissionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = ppq.ctx.Fields - if len(ppq.ctx.Fields) > 0 { - _spec.Unique = ppq.ctx.Unique != nil && *ppq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, ppq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (ppq *PositionPermissionQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *PositionPermissionQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(positionpermission.Table, positionpermission.Columns, sqlgraph.NewFieldSpec(positionpermission.FieldID, field.TypeInt)) - _spec.From = ppq.sql - if unique := ppq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if ppq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := ppq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, positionpermission.FieldID) for i := range fields { @@ -537,27 +537,27 @@ func (ppq *PositionPermissionQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if ppq.withPosition != nil { + if _q.withPosition != nil { _spec.Node.AddColumnOnce(positionpermission.FieldPositionID) } - if ppq.withPermission != nil { + if _q.withPermission != nil { _spec.Node.AddColumnOnce(positionpermission.FieldPermissionID) } } - if ps := ppq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := ppq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := ppq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := ppq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -567,36 +567,36 @@ func (ppq *PositionPermissionQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (ppq *PositionPermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(ppq.driver.Dialect()) +func (_q *PositionPermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(positionpermission.Table) - columns := ppq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = positionpermission.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if ppq.sql != nil { - selector = ppq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if ppq.ctx.Unique != nil && *ppq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range ppq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range ppq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range ppq.order { + for _, p := range _q.order { p(selector) } - if offset := ppq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := ppq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -605,33 +605,33 @@ func (ppq *PositionPermissionQuery) sqlQuery(ctx context.Context) *sql.Selector // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (ppq *PositionPermissionQuery) ForUpdate(opts ...sql.LockOption) *PositionPermissionQuery { - if ppq.driver.Dialect() == dialect.Postgres { - ppq.Unique(false) +func (_q *PositionPermissionQuery) ForUpdate(opts ...sql.LockOption) *PositionPermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - ppq.modifiers = append(ppq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return ppq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (ppq *PositionPermissionQuery) ForShare(opts ...sql.LockOption) *PositionPermissionQuery { - if ppq.driver.Dialect() == dialect.Postgres { - ppq.Unique(false) +func (_q *PositionPermissionQuery) ForShare(opts ...sql.LockOption) *PositionPermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - ppq.modifiers = append(ppq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return ppq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (ppq *PositionPermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *PositionPermissionSelect { - ppq.modifiers = append(ppq.modifiers, modifiers...) - return ppq.Select() +func (_q *PositionPermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *PositionPermissionSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -673,41 +673,41 @@ type PositionPermissionGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (ppgb *PositionPermissionGroupBy) Aggregate(fns ...AggregateFunc) *PositionPermissionGroupBy { - ppgb.fns = append(ppgb.fns, fns...) - return ppgb +func (_g *PositionPermissionGroupBy) Aggregate(fns ...AggregateFunc) *PositionPermissionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (ppgb *PositionPermissionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ppgb.build.ctx, ent.OpQueryGroupBy) - if err := ppgb.build.prepareQuery(ctx); err != nil { +func (_g *PositionPermissionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*PositionPermissionQuery, *PositionPermissionGroupBy](ctx, ppgb.build, ppgb, ppgb.build.inters, v) + return scanWithInterceptors[*PositionPermissionQuery, *PositionPermissionGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (ppgb *PositionPermissionGroupBy) sqlScan(ctx context.Context, root *PositionPermissionQuery, v any) error { +func (_g *PositionPermissionGroupBy) sqlScan(ctx context.Context, root *PositionPermissionQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(ppgb.fns)) - for _, fn := range ppgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*ppgb.flds)+len(ppgb.fns)) - for _, f := range *ppgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*ppgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := ppgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -721,27 +721,27 @@ type PositionPermissionSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (pps *PositionPermissionSelect) Aggregate(fns ...AggregateFunc) *PositionPermissionSelect { - pps.fns = append(pps.fns, fns...) - return pps +func (_s *PositionPermissionSelect) Aggregate(fns ...AggregateFunc) *PositionPermissionSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (pps *PositionPermissionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, pps.ctx, ent.OpQuerySelect) - if err := pps.prepareQuery(ctx); err != nil { +func (_s *PositionPermissionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*PositionPermissionQuery, *PositionPermissionSelect](ctx, pps.PositionPermissionQuery, pps, pps.inters, v) + return scanWithInterceptors[*PositionPermissionQuery, *PositionPermissionSelect](ctx, _s.PositionPermissionQuery, _s, _s.inters, v) } -func (pps *PositionPermissionSelect) sqlScan(ctx context.Context, root *PositionPermissionQuery, v any) error { +func (_s *PositionPermissionSelect) sqlScan(ctx context.Context, root *PositionPermissionQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(pps.fns)) - for _, fn := range pps.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*pps.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -749,7 +749,7 @@ func (pps *PositionPermissionSelect) sqlScan(ctx context.Context, root *Position } rows := &sql.Rows{} query, args := selector.Query() - if err := pps.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -757,7 +757,7 @@ func (pps *PositionPermissionSelect) sqlScan(ctx context.Context, root *Position } // Modify adds a query modifier for attaching custom logic to queries. -func (pps *PositionPermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *PositionPermissionSelect { - pps.modifiers = append(pps.modifiers, modifiers...) - return pps +func (_s *PositionPermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *PositionPermissionSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/positionpermission_update.go b/internal/data/entity/ent/positionpermission_update.go index 9da383d4..ba2b4c35 100644 --- a/internal/data/entity/ent/positionpermission_update.go +++ b/internal/data/entity/ent/positionpermission_update.go @@ -25,74 +25,74 @@ type PositionPermissionUpdate struct { } // Where appends a list predicates to the PositionPermissionUpdate builder. -func (ppu *PositionPermissionUpdate) Where(ps ...predicate.PositionPermission) *PositionPermissionUpdate { - ppu.mutation.Where(ps...) - return ppu +func (_u *PositionPermissionUpdate) Where(ps ...predicate.PositionPermission) *PositionPermissionUpdate { + _u.mutation.Where(ps...) + return _u } // SetPositionID sets the "position_id" field. -func (ppu *PositionPermissionUpdate) SetPositionID(i int64) *PositionPermissionUpdate { - ppu.mutation.SetPositionID(i) - return ppu +func (_u *PositionPermissionUpdate) SetPositionID(v int64) *PositionPermissionUpdate { + _u.mutation.SetPositionID(v) + return _u } // SetNillablePositionID sets the "position_id" field if the given value is not nil. -func (ppu *PositionPermissionUpdate) SetNillablePositionID(i *int64) *PositionPermissionUpdate { - if i != nil { - ppu.SetPositionID(*i) +func (_u *PositionPermissionUpdate) SetNillablePositionID(v *int64) *PositionPermissionUpdate { + if v != nil { + _u.SetPositionID(*v) } - return ppu + return _u } // SetPermissionID sets the "permission_id" field. -func (ppu *PositionPermissionUpdate) SetPermissionID(i int64) *PositionPermissionUpdate { - ppu.mutation.SetPermissionID(i) - return ppu +func (_u *PositionPermissionUpdate) SetPermissionID(v int64) *PositionPermissionUpdate { + _u.mutation.SetPermissionID(v) + return _u } // SetNillablePermissionID sets the "permission_id" field if the given value is not nil. -func (ppu *PositionPermissionUpdate) SetNillablePermissionID(i *int64) *PositionPermissionUpdate { - if i != nil { - ppu.SetPermissionID(*i) +func (_u *PositionPermissionUpdate) SetNillablePermissionID(v *int64) *PositionPermissionUpdate { + if v != nil { + _u.SetPermissionID(*v) } - return ppu + return _u } // SetPosition sets the "position" edge to the Position entity. -func (ppu *PositionPermissionUpdate) SetPosition(p *Position) *PositionPermissionUpdate { - return ppu.SetPositionID(p.ID) +func (_u *PositionPermissionUpdate) SetPosition(v *Position) *PositionPermissionUpdate { + return _u.SetPositionID(v.ID) } // SetPermission sets the "permission" edge to the Permission entity. -func (ppu *PositionPermissionUpdate) SetPermission(p *Permission) *PositionPermissionUpdate { - return ppu.SetPermissionID(p.ID) +func (_u *PositionPermissionUpdate) SetPermission(v *Permission) *PositionPermissionUpdate { + return _u.SetPermissionID(v.ID) } // Mutation returns the PositionPermissionMutation object of the builder. -func (ppu *PositionPermissionUpdate) Mutation() *PositionPermissionMutation { - return ppu.mutation +func (_u *PositionPermissionUpdate) Mutation() *PositionPermissionMutation { + return _u.mutation } // ClearPosition clears the "position" edge to the Position entity. -func (ppu *PositionPermissionUpdate) ClearPosition() *PositionPermissionUpdate { - ppu.mutation.ClearPosition() - return ppu +func (_u *PositionPermissionUpdate) ClearPosition() *PositionPermissionUpdate { + _u.mutation.ClearPosition() + return _u } // ClearPermission clears the "permission" edge to the Permission entity. -func (ppu *PositionPermissionUpdate) ClearPermission() *PositionPermissionUpdate { - ppu.mutation.ClearPermission() - return ppu +func (_u *PositionPermissionUpdate) ClearPermission() *PositionPermissionUpdate { + _u.mutation.ClearPermission() + return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (ppu *PositionPermissionUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, ppu.sqlSave, ppu.mutation, ppu.hooks) +func (_u *PositionPermissionUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (ppu *PositionPermissionUpdate) SaveX(ctx context.Context) int { - affected, err := ppu.Save(ctx) +func (_u *PositionPermissionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -100,58 +100,58 @@ func (ppu *PositionPermissionUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (ppu *PositionPermissionUpdate) Exec(ctx context.Context) error { - _, err := ppu.Save(ctx) +func (_u *PositionPermissionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ppu *PositionPermissionUpdate) ExecX(ctx context.Context) { - if err := ppu.Exec(ctx); err != nil { +func (_u *PositionPermissionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (ppu *PositionPermissionUpdate) check() error { - if v, ok := ppu.mutation.PositionID(); ok { +func (_u *PositionPermissionUpdate) check() error { + if v, ok := _u.mutation.PositionID(); ok { if err := positionpermission.PositionIDValidator(v); err != nil { return &ValidationError{Name: "position_id", err: fmt.Errorf(`ent: validator failed for field "PositionPermission.position_id": %w`, err)} } } - if v, ok := ppu.mutation.PermissionID(); ok { + if v, ok := _u.mutation.PermissionID(); ok { if err := positionpermission.PermissionIDValidator(v); err != nil { return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "PositionPermission.permission_id": %w`, err)} } } - if ppu.mutation.PositionCleared() && len(ppu.mutation.PositionIDs()) > 0 { + if _u.mutation.PositionCleared() && len(_u.mutation.PositionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "PositionPermission.position"`) } - if ppu.mutation.PermissionCleared() && len(ppu.mutation.PermissionIDs()) > 0 { + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "PositionPermission.permission"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (ppu *PositionPermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PositionPermissionUpdate { - ppu.modifiers = append(ppu.modifiers, modifiers...) - return ppu +func (_u *PositionPermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PositionPermissionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (ppu *PositionPermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := ppu.check(); err != nil { - return n, err +func (_u *PositionPermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(positionpermission.Table, positionpermission.Columns, sqlgraph.NewFieldSpec(positionpermission.FieldID, field.TypeInt)) - if ps := ppu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if ppu.mutation.PositionCleared() { + if _u.mutation.PositionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -164,7 +164,7 @@ func (ppu *PositionPermissionUpdate) sqlSave(ctx context.Context) (n int, err er } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ppu.mutation.PositionIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -180,7 +180,7 @@ func (ppu *PositionPermissionUpdate) sqlSave(ctx context.Context) (n int, err er } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ppu.mutation.PermissionCleared() { + if _u.mutation.PermissionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -193,7 +193,7 @@ func (ppu *PositionPermissionUpdate) sqlSave(ctx context.Context) (n int, err er } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ppu.mutation.PermissionIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -209,8 +209,8 @@ func (ppu *PositionPermissionUpdate) sqlSave(ctx context.Context) (n int, err er } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(ppu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, ppu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{positionpermission.Label} } else if sqlgraph.IsConstraintError(err) { @@ -218,8 +218,8 @@ func (ppu *PositionPermissionUpdate) sqlSave(ctx context.Context) (n int, err er } return 0, err } - ppu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // PositionPermissionUpdateOne is the builder for updating a single PositionPermission entity. @@ -232,81 +232,81 @@ type PositionPermissionUpdateOne struct { } // SetPositionID sets the "position_id" field. -func (ppuo *PositionPermissionUpdateOne) SetPositionID(i int64) *PositionPermissionUpdateOne { - ppuo.mutation.SetPositionID(i) - return ppuo +func (_u *PositionPermissionUpdateOne) SetPositionID(v int64) *PositionPermissionUpdateOne { + _u.mutation.SetPositionID(v) + return _u } // SetNillablePositionID sets the "position_id" field if the given value is not nil. -func (ppuo *PositionPermissionUpdateOne) SetNillablePositionID(i *int64) *PositionPermissionUpdateOne { - if i != nil { - ppuo.SetPositionID(*i) +func (_u *PositionPermissionUpdateOne) SetNillablePositionID(v *int64) *PositionPermissionUpdateOne { + if v != nil { + _u.SetPositionID(*v) } - return ppuo + return _u } // SetPermissionID sets the "permission_id" field. -func (ppuo *PositionPermissionUpdateOne) SetPermissionID(i int64) *PositionPermissionUpdateOne { - ppuo.mutation.SetPermissionID(i) - return ppuo +func (_u *PositionPermissionUpdateOne) SetPermissionID(v int64) *PositionPermissionUpdateOne { + _u.mutation.SetPermissionID(v) + return _u } // SetNillablePermissionID sets the "permission_id" field if the given value is not nil. -func (ppuo *PositionPermissionUpdateOne) SetNillablePermissionID(i *int64) *PositionPermissionUpdateOne { - if i != nil { - ppuo.SetPermissionID(*i) +func (_u *PositionPermissionUpdateOne) SetNillablePermissionID(v *int64) *PositionPermissionUpdateOne { + if v != nil { + _u.SetPermissionID(*v) } - return ppuo + return _u } // SetPosition sets the "position" edge to the Position entity. -func (ppuo *PositionPermissionUpdateOne) SetPosition(p *Position) *PositionPermissionUpdateOne { - return ppuo.SetPositionID(p.ID) +func (_u *PositionPermissionUpdateOne) SetPosition(v *Position) *PositionPermissionUpdateOne { + return _u.SetPositionID(v.ID) } // SetPermission sets the "permission" edge to the Permission entity. -func (ppuo *PositionPermissionUpdateOne) SetPermission(p *Permission) *PositionPermissionUpdateOne { - return ppuo.SetPermissionID(p.ID) +func (_u *PositionPermissionUpdateOne) SetPermission(v *Permission) *PositionPermissionUpdateOne { + return _u.SetPermissionID(v.ID) } // Mutation returns the PositionPermissionMutation object of the builder. -func (ppuo *PositionPermissionUpdateOne) Mutation() *PositionPermissionMutation { - return ppuo.mutation +func (_u *PositionPermissionUpdateOne) Mutation() *PositionPermissionMutation { + return _u.mutation } // ClearPosition clears the "position" edge to the Position entity. -func (ppuo *PositionPermissionUpdateOne) ClearPosition() *PositionPermissionUpdateOne { - ppuo.mutation.ClearPosition() - return ppuo +func (_u *PositionPermissionUpdateOne) ClearPosition() *PositionPermissionUpdateOne { + _u.mutation.ClearPosition() + return _u } // ClearPermission clears the "permission" edge to the Permission entity. -func (ppuo *PositionPermissionUpdateOne) ClearPermission() *PositionPermissionUpdateOne { - ppuo.mutation.ClearPermission() - return ppuo +func (_u *PositionPermissionUpdateOne) ClearPermission() *PositionPermissionUpdateOne { + _u.mutation.ClearPermission() + return _u } // Where appends a list predicates to the PositionPermissionUpdate builder. -func (ppuo *PositionPermissionUpdateOne) Where(ps ...predicate.PositionPermission) *PositionPermissionUpdateOne { - ppuo.mutation.Where(ps...) - return ppuo +func (_u *PositionPermissionUpdateOne) Where(ps ...predicate.PositionPermission) *PositionPermissionUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (ppuo *PositionPermissionUpdateOne) Select(field string, fields ...string) *PositionPermissionUpdateOne { - ppuo.fields = append([]string{field}, fields...) - return ppuo +func (_u *PositionPermissionUpdateOne) Select(field string, fields ...string) *PositionPermissionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated PositionPermission entity. -func (ppuo *PositionPermissionUpdateOne) Save(ctx context.Context) (*PositionPermission, error) { - return withHooks(ctx, ppuo.sqlSave, ppuo.mutation, ppuo.hooks) +func (_u *PositionPermissionUpdateOne) Save(ctx context.Context) (*PositionPermission, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (ppuo *PositionPermissionUpdateOne) SaveX(ctx context.Context) *PositionPermission { - node, err := ppuo.Save(ctx) +func (_u *PositionPermissionUpdateOne) SaveX(ctx context.Context) *PositionPermission { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -314,56 +314,56 @@ func (ppuo *PositionPermissionUpdateOne) SaveX(ctx context.Context) *PositionPer } // Exec executes the query on the entity. -func (ppuo *PositionPermissionUpdateOne) Exec(ctx context.Context) error { - _, err := ppuo.Save(ctx) +func (_u *PositionPermissionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ppuo *PositionPermissionUpdateOne) ExecX(ctx context.Context) { - if err := ppuo.Exec(ctx); err != nil { +func (_u *PositionPermissionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (ppuo *PositionPermissionUpdateOne) check() error { - if v, ok := ppuo.mutation.PositionID(); ok { +func (_u *PositionPermissionUpdateOne) check() error { + if v, ok := _u.mutation.PositionID(); ok { if err := positionpermission.PositionIDValidator(v); err != nil { return &ValidationError{Name: "position_id", err: fmt.Errorf(`ent: validator failed for field "PositionPermission.position_id": %w`, err)} } } - if v, ok := ppuo.mutation.PermissionID(); ok { + if v, ok := _u.mutation.PermissionID(); ok { if err := positionpermission.PermissionIDValidator(v); err != nil { return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "PositionPermission.permission_id": %w`, err)} } } - if ppuo.mutation.PositionCleared() && len(ppuo.mutation.PositionIDs()) > 0 { + if _u.mutation.PositionCleared() && len(_u.mutation.PositionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "PositionPermission.position"`) } - if ppuo.mutation.PermissionCleared() && len(ppuo.mutation.PermissionIDs()) > 0 { + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "PositionPermission.permission"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (ppuo *PositionPermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PositionPermissionUpdateOne { - ppuo.modifiers = append(ppuo.modifiers, modifiers...) - return ppuo +func (_u *PositionPermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PositionPermissionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (ppuo *PositionPermissionUpdateOne) sqlSave(ctx context.Context) (_node *PositionPermission, err error) { - if err := ppuo.check(); err != nil { +func (_u *PositionPermissionUpdateOne) sqlSave(ctx context.Context) (_node *PositionPermission, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(positionpermission.Table, positionpermission.Columns, sqlgraph.NewFieldSpec(positionpermission.FieldID, field.TypeInt)) - id, ok := ppuo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PositionPermission.id" for update`)} } _spec.Node.ID.Value = id - if fields := ppuo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, positionpermission.FieldID) for _, f := range fields { @@ -375,14 +375,14 @@ func (ppuo *PositionPermissionUpdateOne) sqlSave(ctx context.Context) (_node *Po } } } - if ps := ppuo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if ppuo.mutation.PositionCleared() { + if _u.mutation.PositionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -395,7 +395,7 @@ func (ppuo *PositionPermissionUpdateOne) sqlSave(ctx context.Context) (_node *Po } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ppuo.mutation.PositionIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -411,7 +411,7 @@ func (ppuo *PositionPermissionUpdateOne) sqlSave(ctx context.Context) (_node *Po } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ppuo.mutation.PermissionCleared() { + if _u.mutation.PermissionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -424,7 +424,7 @@ func (ppuo *PositionPermissionUpdateOne) sqlSave(ctx context.Context) (_node *Po } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ppuo.mutation.PermissionIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -440,11 +440,11 @@ func (ppuo *PositionPermissionUpdateOne) sqlSave(ctx context.Context) (_node *Po } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(ppuo.modifiers...) - _node = &PositionPermission{config: ppuo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &PositionPermission{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, ppuo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{positionpermission.Label} } else if sqlgraph.IsConstraintError(err) { @@ -452,7 +452,7 @@ func (ppuo *PositionPermissionUpdateOne) sqlSave(ctx context.Context) (_node *Po } return nil, err } - ppuo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/resource.go b/internal/data/entity/ent/resource.go index 5fc39ce6..37f78e8c 100644 --- a/internal/data/entity/ent/resource.go +++ b/internal/data/entity/ent/resource.go @@ -140,7 +140,7 @@ func (*Resource) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Resource fields. -func (r *Resource) assignValues(columns []string, values []any) error { +func (_m *Resource) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -151,108 +151,108 @@ func (r *Resource) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - r.ID = int64(value.Int64) + _m.ID = int64(value.Int64) case resource.FieldCreateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field create_time", values[i]) } else if value.Valid { - r.CreateTime = value.Time + _m.CreateTime = value.Time } case resource.FieldUpdateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field update_time", values[i]) } else if value.Valid { - r.UpdateTime = value.Time + _m.UpdateTime = value.Time } case resource.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { - r.Name = value.String + _m.Name = value.String } case resource.FieldKeyword: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field keyword", values[i]) } else if value.Valid { - r.Keyword = value.String + _m.Keyword = value.String } case resource.FieldI18nKey: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field i18n_key", values[i]) } else if value.Valid { - r.I18nKey = value.String + _m.I18nKey = value.String } case resource.FieldType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) } else if value.Valid { - r.Type = value.String + _m.Type = value.String } case resource.FieldStatus: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - r.Status = int8(value.Int64) + _m.Status = int8(value.Int64) } case resource.FieldPath: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field path", values[i]) } else if value.Valid { - r.Path = value.String + _m.Path = value.String } case resource.FieldOperation: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field operation", values[i]) } else if value.Valid { - r.Operation = value.String + _m.Operation = value.String } case resource.FieldMethod: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field method", values[i]) } else if value.Valid { - r.Method = value.String + _m.Method = value.String } case resource.FieldComponent: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field component", values[i]) } else if value.Valid { - r.Component = value.String + _m.Component = value.String } case resource.FieldIcon: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field icon", values[i]) } else if value.Valid { - r.Icon = value.String + _m.Icon = value.String } case resource.FieldSequence: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field sequence", values[i]) } else if value.Valid { - r.Sequence = int(value.Int64) + _m.Sequence = int(value.Int64) } case resource.FieldVisible: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field visible", values[i]) } else if value.Valid { - r.Visible = value.Bool + _m.Visible = value.Bool } case resource.FieldLevel: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field level", values[i]) } else if value.Valid { - r.Level = int8(value.Int64) + _m.Level = int8(value.Int64) } case resource.FieldTreePath: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field tree_path", values[i]) } else if value.Valid { - r.TreePath = value.String + _m.TreePath = value.String } case resource.FieldProperties: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field properties", values[i]) } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &r.Properties); err != nil { + if err := json.Unmarshal(*value, &_m.Properties); err != nil { return fmt.Errorf("unmarshal field properties: %w", err) } } @@ -260,16 +260,16 @@ func (r *Resource) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field description", values[i]) } else if value.Valid { - r.Description = value.String + _m.Description = value.String } case resource.FieldParentID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field parent_id", values[i]) } else if value.Valid { - r.ParentID = value.Int64 + _m.ParentID = value.Int64 } default: - r.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -277,109 +277,109 @@ func (r *Resource) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Resource. // This includes values selected through modifiers, order, etc. -func (r *Resource) Value(name string) (ent.Value, error) { - return r.selectValues.Get(name) +func (_m *Resource) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryChildren queries the "children" edge of the Resource entity. -func (r *Resource) QueryChildren() *ResourceQuery { - return NewResourceClient(r.config).QueryChildren(r) +func (_m *Resource) QueryChildren() *ResourceQuery { + return NewResourceClient(_m.config).QueryChildren(_m) } // QueryParent queries the "parent" edge of the Resource entity. -func (r *Resource) QueryParent() *ResourceQuery { - return NewResourceClient(r.config).QueryParent(r) +func (_m *Resource) QueryParent() *ResourceQuery { + return NewResourceClient(_m.config).QueryParent(_m) } // QueryPermissions queries the "permissions" edge of the Resource entity. -func (r *Resource) QueryPermissions() *PermissionQuery { - return NewResourceClient(r.config).QueryPermissions(r) +func (_m *Resource) QueryPermissions() *PermissionQuery { + return NewResourceClient(_m.config).QueryPermissions(_m) } // QueryPermissionResources queries the "permission_resources" edge of the Resource entity. -func (r *Resource) QueryPermissionResources() *PermissionResourceQuery { - return NewResourceClient(r.config).QueryPermissionResources(r) +func (_m *Resource) QueryPermissionResources() *PermissionResourceQuery { + return NewResourceClient(_m.config).QueryPermissionResources(_m) } // Update returns a builder for updating this Resource. // Note that you need to call Resource.Unwrap() before calling this method if this Resource // was returned from a transaction, and the transaction was committed or rolled back. -func (r *Resource) Update() *ResourceUpdateOne { - return NewResourceClient(r.config).UpdateOne(r) +func (_m *Resource) Update() *ResourceUpdateOne { + return NewResourceClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Resource entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (r *Resource) Unwrap() *Resource { - _tx, ok := r.config.driver.(*txDriver) +func (_m *Resource) Unwrap() *Resource { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Resource is not a transactional entity") } - r.config.driver = _tx.drv - return r + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (r *Resource) String() string { +func (_m *Resource) String() string { var builder strings.Builder builder.WriteString("Resource(") - builder.WriteString(fmt.Sprintf("id=%v, ", r.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("create_time=") - builder.WriteString(r.CreateTime.Format(time.ANSIC)) + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("update_time=") - builder.WriteString(r.UpdateTime.Format(time.ANSIC)) + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("name=") - builder.WriteString(r.Name) + builder.WriteString(_m.Name) builder.WriteString(", ") builder.WriteString("keyword=") - builder.WriteString(r.Keyword) + builder.WriteString(_m.Keyword) builder.WriteString(", ") builder.WriteString("i18n_key=") - builder.WriteString(r.I18nKey) + builder.WriteString(_m.I18nKey) builder.WriteString(", ") builder.WriteString("type=") - builder.WriteString(r.Type) + builder.WriteString(_m.Type) builder.WriteString(", ") builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", r.Status)) + builder.WriteString(fmt.Sprintf("%v", _m.Status)) builder.WriteString(", ") builder.WriteString("path=") - builder.WriteString(r.Path) + builder.WriteString(_m.Path) builder.WriteString(", ") builder.WriteString("operation=") - builder.WriteString(r.Operation) + builder.WriteString(_m.Operation) builder.WriteString(", ") builder.WriteString("method=") - builder.WriteString(r.Method) + builder.WriteString(_m.Method) builder.WriteString(", ") builder.WriteString("component=") - builder.WriteString(r.Component) + builder.WriteString(_m.Component) builder.WriteString(", ") builder.WriteString("icon=") - builder.WriteString(r.Icon) + builder.WriteString(_m.Icon) builder.WriteString(", ") builder.WriteString("sequence=") - builder.WriteString(fmt.Sprintf("%v", r.Sequence)) + builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) builder.WriteString(", ") builder.WriteString("visible=") - builder.WriteString(fmt.Sprintf("%v", r.Visible)) + builder.WriteString(fmt.Sprintf("%v", _m.Visible)) builder.WriteString(", ") builder.WriteString("level=") - builder.WriteString(fmt.Sprintf("%v", r.Level)) + builder.WriteString(fmt.Sprintf("%v", _m.Level)) builder.WriteString(", ") builder.WriteString("tree_path=") - builder.WriteString(r.TreePath) + builder.WriteString(_m.TreePath) builder.WriteString(", ") builder.WriteString("properties=") - builder.WriteString(fmt.Sprintf("%v", r.Properties)) + builder.WriteString(fmt.Sprintf("%v", _m.Properties)) builder.WriteString(", ") builder.WriteString("description=") - builder.WriteString(r.Description) + builder.WriteString(_m.Description) builder.WriteString(", ") builder.WriteString("parent_id=") - builder.WriteString(fmt.Sprintf("%v", r.ParentID)) + builder.WriteString(fmt.Sprintf("%v", _m.ParentID)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/resource_create.go b/internal/data/entity/ent/resource_create.go index 243b139a..203a26fd 100644 --- a/internal/data/entity/ent/resource_create.go +++ b/internal/data/entity/ent/resource_create.go @@ -23,333 +23,333 @@ type ResourceCreate struct { } // SetCreateTime sets the "create_time" field. -func (rc *ResourceCreate) SetCreateTime(t time.Time) *ResourceCreate { - rc.mutation.SetCreateTime(t) - return rc +func (_c *ResourceCreate) SetCreateTime(v time.Time) *ResourceCreate { + _c.mutation.SetCreateTime(v) + return _c } // SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableCreateTime(t *time.Time) *ResourceCreate { - if t != nil { - rc.SetCreateTime(*t) +func (_c *ResourceCreate) SetNillableCreateTime(v *time.Time) *ResourceCreate { + if v != nil { + _c.SetCreateTime(*v) } - return rc + return _c } // SetUpdateTime sets the "update_time" field. -func (rc *ResourceCreate) SetUpdateTime(t time.Time) *ResourceCreate { - rc.mutation.SetUpdateTime(t) - return rc +func (_c *ResourceCreate) SetUpdateTime(v time.Time) *ResourceCreate { + _c.mutation.SetUpdateTime(v) + return _c } // SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableUpdateTime(t *time.Time) *ResourceCreate { - if t != nil { - rc.SetUpdateTime(*t) +func (_c *ResourceCreate) SetNillableUpdateTime(v *time.Time) *ResourceCreate { + if v != nil { + _c.SetUpdateTime(*v) } - return rc + return _c } // SetName sets the "name" field. -func (rc *ResourceCreate) SetName(s string) *ResourceCreate { - rc.mutation.SetName(s) - return rc +func (_c *ResourceCreate) SetName(v string) *ResourceCreate { + _c.mutation.SetName(v) + return _c } // SetNillableName sets the "name" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableName(s *string) *ResourceCreate { - if s != nil { - rc.SetName(*s) +func (_c *ResourceCreate) SetNillableName(v *string) *ResourceCreate { + if v != nil { + _c.SetName(*v) } - return rc + return _c } // SetKeyword sets the "keyword" field. -func (rc *ResourceCreate) SetKeyword(s string) *ResourceCreate { - rc.mutation.SetKeyword(s) - return rc +func (_c *ResourceCreate) SetKeyword(v string) *ResourceCreate { + _c.mutation.SetKeyword(v) + return _c } // SetI18nKey sets the "i18n_key" field. -func (rc *ResourceCreate) SetI18nKey(s string) *ResourceCreate { - rc.mutation.SetI18nKey(s) - return rc +func (_c *ResourceCreate) SetI18nKey(v string) *ResourceCreate { + _c.mutation.SetI18nKey(v) + return _c } // SetNillableI18nKey sets the "i18n_key" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableI18nKey(s *string) *ResourceCreate { - if s != nil { - rc.SetI18nKey(*s) +func (_c *ResourceCreate) SetNillableI18nKey(v *string) *ResourceCreate { + if v != nil { + _c.SetI18nKey(*v) } - return rc + return _c } // SetType sets the "type" field. -func (rc *ResourceCreate) SetType(s string) *ResourceCreate { - rc.mutation.SetType(s) - return rc +func (_c *ResourceCreate) SetType(v string) *ResourceCreate { + _c.mutation.SetType(v) + return _c } // SetNillableType sets the "type" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableType(s *string) *ResourceCreate { - if s != nil { - rc.SetType(*s) +func (_c *ResourceCreate) SetNillableType(v *string) *ResourceCreate { + if v != nil { + _c.SetType(*v) } - return rc + return _c } // SetStatus sets the "status" field. -func (rc *ResourceCreate) SetStatus(i int8) *ResourceCreate { - rc.mutation.SetStatus(i) - return rc +func (_c *ResourceCreate) SetStatus(v int8) *ResourceCreate { + _c.mutation.SetStatus(v) + return _c } // SetNillableStatus sets the "status" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableStatus(i *int8) *ResourceCreate { - if i != nil { - rc.SetStatus(*i) +func (_c *ResourceCreate) SetNillableStatus(v *int8) *ResourceCreate { + if v != nil { + _c.SetStatus(*v) } - return rc + return _c } // SetPath sets the "path" field. -func (rc *ResourceCreate) SetPath(s string) *ResourceCreate { - rc.mutation.SetPath(s) - return rc +func (_c *ResourceCreate) SetPath(v string) *ResourceCreate { + _c.mutation.SetPath(v) + return _c } // SetNillablePath sets the "path" field if the given value is not nil. -func (rc *ResourceCreate) SetNillablePath(s *string) *ResourceCreate { - if s != nil { - rc.SetPath(*s) +func (_c *ResourceCreate) SetNillablePath(v *string) *ResourceCreate { + if v != nil { + _c.SetPath(*v) } - return rc + return _c } // SetOperation sets the "operation" field. -func (rc *ResourceCreate) SetOperation(s string) *ResourceCreate { - rc.mutation.SetOperation(s) - return rc +func (_c *ResourceCreate) SetOperation(v string) *ResourceCreate { + _c.mutation.SetOperation(v) + return _c } // SetNillableOperation sets the "operation" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableOperation(s *string) *ResourceCreate { - if s != nil { - rc.SetOperation(*s) +func (_c *ResourceCreate) SetNillableOperation(v *string) *ResourceCreate { + if v != nil { + _c.SetOperation(*v) } - return rc + return _c } // SetMethod sets the "method" field. -func (rc *ResourceCreate) SetMethod(s string) *ResourceCreate { - rc.mutation.SetMethod(s) - return rc +func (_c *ResourceCreate) SetMethod(v string) *ResourceCreate { + _c.mutation.SetMethod(v) + return _c } // SetNillableMethod sets the "method" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableMethod(s *string) *ResourceCreate { - if s != nil { - rc.SetMethod(*s) +func (_c *ResourceCreate) SetNillableMethod(v *string) *ResourceCreate { + if v != nil { + _c.SetMethod(*v) } - return rc + return _c } // SetComponent sets the "component" field. -func (rc *ResourceCreate) SetComponent(s string) *ResourceCreate { - rc.mutation.SetComponent(s) - return rc +func (_c *ResourceCreate) SetComponent(v string) *ResourceCreate { + _c.mutation.SetComponent(v) + return _c } // SetNillableComponent sets the "component" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableComponent(s *string) *ResourceCreate { - if s != nil { - rc.SetComponent(*s) +func (_c *ResourceCreate) SetNillableComponent(v *string) *ResourceCreate { + if v != nil { + _c.SetComponent(*v) } - return rc + return _c } // SetIcon sets the "icon" field. -func (rc *ResourceCreate) SetIcon(s string) *ResourceCreate { - rc.mutation.SetIcon(s) - return rc +func (_c *ResourceCreate) SetIcon(v string) *ResourceCreate { + _c.mutation.SetIcon(v) + return _c } // SetNillableIcon sets the "icon" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableIcon(s *string) *ResourceCreate { - if s != nil { - rc.SetIcon(*s) +func (_c *ResourceCreate) SetNillableIcon(v *string) *ResourceCreate { + if v != nil { + _c.SetIcon(*v) } - return rc + return _c } // SetSequence sets the "sequence" field. -func (rc *ResourceCreate) SetSequence(i int) *ResourceCreate { - rc.mutation.SetSequence(i) - return rc +func (_c *ResourceCreate) SetSequence(v int) *ResourceCreate { + _c.mutation.SetSequence(v) + return _c } // SetNillableSequence sets the "sequence" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableSequence(i *int) *ResourceCreate { - if i != nil { - rc.SetSequence(*i) +func (_c *ResourceCreate) SetNillableSequence(v *int) *ResourceCreate { + if v != nil { + _c.SetSequence(*v) } - return rc + return _c } // SetVisible sets the "visible" field. -func (rc *ResourceCreate) SetVisible(b bool) *ResourceCreate { - rc.mutation.SetVisible(b) - return rc +func (_c *ResourceCreate) SetVisible(v bool) *ResourceCreate { + _c.mutation.SetVisible(v) + return _c } // SetNillableVisible sets the "visible" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableVisible(b *bool) *ResourceCreate { - if b != nil { - rc.SetVisible(*b) +func (_c *ResourceCreate) SetNillableVisible(v *bool) *ResourceCreate { + if v != nil { + _c.SetVisible(*v) } - return rc + return _c } // SetLevel sets the "level" field. -func (rc *ResourceCreate) SetLevel(i int8) *ResourceCreate { - rc.mutation.SetLevel(i) - return rc +func (_c *ResourceCreate) SetLevel(v int8) *ResourceCreate { + _c.mutation.SetLevel(v) + return _c } // SetNillableLevel sets the "level" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableLevel(i *int8) *ResourceCreate { - if i != nil { - rc.SetLevel(*i) +func (_c *ResourceCreate) SetNillableLevel(v *int8) *ResourceCreate { + if v != nil { + _c.SetLevel(*v) } - return rc + return _c } // SetTreePath sets the "tree_path" field. -func (rc *ResourceCreate) SetTreePath(s string) *ResourceCreate { - rc.mutation.SetTreePath(s) - return rc +func (_c *ResourceCreate) SetTreePath(v string) *ResourceCreate { + _c.mutation.SetTreePath(v) + return _c } // SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableTreePath(s *string) *ResourceCreate { - if s != nil { - rc.SetTreePath(*s) +func (_c *ResourceCreate) SetNillableTreePath(v *string) *ResourceCreate { + if v != nil { + _c.SetTreePath(*v) } - return rc + return _c } // SetProperties sets the "properties" field. -func (rc *ResourceCreate) SetProperties(m map[string]string) *ResourceCreate { - rc.mutation.SetProperties(m) - return rc +func (_c *ResourceCreate) SetProperties(v map[string]string) *ResourceCreate { + _c.mutation.SetProperties(v) + return _c } // SetDescription sets the "description" field. -func (rc *ResourceCreate) SetDescription(s string) *ResourceCreate { - rc.mutation.SetDescription(s) - return rc +func (_c *ResourceCreate) SetDescription(v string) *ResourceCreate { + _c.mutation.SetDescription(v) + return _c } // SetNillableDescription sets the "description" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableDescription(s *string) *ResourceCreate { - if s != nil { - rc.SetDescription(*s) +func (_c *ResourceCreate) SetNillableDescription(v *string) *ResourceCreate { + if v != nil { + _c.SetDescription(*v) } - return rc + return _c } // SetParentID sets the "parent_id" field. -func (rc *ResourceCreate) SetParentID(i int64) *ResourceCreate { - rc.mutation.SetParentID(i) - return rc +func (_c *ResourceCreate) SetParentID(v int64) *ResourceCreate { + _c.mutation.SetParentID(v) + return _c } // SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableParentID(i *int64) *ResourceCreate { - if i != nil { - rc.SetParentID(*i) +func (_c *ResourceCreate) SetNillableParentID(v *int64) *ResourceCreate { + if v != nil { + _c.SetParentID(*v) } - return rc + return _c } // SetID sets the "id" field. -func (rc *ResourceCreate) SetID(i int64) *ResourceCreate { - rc.mutation.SetID(i) - return rc +func (_c *ResourceCreate) SetID(v int64) *ResourceCreate { + _c.mutation.SetID(v) + return _c } // SetNillableID sets the "id" field if the given value is not nil. -func (rc *ResourceCreate) SetNillableID(i *int64) *ResourceCreate { - if i != nil { - rc.SetID(*i) +func (_c *ResourceCreate) SetNillableID(v *int64) *ResourceCreate { + if v != nil { + _c.SetID(*v) } - return rc + return _c } // AddChildIDs adds the "children" edge to the Resource entity by IDs. -func (rc *ResourceCreate) AddChildIDs(ids ...int64) *ResourceCreate { - rc.mutation.AddChildIDs(ids...) - return rc +func (_c *ResourceCreate) AddChildIDs(ids ...int64) *ResourceCreate { + _c.mutation.AddChildIDs(ids...) + return _c } // AddChildren adds the "children" edges to the Resource entity. -func (rc *ResourceCreate) AddChildren(r ...*Resource) *ResourceCreate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_c *ResourceCreate) AddChildren(v ...*Resource) *ResourceCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return rc.AddChildIDs(ids...) + return _c.AddChildIDs(ids...) } // SetParent sets the "parent" edge to the Resource entity. -func (rc *ResourceCreate) SetParent(r *Resource) *ResourceCreate { - return rc.SetParentID(r.ID) +func (_c *ResourceCreate) SetParent(v *Resource) *ResourceCreate { + return _c.SetParentID(v.ID) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (rc *ResourceCreate) AddPermissionIDs(ids ...int64) *ResourceCreate { - rc.mutation.AddPermissionIDs(ids...) - return rc +func (_c *ResourceCreate) AddPermissionIDs(ids ...int64) *ResourceCreate { + _c.mutation.AddPermissionIDs(ids...) + return _c } // AddPermissions adds the "permissions" edges to the Permission entity. -func (rc *ResourceCreate) AddPermissions(p ...*Permission) *ResourceCreate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *ResourceCreate) AddPermissions(v ...*Permission) *ResourceCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return rc.AddPermissionIDs(ids...) + return _c.AddPermissionIDs(ids...) } // AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (rc *ResourceCreate) AddPermissionResourceIDs(ids ...int) *ResourceCreate { - rc.mutation.AddPermissionResourceIDs(ids...) - return rc +func (_c *ResourceCreate) AddPermissionResourceIDs(ids ...int) *ResourceCreate { + _c.mutation.AddPermissionResourceIDs(ids...) + return _c } // AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (rc *ResourceCreate) AddPermissionResources(p ...*PermissionResource) *ResourceCreate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *ResourceCreate) AddPermissionResources(v ...*PermissionResource) *ResourceCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return rc.AddPermissionResourceIDs(ids...) + return _c.AddPermissionResourceIDs(ids...) } // Mutation returns the ResourceMutation object of the builder. -func (rc *ResourceCreate) Mutation() *ResourceMutation { - return rc.mutation +func (_c *ResourceCreate) Mutation() *ResourceMutation { + return _c.mutation } // Save creates the Resource in the database. -func (rc *ResourceCreate) Save(ctx context.Context) (*Resource, error) { - rc.defaults() - return withHooks(ctx, rc.sqlSave, rc.mutation, rc.hooks) +func (_c *ResourceCreate) Save(ctx context.Context) (*Resource, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (rc *ResourceCreate) SaveX(ctx context.Context) *Resource { - v, err := rc.Save(ctx) +func (_c *ResourceCreate) SaveX(ctx context.Context) *Resource { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -357,204 +357,204 @@ func (rc *ResourceCreate) SaveX(ctx context.Context) *Resource { } // Exec executes the query. -func (rc *ResourceCreate) Exec(ctx context.Context) error { - _, err := rc.Save(ctx) +func (_c *ResourceCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rc *ResourceCreate) ExecX(ctx context.Context) { - if err := rc.Exec(ctx); err != nil { +func (_c *ResourceCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (rc *ResourceCreate) defaults() { - if _, ok := rc.mutation.CreateTime(); !ok { +func (_c *ResourceCreate) defaults() { + if _, ok := _c.mutation.CreateTime(); !ok { v := resource.DefaultCreateTime() - rc.mutation.SetCreateTime(v) + _c.mutation.SetCreateTime(v) } - if _, ok := rc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { v := resource.DefaultUpdateTime() - rc.mutation.SetUpdateTime(v) + _c.mutation.SetUpdateTime(v) } - if _, ok := rc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { v := resource.DefaultName - rc.mutation.SetName(v) + _c.mutation.SetName(v) } - if _, ok := rc.mutation.I18nKey(); !ok { + if _, ok := _c.mutation.I18nKey(); !ok { v := resource.DefaultI18nKey - rc.mutation.SetI18nKey(v) + _c.mutation.SetI18nKey(v) } - if _, ok := rc.mutation.GetType(); !ok { + if _, ok := _c.mutation.GetType(); !ok { v := resource.DefaultType - rc.mutation.SetType(v) + _c.mutation.SetType(v) } - if _, ok := rc.mutation.Status(); !ok { + if _, ok := _c.mutation.Status(); !ok { v := resource.DefaultStatus - rc.mutation.SetStatus(v) + _c.mutation.SetStatus(v) } - if _, ok := rc.mutation.Path(); !ok { + if _, ok := _c.mutation.Path(); !ok { v := resource.DefaultPath - rc.mutation.SetPath(v) + _c.mutation.SetPath(v) } - if _, ok := rc.mutation.Operation(); !ok { + if _, ok := _c.mutation.Operation(); !ok { v := resource.DefaultOperation - rc.mutation.SetOperation(v) + _c.mutation.SetOperation(v) } - if _, ok := rc.mutation.Method(); !ok { + if _, ok := _c.mutation.Method(); !ok { v := resource.DefaultMethod - rc.mutation.SetMethod(v) + _c.mutation.SetMethod(v) } - if _, ok := rc.mutation.Component(); !ok { + if _, ok := _c.mutation.Component(); !ok { v := resource.DefaultComponent - rc.mutation.SetComponent(v) + _c.mutation.SetComponent(v) } - if _, ok := rc.mutation.Icon(); !ok { + if _, ok := _c.mutation.Icon(); !ok { v := resource.DefaultIcon - rc.mutation.SetIcon(v) + _c.mutation.SetIcon(v) } - if _, ok := rc.mutation.Sequence(); !ok { + if _, ok := _c.mutation.Sequence(); !ok { v := resource.DefaultSequence - rc.mutation.SetSequence(v) + _c.mutation.SetSequence(v) } - if _, ok := rc.mutation.Visible(); !ok { + if _, ok := _c.mutation.Visible(); !ok { v := resource.DefaultVisible - rc.mutation.SetVisible(v) + _c.mutation.SetVisible(v) } - if _, ok := rc.mutation.Level(); !ok { + if _, ok := _c.mutation.Level(); !ok { v := resource.DefaultLevel - rc.mutation.SetLevel(v) + _c.mutation.SetLevel(v) } - if _, ok := rc.mutation.TreePath(); !ok { + if _, ok := _c.mutation.TreePath(); !ok { v := resource.DefaultTreePath - rc.mutation.SetTreePath(v) + _c.mutation.SetTreePath(v) } - if _, ok := rc.mutation.Description(); !ok { + if _, ok := _c.mutation.Description(); !ok { v := resource.DefaultDescription - rc.mutation.SetDescription(v) + _c.mutation.SetDescription(v) } - if _, ok := rc.mutation.ID(); !ok { + if _, ok := _c.mutation.ID(); !ok { v := resource.DefaultID() - rc.mutation.SetID(v) + _c.mutation.SetID(v) } } // check runs all checks and user-defined validators on the builder. -func (rc *ResourceCreate) check() error { - if _, ok := rc.mutation.CreateTime(); !ok { +func (_c *ResourceCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Resource.create_time"`)} } - if _, ok := rc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Resource.update_time"`)} } - if _, ok := rc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Resource.name"`)} } - if v, ok := rc.mutation.Name(); ok { + if v, ok := _c.mutation.Name(); ok { if err := resource.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} } } - if _, ok := rc.mutation.Keyword(); !ok { + if _, ok := _c.mutation.Keyword(); !ok { return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Resource.keyword"`)} } - if v, ok := rc.mutation.Keyword(); ok { + if v, ok := _c.mutation.Keyword(); ok { if err := resource.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} } } - if _, ok := rc.mutation.I18nKey(); !ok { + if _, ok := _c.mutation.I18nKey(); !ok { return &ValidationError{Name: "i18n_key", err: errors.New(`ent: missing required field "Resource.i18n_key"`)} } - if v, ok := rc.mutation.I18nKey(); ok { + if v, ok := _c.mutation.I18nKey(); ok { if err := resource.I18nKeyValidator(v); err != nil { return &ValidationError{Name: "i18n_key", err: fmt.Errorf(`ent: validator failed for field "Resource.i18n_key": %w`, err)} } } - if _, ok := rc.mutation.GetType(); !ok { + if _, ok := _c.mutation.GetType(); !ok { return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Resource.type"`)} } - if v, ok := rc.mutation.GetType(); ok { + if v, ok := _c.mutation.GetType(); ok { if err := resource.TypeValidator(v); err != nil { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} } } - if _, ok := rc.mutation.Status(); !ok { + if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Resource.status"`)} } - if _, ok := rc.mutation.Path(); !ok { + if _, ok := _c.mutation.Path(); !ok { return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "Resource.path"`)} } - if v, ok := rc.mutation.Path(); ok { + if v, ok := _c.mutation.Path(); ok { if err := resource.PathValidator(v); err != nil { return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} } } - if _, ok := rc.mutation.Operation(); !ok { + if _, ok := _c.mutation.Operation(); !ok { return &ValidationError{Name: "operation", err: errors.New(`ent: missing required field "Resource.operation"`)} } - if v, ok := rc.mutation.Operation(); ok { + if v, ok := _c.mutation.Operation(); ok { if err := resource.OperationValidator(v); err != nil { return &ValidationError{Name: "operation", err: fmt.Errorf(`ent: validator failed for field "Resource.operation": %w`, err)} } } - if _, ok := rc.mutation.Method(); !ok { + if _, ok := _c.mutation.Method(); !ok { return &ValidationError{Name: "method", err: errors.New(`ent: missing required field "Resource.method"`)} } - if v, ok := rc.mutation.Method(); ok { + if v, ok := _c.mutation.Method(); ok { if err := resource.MethodValidator(v); err != nil { return &ValidationError{Name: "method", err: fmt.Errorf(`ent: validator failed for field "Resource.method": %w`, err)} } } - if _, ok := rc.mutation.Component(); !ok { + if _, ok := _c.mutation.Component(); !ok { return &ValidationError{Name: "component", err: errors.New(`ent: missing required field "Resource.component"`)} } - if v, ok := rc.mutation.Component(); ok { + if v, ok := _c.mutation.Component(); ok { if err := resource.ComponentValidator(v); err != nil { return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} } } - if _, ok := rc.mutation.Icon(); !ok { + if _, ok := _c.mutation.Icon(); !ok { return &ValidationError{Name: "icon", err: errors.New(`ent: missing required field "Resource.icon"`)} } - if v, ok := rc.mutation.Icon(); ok { + if v, ok := _c.mutation.Icon(); ok { if err := resource.IconValidator(v); err != nil { return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} } } - if _, ok := rc.mutation.Sequence(); !ok { + if _, ok := _c.mutation.Sequence(); !ok { return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "Resource.sequence"`)} } - if _, ok := rc.mutation.Visible(); !ok { + if _, ok := _c.mutation.Visible(); !ok { return &ValidationError{Name: "visible", err: errors.New(`ent: missing required field "Resource.visible"`)} } - if _, ok := rc.mutation.Level(); !ok { + if _, ok := _c.mutation.Level(); !ok { return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "Resource.level"`)} } - if _, ok := rc.mutation.TreePath(); !ok { + if _, ok := _c.mutation.TreePath(); !ok { return &ValidationError{Name: "tree_path", err: errors.New(`ent: missing required field "Resource.tree_path"`)} } - if v, ok := rc.mutation.TreePath(); ok { + if v, ok := _c.mutation.TreePath(); ok { if err := resource.TreePathValidator(v); err != nil { return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} } } - if _, ok := rc.mutation.Description(); !ok { + if _, ok := _c.mutation.Description(); !ok { return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Resource.description"`)} } - if v, ok := rc.mutation.Description(); ok { + if v, ok := _c.mutation.Description(); ok { if err := resource.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} } } - if v, ok := rc.mutation.ParentID(); ok { + if v, ok := _c.mutation.ParentID(); ok { if err := resource.ParentIDValidator(v); err != nil { return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Resource.parent_id": %w`, err)} } } - if v, ok := rc.mutation.ID(); ok { + if v, ok := _c.mutation.ID(); ok { if err := resource.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Resource.id": %w`, err)} } @@ -562,12 +562,12 @@ func (rc *ResourceCreate) check() error { return nil } -func (rc *ResourceCreate) sqlSave(ctx context.Context) (*Resource, error) { - if err := rc.check(); err != nil { +func (_c *ResourceCreate) sqlSave(ctx context.Context) (*Resource, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := rc.createSpec() - if err := sqlgraph.CreateNode(ctx, rc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -577,93 +577,93 @@ func (rc *ResourceCreate) sqlSave(ctx context.Context) (*Resource, error) { id := _spec.ID.Value.(int64) _node.ID = int64(id) } - rc.mutation.id = &_node.ID - rc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (rc *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { +func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { var ( - _node = &Resource{config: rc.config} + _node = &Resource{config: _c.config} _spec = sqlgraph.NewCreateSpec(resource.Table, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) ) - if id, ok := rc.mutation.ID(); ok { + if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } - if value, ok := rc.mutation.CreateTime(); ok { + if value, ok := _c.mutation.CreateTime(); ok { _spec.SetField(resource.FieldCreateTime, field.TypeTime, value) _node.CreateTime = value } - if value, ok := rc.mutation.UpdateTime(); ok { + if value, ok := _c.mutation.UpdateTime(); ok { _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) _node.UpdateTime = value } - if value, ok := rc.mutation.Name(); ok { + if value, ok := _c.mutation.Name(); ok { _spec.SetField(resource.FieldName, field.TypeString, value) _node.Name = value } - if value, ok := rc.mutation.Keyword(); ok { + if value, ok := _c.mutation.Keyword(); ok { _spec.SetField(resource.FieldKeyword, field.TypeString, value) _node.Keyword = value } - if value, ok := rc.mutation.I18nKey(); ok { + if value, ok := _c.mutation.I18nKey(); ok { _spec.SetField(resource.FieldI18nKey, field.TypeString, value) _node.I18nKey = value } - if value, ok := rc.mutation.GetType(); ok { + if value, ok := _c.mutation.GetType(); ok { _spec.SetField(resource.FieldType, field.TypeString, value) _node.Type = value } - if value, ok := rc.mutation.Status(); ok { + if value, ok := _c.mutation.Status(); ok { _spec.SetField(resource.FieldStatus, field.TypeInt8, value) _node.Status = value } - if value, ok := rc.mutation.Path(); ok { + if value, ok := _c.mutation.Path(); ok { _spec.SetField(resource.FieldPath, field.TypeString, value) _node.Path = value } - if value, ok := rc.mutation.Operation(); ok { + if value, ok := _c.mutation.Operation(); ok { _spec.SetField(resource.FieldOperation, field.TypeString, value) _node.Operation = value } - if value, ok := rc.mutation.Method(); ok { + if value, ok := _c.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) _node.Method = value } - if value, ok := rc.mutation.Component(); ok { + if value, ok := _c.mutation.Component(); ok { _spec.SetField(resource.FieldComponent, field.TypeString, value) _node.Component = value } - if value, ok := rc.mutation.Icon(); ok { + if value, ok := _c.mutation.Icon(); ok { _spec.SetField(resource.FieldIcon, field.TypeString, value) _node.Icon = value } - if value, ok := rc.mutation.Sequence(); ok { + if value, ok := _c.mutation.Sequence(); ok { _spec.SetField(resource.FieldSequence, field.TypeInt, value) _node.Sequence = value } - if value, ok := rc.mutation.Visible(); ok { + if value, ok := _c.mutation.Visible(); ok { _spec.SetField(resource.FieldVisible, field.TypeBool, value) _node.Visible = value } - if value, ok := rc.mutation.Level(); ok { + if value, ok := _c.mutation.Level(); ok { _spec.SetField(resource.FieldLevel, field.TypeInt8, value) _node.Level = value } - if value, ok := rc.mutation.TreePath(); ok { + if value, ok := _c.mutation.TreePath(); ok { _spec.SetField(resource.FieldTreePath, field.TypeString, value) _node.TreePath = value } - if value, ok := rc.mutation.Properties(); ok { + if value, ok := _c.mutation.Properties(); ok { _spec.SetField(resource.FieldProperties, field.TypeJSON, value) _node.Properties = value } - if value, ok := rc.mutation.Description(); ok { + if value, ok := _c.mutation.Description(); ok { _spec.SetField(resource.FieldDescription, field.TypeString, value) _node.Description = value } - if nodes := rc.mutation.ChildrenIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -679,7 +679,7 @@ func (rc *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := rc.mutation.ParentIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -696,7 +696,7 @@ func (rc *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { _node.ParentID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := rc.mutation.PermissionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -712,7 +712,7 @@ func (rc *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := rc.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PermissionResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -732,23 +732,23 @@ func (rc *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { } // SetResource set the Resource -func (rc *ResourceCreate) SetResource(input *Resource, fields ...string) *ResourceCreate { - m := rc.mutation +func (_c *ResourceCreate) SetResource(input *Resource, fields ...string) *ResourceCreate { + m := _c.mutation if len(fields) == 0 { fields = resource.Columns } _ = m.SetFields(input, fields...) - return rc + return _c } // SetResourceWithZero set the Resource -func (rc *ResourceCreate) SetResourceWithZero(input *Resource, fields ...string) *ResourceCreate { - m := rc.mutation +func (_c *ResourceCreate) SetResourceWithZero(input *Resource, fields ...string) *ResourceCreate { + m := _c.mutation if len(fields) == 0 { fields = resource.Columns } _ = m.SetFieldsWithZero(input, fields...) - return rc + return _c } // ResourceCreateBulk is the builder for creating many Resource entities in bulk. @@ -759,16 +759,16 @@ type ResourceCreateBulk struct { } // Save creates the Resource entities in the database. -func (rcb *ResourceCreateBulk) Save(ctx context.Context) ([]*Resource, error) { - if rcb.err != nil { - return nil, rcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(rcb.builders)) - nodes := make([]*Resource, len(rcb.builders)) - mutators := make([]Mutator, len(rcb.builders)) - for i := range rcb.builders { +func (_c *ResourceCreateBulk) Save(ctx context.Context) ([]*Resource, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Resource, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := rcb.builders[i] + builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*ResourceMutation) @@ -782,11 +782,11 @@ func (rcb *ResourceCreateBulk) Save(ctx context.Context) ([]*Resource, error) { var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, rcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, rcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -810,7 +810,7 @@ func (rcb *ResourceCreateBulk) Save(ctx context.Context) ([]*Resource, error) { }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, rcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -818,8 +818,8 @@ func (rcb *ResourceCreateBulk) Save(ctx context.Context) ([]*Resource, error) { } // SaveX is like Save, but panics if an error occurs. -func (rcb *ResourceCreateBulk) SaveX(ctx context.Context) []*Resource { - v, err := rcb.Save(ctx) +func (_c *ResourceCreateBulk) SaveX(ctx context.Context) []*Resource { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -827,14 +827,14 @@ func (rcb *ResourceCreateBulk) SaveX(ctx context.Context) []*Resource { } // Exec executes the query. -func (rcb *ResourceCreateBulk) Exec(ctx context.Context) error { - _, err := rcb.Save(ctx) +func (_c *ResourceCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rcb *ResourceCreateBulk) ExecX(ctx context.Context) { - if err := rcb.Exec(ctx); err != nil { +func (_c *ResourceCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/resource_delete.go b/internal/data/entity/ent/resource_delete.go index 64063c39..3d955ece 100644 --- a/internal/data/entity/ent/resource_delete.go +++ b/internal/data/entity/ent/resource_delete.go @@ -20,56 +20,56 @@ type ResourceDelete struct { } // Where appends a list predicates to the ResourceDelete builder. -func (rd *ResourceDelete) Where(ps ...predicate.Resource) *ResourceDelete { - rd.mutation.Where(ps...) - return rd +func (_d *ResourceDelete) Where(ps ...predicate.Resource) *ResourceDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (rd *ResourceDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, rd.sqlExec, rd.mutation, rd.hooks) +func (_d *ResourceDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (rd *ResourceDelete) ExecX(ctx context.Context) int { - n, err := rd.Exec(ctx) +func (_d *ResourceDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (rd *ResourceDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *ResourceDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(resource.Table, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) - if ps := rd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, rd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - rd.mutation.done = true + _d.mutation.done = true return affected, err } // ResourceDeleteOne is the builder for deleting a single Resource entity. type ResourceDeleteOne struct { - rd *ResourceDelete + _d *ResourceDelete } // Where appends a list predicates to the ResourceDelete builder. -func (rdo *ResourceDeleteOne) Where(ps ...predicate.Resource) *ResourceDeleteOne { - rdo.rd.mutation.Where(ps...) - return rdo +func (_d *ResourceDeleteOne) Where(ps ...predicate.Resource) *ResourceDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (rdo *ResourceDeleteOne) Exec(ctx context.Context) error { - n, err := rdo.rd.Exec(ctx) +func (_d *ResourceDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (rdo *ResourceDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (rdo *ResourceDeleteOne) ExecX(ctx context.Context) { - if err := rdo.Exec(ctx); err != nil { +func (_d *ResourceDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/resource_query.go b/internal/data/entity/ent/resource_query.go index f221e290..b03e9e39 100644 --- a/internal/data/entity/ent/resource_query.go +++ b/internal/data/entity/ent/resource_query.go @@ -37,44 +37,44 @@ type ResourceQuery struct { } // Where adds a new predicate for the ResourceQuery builder. -func (rq *ResourceQuery) Where(ps ...predicate.Resource) *ResourceQuery { - rq.predicates = append(rq.predicates, ps...) - return rq +func (_q *ResourceQuery) Where(ps ...predicate.Resource) *ResourceQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (rq *ResourceQuery) Limit(limit int) *ResourceQuery { - rq.ctx.Limit = &limit - return rq +func (_q *ResourceQuery) Limit(limit int) *ResourceQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (rq *ResourceQuery) Offset(offset int) *ResourceQuery { - rq.ctx.Offset = &offset - return rq +func (_q *ResourceQuery) Offset(offset int) *ResourceQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (rq *ResourceQuery) Unique(unique bool) *ResourceQuery { - rq.ctx.Unique = &unique - return rq +func (_q *ResourceQuery) Unique(unique bool) *ResourceQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (rq *ResourceQuery) Order(o ...resource.OrderOption) *ResourceQuery { - rq.order = append(rq.order, o...) - return rq +func (_q *ResourceQuery) Order(o ...resource.OrderOption) *ResourceQuery { + _q.order = append(_q.order, o...) + return _q } // QueryChildren chains the current query on the "children" edge. -func (rq *ResourceQuery) QueryChildren() *ResourceQuery { - query := (&ResourceClient{config: rq.config}).Query() +func (_q *ResourceQuery) QueryChildren() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -83,20 +83,20 @@ func (rq *ResourceQuery) QueryChildren() *ResourceQuery { sqlgraph.To(resource.Table, resource.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, resource.ChildrenTable, resource.ChildrenColumn), ) - fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryParent chains the current query on the "parent" edge. -func (rq *ResourceQuery) QueryParent() *ResourceQuery { - query := (&ResourceClient{config: rq.config}).Query() +func (_q *ResourceQuery) QueryParent() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -105,20 +105,20 @@ func (rq *ResourceQuery) QueryParent() *ResourceQuery { sqlgraph.To(resource.Table, resource.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, resource.ParentTable, resource.ParentColumn), ) - fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPermissions chains the current query on the "permissions" edge. -func (rq *ResourceQuery) QueryPermissions() *PermissionQuery { - query := (&PermissionClient{config: rq.config}).Query() +func (_q *ResourceQuery) QueryPermissions() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -127,20 +127,20 @@ func (rq *ResourceQuery) QueryPermissions() *PermissionQuery { sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, resource.PermissionsTable, resource.PermissionsPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPermissionResources chains the current query on the "permission_resources" edge. -func (rq *ResourceQuery) QueryPermissionResources() *PermissionResourceQuery { - query := (&PermissionResourceClient{config: rq.config}).Query() +func (_q *ResourceQuery) QueryPermissionResources() *PermissionResourceQuery { + query := (&PermissionResourceClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -149,7 +149,7 @@ func (rq *ResourceQuery) QueryPermissionResources() *PermissionResourceQuery { sqlgraph.To(permissionresource.Table, permissionresource.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, resource.PermissionResourcesTable, resource.PermissionResourcesColumn), ) - fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -157,8 +157,8 @@ func (rq *ResourceQuery) QueryPermissionResources() *PermissionResourceQuery { // First returns the first Resource entity from the query. // Returns a *NotFoundError when no Resource was found. -func (rq *ResourceQuery) First(ctx context.Context) (*Resource, error) { - nodes, err := rq.Limit(1).All(setContextOp(ctx, rq.ctx, ent.OpQueryFirst)) +func (_q *ResourceQuery) First(ctx context.Context) (*Resource, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -169,8 +169,8 @@ func (rq *ResourceQuery) First(ctx context.Context) (*Resource, error) { } // FirstX is like First, but panics if an error occurs. -func (rq *ResourceQuery) FirstX(ctx context.Context) *Resource { - node, err := rq.First(ctx) +func (_q *ResourceQuery) FirstX(ctx context.Context) *Resource { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -179,9 +179,9 @@ func (rq *ResourceQuery) FirstX(ctx context.Context) *Resource { // FirstID returns the first Resource ID from the query. // Returns a *NotFoundError when no Resource ID was found. -func (rq *ResourceQuery) FirstID(ctx context.Context) (id int64, err error) { +func (_q *ResourceQuery) FirstID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = rq.Limit(1).IDs(setContextOp(ctx, rq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -192,8 +192,8 @@ func (rq *ResourceQuery) FirstID(ctx context.Context) (id int64, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (rq *ResourceQuery) FirstIDX(ctx context.Context) int64 { - id, err := rq.FirstID(ctx) +func (_q *ResourceQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -203,8 +203,8 @@ func (rq *ResourceQuery) FirstIDX(ctx context.Context) int64 { // Only returns a single Resource entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Resource entity is found. // Returns a *NotFoundError when no Resource entities are found. -func (rq *ResourceQuery) Only(ctx context.Context) (*Resource, error) { - nodes, err := rq.Limit(2).All(setContextOp(ctx, rq.ctx, ent.OpQueryOnly)) +func (_q *ResourceQuery) Only(ctx context.Context) (*Resource, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -219,8 +219,8 @@ func (rq *ResourceQuery) Only(ctx context.Context) (*Resource, error) { } // OnlyX is like Only, but panics if an error occurs. -func (rq *ResourceQuery) OnlyX(ctx context.Context) *Resource { - node, err := rq.Only(ctx) +func (_q *ResourceQuery) OnlyX(ctx context.Context) *Resource { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -230,9 +230,9 @@ func (rq *ResourceQuery) OnlyX(ctx context.Context) *Resource { // OnlyID is like Only, but returns the only Resource ID in the query. // Returns a *NotSingularError when more than one Resource ID is found. // Returns a *NotFoundError when no entities are found. -func (rq *ResourceQuery) OnlyID(ctx context.Context) (id int64, err error) { +func (_q *ResourceQuery) OnlyID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = rq.Limit(2).IDs(setContextOp(ctx, rq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -247,8 +247,8 @@ func (rq *ResourceQuery) OnlyID(ctx context.Context) (id int64, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (rq *ResourceQuery) OnlyIDX(ctx context.Context) int64 { - id, err := rq.OnlyID(ctx) +func (_q *ResourceQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -256,18 +256,18 @@ func (rq *ResourceQuery) OnlyIDX(ctx context.Context) int64 { } // All executes the query and returns a list of Resources. -func (rq *ResourceQuery) All(ctx context.Context) ([]*Resource, error) { - ctx = setContextOp(ctx, rq.ctx, ent.OpQueryAll) - if err := rq.prepareQuery(ctx); err != nil { +func (_q *ResourceQuery) All(ctx context.Context) ([]*Resource, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Resource, *ResourceQuery]() - return withInterceptors[[]*Resource](ctx, rq, qr, rq.inters) + return withInterceptors[[]*Resource](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (rq *ResourceQuery) AllX(ctx context.Context) []*Resource { - nodes, err := rq.All(ctx) +func (_q *ResourceQuery) AllX(ctx context.Context) []*Resource { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -275,20 +275,20 @@ func (rq *ResourceQuery) AllX(ctx context.Context) []*Resource { } // IDs executes the query and returns a list of Resource IDs. -func (rq *ResourceQuery) IDs(ctx context.Context) (ids []int64, err error) { - if rq.ctx.Unique == nil && rq.path != nil { - rq.Unique(true) +func (_q *ResourceQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, rq.ctx, ent.OpQueryIDs) - if err = rq.Select(resource.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(resource.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (rq *ResourceQuery) IDsX(ctx context.Context) []int64 { - ids, err := rq.IDs(ctx) +func (_q *ResourceQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -296,17 +296,17 @@ func (rq *ResourceQuery) IDsX(ctx context.Context) []int64 { } // Count returns the count of the given query. -func (rq *ResourceQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, rq.ctx, ent.OpQueryCount) - if err := rq.prepareQuery(ctx); err != nil { +func (_q *ResourceQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, rq, querierCount[*ResourceQuery](), rq.inters) + return withInterceptors[int](ctx, _q, querierCount[*ResourceQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (rq *ResourceQuery) CountX(ctx context.Context) int { - count, err := rq.Count(ctx) +func (_q *ResourceQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -314,9 +314,9 @@ func (rq *ResourceQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (rq *ResourceQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, rq.ctx, ent.OpQueryExist) - switch _, err := rq.FirstID(ctx); { +func (_q *ResourceQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -327,8 +327,8 @@ func (rq *ResourceQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (rq *ResourceQuery) ExistX(ctx context.Context) bool { - exist, err := rq.Exist(ctx) +func (_q *ResourceQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -337,69 +337,69 @@ func (rq *ResourceQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the ResourceQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (rq *ResourceQuery) Clone() *ResourceQuery { - if rq == nil { +func (_q *ResourceQuery) Clone() *ResourceQuery { + if _q == nil { return nil } return &ResourceQuery{ - config: rq.config, - ctx: rq.ctx.Clone(), - order: append([]resource.OrderOption{}, rq.order...), - inters: append([]Interceptor{}, rq.inters...), - predicates: append([]predicate.Resource{}, rq.predicates...), - withChildren: rq.withChildren.Clone(), - withParent: rq.withParent.Clone(), - withPermissions: rq.withPermissions.Clone(), - withPermissionResources: rq.withPermissionResources.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]resource.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Resource{}, _q.predicates...), + withChildren: _q.withChildren.Clone(), + withParent: _q.withParent.Clone(), + withPermissions: _q.withPermissions.Clone(), + withPermissionResources: _q.withPermissionResources.Clone(), // clone intermediate query. - sql: rq.sql.Clone(), - path: rq.path, - modifiers: append([]func(*sql.Selector){}, rq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithChildren tells the query-builder to eager-load the nodes that are connected to // the "children" edge. The optional arguments are used to configure the query builder of the edge. -func (rq *ResourceQuery) WithChildren(opts ...func(*ResourceQuery)) *ResourceQuery { - query := (&ResourceClient{config: rq.config}).Query() +func (_q *ResourceQuery) WithChildren(opts ...func(*ResourceQuery)) *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rq.withChildren = query - return rq + _q.withChildren = query + return _q } // WithParent tells the query-builder to eager-load the nodes that are connected to // the "parent" edge. The optional arguments are used to configure the query builder of the edge. -func (rq *ResourceQuery) WithParent(opts ...func(*ResourceQuery)) *ResourceQuery { - query := (&ResourceClient{config: rq.config}).Query() +func (_q *ResourceQuery) WithParent(opts ...func(*ResourceQuery)) *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rq.withParent = query - return rq + _q.withParent = query + return _q } // WithPermissions tells the query-builder to eager-load the nodes that are connected to // the "permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (rq *ResourceQuery) WithPermissions(opts ...func(*PermissionQuery)) *ResourceQuery { - query := (&PermissionClient{config: rq.config}).Query() +func (_q *ResourceQuery) WithPermissions(opts ...func(*PermissionQuery)) *ResourceQuery { + query := (&PermissionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rq.withPermissions = query - return rq + _q.withPermissions = query + return _q } // WithPermissionResources tells the query-builder to eager-load the nodes that are connected to // the "permission_resources" edge. The optional arguments are used to configure the query builder of the edge. -func (rq *ResourceQuery) WithPermissionResources(opts ...func(*PermissionResourceQuery)) *ResourceQuery { - query := (&PermissionResourceClient{config: rq.config}).Query() +func (_q *ResourceQuery) WithPermissionResources(opts ...func(*PermissionResourceQuery)) *ResourceQuery { + query := (&PermissionResourceClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rq.withPermissionResources = query - return rq + _q.withPermissionResources = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -416,10 +416,10 @@ func (rq *ResourceQuery) WithPermissionResources(opts ...func(*PermissionResourc // GroupBy(resource.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (rq *ResourceQuery) GroupBy(field string, fields ...string) *ResourceGroupBy { - rq.ctx.Fields = append([]string{field}, fields...) - grbuild := &ResourceGroupBy{build: rq} - grbuild.flds = &rq.ctx.Fields +func (_q *ResourceQuery) GroupBy(field string, fields ...string) *ResourceGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &ResourceGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = resource.Label grbuild.scan = grbuild.Scan return grbuild @@ -437,99 +437,99 @@ func (rq *ResourceQuery) GroupBy(field string, fields ...string) *ResourceGroupB // client.Resource.Query(). // Select(resource.FieldCreateTime). // Scan(ctx, &v) -func (rq *ResourceQuery) Select(fields ...string) *ResourceSelect { - rq.ctx.Fields = append(rq.ctx.Fields, fields...) - sbuild := &ResourceSelect{ResourceQuery: rq} +func (_q *ResourceQuery) Select(fields ...string) *ResourceSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &ResourceSelect{ResourceQuery: _q} sbuild.label = resource.Label - sbuild.flds, sbuild.scan = &rq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a ResourceSelect configured with the given aggregations. -func (rq *ResourceQuery) Aggregate(fns ...AggregateFunc) *ResourceSelect { - return rq.Select().Aggregate(fns...) +func (_q *ResourceQuery) Aggregate(fns ...AggregateFunc) *ResourceSelect { + return _q.Select().Aggregate(fns...) } -func (rq *ResourceQuery) prepareQuery(ctx context.Context) error { - for _, inter := range rq.inters { +func (_q *ResourceQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, rq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range rq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !resource.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if rq.path != nil { - prev, err := rq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - rq.sql = prev + _q.sql = prev } return nil } -func (rq *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Resource, error) { +func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Resource, error) { var ( nodes = []*Resource{} - _spec = rq.querySpec() + _spec = _q.querySpec() loadedTypes = [4]bool{ - rq.withChildren != nil, - rq.withParent != nil, - rq.withPermissions != nil, - rq.withPermissionResources != nil, + _q.withChildren != nil, + _q.withParent != nil, + _q.withPermissions != nil, + _q.withPermissionResources != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Resource).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Resource{config: rq.config} + node := &Resource{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(rq.modifiers) > 0 { - _spec.Modifiers = rq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, rq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := rq.withChildren; query != nil { - if err := rq.loadChildren(ctx, query, nodes, + if query := _q.withChildren; query != nil { + if err := _q.loadChildren(ctx, query, nodes, func(n *Resource) { n.Edges.Children = []*Resource{} }, func(n *Resource, e *Resource) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil { return nil, err } } - if query := rq.withParent; query != nil { - if err := rq.loadParent(ctx, query, nodes, nil, + if query := _q.withParent; query != nil { + if err := _q.loadParent(ctx, query, nodes, nil, func(n *Resource, e *Resource) { n.Edges.Parent = e }); err != nil { return nil, err } } - if query := rq.withPermissions; query != nil { - if err := rq.loadPermissions(ctx, query, nodes, + if query := _q.withPermissions; query != nil { + if err := _q.loadPermissions(ctx, query, nodes, func(n *Resource) { n.Edges.Permissions = []*Permission{} }, func(n *Resource, e *Permission) { n.Edges.Permissions = append(n.Edges.Permissions, e) }); err != nil { return nil, err } } - if query := rq.withPermissionResources; query != nil { - if err := rq.loadPermissionResources(ctx, query, nodes, + if query := _q.withPermissionResources; query != nil { + if err := _q.loadPermissionResources(ctx, query, nodes, func(n *Resource) { n.Edges.PermissionResources = []*PermissionResource{} }, func(n *Resource, e *PermissionResource) { n.Edges.PermissionResources = append(n.Edges.PermissionResources, e) @@ -540,7 +540,7 @@ func (rq *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Res return nodes, nil } -func (rq *ResourceQuery) loadChildren(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { +func (_q *ResourceQuery) loadChildren(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Resource) for i := range nodes { @@ -570,7 +570,7 @@ func (rq *ResourceQuery) loadChildren(ctx context.Context, query *ResourceQuery, } return nil } -func (rq *ResourceQuery) loadParent(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { +func (_q *ResourceQuery) loadParent(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*Resource) for i := range nodes { @@ -599,7 +599,7 @@ func (rq *ResourceQuery) loadParent(ctx context.Context, query *ResourceQuery, n } return nil } -func (rq *ResourceQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Permission)) error { +func (_q *ResourceQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Permission)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*Resource) nids := make(map[int64]map[*Resource]struct{}) @@ -660,7 +660,7 @@ func (rq *ResourceQuery) loadPermissions(ctx context.Context, query *PermissionQ } return nil } -func (rq *ResourceQuery) loadPermissionResources(ctx context.Context, query *PermissionResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *PermissionResource)) error { +func (_q *ResourceQuery) loadPermissionResources(ctx context.Context, query *PermissionResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *PermissionResource)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Resource) for i := range nodes { @@ -691,27 +691,27 @@ func (rq *ResourceQuery) loadPermissionResources(ctx context.Context, query *Per return nil } -func (rq *ResourceQuery) sqlCount(ctx context.Context) (int, error) { - _spec := rq.querySpec() - if len(rq.modifiers) > 0 { - _spec.Modifiers = rq.modifiers +func (_q *ResourceQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = rq.ctx.Fields - if len(rq.ctx.Fields) > 0 { - _spec.Unique = rq.ctx.Unique != nil && *rq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, rq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (rq *ResourceQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *ResourceQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(resource.Table, resource.Columns, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) - _spec.From = rq.sql - if unique := rq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if rq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := rq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, resource.FieldID) for i := range fields { @@ -719,24 +719,24 @@ func (rq *ResourceQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if rq.withParent != nil { + if _q.withParent != nil { _spec.Node.AddColumnOnce(resource.FieldParentID) } } - if ps := rq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := rq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := rq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := rq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -746,36 +746,36 @@ func (rq *ResourceQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (rq *ResourceQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(rq.driver.Dialect()) +func (_q *ResourceQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(resource.Table) - columns := rq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = resource.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if rq.sql != nil { - selector = rq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if rq.ctx.Unique != nil && *rq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range rq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range rq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range rq.order { + for _, p := range _q.order { p(selector) } - if offset := rq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := rq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -784,33 +784,33 @@ func (rq *ResourceQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (rq *ResourceQuery) ForUpdate(opts ...sql.LockOption) *ResourceQuery { - if rq.driver.Dialect() == dialect.Postgres { - rq.Unique(false) +func (_q *ResourceQuery) ForUpdate(opts ...sql.LockOption) *ResourceQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - rq.modifiers = append(rq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return rq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (rq *ResourceQuery) ForShare(opts ...sql.LockOption) *ResourceQuery { - if rq.driver.Dialect() == dialect.Postgres { - rq.Unique(false) +func (_q *ResourceQuery) ForShare(opts ...sql.LockOption) *ResourceQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - rq.modifiers = append(rq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return rq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (rq *ResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *ResourceSelect { - rq.modifiers = append(rq.modifiers, modifiers...) - return rq.Select() +func (_q *ResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *ResourceSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -886,41 +886,41 @@ type ResourceGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (rgb *ResourceGroupBy) Aggregate(fns ...AggregateFunc) *ResourceGroupBy { - rgb.fns = append(rgb.fns, fns...) - return rgb +func (_g *ResourceGroupBy) Aggregate(fns ...AggregateFunc) *ResourceGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (rgb *ResourceGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, rgb.build.ctx, ent.OpQueryGroupBy) - if err := rgb.build.prepareQuery(ctx); err != nil { +func (_g *ResourceGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*ResourceQuery, *ResourceGroupBy](ctx, rgb.build, rgb, rgb.build.inters, v) + return scanWithInterceptors[*ResourceQuery, *ResourceGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (rgb *ResourceGroupBy) sqlScan(ctx context.Context, root *ResourceQuery, v any) error { +func (_g *ResourceGroupBy) sqlScan(ctx context.Context, root *ResourceQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(rgb.fns)) - for _, fn := range rgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*rgb.flds)+len(rgb.fns)) - for _, f := range *rgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*rgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := rgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -934,27 +934,27 @@ type ResourceSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (rs *ResourceSelect) Aggregate(fns ...AggregateFunc) *ResourceSelect { - rs.fns = append(rs.fns, fns...) - return rs +func (_s *ResourceSelect) Aggregate(fns ...AggregateFunc) *ResourceSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (rs *ResourceSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, rs.ctx, ent.OpQuerySelect) - if err := rs.prepareQuery(ctx); err != nil { +func (_s *ResourceSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*ResourceQuery, *ResourceSelect](ctx, rs.ResourceQuery, rs, rs.inters, v) + return scanWithInterceptors[*ResourceQuery, *ResourceSelect](ctx, _s.ResourceQuery, _s, _s.inters, v) } -func (rs *ResourceSelect) sqlScan(ctx context.Context, root *ResourceQuery, v any) error { +func (_s *ResourceSelect) sqlScan(ctx context.Context, root *ResourceQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(rs.fns)) - for _, fn := range rs.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*rs.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -962,7 +962,7 @@ func (rs *ResourceSelect) sqlScan(ctx context.Context, root *ResourceQuery, v an } rows := &sql.Rows{} query, args := selector.Query() - if err := rs.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -970,7 +970,7 @@ func (rs *ResourceSelect) sqlScan(ctx context.Context, root *ResourceQuery, v an } // Modify adds a query modifier for attaching custom logic to queries. -func (rs *ResourceSelect) Modify(modifiers ...func(s *sql.Selector)) *ResourceSelect { - rs.modifiers = append(rs.modifiers, modifiers...) - return rs +func (_s *ResourceSelect) Modify(modifiers ...func(s *sql.Selector)) *ResourceSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/resource_update.go b/internal/data/entity/ent/resource_update.go index 0095e30a..e70739d9 100644 --- a/internal/data/entity/ent/resource_update.go +++ b/internal/data/entity/ent/resource_update.go @@ -26,413 +26,413 @@ type ResourceUpdate struct { } // Where appends a list predicates to the ResourceUpdate builder. -func (ru *ResourceUpdate) Where(ps ...predicate.Resource) *ResourceUpdate { - ru.mutation.Where(ps...) - return ru +func (_u *ResourceUpdate) Where(ps ...predicate.Resource) *ResourceUpdate { + _u.mutation.Where(ps...) + return _u } // SetUpdateTime sets the "update_time" field. -func (ru *ResourceUpdate) SetUpdateTime(t time.Time) *ResourceUpdate { - ru.mutation.SetUpdateTime(t) - return ru +func (_u *ResourceUpdate) SetUpdateTime(v time.Time) *ResourceUpdate { + _u.mutation.SetUpdateTime(v) + return _u } // SetName sets the "name" field. -func (ru *ResourceUpdate) SetName(s string) *ResourceUpdate { - ru.mutation.SetName(s) - return ru +func (_u *ResourceUpdate) SetName(v string) *ResourceUpdate { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableName(s *string) *ResourceUpdate { - if s != nil { - ru.SetName(*s) +func (_u *ResourceUpdate) SetNillableName(v *string) *ResourceUpdate { + if v != nil { + _u.SetName(*v) } - return ru + return _u } // SetKeyword sets the "keyword" field. -func (ru *ResourceUpdate) SetKeyword(s string) *ResourceUpdate { - ru.mutation.SetKeyword(s) - return ru +func (_u *ResourceUpdate) SetKeyword(v string) *ResourceUpdate { + _u.mutation.SetKeyword(v) + return _u } // SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableKeyword(s *string) *ResourceUpdate { - if s != nil { - ru.SetKeyword(*s) +func (_u *ResourceUpdate) SetNillableKeyword(v *string) *ResourceUpdate { + if v != nil { + _u.SetKeyword(*v) } - return ru + return _u } // SetI18nKey sets the "i18n_key" field. -func (ru *ResourceUpdate) SetI18nKey(s string) *ResourceUpdate { - ru.mutation.SetI18nKey(s) - return ru +func (_u *ResourceUpdate) SetI18nKey(v string) *ResourceUpdate { + _u.mutation.SetI18nKey(v) + return _u } // SetNillableI18nKey sets the "i18n_key" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableI18nKey(s *string) *ResourceUpdate { - if s != nil { - ru.SetI18nKey(*s) +func (_u *ResourceUpdate) SetNillableI18nKey(v *string) *ResourceUpdate { + if v != nil { + _u.SetI18nKey(*v) } - return ru + return _u } // SetType sets the "type" field. -func (ru *ResourceUpdate) SetType(s string) *ResourceUpdate { - ru.mutation.SetType(s) - return ru +func (_u *ResourceUpdate) SetType(v string) *ResourceUpdate { + _u.mutation.SetType(v) + return _u } // SetNillableType sets the "type" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableType(s *string) *ResourceUpdate { - if s != nil { - ru.SetType(*s) +func (_u *ResourceUpdate) SetNillableType(v *string) *ResourceUpdate { + if v != nil { + _u.SetType(*v) } - return ru + return _u } // SetStatus sets the "status" field. -func (ru *ResourceUpdate) SetStatus(i int8) *ResourceUpdate { - ru.mutation.ResetStatus() - ru.mutation.SetStatus(i) - return ru +func (_u *ResourceUpdate) SetStatus(v int8) *ResourceUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableStatus(i *int8) *ResourceUpdate { - if i != nil { - ru.SetStatus(*i) +func (_u *ResourceUpdate) SetNillableStatus(v *int8) *ResourceUpdate { + if v != nil { + _u.SetStatus(*v) } - return ru + return _u } -// AddStatus adds i to the "status" field. -func (ru *ResourceUpdate) AddStatus(i int8) *ResourceUpdate { - ru.mutation.AddStatus(i) - return ru +// AddStatus adds value to the "status" field. +func (_u *ResourceUpdate) AddStatus(v int8) *ResourceUpdate { + _u.mutation.AddStatus(v) + return _u } // SetPath sets the "path" field. -func (ru *ResourceUpdate) SetPath(s string) *ResourceUpdate { - ru.mutation.SetPath(s) - return ru +func (_u *ResourceUpdate) SetPath(v string) *ResourceUpdate { + _u.mutation.SetPath(v) + return _u } // SetNillablePath sets the "path" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillablePath(s *string) *ResourceUpdate { - if s != nil { - ru.SetPath(*s) +func (_u *ResourceUpdate) SetNillablePath(v *string) *ResourceUpdate { + if v != nil { + _u.SetPath(*v) } - return ru + return _u } // SetOperation sets the "operation" field. -func (ru *ResourceUpdate) SetOperation(s string) *ResourceUpdate { - ru.mutation.SetOperation(s) - return ru +func (_u *ResourceUpdate) SetOperation(v string) *ResourceUpdate { + _u.mutation.SetOperation(v) + return _u } // SetNillableOperation sets the "operation" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableOperation(s *string) *ResourceUpdate { - if s != nil { - ru.SetOperation(*s) +func (_u *ResourceUpdate) SetNillableOperation(v *string) *ResourceUpdate { + if v != nil { + _u.SetOperation(*v) } - return ru + return _u } // SetMethod sets the "method" field. -func (ru *ResourceUpdate) SetMethod(s string) *ResourceUpdate { - ru.mutation.SetMethod(s) - return ru +func (_u *ResourceUpdate) SetMethod(v string) *ResourceUpdate { + _u.mutation.SetMethod(v) + return _u } // SetNillableMethod sets the "method" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableMethod(s *string) *ResourceUpdate { - if s != nil { - ru.SetMethod(*s) +func (_u *ResourceUpdate) SetNillableMethod(v *string) *ResourceUpdate { + if v != nil { + _u.SetMethod(*v) } - return ru + return _u } // SetComponent sets the "component" field. -func (ru *ResourceUpdate) SetComponent(s string) *ResourceUpdate { - ru.mutation.SetComponent(s) - return ru +func (_u *ResourceUpdate) SetComponent(v string) *ResourceUpdate { + _u.mutation.SetComponent(v) + return _u } // SetNillableComponent sets the "component" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableComponent(s *string) *ResourceUpdate { - if s != nil { - ru.SetComponent(*s) +func (_u *ResourceUpdate) SetNillableComponent(v *string) *ResourceUpdate { + if v != nil { + _u.SetComponent(*v) } - return ru + return _u } // SetIcon sets the "icon" field. -func (ru *ResourceUpdate) SetIcon(s string) *ResourceUpdate { - ru.mutation.SetIcon(s) - return ru +func (_u *ResourceUpdate) SetIcon(v string) *ResourceUpdate { + _u.mutation.SetIcon(v) + return _u } // SetNillableIcon sets the "icon" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableIcon(s *string) *ResourceUpdate { - if s != nil { - ru.SetIcon(*s) +func (_u *ResourceUpdate) SetNillableIcon(v *string) *ResourceUpdate { + if v != nil { + _u.SetIcon(*v) } - return ru + return _u } // SetSequence sets the "sequence" field. -func (ru *ResourceUpdate) SetSequence(i int) *ResourceUpdate { - ru.mutation.ResetSequence() - ru.mutation.SetSequence(i) - return ru +func (_u *ResourceUpdate) SetSequence(v int) *ResourceUpdate { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u } // SetNillableSequence sets the "sequence" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableSequence(i *int) *ResourceUpdate { - if i != nil { - ru.SetSequence(*i) +func (_u *ResourceUpdate) SetNillableSequence(v *int) *ResourceUpdate { + if v != nil { + _u.SetSequence(*v) } - return ru + return _u } -// AddSequence adds i to the "sequence" field. -func (ru *ResourceUpdate) AddSequence(i int) *ResourceUpdate { - ru.mutation.AddSequence(i) - return ru +// AddSequence adds value to the "sequence" field. +func (_u *ResourceUpdate) AddSequence(v int) *ResourceUpdate { + _u.mutation.AddSequence(v) + return _u } // SetVisible sets the "visible" field. -func (ru *ResourceUpdate) SetVisible(b bool) *ResourceUpdate { - ru.mutation.SetVisible(b) - return ru +func (_u *ResourceUpdate) SetVisible(v bool) *ResourceUpdate { + _u.mutation.SetVisible(v) + return _u } // SetNillableVisible sets the "visible" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableVisible(b *bool) *ResourceUpdate { - if b != nil { - ru.SetVisible(*b) +func (_u *ResourceUpdate) SetNillableVisible(v *bool) *ResourceUpdate { + if v != nil { + _u.SetVisible(*v) } - return ru + return _u } // SetLevel sets the "level" field. -func (ru *ResourceUpdate) SetLevel(i int8) *ResourceUpdate { - ru.mutation.ResetLevel() - ru.mutation.SetLevel(i) - return ru +func (_u *ResourceUpdate) SetLevel(v int8) *ResourceUpdate { + _u.mutation.ResetLevel() + _u.mutation.SetLevel(v) + return _u } // SetNillableLevel sets the "level" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableLevel(i *int8) *ResourceUpdate { - if i != nil { - ru.SetLevel(*i) +func (_u *ResourceUpdate) SetNillableLevel(v *int8) *ResourceUpdate { + if v != nil { + _u.SetLevel(*v) } - return ru + return _u } -// AddLevel adds i to the "level" field. -func (ru *ResourceUpdate) AddLevel(i int8) *ResourceUpdate { - ru.mutation.AddLevel(i) - return ru +// AddLevel adds value to the "level" field. +func (_u *ResourceUpdate) AddLevel(v int8) *ResourceUpdate { + _u.mutation.AddLevel(v) + return _u } // SetTreePath sets the "tree_path" field. -func (ru *ResourceUpdate) SetTreePath(s string) *ResourceUpdate { - ru.mutation.SetTreePath(s) - return ru +func (_u *ResourceUpdate) SetTreePath(v string) *ResourceUpdate { + _u.mutation.SetTreePath(v) + return _u } // SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableTreePath(s *string) *ResourceUpdate { - if s != nil { - ru.SetTreePath(*s) +func (_u *ResourceUpdate) SetNillableTreePath(v *string) *ResourceUpdate { + if v != nil { + _u.SetTreePath(*v) } - return ru + return _u } // SetProperties sets the "properties" field. -func (ru *ResourceUpdate) SetProperties(m map[string]string) *ResourceUpdate { - ru.mutation.SetProperties(m) - return ru +func (_u *ResourceUpdate) SetProperties(v map[string]string) *ResourceUpdate { + _u.mutation.SetProperties(v) + return _u } // ClearProperties clears the value of the "properties" field. -func (ru *ResourceUpdate) ClearProperties() *ResourceUpdate { - ru.mutation.ClearProperties() - return ru +func (_u *ResourceUpdate) ClearProperties() *ResourceUpdate { + _u.mutation.ClearProperties() + return _u } // SetDescription sets the "description" field. -func (ru *ResourceUpdate) SetDescription(s string) *ResourceUpdate { - ru.mutation.SetDescription(s) - return ru +func (_u *ResourceUpdate) SetDescription(v string) *ResourceUpdate { + _u.mutation.SetDescription(v) + return _u } // SetNillableDescription sets the "description" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableDescription(s *string) *ResourceUpdate { - if s != nil { - ru.SetDescription(*s) +func (_u *ResourceUpdate) SetNillableDescription(v *string) *ResourceUpdate { + if v != nil { + _u.SetDescription(*v) } - return ru + return _u } // SetParentID sets the "parent_id" field. -func (ru *ResourceUpdate) SetParentID(i int64) *ResourceUpdate { - ru.mutation.SetParentID(i) - return ru +func (_u *ResourceUpdate) SetParentID(v int64) *ResourceUpdate { + _u.mutation.SetParentID(v) + return _u } // SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (ru *ResourceUpdate) SetNillableParentID(i *int64) *ResourceUpdate { - if i != nil { - ru.SetParentID(*i) +func (_u *ResourceUpdate) SetNillableParentID(v *int64) *ResourceUpdate { + if v != nil { + _u.SetParentID(*v) } - return ru + return _u } // ClearParentID clears the value of the "parent_id" field. -func (ru *ResourceUpdate) ClearParentID() *ResourceUpdate { - ru.mutation.ClearParentID() - return ru +func (_u *ResourceUpdate) ClearParentID() *ResourceUpdate { + _u.mutation.ClearParentID() + return _u } // AddChildIDs adds the "children" edge to the Resource entity by IDs. -func (ru *ResourceUpdate) AddChildIDs(ids ...int64) *ResourceUpdate { - ru.mutation.AddChildIDs(ids...) - return ru +func (_u *ResourceUpdate) AddChildIDs(ids ...int64) *ResourceUpdate { + _u.mutation.AddChildIDs(ids...) + return _u } // AddChildren adds the "children" edges to the Resource entity. -func (ru *ResourceUpdate) AddChildren(r ...*Resource) *ResourceUpdate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *ResourceUpdate) AddChildren(v ...*Resource) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.AddChildIDs(ids...) + return _u.AddChildIDs(ids...) } // SetParent sets the "parent" edge to the Resource entity. -func (ru *ResourceUpdate) SetParent(r *Resource) *ResourceUpdate { - return ru.SetParentID(r.ID) +func (_u *ResourceUpdate) SetParent(v *Resource) *ResourceUpdate { + return _u.SetParentID(v.ID) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (ru *ResourceUpdate) AddPermissionIDs(ids ...int64) *ResourceUpdate { - ru.mutation.AddPermissionIDs(ids...) - return ru +func (_u *ResourceUpdate) AddPermissionIDs(ids ...int64) *ResourceUpdate { + _u.mutation.AddPermissionIDs(ids...) + return _u } // AddPermissions adds the "permissions" edges to the Permission entity. -func (ru *ResourceUpdate) AddPermissions(p ...*Permission) *ResourceUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *ResourceUpdate) AddPermissions(v ...*Permission) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.AddPermissionIDs(ids...) + return _u.AddPermissionIDs(ids...) } // AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (ru *ResourceUpdate) AddPermissionResourceIDs(ids ...int) *ResourceUpdate { - ru.mutation.AddPermissionResourceIDs(ids...) - return ru +func (_u *ResourceUpdate) AddPermissionResourceIDs(ids ...int) *ResourceUpdate { + _u.mutation.AddPermissionResourceIDs(ids...) + return _u } // AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (ru *ResourceUpdate) AddPermissionResources(p ...*PermissionResource) *ResourceUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *ResourceUpdate) AddPermissionResources(v ...*PermissionResource) *ResourceUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.AddPermissionResourceIDs(ids...) + return _u.AddPermissionResourceIDs(ids...) } // Mutation returns the ResourceMutation object of the builder. -func (ru *ResourceUpdate) Mutation() *ResourceMutation { - return ru.mutation +func (_u *ResourceUpdate) Mutation() *ResourceMutation { + return _u.mutation } // ClearChildren clears all "children" edges to the Resource entity. -func (ru *ResourceUpdate) ClearChildren() *ResourceUpdate { - ru.mutation.ClearChildren() - return ru +func (_u *ResourceUpdate) ClearChildren() *ResourceUpdate { + _u.mutation.ClearChildren() + return _u } // RemoveChildIDs removes the "children" edge to Resource entities by IDs. -func (ru *ResourceUpdate) RemoveChildIDs(ids ...int64) *ResourceUpdate { - ru.mutation.RemoveChildIDs(ids...) - return ru +func (_u *ResourceUpdate) RemoveChildIDs(ids ...int64) *ResourceUpdate { + _u.mutation.RemoveChildIDs(ids...) + return _u } // RemoveChildren removes "children" edges to Resource entities. -func (ru *ResourceUpdate) RemoveChildren(r ...*Resource) *ResourceUpdate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *ResourceUpdate) RemoveChildren(v ...*Resource) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.RemoveChildIDs(ids...) + return _u.RemoveChildIDs(ids...) } // ClearParent clears the "parent" edge to the Resource entity. -func (ru *ResourceUpdate) ClearParent() *ResourceUpdate { - ru.mutation.ClearParent() - return ru +func (_u *ResourceUpdate) ClearParent() *ResourceUpdate { + _u.mutation.ClearParent() + return _u } // ClearPermissions clears all "permissions" edges to the Permission entity. -func (ru *ResourceUpdate) ClearPermissions() *ResourceUpdate { - ru.mutation.ClearPermissions() - return ru +func (_u *ResourceUpdate) ClearPermissions() *ResourceUpdate { + _u.mutation.ClearPermissions() + return _u } // RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. -func (ru *ResourceUpdate) RemovePermissionIDs(ids ...int64) *ResourceUpdate { - ru.mutation.RemovePermissionIDs(ids...) - return ru +func (_u *ResourceUpdate) RemovePermissionIDs(ids ...int64) *ResourceUpdate { + _u.mutation.RemovePermissionIDs(ids...) + return _u } // RemovePermissions removes "permissions" edges to Permission entities. -func (ru *ResourceUpdate) RemovePermissions(p ...*Permission) *ResourceUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *ResourceUpdate) RemovePermissions(v ...*Permission) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.RemovePermissionIDs(ids...) + return _u.RemovePermissionIDs(ids...) } // ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. -func (ru *ResourceUpdate) ClearPermissionResources() *ResourceUpdate { - ru.mutation.ClearPermissionResources() - return ru +func (_u *ResourceUpdate) ClearPermissionResources() *ResourceUpdate { + _u.mutation.ClearPermissionResources() + return _u } // RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. -func (ru *ResourceUpdate) RemovePermissionResourceIDs(ids ...int) *ResourceUpdate { - ru.mutation.RemovePermissionResourceIDs(ids...) - return ru +func (_u *ResourceUpdate) RemovePermissionResourceIDs(ids ...int) *ResourceUpdate { + _u.mutation.RemovePermissionResourceIDs(ids...) + return _u } // RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. -func (ru *ResourceUpdate) RemovePermissionResources(p ...*PermissionResource) *ResourceUpdate { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *ResourceUpdate) RemovePermissionResources(v ...*PermissionResource) *ResourceUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.RemovePermissionResourceIDs(ids...) + return _u.RemovePermissionResourceIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. -func (ru *ResourceUpdate) Save(ctx context.Context) (int, error) { - ru.defaults() - return withHooks(ctx, ru.sqlSave, ru.mutation, ru.hooks) +func (_u *ResourceUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (ru *ResourceUpdate) SaveX(ctx context.Context) int { - affected, err := ru.Save(ctx) +func (_u *ResourceUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -440,84 +440,84 @@ func (ru *ResourceUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (ru *ResourceUpdate) Exec(ctx context.Context) error { - _, err := ru.Save(ctx) +func (_u *ResourceUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ru *ResourceUpdate) ExecX(ctx context.Context) { - if err := ru.Exec(ctx); err != nil { +func (_u *ResourceUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (ru *ResourceUpdate) defaults() { - if _, ok := ru.mutation.UpdateTime(); !ok { +func (_u *ResourceUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := resource.UpdateDefaultUpdateTime() - ru.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (ru *ResourceUpdate) check() error { - if v, ok := ru.mutation.Name(); ok { +func (_u *ResourceUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { if err := resource.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} } } - if v, ok := ru.mutation.Keyword(); ok { + if v, ok := _u.mutation.Keyword(); ok { if err := resource.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} } } - if v, ok := ru.mutation.I18nKey(); ok { + if v, ok := _u.mutation.I18nKey(); ok { if err := resource.I18nKeyValidator(v); err != nil { return &ValidationError{Name: "i18n_key", err: fmt.Errorf(`ent: validator failed for field "Resource.i18n_key": %w`, err)} } } - if v, ok := ru.mutation.GetType(); ok { + if v, ok := _u.mutation.GetType(); ok { if err := resource.TypeValidator(v); err != nil { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} } } - if v, ok := ru.mutation.Path(); ok { + if v, ok := _u.mutation.Path(); ok { if err := resource.PathValidator(v); err != nil { return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} } } - if v, ok := ru.mutation.Operation(); ok { + if v, ok := _u.mutation.Operation(); ok { if err := resource.OperationValidator(v); err != nil { return &ValidationError{Name: "operation", err: fmt.Errorf(`ent: validator failed for field "Resource.operation": %w`, err)} } } - if v, ok := ru.mutation.Method(); ok { + if v, ok := _u.mutation.Method(); ok { if err := resource.MethodValidator(v); err != nil { return &ValidationError{Name: "method", err: fmt.Errorf(`ent: validator failed for field "Resource.method": %w`, err)} } } - if v, ok := ru.mutation.Component(); ok { + if v, ok := _u.mutation.Component(); ok { if err := resource.ComponentValidator(v); err != nil { return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} } } - if v, ok := ru.mutation.Icon(); ok { + if v, ok := _u.mutation.Icon(); ok { if err := resource.IconValidator(v); err != nil { return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} } } - if v, ok := ru.mutation.TreePath(); ok { + if v, ok := _u.mutation.TreePath(); ok { if err := resource.TreePathValidator(v); err != nil { return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} } } - if v, ok := ru.mutation.Description(); ok { + if v, ok := _u.mutation.Description(); ok { if err := resource.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} } } - if v, ok := ru.mutation.ParentID(); ok { + if v, ok := _u.mutation.ParentID(); ok { if err := resource.ParentIDValidator(v); err != nil { return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Resource.parent_id": %w`, err)} } @@ -526,87 +526,87 @@ func (ru *ResourceUpdate) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (ru *ResourceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ResourceUpdate { - ru.modifiers = append(ru.modifiers, modifiers...) - return ru +func (_u *ResourceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ResourceUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := ru.check(); err != nil { - return n, err +func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(resource.Table, resource.Columns, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) - if ps := ru.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := ru.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) } - if value, ok := ru.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(resource.FieldName, field.TypeString, value) } - if value, ok := ru.mutation.Keyword(); ok { + if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(resource.FieldKeyword, field.TypeString, value) } - if value, ok := ru.mutation.I18nKey(); ok { + if value, ok := _u.mutation.I18nKey(); ok { _spec.SetField(resource.FieldI18nKey, field.TypeString, value) } - if value, ok := ru.mutation.GetType(); ok { + if value, ok := _u.mutation.GetType(); ok { _spec.SetField(resource.FieldType, field.TypeString, value) } - if value, ok := ru.mutation.Status(); ok { + if value, ok := _u.mutation.Status(); ok { _spec.SetField(resource.FieldStatus, field.TypeInt8, value) } - if value, ok := ru.mutation.AddedStatus(); ok { + if value, ok := _u.mutation.AddedStatus(); ok { _spec.AddField(resource.FieldStatus, field.TypeInt8, value) } - if value, ok := ru.mutation.Path(); ok { + if value, ok := _u.mutation.Path(); ok { _spec.SetField(resource.FieldPath, field.TypeString, value) } - if value, ok := ru.mutation.Operation(); ok { + if value, ok := _u.mutation.Operation(); ok { _spec.SetField(resource.FieldOperation, field.TypeString, value) } - if value, ok := ru.mutation.Method(); ok { + if value, ok := _u.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) } - if value, ok := ru.mutation.Component(); ok { + if value, ok := _u.mutation.Component(); ok { _spec.SetField(resource.FieldComponent, field.TypeString, value) } - if value, ok := ru.mutation.Icon(); ok { + if value, ok := _u.mutation.Icon(); ok { _spec.SetField(resource.FieldIcon, field.TypeString, value) } - if value, ok := ru.mutation.Sequence(); ok { + if value, ok := _u.mutation.Sequence(); ok { _spec.SetField(resource.FieldSequence, field.TypeInt, value) } - if value, ok := ru.mutation.AddedSequence(); ok { + if value, ok := _u.mutation.AddedSequence(); ok { _spec.AddField(resource.FieldSequence, field.TypeInt, value) } - if value, ok := ru.mutation.Visible(); ok { + if value, ok := _u.mutation.Visible(); ok { _spec.SetField(resource.FieldVisible, field.TypeBool, value) } - if value, ok := ru.mutation.Level(); ok { + if value, ok := _u.mutation.Level(); ok { _spec.SetField(resource.FieldLevel, field.TypeInt8, value) } - if value, ok := ru.mutation.AddedLevel(); ok { + if value, ok := _u.mutation.AddedLevel(); ok { _spec.AddField(resource.FieldLevel, field.TypeInt8, value) } - if value, ok := ru.mutation.TreePath(); ok { + if value, ok := _u.mutation.TreePath(); ok { _spec.SetField(resource.FieldTreePath, field.TypeString, value) } - if value, ok := ru.mutation.Properties(); ok { + if value, ok := _u.mutation.Properties(); ok { _spec.SetField(resource.FieldProperties, field.TypeJSON, value) } - if ru.mutation.PropertiesCleared() { + if _u.mutation.PropertiesCleared() { _spec.ClearField(resource.FieldProperties, field.TypeJSON) } - if value, ok := ru.mutation.Description(); ok { + if value, ok := _u.mutation.Description(); ok { _spec.SetField(resource.FieldDescription, field.TypeString, value) } - if ru.mutation.ChildrenCleared() { + if _u.mutation.ChildrenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -619,7 +619,7 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !ru.mutation.ChildrenCleared() { + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -635,7 +635,7 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.ChildrenIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -651,7 +651,7 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ru.mutation.ParentCleared() { + if _u.mutation.ParentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -664,7 +664,7 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.ParentIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -680,7 +680,7 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ru.mutation.PermissionsCleared() { + if _u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -693,7 +693,7 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !ru.mutation.PermissionsCleared() { + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -709,7 +709,7 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.PermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -725,7 +725,7 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ru.mutation.PermissionResourcesCleared() { + if _u.mutation.PermissionResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -738,7 +738,7 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !ru.mutation.PermissionResourcesCleared() { + if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -754,7 +754,7 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -770,8 +770,8 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(ru.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, ru.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{resource.Label} } else if sqlgraph.IsConstraintError(err) { @@ -779,8 +779,8 @@ func (ru *ResourceUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - ru.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // ResourceUpdateOne is the builder for updating a single Resource entity. @@ -793,420 +793,420 @@ type ResourceUpdateOne struct { } // SetUpdateTime sets the "update_time" field. -func (ruo *ResourceUpdateOne) SetUpdateTime(t time.Time) *ResourceUpdateOne { - ruo.mutation.SetUpdateTime(t) - return ruo +func (_u *ResourceUpdateOne) SetUpdateTime(v time.Time) *ResourceUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u } // SetName sets the "name" field. -func (ruo *ResourceUpdateOne) SetName(s string) *ResourceUpdateOne { - ruo.mutation.SetName(s) - return ruo +func (_u *ResourceUpdateOne) SetName(v string) *ResourceUpdateOne { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableName(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetName(*s) +func (_u *ResourceUpdateOne) SetNillableName(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetName(*v) } - return ruo + return _u } // SetKeyword sets the "keyword" field. -func (ruo *ResourceUpdateOne) SetKeyword(s string) *ResourceUpdateOne { - ruo.mutation.SetKeyword(s) - return ruo +func (_u *ResourceUpdateOne) SetKeyword(v string) *ResourceUpdateOne { + _u.mutation.SetKeyword(v) + return _u } // SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableKeyword(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetKeyword(*s) +func (_u *ResourceUpdateOne) SetNillableKeyword(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetKeyword(*v) } - return ruo + return _u } // SetI18nKey sets the "i18n_key" field. -func (ruo *ResourceUpdateOne) SetI18nKey(s string) *ResourceUpdateOne { - ruo.mutation.SetI18nKey(s) - return ruo +func (_u *ResourceUpdateOne) SetI18nKey(v string) *ResourceUpdateOne { + _u.mutation.SetI18nKey(v) + return _u } // SetNillableI18nKey sets the "i18n_key" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableI18nKey(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetI18nKey(*s) +func (_u *ResourceUpdateOne) SetNillableI18nKey(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetI18nKey(*v) } - return ruo + return _u } // SetType sets the "type" field. -func (ruo *ResourceUpdateOne) SetType(s string) *ResourceUpdateOne { - ruo.mutation.SetType(s) - return ruo +func (_u *ResourceUpdateOne) SetType(v string) *ResourceUpdateOne { + _u.mutation.SetType(v) + return _u } // SetNillableType sets the "type" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableType(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetType(*s) +func (_u *ResourceUpdateOne) SetNillableType(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetType(*v) } - return ruo + return _u } // SetStatus sets the "status" field. -func (ruo *ResourceUpdateOne) SetStatus(i int8) *ResourceUpdateOne { - ruo.mutation.ResetStatus() - ruo.mutation.SetStatus(i) - return ruo +func (_u *ResourceUpdateOne) SetStatus(v int8) *ResourceUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableStatus(i *int8) *ResourceUpdateOne { - if i != nil { - ruo.SetStatus(*i) +func (_u *ResourceUpdateOne) SetNillableStatus(v *int8) *ResourceUpdateOne { + if v != nil { + _u.SetStatus(*v) } - return ruo + return _u } -// AddStatus adds i to the "status" field. -func (ruo *ResourceUpdateOne) AddStatus(i int8) *ResourceUpdateOne { - ruo.mutation.AddStatus(i) - return ruo +// AddStatus adds value to the "status" field. +func (_u *ResourceUpdateOne) AddStatus(v int8) *ResourceUpdateOne { + _u.mutation.AddStatus(v) + return _u } // SetPath sets the "path" field. -func (ruo *ResourceUpdateOne) SetPath(s string) *ResourceUpdateOne { - ruo.mutation.SetPath(s) - return ruo +func (_u *ResourceUpdateOne) SetPath(v string) *ResourceUpdateOne { + _u.mutation.SetPath(v) + return _u } // SetNillablePath sets the "path" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillablePath(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetPath(*s) +func (_u *ResourceUpdateOne) SetNillablePath(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetPath(*v) } - return ruo + return _u } // SetOperation sets the "operation" field. -func (ruo *ResourceUpdateOne) SetOperation(s string) *ResourceUpdateOne { - ruo.mutation.SetOperation(s) - return ruo +func (_u *ResourceUpdateOne) SetOperation(v string) *ResourceUpdateOne { + _u.mutation.SetOperation(v) + return _u } // SetNillableOperation sets the "operation" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableOperation(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetOperation(*s) +func (_u *ResourceUpdateOne) SetNillableOperation(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetOperation(*v) } - return ruo + return _u } // SetMethod sets the "method" field. -func (ruo *ResourceUpdateOne) SetMethod(s string) *ResourceUpdateOne { - ruo.mutation.SetMethod(s) - return ruo +func (_u *ResourceUpdateOne) SetMethod(v string) *ResourceUpdateOne { + _u.mutation.SetMethod(v) + return _u } // SetNillableMethod sets the "method" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableMethod(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetMethod(*s) +func (_u *ResourceUpdateOne) SetNillableMethod(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetMethod(*v) } - return ruo + return _u } // SetComponent sets the "component" field. -func (ruo *ResourceUpdateOne) SetComponent(s string) *ResourceUpdateOne { - ruo.mutation.SetComponent(s) - return ruo +func (_u *ResourceUpdateOne) SetComponent(v string) *ResourceUpdateOne { + _u.mutation.SetComponent(v) + return _u } // SetNillableComponent sets the "component" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableComponent(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetComponent(*s) +func (_u *ResourceUpdateOne) SetNillableComponent(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetComponent(*v) } - return ruo + return _u } // SetIcon sets the "icon" field. -func (ruo *ResourceUpdateOne) SetIcon(s string) *ResourceUpdateOne { - ruo.mutation.SetIcon(s) - return ruo +func (_u *ResourceUpdateOne) SetIcon(v string) *ResourceUpdateOne { + _u.mutation.SetIcon(v) + return _u } // SetNillableIcon sets the "icon" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableIcon(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetIcon(*s) +func (_u *ResourceUpdateOne) SetNillableIcon(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetIcon(*v) } - return ruo + return _u } // SetSequence sets the "sequence" field. -func (ruo *ResourceUpdateOne) SetSequence(i int) *ResourceUpdateOne { - ruo.mutation.ResetSequence() - ruo.mutation.SetSequence(i) - return ruo +func (_u *ResourceUpdateOne) SetSequence(v int) *ResourceUpdateOne { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u } // SetNillableSequence sets the "sequence" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableSequence(i *int) *ResourceUpdateOne { - if i != nil { - ruo.SetSequence(*i) +func (_u *ResourceUpdateOne) SetNillableSequence(v *int) *ResourceUpdateOne { + if v != nil { + _u.SetSequence(*v) } - return ruo + return _u } -// AddSequence adds i to the "sequence" field. -func (ruo *ResourceUpdateOne) AddSequence(i int) *ResourceUpdateOne { - ruo.mutation.AddSequence(i) - return ruo +// AddSequence adds value to the "sequence" field. +func (_u *ResourceUpdateOne) AddSequence(v int) *ResourceUpdateOne { + _u.mutation.AddSequence(v) + return _u } // SetVisible sets the "visible" field. -func (ruo *ResourceUpdateOne) SetVisible(b bool) *ResourceUpdateOne { - ruo.mutation.SetVisible(b) - return ruo +func (_u *ResourceUpdateOne) SetVisible(v bool) *ResourceUpdateOne { + _u.mutation.SetVisible(v) + return _u } // SetNillableVisible sets the "visible" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableVisible(b *bool) *ResourceUpdateOne { - if b != nil { - ruo.SetVisible(*b) +func (_u *ResourceUpdateOne) SetNillableVisible(v *bool) *ResourceUpdateOne { + if v != nil { + _u.SetVisible(*v) } - return ruo + return _u } // SetLevel sets the "level" field. -func (ruo *ResourceUpdateOne) SetLevel(i int8) *ResourceUpdateOne { - ruo.mutation.ResetLevel() - ruo.mutation.SetLevel(i) - return ruo +func (_u *ResourceUpdateOne) SetLevel(v int8) *ResourceUpdateOne { + _u.mutation.ResetLevel() + _u.mutation.SetLevel(v) + return _u } // SetNillableLevel sets the "level" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableLevel(i *int8) *ResourceUpdateOne { - if i != nil { - ruo.SetLevel(*i) +func (_u *ResourceUpdateOne) SetNillableLevel(v *int8) *ResourceUpdateOne { + if v != nil { + _u.SetLevel(*v) } - return ruo + return _u } -// AddLevel adds i to the "level" field. -func (ruo *ResourceUpdateOne) AddLevel(i int8) *ResourceUpdateOne { - ruo.mutation.AddLevel(i) - return ruo +// AddLevel adds value to the "level" field. +func (_u *ResourceUpdateOne) AddLevel(v int8) *ResourceUpdateOne { + _u.mutation.AddLevel(v) + return _u } // SetTreePath sets the "tree_path" field. -func (ruo *ResourceUpdateOne) SetTreePath(s string) *ResourceUpdateOne { - ruo.mutation.SetTreePath(s) - return ruo +func (_u *ResourceUpdateOne) SetTreePath(v string) *ResourceUpdateOne { + _u.mutation.SetTreePath(v) + return _u } // SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableTreePath(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetTreePath(*s) +func (_u *ResourceUpdateOne) SetNillableTreePath(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetTreePath(*v) } - return ruo + return _u } // SetProperties sets the "properties" field. -func (ruo *ResourceUpdateOne) SetProperties(m map[string]string) *ResourceUpdateOne { - ruo.mutation.SetProperties(m) - return ruo +func (_u *ResourceUpdateOne) SetProperties(v map[string]string) *ResourceUpdateOne { + _u.mutation.SetProperties(v) + return _u } // ClearProperties clears the value of the "properties" field. -func (ruo *ResourceUpdateOne) ClearProperties() *ResourceUpdateOne { - ruo.mutation.ClearProperties() - return ruo +func (_u *ResourceUpdateOne) ClearProperties() *ResourceUpdateOne { + _u.mutation.ClearProperties() + return _u } // SetDescription sets the "description" field. -func (ruo *ResourceUpdateOne) SetDescription(s string) *ResourceUpdateOne { - ruo.mutation.SetDescription(s) - return ruo +func (_u *ResourceUpdateOne) SetDescription(v string) *ResourceUpdateOne { + _u.mutation.SetDescription(v) + return _u } // SetNillableDescription sets the "description" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableDescription(s *string) *ResourceUpdateOne { - if s != nil { - ruo.SetDescription(*s) +func (_u *ResourceUpdateOne) SetNillableDescription(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetDescription(*v) } - return ruo + return _u } // SetParentID sets the "parent_id" field. -func (ruo *ResourceUpdateOne) SetParentID(i int64) *ResourceUpdateOne { - ruo.mutation.SetParentID(i) - return ruo +func (_u *ResourceUpdateOne) SetParentID(v int64) *ResourceUpdateOne { + _u.mutation.SetParentID(v) + return _u } // SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (ruo *ResourceUpdateOne) SetNillableParentID(i *int64) *ResourceUpdateOne { - if i != nil { - ruo.SetParentID(*i) +func (_u *ResourceUpdateOne) SetNillableParentID(v *int64) *ResourceUpdateOne { + if v != nil { + _u.SetParentID(*v) } - return ruo + return _u } // ClearParentID clears the value of the "parent_id" field. -func (ruo *ResourceUpdateOne) ClearParentID() *ResourceUpdateOne { - ruo.mutation.ClearParentID() - return ruo +func (_u *ResourceUpdateOne) ClearParentID() *ResourceUpdateOne { + _u.mutation.ClearParentID() + return _u } // AddChildIDs adds the "children" edge to the Resource entity by IDs. -func (ruo *ResourceUpdateOne) AddChildIDs(ids ...int64) *ResourceUpdateOne { - ruo.mutation.AddChildIDs(ids...) - return ruo +func (_u *ResourceUpdateOne) AddChildIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.AddChildIDs(ids...) + return _u } // AddChildren adds the "children" edges to the Resource entity. -func (ruo *ResourceUpdateOne) AddChildren(r ...*Resource) *ResourceUpdateOne { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *ResourceUpdateOne) AddChildren(v ...*Resource) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.AddChildIDs(ids...) + return _u.AddChildIDs(ids...) } // SetParent sets the "parent" edge to the Resource entity. -func (ruo *ResourceUpdateOne) SetParent(r *Resource) *ResourceUpdateOne { - return ruo.SetParentID(r.ID) +func (_u *ResourceUpdateOne) SetParent(v *Resource) *ResourceUpdateOne { + return _u.SetParentID(v.ID) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (ruo *ResourceUpdateOne) AddPermissionIDs(ids ...int64) *ResourceUpdateOne { - ruo.mutation.AddPermissionIDs(ids...) - return ruo +func (_u *ResourceUpdateOne) AddPermissionIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.AddPermissionIDs(ids...) + return _u } // AddPermissions adds the "permissions" edges to the Permission entity. -func (ruo *ResourceUpdateOne) AddPermissions(p ...*Permission) *ResourceUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *ResourceUpdateOne) AddPermissions(v ...*Permission) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.AddPermissionIDs(ids...) + return _u.AddPermissionIDs(ids...) } // AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (ruo *ResourceUpdateOne) AddPermissionResourceIDs(ids ...int) *ResourceUpdateOne { - ruo.mutation.AddPermissionResourceIDs(ids...) - return ruo +func (_u *ResourceUpdateOne) AddPermissionResourceIDs(ids ...int) *ResourceUpdateOne { + _u.mutation.AddPermissionResourceIDs(ids...) + return _u } // AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (ruo *ResourceUpdateOne) AddPermissionResources(p ...*PermissionResource) *ResourceUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *ResourceUpdateOne) AddPermissionResources(v ...*PermissionResource) *ResourceUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.AddPermissionResourceIDs(ids...) + return _u.AddPermissionResourceIDs(ids...) } // Mutation returns the ResourceMutation object of the builder. -func (ruo *ResourceUpdateOne) Mutation() *ResourceMutation { - return ruo.mutation +func (_u *ResourceUpdateOne) Mutation() *ResourceMutation { + return _u.mutation } // ClearChildren clears all "children" edges to the Resource entity. -func (ruo *ResourceUpdateOne) ClearChildren() *ResourceUpdateOne { - ruo.mutation.ClearChildren() - return ruo +func (_u *ResourceUpdateOne) ClearChildren() *ResourceUpdateOne { + _u.mutation.ClearChildren() + return _u } // RemoveChildIDs removes the "children" edge to Resource entities by IDs. -func (ruo *ResourceUpdateOne) RemoveChildIDs(ids ...int64) *ResourceUpdateOne { - ruo.mutation.RemoveChildIDs(ids...) - return ruo +func (_u *ResourceUpdateOne) RemoveChildIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.RemoveChildIDs(ids...) + return _u } // RemoveChildren removes "children" edges to Resource entities. -func (ruo *ResourceUpdateOne) RemoveChildren(r ...*Resource) *ResourceUpdateOne { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *ResourceUpdateOne) RemoveChildren(v ...*Resource) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.RemoveChildIDs(ids...) + return _u.RemoveChildIDs(ids...) } // ClearParent clears the "parent" edge to the Resource entity. -func (ruo *ResourceUpdateOne) ClearParent() *ResourceUpdateOne { - ruo.mutation.ClearParent() - return ruo +func (_u *ResourceUpdateOne) ClearParent() *ResourceUpdateOne { + _u.mutation.ClearParent() + return _u } // ClearPermissions clears all "permissions" edges to the Permission entity. -func (ruo *ResourceUpdateOne) ClearPermissions() *ResourceUpdateOne { - ruo.mutation.ClearPermissions() - return ruo +func (_u *ResourceUpdateOne) ClearPermissions() *ResourceUpdateOne { + _u.mutation.ClearPermissions() + return _u } // RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. -func (ruo *ResourceUpdateOne) RemovePermissionIDs(ids ...int64) *ResourceUpdateOne { - ruo.mutation.RemovePermissionIDs(ids...) - return ruo +func (_u *ResourceUpdateOne) RemovePermissionIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.RemovePermissionIDs(ids...) + return _u } // RemovePermissions removes "permissions" edges to Permission entities. -func (ruo *ResourceUpdateOne) RemovePermissions(p ...*Permission) *ResourceUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *ResourceUpdateOne) RemovePermissions(v ...*Permission) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.RemovePermissionIDs(ids...) + return _u.RemovePermissionIDs(ids...) } // ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. -func (ruo *ResourceUpdateOne) ClearPermissionResources() *ResourceUpdateOne { - ruo.mutation.ClearPermissionResources() - return ruo +func (_u *ResourceUpdateOne) ClearPermissionResources() *ResourceUpdateOne { + _u.mutation.ClearPermissionResources() + return _u } // RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. -func (ruo *ResourceUpdateOne) RemovePermissionResourceIDs(ids ...int) *ResourceUpdateOne { - ruo.mutation.RemovePermissionResourceIDs(ids...) - return ruo +func (_u *ResourceUpdateOne) RemovePermissionResourceIDs(ids ...int) *ResourceUpdateOne { + _u.mutation.RemovePermissionResourceIDs(ids...) + return _u } // RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. -func (ruo *ResourceUpdateOne) RemovePermissionResources(p ...*PermissionResource) *ResourceUpdateOne { - ids := make([]int, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *ResourceUpdateOne) RemovePermissionResources(v ...*PermissionResource) *ResourceUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.RemovePermissionResourceIDs(ids...) + return _u.RemovePermissionResourceIDs(ids...) } // Where appends a list predicates to the ResourceUpdate builder. -func (ruo *ResourceUpdateOne) Where(ps ...predicate.Resource) *ResourceUpdateOne { - ruo.mutation.Where(ps...) - return ruo +func (_u *ResourceUpdateOne) Where(ps ...predicate.Resource) *ResourceUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (ruo *ResourceUpdateOne) Select(field string, fields ...string) *ResourceUpdateOne { - ruo.fields = append([]string{field}, fields...) - return ruo +func (_u *ResourceUpdateOne) Select(field string, fields ...string) *ResourceUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Resource entity. -func (ruo *ResourceUpdateOne) Save(ctx context.Context) (*Resource, error) { - ruo.defaults() - return withHooks(ctx, ruo.sqlSave, ruo.mutation, ruo.hooks) +func (_u *ResourceUpdateOne) Save(ctx context.Context) (*Resource, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (ruo *ResourceUpdateOne) SaveX(ctx context.Context) *Resource { - node, err := ruo.Save(ctx) +func (_u *ResourceUpdateOne) SaveX(ctx context.Context) *Resource { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -1214,84 +1214,84 @@ func (ruo *ResourceUpdateOne) SaveX(ctx context.Context) *Resource { } // Exec executes the query on the entity. -func (ruo *ResourceUpdateOne) Exec(ctx context.Context) error { - _, err := ruo.Save(ctx) +func (_u *ResourceUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ruo *ResourceUpdateOne) ExecX(ctx context.Context) { - if err := ruo.Exec(ctx); err != nil { +func (_u *ResourceUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (ruo *ResourceUpdateOne) defaults() { - if _, ok := ruo.mutation.UpdateTime(); !ok { +func (_u *ResourceUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := resource.UpdateDefaultUpdateTime() - ruo.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (ruo *ResourceUpdateOne) check() error { - if v, ok := ruo.mutation.Name(); ok { +func (_u *ResourceUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { if err := resource.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} } } - if v, ok := ruo.mutation.Keyword(); ok { + if v, ok := _u.mutation.Keyword(); ok { if err := resource.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} } } - if v, ok := ruo.mutation.I18nKey(); ok { + if v, ok := _u.mutation.I18nKey(); ok { if err := resource.I18nKeyValidator(v); err != nil { return &ValidationError{Name: "i18n_key", err: fmt.Errorf(`ent: validator failed for field "Resource.i18n_key": %w`, err)} } } - if v, ok := ruo.mutation.GetType(); ok { + if v, ok := _u.mutation.GetType(); ok { if err := resource.TypeValidator(v); err != nil { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} } } - if v, ok := ruo.mutation.Path(); ok { + if v, ok := _u.mutation.Path(); ok { if err := resource.PathValidator(v); err != nil { return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} } } - if v, ok := ruo.mutation.Operation(); ok { + if v, ok := _u.mutation.Operation(); ok { if err := resource.OperationValidator(v); err != nil { return &ValidationError{Name: "operation", err: fmt.Errorf(`ent: validator failed for field "Resource.operation": %w`, err)} } } - if v, ok := ruo.mutation.Method(); ok { + if v, ok := _u.mutation.Method(); ok { if err := resource.MethodValidator(v); err != nil { return &ValidationError{Name: "method", err: fmt.Errorf(`ent: validator failed for field "Resource.method": %w`, err)} } } - if v, ok := ruo.mutation.Component(); ok { + if v, ok := _u.mutation.Component(); ok { if err := resource.ComponentValidator(v); err != nil { return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} } } - if v, ok := ruo.mutation.Icon(); ok { + if v, ok := _u.mutation.Icon(); ok { if err := resource.IconValidator(v); err != nil { return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} } } - if v, ok := ruo.mutation.TreePath(); ok { + if v, ok := _u.mutation.TreePath(); ok { if err := resource.TreePathValidator(v); err != nil { return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} } } - if v, ok := ruo.mutation.Description(); ok { + if v, ok := _u.mutation.Description(); ok { if err := resource.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} } } - if v, ok := ruo.mutation.ParentID(); ok { + if v, ok := _u.mutation.ParentID(); ok { if err := resource.ParentIDValidator(v); err != nil { return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Resource.parent_id": %w`, err)} } @@ -1300,22 +1300,22 @@ func (ruo *ResourceUpdateOne) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (ruo *ResourceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ResourceUpdateOne { - ruo.modifiers = append(ruo.modifiers, modifiers...) - return ruo +func (_u *ResourceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ResourceUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err error) { - if err := ruo.check(); err != nil { +func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(resource.Table, resource.Columns, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) - id, ok := ruo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Resource.id" for update`)} } _spec.Node.ID.Value = id - if fields := ruo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, resource.FieldID) for _, f := range fields { @@ -1327,77 +1327,77 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } } } - if ps := ruo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := ruo.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) } - if value, ok := ruo.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(resource.FieldName, field.TypeString, value) } - if value, ok := ruo.mutation.Keyword(); ok { + if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(resource.FieldKeyword, field.TypeString, value) } - if value, ok := ruo.mutation.I18nKey(); ok { + if value, ok := _u.mutation.I18nKey(); ok { _spec.SetField(resource.FieldI18nKey, field.TypeString, value) } - if value, ok := ruo.mutation.GetType(); ok { + if value, ok := _u.mutation.GetType(); ok { _spec.SetField(resource.FieldType, field.TypeString, value) } - if value, ok := ruo.mutation.Status(); ok { + if value, ok := _u.mutation.Status(); ok { _spec.SetField(resource.FieldStatus, field.TypeInt8, value) } - if value, ok := ruo.mutation.AddedStatus(); ok { + if value, ok := _u.mutation.AddedStatus(); ok { _spec.AddField(resource.FieldStatus, field.TypeInt8, value) } - if value, ok := ruo.mutation.Path(); ok { + if value, ok := _u.mutation.Path(); ok { _spec.SetField(resource.FieldPath, field.TypeString, value) } - if value, ok := ruo.mutation.Operation(); ok { + if value, ok := _u.mutation.Operation(); ok { _spec.SetField(resource.FieldOperation, field.TypeString, value) } - if value, ok := ruo.mutation.Method(); ok { + if value, ok := _u.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) } - if value, ok := ruo.mutation.Component(); ok { + if value, ok := _u.mutation.Component(); ok { _spec.SetField(resource.FieldComponent, field.TypeString, value) } - if value, ok := ruo.mutation.Icon(); ok { + if value, ok := _u.mutation.Icon(); ok { _spec.SetField(resource.FieldIcon, field.TypeString, value) } - if value, ok := ruo.mutation.Sequence(); ok { + if value, ok := _u.mutation.Sequence(); ok { _spec.SetField(resource.FieldSequence, field.TypeInt, value) } - if value, ok := ruo.mutation.AddedSequence(); ok { + if value, ok := _u.mutation.AddedSequence(); ok { _spec.AddField(resource.FieldSequence, field.TypeInt, value) } - if value, ok := ruo.mutation.Visible(); ok { + if value, ok := _u.mutation.Visible(); ok { _spec.SetField(resource.FieldVisible, field.TypeBool, value) } - if value, ok := ruo.mutation.Level(); ok { + if value, ok := _u.mutation.Level(); ok { _spec.SetField(resource.FieldLevel, field.TypeInt8, value) } - if value, ok := ruo.mutation.AddedLevel(); ok { + if value, ok := _u.mutation.AddedLevel(); ok { _spec.AddField(resource.FieldLevel, field.TypeInt8, value) } - if value, ok := ruo.mutation.TreePath(); ok { + if value, ok := _u.mutation.TreePath(); ok { _spec.SetField(resource.FieldTreePath, field.TypeString, value) } - if value, ok := ruo.mutation.Properties(); ok { + if value, ok := _u.mutation.Properties(); ok { _spec.SetField(resource.FieldProperties, field.TypeJSON, value) } - if ruo.mutation.PropertiesCleared() { + if _u.mutation.PropertiesCleared() { _spec.ClearField(resource.FieldProperties, field.TypeJSON) } - if value, ok := ruo.mutation.Description(); ok { + if value, ok := _u.mutation.Description(); ok { _spec.SetField(resource.FieldDescription, field.TypeString, value) } - if ruo.mutation.ChildrenCleared() { + if _u.mutation.ChildrenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1410,7 +1410,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !ruo.mutation.ChildrenCleared() { + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1426,7 +1426,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.ChildrenIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1442,7 +1442,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ruo.mutation.ParentCleared() { + if _u.mutation.ParentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -1455,7 +1455,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.ParentIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -1471,7 +1471,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ruo.mutation.PermissionsCleared() { + if _u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1484,7 +1484,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !ruo.mutation.PermissionsCleared() { + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1500,7 +1500,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.PermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1516,7 +1516,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ruo.mutation.PermissionResourcesCleared() { + if _u.mutation.PermissionResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1529,7 +1529,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !ruo.mutation.PermissionResourcesCleared() { + if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1545,7 +1545,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1561,11 +1561,11 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(ruo.modifiers...) - _node = &Resource{config: ruo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Resource{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, ruo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{resource.Label} } else if sqlgraph.IsConstraintError(err) { @@ -1573,7 +1573,7 @@ func (ruo *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } return nil, err } - ruo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/role.go b/internal/data/entity/ent/role.go index 5703d67b..039ff361 100644 --- a/internal/data/entity/ent/role.go +++ b/internal/data/entity/ent/role.go @@ -111,7 +111,7 @@ func (*Role) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Role fields. -func (r *Role) assignValues(columns []string, values []any) error { +func (_m *Role) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -122,57 +122,57 @@ func (r *Role) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - r.ID = int64(value.Int64) + _m.ID = int64(value.Int64) case role.FieldCreateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field create_time", values[i]) } else if value.Valid { - r.CreateTime = value.Time + _m.CreateTime = value.Time } case role.FieldUpdateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field update_time", values[i]) } else if value.Valid { - r.UpdateTime = value.Time + _m.UpdateTime = value.Time } case role.FieldKeyword: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field keyword", values[i]) } else if value.Valid { - r.Keyword = value.String + _m.Keyword = value.String } case role.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { - r.Name = value.String + _m.Name = value.String } case role.FieldDescription: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field description", values[i]) } else if value.Valid { - r.Description = value.String + _m.Description = value.String } case role.FieldType: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) } else if value.Valid { - r.Type = int8(value.Int64) + _m.Type = int8(value.Int64) } case role.FieldSequence: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field sequence", values[i]) } else if value.Valid { - r.Sequence = int(value.Int64) + _m.Sequence = int(value.Int64) } case role.FieldStatus: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - r.Status = int8(value.Int64) + _m.Status = int8(value.Int64) } default: - r.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -180,76 +180,76 @@ func (r *Role) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Role. // This includes values selected through modifiers, order, etc. -func (r *Role) Value(name string) (ent.Value, error) { - return r.selectValues.Get(name) +func (_m *Role) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryUsers queries the "users" edge of the Role entity. -func (r *Role) QueryUsers() *UserQuery { - return NewRoleClient(r.config).QueryUsers(r) +func (_m *Role) QueryUsers() *UserQuery { + return NewRoleClient(_m.config).QueryUsers(_m) } // QueryPermissions queries the "permissions" edge of the Role entity. -func (r *Role) QueryPermissions() *PermissionQuery { - return NewRoleClient(r.config).QueryPermissions(r) +func (_m *Role) QueryPermissions() *PermissionQuery { + return NewRoleClient(_m.config).QueryPermissions(_m) } // QueryUserRoles queries the "user_roles" edge of the Role entity. -func (r *Role) QueryUserRoles() *UserRoleQuery { - return NewRoleClient(r.config).QueryUserRoles(r) +func (_m *Role) QueryUserRoles() *UserRoleQuery { + return NewRoleClient(_m.config).QueryUserRoles(_m) } // QueryRolePermissions queries the "role_permissions" edge of the Role entity. -func (r *Role) QueryRolePermissions() *RolePermissionQuery { - return NewRoleClient(r.config).QueryRolePermissions(r) +func (_m *Role) QueryRolePermissions() *RolePermissionQuery { + return NewRoleClient(_m.config).QueryRolePermissions(_m) } // Update returns a builder for updating this Role. // Note that you need to call Role.Unwrap() before calling this method if this Role // was returned from a transaction, and the transaction was committed or rolled back. -func (r *Role) Update() *RoleUpdateOne { - return NewRoleClient(r.config).UpdateOne(r) +func (_m *Role) Update() *RoleUpdateOne { + return NewRoleClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Role entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (r *Role) Unwrap() *Role { - _tx, ok := r.config.driver.(*txDriver) +func (_m *Role) Unwrap() *Role { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Role is not a transactional entity") } - r.config.driver = _tx.drv - return r + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (r *Role) String() string { +func (_m *Role) String() string { var builder strings.Builder builder.WriteString("Role(") - builder.WriteString(fmt.Sprintf("id=%v, ", r.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("create_time=") - builder.WriteString(r.CreateTime.Format(time.ANSIC)) + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("update_time=") - builder.WriteString(r.UpdateTime.Format(time.ANSIC)) + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("keyword=") - builder.WriteString(r.Keyword) + builder.WriteString(_m.Keyword) builder.WriteString(", ") builder.WriteString("name=") - builder.WriteString(r.Name) + builder.WriteString(_m.Name) builder.WriteString(", ") builder.WriteString("description=") - builder.WriteString(r.Description) + builder.WriteString(_m.Description) builder.WriteString(", ") builder.WriteString("type=") - builder.WriteString(fmt.Sprintf("%v", r.Type)) + builder.WriteString(fmt.Sprintf("%v", _m.Type)) builder.WriteString(", ") builder.WriteString("sequence=") - builder.WriteString(fmt.Sprintf("%v", r.Sequence)) + builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) builder.WriteString(", ") builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", r.Status)) + builder.WriteString(fmt.Sprintf("%v", _m.Status)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/role_create.go b/internal/data/entity/ent/role_create.go index 5f3e0635..149e169e 100644 --- a/internal/data/entity/ent/role_create.go +++ b/internal/data/entity/ent/role_create.go @@ -25,197 +25,197 @@ type RoleCreate struct { } // SetCreateTime sets the "create_time" field. -func (rc *RoleCreate) SetCreateTime(t time.Time) *RoleCreate { - rc.mutation.SetCreateTime(t) - return rc +func (_c *RoleCreate) SetCreateTime(v time.Time) *RoleCreate { + _c.mutation.SetCreateTime(v) + return _c } // SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (rc *RoleCreate) SetNillableCreateTime(t *time.Time) *RoleCreate { - if t != nil { - rc.SetCreateTime(*t) +func (_c *RoleCreate) SetNillableCreateTime(v *time.Time) *RoleCreate { + if v != nil { + _c.SetCreateTime(*v) } - return rc + return _c } // SetUpdateTime sets the "update_time" field. -func (rc *RoleCreate) SetUpdateTime(t time.Time) *RoleCreate { - rc.mutation.SetUpdateTime(t) - return rc +func (_c *RoleCreate) SetUpdateTime(v time.Time) *RoleCreate { + _c.mutation.SetUpdateTime(v) + return _c } // SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (rc *RoleCreate) SetNillableUpdateTime(t *time.Time) *RoleCreate { - if t != nil { - rc.SetUpdateTime(*t) +func (_c *RoleCreate) SetNillableUpdateTime(v *time.Time) *RoleCreate { + if v != nil { + _c.SetUpdateTime(*v) } - return rc + return _c } // SetKeyword sets the "keyword" field. -func (rc *RoleCreate) SetKeyword(s string) *RoleCreate { - rc.mutation.SetKeyword(s) - return rc +func (_c *RoleCreate) SetKeyword(v string) *RoleCreate { + _c.mutation.SetKeyword(v) + return _c } // SetName sets the "name" field. -func (rc *RoleCreate) SetName(s string) *RoleCreate { - rc.mutation.SetName(s) - return rc +func (_c *RoleCreate) SetName(v string) *RoleCreate { + _c.mutation.SetName(v) + return _c } // SetNillableName sets the "name" field if the given value is not nil. -func (rc *RoleCreate) SetNillableName(s *string) *RoleCreate { - if s != nil { - rc.SetName(*s) +func (_c *RoleCreate) SetNillableName(v *string) *RoleCreate { + if v != nil { + _c.SetName(*v) } - return rc + return _c } // SetDescription sets the "description" field. -func (rc *RoleCreate) SetDescription(s string) *RoleCreate { - rc.mutation.SetDescription(s) - return rc +func (_c *RoleCreate) SetDescription(v string) *RoleCreate { + _c.mutation.SetDescription(v) + return _c } // SetNillableDescription sets the "description" field if the given value is not nil. -func (rc *RoleCreate) SetNillableDescription(s *string) *RoleCreate { - if s != nil { - rc.SetDescription(*s) +func (_c *RoleCreate) SetNillableDescription(v *string) *RoleCreate { + if v != nil { + _c.SetDescription(*v) } - return rc + return _c } // SetType sets the "type" field. -func (rc *RoleCreate) SetType(i int8) *RoleCreate { - rc.mutation.SetType(i) - return rc +func (_c *RoleCreate) SetType(v int8) *RoleCreate { + _c.mutation.SetType(v) + return _c } // SetNillableType sets the "type" field if the given value is not nil. -func (rc *RoleCreate) SetNillableType(i *int8) *RoleCreate { - if i != nil { - rc.SetType(*i) +func (_c *RoleCreate) SetNillableType(v *int8) *RoleCreate { + if v != nil { + _c.SetType(*v) } - return rc + return _c } // SetSequence sets the "sequence" field. -func (rc *RoleCreate) SetSequence(i int) *RoleCreate { - rc.mutation.SetSequence(i) - return rc +func (_c *RoleCreate) SetSequence(v int) *RoleCreate { + _c.mutation.SetSequence(v) + return _c } // SetNillableSequence sets the "sequence" field if the given value is not nil. -func (rc *RoleCreate) SetNillableSequence(i *int) *RoleCreate { - if i != nil { - rc.SetSequence(*i) +func (_c *RoleCreate) SetNillableSequence(v *int) *RoleCreate { + if v != nil { + _c.SetSequence(*v) } - return rc + return _c } // SetStatus sets the "status" field. -func (rc *RoleCreate) SetStatus(i int8) *RoleCreate { - rc.mutation.SetStatus(i) - return rc +func (_c *RoleCreate) SetStatus(v int8) *RoleCreate { + _c.mutation.SetStatus(v) + return _c } // SetNillableStatus sets the "status" field if the given value is not nil. -func (rc *RoleCreate) SetNillableStatus(i *int8) *RoleCreate { - if i != nil { - rc.SetStatus(*i) +func (_c *RoleCreate) SetNillableStatus(v *int8) *RoleCreate { + if v != nil { + _c.SetStatus(*v) } - return rc + return _c } // SetID sets the "id" field. -func (rc *RoleCreate) SetID(i int64) *RoleCreate { - rc.mutation.SetID(i) - return rc +func (_c *RoleCreate) SetID(v int64) *RoleCreate { + _c.mutation.SetID(v) + return _c } // SetNillableID sets the "id" field if the given value is not nil. -func (rc *RoleCreate) SetNillableID(i *int64) *RoleCreate { - if i != nil { - rc.SetID(*i) +func (_c *RoleCreate) SetNillableID(v *int64) *RoleCreate { + if v != nil { + _c.SetID(*v) } - return rc + return _c } // AddUserIDs adds the "users" edge to the User entity by IDs. -func (rc *RoleCreate) AddUserIDs(ids ...int64) *RoleCreate { - rc.mutation.AddUserIDs(ids...) - return rc +func (_c *RoleCreate) AddUserIDs(ids ...int64) *RoleCreate { + _c.mutation.AddUserIDs(ids...) + return _c } // AddUsers adds the "users" edges to the User entity. -func (rc *RoleCreate) AddUsers(u ...*User) *RoleCreate { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_c *RoleCreate) AddUsers(v ...*User) *RoleCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return rc.AddUserIDs(ids...) + return _c.AddUserIDs(ids...) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (rc *RoleCreate) AddPermissionIDs(ids ...int64) *RoleCreate { - rc.mutation.AddPermissionIDs(ids...) - return rc +func (_c *RoleCreate) AddPermissionIDs(ids ...int64) *RoleCreate { + _c.mutation.AddPermissionIDs(ids...) + return _c } // AddPermissions adds the "permissions" edges to the Permission entity. -func (rc *RoleCreate) AddPermissions(p ...*Permission) *RoleCreate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *RoleCreate) AddPermissions(v ...*Permission) *RoleCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return rc.AddPermissionIDs(ids...) + return _c.AddPermissionIDs(ids...) } // AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (rc *RoleCreate) AddUserRoleIDs(ids ...int) *RoleCreate { - rc.mutation.AddUserRoleIDs(ids...) - return rc +func (_c *RoleCreate) AddUserRoleIDs(ids ...int) *RoleCreate { + _c.mutation.AddUserRoleIDs(ids...) + return _c } // AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (rc *RoleCreate) AddUserRoles(u ...*UserRole) *RoleCreate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_c *RoleCreate) AddUserRoles(v ...*UserRole) *RoleCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return rc.AddUserRoleIDs(ids...) + return _c.AddUserRoleIDs(ids...) } // AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (rc *RoleCreate) AddRolePermissionIDs(ids ...int) *RoleCreate { - rc.mutation.AddRolePermissionIDs(ids...) - return rc +func (_c *RoleCreate) AddRolePermissionIDs(ids ...int) *RoleCreate { + _c.mutation.AddRolePermissionIDs(ids...) + return _c } // AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (rc *RoleCreate) AddRolePermissions(r ...*RolePermission) *RoleCreate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_c *RoleCreate) AddRolePermissions(v ...*RolePermission) *RoleCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return rc.AddRolePermissionIDs(ids...) + return _c.AddRolePermissionIDs(ids...) } // Mutation returns the RoleMutation object of the builder. -func (rc *RoleCreate) Mutation() *RoleMutation { - return rc.mutation +func (_c *RoleCreate) Mutation() *RoleMutation { + return _c.mutation } // Save creates the Role in the database. -func (rc *RoleCreate) Save(ctx context.Context) (*Role, error) { - rc.defaults() - return withHooks(ctx, rc.sqlSave, rc.mutation, rc.hooks) +func (_c *RoleCreate) Save(ctx context.Context) (*Role, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (rc *RoleCreate) SaveX(ctx context.Context) *Role { - v, err := rc.Save(ctx) +func (_c *RoleCreate) SaveX(ctx context.Context) *Role { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -223,96 +223,96 @@ func (rc *RoleCreate) SaveX(ctx context.Context) *Role { } // Exec executes the query. -func (rc *RoleCreate) Exec(ctx context.Context) error { - _, err := rc.Save(ctx) +func (_c *RoleCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rc *RoleCreate) ExecX(ctx context.Context) { - if err := rc.Exec(ctx); err != nil { +func (_c *RoleCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (rc *RoleCreate) defaults() { - if _, ok := rc.mutation.CreateTime(); !ok { +func (_c *RoleCreate) defaults() { + if _, ok := _c.mutation.CreateTime(); !ok { v := role.DefaultCreateTime() - rc.mutation.SetCreateTime(v) + _c.mutation.SetCreateTime(v) } - if _, ok := rc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { v := role.DefaultUpdateTime() - rc.mutation.SetUpdateTime(v) + _c.mutation.SetUpdateTime(v) } - if _, ok := rc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { v := role.DefaultName - rc.mutation.SetName(v) + _c.mutation.SetName(v) } - if _, ok := rc.mutation.Description(); !ok { + if _, ok := _c.mutation.Description(); !ok { v := role.DefaultDescription - rc.mutation.SetDescription(v) + _c.mutation.SetDescription(v) } - if _, ok := rc.mutation.GetType(); !ok { + if _, ok := _c.mutation.GetType(); !ok { v := role.DefaultType - rc.mutation.SetType(v) + _c.mutation.SetType(v) } - if _, ok := rc.mutation.Sequence(); !ok { + if _, ok := _c.mutation.Sequence(); !ok { v := role.DefaultSequence - rc.mutation.SetSequence(v) + _c.mutation.SetSequence(v) } - if _, ok := rc.mutation.Status(); !ok { + if _, ok := _c.mutation.Status(); !ok { v := role.DefaultStatus - rc.mutation.SetStatus(v) + _c.mutation.SetStatus(v) } - if _, ok := rc.mutation.ID(); !ok { + if _, ok := _c.mutation.ID(); !ok { v := role.DefaultID() - rc.mutation.SetID(v) + _c.mutation.SetID(v) } } // check runs all checks and user-defined validators on the builder. -func (rc *RoleCreate) check() error { - if _, ok := rc.mutation.CreateTime(); !ok { +func (_c *RoleCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Role.create_time"`)} } - if _, ok := rc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Role.update_time"`)} } - if _, ok := rc.mutation.Keyword(); !ok { + if _, ok := _c.mutation.Keyword(); !ok { return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Role.keyword"`)} } - if v, ok := rc.mutation.Keyword(); ok { + if v, ok := _c.mutation.Keyword(); ok { if err := role.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Role.keyword": %w`, err)} } } - if _, ok := rc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Role.name"`)} } - if v, ok := rc.mutation.Name(); ok { + if v, ok := _c.mutation.Name(); ok { if err := role.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Role.name": %w`, err)} } } - if _, ok := rc.mutation.Description(); !ok { + if _, ok := _c.mutation.Description(); !ok { return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Role.description"`)} } - if v, ok := rc.mutation.Description(); ok { + if v, ok := _c.mutation.Description(); ok { if err := role.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Role.description": %w`, err)} } } - if _, ok := rc.mutation.GetType(); !ok { + if _, ok := _c.mutation.GetType(); !ok { return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Role.type"`)} } - if _, ok := rc.mutation.Sequence(); !ok { + if _, ok := _c.mutation.Sequence(); !ok { return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "Role.sequence"`)} } - if _, ok := rc.mutation.Status(); !ok { + if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Role.status"`)} } - if v, ok := rc.mutation.ID(); ok { + if v, ok := _c.mutation.ID(); ok { if err := role.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Role.id": %w`, err)} } @@ -320,12 +320,12 @@ func (rc *RoleCreate) check() error { return nil } -func (rc *RoleCreate) sqlSave(ctx context.Context) (*Role, error) { - if err := rc.check(); err != nil { +func (_c *RoleCreate) sqlSave(ctx context.Context) (*Role, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := rc.createSpec() - if err := sqlgraph.CreateNode(ctx, rc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -335,53 +335,53 @@ func (rc *RoleCreate) sqlSave(ctx context.Context) (*Role, error) { id := _spec.ID.Value.(int64) _node.ID = int64(id) } - rc.mutation.id = &_node.ID - rc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (rc *RoleCreate) createSpec() (*Role, *sqlgraph.CreateSpec) { +func (_c *RoleCreate) createSpec() (*Role, *sqlgraph.CreateSpec) { var ( - _node = &Role{config: rc.config} + _node = &Role{config: _c.config} _spec = sqlgraph.NewCreateSpec(role.Table, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) ) - if id, ok := rc.mutation.ID(); ok { + if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } - if value, ok := rc.mutation.CreateTime(); ok { + if value, ok := _c.mutation.CreateTime(); ok { _spec.SetField(role.FieldCreateTime, field.TypeTime, value) _node.CreateTime = value } - if value, ok := rc.mutation.UpdateTime(); ok { + if value, ok := _c.mutation.UpdateTime(); ok { _spec.SetField(role.FieldUpdateTime, field.TypeTime, value) _node.UpdateTime = value } - if value, ok := rc.mutation.Keyword(); ok { + if value, ok := _c.mutation.Keyword(); ok { _spec.SetField(role.FieldKeyword, field.TypeString, value) _node.Keyword = value } - if value, ok := rc.mutation.Name(); ok { + if value, ok := _c.mutation.Name(); ok { _spec.SetField(role.FieldName, field.TypeString, value) _node.Name = value } - if value, ok := rc.mutation.Description(); ok { + if value, ok := _c.mutation.Description(); ok { _spec.SetField(role.FieldDescription, field.TypeString, value) _node.Description = value } - if value, ok := rc.mutation.GetType(); ok { + if value, ok := _c.mutation.GetType(); ok { _spec.SetField(role.FieldType, field.TypeInt8, value) _node.Type = value } - if value, ok := rc.mutation.Sequence(); ok { + if value, ok := _c.mutation.Sequence(); ok { _spec.SetField(role.FieldSequence, field.TypeInt, value) _node.Sequence = value } - if value, ok := rc.mutation.Status(); ok { + if value, ok := _c.mutation.Status(); ok { _spec.SetField(role.FieldStatus, field.TypeInt8, value) _node.Status = value } - if nodes := rc.mutation.UsersIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UsersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -397,7 +397,7 @@ func (rc *RoleCreate) createSpec() (*Role, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := rc.mutation.PermissionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -413,7 +413,7 @@ func (rc *RoleCreate) createSpec() (*Role, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := rc.mutation.UserRolesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UserRolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -429,7 +429,7 @@ func (rc *RoleCreate) createSpec() (*Role, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := rc.mutation.RolePermissionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.RolePermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -449,23 +449,23 @@ func (rc *RoleCreate) createSpec() (*Role, *sqlgraph.CreateSpec) { } // SetRole set the Role -func (rc *RoleCreate) SetRole(input *Role, fields ...string) *RoleCreate { - m := rc.mutation +func (_c *RoleCreate) SetRole(input *Role, fields ...string) *RoleCreate { + m := _c.mutation if len(fields) == 0 { fields = role.Columns } _ = m.SetFields(input, fields...) - return rc + return _c } // SetRoleWithZero set the Role -func (rc *RoleCreate) SetRoleWithZero(input *Role, fields ...string) *RoleCreate { - m := rc.mutation +func (_c *RoleCreate) SetRoleWithZero(input *Role, fields ...string) *RoleCreate { + m := _c.mutation if len(fields) == 0 { fields = role.Columns } _ = m.SetFieldsWithZero(input, fields...) - return rc + return _c } // RoleCreateBulk is the builder for creating many Role entities in bulk. @@ -476,16 +476,16 @@ type RoleCreateBulk struct { } // Save creates the Role entities in the database. -func (rcb *RoleCreateBulk) Save(ctx context.Context) ([]*Role, error) { - if rcb.err != nil { - return nil, rcb.err - } - specs := make([]*sqlgraph.CreateSpec, len(rcb.builders)) - nodes := make([]*Role, len(rcb.builders)) - mutators := make([]Mutator, len(rcb.builders)) - for i := range rcb.builders { +func (_c *RoleCreateBulk) Save(ctx context.Context) ([]*Role, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Role, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := rcb.builders[i] + builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*RoleMutation) @@ -499,11 +499,11 @@ func (rcb *RoleCreateBulk) Save(ctx context.Context) ([]*Role, error) { var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, rcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, rcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -527,7 +527,7 @@ func (rcb *RoleCreateBulk) Save(ctx context.Context) ([]*Role, error) { }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, rcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -535,8 +535,8 @@ func (rcb *RoleCreateBulk) Save(ctx context.Context) ([]*Role, error) { } // SaveX is like Save, but panics if an error occurs. -func (rcb *RoleCreateBulk) SaveX(ctx context.Context) []*Role { - v, err := rcb.Save(ctx) +func (_c *RoleCreateBulk) SaveX(ctx context.Context) []*Role { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -544,14 +544,14 @@ func (rcb *RoleCreateBulk) SaveX(ctx context.Context) []*Role { } // Exec executes the query. -func (rcb *RoleCreateBulk) Exec(ctx context.Context) error { - _, err := rcb.Save(ctx) +func (_c *RoleCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rcb *RoleCreateBulk) ExecX(ctx context.Context) { - if err := rcb.Exec(ctx); err != nil { +func (_c *RoleCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/role_delete.go b/internal/data/entity/ent/role_delete.go index 08fe7606..4e52d20e 100644 --- a/internal/data/entity/ent/role_delete.go +++ b/internal/data/entity/ent/role_delete.go @@ -20,56 +20,56 @@ type RoleDelete struct { } // Where appends a list predicates to the RoleDelete builder. -func (rd *RoleDelete) Where(ps ...predicate.Role) *RoleDelete { - rd.mutation.Where(ps...) - return rd +func (_d *RoleDelete) Where(ps ...predicate.Role) *RoleDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (rd *RoleDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, rd.sqlExec, rd.mutation, rd.hooks) +func (_d *RoleDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (rd *RoleDelete) ExecX(ctx context.Context) int { - n, err := rd.Exec(ctx) +func (_d *RoleDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (rd *RoleDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *RoleDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(role.Table, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) - if ps := rd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, rd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - rd.mutation.done = true + _d.mutation.done = true return affected, err } // RoleDeleteOne is the builder for deleting a single Role entity. type RoleDeleteOne struct { - rd *RoleDelete + _d *RoleDelete } // Where appends a list predicates to the RoleDelete builder. -func (rdo *RoleDeleteOne) Where(ps ...predicate.Role) *RoleDeleteOne { - rdo.rd.mutation.Where(ps...) - return rdo +func (_d *RoleDeleteOne) Where(ps ...predicate.Role) *RoleDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (rdo *RoleDeleteOne) Exec(ctx context.Context) error { - n, err := rdo.rd.Exec(ctx) +func (_d *RoleDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (rdo *RoleDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (rdo *RoleDeleteOne) ExecX(ctx context.Context) { - if err := rdo.Exec(ctx); err != nil { +func (_d *RoleDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/role_query.go b/internal/data/entity/ent/role_query.go index c18c9337..ca912788 100644 --- a/internal/data/entity/ent/role_query.go +++ b/internal/data/entity/ent/role_query.go @@ -39,44 +39,44 @@ type RoleQuery struct { } // Where adds a new predicate for the RoleQuery builder. -func (rq *RoleQuery) Where(ps ...predicate.Role) *RoleQuery { - rq.predicates = append(rq.predicates, ps...) - return rq +func (_q *RoleQuery) Where(ps ...predicate.Role) *RoleQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (rq *RoleQuery) Limit(limit int) *RoleQuery { - rq.ctx.Limit = &limit - return rq +func (_q *RoleQuery) Limit(limit int) *RoleQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (rq *RoleQuery) Offset(offset int) *RoleQuery { - rq.ctx.Offset = &offset - return rq +func (_q *RoleQuery) Offset(offset int) *RoleQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (rq *RoleQuery) Unique(unique bool) *RoleQuery { - rq.ctx.Unique = &unique - return rq +func (_q *RoleQuery) Unique(unique bool) *RoleQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (rq *RoleQuery) Order(o ...role.OrderOption) *RoleQuery { - rq.order = append(rq.order, o...) - return rq +func (_q *RoleQuery) Order(o ...role.OrderOption) *RoleQuery { + _q.order = append(_q.order, o...) + return _q } // QueryUsers chains the current query on the "users" edge. -func (rq *RoleQuery) QueryUsers() *UserQuery { - query := (&UserClient{config: rq.config}).Query() +func (_q *RoleQuery) QueryUsers() *UserQuery { + query := (&UserClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -85,20 +85,20 @@ func (rq *RoleQuery) QueryUsers() *UserQuery { sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, role.UsersTable, role.UsersPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPermissions chains the current query on the "permissions" edge. -func (rq *RoleQuery) QueryPermissions() *PermissionQuery { - query := (&PermissionClient{config: rq.config}).Query() +func (_q *RoleQuery) QueryPermissions() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -107,20 +107,20 @@ func (rq *RoleQuery) QueryPermissions() *PermissionQuery { sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, role.PermissionsTable, role.PermissionsPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryUserRoles chains the current query on the "user_roles" edge. -func (rq *RoleQuery) QueryUserRoles() *UserRoleQuery { - query := (&UserRoleClient{config: rq.config}).Query() +func (_q *RoleQuery) QueryUserRoles() *UserRoleQuery { + query := (&UserRoleClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -129,20 +129,20 @@ func (rq *RoleQuery) QueryUserRoles() *UserRoleQuery { sqlgraph.To(userrole.Table, userrole.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, role.UserRolesTable, role.UserRolesColumn), ) - fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryRolePermissions chains the current query on the "role_permissions" edge. -func (rq *RoleQuery) QueryRolePermissions() *RolePermissionQuery { - query := (&RolePermissionClient{config: rq.config}).Query() +func (_q *RoleQuery) QueryRolePermissions() *RolePermissionQuery { + query := (&RolePermissionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -151,7 +151,7 @@ func (rq *RoleQuery) QueryRolePermissions() *RolePermissionQuery { sqlgraph.To(rolepermission.Table, rolepermission.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, role.RolePermissionsTable, role.RolePermissionsColumn), ) - fromU = sqlgraph.SetNeighbors(rq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -159,8 +159,8 @@ func (rq *RoleQuery) QueryRolePermissions() *RolePermissionQuery { // First returns the first Role entity from the query. // Returns a *NotFoundError when no Role was found. -func (rq *RoleQuery) First(ctx context.Context) (*Role, error) { - nodes, err := rq.Limit(1).All(setContextOp(ctx, rq.ctx, ent.OpQueryFirst)) +func (_q *RoleQuery) First(ctx context.Context) (*Role, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -171,8 +171,8 @@ func (rq *RoleQuery) First(ctx context.Context) (*Role, error) { } // FirstX is like First, but panics if an error occurs. -func (rq *RoleQuery) FirstX(ctx context.Context) *Role { - node, err := rq.First(ctx) +func (_q *RoleQuery) FirstX(ctx context.Context) *Role { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -181,9 +181,9 @@ func (rq *RoleQuery) FirstX(ctx context.Context) *Role { // FirstID returns the first Role ID from the query. // Returns a *NotFoundError when no Role ID was found. -func (rq *RoleQuery) FirstID(ctx context.Context) (id int64, err error) { +func (_q *RoleQuery) FirstID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = rq.Limit(1).IDs(setContextOp(ctx, rq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -194,8 +194,8 @@ func (rq *RoleQuery) FirstID(ctx context.Context) (id int64, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (rq *RoleQuery) FirstIDX(ctx context.Context) int64 { - id, err := rq.FirstID(ctx) +func (_q *RoleQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -205,8 +205,8 @@ func (rq *RoleQuery) FirstIDX(ctx context.Context) int64 { // Only returns a single Role entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Role entity is found. // Returns a *NotFoundError when no Role entities are found. -func (rq *RoleQuery) Only(ctx context.Context) (*Role, error) { - nodes, err := rq.Limit(2).All(setContextOp(ctx, rq.ctx, ent.OpQueryOnly)) +func (_q *RoleQuery) Only(ctx context.Context) (*Role, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -221,8 +221,8 @@ func (rq *RoleQuery) Only(ctx context.Context) (*Role, error) { } // OnlyX is like Only, but panics if an error occurs. -func (rq *RoleQuery) OnlyX(ctx context.Context) *Role { - node, err := rq.Only(ctx) +func (_q *RoleQuery) OnlyX(ctx context.Context) *Role { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -232,9 +232,9 @@ func (rq *RoleQuery) OnlyX(ctx context.Context) *Role { // OnlyID is like Only, but returns the only Role ID in the query. // Returns a *NotSingularError when more than one Role ID is found. // Returns a *NotFoundError when no entities are found. -func (rq *RoleQuery) OnlyID(ctx context.Context) (id int64, err error) { +func (_q *RoleQuery) OnlyID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = rq.Limit(2).IDs(setContextOp(ctx, rq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -249,8 +249,8 @@ func (rq *RoleQuery) OnlyID(ctx context.Context) (id int64, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (rq *RoleQuery) OnlyIDX(ctx context.Context) int64 { - id, err := rq.OnlyID(ctx) +func (_q *RoleQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -258,18 +258,18 @@ func (rq *RoleQuery) OnlyIDX(ctx context.Context) int64 { } // All executes the query and returns a list of Roles. -func (rq *RoleQuery) All(ctx context.Context) ([]*Role, error) { - ctx = setContextOp(ctx, rq.ctx, ent.OpQueryAll) - if err := rq.prepareQuery(ctx); err != nil { +func (_q *RoleQuery) All(ctx context.Context) ([]*Role, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Role, *RoleQuery]() - return withInterceptors[[]*Role](ctx, rq, qr, rq.inters) + return withInterceptors[[]*Role](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (rq *RoleQuery) AllX(ctx context.Context) []*Role { - nodes, err := rq.All(ctx) +func (_q *RoleQuery) AllX(ctx context.Context) []*Role { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -277,20 +277,20 @@ func (rq *RoleQuery) AllX(ctx context.Context) []*Role { } // IDs executes the query and returns a list of Role IDs. -func (rq *RoleQuery) IDs(ctx context.Context) (ids []int64, err error) { - if rq.ctx.Unique == nil && rq.path != nil { - rq.Unique(true) +func (_q *RoleQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, rq.ctx, ent.OpQueryIDs) - if err = rq.Select(role.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(role.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (rq *RoleQuery) IDsX(ctx context.Context) []int64 { - ids, err := rq.IDs(ctx) +func (_q *RoleQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -298,17 +298,17 @@ func (rq *RoleQuery) IDsX(ctx context.Context) []int64 { } // Count returns the count of the given query. -func (rq *RoleQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, rq.ctx, ent.OpQueryCount) - if err := rq.prepareQuery(ctx); err != nil { +func (_q *RoleQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, rq, querierCount[*RoleQuery](), rq.inters) + return withInterceptors[int](ctx, _q, querierCount[*RoleQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (rq *RoleQuery) CountX(ctx context.Context) int { - count, err := rq.Count(ctx) +func (_q *RoleQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -316,9 +316,9 @@ func (rq *RoleQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (rq *RoleQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, rq.ctx, ent.OpQueryExist) - switch _, err := rq.FirstID(ctx); { +func (_q *RoleQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -329,8 +329,8 @@ func (rq *RoleQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (rq *RoleQuery) ExistX(ctx context.Context) bool { - exist, err := rq.Exist(ctx) +func (_q *RoleQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -339,69 +339,69 @@ func (rq *RoleQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the RoleQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (rq *RoleQuery) Clone() *RoleQuery { - if rq == nil { +func (_q *RoleQuery) Clone() *RoleQuery { + if _q == nil { return nil } return &RoleQuery{ - config: rq.config, - ctx: rq.ctx.Clone(), - order: append([]role.OrderOption{}, rq.order...), - inters: append([]Interceptor{}, rq.inters...), - predicates: append([]predicate.Role{}, rq.predicates...), - withUsers: rq.withUsers.Clone(), - withPermissions: rq.withPermissions.Clone(), - withUserRoles: rq.withUserRoles.Clone(), - withRolePermissions: rq.withRolePermissions.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]role.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Role{}, _q.predicates...), + withUsers: _q.withUsers.Clone(), + withPermissions: _q.withPermissions.Clone(), + withUserRoles: _q.withUserRoles.Clone(), + withRolePermissions: _q.withRolePermissions.Clone(), // clone intermediate query. - sql: rq.sql.Clone(), - path: rq.path, - modifiers: append([]func(*sql.Selector){}, rq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithUsers tells the query-builder to eager-load the nodes that are connected to // the "users" edge. The optional arguments are used to configure the query builder of the edge. -func (rq *RoleQuery) WithUsers(opts ...func(*UserQuery)) *RoleQuery { - query := (&UserClient{config: rq.config}).Query() +func (_q *RoleQuery) WithUsers(opts ...func(*UserQuery)) *RoleQuery { + query := (&UserClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rq.withUsers = query - return rq + _q.withUsers = query + return _q } // WithPermissions tells the query-builder to eager-load the nodes that are connected to // the "permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (rq *RoleQuery) WithPermissions(opts ...func(*PermissionQuery)) *RoleQuery { - query := (&PermissionClient{config: rq.config}).Query() +func (_q *RoleQuery) WithPermissions(opts ...func(*PermissionQuery)) *RoleQuery { + query := (&PermissionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rq.withPermissions = query - return rq + _q.withPermissions = query + return _q } // WithUserRoles tells the query-builder to eager-load the nodes that are connected to // the "user_roles" edge. The optional arguments are used to configure the query builder of the edge. -func (rq *RoleQuery) WithUserRoles(opts ...func(*UserRoleQuery)) *RoleQuery { - query := (&UserRoleClient{config: rq.config}).Query() +func (_q *RoleQuery) WithUserRoles(opts ...func(*UserRoleQuery)) *RoleQuery { + query := (&UserRoleClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rq.withUserRoles = query - return rq + _q.withUserRoles = query + return _q } // WithRolePermissions tells the query-builder to eager-load the nodes that are connected to // the "role_permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (rq *RoleQuery) WithRolePermissions(opts ...func(*RolePermissionQuery)) *RoleQuery { - query := (&RolePermissionClient{config: rq.config}).Query() +func (_q *RoleQuery) WithRolePermissions(opts ...func(*RolePermissionQuery)) *RoleQuery { + query := (&RolePermissionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rq.withRolePermissions = query - return rq + _q.withRolePermissions = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -418,10 +418,10 @@ func (rq *RoleQuery) WithRolePermissions(opts ...func(*RolePermissionQuery)) *Ro // GroupBy(role.FieldCreateTime). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (rq *RoleQuery) GroupBy(field string, fields ...string) *RoleGroupBy { - rq.ctx.Fields = append([]string{field}, fields...) - grbuild := &RoleGroupBy{build: rq} - grbuild.flds = &rq.ctx.Fields +func (_q *RoleQuery) GroupBy(field string, fields ...string) *RoleGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &RoleGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = role.Label grbuild.scan = grbuild.Scan return grbuild @@ -439,100 +439,100 @@ func (rq *RoleQuery) GroupBy(field string, fields ...string) *RoleGroupBy { // client.Role.Query(). // Select(role.FieldCreateTime). // Scan(ctx, &v) -func (rq *RoleQuery) Select(fields ...string) *RoleSelect { - rq.ctx.Fields = append(rq.ctx.Fields, fields...) - sbuild := &RoleSelect{RoleQuery: rq} +func (_q *RoleQuery) Select(fields ...string) *RoleSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &RoleSelect{RoleQuery: _q} sbuild.label = role.Label - sbuild.flds, sbuild.scan = &rq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a RoleSelect configured with the given aggregations. -func (rq *RoleQuery) Aggregate(fns ...AggregateFunc) *RoleSelect { - return rq.Select().Aggregate(fns...) +func (_q *RoleQuery) Aggregate(fns ...AggregateFunc) *RoleSelect { + return _q.Select().Aggregate(fns...) } -func (rq *RoleQuery) prepareQuery(ctx context.Context) error { - for _, inter := range rq.inters { +func (_q *RoleQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, rq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range rq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !role.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if rq.path != nil { - prev, err := rq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - rq.sql = prev + _q.sql = prev } return nil } -func (rq *RoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Role, error) { +func (_q *RoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Role, error) { var ( nodes = []*Role{} - _spec = rq.querySpec() + _spec = _q.querySpec() loadedTypes = [4]bool{ - rq.withUsers != nil, - rq.withPermissions != nil, - rq.withUserRoles != nil, - rq.withRolePermissions != nil, + _q.withUsers != nil, + _q.withPermissions != nil, + _q.withUserRoles != nil, + _q.withRolePermissions != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Role).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Role{config: rq.config} + node := &Role{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(rq.modifiers) > 0 { - _spec.Modifiers = rq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, rq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := rq.withUsers; query != nil { - if err := rq.loadUsers(ctx, query, nodes, + if query := _q.withUsers; query != nil { + if err := _q.loadUsers(ctx, query, nodes, func(n *Role) { n.Edges.Users = []*User{} }, func(n *Role, e *User) { n.Edges.Users = append(n.Edges.Users, e) }); err != nil { return nil, err } } - if query := rq.withPermissions; query != nil { - if err := rq.loadPermissions(ctx, query, nodes, + if query := _q.withPermissions; query != nil { + if err := _q.loadPermissions(ctx, query, nodes, func(n *Role) { n.Edges.Permissions = []*Permission{} }, func(n *Role, e *Permission) { n.Edges.Permissions = append(n.Edges.Permissions, e) }); err != nil { return nil, err } } - if query := rq.withUserRoles; query != nil { - if err := rq.loadUserRoles(ctx, query, nodes, + if query := _q.withUserRoles; query != nil { + if err := _q.loadUserRoles(ctx, query, nodes, func(n *Role) { n.Edges.UserRoles = []*UserRole{} }, func(n *Role, e *UserRole) { n.Edges.UserRoles = append(n.Edges.UserRoles, e) }); err != nil { return nil, err } } - if query := rq.withRolePermissions; query != nil { - if err := rq.loadRolePermissions(ctx, query, nodes, + if query := _q.withRolePermissions; query != nil { + if err := _q.loadRolePermissions(ctx, query, nodes, func(n *Role) { n.Edges.RolePermissions = []*RolePermission{} }, func(n *Role, e *RolePermission) { n.Edges.RolePermissions = append(n.Edges.RolePermissions, e) }); err != nil { return nil, err @@ -541,7 +541,7 @@ func (rq *RoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Role, e return nodes, nil } -func (rq *RoleQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*Role, init func(*Role), assign func(*Role, *User)) error { +func (_q *RoleQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*Role, init func(*Role), assign func(*Role, *User)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*Role) nids := make(map[int64]map[*Role]struct{}) @@ -602,7 +602,7 @@ func (rq *RoleQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*R } return nil } -func (rq *RoleQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*Role, init func(*Role), assign func(*Role, *Permission)) error { +func (_q *RoleQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*Role, init func(*Role), assign func(*Role, *Permission)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*Role) nids := make(map[int64]map[*Role]struct{}) @@ -663,7 +663,7 @@ func (rq *RoleQuery) loadPermissions(ctx context.Context, query *PermissionQuery } return nil } -func (rq *RoleQuery) loadUserRoles(ctx context.Context, query *UserRoleQuery, nodes []*Role, init func(*Role), assign func(*Role, *UserRole)) error { +func (_q *RoleQuery) loadUserRoles(ctx context.Context, query *UserRoleQuery, nodes []*Role, init func(*Role), assign func(*Role, *UserRole)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Role) for i := range nodes { @@ -693,7 +693,7 @@ func (rq *RoleQuery) loadUserRoles(ctx context.Context, query *UserRoleQuery, no } return nil } -func (rq *RoleQuery) loadRolePermissions(ctx context.Context, query *RolePermissionQuery, nodes []*Role, init func(*Role), assign func(*Role, *RolePermission)) error { +func (_q *RoleQuery) loadRolePermissions(ctx context.Context, query *RolePermissionQuery, nodes []*Role, init func(*Role), assign func(*Role, *RolePermission)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Role) for i := range nodes { @@ -724,27 +724,27 @@ func (rq *RoleQuery) loadRolePermissions(ctx context.Context, query *RolePermiss return nil } -func (rq *RoleQuery) sqlCount(ctx context.Context) (int, error) { - _spec := rq.querySpec() - if len(rq.modifiers) > 0 { - _spec.Modifiers = rq.modifiers +func (_q *RoleQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = rq.ctx.Fields - if len(rq.ctx.Fields) > 0 { - _spec.Unique = rq.ctx.Unique != nil && *rq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, rq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (rq *RoleQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *RoleQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) - _spec.From = rq.sql - if unique := rq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if rq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := rq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, role.FieldID) for i := range fields { @@ -753,20 +753,20 @@ func (rq *RoleQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := rq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := rq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := rq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := rq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -776,36 +776,36 @@ func (rq *RoleQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (rq *RoleQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(rq.driver.Dialect()) +func (_q *RoleQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(role.Table) - columns := rq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = role.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if rq.sql != nil { - selector = rq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if rq.ctx.Unique != nil && *rq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range rq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range rq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range rq.order { + for _, p := range _q.order { p(selector) } - if offset := rq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := rq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -814,33 +814,33 @@ func (rq *RoleQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (rq *RoleQuery) ForUpdate(opts ...sql.LockOption) *RoleQuery { - if rq.driver.Dialect() == dialect.Postgres { - rq.Unique(false) +func (_q *RoleQuery) ForUpdate(opts ...sql.LockOption) *RoleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - rq.modifiers = append(rq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return rq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (rq *RoleQuery) ForShare(opts ...sql.LockOption) *RoleQuery { - if rq.driver.Dialect() == dialect.Postgres { - rq.Unique(false) +func (_q *RoleQuery) ForShare(opts ...sql.LockOption) *RoleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - rq.modifiers = append(rq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return rq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (rq *RoleQuery) Modify(modifiers ...func(s *sql.Selector)) *RoleSelect { - rq.modifiers = append(rq.modifiers, modifiers...) - return rq.Select() +func (_q *RoleQuery) Modify(modifiers ...func(s *sql.Selector)) *RoleSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -894,41 +894,41 @@ type RoleGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (rgb *RoleGroupBy) Aggregate(fns ...AggregateFunc) *RoleGroupBy { - rgb.fns = append(rgb.fns, fns...) - return rgb +func (_g *RoleGroupBy) Aggregate(fns ...AggregateFunc) *RoleGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (rgb *RoleGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, rgb.build.ctx, ent.OpQueryGroupBy) - if err := rgb.build.prepareQuery(ctx); err != nil { +func (_g *RoleGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*RoleQuery, *RoleGroupBy](ctx, rgb.build, rgb, rgb.build.inters, v) + return scanWithInterceptors[*RoleQuery, *RoleGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (rgb *RoleGroupBy) sqlScan(ctx context.Context, root *RoleQuery, v any) error { +func (_g *RoleGroupBy) sqlScan(ctx context.Context, root *RoleQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(rgb.fns)) - for _, fn := range rgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*rgb.flds)+len(rgb.fns)) - for _, f := range *rgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*rgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := rgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -942,27 +942,27 @@ type RoleSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (rs *RoleSelect) Aggregate(fns ...AggregateFunc) *RoleSelect { - rs.fns = append(rs.fns, fns...) - return rs +func (_s *RoleSelect) Aggregate(fns ...AggregateFunc) *RoleSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (rs *RoleSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, rs.ctx, ent.OpQuerySelect) - if err := rs.prepareQuery(ctx); err != nil { +func (_s *RoleSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*RoleQuery, *RoleSelect](ctx, rs.RoleQuery, rs, rs.inters, v) + return scanWithInterceptors[*RoleQuery, *RoleSelect](ctx, _s.RoleQuery, _s, _s.inters, v) } -func (rs *RoleSelect) sqlScan(ctx context.Context, root *RoleQuery, v any) error { +func (_s *RoleSelect) sqlScan(ctx context.Context, root *RoleQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(rs.fns)) - for _, fn := range rs.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*rs.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -970,7 +970,7 @@ func (rs *RoleSelect) sqlScan(ctx context.Context, root *RoleQuery, v any) error } rows := &sql.Rows{} query, args := selector.Query() - if err := rs.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -978,7 +978,7 @@ func (rs *RoleSelect) sqlScan(ctx context.Context, root *RoleQuery, v any) error } // Modify adds a query modifier for attaching custom logic to queries. -func (rs *RoleSelect) Modify(modifiers ...func(s *sql.Selector)) *RoleSelect { - rs.modifiers = append(rs.modifiers, modifiers...) - return rs +func (_s *RoleSelect) Modify(modifiers ...func(s *sql.Selector)) *RoleSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/role_update.go b/internal/data/entity/ent/role_update.go index 833be2d0..97f5b12d 100644 --- a/internal/data/entity/ent/role_update.go +++ b/internal/data/entity/ent/role_update.go @@ -28,280 +28,280 @@ type RoleUpdate struct { } // Where appends a list predicates to the RoleUpdate builder. -func (ru *RoleUpdate) Where(ps ...predicate.Role) *RoleUpdate { - ru.mutation.Where(ps...) - return ru +func (_u *RoleUpdate) Where(ps ...predicate.Role) *RoleUpdate { + _u.mutation.Where(ps...) + return _u } // SetUpdateTime sets the "update_time" field. -func (ru *RoleUpdate) SetUpdateTime(t time.Time) *RoleUpdate { - ru.mutation.SetUpdateTime(t) - return ru +func (_u *RoleUpdate) SetUpdateTime(v time.Time) *RoleUpdate { + _u.mutation.SetUpdateTime(v) + return _u } // SetKeyword sets the "keyword" field. -func (ru *RoleUpdate) SetKeyword(s string) *RoleUpdate { - ru.mutation.SetKeyword(s) - return ru +func (_u *RoleUpdate) SetKeyword(v string) *RoleUpdate { + _u.mutation.SetKeyword(v) + return _u } // SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (ru *RoleUpdate) SetNillableKeyword(s *string) *RoleUpdate { - if s != nil { - ru.SetKeyword(*s) +func (_u *RoleUpdate) SetNillableKeyword(v *string) *RoleUpdate { + if v != nil { + _u.SetKeyword(*v) } - return ru + return _u } // SetName sets the "name" field. -func (ru *RoleUpdate) SetName(s string) *RoleUpdate { - ru.mutation.SetName(s) - return ru +func (_u *RoleUpdate) SetName(v string) *RoleUpdate { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (ru *RoleUpdate) SetNillableName(s *string) *RoleUpdate { - if s != nil { - ru.SetName(*s) +func (_u *RoleUpdate) SetNillableName(v *string) *RoleUpdate { + if v != nil { + _u.SetName(*v) } - return ru + return _u } // SetDescription sets the "description" field. -func (ru *RoleUpdate) SetDescription(s string) *RoleUpdate { - ru.mutation.SetDescription(s) - return ru +func (_u *RoleUpdate) SetDescription(v string) *RoleUpdate { + _u.mutation.SetDescription(v) + return _u } // SetNillableDescription sets the "description" field if the given value is not nil. -func (ru *RoleUpdate) SetNillableDescription(s *string) *RoleUpdate { - if s != nil { - ru.SetDescription(*s) +func (_u *RoleUpdate) SetNillableDescription(v *string) *RoleUpdate { + if v != nil { + _u.SetDescription(*v) } - return ru + return _u } // SetType sets the "type" field. -func (ru *RoleUpdate) SetType(i int8) *RoleUpdate { - ru.mutation.ResetType() - ru.mutation.SetType(i) - return ru +func (_u *RoleUpdate) SetType(v int8) *RoleUpdate { + _u.mutation.ResetType() + _u.mutation.SetType(v) + return _u } // SetNillableType sets the "type" field if the given value is not nil. -func (ru *RoleUpdate) SetNillableType(i *int8) *RoleUpdate { - if i != nil { - ru.SetType(*i) +func (_u *RoleUpdate) SetNillableType(v *int8) *RoleUpdate { + if v != nil { + _u.SetType(*v) } - return ru + return _u } -// AddType adds i to the "type" field. -func (ru *RoleUpdate) AddType(i int8) *RoleUpdate { - ru.mutation.AddType(i) - return ru +// AddType adds value to the "type" field. +func (_u *RoleUpdate) AddType(v int8) *RoleUpdate { + _u.mutation.AddType(v) + return _u } // SetSequence sets the "sequence" field. -func (ru *RoleUpdate) SetSequence(i int) *RoleUpdate { - ru.mutation.ResetSequence() - ru.mutation.SetSequence(i) - return ru +func (_u *RoleUpdate) SetSequence(v int) *RoleUpdate { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u } // SetNillableSequence sets the "sequence" field if the given value is not nil. -func (ru *RoleUpdate) SetNillableSequence(i *int) *RoleUpdate { - if i != nil { - ru.SetSequence(*i) +func (_u *RoleUpdate) SetNillableSequence(v *int) *RoleUpdate { + if v != nil { + _u.SetSequence(*v) } - return ru + return _u } -// AddSequence adds i to the "sequence" field. -func (ru *RoleUpdate) AddSequence(i int) *RoleUpdate { - ru.mutation.AddSequence(i) - return ru +// AddSequence adds value to the "sequence" field. +func (_u *RoleUpdate) AddSequence(v int) *RoleUpdate { + _u.mutation.AddSequence(v) + return _u } // SetStatus sets the "status" field. -func (ru *RoleUpdate) SetStatus(i int8) *RoleUpdate { - ru.mutation.ResetStatus() - ru.mutation.SetStatus(i) - return ru +func (_u *RoleUpdate) SetStatus(v int8) *RoleUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (ru *RoleUpdate) SetNillableStatus(i *int8) *RoleUpdate { - if i != nil { - ru.SetStatus(*i) +func (_u *RoleUpdate) SetNillableStatus(v *int8) *RoleUpdate { + if v != nil { + _u.SetStatus(*v) } - return ru + return _u } -// AddStatus adds i to the "status" field. -func (ru *RoleUpdate) AddStatus(i int8) *RoleUpdate { - ru.mutation.AddStatus(i) - return ru +// AddStatus adds value to the "status" field. +func (_u *RoleUpdate) AddStatus(v int8) *RoleUpdate { + _u.mutation.AddStatus(v) + return _u } // AddUserIDs adds the "users" edge to the User entity by IDs. -func (ru *RoleUpdate) AddUserIDs(ids ...int64) *RoleUpdate { - ru.mutation.AddUserIDs(ids...) - return ru +func (_u *RoleUpdate) AddUserIDs(ids ...int64) *RoleUpdate { + _u.mutation.AddUserIDs(ids...) + return _u } // AddUsers adds the "users" edges to the User entity. -func (ru *RoleUpdate) AddUsers(u ...*User) *RoleUpdate { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *RoleUpdate) AddUsers(v ...*User) *RoleUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.AddUserIDs(ids...) + return _u.AddUserIDs(ids...) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (ru *RoleUpdate) AddPermissionIDs(ids ...int64) *RoleUpdate { - ru.mutation.AddPermissionIDs(ids...) - return ru +func (_u *RoleUpdate) AddPermissionIDs(ids ...int64) *RoleUpdate { + _u.mutation.AddPermissionIDs(ids...) + return _u } // AddPermissions adds the "permissions" edges to the Permission entity. -func (ru *RoleUpdate) AddPermissions(p ...*Permission) *RoleUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *RoleUpdate) AddPermissions(v ...*Permission) *RoleUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.AddPermissionIDs(ids...) + return _u.AddPermissionIDs(ids...) } // AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (ru *RoleUpdate) AddUserRoleIDs(ids ...int) *RoleUpdate { - ru.mutation.AddUserRoleIDs(ids...) - return ru +func (_u *RoleUpdate) AddUserRoleIDs(ids ...int) *RoleUpdate { + _u.mutation.AddUserRoleIDs(ids...) + return _u } // AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (ru *RoleUpdate) AddUserRoles(u ...*UserRole) *RoleUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *RoleUpdate) AddUserRoles(v ...*UserRole) *RoleUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.AddUserRoleIDs(ids...) + return _u.AddUserRoleIDs(ids...) } // AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (ru *RoleUpdate) AddRolePermissionIDs(ids ...int) *RoleUpdate { - ru.mutation.AddRolePermissionIDs(ids...) - return ru +func (_u *RoleUpdate) AddRolePermissionIDs(ids ...int) *RoleUpdate { + _u.mutation.AddRolePermissionIDs(ids...) + return _u } // AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (ru *RoleUpdate) AddRolePermissions(r ...*RolePermission) *RoleUpdate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *RoleUpdate) AddRolePermissions(v ...*RolePermission) *RoleUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.AddRolePermissionIDs(ids...) + return _u.AddRolePermissionIDs(ids...) } // Mutation returns the RoleMutation object of the builder. -func (ru *RoleUpdate) Mutation() *RoleMutation { - return ru.mutation +func (_u *RoleUpdate) Mutation() *RoleMutation { + return _u.mutation } // ClearUsers clears all "users" edges to the User entity. -func (ru *RoleUpdate) ClearUsers() *RoleUpdate { - ru.mutation.ClearUsers() - return ru +func (_u *RoleUpdate) ClearUsers() *RoleUpdate { + _u.mutation.ClearUsers() + return _u } // RemoveUserIDs removes the "users" edge to User entities by IDs. -func (ru *RoleUpdate) RemoveUserIDs(ids ...int64) *RoleUpdate { - ru.mutation.RemoveUserIDs(ids...) - return ru +func (_u *RoleUpdate) RemoveUserIDs(ids ...int64) *RoleUpdate { + _u.mutation.RemoveUserIDs(ids...) + return _u } // RemoveUsers removes "users" edges to User entities. -func (ru *RoleUpdate) RemoveUsers(u ...*User) *RoleUpdate { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *RoleUpdate) RemoveUsers(v ...*User) *RoleUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.RemoveUserIDs(ids...) + return _u.RemoveUserIDs(ids...) } // ClearPermissions clears all "permissions" edges to the Permission entity. -func (ru *RoleUpdate) ClearPermissions() *RoleUpdate { - ru.mutation.ClearPermissions() - return ru +func (_u *RoleUpdate) ClearPermissions() *RoleUpdate { + _u.mutation.ClearPermissions() + return _u } // RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. -func (ru *RoleUpdate) RemovePermissionIDs(ids ...int64) *RoleUpdate { - ru.mutation.RemovePermissionIDs(ids...) - return ru +func (_u *RoleUpdate) RemovePermissionIDs(ids ...int64) *RoleUpdate { + _u.mutation.RemovePermissionIDs(ids...) + return _u } // RemovePermissions removes "permissions" edges to Permission entities. -func (ru *RoleUpdate) RemovePermissions(p ...*Permission) *RoleUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *RoleUpdate) RemovePermissions(v ...*Permission) *RoleUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.RemovePermissionIDs(ids...) + return _u.RemovePermissionIDs(ids...) } // ClearUserRoles clears all "user_roles" edges to the UserRole entity. -func (ru *RoleUpdate) ClearUserRoles() *RoleUpdate { - ru.mutation.ClearUserRoles() - return ru +func (_u *RoleUpdate) ClearUserRoles() *RoleUpdate { + _u.mutation.ClearUserRoles() + return _u } // RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. -func (ru *RoleUpdate) RemoveUserRoleIDs(ids ...int) *RoleUpdate { - ru.mutation.RemoveUserRoleIDs(ids...) - return ru +func (_u *RoleUpdate) RemoveUserRoleIDs(ids ...int) *RoleUpdate { + _u.mutation.RemoveUserRoleIDs(ids...) + return _u } // RemoveUserRoles removes "user_roles" edges to UserRole entities. -func (ru *RoleUpdate) RemoveUserRoles(u ...*UserRole) *RoleUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *RoleUpdate) RemoveUserRoles(v ...*UserRole) *RoleUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.RemoveUserRoleIDs(ids...) + return _u.RemoveUserRoleIDs(ids...) } // ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. -func (ru *RoleUpdate) ClearRolePermissions() *RoleUpdate { - ru.mutation.ClearRolePermissions() - return ru +func (_u *RoleUpdate) ClearRolePermissions() *RoleUpdate { + _u.mutation.ClearRolePermissions() + return _u } // RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. -func (ru *RoleUpdate) RemoveRolePermissionIDs(ids ...int) *RoleUpdate { - ru.mutation.RemoveRolePermissionIDs(ids...) - return ru +func (_u *RoleUpdate) RemoveRolePermissionIDs(ids ...int) *RoleUpdate { + _u.mutation.RemoveRolePermissionIDs(ids...) + return _u } // RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. -func (ru *RoleUpdate) RemoveRolePermissions(r ...*RolePermission) *RoleUpdate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *RoleUpdate) RemoveRolePermissions(v ...*RolePermission) *RoleUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ru.RemoveRolePermissionIDs(ids...) + return _u.RemoveRolePermissionIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. -func (ru *RoleUpdate) Save(ctx context.Context) (int, error) { - ru.defaults() - return withHooks(ctx, ru.sqlSave, ru.mutation, ru.hooks) +func (_u *RoleUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (ru *RoleUpdate) SaveX(ctx context.Context) int { - affected, err := ru.Save(ctx) +func (_u *RoleUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -309,39 +309,39 @@ func (ru *RoleUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (ru *RoleUpdate) Exec(ctx context.Context) error { - _, err := ru.Save(ctx) +func (_u *RoleUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ru *RoleUpdate) ExecX(ctx context.Context) { - if err := ru.Exec(ctx); err != nil { +func (_u *RoleUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (ru *RoleUpdate) defaults() { - if _, ok := ru.mutation.UpdateTime(); !ok { +func (_u *RoleUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := role.UpdateDefaultUpdateTime() - ru.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (ru *RoleUpdate) check() error { - if v, ok := ru.mutation.Keyword(); ok { +func (_u *RoleUpdate) check() error { + if v, ok := _u.mutation.Keyword(); ok { if err := role.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Role.keyword": %w`, err)} } } - if v, ok := ru.mutation.Name(); ok { + if v, ok := _u.mutation.Name(); ok { if err := role.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Role.name": %w`, err)} } } - if v, ok := ru.mutation.Description(); ok { + if v, ok := _u.mutation.Description(); ok { if err := role.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Role.description": %w`, err)} } @@ -350,54 +350,54 @@ func (ru *RoleUpdate) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (ru *RoleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoleUpdate { - ru.modifiers = append(ru.modifiers, modifiers...) - return ru +func (_u *RoleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoleUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := ru.check(); err != nil { - return n, err +func (_u *RoleUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) - if ps := ru.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := ru.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(role.FieldUpdateTime, field.TypeTime, value) } - if value, ok := ru.mutation.Keyword(); ok { + if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(role.FieldKeyword, field.TypeString, value) } - if value, ok := ru.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(role.FieldName, field.TypeString, value) } - if value, ok := ru.mutation.Description(); ok { + if value, ok := _u.mutation.Description(); ok { _spec.SetField(role.FieldDescription, field.TypeString, value) } - if value, ok := ru.mutation.GetType(); ok { + if value, ok := _u.mutation.GetType(); ok { _spec.SetField(role.FieldType, field.TypeInt8, value) } - if value, ok := ru.mutation.AddedType(); ok { + if value, ok := _u.mutation.AddedType(); ok { _spec.AddField(role.FieldType, field.TypeInt8, value) } - if value, ok := ru.mutation.Sequence(); ok { + if value, ok := _u.mutation.Sequence(); ok { _spec.SetField(role.FieldSequence, field.TypeInt, value) } - if value, ok := ru.mutation.AddedSequence(); ok { + if value, ok := _u.mutation.AddedSequence(); ok { _spec.AddField(role.FieldSequence, field.TypeInt, value) } - if value, ok := ru.mutation.Status(); ok { + if value, ok := _u.mutation.Status(); ok { _spec.SetField(role.FieldStatus, field.TypeInt8, value) } - if value, ok := ru.mutation.AddedStatus(); ok { + if value, ok := _u.mutation.AddedStatus(); ok { _spec.AddField(role.FieldStatus, field.TypeInt8, value) } - if ru.mutation.UsersCleared() { + if _u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -410,7 +410,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.RemovedUsersIDs(); len(nodes) > 0 && !ru.mutation.UsersCleared() { + if nodes := _u.mutation.RemovedUsersIDs(); len(nodes) > 0 && !_u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -426,7 +426,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.UsersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UsersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -442,7 +442,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ru.mutation.PermissionsCleared() { + if _u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -455,7 +455,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !ru.mutation.PermissionsCleared() { + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -471,7 +471,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.PermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -487,7 +487,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ru.mutation.UserRolesCleared() { + if _u.mutation.UserRolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -500,7 +500,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !ru.mutation.UserRolesCleared() { + if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -516,7 +516,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.UserRolesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -532,7 +532,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ru.mutation.RolePermissionsCleared() { + if _u.mutation.RolePermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -545,7 +545,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !ru.mutation.RolePermissionsCleared() { + if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -561,7 +561,7 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ru.mutation.RolePermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -577,8 +577,8 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(ru.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, ru.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{role.Label} } else if sqlgraph.IsConstraintError(err) { @@ -586,8 +586,8 @@ func (ru *RoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - ru.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // RoleUpdateOne is the builder for updating a single Role entity. @@ -600,287 +600,287 @@ type RoleUpdateOne struct { } // SetUpdateTime sets the "update_time" field. -func (ruo *RoleUpdateOne) SetUpdateTime(t time.Time) *RoleUpdateOne { - ruo.mutation.SetUpdateTime(t) - return ruo +func (_u *RoleUpdateOne) SetUpdateTime(v time.Time) *RoleUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u } // SetKeyword sets the "keyword" field. -func (ruo *RoleUpdateOne) SetKeyword(s string) *RoleUpdateOne { - ruo.mutation.SetKeyword(s) - return ruo +func (_u *RoleUpdateOne) SetKeyword(v string) *RoleUpdateOne { + _u.mutation.SetKeyword(v) + return _u } // SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (ruo *RoleUpdateOne) SetNillableKeyword(s *string) *RoleUpdateOne { - if s != nil { - ruo.SetKeyword(*s) +func (_u *RoleUpdateOne) SetNillableKeyword(v *string) *RoleUpdateOne { + if v != nil { + _u.SetKeyword(*v) } - return ruo + return _u } // SetName sets the "name" field. -func (ruo *RoleUpdateOne) SetName(s string) *RoleUpdateOne { - ruo.mutation.SetName(s) - return ruo +func (_u *RoleUpdateOne) SetName(v string) *RoleUpdateOne { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (ruo *RoleUpdateOne) SetNillableName(s *string) *RoleUpdateOne { - if s != nil { - ruo.SetName(*s) +func (_u *RoleUpdateOne) SetNillableName(v *string) *RoleUpdateOne { + if v != nil { + _u.SetName(*v) } - return ruo + return _u } // SetDescription sets the "description" field. -func (ruo *RoleUpdateOne) SetDescription(s string) *RoleUpdateOne { - ruo.mutation.SetDescription(s) - return ruo +func (_u *RoleUpdateOne) SetDescription(v string) *RoleUpdateOne { + _u.mutation.SetDescription(v) + return _u } // SetNillableDescription sets the "description" field if the given value is not nil. -func (ruo *RoleUpdateOne) SetNillableDescription(s *string) *RoleUpdateOne { - if s != nil { - ruo.SetDescription(*s) +func (_u *RoleUpdateOne) SetNillableDescription(v *string) *RoleUpdateOne { + if v != nil { + _u.SetDescription(*v) } - return ruo + return _u } // SetType sets the "type" field. -func (ruo *RoleUpdateOne) SetType(i int8) *RoleUpdateOne { - ruo.mutation.ResetType() - ruo.mutation.SetType(i) - return ruo +func (_u *RoleUpdateOne) SetType(v int8) *RoleUpdateOne { + _u.mutation.ResetType() + _u.mutation.SetType(v) + return _u } // SetNillableType sets the "type" field if the given value is not nil. -func (ruo *RoleUpdateOne) SetNillableType(i *int8) *RoleUpdateOne { - if i != nil { - ruo.SetType(*i) +func (_u *RoleUpdateOne) SetNillableType(v *int8) *RoleUpdateOne { + if v != nil { + _u.SetType(*v) } - return ruo + return _u } -// AddType adds i to the "type" field. -func (ruo *RoleUpdateOne) AddType(i int8) *RoleUpdateOne { - ruo.mutation.AddType(i) - return ruo +// AddType adds value to the "type" field. +func (_u *RoleUpdateOne) AddType(v int8) *RoleUpdateOne { + _u.mutation.AddType(v) + return _u } // SetSequence sets the "sequence" field. -func (ruo *RoleUpdateOne) SetSequence(i int) *RoleUpdateOne { - ruo.mutation.ResetSequence() - ruo.mutation.SetSequence(i) - return ruo +func (_u *RoleUpdateOne) SetSequence(v int) *RoleUpdateOne { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u } // SetNillableSequence sets the "sequence" field if the given value is not nil. -func (ruo *RoleUpdateOne) SetNillableSequence(i *int) *RoleUpdateOne { - if i != nil { - ruo.SetSequence(*i) +func (_u *RoleUpdateOne) SetNillableSequence(v *int) *RoleUpdateOne { + if v != nil { + _u.SetSequence(*v) } - return ruo + return _u } -// AddSequence adds i to the "sequence" field. -func (ruo *RoleUpdateOne) AddSequence(i int) *RoleUpdateOne { - ruo.mutation.AddSequence(i) - return ruo +// AddSequence adds value to the "sequence" field. +func (_u *RoleUpdateOne) AddSequence(v int) *RoleUpdateOne { + _u.mutation.AddSequence(v) + return _u } // SetStatus sets the "status" field. -func (ruo *RoleUpdateOne) SetStatus(i int8) *RoleUpdateOne { - ruo.mutation.ResetStatus() - ruo.mutation.SetStatus(i) - return ruo +func (_u *RoleUpdateOne) SetStatus(v int8) *RoleUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (ruo *RoleUpdateOne) SetNillableStatus(i *int8) *RoleUpdateOne { - if i != nil { - ruo.SetStatus(*i) +func (_u *RoleUpdateOne) SetNillableStatus(v *int8) *RoleUpdateOne { + if v != nil { + _u.SetStatus(*v) } - return ruo + return _u } -// AddStatus adds i to the "status" field. -func (ruo *RoleUpdateOne) AddStatus(i int8) *RoleUpdateOne { - ruo.mutation.AddStatus(i) - return ruo +// AddStatus adds value to the "status" field. +func (_u *RoleUpdateOne) AddStatus(v int8) *RoleUpdateOne { + _u.mutation.AddStatus(v) + return _u } // AddUserIDs adds the "users" edge to the User entity by IDs. -func (ruo *RoleUpdateOne) AddUserIDs(ids ...int64) *RoleUpdateOne { - ruo.mutation.AddUserIDs(ids...) - return ruo +func (_u *RoleUpdateOne) AddUserIDs(ids ...int64) *RoleUpdateOne { + _u.mutation.AddUserIDs(ids...) + return _u } // AddUsers adds the "users" edges to the User entity. -func (ruo *RoleUpdateOne) AddUsers(u ...*User) *RoleUpdateOne { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *RoleUpdateOne) AddUsers(v ...*User) *RoleUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.AddUserIDs(ids...) + return _u.AddUserIDs(ids...) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (ruo *RoleUpdateOne) AddPermissionIDs(ids ...int64) *RoleUpdateOne { - ruo.mutation.AddPermissionIDs(ids...) - return ruo +func (_u *RoleUpdateOne) AddPermissionIDs(ids ...int64) *RoleUpdateOne { + _u.mutation.AddPermissionIDs(ids...) + return _u } // AddPermissions adds the "permissions" edges to the Permission entity. -func (ruo *RoleUpdateOne) AddPermissions(p ...*Permission) *RoleUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *RoleUpdateOne) AddPermissions(v ...*Permission) *RoleUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.AddPermissionIDs(ids...) + return _u.AddPermissionIDs(ids...) } // AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (ruo *RoleUpdateOne) AddUserRoleIDs(ids ...int) *RoleUpdateOne { - ruo.mutation.AddUserRoleIDs(ids...) - return ruo +func (_u *RoleUpdateOne) AddUserRoleIDs(ids ...int) *RoleUpdateOne { + _u.mutation.AddUserRoleIDs(ids...) + return _u } // AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (ruo *RoleUpdateOne) AddUserRoles(u ...*UserRole) *RoleUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *RoleUpdateOne) AddUserRoles(v ...*UserRole) *RoleUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.AddUserRoleIDs(ids...) + return _u.AddUserRoleIDs(ids...) } // AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (ruo *RoleUpdateOne) AddRolePermissionIDs(ids ...int) *RoleUpdateOne { - ruo.mutation.AddRolePermissionIDs(ids...) - return ruo +func (_u *RoleUpdateOne) AddRolePermissionIDs(ids ...int) *RoleUpdateOne { + _u.mutation.AddRolePermissionIDs(ids...) + return _u } // AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (ruo *RoleUpdateOne) AddRolePermissions(r ...*RolePermission) *RoleUpdateOne { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *RoleUpdateOne) AddRolePermissions(v ...*RolePermission) *RoleUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.AddRolePermissionIDs(ids...) + return _u.AddRolePermissionIDs(ids...) } // Mutation returns the RoleMutation object of the builder. -func (ruo *RoleUpdateOne) Mutation() *RoleMutation { - return ruo.mutation +func (_u *RoleUpdateOne) Mutation() *RoleMutation { + return _u.mutation } // ClearUsers clears all "users" edges to the User entity. -func (ruo *RoleUpdateOne) ClearUsers() *RoleUpdateOne { - ruo.mutation.ClearUsers() - return ruo +func (_u *RoleUpdateOne) ClearUsers() *RoleUpdateOne { + _u.mutation.ClearUsers() + return _u } // RemoveUserIDs removes the "users" edge to User entities by IDs. -func (ruo *RoleUpdateOne) RemoveUserIDs(ids ...int64) *RoleUpdateOne { - ruo.mutation.RemoveUserIDs(ids...) - return ruo +func (_u *RoleUpdateOne) RemoveUserIDs(ids ...int64) *RoleUpdateOne { + _u.mutation.RemoveUserIDs(ids...) + return _u } // RemoveUsers removes "users" edges to User entities. -func (ruo *RoleUpdateOne) RemoveUsers(u ...*User) *RoleUpdateOne { - ids := make([]int64, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *RoleUpdateOne) RemoveUsers(v ...*User) *RoleUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.RemoveUserIDs(ids...) + return _u.RemoveUserIDs(ids...) } // ClearPermissions clears all "permissions" edges to the Permission entity. -func (ruo *RoleUpdateOne) ClearPermissions() *RoleUpdateOne { - ruo.mutation.ClearPermissions() - return ruo +func (_u *RoleUpdateOne) ClearPermissions() *RoleUpdateOne { + _u.mutation.ClearPermissions() + return _u } // RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. -func (ruo *RoleUpdateOne) RemovePermissionIDs(ids ...int64) *RoleUpdateOne { - ruo.mutation.RemovePermissionIDs(ids...) - return ruo +func (_u *RoleUpdateOne) RemovePermissionIDs(ids ...int64) *RoleUpdateOne { + _u.mutation.RemovePermissionIDs(ids...) + return _u } // RemovePermissions removes "permissions" edges to Permission entities. -func (ruo *RoleUpdateOne) RemovePermissions(p ...*Permission) *RoleUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *RoleUpdateOne) RemovePermissions(v ...*Permission) *RoleUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.RemovePermissionIDs(ids...) + return _u.RemovePermissionIDs(ids...) } // ClearUserRoles clears all "user_roles" edges to the UserRole entity. -func (ruo *RoleUpdateOne) ClearUserRoles() *RoleUpdateOne { - ruo.mutation.ClearUserRoles() - return ruo +func (_u *RoleUpdateOne) ClearUserRoles() *RoleUpdateOne { + _u.mutation.ClearUserRoles() + return _u } // RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. -func (ruo *RoleUpdateOne) RemoveUserRoleIDs(ids ...int) *RoleUpdateOne { - ruo.mutation.RemoveUserRoleIDs(ids...) - return ruo +func (_u *RoleUpdateOne) RemoveUserRoleIDs(ids ...int) *RoleUpdateOne { + _u.mutation.RemoveUserRoleIDs(ids...) + return _u } // RemoveUserRoles removes "user_roles" edges to UserRole entities. -func (ruo *RoleUpdateOne) RemoveUserRoles(u ...*UserRole) *RoleUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *RoleUpdateOne) RemoveUserRoles(v ...*UserRole) *RoleUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.RemoveUserRoleIDs(ids...) + return _u.RemoveUserRoleIDs(ids...) } // ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. -func (ruo *RoleUpdateOne) ClearRolePermissions() *RoleUpdateOne { - ruo.mutation.ClearRolePermissions() - return ruo +func (_u *RoleUpdateOne) ClearRolePermissions() *RoleUpdateOne { + _u.mutation.ClearRolePermissions() + return _u } // RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. -func (ruo *RoleUpdateOne) RemoveRolePermissionIDs(ids ...int) *RoleUpdateOne { - ruo.mutation.RemoveRolePermissionIDs(ids...) - return ruo +func (_u *RoleUpdateOne) RemoveRolePermissionIDs(ids ...int) *RoleUpdateOne { + _u.mutation.RemoveRolePermissionIDs(ids...) + return _u } // RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. -func (ruo *RoleUpdateOne) RemoveRolePermissions(r ...*RolePermission) *RoleUpdateOne { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *RoleUpdateOne) RemoveRolePermissions(v ...*RolePermission) *RoleUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return ruo.RemoveRolePermissionIDs(ids...) + return _u.RemoveRolePermissionIDs(ids...) } // Where appends a list predicates to the RoleUpdate builder. -func (ruo *RoleUpdateOne) Where(ps ...predicate.Role) *RoleUpdateOne { - ruo.mutation.Where(ps...) - return ruo +func (_u *RoleUpdateOne) Where(ps ...predicate.Role) *RoleUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (ruo *RoleUpdateOne) Select(field string, fields ...string) *RoleUpdateOne { - ruo.fields = append([]string{field}, fields...) - return ruo +func (_u *RoleUpdateOne) Select(field string, fields ...string) *RoleUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Role entity. -func (ruo *RoleUpdateOne) Save(ctx context.Context) (*Role, error) { - ruo.defaults() - return withHooks(ctx, ruo.sqlSave, ruo.mutation, ruo.hooks) +func (_u *RoleUpdateOne) Save(ctx context.Context) (*Role, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (ruo *RoleUpdateOne) SaveX(ctx context.Context) *Role { - node, err := ruo.Save(ctx) +func (_u *RoleUpdateOne) SaveX(ctx context.Context) *Role { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -888,39 +888,39 @@ func (ruo *RoleUpdateOne) SaveX(ctx context.Context) *Role { } // Exec executes the query on the entity. -func (ruo *RoleUpdateOne) Exec(ctx context.Context) error { - _, err := ruo.Save(ctx) +func (_u *RoleUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ruo *RoleUpdateOne) ExecX(ctx context.Context) { - if err := ruo.Exec(ctx); err != nil { +func (_u *RoleUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (ruo *RoleUpdateOne) defaults() { - if _, ok := ruo.mutation.UpdateTime(); !ok { +func (_u *RoleUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { v := role.UpdateDefaultUpdateTime() - ruo.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } } // check runs all checks and user-defined validators on the builder. -func (ruo *RoleUpdateOne) check() error { - if v, ok := ruo.mutation.Keyword(); ok { +func (_u *RoleUpdateOne) check() error { + if v, ok := _u.mutation.Keyword(); ok { if err := role.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Role.keyword": %w`, err)} } } - if v, ok := ruo.mutation.Name(); ok { + if v, ok := _u.mutation.Name(); ok { if err := role.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Role.name": %w`, err)} } } - if v, ok := ruo.mutation.Description(); ok { + if v, ok := _u.mutation.Description(); ok { if err := role.DescriptionValidator(v); err != nil { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Role.description": %w`, err)} } @@ -929,22 +929,22 @@ func (ruo *RoleUpdateOne) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (ruo *RoleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoleUpdateOne { - ruo.modifiers = append(ruo.modifiers, modifiers...) - return ruo +func (_u *RoleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoleUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) { - if err := ruo.check(); err != nil { +func (_u *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) - id, ok := ruo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Role.id" for update`)} } _spec.Node.ID.Value = id - if fields := ruo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, role.FieldID) for _, f := range fields { @@ -956,44 +956,44 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } } } - if ps := ruo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := ruo.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(role.FieldUpdateTime, field.TypeTime, value) } - if value, ok := ruo.mutation.Keyword(); ok { + if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(role.FieldKeyword, field.TypeString, value) } - if value, ok := ruo.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(role.FieldName, field.TypeString, value) } - if value, ok := ruo.mutation.Description(); ok { + if value, ok := _u.mutation.Description(); ok { _spec.SetField(role.FieldDescription, field.TypeString, value) } - if value, ok := ruo.mutation.GetType(); ok { + if value, ok := _u.mutation.GetType(); ok { _spec.SetField(role.FieldType, field.TypeInt8, value) } - if value, ok := ruo.mutation.AddedType(); ok { + if value, ok := _u.mutation.AddedType(); ok { _spec.AddField(role.FieldType, field.TypeInt8, value) } - if value, ok := ruo.mutation.Sequence(); ok { + if value, ok := _u.mutation.Sequence(); ok { _spec.SetField(role.FieldSequence, field.TypeInt, value) } - if value, ok := ruo.mutation.AddedSequence(); ok { + if value, ok := _u.mutation.AddedSequence(); ok { _spec.AddField(role.FieldSequence, field.TypeInt, value) } - if value, ok := ruo.mutation.Status(); ok { + if value, ok := _u.mutation.Status(); ok { _spec.SetField(role.FieldStatus, field.TypeInt8, value) } - if value, ok := ruo.mutation.AddedStatus(); ok { + if value, ok := _u.mutation.AddedStatus(); ok { _spec.AddField(role.FieldStatus, field.TypeInt8, value) } - if ruo.mutation.UsersCleared() { + if _u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1006,7 +1006,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.RemovedUsersIDs(); len(nodes) > 0 && !ruo.mutation.UsersCleared() { + if nodes := _u.mutation.RemovedUsersIDs(); len(nodes) > 0 && !_u.mutation.UsersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1022,7 +1022,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.UsersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UsersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1038,7 +1038,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ruo.mutation.PermissionsCleared() { + if _u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1051,7 +1051,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !ruo.mutation.PermissionsCleared() { + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1067,7 +1067,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.PermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1083,7 +1083,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ruo.mutation.UserRolesCleared() { + if _u.mutation.UserRolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1096,7 +1096,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !ruo.mutation.UserRolesCleared() { + if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1112,7 +1112,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.UserRolesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1128,7 +1128,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if ruo.mutation.RolePermissionsCleared() { + if _u.mutation.RolePermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1141,7 +1141,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !ruo.mutation.RolePermissionsCleared() { + if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1157,7 +1157,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := ruo.mutation.RolePermissionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1173,11 +1173,11 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(ruo.modifiers...) - _node = &Role{config: ruo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Role{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, ruo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{role.Label} } else if sqlgraph.IsConstraintError(err) { @@ -1185,7 +1185,7 @@ func (ruo *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) } return nil, err } - ruo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/rolepermission.go b/internal/data/entity/ent/rolepermission.go index cbcb7900..31210ebb 100644 --- a/internal/data/entity/ent/rolepermission.go +++ b/internal/data/entity/ent/rolepermission.go @@ -77,7 +77,7 @@ func (*RolePermission) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the RolePermission fields. -func (rp *RolePermission) assignValues(columns []string, values []any) error { +func (_m *RolePermission) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -88,21 +88,21 @@ func (rp *RolePermission) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - rp.ID = int(value.Int64) + _m.ID = int(value.Int64) case rolepermission.FieldRoleID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field role_id", values[i]) } else if value.Valid { - rp.RoleID = value.Int64 + _m.RoleID = value.Int64 } case rolepermission.FieldPermissionID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field permission_id", values[i]) } else if value.Valid { - rp.PermissionID = value.Int64 + _m.PermissionID = value.Int64 } default: - rp.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -110,48 +110,48 @@ func (rp *RolePermission) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the RolePermission. // This includes values selected through modifiers, order, etc. -func (rp *RolePermission) Value(name string) (ent.Value, error) { - return rp.selectValues.Get(name) +func (_m *RolePermission) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryRole queries the "role" edge of the RolePermission entity. -func (rp *RolePermission) QueryRole() *RoleQuery { - return NewRolePermissionClient(rp.config).QueryRole(rp) +func (_m *RolePermission) QueryRole() *RoleQuery { + return NewRolePermissionClient(_m.config).QueryRole(_m) } // QueryPermission queries the "permission" edge of the RolePermission entity. -func (rp *RolePermission) QueryPermission() *PermissionQuery { - return NewRolePermissionClient(rp.config).QueryPermission(rp) +func (_m *RolePermission) QueryPermission() *PermissionQuery { + return NewRolePermissionClient(_m.config).QueryPermission(_m) } // Update returns a builder for updating this RolePermission. // Note that you need to call RolePermission.Unwrap() before calling this method if this RolePermission // was returned from a transaction, and the transaction was committed or rolled back. -func (rp *RolePermission) Update() *RolePermissionUpdateOne { - return NewRolePermissionClient(rp.config).UpdateOne(rp) +func (_m *RolePermission) Update() *RolePermissionUpdateOne { + return NewRolePermissionClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the RolePermission entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (rp *RolePermission) Unwrap() *RolePermission { - _tx, ok := rp.config.driver.(*txDriver) +func (_m *RolePermission) Unwrap() *RolePermission { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: RolePermission is not a transactional entity") } - rp.config.driver = _tx.drv - return rp + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (rp *RolePermission) String() string { +func (_m *RolePermission) String() string { var builder strings.Builder builder.WriteString("RolePermission(") - builder.WriteString(fmt.Sprintf("id=%v, ", rp.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("role_id=") - builder.WriteString(fmt.Sprintf("%v", rp.RoleID)) + builder.WriteString(fmt.Sprintf("%v", _m.RoleID)) builder.WriteString(", ") builder.WriteString("permission_id=") - builder.WriteString(fmt.Sprintf("%v", rp.PermissionID)) + builder.WriteString(fmt.Sprintf("%v", _m.PermissionID)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/rolepermission_create.go b/internal/data/entity/ent/rolepermission_create.go index f0dbb800..e87bca97 100644 --- a/internal/data/entity/ent/rolepermission_create.go +++ b/internal/data/entity/ent/rolepermission_create.go @@ -22,40 +22,40 @@ type RolePermissionCreate struct { } // SetRoleID sets the "role_id" field. -func (rpc *RolePermissionCreate) SetRoleID(i int64) *RolePermissionCreate { - rpc.mutation.SetRoleID(i) - return rpc +func (_c *RolePermissionCreate) SetRoleID(v int64) *RolePermissionCreate { + _c.mutation.SetRoleID(v) + return _c } // SetPermissionID sets the "permission_id" field. -func (rpc *RolePermissionCreate) SetPermissionID(i int64) *RolePermissionCreate { - rpc.mutation.SetPermissionID(i) - return rpc +func (_c *RolePermissionCreate) SetPermissionID(v int64) *RolePermissionCreate { + _c.mutation.SetPermissionID(v) + return _c } // SetRole sets the "role" edge to the Role entity. -func (rpc *RolePermissionCreate) SetRole(r *Role) *RolePermissionCreate { - return rpc.SetRoleID(r.ID) +func (_c *RolePermissionCreate) SetRole(v *Role) *RolePermissionCreate { + return _c.SetRoleID(v.ID) } // SetPermission sets the "permission" edge to the Permission entity. -func (rpc *RolePermissionCreate) SetPermission(p *Permission) *RolePermissionCreate { - return rpc.SetPermissionID(p.ID) +func (_c *RolePermissionCreate) SetPermission(v *Permission) *RolePermissionCreate { + return _c.SetPermissionID(v.ID) } // Mutation returns the RolePermissionMutation object of the builder. -func (rpc *RolePermissionCreate) Mutation() *RolePermissionMutation { - return rpc.mutation +func (_c *RolePermissionCreate) Mutation() *RolePermissionMutation { + return _c.mutation } // Save creates the RolePermission in the database. -func (rpc *RolePermissionCreate) Save(ctx context.Context) (*RolePermission, error) { - return withHooks(ctx, rpc.sqlSave, rpc.mutation, rpc.hooks) +func (_c *RolePermissionCreate) Save(ctx context.Context) (*RolePermission, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (rpc *RolePermissionCreate) SaveX(ctx context.Context) *RolePermission { - v, err := rpc.Save(ctx) +func (_c *RolePermissionCreate) SaveX(ctx context.Context) *RolePermission { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -63,51 +63,51 @@ func (rpc *RolePermissionCreate) SaveX(ctx context.Context) *RolePermission { } // Exec executes the query. -func (rpc *RolePermissionCreate) Exec(ctx context.Context) error { - _, err := rpc.Save(ctx) +func (_c *RolePermissionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rpc *RolePermissionCreate) ExecX(ctx context.Context) { - if err := rpc.Exec(ctx); err != nil { +func (_c *RolePermissionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (rpc *RolePermissionCreate) check() error { - if _, ok := rpc.mutation.RoleID(); !ok { +func (_c *RolePermissionCreate) check() error { + if _, ok := _c.mutation.RoleID(); !ok { return &ValidationError{Name: "role_id", err: errors.New(`ent: missing required field "RolePermission.role_id"`)} } - if v, ok := rpc.mutation.RoleID(); ok { + if v, ok := _c.mutation.RoleID(); ok { if err := rolepermission.RoleIDValidator(v); err != nil { return &ValidationError{Name: "role_id", err: fmt.Errorf(`ent: validator failed for field "RolePermission.role_id": %w`, err)} } } - if _, ok := rpc.mutation.PermissionID(); !ok { + if _, ok := _c.mutation.PermissionID(); !ok { return &ValidationError{Name: "permission_id", err: errors.New(`ent: missing required field "RolePermission.permission_id"`)} } - if v, ok := rpc.mutation.PermissionID(); ok { + if v, ok := _c.mutation.PermissionID(); ok { if err := rolepermission.PermissionIDValidator(v); err != nil { return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "RolePermission.permission_id": %w`, err)} } } - if len(rpc.mutation.RoleIDs()) == 0 { + if len(_c.mutation.RoleIDs()) == 0 { return &ValidationError{Name: "role", err: errors.New(`ent: missing required edge "RolePermission.role"`)} } - if len(rpc.mutation.PermissionIDs()) == 0 { + if len(_c.mutation.PermissionIDs()) == 0 { return &ValidationError{Name: "permission", err: errors.New(`ent: missing required edge "RolePermission.permission"`)} } return nil } -func (rpc *RolePermissionCreate) sqlSave(ctx context.Context) (*RolePermission, error) { - if err := rpc.check(); err != nil { +func (_c *RolePermissionCreate) sqlSave(ctx context.Context) (*RolePermission, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := rpc.createSpec() - if err := sqlgraph.CreateNode(ctx, rpc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -115,17 +115,17 @@ func (rpc *RolePermissionCreate) sqlSave(ctx context.Context) (*RolePermission, } id := _spec.ID.Value.(int64) _node.ID = int(id) - rpc.mutation.id = &_node.ID - rpc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (rpc *RolePermissionCreate) createSpec() (*RolePermission, *sqlgraph.CreateSpec) { +func (_c *RolePermissionCreate) createSpec() (*RolePermission, *sqlgraph.CreateSpec) { var ( - _node = &RolePermission{config: rpc.config} + _node = &RolePermission{config: _c.config} _spec = sqlgraph.NewCreateSpec(rolepermission.Table, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) ) - if nodes := rpc.mutation.RoleIDs(); len(nodes) > 0 { + if nodes := _c.mutation.RoleIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -142,7 +142,7 @@ func (rpc *RolePermissionCreate) createSpec() (*RolePermission, *sqlgraph.Create _node.RoleID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := rpc.mutation.PermissionIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PermissionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -163,23 +163,23 @@ func (rpc *RolePermissionCreate) createSpec() (*RolePermission, *sqlgraph.Create } // SetRolePermission set the RolePermission -func (rpc *RolePermissionCreate) SetRolePermission(input *RolePermission, fields ...string) *RolePermissionCreate { - m := rpc.mutation +func (_c *RolePermissionCreate) SetRolePermission(input *RolePermission, fields ...string) *RolePermissionCreate { + m := _c.mutation if len(fields) == 0 { fields = rolepermission.Columns } _ = m.SetFields(input, fields...) - return rpc + return _c } // SetRolePermissionWithZero set the RolePermission -func (rpc *RolePermissionCreate) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionCreate { - m := rpc.mutation +func (_c *RolePermissionCreate) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionCreate { + m := _c.mutation if len(fields) == 0 { fields = rolepermission.Columns } _ = m.SetFieldsWithZero(input, fields...) - return rpc + return _c } // RolePermissionCreateBulk is the builder for creating many RolePermission entities in bulk. @@ -190,16 +190,16 @@ type RolePermissionCreateBulk struct { } // Save creates the RolePermission entities in the database. -func (rpcb *RolePermissionCreateBulk) Save(ctx context.Context) ([]*RolePermission, error) { - if rpcb.err != nil { - return nil, rpcb.err +func (_c *RolePermissionCreateBulk) Save(ctx context.Context) ([]*RolePermission, error) { + if _c.err != nil { + return nil, _c.err } - specs := make([]*sqlgraph.CreateSpec, len(rpcb.builders)) - nodes := make([]*RolePermission, len(rpcb.builders)) - mutators := make([]Mutator, len(rpcb.builders)) - for i := range rpcb.builders { + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*RolePermission, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := rpcb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*RolePermissionMutation) if !ok { @@ -212,11 +212,11 @@ func (rpcb *RolePermissionCreateBulk) Save(ctx context.Context) ([]*RolePermissi var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, rpcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, rpcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -240,7 +240,7 @@ func (rpcb *RolePermissionCreateBulk) Save(ctx context.Context) ([]*RolePermissi }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, rpcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -248,8 +248,8 @@ func (rpcb *RolePermissionCreateBulk) Save(ctx context.Context) ([]*RolePermissi } // SaveX is like Save, but panics if an error occurs. -func (rpcb *RolePermissionCreateBulk) SaveX(ctx context.Context) []*RolePermission { - v, err := rpcb.Save(ctx) +func (_c *RolePermissionCreateBulk) SaveX(ctx context.Context) []*RolePermission { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -257,14 +257,14 @@ func (rpcb *RolePermissionCreateBulk) SaveX(ctx context.Context) []*RolePermissi } // Exec executes the query. -func (rpcb *RolePermissionCreateBulk) Exec(ctx context.Context) error { - _, err := rpcb.Save(ctx) +func (_c *RolePermissionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rpcb *RolePermissionCreateBulk) ExecX(ctx context.Context) { - if err := rpcb.Exec(ctx); err != nil { +func (_c *RolePermissionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/rolepermission_delete.go b/internal/data/entity/ent/rolepermission_delete.go index d9add15f..742c020b 100644 --- a/internal/data/entity/ent/rolepermission_delete.go +++ b/internal/data/entity/ent/rolepermission_delete.go @@ -20,56 +20,56 @@ type RolePermissionDelete struct { } // Where appends a list predicates to the RolePermissionDelete builder. -func (rpd *RolePermissionDelete) Where(ps ...predicate.RolePermission) *RolePermissionDelete { - rpd.mutation.Where(ps...) - return rpd +func (_d *RolePermissionDelete) Where(ps ...predicate.RolePermission) *RolePermissionDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (rpd *RolePermissionDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, rpd.sqlExec, rpd.mutation, rpd.hooks) +func (_d *RolePermissionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (rpd *RolePermissionDelete) ExecX(ctx context.Context) int { - n, err := rpd.Exec(ctx) +func (_d *RolePermissionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (rpd *RolePermissionDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *RolePermissionDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(rolepermission.Table, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) - if ps := rpd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, rpd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - rpd.mutation.done = true + _d.mutation.done = true return affected, err } // RolePermissionDeleteOne is the builder for deleting a single RolePermission entity. type RolePermissionDeleteOne struct { - rpd *RolePermissionDelete + _d *RolePermissionDelete } // Where appends a list predicates to the RolePermissionDelete builder. -func (rpdo *RolePermissionDeleteOne) Where(ps ...predicate.RolePermission) *RolePermissionDeleteOne { - rpdo.rpd.mutation.Where(ps...) - return rpdo +func (_d *RolePermissionDeleteOne) Where(ps ...predicate.RolePermission) *RolePermissionDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (rpdo *RolePermissionDeleteOne) Exec(ctx context.Context) error { - n, err := rpdo.rpd.Exec(ctx) +func (_d *RolePermissionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (rpdo *RolePermissionDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (rpdo *RolePermissionDeleteOne) ExecX(ctx context.Context) { - if err := rpdo.Exec(ctx); err != nil { +func (_d *RolePermissionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/rolepermission_query.go b/internal/data/entity/ent/rolepermission_query.go index a20dc4dc..2f6cd66d 100644 --- a/internal/data/entity/ent/rolepermission_query.go +++ b/internal/data/entity/ent/rolepermission_query.go @@ -34,44 +34,44 @@ type RolePermissionQuery struct { } // Where adds a new predicate for the RolePermissionQuery builder. -func (rpq *RolePermissionQuery) Where(ps ...predicate.RolePermission) *RolePermissionQuery { - rpq.predicates = append(rpq.predicates, ps...) - return rpq +func (_q *RolePermissionQuery) Where(ps ...predicate.RolePermission) *RolePermissionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (rpq *RolePermissionQuery) Limit(limit int) *RolePermissionQuery { - rpq.ctx.Limit = &limit - return rpq +func (_q *RolePermissionQuery) Limit(limit int) *RolePermissionQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (rpq *RolePermissionQuery) Offset(offset int) *RolePermissionQuery { - rpq.ctx.Offset = &offset - return rpq +func (_q *RolePermissionQuery) Offset(offset int) *RolePermissionQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (rpq *RolePermissionQuery) Unique(unique bool) *RolePermissionQuery { - rpq.ctx.Unique = &unique - return rpq +func (_q *RolePermissionQuery) Unique(unique bool) *RolePermissionQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (rpq *RolePermissionQuery) Order(o ...rolepermission.OrderOption) *RolePermissionQuery { - rpq.order = append(rpq.order, o...) - return rpq +func (_q *RolePermissionQuery) Order(o ...rolepermission.OrderOption) *RolePermissionQuery { + _q.order = append(_q.order, o...) + return _q } // QueryRole chains the current query on the "role" edge. -func (rpq *RolePermissionQuery) QueryRole() *RoleQuery { - query := (&RoleClient{config: rpq.config}).Query() +func (_q *RolePermissionQuery) QueryRole() *RoleQuery { + query := (&RoleClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rpq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rpq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -80,20 +80,20 @@ func (rpq *RolePermissionQuery) QueryRole() *RoleQuery { sqlgraph.To(role.Table, role.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.RoleTable, rolepermission.RoleColumn), ) - fromU = sqlgraph.SetNeighbors(rpq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPermission chains the current query on the "permission" edge. -func (rpq *RolePermissionQuery) QueryPermission() *PermissionQuery { - query := (&PermissionClient{config: rpq.config}).Query() +func (_q *RolePermissionQuery) QueryPermission() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rpq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rpq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -102,7 +102,7 @@ func (rpq *RolePermissionQuery) QueryPermission() *PermissionQuery { sqlgraph.To(permission.Table, permission.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.PermissionTable, rolepermission.PermissionColumn), ) - fromU = sqlgraph.SetNeighbors(rpq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -110,8 +110,8 @@ func (rpq *RolePermissionQuery) QueryPermission() *PermissionQuery { // First returns the first RolePermission entity from the query. // Returns a *NotFoundError when no RolePermission was found. -func (rpq *RolePermissionQuery) First(ctx context.Context) (*RolePermission, error) { - nodes, err := rpq.Limit(1).All(setContextOp(ctx, rpq.ctx, ent.OpQueryFirst)) +func (_q *RolePermissionQuery) First(ctx context.Context) (*RolePermission, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -122,8 +122,8 @@ func (rpq *RolePermissionQuery) First(ctx context.Context) (*RolePermission, err } // FirstX is like First, but panics if an error occurs. -func (rpq *RolePermissionQuery) FirstX(ctx context.Context) *RolePermission { - node, err := rpq.First(ctx) +func (_q *RolePermissionQuery) FirstX(ctx context.Context) *RolePermission { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -132,9 +132,9 @@ func (rpq *RolePermissionQuery) FirstX(ctx context.Context) *RolePermission { // FirstID returns the first RolePermission ID from the query. // Returns a *NotFoundError when no RolePermission ID was found. -func (rpq *RolePermissionQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *RolePermissionQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = rpq.Limit(1).IDs(setContextOp(ctx, rpq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -145,8 +145,8 @@ func (rpq *RolePermissionQuery) FirstID(ctx context.Context) (id int, err error) } // FirstIDX is like FirstID, but panics if an error occurs. -func (rpq *RolePermissionQuery) FirstIDX(ctx context.Context) int { - id, err := rpq.FirstID(ctx) +func (_q *RolePermissionQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -156,8 +156,8 @@ func (rpq *RolePermissionQuery) FirstIDX(ctx context.Context) int { // Only returns a single RolePermission entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one RolePermission entity is found. // Returns a *NotFoundError when no RolePermission entities are found. -func (rpq *RolePermissionQuery) Only(ctx context.Context) (*RolePermission, error) { - nodes, err := rpq.Limit(2).All(setContextOp(ctx, rpq.ctx, ent.OpQueryOnly)) +func (_q *RolePermissionQuery) Only(ctx context.Context) (*RolePermission, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -172,8 +172,8 @@ func (rpq *RolePermissionQuery) Only(ctx context.Context) (*RolePermission, erro } // OnlyX is like Only, but panics if an error occurs. -func (rpq *RolePermissionQuery) OnlyX(ctx context.Context) *RolePermission { - node, err := rpq.Only(ctx) +func (_q *RolePermissionQuery) OnlyX(ctx context.Context) *RolePermission { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -183,9 +183,9 @@ func (rpq *RolePermissionQuery) OnlyX(ctx context.Context) *RolePermission { // OnlyID is like Only, but returns the only RolePermission ID in the query. // Returns a *NotSingularError when more than one RolePermission ID is found. // Returns a *NotFoundError when no entities are found. -func (rpq *RolePermissionQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *RolePermissionQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = rpq.Limit(2).IDs(setContextOp(ctx, rpq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -200,8 +200,8 @@ func (rpq *RolePermissionQuery) OnlyID(ctx context.Context) (id int, err error) } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (rpq *RolePermissionQuery) OnlyIDX(ctx context.Context) int { - id, err := rpq.OnlyID(ctx) +func (_q *RolePermissionQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -209,18 +209,18 @@ func (rpq *RolePermissionQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of RolePermissions. -func (rpq *RolePermissionQuery) All(ctx context.Context) ([]*RolePermission, error) { - ctx = setContextOp(ctx, rpq.ctx, ent.OpQueryAll) - if err := rpq.prepareQuery(ctx); err != nil { +func (_q *RolePermissionQuery) All(ctx context.Context) ([]*RolePermission, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*RolePermission, *RolePermissionQuery]() - return withInterceptors[[]*RolePermission](ctx, rpq, qr, rpq.inters) + return withInterceptors[[]*RolePermission](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (rpq *RolePermissionQuery) AllX(ctx context.Context) []*RolePermission { - nodes, err := rpq.All(ctx) +func (_q *RolePermissionQuery) AllX(ctx context.Context) []*RolePermission { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -228,20 +228,20 @@ func (rpq *RolePermissionQuery) AllX(ctx context.Context) []*RolePermission { } // IDs executes the query and returns a list of RolePermission IDs. -func (rpq *RolePermissionQuery) IDs(ctx context.Context) (ids []int, err error) { - if rpq.ctx.Unique == nil && rpq.path != nil { - rpq.Unique(true) +func (_q *RolePermissionQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, rpq.ctx, ent.OpQueryIDs) - if err = rpq.Select(rolepermission.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(rolepermission.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (rpq *RolePermissionQuery) IDsX(ctx context.Context) []int { - ids, err := rpq.IDs(ctx) +func (_q *RolePermissionQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -249,17 +249,17 @@ func (rpq *RolePermissionQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (rpq *RolePermissionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, rpq.ctx, ent.OpQueryCount) - if err := rpq.prepareQuery(ctx); err != nil { +func (_q *RolePermissionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, rpq, querierCount[*RolePermissionQuery](), rpq.inters) + return withInterceptors[int](ctx, _q, querierCount[*RolePermissionQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (rpq *RolePermissionQuery) CountX(ctx context.Context) int { - count, err := rpq.Count(ctx) +func (_q *RolePermissionQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -267,9 +267,9 @@ func (rpq *RolePermissionQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (rpq *RolePermissionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, rpq.ctx, ent.OpQueryExist) - switch _, err := rpq.FirstID(ctx); { +func (_q *RolePermissionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -280,8 +280,8 @@ func (rpq *RolePermissionQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (rpq *RolePermissionQuery) ExistX(ctx context.Context) bool { - exist, err := rpq.Exist(ctx) +func (_q *RolePermissionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -290,45 +290,45 @@ func (rpq *RolePermissionQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the RolePermissionQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (rpq *RolePermissionQuery) Clone() *RolePermissionQuery { - if rpq == nil { +func (_q *RolePermissionQuery) Clone() *RolePermissionQuery { + if _q == nil { return nil } return &RolePermissionQuery{ - config: rpq.config, - ctx: rpq.ctx.Clone(), - order: append([]rolepermission.OrderOption{}, rpq.order...), - inters: append([]Interceptor{}, rpq.inters...), - predicates: append([]predicate.RolePermission{}, rpq.predicates...), - withRole: rpq.withRole.Clone(), - withPermission: rpq.withPermission.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]rolepermission.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.RolePermission{}, _q.predicates...), + withRole: _q.withRole.Clone(), + withPermission: _q.withPermission.Clone(), // clone intermediate query. - sql: rpq.sql.Clone(), - path: rpq.path, - modifiers: append([]func(*sql.Selector){}, rpq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithRole tells the query-builder to eager-load the nodes that are connected to // the "role" edge. The optional arguments are used to configure the query builder of the edge. -func (rpq *RolePermissionQuery) WithRole(opts ...func(*RoleQuery)) *RolePermissionQuery { - query := (&RoleClient{config: rpq.config}).Query() +func (_q *RolePermissionQuery) WithRole(opts ...func(*RoleQuery)) *RolePermissionQuery { + query := (&RoleClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rpq.withRole = query - return rpq + _q.withRole = query + return _q } // WithPermission tells the query-builder to eager-load the nodes that are connected to // the "permission" edge. The optional arguments are used to configure the query builder of the edge. -func (rpq *RolePermissionQuery) WithPermission(opts ...func(*PermissionQuery)) *RolePermissionQuery { - query := (&PermissionClient{config: rpq.config}).Query() +func (_q *RolePermissionQuery) WithPermission(opts ...func(*PermissionQuery)) *RolePermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rpq.withPermission = query - return rpq + _q.withPermission = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -345,10 +345,10 @@ func (rpq *RolePermissionQuery) WithPermission(opts ...func(*PermissionQuery)) * // GroupBy(rolepermission.FieldRoleID). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (rpq *RolePermissionQuery) GroupBy(field string, fields ...string) *RolePermissionGroupBy { - rpq.ctx.Fields = append([]string{field}, fields...) - grbuild := &RolePermissionGroupBy{build: rpq} - grbuild.flds = &rpq.ctx.Fields +func (_q *RolePermissionQuery) GroupBy(field string, fields ...string) *RolePermissionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &RolePermissionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = rolepermission.Label grbuild.scan = grbuild.Scan return grbuild @@ -366,83 +366,83 @@ func (rpq *RolePermissionQuery) GroupBy(field string, fields ...string) *RolePer // client.RolePermission.Query(). // Select(rolepermission.FieldRoleID). // Scan(ctx, &v) -func (rpq *RolePermissionQuery) Select(fields ...string) *RolePermissionSelect { - rpq.ctx.Fields = append(rpq.ctx.Fields, fields...) - sbuild := &RolePermissionSelect{RolePermissionQuery: rpq} +func (_q *RolePermissionQuery) Select(fields ...string) *RolePermissionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &RolePermissionSelect{RolePermissionQuery: _q} sbuild.label = rolepermission.Label - sbuild.flds, sbuild.scan = &rpq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a RolePermissionSelect configured with the given aggregations. -func (rpq *RolePermissionQuery) Aggregate(fns ...AggregateFunc) *RolePermissionSelect { - return rpq.Select().Aggregate(fns...) +func (_q *RolePermissionQuery) Aggregate(fns ...AggregateFunc) *RolePermissionSelect { + return _q.Select().Aggregate(fns...) } -func (rpq *RolePermissionQuery) prepareQuery(ctx context.Context) error { - for _, inter := range rpq.inters { +func (_q *RolePermissionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, rpq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range rpq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !rolepermission.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if rpq.path != nil { - prev, err := rpq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - rpq.sql = prev + _q.sql = prev } return nil } -func (rpq *RolePermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*RolePermission, error) { +func (_q *RolePermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*RolePermission, error) { var ( nodes = []*RolePermission{} - _spec = rpq.querySpec() + _spec = _q.querySpec() loadedTypes = [2]bool{ - rpq.withRole != nil, - rpq.withPermission != nil, + _q.withRole != nil, + _q.withPermission != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*RolePermission).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &RolePermission{config: rpq.config} + node := &RolePermission{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(rpq.modifiers) > 0 { - _spec.Modifiers = rpq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, rpq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := rpq.withRole; query != nil { - if err := rpq.loadRole(ctx, query, nodes, nil, + if query := _q.withRole; query != nil { + if err := _q.loadRole(ctx, query, nodes, nil, func(n *RolePermission, e *Role) { n.Edges.Role = e }); err != nil { return nil, err } } - if query := rpq.withPermission; query != nil { - if err := rpq.loadPermission(ctx, query, nodes, nil, + if query := _q.withPermission; query != nil { + if err := _q.loadPermission(ctx, query, nodes, nil, func(n *RolePermission, e *Permission) { n.Edges.Permission = e }); err != nil { return nil, err } @@ -450,7 +450,7 @@ func (rpq *RolePermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) return nodes, nil } -func (rpq *RolePermissionQuery) loadRole(ctx context.Context, query *RoleQuery, nodes []*RolePermission, init func(*RolePermission), assign func(*RolePermission, *Role)) error { +func (_q *RolePermissionQuery) loadRole(ctx context.Context, query *RoleQuery, nodes []*RolePermission, init func(*RolePermission), assign func(*RolePermission, *Role)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*RolePermission) for i := range nodes { @@ -479,7 +479,7 @@ func (rpq *RolePermissionQuery) loadRole(ctx context.Context, query *RoleQuery, } return nil } -func (rpq *RolePermissionQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*RolePermission, init func(*RolePermission), assign func(*RolePermission, *Permission)) error { +func (_q *RolePermissionQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*RolePermission, init func(*RolePermission), assign func(*RolePermission, *Permission)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*RolePermission) for i := range nodes { @@ -509,27 +509,27 @@ func (rpq *RolePermissionQuery) loadPermission(ctx context.Context, query *Permi return nil } -func (rpq *RolePermissionQuery) sqlCount(ctx context.Context) (int, error) { - _spec := rpq.querySpec() - if len(rpq.modifiers) > 0 { - _spec.Modifiers = rpq.modifiers +func (_q *RolePermissionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = rpq.ctx.Fields - if len(rpq.ctx.Fields) > 0 { - _spec.Unique = rpq.ctx.Unique != nil && *rpq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, rpq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (rpq *RolePermissionQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *RolePermissionQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(rolepermission.Table, rolepermission.Columns, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) - _spec.From = rpq.sql - if unique := rpq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if rpq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := rpq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, rolepermission.FieldID) for i := range fields { @@ -537,27 +537,27 @@ func (rpq *RolePermissionQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if rpq.withRole != nil { + if _q.withRole != nil { _spec.Node.AddColumnOnce(rolepermission.FieldRoleID) } - if rpq.withPermission != nil { + if _q.withPermission != nil { _spec.Node.AddColumnOnce(rolepermission.FieldPermissionID) } } - if ps := rpq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := rpq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := rpq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := rpq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -567,36 +567,36 @@ func (rpq *RolePermissionQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (rpq *RolePermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(rpq.driver.Dialect()) +func (_q *RolePermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(rolepermission.Table) - columns := rpq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = rolepermission.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if rpq.sql != nil { - selector = rpq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if rpq.ctx.Unique != nil && *rpq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range rpq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range rpq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range rpq.order { + for _, p := range _q.order { p(selector) } - if offset := rpq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := rpq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -605,33 +605,33 @@ func (rpq *RolePermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (rpq *RolePermissionQuery) ForUpdate(opts ...sql.LockOption) *RolePermissionQuery { - if rpq.driver.Dialect() == dialect.Postgres { - rpq.Unique(false) +func (_q *RolePermissionQuery) ForUpdate(opts ...sql.LockOption) *RolePermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - rpq.modifiers = append(rpq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return rpq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (rpq *RolePermissionQuery) ForShare(opts ...sql.LockOption) *RolePermissionQuery { - if rpq.driver.Dialect() == dialect.Postgres { - rpq.Unique(false) +func (_q *RolePermissionQuery) ForShare(opts ...sql.LockOption) *RolePermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - rpq.modifiers = append(rpq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return rpq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (rpq *RolePermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *RolePermissionSelect { - rpq.modifiers = append(rpq.modifiers, modifiers...) - return rpq.Select() +func (_q *RolePermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *RolePermissionSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -673,41 +673,41 @@ type RolePermissionGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (rpgb *RolePermissionGroupBy) Aggregate(fns ...AggregateFunc) *RolePermissionGroupBy { - rpgb.fns = append(rpgb.fns, fns...) - return rpgb +func (_g *RolePermissionGroupBy) Aggregate(fns ...AggregateFunc) *RolePermissionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (rpgb *RolePermissionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, rpgb.build.ctx, ent.OpQueryGroupBy) - if err := rpgb.build.prepareQuery(ctx); err != nil { +func (_g *RolePermissionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*RolePermissionQuery, *RolePermissionGroupBy](ctx, rpgb.build, rpgb, rpgb.build.inters, v) + return scanWithInterceptors[*RolePermissionQuery, *RolePermissionGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (rpgb *RolePermissionGroupBy) sqlScan(ctx context.Context, root *RolePermissionQuery, v any) error { +func (_g *RolePermissionGroupBy) sqlScan(ctx context.Context, root *RolePermissionQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(rpgb.fns)) - for _, fn := range rpgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*rpgb.flds)+len(rpgb.fns)) - for _, f := range *rpgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*rpgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := rpgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -721,27 +721,27 @@ type RolePermissionSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (rps *RolePermissionSelect) Aggregate(fns ...AggregateFunc) *RolePermissionSelect { - rps.fns = append(rps.fns, fns...) - return rps +func (_s *RolePermissionSelect) Aggregate(fns ...AggregateFunc) *RolePermissionSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (rps *RolePermissionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, rps.ctx, ent.OpQuerySelect) - if err := rps.prepareQuery(ctx); err != nil { +func (_s *RolePermissionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*RolePermissionQuery, *RolePermissionSelect](ctx, rps.RolePermissionQuery, rps, rps.inters, v) + return scanWithInterceptors[*RolePermissionQuery, *RolePermissionSelect](ctx, _s.RolePermissionQuery, _s, _s.inters, v) } -func (rps *RolePermissionSelect) sqlScan(ctx context.Context, root *RolePermissionQuery, v any) error { +func (_s *RolePermissionSelect) sqlScan(ctx context.Context, root *RolePermissionQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(rps.fns)) - for _, fn := range rps.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*rps.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -749,7 +749,7 @@ func (rps *RolePermissionSelect) sqlScan(ctx context.Context, root *RolePermissi } rows := &sql.Rows{} query, args := selector.Query() - if err := rps.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -757,7 +757,7 @@ func (rps *RolePermissionSelect) sqlScan(ctx context.Context, root *RolePermissi } // Modify adds a query modifier for attaching custom logic to queries. -func (rps *RolePermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *RolePermissionSelect { - rps.modifiers = append(rps.modifiers, modifiers...) - return rps +func (_s *RolePermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *RolePermissionSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/rolepermission_update.go b/internal/data/entity/ent/rolepermission_update.go index a9c7534a..bd214577 100644 --- a/internal/data/entity/ent/rolepermission_update.go +++ b/internal/data/entity/ent/rolepermission_update.go @@ -25,74 +25,74 @@ type RolePermissionUpdate struct { } // Where appends a list predicates to the RolePermissionUpdate builder. -func (rpu *RolePermissionUpdate) Where(ps ...predicate.RolePermission) *RolePermissionUpdate { - rpu.mutation.Where(ps...) - return rpu +func (_u *RolePermissionUpdate) Where(ps ...predicate.RolePermission) *RolePermissionUpdate { + _u.mutation.Where(ps...) + return _u } // SetRoleID sets the "role_id" field. -func (rpu *RolePermissionUpdate) SetRoleID(i int64) *RolePermissionUpdate { - rpu.mutation.SetRoleID(i) - return rpu +func (_u *RolePermissionUpdate) SetRoleID(v int64) *RolePermissionUpdate { + _u.mutation.SetRoleID(v) + return _u } // SetNillableRoleID sets the "role_id" field if the given value is not nil. -func (rpu *RolePermissionUpdate) SetNillableRoleID(i *int64) *RolePermissionUpdate { - if i != nil { - rpu.SetRoleID(*i) +func (_u *RolePermissionUpdate) SetNillableRoleID(v *int64) *RolePermissionUpdate { + if v != nil { + _u.SetRoleID(*v) } - return rpu + return _u } // SetPermissionID sets the "permission_id" field. -func (rpu *RolePermissionUpdate) SetPermissionID(i int64) *RolePermissionUpdate { - rpu.mutation.SetPermissionID(i) - return rpu +func (_u *RolePermissionUpdate) SetPermissionID(v int64) *RolePermissionUpdate { + _u.mutation.SetPermissionID(v) + return _u } // SetNillablePermissionID sets the "permission_id" field if the given value is not nil. -func (rpu *RolePermissionUpdate) SetNillablePermissionID(i *int64) *RolePermissionUpdate { - if i != nil { - rpu.SetPermissionID(*i) +func (_u *RolePermissionUpdate) SetNillablePermissionID(v *int64) *RolePermissionUpdate { + if v != nil { + _u.SetPermissionID(*v) } - return rpu + return _u } // SetRole sets the "role" edge to the Role entity. -func (rpu *RolePermissionUpdate) SetRole(r *Role) *RolePermissionUpdate { - return rpu.SetRoleID(r.ID) +func (_u *RolePermissionUpdate) SetRole(v *Role) *RolePermissionUpdate { + return _u.SetRoleID(v.ID) } // SetPermission sets the "permission" edge to the Permission entity. -func (rpu *RolePermissionUpdate) SetPermission(p *Permission) *RolePermissionUpdate { - return rpu.SetPermissionID(p.ID) +func (_u *RolePermissionUpdate) SetPermission(v *Permission) *RolePermissionUpdate { + return _u.SetPermissionID(v.ID) } // Mutation returns the RolePermissionMutation object of the builder. -func (rpu *RolePermissionUpdate) Mutation() *RolePermissionMutation { - return rpu.mutation +func (_u *RolePermissionUpdate) Mutation() *RolePermissionMutation { + return _u.mutation } // ClearRole clears the "role" edge to the Role entity. -func (rpu *RolePermissionUpdate) ClearRole() *RolePermissionUpdate { - rpu.mutation.ClearRole() - return rpu +func (_u *RolePermissionUpdate) ClearRole() *RolePermissionUpdate { + _u.mutation.ClearRole() + return _u } // ClearPermission clears the "permission" edge to the Permission entity. -func (rpu *RolePermissionUpdate) ClearPermission() *RolePermissionUpdate { - rpu.mutation.ClearPermission() - return rpu +func (_u *RolePermissionUpdate) ClearPermission() *RolePermissionUpdate { + _u.mutation.ClearPermission() + return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (rpu *RolePermissionUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, rpu.sqlSave, rpu.mutation, rpu.hooks) +func (_u *RolePermissionUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (rpu *RolePermissionUpdate) SaveX(ctx context.Context) int { - affected, err := rpu.Save(ctx) +func (_u *RolePermissionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -100,58 +100,58 @@ func (rpu *RolePermissionUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (rpu *RolePermissionUpdate) Exec(ctx context.Context) error { - _, err := rpu.Save(ctx) +func (_u *RolePermissionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rpu *RolePermissionUpdate) ExecX(ctx context.Context) { - if err := rpu.Exec(ctx); err != nil { +func (_u *RolePermissionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (rpu *RolePermissionUpdate) check() error { - if v, ok := rpu.mutation.RoleID(); ok { +func (_u *RolePermissionUpdate) check() error { + if v, ok := _u.mutation.RoleID(); ok { if err := rolepermission.RoleIDValidator(v); err != nil { return &ValidationError{Name: "role_id", err: fmt.Errorf(`ent: validator failed for field "RolePermission.role_id": %w`, err)} } } - if v, ok := rpu.mutation.PermissionID(); ok { + if v, ok := _u.mutation.PermissionID(); ok { if err := rolepermission.PermissionIDValidator(v); err != nil { return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "RolePermission.permission_id": %w`, err)} } } - if rpu.mutation.RoleCleared() && len(rpu.mutation.RoleIDs()) > 0 { + if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "RolePermission.role"`) } - if rpu.mutation.PermissionCleared() && len(rpu.mutation.PermissionIDs()) > 0 { + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "RolePermission.permission"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (rpu *RolePermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RolePermissionUpdate { - rpu.modifiers = append(rpu.modifiers, modifiers...) - return rpu +func (_u *RolePermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RolePermissionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (rpu *RolePermissionUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := rpu.check(); err != nil { - return n, err +func (_u *RolePermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(rolepermission.Table, rolepermission.Columns, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) - if ps := rpu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if rpu.mutation.RoleCleared() { + if _u.mutation.RoleCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -164,7 +164,7 @@ func (rpu *RolePermissionUpdate) sqlSave(ctx context.Context) (n int, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := rpu.mutation.RoleIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -180,7 +180,7 @@ func (rpu *RolePermissionUpdate) sqlSave(ctx context.Context) (n int, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if rpu.mutation.PermissionCleared() { + if _u.mutation.PermissionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -193,7 +193,7 @@ func (rpu *RolePermissionUpdate) sqlSave(ctx context.Context) (n int, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := rpu.mutation.PermissionIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -209,8 +209,8 @@ func (rpu *RolePermissionUpdate) sqlSave(ctx context.Context) (n int, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(rpu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, rpu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{rolepermission.Label} } else if sqlgraph.IsConstraintError(err) { @@ -218,8 +218,8 @@ func (rpu *RolePermissionUpdate) sqlSave(ctx context.Context) (n int, err error) } return 0, err } - rpu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // RolePermissionUpdateOne is the builder for updating a single RolePermission entity. @@ -232,81 +232,81 @@ type RolePermissionUpdateOne struct { } // SetRoleID sets the "role_id" field. -func (rpuo *RolePermissionUpdateOne) SetRoleID(i int64) *RolePermissionUpdateOne { - rpuo.mutation.SetRoleID(i) - return rpuo +func (_u *RolePermissionUpdateOne) SetRoleID(v int64) *RolePermissionUpdateOne { + _u.mutation.SetRoleID(v) + return _u } // SetNillableRoleID sets the "role_id" field if the given value is not nil. -func (rpuo *RolePermissionUpdateOne) SetNillableRoleID(i *int64) *RolePermissionUpdateOne { - if i != nil { - rpuo.SetRoleID(*i) +func (_u *RolePermissionUpdateOne) SetNillableRoleID(v *int64) *RolePermissionUpdateOne { + if v != nil { + _u.SetRoleID(*v) } - return rpuo + return _u } // SetPermissionID sets the "permission_id" field. -func (rpuo *RolePermissionUpdateOne) SetPermissionID(i int64) *RolePermissionUpdateOne { - rpuo.mutation.SetPermissionID(i) - return rpuo +func (_u *RolePermissionUpdateOne) SetPermissionID(v int64) *RolePermissionUpdateOne { + _u.mutation.SetPermissionID(v) + return _u } // SetNillablePermissionID sets the "permission_id" field if the given value is not nil. -func (rpuo *RolePermissionUpdateOne) SetNillablePermissionID(i *int64) *RolePermissionUpdateOne { - if i != nil { - rpuo.SetPermissionID(*i) +func (_u *RolePermissionUpdateOne) SetNillablePermissionID(v *int64) *RolePermissionUpdateOne { + if v != nil { + _u.SetPermissionID(*v) } - return rpuo + return _u } // SetRole sets the "role" edge to the Role entity. -func (rpuo *RolePermissionUpdateOne) SetRole(r *Role) *RolePermissionUpdateOne { - return rpuo.SetRoleID(r.ID) +func (_u *RolePermissionUpdateOne) SetRole(v *Role) *RolePermissionUpdateOne { + return _u.SetRoleID(v.ID) } // SetPermission sets the "permission" edge to the Permission entity. -func (rpuo *RolePermissionUpdateOne) SetPermission(p *Permission) *RolePermissionUpdateOne { - return rpuo.SetPermissionID(p.ID) +func (_u *RolePermissionUpdateOne) SetPermission(v *Permission) *RolePermissionUpdateOne { + return _u.SetPermissionID(v.ID) } // Mutation returns the RolePermissionMutation object of the builder. -func (rpuo *RolePermissionUpdateOne) Mutation() *RolePermissionMutation { - return rpuo.mutation +func (_u *RolePermissionUpdateOne) Mutation() *RolePermissionMutation { + return _u.mutation } // ClearRole clears the "role" edge to the Role entity. -func (rpuo *RolePermissionUpdateOne) ClearRole() *RolePermissionUpdateOne { - rpuo.mutation.ClearRole() - return rpuo +func (_u *RolePermissionUpdateOne) ClearRole() *RolePermissionUpdateOne { + _u.mutation.ClearRole() + return _u } // ClearPermission clears the "permission" edge to the Permission entity. -func (rpuo *RolePermissionUpdateOne) ClearPermission() *RolePermissionUpdateOne { - rpuo.mutation.ClearPermission() - return rpuo +func (_u *RolePermissionUpdateOne) ClearPermission() *RolePermissionUpdateOne { + _u.mutation.ClearPermission() + return _u } // Where appends a list predicates to the RolePermissionUpdate builder. -func (rpuo *RolePermissionUpdateOne) Where(ps ...predicate.RolePermission) *RolePermissionUpdateOne { - rpuo.mutation.Where(ps...) - return rpuo +func (_u *RolePermissionUpdateOne) Where(ps ...predicate.RolePermission) *RolePermissionUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (rpuo *RolePermissionUpdateOne) Select(field string, fields ...string) *RolePermissionUpdateOne { - rpuo.fields = append([]string{field}, fields...) - return rpuo +func (_u *RolePermissionUpdateOne) Select(field string, fields ...string) *RolePermissionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated RolePermission entity. -func (rpuo *RolePermissionUpdateOne) Save(ctx context.Context) (*RolePermission, error) { - return withHooks(ctx, rpuo.sqlSave, rpuo.mutation, rpuo.hooks) +func (_u *RolePermissionUpdateOne) Save(ctx context.Context) (*RolePermission, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (rpuo *RolePermissionUpdateOne) SaveX(ctx context.Context) *RolePermission { - node, err := rpuo.Save(ctx) +func (_u *RolePermissionUpdateOne) SaveX(ctx context.Context) *RolePermission { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -314,56 +314,56 @@ func (rpuo *RolePermissionUpdateOne) SaveX(ctx context.Context) *RolePermission } // Exec executes the query on the entity. -func (rpuo *RolePermissionUpdateOne) Exec(ctx context.Context) error { - _, err := rpuo.Save(ctx) +func (_u *RolePermissionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rpuo *RolePermissionUpdateOne) ExecX(ctx context.Context) { - if err := rpuo.Exec(ctx); err != nil { +func (_u *RolePermissionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (rpuo *RolePermissionUpdateOne) check() error { - if v, ok := rpuo.mutation.RoleID(); ok { +func (_u *RolePermissionUpdateOne) check() error { + if v, ok := _u.mutation.RoleID(); ok { if err := rolepermission.RoleIDValidator(v); err != nil { return &ValidationError{Name: "role_id", err: fmt.Errorf(`ent: validator failed for field "RolePermission.role_id": %w`, err)} } } - if v, ok := rpuo.mutation.PermissionID(); ok { + if v, ok := _u.mutation.PermissionID(); ok { if err := rolepermission.PermissionIDValidator(v); err != nil { return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "RolePermission.permission_id": %w`, err)} } } - if rpuo.mutation.RoleCleared() && len(rpuo.mutation.RoleIDs()) > 0 { + if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "RolePermission.role"`) } - if rpuo.mutation.PermissionCleared() && len(rpuo.mutation.PermissionIDs()) > 0 { + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "RolePermission.permission"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (rpuo *RolePermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RolePermissionUpdateOne { - rpuo.modifiers = append(rpuo.modifiers, modifiers...) - return rpuo +func (_u *RolePermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RolePermissionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (rpuo *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePermission, err error) { - if err := rpuo.check(); err != nil { +func (_u *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePermission, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(rolepermission.Table, rolepermission.Columns, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) - id, ok := rpuo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RolePermission.id" for update`)} } _spec.Node.ID.Value = id - if fields := rpuo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, rolepermission.FieldID) for _, f := range fields { @@ -375,14 +375,14 @@ func (rpuo *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePe } } } - if ps := rpuo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if rpuo.mutation.RoleCleared() { + if _u.mutation.RoleCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -395,7 +395,7 @@ func (rpuo *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePe } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := rpuo.mutation.RoleIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -411,7 +411,7 @@ func (rpuo *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePe } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if rpuo.mutation.PermissionCleared() { + if _u.mutation.PermissionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -424,7 +424,7 @@ func (rpuo *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePe } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := rpuo.mutation.PermissionIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -440,11 +440,11 @@ func (rpuo *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePe } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(rpuo.modifiers...) - _node = &RolePermission{config: rpuo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &RolePermission{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, rpuo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{rolepermission.Label} } else if sqlgraph.IsConstraintError(err) { @@ -452,7 +452,7 @@ func (rpuo *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePe } return nil, err } - rpuo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index 027fd4fc..3dd6911a 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -621,6 +621,6 @@ func init() { } const ( - Version = "v0.14.4" // Version of ent codegen. - Sum = "h1:/DhDraSLXIkBhyiVoJeSshr4ZYi7femzhj6/TckzZuI=" // Sum of ent codegen. + Version = "v0.14.5" // Version of ent codegen. + Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen. ) diff --git a/internal/data/entity/ent/user.go b/internal/data/entity/ent/user.go index 436bdf10..28cf0feb 100644 --- a/internal/data/entity/ent/user.go +++ b/internal/data/entity/ent/user.go @@ -175,7 +175,7 @@ func (*User) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the User fields. -func (u *User) assignValues(columns []string, values []any) error { +func (_m *User) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -186,172 +186,172 @@ func (u *User) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - u.ID = int64(value.Int64) + _m.ID = int64(value.Int64) case user.FieldCreateAuthor: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field create_author", values[i]) } else if value.Valid { - u.CreateAuthor = value.Int64 + _m.CreateAuthor = value.Int64 } case user.FieldUpdateAuthor: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field update_author", values[i]) } else if value.Valid { - u.UpdateAuthor = value.Int64 + _m.UpdateAuthor = value.Int64 } case user.FieldCreateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field create_time", values[i]) } else if value.Valid { - u.CreateTime = value.Time + _m.CreateTime = value.Time } case user.FieldUpdateTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field update_time", values[i]) } else if value.Valid { - u.UpdateTime = value.Time + _m.UpdateTime = value.Time } case user.FieldDeleteTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field delete_time", values[i]) } else if value.Valid { - u.DeleteTime = new(time.Time) - *u.DeleteTime = value.Time + _m.DeleteTime = new(time.Time) + *_m.DeleteTime = value.Time } case user.FieldUUID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field uuid", values[i]) } else if value.Valid { - u.UUID = value.String + _m.UUID = value.String } case user.FieldAllowedIP: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field allowed_ip", values[i]) } else if value.Valid { - u.AllowedIP = value.String + _m.AllowedIP = value.String } case user.FieldUsername: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field username", values[i]) } else if value.Valid { - u.Username = value.String + _m.Username = value.String } case user.FieldNickname: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field nickname", values[i]) } else if value.Valid { - u.Nickname = value.String + _m.Nickname = value.String } case user.FieldAvatar: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field avatar", values[i]) } else if value.Valid { - u.Avatar = value.String + _m.Avatar = value.String } case user.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { - u.Name = value.String + _m.Name = value.String } case user.FieldGender: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field gender", values[i]) } else if value.Valid { - u.Gender = user.Gender(value.String) + _m.Gender = user.Gender(value.String) } case user.FieldEncryptedPassword: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field encrypted_password", values[i]) } else if value.Valid { - u.EncryptedPassword = value.String + _m.EncryptedPassword = value.String } case user.FieldSalt: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field salt", values[i]) } else if value.Valid { - u.Salt = value.String + _m.Salt = value.String } case user.FieldPhone: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field phone", values[i]) } else if value.Valid { - u.Phone = value.String + _m.Phone = value.String } case user.FieldEmail: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field email", values[i]) } else if value.Valid { - u.Email = value.String + _m.Email = value.String } case user.FieldDepartment: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field department", values[i]) } else if value.Valid { - u.Department = value.String + _m.Department = value.String } case user.FieldRemark: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field remark", values[i]) } else if value.Valid { - u.Remark = value.String + _m.Remark = value.String } case user.FieldToken: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field token", values[i]) } else if value.Valid { - u.Token = value.String + _m.Token = value.String } case user.FieldStatus: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - u.Status = int8(value.Int64) + _m.Status = int8(value.Int64) } case user.FieldIsSystem: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field is_system", values[i]) } else if value.Valid { - u.IsSystem = value.Bool + _m.IsSystem = value.Bool } case user.FieldLastLoginIP: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field last_login_ip", values[i]) } else if value.Valid { - u.LastLoginIP = value.String + _m.LastLoginIP = value.String } case user.FieldLastLoginTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field last_login_time", values[i]) } else if value.Valid { - u.LastLoginTime = value.Time + _m.LastLoginTime = value.Time } case user.FieldLoginTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field login_time", values[i]) } else if value.Valid { - u.LoginTime = value.Time + _m.LoginTime = value.Time } case user.FieldSanctionDate: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field sanction_date", values[i]) } else if value.Valid { - u.SanctionDate = value.Time + _m.SanctionDate = value.Time } case user.FieldManagerID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field manager_id", values[i]) } else if value.Valid { - u.ManagerID = value.Int64 + _m.ManagerID = value.Int64 } case user.FieldManager: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field manager", values[i]) } else if value.Valid { - u.Manager = value.String + _m.Manager = value.String } default: - u.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -359,145 +359,145 @@ func (u *User) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the User. // This includes values selected through modifiers, order, etc. -func (u *User) Value(name string) (ent.Value, error) { - return u.selectValues.Get(name) +func (_m *User) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryRoles queries the "roles" edge of the User entity. -func (u *User) QueryRoles() *RoleQuery { - return NewUserClient(u.config).QueryRoles(u) +func (_m *User) QueryRoles() *RoleQuery { + return NewUserClient(_m.config).QueryRoles(_m) } // QueryPositions queries the "positions" edge of the User entity. -func (u *User) QueryPositions() *PositionQuery { - return NewUserClient(u.config).QueryPositions(u) +func (_m *User) QueryPositions() *PositionQuery { + return NewUserClient(_m.config).QueryPositions(_m) } // QueryDepartments queries the "departments" edge of the User entity. -func (u *User) QueryDepartments() *DepartmentQuery { - return NewUserClient(u.config).QueryDepartments(u) +func (_m *User) QueryDepartments() *DepartmentQuery { + return NewUserClient(_m.config).QueryDepartments(_m) } // QueryUserRoles queries the "user_roles" edge of the User entity. -func (u *User) QueryUserRoles() *UserRoleQuery { - return NewUserClient(u.config).QueryUserRoles(u) +func (_m *User) QueryUserRoles() *UserRoleQuery { + return NewUserClient(_m.config).QueryUserRoles(_m) } // QueryUserPositions queries the "user_positions" edge of the User entity. -func (u *User) QueryUserPositions() *UserPositionQuery { - return NewUserClient(u.config).QueryUserPositions(u) +func (_m *User) QueryUserPositions() *UserPositionQuery { + return NewUserClient(_m.config).QueryUserPositions(_m) } // QueryUserDepartments queries the "user_departments" edge of the User entity. -func (u *User) QueryUserDepartments() *UserDepartmentQuery { - return NewUserClient(u.config).QueryUserDepartments(u) +func (_m *User) QueryUserDepartments() *UserDepartmentQuery { + return NewUserClient(_m.config).QueryUserDepartments(_m) } // Update returns a builder for updating this User. // Note that you need to call User.Unwrap() before calling this method if this User // was returned from a transaction, and the transaction was committed or rolled back. -func (u *User) Update() *UserUpdateOne { - return NewUserClient(u.config).UpdateOne(u) +func (_m *User) Update() *UserUpdateOne { + return NewUserClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the User entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (u *User) Unwrap() *User { - _tx, ok := u.config.driver.(*txDriver) +func (_m *User) Unwrap() *User { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: User is not a transactional entity") } - u.config.driver = _tx.drv - return u + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (u *User) String() string { +func (_m *User) String() string { var builder strings.Builder builder.WriteString("User(") - builder.WriteString(fmt.Sprintf("id=%v, ", u.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("create_author=") - builder.WriteString(fmt.Sprintf("%v", u.CreateAuthor)) + builder.WriteString(fmt.Sprintf("%v", _m.CreateAuthor)) builder.WriteString(", ") builder.WriteString("update_author=") - builder.WriteString(fmt.Sprintf("%v", u.UpdateAuthor)) + builder.WriteString(fmt.Sprintf("%v", _m.UpdateAuthor)) builder.WriteString(", ") builder.WriteString("create_time=") - builder.WriteString(u.CreateTime.Format(time.ANSIC)) + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("update_time=") - builder.WriteString(u.UpdateTime.Format(time.ANSIC)) + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) builder.WriteString(", ") - if v := u.DeleteTime; v != nil { + if v := _m.DeleteTime; v != nil { builder.WriteString("delete_time=") builder.WriteString(v.Format(time.ANSIC)) } builder.WriteString(", ") builder.WriteString("uuid=") - builder.WriteString(u.UUID) + builder.WriteString(_m.UUID) builder.WriteString(", ") builder.WriteString("allowed_ip=") - builder.WriteString(u.AllowedIP) + builder.WriteString(_m.AllowedIP) builder.WriteString(", ") builder.WriteString("username=") - builder.WriteString(u.Username) + builder.WriteString(_m.Username) builder.WriteString(", ") builder.WriteString("nickname=") - builder.WriteString(u.Nickname) + builder.WriteString(_m.Nickname) builder.WriteString(", ") builder.WriteString("avatar=") - builder.WriteString(u.Avatar) + builder.WriteString(_m.Avatar) builder.WriteString(", ") builder.WriteString("name=") - builder.WriteString(u.Name) + builder.WriteString(_m.Name) builder.WriteString(", ") builder.WriteString("gender=") - builder.WriteString(fmt.Sprintf("%v", u.Gender)) + builder.WriteString(fmt.Sprintf("%v", _m.Gender)) builder.WriteString(", ") builder.WriteString("encrypted_password=") - builder.WriteString(u.EncryptedPassword) + builder.WriteString(_m.EncryptedPassword) builder.WriteString(", ") builder.WriteString("salt=") - builder.WriteString(u.Salt) + builder.WriteString(_m.Salt) builder.WriteString(", ") builder.WriteString("phone=") - builder.WriteString(u.Phone) + builder.WriteString(_m.Phone) builder.WriteString(", ") builder.WriteString("email=") - builder.WriteString(u.Email) + builder.WriteString(_m.Email) builder.WriteString(", ") builder.WriteString("department=") - builder.WriteString(u.Department) + builder.WriteString(_m.Department) builder.WriteString(", ") builder.WriteString("remark=") - builder.WriteString(u.Remark) + builder.WriteString(_m.Remark) builder.WriteString(", ") builder.WriteString("token=") - builder.WriteString(u.Token) + builder.WriteString(_m.Token) builder.WriteString(", ") builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", u.Status)) + builder.WriteString(fmt.Sprintf("%v", _m.Status)) builder.WriteString(", ") builder.WriteString("is_system=") - builder.WriteString(fmt.Sprintf("%v", u.IsSystem)) + builder.WriteString(fmt.Sprintf("%v", _m.IsSystem)) builder.WriteString(", ") builder.WriteString("last_login_ip=") - builder.WriteString(u.LastLoginIP) + builder.WriteString(_m.LastLoginIP) builder.WriteString(", ") builder.WriteString("last_login_time=") - builder.WriteString(u.LastLoginTime.Format(time.ANSIC)) + builder.WriteString(_m.LastLoginTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("login_time=") - builder.WriteString(u.LoginTime.Format(time.ANSIC)) + builder.WriteString(_m.LoginTime.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("sanction_date=") - builder.WriteString(u.SanctionDate.Format(time.ANSIC)) + builder.WriteString(_m.SanctionDate.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("manager_id=") - builder.WriteString(fmt.Sprintf("%v", u.ManagerID)) + builder.WriteString(fmt.Sprintf("%v", _m.ManagerID)) builder.WriteString(", ") builder.WriteString("manager=") - builder.WriteString(u.Manager) + builder.WriteString(_m.Manager) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/user_create.go b/internal/data/entity/ent/user_create.go index 3d012ec2..1a0c0ba6 100644 --- a/internal/data/entity/ent/user_create.go +++ b/internal/data/entity/ent/user_create.go @@ -27,487 +27,487 @@ type UserCreate struct { } // SetCreateAuthor sets the "create_author" field. -func (uc *UserCreate) SetCreateAuthor(i int64) *UserCreate { - uc.mutation.SetCreateAuthor(i) - return uc +func (_c *UserCreate) SetCreateAuthor(v int64) *UserCreate { + _c.mutation.SetCreateAuthor(v) + return _c } // SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. -func (uc *UserCreate) SetNillableCreateAuthor(i *int64) *UserCreate { - if i != nil { - uc.SetCreateAuthor(*i) +func (_c *UserCreate) SetNillableCreateAuthor(v *int64) *UserCreate { + if v != nil { + _c.SetCreateAuthor(*v) } - return uc + return _c } // SetUpdateAuthor sets the "update_author" field. -func (uc *UserCreate) SetUpdateAuthor(i int64) *UserCreate { - uc.mutation.SetUpdateAuthor(i) - return uc +func (_c *UserCreate) SetUpdateAuthor(v int64) *UserCreate { + _c.mutation.SetUpdateAuthor(v) + return _c } // SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. -func (uc *UserCreate) SetNillableUpdateAuthor(i *int64) *UserCreate { - if i != nil { - uc.SetUpdateAuthor(*i) +func (_c *UserCreate) SetNillableUpdateAuthor(v *int64) *UserCreate { + if v != nil { + _c.SetUpdateAuthor(*v) } - return uc + return _c } // SetCreateTime sets the "create_time" field. -func (uc *UserCreate) SetCreateTime(t time.Time) *UserCreate { - uc.mutation.SetCreateTime(t) - return uc +func (_c *UserCreate) SetCreateTime(v time.Time) *UserCreate { + _c.mutation.SetCreateTime(v) + return _c } // SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (uc *UserCreate) SetNillableCreateTime(t *time.Time) *UserCreate { - if t != nil { - uc.SetCreateTime(*t) +func (_c *UserCreate) SetNillableCreateTime(v *time.Time) *UserCreate { + if v != nil { + _c.SetCreateTime(*v) } - return uc + return _c } // SetUpdateTime sets the "update_time" field. -func (uc *UserCreate) SetUpdateTime(t time.Time) *UserCreate { - uc.mutation.SetUpdateTime(t) - return uc +func (_c *UserCreate) SetUpdateTime(v time.Time) *UserCreate { + _c.mutation.SetUpdateTime(v) + return _c } // SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (uc *UserCreate) SetNillableUpdateTime(t *time.Time) *UserCreate { - if t != nil { - uc.SetUpdateTime(*t) +func (_c *UserCreate) SetNillableUpdateTime(v *time.Time) *UserCreate { + if v != nil { + _c.SetUpdateTime(*v) } - return uc + return _c } // SetDeleteTime sets the "delete_time" field. -func (uc *UserCreate) SetDeleteTime(t time.Time) *UserCreate { - uc.mutation.SetDeleteTime(t) - return uc +func (_c *UserCreate) SetDeleteTime(v time.Time) *UserCreate { + _c.mutation.SetDeleteTime(v) + return _c } // SetNillableDeleteTime sets the "delete_time" field if the given value is not nil. -func (uc *UserCreate) SetNillableDeleteTime(t *time.Time) *UserCreate { - if t != nil { - uc.SetDeleteTime(*t) +func (_c *UserCreate) SetNillableDeleteTime(v *time.Time) *UserCreate { + if v != nil { + _c.SetDeleteTime(*v) } - return uc + return _c } // SetUUID sets the "uuid" field. -func (uc *UserCreate) SetUUID(s string) *UserCreate { - uc.mutation.SetUUID(s) - return uc +func (_c *UserCreate) SetUUID(v string) *UserCreate { + _c.mutation.SetUUID(v) + return _c } // SetAllowedIP sets the "allowed_ip" field. -func (uc *UserCreate) SetAllowedIP(s string) *UserCreate { - uc.mutation.SetAllowedIP(s) - return uc +func (_c *UserCreate) SetAllowedIP(v string) *UserCreate { + _c.mutation.SetAllowedIP(v) + return _c } // SetNillableAllowedIP sets the "allowed_ip" field if the given value is not nil. -func (uc *UserCreate) SetNillableAllowedIP(s *string) *UserCreate { - if s != nil { - uc.SetAllowedIP(*s) +func (_c *UserCreate) SetNillableAllowedIP(v *string) *UserCreate { + if v != nil { + _c.SetAllowedIP(*v) } - return uc + return _c } // SetUsername sets the "username" field. -func (uc *UserCreate) SetUsername(s string) *UserCreate { - uc.mutation.SetUsername(s) - return uc +func (_c *UserCreate) SetUsername(v string) *UserCreate { + _c.mutation.SetUsername(v) + return _c } // SetNickname sets the "nickname" field. -func (uc *UserCreate) SetNickname(s string) *UserCreate { - uc.mutation.SetNickname(s) - return uc +func (_c *UserCreate) SetNickname(v string) *UserCreate { + _c.mutation.SetNickname(v) + return _c } // SetNillableNickname sets the "nickname" field if the given value is not nil. -func (uc *UserCreate) SetNillableNickname(s *string) *UserCreate { - if s != nil { - uc.SetNickname(*s) +func (_c *UserCreate) SetNillableNickname(v *string) *UserCreate { + if v != nil { + _c.SetNickname(*v) } - return uc + return _c } // SetAvatar sets the "avatar" field. -func (uc *UserCreate) SetAvatar(s string) *UserCreate { - uc.mutation.SetAvatar(s) - return uc +func (_c *UserCreate) SetAvatar(v string) *UserCreate { + _c.mutation.SetAvatar(v) + return _c } // SetNillableAvatar sets the "avatar" field if the given value is not nil. -func (uc *UserCreate) SetNillableAvatar(s *string) *UserCreate { - if s != nil { - uc.SetAvatar(*s) +func (_c *UserCreate) SetNillableAvatar(v *string) *UserCreate { + if v != nil { + _c.SetAvatar(*v) } - return uc + return _c } // SetName sets the "name" field. -func (uc *UserCreate) SetName(s string) *UserCreate { - uc.mutation.SetName(s) - return uc +func (_c *UserCreate) SetName(v string) *UserCreate { + _c.mutation.SetName(v) + return _c } // SetNillableName sets the "name" field if the given value is not nil. -func (uc *UserCreate) SetNillableName(s *string) *UserCreate { - if s != nil { - uc.SetName(*s) +func (_c *UserCreate) SetNillableName(v *string) *UserCreate { + if v != nil { + _c.SetName(*v) } - return uc + return _c } // SetGender sets the "gender" field. -func (uc *UserCreate) SetGender(u user.Gender) *UserCreate { - uc.mutation.SetGender(u) - return uc +func (_c *UserCreate) SetGender(v user.Gender) *UserCreate { + _c.mutation.SetGender(v) + return _c } // SetNillableGender sets the "gender" field if the given value is not nil. -func (uc *UserCreate) SetNillableGender(u *user.Gender) *UserCreate { - if u != nil { - uc.SetGender(*u) +func (_c *UserCreate) SetNillableGender(v *user.Gender) *UserCreate { + if v != nil { + _c.SetGender(*v) } - return uc + return _c } // SetEncryptedPassword sets the "encrypted_password" field. -func (uc *UserCreate) SetEncryptedPassword(s string) *UserCreate { - uc.mutation.SetEncryptedPassword(s) - return uc +func (_c *UserCreate) SetEncryptedPassword(v string) *UserCreate { + _c.mutation.SetEncryptedPassword(v) + return _c } // SetNillableEncryptedPassword sets the "encrypted_password" field if the given value is not nil. -func (uc *UserCreate) SetNillableEncryptedPassword(s *string) *UserCreate { - if s != nil { - uc.SetEncryptedPassword(*s) +func (_c *UserCreate) SetNillableEncryptedPassword(v *string) *UserCreate { + if v != nil { + _c.SetEncryptedPassword(*v) } - return uc + return _c } // SetSalt sets the "salt" field. -func (uc *UserCreate) SetSalt(s string) *UserCreate { - uc.mutation.SetSalt(s) - return uc +func (_c *UserCreate) SetSalt(v string) *UserCreate { + _c.mutation.SetSalt(v) + return _c } // SetNillableSalt sets the "salt" field if the given value is not nil. -func (uc *UserCreate) SetNillableSalt(s *string) *UserCreate { - if s != nil { - uc.SetSalt(*s) +func (_c *UserCreate) SetNillableSalt(v *string) *UserCreate { + if v != nil { + _c.SetSalt(*v) } - return uc + return _c } // SetPhone sets the "phone" field. -func (uc *UserCreate) SetPhone(s string) *UserCreate { - uc.mutation.SetPhone(s) - return uc +func (_c *UserCreate) SetPhone(v string) *UserCreate { + _c.mutation.SetPhone(v) + return _c } // SetNillablePhone sets the "phone" field if the given value is not nil. -func (uc *UserCreate) SetNillablePhone(s *string) *UserCreate { - if s != nil { - uc.SetPhone(*s) +func (_c *UserCreate) SetNillablePhone(v *string) *UserCreate { + if v != nil { + _c.SetPhone(*v) } - return uc + return _c } // SetEmail sets the "email" field. -func (uc *UserCreate) SetEmail(s string) *UserCreate { - uc.mutation.SetEmail(s) - return uc +func (_c *UserCreate) SetEmail(v string) *UserCreate { + _c.mutation.SetEmail(v) + return _c } // SetNillableEmail sets the "email" field if the given value is not nil. -func (uc *UserCreate) SetNillableEmail(s *string) *UserCreate { - if s != nil { - uc.SetEmail(*s) +func (_c *UserCreate) SetNillableEmail(v *string) *UserCreate { + if v != nil { + _c.SetEmail(*v) } - return uc + return _c } // SetDepartment sets the "department" field. -func (uc *UserCreate) SetDepartment(s string) *UserCreate { - uc.mutation.SetDepartment(s) - return uc +func (_c *UserCreate) SetDepartment(v string) *UserCreate { + _c.mutation.SetDepartment(v) + return _c } // SetNillableDepartment sets the "department" field if the given value is not nil. -func (uc *UserCreate) SetNillableDepartment(s *string) *UserCreate { - if s != nil { - uc.SetDepartment(*s) +func (_c *UserCreate) SetNillableDepartment(v *string) *UserCreate { + if v != nil { + _c.SetDepartment(*v) } - return uc + return _c } // SetRemark sets the "remark" field. -func (uc *UserCreate) SetRemark(s string) *UserCreate { - uc.mutation.SetRemark(s) - return uc +func (_c *UserCreate) SetRemark(v string) *UserCreate { + _c.mutation.SetRemark(v) + return _c } // SetNillableRemark sets the "remark" field if the given value is not nil. -func (uc *UserCreate) SetNillableRemark(s *string) *UserCreate { - if s != nil { - uc.SetRemark(*s) +func (_c *UserCreate) SetNillableRemark(v *string) *UserCreate { + if v != nil { + _c.SetRemark(*v) } - return uc + return _c } // SetToken sets the "token" field. -func (uc *UserCreate) SetToken(s string) *UserCreate { - uc.mutation.SetToken(s) - return uc +func (_c *UserCreate) SetToken(v string) *UserCreate { + _c.mutation.SetToken(v) + return _c } // SetNillableToken sets the "token" field if the given value is not nil. -func (uc *UserCreate) SetNillableToken(s *string) *UserCreate { - if s != nil { - uc.SetToken(*s) +func (_c *UserCreate) SetNillableToken(v *string) *UserCreate { + if v != nil { + _c.SetToken(*v) } - return uc + return _c } // SetStatus sets the "status" field. -func (uc *UserCreate) SetStatus(i int8) *UserCreate { - uc.mutation.SetStatus(i) - return uc +func (_c *UserCreate) SetStatus(v int8) *UserCreate { + _c.mutation.SetStatus(v) + return _c } // SetNillableStatus sets the "status" field if the given value is not nil. -func (uc *UserCreate) SetNillableStatus(i *int8) *UserCreate { - if i != nil { - uc.SetStatus(*i) +func (_c *UserCreate) SetNillableStatus(v *int8) *UserCreate { + if v != nil { + _c.SetStatus(*v) } - return uc + return _c } // SetIsSystem sets the "is_system" field. -func (uc *UserCreate) SetIsSystem(b bool) *UserCreate { - uc.mutation.SetIsSystem(b) - return uc +func (_c *UserCreate) SetIsSystem(v bool) *UserCreate { + _c.mutation.SetIsSystem(v) + return _c } // SetNillableIsSystem sets the "is_system" field if the given value is not nil. -func (uc *UserCreate) SetNillableIsSystem(b *bool) *UserCreate { - if b != nil { - uc.SetIsSystem(*b) +func (_c *UserCreate) SetNillableIsSystem(v *bool) *UserCreate { + if v != nil { + _c.SetIsSystem(*v) } - return uc + return _c } // SetLastLoginIP sets the "last_login_ip" field. -func (uc *UserCreate) SetLastLoginIP(s string) *UserCreate { - uc.mutation.SetLastLoginIP(s) - return uc +func (_c *UserCreate) SetLastLoginIP(v string) *UserCreate { + _c.mutation.SetLastLoginIP(v) + return _c } // SetNillableLastLoginIP sets the "last_login_ip" field if the given value is not nil. -func (uc *UserCreate) SetNillableLastLoginIP(s *string) *UserCreate { - if s != nil { - uc.SetLastLoginIP(*s) +func (_c *UserCreate) SetNillableLastLoginIP(v *string) *UserCreate { + if v != nil { + _c.SetLastLoginIP(*v) } - return uc + return _c } // SetLastLoginTime sets the "last_login_time" field. -func (uc *UserCreate) SetLastLoginTime(t time.Time) *UserCreate { - uc.mutation.SetLastLoginTime(t) - return uc +func (_c *UserCreate) SetLastLoginTime(v time.Time) *UserCreate { + _c.mutation.SetLastLoginTime(v) + return _c } // SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. -func (uc *UserCreate) SetNillableLastLoginTime(t *time.Time) *UserCreate { - if t != nil { - uc.SetLastLoginTime(*t) +func (_c *UserCreate) SetNillableLastLoginTime(v *time.Time) *UserCreate { + if v != nil { + _c.SetLastLoginTime(*v) } - return uc + return _c } // SetLoginTime sets the "login_time" field. -func (uc *UserCreate) SetLoginTime(t time.Time) *UserCreate { - uc.mutation.SetLoginTime(t) - return uc +func (_c *UserCreate) SetLoginTime(v time.Time) *UserCreate { + _c.mutation.SetLoginTime(v) + return _c } // SetNillableLoginTime sets the "login_time" field if the given value is not nil. -func (uc *UserCreate) SetNillableLoginTime(t *time.Time) *UserCreate { - if t != nil { - uc.SetLoginTime(*t) +func (_c *UserCreate) SetNillableLoginTime(v *time.Time) *UserCreate { + if v != nil { + _c.SetLoginTime(*v) } - return uc + return _c } // SetSanctionDate sets the "sanction_date" field. -func (uc *UserCreate) SetSanctionDate(t time.Time) *UserCreate { - uc.mutation.SetSanctionDate(t) - return uc +func (_c *UserCreate) SetSanctionDate(v time.Time) *UserCreate { + _c.mutation.SetSanctionDate(v) + return _c } // SetNillableSanctionDate sets the "sanction_date" field if the given value is not nil. -func (uc *UserCreate) SetNillableSanctionDate(t *time.Time) *UserCreate { - if t != nil { - uc.SetSanctionDate(*t) +func (_c *UserCreate) SetNillableSanctionDate(v *time.Time) *UserCreate { + if v != nil { + _c.SetSanctionDate(*v) } - return uc + return _c } // SetManagerID sets the "manager_id" field. -func (uc *UserCreate) SetManagerID(i int64) *UserCreate { - uc.mutation.SetManagerID(i) - return uc +func (_c *UserCreate) SetManagerID(v int64) *UserCreate { + _c.mutation.SetManagerID(v) + return _c } // SetNillableManagerID sets the "manager_id" field if the given value is not nil. -func (uc *UserCreate) SetNillableManagerID(i *int64) *UserCreate { - if i != nil { - uc.SetManagerID(*i) +func (_c *UserCreate) SetNillableManagerID(v *int64) *UserCreate { + if v != nil { + _c.SetManagerID(*v) } - return uc + return _c } // SetManager sets the "manager" field. -func (uc *UserCreate) SetManager(s string) *UserCreate { - uc.mutation.SetManager(s) - return uc +func (_c *UserCreate) SetManager(v string) *UserCreate { + _c.mutation.SetManager(v) + return _c } // SetNillableManager sets the "manager" field if the given value is not nil. -func (uc *UserCreate) SetNillableManager(s *string) *UserCreate { - if s != nil { - uc.SetManager(*s) +func (_c *UserCreate) SetNillableManager(v *string) *UserCreate { + if v != nil { + _c.SetManager(*v) } - return uc + return _c } // SetID sets the "id" field. -func (uc *UserCreate) SetID(i int64) *UserCreate { - uc.mutation.SetID(i) - return uc +func (_c *UserCreate) SetID(v int64) *UserCreate { + _c.mutation.SetID(v) + return _c } // SetNillableID sets the "id" field if the given value is not nil. -func (uc *UserCreate) SetNillableID(i *int64) *UserCreate { - if i != nil { - uc.SetID(*i) +func (_c *UserCreate) SetNillableID(v *int64) *UserCreate { + if v != nil { + _c.SetID(*v) } - return uc + return _c } // AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (uc *UserCreate) AddRoleIDs(ids ...int64) *UserCreate { - uc.mutation.AddRoleIDs(ids...) - return uc +func (_c *UserCreate) AddRoleIDs(ids ...int64) *UserCreate { + _c.mutation.AddRoleIDs(ids...) + return _c } // AddRoles adds the "roles" edges to the Role entity. -func (uc *UserCreate) AddRoles(r ...*Role) *UserCreate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_c *UserCreate) AddRoles(v ...*Role) *UserCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uc.AddRoleIDs(ids...) + return _c.AddRoleIDs(ids...) } // AddPositionIDs adds the "positions" edge to the Position entity by IDs. -func (uc *UserCreate) AddPositionIDs(ids ...int64) *UserCreate { - uc.mutation.AddPositionIDs(ids...) - return uc +func (_c *UserCreate) AddPositionIDs(ids ...int64) *UserCreate { + _c.mutation.AddPositionIDs(ids...) + return _c } // AddPositions adds the "positions" edges to the Position entity. -func (uc *UserCreate) AddPositions(p ...*Position) *UserCreate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *UserCreate) AddPositions(v ...*Position) *UserCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uc.AddPositionIDs(ids...) + return _c.AddPositionIDs(ids...) } // AddDepartmentIDs adds the "departments" edge to the Department entity by IDs. -func (uc *UserCreate) AddDepartmentIDs(ids ...int64) *UserCreate { - uc.mutation.AddDepartmentIDs(ids...) - return uc +func (_c *UserCreate) AddDepartmentIDs(ids ...int64) *UserCreate { + _c.mutation.AddDepartmentIDs(ids...) + return _c } // AddDepartments adds the "departments" edges to the Department entity. -func (uc *UserCreate) AddDepartments(d ...*Department) *UserCreate { - ids := make([]int64, len(d)) - for i := range d { - ids[i] = d[i].ID +func (_c *UserCreate) AddDepartments(v ...*Department) *UserCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uc.AddDepartmentIDs(ids...) + return _c.AddDepartmentIDs(ids...) } // AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (uc *UserCreate) AddUserRoleIDs(ids ...int) *UserCreate { - uc.mutation.AddUserRoleIDs(ids...) - return uc +func (_c *UserCreate) AddUserRoleIDs(ids ...int) *UserCreate { + _c.mutation.AddUserRoleIDs(ids...) + return _c } // AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (uc *UserCreate) AddUserRoles(u ...*UserRole) *UserCreate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_c *UserCreate) AddUserRoles(v ...*UserRole) *UserCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uc.AddUserRoleIDs(ids...) + return _c.AddUserRoleIDs(ids...) } // AddUserPositionIDs adds the "user_positions" edge to the UserPosition entity by IDs. -func (uc *UserCreate) AddUserPositionIDs(ids ...int) *UserCreate { - uc.mutation.AddUserPositionIDs(ids...) - return uc +func (_c *UserCreate) AddUserPositionIDs(ids ...int) *UserCreate { + _c.mutation.AddUserPositionIDs(ids...) + return _c } // AddUserPositions adds the "user_positions" edges to the UserPosition entity. -func (uc *UserCreate) AddUserPositions(u ...*UserPosition) *UserCreate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_c *UserCreate) AddUserPositions(v ...*UserPosition) *UserCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uc.AddUserPositionIDs(ids...) + return _c.AddUserPositionIDs(ids...) } // AddUserDepartmentIDs adds the "user_departments" edge to the UserDepartment entity by IDs. -func (uc *UserCreate) AddUserDepartmentIDs(ids ...int) *UserCreate { - uc.mutation.AddUserDepartmentIDs(ids...) - return uc +func (_c *UserCreate) AddUserDepartmentIDs(ids ...int) *UserCreate { + _c.mutation.AddUserDepartmentIDs(ids...) + return _c } // AddUserDepartments adds the "user_departments" edges to the UserDepartment entity. -func (uc *UserCreate) AddUserDepartments(u ...*UserDepartment) *UserCreate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_c *UserCreate) AddUserDepartments(v ...*UserDepartment) *UserCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uc.AddUserDepartmentIDs(ids...) + return _c.AddUserDepartmentIDs(ids...) } // Mutation returns the UserMutation object of the builder. -func (uc *UserCreate) Mutation() *UserMutation { - return uc.mutation +func (_c *UserCreate) Mutation() *UserMutation { + return _c.mutation } // Save creates the User in the database. -func (uc *UserCreate) Save(ctx context.Context) (*User, error) { - if err := uc.defaults(); err != nil { +func (_c *UserCreate) Save(ctx context.Context) (*User, error) { + if err := _c.defaults(); err != nil { return nil, err } - return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks) + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (uc *UserCreate) SaveX(ctx context.Context) *User { - v, err := uc.Save(ctx) +func (_c *UserCreate) SaveX(ctx context.Context) *User { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -515,274 +515,274 @@ func (uc *UserCreate) SaveX(ctx context.Context) *User { } // Exec executes the query. -func (uc *UserCreate) Exec(ctx context.Context) error { - _, err := uc.Save(ctx) +func (_c *UserCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (uc *UserCreate) ExecX(ctx context.Context) { - if err := uc.Exec(ctx); err != nil { +func (_c *UserCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (uc *UserCreate) defaults() error { - if _, ok := uc.mutation.CreateAuthor(); !ok { +func (_c *UserCreate) defaults() error { + if _, ok := _c.mutation.CreateAuthor(); !ok { v := user.DefaultCreateAuthor - uc.mutation.SetCreateAuthor(v) + _c.mutation.SetCreateAuthor(v) } - if _, ok := uc.mutation.UpdateAuthor(); !ok { + if _, ok := _c.mutation.UpdateAuthor(); !ok { v := user.DefaultUpdateAuthor - uc.mutation.SetUpdateAuthor(v) + _c.mutation.SetUpdateAuthor(v) } - if _, ok := uc.mutation.CreateTime(); !ok { + if _, ok := _c.mutation.CreateTime(); !ok { if user.DefaultCreateTime == nil { return fmt.Errorf("ent: uninitialized user.DefaultCreateTime (forgotten import ent/runtime?)") } v := user.DefaultCreateTime() - uc.mutation.SetCreateTime(v) + _c.mutation.SetCreateTime(v) } - if _, ok := uc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { if user.DefaultUpdateTime == nil { return fmt.Errorf("ent: uninitialized user.DefaultUpdateTime (forgotten import ent/runtime?)") } v := user.DefaultUpdateTime() - uc.mutation.SetUpdateTime(v) + _c.mutation.SetUpdateTime(v) } - if _, ok := uc.mutation.AllowedIP(); !ok { + if _, ok := _c.mutation.AllowedIP(); !ok { v := user.DefaultAllowedIP - uc.mutation.SetAllowedIP(v) + _c.mutation.SetAllowedIP(v) } - if _, ok := uc.mutation.Nickname(); !ok { + if _, ok := _c.mutation.Nickname(); !ok { v := user.DefaultNickname - uc.mutation.SetNickname(v) + _c.mutation.SetNickname(v) } - if _, ok := uc.mutation.Avatar(); !ok { + if _, ok := _c.mutation.Avatar(); !ok { v := user.DefaultAvatar - uc.mutation.SetAvatar(v) + _c.mutation.SetAvatar(v) } - if _, ok := uc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { v := user.DefaultName - uc.mutation.SetName(v) + _c.mutation.SetName(v) } - if _, ok := uc.mutation.Gender(); !ok { + if _, ok := _c.mutation.Gender(); !ok { v := user.DefaultGender - uc.mutation.SetGender(v) + _c.mutation.SetGender(v) } - if _, ok := uc.mutation.EncryptedPassword(); !ok { + if _, ok := _c.mutation.EncryptedPassword(); !ok { v := user.DefaultEncryptedPassword - uc.mutation.SetEncryptedPassword(v) + _c.mutation.SetEncryptedPassword(v) } - if _, ok := uc.mutation.Salt(); !ok { + if _, ok := _c.mutation.Salt(); !ok { v := user.DefaultSalt - uc.mutation.SetSalt(v) + _c.mutation.SetSalt(v) } - if _, ok := uc.mutation.Phone(); !ok { + if _, ok := _c.mutation.Phone(); !ok { v := user.DefaultPhone - uc.mutation.SetPhone(v) + _c.mutation.SetPhone(v) } - if _, ok := uc.mutation.Email(); !ok { + if _, ok := _c.mutation.Email(); !ok { v := user.DefaultEmail - uc.mutation.SetEmail(v) + _c.mutation.SetEmail(v) } - if _, ok := uc.mutation.Department(); !ok { + if _, ok := _c.mutation.Department(); !ok { v := user.DefaultDepartment - uc.mutation.SetDepartment(v) + _c.mutation.SetDepartment(v) } - if _, ok := uc.mutation.Remark(); !ok { + if _, ok := _c.mutation.Remark(); !ok { v := user.DefaultRemark - uc.mutation.SetRemark(v) + _c.mutation.SetRemark(v) } - if _, ok := uc.mutation.Token(); !ok { + if _, ok := _c.mutation.Token(); !ok { v := user.DefaultToken - uc.mutation.SetToken(v) + _c.mutation.SetToken(v) } - if _, ok := uc.mutation.Status(); !ok { + if _, ok := _c.mutation.Status(); !ok { v := user.DefaultStatus - uc.mutation.SetStatus(v) + _c.mutation.SetStatus(v) } - if _, ok := uc.mutation.IsSystem(); !ok { + if _, ok := _c.mutation.IsSystem(); !ok { v := user.DefaultIsSystem - uc.mutation.SetIsSystem(v) + _c.mutation.SetIsSystem(v) } - if _, ok := uc.mutation.LastLoginIP(); !ok { + if _, ok := _c.mutation.LastLoginIP(); !ok { v := user.DefaultLastLoginIP - uc.mutation.SetLastLoginIP(v) + _c.mutation.SetLastLoginIP(v) } - if _, ok := uc.mutation.LastLoginTime(); !ok { + if _, ok := _c.mutation.LastLoginTime(); !ok { if user.DefaultLastLoginTime == nil { return fmt.Errorf("ent: uninitialized user.DefaultLastLoginTime (forgotten import ent/runtime?)") } v := user.DefaultLastLoginTime() - uc.mutation.SetLastLoginTime(v) + _c.mutation.SetLastLoginTime(v) } - if _, ok := uc.mutation.LoginTime(); !ok { + if _, ok := _c.mutation.LoginTime(); !ok { if user.DefaultLoginTime == nil { return fmt.Errorf("ent: uninitialized user.DefaultLoginTime (forgotten import ent/runtime?)") } v := user.DefaultLoginTime() - uc.mutation.SetLoginTime(v) + _c.mutation.SetLoginTime(v) } - if _, ok := uc.mutation.Manager(); !ok { + if _, ok := _c.mutation.Manager(); !ok { v := user.DefaultManager - uc.mutation.SetManager(v) + _c.mutation.SetManager(v) } - if _, ok := uc.mutation.ID(); !ok { + if _, ok := _c.mutation.ID(); !ok { if user.DefaultID == nil { return fmt.Errorf("ent: uninitialized user.DefaultID (forgotten import ent/runtime?)") } v := user.DefaultID() - uc.mutation.SetID(v) + _c.mutation.SetID(v) } return nil } // check runs all checks and user-defined validators on the builder. -func (uc *UserCreate) check() error { - if _, ok := uc.mutation.CreateTime(); !ok { +func (_c *UserCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "User.create_time"`)} } - if _, ok := uc.mutation.UpdateTime(); !ok { + if _, ok := _c.mutation.UpdateTime(); !ok { return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "User.update_time"`)} } - if _, ok := uc.mutation.UUID(); !ok { + if _, ok := _c.mutation.UUID(); !ok { return &ValidationError{Name: "uuid", err: errors.New(`ent: missing required field "User.uuid"`)} } - if v, ok := uc.mutation.UUID(); ok { + if v, ok := _c.mutation.UUID(); ok { if err := user.UUIDValidator(v); err != nil { return &ValidationError{Name: "uuid", err: fmt.Errorf(`ent: validator failed for field "User.uuid": %w`, err)} } } - if _, ok := uc.mutation.AllowedIP(); !ok { + if _, ok := _c.mutation.AllowedIP(); !ok { return &ValidationError{Name: "allowed_ip", err: errors.New(`ent: missing required field "User.allowed_ip"`)} } - if _, ok := uc.mutation.Username(); !ok { + if _, ok := _c.mutation.Username(); !ok { return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)} } - if v, ok := uc.mutation.Username(); ok { + if v, ok := _c.mutation.Username(); ok { if err := user.UsernameValidator(v); err != nil { return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} } } - if _, ok := uc.mutation.Nickname(); !ok { + if _, ok := _c.mutation.Nickname(); !ok { return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "User.nickname"`)} } - if v, ok := uc.mutation.Nickname(); ok { + if v, ok := _c.mutation.Nickname(); ok { if err := user.NicknameValidator(v); err != nil { return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} } } - if _, ok := uc.mutation.Avatar(); !ok { + if _, ok := _c.mutation.Avatar(); !ok { return &ValidationError{Name: "avatar", err: errors.New(`ent: missing required field "User.avatar"`)} } - if v, ok := uc.mutation.Avatar(); ok { + if v, ok := _c.mutation.Avatar(); ok { if err := user.AvatarValidator(v); err != nil { return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} } } - if _, ok := uc.mutation.Name(); !ok { + if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "User.name"`)} } - if v, ok := uc.mutation.Name(); ok { + if v, ok := _c.mutation.Name(); ok { if err := user.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} } } - if _, ok := uc.mutation.Gender(); !ok { + if _, ok := _c.mutation.Gender(); !ok { return &ValidationError{Name: "gender", err: errors.New(`ent: missing required field "User.gender"`)} } - if v, ok := uc.mutation.Gender(); ok { + if v, ok := _c.mutation.Gender(); ok { if err := user.GenderValidator(v); err != nil { return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} } } - if _, ok := uc.mutation.EncryptedPassword(); !ok { + if _, ok := _c.mutation.EncryptedPassword(); !ok { return &ValidationError{Name: "encrypted_password", err: errors.New(`ent: missing required field "User.encrypted_password"`)} } - if v, ok := uc.mutation.EncryptedPassword(); ok { + if v, ok := _c.mutation.EncryptedPassword(); ok { if err := user.EncryptedPasswordValidator(v); err != nil { return &ValidationError{Name: "encrypted_password", err: fmt.Errorf(`ent: validator failed for field "User.encrypted_password": %w`, err)} } } - if _, ok := uc.mutation.Salt(); !ok { + if _, ok := _c.mutation.Salt(); !ok { return &ValidationError{Name: "salt", err: errors.New(`ent: missing required field "User.salt"`)} } - if v, ok := uc.mutation.Salt(); ok { + if v, ok := _c.mutation.Salt(); ok { if err := user.SaltValidator(v); err != nil { return &ValidationError{Name: "salt", err: fmt.Errorf(`ent: validator failed for field "User.salt": %w`, err)} } } - if _, ok := uc.mutation.Phone(); !ok { + if _, ok := _c.mutation.Phone(); !ok { return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "User.phone"`)} } - if v, ok := uc.mutation.Phone(); ok { + if v, ok := _c.mutation.Phone(); ok { if err := user.PhoneValidator(v); err != nil { return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "User.phone": %w`, err)} } } - if _, ok := uc.mutation.Email(); !ok { + if _, ok := _c.mutation.Email(); !ok { return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "User.email"`)} } - if v, ok := uc.mutation.Email(); ok { + if v, ok := _c.mutation.Email(); ok { if err := user.EmailValidator(v); err != nil { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} } } - if _, ok := uc.mutation.Department(); !ok { + if _, ok := _c.mutation.Department(); !ok { return &ValidationError{Name: "department", err: errors.New(`ent: missing required field "User.department"`)} } - if v, ok := uc.mutation.Department(); ok { + if v, ok := _c.mutation.Department(); ok { if err := user.DepartmentValidator(v); err != nil { return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} } } - if _, ok := uc.mutation.Remark(); !ok { + if _, ok := _c.mutation.Remark(); !ok { return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "User.remark"`)} } - if v, ok := uc.mutation.Remark(); ok { + if v, ok := _c.mutation.Remark(); ok { if err := user.RemarkValidator(v); err != nil { return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "User.remark": %w`, err)} } } - if _, ok := uc.mutation.Token(); !ok { + if _, ok := _c.mutation.Token(); !ok { return &ValidationError{Name: "token", err: errors.New(`ent: missing required field "User.token"`)} } - if v, ok := uc.mutation.Token(); ok { + if v, ok := _c.mutation.Token(); ok { if err := user.TokenValidator(v); err != nil { return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "User.token": %w`, err)} } } - if _, ok := uc.mutation.Status(); !ok { + if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "User.status"`)} } - if _, ok := uc.mutation.IsSystem(); !ok { + if _, ok := _c.mutation.IsSystem(); !ok { return &ValidationError{Name: "is_system", err: errors.New(`ent: missing required field "User.is_system"`)} } - if _, ok := uc.mutation.LastLoginIP(); !ok { + if _, ok := _c.mutation.LastLoginIP(); !ok { return &ValidationError{Name: "last_login_ip", err: errors.New(`ent: missing required field "User.last_login_ip"`)} } - if v, ok := uc.mutation.LastLoginIP(); ok { + if v, ok := _c.mutation.LastLoginIP(); ok { if err := user.LastLoginIPValidator(v); err != nil { return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} } } - if _, ok := uc.mutation.LastLoginTime(); !ok { + if _, ok := _c.mutation.LastLoginTime(); !ok { return &ValidationError{Name: "last_login_time", err: errors.New(`ent: missing required field "User.last_login_time"`)} } - if _, ok := uc.mutation.LoginTime(); !ok { + if _, ok := _c.mutation.LoginTime(); !ok { return &ValidationError{Name: "login_time", err: errors.New(`ent: missing required field "User.login_time"`)} } - if v, ok := uc.mutation.ManagerID(); ok { + if v, ok := _c.mutation.ManagerID(); ok { if err := user.ManagerIDValidator(v); err != nil { return &ValidationError{Name: "manager_id", err: fmt.Errorf(`ent: validator failed for field "User.manager_id": %w`, err)} } } - if _, ok := uc.mutation.Manager(); !ok { + if _, ok := _c.mutation.Manager(); !ok { return &ValidationError{Name: "manager", err: errors.New(`ent: missing required field "User.manager"`)} } - if v, ok := uc.mutation.ID(); ok { + if v, ok := _c.mutation.ID(); ok { if err := user.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "User.id": %w`, err)} } @@ -790,12 +790,12 @@ func (uc *UserCreate) check() error { return nil } -func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { - if err := uc.check(); err != nil { +func (_c *UserCreate) sqlSave(ctx context.Context) (*User, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := uc.createSpec() - if err := sqlgraph.CreateNode(ctx, uc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -805,129 +805,129 @@ func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { id := _spec.ID.Value.(int64) _node.ID = int64(id) } - uc.mutation.id = &_node.ID - uc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { +func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { var ( - _node = &User{config: uc.config} + _node = &User{config: _c.config} _spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) ) - if id, ok := uc.mutation.ID(); ok { + if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } - if value, ok := uc.mutation.CreateAuthor(); ok { + if value, ok := _c.mutation.CreateAuthor(); ok { _spec.SetField(user.FieldCreateAuthor, field.TypeInt64, value) _node.CreateAuthor = value } - if value, ok := uc.mutation.UpdateAuthor(); ok { + if value, ok := _c.mutation.UpdateAuthor(); ok { _spec.SetField(user.FieldUpdateAuthor, field.TypeInt64, value) _node.UpdateAuthor = value } - if value, ok := uc.mutation.CreateTime(); ok { + if value, ok := _c.mutation.CreateTime(); ok { _spec.SetField(user.FieldCreateTime, field.TypeTime, value) _node.CreateTime = value } - if value, ok := uc.mutation.UpdateTime(); ok { + if value, ok := _c.mutation.UpdateTime(); ok { _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) _node.UpdateTime = value } - if value, ok := uc.mutation.DeleteTime(); ok { + if value, ok := _c.mutation.DeleteTime(); ok { _spec.SetField(user.FieldDeleteTime, field.TypeTime, value) _node.DeleteTime = &value } - if value, ok := uc.mutation.UUID(); ok { + if value, ok := _c.mutation.UUID(); ok { _spec.SetField(user.FieldUUID, field.TypeString, value) _node.UUID = value } - if value, ok := uc.mutation.AllowedIP(); ok { + if value, ok := _c.mutation.AllowedIP(); ok { _spec.SetField(user.FieldAllowedIP, field.TypeString, value) _node.AllowedIP = value } - if value, ok := uc.mutation.Username(); ok { + if value, ok := _c.mutation.Username(); ok { _spec.SetField(user.FieldUsername, field.TypeString, value) _node.Username = value } - if value, ok := uc.mutation.Nickname(); ok { + if value, ok := _c.mutation.Nickname(); ok { _spec.SetField(user.FieldNickname, field.TypeString, value) _node.Nickname = value } - if value, ok := uc.mutation.Avatar(); ok { + if value, ok := _c.mutation.Avatar(); ok { _spec.SetField(user.FieldAvatar, field.TypeString, value) _node.Avatar = value } - if value, ok := uc.mutation.Name(); ok { + if value, ok := _c.mutation.Name(); ok { _spec.SetField(user.FieldName, field.TypeString, value) _node.Name = value } - if value, ok := uc.mutation.Gender(); ok { + if value, ok := _c.mutation.Gender(); ok { _spec.SetField(user.FieldGender, field.TypeEnum, value) _node.Gender = value } - if value, ok := uc.mutation.EncryptedPassword(); ok { + if value, ok := _c.mutation.EncryptedPassword(); ok { _spec.SetField(user.FieldEncryptedPassword, field.TypeString, value) _node.EncryptedPassword = value } - if value, ok := uc.mutation.Salt(); ok { + if value, ok := _c.mutation.Salt(); ok { _spec.SetField(user.FieldSalt, field.TypeString, value) _node.Salt = value } - if value, ok := uc.mutation.Phone(); ok { + if value, ok := _c.mutation.Phone(); ok { _spec.SetField(user.FieldPhone, field.TypeString, value) _node.Phone = value } - if value, ok := uc.mutation.Email(); ok { + if value, ok := _c.mutation.Email(); ok { _spec.SetField(user.FieldEmail, field.TypeString, value) _node.Email = value } - if value, ok := uc.mutation.Department(); ok { + if value, ok := _c.mutation.Department(); ok { _spec.SetField(user.FieldDepartment, field.TypeString, value) _node.Department = value } - if value, ok := uc.mutation.Remark(); ok { + if value, ok := _c.mutation.Remark(); ok { _spec.SetField(user.FieldRemark, field.TypeString, value) _node.Remark = value } - if value, ok := uc.mutation.Token(); ok { + if value, ok := _c.mutation.Token(); ok { _spec.SetField(user.FieldToken, field.TypeString, value) _node.Token = value } - if value, ok := uc.mutation.Status(); ok { + if value, ok := _c.mutation.Status(); ok { _spec.SetField(user.FieldStatus, field.TypeInt8, value) _node.Status = value } - if value, ok := uc.mutation.IsSystem(); ok { + if value, ok := _c.mutation.IsSystem(); ok { _spec.SetField(user.FieldIsSystem, field.TypeBool, value) _node.IsSystem = value } - if value, ok := uc.mutation.LastLoginIP(); ok { + if value, ok := _c.mutation.LastLoginIP(); ok { _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) _node.LastLoginIP = value } - if value, ok := uc.mutation.LastLoginTime(); ok { + if value, ok := _c.mutation.LastLoginTime(); ok { _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) _node.LastLoginTime = value } - if value, ok := uc.mutation.LoginTime(); ok { + if value, ok := _c.mutation.LoginTime(); ok { _spec.SetField(user.FieldLoginTime, field.TypeTime, value) _node.LoginTime = value } - if value, ok := uc.mutation.SanctionDate(); ok { + if value, ok := _c.mutation.SanctionDate(); ok { _spec.SetField(user.FieldSanctionDate, field.TypeTime, value) _node.SanctionDate = value } - if value, ok := uc.mutation.ManagerID(); ok { + if value, ok := _c.mutation.ManagerID(); ok { _spec.SetField(user.FieldManagerID, field.TypeInt64, value) _node.ManagerID = value } - if value, ok := uc.mutation.Manager(); ok { + if value, ok := _c.mutation.Manager(); ok { _spec.SetField(user.FieldManager, field.TypeString, value) _node.Manager = value } - if nodes := uc.mutation.RolesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.RolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -943,7 +943,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := uc.mutation.PositionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -959,7 +959,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := uc.mutation.DepartmentsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.DepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -975,7 +975,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := uc.mutation.UserRolesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UserRolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -991,7 +991,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := uc.mutation.UserPositionsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UserPositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1007,7 +1007,7 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := uc.mutation.UserDepartmentsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UserDepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1027,23 +1027,23 @@ func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { } // SetUser set the User -func (uc *UserCreate) SetUser(input *User, fields ...string) *UserCreate { - m := uc.mutation +func (_c *UserCreate) SetUser(input *User, fields ...string) *UserCreate { + m := _c.mutation if len(fields) == 0 { fields = user.Columns } _ = m.SetFields(input, fields...) - return uc + return _c } // SetUserWithZero set the User -func (uc *UserCreate) SetUserWithZero(input *User, fields ...string) *UserCreate { - m := uc.mutation +func (_c *UserCreate) SetUserWithZero(input *User, fields ...string) *UserCreate { + m := _c.mutation if len(fields) == 0 { fields = user.Columns } _ = m.SetFieldsWithZero(input, fields...) - return uc + return _c } // UserCreateBulk is the builder for creating many User entities in bulk. @@ -1054,16 +1054,16 @@ type UserCreateBulk struct { } // Save creates the User entities in the database. -func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { - if ucb.err != nil { - return nil, ucb.err - } - specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) - nodes := make([]*User, len(ucb.builders)) - mutators := make([]Mutator, len(ucb.builders)) - for i := range ucb.builders { +func (_c *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*User, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := ucb.builders[i] + builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*UserMutation) @@ -1077,11 +1077,11 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, ucb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, ucb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -1105,7 +1105,7 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, ucb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -1113,8 +1113,8 @@ func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { } // SaveX is like Save, but panics if an error occurs. -func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User { - v, err := ucb.Save(ctx) +func (_c *UserCreateBulk) SaveX(ctx context.Context) []*User { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -1122,14 +1122,14 @@ func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User { } // Exec executes the query. -func (ucb *UserCreateBulk) Exec(ctx context.Context) error { - _, err := ucb.Save(ctx) +func (_c *UserCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (ucb *UserCreateBulk) ExecX(ctx context.Context) { - if err := ucb.Exec(ctx); err != nil { +func (_c *UserCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/user_delete.go b/internal/data/entity/ent/user_delete.go index 5af88d72..b9b6ed71 100644 --- a/internal/data/entity/ent/user_delete.go +++ b/internal/data/entity/ent/user_delete.go @@ -20,56 +20,56 @@ type UserDelete struct { } // Where appends a list predicates to the UserDelete builder. -func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { - ud.mutation.Where(ps...) - return ud +func (_d *UserDelete) Where(ps ...predicate.User) *UserDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (ud *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, ud.sqlExec, ud.mutation, ud.hooks) +func (_d *UserDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (ud *UserDelete) ExecX(ctx context.Context) int { - n, err := ud.Exec(ctx) +func (_d *UserDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *UserDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) - if ps := ud.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, ud.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - ud.mutation.done = true + _d.mutation.done = true return affected, err } // UserDeleteOne is the builder for deleting a single User entity. type UserDeleteOne struct { - ud *UserDelete + _d *UserDelete } // Where appends a list predicates to the UserDelete builder. -func (udo *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne { - udo.ud.mutation.Where(ps...) - return udo +func (_d *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (udo *UserDeleteOne) Exec(ctx context.Context) error { - n, err := udo.ud.Exec(ctx) +func (_d *UserDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (udo *UserDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (udo *UserDeleteOne) ExecX(ctx context.Context) { - if err := udo.Exec(ctx); err != nil { +func (_d *UserDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/user_query.go b/internal/data/entity/ent/user_query.go index 471c48b1..4449f304 100644 --- a/internal/data/entity/ent/user_query.go +++ b/internal/data/entity/ent/user_query.go @@ -43,44 +43,44 @@ type UserQuery struct { } // Where adds a new predicate for the UserQuery builder. -func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery { - uq.predicates = append(uq.predicates, ps...) - return uq +func (_q *UserQuery) Where(ps ...predicate.User) *UserQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (uq *UserQuery) Limit(limit int) *UserQuery { - uq.ctx.Limit = &limit - return uq +func (_q *UserQuery) Limit(limit int) *UserQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (uq *UserQuery) Offset(offset int) *UserQuery { - uq.ctx.Offset = &offset - return uq +func (_q *UserQuery) Offset(offset int) *UserQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (uq *UserQuery) Unique(unique bool) *UserQuery { - uq.ctx.Unique = &unique - return uq +func (_q *UserQuery) Unique(unique bool) *UserQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (uq *UserQuery) Order(o ...user.OrderOption) *UserQuery { - uq.order = append(uq.order, o...) - return uq +func (_q *UserQuery) Order(o ...user.OrderOption) *UserQuery { + _q.order = append(_q.order, o...) + return _q } // QueryRoles chains the current query on the "roles" edge. -func (uq *UserQuery) QueryRoles() *RoleQuery { - query := (&RoleClient{config: uq.config}).Query() +func (_q *UserQuery) QueryRoles() *RoleQuery { + query := (&RoleClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := uq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := uq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -89,20 +89,20 @@ func (uq *UserQuery) QueryRoles() *RoleQuery { sqlgraph.To(role.Table, role.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, user.RolesTable, user.RolesPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPositions chains the current query on the "positions" edge. -func (uq *UserQuery) QueryPositions() *PositionQuery { - query := (&PositionClient{config: uq.config}).Query() +func (_q *UserQuery) QueryPositions() *PositionQuery { + query := (&PositionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := uq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := uq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -111,20 +111,20 @@ func (uq *UserQuery) QueryPositions() *PositionQuery { sqlgraph.To(position.Table, position.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, user.PositionsTable, user.PositionsPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryDepartments chains the current query on the "departments" edge. -func (uq *UserQuery) QueryDepartments() *DepartmentQuery { - query := (&DepartmentClient{config: uq.config}).Query() +func (_q *UserQuery) QueryDepartments() *DepartmentQuery { + query := (&DepartmentClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := uq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := uq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -133,20 +133,20 @@ func (uq *UserQuery) QueryDepartments() *DepartmentQuery { sqlgraph.To(department.Table, department.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, user.DepartmentsTable, user.DepartmentsPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryUserRoles chains the current query on the "user_roles" edge. -func (uq *UserQuery) QueryUserRoles() *UserRoleQuery { - query := (&UserRoleClient{config: uq.config}).Query() +func (_q *UserQuery) QueryUserRoles() *UserRoleQuery { + query := (&UserRoleClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := uq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := uq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -155,20 +155,20 @@ func (uq *UserQuery) QueryUserRoles() *UserRoleQuery { sqlgraph.To(userrole.Table, userrole.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, user.UserRolesTable, user.UserRolesColumn), ) - fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryUserPositions chains the current query on the "user_positions" edge. -func (uq *UserQuery) QueryUserPositions() *UserPositionQuery { - query := (&UserPositionClient{config: uq.config}).Query() +func (_q *UserQuery) QueryUserPositions() *UserPositionQuery { + query := (&UserPositionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := uq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := uq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -177,20 +177,20 @@ func (uq *UserQuery) QueryUserPositions() *UserPositionQuery { sqlgraph.To(userposition.Table, userposition.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, user.UserPositionsTable, user.UserPositionsColumn), ) - fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryUserDepartments chains the current query on the "user_departments" edge. -func (uq *UserQuery) QueryUserDepartments() *UserDepartmentQuery { - query := (&UserDepartmentClient{config: uq.config}).Query() +func (_q *UserQuery) QueryUserDepartments() *UserDepartmentQuery { + query := (&UserDepartmentClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := uq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := uq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -199,7 +199,7 @@ func (uq *UserQuery) QueryUserDepartments() *UserDepartmentQuery { sqlgraph.To(userdepartment.Table, userdepartment.FieldID), sqlgraph.Edge(sqlgraph.O2M, true, user.UserDepartmentsTable, user.UserDepartmentsColumn), ) - fromU = sqlgraph.SetNeighbors(uq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -207,8 +207,8 @@ func (uq *UserQuery) QueryUserDepartments() *UserDepartmentQuery { // First returns the first User entity from the query. // Returns a *NotFoundError when no User was found. -func (uq *UserQuery) First(ctx context.Context) (*User, error) { - nodes, err := uq.Limit(1).All(setContextOp(ctx, uq.ctx, ent.OpQueryFirst)) +func (_q *UserQuery) First(ctx context.Context) (*User, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -219,8 +219,8 @@ func (uq *UserQuery) First(ctx context.Context) (*User, error) { } // FirstX is like First, but panics if an error occurs. -func (uq *UserQuery) FirstX(ctx context.Context) *User { - node, err := uq.First(ctx) +func (_q *UserQuery) FirstX(ctx context.Context) *User { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -229,9 +229,9 @@ func (uq *UserQuery) FirstX(ctx context.Context) *User { // FirstID returns the first User ID from the query. // Returns a *NotFoundError when no User ID was found. -func (uq *UserQuery) FirstID(ctx context.Context) (id int64, err error) { +func (_q *UserQuery) FirstID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = uq.Limit(1).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -242,8 +242,8 @@ func (uq *UserQuery) FirstID(ctx context.Context) (id int64, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (uq *UserQuery) FirstIDX(ctx context.Context) int64 { - id, err := uq.FirstID(ctx) +func (_q *UserQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -253,8 +253,8 @@ func (uq *UserQuery) FirstIDX(ctx context.Context) int64 { // Only returns a single User entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one User entity is found. // Returns a *NotFoundError when no User entities are found. -func (uq *UserQuery) Only(ctx context.Context) (*User, error) { - nodes, err := uq.Limit(2).All(setContextOp(ctx, uq.ctx, ent.OpQueryOnly)) +func (_q *UserQuery) Only(ctx context.Context) (*User, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -269,8 +269,8 @@ func (uq *UserQuery) Only(ctx context.Context) (*User, error) { } // OnlyX is like Only, but panics if an error occurs. -func (uq *UserQuery) OnlyX(ctx context.Context) *User { - node, err := uq.Only(ctx) +func (_q *UserQuery) OnlyX(ctx context.Context) *User { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -280,9 +280,9 @@ func (uq *UserQuery) OnlyX(ctx context.Context) *User { // OnlyID is like Only, but returns the only User ID in the query. // Returns a *NotSingularError when more than one User ID is found. // Returns a *NotFoundError when no entities are found. -func (uq *UserQuery) OnlyID(ctx context.Context) (id int64, err error) { +func (_q *UserQuery) OnlyID(ctx context.Context) (id int64, err error) { var ids []int64 - if ids, err = uq.Limit(2).IDs(setContextOp(ctx, uq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -297,8 +297,8 @@ func (uq *UserQuery) OnlyID(ctx context.Context) (id int64, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (uq *UserQuery) OnlyIDX(ctx context.Context) int64 { - id, err := uq.OnlyID(ctx) +func (_q *UserQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -306,18 +306,18 @@ func (uq *UserQuery) OnlyIDX(ctx context.Context) int64 { } // All executes the query and returns a list of Users. -func (uq *UserQuery) All(ctx context.Context) ([]*User, error) { - ctx = setContextOp(ctx, uq.ctx, ent.OpQueryAll) - if err := uq.prepareQuery(ctx); err != nil { +func (_q *UserQuery) All(ctx context.Context) ([]*User, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*User, *UserQuery]() - return withInterceptors[[]*User](ctx, uq, qr, uq.inters) + return withInterceptors[[]*User](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (uq *UserQuery) AllX(ctx context.Context) []*User { - nodes, err := uq.All(ctx) +func (_q *UserQuery) AllX(ctx context.Context) []*User { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -325,20 +325,20 @@ func (uq *UserQuery) AllX(ctx context.Context) []*User { } // IDs executes the query and returns a list of User IDs. -func (uq *UserQuery) IDs(ctx context.Context) (ids []int64, err error) { - if uq.ctx.Unique == nil && uq.path != nil { - uq.Unique(true) +func (_q *UserQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, uq.ctx, ent.OpQueryIDs) - if err = uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(user.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (uq *UserQuery) IDsX(ctx context.Context) []int64 { - ids, err := uq.IDs(ctx) +func (_q *UserQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -346,17 +346,17 @@ func (uq *UserQuery) IDsX(ctx context.Context) []int64 { } // Count returns the count of the given query. -func (uq *UserQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, uq.ctx, ent.OpQueryCount) - if err := uq.prepareQuery(ctx); err != nil { +func (_q *UserQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, uq, querierCount[*UserQuery](), uq.inters) + return withInterceptors[int](ctx, _q, querierCount[*UserQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (uq *UserQuery) CountX(ctx context.Context) int { - count, err := uq.Count(ctx) +func (_q *UserQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -364,9 +364,9 @@ func (uq *UserQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (uq *UserQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, uq.ctx, ent.OpQueryExist) - switch _, err := uq.FirstID(ctx); { +func (_q *UserQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -377,8 +377,8 @@ func (uq *UserQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (uq *UserQuery) ExistX(ctx context.Context) bool { - exist, err := uq.Exist(ctx) +func (_q *UserQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -387,93 +387,93 @@ func (uq *UserQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (uq *UserQuery) Clone() *UserQuery { - if uq == nil { +func (_q *UserQuery) Clone() *UserQuery { + if _q == nil { return nil } return &UserQuery{ - config: uq.config, - ctx: uq.ctx.Clone(), - order: append([]user.OrderOption{}, uq.order...), - inters: append([]Interceptor{}, uq.inters...), - predicates: append([]predicate.User{}, uq.predicates...), - withRoles: uq.withRoles.Clone(), - withPositions: uq.withPositions.Clone(), - withDepartments: uq.withDepartments.Clone(), - withUserRoles: uq.withUserRoles.Clone(), - withUserPositions: uq.withUserPositions.Clone(), - withUserDepartments: uq.withUserDepartments.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]user.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.User{}, _q.predicates...), + withRoles: _q.withRoles.Clone(), + withPositions: _q.withPositions.Clone(), + withDepartments: _q.withDepartments.Clone(), + withUserRoles: _q.withUserRoles.Clone(), + withUserPositions: _q.withUserPositions.Clone(), + withUserDepartments: _q.withUserDepartments.Clone(), // clone intermediate query. - sql: uq.sql.Clone(), - path: uq.path, - modifiers: append([]func(*sql.Selector){}, uq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithRoles tells the query-builder to eager-load the nodes that are connected to // the "roles" edge. The optional arguments are used to configure the query builder of the edge. -func (uq *UserQuery) WithRoles(opts ...func(*RoleQuery)) *UserQuery { - query := (&RoleClient{config: uq.config}).Query() +func (_q *UserQuery) WithRoles(opts ...func(*RoleQuery)) *UserQuery { + query := (&RoleClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - uq.withRoles = query - return uq + _q.withRoles = query + return _q } // WithPositions tells the query-builder to eager-load the nodes that are connected to // the "positions" edge. The optional arguments are used to configure the query builder of the edge. -func (uq *UserQuery) WithPositions(opts ...func(*PositionQuery)) *UserQuery { - query := (&PositionClient{config: uq.config}).Query() +func (_q *UserQuery) WithPositions(opts ...func(*PositionQuery)) *UserQuery { + query := (&PositionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - uq.withPositions = query - return uq + _q.withPositions = query + return _q } // WithDepartments tells the query-builder to eager-load the nodes that are connected to // the "departments" edge. The optional arguments are used to configure the query builder of the edge. -func (uq *UserQuery) WithDepartments(opts ...func(*DepartmentQuery)) *UserQuery { - query := (&DepartmentClient{config: uq.config}).Query() +func (_q *UserQuery) WithDepartments(opts ...func(*DepartmentQuery)) *UserQuery { + query := (&DepartmentClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - uq.withDepartments = query - return uq + _q.withDepartments = query + return _q } // WithUserRoles tells the query-builder to eager-load the nodes that are connected to // the "user_roles" edge. The optional arguments are used to configure the query builder of the edge. -func (uq *UserQuery) WithUserRoles(opts ...func(*UserRoleQuery)) *UserQuery { - query := (&UserRoleClient{config: uq.config}).Query() +func (_q *UserQuery) WithUserRoles(opts ...func(*UserRoleQuery)) *UserQuery { + query := (&UserRoleClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - uq.withUserRoles = query - return uq + _q.withUserRoles = query + return _q } // WithUserPositions tells the query-builder to eager-load the nodes that are connected to // the "user_positions" edge. The optional arguments are used to configure the query builder of the edge. -func (uq *UserQuery) WithUserPositions(opts ...func(*UserPositionQuery)) *UserQuery { - query := (&UserPositionClient{config: uq.config}).Query() +func (_q *UserQuery) WithUserPositions(opts ...func(*UserPositionQuery)) *UserQuery { + query := (&UserPositionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - uq.withUserPositions = query - return uq + _q.withUserPositions = query + return _q } // WithUserDepartments tells the query-builder to eager-load the nodes that are connected to // the "user_departments" edge. The optional arguments are used to configure the query builder of the edge. -func (uq *UserQuery) WithUserDepartments(opts ...func(*UserDepartmentQuery)) *UserQuery { - query := (&UserDepartmentClient{config: uq.config}).Query() +func (_q *UserQuery) WithUserDepartments(opts ...func(*UserDepartmentQuery)) *UserQuery { + query := (&UserDepartmentClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - uq.withUserDepartments = query - return uq + _q.withUserDepartments = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -490,10 +490,10 @@ func (uq *UserQuery) WithUserDepartments(opts ...func(*UserDepartmentQuery)) *Us // GroupBy(user.FieldCreateAuthor). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { - uq.ctx.Fields = append([]string{field}, fields...) - grbuild := &UserGroupBy{build: uq} - grbuild.flds = &uq.ctx.Fields +func (_q *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = user.Label grbuild.scan = grbuild.Scan return grbuild @@ -511,116 +511,116 @@ func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { // client.User.Query(). // Select(user.FieldCreateAuthor). // Scan(ctx, &v) -func (uq *UserQuery) Select(fields ...string) *UserSelect { - uq.ctx.Fields = append(uq.ctx.Fields, fields...) - sbuild := &UserSelect{UserQuery: uq} +func (_q *UserQuery) Select(fields ...string) *UserSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &UserSelect{UserQuery: _q} sbuild.label = user.Label - sbuild.flds, sbuild.scan = &uq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a UserSelect configured with the given aggregations. -func (uq *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect { - return uq.Select().Aggregate(fns...) +func (_q *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect { + return _q.Select().Aggregate(fns...) } -func (uq *UserQuery) prepareQuery(ctx context.Context) error { - for _, inter := range uq.inters { +func (_q *UserQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, uq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range uq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !user.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if uq.path != nil { - prev, err := uq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - uq.sql = prev + _q.sql = prev } return nil } -func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) { +func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) { var ( nodes = []*User{} - _spec = uq.querySpec() + _spec = _q.querySpec() loadedTypes = [6]bool{ - uq.withRoles != nil, - uq.withPositions != nil, - uq.withDepartments != nil, - uq.withUserRoles != nil, - uq.withUserPositions != nil, - uq.withUserDepartments != nil, + _q.withRoles != nil, + _q.withPositions != nil, + _q.withDepartments != nil, + _q.withUserRoles != nil, + _q.withUserPositions != nil, + _q.withUserDepartments != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*User).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &User{config: uq.config} + node := &User{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(uq.modifiers) > 0 { - _spec.Modifiers = uq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := uq.withRoles; query != nil { - if err := uq.loadRoles(ctx, query, nodes, + if query := _q.withRoles; query != nil { + if err := _q.loadRoles(ctx, query, nodes, func(n *User) { n.Edges.Roles = []*Role{} }, func(n *User, e *Role) { n.Edges.Roles = append(n.Edges.Roles, e) }); err != nil { return nil, err } } - if query := uq.withPositions; query != nil { - if err := uq.loadPositions(ctx, query, nodes, + if query := _q.withPositions; query != nil { + if err := _q.loadPositions(ctx, query, nodes, func(n *User) { n.Edges.Positions = []*Position{} }, func(n *User, e *Position) { n.Edges.Positions = append(n.Edges.Positions, e) }); err != nil { return nil, err } } - if query := uq.withDepartments; query != nil { - if err := uq.loadDepartments(ctx, query, nodes, + if query := _q.withDepartments; query != nil { + if err := _q.loadDepartments(ctx, query, nodes, func(n *User) { n.Edges.Departments = []*Department{} }, func(n *User, e *Department) { n.Edges.Departments = append(n.Edges.Departments, e) }); err != nil { return nil, err } } - if query := uq.withUserRoles; query != nil { - if err := uq.loadUserRoles(ctx, query, nodes, + if query := _q.withUserRoles; query != nil { + if err := _q.loadUserRoles(ctx, query, nodes, func(n *User) { n.Edges.UserRoles = []*UserRole{} }, func(n *User, e *UserRole) { n.Edges.UserRoles = append(n.Edges.UserRoles, e) }); err != nil { return nil, err } } - if query := uq.withUserPositions; query != nil { - if err := uq.loadUserPositions(ctx, query, nodes, + if query := _q.withUserPositions; query != nil { + if err := _q.loadUserPositions(ctx, query, nodes, func(n *User) { n.Edges.UserPositions = []*UserPosition{} }, func(n *User, e *UserPosition) { n.Edges.UserPositions = append(n.Edges.UserPositions, e) }); err != nil { return nil, err } } - if query := uq.withUserDepartments; query != nil { - if err := uq.loadUserDepartments(ctx, query, nodes, + if query := _q.withUserDepartments; query != nil { + if err := _q.loadUserDepartments(ctx, query, nodes, func(n *User) { n.Edges.UserDepartments = []*UserDepartment{} }, func(n *User, e *UserDepartment) { n.Edges.UserDepartments = append(n.Edges.UserDepartments, e) }); err != nil { return nil, err @@ -629,7 +629,7 @@ func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, e return nodes, nil } -func (uq *UserQuery) loadRoles(ctx context.Context, query *RoleQuery, nodes []*User, init func(*User), assign func(*User, *Role)) error { +func (_q *UserQuery) loadRoles(ctx context.Context, query *RoleQuery, nodes []*User, init func(*User), assign func(*User, *Role)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*User) nids := make(map[int64]map[*User]struct{}) @@ -690,7 +690,7 @@ func (uq *UserQuery) loadRoles(ctx context.Context, query *RoleQuery, nodes []*U } return nil } -func (uq *UserQuery) loadPositions(ctx context.Context, query *PositionQuery, nodes []*User, init func(*User), assign func(*User, *Position)) error { +func (_q *UserQuery) loadPositions(ctx context.Context, query *PositionQuery, nodes []*User, init func(*User), assign func(*User, *Position)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*User) nids := make(map[int64]map[*User]struct{}) @@ -751,7 +751,7 @@ func (uq *UserQuery) loadPositions(ctx context.Context, query *PositionQuery, no } return nil } -func (uq *UserQuery) loadDepartments(ctx context.Context, query *DepartmentQuery, nodes []*User, init func(*User), assign func(*User, *Department)) error { +func (_q *UserQuery) loadDepartments(ctx context.Context, query *DepartmentQuery, nodes []*User, init func(*User), assign func(*User, *Department)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*User) nids := make(map[int64]map[*User]struct{}) @@ -812,7 +812,7 @@ func (uq *UserQuery) loadDepartments(ctx context.Context, query *DepartmentQuery } return nil } -func (uq *UserQuery) loadUserRoles(ctx context.Context, query *UserRoleQuery, nodes []*User, init func(*User), assign func(*User, *UserRole)) error { +func (_q *UserQuery) loadUserRoles(ctx context.Context, query *UserRoleQuery, nodes []*User, init func(*User), assign func(*User, *UserRole)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*User) for i := range nodes { @@ -842,7 +842,7 @@ func (uq *UserQuery) loadUserRoles(ctx context.Context, query *UserRoleQuery, no } return nil } -func (uq *UserQuery) loadUserPositions(ctx context.Context, query *UserPositionQuery, nodes []*User, init func(*User), assign func(*User, *UserPosition)) error { +func (_q *UserQuery) loadUserPositions(ctx context.Context, query *UserPositionQuery, nodes []*User, init func(*User), assign func(*User, *UserPosition)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*User) for i := range nodes { @@ -872,7 +872,7 @@ func (uq *UserQuery) loadUserPositions(ctx context.Context, query *UserPositionQ } return nil } -func (uq *UserQuery) loadUserDepartments(ctx context.Context, query *UserDepartmentQuery, nodes []*User, init func(*User), assign func(*User, *UserDepartment)) error { +func (_q *UserQuery) loadUserDepartments(ctx context.Context, query *UserDepartmentQuery, nodes []*User, init func(*User), assign func(*User, *UserDepartment)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*User) for i := range nodes { @@ -903,27 +903,27 @@ func (uq *UserQuery) loadUserDepartments(ctx context.Context, query *UserDepartm return nil } -func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { - _spec := uq.querySpec() - if len(uq.modifiers) > 0 { - _spec.Modifiers = uq.modifiers +func (_q *UserQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = uq.ctx.Fields - if len(uq.ctx.Fields) > 0 { - _spec.Unique = uq.ctx.Unique != nil && *uq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, uq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *UserQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) - _spec.From = uq.sql - if unique := uq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if uq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := uq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) for i := range fields { @@ -932,20 +932,20 @@ func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := uq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := uq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := uq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := uq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -955,36 +955,36 @@ func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(uq.driver.Dialect()) +func (_q *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(user.Table) - columns := uq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = user.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if uq.sql != nil { - selector = uq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if uq.ctx.Unique != nil && *uq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range uq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range uq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range uq.order { + for _, p := range _q.order { p(selector) } - if offset := uq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := uq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -993,33 +993,33 @@ func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (uq *UserQuery) ForUpdate(opts ...sql.LockOption) *UserQuery { - if uq.driver.Dialect() == dialect.Postgres { - uq.Unique(false) +func (_q *UserQuery) ForUpdate(opts ...sql.LockOption) *UserQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - uq.modifiers = append(uq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return uq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (uq *UserQuery) ForShare(opts ...sql.LockOption) *UserQuery { - if uq.driver.Dialect() == dialect.Postgres { - uq.Unique(false) +func (_q *UserQuery) ForShare(opts ...sql.LockOption) *UserQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - uq.modifiers = append(uq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return uq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (uq *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { - uq.modifiers = append(uq.modifiers, modifiers...) - return uq.Select() +func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -1111,41 +1111,41 @@ type UserGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { - ugb.fns = append(ugb.fns, fns...) - return ugb +func (_g *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (ugb *UserGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ugb.build.ctx, ent.OpQueryGroupBy) - if err := ugb.build.prepareQuery(ctx); err != nil { +func (_g *UserGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, ugb.build, ugb, ugb.build.inters, v) + return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (ugb *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error { +func (_g *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(ugb.fns)) - for _, fn := range ugb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*ugb.flds)+len(ugb.fns)) - for _, f := range *ugb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*ugb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := ugb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -1159,27 +1159,27 @@ type UserSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (us *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect { - us.fns = append(us.fns, fns...) - return us +func (_s *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (us *UserSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, us.ctx, ent.OpQuerySelect) - if err := us.prepareQuery(ctx); err != nil { +func (_s *UserSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*UserQuery, *UserSelect](ctx, us.UserQuery, us, us.inters, v) + return scanWithInterceptors[*UserQuery, *UserSelect](ctx, _s.UserQuery, _s, _s.inters, v) } -func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error { +func (_s *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(us.fns)) - for _, fn := range us.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*us.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -1187,7 +1187,7 @@ func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error } rows := &sql.Rows{} query, args := selector.Query() - if err := us.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -1195,7 +1195,7 @@ func (us *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error } // Modify adds a query modifier for attaching custom logic to queries. -func (us *UserSelect) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { - us.modifiers = append(us.modifiers, modifiers...) - return us +func (_s *UserSelect) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/user_update.go b/internal/data/entity/ent/user_update.go index 618b01c5..6d93a4cf 100644 --- a/internal/data/entity/ent/user_update.go +++ b/internal/data/entity/ent/user_update.go @@ -30,657 +30,657 @@ type UserUpdate struct { } // Where appends a list predicates to the UserUpdate builder. -func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate { - uu.mutation.Where(ps...) - return uu +func (_u *UserUpdate) Where(ps ...predicate.User) *UserUpdate { + _u.mutation.Where(ps...) + return _u } // SetCreateAuthor sets the "create_author" field. -func (uu *UserUpdate) SetCreateAuthor(i int64) *UserUpdate { - uu.mutation.ResetCreateAuthor() - uu.mutation.SetCreateAuthor(i) - return uu +func (_u *UserUpdate) SetCreateAuthor(v int64) *UserUpdate { + _u.mutation.ResetCreateAuthor() + _u.mutation.SetCreateAuthor(v) + return _u } // SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. -func (uu *UserUpdate) SetNillableCreateAuthor(i *int64) *UserUpdate { - if i != nil { - uu.SetCreateAuthor(*i) +func (_u *UserUpdate) SetNillableCreateAuthor(v *int64) *UserUpdate { + if v != nil { + _u.SetCreateAuthor(*v) } - return uu + return _u } -// AddCreateAuthor adds i to the "create_author" field. -func (uu *UserUpdate) AddCreateAuthor(i int64) *UserUpdate { - uu.mutation.AddCreateAuthor(i) - return uu +// AddCreateAuthor adds value to the "create_author" field. +func (_u *UserUpdate) AddCreateAuthor(v int64) *UserUpdate { + _u.mutation.AddCreateAuthor(v) + return _u } // ClearCreateAuthor clears the value of the "create_author" field. -func (uu *UserUpdate) ClearCreateAuthor() *UserUpdate { - uu.mutation.ClearCreateAuthor() - return uu +func (_u *UserUpdate) ClearCreateAuthor() *UserUpdate { + _u.mutation.ClearCreateAuthor() + return _u } // SetUpdateAuthor sets the "update_author" field. -func (uu *UserUpdate) SetUpdateAuthor(i int64) *UserUpdate { - uu.mutation.ResetUpdateAuthor() - uu.mutation.SetUpdateAuthor(i) - return uu +func (_u *UserUpdate) SetUpdateAuthor(v int64) *UserUpdate { + _u.mutation.ResetUpdateAuthor() + _u.mutation.SetUpdateAuthor(v) + return _u } // SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. -func (uu *UserUpdate) SetNillableUpdateAuthor(i *int64) *UserUpdate { - if i != nil { - uu.SetUpdateAuthor(*i) +func (_u *UserUpdate) SetNillableUpdateAuthor(v *int64) *UserUpdate { + if v != nil { + _u.SetUpdateAuthor(*v) } - return uu + return _u } -// AddUpdateAuthor adds i to the "update_author" field. -func (uu *UserUpdate) AddUpdateAuthor(i int64) *UserUpdate { - uu.mutation.AddUpdateAuthor(i) - return uu +// AddUpdateAuthor adds value to the "update_author" field. +func (_u *UserUpdate) AddUpdateAuthor(v int64) *UserUpdate { + _u.mutation.AddUpdateAuthor(v) + return _u } // ClearUpdateAuthor clears the value of the "update_author" field. -func (uu *UserUpdate) ClearUpdateAuthor() *UserUpdate { - uu.mutation.ClearUpdateAuthor() - return uu +func (_u *UserUpdate) ClearUpdateAuthor() *UserUpdate { + _u.mutation.ClearUpdateAuthor() + return _u } // SetUpdateTime sets the "update_time" field. -func (uu *UserUpdate) SetUpdateTime(t time.Time) *UserUpdate { - uu.mutation.SetUpdateTime(t) - return uu +func (_u *UserUpdate) SetUpdateTime(v time.Time) *UserUpdate { + _u.mutation.SetUpdateTime(v) + return _u } // SetDeleteTime sets the "delete_time" field. -func (uu *UserUpdate) SetDeleteTime(t time.Time) *UserUpdate { - uu.mutation.SetDeleteTime(t) - return uu +func (_u *UserUpdate) SetDeleteTime(v time.Time) *UserUpdate { + _u.mutation.SetDeleteTime(v) + return _u } // SetNillableDeleteTime sets the "delete_time" field if the given value is not nil. -func (uu *UserUpdate) SetNillableDeleteTime(t *time.Time) *UserUpdate { - if t != nil { - uu.SetDeleteTime(*t) +func (_u *UserUpdate) SetNillableDeleteTime(v *time.Time) *UserUpdate { + if v != nil { + _u.SetDeleteTime(*v) } - return uu + return _u } // ClearDeleteTime clears the value of the "delete_time" field. -func (uu *UserUpdate) ClearDeleteTime() *UserUpdate { - uu.mutation.ClearDeleteTime() - return uu +func (_u *UserUpdate) ClearDeleteTime() *UserUpdate { + _u.mutation.ClearDeleteTime() + return _u } // SetUUID sets the "uuid" field. -func (uu *UserUpdate) SetUUID(s string) *UserUpdate { - uu.mutation.SetUUID(s) - return uu +func (_u *UserUpdate) SetUUID(v string) *UserUpdate { + _u.mutation.SetUUID(v) + return _u } // SetNillableUUID sets the "uuid" field if the given value is not nil. -func (uu *UserUpdate) SetNillableUUID(s *string) *UserUpdate { - if s != nil { - uu.SetUUID(*s) +func (_u *UserUpdate) SetNillableUUID(v *string) *UserUpdate { + if v != nil { + _u.SetUUID(*v) } - return uu + return _u } // SetAllowedIP sets the "allowed_ip" field. -func (uu *UserUpdate) SetAllowedIP(s string) *UserUpdate { - uu.mutation.SetAllowedIP(s) - return uu +func (_u *UserUpdate) SetAllowedIP(v string) *UserUpdate { + _u.mutation.SetAllowedIP(v) + return _u } // SetNillableAllowedIP sets the "allowed_ip" field if the given value is not nil. -func (uu *UserUpdate) SetNillableAllowedIP(s *string) *UserUpdate { - if s != nil { - uu.SetAllowedIP(*s) +func (_u *UserUpdate) SetNillableAllowedIP(v *string) *UserUpdate { + if v != nil { + _u.SetAllowedIP(*v) } - return uu + return _u } // SetUsername sets the "username" field. -func (uu *UserUpdate) SetUsername(s string) *UserUpdate { - uu.mutation.SetUsername(s) - return uu +func (_u *UserUpdate) SetUsername(v string) *UserUpdate { + _u.mutation.SetUsername(v) + return _u } // SetNillableUsername sets the "username" field if the given value is not nil. -func (uu *UserUpdate) SetNillableUsername(s *string) *UserUpdate { - if s != nil { - uu.SetUsername(*s) +func (_u *UserUpdate) SetNillableUsername(v *string) *UserUpdate { + if v != nil { + _u.SetUsername(*v) } - return uu + return _u } // SetNickname sets the "nickname" field. -func (uu *UserUpdate) SetNickname(s string) *UserUpdate { - uu.mutation.SetNickname(s) - return uu +func (_u *UserUpdate) SetNickname(v string) *UserUpdate { + _u.mutation.SetNickname(v) + return _u } // SetNillableNickname sets the "nickname" field if the given value is not nil. -func (uu *UserUpdate) SetNillableNickname(s *string) *UserUpdate { - if s != nil { - uu.SetNickname(*s) +func (_u *UserUpdate) SetNillableNickname(v *string) *UserUpdate { + if v != nil { + _u.SetNickname(*v) } - return uu + return _u } // SetAvatar sets the "avatar" field. -func (uu *UserUpdate) SetAvatar(s string) *UserUpdate { - uu.mutation.SetAvatar(s) - return uu +func (_u *UserUpdate) SetAvatar(v string) *UserUpdate { + _u.mutation.SetAvatar(v) + return _u } // SetNillableAvatar sets the "avatar" field if the given value is not nil. -func (uu *UserUpdate) SetNillableAvatar(s *string) *UserUpdate { - if s != nil { - uu.SetAvatar(*s) +func (_u *UserUpdate) SetNillableAvatar(v *string) *UserUpdate { + if v != nil { + _u.SetAvatar(*v) } - return uu + return _u } // SetName sets the "name" field. -func (uu *UserUpdate) SetName(s string) *UserUpdate { - uu.mutation.SetName(s) - return uu +func (_u *UserUpdate) SetName(v string) *UserUpdate { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (uu *UserUpdate) SetNillableName(s *string) *UserUpdate { - if s != nil { - uu.SetName(*s) +func (_u *UserUpdate) SetNillableName(v *string) *UserUpdate { + if v != nil { + _u.SetName(*v) } - return uu + return _u } // SetGender sets the "gender" field. -func (uu *UserUpdate) SetGender(u user.Gender) *UserUpdate { - uu.mutation.SetGender(u) - return uu +func (_u *UserUpdate) SetGender(v user.Gender) *UserUpdate { + _u.mutation.SetGender(v) + return _u } // SetNillableGender sets the "gender" field if the given value is not nil. -func (uu *UserUpdate) SetNillableGender(u *user.Gender) *UserUpdate { - if u != nil { - uu.SetGender(*u) +func (_u *UserUpdate) SetNillableGender(v *user.Gender) *UserUpdate { + if v != nil { + _u.SetGender(*v) } - return uu + return _u } // SetEncryptedPassword sets the "encrypted_password" field. -func (uu *UserUpdate) SetEncryptedPassword(s string) *UserUpdate { - uu.mutation.SetEncryptedPassword(s) - return uu +func (_u *UserUpdate) SetEncryptedPassword(v string) *UserUpdate { + _u.mutation.SetEncryptedPassword(v) + return _u } // SetNillableEncryptedPassword sets the "encrypted_password" field if the given value is not nil. -func (uu *UserUpdate) SetNillableEncryptedPassword(s *string) *UserUpdate { - if s != nil { - uu.SetEncryptedPassword(*s) +func (_u *UserUpdate) SetNillableEncryptedPassword(v *string) *UserUpdate { + if v != nil { + _u.SetEncryptedPassword(*v) } - return uu + return _u } // SetSalt sets the "salt" field. -func (uu *UserUpdate) SetSalt(s string) *UserUpdate { - uu.mutation.SetSalt(s) - return uu +func (_u *UserUpdate) SetSalt(v string) *UserUpdate { + _u.mutation.SetSalt(v) + return _u } // SetNillableSalt sets the "salt" field if the given value is not nil. -func (uu *UserUpdate) SetNillableSalt(s *string) *UserUpdate { - if s != nil { - uu.SetSalt(*s) +func (_u *UserUpdate) SetNillableSalt(v *string) *UserUpdate { + if v != nil { + _u.SetSalt(*v) } - return uu + return _u } // SetPhone sets the "phone" field. -func (uu *UserUpdate) SetPhone(s string) *UserUpdate { - uu.mutation.SetPhone(s) - return uu +func (_u *UserUpdate) SetPhone(v string) *UserUpdate { + _u.mutation.SetPhone(v) + return _u } // SetNillablePhone sets the "phone" field if the given value is not nil. -func (uu *UserUpdate) SetNillablePhone(s *string) *UserUpdate { - if s != nil { - uu.SetPhone(*s) +func (_u *UserUpdate) SetNillablePhone(v *string) *UserUpdate { + if v != nil { + _u.SetPhone(*v) } - return uu + return _u } // SetEmail sets the "email" field. -func (uu *UserUpdate) SetEmail(s string) *UserUpdate { - uu.mutation.SetEmail(s) - return uu +func (_u *UserUpdate) SetEmail(v string) *UserUpdate { + _u.mutation.SetEmail(v) + return _u } // SetNillableEmail sets the "email" field if the given value is not nil. -func (uu *UserUpdate) SetNillableEmail(s *string) *UserUpdate { - if s != nil { - uu.SetEmail(*s) +func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate { + if v != nil { + _u.SetEmail(*v) } - return uu + return _u } // SetDepartment sets the "department" field. -func (uu *UserUpdate) SetDepartment(s string) *UserUpdate { - uu.mutation.SetDepartment(s) - return uu +func (_u *UserUpdate) SetDepartment(v string) *UserUpdate { + _u.mutation.SetDepartment(v) + return _u } // SetNillableDepartment sets the "department" field if the given value is not nil. -func (uu *UserUpdate) SetNillableDepartment(s *string) *UserUpdate { - if s != nil { - uu.SetDepartment(*s) +func (_u *UserUpdate) SetNillableDepartment(v *string) *UserUpdate { + if v != nil { + _u.SetDepartment(*v) } - return uu + return _u } // SetRemark sets the "remark" field. -func (uu *UserUpdate) SetRemark(s string) *UserUpdate { - uu.mutation.SetRemark(s) - return uu +func (_u *UserUpdate) SetRemark(v string) *UserUpdate { + _u.mutation.SetRemark(v) + return _u } // SetNillableRemark sets the "remark" field if the given value is not nil. -func (uu *UserUpdate) SetNillableRemark(s *string) *UserUpdate { - if s != nil { - uu.SetRemark(*s) +func (_u *UserUpdate) SetNillableRemark(v *string) *UserUpdate { + if v != nil { + _u.SetRemark(*v) } - return uu + return _u } // SetToken sets the "token" field. -func (uu *UserUpdate) SetToken(s string) *UserUpdate { - uu.mutation.SetToken(s) - return uu +func (_u *UserUpdate) SetToken(v string) *UserUpdate { + _u.mutation.SetToken(v) + return _u } // SetNillableToken sets the "token" field if the given value is not nil. -func (uu *UserUpdate) SetNillableToken(s *string) *UserUpdate { - if s != nil { - uu.SetToken(*s) +func (_u *UserUpdate) SetNillableToken(v *string) *UserUpdate { + if v != nil { + _u.SetToken(*v) } - return uu + return _u } // SetStatus sets the "status" field. -func (uu *UserUpdate) SetStatus(i int8) *UserUpdate { - uu.mutation.ResetStatus() - uu.mutation.SetStatus(i) - return uu +func (_u *UserUpdate) SetStatus(v int8) *UserUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (uu *UserUpdate) SetNillableStatus(i *int8) *UserUpdate { - if i != nil { - uu.SetStatus(*i) +func (_u *UserUpdate) SetNillableStatus(v *int8) *UserUpdate { + if v != nil { + _u.SetStatus(*v) } - return uu + return _u } -// AddStatus adds i to the "status" field. -func (uu *UserUpdate) AddStatus(i int8) *UserUpdate { - uu.mutation.AddStatus(i) - return uu +// AddStatus adds value to the "status" field. +func (_u *UserUpdate) AddStatus(v int8) *UserUpdate { + _u.mutation.AddStatus(v) + return _u } // SetIsSystem sets the "is_system" field. -func (uu *UserUpdate) SetIsSystem(b bool) *UserUpdate { - uu.mutation.SetIsSystem(b) - return uu +func (_u *UserUpdate) SetIsSystem(v bool) *UserUpdate { + _u.mutation.SetIsSystem(v) + return _u } // SetNillableIsSystem sets the "is_system" field if the given value is not nil. -func (uu *UserUpdate) SetNillableIsSystem(b *bool) *UserUpdate { - if b != nil { - uu.SetIsSystem(*b) +func (_u *UserUpdate) SetNillableIsSystem(v *bool) *UserUpdate { + if v != nil { + _u.SetIsSystem(*v) } - return uu + return _u } // SetLastLoginIP sets the "last_login_ip" field. -func (uu *UserUpdate) SetLastLoginIP(s string) *UserUpdate { - uu.mutation.SetLastLoginIP(s) - return uu +func (_u *UserUpdate) SetLastLoginIP(v string) *UserUpdate { + _u.mutation.SetLastLoginIP(v) + return _u } // SetNillableLastLoginIP sets the "last_login_ip" field if the given value is not nil. -func (uu *UserUpdate) SetNillableLastLoginIP(s *string) *UserUpdate { - if s != nil { - uu.SetLastLoginIP(*s) +func (_u *UserUpdate) SetNillableLastLoginIP(v *string) *UserUpdate { + if v != nil { + _u.SetLastLoginIP(*v) } - return uu + return _u } // SetLastLoginTime sets the "last_login_time" field. -func (uu *UserUpdate) SetLastLoginTime(t time.Time) *UserUpdate { - uu.mutation.SetLastLoginTime(t) - return uu +func (_u *UserUpdate) SetLastLoginTime(v time.Time) *UserUpdate { + _u.mutation.SetLastLoginTime(v) + return _u } // SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. -func (uu *UserUpdate) SetNillableLastLoginTime(t *time.Time) *UserUpdate { - if t != nil { - uu.SetLastLoginTime(*t) +func (_u *UserUpdate) SetNillableLastLoginTime(v *time.Time) *UserUpdate { + if v != nil { + _u.SetLastLoginTime(*v) } - return uu + return _u } // SetLoginTime sets the "login_time" field. -func (uu *UserUpdate) SetLoginTime(t time.Time) *UserUpdate { - uu.mutation.SetLoginTime(t) - return uu +func (_u *UserUpdate) SetLoginTime(v time.Time) *UserUpdate { + _u.mutation.SetLoginTime(v) + return _u } // SetNillableLoginTime sets the "login_time" field if the given value is not nil. -func (uu *UserUpdate) SetNillableLoginTime(t *time.Time) *UserUpdate { - if t != nil { - uu.SetLoginTime(*t) +func (_u *UserUpdate) SetNillableLoginTime(v *time.Time) *UserUpdate { + if v != nil { + _u.SetLoginTime(*v) } - return uu + return _u } // SetSanctionDate sets the "sanction_date" field. -func (uu *UserUpdate) SetSanctionDate(t time.Time) *UserUpdate { - uu.mutation.SetSanctionDate(t) - return uu +func (_u *UserUpdate) SetSanctionDate(v time.Time) *UserUpdate { + _u.mutation.SetSanctionDate(v) + return _u } // SetNillableSanctionDate sets the "sanction_date" field if the given value is not nil. -func (uu *UserUpdate) SetNillableSanctionDate(t *time.Time) *UserUpdate { - if t != nil { - uu.SetSanctionDate(*t) +func (_u *UserUpdate) SetNillableSanctionDate(v *time.Time) *UserUpdate { + if v != nil { + _u.SetSanctionDate(*v) } - return uu + return _u } // ClearSanctionDate clears the value of the "sanction_date" field. -func (uu *UserUpdate) ClearSanctionDate() *UserUpdate { - uu.mutation.ClearSanctionDate() - return uu +func (_u *UserUpdate) ClearSanctionDate() *UserUpdate { + _u.mutation.ClearSanctionDate() + return _u } // SetManagerID sets the "manager_id" field. -func (uu *UserUpdate) SetManagerID(i int64) *UserUpdate { - uu.mutation.ResetManagerID() - uu.mutation.SetManagerID(i) - return uu +func (_u *UserUpdate) SetManagerID(v int64) *UserUpdate { + _u.mutation.ResetManagerID() + _u.mutation.SetManagerID(v) + return _u } // SetNillableManagerID sets the "manager_id" field if the given value is not nil. -func (uu *UserUpdate) SetNillableManagerID(i *int64) *UserUpdate { - if i != nil { - uu.SetManagerID(*i) +func (_u *UserUpdate) SetNillableManagerID(v *int64) *UserUpdate { + if v != nil { + _u.SetManagerID(*v) } - return uu + return _u } -// AddManagerID adds i to the "manager_id" field. -func (uu *UserUpdate) AddManagerID(i int64) *UserUpdate { - uu.mutation.AddManagerID(i) - return uu +// AddManagerID adds value to the "manager_id" field. +func (_u *UserUpdate) AddManagerID(v int64) *UserUpdate { + _u.mutation.AddManagerID(v) + return _u } // ClearManagerID clears the value of the "manager_id" field. -func (uu *UserUpdate) ClearManagerID() *UserUpdate { - uu.mutation.ClearManagerID() - return uu +func (_u *UserUpdate) ClearManagerID() *UserUpdate { + _u.mutation.ClearManagerID() + return _u } // SetManager sets the "manager" field. -func (uu *UserUpdate) SetManager(s string) *UserUpdate { - uu.mutation.SetManager(s) - return uu +func (_u *UserUpdate) SetManager(v string) *UserUpdate { + _u.mutation.SetManager(v) + return _u } // SetNillableManager sets the "manager" field if the given value is not nil. -func (uu *UserUpdate) SetNillableManager(s *string) *UserUpdate { - if s != nil { - uu.SetManager(*s) +func (_u *UserUpdate) SetNillableManager(v *string) *UserUpdate { + if v != nil { + _u.SetManager(*v) } - return uu + return _u } // AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (uu *UserUpdate) AddRoleIDs(ids ...int64) *UserUpdate { - uu.mutation.AddRoleIDs(ids...) - return uu +func (_u *UserUpdate) AddRoleIDs(ids ...int64) *UserUpdate { + _u.mutation.AddRoleIDs(ids...) + return _u } // AddRoles adds the "roles" edges to the Role entity. -func (uu *UserUpdate) AddRoles(r ...*Role) *UserUpdate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *UserUpdate) AddRoles(v ...*Role) *UserUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.AddRoleIDs(ids...) + return _u.AddRoleIDs(ids...) } // AddPositionIDs adds the "positions" edge to the Position entity by IDs. -func (uu *UserUpdate) AddPositionIDs(ids ...int64) *UserUpdate { - uu.mutation.AddPositionIDs(ids...) - return uu +func (_u *UserUpdate) AddPositionIDs(ids ...int64) *UserUpdate { + _u.mutation.AddPositionIDs(ids...) + return _u } // AddPositions adds the "positions" edges to the Position entity. -func (uu *UserUpdate) AddPositions(p ...*Position) *UserUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *UserUpdate) AddPositions(v ...*Position) *UserUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.AddPositionIDs(ids...) + return _u.AddPositionIDs(ids...) } // AddDepartmentIDs adds the "departments" edge to the Department entity by IDs. -func (uu *UserUpdate) AddDepartmentIDs(ids ...int64) *UserUpdate { - uu.mutation.AddDepartmentIDs(ids...) - return uu +func (_u *UserUpdate) AddDepartmentIDs(ids ...int64) *UserUpdate { + _u.mutation.AddDepartmentIDs(ids...) + return _u } // AddDepartments adds the "departments" edges to the Department entity. -func (uu *UserUpdate) AddDepartments(d ...*Department) *UserUpdate { - ids := make([]int64, len(d)) - for i := range d { - ids[i] = d[i].ID +func (_u *UserUpdate) AddDepartments(v ...*Department) *UserUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.AddDepartmentIDs(ids...) + return _u.AddDepartmentIDs(ids...) } // AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (uu *UserUpdate) AddUserRoleIDs(ids ...int) *UserUpdate { - uu.mutation.AddUserRoleIDs(ids...) - return uu +func (_u *UserUpdate) AddUserRoleIDs(ids ...int) *UserUpdate { + _u.mutation.AddUserRoleIDs(ids...) + return _u } // AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (uu *UserUpdate) AddUserRoles(u ...*UserRole) *UserUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdate) AddUserRoles(v ...*UserRole) *UserUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.AddUserRoleIDs(ids...) + return _u.AddUserRoleIDs(ids...) } // AddUserPositionIDs adds the "user_positions" edge to the UserPosition entity by IDs. -func (uu *UserUpdate) AddUserPositionIDs(ids ...int) *UserUpdate { - uu.mutation.AddUserPositionIDs(ids...) - return uu +func (_u *UserUpdate) AddUserPositionIDs(ids ...int) *UserUpdate { + _u.mutation.AddUserPositionIDs(ids...) + return _u } // AddUserPositions adds the "user_positions" edges to the UserPosition entity. -func (uu *UserUpdate) AddUserPositions(u ...*UserPosition) *UserUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdate) AddUserPositions(v ...*UserPosition) *UserUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.AddUserPositionIDs(ids...) + return _u.AddUserPositionIDs(ids...) } // AddUserDepartmentIDs adds the "user_departments" edge to the UserDepartment entity by IDs. -func (uu *UserUpdate) AddUserDepartmentIDs(ids ...int) *UserUpdate { - uu.mutation.AddUserDepartmentIDs(ids...) - return uu +func (_u *UserUpdate) AddUserDepartmentIDs(ids ...int) *UserUpdate { + _u.mutation.AddUserDepartmentIDs(ids...) + return _u } // AddUserDepartments adds the "user_departments" edges to the UserDepartment entity. -func (uu *UserUpdate) AddUserDepartments(u ...*UserDepartment) *UserUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdate) AddUserDepartments(v ...*UserDepartment) *UserUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.AddUserDepartmentIDs(ids...) + return _u.AddUserDepartmentIDs(ids...) } // Mutation returns the UserMutation object of the builder. -func (uu *UserUpdate) Mutation() *UserMutation { - return uu.mutation +func (_u *UserUpdate) Mutation() *UserMutation { + return _u.mutation } // ClearRoles clears all "roles" edges to the Role entity. -func (uu *UserUpdate) ClearRoles() *UserUpdate { - uu.mutation.ClearRoles() - return uu +func (_u *UserUpdate) ClearRoles() *UserUpdate { + _u.mutation.ClearRoles() + return _u } // RemoveRoleIDs removes the "roles" edge to Role entities by IDs. -func (uu *UserUpdate) RemoveRoleIDs(ids ...int64) *UserUpdate { - uu.mutation.RemoveRoleIDs(ids...) - return uu +func (_u *UserUpdate) RemoveRoleIDs(ids ...int64) *UserUpdate { + _u.mutation.RemoveRoleIDs(ids...) + return _u } // RemoveRoles removes "roles" edges to Role entities. -func (uu *UserUpdate) RemoveRoles(r ...*Role) *UserUpdate { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *UserUpdate) RemoveRoles(v ...*Role) *UserUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.RemoveRoleIDs(ids...) + return _u.RemoveRoleIDs(ids...) } // ClearPositions clears all "positions" edges to the Position entity. -func (uu *UserUpdate) ClearPositions() *UserUpdate { - uu.mutation.ClearPositions() - return uu +func (_u *UserUpdate) ClearPositions() *UserUpdate { + _u.mutation.ClearPositions() + return _u } // RemovePositionIDs removes the "positions" edge to Position entities by IDs. -func (uu *UserUpdate) RemovePositionIDs(ids ...int64) *UserUpdate { - uu.mutation.RemovePositionIDs(ids...) - return uu +func (_u *UserUpdate) RemovePositionIDs(ids ...int64) *UserUpdate { + _u.mutation.RemovePositionIDs(ids...) + return _u } // RemovePositions removes "positions" edges to Position entities. -func (uu *UserUpdate) RemovePositions(p ...*Position) *UserUpdate { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *UserUpdate) RemovePositions(v ...*Position) *UserUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.RemovePositionIDs(ids...) + return _u.RemovePositionIDs(ids...) } // ClearDepartments clears all "departments" edges to the Department entity. -func (uu *UserUpdate) ClearDepartments() *UserUpdate { - uu.mutation.ClearDepartments() - return uu +func (_u *UserUpdate) ClearDepartments() *UserUpdate { + _u.mutation.ClearDepartments() + return _u } // RemoveDepartmentIDs removes the "departments" edge to Department entities by IDs. -func (uu *UserUpdate) RemoveDepartmentIDs(ids ...int64) *UserUpdate { - uu.mutation.RemoveDepartmentIDs(ids...) - return uu +func (_u *UserUpdate) RemoveDepartmentIDs(ids ...int64) *UserUpdate { + _u.mutation.RemoveDepartmentIDs(ids...) + return _u } // RemoveDepartments removes "departments" edges to Department entities. -func (uu *UserUpdate) RemoveDepartments(d ...*Department) *UserUpdate { - ids := make([]int64, len(d)) - for i := range d { - ids[i] = d[i].ID +func (_u *UserUpdate) RemoveDepartments(v ...*Department) *UserUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.RemoveDepartmentIDs(ids...) + return _u.RemoveDepartmentIDs(ids...) } // ClearUserRoles clears all "user_roles" edges to the UserRole entity. -func (uu *UserUpdate) ClearUserRoles() *UserUpdate { - uu.mutation.ClearUserRoles() - return uu +func (_u *UserUpdate) ClearUserRoles() *UserUpdate { + _u.mutation.ClearUserRoles() + return _u } // RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. -func (uu *UserUpdate) RemoveUserRoleIDs(ids ...int) *UserUpdate { - uu.mutation.RemoveUserRoleIDs(ids...) - return uu +func (_u *UserUpdate) RemoveUserRoleIDs(ids ...int) *UserUpdate { + _u.mutation.RemoveUserRoleIDs(ids...) + return _u } // RemoveUserRoles removes "user_roles" edges to UserRole entities. -func (uu *UserUpdate) RemoveUserRoles(u ...*UserRole) *UserUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdate) RemoveUserRoles(v ...*UserRole) *UserUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.RemoveUserRoleIDs(ids...) + return _u.RemoveUserRoleIDs(ids...) } // ClearUserPositions clears all "user_positions" edges to the UserPosition entity. -func (uu *UserUpdate) ClearUserPositions() *UserUpdate { - uu.mutation.ClearUserPositions() - return uu +func (_u *UserUpdate) ClearUserPositions() *UserUpdate { + _u.mutation.ClearUserPositions() + return _u } // RemoveUserPositionIDs removes the "user_positions" edge to UserPosition entities by IDs. -func (uu *UserUpdate) RemoveUserPositionIDs(ids ...int) *UserUpdate { - uu.mutation.RemoveUserPositionIDs(ids...) - return uu +func (_u *UserUpdate) RemoveUserPositionIDs(ids ...int) *UserUpdate { + _u.mutation.RemoveUserPositionIDs(ids...) + return _u } // RemoveUserPositions removes "user_positions" edges to UserPosition entities. -func (uu *UserUpdate) RemoveUserPositions(u ...*UserPosition) *UserUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdate) RemoveUserPositions(v ...*UserPosition) *UserUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.RemoveUserPositionIDs(ids...) + return _u.RemoveUserPositionIDs(ids...) } // ClearUserDepartments clears all "user_departments" edges to the UserDepartment entity. -func (uu *UserUpdate) ClearUserDepartments() *UserUpdate { - uu.mutation.ClearUserDepartments() - return uu +func (_u *UserUpdate) ClearUserDepartments() *UserUpdate { + _u.mutation.ClearUserDepartments() + return _u } // RemoveUserDepartmentIDs removes the "user_departments" edge to UserDepartment entities by IDs. -func (uu *UserUpdate) RemoveUserDepartmentIDs(ids ...int) *UserUpdate { - uu.mutation.RemoveUserDepartmentIDs(ids...) - return uu +func (_u *UserUpdate) RemoveUserDepartmentIDs(ids ...int) *UserUpdate { + _u.mutation.RemoveUserDepartmentIDs(ids...) + return _u } // RemoveUserDepartments removes "user_departments" edges to UserDepartment entities. -func (uu *UserUpdate) RemoveUserDepartments(u ...*UserDepartment) *UserUpdate { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdate) RemoveUserDepartments(v ...*UserDepartment) *UserUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uu.RemoveUserDepartmentIDs(ids...) + return _u.RemoveUserDepartmentIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. -func (uu *UserUpdate) Save(ctx context.Context) (int, error) { - if err := uu.defaults(); err != nil { +func (_u *UserUpdate) Save(ctx context.Context) (int, error) { + if err := _u.defaults(); err != nil { return 0, err } - return withHooks(ctx, uu.sqlSave, uu.mutation, uu.hooks) + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (uu *UserUpdate) SaveX(ctx context.Context) int { - affected, err := uu.Save(ctx) +func (_u *UserUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -688,103 +688,103 @@ func (uu *UserUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (uu *UserUpdate) Exec(ctx context.Context) error { - _, err := uu.Save(ctx) +func (_u *UserUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (uu *UserUpdate) ExecX(ctx context.Context) { - if err := uu.Exec(ctx); err != nil { +func (_u *UserUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (uu *UserUpdate) defaults() error { - if _, ok := uu.mutation.UpdateTime(); !ok { +func (_u *UserUpdate) defaults() error { + if _, ok := _u.mutation.UpdateTime(); !ok { if user.UpdateDefaultUpdateTime == nil { return fmt.Errorf("ent: uninitialized user.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") } v := user.UpdateDefaultUpdateTime() - uu.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } return nil } // check runs all checks and user-defined validators on the builder. -func (uu *UserUpdate) check() error { - if v, ok := uu.mutation.UUID(); ok { +func (_u *UserUpdate) check() error { + if v, ok := _u.mutation.UUID(); ok { if err := user.UUIDValidator(v); err != nil { return &ValidationError{Name: "uuid", err: fmt.Errorf(`ent: validator failed for field "User.uuid": %w`, err)} } } - if v, ok := uu.mutation.Username(); ok { + if v, ok := _u.mutation.Username(); ok { if err := user.UsernameValidator(v); err != nil { return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} } } - if v, ok := uu.mutation.Nickname(); ok { + if v, ok := _u.mutation.Nickname(); ok { if err := user.NicknameValidator(v); err != nil { return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} } } - if v, ok := uu.mutation.Avatar(); ok { + if v, ok := _u.mutation.Avatar(); ok { if err := user.AvatarValidator(v); err != nil { return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} } } - if v, ok := uu.mutation.Name(); ok { + if v, ok := _u.mutation.Name(); ok { if err := user.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} } } - if v, ok := uu.mutation.Gender(); ok { + if v, ok := _u.mutation.Gender(); ok { if err := user.GenderValidator(v); err != nil { return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} } } - if v, ok := uu.mutation.EncryptedPassword(); ok { + if v, ok := _u.mutation.EncryptedPassword(); ok { if err := user.EncryptedPasswordValidator(v); err != nil { return &ValidationError{Name: "encrypted_password", err: fmt.Errorf(`ent: validator failed for field "User.encrypted_password": %w`, err)} } } - if v, ok := uu.mutation.Salt(); ok { + if v, ok := _u.mutation.Salt(); ok { if err := user.SaltValidator(v); err != nil { return &ValidationError{Name: "salt", err: fmt.Errorf(`ent: validator failed for field "User.salt": %w`, err)} } } - if v, ok := uu.mutation.Phone(); ok { + if v, ok := _u.mutation.Phone(); ok { if err := user.PhoneValidator(v); err != nil { return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "User.phone": %w`, err)} } } - if v, ok := uu.mutation.Email(); ok { + if v, ok := _u.mutation.Email(); ok { if err := user.EmailValidator(v); err != nil { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} } } - if v, ok := uu.mutation.Department(); ok { + if v, ok := _u.mutation.Department(); ok { if err := user.DepartmentValidator(v); err != nil { return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} } } - if v, ok := uu.mutation.Remark(); ok { + if v, ok := _u.mutation.Remark(); ok { if err := user.RemarkValidator(v); err != nil { return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "User.remark": %w`, err)} } } - if v, ok := uu.mutation.Token(); ok { + if v, ok := _u.mutation.Token(); ok { if err := user.TokenValidator(v); err != nil { return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "User.token": %w`, err)} } } - if v, ok := uu.mutation.LastLoginIP(); ok { + if v, ok := _u.mutation.LastLoginIP(); ok { if err := user.LastLoginIPValidator(v); err != nil { return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} } } - if v, ok := uu.mutation.ManagerID(); ok { + if v, ok := _u.mutation.ManagerID(); ok { if err := user.ManagerIDValidator(v); err != nil { return &ValidationError{Name: "manager_id", err: fmt.Errorf(`ent: validator failed for field "User.manager_id": %w`, err)} } @@ -793,129 +793,129 @@ func (uu *UserUpdate) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (uu *UserUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdate { - uu.modifiers = append(uu.modifiers, modifiers...) - return uu +func (_u *UserUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := uu.check(); err != nil { - return n, err +func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) - if ps := uu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := uu.mutation.CreateAuthor(); ok { + if value, ok := _u.mutation.CreateAuthor(); ok { _spec.SetField(user.FieldCreateAuthor, field.TypeInt64, value) } - if value, ok := uu.mutation.AddedCreateAuthor(); ok { + if value, ok := _u.mutation.AddedCreateAuthor(); ok { _spec.AddField(user.FieldCreateAuthor, field.TypeInt64, value) } - if uu.mutation.CreateAuthorCleared() { + if _u.mutation.CreateAuthorCleared() { _spec.ClearField(user.FieldCreateAuthor, field.TypeInt64) } - if value, ok := uu.mutation.UpdateAuthor(); ok { + if value, ok := _u.mutation.UpdateAuthor(); ok { _spec.SetField(user.FieldUpdateAuthor, field.TypeInt64, value) } - if value, ok := uu.mutation.AddedUpdateAuthor(); ok { + if value, ok := _u.mutation.AddedUpdateAuthor(); ok { _spec.AddField(user.FieldUpdateAuthor, field.TypeInt64, value) } - if uu.mutation.UpdateAuthorCleared() { + if _u.mutation.UpdateAuthorCleared() { _spec.ClearField(user.FieldUpdateAuthor, field.TypeInt64) } - if value, ok := uu.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) } - if value, ok := uu.mutation.DeleteTime(); ok { + if value, ok := _u.mutation.DeleteTime(); ok { _spec.SetField(user.FieldDeleteTime, field.TypeTime, value) } - if uu.mutation.DeleteTimeCleared() { + if _u.mutation.DeleteTimeCleared() { _spec.ClearField(user.FieldDeleteTime, field.TypeTime) } - if value, ok := uu.mutation.UUID(); ok { + if value, ok := _u.mutation.UUID(); ok { _spec.SetField(user.FieldUUID, field.TypeString, value) } - if value, ok := uu.mutation.AllowedIP(); ok { + if value, ok := _u.mutation.AllowedIP(); ok { _spec.SetField(user.FieldAllowedIP, field.TypeString, value) } - if value, ok := uu.mutation.Username(); ok { + if value, ok := _u.mutation.Username(); ok { _spec.SetField(user.FieldUsername, field.TypeString, value) } - if value, ok := uu.mutation.Nickname(); ok { + if value, ok := _u.mutation.Nickname(); ok { _spec.SetField(user.FieldNickname, field.TypeString, value) } - if value, ok := uu.mutation.Avatar(); ok { + if value, ok := _u.mutation.Avatar(); ok { _spec.SetField(user.FieldAvatar, field.TypeString, value) } - if value, ok := uu.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(user.FieldName, field.TypeString, value) } - if value, ok := uu.mutation.Gender(); ok { + if value, ok := _u.mutation.Gender(); ok { _spec.SetField(user.FieldGender, field.TypeEnum, value) } - if value, ok := uu.mutation.EncryptedPassword(); ok { + if value, ok := _u.mutation.EncryptedPassword(); ok { _spec.SetField(user.FieldEncryptedPassword, field.TypeString, value) } - if value, ok := uu.mutation.Salt(); ok { + if value, ok := _u.mutation.Salt(); ok { _spec.SetField(user.FieldSalt, field.TypeString, value) } - if value, ok := uu.mutation.Phone(); ok { + if value, ok := _u.mutation.Phone(); ok { _spec.SetField(user.FieldPhone, field.TypeString, value) } - if value, ok := uu.mutation.Email(); ok { + if value, ok := _u.mutation.Email(); ok { _spec.SetField(user.FieldEmail, field.TypeString, value) } - if value, ok := uu.mutation.Department(); ok { + if value, ok := _u.mutation.Department(); ok { _spec.SetField(user.FieldDepartment, field.TypeString, value) } - if value, ok := uu.mutation.Remark(); ok { + if value, ok := _u.mutation.Remark(); ok { _spec.SetField(user.FieldRemark, field.TypeString, value) } - if value, ok := uu.mutation.Token(); ok { + if value, ok := _u.mutation.Token(); ok { _spec.SetField(user.FieldToken, field.TypeString, value) } - if value, ok := uu.mutation.Status(); ok { + if value, ok := _u.mutation.Status(); ok { _spec.SetField(user.FieldStatus, field.TypeInt8, value) } - if value, ok := uu.mutation.AddedStatus(); ok { + if value, ok := _u.mutation.AddedStatus(); ok { _spec.AddField(user.FieldStatus, field.TypeInt8, value) } - if value, ok := uu.mutation.IsSystem(); ok { + if value, ok := _u.mutation.IsSystem(); ok { _spec.SetField(user.FieldIsSystem, field.TypeBool, value) } - if value, ok := uu.mutation.LastLoginIP(); ok { + if value, ok := _u.mutation.LastLoginIP(); ok { _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) } - if value, ok := uu.mutation.LastLoginTime(); ok { + if value, ok := _u.mutation.LastLoginTime(); ok { _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) } - if value, ok := uu.mutation.LoginTime(); ok { + if value, ok := _u.mutation.LoginTime(); ok { _spec.SetField(user.FieldLoginTime, field.TypeTime, value) } - if value, ok := uu.mutation.SanctionDate(); ok { + if value, ok := _u.mutation.SanctionDate(); ok { _spec.SetField(user.FieldSanctionDate, field.TypeTime, value) } - if uu.mutation.SanctionDateCleared() { + if _u.mutation.SanctionDateCleared() { _spec.ClearField(user.FieldSanctionDate, field.TypeTime) } - if value, ok := uu.mutation.ManagerID(); ok { + if value, ok := _u.mutation.ManagerID(); ok { _spec.SetField(user.FieldManagerID, field.TypeInt64, value) } - if value, ok := uu.mutation.AddedManagerID(); ok { + if value, ok := _u.mutation.AddedManagerID(); ok { _spec.AddField(user.FieldManagerID, field.TypeInt64, value) } - if uu.mutation.ManagerIDCleared() { + if _u.mutation.ManagerIDCleared() { _spec.ClearField(user.FieldManagerID, field.TypeInt64) } - if value, ok := uu.mutation.Manager(); ok { + if value, ok := _u.mutation.Manager(); ok { _spec.SetField(user.FieldManager, field.TypeString, value) } - if uu.mutation.RolesCleared() { + if _u.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -928,7 +928,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.RemovedRolesIDs(); len(nodes) > 0 && !uu.mutation.RolesCleared() { + if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -944,7 +944,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.RolesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -960,7 +960,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uu.mutation.PositionsCleared() { + if _u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -973,7 +973,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !uu.mutation.PositionsCleared() { + if nodes := _u.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !_u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -989,7 +989,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.PositionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1005,7 +1005,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uu.mutation.DepartmentsCleared() { + if _u.mutation.DepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1018,7 +1018,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.RemovedDepartmentsIDs(); len(nodes) > 0 && !uu.mutation.DepartmentsCleared() { + if nodes := _u.mutation.RemovedDepartmentsIDs(); len(nodes) > 0 && !_u.mutation.DepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1034,7 +1034,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.DepartmentsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.DepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1050,7 +1050,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uu.mutation.UserRolesCleared() { + if _u.mutation.UserRolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1063,7 +1063,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !uu.mutation.UserRolesCleared() { + if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1079,7 +1079,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.UserRolesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1095,7 +1095,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uu.mutation.UserPositionsCleared() { + if _u.mutation.UserPositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1108,7 +1108,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.RemovedUserPositionsIDs(); len(nodes) > 0 && !uu.mutation.UserPositionsCleared() { + if nodes := _u.mutation.RemovedUserPositionsIDs(); len(nodes) > 0 && !_u.mutation.UserPositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1124,7 +1124,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.UserPositionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserPositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1140,7 +1140,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uu.mutation.UserDepartmentsCleared() { + if _u.mutation.UserDepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1153,7 +1153,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.RemovedUserDepartmentsIDs(); len(nodes) > 0 && !uu.mutation.UserDepartmentsCleared() { + if nodes := _u.mutation.RemovedUserDepartmentsIDs(); len(nodes) > 0 && !_u.mutation.UserDepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1169,7 +1169,7 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uu.mutation.UserDepartmentsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserDepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -1185,8 +1185,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(uu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} } else if sqlgraph.IsConstraintError(err) { @@ -1194,8 +1194,8 @@ func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - uu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // UserUpdateOne is the builder for updating a single User entity. @@ -1208,664 +1208,664 @@ type UserUpdateOne struct { } // SetCreateAuthor sets the "create_author" field. -func (uuo *UserUpdateOne) SetCreateAuthor(i int64) *UserUpdateOne { - uuo.mutation.ResetCreateAuthor() - uuo.mutation.SetCreateAuthor(i) - return uuo +func (_u *UserUpdateOne) SetCreateAuthor(v int64) *UserUpdateOne { + _u.mutation.ResetCreateAuthor() + _u.mutation.SetCreateAuthor(v) + return _u } // SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableCreateAuthor(i *int64) *UserUpdateOne { - if i != nil { - uuo.SetCreateAuthor(*i) +func (_u *UserUpdateOne) SetNillableCreateAuthor(v *int64) *UserUpdateOne { + if v != nil { + _u.SetCreateAuthor(*v) } - return uuo + return _u } -// AddCreateAuthor adds i to the "create_author" field. -func (uuo *UserUpdateOne) AddCreateAuthor(i int64) *UserUpdateOne { - uuo.mutation.AddCreateAuthor(i) - return uuo +// AddCreateAuthor adds value to the "create_author" field. +func (_u *UserUpdateOne) AddCreateAuthor(v int64) *UserUpdateOne { + _u.mutation.AddCreateAuthor(v) + return _u } // ClearCreateAuthor clears the value of the "create_author" field. -func (uuo *UserUpdateOne) ClearCreateAuthor() *UserUpdateOne { - uuo.mutation.ClearCreateAuthor() - return uuo +func (_u *UserUpdateOne) ClearCreateAuthor() *UserUpdateOne { + _u.mutation.ClearCreateAuthor() + return _u } // SetUpdateAuthor sets the "update_author" field. -func (uuo *UserUpdateOne) SetUpdateAuthor(i int64) *UserUpdateOne { - uuo.mutation.ResetUpdateAuthor() - uuo.mutation.SetUpdateAuthor(i) - return uuo +func (_u *UserUpdateOne) SetUpdateAuthor(v int64) *UserUpdateOne { + _u.mutation.ResetUpdateAuthor() + _u.mutation.SetUpdateAuthor(v) + return _u } // SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableUpdateAuthor(i *int64) *UserUpdateOne { - if i != nil { - uuo.SetUpdateAuthor(*i) +func (_u *UserUpdateOne) SetNillableUpdateAuthor(v *int64) *UserUpdateOne { + if v != nil { + _u.SetUpdateAuthor(*v) } - return uuo + return _u } -// AddUpdateAuthor adds i to the "update_author" field. -func (uuo *UserUpdateOne) AddUpdateAuthor(i int64) *UserUpdateOne { - uuo.mutation.AddUpdateAuthor(i) - return uuo +// AddUpdateAuthor adds value to the "update_author" field. +func (_u *UserUpdateOne) AddUpdateAuthor(v int64) *UserUpdateOne { + _u.mutation.AddUpdateAuthor(v) + return _u } // ClearUpdateAuthor clears the value of the "update_author" field. -func (uuo *UserUpdateOne) ClearUpdateAuthor() *UserUpdateOne { - uuo.mutation.ClearUpdateAuthor() - return uuo +func (_u *UserUpdateOne) ClearUpdateAuthor() *UserUpdateOne { + _u.mutation.ClearUpdateAuthor() + return _u } // SetUpdateTime sets the "update_time" field. -func (uuo *UserUpdateOne) SetUpdateTime(t time.Time) *UserUpdateOne { - uuo.mutation.SetUpdateTime(t) - return uuo +func (_u *UserUpdateOne) SetUpdateTime(v time.Time) *UserUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u } // SetDeleteTime sets the "delete_time" field. -func (uuo *UserUpdateOne) SetDeleteTime(t time.Time) *UserUpdateOne { - uuo.mutation.SetDeleteTime(t) - return uuo +func (_u *UserUpdateOne) SetDeleteTime(v time.Time) *UserUpdateOne { + _u.mutation.SetDeleteTime(v) + return _u } // SetNillableDeleteTime sets the "delete_time" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableDeleteTime(t *time.Time) *UserUpdateOne { - if t != nil { - uuo.SetDeleteTime(*t) +func (_u *UserUpdateOne) SetNillableDeleteTime(v *time.Time) *UserUpdateOne { + if v != nil { + _u.SetDeleteTime(*v) } - return uuo + return _u } // ClearDeleteTime clears the value of the "delete_time" field. -func (uuo *UserUpdateOne) ClearDeleteTime() *UserUpdateOne { - uuo.mutation.ClearDeleteTime() - return uuo +func (_u *UserUpdateOne) ClearDeleteTime() *UserUpdateOne { + _u.mutation.ClearDeleteTime() + return _u } // SetUUID sets the "uuid" field. -func (uuo *UserUpdateOne) SetUUID(s string) *UserUpdateOne { - uuo.mutation.SetUUID(s) - return uuo +func (_u *UserUpdateOne) SetUUID(v string) *UserUpdateOne { + _u.mutation.SetUUID(v) + return _u } // SetNillableUUID sets the "uuid" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableUUID(s *string) *UserUpdateOne { - if s != nil { - uuo.SetUUID(*s) +func (_u *UserUpdateOne) SetNillableUUID(v *string) *UserUpdateOne { + if v != nil { + _u.SetUUID(*v) } - return uuo + return _u } // SetAllowedIP sets the "allowed_ip" field. -func (uuo *UserUpdateOne) SetAllowedIP(s string) *UserUpdateOne { - uuo.mutation.SetAllowedIP(s) - return uuo +func (_u *UserUpdateOne) SetAllowedIP(v string) *UserUpdateOne { + _u.mutation.SetAllowedIP(v) + return _u } // SetNillableAllowedIP sets the "allowed_ip" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableAllowedIP(s *string) *UserUpdateOne { - if s != nil { - uuo.SetAllowedIP(*s) +func (_u *UserUpdateOne) SetNillableAllowedIP(v *string) *UserUpdateOne { + if v != nil { + _u.SetAllowedIP(*v) } - return uuo + return _u } // SetUsername sets the "username" field. -func (uuo *UserUpdateOne) SetUsername(s string) *UserUpdateOne { - uuo.mutation.SetUsername(s) - return uuo +func (_u *UserUpdateOne) SetUsername(v string) *UserUpdateOne { + _u.mutation.SetUsername(v) + return _u } // SetNillableUsername sets the "username" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableUsername(s *string) *UserUpdateOne { - if s != nil { - uuo.SetUsername(*s) +func (_u *UserUpdateOne) SetNillableUsername(v *string) *UserUpdateOne { + if v != nil { + _u.SetUsername(*v) } - return uuo + return _u } // SetNickname sets the "nickname" field. -func (uuo *UserUpdateOne) SetNickname(s string) *UserUpdateOne { - uuo.mutation.SetNickname(s) - return uuo +func (_u *UserUpdateOne) SetNickname(v string) *UserUpdateOne { + _u.mutation.SetNickname(v) + return _u } // SetNillableNickname sets the "nickname" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableNickname(s *string) *UserUpdateOne { - if s != nil { - uuo.SetNickname(*s) +func (_u *UserUpdateOne) SetNillableNickname(v *string) *UserUpdateOne { + if v != nil { + _u.SetNickname(*v) } - return uuo + return _u } // SetAvatar sets the "avatar" field. -func (uuo *UserUpdateOne) SetAvatar(s string) *UserUpdateOne { - uuo.mutation.SetAvatar(s) - return uuo +func (_u *UserUpdateOne) SetAvatar(v string) *UserUpdateOne { + _u.mutation.SetAvatar(v) + return _u } // SetNillableAvatar sets the "avatar" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableAvatar(s *string) *UserUpdateOne { - if s != nil { - uuo.SetAvatar(*s) +func (_u *UserUpdateOne) SetNillableAvatar(v *string) *UserUpdateOne { + if v != nil { + _u.SetAvatar(*v) } - return uuo + return _u } // SetName sets the "name" field. -func (uuo *UserUpdateOne) SetName(s string) *UserUpdateOne { - uuo.mutation.SetName(s) - return uuo +func (_u *UserUpdateOne) SetName(v string) *UserUpdateOne { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableName(s *string) *UserUpdateOne { - if s != nil { - uuo.SetName(*s) +func (_u *UserUpdateOne) SetNillableName(v *string) *UserUpdateOne { + if v != nil { + _u.SetName(*v) } - return uuo + return _u } // SetGender sets the "gender" field. -func (uuo *UserUpdateOne) SetGender(u user.Gender) *UserUpdateOne { - uuo.mutation.SetGender(u) - return uuo +func (_u *UserUpdateOne) SetGender(v user.Gender) *UserUpdateOne { + _u.mutation.SetGender(v) + return _u } // SetNillableGender sets the "gender" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableGender(u *user.Gender) *UserUpdateOne { - if u != nil { - uuo.SetGender(*u) +func (_u *UserUpdateOne) SetNillableGender(v *user.Gender) *UserUpdateOne { + if v != nil { + _u.SetGender(*v) } - return uuo + return _u } // SetEncryptedPassword sets the "encrypted_password" field. -func (uuo *UserUpdateOne) SetEncryptedPassword(s string) *UserUpdateOne { - uuo.mutation.SetEncryptedPassword(s) - return uuo +func (_u *UserUpdateOne) SetEncryptedPassword(v string) *UserUpdateOne { + _u.mutation.SetEncryptedPassword(v) + return _u } // SetNillableEncryptedPassword sets the "encrypted_password" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableEncryptedPassword(s *string) *UserUpdateOne { - if s != nil { - uuo.SetEncryptedPassword(*s) +func (_u *UserUpdateOne) SetNillableEncryptedPassword(v *string) *UserUpdateOne { + if v != nil { + _u.SetEncryptedPassword(*v) } - return uuo + return _u } // SetSalt sets the "salt" field. -func (uuo *UserUpdateOne) SetSalt(s string) *UserUpdateOne { - uuo.mutation.SetSalt(s) - return uuo +func (_u *UserUpdateOne) SetSalt(v string) *UserUpdateOne { + _u.mutation.SetSalt(v) + return _u } // SetNillableSalt sets the "salt" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableSalt(s *string) *UserUpdateOne { - if s != nil { - uuo.SetSalt(*s) +func (_u *UserUpdateOne) SetNillableSalt(v *string) *UserUpdateOne { + if v != nil { + _u.SetSalt(*v) } - return uuo + return _u } // SetPhone sets the "phone" field. -func (uuo *UserUpdateOne) SetPhone(s string) *UserUpdateOne { - uuo.mutation.SetPhone(s) - return uuo +func (_u *UserUpdateOne) SetPhone(v string) *UserUpdateOne { + _u.mutation.SetPhone(v) + return _u } // SetNillablePhone sets the "phone" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillablePhone(s *string) *UserUpdateOne { - if s != nil { - uuo.SetPhone(*s) +func (_u *UserUpdateOne) SetNillablePhone(v *string) *UserUpdateOne { + if v != nil { + _u.SetPhone(*v) } - return uuo + return _u } // SetEmail sets the "email" field. -func (uuo *UserUpdateOne) SetEmail(s string) *UserUpdateOne { - uuo.mutation.SetEmail(s) - return uuo +func (_u *UserUpdateOne) SetEmail(v string) *UserUpdateOne { + _u.mutation.SetEmail(v) + return _u } // SetNillableEmail sets the "email" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableEmail(s *string) *UserUpdateOne { - if s != nil { - uuo.SetEmail(*s) +func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne { + if v != nil { + _u.SetEmail(*v) } - return uuo + return _u } // SetDepartment sets the "department" field. -func (uuo *UserUpdateOne) SetDepartment(s string) *UserUpdateOne { - uuo.mutation.SetDepartment(s) - return uuo +func (_u *UserUpdateOne) SetDepartment(v string) *UserUpdateOne { + _u.mutation.SetDepartment(v) + return _u } // SetNillableDepartment sets the "department" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableDepartment(s *string) *UserUpdateOne { - if s != nil { - uuo.SetDepartment(*s) +func (_u *UserUpdateOne) SetNillableDepartment(v *string) *UserUpdateOne { + if v != nil { + _u.SetDepartment(*v) } - return uuo + return _u } // SetRemark sets the "remark" field. -func (uuo *UserUpdateOne) SetRemark(s string) *UserUpdateOne { - uuo.mutation.SetRemark(s) - return uuo +func (_u *UserUpdateOne) SetRemark(v string) *UserUpdateOne { + _u.mutation.SetRemark(v) + return _u } // SetNillableRemark sets the "remark" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableRemark(s *string) *UserUpdateOne { - if s != nil { - uuo.SetRemark(*s) +func (_u *UserUpdateOne) SetNillableRemark(v *string) *UserUpdateOne { + if v != nil { + _u.SetRemark(*v) } - return uuo + return _u } // SetToken sets the "token" field. -func (uuo *UserUpdateOne) SetToken(s string) *UserUpdateOne { - uuo.mutation.SetToken(s) - return uuo +func (_u *UserUpdateOne) SetToken(v string) *UserUpdateOne { + _u.mutation.SetToken(v) + return _u } // SetNillableToken sets the "token" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableToken(s *string) *UserUpdateOne { - if s != nil { - uuo.SetToken(*s) +func (_u *UserUpdateOne) SetNillableToken(v *string) *UserUpdateOne { + if v != nil { + _u.SetToken(*v) } - return uuo + return _u } // SetStatus sets the "status" field. -func (uuo *UserUpdateOne) SetStatus(i int8) *UserUpdateOne { - uuo.mutation.ResetStatus() - uuo.mutation.SetStatus(i) - return uuo +func (_u *UserUpdateOne) SetStatus(v int8) *UserUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableStatus(i *int8) *UserUpdateOne { - if i != nil { - uuo.SetStatus(*i) +func (_u *UserUpdateOne) SetNillableStatus(v *int8) *UserUpdateOne { + if v != nil { + _u.SetStatus(*v) } - return uuo + return _u } -// AddStatus adds i to the "status" field. -func (uuo *UserUpdateOne) AddStatus(i int8) *UserUpdateOne { - uuo.mutation.AddStatus(i) - return uuo +// AddStatus adds value to the "status" field. +func (_u *UserUpdateOne) AddStatus(v int8) *UserUpdateOne { + _u.mutation.AddStatus(v) + return _u } // SetIsSystem sets the "is_system" field. -func (uuo *UserUpdateOne) SetIsSystem(b bool) *UserUpdateOne { - uuo.mutation.SetIsSystem(b) - return uuo +func (_u *UserUpdateOne) SetIsSystem(v bool) *UserUpdateOne { + _u.mutation.SetIsSystem(v) + return _u } // SetNillableIsSystem sets the "is_system" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableIsSystem(b *bool) *UserUpdateOne { - if b != nil { - uuo.SetIsSystem(*b) +func (_u *UserUpdateOne) SetNillableIsSystem(v *bool) *UserUpdateOne { + if v != nil { + _u.SetIsSystem(*v) } - return uuo + return _u } // SetLastLoginIP sets the "last_login_ip" field. -func (uuo *UserUpdateOne) SetLastLoginIP(s string) *UserUpdateOne { - uuo.mutation.SetLastLoginIP(s) - return uuo +func (_u *UserUpdateOne) SetLastLoginIP(v string) *UserUpdateOne { + _u.mutation.SetLastLoginIP(v) + return _u } // SetNillableLastLoginIP sets the "last_login_ip" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableLastLoginIP(s *string) *UserUpdateOne { - if s != nil { - uuo.SetLastLoginIP(*s) +func (_u *UserUpdateOne) SetNillableLastLoginIP(v *string) *UserUpdateOne { + if v != nil { + _u.SetLastLoginIP(*v) } - return uuo + return _u } // SetLastLoginTime sets the "last_login_time" field. -func (uuo *UserUpdateOne) SetLastLoginTime(t time.Time) *UserUpdateOne { - uuo.mutation.SetLastLoginTime(t) - return uuo +func (_u *UserUpdateOne) SetLastLoginTime(v time.Time) *UserUpdateOne { + _u.mutation.SetLastLoginTime(v) + return _u } // SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableLastLoginTime(t *time.Time) *UserUpdateOne { - if t != nil { - uuo.SetLastLoginTime(*t) +func (_u *UserUpdateOne) SetNillableLastLoginTime(v *time.Time) *UserUpdateOne { + if v != nil { + _u.SetLastLoginTime(*v) } - return uuo + return _u } // SetLoginTime sets the "login_time" field. -func (uuo *UserUpdateOne) SetLoginTime(t time.Time) *UserUpdateOne { - uuo.mutation.SetLoginTime(t) - return uuo +func (_u *UserUpdateOne) SetLoginTime(v time.Time) *UserUpdateOne { + _u.mutation.SetLoginTime(v) + return _u } // SetNillableLoginTime sets the "login_time" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableLoginTime(t *time.Time) *UserUpdateOne { - if t != nil { - uuo.SetLoginTime(*t) +func (_u *UserUpdateOne) SetNillableLoginTime(v *time.Time) *UserUpdateOne { + if v != nil { + _u.SetLoginTime(*v) } - return uuo + return _u } // SetSanctionDate sets the "sanction_date" field. -func (uuo *UserUpdateOne) SetSanctionDate(t time.Time) *UserUpdateOne { - uuo.mutation.SetSanctionDate(t) - return uuo +func (_u *UserUpdateOne) SetSanctionDate(v time.Time) *UserUpdateOne { + _u.mutation.SetSanctionDate(v) + return _u } // SetNillableSanctionDate sets the "sanction_date" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableSanctionDate(t *time.Time) *UserUpdateOne { - if t != nil { - uuo.SetSanctionDate(*t) +func (_u *UserUpdateOne) SetNillableSanctionDate(v *time.Time) *UserUpdateOne { + if v != nil { + _u.SetSanctionDate(*v) } - return uuo + return _u } // ClearSanctionDate clears the value of the "sanction_date" field. -func (uuo *UserUpdateOne) ClearSanctionDate() *UserUpdateOne { - uuo.mutation.ClearSanctionDate() - return uuo +func (_u *UserUpdateOne) ClearSanctionDate() *UserUpdateOne { + _u.mutation.ClearSanctionDate() + return _u } // SetManagerID sets the "manager_id" field. -func (uuo *UserUpdateOne) SetManagerID(i int64) *UserUpdateOne { - uuo.mutation.ResetManagerID() - uuo.mutation.SetManagerID(i) - return uuo +func (_u *UserUpdateOne) SetManagerID(v int64) *UserUpdateOne { + _u.mutation.ResetManagerID() + _u.mutation.SetManagerID(v) + return _u } // SetNillableManagerID sets the "manager_id" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableManagerID(i *int64) *UserUpdateOne { - if i != nil { - uuo.SetManagerID(*i) +func (_u *UserUpdateOne) SetNillableManagerID(v *int64) *UserUpdateOne { + if v != nil { + _u.SetManagerID(*v) } - return uuo + return _u } -// AddManagerID adds i to the "manager_id" field. -func (uuo *UserUpdateOne) AddManagerID(i int64) *UserUpdateOne { - uuo.mutation.AddManagerID(i) - return uuo +// AddManagerID adds value to the "manager_id" field. +func (_u *UserUpdateOne) AddManagerID(v int64) *UserUpdateOne { + _u.mutation.AddManagerID(v) + return _u } // ClearManagerID clears the value of the "manager_id" field. -func (uuo *UserUpdateOne) ClearManagerID() *UserUpdateOne { - uuo.mutation.ClearManagerID() - return uuo +func (_u *UserUpdateOne) ClearManagerID() *UserUpdateOne { + _u.mutation.ClearManagerID() + return _u } // SetManager sets the "manager" field. -func (uuo *UserUpdateOne) SetManager(s string) *UserUpdateOne { - uuo.mutation.SetManager(s) - return uuo +func (_u *UserUpdateOne) SetManager(v string) *UserUpdateOne { + _u.mutation.SetManager(v) + return _u } // SetNillableManager sets the "manager" field if the given value is not nil. -func (uuo *UserUpdateOne) SetNillableManager(s *string) *UserUpdateOne { - if s != nil { - uuo.SetManager(*s) +func (_u *UserUpdateOne) SetNillableManager(v *string) *UserUpdateOne { + if v != nil { + _u.SetManager(*v) } - return uuo + return _u } // AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (uuo *UserUpdateOne) AddRoleIDs(ids ...int64) *UserUpdateOne { - uuo.mutation.AddRoleIDs(ids...) - return uuo +func (_u *UserUpdateOne) AddRoleIDs(ids ...int64) *UserUpdateOne { + _u.mutation.AddRoleIDs(ids...) + return _u } // AddRoles adds the "roles" edges to the Role entity. -func (uuo *UserUpdateOne) AddRoles(r ...*Role) *UserUpdateOne { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *UserUpdateOne) AddRoles(v ...*Role) *UserUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.AddRoleIDs(ids...) + return _u.AddRoleIDs(ids...) } // AddPositionIDs adds the "positions" edge to the Position entity by IDs. -func (uuo *UserUpdateOne) AddPositionIDs(ids ...int64) *UserUpdateOne { - uuo.mutation.AddPositionIDs(ids...) - return uuo +func (_u *UserUpdateOne) AddPositionIDs(ids ...int64) *UserUpdateOne { + _u.mutation.AddPositionIDs(ids...) + return _u } // AddPositions adds the "positions" edges to the Position entity. -func (uuo *UserUpdateOne) AddPositions(p ...*Position) *UserUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *UserUpdateOne) AddPositions(v ...*Position) *UserUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.AddPositionIDs(ids...) + return _u.AddPositionIDs(ids...) } // AddDepartmentIDs adds the "departments" edge to the Department entity by IDs. -func (uuo *UserUpdateOne) AddDepartmentIDs(ids ...int64) *UserUpdateOne { - uuo.mutation.AddDepartmentIDs(ids...) - return uuo +func (_u *UserUpdateOne) AddDepartmentIDs(ids ...int64) *UserUpdateOne { + _u.mutation.AddDepartmentIDs(ids...) + return _u } // AddDepartments adds the "departments" edges to the Department entity. -func (uuo *UserUpdateOne) AddDepartments(d ...*Department) *UserUpdateOne { - ids := make([]int64, len(d)) - for i := range d { - ids[i] = d[i].ID +func (_u *UserUpdateOne) AddDepartments(v ...*Department) *UserUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.AddDepartmentIDs(ids...) + return _u.AddDepartmentIDs(ids...) } // AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (uuo *UserUpdateOne) AddUserRoleIDs(ids ...int) *UserUpdateOne { - uuo.mutation.AddUserRoleIDs(ids...) - return uuo +func (_u *UserUpdateOne) AddUserRoleIDs(ids ...int) *UserUpdateOne { + _u.mutation.AddUserRoleIDs(ids...) + return _u } // AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (uuo *UserUpdateOne) AddUserRoles(u ...*UserRole) *UserUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdateOne) AddUserRoles(v ...*UserRole) *UserUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.AddUserRoleIDs(ids...) + return _u.AddUserRoleIDs(ids...) } // AddUserPositionIDs adds the "user_positions" edge to the UserPosition entity by IDs. -func (uuo *UserUpdateOne) AddUserPositionIDs(ids ...int) *UserUpdateOne { - uuo.mutation.AddUserPositionIDs(ids...) - return uuo +func (_u *UserUpdateOne) AddUserPositionIDs(ids ...int) *UserUpdateOne { + _u.mutation.AddUserPositionIDs(ids...) + return _u } // AddUserPositions adds the "user_positions" edges to the UserPosition entity. -func (uuo *UserUpdateOne) AddUserPositions(u ...*UserPosition) *UserUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdateOne) AddUserPositions(v ...*UserPosition) *UserUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.AddUserPositionIDs(ids...) + return _u.AddUserPositionIDs(ids...) } // AddUserDepartmentIDs adds the "user_departments" edge to the UserDepartment entity by IDs. -func (uuo *UserUpdateOne) AddUserDepartmentIDs(ids ...int) *UserUpdateOne { - uuo.mutation.AddUserDepartmentIDs(ids...) - return uuo +func (_u *UserUpdateOne) AddUserDepartmentIDs(ids ...int) *UserUpdateOne { + _u.mutation.AddUserDepartmentIDs(ids...) + return _u } // AddUserDepartments adds the "user_departments" edges to the UserDepartment entity. -func (uuo *UserUpdateOne) AddUserDepartments(u ...*UserDepartment) *UserUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdateOne) AddUserDepartments(v ...*UserDepartment) *UserUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.AddUserDepartmentIDs(ids...) + return _u.AddUserDepartmentIDs(ids...) } // Mutation returns the UserMutation object of the builder. -func (uuo *UserUpdateOne) Mutation() *UserMutation { - return uuo.mutation +func (_u *UserUpdateOne) Mutation() *UserMutation { + return _u.mutation } // ClearRoles clears all "roles" edges to the Role entity. -func (uuo *UserUpdateOne) ClearRoles() *UserUpdateOne { - uuo.mutation.ClearRoles() - return uuo +func (_u *UserUpdateOne) ClearRoles() *UserUpdateOne { + _u.mutation.ClearRoles() + return _u } // RemoveRoleIDs removes the "roles" edge to Role entities by IDs. -func (uuo *UserUpdateOne) RemoveRoleIDs(ids ...int64) *UserUpdateOne { - uuo.mutation.RemoveRoleIDs(ids...) - return uuo +func (_u *UserUpdateOne) RemoveRoleIDs(ids ...int64) *UserUpdateOne { + _u.mutation.RemoveRoleIDs(ids...) + return _u } // RemoveRoles removes "roles" edges to Role entities. -func (uuo *UserUpdateOne) RemoveRoles(r ...*Role) *UserUpdateOne { - ids := make([]int64, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *UserUpdateOne) RemoveRoles(v ...*Role) *UserUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.RemoveRoleIDs(ids...) + return _u.RemoveRoleIDs(ids...) } // ClearPositions clears all "positions" edges to the Position entity. -func (uuo *UserUpdateOne) ClearPositions() *UserUpdateOne { - uuo.mutation.ClearPositions() - return uuo +func (_u *UserUpdateOne) ClearPositions() *UserUpdateOne { + _u.mutation.ClearPositions() + return _u } // RemovePositionIDs removes the "positions" edge to Position entities by IDs. -func (uuo *UserUpdateOne) RemovePositionIDs(ids ...int64) *UserUpdateOne { - uuo.mutation.RemovePositionIDs(ids...) - return uuo +func (_u *UserUpdateOne) RemovePositionIDs(ids ...int64) *UserUpdateOne { + _u.mutation.RemovePositionIDs(ids...) + return _u } // RemovePositions removes "positions" edges to Position entities. -func (uuo *UserUpdateOne) RemovePositions(p ...*Position) *UserUpdateOne { - ids := make([]int64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *UserUpdateOne) RemovePositions(v ...*Position) *UserUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.RemovePositionIDs(ids...) + return _u.RemovePositionIDs(ids...) } // ClearDepartments clears all "departments" edges to the Department entity. -func (uuo *UserUpdateOne) ClearDepartments() *UserUpdateOne { - uuo.mutation.ClearDepartments() - return uuo +func (_u *UserUpdateOne) ClearDepartments() *UserUpdateOne { + _u.mutation.ClearDepartments() + return _u } // RemoveDepartmentIDs removes the "departments" edge to Department entities by IDs. -func (uuo *UserUpdateOne) RemoveDepartmentIDs(ids ...int64) *UserUpdateOne { - uuo.mutation.RemoveDepartmentIDs(ids...) - return uuo +func (_u *UserUpdateOne) RemoveDepartmentIDs(ids ...int64) *UserUpdateOne { + _u.mutation.RemoveDepartmentIDs(ids...) + return _u } // RemoveDepartments removes "departments" edges to Department entities. -func (uuo *UserUpdateOne) RemoveDepartments(d ...*Department) *UserUpdateOne { - ids := make([]int64, len(d)) - for i := range d { - ids[i] = d[i].ID +func (_u *UserUpdateOne) RemoveDepartments(v ...*Department) *UserUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.RemoveDepartmentIDs(ids...) + return _u.RemoveDepartmentIDs(ids...) } // ClearUserRoles clears all "user_roles" edges to the UserRole entity. -func (uuo *UserUpdateOne) ClearUserRoles() *UserUpdateOne { - uuo.mutation.ClearUserRoles() - return uuo +func (_u *UserUpdateOne) ClearUserRoles() *UserUpdateOne { + _u.mutation.ClearUserRoles() + return _u } // RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. -func (uuo *UserUpdateOne) RemoveUserRoleIDs(ids ...int) *UserUpdateOne { - uuo.mutation.RemoveUserRoleIDs(ids...) - return uuo +func (_u *UserUpdateOne) RemoveUserRoleIDs(ids ...int) *UserUpdateOne { + _u.mutation.RemoveUserRoleIDs(ids...) + return _u } // RemoveUserRoles removes "user_roles" edges to UserRole entities. -func (uuo *UserUpdateOne) RemoveUserRoles(u ...*UserRole) *UserUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdateOne) RemoveUserRoles(v ...*UserRole) *UserUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.RemoveUserRoleIDs(ids...) + return _u.RemoveUserRoleIDs(ids...) } // ClearUserPositions clears all "user_positions" edges to the UserPosition entity. -func (uuo *UserUpdateOne) ClearUserPositions() *UserUpdateOne { - uuo.mutation.ClearUserPositions() - return uuo +func (_u *UserUpdateOne) ClearUserPositions() *UserUpdateOne { + _u.mutation.ClearUserPositions() + return _u } // RemoveUserPositionIDs removes the "user_positions" edge to UserPosition entities by IDs. -func (uuo *UserUpdateOne) RemoveUserPositionIDs(ids ...int) *UserUpdateOne { - uuo.mutation.RemoveUserPositionIDs(ids...) - return uuo +func (_u *UserUpdateOne) RemoveUserPositionIDs(ids ...int) *UserUpdateOne { + _u.mutation.RemoveUserPositionIDs(ids...) + return _u } // RemoveUserPositions removes "user_positions" edges to UserPosition entities. -func (uuo *UserUpdateOne) RemoveUserPositions(u ...*UserPosition) *UserUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdateOne) RemoveUserPositions(v ...*UserPosition) *UserUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.RemoveUserPositionIDs(ids...) + return _u.RemoveUserPositionIDs(ids...) } // ClearUserDepartments clears all "user_departments" edges to the UserDepartment entity. -func (uuo *UserUpdateOne) ClearUserDepartments() *UserUpdateOne { - uuo.mutation.ClearUserDepartments() - return uuo +func (_u *UserUpdateOne) ClearUserDepartments() *UserUpdateOne { + _u.mutation.ClearUserDepartments() + return _u } // RemoveUserDepartmentIDs removes the "user_departments" edge to UserDepartment entities by IDs. -func (uuo *UserUpdateOne) RemoveUserDepartmentIDs(ids ...int) *UserUpdateOne { - uuo.mutation.RemoveUserDepartmentIDs(ids...) - return uuo +func (_u *UserUpdateOne) RemoveUserDepartmentIDs(ids ...int) *UserUpdateOne { + _u.mutation.RemoveUserDepartmentIDs(ids...) + return _u } // RemoveUserDepartments removes "user_departments" edges to UserDepartment entities. -func (uuo *UserUpdateOne) RemoveUserDepartments(u ...*UserDepartment) *UserUpdateOne { - ids := make([]int, len(u)) - for i := range u { - ids[i] = u[i].ID +func (_u *UserUpdateOne) RemoveUserDepartments(v ...*UserDepartment) *UserUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return uuo.RemoveUserDepartmentIDs(ids...) + return _u.RemoveUserDepartmentIDs(ids...) } // Where appends a list predicates to the UserUpdate builder. -func (uuo *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { - uuo.mutation.Where(ps...) - return uuo +func (_u *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { - uuo.fields = append([]string{field}, fields...) - return uuo +func (_u *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated User entity. -func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { - if err := uuo.defaults(); err != nil { +func (_u *UserUpdateOne) Save(ctx context.Context) (*User, error) { + if err := _u.defaults(); err != nil { return nil, err } - return withHooks(ctx, uuo.sqlSave, uuo.mutation, uuo.hooks) + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User { - node, err := uuo.Save(ctx) +func (_u *UserUpdateOne) SaveX(ctx context.Context) *User { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -1873,103 +1873,103 @@ func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User { } // Exec executes the query on the entity. -func (uuo *UserUpdateOne) Exec(ctx context.Context) error { - _, err := uuo.Save(ctx) +func (_u *UserUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (uuo *UserUpdateOne) ExecX(ctx context.Context) { - if err := uuo.Exec(ctx); err != nil { +func (_u *UserUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (uuo *UserUpdateOne) defaults() error { - if _, ok := uuo.mutation.UpdateTime(); !ok { +func (_u *UserUpdateOne) defaults() error { + if _, ok := _u.mutation.UpdateTime(); !ok { if user.UpdateDefaultUpdateTime == nil { return fmt.Errorf("ent: uninitialized user.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") } v := user.UpdateDefaultUpdateTime() - uuo.mutation.SetUpdateTime(v) + _u.mutation.SetUpdateTime(v) } return nil } // check runs all checks and user-defined validators on the builder. -func (uuo *UserUpdateOne) check() error { - if v, ok := uuo.mutation.UUID(); ok { +func (_u *UserUpdateOne) check() error { + if v, ok := _u.mutation.UUID(); ok { if err := user.UUIDValidator(v); err != nil { return &ValidationError{Name: "uuid", err: fmt.Errorf(`ent: validator failed for field "User.uuid": %w`, err)} } } - if v, ok := uuo.mutation.Username(); ok { + if v, ok := _u.mutation.Username(); ok { if err := user.UsernameValidator(v); err != nil { return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} } } - if v, ok := uuo.mutation.Nickname(); ok { + if v, ok := _u.mutation.Nickname(); ok { if err := user.NicknameValidator(v); err != nil { return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} } } - if v, ok := uuo.mutation.Avatar(); ok { + if v, ok := _u.mutation.Avatar(); ok { if err := user.AvatarValidator(v); err != nil { return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} } } - if v, ok := uuo.mutation.Name(); ok { + if v, ok := _u.mutation.Name(); ok { if err := user.NameValidator(v); err != nil { return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} } } - if v, ok := uuo.mutation.Gender(); ok { + if v, ok := _u.mutation.Gender(); ok { if err := user.GenderValidator(v); err != nil { return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} } } - if v, ok := uuo.mutation.EncryptedPassword(); ok { + if v, ok := _u.mutation.EncryptedPassword(); ok { if err := user.EncryptedPasswordValidator(v); err != nil { return &ValidationError{Name: "encrypted_password", err: fmt.Errorf(`ent: validator failed for field "User.encrypted_password": %w`, err)} } } - if v, ok := uuo.mutation.Salt(); ok { + if v, ok := _u.mutation.Salt(); ok { if err := user.SaltValidator(v); err != nil { return &ValidationError{Name: "salt", err: fmt.Errorf(`ent: validator failed for field "User.salt": %w`, err)} } } - if v, ok := uuo.mutation.Phone(); ok { + if v, ok := _u.mutation.Phone(); ok { if err := user.PhoneValidator(v); err != nil { return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "User.phone": %w`, err)} } } - if v, ok := uuo.mutation.Email(); ok { + if v, ok := _u.mutation.Email(); ok { if err := user.EmailValidator(v); err != nil { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} } } - if v, ok := uuo.mutation.Department(); ok { + if v, ok := _u.mutation.Department(); ok { if err := user.DepartmentValidator(v); err != nil { return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} } } - if v, ok := uuo.mutation.Remark(); ok { + if v, ok := _u.mutation.Remark(); ok { if err := user.RemarkValidator(v); err != nil { return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "User.remark": %w`, err)} } } - if v, ok := uuo.mutation.Token(); ok { + if v, ok := _u.mutation.Token(); ok { if err := user.TokenValidator(v); err != nil { return &ValidationError{Name: "token", err: fmt.Errorf(`ent: validator failed for field "User.token": %w`, err)} } } - if v, ok := uuo.mutation.LastLoginIP(); ok { + if v, ok := _u.mutation.LastLoginIP(); ok { if err := user.LastLoginIPValidator(v); err != nil { return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} } } - if v, ok := uuo.mutation.ManagerID(); ok { + if v, ok := _u.mutation.ManagerID(); ok { if err := user.ManagerIDValidator(v); err != nil { return &ValidationError{Name: "manager_id", err: fmt.Errorf(`ent: validator failed for field "User.manager_id": %w`, err)} } @@ -1978,22 +1978,22 @@ func (uuo *UserUpdateOne) check() error { } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (uuo *UserUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdateOne { - uuo.modifiers = append(uuo.modifiers, modifiers...) - return uuo +func (_u *UserUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { - if err := uuo.check(); err != nil { +func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) - id, ok := uuo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} } _spec.Node.ID.Value = id - if fields := uuo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) for _, f := range fields { @@ -2005,119 +2005,119 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } } } - if ps := uuo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := uuo.mutation.CreateAuthor(); ok { + if value, ok := _u.mutation.CreateAuthor(); ok { _spec.SetField(user.FieldCreateAuthor, field.TypeInt64, value) } - if value, ok := uuo.mutation.AddedCreateAuthor(); ok { + if value, ok := _u.mutation.AddedCreateAuthor(); ok { _spec.AddField(user.FieldCreateAuthor, field.TypeInt64, value) } - if uuo.mutation.CreateAuthorCleared() { + if _u.mutation.CreateAuthorCleared() { _spec.ClearField(user.FieldCreateAuthor, field.TypeInt64) } - if value, ok := uuo.mutation.UpdateAuthor(); ok { + if value, ok := _u.mutation.UpdateAuthor(); ok { _spec.SetField(user.FieldUpdateAuthor, field.TypeInt64, value) } - if value, ok := uuo.mutation.AddedUpdateAuthor(); ok { + if value, ok := _u.mutation.AddedUpdateAuthor(); ok { _spec.AddField(user.FieldUpdateAuthor, field.TypeInt64, value) } - if uuo.mutation.UpdateAuthorCleared() { + if _u.mutation.UpdateAuthorCleared() { _spec.ClearField(user.FieldUpdateAuthor, field.TypeInt64) } - if value, ok := uuo.mutation.UpdateTime(); ok { + if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) } - if value, ok := uuo.mutation.DeleteTime(); ok { + if value, ok := _u.mutation.DeleteTime(); ok { _spec.SetField(user.FieldDeleteTime, field.TypeTime, value) } - if uuo.mutation.DeleteTimeCleared() { + if _u.mutation.DeleteTimeCleared() { _spec.ClearField(user.FieldDeleteTime, field.TypeTime) } - if value, ok := uuo.mutation.UUID(); ok { + if value, ok := _u.mutation.UUID(); ok { _spec.SetField(user.FieldUUID, field.TypeString, value) } - if value, ok := uuo.mutation.AllowedIP(); ok { + if value, ok := _u.mutation.AllowedIP(); ok { _spec.SetField(user.FieldAllowedIP, field.TypeString, value) } - if value, ok := uuo.mutation.Username(); ok { + if value, ok := _u.mutation.Username(); ok { _spec.SetField(user.FieldUsername, field.TypeString, value) } - if value, ok := uuo.mutation.Nickname(); ok { + if value, ok := _u.mutation.Nickname(); ok { _spec.SetField(user.FieldNickname, field.TypeString, value) } - if value, ok := uuo.mutation.Avatar(); ok { + if value, ok := _u.mutation.Avatar(); ok { _spec.SetField(user.FieldAvatar, field.TypeString, value) } - if value, ok := uuo.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(user.FieldName, field.TypeString, value) } - if value, ok := uuo.mutation.Gender(); ok { + if value, ok := _u.mutation.Gender(); ok { _spec.SetField(user.FieldGender, field.TypeEnum, value) } - if value, ok := uuo.mutation.EncryptedPassword(); ok { + if value, ok := _u.mutation.EncryptedPassword(); ok { _spec.SetField(user.FieldEncryptedPassword, field.TypeString, value) } - if value, ok := uuo.mutation.Salt(); ok { + if value, ok := _u.mutation.Salt(); ok { _spec.SetField(user.FieldSalt, field.TypeString, value) } - if value, ok := uuo.mutation.Phone(); ok { + if value, ok := _u.mutation.Phone(); ok { _spec.SetField(user.FieldPhone, field.TypeString, value) } - if value, ok := uuo.mutation.Email(); ok { + if value, ok := _u.mutation.Email(); ok { _spec.SetField(user.FieldEmail, field.TypeString, value) } - if value, ok := uuo.mutation.Department(); ok { + if value, ok := _u.mutation.Department(); ok { _spec.SetField(user.FieldDepartment, field.TypeString, value) } - if value, ok := uuo.mutation.Remark(); ok { + if value, ok := _u.mutation.Remark(); ok { _spec.SetField(user.FieldRemark, field.TypeString, value) } - if value, ok := uuo.mutation.Token(); ok { + if value, ok := _u.mutation.Token(); ok { _spec.SetField(user.FieldToken, field.TypeString, value) } - if value, ok := uuo.mutation.Status(); ok { + if value, ok := _u.mutation.Status(); ok { _spec.SetField(user.FieldStatus, field.TypeInt8, value) } - if value, ok := uuo.mutation.AddedStatus(); ok { + if value, ok := _u.mutation.AddedStatus(); ok { _spec.AddField(user.FieldStatus, field.TypeInt8, value) } - if value, ok := uuo.mutation.IsSystem(); ok { + if value, ok := _u.mutation.IsSystem(); ok { _spec.SetField(user.FieldIsSystem, field.TypeBool, value) } - if value, ok := uuo.mutation.LastLoginIP(); ok { + if value, ok := _u.mutation.LastLoginIP(); ok { _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) } - if value, ok := uuo.mutation.LastLoginTime(); ok { + if value, ok := _u.mutation.LastLoginTime(); ok { _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) } - if value, ok := uuo.mutation.LoginTime(); ok { + if value, ok := _u.mutation.LoginTime(); ok { _spec.SetField(user.FieldLoginTime, field.TypeTime, value) } - if value, ok := uuo.mutation.SanctionDate(); ok { + if value, ok := _u.mutation.SanctionDate(); ok { _spec.SetField(user.FieldSanctionDate, field.TypeTime, value) } - if uuo.mutation.SanctionDateCleared() { + if _u.mutation.SanctionDateCleared() { _spec.ClearField(user.FieldSanctionDate, field.TypeTime) } - if value, ok := uuo.mutation.ManagerID(); ok { + if value, ok := _u.mutation.ManagerID(); ok { _spec.SetField(user.FieldManagerID, field.TypeInt64, value) } - if value, ok := uuo.mutation.AddedManagerID(); ok { + if value, ok := _u.mutation.AddedManagerID(); ok { _spec.AddField(user.FieldManagerID, field.TypeInt64, value) } - if uuo.mutation.ManagerIDCleared() { + if _u.mutation.ManagerIDCleared() { _spec.ClearField(user.FieldManagerID, field.TypeInt64) } - if value, ok := uuo.mutation.Manager(); ok { + if value, ok := _u.mutation.Manager(); ok { _spec.SetField(user.FieldManager, field.TypeString, value) } - if uuo.mutation.RolesCleared() { + if _u.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -2130,7 +2130,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.RemovedRolesIDs(); len(nodes) > 0 && !uuo.mutation.RolesCleared() { + if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -2146,7 +2146,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.RolesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -2162,7 +2162,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uuo.mutation.PositionsCleared() { + if _u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -2175,7 +2175,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !uuo.mutation.PositionsCleared() { + if nodes := _u.mutation.RemovedPositionsIDs(); len(nodes) > 0 && !_u.mutation.PositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -2191,7 +2191,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.PositionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -2207,7 +2207,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uuo.mutation.DepartmentsCleared() { + if _u.mutation.DepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -2220,7 +2220,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.RemovedDepartmentsIDs(); len(nodes) > 0 && !uuo.mutation.DepartmentsCleared() { + if nodes := _u.mutation.RemovedDepartmentsIDs(); len(nodes) > 0 && !_u.mutation.DepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -2236,7 +2236,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.DepartmentsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.DepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -2252,7 +2252,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uuo.mutation.UserRolesCleared() { + if _u.mutation.UserRolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -2265,7 +2265,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !uuo.mutation.UserRolesCleared() { + if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -2281,7 +2281,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.UserRolesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -2297,7 +2297,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uuo.mutation.UserPositionsCleared() { + if _u.mutation.UserPositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -2310,7 +2310,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.RemovedUserPositionsIDs(); len(nodes) > 0 && !uuo.mutation.UserPositionsCleared() { + if nodes := _u.mutation.RemovedUserPositionsIDs(); len(nodes) > 0 && !_u.mutation.UserPositionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -2326,7 +2326,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.UserPositionsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserPositionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -2342,7 +2342,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uuo.mutation.UserDepartmentsCleared() { + if _u.mutation.UserDepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -2355,7 +2355,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.RemovedUserDepartmentsIDs(); len(nodes) > 0 && !uuo.mutation.UserDepartmentsCleared() { + if nodes := _u.mutation.RemovedUserDepartmentsIDs(); len(nodes) > 0 && !_u.mutation.UserDepartmentsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -2371,7 +2371,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uuo.mutation.UserDepartmentsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserDepartmentsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: true, @@ -2387,11 +2387,11 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(uuo.modifiers...) - _node = &User{config: uuo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &User{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{user.Label} } else if sqlgraph.IsConstraintError(err) { @@ -2399,7 +2399,7 @@ func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) } return nil, err } - uuo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/userdepartment.go b/internal/data/entity/ent/userdepartment.go index 2617c5d3..d620bf0d 100644 --- a/internal/data/entity/ent/userdepartment.go +++ b/internal/data/entity/ent/userdepartment.go @@ -77,7 +77,7 @@ func (*UserDepartment) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the UserDepartment fields. -func (ud *UserDepartment) assignValues(columns []string, values []any) error { +func (_m *UserDepartment) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -88,21 +88,21 @@ func (ud *UserDepartment) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - ud.ID = int(value.Int64) + _m.ID = int(value.Int64) case userdepartment.FieldUserID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field user_id", values[i]) } else if value.Valid { - ud.UserID = value.Int64 + _m.UserID = value.Int64 } case userdepartment.FieldDepartmentID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field department_id", values[i]) } else if value.Valid { - ud.DepartmentID = value.Int64 + _m.DepartmentID = value.Int64 } default: - ud.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -110,48 +110,48 @@ func (ud *UserDepartment) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the UserDepartment. // This includes values selected through modifiers, order, etc. -func (ud *UserDepartment) Value(name string) (ent.Value, error) { - return ud.selectValues.Get(name) +func (_m *UserDepartment) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryUser queries the "user" edge of the UserDepartment entity. -func (ud *UserDepartment) QueryUser() *UserQuery { - return NewUserDepartmentClient(ud.config).QueryUser(ud) +func (_m *UserDepartment) QueryUser() *UserQuery { + return NewUserDepartmentClient(_m.config).QueryUser(_m) } // QueryDepartment queries the "department" edge of the UserDepartment entity. -func (ud *UserDepartment) QueryDepartment() *DepartmentQuery { - return NewUserDepartmentClient(ud.config).QueryDepartment(ud) +func (_m *UserDepartment) QueryDepartment() *DepartmentQuery { + return NewUserDepartmentClient(_m.config).QueryDepartment(_m) } // Update returns a builder for updating this UserDepartment. // Note that you need to call UserDepartment.Unwrap() before calling this method if this UserDepartment // was returned from a transaction, and the transaction was committed or rolled back. -func (ud *UserDepartment) Update() *UserDepartmentUpdateOne { - return NewUserDepartmentClient(ud.config).UpdateOne(ud) +func (_m *UserDepartment) Update() *UserDepartmentUpdateOne { + return NewUserDepartmentClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the UserDepartment entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (ud *UserDepartment) Unwrap() *UserDepartment { - _tx, ok := ud.config.driver.(*txDriver) +func (_m *UserDepartment) Unwrap() *UserDepartment { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: UserDepartment is not a transactional entity") } - ud.config.driver = _tx.drv - return ud + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (ud *UserDepartment) String() string { +func (_m *UserDepartment) String() string { var builder strings.Builder builder.WriteString("UserDepartment(") - builder.WriteString(fmt.Sprintf("id=%v, ", ud.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("user_id=") - builder.WriteString(fmt.Sprintf("%v", ud.UserID)) + builder.WriteString(fmt.Sprintf("%v", _m.UserID)) builder.WriteString(", ") builder.WriteString("department_id=") - builder.WriteString(fmt.Sprintf("%v", ud.DepartmentID)) + builder.WriteString(fmt.Sprintf("%v", _m.DepartmentID)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/userdepartment_create.go b/internal/data/entity/ent/userdepartment_create.go index e3803367..bf89873c 100644 --- a/internal/data/entity/ent/userdepartment_create.go +++ b/internal/data/entity/ent/userdepartment_create.go @@ -22,40 +22,40 @@ type UserDepartmentCreate struct { } // SetUserID sets the "user_id" field. -func (udc *UserDepartmentCreate) SetUserID(i int64) *UserDepartmentCreate { - udc.mutation.SetUserID(i) - return udc +func (_c *UserDepartmentCreate) SetUserID(v int64) *UserDepartmentCreate { + _c.mutation.SetUserID(v) + return _c } // SetDepartmentID sets the "department_id" field. -func (udc *UserDepartmentCreate) SetDepartmentID(i int64) *UserDepartmentCreate { - udc.mutation.SetDepartmentID(i) - return udc +func (_c *UserDepartmentCreate) SetDepartmentID(v int64) *UserDepartmentCreate { + _c.mutation.SetDepartmentID(v) + return _c } // SetUser sets the "user" edge to the User entity. -func (udc *UserDepartmentCreate) SetUser(u *User) *UserDepartmentCreate { - return udc.SetUserID(u.ID) +func (_c *UserDepartmentCreate) SetUser(v *User) *UserDepartmentCreate { + return _c.SetUserID(v.ID) } // SetDepartment sets the "department" edge to the Department entity. -func (udc *UserDepartmentCreate) SetDepartment(d *Department) *UserDepartmentCreate { - return udc.SetDepartmentID(d.ID) +func (_c *UserDepartmentCreate) SetDepartment(v *Department) *UserDepartmentCreate { + return _c.SetDepartmentID(v.ID) } // Mutation returns the UserDepartmentMutation object of the builder. -func (udc *UserDepartmentCreate) Mutation() *UserDepartmentMutation { - return udc.mutation +func (_c *UserDepartmentCreate) Mutation() *UserDepartmentMutation { + return _c.mutation } // Save creates the UserDepartment in the database. -func (udc *UserDepartmentCreate) Save(ctx context.Context) (*UserDepartment, error) { - return withHooks(ctx, udc.sqlSave, udc.mutation, udc.hooks) +func (_c *UserDepartmentCreate) Save(ctx context.Context) (*UserDepartment, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (udc *UserDepartmentCreate) SaveX(ctx context.Context) *UserDepartment { - v, err := udc.Save(ctx) +func (_c *UserDepartmentCreate) SaveX(ctx context.Context) *UserDepartment { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -63,51 +63,51 @@ func (udc *UserDepartmentCreate) SaveX(ctx context.Context) *UserDepartment { } // Exec executes the query. -func (udc *UserDepartmentCreate) Exec(ctx context.Context) error { - _, err := udc.Save(ctx) +func (_c *UserDepartmentCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (udc *UserDepartmentCreate) ExecX(ctx context.Context) { - if err := udc.Exec(ctx); err != nil { +func (_c *UserDepartmentCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (udc *UserDepartmentCreate) check() error { - if _, ok := udc.mutation.UserID(); !ok { +func (_c *UserDepartmentCreate) check() error { + if _, ok := _c.mutation.UserID(); !ok { return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserDepartment.user_id"`)} } - if v, ok := udc.mutation.UserID(); ok { + if v, ok := _c.mutation.UserID(); ok { if err := userdepartment.UserIDValidator(v); err != nil { return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserDepartment.user_id": %w`, err)} } } - if _, ok := udc.mutation.DepartmentID(); !ok { + if _, ok := _c.mutation.DepartmentID(); !ok { return &ValidationError{Name: "department_id", err: errors.New(`ent: missing required field "UserDepartment.department_id"`)} } - if v, ok := udc.mutation.DepartmentID(); ok { + if v, ok := _c.mutation.DepartmentID(); ok { if err := userdepartment.DepartmentIDValidator(v); err != nil { return &ValidationError{Name: "department_id", err: fmt.Errorf(`ent: validator failed for field "UserDepartment.department_id": %w`, err)} } } - if len(udc.mutation.UserIDs()) == 0 { + if len(_c.mutation.UserIDs()) == 0 { return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserDepartment.user"`)} } - if len(udc.mutation.DepartmentIDs()) == 0 { + if len(_c.mutation.DepartmentIDs()) == 0 { return &ValidationError{Name: "department", err: errors.New(`ent: missing required edge "UserDepartment.department"`)} } return nil } -func (udc *UserDepartmentCreate) sqlSave(ctx context.Context) (*UserDepartment, error) { - if err := udc.check(); err != nil { +func (_c *UserDepartmentCreate) sqlSave(ctx context.Context) (*UserDepartment, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := udc.createSpec() - if err := sqlgraph.CreateNode(ctx, udc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -115,17 +115,17 @@ func (udc *UserDepartmentCreate) sqlSave(ctx context.Context) (*UserDepartment, } id := _spec.ID.Value.(int64) _node.ID = int(id) - udc.mutation.id = &_node.ID - udc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (udc *UserDepartmentCreate) createSpec() (*UserDepartment, *sqlgraph.CreateSpec) { +func (_c *UserDepartmentCreate) createSpec() (*UserDepartment, *sqlgraph.CreateSpec) { var ( - _node = &UserDepartment{config: udc.config} + _node = &UserDepartment{config: _c.config} _spec = sqlgraph.NewCreateSpec(userdepartment.Table, sqlgraph.NewFieldSpec(userdepartment.FieldID, field.TypeInt)) ) - if nodes := udc.mutation.UserIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -142,7 +142,7 @@ func (udc *UserDepartmentCreate) createSpec() (*UserDepartment, *sqlgraph.Create _node.UserID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := udc.mutation.DepartmentIDs(); len(nodes) > 0 { + if nodes := _c.mutation.DepartmentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -163,23 +163,23 @@ func (udc *UserDepartmentCreate) createSpec() (*UserDepartment, *sqlgraph.Create } // SetUserDepartment set the UserDepartment -func (udc *UserDepartmentCreate) SetUserDepartment(input *UserDepartment, fields ...string) *UserDepartmentCreate { - m := udc.mutation +func (_c *UserDepartmentCreate) SetUserDepartment(input *UserDepartment, fields ...string) *UserDepartmentCreate { + m := _c.mutation if len(fields) == 0 { fields = userdepartment.Columns } _ = m.SetFields(input, fields...) - return udc + return _c } // SetUserDepartmentWithZero set the UserDepartment -func (udc *UserDepartmentCreate) SetUserDepartmentWithZero(input *UserDepartment, fields ...string) *UserDepartmentCreate { - m := udc.mutation +func (_c *UserDepartmentCreate) SetUserDepartmentWithZero(input *UserDepartment, fields ...string) *UserDepartmentCreate { + m := _c.mutation if len(fields) == 0 { fields = userdepartment.Columns } _ = m.SetFieldsWithZero(input, fields...) - return udc + return _c } // UserDepartmentCreateBulk is the builder for creating many UserDepartment entities in bulk. @@ -190,16 +190,16 @@ type UserDepartmentCreateBulk struct { } // Save creates the UserDepartment entities in the database. -func (udcb *UserDepartmentCreateBulk) Save(ctx context.Context) ([]*UserDepartment, error) { - if udcb.err != nil { - return nil, udcb.err +func (_c *UserDepartmentCreateBulk) Save(ctx context.Context) ([]*UserDepartment, error) { + if _c.err != nil { + return nil, _c.err } - specs := make([]*sqlgraph.CreateSpec, len(udcb.builders)) - nodes := make([]*UserDepartment, len(udcb.builders)) - mutators := make([]Mutator, len(udcb.builders)) - for i := range udcb.builders { + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*UserDepartment, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := udcb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*UserDepartmentMutation) if !ok { @@ -212,11 +212,11 @@ func (udcb *UserDepartmentCreateBulk) Save(ctx context.Context) ([]*UserDepartme var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, udcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, udcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -240,7 +240,7 @@ func (udcb *UserDepartmentCreateBulk) Save(ctx context.Context) ([]*UserDepartme }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, udcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -248,8 +248,8 @@ func (udcb *UserDepartmentCreateBulk) Save(ctx context.Context) ([]*UserDepartme } // SaveX is like Save, but panics if an error occurs. -func (udcb *UserDepartmentCreateBulk) SaveX(ctx context.Context) []*UserDepartment { - v, err := udcb.Save(ctx) +func (_c *UserDepartmentCreateBulk) SaveX(ctx context.Context) []*UserDepartment { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -257,14 +257,14 @@ func (udcb *UserDepartmentCreateBulk) SaveX(ctx context.Context) []*UserDepartme } // Exec executes the query. -func (udcb *UserDepartmentCreateBulk) Exec(ctx context.Context) error { - _, err := udcb.Save(ctx) +func (_c *UserDepartmentCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (udcb *UserDepartmentCreateBulk) ExecX(ctx context.Context) { - if err := udcb.Exec(ctx); err != nil { +func (_c *UserDepartmentCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/userdepartment_delete.go b/internal/data/entity/ent/userdepartment_delete.go index ccda834e..5dcf3c20 100644 --- a/internal/data/entity/ent/userdepartment_delete.go +++ b/internal/data/entity/ent/userdepartment_delete.go @@ -20,56 +20,56 @@ type UserDepartmentDelete struct { } // Where appends a list predicates to the UserDepartmentDelete builder. -func (udd *UserDepartmentDelete) Where(ps ...predicate.UserDepartment) *UserDepartmentDelete { - udd.mutation.Where(ps...) - return udd +func (_d *UserDepartmentDelete) Where(ps ...predicate.UserDepartment) *UserDepartmentDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (udd *UserDepartmentDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, udd.sqlExec, udd.mutation, udd.hooks) +func (_d *UserDepartmentDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (udd *UserDepartmentDelete) ExecX(ctx context.Context) int { - n, err := udd.Exec(ctx) +func (_d *UserDepartmentDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (udd *UserDepartmentDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *UserDepartmentDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(userdepartment.Table, sqlgraph.NewFieldSpec(userdepartment.FieldID, field.TypeInt)) - if ps := udd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, udd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - udd.mutation.done = true + _d.mutation.done = true return affected, err } // UserDepartmentDeleteOne is the builder for deleting a single UserDepartment entity. type UserDepartmentDeleteOne struct { - udd *UserDepartmentDelete + _d *UserDepartmentDelete } // Where appends a list predicates to the UserDepartmentDelete builder. -func (uddo *UserDepartmentDeleteOne) Where(ps ...predicate.UserDepartment) *UserDepartmentDeleteOne { - uddo.udd.mutation.Where(ps...) - return uddo +func (_d *UserDepartmentDeleteOne) Where(ps ...predicate.UserDepartment) *UserDepartmentDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (uddo *UserDepartmentDeleteOne) Exec(ctx context.Context) error { - n, err := uddo.udd.Exec(ctx) +func (_d *UserDepartmentDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (uddo *UserDepartmentDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (uddo *UserDepartmentDeleteOne) ExecX(ctx context.Context) { - if err := uddo.Exec(ctx); err != nil { +func (_d *UserDepartmentDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/userdepartment_query.go b/internal/data/entity/ent/userdepartment_query.go index f55a7b48..8b8fb49a 100644 --- a/internal/data/entity/ent/userdepartment_query.go +++ b/internal/data/entity/ent/userdepartment_query.go @@ -34,44 +34,44 @@ type UserDepartmentQuery struct { } // Where adds a new predicate for the UserDepartmentQuery builder. -func (udq *UserDepartmentQuery) Where(ps ...predicate.UserDepartment) *UserDepartmentQuery { - udq.predicates = append(udq.predicates, ps...) - return udq +func (_q *UserDepartmentQuery) Where(ps ...predicate.UserDepartment) *UserDepartmentQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (udq *UserDepartmentQuery) Limit(limit int) *UserDepartmentQuery { - udq.ctx.Limit = &limit - return udq +func (_q *UserDepartmentQuery) Limit(limit int) *UserDepartmentQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (udq *UserDepartmentQuery) Offset(offset int) *UserDepartmentQuery { - udq.ctx.Offset = &offset - return udq +func (_q *UserDepartmentQuery) Offset(offset int) *UserDepartmentQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (udq *UserDepartmentQuery) Unique(unique bool) *UserDepartmentQuery { - udq.ctx.Unique = &unique - return udq +func (_q *UserDepartmentQuery) Unique(unique bool) *UserDepartmentQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (udq *UserDepartmentQuery) Order(o ...userdepartment.OrderOption) *UserDepartmentQuery { - udq.order = append(udq.order, o...) - return udq +func (_q *UserDepartmentQuery) Order(o ...userdepartment.OrderOption) *UserDepartmentQuery { + _q.order = append(_q.order, o...) + return _q } // QueryUser chains the current query on the "user" edge. -func (udq *UserDepartmentQuery) QueryUser() *UserQuery { - query := (&UserClient{config: udq.config}).Query() +func (_q *UserDepartmentQuery) QueryUser() *UserQuery { + query := (&UserClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := udq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := udq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -80,20 +80,20 @@ func (udq *UserDepartmentQuery) QueryUser() *UserQuery { sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userdepartment.UserTable, userdepartment.UserColumn), ) - fromU = sqlgraph.SetNeighbors(udq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryDepartment chains the current query on the "department" edge. -func (udq *UserDepartmentQuery) QueryDepartment() *DepartmentQuery { - query := (&DepartmentClient{config: udq.config}).Query() +func (_q *UserDepartmentQuery) QueryDepartment() *DepartmentQuery { + query := (&DepartmentClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := udq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := udq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -102,7 +102,7 @@ func (udq *UserDepartmentQuery) QueryDepartment() *DepartmentQuery { sqlgraph.To(department.Table, department.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userdepartment.DepartmentTable, userdepartment.DepartmentColumn), ) - fromU = sqlgraph.SetNeighbors(udq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -110,8 +110,8 @@ func (udq *UserDepartmentQuery) QueryDepartment() *DepartmentQuery { // First returns the first UserDepartment entity from the query. // Returns a *NotFoundError when no UserDepartment was found. -func (udq *UserDepartmentQuery) First(ctx context.Context) (*UserDepartment, error) { - nodes, err := udq.Limit(1).All(setContextOp(ctx, udq.ctx, ent.OpQueryFirst)) +func (_q *UserDepartmentQuery) First(ctx context.Context) (*UserDepartment, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -122,8 +122,8 @@ func (udq *UserDepartmentQuery) First(ctx context.Context) (*UserDepartment, err } // FirstX is like First, but panics if an error occurs. -func (udq *UserDepartmentQuery) FirstX(ctx context.Context) *UserDepartment { - node, err := udq.First(ctx) +func (_q *UserDepartmentQuery) FirstX(ctx context.Context) *UserDepartment { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -132,9 +132,9 @@ func (udq *UserDepartmentQuery) FirstX(ctx context.Context) *UserDepartment { // FirstID returns the first UserDepartment ID from the query. // Returns a *NotFoundError when no UserDepartment ID was found. -func (udq *UserDepartmentQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *UserDepartmentQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = udq.Limit(1).IDs(setContextOp(ctx, udq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -145,8 +145,8 @@ func (udq *UserDepartmentQuery) FirstID(ctx context.Context) (id int, err error) } // FirstIDX is like FirstID, but panics if an error occurs. -func (udq *UserDepartmentQuery) FirstIDX(ctx context.Context) int { - id, err := udq.FirstID(ctx) +func (_q *UserDepartmentQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -156,8 +156,8 @@ func (udq *UserDepartmentQuery) FirstIDX(ctx context.Context) int { // Only returns a single UserDepartment entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one UserDepartment entity is found. // Returns a *NotFoundError when no UserDepartment entities are found. -func (udq *UserDepartmentQuery) Only(ctx context.Context) (*UserDepartment, error) { - nodes, err := udq.Limit(2).All(setContextOp(ctx, udq.ctx, ent.OpQueryOnly)) +func (_q *UserDepartmentQuery) Only(ctx context.Context) (*UserDepartment, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -172,8 +172,8 @@ func (udq *UserDepartmentQuery) Only(ctx context.Context) (*UserDepartment, erro } // OnlyX is like Only, but panics if an error occurs. -func (udq *UserDepartmentQuery) OnlyX(ctx context.Context) *UserDepartment { - node, err := udq.Only(ctx) +func (_q *UserDepartmentQuery) OnlyX(ctx context.Context) *UserDepartment { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -183,9 +183,9 @@ func (udq *UserDepartmentQuery) OnlyX(ctx context.Context) *UserDepartment { // OnlyID is like Only, but returns the only UserDepartment ID in the query. // Returns a *NotSingularError when more than one UserDepartment ID is found. // Returns a *NotFoundError when no entities are found. -func (udq *UserDepartmentQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *UserDepartmentQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = udq.Limit(2).IDs(setContextOp(ctx, udq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -200,8 +200,8 @@ func (udq *UserDepartmentQuery) OnlyID(ctx context.Context) (id int, err error) } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (udq *UserDepartmentQuery) OnlyIDX(ctx context.Context) int { - id, err := udq.OnlyID(ctx) +func (_q *UserDepartmentQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -209,18 +209,18 @@ func (udq *UserDepartmentQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of UserDepartments. -func (udq *UserDepartmentQuery) All(ctx context.Context) ([]*UserDepartment, error) { - ctx = setContextOp(ctx, udq.ctx, ent.OpQueryAll) - if err := udq.prepareQuery(ctx); err != nil { +func (_q *UserDepartmentQuery) All(ctx context.Context) ([]*UserDepartment, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*UserDepartment, *UserDepartmentQuery]() - return withInterceptors[[]*UserDepartment](ctx, udq, qr, udq.inters) + return withInterceptors[[]*UserDepartment](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (udq *UserDepartmentQuery) AllX(ctx context.Context) []*UserDepartment { - nodes, err := udq.All(ctx) +func (_q *UserDepartmentQuery) AllX(ctx context.Context) []*UserDepartment { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -228,20 +228,20 @@ func (udq *UserDepartmentQuery) AllX(ctx context.Context) []*UserDepartment { } // IDs executes the query and returns a list of UserDepartment IDs. -func (udq *UserDepartmentQuery) IDs(ctx context.Context) (ids []int, err error) { - if udq.ctx.Unique == nil && udq.path != nil { - udq.Unique(true) +func (_q *UserDepartmentQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, udq.ctx, ent.OpQueryIDs) - if err = udq.Select(userdepartment.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(userdepartment.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (udq *UserDepartmentQuery) IDsX(ctx context.Context) []int { - ids, err := udq.IDs(ctx) +func (_q *UserDepartmentQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -249,17 +249,17 @@ func (udq *UserDepartmentQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (udq *UserDepartmentQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, udq.ctx, ent.OpQueryCount) - if err := udq.prepareQuery(ctx); err != nil { +func (_q *UserDepartmentQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, udq, querierCount[*UserDepartmentQuery](), udq.inters) + return withInterceptors[int](ctx, _q, querierCount[*UserDepartmentQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (udq *UserDepartmentQuery) CountX(ctx context.Context) int { - count, err := udq.Count(ctx) +func (_q *UserDepartmentQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -267,9 +267,9 @@ func (udq *UserDepartmentQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (udq *UserDepartmentQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, udq.ctx, ent.OpQueryExist) - switch _, err := udq.FirstID(ctx); { +func (_q *UserDepartmentQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -280,8 +280,8 @@ func (udq *UserDepartmentQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (udq *UserDepartmentQuery) ExistX(ctx context.Context) bool { - exist, err := udq.Exist(ctx) +func (_q *UserDepartmentQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -290,45 +290,45 @@ func (udq *UserDepartmentQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the UserDepartmentQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (udq *UserDepartmentQuery) Clone() *UserDepartmentQuery { - if udq == nil { +func (_q *UserDepartmentQuery) Clone() *UserDepartmentQuery { + if _q == nil { return nil } return &UserDepartmentQuery{ - config: udq.config, - ctx: udq.ctx.Clone(), - order: append([]userdepartment.OrderOption{}, udq.order...), - inters: append([]Interceptor{}, udq.inters...), - predicates: append([]predicate.UserDepartment{}, udq.predicates...), - withUser: udq.withUser.Clone(), - withDepartment: udq.withDepartment.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]userdepartment.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.UserDepartment{}, _q.predicates...), + withUser: _q.withUser.Clone(), + withDepartment: _q.withDepartment.Clone(), // clone intermediate query. - sql: udq.sql.Clone(), - path: udq.path, - modifiers: append([]func(*sql.Selector){}, udq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithUser tells the query-builder to eager-load the nodes that are connected to // the "user" edge. The optional arguments are used to configure the query builder of the edge. -func (udq *UserDepartmentQuery) WithUser(opts ...func(*UserQuery)) *UserDepartmentQuery { - query := (&UserClient{config: udq.config}).Query() +func (_q *UserDepartmentQuery) WithUser(opts ...func(*UserQuery)) *UserDepartmentQuery { + query := (&UserClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - udq.withUser = query - return udq + _q.withUser = query + return _q } // WithDepartment tells the query-builder to eager-load the nodes that are connected to // the "department" edge. The optional arguments are used to configure the query builder of the edge. -func (udq *UserDepartmentQuery) WithDepartment(opts ...func(*DepartmentQuery)) *UserDepartmentQuery { - query := (&DepartmentClient{config: udq.config}).Query() +func (_q *UserDepartmentQuery) WithDepartment(opts ...func(*DepartmentQuery)) *UserDepartmentQuery { + query := (&DepartmentClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - udq.withDepartment = query - return udq + _q.withDepartment = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -345,10 +345,10 @@ func (udq *UserDepartmentQuery) WithDepartment(opts ...func(*DepartmentQuery)) * // GroupBy(userdepartment.FieldUserID). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (udq *UserDepartmentQuery) GroupBy(field string, fields ...string) *UserDepartmentGroupBy { - udq.ctx.Fields = append([]string{field}, fields...) - grbuild := &UserDepartmentGroupBy{build: udq} - grbuild.flds = &udq.ctx.Fields +func (_q *UserDepartmentQuery) GroupBy(field string, fields ...string) *UserDepartmentGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserDepartmentGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = userdepartment.Label grbuild.scan = grbuild.Scan return grbuild @@ -366,83 +366,83 @@ func (udq *UserDepartmentQuery) GroupBy(field string, fields ...string) *UserDep // client.UserDepartment.Query(). // Select(userdepartment.FieldUserID). // Scan(ctx, &v) -func (udq *UserDepartmentQuery) Select(fields ...string) *UserDepartmentSelect { - udq.ctx.Fields = append(udq.ctx.Fields, fields...) - sbuild := &UserDepartmentSelect{UserDepartmentQuery: udq} +func (_q *UserDepartmentQuery) Select(fields ...string) *UserDepartmentSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &UserDepartmentSelect{UserDepartmentQuery: _q} sbuild.label = userdepartment.Label - sbuild.flds, sbuild.scan = &udq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a UserDepartmentSelect configured with the given aggregations. -func (udq *UserDepartmentQuery) Aggregate(fns ...AggregateFunc) *UserDepartmentSelect { - return udq.Select().Aggregate(fns...) +func (_q *UserDepartmentQuery) Aggregate(fns ...AggregateFunc) *UserDepartmentSelect { + return _q.Select().Aggregate(fns...) } -func (udq *UserDepartmentQuery) prepareQuery(ctx context.Context) error { - for _, inter := range udq.inters { +func (_q *UserDepartmentQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, udq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range udq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !userdepartment.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if udq.path != nil { - prev, err := udq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - udq.sql = prev + _q.sql = prev } return nil } -func (udq *UserDepartmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserDepartment, error) { +func (_q *UserDepartmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserDepartment, error) { var ( nodes = []*UserDepartment{} - _spec = udq.querySpec() + _spec = _q.querySpec() loadedTypes = [2]bool{ - udq.withUser != nil, - udq.withDepartment != nil, + _q.withUser != nil, + _q.withDepartment != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*UserDepartment).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &UserDepartment{config: udq.config} + node := &UserDepartment{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(udq.modifiers) > 0 { - _spec.Modifiers = udq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, udq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := udq.withUser; query != nil { - if err := udq.loadUser(ctx, query, nodes, nil, + if query := _q.withUser; query != nil { + if err := _q.loadUser(ctx, query, nodes, nil, func(n *UserDepartment, e *User) { n.Edges.User = e }); err != nil { return nil, err } } - if query := udq.withDepartment; query != nil { - if err := udq.loadDepartment(ctx, query, nodes, nil, + if query := _q.withDepartment; query != nil { + if err := _q.loadDepartment(ctx, query, nodes, nil, func(n *UserDepartment, e *Department) { n.Edges.Department = e }); err != nil { return nil, err } @@ -450,7 +450,7 @@ func (udq *UserDepartmentQuery) sqlAll(ctx context.Context, hooks ...queryHook) return nodes, nil } -func (udq *UserDepartmentQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserDepartment, init func(*UserDepartment), assign func(*UserDepartment, *User)) error { +func (_q *UserDepartmentQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserDepartment, init func(*UserDepartment), assign func(*UserDepartment, *User)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*UserDepartment) for i := range nodes { @@ -479,7 +479,7 @@ func (udq *UserDepartmentQuery) loadUser(ctx context.Context, query *UserQuery, } return nil } -func (udq *UserDepartmentQuery) loadDepartment(ctx context.Context, query *DepartmentQuery, nodes []*UserDepartment, init func(*UserDepartment), assign func(*UserDepartment, *Department)) error { +func (_q *UserDepartmentQuery) loadDepartment(ctx context.Context, query *DepartmentQuery, nodes []*UserDepartment, init func(*UserDepartment), assign func(*UserDepartment, *Department)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*UserDepartment) for i := range nodes { @@ -509,27 +509,27 @@ func (udq *UserDepartmentQuery) loadDepartment(ctx context.Context, query *Depar return nil } -func (udq *UserDepartmentQuery) sqlCount(ctx context.Context) (int, error) { - _spec := udq.querySpec() - if len(udq.modifiers) > 0 { - _spec.Modifiers = udq.modifiers +func (_q *UserDepartmentQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = udq.ctx.Fields - if len(udq.ctx.Fields) > 0 { - _spec.Unique = udq.ctx.Unique != nil && *udq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, udq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (udq *UserDepartmentQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *UserDepartmentQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(userdepartment.Table, userdepartment.Columns, sqlgraph.NewFieldSpec(userdepartment.FieldID, field.TypeInt)) - _spec.From = udq.sql - if unique := udq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if udq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := udq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, userdepartment.FieldID) for i := range fields { @@ -537,27 +537,27 @@ func (udq *UserDepartmentQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if udq.withUser != nil { + if _q.withUser != nil { _spec.Node.AddColumnOnce(userdepartment.FieldUserID) } - if udq.withDepartment != nil { + if _q.withDepartment != nil { _spec.Node.AddColumnOnce(userdepartment.FieldDepartmentID) } } - if ps := udq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := udq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := udq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := udq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -567,36 +567,36 @@ func (udq *UserDepartmentQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (udq *UserDepartmentQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(udq.driver.Dialect()) +func (_q *UserDepartmentQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(userdepartment.Table) - columns := udq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = userdepartment.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if udq.sql != nil { - selector = udq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if udq.ctx.Unique != nil && *udq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range udq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range udq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range udq.order { + for _, p := range _q.order { p(selector) } - if offset := udq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := udq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -605,33 +605,33 @@ func (udq *UserDepartmentQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (udq *UserDepartmentQuery) ForUpdate(opts ...sql.LockOption) *UserDepartmentQuery { - if udq.driver.Dialect() == dialect.Postgres { - udq.Unique(false) +func (_q *UserDepartmentQuery) ForUpdate(opts ...sql.LockOption) *UserDepartmentQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - udq.modifiers = append(udq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return udq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (udq *UserDepartmentQuery) ForShare(opts ...sql.LockOption) *UserDepartmentQuery { - if udq.driver.Dialect() == dialect.Postgres { - udq.Unique(false) +func (_q *UserDepartmentQuery) ForShare(opts ...sql.LockOption) *UserDepartmentQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - udq.modifiers = append(udq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return udq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (udq *UserDepartmentQuery) Modify(modifiers ...func(s *sql.Selector)) *UserDepartmentSelect { - udq.modifiers = append(udq.modifiers, modifiers...) - return udq.Select() +func (_q *UserDepartmentQuery) Modify(modifiers ...func(s *sql.Selector)) *UserDepartmentSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -673,41 +673,41 @@ type UserDepartmentGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (udgb *UserDepartmentGroupBy) Aggregate(fns ...AggregateFunc) *UserDepartmentGroupBy { - udgb.fns = append(udgb.fns, fns...) - return udgb +func (_g *UserDepartmentGroupBy) Aggregate(fns ...AggregateFunc) *UserDepartmentGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (udgb *UserDepartmentGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, udgb.build.ctx, ent.OpQueryGroupBy) - if err := udgb.build.prepareQuery(ctx); err != nil { +func (_g *UserDepartmentGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*UserDepartmentQuery, *UserDepartmentGroupBy](ctx, udgb.build, udgb, udgb.build.inters, v) + return scanWithInterceptors[*UserDepartmentQuery, *UserDepartmentGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (udgb *UserDepartmentGroupBy) sqlScan(ctx context.Context, root *UserDepartmentQuery, v any) error { +func (_g *UserDepartmentGroupBy) sqlScan(ctx context.Context, root *UserDepartmentQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(udgb.fns)) - for _, fn := range udgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*udgb.flds)+len(udgb.fns)) - for _, f := range *udgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*udgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := udgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -721,27 +721,27 @@ type UserDepartmentSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (uds *UserDepartmentSelect) Aggregate(fns ...AggregateFunc) *UserDepartmentSelect { - uds.fns = append(uds.fns, fns...) - return uds +func (_s *UserDepartmentSelect) Aggregate(fns ...AggregateFunc) *UserDepartmentSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (uds *UserDepartmentSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, uds.ctx, ent.OpQuerySelect) - if err := uds.prepareQuery(ctx); err != nil { +func (_s *UserDepartmentSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*UserDepartmentQuery, *UserDepartmentSelect](ctx, uds.UserDepartmentQuery, uds, uds.inters, v) + return scanWithInterceptors[*UserDepartmentQuery, *UserDepartmentSelect](ctx, _s.UserDepartmentQuery, _s, _s.inters, v) } -func (uds *UserDepartmentSelect) sqlScan(ctx context.Context, root *UserDepartmentQuery, v any) error { +func (_s *UserDepartmentSelect) sqlScan(ctx context.Context, root *UserDepartmentQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(uds.fns)) - for _, fn := range uds.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*uds.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -749,7 +749,7 @@ func (uds *UserDepartmentSelect) sqlScan(ctx context.Context, root *UserDepartme } rows := &sql.Rows{} query, args := selector.Query() - if err := uds.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -757,7 +757,7 @@ func (uds *UserDepartmentSelect) sqlScan(ctx context.Context, root *UserDepartme } // Modify adds a query modifier for attaching custom logic to queries. -func (uds *UserDepartmentSelect) Modify(modifiers ...func(s *sql.Selector)) *UserDepartmentSelect { - uds.modifiers = append(uds.modifiers, modifiers...) - return uds +func (_s *UserDepartmentSelect) Modify(modifiers ...func(s *sql.Selector)) *UserDepartmentSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/userdepartment_update.go b/internal/data/entity/ent/userdepartment_update.go index e3ad697d..aba0bbcd 100644 --- a/internal/data/entity/ent/userdepartment_update.go +++ b/internal/data/entity/ent/userdepartment_update.go @@ -25,74 +25,74 @@ type UserDepartmentUpdate struct { } // Where appends a list predicates to the UserDepartmentUpdate builder. -func (udu *UserDepartmentUpdate) Where(ps ...predicate.UserDepartment) *UserDepartmentUpdate { - udu.mutation.Where(ps...) - return udu +func (_u *UserDepartmentUpdate) Where(ps ...predicate.UserDepartment) *UserDepartmentUpdate { + _u.mutation.Where(ps...) + return _u } // SetUserID sets the "user_id" field. -func (udu *UserDepartmentUpdate) SetUserID(i int64) *UserDepartmentUpdate { - udu.mutation.SetUserID(i) - return udu +func (_u *UserDepartmentUpdate) SetUserID(v int64) *UserDepartmentUpdate { + _u.mutation.SetUserID(v) + return _u } // SetNillableUserID sets the "user_id" field if the given value is not nil. -func (udu *UserDepartmentUpdate) SetNillableUserID(i *int64) *UserDepartmentUpdate { - if i != nil { - udu.SetUserID(*i) +func (_u *UserDepartmentUpdate) SetNillableUserID(v *int64) *UserDepartmentUpdate { + if v != nil { + _u.SetUserID(*v) } - return udu + return _u } // SetDepartmentID sets the "department_id" field. -func (udu *UserDepartmentUpdate) SetDepartmentID(i int64) *UserDepartmentUpdate { - udu.mutation.SetDepartmentID(i) - return udu +func (_u *UserDepartmentUpdate) SetDepartmentID(v int64) *UserDepartmentUpdate { + _u.mutation.SetDepartmentID(v) + return _u } // SetNillableDepartmentID sets the "department_id" field if the given value is not nil. -func (udu *UserDepartmentUpdate) SetNillableDepartmentID(i *int64) *UserDepartmentUpdate { - if i != nil { - udu.SetDepartmentID(*i) +func (_u *UserDepartmentUpdate) SetNillableDepartmentID(v *int64) *UserDepartmentUpdate { + if v != nil { + _u.SetDepartmentID(*v) } - return udu + return _u } // SetUser sets the "user" edge to the User entity. -func (udu *UserDepartmentUpdate) SetUser(u *User) *UserDepartmentUpdate { - return udu.SetUserID(u.ID) +func (_u *UserDepartmentUpdate) SetUser(v *User) *UserDepartmentUpdate { + return _u.SetUserID(v.ID) } // SetDepartment sets the "department" edge to the Department entity. -func (udu *UserDepartmentUpdate) SetDepartment(d *Department) *UserDepartmentUpdate { - return udu.SetDepartmentID(d.ID) +func (_u *UserDepartmentUpdate) SetDepartment(v *Department) *UserDepartmentUpdate { + return _u.SetDepartmentID(v.ID) } // Mutation returns the UserDepartmentMutation object of the builder. -func (udu *UserDepartmentUpdate) Mutation() *UserDepartmentMutation { - return udu.mutation +func (_u *UserDepartmentUpdate) Mutation() *UserDepartmentMutation { + return _u.mutation } // ClearUser clears the "user" edge to the User entity. -func (udu *UserDepartmentUpdate) ClearUser() *UserDepartmentUpdate { - udu.mutation.ClearUser() - return udu +func (_u *UserDepartmentUpdate) ClearUser() *UserDepartmentUpdate { + _u.mutation.ClearUser() + return _u } // ClearDepartment clears the "department" edge to the Department entity. -func (udu *UserDepartmentUpdate) ClearDepartment() *UserDepartmentUpdate { - udu.mutation.ClearDepartment() - return udu +func (_u *UserDepartmentUpdate) ClearDepartment() *UserDepartmentUpdate { + _u.mutation.ClearDepartment() + return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (udu *UserDepartmentUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, udu.sqlSave, udu.mutation, udu.hooks) +func (_u *UserDepartmentUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (udu *UserDepartmentUpdate) SaveX(ctx context.Context) int { - affected, err := udu.Save(ctx) +func (_u *UserDepartmentUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -100,58 +100,58 @@ func (udu *UserDepartmentUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (udu *UserDepartmentUpdate) Exec(ctx context.Context) error { - _, err := udu.Save(ctx) +func (_u *UserDepartmentUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (udu *UserDepartmentUpdate) ExecX(ctx context.Context) { - if err := udu.Exec(ctx); err != nil { +func (_u *UserDepartmentUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (udu *UserDepartmentUpdate) check() error { - if v, ok := udu.mutation.UserID(); ok { +func (_u *UserDepartmentUpdate) check() error { + if v, ok := _u.mutation.UserID(); ok { if err := userdepartment.UserIDValidator(v); err != nil { return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserDepartment.user_id": %w`, err)} } } - if v, ok := udu.mutation.DepartmentID(); ok { + if v, ok := _u.mutation.DepartmentID(); ok { if err := userdepartment.DepartmentIDValidator(v); err != nil { return &ValidationError{Name: "department_id", err: fmt.Errorf(`ent: validator failed for field "UserDepartment.department_id": %w`, err)} } } - if udu.mutation.UserCleared() && len(udu.mutation.UserIDs()) > 0 { + if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserDepartment.user"`) } - if udu.mutation.DepartmentCleared() && len(udu.mutation.DepartmentIDs()) > 0 { + if _u.mutation.DepartmentCleared() && len(_u.mutation.DepartmentIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserDepartment.department"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (udu *UserDepartmentUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserDepartmentUpdate { - udu.modifiers = append(udu.modifiers, modifiers...) - return udu +func (_u *UserDepartmentUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserDepartmentUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (udu *UserDepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := udu.check(); err != nil { - return n, err +func (_u *UserDepartmentUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(userdepartment.Table, userdepartment.Columns, sqlgraph.NewFieldSpec(userdepartment.FieldID, field.TypeInt)) - if ps := udu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if udu.mutation.UserCleared() { + if _u.mutation.UserCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -164,7 +164,7 @@ func (udu *UserDepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := udu.mutation.UserIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -180,7 +180,7 @@ func (udu *UserDepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if udu.mutation.DepartmentCleared() { + if _u.mutation.DepartmentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -193,7 +193,7 @@ func (udu *UserDepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := udu.mutation.DepartmentIDs(); len(nodes) > 0 { + if nodes := _u.mutation.DepartmentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -209,8 +209,8 @@ func (udu *UserDepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(udu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, udu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{userdepartment.Label} } else if sqlgraph.IsConstraintError(err) { @@ -218,8 +218,8 @@ func (udu *UserDepartmentUpdate) sqlSave(ctx context.Context) (n int, err error) } return 0, err } - udu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // UserDepartmentUpdateOne is the builder for updating a single UserDepartment entity. @@ -232,81 +232,81 @@ type UserDepartmentUpdateOne struct { } // SetUserID sets the "user_id" field. -func (uduo *UserDepartmentUpdateOne) SetUserID(i int64) *UserDepartmentUpdateOne { - uduo.mutation.SetUserID(i) - return uduo +func (_u *UserDepartmentUpdateOne) SetUserID(v int64) *UserDepartmentUpdateOne { + _u.mutation.SetUserID(v) + return _u } // SetNillableUserID sets the "user_id" field if the given value is not nil. -func (uduo *UserDepartmentUpdateOne) SetNillableUserID(i *int64) *UserDepartmentUpdateOne { - if i != nil { - uduo.SetUserID(*i) +func (_u *UserDepartmentUpdateOne) SetNillableUserID(v *int64) *UserDepartmentUpdateOne { + if v != nil { + _u.SetUserID(*v) } - return uduo + return _u } // SetDepartmentID sets the "department_id" field. -func (uduo *UserDepartmentUpdateOne) SetDepartmentID(i int64) *UserDepartmentUpdateOne { - uduo.mutation.SetDepartmentID(i) - return uduo +func (_u *UserDepartmentUpdateOne) SetDepartmentID(v int64) *UserDepartmentUpdateOne { + _u.mutation.SetDepartmentID(v) + return _u } // SetNillableDepartmentID sets the "department_id" field if the given value is not nil. -func (uduo *UserDepartmentUpdateOne) SetNillableDepartmentID(i *int64) *UserDepartmentUpdateOne { - if i != nil { - uduo.SetDepartmentID(*i) +func (_u *UserDepartmentUpdateOne) SetNillableDepartmentID(v *int64) *UserDepartmentUpdateOne { + if v != nil { + _u.SetDepartmentID(*v) } - return uduo + return _u } // SetUser sets the "user" edge to the User entity. -func (uduo *UserDepartmentUpdateOne) SetUser(u *User) *UserDepartmentUpdateOne { - return uduo.SetUserID(u.ID) +func (_u *UserDepartmentUpdateOne) SetUser(v *User) *UserDepartmentUpdateOne { + return _u.SetUserID(v.ID) } // SetDepartment sets the "department" edge to the Department entity. -func (uduo *UserDepartmentUpdateOne) SetDepartment(d *Department) *UserDepartmentUpdateOne { - return uduo.SetDepartmentID(d.ID) +func (_u *UserDepartmentUpdateOne) SetDepartment(v *Department) *UserDepartmentUpdateOne { + return _u.SetDepartmentID(v.ID) } // Mutation returns the UserDepartmentMutation object of the builder. -func (uduo *UserDepartmentUpdateOne) Mutation() *UserDepartmentMutation { - return uduo.mutation +func (_u *UserDepartmentUpdateOne) Mutation() *UserDepartmentMutation { + return _u.mutation } // ClearUser clears the "user" edge to the User entity. -func (uduo *UserDepartmentUpdateOne) ClearUser() *UserDepartmentUpdateOne { - uduo.mutation.ClearUser() - return uduo +func (_u *UserDepartmentUpdateOne) ClearUser() *UserDepartmentUpdateOne { + _u.mutation.ClearUser() + return _u } // ClearDepartment clears the "department" edge to the Department entity. -func (uduo *UserDepartmentUpdateOne) ClearDepartment() *UserDepartmentUpdateOne { - uduo.mutation.ClearDepartment() - return uduo +func (_u *UserDepartmentUpdateOne) ClearDepartment() *UserDepartmentUpdateOne { + _u.mutation.ClearDepartment() + return _u } // Where appends a list predicates to the UserDepartmentUpdate builder. -func (uduo *UserDepartmentUpdateOne) Where(ps ...predicate.UserDepartment) *UserDepartmentUpdateOne { - uduo.mutation.Where(ps...) - return uduo +func (_u *UserDepartmentUpdateOne) Where(ps ...predicate.UserDepartment) *UserDepartmentUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (uduo *UserDepartmentUpdateOne) Select(field string, fields ...string) *UserDepartmentUpdateOne { - uduo.fields = append([]string{field}, fields...) - return uduo +func (_u *UserDepartmentUpdateOne) Select(field string, fields ...string) *UserDepartmentUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated UserDepartment entity. -func (uduo *UserDepartmentUpdateOne) Save(ctx context.Context) (*UserDepartment, error) { - return withHooks(ctx, uduo.sqlSave, uduo.mutation, uduo.hooks) +func (_u *UserDepartmentUpdateOne) Save(ctx context.Context) (*UserDepartment, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (uduo *UserDepartmentUpdateOne) SaveX(ctx context.Context) *UserDepartment { - node, err := uduo.Save(ctx) +func (_u *UserDepartmentUpdateOne) SaveX(ctx context.Context) *UserDepartment { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -314,56 +314,56 @@ func (uduo *UserDepartmentUpdateOne) SaveX(ctx context.Context) *UserDepartment } // Exec executes the query on the entity. -func (uduo *UserDepartmentUpdateOne) Exec(ctx context.Context) error { - _, err := uduo.Save(ctx) +func (_u *UserDepartmentUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (uduo *UserDepartmentUpdateOne) ExecX(ctx context.Context) { - if err := uduo.Exec(ctx); err != nil { +func (_u *UserDepartmentUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (uduo *UserDepartmentUpdateOne) check() error { - if v, ok := uduo.mutation.UserID(); ok { +func (_u *UserDepartmentUpdateOne) check() error { + if v, ok := _u.mutation.UserID(); ok { if err := userdepartment.UserIDValidator(v); err != nil { return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserDepartment.user_id": %w`, err)} } } - if v, ok := uduo.mutation.DepartmentID(); ok { + if v, ok := _u.mutation.DepartmentID(); ok { if err := userdepartment.DepartmentIDValidator(v); err != nil { return &ValidationError{Name: "department_id", err: fmt.Errorf(`ent: validator failed for field "UserDepartment.department_id": %w`, err)} } } - if uduo.mutation.UserCleared() && len(uduo.mutation.UserIDs()) > 0 { + if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserDepartment.user"`) } - if uduo.mutation.DepartmentCleared() && len(uduo.mutation.DepartmentIDs()) > 0 { + if _u.mutation.DepartmentCleared() && len(_u.mutation.DepartmentIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserDepartment.department"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (uduo *UserDepartmentUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserDepartmentUpdateOne { - uduo.modifiers = append(uduo.modifiers, modifiers...) - return uduo +func (_u *UserDepartmentUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserDepartmentUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (uduo *UserDepartmentUpdateOne) sqlSave(ctx context.Context) (_node *UserDepartment, err error) { - if err := uduo.check(); err != nil { +func (_u *UserDepartmentUpdateOne) sqlSave(ctx context.Context) (_node *UserDepartment, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(userdepartment.Table, userdepartment.Columns, sqlgraph.NewFieldSpec(userdepartment.FieldID, field.TypeInt)) - id, ok := uduo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserDepartment.id" for update`)} } _spec.Node.ID.Value = id - if fields := uduo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, userdepartment.FieldID) for _, f := range fields { @@ -375,14 +375,14 @@ func (uduo *UserDepartmentUpdateOne) sqlSave(ctx context.Context) (_node *UserDe } } } - if ps := uduo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if uduo.mutation.UserCleared() { + if _u.mutation.UserCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -395,7 +395,7 @@ func (uduo *UserDepartmentUpdateOne) sqlSave(ctx context.Context) (_node *UserDe } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uduo.mutation.UserIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -411,7 +411,7 @@ func (uduo *UserDepartmentUpdateOne) sqlSave(ctx context.Context) (_node *UserDe } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uduo.mutation.DepartmentCleared() { + if _u.mutation.DepartmentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -424,7 +424,7 @@ func (uduo *UserDepartmentUpdateOne) sqlSave(ctx context.Context) (_node *UserDe } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uduo.mutation.DepartmentIDs(); len(nodes) > 0 { + if nodes := _u.mutation.DepartmentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -440,11 +440,11 @@ func (uduo *UserDepartmentUpdateOne) sqlSave(ctx context.Context) (_node *UserDe } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(uduo.modifiers...) - _node = &UserDepartment{config: uduo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &UserDepartment{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, uduo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{userdepartment.Label} } else if sqlgraph.IsConstraintError(err) { @@ -452,7 +452,7 @@ func (uduo *UserDepartmentUpdateOne) sqlSave(ctx context.Context) (_node *UserDe } return nil, err } - uduo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/userposition.go b/internal/data/entity/ent/userposition.go index 9e75d513..0b2c014a 100644 --- a/internal/data/entity/ent/userposition.go +++ b/internal/data/entity/ent/userposition.go @@ -77,7 +77,7 @@ func (*UserPosition) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the UserPosition fields. -func (up *UserPosition) assignValues(columns []string, values []any) error { +func (_m *UserPosition) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -88,21 +88,21 @@ func (up *UserPosition) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - up.ID = int(value.Int64) + _m.ID = int(value.Int64) case userposition.FieldUserID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field user_id", values[i]) } else if value.Valid { - up.UserID = value.Int64 + _m.UserID = value.Int64 } case userposition.FieldPositionID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field position_id", values[i]) } else if value.Valid { - up.PositionID = value.Int64 + _m.PositionID = value.Int64 } default: - up.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -110,48 +110,48 @@ func (up *UserPosition) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the UserPosition. // This includes values selected through modifiers, order, etc. -func (up *UserPosition) Value(name string) (ent.Value, error) { - return up.selectValues.Get(name) +func (_m *UserPosition) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryUser queries the "user" edge of the UserPosition entity. -func (up *UserPosition) QueryUser() *UserQuery { - return NewUserPositionClient(up.config).QueryUser(up) +func (_m *UserPosition) QueryUser() *UserQuery { + return NewUserPositionClient(_m.config).QueryUser(_m) } // QueryPosition queries the "position" edge of the UserPosition entity. -func (up *UserPosition) QueryPosition() *PositionQuery { - return NewUserPositionClient(up.config).QueryPosition(up) +func (_m *UserPosition) QueryPosition() *PositionQuery { + return NewUserPositionClient(_m.config).QueryPosition(_m) } // Update returns a builder for updating this UserPosition. // Note that you need to call UserPosition.Unwrap() before calling this method if this UserPosition // was returned from a transaction, and the transaction was committed or rolled back. -func (up *UserPosition) Update() *UserPositionUpdateOne { - return NewUserPositionClient(up.config).UpdateOne(up) +func (_m *UserPosition) Update() *UserPositionUpdateOne { + return NewUserPositionClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the UserPosition entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (up *UserPosition) Unwrap() *UserPosition { - _tx, ok := up.config.driver.(*txDriver) +func (_m *UserPosition) Unwrap() *UserPosition { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: UserPosition is not a transactional entity") } - up.config.driver = _tx.drv - return up + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (up *UserPosition) String() string { +func (_m *UserPosition) String() string { var builder strings.Builder builder.WriteString("UserPosition(") - builder.WriteString(fmt.Sprintf("id=%v, ", up.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("user_id=") - builder.WriteString(fmt.Sprintf("%v", up.UserID)) + builder.WriteString(fmt.Sprintf("%v", _m.UserID)) builder.WriteString(", ") builder.WriteString("position_id=") - builder.WriteString(fmt.Sprintf("%v", up.PositionID)) + builder.WriteString(fmt.Sprintf("%v", _m.PositionID)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/userposition_create.go b/internal/data/entity/ent/userposition_create.go index bf6ffd23..8649f0aa 100644 --- a/internal/data/entity/ent/userposition_create.go +++ b/internal/data/entity/ent/userposition_create.go @@ -22,40 +22,40 @@ type UserPositionCreate struct { } // SetUserID sets the "user_id" field. -func (upc *UserPositionCreate) SetUserID(i int64) *UserPositionCreate { - upc.mutation.SetUserID(i) - return upc +func (_c *UserPositionCreate) SetUserID(v int64) *UserPositionCreate { + _c.mutation.SetUserID(v) + return _c } // SetPositionID sets the "position_id" field. -func (upc *UserPositionCreate) SetPositionID(i int64) *UserPositionCreate { - upc.mutation.SetPositionID(i) - return upc +func (_c *UserPositionCreate) SetPositionID(v int64) *UserPositionCreate { + _c.mutation.SetPositionID(v) + return _c } // SetUser sets the "user" edge to the User entity. -func (upc *UserPositionCreate) SetUser(u *User) *UserPositionCreate { - return upc.SetUserID(u.ID) +func (_c *UserPositionCreate) SetUser(v *User) *UserPositionCreate { + return _c.SetUserID(v.ID) } // SetPosition sets the "position" edge to the Position entity. -func (upc *UserPositionCreate) SetPosition(p *Position) *UserPositionCreate { - return upc.SetPositionID(p.ID) +func (_c *UserPositionCreate) SetPosition(v *Position) *UserPositionCreate { + return _c.SetPositionID(v.ID) } // Mutation returns the UserPositionMutation object of the builder. -func (upc *UserPositionCreate) Mutation() *UserPositionMutation { - return upc.mutation +func (_c *UserPositionCreate) Mutation() *UserPositionMutation { + return _c.mutation } // Save creates the UserPosition in the database. -func (upc *UserPositionCreate) Save(ctx context.Context) (*UserPosition, error) { - return withHooks(ctx, upc.sqlSave, upc.mutation, upc.hooks) +func (_c *UserPositionCreate) Save(ctx context.Context) (*UserPosition, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (upc *UserPositionCreate) SaveX(ctx context.Context) *UserPosition { - v, err := upc.Save(ctx) +func (_c *UserPositionCreate) SaveX(ctx context.Context) *UserPosition { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -63,51 +63,51 @@ func (upc *UserPositionCreate) SaveX(ctx context.Context) *UserPosition { } // Exec executes the query. -func (upc *UserPositionCreate) Exec(ctx context.Context) error { - _, err := upc.Save(ctx) +func (_c *UserPositionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (upc *UserPositionCreate) ExecX(ctx context.Context) { - if err := upc.Exec(ctx); err != nil { +func (_c *UserPositionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (upc *UserPositionCreate) check() error { - if _, ok := upc.mutation.UserID(); !ok { +func (_c *UserPositionCreate) check() error { + if _, ok := _c.mutation.UserID(); !ok { return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserPosition.user_id"`)} } - if v, ok := upc.mutation.UserID(); ok { + if v, ok := _c.mutation.UserID(); ok { if err := userposition.UserIDValidator(v); err != nil { return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserPosition.user_id": %w`, err)} } } - if _, ok := upc.mutation.PositionID(); !ok { + if _, ok := _c.mutation.PositionID(); !ok { return &ValidationError{Name: "position_id", err: errors.New(`ent: missing required field "UserPosition.position_id"`)} } - if v, ok := upc.mutation.PositionID(); ok { + if v, ok := _c.mutation.PositionID(); ok { if err := userposition.PositionIDValidator(v); err != nil { return &ValidationError{Name: "position_id", err: fmt.Errorf(`ent: validator failed for field "UserPosition.position_id": %w`, err)} } } - if len(upc.mutation.UserIDs()) == 0 { + if len(_c.mutation.UserIDs()) == 0 { return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserPosition.user"`)} } - if len(upc.mutation.PositionIDs()) == 0 { + if len(_c.mutation.PositionIDs()) == 0 { return &ValidationError{Name: "position", err: errors.New(`ent: missing required edge "UserPosition.position"`)} } return nil } -func (upc *UserPositionCreate) sqlSave(ctx context.Context) (*UserPosition, error) { - if err := upc.check(); err != nil { +func (_c *UserPositionCreate) sqlSave(ctx context.Context) (*UserPosition, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := upc.createSpec() - if err := sqlgraph.CreateNode(ctx, upc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -115,17 +115,17 @@ func (upc *UserPositionCreate) sqlSave(ctx context.Context) (*UserPosition, erro } id := _spec.ID.Value.(int64) _node.ID = int(id) - upc.mutation.id = &_node.ID - upc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (upc *UserPositionCreate) createSpec() (*UserPosition, *sqlgraph.CreateSpec) { +func (_c *UserPositionCreate) createSpec() (*UserPosition, *sqlgraph.CreateSpec) { var ( - _node = &UserPosition{config: upc.config} + _node = &UserPosition{config: _c.config} _spec = sqlgraph.NewCreateSpec(userposition.Table, sqlgraph.NewFieldSpec(userposition.FieldID, field.TypeInt)) ) - if nodes := upc.mutation.UserIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -142,7 +142,7 @@ func (upc *UserPositionCreate) createSpec() (*UserPosition, *sqlgraph.CreateSpec _node.UserID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := upc.mutation.PositionIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PositionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -163,23 +163,23 @@ func (upc *UserPositionCreate) createSpec() (*UserPosition, *sqlgraph.CreateSpec } // SetUserPosition set the UserPosition -func (upc *UserPositionCreate) SetUserPosition(input *UserPosition, fields ...string) *UserPositionCreate { - m := upc.mutation +func (_c *UserPositionCreate) SetUserPosition(input *UserPosition, fields ...string) *UserPositionCreate { + m := _c.mutation if len(fields) == 0 { fields = userposition.Columns } _ = m.SetFields(input, fields...) - return upc + return _c } // SetUserPositionWithZero set the UserPosition -func (upc *UserPositionCreate) SetUserPositionWithZero(input *UserPosition, fields ...string) *UserPositionCreate { - m := upc.mutation +func (_c *UserPositionCreate) SetUserPositionWithZero(input *UserPosition, fields ...string) *UserPositionCreate { + m := _c.mutation if len(fields) == 0 { fields = userposition.Columns } _ = m.SetFieldsWithZero(input, fields...) - return upc + return _c } // UserPositionCreateBulk is the builder for creating many UserPosition entities in bulk. @@ -190,16 +190,16 @@ type UserPositionCreateBulk struct { } // Save creates the UserPosition entities in the database. -func (upcb *UserPositionCreateBulk) Save(ctx context.Context) ([]*UserPosition, error) { - if upcb.err != nil { - return nil, upcb.err +func (_c *UserPositionCreateBulk) Save(ctx context.Context) ([]*UserPosition, error) { + if _c.err != nil { + return nil, _c.err } - specs := make([]*sqlgraph.CreateSpec, len(upcb.builders)) - nodes := make([]*UserPosition, len(upcb.builders)) - mutators := make([]Mutator, len(upcb.builders)) - for i := range upcb.builders { + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*UserPosition, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := upcb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*UserPositionMutation) if !ok { @@ -212,11 +212,11 @@ func (upcb *UserPositionCreateBulk) Save(ctx context.Context) ([]*UserPosition, var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, upcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, upcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -240,7 +240,7 @@ func (upcb *UserPositionCreateBulk) Save(ctx context.Context) ([]*UserPosition, }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, upcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -248,8 +248,8 @@ func (upcb *UserPositionCreateBulk) Save(ctx context.Context) ([]*UserPosition, } // SaveX is like Save, but panics if an error occurs. -func (upcb *UserPositionCreateBulk) SaveX(ctx context.Context) []*UserPosition { - v, err := upcb.Save(ctx) +func (_c *UserPositionCreateBulk) SaveX(ctx context.Context) []*UserPosition { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -257,14 +257,14 @@ func (upcb *UserPositionCreateBulk) SaveX(ctx context.Context) []*UserPosition { } // Exec executes the query. -func (upcb *UserPositionCreateBulk) Exec(ctx context.Context) error { - _, err := upcb.Save(ctx) +func (_c *UserPositionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (upcb *UserPositionCreateBulk) ExecX(ctx context.Context) { - if err := upcb.Exec(ctx); err != nil { +func (_c *UserPositionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/userposition_delete.go b/internal/data/entity/ent/userposition_delete.go index 96c9db6c..f88024f9 100644 --- a/internal/data/entity/ent/userposition_delete.go +++ b/internal/data/entity/ent/userposition_delete.go @@ -20,56 +20,56 @@ type UserPositionDelete struct { } // Where appends a list predicates to the UserPositionDelete builder. -func (upd *UserPositionDelete) Where(ps ...predicate.UserPosition) *UserPositionDelete { - upd.mutation.Where(ps...) - return upd +func (_d *UserPositionDelete) Where(ps ...predicate.UserPosition) *UserPositionDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (upd *UserPositionDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, upd.sqlExec, upd.mutation, upd.hooks) +func (_d *UserPositionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (upd *UserPositionDelete) ExecX(ctx context.Context) int { - n, err := upd.Exec(ctx) +func (_d *UserPositionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (upd *UserPositionDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *UserPositionDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(userposition.Table, sqlgraph.NewFieldSpec(userposition.FieldID, field.TypeInt)) - if ps := upd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, upd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - upd.mutation.done = true + _d.mutation.done = true return affected, err } // UserPositionDeleteOne is the builder for deleting a single UserPosition entity. type UserPositionDeleteOne struct { - upd *UserPositionDelete + _d *UserPositionDelete } // Where appends a list predicates to the UserPositionDelete builder. -func (updo *UserPositionDeleteOne) Where(ps ...predicate.UserPosition) *UserPositionDeleteOne { - updo.upd.mutation.Where(ps...) - return updo +func (_d *UserPositionDeleteOne) Where(ps ...predicate.UserPosition) *UserPositionDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (updo *UserPositionDeleteOne) Exec(ctx context.Context) error { - n, err := updo.upd.Exec(ctx) +func (_d *UserPositionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (updo *UserPositionDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (updo *UserPositionDeleteOne) ExecX(ctx context.Context) { - if err := updo.Exec(ctx); err != nil { +func (_d *UserPositionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/userposition_query.go b/internal/data/entity/ent/userposition_query.go index 70b5484a..37de4035 100644 --- a/internal/data/entity/ent/userposition_query.go +++ b/internal/data/entity/ent/userposition_query.go @@ -34,44 +34,44 @@ type UserPositionQuery struct { } // Where adds a new predicate for the UserPositionQuery builder. -func (upq *UserPositionQuery) Where(ps ...predicate.UserPosition) *UserPositionQuery { - upq.predicates = append(upq.predicates, ps...) - return upq +func (_q *UserPositionQuery) Where(ps ...predicate.UserPosition) *UserPositionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (upq *UserPositionQuery) Limit(limit int) *UserPositionQuery { - upq.ctx.Limit = &limit - return upq +func (_q *UserPositionQuery) Limit(limit int) *UserPositionQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (upq *UserPositionQuery) Offset(offset int) *UserPositionQuery { - upq.ctx.Offset = &offset - return upq +func (_q *UserPositionQuery) Offset(offset int) *UserPositionQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (upq *UserPositionQuery) Unique(unique bool) *UserPositionQuery { - upq.ctx.Unique = &unique - return upq +func (_q *UserPositionQuery) Unique(unique bool) *UserPositionQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (upq *UserPositionQuery) Order(o ...userposition.OrderOption) *UserPositionQuery { - upq.order = append(upq.order, o...) - return upq +func (_q *UserPositionQuery) Order(o ...userposition.OrderOption) *UserPositionQuery { + _q.order = append(_q.order, o...) + return _q } // QueryUser chains the current query on the "user" edge. -func (upq *UserPositionQuery) QueryUser() *UserQuery { - query := (&UserClient{config: upq.config}).Query() +func (_q *UserPositionQuery) QueryUser() *UserQuery { + query := (&UserClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := upq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := upq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -80,20 +80,20 @@ func (upq *UserPositionQuery) QueryUser() *UserQuery { sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userposition.UserTable, userposition.UserColumn), ) - fromU = sqlgraph.SetNeighbors(upq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPosition chains the current query on the "position" edge. -func (upq *UserPositionQuery) QueryPosition() *PositionQuery { - query := (&PositionClient{config: upq.config}).Query() +func (_q *UserPositionQuery) QueryPosition() *PositionQuery { + query := (&PositionClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := upq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := upq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -102,7 +102,7 @@ func (upq *UserPositionQuery) QueryPosition() *PositionQuery { sqlgraph.To(position.Table, position.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userposition.PositionTable, userposition.PositionColumn), ) - fromU = sqlgraph.SetNeighbors(upq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -110,8 +110,8 @@ func (upq *UserPositionQuery) QueryPosition() *PositionQuery { // First returns the first UserPosition entity from the query. // Returns a *NotFoundError when no UserPosition was found. -func (upq *UserPositionQuery) First(ctx context.Context) (*UserPosition, error) { - nodes, err := upq.Limit(1).All(setContextOp(ctx, upq.ctx, ent.OpQueryFirst)) +func (_q *UserPositionQuery) First(ctx context.Context) (*UserPosition, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -122,8 +122,8 @@ func (upq *UserPositionQuery) First(ctx context.Context) (*UserPosition, error) } // FirstX is like First, but panics if an error occurs. -func (upq *UserPositionQuery) FirstX(ctx context.Context) *UserPosition { - node, err := upq.First(ctx) +func (_q *UserPositionQuery) FirstX(ctx context.Context) *UserPosition { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -132,9 +132,9 @@ func (upq *UserPositionQuery) FirstX(ctx context.Context) *UserPosition { // FirstID returns the first UserPosition ID from the query. // Returns a *NotFoundError when no UserPosition ID was found. -func (upq *UserPositionQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *UserPositionQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = upq.Limit(1).IDs(setContextOp(ctx, upq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -145,8 +145,8 @@ func (upq *UserPositionQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (upq *UserPositionQuery) FirstIDX(ctx context.Context) int { - id, err := upq.FirstID(ctx) +func (_q *UserPositionQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -156,8 +156,8 @@ func (upq *UserPositionQuery) FirstIDX(ctx context.Context) int { // Only returns a single UserPosition entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one UserPosition entity is found. // Returns a *NotFoundError when no UserPosition entities are found. -func (upq *UserPositionQuery) Only(ctx context.Context) (*UserPosition, error) { - nodes, err := upq.Limit(2).All(setContextOp(ctx, upq.ctx, ent.OpQueryOnly)) +func (_q *UserPositionQuery) Only(ctx context.Context) (*UserPosition, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -172,8 +172,8 @@ func (upq *UserPositionQuery) Only(ctx context.Context) (*UserPosition, error) { } // OnlyX is like Only, but panics if an error occurs. -func (upq *UserPositionQuery) OnlyX(ctx context.Context) *UserPosition { - node, err := upq.Only(ctx) +func (_q *UserPositionQuery) OnlyX(ctx context.Context) *UserPosition { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -183,9 +183,9 @@ func (upq *UserPositionQuery) OnlyX(ctx context.Context) *UserPosition { // OnlyID is like Only, but returns the only UserPosition ID in the query. // Returns a *NotSingularError when more than one UserPosition ID is found. // Returns a *NotFoundError when no entities are found. -func (upq *UserPositionQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *UserPositionQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = upq.Limit(2).IDs(setContextOp(ctx, upq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -200,8 +200,8 @@ func (upq *UserPositionQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (upq *UserPositionQuery) OnlyIDX(ctx context.Context) int { - id, err := upq.OnlyID(ctx) +func (_q *UserPositionQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -209,18 +209,18 @@ func (upq *UserPositionQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of UserPositions. -func (upq *UserPositionQuery) All(ctx context.Context) ([]*UserPosition, error) { - ctx = setContextOp(ctx, upq.ctx, ent.OpQueryAll) - if err := upq.prepareQuery(ctx); err != nil { +func (_q *UserPositionQuery) All(ctx context.Context) ([]*UserPosition, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*UserPosition, *UserPositionQuery]() - return withInterceptors[[]*UserPosition](ctx, upq, qr, upq.inters) + return withInterceptors[[]*UserPosition](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (upq *UserPositionQuery) AllX(ctx context.Context) []*UserPosition { - nodes, err := upq.All(ctx) +func (_q *UserPositionQuery) AllX(ctx context.Context) []*UserPosition { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -228,20 +228,20 @@ func (upq *UserPositionQuery) AllX(ctx context.Context) []*UserPosition { } // IDs executes the query and returns a list of UserPosition IDs. -func (upq *UserPositionQuery) IDs(ctx context.Context) (ids []int, err error) { - if upq.ctx.Unique == nil && upq.path != nil { - upq.Unique(true) +func (_q *UserPositionQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, upq.ctx, ent.OpQueryIDs) - if err = upq.Select(userposition.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(userposition.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (upq *UserPositionQuery) IDsX(ctx context.Context) []int { - ids, err := upq.IDs(ctx) +func (_q *UserPositionQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -249,17 +249,17 @@ func (upq *UserPositionQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (upq *UserPositionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, upq.ctx, ent.OpQueryCount) - if err := upq.prepareQuery(ctx); err != nil { +func (_q *UserPositionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, upq, querierCount[*UserPositionQuery](), upq.inters) + return withInterceptors[int](ctx, _q, querierCount[*UserPositionQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (upq *UserPositionQuery) CountX(ctx context.Context) int { - count, err := upq.Count(ctx) +func (_q *UserPositionQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -267,9 +267,9 @@ func (upq *UserPositionQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (upq *UserPositionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, upq.ctx, ent.OpQueryExist) - switch _, err := upq.FirstID(ctx); { +func (_q *UserPositionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -280,8 +280,8 @@ func (upq *UserPositionQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (upq *UserPositionQuery) ExistX(ctx context.Context) bool { - exist, err := upq.Exist(ctx) +func (_q *UserPositionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -290,45 +290,45 @@ func (upq *UserPositionQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the UserPositionQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (upq *UserPositionQuery) Clone() *UserPositionQuery { - if upq == nil { +func (_q *UserPositionQuery) Clone() *UserPositionQuery { + if _q == nil { return nil } return &UserPositionQuery{ - config: upq.config, - ctx: upq.ctx.Clone(), - order: append([]userposition.OrderOption{}, upq.order...), - inters: append([]Interceptor{}, upq.inters...), - predicates: append([]predicate.UserPosition{}, upq.predicates...), - withUser: upq.withUser.Clone(), - withPosition: upq.withPosition.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]userposition.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.UserPosition{}, _q.predicates...), + withUser: _q.withUser.Clone(), + withPosition: _q.withPosition.Clone(), // clone intermediate query. - sql: upq.sql.Clone(), - path: upq.path, - modifiers: append([]func(*sql.Selector){}, upq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithUser tells the query-builder to eager-load the nodes that are connected to // the "user" edge. The optional arguments are used to configure the query builder of the edge. -func (upq *UserPositionQuery) WithUser(opts ...func(*UserQuery)) *UserPositionQuery { - query := (&UserClient{config: upq.config}).Query() +func (_q *UserPositionQuery) WithUser(opts ...func(*UserQuery)) *UserPositionQuery { + query := (&UserClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - upq.withUser = query - return upq + _q.withUser = query + return _q } // WithPosition tells the query-builder to eager-load the nodes that are connected to // the "position" edge. The optional arguments are used to configure the query builder of the edge. -func (upq *UserPositionQuery) WithPosition(opts ...func(*PositionQuery)) *UserPositionQuery { - query := (&PositionClient{config: upq.config}).Query() +func (_q *UserPositionQuery) WithPosition(opts ...func(*PositionQuery)) *UserPositionQuery { + query := (&PositionClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - upq.withPosition = query - return upq + _q.withPosition = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -345,10 +345,10 @@ func (upq *UserPositionQuery) WithPosition(opts ...func(*PositionQuery)) *UserPo // GroupBy(userposition.FieldUserID). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (upq *UserPositionQuery) GroupBy(field string, fields ...string) *UserPositionGroupBy { - upq.ctx.Fields = append([]string{field}, fields...) - grbuild := &UserPositionGroupBy{build: upq} - grbuild.flds = &upq.ctx.Fields +func (_q *UserPositionQuery) GroupBy(field string, fields ...string) *UserPositionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserPositionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = userposition.Label grbuild.scan = grbuild.Scan return grbuild @@ -366,83 +366,83 @@ func (upq *UserPositionQuery) GroupBy(field string, fields ...string) *UserPosit // client.UserPosition.Query(). // Select(userposition.FieldUserID). // Scan(ctx, &v) -func (upq *UserPositionQuery) Select(fields ...string) *UserPositionSelect { - upq.ctx.Fields = append(upq.ctx.Fields, fields...) - sbuild := &UserPositionSelect{UserPositionQuery: upq} +func (_q *UserPositionQuery) Select(fields ...string) *UserPositionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &UserPositionSelect{UserPositionQuery: _q} sbuild.label = userposition.Label - sbuild.flds, sbuild.scan = &upq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a UserPositionSelect configured with the given aggregations. -func (upq *UserPositionQuery) Aggregate(fns ...AggregateFunc) *UserPositionSelect { - return upq.Select().Aggregate(fns...) +func (_q *UserPositionQuery) Aggregate(fns ...AggregateFunc) *UserPositionSelect { + return _q.Select().Aggregate(fns...) } -func (upq *UserPositionQuery) prepareQuery(ctx context.Context) error { - for _, inter := range upq.inters { +func (_q *UserPositionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, upq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range upq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !userposition.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if upq.path != nil { - prev, err := upq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - upq.sql = prev + _q.sql = prev } return nil } -func (upq *UserPositionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserPosition, error) { +func (_q *UserPositionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserPosition, error) { var ( nodes = []*UserPosition{} - _spec = upq.querySpec() + _spec = _q.querySpec() loadedTypes = [2]bool{ - upq.withUser != nil, - upq.withPosition != nil, + _q.withUser != nil, + _q.withPosition != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*UserPosition).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &UserPosition{config: upq.config} + node := &UserPosition{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(upq.modifiers) > 0 { - _spec.Modifiers = upq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, upq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := upq.withUser; query != nil { - if err := upq.loadUser(ctx, query, nodes, nil, + if query := _q.withUser; query != nil { + if err := _q.loadUser(ctx, query, nodes, nil, func(n *UserPosition, e *User) { n.Edges.User = e }); err != nil { return nil, err } } - if query := upq.withPosition; query != nil { - if err := upq.loadPosition(ctx, query, nodes, nil, + if query := _q.withPosition; query != nil { + if err := _q.loadPosition(ctx, query, nodes, nil, func(n *UserPosition, e *Position) { n.Edges.Position = e }); err != nil { return nil, err } @@ -450,7 +450,7 @@ func (upq *UserPositionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([ return nodes, nil } -func (upq *UserPositionQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserPosition, init func(*UserPosition), assign func(*UserPosition, *User)) error { +func (_q *UserPositionQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserPosition, init func(*UserPosition), assign func(*UserPosition, *User)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*UserPosition) for i := range nodes { @@ -479,7 +479,7 @@ func (upq *UserPositionQuery) loadUser(ctx context.Context, query *UserQuery, no } return nil } -func (upq *UserPositionQuery) loadPosition(ctx context.Context, query *PositionQuery, nodes []*UserPosition, init func(*UserPosition), assign func(*UserPosition, *Position)) error { +func (_q *UserPositionQuery) loadPosition(ctx context.Context, query *PositionQuery, nodes []*UserPosition, init func(*UserPosition), assign func(*UserPosition, *Position)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*UserPosition) for i := range nodes { @@ -509,27 +509,27 @@ func (upq *UserPositionQuery) loadPosition(ctx context.Context, query *PositionQ return nil } -func (upq *UserPositionQuery) sqlCount(ctx context.Context) (int, error) { - _spec := upq.querySpec() - if len(upq.modifiers) > 0 { - _spec.Modifiers = upq.modifiers +func (_q *UserPositionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = upq.ctx.Fields - if len(upq.ctx.Fields) > 0 { - _spec.Unique = upq.ctx.Unique != nil && *upq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, upq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (upq *UserPositionQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *UserPositionQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(userposition.Table, userposition.Columns, sqlgraph.NewFieldSpec(userposition.FieldID, field.TypeInt)) - _spec.From = upq.sql - if unique := upq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if upq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := upq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, userposition.FieldID) for i := range fields { @@ -537,27 +537,27 @@ func (upq *UserPositionQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if upq.withUser != nil { + if _q.withUser != nil { _spec.Node.AddColumnOnce(userposition.FieldUserID) } - if upq.withPosition != nil { + if _q.withPosition != nil { _spec.Node.AddColumnOnce(userposition.FieldPositionID) } } - if ps := upq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := upq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := upq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := upq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -567,36 +567,36 @@ func (upq *UserPositionQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (upq *UserPositionQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(upq.driver.Dialect()) +func (_q *UserPositionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(userposition.Table) - columns := upq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = userposition.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if upq.sql != nil { - selector = upq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if upq.ctx.Unique != nil && *upq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range upq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range upq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range upq.order { + for _, p := range _q.order { p(selector) } - if offset := upq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := upq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -605,33 +605,33 @@ func (upq *UserPositionQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (upq *UserPositionQuery) ForUpdate(opts ...sql.LockOption) *UserPositionQuery { - if upq.driver.Dialect() == dialect.Postgres { - upq.Unique(false) +func (_q *UserPositionQuery) ForUpdate(opts ...sql.LockOption) *UserPositionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - upq.modifiers = append(upq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return upq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (upq *UserPositionQuery) ForShare(opts ...sql.LockOption) *UserPositionQuery { - if upq.driver.Dialect() == dialect.Postgres { - upq.Unique(false) +func (_q *UserPositionQuery) ForShare(opts ...sql.LockOption) *UserPositionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - upq.modifiers = append(upq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return upq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (upq *UserPositionQuery) Modify(modifiers ...func(s *sql.Selector)) *UserPositionSelect { - upq.modifiers = append(upq.modifiers, modifiers...) - return upq.Select() +func (_q *UserPositionQuery) Modify(modifiers ...func(s *sql.Selector)) *UserPositionSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -673,41 +673,41 @@ type UserPositionGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (upgb *UserPositionGroupBy) Aggregate(fns ...AggregateFunc) *UserPositionGroupBy { - upgb.fns = append(upgb.fns, fns...) - return upgb +func (_g *UserPositionGroupBy) Aggregate(fns ...AggregateFunc) *UserPositionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (upgb *UserPositionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, upgb.build.ctx, ent.OpQueryGroupBy) - if err := upgb.build.prepareQuery(ctx); err != nil { +func (_g *UserPositionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*UserPositionQuery, *UserPositionGroupBy](ctx, upgb.build, upgb, upgb.build.inters, v) + return scanWithInterceptors[*UserPositionQuery, *UserPositionGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (upgb *UserPositionGroupBy) sqlScan(ctx context.Context, root *UserPositionQuery, v any) error { +func (_g *UserPositionGroupBy) sqlScan(ctx context.Context, root *UserPositionQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(upgb.fns)) - for _, fn := range upgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*upgb.flds)+len(upgb.fns)) - for _, f := range *upgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*upgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := upgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -721,27 +721,27 @@ type UserPositionSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (ups *UserPositionSelect) Aggregate(fns ...AggregateFunc) *UserPositionSelect { - ups.fns = append(ups.fns, fns...) - return ups +func (_s *UserPositionSelect) Aggregate(fns ...AggregateFunc) *UserPositionSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (ups *UserPositionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ups.ctx, ent.OpQuerySelect) - if err := ups.prepareQuery(ctx); err != nil { +func (_s *UserPositionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*UserPositionQuery, *UserPositionSelect](ctx, ups.UserPositionQuery, ups, ups.inters, v) + return scanWithInterceptors[*UserPositionQuery, *UserPositionSelect](ctx, _s.UserPositionQuery, _s, _s.inters, v) } -func (ups *UserPositionSelect) sqlScan(ctx context.Context, root *UserPositionQuery, v any) error { +func (_s *UserPositionSelect) sqlScan(ctx context.Context, root *UserPositionQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ups.fns)) - for _, fn := range ups.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*ups.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -749,7 +749,7 @@ func (ups *UserPositionSelect) sqlScan(ctx context.Context, root *UserPositionQu } rows := &sql.Rows{} query, args := selector.Query() - if err := ups.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -757,7 +757,7 @@ func (ups *UserPositionSelect) sqlScan(ctx context.Context, root *UserPositionQu } // Modify adds a query modifier for attaching custom logic to queries. -func (ups *UserPositionSelect) Modify(modifiers ...func(s *sql.Selector)) *UserPositionSelect { - ups.modifiers = append(ups.modifiers, modifiers...) - return ups +func (_s *UserPositionSelect) Modify(modifiers ...func(s *sql.Selector)) *UserPositionSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/userposition_update.go b/internal/data/entity/ent/userposition_update.go index c4a7f3b0..d3cf097c 100644 --- a/internal/data/entity/ent/userposition_update.go +++ b/internal/data/entity/ent/userposition_update.go @@ -25,74 +25,74 @@ type UserPositionUpdate struct { } // Where appends a list predicates to the UserPositionUpdate builder. -func (upu *UserPositionUpdate) Where(ps ...predicate.UserPosition) *UserPositionUpdate { - upu.mutation.Where(ps...) - return upu +func (_u *UserPositionUpdate) Where(ps ...predicate.UserPosition) *UserPositionUpdate { + _u.mutation.Where(ps...) + return _u } // SetUserID sets the "user_id" field. -func (upu *UserPositionUpdate) SetUserID(i int64) *UserPositionUpdate { - upu.mutation.SetUserID(i) - return upu +func (_u *UserPositionUpdate) SetUserID(v int64) *UserPositionUpdate { + _u.mutation.SetUserID(v) + return _u } // SetNillableUserID sets the "user_id" field if the given value is not nil. -func (upu *UserPositionUpdate) SetNillableUserID(i *int64) *UserPositionUpdate { - if i != nil { - upu.SetUserID(*i) +func (_u *UserPositionUpdate) SetNillableUserID(v *int64) *UserPositionUpdate { + if v != nil { + _u.SetUserID(*v) } - return upu + return _u } // SetPositionID sets the "position_id" field. -func (upu *UserPositionUpdate) SetPositionID(i int64) *UserPositionUpdate { - upu.mutation.SetPositionID(i) - return upu +func (_u *UserPositionUpdate) SetPositionID(v int64) *UserPositionUpdate { + _u.mutation.SetPositionID(v) + return _u } // SetNillablePositionID sets the "position_id" field if the given value is not nil. -func (upu *UserPositionUpdate) SetNillablePositionID(i *int64) *UserPositionUpdate { - if i != nil { - upu.SetPositionID(*i) +func (_u *UserPositionUpdate) SetNillablePositionID(v *int64) *UserPositionUpdate { + if v != nil { + _u.SetPositionID(*v) } - return upu + return _u } // SetUser sets the "user" edge to the User entity. -func (upu *UserPositionUpdate) SetUser(u *User) *UserPositionUpdate { - return upu.SetUserID(u.ID) +func (_u *UserPositionUpdate) SetUser(v *User) *UserPositionUpdate { + return _u.SetUserID(v.ID) } // SetPosition sets the "position" edge to the Position entity. -func (upu *UserPositionUpdate) SetPosition(p *Position) *UserPositionUpdate { - return upu.SetPositionID(p.ID) +func (_u *UserPositionUpdate) SetPosition(v *Position) *UserPositionUpdate { + return _u.SetPositionID(v.ID) } // Mutation returns the UserPositionMutation object of the builder. -func (upu *UserPositionUpdate) Mutation() *UserPositionMutation { - return upu.mutation +func (_u *UserPositionUpdate) Mutation() *UserPositionMutation { + return _u.mutation } // ClearUser clears the "user" edge to the User entity. -func (upu *UserPositionUpdate) ClearUser() *UserPositionUpdate { - upu.mutation.ClearUser() - return upu +func (_u *UserPositionUpdate) ClearUser() *UserPositionUpdate { + _u.mutation.ClearUser() + return _u } // ClearPosition clears the "position" edge to the Position entity. -func (upu *UserPositionUpdate) ClearPosition() *UserPositionUpdate { - upu.mutation.ClearPosition() - return upu +func (_u *UserPositionUpdate) ClearPosition() *UserPositionUpdate { + _u.mutation.ClearPosition() + return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (upu *UserPositionUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, upu.sqlSave, upu.mutation, upu.hooks) +func (_u *UserPositionUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (upu *UserPositionUpdate) SaveX(ctx context.Context) int { - affected, err := upu.Save(ctx) +func (_u *UserPositionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -100,58 +100,58 @@ func (upu *UserPositionUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (upu *UserPositionUpdate) Exec(ctx context.Context) error { - _, err := upu.Save(ctx) +func (_u *UserPositionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (upu *UserPositionUpdate) ExecX(ctx context.Context) { - if err := upu.Exec(ctx); err != nil { +func (_u *UserPositionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (upu *UserPositionUpdate) check() error { - if v, ok := upu.mutation.UserID(); ok { +func (_u *UserPositionUpdate) check() error { + if v, ok := _u.mutation.UserID(); ok { if err := userposition.UserIDValidator(v); err != nil { return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserPosition.user_id": %w`, err)} } } - if v, ok := upu.mutation.PositionID(); ok { + if v, ok := _u.mutation.PositionID(); ok { if err := userposition.PositionIDValidator(v); err != nil { return &ValidationError{Name: "position_id", err: fmt.Errorf(`ent: validator failed for field "UserPosition.position_id": %w`, err)} } } - if upu.mutation.UserCleared() && len(upu.mutation.UserIDs()) > 0 { + if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserPosition.user"`) } - if upu.mutation.PositionCleared() && len(upu.mutation.PositionIDs()) > 0 { + if _u.mutation.PositionCleared() && len(_u.mutation.PositionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserPosition.position"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (upu *UserPositionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserPositionUpdate { - upu.modifiers = append(upu.modifiers, modifiers...) - return upu +func (_u *UserPositionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserPositionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (upu *UserPositionUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := upu.check(); err != nil { - return n, err +func (_u *UserPositionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(userposition.Table, userposition.Columns, sqlgraph.NewFieldSpec(userposition.FieldID, field.TypeInt)) - if ps := upu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if upu.mutation.UserCleared() { + if _u.mutation.UserCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -164,7 +164,7 @@ func (upu *UserPositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := upu.mutation.UserIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -180,7 +180,7 @@ func (upu *UserPositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if upu.mutation.PositionCleared() { + if _u.mutation.PositionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -193,7 +193,7 @@ func (upu *UserPositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := upu.mutation.PositionIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -209,8 +209,8 @@ func (upu *UserPositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(upu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, upu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{userposition.Label} } else if sqlgraph.IsConstraintError(err) { @@ -218,8 +218,8 @@ func (upu *UserPositionUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - upu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // UserPositionUpdateOne is the builder for updating a single UserPosition entity. @@ -232,81 +232,81 @@ type UserPositionUpdateOne struct { } // SetUserID sets the "user_id" field. -func (upuo *UserPositionUpdateOne) SetUserID(i int64) *UserPositionUpdateOne { - upuo.mutation.SetUserID(i) - return upuo +func (_u *UserPositionUpdateOne) SetUserID(v int64) *UserPositionUpdateOne { + _u.mutation.SetUserID(v) + return _u } // SetNillableUserID sets the "user_id" field if the given value is not nil. -func (upuo *UserPositionUpdateOne) SetNillableUserID(i *int64) *UserPositionUpdateOne { - if i != nil { - upuo.SetUserID(*i) +func (_u *UserPositionUpdateOne) SetNillableUserID(v *int64) *UserPositionUpdateOne { + if v != nil { + _u.SetUserID(*v) } - return upuo + return _u } // SetPositionID sets the "position_id" field. -func (upuo *UserPositionUpdateOne) SetPositionID(i int64) *UserPositionUpdateOne { - upuo.mutation.SetPositionID(i) - return upuo +func (_u *UserPositionUpdateOne) SetPositionID(v int64) *UserPositionUpdateOne { + _u.mutation.SetPositionID(v) + return _u } // SetNillablePositionID sets the "position_id" field if the given value is not nil. -func (upuo *UserPositionUpdateOne) SetNillablePositionID(i *int64) *UserPositionUpdateOne { - if i != nil { - upuo.SetPositionID(*i) +func (_u *UserPositionUpdateOne) SetNillablePositionID(v *int64) *UserPositionUpdateOne { + if v != nil { + _u.SetPositionID(*v) } - return upuo + return _u } // SetUser sets the "user" edge to the User entity. -func (upuo *UserPositionUpdateOne) SetUser(u *User) *UserPositionUpdateOne { - return upuo.SetUserID(u.ID) +func (_u *UserPositionUpdateOne) SetUser(v *User) *UserPositionUpdateOne { + return _u.SetUserID(v.ID) } // SetPosition sets the "position" edge to the Position entity. -func (upuo *UserPositionUpdateOne) SetPosition(p *Position) *UserPositionUpdateOne { - return upuo.SetPositionID(p.ID) +func (_u *UserPositionUpdateOne) SetPosition(v *Position) *UserPositionUpdateOne { + return _u.SetPositionID(v.ID) } // Mutation returns the UserPositionMutation object of the builder. -func (upuo *UserPositionUpdateOne) Mutation() *UserPositionMutation { - return upuo.mutation +func (_u *UserPositionUpdateOne) Mutation() *UserPositionMutation { + return _u.mutation } // ClearUser clears the "user" edge to the User entity. -func (upuo *UserPositionUpdateOne) ClearUser() *UserPositionUpdateOne { - upuo.mutation.ClearUser() - return upuo +func (_u *UserPositionUpdateOne) ClearUser() *UserPositionUpdateOne { + _u.mutation.ClearUser() + return _u } // ClearPosition clears the "position" edge to the Position entity. -func (upuo *UserPositionUpdateOne) ClearPosition() *UserPositionUpdateOne { - upuo.mutation.ClearPosition() - return upuo +func (_u *UserPositionUpdateOne) ClearPosition() *UserPositionUpdateOne { + _u.mutation.ClearPosition() + return _u } // Where appends a list predicates to the UserPositionUpdate builder. -func (upuo *UserPositionUpdateOne) Where(ps ...predicate.UserPosition) *UserPositionUpdateOne { - upuo.mutation.Where(ps...) - return upuo +func (_u *UserPositionUpdateOne) Where(ps ...predicate.UserPosition) *UserPositionUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (upuo *UserPositionUpdateOne) Select(field string, fields ...string) *UserPositionUpdateOne { - upuo.fields = append([]string{field}, fields...) - return upuo +func (_u *UserPositionUpdateOne) Select(field string, fields ...string) *UserPositionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated UserPosition entity. -func (upuo *UserPositionUpdateOne) Save(ctx context.Context) (*UserPosition, error) { - return withHooks(ctx, upuo.sqlSave, upuo.mutation, upuo.hooks) +func (_u *UserPositionUpdateOne) Save(ctx context.Context) (*UserPosition, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (upuo *UserPositionUpdateOne) SaveX(ctx context.Context) *UserPosition { - node, err := upuo.Save(ctx) +func (_u *UserPositionUpdateOne) SaveX(ctx context.Context) *UserPosition { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -314,56 +314,56 @@ func (upuo *UserPositionUpdateOne) SaveX(ctx context.Context) *UserPosition { } // Exec executes the query on the entity. -func (upuo *UserPositionUpdateOne) Exec(ctx context.Context) error { - _, err := upuo.Save(ctx) +func (_u *UserPositionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (upuo *UserPositionUpdateOne) ExecX(ctx context.Context) { - if err := upuo.Exec(ctx); err != nil { +func (_u *UserPositionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (upuo *UserPositionUpdateOne) check() error { - if v, ok := upuo.mutation.UserID(); ok { +func (_u *UserPositionUpdateOne) check() error { + if v, ok := _u.mutation.UserID(); ok { if err := userposition.UserIDValidator(v); err != nil { return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserPosition.user_id": %w`, err)} } } - if v, ok := upuo.mutation.PositionID(); ok { + if v, ok := _u.mutation.PositionID(); ok { if err := userposition.PositionIDValidator(v); err != nil { return &ValidationError{Name: "position_id", err: fmt.Errorf(`ent: validator failed for field "UserPosition.position_id": %w`, err)} } } - if upuo.mutation.UserCleared() && len(upuo.mutation.UserIDs()) > 0 { + if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserPosition.user"`) } - if upuo.mutation.PositionCleared() && len(upuo.mutation.PositionIDs()) > 0 { + if _u.mutation.PositionCleared() && len(_u.mutation.PositionIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserPosition.position"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (upuo *UserPositionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserPositionUpdateOne { - upuo.modifiers = append(upuo.modifiers, modifiers...) - return upuo +func (_u *UserPositionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserPositionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (upuo *UserPositionUpdateOne) sqlSave(ctx context.Context) (_node *UserPosition, err error) { - if err := upuo.check(); err != nil { +func (_u *UserPositionUpdateOne) sqlSave(ctx context.Context) (_node *UserPosition, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(userposition.Table, userposition.Columns, sqlgraph.NewFieldSpec(userposition.FieldID, field.TypeInt)) - id, ok := upuo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserPosition.id" for update`)} } _spec.Node.ID.Value = id - if fields := upuo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, userposition.FieldID) for _, f := range fields { @@ -375,14 +375,14 @@ func (upuo *UserPositionUpdateOne) sqlSave(ctx context.Context) (_node *UserPosi } } } - if ps := upuo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if upuo.mutation.UserCleared() { + if _u.mutation.UserCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -395,7 +395,7 @@ func (upuo *UserPositionUpdateOne) sqlSave(ctx context.Context) (_node *UserPosi } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := upuo.mutation.UserIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -411,7 +411,7 @@ func (upuo *UserPositionUpdateOne) sqlSave(ctx context.Context) (_node *UserPosi } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if upuo.mutation.PositionCleared() { + if _u.mutation.PositionCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -424,7 +424,7 @@ func (upuo *UserPositionUpdateOne) sqlSave(ctx context.Context) (_node *UserPosi } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := upuo.mutation.PositionIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PositionIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -440,11 +440,11 @@ func (upuo *UserPositionUpdateOne) sqlSave(ctx context.Context) (_node *UserPosi } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(upuo.modifiers...) - _node = &UserPosition{config: upuo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &UserPosition{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, upuo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{userposition.Label} } else if sqlgraph.IsConstraintError(err) { @@ -452,7 +452,7 @@ func (upuo *UserPositionUpdateOne) sqlSave(ctx context.Context) (_node *UserPosi } return nil, err } - upuo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/internal/data/entity/ent/userrole.go b/internal/data/entity/ent/userrole.go index 3da25710..33f53be4 100644 --- a/internal/data/entity/ent/userrole.go +++ b/internal/data/entity/ent/userrole.go @@ -77,7 +77,7 @@ func (*UserRole) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the UserRole fields. -func (ur *UserRole) assignValues(columns []string, values []any) error { +func (_m *UserRole) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -88,21 +88,21 @@ func (ur *UserRole) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - ur.ID = int(value.Int64) + _m.ID = int(value.Int64) case userrole.FieldUserID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field user_id", values[i]) } else if value.Valid { - ur.UserID = value.Int64 + _m.UserID = value.Int64 } case userrole.FieldRoleID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field role_id", values[i]) } else if value.Valid { - ur.RoleID = value.Int64 + _m.RoleID = value.Int64 } default: - ur.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -110,48 +110,48 @@ func (ur *UserRole) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the UserRole. // This includes values selected through modifiers, order, etc. -func (ur *UserRole) Value(name string) (ent.Value, error) { - return ur.selectValues.Get(name) +func (_m *UserRole) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryUser queries the "user" edge of the UserRole entity. -func (ur *UserRole) QueryUser() *UserQuery { - return NewUserRoleClient(ur.config).QueryUser(ur) +func (_m *UserRole) QueryUser() *UserQuery { + return NewUserRoleClient(_m.config).QueryUser(_m) } // QueryRole queries the "role" edge of the UserRole entity. -func (ur *UserRole) QueryRole() *RoleQuery { - return NewUserRoleClient(ur.config).QueryRole(ur) +func (_m *UserRole) QueryRole() *RoleQuery { + return NewUserRoleClient(_m.config).QueryRole(_m) } // Update returns a builder for updating this UserRole. // Note that you need to call UserRole.Unwrap() before calling this method if this UserRole // was returned from a transaction, and the transaction was committed or rolled back. -func (ur *UserRole) Update() *UserRoleUpdateOne { - return NewUserRoleClient(ur.config).UpdateOne(ur) +func (_m *UserRole) Update() *UserRoleUpdateOne { + return NewUserRoleClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the UserRole entity that was returned from a transaction after it was closed, // so that all future queries will be executed through the driver which created the transaction. -func (ur *UserRole) Unwrap() *UserRole { - _tx, ok := ur.config.driver.(*txDriver) +func (_m *UserRole) Unwrap() *UserRole { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: UserRole is not a transactional entity") } - ur.config.driver = _tx.drv - return ur + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (ur *UserRole) String() string { +func (_m *UserRole) String() string { var builder strings.Builder builder.WriteString("UserRole(") - builder.WriteString(fmt.Sprintf("id=%v, ", ur.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("user_id=") - builder.WriteString(fmt.Sprintf("%v", ur.UserID)) + builder.WriteString(fmt.Sprintf("%v", _m.UserID)) builder.WriteString(", ") builder.WriteString("role_id=") - builder.WriteString(fmt.Sprintf("%v", ur.RoleID)) + builder.WriteString(fmt.Sprintf("%v", _m.RoleID)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/userrole_create.go b/internal/data/entity/ent/userrole_create.go index 7269d57a..f98b7a1b 100644 --- a/internal/data/entity/ent/userrole_create.go +++ b/internal/data/entity/ent/userrole_create.go @@ -22,40 +22,40 @@ type UserRoleCreate struct { } // SetUserID sets the "user_id" field. -func (urc *UserRoleCreate) SetUserID(i int64) *UserRoleCreate { - urc.mutation.SetUserID(i) - return urc +func (_c *UserRoleCreate) SetUserID(v int64) *UserRoleCreate { + _c.mutation.SetUserID(v) + return _c } // SetRoleID sets the "role_id" field. -func (urc *UserRoleCreate) SetRoleID(i int64) *UserRoleCreate { - urc.mutation.SetRoleID(i) - return urc +func (_c *UserRoleCreate) SetRoleID(v int64) *UserRoleCreate { + _c.mutation.SetRoleID(v) + return _c } // SetUser sets the "user" edge to the User entity. -func (urc *UserRoleCreate) SetUser(u *User) *UserRoleCreate { - return urc.SetUserID(u.ID) +func (_c *UserRoleCreate) SetUser(v *User) *UserRoleCreate { + return _c.SetUserID(v.ID) } // SetRole sets the "role" edge to the Role entity. -func (urc *UserRoleCreate) SetRole(r *Role) *UserRoleCreate { - return urc.SetRoleID(r.ID) +func (_c *UserRoleCreate) SetRole(v *Role) *UserRoleCreate { + return _c.SetRoleID(v.ID) } // Mutation returns the UserRoleMutation object of the builder. -func (urc *UserRoleCreate) Mutation() *UserRoleMutation { - return urc.mutation +func (_c *UserRoleCreate) Mutation() *UserRoleMutation { + return _c.mutation } // Save creates the UserRole in the database. -func (urc *UserRoleCreate) Save(ctx context.Context) (*UserRole, error) { - return withHooks(ctx, urc.sqlSave, urc.mutation, urc.hooks) +func (_c *UserRoleCreate) Save(ctx context.Context) (*UserRole, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (urc *UserRoleCreate) SaveX(ctx context.Context) *UserRole { - v, err := urc.Save(ctx) +func (_c *UserRoleCreate) SaveX(ctx context.Context) *UserRole { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -63,51 +63,51 @@ func (urc *UserRoleCreate) SaveX(ctx context.Context) *UserRole { } // Exec executes the query. -func (urc *UserRoleCreate) Exec(ctx context.Context) error { - _, err := urc.Save(ctx) +func (_c *UserRoleCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (urc *UserRoleCreate) ExecX(ctx context.Context) { - if err := urc.Exec(ctx); err != nil { +func (_c *UserRoleCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (urc *UserRoleCreate) check() error { - if _, ok := urc.mutation.UserID(); !ok { +func (_c *UserRoleCreate) check() error { + if _, ok := _c.mutation.UserID(); !ok { return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserRole.user_id"`)} } - if v, ok := urc.mutation.UserID(); ok { + if v, ok := _c.mutation.UserID(); ok { if err := userrole.UserIDValidator(v); err != nil { return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserRole.user_id": %w`, err)} } } - if _, ok := urc.mutation.RoleID(); !ok { + if _, ok := _c.mutation.RoleID(); !ok { return &ValidationError{Name: "role_id", err: errors.New(`ent: missing required field "UserRole.role_id"`)} } - if v, ok := urc.mutation.RoleID(); ok { + if v, ok := _c.mutation.RoleID(); ok { if err := userrole.RoleIDValidator(v); err != nil { return &ValidationError{Name: "role_id", err: fmt.Errorf(`ent: validator failed for field "UserRole.role_id": %w`, err)} } } - if len(urc.mutation.UserIDs()) == 0 { + if len(_c.mutation.UserIDs()) == 0 { return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserRole.user"`)} } - if len(urc.mutation.RoleIDs()) == 0 { + if len(_c.mutation.RoleIDs()) == 0 { return &ValidationError{Name: "role", err: errors.New(`ent: missing required edge "UserRole.role"`)} } return nil } -func (urc *UserRoleCreate) sqlSave(ctx context.Context) (*UserRole, error) { - if err := urc.check(); err != nil { +func (_c *UserRoleCreate) sqlSave(ctx context.Context) (*UserRole, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := urc.createSpec() - if err := sqlgraph.CreateNode(ctx, urc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -115,17 +115,17 @@ func (urc *UserRoleCreate) sqlSave(ctx context.Context) (*UserRole, error) { } id := _spec.ID.Value.(int64) _node.ID = int(id) - urc.mutation.id = &_node.ID - urc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (urc *UserRoleCreate) createSpec() (*UserRole, *sqlgraph.CreateSpec) { +func (_c *UserRoleCreate) createSpec() (*UserRole, *sqlgraph.CreateSpec) { var ( - _node = &UserRole{config: urc.config} + _node = &UserRole{config: _c.config} _spec = sqlgraph.NewCreateSpec(userrole.Table, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) ) - if nodes := urc.mutation.UserIDs(); len(nodes) > 0 { + if nodes := _c.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -142,7 +142,7 @@ func (urc *UserRoleCreate) createSpec() (*UserRole, *sqlgraph.CreateSpec) { _node.UserID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := urc.mutation.RoleIDs(); len(nodes) > 0 { + if nodes := _c.mutation.RoleIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -163,23 +163,23 @@ func (urc *UserRoleCreate) createSpec() (*UserRole, *sqlgraph.CreateSpec) { } // SetUserRole set the UserRole -func (urc *UserRoleCreate) SetUserRole(input *UserRole, fields ...string) *UserRoleCreate { - m := urc.mutation +func (_c *UserRoleCreate) SetUserRole(input *UserRole, fields ...string) *UserRoleCreate { + m := _c.mutation if len(fields) == 0 { fields = userrole.Columns } _ = m.SetFields(input, fields...) - return urc + return _c } // SetUserRoleWithZero set the UserRole -func (urc *UserRoleCreate) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleCreate { - m := urc.mutation +func (_c *UserRoleCreate) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleCreate { + m := _c.mutation if len(fields) == 0 { fields = userrole.Columns } _ = m.SetFieldsWithZero(input, fields...) - return urc + return _c } // UserRoleCreateBulk is the builder for creating many UserRole entities in bulk. @@ -190,16 +190,16 @@ type UserRoleCreateBulk struct { } // Save creates the UserRole entities in the database. -func (urcb *UserRoleCreateBulk) Save(ctx context.Context) ([]*UserRole, error) { - if urcb.err != nil { - return nil, urcb.err +func (_c *UserRoleCreateBulk) Save(ctx context.Context) ([]*UserRole, error) { + if _c.err != nil { + return nil, _c.err } - specs := make([]*sqlgraph.CreateSpec, len(urcb.builders)) - nodes := make([]*UserRole, len(urcb.builders)) - mutators := make([]Mutator, len(urcb.builders)) - for i := range urcb.builders { + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*UserRole, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := urcb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*UserRoleMutation) if !ok { @@ -212,11 +212,11 @@ func (urcb *UserRoleCreateBulk) Save(ctx context.Context) ([]*UserRole, error) { var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, urcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, urcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -240,7 +240,7 @@ func (urcb *UserRoleCreateBulk) Save(ctx context.Context) ([]*UserRole, error) { }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, urcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -248,8 +248,8 @@ func (urcb *UserRoleCreateBulk) Save(ctx context.Context) ([]*UserRole, error) { } // SaveX is like Save, but panics if an error occurs. -func (urcb *UserRoleCreateBulk) SaveX(ctx context.Context) []*UserRole { - v, err := urcb.Save(ctx) +func (_c *UserRoleCreateBulk) SaveX(ctx context.Context) []*UserRole { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -257,14 +257,14 @@ func (urcb *UserRoleCreateBulk) SaveX(ctx context.Context) []*UserRole { } // Exec executes the query. -func (urcb *UserRoleCreateBulk) Exec(ctx context.Context) error { - _, err := urcb.Save(ctx) +func (_c *UserRoleCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (urcb *UserRoleCreateBulk) ExecX(ctx context.Context) { - if err := urcb.Exec(ctx); err != nil { +func (_c *UserRoleCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/userrole_delete.go b/internal/data/entity/ent/userrole_delete.go index 00d7c9bb..18a15145 100644 --- a/internal/data/entity/ent/userrole_delete.go +++ b/internal/data/entity/ent/userrole_delete.go @@ -20,56 +20,56 @@ type UserRoleDelete struct { } // Where appends a list predicates to the UserRoleDelete builder. -func (urd *UserRoleDelete) Where(ps ...predicate.UserRole) *UserRoleDelete { - urd.mutation.Where(ps...) - return urd +func (_d *UserRoleDelete) Where(ps ...predicate.UserRole) *UserRoleDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (urd *UserRoleDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, urd.sqlExec, urd.mutation, urd.hooks) +func (_d *UserRoleDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (urd *UserRoleDelete) ExecX(ctx context.Context) int { - n, err := urd.Exec(ctx) +func (_d *UserRoleDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (urd *UserRoleDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *UserRoleDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(userrole.Table, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) - if ps := urd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, urd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - urd.mutation.done = true + _d.mutation.done = true return affected, err } // UserRoleDeleteOne is the builder for deleting a single UserRole entity. type UserRoleDeleteOne struct { - urd *UserRoleDelete + _d *UserRoleDelete } // Where appends a list predicates to the UserRoleDelete builder. -func (urdo *UserRoleDeleteOne) Where(ps ...predicate.UserRole) *UserRoleDeleteOne { - urdo.urd.mutation.Where(ps...) - return urdo +func (_d *UserRoleDeleteOne) Where(ps ...predicate.UserRole) *UserRoleDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (urdo *UserRoleDeleteOne) Exec(ctx context.Context) error { - n, err := urdo.urd.Exec(ctx) +func (_d *UserRoleDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (urdo *UserRoleDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (urdo *UserRoleDeleteOne) ExecX(ctx context.Context) { - if err := urdo.Exec(ctx); err != nil { +func (_d *UserRoleDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/internal/data/entity/ent/userrole_query.go b/internal/data/entity/ent/userrole_query.go index 9fa3b276..09a25c15 100644 --- a/internal/data/entity/ent/userrole_query.go +++ b/internal/data/entity/ent/userrole_query.go @@ -34,44 +34,44 @@ type UserRoleQuery struct { } // Where adds a new predicate for the UserRoleQuery builder. -func (urq *UserRoleQuery) Where(ps ...predicate.UserRole) *UserRoleQuery { - urq.predicates = append(urq.predicates, ps...) - return urq +func (_q *UserRoleQuery) Where(ps ...predicate.UserRole) *UserRoleQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (urq *UserRoleQuery) Limit(limit int) *UserRoleQuery { - urq.ctx.Limit = &limit - return urq +func (_q *UserRoleQuery) Limit(limit int) *UserRoleQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (urq *UserRoleQuery) Offset(offset int) *UserRoleQuery { - urq.ctx.Offset = &offset - return urq +func (_q *UserRoleQuery) Offset(offset int) *UserRoleQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (urq *UserRoleQuery) Unique(unique bool) *UserRoleQuery { - urq.ctx.Unique = &unique - return urq +func (_q *UserRoleQuery) Unique(unique bool) *UserRoleQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (urq *UserRoleQuery) Order(o ...userrole.OrderOption) *UserRoleQuery { - urq.order = append(urq.order, o...) - return urq +func (_q *UserRoleQuery) Order(o ...userrole.OrderOption) *UserRoleQuery { + _q.order = append(_q.order, o...) + return _q } // QueryUser chains the current query on the "user" edge. -func (urq *UserRoleQuery) QueryUser() *UserQuery { - query := (&UserClient{config: urq.config}).Query() +func (_q *UserRoleQuery) QueryUser() *UserQuery { + query := (&UserClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := urq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := urq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -80,20 +80,20 @@ func (urq *UserRoleQuery) QueryUser() *UserQuery { sqlgraph.To(user.Table, user.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userrole.UserTable, userrole.UserColumn), ) - fromU = sqlgraph.SetNeighbors(urq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryRole chains the current query on the "role" edge. -func (urq *UserRoleQuery) QueryRole() *RoleQuery { - query := (&RoleClient{config: urq.config}).Query() +func (_q *UserRoleQuery) QueryRole() *RoleQuery { + query := (&RoleClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := urq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := urq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -102,7 +102,7 @@ func (urq *UserRoleQuery) QueryRole() *RoleQuery { sqlgraph.To(role.Table, role.FieldID), sqlgraph.Edge(sqlgraph.M2O, false, userrole.RoleTable, userrole.RoleColumn), ) - fromU = sqlgraph.SetNeighbors(urq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -110,8 +110,8 @@ func (urq *UserRoleQuery) QueryRole() *RoleQuery { // First returns the first UserRole entity from the query. // Returns a *NotFoundError when no UserRole was found. -func (urq *UserRoleQuery) First(ctx context.Context) (*UserRole, error) { - nodes, err := urq.Limit(1).All(setContextOp(ctx, urq.ctx, ent.OpQueryFirst)) +func (_q *UserRoleQuery) First(ctx context.Context) (*UserRole, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -122,8 +122,8 @@ func (urq *UserRoleQuery) First(ctx context.Context) (*UserRole, error) { } // FirstX is like First, but panics if an error occurs. -func (urq *UserRoleQuery) FirstX(ctx context.Context) *UserRole { - node, err := urq.First(ctx) +func (_q *UserRoleQuery) FirstX(ctx context.Context) *UserRole { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -132,9 +132,9 @@ func (urq *UserRoleQuery) FirstX(ctx context.Context) *UserRole { // FirstID returns the first UserRole ID from the query. // Returns a *NotFoundError when no UserRole ID was found. -func (urq *UserRoleQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *UserRoleQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = urq.Limit(1).IDs(setContextOp(ctx, urq.ctx, ent.OpQueryFirstID)); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -145,8 +145,8 @@ func (urq *UserRoleQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (urq *UserRoleQuery) FirstIDX(ctx context.Context) int { - id, err := urq.FirstID(ctx) +func (_q *UserRoleQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -156,8 +156,8 @@ func (urq *UserRoleQuery) FirstIDX(ctx context.Context) int { // Only returns a single UserRole entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one UserRole entity is found. // Returns a *NotFoundError when no UserRole entities are found. -func (urq *UserRoleQuery) Only(ctx context.Context) (*UserRole, error) { - nodes, err := urq.Limit(2).All(setContextOp(ctx, urq.ctx, ent.OpQueryOnly)) +func (_q *UserRoleQuery) Only(ctx context.Context) (*UserRole, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -172,8 +172,8 @@ func (urq *UserRoleQuery) Only(ctx context.Context) (*UserRole, error) { } // OnlyX is like Only, but panics if an error occurs. -func (urq *UserRoleQuery) OnlyX(ctx context.Context) *UserRole { - node, err := urq.Only(ctx) +func (_q *UserRoleQuery) OnlyX(ctx context.Context) *UserRole { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -183,9 +183,9 @@ func (urq *UserRoleQuery) OnlyX(ctx context.Context) *UserRole { // OnlyID is like Only, but returns the only UserRole ID in the query. // Returns a *NotSingularError when more than one UserRole ID is found. // Returns a *NotFoundError when no entities are found. -func (urq *UserRoleQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *UserRoleQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = urq.Limit(2).IDs(setContextOp(ctx, urq.ctx, ent.OpQueryOnlyID)); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -200,8 +200,8 @@ func (urq *UserRoleQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (urq *UserRoleQuery) OnlyIDX(ctx context.Context) int { - id, err := urq.OnlyID(ctx) +func (_q *UserRoleQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -209,18 +209,18 @@ func (urq *UserRoleQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of UserRoles. -func (urq *UserRoleQuery) All(ctx context.Context) ([]*UserRole, error) { - ctx = setContextOp(ctx, urq.ctx, ent.OpQueryAll) - if err := urq.prepareQuery(ctx); err != nil { +func (_q *UserRoleQuery) All(ctx context.Context) ([]*UserRole, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*UserRole, *UserRoleQuery]() - return withInterceptors[[]*UserRole](ctx, urq, qr, urq.inters) + return withInterceptors[[]*UserRole](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (urq *UserRoleQuery) AllX(ctx context.Context) []*UserRole { - nodes, err := urq.All(ctx) +func (_q *UserRoleQuery) AllX(ctx context.Context) []*UserRole { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -228,20 +228,20 @@ func (urq *UserRoleQuery) AllX(ctx context.Context) []*UserRole { } // IDs executes the query and returns a list of UserRole IDs. -func (urq *UserRoleQuery) IDs(ctx context.Context) (ids []int, err error) { - if urq.ctx.Unique == nil && urq.path != nil { - urq.Unique(true) +func (_q *UserRoleQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, urq.ctx, ent.OpQueryIDs) - if err = urq.Select(userrole.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(userrole.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (urq *UserRoleQuery) IDsX(ctx context.Context) []int { - ids, err := urq.IDs(ctx) +func (_q *UserRoleQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -249,17 +249,17 @@ func (urq *UserRoleQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (urq *UserRoleQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, urq.ctx, ent.OpQueryCount) - if err := urq.prepareQuery(ctx); err != nil { +func (_q *UserRoleQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, urq, querierCount[*UserRoleQuery](), urq.inters) + return withInterceptors[int](ctx, _q, querierCount[*UserRoleQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (urq *UserRoleQuery) CountX(ctx context.Context) int { - count, err := urq.Count(ctx) +func (_q *UserRoleQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -267,9 +267,9 @@ func (urq *UserRoleQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (urq *UserRoleQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, urq.ctx, ent.OpQueryExist) - switch _, err := urq.FirstID(ctx); { +func (_q *UserRoleQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -280,8 +280,8 @@ func (urq *UserRoleQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (urq *UserRoleQuery) ExistX(ctx context.Context) bool { - exist, err := urq.Exist(ctx) +func (_q *UserRoleQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -290,45 +290,45 @@ func (urq *UserRoleQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the UserRoleQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (urq *UserRoleQuery) Clone() *UserRoleQuery { - if urq == nil { +func (_q *UserRoleQuery) Clone() *UserRoleQuery { + if _q == nil { return nil } return &UserRoleQuery{ - config: urq.config, - ctx: urq.ctx.Clone(), - order: append([]userrole.OrderOption{}, urq.order...), - inters: append([]Interceptor{}, urq.inters...), - predicates: append([]predicate.UserRole{}, urq.predicates...), - withUser: urq.withUser.Clone(), - withRole: urq.withRole.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]userrole.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.UserRole{}, _q.predicates...), + withUser: _q.withUser.Clone(), + withRole: _q.withRole.Clone(), // clone intermediate query. - sql: urq.sql.Clone(), - path: urq.path, - modifiers: append([]func(*sql.Selector){}, urq.modifiers...), + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithUser tells the query-builder to eager-load the nodes that are connected to // the "user" edge. The optional arguments are used to configure the query builder of the edge. -func (urq *UserRoleQuery) WithUser(opts ...func(*UserQuery)) *UserRoleQuery { - query := (&UserClient{config: urq.config}).Query() +func (_q *UserRoleQuery) WithUser(opts ...func(*UserQuery)) *UserRoleQuery { + query := (&UserClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - urq.withUser = query - return urq + _q.withUser = query + return _q } // WithRole tells the query-builder to eager-load the nodes that are connected to // the "role" edge. The optional arguments are used to configure the query builder of the edge. -func (urq *UserRoleQuery) WithRole(opts ...func(*RoleQuery)) *UserRoleQuery { - query := (&RoleClient{config: urq.config}).Query() +func (_q *UserRoleQuery) WithRole(opts ...func(*RoleQuery)) *UserRoleQuery { + query := (&RoleClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - urq.withRole = query - return urq + _q.withRole = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -345,10 +345,10 @@ func (urq *UserRoleQuery) WithRole(opts ...func(*RoleQuery)) *UserRoleQuery { // GroupBy(userrole.FieldUserID). // Aggregate(ent.Count()). // Scan(ctx, &v) -func (urq *UserRoleQuery) GroupBy(field string, fields ...string) *UserRoleGroupBy { - urq.ctx.Fields = append([]string{field}, fields...) - grbuild := &UserRoleGroupBy{build: urq} - grbuild.flds = &urq.ctx.Fields +func (_q *UserRoleQuery) GroupBy(field string, fields ...string) *UserRoleGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserRoleGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = userrole.Label grbuild.scan = grbuild.Scan return grbuild @@ -366,83 +366,83 @@ func (urq *UserRoleQuery) GroupBy(field string, fields ...string) *UserRoleGroup // client.UserRole.Query(). // Select(userrole.FieldUserID). // Scan(ctx, &v) -func (urq *UserRoleQuery) Select(fields ...string) *UserRoleSelect { - urq.ctx.Fields = append(urq.ctx.Fields, fields...) - sbuild := &UserRoleSelect{UserRoleQuery: urq} +func (_q *UserRoleQuery) Select(fields ...string) *UserRoleSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &UserRoleSelect{UserRoleQuery: _q} sbuild.label = userrole.Label - sbuild.flds, sbuild.scan = &urq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a UserRoleSelect configured with the given aggregations. -func (urq *UserRoleQuery) Aggregate(fns ...AggregateFunc) *UserRoleSelect { - return urq.Select().Aggregate(fns...) +func (_q *UserRoleQuery) Aggregate(fns ...AggregateFunc) *UserRoleSelect { + return _q.Select().Aggregate(fns...) } -func (urq *UserRoleQuery) prepareQuery(ctx context.Context) error { - for _, inter := range urq.inters { +func (_q *UserRoleQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, urq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range urq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !userrole.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if urq.path != nil { - prev, err := urq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - urq.sql = prev + _q.sql = prev } return nil } -func (urq *UserRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserRole, error) { +func (_q *UserRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserRole, error) { var ( nodes = []*UserRole{} - _spec = urq.querySpec() + _spec = _q.querySpec() loadedTypes = [2]bool{ - urq.withUser != nil, - urq.withRole != nil, + _q.withUser != nil, + _q.withRole != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*UserRole).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &UserRole{config: urq.config} + node := &UserRole{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(urq.modifiers) > 0 { - _spec.Modifiers = urq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, urq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := urq.withUser; query != nil { - if err := urq.loadUser(ctx, query, nodes, nil, + if query := _q.withUser; query != nil { + if err := _q.loadUser(ctx, query, nodes, nil, func(n *UserRole, e *User) { n.Edges.User = e }); err != nil { return nil, err } } - if query := urq.withRole; query != nil { - if err := urq.loadRole(ctx, query, nodes, nil, + if query := _q.withRole; query != nil { + if err := _q.loadRole(ctx, query, nodes, nil, func(n *UserRole, e *Role) { n.Edges.Role = e }); err != nil { return nil, err } @@ -450,7 +450,7 @@ func (urq *UserRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Us return nodes, nil } -func (urq *UserRoleQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserRole, init func(*UserRole), assign func(*UserRole, *User)) error { +func (_q *UserRoleQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserRole, init func(*UserRole), assign func(*UserRole, *User)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*UserRole) for i := range nodes { @@ -479,7 +479,7 @@ func (urq *UserRoleQuery) loadUser(ctx context.Context, query *UserQuery, nodes } return nil } -func (urq *UserRoleQuery) loadRole(ctx context.Context, query *RoleQuery, nodes []*UserRole, init func(*UserRole), assign func(*UserRole, *Role)) error { +func (_q *UserRoleQuery) loadRole(ctx context.Context, query *RoleQuery, nodes []*UserRole, init func(*UserRole), assign func(*UserRole, *Role)) error { ids := make([]int64, 0, len(nodes)) nodeids := make(map[int64][]*UserRole) for i := range nodes { @@ -509,27 +509,27 @@ func (urq *UserRoleQuery) loadRole(ctx context.Context, query *RoleQuery, nodes return nil } -func (urq *UserRoleQuery) sqlCount(ctx context.Context) (int, error) { - _spec := urq.querySpec() - if len(urq.modifiers) > 0 { - _spec.Modifiers = urq.modifiers +func (_q *UserRoleQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = urq.ctx.Fields - if len(urq.ctx.Fields) > 0 { - _spec.Unique = urq.ctx.Unique != nil && *urq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, urq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (urq *UserRoleQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *UserRoleQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(userrole.Table, userrole.Columns, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) - _spec.From = urq.sql - if unique := urq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if urq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := urq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, userrole.FieldID) for i := range fields { @@ -537,27 +537,27 @@ func (urq *UserRoleQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if urq.withUser != nil { + if _q.withUser != nil { _spec.Node.AddColumnOnce(userrole.FieldUserID) } - if urq.withRole != nil { + if _q.withRole != nil { _spec.Node.AddColumnOnce(userrole.FieldRoleID) } } - if ps := urq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := urq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := urq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := urq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -567,36 +567,36 @@ func (urq *UserRoleQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (urq *UserRoleQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(urq.driver.Dialect()) +func (_q *UserRoleQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(userrole.Table) - columns := urq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = userrole.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if urq.sql != nil { - selector = urq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if urq.ctx.Unique != nil && *urq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range urq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range urq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range urq.order { + for _, p := range _q.order { p(selector) } - if offset := urq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := urq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -605,33 +605,33 @@ func (urq *UserRoleQuery) sqlQuery(ctx context.Context) *sql.Selector { // ForUpdate locks the selected rows against concurrent updates, and prevent them from being // updated, deleted or "selected ... for update" by other sessions, until the transaction is // either committed or rolled-back. -func (urq *UserRoleQuery) ForUpdate(opts ...sql.LockOption) *UserRoleQuery { - if urq.driver.Dialect() == dialect.Postgres { - urq.Unique(false) +func (_q *UserRoleQuery) ForUpdate(opts ...sql.LockOption) *UserRoleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - urq.modifiers = append(urq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForUpdate(opts...) }) - return urq + return _q } // ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock // on any rows that are read. Other sessions can read the rows, but cannot modify them // until your transaction commits. -func (urq *UserRoleQuery) ForShare(opts ...sql.LockOption) *UserRoleQuery { - if urq.driver.Dialect() == dialect.Postgres { - urq.Unique(false) +func (_q *UserRoleQuery) ForShare(opts ...sql.LockOption) *UserRoleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) } - urq.modifiers = append(urq.modifiers, func(s *sql.Selector) { + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { s.ForShare(opts...) }) - return urq + return _q } // Modify adds a query modifier for attaching custom logic to queries. -func (urq *UserRoleQuery) Modify(modifiers ...func(s *sql.Selector)) *UserRoleSelect { - urq.modifiers = append(urq.modifiers, modifiers...) - return urq.Select() +func (_q *UserRoleQuery) Modify(modifiers ...func(s *sql.Selector)) *UserRoleSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // Omit allows the unselect one or more fields/columns for the given query, @@ -673,41 +673,41 @@ type UserRoleGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (urgb *UserRoleGroupBy) Aggregate(fns ...AggregateFunc) *UserRoleGroupBy { - urgb.fns = append(urgb.fns, fns...) - return urgb +func (_g *UserRoleGroupBy) Aggregate(fns ...AggregateFunc) *UserRoleGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (urgb *UserRoleGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, urgb.build.ctx, ent.OpQueryGroupBy) - if err := urgb.build.prepareQuery(ctx); err != nil { +func (_g *UserRoleGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*UserRoleQuery, *UserRoleGroupBy](ctx, urgb.build, urgb, urgb.build.inters, v) + return scanWithInterceptors[*UserRoleQuery, *UserRoleGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (urgb *UserRoleGroupBy) sqlScan(ctx context.Context, root *UserRoleQuery, v any) error { +func (_g *UserRoleGroupBy) sqlScan(ctx context.Context, root *UserRoleQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(urgb.fns)) - for _, fn := range urgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*urgb.flds)+len(urgb.fns)) - for _, f := range *urgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*urgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := urgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -721,27 +721,27 @@ type UserRoleSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (urs *UserRoleSelect) Aggregate(fns ...AggregateFunc) *UserRoleSelect { - urs.fns = append(urs.fns, fns...) - return urs +func (_s *UserRoleSelect) Aggregate(fns ...AggregateFunc) *UserRoleSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (urs *UserRoleSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, urs.ctx, ent.OpQuerySelect) - if err := urs.prepareQuery(ctx); err != nil { +func (_s *UserRoleSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*UserRoleQuery, *UserRoleSelect](ctx, urs.UserRoleQuery, urs, urs.inters, v) + return scanWithInterceptors[*UserRoleQuery, *UserRoleSelect](ctx, _s.UserRoleQuery, _s, _s.inters, v) } -func (urs *UserRoleSelect) sqlScan(ctx context.Context, root *UserRoleQuery, v any) error { +func (_s *UserRoleSelect) sqlScan(ctx context.Context, root *UserRoleQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(urs.fns)) - for _, fn := range urs.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*urs.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -749,7 +749,7 @@ func (urs *UserRoleSelect) sqlScan(ctx context.Context, root *UserRoleQuery, v a } rows := &sql.Rows{} query, args := selector.Query() - if err := urs.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -757,7 +757,7 @@ func (urs *UserRoleSelect) sqlScan(ctx context.Context, root *UserRoleQuery, v a } // Modify adds a query modifier for attaching custom logic to queries. -func (urs *UserRoleSelect) Modify(modifiers ...func(s *sql.Selector)) *UserRoleSelect { - urs.modifiers = append(urs.modifiers, modifiers...) - return urs +func (_s *UserRoleSelect) Modify(modifiers ...func(s *sql.Selector)) *UserRoleSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/internal/data/entity/ent/userrole_update.go b/internal/data/entity/ent/userrole_update.go index 79abc5f4..90c3a5a9 100644 --- a/internal/data/entity/ent/userrole_update.go +++ b/internal/data/entity/ent/userrole_update.go @@ -25,74 +25,74 @@ type UserRoleUpdate struct { } // Where appends a list predicates to the UserRoleUpdate builder. -func (uru *UserRoleUpdate) Where(ps ...predicate.UserRole) *UserRoleUpdate { - uru.mutation.Where(ps...) - return uru +func (_u *UserRoleUpdate) Where(ps ...predicate.UserRole) *UserRoleUpdate { + _u.mutation.Where(ps...) + return _u } // SetUserID sets the "user_id" field. -func (uru *UserRoleUpdate) SetUserID(i int64) *UserRoleUpdate { - uru.mutation.SetUserID(i) - return uru +func (_u *UserRoleUpdate) SetUserID(v int64) *UserRoleUpdate { + _u.mutation.SetUserID(v) + return _u } // SetNillableUserID sets the "user_id" field if the given value is not nil. -func (uru *UserRoleUpdate) SetNillableUserID(i *int64) *UserRoleUpdate { - if i != nil { - uru.SetUserID(*i) +func (_u *UserRoleUpdate) SetNillableUserID(v *int64) *UserRoleUpdate { + if v != nil { + _u.SetUserID(*v) } - return uru + return _u } // SetRoleID sets the "role_id" field. -func (uru *UserRoleUpdate) SetRoleID(i int64) *UserRoleUpdate { - uru.mutation.SetRoleID(i) - return uru +func (_u *UserRoleUpdate) SetRoleID(v int64) *UserRoleUpdate { + _u.mutation.SetRoleID(v) + return _u } // SetNillableRoleID sets the "role_id" field if the given value is not nil. -func (uru *UserRoleUpdate) SetNillableRoleID(i *int64) *UserRoleUpdate { - if i != nil { - uru.SetRoleID(*i) +func (_u *UserRoleUpdate) SetNillableRoleID(v *int64) *UserRoleUpdate { + if v != nil { + _u.SetRoleID(*v) } - return uru + return _u } // SetUser sets the "user" edge to the User entity. -func (uru *UserRoleUpdate) SetUser(u *User) *UserRoleUpdate { - return uru.SetUserID(u.ID) +func (_u *UserRoleUpdate) SetUser(v *User) *UserRoleUpdate { + return _u.SetUserID(v.ID) } // SetRole sets the "role" edge to the Role entity. -func (uru *UserRoleUpdate) SetRole(r *Role) *UserRoleUpdate { - return uru.SetRoleID(r.ID) +func (_u *UserRoleUpdate) SetRole(v *Role) *UserRoleUpdate { + return _u.SetRoleID(v.ID) } // Mutation returns the UserRoleMutation object of the builder. -func (uru *UserRoleUpdate) Mutation() *UserRoleMutation { - return uru.mutation +func (_u *UserRoleUpdate) Mutation() *UserRoleMutation { + return _u.mutation } // ClearUser clears the "user" edge to the User entity. -func (uru *UserRoleUpdate) ClearUser() *UserRoleUpdate { - uru.mutation.ClearUser() - return uru +func (_u *UserRoleUpdate) ClearUser() *UserRoleUpdate { + _u.mutation.ClearUser() + return _u } // ClearRole clears the "role" edge to the Role entity. -func (uru *UserRoleUpdate) ClearRole() *UserRoleUpdate { - uru.mutation.ClearRole() - return uru +func (_u *UserRoleUpdate) ClearRole() *UserRoleUpdate { + _u.mutation.ClearRole() + return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (uru *UserRoleUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, uru.sqlSave, uru.mutation, uru.hooks) +func (_u *UserRoleUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (uru *UserRoleUpdate) SaveX(ctx context.Context) int { - affected, err := uru.Save(ctx) +func (_u *UserRoleUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -100,58 +100,58 @@ func (uru *UserRoleUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (uru *UserRoleUpdate) Exec(ctx context.Context) error { - _, err := uru.Save(ctx) +func (_u *UserRoleUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (uru *UserRoleUpdate) ExecX(ctx context.Context) { - if err := uru.Exec(ctx); err != nil { +func (_u *UserRoleUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (uru *UserRoleUpdate) check() error { - if v, ok := uru.mutation.UserID(); ok { +func (_u *UserRoleUpdate) check() error { + if v, ok := _u.mutation.UserID(); ok { if err := userrole.UserIDValidator(v); err != nil { return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserRole.user_id": %w`, err)} } } - if v, ok := uru.mutation.RoleID(); ok { + if v, ok := _u.mutation.RoleID(); ok { if err := userrole.RoleIDValidator(v); err != nil { return &ValidationError{Name: "role_id", err: fmt.Errorf(`ent: validator failed for field "UserRole.role_id": %w`, err)} } } - if uru.mutation.UserCleared() && len(uru.mutation.UserIDs()) > 0 { + if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserRole.user"`) } - if uru.mutation.RoleCleared() && len(uru.mutation.RoleIDs()) > 0 { + if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserRole.role"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (uru *UserRoleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserRoleUpdate { - uru.modifiers = append(uru.modifiers, modifiers...) - return uru +func (_u *UserRoleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserRoleUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (uru *UserRoleUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := uru.check(); err != nil { - return n, err +func (_u *UserRoleUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(userrole.Table, userrole.Columns, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) - if ps := uru.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if uru.mutation.UserCleared() { + if _u.mutation.UserCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -164,7 +164,7 @@ func (uru *UserRoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uru.mutation.UserIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -180,7 +180,7 @@ func (uru *UserRoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uru.mutation.RoleCleared() { + if _u.mutation.RoleCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -193,7 +193,7 @@ func (uru *UserRoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uru.mutation.RoleIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -209,8 +209,8 @@ func (uru *UserRoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(uru.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, uru.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{userrole.Label} } else if sqlgraph.IsConstraintError(err) { @@ -218,8 +218,8 @@ func (uru *UserRoleUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - uru.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // UserRoleUpdateOne is the builder for updating a single UserRole entity. @@ -232,81 +232,81 @@ type UserRoleUpdateOne struct { } // SetUserID sets the "user_id" field. -func (uruo *UserRoleUpdateOne) SetUserID(i int64) *UserRoleUpdateOne { - uruo.mutation.SetUserID(i) - return uruo +func (_u *UserRoleUpdateOne) SetUserID(v int64) *UserRoleUpdateOne { + _u.mutation.SetUserID(v) + return _u } // SetNillableUserID sets the "user_id" field if the given value is not nil. -func (uruo *UserRoleUpdateOne) SetNillableUserID(i *int64) *UserRoleUpdateOne { - if i != nil { - uruo.SetUserID(*i) +func (_u *UserRoleUpdateOne) SetNillableUserID(v *int64) *UserRoleUpdateOne { + if v != nil { + _u.SetUserID(*v) } - return uruo + return _u } // SetRoleID sets the "role_id" field. -func (uruo *UserRoleUpdateOne) SetRoleID(i int64) *UserRoleUpdateOne { - uruo.mutation.SetRoleID(i) - return uruo +func (_u *UserRoleUpdateOne) SetRoleID(v int64) *UserRoleUpdateOne { + _u.mutation.SetRoleID(v) + return _u } // SetNillableRoleID sets the "role_id" field if the given value is not nil. -func (uruo *UserRoleUpdateOne) SetNillableRoleID(i *int64) *UserRoleUpdateOne { - if i != nil { - uruo.SetRoleID(*i) +func (_u *UserRoleUpdateOne) SetNillableRoleID(v *int64) *UserRoleUpdateOne { + if v != nil { + _u.SetRoleID(*v) } - return uruo + return _u } // SetUser sets the "user" edge to the User entity. -func (uruo *UserRoleUpdateOne) SetUser(u *User) *UserRoleUpdateOne { - return uruo.SetUserID(u.ID) +func (_u *UserRoleUpdateOne) SetUser(v *User) *UserRoleUpdateOne { + return _u.SetUserID(v.ID) } // SetRole sets the "role" edge to the Role entity. -func (uruo *UserRoleUpdateOne) SetRole(r *Role) *UserRoleUpdateOne { - return uruo.SetRoleID(r.ID) +func (_u *UserRoleUpdateOne) SetRole(v *Role) *UserRoleUpdateOne { + return _u.SetRoleID(v.ID) } // Mutation returns the UserRoleMutation object of the builder. -func (uruo *UserRoleUpdateOne) Mutation() *UserRoleMutation { - return uruo.mutation +func (_u *UserRoleUpdateOne) Mutation() *UserRoleMutation { + return _u.mutation } // ClearUser clears the "user" edge to the User entity. -func (uruo *UserRoleUpdateOne) ClearUser() *UserRoleUpdateOne { - uruo.mutation.ClearUser() - return uruo +func (_u *UserRoleUpdateOne) ClearUser() *UserRoleUpdateOne { + _u.mutation.ClearUser() + return _u } // ClearRole clears the "role" edge to the Role entity. -func (uruo *UserRoleUpdateOne) ClearRole() *UserRoleUpdateOne { - uruo.mutation.ClearRole() - return uruo +func (_u *UserRoleUpdateOne) ClearRole() *UserRoleUpdateOne { + _u.mutation.ClearRole() + return _u } // Where appends a list predicates to the UserRoleUpdate builder. -func (uruo *UserRoleUpdateOne) Where(ps ...predicate.UserRole) *UserRoleUpdateOne { - uruo.mutation.Where(ps...) - return uruo +func (_u *UserRoleUpdateOne) Where(ps ...predicate.UserRole) *UserRoleUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (uruo *UserRoleUpdateOne) Select(field string, fields ...string) *UserRoleUpdateOne { - uruo.fields = append([]string{field}, fields...) - return uruo +func (_u *UserRoleUpdateOne) Select(field string, fields ...string) *UserRoleUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated UserRole entity. -func (uruo *UserRoleUpdateOne) Save(ctx context.Context) (*UserRole, error) { - return withHooks(ctx, uruo.sqlSave, uruo.mutation, uruo.hooks) +func (_u *UserRoleUpdateOne) Save(ctx context.Context) (*UserRole, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (uruo *UserRoleUpdateOne) SaveX(ctx context.Context) *UserRole { - node, err := uruo.Save(ctx) +func (_u *UserRoleUpdateOne) SaveX(ctx context.Context) *UserRole { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -314,56 +314,56 @@ func (uruo *UserRoleUpdateOne) SaveX(ctx context.Context) *UserRole { } // Exec executes the query on the entity. -func (uruo *UserRoleUpdateOne) Exec(ctx context.Context) error { - _, err := uruo.Save(ctx) +func (_u *UserRoleUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (uruo *UserRoleUpdateOne) ExecX(ctx context.Context) { - if err := uruo.Exec(ctx); err != nil { +func (_u *UserRoleUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (uruo *UserRoleUpdateOne) check() error { - if v, ok := uruo.mutation.UserID(); ok { +func (_u *UserRoleUpdateOne) check() error { + if v, ok := _u.mutation.UserID(); ok { if err := userrole.UserIDValidator(v); err != nil { return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "UserRole.user_id": %w`, err)} } } - if v, ok := uruo.mutation.RoleID(); ok { + if v, ok := _u.mutation.RoleID(); ok { if err := userrole.RoleIDValidator(v); err != nil { return &ValidationError{Name: "role_id", err: fmt.Errorf(`ent: validator failed for field "UserRole.role_id": %w`, err)} } } - if uruo.mutation.UserCleared() && len(uruo.mutation.UserIDs()) > 0 { + if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserRole.user"`) } - if uruo.mutation.RoleCleared() && len(uruo.mutation.RoleIDs()) > 0 { + if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { return errors.New(`ent: clearing a required unique edge "UserRole.role"`) } return nil } // Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (uruo *UserRoleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserRoleUpdateOne { - uruo.modifiers = append(uruo.modifiers, modifiers...) - return uruo +func (_u *UserRoleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserRoleUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (uruo *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, err error) { - if err := uruo.check(); err != nil { +func (_u *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(userrole.Table, userrole.Columns, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) - id, ok := uruo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserRole.id" for update`)} } _spec.Node.ID.Value = id - if fields := uruo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, userrole.FieldID) for _, f := range fields { @@ -375,14 +375,14 @@ func (uruo *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, er } } } - if ps := uruo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if uruo.mutation.UserCleared() { + if _u.mutation.UserCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -395,7 +395,7 @@ func (uruo *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, er } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uruo.mutation.UserIDs(); len(nodes) > 0 { + if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -411,7 +411,7 @@ func (uruo *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, er } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if uruo.mutation.RoleCleared() { + if _u.mutation.RoleCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -424,7 +424,7 @@ func (uruo *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, er } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := uruo.mutation.RoleIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: false, @@ -440,11 +440,11 @@ func (uruo *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, er } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(uruo.modifiers...) - _node = &UserRole{config: uruo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &UserRole{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, uruo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{userrole.Label} } else if sqlgraph.IsConstraintError(err) { @@ -452,7 +452,7 @@ func (uruo *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, er } return nil, err } - uruo.mutation.done = true + _u.mutation.done = true return _node, nil } From abe16d8f26f2c01d55f8a8be41801ec7874c7825 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 12 Nov 2025 01:58:44 +0800 Subject: [PATCH 062/158] refactor(security): Rename PrincipalWithPrincipal to PrincipalWithContext and update comments --- internal/loader/load.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/loader/load.go b/internal/loader/load.go index ceada333..18cc8a6a 100644 --- a/internal/loader/load.go +++ b/internal/loader/load.go @@ -57,7 +57,7 @@ type InjectorClient struct { } //type Injector struct { -// Registrar registry.KRegistrar +// ServerRegistrar registry.KRegistrar // Registrars []service.ServerRegistrar //} From 9be5606d712c8c05319d4bb0dddba0df4ac3d312 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 3 Dec 2025 04:10:09 +0800 Subject: [PATCH 063/158] refactor(backend): consolidate config and bootstrap logic, update imports and remove deprecated consul components --- Makefile | 3 +- buf.yaml | 1 + cmd/internal/start/start.go | 121 +- cmd/root.go | 47 - cmd/system/main.go | 92 +- contrib/consul/config/config.go | 110 - contrib/consul/config/const.go | 38 - contrib/consul/registry/const.go | 73 - contrib/consul/registry/registry.go | 93 - contrib/database/database.go | 58 - contrib/database/drivers/const.go | 24 - contrib/database/drivers/everyone.go | 18 - contrib/database/drivers/mssql.go | 14 - contrib/database/drivers/mysql.go | 14 - contrib/database/drivers/pgx.go | 14 - contrib/database/drivers/postgres.go | 14 - contrib/database/drivers/sqlite3_cgo.go | 14 - contrib/database/drivers/sqlite3_go.go | 14 - contrib/database/internal/mysql/mysql.go | 48 - contrib/database/internal/sqlite/sqlite.go | 53 - contrib/security/authn/jwt/authn.go | 62 - contrib/security/authn/jwt/authn_test.go | 306 - contrib/security/authn/jwt/claims.go | 229 - contrib/security/authn/jwt/jwt.go | 295 - contrib/security/authn/jwt/option.go | 175 - contrib/security/authz/casbin/adapter.go | 184 - contrib/security/authz/casbin/casbin.go | 198 - .../casbin/internal/model/abac_model.conf | 11 - .../model/abac_not_using_policy_model.conf | 11 - .../internal/model/abac_rule_model.conf | 11 - .../casbin/internal/model/basic_model.conf | 11 - .../model/basic_model_without_spaces.conf | 11 - .../internal/model/basic_with_root_model.conf | 11 - .../model/basic_without_resources_model.conf | 11 - .../model/basic_without_users_model.conf | 11 - .../casbin/internal/model/comment_model.conf | 12 - .../authz/casbin/internal/model/embed.go | 78 - .../internal/model/eval_operator_model.conf | 11 - .../casbin/internal/model/glob_model.conf | 11 - .../casbin/internal/model/ipmatch_model.conf | 11 - .../casbin/internal/model/keyget2_model.conf | 11 - .../casbin/internal/model/keyget_model.conf | 11 - .../internal/model/keymatch2_model.conf | 11 - .../internal/model/keymatch_custom_model.conf | 11 - .../casbin/internal/model/keymatch_model.conf | 11 - .../model/keymatch_with_rbac_in_domain.conf | 14 - .../multiple_policy_definitions_model.conf | 19 - .../model/object_conditions_model.conf | 14 - .../casbin/internal/model/priority_model.conf | 14 - .../model/priority_model_enforce_context.conf | 16 - .../model/priority_model_explicit.conf | 14 - .../priority_model_explicit_customized.conf | 14 - .../casbin/internal/model/rbac_model.conf | 14 - .../model/rbac_model_in_multi_line.conf | 15 - .../model/rbac_model_matcher_using_in_op.conf | 14 - ...bac_model_matcher_using_in_op_bracket.conf | 14 - .../model/rbac_with_all_pattern_model.conf | 14 - .../internal/model/rbac_with_deny_model.conf | 14 - ...c_with_different_types_of_roles_model.conf | 15 - .../model/rbac_with_domain_pattern_model.conf | 14 - ...rbac_with_domain_temporal_roles_model.conf | 14 - .../internal/model/rbac_with_domains.conf | 14 - .../model/rbac_with_domains_model.conf | 14 - .../rbac_with_multiple_policy_model.conf | 17 - .../model/rbac_with_not_deny_model.conf | 14 - .../model/rbac_with_pattern_model.conf | 15 - .../model/rbac_with_resource_roles_model.conf | 15 - .../model/rbac_with_temporal_roles_model.conf | 14 - .../internal/model/restfull_with_role.conf | 14 - .../model/subject_priority_model.conf | 14 - .../subject_priority_model_with_domain.conf | 14 - .../policy/abac_rule_effect_policy.csv | 4 - .../internal/policy/abac_rule_policy.csv | 2 - .../internal/policy/basic_inverse_policy.csv | 2 - .../casbin/internal/policy/basic_policy.csv | 2 - .../policy/basic_without_resources_policy.csv | 2 - .../policy/basic_without_users_policy.csv | 2 - .../authz/casbin/internal/policy/embed.go | 51 - .../internal/policy/eval_operator_policy.csv | 1 - .../casbin/internal/policy/glob_policy.csv | 4 - .../casbin/internal/policy/ipmatch_policy.csv | 2 - .../internal/policy/keymatch2_policy.csv | 2 - .../internal/policy/keymatch_policy.csv | 7 - .../policy/keymatch_with_rbac_in_domain.csv | 6 - .../multiple_policy_definitions_policy.csv | 5 - .../policy/object_conditions_policy.csv | 5 - .../policy/priority_indeterminate_policy.csv | 1 - .../internal/policy/priority_policy.csv | 12 - .../priority_policy_enforce_context.csv | 12 - .../policy/priority_policy_explicit.csv | 12 - .../priority_policy_explicit_customized.csv | 12 - .../casbin/internal/policy/rbac_policy.csv | 5 - .../policy/rbac_with_all_pattern_policy.csv | 4 - .../internal/policy/rbac_with_deny_policy.csv | 7 - ...c_with_different_types_of_roles_policy.csv | 12 - .../rbac_with_domain_pattern_policy.csv | 8 - ...rbac_with_domain_temporal_roles_policy.csv | 24 - .../policy/rbac_with_domains_policy.csv | 6 - .../policy/rbac_with_domains_policy2.csv | 10 - .../policy/rbac_with_hierarchy_policy.csv | 10 - ...bac_with_hierarchy_with_domains_policy.csv | 11 - .../rbac_with_multiple_policy_policy.csv | 9 - .../policy/rbac_with_pattern_policy.csv | 28 - .../rbac_with_resource_roles_policy.csv | 7 - .../rbac_with_temporal_roles_policy.csv | 24 - .../policy/subject_priority_policy.csv | 16 - .../subject_priority_policy_with_domain.csv | 7 - contrib/security/authz/casbin/notifier.go | 56 - contrib/security/authz/casbin/option.go | 163 - contrib/security/authz/casbin/update.go | 135 - contrib/security/authz/casbin/watcher.go | 51 - contrib/security/token.go | 109 - contrib/security/token_metadata.go | 74 - contrib/security/token_transport.go | 61 - internal/{configs => conf/pb}/captcha.pb.go | 84 +- .../pb}/captcha.pb.validate.go | 16 +- internal/{configs => conf/pb}/captcha.proto | 11 +- internal/conf/pb/conf.pb.go | 225 + internal/conf/pb/conf.pb.validate.go | 382 ++ internal/conf/pb/conf.proto | 33 + .../root_user.pb.go => conf/pb/root.pb.go} | 60 +- .../pb/root.pb.validate.go} | 4 +- .../root_user.proto => conf/pb/root.proto} | 5 +- internal/configs/bootstrap.pb.go | 521 -- internal/configs/bootstrap.pb.validate.go | 923 --- internal/configs/bootstrap.proto | 89 - internal/configs/security_config.pb.go | 149 - .../configs/security_config.pb.validate.go | 223 - internal/configs/security_config.proto | 15 - internal/configs/server.pb.go | 179 - internal/configs/server.pb.validate.go | 254 - internal/configs/server.proto | 19 - internal/configs/service.pb.go | 297 - internal/configs/service.pb.validate.go | 586 -- internal/configs/service.proto | 29 - .../{mods => features}/auth/biz/README.md | 0 .../{mods => features}/auth/biz/auth.biz.go | 0 internal/{mods => features}/auth/biz/biz.go | 0 .../{mods => features}/auth/biz/casbin.biz.go | 0 .../auth/biz/casbin_stream.biz.go | 0 .../{mods => features}/auth/biz/login.biz.go | 0 .../auth/biz/personal.biz.go | 0 .../{mods => features}/auth/biz/provider.go | 0 .../{mods => features}/auth/dal/README.md | 0 .../{mods => features}/auth/dal/auth.dal.go | 0 .../{mods => features}/auth/dal/casbin.dal.go | 0 internal/{mods => features}/auth/dal/dal.go | 0 .../{mods => features}/auth/dal/login.dal.go | 0 .../auth/dal/personal.dal.go | 0 .../{mods => features}/auth/dal/provider.go | 0 .../{mods => features}/auth/dal/user.dal.go | 0 internal/{mods => features}/auth/dto/auth.go | 0 .../{mods => features}/auth/dto/casbin.go | 0 internal/{mods => features}/auth/dto/dto.go | 0 internal/{mods => features}/auth/dto/login.go | 0 .../{mods => features}/auth/dto/personal.go | 0 .../{mods => features}/auth/server/README.md | 0 .../{mods => features}/auth/server/gins.go | 0 .../{mods => features}/auth/server/grpc.go | 0 .../{mods => features}/auth/server/http.go | 0 .../{mods => features}/auth/server/server.go | 0 .../auth/service/auth.bridge.go | 0 .../auth/service/auth.grpc.go | 0 .../auth/service/auth.http.go | 0 .../auth/service/casbin.bridge.go | 0 .../{mods => features}/auth/service/casbin.go | 0 .../auth/service/casbin.grpc.go | 0 .../auth/service/casbin.http.go | 0 .../auth/service/login.bridge.go | 0 .../auth/service/login.grpc.go | 0 .../auth/service/login.http.go | 0 .../auth/service/personal.bridge.go | 0 .../auth/service/personal.grpc.go | 0 .../auth/service/personal.http.go | 0 .../auth/service/provider.go | 0 .../auth/service/service.go | 0 .../datastore/biz/README.md | 0 .../{mods => features}/datastore/biz/biz.go | 0 .../datastore/biz/datastore.go | 0 .../datastore/biz/provider.go | 0 .../datastore/dal/README.md | 0 .../{mods => features}/datastore/dal/dal.go | 0 .../datastore/dal/menu.dal.go | 0 .../datastore/dal/permission.dal.go | 0 .../datastore/dal/provider.go | 0 .../datastore/dal/resource.dal.go | 0 .../datastore/dal/role.dal.go | 0 .../datastore/dal/user.dal.go | 0 .../datastore/dto/README.md | 0 .../datastore/dto/department.go | 0 .../{mods => features}/datastore/dto/dto.go | 0 .../{mods => features}/datastore/dto/menu.go | 0 .../datastore/dto/permission.go | 0 .../datastore/dto/position.go | 0 .../datastore/dto/resource.go | 0 .../datastore/dto/resource_type.go | 0 .../{mods => features}/datastore/dto/role.go | 0 .../{mods => features}/datastore/dto/user.go | 0 .../datastore/server/README.md | 0 .../datastore/server/gins.go | 0 .../datastore/server/grpc.go | 0 .../datastore/server/http.go | 0 .../datastore/server/server.go | 0 .../datastore/service/README.md | 0 .../datastore/service/menu.bridge.go | 0 .../datastore/service/menu.grpc.go | 0 .../datastore/service/menu.http.go | 0 .../datastore/service/permission.bridge.go | 0 .../datastore/service/permission.grpc.go | 0 .../datastore/service/permission.http.go | 0 .../datastore/service/provider.go | 0 .../datastore/service/resource.bridge.go | 0 .../datastore/service/resource.grpc.go | 0 .../datastore/service/resource.http.go | 0 .../datastore/service/role.bridge.go | 0 .../datastore/service/role.grpc.go | 0 .../datastore/service/role.http.go | 0 .../datastore/service/service.go | 0 .../datastore/service/user.bridge.go | 0 .../datastore/service/user.grpc.go | 0 .../datastore/service/user.http.go | 0 .../{mods => features}/system/biz/README.md | 0 internal/{mods => features}/system/biz/biz.go | 0 .../system/biz/permission.biz.go | 0 .../{mods => features}/system/biz/provider.go | 0 .../system/biz/resource.biz.go | 0 .../{mods => features}/system/biz/role.biz.go | 0 .../{mods => features}/system/biz/user.biz.go | 0 .../{mods => features}/system/dal/README.md | 0 internal/{mods => features}/system/dal/dal.go | 0 .../{mods => features}/system/dal/menu.dal.go | 0 .../system/dal/permission.dal.go | 0 .../{mods => features}/system/dal/provider.go | 0 .../system/dal/resource.dal.go | 0 .../{mods => features}/system/dal/role.dal.go | 0 .../{mods => features}/system/dal/user.dal.go | 0 .../{mods => features}/system/dto/README.md | 0 .../system/dto/department.go | 0 internal/{mods => features}/system/dto/dto.go | 0 .../{mods => features}/system/dto/menu.go | 0 .../system/dto/permission.go | 0 .../{mods => features}/system/dto/position.go | 0 .../{mods => features}/system/dto/resource.go | 0 .../system/dto/resource_type.go | 0 .../{mods => features}/system/dto/role.go | 0 .../{mods => features}/system/dto/user.go | 0 .../system/server/README.md | 0 .../{mods => features}/system/server/gins.go | 0 .../{mods => features}/system/server/grpc.go | 0 .../{mods => features}/system/server/http.go | 0 .../system/server/server.go | 0 .../system/service/README.md | 0 .../system/service/menu.bridge.go | 0 .../system/service/menu.grpc.go | 0 .../system/service/menu.http.go | 0 .../system/service/permission.bridge.go | 0 .../system/service/permission.grpc.go | 0 .../system/service/permission.http.go | 0 .../system/service/provider.go | 0 .../system/service/resource.bridge.go | 0 .../system/service/resource.grpc.go | 0 .../system/service/resource.http.go | 0 .../system/service/role.bridge.go | 0 .../system/service/role.grpc.go | 0 .../system/service/role.http.go | 0 .../system/service/service.go | 0 .../system/service/user.bridge.go | 0 .../system/service/user.grpc.go | 0 .../system/service/user.http.go | 0 internal/{mods => }/gateway/proxy.go | 0 internal/generate.go | 4 +- .../helpers}/base64image/base64image.go | 0 .../helpers}/base64image/base64image_test.go | 0 .../helpers}/captcha/captcha.go | 0 .../helpers}/command/lower.go | 0 {helpers => internal/helpers}/db/db.go | 0 .../helpers}/ent/mixin/field.go | 0 .../helpers}/ent/mixin/mixin.go | 0 .../helpers}/ent/mixin/mixin_id.go | 0 .../helpers}/ent/mixin/mixin_uuid.go | 0 {helpers => internal/helpers}/ent/size.go | 0 .../helpers}/errors/config.go | 0 .../helpers}/errors/errors.go | 0 {helpers => internal/helpers}/errors/start.go | 0 .../helpers}/generic/convert.go | 0 {helpers => internal/helpers}/i18n/i18n.go | 0 .../helpers}/i18n/i18n_test.go | 0 {helpers => internal/helpers}/id/gen.go | 0 .../helpers}/protobuf/duration/duration.go | 0 .../helpers}/resp/data/v1/data.pb.go | 0 .../helpers}/resp/data/v1/data.proto | 0 {helpers => internal/helpers}/resp/error.go | 0 {helpers => internal/helpers}/resp/marshal.go | 0 {helpers => internal/helpers}/resp/resp.go | 0 {helpers => internal/helpers}/resp/result.go | 0 .../helpers}/securityx/auth.go | 0 .../helpers}/securityx/security.go | 0 .../helpers}/securityx/user.go | 0 {helpers => internal/helpers}/time/time.go | 0 internal/loader/application.go | 30 - internal/loader/bootstrap.go | 124 - internal/loader/bootstrap_default.go | 452 -- internal/loader/bootstrap_test.go | 360 -- internal/loader/config.go | 38 - internal/loader/config_test.go | 79 - internal/loader/const.go | 36 - internal/loader/environment.go | 22 - internal/loader/file.go | 137 - internal/loader/load.go | 89 - internal/loader/provider.go | 14 - internal/loader/registry.go | 39 - internal/loader/service_test.go | 251 - main.go | 66 - third_party/auth/v1/auth.proto | 42 - third_party/buf/validate/validate.proto | 4952 ----------------- third_party/config/v1/cors.proto | 45 - third_party/config/v1/customize.proto | 31 - third_party/config/v1/discovery.proto | 53 - third_party/config/v1/gateway.proto | 103 - third_party/config/v1/logger.proto | 83 - third_party/config/v1/mail.proto | 26 - third_party/config/v1/message.proto | 104 - third_party/config/v1/security.proto | 168 - third_party/config/v1/service.proto | 79 - third_party/config/v1/source.proto | 82 - third_party/config/v1/storage.proto | 368 -- third_party/config/v1/task.proto | 49 - third_party/config/v1/tlsconfig.proto | 28 - third_party/config/v1/tracer.proto | 18 - third_party/config/v1/websocket.proto | 18 - third_party/errors/errors.proto | 18 - third_party/errors/rpcerr/rpcerr.proto | 18 - third_party/fileupload/v1/fileupload.proto | 115 - .../gnostic/discovery/v1/discovery.proto | 269 - .../gnostic/openapi/v2/openapiv2.proto | 665 --- .../gnostic/openapi/v3/annotations.proto | 60 - .../gnostic/openapi/v3/openapiv3.proto | 671 --- third_party/google/api/annotations.proto | 31 - third_party/google/api/client.proto | 486 -- .../google/api/expr/v1alpha1/checked.proto | 343 -- .../google/api/expr/v1alpha1/eval.proto | 118 - .../google/api/expr/v1alpha1/explain.proto | 53 - .../google/api/expr/v1alpha1/syntax.proto | 438 -- .../google/api/expr/v1alpha1/value.proto | 115 - .../google/api/expr/v1beta1/decl.proto | 84 - .../google/api/expr/v1beta1/eval.proto | 125 - .../google/api/expr/v1beta1/expr.proto | 265 - .../google/api/expr/v1beta1/source.proto | 62 - .../google/api/expr/v1beta1/value.proto | 114 - third_party/google/api/field_behavior.proto | 104 - third_party/google/api/field_info.proto | 106 - third_party/google/api/http.proto | 370 -- third_party/google/api/httpbody.proto | 80 - third_party/google/api/launch_stage.proto | 72 - third_party/google/api/resource.proto | 242 - third_party/google/api/visibility.proto | 112 - .../google/bytestream/bytestream.proto | 178 - third_party/google/geo/type/viewport.proto | 69 - .../google/longrunning/operations.proto | 246 - third_party/google/protobuf/any.proto | 162 - third_party/google/protobuf/api.proto | 207 - .../google/protobuf/compiler/plugin.proto | 180 - .../google/protobuf/cpp_features.proto | 67 - third_party/google/protobuf/descriptor.proto | 1417 ----- third_party/google/protobuf/duration.proto | 115 - third_party/google/protobuf/empty.proto | 51 - third_party/google/protobuf/field_mask.proto | 245 - third_party/google/protobuf/go_features.proto | 80 - .../google/protobuf/java_features.proto | 130 - .../google/protobuf/source_context.proto | 48 - third_party/google/protobuf/struct.proto | 95 - third_party/google/protobuf/timestamp.proto | 144 - third_party/google/protobuf/type.proto | 193 - third_party/google/protobuf/wrappers.proto | 157 - third_party/google/rpc/code.proto | 186 - .../rpc/context/attribute_context.proto | 345 -- third_party/google/rpc/error_details.proto | 363 -- third_party/google/rpc/status.proto | 49 - third_party/google/type/calendar_period.proto | 56 - third_party/google/type/color.proto | 174 - third_party/google/type/date.proto | 52 - third_party/google/type/datetime.proto | 104 - third_party/google/type/dayofweek.proto | 50 - third_party/google/type/decimal.proto | 95 - third_party/google/type/expr.proto | 73 - third_party/google/type/fraction.proto | 33 - third_party/google/type/interval.proto | 46 - third_party/google/type/latlng.proto | 37 - third_party/google/type/localized_text.proto | 36 - third_party/google/type/money.proto | 42 - third_party/google/type/month.proto | 65 - third_party/google/type/phone_number.proto | 113 - third_party/google/type/postal_address.proto | 134 - third_party/google/type/quaternion.proto | 94 - third_party/google/type/timeofday.proto | 44 - .../circuitbreaker/v1/circuitbreaker.proto | 49 - third_party/middleware/jwt/v1/jwt.proto | 30 - .../middleware/metrics/v1/metrics.proto | 59 - .../middleware/ratelimit/v1/ratelimiter.proto | 55 - .../middleware/selector/v1/selector.proto | 24 - .../v1/circuitbreaker/circuitbreaker.proto | 48 - third_party/middleware/v1/jwt/jwt.proto | 37 - .../middleware/v1/metrics/metrics.proto | 57 - third_party/middleware/v1/middleware.proto | 91 - .../middleware/v1/ratelimit/ratelimiter.proto | 53 - .../middleware/v1/selector/selector.proto | 20 - .../middleware/v1/validator/validator.proto | 25 - .../middleware/validator/v1/validator.proto | 26 - third_party/options/opts.proto | 45 - third_party/pagination/v1/pagination.proto | 102 - third_party/security/casbin/v1/policy.proto | 41 - third_party/security/jwt/v1/config.proto | 77 - third_party/security/jwt/v1/token.proto | 42 - third_party/security/v1/auth.proto | 274 - third_party/security/v1/error.proto | 41 - third_party/validate/validate.proto | 862 --- 416 files changed, 874 insertions(+), 28328 deletions(-) delete mode 100644 cmd/root.go delete mode 100644 contrib/consul/config/config.go delete mode 100644 contrib/consul/config/const.go delete mode 100644 contrib/consul/registry/const.go delete mode 100644 contrib/consul/registry/registry.go delete mode 100644 contrib/database/database.go delete mode 100644 contrib/database/drivers/const.go delete mode 100644 contrib/database/drivers/everyone.go delete mode 100644 contrib/database/drivers/mssql.go delete mode 100644 contrib/database/drivers/mysql.go delete mode 100644 contrib/database/drivers/pgx.go delete mode 100644 contrib/database/drivers/postgres.go delete mode 100644 contrib/database/drivers/sqlite3_cgo.go delete mode 100644 contrib/database/drivers/sqlite3_go.go delete mode 100644 contrib/database/internal/mysql/mysql.go delete mode 100644 contrib/database/internal/sqlite/sqlite.go delete mode 100644 contrib/security/authn/jwt/authn.go delete mode 100644 contrib/security/authn/jwt/authn_test.go delete mode 100644 contrib/security/authn/jwt/claims.go delete mode 100644 contrib/security/authn/jwt/jwt.go delete mode 100644 contrib/security/authn/jwt/option.go delete mode 100644 contrib/security/authz/casbin/adapter.go delete mode 100644 contrib/security/authz/casbin/casbin.go delete mode 100644 contrib/security/authz/casbin/internal/model/abac_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/abac_not_using_policy_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/abac_rule_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/basic_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/basic_model_without_spaces.conf delete mode 100644 contrib/security/authz/casbin/internal/model/basic_with_root_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/basic_without_resources_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/basic_without_users_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/comment_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/embed.go delete mode 100644 contrib/security/authz/casbin/internal/model/eval_operator_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/glob_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/ipmatch_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/keyget2_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/keyget_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/keymatch2_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/keymatch_custom_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/keymatch_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/keymatch_with_rbac_in_domain.conf delete mode 100644 contrib/security/authz/casbin/internal/model/multiple_policy_definitions_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/object_conditions_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/priority_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/priority_model_enforce_context.conf delete mode 100644 contrib/security/authz/casbin/internal/model/priority_model_explicit.conf delete mode 100644 contrib/security/authz/casbin/internal/model/priority_model_explicit_customized.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_model_in_multi_line.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_model_matcher_using_in_op.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_model_matcher_using_in_op_bracket.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_all_pattern_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_deny_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_different_types_of_roles_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_domain_pattern_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_domain_temporal_roles_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_domains.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_domains_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_multiple_policy_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_not_deny_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_pattern_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_resource_roles_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/rbac_with_temporal_roles_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/restfull_with_role.conf delete mode 100644 contrib/security/authz/casbin/internal/model/subject_priority_model.conf delete mode 100644 contrib/security/authz/casbin/internal/model/subject_priority_model_with_domain.conf delete mode 100644 contrib/security/authz/casbin/internal/policy/abac_rule_effect_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/abac_rule_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/basic_inverse_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/basic_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/basic_without_resources_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/basic_without_users_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/embed.go delete mode 100644 contrib/security/authz/casbin/internal/policy/eval_operator_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/glob_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/ipmatch_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/keymatch2_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/keymatch_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/keymatch_with_rbac_in_domain.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/multiple_policy_definitions_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/object_conditions_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/priority_indeterminate_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/priority_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/priority_policy_enforce_context.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/priority_policy_explicit.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/priority_policy_explicit_customized.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_all_pattern_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_deny_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_different_types_of_roles_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_domain_pattern_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_domain_temporal_roles_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_domains_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_domains_policy2.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_hierarchy_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_hierarchy_with_domains_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_multiple_policy_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_pattern_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_resource_roles_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/rbac_with_temporal_roles_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/subject_priority_policy.csv delete mode 100644 contrib/security/authz/casbin/internal/policy/subject_priority_policy_with_domain.csv delete mode 100644 contrib/security/authz/casbin/notifier.go delete mode 100644 contrib/security/authz/casbin/option.go delete mode 100644 contrib/security/authz/casbin/update.go delete mode 100644 contrib/security/authz/casbin/watcher.go delete mode 100644 contrib/security/token.go delete mode 100644 contrib/security/token_metadata.go delete mode 100644 contrib/security/token_transport.go rename internal/{configs => conf/pb}/captcha.pb.go (51%) rename internal/{configs => conf/pb}/captcha.pb.validate.go (92%) rename internal/{configs => conf/pb}/captcha.proto (69%) create mode 100644 internal/conf/pb/conf.pb.go create mode 100644 internal/conf/pb/conf.pb.validate.go create mode 100644 internal/conf/pb/conf.proto rename internal/{configs/root_user.pb.go => conf/pb/root.pb.go} (74%) rename internal/{configs/root_user.pb.validate.go => conf/pb/root.pb.validate.go} (98%) rename internal/{configs/root_user.proto => conf/pb/root.proto} (91%) delete mode 100644 internal/configs/bootstrap.pb.go delete mode 100644 internal/configs/bootstrap.pb.validate.go delete mode 100644 internal/configs/bootstrap.proto delete mode 100644 internal/configs/security_config.pb.go delete mode 100644 internal/configs/security_config.pb.validate.go delete mode 100644 internal/configs/security_config.proto delete mode 100644 internal/configs/server.pb.go delete mode 100644 internal/configs/server.pb.validate.go delete mode 100644 internal/configs/server.proto delete mode 100644 internal/configs/service.pb.go delete mode 100644 internal/configs/service.pb.validate.go delete mode 100644 internal/configs/service.proto rename internal/{mods => features}/auth/biz/README.md (100%) rename internal/{mods => features}/auth/biz/auth.biz.go (100%) rename internal/{mods => features}/auth/biz/biz.go (100%) rename internal/{mods => features}/auth/biz/casbin.biz.go (100%) rename internal/{mods => features}/auth/biz/casbin_stream.biz.go (100%) rename internal/{mods => features}/auth/biz/login.biz.go (100%) rename internal/{mods => features}/auth/biz/personal.biz.go (100%) rename internal/{mods => features}/auth/biz/provider.go (100%) rename internal/{mods => features}/auth/dal/README.md (100%) rename internal/{mods => features}/auth/dal/auth.dal.go (100%) rename internal/{mods => features}/auth/dal/casbin.dal.go (100%) rename internal/{mods => features}/auth/dal/dal.go (100%) rename internal/{mods => features}/auth/dal/login.dal.go (100%) rename internal/{mods => features}/auth/dal/personal.dal.go (100%) rename internal/{mods => features}/auth/dal/provider.go (100%) rename internal/{mods => features}/auth/dal/user.dal.go (100%) rename internal/{mods => features}/auth/dto/auth.go (100%) rename internal/{mods => features}/auth/dto/casbin.go (100%) rename internal/{mods => features}/auth/dto/dto.go (100%) rename internal/{mods => features}/auth/dto/login.go (100%) rename internal/{mods => features}/auth/dto/personal.go (100%) rename internal/{mods => features}/auth/server/README.md (100%) rename internal/{mods => features}/auth/server/gins.go (100%) rename internal/{mods => features}/auth/server/grpc.go (100%) rename internal/{mods => features}/auth/server/http.go (100%) rename internal/{mods => features}/auth/server/server.go (100%) rename internal/{mods => features}/auth/service/auth.bridge.go (100%) rename internal/{mods => features}/auth/service/auth.grpc.go (100%) rename internal/{mods => features}/auth/service/auth.http.go (100%) rename internal/{mods => features}/auth/service/casbin.bridge.go (100%) rename internal/{mods => features}/auth/service/casbin.go (100%) rename internal/{mods => features}/auth/service/casbin.grpc.go (100%) rename internal/{mods => features}/auth/service/casbin.http.go (100%) rename internal/{mods => features}/auth/service/login.bridge.go (100%) rename internal/{mods => features}/auth/service/login.grpc.go (100%) rename internal/{mods => features}/auth/service/login.http.go (100%) rename internal/{mods => features}/auth/service/personal.bridge.go (100%) rename internal/{mods => features}/auth/service/personal.grpc.go (100%) rename internal/{mods => features}/auth/service/personal.http.go (100%) rename internal/{mods => features}/auth/service/provider.go (100%) rename internal/{mods => features}/auth/service/service.go (100%) rename internal/{mods => features}/datastore/biz/README.md (100%) rename internal/{mods => features}/datastore/biz/biz.go (100%) rename internal/{mods => features}/datastore/biz/datastore.go (100%) rename internal/{mods => features}/datastore/biz/provider.go (100%) rename internal/{mods => features}/datastore/dal/README.md (100%) rename internal/{mods => features}/datastore/dal/dal.go (100%) rename internal/{mods => features}/datastore/dal/menu.dal.go (100%) rename internal/{mods => features}/datastore/dal/permission.dal.go (100%) rename internal/{mods => features}/datastore/dal/provider.go (100%) rename internal/{mods => features}/datastore/dal/resource.dal.go (100%) rename internal/{mods => features}/datastore/dal/role.dal.go (100%) rename internal/{mods => features}/datastore/dal/user.dal.go (100%) rename internal/{mods => features}/datastore/dto/README.md (100%) rename internal/{mods => features}/datastore/dto/department.go (100%) rename internal/{mods => features}/datastore/dto/dto.go (100%) rename internal/{mods => features}/datastore/dto/menu.go (100%) rename internal/{mods => features}/datastore/dto/permission.go (100%) rename internal/{mods => features}/datastore/dto/position.go (100%) rename internal/{mods => features}/datastore/dto/resource.go (100%) rename internal/{mods => features}/datastore/dto/resource_type.go (100%) rename internal/{mods => features}/datastore/dto/role.go (100%) rename internal/{mods => features}/datastore/dto/user.go (100%) rename internal/{mods => features}/datastore/server/README.md (100%) rename internal/{mods => features}/datastore/server/gins.go (100%) rename internal/{mods => features}/datastore/server/grpc.go (100%) rename internal/{mods => features}/datastore/server/http.go (100%) rename internal/{mods => features}/datastore/server/server.go (100%) rename internal/{mods => features}/datastore/service/README.md (100%) rename internal/{mods => features}/datastore/service/menu.bridge.go (100%) rename internal/{mods => features}/datastore/service/menu.grpc.go (100%) rename internal/{mods => features}/datastore/service/menu.http.go (100%) rename internal/{mods => features}/datastore/service/permission.bridge.go (100%) rename internal/{mods => features}/datastore/service/permission.grpc.go (100%) rename internal/{mods => features}/datastore/service/permission.http.go (100%) rename internal/{mods => features}/datastore/service/provider.go (100%) rename internal/{mods => features}/datastore/service/resource.bridge.go (100%) rename internal/{mods => features}/datastore/service/resource.grpc.go (100%) rename internal/{mods => features}/datastore/service/resource.http.go (100%) rename internal/{mods => features}/datastore/service/role.bridge.go (100%) rename internal/{mods => features}/datastore/service/role.grpc.go (100%) rename internal/{mods => features}/datastore/service/role.http.go (100%) rename internal/{mods => features}/datastore/service/service.go (100%) rename internal/{mods => features}/datastore/service/user.bridge.go (100%) rename internal/{mods => features}/datastore/service/user.grpc.go (100%) rename internal/{mods => features}/datastore/service/user.http.go (100%) rename internal/{mods => features}/system/biz/README.md (100%) rename internal/{mods => features}/system/biz/biz.go (100%) rename internal/{mods => features}/system/biz/permission.biz.go (100%) rename internal/{mods => features}/system/biz/provider.go (100%) rename internal/{mods => features}/system/biz/resource.biz.go (100%) rename internal/{mods => features}/system/biz/role.biz.go (100%) rename internal/{mods => features}/system/biz/user.biz.go (100%) rename internal/{mods => features}/system/dal/README.md (100%) rename internal/{mods => features}/system/dal/dal.go (100%) rename internal/{mods => features}/system/dal/menu.dal.go (100%) rename internal/{mods => features}/system/dal/permission.dal.go (100%) rename internal/{mods => features}/system/dal/provider.go (100%) rename internal/{mods => features}/system/dal/resource.dal.go (100%) rename internal/{mods => features}/system/dal/role.dal.go (100%) rename internal/{mods => features}/system/dal/user.dal.go (100%) rename internal/{mods => features}/system/dto/README.md (100%) rename internal/{mods => features}/system/dto/department.go (100%) rename internal/{mods => features}/system/dto/dto.go (100%) rename internal/{mods => features}/system/dto/menu.go (100%) rename internal/{mods => features}/system/dto/permission.go (100%) rename internal/{mods => features}/system/dto/position.go (100%) rename internal/{mods => features}/system/dto/resource.go (100%) rename internal/{mods => features}/system/dto/resource_type.go (100%) rename internal/{mods => features}/system/dto/role.go (100%) rename internal/{mods => features}/system/dto/user.go (100%) rename internal/{mods => features}/system/server/README.md (100%) rename internal/{mods => features}/system/server/gins.go (100%) rename internal/{mods => features}/system/server/grpc.go (100%) rename internal/{mods => features}/system/server/http.go (100%) rename internal/{mods => features}/system/server/server.go (100%) rename internal/{mods => features}/system/service/README.md (100%) rename internal/{mods => features}/system/service/menu.bridge.go (100%) rename internal/{mods => features}/system/service/menu.grpc.go (100%) rename internal/{mods => features}/system/service/menu.http.go (100%) rename internal/{mods => features}/system/service/permission.bridge.go (100%) rename internal/{mods => features}/system/service/permission.grpc.go (100%) rename internal/{mods => features}/system/service/permission.http.go (100%) rename internal/{mods => features}/system/service/provider.go (100%) rename internal/{mods => features}/system/service/resource.bridge.go (100%) rename internal/{mods => features}/system/service/resource.grpc.go (100%) rename internal/{mods => features}/system/service/resource.http.go (100%) rename internal/{mods => features}/system/service/role.bridge.go (100%) rename internal/{mods => features}/system/service/role.grpc.go (100%) rename internal/{mods => features}/system/service/role.http.go (100%) rename internal/{mods => features}/system/service/service.go (100%) rename internal/{mods => features}/system/service/user.bridge.go (100%) rename internal/{mods => features}/system/service/user.grpc.go (100%) rename internal/{mods => features}/system/service/user.http.go (100%) rename internal/{mods => }/gateway/proxy.go (100%) rename {helpers => internal/helpers}/base64image/base64image.go (100%) rename {helpers => internal/helpers}/base64image/base64image_test.go (100%) rename {helpers => internal/helpers}/captcha/captcha.go (100%) rename {helpers => internal/helpers}/command/lower.go (100%) rename {helpers => internal/helpers}/db/db.go (100%) rename {helpers => internal/helpers}/ent/mixin/field.go (100%) rename {helpers => internal/helpers}/ent/mixin/mixin.go (100%) rename {helpers => internal/helpers}/ent/mixin/mixin_id.go (100%) rename {helpers => internal/helpers}/ent/mixin/mixin_uuid.go (100%) rename {helpers => internal/helpers}/ent/size.go (100%) rename {helpers => internal/helpers}/errors/config.go (100%) rename {helpers => internal/helpers}/errors/errors.go (100%) rename {helpers => internal/helpers}/errors/start.go (100%) rename {helpers => internal/helpers}/generic/convert.go (100%) rename {helpers => internal/helpers}/i18n/i18n.go (100%) rename {helpers => internal/helpers}/i18n/i18n_test.go (100%) rename {helpers => internal/helpers}/id/gen.go (100%) rename {helpers => internal/helpers}/protobuf/duration/duration.go (100%) rename {helpers => internal/helpers}/resp/data/v1/data.pb.go (100%) rename {helpers => internal/helpers}/resp/data/v1/data.proto (100%) rename {helpers => internal/helpers}/resp/error.go (100%) rename {helpers => internal/helpers}/resp/marshal.go (100%) rename {helpers => internal/helpers}/resp/resp.go (100%) rename {helpers => internal/helpers}/resp/result.go (100%) rename {helpers => internal/helpers}/securityx/auth.go (100%) rename {helpers => internal/helpers}/securityx/security.go (100%) rename {helpers => internal/helpers}/securityx/user.go (100%) rename {helpers => internal/helpers}/time/time.go (100%) delete mode 100644 internal/loader/application.go delete mode 100644 internal/loader/bootstrap.go delete mode 100644 internal/loader/bootstrap_default.go delete mode 100644 internal/loader/bootstrap_test.go delete mode 100644 internal/loader/config.go delete mode 100644 internal/loader/config_test.go delete mode 100644 internal/loader/const.go delete mode 100644 internal/loader/environment.go delete mode 100644 internal/loader/file.go delete mode 100644 internal/loader/load.go delete mode 100644 internal/loader/provider.go delete mode 100644 internal/loader/registry.go delete mode 100644 internal/loader/service_test.go delete mode 100644 main.go delete mode 100644 third_party/auth/v1/auth.proto delete mode 100644 third_party/buf/validate/validate.proto delete mode 100644 third_party/config/v1/cors.proto delete mode 100644 third_party/config/v1/customize.proto delete mode 100644 third_party/config/v1/discovery.proto delete mode 100644 third_party/config/v1/gateway.proto delete mode 100644 third_party/config/v1/logger.proto delete mode 100644 third_party/config/v1/mail.proto delete mode 100644 third_party/config/v1/message.proto delete mode 100644 third_party/config/v1/security.proto delete mode 100644 third_party/config/v1/service.proto delete mode 100644 third_party/config/v1/source.proto delete mode 100644 third_party/config/v1/storage.proto delete mode 100644 third_party/config/v1/task.proto delete mode 100644 third_party/config/v1/tlsconfig.proto delete mode 100644 third_party/config/v1/tracer.proto delete mode 100644 third_party/config/v1/websocket.proto delete mode 100644 third_party/errors/errors.proto delete mode 100644 third_party/errors/rpcerr/rpcerr.proto delete mode 100644 third_party/fileupload/v1/fileupload.proto delete mode 100644 third_party/gnostic/discovery/v1/discovery.proto delete mode 100644 third_party/gnostic/openapi/v2/openapiv2.proto delete mode 100644 third_party/gnostic/openapi/v3/annotations.proto delete mode 100644 third_party/gnostic/openapi/v3/openapiv3.proto delete mode 100644 third_party/google/api/annotations.proto delete mode 100644 third_party/google/api/client.proto delete mode 100644 third_party/google/api/expr/v1alpha1/checked.proto delete mode 100644 third_party/google/api/expr/v1alpha1/eval.proto delete mode 100644 third_party/google/api/expr/v1alpha1/explain.proto delete mode 100644 third_party/google/api/expr/v1alpha1/syntax.proto delete mode 100644 third_party/google/api/expr/v1alpha1/value.proto delete mode 100644 third_party/google/api/expr/v1beta1/decl.proto delete mode 100644 third_party/google/api/expr/v1beta1/eval.proto delete mode 100644 third_party/google/api/expr/v1beta1/expr.proto delete mode 100644 third_party/google/api/expr/v1beta1/source.proto delete mode 100644 third_party/google/api/expr/v1beta1/value.proto delete mode 100644 third_party/google/api/field_behavior.proto delete mode 100644 third_party/google/api/field_info.proto delete mode 100644 third_party/google/api/http.proto delete mode 100644 third_party/google/api/httpbody.proto delete mode 100644 third_party/google/api/launch_stage.proto delete mode 100644 third_party/google/api/resource.proto delete mode 100644 third_party/google/api/visibility.proto delete mode 100644 third_party/google/bytestream/bytestream.proto delete mode 100644 third_party/google/geo/type/viewport.proto delete mode 100644 third_party/google/longrunning/operations.proto delete mode 100644 third_party/google/protobuf/any.proto delete mode 100644 third_party/google/protobuf/api.proto delete mode 100644 third_party/google/protobuf/compiler/plugin.proto delete mode 100644 third_party/google/protobuf/cpp_features.proto delete mode 100644 third_party/google/protobuf/descriptor.proto delete mode 100644 third_party/google/protobuf/duration.proto delete mode 100644 third_party/google/protobuf/empty.proto delete mode 100644 third_party/google/protobuf/field_mask.proto delete mode 100644 third_party/google/protobuf/go_features.proto delete mode 100644 third_party/google/protobuf/java_features.proto delete mode 100644 third_party/google/protobuf/source_context.proto delete mode 100644 third_party/google/protobuf/struct.proto delete mode 100644 third_party/google/protobuf/timestamp.proto delete mode 100644 third_party/google/protobuf/type.proto delete mode 100644 third_party/google/protobuf/wrappers.proto delete mode 100644 third_party/google/rpc/code.proto delete mode 100644 third_party/google/rpc/context/attribute_context.proto delete mode 100644 third_party/google/rpc/error_details.proto delete mode 100644 third_party/google/rpc/status.proto delete mode 100644 third_party/google/type/calendar_period.proto delete mode 100644 third_party/google/type/color.proto delete mode 100644 third_party/google/type/date.proto delete mode 100644 third_party/google/type/datetime.proto delete mode 100644 third_party/google/type/dayofweek.proto delete mode 100644 third_party/google/type/decimal.proto delete mode 100644 third_party/google/type/expr.proto delete mode 100644 third_party/google/type/fraction.proto delete mode 100644 third_party/google/type/interval.proto delete mode 100644 third_party/google/type/latlng.proto delete mode 100644 third_party/google/type/localized_text.proto delete mode 100644 third_party/google/type/money.proto delete mode 100644 third_party/google/type/month.proto delete mode 100644 third_party/google/type/phone_number.proto delete mode 100644 third_party/google/type/postal_address.proto delete mode 100644 third_party/google/type/quaternion.proto delete mode 100644 third_party/google/type/timeofday.proto delete mode 100644 third_party/middleware/circuitbreaker/v1/circuitbreaker.proto delete mode 100644 third_party/middleware/jwt/v1/jwt.proto delete mode 100644 third_party/middleware/metrics/v1/metrics.proto delete mode 100644 third_party/middleware/ratelimit/v1/ratelimiter.proto delete mode 100644 third_party/middleware/selector/v1/selector.proto delete mode 100644 third_party/middleware/v1/circuitbreaker/circuitbreaker.proto delete mode 100644 third_party/middleware/v1/jwt/jwt.proto delete mode 100644 third_party/middleware/v1/metrics/metrics.proto delete mode 100644 third_party/middleware/v1/middleware.proto delete mode 100644 third_party/middleware/v1/ratelimit/ratelimiter.proto delete mode 100644 third_party/middleware/v1/selector/selector.proto delete mode 100644 third_party/middleware/v1/validator/validator.proto delete mode 100644 third_party/middleware/validator/v1/validator.proto delete mode 100644 third_party/options/opts.proto delete mode 100644 third_party/pagination/v1/pagination.proto delete mode 100644 third_party/security/casbin/v1/policy.proto delete mode 100644 third_party/security/jwt/v1/config.proto delete mode 100644 third_party/security/jwt/v1/token.proto delete mode 100644 third_party/security/v1/auth.proto delete mode 100644 third_party/security/v1/error.proto delete mode 100644 third_party/validate/validate.proto diff --git a/Makefile b/Makefile index 0610624c..bff7717e 100644 --- a/Makefile +++ b/Makefile @@ -96,9 +96,8 @@ deps: buf export buf.build/envoyproxy/protoc-gen-validate -o $(THIRD_PARTY_PATH) buf export buf.build/gnostic/gnostic -o $(THIRD_PARTY_PATH) buf export buf.build/kratos/apis -o $(THIRD_PARTY_PATH) - buf export buf.build/origadmin/rpcerr -o $(THIRD_PARTY_PATH) buf export buf.build/origadmin/runtime -o $(THIRD_PARTY_PATH) - buf export buf.build/origadmin/entgen -o $(THIRD_PARTY_PATH) + buf export buf.build/origadmin/contrib -o $(THIRD_PARTY_PATH) .PHONY: config # generate internal proto or use ./internal/generate.go diff --git a/buf.yaml b/buf.yaml index 9fc6b181..c2b5ce07 100644 --- a/buf.yaml +++ b/buf.yaml @@ -23,6 +23,7 @@ deps: - buf.build/googleapis/googleapis - buf.build/gnostic/gnostic - buf.build/origadmin/runtime + - buf.build/origadmin/contrib # - buf.build/bufbuild/protovalidate # - buf.build/origadmin/rpcerr # - buf.build/origadmin/entgen \ No newline at end of file diff --git a/cmd/internal/start/start.go b/cmd/internal/start/start.go index ac075132..178fd305 100644 --- a/cmd/internal/start/start.go +++ b/cmd/internal/start/start.go @@ -6,23 +6,28 @@ package start import ( + "context" + "fmt" "log/slog" "github.com/go-kratos/kratos/v2" "github.com/go-kratos/kratos/v2/encoding" - "github.com/go-kratos/kratos/v2/transport" + "github.com/go-kratos/kratos/v2/middleware/tracing" + "github.com/goexts/generic/cmp" "github.com/origadmin/runtime" + configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" + middlewarev1 "github.com/origadmin/runtime/api/gen/go/middleware/v1" "github.com/origadmin/runtime/bootstrap" + "github.com/origadmin/runtime/config" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/codec/toml" "github.com/spf13/cobra" - _ "origadmin/application/admin/contrib/consul/config" - _ "origadmin/application/admin/contrib/consul/registry" - _ "origadmin/application/admin/contrib/database/drivers" - "origadmin/application/admin/internal/configs" - _ "origadmin/application/admin/internal/data/entity/ent/runtime" - "origadmin/application/admin/internal/loader" + // _ "origadmin/application/admin/contrib/consul/config" // Removed + // _ "origadmin/application/admin/contrib/consul/registry" // Removed + // _ "origadmin/application/admin/contrib/database/drivers" // Removed + _ "github.com/origadmin/backend/internal/data/entity/ent/runtime" // Updated import + "github.com/origadmin/backend/internal/conf" // Updated import ) const ( @@ -66,6 +71,61 @@ func Cmd() *cobra.Command { return cmd } +// ResolvedBootstrap implements config.Resolver for the application's bootstrap configuration. +type ResolvedBootstrap struct { + bootstrap *conf.Bootstrap +} + +// FillServiceInfo populates service information into the bootstrap flags. +func (r *ResolvedBootstrap) FillServiceInfo(flags *bootstrap.Bootstrap) { + core := r.bootstrap.GetServer().GetCore() + name := cmp.Or(flags.ServiceName(), core.GetName()) + version := cmp.Or(flags.Version(), core.GetVersion()) + flags.SetServiceInfo(name, version) +} + +// Discovery returns the discovery configuration. +func (r *ResolvedBootstrap) Discovery() *configv1.Discovery { + log.NewHelper(log.GetLogger()).Infow("msg", "discovery config", "value", r.bootstrap.GetDiscovery()) + return r.bootstrap.GetDiscovery() +} + +// Resolve scans the configuration into the bootstrap structure. +func (r *ResolvedBootstrap) Resolve(cfg config.KConfig) (config.Resolved, error) { + if err := cfg.Scan(r.bootstrap); err != nil { + return nil, err + } + return r, nil +} + +// WithDecode is not implemented for ResolvedBootstrap. +func (r *ResolvedBootstrap) WithDecode(name string, v any, decode func([]byte, any) error) error { + if decode == nil { + return fmt.Errorf("decode function is nil") + } + return nil +} + +// Value is not implemented for ResolvedBootstrap. +func (r *ResolvedBootstrap) Value(name string) (any, error) { + return nil, fmt.Errorf("unknown config name: %s", name) +} + +// Middleware returns the middleware configuration. +func (r *ResolvedBootstrap) Middleware() *middlewarev1.Middleware { + return r.bootstrap.GetMiddleware() +} + +// Services returns the service configurations. +func (r *ResolvedBootstrap) Services() []*configv1.Service { + return r.bootstrap.GetServer().GetServices() +} + +// Logger returns the logger configuration. +func (r *ResolvedBootstrap) Logger() *configv1.Logger { + return r.bootstrap.GetLogger() +} + func startCommandRun(cmd *cobra.Command, args []string) error { debug, err := cmd.Flags().GetBool(startDebug) if err != nil { @@ -73,29 +133,38 @@ func startCommandRun(cmd *cobra.Command, args []string) error { } if debug { flags.SetEnv("debug") - flags.SetConfigPath("resources/configs/config.toml") + flags.SetConfigPath("resources/configs/bootstrap.toml") // Updated path flags.SetWorkDir(".") slog.SetLogLoggerLevel(slog.LevelDebug) } - //var registrar registry.KRegistrar - //if flags.IsMainService() { - // registrar, _ = registry.NewConsulRegistrar() - //} - // - //buildInjectors() - // - //r.CreateApp(cmd.Context()) - // - //// 组合使用配置和服务 - //appInstance := loader.NewApp(cmd.Context(), loader.AppOptions{ - // Name: bs.ServiceName, - // Version: flags.Version(), - // Server: grpcServer, - //}) + ll := log.NewHelper(log.GetLogger()) ll.Infof("bootstrap flags: %+v", flags) - if err := loader.Bootstrap(cmd.Context(), flags, buildInjectors); err != nil { - ll.Infof("failed to bootstrap: %s", err.Error()) + + // Replicate loader.Bootstrap logic + rb := &ResolvedBootstrap{ + bootstrap: &conf.Bootstrap{}, // Initialize with new conf.Bootstrap + } + r, err := runtime.Load(flags, runtime.WithResolver(rb), runtime.WithContext(cmd.Context())) + if err != nil { + return err + } + rb.FillServiceInfo(flags) + r = r.WithLoggerAttrs( + "ts", log.DefaultTimestamp, + "caller", log.DefaultCaller, + "service.id", flags.ServiceID(), + "service.name", flags.ServiceName(), + "service.version", flags.Version(), + "trace.id", tracing.TraceID(), + "span.id", tracing.SpanID(), + ) + app, clean, err := buildInjectors(r, rb.bootstrap) // Use rb.bootstrap + if err != nil { + return err + } + defer clean() + if err := app.Run(); err != nil { return err } @@ -107,7 +176,7 @@ func NewApp(r runtime.Runtime, servers []transport.Server) *kratos.App { return r.CreateApp(servers...) } -func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { +func buildInjectors(r runtime.Runtime, bootstrap *conf.Bootstrap) (*kratos.App, func(), error) { // Updated type ll := log.NewHelper(r.Logger()) if bootstrap.GetMode() == "cluster" { ll.Infof("start cluster mode") diff --git a/cmd/root.go b/cmd/root.go deleted file mode 100644 index 2440bfc0..00000000 --- a/cmd/root.go +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package cmd represents the base command when called without any subcommands -package cmd - -import ( - "os" - - goversion "github.com/caarlos0/go-version" - "github.com/spf13/cobra" - - "origadmin/application/admin/cmd/internal/start" -) - -// rootCmd represents the base command when called without any subcommands -var rootCmd = &cobra.Command{ - Use: "admin", - Short: "Admin is a distributed backend management system with a focus on scalability, security, and flexibility for OrigAdmin.", - // Uncomment the following line if your bare application - // has an action associated with it: - // Run: func(cmd *cobra.Command, args []string) { }, -} - -// Execute adds all child commands to the root command and sets flags appropriately. -// This is called by main.main(). It only needs to happen once to the rootCmd. -func Execute(info goversion.Info) { - rootCmd.Version = info.String() - err := rootCmd.Execute() - if err != nil { - os.Exit(1) - } -} - -func init() { - // Here you will define your flags and configuration settings. - // Cobra supports persistent flags, which, if defined here, - // will be global for your application. - - // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.admin.yaml)") - - // Cobra also supports local flags, which will only run - // when this action is called directly. - // rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") - rootCmd.AddCommand(start.Cmd()) -} diff --git a/cmd/system/main.go b/cmd/system/main.go index 93e975d8..6fbb63ce 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -5,23 +5,17 @@ package main import ( - "context" - "flag" "log/slog" + "os" - "github.com/go-kratos/kratos/v2" + goversion "github.com/caarlos0/go-version" "github.com/go-kratos/kratos/v2/encoding" - "github.com/go-kratos/kratos/v2/transport" - "github.com/origadmin/runtime" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/codec/toml" - _ "origadmin/application/admin/contrib/consul/config" - _ "origadmin/application/admin/contrib/consul/registry" - _ "origadmin/application/admin/contrib/database/drivers" - _ "origadmin/application/admin/internal/data/entity/ent/runtime" - "origadmin/application/admin/internal/loader" + _ "github.com/origadmin/backend/internal/data/entity/ent/runtime" // Updated import + "origadmin/application/admin/cmd/internal/start" // Import the start command ) // go build -ldflags "-X main.Version=vx.y.z -X main.Name=origadmin.service.system.v1" @@ -30,55 +24,55 @@ var ( Name = "origadmin.service.system.v1" // Version is the Version of the compiled software. Version = "v1.0.0" - // boot are the bootstrap boot. + // flags are the bootstrap flags. flags = bootstrap.New() - // debug mode - debug = false - // configPath is the config path, default is config.toml - configPath = "" + + version = "" + commit = "" + treeState = "" + date = "" + builtBy = "" ) +func buildVersion(version, commit, date, builtBy, treeState string) goversion.Info { + return goversion.GetVersionInfo( + goversion.WithAppDetails(Name, "System Service", ""), // Use Name for app details + func(i *goversion.Info) { + if commit != "" { + i.GitCommit = commit + } + if version != "" { + i.GitVersion = version + } + if treeState != "" { + i.GitTreeState = treeState + } + if date != "" { + i.BuildDate = date + } + if builtBy != "" { + i.BuiltBy = builtBy + } + }, + ) +} + func init() { encoding.RegisterCodec(toml.Codec) flags.SetServiceInfo(Name, Version) - flag.BoolVar(&debug, "debug", false, "set environment, eg: -debug") - flag.StringVar(&configPath, "c", "config.toml", "config path, eg: -c config.toml") } func main() { - flag.Parse() + // Initialize cobra command for the system service + rootCmd := start.Cmd() + rootCmd.Use = "system" + rootCmd.Short = "System service for OrigAdmin backend." - // the release mode, work dir sets to empty, use config path as work dir - if debug { - flags.SetEnv("debug") - flags.SetConfigPath("resources/configs/system_config.toml") - flags.SetWorkDir(".") - slog.SetLogLoggerLevel(slog.LevelDebug) - } + info := buildVersion(version, commit, date, builtBy, treeState) + rootCmd.Version = info.String() - //r, err := runtime.Load(flags) - //if err != nil { - // return - //} - //l := r.Logger( - // "ts", log.DefaultTimestamp, - // "caller", log.DefaultCaller, - // "service.id", flags.ServiceID(), - // "service.name", flags.ServiceName(), - // "service.version", flags.Version(), - // "trace.id", tracing.TraceID(), - // "span.id", tracing.SpanID(), - //) - //log.SetLogger(l) - ll := log.NewHelper(log.GetLogger()) - ll.Infof("bootstrap flags: %+v", flags) - if err := loader.Bootstrap(context.Background(), flags, buildInjectors); err != nil { - ll.Infof("failed to bootstrap: %s", err.Error()) - return + if err := rootCmd.Execute(); err != nil { + slog.Error("failed to execute system service command", "error", err) + os.Exit(1) } } - -// NewApp new app with runtime and injector -func NewApp(r runtime.Runtime, servers []transport.Server) *kratos.App { - return r.CreateApp(servers...) -} diff --git a/contrib/consul/config/config.go b/contrib/consul/config/config.go deleted file mode 100644 index 27045f31..00000000 --- a/contrib/consul/config/config.go +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package config - -import ( - "encoding/json" - - "github.com/hashicorp/consul/api" - "github.com/origadmin/toolkits/errors" - "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/proto" - - "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/runtime/config" -) - -func init() { - runtime.RegisterConfigFunc(Type, NewConsulConfig) - runtime.RegisterConfigSync(Type, config.SyncFunc(SyncConfig)) -} - -// NewConsulConfig create a new consul config. -func NewConsulConfig(ccfg *configv1.SourceConfig, options *config.Options) (config.KSource, error) { - consul := ccfg.GetConsul() - if consul == nil { - return nil, errors.New("consul config error") - } - - cfg := api.DefaultConfig() - cfg.Address = consul.Address - cfg.Scheme = consul.Scheme - - apiClient, err := api.NewClient(cfg) - if err != nil { - return nil, errors.Wrap(err, "consul client error") - } - - if consul.Path == "" { - consul.Path = FileConfigPath(ccfg.Name, DefaultPathName) - } - - source, err := New(apiClient, WithPath(consul.Path)) - if err != nil { - return nil, errors.Wrap(err, "consul source error") - } - - //var configSources = []config.KSource{source} - //if ccfg.EnvPrefixes != nil { - // configSources = append(configSources, env.NewSource(ccfg.EnvPrefixes...)) - //} - // - //options.Sources = append(options.Sources, configSources...) - //if options.Config != nil { - // options.ConfigOptions = append(options.ConfigOptions, config.WithDecoder(options.Config)) - //} - return source, nil -} - -func SyncConfig(ccfg *configv1.SourceConfig, k string, v any, options *config.Options) error { - consul := ccfg.GetConsul() - if consul == nil { - return errors.New("consul config error") - } - - cfg := api.DefaultConfig() - cfg.Address = consul.Address - cfg.Scheme = consul.Scheme - apiClient, err := api.NewClient(cfg) - if err != nil { - return errors.Wrap(err, "consul client error") - } - - if consul.Path == "" { - consul.Path = FileConfigPath(ccfg.Name, DefaultPathName) - } - - encode := marshalJSON - if options.Encoder != nil { - encode = options.Encoder - } - marshal, err := encode(v) - if err != nil { - return errors.Wrap(err, "marshal config error") - } - - if _, err := apiClient.KV().Put(&api.KVPair{ - Key: consul.Path, - Value: marshal, - }, nil); err != nil { - return errors.Wrap(err, "consul put error") - } - return nil -} - -func FileConfigPath(serviceName, filename string) string { - return "/config/" + serviceName + "/" + filename -} -func marshalJSON(v any) ([]byte, error) { - if data, ok := v.(proto.Message); ok { - opt := protojson.MarshalOptions{ - EmitUnpopulated: true, - Indent: " ", - } - return opt.Marshal(data) - } - return json.Marshal(v) -} diff --git a/contrib/consul/config/const.go b/contrib/consul/config/const.go deleted file mode 100644 index 75376312..00000000 --- a/contrib/consul/config/const.go +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package config implements the functions, types, and interfaces for the module. -package config - -import ( - "github.com/go-kratos/kratos/contrib/config/consul/v2" - "github.com/hashicorp/consul/api" - - "github.com/origadmin/runtime/config" - "github.com/origadmin/runtime/context" -) - -const ( - DefaultPathName = "bootstrap.json" - Type = "consul" -) - -type ( - Option = consul.Option -) - -// New returns a new consul config source -func New(client *api.Client, opts ...Option) (config.KSource, error) { - return consul.New(client, opts...) -} - -// WithContext with registry context -func WithContext(ctx context.Context) Option { - return consul.WithContext(ctx) -} - -// WithPath with registry path -func WithPath(p string) Option { - return consul.WithPath(p) -} diff --git a/contrib/consul/registry/const.go b/contrib/consul/registry/const.go deleted file mode 100644 index c3aadf9d..00000000 --- a/contrib/consul/registry/const.go +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package registry implements the functions, types, and interfaces for the module. -package registry - -import ( - "time" - - "github.com/go-kratos/kratos/contrib/registry/consul/v2" - "github.com/hashicorp/consul/api" -) - -const ( - SingleDatacenter = consul.SingleDatacenter - MultiDatacenter = consul.MultiDatacenter - Type = "consul" -) - -type ( - Datacenter = consul.Datacenter - Client = consul.Client - ServiceResolver = consul.ServiceResolver - Option = consul.Option - Config = consul.Config - Registry = consul.Registry -) - -// WithHealthCheck is a wrapper for consul.WithHealthCheck -func WithHealthCheck(check bool) Option { - return consul.WithHealthCheck(check) -} - -// WithTimeout is a wrapper for consul.WithTimeout -func WithTimeout(timeout time.Duration) Option { - return consul.WithTimeout(timeout) -} - -// WithDatacenter is a wrapper for consul.WithDatacenter -func WithDatacenter(datacenter Datacenter) Option { - return consul.WithDatacenter(datacenter) -} - -// WithHeartbeat is a wrapper for consul.WithHeartbeat -func WithHeartbeat(heartbeat bool) Option { - return consul.WithHeartbeat(heartbeat) -} - -// WithServiceResolver is a wrapper for consul.WithServiceResolver -func WithServiceResolver(resolver ServiceResolver) Option { - return consul.WithServiceResolver(resolver) -} - -// WithHealthCheckInterval is a wrapper for consul.WithHealthCheckInterval -func WithHealthCheckInterval(interval int) Option { - return consul.WithHealthCheckInterval(interval) -} - -// WithDeregisterCriticalServiceAfter is a wrapper for consul.WithDeregisterCriticalServiceAfter -func WithDeregisterCriticalServiceAfter(duration int) Option { - return consul.WithDeregisterCriticalServiceAfter(duration) -} - -// WithServiceCheck is a wrapper for consul.WithServiceCheck -func WithServiceCheck(check *api.AgentServiceCheck) Option { - return consul.WithServiceCheck(check) -} - -// New is a wrapper for consul.New -func New(client *api.Client, opts ...Option) *Registry { - return consul.New(client, opts...) -} diff --git a/contrib/consul/registry/registry.go b/contrib/consul/registry/registry.go deleted file mode 100644 index 0be3f368..00000000 --- a/contrib/consul/registry/registry.go +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package registry - -import ( - "time" - - consulapi "github.com/hashicorp/consul/api" - "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/runtime/registry" - "github.com/origadmin/toolkits/errors" -) - -type consulBuilder struct { -} - -func init() { - runtime.RegisterRegistry(Type, &consulBuilder{}) -} - -func configFromConfig(registry *configv1.Discovery) *consulapi.Config { - apiconfig := consulapi.DefaultConfig() - cfg := registry.GetConsul() - if cfg == nil { - return apiconfig - } - if cfg.Address != "" { - apiconfig.Address = cfg.Address - } - if cfg.Scheme != "" { - apiconfig.Scheme = cfg.Scheme - } - if cfg.Datacenter != "" { - apiconfig.Datacenter = cfg.Datacenter - } - if cfg.Token != "" { - apiconfig.Token = cfg.Token - } - return apiconfig -} - -func optionsFromConfig(discovery *configv1.Discovery) []Option { - var opts []Option - - cfg := discovery.GetConsul() - if cfg == nil { - return opts - } - - if cfg.HealthCheck { - opts = append(opts, WithHealthCheck(cfg.HealthCheck)) - } - if cfg.HeartBeat { - opts = append(opts, WithHeartbeat(cfg.HeartBeat)) - } - if cfg.Timeout != 0 { - opts = append(opts, WithTimeout(time.Duration(cfg.Timeout))) - } - if cfg.Datacenter != "" { - opts = append(opts, WithDatacenter(Datacenter(cfg.Datacenter))) - } - if cfg.HealthCheckInterval > 0 { - opts = append(opts, WithHealthCheckInterval(int(cfg.HealthCheckInterval))) - } - if cfg.DeregisterCriticalServiceAfter > 0 { - opts = append(opts, WithDeregisterCriticalServiceAfter(int(cfg.DeregisterCriticalServiceAfter))) - } - return opts -} - -func (c *consulBuilder) NewDiscovery(cfg *configv1.Discovery, opts ...registry.Option) (registry.KDiscovery, error) { - return c.Create(cfg, opts...) -} - -func (c *consulBuilder) NewRegistrar(cfg *configv1.Discovery, opts ...registry.Option) (registry.KRegistrar, error) { - return c.Create(cfg, opts...) -} - -func (c *consulBuilder) Create(cfg *configv1.Discovery, _ ...registry.Option) (registry.Registry, error) { - if cfg == nil || cfg.Consul == nil { - return nil, errors.New("configuration: consul config is required") - } - apiConfig := configFromConfig(cfg) - apiClient, err := consulapi.NewClient(apiConfig) - if err != nil { - return nil, errors.Wrap(err, "failed to create consul client") - } - r := New(apiClient, optionsFromConfig(cfg)...) - return r, nil -} diff --git a/contrib/database/database.go b/contrib/database/database.go deleted file mode 100644 index a742e7d0..00000000 --- a/contrib/database/database.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package database implements the functions, types, and interfaces for the module. -package database - -import ( - "database/sql" - "strings" - "time" - - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/toolkits/errors" - - "origadmin/application/admin/contrib/database/internal/mysql" - "origadmin/application/admin/contrib/database/internal/sqlite" -) - -func Open(database *configv1.Database) (*sql.DB, error) { - if database == nil { - return nil, errors.New("config: database is nil") - } - switch database.Dialect { - case "mysql": - err := mysql.CreateDatabase(database.Source, "") - if err != nil { - return nil, errors.Wrap(err, "mysql: create database error") - } - case "pgx": - database.Dialect = "postgres" - case "sqlite3", "sqlite": - database.Dialect = "sqlite3" - if !strings.Contains(database.Source, ":memory:") { - sqlite.MakeSourceDirectory(database.Source) - } - database.Source = sqlite.SourceForeignKeys(database.Source) - default: - - } - db, err := sql.Open(database.Dialect, database.Source) - if err != nil { - return nil, errors.Wrap(err, "database: open database error") - } - if database.MaxIdleConnections > 0 { - db.SetMaxIdleConns(int(database.MaxIdleConnections)) - } - if database.MaxOpenConnections > 0 { - db.SetMaxOpenConns(int(database.MaxOpenConnections)) - } - if t := database.ConnectionMaxLifetime; t > 0 { - db.SetConnMaxLifetime(time.Duration(t)) - } - if t := database.ConnectionMaxIdleTime; t > 0 { - db.SetConnMaxIdleTime(time.Duration(t)) - } - return db, nil -} diff --git a/contrib/database/drivers/const.go b/contrib/database/drivers/const.go deleted file mode 100644 index 27f6a5dc..00000000 --- a/contrib/database/drivers/const.go +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package drivers is the database client wrapper -package drivers - -import ( - "context" - "database/sql/driver" - - "github.com/origadmin/runtime/interfaces/database" -) - -type ( - // Tx is a transaction aliased to driver.Tx - Tx = driver.Tx - // ExecFunc is a function that can be executed within a transaction - ExecFunc = func(context.Context) error - // TxFunc is a function that can be executed within a transaction - TxFunc = func(tx Tx) error - // Trans is a transaction interface - Trans database.Trans -) diff --git a/contrib/database/drivers/everyone.go b/contrib/database/drivers/everyone.go deleted file mode 100644 index 31ba4c3c..00000000 --- a/contrib/database/drivers/everyone.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build !sqlite3 && !mysql && !postgres && !sqlserver && !mssql && !pgx - -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package drivers is the database client wrapper -package drivers - -import ( - _ "github.com/denisenkom/go-mssqldb" - _ "github.com/go-sql-driver/mysql" - _ "github.com/lib/pq" - _ "github.com/sqlite3ent/sqlite3" -) - -// EveryOne ... -type EveryOne struct{} diff --git a/contrib/database/drivers/mssql.go b/contrib/database/drivers/mssql.go deleted file mode 100644 index 8c61bf9e..00000000 --- a/contrib/database/drivers/mssql.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build mssql || sqlserver - -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package drivers is the database client wrapper -package drivers - -import ( - _ "github.com/denisenkom/go-mssqldb" -) - -type MSSQL struct{} diff --git a/contrib/database/drivers/mysql.go b/contrib/database/drivers/mysql.go deleted file mode 100644 index dedf110d..00000000 --- a/contrib/database/drivers/mysql.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build mysql - -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package drivers is the database client wrapper -package drivers - -import ( - _ "github.com/go-sql-driver/mysql" -) - -type MySQL struct{} diff --git a/contrib/database/drivers/pgx.go b/contrib/database/drivers/pgx.go deleted file mode 100644 index e4559344..00000000 --- a/contrib/database/drivers/pgx.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build !postgres && pgx - -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package drivers is the database client wrapper -package drivers - -import ( - _ "github.com/jackc/pgx/v5/stdlib" -) - -type Pgx struct{} diff --git a/contrib/database/drivers/postgres.go b/contrib/database/drivers/postgres.go deleted file mode 100644 index 66e49776..00000000 --- a/contrib/database/drivers/postgres.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build postgres && !pgx - -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package drivers is the database client wrapper -package drivers - -import ( - _ "github.com/lib/pq" -) - -type Postgres struct{} diff --git a/contrib/database/drivers/sqlite3_cgo.go b/contrib/database/drivers/sqlite3_cgo.go deleted file mode 100644 index 255d59dd..00000000 --- a/contrib/database/drivers/sqlite3_cgo.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build sqlite3 && cgo - -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package drivers is the database client wrapper -package drivers - -import ( - _ "github.com/mattn/go-sqlite3" -) - -type SQLite3Cgo struct{} diff --git a/contrib/database/drivers/sqlite3_go.go b/contrib/database/drivers/sqlite3_go.go deleted file mode 100644 index a0fad9c1..00000000 --- a/contrib/database/drivers/sqlite3_go.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build sqlite3 && !cgo - -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package drivers is the database client wrapper -package drivers - -import ( - _ "github.com/sqlite3ent/sqlite3" -) - -type SQLite3Go struct{} diff --git a/contrib/database/internal/mysql/mysql.go b/contrib/database/internal/mysql/mysql.go deleted file mode 100644 index 09e20ce9..00000000 --- a/contrib/database/internal/mysql/mysql.go +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package mysql - -import ( - "database/sql" - "fmt" - "os" - - "github.com/go-sql-driver/mysql" - "github.com/goexts/generic/types" -) - -const ( - databaseCreateQuery = "CREATE DATABASE IF NOT EXISTS `%s` DEFAULT CHARACTER SET '%s' DEFAULT COLLATE '%s';" - defaultCharSet = "utf8mb4" - defaultCollate = "utf8mb4_general_ci" -) - -// CreateDatabase creates a MySQL database with the given DSN. -func CreateDatabase(dsn string, name string) error { - cfg, err := mysql.ParseDSN(dsn) - if err != nil { - return err - } - - db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/", cfg.User, cfg.Passwd, cfg.Addr)) - if err != nil { - return fmt.Errorf("failed to open database: %v", err) - } - defer func(db *sql.DB) { - err := db.Close() - if err != nil { - fmt.Fprintf(os.Stderr, "Failed to close database: %v\n", err) - } - }(db) - - charset := types.ZeroOr(cfg.Params["charset"], defaultCharSet) - collate := types.ZeroOr(cfg.Collation, defaultCollate) - if name == "" { - name = cfg.DBName - } - query := fmt.Sprintf(databaseCreateQuery, name, charset, collate) - _, err = db.Exec(query) - return err -} diff --git a/contrib/database/internal/sqlite/sqlite.go b/contrib/database/internal/sqlite/sqlite.go deleted file mode 100644 index ca36fe2d..00000000 --- a/contrib/database/internal/sqlite/sqlite.go +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package sqlite implements the functions, types, and interfaces for the module. -package sqlite - -import ( - "os" - "strings" -) - -const FKSuffix = "_fk=1" - -func SourceForeignKeys(source string) string { - // Check if the source already contains the FK parameter - if strings.Contains(source, FKSuffix) { - return source - } - - // Check if the source already contains parameters - if strings.Contains(source, "?") { - // If parameters exist, append with & - if !strings.HasSuffix(source, "&") { - source += "&" - } - source += FKSuffix - } else { - // If no parameters exist, append with ? - source += "?" + FKSuffix - } - return source -} - -func MakeSourceDirectory(source string) { - if strings.HasPrefix(source, "file://") { - source = strings.TrimPrefix(source, "file://") - } - idx := strings.Index(source, "?") - if idx > 0 { - source = source[:idx] - } - dirs := strings.Split(source, "/") - if len(dirs) > 1 { - dirs = dirs[:len(dirs)-1] - dir := strings.Join(dirs, "/") - _, err := os.Stat(dir) - if err != nil { - os.MkdirAll(dir, 0755) - return - } - } -} diff --git a/contrib/security/authn/jwt/authn.go b/contrib/security/authn/jwt/authn.go deleted file mode 100644 index c57725d9..00000000 --- a/contrib/security/authn/jwt/authn.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package jwt implements the functions, types, and interfaces for the module. -package jwt - -import ( - "context" - - "github.com/goexts/generic/configure" - "github.com/origadmin/runtime/interfaces/security" - "github.com/origadmin/runtime/interfaces/security/token" - - contribsecurity "origadmin/application/admin/contrib/security" -) - -type Authenticator struct { - Tokenizer security.Tokenizer - Cache token.CacheStorage - Scheme security.Scheme -} - -func (obj Authenticator) Authenticate(ctx context.Context, s string) (security.Claims, error) { - claims, err := obj.Tokenizer.ParseClaims(ctx, s) - if err != nil { - return nil, err - } - return claims, nil -} - -func (obj Authenticator) AuthenticateContext(ctx context.Context, tokenType security.TokenSource) (security.Claims, error) { - token, err := contribsecurity.TokenFromContext(ctx, tokenType, obj.Scheme.String()) - if err != nil { - return nil, err - } - return obj.Authenticate(ctx, token) -} - -func (obj Authenticator) DestroyToken(ctx context.Context, tokenStr string) error { - return obj.Cache.Remove(ctx, obj.key(token.CacheAccess, tokenStr)) -} - -func (obj Authenticator) DestroyRefreshToken(ctx context.Context, tokenStr string) error { - return obj.Cache.Remove(ctx, obj.key(token.CacheRefresh, tokenStr)) -} - -func (obj Authenticator) key(ns, token string) string { - return ns + ":" + token -} - -type AuthenticatorSetting = func(*Authenticator) - -func NewAuthenticator(tokenizer security.Tokenizer, ss ...AuthenticatorSetting) security.Authenticator { - return configure.Apply(&Authenticator{ - Tokenizer: tokenizer, - Cache: token.New(), - Scheme: security.SchemeBearer, - }, ss) -} - -var _ security.Authenticator = (*Authenticator)(nil) diff --git a/contrib/security/authn/jwt/authn_test.go b/contrib/security/authn/jwt/authn_test.go deleted file mode 100644 index 9b600867..00000000 --- a/contrib/security/authn/jwt/authn_test.go +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package jwt - -import ( - "context" - "fmt" - "net/http" - "testing" - "time" - - "github.com/go-kratos/kratos/v2/errors" - "github.com/go-kratos/kratos/v2/transport" - jwtv5 "github.com/golang-jwt/jwt/v5" - middlewaresecurity "github.com/origadmin/runtime/agent/middleware/security" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" - "github.com/origadmin/runtime/interfaces/security" - "github.com/stretchr/testify/assert" -) - -const ( - HeaderAuthorize = "Authorization" -) - -type headerCarrier http.Header - -func (hc headerCarrier) Get(key string) string { return http.Header(hc).Get(key) } - -func (hc headerCarrier) Set(key string, value string) { http.Header(hc).Set(key, value) } - -// Add append value to key-values pair. -func (hc headerCarrier) Add(key string, value string) { - http.Header(hc).Add(key, value) -} - -// Values returns a slice of values associated with the passed key. -func (hc headerCarrier) Values(key string) []string { - return http.Header(hc).Values(key) -} - -// Keys lists the keys stored in this carrier. -func (hc headerCarrier) Keys() []string { - keys := make([]string, 0, len(hc)) - for k := range http.Header(hc) { - keys = append(keys, k) - } - return keys -} - -func newTokenHeader(headerKey string, token string) *headerCarrier { - header := &headerCarrier{} - header.Set(headerKey, fmt.Sprintf("%s %s", security.SchemeBearer.String(), token)) - return header -} - -type Transport struct { - kind transport.Kind - endpoint string - operation string - reqHeader transport.Header -} - -func (tr *Transport) Kind() transport.Kind { - return tr.kind -} - -func (tr *Transport) Endpoint() string { - return tr.endpoint -} - -func (tr *Transport) Operation() string { - return tr.operation -} - -func (tr *Transport) RequestHeader() transport.Header { - return tr.reqHeader -} - -func (tr *Transport) ReplyHeader() transport.Header { - return nil -} - -func generateJwtKey(key, sub string) string { - mapClaims := jwtv5.MapClaims{} - mapClaims["sub"] = sub - claims := jwtv5.NewWithClaims(jwtv5.SigningMethodHS256, mapClaims) - token, _ := claims.SignedString([]byte(key)) - return token -} - -var ErrMissingBearerToken = ErrBearerTokenMissing - -func TestServer(t *testing.T) { - testKey := "testKey" - - token := generateJwtKey(testKey, "fly") - - tests := []struct { - name string - ctx context.Context - alg string - exceptErr error - key string - }{ - { - name: "normal", - ctx: transport.NewServerContext(context.Background(), &Transport{reqHeader: newTokenHeader(HeaderAuthorize, token)}), - alg: "HS256", - exceptErr: nil, - key: testKey, - }, - { - name: "miss token", - ctx: transport.NewServerContext(context.Background(), &Transport{reqHeader: headerCarrier{}}), - alg: "HS256", - exceptErr: ErrMissingBearerToken, - key: testKey, - }, - { - name: "token invalid", - ctx: transport.NewServerContext(context.Background(), &Transport{ - reqHeader: newTokenHeader(HeaderAuthorize, "12313123"), - }), - alg: "HS256", - exceptErr: ErrInvalidToken, - key: testKey, - }, - { - name: "method invalid", - ctx: transport.NewServerContext(context.Background(), &Transport{reqHeader: newTokenHeader(HeaderAuthorize, token)}), - alg: "ES384", - exceptErr: ErrInvalidToken, - key: testKey, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - var testToken security.Claims - next := func(ctx context.Context, req interface{}) (interface{}, error) { - t.Log(req) - testToken = middlewaresecurity.ClaimsFromContext(ctx) - t.Log(testToken) - return "reply", nil - } - cfg := &configv1.Security{ - Authn: &configv1.AuthNConfig{ - Jwt: &configv1.AuthNConfig_JWTConfig{ - Algorithm: test.alg, - SigningKey: testKey, - OldSigningKey: "", - ExpireTime: 0, - RefreshTime: 0, - CacheName: "", - }, - }, - } - authenticator, err := NewAuthenticator(cfg) //WithKey([]byte(testKey)), - //WithSigningMethod(test.alg), - - assert.Nil(t, err) - server, _ := middlewaresecurity.NewAuthN(cfg, - middlewaresecurity.WithAuthenticator(authenticator), - middlewaresecurity.WithSkipper()) - handle := server(next) - ctx := middlewaresecurity.WithSkipContextServer(test.ctx, middlewaresecurity.MetadataSecuritySkipKey) - _, err2 := handle(ctx, test.name) - if !errors.Is(test.exceptErr, err2) { - t.Errorf("except error %v, but got %v", test.exceptErr, err2) - } - if test.exceptErr == nil { - if testToken == nil { - t.Errorf("except testToken not nil, but got nil") - } - } - }) - } -} - -func TestClient(t *testing.T) { - testKey := "testKey" - - tests := []struct { - name string - expectError error - }{ - { - name: "normal", - expectError: nil, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - next := func(ctx context.Context, req interface{}) (interface{}, error) { - if header, ok := transport.FromClientContext(ctx); ok { - t.Log("token: ", header.RequestHeader().Get(HeaderAuthorize)) - } - return "reply", nil - } - cfg := &configv1.Security{ - Authn: &configv1.AuthNConfig{ - Jwt: &configv1.AuthNConfig_JWTConfig{ - Algorithm: "HS256", - SigningKey: testKey, - OldSigningKey: "", - ExpireTime: 0, - RefreshTime: 0, - CacheName: "", - }, - }, - } - authenticator, err := NewAuthenticator(cfg) - assert.Nil(t, err) - - principal := SecurityClaims{ - Claims: &securityv1.Claims{ - Sub: "user_name", - Scopes: make(map[string]bool), - }, - } - principal.Scopes["local:admin:user_name"] = true - principal.Scopes["tenant:admin:user_name"] = true - auth, _ := middlewaresecurity.NewAuthN(cfg, - middlewaresecurity.WithAuthenticator(authenticator), - ) - header := newTokenHeader(HeaderAuthorize, generateJwtKey(testKey, "fly")) - ctx := transport.NewClientContext(context.Background(), &Transport{reqHeader: header}) - handle := auth(next) - _, err2 := handle(ctx, "ok") - if !errors.Is(test.expectError, err2) { - t.Errorf("except error %v, but got %v", test.expectError, err2) - } - }) - } -} - -func TestAuth(t *testing.T) { - //cache := memory.NewCache(memory.Selector{CleanupInterval: time.Second}) - //c:=security.WithCache(cache) - //store := Memory - ctx := context.Background() - //middlewaresecurity.WithStorage(store) - cfg := &configv1.Security{ - Authn: &configv1.AuthNConfig{ - Jwt: &configv1.AuthNConfig_JWTConfig{ - Algorithm: "HS256", - SigningKey: "abc123", - OldSigningKey: "", - ExpireTime: 0, - RefreshTime: 0, - CacheName: "", - }, - }, - } - //WithCache(security.DefaultTokenCacheService()) - jwtAuth, err := NewAuthenticator(cfg) - assert.Nil(t, err) - if err != nil { - t.Fatal(err) - } - userID := "test" - now := time.Now() - claims := &securityv1.Claims{ - Sub: userID, - Iss: "test", - Aud: []string{"test"}, - Exp: now.Add(time.Hour).Unix(), - Nbf: now.Unix(), - Iat: now.Unix(), - Jti: "not need", - Scopes: map[string]bool{ - "test": true, - }, - } - token, err := jwtAuth.CreateToken(ctx, &SecurityClaims{Claims: claims}) - assert.Nil(t, err) - assert.NotNil(t, token) - t.Log("token: ", token) - resultClaims, err := jwtAuth.Authenticate(ctx, token) - assert.Nil(t, err) - fmt.Println("error", err) - fmt.Println("result_id:", resultClaims.GetSubject()) - fmt.Println("user_id: ", userID) - assert.Equal(t, userID, resultClaims.GetSubject()) - var ok bool - ok, err = jwtAuth.Verify(ctx, token) - assert.Nil(t, err) - assert.True(t, ok) - err = jwtAuth.DestroyToken(ctx, token) - assert.Nil(t, err) - ok, err = jwtAuth.Verify(ctx, token) - assert.NotNil(t, err) - assert.False(t, ok) - t.Log("token: ", token) - resultClaims, err = jwtAuth.Authenticate(ctx, token) - assert.NotNil(t, err) - assert.EqualError(t, err, ErrTokenNotFound.Error()) - assert.Empty(t, resultClaims) - - err = jwtAuth.Close(ctx) - assert.Nil(t, err) -} diff --git a/contrib/security/authn/jwt/claims.go b/contrib/security/authn/jwt/claims.go deleted file mode 100644 index a214f1d8..00000000 --- a/contrib/security/authn/jwt/claims.go +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package jwt implements the functions, types, and interfaces for the module. -package jwt - -import ( - "bytes" - "strings" - - jwtv5 "github.com/golang-jwt/jwt/v5" - securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" - "github.com/origadmin/runtime/interfaces/security" -) - -var ( - ErrInvalidToken = securityv1.ErrorSecurityErrorReasonBearerTokenMissing("invalid bearer token") - ErrTokenNotFound = securityv1.ErrorSecurityErrorReasonTokenNotFound("token not found") - ErrTokenMalformed = securityv1.ErrorSecurityErrorReasonBearerTokenMissing("token malformed") - ErrTokenSignatureInvalid = securityv1.ErrorSecurityErrorReasonSignTokenFailed("token signature invalid") - ErrTokenExpired = securityv1.ErrorSecurityErrorReasonTokenExpired("token expired") - ErrTokenNotValidYet = securityv1.ErrorSecurityErrorReasonTokenExpired("token not valid yet") - ErrUnsupportedSigningMethod = securityv1.ErrorSecurityErrorReasonUnsupportedSigningMethod("unsupported signing method") - ErrInvalidClaims = securityv1.ErrorSecurityErrorReasonInvalidClaims("invalid Claims") - ErrBearerTokenMissing = securityv1.ErrorSecurityErrorReasonBearerTokenMissing("bearer token missing") - ErrSignTokenFailed = securityv1.ErrorSecurityErrorReasonSignTokenFailed("sign token failed") - ErrMissingKeyFunc = securityv1.ErrorSecurityErrorReasonMissingKeyFunc("missing key function") - ErrGetKeyFailed = securityv1.ErrorSecurityErrorReasonGetKeyFailed("get key failed") - ErrInvalidSubject = securityv1.ErrorSecurityErrorReasonInvalidSubject("invalid subject") - ErrInvalidIssuer = securityv1.ErrorSecurityErrorReasonInvalidIssuer("invalid issuer") - ErrInvalidAudience = securityv1.ErrorSecurityErrorReasonInvalidAudience("invalid audience") - ErrInvalidExpiration = securityv1.ErrorSecurityErrorReasonInvalidExpiration("invalid expiration") - //ErrInvalidNotBefore = securityv1.ErrorSecurityErrorReasonInvalidNotBefore("invalid not before") - //ErrInvalidIssuedAt = securityv1.ErrorSecurityErrorReasonInvalidIssuedAt("invalid issued at") -) - -type SecurityClaims struct { - *securityv1.Claims - Extra map[string]string -} - -func (s *SecurityClaims) GetSubject() string { - return s.Claims.Sub -} - -func (s *SecurityClaims) GetIssuer() string { - return s.Claims.Iss -} - -func (s *SecurityClaims) GetAudience() []string { - return s.Claims.Aud -} - -func (s *SecurityClaims) GetExpiration() int64 { - return s.Claims.Exp -} - -func (s *SecurityClaims) GetNotBefore() int64 { - return s.Claims.Nbf -} - -func (s *SecurityClaims) GetIssuedAt() int64 { - return s.Claims.Iat -} - -func (s *SecurityClaims) GetID() string { - return s.Claims.Jti -} - -func (s *SecurityClaims) GetExtra() map[string]string { - return s.Extra -} - -func (s *SecurityClaims) GetScopes() map[string]bool { - return s.Claims.Scopes -} - -func ClaimsToJwtClaims(raw security.Claims) jwtv5.Claims { - mapClaims := jwtv5.MapClaims{ - "sub": raw.GetSubject(), - } - - if iss := raw.GetIssuer(); iss != "" { - mapClaims["iss"] = raw.GetIssuer() - } - if aud := raw.GetAudience(); len(aud) > 0 { - mapClaims["aud"] = aud - } - if exp := raw.GetExpiration(); exp > 0 { - mapClaims["exp"] = exp - } - - if extras, ok := security.ExtraObject(raw); ok { - extraMap := extras.GetExtra() - for key, val := range extraMap { - mapClaims[key] = val - } - } - - var buffer bytes.Buffer - count := len(raw.GetScopes()) - idx := 0 - for scope := range raw.GetScopes() { - buffer.WriteString(scope) - if idx != count-1 { - buffer.WriteString(" ") - } - idx++ - } - str := buffer.String() - if len(str) > 0 { - mapClaims["scope"] = buffer.String() - } - - return mapClaims -} - -func MapToClaims(rawClaims jwtv5.MapClaims, extras map[string]string) (security.Claims, error) { - //claims := security.claims{ - // Scopes: make(ScopeSet), - //} - claims := &securityv1.Claims{ - Scopes: make(map[string]bool), - } - - // optional Subject - if subjectClaim, err := rawClaims.GetSubject(); err == nil { - claims.Sub = subjectClaim - } else { - return nil, ErrInvalidSubject - } - // optional Issuer - if issuerClaim, err := rawClaims.GetIssuer(); err == nil { - claims.Iss = issuerClaim - } else { - return nil, ErrInvalidIssuer - } - // optional Audience - if audienceClaim, err := rawClaims.GetAudience(); err == nil { - claims.Aud = append(claims.Aud, audienceClaim...) - } else { - return nil, ErrInvalidAudience - } - // optional Expiration - if expClaim, err := rawClaims.GetExpirationTime(); err == nil { - if expClaim != nil { - claims.Exp = expClaim.Unix() - } - } else { - return nil, ErrInvalidExpiration - } - // optional scopes - if scopeKey, ok := rawClaims["scope"]; ok { - if scope, ok := scopeKey.(string); ok { - scopes := strings.Split(scope, " ") - for _, s := range scopes { - claims.Scopes[s] = true - } - } - } - - return &SecurityClaims{ - Claims: claims, - Extra: extras, - }, nil -} - -func RegisteredToClaims(rawClaims *jwtv5.RegisteredClaims) (security.Claims, error) { - Claims := &securityv1.Claims{ - Scopes: make(map[string]bool), - } - - // optional Subject - if subjectClaim, err := rawClaims.GetSubject(); err == nil { - Claims.Sub = subjectClaim - } else { - return nil, ErrInvalidSubject - } - // optional Issuer - if issuerClaim, err := rawClaims.GetIssuer(); err == nil { - Claims.Iss = issuerClaim - } else { - return nil, ErrInvalidIssuer - } - // optional Audience - if audienceClaim, err := rawClaims.GetAudience(); err == nil { - Claims.Aud = append(Claims.Aud, audienceClaim...) - } else { - return nil, ErrInvalidAudience - } - // optional Expiration - if expClaim, err := rawClaims.GetExpirationTime(); err == nil { - if expClaim != nil { - Claims.Exp = expClaim.Time.Unix() - } - } else { - return nil, ErrInvalidExpiration - } - // optional scopes - //if scopeKey, ok := rawClaims.Scope["scope"]; ok { - // if scope, ok := scopeKey.(string); ok { - // scopes := strings.Split(scope, " ") - // for _, s := range scopes { - // Claims.Scopes[s] = true - // } - // } - //} - - return &SecurityClaims{ - Claims: Claims, - }, nil -} - -func ProtoClaimsToClaims(rawClaims *securityv1.Claims) security.Claims { - return &SecurityClaims{ - Claims: rawClaims, - } -} - -func ToClaims(rawClaims jwtv5.Claims, extras map[string]string) (security.Claims, error) { - if Claims, ok := rawClaims.(*jwtv5.RegisteredClaims); ok { - return RegisteredToClaims(Claims) - } - if Claims, ok := rawClaims.(jwtv5.MapClaims); ok { - return MapToClaims(Claims, extras) - } - return nil, ErrInvalidClaims -} diff --git a/contrib/security/authn/jwt/jwt.go b/contrib/security/authn/jwt/jwt.go deleted file mode 100644 index 4cb535bb..00000000 --- a/contrib/security/authn/jwt/jwt.go +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package jwt implements the functions, types, and interfaces for the module. -package jwt - -import ( - "context" - "errors" - "maps" - "time" - - "github.com/dchest/uniuri" - "github.com/goexts/generic/configure" - jwtv5 "github.com/golang-jwt/jwt/v5" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" - "github.com/origadmin/runtime/interfaces/security" - "github.com/origadmin/runtime/log" -) - -const ( - defaultIssuerDomain = "localhost" - defaultExpirationAccess = 2 * 60 * time.Minute - defaultExpirationRefresh = 14 * 24 * time.Hour -) - -// Tokenizer is a struct that implements the Tokenizer interface. -type Tokenizer struct { - Option *Option - keyFunc func(token *jwtv5.Token) (any, error) - signingMethod jwtv5.SigningMethod - expirationAccess time.Duration - expirationRefresh time.Duration -} - -func (obj *Tokenizer) ParseClaims(_ context.Context, tokenStr string) (security.Claims, error) { - log.Debugf("Authenticating token string: %s", tokenStr) - // Parse the token string. - log.Debugf("Parsing token string") - jwtToken, err := obj.parseToken(tokenStr) - - // If the token is nil, return an error. - if jwtToken == nil { - log.Errorf("Failed to parse token: token is nil") - return nil, ErrInvalidToken - } - - // If there is an error, return the appropriate error. - if err != nil { - log.Errorf("Error parsing token: %v", err) - switch { - case errors.Is(err, jwtv5.ErrTokenMalformed): - log.Debugf("Token is malformed") - return nil, ErrTokenMalformed - case errors.Is(err, jwtv5.ErrTokenSignatureInvalid): - log.Debugf("Token signature is invalid") - return nil, ErrTokenSignatureInvalid - case errors.Is(err, jwtv5.ErrTokenExpired) || errors.Is(err, jwtv5.ErrTokenNotValidYet): - log.Debugf("Token is expired or not valid yet") - return nil, ErrTokenExpired - default: - log.Debugf("Unknown error parsing token") - return nil, ErrInvalidToken - } - } - - // If the token is not valid, return an error. - if !jwtToken.Valid { - log.Errorf("Token is not valid") - return nil, ErrInvalidToken - } - - // If the signing method is not supported, return an error. - if jwtToken.Method != obj.signingMethod { - log.Errorf("Unsupported signing method: %s", jwtToken.Method) - return nil, ErrUnsupportedSigningMethod - } - - // If the claims are nil, return an error. - if jwtToken.Claims == nil { - log.Errorf("Claims are nil") - return nil, ErrInvalidClaims - } - - // Convert the claims to security.Claims. - log.Debugf("Converting claims to security.Claims") - securityClaims, err := ToClaims(jwtToken.Claims, obj.Option.extraClaims) - if err != nil { - log.Errorf("Error converting claims: %v", err) - return nil, err - } - log.Debugf("Authentication successful") - return securityClaims, nil -} - -func (obj *Tokenizer) DestroyRefreshToken(ctx context.Context, s string) error { - //TODO implement me - panic("implement me") -} - -func (obj *Tokenizer) CreateRefreshClaims(_ context.Context, id string) (security.Claims, error) { - expiration := obj.expirationRefresh - now := time.Now() - // Create a new claims object with the base claims and the user ID. - claims := &SecurityClaims{ - Claims: &securityv1.Claims{ - Sub: id, - Iss: obj.Option.issuer, - Aud: obj.Option.audience, - Exp: now.Add(expiration).Unix(), - Nbf: now.Unix(), - Iat: now.Unix(), - Jti: obj.generateJTI(), - Scopes: make(map[string]bool), - }, - Extra: make(map[string]string), - } - - // Add the extra keys to the claims. - claims.Extra = maps.Clone(obj.Option.extraClaims) - - // If the token is scoped, add the scope to the claims. - if obj.Option.scoped { - claims.Claims.Scopes = maps.Clone(obj.Option.scopes) - } - - return claims, nil -} - -func (obj *Tokenizer) CreateClaims(_ context.Context, id string) (security.Claims, error) { - expiration := obj.expirationAccess - now := time.Now() - // Create a new claims object with the base claims and the user ID. - claims := &SecurityClaims{ - Claims: &securityv1.Claims{ - Sub: id, - Iss: obj.Option.issuer, - Aud: obj.Option.audience, - Exp: now.Add(expiration).Unix(), - Nbf: now.Unix(), - Iat: now.Unix(), - Jti: obj.generateJTI(), - Scopes: make(map[string]bool), - }, - Extra: make(map[string]string), - } - - // Add the extra keys to the claims. - claims.Extra = maps.Clone(obj.Option.extraClaims) - - // If the token is scoped, add the scope to the claims. - if obj.Option.scoped { - claims.Claims.Scopes = maps.Clone(obj.Option.scopes) - } - - return claims, nil -} - -func (obj *Tokenizer) Validate(ctx context.Context, tokenStr string) (bool, error) { - // Authenticate the token string. - _, err := obj.ParseClaims(ctx, tokenStr) - // If there is an error, return false and the error. - if err != nil { - return false, err - } - // Otherwise, return true. - return true, nil -} - -// CreateToken creates a token string from the claims. -func (obj *Tokenizer) CreateToken(ctx context.Context, claims security.Claims) (string, error) { - // Create a new token with the claims. - jwtToken := jwtv5.NewWithClaims(obj.signingMethod, ClaimsToJwtClaims(claims)) - - // Generate the token string. - tokenStr, err := obj.generateToken(jwtToken) - if err != nil || tokenStr == "" { - return "", err - } - return tokenStr, nil -} - -// parseToken parses the token string and returns the token. -func (obj *Tokenizer) parseToken(token string) (*jwtv5.Token, error) { - // If the key function is nil, return an error. - if obj.keyFunc == nil { - return nil, ErrMissingKeyFunc - } - // If the extra keys are nil, parse the token with the key function. - if len(obj.Option.extraClaims) == 0 && !obj.Option.scoped { - return jwtv5.ParseWithClaims(token, &jwtv5.RegisteredClaims{}, obj.keyFunc) - } - - // Otherwise, parse the token with the key function and the extra keys. - return jwtv5.Parse(token, obj.keyFunc) -} - -// generateToken generates a signed token string from the token. -func (obj *Tokenizer) generateToken(jwtToken *jwtv5.Token) (string, error) { - // If the key function is nil, return an error. - if obj.keyFunc == nil { - return "", ErrMissingKeyFunc - } - - // Get the key from the key function. - key, err := obj.keyFunc(jwtToken) - if err != nil { - return "", ErrGetKeyFailed - } - - // Generate the token string. - strToken, err := jwtToken.SignedString(key) - if err != nil { - return "", ErrSignTokenFailed - } - - return strToken, nil -} - -func (obj *Tokenizer) generateJTI() string { - if !obj.Option.enabledJTI { - return "" - } - if obj.Option.genJTI != nil { - return obj.Option.genJTI() - } - // Encode the random byte slice in base64. - return uniuri.New() -} - -func (obj *Tokenizer) WithConfig(config *configv1.AuthNConfig_JWTConfig) error { - // If the signing key is empty, return an error. - signingKey := config.SigningKey - if signingKey == "" && (obj.signingMethod == nil || obj.keyFunc == nil) { - return errors.New("signing key is empty") - } - - // Get the signing method and key function from the signing key. - signingMethod, keyFunc, err := getSigningMethodAndKeyFunc(config.Algorithm, config.SigningKey) - if err != nil { - return err - } - obj.signingMethod = signingMethod - obj.keyFunc = keyFunc - if config.ExpireTime > 0 { - obj.expirationAccess = time.Duration(config.ExpireTime) * time.Second - } - if config.RefreshTime > 0 { - obj.expirationRefresh = time.Duration(config.RefreshTime) * time.Second - } - - return nil -} - -// NewTokenizer creates a new Tokenizer. -func NewTokenizer(cfg *configv1.Security, ss ...Setting) (security.RefreshTokenizer, error) { - // Get the JWT config from the security config. - config := cfg.GetAuthn().GetJwt() - if config == nil { - return nil, errors.New("authenticator jwt config is empty") - } - option := configure.Apply(&Option{ - issuer: defaultIssuerDomain, - }, ss) - tokenizer := &Tokenizer{ - Option: option, - expirationAccess: defaultExpirationAccess, - expirationRefresh: defaultExpirationRefresh, - } - err := tokenizer.WithConfig(config) - if err != nil { - return nil, err - } - return tokenizer, nil -} - -func jwt2SecurityError(err error) error { - //if errors.Is(err, jwtv5.ErrTokenExpired) { - return securityv1.ErrorSecurityErrorReasonInvalidAuthentication(err.Error()) - //} - //if errors.Is(err, jwtv5.ErrTokenMalformed) { - // return securityv1.ErrorSecurityErrorReasonTokenMalformed(err.Error()) - //} - //if errors.Is(err, jwtv5.ErrTokenSignatureInvalid) { - // return securityv1.ErrorSecurityErrorReasonTokenSignatureInvalid(err.Error()) - //} - //if errors.Is(err, jwtv5.ErrTokenNotValidYet) { - // return securityv1.ErrorSecurityErrorReasonTokenNotValidYet(err.Error()) - //} - //return err -} - -var _ security.RefreshTokenizer = (*Tokenizer)(nil) diff --git a/contrib/security/authn/jwt/option.go b/contrib/security/authn/jwt/option.go deleted file mode 100644 index edc427b8..00000000 --- a/contrib/security/authn/jwt/option.go +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package jwt implements the functions, types, and interfaces for the module. -package jwt - -import ( - jwtv5 "github.com/golang-jwt/jwt/v5" - "github.com/origadmin/toolkits/errors" -) - -type Option struct { - enabledJTI bool - genJTI func() string - issuer string - audience []string - scoped bool - scopes map[string]bool - extraClaims map[string]string - signingMethod jwtv5.SigningMethod - keyFunc func(token *jwtv5.Token) (any, error) -} - -// Setting is a function type for setting the Tokenizer. -type Setting = func(*Option) - -func (option *Option) ApplyDefaults() error { - return nil -} - -// GetKeyFunc returns a function that retrieves the key for a given token. -// The returned function takes a jwtv5.Token as an argument and returns the key as a string. -func GetKeyFunc(key string) func(token *jwtv5.Token) (any, error) { - // Return a function that checks if the token's algorithm is empty. - // If it is, return an error. Otherwise, return the key. - return func(token *jwtv5.Token) (any, error) { - if token.Method.Alg() == "" { - // Return an error if the token's algorithm is empty. - return nil, ErrInvalidToken - } - // Return the key if the token's algorithm is not empty. - return key, nil - } -} - -// GetKeyFuncWithAlg returns a function that retrieves the key for a given token -// with a specific algorithm. -// The returned function takes a jwtv5.Token as an argument and returns the key as a byte slice. -func GetKeyFuncWithAlg(alg, key string) func(token *jwtv5.Token) (any, error) { - // Return a function that checks if the token's algorithm matches the provided algorithm. - // If it does not, return an error. Otherwise, return the key as a byte slice. - return func(token *jwtv5.Token) (any, error) { - if token.Method.Alg() == "" || alg != token.Method.Alg() { - // Return an error if the token's algorithm does not match the provided algorithm. - return nil, ErrInvalidToken - } - // jwtv5 requires the key to be a byte slice. - return []byte(key), nil - } -} - -// GetAlgorithmSigningMethod returns the signing method for a given algorithm. -func GetAlgorithmSigningMethod(algorithm string) jwtv5.SigningMethod { - // Use a switch statement to map the algorithm to its corresponding signing method. - switch algorithm { - case "HS256": - // Return the signing method for HS256. - return jwtv5.SigningMethodHS256 - case "HS384": - // Return the signing method for HS384. - return jwtv5.SigningMethodHS384 - case "HS512": - // Return the signing method for HS512. - return jwtv5.SigningMethodHS512 - case "RS256": - // Return the signing method for RS256. - return jwtv5.SigningMethodRS256 - case "RS384": - // Return the signing method for RS384. - return jwtv5.SigningMethodRS384 - case "RS512": - // Return the signing method for RS512. - return jwtv5.SigningMethodRS512 - case "ES256": - // Return the signing method for ES256. - return jwtv5.SigningMethodES256 - case "ES384": - // Return the signing method for ES384. - return jwtv5.SigningMethodES384 - case "ES512": - // Return the signing method for ES512. - return jwtv5.SigningMethodES512 - case "EdDSA": - // Return the signing method for EdDSA. - return jwtv5.SigningMethodEdDSA - default: - // Return nil if the algorithm is not recognized. - return nil - } -} - -// WithExtraClaims returns a Setting function that sets the extra keys for an Tokenizer. -func WithExtraClaims(extras map[string]string) Setting { - // Return a function that sets the extra keys for an Tokenizer. - return func(option *Option) { - // Set the extra keys for the Tokenizer. - option.extraClaims = extras - } -} - -// WithSigningMethod returns a Setting function that sets the signing method for an Tokenizer. -// The signing method is used to sign and verify tokens. -func WithSigningMethod(signingMethod jwtv5.SigningMethod) Setting { - // Return a function that sets the signing method for an Tokenizer. - return func(option *Option) { - // Set the signing method for the Tokenizer. - option.signingMethod = signingMethod - } -} - -// WithKeyFunc returns a Setting function that sets the key function for an Tokenizer. -// The key function is used to retrieve the key for a given token. -func WithKeyFunc(keyFunc func(token *jwtv5.Token) (any, error)) Setting { - // Return a function that sets the key function for an Tokenizer. - return func(option *Option) { - // Set the key function for the Tokenizer. - option.keyFunc = keyFunc - } -} - -// WithJTI returns a Setting function that sets the JTI generator function for an Tokenizer. -func WithJTI(fn func() string) Setting { - return func(option *Option) { - option.genJTI = fn - option.enabledJTI = true - } -} - -// WithIssuer returns a Setting function that sets the issuer for an Tokenizer. -func WithIssuer(issuer string) Setting { - return func(option *Option) { - option.issuer = issuer - } -} - -// WithAudience returns a Setting function that sets the audience for an Tokenizer. -func WithAudience(audience []string) Setting { - return func(option *Option) { - option.audience = audience - } -} - -// WithScopes returns a Setting function that sets the scoped flag for an Tokenizer. -// The scoped flag determines whether the Tokenizer should use scoped tokens. -func WithScopes(scopes map[string]bool) Setting { - return func(option *Option) { - option.scopes = scopes - option.scoped = true - } -} - -func getSigningMethodAndKeyFunc(algorithm string, signingKey string) (jwtv5.SigningMethod, func(*jwtv5.Token) (any, error), error) { - signingMethod := GetAlgorithmSigningMethod(algorithm) - if signingMethod == nil { - return nil, nil, errors.New("invalid signing method") - } - - keyFunc := GetKeyFuncWithAlg(algorithm, signingKey) - if keyFunc == nil { - return nil, nil, errors.New("invalid key function") - } - - return signingMethod, keyFunc, nil -} diff --git a/contrib/security/authz/casbin/adapter.go b/contrib/security/authz/casbin/adapter.go deleted file mode 100644 index ab770c16..00000000 --- a/contrib/security/authz/casbin/adapter.go +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package casbin implements the functions, types, and interfaces for the module. -package casbin - -import ( - "context" - "fmt" - - "github.com/casbin/casbin/v2/model" - "github.com/casbin/casbin/v2/persist" - "github.com/goexts/generic/maps" - "github.com/origadmin/runtime/interfaces/security" -) - -type adapter struct { - typedPolicies map[string][][]string -} - -func (a *adapter) SetRoles(ctx context.Context, roles security.RoleMap) error { - return nil -} - -func (a *adapter) SetPolicies(ctx context.Context, policies security.PolicyMap) error { - a.typedPolicies = maps.Transform(policies, func(k string, v any) (string, [][]string, bool) { - if vv, ok := v.([][]string); ok { - return k, vv, true - } - return "", nil, false - }) - return nil -} - -func (a *adapter) SetPolicyRoles(ctx context.Context, policies security.PolicyMap, roles security.RoleMap) error { - merged := make(map[string][][]string) - maps.Transform(policies, func(k string, v any) (string, [][]string, bool) { - if vv, ok := v.([][]string); ok { - merged[k] = append(merged[k], vv...) - return k, vv, true - } - return "", nil, false - }) - maps.Transform(roles, func(k string, v any) (string, [][]string, bool) { - if vv, ok := v.([][]string); ok { - merged[k] = append(merged[k], vv...) - return k, vv, true - } - return "", nil, false - }) - a.typedPolicies = merged - return nil -} - -func (a *adapter) AddPolicies(sec string, ptype string, rules [][]string) error { - for _, rule := range rules { - err := a.AddPolicy(sec, ptype, rule) - if err != nil { - return fmt.Errorf("error adding policy: %v", err) - } - } - return nil -} - -func (a *adapter) RemovePolicies(sec string, ptype string, rules [][]string) error { - for _, rule := range rules { - err := a.RemovePolicy(sec, ptype, rule) - if err != nil { - return fmt.Errorf("error removing policy: %v", err) - } - } - return nil -} - -func (a *adapter) LoadPolicy(model model.Model) error { - var ( - idx int - policies [][]string - ptype string - ) - for ptype, policies = range a.typedPolicies { - for idx = range policies { - err := persist.LoadPolicyArray(append([]string{ptype}, policies[idx]...), model) - if err != nil { - return err - } - } - } - return nil -} - -func (a *adapter) savePolicyLine(ptype string, rule []string) { - rule = append([]string{ptype}, rule...) - a.typedPolicies[ptype] = append(a.typedPolicies[ptype], rule) -} - -func (a *adapter) SavePolicy(m model.Model) error { - var ( - ptype string - rule []string - ast *model.Assertion - ) - for ptype, ast = range m["p"] { - for _, rule = range ast.Policy { - a.savePolicyLine(ptype, rule) - } - } - - for ptype, ast = range m["g"] { - for _, rule = range ast.Policy { - a.savePolicyLine(ptype, rule) - } - } - return nil -} - -func (a *adapter) AddPolicy(sec string, ptype string, rule []string) error { - a.savePolicyLine(ptype, rule) - return nil -} - -func (a *adapter) RemovePolicy(sec string, ptype string, rule []string) error { - var newPolices, polices [][]string - polices, ok := a.typedPolicies[ptype] - if !ok { - return nil - } - var ( - idx int - ) - for idx = range polices { - if arrayEquals(rule, polices[idx][1:]) { - continue - } - newPolices = append(newPolices, polices[idx]) - } - a.typedPolicies[ptype] = newPolices - return nil -} - -func arrayEquals(a, b []string) bool { - if len(a) != len(b) { - return false - } - for i, v := range a { - if v != b[i] { - return false - } - } - return true -} - -func (a *adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error { - var newPolices, polices [][]string - polices, ok := a.typedPolicies[ptype] - if !ok { - return nil - } - var ( - idx int - ) - for idx = range polices { - if arrayEquals(fieldValues, polices[idx][fieldIndex+1:]) { - continue - } - newPolices = append(newPolices, polices[idx]) - } - a.typedPolicies[ptype] = newPolices - return nil -} - -func NewAdapter(policies map[string][][]string) persist.Adapter { - if policies == nil { - policies = make(map[string][][]string) - } - return &adapter{ - typedPolicies: policies, - } -} - -var _ persist.Adapter = (*adapter)(nil) -var _ persist.BatchAdapter = (*adapter)(nil) -var _ security.PolicyRegistry = (*adapter)(nil) diff --git a/contrib/security/authz/casbin/casbin.go b/contrib/security/authz/casbin/casbin.go deleted file mode 100644 index ad92f22d..00000000 --- a/contrib/security/authz/casbin/casbin.go +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package casbin - -import ( - "time" - - "github.com/casbin/casbin/v2" - casbinmodel "github.com/casbin/casbin/v2/model" - "github.com/casbin/casbin/v2/persist" - "github.com/goexts/generic/cmp" - "github.com/goexts/generic/configure" - "github.com/goexts/generic/maps" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/security" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/errors" - "github.com/prometheus/client_golang/prometheus" -) - -// Authorizer is a struct that implements the Authorizer interface. -type Authorizer struct { - enforcer *casbin.SyncedEnforcer - updater *PolicyUpdater - wildcardItem string - model casbinmodel.Model - adapter persist.Adapter - watcher persist.Watcher -} - -const MaxRetryDelay = time.Minute - -var ( - policySyncCounter = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "casbin_policy_sync_total", - Help: "Total number of policy sync operations", - }, - []string{"status"}, - ) - - policyCountGauge = prometheus.NewGauge( - prometheus.GaugeOpts{ - Name: "casbin_policy_count", - Help: "Current number of loaded policies", - }, - ) - - policySyncDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Name: "casbin_sync_duration_seconds", - Help: "Histogram of policy sync durations", - Buckets: prometheus.DefBuckets, - }, - ) -) - -func (auth *Authorizer) Authorized(ctx context.Context, policy security.Policy, object string, action string) (bool, error) { - domain := cmp.Or(policy.GetDomain(), "*") - object = cmp.Or(object, policy.GetObject()) - action = cmp.Or(action, policy.GetAction()) - return auth.enforce(ctx, policy.GetSubject(), object, action, domain) -} - -func (auth *Authorizer) AuthorizedWithDomain(ctx context.Context, policy security.Policy, domain string, object string, action string) (bool, error) { - domain = cmp.Or(domain, policy.GetDomain(), "*") - object = cmp.Or(object, policy.GetObject()) - action = cmp.Or(action, policy.GetAction()) - return auth.enforce(ctx, policy.GetSubject(), object, action, domain) -} - -func (auth *Authorizer) AuthorizedWithExtra(ctx context.Context, data security.ExtraData) (bool, error) { - policy, ok := data.GetPolicy() - if !ok { - return false, errors.New("policy not found in extra data") - } - return auth.enforce(ctx, policy.GetSubject(), policy.GetObject(), policy.GetAction(), policy.GetDomain()) -} - -func (auth *Authorizer) enforce(ctx context.Context, subject, object, action, domain string) (bool, error) { - allowed, err := auth.enforcer.Enforce(subject, object, action, domain) - if err != nil { - log.Errorf("Authorization error: %auth", err) - return false, err - } - if !allowed { - log.Debugf("Authorization result: %t for %s %s %s %s", allowed, subject, object, action, domain) - } - policy, err := auth.enforcer.GetPolicy() - if err != nil { - return false, err - } - log.Infof("Authorization policy %v", policy) - return allowed, nil -} - -func (auth *Authorizer) SetPolicies(ctx context.Context, policies map[string]any, roles map[string]any) error { - merged := make(map[string][][]string) - - // Merge policy and role data - maps.Transform(policies, func(k string, v any) (string, [][]string, bool) { - if vv, ok := v.([][]string); ok { - merged[k] = append(merged[k], vv...) - return k, vv, true - } - return "", nil, false - }) - - maps.Transform(roles, func(k string, v any) (string, [][]string, bool) { - if vv, ok := v.([][]string); ok { - merged[k] = append(merged[k], vv...) - return k, vv, true - } - return "", nil, false - }) - - // Incremental update policy - if ps, ok := auth.adapter.(security.PolicyRegistry); ok { - err := ps.SetPolicyRoles(ctx, policies, roles) - if err != nil { - return err - } - } - err := auth.watcher.Update() - if err != nil { - return err - } - - return nil -} - -func NewAuthorizer(cfg *configv1.Security, ss ...AuthorizerOption) (security.Authorizer, error) { - config := cfg.GetAuthz().GetCasbin() - if config == nil { - return nil, errors.New("authorizer casbin config is empty") - } - - options := configure.ApplyDefault(DefaultAuthorizerOptions, ss) - if options.Source == nil { - return nil, errors.New("authorizer casbin source is empty") - } - err := options.Setup() - if err != nil { - return nil, err - } - - updater := &PolicyUpdater{ - source: options.Source, - adapter: options.Adapter, - interval: options.SyncInterval, - metric: options.EnablePrometheus, - } - - _, err = updater.Sync(context.Background()) - if err != nil { - log.Errorf("Policy sync failed: %v", err) - } - auth, err := authorizerFromOptions(updater, options) - if err != nil { - return nil, err - } - - go updater.Watch(context.Background(), options.Watcher) - if options.EnablePrometheus { - prometheus.MustRegister( - policySyncCounter, - policyCountGauge, - policySyncDuration, - ) - } - - return auth, nil -} - -func authorizerFromOptions(updater *PolicyUpdater, options *AuthorizerOptions) (security.Authorizer, error) { - auth := &Authorizer{ - model: options.Model, - adapter: options.Adapter, - watcher: options.Watcher, - wildcardItem: options.WildcardItem, - updater: updater, - } - enforcer, err := casbin.NewSyncedEnforcer(auth.model, auth.adapter) - if err != nil { - return nil, err - } - if err := enforcer.SetWatcher(auth.watcher); err != nil { - return nil, err - } - auth.enforcer = enforcer - if auth.model == nil || auth.adapter == nil { - return nil, errors.New("authorizer casbin model or adapter is empty") - } - return auth, nil -} diff --git a/contrib/security/authz/casbin/internal/model/abac_model.conf b/contrib/security/authz/casbin/internal/model/abac_model.conf deleted file mode 100644 index 4cfaea38..00000000 --- a/contrib/security/authz/casbin/internal/model/abac_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == r.obj.Owner \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/abac_not_using_policy_model.conf b/contrib/security/authz/casbin/internal/model/abac_not_using_policy_model.conf deleted file mode 100644 index 64c708a8..00000000 --- a/contrib/security/authz/casbin/internal/model/abac_not_using_policy_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act, eft - -[policy_effect] -e = some(where (p.eft == allow)) && !some(where (p.eft == deny)) - -[matchers] -m = r.sub == r.obj.Owner \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/abac_rule_model.conf b/contrib/security/authz/casbin/internal/model/abac_rule_model.conf deleted file mode 100644 index 591dd3a6..00000000 --- a/contrib/security/authz/casbin/internal/model/abac_rule_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub_rule, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = eval(p.sub_rule) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/basic_model.conf b/contrib/security/authz/casbin/internal/model/basic_model.conf deleted file mode 100644 index dc6da813..00000000 --- a/contrib/security/authz/casbin/internal/model/basic_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/basic_model_without_spaces.conf b/contrib/security/authz/casbin/internal/model/basic_model_without_spaces.conf deleted file mode 100644 index 5452f954..00000000 --- a/contrib/security/authz/casbin/internal/model/basic_model_without_spaces.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub,obj,act - -[policy_definition] -p = sub,obj,act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/basic_with_root_model.conf b/contrib/security/authz/casbin/internal/model/basic_with_root_model.conf deleted file mode 100644 index 8f13907e..00000000 --- a/contrib/security/authz/casbin/internal/model/basic_with_root_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && r.obj == p.obj && r.act == p.act || r.sub == "root" \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/basic_without_resources_model.conf b/contrib/security/authz/casbin/internal/model/basic_without_resources_model.conf deleted file mode 100644 index f61bd710..00000000 --- a/contrib/security/authz/casbin/internal/model/basic_without_resources_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, act - -[policy_definition] -p = sub, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/basic_without_users_model.conf b/contrib/security/authz/casbin/internal/model/basic_without_users_model.conf deleted file mode 100644 index 1fe5993c..00000000 --- a/contrib/security/authz/casbin/internal/model/basic_without_users_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = obj, act - -[policy_definition] -p = obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/comment_model.conf b/contrib/security/authz/casbin/internal/model/comment_model.conf deleted file mode 100644 index a4200ebf..00000000 --- a/contrib/security/authz/casbin/internal/model/comment_model.conf +++ /dev/null @@ -1,12 +0,0 @@ -[request_definition] -r = sub, obj, act ; Request definition - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) # This is policy effect. - -# Matchers -[matchers] -m = r.sub == p.sub && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/embed.go b/contrib/security/authz/casbin/internal/model/embed.go deleted file mode 100644 index 2b668885..00000000 --- a/contrib/security/authz/casbin/internal/model/embed.go +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package model embedding the model files for Casbin. -package model - -import ( - "embed" -) - -//go:embed rbac_model.conf -var DefaultRbacModel string - -//go:embed rbac_with_domains.conf -var DefaultRbacWithDomainModel string - -//go:embed abac_rule_model.conf -var DefaultAbacModel string - -//go:embed basic_model.conf -var DefaultAclModel string - -//go:embed keymatch_model.conf -var DefaultRestfullModel string - -//go:embed restfull_with_role.conf -var DefaultRestfullWithRoleModel string - -//go:embed *.conf -var models embed.FS - -// Models returns the embedded file system containing all models. -func Models() embed.FS { - // Return the embedded file system. - return models -} - -// Model reads a model from the embedded file system by name. -// -// Args: -// -// name (string): The name of the model to read. -// -// Returns: -// -// string: The contents of the model file. -// error: Any error that occurred while reading the model file. -func Model(name string) (string, error) { - // Read the model file from the embedded file system. - bytes, err := models.ReadFile(name) - if err != nil { - // If an error occurred, return an empty string and the error. - return "", err - } - // Convert the file contents to a string and return. - return string(bytes), nil -} - -// MustModel reads a model from the embedded file system by name, panicking on error. -// -// Args: -// -// name (string): The name of the model to read. -// -// Returns: -// -// string: The contents of the model file. -func MustModel(name string) string { - // Read the model file, panicking on error. - model, err := Model(name) - if err != nil { - // If an error occurred, panic with the error. - panic(err) - } - // Return the model file contents. - return model -} diff --git a/contrib/security/authz/casbin/internal/model/eval_operator_model.conf b/contrib/security/authz/casbin/internal/model/eval_operator_model.conf deleted file mode 100644 index 9ffb5ba4..00000000 --- a/contrib/security/authz/casbin/internal/model/eval_operator_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub_rule, obj_rule, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = eval(p.sub_rule) && eval(p.obj_rule) && (p.act == '*' || r.act == p.act) diff --git a/contrib/security/authz/casbin/internal/model/glob_model.conf b/contrib/security/authz/casbin/internal/model/glob_model.conf deleted file mode 100644 index b16cad49..00000000 --- a/contrib/security/authz/casbin/internal/model/glob_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && globMatch(r.obj, p.obj) && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/ipmatch_model.conf b/contrib/security/authz/casbin/internal/model/ipmatch_model.conf deleted file mode 100644 index 26e4b011..00000000 --- a/contrib/security/authz/casbin/internal/model/ipmatch_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = ipMatch(r.sub, p.sub) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/keyget2_model.conf b/contrib/security/authz/casbin/internal/model/keyget2_model.conf deleted file mode 100644 index 5b569a68..00000000 --- a/contrib/security/authz/casbin/internal/model/keyget2_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && keyGet2(r.obj, p.obj, 'resource') in ('age', 'name') && regexMatch(r.act, p.act) diff --git a/contrib/security/authz/casbin/internal/model/keyget_model.conf b/contrib/security/authz/casbin/internal/model/keyget_model.conf deleted file mode 100644 index cc92832b..00000000 --- a/contrib/security/authz/casbin/internal/model/keyget_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && (r.obj == p.obj || keyGet(r.obj, p.obj) in ('age','name')) && regexMatch(r.act, p.act) \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/keymatch2_model.conf b/contrib/security/authz/casbin/internal/model/keymatch2_model.conf deleted file mode 100644 index 944123de..00000000 --- a/contrib/security/authz/casbin/internal/model/keymatch2_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && keyMatch2(r.obj, p.obj) && regexMatch(r.act, p.act) \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/keymatch_custom_model.conf b/contrib/security/authz/casbin/internal/model/keymatch_custom_model.conf deleted file mode 100644 index 1cad8bfd..00000000 --- a/contrib/security/authz/casbin/internal/model/keymatch_custom_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && keyMatchCustom(r.obj, p.obj) && regexMatch(r.act, p.act) \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/keymatch_model.conf b/contrib/security/authz/casbin/internal/model/keymatch_model.conf deleted file mode 100644 index 4f86ba8f..00000000 --- a/contrib/security/authz/casbin/internal/model/keymatch_model.conf +++ /dev/null @@ -1,11 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act) \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/keymatch_with_rbac_in_domain.conf b/contrib/security/authz/casbin/internal/model/keymatch_with_rbac_in_domain.conf deleted file mode 100644 index 396fb451..00000000 --- a/contrib/security/authz/casbin/internal/model/keymatch_with_rbac_in_domain.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, dom, obj, act - -[policy_definition] -p = sub, dom, obj, act - -[role_definition] -g = _, _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub, r.dom) && keyMatch(r.dom, p.dom) && keyMatch(r.obj, p.obj) && regexMatch(r.act, p.act) diff --git a/contrib/security/authz/casbin/internal/model/multiple_policy_definitions_model.conf b/contrib/security/authz/casbin/internal/model/multiple_policy_definitions_model.conf deleted file mode 100644 index b619097a..00000000 --- a/contrib/security/authz/casbin/internal/model/multiple_policy_definitions_model.conf +++ /dev/null @@ -1,19 +0,0 @@ -[request_definition] -r = sub, obj, act -r2 = sub, obj, act - -[policy_definition] -p = sub, obj, act -p2= sub_rule, obj, act, eft - -[role_definition] -g = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -#RABC -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act -#ABAC -m2 = eval(p2.sub_rule) && r2.obj == p2.obj && r2.act == p2.act diff --git a/contrib/security/authz/casbin/internal/model/object_conditions_model.conf b/contrib/security/authz/casbin/internal/model/object_conditions_model.conf deleted file mode 100644 index 55aa1852..00000000 --- a/contrib/security/authz/casbin/internal/model/object_conditions_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, sub_rule, act - -[role_definition] -g = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub) && eval(p.sub_rule) && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/priority_model.conf b/contrib/security/authz/casbin/internal/model/priority_model.conf deleted file mode 100644 index ece1562e..00000000 --- a/contrib/security/authz/casbin/internal/model/priority_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act, eft - -[role_definition] -g = _, _ - -[policy_effect] -e = priority(p.eft) || deny - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/priority_model_enforce_context.conf b/contrib/security/authz/casbin/internal/model/priority_model_enforce_context.conf deleted file mode 100644 index 662aeb80..00000000 --- a/contrib/security/authz/casbin/internal/model/priority_model_enforce_context.conf +++ /dev/null @@ -1,16 +0,0 @@ -[request_definition] -r = sub, obj, act -r2 = sub, obj - -[policy_definition] -p = sub, obj, act, eft - -[role_definition] -g = _, _ - -[policy_effect] -e = priority(p.eft) || deny - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act -m2 = g(r2.sub, p.sub) diff --git a/contrib/security/authz/casbin/internal/model/priority_model_explicit.conf b/contrib/security/authz/casbin/internal/model/priority_model_explicit.conf deleted file mode 100644 index 5df75b27..00000000 --- a/contrib/security/authz/casbin/internal/model/priority_model_explicit.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = priority, sub, obj, act, eft - -[role_definition] -g = _, _ - -[policy_effect] -e = priority(p.eft) || deny - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/priority_model_explicit_customized.conf b/contrib/security/authz/casbin/internal/model/priority_model_explicit_customized.conf deleted file mode 100644 index 5071fa77..00000000 --- a/contrib/security/authz/casbin/internal/model/priority_model_explicit_customized.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = subject, obj, act - -[policy_definition] -p = customized_priority, obj, act, eft, subject - -[role_definition] -g = _, _ - -[policy_effect] -e = priority(p.eft) || deny - -[matchers] -m = g(r.subject, p.subject) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_model.conf b/contrib/security/authz/casbin/internal/model/rbac_model.conf deleted file mode 100644 index 71159e38..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[role_definition] -g = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_model_in_multi_line.conf b/contrib/security/authz/casbin/internal/model/rbac_model_in_multi_line.conf deleted file mode 100644 index 17771b67..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_model_in_multi_line.conf +++ /dev/null @@ -1,15 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[role_definition] -g = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj \ - && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_model_matcher_using_in_op.conf b/contrib/security/authz/casbin/internal/model/rbac_model_matcher_using_in_op.conf deleted file mode 100644 index 227d1494..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_model_matcher_using_in_op.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[role_definition] -g = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act || r.obj in ('data2', 'data3') \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_model_matcher_using_in_op_bracket.conf b/contrib/security/authz/casbin/internal/model/rbac_model_matcher_using_in_op_bracket.conf deleted file mode 100644 index 6ff819fe..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_model_matcher_using_in_op_bracket.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[role_definition] -g = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act || r.obj in ['data2', 'data3'] \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_all_pattern_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_all_pattern_model.conf deleted file mode 100644 index 045bfa57..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_all_pattern_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, dom, obj, act - -[policy_definition] -p = sub, dom, obj, act - -[role_definition] -g = _, _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = r.sub == p.sub && g(r.obj, p.obj, r.dom) && r.dom == p.dom && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_deny_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_deny_model.conf deleted file mode 100644 index 33749f00..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_deny_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act, eft - -[role_definition] -g = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) && !some(where (p.eft == deny)) - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_different_types_of_roles_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_different_types_of_roles_model.conf deleted file mode 100644 index 069f2348..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_different_types_of_roles_model.conf +++ /dev/null @@ -1,15 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, dom, obj, act - -[role_definition] -g = _, _, _, (_, _) -g2 = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub, p.dom) && g2(r.obj, p.dom) && regexMatch(r.act, p.act) diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_domain_pattern_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_domain_pattern_model.conf deleted file mode 100644 index 774e4418..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_domain_pattern_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, dom, obj, act - -[policy_definition] -p = sub, dom, obj, act - -[role_definition] -g = _, _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_domain_temporal_roles_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_domain_temporal_roles_model.conf deleted file mode 100644 index e1ab8a41..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_domain_temporal_roles_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, dom, obj, act - -[policy_definition] -p = sub, dom, obj, act - -[role_definition] -g = _, _, _, (_, _) - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_domains.conf b/contrib/security/authz/casbin/internal/model/rbac_with_domains.conf deleted file mode 100644 index f7dff617..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_domains.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act, dom - -[policy_definition] -p = sub, obj, act, dom - -[role_definition] -g = _, _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub, r.dom) && r.obj == p.obj && r.act == p.act && r.dom == p.dom diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_domains_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_domains_model.conf deleted file mode 100644 index 57c37216..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_domains_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, dom, obj, act - -[policy_definition] -p = sub, dom, obj, act - -[role_definition] -g = _, _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_multiple_policy_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_multiple_policy_model.conf deleted file mode 100644 index d4581acd..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_multiple_policy_model.conf +++ /dev/null @@ -1,17 +0,0 @@ -[request_definition] -r = user, thing, action - -[policy_definition] -p = role, thing, action -p2 = role, action - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.user, p.role) && r.thing == p.thing && r.action == p.action -m2 = g(r.user, p2.role) && r.action == p.action - -[role_definition] -g = _,_ -g2 = _,_ \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_not_deny_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_not_deny_model.conf deleted file mode 100644 index 1e8a3e68..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_not_deny_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act, eft - -[role_definition] -g = _, _ - -[policy_effect] -e = !some(where (p.eft == deny)) - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_pattern_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_pattern_model.conf deleted file mode 100644 index 84580d90..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_pattern_model.conf +++ /dev/null @@ -1,15 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[role_definition] -g = _, _ -g2 = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub) && g2(r.obj, p.obj) && regexMatch(r.act, p.act) \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_resource_roles_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_resource_roles_model.conf deleted file mode 100644 index 845bc6c7..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_resource_roles_model.conf +++ /dev/null @@ -1,15 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[role_definition] -g = _, _ -g2 = _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub) && g2(r.obj, p.obj) && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/rbac_with_temporal_roles_model.conf b/contrib/security/authz/casbin/internal/model/rbac_with_temporal_roles_model.conf deleted file mode 100644 index feeae160..00000000 --- a/contrib/security/authz/casbin/internal/model/rbac_with_temporal_roles_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act - -[role_definition] -g = _, _, (_, _) - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/restfull_with_role.conf b/contrib/security/authz/casbin/internal/model/restfull_with_role.conf deleted file mode 100644 index 7d955cc1..00000000 --- a/contrib/security/authz/casbin/internal/model/restfull_with_role.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act, dom - -[policy_definition] -p = sub, obj, act, dom - -[role_definition] -g = _, _, _ - -[policy_effect] -e = some(where (p.eft == allow)) - -[matchers] -m = g(r.sub, p.sub, r.dom) && keyMatch2(r.obj, p.obj) && (regexMatch(r.act, p.act) || p.act == 'ANY') && (keyMatch(r.dom, p.dom) || p.dom == '*') diff --git a/contrib/security/authz/casbin/internal/model/subject_priority_model.conf b/contrib/security/authz/casbin/internal/model/subject_priority_model.conf deleted file mode 100644 index 77b8c4eb..00000000 --- a/contrib/security/authz/casbin/internal/model/subject_priority_model.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, act - -[policy_definition] -p = sub, obj, act, eft - -[role_definition] -g = _, _ - -[policy_effect] -e = subjectPriority(p.eft) || deny - -[matchers] -m = g(r.sub, p.sub) && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/model/subject_priority_model_with_domain.conf b/contrib/security/authz/casbin/internal/model/subject_priority_model_with_domain.conf deleted file mode 100644 index 84ec518c..00000000 --- a/contrib/security/authz/casbin/internal/model/subject_priority_model_with_domain.conf +++ /dev/null @@ -1,14 +0,0 @@ -[request_definition] -r = sub, obj, dom, act - -[policy_definition] -p = sub, obj, dom, act, eft #sub can't change position,must be first - -[role_definition] -g = _, _, _ - -[policy_effect] -e = subjectPriority(p.eft) || deny - -[matchers] -m = g(r.sub, p.sub, r.dom) && r.dom == p.dom && r.obj == p.obj && r.act == p.act \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/abac_rule_effect_policy.csv b/contrib/security/authz/casbin/internal/policy/abac_rule_effect_policy.csv deleted file mode 100644 index bea99626..00000000 --- a/contrib/security/authz/casbin/internal/policy/abac_rule_effect_policy.csv +++ /dev/null @@ -1,4 +0,0 @@ -p, alice, /data1, read, deny -p, alice, /data1, write, allow -p, bob, /data2, write, deny -p, bob, /data2, read, allow \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/abac_rule_policy.csv b/contrib/security/authz/casbin/internal/policy/abac_rule_policy.csv deleted file mode 100644 index e3dbc833..00000000 --- a/contrib/security/authz/casbin/internal/policy/abac_rule_policy.csv +++ /dev/null @@ -1,2 +0,0 @@ -p, r.sub.Age > 18, /data1, read -p, r.sub.Age < 60, /data2, write \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/basic_inverse_policy.csv b/contrib/security/authz/casbin/internal/policy/basic_inverse_policy.csv deleted file mode 100644 index 276c4403..00000000 --- a/contrib/security/authz/casbin/internal/policy/basic_inverse_policy.csv +++ /dev/null @@ -1,2 +0,0 @@ -p, alice, data1, write -p, bob, data2, read \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/basic_policy.csv b/contrib/security/authz/casbin/internal/policy/basic_policy.csv deleted file mode 100644 index 57aaa976..00000000 --- a/contrib/security/authz/casbin/internal/policy/basic_policy.csv +++ /dev/null @@ -1,2 +0,0 @@ -p, alice, data1, read -p, bob, data2, write \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/basic_without_resources_policy.csv b/contrib/security/authz/casbin/internal/policy/basic_without_resources_policy.csv deleted file mode 100644 index c861941b..00000000 --- a/contrib/security/authz/casbin/internal/policy/basic_without_resources_policy.csv +++ /dev/null @@ -1,2 +0,0 @@ -p, alice, read -p, bob, write \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/basic_without_users_policy.csv b/contrib/security/authz/casbin/internal/policy/basic_without_users_policy.csv deleted file mode 100644 index 79048da6..00000000 --- a/contrib/security/authz/casbin/internal/policy/basic_without_users_policy.csv +++ /dev/null @@ -1,2 +0,0 @@ -p, data1, read -p, data2, write \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/embed.go b/contrib/security/authz/casbin/internal/policy/embed.go deleted file mode 100644 index ea6cbd4f..00000000 --- a/contrib/security/authz/casbin/internal/policy/embed.go +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package policy embedding the policy files for Casbin. -package policy - -import ( - "embed" - _ "embed" -) - -//go:embed *.csv -var policies embed.FS - -// Policies returns the embedded file system containing all policies. -func Policies() embed.FS { - return policies -} - -// Policy reads and returns the contents of a policy file from the embedded file system. -// -// Args: -// -// name (string): The name of the policy file to read. -// -// Returns: -// -// ([]byte, error): The contents of the policy file as a byte slice, or an error if the file does not exist. -func Policy(name string) ([]byte, error) { - return policies.ReadFile(name) -} - -// MustPolicy reads and returns the contents of a policy file from the embedded file system. -// -// Note: This function is identical to Policy and may be removed in the future. -// -// Args: -// -// name (string): The name of the policy file to read. -// -// Returns: -// -// ([]byte, error): The contents of the policy file as a byte slice, or an error if the file does not exist. -func MustPolicy(name string) []byte { - bytes, err := policies.ReadFile(name) - if err != nil { - panic(err) - } - return bytes -} diff --git a/contrib/security/authz/casbin/internal/policy/eval_operator_policy.csv b/contrib/security/authz/casbin/internal/policy/eval_operator_policy.csv deleted file mode 100644 index 85665a87..00000000 --- a/contrib/security/authz/casbin/internal/policy/eval_operator_policy.csv +++ /dev/null @@ -1 +0,0 @@ -p, r.sub == 'admin' || false, r.obj == 'users', write \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/glob_policy.csv b/contrib/security/authz/casbin/internal/policy/glob_policy.csv deleted file mode 100644 index 86c03b07..00000000 --- a/contrib/security/authz/casbin/internal/policy/glob_policy.csv +++ /dev/null @@ -1,4 +0,0 @@ -p, u1, /foo/*, read -p, u2, /foo*, read -p, u3, /*/foo/*, read -p, u4, *, read \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/ipmatch_policy.csv b/contrib/security/authz/casbin/internal/policy/ipmatch_policy.csv deleted file mode 100644 index ca678a92..00000000 --- a/contrib/security/authz/casbin/internal/policy/ipmatch_policy.csv +++ /dev/null @@ -1,2 +0,0 @@ -p, 192.168.2.0/24, data1, read -p, 10.0.0.0/16, data2, write \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/keymatch2_policy.csv b/contrib/security/authz/casbin/internal/policy/keymatch2_policy.csv deleted file mode 100644 index 941a48f8..00000000 --- a/contrib/security/authz/casbin/internal/policy/keymatch2_policy.csv +++ /dev/null @@ -1,2 +0,0 @@ -p, alice, /alice_data/:resource, GET -p, alice, /alice_data2/:id/using/:resId, GET \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/keymatch_policy.csv b/contrib/security/authz/casbin/internal/policy/keymatch_policy.csv deleted file mode 100644 index d6e9b7d4..00000000 --- a/contrib/security/authz/casbin/internal/policy/keymatch_policy.csv +++ /dev/null @@ -1,7 +0,0 @@ -p, alice, /alice_data/*, GET -p, alice, /alice_data/resource1, POST - -p, bob, /alice_data/resource2, GET -p, bob, /bob_data/*, POST - -p, cathy, /cathy_data, (GET)|(POST) \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/keymatch_with_rbac_in_domain.csv b/contrib/security/authz/casbin/internal/policy/keymatch_with_rbac_in_domain.csv deleted file mode 100644 index 300579f1..00000000 --- a/contrib/security/authz/casbin/internal/policy/keymatch_with_rbac_in_domain.csv +++ /dev/null @@ -1,6 +0,0 @@ -g, can_manage, can_use, * - -p, can_manage, engines/*, *, (pause)|(resume) -p, can_use, engines/*, *, (attach)|(detach) - -g, Username==test2, can_manage, engines/engine1 diff --git a/contrib/security/authz/casbin/internal/policy/multiple_policy_definitions_policy.csv b/contrib/security/authz/casbin/internal/policy/multiple_policy_definitions_policy.csv deleted file mode 100644 index 66498ab3..00000000 --- a/contrib/security/authz/casbin/internal/policy/multiple_policy_definitions_policy.csv +++ /dev/null @@ -1,5 +0,0 @@ -p, data2_admin, data2, read -p2, r2.sub.Age > 18 && r2.sub.Age < 60, /data1, read, allow -p2, r2.sub.Age > 60 && r2.sub.Age < 100, /data1, read, deny - -g, alice, data2_admin \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/object_conditions_policy.csv b/contrib/security/authz/casbin/internal/policy/object_conditions_policy.csv deleted file mode 100644 index 7dad5c84..00000000 --- a/contrib/security/authz/casbin/internal/policy/object_conditions_policy.csv +++ /dev/null @@ -1,5 +0,0 @@ -p, alice, r.obj.price < 25, read -p, admin, r.obj.category_id = 2, read -p, bob, r.obj.author = bob, write - -g, alice, admin \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/priority_indeterminate_policy.csv b/contrib/security/authz/casbin/internal/policy/priority_indeterminate_policy.csv deleted file mode 100644 index 974aa27e..00000000 --- a/contrib/security/authz/casbin/internal/policy/priority_indeterminate_policy.csv +++ /dev/null @@ -1 +0,0 @@ -p, alice, data1, read, indeterminate \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/priority_policy.csv b/contrib/security/authz/casbin/internal/policy/priority_policy.csv deleted file mode 100644 index 1ec5e5a7..00000000 --- a/contrib/security/authz/casbin/internal/policy/priority_policy.csv +++ /dev/null @@ -1,12 +0,0 @@ -p, alice, data1, read, allow -p, data1_deny_group, data1, read, deny -p, data1_deny_group, data1, write, deny -p, alice, data1, write, allow - -g, alice, data1_deny_group - -p, data2_allow_group, data2, read, allow -p, bob, data2, read, deny -p, bob, data2, write, deny - -g, bob, data2_allow_group \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/priority_policy_enforce_context.csv b/contrib/security/authz/casbin/internal/policy/priority_policy_enforce_context.csv deleted file mode 100644 index 756de5c5..00000000 --- a/contrib/security/authz/casbin/internal/policy/priority_policy_enforce_context.csv +++ /dev/null @@ -1,12 +0,0 @@ -p, alice, data1, read, allow -p, data1_deny_group, data1, read, deny -p, data1_deny_group, data1, write, deny -p, alice, data1, write, allow - -g, alice, data1_deny_group - -p, data2_allow_group, data2, read, allow -p, bob, data2, read, deny -p, bob, data2, write, deny - -g, bob, data2_allow_group diff --git a/contrib/security/authz/casbin/internal/policy/priority_policy_explicit.csv b/contrib/security/authz/casbin/internal/policy/priority_policy_explicit.csv deleted file mode 100644 index 0fec82c5..00000000 --- a/contrib/security/authz/casbin/internal/policy/priority_policy_explicit.csv +++ /dev/null @@ -1,12 +0,0 @@ -p, 10, data1_deny_group, data1, read, deny -p, 10, data1_deny_group, data1, write, deny -p, 10, data2_allow_group, data2, read, allow -p, 10, data2_allow_group, data2, write, allow - - -p, 1, alice, data1, write, allow -p, 1, alice, data1, read, allow -p, 1, bob, data2, read, deny - -g, bob, data2_allow_group -g, alice, data1_deny_group diff --git a/contrib/security/authz/casbin/internal/policy/priority_policy_explicit_customized.csv b/contrib/security/authz/casbin/internal/policy/priority_policy_explicit_customized.csv deleted file mode 100644 index a861e2ba..00000000 --- a/contrib/security/authz/casbin/internal/policy/priority_policy_explicit_customized.csv +++ /dev/null @@ -1,12 +0,0 @@ -p, 10, data1, read, deny, data1_deny_group -p, 10, data1, write, deny, data1_deny_group -p, 10, data2, read, allow, data2_allow_group -p, 10, data2, write, allow, data2_allow_group - - -p, 1, data1, write, allow, alice -p, 1, data1, read, allow, alice -p, 1, data2, read, deny, bob - -g, bob, data2_allow_group -g, alice, data1_deny_group diff --git a/contrib/security/authz/casbin/internal/policy/rbac_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_policy.csv deleted file mode 100644 index f93d6df8..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_policy.csv +++ /dev/null @@ -1,5 +0,0 @@ -p, alice, data1, read -p, bob, data2, write -p, data2_admin, data2, read -p, data2_admin, data2, write -g, alice, data2_admin \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_all_pattern_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_all_pattern_policy.csv deleted file mode 100644 index 8097be8a..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_all_pattern_policy.csv +++ /dev/null @@ -1,4 +0,0 @@ -p, alice, domain1, book_group, read -p, alice, domain2, book_group, write - -g, /book/:id, book_group, * \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_deny_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_deny_policy.csv deleted file mode 100644 index 0603db8d..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_deny_policy.csv +++ /dev/null @@ -1,7 +0,0 @@ -p, alice, data1, read, allow -p, bob, data2, write, allow -p, data2_admin, data2, read, allow -p, data2_admin, data2, write, allow -p, alice, data2, write, deny - -g, alice, data2_admin \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_different_types_of_roles_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_different_types_of_roles_policy.csv deleted file mode 100644 index 67d090be..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_different_types_of_roles_policy.csv +++ /dev/null @@ -1,12 +0,0 @@ -p, role:owner, domain1, _, (read|write) -p, role:developer, domain1, _, read - -p, role:owner, domain2, _, (read|write) -p, role:developer, domain2, _, read - -g, alice, role:owner, domain1, _, _ -g, bob, role:developer, domain2, _, 9999-12-30 00:00:00 -g, carol, role:owner, domain2, _, 0000-01-02 00:00:00 - -g2, data1, domain1 -g2, data2, domain2 diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_domain_pattern_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_domain_pattern_policy.csv deleted file mode 100644 index 783f721e..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_domain_pattern_policy.csv +++ /dev/null @@ -1,8 +0,0 @@ -p, admin, domain1, data1, read -p, admin, domain1, data1, write -p, admin, domain2, data2, read -p, admin, domain2, data2, write -p, admin, *, data3, read - -g, alice, admin, * -g, bob, admin, domain2 \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_domain_temporal_roles_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_domain_temporal_roles_policy.csv deleted file mode 100644 index 8234b64b..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_domain_temporal_roles_policy.csv +++ /dev/null @@ -1,24 +0,0 @@ -p, alice, domain1, data1, read -p, alice, domain1, data1, write -p, data2_admin, domain2, data2, read -p, data2_admin, domain2, data2, write -p, data3_admin, domain3, data3, read -p, data3_admin, domain3, data3, write -p, data4_admin, domain4, data4, read -p, data4_admin, domain4, data4, write -p, data5_admin, domain5, data5, read -p, data5_admin, domain5, data5, write -p, data6_admin, domain6, data6, read -p, data6_admin, domain6, data6, write -p, data7_admin, domain7, data7, read -p, data7_admin, domain7, data7, write -p, data8_admin, domain8, data8, read -p, data8_admin, domain8, data8, write - -g, alice, data2_admin, domain2, 0000-01-01 00:00:00, 0000-01-02 00:00:00 -g, alice, data3_admin, domain3, 0000-01-01 00:00:00, 9999-12-30 00:00:00 -g, alice, data4_admin, domain4, _, _ -g, alice, data5_admin, domain5, _, 9999-12-30 00:00:00 -g, alice, data6_admin, domain6, _, 0000-01-02 00:00:00 -g, alice, data7_admin, domain7, 0000-01-01 00:00:00, _ -g, alice, data8_admin, domain8, 9999-12-30 00:00:00, _ \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_domains_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_domains_policy.csv deleted file mode 100644 index 8558d171..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_domains_policy.csv +++ /dev/null @@ -1,6 +0,0 @@ -p, admin, domain1, data1, read -p, admin, domain1, data1, write -p, admin, domain2, data2, read -p, admin, domain2, data2, write -g, alice, admin, domain1 -g, bob, admin, domain2 \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_domains_policy2.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_domains_policy2.csv deleted file mode 100644 index 39ff8104..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_domains_policy2.csv +++ /dev/null @@ -1,10 +0,0 @@ -p, admin, domain1, data1, read -p, admin, domain1, data1, write -p, admin, domain2, data2, read -p, admin, domain2, data2, write -p, user, domain3, data2, read -g, alice, admin, domain1 -g, alice, admin, domain2 -g, bob, admin, domain2 -g, bob, user, domain3 - diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_hierarchy_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_hierarchy_policy.csv deleted file mode 100644 index f7229986..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_hierarchy_policy.csv +++ /dev/null @@ -1,10 +0,0 @@ -p, alice, data1, read -p, bob, data2, write -p, data1_admin, data1, read -p, data1_admin, data1, write -p, data2_admin, data2, read -p, data2_admin, data2, write - -g, alice, admin -g, admin, data1_admin -g, admin, data2_admin \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_hierarchy_with_domains_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_hierarchy_with_domains_policy.csv deleted file mode 100644 index 45d91739..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_hierarchy_with_domains_policy.csv +++ /dev/null @@ -1,11 +0,0 @@ -p, role:reader, domain1, data1, read -p, role:writer, domain1, data1, write - -p, alice, domain1, data2, read -p, alice, domain2, data2, read - -g, role:global_admin, role:reader, domain1 -g, role:global_admin, role:writer, domain1 - -g, alice, role:global_admin, domain1 - diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_multiple_policy_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_multiple_policy_policy.csv deleted file mode 100644 index 0afb588d..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_multiple_policy_policy.csv +++ /dev/null @@ -1,9 +0,0 @@ -p, user, /data, GET -p, admin, /data, POST - -p2, user, view -p2, admin, create - -g, admin, user -g, alice, admin -g2, alice, user \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_pattern_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_pattern_policy.csv deleted file mode 100644 index bbe76872..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_pattern_policy.csv +++ /dev/null @@ -1,28 +0,0 @@ -p, alice, /pen/1, GET -p, alice, /pen2/1, GET -p, book_admin, book_group, GET -p, pen_admin, pen_group, GET -p, *, pen3_group, GET - -p, /book/admin/:id, pen4_group, GET -g, /book/user/:id, /book/admin/1 - -p, /book/leader/2, pen4_group, POST -g, /book/user/:id, /book/leader/2 - -g, alice, book_admin -g, bob, pen_admin - -g, cathy, /book/1/2/3/4/5 -g, cathy, pen_admin - -g2, /book/*, book_group - -g2, /book/:id, book_group -g2, /pen/:id, pen_group - -g2, /book2/{id}, book_group -g2, /pen2/{id}, pen_group - -g2, /pen3/:id, pen3_group -g2, /pen4/:id, pen4_group \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_resource_roles_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_resource_roles_policy.csv deleted file mode 100644 index b1d36daf..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_resource_roles_policy.csv +++ /dev/null @@ -1,7 +0,0 @@ -p, alice, data1, read -p, bob, data2, write -p, data_group_admin, data_group, write - -g, alice, data_group_admin -g2, data1, data_group -g2, data2, data_group \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/rbac_with_temporal_roles_policy.csv b/contrib/security/authz/casbin/internal/policy/rbac_with_temporal_roles_policy.csv deleted file mode 100644 index c8f77e7b..00000000 --- a/contrib/security/authz/casbin/internal/policy/rbac_with_temporal_roles_policy.csv +++ /dev/null @@ -1,24 +0,0 @@ -p, alice, data1, read -p, alice, data1, write -p, data2_admin, data2, read -p, data2_admin, data2, write -p, data3_admin, data3, read -p, data3_admin, data3, write -p, data4_admin, data4, read -p, data4_admin, data4, write -p, data5_admin, data5, read -p, data5_admin, data5, write -p, data6_admin, data6, read -p, data6_admin, data6, write -p, data7_admin, data7, read -p, data7_admin, data7, write -p, data8_admin, data8, read -p, data8_admin, data8, write - -g, alice, data2_admin, 0000-01-01 00:00:00, 0000-01-02 00:00:00 -g, alice, data3_admin, 0000-01-01 00:00:00, 9999-12-30 00:00:00 -g, alice, data4_admin, _, _ -g, alice, data5_admin, _, 9999-12-30 00:00:00 -g, alice, data6_admin, _, 0000-01-02 00:00:00 -g, alice, data7_admin, 0000-01-01 00:00:00, _ -g, alice, data8_admin, 9999-12-30 00:00:00, _ \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/subject_priority_policy.csv b/contrib/security/authz/casbin/internal/policy/subject_priority_policy.csv deleted file mode 100644 index 24a44223..00000000 --- a/contrib/security/authz/casbin/internal/policy/subject_priority_policy.csv +++ /dev/null @@ -1,16 +0,0 @@ -p, root, data1, read, deny -p, admin, data1, read, deny - -p, editor, data1, read, deny -p, subscriber, data1, read, deny - -p, jane, data1, read, allow -p, alice, data1, read, allow - -g, admin, root - -g, editor, admin -g, subscriber, admin - -g, jane, editor -g, alice, subscriber \ No newline at end of file diff --git a/contrib/security/authz/casbin/internal/policy/subject_priority_policy_with_domain.csv b/contrib/security/authz/casbin/internal/policy/subject_priority_policy_with_domain.csv deleted file mode 100644 index c4859ecd..00000000 --- a/contrib/security/authz/casbin/internal/policy/subject_priority_policy_with_domain.csv +++ /dev/null @@ -1,7 +0,0 @@ -p, admin, data1, domain1, write, deny -p, alice, data1, domain1, write, allow -p, admin, data2, domain2, write, deny -p, bob, data2, domain2, write, allow - -g, alice, admin, domain1 -g, bob, admin, domain2 \ No newline at end of file diff --git a/contrib/security/authz/casbin/notifier.go b/contrib/security/authz/casbin/notifier.go deleted file mode 100644 index 7a731641..00000000 --- a/contrib/security/authz/casbin/notifier.go +++ /dev/null @@ -1,56 +0,0 @@ -package casbin - -import ( - "sync" - - "github.com/origadmin/runtime/log" -) - -type PolicyNotifier interface { - AddObserver(name string, callback func()) - RemoveObserver(name string) - NotifyAll() -} - -type policyNotifier struct { - observers map[string]func() - mu sync.RWMutex -} - -func NewPolicyNotifier() PolicyNotifier { - return &policyNotifier{ - observers: make(map[string]func()), - } -} - -func (n *policyNotifier) AddObserver(name string, callback func()) { - n.mu.Lock() - defer n.mu.Unlock() - n.observers[name] = callback - log.Debugf("Added policy observer: %s", name) -} - -func (n *policyNotifier) RemoveObserver(name string) { - n.mu.Lock() - defer n.mu.Unlock() - delete(n.observers, name) - log.Debugf("Removed policy observer: %s", name) -} - -func (n *policyNotifier) NotifyAll() { - n.mu.RLock() - defer n.mu.RUnlock() - - log.Info("Notifying all policy observers") - for name, cb := range n.observers { - log.Debugf("Triggering policy update for: %s", name) - go func(name string, callback func()) { - defer func() { - if err := recover(); err != nil { - log.Errorf("Policy observer %s panic: %v", name, err) - } - }() - callback() - }(name, cb) - } -} diff --git a/contrib/security/authz/casbin/option.go b/contrib/security/authz/casbin/option.go deleted file mode 100644 index 41324b91..00000000 --- a/contrib/security/authz/casbin/option.go +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package casbin - -import ( - "time" - - "github.com/casbin/casbin/v2" - casbinmodel "github.com/casbin/casbin/v2/model" - "github.com/casbin/casbin/v2/persist" - - "origadmin/application/admin/contrib/security/authz/casbin/internal/model" -) - -// AuthorizerOptions contains configuration parameters for Casbin authorizer -// Model: Required, Casbin model definition -// Adapter: Required, policy persistence adapter -// Watcher: Optional, policy change watcher -// Enforcer: Optional, existing synced enforcer instance -// SyncInterval: Optional, policy sync interval (default 5s) -// Source: gRPC source for policy data service -// WildcardItem: Permission matching wildcard (default "*") -type AuthorizerOptions struct { - Model casbinmodel.Model - Adapter persist.Adapter - Watcher persist.Watcher - Enforcer *casbin.SyncedEnforcer - SyncInterval time.Duration - Source RuleSource - WildcardItem string - EnablePrometheus bool -} - -// AuthorizerOption function type for configuring AuthorizerOptions -type AuthorizerOption = func(*AuthorizerOptions) - -// DefaultAuthorizerOptions parameters for authorizer -// Model: Creates new empty model -// Watcher: Initializes new watcher instance -// SyncInterval: 5s sync interval -// WildcardItem: Wildcard "*" -var ( - DefaultAuthorizerOptions = AuthorizerOptions{ - Watcher: NewWatcher(), - SyncInterval: 30 * time.Second, - WildcardItem: "*", - } -) - -// DefaultModel provides default RESTful role-based model definition -// Returns: Predefined RBAC with RESTful model string -func DefaultModel() string { - return model.DefaultRestfullWithRoleModel -} - -// WithModel sets custom Casbin model configuration -// model: Casbin model instance to use -func WithModel(model casbinmodel.Model) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.Model = model - } -} - -// WithStringModel configures model from definition string -// str: Model definition string in Casbin syntax -func WithStringModel(str string) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.Model, _ = casbinmodel.NewModelFromString(str) - } -} - -// WithFileModel loads model configuration from file -// path: Path to model configuration file -func WithFileModel(path string) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.Model, _ = casbinmodel.NewModelFromFile(path) - } -} - -// WithNameModel sets model using predefined model name -// name: Predefined model name from internal/model package -func WithNameModel(name string) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.Model, _ = casbinmodel.NewModelFromString(model.MustModel(name)) - } -} - -// WithPolicyAdapter sets policy storage adapter -// adapter: Persistence adapter instance (database/file/etc) -func WithPolicyAdapter(adapter persist.Adapter) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.Adapter = adapter - } -} - -// WithWatcher sets policy change watcher -// watcher: Watcher implementation for cluster synchronization -func WithWatcher(watcher persist.Watcher) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.Watcher = watcher - } -} - -// WithSyncInterval sets policy synchronization interval -// interval: Duration between policy sync operations -func WithSyncInterval(interval time.Duration) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.SyncInterval = interval - } -} - -// WithEnforcer reuses existing enforcer instance -// enforcer: Preconfigured synced enforcer instance -func WithEnforcer(enforcer *casbin.SyncedEnforcer) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.Enforcer = enforcer - } -} - -// WithWildcardItem sets permission matching wildcard -// item: Wildcard symbol for policy matching (default "*") -func WithWildcardItem(item string) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.WildcardItem = item - } -} - -// WithSource sets gRPC policy source service source -// source: gRPC source implementing CasbinSourceService -func WithSource(source RuleSource) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.Source = source - } -} - -// WithPrometheusMetrics enables Prometheus metrics collection -// enable: Enable Prometheus metrics collection (default false) -func WithPrometheusMetrics(enable bool) AuthorizerOption { - return func(s *AuthorizerOptions) { - s.EnablePrometheus = enable - } -} - -func (s *AuthorizerOptions) Setup() error { - if s.Adapter == nil { - s.Adapter = NewAdapter(nil) - } - - if s.Model == nil { - var err error - s.Model, err = casbinmodel.NewModelFromString(DefaultModel()) - if err != nil { - return err - } - } - - if s.Watcher == nil { - s.Watcher = NewWatcher() - } - return nil -} diff --git a/contrib/security/authz/casbin/update.go b/contrib/security/authz/casbin/update.go deleted file mode 100644 index 46958792..00000000 --- a/contrib/security/authz/casbin/update.go +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package casbin implements the functions, types, and interfaces for the module. -package casbin - -import ( - "context" - "errors" - "fmt" - "io" - "time" - - "github.com/casbin/casbin/v2" - "github.com/casbin/casbin/v2/persist" - "github.com/goexts/generic/maps" - "github.com/origadmin/runtime/interfaces/security" - "github.com/origadmin/runtime/log" - "google.golang.org/grpc" - "google.golang.org/grpc/status" - - pb "origadmin/application/admin/api/v1/services/auth" -) - -type RuleSource interface { - ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) - ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) - WatchUpdate(ctx context.Context, in *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) - StreamRules(ctx context.Context, in *pb.StreamRulesRequest) (grpc.ServerStreamingClient[pb.StreamRulesResponse], error) -} - -type PolicyUpdater struct { - source RuleSource - adapter persist.Adapter - enforcer *casbin.SyncedEnforcer - lastModified int64 - interval time.Duration - metric bool -} - -func (u *PolicyUpdater) Sync(ctx context.Context) (bool, error) { - start := time.Now() - defer func() { - if u.metric { - policySyncDuration.Observe(time.Since(start).Seconds()) - } - }() - - update, err := u.source.WatchUpdate(ctx, &pb.WatchUpdateRequest{ - LastModified: u.lastModified, - }) - if err != nil { - return false, err - } - if u.lastModified > update.ModifiedDate { - return false, nil - } - fmt.Printf("Received update: %v to %v\n", u.lastModified, update.ModifiedDate) - - stream, err := u.source.StreamRules(ctx, &pb.StreamRulesRequest{ - WithGroupings: true, - WithPolicies: true, - }) - if err != nil { - return false, err - } - - policies := make(map[string][][]string) - for { - rule, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - return false, status.Errorf(status.Code(err), "received stream error: %v", err) - } - - switch v := rule.RuleType.(type) { - case *pb.StreamRulesResponse_Policy: - policies[v.Policy.PType] = append(policies[v.Policy.PType], v.Policy.Params) - case *pb.StreamRulesResponse_Grouping: - policies[v.Grouping.PType] = append(policies[v.Grouping.PType], v.Grouping.Params) - } - } - - if len(policies) > 0 { - for s, v := range policies { - log.Infof("record policy: type(%s), len(%d)", s, len(v)) - } - switch setter := u.adapter.(type) { - case *adapter: - log.Info("set policies(inner)") - setter.typedPolicies = policies - case security.PolicyRegistry: - log.Info("set policies") - pm := maps.Transform(policies, func(k string, v [][]string) (string, any, bool) { - return k, any(v), true - }) - if err := setter.SetPolicies(ctx, pm); err != nil { - return false, err - } - default: - return false, errors.New("unsupported adapter") - } - if u.metric { - policyCountGauge.Set(float64(len(policies))) - policySyncCounter.WithLabelValues("success").Inc() - } - - u.lastModified = time.Now().Unix() - //todo: update lastModified - //u.lastModified = update.ModifiedDate - return true, nil - } - return false, nil -} - -func (u *PolicyUpdater) Watch(ctx context.Context, notifier persist.Watcher) { - ticker := time.NewTicker(u.interval) - defer ticker.Stop() - - for { - select { - case <-ticker.C: - if update, err := u.Sync(ctx); err != nil || !update { - //log.Errorf("Policy sync failed: err(%v) update(%t)", err, update) - continue - } - _ = notifier.Update() - case <-ctx.Done(): - return - } - } -} diff --git a/contrib/security/authz/casbin/watcher.go b/contrib/security/authz/casbin/watcher.go deleted file mode 100644 index 22234f7d..00000000 --- a/contrib/security/authz/casbin/watcher.go +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package casbin implements the functions, types, and interfaces for the module. -package casbin - -import ( - "sync" - - "github.com/casbin/casbin/v2/persist" -) - -type Watcher interface { - SetUpdateCallback(f func(string)) error - Update() error - Close() -} - -type watcher struct { - mu sync.RWMutex - callback func(string) -} - -func (w *watcher) SetUpdateCallback(f func(string)) error { - w.mu.Lock() - defer w.mu.Unlock() - w.callback = f - return nil -} - -func (w *watcher) Update() error { - w.mu.RLock() - defer w.mu.RUnlock() - if w.callback != nil { - w.callback("") - } - return nil -} - -func (w *watcher) Close() { - w.mu.Lock() - defer w.mu.Unlock() - w.callback = nil -} - -func NewWatcher() persist.Watcher { - return &watcher{} -} - -var _ persist.Watcher = &watcher{} diff --git a/contrib/security/token.go b/contrib/security/token.go deleted file mode 100644 index 8ad9ea34..00000000 --- a/contrib/security/token.go +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package securityx implements the functions, types, and interfaces for the module. -package security - -import ( - "fmt" - "strings" - - "github.com/go-kratos/kratos/v2/transport" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/security" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -// TokenToContext . -func TokenToContext(ctx context.Context, tokenType security.TokenSource, scheme string, token string) context.Context { - switch tokenType { - case security.TokenSourceMetadata: - return injectTokenMetadataContext(ctx, scheme, token) - case security.TokenSourceMetadataClient: - return injectTokenMetadataClientContext(ctx, scheme, token) - case security.TokenSourceMetadataServer: - return injectTokenMetadataServerContext(ctx, scheme, token) - case security.TokenSourceHeader: - return injectHeaderTransportContext(ctx, scheme, token) - case security.TokenSourceServerHeader: - return injectServerTransportContext(ctx, scheme, token) - case security.TokenSourceClientHeader: - return injectClientTransportContext(ctx, scheme, token) - case security.TokenSourceContext: - return security.NewTokenContext(ctx, formatToken(scheme, token)) - default: - return injectTokenMetadataContext(ctx, scheme, token) - } -} - -func extractTokenFromContext(ctx context.Context, tokenType security.TokenSource) string { - switch tokenType { - case security.TokenSourceMetadata: - return extractTokenMetadataContext(ctx) - case security.TokenSourceMetadataClient: - return extractTokenMetadataClientContext(ctx) - case security.TokenSourceMetadataServer: - return extractTokenMetadataServerContext(ctx) - case security.TokenSourceHeader: - return extractHeaderTransportContext(ctx) - case security.TokenSourceServerHeader: - return extractServerTransportContext(ctx) - case security.TokenSourceClientHeader: - return extractClientTransportContext(ctx) - case security.TokenSourceContext: - return security.TokenFromContext(ctx) - default: - return extractTokenMetadataContext(ctx) - } -} - -// TokenFromContext . -func TokenFromContext(ctx context.Context, tokenType security.TokenSource, scheme string) (string, error) { - val := extractTokenFromContext(ctx, tokenType) - if val == "" { - return "", status.Errorf(codes.Unauthenticated, "Request unauthenticated with "+scheme) - } - - splits := strings.SplitN(val, " ", 2) - if len(splits) < 2 { - return "", status.Errorf(codes.Unauthenticated, "Bad authorization string") - } - - if !strings.EqualFold(splits[0], scheme) { - return "", status.Errorf(codes.Unauthenticated, "Request unauthenticated with "+scheme) - } - - return splits[1], nil -} - -func formatToken(scheme string, tokenStr string) string { - return fmt.Sprintf("%s %s", scheme, tokenStr) -} - -func TokenFromTransportClient(authorize string, scheme string) func(ctx context.Context) string { - return func(ctx context.Context) string { - if tr, ok := transport.FromClientContext(ctx); ok { - token := tr.RequestHeader().Get(authorize) - splits := strings.SplitN(token, " ", 2) - if len(splits) > 1 && strings.EqualFold(splits[0], scheme) { - return splits[1] - } - } - return "" - } -} - -func TokenFromTransportServer(authorize string, scheme string) func(ctx context.Context) string { - return func(ctx context.Context) string { - if tr, ok := transport.FromServerContext(ctx); ok { - token := tr.RequestHeader().Get(authorize) - splits := strings.SplitN(token, " ", 2) - if len(splits) > 1 && strings.EqualFold(splits[0], scheme) { - return splits[1] - } - } - return "" - } -} diff --git a/contrib/security/token_metadata.go b/contrib/security/token_metadata.go deleted file mode 100644 index 7e08158c..00000000 --- a/contrib/security/token_metadata.go +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package securityx implements the functions, types, and interfaces for the module. -package security - -import ( - kmetadata "github.com/go-kratos/kratos/v2/metadata" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/security" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -func injectTokenMetadataContext(ctx context.Context, scheme string, token string) context.Context { - md, ok := metadata.FromOutgoingContext(ctx) - if !ok { - // Use pairs to create a new one. - md = metadata.Pairs() - } - md.Set(security.HeaderAuthorize, formatToken(scheme, token)) - return ctx -} - -func injectTokenMetadataServerContext(ctx context.Context, scheme string, token string) context.Context { - md, ok := kmetadata.FromServerContext(ctx) - if !ok { - // Use make to create a new one. - md = make(kmetadata.Metadata) - } - md.Set(security.HeaderAuthorize, formatToken(scheme, token)) - return ctx -} - -func injectTokenMetadataClientContext(ctx context.Context, scheme string, token string) context.Context { - md, ok := kmetadata.FromClientContext(ctx) - if !ok { - // Use make to create a new one. - md = make(kmetadata.Metadata) - } - md.Set(security.HeaderAuthorize, formatToken(scheme, token)) - return ctx -} - -func extractTokenMetadataContext(ctx context.Context) string { - if md, ok := metadata.FromIncomingContext(ctx); ok { - return md.Get(security.HeaderAuthorize)[0] - } - return "" -} - -func extractTokenMetadataServerContext(ctx context.Context) string { - if meta, ok := kmetadata.FromServerContext(ctx); ok { - return meta.Get(security.HeaderAuthorize) - } - return "" -} - -func extractTokenMetadataClientContext(ctx context.Context) string { - if meta, ok := kmetadata.FromClientContext(ctx); ok { - return meta.Get(security.HeaderAuthorize) - } - return "" -} - -func ClaimFromTokenTypeContext(ctx context.Context, tokenType security.TokenSource) (security.Claims, error) { - switch tokenType { - case security.TokenSourceContext: - return security.ClaimsFromContext(ctx), nil - } - return nil, status.Errorf(codes.Unauthenticated, "Request unauthenticated with "+tokenType.String()) -} diff --git a/contrib/security/token_transport.go b/contrib/security/token_transport.go deleted file mode 100644 index 22b855a4..00000000 --- a/contrib/security/token_transport.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package securityx implements the functions, types, and interfaces for the module. -package security - -import ( - "github.com/go-kratos/kratos/v2/transport" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/security" -) - -func injectHeaderTransportContext(ctx context.Context, scheme string, token string) context.Context { - if header, ok := transport.FromServerContext(ctx); ok { - header.RequestHeader().Set(security.HeaderAuthorize, formatToken(scheme, token)) - return transport.NewServerContext(ctx, header) - } - if header, ok := transport.FromClientContext(ctx); ok { - header.RequestHeader().Set(security.HeaderAuthorize, formatToken(scheme, token)) - return transport.NewClientContext(ctx, header) - } - return ctx -} -func extractHeaderTransportContext(ctx context.Context) string { - if header, ok := transport.FromServerContext(ctx); ok { - return header.RequestHeader().Get(security.HeaderAuthorize) - } - if header, ok := transport.FromClientContext(ctx); ok { - return header.RequestHeader().Get(security.HeaderAuthorize) - } - return "" -} - -func injectServerTransportContext(ctx context.Context, scheme string, token string) context.Context { - if header, ok := transport.FromServerContext(ctx); ok { - header.RequestHeader().Set(security.HeaderAuthorize, formatToken(scheme, token)) - return transport.NewServerContext(ctx, header) - } - return ctx -} -func extractServerTransportContext(ctx context.Context) string { - if header, ok := transport.FromServerContext(ctx); ok { - return header.RequestHeader().Get(security.HeaderAuthorize) - } - return "" -} -func injectClientTransportContext(ctx context.Context, scheme string, token string) context.Context { - if header, ok := transport.FromClientContext(ctx); ok { - header.RequestHeader().Set(security.HeaderAuthorize, formatToken(scheme, token)) - return transport.NewClientContext(ctx, header) - } - return ctx -} - -func extractClientTransportContext(ctx context.Context) string { - if header, ok := transport.FromClientContext(ctx); ok { - return header.RequestHeader().Get(security.HeaderAuthorize) - } - return "" -} diff --git a/internal/configs/captcha.pb.go b/internal/conf/pb/captcha.pb.go similarity index 51% rename from internal/configs/captcha.pb.go rename to internal/conf/pb/captcha.pb.go index 65e3d3ed..fb6ffd8d 100644 --- a/internal/configs/captcha.pb.go +++ b/internal/conf/pb/captcha.pb.go @@ -1,13 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc v5.28.3 -// source: configs/captcha.proto +// source: conf/pb/captcha.proto -package configs +package conf import ( - v1 "github.com/origadmin/runtime/api/gen/go/config/v1" + v1 "github.com/origadmin/runtime/api/gen/go/config/data/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -27,15 +27,15 @@ type Captcha struct { Length int32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"` Width int32 `protobuf:"varint,2,opt,name=width,proto3" json:"width,omitempty"` Height int32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` - StorageName string `protobuf:"bytes,4,opt,name=storage_name,proto3" json:"storage_name,omitempty"` - Storage *v1.Storage `protobuf:"bytes,5,opt,name=storage,proto3" json:"storage,omitempty"` + CacheName string `protobuf:"bytes,4,opt,name=cache_name,proto3" json:"cache_name,omitempty"` + Caches *v1.Caches `protobuf:"bytes,5,opt,name=caches,proto3" json:"caches,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Captcha) Reset() { *x = Captcha{} - mi := &file_configs_captcha_proto_msgTypes[0] + mi := &file_conf_pb_captcha_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -47,7 +47,7 @@ func (x *Captcha) String() string { func (*Captcha) ProtoMessage() {} func (x *Captcha) ProtoReflect() protoreflect.Message { - mi := &file_configs_captcha_proto_msgTypes[0] + mi := &file_conf_pb_captcha_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -60,7 +60,7 @@ func (x *Captcha) ProtoReflect() protoreflect.Message { // Deprecated: Use Captcha.ProtoReflect.Descriptor instead. func (*Captcha) Descriptor() ([]byte, []int) { - return file_configs_captcha_proto_rawDescGZIP(), []int{0} + return file_conf_pb_captcha_proto_rawDescGZIP(), []int{0} } func (x *Captcha) GetLength() int32 { @@ -84,51 +84,53 @@ func (x *Captcha) GetHeight() int32 { return 0 } -func (x *Captcha) GetStorageName() string { +func (x *Captcha) GetCacheName() string { if x != nil { - return x.StorageName + return x.CacheName } return "" } -func (x *Captcha) GetStorage() *v1.Storage { +func (x *Captcha) GetCaches() *v1.Caches { if x != nil { - return x.Storage + return x.Caches } return nil } -var File_configs_captcha_proto protoreflect.FileDescriptor +var File_conf_pb_captcha_proto protoreflect.FileDescriptor -const file_configs_captcha_proto_rawDesc = "" + +const file_conf_pb_captcha_proto_rawDesc = "" + "\n" + - "\x15configs/captcha.proto\x12\vapi.configs\x1a\x17config/v1/storage.proto\"\xa1\x01\n" + + "\x15conf/pb/captcha.proto\x12\x04conf\x1a\x19config/data/v1/data.proto\"\xab\x01\n" + "\aCaptcha\x12\x16\n" + "\x06length\x18\x01 \x01(\x05R\x06length\x12\x14\n" + "\x05width\x18\x02 \x01(\x05R\x05width\x12\x16\n" + - "\x06height\x18\x03 \x01(\x05R\x06height\x12\"\n" + - "\fstorage_name\x18\x04 \x01(\tR\fstorage_name\x12,\n" + - "\astorage\x18\x05 \x01(\v2\x12.config.v1.StorageR\astorageB.Z,origadmin/application/admin/internal/configsb\x06proto3" + "\x06height\x18\x03 \x01(\x05R\x06height\x12\x1e\n" + + "\n" + + "cache_name\x18\x04 \x01(\tR\n" + + "cache_name\x12:\n" + + "\x06caches\x18\x05 \x01(\v2\".runtime.api.config.data.v1.CachesR\x06cachesB0Z.origadmin/application/admin/internal/conf;confb\x06proto3" var ( - file_configs_captcha_proto_rawDescOnce sync.Once - file_configs_captcha_proto_rawDescData []byte + file_conf_pb_captcha_proto_rawDescOnce sync.Once + file_conf_pb_captcha_proto_rawDescData []byte ) -func file_configs_captcha_proto_rawDescGZIP() []byte { - file_configs_captcha_proto_rawDescOnce.Do(func() { - file_configs_captcha_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_captcha_proto_rawDesc), len(file_configs_captcha_proto_rawDesc))) +func file_conf_pb_captcha_proto_rawDescGZIP() []byte { + file_conf_pb_captcha_proto_rawDescOnce.Do(func() { + file_conf_pb_captcha_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_conf_pb_captcha_proto_rawDesc), len(file_conf_pb_captcha_proto_rawDesc))) }) - return file_configs_captcha_proto_rawDescData + return file_conf_pb_captcha_proto_rawDescData } -var file_configs_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_configs_captcha_proto_goTypes = []any{ - (*Captcha)(nil), // 0: api.configs.Captcha - (*v1.Storage)(nil), // 1: config.v1.Storage +var file_conf_pb_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_conf_pb_captcha_proto_goTypes = []any{ + (*Captcha)(nil), // 0: conf.Captcha + (*v1.Caches)(nil), // 1: runtime.api.config.data.v1.Caches } -var file_configs_captcha_proto_depIdxs = []int32{ - 1, // 0: api.configs.Captcha.storage:type_name -> config.v1.Storage +var file_conf_pb_captcha_proto_depIdxs = []int32{ + 1, // 0: conf.Captcha.caches:type_name -> runtime.api.config.data.v1.Caches 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -136,26 +138,26 @@ var file_configs_captcha_proto_depIdxs = []int32{ 0, // [0:1] is the sub-list for field type_name } -func init() { file_configs_captcha_proto_init() } -func file_configs_captcha_proto_init() { - if File_configs_captcha_proto != nil { +func init() { file_conf_pb_captcha_proto_init() } +func file_conf_pb_captcha_proto_init() { + if File_conf_pb_captcha_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_captcha_proto_rawDesc), len(file_configs_captcha_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_conf_pb_captcha_proto_rawDesc), len(file_conf_pb_captcha_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_configs_captcha_proto_goTypes, - DependencyIndexes: file_configs_captcha_proto_depIdxs, - MessageInfos: file_configs_captcha_proto_msgTypes, + GoTypes: file_conf_pb_captcha_proto_goTypes, + DependencyIndexes: file_conf_pb_captcha_proto_depIdxs, + MessageInfos: file_conf_pb_captcha_proto_msgTypes, }.Build() - File_configs_captcha_proto = out.File - file_configs_captcha_proto_goTypes = nil - file_configs_captcha_proto_depIdxs = nil + File_conf_pb_captcha_proto = out.File + file_conf_pb_captcha_proto_goTypes = nil + file_conf_pb_captcha_proto_depIdxs = nil } diff --git a/internal/configs/captcha.pb.validate.go b/internal/conf/pb/captcha.pb.validate.go similarity index 92% rename from internal/configs/captcha.pb.validate.go rename to internal/conf/pb/captcha.pb.validate.go index c354c51f..a1cf66d9 100644 --- a/internal/configs/captcha.pb.validate.go +++ b/internal/conf/pb/captcha.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: configs/captcha.proto +// source: conf/pb/captcha.proto -package configs +package conf import ( "bytes" @@ -62,14 +62,14 @@ func (m *Captcha) validate(all bool) error { // no validation rules for Height - // no validation rules for StorageName + // no validation rules for CacheName if all { - switch v := interface{}(m.GetStorage()).(type) { + switch v := interface{}(m.GetCaches()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, CaptchaValidationError{ - field: "Storage", + field: "Caches", reason: "embedded message failed validation", cause: err, }) @@ -77,16 +77,16 @@ func (m *Captcha) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, CaptchaValidationError{ - field: "Storage", + field: "Caches", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetStorage()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetCaches()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CaptchaValidationError{ - field: "Storage", + field: "Caches", reason: "embedded message failed validation", cause: err, } diff --git a/internal/configs/captcha.proto b/internal/conf/pb/captcha.proto similarity index 69% rename from internal/configs/captcha.proto rename to internal/conf/pb/captcha.proto index e397d56f..7da2f17d 100644 --- a/internal/configs/captcha.proto +++ b/internal/conf/pb/captcha.proto @@ -1,18 +1,19 @@ syntax = "proto3"; -package api.configs; -import "config/v1/storage.proto"; +package conf; -option go_package = "origadmin/application/admin/internal/configs"; +import "config/data/v1/data.proto"; + +option go_package = "origadmin/application/admin/internal/conf;conf"; message Captcha { int32 length = 1 [json_name = "length"]; int32 width = 2 [json_name = "width"]; int32 height = 3 [json_name = "height"]; - string storage_name = 4 [json_name = "storage_name"]; + string cache_name = 4 [json_name = "cache_name"]; - config.v1.Storage storage = 5 [json_name = "storage"]; + runtime.api.config.data.v1.Caches caches = 5 [json_name = "caches"]; // 注释原有Redis配置(应由公共配置管理) // message Redis { // string addr = 1 [json_name = "addr"]; diff --git a/internal/conf/pb/conf.pb.go b/internal/conf/pb/conf.pb.go new file mode 100644 index 00000000..4fc31ba2 --- /dev/null +++ b/internal/conf/pb/conf.pb.go @@ -0,0 +1,225 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v5.28.3 +// source: conf/pb/conf.proto + +package conf + +import ( + v1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + conf "origadmin/application/admin/conf" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Bootstrap is the top-level configuration structure for the application. +type Bootstrap struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Server-side configuration for the service itself. + Servers *v1.Servers `protobuf:"bytes,1,opt,name=servers,proto3" json:"servers,omitempty"` + // Client-side configurations. The key is the logical name of the downstream service, e.g., "user-service". + Clients *v1.Clients `protobuf:"bytes,2,opt,name=clients,proto3" json:"clients,omitempty"` + // Global-level configurations can be placed here. + SelectorGlobal *SelectorGlobal `protobuf:"bytes,3,opt,name=selector_global,json=selectorGlobal,proto3" json:"selector_global,omitempty"` + // Captcha feature specific configuration. + Captcha *Captcha `protobuf:"bytes,4,opt,name=captcha,proto3" json:"captcha,omitempty"` + // RootUser feature specific configuration for initial user setup. + RootUser *conf.RootUser `protobuf:"bytes,5,opt,name=root_user,json=rootUser,proto3" json:"root_user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Bootstrap) Reset() { + *x = Bootstrap{} + mi := &file_conf_pb_conf_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Bootstrap) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Bootstrap) ProtoMessage() {} + +func (x *Bootstrap) ProtoReflect() protoreflect.Message { + mi := &file_conf_pb_conf_proto_msgTypes[0] + 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 Bootstrap.ProtoReflect.Descriptor instead. +func (*Bootstrap) Descriptor() ([]byte, []int) { + return file_conf_pb_conf_proto_rawDescGZIP(), []int{0} +} + +func (x *Bootstrap) GetServers() *v1.Servers { + if x != nil { + return x.Servers + } + return nil +} + +func (x *Bootstrap) GetClients() *v1.Clients { + if x != nil { + return x.Clients + } + return nil +} + +func (x *Bootstrap) GetSelectorGlobal() *SelectorGlobal { + if x != nil { + return x.SelectorGlobal + } + return nil +} + +func (x *Bootstrap) GetCaptcha() *Captcha { + if x != nil { + return x.Captcha + } + return nil +} + +func (x *Bootstrap) GetRootUser() *conf.RootUser { + if x != nil { + return x.RootUser + } + return nil +} + +// SelectorGlobal defines the global selector/load-balancing strategy. +type SelectorGlobal struct { + state protoimpl.MessageState `protogen:"open.v1"` + // builder specifies the global load balancer, e.g., "p2c", "wrr", "random". + Builder string `protobuf:"bytes,1,opt,name=builder,proto3" json:"builder,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SelectorGlobal) Reset() { + *x = SelectorGlobal{} + mi := &file_conf_pb_conf_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SelectorGlobal) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SelectorGlobal) ProtoMessage() {} + +func (x *SelectorGlobal) ProtoReflect() protoreflect.Message { + mi := &file_conf_pb_conf_proto_msgTypes[1] + 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 SelectorGlobal.ProtoReflect.Descriptor instead. +func (*SelectorGlobal) Descriptor() ([]byte, []int) { + return file_conf_pb_conf_proto_rawDescGZIP(), []int{1} +} + +func (x *SelectorGlobal) GetBuilder() string { + if x != nil { + return x.Builder + } + return "" +} + +var File_conf_pb_conf_proto protoreflect.FileDescriptor + +const file_conf_pb_conf_proto_rawDesc = "" + + "\n" + + "\x12conf/pb/conf.proto\x12\x04conf\x1a#config/transport/v1/transport.proto\x1a\x15conf/pb/captcha.proto\x1a\x12conf/pb/root.proto\"\xa8\x02\n" + + "\tBootstrap\x12B\n" + + "\aservers\x18\x01 \x01(\v2(.runtime.api.config.transport.v1.ServersR\aservers\x12B\n" + + "\aclients\x18\x02 \x01(\v2(.runtime.api.config.transport.v1.ClientsR\aclients\x12=\n" + + "\x0fselector_global\x18\x03 \x01(\v2\x14.conf.SelectorGlobalR\x0eselectorGlobal\x12'\n" + + "\acaptcha\x18\x04 \x01(\v2\r.conf.CaptchaR\acaptcha\x12+\n" + + "\troot_user\x18\x05 \x01(\v2\x0e.conf.RootUserR\brootUser\"*\n" + + "\x0eSelectorGlobal\x12\x18\n" + + "\abuilder\x18\x01 \x01(\tR\abuilderB0Z.origadmin/application/admin/internal/conf;confb\x06proto3" + +var ( + file_conf_pb_conf_proto_rawDescOnce sync.Once + file_conf_pb_conf_proto_rawDescData []byte +) + +func file_conf_pb_conf_proto_rawDescGZIP() []byte { + file_conf_pb_conf_proto_rawDescOnce.Do(func() { + file_conf_pb_conf_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_conf_pb_conf_proto_rawDesc), len(file_conf_pb_conf_proto_rawDesc))) + }) + return file_conf_pb_conf_proto_rawDescData +} + +var file_conf_pb_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_conf_pb_conf_proto_goTypes = []any{ + (*Bootstrap)(nil), // 0: conf.Bootstrap + (*SelectorGlobal)(nil), // 1: conf.SelectorGlobal + (*v1.Servers)(nil), // 2: runtime.api.config.transport.v1.Servers + (*v1.Clients)(nil), // 3: runtime.api.config.transport.v1.Clients + (*Captcha)(nil), // 4: conf.Captcha + (*conf.RootUser)(nil), // 5: conf.RootUser +} +var file_conf_pb_conf_proto_depIdxs = []int32{ + 2, // 0: conf.Bootstrap.servers:type_name -> runtime.api.config.transport.v1.Servers + 3, // 1: conf.Bootstrap.clients:type_name -> runtime.api.config.transport.v1.Clients + 1, // 2: conf.Bootstrap.selector_global:type_name -> conf.SelectorGlobal + 4, // 3: conf.Bootstrap.captcha:type_name -> conf.Captcha + 5, // 4: conf.Bootstrap.root_user:type_name -> conf.RootUser + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name +} + +func init() { file_conf_pb_conf_proto_init() } +func file_conf_pb_conf_proto_init() { + if File_conf_pb_conf_proto != nil { + return + } + file_conf_pb_captcha_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_conf_pb_conf_proto_rawDesc), len(file_conf_pb_conf_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_conf_pb_conf_proto_goTypes, + DependencyIndexes: file_conf_pb_conf_proto_depIdxs, + MessageInfos: file_conf_pb_conf_proto_msgTypes, + }.Build() + File_conf_pb_conf_proto = out.File + file_conf_pb_conf_proto_goTypes = nil + file_conf_pb_conf_proto_depIdxs = nil +} diff --git a/internal/conf/pb/conf.pb.validate.go b/internal/conf/pb/conf.pb.validate.go new file mode 100644 index 00000000..0c973970 --- /dev/null +++ b/internal/conf/pb/conf.pb.validate.go @@ -0,0 +1,382 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: conf/pb/conf.proto + +package conf + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on Bootstrap 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 *Bootstrap) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Bootstrap 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 BootstrapMultiError, or nil +// if none found. +func (m *Bootstrap) ValidateAll() error { + return m.validate(true) +} + +func (m *Bootstrap) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetServers()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Servers", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Servers", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetServers()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "Servers", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetClients()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Clients", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Clients", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetClients()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "Clients", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetSelectorGlobal()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "SelectorGlobal", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "SelectorGlobal", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSelectorGlobal()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "SelectorGlobal", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetCaptcha()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Captcha", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Captcha", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCaptcha()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "Captcha", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetRootUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "RootUser", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "RootUser", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRootUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "RootUser", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return BootstrapMultiError(errors) + } + + return nil +} + +// BootstrapMultiError is an error wrapping multiple validation errors returned +// by Bootstrap.ValidateAll() if the designated constraints aren't met. +type BootstrapMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m BootstrapMultiError) 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 BootstrapMultiError) AllErrors() []error { return m } + +// BootstrapValidationError is the validation error returned by +// Bootstrap.Validate if the designated constraints aren't met. +type BootstrapValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e BootstrapValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e BootstrapValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e BootstrapValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e BootstrapValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e BootstrapValidationError) ErrorName() string { return "BootstrapValidationError" } + +// Error satisfies the builtin error interface +func (e BootstrapValidationError) 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 %sBootstrap.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = BootstrapValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = BootstrapValidationError{} + +// Validate checks the field values on SelectorGlobal 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 *SelectorGlobal) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on SelectorGlobal 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 SelectorGlobalMultiError, +// or nil if none found. +func (m *SelectorGlobal) ValidateAll() error { + return m.validate(true) +} + +func (m *SelectorGlobal) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Builder + + if len(errors) > 0 { + return SelectorGlobalMultiError(errors) + } + + return nil +} + +// SelectorGlobalMultiError is an error wrapping multiple validation errors +// returned by SelectorGlobal.ValidateAll() if the designated constraints +// aren't met. +type SelectorGlobalMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m SelectorGlobalMultiError) 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 SelectorGlobalMultiError) AllErrors() []error { return m } + +// SelectorGlobalValidationError is the validation error returned by +// SelectorGlobal.Validate if the designated constraints aren't met. +type SelectorGlobalValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e SelectorGlobalValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e SelectorGlobalValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e SelectorGlobalValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e SelectorGlobalValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e SelectorGlobalValidationError) ErrorName() string { return "SelectorGlobalValidationError" } + +// Error satisfies the builtin error interface +func (e SelectorGlobalValidationError) 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 %sSelectorGlobal.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = SelectorGlobalValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = SelectorGlobalValidationError{} diff --git a/internal/conf/pb/conf.proto b/internal/conf/pb/conf.proto new file mode 100644 index 00000000..ee705b89 --- /dev/null +++ b/internal/conf/pb/conf.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package conf; + +option go_package = "origadmin/application/admin/internal/conf;conf"; + +import "config/transport/v1/transport.proto"; +import "conf/pb/captcha.proto"; +import "conf/pb/root.proto"; + +// Bootstrap is the top-level configuration structure for the application. +message Bootstrap { + // Server-side configuration for the service itself. + runtime.api.config.transport.v1.Servers servers = 1; + + // Client-side configurations. The key is the logical name of the downstream service, e.g., "user-service". + runtime.api.config.transport.v1.Clients clients = 2; + + // Global-level configurations can be placed here. + SelectorGlobal selector_global = 3; + + // Captcha feature specific configuration. + Captcha captcha = 4; + + // RootUser feature specific configuration for initial user setup. + RootUser root_user = 5; +} + +// SelectorGlobal defines the global selector/load-balancing strategy. +message SelectorGlobal { + // builder specifies the global load balancer, e.g., "p2c", "wrr", "random". + string builder = 1; +} diff --git a/internal/configs/root_user.pb.go b/internal/conf/pb/root.pb.go similarity index 74% rename from internal/configs/root_user.pb.go rename to internal/conf/pb/root.pb.go index a9468f6b..d790be22 100644 --- a/internal/configs/root_user.pb.go +++ b/internal/conf/pb/root.pb.go @@ -1,10 +1,10 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc v5.28.3 -// source: configs/root_user.proto +// source: conf/pb/root.proto -package configs +package conf import ( _ "github.com/envoyproxy/protoc-gen-validate/validate" @@ -43,7 +43,7 @@ type RootUser struct { func (x *RootUser) Reset() { *x = RootUser{} - mi := &file_configs_root_user_proto_msgTypes[0] + mi := &file_conf_pb_root_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -55,7 +55,7 @@ func (x *RootUser) String() string { func (*RootUser) ProtoMessage() {} func (x *RootUser) ProtoReflect() protoreflect.Message { - mi := &file_configs_root_user_proto_msgTypes[0] + mi := &file_conf_pb_root_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -68,7 +68,7 @@ func (x *RootUser) ProtoReflect() protoreflect.Message { // Deprecated: Use RootUser.ProtoReflect.Descriptor instead. func (*RootUser) Descriptor() ([]byte, []int) { - return file_configs_root_user_proto_rawDescGZIP(), []int{0} + return file_conf_pb_root_proto_rawDescGZIP(), []int{0} } func (x *RootUser) GetEnabled() bool { @@ -162,11 +162,11 @@ func (x *RootUser) GetRandomPassword() bool { return false } -var File_configs_root_user_proto protoreflect.FileDescriptor +var File_conf_pb_root_proto protoreflect.FileDescriptor -const file_configs_root_user_proto_rawDesc = "" + +const file_conf_pb_root_proto_rawDesc = "" + "\n" + - "\x17configs/root_user.proto\x12\vapi.configs\x1a\x17validate/validate.proto\"\x8c\x03\n" + + "\x12conf/pb/root.proto\x12\x04conf\x1a\x17validate/validate.proto\"\x8c\x03\n" + "\bRootUser\x12\x18\n" + "\aenabled\x18\x01 \x01(\bR\aenabled\x12\x17\n" + "\x02id\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x02id\x12#\n" + @@ -181,25 +181,25 @@ const file_configs_root_user_proto_rawDesc = "" + " \x01(\tR\x06mobile\x12 \n" + "\vdescription\x18\v \x01(\tR\vdescription\x12 \n" + "\vauto_create\x18d \x01(\bR\vauto_create\x12(\n" + - "\x0frandom_password\x18e \x01(\bR\x0frandom_passwordB.Z,origadmin/application/admin/internal/configsb\x06proto3" + "\x0frandom_password\x18e \x01(\bR\x0frandom_passwordB'Z%origadmin/application/admin/conf;confb\x06proto3" var ( - file_configs_root_user_proto_rawDescOnce sync.Once - file_configs_root_user_proto_rawDescData []byte + file_conf_pb_root_proto_rawDescOnce sync.Once + file_conf_pb_root_proto_rawDescData []byte ) -func file_configs_root_user_proto_rawDescGZIP() []byte { - file_configs_root_user_proto_rawDescOnce.Do(func() { - file_configs_root_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_root_user_proto_rawDesc), len(file_configs_root_user_proto_rawDesc))) +func file_conf_pb_root_proto_rawDescGZIP() []byte { + file_conf_pb_root_proto_rawDescOnce.Do(func() { + file_conf_pb_root_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_conf_pb_root_proto_rawDesc), len(file_conf_pb_root_proto_rawDesc))) }) - return file_configs_root_user_proto_rawDescData + return file_conf_pb_root_proto_rawDescData } -var file_configs_root_user_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_configs_root_user_proto_goTypes = []any{ - (*RootUser)(nil), // 0: api.configs.RootUser +var file_conf_pb_root_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_conf_pb_root_proto_goTypes = []any{ + (*RootUser)(nil), // 0: conf.RootUser } -var file_configs_root_user_proto_depIdxs = []int32{ +var file_conf_pb_root_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -207,26 +207,26 @@ var file_configs_root_user_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_configs_root_user_proto_init() } -func file_configs_root_user_proto_init() { - if File_configs_root_user_proto != nil { +func init() { file_conf_pb_root_proto_init() } +func file_conf_pb_root_proto_init() { + if File_conf_pb_root_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_root_user_proto_rawDesc), len(file_configs_root_user_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_conf_pb_root_proto_rawDesc), len(file_conf_pb_root_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_configs_root_user_proto_goTypes, - DependencyIndexes: file_configs_root_user_proto_depIdxs, - MessageInfos: file_configs_root_user_proto_msgTypes, + GoTypes: file_conf_pb_root_proto_goTypes, + DependencyIndexes: file_conf_pb_root_proto_depIdxs, + MessageInfos: file_conf_pb_root_proto_msgTypes, }.Build() - File_configs_root_user_proto = out.File - file_configs_root_user_proto_goTypes = nil - file_configs_root_user_proto_depIdxs = nil + File_conf_pb_root_proto = out.File + file_conf_pb_root_proto_goTypes = nil + file_conf_pb_root_proto_depIdxs = nil } diff --git a/internal/configs/root_user.pb.validate.go b/internal/conf/pb/root.pb.validate.go similarity index 98% rename from internal/configs/root_user.pb.validate.go rename to internal/conf/pb/root.pb.validate.go index 7bbf6e68..9c7e4b5b 100644 --- a/internal/configs/root_user.pb.validate.go +++ b/internal/conf/pb/root.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: configs/root_user.proto +// source: conf/pb/root.proto -package configs +package conf import ( "bytes" diff --git a/internal/configs/root_user.proto b/internal/conf/pb/root.proto similarity index 91% rename from internal/configs/root_user.proto rename to internal/conf/pb/root.proto index c4bf035c..2911cdf9 100644 --- a/internal/configs/root_user.proto +++ b/internal/conf/pb/root.proto @@ -1,9 +1,10 @@ syntax = "proto3"; -package api.configs; + +package conf; import "validate/validate.proto"; -option go_package = "origadmin/application/admin/internal/configs"; +option go_package = "origadmin/application/admin/conf;conf"; message RootUser { bool enabled = 1 [json_name = "enabled"]; diff --git a/internal/configs/bootstrap.pb.go b/internal/configs/bootstrap.pb.go deleted file mode 100644 index 85656aab..00000000 --- a/internal/configs/bootstrap.pb.go +++ /dev/null @@ -1,521 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc v5.28.3 -// source: configs/bootstrap.proto - -package configs - -import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" - v1 "github.com/origadmin/runtime/api/gen/go/config/v1" - v11 "github.com/origadmin/runtime/api/gen/go/middleware/v1" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type EntrySelectorConfig struct { - state protoimpl.MessageState `protogen:"open.v1"` - Global bool `protobuf:"varint,2,opt,name=global,proto3" json:"global,omitempty"` - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *EntrySelectorConfig) Reset() { - *x = EntrySelectorConfig{} - mi := &file_configs_bootstrap_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *EntrySelectorConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*EntrySelectorConfig) ProtoMessage() {} - -func (x *EntrySelectorConfig) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[0] - 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 EntrySelectorConfig.ProtoReflect.Descriptor instead. -func (*EntrySelectorConfig) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{0} -} - -func (x *EntrySelectorConfig) GetGlobal() bool { - if x != nil { - return x.Global - } - return false -} - -func (x *EntrySelectorConfig) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *EntrySelectorConfig) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -type Bootstrap struct { - state protoimpl.MessageState `protogen:"open.v1"` - // name is the application name or service name for used - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - CryptoType string `protobuf:"bytes,3,opt,name=crypto_type,proto3" json:"crypto_type,omitempty"` - Mode string `protobuf:"bytes,5,opt,name=mode,proto3" json:"mode,omitempty"` - EnableDynamicConfig bool `protobuf:"varint,7,opt,name=enable_dynamic_config,proto3" json:"enable_dynamic_config,omitempty"` - Id string `protobuf:"bytes,100,opt,name=id,proto3" json:"id,omitempty"` - Environment string `protobuf:"bytes,102,opt,name=environment,proto3" json:"environment,omitempty"` - // 入口服务专属配置 - Entry *Bootstrap_Entry `protobuf:"bytes,103,opt,name=entry,proto3" json:"entry,omitempty"` - Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` - Discovery *v1.Discovery `protobuf:"bytes,400,opt,name=discovery,proto3" json:"discovery,omitempty"` - Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` - Security *SecurityConfig `protobuf:"bytes,10,opt,name=security,proto3" json:"security,omitempty"` - HealthCheck *Bootstrap_HealthCheck `protobuf:"bytes,1003,opt,name=health_check,proto3" json:"health_check,omitempty"` - Logger *v1.Logger `protobuf:"bytes,1004,opt,name=logger,proto3" json:"logger,omitempty"` - Server *ServiceServer `protobuf:"bytes,1005,opt,name=server,proto3" json:"server,omitempty"` - Clients []*ServiceClient `protobuf:"bytes,1006,rep,name=clients,proto3" json:"clients,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Bootstrap) Reset() { - *x = Bootstrap{} - mi := &file_configs_bootstrap_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Bootstrap) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Bootstrap) ProtoMessage() {} - -func (x *Bootstrap) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[1] - 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 Bootstrap.ProtoReflect.Descriptor instead. -func (*Bootstrap) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{1} -} - -func (x *Bootstrap) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Bootstrap) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *Bootstrap) GetCryptoType() string { - if x != nil { - return x.CryptoType - } - return "" -} - -func (x *Bootstrap) GetMode() string { - if x != nil { - return x.Mode - } - return "" -} - -func (x *Bootstrap) GetEnableDynamicConfig() bool { - if x != nil { - return x.EnableDynamicConfig - } - return false -} - -func (x *Bootstrap) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *Bootstrap) GetEnvironment() string { - if x != nil { - return x.Environment - } - return "" -} - -func (x *Bootstrap) GetEntry() *Bootstrap_Entry { - if x != nil { - return x.Entry - } - return nil -} - -func (x *Bootstrap) GetStorage() *v1.Storage { - if x != nil { - return x.Storage - } - return nil -} - -func (x *Bootstrap) GetDiscovery() *v1.Discovery { - if x != nil { - return x.Discovery - } - return nil -} - -func (x *Bootstrap) GetMiddleware() *v11.Middleware { - if x != nil { - return x.Middleware - } - return nil -} - -func (x *Bootstrap) GetSecurity() *SecurityConfig { - if x != nil { - return x.Security - } - return nil -} - -func (x *Bootstrap) GetHealthCheck() *Bootstrap_HealthCheck { - if x != nil { - return x.HealthCheck - } - return nil -} - -func (x *Bootstrap) GetLogger() *v1.Logger { - if x != nil { - return x.Logger - } - return nil -} - -func (x *Bootstrap) GetServer() *ServiceServer { - if x != nil { - return x.Server - } - return nil -} - -func (x *Bootstrap) GetClients() []*ServiceClient { - if x != nil { - return x.Clients - } - return nil -} - -type Settings struct { - state protoimpl.MessageState `protogen:"open.v1"` - CryptoType string `protobuf:"bytes,1,opt,name=crypto_type,proto3" json:"crypto_type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Settings) Reset() { - *x = Settings{} - mi := &file_configs_bootstrap_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Settings) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Settings) ProtoMessage() {} - -func (x *Settings) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[2] - 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 Settings.ProtoReflect.Descriptor instead. -func (*Settings) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{2} -} - -func (x *Settings) GetCryptoType() string { - if x != nil { - return x.CryptoType - } - return "" -} - -type Bootstrap_HealthCheck struct { - state protoimpl.MessageState `protogen:"open.v1"` - Timeout int32 `protobuf:"varint,1,opt,name=timeout,proto3" json:"timeout,omitempty"` - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Bootstrap_HealthCheck) Reset() { - *x = Bootstrap_HealthCheck{} - mi := &file_configs_bootstrap_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Bootstrap_HealthCheck) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Bootstrap_HealthCheck) ProtoMessage() {} - -func (x *Bootstrap_HealthCheck) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[3] - 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 Bootstrap_HealthCheck.ProtoReflect.Descriptor instead. -func (*Bootstrap_HealthCheck) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{1, 0} -} - -func (x *Bootstrap_HealthCheck) GetTimeout() int32 { - if x != nil { - return x.Timeout - } - return 0 -} - -func (x *Bootstrap_HealthCheck) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -// Entry -type Bootstrap_Entry struct { - state protoimpl.MessageState `protogen:"open.v1"` - Scheme string `protobuf:"bytes,1,opt,name=scheme,proto3" json:"scheme,omitempty"` - Cors *v1.Cors `protobuf:"bytes,2,opt,name=cors,proto3" json:"cors,omitempty"` - Services []*v1.Service `protobuf:"bytes,3,rep,name=services,proto3" json:"services,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Bootstrap_Entry) Reset() { - *x = Bootstrap_Entry{} - mi := &file_configs_bootstrap_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Bootstrap_Entry) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Bootstrap_Entry) ProtoMessage() {} - -func (x *Bootstrap_Entry) ProtoReflect() protoreflect.Message { - mi := &file_configs_bootstrap_proto_msgTypes[4] - 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 Bootstrap_Entry.ProtoReflect.Descriptor instead. -func (*Bootstrap_Entry) Descriptor() ([]byte, []int) { - return file_configs_bootstrap_proto_rawDescGZIP(), []int{1, 1} -} - -func (x *Bootstrap_Entry) GetScheme() string { - if x != nil { - return x.Scheme - } - return "" -} - -func (x *Bootstrap_Entry) GetCors() *v1.Cors { - if x != nil { - return x.Cors - } - return nil -} - -func (x *Bootstrap_Entry) GetServices() []*v1.Service { - if x != nil { - return x.Services - } - return nil -} - -var File_configs_bootstrap_proto protoreflect.FileDescriptor - -const file_configs_bootstrap_proto_rawDesc = "" + - "\n" + - "\x17configs/bootstrap.proto\x12\vapi.configs\x1a\x14config/v1/cors.proto\x1a\x19config/v1/discovery.proto\x1a\x16config/v1/logger.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1dconfigs/security_config.proto\x1a\x15configs/service.proto\x1a\x1emiddleware/v1/middleware.proto\x1a\x17validate/validate.proto\"[\n" + - "\x13EntrySelectorConfig\x12\x16\n" + - "\x06global\x18\x02 \x01(\bR\x06global\x12\x12\n" + - "\x04name\x18\x03 \x01(\tR\x04name\x12\x18\n" + - "\aversion\x18\x04 \x01(\tR\aversion\"\xa4\a\n" + - "\tBootstrap\x12\x12\n" + - "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + - "\aversion\x18\x02 \x01(\tR\aversion\x12 \n" + - "\vcrypto_type\x18\x03 \x01(\tR\vcrypto_type\x12-\n" + - "\x04mode\x18\x05 \x01(\tB\x19\xfaB\x16r\x14R\tsingletonR\aclusterR\x04mode\x124\n" + - "\x15enable_dynamic_config\x18\a \x01(\bR\x15enable_dynamic_config\x12\x0e\n" + - "\x02id\x18d \x01(\tR\x02id\x122\n" + - "\venvironment\x18f \x01(\tB\x10\xfaB\rr\vR\x03devR\x04prodR\venvironment\x122\n" + - "\x05entry\x18g \x01(\v2\x1c.api.configs.Bootstrap.EntryR\x05entry\x12-\n" + - "\astorage\x18\xac\x02 \x01(\v2\x12.config.v1.StorageR\astorage\x123\n" + - "\tdiscovery\x18\x90\x03 \x01(\v2\x14.config.v1.DiscoveryR\tdiscovery\x129\n" + - "\n" + - "middleware\x18\t \x01(\v2\x19.middleware.v1.MiddlewareR\n" + - "middleware\x127\n" + - "\bsecurity\x18\n" + - " \x01(\v2\x1b.api.configs.SecurityConfigR\bsecurity\x12G\n" + - "\fhealth_check\x18\xeb\a \x01(\v2\".api.configs.Bootstrap.HealthCheckR\fhealth_check\x12*\n" + - "\x06logger\x18\xec\a \x01(\v2\x11.config.v1.LoggerR\x06logger\x123\n" + - "\x06server\x18\xed\a \x01(\v2\x1a.api.configs.ServiceServerR\x06server\x125\n" + - "\aclients\x18\xee\a \x03(\v2\x1a.api.configs.ServiceClientR\aclients\x1a;\n" + - "\vHealthCheck\x12\x18\n" + - "\atimeout\x18\x01 \x01(\x05R\atimeout\x12\x12\n" + - "\x04path\x18\x02 \x01(\tR\x04path\x1at\n" + - "\x05Entry\x12\x16\n" + - "\x06scheme\x18\x01 \x01(\tR\x06scheme\x12#\n" + - "\x04cors\x18\x02 \x01(\v2\x0f.config.v1.CorsR\x04cors\x12.\n" + - "\bservices\x18\x03 \x03(\v2\x12.config.v1.ServiceR\bservices\",\n" + - "\bSettings\x12 \n" + - "\vcrypto_type\x18\x01 \x01(\tR\vcrypto_typeB.Z,origadmin/application/admin/internal/configsb\x06proto3" - -var ( - file_configs_bootstrap_proto_rawDescOnce sync.Once - file_configs_bootstrap_proto_rawDescData []byte -) - -func file_configs_bootstrap_proto_rawDescGZIP() []byte { - file_configs_bootstrap_proto_rawDescOnce.Do(func() { - file_configs_bootstrap_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_bootstrap_proto_rawDesc), len(file_configs_bootstrap_proto_rawDesc))) - }) - return file_configs_bootstrap_proto_rawDescData -} - -var file_configs_bootstrap_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_configs_bootstrap_proto_goTypes = []any{ - (*EntrySelectorConfig)(nil), // 0: api.configs.EntrySelectorConfig - (*Bootstrap)(nil), // 1: api.configs.Bootstrap - (*Settings)(nil), // 2: api.configs.Settings - (*Bootstrap_HealthCheck)(nil), // 3: api.configs.Bootstrap.HealthCheck - (*Bootstrap_Entry)(nil), // 4: api.configs.Bootstrap.Entry - (*v1.Storage)(nil), // 5: config.v1.Storage - (*v1.Discovery)(nil), // 6: config.v1.Discovery - (*v11.Middleware)(nil), // 7: middleware.v1.Middleware - (*SecurityConfig)(nil), // 8: api.configs.SecurityConfig - (*v1.Logger)(nil), // 9: config.v1.Logger - (*ServiceServer)(nil), // 10: api.configs.ServiceServer - (*ServiceClient)(nil), // 11: api.configs.ServiceClient - (*v1.Cors)(nil), // 12: config.v1.Cors - (*v1.Service)(nil), // 13: config.v1.Service -} -var file_configs_bootstrap_proto_depIdxs = []int32{ - 4, // 0: api.configs.Bootstrap.entry:type_name -> api.configs.Bootstrap.Entry - 5, // 1: api.configs.Bootstrap.storage:type_name -> config.v1.Storage - 6, // 2: api.configs.Bootstrap.discovery:type_name -> config.v1.Discovery - 7, // 3: api.configs.Bootstrap.middleware:type_name -> middleware.v1.Middleware - 8, // 4: api.configs.Bootstrap.security:type_name -> api.configs.SecurityConfig - 3, // 5: api.configs.Bootstrap.health_check:type_name -> api.configs.Bootstrap.HealthCheck - 9, // 6: api.configs.Bootstrap.logger:type_name -> config.v1.Logger - 10, // 7: api.configs.Bootstrap.server:type_name -> api.configs.ServiceServer - 11, // 8: api.configs.Bootstrap.clients:type_name -> api.configs.ServiceClient - 12, // 9: api.configs.Bootstrap.Entry.cors:type_name -> config.v1.Cors - 13, // 10: api.configs.Bootstrap.Entry.services:type_name -> config.v1.Service - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name -} - -func init() { file_configs_bootstrap_proto_init() } -func file_configs_bootstrap_proto_init() { - if File_configs_bootstrap_proto != nil { - return - } - file_configs_security_config_proto_init() - file_configs_service_proto_init() - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_bootstrap_proto_rawDesc), len(file_configs_bootstrap_proto_rawDesc)), - NumEnums: 0, - NumMessages: 5, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_configs_bootstrap_proto_goTypes, - DependencyIndexes: file_configs_bootstrap_proto_depIdxs, - MessageInfos: file_configs_bootstrap_proto_msgTypes, - }.Build() - File_configs_bootstrap_proto = out.File - file_configs_bootstrap_proto_goTypes = nil - file_configs_bootstrap_proto_depIdxs = nil -} diff --git a/internal/configs/bootstrap.pb.validate.go b/internal/configs/bootstrap.pb.validate.go deleted file mode 100644 index 9f958490..00000000 --- a/internal/configs/bootstrap.pb.validate.go +++ /dev/null @@ -1,923 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: configs/bootstrap.proto - -package configs - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on EntrySelectorConfig 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 *EntrySelectorConfig) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on EntrySelectorConfig 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 -// EntrySelectorConfigMultiError, or nil if none found. -func (m *EntrySelectorConfig) ValidateAll() error { - return m.validate(true) -} - -func (m *EntrySelectorConfig) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Global - - // no validation rules for Name - - // no validation rules for Version - - if len(errors) > 0 { - return EntrySelectorConfigMultiError(errors) - } - - return nil -} - -// EntrySelectorConfigMultiError is an error wrapping multiple validation -// errors returned by EntrySelectorConfig.ValidateAll() if the designated -// constraints aren't met. -type EntrySelectorConfigMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m EntrySelectorConfigMultiError) 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 EntrySelectorConfigMultiError) AllErrors() []error { return m } - -// EntrySelectorConfigValidationError is the validation error returned by -// EntrySelectorConfig.Validate if the designated constraints aren't met. -type EntrySelectorConfigValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e EntrySelectorConfigValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e EntrySelectorConfigValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e EntrySelectorConfigValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e EntrySelectorConfigValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e EntrySelectorConfigValidationError) ErrorName() string { - return "EntrySelectorConfigValidationError" -} - -// Error satisfies the builtin error interface -func (e EntrySelectorConfigValidationError) 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 %sEntrySelectorConfig.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = EntrySelectorConfigValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = EntrySelectorConfigValidationError{} - -// Validate checks the field values on Bootstrap 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 *Bootstrap) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Bootstrap 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 BootstrapMultiError, or nil -// if none found. -func (m *Bootstrap) ValidateAll() error { - return m.validate(true) -} - -func (m *Bootstrap) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Name - - // no validation rules for Version - - // no validation rules for CryptoType - - if _, ok := _Bootstrap_Mode_InLookup[m.GetMode()]; !ok { - err := BootstrapValidationError{ - field: "Mode", - reason: "value must be in list [singleton cluster]", - } - if !all { - return err - } - errors = append(errors, err) - } - - // no validation rules for EnableDynamicConfig - - // no validation rules for Id - - if _, ok := _Bootstrap_Environment_InLookup[m.GetEnvironment()]; !ok { - err := BootstrapValidationError{ - field: "Environment", - reason: "value must be in list [dev prod]", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetEntry()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Entry", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Entry", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEntry()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "Entry", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetStorage()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Storage", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Storage", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetStorage()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "Storage", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetDiscovery()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Discovery", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Discovery", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDiscovery()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "Discovery", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetMiddleware()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMiddleware()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetSecurity()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Security", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Security", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetSecurity()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "Security", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetHealthCheck()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "HealthCheck", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "HealthCheck", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetHealthCheck()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "HealthCheck", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetLogger()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Logger", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Logger", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetLogger()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "Logger", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetServer()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Server", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: "Server", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetServer()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: "Server", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetClients() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: fmt.Sprintf("Clients[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, BootstrapValidationError{ - field: fmt.Sprintf("Clients[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return BootstrapValidationError{ - field: fmt.Sprintf("Clients[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return BootstrapMultiError(errors) - } - - return nil -} - -// BootstrapMultiError is an error wrapping multiple validation errors returned -// by Bootstrap.ValidateAll() if the designated constraints aren't met. -type BootstrapMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m BootstrapMultiError) 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 BootstrapMultiError) AllErrors() []error { return m } - -// BootstrapValidationError is the validation error returned by -// Bootstrap.Validate if the designated constraints aren't met. -type BootstrapValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e BootstrapValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e BootstrapValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e BootstrapValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e BootstrapValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e BootstrapValidationError) ErrorName() string { return "BootstrapValidationError" } - -// Error satisfies the builtin error interface -func (e BootstrapValidationError) 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 %sBootstrap.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = BootstrapValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = BootstrapValidationError{} - -var _Bootstrap_Mode_InLookup = map[string]struct{}{ - "singleton": {}, - "cluster": {}, -} - -var _Bootstrap_Environment_InLookup = map[string]struct{}{ - "dev": {}, - "prod": {}, -} - -// Validate checks the field values on Settings 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 *Settings) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Settings 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 SettingsMultiError, or nil -// if none found. -func (m *Settings) ValidateAll() error { - return m.validate(true) -} - -func (m *Settings) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for CryptoType - - if len(errors) > 0 { - return SettingsMultiError(errors) - } - - return nil -} - -// SettingsMultiError is an error wrapping multiple validation errors returned -// by Settings.ValidateAll() if the designated constraints aren't met. -type SettingsMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m SettingsMultiError) 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 SettingsMultiError) AllErrors() []error { return m } - -// SettingsValidationError is the validation error returned by -// Settings.Validate if the designated constraints aren't met. -type SettingsValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e SettingsValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e SettingsValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e SettingsValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e SettingsValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e SettingsValidationError) ErrorName() string { return "SettingsValidationError" } - -// Error satisfies the builtin error interface -func (e SettingsValidationError) 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 %sSettings.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = SettingsValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = SettingsValidationError{} - -// Validate checks the field values on Bootstrap_HealthCheck 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 *Bootstrap_HealthCheck) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Bootstrap_HealthCheck 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 -// Bootstrap_HealthCheckMultiError, or nil if none found. -func (m *Bootstrap_HealthCheck) ValidateAll() error { - return m.validate(true) -} - -func (m *Bootstrap_HealthCheck) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Timeout - - // no validation rules for Path - - if len(errors) > 0 { - return Bootstrap_HealthCheckMultiError(errors) - } - - return nil -} - -// Bootstrap_HealthCheckMultiError is an error wrapping multiple validation -// errors returned by Bootstrap_HealthCheck.ValidateAll() if the designated -// constraints aren't met. -type Bootstrap_HealthCheckMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m Bootstrap_HealthCheckMultiError) 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 Bootstrap_HealthCheckMultiError) AllErrors() []error { return m } - -// Bootstrap_HealthCheckValidationError is the validation error returned by -// Bootstrap_HealthCheck.Validate if the designated constraints aren't met. -type Bootstrap_HealthCheckValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e Bootstrap_HealthCheckValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e Bootstrap_HealthCheckValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e Bootstrap_HealthCheckValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e Bootstrap_HealthCheckValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e Bootstrap_HealthCheckValidationError) ErrorName() string { - return "Bootstrap_HealthCheckValidationError" -} - -// Error satisfies the builtin error interface -func (e Bootstrap_HealthCheckValidationError) 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 %sBootstrap_HealthCheck.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = Bootstrap_HealthCheckValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = Bootstrap_HealthCheckValidationError{} - -// Validate checks the field values on Bootstrap_Entry 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 *Bootstrap_Entry) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Bootstrap_Entry 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 -// Bootstrap_EntryMultiError, or nil if none found. -func (m *Bootstrap_Entry) ValidateAll() error { - return m.validate(true) -} - -func (m *Bootstrap_Entry) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Scheme - - if all { - switch v := interface{}(m.GetCors()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, Bootstrap_EntryValidationError{ - field: "Cors", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, Bootstrap_EntryValidationError{ - field: "Cors", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCors()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return Bootstrap_EntryValidationError{ - field: "Cors", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetServices() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, Bootstrap_EntryValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, Bootstrap_EntryValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return Bootstrap_EntryValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return Bootstrap_EntryMultiError(errors) - } - - return nil -} - -// Bootstrap_EntryMultiError is an error wrapping multiple validation errors -// returned by Bootstrap_Entry.ValidateAll() if the designated constraints -// aren't met. -type Bootstrap_EntryMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m Bootstrap_EntryMultiError) 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 Bootstrap_EntryMultiError) AllErrors() []error { return m } - -// Bootstrap_EntryValidationError is the validation error returned by -// Bootstrap_Entry.Validate if the designated constraints aren't met. -type Bootstrap_EntryValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e Bootstrap_EntryValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e Bootstrap_EntryValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e Bootstrap_EntryValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e Bootstrap_EntryValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e Bootstrap_EntryValidationError) ErrorName() string { return "Bootstrap_EntryValidationError" } - -// Error satisfies the builtin error interface -func (e Bootstrap_EntryValidationError) 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 %sBootstrap_Entry.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = Bootstrap_EntryValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = Bootstrap_EntryValidationError{} diff --git a/internal/configs/bootstrap.proto b/internal/configs/bootstrap.proto deleted file mode 100644 index e7f90d94..00000000 --- a/internal/configs/bootstrap.proto +++ /dev/null @@ -1,89 +0,0 @@ -syntax = "proto3"; - -package api.configs; - -import "config/v1/cors.proto"; -import "config/v1/discovery.proto"; -import "config/v1/logger.proto"; -import "config/v1/service.proto"; -import "config/v1/storage.proto"; -import "configs/security_config.proto"; -import "configs/service.proto"; -import "middleware/v1/middleware.proto"; -import "validate/validate.proto"; // Updated import statement - -option go_package = "origadmin/application/admin/internal/configs"; - -message EntrySelectorConfig { - bool global = 2 [json_name = "global"]; - string name = 3 [json_name = "name"]; - string version = 4 [json_name = "version"]; -} - -//message ServiceServer { -// string name = 1 [ -// json_name = "name", -// (validate.rules).string.min_len = 1 -// ]; -// // Entry entry = 2 [json_name = "entry"]; // 各服务独立入口配置 -// // repeated config.v1.Service services = 3 [json_name = "services"]; // 服务专用配置 -//} - -message Bootstrap { - // name is the application name or service name for used - string name = 1 [json_name = "name"]; - string version = 2 [json_name = "version"]; - string crypto_type = 3 [json_name = "crypto_type"]; - string mode = 5 [ - json_name = "mode", - (validate.rules).string = { // Ensure this matches the new import - in: [ - "singleton", - "cluster" - ] - } - ]; - - bool enable_dynamic_config = 7 [json_name = "enable_dynamic_config"]; - - message HealthCheck { - int32 timeout = 1 [json_name = "timeout"]; - string path = 2 [json_name = "path"]; - } - - // Entry - message Entry { - string scheme = 1 [json_name = "scheme"]; - config.v1.Cors cors = 2 [json_name = "cors"]; - repeated config.v1.Service services = 3 [json_name = "services"]; - } - - string id = 100 [json_name = "id"]; - string environment = 102 [ - json_name = "environment", - (validate.rules).string = { - in: [ - "dev", - "prod" - ] - } - ]; - - // 入口服务专属配置 - Entry entry = 103 [json_name = "entry"]; - - config.v1.Storage storage = 300 [json_name = "storage"]; - config.v1.Discovery discovery = 400 [json_name = "discovery"]; - middleware.v1.Middleware middleware = 9 [json_name = "middleware"]; - SecurityConfig security = 10 [json_name = "security"]; - - HealthCheck health_check = 1003 [json_name = "health_check"]; - config.v1.Logger logger = 1004 [json_name = "logger"]; - - ServiceServer server = 1005 [json_name = "server"]; - repeated ServiceClient clients = 1006 [json_name = "clients"]; -} - -message Settings { - string crypto_type = 1 [json_name = "crypto_type"]; -} diff --git a/internal/configs/security_config.pb.go b/internal/configs/security_config.pb.go deleted file mode 100644 index 58378593..00000000 --- a/internal/configs/security_config.pb.go +++ /dev/null @@ -1,149 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc v5.28.3 -// source: configs/security_config.proto - -package configs - -import ( - v1 "github.com/origadmin/runtime/api/gen/go/config/v1" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type SecurityConfig struct { - state protoimpl.MessageState `protogen:"open.v1"` - RootUser *RootUser `protobuf:"bytes,1,opt,name=root_user,proto3" json:"root_user,omitempty"` - Captcha *Captcha `protobuf:"bytes,2,opt,name=captcha,proto3" json:"captcha,omitempty"` - Security *v1.Security `protobuf:"bytes,3,opt,name=security,proto3" json:"security,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *SecurityConfig) Reset() { - *x = SecurityConfig{} - mi := &file_configs_security_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *SecurityConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SecurityConfig) ProtoMessage() {} - -func (x *SecurityConfig) ProtoReflect() protoreflect.Message { - mi := &file_configs_security_config_proto_msgTypes[0] - 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 SecurityConfig.ProtoReflect.Descriptor instead. -func (*SecurityConfig) Descriptor() ([]byte, []int) { - return file_configs_security_config_proto_rawDescGZIP(), []int{0} -} - -func (x *SecurityConfig) GetRootUser() *RootUser { - if x != nil { - return x.RootUser - } - return nil -} - -func (x *SecurityConfig) GetCaptcha() *Captcha { - if x != nil { - return x.Captcha - } - return nil -} - -func (x *SecurityConfig) GetSecurity() *v1.Security { - if x != nil { - return x.Security - } - return nil -} - -var File_configs_security_config_proto protoreflect.FileDescriptor - -const file_configs_security_config_proto_rawDesc = "" + - "\n" + - "\x1dconfigs/security_config.proto\x12\vapi.configs\x1a\x18config/v1/security.proto\x1a\x15configs/captcha.proto\x1a\x17configs/root_user.proto\"\xa6\x01\n" + - "\x0eSecurityConfig\x123\n" + - "\troot_user\x18\x01 \x01(\v2\x15.api.configs.RootUserR\troot_user\x12.\n" + - "\acaptcha\x18\x02 \x01(\v2\x14.api.configs.CaptchaR\acaptcha\x12/\n" + - "\bsecurity\x18\x03 \x01(\v2\x13.config.v1.SecurityR\bsecurityB.Z,origadmin/application/admin/internal/configsb\x06proto3" - -var ( - file_configs_security_config_proto_rawDescOnce sync.Once - file_configs_security_config_proto_rawDescData []byte -) - -func file_configs_security_config_proto_rawDescGZIP() []byte { - file_configs_security_config_proto_rawDescOnce.Do(func() { - file_configs_security_config_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_security_config_proto_rawDesc), len(file_configs_security_config_proto_rawDesc))) - }) - return file_configs_security_config_proto_rawDescData -} - -var file_configs_security_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_configs_security_config_proto_goTypes = []any{ - (*SecurityConfig)(nil), // 0: api.configs.SecurityConfig - (*RootUser)(nil), // 1: api.configs.RootUser - (*Captcha)(nil), // 2: api.configs.Captcha - (*v1.Security)(nil), // 3: config.v1.Security -} -var file_configs_security_config_proto_depIdxs = []int32{ - 1, // 0: api.configs.SecurityConfig.root_user:type_name -> api.configs.RootUser - 2, // 1: api.configs.SecurityConfig.captcha:type_name -> api.configs.Captcha - 3, // 2: api.configs.SecurityConfig.security:type_name -> config.v1.Security - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_configs_security_config_proto_init() } -func file_configs_security_config_proto_init() { - if File_configs_security_config_proto != nil { - return - } - file_configs_captcha_proto_init() - file_configs_root_user_proto_init() - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_security_config_proto_rawDesc), len(file_configs_security_config_proto_rawDesc)), - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_configs_security_config_proto_goTypes, - DependencyIndexes: file_configs_security_config_proto_depIdxs, - MessageInfos: file_configs_security_config_proto_msgTypes, - }.Build() - File_configs_security_config_proto = out.File - file_configs_security_config_proto_goTypes = nil - file_configs_security_config_proto_depIdxs = nil -} diff --git a/internal/configs/security_config.pb.validate.go b/internal/configs/security_config.pb.validate.go deleted file mode 100644 index e6227f9c..00000000 --- a/internal/configs/security_config.pb.validate.go +++ /dev/null @@ -1,223 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: configs/security_config.proto - -package configs - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on SecurityConfig 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 *SecurityConfig) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on SecurityConfig 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 SecurityConfigMultiError, -// or nil if none found. -func (m *SecurityConfig) ValidateAll() error { - return m.validate(true) -} - -func (m *SecurityConfig) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRootUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, SecurityConfigValidationError{ - field: "RootUser", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, SecurityConfigValidationError{ - field: "RootUser", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRootUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return SecurityConfigValidationError{ - field: "RootUser", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetCaptcha()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, SecurityConfigValidationError{ - field: "Captcha", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, SecurityConfigValidationError{ - field: "Captcha", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCaptcha()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return SecurityConfigValidationError{ - field: "Captcha", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetSecurity()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, SecurityConfigValidationError{ - field: "Security", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, SecurityConfigValidationError{ - field: "Security", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetSecurity()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return SecurityConfigValidationError{ - field: "Security", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return SecurityConfigMultiError(errors) - } - - return nil -} - -// SecurityConfigMultiError is an error wrapping multiple validation errors -// returned by SecurityConfig.ValidateAll() if the designated constraints -// aren't met. -type SecurityConfigMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m SecurityConfigMultiError) 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 SecurityConfigMultiError) AllErrors() []error { return m } - -// SecurityConfigValidationError is the validation error returned by -// SecurityConfig.Validate if the designated constraints aren't met. -type SecurityConfigValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e SecurityConfigValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e SecurityConfigValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e SecurityConfigValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e SecurityConfigValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e SecurityConfigValidationError) ErrorName() string { return "SecurityConfigValidationError" } - -// Error satisfies the builtin error interface -func (e SecurityConfigValidationError) 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 %sSecurityConfig.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = SecurityConfigValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = SecurityConfigValidationError{} diff --git a/internal/configs/security_config.proto b/internal/configs/security_config.proto deleted file mode 100644 index 56fba8d6..00000000 --- a/internal/configs/security_config.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; -package api.configs; - -import "config/v1/security.proto"; -import "configs/captcha.proto"; -import "configs/root_user.proto"; - -option go_package = "origadmin/application/admin/internal/configs"; - -message SecurityConfig { - RootUser root_user = 1 [json_name = "root_user"]; - Captcha captcha = 2 [json_name = "captcha"]; - - config.v1.Security security = 3 [json_name = "security"]; -} diff --git a/internal/configs/server.pb.go b/internal/configs/server.pb.go deleted file mode 100644 index 9df38a54..00000000 --- a/internal/configs/server.pb.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc v5.28.3 -// source: configs/server.proto - -package configs - -import ( - v1 "github.com/origadmin/runtime/api/gen/go/config/v1" - v11 "github.com/origadmin/runtime/api/gen/go/middleware/v1" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Server struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Service *v1.Service `protobuf:"bytes,200,opt,name=service,proto3" json:"service,omitempty"` - Storage *v1.Storage `protobuf:"bytes,300,opt,name=storage,proto3" json:"storage,omitempty"` - Discovery *v1.Discovery `protobuf:"bytes,400,opt,name=discovery,proto3" json:"discovery,omitempty"` - Middleware *v11.Middleware `protobuf:"bytes,9,opt,name=middleware,proto3" json:"middleware,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Server) Reset() { - *x = Server{} - mi := &file_configs_server_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Server) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Server) ProtoMessage() {} - -func (x *Server) ProtoReflect() protoreflect.Message { - mi := &file_configs_server_proto_msgTypes[0] - 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 Server.ProtoReflect.Descriptor instead. -func (*Server) Descriptor() ([]byte, []int) { - return file_configs_server_proto_rawDescGZIP(), []int{0} -} - -func (x *Server) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Server) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *Server) GetService() *v1.Service { - if x != nil { - return x.Service - } - return nil -} - -func (x *Server) GetStorage() *v1.Storage { - if x != nil { - return x.Storage - } - return nil -} - -func (x *Server) GetDiscovery() *v1.Discovery { - if x != nil { - return x.Discovery - } - return nil -} - -func (x *Server) GetMiddleware() *v11.Middleware { - if x != nil { - return x.Middleware - } - return nil -} - -var File_configs_server_proto protoreflect.FileDescriptor - -const file_configs_server_proto_rawDesc = "" + - "\n" + - "\x14configs/server.proto\x12\x15origadmin.api.configs\x1a\x17config/v1/storage.proto\x1a\x19config/v1/discovery.proto\x1a\x17config/v1/service.proto\x1a\x1emiddleware/v1/middleware.proto\"\x84\x02\n" + - "\x06Server\x12\x12\n" + - "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + - "\aversion\x18\x02 \x01(\tR\aversion\x12-\n" + - "\aservice\x18\xc8\x01 \x01(\v2\x12.config.v1.ServiceR\aservice\x12-\n" + - "\astorage\x18\xac\x02 \x01(\v2\x12.config.v1.StorageR\astorage\x123\n" + - "\tdiscovery\x18\x90\x03 \x01(\v2\x14.config.v1.DiscoveryR\tdiscovery\x129\n" + - "\n" + - "middleware\x18\t \x01(\v2\x19.middleware.v1.MiddlewareR\n" + - "middlewareB.Z,origadmin/application/admin/internal/configsb\x06proto3" - -var ( - file_configs_server_proto_rawDescOnce sync.Once - file_configs_server_proto_rawDescData []byte -) - -func file_configs_server_proto_rawDescGZIP() []byte { - file_configs_server_proto_rawDescOnce.Do(func() { - file_configs_server_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_server_proto_rawDesc), len(file_configs_server_proto_rawDesc))) - }) - return file_configs_server_proto_rawDescData -} - -var file_configs_server_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_configs_server_proto_goTypes = []any{ - (*Server)(nil), // 0: origadmin.api.configs.Server - (*v1.Service)(nil), // 1: config.v1.Service - (*v1.Storage)(nil), // 2: config.v1.Storage - (*v1.Discovery)(nil), // 3: config.v1.Discovery - (*v11.Middleware)(nil), // 4: middleware.v1.Middleware -} -var file_configs_server_proto_depIdxs = []int32{ - 1, // 0: origadmin.api.configs.Server.service:type_name -> config.v1.Service - 2, // 1: origadmin.api.configs.Server.storage:type_name -> config.v1.Storage - 3, // 2: origadmin.api.configs.Server.discovery:type_name -> config.v1.Discovery - 4, // 3: origadmin.api.configs.Server.middleware:type_name -> middleware.v1.Middleware - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_configs_server_proto_init() } -func file_configs_server_proto_init() { - if File_configs_server_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_server_proto_rawDesc), len(file_configs_server_proto_rawDesc)), - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_configs_server_proto_goTypes, - DependencyIndexes: file_configs_server_proto_depIdxs, - MessageInfos: file_configs_server_proto_msgTypes, - }.Build() - File_configs_server_proto = out.File - file_configs_server_proto_goTypes = nil - file_configs_server_proto_depIdxs = nil -} diff --git a/internal/configs/server.pb.validate.go b/internal/configs/server.pb.validate.go deleted file mode 100644 index 414bf880..00000000 --- a/internal/configs/server.pb.validate.go +++ /dev/null @@ -1,254 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: configs/server.proto - -package configs - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on Server 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 *Server) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Server 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 ServerMultiError, or nil if none found. -func (m *Server) ValidateAll() error { - return m.validate(true) -} - -func (m *Server) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Name - - // no validation rules for Version - - if all { - switch v := interface{}(m.GetService()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServerValidationError{ - field: "Service", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServerValidationError{ - field: "Service", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetService()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServerValidationError{ - field: "Service", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetStorage()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServerValidationError{ - field: "Storage", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServerValidationError{ - field: "Storage", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetStorage()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServerValidationError{ - field: "Storage", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetDiscovery()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServerValidationError{ - field: "Discovery", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServerValidationError{ - field: "Discovery", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDiscovery()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServerValidationError{ - field: "Discovery", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetMiddleware()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServerValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServerValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMiddleware()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServerValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ServerMultiError(errors) - } - - return nil -} - -// ServerMultiError is an error wrapping multiple validation errors returned by -// Server.ValidateAll() if the designated constraints aren't met. -type ServerMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ServerMultiError) 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 ServerMultiError) AllErrors() []error { return m } - -// ServerValidationError is the validation error returned by Server.Validate if -// the designated constraints aren't met. -type ServerValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ServerValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ServerValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ServerValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ServerValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ServerValidationError) ErrorName() string { return "ServerValidationError" } - -// Error satisfies the builtin error interface -func (e ServerValidationError) 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 %sServer.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ServerValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ServerValidationError{} diff --git a/internal/configs/server.proto b/internal/configs/server.proto deleted file mode 100644 index e42e9f96..00000000 --- a/internal/configs/server.proto +++ /dev/null @@ -1,19 +0,0 @@ -syntax = "proto3"; -package origadmin.api.configs; - -import "config/v1/storage.proto"; -import "config/v1/discovery.proto"; -import "config/v1/service.proto"; -import "middleware/v1/middleware.proto"; - -option go_package = "origadmin/application/admin/internal/configs"; - -message Server { - string name = 1 [json_name = "name"]; - string version = 2 [json_name = "version"]; - - config.v1.Service service = 200 [json_name = "service"]; - config.v1.Storage storage = 300 [json_name = "storage"]; - config.v1.Discovery discovery = 400 [json_name = "discovery"]; - middleware.v1.Middleware middleware = 9 [json_name = "middleware"]; -} diff --git a/internal/configs/service.pb.go b/internal/configs/service.pb.go deleted file mode 100644 index 79046f66..00000000 --- a/internal/configs/service.pb.go +++ /dev/null @@ -1,297 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.6 -// protoc v5.28.3 -// source: configs/service.proto - -package configs - -import ( - v1 "github.com/origadmin/runtime/api/gen/go/config/v1" - v11 "github.com/origadmin/runtime/api/gen/go/middleware/v1" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ServiceCore struct { - state protoimpl.MessageState `protogen:"open.v1"` - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` - Discovery *v1.Discovery `protobuf:"bytes,3,opt,name=discovery,proto3" json:"discovery,omitempty"` - Storages []*v1.Storage `protobuf:"bytes,4,rep,name=storages,proto3" json:"storages,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ServiceCore) Reset() { - *x = ServiceCore{} - mi := &file_configs_service_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ServiceCore) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServiceCore) ProtoMessage() {} - -func (x *ServiceCore) ProtoReflect() protoreflect.Message { - mi := &file_configs_service_proto_msgTypes[0] - 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 ServiceCore.ProtoReflect.Descriptor instead. -func (*ServiceCore) Descriptor() ([]byte, []int) { - return file_configs_service_proto_rawDescGZIP(), []int{0} -} - -func (x *ServiceCore) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *ServiceCore) GetVersion() string { - if x != nil { - return x.Version - } - return "" -} - -func (x *ServiceCore) GetDiscovery() *v1.Discovery { - if x != nil { - return x.Discovery - } - return nil -} - -func (x *ServiceCore) GetStorages() []*v1.Storage { - if x != nil { - return x.Storages - } - return nil -} - -type ServiceServer struct { - state protoimpl.MessageState `protogen:"open.v1"` - Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` - Services []*v1.Service `protobuf:"bytes,200,rep,name=services,proto3" json:"services,omitempty"` - Middleware *v11.Middleware `protobuf:"bytes,300,opt,name=middleware,proto3" json:"middleware,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ServiceServer) Reset() { - *x = ServiceServer{} - mi := &file_configs_service_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ServiceServer) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServiceServer) ProtoMessage() {} - -func (x *ServiceServer) ProtoReflect() protoreflect.Message { - mi := &file_configs_service_proto_msgTypes[1] - 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 ServiceServer.ProtoReflect.Descriptor instead. -func (*ServiceServer) Descriptor() ([]byte, []int) { - return file_configs_service_proto_rawDescGZIP(), []int{1} -} - -func (x *ServiceServer) GetCore() *ServiceCore { - if x != nil { - return x.Core - } - return nil -} - -func (x *ServiceServer) GetServices() []*v1.Service { - if x != nil { - return x.Services - } - return nil -} - -func (x *ServiceServer) GetMiddleware() *v11.Middleware { - if x != nil { - return x.Middleware - } - return nil -} - -type ServiceClient struct { - state protoimpl.MessageState `protogen:"open.v1"` - Core *ServiceCore `protobuf:"bytes,1,opt,name=core,proto3" json:"core,omitempty"` - Services []*v1.Service `protobuf:"bytes,200,rep,name=services,proto3" json:"services,omitempty"` - Middleware *v11.Middleware `protobuf:"bytes,300,opt,name=middleware,proto3" json:"middleware,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ServiceClient) Reset() { - *x = ServiceClient{} - mi := &file_configs_service_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ServiceClient) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServiceClient) ProtoMessage() {} - -func (x *ServiceClient) ProtoReflect() protoreflect.Message { - mi := &file_configs_service_proto_msgTypes[2] - 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 ServiceClient.ProtoReflect.Descriptor instead. -func (*ServiceClient) Descriptor() ([]byte, []int) { - return file_configs_service_proto_rawDescGZIP(), []int{2} -} - -func (x *ServiceClient) GetCore() *ServiceCore { - if x != nil { - return x.Core - } - return nil -} - -func (x *ServiceClient) GetServices() []*v1.Service { - if x != nil { - return x.Services - } - return nil -} - -func (x *ServiceClient) GetMiddleware() *v11.Middleware { - if x != nil { - return x.Middleware - } - return nil -} - -var File_configs_service_proto protoreflect.FileDescriptor - -const file_configs_service_proto_rawDesc = "" + - "\n" + - "\x15configs/service.proto\x12\vapi.configs\x1a\x19config/v1/discovery.proto\x1a\x17config/v1/service.proto\x1a\x17config/v1/storage.proto\x1a\x1emiddleware/v1/middleware.proto\"\x9f\x01\n" + - "\vServiceCore\x12\x12\n" + - "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + - "\aversion\x18\x02 \x01(\tR\aversion\x122\n" + - "\tdiscovery\x18\x03 \x01(\v2\x14.config.v1.DiscoveryR\tdiscovery\x12.\n" + - "\bstorages\x18\x04 \x03(\v2\x12.config.v1.StorageR\bstorages\"\xaa\x01\n" + - "\rServiceServer\x12,\n" + - "\x04core\x18\x01 \x01(\v2\x18.api.configs.ServiceCoreR\x04core\x12/\n" + - "\bservices\x18\xc8\x01 \x03(\v2\x12.config.v1.ServiceR\bservices\x12:\n" + - "\n" + - "middleware\x18\xac\x02 \x01(\v2\x19.middleware.v1.MiddlewareR\n" + - "middleware\"\xaa\x01\n" + - "\rServiceClient\x12,\n" + - "\x04core\x18\x01 \x01(\v2\x18.api.configs.ServiceCoreR\x04core\x12/\n" + - "\bservices\x18\xc8\x01 \x03(\v2\x12.config.v1.ServiceR\bservices\x12:\n" + - "\n" + - "middleware\x18\xac\x02 \x01(\v2\x19.middleware.v1.MiddlewareR\n" + - "middlewareB.Z,origadmin/application/admin/internal/configsb\x06proto3" - -var ( - file_configs_service_proto_rawDescOnce sync.Once - file_configs_service_proto_rawDescData []byte -) - -func file_configs_service_proto_rawDescGZIP() []byte { - file_configs_service_proto_rawDescOnce.Do(func() { - file_configs_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_configs_service_proto_rawDesc), len(file_configs_service_proto_rawDesc))) - }) - return file_configs_service_proto_rawDescData -} - -var file_configs_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_configs_service_proto_goTypes = []any{ - (*ServiceCore)(nil), // 0: api.configs.ServiceCore - (*ServiceServer)(nil), // 1: api.configs.ServiceServer - (*ServiceClient)(nil), // 2: api.configs.ServiceClient - (*v1.Discovery)(nil), // 3: config.v1.Discovery - (*v1.Storage)(nil), // 4: config.v1.Storage - (*v1.Service)(nil), // 5: config.v1.Service - (*v11.Middleware)(nil), // 6: middleware.v1.Middleware -} -var file_configs_service_proto_depIdxs = []int32{ - 3, // 0: api.configs.ServiceCore.discovery:type_name -> config.v1.Discovery - 4, // 1: api.configs.ServiceCore.storages:type_name -> config.v1.Storage - 0, // 2: api.configs.ServiceServer.core:type_name -> api.configs.ServiceCore - 5, // 3: api.configs.ServiceServer.services:type_name -> config.v1.Service - 6, // 4: api.configs.ServiceServer.middleware:type_name -> middleware.v1.Middleware - 0, // 5: api.configs.ServiceClient.core:type_name -> api.configs.ServiceCore - 5, // 6: api.configs.ServiceClient.services:type_name -> config.v1.Service - 6, // 7: api.configs.ServiceClient.middleware:type_name -> middleware.v1.Middleware - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_configs_service_proto_init() } -func file_configs_service_proto_init() { - if File_configs_service_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_configs_service_proto_rawDesc), len(file_configs_service_proto_rawDesc)), - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_configs_service_proto_goTypes, - DependencyIndexes: file_configs_service_proto_depIdxs, - MessageInfos: file_configs_service_proto_msgTypes, - }.Build() - File_configs_service_proto = out.File - file_configs_service_proto_goTypes = nil - file_configs_service_proto_depIdxs = nil -} diff --git a/internal/configs/service.pb.validate.go b/internal/configs/service.pb.validate.go deleted file mode 100644 index 7db5efe8..00000000 --- a/internal/configs/service.pb.validate.go +++ /dev/null @@ -1,586 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: configs/service.proto - -package configs - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ServiceCore 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 *ServiceCore) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ServiceCore 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 ServiceCoreMultiError, or -// nil if none found. -func (m *ServiceCore) ValidateAll() error { - return m.validate(true) -} - -func (m *ServiceCore) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Name - - // no validation rules for Version - - if all { - switch v := interface{}(m.GetDiscovery()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceCoreValidationError{ - field: "Discovery", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServiceCoreValidationError{ - field: "Discovery", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDiscovery()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServiceCoreValidationError{ - field: "Discovery", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetStorages() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceCoreValidationError{ - field: fmt.Sprintf("Storages[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServiceCoreValidationError{ - field: fmt.Sprintf("Storages[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServiceCoreValidationError{ - field: fmt.Sprintf("Storages[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ServiceCoreMultiError(errors) - } - - return nil -} - -// ServiceCoreMultiError is an error wrapping multiple validation errors -// returned by ServiceCore.ValidateAll() if the designated constraints aren't met. -type ServiceCoreMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ServiceCoreMultiError) 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 ServiceCoreMultiError) AllErrors() []error { return m } - -// ServiceCoreValidationError is the validation error returned by -// ServiceCore.Validate if the designated constraints aren't met. -type ServiceCoreValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ServiceCoreValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ServiceCoreValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ServiceCoreValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ServiceCoreValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ServiceCoreValidationError) ErrorName() string { return "ServiceCoreValidationError" } - -// Error satisfies the builtin error interface -func (e ServiceCoreValidationError) 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 %sServiceCore.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ServiceCoreValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ServiceCoreValidationError{} - -// Validate checks the field values on ServiceServer 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 *ServiceServer) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ServiceServer 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 ServiceServerMultiError, or -// nil if none found. -func (m *ServiceServer) ValidateAll() error { - return m.validate(true) -} - -func (m *ServiceServer) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetCore()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceServerValidationError{ - field: "Core", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServiceServerValidationError{ - field: "Core", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCore()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServiceServerValidationError{ - field: "Core", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetServices() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceServerValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServiceServerValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServiceServerValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetMiddleware()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceServerValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServiceServerValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMiddleware()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServiceServerValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ServiceServerMultiError(errors) - } - - return nil -} - -// ServiceServerMultiError is an error wrapping multiple validation errors -// returned by ServiceServer.ValidateAll() if the designated constraints -// aren't met. -type ServiceServerMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ServiceServerMultiError) 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 ServiceServerMultiError) AllErrors() []error { return m } - -// ServiceServerValidationError is the validation error returned by -// ServiceServer.Validate if the designated constraints aren't met. -type ServiceServerValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ServiceServerValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ServiceServerValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ServiceServerValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ServiceServerValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ServiceServerValidationError) ErrorName() string { return "ServiceServerValidationError" } - -// Error satisfies the builtin error interface -func (e ServiceServerValidationError) 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 %sServiceServer.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ServiceServerValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ServiceServerValidationError{} - -// Validate checks the field values on ServiceClient 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 *ServiceClient) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ServiceClient 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 ServiceClientMultiError, or -// nil if none found. -func (m *ServiceClient) ValidateAll() error { - return m.validate(true) -} - -func (m *ServiceClient) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetCore()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceClientValidationError{ - field: "Core", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServiceClientValidationError{ - field: "Core", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCore()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServiceClientValidationError{ - field: "Core", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetServices() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceClientValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServiceClientValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServiceClientValidationError{ - field: fmt.Sprintf("Services[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetMiddleware()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ServiceClientValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ServiceClientValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMiddleware()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ServiceClientValidationError{ - field: "Middleware", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ServiceClientMultiError(errors) - } - - return nil -} - -// ServiceClientMultiError is an error wrapping multiple validation errors -// returned by ServiceClient.ValidateAll() if the designated constraints -// aren't met. -type ServiceClientMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ServiceClientMultiError) 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 ServiceClientMultiError) AllErrors() []error { return m } - -// ServiceClientValidationError is the validation error returned by -// ServiceClient.Validate if the designated constraints aren't met. -type ServiceClientValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ServiceClientValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ServiceClientValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ServiceClientValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ServiceClientValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ServiceClientValidationError) ErrorName() string { return "ServiceClientValidationError" } - -// Error satisfies the builtin error interface -func (e ServiceClientValidationError) 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 %sServiceClient.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ServiceClientValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ServiceClientValidationError{} diff --git a/internal/configs/service.proto b/internal/configs/service.proto deleted file mode 100644 index 88bd191d..00000000 --- a/internal/configs/service.proto +++ /dev/null @@ -1,29 +0,0 @@ -syntax = "proto3"; -package api.configs; - -import "config/v1/discovery.proto"; -import "config/v1/service.proto"; -import "config/v1/storage.proto"; -import "middleware/v1/middleware.proto"; - -option go_package = "origadmin/application/admin/internal/configs"; - -message ServiceCore { - string name = 1 [json_name = "name"]; - string version = 2 [json_name = "version"]; - - config.v1.Discovery discovery = 3 [json_name = "discovery"]; - repeated config.v1.Storage storages = 4 [json_name = "storages"]; -} - -message ServiceServer { - ServiceCore core = 1 [json_name = "core"]; - repeated config.v1.Service services = 200 [json_name = "services"]; - middleware.v1.Middleware middleware = 300 [json_name = "middleware"]; -} - -message ServiceClient { - ServiceCore core = 1 [json_name = "core"]; - repeated config.v1.Service services = 200 [json_name = "services"]; - middleware.v1.Middleware middleware = 300 [json_name = "middleware"]; -} \ No newline at end of file diff --git a/internal/mods/auth/biz/README.md b/internal/features/auth/biz/README.md similarity index 100% rename from internal/mods/auth/biz/README.md rename to internal/features/auth/biz/README.md diff --git a/internal/mods/auth/biz/auth.biz.go b/internal/features/auth/biz/auth.biz.go similarity index 100% rename from internal/mods/auth/biz/auth.biz.go rename to internal/features/auth/biz/auth.biz.go diff --git a/internal/mods/auth/biz/biz.go b/internal/features/auth/biz/biz.go similarity index 100% rename from internal/mods/auth/biz/biz.go rename to internal/features/auth/biz/biz.go diff --git a/internal/mods/auth/biz/casbin.biz.go b/internal/features/auth/biz/casbin.biz.go similarity index 100% rename from internal/mods/auth/biz/casbin.biz.go rename to internal/features/auth/biz/casbin.biz.go diff --git a/internal/mods/auth/biz/casbin_stream.biz.go b/internal/features/auth/biz/casbin_stream.biz.go similarity index 100% rename from internal/mods/auth/biz/casbin_stream.biz.go rename to internal/features/auth/biz/casbin_stream.biz.go diff --git a/internal/mods/auth/biz/login.biz.go b/internal/features/auth/biz/login.biz.go similarity index 100% rename from internal/mods/auth/biz/login.biz.go rename to internal/features/auth/biz/login.biz.go diff --git a/internal/mods/auth/biz/personal.biz.go b/internal/features/auth/biz/personal.biz.go similarity index 100% rename from internal/mods/auth/biz/personal.biz.go rename to internal/features/auth/biz/personal.biz.go diff --git a/internal/mods/auth/biz/provider.go b/internal/features/auth/biz/provider.go similarity index 100% rename from internal/mods/auth/biz/provider.go rename to internal/features/auth/biz/provider.go diff --git a/internal/mods/auth/dal/README.md b/internal/features/auth/dal/README.md similarity index 100% rename from internal/mods/auth/dal/README.md rename to internal/features/auth/dal/README.md diff --git a/internal/mods/auth/dal/auth.dal.go b/internal/features/auth/dal/auth.dal.go similarity index 100% rename from internal/mods/auth/dal/auth.dal.go rename to internal/features/auth/dal/auth.dal.go diff --git a/internal/mods/auth/dal/casbin.dal.go b/internal/features/auth/dal/casbin.dal.go similarity index 100% rename from internal/mods/auth/dal/casbin.dal.go rename to internal/features/auth/dal/casbin.dal.go diff --git a/internal/mods/auth/dal/dal.go b/internal/features/auth/dal/dal.go similarity index 100% rename from internal/mods/auth/dal/dal.go rename to internal/features/auth/dal/dal.go diff --git a/internal/mods/auth/dal/login.dal.go b/internal/features/auth/dal/login.dal.go similarity index 100% rename from internal/mods/auth/dal/login.dal.go rename to internal/features/auth/dal/login.dal.go diff --git a/internal/mods/auth/dal/personal.dal.go b/internal/features/auth/dal/personal.dal.go similarity index 100% rename from internal/mods/auth/dal/personal.dal.go rename to internal/features/auth/dal/personal.dal.go diff --git a/internal/mods/auth/dal/provider.go b/internal/features/auth/dal/provider.go similarity index 100% rename from internal/mods/auth/dal/provider.go rename to internal/features/auth/dal/provider.go diff --git a/internal/mods/auth/dal/user.dal.go b/internal/features/auth/dal/user.dal.go similarity index 100% rename from internal/mods/auth/dal/user.dal.go rename to internal/features/auth/dal/user.dal.go diff --git a/internal/mods/auth/dto/auth.go b/internal/features/auth/dto/auth.go similarity index 100% rename from internal/mods/auth/dto/auth.go rename to internal/features/auth/dto/auth.go diff --git a/internal/mods/auth/dto/casbin.go b/internal/features/auth/dto/casbin.go similarity index 100% rename from internal/mods/auth/dto/casbin.go rename to internal/features/auth/dto/casbin.go diff --git a/internal/mods/auth/dto/dto.go b/internal/features/auth/dto/dto.go similarity index 100% rename from internal/mods/auth/dto/dto.go rename to internal/features/auth/dto/dto.go diff --git a/internal/mods/auth/dto/login.go b/internal/features/auth/dto/login.go similarity index 100% rename from internal/mods/auth/dto/login.go rename to internal/features/auth/dto/login.go diff --git a/internal/mods/auth/dto/personal.go b/internal/features/auth/dto/personal.go similarity index 100% rename from internal/mods/auth/dto/personal.go rename to internal/features/auth/dto/personal.go diff --git a/internal/mods/auth/server/README.md b/internal/features/auth/server/README.md similarity index 100% rename from internal/mods/auth/server/README.md rename to internal/features/auth/server/README.md diff --git a/internal/mods/auth/server/gins.go b/internal/features/auth/server/gins.go similarity index 100% rename from internal/mods/auth/server/gins.go rename to internal/features/auth/server/gins.go diff --git a/internal/mods/auth/server/grpc.go b/internal/features/auth/server/grpc.go similarity index 100% rename from internal/mods/auth/server/grpc.go rename to internal/features/auth/server/grpc.go diff --git a/internal/mods/auth/server/http.go b/internal/features/auth/server/http.go similarity index 100% rename from internal/mods/auth/server/http.go rename to internal/features/auth/server/http.go diff --git a/internal/mods/auth/server/server.go b/internal/features/auth/server/server.go similarity index 100% rename from internal/mods/auth/server/server.go rename to internal/features/auth/server/server.go diff --git a/internal/mods/auth/service/auth.bridge.go b/internal/features/auth/service/auth.bridge.go similarity index 100% rename from internal/mods/auth/service/auth.bridge.go rename to internal/features/auth/service/auth.bridge.go diff --git a/internal/mods/auth/service/auth.grpc.go b/internal/features/auth/service/auth.grpc.go similarity index 100% rename from internal/mods/auth/service/auth.grpc.go rename to internal/features/auth/service/auth.grpc.go diff --git a/internal/mods/auth/service/auth.http.go b/internal/features/auth/service/auth.http.go similarity index 100% rename from internal/mods/auth/service/auth.http.go rename to internal/features/auth/service/auth.http.go diff --git a/internal/mods/auth/service/casbin.bridge.go b/internal/features/auth/service/casbin.bridge.go similarity index 100% rename from internal/mods/auth/service/casbin.bridge.go rename to internal/features/auth/service/casbin.bridge.go diff --git a/internal/mods/auth/service/casbin.go b/internal/features/auth/service/casbin.go similarity index 100% rename from internal/mods/auth/service/casbin.go rename to internal/features/auth/service/casbin.go diff --git a/internal/mods/auth/service/casbin.grpc.go b/internal/features/auth/service/casbin.grpc.go similarity index 100% rename from internal/mods/auth/service/casbin.grpc.go rename to internal/features/auth/service/casbin.grpc.go diff --git a/internal/mods/auth/service/casbin.http.go b/internal/features/auth/service/casbin.http.go similarity index 100% rename from internal/mods/auth/service/casbin.http.go rename to internal/features/auth/service/casbin.http.go diff --git a/internal/mods/auth/service/login.bridge.go b/internal/features/auth/service/login.bridge.go similarity index 100% rename from internal/mods/auth/service/login.bridge.go rename to internal/features/auth/service/login.bridge.go diff --git a/internal/mods/auth/service/login.grpc.go b/internal/features/auth/service/login.grpc.go similarity index 100% rename from internal/mods/auth/service/login.grpc.go rename to internal/features/auth/service/login.grpc.go diff --git a/internal/mods/auth/service/login.http.go b/internal/features/auth/service/login.http.go similarity index 100% rename from internal/mods/auth/service/login.http.go rename to internal/features/auth/service/login.http.go diff --git a/internal/mods/auth/service/personal.bridge.go b/internal/features/auth/service/personal.bridge.go similarity index 100% rename from internal/mods/auth/service/personal.bridge.go rename to internal/features/auth/service/personal.bridge.go diff --git a/internal/mods/auth/service/personal.grpc.go b/internal/features/auth/service/personal.grpc.go similarity index 100% rename from internal/mods/auth/service/personal.grpc.go rename to internal/features/auth/service/personal.grpc.go diff --git a/internal/mods/auth/service/personal.http.go b/internal/features/auth/service/personal.http.go similarity index 100% rename from internal/mods/auth/service/personal.http.go rename to internal/features/auth/service/personal.http.go diff --git a/internal/mods/auth/service/provider.go b/internal/features/auth/service/provider.go similarity index 100% rename from internal/mods/auth/service/provider.go rename to internal/features/auth/service/provider.go diff --git a/internal/mods/auth/service/service.go b/internal/features/auth/service/service.go similarity index 100% rename from internal/mods/auth/service/service.go rename to internal/features/auth/service/service.go diff --git a/internal/mods/datastore/biz/README.md b/internal/features/datastore/biz/README.md similarity index 100% rename from internal/mods/datastore/biz/README.md rename to internal/features/datastore/biz/README.md diff --git a/internal/mods/datastore/biz/biz.go b/internal/features/datastore/biz/biz.go similarity index 100% rename from internal/mods/datastore/biz/biz.go rename to internal/features/datastore/biz/biz.go diff --git a/internal/mods/datastore/biz/datastore.go b/internal/features/datastore/biz/datastore.go similarity index 100% rename from internal/mods/datastore/biz/datastore.go rename to internal/features/datastore/biz/datastore.go diff --git a/internal/mods/datastore/biz/provider.go b/internal/features/datastore/biz/provider.go similarity index 100% rename from internal/mods/datastore/biz/provider.go rename to internal/features/datastore/biz/provider.go diff --git a/internal/mods/datastore/dal/README.md b/internal/features/datastore/dal/README.md similarity index 100% rename from internal/mods/datastore/dal/README.md rename to internal/features/datastore/dal/README.md diff --git a/internal/mods/datastore/dal/dal.go b/internal/features/datastore/dal/dal.go similarity index 100% rename from internal/mods/datastore/dal/dal.go rename to internal/features/datastore/dal/dal.go diff --git a/internal/mods/datastore/dal/menu.dal.go b/internal/features/datastore/dal/menu.dal.go similarity index 100% rename from internal/mods/datastore/dal/menu.dal.go rename to internal/features/datastore/dal/menu.dal.go diff --git a/internal/mods/datastore/dal/permission.dal.go b/internal/features/datastore/dal/permission.dal.go similarity index 100% rename from internal/mods/datastore/dal/permission.dal.go rename to internal/features/datastore/dal/permission.dal.go diff --git a/internal/mods/datastore/dal/provider.go b/internal/features/datastore/dal/provider.go similarity index 100% rename from internal/mods/datastore/dal/provider.go rename to internal/features/datastore/dal/provider.go diff --git a/internal/mods/datastore/dal/resource.dal.go b/internal/features/datastore/dal/resource.dal.go similarity index 100% rename from internal/mods/datastore/dal/resource.dal.go rename to internal/features/datastore/dal/resource.dal.go diff --git a/internal/mods/datastore/dal/role.dal.go b/internal/features/datastore/dal/role.dal.go similarity index 100% rename from internal/mods/datastore/dal/role.dal.go rename to internal/features/datastore/dal/role.dal.go diff --git a/internal/mods/datastore/dal/user.dal.go b/internal/features/datastore/dal/user.dal.go similarity index 100% rename from internal/mods/datastore/dal/user.dal.go rename to internal/features/datastore/dal/user.dal.go diff --git a/internal/mods/datastore/dto/README.md b/internal/features/datastore/dto/README.md similarity index 100% rename from internal/mods/datastore/dto/README.md rename to internal/features/datastore/dto/README.md diff --git a/internal/mods/datastore/dto/department.go b/internal/features/datastore/dto/department.go similarity index 100% rename from internal/mods/datastore/dto/department.go rename to internal/features/datastore/dto/department.go diff --git a/internal/mods/datastore/dto/dto.go b/internal/features/datastore/dto/dto.go similarity index 100% rename from internal/mods/datastore/dto/dto.go rename to internal/features/datastore/dto/dto.go diff --git a/internal/mods/datastore/dto/menu.go b/internal/features/datastore/dto/menu.go similarity index 100% rename from internal/mods/datastore/dto/menu.go rename to internal/features/datastore/dto/menu.go diff --git a/internal/mods/datastore/dto/permission.go b/internal/features/datastore/dto/permission.go similarity index 100% rename from internal/mods/datastore/dto/permission.go rename to internal/features/datastore/dto/permission.go diff --git a/internal/mods/datastore/dto/position.go b/internal/features/datastore/dto/position.go similarity index 100% rename from internal/mods/datastore/dto/position.go rename to internal/features/datastore/dto/position.go diff --git a/internal/mods/datastore/dto/resource.go b/internal/features/datastore/dto/resource.go similarity index 100% rename from internal/mods/datastore/dto/resource.go rename to internal/features/datastore/dto/resource.go diff --git a/internal/mods/datastore/dto/resource_type.go b/internal/features/datastore/dto/resource_type.go similarity index 100% rename from internal/mods/datastore/dto/resource_type.go rename to internal/features/datastore/dto/resource_type.go diff --git a/internal/mods/datastore/dto/role.go b/internal/features/datastore/dto/role.go similarity index 100% rename from internal/mods/datastore/dto/role.go rename to internal/features/datastore/dto/role.go diff --git a/internal/mods/datastore/dto/user.go b/internal/features/datastore/dto/user.go similarity index 100% rename from internal/mods/datastore/dto/user.go rename to internal/features/datastore/dto/user.go diff --git a/internal/mods/datastore/server/README.md b/internal/features/datastore/server/README.md similarity index 100% rename from internal/mods/datastore/server/README.md rename to internal/features/datastore/server/README.md diff --git a/internal/mods/datastore/server/gins.go b/internal/features/datastore/server/gins.go similarity index 100% rename from internal/mods/datastore/server/gins.go rename to internal/features/datastore/server/gins.go diff --git a/internal/mods/datastore/server/grpc.go b/internal/features/datastore/server/grpc.go similarity index 100% rename from internal/mods/datastore/server/grpc.go rename to internal/features/datastore/server/grpc.go diff --git a/internal/mods/datastore/server/http.go b/internal/features/datastore/server/http.go similarity index 100% rename from internal/mods/datastore/server/http.go rename to internal/features/datastore/server/http.go diff --git a/internal/mods/datastore/server/server.go b/internal/features/datastore/server/server.go similarity index 100% rename from internal/mods/datastore/server/server.go rename to internal/features/datastore/server/server.go diff --git a/internal/mods/datastore/service/README.md b/internal/features/datastore/service/README.md similarity index 100% rename from internal/mods/datastore/service/README.md rename to internal/features/datastore/service/README.md diff --git a/internal/mods/datastore/service/menu.bridge.go b/internal/features/datastore/service/menu.bridge.go similarity index 100% rename from internal/mods/datastore/service/menu.bridge.go rename to internal/features/datastore/service/menu.bridge.go diff --git a/internal/mods/datastore/service/menu.grpc.go b/internal/features/datastore/service/menu.grpc.go similarity index 100% rename from internal/mods/datastore/service/menu.grpc.go rename to internal/features/datastore/service/menu.grpc.go diff --git a/internal/mods/datastore/service/menu.http.go b/internal/features/datastore/service/menu.http.go similarity index 100% rename from internal/mods/datastore/service/menu.http.go rename to internal/features/datastore/service/menu.http.go diff --git a/internal/mods/datastore/service/permission.bridge.go b/internal/features/datastore/service/permission.bridge.go similarity index 100% rename from internal/mods/datastore/service/permission.bridge.go rename to internal/features/datastore/service/permission.bridge.go diff --git a/internal/mods/datastore/service/permission.grpc.go b/internal/features/datastore/service/permission.grpc.go similarity index 100% rename from internal/mods/datastore/service/permission.grpc.go rename to internal/features/datastore/service/permission.grpc.go diff --git a/internal/mods/datastore/service/permission.http.go b/internal/features/datastore/service/permission.http.go similarity index 100% rename from internal/mods/datastore/service/permission.http.go rename to internal/features/datastore/service/permission.http.go diff --git a/internal/mods/datastore/service/provider.go b/internal/features/datastore/service/provider.go similarity index 100% rename from internal/mods/datastore/service/provider.go rename to internal/features/datastore/service/provider.go diff --git a/internal/mods/datastore/service/resource.bridge.go b/internal/features/datastore/service/resource.bridge.go similarity index 100% rename from internal/mods/datastore/service/resource.bridge.go rename to internal/features/datastore/service/resource.bridge.go diff --git a/internal/mods/datastore/service/resource.grpc.go b/internal/features/datastore/service/resource.grpc.go similarity index 100% rename from internal/mods/datastore/service/resource.grpc.go rename to internal/features/datastore/service/resource.grpc.go diff --git a/internal/mods/datastore/service/resource.http.go b/internal/features/datastore/service/resource.http.go similarity index 100% rename from internal/mods/datastore/service/resource.http.go rename to internal/features/datastore/service/resource.http.go diff --git a/internal/mods/datastore/service/role.bridge.go b/internal/features/datastore/service/role.bridge.go similarity index 100% rename from internal/mods/datastore/service/role.bridge.go rename to internal/features/datastore/service/role.bridge.go diff --git a/internal/mods/datastore/service/role.grpc.go b/internal/features/datastore/service/role.grpc.go similarity index 100% rename from internal/mods/datastore/service/role.grpc.go rename to internal/features/datastore/service/role.grpc.go diff --git a/internal/mods/datastore/service/role.http.go b/internal/features/datastore/service/role.http.go similarity index 100% rename from internal/mods/datastore/service/role.http.go rename to internal/features/datastore/service/role.http.go diff --git a/internal/mods/datastore/service/service.go b/internal/features/datastore/service/service.go similarity index 100% rename from internal/mods/datastore/service/service.go rename to internal/features/datastore/service/service.go diff --git a/internal/mods/datastore/service/user.bridge.go b/internal/features/datastore/service/user.bridge.go similarity index 100% rename from internal/mods/datastore/service/user.bridge.go rename to internal/features/datastore/service/user.bridge.go diff --git a/internal/mods/datastore/service/user.grpc.go b/internal/features/datastore/service/user.grpc.go similarity index 100% rename from internal/mods/datastore/service/user.grpc.go rename to internal/features/datastore/service/user.grpc.go diff --git a/internal/mods/datastore/service/user.http.go b/internal/features/datastore/service/user.http.go similarity index 100% rename from internal/mods/datastore/service/user.http.go rename to internal/features/datastore/service/user.http.go diff --git a/internal/mods/system/biz/README.md b/internal/features/system/biz/README.md similarity index 100% rename from internal/mods/system/biz/README.md rename to internal/features/system/biz/README.md diff --git a/internal/mods/system/biz/biz.go b/internal/features/system/biz/biz.go similarity index 100% rename from internal/mods/system/biz/biz.go rename to internal/features/system/biz/biz.go diff --git a/internal/mods/system/biz/permission.biz.go b/internal/features/system/biz/permission.biz.go similarity index 100% rename from internal/mods/system/biz/permission.biz.go rename to internal/features/system/biz/permission.biz.go diff --git a/internal/mods/system/biz/provider.go b/internal/features/system/biz/provider.go similarity index 100% rename from internal/mods/system/biz/provider.go rename to internal/features/system/biz/provider.go diff --git a/internal/mods/system/biz/resource.biz.go b/internal/features/system/biz/resource.biz.go similarity index 100% rename from internal/mods/system/biz/resource.biz.go rename to internal/features/system/biz/resource.biz.go diff --git a/internal/mods/system/biz/role.biz.go b/internal/features/system/biz/role.biz.go similarity index 100% rename from internal/mods/system/biz/role.biz.go rename to internal/features/system/biz/role.biz.go diff --git a/internal/mods/system/biz/user.biz.go b/internal/features/system/biz/user.biz.go similarity index 100% rename from internal/mods/system/biz/user.biz.go rename to internal/features/system/biz/user.biz.go diff --git a/internal/mods/system/dal/README.md b/internal/features/system/dal/README.md similarity index 100% rename from internal/mods/system/dal/README.md rename to internal/features/system/dal/README.md diff --git a/internal/mods/system/dal/dal.go b/internal/features/system/dal/dal.go similarity index 100% rename from internal/mods/system/dal/dal.go rename to internal/features/system/dal/dal.go diff --git a/internal/mods/system/dal/menu.dal.go b/internal/features/system/dal/menu.dal.go similarity index 100% rename from internal/mods/system/dal/menu.dal.go rename to internal/features/system/dal/menu.dal.go diff --git a/internal/mods/system/dal/permission.dal.go b/internal/features/system/dal/permission.dal.go similarity index 100% rename from internal/mods/system/dal/permission.dal.go rename to internal/features/system/dal/permission.dal.go diff --git a/internal/mods/system/dal/provider.go b/internal/features/system/dal/provider.go similarity index 100% rename from internal/mods/system/dal/provider.go rename to internal/features/system/dal/provider.go diff --git a/internal/mods/system/dal/resource.dal.go b/internal/features/system/dal/resource.dal.go similarity index 100% rename from internal/mods/system/dal/resource.dal.go rename to internal/features/system/dal/resource.dal.go diff --git a/internal/mods/system/dal/role.dal.go b/internal/features/system/dal/role.dal.go similarity index 100% rename from internal/mods/system/dal/role.dal.go rename to internal/features/system/dal/role.dal.go diff --git a/internal/mods/system/dal/user.dal.go b/internal/features/system/dal/user.dal.go similarity index 100% rename from internal/mods/system/dal/user.dal.go rename to internal/features/system/dal/user.dal.go diff --git a/internal/mods/system/dto/README.md b/internal/features/system/dto/README.md similarity index 100% rename from internal/mods/system/dto/README.md rename to internal/features/system/dto/README.md diff --git a/internal/mods/system/dto/department.go b/internal/features/system/dto/department.go similarity index 100% rename from internal/mods/system/dto/department.go rename to internal/features/system/dto/department.go diff --git a/internal/mods/system/dto/dto.go b/internal/features/system/dto/dto.go similarity index 100% rename from internal/mods/system/dto/dto.go rename to internal/features/system/dto/dto.go diff --git a/internal/mods/system/dto/menu.go b/internal/features/system/dto/menu.go similarity index 100% rename from internal/mods/system/dto/menu.go rename to internal/features/system/dto/menu.go diff --git a/internal/mods/system/dto/permission.go b/internal/features/system/dto/permission.go similarity index 100% rename from internal/mods/system/dto/permission.go rename to internal/features/system/dto/permission.go diff --git a/internal/mods/system/dto/position.go b/internal/features/system/dto/position.go similarity index 100% rename from internal/mods/system/dto/position.go rename to internal/features/system/dto/position.go diff --git a/internal/mods/system/dto/resource.go b/internal/features/system/dto/resource.go similarity index 100% rename from internal/mods/system/dto/resource.go rename to internal/features/system/dto/resource.go diff --git a/internal/mods/system/dto/resource_type.go b/internal/features/system/dto/resource_type.go similarity index 100% rename from internal/mods/system/dto/resource_type.go rename to internal/features/system/dto/resource_type.go diff --git a/internal/mods/system/dto/role.go b/internal/features/system/dto/role.go similarity index 100% rename from internal/mods/system/dto/role.go rename to internal/features/system/dto/role.go diff --git a/internal/mods/system/dto/user.go b/internal/features/system/dto/user.go similarity index 100% rename from internal/mods/system/dto/user.go rename to internal/features/system/dto/user.go diff --git a/internal/mods/system/server/README.md b/internal/features/system/server/README.md similarity index 100% rename from internal/mods/system/server/README.md rename to internal/features/system/server/README.md diff --git a/internal/mods/system/server/gins.go b/internal/features/system/server/gins.go similarity index 100% rename from internal/mods/system/server/gins.go rename to internal/features/system/server/gins.go diff --git a/internal/mods/system/server/grpc.go b/internal/features/system/server/grpc.go similarity index 100% rename from internal/mods/system/server/grpc.go rename to internal/features/system/server/grpc.go diff --git a/internal/mods/system/server/http.go b/internal/features/system/server/http.go similarity index 100% rename from internal/mods/system/server/http.go rename to internal/features/system/server/http.go diff --git a/internal/mods/system/server/server.go b/internal/features/system/server/server.go similarity index 100% rename from internal/mods/system/server/server.go rename to internal/features/system/server/server.go diff --git a/internal/mods/system/service/README.md b/internal/features/system/service/README.md similarity index 100% rename from internal/mods/system/service/README.md rename to internal/features/system/service/README.md diff --git a/internal/mods/system/service/menu.bridge.go b/internal/features/system/service/menu.bridge.go similarity index 100% rename from internal/mods/system/service/menu.bridge.go rename to internal/features/system/service/menu.bridge.go diff --git a/internal/mods/system/service/menu.grpc.go b/internal/features/system/service/menu.grpc.go similarity index 100% rename from internal/mods/system/service/menu.grpc.go rename to internal/features/system/service/menu.grpc.go diff --git a/internal/mods/system/service/menu.http.go b/internal/features/system/service/menu.http.go similarity index 100% rename from internal/mods/system/service/menu.http.go rename to internal/features/system/service/menu.http.go diff --git a/internal/mods/system/service/permission.bridge.go b/internal/features/system/service/permission.bridge.go similarity index 100% rename from internal/mods/system/service/permission.bridge.go rename to internal/features/system/service/permission.bridge.go diff --git a/internal/mods/system/service/permission.grpc.go b/internal/features/system/service/permission.grpc.go similarity index 100% rename from internal/mods/system/service/permission.grpc.go rename to internal/features/system/service/permission.grpc.go diff --git a/internal/mods/system/service/permission.http.go b/internal/features/system/service/permission.http.go similarity index 100% rename from internal/mods/system/service/permission.http.go rename to internal/features/system/service/permission.http.go diff --git a/internal/mods/system/service/provider.go b/internal/features/system/service/provider.go similarity index 100% rename from internal/mods/system/service/provider.go rename to internal/features/system/service/provider.go diff --git a/internal/mods/system/service/resource.bridge.go b/internal/features/system/service/resource.bridge.go similarity index 100% rename from internal/mods/system/service/resource.bridge.go rename to internal/features/system/service/resource.bridge.go diff --git a/internal/mods/system/service/resource.grpc.go b/internal/features/system/service/resource.grpc.go similarity index 100% rename from internal/mods/system/service/resource.grpc.go rename to internal/features/system/service/resource.grpc.go diff --git a/internal/mods/system/service/resource.http.go b/internal/features/system/service/resource.http.go similarity index 100% rename from internal/mods/system/service/resource.http.go rename to internal/features/system/service/resource.http.go diff --git a/internal/mods/system/service/role.bridge.go b/internal/features/system/service/role.bridge.go similarity index 100% rename from internal/mods/system/service/role.bridge.go rename to internal/features/system/service/role.bridge.go diff --git a/internal/mods/system/service/role.grpc.go b/internal/features/system/service/role.grpc.go similarity index 100% rename from internal/mods/system/service/role.grpc.go rename to internal/features/system/service/role.grpc.go diff --git a/internal/mods/system/service/role.http.go b/internal/features/system/service/role.http.go similarity index 100% rename from internal/mods/system/service/role.http.go rename to internal/features/system/service/role.http.go diff --git a/internal/mods/system/service/service.go b/internal/features/system/service/service.go similarity index 100% rename from internal/mods/system/service/service.go rename to internal/features/system/service/service.go diff --git a/internal/mods/system/service/user.bridge.go b/internal/features/system/service/user.bridge.go similarity index 100% rename from internal/mods/system/service/user.bridge.go rename to internal/features/system/service/user.bridge.go diff --git a/internal/mods/system/service/user.grpc.go b/internal/features/system/service/user.grpc.go similarity index 100% rename from internal/mods/system/service/user.grpc.go rename to internal/features/system/service/user.grpc.go diff --git a/internal/mods/system/service/user.http.go b/internal/features/system/service/user.http.go similarity index 100% rename from internal/mods/system/service/user.http.go rename to internal/features/system/service/user.http.go diff --git a/internal/mods/gateway/proxy.go b/internal/gateway/proxy.go similarity index 100% rename from internal/mods/gateway/proxy.go rename to internal/gateway/proxy.go diff --git a/internal/generate.go b/internal/generate.go index 6487238b..6869ff47 100644 --- a/internal/generate.go +++ b/internal/generate.go @@ -11,5 +11,5 @@ package internal //=paths=source_relative:. outputs to the same directory with the proto file // uncomment this line to generate the client code to the same directory -//go:generate protoc -I. -I../third_party --go_out=paths=source_relative:../internal ./configs/*.proto -//go:generate protoc -I. -I../third_party --validate_out=paths=source_relative,lang=go:../internal ./configs/*.proto +//go:generate protoc -I. -I../third_party --go_out=paths=source_relative:../internal ./conf/pb/*.proto +//go:generate protoc -I. -I../third_party --validate_out=paths=source_relative,lang=go:../internal ./conf/pb/*.proto diff --git a/helpers/base64image/base64image.go b/internal/helpers/base64image/base64image.go similarity index 100% rename from helpers/base64image/base64image.go rename to internal/helpers/base64image/base64image.go diff --git a/helpers/base64image/base64image_test.go b/internal/helpers/base64image/base64image_test.go similarity index 100% rename from helpers/base64image/base64image_test.go rename to internal/helpers/base64image/base64image_test.go diff --git a/helpers/captcha/captcha.go b/internal/helpers/captcha/captcha.go similarity index 100% rename from helpers/captcha/captcha.go rename to internal/helpers/captcha/captcha.go diff --git a/helpers/command/lower.go b/internal/helpers/command/lower.go similarity index 100% rename from helpers/command/lower.go rename to internal/helpers/command/lower.go diff --git a/helpers/db/db.go b/internal/helpers/db/db.go similarity index 100% rename from helpers/db/db.go rename to internal/helpers/db/db.go diff --git a/helpers/ent/mixin/field.go b/internal/helpers/ent/mixin/field.go similarity index 100% rename from helpers/ent/mixin/field.go rename to internal/helpers/ent/mixin/field.go diff --git a/helpers/ent/mixin/mixin.go b/internal/helpers/ent/mixin/mixin.go similarity index 100% rename from helpers/ent/mixin/mixin.go rename to internal/helpers/ent/mixin/mixin.go diff --git a/helpers/ent/mixin/mixin_id.go b/internal/helpers/ent/mixin/mixin_id.go similarity index 100% rename from helpers/ent/mixin/mixin_id.go rename to internal/helpers/ent/mixin/mixin_id.go diff --git a/helpers/ent/mixin/mixin_uuid.go b/internal/helpers/ent/mixin/mixin_uuid.go similarity index 100% rename from helpers/ent/mixin/mixin_uuid.go rename to internal/helpers/ent/mixin/mixin_uuid.go diff --git a/helpers/ent/size.go b/internal/helpers/ent/size.go similarity index 100% rename from helpers/ent/size.go rename to internal/helpers/ent/size.go diff --git a/helpers/errors/config.go b/internal/helpers/errors/config.go similarity index 100% rename from helpers/errors/config.go rename to internal/helpers/errors/config.go diff --git a/helpers/errors/errors.go b/internal/helpers/errors/errors.go similarity index 100% rename from helpers/errors/errors.go rename to internal/helpers/errors/errors.go diff --git a/helpers/errors/start.go b/internal/helpers/errors/start.go similarity index 100% rename from helpers/errors/start.go rename to internal/helpers/errors/start.go diff --git a/helpers/generic/convert.go b/internal/helpers/generic/convert.go similarity index 100% rename from helpers/generic/convert.go rename to internal/helpers/generic/convert.go diff --git a/helpers/i18n/i18n.go b/internal/helpers/i18n/i18n.go similarity index 100% rename from helpers/i18n/i18n.go rename to internal/helpers/i18n/i18n.go diff --git a/helpers/i18n/i18n_test.go b/internal/helpers/i18n/i18n_test.go similarity index 100% rename from helpers/i18n/i18n_test.go rename to internal/helpers/i18n/i18n_test.go diff --git a/helpers/id/gen.go b/internal/helpers/id/gen.go similarity index 100% rename from helpers/id/gen.go rename to internal/helpers/id/gen.go diff --git a/helpers/protobuf/duration/duration.go b/internal/helpers/protobuf/duration/duration.go similarity index 100% rename from helpers/protobuf/duration/duration.go rename to internal/helpers/protobuf/duration/duration.go diff --git a/helpers/resp/data/v1/data.pb.go b/internal/helpers/resp/data/v1/data.pb.go similarity index 100% rename from helpers/resp/data/v1/data.pb.go rename to internal/helpers/resp/data/v1/data.pb.go diff --git a/helpers/resp/data/v1/data.proto b/internal/helpers/resp/data/v1/data.proto similarity index 100% rename from helpers/resp/data/v1/data.proto rename to internal/helpers/resp/data/v1/data.proto diff --git a/helpers/resp/error.go b/internal/helpers/resp/error.go similarity index 100% rename from helpers/resp/error.go rename to internal/helpers/resp/error.go diff --git a/helpers/resp/marshal.go b/internal/helpers/resp/marshal.go similarity index 100% rename from helpers/resp/marshal.go rename to internal/helpers/resp/marshal.go diff --git a/helpers/resp/resp.go b/internal/helpers/resp/resp.go similarity index 100% rename from helpers/resp/resp.go rename to internal/helpers/resp/resp.go diff --git a/helpers/resp/result.go b/internal/helpers/resp/result.go similarity index 100% rename from helpers/resp/result.go rename to internal/helpers/resp/result.go diff --git a/helpers/securityx/auth.go b/internal/helpers/securityx/auth.go similarity index 100% rename from helpers/securityx/auth.go rename to internal/helpers/securityx/auth.go diff --git a/helpers/securityx/security.go b/internal/helpers/securityx/security.go similarity index 100% rename from helpers/securityx/security.go rename to internal/helpers/securityx/security.go diff --git a/helpers/securityx/user.go b/internal/helpers/securityx/user.go similarity index 100% rename from helpers/securityx/user.go rename to internal/helpers/securityx/user.go diff --git a/helpers/time/time.go b/internal/helpers/time/time.go similarity index 100% rename from helpers/time/time.go rename to internal/helpers/time/time.go diff --git a/internal/loader/application.go b/internal/loader/application.go deleted file mode 100644 index 03b572e8..00000000 --- a/internal/loader/application.go +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -// -//func NewApp(ctx context.Context, injector *InjectorClient) *kratos.App { -// opts := []kratos.Option{ -// kratos.ID(flags.ServiceID()), -// kratos.Name(flags.ServiceName()), -// kratos.Version(flags.Version()), -// kratos.Metadata(map[string]string{}), -// kratos.Context(ctx), -// kratos.Signal(syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT), -// kratos.Logger(injector.Logger), -// kratos.Server(injector.Server), -// } -// -// if flags.Env() == "release" { -// gin.SetMode(gin.ReleaseMode) -// } -// -// gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) { -// log.Infow("msg", "GIN route", "method", httpMethod, "path", absolutePath, "operation", handlerName, "handlers", nuHandlers) -// } -// -// return kratos.New(opts...) -//} diff --git a/internal/loader/bootstrap.go b/internal/loader/bootstrap.go deleted file mode 100644 index 323d4471..00000000 --- a/internal/loader/bootstrap.go +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "context" - "fmt" - - "github.com/go-kratos/kratos/v2" - "github.com/go-kratos/kratos/v2/middleware/tracing" - "github.com/goexts/generic/cmp" - "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - middlewarev1 "github.com/origadmin/runtime/api/gen/go/middleware/v1" - "github.com/origadmin/runtime/bootstrap" - "github.com/origadmin/runtime/config" - "github.com/origadmin/runtime/log" - - "origadmin/application/admin/internal/configs" -) - -type NewApp func(runtime.Runtime, *configs.Bootstrap) (*kratos.App, func(), error) - -func Resolve(config config.KConfig) (config.Resolved, error) { - rb := &ResolvedBootstrap{ - bootstrap: DefaultBootstrap(), - } - if err := config.Load(); err != nil { - return nil, err - } - if err := config.Scan(rb.bootstrap); err != nil { - return nil, err - } - return rb, nil -} - -type BootstrapConfig func(config config.KConfig) (config.Resolved, error) - -func (b BootstrapConfig) Resolve(config config.KConfig) (config.Resolved, error) { - return b(config) -} - -type ResolvedBootstrap struct { - bootstrap *configs.Bootstrap -} - -func (r *ResolvedBootstrap) FillServiceInfo(flags *bootstrap.Bootstrap) { - core := r.bootstrap.GetServer().GetCore() - name := cmp.Or(flags.ServiceName(), core.GetName()) - version := cmp.Or(flags.Version(), core.GetVersion()) - flags.SetServiceInfo(name, version) -} - -func (r *ResolvedBootstrap) Discovery() *configv1.Discovery { - log.NewHelper(log.GetLogger()).Infow("msg", "discovery config", "value", r.bootstrap.GetDiscovery()) - return r.bootstrap.GetDiscovery() -} - -func (r *ResolvedBootstrap) Resolve(config config.KConfig) (config.Resolved, error) { - if err := config.Scan(r.bootstrap); err != nil { - return nil, err - } - return r, nil -} - -func (r *ResolvedBootstrap) WithDecode(name string, v any, decode func([]byte, any) error) error { - if decode == nil { - return fmt.Errorf("decode function is nil") - } - return nil -} - -func (r *ResolvedBootstrap) Value(name string) (any, error) { - switch name { - - default: - return nil, fmt.Errorf("unknown config name: %s", name) - } - -} - -func (r *ResolvedBootstrap) Middleware() *middlewarev1.Middleware { - return r.bootstrap.GetMiddleware() -} - -func (r *ResolvedBootstrap) Services() []*configv1.Service { - return r.bootstrap.GetServer().GetServices() -} - -func (r *ResolvedBootstrap) Logger() *configv1.Logger { - return r.bootstrap.GetLogger() -} - -func Bootstrap(ctx context.Context, flags *bootstrap.Bootstrap, newApp NewApp) error { - rb := &ResolvedBootstrap{ - bootstrap: DefaultBootstrap(), - } - r, err := runtime.Load(flags, runtime.WithResolver(rb), runtime.WithContext(ctx)) - if err != nil { - return err - } - rb.FillServiceInfo(flags) - r = r.WithLoggerAttrs( - "ts", log.DefaultTimestamp, - "caller", log.DefaultCaller, - "service.id", flags.ServiceID(), - "service.name", flags.ServiceName(), - "service.version", flags.Version(), - "trace.id", tracing.TraceID(), - "span.id", tracing.SpanID(), - ) - app, clean, err := newApp(r, rb.bootstrap) - if err != nil { - return err - } - defer clean() - if err := app.Run(); err != nil { - return err - } - return nil -} diff --git a/internal/loader/bootstrap_default.go b/internal/loader/bootstrap_default.go deleted file mode 100644 index 62a2379f..00000000 --- a/internal/loader/bootstrap_default.go +++ /dev/null @@ -1,452 +0,0 @@ -package loader - -import ( - "time" - - // configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" // REMOVE - middlewarev1 "github.com/origadmin/runtime/api/gen/go/middleware/v1" - jwtv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/jwt" - "github.com/origadmin/runtime/api/gen/go/middleware/v1/metrics" - "github.com/origadmin/runtime/api/gen/go/middleware/v1/ratelimit" - "github.com/origadmin/runtime/api/gen/go/middleware/v1/selector" - "github.com/origadmin/runtime/api/gen/go/middleware/v1/validator" - sjwtv1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" - securityv1 "github.com/origadmin/runtime/api/gen/go/security/transport/v1" // ADD for TLSConfig - transportv1 "github.com/origadmin/runtime/api/gen/go/transport/v1" // ADD - - "origadmin/application/admin/internal/configs" - "google.golang.org/protobuf/types/known/durationpb" -) - -const ( - SigningKey = "%VH_C!Vpa$_aK2kOynB&q+x=4$27&Ios" -) - -func DefaultBootstrap() *configs.Bootstrap { - return &configs.Bootstrap{ - Name: "origadmin.service.admin.v1", - Mode: "singleton", - Version: "v1.0.0", - CryptoType: "argon2", - //Servers: map[string]string{ - // systemserver.ServiceName: "origadmin.service.system.v1", - //}, - Id: "", - Entry: &configs.Bootstrap_Entry{ - Scheme: "http", - Services: DefaultServices(), // This will cause a type mismatch after this change - Cors: DefaultEntryCors(), - }, - Server: &configs.ServiceServer{ - Services: DefaultServices(), // This will cause a type mismatch after this change - Middleware: DefaultServiceMiddleware(), - }, - Clients: DefaultServiceClients(), - Logger: DefaultLogger(), - Storage: DefaultStorage(), - Discovery: DefaultDiscovery(), - Middleware: DefaultServiceMiddleware(), - Security: &configs.SecurityConfig{ - RootUser: DefaultRootUser(), - Captcha: DefaultCaptcha(), - Security: &configs.Security{ - PublicPaths: []string{ - "/swagger/*", - "/api/v1/health", - "/api/v1/health/*", - "/api/v1/captcha", - "/api/v1/captcha/*", - "/api/v1/login", - "/api/v1/register", - "/api/v1/current/logout", - "/api/v1/refresh_token", - "/api.v1.services.system.LoginAPI/CaptchaId", - "/api.v1.services.system.LoginAPI/CaptchaImage", - "/api.v1.services.system.LoginAPI/CaptchaResource", - "/api.v1.services.system.LoginAPI/CaptchaResources", - "/api.v1.services.system.LoginAPI/Login", - "/api.v1.services.system.LoginAPI/Register", - "/api.v1.services.system.LoginAPI/Refresh", - //"/api.v1.services.basis.LoginAPI/Logout", - //"/api.v1.services.basis.LoginAPI/CurrentUser", - //"/api.v1.services.basis.LoginAPI/CurrentMenus", - }, - Authz: &configs.AuthZConfig{ - Disabled: false, - PublicPaths: nil, - Type: "casbin", - Casbin: &configs.AuthZConfig_CasbinConfig{ - PolicyFile: "", - ModelFile: "", - }, - Opa: nil, - Zanzibar: nil, - }, - Authn: &configs.AuthNConfig{ - Disabled: false, - Type: "jwt", - Jwt: &configs.AuthNConfig_JWTConfig{ - Algorithm: "HS512", - SigningKey: SigningKey, - OldSigningKey: "", - ExpireTime: 0, // use default - RefreshTime: 0, // use default - CacheName: "", - }, - }, - }, - }, - } -} - -func DefaultEntryCors() *configs.Cors { - return &configs.Cors{ - AllowOrigins: []string{"*"}, - AllowMethods: []string{"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS"}, - AllowHeaders: []string{"X-Requested-With", "Content-Type", "Authorization"}, - ExposeHeaders: []string{"*"}, - AllowCredentials: false, - MaxAge: 0, - } -} - -func DefaultServices() []*configs.Service { - return []*configs.Service{ - { - Name: "", - DynamicEndpoint: true, - Type: "grpc", - Grpc: DefaultServiceGrpc(), // This will cause a type mismatch - Websocket: DefaultServiceWebsocket(), - Message: DefaultServiceMessage(), - Task: DefaultServiceTask(), - //Middleware: DefaultServiceMiddleware(), - Selector: &configs.Service_Selector{ - Version: "v1.0.0", - Builder: "bbr", - }, - }, - { - Name: "", - DynamicEndpoint: true, - Type: "http", - Http: DefaultServiceHttp(), // This will cause a type mismatch - Websocket: DefaultServiceWebsocket(), - Message: DefaultServiceMessage(), - Task: DefaultServiceTask(), - //Middleware: DefaultServiceMiddleware(), - Selector: &configs.Service_Selector{ - Version: "v1.0.0", - Builder: "bbr", - }, - }, - } -} - -func DefaultServiceClients() []*configs.ServiceClient { - serviceNames := map[string]string{ - "system": "origadmin.service.system.v1", - "auth": "origadmin.service.auth.v1", - } - clients := make([]*configs.ServiceClient, 0, len(serviceNames)) - for name, serviceName := range serviceNames { - core := &configs.ServiceCore{ - Name: name, - Discovery: DefaultDiscovery(), - } - core.Discovery.ServiceName = serviceName - clients = append(clients, &configs.ServiceClient{ - Core: core, - Services: DefaultServices(), // This will cause a type mismatch after this change - Middleware: DefaultServiceMiddleware(), - }) - } - return clients -} - -func DefaultLogger() *configs.Logger { - return &configs.Logger{ - Disabled: false, - Develop: true, - Default: true, - Name: "output.log", - Format: "json", - Level: "info", - Stdout: true, - DisableCaller: false, - CallerSkip: 0, - TimeFormat: "", - File: &configs.Logger_File{ - Path: "logs", - Lumberjack: true, - Compress: false, - LocalTime: false, - MaxSize: 0, - MaxAge: 0, - MaxBackups: 0, - }, - DevLogger: nil, - } -} - -func DefaultServiceWebsocket() *configs.WebSocket { - return &configs.WebSocket{ - Addr: "", - Path: "", - } -} - -func DefaultStorage() *configs.Storage { - return &configs.Storage{ - Name: "", - Type: "", - Database: &configs.Database{ - Debug: false, - Dialect: "sqlite3", - Source: "data/admin.db", - Migration: &configs.Migration{ - Enabled: false, - Path: "", - Names: nil, - Version: "", - Mode: "", - }, - EnableTrace: false, - EnableMetrics: false, - MaxIdleConnections: 0, - MaxOpenConnections: 0, - ConnectionMaxLifetime: 0, - ConnectionMaxIdleTime: 0, - }, - Cache: &configs.Cache{ - Driver: "memory", //["none", "redis", "memcached", "memory"] [string.in] - Memcached: &configs.Memcached{ - Addr: "", - Username: "", - Password: "", - MaxIdle: 0, - Timeout: 0, - }, - Memory: &configs.Memory{ - Size: 0, - Capacity: 0, - Expiration: 0, - CleanupInterval: 0, - }, - Redis: &configs.Redis{ - Network: "", - Addr: "", - Password: "", - Db: 0, - DialTimeout: 0, - ReadTimeout: 0, - WriteTimeout: 0, - }, - Badger: &configs.BadgerDS{ - Path: "", - SyncWrites: false, - ValueLogFileSize: 0, - LogLevel: 0, - }, - }, - File: nil, - Redis: nil, - Badger: nil, - Mongo: nil, - Oss: nil, - } -} - -func DefaultServiceTask() *configs.Task { - return &configs.Task{ - Type: "none", //["none", "asynq", "machinery", "cron"] [string.in] - Name: "", - Asynq: &configs.Task_Asynq{ - Endpoint: "", - Password: "", - Db: 0, - Location: "", - }, - Machinery: &configs.Task_Machinery{ - Brokers: nil, - Backends: nil, - }, - Cron: &configs.Task_Cron{ - Addr: "", - }, - } -} - -func DefaultServiceMessage() *configs.Message { - return &configs.Message{ - Type: "none", //["none", "mqtt", "kafka", "rabbitmq", "activemq", "nats", "nsq", "pulsar", "redis", "rocketmq"] - Name: "", - Mqtt: &configs.Message_MQTT{ - Endpoint: "", - Codec: "", - }, - Kafka: &configs.Message_Kafka{ - Endpoint: "", - Codec: "", - }, - Rabbitmq: &configs.Message_RabbitMQ{ - Endpoint: "", Codec: "", - }, - Activemq: &configs.Message_ActiveMQ{ - Endpoint: "", - Codec: "", - }, - Nats: &configs.Message_NATS{ - Endpoint: "", - Codec: "", - }, - Nsq: &configs.Message_NSQ{ - Endpoint: "", - Codec: "", - }, - Pulsar: &configs.Message_Pulsar{ - Endpoint: "", - Codec: "", - }, - Redis: &configs.Message_Redis{ - Endpoint: "", - Codec: "", - }, - Rocketmq: &configs.Message_RocketMQ{ - Endpoint: "", - Codec: "", - EnableTrace: false, - NameServers: nil, - NameServerDomain: "", - AccessKey: "", - SecretKey: "", SecurityToken: "", - Namespace: "", - InstanceName: "", - GroupName: "", - }, - } -} - -func DefaultDiscovery() *configs.Discovery { - return &configs.Discovery{ - Debug: false, - Type: "consul", - Consul: &configs.Discovery_Consul{ - Address: "${consul_address:127.0.0.1:8500}", - Scheme: "http", - Token: "", - HeartBeat: true, - HealthCheck: true, - Datacenter: "", - HealthCheckInterval: 30, - Timeout: 0, - DeregisterCriticalServiceAfter: 0, - }, - Etcd: nil, - } -} - -func DefaultServiceMiddleware() *middlewarev1.Middleware { - return &middlewarev1.Middleware{ - EnabledMiddlewares: []string{ - "logging", - "recovery", - "tracing", - "circuit_breaker", - "metadata", - "rate_limiter", - "metrics", - "validator", - "jwt", - "selector", - }, - //Logging: true, - //Recovery: true, - //Tracing: true, - //CircuitBreaker: true, - Metadata: &middlewarev1.Middleware_Metadata{ - Enabled: true, - }, - RateLimiter: &ratelimitv1.RateLimiter{ - Enabled: true, - Name: "bbr", - }, - Metrics: &metricsv1.Metrics{ - Enabled: true, - }, - Validator: &validatorv1.Validator{ - Enabled: true, - Version: 1, - FailFast: true, - }, - //It is not recommended to use integrated JWT components - Jwt: &jwtv1.JWT{ - Enabled: false, - Config: &sjwtv1.Config{ - SigningMethod: "HS512", - Key: SigningKey, - Key2: "can empty next version fixed", - AccessTokenLifetime: int64(15 * time.Minute), - RefreshTokenLifetime: int64(3 * 24 * time.Hour), - Issuer: "localhost", - Audience: nil, - TokenType: "Bearer", - }, - }, - // Middleware filters - Selector: &selectorv1.Selector{ - Enabled: false, - }, - } -} - -func DefaultServiceGrpc() *transportv1.GRPCServer { - return &transportv1.GRPCServer{ - Network: "tcp", - Addr: "${grpc_address:0.0.0.0:18000}", - Tls: &securityv1.TLSConfig{Enabled: false}, // Replaced UseTls - Timeout: &durationpb.Duration{}, // Use durationpb.Duration - ShutdownTimeout: &durationpb.Duration{}, // Use durationpb.Duration - Endpoint: "", - } -} - -func DefaultServiceHttp() *transportv1.HTTPServer { - return &transportv1.HTTPServer{ - Network: "tcp", - Addr: "${http_address:0.0.0.0:18100}", - Tls: &securityv1.TLSConfig{Enabled: false}, // Replaced UseTls - Timeout: &durationpb.Duration{}, // Use durationpb.Duration - ShutdownTimeout: &durationpb.Duration{}, // Use durationpb.Duration - Endpoint: "", - } -} - -func DefaultEntry() *configs.Bootstrap_Entry { - return &configs.Bootstrap_Entry{ - Scheme: "http", - } -} - -func DefaultCaptcha() *configs.Captcha { - return &configs.Captcha{ - Length: 4, - Width: 400, - Height: 160, - StorageName: "captcha", - Storage: &configs.Storage{}, - } -} - -func DefaultRootUser() *configs.RootUser { - return &configs.RootUser{ - Enabled: true, - Username: "admin", - Password: "admin", - RandomPassword: true, - Name: "admin", - Nickname: "admin", - Email: "admin@admin.com", - Mobile: "1380000000", - } -} diff --git a/internal/loader/bootstrap_test.go b/internal/loader/bootstrap_test.go deleted file mode 100644 index 5dbcdaee..00000000 --- a/internal/loader/bootstrap_test.go +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "context" - "fmt" - "os" - "path/filepath" - "testing" - "time" - - "github.com/go-kratos/kratos/v2/encoding" - _ "github.com/go-kratos/kratos/v2/encoding/proto" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/slog-kratos" - "github.com/origadmin/toolkits/codec/toml" - "github.com/origadmin/toolkits/crypto/rand" - "github.com/origadmin/toolkits/identifier/uuid" - "google.golang.org/protobuf/encoding/protojson" - - _ "origadmin/application/admin/contrib/database" - "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - _ "origadmin/application/admin/internal/data/entity/ent/runtime" -) - -const ( - testPath = "test" -) - -var ( - key = rand.GenerateRandom(32) -) - -func init() { - encoding.RegisterCodec(toml.Codec) - _, err := os.Stat(testPath) - if err != nil { - os.MkdirAll(testPath, 0755) - } -} - -func TestSaveConfig(t *testing.T) { - fmt.Println("unix:", time.Now().Unix()) - fmt.Println("unixmillis:", time.Now().UnixMilli()) - bootstrap := DefaultBootstrap() - //bootstrap.Security.Authn.Jwt.SigningMethod = "HS256" - //bootstrap.Security.Authn.Jwt.SigningKey = key - bootstrap.Middleware.Jwt.Config.Key = key - bootstrap.Middleware.Jwt.Config.SigningMethod = "HS512" - //bootstrap.Service.Middleware.Jwt.Config.Key = key - //bootstrap.Service.Middleware.Jwt.Config.SigningMethod = "HS512" - type args struct { - path string - conf *configs.Bootstrap - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "test", - args: args{ - path: "test.toml", - conf: bootstrap, - }, - }, - { - name: "test", - args: args{ - path: "test.yml", - conf: bootstrap, - }, - }, - { - name: "test", - args: args{ - path: "test.json", - conf: bootstrap, - }, - }, - //{ - // name: "test", - // args: args{ - // path: "test.ini", - // conf: DefaultBootstrap(), - // }, - //}, - //{ - // name: "test", - // args: args{ - // path: "test.xml", - // conf: DefaultBootstrap(), - // }, - //}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := SaveConfig(filepath.Join(testPath, tt.args.path), tt.args.conf); (err != nil) != tt.wantErr { - t.Errorf("SaveConf() error = %v, wantErr %v", err, tt.wantErr) - } - }) - opt := protojson.MarshalOptions{ - EmitUnpopulated: true, - Indent: " ", - } - bs, _ := opt.Marshal(DefaultBootstrap()) - _ = os.WriteFile("test.json", bs, os.ModePerm) - } -} - -func TestLoadConfig(t *testing.T) { - type args struct { - path string - } - tests := []struct { - name string - args args - want *configs.Bootstrap - wantErr bool - }{ - { - name: "test", - args: args{ - path: "test.toml", - }, - want: DefaultBootstrap(), - wantErr: false, - }, - { - name: "test", - args: args{ - path: "test.json", - }, - want: DefaultBootstrap(), - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got, err := LoadLocalBootstrap(filepath.Join(testPath, tt.args.path)) - if (err != nil) != tt.wantErr { - t.Errorf("LoadConf() error = %v, wantErr %v", err, tt.wantErr) - return - } - if got.Mode != tt.want.Mode { - t.Errorf("LoadConf() got = %v, want %v", got.Mode, tt.want.Mode) - } - if got.Name != tt.want.Name { - t.Errorf("LoadConf() got = %v, want %v", got.Name, tt.want.Name) - } - }) - } -} - -func TestData_InitDataFromPath(t *testing.T) { - log.SetLogger(slog.NewLogger()) - _ = uuid.UUID{} - type fields struct { - Bootstrap *configs.Bootstrap - } - type args struct { - filename string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "test", - fields: fields{ - //Bootstrap: DefaultBootstrap(), - }, - args: args{ - filename: "../../resources/data", - }, - wantErr: false, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.fields.Bootstrap == nil { - abs, err := filepath.Abs("D:\\workspace\\project\\golang\\origadmin\\backend\\internal\\loader\\test" + - "\\test.toml") - if err != nil { - return - } - log.Infof("abs: %s", abs) - bs, err := LoadLocalBootstrap(abs) - if err != nil { - t.Fatal(err) - return - } - tt.fields.Bootstrap = bs - } - _, cleanup, err := data.NewData(runtime.Global(), tt.fields.Bootstrap) - if err != nil { - t.Errorf("NewData() error = %v", err) - return - } - defer cleanup() - //if err := d.InitDataFromPath(context.Background(), tt.args.filename, "resource"); (err != nil) != tt.wantErr { - // t.Errorf("InitFromFile() error = %v, wantErr %v", err, tt.wantErr) - //} - }) - } -} - -func setupTestDB(t *testing.T) *ent.Client { - client, err := ent.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") - if err != nil { - t.Fatalf("failed opening connection to sqlite: %v", err) - } - t.Cleanup(func() { - client.Close() - }) - - if err := client.Schema.Create(context.Background()); err != nil { - t.Fatalf("failed creating schema resources: %v", err) - } - - return client -} - -func createTestRole(t *testing.T, client *ent.Client) *ent.Role { - r, err := client.Role.Create(). - SetName("test-role"). - SetDescription("Test role for testing"). - SetKeyword("test-role"). - Save(context.Background()) - if err != nil { - t.Fatalf("failed creating role: %v", err) - } - return r -} - -func createTestResource(t *testing.T, client *ent.Client) *ent.Resource { - m, err := client.Resource.Create(). - SetName("test-resource"). - SetPath("/test"). - SetDescription("Test menu for testing"). - SetKeyword("test-resource"). - //SetI18nKey("test-resource"). - //SetOperation("test-resource"). - //SetMethod("GET"). - //SetComponent("test-resource"). - Save(context.Background()) - if err != nil { - t.Fatalf("failed creating resource: %v", err) - } - return m -} - -func createTestPermission(t *testing.T, client *ent.Client) *ent.Permission { - p, err := client.Permission.Create(). - SetName("test-permission"). - SetDescription("Test permission for testing"). - SetKeyword("test-permission"). - Save(context.Background()) - if err != nil { - t.Fatalf("failed creating permission: %v", err) - } - return p -} -func TestAddRole(t *testing.T) { - client := setupTestDB(t) - role := createTestRole(t, client) - - if role.Name != "test-role" { - t.Errorf("Expected role name to be 'test-role', got '%s'", role.Name) - } -} - -func TestAddResource(t *testing.T) { - client := setupTestDB(t) - menu := createTestResource(t, client) - - if menu.Name != "test-menu" { - t.Errorf("Expected menu name to be 'test-menu', got '%s'", menu.Name) - } -} - -func TestAddPermission(t *testing.T) { - client := setupTestDB(t) - permission := createTestPermission(t, client) - - if permission.Name != "test-permission" { - t.Errorf("Expected permission name to be 'test-permission', got '%s'", permission.Name) - } -} - -func TestAddRolePermission(t *testing.T) { - client := setupTestDB(t) - role := createTestRole(t, client) - permission := createTestPermission(t, client) - - role, err := role.Update(). - AddPermissions(permission). - Save(context.Background()) - if err != nil { - t.Fatalf("failed adding permission to role: %v", err) - } - permissions := role.QueryPermissions().AllX(context.Background()) - if len(permissions) != 1 { - t.Errorf("Expected role to have 1 permission, got %d", len(role.Edges.Permissions)) - } -} - -func TestAddRoleResource(t *testing.T) { - client := setupTestDB(t) - role := createTestRole(t, client) - perm := createTestPermission(t, client) - res := createTestResource(t, client) - pr, err := client.PermissionResource.Create(). - SetPermission(perm). - SetResource(res). - Save(context.Background()) - //perm, err := perm.Update().AddPermissionResources().Save(context.Background()) - if err != nil { - t.Fatalf("failed adding resource to permission: %v", err) - } - role, err = role.Update(). - AddPermissionIDs(pr.PermissionID). - Save(context.Background()) - if err != nil { - t.Fatalf("failed adding permission to role: %v", err) - } - ress := role.QueryPermissions().QueryResources().AllX(context.Background()) - if len(ress) != 1 { - t.Errorf("Expected role to have 1 menu, got %d", len(ress)) - } - resources := role.QueryPermissions().QueryPermissionResources().AllX(context.Background()) - t.Logf("resources: %v", resources) -} - -func TestDeleteRole(t *testing.T) { - client := setupTestDB(t) - role := createTestRole(t, client) - - err := client.Role.DeleteOne(role). - Exec(context.Background()) - if err != nil { - t.Fatalf("failed deleting role: %v", err) - } - - _, err = client.Role.Get(context.Background(), role.ID) - if !ent.IsNotFound(err) { - t.Errorf("Expected role to be deleted, got %v", err) - } -} diff --git a/internal/loader/config.go b/internal/loader/config.go deleted file mode 100644 index c2f772cc..00000000 --- a/internal/loader/config.go +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - - "origadmin/application/admin/internal/configs" -) - -func LoadBootstrap(cfg *configv1.SourceConfig) (*configs.Bootstrap, error) { - source, err := runtime.NewConfig(cfg) - if err != nil { - return nil, err - } - if err := source.Load(); err != nil { - return nil, err - } - bs := DefaultBootstrap() - if err := source.Scan(bs); err != nil { - return nil, err - } - return bs, nil -} - -func LoadLocalBootstrap(path string) (*configs.Bootstrap, error) { - source := configv1.SourceConfig{ - Types: []string{"file"}, - File: &configv1.SourceConfig_File{ - Path: path, - }, - } - return LoadBootstrap(&source) -} diff --git a/internal/loader/config_test.go b/internal/loader/config_test.go deleted file mode 100644 index b3e076a2..00000000 --- a/internal/loader/config_test.go +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "os" - "path/filepath" - "reflect" - "testing" - - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/toolkits/codec" -) - -func TestNewFileSourceConfig(t *testing.T) { - type args struct { - path string - } - tests := []struct { - name string - args args - want *configv1.SourceConfig - }{ - // TODO: Add test cases. - { - name: "test", - args: args{ - path: "resources/configs", - }, - want: &configv1.SourceConfig{ - Types: []string{"consul"}, - File: &configv1.SourceConfig_File{ - Path: "resources/configs", - }, - Consul: &configv1.SourceConfig_Consul{ - Address: "127.0.0.1:8500", - Scheme: "http", - }, - Etcd: &configv1.SourceConfig_ETCD{ - Endpoints: []string{"127.0.0.1:2379"}, - }, - EnvArgs: map[string]string{ - "env": "dev", - }, - EnvPrefixes: []string{"env"}, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - got := &configv1.SourceConfig{ - Types: []string{"consul"}, - File: &configv1.SourceConfig_File{ - Path: "resources/configs", - }, - Consul: &configv1.SourceConfig_Consul{ - Address: "127.0.0.1:8500", - Scheme: "http", - }, - EnvArgs: map[string]string{ - "env": "dev", - }, - EnvPrefixes: []string{"env"}, - } - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("NewFileSourceConfig() = %v, want %v", got, tt.want) - } - wd, _ := os.Getwd() - path := filepath.Join(wd, "../../resources/local2.toml") - err := codec.EncodeToFile(path, got) - if err != nil { - t.Errorf("NewFileSourceConfig() = %v", err) - } - }) - } -} diff --git a/internal/loader/const.go b/internal/loader/const.go deleted file mode 100644 index 1a0f75eb..00000000 --- a/internal/loader/const.go +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -const ( - Application = `OrigAdmin` - WebSite = `https://origadmin.com` - Description = `A distributed backend management system with a focus on scalability, security, and flexibility.` -) - -// UI generated by https://patorjk.com/software/taag/#p=display&f=Graffiti&t=origadmin -const UI = ` -________ .__ _____ .___ .__ -\_____ \_______|__| ____ / _ \ __| _/_____ |__| ____ - / | \_ __ \ |/ ___\ / /_\ \ / __ |/ \| |/ \ -/ | \ | \/ / /_/ > | \/ /_/ | Y Y \ | | \ -\_______ /__| |__\___ /\____|__ /\____ |__|_| /__|___| / - \/ /_____/ \/ \/ \/ \/ -` - -const ( - CacheNSForUser = "user" - CacheNSForRole = "role" - CacheNSForMenu = "menu" - CacheNSForRes = "resource" - CacheNSForAuth = "auth" - CacheNSForCasbin = "casbin" -) - -const ( - CacheKeyForSyncToCasbin = "sync:casbin:update" - CacheKeyForSyncedCasbin = "sync:casbin:success" -) diff --git a/internal/loader/environment.go b/internal/loader/environment.go deleted file mode 100644 index d78266d6..00000000 --- a/internal/loader/environment.go +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/env" -) - -func SetupEnv(args map[string]string, prefix string) { - for k, v := range args { - key := env.Var(prefix, k) - log.Infof("set environment variable: %s=%s", key, v) - err := env.SetEnv(key, v) - if err != nil { - log.Warnf("failed to set environment variable: %s", err.Error()) - } - } -} diff --git a/internal/loader/file.go b/internal/loader/file.go deleted file mode 100644 index 77870163..00000000 --- a/internal/loader/file.go +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "encoding/json" - "fmt" - "os" - "path/filepath" - "strings" - - "github.com/go-kratos/kratos/v2/encoding" - "github.com/goexts/generic/settings" - "github.com/origadmin/contrib/replacer" - "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/runtime/config" - "github.com/origadmin/runtime/config/file" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/codec" - "github.com/origadmin/toolkits/errors" - "google.golang.org/protobuf/encoding/protojson" - "google.golang.org/protobuf/proto" - - "origadmin/application/admin/internal/configs" -) - -// SaveOption represents an option for saving configuration data. -type SaveOption = func(*protojson.MarshalOptions) - -var ( - r = replacer.New(replacer.WithStart("${"), replacer.WithEnd("}"), replacer.WithSeparator(":")) -) - -func init() { - runtime.RegisterConfig("file", FileConfig(NewFileConfig)) -} - -// SaveConfig saves the configuration data to the specified file path. -func SaveConfig(path string, data any, opts ...SaveOption) error { - if v, ok := data.(proto.Message); ok && strings.HasSuffix(path, ".json") { - opt := settings.Apply(&protojson.MarshalOptions{ - Indent: " ", - }, opts) - bytes, err := opt.Marshal(v) - if err != nil { - return err - } - if err := os.WriteFile(path, bytes, 0644); err != nil { - return err - } - return nil - } - if err := codec.EncodeToFile(path, data); err != nil { - return err - } - return nil -} - -func Replace(s []byte, envs map[string]string) []byte { - return r.Replace(s, envs) -} - -func ReplaceObject(s any, envs map[string]string) error { - marshal, err := json.Marshal(s) - if err != nil { - return err - } - marshal = Replace(marshal, envs) - return json.Unmarshal(marshal, s) -} - -type FileConfig func(*configv1.SourceConfig, *config.Options) (config.KSource, error) - -func (f FileConfig) NewSource(sourceConfig *configv1.SourceConfig, _ *config.Options) (config.KSource, error) { - return f(sourceConfig, nil) -} - -func NewFileConfig(sourceConfig *configv1.SourceConfig, _ *config.Options) (config.KSource, error) { - cfg := sourceConfig.GetFile() - if cfg == nil { - return nil, config.ErrInvalidConfigType - } - var options []file.Option - if len(cfg.Ignores) > 0 { - options = append(options, file.WithIgnores(cfg.Ignores...)) - } - v := new(configs.Bootstrap) - options = append(options, file.WithFormatter(fileFormatter(v))) - path, _ := filepath.Abs(cfg.Path) - log.NewHelper(log.GetLogger()).Infof("loading config from %s", path) - return file.NewSource(cfg.Path, options...), nil -} - -func fileFormatter(typo any) file.Formatter { - return func(key string, value []byte) (*config.KKeyValue, error) { - fmt.Printf("loading config from %s\n", key) - // Don't forget to register the codec - err := encoding.GetCodec(format(key)).Unmarshal(value, typo) - if err != nil { - return nil, errors.Wrap(err, "unmarshal config") - } - //if v, ok := typo.(proto.Message); ok { - // c := encoding.GetCodec("proto") - // marshal, err := c.Marshal(v) - // if err != nil { - // return nil, err - // } - // return &config.KKeyValue{ - // Key: key, - // Format: "proto", - // Value: marshal, - // }, nil - //} - j := encoding.GetCodec("json") - marshal, err := j.Marshal(typo) - if err != nil { - return nil, err - } - key = strings.TrimSuffix(key, filepath.Ext(key)) - return &config.KKeyValue{ - Key: key + ".json", - Format: "json", - Value: marshal, - }, nil - } -} - -func format(name string) string { - if p := strings.Split(name, "."); len(p) > 1 { - return p[len(p)-1] - } - return "" -} diff --git a/internal/loader/load.go b/internal/loader/load.go deleted file mode 100644 index 18cc8a6a..00000000 --- a/internal/loader/load.go +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "github.com/go-kratos/kratos/v2/transport" - "github.com/go-kratos/kratos/v2/transport/grpc" - "github.com/go-kratos/kratos/v2/transport/http" - "github.com/google/wire" - "github.com/origadmin/contrib/transport/gins" - "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/runtime/bootstrap" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - "origadmin/application/admin/internal/configs" - authservice "origadmin/application/admin/internal/mods/auth/service" - systemservice "origadmin/application/admin/internal/mods/system/service" -) - -// AppOptions 包含微服务核心配置 -type AppOptions struct { - ID string - Name string - Version string - Metadata map[string]string - Logger log.KLogger - Server transport.Server -} - -var ( - _ *gins.Server - _ *http.Server - _ *grpc.Server -) - -func NewServiceServerRegistrars( - system systemservice.SystemServerRegistrar, - auth authservice.AuthServerRegistrar, -) []service.ServerRegistrar { - return []service.ServerRegistrar{ - system, - auth, - } -} - -type Loader interface { - SetupEnv() error -} - -type InjectorClient struct { - Server *http.Server -} - -//type Injector struct { -// ServerRegistrar registry.KRegistrar -// Registrars []service.ServerRegistrar -//} - -func init() { - runtime.RegisterConfigFunc("file", NewFileConfig) -} - -type loader struct { - flags *bootstrap.Bootstrap - cfg *configv1.SourceConfig -} - -func (l loader) SetupEnv() error { - if len(l.cfg.EnvPrefixes) > 0 { - SetupEnv(l.cfg.EnvArgs, l.cfg.EnvPrefixes[0]) - } - return nil -} - -func (l loader) Bootstrap() (*configs.Bootstrap, error) { - return LoadBootstrap(l.cfg) -} - -func NewLoader(bs *bootstrap.Bootstrap) (Loader, error) { - load := &loader{ - flags: bs, - } - return load, nil -} diff --git a/internal/loader/provider.go b/internal/loader/provider.go deleted file mode 100644 index 4dd7bbb6..00000000 --- a/internal/loader/provider.go +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "github.com/google/wire" -) - -var ProviderSet = wire.NewSet( - NewServiceServerRegistrars, -) diff --git a/internal/loader/registry.go b/internal/loader/registry.go deleted file mode 100644 index a1cd7c7d..00000000 --- a/internal/loader/registry.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "errors" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/registry" - - "origadmin/application/admin/internal/configs" -) - -func NewRegistrar(bootstrap *configs.Bootstrap) (registry.KRegistrar, error) { - cfg := bootstrap.GetDiscovery() - if cfg == nil { - return nil, errors.New("registry config is nil") - } - registrar, err := runtime.NewRegistrar(cfg) - if err != nil { - return nil, err - } - return registrar, nil -} - -func NewDiscovery(bootstrap *configs.Bootstrap) (registry.KDiscovery, error) { - cfg := bootstrap.GetDiscovery() - if cfg == nil { - return nil, errors.New("registry config is nil") - } - discovery, err := runtime.NewDiscovery(cfg) - if err != nil { - return nil, err - } - return discovery, nil -} diff --git a/internal/loader/service_test.go b/internal/loader/service_test.go deleted file mode 100644 index 0c1a097a..00000000 --- a/internal/loader/service_test.go +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package loader implements the functions, types, and interfaces for the module. -package loader - -import ( - "testing" - - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - v11 "github.com/origadmin/runtime/api/gen/go/middleware/v1" - jwtv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/jwt" - metricsv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/metrics" - ratelimitv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/ratelimit" - selectorv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/selector" - validatorv1 "github.com/origadmin/runtime/api/gen/go/middleware/v1/validator" - - "github.com/stretchr/testify/assert" - - "origadmin/application/admin/internal/configs" -) - -func TestServiceDefaultOutput(t *testing.T) { - // Test the default service configuration initialization - ss := make([]*configs.ServiceServer, 0) - - // Verify empty slice initialization - assert.Empty(t, ss, "默认服务列表应为空") - - // 添加测试服务实例 - testService := &configs.ServiceServer{ - Core: &configs.ServiceCore{ - Name: "test-service", - Version: "v1.0.0", - Discovery: &configv1.Discovery{ - Type: "", - ServiceName: "", - Debug: false, - Consul: &configv1.Discovery_Consul{ - Address: "", - Scheme: "", - Token: "", - HeartBeat: false, - HealthCheck: false, - Datacenter: "", - HealthCheckInterval: 0, - Timeout: 0, - DeregisterCriticalServiceAfter: 0, - }, - Etcd: &configv1.Discovery_ETCD{ - Endpoints: nil, - }, - }, - Storages: nil, - }, - Services: []*configv1.Service{ - &configv1.Service{ - Name: "", - DynamicEndpoint: false, - Grpc: &configv1.Service_GRPC{ - Network: "", - Addr: "", - UseTls: false, - TlsConfig: &configv1.TLSConfig{ - File: &configv1.TLSConfig_File{ - Cert: "", - Key: "", - Ca: "", - }, - Pem: &configv1.TLSConfig_PEM{ - Cert: nil, - Key: nil, - Ca: nil, - }, - }, - Timeout: 0, - ShutdownTimeout: 0, - ReadTimeout: 0, - WriteTimeout: 0, - IdleTimeout: 0, - Endpoint: "", - }, - Http: &configv1.Service_HTTP{ - Network: "", - Addr: "", - UseTls: false, - TlsConfig: &configv1.TLSConfig{ - File: &configv1.TLSConfig_File{ - Cert: "", - Key: "", - Ca: "", - }, - Pem: &configv1.TLSConfig_PEM{ - Cert: nil, - Key: nil, - Ca: nil, - }, - }, - Timeout: 0, - ShutdownTimeout: 0, - ReadTimeout: 0, - WriteTimeout: 0, - IdleTimeout: 0, - Endpoint: "", - }, - Websocket: &configv1.WebSocket{ - Network: "", - Addr: "", - Path: "", - Codec: "", - Timeout: 0, - }, - Message: &configv1.Message{ - Type: "", - Name: "", - Mqtt: &configv1.Message_MQTT{ - Endpoint: "", - Codec: "", - }, - Kafka: &configv1.Message_Kafka{ - Endpoint: "", - Codec: "", - }, - Rabbitmq: &configv1.Message_RabbitMQ{ - Endpoint: "", - Codec: "", - }, - Activemq: &configv1.Message_ActiveMQ{ - Endpoint: "", - Codec: "", - }, - Nats: &configv1.Message_NATS{ - Endpoint: "", - Codec: "", - }, - Nsq: &configv1.Message_NSQ{ - Endpoint: "", - Codec: "", - }, - Pulsar: &configv1.Message_Pulsar{ - Endpoint: "", - Codec: "", - }, - Redis: &configv1.Message_Redis{ - Endpoint: "", - Codec: "", - }, - Rocketmq: &configv1.Message_RocketMQ{ - Endpoint: "", - Codec: "", - EnableTrace: false, - NameServers: nil, - NameServerDomain: "", - AccessKey: "", - SecretKey: "", - SecurityToken: "", - Namespace: "", - InstanceName: "", - GroupName: "", - }, - }, - Task: &configv1.Task{ - Type: "", - Name: "", - Asynq: &configv1.Task_Asynq{ - Endpoint: "", - Password: "", - Db: 0, - Location: "", - }, - Machinery: &configv1.Task_Machinery{ - Brokers: nil, - Backends: nil, - }, - Cron: &configv1.Task_Cron{ - Addr: "", - }, - }, - }, - }, - Middleware: &v11.Middleware{ - //Logging: false, - //Recovery: false, - //Tracing: false, - //CircuitBreaker: false, - Metadata: &v11.Middleware_Metadata{ - Enabled: false, - Prefixes: nil, - Data: nil, - }, - RateLimiter: &ratelimitv1.RateLimiter{ - Enabled: false, - Name: "", - Period: 0, - XRatelimitLimit: 0, - XRatelimitRemaining: 0, - XRatelimitReset: 0, - RetryAfter: 0, - Memory: &ratelimitv1.RateLimiter_Memory{ - Expiration: 0, - CleanupInterval: 0, - }, - Redis: &ratelimitv1.RateLimiter_Redis{ - Addr: "", - Username: "", - Password: "", - Db: 0, - }, - }, - Metrics: &metricsv1.Metrics{ - Enabled: false, - SupportedMetrics: nil, - UserMetrics: nil, - }, - Validator: &validatorv1.Validator{ - Enabled: false, - Version: 0, - FailFast: false, - }, - Jwt: &jwtv1.JWT{ - Enabled: false, - Subject: "", - ClaimType: "", - TokenHeader: nil, - //Config: &jwtv1.Config{ - // SigningMethod: "", - // Key: "", - // Key2: "", - // AccessTokenLifetime: 0, - // RefreshTokenLifetime: 0, - // Issuer: "", - // Audience: nil, - // TokenType: "", - //}, - }, - Selector: &selectorv1.Selector{ - Enabled: false, - Names: nil, - Paths: nil, - Regex: "", - Prefixes: nil, - }, - }, - } - ss = append(ss, testService) - - // 验证服务添加后的数量和内容 - assert.Len(t, ss, 1, "添加服务后应包含一个元素") - assert.Equal(t, "test-service", ss[0].Services[0].Name, "服务名称不匹配") -} diff --git a/main.go b/main.go deleted file mode 100644 index bee37ea5..00000000 --- a/main.go +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package main is the main package -package main - -import ( - goversion "github.com/caarlos0/go-version" - - "origadmin/application/admin/cmd" - "origadmin/application/admin/internal/loader" -) - -var ( - version = "" - commit = "" - treeState = "" - date = "" - builtBy = "" -) - -func buildVersion(version, commit, date, builtBy, treeState string) goversion.Info { - return goversion.GetVersionInfo( - goversion.WithAppDetails(loader.Application, loader.Description, loader.WebSite), - func(i *goversion.Info) { - i.ASCIIName = loader.UI - if commit != "" { - i.GitCommit = commit - } - if version != "" { - i.GitVersion = version - } - if treeState != "" { - i.GitTreeState = treeState - } - if date != "" { - i.BuildDate = date - } - if builtBy != "" { - i.BuiltBy = builtBy - } - }, - ) -} - -// @title OrigAdmin Backend API -// @version v1.0.0 -// @description A distributed backend management system with a focus on scalability, security, and flexibility. -// @contact.name OrigAdmin -// @contact.url https://github.com/origadmin -// @license.name MIT -// @license.url https://github.com/origadmin/origadmin/blob/main/LICENSE.md -// -// @host localhost:10080 -// @basepath /api/v1 -// @schemes http https -// -// @securitydefinitions.basic Basic -// -// @securitydefinitions.apikey Bearer -// @in header -// @name Authorization -func main() { - cmd.Execute(buildVersion(version, commit, date, builtBy, treeState)) -} diff --git a/third_party/auth/v1/auth.proto b/third_party/auth/v1/auth.proto deleted file mode 100644 index b7a776ed..00000000 --- a/third_party/auth/v1/auth.proto +++ /dev/null @@ -1,42 +0,0 @@ -syntax = "proto3"; - -package auth.v1; - -import "google/protobuf/timestamp.proto"; -import "buf/validate/validate.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "OrigAdmin.Runtime.Auth.V1"; -option go_package = "github.com/origadmin/runtime/api/gen/go/auth/v1;authv1"; -option java_multiple_files = true; -option java_outer_classname = "AuthProto"; -option java_package = "com.github.origadmin.runtime.auth.v1"; -option objc_class_prefix = "ORA"; -option php_namespace = "OrigAdmin\\Runtime\\Auth\\V1"; - - -message BasicAuth { - string username = 1 [json_name = "username"]; - string password = 2 [json_name = "password"]; -} - -message BearerAuth { - string token = 1 [json_name = "token"]; -} - -message AuthN { - string type = 1 [json_name = "type", (buf.validate.field).string = {in: ["basic", "bearer"]}] ; - oneof auth { - BasicAuth basic = 10; - BearerAuth bearer = 11; - } -} - -message AuthZ { - bool root = 1 [json_name = "root"]; - string id = 2 [json_name = "id"]; - string user =3 [json_name = "user", (buf.validate.field).string = {in: ["admin", "user", "guest"]}]; - string username = 4 [json_name = "username"]; - repeated string roles = 5 [json_name = "roles"]; // Roles; - google.protobuf.Timestamp timestamp = 6 [json_name = "timestamp"]; -} \ No newline at end of file diff --git a/third_party/buf/validate/validate.proto b/third_party/buf/validate/validate.proto deleted file mode 100644 index 40236f65..00000000 --- a/third_party/buf/validate/validate.proto +++ /dev/null @@ -1,4952 +0,0 @@ -// Copyright 2023-2025 Buf Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto2"; - -package buf.validate; - -import "google/protobuf/descriptor.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -option go_package = "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"; -option java_multiple_files = true; -option java_outer_classname = "ValidateProto"; -option java_package = "build.buf.validate"; - -// MessageOptions is an extension to google.protobuf.MessageOptions. It allows -// the addition of validation rules at the message level. These rules can be -// applied to incoming messages to ensure they meet certain criteria before -// being processed. -extend google.protobuf.MessageOptions { - // Rules specify the validations to be performed on this message. By default, - // no validation is performed against a message. - optional MessageRules message = 1159; -} - -// OneofOptions is an extension to google.protobuf.OneofOptions. It allows -// the addition of validation rules on a oneof. These rules can be -// applied to incoming messages to ensure they meet certain criteria before -// being processed. -extend google.protobuf.OneofOptions { - // Rules specify the validations to be performed on this oneof. By default, - // no validation is performed against a oneof. - optional OneofRules oneof = 1159; -} - -// FieldOptions is an extension to google.protobuf.FieldOptions. It allows -// the addition of validation rules at the field level. These rules can be -// applied to incoming messages to ensure they meet certain criteria before -// being processed. -extend google.protobuf.FieldOptions { - // Rules specify the validations to be performed on this field. By default, - // no validation is performed against a field. - optional FieldRules field = 1159; - - // Specifies predefined rules. When extending a standard rule message, - // this adds additional CEL expressions that apply when the extension is used. - // - // ```proto - // extend buf.validate.Int32Rules { - // bool is_zero [(buf.validate.predefined).cel = { - // id: "int32.is_zero", - // message: "value must be zero", - // expression: "!rule || this == 0", - // }]; - // } - // - // message Foo { - // int32 reserved = 1 [(buf.validate.field).int32.(is_zero) = true]; - // } - // ``` - optional PredefinedRules predefined = 1160; -} - -// `Rule` represents a validation rule written in the Common Expression -// Language (CEL) syntax. Each Rule includes a unique identifier, an -// optional error message, and the CEL expression to evaluate. For more -// information on CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). -// -// ```proto -// message Foo { -// option (buf.validate.message).cel = { -// id: "foo.bar" -// message: "bar must be greater than 0" -// expression: "this.bar > 0" -// }; -// int32 bar = 1; -// } -// ``` -message Rule { - // `id` is a string that serves as a machine-readable name for this Rule. - // It should be unique within its scope, which could be either a message or a field. - optional string id = 1; - - // `message` is an optional field that provides a human-readable error message - // for this Rule when the CEL expression evaluates to false. If a - // non-empty message is provided, any strings resulting from the CEL - // expression evaluation are ignored. - optional string message = 2; - - // `expression` is the actual CEL expression that will be evaluated for - // validation. This string must resolve to either a boolean or a string - // value. If the expression evaluates to false or a non-empty string, the - // validation is considered failed, and the message is rejected. - optional string expression = 3; -} - -// MessageRules represents validation rules that are applied to the entire message. -// It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules. -message MessageRules { - // `disabled` is a boolean flag that, when set to true, nullifies any validation rules for this message. - // This includes any fields within the message that would otherwise support validation. - // - // ```proto - // message MyMessage { - // // validation will be bypassed for this message - // option (buf.validate.message).disabled = true; - // } - // ``` - optional bool disabled = 1; - - // `cel` is a repeated field of type Rule. Each Rule specifies a validation rule to be applied to this message. - // These rules are written in Common Expression Language (CEL) syntax. For more information on - // CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). - // - // - // ```proto - // message MyMessage { - // // The field `foo` must be greater than 42. - // option (buf.validate.message).cel = { - // id: "my_message.value", - // message: "value must be greater than 42", - // expression: "this.foo > 42", - // }; - // optional int32 foo = 1; - // } - // ``` - repeated Rule cel = 3; -} - -// The `OneofRules` message type enables you to manage rules for -// oneof fields in your protobuf messages. -message OneofRules { - // If `required` is true, exactly one field of the oneof must be present. A - // validation error is returned if no fields in the oneof are present. The - // field itself may still be a default value; further rules - // should be placed on the fields themselves to ensure they are valid values, - // such as `min_len` or `gt`. - // - // ```proto - // message MyMessage { - // oneof value { - // // Either `a` or `b` must be set. If `a` is set, it must also be - // // non-empty; whereas if `b` is set, it can still be an empty string. - // option (buf.validate.oneof).required = true; - // string a = 1 [(buf.validate.field).string.min_len = 1]; - // string b = 2; - // } - // } - // ``` - optional bool required = 1; -} - -// FieldRules encapsulates the rules for each type of field. Depending on -// the field, the correct set should be used to ensure proper validations. -message FieldRules { - // `cel` is a repeated field used to represent a textual expression - // in the Common Expression Language (CEL) syntax. For more information on - // CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). - // - // ```proto - // message MyMessage { - // // The field `value` must be greater than 42. - // optional int32 value = 1 [(buf.validate.field).cel = { - // id: "my_message.value", - // message: "value must be greater than 42", - // expression: "this > 42", - // }]; - // } - // ``` - repeated Rule cel = 23; - // If `required` is true, the field must be populated. A populated field can be - // described as "serialized in the wire format," which includes: - // - // - the following "nullable" fields must be explicitly set to be considered populated: - // - singular message fields (whose fields may be unpopulated / default values) - // - member fields of a oneof (may be their default value) - // - proto3 optional fields (may be their default value) - // - proto2 scalar fields (both optional and required) - // - proto3 scalar fields must be non-zero to be considered populated - // - repeated and map fields must be non-empty to be considered populated - // - // ```proto - // message MyMessage { - // // The field `value` must be set to a non-null value. - // optional MyOtherMessage value = 1 [(buf.validate.field).required = true]; - // } - // ``` - optional bool required = 25; - // Skip validation on the field if its value matches the specified criteria. - // See Ignore enum for details. - // - // ```proto - // message UpdateRequest { - // // The uri rule only applies if the field is populated and not an empty - // // string. - // optional string url = 1 [ - // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE, - // (buf.validate.field).string.uri = true, - // ]; - // } - // ``` - optional Ignore ignore = 27; - - oneof type { - // Scalar Field Types - FloatRules float = 1; - DoubleRules double = 2; - Int32Rules int32 = 3; - Int64Rules int64 = 4; - UInt32Rules uint32 = 5; - UInt64Rules uint64 = 6; - SInt32Rules sint32 = 7; - SInt64Rules sint64 = 8; - Fixed32Rules fixed32 = 9; - Fixed64Rules fixed64 = 10; - SFixed32Rules sfixed32 = 11; - SFixed64Rules sfixed64 = 12; - BoolRules bool = 13; - StringRules string = 14; - BytesRules bytes = 15; - - // Complex Field Types - EnumRules enum = 16; - RepeatedRules repeated = 18; - MapRules map = 19; - - // Well-Known Field Types - AnyRules any = 20; - DurationRules duration = 21; - TimestampRules timestamp = 22; - } - - reserved 24, 26; - reserved "skipped", "ignore_empty"; -} - -// PredefinedRules are custom rules that can be re-used with -// multiple fields. -message PredefinedRules { - // `cel` is a repeated field used to represent a textual expression - // in the Common Expression Language (CEL) syntax. For more information on - // CEL, [see our documentation](https://github.com/bufbuild/protovalidate/blob/main/docs/cel.md). - // - // ```proto - // message MyMessage { - // // The field `value` must be greater than 42. - // optional int32 value = 1 [(buf.validate.predefined).cel = { - // id: "my_message.value", - // message: "value must be greater than 42", - // expression: "this > 42", - // }]; - // } - // ``` - repeated Rule cel = 1; - - reserved 24, 26; - reserved - "skipped" - "ignore_empty" -; -} - -// Specifies how FieldRules.ignore behaves. See the documentation for -// FieldRules.required for definitions of "populated" and "nullable". -enum Ignore { - // Validation is only skipped if it's an unpopulated nullable fields. - // - // ```proto - // syntax="proto3"; - // - // message Request { - // // The uri rule applies to any value, including the empty string. - // string foo = 1 [ - // (buf.validate.field).string.uri = true - // ]; - // - // // The uri rule only applies if the field is set, including if it's - // // set to the empty string. - // optional string bar = 2 [ - // (buf.validate.field).string.uri = true - // ]; - // - // // The min_items rule always applies, even if the list is empty. - // repeated string baz = 3 [ - // (buf.validate.field).repeated.min_items = 3 - // ]; - // - // // The custom CEL rule applies only if the field is set, including if - // // it's the "zero" value of that message. - // SomeMessage quux = 4 [ - // (buf.validate.field).cel = {/* ... */} - // ]; - // } - // ``` - IGNORE_UNSPECIFIED = 0; - - // Validation is skipped if the field is unpopulated. This rule is redundant - // if the field is already nullable. - // - // ```proto - // syntax="proto3 - // - // message Request { - // // The uri rule applies only if the value is not the empty string. - // string foo = 1 [ - // (buf.validate.field).string.uri = true, - // (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED - // ]; - // - // // IGNORE_IF_UNPOPULATED is equivalent to IGNORE_UNSPECIFIED in this - // // case: the uri rule only applies if the field is set, including if - // // it's set to the empty string. - // optional string bar = 2 [ - // (buf.validate.field).string.uri = true, - // (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED - // ]; - // - // // The min_items rule only applies if the list has at least one item. - // repeated string baz = 3 [ - // (buf.validate.field).repeated.min_items = 3, - // (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED - // ]; - // - // // IGNORE_IF_UNPOPULATED is equivalent to IGNORE_UNSPECIFIED in this - // // case: the custom CEL rule applies only if the field is set, including - // // if it's the "zero" value of that message. - // SomeMessage quux = 4 [ - // (buf.validate.field).cel = {/* ... */}, - // (buf.validate.field).ignore = IGNORE_IF_UNPOPULATED - // ]; - // } - // ``` - IGNORE_IF_UNPOPULATED = 1; - - // Validation is skipped if the field is unpopulated or if it is a nullable - // field populated with its default value. This is typically the zero or - // empty value, but proto2 scalars support custom defaults. For messages, the - // default is a non-null message with all its fields unpopulated. - // - // ```proto - // syntax="proto3 - // - // message Request { - // // IGNORE_IF_DEFAULT_VALUE is equivalent to IGNORE_IF_UNPOPULATED in - // // this case; the uri rule applies only if the value is not the empty - // // string. - // string foo = 1 [ - // (buf.validate.field).string.uri = true, - // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE - // ]; - // - // // The uri rule only applies if the field is set to a value other than - // // the empty string. - // optional string bar = 2 [ - // (buf.validate.field).string.uri = true, - // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE - // ]; - // - // // IGNORE_IF_DEFAULT_VALUE is equivalent to IGNORE_IF_UNPOPULATED in - // // this case; the min_items rule only applies if the list has at least - // // one item. - // repeated string baz = 3 [ - // (buf.validate.field).repeated.min_items = 3, - // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE - // ]; - // - // // The custom CEL rule only applies if the field is set to a value other - // // than an empty message (i.e., fields are unpopulated). - // SomeMessage quux = 4 [ - // (buf.validate.field).cel = {/* ... */}, - // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE - // ]; - // } - // ``` - // - // This rule is affected by proto2 custom default values: - // - // ```proto - // syntax="proto2"; - // - // message Request { - // // The gt rule only applies if the field is set and it's value is not - // the default (i.e., not -42). The rule even applies if the field is set - // to zero since the default value differs. - // optional int32 value = 1 [ - // default = -42, - // (buf.validate.field).int32.gt = 0, - // (buf.validate.field).ignore = IGNORE_IF_DEFAULT_VALUE - // ]; - // } - IGNORE_IF_DEFAULT_VALUE = 2; - - // The validation rules of this field will be skipped and not evaluated. This - // is useful for situations that necessitate turning off the rules of a field - // containing a message that may not make sense in the current context, or to - // temporarily disable rules during development. - // - // ```proto - // message MyMessage { - // // The field's rules will always be ignored, including any validation's - // // on value's fields. - // MyOtherMessage value = 1 [ - // (buf.validate.field).ignore = IGNORE_ALWAYS]; - // } - // ``` - IGNORE_ALWAYS = 3; - - reserved - "IGNORE_EMPTY" - "IGNORE_DEFAULT" -; -} - -// FloatRules describes the rules applied to `float` values. These -// rules may also be applied to the `google.protobuf.FloatValue` Well-Known-Type. -message FloatRules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MyFloat { - // // value must equal 42.0 - // float value = 1 [(buf.validate.field).float.const = 42.0]; - // } - // ``` - optional float const = 1 [(predefined).cel = { - id: "float.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - - oneof less_than { - // `lt` requires the field value to be less than the specified value (field < - // value). If the field value is equal to or greater than the specified value, - // an error message is generated. - // - // ```proto - // message MyFloat { - // // value must be less than 10.0 - // float value = 1 [(buf.validate.field).float.lt = 10.0]; - // } - // ``` - float lt = 2 [(predefined).cel = { - id: "float.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MyFloat { - // // value must be less than or equal to 10.0 - // float value = 1 [(buf.validate.field).float.lte = 10.0]; - // } - // ``` - float lte = 3 [(predefined).cel = { - id: "float.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyFloat { - // // value must be greater than 5.0 [float.gt] - // float value = 1 [(buf.validate.field).float.gt = 5.0]; - // - // // value must be greater than 5 and less than 10.0 [float.gt_lt] - // float other_value = 2 [(buf.validate.field).float = { gt: 5.0, lt: 10.0 }]; - // - // // value must be greater than 10 or less than 5.0 [float.gt_lt_exclusive] - // float another_value = 3 [(buf.validate.field).float = { gt: 10.0, lt: 5.0 }]; - // } - // ``` - float gt = 4 [ - (predefined).cel = { - id: "float.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "float.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "float.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "float.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "float.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyFloat { - // // value must be greater than or equal to 5.0 [float.gte] - // float value = 1 [(buf.validate.field).float.gte = 5.0]; - // - // // value must be greater than or equal to 5.0 and less than 10.0 [float.gte_lt] - // float other_value = 2 [(buf.validate.field).float = { gte: 5.0, lt: 10.0 }]; - // - // // value must be greater than or equal to 10.0 or less than 5.0 [float.gte_lt_exclusive] - // float another_value = 3 [(buf.validate.field).float = { gte: 10.0, lt: 5.0 }]; - // } - // ``` - float gte = 5 [ - (predefined).cel = { - id: "float.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "float.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "float.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "float.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "float.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message - // is generated. - // - // ```proto - // message MyFloat { - // // value must be in list [1.0, 2.0, 3.0] - // float value = 1 [(buf.validate.field).float = { in: [1.0, 2.0, 3.0] }]; - // } - // ``` - repeated float in = 6 [(predefined).cel = { - id: "float.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MyFloat { - // // value must not be in list [1.0, 2.0, 3.0] - // float value = 1 [(buf.validate.field).float = { not_in: [1.0, 2.0, 3.0] }]; - // } - // ``` - repeated float not_in = 7 [(predefined).cel = { - id: "float.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `finite` requires the field value to be finite. If the field value is - // infinite or NaN, an error message is generated. - optional bool finite = 8 [(predefined).cel = { - id: "float.finite" - expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyFloat { - // float value = 1 [ - // (buf.validate.field).float.example = 1.0, - // (buf.validate.field).float.example = "Infinity" - // ]; - // } - // ``` - repeated float example = 9 [(predefined).cel = { - id: "float.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// DoubleRules describes the rules applied to `double` values. These -// rules may also be applied to the `google.protobuf.DoubleValue` Well-Known-Type. -message DoubleRules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MyDouble { - // // value must equal 42.0 - // double value = 1 [(buf.validate.field).double.const = 42.0]; - // } - // ``` - optional double const = 1 [(predefined).cel = { - id: "double.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field < - // value). If the field value is equal to or greater than the specified - // value, an error message is generated. - // - // ```proto - // message MyDouble { - // // value must be less than 10.0 - // double value = 1 [(buf.validate.field).double.lt = 10.0]; - // } - // ``` - double lt = 2 [(predefined).cel = { - id: "double.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified value - // (field <= value). If the field value is greater than the specified value, - // an error message is generated. - // - // ```proto - // message MyDouble { - // // value must be less than or equal to 10.0 - // double value = 1 [(buf.validate.field).double.lte = 10.0]; - // } - // ``` - double lte = 3 [(predefined).cel = { - id: "double.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or `lte`, - // the range is reversed, and the field value must be outside the specified - // range. If the field value doesn't meet the required conditions, an error - // message is generated. - // - // ```proto - // message MyDouble { - // // value must be greater than 5.0 [double.gt] - // double value = 1 [(buf.validate.field).double.gt = 5.0]; - // - // // value must be greater than 5 and less than 10.0 [double.gt_lt] - // double other_value = 2 [(buf.validate.field).double = { gt: 5.0, lt: 10.0 }]; - // - // // value must be greater than 10 or less than 5.0 [double.gt_lt_exclusive] - // double another_value = 3 [(buf.validate.field).double = { gt: 10.0, lt: 5.0 }]; - // } - // ``` - double gt = 4 [ - (predefined).cel = { - id: "double.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "double.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "double.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "double.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "double.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyDouble { - // // value must be greater than or equal to 5.0 [double.gte] - // double value = 1 [(buf.validate.field).double.gte = 5.0]; - // - // // value must be greater than or equal to 5.0 and less than 10.0 [double.gte_lt] - // double other_value = 2 [(buf.validate.field).double = { gte: 5.0, lt: 10.0 }]; - // - // // value must be greater than or equal to 10.0 or less than 5.0 [double.gte_lt_exclusive] - // double another_value = 3 [(buf.validate.field).double = { gte: 10.0, lt: 5.0 }]; - // } - // ``` - double gte = 5 [ - (predefined).cel = { - id: "double.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "double.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "double.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "double.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "double.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message is - // generated. - // - // ```proto - // message MyDouble { - // // value must be in list [1.0, 2.0, 3.0] - // double value = 1 [(buf.validate.field).double = { in: [1.0, 2.0, 3.0] }]; - // } - // ``` - repeated double in = 6 [(predefined).cel = { - id: "double.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MyDouble { - // // value must not be in list [1.0, 2.0, 3.0] - // double value = 1 [(buf.validate.field).double = { not_in: [1.0, 2.0, 3.0] }]; - // } - // ``` - repeated double not_in = 7 [(predefined).cel = { - id: "double.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `finite` requires the field value to be finite. If the field value is - // infinite or NaN, an error message is generated. - optional bool finite = 8 [(predefined).cel = { - id: "double.finite" - expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyDouble { - // double value = 1 [ - // (buf.validate.field).double.example = 1.0, - // (buf.validate.field).double.example = "Infinity" - // ]; - // } - // ``` - repeated double example = 9 [(predefined).cel = { - id: "double.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// Int32Rules describes the rules applied to `int32` values. These -// rules may also be applied to the `google.protobuf.Int32Value` Well-Known-Type. -message Int32Rules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MyInt32 { - // // value must equal 42 - // int32 value = 1 [(buf.validate.field).int32.const = 42]; - // } - // ``` - optional int32 const = 1 [(predefined).cel = { - id: "int32.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field - // < value). If the field value is equal to or greater than the specified - // value, an error message is generated. - // - // ```proto - // message MyInt32 { - // // value must be less than 10 - // int32 value = 1 [(buf.validate.field).int32.lt = 10]; - // } - // ``` - int32 lt = 2 [(predefined).cel = { - id: "int32.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MyInt32 { - // // value must be less than or equal to 10 - // int32 value = 1 [(buf.validate.field).int32.lte = 10]; - // } - // ``` - int32 lte = 3 [(predefined).cel = { - id: "int32.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyInt32 { - // // value must be greater than 5 [int32.gt] - // int32 value = 1 [(buf.validate.field).int32.gt = 5]; - // - // // value must be greater than 5 and less than 10 [int32.gt_lt] - // int32 other_value = 2 [(buf.validate.field).int32 = { gt: 5, lt: 10 }]; - // - // // value must be greater than 10 or less than 5 [int32.gt_lt_exclusive] - // int32 another_value = 3 [(buf.validate.field).int32 = { gt: 10, lt: 5 }]; - // } - // ``` - int32 gt = 4 [ - (predefined).cel = { - id: "int32.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "int32.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "int32.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "int32.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "int32.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified value - // (exclusive). If the value of `gte` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyInt32 { - // // value must be greater than or equal to 5 [int32.gte] - // int32 value = 1 [(buf.validate.field).int32.gte = 5]; - // - // // value must be greater than or equal to 5 and less than 10 [int32.gte_lt] - // int32 other_value = 2 [(buf.validate.field).int32 = { gte: 5, lt: 10 }]; - // - // // value must be greater than or equal to 10 or less than 5 [int32.gte_lt_exclusive] - // int32 another_value = 3 [(buf.validate.field).int32 = { gte: 10, lt: 5 }]; - // } - // ``` - int32 gte = 5 [ - (predefined).cel = { - id: "int32.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "int32.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "int32.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "int32.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "int32.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message is - // generated. - // - // ```proto - // message MyInt32 { - // // value must be in list [1, 2, 3] - // int32 value = 1 [(buf.validate.field).int32 = { in: [1, 2, 3] }]; - // } - // ``` - repeated int32 in = 6 [(predefined).cel = { - id: "int32.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error message - // is generated. - // - // ```proto - // message MyInt32 { - // // value must not be in list [1, 2, 3] - // int32 value = 1 [(buf.validate.field).int32 = { not_in: [1, 2, 3] }]; - // } - // ``` - repeated int32 not_in = 7 [(predefined).cel = { - id: "int32.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyInt32 { - // int32 value = 1 [ - // (buf.validate.field).int32.example = 1, - // (buf.validate.field).int32.example = -10 - // ]; - // } - // ``` - repeated int32 example = 8 [(predefined).cel = { - id: "int32.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// Int64Rules describes the rules applied to `int64` values. These -// rules may also be applied to the `google.protobuf.Int64Value` Well-Known-Type. -message Int64Rules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MyInt64 { - // // value must equal 42 - // int64 value = 1 [(buf.validate.field).int64.const = 42]; - // } - // ``` - optional int64 const = 1 [(predefined).cel = { - id: "int64.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field < - // value). If the field value is equal to or greater than the specified value, - // an error message is generated. - // - // ```proto - // message MyInt64 { - // // value must be less than 10 - // int64 value = 1 [(buf.validate.field).int64.lt = 10]; - // } - // ``` - int64 lt = 2 [(predefined).cel = { - id: "int64.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MyInt64 { - // // value must be less than or equal to 10 - // int64 value = 1 [(buf.validate.field).int64.lte = 10]; - // } - // ``` - int64 lte = 3 [(predefined).cel = { - id: "int64.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyInt64 { - // // value must be greater than 5 [int64.gt] - // int64 value = 1 [(buf.validate.field).int64.gt = 5]; - // - // // value must be greater than 5 and less than 10 [int64.gt_lt] - // int64 other_value = 2 [(buf.validate.field).int64 = { gt: 5, lt: 10 }]; - // - // // value must be greater than 10 or less than 5 [int64.gt_lt_exclusive] - // int64 another_value = 3 [(buf.validate.field).int64 = { gt: 10, lt: 5 }]; - // } - // ``` - int64 gt = 4 [ - (predefined).cel = { - id: "int64.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "int64.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "int64.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "int64.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "int64.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyInt64 { - // // value must be greater than or equal to 5 [int64.gte] - // int64 value = 1 [(buf.validate.field).int64.gte = 5]; - // - // // value must be greater than or equal to 5 and less than 10 [int64.gte_lt] - // int64 other_value = 2 [(buf.validate.field).int64 = { gte: 5, lt: 10 }]; - // - // // value must be greater than or equal to 10 or less than 5 [int64.gte_lt_exclusive] - // int64 another_value = 3 [(buf.validate.field).int64 = { gte: 10, lt: 5 }]; - // } - // ``` - int64 gte = 5 [ - (predefined).cel = { - id: "int64.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "int64.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "int64.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "int64.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "int64.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message is - // generated. - // - // ```proto - // message MyInt64 { - // // value must be in list [1, 2, 3] - // int64 value = 1 [(buf.validate.field).int64 = { in: [1, 2, 3] }]; - // } - // ``` - repeated int64 in = 6 [(predefined).cel = { - id: "int64.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MyInt64 { - // // value must not be in list [1, 2, 3] - // int64 value = 1 [(buf.validate.field).int64 = { not_in: [1, 2, 3] }]; - // } - // ``` - repeated int64 not_in = 7 [(predefined).cel = { - id: "int64.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyInt64 { - // int64 value = 1 [ - // (buf.validate.field).int64.example = 1, - // (buf.validate.field).int64.example = -10 - // ]; - // } - // ``` - repeated int64 example = 9 [(predefined).cel = { - id: "int64.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// UInt32Rules describes the rules applied to `uint32` values. These -// rules may also be applied to the `google.protobuf.UInt32Value` Well-Known-Type. -message UInt32Rules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MyUInt32 { - // // value must equal 42 - // uint32 value = 1 [(buf.validate.field).uint32.const = 42]; - // } - // ``` - optional uint32 const = 1 [(predefined).cel = { - id: "uint32.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field < - // value). If the field value is equal to or greater than the specified value, - // an error message is generated. - // - // ```proto - // message MyUInt32 { - // // value must be less than 10 - // uint32 value = 1 [(buf.validate.field).uint32.lt = 10]; - // } - // ``` - uint32 lt = 2 [(predefined).cel = { - id: "uint32.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MyUInt32 { - // // value must be less than or equal to 10 - // uint32 value = 1 [(buf.validate.field).uint32.lte = 10]; - // } - // ``` - uint32 lte = 3 [(predefined).cel = { - id: "uint32.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyUInt32 { - // // value must be greater than 5 [uint32.gt] - // uint32 value = 1 [(buf.validate.field).uint32.gt = 5]; - // - // // value must be greater than 5 and less than 10 [uint32.gt_lt] - // uint32 other_value = 2 [(buf.validate.field).uint32 = { gt: 5, lt: 10 }]; - // - // // value must be greater than 10 or less than 5 [uint32.gt_lt_exclusive] - // uint32 another_value = 3 [(buf.validate.field).uint32 = { gt: 10, lt: 5 }]; - // } - // ``` - uint32 gt = 4 [ - (predefined).cel = { - id: "uint32.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "uint32.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "uint32.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "uint32.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "uint32.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyUInt32 { - // // value must be greater than or equal to 5 [uint32.gte] - // uint32 value = 1 [(buf.validate.field).uint32.gte = 5]; - // - // // value must be greater than or equal to 5 and less than 10 [uint32.gte_lt] - // uint32 other_value = 2 [(buf.validate.field).uint32 = { gte: 5, lt: 10 }]; - // - // // value must be greater than or equal to 10 or less than 5 [uint32.gte_lt_exclusive] - // uint32 another_value = 3 [(buf.validate.field).uint32 = { gte: 10, lt: 5 }]; - // } - // ``` - uint32 gte = 5 [ - (predefined).cel = { - id: "uint32.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "uint32.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "uint32.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "uint32.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "uint32.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message is - // generated. - // - // ```proto - // message MyUInt32 { - // // value must be in list [1, 2, 3] - // uint32 value = 1 [(buf.validate.field).uint32 = { in: [1, 2, 3] }]; - // } - // ``` - repeated uint32 in = 6 [(predefined).cel = { - id: "uint32.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MyUInt32 { - // // value must not be in list [1, 2, 3] - // uint32 value = 1 [(buf.validate.field).uint32 = { not_in: [1, 2, 3] }]; - // } - // ``` - repeated uint32 not_in = 7 [(predefined).cel = { - id: "uint32.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyUInt32 { - // uint32 value = 1 [ - // (buf.validate.field).uint32.example = 1, - // (buf.validate.field).uint32.example = 10 - // ]; - // } - // ``` - repeated uint32 example = 8 [(predefined).cel = { - id: "uint32.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// UInt64Rules describes the rules applied to `uint64` values. These -// rules may also be applied to the `google.protobuf.UInt64Value` Well-Known-Type. -message UInt64Rules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MyUInt64 { - // // value must equal 42 - // uint64 value = 1 [(buf.validate.field).uint64.const = 42]; - // } - // ``` - optional uint64 const = 1 [(predefined).cel = { - id: "uint64.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field < - // value). If the field value is equal to or greater than the specified value, - // an error message is generated. - // - // ```proto - // message MyUInt64 { - // // value must be less than 10 - // uint64 value = 1 [(buf.validate.field).uint64.lt = 10]; - // } - // ``` - uint64 lt = 2 [(predefined).cel = { - id: "uint64.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MyUInt64 { - // // value must be less than or equal to 10 - // uint64 value = 1 [(buf.validate.field).uint64.lte = 10]; - // } - // ``` - uint64 lte = 3 [(predefined).cel = { - id: "uint64.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyUInt64 { - // // value must be greater than 5 [uint64.gt] - // uint64 value = 1 [(buf.validate.field).uint64.gt = 5]; - // - // // value must be greater than 5 and less than 10 [uint64.gt_lt] - // uint64 other_value = 2 [(buf.validate.field).uint64 = { gt: 5, lt: 10 }]; - // - // // value must be greater than 10 or less than 5 [uint64.gt_lt_exclusive] - // uint64 another_value = 3 [(buf.validate.field).uint64 = { gt: 10, lt: 5 }]; - // } - // ``` - uint64 gt = 4 [ - (predefined).cel = { - id: "uint64.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "uint64.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "uint64.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "uint64.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "uint64.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyUInt64 { - // // value must be greater than or equal to 5 [uint64.gte] - // uint64 value = 1 [(buf.validate.field).uint64.gte = 5]; - // - // // value must be greater than or equal to 5 and less than 10 [uint64.gte_lt] - // uint64 other_value = 2 [(buf.validate.field).uint64 = { gte: 5, lt: 10 }]; - // - // // value must be greater than or equal to 10 or less than 5 [uint64.gte_lt_exclusive] - // uint64 another_value = 3 [(buf.validate.field).uint64 = { gte: 10, lt: 5 }]; - // } - // ``` - uint64 gte = 5 [ - (predefined).cel = { - id: "uint64.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "uint64.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "uint64.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "uint64.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "uint64.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message is - // generated. - // - // ```proto - // message MyUInt64 { - // // value must be in list [1, 2, 3] - // uint64 value = 1 [(buf.validate.field).uint64 = { in: [1, 2, 3] }]; - // } - // ``` - repeated uint64 in = 6 [(predefined).cel = { - id: "uint64.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MyUInt64 { - // // value must not be in list [1, 2, 3] - // uint64 value = 1 [(buf.validate.field).uint64 = { not_in: [1, 2, 3] }]; - // } - // ``` - repeated uint64 not_in = 7 [(predefined).cel = { - id: "uint64.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyUInt64 { - // uint64 value = 1 [ - // (buf.validate.field).uint64.example = 1, - // (buf.validate.field).uint64.example = -10 - // ]; - // } - // ``` - repeated uint64 example = 8 [(predefined).cel = { - id: "uint64.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// SInt32Rules describes the rules applied to `sint32` values. -message SInt32Rules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MySInt32 { - // // value must equal 42 - // sint32 value = 1 [(buf.validate.field).sint32.const = 42]; - // } - // ``` - optional sint32 const = 1 [(predefined).cel = { - id: "sint32.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field - // < value). If the field value is equal to or greater than the specified - // value, an error message is generated. - // - // ```proto - // message MySInt32 { - // // value must be less than 10 - // sint32 value = 1 [(buf.validate.field).sint32.lt = 10]; - // } - // ``` - sint32 lt = 2 [(predefined).cel = { - id: "sint32.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MySInt32 { - // // value must be less than or equal to 10 - // sint32 value = 1 [(buf.validate.field).sint32.lte = 10]; - // } - // ``` - sint32 lte = 3 [(predefined).cel = { - id: "sint32.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MySInt32 { - // // value must be greater than 5 [sint32.gt] - // sint32 value = 1 [(buf.validate.field).sint32.gt = 5]; - // - // // value must be greater than 5 and less than 10 [sint32.gt_lt] - // sint32 other_value = 2 [(buf.validate.field).sint32 = { gt: 5, lt: 10 }]; - // - // // value must be greater than 10 or less than 5 [sint32.gt_lt_exclusive] - // sint32 another_value = 3 [(buf.validate.field).sint32 = { gt: 10, lt: 5 }]; - // } - // ``` - sint32 gt = 4 [ - (predefined).cel = { - id: "sint32.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "sint32.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sint32.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sint32.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "sint32.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MySInt32 { - // // value must be greater than or equal to 5 [sint32.gte] - // sint32 value = 1 [(buf.validate.field).sint32.gte = 5]; - // - // // value must be greater than or equal to 5 and less than 10 [sint32.gte_lt] - // sint32 other_value = 2 [(buf.validate.field).sint32 = { gte: 5, lt: 10 }]; - // - // // value must be greater than or equal to 10 or less than 5 [sint32.gte_lt_exclusive] - // sint32 another_value = 3 [(buf.validate.field).sint32 = { gte: 10, lt: 5 }]; - // } - // ``` - sint32 gte = 5 [ - (predefined).cel = { - id: "sint32.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "sint32.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sint32.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sint32.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "sint32.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message is - // generated. - // - // ```proto - // message MySInt32 { - // // value must be in list [1, 2, 3] - // sint32 value = 1 [(buf.validate.field).sint32 = { in: [1, 2, 3] }]; - // } - // ``` - repeated sint32 in = 6 [(predefined).cel = { - id: "sint32.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MySInt32 { - // // value must not be in list [1, 2, 3] - // sint32 value = 1 [(buf.validate.field).sint32 = { not_in: [1, 2, 3] }]; - // } - // ``` - repeated sint32 not_in = 7 [(predefined).cel = { - id: "sint32.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MySInt32 { - // sint32 value = 1 [ - // (buf.validate.field).sint32.example = 1, - // (buf.validate.field).sint32.example = -10 - // ]; - // } - // ``` - repeated sint32 example = 8 [(predefined).cel = { - id: "sint32.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// SInt64Rules describes the rules applied to `sint64` values. -message SInt64Rules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MySInt64 { - // // value must equal 42 - // sint64 value = 1 [(buf.validate.field).sint64.const = 42]; - // } - // ``` - optional sint64 const = 1 [(predefined).cel = { - id: "sint64.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field - // < value). If the field value is equal to or greater than the specified - // value, an error message is generated. - // - // ```proto - // message MySInt64 { - // // value must be less than 10 - // sint64 value = 1 [(buf.validate.field).sint64.lt = 10]; - // } - // ``` - sint64 lt = 2 [(predefined).cel = { - id: "sint64.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MySInt64 { - // // value must be less than or equal to 10 - // sint64 value = 1 [(buf.validate.field).sint64.lte = 10]; - // } - // ``` - sint64 lte = 3 [(predefined).cel = { - id: "sint64.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MySInt64 { - // // value must be greater than 5 [sint64.gt] - // sint64 value = 1 [(buf.validate.field).sint64.gt = 5]; - // - // // value must be greater than 5 and less than 10 [sint64.gt_lt] - // sint64 other_value = 2 [(buf.validate.field).sint64 = { gt: 5, lt: 10 }]; - // - // // value must be greater than 10 or less than 5 [sint64.gt_lt_exclusive] - // sint64 another_value = 3 [(buf.validate.field).sint64 = { gt: 10, lt: 5 }]; - // } - // ``` - sint64 gt = 4 [ - (predefined).cel = { - id: "sint64.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "sint64.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sint64.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sint64.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "sint64.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MySInt64 { - // // value must be greater than or equal to 5 [sint64.gte] - // sint64 value = 1 [(buf.validate.field).sint64.gte = 5]; - // - // // value must be greater than or equal to 5 and less than 10 [sint64.gte_lt] - // sint64 other_value = 2 [(buf.validate.field).sint64 = { gte: 5, lt: 10 }]; - // - // // value must be greater than or equal to 10 or less than 5 [sint64.gte_lt_exclusive] - // sint64 another_value = 3 [(buf.validate.field).sint64 = { gte: 10, lt: 5 }]; - // } - // ``` - sint64 gte = 5 [ - (predefined).cel = { - id: "sint64.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "sint64.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sint64.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sint64.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "sint64.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message - // is generated. - // - // ```proto - // message MySInt64 { - // // value must be in list [1, 2, 3] - // sint64 value = 1 [(buf.validate.field).sint64 = { in: [1, 2, 3] }]; - // } - // ``` - repeated sint64 in = 6 [(predefined).cel = { - id: "sint64.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MySInt64 { - // // value must not be in list [1, 2, 3] - // sint64 value = 1 [(buf.validate.field).sint64 = { not_in: [1, 2, 3] }]; - // } - // ``` - repeated sint64 not_in = 7 [(predefined).cel = { - id: "sint64.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MySInt64 { - // sint64 value = 1 [ - // (buf.validate.field).sint64.example = 1, - // (buf.validate.field).sint64.example = -10 - // ]; - // } - // ``` - repeated sint64 example = 8 [(predefined).cel = { - id: "sint64.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// Fixed32Rules describes the rules applied to `fixed32` values. -message Fixed32Rules { - // `const` requires the field value to exactly match the specified value. - // If the field value doesn't match, an error message is generated. - // - // ```proto - // message MyFixed32 { - // // value must equal 42 - // fixed32 value = 1 [(buf.validate.field).fixed32.const = 42]; - // } - // ``` - optional fixed32 const = 1 [(predefined).cel = { - id: "fixed32.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field < - // value). If the field value is equal to or greater than the specified value, - // an error message is generated. - // - // ```proto - // message MyFixed32 { - // // value must be less than 10 - // fixed32 value = 1 [(buf.validate.field).fixed32.lt = 10]; - // } - // ``` - fixed32 lt = 2 [(predefined).cel = { - id: "fixed32.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MyFixed32 { - // // value must be less than or equal to 10 - // fixed32 value = 1 [(buf.validate.field).fixed32.lte = 10]; - // } - // ``` - fixed32 lte = 3 [(predefined).cel = { - id: "fixed32.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyFixed32 { - // // value must be greater than 5 [fixed32.gt] - // fixed32 value = 1 [(buf.validate.field).fixed32.gt = 5]; - // - // // value must be greater than 5 and less than 10 [fixed32.gt_lt] - // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gt: 5, lt: 10 }]; - // - // // value must be greater than 10 or less than 5 [fixed32.gt_lt_exclusive] - // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gt: 10, lt: 5 }]; - // } - // ``` - fixed32 gt = 4 [ - (predefined).cel = { - id: "fixed32.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "fixed32.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "fixed32.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "fixed32.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "fixed32.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyFixed32 { - // // value must be greater than or equal to 5 [fixed32.gte] - // fixed32 value = 1 [(buf.validate.field).fixed32.gte = 5]; - // - // // value must be greater than or equal to 5 and less than 10 [fixed32.gte_lt] - // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gte: 5, lt: 10 }]; - // - // // value must be greater than or equal to 10 or less than 5 [fixed32.gte_lt_exclusive] - // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gte: 10, lt: 5 }]; - // } - // ``` - fixed32 gte = 5 [ - (predefined).cel = { - id: "fixed32.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "fixed32.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "fixed32.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "fixed32.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "fixed32.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message - // is generated. - // - // ```proto - // message MyFixed32 { - // // value must be in list [1, 2, 3] - // fixed32 value = 1 [(buf.validate.field).fixed32 = { in: [1, 2, 3] }]; - // } - // ``` - repeated fixed32 in = 6 [(predefined).cel = { - id: "fixed32.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MyFixed32 { - // // value must not be in list [1, 2, 3] - // fixed32 value = 1 [(buf.validate.field).fixed32 = { not_in: [1, 2, 3] }]; - // } - // ``` - repeated fixed32 not_in = 7 [(predefined).cel = { - id: "fixed32.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyFixed32 { - // fixed32 value = 1 [ - // (buf.validate.field).fixed32.example = 1, - // (buf.validate.field).fixed32.example = 2 - // ]; - // } - // ``` - repeated fixed32 example = 8 [(predefined).cel = { - id: "fixed32.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// Fixed64Rules describes the rules applied to `fixed64` values. -message Fixed64Rules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MyFixed64 { - // // value must equal 42 - // fixed64 value = 1 [(buf.validate.field).fixed64.const = 42]; - // } - // ``` - optional fixed64 const = 1 [(predefined).cel = { - id: "fixed64.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field < - // value). If the field value is equal to or greater than the specified value, - // an error message is generated. - // - // ```proto - // message MyFixed64 { - // // value must be less than 10 - // fixed64 value = 1 [(buf.validate.field).fixed64.lt = 10]; - // } - // ``` - fixed64 lt = 2 [(predefined).cel = { - id: "fixed64.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MyFixed64 { - // // value must be less than or equal to 10 - // fixed64 value = 1 [(buf.validate.field).fixed64.lte = 10]; - // } - // ``` - fixed64 lte = 3 [(predefined).cel = { - id: "fixed64.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyFixed64 { - // // value must be greater than 5 [fixed64.gt] - // fixed64 value = 1 [(buf.validate.field).fixed64.gt = 5]; - // - // // value must be greater than 5 and less than 10 [fixed64.gt_lt] - // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gt: 5, lt: 10 }]; - // - // // value must be greater than 10 or less than 5 [fixed64.gt_lt_exclusive] - // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gt: 10, lt: 5 }]; - // } - // ``` - fixed64 gt = 4 [ - (predefined).cel = { - id: "fixed64.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "fixed64.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "fixed64.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "fixed64.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "fixed64.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyFixed64 { - // // value must be greater than or equal to 5 [fixed64.gte] - // fixed64 value = 1 [(buf.validate.field).fixed64.gte = 5]; - // - // // value must be greater than or equal to 5 and less than 10 [fixed64.gte_lt] - // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gte: 5, lt: 10 }]; - // - // // value must be greater than or equal to 10 or less than 5 [fixed64.gte_lt_exclusive] - // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gte: 10, lt: 5 }]; - // } - // ``` - fixed64 gte = 5 [ - (predefined).cel = { - id: "fixed64.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "fixed64.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "fixed64.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "fixed64.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "fixed64.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message is - // generated. - // - // ```proto - // message MyFixed64 { - // // value must be in list [1, 2, 3] - // fixed64 value = 1 [(buf.validate.field).fixed64 = { in: [1, 2, 3] }]; - // } - // ``` - repeated fixed64 in = 6 [(predefined).cel = { - id: "fixed64.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MyFixed64 { - // // value must not be in list [1, 2, 3] - // fixed64 value = 1 [(buf.validate.field).fixed64 = { not_in: [1, 2, 3] }]; - // } - // ``` - repeated fixed64 not_in = 7 [(predefined).cel = { - id: "fixed64.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyFixed64 { - // fixed64 value = 1 [ - // (buf.validate.field).fixed64.example = 1, - // (buf.validate.field).fixed64.example = 2 - // ]; - // } - // ``` - repeated fixed64 example = 8 [(predefined).cel = { - id: "fixed64.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// SFixed32Rules describes the rules applied to `fixed32` values. -message SFixed32Rules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MySFixed32 { - // // value must equal 42 - // sfixed32 value = 1 [(buf.validate.field).sfixed32.const = 42]; - // } - // ``` - optional sfixed32 const = 1 [(predefined).cel = { - id: "sfixed32.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field < - // value). If the field value is equal to or greater than the specified value, - // an error message is generated. - // - // ```proto - // message MySFixed32 { - // // value must be less than 10 - // sfixed32 value = 1 [(buf.validate.field).sfixed32.lt = 10]; - // } - // ``` - sfixed32 lt = 2 [(predefined).cel = { - id: "sfixed32.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MySFixed32 { - // // value must be less than or equal to 10 - // sfixed32 value = 1 [(buf.validate.field).sfixed32.lte = 10]; - // } - // ``` - sfixed32 lte = 3 [(predefined).cel = { - id: "sfixed32.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MySFixed32 { - // // value must be greater than 5 [sfixed32.gt] - // sfixed32 value = 1 [(buf.validate.field).sfixed32.gt = 5]; - // - // // value must be greater than 5 and less than 10 [sfixed32.gt_lt] - // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gt: 5, lt: 10 }]; - // - // // value must be greater than 10 or less than 5 [sfixed32.gt_lt_exclusive] - // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gt: 10, lt: 5 }]; - // } - // ``` - sfixed32 gt = 4 [ - (predefined).cel = { - id: "sfixed32.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "sfixed32.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sfixed32.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sfixed32.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "sfixed32.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MySFixed32 { - // // value must be greater than or equal to 5 [sfixed32.gte] - // sfixed32 value = 1 [(buf.validate.field).sfixed32.gte = 5]; - // - // // value must be greater than or equal to 5 and less than 10 [sfixed32.gte_lt] - // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gte: 5, lt: 10 }]; - // - // // value must be greater than or equal to 10 or less than 5 [sfixed32.gte_lt_exclusive] - // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gte: 10, lt: 5 }]; - // } - // ``` - sfixed32 gte = 5 [ - (predefined).cel = { - id: "sfixed32.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "sfixed32.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sfixed32.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sfixed32.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "sfixed32.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message is - // generated. - // - // ```proto - // message MySFixed32 { - // // value must be in list [1, 2, 3] - // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { in: [1, 2, 3] }]; - // } - // ``` - repeated sfixed32 in = 6 [(predefined).cel = { - id: "sfixed32.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MySFixed32 { - // // value must not be in list [1, 2, 3] - // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { not_in: [1, 2, 3] }]; - // } - // ``` - repeated sfixed32 not_in = 7 [(predefined).cel = { - id: "sfixed32.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MySFixed32 { - // sfixed32 value = 1 [ - // (buf.validate.field).sfixed32.example = 1, - // (buf.validate.field).sfixed32.example = 2 - // ]; - // } - // ``` - repeated sfixed32 example = 8 [(predefined).cel = { - id: "sfixed32.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// SFixed64Rules describes the rules applied to `fixed64` values. -message SFixed64Rules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MySFixed64 { - // // value must equal 42 - // sfixed64 value = 1 [(buf.validate.field).sfixed64.const = 42]; - // } - // ``` - optional sfixed64 const = 1 [(predefined).cel = { - id: "sfixed64.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` requires the field value to be less than the specified value (field < - // value). If the field value is equal to or greater than the specified value, - // an error message is generated. - // - // ```proto - // message MySFixed64 { - // // value must be less than 10 - // sfixed64 value = 1 [(buf.validate.field).sfixed64.lt = 10]; - // } - // ``` - sfixed64 lt = 2 [(predefined).cel = { - id: "sfixed64.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` requires the field value to be less than or equal to the specified - // value (field <= value). If the field value is greater than the specified - // value, an error message is generated. - // - // ```proto - // message MySFixed64 { - // // value must be less than or equal to 10 - // sfixed64 value = 1 [(buf.validate.field).sfixed64.lte = 10]; - // } - // ``` - sfixed64 lte = 3 [(predefined).cel = { - id: "sfixed64.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the field value to be greater than the specified value - // (exclusive). If the value of `gt` is larger than a specified `lt` or - // `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MySFixed64 { - // // value must be greater than 5 [sfixed64.gt] - // sfixed64 value = 1 [(buf.validate.field).sfixed64.gt = 5]; - // - // // value must be greater than 5 and less than 10 [sfixed64.gt_lt] - // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gt: 5, lt: 10 }]; - // - // // value must be greater than 10 or less than 5 [sfixed64.gt_lt_exclusive] - // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gt: 10, lt: 5 }]; - // } - // ``` - sfixed64 gt = 4 [ - (predefined).cel = { - id: "sfixed64.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "sfixed64.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sfixed64.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sfixed64.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "sfixed64.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the field value to be greater than or equal to the specified - // value (exclusive). If the value of `gte` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MySFixed64 { - // // value must be greater than or equal to 5 [sfixed64.gte] - // sfixed64 value = 1 [(buf.validate.field).sfixed64.gte = 5]; - // - // // value must be greater than or equal to 5 and less than 10 [sfixed64.gte_lt] - // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gte: 5, lt: 10 }]; - // - // // value must be greater than or equal to 10 or less than 5 [sfixed64.gte_lt_exclusive] - // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gte: 10, lt: 5 }]; - // } - // ``` - sfixed64 gte = 5 [ - (predefined).cel = { - id: "sfixed64.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "sfixed64.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sfixed64.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "sfixed64.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "sfixed64.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` requires the field value to be equal to one of the specified values. - // If the field value isn't one of the specified values, an error message is - // generated. - // - // ```proto - // message MySFixed64 { - // // value must be in list [1, 2, 3] - // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { in: [1, 2, 3] }]; - // } - // ``` - repeated sfixed64 in = 6 [(predefined).cel = { - id: "sfixed64.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to not be equal to any of the specified - // values. If the field value is one of the specified values, an error - // message is generated. - // - // ```proto - // message MySFixed64 { - // // value must not be in list [1, 2, 3] - // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { not_in: [1, 2, 3] }]; - // } - // ``` - repeated sfixed64 not_in = 7 [(predefined).cel = { - id: "sfixed64.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MySFixed64 { - // sfixed64 value = 1 [ - // (buf.validate.field).sfixed64.example = 1, - // (buf.validate.field).sfixed64.example = 2 - // ]; - // } - // ``` - repeated sfixed64 example = 8 [(predefined).cel = { - id: "sfixed64.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// BoolRules describes the rules applied to `bool` values. These rules -// may also be applied to the `google.protobuf.BoolValue` Well-Known-Type. -message BoolRules { - // `const` requires the field value to exactly match the specified boolean value. - // If the field value doesn't match, an error message is generated. - // - // ```proto - // message MyBool { - // // value must equal true - // bool value = 1 [(buf.validate.field).bool.const = true]; - // } - // ``` - optional bool const = 1 [(predefined).cel = { - id: "bool.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyBool { - // bool value = 1 [ - // (buf.validate.field).bool.example = 1, - // (buf.validate.field).bool.example = 2 - // ]; - // } - // ``` - repeated bool example = 2 [(predefined).cel = { - id: "bool.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// StringRules describes the rules applied to `string` values These -// rules may also be applied to the `google.protobuf.StringValue` Well-Known-Type. -message StringRules { - // `const` requires the field value to exactly match the specified value. If - // the field value doesn't match, an error message is generated. - // - // ```proto - // message MyString { - // // value must equal `hello` - // string value = 1 [(buf.validate.field).string.const = "hello"]; - // } - // ``` - optional string const = 1 [(predefined).cel = { - id: "string.const" - expression: "this != getField(rules, 'const') ? 'value must equal `%s`'.format([getField(rules, 'const')]) : ''" - }]; - - // `len` dictates that the field value must have the specified - // number of characters (Unicode code points), which may differ from the number - // of bytes in the string. If the field value does not meet the specified - // length, an error message will be generated. - // - // ```proto - // message MyString { - // // value length must be 5 characters - // string value = 1 [(buf.validate.field).string.len = 5]; - // } - // ``` - optional uint64 len = 19 [(predefined).cel = { - id: "string.len" - expression: "uint(this.size()) != rules.len ? 'value length must be %s characters'.format([rules.len]) : ''" - }]; - - // `min_len` specifies that the field value must have at least the specified - // number of characters (Unicode code points), which may differ from the number - // of bytes in the string. If the field value contains fewer characters, an error - // message will be generated. - // - // ```proto - // message MyString { - // // value length must be at least 3 characters - // string value = 1 [(buf.validate.field).string.min_len = 3]; - // } - // ``` - optional uint64 min_len = 2 [(predefined).cel = { - id: "string.min_len" - expression: "uint(this.size()) < rules.min_len ? 'value length must be at least %s characters'.format([rules.min_len]) : ''" - }]; - - // `max_len` specifies that the field value must have no more than the specified - // number of characters (Unicode code points), which may differ from the - // number of bytes in the string. If the field value contains more characters, - // an error message will be generated. - // - // ```proto - // message MyString { - // // value length must be at most 10 characters - // string value = 1 [(buf.validate.field).string.max_len = 10]; - // } - // ``` - optional uint64 max_len = 3 [(predefined).cel = { - id: "string.max_len" - expression: "uint(this.size()) > rules.max_len ? 'value length must be at most %s characters'.format([rules.max_len]) : ''" - }]; - - // `len_bytes` dictates that the field value must have the specified number of - // bytes. If the field value does not match the specified length in bytes, - // an error message will be generated. - // - // ```proto - // message MyString { - // // value length must be 6 bytes - // string value = 1 [(buf.validate.field).string.len_bytes = 6]; - // } - // ``` - optional uint64 len_bytes = 20 [(predefined).cel = { - id: "string.len_bytes" - expression: "uint(bytes(this).size()) != rules.len_bytes ? 'value length must be %s bytes'.format([rules.len_bytes]) : ''" - }]; - - // `min_bytes` specifies that the field value must have at least the specified - // number of bytes. If the field value contains fewer bytes, an error message - // will be generated. - // - // ```proto - // message MyString { - // // value length must be at least 4 bytes - // string value = 1 [(buf.validate.field).string.min_bytes = 4]; - // } - // - // ``` - optional uint64 min_bytes = 4 [(predefined).cel = { - id: "string.min_bytes" - expression: "uint(bytes(this).size()) < rules.min_bytes ? 'value length must be at least %s bytes'.format([rules.min_bytes]) : ''" - }]; - - // `max_bytes` specifies that the field value must have no more than the - //specified number of bytes. If the field value contains more bytes, an - // error message will be generated. - // - // ```proto - // message MyString { - // // value length must be at most 8 bytes - // string value = 1 [(buf.validate.field).string.max_bytes = 8]; - // } - // ``` - optional uint64 max_bytes = 5 [(predefined).cel = { - id: "string.max_bytes" - expression: "uint(bytes(this).size()) > rules.max_bytes ? 'value length must be at most %s bytes'.format([rules.max_bytes]) : ''" - }]; - - // `pattern` specifies that the field value must match the specified - // regular expression (RE2 syntax), with the expression provided without any - // delimiters. If the field value doesn't match the regular expression, an - // error message will be generated. - // - // ```proto - // message MyString { - // // value does not match regex pattern `^[a-zA-Z]//$` - // string value = 1 [(buf.validate.field).string.pattern = "^[a-zA-Z]//$"]; - // } - // ``` - optional string pattern = 6 [(predefined).cel = { - id: "string.pattern" - expression: "!this.matches(rules.pattern) ? 'value does not match regex pattern `%s`'.format([rules.pattern]) : ''" - }]; - - // `prefix` specifies that the field value must have the - //specified substring at the beginning of the string. If the field value - // doesn't start with the specified prefix, an error message will be - // generated. - // - // ```proto - // message MyString { - // // value does not have prefix `pre` - // string value = 1 [(buf.validate.field).string.prefix = "pre"]; - // } - // ``` - optional string prefix = 7 [(predefined).cel = { - id: "string.prefix" - expression: "!this.startsWith(rules.prefix) ? 'value does not have prefix `%s`'.format([rules.prefix]) : ''" - }]; - - // `suffix` specifies that the field value must have the - //specified substring at the end of the string. If the field value doesn't - // end with the specified suffix, an error message will be generated. - // - // ```proto - // message MyString { - // // value does not have suffix `post` - // string value = 1 [(buf.validate.field).string.suffix = "post"]; - // } - // ``` - optional string suffix = 8 [(predefined).cel = { - id: "string.suffix" - expression: "!this.endsWith(rules.suffix) ? 'value does not have suffix `%s`'.format([rules.suffix]) : ''" - }]; - - // `contains` specifies that the field value must have the - //specified substring anywhere in the string. If the field value doesn't - // contain the specified substring, an error message will be generated. - // - // ```proto - // message MyString { - // // value does not contain substring `inside`. - // string value = 1 [(buf.validate.field).string.contains = "inside"]; - // } - // ``` - optional string contains = 9 [(predefined).cel = { - id: "string.contains" - expression: "!this.contains(rules.contains) ? 'value does not contain substring `%s`'.format([rules.contains]) : ''" - }]; - - // `not_contains` specifies that the field value must not have the - //specified substring anywhere in the string. If the field value contains - // the specified substring, an error message will be generated. - // - // ```proto - // message MyString { - // // value contains substring `inside`. - // string value = 1 [(buf.validate.field).string.not_contains = "inside"]; - // } - // ``` - optional string not_contains = 23 [(predefined).cel = { - id: "string.not_contains" - expression: "this.contains(rules.not_contains) ? 'value contains substring `%s`'.format([rules.not_contains]) : ''" - }]; - - // `in` specifies that the field value must be equal to one of the specified - // values. If the field value isn't one of the specified values, an error - // message will be generated. - // - // ```proto - // message MyString { - // // value must be in list ["apple", "banana"] - // string value = 1 [(buf.validate.field).string.in = "apple", (buf.validate.field).string.in = "banana"]; - // } - // ``` - repeated string in = 10 [(predefined).cel = { - id: "string.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` specifies that the field value cannot be equal to any - // of the specified values. If the field value is one of the specified values, - // an error message will be generated. - // ```proto - // message MyString { - // // value must not be in list ["orange", "grape"] - // string value = 1 [(buf.validate.field).string.not_in = "orange", (buf.validate.field).string.not_in = "grape"]; - // } - // ``` - repeated string not_in = 11 [(predefined).cel = { - id: "string.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `WellKnown` rules provide advanced rules against common string - // patterns. - oneof well_known { - // `email` specifies that the field value must be a valid email address, for - // example "foo@example.com". - // - // Conforms to the definition for a valid email address from the [HTML standard](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address). - // Note that this standard willfully deviates from [RFC 5322](https://datatracker.ietf.org/doc/html/rfc5322), - // which allows many unexpected forms of email addresses and will easily match - // a typographical error. - // - // If the field value isn't a valid email address, an error message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid email address - // string value = 1 [(buf.validate.field).string.email = true]; - // } - // ``` - bool email = 12 [ - (predefined).cel = { - id: "string.email" - message: "value must be a valid email address" - expression: "!rules.email || this == '' || this.isEmail()" - }, - (predefined).cel = { - id: "string.email_empty" - message: "value is empty, which is not a valid email address" - expression: "!rules.email || this != ''" - } - ]; - - // `hostname` specifies that the field value must be a valid hostname, for - // example "foo.example.com". - // - // A valid hostname follows the rules below: - // - The name consists of one or more labels, separated by a dot ("."). - // - Each label can be 1 to 63 alphanumeric characters. - // - A label can contain hyphens ("-"), but must not start or end with a hyphen. - // - The right-most label must not be digits only. - // - The name can have a trailing dot—for example, "foo.example.com.". - // - The name can be 253 characters at most, excluding the optional trailing dot. - // - // If the field value isn't a valid hostname, an error message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid hostname - // string value = 1 [(buf.validate.field).string.hostname = true]; - // } - // ``` - bool hostname = 13 [ - (predefined).cel = { - id: "string.hostname" - message: "value must be a valid hostname" - expression: "!rules.hostname || this == '' || this.isHostname()" - }, - (predefined).cel = { - id: "string.hostname_empty" - message: "value is empty, which is not a valid hostname" - expression: "!rules.hostname || this != ''" - } - ]; - - // `ip` specifies that the field value must be a valid IP (v4 or v6) address. - // - // IPv4 addresses are expected in the dotted decimal format—for example, "192.168.5.21". - // IPv6 addresses are expected in their text representation—for example, "::1", - // or "2001:0DB8:ABCD:0012::0". - // - // Both formats are well-defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). - // Zone identifiers for IPv6 addresses (for example, "fe80::a%en1") are supported. - // - // If the field value isn't a valid IP address, an error message will be - // generated. - // - // ```proto - // message MyString { - // // value must be a valid IP address - // string value = 1 [(buf.validate.field).string.ip = true]; - // } - // ``` - bool ip = 14 [ - (predefined).cel = { - id: "string.ip" - message: "value must be a valid IP address" - expression: "!rules.ip || this == '' || this.isIp()" - }, - (predefined).cel = { - id: "string.ip_empty" - message: "value is empty, which is not a valid IP address" - expression: "!rules.ip || this != ''" - } - ]; - - // `ipv4` specifies that the field value must be a valid IPv4 address—for - // example "192.168.5.21". If the field value isn't a valid IPv4 address, an - // error message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid IPv4 address - // string value = 1 [(buf.validate.field).string.ipv4 = true]; - // } - // ``` - bool ipv4 = 15 [ - (predefined).cel = { - id: "string.ipv4" - message: "value must be a valid IPv4 address" - expression: "!rules.ipv4 || this == '' || this.isIp(4)" - }, - (predefined).cel = { - id: "string.ipv4_empty" - message: "value is empty, which is not a valid IPv4 address" - expression: "!rules.ipv4 || this != ''" - } - ]; - - // `ipv6` specifies that the field value must be a valid IPv6 address—for - // example "::1", or "d7a:115c:a1e0:ab12:4843:cd96:626b:430b". If the field - // value is not a valid IPv6 address, an error message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid IPv6 address - // string value = 1 [(buf.validate.field).string.ipv6 = true]; - // } - // ``` - bool ipv6 = 16 [ - (predefined).cel = { - id: "string.ipv6" - message: "value must be a valid IPv6 address" - expression: "!rules.ipv6 || this == '' || this.isIp(6)" - }, - (predefined).cel = { - id: "string.ipv6_empty" - message: "value is empty, which is not a valid IPv6 address" - expression: "!rules.ipv6 || this != ''" - } - ]; - - // `uri` specifies that the field value must be a valid URI, for example - // "https://example.com/foo/bar?baz=quux#frag". - // - // URI is defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). - // Zone Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)). - // - // If the field value isn't a valid URI, an error message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid URI - // string value = 1 [(buf.validate.field).string.uri = true]; - // } - // ``` - bool uri = 17 [ - (predefined).cel = { - id: "string.uri" - message: "value must be a valid URI" - expression: "!rules.uri || this == '' || this.isUri()" - }, - (predefined).cel = { - id: "string.uri_empty" - message: "value is empty, which is not a valid URI" - expression: "!rules.uri || this != ''" - } - ]; - - // `uri_ref` specifies that the field value must be a valid URI Reference—either - // a URI such as "https://example.com/foo/bar?baz=quux#frag", or a Relative - // Reference such as "./foo/bar?query". - // - // URI, URI Reference, and Relative Reference are defined in the internet - // standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). Zone - // Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)). - // - // If the field value isn't a valid URI Reference, an error message will be - // generated. - // - // ```proto - // message MyString { - // // value must be a valid URI Reference - // string value = 1 [(buf.validate.field).string.uri_ref = true]; - // } - // ``` - bool uri_ref = 18 [(predefined).cel = { - id: "string.uri_ref" - message: "value must be a valid URI Reference" - expression: "!rules.uri_ref || this.isUriRef()" - }]; - - // `address` specifies that the field value must be either a valid hostname - // (for example, "example.com"), or a valid IP (v4 or v6) address (for example, - // "192.168.0.1", or "::1"). If the field value isn't a valid hostname or IP, - // an error message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid hostname, or ip address - // string value = 1 [(buf.validate.field).string.address = true]; - // } - // ``` - bool address = 21 [ - (predefined).cel = { - id: "string.address" - message: "value must be a valid hostname, or ip address" - expression: "!rules.address || this == '' || this.isHostname() || this.isIp()" - }, - (predefined).cel = { - id: "string.address_empty" - message: "value is empty, which is not a valid hostname, or ip address" - expression: "!rules.address || this != ''" - } - ]; - - // `uuid` specifies that the field value must be a valid UUID as defined by - // [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). If the - // field value isn't a valid UUID, an error message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid UUID - // string value = 1 [(buf.validate.field).string.uuid = true]; - // } - // ``` - bool uuid = 22 [ - (predefined).cel = { - id: "string.uuid" - message: "value must be a valid UUID" - expression: "!rules.uuid || this == '' || this.matches('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')" - }, - (predefined).cel = { - id: "string.uuid_empty" - message: "value is empty, which is not a valid UUID" - expression: "!rules.uuid || this != ''" - } - ]; - - // `tuuid` (trimmed UUID) specifies that the field value must be a valid UUID as - // defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2) with all dashes - // omitted. If the field value isn't a valid UUID without dashes, an error message - // will be generated. - // - // ```proto - // message MyString { - // // value must be a valid trimmed UUID - // string value = 1 [(buf.validate.field).string.tuuid = true]; - // } - // ``` - bool tuuid = 33 [ - (predefined).cel = { - id: "string.tuuid" - message: "value must be a valid trimmed UUID" - expression: "!rules.tuuid || this == '' || this.matches('^[0-9a-fA-F]{32}$')" - }, - (predefined).cel = { - id: "string.tuuid_empty" - message: "value is empty, which is not a valid trimmed UUID" - expression: "!rules.tuuid || this != ''" - } - ]; - - // `ip_with_prefixlen` specifies that the field value must be a valid IP - // (v4 or v6) address with prefix length—for example, "192.168.5.21/16" or - // "2001:0DB8:ABCD:0012::F1/64". If the field value isn't a valid IP with - // prefix length, an error message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid IP with prefix length - // string value = 1 [(buf.validate.field).string.ip_with_prefixlen = true]; - // } - // ``` - bool ip_with_prefixlen = 26 [ - (predefined).cel = { - id: "string.ip_with_prefixlen" - message: "value must be a valid IP prefix" - expression: "!rules.ip_with_prefixlen || this == '' || this.isIpPrefix()" - }, - (predefined).cel = { - id: "string.ip_with_prefixlen_empty" - message: "value is empty, which is not a valid IP prefix" - expression: "!rules.ip_with_prefixlen || this != ''" - } - ]; - - // `ipv4_with_prefixlen` specifies that the field value must be a valid - // IPv4 address with prefix length—for example, "192.168.5.21/16". If the - // field value isn't a valid IPv4 address with prefix length, an error - // message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid IPv4 address with prefix length - // string value = 1 [(buf.validate.field).string.ipv4_with_prefixlen = true]; - // } - // ``` - bool ipv4_with_prefixlen = 27 [ - (predefined).cel = { - id: "string.ipv4_with_prefixlen" - message: "value must be a valid IPv4 address with prefix length" - expression: "!rules.ipv4_with_prefixlen || this == '' || this.isIpPrefix(4)" - }, - (predefined).cel = { - id: "string.ipv4_with_prefixlen_empty" - message: "value is empty, which is not a valid IPv4 address with prefix length" - expression: "!rules.ipv4_with_prefixlen || this != ''" - } - ]; - - // `ipv6_with_prefixlen` specifies that the field value must be a valid - // IPv6 address with prefix length—for example, "2001:0DB8:ABCD:0012::F1/64". - // If the field value is not a valid IPv6 address with prefix length, - // an error message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid IPv6 address prefix length - // string value = 1 [(buf.validate.field).string.ipv6_with_prefixlen = true]; - // } - // ``` - bool ipv6_with_prefixlen = 28 [ - (predefined).cel = { - id: "string.ipv6_with_prefixlen" - message: "value must be a valid IPv6 address with prefix length" - expression: "!rules.ipv6_with_prefixlen || this == '' || this.isIpPrefix(6)" - }, - (predefined).cel = { - id: "string.ipv6_with_prefixlen_empty" - message: "value is empty, which is not a valid IPv6 address with prefix length" - expression: "!rules.ipv6_with_prefixlen || this != ''" - } - ]; - - // `ip_prefix` specifies that the field value must be a valid IP (v4 or v6) - // prefix—for example, "192.168.0.0/16" or "2001:0DB8:ABCD:0012::0/64". - // - // The prefix must have all zeros for the unmasked bits. For example, - // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the - // prefix, and the remaining 64 bits must be zero. - // - // If the field value isn't a valid IP prefix, an error message will be - // generated. - // - // ```proto - // message MyString { - // // value must be a valid IP prefix - // string value = 1 [(buf.validate.field).string.ip_prefix = true]; - // } - // ``` - bool ip_prefix = 29 [ - (predefined).cel = { - id: "string.ip_prefix" - message: "value must be a valid IP prefix" - expression: "!rules.ip_prefix || this == '' || this.isIpPrefix(true)" - }, - (predefined).cel = { - id: "string.ip_prefix_empty" - message: "value is empty, which is not a valid IP prefix" - expression: "!rules.ip_prefix || this != ''" - } - ]; - - // `ipv4_prefix` specifies that the field value must be a valid IPv4 - // prefix, for example "192.168.0.0/16". - // - // The prefix must have all zeros for the unmasked bits. For example, - // "192.168.0.0/16" designates the left-most 16 bits for the prefix, - // and the remaining 16 bits must be zero. - // - // If the field value isn't a valid IPv4 prefix, an error message - // will be generated. - // - // ```proto - // message MyString { - // // value must be a valid IPv4 prefix - // string value = 1 [(buf.validate.field).string.ipv4_prefix = true]; - // } - // ``` - bool ipv4_prefix = 30 [ - (predefined).cel = { - id: "string.ipv4_prefix" - message: "value must be a valid IPv4 prefix" - expression: "!rules.ipv4_prefix || this == '' || this.isIpPrefix(4, true)" - }, - (predefined).cel = { - id: "string.ipv4_prefix_empty" - message: "value is empty, which is not a valid IPv4 prefix" - expression: "!rules.ipv4_prefix || this != ''" - } - ]; - - // `ipv6_prefix` specifies that the field value must be a valid IPv6 prefix—for - // example, "2001:0DB8:ABCD:0012::0/64". - // - // The prefix must have all zeros for the unmasked bits. For example, - // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the - // prefix, and the remaining 64 bits must be zero. - // - // If the field value is not a valid IPv6 prefix, an error message will be - // generated. - // - // ```proto - // message MyString { - // // value must be a valid IPv6 prefix - // string value = 1 [(buf.validate.field).string.ipv6_prefix = true]; - // } - // ``` - bool ipv6_prefix = 31 [ - (predefined).cel = { - id: "string.ipv6_prefix" - message: "value must be a valid IPv6 prefix" - expression: "!rules.ipv6_prefix || this == '' || this.isIpPrefix(6, true)" - }, - (predefined).cel = { - id: "string.ipv6_prefix_empty" - message: "value is empty, which is not a valid IPv6 prefix" - expression: "!rules.ipv6_prefix || this != ''" - } - ]; - - // `host_and_port` specifies that the field value must be valid host/port - // pair—for example, "example.com:8080". - // - // The host can be one of: - //- An IPv4 address in dotted decimal format—for example, "192.168.5.21". - //- An IPv6 address enclosed in square brackets—for example, "[2001:0DB8:ABCD:0012::F1]". - //- A hostname—for example, "example.com". - // - // The port is separated by a colon. It must be non-empty, with a decimal number - // in the range of 0-65535, inclusive. - bool host_and_port = 32 [ - (predefined).cel = { - id: "string.host_and_port" - message: "value must be a valid host (hostname or IP address) and port pair" - expression: "!rules.host_and_port || this == '' || this.isHostAndPort(true)" - }, - (predefined).cel = { - id: "string.host_and_port_empty" - message: "value is empty, which is not a valid host and port pair" - expression: "!rules.host_and_port || this != ''" - } - ]; - - // `well_known_regex` specifies a common well-known pattern - // defined as a regex. If the field value doesn't match the well-known - // regex, an error message will be generated. - // - // ```proto - // message MyString { - // // value must be a valid HTTP header value - // string value = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_VALUE]; - // } - // ``` - // - // #### KnownRegex - // - // `well_known_regex` contains some well-known patterns. - // - // | Name | Number | Description | - // |-------------------------------|--------|-------------------------------------------| - // | KNOWN_REGEX_UNSPECIFIED | 0 | | - // | KNOWN_REGEX_HTTP_HEADER_NAME | 1 | HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2) | - // | KNOWN_REGEX_HTTP_HEADER_VALUE | 2 | HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4) | - KnownRegex well_known_regex = 24 [ - (predefined).cel = { - id: "string.well_known_regex.header_name" - message: "value must be a valid HTTP header name" - expression: - "rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?" - "'^:?[0-9a-zA-Z!#$%&\\'*+-.^_|~\\x60]+$' :" - "'^[^\\u0000\\u000A\\u000D]+$')" - }, - (predefined).cel = { - id: "string.well_known_regex.header_name_empty" - message: "value is empty, which is not a valid HTTP header name" - expression: "rules.well_known_regex != 1 || this != ''" - }, - (predefined).cel = { - id: "string.well_known_regex.header_value" - message: "value must be a valid HTTP header value" - expression: - "rules.well_known_regex != 2 || this.matches(!has(rules.strict) || rules.strict ?" - "'^[^\\u0000-\\u0008\\u000A-\\u001F\\u007F]*$' :" - "'^[^\\u0000\\u000A\\u000D]*$')" - } - ]; - } - - // This applies to regexes `HTTP_HEADER_NAME` and `HTTP_HEADER_VALUE` to - // enable strict header validation. By default, this is true, and HTTP header - // validations are [RFC-compliant](https://datatracker.ietf.org/doc/html/rfc7230#section-3). Setting to false will enable looser - // validations that only disallow `\r\n\0` characters, which can be used to - // bypass header matching rules. - // - // ```proto - // message MyString { - // // The field `value` must have be a valid HTTP headers, but not enforced with strict rules. - // string value = 1 [(buf.validate.field).string.strict = false]; - // } - // ``` - optional bool strict = 25; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyString { - // string value = 1 [ - // (buf.validate.field).string.example = "hello", - // (buf.validate.field).string.example = "world" - // ]; - // } - // ``` - repeated string example = 34 [(predefined).cel = { - id: "string.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// WellKnownRegex contain some well-known patterns. -enum KnownRegex { - KNOWN_REGEX_UNSPECIFIED = 0; - - // HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2). - KNOWN_REGEX_HTTP_HEADER_NAME = 1; - - // HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4). - KNOWN_REGEX_HTTP_HEADER_VALUE = 2; -} - -// BytesRules describe the rules applied to `bytes` values. These rules -// may also be applied to the `google.protobuf.BytesValue` Well-Known-Type. -message BytesRules { - // `const` requires the field value to exactly match the specified bytes - // value. If the field value doesn't match, an error message is generated. - // - // ```proto - // message MyBytes { - // // value must be "\x01\x02\x03\x04" - // bytes value = 1 [(buf.validate.field).bytes.const = "\x01\x02\x03\x04"]; - // } - // ``` - optional bytes const = 1 [(predefined).cel = { - id: "bytes.const" - expression: "this != getField(rules, 'const') ? 'value must be %x'.format([getField(rules, 'const')]) : ''" - }]; - - // `len` requires the field value to have the specified length in bytes. - // If the field value doesn't match, an error message is generated. - // - // ```proto - // message MyBytes { - // // value length must be 4 bytes. - // optional bytes value = 1 [(buf.validate.field).bytes.len = 4]; - // } - // ``` - optional uint64 len = 13 [(predefined).cel = { - id: "bytes.len" - expression: "uint(this.size()) != rules.len ? 'value length must be %s bytes'.format([rules.len]) : ''" - }]; - - // `min_len` requires the field value to have at least the specified minimum - // length in bytes. - // If the field value doesn't meet the requirement, an error message is generated. - // - // ```proto - // message MyBytes { - // // value length must be at least 2 bytes. - // optional bytes value = 1 [(buf.validate.field).bytes.min_len = 2]; - // } - // ``` - optional uint64 min_len = 2 [(predefined).cel = { - id: "bytes.min_len" - expression: "uint(this.size()) < rules.min_len ? 'value length must be at least %s bytes'.format([rules.min_len]) : ''" - }]; - - // `max_len` requires the field value to have at most the specified maximum - // length in bytes. - // If the field value exceeds the requirement, an error message is generated. - // - // ```proto - // message MyBytes { - // // value must be at most 6 bytes. - // optional bytes value = 1 [(buf.validate.field).bytes.max_len = 6]; - // } - // ``` - optional uint64 max_len = 3 [(predefined).cel = { - id: "bytes.max_len" - expression: "uint(this.size()) > rules.max_len ? 'value must be at most %s bytes'.format([rules.max_len]) : ''" - }]; - - // `pattern` requires the field value to match the specified regular - // expression ([RE2 syntax](https://github.com/google/re2/wiki/Syntax)). - // The value of the field must be valid UTF-8 or validation will fail with a - // runtime error. - // If the field value doesn't match the pattern, an error message is generated. - // - // ```proto - // message MyBytes { - // // value must match regex pattern "^[a-zA-Z0-9]+$". - // optional bytes value = 1 [(buf.validate.field).bytes.pattern = "^[a-zA-Z0-9]+$"]; - // } - // ``` - optional string pattern = 4 [(predefined).cel = { - id: "bytes.pattern" - expression: "!string(this).matches(rules.pattern) ? 'value must match regex pattern `%s`'.format([rules.pattern]) : ''" - }]; - - // `prefix` requires the field value to have the specified bytes at the - // beginning of the string. - // If the field value doesn't meet the requirement, an error message is generated. - // - // ```proto - // message MyBytes { - // // value does not have prefix \x01\x02 - // optional bytes value = 1 [(buf.validate.field).bytes.prefix = "\x01\x02"]; - // } - // ``` - optional bytes prefix = 5 [(predefined).cel = { - id: "bytes.prefix" - expression: "!this.startsWith(rules.prefix) ? 'value does not have prefix %x'.format([rules.prefix]) : ''" - }]; - - // `suffix` requires the field value to have the specified bytes at the end - // of the string. - // If the field value doesn't meet the requirement, an error message is generated. - // - // ```proto - // message MyBytes { - // // value does not have suffix \x03\x04 - // optional bytes value = 1 [(buf.validate.field).bytes.suffix = "\x03\x04"]; - // } - // ``` - optional bytes suffix = 6 [(predefined).cel = { - id: "bytes.suffix" - expression: "!this.endsWith(rules.suffix) ? 'value does not have suffix %x'.format([rules.suffix]) : ''" - }]; - - // `contains` requires the field value to have the specified bytes anywhere in - // the string. - // If the field value doesn't meet the requirement, an error message is generated. - // - // ```protobuf - // message MyBytes { - // // value does not contain \x02\x03 - // optional bytes value = 1 [(buf.validate.field).bytes.contains = "\x02\x03"]; - // } - // ``` - optional bytes contains = 7 [(predefined).cel = { - id: "bytes.contains" - expression: "!this.contains(rules.contains) ? 'value does not contain %x'.format([rules.contains]) : ''" - }]; - - // `in` requires the field value to be equal to one of the specified - // values. If the field value doesn't match any of the specified values, an - // error message is generated. - // - // ```protobuf - // message MyBytes { - // // value must in ["\x01\x02", "\x02\x03", "\x03\x04"] - // optional bytes value = 1 [(buf.validate.field).bytes.in = {"\x01\x02", "\x02\x03", "\x03\x04"}]; - // } - // ``` - repeated bytes in = 8 [(predefined).cel = { - id: "bytes.in" - expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to be not equal to any of the specified - // values. - // If the field value matches any of the specified values, an error message is - // generated. - // - // ```proto - // message MyBytes { - // // value must not in ["\x01\x02", "\x02\x03", "\x03\x04"] - // optional bytes value = 1 [(buf.validate.field).bytes.not_in = {"\x01\x02", "\x02\x03", "\x03\x04"}]; - // } - // ``` - repeated bytes not_in = 9 [(predefined).cel = { - id: "bytes.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // WellKnown rules provide advanced rules against common byte - // patterns - oneof well_known { - // `ip` ensures that the field `value` is a valid IP address (v4 or v6) in byte format. - // If the field value doesn't meet this rule, an error message is generated. - // - // ```proto - // message MyBytes { - // // value must be a valid IP address - // optional bytes value = 1 [(buf.validate.field).bytes.ip = true]; - // } - // ``` - bool ip = 10 [ - (predefined).cel = { - id: "bytes.ip" - message: "value must be a valid IP address" - expression: "!rules.ip || this.size() == 0 || this.size() == 4 || this.size() == 16" - }, - (predefined).cel = { - id: "bytes.ip_empty" - message: "value is empty, which is not a valid IP address" - expression: "!rules.ip || this.size() != 0" - } - ]; - - // `ipv4` ensures that the field `value` is a valid IPv4 address in byte format. - // If the field value doesn't meet this rule, an error message is generated. - // - // ```proto - // message MyBytes { - // // value must be a valid IPv4 address - // optional bytes value = 1 [(buf.validate.field).bytes.ipv4 = true]; - // } - // ``` - bool ipv4 = 11 [ - (predefined).cel = { - id: "bytes.ipv4" - message: "value must be a valid IPv4 address" - expression: "!rules.ipv4 || this.size() == 0 || this.size() == 4" - }, - (predefined).cel = { - id: "bytes.ipv4_empty" - message: "value is empty, which is not a valid IPv4 address" - expression: "!rules.ipv4 || this.size() != 0" - } - ]; - - // `ipv6` ensures that the field `value` is a valid IPv6 address in byte format. - // If the field value doesn't meet this rule, an error message is generated. - // ```proto - // message MyBytes { - // // value must be a valid IPv6 address - // optional bytes value = 1 [(buf.validate.field).bytes.ipv6 = true]; - // } - // ``` - bool ipv6 = 12 [ - (predefined).cel = { - id: "bytes.ipv6" - message: "value must be a valid IPv6 address" - expression: "!rules.ipv6 || this.size() == 0 || this.size() == 16" - }, - (predefined).cel = { - id: "bytes.ipv6_empty" - message: "value is empty, which is not a valid IPv6 address" - expression: "!rules.ipv6 || this.size() != 0" - } - ]; - } - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyBytes { - // bytes value = 1 [ - // (buf.validate.field).bytes.example = "\x01\x02", - // (buf.validate.field).bytes.example = "\x02\x03" - // ]; - // } - // ``` - repeated bytes example = 14 [(predefined).cel = { - id: "bytes.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// EnumRules describe the rules applied to `enum` values. -message EnumRules { - // `const` requires the field value to exactly match the specified enum value. - // If the field value doesn't match, an error message is generated. - // - // ```proto - // enum MyEnum { - // MY_ENUM_UNSPECIFIED = 0; - // MY_ENUM_VALUE1 = 1; - // MY_ENUM_VALUE2 = 2; - // } - // - // message MyMessage { - // // The field `value` must be exactly MY_ENUM_VALUE1. - // MyEnum value = 1 [(buf.validate.field).enum.const = 1]; - // } - // ``` - optional int32 const = 1 [(predefined).cel = { - id: "enum.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - - // `defined_only` requires the field value to be one of the defined values for - // this enum, failing on any undefined value. - // - // ```proto - // enum MyEnum { - // MY_ENUM_UNSPECIFIED = 0; - // MY_ENUM_VALUE1 = 1; - // MY_ENUM_VALUE2 = 2; - // } - // - // message MyMessage { - // // The field `value` must be a defined value of MyEnum. - // MyEnum value = 1 [(buf.validate.field).enum.defined_only = true]; - // } - // ``` - optional bool defined_only = 2; - - // `in` requires the field value to be equal to one of the - //specified enum values. If the field value doesn't match any of the - //specified values, an error message is generated. - // - // ```proto - // enum MyEnum { - // MY_ENUM_UNSPECIFIED = 0; - // MY_ENUM_VALUE1 = 1; - // MY_ENUM_VALUE2 = 2; - // } - // - // message MyMessage { - // // The field `value` must be equal to one of the specified values. - // MyEnum value = 1 [(buf.validate.field).enum = { in: [1, 2]}]; - // } - // ``` - repeated int32 in = 3 [(predefined).cel = { - id: "enum.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` requires the field value to be not equal to any of the - //specified enum values. If the field value matches one of the specified - // values, an error message is generated. - // - // ```proto - // enum MyEnum { - // MY_ENUM_UNSPECIFIED = 0; - // MY_ENUM_VALUE1 = 1; - // MY_ENUM_VALUE2 = 2; - // } - // - // message MyMessage { - // // The field `value` must not be equal to any of the specified values. - // MyEnum value = 1 [(buf.validate.field).enum = { not_in: [1, 2]}]; - // } - // ``` - repeated int32 not_in = 4 [(predefined).cel = { - id: "enum.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // enum MyEnum { - // MY_ENUM_UNSPECIFIED = 0; - // MY_ENUM_VALUE1 = 1; - // MY_ENUM_VALUE2 = 2; - // } - // - // message MyMessage { - // (buf.validate.field).enum.example = 1, - // (buf.validate.field).enum.example = 2 - // } - // ``` - repeated int32 example = 5 [(predefined).cel = { - id: "enum.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// RepeatedRules describe the rules applied to `repeated` values. -message RepeatedRules { - // `min_items` requires that this field must contain at least the specified - // minimum number of items. - // - // Note that `min_items = 1` is equivalent to setting a field as `required`. - // - // ```proto - // message MyRepeated { - // // value must contain at least 2 items - // repeated string value = 1 [(buf.validate.field).repeated.min_items = 2]; - // } - // ``` - optional uint64 min_items = 1 [(predefined).cel = { - id: "repeated.min_items" - expression: "uint(this.size()) < rules.min_items ? 'value must contain at least %d item(s)'.format([rules.min_items]) : ''" - }]; - - // `max_items` denotes that this field must not exceed a - // certain number of items as the upper limit. If the field contains more - // items than specified, an error message will be generated, requiring the - // field to maintain no more than the specified number of items. - // - // ```proto - // message MyRepeated { - // // value must contain no more than 3 item(s) - // repeated string value = 1 [(buf.validate.field).repeated.max_items = 3]; - // } - // ``` - optional uint64 max_items = 2 [(predefined).cel = { - id: "repeated.max_items" - expression: "uint(this.size()) > rules.max_items ? 'value must contain no more than %s item(s)'.format([rules.max_items]) : ''" - }]; - - // `unique` indicates that all elements in this field must - // be unique. This rule is strictly applicable to scalar and enum - // types, with message types not being supported. - // - // ```proto - // message MyRepeated { - // // repeated value must contain unique items - // repeated string value = 1 [(buf.validate.field).repeated.unique = true]; - // } - // ``` - optional bool unique = 3 [(predefined).cel = { - id: "repeated.unique" - message: "repeated value must contain unique items" - expression: "!rules.unique || this.unique()" - }]; - - // `items` details the rules to be applied to each item - // in the field. Even for repeated message fields, validation is executed - // against each item unless skip is explicitly specified. - // - // ```proto - // message MyRepeated { - // // The items in the field `value` must follow the specified rules. - // repeated string value = 1 [(buf.validate.field).repeated.items = { - // string: { - // min_len: 3 - // max_len: 10 - // } - // }]; - // } - // ``` - optional FieldRules items = 4; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// MapRules describe the rules applied to `map` values. -message MapRules { - //Specifies the minimum number of key-value pairs allowed. If the field has - // fewer key-value pairs than specified, an error message is generated. - // - // ```proto - // message MyMap { - // // The field `value` must have at least 2 key-value pairs. - // map value = 1 [(buf.validate.field).map.min_pairs = 2]; - // } - // ``` - optional uint64 min_pairs = 1 [(predefined).cel = { - id: "map.min_pairs" - expression: "uint(this.size()) < rules.min_pairs ? 'map must be at least %d entries'.format([rules.min_pairs]) : ''" - }]; - - //Specifies the maximum number of key-value pairs allowed. If the field has - // more key-value pairs than specified, an error message is generated. - // - // ```proto - // message MyMap { - // // The field `value` must have at most 3 key-value pairs. - // map value = 1 [(buf.validate.field).map.max_pairs = 3]; - // } - // ``` - optional uint64 max_pairs = 2 [(predefined).cel = { - id: "map.max_pairs" - expression: "uint(this.size()) > rules.max_pairs ? 'map must be at most %d entries'.format([rules.max_pairs]) : ''" - }]; - - //Specifies the rules to be applied to each key in the field. - // - // ```proto - // message MyMap { - // // The keys in the field `value` must follow the specified rules. - // map value = 1 [(buf.validate.field).map.keys = { - // string: { - // min_len: 3 - // max_len: 10 - // } - // }]; - // } - // ``` - optional FieldRules keys = 4; - - //Specifies the rules to be applied to the value of each key in the - // field. Message values will still have their validations evaluated unless - //skip is specified here. - // - // ```proto - // message MyMap { - // // The values in the field `value` must follow the specified rules. - // map value = 1 [(buf.validate.field).map.values = { - // string: { - // min_len: 5 - // max_len: 20 - // } - // }]; - // } - // ``` - optional FieldRules values = 5; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// AnyRules describe rules applied exclusively to the `google.protobuf.Any` well-known type. -message AnyRules { - // `in` requires the field's `type_url` to be equal to one of the - //specified values. If it doesn't match any of the specified values, an error - // message is generated. - // - // ```proto - // message MyAny { - // // The `value` field must have a `type_url` equal to one of the specified values. - // google.protobuf.Any value = 1 [(buf.validate.field).any.in = ["type.googleapis.com/MyType1", "type.googleapis.com/MyType2"]]; - // } - // ``` - repeated string in = 2; - - // requires the field's type_url to be not equal to any of the specified values. If it matches any of the specified values, an error message is generated. - // - // ```proto - // message MyAny { - // // The field `value` must not have a `type_url` equal to any of the specified values. - // google.protobuf.Any value = 1 [(buf.validate.field).any.not_in = ["type.googleapis.com/ForbiddenType1", "type.googleapis.com/ForbiddenType2"]]; - // } - // ``` - repeated string not_in = 3; -} - -// DurationRules describe the rules applied exclusively to the `google.protobuf.Duration` well-known type. -message DurationRules { - // `const` dictates that the field must match the specified value of the `google.protobuf.Duration` type exactly. - // If the field's value deviates from the specified value, an error message - // will be generated. - // - // ```proto - // message MyDuration { - // // value must equal 5s - // google.protobuf.Duration value = 1 [(buf.validate.field).duration.const = "5s"]; - // } - // ``` - optional google.protobuf.Duration const = 2 [(predefined).cel = { - id: "duration.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // `lt` stipulates that the field must be less than the specified value of the `google.protobuf.Duration` type, - // exclusive. If the field's value is greater than or equal to the specified - // value, an error message will be generated. - // - // ```proto - // message MyDuration { - // // value must be less than 5s - // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = "5s"]; - // } - // ``` - google.protobuf.Duration lt = 3 [(predefined).cel = { - id: "duration.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // `lte` indicates that the field must be less than or equal to the specified - // value of the `google.protobuf.Duration` type, inclusive. If the field's value is greater than the specified value, - // an error message will be generated. - // - // ```proto - // message MyDuration { - // // value must be less than or equal to 10s - // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lte = "10s"]; - // } - // ``` - google.protobuf.Duration lte = 4 [(predefined).cel = { - id: "duration.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - } - oneof greater_than { - // `gt` requires the duration field value to be greater than the specified - // value (exclusive). If the value of `gt` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyDuration { - // // duration must be greater than 5s [duration.gt] - // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gt = { seconds: 5 }]; - // - // // duration must be greater than 5s and less than 10s [duration.gt_lt] - // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gt: { seconds: 5 }, lt: { seconds: 10 } }]; - // - // // duration must be greater than 10s or less than 5s [duration.gt_lt_exclusive] - // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gt: { seconds: 10 }, lt: { seconds: 5 } }]; - // } - // ``` - google.protobuf.Duration gt = 5 [ - (predefined).cel = { - id: "duration.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "duration.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "duration.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "duration.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "duration.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the duration field value to be greater than or equal to the - // specified value (exclusive). If the value of `gte` is larger than a - // specified `lt` or `lte`, the range is reversed, and the field value must - // be outside the specified range. If the field value doesn't meet the - // required conditions, an error message is generated. - // - // ```proto - // message MyDuration { - // // duration must be greater than or equal to 5s [duration.gte] - // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gte = { seconds: 5 }]; - // - // // duration must be greater than or equal to 5s and less than 10s [duration.gte_lt] - // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gte: { seconds: 5 }, lt: { seconds: 10 } }]; - // - // // duration must be greater than or equal to 10s or less than 5s [duration.gte_lt_exclusive] - // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gte: { seconds: 10 }, lt: { seconds: 5 } }]; - // } - // ``` - google.protobuf.Duration gte = 6 [ - (predefined).cel = { - id: "duration.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "duration.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "duration.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "duration.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "duration.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - } - - // `in` asserts that the field must be equal to one of the specified values of the `google.protobuf.Duration` type. - // If the field's value doesn't correspond to any of the specified values, - // an error message will be generated. - // - // ```proto - // message MyDuration { - // // value must be in list [1s, 2s, 3s] - // google.protobuf.Duration value = 1 [(buf.validate.field).duration.in = ["1s", "2s", "3s"]]; - // } - // ``` - repeated google.protobuf.Duration in = 7 [(predefined).cel = { - id: "duration.in" - expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" - }]; - - // `not_in` denotes that the field must not be equal to - // any of the specified values of the `google.protobuf.Duration` type. - // If the field's value matches any of these values, an error message will be - // generated. - // - // ```proto - // message MyDuration { - // // value must not be in list [1s, 2s, 3s] - // google.protobuf.Duration value = 1 [(buf.validate.field).duration.not_in = ["1s", "2s", "3s"]]; - // } - // ``` - repeated google.protobuf.Duration not_in = 8 [(predefined).cel = { - id: "duration.not_in" - expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyDuration { - // google.protobuf.Duration value = 1 [ - // (buf.validate.field).duration.example = { seconds: 1 }, - // (buf.validate.field).duration.example = { seconds: 2 }, - // ]; - // } - // ``` - repeated google.protobuf.Duration example = 9 [(predefined).cel = { - id: "duration.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// TimestampRules describe the rules applied exclusively to the `google.protobuf.Timestamp` well-known type. -message TimestampRules { - // `const` dictates that this field, of the `google.protobuf.Timestamp` type, must exactly match the specified value. If the field value doesn't correspond to the specified timestamp, an error message will be generated. - // - // ```proto - // message MyTimestamp { - // // value must equal 2023-05-03T10:00:00Z - // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.const = {seconds: 1727998800}]; - // } - // ``` - optional google.protobuf.Timestamp const = 2 [(predefined).cel = { - id: "timestamp.const" - expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" - }]; - oneof less_than { - // requires the duration field value to be less than the specified value (field < value). If the field value doesn't meet the required conditions, an error message is generated. - // - // ```proto - // message MyDuration { - // // duration must be less than 'P3D' [duration.lt] - // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = { seconds: 259200 }]; - // } - // ``` - google.protobuf.Timestamp lt = 3 [(predefined).cel = { - id: "timestamp.lt" - expression: - "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" - "? 'value must be less than %s'.format([rules.lt]) : ''" - }]; - - // requires the timestamp field value to be less than or equal to the specified value (field <= value). If the field value doesn't meet the required conditions, an error message is generated. - // - // ```proto - // message MyTimestamp { - // // timestamp must be less than or equal to '2023-05-14T00:00:00Z' [timestamp.lte] - // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lte = { seconds: 1678867200 }]; - // } - // ``` - google.protobuf.Timestamp lte = 4 [(predefined).cel = { - id: "timestamp.lte" - expression: - "!has(rules.gte) && !has(rules.gt) && this > rules.lte" - "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" - }]; - - // `lt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be less than the current time. `lt_now` can only be used with the `within` rule. - // - // ```proto - // message MyTimestamp { - // // value must be less than now - // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.lt_now = true]; - // } - // ``` - bool lt_now = 7 [(predefined).cel = { - id: "timestamp.lt_now" - expression: "(rules.lt_now && this > now) ? 'value must be less than now' : ''" - }]; - } - oneof greater_than { - // `gt` requires the timestamp field value to be greater than the specified - // value (exclusive). If the value of `gt` is larger than a specified `lt` - // or `lte`, the range is reversed, and the field value must be outside the - // specified range. If the field value doesn't meet the required conditions, - // an error message is generated. - // - // ```proto - // message MyTimestamp { - // // timestamp must be greater than '2023-01-01T00:00:00Z' [timestamp.gt] - // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gt = { seconds: 1672444800 }]; - // - // // timestamp must be greater than '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gt_lt] - // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gt: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }]; - // - // // timestamp must be greater than '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gt_lt_exclusive] - // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gt: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }]; - // } - // ``` - google.protobuf.Timestamp gt = 5 [ - (predefined).cel = { - id: "timestamp.gt" - expression: - "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" - "? 'value must be greater than %s'.format([rules.gt]) : ''" - }, - (predefined).cel = { - id: "timestamp.gt_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" - "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "timestamp.gt_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" - "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" - }, - (predefined).cel = { - id: "timestamp.gt_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" - "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - }, - (predefined).cel = { - id: "timestamp.gt_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" - "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" - } - ]; - - // `gte` requires the timestamp field value to be greater than or equal to the - // specified value (exclusive). If the value of `gte` is larger than a - // specified `lt` or `lte`, the range is reversed, and the field value - // must be outside the specified range. If the field value doesn't meet - // the required conditions, an error message is generated. - // - // ```proto - // message MyTimestamp { - // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' [timestamp.gte] - // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gte = { seconds: 1672444800 }]; - // - // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gte_lt] - // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gte: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }]; - // - // // timestamp must be greater than or equal to '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gte_lt_exclusive] - // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gte: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }]; - // } - // ``` - google.protobuf.Timestamp gte = 6 [ - (predefined).cel = { - id: "timestamp.gte" - expression: - "!has(rules.lt) && !has(rules.lte) && this < rules.gte" - "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" - }, - (predefined).cel = { - id: "timestamp.gte_lt" - expression: - "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "timestamp.gte_lt_exclusive" - expression: - "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" - }, - (predefined).cel = { - id: "timestamp.gte_lte" - expression: - "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" - "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - }, - (predefined).cel = { - id: "timestamp.gte_lte_exclusive" - expression: - "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" - "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" - } - ]; - - // `gt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be greater than the current time. `gt_now` can only be used with the `within` rule. - // - // ```proto - // message MyTimestamp { - // // value must be greater than now - // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.gt_now = true]; - // } - // ``` - bool gt_now = 8 [(predefined).cel = { - id: "timestamp.gt_now" - expression: "(rules.gt_now && this < now) ? 'value must be greater than now' : ''" - }]; - } - - // `within` specifies that this field, of the `google.protobuf.Timestamp` type, must be within the specified duration of the current time. If the field value isn't within the duration, an error message is generated. - // - // ```proto - // message MyTimestamp { - // // value must be within 1 hour of now - // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.within = {seconds: 3600}]; - // } - // ``` - optional google.protobuf.Duration within = 9 [(predefined).cel = { - id: "timestamp.within" - expression: "this < now-rules.within || this > now+rules.within ? 'value must be within %s of now'.format([rules.within]) : ''" - }]; - - // `example` specifies values that the field may have. These values SHOULD - // conform to other rules. `example` values will not impact validation - // but may be used as helpful guidance on how to populate the given field. - // - // ```proto - // message MyTimestamp { - // google.protobuf.Timestamp value = 1 [ - // (buf.validate.field).timestamp.example = { seconds: 1672444800 }, - // (buf.validate.field).timestamp.example = { seconds: 1672531200 }, - // ]; - // } - // ``` - - repeated google.protobuf.Timestamp example = 10 [(predefined).cel = { - id: "timestamp.example" - expression: "true" - }]; - - // Extension fields in this range that have the (buf.validate.predefined) - // option set will be treated as predefined field rules that can then be - // set on the field options of other fields to apply field rules. - // Extension numbers 1000 to 99999 are reserved for extension numbers that are - // defined in the [Protobuf Global Extension Registry][1]. Extension numbers - // above this range are reserved for extension numbers that are not explicitly - // assigned. For rules defined in publicly-consumed schemas, use of extensions - // above 99999 is discouraged due to the risk of conflicts. - // - // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md - extensions 1000 to max; -} - -// `Violations` is a collection of `Violation` messages. This message type is returned by -// protovalidate when a proto message fails to meet the requirements set by the `Rule` validation rules. -// Each individual violation is represented by a `Violation` message. -message Violations { - // `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected. - repeated Violation violations = 1; -} - -// `Violation` represents a single instance where a validation rule, expressed -// as a `Rule`, was not met. It provides information about the field that -// caused the violation, the specific rule that wasn't fulfilled, and a -// human-readable error message. -// -// ```json -// { -// "fieldPath": "bar", -// "ruleId": "foo.bar", -// "message": "bar must be greater than 0" -// } -// ``` -message Violation { - // `field` is a machine-readable path to the field that failed validation. - // This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation. - // - // For example, consider the following message: - // - // ```proto - // message Message { - // bool a = 1 [(buf.validate.field).required = true]; - // } - // ``` - // - // It could produce the following violation: - // - // ```textproto - // violation { - // field { element { field_number: 1, field_name: "a", field_type: 8 } } - // ... - // } - // ``` - optional FieldPath field = 5; - - // `rule` is a machine-readable path that points to the specific rule rule that failed validation. - // This will be a nested field starting from the FieldRules of the field that failed validation. - // For custom rules, this will provide the path of the rule, e.g. `cel[0]`. - // - // For example, consider the following message: - // - // ```proto - // message Message { - // bool a = 1 [(buf.validate.field).required = true]; - // bool b = 2 [(buf.validate.field).cel = { - // id: "custom_rule", - // expression: "!this ? 'b must be true': ''" - // }] - // } - // ``` - // - // It could produce the following violations: - // - // ```textproto - // violation { - // rule { element { field_number: 25, field_name: "required", field_type: 8 } } - // ... - // } - // violation { - // rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } } - // ... - // } - // ``` - optional FieldPath rule = 6; - - // `rule_id` is the unique identifier of the `Rule` that was not fulfilled. - // This is the same `id` that was specified in the `Rule` message, allowing easy tracing of which rule was violated. - optional string rule_id = 2; - - // `message` is a human-readable error message that describes the nature of the violation. - // This can be the default error message from the violated `Rule`, or it can be a custom message that gives more context about the violation. - optional string message = 3; - - // `for_key` indicates whether the violation was caused by a map key, rather than a value. - optional bool for_key = 4; - - reserved 1; - reserved "field_path"; -} - -// `FieldPath` provides a path to a nested protobuf field. -// -// This message provides enough information to render a dotted field path even without protobuf descriptors. -// It also provides enough information to resolve a nested field through unknown wire data. -message FieldPath { - // `elements` contains each element of the path, starting from the root and recursing downward. - repeated FieldPathElement elements = 1; -} - -// `FieldPathElement` provides enough information to nest through a single protobuf field. -// -// If the selected field is a map or repeated field, the `subscript` value selects a specific element from it. -// A path that refers to a value nested under a map key or repeated field index will have a `subscript` value. -// The `field_type` field allows unambiguous resolution of a field even if descriptors are not available. -message FieldPathElement { - // `field_number` is the field number this path element refers to. - optional int32 field_number = 1; - - // `field_name` contains the field name this path element refers to. - // This can be used to display a human-readable path even if the field number is unknown. - optional string field_name = 2; - - // `field_type` specifies the type of this field. When using reflection, this value is not needed. - // - // This value is provided to make it possible to traverse unknown fields through wire data. - // When traversing wire data, be mindful of both packed[1] and delimited[2] encoding schemes. - // - // [1]: https://protobuf.dev/programming-guides/encoding/#packed - // [2]: https://protobuf.dev/programming-guides/encoding/#groups - // - // N.B.: Although groups are deprecated, the corresponding delimited encoding scheme is not, and - // can be explicitly used in Protocol Buffers 2023 Edition. - optional google.protobuf.FieldDescriptorProto.Type field_type = 3; - - // `key_type` specifies the map key type of this field. This value is useful when traversing - // unknown fields through wire data: specifically, it allows handling the differences between - // different integer encodings. - optional google.protobuf.FieldDescriptorProto.Type key_type = 4; - - // `value_type` specifies map value type of this field. This is useful if you want to display a - // value inside unknown fields through wire data. - optional google.protobuf.FieldDescriptorProto.Type value_type = 5; - - // `subscript` contains a repeated index or map key, if this path element nests into a repeated or map field. - oneof subscript { - // `index` specifies a 0-based index into a repeated field. - uint64 index = 6; - - // `bool_key` specifies a map key of type bool. - bool bool_key = 7; - - // `int_key` specifies a map key of type int32, int64, sint32, sint64, sfixed32 or sfixed64. - int64 int_key = 8; - - // `uint_key` specifies a map key of type uint32, uint64, fixed32 or fixed64. - uint64 uint_key = 9; - - // `string_key` specifies a map key of type string. - string string_key = 10; - } -} diff --git a/third_party/config/v1/cors.proto b/third_party/config/v1/cors.proto deleted file mode 100644 index 98ceca9b..00000000 --- a/third_party/config/v1/cors.proto +++ /dev/null @@ -1,45 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "CorsProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// Cors -message Cors { - // Enabled indicates whether CORS should be enabled for the target. - bool enabled = 1 [json_name = "enabled"]; - // AllowCredentials indicates whether the request can include user credentials like - // cookies, HTTP authentication or client side SSL certificates. - bool allow_credentials = 2 [json_name = "allow_credentials"]; - // AllowOrigins is a list of origins a cross-domain request can be executed from. - // If the special "*" value is present in the list, all origins will be allowed. - // Default value is [*] - repeated string allow_origins = 3 [json_name = "allow_origins"]; - // AllowMethods is a list of methods the client is allowed to use with - // cross-domain requests. Default value is simple methods (GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS) - repeated string allow_methods = 4 [json_name = "allow_methods"]; - // AllowHeaders is list of non simple headers the client is allowed to use with - // cross-domain requests. - repeated string allow_headers = 5 [json_name = "allow_headers"]; - // ExposeHeaders indicates which headers are safe to expose to the API of a CORS - // API specification - repeated string expose_headers = 6 [json_name = "expose_headers"]; - // MaxAge indicates how long (with second-precision) the results of a preflight request - // can be cached - int64 max_age = 7 [json_name = "max_age"]; - // Allows to add origins like http://some-domain/*, https://api.* or http://some.*.subdomain.com - bool allow_wildcard = 8 [json_name = "allow_wildcard"]; - // Allows usage of popular browser extensions schemas - bool allow_browser_extensions = 9 [json_name = "allow_browser_extensions"]; - // Allows usage of WebSocket protocol - bool allow_web_sockets = 10 [json_name = "allow_web_sockets"]; - // Allows usage of private network addresses (127.0.0.1, [::1], localhost) - bool allow_private_network = 11 [json_name = "allow_private_network"]; - // Allows usage of file:// schema (dangerous!) use it only when you 100% sure it's needed - bool allow_files = 12 [json_name = "allow_files"]; -} diff --git a/third_party/config/v1/customize.proto b/third_party/config/v1/customize.proto deleted file mode 100644 index 38191d5a..00000000 --- a/third_party/config/v1/customize.proto +++ /dev/null @@ -1,31 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -import "google/protobuf/any.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "CustomizeProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// Customize -message Customize { - message Config { - // enabled is used to enable or disable the custom config - bool enabled = 1 [json_name = "enabled"]; - // name can be any named with registered names - string name = 2 [json_name = "name"]; - // value can be any type - google.protobuf.Any value = 3 [json_name = "value"]; - } - - // configs is a map of custom configs with type string - repeated Config configs = 1 [json_name = "configs"]; -} - -message CustomizeMap { - map types = 1 [json_name = "types"]; -} diff --git a/third_party/config/v1/discovery.proto b/third_party/config/v1/discovery.proto deleted file mode 100644 index 73221b67..00000000 --- a/third_party/config/v1/discovery.proto +++ /dev/null @@ -1,53 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -import "config/v1/customize.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "RegistryProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// Discovery -message Discovery { - // Consul - message Consul { - string address = 1 [json_name = "address"]; - string scheme = 2 [json_name = "scheme"]; - string token = 3 [json_name = "token"]; - bool heart_beat = 4 [json_name = "heart_beat"]; - bool health_check = 5 [json_name = "health_check"]; - string datacenter = 6 [json_name = "datacenter"]; - // string tag = 7 [json_name = "tag"]; - uint32 health_check_interval = 8 [json_name = "health_check_interval"]; - // string health_check_timeout = 9[json_name = "health_check_timeout"]; - int64 timeout = 10 [json_name = "timeout"]; - uint32 deregister_critical_service_after = 11 [json_name = "deregister_critical_service_after"]; - } - // ETCD - message ETCD { - repeated string endpoints = 1 [json_name = "endpoints"]; - } - - string type = 1 [(validate.rules).string = { - in: [ - "none", - "consul", - "etcd", - "nacos", - "apollo", - "kubernetes", - "polaris" - ] - }]; // Type - string service_name = 2 [json_name = "service_name"]; // ServiceName - bool debug = 5 [json_name = "debug"]; - config.v1.Customize customize = 6 [json_name = "customize"]; - - optional Consul consul = 300 [json_name = "consul"]; // Consul - optional ETCD etcd = 400 [json_name = "etcd"]; // ETCD -} diff --git a/third_party/config/v1/gateway.proto b/third_party/config/v1/gateway.proto deleted file mode 100644 index f6f3847b..00000000 --- a/third_party/config/v1/gateway.proto +++ /dev/null @@ -1,103 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "GatewayProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -message Gateway { - string name = 1; - string version = 2; - repeated string hosts = 3 [deprecated = true]; - repeated Endpoint endpoints = 4; - repeated Middleware middlewares = 5; - map tls_store = 6; -} - -message TLS { - bool insecure = 1; - string cacert = 2; - string cert = 3; - string key = 4; - string server_name = 5; -} - -message PriorityConfig { - string name = 1; - string version = 2; - repeated Endpoint endpoints = 3; -} - -message Endpoint { - string path = 1; - string method = 2; - string description = 3; - Protocol protocol = 4; - int64 timeout = 5; - repeated Middleware middlewares = 6; - repeated Backend backends = 7; - Retry retry = 8; - map metadata = 9; - string host = 10; -} - -message Middleware { - string name = 1; - bytes options = 2; - bool required = 3; -} - -message Backend { - // localhost - // 127.0.0.1:8000 - // discovery:///service_name - string target = 1; - optional int64 weight = 2; - HealthCheck health_check = 3; - bool tls = 4; - string tls_config_name = 5; - map metadata = 6; -} - -enum Protocol { - PROTOCOL_UNSPECIFIED = 0; - PROTOCOL_HTTP = 1; - PROTOCOL_GRPC = 2; - PROTOCOL_CUSTOM = 3; -} - -message HealthCheck { - enum CheckType { - CHECK_TYPE_UNSPECIFIED = 0; - CHECK_TYPE_HTTP = 1; - CHECK_TYPE_TCP = 2; - } - CheckType type = 1; - string endpoint = 2; -} - -message Retry { - // default attempts is 1 - uint32 attempts = 1; - int64 per_try_timeout = 2; - repeated Condition conditions = 3; - // primary,secondary - repeated string priorities = 4; -} - -message Condition { - message Header { - string name = 1; - string value = 2; - } - oneof condition { - // "500-599", "429" - string by_status_code = 1; - // {"name": "grpc-status", "value": "14"} - Header by_header = 2; - } -} diff --git a/third_party/config/v1/logger.proto b/third_party/config/v1/logger.proto deleted file mode 100644 index 419c271d..00000000 --- a/third_party/config/v1/logger.proto +++ /dev/null @@ -1,83 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "LoggerProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// Logger level -enum LoggerLevel { - LOGGER_LEVEL_UNSPECIFIED = 0; - LOGGER_LEVEL_DEBUG = 1; - LOGGER_LEVEL_INFO = 2; - LOGGER_LEVEL_WARN = 3; - LOGGER_LEVEL_ERROR = 4; - LOGGER_LEVEL_FATAL = 5; -} - -// Logger hook message -message LoggerHookMessage { - string level = 1 [json_name = "level"]; - string message = 2 [json_name = "message"]; - string stacktrace = 3 [json_name = "stacktrace"]; - string error = 4 [json_name = "error"]; - map fields = 5 [json_name = "fields"]; -} - -// Logger -message Logger { - // Logger file - message File { - string path = 1 [json_name = "path"]; - bool lumberjack = 2 [json_name = "lumberjack"]; - bool compress = 3 [json_name = "compress"]; - bool local_time = 4 [json_name = "local_time"]; - int32 max_size = 5 [json_name = "max_size"]; - int32 max_age = 6 [json_name = "max_age"]; - int32 max_backups = 7 [json_name = "max_backups"]; - } - - // Dev logger - message DevLogger { - uint32 max_slice = 1 [json_name = "max_slice"]; - bool sort_keys = 2 [json_name = "sort_keys"]; - bool newline = 3 [json_name = "newline"]; - bool indent = 4 [json_name = "indent"]; - uint32 debug_color = 5 [json_name = "debug_color"]; - uint32 info_color = 6 [json_name = "info_color"]; - uint32 warn_color = 7 [json_name = "warn_color"]; - uint32 error_color = 8 [json_name = "error_color"]; - uint32 max_trace = 9 [json_name = "max_trace"]; - bool formatter = 10 [json_name = "formatter"]; - } - - // Disable logger - bool disabled = 1 [json_name = "disabled"]; - // Enable dev logger output - bool develop = 2 [json_name = "develop"]; - // Set default logger - bool default = 3 [json_name = "default"]; - // Logger name - string name = 4 [json_name = "name"]; - // Logger format json text or tint - string format = 5 [json_name = "format"]; - // Logger level - string level = 6 [json_name = "level"]; - // Logger output stdout - bool stdout = 7 [json_name = "stdout"]; - // Disable logger caller - bool disable_caller = 8 [json_name = "disable_caller"]; - // Logger caller skip - uint32 caller_skip = 9 [json_name = "caller_skip"]; - // Logger time format - string time_format = 10 [json_name = "time_format"]; - - // Logger file output config - File file = 100 [json_name = "file"]; - // Logger dev logger config - DevLogger dev_logger = 101 [json_name = "dev_logger"]; //DevLogger -} diff --git a/third_party/config/v1/mail.proto b/third_party/config/v1/mail.proto deleted file mode 100644 index 42f87ed9..00000000 --- a/third_party/config/v1/mail.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "MailProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// Mail -message Mail { - string type = 1 [json_name = "type"]; - string host = 2 [json_name = "host"]; - int32 port = 3 [json_name = "port"]; - string username = 4 [json_name = "username"]; - string password = 5 [json_name = "password"]; - string token_secret = 6 [json_name = "token_secret"]; - bool ssl = 7 [json_name = "ssl"]; - int32 max_retries = 8 [json_name = "max_retries"]; - int64 retry_interval = 9 [json_name = "retry_interval"]; - - string nickname = 100 [json_name = "nickname"]; - string from = 101 [json_name = "from"]; -} diff --git a/third_party/config/v1/message.proto b/third_party/config/v1/message.proto deleted file mode 100644 index cf79c3da..00000000 --- a/third_party/config/v1/message.proto +++ /dev/null @@ -1,104 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "MessageProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// Message -message Message { - // MQTT - message MQTT { - string endpoint = 1 [json_name = "endpoint"]; - string codec = 2 [json_name = "codec"]; - } - - // Kafka - message Kafka { - string endpoint = 1 [json_name = "endpoint"]; - string codec = 2 [json_name = "codec"]; - } - - // RabbitMQ - message RabbitMQ { - string endpoint = 1 [json_name = "endpoint"]; - string codec = 2 [json_name = "codec"]; - } - - message ActiveMQ { - string endpoint = 1 [json_name = "endpoint"]; - string codec = 2 [json_name = "codec"]; - } - - message NATS { - string endpoint = 1 [json_name = "endpoint"]; - string codec = 2 [json_name = "codec"]; - } - - message NSQ { - string endpoint = 1 [json_name = "endpoint"]; - string codec = 2 [json_name = "codec"]; - } - - message Pulsar { - string endpoint = 1 [json_name = "endpoint"]; - string codec = 2 [json_name = "codec"]; - } - - message Redis { - string endpoint = 1 [json_name = "endpoint"]; - string codec = 2 [json_name = "codec"]; - } - - message RocketMQ { - string endpoint = 1 [json_name = "endpoint"]; - string codec = 2 [json_name = "codec"]; - bool enable_trace = 3 [json_name = "enable_trace"]; - - repeated string name_servers = 4 [json_name = "name_servers"]; - string name_server_domain = 5 [json_name = "name_server_domain"]; - - string access_key = 6 [json_name = "access_key"]; - string secret_key = 7 [json_name = "secret_key"]; - string security_token = 8 [json_name = "security_token"]; - - string namespace = 9 [json_name = "namespace"]; - string instance_name = 10 [json_name = "instance_name"]; - string group_name = 11 [json_name = "group_name"]; - } - - string type = 1 [ - json_name = "type", - (validate.rules).string = { - in: [ - "none", - "mqtt", - "kafka", - "rabbitmq", - "activemq", - "nats", - "nsq", - "pulsar", - "redis", - "rocketmq" - ] - } - ]; - // name is for register multiple message service - string name = 2 [json_name = "name"]; - MQTT mqtt = 3 [json_name = "mqtt"]; - Kafka kafka = 4 [json_name = "kafka"]; - RabbitMQ rabbitmq = 5 [json_name = "rabbitmq"]; - ActiveMQ activemq = 6 [json_name = "activemq"]; - NATS nats = 7 [json_name = "nats"]; - NSQ nsq = 8 [json_name = "nsq"]; - Pulsar pulsar = 9 [json_name = "pulsar"]; - Redis redis = 10 [json_name = "redis"]; - RocketMQ rocketmq = 11 [json_name = "rocketmq"]; -} diff --git a/third_party/config/v1/security.proto b/third_party/config/v1/security.proto deleted file mode 100644 index fedbe9e6..00000000 --- a/third_party/config/v1/security.proto +++ /dev/null @@ -1,168 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "SecurityProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// AuthNConfig contains the configuration for authentication middleware. -message AuthNConfig { - // Authorization middleware config - message JWTConfig { - // Algorithm used to sign the token - string algorithm = 3 [json_name = "algorithm"]; - // Signing key - string signing_key = 4 [json_name = "signing_key"]; - // Old signing key - string old_signing_key = 5 [json_name = "old_signing_key"]; - // Token expiration time - int64 expire_time = 6 [json_name = "expire_time"]; - // Token refresh time - int64 refresh_time = 7 [json_name = "refresh_time"]; - // Cache config name from cache service - string cache_name = 8 [json_name = "cache_name"]; - } - // OIDC config for authorization - message OIDCConfig { - // Issuer url - string issuer_url = 2 [json_name = "issuer_url"]; - // Audience - string audience = 3 [json_name = "audience"]; - // Algorithm used to sign the token - string algorithm = 4 [json_name = "algorithm"]; - } - message PreSharedKeyConfig { - // Secret key - repeated string secret_keys = 2 [json_name = "secret_keys"]; - } - message BasicAuthConfig { - // string username = 1; - // string password = 2; - } - message OAuth2Config { - // string client_id = 1; - // string client_secret = 2; - // string token_url = 3; - // string scope = 4; - // string redirect_uri = 5; - } - message LdapConfig { - // string server_url = 1; - // string base_dn = 2; - // string bind_dn = 3; - // string bind_password = 4; - // string search_filter = 5; - } - message X509Config { - // string cert_file = 1; - // string key_file = 2; - // string ca_file = 3; - } - message SamlConfig { - // string idp_metadata_url = 1; - // string sp_entity_id = 2; - // string acs_url = 3; - // string certificate_file = 4; - // string private_key_file = 5; - } - message ApiKeyConfig { - // string api_key = 1; - } - - // Disable security middleware - bool disabled = 1 [json_name = "disabled"]; - // Direct release paths - repeated string public_paths = 2 [json_name = "public_paths"]; - // Type of authentication noop, jwt, oidc, pre_shared_key, etc - string type = 3 [ - json_name = "type", - (validate.rules).string = { - in: [ - "noop", - "jwt", - "oidc", - "pre_shared_key", - "basic_auth", - "oauth2", - "ldap", - "x509", - "saml", - "api_key" - ] - } - ]; - // JWT config for authorization - JWTConfig jwt = 10 [json_name = "jwt"]; - // OIDC config for authorization - OIDCConfig oidc = 11 [json_name = "oidc"]; - // Pre shared key config for authorization - PreSharedKeyConfig pre_shared_key = 12 [json_name = "pre_shared_key"]; - // Customize config -} - -// AuthZConfig contains the configuration for authorization middleware. -message AuthZConfig { - // Casbin middleware config - message CasbinConfig { - // Policy file - string policy_file = 3 [json_name = "policy_file"]; - // Model file - string model_file = 4 [json_name = "model_file"]; - } - message OpaConfig { - // OPA policy file path - string policy_file = 3 [json_name = "policy_file"]; - // OPA data file path - string data_file = 4 [json_name = "data_file"]; - // OPA server URL - string server_url = 5 [json_name = "server_url"]; - // OPA rego file path - string rego_file = 6 [json_name = "rego_file"]; - } - message ZanzibarConfig { - // Zanzibar API endpoint - string api_endpoint = 3 [json_name = "api_endpoint"]; - // Zanzibar namespace - string namespace = 4 [json_name = "namespace"]; - // Zanzibar read consistency - string read_consistency = 5 [json_name = "read_consistency"]; - // Zanzibar write consistency - string write_consistency = 6 [json_name = "write_consistency"]; - } - // Disable security middleware - bool disabled = 1 [json_name = "disabled"]; - // Direct release paths, paths exempt from authorization - repeated string public_paths = 2 [json_name = "public_paths"]; - // Type of authorization noop, casbin, opa, etc - string type = 3 [ - json_name = "type", - (validate.rules).string = { - in: [ - "noop", - "casbin", - "opa", - "zanzibar" - ] - } - ]; - // Casbin config for authorization - CasbinConfig casbin = 11 [json_name = "casbin"]; - // OPA config for authorization - OpaConfig opa = 12 [json_name = "opa"]; - // Zanzibar config for authorization - ZanzibarConfig zanzibar = 13 [json_name = "zanzibar"]; -} - -// Security middleware config. -message Security { - // Direct release paths - repeated string public_paths = 1 [json_name = "public_paths"]; - AuthZConfig authz = 2 [json_name = "authz"]; - AuthNConfig authn = 3 [json_name = "authn"]; -} diff --git a/third_party/config/v1/service.proto b/third_party/config/v1/service.proto deleted file mode 100644 index b911c14a..00000000 --- a/third_party/config/v1/service.proto +++ /dev/null @@ -1,79 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -import "config/v1/message.proto"; -import "config/v1/task.proto"; -import "config/v1/tlsconfig.proto"; -import "config/v1/websocket.proto"; -import "middleware/v1/middleware.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "ServiceProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -message Service { - // HTTP - message HTTP { - string network = 1; - string addr = 2; - bool use_tls = 3 [json_name = "use_tls"]; - config.v1.TLSConfig tls_config = 4 [json_name = "tls_config"]; - int64 timeout = 6 [json_name = "timeout"]; - int64 shutdown_timeout = 7 [json_name = "shutdown_timeout"]; - int64 read_timeout = 8 [json_name = "read_timeout"]; - int64 write_timeout = 9 [json_name = "write_timeout"]; - int64 idle_timeout = 10 [json_name = "idle_timeout"]; - string endpoint = 11 [json_name = "endpoint"]; - } - - // GRPC - message GRPC { - string network = 1; - string addr = 2; - bool use_tls = 3 [json_name = "use_tls"]; - config.v1.TLSConfig tls_config = 4 [json_name = "tls_config"]; - int64 timeout = 6 [json_name = "timeout"]; - int64 shutdown_timeout = 7 [json_name = "shutdown_timeout"]; - int64 read_timeout = 8 [json_name = "read_timeout"]; - int64 write_timeout = 9 [json_name = "write_timeout"]; - int64 idle_timeout = 10 [json_name = "idle_timeout"]; - string endpoint = 11 [json_name = "endpoint"]; - } - - // Selector - message Selector { - string version = 1; - string builder = 2; - } - // Service name for service discovery - string name = 1 [json_name = "name"]; - string type = 2 [ - json_name = "type", - (validate.rules).string = { - in: [ - "http", - "grpc", - "websocket", - "message", - "task" - ] - } - ]; - bool dynamic_endpoint = 3 [json_name = "dynamic_endpoint"]; - string version = 4 [json_name = "version"]; - - GRPC grpc = 10 [json_name = "grpc"]; - HTTP http = 20 [json_name = "http"]; - - config.v1.WebSocket websocket = 100 [json_name = "websocket"]; - config.v1.Message message = 200 [json_name = "message"]; - config.v1.Task task = 300 [json_name = "task"]; - - middleware.v1.Middleware middleware = 400 [json_name = "middleware"]; - Selector selector = 500 [json_name = "selector"]; -} diff --git a/third_party/config/v1/source.proto b/third_party/config/v1/source.proto deleted file mode 100644 index 363d8a11..00000000 --- a/third_party/config/v1/source.proto +++ /dev/null @@ -1,82 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -import "config/v1/customize.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "SourceConfigProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// SourceConfig is the source file for load configuration -message SourceConfig { - // File - message File { - string path = 1 [json_name = "path"]; - string format = 2 [json_name = "format"]; - repeated string ignores = 3 [json_name = "ignores"]; - } - // Consul - message Consul { - string address = 1 [json_name = "address"]; - string scheme = 2 [json_name = "scheme"]; - string token = 3 [json_name = "token"]; - string path = 4 [json_name = "path"]; - // bool heart_beat = 4 [json_name = "heart_beat"]; - // bool health_check = 5 [json_name = "health_check"]; - // string datacenter = 6 [json_name = "datacenter"]; - // string tag = 7 [json_name = "tag"]; - // string health_check_interval = 8 [json_name = "health_check_interval"]; - // string health_check_timeout = 9[json_name = "health_check_timeout"]; - } - // ETCD - message ETCD { - repeated string endpoints = 1 [json_name = "endpoints"]; - } - - message Nacos {} - message Apollo {} - - message Kubernetes {} - - message Polaris {} - - repeated string types = 1 [ - json_name = "types", - (validate.rules).repeated.items.string = { - in: [ - "file", - "apollo", - "consul", - "etcd", - "kubernetes", - "nacos", - "polaris", - "customize" - ] - } - ]; // Type - // name - string name = 2 [json_name = "name"]; - string version = 3 [json_name = "version"]; - // set the supported file format, if not set, all formats are supported - repeated string formats = 4 [json_name = "formats"]; - bool env = 5 [json_name = "env"]; - // set the environment variable name - map env_args = 6 [json_name = "env_args"]; - // set the environment variable prefix - repeated string env_prefixes = 7 [json_name = "env_prefixes"]; - - optional File file = 100 [json_name = "file"]; - optional Consul consul = 200 [json_name = "consul"]; - optional ETCD etcd = 300 [json_name = "etcd"]; - optional Nacos nacos = 400 [json_name = "nacos"]; // Nacos - optional Apollo apollo = 500 [json_name = "apollo"]; // Apollo - optional Kubernetes kubernetes = 600 [json_name = "kubernetes"]; // Kubernetes - optional Polaris polaris = 700 [json_name = "polaris"]; // Polaris - optional config.v1.Customize customize = 800 [json_name = "customize"]; // Customize -} diff --git a/third_party/config/v1/storage.proto b/third_party/config/v1/storage.proto deleted file mode 100644 index bdd6169e..00000000 --- a/third_party/config/v1/storage.proto +++ /dev/null @@ -1,368 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -import "gnostic/openapi/v3/annotations.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "StorageProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -message Migration { - bool enabled = 1 [ - json_name = "enabled", - (gnostic.openapi.v3.property) = {description: "whether to enable migration"} - ]; - string path = 2 [ - json_name = "path", - (gnostic.openapi.v3.property) = {description: "migration path"} - ]; - repeated string names = 3 [ - json_name = "names", - (gnostic.openapi.v3.property) = {description: "migration name"} - ]; - string version = 4 [ - json_name = "version", - (gnostic.openapi.v3.property) = {description: "migration version"} - ]; - string mode = 5 [ - json_name = "mode", - (gnostic.openapi.v3.property) = {description: "migration mode"} - ]; -} - -// Database -message Database { - // Debugging - bool debug = 1 [ - json_name = "debug", - (gnostic.openapi.v3.property) = {description: "whether to enable debug mode "} - ]; - // Dialect name: mysql, postgresql, mongodb, sqlite...... - string dialect = 2 [ - json_name = "dialect", - (validate.rules).string = { - in: [ - "mssql", - "mysql", - "postgresql", - "mongodb", - "sqlite", - "oracle", - "sqlserver", - "sqlite3" - ] - }, - (gnostic.openapi.v3.property) = {description: "database driver name"} - ]; - // Data source (DSN string) - string source = 3 [ - json_name = "source", - (gnostic.openapi.v3.property) = {description: "data source dsn string"} - ]; - // Data migration - Migration migration = 10 [ - json_name = "migration", - (gnostic.openapi.v3.property) = {description: "data migration"} - ]; - // Link tracking switch - bool enable_trace = 12 [ - json_name = "enable_trace", - (gnostic.openapi.v3.property) = {description: "link tracking switch"} - ]; - // Performance analysis switch - bool enable_metrics = 13 [ - json_name = "enable_metrics", - (gnostic.openapi.v3.property) = {description: "performance analysis switch"} - ]; - // Maximum number of free connections in the connection pool - int32 max_idle_connections = 20 [ - json_name = "max_idle_connections", - (gnostic.openapi.v3.property) = {description: "The maximum number of free connections in the connection pool"} - ]; - // Maximum number of open connections in the connection pool - int32 max_open_connections = 21 [ - json_name = "max_open_connections", - (gnostic.openapi.v3.property) = {description: "The maximum number of open connections in the connection pool"} - ]; - // Maximum length of time that the connection can be reused - int64 connection_max_lifetime = 22 [ - json_name = "connection_max_lifetime", - (gnostic.openapi.v3.property) = {description: "The maximum length of time a connection can be reused"} - ]; - // Maximum number of connections in the connection pool for reading - int64 connection_max_idle_time = 23 [ - json_name = "connection_max_idle_time", - (gnostic.openapi.v3.property) = {description: "The maximum number of connections in the connection pool for reading"} - ]; -} - -// Redis -message Redis { - string network = 1 [ - json_name = "network", - (gnostic.openapi.v3.property) = {description: "network type"} - ]; - string addr = 2 [ - json_name = "addr", - (gnostic.openapi.v3.property) = {description: "address"} - ]; - string password = 3 [ - json_name = "password", - (gnostic.openapi.v3.property) = {description: "cipher"} - ]; - int32 db = 4 [ - json_name = "db", - (gnostic.openapi.v3.property) = {description: "database index"} - ]; - int64 dial_timeout = 5 [ - json_name = "dial_timeout", - (validate.rules).int64.gte = 0, - (gnostic.openapi.v3.property) = {description: "dial timeout"} - ]; - int64 read_timeout = 6 [ - json_name = "read_timeout", - (validate.rules).int64.gte = 0, - (gnostic.openapi.v3.property) = {description: "read timeout"} - ]; - int64 write_timeout = 7 [ - json_name = "write_timeout", - (validate.rules).int64.gte = 0, - (gnostic.openapi.v3.property) = {description: "write timeout"} - ]; -} - -// Memcached -message Memcached { - string addr = 1 [ - json_name = "addr", - (gnostic.openapi.v3.property) = {description: "address"} - ]; - string username = 2 [ - json_name = "username", - (gnostic.openapi.v3.property) = {description: "username"} - ]; - string password = 3 [ - json_name = "password", - (gnostic.openapi.v3.property) = {description: "cipher"} - ]; - int32 max_idle = 4 [ - json_name = "max_idle", - (gnostic.openapi.v3.property) = { - description: "maximum number of idle connections" - minimum: 1 - } - ]; - int64 timeout = 5 [ - json_name = "timeout", - (validate.rules).int64.gte = 0, - (gnostic.openapi.v3.property) = {description: "overtime"} - ]; -} - -// Memory -message Memory { - int32 size = 1 [ - json_name = "size", - (gnostic.openapi.v3.property) = {description: "size"} - ]; - int32 capacity = 2 [ - json_name = "capacity", - (gnostic.openapi.v3.property) = {description: "capacity"} - ]; - int64 expiration = 3 [ - json_name = "expiration", - (gnostic.openapi.v3.property) = {description: "expiration time"} - ]; - int64 cleanup_interval = 4 [ - json_name = "cleanup_interval", - (gnostic.openapi.v3.property) = {description: "clearance interval"} - ]; -} - -message BadgerDS { - string path = 1 [ - json_name = "path", - (gnostic.openapi.v3.property) = {description: "path"} - ]; - bool sync_writes = 2 [ - json_name = "sync_writes", - (gnostic.openapi.v3.property) = {description: "synchronous write or not"} - ]; - int32 value_log_file_size = 3 [ - json_name = "value_log_file_size", - (gnostic.openapi.v3.property) = {description: "value log file size"} - ]; - bool in_memory = 4 [ - json_name = "in_memory", - (gnostic.openapi.v3.property) = {description: "in memory or not"} - ]; - uint32 log_level = 5 [ - json_name = "log_level", - (validate.rules).uint32 = { - gte: 0 - lte: 3 - }, - (gnostic.openapi.v3.property) = {description: "log level"} - ]; -} - -// File -message File { - string root = 1 [ - json_name = "root", - (gnostic.openapi.v3.property) = {description: "root directory"} - ]; -} - -// OSS -message Oss { - string endpoint = 1 [ - json_name = "endpoint", - (gnostic.openapi.v3.property) = {description: "Storage service endpoint"} - ]; - string access_key_id = 2 [json_name = "access_key_id"]; - string access_key_secret = 3 [json_name = "access_key_secret"]; - string bucket = 4 [json_name = "bucket"]; - string region = 5 [json_name = "region"]; - bool ssl = 6 [json_name = "ssl"]; - int64 connect_timeout = 7 [ - json_name = "connect_timeout", - (validate.rules).int64.gte = 0, - (gnostic.openapi.v3.property) = {description: "Connection timeout in milliseconds"} - ]; - int64 read_timeout = 8 [ - json_name = "read_timeout", - (validate.rules).int64.gte = 0, - (gnostic.openapi.v3.property) = {description: "Read timeout in milliseconds"} - ]; -} - -// Mongo -message Mongo { - string uri = 1 [ - json_name = "uri", - (gnostic.openapi.v3.property) = {description: "MongoDB connection URI"} - ]; - string database = 2 [ - json_name = "database", - (gnostic.openapi.v3.property) = {description: "Database name"} - ]; - string username = 3 [json_name = "username"]; - string password = 4 [json_name = "password"]; - bool auth_source = 5 [json_name = "auth_source"]; - int32 max_pool_size = 6 [json_name = "max_pool_size"]; - int32 min_pool_size = 7 [json_name = "min_pool_size"]; - int64 connect_timeout = 8 [ - json_name = "connect_timeout", - (validate.rules).int64.gte = 0, - (gnostic.openapi.v3.property) = {description: "Connection timeout in milliseconds"} - ]; -} - -// Cache -message Cache { - // Driver name: redis, memcached, etc. - string driver = 1 [ - json_name = "driver", - (validate.rules).string = { - in: [ - "none", - "redis", - "memcached", - "memory" - ] - }, - (gnostic.openapi.v3.property) = {description: "cache driver name"} - ]; - string name = 2 [ - json_name = "name", - (gnostic.openapi.v3.property) = {description: "cache name"} - ]; - // Memcached - Memcached memcached = 10 [ - json_name = "memcached", - (gnostic.openapi.v3.property) = {description: "memcached cache configuration"} - ]; - // Memory cache - Memory memory = 11 [ - json_name = "memory", - (gnostic.openapi.v3.property) = {description: "memory cache configuration"} - ]; - // Redis - Redis redis = 12 [ - json_name = "redis", - (gnostic.openapi.v3.property) = {description: "redis cache configuration"} - ]; - // Badger - BadgerDS badger = 13 [ - json_name = "badger", - (gnostic.openapi.v3.property) = {description: "badger storage configuration"} - ]; -} - -message Storage { - string name = 1 [ - json_name = "name", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "Unique identifier for the storage configuration"} - ]; - - // Type - string type = 2 [ - json_name = "type", - (validate.rules).string = { - in: [ - "none", - "file", - "redis", - "mongo", - "oss", - "database", - "cache" - ] - }, - (gnostic.openapi.v3.property) = {description: "storage type"} - ]; - - // Database - Database database = 3 [ - json_name = "database", - (gnostic.openapi.v3.property) = {description: "database configuration"} - ]; - // Cache - Cache cache = 4 [ - json_name = "cache", - (gnostic.openapi.v3.property) = {description: "cache configuration"} - ]; - - // File - File file = 10 [ - json_name = "file", - (gnostic.openapi.v3.property) = {description: "file storage configuration"} - ]; - // Redis - Redis redis = 11 [ - json_name = "redis", - (gnostic.openapi.v3.property) = {description: "redis storage configuration"} - ]; - // Badger - BadgerDS badger = 12 [ - json_name = "badger", - (gnostic.openapi.v3.property) = {description: "badger storage configuration"} - ]; - // Mongo - Mongo mongo = 13 [ - json_name = "mongo", - (gnostic.openapi.v3.property) = {description: "mongo storage configuration"} - ]; - // OSS - Oss oss = 14 [ - json_name = "oss", - (gnostic.openapi.v3.property) = {description: "oss storage configuration"} - ]; -} diff --git a/third_party/config/v1/task.proto b/third_party/config/v1/task.proto deleted file mode 100644 index 6e10229a..00000000 --- a/third_party/config/v1/task.proto +++ /dev/null @@ -1,49 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "TaskProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// Task config -message Task { - - // Asynq config - message Asynq { - // endpoint is peer network address - string endpoint = 1; - // login password - string password = 2; - // database index - int32 db = 3; - // timezone location - string location = 4; - } - - // Machinery config - message Machinery { - // brokers address, which can be specified as Redis, AMQP, or AWS SQS according to the actual storage medium used - repeated string brokers = 1; - // backends configures the media for storing results. The value can be Redis, memcached, or mongodb as required - repeated string backends = 2; - } - - // Cron config - message Cron { - // addr is peer network address - string addr = 1; - } - - string type = 1 [json_name = "type", (validate.rules).string = {in: ["none", "asynq", "machinery", "cron"]}]; - string name = 2 [json_name = "name"]; - - Asynq asynq = 3 [json_name = "asynq"]; - Machinery machinery = 4 [json_name = "machinery"]; - Cron cron = 5 [json_name = "cron"]; -} diff --git a/third_party/config/v1/tlsconfig.proto b/third_party/config/v1/tlsconfig.proto deleted file mode 100644 index 3fdb32c1..00000000 --- a/third_party/config/v1/tlsconfig.proto +++ /dev/null @@ -1,28 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "TlsConfigProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// TLSConfig -message TLSConfig { - message File { - string cert = 1; - string key = 2; - string ca = 3; - } - - message PEM { - bytes cert = 1; - bytes key = 2; - bytes ca = 3; - } - - File file = 1 [json_name = "file"]; - PEM pem = 2 [json_name = "pem"]; -} diff --git a/third_party/config/v1/tracer.proto b/third_party/config/v1/tracer.proto deleted file mode 100644 index 0fc6a3d7..00000000 --- a/third_party/config/v1/tracer.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "TraceProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -// Trace config. -message Trace { - // name of trace service - string name = 2 [json_name = "name"]; - // endpoint is the endpoint of trace service - string endpoint = 3 [json_name = "endpoint"]; -} diff --git a/third_party/config/v1/websocket.proto b/third_party/config/v1/websocket.proto deleted file mode 100644 index 47a7eec6..00000000 --- a/third_party/config/v1/websocket.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package config.v1; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/config/v1;configv1"; -option java_multiple_files = true; -option java_outer_classname = "WebSocketProto"; -option java_package = "com.github.origadmin.api.runtime.config.v1"; -option objc_class_prefix = "ORC"; - -message WebSocket { - string network = 1 [json_name = "network"]; - string addr = 2 [json_name = "addr"]; - string path = 3 [json_name = "path"]; - string codec = 4 [json_name = "codec"]; - int64 timeout = 5 [json_name = "timeout"]; -} diff --git a/third_party/errors/errors.proto b/third_party/errors/errors.proto deleted file mode 100644 index 331f0fba..00000000 --- a/third_party/errors/errors.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package errors; - -option go_package = "github.com/go-kratos/kratos/v2/errors;errors"; -option java_multiple_files = true; -option java_package = "com.github.kratos.errors"; -option objc_class_prefix = "KratosErrors"; - -import "google/protobuf/descriptor.proto"; - -extend google.protobuf.EnumOptions { - int32 default_code = 1108; -} - -extend google.protobuf.EnumValueOptions { - int32 code = 1109; -} diff --git a/third_party/errors/rpcerr/rpcerr.proto b/third_party/errors/rpcerr/rpcerr.proto deleted file mode 100644 index 467de07f..00000000 --- a/third_party/errors/rpcerr/rpcerr.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package errors.rpcerr; - -option go_package = "github.com/origadmin/toolkits/errors/rpcerr;rpcerr"; -option java_multiple_files = true; -option java_package = "com.github.origadmin.errors.rpcerr"; -option objc_class_prefix = "OrigAdminErrorsRpcerr"; - -message Error { - string id = 1; - int32 code = 2; - string detail = 3; -}; - -message MultiError { - repeated Error errors = 1; -} \ No newline at end of file diff --git a/third_party/fileupload/v1/fileupload.proto b/third_party/fileupload/v1/fileupload.proto deleted file mode 100644 index e3919898..00000000 --- a/third_party/fileupload/v1/fileupload.proto +++ /dev/null @@ -1,115 +0,0 @@ -syntax = "proto3"; - -package fileupload.v1; - -import "validate/validate.proto"; -import "gnostic/openapi/v3/annotations.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/fileupload/v1;fileuploadv1"; -option java_multiple_files = true; -option java_outer_classname = "FileUploadProto"; -option java_package = "com.github.origadmin.runtime.fileupload"; -option objc_class_prefix = "ORPF"; - -service FileUploadService { - rpc Upload(stream UploadRequest) returns (UploadResponse); -} - -// FileHeader defines the structure of a file header. -message FileHeader { - string filename = 1 [ - json_name = "filename", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = { - description: "fie name", - } - ]; - uint32 size = 3 [ - json_name = "size", - (gnostic.openapi.v3.property) = { - description: "file size", - } - ]; - string mod_time_string = 4 [ - json_name = "mod_time_string", - (gnostic.openapi.v3.property) = { - description: "file mod time string", - } - ]; - uint32 mod_time = 5 [ - json_name = "mod_time", - (gnostic.openapi.v3.property) = { - description: "file mod time unix", - } - ]; - string content_type = 2 [ - json_name = "content_type", - (gnostic.openapi.v3.property) = { - description: "file content type", - } - ]; - map header = 6 [ - json_name = "header", - (gnostic.openapi.v3.property) = { - description: "file header", - } - ]; - bool is_dir = 7 [ - json_name = "is_dir", - (gnostic.openapi.v3.property) = { - description: "file is dir", - } - ]; -} - -// UploadRequest file block information -message UploadRequest { - bool is_header = 1 [ - json_name = "is_header", - (gnostic.openapi.v3.property) = { - description: "file header", - } - ]; - bytes data = 2 [ - json_name = "data", - (gnostic.openapi.v3.property) = { - description: "file data", - } - ]; -} - - -// UploadResponse defines the structure of a file response. -message UploadResponse { - bool success = 1 [ - json_name = "success", - (gnostic.openapi.v3.property) = { - description: "file upload success", - } - ]; - string hash = 2 [ - json_name = "hash", - (gnostic.openapi.v3.property) = { - description: "file hash", - } - ]; - string path = 3 [ - json_name = "path", - (gnostic.openapi.v3.property) = { - description: "file path", - } - ]; - uint32 size = 4 [ - json_name = "size", - (gnostic.openapi.v3.property) = { - description: "file size", - } - ]; - string fail_reason = 5 [ - json_name = "fail_reason", - (gnostic.openapi.v3.property) = { - description: "file failed reason message info", - } - ]; -} diff --git a/third_party/gnostic/discovery/v1/discovery.proto b/third_party/gnostic/discovery/v1/discovery.proto deleted file mode 100644 index 392bb8a5..00000000 --- a/third_party/gnostic/discovery/v1/discovery.proto +++ /dev/null @@ -1,269 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// THIS FILE IS AUTOMATICALLY GENERATED. - -syntax = "proto3"; - -package gnostic.discovery.v1; - -import "google/protobuf/any.proto"; - -// This option lets the proto compiler generate Java code inside the package -// name (see below) instead of inside an outer class. It creates a simpler -// developer experience by reducing one-level of name nesting and be -// consistent with most programming languages that don't support outer classes. -option java_multiple_files = true; - -// The Java outer classname should be the filename in UpperCamelCase. This -// class is only used to hold proto descriptor, so developers don't need to -// work with it directly. -option java_outer_classname = "OpenAPIProto"; - -// The Java package name must be proto package name with proper prefix. -option java_package = "org.discovery_v1"; - -// A reasonable prefix for the Objective-C symbols generated from the package. -// It should at a minimum be 3 characters long, all uppercase, and convention -// is to use an abbreviation of the package name. Something short, but -// hopefully unique enough to not conflict with things that may come along in -// the future. 'GPB' is reserved for the protocol buffer implementation itself. -option objc_class_prefix = "OAS"; - -// The Go package name. -option go_package = "github.com/google/gnostic/discovery;discovery_v1"; - -message Annotations { - repeated string required = 1; -} - -message Any { - google.protobuf.Any value = 1; - string yaml = 2; -} - -message Auth { - Oauth2 oauth2 = 1; -} - -message Document { - string kind = 1; - string discovery_version = 2; - string id = 3; - string name = 4; - string version = 5; - string revision = 6; - string title = 7; - string description = 8; - Icons icons = 9; - string documentation_link = 10; - repeated string labels = 11; - string protocol = 12; - string base_url = 13; - string base_path = 14; - string root_url = 15; - string service_path = 16; - string batch_path = 17; - Parameters parameters = 18; - Auth auth = 19; - repeated string features = 20; - Schemas schemas = 21; - Methods methods = 22; - Resources resources = 23; - string etag = 24; - string owner_domain = 25; - string owner_name = 26; - bool version_module = 27; - string canonical_name = 28; - bool fully_encode_reserved_expansion = 29; - string package_path = 30; - string mtls_root_url = 31; -} - -// Icons that represent the API. -message Icons { - string x16 = 1; - string x32 = 2; -} - -message MediaUpload { - repeated string accept = 1; - string max_size = 2; - Protocols protocols = 3; - bool supports_subscription = 4; -} - -message Method { - string id = 1; - string path = 2; - string http_method = 3; - string description = 4; - Parameters parameters = 5; - repeated string parameter_order = 6; - Request request = 7; - Response response = 8; - repeated string scopes = 9; - bool supports_media_download = 10; - bool supports_media_upload = 11; - bool use_media_download_service = 12; - MediaUpload media_upload = 13; - bool supports_subscription = 14; - string flat_path = 15; - bool etag_required = 16; - string streaming_type = 17; -} - -message Methods { - repeated NamedMethod additional_properties = 1; -} - -// Automatically-generated message used to represent maps of Method as ordered (name,value) pairs. -message NamedMethod { - // Map key - string name = 1; - // Mapped value - Method value = 2; -} - -// Automatically-generated message used to represent maps of Parameter as ordered (name,value) pairs. -message NamedParameter { - // Map key - string name = 1; - // Mapped value - Parameter value = 2; -} - -// Automatically-generated message used to represent maps of Resource as ordered (name,value) pairs. -message NamedResource { - // Map key - string name = 1; - // Mapped value - Resource value = 2; -} - -// Automatically-generated message used to represent maps of Schema as ordered (name,value) pairs. -message NamedSchema { - // Map key - string name = 1; - // Mapped value - Schema value = 2; -} - -// Automatically-generated message used to represent maps of Scope as ordered (name,value) pairs. -message NamedScope { - // Map key - string name = 1; - // Mapped value - Scope value = 2; -} - -message Oauth2 { - Scopes scopes = 1; -} - -message Parameter { - string id = 1; - string type = 2; - string _ref = 3; - string description = 4; - string default = 5; - bool required = 6; - string format = 7; - string pattern = 8; - string minimum = 9; - string maximum = 10; - repeated string enum = 11; - repeated string enum_descriptions = 12; - bool repeated = 13; - string location = 14; - Schemas properties = 15; - Schema additional_properties = 16; - Schema items = 17; - Annotations annotations = 18; -} - -message Parameters { - repeated NamedParameter additional_properties = 1; -} - -message Protocols { - Simple simple = 1; - Resumable resumable = 2; -} - -message Request { - string _ref = 1; - string parameter_name = 2; -} - -message Resource { - Methods methods = 1; - Resources resources = 2; -} - -message Resources { - repeated NamedResource additional_properties = 1; -} - -message Response { - string _ref = 1; -} - -message Resumable { - bool multipart = 1; - string path = 2; -} - -message Schema { - string id = 1; - string type = 2; - string description = 3; - string default = 4; - bool required = 5; - string format = 6; - string pattern = 7; - string minimum = 8; - string maximum = 9; - repeated string enum = 10; - repeated string enum_descriptions = 11; - bool repeated = 12; - string location = 13; - Schemas properties = 14; - Schema additional_properties = 15; - Schema items = 16; - string _ref = 17; - Annotations annotations = 18; - bool read_only = 19; -} - -message Schemas { - repeated NamedSchema additional_properties = 1; -} - -message Scope { - string description = 1; -} - -message Scopes { - repeated NamedScope additional_properties = 1; -} - -message Simple { - bool multipart = 1; - string path = 2; -} - -message StringArray { - repeated string value = 1; -} \ No newline at end of file diff --git a/third_party/gnostic/openapi/v2/openapiv2.proto b/third_party/gnostic/openapi/v2/openapiv2.proto deleted file mode 100644 index 899d2710..00000000 --- a/third_party/gnostic/openapi/v2/openapiv2.proto +++ /dev/null @@ -1,665 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// THIS FILE IS AUTOMATICALLY GENERATED. - -syntax = "proto3"; - -package gnostic.openapi.v2; - -import "google/protobuf/any.proto"; - -// This option lets the proto compiler generate Java code inside the package -// name (see below) instead of inside an outer class. It creates a simpler -// developer experience by reducing one-level of name nesting and be -// consistent with most programming languages that don't support outer classes. -option java_multiple_files = true; - -// The Java outer classname should be the filename in UpperCamelCase. This -// class is only used to hold proto descriptor, so developers don't need to -// work with it directly. -option java_outer_classname = "OpenAPIProto"; - -// The Java package name must be proto package name with proper prefix. -option java_package = "org.openapi_v2"; - -// A reasonable prefix for the Objective-C symbols generated from the package. -// It should at a minimum be 3 characters long, all uppercase, and convention -// is to use an abbreviation of the package name. Something short, but -// hopefully unique enough to not conflict with things that may come along in -// the future. 'GPB' is reserved for the protocol buffer implementation itself. -option objc_class_prefix = "OAS"; - -// The Go package name. -option go_package = "github.com/google/gnostic/openapiv2;openapi_v2"; - -message AdditionalPropertiesItem { - oneof oneof { - Schema schema = 1; - bool boolean = 2; - } -} - -message Any { - google.protobuf.Any value = 1; - string yaml = 2; -} - -message ApiKeySecurity { - string type = 1; - string name = 2; - string in = 3; - string description = 4; - repeated NamedAny vendor_extension = 5; -} - -message BasicAuthenticationSecurity { - string type = 1; - string description = 2; - repeated NamedAny vendor_extension = 3; -} - -message BodyParameter { - // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - string description = 1; - // The name of the parameter. - string name = 2; - // Determines the location of the parameter. - string in = 3; - // Determines whether or not this parameter is required or optional. - bool required = 4; - Schema schema = 5; - repeated NamedAny vendor_extension = 6; -} - -// Contact information for the owners of the API. -message Contact { - // The identifying name of the contact person/organization. - string name = 1; - // The URL pointing to the contact information. - string url = 2; - // The email address of the contact person/organization. - string email = 3; - repeated NamedAny vendor_extension = 4; -} - -message Default { - repeated NamedAny additional_properties = 1; -} - -// One or more JSON objects describing the schemas being consumed and produced by the API. -message Definitions { - repeated NamedSchema additional_properties = 1; -} - -message Document { - // The Swagger version of this document. - string swagger = 1; - Info info = 2; - // The host (name or ip) of the API. Example: 'swagger.io' - string host = 3; - // The base path to the API. Example: '/api'. - string base_path = 4; - // The transfer protocol of the API. - repeated string schemes = 5; - // A list of MIME types accepted by the API. - repeated string consumes = 6; - // A list of MIME types the API can produce. - repeated string produces = 7; - Paths paths = 8; - Definitions definitions = 9; - ParameterDefinitions parameters = 10; - ResponseDefinitions responses = 11; - repeated SecurityRequirement security = 12; - SecurityDefinitions security_definitions = 13; - repeated Tag tags = 14; - ExternalDocs external_docs = 15; - repeated NamedAny vendor_extension = 16; -} - -message Examples { - repeated NamedAny additional_properties = 1; -} - -// information about external documentation -message ExternalDocs { - string description = 1; - string url = 2; - repeated NamedAny vendor_extension = 3; -} - -// A deterministic version of a JSON Schema object. -message FileSchema { - string format = 1; - string title = 2; - string description = 3; - Any default = 4; - repeated string required = 5; - string type = 6; - bool read_only = 7; - ExternalDocs external_docs = 8; - Any example = 9; - repeated NamedAny vendor_extension = 10; -} - -message FormDataParameterSubSchema { - // Determines whether or not this parameter is required or optional. - bool required = 1; - // Determines the location of the parameter. - string in = 2; - // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - string description = 3; - // The name of the parameter. - string name = 4; - // allows sending a parameter by name only or with an empty value. - bool allow_empty_value = 5; - string type = 6; - string format = 7; - PrimitivesItems items = 8; - string collection_format = 9; - Any default = 10; - double maximum = 11; - bool exclusive_maximum = 12; - double minimum = 13; - bool exclusive_minimum = 14; - int64 max_length = 15; - int64 min_length = 16; - string pattern = 17; - int64 max_items = 18; - int64 min_items = 19; - bool unique_items = 20; - repeated Any enum = 21; - double multiple_of = 22; - repeated NamedAny vendor_extension = 23; -} - -message Header { - string type = 1; - string format = 2; - PrimitivesItems items = 3; - string collection_format = 4; - Any default = 5; - double maximum = 6; - bool exclusive_maximum = 7; - double minimum = 8; - bool exclusive_minimum = 9; - int64 max_length = 10; - int64 min_length = 11; - string pattern = 12; - int64 max_items = 13; - int64 min_items = 14; - bool unique_items = 15; - repeated Any enum = 16; - double multiple_of = 17; - string description = 18; - repeated NamedAny vendor_extension = 19; -} - -message HeaderParameterSubSchema { - // Determines whether or not this parameter is required or optional. - bool required = 1; - // Determines the location of the parameter. - string in = 2; - // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - string description = 3; - // The name of the parameter. - string name = 4; - string type = 5; - string format = 6; - PrimitivesItems items = 7; - string collection_format = 8; - Any default = 9; - double maximum = 10; - bool exclusive_maximum = 11; - double minimum = 12; - bool exclusive_minimum = 13; - int64 max_length = 14; - int64 min_length = 15; - string pattern = 16; - int64 max_items = 17; - int64 min_items = 18; - bool unique_items = 19; - repeated Any enum = 20; - double multiple_of = 21; - repeated NamedAny vendor_extension = 22; -} - -message Headers { - repeated NamedHeader additional_properties = 1; -} - -// General information about the API. -message Info { - // A unique and precise title of the API. - string title = 1; - // A semantic version number of the API. - string version = 2; - // A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed. - string description = 3; - // The terms of service for the API. - string terms_of_service = 4; - Contact contact = 5; - License license = 6; - repeated NamedAny vendor_extension = 7; -} - -message ItemsItem { - repeated Schema schema = 1; -} - -message JsonReference { - string _ref = 1; - string description = 2; -} - -message License { - // The name of the license type. It's encouraged to use an OSI compatible license. - string name = 1; - // The URL pointing to the license. - string url = 2; - repeated NamedAny vendor_extension = 3; -} - -// Automatically-generated message used to represent maps of Any as ordered (name,value) pairs. -message NamedAny { - // Map key - string name = 1; - // Mapped value - Any value = 2; -} - -// Automatically-generated message used to represent maps of Header as ordered (name,value) pairs. -message NamedHeader { - // Map key - string name = 1; - // Mapped value - Header value = 2; -} - -// Automatically-generated message used to represent maps of Parameter as ordered (name,value) pairs. -message NamedParameter { - // Map key - string name = 1; - // Mapped value - Parameter value = 2; -} - -// Automatically-generated message used to represent maps of PathItem as ordered (name,value) pairs. -message NamedPathItem { - // Map key - string name = 1; - // Mapped value - PathItem value = 2; -} - -// Automatically-generated message used to represent maps of Response as ordered (name,value) pairs. -message NamedResponse { - // Map key - string name = 1; - // Mapped value - Response value = 2; -} - -// Automatically-generated message used to represent maps of ResponseValue as ordered (name,value) pairs. -message NamedResponseValue { - // Map key - string name = 1; - // Mapped value - ResponseValue value = 2; -} - -// Automatically-generated message used to represent maps of Schema as ordered (name,value) pairs. -message NamedSchema { - // Map key - string name = 1; - // Mapped value - Schema value = 2; -} - -// Automatically-generated message used to represent maps of SecurityDefinitionsItem as ordered (name,value) pairs. -message NamedSecurityDefinitionsItem { - // Map key - string name = 1; - // Mapped value - SecurityDefinitionsItem value = 2; -} - -// Automatically-generated message used to represent maps of string as ordered (name,value) pairs. -message NamedString { - // Map key - string name = 1; - // Mapped value - string value = 2; -} - -// Automatically-generated message used to represent maps of StringArray as ordered (name,value) pairs. -message NamedStringArray { - // Map key - string name = 1; - // Mapped value - StringArray value = 2; -} - -message NonBodyParameter { - oneof oneof { - HeaderParameterSubSchema header_parameter_sub_schema = 1; - FormDataParameterSubSchema form_data_parameter_sub_schema = 2; - QueryParameterSubSchema query_parameter_sub_schema = 3; - PathParameterSubSchema path_parameter_sub_schema = 4; - } -} - -message Oauth2AccessCodeSecurity { - string type = 1; - string flow = 2; - Oauth2Scopes scopes = 3; - string authorization_url = 4; - string token_url = 5; - string description = 6; - repeated NamedAny vendor_extension = 7; -} - -message Oauth2ApplicationSecurity { - string type = 1; - string flow = 2; - Oauth2Scopes scopes = 3; - string token_url = 4; - string description = 5; - repeated NamedAny vendor_extension = 6; -} - -message Oauth2ImplicitSecurity { - string type = 1; - string flow = 2; - Oauth2Scopes scopes = 3; - string authorization_url = 4; - string description = 5; - repeated NamedAny vendor_extension = 6; -} - -message Oauth2PasswordSecurity { - string type = 1; - string flow = 2; - Oauth2Scopes scopes = 3; - string token_url = 4; - string description = 5; - repeated NamedAny vendor_extension = 6; -} - -message Oauth2Scopes { - repeated NamedString additional_properties = 1; -} - -message Operation { - repeated string tags = 1; - // A brief summary of the operation. - string summary = 2; - // A longer description of the operation, GitHub Flavored Markdown is allowed. - string description = 3; - ExternalDocs external_docs = 4; - // A unique identifier of the operation. - string operation_id = 5; - // A list of MIME types the API can produce. - repeated string produces = 6; - // A list of MIME types the API can consume. - repeated string consumes = 7; - // The parameters needed to send a valid API call. - repeated ParametersItem parameters = 8; - Responses responses = 9; - // The transfer protocol of the API. - repeated string schemes = 10; - bool deprecated = 11; - repeated SecurityRequirement security = 12; - repeated NamedAny vendor_extension = 13; -} - -message Parameter { - oneof oneof { - BodyParameter body_parameter = 1; - NonBodyParameter non_body_parameter = 2; - } -} - -// One or more JSON representations for parameters -message ParameterDefinitions { - repeated NamedParameter additional_properties = 1; -} - -message ParametersItem { - oneof oneof { - Parameter parameter = 1; - JsonReference json_reference = 2; - } -} - -message PathItem { - string _ref = 1; - Operation get = 2; - Operation put = 3; - Operation post = 4; - Operation delete = 5; - Operation options = 6; - Operation head = 7; - Operation patch = 8; - // The parameters needed to send a valid API call. - repeated ParametersItem parameters = 9; - repeated NamedAny vendor_extension = 10; -} - -message PathParameterSubSchema { - // Determines whether or not this parameter is required or optional. - bool required = 1; - // Determines the location of the parameter. - string in = 2; - // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - string description = 3; - // The name of the parameter. - string name = 4; - string type = 5; - string format = 6; - PrimitivesItems items = 7; - string collection_format = 8; - Any default = 9; - double maximum = 10; - bool exclusive_maximum = 11; - double minimum = 12; - bool exclusive_minimum = 13; - int64 max_length = 14; - int64 min_length = 15; - string pattern = 16; - int64 max_items = 17; - int64 min_items = 18; - bool unique_items = 19; - repeated Any enum = 20; - double multiple_of = 21; - repeated NamedAny vendor_extension = 22; -} - -// Relative paths to the individual endpoints. They must be relative to the 'basePath'. -message Paths { - repeated NamedAny vendor_extension = 1; - repeated NamedPathItem path = 2; -} - -message PrimitivesItems { - string type = 1; - string format = 2; - PrimitivesItems items = 3; - string collection_format = 4; - Any default = 5; - double maximum = 6; - bool exclusive_maximum = 7; - double minimum = 8; - bool exclusive_minimum = 9; - int64 max_length = 10; - int64 min_length = 11; - string pattern = 12; - int64 max_items = 13; - int64 min_items = 14; - bool unique_items = 15; - repeated Any enum = 16; - double multiple_of = 17; - repeated NamedAny vendor_extension = 18; -} - -message Properties { - repeated NamedSchema additional_properties = 1; -} - -message QueryParameterSubSchema { - // Determines whether or not this parameter is required or optional. - bool required = 1; - // Determines the location of the parameter. - string in = 2; - // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. - string description = 3; - // The name of the parameter. - string name = 4; - // allows sending a parameter by name only or with an empty value. - bool allow_empty_value = 5; - string type = 6; - string format = 7; - PrimitivesItems items = 8; - string collection_format = 9; - Any default = 10; - double maximum = 11; - bool exclusive_maximum = 12; - double minimum = 13; - bool exclusive_minimum = 14; - int64 max_length = 15; - int64 min_length = 16; - string pattern = 17; - int64 max_items = 18; - int64 min_items = 19; - bool unique_items = 20; - repeated Any enum = 21; - double multiple_of = 22; - repeated NamedAny vendor_extension = 23; -} - -message Response { - string description = 1; - SchemaItem schema = 2; - Headers headers = 3; - Examples examples = 4; - repeated NamedAny vendor_extension = 5; -} - -// One or more JSON representations for responses -message ResponseDefinitions { - repeated NamedResponse additional_properties = 1; -} - -message ResponseValue { - oneof oneof { - Response response = 1; - JsonReference json_reference = 2; - } -} - -// Response objects names can either be any valid HTTP status code or 'default'. -message Responses { - repeated NamedResponseValue response_code = 1; - repeated NamedAny vendor_extension = 2; -} - -// A deterministic version of a JSON Schema object. -message Schema { - string _ref = 1; - string format = 2; - string title = 3; - string description = 4; - Any default = 5; - double multiple_of = 6; - double maximum = 7; - bool exclusive_maximum = 8; - double minimum = 9; - bool exclusive_minimum = 10; - int64 max_length = 11; - int64 min_length = 12; - string pattern = 13; - int64 max_items = 14; - int64 min_items = 15; - bool unique_items = 16; - int64 max_properties = 17; - int64 min_properties = 18; - repeated string required = 19; - repeated Any enum = 20; - AdditionalPropertiesItem additional_properties = 21; - TypeItem type = 22; - ItemsItem items = 23; - repeated Schema all_of = 24; - Properties properties = 25; - string discriminator = 26; - bool read_only = 27; - Xml xml = 28; - ExternalDocs external_docs = 29; - Any example = 30; - repeated NamedAny vendor_extension = 31; -} - -message SchemaItem { - oneof oneof { - Schema schema = 1; - FileSchema file_schema = 2; - } -} - -message SecurityDefinitions { - repeated NamedSecurityDefinitionsItem additional_properties = 1; -} - -message SecurityDefinitionsItem { - oneof oneof { - BasicAuthenticationSecurity basic_authentication_security = 1; - ApiKeySecurity api_key_security = 2; - Oauth2ImplicitSecurity oauth2_implicit_security = 3; - Oauth2PasswordSecurity oauth2_password_security = 4; - Oauth2ApplicationSecurity oauth2_application_security = 5; - Oauth2AccessCodeSecurity oauth2_access_code_security = 6; - } -} - -message SecurityRequirement { - repeated NamedStringArray additional_properties = 1; -} - -message StringArray { - repeated string value = 1; -} - -message Tag { - string name = 1; - string description = 2; - ExternalDocs external_docs = 3; - repeated NamedAny vendor_extension = 4; -} - -message TypeItem { - repeated string value = 1; -} - -// Any property starting with x- is valid. -message VendorExtension { - repeated NamedAny additional_properties = 1; -} - -message Xml { - string name = 1; - string namespace = 2; - string prefix = 3; - bool attribute = 4; - bool wrapped = 5; - repeated NamedAny vendor_extension = 6; -} diff --git a/third_party/gnostic/openapi/v3/annotations.proto b/third_party/gnostic/openapi/v3/annotations.proto deleted file mode 100644 index 1b1a13fe..00000000 --- a/third_party/gnostic/openapi/v3/annotations.proto +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2022 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package gnostic.openapi.v3; - -import "gnostic/openapi/v3/openapiv3.proto"; -import "google/protobuf/descriptor.proto"; - -// This option lets the proto compiler generate Java code inside the package -// name (see below) instead of inside an outer class. It creates a simpler -// developer experience by reducing one-level of name nesting and be -// consistent with most programming languages that don't support outer classes. -option java_multiple_files = true; - -// The Java outer classname should be the filename in UpperCamelCase. This -// class is only used to hold proto descriptor, so developers don't need to -// work with it directly. -option java_outer_classname = "AnnotationsProto"; - -// The Java package name must be proto package name with proper prefix. -option java_package = "org.openapi_v3"; - -// A reasonable prefix for the Objective-C symbols generated from the package. -// It should at a minimum be 3 characters long, all uppercase, and convention -// is to use an abbreviation of the package name. Something short, but -// hopefully unique enough to not conflict with things that may come along in -// the future. 'GPB' is reserved for the protocol buffer implementation itself. -option objc_class_prefix = "OAS"; - -// The Go package name. -option go_package = "github.com/google/gnostic/openapiv3;openapi_v3"; - -extend google.protobuf.FileOptions { - Document document = 1143; -} - -extend google.protobuf.MethodOptions { - Operation operation = 1143; -} - -extend google.protobuf.MessageOptions { - Schema schema = 1143; -} - -extend google.protobuf.FieldOptions { - Schema property = 1143; -} diff --git a/third_party/gnostic/openapi/v3/openapiv3.proto b/third_party/gnostic/openapi/v3/openapiv3.proto deleted file mode 100644 index e7835644..00000000 --- a/third_party/gnostic/openapi/v3/openapiv3.proto +++ /dev/null @@ -1,671 +0,0 @@ -// Copyright 2020 Google LLC. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// THIS FILE IS AUTOMATICALLY GENERATED. - -syntax = "proto3"; - -package gnostic.openapi.v3; - -import "google/protobuf/any.proto"; - -// This option lets the proto compiler generate Java code inside the package -// name (see below) instead of inside an outer class. It creates a simpler -// developer experience by reducing one-level of name nesting and be -// consistent with most programming languages that don't support outer classes. -option java_multiple_files = true; - -// The Java outer classname should be the filename in UpperCamelCase. This -// class is only used to hold proto descriptor, so developers don't need to -// work with it directly. -option java_outer_classname = "OpenAPIProto"; - -// The Java package name must be proto package name with proper prefix. -option java_package = "org.openapi_v3"; - -// A reasonable prefix for the Objective-C symbols generated from the package. -// It should at a minimum be 3 characters long, all uppercase, and convention -// is to use an abbreviation of the package name. Something short, but -// hopefully unique enough to not conflict with things that may come along in -// the future. 'GPB' is reserved for the protocol buffer implementation itself. -option objc_class_prefix = "OAS"; - -// The Go package name. -option go_package = "github.com/google/gnostic/openapiv3;openapi_v3"; - -message AdditionalPropertiesItem { - oneof oneof { - SchemaOrReference schema_or_reference = 1; - bool boolean = 2; - } -} - -message Any { - google.protobuf.Any value = 1; - string yaml = 2; -} - -message AnyOrExpression { - oneof oneof { - Any any = 1; - Expression expression = 2; - } -} - -// A map of possible out-of band callbacks related to the parent operation. Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. -message Callback { - repeated NamedPathItem path = 1; - repeated NamedAny specification_extension = 2; -} - -message CallbackOrReference { - oneof oneof { - Callback callback = 1; - Reference reference = 2; - } -} - -message CallbacksOrReferences { - repeated NamedCallbackOrReference additional_properties = 1; -} - -// Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. -message Components { - SchemasOrReferences schemas = 1; - ResponsesOrReferences responses = 2; - ParametersOrReferences parameters = 3; - ExamplesOrReferences examples = 4; - RequestBodiesOrReferences request_bodies = 5; - HeadersOrReferences headers = 6; - SecuritySchemesOrReferences security_schemes = 7; - LinksOrReferences links = 8; - CallbacksOrReferences callbacks = 9; - repeated NamedAny specification_extension = 10; -} - -// Contact information for the exposed API. -message Contact { - string name = 1; - string url = 2; - string email = 3; - repeated NamedAny specification_extension = 4; -} - -message DefaultType { - oneof oneof { - double number = 1; - bool boolean = 2; - string string = 3; - } -} - -// When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it. When using the discriminator, _inline_ schemas will not be considered. -message Discriminator { - string property_name = 1; - Strings mapping = 2; - repeated NamedAny specification_extension = 3; -} - -message Document { - string openapi = 1; - Info info = 2; - repeated Server servers = 3; - Paths paths = 4; - Components components = 5; - repeated SecurityRequirement security = 6; - repeated Tag tags = 7; - ExternalDocs external_docs = 8; - repeated NamedAny specification_extension = 9; -} - -// A single encoding definition applied to a single schema property. -message Encoding { - string content_type = 1; - HeadersOrReferences headers = 2; - string style = 3; - bool explode = 4; - bool allow_reserved = 5; - repeated NamedAny specification_extension = 6; -} - -message Encodings { - repeated NamedEncoding additional_properties = 1; -} - -message Example { - string summary = 1; - string description = 2; - Any value = 3; - string external_value = 4; - repeated NamedAny specification_extension = 5; -} - -message ExampleOrReference { - oneof oneof { - Example example = 1; - Reference reference = 2; - } -} - -message ExamplesOrReferences { - repeated NamedExampleOrReference additional_properties = 1; -} - -message Expression { - repeated NamedAny additional_properties = 1; -} - -// Allows referencing an external resource for extended documentation. -message ExternalDocs { - string description = 1; - string url = 2; - repeated NamedAny specification_extension = 3; -} - -// The Header Object follows the structure of the Parameter Object with the following changes: 1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. 1. `in` MUST NOT be specified, it is implicitly in `header`. 1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, `style`). -message Header { - string description = 1; - bool required = 2; - bool deprecated = 3; - bool allow_empty_value = 4; - string style = 5; - bool explode = 6; - bool allow_reserved = 7; - SchemaOrReference schema = 8; - Any example = 9; - ExamplesOrReferences examples = 10; - MediaTypes content = 11; - repeated NamedAny specification_extension = 12; -} - -message HeaderOrReference { - oneof oneof { - Header header = 1; - Reference reference = 2; - } -} - -message HeadersOrReferences { - repeated NamedHeaderOrReference additional_properties = 1; -} - -// The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. -message Info { - string title = 1; - string description = 2; - string terms_of_service = 3; - Contact contact = 4; - License license = 5; - string version = 6; - repeated NamedAny specification_extension = 7; - string summary = 8; -} - -message ItemsItem { - repeated SchemaOrReference schema_or_reference = 1; -} - -// License information for the exposed API. -message License { - string name = 1; - string url = 2; - repeated NamedAny specification_extension = 3; -} - -// The `Link object` represents a possible design-time link for a response. The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations. Unlike _dynamic_ links (i.e. links provided **in** the response payload), the OAS linking mechanism does not require link information in the runtime response. For computing links, and providing instructions to execute them, a runtime expression is used for accessing values in an operation and using them as parameters while invoking the linked operation. -message Link { - string operation_ref = 1; - string operation_id = 2; - AnyOrExpression parameters = 3; - AnyOrExpression request_body = 4; - string description = 5; - Server server = 6; - repeated NamedAny specification_extension = 7; -} - -message LinkOrReference { - oneof oneof { - Link link = 1; - Reference reference = 2; - } -} - -message LinksOrReferences { - repeated NamedLinkOrReference additional_properties = 1; -} - -// Each Media Type Object provides schema and examples for the media type identified by its key. -message MediaType { - SchemaOrReference schema = 1; - Any example = 2; - ExamplesOrReferences examples = 3; - Encodings encoding = 4; - repeated NamedAny specification_extension = 5; -} - -message MediaTypes { - repeated NamedMediaType additional_properties = 1; -} - -// Automatically-generated message used to represent maps of Any as ordered (name,value) pairs. -message NamedAny { - // Map key - string name = 1; - // Mapped value - Any value = 2; -} - -// Automatically-generated message used to represent maps of CallbackOrReference as ordered (name,value) pairs. -message NamedCallbackOrReference { - // Map key - string name = 1; - // Mapped value - CallbackOrReference value = 2; -} - -// Automatically-generated message used to represent maps of Encoding as ordered (name,value) pairs. -message NamedEncoding { - // Map key - string name = 1; - // Mapped value - Encoding value = 2; -} - -// Automatically-generated message used to represent maps of ExampleOrReference as ordered (name,value) pairs. -message NamedExampleOrReference { - // Map key - string name = 1; - // Mapped value - ExampleOrReference value = 2; -} - -// Automatically-generated message used to represent maps of HeaderOrReference as ordered (name,value) pairs. -message NamedHeaderOrReference { - // Map key - string name = 1; - // Mapped value - HeaderOrReference value = 2; -} - -// Automatically-generated message used to represent maps of LinkOrReference as ordered (name,value) pairs. -message NamedLinkOrReference { - // Map key - string name = 1; - // Mapped value - LinkOrReference value = 2; -} - -// Automatically-generated message used to represent maps of MediaType as ordered (name,value) pairs. -message NamedMediaType { - // Map key - string name = 1; - // Mapped value - MediaType value = 2; -} - -// Automatically-generated message used to represent maps of ParameterOrReference as ordered (name,value) pairs. -message NamedParameterOrReference { - // Map key - string name = 1; - // Mapped value - ParameterOrReference value = 2; -} - -// Automatically-generated message used to represent maps of PathItem as ordered (name,value) pairs. -message NamedPathItem { - // Map key - string name = 1; - // Mapped value - PathItem value = 2; -} - -// Automatically-generated message used to represent maps of RequestBodyOrReference as ordered (name,value) pairs. -message NamedRequestBodyOrReference { - // Map key - string name = 1; - // Mapped value - RequestBodyOrReference value = 2; -} - -// Automatically-generated message used to represent maps of ResponseOrReference as ordered (name,value) pairs. -message NamedResponseOrReference { - // Map key - string name = 1; - // Mapped value - ResponseOrReference value = 2; -} - -// Automatically-generated message used to represent maps of SchemaOrReference as ordered (name,value) pairs. -message NamedSchemaOrReference { - // Map key - string name = 1; - // Mapped value - SchemaOrReference value = 2; -} - -// Automatically-generated message used to represent maps of SecuritySchemeOrReference as ordered (name,value) pairs. -message NamedSecuritySchemeOrReference { - // Map key - string name = 1; - // Mapped value - SecuritySchemeOrReference value = 2; -} - -// Automatically-generated message used to represent maps of ServerVariable as ordered (name,value) pairs. -message NamedServerVariable { - // Map key - string name = 1; - // Mapped value - ServerVariable value = 2; -} - -// Automatically-generated message used to represent maps of string as ordered (name,value) pairs. -message NamedString { - // Map key - string name = 1; - // Mapped value - string value = 2; -} - -// Automatically-generated message used to represent maps of StringArray as ordered (name,value) pairs. -message NamedStringArray { - // Map key - string name = 1; - // Mapped value - StringArray value = 2; -} - -// Configuration details for a supported OAuth Flow -message OauthFlow { - string authorization_url = 1; - string token_url = 2; - string refresh_url = 3; - Strings scopes = 4; - repeated NamedAny specification_extension = 5; -} - -// Allows configuration of the supported OAuth Flows. -message OauthFlows { - OauthFlow implicit = 1; - OauthFlow password = 2; - OauthFlow client_credentials = 3; - OauthFlow authorization_code = 4; - repeated NamedAny specification_extension = 5; -} - -message Object { - repeated NamedAny additional_properties = 1; -} - -// Describes a single API operation on a path. -message Operation { - repeated string tags = 1; - string summary = 2; - string description = 3; - ExternalDocs external_docs = 4; - string operation_id = 5; - repeated ParameterOrReference parameters = 6; - RequestBodyOrReference request_body = 7; - Responses responses = 8; - CallbacksOrReferences callbacks = 9; - bool deprecated = 10; - repeated SecurityRequirement security = 11; - repeated Server servers = 12; - repeated NamedAny specification_extension = 13; -} - -// Describes a single operation parameter. A unique parameter is defined by a combination of a name and location. -message Parameter { - string name = 1; - string in = 2; - string description = 3; - bool required = 4; - bool deprecated = 5; - bool allow_empty_value = 6; - string style = 7; - bool explode = 8; - bool allow_reserved = 9; - SchemaOrReference schema = 10; - Any example = 11; - ExamplesOrReferences examples = 12; - MediaTypes content = 13; - repeated NamedAny specification_extension = 14; -} - -message ParameterOrReference { - oneof oneof { - Parameter parameter = 1; - Reference reference = 2; - } -} - -message ParametersOrReferences { - repeated NamedParameterOrReference additional_properties = 1; -} - -// Describes the operations available on a single path. A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available. -message PathItem { - string _ref = 1; - string summary = 2; - string description = 3; - Operation get = 4; - Operation put = 5; - Operation post = 6; - Operation delete = 7; - Operation options = 8; - Operation head = 9; - Operation patch = 10; - Operation trace = 11; - repeated Server servers = 12; - repeated ParameterOrReference parameters = 13; - repeated NamedAny specification_extension = 14; -} - -// Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the `Server Object` in order to construct the full URL. The Paths MAY be empty, due to ACL constraints. -message Paths { - repeated NamedPathItem path = 1; - repeated NamedAny specification_extension = 2; -} - -message Properties { - repeated NamedSchemaOrReference additional_properties = 1; -} - -// A simple object to allow referencing other components in the specification, internally and externally. The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules. For this specification, reference resolution is accomplished as defined by the JSON Reference specification and not by the JSON Schema specification. -message Reference { - string _ref = 1; - string summary = 2; - string description = 3; -} - -message RequestBodiesOrReferences { - repeated NamedRequestBodyOrReference additional_properties = 1; -} - -// Describes a single request body. -message RequestBody { - string description = 1; - MediaTypes content = 2; - bool required = 3; - repeated NamedAny specification_extension = 4; -} - -message RequestBodyOrReference { - oneof oneof { - RequestBody request_body = 1; - Reference reference = 2; - } -} - -// Describes a single response from an API Operation, including design-time, static `links` to operations based on the response. -message Response { - string description = 1; - HeadersOrReferences headers = 2; - MediaTypes content = 3; - LinksOrReferences links = 4; - repeated NamedAny specification_extension = 5; -} - -message ResponseOrReference { - oneof oneof { - Response response = 1; - Reference reference = 2; - } -} - -// A container for the expected responses of an operation. The container maps a HTTP response code to the expected response. The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors. The `default` MAY be used as a default response object for all HTTP codes that are not covered individually by the specification. The `Responses Object` MUST contain at least one response code, and it SHOULD be the response for a successful operation call. -message Responses { - ResponseOrReference default = 1; - repeated NamedResponseOrReference response_or_reference = 2; - repeated NamedAny specification_extension = 3; -} - -message ResponsesOrReferences { - repeated NamedResponseOrReference additional_properties = 1; -} - -// The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is an extended subset of the JSON Schema Specification Wright Draft 00. For more information about the properties, see JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema. -message Schema { - bool nullable = 1; - Discriminator discriminator = 2; - bool read_only = 3; - bool write_only = 4; - Xml xml = 5; - ExternalDocs external_docs = 6; - Any example = 7; - bool deprecated = 8; - string title = 9; - double multiple_of = 10; - double maximum = 11; - bool exclusive_maximum = 12; - double minimum = 13; - bool exclusive_minimum = 14; - int64 max_length = 15; - int64 min_length = 16; - string pattern = 17; - int64 max_items = 18; - int64 min_items = 19; - bool unique_items = 20; - int64 max_properties = 21; - int64 min_properties = 22; - repeated string required = 23; - repeated Any enum = 24; - string type = 25; - repeated SchemaOrReference all_of = 26; - repeated SchemaOrReference one_of = 27; - repeated SchemaOrReference any_of = 28; - Schema not = 29; - ItemsItem items = 30; - Properties properties = 31; - AdditionalPropertiesItem additional_properties = 32; - DefaultType default = 33; - string description = 34; - string format = 35; - repeated NamedAny specification_extension = 36; -} - -message SchemaOrReference { - oneof oneof { - Schema schema = 1; - Reference reference = 2; - } -} - -message SchemasOrReferences { - repeated NamedSchemaOrReference additional_properties = 1; -} - -// Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object. Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information. When a list of Security Requirement Objects is defined on the OpenAPI Object or Operation Object, only one of the Security Requirement Objects in the list needs to be satisfied to authorize the request. -message SecurityRequirement { - repeated NamedStringArray additional_properties = 1; -} - -// Defines a security scheme that can be used by the operations. Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), mutual TLS (use of a client certificate), OAuth2's common flows (implicit, password, application and access code) as defined in RFC6749, and OpenID Connect. Please note that currently (2019) the implicit flow is about to be deprecated OAuth 2.0 Security Best Current Practice. Recommended for most use case is Authorization Code Grant flow with PKCE. -message SecurityScheme { - string type = 1; - string description = 2; - string name = 3; - string in = 4; - string scheme = 5; - string bearer_format = 6; - OauthFlows flows = 7; - string open_id_connect_url = 8; - repeated NamedAny specification_extension = 9; -} - -message SecuritySchemeOrReference { - oneof oneof { - SecurityScheme security_scheme = 1; - Reference reference = 2; - } -} - -message SecuritySchemesOrReferences { - repeated NamedSecuritySchemeOrReference additional_properties = 1; -} - -// An object representing a Server. -message Server { - string url = 1; - string description = 2; - ServerVariables variables = 3; - repeated NamedAny specification_extension = 4; -} - -// An object representing a Server Variable for server URL template substitution. -message ServerVariable { - repeated string enum = 1; - string default = 2; - string description = 3; - repeated NamedAny specification_extension = 4; -} - -message ServerVariables { - repeated NamedServerVariable additional_properties = 1; -} - -// Any property starting with x- is valid. -message SpecificationExtension { - oneof oneof { - double number = 1; - bool boolean = 2; - string string = 3; - } -} - -message StringArray { - repeated string value = 1; -} - -message Strings { - repeated NamedString additional_properties = 1; -} - -// Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag defined in the Operation Object instances. -message Tag { - string name = 1; - string description = 2; - ExternalDocs external_docs = 3; - repeated NamedAny specification_extension = 4; -} - -// A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. See examples for expected behavior. -message Xml { - string name = 1; - string namespace = 2; - string prefix = 3; - bool attribute = 4; - bool wrapped = 5; - repeated NamedAny specification_extension = 6; -} diff --git a/third_party/google/api/annotations.proto b/third_party/google/api/annotations.proto deleted file mode 100644 index 417edd8f..00000000 --- a/third_party/google/api/annotations.proto +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/api/http.proto"; -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "AnnotationsProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.MethodOptions { - // See `HttpRule`. - HttpRule http = 72295728; -} diff --git a/third_party/google/api/client.proto b/third_party/google/api/client.proto deleted file mode 100644 index 3d692560..00000000 --- a/third_party/google/api/client.proto +++ /dev/null @@ -1,486 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/api/launch_stage.proto"; -import "google/protobuf/descriptor.proto"; -import "google/protobuf/duration.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "ClientProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.MethodOptions { - // A definition of a client library method signature. - // - // In client libraries, each proto RPC corresponds to one or more methods - // which the end user is able to call, and calls the underlying RPC. - // Normally, this method receives a single argument (a struct or instance - // corresponding to the RPC request object). Defining this field will - // add one or more overloads providing flattened or simpler method signatures - // in some languages. - // - // The fields on the method signature are provided as a comma-separated - // string. - // - // For example, the proto RPC and annotation: - // - // rpc CreateSubscription(CreateSubscriptionRequest) - // returns (Subscription) { - // option (google.api.method_signature) = "name,topic"; - // } - // - // Would add the following Java overload (in addition to the method accepting - // the request object): - // - // public final Subscription createSubscription(String name, String topic) - // - // The following backwards-compatibility guidelines apply: - // - // * Adding this annotation to an unannotated method is backwards - // compatible. - // * Adding this annotation to a method which already has existing - // method signature annotations is backwards compatible if and only if - // the new method signature annotation is last in the sequence. - // * Modifying or removing an existing method signature annotation is - // a breaking change. - // * Re-ordering existing method signature annotations is a breaking - // change. - repeated string method_signature = 1051; -} - -extend google.protobuf.ServiceOptions { - // The hostname for this service. - // This should be specified with no prefix or protocol. - // - // Example: - // - // service Foo { - // option (google.api.default_host) = "foo.googleapi.com"; - // ... - // } - string default_host = 1049; - - // OAuth scopes needed for the client. - // - // Example: - // - // service Foo { - // option (google.api.oauth_scopes) = \ - // "https://www.googleapis.com/auth/cloud-platform"; - // ... - // } - // - // If there is more than one scope, use a comma-separated string: - // - // Example: - // - // service Foo { - // option (google.api.oauth_scopes) = \ - // "https://www.googleapis.com/auth/cloud-platform," - // "https://www.googleapis.com/auth/monitoring"; - // ... - // } - string oauth_scopes = 1050; - - // The API version of this service, which should be sent by version-aware - // clients to the service. This allows services to abide by the schema and - // behavior of the service at the time this API version was deployed. - // The format of the API version must be treated as opaque by clients. - // Services may use a format with an apparent structure, but clients must - // not rely on this to determine components within an API version, or attempt - // to construct other valid API versions. Note that this is for upcoming - // functionality and may not be implemented for all services. - // - // Example: - // - // service Foo { - // option (google.api.api_version) = "v1_20230821_preview"; - // } - string api_version = 525000001; -} - -// Required information for every language. -message CommonLanguageSettings { - // Link to automatically generated reference documentation. Example: - // https://cloud.google.com/nodejs/docs/reference/asset/latest - string reference_docs_uri = 1 [deprecated = true]; - - // The destination where API teams want this client library to be published. - repeated ClientLibraryDestination destinations = 2; - - // Configuration for which RPCs should be generated in the GAPIC client. - SelectiveGapicGeneration selective_gapic_generation = 3; -} - -// Details about how and where to publish client libraries. -message ClientLibrarySettings { - // Version of the API to apply these settings to. This is the full protobuf - // package for the API, ending in the version element. - // Examples: "google.cloud.speech.v1" and "google.spanner.admin.database.v1". - string version = 1; - - // Launch stage of this version of the API. - LaunchStage launch_stage = 2; - - // When using transport=rest, the client request will encode enums as - // numbers rather than strings. - bool rest_numeric_enums = 3; - - // Settings for legacy Java features, supported in the Service YAML. - JavaSettings java_settings = 21; - - // Settings for C++ client libraries. - CppSettings cpp_settings = 22; - - // Settings for PHP client libraries. - PhpSettings php_settings = 23; - - // Settings for Python client libraries. - PythonSettings python_settings = 24; - - // Settings for Node client libraries. - NodeSettings node_settings = 25; - - // Settings for .NET client libraries. - DotnetSettings dotnet_settings = 26; - - // Settings for Ruby client libraries. - RubySettings ruby_settings = 27; - - // Settings for Go client libraries. - GoSettings go_settings = 28; -} - -// This message configures the settings for publishing [Google Cloud Client -// libraries](https://cloud.google.com/apis/docs/cloud-client-libraries) -// generated from the service config. -message Publishing { - // A list of API method settings, e.g. the behavior for methods that use the - // long-running operation pattern. - repeated MethodSettings method_settings = 2; - - // Link to a *public* URI where users can report issues. Example: - // https://issuetracker.google.com/issues/new?component=190865&template=1161103 - string new_issue_uri = 101; - - // Link to product home page. Example: - // https://cloud.google.com/asset-inventory/docs/overview - string documentation_uri = 102; - - // Used as a tracking tag when collecting data about the APIs developer - // relations artifacts like docs, packages delivered to package managers, - // etc. Example: "speech". - string api_short_name = 103; - - // GitHub label to apply to issues and pull requests opened for this API. - string github_label = 104; - - // GitHub teams to be added to CODEOWNERS in the directory in GitHub - // containing source code for the client libraries for this API. - repeated string codeowner_github_teams = 105; - - // A prefix used in sample code when demarking regions to be included in - // documentation. - string doc_tag_prefix = 106; - - // For whom the client library is being published. - ClientLibraryOrganization organization = 107; - - // Client library settings. If the same version string appears multiple - // times in this list, then the last one wins. Settings from earlier - // settings with the same version string are discarded. - repeated ClientLibrarySettings library_settings = 109; - - // Optional link to proto reference documentation. Example: - // https://cloud.google.com/pubsub/lite/docs/reference/rpc - string proto_reference_documentation_uri = 110; - - // Optional link to REST reference documentation. Example: - // https://cloud.google.com/pubsub/lite/docs/reference/rest - string rest_reference_documentation_uri = 111; -} - -// Settings for Java client libraries. -message JavaSettings { - // The package name to use in Java. Clobbers the java_package option - // set in the protobuf. This should be used **only** by APIs - // who have already set the language_settings.java.package_name" field - // in gapic.yaml. API teams should use the protobuf java_package option - // where possible. - // - // Example of a YAML configuration:: - // - // publishing: - // java_settings: - // library_package: com.google.cloud.pubsub.v1 - string library_package = 1; - - // Configure the Java class name to use instead of the service's for its - // corresponding generated GAPIC client. Keys are fully-qualified - // service names as they appear in the protobuf (including the full - // the language_settings.java.interface_names" field in gapic.yaml. API - // teams should otherwise use the service name as it appears in the - // protobuf. - // - // Example of a YAML configuration:: - // - // publishing: - // java_settings: - // service_class_names: - // - google.pubsub.v1.Publisher: TopicAdmin - // - google.pubsub.v1.Subscriber: SubscriptionAdmin - map service_class_names = 2; - - // Some settings. - CommonLanguageSettings common = 3; -} - -// Settings for C++ client libraries. -message CppSettings { - // Some settings. - CommonLanguageSettings common = 1; -} - -// Settings for Php client libraries. -message PhpSettings { - // Some settings. - CommonLanguageSettings common = 1; -} - -// Settings for Python client libraries. -message PythonSettings { - // Experimental features to be included during client library generation. - // These fields will be deprecated once the feature graduates and is enabled - // by default. - message ExperimentalFeatures { - // Enables generation of asynchronous REST clients if `rest` transport is - // enabled. By default, asynchronous REST clients will not be generated. - // This feature will be enabled by default 1 month after launching the - // feature in preview packages. - bool rest_async_io_enabled = 1; - - // Enables generation of protobuf code using new types that are more - // Pythonic which are included in `protobuf>=5.29.x`. This feature will be - // enabled by default 1 month after launching the feature in preview - // packages. - bool protobuf_pythonic_types_enabled = 2; - - // Disables generation of an unversioned Python package for this client - // library. This means that the module names will need to be versioned in - // import statements. For example `import google.cloud.library_v2` instead - // of `import google.cloud.library`. - bool unversioned_package_disabled = 3; - } - - // Some settings. - CommonLanguageSettings common = 1; - - // Experimental features to be included during client library generation. - ExperimentalFeatures experimental_features = 2; -} - -// Settings for Node client libraries. -message NodeSettings { - // Some settings. - CommonLanguageSettings common = 1; -} - -// Settings for Dotnet client libraries. -message DotnetSettings { - // Some settings. - CommonLanguageSettings common = 1; - - // Map from original service names to renamed versions. - // This is used when the default generated types - // would cause a naming conflict. (Neither name is - // fully-qualified.) - // Example: Subscriber to SubscriberServiceApi. - map renamed_services = 2; - - // Map from full resource types to the effective short name - // for the resource. This is used when otherwise resource - // named from different services would cause naming collisions. - // Example entry: - // "datalabeling.googleapis.com/Dataset": "DataLabelingDataset" - map renamed_resources = 3; - - // List of full resource types to ignore during generation. - // This is typically used for API-specific Location resources, - // which should be handled by the generator as if they were actually - // the common Location resources. - // Example entry: "documentai.googleapis.com/Location" - repeated string ignored_resources = 4; - - // Namespaces which must be aliased in snippets due to - // a known (but non-generator-predictable) naming collision - repeated string forced_namespace_aliases = 5; - - // Method signatures (in the form "service.method(signature)") - // which are provided separately, so shouldn't be generated. - // Snippets *calling* these methods are still generated, however. - repeated string handwritten_signatures = 6; -} - -// Settings for Ruby client libraries. -message RubySettings { - // Some settings. - CommonLanguageSettings common = 1; -} - -// Settings for Go client libraries. -message GoSettings { - // Some settings. - CommonLanguageSettings common = 1; - - // Map of service names to renamed services. Keys are the package relative - // service names and values are the name to be used for the service client - // and call options. - // - // publishing: - // go_settings: - // renamed_services: - // Publisher: TopicAdmin - map renamed_services = 2; -} - -// Describes the generator configuration for a method. -message MethodSettings { - // Describes settings to use when generating API methods that use the - // long-running operation pattern. - // All default values below are from those used in the client library - // generators (e.g. - // [Java](https://github.com/googleapis/gapic-generator-java/blob/04c2faa191a9b5a10b92392fe8482279c4404803/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java)). - message LongRunning { - // Initial delay after which the first poll request will be made. - // Default value: 5 seconds. - google.protobuf.Duration initial_poll_delay = 1; - - // Multiplier to gradually increase delay between subsequent polls until it - // reaches max_poll_delay. - // Default value: 1.5. - float poll_delay_multiplier = 2; - - // Maximum time between two subsequent poll requests. - // Default value: 45 seconds. - google.protobuf.Duration max_poll_delay = 3; - - // Total polling timeout. - // Default value: 5 minutes. - google.protobuf.Duration total_poll_timeout = 4; - } - - // The fully qualified name of the method, for which the options below apply. - // This is used to find the method to apply the options. - // - // Example: - // - // publishing: - // method_settings: - // - selector: google.storage.control.v2.StorageControl.CreateFolder - // # method settings for CreateFolder... - string selector = 1; - - // Describes settings to use for long-running operations when generating - // API methods for RPCs. Complements RPCs that use the annotations in - // google/longrunning/operations.proto. - // - // Example of a YAML configuration:: - // - // publishing: - // method_settings: - // - selector: google.cloud.speech.v2.Speech.BatchRecognize - // long_running: - // initial_poll_delay: 60s # 1 minute - // poll_delay_multiplier: 1.5 - // max_poll_delay: 360s # 6 minutes - // total_poll_timeout: 54000s # 90 minutes - LongRunning long_running = 2; - - // List of top-level fields of the request message, that should be - // automatically populated by the client libraries based on their - // (google.api.field_info).format. Currently supported format: UUID4. - // - // Example of a YAML configuration: - // - // publishing: - // method_settings: - // - selector: google.example.v1.ExampleService.CreateExample - // auto_populated_fields: - // - request_id - repeated string auto_populated_fields = 3; -} - -// The organization for which the client libraries are being published. -// Affects the url where generated docs are published, etc. -enum ClientLibraryOrganization { - // Not useful. - CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED = 0; - - // Google Cloud Platform Org. - CLOUD = 1; - - // Ads (Advertising) Org. - ADS = 2; - - // Photos Org. - PHOTOS = 3; - - // Street View Org. - STREET_VIEW = 4; - - // Shopping Org. - SHOPPING = 5; - - // Geo Org. - GEO = 6; - - // Generative AI - https://developers.generativeai.google - GENERATIVE_AI = 7; -} - -// To where should client libraries be published? -enum ClientLibraryDestination { - // Client libraries will neither be generated nor published to package - // managers. - CLIENT_LIBRARY_DESTINATION_UNSPECIFIED = 0; - - // Generate the client library in a repo under github.com/googleapis, - // but don't publish it to package managers. - GITHUB = 10; - - // Publish the library to package managers like nuget.org and npmjs.com. - PACKAGE_MANAGER = 20; -} - -// This message is used to configure the generation of a subset of the RPCs in -// a service for client libraries. -message SelectiveGapicGeneration { - // An allowlist of the fully qualified names of RPCs that should be included - // on public client surfaces. - repeated string methods = 1; - - // Setting this to true indicates to the client generators that methods - // that would be excluded from the generation should instead be generated - // in a way that indicates these methods should not be consumed by - // end users. How this is expressed is up to individual language - // implementations to decide. Some examples may be: added annotations, - // obfuscated identifiers, or other language idiomatic patterns. - bool generate_omitted_as_internal = 2; -} diff --git a/third_party/google/api/expr/v1alpha1/checked.proto b/third_party/google/api/expr/v1alpha1/checked.proto deleted file mode 100644 index ffdbee5f..00000000 --- a/third_party/google/api/expr/v1alpha1/checked.proto +++ /dev/null @@ -1,343 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api.expr.v1alpha1; - -import "google/api/expr/v1alpha1/syntax.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/struct.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr"; -option java_multiple_files = true; -option java_outer_classname = "DeclProto"; -option java_package = "com.google.api.expr.v1alpha1"; - -// Protos for representing CEL declarations and typed checked expressions. - -// A CEL expression which has been successfully type checked. -message CheckedExpr { - // A map from expression ids to resolved references. - // - // The following entries are in this table: - // - // - An Ident or Select expression is represented here if it resolves to a - // declaration. For instance, if `a.b.c` is represented by - // `select(select(id(a), b), c)`, and `a.b` resolves to a declaration, - // while `c` is a field selection, then the reference is attached to the - // nested select expression (but not to the id or or the outer select). - // In turn, if `a` resolves to a declaration and `b.c` are field selections, - // the reference is attached to the ident expression. - // - Every Call expression has an entry here, identifying the function being - // called. - // - Every CreateStruct expression for a message has an entry, identifying - // the message. - map reference_map = 2; - - // A map from expression ids to types. - // - // Every expression node which has a type different than DYN has a mapping - // here. If an expression has type DYN, it is omitted from this map to save - // space. - map type_map = 3; - - // The source info derived from input that generated the parsed `expr` and - // any optimizations made during the type-checking pass. - SourceInfo source_info = 5; - - // The expr version indicates the major / minor version number of the `expr` - // representation. - // - // The most common reason for a version change will be to indicate to the CEL - // runtimes that transformations have been performed on the expr during static - // analysis. In some cases, this will save the runtime the work of applying - // the same or similar transformations prior to evaluation. - string expr_version = 6; - - // The checked expression. Semantically equivalent to the parsed `expr`, but - // may have structural differences. - Expr expr = 4; -} - -// Represents a CEL type. -message Type { - // List type with typed elements, e.g. `list`. - message ListType { - // The element type. - Type elem_type = 1; - } - - // Map type with parameterized key and value types, e.g. `map`. - message MapType { - // The type of the key. - Type key_type = 1; - - // The type of the value. - Type value_type = 2; - } - - // Function type with result and arg types. - message FunctionType { - // Result type of the function. - Type result_type = 1; - - // Argument types of the function. - repeated Type arg_types = 2; - } - - // Application defined abstract type. - message AbstractType { - // The fully qualified name of this abstract type. - string name = 1; - - // Parameter types for this abstract type. - repeated Type parameter_types = 2; - } - - // CEL primitive types. - enum PrimitiveType { - // Unspecified type. - PRIMITIVE_TYPE_UNSPECIFIED = 0; - - // Boolean type. - BOOL = 1; - - // Int64 type. - // - // Proto-based integer values are widened to int64. - INT64 = 2; - - // Uint64 type. - // - // Proto-based unsigned integer values are widened to uint64. - UINT64 = 3; - - // Double type. - // - // Proto-based float values are widened to double values. - DOUBLE = 4; - - // String type. - STRING = 5; - - // Bytes type. - BYTES = 6; - } - - // Well-known protobuf types treated with first-class support in CEL. - enum WellKnownType { - // Unspecified type. - WELL_KNOWN_TYPE_UNSPECIFIED = 0; - - // Well-known protobuf.Any type. - // - // Any types are a polymorphic message type. During type-checking they are - // treated like `DYN` types, but at runtime they are resolved to a specific - // message type specified at evaluation time. - ANY = 1; - - // Well-known protobuf.Timestamp type, internally referenced as `timestamp`. - TIMESTAMP = 2; - - // Well-known protobuf.Duration type, internally referenced as `duration`. - DURATION = 3; - } - - // The kind of type. - oneof type_kind { - // Dynamic type. - google.protobuf.Empty dyn = 1; - - // Null value. - google.protobuf.NullValue null = 2; - - // Primitive types: `true`, `1u`, `-2.0`, `'string'`, `b'bytes'`. - PrimitiveType primitive = 3; - - // Wrapper of a primitive type, e.g. `google.protobuf.Int64Value`. - PrimitiveType wrapper = 4; - - // Well-known protobuf type such as `google.protobuf.Timestamp`. - WellKnownType well_known = 5; - - // Parameterized list with elements of `list_type`, e.g. `list`. - ListType list_type = 6; - - // Parameterized map with typed keys and values. - MapType map_type = 7; - - // Function type. - FunctionType function = 8; - - // Protocol buffer message type. - // - // The `message_type` string specifies the qualified message type name. For - // example, `google.plus.Profile`. - string message_type = 9; - - // Type param type. - // - // The `type_param` string specifies the type parameter name, e.g. `list` - // would be a `list_type` whose element type was a `type_param` type - // named `E`. - string type_param = 10; - - // Type type. - // - // The `type` value specifies the target type. e.g. int is type with a - // target type of `Primitive.INT`. - Type type = 11; - - // Error type. - // - // During type-checking if an expression is an error, its type is propagated - // as the `ERROR` type. This permits the type-checker to discover other - // errors present in the expression. - google.protobuf.Empty error = 12; - - // Abstract, application defined type. - AbstractType abstract_type = 14; - } -} - -// Represents a declaration of a named value or function. -// -// A declaration is part of the contract between the expression, the agent -// evaluating that expression, and the caller requesting evaluation. -message Decl { - // Identifier declaration which specifies its type and optional `Expr` value. - // - // An identifier without a value is a declaration that must be provided at - // evaluation time. An identifier with a value should resolve to a constant, - // but may be used in conjunction with other identifiers bound at evaluation - // time. - message IdentDecl { - // Required. The type of the identifier. - Type type = 1; - - // The constant value of the identifier. If not specified, the identifier - // must be supplied at evaluation time. - Constant value = 2; - - // Documentation string for the identifier. - string doc = 3; - } - - // Function declaration specifies one or more overloads which indicate the - // function's parameter types and return type. - // - // Functions have no observable side-effects (there may be side-effects like - // logging which are not observable from CEL). - message FunctionDecl { - // An overload indicates a function's parameter types and return type, and - // may optionally include a function body described in terms of - // [Expr][google.api.expr.v1alpha1.Expr] values. - // - // Functions overloads are declared in either a function or method - // call-style. For methods, the `params[0]` is the expected type of the - // target receiver. - // - // Overloads must have non-overlapping argument types after erasure of all - // parameterized type variables (similar as type erasure in Java). - message Overload { - // Required. Globally unique overload name of the function which reflects - // the function name and argument types. - // - // This will be used by a [Reference][google.api.expr.v1alpha1.Reference] - // to indicate the `overload_id` that was resolved for the function - // `name`. - string overload_id = 1; - - // List of function parameter [Type][google.api.expr.v1alpha1.Type] - // values. - // - // Param types are disjoint after generic type parameters have been - // replaced with the type `DYN`. Since the `DYN` type is compatible with - // any other type, this means that if `A` is a type parameter, the - // function types `int` and `int` are not disjoint. Likewise, - // `map` is not disjoint from `map`. - // - // When the `result_type` of a function is a generic type param, the - // type param name also appears as the `type` of on at least one params. - repeated Type params = 2; - - // The type param names associated with the function declaration. - // - // For example, `function ex(K key, map map) : V` would yield - // the type params of `K, V`. - repeated string type_params = 3; - - // Required. The result type of the function. For example, the operator - // `string.isEmpty()` would have `result_type` of `kind: BOOL`. - Type result_type = 4; - - // Whether the function is to be used in a method call-style `x.f(...)` - // or a function call-style `f(x, ...)`. - // - // For methods, the first parameter declaration, `params[0]` is the - // expected type of the target receiver. - bool is_instance_function = 5; - - // Documentation string for the overload. - string doc = 6; - } - - // Required. List of function overloads, must contain at least one overload. - repeated Overload overloads = 1; - } - - // The fully qualified name of the declaration. - // - // Declarations are organized in containers and this represents the full path - // to the declaration in its container, as in `google.api.expr.Decl`. - // - // Declarations used as - // [FunctionDecl.Overload][google.api.expr.v1alpha1.Decl.FunctionDecl.Overload] - // parameters may or may not have a name depending on whether the overload is - // function declaration or a function definition containing a result - // [Expr][google.api.expr.v1alpha1.Expr]. - string name = 1; - - // Required. The declaration kind. - oneof decl_kind { - // Identifier declaration. - IdentDecl ident = 2; - - // Function declaration. - FunctionDecl function = 3; - } -} - -// Describes a resolved reference to a declaration. -message Reference { - // The fully qualified name of the declaration. - string name = 1; - - // For references to functions, this is a list of `Overload.overload_id` - // values which match according to typing rules. - // - // If the list has more than one element, overload resolution among the - // presented candidates must happen at runtime because of dynamic types. The - // type checker attempts to narrow down this list as much as possible. - // - // Empty if this is not a reference to a - // [Decl.FunctionDecl][google.api.expr.v1alpha1.Decl.FunctionDecl]. - repeated string overload_id = 3; - - // For references to constants, this may contain the value of the - // constant if known at compile time. - Constant value = 4; -} diff --git a/third_party/google/api/expr/v1alpha1/eval.proto b/third_party/google/api/expr/v1alpha1/eval.proto deleted file mode 100644 index cdf1d48d..00000000 --- a/third_party/google/api/expr/v1alpha1/eval.proto +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api.expr.v1alpha1; - -import "google/api/expr/v1alpha1/value.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr"; -option java_multiple_files = true; -option java_outer_classname = "EvalProto"; -option java_package = "com.google.api.expr.v1alpha1"; - -// The state of an evaluation. -// -// Can represent an inital, partial, or completed state of evaluation. -message EvalState { - // A single evalution result. - message Result { - // The id of the expression this result if for. - int64 expr = 1; - - // The index in `values` of the resulting value. - int64 value = 2; - } - - // The unique values referenced in this message. - repeated ExprValue values = 1; - - // An ordered list of results. - // - // Tracks the flow of evaluation through the expression. - // May be sparse. - repeated Result results = 3; -} - -// The value of an evaluated expression. -message ExprValue { - // An expression can resolve to a value, error or unknown. - oneof kind { - // A concrete value. - Value value = 1; - - // The set of errors in the critical path of evalution. - // - // Only errors in the critical path are included. For example, - // `( || true) && ` will only result in ``, - // while ` || ` will result in both `` and - // ``. - // - // Errors cause by the presence of other errors are not included in the - // set. For example `.foo`, `foo()`, and ` + 1` will - // only result in ``. - // - // Multiple errors *might* be included when evaluation could result - // in different errors. For example ` + ` and - // `foo(, )` may result in ``, `` or both. - // The exact subset of errors included for this case is unspecified and - // depends on the implementation details of the evaluator. - ErrorSet error = 2; - - // The set of unknowns in the critical path of evaluation. - // - // Unknown behaves identically to Error with regards to propagation. - // Specifically, only unknowns in the critical path are included, unknowns - // caused by the presence of other unknowns are not included, and multiple - // unknowns *might* be included included when evaluation could result in - // different unknowns. For example: - // - // ( || true) && -> - // || -> - // .foo -> - // foo() -> - // + -> or - // - // Unknown takes precidence over Error in cases where a `Value` can short - // circuit the result: - // - // || -> - // && -> - // - // Errors take precidence in all other cases: - // - // + -> - // foo(, ) -> - UnknownSet unknown = 3; - } -} - -// A set of errors. -// -// The errors included depend on the context. See `ExprValue.error`. -message ErrorSet { - // The errors in the set. - repeated google.rpc.Status errors = 1; -} - -// A set of expressions for which the value is unknown. -// -// The unknowns included depend on the context. See `ExprValue.unknown`. -message UnknownSet { - // The ids of the expressions with unknown values. - repeated int64 exprs = 1; -} diff --git a/third_party/google/api/expr/v1alpha1/explain.proto b/third_party/google/api/expr/v1alpha1/explain.proto deleted file mode 100644 index cd5ffc29..00000000 --- a/third_party/google/api/expr/v1alpha1/explain.proto +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api.expr.v1alpha1; - -import "google/api/expr/v1alpha1/value.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr"; -option java_multiple_files = true; -option java_outer_classname = "ExplainProto"; -option java_package = "com.google.api.expr.v1alpha1"; - -// Values of intermediate expressions produced when evaluating expression. -// Deprecated, use `EvalState` instead. -message Explain { - option deprecated = true; - - // ID and value index of one step. - message ExprStep { - // ID of corresponding Expr node. - int64 id = 1; - - // Index of the value in the values list. - int32 value_index = 2; - } - - // All of the observed values. - // - // The field value_index is an index in the values list. - // Separating values from steps is needed to remove redundant values. - repeated Value values = 1; - - // List of steps. - // - // Repeated evaluations of the same expression generate new ExprStep - // instances. The order of such ExprStep instances matches the order of - // elements returned by Comprehension.iter_range. - repeated ExprStep expr_steps = 2; -} diff --git a/third_party/google/api/expr/v1alpha1/syntax.proto b/third_party/google/api/expr/v1alpha1/syntax.proto deleted file mode 100644 index b0cdd4d4..00000000 --- a/third_party/google/api/expr/v1alpha1/syntax.proto +++ /dev/null @@ -1,438 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api.expr.v1alpha1; - -import "google/protobuf/duration.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr"; -option java_multiple_files = true; -option java_outer_classname = "SyntaxProto"; -option java_package = "com.google.api.expr.v1alpha1"; - -// A representation of the abstract syntax of the Common Expression Language. - -// An expression together with source information as returned by the parser. -message ParsedExpr { - // The parsed expression. - Expr expr = 2; - - // The source info derived from input that generated the parsed `expr`. - SourceInfo source_info = 3; -} - -// An abstract representation of a common expression. -// -// Expressions are abstractly represented as a collection of identifiers, -// select statements, function calls, literals, and comprehensions. All -// operators with the exception of the '.' operator are modelled as function -// calls. This makes it easy to represent new operators into the existing AST. -// -// All references within expressions must resolve to a -// [Decl][google.api.expr.v1alpha1.Decl] provided at type-check for an -// expression to be valid. A reference may either be a bare identifier `name` or -// a qualified identifier `google.api.name`. References may either refer to a -// value or a function declaration. -// -// For example, the expression `google.api.name.startsWith('expr')` references -// the declaration `google.api.name` within a -// [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and the -// function declaration `startsWith`. -message Expr { - // An identifier expression. e.g. `request`. - message Ident { - // Required. Holds a single, unqualified identifier, possibly preceded by a - // '.'. - // - // Qualified names are represented by the - // [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression. - string name = 1; - } - - // A field selection expression. e.g. `request.auth`. - message Select { - // Required. The target of the selection expression. - // - // For example, in the select expression `request.auth`, the `request` - // portion of the expression is the `operand`. - Expr operand = 1; - - // Required. The name of the field to select. - // - // For example, in the select expression `request.auth`, the `auth` portion - // of the expression would be the `field`. - string field = 2; - - // Whether the select is to be interpreted as a field presence test. - // - // This results from the macro `has(request.auth)`. - bool test_only = 3; - } - - // A call expression, including calls to predefined functions and operators. - // - // For example, `value == 10`, `size(map_value)`. - message Call { - // The target of an method call-style expression. For example, `x` in - // `x.f()`. - Expr target = 1; - - // Required. The name of the function or method being called. - string function = 2; - - // The arguments. - repeated Expr args = 3; - } - - // A list creation expression. - // - // Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogeneous, e.g. - // `dyn([1, 'hello', 2.0])` - message CreateList { - // The elements part of the list. - repeated Expr elements = 1; - - // The indices within the elements list which are marked as optional - // elements. - // - // When an optional-typed value is present, the value it contains - // is included in the list. If the optional-typed value is absent, the list - // element is omitted from the CreateList result. - repeated int32 optional_indices = 2; - } - - // A map or message creation expression. - // - // Maps are constructed as `{'key_name': 'value'}`. Message construction is - // similar, but prefixed with a type name and composed of field ids: - // `types.MyType{field_id: 'value'}`. - message CreateStruct { - // Represents an entry. - message Entry { - // Required. An id assigned to this node by the parser which is unique - // in a given expression tree. This is used to associate type - // information and other attributes to the node. - int64 id = 1; - - // The `Entry` key kinds. - oneof key_kind { - // The field key for a message creator statement. - string field_key = 2; - - // The key expression for a map creation statement. - Expr map_key = 3; - } - - // Required. The value assigned to the key. - // - // If the optional_entry field is true, the expression must resolve to an - // optional-typed value. If the optional value is present, the key will be - // set; however, if the optional value is absent, the key will be unset. - Expr value = 4; - - // Whether the key-value pair is optional. - bool optional_entry = 5; - } - - // The type name of the message to be created, empty when creating map - // literals. - string message_name = 1; - - // The entries in the creation expression. - repeated Entry entries = 2; - } - - // A comprehension expression applied to a list or map. - // - // Comprehensions are not part of the core syntax, but enabled with macros. - // A macro matches a specific call signature within a parsed AST and replaces - // the call with an alternate AST block. Macro expansion happens at parse - // time. - // - // The following macros are supported within CEL: - // - // Aggregate type macros may be applied to all elements in a list or all keys - // in a map: - // - // * `all`, `exists`, `exists_one` - test a predicate expression against - // the inputs and return `true` if the predicate is satisfied for all, - // any, or only one value `list.all(x, x < 10)`. - // * `filter` - test a predicate expression against the inputs and return - // the subset of elements which satisfy the predicate: - // `payments.filter(p, p > 1000)`. - // * `map` - apply an expression to all elements in the input and return the - // output aggregate type: `[1, 2, 3].map(i, i * i)`. - // - // The `has(m.x)` macro tests whether the property `x` is present in struct - // `m`. The semantics of this macro depend on the type of `m`. For proto2 - // messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the - // macro tests whether the property is set to its default. For map and struct - // types, the macro tests whether the property `x` is defined on `m`. - // - // Comprehensions for the standard environment macros evaluation can be best - // visualized as the following pseudocode: - // - // ``` - // let `accu_var` = `accu_init` - // for (let `iter_var` in `iter_range`) { - // if (!`loop_condition`) { - // break - // } - // `accu_var` = `loop_step` - // } - // return `result` - // ``` - // - // Comprehensions for the optional V2 macros which support map-to-map - // translation differ slightly from the standard environment macros in that - // they expose both the key or index in addition to the value for each list - // or map entry: - // - // ``` - // let `accu_var` = `accu_init` - // for (let `iter_var`, `iter_var2` in `iter_range`) { - // if (!`loop_condition`) { - // break - // } - // `accu_var` = `loop_step` - // } - // return `result` - // ``` - message Comprehension { - // The name of the first iteration variable. - // When the iter_range is a list, this variable is the list element. - // When the iter_range is a map, this variable is the map entry key. - string iter_var = 1; - - // The name of the second iteration variable, empty if not set. - // When the iter_range is a list, this variable is the integer index. - // When the iter_range is a map, this variable is the map entry value. - // This field is only set for comprehension v2 macros. - string iter_var2 = 8; - - // The range over which the comprehension iterates. - Expr iter_range = 2; - - // The name of the variable used for accumulation of the result. - string accu_var = 3; - - // The initial value of the accumulator. - Expr accu_init = 4; - - // An expression which can contain iter_var, iter_var2, and accu_var. - // - // Returns false when the result has been computed and may be used as - // a hint to short-circuit the remainder of the comprehension. - Expr loop_condition = 5; - - // An expression which can contain iter_var, iter_var2, and accu_var. - // - // Computes the next value of accu_var. - Expr loop_step = 6; - - // An expression which can contain accu_var. - // - // Computes the result. - Expr result = 7; - } - - // Required. An id assigned to this node by the parser which is unique in a - // given expression tree. This is used to associate type information and other - // attributes to a node in the parse tree. - int64 id = 2; - - // Required. Variants of expressions. - oneof expr_kind { - // A literal expression. - Constant const_expr = 3; - - // An identifier expression. - Ident ident_expr = 4; - - // A field selection expression, e.g. `request.auth`. - Select select_expr = 5; - - // A call expression, including calls to predefined functions and operators. - Call call_expr = 6; - - // A list creation expression. - CreateList list_expr = 7; - - // A map or message creation expression. - CreateStruct struct_expr = 8; - - // A comprehension expression. - Comprehension comprehension_expr = 9; - } -} - -// Represents a primitive literal. -// -// Named 'Constant' here for backwards compatibility. -// -// This is similar as the primitives supported in the well-known type -// `google.protobuf.Value`, but richer so it can represent CEL's full range of -// primitives. -// -// Lists and structs are not included as constants as these aggregate types may -// contain [Expr][google.api.expr.v1alpha1.Expr] elements which require -// evaluation and are thus not constant. -// -// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`, -// `true`, `null`. -message Constant { - // Required. The valid constant kinds. - oneof constant_kind { - // null value. - google.protobuf.NullValue null_value = 1; - - // boolean value. - bool bool_value = 2; - - // int64 value. - int64 int64_value = 3; - - // uint64 value. - uint64 uint64_value = 4; - - // double value. - double double_value = 5; - - // string value. - string string_value = 6; - - // bytes value. - bytes bytes_value = 7; - - // protobuf.Duration value. - // - // Deprecated: duration is no longer considered a builtin cel type. - google.protobuf.Duration duration_value = 8 [deprecated = true]; - - // protobuf.Timestamp value. - // - // Deprecated: timestamp is no longer considered a builtin cel type. - google.protobuf.Timestamp timestamp_value = 9 [deprecated = true]; - } -} - -// Source information collected at parse time. -message SourceInfo { - // An extension that was requested for the source expression. - message Extension { - // Version - message Version { - // Major version changes indicate different required support level from - // the required components. - int64 major = 1; - - // Minor version changes must not change the observed behavior from - // existing implementations, but may be provided informationally. - int64 minor = 2; - } - - // CEL component specifier. - enum Component { - // Unspecified, default. - COMPONENT_UNSPECIFIED = 0; - - // Parser. Converts a CEL string to an AST. - COMPONENT_PARSER = 1; - - // Type checker. Checks that references in an AST are defined and types - // agree. - COMPONENT_TYPE_CHECKER = 2; - - // Runtime. Evaluates a parsed and optionally checked CEL AST against a - // context. - COMPONENT_RUNTIME = 3; - } - - // Identifier for the extension. Example: constant_folding - string id = 1; - - // If set, the listed components must understand the extension for the - // expression to evaluate correctly. - // - // This field has set semantics, repeated values should be deduplicated. - repeated Component affected_components = 2; - - // Version info. May be skipped if it isn't meaningful for the extension. - // (for example constant_folding might always be v0.0). - Version version = 3; - } - - // The syntax version of the source, e.g. `cel1`. - string syntax_version = 1; - - // The location name. All position information attached to an expression is - // relative to this location. - // - // The location could be a file, UI element, or similar. For example, - // `acme/app/AnvilPolicy.cel`. - string location = 2; - - // Monotonically increasing list of code point offsets where newlines - // `\n` appear. - // - // The line number of a given position is the index `i` where for a given - // `id` the `line_offsets[i] < id_positions[id] < line_offsets[i+1]`. The - // column may be derivd from `id_positions[id] - line_offsets[i]`. - repeated int32 line_offsets = 3; - - // A map from the parse node id (e.g. `Expr.id`) to the code point offset - // within the source. - map positions = 4; - - // A map from the parse node id where a macro replacement was made to the - // call `Expr` that resulted in a macro expansion. - // - // For example, `has(value.field)` is a function call that is replaced by a - // `test_only` field selection in the AST. Likewise, the call - // `list.exists(e, e > 10)` translates to a comprehension expression. The key - // in the map corresponds to the expression id of the expanded macro, and the - // value is the call `Expr` that was replaced. - map macro_calls = 5; - - // A list of tags for extensions that were used while parsing or type checking - // the source expression. For example, optimizations that require special - // runtime support may be specified. - // - // These are used to check feature support between components in separate - // implementations. This can be used to either skip redundant work or - // report an error if the extension is unsupported. - repeated Extension extensions = 6; -} - -// A specific position in source. -message SourcePosition { - // The soucre location name (e.g. file name). - string location = 1; - - // The UTF-8 code unit offset. - int32 offset = 2; - - // The 1-based index of the starting line in the source text - // where the issue occurs, or 0 if unknown. - int32 line = 3; - - // The 0-based index of the starting position within the line of source text - // where the issue occurs. Only meaningful if line is nonzero. - int32 column = 4; -} diff --git a/third_party/google/api/expr/v1alpha1/value.proto b/third_party/google/api/expr/v1alpha1/value.proto deleted file mode 100644 index 9d695207..00000000 --- a/third_party/google/api/expr/v1alpha1/value.proto +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api.expr.v1alpha1; - -import "google/protobuf/any.proto"; -import "google/protobuf/struct.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr"; -option java_multiple_files = true; -option java_outer_classname = "ValueProto"; -option java_package = "com.google.api.expr.v1alpha1"; - -// Contains representations for CEL runtime values. - -// Represents a CEL value. -// -// This is similar to `google.protobuf.Value`, but can represent CEL's full -// range of values. -message Value { - // Required. The valid kinds of values. - oneof kind { - // Null value. - google.protobuf.NullValue null_value = 1; - - // Boolean value. - bool bool_value = 2; - - // Signed integer value. - int64 int64_value = 3; - - // Unsigned integer value. - uint64 uint64_value = 4; - - // Floating point value. - double double_value = 5; - - // UTF-8 string value. - string string_value = 6; - - // Byte string value. - bytes bytes_value = 7; - - // An enum value. - EnumValue enum_value = 9; - - // The proto message backing an object value. - google.protobuf.Any object_value = 10; - - // Map value. - MapValue map_value = 11; - - // List value. - ListValue list_value = 12; - - // Type value. - string type_value = 15; - } -} - -// An enum value. -message EnumValue { - // The fully qualified name of the enum type. - string type = 1; - - // The value of the enum. - int32 value = 2; -} - -// A list. -// -// Wrapped in a message so 'not set' and empty can be differentiated, which is -// required for use in a 'oneof'. -message ListValue { - // The ordered values in the list. - repeated Value values = 1; -} - -// A map. -// -// Wrapped in a message so 'not set' and empty can be differentiated, which is -// required for use in a 'oneof'. -message MapValue { - // An entry in the map. - message Entry { - // The key. - // - // Must be unique with in the map. - // Currently only boolean, int, uint, and string values can be keys. - Value key = 1; - - // The value. - Value value = 2; - } - - // The set of map entries. - // - // CEL has fewer restrictions on keys, so a protobuf map represenation - // cannot be used. - repeated Entry entries = 1; -} diff --git a/third_party/google/api/expr/v1beta1/decl.proto b/third_party/google/api/expr/v1beta1/decl.proto deleted file mode 100644 index b433b2df..00000000 --- a/third_party/google/api/expr/v1beta1/decl.proto +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.api.expr.v1beta1; - -import "google/api/expr/v1beta1/expr.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr"; -option java_multiple_files = true; -option java_outer_classname = "DeclProto"; -option java_package = "com.google.api.expr.v1beta1"; - -// A declaration. -message Decl { - // The id of the declaration. - int32 id = 1; - - // The name of the declaration. - string name = 2; - - // The documentation string for the declaration. - string doc = 3; - - // The kind of declaration. - oneof kind { - // An identifier declaration. - IdentDecl ident = 4; - - // A function declaration. - FunctionDecl function = 5; - } -} - -// The declared type of a variable. -// -// Extends runtime type values with extra information used for type checking -// and dispatching. -message DeclType { - // The expression id of the declared type, if applicable. - int32 id = 1; - - // The type name, e.g. 'int', 'my.type.Type' or 'T' - string type = 2; - - // An ordered list of type parameters, e.g. ``. - // Only applies to a subset of types, e.g. `map`, `list`. - repeated DeclType type_params = 4; -} - -// An identifier declaration. -message IdentDecl { - // Optional type of the identifier. - DeclType type = 3; - - // Optional value of the identifier. - Expr value = 4; -} - -// A function declaration. -message FunctionDecl { - // The function arguments. - repeated IdentDecl args = 1; - - // Optional declared return type. - DeclType return_type = 2; - - // If the first argument of the function is the receiver. - bool receiver_function = 3; -} diff --git a/third_party/google/api/expr/v1beta1/eval.proto b/third_party/google/api/expr/v1beta1/eval.proto deleted file mode 100644 index cb8928c3..00000000 --- a/third_party/google/api/expr/v1beta1/eval.proto +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.api.expr.v1beta1; - -import "google/api/expr/v1beta1/value.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr"; -option java_multiple_files = true; -option java_outer_classname = "EvalProto"; -option java_package = "com.google.api.expr.v1beta1"; - -// The state of an evaluation. -// -// Can represent an initial, partial, or completed state of evaluation. -message EvalState { - // A single evaluation result. - message Result { - // The expression this result is for. - IdRef expr = 1; - - // The index in `values` of the resulting value. - int32 value = 2; - } - - // The unique values referenced in this message. - repeated ExprValue values = 1; - - // An ordered list of results. - // - // Tracks the flow of evaluation through the expression. - // May be sparse. - repeated Result results = 3; -} - -// The value of an evaluated expression. -message ExprValue { - // An expression can resolve to a value, error or unknown. - oneof kind { - // A concrete value. - Value value = 1; - - // The set of errors in the critical path of evalution. - // - // Only errors in the critical path are included. For example, - // `( || true) && ` will only result in ``, - // while ` || ` will result in both `` and - // ``. - // - // Errors cause by the presence of other errors are not included in the - // set. For example `.foo`, `foo()`, and ` + 1` will - // only result in ``. - // - // Multiple errors *might* be included when evaluation could result - // in different errors. For example ` + ` and - // `foo(, )` may result in ``, `` or both. - // The exact subset of errors included for this case is unspecified and - // depends on the implementation details of the evaluator. - ErrorSet error = 2; - - // The set of unknowns in the critical path of evaluation. - // - // Unknown behaves identically to Error with regards to propagation. - // Specifically, only unknowns in the critical path are included, unknowns - // caused by the presence of other unknowns are not included, and multiple - // unknowns *might* be included included when evaluation could result in - // different unknowns. For example: - // - // ( || true) && -> - // || -> - // .foo -> - // foo() -> - // + -> or - // - // Unknown takes precidence over Error in cases where a `Value` can short - // circuit the result: - // - // || -> - // && -> - // - // Errors take precidence in all other cases: - // - // + -> - // foo(, ) -> - UnknownSet unknown = 3; - } -} - -// A set of errors. -// -// The errors included depend on the context. See `ExprValue.error`. -message ErrorSet { - // The errors in the set. - repeated google.rpc.Status errors = 1; -} - -// A set of expressions for which the value is unknown. -// -// The unknowns included depend on the context. See `ExprValue.unknown`. -message UnknownSet { - // The ids of the expressions with unknown values. - repeated IdRef exprs = 1; -} - -// A reference to an expression id. -message IdRef { - // The expression id. - int32 id = 1; -} diff --git a/third_party/google/api/expr/v1beta1/expr.proto b/third_party/google/api/expr/v1beta1/expr.proto deleted file mode 100644 index b20a860c..00000000 --- a/third_party/google/api/expr/v1beta1/expr.proto +++ /dev/null @@ -1,265 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.api.expr.v1beta1; - -import "google/api/expr/v1beta1/source.proto"; -import "google/protobuf/struct.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr"; -option java_multiple_files = true; -option java_outer_classname = "ExprProto"; -option java_package = "com.google.api.expr.v1beta1"; - -// An expression together with source information as returned by the parser. -message ParsedExpr { - // The parsed expression. - Expr expr = 2; - - // The source info derived from input that generated the parsed `expr`. - SourceInfo source_info = 3; - - // The syntax version of the source, e.g. `cel1`. - string syntax_version = 4; -} - -// An abstract representation of a common expression. -// -// Expressions are abstractly represented as a collection of identifiers, -// select statements, function calls, literals, and comprehensions. All -// operators with the exception of the '.' operator are modelled as function -// calls. This makes it easy to represent new operators into the existing AST. -// -// All references within expressions must resolve to a [Decl][google.api.expr.v1beta1.Decl] provided at -// type-check for an expression to be valid. A reference may either be a bare -// identifier `name` or a qualified identifier `google.api.name`. References -// may either refer to a value or a function declaration. -// -// For example, the expression `google.api.name.startsWith('expr')` references -// the declaration `google.api.name` within a [Expr.Select][google.api.expr.v1beta1.Expr.Select] expression, and -// the function declaration `startsWith`. -message Expr { - // An identifier expression. e.g. `request`. - message Ident { - // Required. Holds a single, unqualified identifier, possibly preceded by a - // '.'. - // - // Qualified names are represented by the [Expr.Select][google.api.expr.v1beta1.Expr.Select] expression. - string name = 1; - } - - // A field selection expression. e.g. `request.auth`. - message Select { - // Required. The target of the selection expression. - // - // For example, in the select expression `request.auth`, the `request` - // portion of the expression is the `operand`. - Expr operand = 1; - - // Required. The name of the field to select. - // - // For example, in the select expression `request.auth`, the `auth` portion - // of the expression would be the `field`. - string field = 2; - - // Whether the select is to be interpreted as a field presence test. - // - // This results from the macro `has(request.auth)`. - bool test_only = 3; - } - - // A call expression, including calls to predefined functions and operators. - // - // For example, `value == 10`, `size(map_value)`. - message Call { - // The target of an method call-style expression. For example, `x` in - // `x.f()`. - Expr target = 1; - - // Required. The name of the function or method being called. - string function = 2; - - // The arguments. - repeated Expr args = 3; - } - - // A list creation expression. - // - // Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogenous, e.g. - // `dyn([1, 'hello', 2.0])` - message CreateList { - // The elements part of the list. - repeated Expr elements = 1; - } - - // A map or message creation expression. - // - // Maps are constructed as `{'key_name': 'value'}`. Message construction is - // similar, but prefixed with a type name and composed of field ids: - // `types.MyType{field_id: 'value'}`. - message CreateStruct { - // Represents an entry. - message Entry { - // Required. An id assigned to this node by the parser which is unique - // in a given expression tree. This is used to associate type - // information and other attributes to the node. - int32 id = 1; - - // The `Entry` key kinds. - oneof key_kind { - // The field key for a message creator statement. - string field_key = 2; - - // The key expression for a map creation statement. - Expr map_key = 3; - } - - // Required. The value assigned to the key. - Expr value = 4; - } - - // The type name of the message to be created, empty when creating map - // literals. - string type = 1; - - // The entries in the creation expression. - repeated Entry entries = 2; - } - - // A comprehension expression applied to a list or map. - // - // Comprehensions are not part of the core syntax, but enabled with macros. - // A macro matches a specific call signature within a parsed AST and replaces - // the call with an alternate AST block. Macro expansion happens at parse - // time. - // - // The following macros are supported within CEL: - // - // Aggregate type macros may be applied to all elements in a list or all keys - // in a map: - // - // * `all`, `exists`, `exists_one` - test a predicate expression against - // the inputs and return `true` if the predicate is satisfied for all, - // any, or only one value `list.all(x, x < 10)`. - // * `filter` - test a predicate expression against the inputs and return - // the subset of elements which satisfy the predicate: - // `payments.filter(p, p > 1000)`. - // * `map` - apply an expression to all elements in the input and return the - // output aggregate type: `[1, 2, 3].map(i, i * i)`. - // - // The `has(m.x)` macro tests whether the property `x` is present in struct - // `m`. The semantics of this macro depend on the type of `m`. For proto2 - // messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the - // macro tests whether the property is set to its default. For map and struct - // types, the macro tests whether the property `x` is defined on `m`. - message Comprehension { - // The name of the iteration variable. - string iter_var = 1; - - // The range over which var iterates. - Expr iter_range = 2; - - // The name of the variable used for accumulation of the result. - string accu_var = 3; - - // The initial value of the accumulator. - Expr accu_init = 4; - - // An expression which can contain iter_var and accu_var. - // - // Returns false when the result has been computed and may be used as - // a hint to short-circuit the remainder of the comprehension. - Expr loop_condition = 5; - - // An expression which can contain iter_var and accu_var. - // - // Computes the next value of accu_var. - Expr loop_step = 6; - - // An expression which can contain accu_var. - // - // Computes the result. - Expr result = 7; - } - - // Required. An id assigned to this node by the parser which is unique in a - // given expression tree. This is used to associate type information and other - // attributes to a node in the parse tree. - int32 id = 2; - - // Required. Variants of expressions. - oneof expr_kind { - // A literal expression. - Literal literal_expr = 3; - - // An identifier expression. - Ident ident_expr = 4; - - // A field selection expression, e.g. `request.auth`. - Select select_expr = 5; - - // A call expression, including calls to predefined functions and operators. - Call call_expr = 6; - - // A list creation expression. - CreateList list_expr = 7; - - // A map or object creation expression. - CreateStruct struct_expr = 8; - - // A comprehension expression. - Comprehension comprehension_expr = 9; - } -} - -// Represents a primitive literal. -// -// This is similar to the primitives supported in the well-known type -// `google.protobuf.Value`, but richer so it can represent CEL's full range of -// primitives. -// -// Lists and structs are not included as constants as these aggregate types may -// contain [Expr][google.api.expr.v1beta1.Expr] elements which require evaluation and are thus not constant. -// -// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`, -// `true`, `null`. -message Literal { - // Required. The valid constant kinds. - oneof constant_kind { - // null value. - google.protobuf.NullValue null_value = 1; - - // boolean value. - bool bool_value = 2; - - // int64 value. - int64 int64_value = 3; - - // uint64 value. - uint64 uint64_value = 4; - - // double value. - double double_value = 5; - - // string value. - string string_value = 6; - - // bytes value. - bytes bytes_value = 7; - } -} diff --git a/third_party/google/api/expr/v1beta1/source.proto b/third_party/google/api/expr/v1beta1/source.proto deleted file mode 100644 index fdf173ba..00000000 --- a/third_party/google/api/expr/v1beta1/source.proto +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.api.expr.v1beta1; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr"; -option java_multiple_files = true; -option java_outer_classname = "SourceProto"; -option java_package = "com.google.api.expr.v1beta1"; - -// Source information collected at parse time. -message SourceInfo { - // The location name. All position information attached to an expression is - // relative to this location. - // - // The location could be a file, UI element, or similar. For example, - // `acme/app/AnvilPolicy.cel`. - string location = 2; - - // Monotonically increasing list of character offsets where newlines appear. - // - // The line number of a given position is the index `i` where for a given - // `id` the `line_offsets[i] < id_positions[id] < line_offsets[i+1]`. The - // column may be derivd from `id_positions[id] - line_offsets[i]`. - repeated int32 line_offsets = 3; - - // A map from the parse node id (e.g. `Expr.id`) to the character offset - // within source. - map positions = 4; -} - -// A specific position in source. -message SourcePosition { - // The soucre location name (e.g. file name). - string location = 1; - - // The character offset. - int32 offset = 2; - - // The 1-based index of the starting line in the source text - // where the issue occurs, or 0 if unknown. - int32 line = 3; - - // The 0-based index of the starting position within the line of source text - // where the issue occurs. Only meaningful if line is nonzer.. - int32 column = 4; -} diff --git a/third_party/google/api/expr/v1beta1/value.proto b/third_party/google/api/expr/v1beta1/value.proto deleted file mode 100644 index 098e92e3..00000000 --- a/third_party/google/api/expr/v1beta1/value.proto +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.api.expr.v1beta1; - -import "google/protobuf/any.proto"; -import "google/protobuf/struct.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr"; -option java_multiple_files = true; -option java_outer_classname = "ValueProto"; -option java_package = "com.google.api.expr.v1beta1"; - -// Represents a CEL value. -// -// This is similar to `google.protobuf.Value`, but can represent CEL's full -// range of values. -message Value { - // Required. The valid kinds of values. - oneof kind { - // Null value. - google.protobuf.NullValue null_value = 1; - - // Boolean value. - bool bool_value = 2; - - // Signed integer value. - int64 int64_value = 3; - - // Unsigned integer value. - uint64 uint64_value = 4; - - // Floating point value. - double double_value = 5; - - // UTF-8 string value. - string string_value = 6; - - // Byte string value. - bytes bytes_value = 7; - - // An enum value. - EnumValue enum_value = 9; - - // The proto message backing an object value. - google.protobuf.Any object_value = 10; - - // Map value. - MapValue map_value = 11; - - // List value. - ListValue list_value = 12; - - // A Type value represented by the fully qualified name of the type. - string type_value = 15; - } -} - -// An enum value. -message EnumValue { - // The fully qualified name of the enum type. - string type = 1; - - // The value of the enum. - int32 value = 2; -} - -// A list. -// -// Wrapped in a message so 'not set' and empty can be differentiated, which is -// required for use in a 'oneof'. -message ListValue { - // The ordered values in the list. - repeated Value values = 1; -} - -// A map. -// -// Wrapped in a message so 'not set' and empty can be differentiated, which is -// required for use in a 'oneof'. -message MapValue { - // An entry in the map. - message Entry { - // The key. - // - // Must be unique with in the map. - // Currently only boolean, int, uint, and string values can be keys. - Value key = 1; - - // The value. - Value value = 2; - } - - // The set of map entries. - // - // CEL has fewer restrictions on keys, so a protobuf map represenation - // cannot be used. - repeated Entry entries = 1; -} diff --git a/third_party/google/api/field_behavior.proto b/third_party/google/api/field_behavior.proto deleted file mode 100644 index 1fdaaed1..00000000 --- a/third_party/google/api/field_behavior.proto +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "FieldBehaviorProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.FieldOptions { - // A designation of a specific field behavior (required, output only, etc.) - // in protobuf messages. - // - // Examples: - // - // string name = 1 [(google.api.field_behavior) = REQUIRED]; - // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; - // google.protobuf.Duration ttl = 1 - // [(google.api.field_behavior) = INPUT_ONLY]; - // google.protobuf.Timestamp expire_time = 1 - // [(google.api.field_behavior) = OUTPUT_ONLY, - // (google.api.field_behavior) = IMMUTABLE]; - repeated google.api.FieldBehavior field_behavior = 1052 [packed = false]; -} - -// An indicator of the behavior of a given field (for example, that a field -// is required in requests, or given as output but ignored as input). -// This **does not** change the behavior in protocol buffers itself; it only -// denotes the behavior and may affect how API tooling handles the field. -// -// Note: This enum **may** receive new values in the future. -enum FieldBehavior { - // Conventional default for enums. Do not use this. - FIELD_BEHAVIOR_UNSPECIFIED = 0; - - // Specifically denotes a field as optional. - // While all fields in protocol buffers are optional, this may be specified - // for emphasis if appropriate. - OPTIONAL = 1; - - // Denotes a field as required. - // This indicates that the field **must** be provided as part of the request, - // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). - REQUIRED = 2; - - // Denotes a field as output only. - // This indicates that the field is provided in responses, but including the - // field in a request does nothing (the server *must* ignore it and - // *must not* throw an error as a result of the field's presence). - OUTPUT_ONLY = 3; - - // Denotes a field as input only. - // This indicates that the field is provided in requests, and the - // corresponding field is not included in output. - INPUT_ONLY = 4; - - // Denotes a field as immutable. - // This indicates that the field may be set once in a request to create a - // resource, but may not be changed thereafter. - IMMUTABLE = 5; - - // Denotes that a (repeated) field is an unordered list. - // This indicates that the service may provide the elements of the list - // in any arbitrary order, rather than the order the user originally - // provided. Additionally, the list's order may or may not be stable. - UNORDERED_LIST = 6; - - // Denotes that this field returns a non-empty default value if not set. - // This indicates that if the user provides the empty value in a request, - // a non-empty value will be returned. The user will not be aware of what - // non-empty value to expect. - NON_EMPTY_DEFAULT = 7; - - // Denotes that the field in a resource (a message annotated with - // google.api.resource) is used in the resource name to uniquely identify the - // resource. For AIP-compliant APIs, this should only be applied to the - // `name` field on the resource. - // - // This behavior should not be applied to references to other resources within - // the message. - // - // The identifier field of resources often have different field behavior - // depending on the request it is embedded in (e.g. for Create methods name - // is optional and unused, while for Update methods it is required). Instead - // of method-specific annotations, only `IDENTIFIER` is required. - IDENTIFIER = 8; -} diff --git a/third_party/google/api/field_info.proto b/third_party/google/api/field_info.proto deleted file mode 100644 index aaa07a18..00000000 --- a/third_party/google/api/field_info.proto +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "FieldInfoProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.FieldOptions { - // Rich semantic descriptor of an API field beyond the basic typing. - // - // Examples: - // - // string request_id = 1 [(google.api.field_info).format = UUID4]; - // string old_ip_address = 2 [(google.api.field_info).format = IPV4]; - // string new_ip_address = 3 [(google.api.field_info).format = IPV6]; - // string actual_ip_address = 4 [ - // (google.api.field_info).format = IPV4_OR_IPV6 - // ]; - // google.protobuf.Any generic_field = 5 [ - // (google.api.field_info).referenced_types = {type_name: "ActualType"}, - // (google.api.field_info).referenced_types = {type_name: "OtherType"}, - // ]; - // google.protobuf.Any generic_user_input = 5 [ - // (google.api.field_info).referenced_types = {type_name: "*"}, - // ]; - google.api.FieldInfo field_info = 291403980; -} - -// Rich semantic information of an API field beyond basic typing. -message FieldInfo { - // The standard format of a field value. The supported formats are all backed - // by either an RFC defined by the IETF or a Google-defined AIP. - enum Format { - // Default, unspecified value. - FORMAT_UNSPECIFIED = 0; - - // Universally Unique Identifier, version 4, value as defined by - // https://datatracker.ietf.org/doc/html/rfc4122. The value may be - // normalized to entirely lowercase letters. For example, the value - // `F47AC10B-58CC-0372-8567-0E02B2C3D479` would be normalized to - // `f47ac10b-58cc-0372-8567-0e02b2c3d479`. - UUID4 = 1; - - // Internet Protocol v4 value as defined by [RFC - // 791](https://datatracker.ietf.org/doc/html/rfc791). The value may be - // condensed, with leading zeros in each octet stripped. For example, - // `001.022.233.040` would be condensed to `1.22.233.40`. - IPV4 = 2; - - // Internet Protocol v6 value as defined by [RFC - // 2460](https://datatracker.ietf.org/doc/html/rfc2460). The value may be - // normalized to entirely lowercase letters with zeros compressed, following - // [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952). For example, - // the value `2001:0DB8:0::0` would be normalized to `2001:db8::`. - IPV6 = 3; - - // An IP address in either v4 or v6 format as described by the individual - // values defined herein. See the comments on the IPV4 and IPV6 types for - // allowed normalizations of each. - IPV4_OR_IPV6 = 4; - } - - // The standard format of a field value. This does not explicitly configure - // any API consumer, just documents the API's format for the field it is - // applied to. - Format format = 1; - - // The type(s) that the annotated, generic field may represent. - // - // Currently, this must only be used on fields of type `google.protobuf.Any`. - // Supporting other generic types may be considered in the future. - repeated TypeReference referenced_types = 2; -} - -// A reference to a message type, for use in [FieldInfo][google.api.FieldInfo]. -message TypeReference { - // The name of the type that the annotated, generic field may represent. - // If the type is in the same protobuf package, the value can be the simple - // message name e.g., `"MyMessage"`. Otherwise, the value must be the - // fully-qualified message name e.g., `"google.library.v1.Book"`. - // - // If the type(s) are unknown to the service (e.g. the field accepts generic - // user input), use the wildcard `"*"` to denote this behavior. - // - // See [AIP-202](https://google.aip.dev/202#type-references) for more details. - string type_name = 1; -} diff --git a/third_party/google/api/http.proto b/third_party/google/api/http.proto deleted file mode 100644 index 57621b53..00000000 --- a/third_party/google/api/http.proto +++ /dev/null @@ -1,370 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "HttpProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -// Defines the HTTP configuration for an API service. It contains a list of -// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method -// to one or more HTTP REST API methods. -message Http { - // A list of HTTP configuration rules that apply to individual API methods. - // - // **NOTE:** All service configuration rules follow "last one wins" order. - repeated HttpRule rules = 1; - - // When set to true, URL path parameters will be fully URI-decoded except in - // cases of single segment matches in reserved expansion, where "%2F" will be - // left encoded. - // - // The default behavior is to not decode RFC 6570 reserved characters in multi - // segment matches. - bool fully_decode_reserved_expansion = 2; -} - -// gRPC Transcoding -// -// gRPC Transcoding is a feature for mapping between a gRPC method and one or -// more HTTP REST endpoints. It allows developers to build a single API service -// that supports both gRPC APIs and REST APIs. Many systems, including [Google -// APIs](https://github.com/googleapis/googleapis), -// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC -// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), -// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature -// and use it for large scale production services. -// -// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies -// how different portions of the gRPC request message are mapped to the URL -// path, URL query parameters, and HTTP request body. It also controls how the -// gRPC response message is mapped to the HTTP response body. `HttpRule` is -// typically specified as an `google.api.http` annotation on the gRPC method. -// -// Each mapping specifies a URL path template and an HTTP method. The path -// template may refer to one or more fields in the gRPC request message, as long -// as each field is a non-repeated field with a primitive (non-message) type. -// The path template controls how fields of the request message are mapped to -// the URL path. -// -// Example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get: "/v1/{name=messages/*}" -// }; -// } -// } -// message GetMessageRequest { -// string name = 1; // Mapped to URL path. -// } -// message Message { -// string text = 1; // The resource content. -// } -// -// This enables an HTTP REST to gRPC mapping as below: -// -// - HTTP: `GET /v1/messages/123456` -// - gRPC: `GetMessage(name: "messages/123456")` -// -// Any fields in the request message which are not bound by the path template -// automatically become HTTP query parameters if there is no HTTP request body. -// For example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get:"/v1/messages/{message_id}" -// }; -// } -// } -// message GetMessageRequest { -// message SubMessage { -// string subfield = 1; -// } -// string message_id = 1; // Mapped to URL path. -// int64 revision = 2; // Mapped to URL query parameter `revision`. -// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. -// } -// -// This enables a HTTP JSON to RPC mapping as below: -// -// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo` -// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub: -// SubMessage(subfield: "foo"))` -// -// Note that fields which are mapped to URL query parameters must have a -// primitive type or a repeated primitive type or a non-repeated message type. -// In the case of a repeated type, the parameter can be repeated in the URL -// as `...?param=A¶m=B`. In the case of a message type, each field of the -// message is mapped to a separate parameter, such as -// `...?foo.a=A&foo.b=B&foo.c=C`. -// -// For HTTP methods that allow a request body, the `body` field -// specifies the mapping. Consider a REST update method on the -// message resource collection: -// -// service Messaging { -// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { -// option (google.api.http) = { -// patch: "/v1/messages/{message_id}" -// body: "message" -// }; -// } -// } -// message UpdateMessageRequest { -// string message_id = 1; // mapped to the URL -// Message message = 2; // mapped to the body -// } -// -// The following HTTP JSON to RPC mapping is enabled, where the -// representation of the JSON in the request body is determined by -// protos JSON encoding: -// -// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` -// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })` -// -// The special name `*` can be used in the body mapping to define that -// every field not bound by the path template should be mapped to the -// request body. This enables the following alternative definition of -// the update method: -// -// service Messaging { -// rpc UpdateMessage(Message) returns (Message) { -// option (google.api.http) = { -// patch: "/v1/messages/{message_id}" -// body: "*" -// }; -// } -// } -// message Message { -// string message_id = 1; -// string text = 2; -// } -// -// -// The following HTTP JSON to RPC mapping is enabled: -// -// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` -// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")` -// -// Note that when using `*` in the body mapping, it is not possible to -// have HTTP parameters, as all fields not bound by the path end in -// the body. This makes this option more rarely used in practice when -// defining REST APIs. The common usage of `*` is in custom methods -// which don't use the URL at all for transferring data. -// -// It is possible to define multiple HTTP methods for one RPC by using -// the `additional_bindings` option. Example: -// -// service Messaging { -// rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http) = { -// get: "/v1/messages/{message_id}" -// additional_bindings { -// get: "/v1/users/{user_id}/messages/{message_id}" -// } -// }; -// } -// } -// message GetMessageRequest { -// string message_id = 1; -// string user_id = 2; -// } -// -// This enables the following two alternative HTTP JSON to RPC mappings: -// -// - HTTP: `GET /v1/messages/123456` -// - gRPC: `GetMessage(message_id: "123456")` -// -// - HTTP: `GET /v1/users/me/messages/123456` -// - gRPC: `GetMessage(user_id: "me" message_id: "123456")` -// -// Rules for HTTP mapping -// -// 1. Leaf request fields (recursive expansion nested messages in the request -// message) are classified into three categories: -// - Fields referred by the path template. They are passed via the URL path. -// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They -// are passed via the HTTP -// request body. -// - All other fields are passed via the URL query parameters, and the -// parameter name is the field path in the request message. A repeated -// field can be represented as multiple query parameters under the same -// name. -// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL -// query parameter, all fields -// are passed via URL path and HTTP request body. -// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP -// request body, all -// fields are passed via URL path and URL query parameters. -// -// Path template syntax -// -// Template = "/" Segments [ Verb ] ; -// Segments = Segment { "/" Segment } ; -// Segment = "*" | "**" | LITERAL | Variable ; -// Variable = "{" FieldPath [ "=" Segments ] "}" ; -// FieldPath = IDENT { "." IDENT } ; -// Verb = ":" LITERAL ; -// -// The syntax `*` matches a single URL path segment. The syntax `**` matches -// zero or more URL path segments, which must be the last part of the URL path -// except the `Verb`. -// -// The syntax `Variable` matches part of the URL path as specified by its -// template. A variable template must not contain other variables. If a variable -// matches a single path segment, its template may be omitted, e.g. `{var}` -// is equivalent to `{var=*}`. -// -// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` -// contains any reserved character, such characters should be percent-encoded -// before the matching. -// -// If a variable contains exactly one path segment, such as `"{var}"` or -// `"{var=*}"`, when such a variable is expanded into a URL path on the client -// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The -// server side does the reverse decoding. Such variables show up in the -// [Discovery -// Document](https://developers.google.com/discovery/v1/reference/apis) as -// `{var}`. -// -// If a variable contains multiple path segments, such as `"{var=foo/*}"` -// or `"{var=**}"`, when such a variable is expanded into a URL path on the -// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. -// The server side does the reverse decoding, except "%2F" and "%2f" are left -// unchanged. Such variables show up in the -// [Discovery -// Document](https://developers.google.com/discovery/v1/reference/apis) as -// `{+var}`. -// -// Using gRPC API Service Configuration -// -// gRPC API Service Configuration (service config) is a configuration language -// for configuring a gRPC service to become a user-facing product. The -// service config is simply the YAML representation of the `google.api.Service` -// proto message. -// -// As an alternative to annotating your proto file, you can configure gRPC -// transcoding in your service config YAML files. You do this by specifying a -// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same -// effect as the proto annotation. This can be particularly useful if you -// have a proto that is reused in multiple services. Note that any transcoding -// specified in the service config will override any matching transcoding -// configuration in the proto. -// -// The following example selects a gRPC method and applies an `HttpRule` to it: -// -// http: -// rules: -// - selector: example.v1.Messaging.GetMessage -// get: /v1/messages/{message_id}/{sub.subfield} -// -// Special notes -// -// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the -// proto to JSON conversion must follow the [proto3 -// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). -// -// While the single segment variable follows the semantics of -// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String -// Expansion, the multi segment variable **does not** follow RFC 6570 Section -// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion -// does not expand special characters like `?` and `#`, which would lead -// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding -// for multi segment variables. -// -// The path variables **must not** refer to any repeated or mapped field, -// because client libraries are not capable of handling such variable expansion. -// -// The path variables **must not** capture the leading "/" character. The reason -// is that the most common use case "{var}" does not capture the leading "/" -// character. For consistency, all path variables must share the same behavior. -// -// Repeated message fields must not be mapped to URL query parameters, because -// no client library can support such complicated mapping. -// -// If an API needs to use a JSON array for request or response body, it can map -// the request or response body to a repeated field. However, some gRPC -// Transcoding implementations may not support this feature. -message HttpRule { - // Selects a method to which this rule applies. - // - // Refer to [selector][google.api.DocumentationRule.selector] for syntax - // details. - string selector = 1; - - // Determines the URL pattern is matched by this rules. This pattern can be - // used with any of the {get|put|post|delete|patch} methods. A custom method - // can be defined using the 'custom' field. - oneof pattern { - // Maps to HTTP GET. Used for listing and getting information about - // resources. - string get = 2; - - // Maps to HTTP PUT. Used for replacing a resource. - string put = 3; - - // Maps to HTTP POST. Used for creating a resource or performing an action. - string post = 4; - - // Maps to HTTP DELETE. Used for deleting a resource. - string delete = 5; - - // Maps to HTTP PATCH. Used for updating a resource. - string patch = 6; - - // The custom pattern is used for specifying an HTTP method that is not - // included in the `pattern` field, such as HEAD, or "*" to leave the - // HTTP method unspecified for this rule. The wild-card rule is useful - // for services that provide content to Web (HTML) clients. - CustomHttpPattern custom = 8; - } - - // The name of the request field whose value is mapped to the HTTP request - // body, or `*` for mapping all request fields not captured by the path - // pattern to the HTTP body, or omitted for not having any HTTP request body. - // - // NOTE: the referred field must be present at the top-level of the request - // message type. - string body = 7; - - // Optional. The name of the response field whose value is mapped to the HTTP - // response body. When omitted, the entire response message will be used - // as the HTTP response body. - // - // NOTE: The referred field must be present at the top-level of the response - // message type. - string response_body = 12; - - // Additional HTTP bindings for the selector. Nested bindings must - // not contain an `additional_bindings` field themselves (that is, - // the nesting may only be one level deep). - repeated HttpRule additional_bindings = 11; -} - -// A custom pattern is used for defining custom HTTP verb. -message CustomHttpPattern { - // The name of this custom HTTP verb. - string kind = 1; - - // The path matched by this custom verb. - string path = 2; -} diff --git a/third_party/google/api/httpbody.proto b/third_party/google/api/httpbody.proto deleted file mode 100644 index e3e17c8a..00000000 --- a/third_party/google/api/httpbody.proto +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/any.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody"; -option java_multiple_files = true; -option java_outer_classname = "HttpBodyProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -// Message that represents an arbitrary HTTP body. It should only be used for -// payload formats that can't be represented as JSON, such as raw binary or -// an HTML page. -// -// -// This message can be used both in streaming and non-streaming API methods in -// the request as well as the response. -// -// It can be used as a top-level request field, which is convenient if one -// wants to extract parameters from either the URL or HTTP template into the -// request fields and also want access to the raw HTTP body. -// -// Example: -// -// message GetResourceRequest { -// // A unique request id. -// string request_id = 1; -// -// // The raw HTTP body is bound to this field. -// google.api.HttpBody http_body = 2; -// -// } -// -// service ResourceService { -// rpc GetResource(GetResourceRequest) -// returns (google.api.HttpBody); -// rpc UpdateResource(google.api.HttpBody) -// returns (google.protobuf.Empty); -// -// } -// -// Example with streaming methods: -// -// service CaldavService { -// rpc GetCalendar(stream google.api.HttpBody) -// returns (stream google.api.HttpBody); -// rpc UpdateCalendar(stream google.api.HttpBody) -// returns (stream google.api.HttpBody); -// -// } -// -// Use of this type only changes how the request and response bodies are -// handled, all other features will continue to work unchanged. -message HttpBody { - // The HTTP Content-Type header value specifying the content type of the body. - string content_type = 1; - - // The HTTP request/response body as raw binary. - bytes data = 2; - - // Application specific response metadata. Must be set in the first response - // for streaming APIs. - repeated google.protobuf.Any extensions = 3; -} diff --git a/third_party/google/api/launch_stage.proto b/third_party/google/api/launch_stage.proto deleted file mode 100644 index 1e86c1ad..00000000 --- a/third_party/google/api/launch_stage.proto +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -option go_package = "google.golang.org/genproto/googleapis/api;api"; -option java_multiple_files = true; -option java_outer_classname = "LaunchStageProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -// The launch stage as defined by [Google Cloud Platform -// Launch Stages](https://cloud.google.com/terms/launch-stages). -enum LaunchStage { - // Do not use this default value. - LAUNCH_STAGE_UNSPECIFIED = 0; - - // The feature is not yet implemented. Users can not use it. - UNIMPLEMENTED = 6; - - // Prelaunch features are hidden from users and are only visible internally. - PRELAUNCH = 7; - - // Early Access features are limited to a closed group of testers. To use - // these features, you must sign up in advance and sign a Trusted Tester - // agreement (which includes confidentiality provisions). These features may - // be unstable, changed in backward-incompatible ways, and are not - // guaranteed to be released. - EARLY_ACCESS = 1; - - // Alpha is a limited availability test for releases before they are cleared - // for widespread use. By Alpha, all significant design issues are resolved - // and we are in the process of verifying functionality. Alpha customers - // need to apply for access, agree to applicable terms, and have their - // projects allowlisted. Alpha releases don't have to be feature complete, - // no SLAs are provided, and there are no technical support obligations, but - // they will be far enough along that customers can actually use them in - // test environments or for limited-use tests -- just like they would in - // normal production cases. - ALPHA = 2; - - // Beta is the point at which we are ready to open a release for any - // customer to use. There are no SLA or technical support obligations in a - // Beta release. Products will be complete from a feature perspective, but - // may have some open outstanding issues. Beta releases are suitable for - // limited production use cases. - BETA = 3; - - // GA features are open to all developers and are considered stable and - // fully qualified for production use. - GA = 4; - - // Deprecated features are scheduled to be shut down and removed. For more - // information, see the "Deprecation Policy" section of our [Terms of - // Service](https://cloud.google.com/terms/) - // and the [Google Cloud Platform Subject to the Deprecation - // Policy](https://cloud.google.com/terms/deprecation) documentation. - DEPRECATED = 5; -} diff --git a/third_party/google/api/resource.proto b/third_party/google/api/resource.proto deleted file mode 100644 index 5669cbc9..00000000 --- a/third_party/google/api/resource.proto +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; -option java_multiple_files = true; -option java_outer_classname = "ResourceProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.FieldOptions { - // An annotation that describes a resource reference, see - // [ResourceReference][]. - google.api.ResourceReference resource_reference = 1055; -} - -extend google.protobuf.FileOptions { - // An annotation that describes a resource definition without a corresponding - // message; see [ResourceDescriptor][]. - repeated google.api.ResourceDescriptor resource_definition = 1053; -} - -extend google.protobuf.MessageOptions { - // An annotation that describes a resource definition, see - // [ResourceDescriptor][]. - google.api.ResourceDescriptor resource = 1053; -} - -// A simple descriptor of a resource type. -// -// ResourceDescriptor annotates a resource message (either by means of a -// protobuf annotation or use in the service config), and associates the -// resource's schema, the resource type, and the pattern of the resource name. -// -// Example: -// -// message Topic { -// // Indicates this message defines a resource schema. -// // Declares the resource type in the format of {service}/{kind}. -// // For Kubernetes resources, the format is {api group}/{kind}. -// option (google.api.resource) = { -// type: "pubsub.googleapis.com/Topic" -// pattern: "projects/{project}/topics/{topic}" -// }; -// } -// -// The ResourceDescriptor Yaml config will look like: -// -// resources: -// - type: "pubsub.googleapis.com/Topic" -// pattern: "projects/{project}/topics/{topic}" -// -// Sometimes, resources have multiple patterns, typically because they can -// live under multiple parents. -// -// Example: -// -// message LogEntry { -// option (google.api.resource) = { -// type: "logging.googleapis.com/LogEntry" -// pattern: "projects/{project}/logs/{log}" -// pattern: "folders/{folder}/logs/{log}" -// pattern: "organizations/{organization}/logs/{log}" -// pattern: "billingAccounts/{billing_account}/logs/{log}" -// }; -// } -// -// The ResourceDescriptor Yaml config will look like: -// -// resources: -// - type: 'logging.googleapis.com/LogEntry' -// pattern: "projects/{project}/logs/{log}" -// pattern: "folders/{folder}/logs/{log}" -// pattern: "organizations/{organization}/logs/{log}" -// pattern: "billingAccounts/{billing_account}/logs/{log}" -message ResourceDescriptor { - // A description of the historical or future-looking state of the - // resource pattern. - enum History { - // The "unset" value. - HISTORY_UNSPECIFIED = 0; - - // The resource originally had one pattern and launched as such, and - // additional patterns were added later. - ORIGINALLY_SINGLE_PATTERN = 1; - - // The resource has one pattern, but the API owner expects to add more - // later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents - // that from being necessary once there are multiple patterns.) - FUTURE_MULTI_PATTERN = 2; - } - - // A flag representing a specific style that a resource claims to conform to. - enum Style { - // The unspecified value. Do not use. - STYLE_UNSPECIFIED = 0; - - // This resource is intended to be "declarative-friendly". - // - // Declarative-friendly resources must be more strictly consistent, and - // setting this to true communicates to tools that this resource should - // adhere to declarative-friendly expectations. - // - // Note: This is used by the API linter (linter.aip.dev) to enable - // additional checks. - DECLARATIVE_FRIENDLY = 1; - } - - // The resource type. It must be in the format of - // {service_name}/{resource_type_kind}. The `resource_type_kind` must be - // singular and must not include version numbers. - // - // Example: `storage.googleapis.com/Bucket` - // - // The value of the resource_type_kind must follow the regular expression - // /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and - // should use PascalCase (UpperCamelCase). The maximum number of - // characters allowed for the `resource_type_kind` is 100. - string type = 1; - - // Optional. The relative resource name pattern associated with this resource - // type. The DNS prefix of the full resource name shouldn't be specified here. - // - // The path pattern must follow the syntax, which aligns with HTTP binding - // syntax: - // - // Template = Segment { "/" Segment } ; - // Segment = LITERAL | Variable ; - // Variable = "{" LITERAL "}" ; - // - // Examples: - // - // - "projects/{project}/topics/{topic}" - // - "projects/{project}/knowledgeBases/{knowledge_base}" - // - // The components in braces correspond to the IDs for each resource in the - // hierarchy. It is expected that, if multiple patterns are provided, - // the same component name (e.g. "project") refers to IDs of the same - // type of resource. - repeated string pattern = 2; - - // Optional. The field on the resource that designates the resource name - // field. If omitted, this is assumed to be "name". - string name_field = 3; - - // Optional. The historical or future-looking state of the resource pattern. - // - // Example: - // - // // The InspectTemplate message originally only supported resource - // // names with organization, and project was added later. - // message InspectTemplate { - // option (google.api.resource) = { - // type: "dlp.googleapis.com/InspectTemplate" - // pattern: - // "organizations/{organization}/inspectTemplates/{inspect_template}" - // pattern: "projects/{project}/inspectTemplates/{inspect_template}" - // history: ORIGINALLY_SINGLE_PATTERN - // }; - // } - History history = 4; - - // The plural name used in the resource name and permission names, such as - // 'projects' for the resource name of 'projects/{project}' and the permission - // name of 'cloudresourcemanager.googleapis.com/projects.get'. One exception - // to this is for Nested Collections that have stuttering names, as defined - // in [AIP-122](https://google.aip.dev/122#nested-collections), where the - // collection ID in the resource name pattern does not necessarily directly - // match the `plural` value. - // - // It is the same concept of the `plural` field in k8s CRD spec - // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ - // - // Note: The plural form is required even for singleton resources. See - // https://aip.dev/156 - string plural = 5; - - // The same concept of the `singular` field in k8s CRD spec - // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ - // Such as "project" for the `resourcemanager.googleapis.com/Project` type. - string singular = 6; - - // Style flag(s) for this resource. - // These indicate that a resource is expected to conform to a given - // style. See the specific style flags for additional information. - repeated Style style = 10; -} - -// Defines a proto annotation that describes a string field that refers to -// an API resource. -message ResourceReference { - // The resource type that the annotated field references. - // - // Example: - // - // message Subscription { - // string topic = 2 [(google.api.resource_reference) = { - // type: "pubsub.googleapis.com/Topic" - // }]; - // } - // - // Occasionally, a field may reference an arbitrary resource. In this case, - // APIs use the special value * in their resource reference. - // - // Example: - // - // message GetIamPolicyRequest { - // string resource = 2 [(google.api.resource_reference) = { - // type: "*" - // }]; - // } - string type = 1; - - // The resource type of a child collection that the annotated field - // references. This is useful for annotating the `parent` field that - // doesn't have a fixed resource type. - // - // Example: - // - // message ListLogEntriesRequest { - // string parent = 1 [(google.api.resource_reference) = { - // child_type: "logging.googleapis.com/LogEntry" - // }; - // } - string child_type = 2; -} diff --git a/third_party/google/api/visibility.proto b/third_party/google/api/visibility.proto deleted file mode 100644 index 0ab5bdc1..00000000 --- a/third_party/google/api/visibility.proto +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.api; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/genproto/googleapis/api/visibility;visibility"; -option java_multiple_files = true; -option java_outer_classname = "VisibilityProto"; -option java_package = "com.google.api"; -option objc_class_prefix = "GAPI"; - -extend google.protobuf.EnumOptions { - // See `VisibilityRule`. - google.api.VisibilityRule enum_visibility = 72295727; -} - -extend google.protobuf.EnumValueOptions { - // See `VisibilityRule`. - google.api.VisibilityRule value_visibility = 72295727; -} - -extend google.protobuf.FieldOptions { - // See `VisibilityRule`. - google.api.VisibilityRule field_visibility = 72295727; -} - -extend google.protobuf.MessageOptions { - // See `VisibilityRule`. - google.api.VisibilityRule message_visibility = 72295727; -} - -extend google.protobuf.MethodOptions { - // See `VisibilityRule`. - google.api.VisibilityRule method_visibility = 72295727; -} - -extend google.protobuf.ServiceOptions { - // See `VisibilityRule`. - google.api.VisibilityRule api_visibility = 72295727; -} - -// `Visibility` restricts service consumer's access to service elements, -// such as whether an application can call a visibility-restricted method. -// The restriction is expressed by applying visibility labels on service -// elements. The visibility labels are elsewhere linked to service consumers. -// -// A service can define multiple visibility labels, but a service consumer -// should be granted at most one visibility label. Multiple visibility -// labels for a single service consumer are not supported. -// -// If an element and all its parents have no visibility label, its visibility -// is unconditionally granted. -// -// Example: -// -// visibility: -// rules: -// - selector: google.calendar.Calendar.EnhancedSearch -// restriction: PREVIEW -// - selector: google.calendar.Calendar.Delegate -// restriction: INTERNAL -// -// Here, all methods are publicly visible except for the restricted methods -// EnhancedSearch and Delegate. -message Visibility { - // A list of visibility rules that apply to individual API elements. - // - // **NOTE:** All service configuration rules follow "last one wins" order. - repeated VisibilityRule rules = 1; -} - -// A visibility rule provides visibility configuration for an individual API -// element. -message VisibilityRule { - // Selects methods, messages, fields, enums, etc. to which this rule applies. - // - // Refer to [selector][google.api.DocumentationRule.selector] for syntax - // details. - string selector = 1; - - // A comma-separated list of visibility labels that apply to the `selector`. - // Any of the listed labels can be used to grant the visibility. - // - // If a rule has multiple labels, removing one of the labels but not all of - // them can break clients. - // - // Example: - // - // visibility: - // rules: - // - selector: google.calendar.Calendar.EnhancedSearch - // restriction: INTERNAL, PREVIEW - // - // Removing INTERNAL from this restriction will break clients that rely on - // this method and only had access to it through INTERNAL. - string restriction = 2; -} diff --git a/third_party/google/bytestream/bytestream.proto b/third_party/google/bytestream/bytestream.proto deleted file mode 100644 index 26bc609e..00000000 --- a/third_party/google/bytestream/bytestream.proto +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.bytestream; - -option go_package = "google.golang.org/genproto/googleapis/bytestream;bytestream"; -option java_outer_classname = "ByteStreamProto"; -option java_package = "com.google.bytestream"; - -// #### Introduction -// -// The Byte Stream API enables a client to read and write a stream of bytes to -// and from a resource. Resources have names, and these names are supplied in -// the API calls below to identify the resource that is being read from or -// written to. -// -// All implementations of the Byte Stream API export the interface defined here: -// -// * `Read()`: Reads the contents of a resource. -// -// * `Write()`: Writes the contents of a resource. The client can call `Write()` -// multiple times with the same resource and can check the status of the write -// by calling `QueryWriteStatus()`. -// -// #### Service parameters and metadata -// -// The ByteStream API provides no direct way to access/modify any metadata -// associated with the resource. -// -// #### Errors -// -// The errors returned by the service are in the Google canonical error space. -service ByteStream { - // `Read()` is used to retrieve the contents of a resource as a sequence - // of bytes. The bytes are returned in a sequence of responses, and the - // responses are delivered as the results of a server-side streaming RPC. - rpc Read(ReadRequest) returns (stream ReadResponse); - - // `Write()` is used to send the contents of a resource as a sequence of - // bytes. The bytes are sent in a sequence of request protos of a client-side - // streaming RPC. - // - // A `Write()` action is resumable. If there is an error or the connection is - // broken during the `Write()`, the client should check the status of the - // `Write()` by calling `QueryWriteStatus()` and continue writing from the - // returned `committed_size`. This may be less than the amount of data the - // client previously sent. - // - // Calling `Write()` on a resource name that was previously written and - // finalized could cause an error, depending on whether the underlying service - // allows over-writing of previously written resources. - // - // When the client closes the request channel, the service will respond with - // a `WriteResponse`. The service will not view the resource as `complete` - // until the client has sent a `WriteRequest` with `finish_write` set to - // `true`. Sending any requests on a stream after sending a request with - // `finish_write` set to `true` will cause an error. The client **should** - // check the `WriteResponse` it receives to determine how much data the - // service was able to commit and whether the service views the resource as - // `complete` or not. - rpc Write(stream WriteRequest) returns (WriteResponse); - - // `QueryWriteStatus()` is used to find the `committed_size` for a resource - // that is being written, which can then be used as the `write_offset` for - // the next `Write()` call. - // - // If the resource does not exist (i.e., the resource has been deleted, or the - // first `Write()` has not yet reached the service), this method returns the - // error `NOT_FOUND`. - // - // The client **may** call `QueryWriteStatus()` at any time to determine how - // much data has been processed for this resource. This is useful if the - // client is buffering data and needs to know which data can be safely - // evicted. For any sequence of `QueryWriteStatus()` calls for a given - // resource name, the sequence of returned `committed_size` values will be - // non-decreasing. - rpc QueryWriteStatus(QueryWriteStatusRequest) - returns (QueryWriteStatusResponse); -} - -// Request object for ByteStream.Read. -message ReadRequest { - // The name of the resource to read. - string resource_name = 1; - - // The offset for the first byte to return in the read, relative to the start - // of the resource. - // - // A `read_offset` that is negative or greater than the size of the resource - // will cause an `OUT_OF_RANGE` error. - int64 read_offset = 2; - - // The maximum number of `data` bytes the server is allowed to return in the - // sum of all `ReadResponse` messages. A `read_limit` of zero indicates that - // there is no limit, and a negative `read_limit` will cause an error. - // - // If the stream returns fewer bytes than allowed by the `read_limit` and no - // error occurred, the stream includes all data from the `read_offset` to the - // end of the resource. - int64 read_limit = 3; -} - -// Response object for ByteStream.Read. -message ReadResponse { - // A portion of the data for the resource. The service **may** leave `data` - // empty for any given `ReadResponse`. This enables the service to inform the - // client that the request is still live while it is running an operation to - // generate more data. - bytes data = 10; -} - -// Request object for ByteStream.Write. -message WriteRequest { - // The name of the resource to write. This **must** be set on the first - // `WriteRequest` of each `Write()` action. If it is set on subsequent calls, - // it **must** match the value of the first request. - string resource_name = 1; - - // The offset from the beginning of the resource at which the data should be - // written. It is required on all `WriteRequest`s. - // - // In the first `WriteRequest` of a `Write()` action, it indicates - // the initial offset for the `Write()` call. The value **must** be equal to - // the `committed_size` that a call to `QueryWriteStatus()` would return. - // - // On subsequent calls, this value **must** be set and **must** be equal to - // the sum of the first `write_offset` and the sizes of all `data` bundles - // sent previously on this stream. - // - // An incorrect value will cause an error. - int64 write_offset = 2; - - // If `true`, this indicates that the write is complete. Sending any - // `WriteRequest`s subsequent to one in which `finish_write` is `true` will - // cause an error. - bool finish_write = 3; - - // A portion of the data for the resource. The client **may** leave `data` - // empty for any given `WriteRequest`. This enables the client to inform the - // service that the request is still live while it is running an operation to - // generate more data. - bytes data = 10; -} - -// Response object for ByteStream.Write. -message WriteResponse { - // The number of bytes that have been processed for the given resource. - int64 committed_size = 1; -} - -// Request object for ByteStream.QueryWriteStatus. -message QueryWriteStatusRequest { - // The name of the resource whose write status is being requested. - string resource_name = 1; -} - -// Response object for ByteStream.QueryWriteStatus. -message QueryWriteStatusResponse { - // The number of bytes that have been processed for the given resource. - int64 committed_size = 1; - - // `complete` is `true` only if the client has sent a `WriteRequest` with - // `finish_write` set to true, and the server has processed that request. - bool complete = 2; -} diff --git a/third_party/google/geo/type/viewport.proto b/third_party/google/geo/type/viewport.proto deleted file mode 100644 index 08c0cce8..00000000 --- a/third_party/google/geo/type/viewport.proto +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -syntax = "proto3"; - -package google.geo.type; - -import "google/type/latlng.proto"; - -option go_package = "google.golang.org/genproto/googleapis/geo/type/viewport;viewport"; -option java_multiple_files = true; -option java_outer_classname = "ViewportProto"; -option java_package = "com.google.geo.type"; -option objc_class_prefix = "GGTP"; - -// A latitude-longitude viewport, represented as two diagonally opposite `low` -// and `high` points. A viewport is considered a closed region, i.e. it includes -// its boundary. The latitude bounds must range between -90 to 90 degrees -// inclusive, and the longitude bounds must range between -180 to 180 degrees -// inclusive. Various cases include: -// -// - If `low` = `high`, the viewport consists of that single point. -// -// - If `low.longitude` > `high.longitude`, the longitude range is inverted -// (the viewport crosses the 180 degree longitude line). -// -// - If `low.longitude` = -180 degrees and `high.longitude` = 180 degrees, -// the viewport includes all longitudes. -// -// - If `low.longitude` = 180 degrees and `high.longitude` = -180 degrees, -// the longitude range is empty. -// -// - If `low.latitude` > `high.latitude`, the latitude range is empty. -// -// Both `low` and `high` must be populated, and the represented box cannot be -// empty (as specified by the definitions above). An empty viewport will result -// in an error. -// -// For example, this viewport fully encloses New York City: -// -// { -// "low": { -// "latitude": 40.477398, -// "longitude": -74.259087 -// }, -// "high": { -// "latitude": 40.91618, -// "longitude": -73.70018 -// } -// } -message Viewport { - // Required. The low point of the viewport. - google.type.LatLng low = 1; - - // Required. The high point of the viewport. - google.type.LatLng high = 2; -} diff --git a/third_party/google/longrunning/operations.proto b/third_party/google/longrunning/operations.proto deleted file mode 100644 index e0206a90..00000000 --- a/third_party/google/longrunning/operations.proto +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.longrunning; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/protobuf/any.proto"; -import "google/protobuf/descriptor.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/empty.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "Google.LongRunning"; -option go_package = "cloud.google.com/go/longrunning/autogen/longrunningpb;longrunningpb"; -option java_multiple_files = true; -option java_outer_classname = "OperationsProto"; -option java_package = "com.google.longrunning"; -option objc_class_prefix = "GLRUN"; -option php_namespace = "Google\\LongRunning"; - -extend google.protobuf.MethodOptions { - // Additional information regarding long-running operations. - // In particular, this specifies the types that are returned from - // long-running operations. - // - // Required for methods that return `google.longrunning.Operation`; invalid - // otherwise. - google.longrunning.OperationInfo operation_info = 1049; -} - -// Manages long-running operations with an API service. -// -// When an API method normally takes long time to complete, it can be designed -// to return [Operation][google.longrunning.Operation] to the client, and the -// client can use this interface to receive the real response asynchronously by -// polling the operation resource, or pass the operation resource to another API -// (such as Pub/Sub API) to receive the response. Any API service that returns -// long-running operations should implement the `Operations` interface so -// developers can have a consistent client experience. -service Operations { - option (google.api.default_host) = "longrunning.googleapis.com"; - - // Lists operations that match the specified filter in the request. If the - // server doesn't support this method, it returns `UNIMPLEMENTED`. - rpc ListOperations(ListOperationsRequest) returns (ListOperationsResponse) { - option (google.api.http) = { - get: "/v1/{name=operations}" - }; - option (google.api.method_signature) = "name,filter"; - } - - // Gets the latest state of a long-running operation. Clients can use this - // method to poll the operation result at intervals as recommended by the API - // service. - rpc GetOperation(GetOperationRequest) returns (Operation) { - option (google.api.http) = { - get: "/v1/{name=operations/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Deletes a long-running operation. This method indicates that the client is - // no longer interested in the operation result. It does not cancel the - // operation. If the server doesn't support this method, it returns - // `google.rpc.Code.UNIMPLEMENTED`. - rpc DeleteOperation(DeleteOperationRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=operations/**}" - }; - option (google.api.method_signature) = "name"; - } - - // Starts asynchronous cancellation on a long-running operation. The server - // makes a best effort to cancel the operation, but success is not - // guaranteed. If the server doesn't support this method, it returns - // `google.rpc.Code.UNIMPLEMENTED`. Clients can use - // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or - // other methods to check whether the cancellation succeeded or whether the - // operation completed despite cancellation. On successful cancellation, - // the operation is not deleted; instead, it becomes an operation with - // an [Operation.error][google.longrunning.Operation.error] value with a - // [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to - // `Code.CANCELLED`. - rpc CancelOperation(CancelOperationRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v1/{name=operations/**}:cancel" - body: "*" - }; - option (google.api.method_signature) = "name"; - } - - // Waits until the specified long-running operation is done or reaches at most - // a specified timeout, returning the latest state. If the operation is - // already done, the latest state is immediately returned. If the timeout - // specified is greater than the default HTTP/RPC timeout, the HTTP/RPC - // timeout is used. If the server does not support this method, it returns - // `google.rpc.Code.UNIMPLEMENTED`. - // Note that this method is on a best-effort basis. It may return the latest - // state before the specified timeout (including immediately), meaning even an - // immediate response is no guarantee that the operation is done. - rpc WaitOperation(WaitOperationRequest) returns (Operation) {} -} - -// This resource represents a long-running operation that is the result of a -// network API call. -message Operation { - // The server-assigned name, which is only unique within the same service that - // originally returns it. If you use the default HTTP mapping, the - // `name` should be a resource name ending with `operations/{unique_id}`. - string name = 1; - - // Service-specific metadata associated with the operation. It typically - // contains progress information and common metadata such as create time. - // Some services might not provide such metadata. Any method that returns a - // long-running operation should document the metadata type, if any. - google.protobuf.Any metadata = 2; - - // If the value is `false`, it means the operation is still in progress. - // If `true`, the operation is completed, and either `error` or `response` is - // available. - bool done = 3; - - // The operation result, which can be either an `error` or a valid `response`. - // If `done` == `false`, neither `error` nor `response` is set. - // If `done` == `true`, exactly one of `error` or `response` can be set. - // Some services might not provide the result. - oneof result { - // The error result of the operation in case of failure or cancellation. - google.rpc.Status error = 4; - - // The normal, successful response of the operation. If the original - // method returns no data on success, such as `Delete`, the response is - // `google.protobuf.Empty`. If the original method is standard - // `Get`/`Create`/`Update`, the response should be the resource. For other - // methods, the response should have the type `XxxResponse`, where `Xxx` - // is the original method name. For example, if the original method name - // is `TakeSnapshot()`, the inferred response type is - // `TakeSnapshotResponse`. - google.protobuf.Any response = 5; - } -} - -// The request message for -// [Operations.GetOperation][google.longrunning.Operations.GetOperation]. -message GetOperationRequest { - // The name of the operation resource. - string name = 1; -} - -// The request message for -// [Operations.ListOperations][google.longrunning.Operations.ListOperations]. -message ListOperationsRequest { - // The name of the operation's parent resource. - string name = 4; - - // The standard list filter. - string filter = 1; - - // The standard list page size. - int32 page_size = 2; - - // The standard list page token. - string page_token = 3; -} - -// The response message for -// [Operations.ListOperations][google.longrunning.Operations.ListOperations]. -message ListOperationsResponse { - // A list of operations that matches the specified filter in the request. - repeated Operation operations = 1; - - // The standard List next-page token. - string next_page_token = 2; -} - -// The request message for -// [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]. -message CancelOperationRequest { - // The name of the operation resource to be cancelled. - string name = 1; -} - -// The request message for -// [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation]. -message DeleteOperationRequest { - // The name of the operation resource to be deleted. - string name = 1; -} - -// The request message for -// [Operations.WaitOperation][google.longrunning.Operations.WaitOperation]. -message WaitOperationRequest { - // The name of the operation resource to wait on. - string name = 1; - - // The maximum duration to wait before timing out. If left blank, the wait - // will be at most the time permitted by the underlying HTTP/RPC protocol. - // If RPC context deadline is also specified, the shorter one will be used. - google.protobuf.Duration timeout = 2; -} - -// A message representing the message types used by a long-running operation. -// -// Example: -// -// rpc Export(ExportRequest) returns (google.longrunning.Operation) { -// option (google.longrunning.operation_info) = { -// response_type: "ExportResponse" -// metadata_type: "ExportMetadata" -// }; -// } -message OperationInfo { - // Required. The message name of the primary return type for this - // long-running operation. - // This type will be used to deserialize the LRO's response. - // - // If the response is in a different package from the rpc, a fully-qualified - // message name must be used (e.g. `google.protobuf.Struct`). - // - // Note: Altering this value constitutes a breaking change. - string response_type = 1; - - // Required. The message name of the metadata type for this long-running - // operation. - // - // If the response is in a different package from the rpc, a fully-qualified - // message name must be used (e.g. `google.protobuf.Struct`). - // - // Note: Altering this value constitutes a breaking change. - string metadata_type = 2; -} diff --git a/third_party/google/protobuf/any.proto b/third_party/google/protobuf/any.proto deleted file mode 100644 index eff44e50..00000000 --- a/third_party/google/protobuf/any.proto +++ /dev/null @@ -1,162 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option go_package = "google.golang.org/protobuf/types/known/anypb"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "AnyProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; - -// `Any` contains an arbitrary serialized protocol buffer message along with a -// URL that describes the type of the serialized message. -// -// Protobuf library provides support to pack/unpack Any values in the form -// of utility functions or additional generated methods of the Any type. -// -// Example 1: Pack and unpack a message in C++. -// -// Foo foo = ...; -// Any any; -// any.PackFrom(foo); -// ... -// if (any.UnpackTo(&foo)) { -// ... -// } -// -// Example 2: Pack and unpack a message in Java. -// -// Foo foo = ...; -// Any any = Any.pack(foo); -// ... -// if (any.is(Foo.class)) { -// foo = any.unpack(Foo.class); -// } -// // or ... -// if (any.isSameTypeAs(Foo.getDefaultInstance())) { -// foo = any.unpack(Foo.getDefaultInstance()); -// } -// -// Example 3: Pack and unpack a message in Python. -// -// foo = Foo(...) -// any = Any() -// any.Pack(foo) -// ... -// if any.Is(Foo.DESCRIPTOR): -// any.Unpack(foo) -// ... -// -// Example 4: Pack and unpack a message in Go -// -// foo := &pb.Foo{...} -// any, err := anypb.New(foo) -// if err != nil { -// ... -// } -// ... -// foo := &pb.Foo{} -// if err := any.UnmarshalTo(foo); err != nil { -// ... -// } -// -// The pack methods provided by protobuf library will by default use -// 'type.googleapis.com/full.type.name' as the type URL and the unpack -// methods only use the fully qualified type name after the last '/' -// in the type URL, for example "foo.bar.com/x/y.z" will yield type -// name "y.z". -// -// JSON -// ==== -// The JSON representation of an `Any` value uses the regular -// representation of the deserialized, embedded message, with an -// additional field `@type` which contains the type URL. Example: -// -// package google.profile; -// message Person { -// string first_name = 1; -// string last_name = 2; -// } -// -// { -// "@type": "type.googleapis.com/google.profile.Person", -// "firstName": , -// "lastName": -// } -// -// If the embedded message type is well-known and has a custom JSON -// representation, that representation will be embedded adding a field -// `value` which holds the custom JSON in addition to the `@type` -// field. Example (for message [google.protobuf.Duration][]): -// -// { -// "@type": "type.googleapis.com/google.protobuf.Duration", -// "value": "1.212s" -// } -// -message Any { - // A URL/resource name that uniquely identifies the type of the serialized - // protocol buffer message. This string must contain at least - // one "/" character. The last segment of the URL's path must represent - // the fully qualified name of the type (as in - // `path/google.protobuf.Duration`). The name should be in a canonical form - // (e.g., leading "." is not accepted). - // - // In practice, teams usually precompile into the binary all types that they - // expect it to use in the context of Any. However, for URLs which use the - // scheme `http`, `https`, or no scheme, one can optionally set up a type - // server that maps type URLs to message definitions as follows: - // - // * If no scheme is provided, `https` is assumed. - // * An HTTP GET on the URL must yield a [google.protobuf.Type][] - // value in binary format, or produce an error. - // * Applications are allowed to cache lookup results based on the - // URL, or have them precompiled into a binary to avoid any - // lookup. Therefore, binary compatibility needs to be preserved - // on changes to types. (Use versioned type names to manage - // breaking changes.) - // - // Note: this functionality is not currently available in the official - // protobuf release, and it is not used for type URLs beginning with - // type.googleapis.com. As of May 2023, there are no widely used type server - // implementations and no plans to implement one. - // - // Schemes other than `http`, `https` (or the empty scheme) might be - // used with implementation specific semantics. - // - string type_url = 1; - - // Must be a valid serialized protocol buffer of the above specified type. - bytes value = 2; -} diff --git a/third_party/google/protobuf/api.proto b/third_party/google/protobuf/api.proto deleted file mode 100644 index afc9cc15..00000000 --- a/third_party/google/protobuf/api.proto +++ /dev/null @@ -1,207 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -import "google/protobuf/source_context.proto"; -import "google/protobuf/type.proto"; - -option java_package = "com.google.protobuf"; -option java_outer_classname = "ApiProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "google.golang.org/protobuf/types/known/apipb"; - -// Api is a light-weight descriptor for an API Interface. -// -// Interfaces are also described as "protocol buffer services" in some contexts, -// such as by the "service" keyword in a .proto file, but they are different -// from API Services, which represent a concrete implementation of an interface -// as opposed to simply a description of methods and bindings. They are also -// sometimes simply referred to as "APIs" in other contexts, such as the name of -// this message itself. See https://cloud.google.com/apis/design/glossary for -// detailed terminology. -message Api { - // The fully qualified name of this interface, including package name - // followed by the interface's simple name. - string name = 1; - - // The methods of this interface, in unspecified order. - repeated Method methods = 2; - - // Any metadata attached to the interface. - repeated Option options = 3; - - // A version string for this interface. If specified, must have the form - // `major-version.minor-version`, as in `1.10`. If the minor version is - // omitted, it defaults to zero. If the entire version field is empty, the - // major version is derived from the package name, as outlined below. If the - // field is not empty, the version in the package name will be verified to be - // consistent with what is provided here. - // - // The versioning schema uses [semantic - // versioning](http://semver.org) where the major version number - // indicates a breaking change and the minor version an additive, - // non-breaking change. Both version numbers are signals to users - // what to expect from different versions, and should be carefully - // chosen based on the product plan. - // - // The major version is also reflected in the package name of the - // interface, which must end in `v`, as in - // `google.feature.v1`. For major versions 0 and 1, the suffix can - // be omitted. Zero major versions must only be used for - // experimental, non-GA interfaces. - // - string version = 4; - - // Source context for the protocol buffer service represented by this - // message. - SourceContext source_context = 5; - - // Included interfaces. See [Mixin][]. - repeated Mixin mixins = 6; - - // The source syntax of the service. - Syntax syntax = 7; -} - -// Method represents a method of an API interface. -message Method { - // The simple name of this method. - string name = 1; - - // A URL of the input message type. - string request_type_url = 2; - - // If true, the request is streamed. - bool request_streaming = 3; - - // The URL of the output message type. - string response_type_url = 4; - - // If true, the response is streamed. - bool response_streaming = 5; - - // Any metadata attached to the method. - repeated Option options = 6; - - // The source syntax of this method. - Syntax syntax = 7; -} - -// Declares an API Interface to be included in this interface. The including -// interface must redeclare all the methods from the included interface, but -// documentation and options are inherited as follows: -// -// - If after comment and whitespace stripping, the documentation -// string of the redeclared method is empty, it will be inherited -// from the original method. -// -// - Each annotation belonging to the service config (http, -// visibility) which is not set in the redeclared method will be -// inherited. -// -// - If an http annotation is inherited, the path pattern will be -// modified as follows. Any version prefix will be replaced by the -// version of the including interface plus the [root][] path if -// specified. -// -// Example of a simple mixin: -// -// package google.acl.v1; -// service AccessControl { -// // Get the underlying ACL object. -// rpc GetAcl(GetAclRequest) returns (Acl) { -// option (google.api.http).get = "/v1/{resource=**}:getAcl"; -// } -// } -// -// package google.storage.v2; -// service Storage { -// rpc GetAcl(GetAclRequest) returns (Acl); -// -// // Get a data record. -// rpc GetData(GetDataRequest) returns (Data) { -// option (google.api.http).get = "/v2/{resource=**}"; -// } -// } -// -// Example of a mixin configuration: -// -// apis: -// - name: google.storage.v2.Storage -// mixins: -// - name: google.acl.v1.AccessControl -// -// The mixin construct implies that all methods in `AccessControl` are -// also declared with same name and request/response types in -// `Storage`. A documentation generator or annotation processor will -// see the effective `Storage.GetAcl` method after inheriting -// documentation and annotations as follows: -// -// service Storage { -// // Get the underlying ACL object. -// rpc GetAcl(GetAclRequest) returns (Acl) { -// option (google.api.http).get = "/v2/{resource=**}:getAcl"; -// } -// ... -// } -// -// Note how the version in the path pattern changed from `v1` to `v2`. -// -// If the `root` field in the mixin is specified, it should be a -// relative path under which inherited HTTP paths are placed. Example: -// -// apis: -// - name: google.storage.v2.Storage -// mixins: -// - name: google.acl.v1.AccessControl -// root: acls -// -// This implies the following inherited HTTP annotation: -// -// service Storage { -// // Get the underlying ACL object. -// rpc GetAcl(GetAclRequest) returns (Acl) { -// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; -// } -// ... -// } -message Mixin { - // The fully qualified name of the interface which is included. - string name = 1; - - // If non-empty specifies a path under which inherited HTTP paths - // are rooted. - string root = 2; -} diff --git a/third_party/google/protobuf/compiler/plugin.proto b/third_party/google/protobuf/compiler/plugin.proto deleted file mode 100644 index 033fab23..00000000 --- a/third_party/google/protobuf/compiler/plugin.proto +++ /dev/null @@ -1,180 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -// Author: kenton@google.com (Kenton Varda) -// -// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is -// just a program that reads a CodeGeneratorRequest from stdin and writes a -// CodeGeneratorResponse to stdout. -// -// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead -// of dealing with the raw protocol defined here. -// -// A plugin executable needs only to be placed somewhere in the path. The -// plugin should be named "protoc-gen-$NAME", and will then be used when the -// flag "--${NAME}_out" is passed to protoc. - -syntax = "proto2"; - -package google.protobuf.compiler; -option java_package = "com.google.protobuf.compiler"; -option java_outer_classname = "PluginProtos"; - -option csharp_namespace = "Google.Protobuf.Compiler"; -option go_package = "google.golang.org/protobuf/types/pluginpb"; - -import "google/protobuf/descriptor.proto"; - -// The version number of protocol compiler. -message Version { - optional int32 major = 1; - optional int32 minor = 2; - optional int32 patch = 3; - // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should - // be empty for mainline stable releases. - optional string suffix = 4; -} - -// An encoded CodeGeneratorRequest is written to the plugin's stdin. -message CodeGeneratorRequest { - // The .proto files that were explicitly listed on the command-line. The - // code generator should generate code only for these files. Each file's - // descriptor will be included in proto_file, below. - repeated string file_to_generate = 1; - - // The generator parameter passed on the command-line. - optional string parameter = 2; - - // FileDescriptorProtos for all files in files_to_generate and everything - // they import. The files will appear in topological order, so each file - // appears before any file that imports it. - // - // Note: the files listed in files_to_generate will include runtime-retention - // options only, but all other files will include source-retention options. - // The source_file_descriptors field below is available in case you need - // source-retention options for files_to_generate. - // - // protoc guarantees that all proto_files will be written after - // the fields above, even though this is not technically guaranteed by the - // protobuf wire format. This theoretically could allow a plugin to stream - // in the FileDescriptorProtos and handle them one by one rather than read - // the entire set into memory at once. However, as of this writing, this - // is not similarly optimized on protoc's end -- it will store all fields in - // memory at once before sending them to the plugin. - // - // Type names of fields and extensions in the FileDescriptorProto are always - // fully qualified. - repeated FileDescriptorProto proto_file = 15; - - // File descriptors with all options, including source-retention options. - // These descriptors are only provided for the files listed in - // files_to_generate. - repeated FileDescriptorProto source_file_descriptors = 17; - - // The version number of protocol compiler. - optional Version compiler_version = 3; -} - -// The plugin writes an encoded CodeGeneratorResponse to stdout. -message CodeGeneratorResponse { - // Error message. If non-empty, code generation failed. The plugin process - // should exit with status code zero even if it reports an error in this way. - // - // This should be used to indicate errors in .proto files which prevent the - // code generator from generating correct code. Errors which indicate a - // problem in protoc itself -- such as the input CodeGeneratorRequest being - // unparseable -- should be reported by writing a message to stderr and - // exiting with a non-zero status code. - optional string error = 1; - - // A bitmask of supported features that the code generator supports. - // This is a bitwise "or" of values from the Feature enum. - optional uint64 supported_features = 2; - - // Sync with code_generator.h. - enum Feature { - FEATURE_NONE = 0; - FEATURE_PROTO3_OPTIONAL = 1; - FEATURE_SUPPORTS_EDITIONS = 2; - } - - // The minimum edition this plugin supports. This will be treated as an - // Edition enum, but we want to allow unknown values. It should be specified - // according the edition enum value, *not* the edition number. Only takes - // effect for plugins that have FEATURE_SUPPORTS_EDITIONS set. - optional int32 minimum_edition = 3; - - // The maximum edition this plugin supports. This will be treated as an - // Edition enum, but we want to allow unknown values. It should be specified - // according the edition enum value, *not* the edition number. Only takes - // effect for plugins that have FEATURE_SUPPORTS_EDITIONS set. - optional int32 maximum_edition = 4; - - // Represents a single generated file. - message File { - // The file name, relative to the output directory. The name must not - // contain "." or ".." components and must be relative, not be absolute (so, - // the file cannot lie outside the output directory). "/" must be used as - // the path separator, not "\". - // - // If the name is omitted, the content will be appended to the previous - // file. This allows the generator to break large files into small chunks, - // and allows the generated text to be streamed back to protoc so that large - // files need not reside completely in memory at one time. Note that as of - // this writing protoc does not optimize for this -- it will read the entire - // CodeGeneratorResponse before writing files to disk. - optional string name = 1; - - // If non-empty, indicates that the named file should already exist, and the - // content here is to be inserted into that file at a defined insertion - // point. This feature allows a code generator to extend the output - // produced by another code generator. The original generator may provide - // insertion points by placing special annotations in the file that look - // like: - // @@protoc_insertion_point(NAME) - // The annotation can have arbitrary text before and after it on the line, - // which allows it to be placed in a comment. NAME should be replaced with - // an identifier naming the point -- this is what other generators will use - // as the insertion_point. Code inserted at this point will be placed - // immediately above the line containing the insertion point (thus multiple - // insertions to the same point will come out in the order they were added). - // The double-@ is intended to make it unlikely that the generated code - // could contain things that look like insertion points by accident. - // - // For example, the C++ code generator places the following line in the - // .pb.h files that it generates: - // // @@protoc_insertion_point(namespace_scope) - // This line appears within the scope of the file's package namespace, but - // outside of any particular class. Another plugin can then specify the - // insertion_point "namespace_scope" to generate additional classes or - // other declarations that should be placed in this scope. - // - // Note that if the line containing the insertion point begins with - // whitespace, the same whitespace will be added to every line of the - // inserted text. This is useful for languages like Python, where - // indentation matters. In these languages, the insertion point comment - // should be indented the same amount as any inserted code will need to be - // in order to work correctly in that context. - // - // The code generator that generates the initial file and the one which - // inserts into it must both run as part of a single invocation of protoc. - // Code generators are executed in the order in which they appear on the - // command line. - // - // If |insertion_point| is present, |name| must also be present. - optional string insertion_point = 2; - - // The file contents. - optional string content = 15; - - // Information describing the file content being inserted. If an insertion - // point is used, this information will be appropriately offset and inserted - // into the code generation metadata for the generated files. - optional GeneratedCodeInfo generated_code_info = 16; - } - repeated File file = 15; -} diff --git a/third_party/google/protobuf/cpp_features.proto b/third_party/google/protobuf/cpp_features.proto deleted file mode 100644 index a0d19299..00000000 --- a/third_party/google/protobuf/cpp_features.proto +++ /dev/null @@ -1,67 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2023 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -syntax = "proto2"; - -package pb; - -import "google/protobuf/descriptor.proto"; - -extend google.protobuf.FeatureSet { - optional CppFeatures cpp = 1000; -} - -message CppFeatures { - // Whether or not to treat an enum field as closed. This option is only - // applicable to enum fields, and will be removed in the future. It is - // consistent with the legacy behavior of using proto3 enum types for proto2 - // fields. - optional bool legacy_closed_enum = 1 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_FIELD, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - edition_deprecated: EDITION_2023, - deprecation_warning: "The legacy closed enum behavior in C++ is " - "deprecated and is scheduled to be removed in " - "edition 2025. See http://protobuf.dev/programming-guides/enum/#cpp for " - "more information", - }, - edition_defaults = { edition: EDITION_LEGACY, value: "true" }, - edition_defaults = { edition: EDITION_PROTO3, value: "false" } - ]; - - enum StringType { - STRING_TYPE_UNKNOWN = 0; - VIEW = 1; - CORD = 2; - STRING = 3; - } - - optional StringType string_type = 2 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_FIELD, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "STRING" }, - edition_defaults = { edition: EDITION_2024, value: "VIEW" } - ]; - - optional bool enum_name_uses_string_view = 3 [ - retention = RETENTION_SOURCE, - targets = TARGET_TYPE_ENUM, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2024, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "false" }, - edition_defaults = { edition: EDITION_2024, value: "true" } - ]; -} diff --git a/third_party/google/protobuf/descriptor.proto b/third_party/google/protobuf/descriptor.proto deleted file mode 100644 index 0be20ea7..00000000 --- a/third_party/google/protobuf/descriptor.proto +++ /dev/null @@ -1,1417 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// Author: kenton@google.com (Kenton Varda) -// Based on original Protocol Buffers design by -// Sanjay Ghemawat, Jeff Dean, and others. -// -// The messages in this file describe the definitions found in .proto files. -// A valid .proto file can be translated directly to a FileDescriptorProto -// without any other information (e.g. without reading its imports). - -syntax = "proto2"; - -package google.protobuf; - -option go_package = "google.golang.org/protobuf/types/descriptorpb"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "DescriptorProtos"; -option csharp_namespace = "Google.Protobuf.Reflection"; -option objc_class_prefix = "GPB"; -option cc_enable_arenas = true; - -// descriptor.proto must be optimized for speed because reflection-based -// algorithms don't work during bootstrapping. -option optimize_for = SPEED; - -// The protocol compiler can output a FileDescriptorSet containing the .proto -// files it parses. -message FileDescriptorSet { - repeated FileDescriptorProto file = 1; - - // Extensions for tooling. - extensions 536000000 [declaration = { - number: 536000000 - type: ".buf.descriptor.v1.FileDescriptorSetExtension" - full_name: ".buf.descriptor.v1.buf_file_descriptor_set_extension" - }]; -} - -// The full set of known editions. -enum Edition { - // A placeholder for an unknown edition value. - EDITION_UNKNOWN = 0; - - // A placeholder edition for specifying default behaviors *before* a feature - // was first introduced. This is effectively an "infinite past". - EDITION_LEGACY = 900; - - // Legacy syntax "editions". These pre-date editions, but behave much like - // distinct editions. These can't be used to specify the edition of proto - // files, but feature definitions must supply proto2/proto3 defaults for - // backwards compatibility. - EDITION_PROTO2 = 998; - EDITION_PROTO3 = 999; - - // Editions that have been released. The specific values are arbitrary and - // should not be depended on, but they will always be time-ordered for easy - // comparison. - EDITION_2023 = 1000; - EDITION_2024 = 1001; - - // Placeholder editions for testing feature resolution. These should not be - // used or relied on outside of tests. - EDITION_1_TEST_ONLY = 1; - EDITION_2_TEST_ONLY = 2; - EDITION_99997_TEST_ONLY = 99997; - EDITION_99998_TEST_ONLY = 99998; - EDITION_99999_TEST_ONLY = 99999; - - // Placeholder for specifying unbounded edition support. This should only - // ever be used by plugins that can expect to never require any changes to - // support a new edition. - EDITION_MAX = 0x7FFFFFFF; -} - -// Describes a complete .proto file. -message FileDescriptorProto { - optional string name = 1; // file name, relative to root of source tree - optional string package = 2; // e.g. "foo", "foo.bar", etc. - - // Names of files imported by this file. - repeated string dependency = 3; - // Indexes of the public imported files in the dependency list above. - repeated int32 public_dependency = 10; - // Indexes of the weak imported files in the dependency list. - // For Google-internal migration only. Do not use. - repeated int32 weak_dependency = 11; - - // Names of files imported by this file purely for the purpose of providing - // option extensions. These are excluded from the dependency list above. - repeated string option_dependency = 15; - - // All top-level definitions in this file. - repeated DescriptorProto message_type = 4; - repeated EnumDescriptorProto enum_type = 5; - repeated ServiceDescriptorProto service = 6; - repeated FieldDescriptorProto extension = 7; - - optional FileOptions options = 8; - - // This field contains optional information about the original source code. - // You may safely remove this entire field without harming runtime - // functionality of the descriptors -- the information is needed only by - // development tools. - optional SourceCodeInfo source_code_info = 9; - - // The syntax of the proto file. - // The supported values are "proto2", "proto3", and "editions". - // - // If `edition` is present, this value must be "editions". - // WARNING: This field should only be used by protobuf plugins or special - // cases like the proto compiler. Other uses are discouraged and - // developers should rely on the protoreflect APIs for their client language. - optional string syntax = 12; - - // The edition of the proto file. - // WARNING: This field should only be used by protobuf plugins or special - // cases like the proto compiler. Other uses are discouraged and - // developers should rely on the protoreflect APIs for their client language. - optional Edition edition = 14; -} - -// Describes a message type. -message DescriptorProto { - optional string name = 1; - - repeated FieldDescriptorProto field = 2; - repeated FieldDescriptorProto extension = 6; - - repeated DescriptorProto nested_type = 3; - repeated EnumDescriptorProto enum_type = 4; - - message ExtensionRange { - optional int32 start = 1; // Inclusive. - optional int32 end = 2; // Exclusive. - - optional ExtensionRangeOptions options = 3; - } - repeated ExtensionRange extension_range = 5; - - repeated OneofDescriptorProto oneof_decl = 8; - - optional MessageOptions options = 7; - - // Range of reserved tag numbers. Reserved tag numbers may not be used by - // fields or extension ranges in the same message. Reserved ranges may - // not overlap. - message ReservedRange { - optional int32 start = 1; // Inclusive. - optional int32 end = 2; // Exclusive. - } - repeated ReservedRange reserved_range = 9; - // Reserved field names, which may not be used by fields in the same message. - // A given name may only be reserved once. - repeated string reserved_name = 10; - - // Support for `export` and `local` keywords on enums. - optional SymbolVisibility visibility = 11; -} - -message ExtensionRangeOptions { - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - message Declaration { - // The extension number declared within the extension range. - optional int32 number = 1; - - // The fully-qualified name of the extension field. There must be a leading - // dot in front of the full name. - optional string full_name = 2; - - // The fully-qualified type name of the extension field. Unlike - // Metadata.type, Declaration.type must have a leading dot for messages - // and enums. - optional string type = 3; - - // If true, indicates that the number is reserved in the extension range, - // and any extension field with the number will fail to compile. Set this - // when a declared extension field is deleted. - optional bool reserved = 5; - - // If true, indicates that the extension must be defined as repeated. - // Otherwise the extension must be defined as optional. - optional bool repeated = 6; - - reserved 4; // removed is_repeated - } - - // For external users: DO NOT USE. We are in the process of open sourcing - // extension declaration and executing internal cleanups before it can be - // used externally. - repeated Declaration declaration = 2 [retention = RETENTION_SOURCE]; - - // Any features defined in the specific edition. - optional FeatureSet features = 50; - - // The verification state of the extension range. - enum VerificationState { - // All the extensions of the range must be declared. - DECLARATION = 0; - UNVERIFIED = 1; - } - - // The verification state of the range. - // TODO: flip the default to DECLARATION once all empty ranges - // are marked as UNVERIFIED. - optional VerificationState verification = 3 - [default = UNVERIFIED, retention = RETENTION_SOURCE]; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -// Describes a field within a message. -message FieldDescriptorProto { - enum Type { - // 0 is reserved for errors. - // Order is weird for historical reasons. - TYPE_DOUBLE = 1; - TYPE_FLOAT = 2; - // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if - // negative values are likely. - TYPE_INT64 = 3; - TYPE_UINT64 = 4; - // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if - // negative values are likely. - TYPE_INT32 = 5; - TYPE_FIXED64 = 6; - TYPE_FIXED32 = 7; - TYPE_BOOL = 8; - TYPE_STRING = 9; - // Tag-delimited aggregate. - // Group type is deprecated and not supported after google.protobuf. However, Proto3 - // implementations should still be able to parse the group wire format and - // treat group fields as unknown fields. In Editions, the group wire format - // can be enabled via the `message_encoding` feature. - TYPE_GROUP = 10; - TYPE_MESSAGE = 11; // Length-delimited aggregate. - - // New in version 2. - TYPE_BYTES = 12; - TYPE_UINT32 = 13; - TYPE_ENUM = 14; - TYPE_SFIXED32 = 15; - TYPE_SFIXED64 = 16; - TYPE_SINT32 = 17; // Uses ZigZag encoding. - TYPE_SINT64 = 18; // Uses ZigZag encoding. - } - - enum Label { - // 0 is reserved for errors - LABEL_OPTIONAL = 1; - LABEL_REPEATED = 3; - // The required label is only allowed in google.protobuf. In proto3 and Editions - // it's explicitly prohibited. In Editions, the `field_presence` feature - // can be used to get this behavior. - LABEL_REQUIRED = 2; - } - - optional string name = 1; - optional int32 number = 3; - optional Label label = 4; - - // If type_name is set, this need not be set. If both this and type_name - // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. - optional Type type = 5; - - // For message and enum types, this is the name of the type. If the name - // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping - // rules are used to find the type (i.e. first the nested types within this - // message are searched, then within the parent, on up to the root - // namespace). - optional string type_name = 6; - - // For extensions, this is the name of the type being extended. It is - // resolved in the same manner as type_name. - optional string extendee = 2; - - // For numeric types, contains the original text representation of the value. - // For booleans, "true" or "false". - // For strings, contains the default text contents (not escaped in any way). - // For bytes, contains the C escaped value. All bytes >= 128 are escaped. - optional string default_value = 7; - - // If set, gives the index of a oneof in the containing type's oneof_decl - // list. This field is a member of that oneof. - optional int32 oneof_index = 9; - - // JSON name of this field. The value is set by protocol compiler. If the - // user has set a "json_name" option on this field, that option's value - // will be used. Otherwise, it's deduced from the field's name by converting - // it to camelCase. - optional string json_name = 10; - - optional FieldOptions options = 8; - - // If true, this is a proto3 "optional". When a proto3 field is optional, it - // tracks presence regardless of field type. - // - // When proto3_optional is true, this field must belong to a oneof to signal - // to old proto3 clients that presence is tracked for this field. This oneof - // is known as a "synthetic" oneof, and this field must be its sole member - // (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs - // exist in the descriptor only, and do not generate any API. Synthetic oneofs - // must be ordered after all "real" oneofs. - // - // For message fields, proto3_optional doesn't create any semantic change, - // since non-repeated message fields always track presence. However it still - // indicates the semantic detail of whether the user wrote "optional" or not. - // This can be useful for round-tripping the .proto file. For consistency we - // give message fields a synthetic oneof also, even though it is not required - // to track presence. This is especially important because the parser can't - // tell if a field is a message or an enum, so it must always create a - // synthetic oneof. - // - // Proto2 optional fields do not set this flag, because they already indicate - // optional with `LABEL_OPTIONAL`. - optional bool proto3_optional = 17; -} - -// Describes a oneof. -message OneofDescriptorProto { - optional string name = 1; - optional OneofOptions options = 2; -} - -// Describes an enum type. -message EnumDescriptorProto { - optional string name = 1; - - repeated EnumValueDescriptorProto value = 2; - - optional EnumOptions options = 3; - - // Range of reserved numeric values. Reserved values may not be used by - // entries in the same enum. Reserved ranges may not overlap. - // - // Note that this is distinct from DescriptorProto.ReservedRange in that it - // is inclusive such that it can appropriately represent the entire int32 - // domain. - message EnumReservedRange { - optional int32 start = 1; // Inclusive. - optional int32 end = 2; // Inclusive. - } - - // Range of reserved numeric values. Reserved numeric values may not be used - // by enum values in the same enum declaration. Reserved ranges may not - // overlap. - repeated EnumReservedRange reserved_range = 4; - - // Reserved enum value names, which may not be reused. A given name may only - // be reserved once. - repeated string reserved_name = 5; - - // Support for `export` and `local` keywords on enums. - optional SymbolVisibility visibility = 6; -} - -// Describes a value within an enum. -message EnumValueDescriptorProto { - optional string name = 1; - optional int32 number = 2; - - optional EnumValueOptions options = 3; -} - -// Describes a service. -message ServiceDescriptorProto { - optional string name = 1; - repeated MethodDescriptorProto method = 2; - - optional ServiceOptions options = 3; -} - -// Describes a method of a service. -message MethodDescriptorProto { - optional string name = 1; - - // Input and output type names. These are resolved in the same way as - // FieldDescriptorProto.type_name, but must refer to a message type. - optional string input_type = 2; - optional string output_type = 3; - - optional MethodOptions options = 4; - - // Identifies if client streams multiple client messages - optional bool client_streaming = 5 [default = false]; - // Identifies if server streams multiple server messages - optional bool server_streaming = 6 [default = false]; -} - -// =================================================================== -// Options - -// Each of the definitions above may have "options" attached. These are -// just annotations which may cause code to be generated slightly differently -// or may contain hints for code that manipulates protocol messages. -// -// Clients may define custom options as extensions of the *Options messages. -// These extensions may not yet be known at parsing time, so the parser cannot -// store the values in them. Instead it stores them in a field in the *Options -// message called uninterpreted_option. This field must have the same name -// across all *Options messages. We then use this field to populate the -// extensions when we build a descriptor, at which point all protos have been -// parsed and so all extensions are known. -// -// Extension numbers for custom options may be chosen as follows: -// * For options which will only be used within a single application or -// organization, or for experimental options, use field numbers 50000 -// through 99999. It is up to you to ensure that you do not use the -// same number for multiple options. -// * For options which will be published and used publicly by multiple -// independent entities, e-mail protobuf-global-extension-registry@google.com -// to reserve extension numbers. Simply provide your project name (e.g. -// Objective-C plugin) and your project website (if available) -- there's no -// need to explain how you intend to use them. Usually you only need one -// extension number. You can declare multiple options with only one extension -// number by putting them in a sub-message. See the Custom Options section of -// the docs for examples: -// https://developers.google.com/protocol-buffers/docs/proto#options -// If this turns out to be popular, a web service will be set up -// to automatically assign option numbers. - -message FileOptions { - - // Sets the Java package where classes generated from this .proto will be - // placed. By default, the proto package is used, but this is often - // inappropriate because proto packages do not normally start with backwards - // domain names. - optional string java_package = 1; - - // Controls the name of the wrapper Java class generated for the .proto file. - // That class will always contain the .proto file's getDescriptor() method as - // well as any top-level extensions defined in the .proto file. - // If java_multiple_files is disabled, then all the other classes from the - // .proto file will be nested inside the single wrapper outer class. - optional string java_outer_classname = 8; - - // If enabled, then the Java code generator will generate a separate .java - // file for each top-level message, enum, and service defined in the .proto - // file. Thus, these types will *not* be nested inside the wrapper class - // named by java_outer_classname. However, the wrapper class will still be - // generated to contain the file's getDescriptor() method as well as any - // top-level extensions defined in the file. - optional bool java_multiple_files = 10 [default = false]; - - // This option does nothing. - optional bool java_generate_equals_and_hash = 20 [deprecated=true]; - - // A proto2 file can set this to true to opt in to UTF-8 checking for Java, - // which will throw an exception if invalid UTF-8 is parsed from the wire or - // assigned to a string field. - // - // TODO: clarify exactly what kinds of field types this option - // applies to, and update these docs accordingly. - // - // Proto3 files already perform these checks. Setting the option explicitly to - // false has no effect: it cannot be used to opt proto3 files out of UTF-8 - // checks. - optional bool java_string_check_utf8 = 27 [default = false]; - - // Generated classes can be optimized for speed or code size. - enum OptimizeMode { - SPEED = 1; // Generate complete code for parsing, serialization, - // etc. - CODE_SIZE = 2; // Use ReflectionOps to implement these methods. - LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. - } - optional OptimizeMode optimize_for = 9 [default = SPEED]; - - // Sets the Go package where structs generated from this .proto will be - // placed. If omitted, the Go package will be derived from the following: - // - The basename of the package import path, if provided. - // - Otherwise, the package statement in the .proto file, if present. - // - Otherwise, the basename of the .proto file, without extension. - optional string go_package = 11; - - // Should generic services be generated in each language? "Generic" services - // are not specific to any particular RPC system. They are generated by the - // main code generators in each language (without additional plugins). - // Generic services were the only kind of service generation supported by - // early versions of google.protobuf. - // - // Generic services are now considered deprecated in favor of using plugins - // that generate code specific to your particular RPC system. Therefore, - // these default to false. Old code which depends on generic services should - // explicitly set them to true. - optional bool cc_generic_services = 16 [default = false]; - optional bool java_generic_services = 17 [default = false]; - optional bool py_generic_services = 18 [default = false]; - reserved 42; // removed php_generic_services - reserved "php_generic_services"; - - // Is this file deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for everything in the file, or it will be completely ignored; in the very - // least, this is a formalization for deprecating files. - optional bool deprecated = 23 [default = false]; - - // Enables the use of arenas for the proto messages in this file. This applies - // only to generated classes for C++. - optional bool cc_enable_arenas = 31 [default = true]; - - // Sets the objective c class prefix which is prepended to all objective c - // generated classes from this .proto. There is no default. - optional string objc_class_prefix = 36; - - // Namespace for generated classes; defaults to the package. - optional string csharp_namespace = 37; - - // By default Swift generators will take the proto package and CamelCase it - // replacing '.' with underscore and use that to prefix the types/symbols - // defined. When this options is provided, they will use this value instead - // to prefix the types/symbols defined. - optional string swift_prefix = 39; - - // Sets the php class prefix which is prepended to all php generated classes - // from this .proto. Default is empty. - optional string php_class_prefix = 40; - - // Use this option to change the namespace of php generated classes. Default - // is empty. When this option is empty, the package name will be used for - // determining the namespace. - optional string php_namespace = 41; - - // Use this option to change the namespace of php generated metadata classes. - // Default is empty. When this option is empty, the proto file name will be - // used for determining the namespace. - optional string php_metadata_namespace = 44; - - // Use this option to change the package of ruby generated classes. Default - // is empty. When this option is not set, the package name will be used for - // determining the ruby package. - optional string ruby_package = 45; - - // Any features defined in the specific edition. - // WARNING: This field should only be used by protobuf plugins or special - // cases like the proto compiler. Other uses are discouraged and - // developers should rely on the protoreflect APIs for their client language. - optional FeatureSet features = 50; - - // The parser stores options it doesn't recognize here. - // See the documentation for the "Options" section above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. - // See the documentation for the "Options" section above. - extensions 1000 to max; - - reserved 38; -} - -message MessageOptions { - // Set true to use the old proto1 MessageSet wire format for extensions. - // This is provided for backwards-compatibility with the MessageSet wire - // format. You should not use this for any other reason: It's less - // efficient, has fewer features, and is more complicated. - // - // The message must be defined exactly as follows: - // message Foo { - // option message_set_wire_format = true; - // extensions 4 to max; - // } - // Note that the message cannot have any defined fields; MessageSets only - // have extensions. - // - // All extensions of your type must be singular messages; e.g. they cannot - // be int32s, enums, or repeated messages. - // - // Because this is an option, the above two restrictions are not enforced by - // the protocol compiler. - optional bool message_set_wire_format = 1 [default = false]; - - // Disables the generation of the standard "descriptor()" accessor, which can - // conflict with a field of the same name. This is meant to make migration - // from proto1 easier; new code should avoid fields named "descriptor". - optional bool no_standard_descriptor_accessor = 2 [default = false]; - - // Is this message deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for the message, or it will be completely ignored; in the very least, - // this is a formalization for deprecating messages. - optional bool deprecated = 3 [default = false]; - - reserved 4, 5, 6; - - // Whether the message is an automatically generated map entry type for the - // maps field. - // - // For maps fields: - // map map_field = 1; - // The parsed descriptor looks like: - // message MapFieldEntry { - // option map_entry = true; - // optional KeyType key = 1; - // optional ValueType value = 2; - // } - // repeated MapFieldEntry map_field = 1; - // - // Implementations may choose not to generate the map_entry=true message, but - // use a native map in the target language to hold the keys and values. - // The reflection APIs in such implementations still need to work as - // if the field is a repeated message field. - // - // NOTE: Do not set the option in .proto files. Always use the maps syntax - // instead. The option should only be implicitly set by the proto compiler - // parser. - optional bool map_entry = 7; - - reserved 8; // javalite_serializable - reserved 9; // javanano_as_lite - - // Enable the legacy handling of JSON field name conflicts. This lowercases - // and strips underscored from the fields before comparison in proto3 only. - // The new behavior takes `json_name` into account and applies to proto2 as - // well. - // - // This should only be used as a temporary measure against broken builds due - // to the change in behavior for JSON field name conflicts. - // - // TODO This is legacy behavior we plan to remove once downstream - // teams have had time to migrate. - optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true]; - - // Any features defined in the specific edition. - // WARNING: This field should only be used by protobuf plugins or special - // cases like the proto compiler. Other uses are discouraged and - // developers should rely on the protoreflect APIs for their client language. - optional FeatureSet features = 12; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message FieldOptions { - // NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead. - // The ctype option instructs the C++ code generator to use a different - // representation of the field than it normally would. See the specific - // options below. This option is only implemented to support use of - // [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of - // type "bytes" in the open source release. - // TODO: make ctype actually deprecated. - optional CType ctype = 1 [/*deprecated = true,*/ default = STRING]; - enum CType { - // Default mode. - STRING = 0; - - // The option [ctype=CORD] may be applied to a non-repeated field of type - // "bytes". It indicates that in C++, the data should be stored in a Cord - // instead of a string. For very large strings, this may reduce memory - // fragmentation. It may also allow better performance when parsing from a - // Cord, or when parsing with aliasing enabled, as the parsed Cord may then - // alias the original buffer. - CORD = 1; - - STRING_PIECE = 2; - } - // The packed option can be enabled for repeated primitive fields to enable - // a more efficient representation on the wire. Rather than repeatedly - // writing the tag and type for each element, the entire array is encoded as - // a single length-delimited blob. In proto3, only explicit setting it to - // false will avoid using packed encoding. This option is prohibited in - // Editions, but the `repeated_field_encoding` feature can be used to control - // the behavior. - optional bool packed = 2; - - // The jstype option determines the JavaScript type used for values of the - // field. The option is permitted only for 64 bit integral and fixed types - // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING - // is represented as JavaScript string, which avoids loss of precision that - // can happen when a large value is converted to a floating point JavaScript. - // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to - // use the JavaScript "number" type. The behavior of the default option - // JS_NORMAL is implementation dependent. - // - // This option is an enum to permit additional types to be added, e.g. - // goog.math.Integer. - optional JSType jstype = 6 [default = JS_NORMAL]; - enum JSType { - // Use the default type. - JS_NORMAL = 0; - - // Use JavaScript strings. - JS_STRING = 1; - - // Use JavaScript numbers. - JS_NUMBER = 2; - } - - // Should this field be parsed lazily? Lazy applies only to message-type - // fields. It means that when the outer message is initially parsed, the - // inner message's contents will not be parsed but instead stored in encoded - // form. The inner message will actually be parsed when it is first accessed. - // - // This is only a hint. Implementations are free to choose whether to use - // eager or lazy parsing regardless of the value of this option. However, - // setting this option true suggests that the protocol author believes that - // using lazy parsing on this field is worth the additional bookkeeping - // overhead typically needed to implement it. - // - // This option does not affect the public interface of any generated code; - // all method signatures remain the same. Furthermore, thread-safety of the - // interface is not affected by this option; const methods remain safe to - // call from multiple threads concurrently, while non-const methods continue - // to require exclusive access. - // - // Note that lazy message fields are still eagerly verified to check - // ill-formed wireformat or missing required fields. Calling IsInitialized() - // on the outer message would fail if the inner message has missing required - // fields. Failed verification would result in parsing failure (except when - // uninitialized messages are acceptable). - optional bool lazy = 5 [default = false]; - - // unverified_lazy does no correctness checks on the byte stream. This should - // only be used where lazy with verification is prohibitive for performance - // reasons. - optional bool unverified_lazy = 15 [default = false]; - - // Is this field deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for accessors, or it will be completely ignored; in the very least, this - // is a formalization for deprecating fields. - optional bool deprecated = 3 [default = false]; - - // For Google-internal migration only. Do not use. - optional bool weak = 10 [default = false]; - - // Indicate that the field value should not be printed out when using debug - // formats, e.g. when the field contains sensitive credentials. - optional bool debug_redact = 16 [default = false]; - - // If set to RETENTION_SOURCE, the option will be omitted from the binary. - enum OptionRetention { - RETENTION_UNKNOWN = 0; - RETENTION_RUNTIME = 1; - RETENTION_SOURCE = 2; - } - - optional OptionRetention retention = 17; - - // This indicates the types of entities that the field may apply to when used - // as an option. If it is unset, then the field may be freely used as an - // option on any kind of entity. - enum OptionTargetType { - TARGET_TYPE_UNKNOWN = 0; - TARGET_TYPE_FILE = 1; - TARGET_TYPE_EXTENSION_RANGE = 2; - TARGET_TYPE_MESSAGE = 3; - TARGET_TYPE_FIELD = 4; - TARGET_TYPE_ONEOF = 5; - TARGET_TYPE_ENUM = 6; - TARGET_TYPE_ENUM_ENTRY = 7; - TARGET_TYPE_SERVICE = 8; - TARGET_TYPE_METHOD = 9; - } - - repeated OptionTargetType targets = 19; - - message EditionDefault { - optional Edition edition = 3; - optional string value = 2; // Textproto value. - } - repeated EditionDefault edition_defaults = 20; - - // Any features defined in the specific edition. - // WARNING: This field should only be used by protobuf plugins or special - // cases like the proto compiler. Other uses are discouraged and - // developers should rely on the protoreflect APIs for their client language. - optional FeatureSet features = 21; - - // Information about the support window of a feature. - message FeatureSupport { - // The edition that this feature was first available in. In editions - // earlier than this one, the default assigned to EDITION_LEGACY will be - // used, and proto files will not be able to override it. - optional Edition edition_introduced = 1; - - // The edition this feature becomes deprecated in. Using this after this - // edition may trigger warnings. - optional Edition edition_deprecated = 2; - - // The deprecation warning text if this feature is used after the edition it - // was marked deprecated in. - optional string deprecation_warning = 3; - - // The edition this feature is no longer available in. In editions after - // this one, the last default assigned will be used, and proto files will - // not be able to override it. - optional Edition edition_removed = 4; - } - optional FeatureSupport feature_support = 22; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; - - reserved 4; // removed jtype - reserved 18; // reserve target, target_obsolete_do_not_use -} - -message OneofOptions { - // Any features defined in the specific edition. - // WARNING: This field should only be used by protobuf plugins or special - // cases like the proto compiler. Other uses are discouraged and - // developers should rely on the protoreflect APIs for their client language. - optional FeatureSet features = 1; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message EnumOptions { - - // Set this option to true to allow mapping different tag names to the same - // value. - optional bool allow_alias = 2; - - // Is this enum deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for the enum, or it will be completely ignored; in the very least, this - // is a formalization for deprecating enums. - optional bool deprecated = 3 [default = false]; - - reserved 5; // javanano_as_lite - - // Enable the legacy handling of JSON field name conflicts. This lowercases - // and strips underscored from the fields before comparison in proto3 only. - // The new behavior takes `json_name` into account and applies to proto2 as - // well. - // TODO Remove this legacy behavior once downstream teams have - // had time to migrate. - optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true]; - - // Any features defined in the specific edition. - // WARNING: This field should only be used by protobuf plugins or special - // cases like the proto compiler. Other uses are discouraged and - // developers should rely on the protoreflect APIs for their client language. - optional FeatureSet features = 7; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message EnumValueOptions { - // Is this enum value deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for the enum value, or it will be completely ignored; in the very least, - // this is a formalization for deprecating enum values. - optional bool deprecated = 1 [default = false]; - - // Any features defined in the specific edition. - // WARNING: This field should only be used by protobuf plugins or special - // cases like the proto compiler. Other uses are discouraged and - // developers should rely on the protoreflect APIs for their client language. - optional FeatureSet features = 2; - - // Indicate that fields annotated with this enum value should not be printed - // out when using debug formats, e.g. when the field contains sensitive - // credentials. - optional bool debug_redact = 3 [default = false]; - - // Information about the support window of a feature value. - optional FieldOptions.FeatureSupport feature_support = 4; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message ServiceOptions { - - // Any features defined in the specific edition. - // WARNING: This field should only be used by protobuf plugins or special - // cases like the proto compiler. Other uses are discouraged and - // developers should rely on the protoreflect APIs for their client language. - optional FeatureSet features = 34; - - // Note: Field numbers 1 through 32 are reserved for Google's internal RPC - // framework. We apologize for hoarding these numbers to ourselves, but - // we were already using them long before we decided to release Protocol - // Buffers. - - // Is this service deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for the service, or it will be completely ignored; in the very least, - // this is a formalization for deprecating services. - optional bool deprecated = 33 [default = false]; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -message MethodOptions { - - // Note: Field numbers 1 through 32 are reserved for Google's internal RPC - // framework. We apologize for hoarding these numbers to ourselves, but - // we were already using them long before we decided to release Protocol - // Buffers. - - // Is this method deprecated? - // Depending on the target platform, this can emit Deprecated annotations - // for the method, or it will be completely ignored; in the very least, - // this is a formalization for deprecating methods. - optional bool deprecated = 33 [default = false]; - - // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, - // or neither? HTTP based RPC implementation may choose GET verb for safe - // methods, and PUT verb for idempotent methods instead of the default POST. - enum IdempotencyLevel { - IDEMPOTENCY_UNKNOWN = 0; - NO_SIDE_EFFECTS = 1; // implies idempotent - IDEMPOTENT = 2; // idempotent, but may have side effects - } - optional IdempotencyLevel idempotency_level = 34 - [default = IDEMPOTENCY_UNKNOWN]; - - // Any features defined in the specific edition. - // WARNING: This field should only be used by protobuf plugins or special - // cases like the proto compiler. Other uses are discouraged and - // developers should rely on the protoreflect APIs for their client language. - optional FeatureSet features = 35; - - // The parser stores options it doesn't recognize here. See above. - repeated UninterpretedOption uninterpreted_option = 999; - - // Clients can define custom options in extensions of this message. See above. - extensions 1000 to max; -} - -// A message representing a option the parser does not recognize. This only -// appears in options protos created by the compiler::Parser class. -// DescriptorPool resolves these when building Descriptor objects. Therefore, -// options protos in descriptor objects (e.g. returned by Descriptor::options(), -// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions -// in them. -message UninterpretedOption { - // The name of the uninterpreted option. Each string represents a segment in - // a dot-separated name. is_extension is true iff a segment represents an - // extension (denoted with parentheses in options specs in .proto files). - // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents - // "foo.(bar.baz).moo". - message NamePart { - required string name_part = 1; - required bool is_extension = 2; - } - repeated NamePart name = 2; - - // The value of the uninterpreted option, in whatever type the tokenizer - // identified it as during parsing. Exactly one of these should be set. - optional string identifier_value = 3; - optional uint64 positive_int_value = 4; - optional int64 negative_int_value = 5; - optional double double_value = 6; - optional bytes string_value = 7; - optional string aggregate_value = 8; -} - -// =================================================================== -// Features - -// TODO Enums in C++ gencode (and potentially other languages) are -// not well scoped. This means that each of the feature enums below can clash -// with each other. The short names we've chosen maximize call-site -// readability, but leave us very open to this scenario. A future feature will -// be designed and implemented to handle this, hopefully before we ever hit a -// conflict here. -message FeatureSet { - enum FieldPresence { - FIELD_PRESENCE_UNKNOWN = 0; - EXPLICIT = 1; - IMPLICIT = 2; - LEGACY_REQUIRED = 3; - } - optional FieldPresence field_presence = 1 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_FIELD, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "EXPLICIT" }, - edition_defaults = { edition: EDITION_PROTO3, value: "IMPLICIT" }, - edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" } - ]; - - enum EnumType { - ENUM_TYPE_UNKNOWN = 0; - OPEN = 1; - CLOSED = 2; - } - optional EnumType enum_type = 2 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_ENUM, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "CLOSED" }, - edition_defaults = { edition: EDITION_PROTO3, value: "OPEN" } - ]; - - enum RepeatedFieldEncoding { - REPEATED_FIELD_ENCODING_UNKNOWN = 0; - PACKED = 1; - EXPANDED = 2; - } - optional RepeatedFieldEncoding repeated_field_encoding = 3 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_FIELD, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "EXPANDED" }, - edition_defaults = { edition: EDITION_PROTO3, value: "PACKED" } - ]; - - enum Utf8Validation { - UTF8_VALIDATION_UNKNOWN = 0; - VERIFY = 2; - NONE = 3; - reserved 1; - } - optional Utf8Validation utf8_validation = 4 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_FIELD, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "NONE" }, - edition_defaults = { edition: EDITION_PROTO3, value: "VERIFY" } - ]; - - enum MessageEncoding { - MESSAGE_ENCODING_UNKNOWN = 0; - LENGTH_PREFIXED = 1; - DELIMITED = 2; - } - optional MessageEncoding message_encoding = 5 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_FIELD, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "LENGTH_PREFIXED" } - ]; - - enum JsonFormat { - JSON_FORMAT_UNKNOWN = 0; - ALLOW = 1; - LEGACY_BEST_EFFORT = 2; - } - optional JsonFormat json_format = 6 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_MESSAGE, - targets = TARGET_TYPE_ENUM, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY_BEST_EFFORT" }, - edition_defaults = { edition: EDITION_PROTO3, value: "ALLOW" } - ]; - - enum EnforceNamingStyle { - ENFORCE_NAMING_STYLE_UNKNOWN = 0; - STYLE2024 = 1; - STYLE_LEGACY = 2; - } - optional EnforceNamingStyle enforce_naming_style = 7 [ - retention = RETENTION_SOURCE, - targets = TARGET_TYPE_FILE, - targets = TARGET_TYPE_EXTENSION_RANGE, - targets = TARGET_TYPE_MESSAGE, - targets = TARGET_TYPE_FIELD, - targets = TARGET_TYPE_ONEOF, - targets = TARGET_TYPE_ENUM, - targets = TARGET_TYPE_ENUM_ENTRY, - targets = TARGET_TYPE_SERVICE, - targets = TARGET_TYPE_METHOD, - feature_support = { - edition_introduced: EDITION_2024, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "STYLE_LEGACY" }, - edition_defaults = { edition: EDITION_2024, value: "STYLE2024" } - ]; - - message VisibilityFeature { - enum DefaultSymbolVisibility { - DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0; - - // Default pre-EDITION_2024, all UNSET visibility are export. - EXPORT_ALL = 1; - - // All top-level symbols default to export, nested default to local. - EXPORT_TOP_LEVEL = 2; - - // All symbols default to local. - LOCAL_ALL = 3; - - // All symbols local by default. Nested types cannot be exported. - // With special case caveat for message { enum {} reserved 1 to max; } - // This is the recommended setting for new protos. - STRICT = 4; - } - reserved 1 to max; - } - optional VisibilityFeature.DefaultSymbolVisibility default_symbol_visibility = - 8 [ - retention = RETENTION_SOURCE, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2024, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "EXPORT_ALL" }, - edition_defaults = { edition: EDITION_2024, value: "EXPORT_TOP_LEVEL" } - ]; - - reserved 999; - - extensions 1000 to 9994 [ - declaration = { - number: 1000, - full_name: ".pb.cpp", - type: ".pb.CppFeatures" - }, - declaration = { - number: 1001, - full_name: ".pb.java", - type: ".pb.JavaFeatures" - }, - declaration = { number: 1002, full_name: ".pb.go", type: ".pb.GoFeatures" }, - declaration = { - number: 1003, - full_name: ".pb.python", - type: ".pb.PythonFeatures" - }, - declaration = { - number: 9990, - full_name: ".pb.proto1", - type: ".pb.Proto1Features" - } - ]; - - extensions 9995 to 9999; // For internal testing - extensions 10000; // for https://github.com/bufbuild/protobuf-es -} - -// A compiled specification for the defaults of a set of features. These -// messages are generated from FeatureSet extensions and can be used to seed -// feature resolution. The resolution with this object becomes a simple search -// for the closest matching edition, followed by proto merges. -message FeatureSetDefaults { - // A map from every known edition with a unique set of defaults to its - // defaults. Not all editions may be contained here. For a given edition, - // the defaults at the closest matching edition ordered at or before it should - // be used. This field must be in strict ascending order by edition. - message FeatureSetEditionDefault { - optional Edition edition = 3; - - // Defaults of features that can be overridden in this edition. - optional FeatureSet overridable_features = 4; - - // Defaults of features that can't be overridden in this edition. - optional FeatureSet fixed_features = 5; - - reserved 1, 2; - reserved "features"; - } - repeated FeatureSetEditionDefault defaults = 1; - - // The minimum supported edition (inclusive) when this was constructed. - // Editions before this will not have defaults. - optional Edition minimum_edition = 4; - - // The maximum known edition (inclusive) when this was constructed. Editions - // after this will not have reliable defaults. - optional Edition maximum_edition = 5; -} - -// =================================================================== -// Optional source code info - -// Encapsulates information about the original source file from which a -// FileDescriptorProto was generated. -message SourceCodeInfo { - // A Location identifies a piece of source code in a .proto file which - // corresponds to a particular definition. This information is intended - // to be useful to IDEs, code indexers, documentation generators, and similar - // tools. - // - // For example, say we have a file like: - // message Foo { - // optional string foo = 1; - // } - // Let's look at just the field definition: - // optional string foo = 1; - // ^ ^^ ^^ ^ ^^^ - // a bc de f ghi - // We have the following locations: - // span path represents - // [a,i) [ 4, 0, 2, 0 ] The whole field definition. - // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). - // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). - // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). - // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). - // - // Notes: - // - A location may refer to a repeated field itself (i.e. not to any - // particular index within it). This is used whenever a set of elements are - // logically enclosed in a single code segment. For example, an entire - // extend block (possibly containing multiple extension definitions) will - // have an outer location whose path refers to the "extensions" repeated - // field without an index. - // - Multiple locations may have the same path. This happens when a single - // logical declaration is spread out across multiple places. The most - // obvious example is the "extend" block again -- there may be multiple - // extend blocks in the same scope, each of which will have the same path. - // - A location's span is not always a subset of its parent's span. For - // example, the "extendee" of an extension declaration appears at the - // beginning of the "extend" block and is shared by all extensions within - // the block. - // - Just because a location's span is a subset of some other location's span - // does not mean that it is a descendant. For example, a "group" defines - // both a type and a field in a single declaration. Thus, the locations - // corresponding to the type and field and their components will overlap. - // - Code which tries to interpret locations should probably be designed to - // ignore those that it doesn't understand, as more types of locations could - // be recorded in the future. - repeated Location location = 1; - message Location { - // Identifies which part of the FileDescriptorProto was defined at this - // location. - // - // Each element is a field number or an index. They form a path from - // the root FileDescriptorProto to the place where the definition appears. - // For example, this path: - // [ 4, 3, 2, 7, 1 ] - // refers to: - // file.message_type(3) // 4, 3 - // .field(7) // 2, 7 - // .name() // 1 - // This is because FileDescriptorProto.message_type has field number 4: - // repeated DescriptorProto message_type = 4; - // and DescriptorProto.field has field number 2: - // repeated FieldDescriptorProto field = 2; - // and FieldDescriptorProto.name has field number 1: - // optional string name = 1; - // - // Thus, the above path gives the location of a field name. If we removed - // the last element: - // [ 4, 3, 2, 7 ] - // this path refers to the whole field declaration (from the beginning - // of the label to the terminating semicolon). - repeated int32 path = 1 [packed = true]; - - // Always has exactly three or four elements: start line, start column, - // end line (optional, otherwise assumed same as start line), end column. - // These are packed into a single field for efficiency. Note that line - // and column numbers are zero-based -- typically you will want to add - // 1 to each before displaying to a user. - repeated int32 span = 2 [packed = true]; - - // If this SourceCodeInfo represents a complete declaration, these are any - // comments appearing before and after the declaration which appear to be - // attached to the declaration. - // - // A series of line comments appearing on consecutive lines, with no other - // tokens appearing on those lines, will be treated as a single comment. - // - // leading_detached_comments will keep paragraphs of comments that appear - // before (but not connected to) the current element. Each paragraph, - // separated by empty lines, will be one comment element in the repeated - // field. - // - // Only the comment content is provided; comment markers (e.g. //) are - // stripped out. For block comments, leading whitespace and an asterisk - // will be stripped from the beginning of each line other than the first. - // Newlines are included in the output. - // - // Examples: - // - // optional int32 foo = 1; // Comment attached to foo. - // // Comment attached to bar. - // optional int32 bar = 2; - // - // optional string baz = 3; - // // Comment attached to baz. - // // Another line attached to baz. - // - // // Comment attached to moo. - // // - // // Another line attached to moo. - // optional double moo = 4; - // - // // Detached comment for corge. This is not leading or trailing comments - // // to moo or corge because there are blank lines separating it from - // // both. - // - // // Detached comment for corge paragraph 2. - // - // optional string corge = 5; - // /* Block comment attached - // * to corge. Leading asterisks - // * will be removed. */ - // /* Block comment attached to - // * grault. */ - // optional int32 grault = 6; - // - // // ignored detached comments. - optional string leading_comments = 3; - optional string trailing_comments = 4; - repeated string leading_detached_comments = 6; - } - - // Extensions for tooling. - extensions 536000000 [declaration = { - number: 536000000 - type: ".buf.descriptor.v1.SourceCodeInfoExtension" - full_name: ".buf.descriptor.v1.buf_source_code_info_extension" - }]; -} - -// Describes the relationship between generated code and its original source -// file. A GeneratedCodeInfo message is associated with only one generated -// source file, but may contain references to different source .proto files. -message GeneratedCodeInfo { - // An Annotation connects some span of text in generated code to an element - // of its generating .proto file. - repeated Annotation annotation = 1; - message Annotation { - // Identifies the element in the original source .proto file. This field - // is formatted the same as SourceCodeInfo.Location.path. - repeated int32 path = 1 [packed = true]; - - // Identifies the filesystem path to the original source .proto. - optional string source_file = 2; - - // Identifies the starting offset in bytes in the generated code - // that relates to the identified object. - optional int32 begin = 3; - - // Identifies the ending offset in bytes in the generated code that - // relates to the identified object. The end offset should be one past - // the last relevant byte (so the length of the text = end - begin). - optional int32 end = 4; - - // Represents the identified object's effect on the element in the original - // .proto file. - enum Semantic { - // There is no effect or the effect is indescribable. - NONE = 0; - // The element is set or otherwise mutated. - SET = 1; - // An alias to the element is returned. - ALIAS = 2; - } - optional Semantic semantic = 5; - } -} - -// Describes the 'visibility' of a symbol with respect to the proto import -// system. Symbols can only be imported when the visibility rules do not prevent -// it (ex: local symbols cannot be imported). Visibility modifiers can only set -// on `message` and `enum` as they are the only types available to be referenced -// from other files. -enum SymbolVisibility { - VISIBILITY_UNSET = 0; - VISIBILITY_LOCAL = 1; - VISIBILITY_EXPORT = 2; -} diff --git a/third_party/google/protobuf/duration.proto b/third_party/google/protobuf/duration.proto deleted file mode 100644 index 41f40c22..00000000 --- a/third_party/google/protobuf/duration.proto +++ /dev/null @@ -1,115 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/protobuf/types/known/durationpb"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "DurationProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; - -// A Duration represents a signed, fixed-length span of time represented -// as a count of seconds and fractions of seconds at nanosecond -// resolution. It is independent of any calendar and concepts like "day" -// or "month". It is related to Timestamp in that the difference between -// two Timestamp values is a Duration and it can be added or subtracted -// from a Timestamp. Range is approximately +-10,000 years. -// -// # Examples -// -// Example 1: Compute Duration from two Timestamps in pseudo code. -// -// Timestamp start = ...; -// Timestamp end = ...; -// Duration duration = ...; -// -// duration.seconds = end.seconds - start.seconds; -// duration.nanos = end.nanos - start.nanos; -// -// if (duration.seconds < 0 && duration.nanos > 0) { -// duration.seconds += 1; -// duration.nanos -= 1000000000; -// } else if (duration.seconds > 0 && duration.nanos < 0) { -// duration.seconds -= 1; -// duration.nanos += 1000000000; -// } -// -// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. -// -// Timestamp start = ...; -// Duration duration = ...; -// Timestamp end = ...; -// -// end.seconds = start.seconds + duration.seconds; -// end.nanos = start.nanos + duration.nanos; -// -// if (end.nanos < 0) { -// end.seconds -= 1; -// end.nanos += 1000000000; -// } else if (end.nanos >= 1000000000) { -// end.seconds += 1; -// end.nanos -= 1000000000; -// } -// -// Example 3: Compute Duration from datetime.timedelta in Python. -// -// td = datetime.timedelta(days=3, minutes=10) -// duration = Duration() -// duration.FromTimedelta(td) -// -// # JSON Mapping -// -// In JSON format, the Duration type is encoded as a string rather than an -// object, where the string ends in the suffix "s" (indicating seconds) and -// is preceded by the number of seconds, with nanoseconds expressed as -// fractional seconds. For example, 3 seconds with 0 nanoseconds should be -// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should -// be expressed in JSON format as "3.000000001s", and 3 seconds and 1 -// microsecond should be expressed in JSON format as "3.000001s". -// -message Duration { - // Signed seconds of the span of time. Must be from -315,576,000,000 - // to +315,576,000,000 inclusive. Note: these bounds are computed from: - // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years - int64 seconds = 1; - - // Signed fractions of a second at nanosecond resolution of the span - // of time. Durations less than one second are represented with a 0 - // `seconds` field and a positive or negative `nanos` field. For durations - // of one second or more, a non-zero value for the `nanos` field must be - // of the same sign as the `seconds` field. Must be from -999,999,999 - // to +999,999,999 inclusive. - int32 nanos = 2; -} diff --git a/third_party/google/protobuf/empty.proto b/third_party/google/protobuf/empty.proto deleted file mode 100644 index b87c89dc..00000000 --- a/third_party/google/protobuf/empty.proto +++ /dev/null @@ -1,51 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option go_package = "google.golang.org/protobuf/types/known/emptypb"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "EmptyProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option cc_enable_arenas = true; - -// A generic empty message that you can re-use to avoid defining duplicated -// empty messages in your APIs. A typical example is to use it as the request -// or the response type of an API method. For instance: -// -// service Foo { -// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); -// } -// -message Empty {} diff --git a/third_party/google/protobuf/field_mask.proto b/third_party/google/protobuf/field_mask.proto deleted file mode 100644 index b28334b9..00000000 --- a/third_party/google/protobuf/field_mask.proto +++ /dev/null @@ -1,245 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option java_package = "com.google.protobuf"; -option java_outer_classname = "FieldMaskProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "google.golang.org/protobuf/types/known/fieldmaskpb"; -option cc_enable_arenas = true; - -// `FieldMask` represents a set of symbolic field paths, for example: -// -// paths: "f.a" -// paths: "f.b.d" -// -// Here `f` represents a field in some root message, `a` and `b` -// fields in the message found in `f`, and `d` a field found in the -// message in `f.b`. -// -// Field masks are used to specify a subset of fields that should be -// returned by a get operation or modified by an update operation. -// Field masks also have a custom JSON encoding (see below). -// -// # Field Masks in Projections -// -// When used in the context of a projection, a response message or -// sub-message is filtered by the API to only contain those fields as -// specified in the mask. For example, if the mask in the previous -// example is applied to a response message as follows: -// -// f { -// a : 22 -// b { -// d : 1 -// x : 2 -// } -// y : 13 -// } -// z: 8 -// -// The result will not contain specific values for fields x,y and z -// (their value will be set to the default, and omitted in proto text -// output): -// -// -// f { -// a : 22 -// b { -// d : 1 -// } -// } -// -// A repeated field is not allowed except at the last position of a -// paths string. -// -// If a FieldMask object is not present in a get operation, the -// operation applies to all fields (as if a FieldMask of all fields -// had been specified). -// -// Note that a field mask does not necessarily apply to the -// top-level response message. In case of a REST get operation, the -// field mask applies directly to the response, but in case of a REST -// list operation, the mask instead applies to each individual message -// in the returned resource list. In case of a REST custom method, -// other definitions may be used. Where the mask applies will be -// clearly documented together with its declaration in the API. In -// any case, the effect on the returned resource/resources is required -// behavior for APIs. -// -// # Field Masks in Update Operations -// -// A field mask in update operations specifies which fields of the -// targeted resource are going to be updated. The API is required -// to only change the values of the fields as specified in the mask -// and leave the others untouched. If a resource is passed in to -// describe the updated values, the API ignores the values of all -// fields not covered by the mask. -// -// If a repeated field is specified for an update operation, new values will -// be appended to the existing repeated field in the target resource. Note that -// a repeated field is only allowed in the last position of a `paths` string. -// -// If a sub-message is specified in the last position of the field mask for an -// update operation, then new value will be merged into the existing sub-message -// in the target resource. -// -// For example, given the target message: -// -// f { -// b { -// d: 1 -// x: 2 -// } -// c: [1] -// } -// -// And an update message: -// -// f { -// b { -// d: 10 -// } -// c: [2] -// } -// -// then if the field mask is: -// -// paths: ["f.b", "f.c"] -// -// then the result will be: -// -// f { -// b { -// d: 10 -// x: 2 -// } -// c: [1, 2] -// } -// -// An implementation may provide options to override this default behavior for -// repeated and message fields. -// -// In order to reset a field's value to the default, the field must -// be in the mask and set to the default value in the provided resource. -// Hence, in order to reset all fields of a resource, provide a default -// instance of the resource and set all fields in the mask, or do -// not provide a mask as described below. -// -// If a field mask is not present on update, the operation applies to -// all fields (as if a field mask of all fields has been specified). -// Note that in the presence of schema evolution, this may mean that -// fields the client does not know and has therefore not filled into -// the request will be reset to their default. If this is unwanted -// behavior, a specific service may require a client to always specify -// a field mask, producing an error if not. -// -// As with get operations, the location of the resource which -// describes the updated values in the request message depends on the -// operation kind. In any case, the effect of the field mask is -// required to be honored by the API. -// -// ## Considerations for HTTP REST -// -// The HTTP kind of an update operation which uses a field mask must -// be set to PATCH instead of PUT in order to satisfy HTTP semantics -// (PUT must only be used for full updates). -// -// # JSON Encoding of Field Masks -// -// In JSON, a field mask is encoded as a single string where paths are -// separated by a comma. Fields name in each path are converted -// to/from lower-camel naming conventions. -// -// As an example, consider the following message declarations: -// -// message Profile { -// User user = 1; -// Photo photo = 2; -// } -// message User { -// string display_name = 1; -// string address = 2; -// } -// -// In proto a field mask for `Profile` may look as such: -// -// mask { -// paths: "user.display_name" -// paths: "photo" -// } -// -// In JSON, the same mask is represented as below: -// -// { -// mask: "user.displayName,photo" -// } -// -// # Field Masks and Oneof Fields -// -// Field masks treat fields in oneofs just as regular fields. Consider the -// following message: -// -// message SampleMessage { -// oneof test_oneof { -// string name = 4; -// SubMessage sub_message = 9; -// } -// } -// -// The field mask can be: -// -// mask { -// paths: "name" -// } -// -// Or: -// -// mask { -// paths: "sub_message" -// } -// -// Note that oneof type names ("test_oneof" in this case) cannot be used in -// paths. -// -// ## Field Mask Verification -// -// The implementation of any API method which has a FieldMask type field in the -// request should verify the included field paths, and return an -// `INVALID_ARGUMENT` error if any path is unmappable. -message FieldMask { - // The set of field mask paths. - repeated string paths = 1; -} diff --git a/third_party/google/protobuf/go_features.proto b/third_party/google/protobuf/go_features.proto deleted file mode 100644 index a9cc7923..00000000 --- a/third_party/google/protobuf/go_features.proto +++ /dev/null @@ -1,80 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2023 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -syntax = "proto2"; - -package pb; - -import "google/protobuf/descriptor.proto"; - -option go_package = "google.golang.org/protobuf/types/gofeaturespb"; - -extend google.protobuf.FeatureSet { - optional GoFeatures go = 1002; -} - -message GoFeatures { - // Whether or not to generate the deprecated UnmarshalJSON method for enums. - // Can only be true for proto using the Open Struct api. - optional bool legacy_unmarshal_json_enum = 1 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_ENUM, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - edition_deprecated: EDITION_2023, - deprecation_warning: "The legacy UnmarshalJSON API is deprecated and " - "will be removed in a future edition.", - }, - edition_defaults = { edition: EDITION_LEGACY, value: "true" }, - edition_defaults = { edition: EDITION_PROTO3, value: "false" } - ]; - - enum APILevel { - // API_LEVEL_UNSPECIFIED results in selecting the OPEN API, - // but needs to be a separate value to distinguish between - // an explicitly set api level or a missing api level. - API_LEVEL_UNSPECIFIED = 0; - API_OPEN = 1; - API_HYBRID = 2; - API_OPAQUE = 3; - } - - // One of OPEN, HYBRID or OPAQUE. - optional APILevel api_level = 2 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_MESSAGE, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "API_LEVEL_UNSPECIFIED" }, - edition_defaults = { edition: EDITION_2024, value: "API_OPAQUE" } - ]; - - enum StripEnumPrefix { - STRIP_ENUM_PREFIX_UNSPECIFIED = 0; - STRIP_ENUM_PREFIX_KEEP = 1; - STRIP_ENUM_PREFIX_GENERATE_BOTH = 2; - STRIP_ENUM_PREFIX_STRIP = 3; - } - - optional StripEnumPrefix strip_enum_prefix = 3 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_ENUM, - targets = TARGET_TYPE_ENUM_ENTRY, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2024, - }, - // TODO: change the default to STRIP_ENUM_PREFIX_STRIP for edition 2025. - edition_defaults = { - edition: EDITION_LEGACY, - value: "STRIP_ENUM_PREFIX_KEEP" - } - ]; -} diff --git a/third_party/google/protobuf/java_features.proto b/third_party/google/protobuf/java_features.proto deleted file mode 100644 index 4fc6dc41..00000000 --- a/third_party/google/protobuf/java_features.proto +++ /dev/null @@ -1,130 +0,0 @@ - -// Protocol Buffers - Google's data interchange format -// Copyright 2023 Google Inc. All rights reserved. -// -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file or at -// https://developers.google.com/open-source/licenses/bsd - -syntax = "proto2"; - -package pb; - -import "google/protobuf/descriptor.proto"; - -option java_package = "com.google.protobuf"; -option java_outer_classname = "JavaFeaturesProto"; - -extend google.protobuf.FeatureSet { - optional JavaFeatures java = 1001; -} - -message JavaFeatures { - // Whether or not to treat an enum field as closed. This option is only - // applicable to enum fields, and will be removed in the future. It is - // consistent with the legacy behavior of using proto3 enum types for proto2 - // fields. - optional bool legacy_closed_enum = 1 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_FIELD, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - edition_deprecated: EDITION_2023, - deprecation_warning: "The legacy closed enum behavior in Java is " - "deprecated and is scheduled to be removed in " - "edition 2025. See http://protobuf.dev/programming-guides/enum/#java for " - "more information.", - }, - edition_defaults = { edition: EDITION_LEGACY, value: "true" }, - edition_defaults = { edition: EDITION_PROTO3, value: "false" } - ]; - - // The UTF8 validation strategy to use. - enum Utf8Validation { - // Invalid default, which should never be used. - UTF8_VALIDATION_UNKNOWN = 0; - // Respect the UTF8 validation behavior specified by the global - // utf8_validation feature. - DEFAULT = 1; - // Verifies UTF8 validity overriding the global utf8_validation - // feature. This represents the legacy java_string_check_utf8 option. - VERIFY = 2; - } - optional Utf8Validation utf8_validation = 2 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_FIELD, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2023, - edition_deprecated: EDITION_2024, - deprecation_warning: "The Java-specific utf8 validation feature is " - "deprecated and is scheduled to be removed in " - "edition 2025. Utf8 validation behavior should " - "use the global cross-language utf8_validation " - "feature.", - }, - edition_defaults = { edition: EDITION_LEGACY, value: "DEFAULT" } - ]; - - // Allows creation of large Java enums, extending beyond the standard - // constant limits imposed by the Java language. - optional bool large_enum = 3 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_ENUM, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2024, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "false" } - ]; - - // Whether to use the old default outer class name scheme, or the new feature - // which adds a "Proto" suffix to the outer class name. - // - // Users will not be able to set this option, because we removed it in the - // same edition that it was introduced. But we use it to determine which - // naming scheme to use for outer class name defaults. - optional bool use_old_outer_classname_default = 4 [ - retention = RETENTION_RUNTIME, - targets = TARGET_TYPE_FILE, - feature_support = { - edition_introduced: EDITION_2024, - edition_removed: EDITION_2024, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "true" }, - edition_defaults = { edition: EDITION_2024, value: "false" } - ]; - - message NestInFileClassFeature { - enum NestInFileClass { - // Invalid default, which should never be used. - NEST_IN_FILE_CLASS_UNKNOWN = 0; - // Do not nest the generated class in the file class. - NO = 1; - // Nest the generated class in the file class. - YES = 2; - // Fall back to the `java_multiple_files` option. Users won't be able to - // set this option. - LEGACY = 3 [feature_support = { - edition_introduced: EDITION_2024 - edition_removed: EDITION_2024 - }]; - } - reserved 1 to max; - } - - // Whether to nest the generated class in the generated file class. This is - // only applicable to *top-level* messages, enums, and services. - optional NestInFileClassFeature.NestInFileClass nest_in_file_class = 5 [ - retention = RETENTION_SOURCE, - targets = TARGET_TYPE_MESSAGE, - targets = TARGET_TYPE_ENUM, - targets = TARGET_TYPE_SERVICE, - feature_support = { - edition_introduced: EDITION_2024, - }, - edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY" }, - edition_defaults = { edition: EDITION_2024, value: "NO" } - ]; -} diff --git a/third_party/google/protobuf/source_context.proto b/third_party/google/protobuf/source_context.proto deleted file mode 100644 index 135f50fe..00000000 --- a/third_party/google/protobuf/source_context.proto +++ /dev/null @@ -1,48 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option java_package = "com.google.protobuf"; -option java_outer_classname = "SourceContextProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "google.golang.org/protobuf/types/known/sourcecontextpb"; - -// `SourceContext` represents information about the source of a -// protobuf element, like the file in which it is defined. -message SourceContext { - // The path-qualified name of the .proto file that contained the associated - // protobuf element. For example: `"google/protobuf/source_context.proto"`. - string file_name = 1; -} diff --git a/third_party/google/protobuf/struct.proto b/third_party/google/protobuf/struct.proto deleted file mode 100644 index 1bf0c1ad..00000000 --- a/third_party/google/protobuf/struct.proto +++ /dev/null @@ -1,95 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/protobuf/types/known/structpb"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "StructProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; - -// `Struct` represents a structured data value, consisting of fields -// which map to dynamically typed values. In some languages, `Struct` -// might be supported by a native representation. For example, in -// scripting languages like JS a struct is represented as an -// object. The details of that representation are described together -// with the proto support for the language. -// -// The JSON representation for `Struct` is JSON object. -message Struct { - // Unordered map of dynamically typed values. - map fields = 1; -} - -// `Value` represents a dynamically typed value which can be either -// null, a number, a string, a boolean, a recursive struct value, or a -// list of values. A producer of value is expected to set one of these -// variants. Absence of any variant indicates an error. -// -// The JSON representation for `Value` is JSON value. -message Value { - // The kind of value. - oneof kind { - // Represents a null value. - NullValue null_value = 1; - // Represents a double value. - double number_value = 2; - // Represents a string value. - string string_value = 3; - // Represents a boolean value. - bool bool_value = 4; - // Represents a structured value. - Struct struct_value = 5; - // Represents a repeated `Value`. - ListValue list_value = 6; - } -} - -// `NullValue` is a singleton enumeration to represent the null value for the -// `Value` type union. -// -// The JSON representation for `NullValue` is JSON `null`. -enum NullValue { - // Null value. - NULL_VALUE = 0; -} - -// `ListValue` is a wrapper around a repeated field of values. -// -// The JSON representation for `ListValue` is JSON array. -message ListValue { - // Repeated field of dynamically typed values. - repeated Value values = 1; -} diff --git a/third_party/google/protobuf/timestamp.proto b/third_party/google/protobuf/timestamp.proto deleted file mode 100644 index fd0bc07d..00000000 --- a/third_party/google/protobuf/timestamp.proto +++ /dev/null @@ -1,144 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/protobuf/types/known/timestamppb"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "TimestampProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; - -// A Timestamp represents a point in time independent of any time zone or local -// calendar, encoded as a count of seconds and fractions of seconds at -// nanosecond resolution. The count is relative to an epoch at UTC midnight on -// January 1, 1970, in the proleptic Gregorian calendar which extends the -// Gregorian calendar backwards to year one. -// -// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap -// second table is needed for interpretation, using a [24-hour linear -// smear](https://developers.google.com/time/smear). -// -// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By -// restricting to that range, we ensure that we can convert to and from [RFC -// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. -// -// # Examples -// -// Example 1: Compute Timestamp from POSIX `time()`. -// -// Timestamp timestamp; -// timestamp.set_seconds(time(NULL)); -// timestamp.set_nanos(0); -// -// Example 2: Compute Timestamp from POSIX `gettimeofday()`. -// -// struct timeval tv; -// gettimeofday(&tv, NULL); -// -// Timestamp timestamp; -// timestamp.set_seconds(tv.tv_sec); -// timestamp.set_nanos(tv.tv_usec * 1000); -// -// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. -// -// FILETIME ft; -// GetSystemTimeAsFileTime(&ft); -// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; -// -// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z -// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. -// Timestamp timestamp; -// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); -// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); -// -// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. -// -// long millis = System.currentTimeMillis(); -// -// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) -// .setNanos((int) ((millis % 1000) * 1000000)).build(); -// -// Example 5: Compute Timestamp from Java `Instant.now()`. -// -// Instant now = Instant.now(); -// -// Timestamp timestamp = -// Timestamp.newBuilder().setSeconds(now.getEpochSecond()) -// .setNanos(now.getNano()).build(); -// -// Example 6: Compute Timestamp from current time in Python. -// -// timestamp = Timestamp() -// timestamp.GetCurrentTime() -// -// # JSON Mapping -// -// In JSON format, the Timestamp type is encoded as a string in the -// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the -// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" -// where {year} is always expressed using four digits while {month}, {day}, -// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional -// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), -// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone -// is required. A proto3 JSON serializer should always use UTC (as indicated by -// "Z") when printing the Timestamp type and a proto3 JSON parser should be -// able to accept both UTC and other timezones (as indicated by an offset). -// -// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past -// 01:30 UTC on January 15, 2017. -// -// In JavaScript, one can convert a Date object to this format using the -// standard -// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) -// method. In Python, a standard `datetime.datetime` object can be converted -// to this format using -// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with -// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use -// the Joda Time's [`ISODateTimeFormat.dateTime()`]( -// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime() -// ) to obtain a formatter capable of generating timestamps in this format. -// -message Timestamp { - // Represents seconds of UTC time since Unix epoch - // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to - // 9999-12-31T23:59:59Z inclusive. - int64 seconds = 1; - - // Non-negative fractions of a second at nanosecond resolution. Negative - // second values with fractions must still have non-negative nanos values - // that count forward in time. Must be from 0 to 999,999,999 - // inclusive. - int32 nanos = 2; -} diff --git a/third_party/google/protobuf/type.proto b/third_party/google/protobuf/type.proto deleted file mode 100644 index 48cb11e7..00000000 --- a/third_party/google/protobuf/type.proto +++ /dev/null @@ -1,193 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -syntax = "proto3"; - -package google.protobuf; - -import "google/protobuf/any.proto"; -import "google/protobuf/source_context.proto"; - -option cc_enable_arenas = true; -option java_package = "com.google.protobuf"; -option java_outer_classname = "TypeProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; -option go_package = "google.golang.org/protobuf/types/known/typepb"; - -// A protocol buffer message type. -message Type { - // The fully qualified message name. - string name = 1; - // The list of fields. - repeated Field fields = 2; - // The list of types appearing in `oneof` definitions in this type. - repeated string oneofs = 3; - // The protocol buffer options. - repeated Option options = 4; - // The source context. - SourceContext source_context = 5; - // The source syntax. - Syntax syntax = 6; - // The source edition string, only valid when syntax is SYNTAX_EDITIONS. - string edition = 7; -} - -// A single field of a message type. -message Field { - // Basic field types. - enum Kind { - // Field type unknown. - TYPE_UNKNOWN = 0; - // Field type double. - TYPE_DOUBLE = 1; - // Field type float. - TYPE_FLOAT = 2; - // Field type int64. - TYPE_INT64 = 3; - // Field type uint64. - TYPE_UINT64 = 4; - // Field type int32. - TYPE_INT32 = 5; - // Field type fixed64. - TYPE_FIXED64 = 6; - // Field type fixed32. - TYPE_FIXED32 = 7; - // Field type bool. - TYPE_BOOL = 8; - // Field type string. - TYPE_STRING = 9; - // Field type group. Proto2 syntax only, and deprecated. - TYPE_GROUP = 10; - // Field type message. - TYPE_MESSAGE = 11; - // Field type bytes. - TYPE_BYTES = 12; - // Field type uint32. - TYPE_UINT32 = 13; - // Field type enum. - TYPE_ENUM = 14; - // Field type sfixed32. - TYPE_SFIXED32 = 15; - // Field type sfixed64. - TYPE_SFIXED64 = 16; - // Field type sint32. - TYPE_SINT32 = 17; - // Field type sint64. - TYPE_SINT64 = 18; - } - - // Whether a field is optional, required, or repeated. - enum Cardinality { - // For fields with unknown cardinality. - CARDINALITY_UNKNOWN = 0; - // For optional fields. - CARDINALITY_OPTIONAL = 1; - // For required fields. Proto2 syntax only. - CARDINALITY_REQUIRED = 2; - // For repeated fields. - CARDINALITY_REPEATED = 3; - } - - // The field type. - Kind kind = 1; - // The field cardinality. - Cardinality cardinality = 2; - // The field number. - int32 number = 3; - // The field name. - string name = 4; - // The field type URL, without the scheme, for message or enumeration - // types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. - string type_url = 6; - // The index of the field type in `Type.oneofs`, for message or enumeration - // types. The first type has index 1; zero means the type is not in the list. - int32 oneof_index = 7; - // Whether to use alternative packed wire representation. - bool packed = 8; - // The protocol buffer options. - repeated Option options = 9; - // The field JSON name. - string json_name = 10; - // The string value of the default value of this field. Proto2 syntax only. - string default_value = 11; -} - -// Enum type definition. -message Enum { - // Enum type name. - string name = 1; - // Enum value definitions. - repeated EnumValue enumvalue = 2; - // Protocol buffer options. - repeated Option options = 3; - // The source context. - SourceContext source_context = 4; - // The source syntax. - Syntax syntax = 5; - // The source edition string, only valid when syntax is SYNTAX_EDITIONS. - string edition = 6; -} - -// Enum value definition. -message EnumValue { - // Enum value name. - string name = 1; - // Enum value number. - int32 number = 2; - // Protocol buffer options. - repeated Option options = 3; -} - -// A protocol buffer option, which can be attached to a message, field, -// enumeration, etc. -message Option { - // The option's name. For protobuf built-in options (options defined in - // descriptor.proto), this is the short name. For example, `"map_entry"`. - // For custom options, it should be the fully-qualified name. For example, - // `"google.api.http"`. - string name = 1; - // The option's value packed in an Any message. If the value is a primitive, - // the corresponding wrapper type defined in google/protobuf/wrappers.proto - // should be used. If the value is an enum, it should be stored as an int32 - // value using the google.protobuf.Int32Value type. - Any value = 2; -} - -// The syntax in which a protocol buffer element is defined. -enum Syntax { - // Syntax `proto2`. - SYNTAX_PROTO2 = 0; - // Syntax `proto3`. - SYNTAX_PROTO3 = 1; - // Syntax `editions`. - SYNTAX_EDITIONS = 2; -} diff --git a/third_party/google/protobuf/wrappers.proto b/third_party/google/protobuf/wrappers.proto deleted file mode 100644 index e583e7c4..00000000 --- a/third_party/google/protobuf/wrappers.proto +++ /dev/null @@ -1,157 +0,0 @@ -// Protocol Buffers - Google's data interchange format -// Copyright 2008 Google Inc. All rights reserved. -// https://developers.google.com/protocol-buffers/ -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Wrappers for primitive (non-message) types. These types were needed -// for legacy reasons and are not recommended for use in new APIs. -// -// Historically these wrappers were useful to have presence on proto3 primitive -// fields, but proto3 syntax has been updated to support the `optional` keyword. -// Using that keyword is now the strongly preferred way to add presence to -// proto3 primitive fields. -// -// A secondary usecase was to embed primitives in the `google.protobuf.Any` -// type: it is now recommended that you embed your value in your own wrapper -// message which can be specifically documented. -// -// These wrappers have no meaningful use within repeated fields as they lack -// the ability to detect presence on individual elements. -// These wrappers have no meaningful use within a map or a oneof since -// individual entries of a map or fields of a oneof can already detect presence. - -syntax = "proto3"; - -package google.protobuf; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/protobuf/types/known/wrapperspb"; -option java_package = "com.google.protobuf"; -option java_outer_classname = "WrappersProto"; -option java_multiple_files = true; -option objc_class_prefix = "GPB"; -option csharp_namespace = "Google.Protobuf.WellKnownTypes"; - -// Wrapper message for `double`. -// -// The JSON representation for `DoubleValue` is JSON number. -// -// Not recommended for use in new APIs, but still useful for legacy APIs and -// has no plan to be removed. -message DoubleValue { - // The double value. - double value = 1; -} - -// Wrapper message for `float`. -// -// The JSON representation for `FloatValue` is JSON number. -// -// Not recommended for use in new APIs, but still useful for legacy APIs and -// has no plan to be removed. -message FloatValue { - // The float value. - float value = 1; -} - -// Wrapper message for `int64`. -// -// The JSON representation for `Int64Value` is JSON string. -// -// Not recommended for use in new APIs, but still useful for legacy APIs and -// has no plan to be removed. -message Int64Value { - // The int64 value. - int64 value = 1; -} - -// Wrapper message for `uint64`. -// -// The JSON representation for `UInt64Value` is JSON string. -// -// Not recommended for use in new APIs, but still useful for legacy APIs and -// has no plan to be removed. -message UInt64Value { - // The uint64 value. - uint64 value = 1; -} - -// Wrapper message for `int32`. -// -// The JSON representation for `Int32Value` is JSON number. -// -// Not recommended for use in new APIs, but still useful for legacy APIs and -// has no plan to be removed. -message Int32Value { - // The int32 value. - int32 value = 1; -} - -// Wrapper message for `uint32`. -// -// The JSON representation for `UInt32Value` is JSON number. -// -// Not recommended for use in new APIs, but still useful for legacy APIs and -// has no plan to be removed. -message UInt32Value { - // The uint32 value. - uint32 value = 1; -} - -// Wrapper message for `bool`. -// -// The JSON representation for `BoolValue` is JSON `true` and `false`. -// -// Not recommended for use in new APIs, but still useful for legacy APIs and -// has no plan to be removed. -message BoolValue { - // The bool value. - bool value = 1; -} - -// Wrapper message for `string`. -// -// The JSON representation for `StringValue` is JSON string. -// -// Not recommended for use in new APIs, but still useful for legacy APIs and -// has no plan to be removed. -message StringValue { - // The string value. - string value = 1; -} - -// Wrapper message for `bytes`. -// -// The JSON representation for `BytesValue` is JSON string. -// -// Not recommended for use in new APIs, but still useful for legacy APIs and -// has no plan to be removed. -message BytesValue { - // The bytes value. - bytes value = 1; -} diff --git a/third_party/google/rpc/code.proto b/third_party/google/rpc/code.proto deleted file mode 100644 index aa6ce153..00000000 --- a/third_party/google/rpc/code.proto +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc; - -option go_package = "google.golang.org/genproto/googleapis/rpc/code;code"; -option java_multiple_files = true; -option java_outer_classname = "CodeProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - -// The canonical error codes for gRPC APIs. -// -// -// Sometimes multiple error codes may apply. Services should return -// the most specific error code that applies. For example, prefer -// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply. -// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`. -enum Code { - // Not an error; returned on success. - // - // HTTP Mapping: 200 OK - OK = 0; - - // The operation was cancelled, typically by the caller. - // - // HTTP Mapping: 499 Client Closed Request - CANCELLED = 1; - - // Unknown error. For example, this error may be returned when - // a `Status` value received from another address space belongs to - // an error space that is not known in this address space. Also - // errors raised by APIs that do not return enough error information - // may be converted to this error. - // - // HTTP Mapping: 500 Internal Server Error - UNKNOWN = 2; - - // The client specified an invalid argument. Note that this differs - // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments - // that are problematic regardless of the state of the system - // (e.g., a malformed file name). - // - // HTTP Mapping: 400 Bad Request - INVALID_ARGUMENT = 3; - - // The deadline expired before the operation could complete. For operations - // that change the state of the system, this error may be returned - // even if the operation has completed successfully. For example, a - // successful response from a server could have been delayed long - // enough for the deadline to expire. - // - // HTTP Mapping: 504 Gateway Timeout - DEADLINE_EXCEEDED = 4; - - // Some requested entity (e.g., file or directory) was not found. - // - // Note to server developers: if a request is denied for an entire class - // of users, such as gradual feature rollout or undocumented allowlist, - // `NOT_FOUND` may be used. If a request is denied for some users within - // a class of users, such as user-based access control, `PERMISSION_DENIED` - // must be used. - // - // HTTP Mapping: 404 Not Found - NOT_FOUND = 5; - - // The entity that a client attempted to create (e.g., file or directory) - // already exists. - // - // HTTP Mapping: 409 Conflict - ALREADY_EXISTS = 6; - - // The caller does not have permission to execute the specified - // operation. `PERMISSION_DENIED` must not be used for rejections - // caused by exhausting some resource (use `RESOURCE_EXHAUSTED` - // instead for those errors). `PERMISSION_DENIED` must not be - // used if the caller can not be identified (use `UNAUTHENTICATED` - // instead for those errors). This error code does not imply the - // request is valid or the requested entity exists or satisfies - // other pre-conditions. - // - // HTTP Mapping: 403 Forbidden - PERMISSION_DENIED = 7; - - // The request does not have valid authentication credentials for the - // operation. - // - // HTTP Mapping: 401 Unauthorized - UNAUTHENTICATED = 16; - - // Some resource has been exhausted, perhaps a per-user quota, or - // perhaps the entire file system is out of space. - // - // HTTP Mapping: 429 Too Many Requests - RESOURCE_EXHAUSTED = 8; - - // The operation was rejected because the system is not in a state - // required for the operation's execution. For example, the directory - // to be deleted is non-empty, an rmdir operation is applied to - // a non-directory, etc. - // - // Service implementors can use the following guidelines to decide - // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: - // (a) Use `UNAVAILABLE` if the client can retry just the failing call. - // (b) Use `ABORTED` if the client should retry at a higher level. For - // example, when a client-specified test-and-set fails, indicating the - // client should restart a read-modify-write sequence. - // (c) Use `FAILED_PRECONDITION` if the client should not retry until - // the system state has been explicitly fixed. For example, if an "rmdir" - // fails because the directory is non-empty, `FAILED_PRECONDITION` - // should be returned since the client should not retry unless - // the files are deleted from the directory. - // - // HTTP Mapping: 400 Bad Request - FAILED_PRECONDITION = 9; - - // The operation was aborted, typically due to a concurrency issue such as - // a sequencer check failure or transaction abort. - // - // See the guidelines above for deciding between `FAILED_PRECONDITION`, - // `ABORTED`, and `UNAVAILABLE`. - // - // HTTP Mapping: 409 Conflict - ABORTED = 10; - - // The operation was attempted past the valid range. E.g., seeking or - // reading past end-of-file. - // - // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may - // be fixed if the system state changes. For example, a 32-bit file - // system will generate `INVALID_ARGUMENT` if asked to read at an - // offset that is not in the range [0,2^32-1], but it will generate - // `OUT_OF_RANGE` if asked to read from an offset past the current - // file size. - // - // There is a fair bit of overlap between `FAILED_PRECONDITION` and - // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific - // error) when it applies so that callers who are iterating through - // a space can easily look for an `OUT_OF_RANGE` error to detect when - // they are done. - // - // HTTP Mapping: 400 Bad Request - OUT_OF_RANGE = 11; - - // The operation is not implemented or is not supported/enabled in this - // service. - // - // HTTP Mapping: 501 Not Implemented - UNIMPLEMENTED = 12; - - // Internal errors. This means that some invariants expected by the - // underlying system have been broken. This error code is reserved - // for serious errors. - // - // HTTP Mapping: 500 Internal Server Error - INTERNAL = 13; - - // The service is currently unavailable. This is most likely a - // transient condition, which can be corrected by retrying with - // a backoff. Note that it is not always safe to retry - // non-idempotent operations. - // - // See the guidelines above for deciding between `FAILED_PRECONDITION`, - // `ABORTED`, and `UNAVAILABLE`. - // - // HTTP Mapping: 503 Service Unavailable - UNAVAILABLE = 14; - - // Unrecoverable data loss or corruption. - // - // HTTP Mapping: 500 Internal Server Error - DATA_LOSS = 15; -} diff --git a/third_party/google/rpc/context/attribute_context.proto b/third_party/google/rpc/context/attribute_context.proto deleted file mode 100644 index 57276600..00000000 --- a/third_party/google/rpc/context/attribute_context.proto +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc.context; - -import "google/protobuf/any.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/struct.proto"; -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/rpc/context/attribute_context;attribute_context"; -option java_multiple_files = true; -option java_outer_classname = "AttributeContextProto"; -option java_package = "com.google.rpc.context"; - -// This message defines the standard attribute vocabulary for Google APIs. -// -// An attribute is a piece of metadata that describes an activity on a network -// service. For example, the size of an HTTP request, or the status code of -// an HTTP response. -// -// Each attribute has a type and a name, which is logically defined as -// a proto message field in `AttributeContext`. The field type becomes the -// attribute type, and the field path becomes the attribute name. For example, -// the attribute `source.ip` maps to field `AttributeContext.source.ip`. -// -// This message definition is guaranteed not to have any wire breaking change. -// So you can use it directly for passing attributes across different systems. -// -// NOTE: Different system may generate different subset of attributes. Please -// verify the system specification before relying on an attribute generated -// a system. -message AttributeContext { - // This message defines attributes for a node that handles a network request. - // The node can be either a service or an application that sends, forwards, - // or receives the request. Service peers should fill in - // `principal` and `labels` as appropriate. - message Peer { - // The IP address of the peer. - string ip = 1; - - // The network port of the peer. - int64 port = 2; - - // The labels associated with the peer. - map labels = 6; - - // The identity of this peer. Similar to `Request.auth.principal`, but - // relative to the peer instead of the request. For example, the - // identity associated with a load balancer that forwarded the request. - string principal = 7; - - // The CLDR country/region code associated with the above IP address. - // If the IP address is private, the `region_code` should reflect the - // physical location where this peer is running. - string region_code = 8; - } - - // This message defines attributes associated with API operations, such as - // a network API request. The terminology is based on the conventions used - // by Google APIs, Istio, and OpenAPI. - message Api { - // The API service name. It is a logical identifier for a networked API, - // such as "pubsub.googleapis.com". The naming syntax depends on the - // API management system being used for handling the request. - string service = 1; - - // The API operation name. For gRPC requests, it is the fully qualified API - // method name, such as "google.pubsub.v1.Publisher.Publish". For OpenAPI - // requests, it is the `operationId`, such as "getPet". - string operation = 2; - - // The API protocol used for sending the request, such as "http", "https", - // "grpc", or "internal". - string protocol = 3; - - // The API version associated with the API operation above, such as "v1" or - // "v1alpha1". - string version = 4; - } - - // This message defines request authentication attributes. Terminology is - // based on the JSON Web Token (JWT) standard, but the terms also - // correlate to concepts in other standards. - message Auth { - // The authenticated principal. Reflects the issuer (`iss`) and subject - // (`sub`) claims within a JWT. The issuer and subject should be `/` - // delimited, with `/` percent-encoded within the subject fragment. For - // Google accounts, the principal format is: - // "https://accounts.google.com/{id}" - string principal = 1; - - // The intended audience(s) for this authentication information. Reflects - // the audience (`aud`) claim within a JWT. The audience - // value(s) depends on the `issuer`, but typically include one or more of - // the following pieces of information: - // - // * The services intended to receive the credential. For example, - // ["https://pubsub.googleapis.com/", "https://storage.googleapis.com/"]. - // * A set of service-based scopes. For example, - // ["https://www.googleapis.com/auth/cloud-platform"]. - // * The client id of an app, such as the Firebase project id for JWTs - // from Firebase Auth. - // - // Consult the documentation for the credential issuer to determine the - // information provided. - repeated string audiences = 2; - - // The authorized presenter of the credential. Reflects the optional - // Authorized Presenter (`azp`) claim within a JWT or the - // OAuth client id. For example, a Google Cloud Platform client id looks - // as follows: "123456789012.apps.googleusercontent.com". - string presenter = 3; - - // Structured claims presented with the credential. JWTs include - // `{key: value}` pairs for standard and private claims. The following - // is a subset of the standard required and optional claims that would - // typically be presented for a Google-based JWT: - // - // {'iss': 'accounts.google.com', - // 'sub': '113289723416554971153', - // 'aud': ['123456789012', 'pubsub.googleapis.com'], - // 'azp': '123456789012.apps.googleusercontent.com', - // 'email': 'jsmith@example.com', - // 'iat': 1353601026, - // 'exp': 1353604926} - // - // SAML assertions are similarly specified, but with an identity provider - // dependent structure. - google.protobuf.Struct claims = 4; - - // A list of access level resource names that allow resources to be - // accessed by authenticated requester. It is part of Secure GCP processing - // for the incoming request. An access level string has the format: - // "//{api_service_name}/accessPolicies/{policy_id}/accessLevels/{short_name}" - // - // Example: - // "//accesscontextmanager.googleapis.com/accessPolicies/MY_POLICY_ID/accessLevels/MY_LEVEL" - repeated string access_levels = 5; - } - - // This message defines attributes for an HTTP request. If the actual - // request is not an HTTP request, the runtime system should try to map - // the actual request to an equivalent HTTP request. - message Request { - // The unique ID for a request, which can be propagated to downstream - // systems. The ID should have low probability of collision - // within a single day for a specific service. - string id = 1; - - // The HTTP request method, such as `GET`, `POST`. - string method = 2; - - // The HTTP request headers. If multiple headers share the same key, they - // must be merged according to the HTTP spec. All header keys must be - // lowercased, because HTTP header keys are case-insensitive. - map headers = 3; - - // The HTTP URL path, excluding the query parameters. - string path = 4; - - // The HTTP request `Host` header value. - string host = 5; - - // The HTTP URL scheme, such as `http` and `https`. - string scheme = 6; - - // The HTTP URL query in the format of `name1=value1&name2=value2`, as it - // appears in the first line of the HTTP request. No decoding is performed. - string query = 7; - - // The timestamp when the `destination` service receives the last byte of - // the request. - google.protobuf.Timestamp time = 9; - - // The HTTP request size in bytes. If unknown, it must be -1. - int64 size = 10; - - // The network protocol used with the request, such as "http/1.1", - // "spdy/3", "h2", "h2c", "webrtc", "tcp", "udp", "quic". See - // https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids - // for details. - string protocol = 11; - - // A special parameter for request reason. It is used by security systems - // to associate auditing information with a request. - string reason = 12; - - // The request authentication. May be absent for unauthenticated requests. - // Derived from the HTTP request `Authorization` header or equivalent. - Auth auth = 13; - } - - // This message defines attributes for a typical network response. It - // generally models semantics of an HTTP response. - message Response { - // The HTTP response status code, such as `200` and `404`. - int64 code = 1; - - // The HTTP response size in bytes. If unknown, it must be -1. - int64 size = 2; - - // The HTTP response headers. If multiple headers share the same key, they - // must be merged according to HTTP spec. All header keys must be - // lowercased, because HTTP header keys are case-insensitive. - map headers = 3; - - // The timestamp when the `destination` service sends the last byte of - // the response. - google.protobuf.Timestamp time = 4; - - // The amount of time it takes the backend service to fully respond to a - // request. Measured from when the destination service starts to send the - // request to the backend until when the destination service receives the - // complete response from the backend. - google.protobuf.Duration backend_latency = 5; - } - - // This message defines core attributes for a resource. A resource is an - // addressable (named) entity provided by the destination service. For - // example, a file stored on a network storage service. - message Resource { - // The name of the service that this resource belongs to, such as - // `pubsub.googleapis.com`. The service may be different from the DNS - // hostname that actually serves the request. - string service = 1; - - // The stable identifier (name) of a resource on the `service`. A resource - // can be logically identified as "//{resource.service}/{resource.name}". - // The differences between a resource name and a URI are: - // - // * Resource name is a logical identifier, independent of network - // protocol and API version. For example, - // `//pubsub.googleapis.com/projects/123/topics/news-feed`. - // * URI often includes protocol and version information, so it can - // be used directly by applications. For example, - // `https://pubsub.googleapis.com/v1/projects/123/topics/news-feed`. - // - // See https://cloud.google.com/apis/design/resource_names for details. - string name = 2; - - // The type of the resource. The syntax is platform-specific because - // different platforms define their resources differently. - // - // For Google APIs, the type format must be "{service}/{kind}", such as - // "pubsub.googleapis.com/Topic". - string type = 3; - - // The labels or tags on the resource, such as AWS resource tags and - // Kubernetes resource labels. - map labels = 4; - - // The unique identifier of the resource. UID is unique in the time - // and space for this resource within the scope of the service. It is - // typically generated by the server on successful creation of a resource - // and must not be changed. UID is used to uniquely identify resources - // with resource name reuses. This should be a UUID4. - string uid = 5; - - // Annotations is an unstructured key-value map stored with a resource that - // may be set by external tools to store and retrieve arbitrary metadata. - // They are not queryable and should be preserved when modifying objects. - // - // More info: - // https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ - map annotations = 6; - - // Mutable. The display name set by clients. Must be <= 63 characters. - string display_name = 7; - - // Output only. The timestamp when the resource was created. This may - // be either the time creation was initiated or when it was completed. - google.protobuf.Timestamp create_time = 8; - - // Output only. The timestamp when the resource was last updated. Any - // change to the resource made by users must refresh this value. - // Changes to a resource made by the service should refresh this value. - google.protobuf.Timestamp update_time = 9; - - // Output only. The timestamp when the resource was deleted. - // If the resource is not deleted, this must be empty. - google.protobuf.Timestamp delete_time = 10; - - // Output only. An opaque value that uniquely identifies a version or - // generation of a resource. It can be used to confirm that the client - // and server agree on the ordering of a resource being written. - string etag = 11; - - // Immutable. The location of the resource. The location encoding is - // specific to the service provider, and new encoding may be introduced - // as the service evolves. - // - // For Google Cloud products, the encoding is what is used by Google Cloud - // APIs, such as `us-east1`, `aws-us-east-1`, and `azure-eastus2`. The - // semantics of `location` is identical to the - // `cloud.googleapis.com/location` label used by some Google Cloud APIs. - string location = 12; - } - - // The origin of a network activity. In a multi hop network activity, - // the origin represents the sender of the first hop. For the first hop, - // the `source` and the `origin` must have the same content. - Peer origin = 7; - - // The source of a network activity, such as starting a TCP connection. - // In a multi hop network activity, the source represents the sender of the - // last hop. - Peer source = 1; - - // The destination of a network activity, such as accepting a TCP connection. - // In a multi hop network activity, the destination represents the receiver of - // the last hop. - Peer destination = 2; - - // Represents a network request, such as an HTTP request. - Request request = 3; - - // Represents a network response, such as an HTTP response. - Response response = 4; - - // Represents a target resource that is involved with a network activity. - // If multiple resources are involved with an activity, this must be the - // primary one. - Resource resource = 5; - - // Represents an API operation that is involved to a network activity. - Api api = 6; - - // Supports extensions for advanced use cases, such as logs and metrics. - repeated google.protobuf.Any extensions = 8; -} diff --git a/third_party/google/rpc/error_details.proto b/third_party/google/rpc/error_details.proto deleted file mode 100644 index 4f9ecff0..00000000 --- a/third_party/google/rpc/error_details.proto +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc; - -import "google/protobuf/duration.proto"; - -option go_package = "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails"; -option java_multiple_files = true; -option java_outer_classname = "ErrorDetailsProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - -// Describes the cause of the error with structured details. -// -// Example of an error when contacting the "pubsub.googleapis.com" API when it -// is not enabled: -// -// { "reason": "API_DISABLED" -// "domain": "googleapis.com" -// "metadata": { -// "resource": "projects/123", -// "service": "pubsub.googleapis.com" -// } -// } -// -// This response indicates that the pubsub.googleapis.com API is not enabled. -// -// Example of an error that is returned when attempting to create a Spanner -// instance in a region that is out of stock: -// -// { "reason": "STOCKOUT" -// "domain": "spanner.googleapis.com", -// "metadata": { -// "availableRegions": "us-central1,us-east2" -// } -// } -message ErrorInfo { - // The reason of the error. This is a constant value that identifies the - // proximate cause of the error. Error reasons are unique within a particular - // domain of errors. This should be at most 63 characters and match a - // regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, which represents - // UPPER_SNAKE_CASE. - string reason = 1; - - // The logical grouping to which the "reason" belongs. The error domain - // is typically the registered service name of the tool or product that - // generates the error. Example: "pubsub.googleapis.com". If the error is - // generated by some common infrastructure, the error domain must be a - // globally unique value that identifies the infrastructure. For Google API - // infrastructure, the error domain is "googleapis.com". - string domain = 2; - - // Additional structured details about this error. - // - // Keys must match a regular expression of `[a-z][a-zA-Z0-9-_]+` but should - // ideally be lowerCamelCase. Also, they must be limited to 64 characters in - // length. When identifying the current value of an exceeded limit, the units - // should be contained in the key, not the value. For example, rather than - // `{"instanceLimit": "100/request"}`, should be returned as, - // `{"instanceLimitPerRequest": "100"}`, if the client exceeds the number of - // instances that can be created in a single (batch) request. - map metadata = 3; -} - -// Describes when the clients can retry a failed request. Clients could ignore -// the recommendation here or retry when this information is missing from error -// responses. -// -// It's always recommended that clients should use exponential backoff when -// retrying. -// -// Clients should wait until `retry_delay` amount of time has passed since -// receiving the error response before retrying. If retrying requests also -// fail, clients should use an exponential backoff scheme to gradually increase -// the delay between retries based on `retry_delay`, until either a maximum -// number of retries have been reached or a maximum retry delay cap has been -// reached. -message RetryInfo { - // Clients should wait at least this long between retrying the same request. - google.protobuf.Duration retry_delay = 1; -} - -// Describes additional debugging info. -message DebugInfo { - // The stack trace entries indicating where the error occurred. - repeated string stack_entries = 1; - - // Additional debugging information provided by the server. - string detail = 2; -} - -// Describes how a quota check failed. -// -// For example if a daily limit was exceeded for the calling project, -// a service could respond with a QuotaFailure detail containing the project -// id and the description of the quota limit that was exceeded. If the -// calling project hasn't enabled the service in the developer console, then -// a service could respond with the project id and set `service_disabled` -// to true. -// -// Also see RetryInfo and Help types for other details about handling a -// quota failure. -message QuotaFailure { - // A message type used to describe a single quota violation. For example, a - // daily quota or a custom quota that was exceeded. - message Violation { - // The subject on which the quota check failed. - // For example, "clientip:" or "project:". - string subject = 1; - - // A description of how the quota check failed. Clients can use this - // description to find more about the quota configuration in the service's - // public documentation, or find the relevant quota limit to adjust through - // developer console. - // - // For example: "Service disabled" or "Daily Limit for read operations - // exceeded". - string description = 2; - - // The API Service from which the `QuotaFailure.Violation` orginates. In - // some cases, Quota issues originate from an API Service other than the one - // that was called. In other words, a dependency of the called API Service - // could be the cause of the `QuotaFailure`, and this field would have the - // dependency API service name. - // - // For example, if the called API is Kubernetes Engine API - // (container.googleapis.com), and a quota violation occurs in the - // Kubernetes Engine API itself, this field would be - // "container.googleapis.com". On the other hand, if the quota violation - // occurs when the Kubernetes Engine API creates VMs in the Compute Engine - // API (compute.googleapis.com), this field would be - // "compute.googleapis.com". - string api_service = 3; - - // The metric of the violated quota. A quota metric is a named counter to - // measure usage, such as API requests or CPUs. When an activity occurs in a - // service, such as Virtual Machine allocation, one or more quota metrics - // may be affected. - // - // For example, "compute.googleapis.com/cpus_per_vm_family", - // "storage.googleapis.com/internet_egress_bandwidth". - string quota_metric = 4; - - // The id of the violated quota. Also know as "limit name", this is the - // unique identifier of a quota in the context of an API service. - // - // For example, "CPUS-PER-VM-FAMILY-per-project-region". - string quota_id = 5; - - // The dimensions of the violated quota. Every non-global quota is enforced - // on a set of dimensions. While quota metric defines what to count, the - // dimensions specify for what aspects the counter should be increased. - // - // For example, the quota "CPUs per region per VM family" enforces a limit - // on the metric "compute.googleapis.com/cpus_per_vm_family" on dimensions - // "region" and "vm_family". And if the violation occurred in region - // "us-central1" and for VM family "n1", the quota_dimensions would be, - // - // { - // "region": "us-central1", - // "vm_family": "n1", - // } - // - // When a quota is enforced globally, the quota_dimensions would always be - // empty. - map quota_dimensions = 6; - - // The enforced quota value at the time of the `QuotaFailure`. - // - // For example, if the enforced quota value at the time of the - // `QuotaFailure` on the number of CPUs is "10", then the value of this - // field would reflect this quantity. - int64 quota_value = 7; - - // The new quota value being rolled out at the time of the violation. At the - // completion of the rollout, this value will be enforced in place of - // quota_value. If no rollout is in progress at the time of the violation, - // this field is not set. - // - // For example, if at the time of the violation a rollout is in progress - // changing the number of CPUs quota from 10 to 20, 20 would be the value of - // this field. - optional int64 future_quota_value = 8; - } - - // Describes all quota violations. - repeated Violation violations = 1; -} - -// Describes what preconditions have failed. -// -// For example, if an RPC failed because it required the Terms of Service to be -// acknowledged, it could list the terms of service violation in the -// PreconditionFailure message. -message PreconditionFailure { - // A message type used to describe a single precondition failure. - message Violation { - // The type of PreconditionFailure. We recommend using a service-specific - // enum type to define the supported precondition violation subjects. For - // example, "TOS" for "Terms of Service violation". - string type = 1; - - // The subject, relative to the type, that failed. - // For example, "google.com/cloud" relative to the "TOS" type would indicate - // which terms of service is being referenced. - string subject = 2; - - // A description of how the precondition failed. Developers can use this - // description to understand how to fix the failure. - // - // For example: "Terms of service not accepted". - string description = 3; - } - - // Describes all precondition violations. - repeated Violation violations = 1; -} - -// Describes violations in a client request. This error type focuses on the -// syntactic aspects of the request. -message BadRequest { - // A message type used to describe a single bad request field. - message FieldViolation { - // A path that leads to a field in the request body. The value will be a - // sequence of dot-separated identifiers that identify a protocol buffer - // field. - // - // Consider the following: - // - // message CreateContactRequest { - // message EmailAddress { - // enum Type { - // TYPE_UNSPECIFIED = 0; - // HOME = 1; - // WORK = 2; - // } - // - // optional string email = 1; - // repeated EmailType type = 2; - // } - // - // string full_name = 1; - // repeated EmailAddress email_addresses = 2; - // } - // - // In this example, in proto `field` could take one of the following values: - // - // * `full_name` for a violation in the `full_name` value - // * `email_addresses[1].email` for a violation in the `email` field of the - // first `email_addresses` message - // * `email_addresses[3].type[2]` for a violation in the second `type` - // value in the third `email_addresses` message. - // - // In JSON, the same values are represented as: - // - // * `fullName` for a violation in the `fullName` value - // * `emailAddresses[1].email` for a violation in the `email` field of the - // first `emailAddresses` message - // * `emailAddresses[3].type[2]` for a violation in the second `type` - // value in the third `emailAddresses` message. - string field = 1; - - // A description of why the request element is bad. - string description = 2; - - // The reason of the field-level error. This is a constant value that - // identifies the proximate cause of the field-level error. It should - // uniquely identify the type of the FieldViolation within the scope of the - // google.rpc.ErrorInfo.domain. This should be at most 63 - // characters and match a regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, - // which represents UPPER_SNAKE_CASE. - string reason = 3; - - // Provides a localized error message for field-level errors that is safe to - // return to the API consumer. - LocalizedMessage localized_message = 4; - } - - // Describes all violations in a client request. - repeated FieldViolation field_violations = 1; -} - -// Contains metadata about the request that clients can attach when filing a bug -// or providing other forms of feedback. -message RequestInfo { - // An opaque string that should only be interpreted by the service generating - // it. For example, it can be used to identify requests in the service's logs. - string request_id = 1; - - // Any data that was used to serve this request. For example, an encrypted - // stack trace that can be sent back to the service provider for debugging. - string serving_data = 2; -} - -// Describes the resource that is being accessed. -message ResourceInfo { - // A name for the type of resource being accessed, e.g. "sql table", - // "cloud storage bucket", "file", "Google calendar"; or the type URL - // of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic". - string resource_type = 1; - - // The name of the resource being accessed. For example, a shared calendar - // name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current - // error is - // [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED]. - string resource_name = 2; - - // The owner of the resource (optional). - // For example, "user:" or "project:". - string owner = 3; - - // Describes what error is encountered when accessing this resource. - // For example, updating a cloud project may require the `writer` permission - // on the developer console project. - string description = 4; -} - -// Provides links to documentation or for performing an out of band action. -// -// For example, if a quota check failed with an error indicating the calling -// project hasn't enabled the accessed service, this can contain a URL pointing -// directly to the right place in the developer console to flip the bit. -message Help { - // Describes a URL link. - message Link { - // Describes what the link offers. - string description = 1; - - // The URL of the link. - string url = 2; - } - - // URL(s) pointing to additional information on handling the current error. - repeated Link links = 1; -} - -// Provides a localized error message that is safe to return to the user -// which can be attached to an RPC error. -message LocalizedMessage { - // The locale used following the specification defined at - // https://www.rfc-editor.org/rfc/bcp/bcp47.txt. - // Examples are: "en-US", "fr-CH", "es-MX" - string locale = 1; - - // The localized error message in the above locale. - string message = 2; -} diff --git a/third_party/google/rpc/status.proto b/third_party/google/rpc/status.proto deleted file mode 100644 index dc14c943..00000000 --- a/third_party/google/rpc/status.proto +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.rpc; - -import "google/protobuf/any.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; -option java_multiple_files = true; -option java_outer_classname = "StatusProto"; -option java_package = "com.google.rpc"; -option objc_class_prefix = "RPC"; - -// The `Status` type defines a logical error model that is suitable for -// different programming environments, including REST APIs and RPC APIs. It is -// used by [gRPC](https://github.com/grpc). Each `Status` message contains -// three pieces of data: error code, error message, and error details. -// -// You can find out more about this error model and how to work with it in the -// [API Design Guide](https://cloud.google.com/apis/design/errors). -message Status { - // The status code, which should be an enum value of - // [google.rpc.Code][google.rpc.Code]. - int32 code = 1; - - // A developer-facing error message, which should be in English. Any - // user-facing error message should be localized and sent in the - // [google.rpc.Status.details][google.rpc.Status.details] field, or localized - // by the client. - string message = 2; - - // A list of messages that carry the error details. There is a common set of - // message types for APIs to use. - repeated google.protobuf.Any details = 3; -} diff --git a/third_party/google/type/calendar_period.proto b/third_party/google/type/calendar_period.proto deleted file mode 100644 index 57d360ad..00000000 --- a/third_party/google/type/calendar_period.proto +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option go_package = "google.golang.org/genproto/googleapis/type/calendarperiod;calendarperiod"; -option java_multiple_files = true; -option java_outer_classname = "CalendarPeriodProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// A `CalendarPeriod` represents the abstract concept of a time period that has -// a canonical start. Grammatically, "the start of the current -// `CalendarPeriod`." All calendar times begin at midnight UTC. -enum CalendarPeriod { - // Undefined period, raises an error. - CALENDAR_PERIOD_UNSPECIFIED = 0; - - // A day. - DAY = 1; - - // A week. Weeks begin on Monday, following - // [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date). - WEEK = 2; - - // A fortnight. The first calendar fortnight of the year begins at the start - // of week 1 according to - // [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date). - FORTNIGHT = 3; - - // A month. - MONTH = 4; - - // A quarter. Quarters start on dates 1-Jan, 1-Apr, 1-Jul, and 1-Oct of each - // year. - QUARTER = 5; - - // A half-year. Half-years start on dates 1-Jan and 1-Jul. - HALF = 6; - - // A year. - YEAR = 7; -} diff --git a/third_party/google/type/color.proto b/third_party/google/type/color.proto deleted file mode 100644 index 26508db9..00000000 --- a/third_party/google/type/color.proto +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -import "google/protobuf/wrappers.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/color;color"; -option java_multiple_files = true; -option java_outer_classname = "ColorProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a color in the RGBA color space. This representation is designed -// for simplicity of conversion to/from color representations in various -// languages over compactness. For example, the fields of this representation -// can be trivially provided to the constructor of `java.awt.Color` in Java; it -// can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` -// method in iOS; and, with just a little work, it can be easily formatted into -// a CSS `rgba()` string in JavaScript. -// -// This reference page doesn't carry information about the absolute color -// space -// that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, -// DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color -// space. -// -// When color equality needs to be decided, implementations, unless -// documented otherwise, treat two colors as equal if all their red, -// green, blue, and alpha values each differ by at most 1e-5. -// -// Example (Java): -// -// import com.google.type.Color; -// -// // ... -// public static java.awt.Color fromProto(Color protocolor) { -// float alpha = protocolor.hasAlpha() -// ? protocolor.getAlpha().getValue() -// : 1.0; -// -// return new java.awt.Color( -// protocolor.getRed(), -// protocolor.getGreen(), -// protocolor.getBlue(), -// alpha); -// } -// -// public static Color toProto(java.awt.Color color) { -// float red = (float) color.getRed(); -// float green = (float) color.getGreen(); -// float blue = (float) color.getBlue(); -// float denominator = 255.0; -// Color.Builder resultBuilder = -// Color -// .newBuilder() -// .setRed(red / denominator) -// .setGreen(green / denominator) -// .setBlue(blue / denominator); -// int alpha = color.getAlpha(); -// if (alpha != 255) { -// result.setAlpha( -// FloatValue -// .newBuilder() -// .setValue(((float) alpha) / denominator) -// .build()); -// } -// return resultBuilder.build(); -// } -// // ... -// -// Example (iOS / Obj-C): -// -// // ... -// static UIColor* fromProto(Color* protocolor) { -// float red = [protocolor red]; -// float green = [protocolor green]; -// float blue = [protocolor blue]; -// FloatValue* alpha_wrapper = [protocolor alpha]; -// float alpha = 1.0; -// if (alpha_wrapper != nil) { -// alpha = [alpha_wrapper value]; -// } -// return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; -// } -// -// static Color* toProto(UIColor* color) { -// CGFloat red, green, blue, alpha; -// if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { -// return nil; -// } -// Color* result = [[Color alloc] init]; -// [result setRed:red]; -// [result setGreen:green]; -// [result setBlue:blue]; -// if (alpha <= 0.9999) { -// [result setAlpha:floatWrapperWithValue(alpha)]; -// } -// [result autorelease]; -// return result; -// } -// // ... -// -// Example (JavaScript): -// -// // ... -// -// var protoToCssColor = function(rgb_color) { -// var redFrac = rgb_color.red || 0.0; -// var greenFrac = rgb_color.green || 0.0; -// var blueFrac = rgb_color.blue || 0.0; -// var red = Math.floor(redFrac * 255); -// var green = Math.floor(greenFrac * 255); -// var blue = Math.floor(blueFrac * 255); -// -// if (!('alpha' in rgb_color)) { -// return rgbToCssColor(red, green, blue); -// } -// -// var alphaFrac = rgb_color.alpha.value || 0.0; -// var rgbParams = [red, green, blue].join(','); -// return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); -// }; -// -// var rgbToCssColor = function(red, green, blue) { -// var rgbNumber = new Number((red << 16) | (green << 8) | blue); -// var hexString = rgbNumber.toString(16); -// var missingZeros = 6 - hexString.length; -// var resultBuilder = ['#']; -// for (var i = 0; i < missingZeros; i++) { -// resultBuilder.push('0'); -// } -// resultBuilder.push(hexString); -// return resultBuilder.join(''); -// }; -// -// // ... -message Color { - // The amount of red in the color as a value in the interval [0, 1]. - float red = 1; - - // The amount of green in the color as a value in the interval [0, 1]. - float green = 2; - - // The amount of blue in the color as a value in the interval [0, 1]. - float blue = 3; - - // The fraction of this color that should be applied to the pixel. That is, - // the final pixel color is defined by the equation: - // - // `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` - // - // This means that a value of 1.0 corresponds to a solid color, whereas - // a value of 0.0 corresponds to a completely transparent color. This - // uses a wrapper message rather than a simple float scalar so that it is - // possible to distinguish between a default value and the value being unset. - // If omitted, this color object is rendered as a solid color - // (as if the alpha value had been explicitly given a value of 1.0). - google.protobuf.FloatValue alpha = 4; -} diff --git a/third_party/google/type/date.proto b/third_party/google/type/date.proto deleted file mode 100644 index 6f63436e..00000000 --- a/third_party/google/type/date.proto +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/date;date"; -option java_multiple_files = true; -option java_outer_classname = "DateProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a whole or partial calendar date, such as a birthday. The time of -// day and time zone are either specified elsewhere or are insignificant. The -// date is relative to the Gregorian Calendar. This can represent one of the -// following: -// -// * A full date, with non-zero year, month, and day values -// * A month and day value, with a zero year, such as an anniversary -// * A year on its own, with zero month and day values -// * A year and month value, with a zero day, such as a credit card expiration -// date -// -// Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and -// `google.protobuf.Timestamp`. -message Date { - // Year of the date. Must be from 1 to 9999, or 0 to specify a date without - // a year. - int32 year = 1; - - // Month of a year. Must be from 1 to 12, or 0 to specify a year without a - // month and day. - int32 month = 2; - - // Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 - // to specify a year by itself or a year and month where the day isn't - // significant. - int32 day = 3; -} diff --git a/third_party/google/type/datetime.proto b/third_party/google/type/datetime.proto deleted file mode 100644 index 9f0d62b0..00000000 --- a/third_party/google/type/datetime.proto +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -import "google/protobuf/duration.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/datetime;datetime"; -option java_multiple_files = true; -option java_outer_classname = "DateTimeProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents civil time (or occasionally physical time). -// -// This type can represent a civil time in one of a few possible ways: -// -// * When utc_offset is set and time_zone is unset: a civil time on a calendar -// day with a particular offset from UTC. -// * When time_zone is set and utc_offset is unset: a civil time on a calendar -// day in a particular time zone. -// * When neither time_zone nor utc_offset is set: a civil time on a calendar -// day in local time. -// -// The date is relative to the Proleptic Gregorian Calendar. -// -// If year is 0, the DateTime is considered not to have a specific year. month -// and day must have valid, non-zero values. -// -// This type may also be used to represent a physical time if all the date and -// time fields are set and either case of the `time_offset` oneof is set. -// Consider using `Timestamp` message for physical time instead. If your use -// case also would like to store the user's timezone, that can be done in -// another field. -// -// This type is more flexible than some applications may want. Make sure to -// document and validate your application's limitations. -message DateTime { - // Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a - // datetime without a year. - int32 year = 1; - - // Required. Month of year. Must be from 1 to 12. - int32 month = 2; - - // Required. Day of month. Must be from 1 to 31 and valid for the year and - // month. - int32 day = 3; - - // Required. Hours of day in 24 hour format. Should be from 0 to 23. An API - // may choose to allow the value "24:00:00" for scenarios like business - // closing time. - int32 hours = 4; - - // Required. Minutes of hour of day. Must be from 0 to 59. - int32 minutes = 5; - - // Required. Seconds of minutes of the time. Must normally be from 0 to 59. An - // API may allow the value 60 if it allows leap-seconds. - int32 seconds = 6; - - // Required. Fractions of seconds in nanoseconds. Must be from 0 to - // 999,999,999. - int32 nanos = 7; - - // Optional. Specifies either the UTC offset or the time zone of the DateTime. - // Choose carefully between them, considering that time zone data may change - // in the future (for example, a country modifies their DST start/end dates, - // and future DateTimes in the affected range had already been stored). - // If omitted, the DateTime is considered to be in local time. - oneof time_offset { - // UTC offset. Must be whole seconds, between -18 hours and +18 hours. - // For example, a UTC offset of -4:00 would be represented as - // { seconds: -14400 }. - google.protobuf.Duration utc_offset = 8; - - // Time zone. - TimeZone time_zone = 9; - } -} - -// Represents a time zone from the -// [IANA Time Zone Database](https://www.iana.org/time-zones). -message TimeZone { - // IANA Time Zone Database time zone, e.g. "America/New_York". - string id = 1; - - // Optional. IANA Time Zone Database version number, e.g. "2019a". - string version = 2; -} diff --git a/third_party/google/type/dayofweek.proto b/third_party/google/type/dayofweek.proto deleted file mode 100644 index 5684bec3..00000000 --- a/third_party/google/type/dayofweek.proto +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option go_package = "google.golang.org/genproto/googleapis/type/dayofweek;dayofweek"; -option java_multiple_files = true; -option java_outer_classname = "DayOfWeekProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a day of the week. -enum DayOfWeek { - // The day of the week is unspecified. - DAY_OF_WEEK_UNSPECIFIED = 0; - - // Monday - MONDAY = 1; - - // Tuesday - TUESDAY = 2; - - // Wednesday - WEDNESDAY = 3; - - // Thursday - THURSDAY = 4; - - // Friday - FRIDAY = 5; - - // Saturday - SATURDAY = 6; - - // Sunday - SUNDAY = 7; -} diff --git a/third_party/google/type/decimal.proto b/third_party/google/type/decimal.proto deleted file mode 100644 index 77a06db0..00000000 --- a/third_party/google/type/decimal.proto +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/decimal;decimal"; -option java_multiple_files = true; -option java_outer_classname = "DecimalProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// A representation of a decimal value, such as 2.5. Clients may convert values -// into language-native decimal formats, such as Java's [BigDecimal][] or -// Python's [decimal.Decimal][]. -// -// [BigDecimal]: -// https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html -// [decimal.Decimal]: https://docs.python.org/3/library/decimal.html -message Decimal { - // The decimal value, as a string. - // - // The string representation consists of an optional sign, `+` (`U+002B`) - // or `-` (`U+002D`), followed by a sequence of zero or more decimal digits - // ("the integer"), optionally followed by a fraction, optionally followed - // by an exponent. - // - // The fraction consists of a decimal point followed by zero or more decimal - // digits. The string must contain at least one digit in either the integer - // or the fraction. The number formed by the sign, the integer and the - // fraction is referred to as the significand. - // - // The exponent consists of the character `e` (`U+0065`) or `E` (`U+0045`) - // followed by one or more decimal digits. - // - // Services **should** normalize decimal values before storing them by: - // - // - Removing an explicitly-provided `+` sign (`+2.5` -> `2.5`). - // - Replacing a zero-length integer value with `0` (`.5` -> `0.5`). - // - Coercing the exponent character to lower-case (`2.5E8` -> `2.5e8`). - // - Removing an explicitly-provided zero exponent (`2.5e0` -> `2.5`). - // - // Services **may** perform additional normalization based on its own needs - // and the internal decimal implementation selected, such as shifting the - // decimal point and exponent value together (example: `2.5e-1` <-> `0.25`). - // Additionally, services **may** preserve trailing zeroes in the fraction - // to indicate increased precision, but are not required to do so. - // - // Note that only the `.` character is supported to divide the integer - // and the fraction; `,` **should not** be supported regardless of locale. - // Additionally, thousand separators **should not** be supported. If a - // service does support them, values **must** be normalized. - // - // The ENBF grammar is: - // - // DecimalString = - // [Sign] Significand [Exponent]; - // - // Sign = '+' | '-'; - // - // Significand = - // Digits ['.'] [Digits] | [Digits] '.' Digits; - // - // Exponent = ('e' | 'E') [Sign] Digits; - // - // Digits = { '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' }; - // - // Services **should** clearly document the range of supported values, the - // maximum supported precision (total number of digits), and, if applicable, - // the scale (number of digits after the decimal point), as well as how it - // behaves when receiving out-of-bounds values. - // - // Services **may** choose to accept values passed as input even when the - // value has a higher precision or scale than the service supports, and - // **should** round the value to fit the supported scale. Alternatively, the - // service **may** error with `400 Bad Request` (`INVALID_ARGUMENT` in gRPC) - // if precision would be lost. - // - // Services **should** error with `400 Bad Request` (`INVALID_ARGUMENT` in - // gRPC) if the service receives a value outside of the supported range. - string value = 1; -} diff --git a/third_party/google/type/expr.proto b/third_party/google/type/expr.proto deleted file mode 100644 index 97c4f7da..00000000 --- a/third_party/google/type/expr.proto +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option go_package = "google.golang.org/genproto/googleapis/type/expr;expr"; -option java_multiple_files = true; -option java_outer_classname = "ExprProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a textual expression in the Common Expression Language (CEL) -// syntax. CEL is a C-like expression language. The syntax and semantics of CEL -// are documented at https://github.com/google/cel-spec. -// -// Example (Comparison): -// -// title: "Summary size limit" -// description: "Determines if a summary is less than 100 chars" -// expression: "document.summary.size() < 100" -// -// Example (Equality): -// -// title: "Requestor is owner" -// description: "Determines if requestor is the document owner" -// expression: "document.owner == request.auth.claims.email" -// -// Example (Logic): -// -// title: "Public documents" -// description: "Determine whether the document should be publicly visible" -// expression: "document.type != 'private' && document.type != 'internal'" -// -// Example (Data Manipulation): -// -// title: "Notification string" -// description: "Create a notification string with a timestamp." -// expression: "'New message received at ' + string(document.create_time)" -// -// The exact variables and functions that may be referenced within an expression -// are determined by the service that evaluates it. See the service -// documentation for additional information. -message Expr { - // Textual representation of an expression in Common Expression Language - // syntax. - string expression = 1; - - // Optional. Title for the expression, i.e. a short string describing - // its purpose. This can be used e.g. in UIs which allow to enter the - // expression. - string title = 2; - - // Optional. Description of the expression. This is a longer text which - // describes the expression, e.g. when hovered over it in a UI. - string description = 3; - - // Optional. String indicating the location of the expression for error - // reporting, e.g. a file name and a position in the file. - string location = 4; -} diff --git a/third_party/google/type/fraction.proto b/third_party/google/type/fraction.proto deleted file mode 100644 index b3b0d0f3..00000000 --- a/third_party/google/type/fraction.proto +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option go_package = "google.golang.org/genproto/googleapis/type/fraction;fraction"; -option java_multiple_files = true; -option java_outer_classname = "FractionProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a fraction in terms of a numerator divided by a denominator. -message Fraction { - // The numerator in the fraction, e.g. 2 in 2/3. - int64 numerator = 1; - - // The value by which the numerator is divided, e.g. 3 in 2/3. Must be - // positive. - int64 denominator = 2; -} diff --git a/third_party/google/type/interval.proto b/third_party/google/type/interval.proto deleted file mode 100644 index d9b24271..00000000 --- a/third_party/google/type/interval.proto +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/interval;interval"; -option java_multiple_files = true; -option java_outer_classname = "IntervalProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a time interval, encoded as a Timestamp start (inclusive) and a -// Timestamp end (exclusive). -// -// The start must be less than or equal to the end. -// When the start equals the end, the interval is empty (matches no time). -// When both start and end are unspecified, the interval matches any time. -message Interval { - // Optional. Inclusive start of the interval. - // - // If specified, a Timestamp matching this interval will have to be the same - // or after the start. - google.protobuf.Timestamp start_time = 1; - - // Optional. Exclusive end of the interval. - // - // If specified, a Timestamp matching this interval will have to be before the - // end. - google.protobuf.Timestamp end_time = 2; -} diff --git a/third_party/google/type/latlng.proto b/third_party/google/type/latlng.proto deleted file mode 100644 index 6714f65b..00000000 --- a/third_party/google/type/latlng.proto +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/latlng;latlng"; -option java_multiple_files = true; -option java_outer_classname = "LatLngProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// An object that represents a latitude/longitude pair. This is expressed as a -// pair of doubles to represent degrees latitude and degrees longitude. Unless -// specified otherwise, this must conform to the -// WGS84 -// standard. Values must be within normalized ranges. -message LatLng { - // The latitude in degrees. It must be in the range [-90.0, +90.0]. - double latitude = 1; - - // The longitude in degrees. It must be in the range [-180.0, +180.0]. - double longitude = 2; -} diff --git a/third_party/google/type/localized_text.proto b/third_party/google/type/localized_text.proto deleted file mode 100644 index 3971e811..00000000 --- a/third_party/google/type/localized_text.proto +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/localized_text;localized_text"; -option java_multiple_files = true; -option java_outer_classname = "LocalizedTextProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Localized variant of a text in a particular language. -message LocalizedText { - // Localized string in the language corresponding to `language_code' below. - string text = 1; - - // The text's BCP-47 language code, such as "en-US" or "sr-Latn". - // - // For more information, see - // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. - string language_code = 2; -} diff --git a/third_party/google/type/money.proto b/third_party/google/type/money.proto deleted file mode 100644 index f67aa51f..00000000 --- a/third_party/google/type/money.proto +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/money;money"; -option java_multiple_files = true; -option java_outer_classname = "MoneyProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents an amount of money with its currency type. -message Money { - // The three-letter currency code defined in ISO 4217. - string currency_code = 1; - - // The whole units of the amount. - // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar. - int64 units = 2; - - // Number of nano (10^-9) units of the amount. - // The value must be between -999,999,999 and +999,999,999 inclusive. - // If `units` is positive, `nanos` must be positive or zero. - // If `units` is zero, `nanos` can be positive, zero, or negative. - // If `units` is negative, `nanos` must be negative or zero. - // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. - int32 nanos = 3; -} diff --git a/third_party/google/type/month.proto b/third_party/google/type/month.proto deleted file mode 100644 index 169282ae..00000000 --- a/third_party/google/type/month.proto +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option go_package = "google.golang.org/genproto/googleapis/type/month;month"; -option java_multiple_files = true; -option java_outer_classname = "MonthProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a month in the Gregorian calendar. -enum Month { - // The unspecified month. - MONTH_UNSPECIFIED = 0; - - // The month of January. - JANUARY = 1; - - // The month of February. - FEBRUARY = 2; - - // The month of March. - MARCH = 3; - - // The month of April. - APRIL = 4; - - // The month of May. - MAY = 5; - - // The month of June. - JUNE = 6; - - // The month of July. - JULY = 7; - - // The month of August. - AUGUST = 8; - - // The month of September. - SEPTEMBER = 9; - - // The month of October. - OCTOBER = 10; - - // The month of November. - NOVEMBER = 11; - - // The month of December. - DECEMBER = 12; -} diff --git a/third_party/google/type/phone_number.proto b/third_party/google/type/phone_number.proto deleted file mode 100644 index 23dbc6bd..00000000 --- a/third_party/google/type/phone_number.proto +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/phone_number;phone_number"; -option java_multiple_files = true; -option java_outer_classname = "PhoneNumberProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// An object representing a phone number, suitable as an API wire format. -// -// This representation: -// -// - should not be used for locale-specific formatting of a phone number, such -// as "+1 (650) 253-0000 ext. 123" -// -// - is not designed for efficient storage -// - may not be suitable for dialing - specialized libraries (see references) -// should be used to parse the number for that purpose -// -// To do something meaningful with this number, such as format it for various -// use-cases, convert it to an `i18n.phonenumbers.PhoneNumber` object first. -// -// For instance, in Java this would be: -// -// com.google.type.PhoneNumber wireProto = -// com.google.type.PhoneNumber.newBuilder().build(); -// com.google.i18n.phonenumbers.Phonenumber.PhoneNumber phoneNumber = -// PhoneNumberUtil.getInstance().parse(wireProto.getE164Number(), "ZZ"); -// if (!wireProto.getExtension().isEmpty()) { -// phoneNumber.setExtension(wireProto.getExtension()); -// } -// -// Reference(s): -// - https://github.com/google/libphonenumber -message PhoneNumber { - // An object representing a short code, which is a phone number that is - // typically much shorter than regular phone numbers and can be used to - // address messages in MMS and SMS systems, as well as for abbreviated dialing - // (e.g. "Text 611 to see how many minutes you have remaining on your plan."). - // - // Short codes are restricted to a region and are not internationally - // dialable, which means the same short code can exist in different regions, - // with different usage and pricing, even if those regions share the same - // country calling code (e.g. US and CA). - message ShortCode { - // Required. The BCP-47 region code of the location where calls to this - // short code can be made, such as "US" and "BB". - // - // Reference(s): - // - http://www.unicode.org/reports/tr35/#unicode_region_subtag - string region_code = 1; - - // Required. The short code digits, without a leading plus ('+') or country - // calling code, e.g. "611". - string number = 2; - } - - // Required. Either a regular number, or a short code. New fields may be - // added to the oneof below in the future, so clients should ignore phone - // numbers for which none of the fields they coded against are set. - oneof kind { - // The phone number, represented as a leading plus sign ('+'), followed by a - // phone number that uses a relaxed ITU E.164 format consisting of the - // country calling code (1 to 3 digits) and the subscriber number, with no - // additional spaces or formatting, e.g.: - // - correct: "+15552220123" - // - incorrect: "+1 (555) 222-01234 x123". - // - // The ITU E.164 format limits the latter to 12 digits, but in practice not - // all countries respect that, so we relax that restriction here. - // National-only numbers are not allowed. - // - // References: - // - https://www.itu.int/rec/T-REC-E.164-201011-I - // - https://en.wikipedia.org/wiki/E.164. - // - https://en.wikipedia.org/wiki/List_of_country_calling_codes - string e164_number = 1; - - // A short code. - // - // Reference(s): - // - https://en.wikipedia.org/wiki/Short_code - ShortCode short_code = 2; - } - - // The phone number's extension. The extension is not standardized in ITU - // recommendations, except for being defined as a series of numbers with a - // maximum length of 40 digits. Other than digits, some other dialing - // characters such as ',' (indicating a wait) or '#' may be stored here. - // - // Note that no regions currently use extensions with short codes, so this - // field is normally only set in conjunction with an E.164 number. It is held - // separately from the E.164 number to allow for short code extensions in the - // future. - string extension = 3; -} diff --git a/third_party/google/type/postal_address.proto b/third_party/google/type/postal_address.proto deleted file mode 100644 index e58d5c35..00000000 --- a/third_party/google/type/postal_address.proto +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/postaladdress;postaladdress"; -option java_multiple_files = true; -option java_outer_classname = "PostalAddressProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a postal address, e.g. for postal delivery or payments addresses. -// Given a postal address, a postal service can deliver items to a premise, P.O. -// Box or similar. -// It is not intended to model geographical locations (roads, towns, -// mountains). -// -// In typical usage an address would be created via user input or from importing -// existing data, depending on the type of process. -// -// Advice on address input / editing: -// - Use an i18n-ready address widget such as -// https://github.com/google/libaddressinput) -// - Users should not be presented with UI elements for input or editing of -// fields outside countries where that field is used. -// -// For more guidance on how to use this schema, please see: -// https://support.google.com/business/answer/6397478 -message PostalAddress { - // The schema revision of the `PostalAddress`. This must be set to 0, which is - // the latest revision. - // - // All new revisions **must** be backward compatible with old revisions. - int32 revision = 1; - - // Required. CLDR region code of the country/region of the address. This - // is never inferred and it is up to the user to ensure the value is - // correct. See http://cldr.unicode.org/ and - // http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html - // for details. Example: "CH" for Switzerland. - string region_code = 2; - - // Optional. BCP-47 language code of the contents of this address (if - // known). This is often the UI language of the input form or is expected - // to match one of the languages used in the address' country/region, or their - // transliterated equivalents. - // This can affect formatting in certain countries, but is not critical - // to the correctness of the data and will never affect any validation or - // other non-formatting related operations. - // - // If this value is not known, it should be omitted (rather than specifying a - // possibly incorrect default). - // - // Examples: "zh-Hant", "ja", "ja-Latn", "en". - string language_code = 3; - - // Optional. Postal code of the address. Not all countries use or require - // postal codes to be present, but where they are used, they may trigger - // additional validation with other parts of the address (e.g. state/zip - // validation in the U.S.A.). - string postal_code = 4; - - // Optional. Additional, country-specific, sorting code. This is not used - // in most regions. Where it is used, the value is either a string like - // "CEDEX", optionally followed by a number (e.g. "CEDEX 7"), or just a number - // alone, representing the "sector code" (Jamaica), "delivery area indicator" - // (Malawi) or "post office indicator" (e.g. Côte d'Ivoire). - string sorting_code = 5; - - // Optional. Highest administrative subdivision which is used for postal - // addresses of a country or region. - // For example, this can be a state, a province, an oblast, or a prefecture. - // Specifically, for Spain this is the province and not the autonomous - // community (e.g. "Barcelona" and not "Catalonia"). - // Many countries don't use an administrative area in postal addresses. E.g. - // in Switzerland this should be left unpopulated. - string administrative_area = 6; - - // Optional. Generally refers to the city/town portion of the address. - // Examples: US city, IT comune, UK post town. - // In regions of the world where localities are not well defined or do not fit - // into this structure well, leave locality empty and use address_lines. - string locality = 7; - - // Optional. Sublocality of the address. - // For example, this can be neighborhoods, boroughs, districts. - string sublocality = 8; - - // Unstructured address lines describing the lower levels of an address. - // - // Because values in address_lines do not have type information and may - // sometimes contain multiple values in a single field (e.g. - // "Austin, TX"), it is important that the line order is clear. The order of - // address lines should be "envelope order" for the country/region of the - // address. In places where this can vary (e.g. Japan), address_language is - // used to make it explicit (e.g. "ja" for large-to-small ordering and - // "ja-Latn" or "en" for small-to-large). This way, the most specific line of - // an address can be selected based on the language. - // - // The minimum permitted structural representation of an address consists - // of a region_code with all remaining information placed in the - // address_lines. It would be possible to format such an address very - // approximately without geocoding, but no semantic reasoning could be - // made about any of the address components until it was at least - // partially resolved. - // - // Creating an address only containing a region_code and address_lines, and - // then geocoding is the recommended way to handle completely unstructured - // addresses (as opposed to guessing which parts of the address should be - // localities or administrative areas). - repeated string address_lines = 9; - - // Optional. The recipient at the address. - // This field may, under certain circumstances, contain multiline information. - // For example, it might contain "care of" information. - repeated string recipients = 10; - - // Optional. The name of the organization at the address. - string organization = 11; -} diff --git a/third_party/google/type/quaternion.proto b/third_party/google/type/quaternion.proto deleted file mode 100644 index 18c7b742..00000000 --- a/third_party/google/type/quaternion.proto +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/quaternion;quaternion"; -option java_multiple_files = true; -option java_outer_classname = "QuaternionProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// A quaternion is defined as the quotient of two directed lines in a -// three-dimensional space or equivalently as the quotient of two Euclidean -// vectors (https://en.wikipedia.org/wiki/Quaternion). -// -// Quaternions are often used in calculations involving three-dimensional -// rotations (https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation), -// as they provide greater mathematical robustness by avoiding the gimbal lock -// problems that can be encountered when using Euler angles -// (https://en.wikipedia.org/wiki/Gimbal_lock). -// -// Quaternions are generally represented in this form: -// -// w + xi + yj + zk -// -// where x, y, z, and w are real numbers, and i, j, and k are three imaginary -// numbers. -// -// Our naming choice `(x, y, z, w)` comes from the desire to avoid confusion for -// those interested in the geometric properties of the quaternion in the 3D -// Cartesian space. Other texts often use alternative names or subscripts, such -// as `(a, b, c, d)`, `(1, i, j, k)`, or `(0, 1, 2, 3)`, which are perhaps -// better suited for mathematical interpretations. -// -// To avoid any confusion, as well as to maintain compatibility with a large -// number of software libraries, the quaternions represented using the protocol -// buffer below *must* follow the Hamilton convention, which defines `ij = k` -// (i.e. a right-handed algebra), and therefore: -// -// i^2 = j^2 = k^2 = ijk = −1 -// ij = −ji = k -// jk = −kj = i -// ki = −ik = j -// -// Please DO NOT use this to represent quaternions that follow the JPL -// convention, or any of the other quaternion flavors out there. -// -// Definitions: -// -// - Quaternion norm (or magnitude): `sqrt(x^2 + y^2 + z^2 + w^2)`. -// - Unit (or normalized) quaternion: a quaternion whose norm is 1. -// - Pure quaternion: a quaternion whose scalar component (`w`) is 0. -// - Rotation quaternion: a unit quaternion used to represent rotation. -// - Orientation quaternion: a unit quaternion used to represent orientation. -// -// A quaternion can be normalized by dividing it by its norm. The resulting -// quaternion maintains the same direction, but has a norm of 1, i.e. it moves -// on the unit sphere. This is generally necessary for rotation and orientation -// quaternions, to avoid rounding errors: -// https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions -// -// Note that `(x, y, z, w)` and `(-x, -y, -z, -w)` represent the same rotation, -// but normalization would be even more useful, e.g. for comparison purposes, if -// it would produce a unique representation. It is thus recommended that `w` be -// kept positive, which can be achieved by changing all the signs when `w` is -// negative. -// -message Quaternion { - // The x component. - double x = 1; - - // The y component. - double y = 2; - - // The z component. - double z = 3; - - // The scalar component. - double w = 4; -} diff --git a/third_party/google/type/timeofday.proto b/third_party/google/type/timeofday.proto deleted file mode 100644 index cd6a8057..00000000 --- a/third_party/google/type/timeofday.proto +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2025 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -syntax = "proto3"; - -package google.type; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/type/timeofday;timeofday"; -option java_multiple_files = true; -option java_outer_classname = "TimeOfDayProto"; -option java_package = "com.google.type"; -option objc_class_prefix = "GTP"; - -// Represents a time of day. The date and time zone are either not significant -// or are specified elsewhere. An API may choose to allow leap seconds. Related -// types are [google.type.Date][google.type.Date] and -// `google.protobuf.Timestamp`. -message TimeOfDay { - // Hours of day in 24 hour format. Should be from 0 to 23. An API may choose - // to allow the value "24:00:00" for scenarios like business closing time. - int32 hours = 1; - - // Minutes of hour of day. Must be from 0 to 59. - int32 minutes = 2; - - // Seconds of minutes of the time. Must normally be from 0 to 59. An API may - // allow the value 60 if it allows leap-seconds. - int32 seconds = 3; - - // Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999. - int32 nanos = 4; -} diff --git a/third_party/middleware/circuitbreaker/v1/circuitbreaker.proto b/third_party/middleware/circuitbreaker/v1/circuitbreaker.proto deleted file mode 100644 index 4800520a..00000000 --- a/third_party/middleware/circuitbreaker/v1/circuitbreaker.proto +++ /dev/null @@ -1,49 +0,0 @@ -syntax = "proto3"; - -package middleware.circuitbreaker.v1; - -import "config/v1/gateway.proto"; -import "google/protobuf/duration.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/circuitbreaker/v1;circuitbreakerv1"; -option java_multiple_files = true; -option java_outer_classname = "CircuitBreakerProto"; -option java_package = "com.github.origadmin.runtime.middleware.circuitbreaker.v1"; -option objc_class_prefix = "OMC"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\CircuitBreaker\\V1"; - -// CircuitBreaker middleware config. -message CircuitBreaker { - oneof trigger { - SuccessRatio success_ratio = 1; - int64 ratio = 2; - } - oneof action { - ResponseData response_data = 3; - BackupService backup_service = 4; - } - repeated config.v1.Condition assert_condtions = 5; -} - -message Header { - string key = 1; - repeated string value = 2; -} - -message ResponseData { - int32 status_code = 1; - repeated Header header = 2; - bytes body = 3; -} - -message BackupService { - config.v1.Endpoint endpoint = 1; -} - -message SuccessRatio { - double success = 1; - int32 request = 2; - int32 bucket = 3; - int64 window = 4; -} diff --git a/third_party/middleware/jwt/v1/jwt.proto b/third_party/middleware/jwt/v1/jwt.proto deleted file mode 100644 index b7085d65..00000000 --- a/third_party/middleware/jwt/v1/jwt.proto +++ /dev/null @@ -1,30 +0,0 @@ -syntax = "proto3"; - -package middleware.jwt.v1; - -import "gnostic/openapi/v3/annotations.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "security/jwt/v1/config.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/jwt/v1;jwtv1"; -option java_multiple_files = true; -option java_outer_classname = "JWTProto"; -option java_package = "com.github.origadmin.runtime.middleware.jwt.v1"; -option objc_class_prefix = "OMM"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\JWT\\V1"; - -// JSON Web Token -message JWT { - bool enabled = 1 [json_name = 'enabled']; - string subject = 2 [json_name = 'subject']; - string claim_type = 3 [json_name = 'claim_type']; - map token_header = 4 [json_name = 'token_header']; - // The token used security.jwt.v1. - security.jwt.v1.Config config = 100 [ - json_name = "config", - (gnostic.openapi.v3.property) = {description: "The configuration used to create the token."} - ]; -} diff --git a/third_party/middleware/metrics/v1/metrics.proto b/third_party/middleware/metrics/v1/metrics.proto deleted file mode 100644 index a8b0c487..00000000 --- a/third_party/middleware/metrics/v1/metrics.proto +++ /dev/null @@ -1,59 +0,0 @@ -syntax = "proto3"; - -package middleware.metrics.v1; - -import "google/protobuf/timestamp.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/metrics/v1;metricsv1"; -option java_multiple_files = true; -option java_outer_classname = "CircuitBreakerProto"; -option java_package = "com.github.origadmin.runtime.middleware.metrics.v1"; -option objc_class_prefix = "OMM"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\Metric\\V1"; - -message UserMetric { - // Timestamp: indicates the time of indicator data - int64 timestamp = 1; - // Indicator name - string name = 2; - // Indicator value - double value = 3; - // Indicator label for classification or filtering - map labels = 4; - // Indicator unit - string unit = 5; - // Type of indicator (e.g. counter, timer, histogram, etc.) - enum MetricType { - METRIC_TYPE_UNSPECIFIED = 0; - METRIC_TYPE_COUNTER = 1; - METRIC_TYPE_GAUGE = 2; - METRIC_TYPE_HISTOGRAM = 3; - METRIC_TYPE_SUMMARY = 4; - } - MetricType type = 6; - // Description of indicators - string description = 7; - // Indicator context information - string context = 8; - // Additional information for metrics that can be used to store arbitrary metadata - map metadata = 9; -} - -// Metrics -message Metrics { - bool enabled = 1 [json_name = "enabled"]; - // System-generated timestamp for the metrics report - // int64 report_timestamp = 1 [json_name = "report_timestamp"]; - // System-generated unique identifier for the metrics report - // string report_id = 2 [json_name = "report_id"]; - // System-generated status code indicating the success or failure of the metrics collection - // int32 status_code = 3 [json_name = "status_code"]; - // System-generated message providing additional context about the metrics collection - // string status_message = 4 [json_name = "status_message"]; - - // Add a list of supported metrics for enabling or disabling specific metrics - repeated string supported_metrics = 5 [json_name = "supported_metrics"]; - // Repeated field for user-defined metrics - repeated UserMetric user_metrics = 6 [json_name = "user_metrics"]; -} diff --git a/third_party/middleware/ratelimit/v1/ratelimiter.proto b/third_party/middleware/ratelimit/v1/ratelimiter.proto deleted file mode 100644 index 82a69f92..00000000 --- a/third_party/middleware/ratelimit/v1/ratelimiter.proto +++ /dev/null @@ -1,55 +0,0 @@ -syntax = "proto3"; - -package middleware.ratelimit.v1; - -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/ratelimit/v1;ratelimitv1"; -option java_multiple_files = true; -option java_outer_classname = "RateLimitProto"; -option java_package = "com.github.origadmin.runtime.middleware.ratelimit.v1"; -option objc_class_prefix = "OMM"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\RateLimit\\V1"; - -// Rate limiter -message RateLimiter { - message Redis { - string addr = 1 [json_name = "addr"]; - string username = 2 [json_name = "username"]; - string password = 3 [json_name = "password"]; - int32 db = 4 [json_name = "db"]; - } - message Memory { - int64 expiration = 1 [json_name = "expiration"]; - int64 cleanup_interval = 2 [json_name = "cleanup_interval"]; - } - bool enabled = 1 [json_name = "enabled"]; - // rate limiter name, supported: bbr, memory, redis. - string name = 2 [ - json_name = "name", - (validate.rules).string = { - in: [ - "bbr", - "memory", - "redis" - ] - } - ]; - // The number of seconds in a rate limit window - int32 period = 3 [json_name = "period"]; - - // The number of requests allowed in a window of time - int32 x_ratelimit_limit = 5 [json_name = "x_ratelimit_limit"]; - // The number of requests that can still be made in the current window of time - int32 x_ratelimit_remaining = 6 [json_name = "x_ratelimit_remaining"]; - // The number of seconds until the current rate limit window completely resets - int32 x_ratelimit_reset = 7 [json_name = "x_ratelimit_reset"]; - // When rate limited, the number of seconds to wait before another request will be accepted - int32 retry_after = 8 [json_name = "retry_after"]; - - Memory memory = 101 [json_name = "memory"]; - Redis redis = 102 [json_name = "redis"]; -} diff --git a/third_party/middleware/selector/v1/selector.proto b/third_party/middleware/selector/v1/selector.proto deleted file mode 100644 index 8893a88b..00000000 --- a/third_party/middleware/selector/v1/selector.proto +++ /dev/null @@ -1,24 +0,0 @@ -syntax = "proto3"; - -package middleware.selector.v1; - -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/selector/v1;selectorv1"; -option java_multiple_files = true; -option java_outer_classname = "SelectorProto"; -option java_package = "com.github.origadmin.runtime.middleware.selector.v1"; -option objc_class_prefix = "OMM"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\Selector\\V1"; - -// Selector -message Selector { - bool enabled = 1 [json_name = "enabled"]; - repeated string names = 2 [json_name = "names"]; - repeated string paths = 3 [json_name = "paths"]; - string regex = 4 [json_name = "regex"]; - repeated string prefixes = 5 [json_name = "prefixes"]; -} diff --git a/third_party/middleware/v1/circuitbreaker/circuitbreaker.proto b/third_party/middleware/v1/circuitbreaker/circuitbreaker.proto deleted file mode 100644 index 35420eaa..00000000 --- a/third_party/middleware/v1/circuitbreaker/circuitbreaker.proto +++ /dev/null @@ -1,48 +0,0 @@ -syntax = "proto3"; - -package middleware.v1.circuitbreaker; - -import "config/v1/gateway.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/circuitbreaker;circuitbreakerv1"; -option java_multiple_files = true; -option java_outer_classname = "CircuitBreakerProto"; -option java_package = "com.github.origadmin.api.runtime.middleware.v1.circuitbreaker"; -option objc_class_prefix = "OMC"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\CircuitBreaker\\V1"; - -// CircuitBreaker middleware config. -message CircuitBreaker { - oneof trigger { - SuccessRatio success_ratio = 1; - int64 ratio = 2; - } - oneof action { - ResponseData response_data = 3; - BackupService backup_service = 4; - } - repeated config.v1.Condition assert_condtions = 5; -} - -message Header { - string key = 1; - repeated string value = 2; -} - -message ResponseData { - int32 status_code = 1; - repeated Header header = 2; - bytes body = 3; -} - -message BackupService { - config.v1.Endpoint endpoint = 1; -} - -message SuccessRatio { - double success = 1; - int32 request = 2; - int32 bucket = 3; - int64 window = 4; -} diff --git a/third_party/middleware/v1/jwt/jwt.proto b/third_party/middleware/v1/jwt/jwt.proto deleted file mode 100644 index 1888bfb0..00000000 --- a/third_party/middleware/v1/jwt/jwt.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; - -package middleware.v1.jwt; - -import "gnostic/openapi/v3/annotations.proto"; -import "security/jwt/v1/config.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/jwt;jwtv1"; -option java_multiple_files = true; -option java_outer_classname = "JWTProto"; -option java_package = "com.github.origadmin.api.runtime.middleware.v1.jwt"; -option objc_class_prefix = "OMM"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\JWT\\V1"; - -// JSON Web Token -message JWT { - bool enabled = 1 [json_name = 'enabled']; - string subject = 2 [json_name = 'subject']; - string claim_type = 3 [ - json_name = 'claim_type', - (validate.rules).string = { - in: [ - "map", - "registered" - ] - }, - (gnostic.openapi.v3.property) = {description: "The type of the claim used to extract the token."} - ]; - map token_header = 4 [json_name = 'token_header']; - // The token used security.jwt.v1. - security.jwt.v1.Config config = 100 [ - json_name = "config", - (gnostic.openapi.v3.property) = {description: "The configuration used to create the token."} - ]; -} diff --git a/third_party/middleware/v1/metrics/metrics.proto b/third_party/middleware/v1/metrics/metrics.proto deleted file mode 100644 index 22eb54ed..00000000 --- a/third_party/middleware/v1/metrics/metrics.proto +++ /dev/null @@ -1,57 +0,0 @@ -syntax = "proto3"; - -package middleware.v1.metrics; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/metrics;metricsv1"; -option java_multiple_files = true; -option java_outer_classname = "CircuitBreakerProto"; -option java_package = "com.github.origadmin.api.runtime.middleware.v1.metrics"; -option objc_class_prefix = "OMM"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\Metric\\V1"; - -message UserMetric { - // Timestamp: indicates the time of indicator data - int64 timestamp = 1; - // Indicator name - string name = 2; - // Indicator value - double value = 3; - // Indicator label for classification or filtering - map labels = 4; - // Indicator unit - string unit = 5; - // Type of indicator (e.g. counter, timer, histogram, etc.) - enum MetricType { - METRIC_TYPE_UNSPECIFIED = 0; - METRIC_TYPE_COUNTER = 1; - METRIC_TYPE_GAUGE = 2; - METRIC_TYPE_HISTOGRAM = 3; - METRIC_TYPE_SUMMARY = 4; - } - MetricType type = 6; - // Description of indicators - string description = 7; - // Indicator context information - string context = 8; - // Additional information for metrics that can be used to store arbitrary metadata - map metadata = 9; -} - -// Metrics -message Metrics { - bool enabled = 1 [json_name = "enabled"]; - // System-generated timestamp for the metrics report - // int64 report_timestamp = 1 [json_name = "report_timestamp"]; - // System-generated unique identifier for the metrics report - // string report_id = 2 [json_name = "report_id"]; - // System-generated status code indicating the success or failure of the metrics collection - // int32 status_code = 3 [json_name = "status_code"]; - // System-generated message providing additional context about the metrics collection - // string status_message = 4 [json_name = "status_message"]; - - // Add a list of supported metrics for enabling or disabling specific metrics - repeated string supported_metrics = 5 [json_name = "supported_metrics"]; - // Repeated field for user-defined metrics - repeated UserMetric user_metrics = 6 [json_name = "user_metrics"]; -} diff --git a/third_party/middleware/v1/middleware.proto b/third_party/middleware/v1/middleware.proto deleted file mode 100644 index 1833607f..00000000 --- a/third_party/middleware/v1/middleware.proto +++ /dev/null @@ -1,91 +0,0 @@ -syntax = "proto3"; - -package middleware.v1; - -import "middleware/v1/jwt/jwt.proto"; -import "middleware/v1/metrics/metrics.proto"; -import "middleware/v1/ratelimit/ratelimiter.proto"; -import "middleware/v1/selector/selector.proto"; -import "middleware/v1/validator/validator.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1;middlewarev1"; -option java_multiple_files = true; -option java_outer_classname = "MiddlewareProto"; -option java_package = "com.github.origadmin.api.runtime.middleware.v1"; -option objc_class_prefix = "OMX"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\V1"; - -// UserMetric: used to report user-defined metrics -// Example: -// request_count := UserMetric { -// timestamp: 1633072800, -// name: "request_count", -// value: 12345, -// labels: { -// "service": "api_service", -// "endpoint": "/users" -// }, -// unit: "requests", -// type: COUNTER, -// description: "Number of requests to the API service", -// context: "Production environment", -// metadata: { -// "region": "us-west-1", -// "instance_id": "i-0123456789abcdef0" -// } -// }; -// -// response_time := UserMetric { -// timestamp: 1633072800, -// name: "response_time", -// value: 0.25, -// labels: { -// "service": "api_service", -// "endpoint": "/users" -// }, -// unit: "seconds", -// type: GAUGE, -// description: "Average response time of the API service", -// context: "Production environment", -// metadata: { -// "region": "us-west-1", -// "instance_id": "i-0123456789abcdef0" -// } -// }; - -enum MiddlewareName { - MIDDLEWARE_NAME_UNSPECIFIED = 0; - MIDDLEWARE_NAME_LOGGING = 1; - MIDDLEWARE_NAME_RECOVERY = 2; - MIDDLEWARE_NAME_TRACING = 3; - MIDDLEWARE_NAME_CIRCUIT_BREAKER = 4; - MIDDLEWARE_NAME_METADATA = 5; - MIDDLEWARE_NAME_JWT = 6; - MIDDLEWARE_NAME_RATE_LIMITER = 7; - MIDDLEWARE_NAME_METRICS = 8; - MIDDLEWARE_NAME_VALIDATOR = 9; - MIDDLEWARE_NAME_SELECTOR = 10; - MIDDLEWARE_NAME_CUSTOMIZE = 11; -} - -// Middleware middleware is used to middlewareure middleware for entry -message Middleware { - // Metadata - message Metadata { - bool enabled = 1 [json_name = "enabled"]; - // Metadata prefix - string prefix = 2 [json_name = "prefix"]; - // Metadata data - map data = 3 [json_name = "data"]; - } - - repeated string enabled_middlewares = 1 [json_name = "enabled_middlewares"]; - - Metadata metadata = 100 [json_name = "metadata"]; - middleware.v1.ratelimit.RateLimiter rate_limiter = 101 [json_name = "rate_limiter"]; - middleware.v1.metrics.Metrics metrics = 102 [json_name = "metrics"]; - middleware.v1.validator.Validator validator = 103 [json_name = "validator"]; - middleware.v1.jwt.JWT jwt = 104 [json_name = "jwt"]; - middleware.v1.selector.Selector selector = 105 [json_name = "selector"]; -} diff --git a/third_party/middleware/v1/ratelimit/ratelimiter.proto b/third_party/middleware/v1/ratelimit/ratelimiter.proto deleted file mode 100644 index 5438502e..00000000 --- a/third_party/middleware/v1/ratelimit/ratelimiter.proto +++ /dev/null @@ -1,53 +0,0 @@ -syntax = "proto3"; - -package middleware.v1.ratelimit; - -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/ratelimit;ratelimitv1"; -option java_multiple_files = true; -option java_outer_classname = "RateLimitProto"; -option java_package = "com.github.origadmin.api.runtime.middleware.v1.ratelimit"; -option objc_class_prefix = "OMM"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\RateLimit\\V1"; - -// Rate limiter -message RateLimiter { - message Redis { - string addr = 1 [json_name = "addr"]; - string username = 2 [json_name = "username"]; - string password = 3 [json_name = "password"]; - int32 db = 4 [json_name = "db"]; - } - message Memory { - int64 expiration = 1 [json_name = "expiration"]; - int64 cleanup_interval = 2 [json_name = "cleanup_interval"]; - } - bool enabled = 1 [json_name = "enabled"]; - // rate limiter name, supported: bbr, memory, redis. - string name = 2 [ - json_name = "name", - (validate.rules).string = { - in: [ - "bbr", - "memory", - "redis" - ] - } - ]; - // The number of seconds in a rate limit window - int32 period = 3 [json_name = "period"]; - - // The number of requests allowed in a window of time - int32 x_ratelimit_limit = 5 [json_name = "x_ratelimit_limit"]; - // The number of requests that can still be made in the current window of time - int32 x_ratelimit_remaining = 6 [json_name = "x_ratelimit_remaining"]; - // The number of seconds until the current rate limit window completely resets - int32 x_ratelimit_reset = 7 [json_name = "x_ratelimit_reset"]; - // When rate limited, the number of seconds to wait before another request will be accepted - int32 retry_after = 8 [json_name = "retry_after"]; - - Memory memory = 101 [json_name = "memory"]; - Redis redis = 102 [json_name = "redis"]; -} diff --git a/third_party/middleware/v1/selector/selector.proto b/third_party/middleware/v1/selector/selector.proto deleted file mode 100644 index 7865e293..00000000 --- a/third_party/middleware/v1/selector/selector.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; - -package middleware.v1.selector; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/selector;selectorv1"; -option java_multiple_files = true; -option java_outer_classname = "SelectorProto"; -option java_package = "com.github.origadmin.api.runtime.middleware.v1.selector"; -option objc_class_prefix = "OMM"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\Selector\\V1"; - -// Selector -message Selector { - bool enabled = 1 [json_name = "enabled"]; - repeated string names = 2 [json_name = "names"]; - repeated string paths = 3 [json_name = "paths"]; - string regex = 4 [json_name = "regex"]; - repeated string prefixes = 5 [json_name = "prefixes"]; -} diff --git a/third_party/middleware/v1/validator/validator.proto b/third_party/middleware/v1/validator/validator.proto deleted file mode 100644 index 6dd79aa5..00000000 --- a/third_party/middleware/v1/validator/validator.proto +++ /dev/null @@ -1,25 +0,0 @@ -syntax = "proto3"; - -package middleware.v1.validator; - -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/v1/validator;validatorv1"; -option java_multiple_files = true; -option java_outer_classname = "ValidatorProto"; -option java_package = "com.github.origadmin.api.runtime.middleware.v1.validator"; -option objc_class_prefix = "OMV"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\Validator\\V1"; - -message Validator { - bool enabled = 1 [json_name = "enabled"]; - int32 version = 2 [ - json_name = "version", - (validate.rules).int32 = { - gt: 0 - lt: 3 - } - ]; - bool fail_fast = 3 [json_name = "fail_fast"]; -} diff --git a/third_party/middleware/validator/v1/validator.proto b/third_party/middleware/validator/v1/validator.proto deleted file mode 100644 index 49a5b726..00000000 --- a/third_party/middleware/validator/v1/validator.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; - -package middleware.validator.v1; - -import "google/protobuf/timestamp.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/middleware/validator/v1;validatorv1"; -option java_multiple_files = true; -option java_outer_classname = "ValidatorProto"; -option java_package = "com.github.origadmin.runtime.middleware.validator.v1"; -option objc_class_prefix = "OMV"; -option php_namespace = "OrigAdmin\\Runtime\\Middleware\\Validator\\V1"; - -message Validator { - bool enabled = 1 [json_name = "enabled"]; - int32 version = 2 [ - json_name = "version", - (validate.rules).int32 = { - gt: 0 - lt: 3 - } - ]; - bool fail_fast = 3 [json_name = "fail_fast"]; -} diff --git a/third_party/options/opts.proto b/third_party/options/opts.proto deleted file mode 100644 index 9b0bc53a..00000000 --- a/third_party/options/opts.proto +++ /dev/null @@ -1,45 +0,0 @@ -syntax = "proto2"; - -import "google/protobuf/descriptor.proto"; -package ent; -option go_package = "entgo.io/contrib/entproto/cmd/protoc-gen-ent/options/ent"; - -message Schema { - optional bool gen = 1; - optional string name = 2; -} - -extend google.protobuf.MessageOptions { - optional Schema schema = 150119; -} - -message Field { - optional bool optional = 1; - optional bool nillable = 2; - optional bool unique = 3; - optional bool sensitive = 4; - optional bool immutable = 5; - optional string comment = 6; - optional string struct_tag = 7; - optional string storage_key = 8; - map schema_type = 9; -} - -message Edge { - optional bool unique = 1; - optional string ref = 2; - optional bool required = 3; - optional string field = 4; - optional StorageKey storage_key = 5; - optional string struct_tag = 6; - - message StorageKey { - optional string table = 1; - repeated string columns = 2; - } -} - -extend google.protobuf.FieldOptions { - optional Field field = 150119; - optional Edge edge = 150120; -} \ No newline at end of file diff --git a/third_party/pagination/v1/pagination.proto b/third_party/pagination/v1/pagination.proto deleted file mode 100644 index 9bbd9cfa..00000000 --- a/third_party/pagination/v1/pagination.proto +++ /dev/null @@ -1,102 +0,0 @@ -syntax = "proto3"; - -package pagination.v1; - -import "gnostic/openapi/v3/annotations.proto"; -import "google/protobuf/any.proto"; -import "google/protobuf/field_mask.proto"; - -option cc_enable_arenas = true; -option go_package = "github.com/origadmin/runtime/api/gen/go/pagination/v1;paginationv1"; -option java_multiple_files = true; -option java_outer_classname = "PaginationProto"; -option java_package = "com.github.origadmin.api.runtime.pagination.v1"; -option objc_class_prefix = "ORP"; -option php_namespace = "OrigAdmin\\Runtime\\Pagination\\V1"; - -// PageRequest common request -message PageRequest { - // current page number - optional int32 current = 1 [ - json_name = "current", - (gnostic.openapi.v3.property) = { - description: "current page number " - default: {number: 1} - } - ]; - // The number of lines per page - optional int32 page_size = 2 [ - json_name = "page_size", - (gnostic.openapi.v3.property) = { - description: "The number of lines per page" - default: {number: 15} - } - ]; - // The page_token is the query parameter for set the page token. - string page_token = 3 [ - json_name = "page_token", - (gnostic.openapi.v3.property) = {description: "paging token"} - ]; - // The only_count is the query parameter for set only to query the total number - bool only_count = 4 [ - json_name = "only_count", - (gnostic.openapi.v3.property) = {description: "query total only"} - ]; - // The no_paging is used to disable pagination. - optional bool no_paging = 5 [ - json_name = "no_paging", - (gnostic.openapi.v3.property) = {description: "whether not paging"} - ]; - // sort condition - string order_by = 6 [ - json_name = "order_by", - (gnostic.openapi.v3.property) = { - description: "sort condition, field name followed by 'asc' (ascending) or 'desc' (descending)" - example: {yaml: "id:asc"} - } - ]; - // Field mask - google.protobuf.FieldMask field_mask = 7 [ - json_name = "field_mask", - (gnostic.openapi.v3.property) = { - description: "It is used to Update the request message, which is used to perform a partial update to the resource. This mask is related to the resource, not the request message." - example: {yaml: "id,name,age"} - } - ]; -} - -// PageResponse general result -message PageResponse { - // The total number of items in the list. - int32 total_size = 1 [ - json_name = "total_size", - (gnostic.openapi.v3.property) = {description: "total number"} - ]; - // The paging data - repeated google.protobuf.Any data = 2 [ - json_name = "data", - (gnostic.openapi.v3.property) = {description: "data"} - ]; - // The current page number. - optional int32 current = 3 [ - json_name = "current", - (gnostic.openapi.v3.property) = {description: "current page number"} - ]; - // The maximum number of items to return. - optional int32 page_size = 4 [ - json_name = "page_size", - (gnostic.openapi.v3.property) = {description: "maximum number of items to return"} - ]; - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - string next_page_token = 5 [ - json_name = "next_page_token", - (gnostic.openapi.v3.property) = {description: "token to retrieve the next page of results, or empty if there are no more results in the list"} - ]; - // Additional information about this response. - // content to be added without destroying the current data format - map extra = 6 [ - json_name = "extra", - (gnostic.openapi.v3.property) = {description: "additional information about this response"} - ]; -} diff --git a/third_party/security/casbin/v1/policy.proto b/third_party/security/casbin/v1/policy.proto deleted file mode 100644 index 9c21d12b..00000000 --- a/third_party/security/casbin/v1/policy.proto +++ /dev/null @@ -1,41 +0,0 @@ -syntax = "proto3"; - -package security.casbin.v1; - -import "gnostic/openapi/v3/annotations.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "OrigAdmin.Runtime.Security.Casbin.V1"; -option go_package = "github.com/origadmin/runtime/api/gen/go/security/casbin/v1;casbinv1"; -option java_multiple_files = true; -option java_outer_classname = "CasbinProto"; -option java_package = "com.github.origadmin.api.runtime.security.casbin.v1"; -option objc_class_prefix = "ORSC"; -option php_namespace = "OrigAdmin\\Runtime\\Security\\Casbin\\V1"; - -message Policy { - string subject = 1 [ - json_name = "subject", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The subject of the policy."} - ]; - string object = 2 [ - json_name = "object", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The object of the policy."} - ]; - string action = 3 [ - json_name = "action", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The action of the policy."} - ]; - repeated string domain = 4 [ - json_name = "domain", - (gnostic.openapi.v3.property) = {description: "The domains associated with the policy."} - ]; - map extras = 6 [ - json_name = "extras", - (gnostic.openapi.v3.property) = {description: "The extra data associated with the policy."} - ]; -} diff --git a/third_party/security/jwt/v1/config.proto b/third_party/security/jwt/v1/config.proto deleted file mode 100644 index 768a363d..00000000 --- a/third_party/security/jwt/v1/config.proto +++ /dev/null @@ -1,77 +0,0 @@ -syntax = "proto3"; - -package security.jwt.v1; - -import "gnostic/openapi/v3/annotations.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "OrigAdmin.Runtime.Security.JWT.V1"; -option go_package = "github.com/origadmin/runtime/api/gen/go/security/jwt/v1;jwtv1"; -option java_multiple_files = true; -option java_outer_classname = "JWTProto"; -option java_package = "com.github.origadmin.api.runtime.security.jwt.v1"; -option objc_class_prefix = "ORST"; -option php_namespace = "OrigAdmin\\Runtime\\Security\\JWT\\V1"; - -// Config contains configuration parameters for creating and validating a JWT. -message Config { - string signing_method = 1 [ - json_name = "signing_method", - (validate.rules).string = { - min_len: 1 - max_len: 1024 - pattern: "^[A-Z0-9]+$" - }, - (gnostic.openapi.v3.property) = {description: "The signing method used for the token (e.g., HS256, RS256)."} - ]; - string key = 2 [ - json_name = "key", - (validate.rules).string = { - min_len: 1 - max_len: 1024 - }, - (gnostic.openapi.v3.property) = {description: "The key used for signing the token."} - ]; - string key2 = 3 [ - json_name = "key2", - (gnostic.openapi.v3.property) = {description: "The secondary key used for signing the token."} - ]; - int64 access_token_lifetime = 5 [ - json_name = "access_token_lifetime", - (validate.rules).int64 = { - gte: 1 - lte: 31536000 - }, - (gnostic.openapi.v3.property) = {description: "The lifetime of the token."} - ]; - int64 refresh_token_lifetime = 6 [ - json_name = "refresh_token_lifetime", - (validate.rules).int64 = { - gte: 1 - lte: 31536000 - }, - (gnostic.openapi.v3.property) = {description: "The lifetime of the refresh token."} - ]; - string issuer = 7 [ - json_name = "issuer", - (gnostic.openapi.v3.property) = {description: "The issuer of the token."} - ]; - repeated string audience = 8 [ - json_name = "audience", - (validate.rules).repeated = { - min_items: 1 - max_items: 1024, - unique: true, - }, - (gnostic.openapi.v3.property) = {description: "The audience for which the token is intended."} - ]; // Audience - string token_type = 9 [ - json_name = "token_type", - (validate.rules).string = { - min_len: 1 - max_len: 1024 - }, - (gnostic.openapi.v3.property) = {description: "The type of the token (e.g., Bearer)."} - ]; -} diff --git a/third_party/security/jwt/v1/token.proto b/third_party/security/jwt/v1/token.proto deleted file mode 100644 index 064c07f4..00000000 --- a/third_party/security/jwt/v1/token.proto +++ /dev/null @@ -1,42 +0,0 @@ -syntax = "proto3"; - -package security.jwt.v1; - -import "gnostic/openapi/v3/annotations.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "OrigAdmin.Runtime.Security.JWT.V1"; -option go_package = "github.com/origadmin/runtime/api/gen/go/security/jwt/v1;jwtv1"; -option java_multiple_files = true; -option java_outer_classname = "JWTProto"; -option java_package = "com.github.origadmin.api.runtime.security.jwt.v1"; -option objc_class_prefix = "ORST"; -option php_namespace = "OrigAdmin\\Runtime\\Security\\JWT\\V1"; - -// PWT is a web token that can be used to authenticate a user with protobuf services. -message Token { - string client_id = 1 [ - json_name = "client_id", - (gnostic.openapi.v3.property) = {description: "The client ID associated with the token."} - ]; - string user_id = 2 [ - json_name = "user_id", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The ID of the user associated with the token."} - ]; - string access_token = 10 [ - json_name = "access_token", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The web access token used for authentication."} - ]; - string refresh_token = 11 [ - json_name = "refresh_token", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The refresh token used to obtain a new access token."} - ]; - int64 expiration_time = 12 [ - json_name = "expiration_time", - (gnostic.openapi.v3.property) = {description: "The expiration time of the token."} - ]; -} diff --git a/third_party/security/v1/auth.proto b/third_party/security/v1/auth.proto deleted file mode 100644 index 0665732a..00000000 --- a/third_party/security/v1/auth.proto +++ /dev/null @@ -1,274 +0,0 @@ -syntax = "proto3"; - -package security.v1; - -import "gnostic/openapi/v3/annotations.proto"; -import "security/casbin/v1/policy.proto"; -import "security/jwt/v1/token.proto"; -import "validate/validate.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "OrigAdmin.Runtime.Security.V1"; -option go_package = "github.com/origadmin/runtime/api/gen/go/security/v1;securityv1"; -option java_multiple_files = true; -option java_outer_classname = "SecurityProto"; -option java_package = "com.github.origadmin.api.runtime.security.v1"; -option objc_class_prefix = "ORS"; -option php_namespace = "OrigAdmin\\Runtime\\Security\\V1"; - -message BasicAuth { - string username = 1 [ - json_name = "username", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The username for basic authentication."} - ]; - string password = 2 [ - json_name = "password", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The password for basic authentication."} - ]; -} - -message BearerAuth { - string token = 1 [ - json_name = "token", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The bearer token for authentication."} - ]; -} - -message DigestAuth { - string username = 1 [ - json_name = "username", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The username for digest authentication."} - ]; - string realm = 2 [ - json_name = "realm", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The authentication realm."} - ]; - string nonce = 3 [ - json_name = "nonce", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The server-specified nonce."} - ]; - string uri = 4 [ - json_name = "uri", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The URI being authenticated."} - ]; - string response = 5 [ - json_name = "response", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The client-generated response."} - ]; - string algorithm = 6 [ - json_name = "algorithm", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The algorithm used for the digest, e.g., MD5."} - ]; - string qop = 7 [ - json_name = "qop", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The quality of protection value, e.g., 'auth'."} - ]; - string nc = 8 [ - json_name = "nc", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The nonce count."} - ]; - string cnonce = 9 [ - json_name = "cnonce", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The client nonce."} - ]; -} - -message OAuth2Auth { - string access_token = 1 [ - json_name = "access_token", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The OAuth2 access token."} - ]; - string token_type = 2 [ - json_name = "token_type", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The type of the OAuth2 token, e.g., 'Bearer'."} - ]; - int32 expires_in = 3 [ - json_name = "expires_in", - (validate.rules).int32.gt = 0, - (gnostic.openapi.v3.property) = {description: "The lifetime of the OAuth2 token in seconds."} - ]; - string refresh_token = 4 [ - json_name = "refresh_token", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The OAuth2 refresh token."} - ]; - repeated string scope = 5 [ - json_name = "scope", - (validate.rules).repeated.min_items = 1, - (gnostic.openapi.v3.property) = {description: "The scopes of the OAuth2 token."} - ]; -} - -message ApiKeyAuth { - string api_key = 1 [ - json_name = "api_key", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The API key for authentication."} - ]; -} - -message JwtAuth { - string token = 1 [ - json_name = "token", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The JWT token for authentication."} - ]; - security.jwt.v1.Token jwt_token = 2 [ - json_name = "jwt_token", - (gnostic.openapi.v3.property) = {description: "The JWT token data for authentication."} - ]; - Claims claims = 20 [ - json_name = "claims", - (gnostic.openapi.v3.property) = {description: "The claims embedded in the token."} - ]; // Claims -} - -message AuthN { - enum Type { - TYPE_UNSPECIFIED = 0; // default value not specified - TYPE_BASIC = 1; // Basic authentication - TYPE_BEARER = 2; // Bearer authentication - TYPE_DIGEST = 3; // Digest authentication - TYPE_OAUTH2 = 4; // OAuth2 authentication - TYPE_API_KEY = 5; // API Key authentication - TYPE_JWT = 6; // JWT authentication - // you can add more types as needed - TYPE_USER_ADDITIONAL = 7; - } - Type type = 1 [ - json_name = "type", - (validate.rules).enum.defined_only = true, - (gnostic.openapi.v3.property) = {description: "The type of authentication, e.g., 'basic', 'bearer', 'digest', 'oauth2', 'api_key', 'jwt'."} - ]; - - optional BasicAuth basic = 10 [ - json_name = "basic", - (gnostic.openapi.v3.property) = {description: "The basic authentication details."} - ]; - optional BearerAuth bearer = 11 [ - json_name = "bearer", - (gnostic.openapi.v3.property) = {description: "The bearer authentication details."} - ]; - optional DigestAuth digest = 12 [ - json_name = "digest", - (gnostic.openapi.v3.property) = {description: "The digest authentication details."} - ]; - optional OAuth2Auth oauth2 = 13 [ - json_name = "oauth2", - (gnostic.openapi.v3.property) = {description: "The OAuth2 authentication details."} - ]; - optional ApiKeyAuth api_key = 14 [ - json_name = "api_key", - (gnostic.openapi.v3.property) = {description: "The API key authentication details."} - ]; - optional JwtAuth jwt = 15 [ - json_name = "jwt", - (gnostic.openapi.v3.property) = {description: "The JWT authentication details."} - ]; - optional bytes additional = 16 [ - json_name = "additional", - (gnostic.openapi.v3.property) = {description: "Additional properties for the authentication."} - ]; -} - -message CasbinAuth { - security.casbin.v1.Policy policy = 1 [ - json_name = "policy", - (gnostic.openapi.v3.property) = {description: "The Casbin policy associated with the authorization."} - ]; - Claims claims = 20 [ - json_name = "claims", - (gnostic.openapi.v3.property) = {description: "The claims embedded in the token."} - ]; // Claims -} - -message AuthZ { - bool root = 1 [ - json_name = "root", - (gnostic.openapi.v3.property) = {description: "Indicates if the user has root privileges."} - ]; - string id = 2 [ - json_name = "id", - (gnostic.openapi.v3.property) = {description: "The unique identifier of the user."} - ]; - string user_type = 3 [ - json_name = "user_type", - (validate.rules).string = { - in: [ - "admin", - "user", - "guest" - ] - }, - (gnostic.openapi.v3.property) = {description: "The type of user, either 'admin', 'user', or 'guest'."} - ]; - string username = 4 [ - json_name = "username", - (gnostic.openapi.v3.property) = {description: "The username of the user."} - ]; - repeated string roles = 5 [ - json_name = "roles", - (gnostic.openapi.v3.property) = {description: "The roles assigned to the user."} - ]; - int64 timestamp = 6 [ - json_name = "timestamp", - (gnostic.openapi.v3.property) = {description: "The timestamp of the authorization."} - ]; - CasbinAuth casbin = 7 [ - json_name = "casbin", - (gnostic.openapi.v3.property) = {description: "The Casbin authorization details."} - ]; -} - -message Claims { - string sub = 1 [ - json_name = "sub", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The subject of the token."} - ]; // Subject - string iss = 2 [ - json_name = "iss", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The issuer of the token."} - ]; // Issuer - repeated string aud = 3 [ - json_name = "aud", - (validate.rules).repeated.min_items = 1, - (gnostic.openapi.v3.property) = {description: "The audience for which the token is intended."} - ]; // Audience - int64 exp = 4 [ - json_name = "exp", - (gnostic.openapi.v3.property) = {description: "The expiration time of the token."} - ]; // Expiration Time - int64 nbf = 5 [ - json_name = "nbf", - (gnostic.openapi.v3.property) = {description: "The time before which the token must not be accepted."} - ]; // Not Before - int64 iat = 6 [ - json_name = "iat", - (gnostic.openapi.v3.property) = {description: "The time at which the token was issued."} - ]; // Issued At - string jti = 7 [ - json_name = "jti", - (validate.rules).string.min_len = 1, - (gnostic.openapi.v3.property) = {description: "The unique identifier for the token."} - ]; // JWT ID - map scopes = 8 [ - json_name = "scopes", - (gnostic.openapi.v3.property) = {description: "The scopes associated with the token."} - ]; // Scopes -} diff --git a/third_party/security/v1/error.proto b/third_party/security/v1/error.proto deleted file mode 100644 index be6e1934..00000000 --- a/third_party/security/v1/error.proto +++ /dev/null @@ -1,41 +0,0 @@ -syntax = "proto3"; - -package security.v1; - -import "errors/errors.proto"; - -option cc_enable_arenas = true; -option csharp_namespace = "OrigAdmin.Runtime.Security.V1"; -option go_package = "github.com/origadmin/runtime/api/gen/go/security/v1;securityv1"; -option java_multiple_files = true; -option java_outer_classname = "SecurityProto"; -option java_package = "com.github.origadmin.api.runtime.security.v1"; -option objc_class_prefix = "ORS"; -option php_namespace = "OrigAdmin\\Runtime\\Security\\V1"; - -enum SecurityErrorReason { - option (errors.default_code) = 500; - SECURITY_ERROR_REASON_UNSPECIFIED = 0; - // authentication starts at 1000, and ends at 1999 - SECURITY_ERROR_REASON_INVALID_AUTHENTICATION = 1000; - SECURITY_ERROR_REASON_INVALID_CLAIMS = 1001; - SECURITY_ERROR_REASON_INVALID_BEARER_TOKEN = 1002; - SECURITY_ERROR_REASON_INVALID_SUBJECT = 1003; - SECURITY_ERROR_REASON_INVALID_AUDIENCE = 1004; - SECURITY_ERROR_REASON_INVALID_ISSUER = 1005; - SECURITY_ERROR_REASON_INVALID_EXPIRATION = 1006; - SECURITY_ERROR_REASON_TOKEN_NOT_FOUND = 1007; - SECURITY_ERROR_REASON_BEARER_TOKEN_MISSING = 1010; - SECURITY_ERROR_REASON_TOKEN_EXPIRED = 1011; - SECURITY_ERROR_REASON_UNSUPPORTED_SIGNING_METHOD = 1012; - SECURITY_ERROR_REASON_MISSING_KEY_FUNC = 1014; - SECURITY_ERROR_REASON_SIGN_TOKEN_FAILED = 1015; - SECURITY_ERROR_REASON_GET_KEY_FAILED = 1016; - // authorization starts at 2000, and ends at 2999 - SECURITY_ERROR_REASON_INVALID_AUTHORIZATION = 2000; - - SECURITY_ERROR_REASON_NO_AT_HASH = 1050; - SECURITY_ERROR_REASON_INVALID_AT_HASH = 1051; - - SECURITY_ERROR_REASON_UNSECURITY_ENTICATED = 3000; -} diff --git a/third_party/validate/validate.proto b/third_party/validate/validate.proto deleted file mode 100644 index 5aa96539..00000000 --- a/third_party/validate/validate.proto +++ /dev/null @@ -1,862 +0,0 @@ -syntax = "proto2"; -package validate; - -option go_package = "github.com/envoyproxy/protoc-gen-validate/validate"; -option java_package = "io.envoyproxy.pgv.validate"; - -import "google/protobuf/descriptor.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; - -// Validation rules applied at the message level -extend google.protobuf.MessageOptions { - // Disabled nullifies any validation rules for this message, including any - // message fields associated with it that do support validation. - optional bool disabled = 1071; - // Ignore skips generation of validation methods for this message. - optional bool ignored = 1072; -} - -// Validation rules applied at the oneof level -extend google.protobuf.OneofOptions { - // Required ensures that exactly one the field options in a oneof is set; - // validation fails if no fields in the oneof are set. - optional bool required = 1071; -} - -// Validation rules applied at the field level -extend google.protobuf.FieldOptions { - // Rules specify the validations to be performed on this field. By default, - // no validation is performed against a field. - optional FieldRules rules = 1071; -} - -// FieldRules encapsulates the rules for each type of field. Depending on the -// field, the correct set should be used to ensure proper validations. -message FieldRules { - optional MessageRules message = 17; - oneof type { - // Scalar Field Types - FloatRules float = 1; - DoubleRules double = 2; - Int32Rules int32 = 3; - Int64Rules int64 = 4; - UInt32Rules uint32 = 5; - UInt64Rules uint64 = 6; - SInt32Rules sint32 = 7; - SInt64Rules sint64 = 8; - Fixed32Rules fixed32 = 9; - Fixed64Rules fixed64 = 10; - SFixed32Rules sfixed32 = 11; - SFixed64Rules sfixed64 = 12; - BoolRules bool = 13; - StringRules string = 14; - BytesRules bytes = 15; - - // Complex Field Types - EnumRules enum = 16; - RepeatedRules repeated = 18; - MapRules map = 19; - - // Well-Known Field Types - AnyRules any = 20; - DurationRules duration = 21; - TimestampRules timestamp = 22; - } -} - -// FloatRules describes the constraints applied to `float` values -message FloatRules { - // Const specifies that this field must be exactly the specified value - optional float const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional float lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional float lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional float gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional float gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated float in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated float not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// DoubleRules describes the constraints applied to `double` values -message DoubleRules { - // Const specifies that this field must be exactly the specified value - optional double const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional double lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional double lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional double gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional double gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated double in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated double not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Int32Rules describes the constraints applied to `int32` values -message Int32Rules { - // Const specifies that this field must be exactly the specified value - optional int32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional int32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional int32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional int32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional int32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated int32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated int32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Int64Rules describes the constraints applied to `int64` values -message Int64Rules { - // Const specifies that this field must be exactly the specified value - optional int64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional int64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional int64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional int64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional int64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated int64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated int64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// UInt32Rules describes the constraints applied to `uint32` values -message UInt32Rules { - // Const specifies that this field must be exactly the specified value - optional uint32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional uint32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional uint32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional uint32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional uint32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated uint32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated uint32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// UInt64Rules describes the constraints applied to `uint64` values -message UInt64Rules { - // Const specifies that this field must be exactly the specified value - optional uint64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional uint64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional uint64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional uint64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional uint64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated uint64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated uint64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SInt32Rules describes the constraints applied to `sint32` values -message SInt32Rules { - // Const specifies that this field must be exactly the specified value - optional sint32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sint32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sint32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sint32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sint32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sint32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sint32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SInt64Rules describes the constraints applied to `sint64` values -message SInt64Rules { - // Const specifies that this field must be exactly the specified value - optional sint64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sint64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sint64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sint64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sint64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sint64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sint64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Fixed32Rules describes the constraints applied to `fixed32` values -message Fixed32Rules { - // Const specifies that this field must be exactly the specified value - optional fixed32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional fixed32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional fixed32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional fixed32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional fixed32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated fixed32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated fixed32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// Fixed64Rules describes the constraints applied to `fixed64` values -message Fixed64Rules { - // Const specifies that this field must be exactly the specified value - optional fixed64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional fixed64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional fixed64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional fixed64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional fixed64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated fixed64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated fixed64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SFixed32Rules describes the constraints applied to `sfixed32` values -message SFixed32Rules { - // Const specifies that this field must be exactly the specified value - optional sfixed32 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sfixed32 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sfixed32 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sfixed32 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sfixed32 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sfixed32 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sfixed32 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// SFixed64Rules describes the constraints applied to `sfixed64` values -message SFixed64Rules { - // Const specifies that this field must be exactly the specified value - optional sfixed64 const = 1; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional sfixed64 lt = 2; - - // Lte specifies that this field must be less than or equal to the - // specified value, inclusive - optional sfixed64 lte = 3; - - // Gt specifies that this field must be greater than the specified value, - // exclusive. If the value of Gt is larger than a specified Lt or Lte, the - // range is reversed. - optional sfixed64 gt = 4; - - // Gte specifies that this field must be greater than or equal to the - // specified value, inclusive. If the value of Gte is larger than a - // specified Lt or Lte, the range is reversed. - optional sfixed64 gte = 5; - - // In specifies that this field must be equal to one of the specified - // values - repeated sfixed64 in = 6; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated sfixed64 not_in = 7; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 8; -} - -// BoolRules describes the constraints applied to `bool` values -message BoolRules { - // Const specifies that this field must be exactly the specified value - optional bool const = 1; -} - -// StringRules describe the constraints applied to `string` values -message StringRules { - // Const specifies that this field must be exactly the specified value - optional string const = 1; - - // Len specifies that this field must be the specified number of - // characters (Unicode code points). Note that the number of - // characters may differ from the number of bytes in the string. - optional uint64 len = 19; - - // MinLen specifies that this field must be the specified number of - // characters (Unicode code points) at a minimum. Note that the number of - // characters may differ from the number of bytes in the string. - optional uint64 min_len = 2; - - // MaxLen specifies that this field must be the specified number of - // characters (Unicode code points) at a maximum. Note that the number of - // characters may differ from the number of bytes in the string. - optional uint64 max_len = 3; - - // LenBytes specifies that this field must be the specified number of bytes - optional uint64 len_bytes = 20; - - // MinBytes specifies that this field must be the specified number of bytes - // at a minimum - optional uint64 min_bytes = 4; - - // MaxBytes specifies that this field must be the specified number of bytes - // at a maximum - optional uint64 max_bytes = 5; - - // Pattern specifies that this field must match against the specified - // regular expression (RE2 syntax). The included expression should elide - // any delimiters. - optional string pattern = 6; - - // Prefix specifies that this field must have the specified substring at - // the beginning of the string. - optional string prefix = 7; - - // Suffix specifies that this field must have the specified substring at - // the end of the string. - optional string suffix = 8; - - // Contains specifies that this field must have the specified substring - // anywhere in the string. - optional string contains = 9; - - // NotContains specifies that this field cannot have the specified substring - // anywhere in the string. - optional string not_contains = 23; - - // In specifies that this field must be equal to one of the specified - // values - repeated string in = 10; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated string not_in = 11; - - // WellKnown rules provide advanced constraints against common string - // patterns - oneof well_known { - // Email specifies that the field must be a valid email address as - // defined by RFC 5322 - bool email = 12; - - // Hostname specifies that the field must be a valid hostname as - // defined by RFC 1034. This constraint does not support - // internationalized domain names (IDNs). - bool hostname = 13; - - // Ip specifies that the field must be a valid IP (v4 or v6) address. - // Valid IPv6 addresses should not include surrounding square brackets. - bool ip = 14; - - // Ipv4 specifies that the field must be a valid IPv4 address. - bool ipv4 = 15; - - // Ipv6 specifies that the field must be a valid IPv6 address. Valid - // IPv6 addresses should not include surrounding square brackets. - bool ipv6 = 16; - - // Uri specifies that the field must be a valid, absolute URI as defined - // by RFC 3986 - bool uri = 17; - - // UriRef specifies that the field must be a valid URI as defined by RFC - // 3986 and may be relative or absolute. - bool uri_ref = 18; - - // Address specifies that the field must be either a valid hostname as - // defined by RFC 1034 (which does not support internationalized domain - // names or IDNs), or it can be a valid IP (v4 or v6). - bool address = 21; - - // Uuid specifies that the field must be a valid UUID as defined by - // RFC 4122 - bool uuid = 22; - - // WellKnownRegex specifies a common well known pattern defined as a regex. - KnownRegex well_known_regex = 24; - } - - // This applies to regexes HTTP_HEADER_NAME and HTTP_HEADER_VALUE to enable - // strict header validation. - // By default, this is true, and HTTP header validations are RFC-compliant. - // Setting to false will enable a looser validations that only disallows - // \r\n\0 characters, which can be used to bypass header matching rules. - optional bool strict = 25 [default = true]; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 26; -} - -// WellKnownRegex contain some well-known patterns. -enum KnownRegex { - UNKNOWN = 0; - - // HTTP header name as defined by RFC 7230. - HTTP_HEADER_NAME = 1; - - // HTTP header value as defined by RFC 7230. - HTTP_HEADER_VALUE = 2; -} - -// BytesRules describe the constraints applied to `bytes` values -message BytesRules { - // Const specifies that this field must be exactly the specified value - optional bytes const = 1; - - // Len specifies that this field must be the specified number of bytes - optional uint64 len = 13; - - // MinLen specifies that this field must be the specified number of bytes - // at a minimum - optional uint64 min_len = 2; - - // MaxLen specifies that this field must be the specified number of bytes - // at a maximum - optional uint64 max_len = 3; - - // Pattern specifies that this field must match against the specified - // regular expression (RE2 syntax). The included expression should elide - // any delimiters. - optional string pattern = 4; - - // Prefix specifies that this field must have the specified bytes at the - // beginning of the string. - optional bytes prefix = 5; - - // Suffix specifies that this field must have the specified bytes at the - // end of the string. - optional bytes suffix = 6; - - // Contains specifies that this field must have the specified bytes - // anywhere in the string. - optional bytes contains = 7; - - // In specifies that this field must be equal to one of the specified - // values - repeated bytes in = 8; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated bytes not_in = 9; - - // WellKnown rules provide advanced constraints against common byte - // patterns - oneof well_known { - // Ip specifies that the field must be a valid IP (v4 or v6) address in - // byte format - bool ip = 10; - - // Ipv4 specifies that the field must be a valid IPv4 address in byte - // format - bool ipv4 = 11; - - // Ipv6 specifies that the field must be a valid IPv6 address in byte - // format - bool ipv6 = 12; - } - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 14; -} - -// EnumRules describe the constraints applied to enum values -message EnumRules { - // Const specifies that this field must be exactly the specified value - optional int32 const = 1; - - // DefinedOnly specifies that this field must be only one of the defined - // values for this enum, failing on any undefined value. - optional bool defined_only = 2; - - // In specifies that this field must be equal to one of the specified - // values - repeated int32 in = 3; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated int32 not_in = 4; -} - -// MessageRules describe the constraints applied to embedded message values. -// For message-type fields, validation is performed recursively. -message MessageRules { - // Skip specifies that the validation rules of this field should not be - // evaluated - optional bool skip = 1; - - // Required specifies that this field must be set - optional bool required = 2; -} - -// RepeatedRules describe the constraints applied to `repeated` values -message RepeatedRules { - // MinItems specifies that this field must have the specified number of - // items at a minimum - optional uint64 min_items = 1; - - // MaxItems specifies that this field must have the specified number of - // items at a maximum - optional uint64 max_items = 2; - - // Unique specifies that all elements in this field must be unique. This - // constraint is only applicable to scalar and enum types (messages are not - // supported). - optional bool unique = 3; - - // Items specifies the constraints to be applied to each item in the field. - // Repeated message fields will still execute validation against each item - // unless skip is specified here. - optional FieldRules items = 4; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 5; -} - -// MapRules describe the constraints applied to `map` values -message MapRules { - // MinPairs specifies that this field must have the specified number of - // KVs at a minimum - optional uint64 min_pairs = 1; - - // MaxPairs specifies that this field must have the specified number of - // KVs at a maximum - optional uint64 max_pairs = 2; - - // NoSparse specifies values in this field cannot be unset. This only - // applies to map's with message value types. - optional bool no_sparse = 3; - - // Keys specifies the constraints to be applied to each key in the field. - optional FieldRules keys = 4; - - // Values specifies the constraints to be applied to the value of each key - // in the field. Message values will still have their validations evaluated - // unless skip is specified here. - optional FieldRules values = 5; - - // IgnoreEmpty specifies that the validation rules of this field should be - // evaluated only if the field is not empty - optional bool ignore_empty = 6; -} - -// AnyRules describe constraints applied exclusively to the -// `google.protobuf.Any` well-known type -message AnyRules { - // Required specifies that this field must be set - optional bool required = 1; - - // In specifies that this field's `type_url` must be equal to one of the - // specified values. - repeated string in = 2; - - // NotIn specifies that this field's `type_url` must not be equal to any of - // the specified values. - repeated string not_in = 3; -} - -// DurationRules describe the constraints applied exclusively to the -// `google.protobuf.Duration` well-known type -message DurationRules { - // Required specifies that this field must be set - optional bool required = 1; - - // Const specifies that this field must be exactly the specified value - optional google.protobuf.Duration const = 2; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional google.protobuf.Duration lt = 3; - - // Lt specifies that this field must be less than the specified value, - // inclusive - optional google.protobuf.Duration lte = 4; - - // Gt specifies that this field must be greater than the specified value, - // exclusive - optional google.protobuf.Duration gt = 5; - - // Gte specifies that this field must be greater than the specified value, - // inclusive - optional google.protobuf.Duration gte = 6; - - // In specifies that this field must be equal to one of the specified - // values - repeated google.protobuf.Duration in = 7; - - // NotIn specifies that this field cannot be equal to one of the specified - // values - repeated google.protobuf.Duration not_in = 8; -} - -// TimestampRules describe the constraints applied exclusively to the -// `google.protobuf.Timestamp` well-known type -message TimestampRules { - // Required specifies that this field must be set - optional bool required = 1; - - // Const specifies that this field must be exactly the specified value - optional google.protobuf.Timestamp const = 2; - - // Lt specifies that this field must be less than the specified value, - // exclusive - optional google.protobuf.Timestamp lt = 3; - - // Lte specifies that this field must be less than the specified value, - // inclusive - optional google.protobuf.Timestamp lte = 4; - - // Gt specifies that this field must be greater than the specified value, - // exclusive - optional google.protobuf.Timestamp gt = 5; - - // Gte specifies that this field must be greater than the specified value, - // inclusive - optional google.protobuf.Timestamp gte = 6; - - // LtNow specifies that this must be less than the current time. LtNow - // can only be used with the Within rule. - optional bool lt_now = 7; - - // GtNow specifies that this must be greater than the current time. GtNow - // can only be used with the Within rule. - optional bool gt_now = 8; - - // Within specifies that this field must be within this duration of the - // current time. This constraint can be used alone or with the LtNow and - // GtNow rules. - optional google.protobuf.Duration within = 9; -} From 399446688c0879a04ccad4711cd3a52d441d6a39 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 3 Dec 2025 04:16:34 +0800 Subject: [PATCH 064/158] refactor(conf): update proto package names from 'conf' to 'conf.pb' and adjust go_package paths --- internal/conf/pb/captcha.pb.go | 10 +++---- internal/conf/pb/captcha.pb.validate.go | 2 +- internal/conf/pb/captcha.proto | 4 +-- internal/conf/pb/conf.pb.go | 38 ++++++++++++------------- internal/conf/pb/conf.pb.validate.go | 2 +- internal/conf/pb/conf.proto | 8 +++--- internal/conf/pb/root.pb.go | 8 +++--- internal/conf/pb/root.pb.validate.go | 2 +- internal/conf/pb/root.proto | 4 +-- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/internal/conf/pb/captcha.pb.go b/internal/conf/pb/captcha.pb.go index fb6ffd8d..7a5ad4a7 100644 --- a/internal/conf/pb/captcha.pb.go +++ b/internal/conf/pb/captcha.pb.go @@ -4,7 +4,7 @@ // protoc v5.28.3 // source: conf/pb/captcha.proto -package conf +package confpb import ( v1 "github.com/origadmin/runtime/api/gen/go/config/data/v1" @@ -102,7 +102,7 @@ var File_conf_pb_captcha_proto protoreflect.FileDescriptor const file_conf_pb_captcha_proto_rawDesc = "" + "\n" + - "\x15conf/pb/captcha.proto\x12\x04conf\x1a\x19config/data/v1/data.proto\"\xab\x01\n" + + "\x15conf/pb/captcha.proto\x12\aconf.pb\x1a\x19config/data/v1/data.proto\"\xab\x01\n" + "\aCaptcha\x12\x16\n" + "\x06length\x18\x01 \x01(\x05R\x06length\x12\x14\n" + "\x05width\x18\x02 \x01(\x05R\x05width\x12\x16\n" + @@ -110,7 +110,7 @@ const file_conf_pb_captcha_proto_rawDesc = "" + "\n" + "cache_name\x18\x04 \x01(\tR\n" + "cache_name\x12:\n" + - "\x06caches\x18\x05 \x01(\v2\".runtime.api.config.data.v1.CachesR\x06cachesB0Z.origadmin/application/admin/internal/conf;confb\x06proto3" + "\x06caches\x18\x05 \x01(\v2\".runtime.api.config.data.v1.CachesR\x06cachesB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" var ( file_conf_pb_captcha_proto_rawDescOnce sync.Once @@ -126,11 +126,11 @@ func file_conf_pb_captcha_proto_rawDescGZIP() []byte { var file_conf_pb_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_conf_pb_captcha_proto_goTypes = []any{ - (*Captcha)(nil), // 0: conf.Captcha + (*Captcha)(nil), // 0: conf.pb.Captcha (*v1.Caches)(nil), // 1: runtime.api.config.data.v1.Caches } var file_conf_pb_captcha_proto_depIdxs = []int32{ - 1, // 0: conf.Captcha.caches:type_name -> runtime.api.config.data.v1.Caches + 1, // 0: conf.pb.Captcha.caches:type_name -> runtime.api.config.data.v1.Caches 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name diff --git a/internal/conf/pb/captcha.pb.validate.go b/internal/conf/pb/captcha.pb.validate.go index a1cf66d9..865dd313 100644 --- a/internal/conf/pb/captcha.pb.validate.go +++ b/internal/conf/pb/captcha.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. // source: conf/pb/captcha.proto -package conf +package confpb import ( "bytes" diff --git a/internal/conf/pb/captcha.proto b/internal/conf/pb/captcha.proto index 7da2f17d..27bc81e1 100644 --- a/internal/conf/pb/captcha.proto +++ b/internal/conf/pb/captcha.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package conf; +package conf.pb; import "config/data/v1/data.proto"; -option go_package = "origadmin/application/admin/internal/conf;conf"; +option go_package = "origadmin/application/admin/internal/conf/pb;confpb"; message Captcha { int32 length = 1 [json_name = "length"]; diff --git a/internal/conf/pb/conf.pb.go b/internal/conf/pb/conf.pb.go index 4fc31ba2..b74213c3 100644 --- a/internal/conf/pb/conf.pb.go +++ b/internal/conf/pb/conf.pb.go @@ -4,13 +4,12 @@ // protoc v5.28.3 // source: conf/pb/conf.proto -package conf +package confpb import ( v1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - conf "origadmin/application/admin/conf" reflect "reflect" sync "sync" unsafe "unsafe" @@ -35,7 +34,7 @@ type Bootstrap struct { // Captcha feature specific configuration. Captcha *Captcha `protobuf:"bytes,4,opt,name=captcha,proto3" json:"captcha,omitempty"` // RootUser feature specific configuration for initial user setup. - RootUser *conf.RootUser `protobuf:"bytes,5,opt,name=root_user,json=rootUser,proto3" json:"root_user,omitempty"` + RootUser *RootUser `protobuf:"bytes,5,opt,name=root_user,json=rootUser,proto3" json:"root_user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -98,7 +97,7 @@ func (x *Bootstrap) GetCaptcha() *Captcha { return nil } -func (x *Bootstrap) GetRootUser() *conf.RootUser { +func (x *Bootstrap) GetRootUser() *RootUser { if x != nil { return x.RootUser } @@ -155,15 +154,15 @@ var File_conf_pb_conf_proto protoreflect.FileDescriptor const file_conf_pb_conf_proto_rawDesc = "" + "\n" + - "\x12conf/pb/conf.proto\x12\x04conf\x1a#config/transport/v1/transport.proto\x1a\x15conf/pb/captcha.proto\x1a\x12conf/pb/root.proto\"\xa8\x02\n" + + "\x12conf/pb/conf.proto\x12\aconf.pb\x1a#config/transport/v1/transport.proto\x1a\x15conf/pb/captcha.proto\x1a\x12conf/pb/root.proto\"\xb1\x02\n" + "\tBootstrap\x12B\n" + "\aservers\x18\x01 \x01(\v2(.runtime.api.config.transport.v1.ServersR\aservers\x12B\n" + - "\aclients\x18\x02 \x01(\v2(.runtime.api.config.transport.v1.ClientsR\aclients\x12=\n" + - "\x0fselector_global\x18\x03 \x01(\v2\x14.conf.SelectorGlobalR\x0eselectorGlobal\x12'\n" + - "\acaptcha\x18\x04 \x01(\v2\r.conf.CaptchaR\acaptcha\x12+\n" + - "\troot_user\x18\x05 \x01(\v2\x0e.conf.RootUserR\brootUser\"*\n" + + "\aclients\x18\x02 \x01(\v2(.runtime.api.config.transport.v1.ClientsR\aclients\x12@\n" + + "\x0fselector_global\x18\x03 \x01(\v2\x17.conf.pb.SelectorGlobalR\x0eselectorGlobal\x12*\n" + + "\acaptcha\x18\x04 \x01(\v2\x10.conf.pb.CaptchaR\acaptcha\x12.\n" + + "\troot_user\x18\x05 \x01(\v2\x11.conf.pb.RootUserR\brootUser\"*\n" + "\x0eSelectorGlobal\x12\x18\n" + - "\abuilder\x18\x01 \x01(\tR\abuilderB0Z.origadmin/application/admin/internal/conf;confb\x06proto3" + "\abuilder\x18\x01 \x01(\tR\abuilderB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" var ( file_conf_pb_conf_proto_rawDescOnce sync.Once @@ -179,19 +178,19 @@ func file_conf_pb_conf_proto_rawDescGZIP() []byte { var file_conf_pb_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_conf_pb_conf_proto_goTypes = []any{ - (*Bootstrap)(nil), // 0: conf.Bootstrap - (*SelectorGlobal)(nil), // 1: conf.SelectorGlobal + (*Bootstrap)(nil), // 0: conf.pb.Bootstrap + (*SelectorGlobal)(nil), // 1: conf.pb.SelectorGlobal (*v1.Servers)(nil), // 2: runtime.api.config.transport.v1.Servers (*v1.Clients)(nil), // 3: runtime.api.config.transport.v1.Clients - (*Captcha)(nil), // 4: conf.Captcha - (*conf.RootUser)(nil), // 5: conf.RootUser + (*Captcha)(nil), // 4: conf.pb.Captcha + (*RootUser)(nil), // 5: conf.pb.RootUser } var file_conf_pb_conf_proto_depIdxs = []int32{ - 2, // 0: conf.Bootstrap.servers:type_name -> runtime.api.config.transport.v1.Servers - 3, // 1: conf.Bootstrap.clients:type_name -> runtime.api.config.transport.v1.Clients - 1, // 2: conf.Bootstrap.selector_global:type_name -> conf.SelectorGlobal - 4, // 3: conf.Bootstrap.captcha:type_name -> conf.Captcha - 5, // 4: conf.Bootstrap.root_user:type_name -> conf.RootUser + 2, // 0: conf.pb.Bootstrap.servers:type_name -> runtime.api.config.transport.v1.Servers + 3, // 1: conf.pb.Bootstrap.clients:type_name -> runtime.api.config.transport.v1.Clients + 1, // 2: conf.pb.Bootstrap.selector_global:type_name -> conf.pb.SelectorGlobal + 4, // 3: conf.pb.Bootstrap.captcha:type_name -> conf.pb.Captcha + 5, // 4: conf.pb.Bootstrap.root_user:type_name -> conf.pb.RootUser 5, // [5:5] is the sub-list for method output_type 5, // [5:5] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name @@ -205,6 +204,7 @@ func file_conf_pb_conf_proto_init() { return } file_conf_pb_captcha_proto_init() + file_conf_pb_root_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/internal/conf/pb/conf.pb.validate.go b/internal/conf/pb/conf.pb.validate.go index 0c973970..4c64c27b 100644 --- a/internal/conf/pb/conf.pb.validate.go +++ b/internal/conf/pb/conf.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. // source: conf/pb/conf.proto -package conf +package confpb import ( "bytes" diff --git a/internal/conf/pb/conf.proto b/internal/conf/pb/conf.proto index ee705b89..04441eb0 100644 --- a/internal/conf/pb/conf.proto +++ b/internal/conf/pb/conf.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -package conf; +package conf.pb; -option go_package = "origadmin/application/admin/internal/conf;conf"; +option go_package = "origadmin/application/admin/internal/conf/pb;confpb"; import "config/transport/v1/transport.proto"; import "conf/pb/captcha.proto"; @@ -20,10 +20,10 @@ message Bootstrap { SelectorGlobal selector_global = 3; // Captcha feature specific configuration. - Captcha captcha = 4; + conf.pb.Captcha captcha = 4; // RootUser feature specific configuration for initial user setup. - RootUser root_user = 5; + conf.pb.RootUser root_user = 5; } // SelectorGlobal defines the global selector/load-balancing strategy. diff --git a/internal/conf/pb/root.pb.go b/internal/conf/pb/root.pb.go index d790be22..c5ad0fe1 100644 --- a/internal/conf/pb/root.pb.go +++ b/internal/conf/pb/root.pb.go @@ -4,7 +4,7 @@ // protoc v5.28.3 // source: conf/pb/root.proto -package conf +package confpb import ( _ "github.com/envoyproxy/protoc-gen-validate/validate" @@ -166,7 +166,7 @@ var File_conf_pb_root_proto protoreflect.FileDescriptor const file_conf_pb_root_proto_rawDesc = "" + "\n" + - "\x12conf/pb/root.proto\x12\x04conf\x1a\x17validate/validate.proto\"\x8c\x03\n" + + "\x12conf/pb/root.proto\x12\aconf.pb\x1a\x17validate/validate.proto\"\x8c\x03\n" + "\bRootUser\x12\x18\n" + "\aenabled\x18\x01 \x01(\bR\aenabled\x12\x17\n" + "\x02id\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x02id\x12#\n" + @@ -181,7 +181,7 @@ const file_conf_pb_root_proto_rawDesc = "" + " \x01(\tR\x06mobile\x12 \n" + "\vdescription\x18\v \x01(\tR\vdescription\x12 \n" + "\vauto_create\x18d \x01(\bR\vauto_create\x12(\n" + - "\x0frandom_password\x18e \x01(\bR\x0frandom_passwordB'Z%origadmin/application/admin/conf;confb\x06proto3" + "\x0frandom_password\x18e \x01(\bR\x0frandom_passwordB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" var ( file_conf_pb_root_proto_rawDescOnce sync.Once @@ -197,7 +197,7 @@ func file_conf_pb_root_proto_rawDescGZIP() []byte { var file_conf_pb_root_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_conf_pb_root_proto_goTypes = []any{ - (*RootUser)(nil), // 0: conf.RootUser + (*RootUser)(nil), // 0: conf.pb.RootUser } var file_conf_pb_root_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type diff --git a/internal/conf/pb/root.pb.validate.go b/internal/conf/pb/root.pb.validate.go index 9c7e4b5b..b49b77c9 100644 --- a/internal/conf/pb/root.pb.validate.go +++ b/internal/conf/pb/root.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. // source: conf/pb/root.proto -package conf +package confpb import ( "bytes" diff --git a/internal/conf/pb/root.proto b/internal/conf/pb/root.proto index 2911cdf9..c4452908 100644 --- a/internal/conf/pb/root.proto +++ b/internal/conf/pb/root.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package conf; +package conf.pb; import "validate/validate.proto"; -option go_package = "origadmin/application/admin/conf;conf"; +option go_package = "origadmin/application/admin/internal/conf/pb;confpb"; message RootUser { bool enabled = 1 [json_name = "enabled"]; From aeb8c4747becd120270add1249f7d04f9958639f Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 3 Dec 2025 14:40:38 +0800 Subject: [PATCH 065/158] refactor(proto): update go_package paths and clean up proto files --- api/v1/proto/annotations.proto | 2 +- api/v1/proto/auth/auth.proto | 2 +- api/v1/proto/auth/casbin.proto | 5 +- api/v1/proto/auth/login.proto | 2 +- api/v1/proto/auth/personal.proto | 2 +- api/v1/proto/datastore/datastore.proto | 2 +- api/v1/proto/datastore/upload.proto | 4 +- api/v1/proto/message/message.proto | 2 +- api/v1/proto/system/department.proto | 2 +- api/v1/proto/system/menu.proto | 2 +- api/v1/proto/system/permission.proto | 2 +- api/v1/proto/system/position.proto | 2 +- api/v1/proto/system/resource.proto | 2 +- api/v1/proto/system/role.proto | 2 +- api/v1/proto/system/user.proto | 2 +- api/v1/proto/types/datastore.proto | 4 +- api/v1/proto/types/message.proto | 4 +- api/v1/services/annotations.pb.go | 6 +- api/v1/services/auth/auth.pb.go | 6 +- api/v1/services/auth/auth_http.pb.go | 14 +- api/v1/services/auth/casbin.pb.go | 6 +- api/v1/services/auth/casbin_http.pb.go | 2 +- api/v1/services/auth/login.pb.go | 6 +- api/v1/services/auth/login_http.pb.go | 2 +- api/v1/services/auth/personal.pb.go | 6 +- api/v1/services/auth/personal_http.pb.go | 18 +- api/v1/services/datastore/datastore.pb.go | 6 +- .../services/datastore/datastore_http.pb.go | 2 +- api/v1/services/datastore/upload.pb.go | 749 ++++++ api/v1/services/datastore/upload.pb.gw.go | 487 ++++ .../services/datastore/upload.pb.validate.go | 1327 +++++++++ api/v1/services/datastore/upload_bridge.pb.go | 392 +++ api/v1/services/datastore/upload_grpc.pb.go | 277 ++ api/v1/services/datastore/upload_http.pb.go | 234 ++ api/v1/services/message/message.pb.go | 1074 ++++++++ api/v1/services/message/message.pb.gw.go | 594 ++++ .../services/message/message.pb.validate.go | 2390 +++++++++++++++++ api/v1/services/message/message_bridge.pb.go | 565 ++++ api/v1/services/message/message_grpc.pb.go | 407 +++ api/v1/services/message/message_http.pb.go | 366 +++ api/v1/services/system/department.pb.go | 6 +- api/v1/services/system/department_http.pb.go | 2 +- api/v1/services/system/menu.pb.go | 6 +- api/v1/services/system/menu_http.pb.go | 2 +- api/v1/services/system/permission.pb.go | 6 +- api/v1/services/system/permission_http.pb.go | 2 +- api/v1/services/system/position.pb.go | 6 +- api/v1/services/system/position_http.pb.go | 2 +- api/v1/services/system/resource.pb.go | 6 +- api/v1/services/system/resource_http.pb.go | 2 +- api/v1/services/system/role.pb.go | 6 +- api/v1/services/system/role_http.pb.go | 2 +- api/v1/services/system/user.pb.go | 6 +- api/v1/services/system/user_http.pb.go | 8 +- api/v1/services/types/auth_error.pb.go | 2 +- api/v1/services/types/datastore.pb.go | 206 ++ .../services/types/datastore.pb.validate.go | 232 ++ api/v1/services/types/error.pb.go | 2 +- api/v1/services/types/message.pb.go | 6 +- api/v1/services/types/system.pb.go | 2 +- api/v1/services/types/system_error.pb.go | 2 +- go.mod | 2 +- resources/docs/openapi/openapi.yaml | 230 +- 63 files changed, 9644 insertions(+), 81 deletions(-) create mode 100644 api/v1/services/datastore/upload.pb.go create mode 100644 api/v1/services/datastore/upload.pb.gw.go create mode 100644 api/v1/services/datastore/upload.pb.validate.go create mode 100644 api/v1/services/datastore/upload_bridge.pb.go create mode 100644 api/v1/services/datastore/upload_grpc.pb.go create mode 100644 api/v1/services/datastore/upload_http.pb.go create mode 100644 api/v1/services/message/message.pb.go create mode 100644 api/v1/services/message/message.pb.gw.go create mode 100644 api/v1/services/message/message.pb.validate.go create mode 100644 api/v1/services/message/message_bridge.pb.go create mode 100644 api/v1/services/message/message_grpc.pb.go create mode 100644 api/v1/services/message/message_http.pb.go create mode 100644 api/v1/services/types/datastore.pb.go create mode 100644 api/v1/services/types/datastore.pb.validate.go diff --git a/api/v1/proto/annotations.proto b/api/v1/proto/annotations.proto index 3bb83ad9..1594e933 100644 --- a/api/v1/proto/annotations.proto +++ b/api/v1/proto/annotations.proto @@ -4,7 +4,7 @@ package api.v1.services; import "gnostic/openapi/v3/annotations.proto"; -option go_package = "api/v1/services;services"; +option go_package = "origadmin/application/admin/api/v1/services;services"; option (gnostic.openapi.v3.document) = { info: { title: "OrigAdmin API" diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index a64e7ea0..a053fe13 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -7,7 +7,7 @@ import "google/api/client.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "api/v1/services/auth;auth"; +option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; option java_outer_classname = "APIServiceAuthAuthProto"; option java_package = "com.origadmin.api.v1.services.auth"; diff --git a/api/v1/proto/auth/casbin.proto b/api/v1/proto/auth/casbin.proto index 0fc566ef..4ca298f6 100644 --- a/api/v1/proto/auth/casbin.proto +++ b/api/v1/proto/auth/casbin.proto @@ -3,11 +3,8 @@ syntax = "proto3"; package api.v1.services.auth; import "google/api/annotations.proto"; -//import "google/protobuf/any.proto"; -//import "google/protobuf/empty.proto"; -//import "types/system.proto"; -option go_package = "api/v1/services/auth;auth"; +option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; option java_outer_classname = "APIServiceAuthCasbinProto"; option java_package = "com.origadmin.api.v1.services.auth"; diff --git a/api/v1/proto/auth/login.proto b/api/v1/proto/auth/login.proto index c141988a..75890745 100644 --- a/api/v1/proto/auth/login.proto +++ b/api/v1/proto/auth/login.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "security/jwt/v1/token.proto"; import "validate/validate.proto"; -option go_package = "api/v1/services/auth;auth"; +option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; option java_outer_classname = "APIV1ServicesAuthLoginProto"; option java_package = "com.origadmin.api.v1.services.auth"; diff --git a/api/v1/proto/auth/personal.proto b/api/v1/proto/auth/personal.proto index 54c61082..c02c4c3c 100644 --- a/api/v1/proto/auth/personal.proto +++ b/api/v1/proto/auth/personal.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "types/system.proto"; import "validate/validate.proto"; -option go_package = "api/v1/services/auth;auth"; +option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; option java_outer_classname = "APIV1ServicesAuthPersonalProto"; option java_package = "com.origadmin.api.v1.services.auth"; diff --git a/api/v1/proto/datastore/datastore.proto b/api/v1/proto/datastore/datastore.proto index 4d396a96..01ae6faf 100644 --- a/api/v1/proto/datastore/datastore.proto +++ b/api/v1/proto/datastore/datastore.proto @@ -8,7 +8,7 @@ import "google/protobuf/empty.proto"; import "types/datastore.proto"; import "validate/validate.proto"; -option go_package = "api/v1/services/datastore;datastore"; +option go_package = "origadmin/application/admin/api/v1/services/datastore;datastore"; option java_multiple_files = true; option java_outer_classname = "APIV1ServicesDatastoreProto"; option java_package = "com.origadmin.api.v1.services.datastore"; diff --git a/api/v1/proto/datastore/upload.proto b/api/v1/proto/datastore/upload.proto index 6acb4cc9..3f37a2d5 100644 --- a/api/v1/proto/datastore/upload.proto +++ b/api/v1/proto/datastore/upload.proto @@ -5,10 +5,10 @@ package api.v1.services.upload; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "types/upload.proto"; +import "types/datastore.proto"; import "validate/validate.proto"; -option go_package = "api/v1/services/upload;upload"; +option go_package = "origadmin/application/admin/api/v1/services/upload;upload"; option java_multiple_files = true; option java_outer_classname = "APIV1ServicesUploadProto"; option java_package = "com.origadmin.api.v1.services.upload"; diff --git a/api/v1/proto/message/message.proto b/api/v1/proto/message/message.proto index bb39cc8b..368ec2d5 100644 --- a/api/v1/proto/message/message.proto +++ b/api/v1/proto/message/message.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "types/system.proto"; import "validate/validate.proto"; -option go_package = "api/v1/services/message;message"; +option go_package = "origadmin/application/admin/api/v1/services/message;message"; option java_multiple_files = true; option java_outer_classname = "APIV1ServicesMessagePersonalProto"; option java_package = "com.origadmin.api.v1.services.message"; diff --git a/api/v1/proto/system/department.proto b/api/v1/proto/system/department.proto index d26cd2f5..cfb7d8e3 100644 --- a/api/v1/proto/system/department.proto +++ b/api/v1/proto/system/department.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "api/v1/services/system;system"; +option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemDepartmentProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/menu.proto b/api/v1/proto/system/menu.proto index b04e0c2c..a935cd0f 100644 --- a/api/v1/proto/system/menu.proto +++ b/api/v1/proto/system/menu.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "api/v1/services/system;system"; +option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemMenuProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/permission.proto b/api/v1/proto/system/permission.proto index a7ec2ac6..1b9130ef 100644 --- a/api/v1/proto/system/permission.proto +++ b/api/v1/proto/system/permission.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "api/v1/services/system;system"; +option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemPermissionProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/position.proto b/api/v1/proto/system/position.proto index 6012ba4a..9c708d12 100644 --- a/api/v1/proto/system/position.proto +++ b/api/v1/proto/system/position.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "api/v1/services/system;system"; +option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemPositionProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index c8438765..d26aa42f 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "api/v1/services/system;system"; +option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemResourceProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/role.proto b/api/v1/proto/system/role.proto index 684c65bf..f1f3aa8b 100644 --- a/api/v1/proto/system/role.proto +++ b/api/v1/proto/system/role.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "api/v1/services/system;system"; +option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemRoleProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index 14335c73..c09684f8 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -7,7 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; -option go_package = "api/v1/services/system;system"; +option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; option java_outer_classname = "APIServiceSystemUserProto"; option java_package = "com.origadmin.api.v1.services.system"; diff --git a/api/v1/proto/types/datastore.proto b/api/v1/proto/types/datastore.proto index b5c12c1c..a8f6678c 100644 --- a/api/v1/proto/types/datastore.proto +++ b/api/v1/proto/types/datastore.proto @@ -6,11 +6,11 @@ import "google/protobuf/timestamp.proto"; option go_package = "origadmin/application/admin/api/v1/services/types;types"; option java_multiple_files = true; -option java_outer_classname = "APIServiceTypeMessageProto"; +option java_outer_classname = "APIServiceTypeDatastoreProto"; option java_package = "com.origadmin.api.v1.services.types"; option objc_class_prefix = "APIServiceType"; -// Menu is the model entity for the Menu schema. +// DataObject is the model entity for the DataObject schema. message DataObject { // ID of the ent. string id = 1 [json_name = "id"]; diff --git a/api/v1/proto/types/message.proto b/api/v1/proto/types/message.proto index d5864c47..f784d7e3 100644 --- a/api/v1/proto/types/message.proto +++ b/api/v1/proto/types/message.proto @@ -10,7 +10,9 @@ option java_outer_classname = "APIServiceTypeMessageProto"; option java_package = "com.origadmin.api.v1.services.types"; option objc_class_prefix = "APIServiceType"; -// Menu is the model entity for the Menu schema. +// Message is the model entity for the Message schema. +// NOTE: This message definition is currently incomplete and only contains an ID field. +// It should be extended with actual message content as needed. message Message { // ID of the ent. int64 id = 1 [json_name = "id"]; diff --git a/api/v1/services/annotations.pb.go b/api/v1/services/annotations.pb.go index 74180403..18f60855 100644 --- a/api/v1/services/annotations.pb.go +++ b/api/v1/services/annotations.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: annotations.proto @@ -25,7 +25,7 @@ var File_annotations_proto protoreflect.FileDescriptor const file_annotations_proto_rawDesc = "" + "\n" + - "\x11annotations.proto\x12\x0fapi.v1.services\x1a$gnostic/openapi/v3/annotations.protoB\xb2\x04\xbaG\x8f\x03\x12\x8c\x02\n" + + "\x11annotations.proto\x12\x0fapi.v1.services\x1a$gnostic/openapi/v3/annotations.protoB\xce\x04\xbaG\x8f\x03\x12\x8c\x02\n" + "\rOrigAdmin API\x12_A lightweight, flexible, elegant and full-featured RBAC scaffolding backend management project.\"@\n" + "\aGodCong\x12\x1chttps://github.com/origadmin\x1a\x17waitforadding@gmail.com*?\n" + "\x03MIT\x128https://github.com/origadmin/backend/blob/master/LICENSE2\x17Version from annotation\x1a\x18\n" + @@ -39,7 +39,7 @@ const file_annotations_proto_rawDesc = "" + "\x06Bearer\x12!\n" + "\x1f\n" + "\x06apiKey\x1a\rAuthorization\"\x06header\n" + - "\x13com.api.v1.servicesB\x10AnnotationsProtoP\x01Z\x18api/v1/services;services\xa2\x02\x03AVS\xaa\x02\x0fApi.V1.Services\xca\x02\x0fApi\\V1\\Services\xe2\x02\x1bApi\\V1\\Services\\GPBMetadata\xea\x02\x11Api::V1::Servicesb\x06proto3" + "\x13com.api.v1.servicesB\x10AnnotationsProtoP\x01Z4origadmin/application/admin/api/v1/services;services\xa2\x02\x03AVS\xaa\x02\x0fApi.V1.Services\xca\x02\x0fApi\\V1\\Services\xe2\x02\x1bApi\\V1\\Services\\GPBMetadata\xea\x02\x11Api::V1::Servicesb\x06proto3" var file_annotations_proto_goTypes = []any{} var file_annotations_proto_depIdxs = []int32{ diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index db4d2099..e5c2c744 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: auth/auth.proto @@ -872,8 +872,8 @@ const file_auth_auth_proto_rawDesc = "" + "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x04data\"\r/auth/destroy\x12\x87\x01\n" + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\" \x82\xd3\xe4\x93\x02\x1a:\x04data\"\x12/auth/authenticate\x12{\n" + "\n" + - "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x04data\"\f/auth/logout\x1a\x0e\xcaA\vapi.foo.comB\xb4\x01\n" + - "\x18com.api.v1.services.authB\tAuthProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x04data\"\f/auth/logout\x1a\x0e\xcaA\vapi.foo.comB\xd0\x01\n" + + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_auth_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go index 0f0b3994..cd009a40 100644 --- a/api/v1/services/auth/auth_http.pb.go +++ b/api/v1/services/auth/auth_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: auth/auth.proto @@ -178,11 +178,17 @@ func _AuthService_AuthLogout0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx h } type AuthServiceHTTPClient interface { + // AuthLogout AuthLogout logs out a user. AuthLogout(ctx context.Context, req *AuthLogoutRequest, opts ...http.CallOption) (rsp *AuthLogoutResponse, err error) + // Authenticate Authenticate authenticates a user. Authenticate(ctx context.Context, req *AuthenticateRequest, opts ...http.CallOption) (rsp *AuthenticateResponse, err error) + // CreateToken CreateToken generates a new JWT token for the given user. CreateToken(ctx context.Context, req *CreateTokenRequest, opts ...http.CallOption) (rsp *CreateTokenResponse, err error) + // DestroyToken DestroyToken invalidates a JWT token. DestroyToken(ctx context.Context, req *DestroyTokenRequest, opts ...http.CallOption) (rsp *DestroyTokenResponse, err error) + // ListAuthResources ListAuthResources returns a list of Auths. ListAuthResources(ctx context.Context, req *ListAuthResourcesRequest, opts ...http.CallOption) (rsp *ListAuthResourcesResponse, err error) + // ValidateToken ValidateToken verifies the validity of a JWT token. ValidateToken(ctx context.Context, req *ValidateTokenRequest, opts ...http.CallOption) (rsp *ValidateTokenResponse, err error) } @@ -194,6 +200,7 @@ func NewAuthServiceHTTPClient(client *http.Client) AuthServiceHTTPClient { return &AuthServiceHTTPClientImpl{client} } +// AuthLogout AuthLogout logs out a user. func (c *AuthServiceHTTPClientImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...http.CallOption) (*AuthLogoutResponse, error) { var out AuthLogoutResponse pattern := "/auth/logout" @@ -207,6 +214,7 @@ func (c *AuthServiceHTTPClientImpl) AuthLogout(ctx context.Context, in *AuthLogo return &out, nil } +// Authenticate Authenticate authenticates a user. func (c *AuthServiceHTTPClientImpl) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...http.CallOption) (*AuthenticateResponse, error) { var out AuthenticateResponse pattern := "/auth/authenticate" @@ -220,6 +228,7 @@ func (c *AuthServiceHTTPClientImpl) Authenticate(ctx context.Context, in *Authen return &out, nil } +// CreateToken CreateToken generates a new JWT token for the given user. func (c *AuthServiceHTTPClientImpl) CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...http.CallOption) (*CreateTokenResponse, error) { var out CreateTokenResponse pattern := "/auth/token" @@ -233,6 +242,7 @@ func (c *AuthServiceHTTPClientImpl) CreateToken(ctx context.Context, in *CreateT return &out, nil } +// DestroyToken DestroyToken invalidates a JWT token. func (c *AuthServiceHTTPClientImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...http.CallOption) (*DestroyTokenResponse, error) { var out DestroyTokenResponse pattern := "/auth/destroy" @@ -246,6 +256,7 @@ func (c *AuthServiceHTTPClientImpl) DestroyToken(ctx context.Context, in *Destro return &out, nil } +// ListAuthResources ListAuthResources returns a list of Auths. func (c *AuthServiceHTTPClientImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...http.CallOption) (*ListAuthResourcesResponse, error) { var out ListAuthResourcesResponse pattern := "/auth/resources" @@ -259,6 +270,7 @@ func (c *AuthServiceHTTPClientImpl) ListAuthResources(ctx context.Context, in *L return &out, nil } +// ValidateToken ValidateToken verifies the validity of a JWT token. func (c *AuthServiceHTTPClientImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...http.CallOption) (*ValidateTokenResponse, error) { var out ValidateTokenResponse pattern := "/auth/validate" diff --git a/api/v1/services/auth/casbin.pb.go b/api/v1/services/auth/casbin.pb.go index 3bda3719..09c72623 100644 --- a/api/v1/services/auth/casbin.pb.go +++ b/api/v1/services/auth/casbin.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: auth/casbin.proto @@ -541,8 +541,8 @@ const file_auth_casbin_proto_rawDesc = "" + "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x86\x01\n" + "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12|\n" + "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12f\n" + - "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xb6\x01\n" + - "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xd2\x01\n" + + "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_casbin_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/casbin_http.pb.go b/api/v1/services/auth/casbin_http.pb.go index 366708dc..e66f87ae 100644 --- a/api/v1/services/auth/casbin_http.pb.go +++ b/api/v1/services/auth/casbin_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: auth/casbin.proto diff --git a/api/v1/services/auth/login.pb.go b/api/v1/services/auth/login.pb.go index 93d34a71..3ae746b2 100644 --- a/api/v1/services/auth/login.pb.go +++ b/api/v1/services/auth/login.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: auth/login.proto @@ -1352,9 +1352,9 @@ const file_auth_login_proto_rawDesc = "" + "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x14\x82\xd3\xe4\x93\x02\x0e:\x04data\"\x06/login\x12j\n" + "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/logout\x12r\n" + "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a&.api.v1.services.auth.RegisterResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x04data\"\t/register\x12\x83\x01\n" + - "\fTokenRefresh\x12).api.v1.services.auth.TokenRefreshRequest\x1a*.api.v1.services.auth.TokenRefreshResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04data\"\x0e/token/refreshB\xb5\x01\n" + + "\fTokenRefresh\x12).api.v1.services.auth.TokenRefreshRequest\x1a*.api.v1.services.auth.TokenRefreshResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04data\"\x0e/token/refreshB\xd1\x01\n" + "\x18com.api.v1.services.authB\n" + - "LoginProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "LoginProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_login_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/login_http.pb.go b/api/v1/services/auth/login_http.pb.go index b5de8ab2..cd24ca67 100644 --- a/api/v1/services/auth/login_http.pb.go +++ b/api/v1/services/auth/login_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: auth/login.proto diff --git a/api/v1/services/auth/personal.pb.go b/api/v1/services/auth/personal.pb.go index ffe4e38f..5d73ceaf 100644 --- a/api/v1/services/auth/personal.pb.go +++ b/api/v1/services/auth/personal.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: auth/personal.proto @@ -974,8 +974,8 @@ const file_auth_personal_proto_rawDesc = "" + "\x14RefreshPersonalToken\x121.api.v1.services.auth.RefreshPersonalTokenRequest\x1a2.api.v1.services.auth.RefreshPersonalTokenResponse\"*\x82\xd3\xe4\x93\x02$:\x04data\"\x1c/auth/personal/token/refresh\x12\xaa\x01\n" + "\x16UpdatePersonalPassword\x123.api.v1.services.auth.UpdatePersonalPasswordRequest\x1a4.api.v1.services.auth.UpdatePersonalPasswordResponse\"%\x82\xd3\xe4\x93\x02\x1f:\x04data\x1a\x17/auth/personal/password\x12\xa6\x01\n" + "\x15UpdatePersonalProfile\x122.api.v1.services.auth.UpdatePersonalProfileRequest\x1a3.api.v1.services.auth.UpdatePersonalProfileResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/profile\x12\xa6\x01\n" + - "\x15UpdatePersonalSetting\x122.api.v1.services.auth.UpdatePersonalSettingRequest\x1a3.api.v1.services.auth.UpdatePersonalSettingResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/settingB\xb8\x01\n" + - "\x18com.api.v1.services.authB\rPersonalProtoP\x01Z\x19api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "\x15UpdatePersonalSetting\x122.api.v1.services.auth.UpdatePersonalSettingRequest\x1a3.api.v1.services.auth.UpdatePersonalSettingResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/settingB\xd4\x01\n" + + "\x18com.api.v1.services.authB\rPersonalProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_personal_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/personal_http.pb.go b/api/v1/services/auth/personal_http.pb.go index c14326b3..1d00a291 100644 --- a/api/v1/services/auth/personal_http.pb.go +++ b/api/v1/services/auth/personal_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: auth/personal.proto @@ -227,13 +227,21 @@ func _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv PersonalServiceHTT } type PersonalServiceHTTPClient interface { + // GetPersonalProfile GetPersonalProfile Update the personal user information GetPersonalProfile(ctx context.Context, req *GetPersonalProfileRequest, opts ...http.CallOption) (rsp *GetPersonalProfileResponse, err error) + // ListPersonalResources ListPersonalResources List the personal user's menu ListPersonalResources(ctx context.Context, req *ListPersonalResourcesRequest, opts ...http.CallOption) (rsp *ListPersonalResourcesResponse, err error) + // ListPersonalRoles ListPersonalResources List the personal user's menu ListPersonalRoles(ctx context.Context, req *ListPersonalRolesRequest, opts ...http.CallOption) (rsp *ListPersonalRolesResponse, err error) + // PersonalLogout PersonalLogout Personal user logs out PersonalLogout(ctx context.Context, req *PersonalLogoutRequest, opts ...http.CallOption) (rsp *PersonalLogoutResponse, err error) + // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token RefreshPersonalToken(ctx context.Context, req *RefreshPersonalTokenRequest, opts ...http.CallOption) (rsp *RefreshPersonalTokenResponse, err error) + // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password UpdatePersonalPassword(ctx context.Context, req *UpdatePersonalPasswordRequest, opts ...http.CallOption) (rsp *UpdatePersonalPasswordResponse, err error) + // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information UpdatePersonalProfile(ctx context.Context, req *UpdatePersonalProfileRequest, opts ...http.CallOption) (rsp *UpdatePersonalProfileResponse, err error) + // UpdatePersonalSetting UpdatePersonalSetting User settings are saved UpdatePersonalSetting(ctx context.Context, req *UpdatePersonalSettingRequest, opts ...http.CallOption) (rsp *UpdatePersonalSettingResponse, err error) } @@ -245,6 +253,7 @@ func NewPersonalServiceHTTPClient(client *http.Client) PersonalServiceHTTPClient return &PersonalServiceHTTPClientImpl{client} } +// GetPersonalProfile GetPersonalProfile Update the personal user information func (c *PersonalServiceHTTPClientImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...http.CallOption) (*GetPersonalProfileResponse, error) { var out GetPersonalProfileResponse pattern := "/auth/personal/profile" @@ -258,6 +267,7 @@ func (c *PersonalServiceHTTPClientImpl) GetPersonalProfile(ctx context.Context, return &out, nil } +// ListPersonalResources ListPersonalResources List the personal user's menu func (c *PersonalServiceHTTPClientImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...http.CallOption) (*ListPersonalResourcesResponse, error) { var out ListPersonalResourcesResponse pattern := "/auth/personal/resources" @@ -271,6 +281,7 @@ func (c *PersonalServiceHTTPClientImpl) ListPersonalResources(ctx context.Contex return &out, nil } +// ListPersonalRoles ListPersonalResources List the personal user's menu func (c *PersonalServiceHTTPClientImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...http.CallOption) (*ListPersonalRolesResponse, error) { var out ListPersonalRolesResponse pattern := "/auth/personal/roles" @@ -284,6 +295,7 @@ func (c *PersonalServiceHTTPClientImpl) ListPersonalRoles(ctx context.Context, i return &out, nil } +// PersonalLogout PersonalLogout Personal user logs out func (c *PersonalServiceHTTPClientImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...http.CallOption) (*PersonalLogoutResponse, error) { var out PersonalLogoutResponse pattern := "/auth/personal/logout" @@ -297,6 +309,7 @@ func (c *PersonalServiceHTTPClientImpl) PersonalLogout(ctx context.Context, in * return &out, nil } +// RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token func (c *PersonalServiceHTTPClientImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...http.CallOption) (*RefreshPersonalTokenResponse, error) { var out RefreshPersonalTokenResponse pattern := "/auth/personal/token/refresh" @@ -310,6 +323,7 @@ func (c *PersonalServiceHTTPClientImpl) RefreshPersonalToken(ctx context.Context return &out, nil } +// UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password func (c *PersonalServiceHTTPClientImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...http.CallOption) (*UpdatePersonalPasswordResponse, error) { var out UpdatePersonalPasswordResponse pattern := "/auth/personal/password" @@ -323,6 +337,7 @@ func (c *PersonalServiceHTTPClientImpl) UpdatePersonalPassword(ctx context.Conte return &out, nil } +// UpdatePersonalProfile UpdatePersonalProfile Update the personal user information func (c *PersonalServiceHTTPClientImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...http.CallOption) (*UpdatePersonalProfileResponse, error) { var out UpdatePersonalProfileResponse pattern := "/auth/personal/profile" @@ -336,6 +351,7 @@ func (c *PersonalServiceHTTPClientImpl) UpdatePersonalProfile(ctx context.Contex return &out, nil } +// UpdatePersonalSetting UpdatePersonalSetting User settings are saved func (c *PersonalServiceHTTPClientImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...http.CallOption) (*UpdatePersonalSettingResponse, error) { var out UpdatePersonalSettingResponse pattern := "/auth/personal/setting" diff --git a/api/v1/services/datastore/datastore.pb.go b/api/v1/services/datastore/datastore.pb.go index 771681ea..f8e0be72 100644 --- a/api/v1/services/datastore/datastore.pb.go +++ b/api/v1/services/datastore/datastore.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: datastore/datastore.proto @@ -667,8 +667,8 @@ const file_datastore_datastore_proto_rawDesc = "" + "\x0fCreateDatastore\x121.api.v1.services.datastore.CreateDatastoreRequest\x1a2.api.v1.services.datastore.CreateDatastoreResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04data\"\n" + "/datastore\x12\x9c\x01\n" + "\x0fUpdateDatastore\x121.api.v1.services.datastore.UpdateDatastoreRequest\x1a2.api.v1.services.datastore.UpdateDatastoreResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04data\x1a\x14/datastore/{data.id}\x12\x91\x01\n" + - "\x0fDeleteDatastore\x121.api.v1.services.datastore.DeleteDatastoreRequest\x1a2.api.v1.services.datastore.DeleteDatastoreResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/datastore/{id}B\xdc\x01\n" + - "\x1dcom.api.v1.services.datastoreB\x0eDatastoreProtoP\x01Z#api/v1/services/datastore;datastore\xa2\x02\x04AVSD\xaa\x02\x19Api.V1.Services.Datastore\xca\x02\x19Api\\V1\\Services\\Datastore\xe2\x02%Api\\V1\\Services\\Datastore\\GPBMetadata\xea\x02\x1cApi::V1::Services::Datastoreb\x06proto3" + "\x0fDeleteDatastore\x121.api.v1.services.datastore.DeleteDatastoreRequest\x1a2.api.v1.services.datastore.DeleteDatastoreResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/datastore/{id}B\xf8\x01\n" + + "\x1dcom.api.v1.services.datastoreB\x0eDatastoreProtoP\x01Z?origadmin/application/admin/api/v1/services/datastore;datastore\xa2\x02\x04AVSD\xaa\x02\x19Api.V1.Services.Datastore\xca\x02\x19Api\\V1\\Services\\Datastore\xe2\x02%Api\\V1\\Services\\Datastore\\GPBMetadata\xea\x02\x1cApi::V1::Services::Datastoreb\x06proto3" var ( file_datastore_datastore_proto_rawDescOnce sync.Once diff --git a/api/v1/services/datastore/datastore_http.pb.go b/api/v1/services/datastore/datastore_http.pb.go index 7b8497ff..955111fa 100644 --- a/api/v1/services/datastore/datastore_http.pb.go +++ b/api/v1/services/datastore/datastore_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: datastore/datastore.proto diff --git a/api/v1/services/datastore/upload.pb.go b/api/v1/services/datastore/upload.pb.go new file mode 100644 index 00000000..227e8804 --- /dev/null +++ b/api/v1/services/datastore/upload.pb.go @@ -0,0 +1,749 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: datastore/upload.proto + +package upload + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// ListUploadRequest is the request for the UploadService.ListUpload method. +type ListUploadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent data id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // data type + Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListUploadRequest) Reset() { + *x = ListUploadRequest{} + mi := &file_datastore_upload_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListUploadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUploadRequest) ProtoMessage() {} + +func (x *ListUploadRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[0] + 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 ListUploadRequest.ProtoReflect.Descriptor instead. +func (*ListUploadRequest) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{0} +} + +func (x *ListUploadRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListUploadRequest) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListUploadRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListUploadRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListUploadRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListUploadRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListUploadRequest) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +// ListUploadResponse is the response for the UploadService.ListUpload method. +type ListUploadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` + // The paging upload + Data []*types.DataObject `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the current data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListUploadResponse) Reset() { + *x = ListUploadResponse{} + mi := &file_datastore_upload_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUploadResponse) ProtoMessage() {} + +func (x *ListUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[1] + 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 ListUploadResponse.ProtoReflect.Descriptor instead. +func (*ListUploadResponse) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{1} +} + +func (x *ListUploadResponse) GetTotalSize() int32 { + if x != nil { + return x.TotalSize + } + return 0 +} + +func (x *ListUploadResponse) GetData() []*types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +func (x *ListUploadResponse) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListUploadResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListUploadResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListUploadResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +// GetUploadRequest is the request for the UploadService.GetUpload method. +type GetUploadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the data requested, for example: + // "shelves/shelf1/upload/data2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUploadRequest) Reset() { + *x = GetUploadRequest{} + mi := &file_datastore_upload_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUploadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUploadRequest) ProtoMessage() {} + +func (x *GetUploadRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[2] + 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 GetUploadRequest.ProtoReflect.Descriptor instead. +func (*GetUploadRequest) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{2} +} + +func (x *GetUploadRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// GetUploadResponse is the response for the UploadService.GetUpload method. +type GetUploadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field id should match the Noun in the method id. + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUploadResponse) Reset() { + *x = GetUploadResponse{} + mi := &file_datastore_upload_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUploadResponse) ProtoMessage() {} + +func (x *GetUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[3] + 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 GetUploadResponse.ProtoReflect.Descriptor instead. +func (*GetUploadResponse) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{3} +} + +func (x *GetUploadResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// CreateUploadRequest is the request for the UploadService.CreateUpload method. +type CreateUploadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent data id where the data is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The data id to use for this data. + DataId string `protobuf:"bytes,2,opt,name=data_id,proto3" json:"data_id,omitempty"` + // The data object to create. + Data *types.DataObject `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateUploadRequest) Reset() { + *x = CreateUploadRequest{} + mi := &file_datastore_upload_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateUploadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateUploadRequest) ProtoMessage() {} + +func (x *CreateUploadRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[4] + 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 CreateUploadRequest.ProtoReflect.Descriptor instead. +func (*CreateUploadRequest) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateUploadRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateUploadRequest) GetDataId() string { + if x != nil { + return x.DataId + } + return "" +} + +func (x *CreateUploadRequest) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// CreateUploadResponse is the response for the UploadService.CreateUpload method. +type CreateUploadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateUploadResponse) Reset() { + *x = CreateUploadResponse{} + mi := &file_datastore_upload_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateUploadResponse) ProtoMessage() {} + +func (x *CreateUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[5] + 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 CreateUploadResponse.ProtoReflect.Descriptor instead. +func (*CreateUploadResponse) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateUploadResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// UpdateUploadRequest is the request for the UploadService.UpdateUpload method. +type UpdateUploadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The id of the data object to update. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The data object which replaces the data on the server. + Data *types.DataObject `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateUploadRequest) Reset() { + *x = UpdateUploadRequest{} + mi := &file_datastore_upload_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateUploadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUploadRequest) ProtoMessage() {} + +func (x *UpdateUploadRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_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 UpdateUploadRequest.ProtoReflect.Descriptor instead. +func (*UpdateUploadRequest) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateUploadRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateUploadRequest) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// UpdateUploadResponse is the response for the UploadService.UpdateUpload method. +type UpdateUploadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateUploadResponse) Reset() { + *x = UpdateUploadResponse{} + mi := &file_datastore_upload_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUploadResponse) ProtoMessage() {} + +func (x *UpdateUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateUploadResponse.ProtoReflect.Descriptor instead. +func (*UpdateUploadResponse) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateUploadResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// DeleteUploadRequest is the request for the UploadService.DeleteUpload method. +type DeleteUploadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The data id of the data to be deleted, for example: + // "shelves/shelf1/upload/data2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteUploadRequest) Reset() { + *x = DeleteUploadRequest{} + mi := &file_datastore_upload_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteUploadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUploadRequest) ProtoMessage() {} + +func (x *DeleteUploadRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[8] + 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 DeleteUploadRequest.ProtoReflect.Descriptor instead. +func (*DeleteUploadRequest) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteUploadRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// DeleteUploadResponse is the response for the UploadService.DeleteUpload method. +type DeleteUploadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // or Upload data = 1; or google.protobuf.Empty empty = 1; + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteUploadResponse) Reset() { + *x = DeleteUploadResponse{} + mi := &file_datastore_upload_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUploadResponse) ProtoMessage() {} + +func (x *DeleteUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[9] + 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 DeleteUploadResponse.ProtoReflect.Descriptor instead. +func (*DeleteUploadResponse) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{9} +} + +func (x *DeleteUploadResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_datastore_upload_proto protoreflect.FileDescriptor + +const file_datastore_upload_proto_rawDesc = "" + + "\n" + + "\x16datastore/upload.proto\x12\x16api.v1.services.upload\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15types/datastore.proto\x1a\x17validate/validate.proto\"\xcd\x01\n" + + "\x11ListUploadRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x12\n" + + "\x04type\x18\a \x01(\tR\x04type\"\x88\x02\n" + + "\x12ListUploadResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x125\n" + + "\x04data\x18\x02 \x03(\v2!.api.v1.services.types.DataObjectR\x04data\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"\"\n" + + "\x10GetUploadRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"J\n" + + "\x11GetUploadResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"~\n" + + "\x13CreateUploadRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x18\n" + + "\adata_id\x18\x02 \x01(\tR\adata_id\x125\n" + + "\x04data\x18\x03 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"M\n" + + "\x14CreateUploadResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"\\\n" + + "\x13UpdateUploadRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x125\n" + + "\x04data\x18\x02 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"M\n" + + "\x14UpdateUploadResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"%\n" + + "\x13DeleteUploadRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"D\n" + + "\x14DeleteUploadResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x8e\x05\n" + + "\rUploadService\x12t\n" + + "\n" + + "ListUpload\x12).api.v1.services.upload.ListUploadRequest\x1a*.api.v1.services.upload.ListUploadResponse\"\x0f\x82\xd3\xe4\x93\x02\t\x12\a/upload\x12v\n" + + "\tGetUpload\x12(.api.v1.services.upload.GetUploadRequest\x1a).api.v1.services.upload.GetUploadResponse\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/upload/{id}\x12\x80\x01\n" + + "\fCreateUpload\x12+.api.v1.services.upload.CreateUploadRequest\x1a,.api.v1.services.upload.CreateUploadResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/upload\x12\x8a\x01\n" + + "\fUpdateUpload\x12+.api.v1.services.upload.UpdateUploadRequest\x1a,.api.v1.services.upload.UpdateUploadResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x04data\x1a\x11/upload/{data.id}\x12\x7f\n" + + "\fDeleteUpload\x12+.api.v1.services.upload.DeleteUploadRequest\x1a,.api.v1.services.upload.DeleteUploadResponse\"\x14\x82\xd3\xe4\x93\x02\x0e*\f/upload/{id}B\xe0\x01\n" + + "\x1acom.api.v1.services.uploadB\vUploadProtoP\x01Z9origadmin/application/admin/api/v1/services/upload;upload\xa2\x02\x04AVSU\xaa\x02\x16Api.V1.Services.Upload\xca\x02\x16Api\\V1\\Services\\Upload\xe2\x02\"Api\\V1\\Services\\Upload\\GPBMetadata\xea\x02\x19Api::V1::Services::Uploadb\x06proto3" + +var ( + file_datastore_upload_proto_rawDescOnce sync.Once + file_datastore_upload_proto_rawDescData []byte +) + +func file_datastore_upload_proto_rawDescGZIP() []byte { + file_datastore_upload_proto_rawDescOnce.Do(func() { + file_datastore_upload_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_datastore_upload_proto_rawDesc), len(file_datastore_upload_proto_rawDesc))) + }) + return file_datastore_upload_proto_rawDescData +} + +var file_datastore_upload_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_datastore_upload_proto_goTypes = []any{ + (*ListUploadRequest)(nil), // 0: api.v1.services.upload.ListUploadRequest + (*ListUploadResponse)(nil), // 1: api.v1.services.upload.ListUploadResponse + (*GetUploadRequest)(nil), // 2: api.v1.services.upload.GetUploadRequest + (*GetUploadResponse)(nil), // 3: api.v1.services.upload.GetUploadResponse + (*CreateUploadRequest)(nil), // 4: api.v1.services.upload.CreateUploadRequest + (*CreateUploadResponse)(nil), // 5: api.v1.services.upload.CreateUploadResponse + (*UpdateUploadRequest)(nil), // 6: api.v1.services.upload.UpdateUploadRequest + (*UpdateUploadResponse)(nil), // 7: api.v1.services.upload.UpdateUploadResponse + (*DeleteUploadRequest)(nil), // 8: api.v1.services.upload.DeleteUploadRequest + (*DeleteUploadResponse)(nil), // 9: api.v1.services.upload.DeleteUploadResponse + (*types.DataObject)(nil), // 10: api.v1.services.types.DataObject + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_datastore_upload_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.upload.ListUploadResponse.data:type_name -> api.v1.services.types.DataObject + 11, // 1: api.v1.services.upload.ListUploadResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.upload.GetUploadResponse.data:type_name -> api.v1.services.types.DataObject + 10, // 3: api.v1.services.upload.CreateUploadRequest.data:type_name -> api.v1.services.types.DataObject + 10, // 4: api.v1.services.upload.CreateUploadResponse.data:type_name -> api.v1.services.types.DataObject + 10, // 5: api.v1.services.upload.UpdateUploadRequest.data:type_name -> api.v1.services.types.DataObject + 10, // 6: api.v1.services.upload.UpdateUploadResponse.data:type_name -> api.v1.services.types.DataObject + 12, // 7: api.v1.services.upload.DeleteUploadResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.upload.UploadService.ListUpload:input_type -> api.v1.services.upload.ListUploadRequest + 2, // 9: api.v1.services.upload.UploadService.GetUpload:input_type -> api.v1.services.upload.GetUploadRequest + 4, // 10: api.v1.services.upload.UploadService.CreateUpload:input_type -> api.v1.services.upload.CreateUploadRequest + 6, // 11: api.v1.services.upload.UploadService.UpdateUpload:input_type -> api.v1.services.upload.UpdateUploadRequest + 8, // 12: api.v1.services.upload.UploadService.DeleteUpload:input_type -> api.v1.services.upload.DeleteUploadRequest + 1, // 13: api.v1.services.upload.UploadService.ListUpload:output_type -> api.v1.services.upload.ListUploadResponse + 3, // 14: api.v1.services.upload.UploadService.GetUpload:output_type -> api.v1.services.upload.GetUploadResponse + 5, // 15: api.v1.services.upload.UploadService.CreateUpload:output_type -> api.v1.services.upload.CreateUploadResponse + 7, // 16: api.v1.services.upload.UploadService.UpdateUpload:output_type -> api.v1.services.upload.UpdateUploadResponse + 9, // 17: api.v1.services.upload.UploadService.DeleteUpload:output_type -> api.v1.services.upload.DeleteUploadResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_datastore_upload_proto_init() } +func file_datastore_upload_proto_init() { + if File_datastore_upload_proto != nil { + return + } + file_datastore_upload_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_datastore_upload_proto_rawDesc), len(file_datastore_upload_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_datastore_upload_proto_goTypes, + DependencyIndexes: file_datastore_upload_proto_depIdxs, + MessageInfos: file_datastore_upload_proto_msgTypes, + }.Build() + File_datastore_upload_proto = out.File + file_datastore_upload_proto_goTypes = nil + file_datastore_upload_proto_depIdxs = nil +} diff --git a/api/v1/services/datastore/upload.pb.gw.go b/api/v1/services/datastore/upload.pb.gw.go new file mode 100644 index 00000000..0084a218 --- /dev/null +++ b/api/v1/services/datastore/upload.pb.gw.go @@ -0,0 +1,487 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: datastore/upload.proto + +/* +Package upload is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package upload + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_UploadService_ListUpload_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_UploadService_ListUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListUploadRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_ListUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UploadService_ListUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListUploadRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_ListUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListUpload(ctx, &protoReq) + return msg, metadata, err +} + +func request_UploadService_GetUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetUploadRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UploadService_GetUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetUploadRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetUpload(ctx, &protoReq) + return msg, metadata, err +} + +var filter_UploadService_CreateUpload_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_UploadService_CreateUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateUploadRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_CreateUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UploadService_CreateUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateUploadRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_CreateUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateUpload(ctx, &protoReq) + return msg, metadata, err +} + +var filter_UploadService_UpdateUpload_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_UploadService_UpdateUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateUploadRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["data.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_UpdateUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UploadService_UpdateUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateUploadRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["data.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_UpdateUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateUpload(ctx, &protoReq) + return msg, metadata, err +} + +func request_UploadService_DeleteUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteUploadRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UploadService_DeleteUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteUploadRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteUpload(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterUploadServiceHandlerServer registers the http handlers for service UploadService to "mux". +// UnaryRPC :call UploadServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUploadServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterUploadServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UploadServiceServer) error { + mux.Handle(http.MethodGet, pattern_UploadService_ListUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/ListUpload", runtime.WithHTTPPathPattern("/upload")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UploadService_ListUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_ListUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_UploadService_GetUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/GetUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UploadService_GetUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_GetUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_UploadService_CreateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/CreateUpload", runtime.WithHTTPPathPattern("/upload")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UploadService_CreateUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_CreateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_UploadService_UpdateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/UpdateUpload", runtime.WithHTTPPathPattern("/upload/{data.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UploadService_UpdateUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_UpdateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_UploadService_DeleteUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/DeleteUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UploadService_DeleteUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_DeleteUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterUploadServiceHandlerFromEndpoint is same as RegisterUploadServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterUploadServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterUploadServiceHandler(ctx, mux, conn) +} + +// RegisterUploadServiceHandler registers the http handlers for service UploadService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterUploadServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterUploadServiceHandlerClient(ctx, mux, NewUploadServiceClient(conn)) +} + +// RegisterUploadServiceHandlerClient registers the http handlers for service UploadService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UploadServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UploadServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "UploadServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterUploadServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UploadServiceClient) error { + mux.Handle(http.MethodGet, pattern_UploadService_ListUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/ListUpload", runtime.WithHTTPPathPattern("/upload")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UploadService_ListUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_ListUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_UploadService_GetUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/GetUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UploadService_GetUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_GetUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_UploadService_CreateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/CreateUpload", runtime.WithHTTPPathPattern("/upload")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UploadService_CreateUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_CreateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_UploadService_UpdateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/UpdateUpload", runtime.WithHTTPPathPattern("/upload/{data.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UploadService_UpdateUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_UpdateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_UploadService_DeleteUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/DeleteUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UploadService_DeleteUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_DeleteUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_UploadService_ListUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"upload"}, "")) + pattern_UploadService_GetUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"upload", "id"}, "")) + pattern_UploadService_CreateUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"upload"}, "")) + pattern_UploadService_UpdateUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"upload", "data.id"}, "")) + pattern_UploadService_DeleteUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"upload", "id"}, "")) +) + +var ( + forward_UploadService_ListUpload_0 = runtime.ForwardResponseMessage + forward_UploadService_GetUpload_0 = runtime.ForwardResponseMessage + forward_UploadService_CreateUpload_0 = runtime.ForwardResponseMessage + forward_UploadService_UpdateUpload_0 = runtime.ForwardResponseMessage + forward_UploadService_DeleteUpload_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/datastore/upload.pb.validate.go b/api/v1/services/datastore/upload.pb.validate.go new file mode 100644 index 00000000..57c44c58 --- /dev/null +++ b/api/v1/services/datastore/upload.pb.validate.go @@ -0,0 +1,1327 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: datastore/upload.proto + +package upload + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListUploadRequest 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 *ListUploadRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUploadRequest 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 +// ListUploadRequestMultiError, or nil if none found. +func (m *ListUploadRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUploadRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Type + + if len(errors) > 0 { + return ListUploadRequestMultiError(errors) + } + + return nil +} + +// ListUploadRequestMultiError is an error wrapping multiple validation errors +// returned by ListUploadRequest.ValidateAll() if the designated constraints +// aren't met. +type ListUploadRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUploadRequestMultiError) 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 ListUploadRequestMultiError) AllErrors() []error { return m } + +// ListUploadRequestValidationError is the validation error returned by +// ListUploadRequest.Validate if the designated constraints aren't met. +type ListUploadRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListUploadRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListUploadRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListUploadRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListUploadRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListUploadRequestValidationError) ErrorName() string { + return "ListUploadRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListUploadRequestValidationError) 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 %sListUploadRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListUploadRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListUploadRequestValidationError{} + +// Validate checks the field values on ListUploadResponse 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 *ListUploadResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUploadResponse 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 +// ListUploadResponseMultiError, or nil if none found. +func (m *ListUploadResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUploadResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TotalSize + + for idx, item := range m.GetData() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUploadResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUploadResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListUploadResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUploadResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUploadResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListUploadResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListUploadResponseMultiError(errors) + } + + return nil +} + +// ListUploadResponseMultiError is an error wrapping multiple validation errors +// returned by ListUploadResponse.ValidateAll() if the designated constraints +// aren't met. +type ListUploadResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUploadResponseMultiError) 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 ListUploadResponseMultiError) AllErrors() []error { return m } + +// ListUploadResponseValidationError is the validation error returned by +// ListUploadResponse.Validate if the designated constraints aren't met. +type ListUploadResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListUploadResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListUploadResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListUploadResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListUploadResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListUploadResponseValidationError) ErrorName() string { + return "ListUploadResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListUploadResponseValidationError) 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 %sListUploadResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListUploadResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListUploadResponseValidationError{} + +// Validate checks the field values on GetUploadRequest 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 *GetUploadRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUploadRequest 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 +// GetUploadRequestMultiError, or nil if none found. +func (m *GetUploadRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUploadRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetUploadRequestMultiError(errors) + } + + return nil +} + +// GetUploadRequestMultiError is an error wrapping multiple validation errors +// returned by GetUploadRequest.ValidateAll() if the designated constraints +// aren't met. +type GetUploadRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUploadRequestMultiError) 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 GetUploadRequestMultiError) AllErrors() []error { return m } + +// GetUploadRequestValidationError is the validation error returned by +// GetUploadRequest.Validate if the designated constraints aren't met. +type GetUploadRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUploadRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUploadRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUploadRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUploadRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUploadRequestValidationError) ErrorName() string { return "GetUploadRequestValidationError" } + +// Error satisfies the builtin error interface +func (e GetUploadRequestValidationError) 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 %sGetUploadRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUploadRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUploadRequestValidationError{} + +// Validate checks the field values on GetUploadResponse 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 *GetUploadResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUploadResponse 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 +// GetUploadResponseMultiError, or nil if none found. +func (m *GetUploadResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUploadResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetUploadResponseMultiError(errors) + } + + return nil +} + +// GetUploadResponseMultiError is an error wrapping multiple validation errors +// returned by GetUploadResponse.ValidateAll() if the designated constraints +// aren't met. +type GetUploadResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUploadResponseMultiError) 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 GetUploadResponseMultiError) AllErrors() []error { return m } + +// GetUploadResponseValidationError is the validation error returned by +// GetUploadResponse.Validate if the designated constraints aren't met. +type GetUploadResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUploadResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUploadResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUploadResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUploadResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUploadResponseValidationError) ErrorName() string { + return "GetUploadResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUploadResponseValidationError) 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 %sGetUploadResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUploadResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUploadResponseValidationError{} + +// Validate checks the field values on CreateUploadRequest 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 *CreateUploadRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateUploadRequest 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 +// CreateUploadRequestMultiError, or nil if none found. +func (m *CreateUploadRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateUploadRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for DataId + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateUploadRequestMultiError(errors) + } + + return nil +} + +// CreateUploadRequestMultiError is an error wrapping multiple validation +// errors returned by CreateUploadRequest.ValidateAll() if the designated +// constraints aren't met. +type CreateUploadRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateUploadRequestMultiError) 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 CreateUploadRequestMultiError) AllErrors() []error { return m } + +// CreateUploadRequestValidationError is the validation error returned by +// CreateUploadRequest.Validate if the designated constraints aren't met. +type CreateUploadRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateUploadRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateUploadRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateUploadRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateUploadRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateUploadRequestValidationError) ErrorName() string { + return "CreateUploadRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateUploadRequestValidationError) 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 %sCreateUploadRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateUploadRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateUploadRequestValidationError{} + +// Validate checks the field values on CreateUploadResponse 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 *CreateUploadResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateUploadResponse 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 +// CreateUploadResponseMultiError, or nil if none found. +func (m *CreateUploadResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateUploadResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateUploadResponseMultiError(errors) + } + + return nil +} + +// CreateUploadResponseMultiError is an error wrapping multiple validation +// errors returned by CreateUploadResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateUploadResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateUploadResponseMultiError) 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 CreateUploadResponseMultiError) AllErrors() []error { return m } + +// CreateUploadResponseValidationError is the validation error returned by +// CreateUploadResponse.Validate if the designated constraints aren't met. +type CreateUploadResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateUploadResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateUploadResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateUploadResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateUploadResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateUploadResponseValidationError) ErrorName() string { + return "CreateUploadResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateUploadResponseValidationError) 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 %sCreateUploadResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateUploadResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateUploadResponseValidationError{} + +// Validate checks the field values on UpdateUploadRequest 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 *UpdateUploadRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUploadRequest 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 +// UpdateUploadRequestMultiError, or nil if none found. +func (m *UpdateUploadRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUploadRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateUploadRequestMultiError(errors) + } + + return nil +} + +// UpdateUploadRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateUploadRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateUploadRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUploadRequestMultiError) 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 UpdateUploadRequestMultiError) AllErrors() []error { return m } + +// UpdateUploadRequestValidationError is the validation error returned by +// UpdateUploadRequest.Validate if the designated constraints aren't met. +type UpdateUploadRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUploadRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUploadRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUploadRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUploadRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUploadRequestValidationError) ErrorName() string { + return "UpdateUploadRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUploadRequestValidationError) 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 %sUpdateUploadRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUploadRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUploadRequestValidationError{} + +// Validate checks the field values on UpdateUploadResponse 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 *UpdateUploadResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUploadResponse 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 +// UpdateUploadResponseMultiError, or nil if none found. +func (m *UpdateUploadResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUploadResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateUploadResponseMultiError(errors) + } + + return nil +} + +// UpdateUploadResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateUploadResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateUploadResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUploadResponseMultiError) 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 UpdateUploadResponseMultiError) AllErrors() []error { return m } + +// UpdateUploadResponseValidationError is the validation error returned by +// UpdateUploadResponse.Validate if the designated constraints aren't met. +type UpdateUploadResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUploadResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUploadResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUploadResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUploadResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUploadResponseValidationError) ErrorName() string { + return "UpdateUploadResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUploadResponseValidationError) 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 %sUpdateUploadResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUploadResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUploadResponseValidationError{} + +// Validate checks the field values on DeleteUploadRequest 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 *DeleteUploadRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteUploadRequest 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 +// DeleteUploadRequestMultiError, or nil if none found. +func (m *DeleteUploadRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteUploadRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeleteUploadRequestMultiError(errors) + } + + return nil +} + +// DeleteUploadRequestMultiError is an error wrapping multiple validation +// errors returned by DeleteUploadRequest.ValidateAll() if the designated +// constraints aren't met. +type DeleteUploadRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteUploadRequestMultiError) 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 DeleteUploadRequestMultiError) AllErrors() []error { return m } + +// DeleteUploadRequestValidationError is the validation error returned by +// DeleteUploadRequest.Validate if the designated constraints aren't met. +type DeleteUploadRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteUploadRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteUploadRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteUploadRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteUploadRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteUploadRequestValidationError) ErrorName() string { + return "DeleteUploadRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteUploadRequestValidationError) 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 %sDeleteUploadRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteUploadRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteUploadRequestValidationError{} + +// Validate checks the field values on DeleteUploadResponse 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 *DeleteUploadResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteUploadResponse 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 +// DeleteUploadResponseMultiError, or nil if none found. +func (m *DeleteUploadResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteUploadResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteUploadResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteUploadResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteUploadResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteUploadResponseMultiError(errors) + } + + return nil +} + +// DeleteUploadResponseMultiError is an error wrapping multiple validation +// errors returned by DeleteUploadResponse.ValidateAll() if the designated +// constraints aren't met. +type DeleteUploadResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteUploadResponseMultiError) 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 DeleteUploadResponseMultiError) AllErrors() []error { return m } + +// DeleteUploadResponseValidationError is the validation error returned by +// DeleteUploadResponse.Validate if the designated constraints aren't met. +type DeleteUploadResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteUploadResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteUploadResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteUploadResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteUploadResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteUploadResponseValidationError) ErrorName() string { + return "DeleteUploadResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteUploadResponseValidationError) 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 %sDeleteUploadResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteUploadResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteUploadResponseValidationError{} diff --git a/api/v1/services/datastore/upload_bridge.pb.go b/api/v1/services/datastore/upload_bridge.pb.go new file mode 100644 index 00000000..0043c929 --- /dev/null +++ b/api/v1/services/datastore/upload_bridge.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: datastore/upload.proto + +package upload + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const UploadServiceCreateUploadBridgeOperation = "/api.v1.services.upload.UploadService/CreateUpload" +const UploadServiceDeleteUploadBridgeOperation = "/api.v1.services.upload.UploadService/DeleteUpload" +const UploadServiceGetUploadBridgeOperation = "/api.v1.services.upload.UploadService/GetUpload" +const UploadServiceListUploadBridgeOperation = "/api.v1.services.upload.UploadService/ListUpload" +const UploadServiceUpdateUploadBridgeOperation = "/api.v1.services.upload.UploadService/UpdateUpload" + +type UploadServiceBridgeServer interface { + CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) + DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) + GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) + ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) + UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) +} + +type UploadServiceHooker interface { + UploadServiceCreateUploadHooker + UploadServiceDeleteUploadHooker + UploadServiceGetUploadHooker + UploadServiceListUploadHooker + UploadServiceUpdateUploadHooker +} + +type UploadServiceHookedBridger interface { + UploadServiceHooker + UploadServiceBridgeServer +} +type UploadServiceCreateUploadHooker interface { + PrepareCreateUpload(http.Context, *CreateUploadRequest) (context.Context, error) + CompleteCreateUpload(http.Context, *CreateUploadRequest, *CreateUploadResponse) error +} +type UploadServiceDeleteUploadHooker interface { + PrepareDeleteUpload(http.Context, *DeleteUploadRequest) (context.Context, error) + CompleteDeleteUpload(http.Context, *DeleteUploadRequest, *DeleteUploadResponse) error +} +type UploadServiceGetUploadHooker interface { + PrepareGetUpload(http.Context, *GetUploadRequest) (context.Context, error) + CompleteGetUpload(http.Context, *GetUploadRequest, *GetUploadResponse) error +} +type UploadServiceListUploadHooker interface { + PrepareListUpload(http.Context, *ListUploadRequest) (context.Context, error) + CompleteListUpload(http.Context, *ListUploadRequest, *ListUploadResponse) error +} +type UploadServiceUpdateUploadHooker interface { + PrepareUpdateUpload(http.Context, *UpdateUploadRequest) (context.Context, error) + CompleteUpdateUpload(http.Context, *UpdateUploadRequest, *UpdateUploadResponse) error +} + +func RegisterUploadServiceBridgeServer(s *http.Server, srv UploadServiceHookedBridger) { + r := s.Route("/") + r.GET("/upload", _UploadService_ListUpload0_Bridge_Handler(srv)) + r.GET("/upload/:id", _UploadService_GetUpload0_Bridge_Handler(srv)) + r.POST("/upload", _UploadService_CreateUpload0_Bridge_Handler(srv)) + r.PUT("/upload/:data.id", _UploadService_UpdateUpload0_Bridge_Handler(srv)) + r.DELETE("/upload/:id", _UploadService_DeleteUpload0_Bridge_Handler(srv)) +} + +func _UploadService_ListUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceListUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUpload(ctx, req.(*ListUploadRequest)) + }) + + newctx, err := srv.PrepareListUpload(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListUpload(ctx, &in, out.(*ListUploadResponse)) + } +} + +func _UploadService_GetUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceGetUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUpload(ctx, req.(*GetUploadRequest)) + }) + + newctx, err := srv.PrepareGetUpload(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetUpload(ctx, &in, out.(*GetUploadResponse)) + } +} + +func _UploadService_CreateUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateUploadRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceCreateUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateUpload(ctx, req.(*CreateUploadRequest)) + }) + + newctx, err := srv.PrepareCreateUpload(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateUpload(ctx, &in, out.(*CreateUploadResponse)) + } +} + +func _UploadService_UpdateUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUploadRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceUpdateUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUpload(ctx, req.(*UpdateUploadRequest)) + }) + + newctx, err := srv.PrepareUpdateUpload(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateUpload(ctx, &in, out.(*UpdateUploadResponse)) + } +} + +func _UploadService_DeleteUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceDeleteUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteUpload(ctx, req.(*DeleteUploadRequest)) + }) + + newctx, err := srv.PrepareDeleteUpload(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteUpload(ctx, &in, out.(*DeleteUploadResponse)) + } +} + +// UnimplementedUploadServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedUploadServiceHooked struct{} + +func (UnimplementedUploadServiceHooked) PrepareCreateUpload(ctx http.Context, in *CreateUploadRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUploadServiceHooked) CompleteCreateUpload(ctx http.Context, in *CreateUploadRequest, out *CreateUploadResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUploadServiceHooked) PrepareDeleteUpload(ctx http.Context, in *DeleteUploadRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUploadServiceHooked) CompleteDeleteUpload(ctx http.Context, in *DeleteUploadRequest, out *DeleteUploadResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUploadServiceHooked) PrepareGetUpload(ctx http.Context, in *GetUploadRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUploadServiceHooked) CompleteGetUpload(ctx http.Context, in *GetUploadRequest, out *GetUploadResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUploadServiceHooked) PrepareListUpload(ctx http.Context, in *ListUploadRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUploadServiceHooked) CompleteListUpload(ctx http.Context, in *ListUploadRequest, out *ListUploadResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUploadServiceHooked) PrepareUpdateUpload(ctx http.Context, in *UpdateUploadRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUploadServiceHooked) CompleteUpdateUpload(ctx http.Context, in *UpdateUploadRequest, out *UpdateUploadResponse) error { + return ctx.Result(200, out) +} + +func WithUploadServiceHook(h UploadServiceHooker) func(UploadServiceBridgeServer) UploadServiceHookedBridger { + return func(srv UploadServiceBridgeServer) UploadServiceHookedBridger { + return UploadServiceHookedBridge{UploadServiceBridgeServer: srv, UploadServiceHooker: h} + } +} + +// UploadServiceHookedBridge is a bridge between the HTTP and gRPC implementations of UploadService. +// It implements the HTTP and gRPC implementations of UploadService. +// It forwards requests and responses between the two implementations. +type UploadServiceHookedBridge struct { + UploadServiceBridgeServer + UploadServiceHooker +} + +type UploadServiceHTTPBridgeImpl struct { + client UploadServiceHTTPClient +} + +func NewUploadServiceHTTPBridge(client *http.Client) UploadServiceHTTPServer { + return &UploadServiceHTTPBridgeImpl{client: NewUploadServiceHTTPClient(client)} +} + +func (c *UploadServiceHTTPBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) +} + +func (c *UploadServiceHTTPBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + +func (c *UploadServiceHTTPBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { + return c.client.GetUpload(ctx, in) +} + +func (c *UploadServiceHTTPBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) +} + +func (c *UploadServiceHTTPBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { + return c.client.UpdateUpload(ctx, in) +} + +type UploadServiceBridgeImpl struct { + client UploadServiceClient +} + +func NewUploadServiceBridge(client grpc.ClientConnInterface) UploadServiceServer { + return &UploadServiceBridgeImpl{client: NewUploadServiceClient(client)} +} + +func (c *UploadServiceBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) +} + +func (c *UploadServiceBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + +func (c *UploadServiceBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { + return c.client.GetUpload(ctx, in) +} + +func (c *UploadServiceBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) +} + +func (c *UploadServiceBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { + return c.client.UpdateUpload(ctx, in) +} + +func (c *UploadServiceBridgeImpl) mustEmbedUnimplementedUploadServiceServer() {} + +type UploadServiceGRPC2HTTPBridgeImpl struct { + client UploadServiceClient +} + +func NewUploadServiceGRPC2HTTP(client grpc.ClientConnInterface) UploadServiceHTTPServer { + return &UploadServiceGRPC2HTTPBridgeImpl{client: NewUploadServiceClient(client)} +} + +func (c *UploadServiceGRPC2HTTPBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) +} + +func (c *UploadServiceGRPC2HTTPBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + +func (c *UploadServiceGRPC2HTTPBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { + return c.client.GetUpload(ctx, in) +} + +func (c *UploadServiceGRPC2HTTPBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) +} + +func (c *UploadServiceGRPC2HTTPBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { + return c.client.UpdateUpload(ctx, in) +} + +type UploadServiceHTTP2GRPCBridgeImpl struct { + client UploadServiceHTTPClient +} + +func NewUploadServiceHTTP2GRPC(client *http.Client) UploadServiceServer { + return &UploadServiceHTTP2GRPCBridgeImpl{client: NewUploadServiceHTTPClient(client)} +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { + return c.client.GetUpload(ctx, in) +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { + return c.client.UpdateUpload(ctx, in) +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedUploadServiceServer() {} diff --git a/api/v1/services/datastore/upload_grpc.pb.go b/api/v1/services/datastore/upload_grpc.pb.go new file mode 100644 index 00000000..8f0238b8 --- /dev/null +++ b/api/v1/services/datastore/upload_grpc.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: datastore/upload.proto + +package upload + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + UploadService_ListUpload_FullMethodName = "/api.v1.services.upload.UploadService/ListUpload" + UploadService_GetUpload_FullMethodName = "/api.v1.services.upload.UploadService/GetUpload" + UploadService_CreateUpload_FullMethodName = "/api.v1.services.upload.UploadService/CreateUpload" + UploadService_UpdateUpload_FullMethodName = "/api.v1.services.upload.UploadService/UpdateUpload" + UploadService_DeleteUpload_FullMethodName = "/api.v1.services.upload.UploadService/DeleteUpload" +) + +// UploadServiceClient is the client API for UploadService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The data service definition. +type UploadServiceClient interface { + ListUpload(ctx context.Context, in *ListUploadRequest, opts ...grpc.CallOption) (*ListUploadResponse, error) + GetUpload(ctx context.Context, in *GetUploadRequest, opts ...grpc.CallOption) (*GetUploadResponse, error) + CreateUpload(ctx context.Context, in *CreateUploadRequest, opts ...grpc.CallOption) (*CreateUploadResponse, error) + UpdateUpload(ctx context.Context, in *UpdateUploadRequest, opts ...grpc.CallOption) (*UpdateUploadResponse, error) + DeleteUpload(ctx context.Context, in *DeleteUploadRequest, opts ...grpc.CallOption) (*DeleteUploadResponse, error) +} + +type uploadServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewUploadServiceClient(cc grpc.ClientConnInterface) UploadServiceClient { + return &uploadServiceClient{cc} +} + +func (c *uploadServiceClient) ListUpload(ctx context.Context, in *ListUploadRequest, opts ...grpc.CallOption) (*ListUploadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListUploadResponse) + err := c.cc.Invoke(ctx, UploadService_ListUpload_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *uploadServiceClient) GetUpload(ctx context.Context, in *GetUploadRequest, opts ...grpc.CallOption) (*GetUploadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetUploadResponse) + err := c.cc.Invoke(ctx, UploadService_GetUpload_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *uploadServiceClient) CreateUpload(ctx context.Context, in *CreateUploadRequest, opts ...grpc.CallOption) (*CreateUploadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateUploadResponse) + err := c.cc.Invoke(ctx, UploadService_CreateUpload_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *uploadServiceClient) UpdateUpload(ctx context.Context, in *UpdateUploadRequest, opts ...grpc.CallOption) (*UpdateUploadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateUploadResponse) + err := c.cc.Invoke(ctx, UploadService_UpdateUpload_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *uploadServiceClient) DeleteUpload(ctx context.Context, in *DeleteUploadRequest, opts ...grpc.CallOption) (*DeleteUploadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteUploadResponse) + err := c.cc.Invoke(ctx, UploadService_DeleteUpload_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// UploadServiceServer is the server API for UploadService service. +// All implementations must embed UnimplementedUploadServiceServer +// for forward compatibility. +// +// The data service definition. +type UploadServiceServer interface { + ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) + GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) + CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) + UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) + DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) + mustEmbedUnimplementedUploadServiceServer() +} + +// UnimplementedUploadServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedUploadServiceServer struct{} + +func (UnimplementedUploadServiceServer) ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListUpload not implemented") +} +func (UnimplementedUploadServiceServer) GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUpload not implemented") +} +func (UnimplementedUploadServiceServer) CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateUpload not implemented") +} +func (UnimplementedUploadServiceServer) UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateUpload not implemented") +} +func (UnimplementedUploadServiceServer) DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteUpload not implemented") +} +func (UnimplementedUploadServiceServer) mustEmbedUnimplementedUploadServiceServer() {} +func (UnimplementedUploadServiceServer) testEmbeddedByValue() {} + +// UnsafeUploadServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to UploadServiceServer will +// result in compilation errors. +type UnsafeUploadServiceServer interface { + mustEmbedUnimplementedUploadServiceServer() +} + +func RegisterUploadServiceServer(s grpc.ServiceRegistrar, srv UploadServiceServer) { + // If the following call pancis, it indicates UnimplementedUploadServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&UploadService_ServiceDesc, srv) +} + +func _UploadService_ListUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListUploadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UploadServiceServer).ListUpload(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UploadService_ListUpload_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UploadServiceServer).ListUpload(ctx, req.(*ListUploadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UploadService_GetUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUploadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UploadServiceServer).GetUpload(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UploadService_GetUpload_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UploadServiceServer).GetUpload(ctx, req.(*GetUploadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UploadService_CreateUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateUploadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UploadServiceServer).CreateUpload(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UploadService_CreateUpload_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UploadServiceServer).CreateUpload(ctx, req.(*CreateUploadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UploadService_UpdateUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateUploadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UploadServiceServer).UpdateUpload(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UploadService_UpdateUpload_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UploadServiceServer).UpdateUpload(ctx, req.(*UpdateUploadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UploadService_DeleteUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteUploadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UploadServiceServer).DeleteUpload(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UploadService_DeleteUpload_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UploadServiceServer).DeleteUpload(ctx, req.(*DeleteUploadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// UploadService_ServiceDesc is the grpc.ServiceDesc for UploadService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var UploadService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.upload.UploadService", + HandlerType: (*UploadServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListUpload", + Handler: _UploadService_ListUpload_Handler, + }, + { + MethodName: "GetUpload", + Handler: _UploadService_GetUpload_Handler, + }, + { + MethodName: "CreateUpload", + Handler: _UploadService_CreateUpload_Handler, + }, + { + MethodName: "UpdateUpload", + Handler: _UploadService_UpdateUpload_Handler, + }, + { + MethodName: "DeleteUpload", + Handler: _UploadService_DeleteUpload_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "datastore/upload.proto", +} diff --git a/api/v1/services/datastore/upload_http.pb.go b/api/v1/services/datastore/upload_http.pb.go new file mode 100644 index 00000000..2162bd5d --- /dev/null +++ b/api/v1/services/datastore/upload_http.pb.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: datastore/upload.proto + +package upload + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationUploadServiceCreateUpload = "/api.v1.services.upload.UploadService/CreateUpload" +const OperationUploadServiceDeleteUpload = "/api.v1.services.upload.UploadService/DeleteUpload" +const OperationUploadServiceGetUpload = "/api.v1.services.upload.UploadService/GetUpload" +const OperationUploadServiceListUpload = "/api.v1.services.upload.UploadService/ListUpload" +const OperationUploadServiceUpdateUpload = "/api.v1.services.upload.UploadService/UpdateUpload" + +type UploadServiceHTTPServer interface { + CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) + DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) + GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) + ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) + UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) +} + +func RegisterUploadServiceHTTPServer(s *http.Server, srv UploadServiceHTTPServer) { + r := s.Route("/") + r.GET("/upload", _UploadService_ListUpload0_HTTP_Handler(srv)) + r.GET("/upload/{id}", _UploadService_GetUpload0_HTTP_Handler(srv)) + r.POST("/upload", _UploadService_CreateUpload0_HTTP_Handler(srv)) + r.PUT("/upload/{data.id}", _UploadService_UpdateUpload0_HTTP_Handler(srv)) + r.DELETE("/upload/{id}", _UploadService_DeleteUpload0_HTTP_Handler(srv)) +} + +func _UploadService_ListUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceListUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUpload(ctx, req.(*ListUploadRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListUploadResponse) + return ctx.Result(200, reply) + } +} + +func _UploadService_GetUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceGetUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUpload(ctx, req.(*GetUploadRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetUploadResponse) + return ctx.Result(200, reply) + } +} + +func _UploadService_CreateUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateUploadRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceCreateUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateUpload(ctx, req.(*CreateUploadRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateUploadResponse) + return ctx.Result(200, reply) + } +} + +func _UploadService_UpdateUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUploadRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceUpdateUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUpload(ctx, req.(*UpdateUploadRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateUploadResponse) + return ctx.Result(200, reply) + } +} + +func _UploadService_DeleteUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceDeleteUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteUpload(ctx, req.(*DeleteUploadRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeleteUploadResponse) + return ctx.Result(200, reply) + } +} + +type UploadServiceHTTPClient interface { + CreateUpload(ctx context.Context, req *CreateUploadRequest, opts ...http.CallOption) (rsp *CreateUploadResponse, err error) + DeleteUpload(ctx context.Context, req *DeleteUploadRequest, opts ...http.CallOption) (rsp *DeleteUploadResponse, err error) + GetUpload(ctx context.Context, req *GetUploadRequest, opts ...http.CallOption) (rsp *GetUploadResponse, err error) + ListUpload(ctx context.Context, req *ListUploadRequest, opts ...http.CallOption) (rsp *ListUploadResponse, err error) + UpdateUpload(ctx context.Context, req *UpdateUploadRequest, opts ...http.CallOption) (rsp *UpdateUploadResponse, err error) +} + +type UploadServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewUploadServiceHTTPClient(client *http.Client) UploadServiceHTTPClient { + return &UploadServiceHTTPClientImpl{client} +} + +func (c *UploadServiceHTTPClientImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest, opts ...http.CallOption) (*CreateUploadResponse, error) { + var out CreateUploadResponse + pattern := "/upload" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationUploadServiceCreateUpload)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UploadServiceHTTPClientImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest, opts ...http.CallOption) (*DeleteUploadResponse, error) { + var out DeleteUploadResponse + pattern := "/upload/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationUploadServiceDeleteUpload)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UploadServiceHTTPClientImpl) GetUpload(ctx context.Context, in *GetUploadRequest, opts ...http.CallOption) (*GetUploadResponse, error) { + var out GetUploadResponse + pattern := "/upload/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationUploadServiceGetUpload)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UploadServiceHTTPClientImpl) ListUpload(ctx context.Context, in *ListUploadRequest, opts ...http.CallOption) (*ListUploadResponse, error) { + var out ListUploadResponse + pattern := "/upload" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationUploadServiceListUpload)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UploadServiceHTTPClientImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest, opts ...http.CallOption) (*UpdateUploadResponse, error) { + var out UpdateUploadResponse + pattern := "/upload/{data.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationUploadServiceUpdateUpload)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/message/message.pb.go b/api/v1/services/message/message.pb.go new file mode 100644 index 00000000..be871264 --- /dev/null +++ b/api/v1/services/message/message.pb.go @@ -0,0 +1,1074 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: message/message.proto + +package message + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UpdatePersonalSettingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalSettingRequest) Reset() { + *x = UpdatePersonalSettingRequest{} + mi := &file_message_message_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalSettingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalSettingRequest) ProtoMessage() {} + +func (x *UpdatePersonalSettingRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[0] + 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 UpdatePersonalSettingRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalSettingRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{0} +} + +func (x *UpdatePersonalSettingRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalSettingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalSettingResponse) Reset() { + *x = UpdatePersonalSettingResponse{} + mi := &file_message_message_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalSettingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalSettingResponse) ProtoMessage() {} + +func (x *UpdatePersonalSettingResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[1] + 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 UpdatePersonalSettingResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalSettingResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{1} +} + +type UpdatePersonalRoleRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalRoleRequest) Reset() { + *x = UpdatePersonalRoleRequest{} + mi := &file_message_message_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalRoleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalRoleRequest) ProtoMessage() {} + +func (x *UpdatePersonalRoleRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[2] + 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 UpdatePersonalRoleRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalRoleRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{2} +} + +func (x *UpdatePersonalRoleRequest) GetRole() *types.Role { + if x != nil { + return x.Role + } + return nil +} + +type UpdatePersonalRoleResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalRoleResponse) Reset() { + *x = UpdatePersonalRoleResponse{} + mi := &file_message_message_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalRoleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalRoleResponse) ProtoMessage() {} + +func (x *UpdatePersonalRoleResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[3] + 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 UpdatePersonalRoleResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalRoleResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{3} +} + +type ListPersonalResourcesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalResourcesRequest) Reset() { + *x = ListPersonalResourcesRequest{} + mi := &file_message_message_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalResourcesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalResourcesRequest) ProtoMessage() {} + +func (x *ListPersonalResourcesRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[4] + 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 ListPersonalResourcesRequest.ProtoReflect.Descriptor instead. +func (*ListPersonalResourcesRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{4} +} + +func (x *ListPersonalResourcesRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListPersonalResourcesRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListPersonalResourcesRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +type ListPersonalResourcesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + TotalSize int64 `protobuf:"varint,1,opt,name=total_size,json=total,proto3" json:"total_size,omitempty"` + // list of resources + Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalResourcesResponse) Reset() { + *x = ListPersonalResourcesResponse{} + mi := &file_message_message_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalResourcesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalResourcesResponse) ProtoMessage() {} + +func (x *ListPersonalResourcesResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[5] + 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 ListPersonalResourcesResponse.ProtoReflect.Descriptor instead. +func (*ListPersonalResourcesResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{5} +} + +func (x *ListPersonalResourcesResponse) GetTotalSize() int64 { + if x != nil { + return x.TotalSize + } + return 0 +} + +func (x *ListPersonalResourcesResponse) GetResources() []*types.Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *ListPersonalResourcesResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +type UpdatePersonalPasswordRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalPasswordRequest) Reset() { + *x = UpdatePersonalPasswordRequest{} + mi := &file_message_message_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalPasswordRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalPasswordRequest) ProtoMessage() {} + +func (x *UpdatePersonalPasswordRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_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 UpdatePersonalPasswordRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalPasswordRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdatePersonalPasswordRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalPasswordResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalPasswordResponse) Reset() { + *x = UpdatePersonalPasswordResponse{} + mi := &file_message_message_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalPasswordResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalPasswordResponse) ProtoMessage() {} + +func (x *UpdatePersonalPasswordResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdatePersonalPasswordResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalPasswordResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{7} +} + +type PersonalPasswordRestRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalPasswordRestRequest) Reset() { + *x = PersonalPasswordRestRequest{} + mi := &file_message_message_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalPasswordRestRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalPasswordRestRequest) ProtoMessage() {} + +func (x *PersonalPasswordRestRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[8] + 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 PersonalPasswordRestRequest.ProtoReflect.Descriptor instead. +func (*PersonalPasswordRestRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{8} +} + +func (x *PersonalPasswordRestRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type PersonalPasswordRestResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalPasswordRestResponse) Reset() { + *x = PersonalPasswordRestResponse{} + mi := &file_message_message_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalPasswordRestResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalPasswordRestResponse) ProtoMessage() {} + +func (x *PersonalPasswordRestResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[9] + 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 PersonalPasswordRestResponse.ProtoReflect.Descriptor instead. +func (*PersonalPasswordRestResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{9} +} + +type UpdatePersonalProfileRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalProfileRequest) Reset() { + *x = UpdatePersonalProfileRequest{} + mi := &file_message_message_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalProfileRequest) ProtoMessage() {} + +func (x *UpdatePersonalProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[10] + 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 UpdatePersonalProfileRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalProfileRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{10} +} + +func (x *UpdatePersonalProfileRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalProfileResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalProfileResponse) Reset() { + *x = UpdatePersonalProfileResponse{} + mi := &file_message_message_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalProfileResponse) ProtoMessage() {} + +func (x *UpdatePersonalProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[11] + 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 UpdatePersonalProfileResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalProfileResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{11} +} + +type PersonalLogoutRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalLogoutRequest) Reset() { + *x = PersonalLogoutRequest{} + mi := &file_message_message_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalLogoutRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalLogoutRequest) ProtoMessage() {} + +func (x *PersonalLogoutRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[12] + 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 PersonalLogoutRequest.ProtoReflect.Descriptor instead. +func (*PersonalLogoutRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{12} +} + +func (x *PersonalLogoutRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type PersonalLogoutResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalLogoutResponse) Reset() { + *x = PersonalLogoutResponse{} + mi := &file_message_message_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalLogoutResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalLogoutResponse) ProtoMessage() {} + +func (x *PersonalLogoutResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[13] + 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 PersonalLogoutResponse.ProtoReflect.Descriptor instead. +func (*PersonalLogoutResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{13} +} + +func (x *PersonalLogoutResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +type ListPersonalRolesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalRolesRequest) Reset() { + *x = ListPersonalRolesRequest{} + mi := &file_message_message_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalRolesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalRolesRequest) ProtoMessage() {} + +func (x *ListPersonalRolesRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[14] + 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 ListPersonalRolesRequest.ProtoReflect.Descriptor instead. +func (*ListPersonalRolesRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{14} +} + +type ListPersonalRolesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Roles []*types.Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalRolesResponse) Reset() { + *x = ListPersonalRolesResponse{} + mi := &file_message_message_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalRolesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalRolesResponse) ProtoMessage() {} + +func (x *ListPersonalRolesResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[15] + 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 ListPersonalRolesResponse.ProtoReflect.Descriptor instead. +func (*ListPersonalRolesResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{15} +} + +func (x *ListPersonalRolesResponse) GetRoles() []*types.Role { + if x != nil { + return x.Roles + } + return nil +} + +type GetPersonalProfileRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPersonalProfileRequest) Reset() { + *x = GetPersonalProfileRequest{} + mi := &file_message_message_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPersonalProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPersonalProfileRequest) ProtoMessage() {} + +func (x *GetPersonalProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[16] + 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 GetPersonalProfileRequest.ProtoReflect.Descriptor instead. +func (*GetPersonalProfileRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{16} +} + +type GetPersonalProfileResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPersonalProfileResponse) Reset() { + *x = GetPersonalProfileResponse{} + mi := &file_message_message_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPersonalProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPersonalProfileResponse) ProtoMessage() {} + +func (x *GetPersonalProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[17] + 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 GetPersonalProfileResponse.ProtoReflect.Descriptor instead. +func (*GetPersonalProfileResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{17} +} + +func (x *GetPersonalProfileResponse) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +type RefreshPersonalTokenRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshPersonalTokenRequest) Reset() { + *x = RefreshPersonalTokenRequest{} + mi := &file_message_message_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshPersonalTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshPersonalTokenRequest) ProtoMessage() {} + +func (x *RefreshPersonalTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshPersonalTokenRequest.ProtoReflect.Descriptor instead. +func (*RefreshPersonalTokenRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{18} +} + +func (x *RefreshPersonalTokenRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type RefreshPersonalTokenResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshPersonalTokenResponse) Reset() { + *x = RefreshPersonalTokenResponse{} + mi := &file_message_message_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshPersonalTokenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshPersonalTokenResponse) ProtoMessage() {} + +func (x *RefreshPersonalTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshPersonalTokenResponse.ProtoReflect.Descriptor instead. +func (*RefreshPersonalTokenResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{19} +} + +func (x *RefreshPersonalTokenResponse) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +var File_message_message_proto protoreflect.FileDescriptor + +const file_message_message_proto_rawDesc = "" + + "\n" + + "\x15message/message.proto\x12\x17api.v1.services.message\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12types/system.proto\x1a\x17validate/validate.proto\"H\n" + + "\x1cUpdatePersonalSettingRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + + "\x1dUpdatePersonalSettingResponse\"L\n" + + "\x19UpdatePersonalRoleRequest\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\x1c\n" + + "\x1aUpdatePersonalRoleResponse\"\xc4\x01\n" + + "\x1cListPersonalResourcesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\"\xa3\x01\n" + + "\x1dListPersonalResourcesResponse\x12\x19\n" + + "\n" + + "total_size\x18\x01 \x01(\x03R\x05total\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\"I\n" + + "\x1dUpdatePersonalPasswordRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\" \n" + + "\x1eUpdatePersonalPasswordResponse\"6\n" + + "\x1bPersonalPasswordRestRequest\x12\x17\n" + + "\x02id\x18\x01 \x01(\x03B\a\xfaB\x04\"\x02 \x00R\x02id\"\x1e\n" + + "\x1cPersonalPasswordRestResponse\"H\n" + + "\x1cUpdatePersonalProfileRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + + "\x1dUpdatePersonalProfileResponse\"A\n" + + "\x15PersonalLogoutRequest\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"2\n" + + "\x16PersonalLogoutResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\"\x1a\n" + + "\x18ListPersonalRolesRequest\"N\n" + + "\x19ListPersonalRolesResponse\x121\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x1b\n" + + "\x19GetPersonalProfileRequest\"M\n" + + "\x1aGetPersonalProfileResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + + "\x1bRefreshPersonalTokenRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"4\n" + + "\x1cRefreshPersonalTokenResponse\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token2\xeb\n" + + "\n" + + "\x0fPersonalService\x12\xa0\x01\n" + + "\x12GetPersonalProfile\x122.api.v1.services.message.GetPersonalProfileRequest\x1a3.api.v1.services.message.GetPersonalProfileResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/message/personal/profile\x12\xab\x01\n" + + "\x15ListPersonalResources\x125.api.v1.services.message.ListPersonalResourcesRequest\x1a6.api.v1.services.message.ListPersonalResourcesResponse\"#\x82\xd3\xe4\x93\x02\x1d\x12\x1b/message/personal/resources\x12\x9b\x01\n" + + "\x11ListPersonalRoles\x121.api.v1.services.message.ListPersonalRolesRequest\x1a2.api.v1.services.message.ListPersonalRolesResponse\"\x1f\x82\xd3\xe4\x93\x02\x19\x12\x17/message/personal/roles\x12\x99\x01\n" + + "\x0ePersonalLogout\x12..api.v1.services.message.PersonalLogoutRequest\x1a/.api.v1.services.message.PersonalLogoutResponse\"&\x82\xd3\xe4\x93\x02 :\x04data\"\x18/message/personal/logout\x12\xb2\x01\n" + + "\x14RefreshPersonalToken\x124.api.v1.services.message.RefreshPersonalTokenRequest\x1a5.api.v1.services.message.RefreshPersonalTokenResponse\"-\x82\xd3\xe4\x93\x02':\x04data\"\x1f/message/personal/token/refresh\x12\xb3\x01\n" + + "\x16UpdatePersonalPassword\x126.api.v1.services.message.UpdatePersonalPasswordRequest\x1a7.api.v1.services.message.UpdatePersonalPasswordResponse\"(\x82\xd3\xe4\x93\x02\":\x04data\x1a\x1a/message/personal/password\x12\xaf\x01\n" + + "\x15UpdatePersonalProfile\x125.api.v1.services.message.UpdatePersonalProfileRequest\x1a6.api.v1.services.message.UpdatePersonalProfileResponse\"'\x82\xd3\xe4\x93\x02!:\x04data\x1a\x19/message/personal/profile\x12\xaf\x01\n" + + "\x15UpdatePersonalSetting\x125.api.v1.services.message.UpdatePersonalSettingRequest\x1a6.api.v1.services.message.UpdatePersonalSettingResponse\"'\x82\xd3\xe4\x93\x02!:\x04data\x1a\x19/message/personal/settingB\xe8\x01\n" + + "\x1bcom.api.v1.services.messageB\fMessageProtoP\x01Z;origadmin/application/admin/api/v1/services/message;message\xa2\x02\x04AVSM\xaa\x02\x17Api.V1.Services.Message\xca\x02\x17Api\\V1\\Services\\Message\xe2\x02#Api\\V1\\Services\\Message\\GPBMetadata\xea\x02\x1aApi::V1::Services::Messageb\x06proto3" + +var ( + file_message_message_proto_rawDescOnce sync.Once + file_message_message_proto_rawDescData []byte +) + +func file_message_message_proto_rawDescGZIP() []byte { + file_message_message_proto_rawDescOnce.Do(func() { + file_message_message_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_message_message_proto_rawDesc), len(file_message_message_proto_rawDesc))) + }) + return file_message_message_proto_rawDescData +} + +var file_message_message_proto_msgTypes = make([]protoimpl.MessageInfo, 20) +var file_message_message_proto_goTypes = []any{ + (*UpdatePersonalSettingRequest)(nil), // 0: api.v1.services.message.UpdatePersonalSettingRequest + (*UpdatePersonalSettingResponse)(nil), // 1: api.v1.services.message.UpdatePersonalSettingResponse + (*UpdatePersonalRoleRequest)(nil), // 2: api.v1.services.message.UpdatePersonalRoleRequest + (*UpdatePersonalRoleResponse)(nil), // 3: api.v1.services.message.UpdatePersonalRoleResponse + (*ListPersonalResourcesRequest)(nil), // 4: api.v1.services.message.ListPersonalResourcesRequest + (*ListPersonalResourcesResponse)(nil), // 5: api.v1.services.message.ListPersonalResourcesResponse + (*UpdatePersonalPasswordRequest)(nil), // 6: api.v1.services.message.UpdatePersonalPasswordRequest + (*UpdatePersonalPasswordResponse)(nil), // 7: api.v1.services.message.UpdatePersonalPasswordResponse + (*PersonalPasswordRestRequest)(nil), // 8: api.v1.services.message.PersonalPasswordRestRequest + (*PersonalPasswordRestResponse)(nil), // 9: api.v1.services.message.PersonalPasswordRestResponse + (*UpdatePersonalProfileRequest)(nil), // 10: api.v1.services.message.UpdatePersonalProfileRequest + (*UpdatePersonalProfileResponse)(nil), // 11: api.v1.services.message.UpdatePersonalProfileResponse + (*PersonalLogoutRequest)(nil), // 12: api.v1.services.message.PersonalLogoutRequest + (*PersonalLogoutResponse)(nil), // 13: api.v1.services.message.PersonalLogoutResponse + (*ListPersonalRolesRequest)(nil), // 14: api.v1.services.message.ListPersonalRolesRequest + (*ListPersonalRolesResponse)(nil), // 15: api.v1.services.message.ListPersonalRolesResponse + (*GetPersonalProfileRequest)(nil), // 16: api.v1.services.message.GetPersonalProfileRequest + (*GetPersonalProfileResponse)(nil), // 17: api.v1.services.message.GetPersonalProfileResponse + (*RefreshPersonalTokenRequest)(nil), // 18: api.v1.services.message.RefreshPersonalTokenRequest + (*RefreshPersonalTokenResponse)(nil), // 19: api.v1.services.message.RefreshPersonalTokenResponse + (*anypb.Any)(nil), // 20: google.protobuf.Any + (*types.Role)(nil), // 21: api.v1.services.types.Role + (*types.Resource)(nil), // 22: api.v1.services.types.Resource + (*types.User)(nil), // 23: api.v1.services.types.User +} +var file_message_message_proto_depIdxs = []int32{ + 20, // 0: api.v1.services.message.UpdatePersonalSettingRequest.data:type_name -> google.protobuf.Any + 21, // 1: api.v1.services.message.UpdatePersonalRoleRequest.role:type_name -> api.v1.services.types.Role + 22, // 2: api.v1.services.message.ListPersonalResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 20, // 3: api.v1.services.message.UpdatePersonalPasswordRequest.data:type_name -> google.protobuf.Any + 20, // 4: api.v1.services.message.UpdatePersonalProfileRequest.data:type_name -> google.protobuf.Any + 20, // 5: api.v1.services.message.PersonalLogoutRequest.data:type_name -> google.protobuf.Any + 21, // 6: api.v1.services.message.ListPersonalRolesResponse.roles:type_name -> api.v1.services.types.Role + 23, // 7: api.v1.services.message.GetPersonalProfileResponse.user:type_name -> api.v1.services.types.User + 20, // 8: api.v1.services.message.RefreshPersonalTokenRequest.data:type_name -> google.protobuf.Any + 16, // 9: api.v1.services.message.PersonalService.GetPersonalProfile:input_type -> api.v1.services.message.GetPersonalProfileRequest + 4, // 10: api.v1.services.message.PersonalService.ListPersonalResources:input_type -> api.v1.services.message.ListPersonalResourcesRequest + 14, // 11: api.v1.services.message.PersonalService.ListPersonalRoles:input_type -> api.v1.services.message.ListPersonalRolesRequest + 12, // 12: api.v1.services.message.PersonalService.PersonalLogout:input_type -> api.v1.services.message.PersonalLogoutRequest + 18, // 13: api.v1.services.message.PersonalService.RefreshPersonalToken:input_type -> api.v1.services.message.RefreshPersonalTokenRequest + 6, // 14: api.v1.services.message.PersonalService.UpdatePersonalPassword:input_type -> api.v1.services.message.UpdatePersonalPasswordRequest + 10, // 15: api.v1.services.message.PersonalService.UpdatePersonalProfile:input_type -> api.v1.services.message.UpdatePersonalProfileRequest + 0, // 16: api.v1.services.message.PersonalService.UpdatePersonalSetting:input_type -> api.v1.services.message.UpdatePersonalSettingRequest + 17, // 17: api.v1.services.message.PersonalService.GetPersonalProfile:output_type -> api.v1.services.message.GetPersonalProfileResponse + 5, // 18: api.v1.services.message.PersonalService.ListPersonalResources:output_type -> api.v1.services.message.ListPersonalResourcesResponse + 15, // 19: api.v1.services.message.PersonalService.ListPersonalRoles:output_type -> api.v1.services.message.ListPersonalRolesResponse + 13, // 20: api.v1.services.message.PersonalService.PersonalLogout:output_type -> api.v1.services.message.PersonalLogoutResponse + 19, // 21: api.v1.services.message.PersonalService.RefreshPersonalToken:output_type -> api.v1.services.message.RefreshPersonalTokenResponse + 7, // 22: api.v1.services.message.PersonalService.UpdatePersonalPassword:output_type -> api.v1.services.message.UpdatePersonalPasswordResponse + 11, // 23: api.v1.services.message.PersonalService.UpdatePersonalProfile:output_type -> api.v1.services.message.UpdatePersonalProfileResponse + 1, // 24: api.v1.services.message.PersonalService.UpdatePersonalSetting:output_type -> api.v1.services.message.UpdatePersonalSettingResponse + 17, // [17:25] is the sub-list for method output_type + 9, // [9:17] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_message_message_proto_init() } +func file_message_message_proto_init() { + if File_message_message_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_message_message_proto_rawDesc), len(file_message_message_proto_rawDesc)), + NumEnums: 0, + NumMessages: 20, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_message_message_proto_goTypes, + DependencyIndexes: file_message_message_proto_depIdxs, + MessageInfos: file_message_message_proto_msgTypes, + }.Build() + File_message_message_proto = out.File + file_message_message_proto_goTypes = nil + file_message_message_proto_depIdxs = nil +} diff --git a/api/v1/services/message/message.pb.gw.go b/api/v1/services/message/message.pb.gw.go new file mode 100644 index 00000000..96398dee --- /dev/null +++ b/api/v1/services/message/message.pb.gw.go @@ -0,0 +1,594 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: message/message.proto + +/* +Package message is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package message + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +func request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPersonalProfileRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.GetPersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPersonalProfileRequest + metadata runtime.ServerMetadata + ) + msg, err := server.GetPersonalProfile(ctx, &protoReq) + return msg, metadata, err +} + +var filter_PersonalService_ListPersonalResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalResourcesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListPersonalResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalResourcesRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListPersonalResources(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalRolesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.ListPersonalRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalRolesRequest + metadata runtime.ServerMetadata + ) + msg, err := server.ListPersonalRoles(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq PersonalLogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.PersonalLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq PersonalLogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.PersonalLogout(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RefreshPersonalTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.RefreshPersonalToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RefreshPersonalTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.RefreshPersonalToken(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalPasswordRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalPasswordRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalPassword(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalProfileRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalProfileRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalProfile(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalSettingRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalSetting(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalSettingRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalSetting(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterPersonalServiceHandlerServer registers the http handlers for service PersonalService to "mux". +// UnaryRPC :call PersonalServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPersonalServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterPersonalServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PersonalServiceServer) error { + mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/message/personal/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/message/personal/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/message/personal/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/message/personal/token/refresh")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/message/personal/password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/message/personal/setting")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterPersonalServiceHandlerFromEndpoint is same as RegisterPersonalServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterPersonalServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterPersonalServiceHandler(ctx, mux, conn) +} + +// RegisterPersonalServiceHandler registers the http handlers for service PersonalService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterPersonalServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterPersonalServiceHandlerClient(ctx, mux, NewPersonalServiceClient(conn)) +} + +// RegisterPersonalServiceHandlerClient registers the http handlers for service PersonalService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PersonalServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PersonalServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "PersonalServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterPersonalServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PersonalServiceClient) error { + mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/message/personal/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/message/personal/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/message/personal/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/message/personal/token/refresh")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/message/personal/password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/message/personal/setting")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_PersonalService_GetPersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "profile"}, "")) + pattern_PersonalService_ListPersonalResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "resources"}, "")) + pattern_PersonalService_ListPersonalRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "roles"}, "")) + pattern_PersonalService_PersonalLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "logout"}, "")) + pattern_PersonalService_RefreshPersonalToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"message", "personal", "token", "refresh"}, "")) + pattern_PersonalService_UpdatePersonalPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "password"}, "")) + pattern_PersonalService_UpdatePersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "profile"}, "")) + pattern_PersonalService_UpdatePersonalSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "setting"}, "")) +) + +var ( + forward_PersonalService_GetPersonalProfile_0 = runtime.ForwardResponseMessage + forward_PersonalService_ListPersonalResources_0 = runtime.ForwardResponseMessage + forward_PersonalService_ListPersonalRoles_0 = runtime.ForwardResponseMessage + forward_PersonalService_PersonalLogout_0 = runtime.ForwardResponseMessage + forward_PersonalService_RefreshPersonalToken_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalPassword_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalProfile_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalSetting_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/message/message.pb.validate.go b/api/v1/services/message/message.pb.validate.go new file mode 100644 index 00000000..772c5e54 --- /dev/null +++ b/api/v1/services/message/message.pb.validate.go @@ -0,0 +1,2390 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: message/message.proto + +package message + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on UpdatePersonalSettingRequest 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 *UpdatePersonalSettingRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalSettingRequest 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 +// UpdatePersonalSettingRequestMultiError, or nil if none found. +func (m *UpdatePersonalSettingRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalSettingRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalSettingRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalSettingRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalSettingRequest.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalSettingRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalSettingRequestMultiError) 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 UpdatePersonalSettingRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalSettingRequestValidationError is the validation error returned +// by UpdatePersonalSettingRequest.Validate if the designated constraints +// aren't met. +type UpdatePersonalSettingRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalSettingRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalSettingRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalSettingRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalSettingRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalSettingRequestValidationError) ErrorName() string { + return "UpdatePersonalSettingRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalSettingRequestValidationError) 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 %sUpdatePersonalSettingRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalSettingRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalSettingRequestValidationError{} + +// Validate checks the field values on UpdatePersonalSettingResponse 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 *UpdatePersonalSettingResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalSettingResponse 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 +// UpdatePersonalSettingResponseMultiError, or nil if none found. +func (m *UpdatePersonalSettingResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalSettingResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalSettingResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalSettingResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalSettingResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalSettingResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalSettingResponseMultiError) 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 UpdatePersonalSettingResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalSettingResponseValidationError is the validation error +// returned by UpdatePersonalSettingResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalSettingResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalSettingResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalSettingResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalSettingResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalSettingResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalSettingResponseValidationError) ErrorName() string { + return "UpdatePersonalSettingResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalSettingResponseValidationError) 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 %sUpdatePersonalSettingResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalSettingResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalSettingResponseValidationError{} + +// Validate checks the field values on UpdatePersonalRoleRequest 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 *UpdatePersonalRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalRoleRequest 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 +// UpdatePersonalRoleRequestMultiError, or nil if none found. +func (m *UpdatePersonalRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalRoleRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalRoleRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalRoleRequestMultiError is an error wrapping multiple validation +// errors returned by UpdatePersonalRoleRequest.ValidateAll() if the +// designated constraints aren't met. +type UpdatePersonalRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalRoleRequestMultiError) 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 UpdatePersonalRoleRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalRoleRequestValidationError is the validation error returned by +// UpdatePersonalRoleRequest.Validate if the designated constraints aren't met. +type UpdatePersonalRoleRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalRoleRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalRoleRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalRoleRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalRoleRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalRoleRequestValidationError) ErrorName() string { + return "UpdatePersonalRoleRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalRoleRequestValidationError) 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 %sUpdatePersonalRoleRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalRoleRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalRoleRequestValidationError{} + +// Validate checks the field values on UpdatePersonalRoleResponse 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 *UpdatePersonalRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalRoleResponse 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 +// UpdatePersonalRoleResponseMultiError, or nil if none found. +func (m *UpdatePersonalRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalRoleResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalRoleResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalRoleResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalRoleResponse.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalRoleResponseMultiError) 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 UpdatePersonalRoleResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalRoleResponseValidationError is the validation error returned +// by UpdatePersonalRoleResponse.Validate if the designated constraints aren't met. +type UpdatePersonalRoleResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalRoleResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalRoleResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalRoleResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalRoleResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalRoleResponseValidationError) ErrorName() string { + return "UpdatePersonalRoleResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalRoleResponseValidationError) 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 %sUpdatePersonalRoleResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalRoleResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalRoleResponseValidationError{} + +// Validate checks the field values on ListPersonalResourcesRequest 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 *ListPersonalResourcesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalResourcesRequest 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 +// ListPersonalResourcesRequestMultiError, or nil if none found. +func (m *ListPersonalResourcesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalResourcesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + if len(errors) > 0 { + return ListPersonalResourcesRequestMultiError(errors) + } + + return nil +} + +// ListPersonalResourcesRequestMultiError is an error wrapping multiple +// validation errors returned by ListPersonalResourcesRequest.ValidateAll() if +// the designated constraints aren't met. +type ListPersonalResourcesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalResourcesRequestMultiError) 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 ListPersonalResourcesRequestMultiError) AllErrors() []error { return m } + +// ListPersonalResourcesRequestValidationError is the validation error returned +// by ListPersonalResourcesRequest.Validate if the designated constraints +// aren't met. +type ListPersonalResourcesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalResourcesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalResourcesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalResourcesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalResourcesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalResourcesRequestValidationError) ErrorName() string { + return "ListPersonalResourcesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalResourcesRequestValidationError) 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 %sListPersonalResourcesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalResourcesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalResourcesRequestValidationError{} + +// Validate checks the field values on ListPersonalResourcesResponse 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 *ListPersonalResourcesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalResourcesResponse 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 +// ListPersonalResourcesResponseMultiError, or nil if none found. +func (m *ListPersonalResourcesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalResourcesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TotalSize + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for NextPageToken + + if len(errors) > 0 { + return ListPersonalResourcesResponseMultiError(errors) + } + + return nil +} + +// ListPersonalResourcesResponseMultiError is an error wrapping multiple +// validation errors returned by ListPersonalResourcesResponse.ValidateAll() +// if the designated constraints aren't met. +type ListPersonalResourcesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalResourcesResponseMultiError) 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 ListPersonalResourcesResponseMultiError) AllErrors() []error { return m } + +// ListPersonalResourcesResponseValidationError is the validation error +// returned by ListPersonalResourcesResponse.Validate if the designated +// constraints aren't met. +type ListPersonalResourcesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalResourcesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalResourcesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalResourcesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalResourcesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalResourcesResponseValidationError) ErrorName() string { + return "ListPersonalResourcesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalResourcesResponseValidationError) 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 %sListPersonalResourcesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalResourcesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalResourcesResponseValidationError{} + +// Validate checks the field values on UpdatePersonalPasswordRequest 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 *UpdatePersonalPasswordRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalPasswordRequest 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 +// UpdatePersonalPasswordRequestMultiError, or nil if none found. +func (m *UpdatePersonalPasswordRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalPasswordRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalPasswordRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalPasswordRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalPasswordRequest.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalPasswordRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalPasswordRequestMultiError) 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 UpdatePersonalPasswordRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalPasswordRequestValidationError is the validation error +// returned by UpdatePersonalPasswordRequest.Validate if the designated +// constraints aren't met. +type UpdatePersonalPasswordRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalPasswordRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalPasswordRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalPasswordRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalPasswordRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalPasswordRequestValidationError) ErrorName() string { + return "UpdatePersonalPasswordRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalPasswordRequestValidationError) 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 %sUpdatePersonalPasswordRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalPasswordRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalPasswordRequestValidationError{} + +// Validate checks the field values on UpdatePersonalPasswordResponse 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 *UpdatePersonalPasswordResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalPasswordResponse 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 +// UpdatePersonalPasswordResponseMultiError, or nil if none found. +func (m *UpdatePersonalPasswordResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalPasswordResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalPasswordResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalPasswordResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalPasswordResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalPasswordResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalPasswordResponseMultiError) 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 UpdatePersonalPasswordResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalPasswordResponseValidationError is the validation error +// returned by UpdatePersonalPasswordResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalPasswordResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalPasswordResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalPasswordResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalPasswordResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalPasswordResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalPasswordResponseValidationError) ErrorName() string { + return "UpdatePersonalPasswordResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalPasswordResponseValidationError) 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 %sUpdatePersonalPasswordResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalPasswordResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalPasswordResponseValidationError{} + +// Validate checks the field values on PersonalPasswordRestRequest 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 *PersonalPasswordRestRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalPasswordRestRequest 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 +// PersonalPasswordRestRequestMultiError, or nil if none found. +func (m *PersonalPasswordRestRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalPasswordRestRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetId() <= 0 { + err := PersonalPasswordRestRequestValidationError{ + field: "Id", + reason: "value must be greater than 0", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return PersonalPasswordRestRequestMultiError(errors) + } + + return nil +} + +// PersonalPasswordRestRequestMultiError is an error wrapping multiple +// validation errors returned by PersonalPasswordRestRequest.ValidateAll() if +// the designated constraints aren't met. +type PersonalPasswordRestRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalPasswordRestRequestMultiError) 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 PersonalPasswordRestRequestMultiError) AllErrors() []error { return m } + +// PersonalPasswordRestRequestValidationError is the validation error returned +// by PersonalPasswordRestRequest.Validate if the designated constraints +// aren't met. +type PersonalPasswordRestRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalPasswordRestRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalPasswordRestRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalPasswordRestRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalPasswordRestRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalPasswordRestRequestValidationError) ErrorName() string { + return "PersonalPasswordRestRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalPasswordRestRequestValidationError) 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 %sPersonalPasswordRestRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalPasswordRestRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalPasswordRestRequestValidationError{} + +// Validate checks the field values on PersonalPasswordRestResponse 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 *PersonalPasswordRestResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalPasswordRestResponse 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 +// PersonalPasswordRestResponseMultiError, or nil if none found. +func (m *PersonalPasswordRestResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalPasswordRestResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return PersonalPasswordRestResponseMultiError(errors) + } + + return nil +} + +// PersonalPasswordRestResponseMultiError is an error wrapping multiple +// validation errors returned by PersonalPasswordRestResponse.ValidateAll() if +// the designated constraints aren't met. +type PersonalPasswordRestResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalPasswordRestResponseMultiError) 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 PersonalPasswordRestResponseMultiError) AllErrors() []error { return m } + +// PersonalPasswordRestResponseValidationError is the validation error returned +// by PersonalPasswordRestResponse.Validate if the designated constraints +// aren't met. +type PersonalPasswordRestResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalPasswordRestResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalPasswordRestResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalPasswordRestResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalPasswordRestResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalPasswordRestResponseValidationError) ErrorName() string { + return "PersonalPasswordRestResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalPasswordRestResponseValidationError) 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 %sPersonalPasswordRestResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalPasswordRestResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalPasswordRestResponseValidationError{} + +// Validate checks the field values on UpdatePersonalProfileRequest 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 *UpdatePersonalProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalProfileRequest 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 +// UpdatePersonalProfileRequestMultiError, or nil if none found. +func (m *UpdatePersonalProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalProfileRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalProfileRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalProfileRequest.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalProfileRequestMultiError) 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 UpdatePersonalProfileRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalProfileRequestValidationError is the validation error returned +// by UpdatePersonalProfileRequest.Validate if the designated constraints +// aren't met. +type UpdatePersonalProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalProfileRequestValidationError) ErrorName() string { + return "UpdatePersonalProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalProfileRequestValidationError) 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 %sUpdatePersonalProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalProfileRequestValidationError{} + +// Validate checks the field values on UpdatePersonalProfileResponse 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 *UpdatePersonalProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalProfileResponse 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 +// UpdatePersonalProfileResponseMultiError, or nil if none found. +func (m *UpdatePersonalProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalProfileResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalProfileResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalProfileResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalProfileResponseMultiError) 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 UpdatePersonalProfileResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalProfileResponseValidationError is the validation error +// returned by UpdatePersonalProfileResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalProfileResponseValidationError) ErrorName() string { + return "UpdatePersonalProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalProfileResponseValidationError) 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 %sUpdatePersonalProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalProfileResponseValidationError{} + +// Validate checks the field values on PersonalLogoutRequest 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 *PersonalLogoutRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalLogoutRequest 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 +// PersonalLogoutRequestMultiError, or nil if none found. +func (m *PersonalLogoutRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalLogoutRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return PersonalLogoutRequestMultiError(errors) + } + + return nil +} + +// PersonalLogoutRequestMultiError is an error wrapping multiple validation +// errors returned by PersonalLogoutRequest.ValidateAll() if the designated +// constraints aren't met. +type PersonalLogoutRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalLogoutRequestMultiError) 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 PersonalLogoutRequestMultiError) AllErrors() []error { return m } + +// PersonalLogoutRequestValidationError is the validation error returned by +// PersonalLogoutRequest.Validate if the designated constraints aren't met. +type PersonalLogoutRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalLogoutRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalLogoutRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalLogoutRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalLogoutRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalLogoutRequestValidationError) ErrorName() string { + return "PersonalLogoutRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalLogoutRequestValidationError) 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 %sPersonalLogoutRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalLogoutRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalLogoutRequestValidationError{} + +// Validate checks the field values on PersonalLogoutResponse 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 *PersonalLogoutResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalLogoutResponse 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 +// PersonalLogoutResponseMultiError, or nil if none found. +func (m *PersonalLogoutResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalLogoutResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Success + + if len(errors) > 0 { + return PersonalLogoutResponseMultiError(errors) + } + + return nil +} + +// PersonalLogoutResponseMultiError is an error wrapping multiple validation +// errors returned by PersonalLogoutResponse.ValidateAll() if the designated +// constraints aren't met. +type PersonalLogoutResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalLogoutResponseMultiError) 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 PersonalLogoutResponseMultiError) AllErrors() []error { return m } + +// PersonalLogoutResponseValidationError is the validation error returned by +// PersonalLogoutResponse.Validate if the designated constraints aren't met. +type PersonalLogoutResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalLogoutResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalLogoutResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalLogoutResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalLogoutResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalLogoutResponseValidationError) ErrorName() string { + return "PersonalLogoutResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalLogoutResponseValidationError) 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 %sPersonalLogoutResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalLogoutResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalLogoutResponseValidationError{} + +// Validate checks the field values on ListPersonalRolesRequest 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 *ListPersonalRolesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalRolesRequest 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 +// ListPersonalRolesRequestMultiError, or nil if none found. +func (m *ListPersonalRolesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalRolesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return ListPersonalRolesRequestMultiError(errors) + } + + return nil +} + +// ListPersonalRolesRequestMultiError is an error wrapping multiple validation +// errors returned by ListPersonalRolesRequest.ValidateAll() if the designated +// constraints aren't met. +type ListPersonalRolesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalRolesRequestMultiError) 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 ListPersonalRolesRequestMultiError) AllErrors() []error { return m } + +// ListPersonalRolesRequestValidationError is the validation error returned by +// ListPersonalRolesRequest.Validate if the designated constraints aren't met. +type ListPersonalRolesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalRolesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalRolesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalRolesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalRolesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalRolesRequestValidationError) ErrorName() string { + return "ListPersonalRolesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalRolesRequestValidationError) 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 %sListPersonalRolesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalRolesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalRolesRequestValidationError{} + +// Validate checks the field values on ListPersonalRolesResponse 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 *ListPersonalRolesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalRolesResponse 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 +// ListPersonalRolesResponseMultiError, or nil if none found. +func (m *ListPersonalRolesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalRolesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListPersonalRolesResponseMultiError(errors) + } + + return nil +} + +// ListPersonalRolesResponseMultiError is an error wrapping multiple validation +// errors returned by ListPersonalRolesResponse.ValidateAll() if the +// designated constraints aren't met. +type ListPersonalRolesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalRolesResponseMultiError) 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 ListPersonalRolesResponseMultiError) AllErrors() []error { return m } + +// ListPersonalRolesResponseValidationError is the validation error returned by +// ListPersonalRolesResponse.Validate if the designated constraints aren't met. +type ListPersonalRolesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalRolesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalRolesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalRolesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalRolesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalRolesResponseValidationError) ErrorName() string { + return "ListPersonalRolesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalRolesResponseValidationError) 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 %sListPersonalRolesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalRolesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalRolesResponseValidationError{} + +// Validate checks the field values on GetPersonalProfileRequest 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 *GetPersonalProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPersonalProfileRequest 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 +// GetPersonalProfileRequestMultiError, or nil if none found. +func (m *GetPersonalProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPersonalProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetPersonalProfileRequestMultiError(errors) + } + + return nil +} + +// GetPersonalProfileRequestMultiError is an error wrapping multiple validation +// errors returned by GetPersonalProfileRequest.ValidateAll() if the +// designated constraints aren't met. +type GetPersonalProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPersonalProfileRequestMultiError) 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 GetPersonalProfileRequestMultiError) AllErrors() []error { return m } + +// GetPersonalProfileRequestValidationError is the validation error returned by +// GetPersonalProfileRequest.Validate if the designated constraints aren't met. +type GetPersonalProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPersonalProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPersonalProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPersonalProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPersonalProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPersonalProfileRequestValidationError) ErrorName() string { + return "GetPersonalProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPersonalProfileRequestValidationError) 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 %sGetPersonalProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPersonalProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPersonalProfileRequestValidationError{} + +// Validate checks the field values on GetPersonalProfileResponse 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 *GetPersonalProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPersonalProfileResponse 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 +// GetPersonalProfileResponseMultiError, or nil if none found. +func (m *GetPersonalProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPersonalProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetPersonalProfileResponseMultiError(errors) + } + + return nil +} + +// GetPersonalProfileResponseMultiError is an error wrapping multiple +// validation errors returned by GetPersonalProfileResponse.ValidateAll() if +// the designated constraints aren't met. +type GetPersonalProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPersonalProfileResponseMultiError) 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 GetPersonalProfileResponseMultiError) AllErrors() []error { return m } + +// GetPersonalProfileResponseValidationError is the validation error returned +// by GetPersonalProfileResponse.Validate if the designated constraints aren't met. +type GetPersonalProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPersonalProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPersonalProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPersonalProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPersonalProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPersonalProfileResponseValidationError) ErrorName() string { + return "GetPersonalProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPersonalProfileResponseValidationError) 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 %sGetPersonalProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPersonalProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPersonalProfileResponseValidationError{} + +// Validate checks the field values on RefreshPersonalTokenRequest 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 *RefreshPersonalTokenRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RefreshPersonalTokenRequest 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 +// RefreshPersonalTokenRequestMultiError, or nil if none found. +func (m *RefreshPersonalTokenRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *RefreshPersonalTokenRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RefreshPersonalTokenRequestMultiError(errors) + } + + return nil +} + +// RefreshPersonalTokenRequestMultiError is an error wrapping multiple +// validation errors returned by RefreshPersonalTokenRequest.ValidateAll() if +// the designated constraints aren't met. +type RefreshPersonalTokenRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RefreshPersonalTokenRequestMultiError) 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 RefreshPersonalTokenRequestMultiError) AllErrors() []error { return m } + +// RefreshPersonalTokenRequestValidationError is the validation error returned +// by RefreshPersonalTokenRequest.Validate if the designated constraints +// aren't met. +type RefreshPersonalTokenRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RefreshPersonalTokenRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RefreshPersonalTokenRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RefreshPersonalTokenRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RefreshPersonalTokenRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RefreshPersonalTokenRequestValidationError) ErrorName() string { + return "RefreshPersonalTokenRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e RefreshPersonalTokenRequestValidationError) 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 %sRefreshPersonalTokenRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RefreshPersonalTokenRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RefreshPersonalTokenRequestValidationError{} + +// Validate checks the field values on RefreshPersonalTokenResponse 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 *RefreshPersonalTokenResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RefreshPersonalTokenResponse 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 +// RefreshPersonalTokenResponseMultiError, or nil if none found. +func (m *RefreshPersonalTokenResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *RefreshPersonalTokenResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Token + + if len(errors) > 0 { + return RefreshPersonalTokenResponseMultiError(errors) + } + + return nil +} + +// RefreshPersonalTokenResponseMultiError is an error wrapping multiple +// validation errors returned by RefreshPersonalTokenResponse.ValidateAll() if +// the designated constraints aren't met. +type RefreshPersonalTokenResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RefreshPersonalTokenResponseMultiError) 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 RefreshPersonalTokenResponseMultiError) AllErrors() []error { return m } + +// RefreshPersonalTokenResponseValidationError is the validation error returned +// by RefreshPersonalTokenResponse.Validate if the designated constraints +// aren't met. +type RefreshPersonalTokenResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RefreshPersonalTokenResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RefreshPersonalTokenResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RefreshPersonalTokenResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RefreshPersonalTokenResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RefreshPersonalTokenResponseValidationError) ErrorName() string { + return "RefreshPersonalTokenResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e RefreshPersonalTokenResponseValidationError) 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 %sRefreshPersonalTokenResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RefreshPersonalTokenResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RefreshPersonalTokenResponseValidationError{} diff --git a/api/v1/services/message/message_bridge.pb.go b/api/v1/services/message/message_bridge.pb.go new file mode 100644 index 00000000..14cefe32 --- /dev/null +++ b/api/v1/services/message/message_bridge.pb.go @@ -0,0 +1,565 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: message/message.proto + +package message + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const PersonalServiceGetPersonalProfileBridgeOperation = "/api.v1.services.message.PersonalService/GetPersonalProfile" +const PersonalServiceListPersonalResourcesBridgeOperation = "/api.v1.services.message.PersonalService/ListPersonalResources" +const PersonalServiceListPersonalRolesBridgeOperation = "/api.v1.services.message.PersonalService/ListPersonalRoles" +const PersonalServicePersonalLogoutBridgeOperation = "/api.v1.services.message.PersonalService/PersonalLogout" +const PersonalServiceRefreshPersonalTokenBridgeOperation = "/api.v1.services.message.PersonalService/RefreshPersonalToken" +const PersonalServiceUpdatePersonalPasswordBridgeOperation = "/api.v1.services.message.PersonalService/UpdatePersonalPassword" +const PersonalServiceUpdatePersonalProfileBridgeOperation = "/api.v1.services.message.PersonalService/UpdatePersonalProfile" +const PersonalServiceUpdatePersonalSettingBridgeOperation = "/api.v1.services.message.PersonalService/UpdatePersonalSetting" + +type PersonalServiceBridgeServer interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) +} + +type PersonalServiceHooker interface { + PersonalServiceGetPersonalProfileHooker + PersonalServiceListPersonalResourcesHooker + PersonalServiceListPersonalRolesHooker + PersonalServicePersonalLogoutHooker + PersonalServiceRefreshPersonalTokenHooker + PersonalServiceUpdatePersonalPasswordHooker + PersonalServiceUpdatePersonalProfileHooker + PersonalServiceUpdatePersonalSettingHooker +} + +type PersonalServiceHookedBridger interface { + PersonalServiceHooker + PersonalServiceBridgeServer +} +type PersonalServiceGetPersonalProfileHooker interface { + PrepareGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) + CompleteGetPersonalProfile(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error +} +type PersonalServiceListPersonalResourcesHooker interface { + PrepareListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) + CompleteListPersonalResources(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error +} +type PersonalServiceListPersonalRolesHooker interface { + PrepareListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) + CompleteListPersonalRoles(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error +} +type PersonalServicePersonalLogoutHooker interface { + PreparePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) + CompletePersonalLogout(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error +} +type PersonalServiceRefreshPersonalTokenHooker interface { + PrepareRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) + CompleteRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error +} +type PersonalServiceUpdatePersonalPasswordHooker interface { + PrepareUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) + CompleteUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error +} +type PersonalServiceUpdatePersonalProfileHooker interface { + PrepareUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) + CompleteUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error +} +type PersonalServiceUpdatePersonalSettingHooker interface { + PrepareUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) + CompleteUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error +} + +func RegisterPersonalServiceBridgeServer(s *http.Server, srv PersonalServiceHookedBridger) { + r := s.Route("/") + r.GET("/message/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) + r.GET("/message/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) + r.GET("/message/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) + r.POST("/message/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(srv)) + r.POST("/message/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv)) + r.PUT("/message/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv)) + r.PUT("/message/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv)) + r.PUT("/message/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv)) +} + +func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPersonalProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + }) + + newctx, err := srv.PrepareGetPersonalProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetPersonalProfile(ctx, &in, out.(*GetPersonalProfileResponse)) + } +} + +func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + }) + + newctx, err := srv.PrepareListPersonalResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPersonalResources(ctx, &in, out.(*ListPersonalResourcesResponse)) + } +} + +func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + }) + + newctx, err := srv.PrepareListPersonalRoles(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPersonalRoles(ctx, &in, out.(*ListPersonalRolesResponse)) + } +} + +func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in PersonalLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServicePersonalLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + }) + + newctx, err := srv.PreparePersonalLogout(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompletePersonalLogout(ctx, &in, out.(*PersonalLogoutResponse)) + } +} + +func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RefreshPersonalTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + }) + + newctx, err := srv.PrepareRefreshPersonalToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteRefreshPersonalToken(ctx, &in, out.(*RefreshPersonalTokenResponse)) + } +} + +func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalPassword(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalPassword(ctx, &in, out.(*UpdatePersonalPasswordResponse)) + } +} + +func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalProfileRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalProfile(ctx, &in, out.(*UpdatePersonalProfileResponse)) + } +} + +func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalSettingRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalSetting(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalSetting(ctx, &in, out.(*UpdatePersonalSettingResponse)) + } +} + +// UnimplementedPersonalServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPersonalServiceHooked struct{} + +func (UnimplementedPersonalServiceHooked) PrepareGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PreparePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompletePersonalLogout(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { + return ctx.Result(200, out) +} + +func WithPersonalServiceHook(h PersonalServiceHooker) func(PersonalServiceBridgeServer) PersonalServiceHookedBridger { + return func(srv PersonalServiceBridgeServer) PersonalServiceHookedBridger { + return PersonalServiceHookedBridge{PersonalServiceBridgeServer: srv, PersonalServiceHooker: h} + } +} + +// PersonalServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PersonalService. +// It implements the HTTP and gRPC implementations of PersonalService. +// It forwards requests and responses between the two implementations. +type PersonalServiceHookedBridge struct { + PersonalServiceBridgeServer + PersonalServiceHooker +} + +type PersonalServiceHTTPBridgeImpl struct { + client PersonalServiceHTTPClient +} + +func NewPersonalServiceHTTPBridge(client *http.Client) PersonalServiceHTTPServer { + return &PersonalServiceHTTPBridgeImpl{client: NewPersonalServiceHTTPClient(client)} +} + +func (c *PersonalServiceHTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +type PersonalServiceBridgeImpl struct { + client PersonalServiceClient +} + +func NewPersonalServiceBridge(client grpc.ClientConnInterface) PersonalServiceServer { + return &PersonalServiceBridgeImpl{client: NewPersonalServiceClient(client)} +} + +func (c *PersonalServiceBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} + +type PersonalServiceGRPC2HTTPBridgeImpl struct { + client PersonalServiceClient +} + +func NewPersonalServiceGRPC2HTTP(client grpc.ClientConnInterface) PersonalServiceHTTPServer { + return &PersonalServiceGRPC2HTTPBridgeImpl{client: NewPersonalServiceClient(client)} +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +type PersonalServiceHTTP2GRPCBridgeImpl struct { + client PersonalServiceHTTPClient +} + +func NewPersonalServiceHTTP2GRPC(client *http.Client) PersonalServiceServer { + return &PersonalServiceHTTP2GRPCBridgeImpl{client: NewPersonalServiceHTTPClient(client)} +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} diff --git a/api/v1/services/message/message_grpc.pb.go b/api/v1/services/message/message_grpc.pb.go new file mode 100644 index 00000000..2e0bc3e2 --- /dev/null +++ b/api/v1/services/message/message_grpc.pb.go @@ -0,0 +1,407 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: message/message.proto + +package message + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + PersonalService_GetPersonalProfile_FullMethodName = "/api.v1.services.message.PersonalService/GetPersonalProfile" + PersonalService_ListPersonalResources_FullMethodName = "/api.v1.services.message.PersonalService/ListPersonalResources" + PersonalService_ListPersonalRoles_FullMethodName = "/api.v1.services.message.PersonalService/ListPersonalRoles" + PersonalService_PersonalLogout_FullMethodName = "/api.v1.services.message.PersonalService/PersonalLogout" + PersonalService_RefreshPersonalToken_FullMethodName = "/api.v1.services.message.PersonalService/RefreshPersonalToken" + PersonalService_UpdatePersonalPassword_FullMethodName = "/api.v1.services.message.PersonalService/UpdatePersonalPassword" + PersonalService_UpdatePersonalProfile_FullMethodName = "/api.v1.services.message.PersonalService/UpdatePersonalProfile" + PersonalService_UpdatePersonalSetting_FullMethodName = "/api.v1.services.message.PersonalService/UpdatePersonalSetting" +) + +// PersonalServiceClient is the client API for PersonalService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// PersonalService Personal user service +type PersonalServiceClient interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) +} + +type personalServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPersonalServiceClient(cc grpc.ClientConnInterface) PersonalServiceClient { + return &personalServiceClient{cc} +} + +func (c *personalServiceClient) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetPersonalProfileResponse) + err := c.cc.Invoke(ctx, PersonalService_GetPersonalProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPersonalResourcesResponse) + err := c.cc.Invoke(ctx, PersonalService_ListPersonalResources_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPersonalRolesResponse) + err := c.cc.Invoke(ctx, PersonalService_ListPersonalRoles_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(PersonalLogoutResponse) + err := c.cc.Invoke(ctx, PersonalService_PersonalLogout_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RefreshPersonalTokenResponse) + err := c.cc.Invoke(ctx, PersonalService_RefreshPersonalToken_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalPasswordResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalPassword_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalProfileResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalSettingResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalSetting_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PersonalServiceServer is the server API for PersonalService service. +// All implementations must embed UnimplementedPersonalServiceServer +// for forward compatibility. +// +// PersonalService Personal user service +type PersonalServiceServer interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) + mustEmbedUnimplementedPersonalServiceServer() +} + +// UnimplementedPersonalServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPersonalServiceServer struct{} + +func (UnimplementedPersonalServiceServer) GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPersonalProfile not implemented") +} +func (UnimplementedPersonalServiceServer) ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPersonalResources not implemented") +} +func (UnimplementedPersonalServiceServer) ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPersonalRoles not implemented") +} +func (UnimplementedPersonalServiceServer) PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PersonalLogout not implemented") +} +func (UnimplementedPersonalServiceServer) RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RefreshPersonalToken not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalPassword not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalProfile not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalSetting not implemented") +} +func (UnimplementedPersonalServiceServer) mustEmbedUnimplementedPersonalServiceServer() {} +func (UnimplementedPersonalServiceServer) testEmbeddedByValue() {} + +// UnsafePersonalServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PersonalServiceServer will +// result in compilation errors. +type UnsafePersonalServiceServer interface { + mustEmbedUnimplementedPersonalServiceServer() +} + +func RegisterPersonalServiceServer(s grpc.ServiceRegistrar, srv PersonalServiceServer) { + // If the following call pancis, it indicates UnimplementedPersonalServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&PersonalService_ServiceDesc, srv) +} + +func _PersonalService_GetPersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPersonalProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).GetPersonalProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_GetPersonalProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_ListPersonalResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPersonalResourcesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).ListPersonalResources(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_ListPersonalResources_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_ListPersonalRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPersonalRolesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).ListPersonalRoles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_ListPersonalRoles_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_PersonalLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PersonalLogoutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).PersonalLogout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_PersonalLogout_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_RefreshPersonalToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RefreshPersonalTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_RefreshPersonalToken_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalPasswordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalPassword_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalSettingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalSetting_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// PersonalService_ServiceDesc is the grpc.ServiceDesc for PersonalService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PersonalService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.message.PersonalService", + HandlerType: (*PersonalServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetPersonalProfile", + Handler: _PersonalService_GetPersonalProfile_Handler, + }, + { + MethodName: "ListPersonalResources", + Handler: _PersonalService_ListPersonalResources_Handler, + }, + { + MethodName: "ListPersonalRoles", + Handler: _PersonalService_ListPersonalRoles_Handler, + }, + { + MethodName: "PersonalLogout", + Handler: _PersonalService_PersonalLogout_Handler, + }, + { + MethodName: "RefreshPersonalToken", + Handler: _PersonalService_RefreshPersonalToken_Handler, + }, + { + MethodName: "UpdatePersonalPassword", + Handler: _PersonalService_UpdatePersonalPassword_Handler, + }, + { + MethodName: "UpdatePersonalProfile", + Handler: _PersonalService_UpdatePersonalProfile_Handler, + }, + { + MethodName: "UpdatePersonalSetting", + Handler: _PersonalService_UpdatePersonalSetting_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "message/message.proto", +} diff --git a/api/v1/services/message/message_http.pb.go b/api/v1/services/message/message_http.pb.go new file mode 100644 index 00000000..a01701c9 --- /dev/null +++ b/api/v1/services/message/message_http.pb.go @@ -0,0 +1,366 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: message/message.proto + +package message + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationPersonalServiceGetPersonalProfile = "/api.v1.services.message.PersonalService/GetPersonalProfile" +const OperationPersonalServiceListPersonalResources = "/api.v1.services.message.PersonalService/ListPersonalResources" +const OperationPersonalServiceListPersonalRoles = "/api.v1.services.message.PersonalService/ListPersonalRoles" +const OperationPersonalServicePersonalLogout = "/api.v1.services.message.PersonalService/PersonalLogout" +const OperationPersonalServiceRefreshPersonalToken = "/api.v1.services.message.PersonalService/RefreshPersonalToken" +const OperationPersonalServiceUpdatePersonalPassword = "/api.v1.services.message.PersonalService/UpdatePersonalPassword" +const OperationPersonalServiceUpdatePersonalProfile = "/api.v1.services.message.PersonalService/UpdatePersonalProfile" +const OperationPersonalServiceUpdatePersonalSetting = "/api.v1.services.message.PersonalService/UpdatePersonalSetting" + +type PersonalServiceHTTPServer interface { + // GetPersonalProfile GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalRoles ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) +} + +func RegisterPersonalServiceHTTPServer(s *http.Server, srv PersonalServiceHTTPServer) { + r := s.Route("/") + r.GET("/message/personal/profile", _PersonalService_GetPersonalProfile0_HTTP_Handler(srv)) + r.GET("/message/personal/resources", _PersonalService_ListPersonalResources0_HTTP_Handler(srv)) + r.GET("/message/personal/roles", _PersonalService_ListPersonalRoles0_HTTP_Handler(srv)) + r.POST("/message/personal/logout", _PersonalService_PersonalLogout0_HTTP_Handler(srv)) + r.POST("/message/personal/token/refresh", _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv)) + r.PUT("/message/personal/password", _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv)) + r.PUT("/message/personal/profile", _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv)) + r.PUT("/message/personal/setting", _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv)) +} + +func _PersonalService_GetPersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPersonalProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetPersonalProfileResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_ListPersonalResources0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPersonalResourcesResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_ListPersonalRoles0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPersonalRolesResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_PersonalLogout0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in PersonalLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServicePersonalLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*PersonalLogoutResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RefreshPersonalTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*RefreshPersonalTokenResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalPasswordResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalProfileRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalProfileResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalSettingRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalSettingResponse) + return ctx.Result(200, reply) + } +} + +type PersonalServiceHTTPClient interface { + // GetPersonalProfile GetPersonalProfile Update the personal user information + GetPersonalProfile(ctx context.Context, req *GetPersonalProfileRequest, opts ...http.CallOption) (rsp *GetPersonalProfileResponse, err error) + // ListPersonalResources ListPersonalResources List the personal user's menu + ListPersonalResources(ctx context.Context, req *ListPersonalResourcesRequest, opts ...http.CallOption) (rsp *ListPersonalResourcesResponse, err error) + // ListPersonalRoles ListPersonalResources List the personal user's menu + ListPersonalRoles(ctx context.Context, req *ListPersonalRolesRequest, opts ...http.CallOption) (rsp *ListPersonalRolesResponse, err error) + // PersonalLogout PersonalLogout Personal user logs out + PersonalLogout(ctx context.Context, req *PersonalLogoutRequest, opts ...http.CallOption) (rsp *PersonalLogoutResponse, err error) + // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(ctx context.Context, req *RefreshPersonalTokenRequest, opts ...http.CallOption) (rsp *RefreshPersonalTokenResponse, err error) + // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(ctx context.Context, req *UpdatePersonalPasswordRequest, opts ...http.CallOption) (rsp *UpdatePersonalPasswordResponse, err error) + // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(ctx context.Context, req *UpdatePersonalProfileRequest, opts ...http.CallOption) (rsp *UpdatePersonalProfileResponse, err error) + // UpdatePersonalSetting UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(ctx context.Context, req *UpdatePersonalSettingRequest, opts ...http.CallOption) (rsp *UpdatePersonalSettingResponse, err error) +} + +type PersonalServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewPersonalServiceHTTPClient(client *http.Client) PersonalServiceHTTPClient { + return &PersonalServiceHTTPClientImpl{client} +} + +// GetPersonalProfile GetPersonalProfile Update the personal user information +func (c *PersonalServiceHTTPClientImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...http.CallOption) (*GetPersonalProfileResponse, error) { + var out GetPersonalProfileResponse + pattern := "/message/personal/profile" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceGetPersonalProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ListPersonalResources ListPersonalResources List the personal user's menu +func (c *PersonalServiceHTTPClientImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...http.CallOption) (*ListPersonalResourcesResponse, error) { + var out ListPersonalResourcesResponse + pattern := "/message/personal/resources" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceListPersonalResources)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ListPersonalRoles ListPersonalResources List the personal user's menu +func (c *PersonalServiceHTTPClientImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...http.CallOption) (*ListPersonalRolesResponse, error) { + var out ListPersonalRolesResponse + pattern := "/message/personal/roles" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceListPersonalRoles)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// PersonalLogout PersonalLogout Personal user logs out +func (c *PersonalServiceHTTPClientImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...http.CallOption) (*PersonalLogoutResponse, error) { + var out PersonalLogoutResponse + pattern := "/message/personal/logout" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServicePersonalLogout)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token +func (c *PersonalServiceHTTPClientImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...http.CallOption) (*RefreshPersonalTokenResponse, error) { + var out RefreshPersonalTokenResponse + pattern := "/message/personal/token/refresh" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceRefreshPersonalToken)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...http.CallOption) (*UpdatePersonalPasswordResponse, error) { + var out UpdatePersonalPasswordResponse + pattern := "/message/personal/password" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalPassword)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdatePersonalProfile UpdatePersonalProfile Update the personal user information +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...http.CallOption) (*UpdatePersonalProfileResponse, error) { + var out UpdatePersonalProfileResponse + pattern := "/message/personal/profile" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdatePersonalSetting UpdatePersonalSetting User settings are saved +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...http.CallOption) (*UpdatePersonalSettingResponse, error) { + var out UpdatePersonalSettingResponse + pattern := "/message/personal/setting" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalSetting)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/system/department.pb.go b/api/v1/services/system/department.pb.go index 7344a00b..79817e54 100644 --- a/api/v1/services/system/department.pb.go +++ b/api/v1/services/system/department.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: system/department.proto @@ -655,8 +655,8 @@ const file_system_department_proto_rawDesc = "" + "department\"\x10/sys/departments\x12\xab\x01\n" + "\x10UpdateDepartment\x12/.api.v1.services.system.UpdateDepartmentRequest\x1a0.api.v1.services.system.UpdateDepartmentResponse\"4\x82\xd3\xe4\x93\x02.:\n" + "department\x1a /sys/departments/{department.id}\x12\x94\x01\n" + - "\x10DeleteDepartment\x12/.api.v1.services.system.DeleteDepartmentRequest\x1a0.api.v1.services.system.DeleteDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/departments/{id}B\xc8\x01\n" + - "\x1acom.api.v1.services.systemB\x0fDepartmentProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x10DeleteDepartment\x12/.api.v1.services.system.DeleteDepartmentRequest\x1a0.api.v1.services.system.DeleteDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/departments/{id}B\xe4\x01\n" + + "\x1acom.api.v1.services.systemB\x0fDepartmentProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_department_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/department_http.pb.go b/api/v1/services/system/department_http.pb.go index dd2242cc..1420bdf9 100644 --- a/api/v1/services/system/department_http.pb.go +++ b/api/v1/services/system/department_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: system/department.proto diff --git a/api/v1/services/system/menu.pb.go b/api/v1/services/system/menu.pb.go index 38a276f0..356ecb46 100644 --- a/api/v1/services/system/menu.pb.go +++ b/api/v1/services/system/menu.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: system/menu.proto @@ -648,8 +648,8 @@ const file_system_menu_proto_rawDesc = "" + "\n" + "UpdateMenu\x12).api.v1.services.system.UpdateMenuRequest\x1a*.api.v1.services.system.UpdateMenuResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04menu\x1a\x14/sys/menus/{menu.id}\x12|\n" + "\n" + - "DeleteMenu\x12).api.v1.services.system.DeleteMenuRequest\x1a*.api.v1.services.system.DeleteMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/menus/{id}B\xc2\x01\n" + - "\x1acom.api.v1.services.systemB\tMenuProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "DeleteMenu\x12).api.v1.services.system.DeleteMenuRequest\x1a*.api.v1.services.system.DeleteMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/menus/{id}B\xde\x01\n" + + "\x1acom.api.v1.services.systemB\tMenuProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_menu_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/menu_http.pb.go b/api/v1/services/system/menu_http.pb.go index 30e4ec1c..ff62da43 100644 --- a/api/v1/services/system/menu_http.pb.go +++ b/api/v1/services/system/menu_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: system/menu.proto diff --git a/api/v1/services/system/permission.pb.go b/api/v1/services/system/permission.pb.go index c949663c..65266a72 100644 --- a/api/v1/services/system/permission.pb.go +++ b/api/v1/services/system/permission.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: system/permission.proto @@ -665,8 +665,8 @@ const file_system_permission_proto_rawDesc = "" + "permission\"\x10/sys/permissions\x12\xab\x01\n" + "\x10UpdatePermission\x12/.api.v1.services.system.UpdatePermissionRequest\x1a0.api.v1.services.system.UpdatePermissionResponse\"4\x82\xd3\xe4\x93\x02.:\n" + "permission\x1a /sys/permissions/{permission.id}\x12\x94\x01\n" + - "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xc8\x01\n" + - "\x1acom.api.v1.services.systemB\x0fPermissionProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xe4\x01\n" + + "\x1acom.api.v1.services.systemB\x0fPermissionProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_permission_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/permission_http.pb.go b/api/v1/services/system/permission_http.pb.go index 338a7c76..51616cbb 100644 --- a/api/v1/services/system/permission_http.pb.go +++ b/api/v1/services/system/permission_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: system/permission.proto diff --git a/api/v1/services/system/position.pb.go b/api/v1/services/system/position.pb.go index 9c5c63c3..6c2a4ad7 100644 --- a/api/v1/services/system/position.pb.go +++ b/api/v1/services/system/position.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: system/position.proto @@ -642,8 +642,8 @@ const file_system_position_proto_rawDesc = "" + "\vGetPosition\x12*.api.v1.services.system.GetPositionRequest\x1a+.api.v1.services.system.GetPositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/positions/{id}\x12\x91\x01\n" + "\x0eCreatePosition\x12-.api.v1.services.system.CreatePositionRequest\x1a..api.v1.services.system.CreatePositionResponse\" \x82\xd3\xe4\x93\x02\x1a:\bposition\"\x0e/sys/positions\x12\x9f\x01\n" + "\x0eUpdatePosition\x12-.api.v1.services.system.UpdatePositionRequest\x1a..api.v1.services.system.UpdatePositionResponse\".\x82\xd3\xe4\x93\x02(:\bposition\x1a\x1c/sys/positions/{position.id}\x12\x8c\x01\n" + - "\x0eDeletePosition\x12-.api.v1.services.system.DeletePositionRequest\x1a..api.v1.services.system.DeletePositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/positions/{id}B\xc6\x01\n" + - "\x1acom.api.v1.services.systemB\rPositionProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x0eDeletePosition\x12-.api.v1.services.system.DeletePositionRequest\x1a..api.v1.services.system.DeletePositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/positions/{id}B\xe2\x01\n" + + "\x1acom.api.v1.services.systemB\rPositionProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_position_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/position_http.pb.go b/api/v1/services/system/position_http.pb.go index ed5e52ba..6ded04a3 100644 --- a/api/v1/services/system/position_http.pb.go +++ b/api/v1/services/system/position_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: system/position.proto diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go index d9522140..ae1d6757 100644 --- a/api/v1/services/system/resource.pb.go +++ b/api/v1/services/system/resource.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: system/resource.proto @@ -664,8 +664,8 @@ const file_system_resource_proto_rawDesc = "" + "\vGetResource\x12*.api.v1.services.system.GetResourceRequest\x1a+.api.v1.services.system.GetResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/resources/{id}\x12\x91\x01\n" + "\x0eCreateResource\x12-.api.v1.services.system.CreateResourceRequest\x1a..api.v1.services.system.CreateResourceResponse\" \x82\xd3\xe4\x93\x02\x1a:\bresource\"\x0e/sys/resources\x12\x9f\x01\n" + "\x0eUpdateResource\x12-.api.v1.services.system.UpdateResourceRequest\x1a..api.v1.services.system.UpdateResourceResponse\".\x82\xd3\xe4\x93\x02(:\bresource\x1a\x1c/sys/resources/{resource.id}\x12\x8c\x01\n" + - "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xc6\x01\n" + - "\x1acom.api.v1.services.systemB\rResourceProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xe2\x01\n" + + "\x1acom.api.v1.services.systemB\rResourceProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_resource_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/resource_http.pb.go b/api/v1/services/system/resource_http.pb.go index ac0caac8..05816b6c 100644 --- a/api/v1/services/system/resource_http.pb.go +++ b/api/v1/services/system/resource_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: system/resource.proto diff --git a/api/v1/services/system/role.pb.go b/api/v1/services/system/role.pb.go index 703fa1b4..37d20a2d 100644 --- a/api/v1/services/system/role.pb.go +++ b/api/v1/services/system/role.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: system/role.proto @@ -648,8 +648,8 @@ const file_system_role_proto_rawDesc = "" + "\n" + "UpdateRole\x12).api.v1.services.system.UpdateRoleRequest\x1a*.api.v1.services.system.UpdateRoleResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04role\x1a\x14/sys/roles/{role.id}\x12|\n" + "\n" + - "DeleteRole\x12).api.v1.services.system.DeleteRoleRequest\x1a*.api.v1.services.system.DeleteRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/roles/{id}B\xc2\x01\n" + - "\x1acom.api.v1.services.systemB\tRoleProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "DeleteRole\x12).api.v1.services.system.DeleteRoleRequest\x1a*.api.v1.services.system.DeleteRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/roles/{id}B\xde\x01\n" + + "\x1acom.api.v1.services.systemB\tRoleProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_role_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/role_http.pb.go b/api/v1/services/system/role_http.pb.go index 221edd5f..4b10fbf7 100644 --- a/api/v1/services/system/role_http.pb.go +++ b/api/v1/services/system/role_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: system/role.proto diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go index 7b56430c..09030a6b 100644 --- a/api/v1/services/system/user.pb.go +++ b/api/v1/services/system/user.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: system/user.proto @@ -1090,8 +1090,8 @@ const file_system_user_proto_rawDesc = "" + "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x1c\x82\xd3\xe4\x93\x02\x16*\x14/sys/users/{user.id}\x12\xa0\x01\n" + "\x10UpdateUserStatus\x12/.api.v1.services.system.UpdateUserStatusRequest\x1a0.api.v1.services.system.UpdateUserStatusResponse\")\x82\xd3\xe4\x93\x02#:\x04user\x1a\x1b/sys/users/{user.id}/status\x12\x9c\x01\n" + "\x0fUpdateUserRoles\x12..api.v1.services.system.UpdateUserRolesRequest\x1a/.api.v1.services.system.UpdateUserRolesResponse\"(\x82\xd3\xe4\x93\x02\":\x04user\x1a\x1a/sys/users/{user.id}/roles\x12\xa6\x01\n" + - "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\",\x82\xd3\xe4\x93\x02&:\x04data\"\x1e/sys/users/{id}/password/resetB\xc2\x01\n" + - "\x1acom.api.v1.services.systemB\tUserProtoP\x01Z\x1dapi/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\",\x82\xd3\xe4\x93\x02&:\x04data\"\x1e/sys/users/{id}/password/resetB\xde\x01\n" + + "\x1acom.api.v1.services.systemB\tUserProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( file_system_user_proto_rawDescOnce sync.Once diff --git a/api/v1/services/system/user_http.pb.go b/api/v1/services/system/user_http.pb.go index fb90c3bf..4ab1e025 100644 --- a/api/v1/services/system/user_http.pb.go +++ b/api/v1/services/system/user_http.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-http. DO NOT EDIT. // versions: -// - protoc-gen-go-http v2.8.4 +// - protoc-gen-go-http v2.9.0 // - protoc (unknown) // source: system/user.proto @@ -270,9 +270,12 @@ type UserServiceHTTPClient interface { GetUser(ctx context.Context, req *GetUserRequest, opts ...http.CallOption) (rsp *GetUserResponse, err error) ListUserResources(ctx context.Context, req *ListUserResourcesRequest, opts ...http.CallOption) (rsp *ListUserResourcesResponse, err error) ListUsers(ctx context.Context, req *ListUsersRequest, opts ...http.CallOption) (rsp *ListUsersResponse, err error) + // ResetUserPassword ResetUserPassword reset the user s password ResetUserPassword(ctx context.Context, req *ResetUserPasswordRequest, opts ...http.CallOption) (rsp *ResetUserPasswordResponse, err error) UpdateUser(ctx context.Context, req *UpdateUserRequest, opts ...http.CallOption) (rsp *UpdateUserResponse, err error) + // UpdateUserRoles UpdateUserRoles update the user roles UpdateUserRoles(ctx context.Context, req *UpdateUserRolesRequest, opts ...http.CallOption) (rsp *UpdateUserRolesResponse, err error) + // UpdateUserStatus UpdateUserStatus Update the status of the user information UpdateUserStatus(ctx context.Context, req *UpdateUserStatusRequest, opts ...http.CallOption) (rsp *UpdateUserStatusResponse, err error) } @@ -349,6 +352,7 @@ func (c *UserServiceHTTPClientImpl) ListUsers(ctx context.Context, in *ListUsers return &out, nil } +// ResetUserPassword ResetUserPassword reset the user s password func (c *UserServiceHTTPClientImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest, opts ...http.CallOption) (*ResetUserPasswordResponse, error) { var out ResetUserPasswordResponse pattern := "/sys/users/{id}/password/reset" @@ -375,6 +379,7 @@ func (c *UserServiceHTTPClientImpl) UpdateUser(ctx context.Context, in *UpdateUs return &out, nil } +// UpdateUserRoles UpdateUserRoles update the user roles func (c *UserServiceHTTPClientImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest, opts ...http.CallOption) (*UpdateUserRolesResponse, error) { var out UpdateUserRolesResponse pattern := "/sys/users/{user.id}/roles" @@ -388,6 +393,7 @@ func (c *UserServiceHTTPClientImpl) UpdateUserRoles(ctx context.Context, in *Upd return &out, nil } +// UpdateUserStatus UpdateUserStatus Update the status of the user information func (c *UserServiceHTTPClientImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest, opts ...http.CallOption) (*UpdateUserStatusResponse, error) { var out UpdateUserStatusResponse pattern := "/sys/users/{user.id}/status" diff --git a/api/v1/services/types/auth_error.pb.go b/api/v1/services/types/auth_error.pb.go index fd5e0795..e05ea522 100644 --- a/api/v1/services/types/auth_error.pb.go +++ b/api/v1/services/types/auth_error.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: types/auth_error.proto diff --git a/api/v1/services/types/datastore.pb.go b/api/v1/services/types/datastore.pb.go new file mode 100644 index 00000000..c97a2396 --- /dev/null +++ b/api/v1/services/types/datastore.pb.go @@ -0,0 +1,206 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: types/datastore.proto + +package types + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// DataObject is the model entity for the DataObject schema. +type DataObject struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // DeleteTime holds the value of the "delete_time" field. + DeleteTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=delete_time,proto3" json:"delete_time,omitempty"` + // Version holds the value of the "version" field. + Version int64 `protobuf:"varint,5,opt,name=version,proto3" json:"version,omitempty"` + // OwnerID holds the value of the "owner_id" field. + OwnerId string `protobuf:"bytes,6,opt,name=owner_id,proto3" json:"owner_id,omitempty"` + // Metadata holds the value of the "metadata" field. + Metadata map[string]string `protobuf:"bytes,7,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + // Payload holds the value of the "payload" field. + Payload []byte `protobuf:"bytes,8,opt,name=payload,proto3" json:"payload,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DataObject) Reset() { + *x = DataObject{} + mi := &file_types_datastore_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DataObject) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataObject) ProtoMessage() {} + +func (x *DataObject) ProtoReflect() protoreflect.Message { + mi := &file_types_datastore_proto_msgTypes[0] + 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 DataObject.ProtoReflect.Descriptor instead. +func (*DataObject) Descriptor() ([]byte, []int) { + return file_types_datastore_proto_rawDescGZIP(), []int{0} +} + +func (x *DataObject) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DataObject) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *DataObject) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *DataObject) GetDeleteTime() *timestamppb.Timestamp { + if x != nil { + return x.DeleteTime + } + return nil +} + +func (x *DataObject) GetVersion() int64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *DataObject) GetOwnerId() string { + if x != nil { + return x.OwnerId + } + return "" +} + +func (x *DataObject) GetMetadata() map[string]string { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *DataObject) GetPayload() []byte { + if x != nil { + return x.Payload + } + return nil +} + +var File_types_datastore_proto protoreflect.FileDescriptor + +const file_types_datastore_proto_rawDesc = "" + + "\n" + + "\x15types/datastore.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xb0\x03\n" + + "\n" + + "DataObject\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12<\n" + + "\vdelete_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\vdelete_time\x12\x18\n" + + "\aversion\x18\x05 \x01(\x03R\aversion\x12\x1a\n" + + "\bowner_id\x18\x06 \x01(\tR\bowner_id\x12K\n" + + "\bmetadata\x18\a \x03(\v2/.api.v1.services.types.DataObject.MetadataEntryR\bmetadata\x12\x18\n" + + "\apayload\x18\b \x01(\fR\apayload\x1a;\n" + + "\rMetadataEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01B\xdc\x01\n" + + "\x19com.api.v1.services.typesB\x0eDatastoreProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_datastore_proto_rawDescOnce sync.Once + file_types_datastore_proto_rawDescData []byte +) + +func file_types_datastore_proto_rawDescGZIP() []byte { + file_types_datastore_proto_rawDescOnce.Do(func() { + file_types_datastore_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_datastore_proto_rawDesc), len(file_types_datastore_proto_rawDesc))) + }) + return file_types_datastore_proto_rawDescData +} + +var file_types_datastore_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_types_datastore_proto_goTypes = []any{ + (*DataObject)(nil), // 0: api.v1.services.types.DataObject + nil, // 1: api.v1.services.types.DataObject.MetadataEntry + (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp +} +var file_types_datastore_proto_depIdxs = []int32{ + 2, // 0: api.v1.services.types.DataObject.create_time:type_name -> google.protobuf.Timestamp + 2, // 1: api.v1.services.types.DataObject.update_time:type_name -> google.protobuf.Timestamp + 2, // 2: api.v1.services.types.DataObject.delete_time:type_name -> google.protobuf.Timestamp + 1, // 3: api.v1.services.types.DataObject.metadata:type_name -> api.v1.services.types.DataObject.MetadataEntry + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_types_datastore_proto_init() } +func file_types_datastore_proto_init() { + if File_types_datastore_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_datastore_proto_rawDesc), len(file_types_datastore_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_datastore_proto_goTypes, + DependencyIndexes: file_types_datastore_proto_depIdxs, + MessageInfos: file_types_datastore_proto_msgTypes, + }.Build() + File_types_datastore_proto = out.File + file_types_datastore_proto_goTypes = nil + file_types_datastore_proto_depIdxs = nil +} diff --git a/api/v1/services/types/datastore.pb.validate.go b/api/v1/services/types/datastore.pb.validate.go new file mode 100644 index 00000000..4cd8afdc --- /dev/null +++ b/api/v1/services/types/datastore.pb.validate.go @@ -0,0 +1,232 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/datastore.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on DataObject 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 *DataObject) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DataObject 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 DataObjectMultiError, or +// nil if none found. +func (m *DataObject) ValidateAll() error { + return m.validate(true) +} + +func (m *DataObject) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DataObjectValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DataObjectValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetDeleteTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "DeleteTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "DeleteTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDeleteTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DataObjectValidationError{ + field: "DeleteTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Version + + // no validation rules for OwnerId + + // no validation rules for Metadata + + // no validation rules for Payload + + if len(errors) > 0 { + return DataObjectMultiError(errors) + } + + return nil +} + +// DataObjectMultiError is an error wrapping multiple validation errors +// returned by DataObject.ValidateAll() if the designated constraints aren't met. +type DataObjectMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DataObjectMultiError) 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 DataObjectMultiError) AllErrors() []error { return m } + +// DataObjectValidationError is the validation error returned by +// DataObject.Validate if the designated constraints aren't met. +type DataObjectValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DataObjectValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DataObjectValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DataObjectValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DataObjectValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DataObjectValidationError) ErrorName() string { return "DataObjectValidationError" } + +// Error satisfies the builtin error interface +func (e DataObjectValidationError) 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 %sDataObject.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DataObjectValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DataObjectValidationError{} diff --git a/api/v1/services/types/error.pb.go b/api/v1/services/types/error.pb.go index e541222e..ef7d92f7 100644 --- a/api/v1/services/types/error.pb.go +++ b/api/v1/services/types/error.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: types/error.proto diff --git a/api/v1/services/types/message.pb.go b/api/v1/services/types/message.pb.go index 0e31bac9..17b6aa72 100644 --- a/api/v1/services/types/message.pb.go +++ b/api/v1/services/types/message.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: types/message.proto @@ -22,7 +22,9 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// Menu is the model entity for the Menu schema. +// Message is the model entity for the Message schema. +// NOTE: This message definition is currently incomplete and only contains an ID field. +// It should be extended with actual message content as needed. type Message struct { state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index 9fe125cb..36899fd2 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: types/system.proto diff --git a/api/v1/services/types/system_error.pb.go b/api/v1/services/types/system_error.pb.go index 42aeaf6e..39371eb2 100644 --- a/api/v1/services/types/system_error.pb.go +++ b/api/v1/services/types/system_error.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.10 // protoc (unknown) // source: types/system_error.proto diff --git a/go.mod b/go.mod index a21e1089..481841f6 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module origadmin/application/admin +module github.com/origadmin/backend go 1.23.1 diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 8b804723..056d91cd 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -2648,6 +2648,180 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' + /upload: + get: + tags: + - UploadService + operationId: UploadService_ListUpload + parameters: + - name: id + in: query + description: The parent data id, for example, "shelves/shelf1". + schema: + type: string + - name: current + in: query + description: The current page number. + schema: + type: integer + format: int32 + - name: page_size + in: query + description: The maximum number of items to return. + schema: + type: integer + format: int32 + - name: page_token + in: query + description: The next_page_token value returned from a previous List request, if any. + schema: + type: string + - name: no_paging + in: query + description: The no_paging is used to disable pagination. + schema: + type: boolean + - name: only_count + in: query + description: The only_count is the query parameter for set only to query the total number + schema: + type: boolean + - name: type + in: query + description: data type + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.upload.ListUploadResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + post: + tags: + - UploadService + operationId: UploadService_CreateUpload + parameters: + - name: parent + in: query + description: The parent data id where the data is to be created. + schema: + type: string + - name: data_id + in: query + description: The data id to use for this data. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.upload.CreateUploadResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /upload/{data.id}: + put: + tags: + - UploadService + operationId: UploadService_UpdateUpload + parameters: + - name: data.id + in: path + required: true + schema: + type: string + - name: id + in: query + description: The id of the data object to update. + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.upload.UpdateUploadResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /upload/{id}: + get: + tags: + - UploadService + operationId: UploadService_GetUpload + parameters: + - name: id + in: path + description: "The field will contain id of the data requested, for example:\r\n \"shelves/shelf1/upload/data2\"" + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.upload.GetUploadResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + delete: + tags: + - UploadService + operationId: UploadService_DeleteUpload + parameters: + - name: id + in: path + description: "The data id of the data to be deleted, for example:\r\n \"shelves/shelf1/upload/data2\"" + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.upload.DeleteUploadResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' components: schemas: api.v1.services.auth.AuthLogoutRequest_Data: @@ -3400,7 +3574,7 @@ components: type: string description: Payload holds the value of the "payload" field. format: bytes - description: Menu is the model entity for the Menu schema. + description: DataObject is the model entity for the DataObject schema. api.v1.services.types.Department: type: object properties: @@ -3858,6 +4032,58 @@ components: type: string description: Role Ids holds the value of the role_ids description: User is the model entity for the User schema. + api.v1.services.upload.CreateUploadResponse: + type: object + properties: + data: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: CreateUploadResponse is the response for the UploadService.CreateUpload method. + api.v1.services.upload.DeleteUploadResponse: + type: object + properties: {} + description: DeleteUploadResponse is the response for the UploadService.DeleteUpload method. + api.v1.services.upload.GetUploadResponse: + type: object + properties: + data: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: The field id should match the Noun in the method id. + description: GetUploadResponse is the response for the UploadService.GetUpload method. + api.v1.services.upload.ListUploadResponse: + type: object + properties: + total_size: + type: integer + description: The total number of items in the list. + format: int32 + data: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: The paging upload + current: + type: integer + description: The current page number. + format: int32 + page_size: + type: integer + description: The maximum number of items to return. + format: int32 + next_page_token: + type: string + description: "Token to retrieve the next page of results, or empty if there are no\r\n more results in the list." + extra: + allOf: + - $ref: '#/components/schemas/google.protobuf.Any' + description: "Additional information about this response.\r\n content to be added without destroying the current data format" + description: ListUploadResponse is the response for the UploadService.ListUpload method. + api.v1.services.upload.UpdateUploadResponse: + type: object + properties: + data: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: UpdateUploadResponse is the response for the UploadService.UpdateUpload method. google.protobuf.Any: type: object properties: @@ -3933,5 +4159,7 @@ tags: description: The resource service definition. - name: RoleService description: The login service definition. + - name: UploadService + description: The data service definition. - name: UserService description: The login service definition. From 101fc701fd4c06df9de265ce529869862bf60ad9 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 3 Dec 2025 14:41:32 +0800 Subject: [PATCH 066/158] chore(backend): update module path from github.com/origadmin/backend to origadmin/application/admin --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 481841f6..a21e1089 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/origadmin/backend +module origadmin/application/admin go 1.23.1 From c64ca8196b322654999a81e5560c37c8b223c42c Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 23 Dec 2025 04:49:13 +0800 Subject: [PATCH 067/158] feat(auth): refactor proto files and update token credential imports --- Makefile | 48 +- api/v1/proto/annotations.proto | 2 +- api/v1/proto/auth/auth.proto | 1 + api/v1/proto/auth/login.proto | 23 +- api/v1/services/annotations.pb.go | 74 - api/v1/services/annotations.pb.validate.go | 36 - api/v1/services/auth/auth.pb.go | 962 --- api/v1/services/auth/auth.pb.gw.go | 487 -- api/v1/services/auth/auth.pb.validate.go | 1910 ------ api/v1/services/auth/auth_bridge.pb.go | 450 -- api/v1/services/auth/auth_grpc.pb.go | 323 - api/v1/services/auth/auth_http.pb.go | 285 - api/v1/services/auth/casbin.pb.go | 618 -- api/v1/services/auth/casbin.pb.gw.go | 279 - api/v1/services/auth/casbin.pb.validate.go | 1217 ---- api/v1/services/auth/casbin_bridge.pb.go | 291 - api/v1/services/auth/casbin_grpc.pb.go | 243 - api/v1/services/auth/casbin_http.pb.go | 147 - api/v1/services/auth/login.pb.go | 1461 ----- api/v1/services/auth/login.pb.gw.go | 631 -- api/v1/services/auth/login.pb.validate.go | 2930 --------- api/v1/services/auth/login_bridge.pb.go | 554 -- api/v1/services/auth/login_grpc.pb.go | 391 -- api/v1/services/auth/login_http.pb.go | 339 - api/v1/services/auth/personal.pb.go | 1074 ---- api/v1/services/auth/personal.pb.gw.go | 594 -- api/v1/services/auth/personal.pb.validate.go | 2390 ------- api/v1/services/auth/personal_bridge.pb.go | 565 -- api/v1/services/auth/personal_grpc.pb.go | 407 -- api/v1/services/auth/personal_http.pb.go | 366 -- api/v1/services/datastore/datastore.pb.go | 750 --- api/v1/services/datastore/datastore.pb.gw.go | 487 -- .../datastore/datastore.pb.validate.go | 1329 ---- .../services/datastore/datastore_bridge.pb.go | 392 -- .../services/datastore/datastore_grpc.pb.go | 277 - .../services/datastore/datastore_http.pb.go | 234 - api/v1/services/datastore/upload.pb.go | 749 --- api/v1/services/datastore/upload.pb.gw.go | 487 -- .../services/datastore/upload.pb.validate.go | 1327 ---- api/v1/services/datastore/upload_bridge.pb.go | 392 -- api/v1/services/datastore/upload_grpc.pb.go | 277 - api/v1/services/datastore/upload_http.pb.go | 234 - api/v1/services/message/message.pb.go | 1074 ---- api/v1/services/message/message.pb.gw.go | 594 -- .../services/message/message.pb.validate.go | 2390 ------- api/v1/services/message/message_bridge.pb.go | 565 -- api/v1/services/message/message_grpc.pb.go | 407 -- api/v1/services/message/message_http.pb.go | 366 -- api/v1/services/system/department.pb.go | 738 --- api/v1/services/system/department.pb.gw.go | 487 -- .../services/system/department.pb.validate.go | 1327 ---- .../services/system/department_bridge.pb.go | 392 -- api/v1/services/system/department_grpc.pb.go | 277 - api/v1/services/system/department_http.pb.go | 234 - api/v1/services/system/menu.pb.go | 731 --- api/v1/services/system/menu.pb.gw.go | 473 -- api/v1/services/system/menu.pb.validate.go | 1319 ---- api/v1/services/system/menu_bridge.pb.go | 392 -- api/v1/services/system/menu_grpc.pb.go | 277 - api/v1/services/system/menu_http.pb.go | 234 - api/v1/services/system/permission.pb.go | 748 --- api/v1/services/system/permission.pb.gw.go | 487 -- .../services/system/permission.pb.validate.go | 1327 ---- .../services/system/permission_bridge.pb.go | 392 -- api/v1/services/system/permission_grpc.pb.go | 277 - api/v1/services/system/permission_http.pb.go | 234 - api/v1/services/system/position.pb.go | 725 --- api/v1/services/system/position.pb.gw.go | 487 -- .../services/system/position.pb.validate.go | 1327 ---- api/v1/services/system/position_bridge.pb.go | 392 -- api/v1/services/system/position_grpc.pb.go | 277 - api/v1/services/system/position_http.pb.go | 234 - api/v1/services/system/resource.pb.go | 747 --- api/v1/services/system/resource.pb.gw.go | 487 -- .../services/system/resource.pb.validate.go | 1329 ---- api/v1/services/system/resource_bridge.pb.go | 392 -- api/v1/services/system/resource_grpc.pb.go | 277 - api/v1/services/system/resource_http.pb.go | 234 - api/v1/services/system/role.pb.go | 731 --- api/v1/services/system/role.pb.gw.go | 487 -- api/v1/services/system/role.pb.validate.go | 1321 ---- api/v1/services/system/role_bridge.pb.go | 392 -- api/v1/services/system/role_grpc.pb.go | 277 - api/v1/services/system/role_http.pb.go | 234 - api/v1/services/system/user.pb.go | 1196 ---- api/v1/services/system/user.pb.gw.go | 834 --- api/v1/services/system/user.pb.validate.go | 2332 ------- api/v1/services/system/user_bridge.pb.go | 636 -- api/v1/services/system/user_grpc.pb.go | 435 -- api/v1/services/system/user_http.pb.go | 408 -- api/v1/services/types/auth_error.pb.go | 131 - .../services/types/auth_error.pb.validate.go | 36 - api/v1/services/types/auth_error_errors.pb.go | 48 - api/v1/services/types/datastore.pb.go | 206 - .../services/types/datastore.pb.validate.go | 232 - api/v1/services/types/error.pb.go | 128 - api/v1/services/types/error.pb.validate.go | 36 - api/v1/services/types/error_errors.pb.go | 36 - api/v1/services/types/message.pb.go | 128 - api/v1/services/types/message.pb.validate.go | 136 - api/v1/services/types/system.pb.go | 3205 ---------- api/v1/services/types/system.pb.validate.go | 5600 ----------------- api/v1/services/types/system_error.pb.go | 195 - .../types/system_error.pb.validate.go | 36 - .../services/types/system_error_errors.pb.go | 240 - buf.lock | 15 +- cmd/auth/wire.go | 8 +- cmd/auth/wire_gen.go | 8 +- .../start/start.go => gateway/main.go} | 60 +- cmd/{internal/start => gateway}/wire.go | 20 +- cmd/internal/start/wire.work.go | 11 - cmd/internal/start/wire_gen.go | 112 - cmd/system/main.go | 122 +- cmd/system/wire.go | 19 +- cmd/system/wire_gen.go | 23 +- generate.go | 42 - go.mod | 254 +- go.sum | 2118 +------ internal/conf/config.go | 82 + internal/conf/pb/conf.proto | 19 + internal/data/casbin-adapter.dal.go | 4 +- internal/data/data.go | 569 +- internal/data/entity/ent/database.go | 2 +- internal/data/entity/ent/schema/department.go | 4 +- .../data/entity/ent/schema/notification.go | 4 +- internal/data/entity/ent/schema/permission.go | 4 +- .../entity/ent/schema/permissionresource.go | 4 +- internal/data/entity/ent/schema/position.go | 4 +- .../entity/ent/schema/positionpermission.go | 4 +- internal/data/entity/ent/schema/resource.go | 4 +- internal/data/entity/ent/schema/role.go | 4 +- .../data/entity/ent/schema/rolepermission.go | 4 +- internal/data/entity/ent/schema/softdelete.go | 2 +- internal/data/entity/ent/schema/user.go | 4 +- .../data/entity/ent/schema/userdepartment.go | 4 +- .../data/entity/ent/schema/userposition.go | 4 +- internal/data/entity/ent/schema/userrole.go | 4 +- .../data/entity/ent/template/database.tpl | 2 +- internal/features/auth/biz/auth.biz.go | 3 +- internal/features/auth/biz/biz.go | 2 +- internal/features/auth/biz/casbin.biz.go | 3 +- internal/features/auth/biz/login.biz.go | 3 +- internal/features/auth/biz/personal.biz.go | 3 +- internal/features/auth/dal/auth.dal.go | 6 +- internal/features/auth/dal/casbin.dal.go | 2 +- internal/features/auth/dal/dal.go | 2 +- internal/features/auth/dal/login.dal.go | 23 +- internal/features/auth/dal/user.dal.go | 2 +- internal/features/auth/dto/auth.go | 2 +- internal/features/auth/dto/dto.go | 12 +- internal/features/auth/server/server.go | 2 +- internal/features/auth/service/auth.grpc.go | 2 +- internal/features/auth/service/casbin.go | 2 +- internal/features/auth/service/casbin.grpc.go | 2 +- internal/features/auth/service/login.grpc.go | 2 +- .../features/auth/service/personal.grpc.go | 2 +- internal/features/datastore/biz/biz.go | 11 +- internal/features/datastore/biz/datastore.go | 5 +- internal/features/datastore/dal/menu.dal.go | 2 +- .../features/datastore/dal/permission.dal.go | 6 +- .../features/datastore/dal/resource.dal.go | 6 +- internal/features/datastore/dal/role.dal.go | 6 +- internal/features/datastore/dal/user.dal.go | 6 +- internal/features/datastore/dto/dto.go | 12 +- internal/features/datastore/dto/menu.go | 2 +- internal/features/datastore/dto/permission.go | 2 +- internal/features/datastore/dto/resource.go | 2 +- internal/features/datastore/dto/role.go | 2 +- internal/features/datastore/dto/user.go | 3 +- internal/features/datastore/server/server.go | 2 +- .../datastore/service/permission.grpc.go | 2 +- .../datastore/service/permission.http.go | 2 +- .../datastore/service/resource.grpc.go | 2 +- internal/features/system/biz/biz.go | 7 +- .../features/system/biz/permission.biz.go | 5 +- internal/features/system/biz/resource.biz.go | 5 +- internal/features/system/biz/role.biz.go | 5 +- internal/features/system/biz/user.biz.go | 5 +- internal/features/system/dal/dal.go | 4 - internal/features/system/dal/menu.dal.go | 323 +- .../features/system/dal/permission.dal.go | 28 +- internal/features/system/dal/provider.go | 34 +- internal/features/system/dal/resource.dal.go | 36 +- internal/features/system/dal/role.dal.go | 48 +- internal/features/system/dal/user.dal.go | 41 +- internal/features/system/dto/custom.gen.go | 17 + internal/features/system/dto/dto.gen.go | 1149 ++++ internal/features/system/dto/dto.go | 1018 +-- internal/features/system/dto/menu.go | 14 +- internal/features/system/dto/permission.go | 28 +- internal/features/system/dto/resource.go | 37 +- internal/features/system/dto/role.go | 23 +- internal/features/system/dto/user.go | 55 +- internal/features/system/server/server.go | 4 +- .../system/service/permission.grpc.go | 2 +- .../system/service/permission.http.go | 2 +- .../features/system/service/resource.grpc.go | 2 +- internal/features/system/service/role.grpc.go | 2 +- internal/features/system/service/user.grpc.go | 2 +- internal/generate.go | 15 - internal/helpers/captcha/captcha.go | 5 +- internal/helpers/command/lower.go | 16 - internal/helpers/conf/bootstrap.go | 57 + internal/helpers/db/db.go | 17 +- internal/helpers/ent/mixin/field.go | 2 +- internal/helpers/ent/mixin/mixin.go | 2 +- internal/helpers/ent/mixin/mixin_id.go | 4 +- internal/helpers/ent/mixin/mixin_uuid.go | 2 +- internal/helpers/resp/error.go | 1 + internal/helpers/resp/marshal.go | 2 +- internal/helpers/resp/resp.go | 5 +- internal/helpers/resp/result.go | 2 +- resources/docs/openapi/openapi.yaml | 41 +- test/token_test.go | 4 +- third_party/buf/validate/validate.proto | 5004 +++++++++++++++ third_party/config/app/v1/app.proto | 37 + .../config/bootstrap/v1/bootstrap.proto | 34 + .../config/broker/kafka/v1/kafka.proto | 45 + third_party/config/broker/mqtt/v1/mqtt.proto | 39 + third_party/config/broker/nats/v1/nats.proto | 37 + third_party/config/broker/nsq/v1/nsq.proto | 33 + .../config/broker/pulsar/v1/pulsar.proto | 33 + .../config/broker/rabbitmq/v1/rabbitmq.proto | 45 + .../config/broker/redis_mq/v1/redis_mq.proto | 31 + .../config/broker/rocketmq/v1/rocketmq.proto | 31 + third_party/config/broker/sqs/v1/sqs.proto | 29 + .../config/broker/stomp/v1/stomp.proto | 31 + third_party/config/broker/v1/broker.proto | 114 + third_party/config/common/v1/errors.proto | 93 + third_party/config/common/v1/pagination.proto | 109 + third_party/config/config/v1/gateway.proto | 110 + third_party/config/data/cache/v1/cache.proto | 55 + .../config/data/cache/v1/memcached.proto | 37 + third_party/config/data/cache/v1/memory.proto | 28 + third_party/config/data/cache/v1/redis.proto | 92 + .../config/data/database/v1/database.proto | 78 + .../config/data/database/v1/document.proto | 38 + .../config/data/database/v1/migration.proto | 32 + .../config/data/database/v1/mongo.proto | 46 + .../config/data/oss/v1/object_meta.proto | 35 + .../config/data/oss/v1/object_service.proto | 200 + .../config/data/oss/v1/objectstore.proto | 56 + third_party/config/data/oss/v1/oss.proto | 144 + .../config/data/oss/v1/oss_local.proto | 16 + third_party/config/data/v1/data.proto | 121 + .../config/discovery/v1/discovery.proto | 152 + .../config/discovery/v1/endpoint.proto | 48 + third_party/config/logger/v1/logger.proto | 182 + third_party/config/mail/v1/mail.proto | 65 + .../circuitbreaker/v1/circuitbreaker.proto | 63 + .../config/middleware/cors/v1/cors.proto | 101 + .../config/middleware/jwt/v1/jwt.proto | 84 + .../middleware/metrics/v1/metrics.proto | 50 + .../middleware/optimize/v1/optimize.proto | 24 + .../middleware/ratelimit/v1/ratelimiter.proto | 49 + .../middleware/selector/v1/selector.proto | 14 + .../config/middleware/v1/middleware.proto | 118 + .../config/middleware/v1/security.proto | 17 + .../middleware/validator/v1/validator.proto | 18 + third_party/config/selector/v1/selector.proto | 23 + .../config/source/v1/apollo_source.proto | 25 + .../config/source/v1/consul_source.proto | 20 + third_party/config/source/v1/env_source.proto | 17 + .../config/source/v1/etcd_source.proto | 21 + .../config/source/v1/file_source.proto | 16 + .../config/source/v1/kubernetes_source.proto | 21 + .../config/source/v1/nacos_source.proto | 27 + .../config/source/v1/polaris_source.proto | 23 + third_party/config/source/v1/source.proto | 55 + third_party/config/task/v1/task.proto | 11 + third_party/config/trace/v1/trace.proto | 47 + .../config/transport/grpc/v1/grpc.proto | 70 + .../config/transport/http/v1/http.proto | 85 + third_party/config/transport/tls/v1/tls.proto | 149 + .../config/transport/v1/transport.proto | 121 + .../transport/websocket/v1/websocket.proto | 29 + third_party/errors/errors.proto | 18 + .../gnostic/discovery/v1/discovery.proto | 269 + .../gnostic/openapi/v2/openapiv2.proto | 665 ++ .../gnostic/openapi/v3/annotations.proto | 60 + .../gnostic/openapi/v3/openapiv3.proto | 671 ++ third_party/google/api/annotations.proto | 31 + third_party/google/api/client.proto | 486 ++ .../google/api/expr/v1alpha1/checked.proto | 343 + .../google/api/expr/v1alpha1/eval.proto | 118 + .../google/api/expr/v1alpha1/explain.proto | 53 + .../google/api/expr/v1alpha1/syntax.proto | 438 ++ .../google/api/expr/v1alpha1/value.proto | 115 + .../google/api/expr/v1beta1/decl.proto | 84 + .../google/api/expr/v1beta1/eval.proto | 125 + .../google/api/expr/v1beta1/expr.proto | 265 + .../google/api/expr/v1beta1/source.proto | 62 + .../google/api/expr/v1beta1/value.proto | 114 + third_party/google/api/field_behavior.proto | 104 + third_party/google/api/field_info.proto | 106 + third_party/google/api/http.proto | 370 ++ third_party/google/api/httpbody.proto | 80 + third_party/google/api/launch_stage.proto | 72 + third_party/google/api/resource.proto | 242 + third_party/google/api/routing.proto | 461 ++ third_party/google/api/visibility.proto | 112 + .../google/bytestream/bytestream.proto | 178 + third_party/google/geo/type/viewport.proto | 69 + third_party/google/iam/v1/iam_policy.proto | 157 + third_party/google/iam/v1/options.proto | 48 + third_party/google/iam/v1/policy.proto | 410 ++ .../google/longrunning/operations.proto | 265 + third_party/google/protobuf/any.proto | 162 + third_party/google/protobuf/api.proto | 229 + .../google/protobuf/compiler/plugin.proto | 180 + .../google/protobuf/cpp_features.proto | 67 + third_party/google/protobuf/descriptor.proto | 1426 +++++ third_party/google/protobuf/duration.proto | 115 + third_party/google/protobuf/empty.proto | 51 + third_party/google/protobuf/field_mask.proto | 245 + third_party/google/protobuf/go_features.proto | 83 + .../google/protobuf/java_features.proto | 132 + .../google/protobuf/source_context.proto | 48 + third_party/google/protobuf/struct.proto | 95 + third_party/google/protobuf/timestamp.proto | 145 + third_party/google/protobuf/type.proto | 217 + third_party/google/protobuf/wrappers.proto | 157 + third_party/google/rpc/code.proto | 186 + .../rpc/context/attribute_context.proto | 345 + third_party/google/rpc/error_details.proto | 363 ++ third_party/google/rpc/status.proto | 49 + third_party/google/type/calendar_period.proto | 56 + third_party/google/type/color.proto | 174 + third_party/google/type/date.proto | 52 + third_party/google/type/datetime.proto | 104 + third_party/google/type/dayofweek.proto | 50 + third_party/google/type/decimal.proto | 95 + third_party/google/type/expr.proto | 73 + third_party/google/type/fraction.proto | 33 + third_party/google/type/interval.proto | 46 + third_party/google/type/latlng.proto | 37 + third_party/google/type/localized_text.proto | 36 + third_party/google/type/money.proto | 42 + third_party/google/type/month.proto | 65 + third_party/google/type/phone_number.proto | 113 + third_party/google/type/postal_address.proto | 134 + third_party/google/type/quaternion.proto | 94 + third_party/google/type/timeofday.proto | 44 + third_party/policy/v1/policy.proto | 22 + .../security/authn/apikey/v1/config.proto | 50 + .../security/authn/apikey/v1/credential.proto | 10 + .../security/authn/basic/v1/credential.proto | 11 + .../security/authn/jwt/v1/claims.proto | 51 + .../security/authn/jwt/v1/config.proto | 69 + third_party/security/authn/jwt/v1/data.proto | 28 + .../security/authn/oidc/v1/config.proto | 40 + .../security/authn/oidc/v1/credential.proto | 10 + .../authn/presharedkey/v1/config.proto | 48 + third_party/security/authn/v1/authn.proto | 69 + .../security/authz/casbin/v1/config.proto | 63 + third_party/security/authz/v1/authz.proto | 67 + third_party/security/v1/credential.proto | 164 + third_party/security/v1/error.proto | 41 + third_party/security/v1/principal.proto | 38 + third_party/security/v1/security.proto | 47 + .../service/security/authz/v1/service.proto | 123 + third_party/validate/validate.proto | 862 +++ tools.go | 16 + 363 files changed, 24996 insertions(+), 72667 deletions(-) delete mode 100644 api/v1/services/annotations.pb.go delete mode 100644 api/v1/services/annotations.pb.validate.go delete mode 100644 api/v1/services/auth/auth.pb.go delete mode 100644 api/v1/services/auth/auth.pb.gw.go delete mode 100644 api/v1/services/auth/auth.pb.validate.go delete mode 100644 api/v1/services/auth/auth_bridge.pb.go delete mode 100644 api/v1/services/auth/auth_grpc.pb.go delete mode 100644 api/v1/services/auth/auth_http.pb.go delete mode 100644 api/v1/services/auth/casbin.pb.go delete mode 100644 api/v1/services/auth/casbin.pb.gw.go delete mode 100644 api/v1/services/auth/casbin.pb.validate.go delete mode 100644 api/v1/services/auth/casbin_bridge.pb.go delete mode 100644 api/v1/services/auth/casbin_grpc.pb.go delete mode 100644 api/v1/services/auth/casbin_http.pb.go delete mode 100644 api/v1/services/auth/login.pb.go delete mode 100644 api/v1/services/auth/login.pb.gw.go delete mode 100644 api/v1/services/auth/login.pb.validate.go delete mode 100644 api/v1/services/auth/login_bridge.pb.go delete mode 100644 api/v1/services/auth/login_grpc.pb.go delete mode 100644 api/v1/services/auth/login_http.pb.go delete mode 100644 api/v1/services/auth/personal.pb.go delete mode 100644 api/v1/services/auth/personal.pb.gw.go delete mode 100644 api/v1/services/auth/personal.pb.validate.go delete mode 100644 api/v1/services/auth/personal_bridge.pb.go delete mode 100644 api/v1/services/auth/personal_grpc.pb.go delete mode 100644 api/v1/services/auth/personal_http.pb.go delete mode 100644 api/v1/services/datastore/datastore.pb.go delete mode 100644 api/v1/services/datastore/datastore.pb.gw.go delete mode 100644 api/v1/services/datastore/datastore.pb.validate.go delete mode 100644 api/v1/services/datastore/datastore_bridge.pb.go delete mode 100644 api/v1/services/datastore/datastore_grpc.pb.go delete mode 100644 api/v1/services/datastore/datastore_http.pb.go delete mode 100644 api/v1/services/datastore/upload.pb.go delete mode 100644 api/v1/services/datastore/upload.pb.gw.go delete mode 100644 api/v1/services/datastore/upload.pb.validate.go delete mode 100644 api/v1/services/datastore/upload_bridge.pb.go delete mode 100644 api/v1/services/datastore/upload_grpc.pb.go delete mode 100644 api/v1/services/datastore/upload_http.pb.go delete mode 100644 api/v1/services/message/message.pb.go delete mode 100644 api/v1/services/message/message.pb.gw.go delete mode 100644 api/v1/services/message/message.pb.validate.go delete mode 100644 api/v1/services/message/message_bridge.pb.go delete mode 100644 api/v1/services/message/message_grpc.pb.go delete mode 100644 api/v1/services/message/message_http.pb.go delete mode 100644 api/v1/services/system/department.pb.go delete mode 100644 api/v1/services/system/department.pb.gw.go delete mode 100644 api/v1/services/system/department.pb.validate.go delete mode 100644 api/v1/services/system/department_bridge.pb.go delete mode 100644 api/v1/services/system/department_grpc.pb.go delete mode 100644 api/v1/services/system/department_http.pb.go delete mode 100644 api/v1/services/system/menu.pb.go delete mode 100644 api/v1/services/system/menu.pb.gw.go delete mode 100644 api/v1/services/system/menu.pb.validate.go delete mode 100644 api/v1/services/system/menu_bridge.pb.go delete mode 100644 api/v1/services/system/menu_grpc.pb.go delete mode 100644 api/v1/services/system/menu_http.pb.go delete mode 100644 api/v1/services/system/permission.pb.go delete mode 100644 api/v1/services/system/permission.pb.gw.go delete mode 100644 api/v1/services/system/permission.pb.validate.go delete mode 100644 api/v1/services/system/permission_bridge.pb.go delete mode 100644 api/v1/services/system/permission_grpc.pb.go delete mode 100644 api/v1/services/system/permission_http.pb.go delete mode 100644 api/v1/services/system/position.pb.go delete mode 100644 api/v1/services/system/position.pb.gw.go delete mode 100644 api/v1/services/system/position.pb.validate.go delete mode 100644 api/v1/services/system/position_bridge.pb.go delete mode 100644 api/v1/services/system/position_grpc.pb.go delete mode 100644 api/v1/services/system/position_http.pb.go delete mode 100644 api/v1/services/system/resource.pb.go delete mode 100644 api/v1/services/system/resource.pb.gw.go delete mode 100644 api/v1/services/system/resource.pb.validate.go delete mode 100644 api/v1/services/system/resource_bridge.pb.go delete mode 100644 api/v1/services/system/resource_grpc.pb.go delete mode 100644 api/v1/services/system/resource_http.pb.go delete mode 100644 api/v1/services/system/role.pb.go delete mode 100644 api/v1/services/system/role.pb.gw.go delete mode 100644 api/v1/services/system/role.pb.validate.go delete mode 100644 api/v1/services/system/role_bridge.pb.go delete mode 100644 api/v1/services/system/role_grpc.pb.go delete mode 100644 api/v1/services/system/role_http.pb.go delete mode 100644 api/v1/services/system/user.pb.go delete mode 100644 api/v1/services/system/user.pb.gw.go delete mode 100644 api/v1/services/system/user.pb.validate.go delete mode 100644 api/v1/services/system/user_bridge.pb.go delete mode 100644 api/v1/services/system/user_grpc.pb.go delete mode 100644 api/v1/services/system/user_http.pb.go delete mode 100644 api/v1/services/types/auth_error.pb.go delete mode 100644 api/v1/services/types/auth_error.pb.validate.go delete mode 100644 api/v1/services/types/auth_error_errors.pb.go delete mode 100644 api/v1/services/types/datastore.pb.go delete mode 100644 api/v1/services/types/datastore.pb.validate.go delete mode 100644 api/v1/services/types/error.pb.go delete mode 100644 api/v1/services/types/error.pb.validate.go delete mode 100644 api/v1/services/types/error_errors.pb.go delete mode 100644 api/v1/services/types/message.pb.go delete mode 100644 api/v1/services/types/message.pb.validate.go delete mode 100644 api/v1/services/types/system.pb.go delete mode 100644 api/v1/services/types/system.pb.validate.go delete mode 100644 api/v1/services/types/system_error.pb.go delete mode 100644 api/v1/services/types/system_error.pb.validate.go delete mode 100644 api/v1/services/types/system_error_errors.pb.go rename cmd/{internal/start/start.go => gateway/main.go} (77%) rename cmd/{internal/start => gateway}/wire.go (61%) delete mode 100644 cmd/internal/start/wire.work.go delete mode 100644 cmd/internal/start/wire_gen.go delete mode 100644 generate.go create mode 100644 internal/conf/config.go create mode 100644 internal/features/system/dto/custom.gen.go create mode 100644 internal/features/system/dto/dto.gen.go delete mode 100644 internal/generate.go delete mode 100644 internal/helpers/command/lower.go create mode 100644 internal/helpers/conf/bootstrap.go create mode 100644 third_party/buf/validate/validate.proto create mode 100644 third_party/config/app/v1/app.proto create mode 100644 third_party/config/bootstrap/v1/bootstrap.proto create mode 100644 third_party/config/broker/kafka/v1/kafka.proto create mode 100644 third_party/config/broker/mqtt/v1/mqtt.proto create mode 100644 third_party/config/broker/nats/v1/nats.proto create mode 100644 third_party/config/broker/nsq/v1/nsq.proto create mode 100644 third_party/config/broker/pulsar/v1/pulsar.proto create mode 100644 third_party/config/broker/rabbitmq/v1/rabbitmq.proto create mode 100644 third_party/config/broker/redis_mq/v1/redis_mq.proto create mode 100644 third_party/config/broker/rocketmq/v1/rocketmq.proto create mode 100644 third_party/config/broker/sqs/v1/sqs.proto create mode 100644 third_party/config/broker/stomp/v1/stomp.proto create mode 100644 third_party/config/broker/v1/broker.proto create mode 100644 third_party/config/common/v1/errors.proto create mode 100644 third_party/config/common/v1/pagination.proto create mode 100644 third_party/config/config/v1/gateway.proto create mode 100644 third_party/config/data/cache/v1/cache.proto create mode 100644 third_party/config/data/cache/v1/memcached.proto create mode 100644 third_party/config/data/cache/v1/memory.proto create mode 100644 third_party/config/data/cache/v1/redis.proto create mode 100644 third_party/config/data/database/v1/database.proto create mode 100644 third_party/config/data/database/v1/document.proto create mode 100644 third_party/config/data/database/v1/migration.proto create mode 100644 third_party/config/data/database/v1/mongo.proto create mode 100644 third_party/config/data/oss/v1/object_meta.proto create mode 100644 third_party/config/data/oss/v1/object_service.proto create mode 100644 third_party/config/data/oss/v1/objectstore.proto create mode 100644 third_party/config/data/oss/v1/oss.proto create mode 100644 third_party/config/data/oss/v1/oss_local.proto create mode 100644 third_party/config/data/v1/data.proto create mode 100644 third_party/config/discovery/v1/discovery.proto create mode 100644 third_party/config/discovery/v1/endpoint.proto create mode 100644 third_party/config/logger/v1/logger.proto create mode 100644 third_party/config/mail/v1/mail.proto create mode 100644 third_party/config/middleware/circuitbreaker/v1/circuitbreaker.proto create mode 100644 third_party/config/middleware/cors/v1/cors.proto create mode 100644 third_party/config/middleware/jwt/v1/jwt.proto create mode 100644 third_party/config/middleware/metrics/v1/metrics.proto create mode 100644 third_party/config/middleware/optimize/v1/optimize.proto create mode 100644 third_party/config/middleware/ratelimit/v1/ratelimiter.proto create mode 100644 third_party/config/middleware/selector/v1/selector.proto create mode 100644 third_party/config/middleware/v1/middleware.proto create mode 100644 third_party/config/middleware/v1/security.proto create mode 100644 third_party/config/middleware/validator/v1/validator.proto create mode 100644 third_party/config/selector/v1/selector.proto create mode 100644 third_party/config/source/v1/apollo_source.proto create mode 100644 third_party/config/source/v1/consul_source.proto create mode 100644 third_party/config/source/v1/env_source.proto create mode 100644 third_party/config/source/v1/etcd_source.proto create mode 100644 third_party/config/source/v1/file_source.proto create mode 100644 third_party/config/source/v1/kubernetes_source.proto create mode 100644 third_party/config/source/v1/nacos_source.proto create mode 100644 third_party/config/source/v1/polaris_source.proto create mode 100644 third_party/config/source/v1/source.proto create mode 100644 third_party/config/task/v1/task.proto create mode 100644 third_party/config/trace/v1/trace.proto create mode 100644 third_party/config/transport/grpc/v1/grpc.proto create mode 100644 third_party/config/transport/http/v1/http.proto create mode 100644 third_party/config/transport/tls/v1/tls.proto create mode 100644 third_party/config/transport/v1/transport.proto create mode 100644 third_party/config/transport/websocket/v1/websocket.proto create mode 100644 third_party/errors/errors.proto create mode 100644 third_party/gnostic/discovery/v1/discovery.proto create mode 100644 third_party/gnostic/openapi/v2/openapiv2.proto create mode 100644 third_party/gnostic/openapi/v3/annotations.proto create mode 100644 third_party/gnostic/openapi/v3/openapiv3.proto create mode 100644 third_party/google/api/annotations.proto create mode 100644 third_party/google/api/client.proto create mode 100644 third_party/google/api/expr/v1alpha1/checked.proto create mode 100644 third_party/google/api/expr/v1alpha1/eval.proto create mode 100644 third_party/google/api/expr/v1alpha1/explain.proto create mode 100644 third_party/google/api/expr/v1alpha1/syntax.proto create mode 100644 third_party/google/api/expr/v1alpha1/value.proto create mode 100644 third_party/google/api/expr/v1beta1/decl.proto create mode 100644 third_party/google/api/expr/v1beta1/eval.proto create mode 100644 third_party/google/api/expr/v1beta1/expr.proto create mode 100644 third_party/google/api/expr/v1beta1/source.proto create mode 100644 third_party/google/api/expr/v1beta1/value.proto create mode 100644 third_party/google/api/field_behavior.proto create mode 100644 third_party/google/api/field_info.proto create mode 100644 third_party/google/api/http.proto create mode 100644 third_party/google/api/httpbody.proto create mode 100644 third_party/google/api/launch_stage.proto create mode 100644 third_party/google/api/resource.proto create mode 100644 third_party/google/api/routing.proto create mode 100644 third_party/google/api/visibility.proto create mode 100644 third_party/google/bytestream/bytestream.proto create mode 100644 third_party/google/geo/type/viewport.proto create mode 100644 third_party/google/iam/v1/iam_policy.proto create mode 100644 third_party/google/iam/v1/options.proto create mode 100644 third_party/google/iam/v1/policy.proto create mode 100644 third_party/google/longrunning/operations.proto create mode 100644 third_party/google/protobuf/any.proto create mode 100644 third_party/google/protobuf/api.proto create mode 100644 third_party/google/protobuf/compiler/plugin.proto create mode 100644 third_party/google/protobuf/cpp_features.proto create mode 100644 third_party/google/protobuf/descriptor.proto create mode 100644 third_party/google/protobuf/duration.proto create mode 100644 third_party/google/protobuf/empty.proto create mode 100644 third_party/google/protobuf/field_mask.proto create mode 100644 third_party/google/protobuf/go_features.proto create mode 100644 third_party/google/protobuf/java_features.proto create mode 100644 third_party/google/protobuf/source_context.proto create mode 100644 third_party/google/protobuf/struct.proto create mode 100644 third_party/google/protobuf/timestamp.proto create mode 100644 third_party/google/protobuf/type.proto create mode 100644 third_party/google/protobuf/wrappers.proto create mode 100644 third_party/google/rpc/code.proto create mode 100644 third_party/google/rpc/context/attribute_context.proto create mode 100644 third_party/google/rpc/error_details.proto create mode 100644 third_party/google/rpc/status.proto create mode 100644 third_party/google/type/calendar_period.proto create mode 100644 third_party/google/type/color.proto create mode 100644 third_party/google/type/date.proto create mode 100644 third_party/google/type/datetime.proto create mode 100644 third_party/google/type/dayofweek.proto create mode 100644 third_party/google/type/decimal.proto create mode 100644 third_party/google/type/expr.proto create mode 100644 third_party/google/type/fraction.proto create mode 100644 third_party/google/type/interval.proto create mode 100644 third_party/google/type/latlng.proto create mode 100644 third_party/google/type/localized_text.proto create mode 100644 third_party/google/type/money.proto create mode 100644 third_party/google/type/month.proto create mode 100644 third_party/google/type/phone_number.proto create mode 100644 third_party/google/type/postal_address.proto create mode 100644 third_party/google/type/quaternion.proto create mode 100644 third_party/google/type/timeofday.proto create mode 100644 third_party/policy/v1/policy.proto create mode 100644 third_party/security/authn/apikey/v1/config.proto create mode 100644 third_party/security/authn/apikey/v1/credential.proto create mode 100644 third_party/security/authn/basic/v1/credential.proto create mode 100644 third_party/security/authn/jwt/v1/claims.proto create mode 100644 third_party/security/authn/jwt/v1/config.proto create mode 100644 third_party/security/authn/jwt/v1/data.proto create mode 100644 third_party/security/authn/oidc/v1/config.proto create mode 100644 third_party/security/authn/oidc/v1/credential.proto create mode 100644 third_party/security/authn/presharedkey/v1/config.proto create mode 100644 third_party/security/authn/v1/authn.proto create mode 100644 third_party/security/authz/casbin/v1/config.proto create mode 100644 third_party/security/authz/v1/authz.proto create mode 100644 third_party/security/v1/credential.proto create mode 100644 third_party/security/v1/error.proto create mode 100644 third_party/security/v1/principal.proto create mode 100644 third_party/security/v1/security.proto create mode 100644 third_party/service/security/authz/v1/service.proto create mode 100644 third_party/validate/validate.proto create mode 100644 tools.go diff --git a/Makefile b/Makefile index bff7717e..69bf7c7e 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ ifeq ($(GOHOSTOS), windows) BUILT_DATE = $(shell powershell -Command "Get-Date -Format 'yyyy-MM-ddTHH:mm:ssK'") TREE_STATE = $(shell powershell -Command "if ((git status) -match 'clean') { 'clean' } else { 'dirty' }") - TAG = $(shell powershell -Command "if ((git tag --points-at '${gitHash}') -match '^v') { '$(HEAD_TAG)' } else { '${gitHash}' }") + TAG = $(shell powershell -Command "if ((git tag --points-at '${gitHash}') -match '^v') { '$(HEAD_HEAD_TAG)' } else { '${gitHash}' }") # buildDate = $(shell TZ=Asia/Shanghai date +%F\ %T%z | tr 'T' ' ') # same as gitHash previously COMMIT = $(shell git log --pretty=format:'%h' -n 1) @@ -84,8 +84,8 @@ init: go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest go install github.com/google/wire/cmd/wire@latest go install github.com/envoyproxy/protoc-gen-validate@latest - go install github.com/bufbuild/buf/cmd/buf@latest + go install entgo.io/ent/cmd/ent@latest .PHONY: deps # update third_party proto @@ -99,33 +99,6 @@ deps: buf export buf.build/origadmin/runtime -o $(THIRD_PARTY_PATH) buf export buf.build/origadmin/contrib -o $(THIRD_PARTY_PATH) -.PHONY: config -# generate internal proto or use ./internal/generate.go -config: - protoc ${PROTO_PATH} \ - --go_out=paths=source_relative:./internal \ - --validate_out=lang=go:. \ - $(INTERNAL_PROTO_FILES) - -.PHONY: api -# generate api proto or use ./api/generate.go -api: -# protoc --proto_path=./api \ -# --proto_path=$(THIRD_PARTY_PATH) \ -# --go_out=paths=source_relative:./api \ -# --go-http_out=paths=source_relative:./api \ -# --go-grpc_out=paths=source_relative:./api \ -# --openapi_out=fq_schema_naming=true,default_response=false:. \ -# $(API_PROTO_FILES) - protoc ${PROTO_PATH} \ - --go_out=. \ - --go-http_out=. \ - --go-grpc_out=. \ - --go-gins_out=. \ - --go-errors_out=. \ - --validate_out=lang=go:. \ - $(API_PROTO_FILES) - .PHONY: openapi # generate the openapi spec file openapi: @@ -159,7 +132,7 @@ release: #.PHONY: server ## server used generate a service at first #server: -# kratos proto server -t ./internal/mods/helloworld/service ./api/v1/protos/helloworld/greeter.proto +# kratos proto server -t ./internal/features/helloworld/service ./api/v1/protos/helloworld/greeter.proto # #.PHONY: client ## client used when proto file is in the same directory @@ -172,8 +145,7 @@ release: #buf dep update #buf build #buf generate # generate proto files -#go generate ./internal/generate.go #generate configs -#go generate ./internal/mods/system/dal/entity/generate.go #generate dal entity +#go generate ./internal/features/system/dal/entity/generate.go #generate dal entity #go generate ./cmd/system #generate system module #go generate ./cmd/internal/start #generate main module start gen: @@ -183,20 +155,20 @@ gen: buf build buf generate - go generate ./internal/generate.go + @echo "Generating Protobuf code for helpers/resp/data/v1..." + @protoc -I. -I./third_party --go_out=paths=source_relative:. ./helpers/resp/data/v1/*.proto + + @echo "Generating Protobuf code for conf/pb..." + @protoc -I. -I./third_party --go_out=paths=source_relative:./internal --validate_out=paths=source_relative,lang=go:./internal ./conf/pb/*.proto go generate ./internal/data/entity/ent/generate.go go generate ./cmd/system go generate ./cmd/auth - go generate ./cmd/internal/start - .PHONY: all # generate all all: - $(MAKE) api; - $(MAKE) config; - $(MAKE) generate; + $(MAKE) gen; $(MAKE) openapi; .PHONY: http diff --git a/api/v1/proto/annotations.proto b/api/v1/proto/annotations.proto index 1594e933..53d6f124 100644 --- a/api/v1/proto/annotations.proto +++ b/api/v1/proto/annotations.proto @@ -17,7 +17,7 @@ option (gnostic.openapi.v3.document) = { } license: { name: "MIT" - url: "https://github.com/origadmin/backend/blob/master/LICENSE" + url: "https://origadmin/application/admin/blob/master/LICENSE" } } servers: [ diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index a053fe13..43b5db3d 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -19,6 +19,7 @@ service AuthService { rpc ListAuthResources(ListAuthResourcesRequest) returns (ListAuthResourcesResponse) { option (google.api.http) = {get: "/auth/resources"}; } + // CreateToken generates a new JWT token for the given user. rpc CreateToken(CreateTokenRequest) returns (CreateTokenResponse) { option (google.api.http) = { diff --git a/api/v1/proto/auth/login.proto b/api/v1/proto/auth/login.proto index 75890745..d21a5be2 100644 --- a/api/v1/proto/auth/login.proto +++ b/api/v1/proto/auth/login.proto @@ -4,7 +4,7 @@ package api.v1.services.auth; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; -import "security/jwt/v1/token.proto"; +import "security/v1/credential.proto"; import "validate/validate.proto"; option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; @@ -15,46 +15,46 @@ option objc_class_prefix = "APIServiceAuthLogin"; // The login service definition. service LoginService { - rpc Captcha (CaptchaRequest) returns (CaptchaResponse) { + rpc Captcha(CaptchaRequest) returns (CaptchaResponse) { option (google.api.http) = { get: "/captcha" response_body: "*" }; } - rpc CaptchaId (CaptchaIdRequest) returns (CaptchaIdResponse) { + rpc CaptchaId(CaptchaIdRequest) returns (CaptchaIdResponse) { option (google.api.http) = {get: "/captcha/id"}; } - rpc CaptchaImage (CaptchaImageRequest) returns (CaptchaImageResponse) { + rpc CaptchaImage(CaptchaImageRequest) returns (CaptchaImageResponse) { option (google.api.http) = { get: "/captcha/image" response_body: "*" }; } - rpc CaptchaAudio (CaptchaAudioRequest) returns (CaptchaAudioResponse) { + rpc CaptchaAudio(CaptchaAudioRequest) returns (CaptchaAudioResponse) { option (google.api.http) = { get: "/captcha/audio" response_body: "*" }; } - rpc Login (LoginRequest) returns (LoginResponse) { + rpc Login(LoginRequest) returns (LoginResponse) { option (google.api.http) = { post: "/login" body: "data" }; } - rpc Logout (LogoutRequest) returns (LogoutResponse) { + rpc Logout(LogoutRequest) returns (LogoutResponse) { option (google.api.http) = { post: "/logout" body: "data" }; } - rpc Register (RegisterRequest) returns (RegisterResponse) { + rpc Register(RegisterRequest) returns (RegisterResponse) { option (google.api.http) = { post: "/register" body: "data" }; } - rpc TokenRefresh (TokenRefreshRequest) returns (TokenRefreshResponse) { + rpc TokenRefresh(TokenRefreshRequest) returns (TokenRefreshResponse) { option (google.api.http) = { post: "/token/refresh" body: "data" @@ -73,7 +73,7 @@ message TokenRefreshRequest { } message TokenRefreshResponse { - security.jwt.v1.Token token = 1; + contrib.api.security.v1.TokenCredential token = 1; } message LoginRequest { @@ -99,7 +99,7 @@ message LoginRequest { } message LoginResponse { - security.jwt.v1.Token token = 1; + contrib.api.security.v1.TokenCredential token = 1; } message CurrentUserRequestQuery { @@ -156,7 +156,6 @@ message CaptchaAudioResponse { bytes audio = 2 [json_name = "audio"]; } - message CaptchaRequest { // The id of the captcha string id = 1 [json_name = "id"]; diff --git a/api/v1/services/annotations.pb.go b/api/v1/services/annotations.pb.go deleted file mode 100644 index 18f60855..00000000 --- a/api/v1/services/annotations.pb.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: annotations.proto - -package services - -import ( - _ "github.com/google/gnostic/openapiv3" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -var File_annotations_proto protoreflect.FileDescriptor - -const file_annotations_proto_rawDesc = "" + - "\n" + - "\x11annotations.proto\x12\x0fapi.v1.services\x1a$gnostic/openapi/v3/annotations.protoB\xce\x04\xbaG\x8f\x03\x12\x8c\x02\n" + - "\rOrigAdmin API\x12_A lightweight, flexible, elegant and full-featured RBAC scaffolding backend management project.\"@\n" + - "\aGodCong\x12\x1chttps://github.com/origadmin\x1a\x17waitforadding@gmail.com*?\n" + - "\x03MIT\x128https://github.com/origadmin/backend/blob/master/LICENSE2\x17Version from annotation\x1a\x18\n" + - "\x16http://localhost:10080\x1a\x19\n" + - "\x17https://localhost:10080*I:G\n" + - "\x18\n" + - "\x05Basic\x12\x0f\n" + - "\r\n" + - "\x04http*\x05basic\n" + - "+\n" + - "\x06Bearer\x12!\n" + - "\x1f\n" + - "\x06apiKey\x1a\rAuthorization\"\x06header\n" + - "\x13com.api.v1.servicesB\x10AnnotationsProtoP\x01Z4origadmin/application/admin/api/v1/services;services\xa2\x02\x03AVS\xaa\x02\x0fApi.V1.Services\xca\x02\x0fApi\\V1\\Services\xe2\x02\x1bApi\\V1\\Services\\GPBMetadata\xea\x02\x11Api::V1::Servicesb\x06proto3" - -var file_annotations_proto_goTypes = []any{} -var file_annotations_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_annotations_proto_init() } -func file_annotations_proto_init() { - if File_annotations_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_annotations_proto_rawDesc), len(file_annotations_proto_rawDesc)), - NumEnums: 0, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_annotations_proto_goTypes, - DependencyIndexes: file_annotations_proto_depIdxs, - }.Build() - File_annotations_proto = out.File - file_annotations_proto_goTypes = nil - file_annotations_proto_depIdxs = nil -} diff --git a/api/v1/services/annotations.pb.validate.go b/api/v1/services/annotations.pb.validate.go deleted file mode 100644 index c62ec169..00000000 --- a/api/v1/services/annotations.pb.validate.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: annotations.proto - -package services - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go deleted file mode 100644 index e5c2c744..00000000 --- a/api/v1/services/auth/auth.pb.go +++ /dev/null @@ -1,962 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: auth/auth.proto - -package auth - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type AuthLogoutRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *AuthLogoutRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AuthLogoutRequest) Reset() { - *x = AuthLogoutRequest{} - mi := &file_auth_auth_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AuthLogoutRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthLogoutRequest) ProtoMessage() {} - -func (x *AuthLogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[0] - 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 AuthLogoutRequest.ProtoReflect.Descriptor instead. -func (*AuthLogoutRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{0} -} - -func (x *AuthLogoutRequest) GetData() *AuthLogoutRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -type AuthLogoutResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AuthLogoutResponse) Reset() { - *x = AuthLogoutResponse{} - mi := &file_auth_auth_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AuthLogoutResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthLogoutResponse) ProtoMessage() {} - -func (x *AuthLogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[1] - 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 AuthLogoutResponse.ProtoReflect.Descriptor instead. -func (*AuthLogoutResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{1} -} - -func (x *AuthLogoutResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -type ListAuthResourcesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The maximum number of Auths to return. - PageSize int32 `protobuf:"varint,1,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,2,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,4,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListAuthResourcesRequest) Reset() { - *x = ListAuthResourcesRequest{} - mi := &file_auth_auth_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListAuthResourcesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListAuthResourcesRequest) ProtoMessage() {} - -func (x *ListAuthResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[2] - 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 ListAuthResourcesRequest.ProtoReflect.Descriptor instead. -func (*ListAuthResourcesRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{2} -} - -func (x *ListAuthResourcesRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListAuthResourcesRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListAuthResourcesRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListAuthResourcesRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -type ListAuthResourcesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The list of Auths. - Resources []*types.Resource `protobuf:"bytes,1,rep,name=resources,proto3" json:"resources,omitempty"` - // The total number of Auths in the result set. - TotalSize int32 `protobuf:"varint,2,opt,name=total_size,proto3" json:"total_size,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListAuthResourcesResponse) Reset() { - *x = ListAuthResourcesResponse{} - mi := &file_auth_auth_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListAuthResourcesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListAuthResourcesResponse) ProtoMessage() {} - -func (x *ListAuthResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[3] - 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 ListAuthResourcesResponse.ProtoReflect.Descriptor instead. -func (*ListAuthResourcesResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{3} -} - -func (x *ListAuthResourcesResponse) GetResources() []*types.Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *ListAuthResourcesResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -// CreateTokenRequest contains the information needed to create a token. -type CreateTokenRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *CreateTokenRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateTokenRequest) Reset() { - *x = CreateTokenRequest{} - mi := &file_auth_auth_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateTokenRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateTokenRequest) ProtoMessage() {} - -func (x *CreateTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[4] - 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 CreateTokenRequest.ProtoReflect.Descriptor instead. -func (*CreateTokenRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{4} -} - -func (x *CreateTokenRequest) GetData() *CreateTokenRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -// CreateTokenResponse contains the generated token. -type CreateTokenResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateTokenResponse) Reset() { - *x = CreateTokenResponse{} - mi := &file_auth_auth_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateTokenResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateTokenResponse) ProtoMessage() {} - -func (x *CreateTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[5] - 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 CreateTokenResponse.ProtoReflect.Descriptor instead. -func (*CreateTokenResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{5} -} - -func (x *CreateTokenResponse) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -// VerifyTokenRequest contains the token to be verified. -type ValidateTokenRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ValidateTokenRequest) Reset() { - *x = ValidateTokenRequest{} - mi := &file_auth_auth_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ValidateTokenRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ValidateTokenRequest) ProtoMessage() {} - -func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_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 ValidateTokenRequest.ProtoReflect.Descriptor instead. -func (*ValidateTokenRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{6} -} - -func (x *ValidateTokenRequest) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -// VerifyTokenResponse contains the result of the verification. -type ValidateTokenResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - IsValid bool `protobuf:"varint,1,opt,name=is_valid,proto3" json:"is_valid,omitempty"` - Claims map[string]string `protobuf:"bytes,2,rep,name=claims,proto3" json:"claims,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ValidateTokenResponse) Reset() { - *x = ValidateTokenResponse{} - mi := &file_auth_auth_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ValidateTokenResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ValidateTokenResponse) ProtoMessage() {} - -func (x *ValidateTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ValidateTokenResponse.ProtoReflect.Descriptor instead. -func (*ValidateTokenResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{7} -} - -func (x *ValidateTokenResponse) GetIsValid() bool { - if x != nil { - return x.IsValid - } - return false -} - -func (x *ValidateTokenResponse) GetClaims() map[string]string { - if x != nil { - return x.Claims - } - return nil -} - -// DestroyTokenRequest contains the token to be invalidated. -type DestroyTokenRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *DestroyTokenRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DestroyTokenRequest) Reset() { - *x = DestroyTokenRequest{} - mi := &file_auth_auth_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DestroyTokenRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DestroyTokenRequest) ProtoMessage() {} - -func (x *DestroyTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[8] - 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 DestroyTokenRequest.ProtoReflect.Descriptor instead. -func (*DestroyTokenRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{8} -} - -func (x *DestroyTokenRequest) GetData() *DestroyTokenRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -// DestroyTokenResponse contains the result of the invalidation. -type DestroyTokenResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DestroyTokenResponse) Reset() { - *x = DestroyTokenResponse{} - mi := &file_auth_auth_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DestroyTokenResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DestroyTokenResponse) ProtoMessage() {} - -func (x *DestroyTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[9] - 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 DestroyTokenResponse.ProtoReflect.Descriptor instead. -func (*DestroyTokenResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{9} -} - -func (x *DestroyTokenResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -type AuthenticateRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *AuthenticateRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AuthenticateRequest) Reset() { - *x = AuthenticateRequest{} - mi := &file_auth_auth_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AuthenticateRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthenticateRequest) ProtoMessage() {} - -func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[10] - 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 AuthenticateRequest.ProtoReflect.Descriptor instead. -func (*AuthenticateRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{10} -} - -func (x *AuthenticateRequest) GetData() *AuthenticateRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -type AuthenticateResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - IsValid bool `protobuf:"varint,1,opt,name=is_valid,proto3" json:"is_valid,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AuthenticateResponse) Reset() { - *x = AuthenticateResponse{} - mi := &file_auth_auth_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AuthenticateResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthenticateResponse) ProtoMessage() {} - -func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[11] - 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 AuthenticateResponse.ProtoReflect.Descriptor instead. -func (*AuthenticateResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{11} -} - -func (x *AuthenticateResponse) GetIsValid() bool { - if x != nil { - return x.IsValid - } - return false -} - -type AuthLogoutRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AuthLogoutRequest_Data) Reset() { - *x = AuthLogoutRequest_Data{} - mi := &file_auth_auth_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AuthLogoutRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthLogoutRequest_Data) ProtoMessage() {} - -func (x *AuthLogoutRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[12] - 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 AuthLogoutRequest_Data.ProtoReflect.Descriptor instead. -func (*AuthLogoutRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *AuthLogoutRequest_Data) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -type CreateTokenRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId string `protobuf:"bytes,1,opt,name=user_id,proto3" json:"user_id,omitempty"` - Scopes []string `protobuf:"bytes,2,rep,name=scopes,proto3" json:"scopes,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateTokenRequest_Data) Reset() { - *x = CreateTokenRequest_Data{} - mi := &file_auth_auth_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateTokenRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateTokenRequest_Data) ProtoMessage() {} - -func (x *CreateTokenRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[13] - 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 CreateTokenRequest_Data.ProtoReflect.Descriptor instead. -func (*CreateTokenRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{4, 0} -} - -func (x *CreateTokenRequest_Data) GetUserId() string { - if x != nil { - return x.UserId - } - return "" -} - -func (x *CreateTokenRequest_Data) GetScopes() []string { - if x != nil { - return x.Scopes - } - return nil -} - -type DestroyTokenRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DestroyTokenRequest_Data) Reset() { - *x = DestroyTokenRequest_Data{} - mi := &file_auth_auth_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DestroyTokenRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DestroyTokenRequest_Data) ProtoMessage() {} - -func (x *DestroyTokenRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[15] - 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 DestroyTokenRequest_Data.ProtoReflect.Descriptor instead. -func (*DestroyTokenRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{8, 0} -} - -func (x *DestroyTokenRequest_Data) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -type AuthenticateRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` - Method string `protobuf:"bytes,4,opt,name=method,proto3" json:"method,omitempty"` - Operation string `protobuf:"bytes,5,opt,name=operation,proto3" json:"operation,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AuthenticateRequest_Data) Reset() { - *x = AuthenticateRequest_Data{} - mi := &file_auth_auth_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AuthenticateRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*AuthenticateRequest_Data) ProtoMessage() {} - -func (x *AuthenticateRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[16] - 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 AuthenticateRequest_Data.ProtoReflect.Descriptor instead. -func (*AuthenticateRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{10, 0} -} - -func (x *AuthenticateRequest_Data) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -func (x *AuthenticateRequest_Data) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *AuthenticateRequest_Data) GetMethod() string { - if x != nil { - return x.Method - } - return "" -} - -func (x *AuthenticateRequest_Data) GetOperation() string { - if x != nil { - return x.Operation - } - return "" -} - -var File_auth_auth_proto protoreflect.FileDescriptor - -const file_auth_auth_proto_rawDesc = "" + - "\n" + - "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"s\n" + - "\x11AuthLogoutRequest\x12@\n" + - "\x04data\x18\x01 \x01(\v2,.api.v1.services.auth.AuthLogoutRequest.DataR\x04data\x1a\x1c\n" + - "\x04Data\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\"B\n" + - "\x12AuthLogoutResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"\x90\x01\n" + - "\x18ListAuthResourcesRequest\x12\x1c\n" + - "\tpage_size\x18\x01 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x02 \x01(\tR\n" + - "page_token\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tno_paging\x18\x04 \x01(\bR\tno_paging\"z\n" + - "\x19ListAuthResourcesResponse\x12=\n" + - "\tresources\x18\x01 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x1e\n" + - "\n" + - "total_size\x18\x02 \x01(\x05R\n" + - "total_size\"\x91\x01\n" + - "\x12CreateTokenRequest\x12A\n" + - "\x04data\x18\x01 \x01(\v2-.api.v1.services.auth.CreateTokenRequest.DataR\x04data\x1a8\n" + - "\x04Data\x12\x18\n" + - "\auser_id\x18\x01 \x01(\tR\auser_id\x12\x16\n" + - "\x06scopes\x18\x02 \x03(\tR\x06scopes\"+\n" + - "\x13CreateTokenResponse\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\",\n" + - "\x14ValidateTokenRequest\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\"\xbf\x01\n" + - "\x15ValidateTokenResponse\x12\x1a\n" + - "\bis_valid\x18\x01 \x01(\bR\bis_valid\x12O\n" + - "\x06claims\x18\x02 \x03(\v27.api.v1.services.auth.ValidateTokenResponse.ClaimsEntryR\x06claims\x1a9\n" + - "\vClaimsEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"w\n" + - "\x13DestroyTokenRequest\x12B\n" + - "\x04data\x18\x01 \x01(\v2..api.v1.services.auth.DestroyTokenRequest.DataR\x04data\x1a\x1c\n" + - "\x04Data\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\"D\n" + - "\x14DestroyTokenResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"\xc1\x01\n" + - "\x13AuthenticateRequest\x12B\n" + - "\x04data\x18\x01 \x01(\v2..api.v1.services.auth.AuthenticateRequest.DataR\x04data\x1af\n" + - "\x04Data\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\x12\x12\n" + - "\x04path\x18\x03 \x01(\tR\x04path\x12\x16\n" + - "\x06method\x18\x04 \x01(\tR\x06method\x12\x1c\n" + - "\toperation\x18\x05 \x01(\tR\toperation\"2\n" + - "\x14AuthenticateResponse\x12\x1a\n" + - "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xbb\x06\n" + - "\vAuthService\x12\x8d\x01\n" + - "\x11ListAuthResources\x12..api.v1.services.auth.ListAuthResourcesRequest\x1a/.api.v1.services.auth.ListAuthResourcesResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/auth/resources\x12}\n" + - "\vCreateToken\x12(.api.v1.services.auth.CreateTokenRequest\x1a).api.v1.services.auth.CreateTokenResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x04data\"\v/auth/token\x12\x80\x01\n" + - "\rValidateToken\x12*.api.v1.services.auth.ValidateTokenRequest\x1a+.api.v1.services.auth.ValidateTokenResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/auth/validate\x12\x82\x01\n" + - "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x04data\"\r/auth/destroy\x12\x87\x01\n" + - "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\" \x82\xd3\xe4\x93\x02\x1a:\x04data\"\x12/auth/authenticate\x12{\n" + - "\n" + - "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x04data\"\f/auth/logout\x1a\x0e\xcaA\vapi.foo.comB\xd0\x01\n" + - "\x18com.api.v1.services.authB\tAuthProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" - -var ( - file_auth_auth_proto_rawDescOnce sync.Once - file_auth_auth_proto_rawDescData []byte -) - -func file_auth_auth_proto_rawDescGZIP() []byte { - file_auth_auth_proto_rawDescOnce.Do(func() { - file_auth_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_auth_proto_rawDesc), len(file_auth_auth_proto_rawDesc))) - }) - return file_auth_auth_proto_rawDescData -} - -var file_auth_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 17) -var file_auth_auth_proto_goTypes = []any{ - (*AuthLogoutRequest)(nil), // 0: api.v1.services.auth.AuthLogoutRequest - (*AuthLogoutResponse)(nil), // 1: api.v1.services.auth.AuthLogoutResponse - (*ListAuthResourcesRequest)(nil), // 2: api.v1.services.auth.ListAuthResourcesRequest - (*ListAuthResourcesResponse)(nil), // 3: api.v1.services.auth.ListAuthResourcesResponse - (*CreateTokenRequest)(nil), // 4: api.v1.services.auth.CreateTokenRequest - (*CreateTokenResponse)(nil), // 5: api.v1.services.auth.CreateTokenResponse - (*ValidateTokenRequest)(nil), // 6: api.v1.services.auth.ValidateTokenRequest - (*ValidateTokenResponse)(nil), // 7: api.v1.services.auth.ValidateTokenResponse - (*DestroyTokenRequest)(nil), // 8: api.v1.services.auth.DestroyTokenRequest - (*DestroyTokenResponse)(nil), // 9: api.v1.services.auth.DestroyTokenResponse - (*AuthenticateRequest)(nil), // 10: api.v1.services.auth.AuthenticateRequest - (*AuthenticateResponse)(nil), // 11: api.v1.services.auth.AuthenticateResponse - (*AuthLogoutRequest_Data)(nil), // 12: api.v1.services.auth.AuthLogoutRequest.Data - (*CreateTokenRequest_Data)(nil), // 13: api.v1.services.auth.CreateTokenRequest.Data - nil, // 14: api.v1.services.auth.ValidateTokenResponse.ClaimsEntry - (*DestroyTokenRequest_Data)(nil), // 15: api.v1.services.auth.DestroyTokenRequest.Data - (*AuthenticateRequest_Data)(nil), // 16: api.v1.services.auth.AuthenticateRequest.Data - (*emptypb.Empty)(nil), // 17: google.protobuf.Empty - (*types.Resource)(nil), // 18: api.v1.services.types.Resource -} -var file_auth_auth_proto_depIdxs = []int32{ - 12, // 0: api.v1.services.auth.AuthLogoutRequest.data:type_name -> api.v1.services.auth.AuthLogoutRequest.Data - 17, // 1: api.v1.services.auth.AuthLogoutResponse.empty:type_name -> google.protobuf.Empty - 18, // 2: api.v1.services.auth.ListAuthResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 13, // 3: api.v1.services.auth.CreateTokenRequest.data:type_name -> api.v1.services.auth.CreateTokenRequest.Data - 14, // 4: api.v1.services.auth.ValidateTokenResponse.claims:type_name -> api.v1.services.auth.ValidateTokenResponse.ClaimsEntry - 15, // 5: api.v1.services.auth.DestroyTokenRequest.data:type_name -> api.v1.services.auth.DestroyTokenRequest.Data - 17, // 6: api.v1.services.auth.DestroyTokenResponse.empty:type_name -> google.protobuf.Empty - 16, // 7: api.v1.services.auth.AuthenticateRequest.data:type_name -> api.v1.services.auth.AuthenticateRequest.Data - 2, // 8: api.v1.services.auth.AuthService.ListAuthResources:input_type -> api.v1.services.auth.ListAuthResourcesRequest - 4, // 9: api.v1.services.auth.AuthService.CreateToken:input_type -> api.v1.services.auth.CreateTokenRequest - 6, // 10: api.v1.services.auth.AuthService.ValidateToken:input_type -> api.v1.services.auth.ValidateTokenRequest - 8, // 11: api.v1.services.auth.AuthService.DestroyToken:input_type -> api.v1.services.auth.DestroyTokenRequest - 10, // 12: api.v1.services.auth.AuthService.Authenticate:input_type -> api.v1.services.auth.AuthenticateRequest - 0, // 13: api.v1.services.auth.AuthService.AuthLogout:input_type -> api.v1.services.auth.AuthLogoutRequest - 3, // 14: api.v1.services.auth.AuthService.ListAuthResources:output_type -> api.v1.services.auth.ListAuthResourcesResponse - 5, // 15: api.v1.services.auth.AuthService.CreateToken:output_type -> api.v1.services.auth.CreateTokenResponse - 7, // 16: api.v1.services.auth.AuthService.ValidateToken:output_type -> api.v1.services.auth.ValidateTokenResponse - 9, // 17: api.v1.services.auth.AuthService.DestroyToken:output_type -> api.v1.services.auth.DestroyTokenResponse - 11, // 18: api.v1.services.auth.AuthService.Authenticate:output_type -> api.v1.services.auth.AuthenticateResponse - 1, // 19: api.v1.services.auth.AuthService.AuthLogout:output_type -> api.v1.services.auth.AuthLogoutResponse - 14, // [14:20] is the sub-list for method output_type - 8, // [8:14] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_auth_auth_proto_init() } -func file_auth_auth_proto_init() { - if File_auth_auth_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_auth_proto_rawDesc), len(file_auth_auth_proto_rawDesc)), - NumEnums: 0, - NumMessages: 17, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_auth_auth_proto_goTypes, - DependencyIndexes: file_auth_auth_proto_depIdxs, - MessageInfos: file_auth_auth_proto_msgTypes, - }.Build() - File_auth_auth_proto = out.File - file_auth_auth_proto_goTypes = nil - file_auth_auth_proto_depIdxs = nil -} diff --git a/api/v1/services/auth/auth.pb.gw.go b/api/v1/services/auth/auth.pb.gw.go deleted file mode 100644 index 40545037..00000000 --- a/api/v1/services/auth/auth.pb.gw.go +++ /dev/null @@ -1,487 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: auth/auth.proto - -/* -Package auth is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package auth - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_AuthService_ListAuthResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_AuthService_ListAuthResources_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListAuthResourcesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ListAuthResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListAuthResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_AuthService_ListAuthResources_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListAuthResourcesRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ListAuthResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListAuthResources(ctx, &protoReq) - return msg, metadata, err -} - -func request_AuthService_CreateToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreateToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_AuthService_CreateToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreateToken(ctx, &protoReq) - return msg, metadata, err -} - -var filter_AuthService_ValidateToken_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_AuthService_ValidateToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ValidateTokenRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ValidateToken_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ValidateToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_AuthService_ValidateToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ValidateTokenRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ValidateToken_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ValidateToken(ctx, &protoReq) - return msg, metadata, err -} - -func request_AuthService_DestroyToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DestroyTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.DestroyToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_AuthService_DestroyToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DestroyTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.DestroyToken(ctx, &protoReq) - return msg, metadata, err -} - -func request_AuthService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq AuthenticateRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Authenticate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_AuthService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq AuthenticateRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Authenticate(ctx, &protoReq) - return msg, metadata, err -} - -func request_AuthService_AuthLogout_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq AuthLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.AuthLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_AuthService_AuthLogout_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq AuthLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.AuthLogout(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterAuthServiceHandlerServer registers the http handlers for service AuthService to "mux". -// UnaryRPC :call AuthServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServiceServer) error { - mux.Handle(http.MethodGet, pattern_AuthService_ListAuthResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/auth/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_AuthService_ListAuthResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_ListAuthResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_AuthService_CreateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/auth/token")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_AuthService_CreateToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_CreateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_AuthService_ValidateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/auth/validate")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_AuthService_ValidateToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_ValidateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_AuthService_DestroyToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/auth/destroy")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_AuthService_DestroyToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_DestroyToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_AuthService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/auth/authenticate")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_AuthService_Authenticate_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_Authenticate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_AuthService_AuthLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/auth/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_AuthService_AuthLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_AuthLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterAuthServiceHandlerFromEndpoint is same as RegisterAuthServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterAuthServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterAuthServiceHandler(ctx, mux, conn) -} - -// RegisterAuthServiceHandler registers the http handlers for service AuthService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterAuthServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterAuthServiceHandlerClient(ctx, mux, NewAuthServiceClient(conn)) -} - -// RegisterAuthServiceHandlerClient registers the http handlers for service AuthService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AuthServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AuthServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "AuthServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthServiceClient) error { - mux.Handle(http.MethodGet, pattern_AuthService_ListAuthResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/auth/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_AuthService_ListAuthResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_ListAuthResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_AuthService_CreateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/auth/token")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_AuthService_CreateToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_CreateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_AuthService_ValidateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/auth/validate")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_AuthService_ValidateToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_ValidateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_AuthService_DestroyToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/auth/destroy")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_AuthService_DestroyToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_DestroyToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_AuthService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/auth/authenticate")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_AuthService_Authenticate_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_Authenticate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_AuthService_AuthLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/auth/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_AuthService_AuthLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_AuthLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_AuthService_ListAuthResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "resources"}, "")) - pattern_AuthService_CreateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "token"}, "")) - pattern_AuthService_ValidateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "validate"}, "")) - pattern_AuthService_DestroyToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "destroy"}, "")) - pattern_AuthService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "authenticate"}, "")) - pattern_AuthService_AuthLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "logout"}, "")) -) - -var ( - forward_AuthService_ListAuthResources_0 = runtime.ForwardResponseMessage - forward_AuthService_CreateToken_0 = runtime.ForwardResponseMessage - forward_AuthService_ValidateToken_0 = runtime.ForwardResponseMessage - forward_AuthService_DestroyToken_0 = runtime.ForwardResponseMessage - forward_AuthService_Authenticate_0 = runtime.ForwardResponseMessage - forward_AuthService_AuthLogout_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/auth/auth.pb.validate.go b/api/v1/services/auth/auth.pb.validate.go deleted file mode 100644 index 3cc97d16..00000000 --- a/api/v1/services/auth/auth.pb.validate.go +++ /dev/null @@ -1,1910 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: auth/auth.proto - -package auth - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on AuthLogoutRequest 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 *AuthLogoutRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on AuthLogoutRequest 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 -// AuthLogoutRequestMultiError, or nil if none found. -func (m *AuthLogoutRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *AuthLogoutRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, AuthLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, AuthLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return AuthLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return AuthLogoutRequestMultiError(errors) - } - - return nil -} - -// AuthLogoutRequestMultiError is an error wrapping multiple validation errors -// returned by AuthLogoutRequest.ValidateAll() if the designated constraints -// aren't met. -type AuthLogoutRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m AuthLogoutRequestMultiError) 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 AuthLogoutRequestMultiError) AllErrors() []error { return m } - -// AuthLogoutRequestValidationError is the validation error returned by -// AuthLogoutRequest.Validate if the designated constraints aren't met. -type AuthLogoutRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e AuthLogoutRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e AuthLogoutRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e AuthLogoutRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e AuthLogoutRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e AuthLogoutRequestValidationError) ErrorName() string { - return "AuthLogoutRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e AuthLogoutRequestValidationError) 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 %sAuthLogoutRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = AuthLogoutRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = AuthLogoutRequestValidationError{} - -// Validate checks the field values on AuthLogoutResponse 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 *AuthLogoutResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on AuthLogoutResponse 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 -// AuthLogoutResponseMultiError, or nil if none found. -func (m *AuthLogoutResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *AuthLogoutResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, AuthLogoutResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, AuthLogoutResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return AuthLogoutResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return AuthLogoutResponseMultiError(errors) - } - - return nil -} - -// AuthLogoutResponseMultiError is an error wrapping multiple validation errors -// returned by AuthLogoutResponse.ValidateAll() if the designated constraints -// aren't met. -type AuthLogoutResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m AuthLogoutResponseMultiError) 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 AuthLogoutResponseMultiError) AllErrors() []error { return m } - -// AuthLogoutResponseValidationError is the validation error returned by -// AuthLogoutResponse.Validate if the designated constraints aren't met. -type AuthLogoutResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e AuthLogoutResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e AuthLogoutResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e AuthLogoutResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e AuthLogoutResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e AuthLogoutResponseValidationError) ErrorName() string { - return "AuthLogoutResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e AuthLogoutResponseValidationError) 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 %sAuthLogoutResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = AuthLogoutResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = AuthLogoutResponseValidationError{} - -// Validate checks the field values on ListAuthResourcesRequest 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 *ListAuthResourcesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListAuthResourcesRequest 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 -// ListAuthResourcesRequestMultiError, or nil if none found. -func (m *ListAuthResourcesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListAuthResourcesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for Current - - // no validation rules for NoPaging - - if len(errors) > 0 { - return ListAuthResourcesRequestMultiError(errors) - } - - return nil -} - -// ListAuthResourcesRequestMultiError is an error wrapping multiple validation -// errors returned by ListAuthResourcesRequest.ValidateAll() if the designated -// constraints aren't met. -type ListAuthResourcesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListAuthResourcesRequestMultiError) 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 ListAuthResourcesRequestMultiError) AllErrors() []error { return m } - -// ListAuthResourcesRequestValidationError is the validation error returned by -// ListAuthResourcesRequest.Validate if the designated constraints aren't met. -type ListAuthResourcesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListAuthResourcesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListAuthResourcesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListAuthResourcesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListAuthResourcesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListAuthResourcesRequestValidationError) ErrorName() string { - return "ListAuthResourcesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListAuthResourcesRequestValidationError) 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 %sListAuthResourcesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListAuthResourcesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListAuthResourcesRequestValidationError{} - -// Validate checks the field values on ListAuthResourcesResponse 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 *ListAuthResourcesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListAuthResourcesResponse 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 -// ListAuthResourcesResponseMultiError, or nil if none found. -func (m *ListAuthResourcesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListAuthResourcesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListAuthResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListAuthResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListAuthResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for TotalSize - - if len(errors) > 0 { - return ListAuthResourcesResponseMultiError(errors) - } - - return nil -} - -// ListAuthResourcesResponseMultiError is an error wrapping multiple validation -// errors returned by ListAuthResourcesResponse.ValidateAll() if the -// designated constraints aren't met. -type ListAuthResourcesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListAuthResourcesResponseMultiError) 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 ListAuthResourcesResponseMultiError) AllErrors() []error { return m } - -// ListAuthResourcesResponseValidationError is the validation error returned by -// ListAuthResourcesResponse.Validate if the designated constraints aren't met. -type ListAuthResourcesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListAuthResourcesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListAuthResourcesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListAuthResourcesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListAuthResourcesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListAuthResourcesResponseValidationError) ErrorName() string { - return "ListAuthResourcesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListAuthResourcesResponseValidationError) 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 %sListAuthResourcesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListAuthResourcesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListAuthResourcesResponseValidationError{} - -// Validate checks the field values on CreateTokenRequest 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 *CreateTokenRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateTokenRequest 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 -// CreateTokenRequestMultiError, or nil if none found. -func (m *CreateTokenRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateTokenRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateTokenRequestMultiError(errors) - } - - return nil -} - -// CreateTokenRequestMultiError is an error wrapping multiple validation errors -// returned by CreateTokenRequest.ValidateAll() if the designated constraints -// aren't met. -type CreateTokenRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateTokenRequestMultiError) 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 CreateTokenRequestMultiError) AllErrors() []error { return m } - -// CreateTokenRequestValidationError is the validation error returned by -// CreateTokenRequest.Validate if the designated constraints aren't met. -type CreateTokenRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateTokenRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateTokenRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateTokenRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateTokenRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateTokenRequestValidationError) ErrorName() string { - return "CreateTokenRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateTokenRequestValidationError) 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 %sCreateTokenRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateTokenRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateTokenRequestValidationError{} - -// Validate checks the field values on CreateTokenResponse 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 *CreateTokenResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateTokenResponse 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 -// CreateTokenResponseMultiError, or nil if none found. -func (m *CreateTokenResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateTokenResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - if len(errors) > 0 { - return CreateTokenResponseMultiError(errors) - } - - return nil -} - -// CreateTokenResponseMultiError is an error wrapping multiple validation -// errors returned by CreateTokenResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateTokenResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateTokenResponseMultiError) 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 CreateTokenResponseMultiError) AllErrors() []error { return m } - -// CreateTokenResponseValidationError is the validation error returned by -// CreateTokenResponse.Validate if the designated constraints aren't met. -type CreateTokenResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateTokenResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateTokenResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateTokenResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateTokenResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateTokenResponseValidationError) ErrorName() string { - return "CreateTokenResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateTokenResponseValidationError) 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 %sCreateTokenResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateTokenResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateTokenResponseValidationError{} - -// Validate checks the field values on ValidateTokenRequest 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 *ValidateTokenRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ValidateTokenRequest 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 -// ValidateTokenRequestMultiError, or nil if none found. -func (m *ValidateTokenRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ValidateTokenRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - if len(errors) > 0 { - return ValidateTokenRequestMultiError(errors) - } - - return nil -} - -// ValidateTokenRequestMultiError is an error wrapping multiple validation -// errors returned by ValidateTokenRequest.ValidateAll() if the designated -// constraints aren't met. -type ValidateTokenRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ValidateTokenRequestMultiError) 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 ValidateTokenRequestMultiError) AllErrors() []error { return m } - -// ValidateTokenRequestValidationError is the validation error returned by -// ValidateTokenRequest.Validate if the designated constraints aren't met. -type ValidateTokenRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ValidateTokenRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ValidateTokenRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ValidateTokenRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ValidateTokenRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ValidateTokenRequestValidationError) ErrorName() string { - return "ValidateTokenRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ValidateTokenRequestValidationError) 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 %sValidateTokenRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ValidateTokenRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ValidateTokenRequestValidationError{} - -// Validate checks the field values on ValidateTokenResponse 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 *ValidateTokenResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ValidateTokenResponse 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 -// ValidateTokenResponseMultiError, or nil if none found. -func (m *ValidateTokenResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ValidateTokenResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for IsValid - - // no validation rules for Claims - - if len(errors) > 0 { - return ValidateTokenResponseMultiError(errors) - } - - return nil -} - -// ValidateTokenResponseMultiError is an error wrapping multiple validation -// errors returned by ValidateTokenResponse.ValidateAll() if the designated -// constraints aren't met. -type ValidateTokenResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ValidateTokenResponseMultiError) 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 ValidateTokenResponseMultiError) AllErrors() []error { return m } - -// ValidateTokenResponseValidationError is the validation error returned by -// ValidateTokenResponse.Validate if the designated constraints aren't met. -type ValidateTokenResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ValidateTokenResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ValidateTokenResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ValidateTokenResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ValidateTokenResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ValidateTokenResponseValidationError) ErrorName() string { - return "ValidateTokenResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ValidateTokenResponseValidationError) 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 %sValidateTokenResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ValidateTokenResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ValidateTokenResponseValidationError{} - -// Validate checks the field values on DestroyTokenRequest 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 *DestroyTokenRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DestroyTokenRequest 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 -// DestroyTokenRequestMultiError, or nil if none found. -func (m *DestroyTokenRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DestroyTokenRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DestroyTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DestroyTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DestroyTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DestroyTokenRequestMultiError(errors) - } - - return nil -} - -// DestroyTokenRequestMultiError is an error wrapping multiple validation -// errors returned by DestroyTokenRequest.ValidateAll() if the designated -// constraints aren't met. -type DestroyTokenRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DestroyTokenRequestMultiError) 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 DestroyTokenRequestMultiError) AllErrors() []error { return m } - -// DestroyTokenRequestValidationError is the validation error returned by -// DestroyTokenRequest.Validate if the designated constraints aren't met. -type DestroyTokenRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DestroyTokenRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DestroyTokenRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DestroyTokenRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DestroyTokenRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DestroyTokenRequestValidationError) ErrorName() string { - return "DestroyTokenRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DestroyTokenRequestValidationError) 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 %sDestroyTokenRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DestroyTokenRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DestroyTokenRequestValidationError{} - -// Validate checks the field values on DestroyTokenResponse 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 *DestroyTokenResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DestroyTokenResponse 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 -// DestroyTokenResponseMultiError, or nil if none found. -func (m *DestroyTokenResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DestroyTokenResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DestroyTokenResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DestroyTokenResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DestroyTokenResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DestroyTokenResponseMultiError(errors) - } - - return nil -} - -// DestroyTokenResponseMultiError is an error wrapping multiple validation -// errors returned by DestroyTokenResponse.ValidateAll() if the designated -// constraints aren't met. -type DestroyTokenResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DestroyTokenResponseMultiError) 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 DestroyTokenResponseMultiError) AllErrors() []error { return m } - -// DestroyTokenResponseValidationError is the validation error returned by -// DestroyTokenResponse.Validate if the designated constraints aren't met. -type DestroyTokenResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DestroyTokenResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DestroyTokenResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DestroyTokenResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DestroyTokenResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DestroyTokenResponseValidationError) ErrorName() string { - return "DestroyTokenResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DestroyTokenResponseValidationError) 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 %sDestroyTokenResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DestroyTokenResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DestroyTokenResponseValidationError{} - -// Validate checks the field values on AuthenticateRequest 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 *AuthenticateRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on AuthenticateRequest 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 -// AuthenticateRequestMultiError, or nil if none found. -func (m *AuthenticateRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *AuthenticateRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, AuthenticateRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, AuthenticateRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return AuthenticateRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return AuthenticateRequestMultiError(errors) - } - - return nil -} - -// AuthenticateRequestMultiError is an error wrapping multiple validation -// errors returned by AuthenticateRequest.ValidateAll() if the designated -// constraints aren't met. -type AuthenticateRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m AuthenticateRequestMultiError) 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 AuthenticateRequestMultiError) AllErrors() []error { return m } - -// AuthenticateRequestValidationError is the validation error returned by -// AuthenticateRequest.Validate if the designated constraints aren't met. -type AuthenticateRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e AuthenticateRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e AuthenticateRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e AuthenticateRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e AuthenticateRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e AuthenticateRequestValidationError) ErrorName() string { - return "AuthenticateRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e AuthenticateRequestValidationError) 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 %sAuthenticateRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = AuthenticateRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = AuthenticateRequestValidationError{} - -// Validate checks the field values on AuthenticateResponse 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 *AuthenticateResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on AuthenticateResponse 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 -// AuthenticateResponseMultiError, or nil if none found. -func (m *AuthenticateResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *AuthenticateResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for IsValid - - if len(errors) > 0 { - return AuthenticateResponseMultiError(errors) - } - - return nil -} - -// AuthenticateResponseMultiError is an error wrapping multiple validation -// errors returned by AuthenticateResponse.ValidateAll() if the designated -// constraints aren't met. -type AuthenticateResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m AuthenticateResponseMultiError) 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 AuthenticateResponseMultiError) AllErrors() []error { return m } - -// AuthenticateResponseValidationError is the validation error returned by -// AuthenticateResponse.Validate if the designated constraints aren't met. -type AuthenticateResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e AuthenticateResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e AuthenticateResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e AuthenticateResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e AuthenticateResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e AuthenticateResponseValidationError) ErrorName() string { - return "AuthenticateResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e AuthenticateResponseValidationError) 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 %sAuthenticateResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = AuthenticateResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = AuthenticateResponseValidationError{} - -// Validate checks the field values on AuthLogoutRequest_Data 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 *AuthLogoutRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on AuthLogoutRequest_Data 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 -// AuthLogoutRequest_DataMultiError, or nil if none found. -func (m *AuthLogoutRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *AuthLogoutRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - if len(errors) > 0 { - return AuthLogoutRequest_DataMultiError(errors) - } - - return nil -} - -// AuthLogoutRequest_DataMultiError is an error wrapping multiple validation -// errors returned by AuthLogoutRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type AuthLogoutRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m AuthLogoutRequest_DataMultiError) 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 AuthLogoutRequest_DataMultiError) AllErrors() []error { return m } - -// AuthLogoutRequest_DataValidationError is the validation error returned by -// AuthLogoutRequest_Data.Validate if the designated constraints aren't met. -type AuthLogoutRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e AuthLogoutRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e AuthLogoutRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e AuthLogoutRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e AuthLogoutRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e AuthLogoutRequest_DataValidationError) ErrorName() string { - return "AuthLogoutRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e AuthLogoutRequest_DataValidationError) 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 %sAuthLogoutRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = AuthLogoutRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = AuthLogoutRequest_DataValidationError{} - -// Validate checks the field values on CreateTokenRequest_Data 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 *CreateTokenRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateTokenRequest_Data 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 -// CreateTokenRequest_DataMultiError, or nil if none found. -func (m *CreateTokenRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateTokenRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for UserId - - if len(errors) > 0 { - return CreateTokenRequest_DataMultiError(errors) - } - - return nil -} - -// CreateTokenRequest_DataMultiError is an error wrapping multiple validation -// errors returned by CreateTokenRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type CreateTokenRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateTokenRequest_DataMultiError) 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 CreateTokenRequest_DataMultiError) AllErrors() []error { return m } - -// CreateTokenRequest_DataValidationError is the validation error returned by -// CreateTokenRequest_Data.Validate if the designated constraints aren't met. -type CreateTokenRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateTokenRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateTokenRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateTokenRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateTokenRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateTokenRequest_DataValidationError) ErrorName() string { - return "CreateTokenRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateTokenRequest_DataValidationError) 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 %sCreateTokenRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateTokenRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateTokenRequest_DataValidationError{} - -// Validate checks the field values on DestroyTokenRequest_Data 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 *DestroyTokenRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DestroyTokenRequest_Data 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 -// DestroyTokenRequest_DataMultiError, or nil if none found. -func (m *DestroyTokenRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *DestroyTokenRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - if len(errors) > 0 { - return DestroyTokenRequest_DataMultiError(errors) - } - - return nil -} - -// DestroyTokenRequest_DataMultiError is an error wrapping multiple validation -// errors returned by DestroyTokenRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type DestroyTokenRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DestroyTokenRequest_DataMultiError) 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 DestroyTokenRequest_DataMultiError) AllErrors() []error { return m } - -// DestroyTokenRequest_DataValidationError is the validation error returned by -// DestroyTokenRequest_Data.Validate if the designated constraints aren't met. -type DestroyTokenRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DestroyTokenRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DestroyTokenRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DestroyTokenRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DestroyTokenRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DestroyTokenRequest_DataValidationError) ErrorName() string { - return "DestroyTokenRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e DestroyTokenRequest_DataValidationError) 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 %sDestroyTokenRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DestroyTokenRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DestroyTokenRequest_DataValidationError{} - -// Validate checks the field values on AuthenticateRequest_Data 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 *AuthenticateRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on AuthenticateRequest_Data 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 -// AuthenticateRequest_DataMultiError, or nil if none found. -func (m *AuthenticateRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *AuthenticateRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - // no validation rules for Path - - // no validation rules for Method - - // no validation rules for Operation - - if len(errors) > 0 { - return AuthenticateRequest_DataMultiError(errors) - } - - return nil -} - -// AuthenticateRequest_DataMultiError is an error wrapping multiple validation -// errors returned by AuthenticateRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type AuthenticateRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m AuthenticateRequest_DataMultiError) 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 AuthenticateRequest_DataMultiError) AllErrors() []error { return m } - -// AuthenticateRequest_DataValidationError is the validation error returned by -// AuthenticateRequest_Data.Validate if the designated constraints aren't met. -type AuthenticateRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e AuthenticateRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e AuthenticateRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e AuthenticateRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e AuthenticateRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e AuthenticateRequest_DataValidationError) ErrorName() string { - return "AuthenticateRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e AuthenticateRequest_DataValidationError) 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 %sAuthenticateRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = AuthenticateRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = AuthenticateRequest_DataValidationError{} diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go deleted file mode 100644 index e2e5322b..00000000 --- a/api/v1/services/auth/auth_bridge.pb.go +++ /dev/null @@ -1,450 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: auth/auth.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const AuthServiceAuthLogoutBridgeOperation = "/api.v1.services.auth.AuthService/AuthLogout" -const AuthServiceAuthenticateBridgeOperation = "/api.v1.services.auth.AuthService/Authenticate" -const AuthServiceCreateTokenBridgeOperation = "/api.v1.services.auth.AuthService/CreateToken" -const AuthServiceDestroyTokenBridgeOperation = "/api.v1.services.auth.AuthService/DestroyToken" -const AuthServiceListAuthResourcesBridgeOperation = "/api.v1.services.auth.AuthService/ListAuthResources" -const AuthServiceValidateTokenBridgeOperation = "/api.v1.services.auth.AuthService/ValidateToken" - -type AuthServiceBridgeServer interface { - // AuthLogout logs out a user. - AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) - // Authenticate authenticates a user. - Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) - // CreateToken generates a new JWT token for the given user. - CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) - // DestroyToken invalidates a JWT token. - DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) - // ListAuthResources returns a list of Auths. - ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) - // ValidateToken verifies the validity of a JWT token. - ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) -} - -type AuthServiceHooker interface { - AuthServiceAuthLogoutHooker - AuthServiceAuthenticateHooker - AuthServiceCreateTokenHooker - AuthServiceDestroyTokenHooker - AuthServiceListAuthResourcesHooker - AuthServiceValidateTokenHooker -} - -type AuthServiceHookedBridger interface { - AuthServiceHooker - AuthServiceBridgeServer -} -type AuthServiceAuthLogoutHooker interface { - PrepareAuthLogout(http.Context, *AuthLogoutRequest) (context.Context, error) - CompleteAuthLogout(http.Context, *AuthLogoutRequest, *AuthLogoutResponse) error -} -type AuthServiceAuthenticateHooker interface { - PrepareAuthenticate(http.Context, *AuthenticateRequest) (context.Context, error) - CompleteAuthenticate(http.Context, *AuthenticateRequest, *AuthenticateResponse) error -} -type AuthServiceCreateTokenHooker interface { - PrepareCreateToken(http.Context, *CreateTokenRequest) (context.Context, error) - CompleteCreateToken(http.Context, *CreateTokenRequest, *CreateTokenResponse) error -} -type AuthServiceDestroyTokenHooker interface { - PrepareDestroyToken(http.Context, *DestroyTokenRequest) (context.Context, error) - CompleteDestroyToken(http.Context, *DestroyTokenRequest, *DestroyTokenResponse) error -} -type AuthServiceListAuthResourcesHooker interface { - PrepareListAuthResources(http.Context, *ListAuthResourcesRequest) (context.Context, error) - CompleteListAuthResources(http.Context, *ListAuthResourcesRequest, *ListAuthResourcesResponse) error -} -type AuthServiceValidateTokenHooker interface { - PrepareValidateToken(http.Context, *ValidateTokenRequest) (context.Context, error) - CompleteValidateToken(http.Context, *ValidateTokenRequest, *ValidateTokenResponse) error -} - -func RegisterAuthServiceBridgeServer(s *http.Server, srv AuthServiceHookedBridger) { - r := s.Route("/") - r.GET("/auth/resources", _AuthService_ListAuthResources0_Bridge_Handler(srv)) - r.POST("/auth/token", _AuthService_CreateToken0_Bridge_Handler(srv)) - r.GET("/auth/validate", _AuthService_ValidateToken0_Bridge_Handler(srv)) - r.POST("/auth/destroy", _AuthService_DestroyToken0_Bridge_Handler(srv)) - r.POST("/auth/authenticate", _AuthService_Authenticate0_Bridge_Handler(srv)) - r.POST("/auth/logout", _AuthService_AuthLogout0_Bridge_Handler(srv)) -} - -func _AuthService_ListAuthResources0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListAuthResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceListAuthResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) - }) - - newctx, err := srv.PrepareListAuthResources(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListAuthResources(ctx, &in, out.(*ListAuthResourcesResponse)) - } -} - -func _AuthService_CreateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceCreateToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateToken(ctx, req.(*CreateTokenRequest)) - }) - - newctx, err := srv.PrepareCreateToken(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreateToken(ctx, &in, out.(*CreateTokenResponse)) - } -} - -func _AuthService_ValidateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ValidateTokenRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceValidateToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ValidateToken(ctx, req.(*ValidateTokenRequest)) - }) - - newctx, err := srv.PrepareValidateToken(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteValidateToken(ctx, &in, out.(*ValidateTokenResponse)) - } -} - -func _AuthService_DestroyToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DestroyTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceDestroyToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DestroyToken(ctx, req.(*DestroyTokenRequest)) - }) - - newctx, err := srv.PrepareDestroyToken(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDestroyToken(ctx, &in, out.(*DestroyTokenResponse)) - } -} - -func _AuthService_Authenticate0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in AuthenticateRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceAuthenticate) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Authenticate(ctx, req.(*AuthenticateRequest)) - }) - - newctx, err := srv.PrepareAuthenticate(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteAuthenticate(ctx, &in, out.(*AuthenticateResponse)) - } -} - -func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in AuthLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceAuthLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.AuthLogout(ctx, req.(*AuthLogoutRequest)) - }) - - newctx, err := srv.PrepareAuthLogout(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteAuthLogout(ctx, &in, out.(*AuthLogoutResponse)) - } -} - -// UnimplementedAuthServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedAuthServiceHooked struct{} - -func (UnimplementedAuthServiceHooked) PrepareAuthLogout(ctx http.Context, in *AuthLogoutRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedAuthServiceHooked) CompleteAuthLogout(ctx http.Context, in *AuthLogoutRequest, out *AuthLogoutResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedAuthServiceHooked) PrepareAuthenticate(ctx http.Context, in *AuthenticateRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedAuthServiceHooked) CompleteAuthenticate(ctx http.Context, in *AuthenticateRequest, out *AuthenticateResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedAuthServiceHooked) PrepareCreateToken(ctx http.Context, in *CreateTokenRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedAuthServiceHooked) CompleteCreateToken(ctx http.Context, in *CreateTokenRequest, out *CreateTokenResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedAuthServiceHooked) PrepareDestroyToken(ctx http.Context, in *DestroyTokenRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedAuthServiceHooked) CompleteDestroyToken(ctx http.Context, in *DestroyTokenRequest, out *DestroyTokenResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedAuthServiceHooked) PrepareListAuthResources(ctx http.Context, in *ListAuthResourcesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedAuthServiceHooked) CompleteListAuthResources(ctx http.Context, in *ListAuthResourcesRequest, out *ListAuthResourcesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedAuthServiceHooked) PrepareValidateToken(ctx http.Context, in *ValidateTokenRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedAuthServiceHooked) CompleteValidateToken(ctx http.Context, in *ValidateTokenRequest, out *ValidateTokenResponse) error { - return ctx.Result(200, out) -} - -func WithAuthServiceHook(h AuthServiceHooker) func(AuthServiceBridgeServer) AuthServiceHookedBridger { - return func(srv AuthServiceBridgeServer) AuthServiceHookedBridger { - return AuthServiceHookedBridge{AuthServiceBridgeServer: srv, AuthServiceHooker: h} - } -} - -// AuthServiceHookedBridge is a bridge between the HTTP and gRPC implementations of AuthService. -// It implements the HTTP and gRPC implementations of AuthService. -// It forwards requests and responses between the two implementations. -type AuthServiceHookedBridge struct { - AuthServiceBridgeServer - AuthServiceHooker -} - -type AuthServiceHTTPBridgeImpl struct { - client AuthServiceHTTPClient -} - -func NewAuthServiceHTTPBridge(client *http.Client) AuthServiceHTTPServer { - return &AuthServiceHTTPBridgeImpl{client: NewAuthServiceHTTPClient(client)} -} - -func (c *AuthServiceHTTPBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { - return c.client.AuthLogout(ctx, in) -} - -func (c *AuthServiceHTTPBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { - return c.client.Authenticate(ctx, in) -} - -func (c *AuthServiceHTTPBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { - return c.client.CreateToken(ctx, in) -} - -func (c *AuthServiceHTTPBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { - return c.client.DestroyToken(ctx, in) -} - -func (c *AuthServiceHTTPBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { - return c.client.ListAuthResources(ctx, in) -} - -func (c *AuthServiceHTTPBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { - return c.client.ValidateToken(ctx, in) -} - -type AuthServiceBridgeImpl struct { - client AuthServiceClient -} - -func NewAuthServiceBridge(client grpc.ClientConnInterface) AuthServiceServer { - return &AuthServiceBridgeImpl{client: NewAuthServiceClient(client)} -} - -func (c *AuthServiceBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { - return c.client.AuthLogout(ctx, in) -} - -func (c *AuthServiceBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { - return c.client.Authenticate(ctx, in) -} - -func (c *AuthServiceBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { - return c.client.CreateToken(ctx, in) -} - -func (c *AuthServiceBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { - return c.client.DestroyToken(ctx, in) -} - -func (c *AuthServiceBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { - return c.client.ListAuthResources(ctx, in) -} - -func (c *AuthServiceBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { - return c.client.ValidateToken(ctx, in) -} - -func (c *AuthServiceBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} - -type AuthServiceGRPC2HTTPBridgeImpl struct { - client AuthServiceClient -} - -func NewAuthServiceGRPC2HTTP(client grpc.ClientConnInterface) AuthServiceHTTPServer { - return &AuthServiceGRPC2HTTPBridgeImpl{client: NewAuthServiceClient(client)} -} - -func (c *AuthServiceGRPC2HTTPBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { - return c.client.AuthLogout(ctx, in) -} - -func (c *AuthServiceGRPC2HTTPBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { - return c.client.Authenticate(ctx, in) -} - -func (c *AuthServiceGRPC2HTTPBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { - return c.client.CreateToken(ctx, in) -} - -func (c *AuthServiceGRPC2HTTPBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { - return c.client.DestroyToken(ctx, in) -} - -func (c *AuthServiceGRPC2HTTPBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { - return c.client.ListAuthResources(ctx, in) -} - -func (c *AuthServiceGRPC2HTTPBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { - return c.client.ValidateToken(ctx, in) -} - -type AuthServiceHTTP2GRPCBridgeImpl struct { - client AuthServiceHTTPClient -} - -func NewAuthServiceHTTP2GRPC(client *http.Client) AuthServiceServer { - return &AuthServiceHTTP2GRPCBridgeImpl{client: NewAuthServiceHTTPClient(client)} -} - -func (c *AuthServiceHTTP2GRPCBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { - return c.client.AuthLogout(ctx, in) -} - -func (c *AuthServiceHTTP2GRPCBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { - return c.client.Authenticate(ctx, in) -} - -func (c *AuthServiceHTTP2GRPCBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { - return c.client.CreateToken(ctx, in) -} - -func (c *AuthServiceHTTP2GRPCBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { - return c.client.DestroyToken(ctx, in) -} - -func (c *AuthServiceHTTP2GRPCBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { - return c.client.ListAuthResources(ctx, in) -} - -func (c *AuthServiceHTTP2GRPCBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { - return c.client.ValidateToken(ctx, in) -} - -func (c *AuthServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} diff --git a/api/v1/services/auth/auth_grpc.pb.go b/api/v1/services/auth/auth_grpc.pb.go deleted file mode 100644 index fcac5f0b..00000000 --- a/api/v1/services/auth/auth_grpc.pb.go +++ /dev/null @@ -1,323 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: auth/auth.proto - -package auth - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - AuthService_ListAuthResources_FullMethodName = "/api.v1.services.auth.AuthService/ListAuthResources" - AuthService_CreateToken_FullMethodName = "/api.v1.services.auth.AuthService/CreateToken" - AuthService_ValidateToken_FullMethodName = "/api.v1.services.auth.AuthService/ValidateToken" - AuthService_DestroyToken_FullMethodName = "/api.v1.services.auth.AuthService/DestroyToken" - AuthService_Authenticate_FullMethodName = "/api.v1.services.auth.AuthService/Authenticate" - AuthService_AuthLogout_FullMethodName = "/api.v1.services.auth.AuthService/AuthLogout" -) - -// AuthServiceClient is the client API for AuthService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type AuthServiceClient interface { - // ListAuthResources returns a list of Auths. - ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...grpc.CallOption) (*ListAuthResourcesResponse, error) - // CreateToken generates a new JWT token for the given user. - CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...grpc.CallOption) (*CreateTokenResponse, error) - // ValidateToken verifies the validity of a JWT token. - ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*ValidateTokenResponse, error) - // DestroyToken invalidates a JWT token. - DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...grpc.CallOption) (*DestroyTokenResponse, error) - // Authenticate authenticates a user. - Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) - // AuthLogout logs out a user. - AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...grpc.CallOption) (*AuthLogoutResponse, error) -} - -type authServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { - return &authServiceClient{cc} -} - -func (c *authServiceClient) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...grpc.CallOption) (*ListAuthResourcesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListAuthResourcesResponse) - err := c.cc.Invoke(ctx, AuthService_ListAuthResources_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *authServiceClient) CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...grpc.CallOption) (*CreateTokenResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateTokenResponse) - err := c.cc.Invoke(ctx, AuthService_CreateToken_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *authServiceClient) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*ValidateTokenResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ValidateTokenResponse) - err := c.cc.Invoke(ctx, AuthService_ValidateToken_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *authServiceClient) DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...grpc.CallOption) (*DestroyTokenResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DestroyTokenResponse) - err := c.cc.Invoke(ctx, AuthService_DestroyToken_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *authServiceClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(AuthenticateResponse) - err := c.cc.Invoke(ctx, AuthService_Authenticate_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *authServiceClient) AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...grpc.CallOption) (*AuthLogoutResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(AuthLogoutResponse) - err := c.cc.Invoke(ctx, AuthService_AuthLogout_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// AuthServiceServer is the server API for AuthService service. -// All implementations must embed UnimplementedAuthServiceServer -// for forward compatibility. -type AuthServiceServer interface { - // ListAuthResources returns a list of Auths. - ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) - // CreateToken generates a new JWT token for the given user. - CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) - // ValidateToken verifies the validity of a JWT token. - ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) - // DestroyToken invalidates a JWT token. - DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) - // Authenticate authenticates a user. - Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) - // AuthLogout logs out a user. - AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) - mustEmbedUnimplementedAuthServiceServer() -} - -// UnimplementedAuthServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedAuthServiceServer struct{} - -func (UnimplementedAuthServiceServer) ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListAuthResources not implemented") -} -func (UnimplementedAuthServiceServer) CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateToken not implemented") -} -func (UnimplementedAuthServiceServer) ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ValidateToken not implemented") -} -func (UnimplementedAuthServiceServer) DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DestroyToken not implemented") -} -func (UnimplementedAuthServiceServer) Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") -} -func (UnimplementedAuthServiceServer) AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AuthLogout not implemented") -} -func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} -func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} - -// UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to AuthServiceServer will -// result in compilation errors. -type UnsafeAuthServiceServer interface { - mustEmbedUnimplementedAuthServiceServer() -} - -func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { - // If the following call pancis, it indicates UnimplementedAuthServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&AuthService_ServiceDesc, srv) -} - -func _AuthService_ListAuthResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListAuthResourcesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AuthServiceServer).ListAuthResources(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: AuthService_ListAuthResources_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _AuthService_CreateToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateTokenRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AuthServiceServer).CreateToken(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: AuthService_CreateToken_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).CreateToken(ctx, req.(*CreateTokenRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _AuthService_ValidateToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ValidateTokenRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AuthServiceServer).ValidateToken(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: AuthService_ValidateToken_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).ValidateToken(ctx, req.(*ValidateTokenRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _AuthService_DestroyToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DestroyTokenRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AuthServiceServer).DestroyToken(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: AuthService_DestroyToken_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).DestroyToken(ctx, req.(*DestroyTokenRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _AuthService_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AuthenticateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AuthServiceServer).Authenticate(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: AuthService_Authenticate_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).Authenticate(ctx, req.(*AuthenticateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _AuthService_AuthLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AuthLogoutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AuthServiceServer).AuthLogout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: AuthService_AuthLogout_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).AuthLogout(ctx, req.(*AuthLogoutRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var AuthService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.auth.AuthService", - HandlerType: (*AuthServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListAuthResources", - Handler: _AuthService_ListAuthResources_Handler, - }, - { - MethodName: "CreateToken", - Handler: _AuthService_CreateToken_Handler, - }, - { - MethodName: "ValidateToken", - Handler: _AuthService_ValidateToken_Handler, - }, - { - MethodName: "DestroyToken", - Handler: _AuthService_DestroyToken_Handler, - }, - { - MethodName: "Authenticate", - Handler: _AuthService_Authenticate_Handler, - }, - { - MethodName: "AuthLogout", - Handler: _AuthService_AuthLogout_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "auth/auth.proto", -} diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go deleted file mode 100644 index cd009a40..00000000 --- a/api/v1/services/auth/auth_http.pb.go +++ /dev/null @@ -1,285 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: auth/auth.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationAuthServiceAuthLogout = "/api.v1.services.auth.AuthService/AuthLogout" -const OperationAuthServiceAuthenticate = "/api.v1.services.auth.AuthService/Authenticate" -const OperationAuthServiceCreateToken = "/api.v1.services.auth.AuthService/CreateToken" -const OperationAuthServiceDestroyToken = "/api.v1.services.auth.AuthService/DestroyToken" -const OperationAuthServiceListAuthResources = "/api.v1.services.auth.AuthService/ListAuthResources" -const OperationAuthServiceValidateToken = "/api.v1.services.auth.AuthService/ValidateToken" - -type AuthServiceHTTPServer interface { - // AuthLogout AuthLogout logs out a user. - AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) - // Authenticate Authenticate authenticates a user. - Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) - // CreateToken CreateToken generates a new JWT token for the given user. - CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) - // DestroyToken DestroyToken invalidates a JWT token. - DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) - // ListAuthResources ListAuthResources returns a list of Auths. - ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) - // ValidateToken ValidateToken verifies the validity of a JWT token. - ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) -} - -func RegisterAuthServiceHTTPServer(s *http.Server, srv AuthServiceHTTPServer) { - r := s.Route("/") - r.GET("/auth/resources", _AuthService_ListAuthResources0_HTTP_Handler(srv)) - r.POST("/auth/token", _AuthService_CreateToken0_HTTP_Handler(srv)) - r.GET("/auth/validate", _AuthService_ValidateToken0_HTTP_Handler(srv)) - r.POST("/auth/destroy", _AuthService_DestroyToken0_HTTP_Handler(srv)) - r.POST("/auth/authenticate", _AuthService_Authenticate0_HTTP_Handler(srv)) - r.POST("/auth/logout", _AuthService_AuthLogout0_HTTP_Handler(srv)) -} - -func _AuthService_ListAuthResources0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListAuthResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceListAuthResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListAuthResourcesResponse) - return ctx.Result(200, reply) - } -} - -func _AuthService_CreateToken0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceCreateToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateToken(ctx, req.(*CreateTokenRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreateTokenResponse) - return ctx.Result(200, reply) - } -} - -func _AuthService_ValidateToken0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ValidateTokenRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceValidateToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ValidateToken(ctx, req.(*ValidateTokenRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ValidateTokenResponse) - return ctx.Result(200, reply) - } -} - -func _AuthService_DestroyToken0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DestroyTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceDestroyToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DestroyToken(ctx, req.(*DestroyTokenRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DestroyTokenResponse) - return ctx.Result(200, reply) - } -} - -func _AuthService_Authenticate0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in AuthenticateRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceAuthenticate) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Authenticate(ctx, req.(*AuthenticateRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*AuthenticateResponse) - return ctx.Result(200, reply) - } -} - -func _AuthService_AuthLogout0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in AuthLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceAuthLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.AuthLogout(ctx, req.(*AuthLogoutRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*AuthLogoutResponse) - return ctx.Result(200, reply) - } -} - -type AuthServiceHTTPClient interface { - // AuthLogout AuthLogout logs out a user. - AuthLogout(ctx context.Context, req *AuthLogoutRequest, opts ...http.CallOption) (rsp *AuthLogoutResponse, err error) - // Authenticate Authenticate authenticates a user. - Authenticate(ctx context.Context, req *AuthenticateRequest, opts ...http.CallOption) (rsp *AuthenticateResponse, err error) - // CreateToken CreateToken generates a new JWT token for the given user. - CreateToken(ctx context.Context, req *CreateTokenRequest, opts ...http.CallOption) (rsp *CreateTokenResponse, err error) - // DestroyToken DestroyToken invalidates a JWT token. - DestroyToken(ctx context.Context, req *DestroyTokenRequest, opts ...http.CallOption) (rsp *DestroyTokenResponse, err error) - // ListAuthResources ListAuthResources returns a list of Auths. - ListAuthResources(ctx context.Context, req *ListAuthResourcesRequest, opts ...http.CallOption) (rsp *ListAuthResourcesResponse, err error) - // ValidateToken ValidateToken verifies the validity of a JWT token. - ValidateToken(ctx context.Context, req *ValidateTokenRequest, opts ...http.CallOption) (rsp *ValidateTokenResponse, err error) -} - -type AuthServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewAuthServiceHTTPClient(client *http.Client) AuthServiceHTTPClient { - return &AuthServiceHTTPClientImpl{client} -} - -// AuthLogout AuthLogout logs out a user. -func (c *AuthServiceHTTPClientImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...http.CallOption) (*AuthLogoutResponse, error) { - var out AuthLogoutResponse - pattern := "/auth/logout" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthServiceAuthLogout)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// Authenticate Authenticate authenticates a user. -func (c *AuthServiceHTTPClientImpl) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...http.CallOption) (*AuthenticateResponse, error) { - var out AuthenticateResponse - pattern := "/auth/authenticate" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthServiceAuthenticate)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// CreateToken CreateToken generates a new JWT token for the given user. -func (c *AuthServiceHTTPClientImpl) CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...http.CallOption) (*CreateTokenResponse, error) { - var out CreateTokenResponse - pattern := "/auth/token" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthServiceCreateToken)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// DestroyToken DestroyToken invalidates a JWT token. -func (c *AuthServiceHTTPClientImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...http.CallOption) (*DestroyTokenResponse, error) { - var out DestroyTokenResponse - pattern := "/auth/destroy" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthServiceDestroyToken)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ListAuthResources ListAuthResources returns a list of Auths. -func (c *AuthServiceHTTPClientImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...http.CallOption) (*ListAuthResourcesResponse, error) { - var out ListAuthResourcesResponse - pattern := "/auth/resources" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationAuthServiceListAuthResources)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ValidateToken ValidateToken verifies the validity of a JWT token. -func (c *AuthServiceHTTPClientImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...http.CallOption) (*ValidateTokenResponse, error) { - var out ValidateTokenResponse - pattern := "/auth/validate" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationAuthServiceValidateToken)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/auth/casbin.pb.go b/api/v1/services/auth/casbin.pb.go deleted file mode 100644 index 09c72623..00000000 --- a/api/v1/services/auth/casbin.pb.go +++ /dev/null @@ -1,618 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: auth/casbin.proto - -package auth - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ListPoliciesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPoliciesRequest) Reset() { - *x = ListPoliciesRequest{} - mi := &file_auth_casbin_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPoliciesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPoliciesRequest) ProtoMessage() {} - -func (x *ListPoliciesRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_casbin_proto_msgTypes[0] - 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 ListPoliciesRequest.ProtoReflect.Descriptor instead. -func (*ListPoliciesRequest) Descriptor() ([]byte, []int) { - return file_auth_casbin_proto_rawDescGZIP(), []int{0} -} - -type ListPoliciesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Rules []*PolicyRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPoliciesResponse) Reset() { - *x = ListPoliciesResponse{} - mi := &file_auth_casbin_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPoliciesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPoliciesResponse) ProtoMessage() {} - -func (x *ListPoliciesResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_casbin_proto_msgTypes[1] - 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 ListPoliciesResponse.ProtoReflect.Descriptor instead. -func (*ListPoliciesResponse) Descriptor() ([]byte, []int) { - return file_auth_casbin_proto_rawDescGZIP(), []int{1} -} - -func (x *ListPoliciesResponse) GetRules() []*PolicyRule { - if x != nil { - return x.Rules - } - return nil -} - -type PolicyRule struct { - state protoimpl.MessageState `protogen:"open.v1"` - PType string `protobuf:"bytes,1,opt,name=p_type,proto3" json:"p_type,omitempty"` - Params []string `protobuf:"bytes,2,rep,name=params,proto3" json:"params,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PolicyRule) Reset() { - *x = PolicyRule{} - mi := &file_auth_casbin_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PolicyRule) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PolicyRule) ProtoMessage() {} - -func (x *PolicyRule) ProtoReflect() protoreflect.Message { - mi := &file_auth_casbin_proto_msgTypes[2] - 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 PolicyRule.ProtoReflect.Descriptor instead. -func (*PolicyRule) Descriptor() ([]byte, []int) { - return file_auth_casbin_proto_rawDescGZIP(), []int{2} -} - -func (x *PolicyRule) GetPType() string { - if x != nil { - return x.PType - } - return "" -} - -func (x *PolicyRule) GetParams() []string { - if x != nil { - return x.Params - } - return nil -} - -type ListGroupingsRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListGroupingsRequest) Reset() { - *x = ListGroupingsRequest{} - mi := &file_auth_casbin_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListGroupingsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListGroupingsRequest) ProtoMessage() {} - -func (x *ListGroupingsRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_casbin_proto_msgTypes[3] - 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 ListGroupingsRequest.ProtoReflect.Descriptor instead. -func (*ListGroupingsRequest) Descriptor() ([]byte, []int) { - return file_auth_casbin_proto_rawDescGZIP(), []int{3} -} - -type ListGroupingsResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Rules []*GroupingRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListGroupingsResponse) Reset() { - *x = ListGroupingsResponse{} - mi := &file_auth_casbin_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListGroupingsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListGroupingsResponse) ProtoMessage() {} - -func (x *ListGroupingsResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_casbin_proto_msgTypes[4] - 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 ListGroupingsResponse.ProtoReflect.Descriptor instead. -func (*ListGroupingsResponse) Descriptor() ([]byte, []int) { - return file_auth_casbin_proto_rawDescGZIP(), []int{4} -} - -func (x *ListGroupingsResponse) GetRules() []*GroupingRule { - if x != nil { - return x.Rules - } - return nil -} - -type GroupingRule struct { - state protoimpl.MessageState `protogen:"open.v1"` - PType string `protobuf:"bytes,1,opt,name=p_type,proto3" json:"p_type,omitempty"` - Params []string `protobuf:"bytes,2,rep,name=params,proto3" json:"params,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GroupingRule) Reset() { - *x = GroupingRule{} - mi := &file_auth_casbin_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GroupingRule) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GroupingRule) ProtoMessage() {} - -func (x *GroupingRule) ProtoReflect() protoreflect.Message { - mi := &file_auth_casbin_proto_msgTypes[5] - 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 GroupingRule.ProtoReflect.Descriptor instead. -func (*GroupingRule) Descriptor() ([]byte, []int) { - return file_auth_casbin_proto_rawDescGZIP(), []int{5} -} - -func (x *GroupingRule) GetPType() string { - if x != nil { - return x.PType - } - return "" -} - -func (x *GroupingRule) GetParams() []string { - if x != nil { - return x.Params - } - return nil -} - -type StreamRulesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - WithPolicies bool `protobuf:"varint,1,opt,name=with_policies,proto3" json:"with_policies,omitempty"` - WithGroupings bool `protobuf:"varint,2,opt,name=with_groupings,proto3" json:"with_groupings,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StreamRulesRequest) Reset() { - *x = StreamRulesRequest{} - mi := &file_auth_casbin_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StreamRulesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StreamRulesRequest) ProtoMessage() {} - -func (x *StreamRulesRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_casbin_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 StreamRulesRequest.ProtoReflect.Descriptor instead. -func (*StreamRulesRequest) Descriptor() ([]byte, []int) { - return file_auth_casbin_proto_rawDescGZIP(), []int{6} -} - -func (x *StreamRulesRequest) GetWithPolicies() bool { - if x != nil { - return x.WithPolicies - } - return false -} - -func (x *StreamRulesRequest) GetWithGroupings() bool { - if x != nil { - return x.WithGroupings - } - return false -} - -type StreamRulesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Types that are valid to be assigned to RuleType: - // - // *StreamRulesResponse_Policy - // *StreamRulesResponse_Grouping - RuleType isStreamRulesResponse_RuleType `protobuf_oneof:"rule_type"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *StreamRulesResponse) Reset() { - *x = StreamRulesResponse{} - mi := &file_auth_casbin_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *StreamRulesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*StreamRulesResponse) ProtoMessage() {} - -func (x *StreamRulesResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_casbin_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use StreamRulesResponse.ProtoReflect.Descriptor instead. -func (*StreamRulesResponse) Descriptor() ([]byte, []int) { - return file_auth_casbin_proto_rawDescGZIP(), []int{7} -} - -func (x *StreamRulesResponse) GetRuleType() isStreamRulesResponse_RuleType { - if x != nil { - return x.RuleType - } - return nil -} - -func (x *StreamRulesResponse) GetPolicy() *PolicyRule { - if x != nil { - if x, ok := x.RuleType.(*StreamRulesResponse_Policy); ok { - return x.Policy - } - } - return nil -} - -func (x *StreamRulesResponse) GetGrouping() *GroupingRule { - if x != nil { - if x, ok := x.RuleType.(*StreamRulesResponse_Grouping); ok { - return x.Grouping - } - } - return nil -} - -type isStreamRulesResponse_RuleType interface { - isStreamRulesResponse_RuleType() -} - -type StreamRulesResponse_Policy struct { - Policy *PolicyRule `protobuf:"bytes,1,opt,name=policy,proto3,oneof"` -} - -type StreamRulesResponse_Grouping struct { - Grouping *GroupingRule `protobuf:"bytes,2,opt,name=grouping,proto3,oneof"` -} - -func (*StreamRulesResponse_Policy) isStreamRulesResponse_RuleType() {} - -func (*StreamRulesResponse_Grouping) isStreamRulesResponse_RuleType() {} - -type WatchUpdateRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - LastModified int64 `protobuf:"varint,1,opt,name=last_modified,proto3" json:"last_modified,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *WatchUpdateRequest) Reset() { - *x = WatchUpdateRequest{} - mi := &file_auth_casbin_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *WatchUpdateRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WatchUpdateRequest) ProtoMessage() {} - -func (x *WatchUpdateRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_casbin_proto_msgTypes[8] - 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 WatchUpdateRequest.ProtoReflect.Descriptor instead. -func (*WatchUpdateRequest) Descriptor() ([]byte, []int) { - return file_auth_casbin_proto_rawDescGZIP(), []int{8} -} - -func (x *WatchUpdateRequest) GetLastModified() int64 { - if x != nil { - return x.LastModified - } - return 0 -} - -type WatchUpdateResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - ModifiedDate int64 `protobuf:"varint,1,opt,name=modified_date,proto3" json:"modified_date,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *WatchUpdateResponse) Reset() { - *x = WatchUpdateResponse{} - mi := &file_auth_casbin_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *WatchUpdateResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*WatchUpdateResponse) ProtoMessage() {} - -func (x *WatchUpdateResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_casbin_proto_msgTypes[9] - 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 WatchUpdateResponse.ProtoReflect.Descriptor instead. -func (*WatchUpdateResponse) Descriptor() ([]byte, []int) { - return file_auth_casbin_proto_rawDescGZIP(), []int{9} -} - -func (x *WatchUpdateResponse) GetModifiedDate() int64 { - if x != nil { - return x.ModifiedDate - } - return 0 -} - -var File_auth_casbin_proto protoreflect.FileDescriptor - -const file_auth_casbin_proto_rawDesc = "" + - "\n" + - "\x11auth/casbin.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\"\x15\n" + - "\x13ListPoliciesRequest\"N\n" + - "\x14ListPoliciesResponse\x126\n" + - "\x05rules\x18\x01 \x03(\v2 .api.v1.services.auth.PolicyRuleR\x05rules\"<\n" + - "\n" + - "PolicyRule\x12\x16\n" + - "\x06p_type\x18\x01 \x01(\tR\x06p_type\x12\x16\n" + - "\x06params\x18\x02 \x03(\tR\x06params\"\x16\n" + - "\x14ListGroupingsRequest\"Q\n" + - "\x15ListGroupingsResponse\x128\n" + - "\x05rules\x18\x01 \x03(\v2\".api.v1.services.auth.GroupingRuleR\x05rules\">\n" + - "\fGroupingRule\x12\x16\n" + - "\x06p_type\x18\x01 \x01(\tR\x06p_type\x12\x16\n" + - "\x06params\x18\x02 \x03(\tR\x06params\"b\n" + - "\x12StreamRulesRequest\x12$\n" + - "\rwith_policies\x18\x01 \x01(\bR\rwith_policies\x12&\n" + - "\x0ewith_groupings\x18\x02 \x01(\bR\x0ewith_groupings\"\xa0\x01\n" + - "\x13StreamRulesResponse\x12:\n" + - "\x06policy\x18\x01 \x01(\v2 .api.v1.services.auth.PolicyRuleH\x00R\x06policy\x12@\n" + - "\bgrouping\x18\x02 \x01(\v2\".api.v1.services.auth.GroupingRuleH\x00R\bgroupingB\v\n" + - "\trule_type\":\n" + - "\x12WatchUpdateRequest\x12$\n" + - "\rlast_modified\x18\x01 \x01(\x03R\rlast_modified\";\n" + - "\x13WatchUpdateResponse\x12$\n" + - "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\x89\x04\n" + - "\x13CasbinSourceService\x12\x82\x01\n" + - "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x86\x01\n" + - "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12|\n" + - "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12f\n" + - "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xd2\x01\n" + - "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" - -var ( - file_auth_casbin_proto_rawDescOnce sync.Once - file_auth_casbin_proto_rawDescData []byte -) - -func file_auth_casbin_proto_rawDescGZIP() []byte { - file_auth_casbin_proto_rawDescOnce.Do(func() { - file_auth_casbin_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_casbin_proto_rawDesc), len(file_auth_casbin_proto_rawDesc))) - }) - return file_auth_casbin_proto_rawDescData -} - -var file_auth_casbin_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_auth_casbin_proto_goTypes = []any{ - (*ListPoliciesRequest)(nil), // 0: api.v1.services.auth.ListPoliciesRequest - (*ListPoliciesResponse)(nil), // 1: api.v1.services.auth.ListPoliciesResponse - (*PolicyRule)(nil), // 2: api.v1.services.auth.PolicyRule - (*ListGroupingsRequest)(nil), // 3: api.v1.services.auth.ListGroupingsRequest - (*ListGroupingsResponse)(nil), // 4: api.v1.services.auth.ListGroupingsResponse - (*GroupingRule)(nil), // 5: api.v1.services.auth.GroupingRule - (*StreamRulesRequest)(nil), // 6: api.v1.services.auth.StreamRulesRequest - (*StreamRulesResponse)(nil), // 7: api.v1.services.auth.StreamRulesResponse - (*WatchUpdateRequest)(nil), // 8: api.v1.services.auth.WatchUpdateRequest - (*WatchUpdateResponse)(nil), // 9: api.v1.services.auth.WatchUpdateResponse -} -var file_auth_casbin_proto_depIdxs = []int32{ - 2, // 0: api.v1.services.auth.ListPoliciesResponse.rules:type_name -> api.v1.services.auth.PolicyRule - 5, // 1: api.v1.services.auth.ListGroupingsResponse.rules:type_name -> api.v1.services.auth.GroupingRule - 2, // 2: api.v1.services.auth.StreamRulesResponse.policy:type_name -> api.v1.services.auth.PolicyRule - 5, // 3: api.v1.services.auth.StreamRulesResponse.grouping:type_name -> api.v1.services.auth.GroupingRule - 0, // 4: api.v1.services.auth.CasbinSourceService.ListPolicies:input_type -> api.v1.services.auth.ListPoliciesRequest - 3, // 5: api.v1.services.auth.CasbinSourceService.ListGroupings:input_type -> api.v1.services.auth.ListGroupingsRequest - 8, // 6: api.v1.services.auth.CasbinSourceService.WatchUpdate:input_type -> api.v1.services.auth.WatchUpdateRequest - 6, // 7: api.v1.services.auth.CasbinSourceService.StreamRules:input_type -> api.v1.services.auth.StreamRulesRequest - 1, // 8: api.v1.services.auth.CasbinSourceService.ListPolicies:output_type -> api.v1.services.auth.ListPoliciesResponse - 4, // 9: api.v1.services.auth.CasbinSourceService.ListGroupings:output_type -> api.v1.services.auth.ListGroupingsResponse - 9, // 10: api.v1.services.auth.CasbinSourceService.WatchUpdate:output_type -> api.v1.services.auth.WatchUpdateResponse - 7, // 11: api.v1.services.auth.CasbinSourceService.StreamRules:output_type -> api.v1.services.auth.StreamRulesResponse - 8, // [8:12] is the sub-list for method output_type - 4, // [4:8] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_auth_casbin_proto_init() } -func file_auth_casbin_proto_init() { - if File_auth_casbin_proto != nil { - return - } - file_auth_casbin_proto_msgTypes[7].OneofWrappers = []any{ - (*StreamRulesResponse_Policy)(nil), - (*StreamRulesResponse_Grouping)(nil), - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_casbin_proto_rawDesc), len(file_auth_casbin_proto_rawDesc)), - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_auth_casbin_proto_goTypes, - DependencyIndexes: file_auth_casbin_proto_depIdxs, - MessageInfos: file_auth_casbin_proto_msgTypes, - }.Build() - File_auth_casbin_proto = out.File - file_auth_casbin_proto_goTypes = nil - file_auth_casbin_proto_depIdxs = nil -} diff --git a/api/v1/services/auth/casbin.pb.gw.go b/api/v1/services/auth/casbin.pb.gw.go deleted file mode 100644 index b20ef61b..00000000 --- a/api/v1/services/auth/casbin.pb.gw.go +++ /dev/null @@ -1,279 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: auth/casbin.proto - -/* -Package auth is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package auth - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -func request_CasbinSourceService_ListPolicies_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinSourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPoliciesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.ListPolicies(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_CasbinSourceService_ListPolicies_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinSourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPoliciesRequest - metadata runtime.ServerMetadata - ) - msg, err := server.ListPolicies(ctx, &protoReq) - return msg, metadata, err -} - -func request_CasbinSourceService_ListGroupings_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinSourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListGroupingsRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.ListGroupings(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_CasbinSourceService_ListGroupings_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinSourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListGroupingsRequest - metadata runtime.ServerMetadata - ) - msg, err := server.ListGroupings(ctx, &protoReq) - return msg, metadata, err -} - -var filter_CasbinSourceService_WatchUpdate_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_CasbinSourceService_WatchUpdate_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinSourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq WatchUpdateRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CasbinSourceService_WatchUpdate_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.WatchUpdate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_CasbinSourceService_WatchUpdate_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinSourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq WatchUpdateRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CasbinSourceService_WatchUpdate_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.WatchUpdate(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterCasbinSourceServiceHandlerServer registers the http handlers for service CasbinSourceService to "mux". -// UnaryRPC :call CasbinSourceServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterCasbinSourceServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterCasbinSourceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server CasbinSourceServiceServer) error { - mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListPolicies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_CasbinSourceService_ListPolicies_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_CasbinSourceService_ListPolicies_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListGroupings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_CasbinSourceService_ListGroupings_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_CasbinSourceService_ListGroupings_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_CasbinSourceService_WatchUpdate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_CasbinSourceService_WatchUpdate_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_CasbinSourceService_WatchUpdate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterCasbinSourceServiceHandlerFromEndpoint is same as RegisterCasbinSourceServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterCasbinSourceServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterCasbinSourceServiceHandler(ctx, mux, conn) -} - -// RegisterCasbinSourceServiceHandler registers the http handlers for service CasbinSourceService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterCasbinSourceServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterCasbinSourceServiceHandlerClient(ctx, mux, NewCasbinSourceServiceClient(conn)) -} - -// RegisterCasbinSourceServiceHandlerClient registers the http handlers for service CasbinSourceService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "CasbinSourceServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "CasbinSourceServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "CasbinSourceServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client CasbinSourceServiceClient) error { - mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListPolicies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_CasbinSourceService_ListPolicies_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_CasbinSourceService_ListPolicies_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListGroupings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_CasbinSourceService_ListGroupings_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_CasbinSourceService_ListGroupings_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_CasbinSourceService_WatchUpdate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_CasbinSourceService_WatchUpdate_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_CasbinSourceService_WatchUpdate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_CasbinSourceService_ListPolicies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "policies"}, "")) - pattern_CasbinSourceService_ListGroupings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "groupings"}, "")) - pattern_CasbinSourceService_WatchUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "watch"}, "")) -) - -var ( - forward_CasbinSourceService_ListPolicies_0 = runtime.ForwardResponseMessage - forward_CasbinSourceService_ListGroupings_0 = runtime.ForwardResponseMessage - forward_CasbinSourceService_WatchUpdate_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/auth/casbin.pb.validate.go b/api/v1/services/auth/casbin.pb.validate.go deleted file mode 100644 index c40e5d7d..00000000 --- a/api/v1/services/auth/casbin.pb.validate.go +++ /dev/null @@ -1,1217 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: auth/casbin.proto - -package auth - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListPoliciesRequest 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 *ListPoliciesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPoliciesRequest 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 -// ListPoliciesRequestMultiError, or nil if none found. -func (m *ListPoliciesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPoliciesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return ListPoliciesRequestMultiError(errors) - } - - return nil -} - -// ListPoliciesRequestMultiError is an error wrapping multiple validation -// errors returned by ListPoliciesRequest.ValidateAll() if the designated -// constraints aren't met. -type ListPoliciesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPoliciesRequestMultiError) 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 ListPoliciesRequestMultiError) AllErrors() []error { return m } - -// ListPoliciesRequestValidationError is the validation error returned by -// ListPoliciesRequest.Validate if the designated constraints aren't met. -type ListPoliciesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPoliciesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPoliciesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPoliciesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPoliciesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPoliciesRequestValidationError) ErrorName() string { - return "ListPoliciesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPoliciesRequestValidationError) 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 %sListPoliciesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPoliciesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPoliciesRequestValidationError{} - -// Validate checks the field values on ListPoliciesResponse 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 *ListPoliciesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPoliciesResponse 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 -// ListPoliciesResponseMultiError, or nil if none found. -func (m *ListPoliciesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPoliciesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRules() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPoliciesResponseValidationError{ - field: fmt.Sprintf("Rules[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPoliciesResponseValidationError{ - field: fmt.Sprintf("Rules[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPoliciesResponseValidationError{ - field: fmt.Sprintf("Rules[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListPoliciesResponseMultiError(errors) - } - - return nil -} - -// ListPoliciesResponseMultiError is an error wrapping multiple validation -// errors returned by ListPoliciesResponse.ValidateAll() if the designated -// constraints aren't met. -type ListPoliciesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPoliciesResponseMultiError) 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 ListPoliciesResponseMultiError) AllErrors() []error { return m } - -// ListPoliciesResponseValidationError is the validation error returned by -// ListPoliciesResponse.Validate if the designated constraints aren't met. -type ListPoliciesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPoliciesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPoliciesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPoliciesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPoliciesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPoliciesResponseValidationError) ErrorName() string { - return "ListPoliciesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPoliciesResponseValidationError) 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 %sListPoliciesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPoliciesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPoliciesResponseValidationError{} - -// Validate checks the field values on PolicyRule 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 *PolicyRule) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PolicyRule 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 PolicyRuleMultiError, or -// nil if none found. -func (m *PolicyRule) ValidateAll() error { - return m.validate(true) -} - -func (m *PolicyRule) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for PType - - if len(errors) > 0 { - return PolicyRuleMultiError(errors) - } - - return nil -} - -// PolicyRuleMultiError is an error wrapping multiple validation errors -// returned by PolicyRule.ValidateAll() if the designated constraints aren't met. -type PolicyRuleMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PolicyRuleMultiError) 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 PolicyRuleMultiError) AllErrors() []error { return m } - -// PolicyRuleValidationError is the validation error returned by -// PolicyRule.Validate if the designated constraints aren't met. -type PolicyRuleValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PolicyRuleValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PolicyRuleValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PolicyRuleValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PolicyRuleValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PolicyRuleValidationError) ErrorName() string { return "PolicyRuleValidationError" } - -// Error satisfies the builtin error interface -func (e PolicyRuleValidationError) 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 %sPolicyRule.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PolicyRuleValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PolicyRuleValidationError{} - -// Validate checks the field values on ListGroupingsRequest 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 *ListGroupingsRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListGroupingsRequest 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 -// ListGroupingsRequestMultiError, or nil if none found. -func (m *ListGroupingsRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListGroupingsRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return ListGroupingsRequestMultiError(errors) - } - - return nil -} - -// ListGroupingsRequestMultiError is an error wrapping multiple validation -// errors returned by ListGroupingsRequest.ValidateAll() if the designated -// constraints aren't met. -type ListGroupingsRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListGroupingsRequestMultiError) 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 ListGroupingsRequestMultiError) AllErrors() []error { return m } - -// ListGroupingsRequestValidationError is the validation error returned by -// ListGroupingsRequest.Validate if the designated constraints aren't met. -type ListGroupingsRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListGroupingsRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListGroupingsRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListGroupingsRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListGroupingsRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListGroupingsRequestValidationError) ErrorName() string { - return "ListGroupingsRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListGroupingsRequestValidationError) 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 %sListGroupingsRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListGroupingsRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListGroupingsRequestValidationError{} - -// Validate checks the field values on ListGroupingsResponse 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 *ListGroupingsResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListGroupingsResponse 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 -// ListGroupingsResponseMultiError, or nil if none found. -func (m *ListGroupingsResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListGroupingsResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRules() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListGroupingsResponseValidationError{ - field: fmt.Sprintf("Rules[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListGroupingsResponseValidationError{ - field: fmt.Sprintf("Rules[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListGroupingsResponseValidationError{ - field: fmt.Sprintf("Rules[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListGroupingsResponseMultiError(errors) - } - - return nil -} - -// ListGroupingsResponseMultiError is an error wrapping multiple validation -// errors returned by ListGroupingsResponse.ValidateAll() if the designated -// constraints aren't met. -type ListGroupingsResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListGroupingsResponseMultiError) 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 ListGroupingsResponseMultiError) AllErrors() []error { return m } - -// ListGroupingsResponseValidationError is the validation error returned by -// ListGroupingsResponse.Validate if the designated constraints aren't met. -type ListGroupingsResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListGroupingsResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListGroupingsResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListGroupingsResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListGroupingsResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListGroupingsResponseValidationError) ErrorName() string { - return "ListGroupingsResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListGroupingsResponseValidationError) 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 %sListGroupingsResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListGroupingsResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListGroupingsResponseValidationError{} - -// Validate checks the field values on GroupingRule 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 *GroupingRule) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GroupingRule 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 GroupingRuleMultiError, or -// nil if none found. -func (m *GroupingRule) ValidateAll() error { - return m.validate(true) -} - -func (m *GroupingRule) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for PType - - if len(errors) > 0 { - return GroupingRuleMultiError(errors) - } - - return nil -} - -// GroupingRuleMultiError is an error wrapping multiple validation errors -// returned by GroupingRule.ValidateAll() if the designated constraints aren't met. -type GroupingRuleMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GroupingRuleMultiError) 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 GroupingRuleMultiError) AllErrors() []error { return m } - -// GroupingRuleValidationError is the validation error returned by -// GroupingRule.Validate if the designated constraints aren't met. -type GroupingRuleValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GroupingRuleValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GroupingRuleValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GroupingRuleValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GroupingRuleValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GroupingRuleValidationError) ErrorName() string { return "GroupingRuleValidationError" } - -// Error satisfies the builtin error interface -func (e GroupingRuleValidationError) 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 %sGroupingRule.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GroupingRuleValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GroupingRuleValidationError{} - -// Validate checks the field values on StreamRulesRequest 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 *StreamRulesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on StreamRulesRequest 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 -// StreamRulesRequestMultiError, or nil if none found. -func (m *StreamRulesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *StreamRulesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for WithPolicies - - // no validation rules for WithGroupings - - if len(errors) > 0 { - return StreamRulesRequestMultiError(errors) - } - - return nil -} - -// StreamRulesRequestMultiError is an error wrapping multiple validation errors -// returned by StreamRulesRequest.ValidateAll() if the designated constraints -// aren't met. -type StreamRulesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m StreamRulesRequestMultiError) 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 StreamRulesRequestMultiError) AllErrors() []error { return m } - -// StreamRulesRequestValidationError is the validation error returned by -// StreamRulesRequest.Validate if the designated constraints aren't met. -type StreamRulesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e StreamRulesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e StreamRulesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e StreamRulesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e StreamRulesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e StreamRulesRequestValidationError) ErrorName() string { - return "StreamRulesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e StreamRulesRequestValidationError) 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 %sStreamRulesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = StreamRulesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = StreamRulesRequestValidationError{} - -// Validate checks the field values on StreamRulesResponse 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 *StreamRulesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on StreamRulesResponse 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 -// StreamRulesResponseMultiError, or nil if none found. -func (m *StreamRulesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *StreamRulesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - switch v := m.RuleType.(type) { - case *StreamRulesResponse_Policy: - if v == nil { - err := StreamRulesResponseValidationError{ - field: "RuleType", - reason: "oneof value cannot be a typed-nil", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetPolicy()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, StreamRulesResponseValidationError{ - field: "Policy", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, StreamRulesResponseValidationError{ - field: "Policy", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPolicy()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return StreamRulesResponseValidationError{ - field: "Policy", - reason: "embedded message failed validation", - cause: err, - } - } - } - - case *StreamRulesResponse_Grouping: - if v == nil { - err := StreamRulesResponseValidationError{ - field: "RuleType", - reason: "oneof value cannot be a typed-nil", - } - if !all { - return err - } - errors = append(errors, err) - } - - if all { - switch v := interface{}(m.GetGrouping()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, StreamRulesResponseValidationError{ - field: "Grouping", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, StreamRulesResponseValidationError{ - field: "Grouping", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetGrouping()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return StreamRulesResponseValidationError{ - field: "Grouping", - reason: "embedded message failed validation", - cause: err, - } - } - } - - default: - _ = v // ensures v is used - } - - if len(errors) > 0 { - return StreamRulesResponseMultiError(errors) - } - - return nil -} - -// StreamRulesResponseMultiError is an error wrapping multiple validation -// errors returned by StreamRulesResponse.ValidateAll() if the designated -// constraints aren't met. -type StreamRulesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m StreamRulesResponseMultiError) 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 StreamRulesResponseMultiError) AllErrors() []error { return m } - -// StreamRulesResponseValidationError is the validation error returned by -// StreamRulesResponse.Validate if the designated constraints aren't met. -type StreamRulesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e StreamRulesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e StreamRulesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e StreamRulesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e StreamRulesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e StreamRulesResponseValidationError) ErrorName() string { - return "StreamRulesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e StreamRulesResponseValidationError) 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 %sStreamRulesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = StreamRulesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = StreamRulesResponseValidationError{} - -// Validate checks the field values on WatchUpdateRequest 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 *WatchUpdateRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on WatchUpdateRequest 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 -// WatchUpdateRequestMultiError, or nil if none found. -func (m *WatchUpdateRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *WatchUpdateRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for LastModified - - if len(errors) > 0 { - return WatchUpdateRequestMultiError(errors) - } - - return nil -} - -// WatchUpdateRequestMultiError is an error wrapping multiple validation errors -// returned by WatchUpdateRequest.ValidateAll() if the designated constraints -// aren't met. -type WatchUpdateRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m WatchUpdateRequestMultiError) 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 WatchUpdateRequestMultiError) AllErrors() []error { return m } - -// WatchUpdateRequestValidationError is the validation error returned by -// WatchUpdateRequest.Validate if the designated constraints aren't met. -type WatchUpdateRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e WatchUpdateRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e WatchUpdateRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e WatchUpdateRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e WatchUpdateRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e WatchUpdateRequestValidationError) ErrorName() string { - return "WatchUpdateRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e WatchUpdateRequestValidationError) 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 %sWatchUpdateRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = WatchUpdateRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = WatchUpdateRequestValidationError{} - -// Validate checks the field values on WatchUpdateResponse 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 *WatchUpdateResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on WatchUpdateResponse 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 -// WatchUpdateResponseMultiError, or nil if none found. -func (m *WatchUpdateResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *WatchUpdateResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for ModifiedDate - - if len(errors) > 0 { - return WatchUpdateResponseMultiError(errors) - } - - return nil -} - -// WatchUpdateResponseMultiError is an error wrapping multiple validation -// errors returned by WatchUpdateResponse.ValidateAll() if the designated -// constraints aren't met. -type WatchUpdateResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m WatchUpdateResponseMultiError) 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 WatchUpdateResponseMultiError) AllErrors() []error { return m } - -// WatchUpdateResponseValidationError is the validation error returned by -// WatchUpdateResponse.Validate if the designated constraints aren't met. -type WatchUpdateResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e WatchUpdateResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e WatchUpdateResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e WatchUpdateResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e WatchUpdateResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e WatchUpdateResponseValidationError) ErrorName() string { - return "WatchUpdateResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e WatchUpdateResponseValidationError) 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 %sWatchUpdateResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = WatchUpdateResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = WatchUpdateResponseValidationError{} diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go deleted file mode 100644 index 9e7e573b..00000000 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ /dev/null @@ -1,291 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: auth/casbin.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const CasbinSourceServiceListGroupingsBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListGroupings" -const CasbinSourceServiceListPoliciesBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListPolicies" -const CasbinSourceServiceWatchUpdateBridgeOperation = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" - -type CasbinSourceServiceBridgeServer interface { - ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) - ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) - WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) -} - -type CasbinSourceServiceHooker interface { - CasbinSourceServiceListGroupingsHooker - CasbinSourceServiceListPoliciesHooker - CasbinSourceServiceWatchUpdateHooker -} - -type CasbinSourceServiceHookedBridger interface { - CasbinSourceServiceHooker - CasbinSourceServiceBridgeServer -} -type CasbinSourceServiceListGroupingsHooker interface { - PrepareListGroupings(http.Context, *ListGroupingsRequest) (context.Context, error) - CompleteListGroupings(http.Context, *ListGroupingsRequest, *ListGroupingsResponse) error -} -type CasbinSourceServiceListPoliciesHooker interface { - PrepareListPolicies(http.Context, *ListPoliciesRequest) (context.Context, error) - CompleteListPolicies(http.Context, *ListPoliciesRequest, *ListPoliciesResponse) error -} -type CasbinSourceServiceWatchUpdateHooker interface { - PrepareWatchUpdate(http.Context, *WatchUpdateRequest) (context.Context, error) - CompleteWatchUpdate(http.Context, *WatchUpdateRequest, *WatchUpdateResponse) error -} - -func RegisterCasbinSourceServiceBridgeServer(s *http.Server, srv CasbinSourceServiceHookedBridger) { - r := s.Route("/") - r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_Bridge_Handler(srv)) - r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_Bridge_Handler(srv)) - r.GET("/casbin/watch", _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv)) -} - -func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPoliciesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCasbinSourceServiceListPolicies) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPolicies(ctx, req.(*ListPoliciesRequest)) - }) - - newctx, err := srv.PrepareListPolicies(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPolicies(ctx, &in, out.(*ListPoliciesResponse)) - } -} - -func _CasbinSourceService_ListGroupings0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListGroupingsRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCasbinSourceServiceListGroupings) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListGroupings(ctx, req.(*ListGroupingsRequest)) - }) - - newctx, err := srv.PrepareListGroupings(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListGroupings(ctx, &in, out.(*ListGroupingsResponse)) - } -} - -func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in WatchUpdateRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCasbinSourceServiceWatchUpdate) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.WatchUpdate(ctx, req.(*WatchUpdateRequest)) - }) - - newctx, err := srv.PrepareWatchUpdate(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteWatchUpdate(ctx, &in, out.(*WatchUpdateResponse)) - } -} - -// UnimplementedCasbinSourceServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedCasbinSourceServiceHooked struct{} - -func (UnimplementedCasbinSourceServiceHooked) PrepareListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedCasbinSourceServiceHooked) CompleteListGroupings(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedCasbinSourceServiceHooked) PrepareListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedCasbinSourceServiceHooked) CompleteListPolicies(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedCasbinSourceServiceHooked) PrepareWatchUpdate(ctx http.Context, in *WatchUpdateRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedCasbinSourceServiceHooked) CompleteWatchUpdate(ctx http.Context, in *WatchUpdateRequest, out *WatchUpdateResponse) error { - return ctx.Result(200, out) -} - -func WithCasbinSourceServiceHook(h CasbinSourceServiceHooker) func(CasbinSourceServiceBridgeServer) CasbinSourceServiceHookedBridger { - return func(srv CasbinSourceServiceBridgeServer) CasbinSourceServiceHookedBridger { - return CasbinSourceServiceHookedBridge{CasbinSourceServiceBridgeServer: srv, CasbinSourceServiceHooker: h} - } -} - -// CasbinSourceServiceHookedBridge is a bridge between the HTTP and gRPC implementations of CasbinSourceService. -// It implements the HTTP and gRPC implementations of CasbinSourceService. -// It forwards requests and responses between the two implementations. -type CasbinSourceServiceHookedBridge struct { - CasbinSourceServiceBridgeServer - CasbinSourceServiceHooker -} - -type CasbinSourceServiceHTTPBridgeImpl struct { - client CasbinSourceServiceHTTPClient -} - -func NewCasbinSourceServiceHTTPBridge(client *http.Client) CasbinSourceServiceHTTPServer { - return &CasbinSourceServiceHTTPBridgeImpl{client: NewCasbinSourceServiceHTTPClient(client)} -} - -func (c *CasbinSourceServiceHTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, in) -} - -func (c *CasbinSourceServiceHTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { - return c.client.ListPolicies(ctx, in) -} - -func (c *CasbinSourceServiceHTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { - return c.client.WatchUpdate(ctx, in) -} - -type CasbinSourceServiceBridgeImpl struct { - client CasbinSourceServiceClient -} - -func NewCasbinSourceServiceBridge(client grpc.ClientConnInterface) CasbinSourceServiceServer { - return &CasbinSourceServiceBridgeImpl{client: NewCasbinSourceServiceClient(client)} -} - -func (c *CasbinSourceServiceBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, in) -} - -func (c *CasbinSourceServiceBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { - return c.client.ListPolicies(ctx, in) -} - -func (c *CasbinSourceServiceBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { - return c.client.WatchUpdate(ctx, in) -} - -func (c *CasbinSourceServiceBridgeImpl) StreamRules(request *StreamRulesRequest, g grpc.ServerStreamingServer[StreamRulesResponse]) error { - stream, err := c.client.StreamRules(g.Context(), request) - if err != nil { - return err - } - for { - rule, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - return status.Errorf(status.Code(err), "received stream error: %v", err) - } - if err := g.Send(rule); err != nil { - return err - } - } - return nil -} - -func (c *CasbinSourceServiceBridgeImpl) mustEmbedUnimplementedCasbinSourceServiceServer() {} - -type CasbinSourceServiceGRPC2HTTPBridgeImpl struct { - client CasbinSourceServiceClient -} - -func NewCasbinSourceServiceGRPC2HTTP(client grpc.ClientConnInterface) CasbinSourceServiceHTTPServer { - return &CasbinSourceServiceGRPC2HTTPBridgeImpl{client: NewCasbinSourceServiceClient(client)} -} - -func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, in) -} - -func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { - return c.client.ListPolicies(ctx, in) -} - -func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { - return c.client.WatchUpdate(ctx, in) -} - -type CasbinSourceServiceHTTP2GRPCBridgeImpl struct { - client CasbinSourceServiceHTTPClient -} - -func NewCasbinSourceServiceHTTP2GRPC(client *http.Client) CasbinSourceServiceServer { - return &CasbinSourceServiceHTTP2GRPCBridgeImpl{client: NewCasbinSourceServiceHTTPClient(client)} -} - -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, in) -} - -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { - return c.client.ListPolicies(ctx, in) -} - -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { - return c.client.WatchUpdate(ctx, in) -} - -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) StreamRules(request *StreamRulesRequest, g grpc.ServerStreamingServer[StreamRulesResponse]) error { - return status.Errorf(codes.Unimplemented, "StreamRules not implemented") -} - -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedCasbinSourceServiceServer() {} diff --git a/api/v1/services/auth/casbin_grpc.pb.go b/api/v1/services/auth/casbin_grpc.pb.go deleted file mode 100644 index 86911a12..00000000 --- a/api/v1/services/auth/casbin_grpc.pb.go +++ /dev/null @@ -1,243 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: auth/casbin.proto - -package auth - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - CasbinSourceService_ListPolicies_FullMethodName = "/api.v1.services.auth.CasbinSourceService/ListPolicies" - CasbinSourceService_ListGroupings_FullMethodName = "/api.v1.services.auth.CasbinSourceService/ListGroupings" - CasbinSourceService_WatchUpdate_FullMethodName = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" - CasbinSourceService_StreamRules_FullMethodName = "/api.v1.services.auth.CasbinSourceService/StreamRules" -) - -// CasbinSourceServiceClient is the client API for CasbinSourceService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The Casbin source service definition. -type CasbinSourceServiceClient interface { - ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...grpc.CallOption) (*ListPoliciesResponse, error) - ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...grpc.CallOption) (*ListGroupingsResponse, error) - WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...grpc.CallOption) (*WatchUpdateResponse, error) - StreamRules(ctx context.Context, in *StreamRulesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamRulesResponse], error) -} - -type casbinSourceServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewCasbinSourceServiceClient(cc grpc.ClientConnInterface) CasbinSourceServiceClient { - return &casbinSourceServiceClient{cc} -} - -func (c *casbinSourceServiceClient) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...grpc.CallOption) (*ListPoliciesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPoliciesResponse) - err := c.cc.Invoke(ctx, CasbinSourceService_ListPolicies_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *casbinSourceServiceClient) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...grpc.CallOption) (*ListGroupingsResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListGroupingsResponse) - err := c.cc.Invoke(ctx, CasbinSourceService_ListGroupings_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *casbinSourceServiceClient) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...grpc.CallOption) (*WatchUpdateResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(WatchUpdateResponse) - err := c.cc.Invoke(ctx, CasbinSourceService_WatchUpdate_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *casbinSourceServiceClient) StreamRules(ctx context.Context, in *StreamRulesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamRulesResponse], error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &CasbinSourceService_ServiceDesc.Streams[0], CasbinSourceService_StreamRules_FullMethodName, cOpts...) - if err != nil { - return nil, err - } - x := &grpc.GenericClientStream[StreamRulesRequest, StreamRulesResponse]{ClientStream: stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type CasbinSourceService_StreamRulesClient = grpc.ServerStreamingClient[StreamRulesResponse] - -// CasbinSourceServiceServer is the server API for CasbinSourceService service. -// All implementations must embed UnimplementedCasbinSourceServiceServer -// for forward compatibility. -// -// The Casbin source service definition. -type CasbinSourceServiceServer interface { - ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) - ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) - WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) - StreamRules(*StreamRulesRequest, grpc.ServerStreamingServer[StreamRulesResponse]) error - mustEmbedUnimplementedCasbinSourceServiceServer() -} - -// UnimplementedCasbinSourceServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedCasbinSourceServiceServer struct{} - -func (UnimplementedCasbinSourceServiceServer) ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPolicies not implemented") -} -func (UnimplementedCasbinSourceServiceServer) ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListGroupings not implemented") -} -func (UnimplementedCasbinSourceServiceServer) WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method WatchUpdate not implemented") -} -func (UnimplementedCasbinSourceServiceServer) StreamRules(*StreamRulesRequest, grpc.ServerStreamingServer[StreamRulesResponse]) error { - return status.Errorf(codes.Unimplemented, "method StreamRules not implemented") -} -func (UnimplementedCasbinSourceServiceServer) mustEmbedUnimplementedCasbinSourceServiceServer() {} -func (UnimplementedCasbinSourceServiceServer) testEmbeddedByValue() {} - -// UnsafeCasbinSourceServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to CasbinSourceServiceServer will -// result in compilation errors. -type UnsafeCasbinSourceServiceServer interface { - mustEmbedUnimplementedCasbinSourceServiceServer() -} - -func RegisterCasbinSourceServiceServer(s grpc.ServiceRegistrar, srv CasbinSourceServiceServer) { - // If the following call pancis, it indicates UnimplementedCasbinSourceServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&CasbinSourceService_ServiceDesc, srv) -} - -func _CasbinSourceService_ListPolicies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPoliciesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CasbinSourceServiceServer).ListPolicies(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CasbinSourceService_ListPolicies_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CasbinSourceServiceServer).ListPolicies(ctx, req.(*ListPoliciesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CasbinSourceService_ListGroupings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListGroupingsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CasbinSourceServiceServer).ListGroupings(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CasbinSourceService_ListGroupings_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CasbinSourceServiceServer).ListGroupings(ctx, req.(*ListGroupingsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CasbinSourceService_WatchUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(WatchUpdateRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CasbinSourceServiceServer).WatchUpdate(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: CasbinSourceService_WatchUpdate_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CasbinSourceServiceServer).WatchUpdate(ctx, req.(*WatchUpdateRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _CasbinSourceService_StreamRules_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(StreamRulesRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(CasbinSourceServiceServer).StreamRules(m, &grpc.GenericServerStream[StreamRulesRequest, StreamRulesResponse]{ServerStream: stream}) -} - -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type CasbinSourceService_StreamRulesServer = grpc.ServerStreamingServer[StreamRulesResponse] - -// CasbinSourceService_ServiceDesc is the grpc.ServiceDesc for CasbinSourceService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var CasbinSourceService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.auth.CasbinSourceService", - HandlerType: (*CasbinSourceServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListPolicies", - Handler: _CasbinSourceService_ListPolicies_Handler, - }, - { - MethodName: "ListGroupings", - Handler: _CasbinSourceService_ListGroupings_Handler, - }, - { - MethodName: "WatchUpdate", - Handler: _CasbinSourceService_WatchUpdate_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "StreamRules", - Handler: _CasbinSourceService_StreamRules_Handler, - ServerStreams: true, - }, - }, - Metadata: "auth/casbin.proto", -} diff --git a/api/v1/services/auth/casbin_http.pb.go b/api/v1/services/auth/casbin_http.pb.go deleted file mode 100644 index e66f87ae..00000000 --- a/api/v1/services/auth/casbin_http.pb.go +++ /dev/null @@ -1,147 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: auth/casbin.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationCasbinSourceServiceListGroupings = "/api.v1.services.auth.CasbinSourceService/ListGroupings" -const OperationCasbinSourceServiceListPolicies = "/api.v1.services.auth.CasbinSourceService/ListPolicies" -const OperationCasbinSourceServiceWatchUpdate = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" - -type CasbinSourceServiceHTTPServer interface { - ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) - ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) - WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) -} - -func RegisterCasbinSourceServiceHTTPServer(s *http.Server, srv CasbinSourceServiceHTTPServer) { - r := s.Route("/") - r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_HTTP_Handler(srv)) - r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_HTTP_Handler(srv)) - r.GET("/casbin/watch", _CasbinSourceService_WatchUpdate0_HTTP_Handler(srv)) -} - -func _CasbinSourceService_ListPolicies0_HTTP_Handler(srv CasbinSourceServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPoliciesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCasbinSourceServiceListPolicies) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPolicies(ctx, req.(*ListPoliciesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPoliciesResponse) - return ctx.Result(200, reply) - } -} - -func _CasbinSourceService_ListGroupings0_HTTP_Handler(srv CasbinSourceServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListGroupingsRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCasbinSourceServiceListGroupings) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListGroupings(ctx, req.(*ListGroupingsRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListGroupingsResponse) - return ctx.Result(200, reply) - } -} - -func _CasbinSourceService_WatchUpdate0_HTTP_Handler(srv CasbinSourceServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in WatchUpdateRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationCasbinSourceServiceWatchUpdate) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.WatchUpdate(ctx, req.(*WatchUpdateRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*WatchUpdateResponse) - return ctx.Result(200, reply) - } -} - -type CasbinSourceServiceHTTPClient interface { - ListGroupings(ctx context.Context, req *ListGroupingsRequest, opts ...http.CallOption) (rsp *ListGroupingsResponse, err error) - ListPolicies(ctx context.Context, req *ListPoliciesRequest, opts ...http.CallOption) (rsp *ListPoliciesResponse, err error) - WatchUpdate(ctx context.Context, req *WatchUpdateRequest, opts ...http.CallOption) (rsp *WatchUpdateResponse, err error) -} - -type CasbinSourceServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewCasbinSourceServiceHTTPClient(client *http.Client) CasbinSourceServiceHTTPClient { - return &CasbinSourceServiceHTTPClientImpl{client} -} - -func (c *CasbinSourceServiceHTTPClientImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...http.CallOption) (*ListGroupingsResponse, error) { - var out ListGroupingsResponse - pattern := "/casbin/groupings" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationCasbinSourceServiceListGroupings)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *CasbinSourceServiceHTTPClientImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...http.CallOption) (*ListPoliciesResponse, error) { - var out ListPoliciesResponse - pattern := "/casbin/policies" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationCasbinSourceServiceListPolicies)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *CasbinSourceServiceHTTPClientImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...http.CallOption) (*WatchUpdateResponse, error) { - var out WatchUpdateResponse - pattern := "/casbin/watch" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationCasbinSourceServiceWatchUpdate)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/auth/login.pb.go b/api/v1/services/auth/login.pb.go deleted file mode 100644 index 3ae746b2..00000000 --- a/api/v1/services/auth/login.pb.go +++ /dev/null @@ -1,1461 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: auth/login.proto - -package auth - -import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" - v1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type TokenRefreshRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *TokenRefreshRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *TokenRefreshRequest) Reset() { - *x = TokenRefreshRequest{} - mi := &file_auth_login_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *TokenRefreshRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TokenRefreshRequest) ProtoMessage() {} - -func (x *TokenRefreshRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[0] - 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 TokenRefreshRequest.ProtoReflect.Descriptor instead. -func (*TokenRefreshRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{0} -} - -func (x *TokenRefreshRequest) GetData() *TokenRefreshRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -type TokenRefreshResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token *v1.Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *TokenRefreshResponse) Reset() { - *x = TokenRefreshResponse{} - mi := &file_auth_login_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *TokenRefreshResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TokenRefreshResponse) ProtoMessage() {} - -func (x *TokenRefreshResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[1] - 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 TokenRefreshResponse.ProtoReflect.Descriptor instead. -func (*TokenRefreshResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{1} -} - -func (x *TokenRefreshResponse) GetToken() *v1.Token { - if x != nil { - return x.Token - } - return nil -} - -type LoginRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *LoginRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LoginRequest) Reset() { - *x = LoginRequest{} - mi := &file_auth_login_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LoginRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoginRequest) ProtoMessage() {} - -func (x *LoginRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[2] - 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 LoginRequest.ProtoReflect.Descriptor instead. -func (*LoginRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{2} -} - -func (x *LoginRequest) GetData() *LoginRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -type LoginResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token *v1.Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LoginResponse) Reset() { - *x = LoginResponse{} - mi := &file_auth_login_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LoginResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoginResponse) ProtoMessage() {} - -func (x *LoginResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[3] - 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 LoginResponse.ProtoReflect.Descriptor instead. -func (*LoginResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{3} -} - -func (x *LoginResponse) GetToken() *v1.Token { - if x != nil { - return x.Token - } - return nil -} - -type CurrentUserRequestQuery struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId int64 `protobuf:"varint,1,opt,name=user_id,proto3" json:"user_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CurrentUserRequestQuery) Reset() { - *x = CurrentUserRequestQuery{} - mi := &file_auth_login_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CurrentUserRequestQuery) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CurrentUserRequestQuery) ProtoMessage() {} - -func (x *CurrentUserRequestQuery) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[4] - 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 CurrentUserRequestQuery.ProtoReflect.Descriptor instead. -func (*CurrentUserRequestQuery) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{4} -} - -func (x *CurrentUserRequestQuery) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -type CurrentUserRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *CurrentUserRequestQuery `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CurrentUserRequest) Reset() { - *x = CurrentUserRequest{} - mi := &file_auth_login_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CurrentUserRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CurrentUserRequest) ProtoMessage() {} - -func (x *CurrentUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[5] - 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 CurrentUserRequest.ProtoReflect.Descriptor instead. -func (*CurrentUserRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{5} -} - -func (x *CurrentUserRequest) GetData() *CurrentUserRequestQuery { - if x != nil { - return x.Data - } - return nil -} - -type CurrentUserResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CurrentUserResponse) Reset() { - *x = CurrentUserResponse{} - mi := &file_auth_login_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CurrentUserResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CurrentUserResponse) ProtoMessage() {} - -func (x *CurrentUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_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 CurrentUserResponse.ProtoReflect.Descriptor instead. -func (*CurrentUserResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{6} -} - -func (x *CurrentUserResponse) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -func (x *CurrentUserResponse) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type CaptchaIdRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The timestamp of the request prevent caching of the same result - Ts string `protobuf:"bytes,1,opt,name=ts,proto3" json:"ts,omitempty"` - Reload bool `protobuf:"varint,2,opt,name=reload,proto3" json:"reload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaIdRequest) Reset() { - *x = CaptchaIdRequest{} - mi := &file_auth_login_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaIdRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaIdRequest) ProtoMessage() {} - -func (x *CaptchaIdRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CaptchaIdRequest.ProtoReflect.Descriptor instead. -func (*CaptchaIdRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{7} -} - -func (x *CaptchaIdRequest) GetTs() string { - if x != nil { - return x.Ts - } - return "" -} - -func (x *CaptchaIdRequest) GetReload() bool { - if x != nil { - return x.Reload - } - return false -} - -type CaptchaIdResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaIdResponse) Reset() { - *x = CaptchaIdResponse{} - mi := &file_auth_login_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaIdResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaIdResponse) ProtoMessage() {} - -func (x *CaptchaIdResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[8] - 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 CaptchaIdResponse.ProtoReflect.Descriptor instead. -func (*CaptchaIdResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{8} -} - -func (x *CaptchaIdResponse) GetData() string { - if x != nil { - return x.Data - } - return "" -} - -// The request message containing the user's name. -type CaptchaImageRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Reload string `protobuf:"bytes,2,opt,name=reload,proto3" json:"reload,omitempty"` - Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaImageRequest) Reset() { - *x = CaptchaImageRequest{} - mi := &file_auth_login_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaImageRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaImageRequest) ProtoMessage() {} - -func (x *CaptchaImageRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[9] - 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 CaptchaImageRequest.ProtoReflect.Descriptor instead. -func (*CaptchaImageRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{9} -} - -func (x *CaptchaImageRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CaptchaImageRequest) GetReload() string { - if x != nil { - return x.Reload - } - return "" -} - -func (x *CaptchaImageRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type CaptchaData struct { - state protoimpl.MessageState `protogen:"open.v1"` - CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` - CaptchaImg string `protobuf:"bytes,2,opt,name=captcha_img,json=captchaImg,proto3" json:"captcha_img,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaData) Reset() { - *x = CaptchaData{} - mi := &file_auth_login_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaData) ProtoMessage() {} - -func (x *CaptchaData) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[10] - 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 CaptchaData.ProtoReflect.Descriptor instead. -func (*CaptchaData) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{10} -} - -func (x *CaptchaData) GetCaptchaId() string { - if x != nil { - return x.CaptchaId - } - return "" -} - -func (x *CaptchaData) GetCaptchaImg() string { - if x != nil { - return x.CaptchaImg - } - return "" -} - -// The response message containing the greetings -type CaptchaImageResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - Image []byte `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaImageResponse) Reset() { - *x = CaptchaImageResponse{} - mi := &file_auth_login_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaImageResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaImageResponse) ProtoMessage() {} - -func (x *CaptchaImageResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[11] - 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 CaptchaImageResponse.ProtoReflect.Descriptor instead. -func (*CaptchaImageResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{11} -} - -func (x *CaptchaImageResponse) GetHeaders() map[string]string { - if x != nil { - return x.Headers - } - return nil -} - -func (x *CaptchaImageResponse) GetImage() []byte { - if x != nil { - return x.Image - } - return nil -} - -// The request message containing the user's name. -type CaptchaAudioRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Reload string `protobuf:"bytes,2,opt,name=reload,proto3" json:"reload,omitempty"` - Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaAudioRequest) Reset() { - *x = CaptchaAudioRequest{} - mi := &file_auth_login_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaAudioRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaAudioRequest) ProtoMessage() {} - -func (x *CaptchaAudioRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[12] - 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 CaptchaAudioRequest.ProtoReflect.Descriptor instead. -func (*CaptchaAudioRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{12} -} - -func (x *CaptchaAudioRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CaptchaAudioRequest) GetReload() string { - if x != nil { - return x.Reload - } - return "" -} - -func (x *CaptchaAudioRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -// The response message containing the greetings -type CaptchaAudioResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - Audio []byte `protobuf:"bytes,2,opt,name=audio,proto3" json:"audio,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaAudioResponse) Reset() { - *x = CaptchaAudioResponse{} - mi := &file_auth_login_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaAudioResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaAudioResponse) ProtoMessage() {} - -func (x *CaptchaAudioResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[13] - 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 CaptchaAudioResponse.ProtoReflect.Descriptor instead. -func (*CaptchaAudioResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{13} -} - -func (x *CaptchaAudioResponse) GetHeaders() map[string]string { - if x != nil { - return x.Headers - } - return nil -} - -func (x *CaptchaAudioResponse) GetAudio() []byte { - if x != nil { - return x.Audio - } - return nil -} - -type CaptchaRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The id of the captcha - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // The type of the captcha - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - // The reload is used to reload the captcha - Reload bool `protobuf:"varint,3,opt,name=reload,proto3" json:"reload,omitempty"` - // The timestamp of the request prevent caching of the same result - Ts string `protobuf:"bytes,4,opt,name=ts,proto3" json:"ts,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaRequest) Reset() { - *x = CaptchaRequest{} - mi := &file_auth_login_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaRequest) ProtoMessage() {} - -func (x *CaptchaRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[14] - 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 CaptchaRequest.ProtoReflect.Descriptor instead. -func (*CaptchaRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{14} -} - -func (x *CaptchaRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CaptchaRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *CaptchaRequest) GetReload() bool { - if x != nil { - return x.Reload - } - return false -} - -func (x *CaptchaRequest) GetTs() string { - if x != nil { - return x.Ts - } - return "" -} - -type CaptchaResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaResponse) Reset() { - *x = CaptchaResponse{} - mi := &file_auth_login_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaResponse) ProtoMessage() {} - -func (x *CaptchaResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[15] - 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 CaptchaResponse.ProtoReflect.Descriptor instead. -func (*CaptchaResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{15} -} - -func (x *CaptchaResponse) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CaptchaResponse) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *CaptchaResponse) GetData() string { - if x != nil { - return x.Data - } - return "" -} - -type RegisterRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *RegisterRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RegisterRequest) Reset() { - *x = RegisterRequest{} - mi := &file_auth_login_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RegisterRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterRequest) ProtoMessage() {} - -func (x *RegisterRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[16] - 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 RegisterRequest.ProtoReflect.Descriptor instead. -func (*RegisterRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{16} -} - -func (x *RegisterRequest) GetData() *RegisterRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -type RegisterResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data *RegisterResponse_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RegisterResponse) Reset() { - *x = RegisterResponse{} - mi := &file_auth_login_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RegisterResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterResponse) ProtoMessage() {} - -func (x *RegisterResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[17] - 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 RegisterResponse.ProtoReflect.Descriptor instead. -func (*RegisterResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{17} -} - -func (x *RegisterResponse) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -func (x *RegisterResponse) GetData() *RegisterResponse_Data { - if x != nil { - return x.Data - } - return nil -} - -type LogoutRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LogoutRequest) Reset() { - *x = LogoutRequest{} - mi := &file_auth_login_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LogoutRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LogoutRequest) ProtoMessage() {} - -func (x *LogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[18] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. -func (*LogoutRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{18} -} - -func (x *LogoutRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type LogoutResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LogoutResponse) Reset() { - *x = LogoutResponse{} - mi := &file_auth_login_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LogoutResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LogoutResponse) ProtoMessage() {} - -func (x *LogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead. -func (*LogoutResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{19} -} - -func (x *LogoutResponse) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -type TokenRefreshRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *TokenRefreshRequest_Data) Reset() { - *x = TokenRefreshRequest_Data{} - mi := &file_auth_login_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *TokenRefreshRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TokenRefreshRequest_Data) ProtoMessage() {} - -func (x *TokenRefreshRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[20] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TokenRefreshRequest_Data.ProtoReflect.Descriptor instead. -func (*TokenRefreshRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *TokenRefreshRequest_Data) GetRefreshToken() string { - if x != nil { - return x.RefreshToken - } - return "" -} - -type LoginRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` - CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` - CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LoginRequest_Data) Reset() { - *x = LoginRequest_Data{} - mi := &file_auth_login_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LoginRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoginRequest_Data) ProtoMessage() {} - -func (x *LoginRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[21] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LoginRequest_Data.ProtoReflect.Descriptor instead. -func (*LoginRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{2, 0} -} - -func (x *LoginRequest_Data) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *LoginRequest_Data) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -func (x *LoginRequest_Data) GetCaptchaId() string { - if x != nil { - return x.CaptchaId - } - return "" -} - -func (x *LoginRequest_Data) GetCaptchaCode() string { - if x != nil { - return x.CaptchaCode - } - return "" -} - -type RegisterRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` - CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` - CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RegisterRequest_Data) Reset() { - *x = RegisterRequest_Data{} - mi := &file_auth_login_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RegisterRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterRequest_Data) ProtoMessage() {} - -func (x *RegisterRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[24] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterRequest_Data.ProtoReflect.Descriptor instead. -func (*RegisterRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{16, 0} -} - -func (x *RegisterRequest_Data) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *RegisterRequest_Data) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -func (x *RegisterRequest_Data) GetCaptchaId() string { - if x != nil { - return x.CaptchaId - } - return "" -} - -func (x *RegisterRequest_Data) GetCaptchaCode() string { - if x != nil { - return x.CaptchaCode - } - return "" -} - -type RegisterResponse_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - Redirect string `protobuf:"bytes,1,opt,name=redirect,proto3" json:"redirect,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RegisterResponse_Data) Reset() { - *x = RegisterResponse_Data{} - mi := &file_auth_login_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RegisterResponse_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterResponse_Data) ProtoMessage() {} - -func (x *RegisterResponse_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_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 RegisterResponse_Data.ProtoReflect.Descriptor instead. -func (*RegisterResponse_Data) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{17, 0} -} - -func (x *RegisterResponse_Data) GetRedirect() string { - if x != nil { - return x.Redirect - } - return "" -} - -var File_auth_login_proto protoreflect.FileDescriptor - -const file_auth_login_proto_rawDesc = "" + - "\n" + - "\x10auth/login.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bsecurity/jwt/v1/token.proto\x1a\x17validate/validate.proto\"\x90\x01\n" + - "\x13TokenRefreshRequest\x12B\n" + - "\x04data\x18\x02 \x01(\v2..api.v1.services.auth.TokenRefreshRequest.DataR\x04data\x1a5\n" + - "\x04Data\x12-\n" + - "\rrefresh_token\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\rrefresh_token\"D\n" + - "\x14TokenRefreshResponse\x12,\n" + - "\x05token\x18\x01 \x01(\v2\x16.security.jwt.v1.TokenR\x05token\"\xf4\x01\n" + - "\fLoginRequest\x12;\n" + - "\x04data\x18\x02 \x01(\v2'.api.v1.services.auth.LoginRequest.DataR\x04data\x1a\xa6\x01\n" + - "\x04Data\x12#\n" + - "\busername\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12#\n" + - "\bpassword\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\bpassword\x12'\n" + - "\n" + - "captcha_id\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\n" + - "captcha_id\x12+\n" + - "\fcaptcha_code\x18\x04 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\fcaptcha_code\"=\n" + - "\rLoginResponse\x12,\n" + - "\x05token\x18\x01 \x01(\v2\x16.security.jwt.v1.TokenR\x05token\"3\n" + - "\x17CurrentUserRequestQuery\x12\x18\n" + - "\auser_id\x18\x01 \x01(\x03R\auser_id\"W\n" + - "\x12CurrentUserRequest\x12A\n" + - "\x04data\x18\x01 \x01(\v2-.api.v1.services.auth.CurrentUserRequestQueryR\x04data\"Y\n" + - "\x13CurrentUserResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\x12(\n" + - "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\":\n" + - "\x10CaptchaIdRequest\x12\x0e\n" + - "\x02ts\x18\x01 \x01(\tR\x02ts\x12\x16\n" + - "\x06reload\x18\x02 \x01(\bR\x06reload\"'\n" + - "\x11CaptchaIdResponse\x12\x12\n" + - "\x04data\x18\x01 \x01(\tR\x04data\"g\n" + - "\x13CaptchaImageRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" + - "\x06reload\x18\x02 \x01(\tR\x06reload\x12(\n" + - "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\"M\n" + - "\vCaptchaData\x12\x1d\n" + - "\n" + - "captcha_id\x18\x01 \x01(\tR\tcaptchaId\x12\x1f\n" + - "\vcaptcha_img\x18\x02 \x01(\tR\n" + - "captchaImg\"\xbb\x01\n" + - "\x14CaptchaImageResponse\x12Q\n" + - "\aheaders\x18\x01 \x03(\v27.api.v1.services.auth.CaptchaImageResponse.HeadersEntryR\aheaders\x12\x14\n" + - "\x05image\x18\x02 \x01(\fR\x05image\x1a:\n" + - "\fHeadersEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"g\n" + - "\x13CaptchaAudioRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" + - "\x06reload\x18\x02 \x01(\tR\x06reload\x12(\n" + - "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\xbb\x01\n" + - "\x14CaptchaAudioResponse\x12Q\n" + - "\aheaders\x18\x01 \x03(\v27.api.v1.services.auth.CaptchaAudioResponse.HeadersEntryR\aheaders\x12\x14\n" + - "\x05audio\x18\x02 \x01(\fR\x05audio\x1a:\n" + - "\fHeadersEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\\\n" + - "\x0eCaptchaRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + - "\x04type\x18\x02 \x01(\tR\x04type\x12\x16\n" + - "\x06reload\x18\x03 \x01(\bR\x06reload\x12\x0e\n" + - "\x02ts\x18\x04 \x01(\tR\x02ts\"I\n" + - "\x0fCaptchaResponse\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + - "\x04type\x18\x02 \x01(\tR\x04type\x12\x12\n" + - "\x04data\x18\x03 \x01(\tR\x04data\"\xfa\x01\n" + - "\x0fRegisterRequest\x12>\n" + - "\x04data\x18\x02 \x01(\v2*.api.v1.services.auth.RegisterRequest.DataR\x04data\x1a\xa6\x01\n" + - "\x04Data\x12#\n" + - "\busername\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12#\n" + - "\bpassword\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\bpassword\x12'\n" + - "\n" + - "captcha_id\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\n" + - "captcha_id\x12+\n" + - "\fcaptcha_code\x18\x04 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\fcaptcha_code\"\x91\x01\n" + - "\x10RegisterResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\x12?\n" + - "\x04data\x18\x02 \x01(\v2+.api.v1.services.auth.RegisterResponse.DataR\x04data\x1a\"\n" + - "\x04Data\x12\x1a\n" + - "\bredirect\x18\x01 \x01(\tR\bredirect\"9\n" + - "\rLogoutRequest\x12(\n" + - "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"*\n" + - "\x0eLogoutResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess2\xc2\a\n" + - "\fLoginService\x12k\n" + - "\aCaptcha\x12$.api.v1.services.auth.CaptchaRequest\x1a%.api.v1.services.auth.CaptchaResponse\"\x13\x82\xd3\xe4\x93\x02\rb\x01*\x12\b/captcha\x12q\n" + - "\tCaptchaId\x12&.api.v1.services.auth.CaptchaIdRequest\x1a'.api.v1.services.auth.CaptchaIdResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/captcha/id\x12\x80\x01\n" + - "\fCaptchaImage\x12).api.v1.services.auth.CaptchaImageRequest\x1a*.api.v1.services.auth.CaptchaImageResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/image\x12\x80\x01\n" + - "\fCaptchaAudio\x12).api.v1.services.auth.CaptchaAudioRequest\x1a*.api.v1.services.auth.CaptchaAudioResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/audio\x12f\n" + - "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x14\x82\xd3\xe4\x93\x02\x0e:\x04data\"\x06/login\x12j\n" + - "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/logout\x12r\n" + - "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a&.api.v1.services.auth.RegisterResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x04data\"\t/register\x12\x83\x01\n" + - "\fTokenRefresh\x12).api.v1.services.auth.TokenRefreshRequest\x1a*.api.v1.services.auth.TokenRefreshResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04data\"\x0e/token/refreshB\xd1\x01\n" + - "\x18com.api.v1.services.authB\n" + - "LoginProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" - -var ( - file_auth_login_proto_rawDescOnce sync.Once - file_auth_login_proto_rawDescData []byte -) - -func file_auth_login_proto_rawDescGZIP() []byte { - file_auth_login_proto_rawDescOnce.Do(func() { - file_auth_login_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_login_proto_rawDesc), len(file_auth_login_proto_rawDesc))) - }) - return file_auth_login_proto_rawDescData -} - -var file_auth_login_proto_msgTypes = make([]protoimpl.MessageInfo, 26) -var file_auth_login_proto_goTypes = []any{ - (*TokenRefreshRequest)(nil), // 0: api.v1.services.auth.TokenRefreshRequest - (*TokenRefreshResponse)(nil), // 1: api.v1.services.auth.TokenRefreshResponse - (*LoginRequest)(nil), // 2: api.v1.services.auth.LoginRequest - (*LoginResponse)(nil), // 3: api.v1.services.auth.LoginResponse - (*CurrentUserRequestQuery)(nil), // 4: api.v1.services.auth.CurrentUserRequestQuery - (*CurrentUserRequest)(nil), // 5: api.v1.services.auth.CurrentUserRequest - (*CurrentUserResponse)(nil), // 6: api.v1.services.auth.CurrentUserResponse - (*CaptchaIdRequest)(nil), // 7: api.v1.services.auth.CaptchaIdRequest - (*CaptchaIdResponse)(nil), // 8: api.v1.services.auth.CaptchaIdResponse - (*CaptchaImageRequest)(nil), // 9: api.v1.services.auth.CaptchaImageRequest - (*CaptchaData)(nil), // 10: api.v1.services.auth.CaptchaData - (*CaptchaImageResponse)(nil), // 11: api.v1.services.auth.CaptchaImageResponse - (*CaptchaAudioRequest)(nil), // 12: api.v1.services.auth.CaptchaAudioRequest - (*CaptchaAudioResponse)(nil), // 13: api.v1.services.auth.CaptchaAudioResponse - (*CaptchaRequest)(nil), // 14: api.v1.services.auth.CaptchaRequest - (*CaptchaResponse)(nil), // 15: api.v1.services.auth.CaptchaResponse - (*RegisterRequest)(nil), // 16: api.v1.services.auth.RegisterRequest - (*RegisterResponse)(nil), // 17: api.v1.services.auth.RegisterResponse - (*LogoutRequest)(nil), // 18: api.v1.services.auth.LogoutRequest - (*LogoutResponse)(nil), // 19: api.v1.services.auth.LogoutResponse - (*TokenRefreshRequest_Data)(nil), // 20: api.v1.services.auth.TokenRefreshRequest.Data - (*LoginRequest_Data)(nil), // 21: api.v1.services.auth.LoginRequest.Data - nil, // 22: api.v1.services.auth.CaptchaImageResponse.HeadersEntry - nil, // 23: api.v1.services.auth.CaptchaAudioResponse.HeadersEntry - (*RegisterRequest_Data)(nil), // 24: api.v1.services.auth.RegisterRequest.Data - (*RegisterResponse_Data)(nil), // 25: api.v1.services.auth.RegisterResponse.Data - (*v1.Token)(nil), // 26: security.jwt.v1.Token - (*anypb.Any)(nil), // 27: google.protobuf.Any -} -var file_auth_login_proto_depIdxs = []int32{ - 20, // 0: api.v1.services.auth.TokenRefreshRequest.data:type_name -> api.v1.services.auth.TokenRefreshRequest.Data - 26, // 1: api.v1.services.auth.TokenRefreshResponse.token:type_name -> security.jwt.v1.Token - 21, // 2: api.v1.services.auth.LoginRequest.data:type_name -> api.v1.services.auth.LoginRequest.Data - 26, // 3: api.v1.services.auth.LoginResponse.token:type_name -> security.jwt.v1.Token - 4, // 4: api.v1.services.auth.CurrentUserRequest.data:type_name -> api.v1.services.auth.CurrentUserRequestQuery - 27, // 5: api.v1.services.auth.CurrentUserResponse.data:type_name -> google.protobuf.Any - 27, // 6: api.v1.services.auth.CaptchaImageRequest.data:type_name -> google.protobuf.Any - 22, // 7: api.v1.services.auth.CaptchaImageResponse.headers:type_name -> api.v1.services.auth.CaptchaImageResponse.HeadersEntry - 27, // 8: api.v1.services.auth.CaptchaAudioRequest.data:type_name -> google.protobuf.Any - 23, // 9: api.v1.services.auth.CaptchaAudioResponse.headers:type_name -> api.v1.services.auth.CaptchaAudioResponse.HeadersEntry - 24, // 10: api.v1.services.auth.RegisterRequest.data:type_name -> api.v1.services.auth.RegisterRequest.Data - 25, // 11: api.v1.services.auth.RegisterResponse.data:type_name -> api.v1.services.auth.RegisterResponse.Data - 27, // 12: api.v1.services.auth.LogoutRequest.data:type_name -> google.protobuf.Any - 14, // 13: api.v1.services.auth.LoginService.Captcha:input_type -> api.v1.services.auth.CaptchaRequest - 7, // 14: api.v1.services.auth.LoginService.CaptchaId:input_type -> api.v1.services.auth.CaptchaIdRequest - 9, // 15: api.v1.services.auth.LoginService.CaptchaImage:input_type -> api.v1.services.auth.CaptchaImageRequest - 12, // 16: api.v1.services.auth.LoginService.CaptchaAudio:input_type -> api.v1.services.auth.CaptchaAudioRequest - 2, // 17: api.v1.services.auth.LoginService.Login:input_type -> api.v1.services.auth.LoginRequest - 18, // 18: api.v1.services.auth.LoginService.Logout:input_type -> api.v1.services.auth.LogoutRequest - 16, // 19: api.v1.services.auth.LoginService.Register:input_type -> api.v1.services.auth.RegisterRequest - 0, // 20: api.v1.services.auth.LoginService.TokenRefresh:input_type -> api.v1.services.auth.TokenRefreshRequest - 15, // 21: api.v1.services.auth.LoginService.Captcha:output_type -> api.v1.services.auth.CaptchaResponse - 8, // 22: api.v1.services.auth.LoginService.CaptchaId:output_type -> api.v1.services.auth.CaptchaIdResponse - 11, // 23: api.v1.services.auth.LoginService.CaptchaImage:output_type -> api.v1.services.auth.CaptchaImageResponse - 13, // 24: api.v1.services.auth.LoginService.CaptchaAudio:output_type -> api.v1.services.auth.CaptchaAudioResponse - 3, // 25: api.v1.services.auth.LoginService.Login:output_type -> api.v1.services.auth.LoginResponse - 19, // 26: api.v1.services.auth.LoginService.Logout:output_type -> api.v1.services.auth.LogoutResponse - 17, // 27: api.v1.services.auth.LoginService.Register:output_type -> api.v1.services.auth.RegisterResponse - 1, // 28: api.v1.services.auth.LoginService.TokenRefresh:output_type -> api.v1.services.auth.TokenRefreshResponse - 21, // [21:29] is the sub-list for method output_type - 13, // [13:21] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name -} - -func init() { file_auth_login_proto_init() } -func file_auth_login_proto_init() { - if File_auth_login_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_login_proto_rawDesc), len(file_auth_login_proto_rawDesc)), - NumEnums: 0, - NumMessages: 26, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_auth_login_proto_goTypes, - DependencyIndexes: file_auth_login_proto_depIdxs, - MessageInfos: file_auth_login_proto_msgTypes, - }.Build() - File_auth_login_proto = out.File - file_auth_login_proto_goTypes = nil - file_auth_login_proto_depIdxs = nil -} diff --git a/api/v1/services/auth/login.pb.gw.go b/api/v1/services/auth/login.pb.gw.go deleted file mode 100644 index 6c520321..00000000 --- a/api/v1/services/auth/login.pb.gw.go +++ /dev/null @@ -1,631 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: auth/login.proto - -/* -Package auth is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package auth - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_LoginService_Captcha_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_LoginService_Captcha_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_Captcha_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Captcha(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_Captcha_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_Captcha_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Captcha(ctx, &protoReq) - return msg, metadata, err -} - -var filter_LoginService_CaptchaId_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_LoginService_CaptchaId_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaIdRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaId_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CaptchaId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_CaptchaId_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaIdRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaId_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CaptchaId(ctx, &protoReq) - return msg, metadata, err -} - -var filter_LoginService_CaptchaImage_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_LoginService_CaptchaImage_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaImageRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaImage_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CaptchaImage(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_CaptchaImage_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaImageRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaImage_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CaptchaImage(ctx, &protoReq) - return msg, metadata, err -} - -var filter_LoginService_CaptchaAudio_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_LoginService_CaptchaAudio_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaAudioRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaAudio_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CaptchaAudio(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_CaptchaAudio_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaAudioRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaAudio_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CaptchaAudio(ctx, &protoReq) - return msg, metadata, err -} - -func request_LoginService_Login_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq LoginRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_Login_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq LoginRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Login(ctx, &protoReq) - return msg, metadata, err -} - -func request_LoginService_Logout_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq LogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Logout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_Logout_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq LogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Logout(ctx, &protoReq) - return msg, metadata, err -} - -func request_LoginService_Register_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RegisterRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Register(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_Register_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RegisterRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Register(ctx, &protoReq) - return msg, metadata, err -} - -func request_LoginService_TokenRefresh_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq TokenRefreshRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.TokenRefresh(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_TokenRefresh_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq TokenRefreshRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.TokenRefresh(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterLoginServiceHandlerServer registers the http handlers for service LoginService to "mux". -// UnaryRPC :call LoginServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterLoginServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server LoginServiceServer) error { - mux.Handle(http.MethodGet, pattern_LoginService_Captcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Captcha", runtime.WithHTTPPathPattern("/captcha")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_Captcha_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Captcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaId", runtime.WithHTTPPathPattern("/captcha/id")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_CaptchaId_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaId_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaImage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaImage", runtime.WithHTTPPathPattern("/captcha/image")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_CaptchaImage_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaImage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaAudio_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaAudio", runtime.WithHTTPPathPattern("/captcha/audio")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_CaptchaAudio_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaAudio_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Login", runtime.WithHTTPPathPattern("/login")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Logout", runtime.WithHTTPPathPattern("/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_Logout_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Register", runtime.WithHTTPPathPattern("/register")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_Register_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_TokenRefresh_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/TokenRefresh", runtime.WithHTTPPathPattern("/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_TokenRefresh_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_TokenRefresh_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterLoginServiceHandlerFromEndpoint is same as RegisterLoginServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterLoginServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterLoginServiceHandler(ctx, mux, conn) -} - -// RegisterLoginServiceHandler registers the http handlers for service LoginService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterLoginServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterLoginServiceHandlerClient(ctx, mux, NewLoginServiceClient(conn)) -} - -// RegisterLoginServiceHandlerClient registers the http handlers for service LoginService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "LoginServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LoginServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "LoginServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client LoginServiceClient) error { - mux.Handle(http.MethodGet, pattern_LoginService_Captcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Captcha", runtime.WithHTTPPathPattern("/captcha")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_Captcha_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Captcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaId", runtime.WithHTTPPathPattern("/captcha/id")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_CaptchaId_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaId_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaImage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaImage", runtime.WithHTTPPathPattern("/captcha/image")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_CaptchaImage_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaImage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaAudio_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaAudio", runtime.WithHTTPPathPattern("/captcha/audio")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_CaptchaAudio_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaAudio_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Login", runtime.WithHTTPPathPattern("/login")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Logout", runtime.WithHTTPPathPattern("/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_Logout_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Register", runtime.WithHTTPPathPattern("/register")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_Register_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_TokenRefresh_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/TokenRefresh", runtime.WithHTTPPathPattern("/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_TokenRefresh_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_TokenRefresh_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_LoginService_Captcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"captcha"}, "")) - pattern_LoginService_CaptchaId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"captcha", "id"}, "")) - pattern_LoginService_CaptchaImage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"captcha", "image"}, "")) - pattern_LoginService_CaptchaAudio_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"captcha", "audio"}, "")) - pattern_LoginService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"login"}, "")) - pattern_LoginService_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"logout"}, "")) - pattern_LoginService_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"register"}, "")) - pattern_LoginService_TokenRefresh_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"token", "refresh"}, "")) -) - -var ( - forward_LoginService_Captcha_0 = runtime.ForwardResponseMessage - forward_LoginService_CaptchaId_0 = runtime.ForwardResponseMessage - forward_LoginService_CaptchaImage_0 = runtime.ForwardResponseMessage - forward_LoginService_CaptchaAudio_0 = runtime.ForwardResponseMessage - forward_LoginService_Login_0 = runtime.ForwardResponseMessage - forward_LoginService_Logout_0 = runtime.ForwardResponseMessage - forward_LoginService_Register_0 = runtime.ForwardResponseMessage - forward_LoginService_TokenRefresh_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/auth/login.pb.validate.go b/api/v1/services/auth/login.pb.validate.go deleted file mode 100644 index 45969891..00000000 --- a/api/v1/services/auth/login.pb.validate.go +++ /dev/null @@ -1,2930 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: auth/login.proto - -package auth - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on TokenRefreshRequest 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 *TokenRefreshRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on TokenRefreshRequest 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 -// TokenRefreshRequestMultiError, or nil if none found. -func (m *TokenRefreshRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *TokenRefreshRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, TokenRefreshRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, TokenRefreshRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return TokenRefreshRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return TokenRefreshRequestMultiError(errors) - } - - return nil -} - -// TokenRefreshRequestMultiError is an error wrapping multiple validation -// errors returned by TokenRefreshRequest.ValidateAll() if the designated -// constraints aren't met. -type TokenRefreshRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m TokenRefreshRequestMultiError) 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 TokenRefreshRequestMultiError) AllErrors() []error { return m } - -// TokenRefreshRequestValidationError is the validation error returned by -// TokenRefreshRequest.Validate if the designated constraints aren't met. -type TokenRefreshRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e TokenRefreshRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e TokenRefreshRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e TokenRefreshRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e TokenRefreshRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e TokenRefreshRequestValidationError) ErrorName() string { - return "TokenRefreshRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e TokenRefreshRequestValidationError) 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 %sTokenRefreshRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = TokenRefreshRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = TokenRefreshRequestValidationError{} - -// Validate checks the field values on TokenRefreshResponse 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 *TokenRefreshResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on TokenRefreshResponse 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 -// TokenRefreshResponseMultiError, or nil if none found. -func (m *TokenRefreshResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *TokenRefreshResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetToken()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, TokenRefreshResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, TokenRefreshResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetToken()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return TokenRefreshResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return TokenRefreshResponseMultiError(errors) - } - - return nil -} - -// TokenRefreshResponseMultiError is an error wrapping multiple validation -// errors returned by TokenRefreshResponse.ValidateAll() if the designated -// constraints aren't met. -type TokenRefreshResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m TokenRefreshResponseMultiError) 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 TokenRefreshResponseMultiError) AllErrors() []error { return m } - -// TokenRefreshResponseValidationError is the validation error returned by -// TokenRefreshResponse.Validate if the designated constraints aren't met. -type TokenRefreshResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e TokenRefreshResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e TokenRefreshResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e TokenRefreshResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e TokenRefreshResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e TokenRefreshResponseValidationError) ErrorName() string { - return "TokenRefreshResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e TokenRefreshResponseValidationError) 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 %sTokenRefreshResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = TokenRefreshResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = TokenRefreshResponseValidationError{} - -// 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. -func (m *LoginRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LoginRequest 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 LoginRequestMultiError, or -// nil if none found. -func (m *LoginRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *LoginRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LoginRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LoginRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LoginRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return LoginRequestMultiError(errors) - } - - return nil -} - -// LoginRequestMultiError is an error wrapping multiple validation errors -// returned by LoginRequest.ValidateAll() if the designated constraints aren't met. -type LoginRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LoginRequestMultiError) 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 LoginRequestMultiError) AllErrors() []error { return m } - -// LoginRequestValidationError is the validation error returned by -// LoginRequest.Validate if the designated constraints aren't met. -type LoginRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LoginRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LoginRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LoginRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LoginRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LoginRequestValidationError) ErrorName() string { return "LoginRequestValidationError" } - -// Error satisfies the builtin error interface -func (e LoginRequestValidationError) 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 %sLoginRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LoginRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LoginRequestValidationError{} - -// Validate checks the field values on LoginResponse 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 *LoginResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LoginResponse 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 LoginResponseMultiError, or -// nil if none found. -func (m *LoginResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *LoginResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetToken()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LoginResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LoginResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetToken()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LoginResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return LoginResponseMultiError(errors) - } - - return nil -} - -// LoginResponseMultiError is an error wrapping multiple validation errors -// returned by LoginResponse.ValidateAll() if the designated constraints -// aren't met. -type LoginResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LoginResponseMultiError) 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 LoginResponseMultiError) AllErrors() []error { return m } - -// LoginResponseValidationError is the validation error returned by -// LoginResponse.Validate if the designated constraints aren't met. -type LoginResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LoginResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LoginResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LoginResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LoginResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LoginResponseValidationError) ErrorName() string { return "LoginResponseValidationError" } - -// Error satisfies the builtin error interface -func (e LoginResponseValidationError) 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 %sLoginResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LoginResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LoginResponseValidationError{} - -// Validate checks the field values on CurrentUserRequestQuery 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 *CurrentUserRequestQuery) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CurrentUserRequestQuery 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 -// CurrentUserRequestQueryMultiError, or nil if none found. -func (m *CurrentUserRequestQuery) ValidateAll() error { - return m.validate(true) -} - -func (m *CurrentUserRequestQuery) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for UserId - - if len(errors) > 0 { - return CurrentUserRequestQueryMultiError(errors) - } - - return nil -} - -// CurrentUserRequestQueryMultiError is an error wrapping multiple validation -// errors returned by CurrentUserRequestQuery.ValidateAll() if the designated -// constraints aren't met. -type CurrentUserRequestQueryMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CurrentUserRequestQueryMultiError) 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 CurrentUserRequestQueryMultiError) AllErrors() []error { return m } - -// CurrentUserRequestQueryValidationError is the validation error returned by -// CurrentUserRequestQuery.Validate if the designated constraints aren't met. -type CurrentUserRequestQueryValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CurrentUserRequestQueryValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CurrentUserRequestQueryValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CurrentUserRequestQueryValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CurrentUserRequestQueryValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CurrentUserRequestQueryValidationError) ErrorName() string { - return "CurrentUserRequestQueryValidationError" -} - -// Error satisfies the builtin error interface -func (e CurrentUserRequestQueryValidationError) 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 %sCurrentUserRequestQuery.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CurrentUserRequestQueryValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CurrentUserRequestQueryValidationError{} - -// Validate checks the field values on CurrentUserRequest 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 *CurrentUserRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CurrentUserRequest 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 -// CurrentUserRequestMultiError, or nil if none found. -func (m *CurrentUserRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CurrentUserRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CurrentUserRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CurrentUserRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CurrentUserRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CurrentUserRequestMultiError(errors) - } - - return nil -} - -// CurrentUserRequestMultiError is an error wrapping multiple validation errors -// returned by CurrentUserRequest.ValidateAll() if the designated constraints -// aren't met. -type CurrentUserRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CurrentUserRequestMultiError) 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 CurrentUserRequestMultiError) AllErrors() []error { return m } - -// CurrentUserRequestValidationError is the validation error returned by -// CurrentUserRequest.Validate if the designated constraints aren't met. -type CurrentUserRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CurrentUserRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CurrentUserRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CurrentUserRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CurrentUserRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CurrentUserRequestValidationError) ErrorName() string { - return "CurrentUserRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CurrentUserRequestValidationError) 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 %sCurrentUserRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CurrentUserRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CurrentUserRequestValidationError{} - -// Validate checks the field values on CurrentUserResponse 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 *CurrentUserResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CurrentUserResponse 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 -// CurrentUserResponseMultiError, or nil if none found. -func (m *CurrentUserResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CurrentUserResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Success - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CurrentUserResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CurrentUserResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CurrentUserResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CurrentUserResponseMultiError(errors) - } - - return nil -} - -// CurrentUserResponseMultiError is an error wrapping multiple validation -// errors returned by CurrentUserResponse.ValidateAll() if the designated -// constraints aren't met. -type CurrentUserResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CurrentUserResponseMultiError) 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 CurrentUserResponseMultiError) AllErrors() []error { return m } - -// CurrentUserResponseValidationError is the validation error returned by -// CurrentUserResponse.Validate if the designated constraints aren't met. -type CurrentUserResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CurrentUserResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CurrentUserResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CurrentUserResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CurrentUserResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CurrentUserResponseValidationError) ErrorName() string { - return "CurrentUserResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CurrentUserResponseValidationError) 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 %sCurrentUserResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CurrentUserResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CurrentUserResponseValidationError{} - -// Validate checks the field values on CaptchaIdRequest 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 *CaptchaIdRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaIdRequest 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 -// CaptchaIdRequestMultiError, or nil if none found. -func (m *CaptchaIdRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaIdRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Ts - - // no validation rules for Reload - - if len(errors) > 0 { - return CaptchaIdRequestMultiError(errors) - } - - return nil -} - -// CaptchaIdRequestMultiError is an error wrapping multiple validation errors -// returned by CaptchaIdRequest.ValidateAll() if the designated constraints -// aren't met. -type CaptchaIdRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaIdRequestMultiError) 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 CaptchaIdRequestMultiError) AllErrors() []error { return m } - -// CaptchaIdRequestValidationError is the validation error returned by -// CaptchaIdRequest.Validate if the designated constraints aren't met. -type CaptchaIdRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaIdRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaIdRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaIdRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaIdRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaIdRequestValidationError) ErrorName() string { return "CaptchaIdRequestValidationError" } - -// Error satisfies the builtin error interface -func (e CaptchaIdRequestValidationError) 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 %sCaptchaIdRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaIdRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaIdRequestValidationError{} - -// Validate checks the field values on CaptchaIdResponse 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 *CaptchaIdResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaIdResponse 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 -// CaptchaIdResponseMultiError, or nil if none found. -func (m *CaptchaIdResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaIdResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Data - - if len(errors) > 0 { - return CaptchaIdResponseMultiError(errors) - } - - return nil -} - -// CaptchaIdResponseMultiError is an error wrapping multiple validation errors -// returned by CaptchaIdResponse.ValidateAll() if the designated constraints -// aren't met. -type CaptchaIdResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaIdResponseMultiError) 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 CaptchaIdResponseMultiError) AllErrors() []error { return m } - -// CaptchaIdResponseValidationError is the validation error returned by -// CaptchaIdResponse.Validate if the designated constraints aren't met. -type CaptchaIdResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaIdResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaIdResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaIdResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaIdResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaIdResponseValidationError) ErrorName() string { - return "CaptchaIdResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CaptchaIdResponseValidationError) 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 %sCaptchaIdResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaIdResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaIdResponseValidationError{} - -// Validate checks the field values on CaptchaImageRequest 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 *CaptchaImageRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaImageRequest 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 -// CaptchaImageRequestMultiError, or nil if none found. -func (m *CaptchaImageRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaImageRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Reload - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CaptchaImageRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CaptchaImageRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CaptchaImageRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CaptchaImageRequestMultiError(errors) - } - - return nil -} - -// CaptchaImageRequestMultiError is an error wrapping multiple validation -// errors returned by CaptchaImageRequest.ValidateAll() if the designated -// constraints aren't met. -type CaptchaImageRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaImageRequestMultiError) 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 CaptchaImageRequestMultiError) AllErrors() []error { return m } - -// CaptchaImageRequestValidationError is the validation error returned by -// CaptchaImageRequest.Validate if the designated constraints aren't met. -type CaptchaImageRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaImageRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaImageRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaImageRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaImageRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaImageRequestValidationError) ErrorName() string { - return "CaptchaImageRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CaptchaImageRequestValidationError) 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 %sCaptchaImageRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaImageRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaImageRequestValidationError{} - -// Validate checks the field values on CaptchaData 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 *CaptchaData) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaData 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 CaptchaDataMultiError, or -// nil if none found. -func (m *CaptchaData) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaData) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for CaptchaId - - // no validation rules for CaptchaImg - - if len(errors) > 0 { - return CaptchaDataMultiError(errors) - } - - return nil -} - -// CaptchaDataMultiError is an error wrapping multiple validation errors -// returned by CaptchaData.ValidateAll() if the designated constraints aren't met. -type CaptchaDataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaDataMultiError) 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 CaptchaDataMultiError) AllErrors() []error { return m } - -// CaptchaDataValidationError is the validation error returned by -// CaptchaData.Validate if the designated constraints aren't met. -type CaptchaDataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaDataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaDataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaDataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaDataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaDataValidationError) ErrorName() string { return "CaptchaDataValidationError" } - -// Error satisfies the builtin error interface -func (e CaptchaDataValidationError) 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 %sCaptchaData.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaDataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaDataValidationError{} - -// Validate checks the field values on CaptchaImageResponse 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 *CaptchaImageResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaImageResponse 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 -// CaptchaImageResponseMultiError, or nil if none found. -func (m *CaptchaImageResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaImageResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Headers - - // no validation rules for Image - - if len(errors) > 0 { - return CaptchaImageResponseMultiError(errors) - } - - return nil -} - -// CaptchaImageResponseMultiError is an error wrapping multiple validation -// errors returned by CaptchaImageResponse.ValidateAll() if the designated -// constraints aren't met. -type CaptchaImageResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaImageResponseMultiError) 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 CaptchaImageResponseMultiError) AllErrors() []error { return m } - -// CaptchaImageResponseValidationError is the validation error returned by -// CaptchaImageResponse.Validate if the designated constraints aren't met. -type CaptchaImageResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaImageResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaImageResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaImageResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaImageResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaImageResponseValidationError) ErrorName() string { - return "CaptchaImageResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CaptchaImageResponseValidationError) 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 %sCaptchaImageResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaImageResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaImageResponseValidationError{} - -// Validate checks the field values on CaptchaAudioRequest 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 *CaptchaAudioRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaAudioRequest 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 -// CaptchaAudioRequestMultiError, or nil if none found. -func (m *CaptchaAudioRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaAudioRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Reload - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CaptchaAudioRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CaptchaAudioRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CaptchaAudioRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CaptchaAudioRequestMultiError(errors) - } - - return nil -} - -// CaptchaAudioRequestMultiError is an error wrapping multiple validation -// errors returned by CaptchaAudioRequest.ValidateAll() if the designated -// constraints aren't met. -type CaptchaAudioRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaAudioRequestMultiError) 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 CaptchaAudioRequestMultiError) AllErrors() []error { return m } - -// CaptchaAudioRequestValidationError is the validation error returned by -// CaptchaAudioRequest.Validate if the designated constraints aren't met. -type CaptchaAudioRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaAudioRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaAudioRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaAudioRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaAudioRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaAudioRequestValidationError) ErrorName() string { - return "CaptchaAudioRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CaptchaAudioRequestValidationError) 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 %sCaptchaAudioRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaAudioRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaAudioRequestValidationError{} - -// Validate checks the field values on CaptchaAudioResponse 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 *CaptchaAudioResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaAudioResponse 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 -// CaptchaAudioResponseMultiError, or nil if none found. -func (m *CaptchaAudioResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaAudioResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Headers - - // no validation rules for Audio - - if len(errors) > 0 { - return CaptchaAudioResponseMultiError(errors) - } - - return nil -} - -// CaptchaAudioResponseMultiError is an error wrapping multiple validation -// errors returned by CaptchaAudioResponse.ValidateAll() if the designated -// constraints aren't met. -type CaptchaAudioResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaAudioResponseMultiError) 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 CaptchaAudioResponseMultiError) AllErrors() []error { return m } - -// CaptchaAudioResponseValidationError is the validation error returned by -// CaptchaAudioResponse.Validate if the designated constraints aren't met. -type CaptchaAudioResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaAudioResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaAudioResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaAudioResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaAudioResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaAudioResponseValidationError) ErrorName() string { - return "CaptchaAudioResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CaptchaAudioResponseValidationError) 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 %sCaptchaAudioResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaAudioResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaAudioResponseValidationError{} - -// Validate checks the field values on CaptchaRequest 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 *CaptchaRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaRequest 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 CaptchaRequestMultiError, -// or nil if none found. -func (m *CaptchaRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Type - - // no validation rules for Reload - - // no validation rules for Ts - - if len(errors) > 0 { - return CaptchaRequestMultiError(errors) - } - - return nil -} - -// CaptchaRequestMultiError is an error wrapping multiple validation errors -// returned by CaptchaRequest.ValidateAll() if the designated constraints -// aren't met. -type CaptchaRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaRequestMultiError) 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 CaptchaRequestMultiError) AllErrors() []error { return m } - -// CaptchaRequestValidationError is the validation error returned by -// CaptchaRequest.Validate if the designated constraints aren't met. -type CaptchaRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaRequestValidationError) ErrorName() string { return "CaptchaRequestValidationError" } - -// Error satisfies the builtin error interface -func (e CaptchaRequestValidationError) 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 %sCaptchaRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaRequestValidationError{} - -// Validate checks the field values on CaptchaResponse 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 *CaptchaResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaResponse 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 -// CaptchaResponseMultiError, or nil if none found. -func (m *CaptchaResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Type - - // no validation rules for Data - - if len(errors) > 0 { - return CaptchaResponseMultiError(errors) - } - - return nil -} - -// CaptchaResponseMultiError is an error wrapping multiple validation errors -// returned by CaptchaResponse.ValidateAll() if the designated constraints -// aren't met. -type CaptchaResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaResponseMultiError) 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 CaptchaResponseMultiError) AllErrors() []error { return m } - -// CaptchaResponseValidationError is the validation error returned by -// CaptchaResponse.Validate if the designated constraints aren't met. -type CaptchaResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaResponseValidationError) ErrorName() string { return "CaptchaResponseValidationError" } - -// Error satisfies the builtin error interface -func (e CaptchaResponseValidationError) 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 %sCaptchaResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaResponseValidationError{} - -// Validate checks the field values on RegisterRequest 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 *RegisterRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RegisterRequest 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 -// RegisterRequestMultiError, or nil if none found. -func (m *RegisterRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *RegisterRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RegisterRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RegisterRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RegisterRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RegisterRequestMultiError(errors) - } - - return nil -} - -// RegisterRequestMultiError is an error wrapping multiple validation errors -// returned by RegisterRequest.ValidateAll() if the designated constraints -// aren't met. -type RegisterRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RegisterRequestMultiError) 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 RegisterRequestMultiError) AllErrors() []error { return m } - -// RegisterRequestValidationError is the validation error returned by -// RegisterRequest.Validate if the designated constraints aren't met. -type RegisterRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RegisterRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RegisterRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RegisterRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RegisterRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RegisterRequestValidationError) ErrorName() string { return "RegisterRequestValidationError" } - -// Error satisfies the builtin error interface -func (e RegisterRequestValidationError) 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 %sRegisterRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RegisterRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RegisterRequestValidationError{} - -// Validate checks the field values on RegisterResponse 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 *RegisterResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RegisterResponse 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 -// RegisterResponseMultiError, or nil if none found. -func (m *RegisterResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *RegisterResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Success - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RegisterResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RegisterResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RegisterResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RegisterResponseMultiError(errors) - } - - return nil -} - -// RegisterResponseMultiError is an error wrapping multiple validation errors -// returned by RegisterResponse.ValidateAll() if the designated constraints -// aren't met. -type RegisterResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RegisterResponseMultiError) 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 RegisterResponseMultiError) AllErrors() []error { return m } - -// RegisterResponseValidationError is the validation error returned by -// RegisterResponse.Validate if the designated constraints aren't met. -type RegisterResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RegisterResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RegisterResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RegisterResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RegisterResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RegisterResponseValidationError) ErrorName() string { return "RegisterResponseValidationError" } - -// Error satisfies the builtin error interface -func (e RegisterResponseValidationError) 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 %sRegisterResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RegisterResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RegisterResponseValidationError{} - -// Validate checks the field values on LogoutRequest 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 *LogoutRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LogoutRequest 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 LogoutRequestMultiError, or -// nil if none found. -func (m *LogoutRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *LogoutRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return LogoutRequestMultiError(errors) - } - - return nil -} - -// LogoutRequestMultiError is an error wrapping multiple validation errors -// returned by LogoutRequest.ValidateAll() if the designated constraints -// aren't met. -type LogoutRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LogoutRequestMultiError) 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 LogoutRequestMultiError) AllErrors() []error { return m } - -// LogoutRequestValidationError is the validation error returned by -// LogoutRequest.Validate if the designated constraints aren't met. -type LogoutRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LogoutRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LogoutRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LogoutRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LogoutRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LogoutRequestValidationError) ErrorName() string { return "LogoutRequestValidationError" } - -// Error satisfies the builtin error interface -func (e LogoutRequestValidationError) 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 %sLogoutRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LogoutRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LogoutRequestValidationError{} - -// Validate checks the field values on LogoutResponse 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 *LogoutResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LogoutResponse 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 LogoutResponseMultiError, -// or nil if none found. -func (m *LogoutResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *LogoutResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Success - - if len(errors) > 0 { - return LogoutResponseMultiError(errors) - } - - return nil -} - -// LogoutResponseMultiError is an error wrapping multiple validation errors -// returned by LogoutResponse.ValidateAll() if the designated constraints -// aren't met. -type LogoutResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LogoutResponseMultiError) 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 LogoutResponseMultiError) AllErrors() []error { return m } - -// LogoutResponseValidationError is the validation error returned by -// LogoutResponse.Validate if the designated constraints aren't met. -type LogoutResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LogoutResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LogoutResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LogoutResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LogoutResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LogoutResponseValidationError) ErrorName() string { return "LogoutResponseValidationError" } - -// Error satisfies the builtin error interface -func (e LogoutResponseValidationError) 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 %sLogoutResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LogoutResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LogoutResponseValidationError{} - -// Validate checks the field values on TokenRefreshRequest_Data 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 *TokenRefreshRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on TokenRefreshRequest_Data 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 -// TokenRefreshRequest_DataMultiError, or nil if none found. -func (m *TokenRefreshRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *TokenRefreshRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetRefreshToken()) < 1 { - err := TokenRefreshRequest_DataValidationError{ - field: "RefreshToken", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return TokenRefreshRequest_DataMultiError(errors) - } - - return nil -} - -// TokenRefreshRequest_DataMultiError is an error wrapping multiple validation -// errors returned by TokenRefreshRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type TokenRefreshRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m TokenRefreshRequest_DataMultiError) 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 TokenRefreshRequest_DataMultiError) AllErrors() []error { return m } - -// TokenRefreshRequest_DataValidationError is the validation error returned by -// TokenRefreshRequest_Data.Validate if the designated constraints aren't met. -type TokenRefreshRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e TokenRefreshRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e TokenRefreshRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e TokenRefreshRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e TokenRefreshRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e TokenRefreshRequest_DataValidationError) ErrorName() string { - return "TokenRefreshRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e TokenRefreshRequest_DataValidationError) 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 %sTokenRefreshRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = TokenRefreshRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = TokenRefreshRequest_DataValidationError{} - -// Validate checks the field values on LoginRequest_Data 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 *LoginRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LoginRequest_Data 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 -// LoginRequest_DataMultiError, or nil if none found. -func (m *LoginRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *LoginRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetUsername()) < 1 { - err := LoginRequest_DataValidationError{ - field: "Username", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetPassword()) < 1 { - err := LoginRequest_DataValidationError{ - field: "Password", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetCaptchaId()) < 1 { - err := LoginRequest_DataValidationError{ - field: "CaptchaId", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetCaptchaCode()) < 1 { - err := LoginRequest_DataValidationError{ - field: "CaptchaCode", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return LoginRequest_DataMultiError(errors) - } - - return nil -} - -// LoginRequest_DataMultiError is an error wrapping multiple validation errors -// returned by LoginRequest_Data.ValidateAll() if the designated constraints -// aren't met. -type LoginRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LoginRequest_DataMultiError) 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 LoginRequest_DataMultiError) AllErrors() []error { return m } - -// LoginRequest_DataValidationError is the validation error returned by -// LoginRequest_Data.Validate if the designated constraints aren't met. -type LoginRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LoginRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LoginRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LoginRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LoginRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LoginRequest_DataValidationError) ErrorName() string { - return "LoginRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e LoginRequest_DataValidationError) 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 %sLoginRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LoginRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LoginRequest_DataValidationError{} - -// Validate checks the field values on RegisterRequest_Data 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 *RegisterRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RegisterRequest_Data 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 -// RegisterRequest_DataMultiError, or nil if none found. -func (m *RegisterRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *RegisterRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetUsername()) < 1 { - err := RegisterRequest_DataValidationError{ - field: "Username", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetPassword()) < 1 { - err := RegisterRequest_DataValidationError{ - field: "Password", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetCaptchaId()) < 1 { - err := RegisterRequest_DataValidationError{ - field: "CaptchaId", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetCaptchaCode()) < 1 { - err := RegisterRequest_DataValidationError{ - field: "CaptchaCode", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return RegisterRequest_DataMultiError(errors) - } - - return nil -} - -// RegisterRequest_DataMultiError is an error wrapping multiple validation -// errors returned by RegisterRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type RegisterRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RegisterRequest_DataMultiError) 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 RegisterRequest_DataMultiError) AllErrors() []error { return m } - -// RegisterRequest_DataValidationError is the validation error returned by -// RegisterRequest_Data.Validate if the designated constraints aren't met. -type RegisterRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RegisterRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RegisterRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RegisterRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RegisterRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RegisterRequest_DataValidationError) ErrorName() string { - return "RegisterRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e RegisterRequest_DataValidationError) 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 %sRegisterRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RegisterRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RegisterRequest_DataValidationError{} - -// Validate checks the field values on RegisterResponse_Data 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 *RegisterResponse_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RegisterResponse_Data 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 -// RegisterResponse_DataMultiError, or nil if none found. -func (m *RegisterResponse_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *RegisterResponse_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Redirect - - if len(errors) > 0 { - return RegisterResponse_DataMultiError(errors) - } - - return nil -} - -// RegisterResponse_DataMultiError is an error wrapping multiple validation -// errors returned by RegisterResponse_Data.ValidateAll() if the designated -// constraints aren't met. -type RegisterResponse_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RegisterResponse_DataMultiError) 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 RegisterResponse_DataMultiError) AllErrors() []error { return m } - -// RegisterResponse_DataValidationError is the validation error returned by -// RegisterResponse_Data.Validate if the designated constraints aren't met. -type RegisterResponse_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RegisterResponse_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RegisterResponse_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RegisterResponse_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RegisterResponse_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RegisterResponse_DataValidationError) ErrorName() string { - return "RegisterResponse_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e RegisterResponse_DataValidationError) 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 %sRegisterResponse_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RegisterResponse_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RegisterResponse_DataValidationError{} diff --git a/api/v1/services/auth/login_bridge.pb.go b/api/v1/services/auth/login_bridge.pb.go deleted file mode 100644 index de674202..00000000 --- a/api/v1/services/auth/login_bridge.pb.go +++ /dev/null @@ -1,554 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: auth/login.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const LoginServiceCaptchaBridgeOperation = "/api.v1.services.auth.LoginService/Captcha" -const LoginServiceCaptchaAudioBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaAudio" -const LoginServiceCaptchaIdBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaId" -const LoginServiceCaptchaImageBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaImage" -const LoginServiceLoginBridgeOperation = "/api.v1.services.auth.LoginService/Login" -const LoginServiceLogoutBridgeOperation = "/api.v1.services.auth.LoginService/Logout" -const LoginServiceRegisterBridgeOperation = "/api.v1.services.auth.LoginService/Register" -const LoginServiceTokenRefreshBridgeOperation = "/api.v1.services.auth.LoginService/TokenRefresh" - -type LoginServiceBridgeServer interface { - Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) - CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) - CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) - CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) - Login(context.Context, *LoginRequest) (*LoginResponse, error) - Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) - Register(context.Context, *RegisterRequest) (*RegisterResponse, error) - TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) -} - -type LoginServiceHooker interface { - LoginServiceCaptchaHooker - LoginServiceCaptchaAudioHooker - LoginServiceCaptchaIdHooker - LoginServiceCaptchaImageHooker - LoginServiceLoginHooker - LoginServiceLogoutHooker - LoginServiceRegisterHooker - LoginServiceTokenRefreshHooker -} - -type LoginServiceHookedBridger interface { - LoginServiceHooker - LoginServiceBridgeServer -} -type LoginServiceCaptchaHooker interface { - PrepareCaptcha(http.Context, *CaptchaRequest) (context.Context, error) - CompleteCaptcha(http.Context, *CaptchaRequest, *CaptchaResponse) error -} -type LoginServiceCaptchaAudioHooker interface { - PrepareCaptchaAudio(http.Context, *CaptchaAudioRequest) (context.Context, error) - CompleteCaptchaAudio(http.Context, *CaptchaAudioRequest, *CaptchaAudioResponse) error -} -type LoginServiceCaptchaIdHooker interface { - PrepareCaptchaId(http.Context, *CaptchaIdRequest) (context.Context, error) - CompleteCaptchaId(http.Context, *CaptchaIdRequest, *CaptchaIdResponse) error -} -type LoginServiceCaptchaImageHooker interface { - PrepareCaptchaImage(http.Context, *CaptchaImageRequest) (context.Context, error) - CompleteCaptchaImage(http.Context, *CaptchaImageRequest, *CaptchaImageResponse) error -} -type LoginServiceLoginHooker interface { - PrepareLogin(http.Context, *LoginRequest) (context.Context, error) - CompleteLogin(http.Context, *LoginRequest, *LoginResponse) error -} -type LoginServiceLogoutHooker interface { - PrepareLogout(http.Context, *LogoutRequest) (context.Context, error) - CompleteLogout(http.Context, *LogoutRequest, *LogoutResponse) error -} -type LoginServiceRegisterHooker interface { - PrepareRegister(http.Context, *RegisterRequest) (context.Context, error) - CompleteRegister(http.Context, *RegisterRequest, *RegisterResponse) error -} -type LoginServiceTokenRefreshHooker interface { - PrepareTokenRefresh(http.Context, *TokenRefreshRequest) (context.Context, error) - CompleteTokenRefresh(http.Context, *TokenRefreshRequest, *TokenRefreshResponse) error -} - -func RegisterLoginServiceBridgeServer(s *http.Server, srv LoginServiceHookedBridger) { - r := s.Route("/") - r.GET("/captcha", _LoginService_Captcha0_Bridge_Handler(srv)) - r.GET("/captcha/id", _LoginService_CaptchaId0_Bridge_Handler(srv)) - r.GET("/captcha/image", _LoginService_CaptchaImage0_Bridge_Handler(srv)) - r.GET("/captcha/audio", _LoginService_CaptchaAudio0_Bridge_Handler(srv)) - r.POST("/login", _LoginService_Login0_Bridge_Handler(srv)) - r.POST("/logout", _LoginService_Logout0_Bridge_Handler(srv)) - r.POST("/register", _LoginService_Register0_Bridge_Handler(srv)) - r.POST("/token/refresh", _LoginService_TokenRefresh0_Bridge_Handler(srv)) -} - -func _LoginService_Captcha0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptcha) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Captcha(ctx, req.(*CaptchaRequest)) - }) - - newctx, err := srv.PrepareCaptcha(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCaptcha(ctx, &in, out.(*CaptchaResponse)) - } -} - -func _LoginService_CaptchaId0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaIdRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaId) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaId(ctx, req.(*CaptchaIdRequest)) - }) - - newctx, err := srv.PrepareCaptchaId(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCaptchaId(ctx, &in, out.(*CaptchaIdResponse)) - } -} - -func _LoginService_CaptchaImage0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaImageRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaImage) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaImage(ctx, req.(*CaptchaImageRequest)) - }) - - newctx, err := srv.PrepareCaptchaImage(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCaptchaImage(ctx, &in, out.(*CaptchaImageResponse)) - } -} - -func _LoginService_CaptchaAudio0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaAudioRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaAudio) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) - }) - - newctx, err := srv.PrepareCaptchaAudio(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCaptchaAudio(ctx, &in, out.(*CaptchaAudioResponse)) - } -} - -func _LoginService_Login0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in LoginRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceLogin) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Login(ctx, req.(*LoginRequest)) - }) - - newctx, err := srv.PrepareLogin(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteLogin(ctx, &in, out.(*LoginResponse)) - } -} - -func _LoginService_Logout0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in LogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Logout(ctx, req.(*LogoutRequest)) - }) - - newctx, err := srv.PrepareLogout(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteLogout(ctx, &in, out.(*LogoutResponse)) - } -} - -func _LoginService_Register0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RegisterRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceRegister) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Register(ctx, req.(*RegisterRequest)) - }) - - newctx, err := srv.PrepareRegister(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteRegister(ctx, &in, out.(*RegisterResponse)) - } -} - -func _LoginService_TokenRefresh0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in TokenRefreshRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceTokenRefresh) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.TokenRefresh(ctx, req.(*TokenRefreshRequest)) - }) - - newctx, err := srv.PrepareTokenRefresh(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteTokenRefresh(ctx, &in, out.(*TokenRefreshResponse)) - } -} - -// UnimplementedLoginServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedLoginServiceHooked struct{} - -func (UnimplementedLoginServiceHooked) PrepareCaptcha(ctx http.Context, in *CaptchaRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteCaptcha(ctx http.Context, in *CaptchaRequest, out *CaptchaResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest, out *CaptchaAudioResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareCaptchaId(ctx http.Context, in *CaptchaIdRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteCaptchaId(ctx http.Context, in *CaptchaIdRequest, out *CaptchaIdResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareCaptchaImage(ctx http.Context, in *CaptchaImageRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteCaptchaImage(ctx http.Context, in *CaptchaImageRequest, out *CaptchaImageResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteLogin(ctx http.Context, in *LoginRequest, out *LoginResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteLogout(ctx http.Context, in *LogoutRequest, out *LogoutResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteRegister(ctx http.Context, in *RegisterRequest, out *RegisterResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareTokenRefresh(ctx http.Context, in *TokenRefreshRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteTokenRefresh(ctx http.Context, in *TokenRefreshRequest, out *TokenRefreshResponse) error { - return ctx.Result(200, out) -} - -func WithLoginServiceHook(h LoginServiceHooker) func(LoginServiceBridgeServer) LoginServiceHookedBridger { - return func(srv LoginServiceBridgeServer) LoginServiceHookedBridger { - return LoginServiceHookedBridge{LoginServiceBridgeServer: srv, LoginServiceHooker: h} - } -} - -// LoginServiceHookedBridge is a bridge between the HTTP and gRPC implementations of LoginService. -// It implements the HTTP and gRPC implementations of LoginService. -// It forwards requests and responses between the two implementations. -type LoginServiceHookedBridge struct { - LoginServiceBridgeServer - LoginServiceHooker -} - -type LoginServiceHTTPBridgeImpl struct { - client LoginServiceHTTPClient -} - -func NewLoginServiceHTTPBridge(client *http.Client) LoginServiceHTTPServer { - return &LoginServiceHTTPBridgeImpl{client: NewLoginServiceHTTPClient(client)} -} - -func (c *LoginServiceHTTPBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { - return c.client.Captcha(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { - return c.client.CaptchaAudio(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { - return c.client.CaptchaId(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { - return c.client.CaptchaImage(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { - return c.client.Logout(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { - return c.client.Register(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { - return c.client.TokenRefresh(ctx, in) -} - -type LoginServiceBridgeImpl struct { - client LoginServiceClient -} - -func NewLoginServiceBridge(client grpc.ClientConnInterface) LoginServiceServer { - return &LoginServiceBridgeImpl{client: NewLoginServiceClient(client)} -} - -func (c *LoginServiceBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { - return c.client.Captcha(ctx, in) -} - -func (c *LoginServiceBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { - return c.client.CaptchaAudio(ctx, in) -} - -func (c *LoginServiceBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { - return c.client.CaptchaId(ctx, in) -} - -func (c *LoginServiceBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { - return c.client.CaptchaImage(ctx, in) -} - -func (c *LoginServiceBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *LoginServiceBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { - return c.client.Logout(ctx, in) -} - -func (c *LoginServiceBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { - return c.client.Register(ctx, in) -} - -func (c *LoginServiceBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { - return c.client.TokenRefresh(ctx, in) -} - -func (c *LoginServiceBridgeImpl) mustEmbedUnimplementedLoginServiceServer() {} - -type LoginServiceGRPC2HTTPBridgeImpl struct { - client LoginServiceClient -} - -func NewLoginServiceGRPC2HTTP(client grpc.ClientConnInterface) LoginServiceHTTPServer { - return &LoginServiceGRPC2HTTPBridgeImpl{client: NewLoginServiceClient(client)} -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { - return c.client.Captcha(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { - return c.client.CaptchaAudio(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { - return c.client.CaptchaId(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { - return c.client.CaptchaImage(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { - return c.client.Logout(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { - return c.client.Register(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { - return c.client.TokenRefresh(ctx, in) -} - -type LoginServiceHTTP2GRPCBridgeImpl struct { - client LoginServiceHTTPClient -} - -func NewLoginServiceHTTP2GRPC(client *http.Client) LoginServiceServer { - return &LoginServiceHTTP2GRPCBridgeImpl{client: NewLoginServiceHTTPClient(client)} -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { - return c.client.Captcha(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { - return c.client.CaptchaAudio(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { - return c.client.CaptchaId(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { - return c.client.CaptchaImage(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { - return c.client.Logout(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { - return c.client.Register(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { - return c.client.TokenRefresh(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedLoginServiceServer() {} diff --git a/api/v1/services/auth/login_grpc.pb.go b/api/v1/services/auth/login_grpc.pb.go deleted file mode 100644 index dbb951a2..00000000 --- a/api/v1/services/auth/login_grpc.pb.go +++ /dev/null @@ -1,391 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: auth/login.proto - -package auth - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - LoginService_Captcha_FullMethodName = "/api.v1.services.auth.LoginService/Captcha" - LoginService_CaptchaId_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaId" - LoginService_CaptchaImage_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaImage" - LoginService_CaptchaAudio_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaAudio" - LoginService_Login_FullMethodName = "/api.v1.services.auth.LoginService/Login" - LoginService_Logout_FullMethodName = "/api.v1.services.auth.LoginService/Logout" - LoginService_Register_FullMethodName = "/api.v1.services.auth.LoginService/Register" - LoginService_TokenRefresh_FullMethodName = "/api.v1.services.auth.LoginService/TokenRefresh" -) - -// LoginServiceClient is the client API for LoginService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The login service definition. -type LoginServiceClient interface { - Captcha(ctx context.Context, in *CaptchaRequest, opts ...grpc.CallOption) (*CaptchaResponse, error) - CaptchaId(ctx context.Context, in *CaptchaIdRequest, opts ...grpc.CallOption) (*CaptchaIdResponse, error) - CaptchaImage(ctx context.Context, in *CaptchaImageRequest, opts ...grpc.CallOption) (*CaptchaImageResponse, error) - CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest, opts ...grpc.CallOption) (*CaptchaAudioResponse, error) - Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) - Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) - Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) - TokenRefresh(ctx context.Context, in *TokenRefreshRequest, opts ...grpc.CallOption) (*TokenRefreshResponse, error) -} - -type loginServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewLoginServiceClient(cc grpc.ClientConnInterface) LoginServiceClient { - return &loginServiceClient{cc} -} - -func (c *loginServiceClient) Captcha(ctx context.Context, in *CaptchaRequest, opts ...grpc.CallOption) (*CaptchaResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CaptchaResponse) - err := c.cc.Invoke(ctx, LoginService_Captcha_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) CaptchaId(ctx context.Context, in *CaptchaIdRequest, opts ...grpc.CallOption) (*CaptchaIdResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CaptchaIdResponse) - err := c.cc.Invoke(ctx, LoginService_CaptchaId_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) CaptchaImage(ctx context.Context, in *CaptchaImageRequest, opts ...grpc.CallOption) (*CaptchaImageResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CaptchaImageResponse) - err := c.cc.Invoke(ctx, LoginService_CaptchaImage_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest, opts ...grpc.CallOption) (*CaptchaAudioResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CaptchaAudioResponse) - err := c.cc.Invoke(ctx, LoginService_CaptchaAudio_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(LoginResponse) - err := c.cc.Invoke(ctx, LoginService_Login_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(LogoutResponse) - err := c.cc.Invoke(ctx, LoginService_Logout_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(RegisterResponse) - err := c.cc.Invoke(ctx, LoginService_Register_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) TokenRefresh(ctx context.Context, in *TokenRefreshRequest, opts ...grpc.CallOption) (*TokenRefreshResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(TokenRefreshResponse) - err := c.cc.Invoke(ctx, LoginService_TokenRefresh_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// LoginServiceServer is the server API for LoginService service. -// All implementations must embed UnimplementedLoginServiceServer -// for forward compatibility. -// -// The login service definition. -type LoginServiceServer interface { - Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) - CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) - CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) - CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) - Login(context.Context, *LoginRequest) (*LoginResponse, error) - Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) - Register(context.Context, *RegisterRequest) (*RegisterResponse, error) - TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) - mustEmbedUnimplementedLoginServiceServer() -} - -// UnimplementedLoginServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedLoginServiceServer struct{} - -func (UnimplementedLoginServiceServer) Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Captcha not implemented") -} -func (UnimplementedLoginServiceServer) CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CaptchaId not implemented") -} -func (UnimplementedLoginServiceServer) CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CaptchaImage not implemented") -} -func (UnimplementedLoginServiceServer) CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CaptchaAudio not implemented") -} -func (UnimplementedLoginServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") -} -func (UnimplementedLoginServiceServer) Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented") -} -func (UnimplementedLoginServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") -} -func (UnimplementedLoginServiceServer) TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method TokenRefresh not implemented") -} -func (UnimplementedLoginServiceServer) mustEmbedUnimplementedLoginServiceServer() {} -func (UnimplementedLoginServiceServer) testEmbeddedByValue() {} - -// UnsafeLoginServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to LoginServiceServer will -// result in compilation errors. -type UnsafeLoginServiceServer interface { - mustEmbedUnimplementedLoginServiceServer() -} - -func RegisterLoginServiceServer(s grpc.ServiceRegistrar, srv LoginServiceServer) { - // If the following call pancis, it indicates UnimplementedLoginServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&LoginService_ServiceDesc, srv) -} - -func _LoginService_Captcha_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CaptchaRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).Captcha(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_Captcha_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).Captcha(ctx, req.(*CaptchaRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_CaptchaId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CaptchaIdRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).CaptchaId(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_CaptchaId_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).CaptchaId(ctx, req.(*CaptchaIdRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_CaptchaImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CaptchaImageRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).CaptchaImage(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_CaptchaImage_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).CaptchaImage(ctx, req.(*CaptchaImageRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_CaptchaAudio_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CaptchaAudioRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).CaptchaAudio(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_CaptchaAudio_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LoginRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).Login(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_Login_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).Login(ctx, req.(*LoginRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LogoutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).Logout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_Logout_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).Logout(ctx, req.(*LogoutRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RegisterRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).Register(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_Register_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).Register(ctx, req.(*RegisterRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_TokenRefresh_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TokenRefreshRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).TokenRefresh(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_TokenRefresh_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).TokenRefresh(ctx, req.(*TokenRefreshRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// LoginService_ServiceDesc is the grpc.ServiceDesc for LoginService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var LoginService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.auth.LoginService", - HandlerType: (*LoginServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Captcha", - Handler: _LoginService_Captcha_Handler, - }, - { - MethodName: "CaptchaId", - Handler: _LoginService_CaptchaId_Handler, - }, - { - MethodName: "CaptchaImage", - Handler: _LoginService_CaptchaImage_Handler, - }, - { - MethodName: "CaptchaAudio", - Handler: _LoginService_CaptchaAudio_Handler, - }, - { - MethodName: "Login", - Handler: _LoginService_Login_Handler, - }, - { - MethodName: "Logout", - Handler: _LoginService_Logout_Handler, - }, - { - MethodName: "Register", - Handler: _LoginService_Register_Handler, - }, - { - MethodName: "TokenRefresh", - Handler: _LoginService_TokenRefresh_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "auth/login.proto", -} diff --git a/api/v1/services/auth/login_http.pb.go b/api/v1/services/auth/login_http.pb.go deleted file mode 100644 index cd24ca67..00000000 --- a/api/v1/services/auth/login_http.pb.go +++ /dev/null @@ -1,339 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: auth/login.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationLoginServiceCaptcha = "/api.v1.services.auth.LoginService/Captcha" -const OperationLoginServiceCaptchaAudio = "/api.v1.services.auth.LoginService/CaptchaAudio" -const OperationLoginServiceCaptchaId = "/api.v1.services.auth.LoginService/CaptchaId" -const OperationLoginServiceCaptchaImage = "/api.v1.services.auth.LoginService/CaptchaImage" -const OperationLoginServiceLogin = "/api.v1.services.auth.LoginService/Login" -const OperationLoginServiceLogout = "/api.v1.services.auth.LoginService/Logout" -const OperationLoginServiceRegister = "/api.v1.services.auth.LoginService/Register" -const OperationLoginServiceTokenRefresh = "/api.v1.services.auth.LoginService/TokenRefresh" - -type LoginServiceHTTPServer interface { - Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) - CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) - CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) - CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) - Login(context.Context, *LoginRequest) (*LoginResponse, error) - Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) - Register(context.Context, *RegisterRequest) (*RegisterResponse, error) - TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) -} - -func RegisterLoginServiceHTTPServer(s *http.Server, srv LoginServiceHTTPServer) { - r := s.Route("/") - r.GET("/captcha", _LoginService_Captcha0_HTTP_Handler(srv)) - r.GET("/captcha/id", _LoginService_CaptchaId0_HTTP_Handler(srv)) - r.GET("/captcha/image", _LoginService_CaptchaImage0_HTTP_Handler(srv)) - r.GET("/captcha/audio", _LoginService_CaptchaAudio0_HTTP_Handler(srv)) - r.POST("/login", _LoginService_Login0_HTTP_Handler(srv)) - r.POST("/logout", _LoginService_Logout0_HTTP_Handler(srv)) - r.POST("/register", _LoginService_Register0_HTTP_Handler(srv)) - r.POST("/token/refresh", _LoginService_TokenRefresh0_HTTP_Handler(srv)) -} - -func _LoginService_Captcha0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptcha) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Captcha(ctx, req.(*CaptchaRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_CaptchaId0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaIdRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaId) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaId(ctx, req.(*CaptchaIdRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaIdResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_CaptchaImage0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaImageRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaImage) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaImage(ctx, req.(*CaptchaImageRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaImageResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_CaptchaAudio0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaAudioRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaAudio) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaAudioResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_Login0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in LoginRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceLogin) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Login(ctx, req.(*LoginRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*LoginResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_Logout0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in LogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Logout(ctx, req.(*LogoutRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*LogoutResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_Register0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RegisterRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceRegister) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Register(ctx, req.(*RegisterRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*RegisterResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_TokenRefresh0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in TokenRefreshRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceTokenRefresh) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.TokenRefresh(ctx, req.(*TokenRefreshRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*TokenRefreshResponse) - return ctx.Result(200, reply) - } -} - -type LoginServiceHTTPClient interface { - Captcha(ctx context.Context, req *CaptchaRequest, opts ...http.CallOption) (rsp *CaptchaResponse, err error) - CaptchaAudio(ctx context.Context, req *CaptchaAudioRequest, opts ...http.CallOption) (rsp *CaptchaAudioResponse, err error) - CaptchaId(ctx context.Context, req *CaptchaIdRequest, opts ...http.CallOption) (rsp *CaptchaIdResponse, err error) - CaptchaImage(ctx context.Context, req *CaptchaImageRequest, opts ...http.CallOption) (rsp *CaptchaImageResponse, err error) - Login(ctx context.Context, req *LoginRequest, opts ...http.CallOption) (rsp *LoginResponse, err error) - Logout(ctx context.Context, req *LogoutRequest, opts ...http.CallOption) (rsp *LogoutResponse, err error) - Register(ctx context.Context, req *RegisterRequest, opts ...http.CallOption) (rsp *RegisterResponse, err error) - TokenRefresh(ctx context.Context, req *TokenRefreshRequest, opts ...http.CallOption) (rsp *TokenRefreshResponse, err error) -} - -type LoginServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewLoginServiceHTTPClient(client *http.Client) LoginServiceHTTPClient { - return &LoginServiceHTTPClientImpl{client} -} - -func (c *LoginServiceHTTPClientImpl) Captcha(ctx context.Context, in *CaptchaRequest, opts ...http.CallOption) (*CaptchaResponse, error) { - var out CaptchaResponse - pattern := "/captcha" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationLoginServiceCaptcha)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest, opts ...http.CallOption) (*CaptchaAudioResponse, error) { - var out CaptchaAudioResponse - pattern := "/captcha/audio" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationLoginServiceCaptchaAudio)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest, opts ...http.CallOption) (*CaptchaIdResponse, error) { - var out CaptchaIdResponse - pattern := "/captcha/id" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationLoginServiceCaptchaId)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest, opts ...http.CallOption) (*CaptchaImageResponse, error) { - var out CaptchaImageResponse - pattern := "/captcha/image" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationLoginServiceCaptchaImage)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) Login(ctx context.Context, in *LoginRequest, opts ...http.CallOption) (*LoginResponse, error) { - var out LoginResponse - pattern := "/login" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationLoginServiceLogin)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) Logout(ctx context.Context, in *LogoutRequest, opts ...http.CallOption) (*LogoutResponse, error) { - var out LogoutResponse - pattern := "/logout" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationLoginServiceLogout)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) Register(ctx context.Context, in *RegisterRequest, opts ...http.CallOption) (*RegisterResponse, error) { - var out RegisterResponse - pattern := "/register" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationLoginServiceRegister)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest, opts ...http.CallOption) (*TokenRefreshResponse, error) { - var out TokenRefreshResponse - pattern := "/token/refresh" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationLoginServiceTokenRefresh)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/auth/personal.pb.go b/api/v1/services/auth/personal.pb.go deleted file mode 100644 index 5d73ceaf..00000000 --- a/api/v1/services/auth/personal.pb.go +++ /dev/null @@ -1,1074 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: auth/personal.proto - -package auth - -import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type UpdatePersonalSettingRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalSettingRequest) Reset() { - *x = UpdatePersonalSettingRequest{} - mi := &file_auth_personal_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalSettingRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalSettingRequest) ProtoMessage() {} - -func (x *UpdatePersonalSettingRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[0] - 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 UpdatePersonalSettingRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalSettingRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{0} -} - -func (x *UpdatePersonalSettingRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalSettingResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalSettingResponse) Reset() { - *x = UpdatePersonalSettingResponse{} - mi := &file_auth_personal_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalSettingResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalSettingResponse) ProtoMessage() {} - -func (x *UpdatePersonalSettingResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[1] - 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 UpdatePersonalSettingResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalSettingResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{1} -} - -type UpdatePersonalRoleRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalRoleRequest) Reset() { - *x = UpdatePersonalRoleRequest{} - mi := &file_auth_personal_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalRoleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalRoleRequest) ProtoMessage() {} - -func (x *UpdatePersonalRoleRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[2] - 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 UpdatePersonalRoleRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalRoleRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{2} -} - -func (x *UpdatePersonalRoleRequest) GetRole() *types.Role { - if x != nil { - return x.Role - } - return nil -} - -type UpdatePersonalRoleResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalRoleResponse) Reset() { - *x = UpdatePersonalRoleResponse{} - mi := &file_auth_personal_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalRoleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalRoleResponse) ProtoMessage() {} - -func (x *UpdatePersonalRoleResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[3] - 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 UpdatePersonalRoleResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalRoleResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{3} -} - -type ListPersonalResourcesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalResourcesRequest) Reset() { - *x = ListPersonalResourcesRequest{} - mi := &file_auth_personal_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalResourcesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalResourcesRequest) ProtoMessage() {} - -func (x *ListPersonalResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[4] - 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 ListPersonalResourcesRequest.ProtoReflect.Descriptor instead. -func (*ListPersonalResourcesRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{4} -} - -func (x *ListPersonalResourcesRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListPersonalResourcesRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListPersonalResourcesRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -type ListPersonalResourcesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int64 `protobuf:"varint,1,opt,name=total_size,json=total,proto3" json:"total_size,omitempty"` - // list of resources - Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalResourcesResponse) Reset() { - *x = ListPersonalResourcesResponse{} - mi := &file_auth_personal_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalResourcesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalResourcesResponse) ProtoMessage() {} - -func (x *ListPersonalResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[5] - 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 ListPersonalResourcesResponse.ProtoReflect.Descriptor instead. -func (*ListPersonalResourcesResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{5} -} - -func (x *ListPersonalResourcesResponse) GetTotalSize() int64 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListPersonalResourcesResponse) GetResources() []*types.Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *ListPersonalResourcesResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -type UpdatePersonalPasswordRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalPasswordRequest) Reset() { - *x = UpdatePersonalPasswordRequest{} - mi := &file_auth_personal_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalPasswordRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalPasswordRequest) ProtoMessage() {} - -func (x *UpdatePersonalPasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_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 UpdatePersonalPasswordRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalPasswordRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdatePersonalPasswordRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalPasswordResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalPasswordResponse) Reset() { - *x = UpdatePersonalPasswordResponse{} - mi := &file_auth_personal_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalPasswordResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalPasswordResponse) ProtoMessage() {} - -func (x *UpdatePersonalPasswordResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdatePersonalPasswordResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalPasswordResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{7} -} - -type PersonalPasswordRestRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalPasswordRestRequest) Reset() { - *x = PersonalPasswordRestRequest{} - mi := &file_auth_personal_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalPasswordRestRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalPasswordRestRequest) ProtoMessage() {} - -func (x *PersonalPasswordRestRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[8] - 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 PersonalPasswordRestRequest.ProtoReflect.Descriptor instead. -func (*PersonalPasswordRestRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{8} -} - -func (x *PersonalPasswordRestRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type PersonalPasswordRestResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalPasswordRestResponse) Reset() { - *x = PersonalPasswordRestResponse{} - mi := &file_auth_personal_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalPasswordRestResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalPasswordRestResponse) ProtoMessage() {} - -func (x *PersonalPasswordRestResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[9] - 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 PersonalPasswordRestResponse.ProtoReflect.Descriptor instead. -func (*PersonalPasswordRestResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{9} -} - -type UpdatePersonalProfileRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalProfileRequest) Reset() { - *x = UpdatePersonalProfileRequest{} - mi := &file_auth_personal_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalProfileRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalProfileRequest) ProtoMessage() {} - -func (x *UpdatePersonalProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[10] - 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 UpdatePersonalProfileRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalProfileRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{10} -} - -func (x *UpdatePersonalProfileRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalProfileResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalProfileResponse) Reset() { - *x = UpdatePersonalProfileResponse{} - mi := &file_auth_personal_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalProfileResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalProfileResponse) ProtoMessage() {} - -func (x *UpdatePersonalProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[11] - 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 UpdatePersonalProfileResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalProfileResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{11} -} - -type PersonalLogoutRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalLogoutRequest) Reset() { - *x = PersonalLogoutRequest{} - mi := &file_auth_personal_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalLogoutRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalLogoutRequest) ProtoMessage() {} - -func (x *PersonalLogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[12] - 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 PersonalLogoutRequest.ProtoReflect.Descriptor instead. -func (*PersonalLogoutRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{12} -} - -func (x *PersonalLogoutRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type PersonalLogoutResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalLogoutResponse) Reset() { - *x = PersonalLogoutResponse{} - mi := &file_auth_personal_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalLogoutResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalLogoutResponse) ProtoMessage() {} - -func (x *PersonalLogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[13] - 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 PersonalLogoutResponse.ProtoReflect.Descriptor instead. -func (*PersonalLogoutResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{13} -} - -func (x *PersonalLogoutResponse) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -type ListPersonalRolesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalRolesRequest) Reset() { - *x = ListPersonalRolesRequest{} - mi := &file_auth_personal_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalRolesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalRolesRequest) ProtoMessage() {} - -func (x *ListPersonalRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[14] - 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 ListPersonalRolesRequest.ProtoReflect.Descriptor instead. -func (*ListPersonalRolesRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{14} -} - -type ListPersonalRolesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Roles []*types.Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalRolesResponse) Reset() { - *x = ListPersonalRolesResponse{} - mi := &file_auth_personal_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalRolesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalRolesResponse) ProtoMessage() {} - -func (x *ListPersonalRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[15] - 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 ListPersonalRolesResponse.ProtoReflect.Descriptor instead. -func (*ListPersonalRolesResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{15} -} - -func (x *ListPersonalRolesResponse) GetRoles() []*types.Role { - if x != nil { - return x.Roles - } - return nil -} - -type GetPersonalProfileRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPersonalProfileRequest) Reset() { - *x = GetPersonalProfileRequest{} - mi := &file_auth_personal_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPersonalProfileRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPersonalProfileRequest) ProtoMessage() {} - -func (x *GetPersonalProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[16] - 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 GetPersonalProfileRequest.ProtoReflect.Descriptor instead. -func (*GetPersonalProfileRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{16} -} - -type GetPersonalProfileResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPersonalProfileResponse) Reset() { - *x = GetPersonalProfileResponse{} - mi := &file_auth_personal_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPersonalProfileResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPersonalProfileResponse) ProtoMessage() {} - -func (x *GetPersonalProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[17] - 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 GetPersonalProfileResponse.ProtoReflect.Descriptor instead. -func (*GetPersonalProfileResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{17} -} - -func (x *GetPersonalProfileResponse) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -type RefreshPersonalTokenRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RefreshPersonalTokenRequest) Reset() { - *x = RefreshPersonalTokenRequest{} - mi := &file_auth_personal_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RefreshPersonalTokenRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RefreshPersonalTokenRequest) ProtoMessage() {} - -func (x *RefreshPersonalTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[18] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RefreshPersonalTokenRequest.ProtoReflect.Descriptor instead. -func (*RefreshPersonalTokenRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{18} -} - -func (x *RefreshPersonalTokenRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type RefreshPersonalTokenResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RefreshPersonalTokenResponse) Reset() { - *x = RefreshPersonalTokenResponse{} - mi := &file_auth_personal_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RefreshPersonalTokenResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RefreshPersonalTokenResponse) ProtoMessage() {} - -func (x *RefreshPersonalTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RefreshPersonalTokenResponse.ProtoReflect.Descriptor instead. -func (*RefreshPersonalTokenResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{19} -} - -func (x *RefreshPersonalTokenResponse) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -var File_auth_personal_proto protoreflect.FileDescriptor - -const file_auth_personal_proto_rawDesc = "" + - "\n" + - "\x13auth/personal.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12types/system.proto\x1a\x17validate/validate.proto\"H\n" + - "\x1cUpdatePersonalSettingRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + - "\x1dUpdatePersonalSettingResponse\"L\n" + - "\x19UpdatePersonalRoleRequest\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\x1c\n" + - "\x1aUpdatePersonalRoleResponse\"\xc4\x01\n" + - "\x1cListPersonalResourcesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\xa3\x01\n" + - "\x1dListPersonalResourcesResponse\x12\x19\n" + - "\n" + - "total_size\x18\x01 \x01(\x03R\x05total\x12=\n" + - "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\"I\n" + - "\x1dUpdatePersonalPasswordRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\" \n" + - "\x1eUpdatePersonalPasswordResponse\"6\n" + - "\x1bPersonalPasswordRestRequest\x12\x17\n" + - "\x02id\x18\x01 \x01(\x03B\a\xfaB\x04\"\x02 \x00R\x02id\"\x1e\n" + - "\x1cPersonalPasswordRestResponse\"H\n" + - "\x1cUpdatePersonalProfileRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + - "\x1dUpdatePersonalProfileResponse\"A\n" + - "\x15PersonalLogoutRequest\x12(\n" + - "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"2\n" + - "\x16PersonalLogoutResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\"\x1a\n" + - "\x18ListPersonalRolesRequest\"N\n" + - "\x19ListPersonalRolesResponse\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x1b\n" + - "\x19GetPersonalProfileRequest\"M\n" + - "\x1aGetPersonalProfileResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + - "\x1bRefreshPersonalTokenRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"4\n" + - "\x1cRefreshPersonalTokenResponse\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token2\xa3\n" + - "\n" + - "\x0fPersonalService\x12\x97\x01\n" + - "\x12GetPersonalProfile\x12/.api.v1.services.auth.GetPersonalProfileRequest\x1a0.api.v1.services.auth.GetPersonalProfileResponse\"\x1e\x82\xd3\xe4\x93\x02\x18\x12\x16/auth/personal/profile\x12\xa2\x01\n" + - "\x15ListPersonalResources\x122.api.v1.services.auth.ListPersonalResourcesRequest\x1a3.api.v1.services.auth.ListPersonalResourcesResponse\" \x82\xd3\xe4\x93\x02\x1a\x12\x18/auth/personal/resources\x12\x92\x01\n" + - "\x11ListPersonalRoles\x12..api.v1.services.auth.ListPersonalRolesRequest\x1a/.api.v1.services.auth.ListPersonalRolesResponse\"\x1c\x82\xd3\xe4\x93\x02\x16\x12\x14/auth/personal/roles\x12\x90\x01\n" + - "\x0ePersonalLogout\x12+.api.v1.services.auth.PersonalLogoutRequest\x1a,.api.v1.services.auth.PersonalLogoutResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\"\x15/auth/personal/logout\x12\xa9\x01\n" + - "\x14RefreshPersonalToken\x121.api.v1.services.auth.RefreshPersonalTokenRequest\x1a2.api.v1.services.auth.RefreshPersonalTokenResponse\"*\x82\xd3\xe4\x93\x02$:\x04data\"\x1c/auth/personal/token/refresh\x12\xaa\x01\n" + - "\x16UpdatePersonalPassword\x123.api.v1.services.auth.UpdatePersonalPasswordRequest\x1a4.api.v1.services.auth.UpdatePersonalPasswordResponse\"%\x82\xd3\xe4\x93\x02\x1f:\x04data\x1a\x17/auth/personal/password\x12\xa6\x01\n" + - "\x15UpdatePersonalProfile\x122.api.v1.services.auth.UpdatePersonalProfileRequest\x1a3.api.v1.services.auth.UpdatePersonalProfileResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/profile\x12\xa6\x01\n" + - "\x15UpdatePersonalSetting\x122.api.v1.services.auth.UpdatePersonalSettingRequest\x1a3.api.v1.services.auth.UpdatePersonalSettingResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/settingB\xd4\x01\n" + - "\x18com.api.v1.services.authB\rPersonalProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" - -var ( - file_auth_personal_proto_rawDescOnce sync.Once - file_auth_personal_proto_rawDescData []byte -) - -func file_auth_personal_proto_rawDescGZIP() []byte { - file_auth_personal_proto_rawDescOnce.Do(func() { - file_auth_personal_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_personal_proto_rawDesc), len(file_auth_personal_proto_rawDesc))) - }) - return file_auth_personal_proto_rawDescData -} - -var file_auth_personal_proto_msgTypes = make([]protoimpl.MessageInfo, 20) -var file_auth_personal_proto_goTypes = []any{ - (*UpdatePersonalSettingRequest)(nil), // 0: api.v1.services.auth.UpdatePersonalSettingRequest - (*UpdatePersonalSettingResponse)(nil), // 1: api.v1.services.auth.UpdatePersonalSettingResponse - (*UpdatePersonalRoleRequest)(nil), // 2: api.v1.services.auth.UpdatePersonalRoleRequest - (*UpdatePersonalRoleResponse)(nil), // 3: api.v1.services.auth.UpdatePersonalRoleResponse - (*ListPersonalResourcesRequest)(nil), // 4: api.v1.services.auth.ListPersonalResourcesRequest - (*ListPersonalResourcesResponse)(nil), // 5: api.v1.services.auth.ListPersonalResourcesResponse - (*UpdatePersonalPasswordRequest)(nil), // 6: api.v1.services.auth.UpdatePersonalPasswordRequest - (*UpdatePersonalPasswordResponse)(nil), // 7: api.v1.services.auth.UpdatePersonalPasswordResponse - (*PersonalPasswordRestRequest)(nil), // 8: api.v1.services.auth.PersonalPasswordRestRequest - (*PersonalPasswordRestResponse)(nil), // 9: api.v1.services.auth.PersonalPasswordRestResponse - (*UpdatePersonalProfileRequest)(nil), // 10: api.v1.services.auth.UpdatePersonalProfileRequest - (*UpdatePersonalProfileResponse)(nil), // 11: api.v1.services.auth.UpdatePersonalProfileResponse - (*PersonalLogoutRequest)(nil), // 12: api.v1.services.auth.PersonalLogoutRequest - (*PersonalLogoutResponse)(nil), // 13: api.v1.services.auth.PersonalLogoutResponse - (*ListPersonalRolesRequest)(nil), // 14: api.v1.services.auth.ListPersonalRolesRequest - (*ListPersonalRolesResponse)(nil), // 15: api.v1.services.auth.ListPersonalRolesResponse - (*GetPersonalProfileRequest)(nil), // 16: api.v1.services.auth.GetPersonalProfileRequest - (*GetPersonalProfileResponse)(nil), // 17: api.v1.services.auth.GetPersonalProfileResponse - (*RefreshPersonalTokenRequest)(nil), // 18: api.v1.services.auth.RefreshPersonalTokenRequest - (*RefreshPersonalTokenResponse)(nil), // 19: api.v1.services.auth.RefreshPersonalTokenResponse - (*anypb.Any)(nil), // 20: google.protobuf.Any - (*types.Role)(nil), // 21: api.v1.services.types.Role - (*types.Resource)(nil), // 22: api.v1.services.types.Resource - (*types.User)(nil), // 23: api.v1.services.types.User -} -var file_auth_personal_proto_depIdxs = []int32{ - 20, // 0: api.v1.services.auth.UpdatePersonalSettingRequest.data:type_name -> google.protobuf.Any - 21, // 1: api.v1.services.auth.UpdatePersonalRoleRequest.role:type_name -> api.v1.services.types.Role - 22, // 2: api.v1.services.auth.ListPersonalResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 20, // 3: api.v1.services.auth.UpdatePersonalPasswordRequest.data:type_name -> google.protobuf.Any - 20, // 4: api.v1.services.auth.UpdatePersonalProfileRequest.data:type_name -> google.protobuf.Any - 20, // 5: api.v1.services.auth.PersonalLogoutRequest.data:type_name -> google.protobuf.Any - 21, // 6: api.v1.services.auth.ListPersonalRolesResponse.roles:type_name -> api.v1.services.types.Role - 23, // 7: api.v1.services.auth.GetPersonalProfileResponse.user:type_name -> api.v1.services.types.User - 20, // 8: api.v1.services.auth.RefreshPersonalTokenRequest.data:type_name -> google.protobuf.Any - 16, // 9: api.v1.services.auth.PersonalService.GetPersonalProfile:input_type -> api.v1.services.auth.GetPersonalProfileRequest - 4, // 10: api.v1.services.auth.PersonalService.ListPersonalResources:input_type -> api.v1.services.auth.ListPersonalResourcesRequest - 14, // 11: api.v1.services.auth.PersonalService.ListPersonalRoles:input_type -> api.v1.services.auth.ListPersonalRolesRequest - 12, // 12: api.v1.services.auth.PersonalService.PersonalLogout:input_type -> api.v1.services.auth.PersonalLogoutRequest - 18, // 13: api.v1.services.auth.PersonalService.RefreshPersonalToken:input_type -> api.v1.services.auth.RefreshPersonalTokenRequest - 6, // 14: api.v1.services.auth.PersonalService.UpdatePersonalPassword:input_type -> api.v1.services.auth.UpdatePersonalPasswordRequest - 10, // 15: api.v1.services.auth.PersonalService.UpdatePersonalProfile:input_type -> api.v1.services.auth.UpdatePersonalProfileRequest - 0, // 16: api.v1.services.auth.PersonalService.UpdatePersonalSetting:input_type -> api.v1.services.auth.UpdatePersonalSettingRequest - 17, // 17: api.v1.services.auth.PersonalService.GetPersonalProfile:output_type -> api.v1.services.auth.GetPersonalProfileResponse - 5, // 18: api.v1.services.auth.PersonalService.ListPersonalResources:output_type -> api.v1.services.auth.ListPersonalResourcesResponse - 15, // 19: api.v1.services.auth.PersonalService.ListPersonalRoles:output_type -> api.v1.services.auth.ListPersonalRolesResponse - 13, // 20: api.v1.services.auth.PersonalService.PersonalLogout:output_type -> api.v1.services.auth.PersonalLogoutResponse - 19, // 21: api.v1.services.auth.PersonalService.RefreshPersonalToken:output_type -> api.v1.services.auth.RefreshPersonalTokenResponse - 7, // 22: api.v1.services.auth.PersonalService.UpdatePersonalPassword:output_type -> api.v1.services.auth.UpdatePersonalPasswordResponse - 11, // 23: api.v1.services.auth.PersonalService.UpdatePersonalProfile:output_type -> api.v1.services.auth.UpdatePersonalProfileResponse - 1, // 24: api.v1.services.auth.PersonalService.UpdatePersonalSetting:output_type -> api.v1.services.auth.UpdatePersonalSettingResponse - 17, // [17:25] is the sub-list for method output_type - 9, // [9:17] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name -} - -func init() { file_auth_personal_proto_init() } -func file_auth_personal_proto_init() { - if File_auth_personal_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_personal_proto_rawDesc), len(file_auth_personal_proto_rawDesc)), - NumEnums: 0, - NumMessages: 20, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_auth_personal_proto_goTypes, - DependencyIndexes: file_auth_personal_proto_depIdxs, - MessageInfos: file_auth_personal_proto_msgTypes, - }.Build() - File_auth_personal_proto = out.File - file_auth_personal_proto_goTypes = nil - file_auth_personal_proto_depIdxs = nil -} diff --git a/api/v1/services/auth/personal.pb.gw.go b/api/v1/services/auth/personal.pb.gw.go deleted file mode 100644 index fb8ce2cc..00000000 --- a/api/v1/services/auth/personal.pb.gw.go +++ /dev/null @@ -1,594 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: auth/personal.proto - -/* -Package auth is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package auth - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -func request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPersonalProfileRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.GetPersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPersonalProfileRequest - metadata runtime.ServerMetadata - ) - msg, err := server.GetPersonalProfile(ctx, &protoReq) - return msg, metadata, err -} - -var filter_PersonalService_ListPersonalResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalResourcesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListPersonalResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalResourcesRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListPersonalResources(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalRolesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.ListPersonalRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalRolesRequest - metadata runtime.ServerMetadata - ) - msg, err := server.ListPersonalRoles(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq PersonalLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.PersonalLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq PersonalLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.PersonalLogout(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RefreshPersonalTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.RefreshPersonalToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RefreshPersonalTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.RefreshPersonalToken(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalPasswordRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalPasswordRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalPassword(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalProfileRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalProfileRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalProfile(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalSettingRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalSetting(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalSettingRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalSetting(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterPersonalServiceHandlerServer registers the http handlers for service PersonalService to "mux". -// UnaryRPC :call PersonalServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPersonalServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterPersonalServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PersonalServiceServer) error { - mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/auth/personal/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/auth/personal/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/auth/personal/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/auth/personal/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/auth/personal/password")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/auth/personal/setting")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterPersonalServiceHandlerFromEndpoint is same as RegisterPersonalServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterPersonalServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterPersonalServiceHandler(ctx, mux, conn) -} - -// RegisterPersonalServiceHandler registers the http handlers for service PersonalService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterPersonalServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterPersonalServiceHandlerClient(ctx, mux, NewPersonalServiceClient(conn)) -} - -// RegisterPersonalServiceHandlerClient registers the http handlers for service PersonalService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PersonalServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PersonalServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "PersonalServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterPersonalServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PersonalServiceClient) error { - mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/auth/personal/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/auth/personal/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/auth/personal/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/auth/personal/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/auth/personal/password")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/auth/personal/setting")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_PersonalService_GetPersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "profile"}, "")) - pattern_PersonalService_ListPersonalResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "resources"}, "")) - pattern_PersonalService_ListPersonalRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "roles"}, "")) - pattern_PersonalService_PersonalLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "logout"}, "")) - pattern_PersonalService_RefreshPersonalToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"auth", "personal", "token", "refresh"}, "")) - pattern_PersonalService_UpdatePersonalPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "password"}, "")) - pattern_PersonalService_UpdatePersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "profile"}, "")) - pattern_PersonalService_UpdatePersonalSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "setting"}, "")) -) - -var ( - forward_PersonalService_GetPersonalProfile_0 = runtime.ForwardResponseMessage - forward_PersonalService_ListPersonalResources_0 = runtime.ForwardResponseMessage - forward_PersonalService_ListPersonalRoles_0 = runtime.ForwardResponseMessage - forward_PersonalService_PersonalLogout_0 = runtime.ForwardResponseMessage - forward_PersonalService_RefreshPersonalToken_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalPassword_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalProfile_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalSetting_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/auth/personal.pb.validate.go b/api/v1/services/auth/personal.pb.validate.go deleted file mode 100644 index 92933952..00000000 --- a/api/v1/services/auth/personal.pb.validate.go +++ /dev/null @@ -1,2390 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: auth/personal.proto - -package auth - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on UpdatePersonalSettingRequest 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 *UpdatePersonalSettingRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalSettingRequest 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 -// UpdatePersonalSettingRequestMultiError, or nil if none found. -func (m *UpdatePersonalSettingRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalSettingRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalSettingRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalSettingRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalSettingRequest.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalSettingRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalSettingRequestMultiError) 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 UpdatePersonalSettingRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalSettingRequestValidationError is the validation error returned -// by UpdatePersonalSettingRequest.Validate if the designated constraints -// aren't met. -type UpdatePersonalSettingRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalSettingRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalSettingRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalSettingRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalSettingRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalSettingRequestValidationError) ErrorName() string { - return "UpdatePersonalSettingRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalSettingRequestValidationError) 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 %sUpdatePersonalSettingRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalSettingRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalSettingRequestValidationError{} - -// Validate checks the field values on UpdatePersonalSettingResponse 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 *UpdatePersonalSettingResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalSettingResponse 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 -// UpdatePersonalSettingResponseMultiError, or nil if none found. -func (m *UpdatePersonalSettingResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalSettingResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalSettingResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalSettingResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalSettingResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalSettingResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalSettingResponseMultiError) 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 UpdatePersonalSettingResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalSettingResponseValidationError is the validation error -// returned by UpdatePersonalSettingResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalSettingResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalSettingResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalSettingResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalSettingResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalSettingResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalSettingResponseValidationError) ErrorName() string { - return "UpdatePersonalSettingResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalSettingResponseValidationError) 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 %sUpdatePersonalSettingResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalSettingResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalSettingResponseValidationError{} - -// Validate checks the field values on UpdatePersonalRoleRequest 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 *UpdatePersonalRoleRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalRoleRequest 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 -// UpdatePersonalRoleRequestMultiError, or nil if none found. -func (m *UpdatePersonalRoleRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalRoleRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalRoleRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalRoleRequestMultiError is an error wrapping multiple validation -// errors returned by UpdatePersonalRoleRequest.ValidateAll() if the -// designated constraints aren't met. -type UpdatePersonalRoleRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalRoleRequestMultiError) 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 UpdatePersonalRoleRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalRoleRequestValidationError is the validation error returned by -// UpdatePersonalRoleRequest.Validate if the designated constraints aren't met. -type UpdatePersonalRoleRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalRoleRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalRoleRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalRoleRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalRoleRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalRoleRequestValidationError) ErrorName() string { - return "UpdatePersonalRoleRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalRoleRequestValidationError) 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 %sUpdatePersonalRoleRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalRoleRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalRoleRequestValidationError{} - -// Validate checks the field values on UpdatePersonalRoleResponse 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 *UpdatePersonalRoleResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalRoleResponse 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 -// UpdatePersonalRoleResponseMultiError, or nil if none found. -func (m *UpdatePersonalRoleResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalRoleResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalRoleResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalRoleResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalRoleResponse.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalRoleResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalRoleResponseMultiError) 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 UpdatePersonalRoleResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalRoleResponseValidationError is the validation error returned -// by UpdatePersonalRoleResponse.Validate if the designated constraints aren't met. -type UpdatePersonalRoleResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalRoleResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalRoleResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalRoleResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalRoleResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalRoleResponseValidationError) ErrorName() string { - return "UpdatePersonalRoleResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalRoleResponseValidationError) 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 %sUpdatePersonalRoleResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalRoleResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalRoleResponseValidationError{} - -// Validate checks the field values on ListPersonalResourcesRequest 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 *ListPersonalResourcesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalResourcesRequest 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 -// ListPersonalResourcesRequestMultiError, or nil if none found. -func (m *ListPersonalResourcesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalResourcesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - if len(errors) > 0 { - return ListPersonalResourcesRequestMultiError(errors) - } - - return nil -} - -// ListPersonalResourcesRequestMultiError is an error wrapping multiple -// validation errors returned by ListPersonalResourcesRequest.ValidateAll() if -// the designated constraints aren't met. -type ListPersonalResourcesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalResourcesRequestMultiError) 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 ListPersonalResourcesRequestMultiError) AllErrors() []error { return m } - -// ListPersonalResourcesRequestValidationError is the validation error returned -// by ListPersonalResourcesRequest.Validate if the designated constraints -// aren't met. -type ListPersonalResourcesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalResourcesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalResourcesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalResourcesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalResourcesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalResourcesRequestValidationError) ErrorName() string { - return "ListPersonalResourcesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalResourcesRequestValidationError) 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 %sListPersonalResourcesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalResourcesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalResourcesRequestValidationError{} - -// Validate checks the field values on ListPersonalResourcesResponse 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 *ListPersonalResourcesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalResourcesResponse 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 -// ListPersonalResourcesResponseMultiError, or nil if none found. -func (m *ListPersonalResourcesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalResourcesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for NextPageToken - - if len(errors) > 0 { - return ListPersonalResourcesResponseMultiError(errors) - } - - return nil -} - -// ListPersonalResourcesResponseMultiError is an error wrapping multiple -// validation errors returned by ListPersonalResourcesResponse.ValidateAll() -// if the designated constraints aren't met. -type ListPersonalResourcesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalResourcesResponseMultiError) 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 ListPersonalResourcesResponseMultiError) AllErrors() []error { return m } - -// ListPersonalResourcesResponseValidationError is the validation error -// returned by ListPersonalResourcesResponse.Validate if the designated -// constraints aren't met. -type ListPersonalResourcesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalResourcesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalResourcesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalResourcesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalResourcesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalResourcesResponseValidationError) ErrorName() string { - return "ListPersonalResourcesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalResourcesResponseValidationError) 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 %sListPersonalResourcesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalResourcesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalResourcesResponseValidationError{} - -// Validate checks the field values on UpdatePersonalPasswordRequest 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 *UpdatePersonalPasswordRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalPasswordRequest 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 -// UpdatePersonalPasswordRequestMultiError, or nil if none found. -func (m *UpdatePersonalPasswordRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalPasswordRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalPasswordRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalPasswordRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalPasswordRequest.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalPasswordRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalPasswordRequestMultiError) 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 UpdatePersonalPasswordRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalPasswordRequestValidationError is the validation error -// returned by UpdatePersonalPasswordRequest.Validate if the designated -// constraints aren't met. -type UpdatePersonalPasswordRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalPasswordRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalPasswordRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalPasswordRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalPasswordRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalPasswordRequestValidationError) ErrorName() string { - return "UpdatePersonalPasswordRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalPasswordRequestValidationError) 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 %sUpdatePersonalPasswordRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalPasswordRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalPasswordRequestValidationError{} - -// Validate checks the field values on UpdatePersonalPasswordResponse 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 *UpdatePersonalPasswordResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalPasswordResponse 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 -// UpdatePersonalPasswordResponseMultiError, or nil if none found. -func (m *UpdatePersonalPasswordResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalPasswordResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalPasswordResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalPasswordResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalPasswordResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalPasswordResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalPasswordResponseMultiError) 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 UpdatePersonalPasswordResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalPasswordResponseValidationError is the validation error -// returned by UpdatePersonalPasswordResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalPasswordResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalPasswordResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalPasswordResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalPasswordResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalPasswordResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalPasswordResponseValidationError) ErrorName() string { - return "UpdatePersonalPasswordResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalPasswordResponseValidationError) 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 %sUpdatePersonalPasswordResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalPasswordResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalPasswordResponseValidationError{} - -// Validate checks the field values on PersonalPasswordRestRequest 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 *PersonalPasswordRestRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalPasswordRestRequest 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 -// PersonalPasswordRestRequestMultiError, or nil if none found. -func (m *PersonalPasswordRestRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalPasswordRestRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetId() <= 0 { - err := PersonalPasswordRestRequestValidationError{ - field: "Id", - reason: "value must be greater than 0", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return PersonalPasswordRestRequestMultiError(errors) - } - - return nil -} - -// PersonalPasswordRestRequestMultiError is an error wrapping multiple -// validation errors returned by PersonalPasswordRestRequest.ValidateAll() if -// the designated constraints aren't met. -type PersonalPasswordRestRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalPasswordRestRequestMultiError) 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 PersonalPasswordRestRequestMultiError) AllErrors() []error { return m } - -// PersonalPasswordRestRequestValidationError is the validation error returned -// by PersonalPasswordRestRequest.Validate if the designated constraints -// aren't met. -type PersonalPasswordRestRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalPasswordRestRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalPasswordRestRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalPasswordRestRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalPasswordRestRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalPasswordRestRequestValidationError) ErrorName() string { - return "PersonalPasswordRestRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalPasswordRestRequestValidationError) 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 %sPersonalPasswordRestRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalPasswordRestRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalPasswordRestRequestValidationError{} - -// Validate checks the field values on PersonalPasswordRestResponse 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 *PersonalPasswordRestResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalPasswordRestResponse 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 -// PersonalPasswordRestResponseMultiError, or nil if none found. -func (m *PersonalPasswordRestResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalPasswordRestResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return PersonalPasswordRestResponseMultiError(errors) - } - - return nil -} - -// PersonalPasswordRestResponseMultiError is an error wrapping multiple -// validation errors returned by PersonalPasswordRestResponse.ValidateAll() if -// the designated constraints aren't met. -type PersonalPasswordRestResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalPasswordRestResponseMultiError) 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 PersonalPasswordRestResponseMultiError) AllErrors() []error { return m } - -// PersonalPasswordRestResponseValidationError is the validation error returned -// by PersonalPasswordRestResponse.Validate if the designated constraints -// aren't met. -type PersonalPasswordRestResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalPasswordRestResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalPasswordRestResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalPasswordRestResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalPasswordRestResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalPasswordRestResponseValidationError) ErrorName() string { - return "PersonalPasswordRestResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalPasswordRestResponseValidationError) 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 %sPersonalPasswordRestResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalPasswordRestResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalPasswordRestResponseValidationError{} - -// Validate checks the field values on UpdatePersonalProfileRequest 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 *UpdatePersonalProfileRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalProfileRequest 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 -// UpdatePersonalProfileRequestMultiError, or nil if none found. -func (m *UpdatePersonalProfileRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalProfileRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalProfileRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalProfileRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalProfileRequest.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalProfileRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalProfileRequestMultiError) 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 UpdatePersonalProfileRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalProfileRequestValidationError is the validation error returned -// by UpdatePersonalProfileRequest.Validate if the designated constraints -// aren't met. -type UpdatePersonalProfileRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalProfileRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalProfileRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalProfileRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalProfileRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalProfileRequestValidationError) ErrorName() string { - return "UpdatePersonalProfileRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalProfileRequestValidationError) 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 %sUpdatePersonalProfileRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalProfileRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalProfileRequestValidationError{} - -// Validate checks the field values on UpdatePersonalProfileResponse 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 *UpdatePersonalProfileResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalProfileResponse 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 -// UpdatePersonalProfileResponseMultiError, or nil if none found. -func (m *UpdatePersonalProfileResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalProfileResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalProfileResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalProfileResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalProfileResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalProfileResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalProfileResponseMultiError) 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 UpdatePersonalProfileResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalProfileResponseValidationError is the validation error -// returned by UpdatePersonalProfileResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalProfileResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalProfileResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalProfileResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalProfileResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalProfileResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalProfileResponseValidationError) ErrorName() string { - return "UpdatePersonalProfileResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalProfileResponseValidationError) 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 %sUpdatePersonalProfileResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalProfileResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalProfileResponseValidationError{} - -// Validate checks the field values on PersonalLogoutRequest 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 *PersonalLogoutRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalLogoutRequest 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 -// PersonalLogoutRequestMultiError, or nil if none found. -func (m *PersonalLogoutRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalLogoutRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return PersonalLogoutRequestMultiError(errors) - } - - return nil -} - -// PersonalLogoutRequestMultiError is an error wrapping multiple validation -// errors returned by PersonalLogoutRequest.ValidateAll() if the designated -// constraints aren't met. -type PersonalLogoutRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalLogoutRequestMultiError) 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 PersonalLogoutRequestMultiError) AllErrors() []error { return m } - -// PersonalLogoutRequestValidationError is the validation error returned by -// PersonalLogoutRequest.Validate if the designated constraints aren't met. -type PersonalLogoutRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalLogoutRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalLogoutRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalLogoutRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalLogoutRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalLogoutRequestValidationError) ErrorName() string { - return "PersonalLogoutRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalLogoutRequestValidationError) 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 %sPersonalLogoutRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalLogoutRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalLogoutRequestValidationError{} - -// Validate checks the field values on PersonalLogoutResponse 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 *PersonalLogoutResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalLogoutResponse 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 -// PersonalLogoutResponseMultiError, or nil if none found. -func (m *PersonalLogoutResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalLogoutResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Success - - if len(errors) > 0 { - return PersonalLogoutResponseMultiError(errors) - } - - return nil -} - -// PersonalLogoutResponseMultiError is an error wrapping multiple validation -// errors returned by PersonalLogoutResponse.ValidateAll() if the designated -// constraints aren't met. -type PersonalLogoutResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalLogoutResponseMultiError) 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 PersonalLogoutResponseMultiError) AllErrors() []error { return m } - -// PersonalLogoutResponseValidationError is the validation error returned by -// PersonalLogoutResponse.Validate if the designated constraints aren't met. -type PersonalLogoutResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalLogoutResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalLogoutResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalLogoutResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalLogoutResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalLogoutResponseValidationError) ErrorName() string { - return "PersonalLogoutResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalLogoutResponseValidationError) 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 %sPersonalLogoutResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalLogoutResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalLogoutResponseValidationError{} - -// Validate checks the field values on ListPersonalRolesRequest 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 *ListPersonalRolesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalRolesRequest 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 -// ListPersonalRolesRequestMultiError, or nil if none found. -func (m *ListPersonalRolesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalRolesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return ListPersonalRolesRequestMultiError(errors) - } - - return nil -} - -// ListPersonalRolesRequestMultiError is an error wrapping multiple validation -// errors returned by ListPersonalRolesRequest.ValidateAll() if the designated -// constraints aren't met. -type ListPersonalRolesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalRolesRequestMultiError) 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 ListPersonalRolesRequestMultiError) AllErrors() []error { return m } - -// ListPersonalRolesRequestValidationError is the validation error returned by -// ListPersonalRolesRequest.Validate if the designated constraints aren't met. -type ListPersonalRolesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalRolesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalRolesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalRolesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalRolesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalRolesRequestValidationError) ErrorName() string { - return "ListPersonalRolesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalRolesRequestValidationError) 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 %sListPersonalRolesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalRolesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalRolesRequestValidationError{} - -// Validate checks the field values on ListPersonalRolesResponse 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 *ListPersonalRolesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalRolesResponse 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 -// ListPersonalRolesResponseMultiError, or nil if none found. -func (m *ListPersonalRolesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalRolesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListPersonalRolesResponseMultiError(errors) - } - - return nil -} - -// ListPersonalRolesResponseMultiError is an error wrapping multiple validation -// errors returned by ListPersonalRolesResponse.ValidateAll() if the -// designated constraints aren't met. -type ListPersonalRolesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalRolesResponseMultiError) 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 ListPersonalRolesResponseMultiError) AllErrors() []error { return m } - -// ListPersonalRolesResponseValidationError is the validation error returned by -// ListPersonalRolesResponse.Validate if the designated constraints aren't met. -type ListPersonalRolesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalRolesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalRolesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalRolesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalRolesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalRolesResponseValidationError) ErrorName() string { - return "ListPersonalRolesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalRolesResponseValidationError) 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 %sListPersonalRolesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalRolesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalRolesResponseValidationError{} - -// Validate checks the field values on GetPersonalProfileRequest 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 *GetPersonalProfileRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPersonalProfileRequest 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 -// GetPersonalProfileRequestMultiError, or nil if none found. -func (m *GetPersonalProfileRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPersonalProfileRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return GetPersonalProfileRequestMultiError(errors) - } - - return nil -} - -// GetPersonalProfileRequestMultiError is an error wrapping multiple validation -// errors returned by GetPersonalProfileRequest.ValidateAll() if the -// designated constraints aren't met. -type GetPersonalProfileRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPersonalProfileRequestMultiError) 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 GetPersonalProfileRequestMultiError) AllErrors() []error { return m } - -// GetPersonalProfileRequestValidationError is the validation error returned by -// GetPersonalProfileRequest.Validate if the designated constraints aren't met. -type GetPersonalProfileRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPersonalProfileRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPersonalProfileRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPersonalProfileRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPersonalProfileRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPersonalProfileRequestValidationError) ErrorName() string { - return "GetPersonalProfileRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPersonalProfileRequestValidationError) 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 %sGetPersonalProfileRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPersonalProfileRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPersonalProfileRequestValidationError{} - -// Validate checks the field values on GetPersonalProfileResponse 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 *GetPersonalProfileResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPersonalProfileResponse 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 -// GetPersonalProfileResponseMultiError, or nil if none found. -func (m *GetPersonalProfileResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPersonalProfileResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetPersonalProfileResponseMultiError(errors) - } - - return nil -} - -// GetPersonalProfileResponseMultiError is an error wrapping multiple -// validation errors returned by GetPersonalProfileResponse.ValidateAll() if -// the designated constraints aren't met. -type GetPersonalProfileResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPersonalProfileResponseMultiError) 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 GetPersonalProfileResponseMultiError) AllErrors() []error { return m } - -// GetPersonalProfileResponseValidationError is the validation error returned -// by GetPersonalProfileResponse.Validate if the designated constraints aren't met. -type GetPersonalProfileResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPersonalProfileResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPersonalProfileResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPersonalProfileResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPersonalProfileResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPersonalProfileResponseValidationError) ErrorName() string { - return "GetPersonalProfileResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPersonalProfileResponseValidationError) 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 %sGetPersonalProfileResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPersonalProfileResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPersonalProfileResponseValidationError{} - -// Validate checks the field values on RefreshPersonalTokenRequest 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 *RefreshPersonalTokenRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RefreshPersonalTokenRequest 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 -// RefreshPersonalTokenRequestMultiError, or nil if none found. -func (m *RefreshPersonalTokenRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *RefreshPersonalTokenRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RefreshPersonalTokenRequestMultiError(errors) - } - - return nil -} - -// RefreshPersonalTokenRequestMultiError is an error wrapping multiple -// validation errors returned by RefreshPersonalTokenRequest.ValidateAll() if -// the designated constraints aren't met. -type RefreshPersonalTokenRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RefreshPersonalTokenRequestMultiError) 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 RefreshPersonalTokenRequestMultiError) AllErrors() []error { return m } - -// RefreshPersonalTokenRequestValidationError is the validation error returned -// by RefreshPersonalTokenRequest.Validate if the designated constraints -// aren't met. -type RefreshPersonalTokenRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RefreshPersonalTokenRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RefreshPersonalTokenRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RefreshPersonalTokenRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RefreshPersonalTokenRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RefreshPersonalTokenRequestValidationError) ErrorName() string { - return "RefreshPersonalTokenRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e RefreshPersonalTokenRequestValidationError) 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 %sRefreshPersonalTokenRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RefreshPersonalTokenRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RefreshPersonalTokenRequestValidationError{} - -// Validate checks the field values on RefreshPersonalTokenResponse 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 *RefreshPersonalTokenResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RefreshPersonalTokenResponse 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 -// RefreshPersonalTokenResponseMultiError, or nil if none found. -func (m *RefreshPersonalTokenResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *RefreshPersonalTokenResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - if len(errors) > 0 { - return RefreshPersonalTokenResponseMultiError(errors) - } - - return nil -} - -// RefreshPersonalTokenResponseMultiError is an error wrapping multiple -// validation errors returned by RefreshPersonalTokenResponse.ValidateAll() if -// the designated constraints aren't met. -type RefreshPersonalTokenResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RefreshPersonalTokenResponseMultiError) 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 RefreshPersonalTokenResponseMultiError) AllErrors() []error { return m } - -// RefreshPersonalTokenResponseValidationError is the validation error returned -// by RefreshPersonalTokenResponse.Validate if the designated constraints -// aren't met. -type RefreshPersonalTokenResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RefreshPersonalTokenResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RefreshPersonalTokenResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RefreshPersonalTokenResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RefreshPersonalTokenResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RefreshPersonalTokenResponseValidationError) ErrorName() string { - return "RefreshPersonalTokenResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e RefreshPersonalTokenResponseValidationError) 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 %sRefreshPersonalTokenResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RefreshPersonalTokenResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RefreshPersonalTokenResponseValidationError{} diff --git a/api/v1/services/auth/personal_bridge.pb.go b/api/v1/services/auth/personal_bridge.pb.go deleted file mode 100644 index 25b430e6..00000000 --- a/api/v1/services/auth/personal_bridge.pb.go +++ /dev/null @@ -1,565 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: auth/personal.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const PersonalServiceGetPersonalProfileBridgeOperation = "/api.v1.services.auth.PersonalService/GetPersonalProfile" -const PersonalServiceListPersonalResourcesBridgeOperation = "/api.v1.services.auth.PersonalService/ListPersonalResources" -const PersonalServiceListPersonalRolesBridgeOperation = "/api.v1.services.auth.PersonalService/ListPersonalRoles" -const PersonalServicePersonalLogoutBridgeOperation = "/api.v1.services.auth.PersonalService/PersonalLogout" -const PersonalServiceRefreshPersonalTokenBridgeOperation = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" -const PersonalServiceUpdatePersonalPasswordBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" -const PersonalServiceUpdatePersonalProfileBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" -const PersonalServiceUpdatePersonalSettingBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" - -type PersonalServiceBridgeServer interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) -} - -type PersonalServiceHooker interface { - PersonalServiceGetPersonalProfileHooker - PersonalServiceListPersonalResourcesHooker - PersonalServiceListPersonalRolesHooker - PersonalServicePersonalLogoutHooker - PersonalServiceRefreshPersonalTokenHooker - PersonalServiceUpdatePersonalPasswordHooker - PersonalServiceUpdatePersonalProfileHooker - PersonalServiceUpdatePersonalSettingHooker -} - -type PersonalServiceHookedBridger interface { - PersonalServiceHooker - PersonalServiceBridgeServer -} -type PersonalServiceGetPersonalProfileHooker interface { - PrepareGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) - CompleteGetPersonalProfile(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error -} -type PersonalServiceListPersonalResourcesHooker interface { - PrepareListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) - CompleteListPersonalResources(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error -} -type PersonalServiceListPersonalRolesHooker interface { - PrepareListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) - CompleteListPersonalRoles(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error -} -type PersonalServicePersonalLogoutHooker interface { - PreparePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) - CompletePersonalLogout(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error -} -type PersonalServiceRefreshPersonalTokenHooker interface { - PrepareRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) - CompleteRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error -} -type PersonalServiceUpdatePersonalPasswordHooker interface { - PrepareUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) - CompleteUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error -} -type PersonalServiceUpdatePersonalProfileHooker interface { - PrepareUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) - CompleteUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error -} -type PersonalServiceUpdatePersonalSettingHooker interface { - PrepareUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) - CompleteUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error -} - -func RegisterPersonalServiceBridgeServer(s *http.Server, srv PersonalServiceHookedBridger) { - r := s.Route("/") - r.GET("/auth/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) - r.GET("/auth/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) - r.GET("/auth/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) - r.POST("/auth/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(srv)) - r.POST("/auth/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv)) - r.PUT("/auth/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv)) - r.PUT("/auth/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv)) - r.PUT("/auth/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv)) -} - -func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPersonalProfileRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - }) - - newctx, err := srv.PrepareGetPersonalProfile(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetPersonalProfile(ctx, &in, out.(*GetPersonalProfileResponse)) - } -} - -func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - }) - - newctx, err := srv.PrepareListPersonalResources(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPersonalResources(ctx, &in, out.(*ListPersonalResourcesResponse)) - } -} - -func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalRolesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - }) - - newctx, err := srv.PrepareListPersonalRoles(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPersonalRoles(ctx, &in, out.(*ListPersonalRolesResponse)) - } -} - -func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in PersonalLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServicePersonalLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - }) - - newctx, err := srv.PreparePersonalLogout(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompletePersonalLogout(ctx, &in, out.(*PersonalLogoutResponse)) - } -} - -func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RefreshPersonalTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - }) - - newctx, err := srv.PrepareRefreshPersonalToken(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteRefreshPersonalToken(ctx, &in, out.(*RefreshPersonalTokenResponse)) - } -} - -func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalPassword(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalPassword(ctx, &in, out.(*UpdatePersonalPasswordResponse)) - } -} - -func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalProfileRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalProfile(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalProfile(ctx, &in, out.(*UpdatePersonalProfileResponse)) - } -} - -func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalSettingRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalSetting(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalSetting(ctx, &in, out.(*UpdatePersonalSettingResponse)) - } -} - -// UnimplementedPersonalServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPersonalServiceHooked struct{} - -func (UnimplementedPersonalServiceHooked) PrepareGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PreparePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompletePersonalLogout(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { - return ctx.Result(200, out) -} - -func WithPersonalServiceHook(h PersonalServiceHooker) func(PersonalServiceBridgeServer) PersonalServiceHookedBridger { - return func(srv PersonalServiceBridgeServer) PersonalServiceHookedBridger { - return PersonalServiceHookedBridge{PersonalServiceBridgeServer: srv, PersonalServiceHooker: h} - } -} - -// PersonalServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PersonalService. -// It implements the HTTP and gRPC implementations of PersonalService. -// It forwards requests and responses between the two implementations. -type PersonalServiceHookedBridge struct { - PersonalServiceBridgeServer - PersonalServiceHooker -} - -type PersonalServiceHTTPBridgeImpl struct { - client PersonalServiceHTTPClient -} - -func NewPersonalServiceHTTPBridge(client *http.Client) PersonalServiceHTTPServer { - return &PersonalServiceHTTPBridgeImpl{client: NewPersonalServiceHTTPClient(client)} -} - -func (c *PersonalServiceHTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -type PersonalServiceBridgeImpl struct { - client PersonalServiceClient -} - -func NewPersonalServiceBridge(client grpc.ClientConnInterface) PersonalServiceServer { - return &PersonalServiceBridgeImpl{client: NewPersonalServiceClient(client)} -} - -func (c *PersonalServiceBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} - -type PersonalServiceGRPC2HTTPBridgeImpl struct { - client PersonalServiceClient -} - -func NewPersonalServiceGRPC2HTTP(client grpc.ClientConnInterface) PersonalServiceHTTPServer { - return &PersonalServiceGRPC2HTTPBridgeImpl{client: NewPersonalServiceClient(client)} -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -type PersonalServiceHTTP2GRPCBridgeImpl struct { - client PersonalServiceHTTPClient -} - -func NewPersonalServiceHTTP2GRPC(client *http.Client) PersonalServiceServer { - return &PersonalServiceHTTP2GRPCBridgeImpl{client: NewPersonalServiceHTTPClient(client)} -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} diff --git a/api/v1/services/auth/personal_grpc.pb.go b/api/v1/services/auth/personal_grpc.pb.go deleted file mode 100644 index 6f4d95e8..00000000 --- a/api/v1/services/auth/personal_grpc.pb.go +++ /dev/null @@ -1,407 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: auth/personal.proto - -package auth - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - PersonalService_GetPersonalProfile_FullMethodName = "/api.v1.services.auth.PersonalService/GetPersonalProfile" - PersonalService_ListPersonalResources_FullMethodName = "/api.v1.services.auth.PersonalService/ListPersonalResources" - PersonalService_ListPersonalRoles_FullMethodName = "/api.v1.services.auth.PersonalService/ListPersonalRoles" - PersonalService_PersonalLogout_FullMethodName = "/api.v1.services.auth.PersonalService/PersonalLogout" - PersonalService_RefreshPersonalToken_FullMethodName = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" - PersonalService_UpdatePersonalPassword_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" - PersonalService_UpdatePersonalProfile_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" - PersonalService_UpdatePersonalSetting_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" -) - -// PersonalServiceClient is the client API for PersonalService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// PersonalService Personal user service -type PersonalServiceClient interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) -} - -type personalServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewPersonalServiceClient(cc grpc.ClientConnInterface) PersonalServiceClient { - return &personalServiceClient{cc} -} - -func (c *personalServiceClient) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetPersonalProfileResponse) - err := c.cc.Invoke(ctx, PersonalService_GetPersonalProfile_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPersonalResourcesResponse) - err := c.cc.Invoke(ctx, PersonalService_ListPersonalResources_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPersonalRolesResponse) - err := c.cc.Invoke(ctx, PersonalService_ListPersonalRoles_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(PersonalLogoutResponse) - err := c.cc.Invoke(ctx, PersonalService_PersonalLogout_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(RefreshPersonalTokenResponse) - err := c.cc.Invoke(ctx, PersonalService_RefreshPersonalToken_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalPasswordResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalPassword_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalProfileResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalProfile_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalSettingResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalSetting_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// PersonalServiceServer is the server API for PersonalService service. -// All implementations must embed UnimplementedPersonalServiceServer -// for forward compatibility. -// -// PersonalService Personal user service -type PersonalServiceServer interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) - mustEmbedUnimplementedPersonalServiceServer() -} - -// UnimplementedPersonalServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPersonalServiceServer struct{} - -func (UnimplementedPersonalServiceServer) GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetPersonalProfile not implemented") -} -func (UnimplementedPersonalServiceServer) ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPersonalResources not implemented") -} -func (UnimplementedPersonalServiceServer) ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPersonalRoles not implemented") -} -func (UnimplementedPersonalServiceServer) PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PersonalLogout not implemented") -} -func (UnimplementedPersonalServiceServer) RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RefreshPersonalToken not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalPassword not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalProfile not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalSetting not implemented") -} -func (UnimplementedPersonalServiceServer) mustEmbedUnimplementedPersonalServiceServer() {} -func (UnimplementedPersonalServiceServer) testEmbeddedByValue() {} - -// UnsafePersonalServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to PersonalServiceServer will -// result in compilation errors. -type UnsafePersonalServiceServer interface { - mustEmbedUnimplementedPersonalServiceServer() -} - -func RegisterPersonalServiceServer(s grpc.ServiceRegistrar, srv PersonalServiceServer) { - // If the following call pancis, it indicates UnimplementedPersonalServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&PersonalService_ServiceDesc, srv) -} - -func _PersonalService_GetPersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPersonalProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).GetPersonalProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_GetPersonalProfile_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_ListPersonalResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPersonalResourcesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).ListPersonalResources(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_ListPersonalResources_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_ListPersonalRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPersonalRolesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).ListPersonalRoles(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_ListPersonalRoles_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_PersonalLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PersonalLogoutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).PersonalLogout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_PersonalLogout_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_RefreshPersonalToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RefreshPersonalTokenRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_RefreshPersonalToken_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalPasswordRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalPassword_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalProfile_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalSettingRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalSetting_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// PersonalService_ServiceDesc is the grpc.ServiceDesc for PersonalService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var PersonalService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.auth.PersonalService", - HandlerType: (*PersonalServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetPersonalProfile", - Handler: _PersonalService_GetPersonalProfile_Handler, - }, - { - MethodName: "ListPersonalResources", - Handler: _PersonalService_ListPersonalResources_Handler, - }, - { - MethodName: "ListPersonalRoles", - Handler: _PersonalService_ListPersonalRoles_Handler, - }, - { - MethodName: "PersonalLogout", - Handler: _PersonalService_PersonalLogout_Handler, - }, - { - MethodName: "RefreshPersonalToken", - Handler: _PersonalService_RefreshPersonalToken_Handler, - }, - { - MethodName: "UpdatePersonalPassword", - Handler: _PersonalService_UpdatePersonalPassword_Handler, - }, - { - MethodName: "UpdatePersonalProfile", - Handler: _PersonalService_UpdatePersonalProfile_Handler, - }, - { - MethodName: "UpdatePersonalSetting", - Handler: _PersonalService_UpdatePersonalSetting_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "auth/personal.proto", -} diff --git a/api/v1/services/auth/personal_http.pb.go b/api/v1/services/auth/personal_http.pb.go deleted file mode 100644 index 1d00a291..00000000 --- a/api/v1/services/auth/personal_http.pb.go +++ /dev/null @@ -1,366 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: auth/personal.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationPersonalServiceGetPersonalProfile = "/api.v1.services.auth.PersonalService/GetPersonalProfile" -const OperationPersonalServiceListPersonalResources = "/api.v1.services.auth.PersonalService/ListPersonalResources" -const OperationPersonalServiceListPersonalRoles = "/api.v1.services.auth.PersonalService/ListPersonalRoles" -const OperationPersonalServicePersonalLogout = "/api.v1.services.auth.PersonalService/PersonalLogout" -const OperationPersonalServiceRefreshPersonalToken = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" -const OperationPersonalServiceUpdatePersonalPassword = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" -const OperationPersonalServiceUpdatePersonalProfile = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" -const OperationPersonalServiceUpdatePersonalSetting = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" - -type PersonalServiceHTTPServer interface { - // GetPersonalProfile GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalRoles ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) -} - -func RegisterPersonalServiceHTTPServer(s *http.Server, srv PersonalServiceHTTPServer) { - r := s.Route("/") - r.GET("/auth/personal/profile", _PersonalService_GetPersonalProfile0_HTTP_Handler(srv)) - r.GET("/auth/personal/resources", _PersonalService_ListPersonalResources0_HTTP_Handler(srv)) - r.GET("/auth/personal/roles", _PersonalService_ListPersonalRoles0_HTTP_Handler(srv)) - r.POST("/auth/personal/logout", _PersonalService_PersonalLogout0_HTTP_Handler(srv)) - r.POST("/auth/personal/token/refresh", _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv)) - r.PUT("/auth/personal/password", _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv)) - r.PUT("/auth/personal/profile", _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv)) - r.PUT("/auth/personal/setting", _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv)) -} - -func _PersonalService_GetPersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPersonalProfileRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetPersonalProfileResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_ListPersonalResources0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPersonalResourcesResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_ListPersonalRoles0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalRolesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPersonalRolesResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_PersonalLogout0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in PersonalLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServicePersonalLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*PersonalLogoutResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RefreshPersonalTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*RefreshPersonalTokenResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalPasswordResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalProfileRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalProfileResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalSettingRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalSettingResponse) - return ctx.Result(200, reply) - } -} - -type PersonalServiceHTTPClient interface { - // GetPersonalProfile GetPersonalProfile Update the personal user information - GetPersonalProfile(ctx context.Context, req *GetPersonalProfileRequest, opts ...http.CallOption) (rsp *GetPersonalProfileResponse, err error) - // ListPersonalResources ListPersonalResources List the personal user's menu - ListPersonalResources(ctx context.Context, req *ListPersonalResourcesRequest, opts ...http.CallOption) (rsp *ListPersonalResourcesResponse, err error) - // ListPersonalRoles ListPersonalResources List the personal user's menu - ListPersonalRoles(ctx context.Context, req *ListPersonalRolesRequest, opts ...http.CallOption) (rsp *ListPersonalRolesResponse, err error) - // PersonalLogout PersonalLogout Personal user logs out - PersonalLogout(ctx context.Context, req *PersonalLogoutRequest, opts ...http.CallOption) (rsp *PersonalLogoutResponse, err error) - // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(ctx context.Context, req *RefreshPersonalTokenRequest, opts ...http.CallOption) (rsp *RefreshPersonalTokenResponse, err error) - // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(ctx context.Context, req *UpdatePersonalPasswordRequest, opts ...http.CallOption) (rsp *UpdatePersonalPasswordResponse, err error) - // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(ctx context.Context, req *UpdatePersonalProfileRequest, opts ...http.CallOption) (rsp *UpdatePersonalProfileResponse, err error) - // UpdatePersonalSetting UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(ctx context.Context, req *UpdatePersonalSettingRequest, opts ...http.CallOption) (rsp *UpdatePersonalSettingResponse, err error) -} - -type PersonalServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewPersonalServiceHTTPClient(client *http.Client) PersonalServiceHTTPClient { - return &PersonalServiceHTTPClientImpl{client} -} - -// GetPersonalProfile GetPersonalProfile Update the personal user information -func (c *PersonalServiceHTTPClientImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...http.CallOption) (*GetPersonalProfileResponse, error) { - var out GetPersonalProfileResponse - pattern := "/auth/personal/profile" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceGetPersonalProfile)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ListPersonalResources ListPersonalResources List the personal user's menu -func (c *PersonalServiceHTTPClientImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...http.CallOption) (*ListPersonalResourcesResponse, error) { - var out ListPersonalResourcesResponse - pattern := "/auth/personal/resources" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceListPersonalResources)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ListPersonalRoles ListPersonalResources List the personal user's menu -func (c *PersonalServiceHTTPClientImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...http.CallOption) (*ListPersonalRolesResponse, error) { - var out ListPersonalRolesResponse - pattern := "/auth/personal/roles" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceListPersonalRoles)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// PersonalLogout PersonalLogout Personal user logs out -func (c *PersonalServiceHTTPClientImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...http.CallOption) (*PersonalLogoutResponse, error) { - var out PersonalLogoutResponse - pattern := "/auth/personal/logout" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServicePersonalLogout)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token -func (c *PersonalServiceHTTPClientImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...http.CallOption) (*RefreshPersonalTokenResponse, error) { - var out RefreshPersonalTokenResponse - pattern := "/auth/personal/token/refresh" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceRefreshPersonalToken)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...http.CallOption) (*UpdatePersonalPasswordResponse, error) { - var out UpdatePersonalPasswordResponse - pattern := "/auth/personal/password" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalPassword)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdatePersonalProfile UpdatePersonalProfile Update the personal user information -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...http.CallOption) (*UpdatePersonalProfileResponse, error) { - var out UpdatePersonalProfileResponse - pattern := "/auth/personal/profile" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalProfile)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdatePersonalSetting UpdatePersonalSetting User settings are saved -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...http.CallOption) (*UpdatePersonalSettingResponse, error) { - var out UpdatePersonalSettingResponse - pattern := "/auth/personal/setting" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalSetting)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/datastore/datastore.pb.go b/api/v1/services/datastore/datastore.pb.go deleted file mode 100644 index f8e0be72..00000000 --- a/api/v1/services/datastore/datastore.pb.go +++ /dev/null @@ -1,750 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: datastore/datastore.proto - -package datastore - -import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// ListDatastoreRequest is the request for the DatastoreService.ListDatastore method. -type ListDatastoreRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent data id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - // data type - Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListDatastoreRequest) Reset() { - *x = ListDatastoreRequest{} - mi := &file_datastore_datastore_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListDatastoreRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListDatastoreRequest) ProtoMessage() {} - -func (x *ListDatastoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_datastore_datastore_proto_msgTypes[0] - 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 ListDatastoreRequest.ProtoReflect.Descriptor instead. -func (*ListDatastoreRequest) Descriptor() ([]byte, []int) { - return file_datastore_datastore_proto_rawDescGZIP(), []int{0} -} - -func (x *ListDatastoreRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListDatastoreRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListDatastoreRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListDatastoreRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListDatastoreRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListDatastoreRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -func (x *ListDatastoreRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -// ListDatastoreResponse is the response for the DatastoreService.ListDatastore method. -type ListDatastoreResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - // The paging datastore - Data []*types.DataObject `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListDatastoreResponse) Reset() { - *x = ListDatastoreResponse{} - mi := &file_datastore_datastore_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListDatastoreResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListDatastoreResponse) ProtoMessage() {} - -func (x *ListDatastoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_datastore_datastore_proto_msgTypes[1] - 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 ListDatastoreResponse.ProtoReflect.Descriptor instead. -func (*ListDatastoreResponse) Descriptor() ([]byte, []int) { - return file_datastore_datastore_proto_rawDescGZIP(), []int{1} -} - -func (x *ListDatastoreResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListDatastoreResponse) GetData() []*types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -func (x *ListDatastoreResponse) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListDatastoreResponse) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListDatastoreResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -func (x *ListDatastoreResponse) GetExtra() *anypb.Any { - if x != nil { - return x.Extra - } - return nil -} - -// GetDatastoreRequest is the request for the DatastoreService.GetDatastore method. -type GetDatastoreRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the data requested, for example: - // "shelves/shelf1/datastore/data2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetDatastoreRequest) Reset() { - *x = GetDatastoreRequest{} - mi := &file_datastore_datastore_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetDatastoreRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetDatastoreRequest) ProtoMessage() {} - -func (x *GetDatastoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_datastore_datastore_proto_msgTypes[2] - 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 GetDatastoreRequest.ProtoReflect.Descriptor instead. -func (*GetDatastoreRequest) Descriptor() ([]byte, []int) { - return file_datastore_datastore_proto_rawDescGZIP(), []int{2} -} - -func (x *GetDatastoreRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -// GetDatastoreResponse is the response for the DatastoreService.GetDatastore method. -type GetDatastoreResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field id should match the Noun in the method id. - Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetDatastoreResponse) Reset() { - *x = GetDatastoreResponse{} - mi := &file_datastore_datastore_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetDatastoreResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetDatastoreResponse) ProtoMessage() {} - -func (x *GetDatastoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_datastore_datastore_proto_msgTypes[3] - 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 GetDatastoreResponse.ProtoReflect.Descriptor instead. -func (*GetDatastoreResponse) Descriptor() ([]byte, []int) { - return file_datastore_datastore_proto_rawDescGZIP(), []int{3} -} - -func (x *GetDatastoreResponse) GetData() *types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -// CreateDatastoreRequest is the request for the DatastoreService.CreateDatastore method. -type CreateDatastoreRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent data id where the data is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The data id to use for this data. - DataId string `protobuf:"bytes,2,opt,name=data_id,proto3" json:"data_id,omitempty"` - // The data object to create. - Data *types.DataObject `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateDatastoreRequest) Reset() { - *x = CreateDatastoreRequest{} - mi := &file_datastore_datastore_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateDatastoreRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateDatastoreRequest) ProtoMessage() {} - -func (x *CreateDatastoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_datastore_datastore_proto_msgTypes[4] - 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 CreateDatastoreRequest.ProtoReflect.Descriptor instead. -func (*CreateDatastoreRequest) Descriptor() ([]byte, []int) { - return file_datastore_datastore_proto_rawDescGZIP(), []int{4} -} - -func (x *CreateDatastoreRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreateDatastoreRequest) GetDataId() string { - if x != nil { - return x.DataId - } - return "" -} - -func (x *CreateDatastoreRequest) GetData() *types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -// CreateDatastoreResponse is the response for the DatastoreService.CreateDatastore method. -type CreateDatastoreResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateDatastoreResponse) Reset() { - *x = CreateDatastoreResponse{} - mi := &file_datastore_datastore_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateDatastoreResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateDatastoreResponse) ProtoMessage() {} - -func (x *CreateDatastoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_datastore_datastore_proto_msgTypes[5] - 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 CreateDatastoreResponse.ProtoReflect.Descriptor instead. -func (*CreateDatastoreResponse) Descriptor() ([]byte, []int) { - return file_datastore_datastore_proto_rawDescGZIP(), []int{5} -} - -func (x *CreateDatastoreResponse) GetData() *types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -// UpdateDatastoreRequest is the request for the DatastoreService.UpdateDatastore method. -type UpdateDatastoreRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The id of the data object to update. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The data object which replaces the data on the server. - Data *types.DataObject `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateDatastoreRequest) Reset() { - *x = UpdateDatastoreRequest{} - mi := &file_datastore_datastore_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateDatastoreRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateDatastoreRequest) ProtoMessage() {} - -func (x *UpdateDatastoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_datastore_datastore_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 UpdateDatastoreRequest.ProtoReflect.Descriptor instead. -func (*UpdateDatastoreRequest) Descriptor() ([]byte, []int) { - return file_datastore_datastore_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdateDatastoreRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UpdateDatastoreRequest) GetData() *types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -// UpdateDatastoreResponse is the response for the DatastoreService.UpdateDatastore method. -type UpdateDatastoreResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateDatastoreResponse) Reset() { - *x = UpdateDatastoreResponse{} - mi := &file_datastore_datastore_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateDatastoreResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateDatastoreResponse) ProtoMessage() {} - -func (x *UpdateDatastoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_datastore_datastore_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateDatastoreResponse.ProtoReflect.Descriptor instead. -func (*UpdateDatastoreResponse) Descriptor() ([]byte, []int) { - return file_datastore_datastore_proto_rawDescGZIP(), []int{7} -} - -func (x *UpdateDatastoreResponse) GetData() *types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -// DeleteDatastoreRequest is the request for the DatastoreService.DeleteDatastore method. -type DeleteDatastoreRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The data id of the data to be deleted, for example: - // "shelves/shelf1/datastore/data2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteDatastoreRequest) Reset() { - *x = DeleteDatastoreRequest{} - mi := &file_datastore_datastore_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteDatastoreRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteDatastoreRequest) ProtoMessage() {} - -func (x *DeleteDatastoreRequest) ProtoReflect() protoreflect.Message { - mi := &file_datastore_datastore_proto_msgTypes[8] - 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 DeleteDatastoreRequest.ProtoReflect.Descriptor instead. -func (*DeleteDatastoreRequest) Descriptor() ([]byte, []int) { - return file_datastore_datastore_proto_rawDescGZIP(), []int{8} -} - -func (x *DeleteDatastoreRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -// DeleteDatastoreResponse is the response for the DatastoreService.DeleteDatastore method. -type DeleteDatastoreResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // or Datastore data = 1; or google.protobuf.Empty empty = 1; - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteDatastoreResponse) Reset() { - *x = DeleteDatastoreResponse{} - mi := &file_datastore_datastore_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteDatastoreResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteDatastoreResponse) ProtoMessage() {} - -func (x *DeleteDatastoreResponse) ProtoReflect() protoreflect.Message { - mi := &file_datastore_datastore_proto_msgTypes[9] - 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 DeleteDatastoreResponse.ProtoReflect.Descriptor instead. -func (*DeleteDatastoreResponse) Descriptor() ([]byte, []int) { - return file_datastore_datastore_proto_rawDescGZIP(), []int{9} -} - -func (x *DeleteDatastoreResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -var File_datastore_datastore_proto protoreflect.FileDescriptor - -const file_datastore_datastore_proto_rawDesc = "" + - "\n" + - "\x19datastore/datastore.proto\x12\x19api.v1.services.datastore\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15types/datastore.proto\x1a\x17validate/validate.proto\"\xd0\x01\n" + - "\x14ListDatastoreRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\x12\x12\n" + - "\x04type\x18\a \x01(\tR\x04type\"\x8b\x02\n" + - "\x15ListDatastoreResponse\x12\x1e\n" + - "\n" + - "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x125\n" + - "\x04data\x18\x02 \x03(\v2!.api.v1.services.types.DataObjectR\x04data\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + - "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + - "\x06_extra\"%\n" + - "\x13GetDatastoreRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"M\n" + - "\x14GetDatastoreResponse\x125\n" + - "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"\x81\x01\n" + - "\x16CreateDatastoreRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x18\n" + - "\adata_id\x18\x02 \x01(\tR\adata_id\x125\n" + - "\x04data\x18\x03 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"P\n" + - "\x17CreateDatastoreResponse\x125\n" + - "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"_\n" + - "\x16UpdateDatastoreRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x125\n" + - "\x04data\x18\x02 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"P\n" + - "\x17UpdateDatastoreResponse\x125\n" + - "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"(\n" + - "\x16DeleteDatastoreRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"G\n" + - "\x17DeleteDatastoreResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xee\x05\n" + - "\x10DatastoreService\x12\x86\x01\n" + - "\rListDatastore\x12/.api.v1.services.datastore.ListDatastoreRequest\x1a0.api.v1.services.datastore.ListDatastoreResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + - "/datastore\x12\x88\x01\n" + - "\fGetDatastore\x12..api.v1.services.datastore.GetDatastoreRequest\x1a/.api.v1.services.datastore.GetDatastoreResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/datastore/{id}\x12\x92\x01\n" + - "\x0fCreateDatastore\x121.api.v1.services.datastore.CreateDatastoreRequest\x1a2.api.v1.services.datastore.CreateDatastoreResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04data\"\n" + - "/datastore\x12\x9c\x01\n" + - "\x0fUpdateDatastore\x121.api.v1.services.datastore.UpdateDatastoreRequest\x1a2.api.v1.services.datastore.UpdateDatastoreResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04data\x1a\x14/datastore/{data.id}\x12\x91\x01\n" + - "\x0fDeleteDatastore\x121.api.v1.services.datastore.DeleteDatastoreRequest\x1a2.api.v1.services.datastore.DeleteDatastoreResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/datastore/{id}B\xf8\x01\n" + - "\x1dcom.api.v1.services.datastoreB\x0eDatastoreProtoP\x01Z?origadmin/application/admin/api/v1/services/datastore;datastore\xa2\x02\x04AVSD\xaa\x02\x19Api.V1.Services.Datastore\xca\x02\x19Api\\V1\\Services\\Datastore\xe2\x02%Api\\V1\\Services\\Datastore\\GPBMetadata\xea\x02\x1cApi::V1::Services::Datastoreb\x06proto3" - -var ( - file_datastore_datastore_proto_rawDescOnce sync.Once - file_datastore_datastore_proto_rawDescData []byte -) - -func file_datastore_datastore_proto_rawDescGZIP() []byte { - file_datastore_datastore_proto_rawDescOnce.Do(func() { - file_datastore_datastore_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_datastore_datastore_proto_rawDesc), len(file_datastore_datastore_proto_rawDesc))) - }) - return file_datastore_datastore_proto_rawDescData -} - -var file_datastore_datastore_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_datastore_datastore_proto_goTypes = []any{ - (*ListDatastoreRequest)(nil), // 0: api.v1.services.datastore.ListDatastoreRequest - (*ListDatastoreResponse)(nil), // 1: api.v1.services.datastore.ListDatastoreResponse - (*GetDatastoreRequest)(nil), // 2: api.v1.services.datastore.GetDatastoreRequest - (*GetDatastoreResponse)(nil), // 3: api.v1.services.datastore.GetDatastoreResponse - (*CreateDatastoreRequest)(nil), // 4: api.v1.services.datastore.CreateDatastoreRequest - (*CreateDatastoreResponse)(nil), // 5: api.v1.services.datastore.CreateDatastoreResponse - (*UpdateDatastoreRequest)(nil), // 6: api.v1.services.datastore.UpdateDatastoreRequest - (*UpdateDatastoreResponse)(nil), // 7: api.v1.services.datastore.UpdateDatastoreResponse - (*DeleteDatastoreRequest)(nil), // 8: api.v1.services.datastore.DeleteDatastoreRequest - (*DeleteDatastoreResponse)(nil), // 9: api.v1.services.datastore.DeleteDatastoreResponse - (*types.DataObject)(nil), // 10: api.v1.services.types.DataObject - (*anypb.Any)(nil), // 11: google.protobuf.Any - (*emptypb.Empty)(nil), // 12: google.protobuf.Empty -} -var file_datastore_datastore_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.datastore.ListDatastoreResponse.data:type_name -> api.v1.services.types.DataObject - 11, // 1: api.v1.services.datastore.ListDatastoreResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.datastore.GetDatastoreResponse.data:type_name -> api.v1.services.types.DataObject - 10, // 3: api.v1.services.datastore.CreateDatastoreRequest.data:type_name -> api.v1.services.types.DataObject - 10, // 4: api.v1.services.datastore.CreateDatastoreResponse.data:type_name -> api.v1.services.types.DataObject - 10, // 5: api.v1.services.datastore.UpdateDatastoreRequest.data:type_name -> api.v1.services.types.DataObject - 10, // 6: api.v1.services.datastore.UpdateDatastoreResponse.data:type_name -> api.v1.services.types.DataObject - 12, // 7: api.v1.services.datastore.DeleteDatastoreResponse.empty:type_name -> google.protobuf.Empty - 0, // 8: api.v1.services.datastore.DatastoreService.ListDatastore:input_type -> api.v1.services.datastore.ListDatastoreRequest - 2, // 9: api.v1.services.datastore.DatastoreService.GetDatastore:input_type -> api.v1.services.datastore.GetDatastoreRequest - 4, // 10: api.v1.services.datastore.DatastoreService.CreateDatastore:input_type -> api.v1.services.datastore.CreateDatastoreRequest - 6, // 11: api.v1.services.datastore.DatastoreService.UpdateDatastore:input_type -> api.v1.services.datastore.UpdateDatastoreRequest - 8, // 12: api.v1.services.datastore.DatastoreService.DeleteDatastore:input_type -> api.v1.services.datastore.DeleteDatastoreRequest - 1, // 13: api.v1.services.datastore.DatastoreService.ListDatastore:output_type -> api.v1.services.datastore.ListDatastoreResponse - 3, // 14: api.v1.services.datastore.DatastoreService.GetDatastore:output_type -> api.v1.services.datastore.GetDatastoreResponse - 5, // 15: api.v1.services.datastore.DatastoreService.CreateDatastore:output_type -> api.v1.services.datastore.CreateDatastoreResponse - 7, // 16: api.v1.services.datastore.DatastoreService.UpdateDatastore:output_type -> api.v1.services.datastore.UpdateDatastoreResponse - 9, // 17: api.v1.services.datastore.DatastoreService.DeleteDatastore:output_type -> api.v1.services.datastore.DeleteDatastoreResponse - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_datastore_datastore_proto_init() } -func file_datastore_datastore_proto_init() { - if File_datastore_datastore_proto != nil { - return - } - file_datastore_datastore_proto_msgTypes[1].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_datastore_datastore_proto_rawDesc), len(file_datastore_datastore_proto_rawDesc)), - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_datastore_datastore_proto_goTypes, - DependencyIndexes: file_datastore_datastore_proto_depIdxs, - MessageInfos: file_datastore_datastore_proto_msgTypes, - }.Build() - File_datastore_datastore_proto = out.File - file_datastore_datastore_proto_goTypes = nil - file_datastore_datastore_proto_depIdxs = nil -} diff --git a/api/v1/services/datastore/datastore.pb.gw.go b/api/v1/services/datastore/datastore.pb.gw.go deleted file mode 100644 index bcf43768..00000000 --- a/api/v1/services/datastore/datastore.pb.gw.go +++ /dev/null @@ -1,487 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: datastore/datastore.proto - -/* -Package datastore is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package datastore - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_DatastoreService_ListDatastore_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_DatastoreService_ListDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListDatastoreRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_ListDatastore_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_DatastoreService_ListDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListDatastoreRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_ListDatastore_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListDatastore(ctx, &protoReq) - return msg, metadata, err -} - -func request_DatastoreService_GetDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetDatastoreRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_DatastoreService_GetDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetDatastoreRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetDatastore(ctx, &protoReq) - return msg, metadata, err -} - -var filter_DatastoreService_CreateDatastore_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - -func request_DatastoreService_CreateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateDatastoreRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_CreateDatastore_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreateDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_DatastoreService_CreateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateDatastoreRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_CreateDatastore_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreateDatastore(ctx, &protoReq) - return msg, metadata, err -} - -var filter_DatastoreService_UpdateDatastore_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - -func request_DatastoreService_UpdateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateDatastoreRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["data.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_UpdateDatastore_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdateDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_DatastoreService_UpdateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateDatastoreRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["data.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_UpdateDatastore_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdateDatastore(ctx, &protoReq) - return msg, metadata, err -} - -func request_DatastoreService_DeleteDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteDatastoreRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.DeleteDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_DatastoreService_DeleteDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteDatastoreRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.DeleteDatastore(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterDatastoreServiceHandlerServer registers the http handlers for service DatastoreService to "mux". -// UnaryRPC :call DatastoreServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterDatastoreServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterDatastoreServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DatastoreServiceServer) error { - mux.Handle(http.MethodGet, pattern_DatastoreService_ListDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/ListDatastore", runtime.WithHTTPPathPattern("/datastore")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_DatastoreService_ListDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DatastoreService_ListDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_DatastoreService_GetDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/GetDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_DatastoreService_GetDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DatastoreService_GetDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_DatastoreService_CreateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/CreateDatastore", runtime.WithHTTPPathPattern("/datastore")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_DatastoreService_CreateDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DatastoreService_CreateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_DatastoreService_UpdateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/UpdateDatastore", runtime.WithHTTPPathPattern("/datastore/{data.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_DatastoreService_UpdateDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DatastoreService_UpdateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_DatastoreService_DeleteDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/DeleteDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_DatastoreService_DeleteDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DatastoreService_DeleteDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterDatastoreServiceHandlerFromEndpoint is same as RegisterDatastoreServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterDatastoreServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterDatastoreServiceHandler(ctx, mux, conn) -} - -// RegisterDatastoreServiceHandler registers the http handlers for service DatastoreService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterDatastoreServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterDatastoreServiceHandlerClient(ctx, mux, NewDatastoreServiceClient(conn)) -} - -// RegisterDatastoreServiceHandlerClient registers the http handlers for service DatastoreService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DatastoreServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DatastoreServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "DatastoreServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterDatastoreServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DatastoreServiceClient) error { - mux.Handle(http.MethodGet, pattern_DatastoreService_ListDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/ListDatastore", runtime.WithHTTPPathPattern("/datastore")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_DatastoreService_ListDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DatastoreService_ListDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_DatastoreService_GetDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/GetDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_DatastoreService_GetDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DatastoreService_GetDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_DatastoreService_CreateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/CreateDatastore", runtime.WithHTTPPathPattern("/datastore")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_DatastoreService_CreateDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DatastoreService_CreateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_DatastoreService_UpdateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/UpdateDatastore", runtime.WithHTTPPathPattern("/datastore/{data.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_DatastoreService_UpdateDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DatastoreService_UpdateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_DatastoreService_DeleteDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/DeleteDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_DatastoreService_DeleteDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DatastoreService_DeleteDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_DatastoreService_ListDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"datastore"}, "")) - pattern_DatastoreService_GetDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"datastore", "id"}, "")) - pattern_DatastoreService_CreateDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"datastore"}, "")) - pattern_DatastoreService_UpdateDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"datastore", "data.id"}, "")) - pattern_DatastoreService_DeleteDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"datastore", "id"}, "")) -) - -var ( - forward_DatastoreService_ListDatastore_0 = runtime.ForwardResponseMessage - forward_DatastoreService_GetDatastore_0 = runtime.ForwardResponseMessage - forward_DatastoreService_CreateDatastore_0 = runtime.ForwardResponseMessage - forward_DatastoreService_UpdateDatastore_0 = runtime.ForwardResponseMessage - forward_DatastoreService_DeleteDatastore_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/datastore/datastore.pb.validate.go b/api/v1/services/datastore/datastore.pb.validate.go deleted file mode 100644 index 330c520f..00000000 --- a/api/v1/services/datastore/datastore.pb.validate.go +++ /dev/null @@ -1,1329 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: datastore/datastore.proto - -package datastore - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListDatastoreRequest 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 *ListDatastoreRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListDatastoreRequest 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 -// ListDatastoreRequestMultiError, or nil if none found. -func (m *ListDatastoreRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListDatastoreRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - // no validation rules for Type - - if len(errors) > 0 { - return ListDatastoreRequestMultiError(errors) - } - - return nil -} - -// ListDatastoreRequestMultiError is an error wrapping multiple validation -// errors returned by ListDatastoreRequest.ValidateAll() if the designated -// constraints aren't met. -type ListDatastoreRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListDatastoreRequestMultiError) 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 ListDatastoreRequestMultiError) AllErrors() []error { return m } - -// ListDatastoreRequestValidationError is the validation error returned by -// ListDatastoreRequest.Validate if the designated constraints aren't met. -type ListDatastoreRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListDatastoreRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListDatastoreRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListDatastoreRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListDatastoreRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListDatastoreRequestValidationError) ErrorName() string { - return "ListDatastoreRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListDatastoreRequestValidationError) 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 %sListDatastoreRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListDatastoreRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListDatastoreRequestValidationError{} - -// Validate checks the field values on ListDatastoreResponse 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 *ListDatastoreResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListDatastoreResponse 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 -// ListDatastoreResponseMultiError, or nil if none found. -func (m *ListDatastoreResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListDatastoreResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetData() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListDatastoreResponseValidationError{ - field: fmt.Sprintf("Data[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListDatastoreResponseValidationError{ - field: fmt.Sprintf("Data[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListDatastoreResponseValidationError{ - field: fmt.Sprintf("Data[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for NextPageToken - - if m.Extra != nil { - - if all { - switch v := interface{}(m.GetExtra()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListDatastoreResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListDatastoreResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListDatastoreResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListDatastoreResponseMultiError(errors) - } - - return nil -} - -// ListDatastoreResponseMultiError is an error wrapping multiple validation -// errors returned by ListDatastoreResponse.ValidateAll() if the designated -// constraints aren't met. -type ListDatastoreResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListDatastoreResponseMultiError) 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 ListDatastoreResponseMultiError) AllErrors() []error { return m } - -// ListDatastoreResponseValidationError is the validation error returned by -// ListDatastoreResponse.Validate if the designated constraints aren't met. -type ListDatastoreResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListDatastoreResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListDatastoreResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListDatastoreResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListDatastoreResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListDatastoreResponseValidationError) ErrorName() string { - return "ListDatastoreResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListDatastoreResponseValidationError) 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 %sListDatastoreResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListDatastoreResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListDatastoreResponseValidationError{} - -// Validate checks the field values on GetDatastoreRequest 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 *GetDatastoreRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetDatastoreRequest 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 -// GetDatastoreRequestMultiError, or nil if none found. -func (m *GetDatastoreRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetDatastoreRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return GetDatastoreRequestMultiError(errors) - } - - return nil -} - -// GetDatastoreRequestMultiError is an error wrapping multiple validation -// errors returned by GetDatastoreRequest.ValidateAll() if the designated -// constraints aren't met. -type GetDatastoreRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetDatastoreRequestMultiError) 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 GetDatastoreRequestMultiError) AllErrors() []error { return m } - -// GetDatastoreRequestValidationError is the validation error returned by -// GetDatastoreRequest.Validate if the designated constraints aren't met. -type GetDatastoreRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetDatastoreRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetDatastoreRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetDatastoreRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetDatastoreRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetDatastoreRequestValidationError) ErrorName() string { - return "GetDatastoreRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetDatastoreRequestValidationError) 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 %sGetDatastoreRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetDatastoreRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetDatastoreRequestValidationError{} - -// Validate checks the field values on GetDatastoreResponse 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 *GetDatastoreResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetDatastoreResponse 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 -// GetDatastoreResponseMultiError, or nil if none found. -func (m *GetDatastoreResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetDatastoreResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetDatastoreResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetDatastoreResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetDatastoreResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetDatastoreResponseMultiError(errors) - } - - return nil -} - -// GetDatastoreResponseMultiError is an error wrapping multiple validation -// errors returned by GetDatastoreResponse.ValidateAll() if the designated -// constraints aren't met. -type GetDatastoreResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetDatastoreResponseMultiError) 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 GetDatastoreResponseMultiError) AllErrors() []error { return m } - -// GetDatastoreResponseValidationError is the validation error returned by -// GetDatastoreResponse.Validate if the designated constraints aren't met. -type GetDatastoreResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetDatastoreResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetDatastoreResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetDatastoreResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetDatastoreResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetDatastoreResponseValidationError) ErrorName() string { - return "GetDatastoreResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetDatastoreResponseValidationError) 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 %sGetDatastoreResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetDatastoreResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetDatastoreResponseValidationError{} - -// Validate checks the field values on CreateDatastoreRequest 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 *CreateDatastoreRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateDatastoreRequest 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 -// CreateDatastoreRequestMultiError, or nil if none found. -func (m *CreateDatastoreRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateDatastoreRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Parent - - // no validation rules for DataId - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateDatastoreRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateDatastoreRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateDatastoreRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateDatastoreRequestMultiError(errors) - } - - return nil -} - -// CreateDatastoreRequestMultiError is an error wrapping multiple validation -// errors returned by CreateDatastoreRequest.ValidateAll() if the designated -// constraints aren't met. -type CreateDatastoreRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateDatastoreRequestMultiError) 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 CreateDatastoreRequestMultiError) AllErrors() []error { return m } - -// CreateDatastoreRequestValidationError is the validation error returned by -// CreateDatastoreRequest.Validate if the designated constraints aren't met. -type CreateDatastoreRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateDatastoreRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateDatastoreRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateDatastoreRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateDatastoreRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateDatastoreRequestValidationError) ErrorName() string { - return "CreateDatastoreRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateDatastoreRequestValidationError) 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 %sCreateDatastoreRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateDatastoreRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateDatastoreRequestValidationError{} - -// Validate checks the field values on CreateDatastoreResponse 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 *CreateDatastoreResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateDatastoreResponse 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 -// CreateDatastoreResponseMultiError, or nil if none found. -func (m *CreateDatastoreResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateDatastoreResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateDatastoreResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateDatastoreResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateDatastoreResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateDatastoreResponseMultiError(errors) - } - - return nil -} - -// CreateDatastoreResponseMultiError is an error wrapping multiple validation -// errors returned by CreateDatastoreResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateDatastoreResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateDatastoreResponseMultiError) 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 CreateDatastoreResponseMultiError) AllErrors() []error { return m } - -// CreateDatastoreResponseValidationError is the validation error returned by -// CreateDatastoreResponse.Validate if the designated constraints aren't met. -type CreateDatastoreResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateDatastoreResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateDatastoreResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateDatastoreResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateDatastoreResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateDatastoreResponseValidationError) ErrorName() string { - return "CreateDatastoreResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateDatastoreResponseValidationError) 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 %sCreateDatastoreResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateDatastoreResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateDatastoreResponseValidationError{} - -// Validate checks the field values on UpdateDatastoreRequest 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 *UpdateDatastoreRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateDatastoreRequest 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 -// UpdateDatastoreRequestMultiError, or nil if none found. -func (m *UpdateDatastoreRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateDatastoreRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateDatastoreRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateDatastoreRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateDatastoreRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateDatastoreRequestMultiError(errors) - } - - return nil -} - -// UpdateDatastoreRequestMultiError is an error wrapping multiple validation -// errors returned by UpdateDatastoreRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateDatastoreRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateDatastoreRequestMultiError) 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 UpdateDatastoreRequestMultiError) AllErrors() []error { return m } - -// UpdateDatastoreRequestValidationError is the validation error returned by -// UpdateDatastoreRequest.Validate if the designated constraints aren't met. -type UpdateDatastoreRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateDatastoreRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateDatastoreRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateDatastoreRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateDatastoreRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateDatastoreRequestValidationError) ErrorName() string { - return "UpdateDatastoreRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateDatastoreRequestValidationError) 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 %sUpdateDatastoreRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateDatastoreRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateDatastoreRequestValidationError{} - -// Validate checks the field values on UpdateDatastoreResponse 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 *UpdateDatastoreResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateDatastoreResponse 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 -// UpdateDatastoreResponseMultiError, or nil if none found. -func (m *UpdateDatastoreResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateDatastoreResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateDatastoreResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateDatastoreResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateDatastoreResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateDatastoreResponseMultiError(errors) - } - - return nil -} - -// UpdateDatastoreResponseMultiError is an error wrapping multiple validation -// errors returned by UpdateDatastoreResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateDatastoreResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateDatastoreResponseMultiError) 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 UpdateDatastoreResponseMultiError) AllErrors() []error { return m } - -// UpdateDatastoreResponseValidationError is the validation error returned by -// UpdateDatastoreResponse.Validate if the designated constraints aren't met. -type UpdateDatastoreResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateDatastoreResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateDatastoreResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateDatastoreResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateDatastoreResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateDatastoreResponseValidationError) ErrorName() string { - return "UpdateDatastoreResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateDatastoreResponseValidationError) 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 %sUpdateDatastoreResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateDatastoreResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateDatastoreResponseValidationError{} - -// Validate checks the field values on DeleteDatastoreRequest 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 *DeleteDatastoreRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteDatastoreRequest 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 -// DeleteDatastoreRequestMultiError, or nil if none found. -func (m *DeleteDatastoreRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteDatastoreRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return DeleteDatastoreRequestMultiError(errors) - } - - return nil -} - -// DeleteDatastoreRequestMultiError is an error wrapping multiple validation -// errors returned by DeleteDatastoreRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteDatastoreRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteDatastoreRequestMultiError) 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 DeleteDatastoreRequestMultiError) AllErrors() []error { return m } - -// DeleteDatastoreRequestValidationError is the validation error returned by -// DeleteDatastoreRequest.Validate if the designated constraints aren't met. -type DeleteDatastoreRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteDatastoreRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteDatastoreRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteDatastoreRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteDatastoreRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteDatastoreRequestValidationError) ErrorName() string { - return "DeleteDatastoreRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteDatastoreRequestValidationError) 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 %sDeleteDatastoreRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteDatastoreRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteDatastoreRequestValidationError{} - -// Validate checks the field values on DeleteDatastoreResponse 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 *DeleteDatastoreResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteDatastoreResponse 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 -// DeleteDatastoreResponseMultiError, or nil if none found. -func (m *DeleteDatastoreResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteDatastoreResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteDatastoreResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteDatastoreResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteDatastoreResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteDatastoreResponseMultiError(errors) - } - - return nil -} - -// DeleteDatastoreResponseMultiError is an error wrapping multiple validation -// errors returned by DeleteDatastoreResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteDatastoreResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteDatastoreResponseMultiError) 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 DeleteDatastoreResponseMultiError) AllErrors() []error { return m } - -// DeleteDatastoreResponseValidationError is the validation error returned by -// DeleteDatastoreResponse.Validate if the designated constraints aren't met. -type DeleteDatastoreResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteDatastoreResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteDatastoreResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteDatastoreResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteDatastoreResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteDatastoreResponseValidationError) ErrorName() string { - return "DeleteDatastoreResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteDatastoreResponseValidationError) 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 %sDeleteDatastoreResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteDatastoreResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteDatastoreResponseValidationError{} diff --git a/api/v1/services/datastore/datastore_bridge.pb.go b/api/v1/services/datastore/datastore_bridge.pb.go deleted file mode 100644 index 34b94072..00000000 --- a/api/v1/services/datastore/datastore_bridge.pb.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: datastore/datastore.proto - -package datastore - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const DatastoreServiceCreateDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/CreateDatastore" -const DatastoreServiceDeleteDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" -const DatastoreServiceGetDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/GetDatastore" -const DatastoreServiceListDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/ListDatastore" -const DatastoreServiceUpdateDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/UpdateDatastore" - -type DatastoreServiceBridgeServer interface { - CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) - DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) - GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) - ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) - UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) -} - -type DatastoreServiceHooker interface { - DatastoreServiceCreateDatastoreHooker - DatastoreServiceDeleteDatastoreHooker - DatastoreServiceGetDatastoreHooker - DatastoreServiceListDatastoreHooker - DatastoreServiceUpdateDatastoreHooker -} - -type DatastoreServiceHookedBridger interface { - DatastoreServiceHooker - DatastoreServiceBridgeServer -} -type DatastoreServiceCreateDatastoreHooker interface { - PrepareCreateDatastore(http.Context, *CreateDatastoreRequest) (context.Context, error) - CompleteCreateDatastore(http.Context, *CreateDatastoreRequest, *CreateDatastoreResponse) error -} -type DatastoreServiceDeleteDatastoreHooker interface { - PrepareDeleteDatastore(http.Context, *DeleteDatastoreRequest) (context.Context, error) - CompleteDeleteDatastore(http.Context, *DeleteDatastoreRequest, *DeleteDatastoreResponse) error -} -type DatastoreServiceGetDatastoreHooker interface { - PrepareGetDatastore(http.Context, *GetDatastoreRequest) (context.Context, error) - CompleteGetDatastore(http.Context, *GetDatastoreRequest, *GetDatastoreResponse) error -} -type DatastoreServiceListDatastoreHooker interface { - PrepareListDatastore(http.Context, *ListDatastoreRequest) (context.Context, error) - CompleteListDatastore(http.Context, *ListDatastoreRequest, *ListDatastoreResponse) error -} -type DatastoreServiceUpdateDatastoreHooker interface { - PrepareUpdateDatastore(http.Context, *UpdateDatastoreRequest) (context.Context, error) - CompleteUpdateDatastore(http.Context, *UpdateDatastoreRequest, *UpdateDatastoreResponse) error -} - -func RegisterDatastoreServiceBridgeServer(s *http.Server, srv DatastoreServiceHookedBridger) { - r := s.Route("/") - r.GET("/datastore", _DatastoreService_ListDatastore0_Bridge_Handler(srv)) - r.GET("/datastore/:id", _DatastoreService_GetDatastore0_Bridge_Handler(srv)) - r.POST("/datastore", _DatastoreService_CreateDatastore0_Bridge_Handler(srv)) - r.PUT("/datastore/:data.id", _DatastoreService_UpdateDatastore0_Bridge_Handler(srv)) - r.DELETE("/datastore/:id", _DatastoreService_DeleteDatastore0_Bridge_Handler(srv)) -} - -func _DatastoreService_ListDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListDatastoreRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDatastoreServiceListDatastore) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListDatastore(ctx, req.(*ListDatastoreRequest)) - }) - - newctx, err := srv.PrepareListDatastore(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListDatastore(ctx, &in, out.(*ListDatastoreResponse)) - } -} - -func _DatastoreService_GetDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetDatastoreRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDatastoreServiceGetDatastore) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetDatastore(ctx, req.(*GetDatastoreRequest)) - }) - - newctx, err := srv.PrepareGetDatastore(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetDatastore(ctx, &in, out.(*GetDatastoreResponse)) - } -} - -func _DatastoreService_CreateDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateDatastoreRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDatastoreServiceCreateDatastore) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateDatastore(ctx, req.(*CreateDatastoreRequest)) - }) - - newctx, err := srv.PrepareCreateDatastore(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreateDatastore(ctx, &in, out.(*CreateDatastoreResponse)) - } -} - -func _DatastoreService_UpdateDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateDatastoreRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDatastoreServiceUpdateDatastore) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateDatastore(ctx, req.(*UpdateDatastoreRequest)) - }) - - newctx, err := srv.PrepareUpdateDatastore(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateDatastore(ctx, &in, out.(*UpdateDatastoreResponse)) - } -} - -func _DatastoreService_DeleteDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteDatastoreRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDatastoreServiceDeleteDatastore) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteDatastore(ctx, req.(*DeleteDatastoreRequest)) - }) - - newctx, err := srv.PrepareDeleteDatastore(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeleteDatastore(ctx, &in, out.(*DeleteDatastoreResponse)) - } -} - -// UnimplementedDatastoreServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedDatastoreServiceHooked struct{} - -func (UnimplementedDatastoreServiceHooked) PrepareCreateDatastore(ctx http.Context, in *CreateDatastoreRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedDatastoreServiceHooked) CompleteCreateDatastore(ctx http.Context, in *CreateDatastoreRequest, out *CreateDatastoreResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedDatastoreServiceHooked) PrepareDeleteDatastore(ctx http.Context, in *DeleteDatastoreRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedDatastoreServiceHooked) CompleteDeleteDatastore(ctx http.Context, in *DeleteDatastoreRequest, out *DeleteDatastoreResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedDatastoreServiceHooked) PrepareGetDatastore(ctx http.Context, in *GetDatastoreRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedDatastoreServiceHooked) CompleteGetDatastore(ctx http.Context, in *GetDatastoreRequest, out *GetDatastoreResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedDatastoreServiceHooked) PrepareListDatastore(ctx http.Context, in *ListDatastoreRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedDatastoreServiceHooked) CompleteListDatastore(ctx http.Context, in *ListDatastoreRequest, out *ListDatastoreResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedDatastoreServiceHooked) PrepareUpdateDatastore(ctx http.Context, in *UpdateDatastoreRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedDatastoreServiceHooked) CompleteUpdateDatastore(ctx http.Context, in *UpdateDatastoreRequest, out *UpdateDatastoreResponse) error { - return ctx.Result(200, out) -} - -func WithDatastoreServiceHook(h DatastoreServiceHooker) func(DatastoreServiceBridgeServer) DatastoreServiceHookedBridger { - return func(srv DatastoreServiceBridgeServer) DatastoreServiceHookedBridger { - return DatastoreServiceHookedBridge{DatastoreServiceBridgeServer: srv, DatastoreServiceHooker: h} - } -} - -// DatastoreServiceHookedBridge is a bridge between the HTTP and gRPC implementations of DatastoreService. -// It implements the HTTP and gRPC implementations of DatastoreService. -// It forwards requests and responses between the two implementations. -type DatastoreServiceHookedBridge struct { - DatastoreServiceBridgeServer - DatastoreServiceHooker -} - -type DatastoreServiceHTTPBridgeImpl struct { - client DatastoreServiceHTTPClient -} - -func NewDatastoreServiceHTTPBridge(client *http.Client) DatastoreServiceHTTPServer { - return &DatastoreServiceHTTPBridgeImpl{client: NewDatastoreServiceHTTPClient(client)} -} - -func (c *DatastoreServiceHTTPBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { - return c.client.CreateDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTPBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { - return c.client.DeleteDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTPBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { - return c.client.GetDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTPBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { - return c.client.ListDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTPBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { - return c.client.UpdateDatastore(ctx, in) -} - -type DatastoreServiceBridgeImpl struct { - client DatastoreServiceClient -} - -func NewDatastoreServiceBridge(client grpc.ClientConnInterface) DatastoreServiceServer { - return &DatastoreServiceBridgeImpl{client: NewDatastoreServiceClient(client)} -} - -func (c *DatastoreServiceBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { - return c.client.CreateDatastore(ctx, in) -} - -func (c *DatastoreServiceBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { - return c.client.DeleteDatastore(ctx, in) -} - -func (c *DatastoreServiceBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { - return c.client.GetDatastore(ctx, in) -} - -func (c *DatastoreServiceBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { - return c.client.ListDatastore(ctx, in) -} - -func (c *DatastoreServiceBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { - return c.client.UpdateDatastore(ctx, in) -} - -func (c *DatastoreServiceBridgeImpl) mustEmbedUnimplementedDatastoreServiceServer() {} - -type DatastoreServiceGRPC2HTTPBridgeImpl struct { - client DatastoreServiceClient -} - -func NewDatastoreServiceGRPC2HTTP(client grpc.ClientConnInterface) DatastoreServiceHTTPServer { - return &DatastoreServiceGRPC2HTTPBridgeImpl{client: NewDatastoreServiceClient(client)} -} - -func (c *DatastoreServiceGRPC2HTTPBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { - return c.client.CreateDatastore(ctx, in) -} - -func (c *DatastoreServiceGRPC2HTTPBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { - return c.client.DeleteDatastore(ctx, in) -} - -func (c *DatastoreServiceGRPC2HTTPBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { - return c.client.GetDatastore(ctx, in) -} - -func (c *DatastoreServiceGRPC2HTTPBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { - return c.client.ListDatastore(ctx, in) -} - -func (c *DatastoreServiceGRPC2HTTPBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { - return c.client.UpdateDatastore(ctx, in) -} - -type DatastoreServiceHTTP2GRPCBridgeImpl struct { - client DatastoreServiceHTTPClient -} - -func NewDatastoreServiceHTTP2GRPC(client *http.Client) DatastoreServiceServer { - return &DatastoreServiceHTTP2GRPCBridgeImpl{client: NewDatastoreServiceHTTPClient(client)} -} - -func (c *DatastoreServiceHTTP2GRPCBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { - return c.client.CreateDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTP2GRPCBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { - return c.client.DeleteDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTP2GRPCBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { - return c.client.GetDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTP2GRPCBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { - return c.client.ListDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTP2GRPCBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { - return c.client.UpdateDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedDatastoreServiceServer() {} diff --git a/api/v1/services/datastore/datastore_grpc.pb.go b/api/v1/services/datastore/datastore_grpc.pb.go deleted file mode 100644 index 94daa542..00000000 --- a/api/v1/services/datastore/datastore_grpc.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: datastore/datastore.proto - -package datastore - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - DatastoreService_ListDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/ListDatastore" - DatastoreService_GetDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/GetDatastore" - DatastoreService_CreateDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/CreateDatastore" - DatastoreService_UpdateDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/UpdateDatastore" - DatastoreService_DeleteDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" -) - -// DatastoreServiceClient is the client API for DatastoreService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The data service definition. -type DatastoreServiceClient interface { - ListDatastore(ctx context.Context, in *ListDatastoreRequest, opts ...grpc.CallOption) (*ListDatastoreResponse, error) - GetDatastore(ctx context.Context, in *GetDatastoreRequest, opts ...grpc.CallOption) (*GetDatastoreResponse, error) - CreateDatastore(ctx context.Context, in *CreateDatastoreRequest, opts ...grpc.CallOption) (*CreateDatastoreResponse, error) - UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest, opts ...grpc.CallOption) (*UpdateDatastoreResponse, error) - DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest, opts ...grpc.CallOption) (*DeleteDatastoreResponse, error) -} - -type datastoreServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewDatastoreServiceClient(cc grpc.ClientConnInterface) DatastoreServiceClient { - return &datastoreServiceClient{cc} -} - -func (c *datastoreServiceClient) ListDatastore(ctx context.Context, in *ListDatastoreRequest, opts ...grpc.CallOption) (*ListDatastoreResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListDatastoreResponse) - err := c.cc.Invoke(ctx, DatastoreService_ListDatastore_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *datastoreServiceClient) GetDatastore(ctx context.Context, in *GetDatastoreRequest, opts ...grpc.CallOption) (*GetDatastoreResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetDatastoreResponse) - err := c.cc.Invoke(ctx, DatastoreService_GetDatastore_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *datastoreServiceClient) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest, opts ...grpc.CallOption) (*CreateDatastoreResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateDatastoreResponse) - err := c.cc.Invoke(ctx, DatastoreService_CreateDatastore_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *datastoreServiceClient) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest, opts ...grpc.CallOption) (*UpdateDatastoreResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateDatastoreResponse) - err := c.cc.Invoke(ctx, DatastoreService_UpdateDatastore_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *datastoreServiceClient) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest, opts ...grpc.CallOption) (*DeleteDatastoreResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeleteDatastoreResponse) - err := c.cc.Invoke(ctx, DatastoreService_DeleteDatastore_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// DatastoreServiceServer is the server API for DatastoreService service. -// All implementations must embed UnimplementedDatastoreServiceServer -// for forward compatibility. -// -// The data service definition. -type DatastoreServiceServer interface { - ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) - GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) - CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) - UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) - DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) - mustEmbedUnimplementedDatastoreServiceServer() -} - -// UnimplementedDatastoreServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedDatastoreServiceServer struct{} - -func (UnimplementedDatastoreServiceServer) ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListDatastore not implemented") -} -func (UnimplementedDatastoreServiceServer) GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetDatastore not implemented") -} -func (UnimplementedDatastoreServiceServer) CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateDatastore not implemented") -} -func (UnimplementedDatastoreServiceServer) UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateDatastore not implemented") -} -func (UnimplementedDatastoreServiceServer) DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteDatastore not implemented") -} -func (UnimplementedDatastoreServiceServer) mustEmbedUnimplementedDatastoreServiceServer() {} -func (UnimplementedDatastoreServiceServer) testEmbeddedByValue() {} - -// UnsafeDatastoreServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to DatastoreServiceServer will -// result in compilation errors. -type UnsafeDatastoreServiceServer interface { - mustEmbedUnimplementedDatastoreServiceServer() -} - -func RegisterDatastoreServiceServer(s grpc.ServiceRegistrar, srv DatastoreServiceServer) { - // If the following call pancis, it indicates UnimplementedDatastoreServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&DatastoreService_ServiceDesc, srv) -} - -func _DatastoreService_ListDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListDatastoreRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DatastoreServiceServer).ListDatastore(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: DatastoreService_ListDatastore_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DatastoreServiceServer).ListDatastore(ctx, req.(*ListDatastoreRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DatastoreService_GetDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetDatastoreRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DatastoreServiceServer).GetDatastore(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: DatastoreService_GetDatastore_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DatastoreServiceServer).GetDatastore(ctx, req.(*GetDatastoreRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DatastoreService_CreateDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateDatastoreRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DatastoreServiceServer).CreateDatastore(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: DatastoreService_CreateDatastore_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DatastoreServiceServer).CreateDatastore(ctx, req.(*CreateDatastoreRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DatastoreService_UpdateDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateDatastoreRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DatastoreServiceServer).UpdateDatastore(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: DatastoreService_UpdateDatastore_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DatastoreServiceServer).UpdateDatastore(ctx, req.(*UpdateDatastoreRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DatastoreService_DeleteDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteDatastoreRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DatastoreServiceServer).DeleteDatastore(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: DatastoreService_DeleteDatastore_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DatastoreServiceServer).DeleteDatastore(ctx, req.(*DeleteDatastoreRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// DatastoreService_ServiceDesc is the grpc.ServiceDesc for DatastoreService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var DatastoreService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.datastore.DatastoreService", - HandlerType: (*DatastoreServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListDatastore", - Handler: _DatastoreService_ListDatastore_Handler, - }, - { - MethodName: "GetDatastore", - Handler: _DatastoreService_GetDatastore_Handler, - }, - { - MethodName: "CreateDatastore", - Handler: _DatastoreService_CreateDatastore_Handler, - }, - { - MethodName: "UpdateDatastore", - Handler: _DatastoreService_UpdateDatastore_Handler, - }, - { - MethodName: "DeleteDatastore", - Handler: _DatastoreService_DeleteDatastore_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "datastore/datastore.proto", -} diff --git a/api/v1/services/datastore/datastore_http.pb.go b/api/v1/services/datastore/datastore_http.pb.go deleted file mode 100644 index 955111fa..00000000 --- a/api/v1/services/datastore/datastore_http.pb.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: datastore/datastore.proto - -package datastore - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationDatastoreServiceCreateDatastore = "/api.v1.services.datastore.DatastoreService/CreateDatastore" -const OperationDatastoreServiceDeleteDatastore = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" -const OperationDatastoreServiceGetDatastore = "/api.v1.services.datastore.DatastoreService/GetDatastore" -const OperationDatastoreServiceListDatastore = "/api.v1.services.datastore.DatastoreService/ListDatastore" -const OperationDatastoreServiceUpdateDatastore = "/api.v1.services.datastore.DatastoreService/UpdateDatastore" - -type DatastoreServiceHTTPServer interface { - CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) - DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) - GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) - ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) - UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) -} - -func RegisterDatastoreServiceHTTPServer(s *http.Server, srv DatastoreServiceHTTPServer) { - r := s.Route("/") - r.GET("/datastore", _DatastoreService_ListDatastore0_HTTP_Handler(srv)) - r.GET("/datastore/{id}", _DatastoreService_GetDatastore0_HTTP_Handler(srv)) - r.POST("/datastore", _DatastoreService_CreateDatastore0_HTTP_Handler(srv)) - r.PUT("/datastore/{data.id}", _DatastoreService_UpdateDatastore0_HTTP_Handler(srv)) - r.DELETE("/datastore/{id}", _DatastoreService_DeleteDatastore0_HTTP_Handler(srv)) -} - -func _DatastoreService_ListDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListDatastoreRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDatastoreServiceListDatastore) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListDatastore(ctx, req.(*ListDatastoreRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListDatastoreResponse) - return ctx.Result(200, reply) - } -} - -func _DatastoreService_GetDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetDatastoreRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDatastoreServiceGetDatastore) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetDatastore(ctx, req.(*GetDatastoreRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetDatastoreResponse) - return ctx.Result(200, reply) - } -} - -func _DatastoreService_CreateDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateDatastoreRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDatastoreServiceCreateDatastore) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateDatastore(ctx, req.(*CreateDatastoreRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreateDatastoreResponse) - return ctx.Result(200, reply) - } -} - -func _DatastoreService_UpdateDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateDatastoreRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDatastoreServiceUpdateDatastore) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateDatastore(ctx, req.(*UpdateDatastoreRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateDatastoreResponse) - return ctx.Result(200, reply) - } -} - -func _DatastoreService_DeleteDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteDatastoreRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDatastoreServiceDeleteDatastore) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteDatastore(ctx, req.(*DeleteDatastoreRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteDatastoreResponse) - return ctx.Result(200, reply) - } -} - -type DatastoreServiceHTTPClient interface { - CreateDatastore(ctx context.Context, req *CreateDatastoreRequest, opts ...http.CallOption) (rsp *CreateDatastoreResponse, err error) - DeleteDatastore(ctx context.Context, req *DeleteDatastoreRequest, opts ...http.CallOption) (rsp *DeleteDatastoreResponse, err error) - GetDatastore(ctx context.Context, req *GetDatastoreRequest, opts ...http.CallOption) (rsp *GetDatastoreResponse, err error) - ListDatastore(ctx context.Context, req *ListDatastoreRequest, opts ...http.CallOption) (rsp *ListDatastoreResponse, err error) - UpdateDatastore(ctx context.Context, req *UpdateDatastoreRequest, opts ...http.CallOption) (rsp *UpdateDatastoreResponse, err error) -} - -type DatastoreServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewDatastoreServiceHTTPClient(client *http.Client) DatastoreServiceHTTPClient { - return &DatastoreServiceHTTPClientImpl{client} -} - -func (c *DatastoreServiceHTTPClientImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest, opts ...http.CallOption) (*CreateDatastoreResponse, error) { - var out CreateDatastoreResponse - pattern := "/datastore" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationDatastoreServiceCreateDatastore)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *DatastoreServiceHTTPClientImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest, opts ...http.CallOption) (*DeleteDatastoreResponse, error) { - var out DeleteDatastoreResponse - pattern := "/datastore/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationDatastoreServiceDeleteDatastore)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *DatastoreServiceHTTPClientImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest, opts ...http.CallOption) (*GetDatastoreResponse, error) { - var out GetDatastoreResponse - pattern := "/datastore/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationDatastoreServiceGetDatastore)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *DatastoreServiceHTTPClientImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest, opts ...http.CallOption) (*ListDatastoreResponse, error) { - var out ListDatastoreResponse - pattern := "/datastore" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationDatastoreServiceListDatastore)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *DatastoreServiceHTTPClientImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest, opts ...http.CallOption) (*UpdateDatastoreResponse, error) { - var out UpdateDatastoreResponse - pattern := "/datastore/{data.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationDatastoreServiceUpdateDatastore)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/datastore/upload.pb.go b/api/v1/services/datastore/upload.pb.go deleted file mode 100644 index 227e8804..00000000 --- a/api/v1/services/datastore/upload.pb.go +++ /dev/null @@ -1,749 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: datastore/upload.proto - -package upload - -import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// ListUploadRequest is the request for the UploadService.ListUpload method. -type ListUploadRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent data id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - // data type - Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListUploadRequest) Reset() { - *x = ListUploadRequest{} - mi := &file_datastore_upload_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListUploadRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUploadRequest) ProtoMessage() {} - -func (x *ListUploadRequest) ProtoReflect() protoreflect.Message { - mi := &file_datastore_upload_proto_msgTypes[0] - 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 ListUploadRequest.ProtoReflect.Descriptor instead. -func (*ListUploadRequest) Descriptor() ([]byte, []int) { - return file_datastore_upload_proto_rawDescGZIP(), []int{0} -} - -func (x *ListUploadRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListUploadRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListUploadRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListUploadRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListUploadRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListUploadRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -func (x *ListUploadRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -// ListUploadResponse is the response for the UploadService.ListUpload method. -type ListUploadResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - // The paging upload - Data []*types.DataObject `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListUploadResponse) Reset() { - *x = ListUploadResponse{} - mi := &file_datastore_upload_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListUploadResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUploadResponse) ProtoMessage() {} - -func (x *ListUploadResponse) ProtoReflect() protoreflect.Message { - mi := &file_datastore_upload_proto_msgTypes[1] - 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 ListUploadResponse.ProtoReflect.Descriptor instead. -func (*ListUploadResponse) Descriptor() ([]byte, []int) { - return file_datastore_upload_proto_rawDescGZIP(), []int{1} -} - -func (x *ListUploadResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListUploadResponse) GetData() []*types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -func (x *ListUploadResponse) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListUploadResponse) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListUploadResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -func (x *ListUploadResponse) GetExtra() *anypb.Any { - if x != nil { - return x.Extra - } - return nil -} - -// GetUploadRequest is the request for the UploadService.GetUpload method. -type GetUploadRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the data requested, for example: - // "shelves/shelf1/upload/data2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetUploadRequest) Reset() { - *x = GetUploadRequest{} - mi := &file_datastore_upload_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetUploadRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetUploadRequest) ProtoMessage() {} - -func (x *GetUploadRequest) ProtoReflect() protoreflect.Message { - mi := &file_datastore_upload_proto_msgTypes[2] - 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 GetUploadRequest.ProtoReflect.Descriptor instead. -func (*GetUploadRequest) Descriptor() ([]byte, []int) { - return file_datastore_upload_proto_rawDescGZIP(), []int{2} -} - -func (x *GetUploadRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -// GetUploadResponse is the response for the UploadService.GetUpload method. -type GetUploadResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field id should match the Noun in the method id. - Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetUploadResponse) Reset() { - *x = GetUploadResponse{} - mi := &file_datastore_upload_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetUploadResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetUploadResponse) ProtoMessage() {} - -func (x *GetUploadResponse) ProtoReflect() protoreflect.Message { - mi := &file_datastore_upload_proto_msgTypes[3] - 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 GetUploadResponse.ProtoReflect.Descriptor instead. -func (*GetUploadResponse) Descriptor() ([]byte, []int) { - return file_datastore_upload_proto_rawDescGZIP(), []int{3} -} - -func (x *GetUploadResponse) GetData() *types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -// CreateUploadRequest is the request for the UploadService.CreateUpload method. -type CreateUploadRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent data id where the data is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The data id to use for this data. - DataId string `protobuf:"bytes,2,opt,name=data_id,proto3" json:"data_id,omitempty"` - // The data object to create. - Data *types.DataObject `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateUploadRequest) Reset() { - *x = CreateUploadRequest{} - mi := &file_datastore_upload_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateUploadRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateUploadRequest) ProtoMessage() {} - -func (x *CreateUploadRequest) ProtoReflect() protoreflect.Message { - mi := &file_datastore_upload_proto_msgTypes[4] - 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 CreateUploadRequest.ProtoReflect.Descriptor instead. -func (*CreateUploadRequest) Descriptor() ([]byte, []int) { - return file_datastore_upload_proto_rawDescGZIP(), []int{4} -} - -func (x *CreateUploadRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreateUploadRequest) GetDataId() string { - if x != nil { - return x.DataId - } - return "" -} - -func (x *CreateUploadRequest) GetData() *types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -// CreateUploadResponse is the response for the UploadService.CreateUpload method. -type CreateUploadResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateUploadResponse) Reset() { - *x = CreateUploadResponse{} - mi := &file_datastore_upload_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateUploadResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateUploadResponse) ProtoMessage() {} - -func (x *CreateUploadResponse) ProtoReflect() protoreflect.Message { - mi := &file_datastore_upload_proto_msgTypes[5] - 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 CreateUploadResponse.ProtoReflect.Descriptor instead. -func (*CreateUploadResponse) Descriptor() ([]byte, []int) { - return file_datastore_upload_proto_rawDescGZIP(), []int{5} -} - -func (x *CreateUploadResponse) GetData() *types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -// UpdateUploadRequest is the request for the UploadService.UpdateUpload method. -type UpdateUploadRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The id of the data object to update. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The data object which replaces the data on the server. - Data *types.DataObject `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateUploadRequest) Reset() { - *x = UpdateUploadRequest{} - mi := &file_datastore_upload_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateUploadRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateUploadRequest) ProtoMessage() {} - -func (x *UpdateUploadRequest) ProtoReflect() protoreflect.Message { - mi := &file_datastore_upload_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 UpdateUploadRequest.ProtoReflect.Descriptor instead. -func (*UpdateUploadRequest) Descriptor() ([]byte, []int) { - return file_datastore_upload_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdateUploadRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UpdateUploadRequest) GetData() *types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -// UpdateUploadResponse is the response for the UploadService.UpdateUpload method. -type UpdateUploadResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateUploadResponse) Reset() { - *x = UpdateUploadResponse{} - mi := &file_datastore_upload_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateUploadResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateUploadResponse) ProtoMessage() {} - -func (x *UpdateUploadResponse) ProtoReflect() protoreflect.Message { - mi := &file_datastore_upload_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateUploadResponse.ProtoReflect.Descriptor instead. -func (*UpdateUploadResponse) Descriptor() ([]byte, []int) { - return file_datastore_upload_proto_rawDescGZIP(), []int{7} -} - -func (x *UpdateUploadResponse) GetData() *types.DataObject { - if x != nil { - return x.Data - } - return nil -} - -// DeleteUploadRequest is the request for the UploadService.DeleteUpload method. -type DeleteUploadRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The data id of the data to be deleted, for example: - // "shelves/shelf1/upload/data2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteUploadRequest) Reset() { - *x = DeleteUploadRequest{} - mi := &file_datastore_upload_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteUploadRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteUploadRequest) ProtoMessage() {} - -func (x *DeleteUploadRequest) ProtoReflect() protoreflect.Message { - mi := &file_datastore_upload_proto_msgTypes[8] - 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 DeleteUploadRequest.ProtoReflect.Descriptor instead. -func (*DeleteUploadRequest) Descriptor() ([]byte, []int) { - return file_datastore_upload_proto_rawDescGZIP(), []int{8} -} - -func (x *DeleteUploadRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -// DeleteUploadResponse is the response for the UploadService.DeleteUpload method. -type DeleteUploadResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // or Upload data = 1; or google.protobuf.Empty empty = 1; - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteUploadResponse) Reset() { - *x = DeleteUploadResponse{} - mi := &file_datastore_upload_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteUploadResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteUploadResponse) ProtoMessage() {} - -func (x *DeleteUploadResponse) ProtoReflect() protoreflect.Message { - mi := &file_datastore_upload_proto_msgTypes[9] - 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 DeleteUploadResponse.ProtoReflect.Descriptor instead. -func (*DeleteUploadResponse) Descriptor() ([]byte, []int) { - return file_datastore_upload_proto_rawDescGZIP(), []int{9} -} - -func (x *DeleteUploadResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -var File_datastore_upload_proto protoreflect.FileDescriptor - -const file_datastore_upload_proto_rawDesc = "" + - "\n" + - "\x16datastore/upload.proto\x12\x16api.v1.services.upload\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15types/datastore.proto\x1a\x17validate/validate.proto\"\xcd\x01\n" + - "\x11ListUploadRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\x12\x12\n" + - "\x04type\x18\a \x01(\tR\x04type\"\x88\x02\n" + - "\x12ListUploadResponse\x12\x1e\n" + - "\n" + - "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x125\n" + - "\x04data\x18\x02 \x03(\v2!.api.v1.services.types.DataObjectR\x04data\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + - "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + - "\x06_extra\"\"\n" + - "\x10GetUploadRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"J\n" + - "\x11GetUploadResponse\x125\n" + - "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"~\n" + - "\x13CreateUploadRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x18\n" + - "\adata_id\x18\x02 \x01(\tR\adata_id\x125\n" + - "\x04data\x18\x03 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"M\n" + - "\x14CreateUploadResponse\x125\n" + - "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"\\\n" + - "\x13UpdateUploadRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x125\n" + - "\x04data\x18\x02 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"M\n" + - "\x14UpdateUploadResponse\x125\n" + - "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"%\n" + - "\x13DeleteUploadRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"D\n" + - "\x14DeleteUploadResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x8e\x05\n" + - "\rUploadService\x12t\n" + - "\n" + - "ListUpload\x12).api.v1.services.upload.ListUploadRequest\x1a*.api.v1.services.upload.ListUploadResponse\"\x0f\x82\xd3\xe4\x93\x02\t\x12\a/upload\x12v\n" + - "\tGetUpload\x12(.api.v1.services.upload.GetUploadRequest\x1a).api.v1.services.upload.GetUploadResponse\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/upload/{id}\x12\x80\x01\n" + - "\fCreateUpload\x12+.api.v1.services.upload.CreateUploadRequest\x1a,.api.v1.services.upload.CreateUploadResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/upload\x12\x8a\x01\n" + - "\fUpdateUpload\x12+.api.v1.services.upload.UpdateUploadRequest\x1a,.api.v1.services.upload.UpdateUploadResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x04data\x1a\x11/upload/{data.id}\x12\x7f\n" + - "\fDeleteUpload\x12+.api.v1.services.upload.DeleteUploadRequest\x1a,.api.v1.services.upload.DeleteUploadResponse\"\x14\x82\xd3\xe4\x93\x02\x0e*\f/upload/{id}B\xe0\x01\n" + - "\x1acom.api.v1.services.uploadB\vUploadProtoP\x01Z9origadmin/application/admin/api/v1/services/upload;upload\xa2\x02\x04AVSU\xaa\x02\x16Api.V1.Services.Upload\xca\x02\x16Api\\V1\\Services\\Upload\xe2\x02\"Api\\V1\\Services\\Upload\\GPBMetadata\xea\x02\x19Api::V1::Services::Uploadb\x06proto3" - -var ( - file_datastore_upload_proto_rawDescOnce sync.Once - file_datastore_upload_proto_rawDescData []byte -) - -func file_datastore_upload_proto_rawDescGZIP() []byte { - file_datastore_upload_proto_rawDescOnce.Do(func() { - file_datastore_upload_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_datastore_upload_proto_rawDesc), len(file_datastore_upload_proto_rawDesc))) - }) - return file_datastore_upload_proto_rawDescData -} - -var file_datastore_upload_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_datastore_upload_proto_goTypes = []any{ - (*ListUploadRequest)(nil), // 0: api.v1.services.upload.ListUploadRequest - (*ListUploadResponse)(nil), // 1: api.v1.services.upload.ListUploadResponse - (*GetUploadRequest)(nil), // 2: api.v1.services.upload.GetUploadRequest - (*GetUploadResponse)(nil), // 3: api.v1.services.upload.GetUploadResponse - (*CreateUploadRequest)(nil), // 4: api.v1.services.upload.CreateUploadRequest - (*CreateUploadResponse)(nil), // 5: api.v1.services.upload.CreateUploadResponse - (*UpdateUploadRequest)(nil), // 6: api.v1.services.upload.UpdateUploadRequest - (*UpdateUploadResponse)(nil), // 7: api.v1.services.upload.UpdateUploadResponse - (*DeleteUploadRequest)(nil), // 8: api.v1.services.upload.DeleteUploadRequest - (*DeleteUploadResponse)(nil), // 9: api.v1.services.upload.DeleteUploadResponse - (*types.DataObject)(nil), // 10: api.v1.services.types.DataObject - (*anypb.Any)(nil), // 11: google.protobuf.Any - (*emptypb.Empty)(nil), // 12: google.protobuf.Empty -} -var file_datastore_upload_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.upload.ListUploadResponse.data:type_name -> api.v1.services.types.DataObject - 11, // 1: api.v1.services.upload.ListUploadResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.upload.GetUploadResponse.data:type_name -> api.v1.services.types.DataObject - 10, // 3: api.v1.services.upload.CreateUploadRequest.data:type_name -> api.v1.services.types.DataObject - 10, // 4: api.v1.services.upload.CreateUploadResponse.data:type_name -> api.v1.services.types.DataObject - 10, // 5: api.v1.services.upload.UpdateUploadRequest.data:type_name -> api.v1.services.types.DataObject - 10, // 6: api.v1.services.upload.UpdateUploadResponse.data:type_name -> api.v1.services.types.DataObject - 12, // 7: api.v1.services.upload.DeleteUploadResponse.empty:type_name -> google.protobuf.Empty - 0, // 8: api.v1.services.upload.UploadService.ListUpload:input_type -> api.v1.services.upload.ListUploadRequest - 2, // 9: api.v1.services.upload.UploadService.GetUpload:input_type -> api.v1.services.upload.GetUploadRequest - 4, // 10: api.v1.services.upload.UploadService.CreateUpload:input_type -> api.v1.services.upload.CreateUploadRequest - 6, // 11: api.v1.services.upload.UploadService.UpdateUpload:input_type -> api.v1.services.upload.UpdateUploadRequest - 8, // 12: api.v1.services.upload.UploadService.DeleteUpload:input_type -> api.v1.services.upload.DeleteUploadRequest - 1, // 13: api.v1.services.upload.UploadService.ListUpload:output_type -> api.v1.services.upload.ListUploadResponse - 3, // 14: api.v1.services.upload.UploadService.GetUpload:output_type -> api.v1.services.upload.GetUploadResponse - 5, // 15: api.v1.services.upload.UploadService.CreateUpload:output_type -> api.v1.services.upload.CreateUploadResponse - 7, // 16: api.v1.services.upload.UploadService.UpdateUpload:output_type -> api.v1.services.upload.UpdateUploadResponse - 9, // 17: api.v1.services.upload.UploadService.DeleteUpload:output_type -> api.v1.services.upload.DeleteUploadResponse - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_datastore_upload_proto_init() } -func file_datastore_upload_proto_init() { - if File_datastore_upload_proto != nil { - return - } - file_datastore_upload_proto_msgTypes[1].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_datastore_upload_proto_rawDesc), len(file_datastore_upload_proto_rawDesc)), - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_datastore_upload_proto_goTypes, - DependencyIndexes: file_datastore_upload_proto_depIdxs, - MessageInfos: file_datastore_upload_proto_msgTypes, - }.Build() - File_datastore_upload_proto = out.File - file_datastore_upload_proto_goTypes = nil - file_datastore_upload_proto_depIdxs = nil -} diff --git a/api/v1/services/datastore/upload.pb.gw.go b/api/v1/services/datastore/upload.pb.gw.go deleted file mode 100644 index 0084a218..00000000 --- a/api/v1/services/datastore/upload.pb.gw.go +++ /dev/null @@ -1,487 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: datastore/upload.proto - -/* -Package upload is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package upload - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_UploadService_ListUpload_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_UploadService_ListUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListUploadRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_ListUpload_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UploadService_ListUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListUploadRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_ListUpload_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListUpload(ctx, &protoReq) - return msg, metadata, err -} - -func request_UploadService_GetUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetUploadRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UploadService_GetUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetUploadRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetUpload(ctx, &protoReq) - return msg, metadata, err -} - -var filter_UploadService_CreateUpload_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - -func request_UploadService_CreateUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateUploadRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_CreateUpload_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreateUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UploadService_CreateUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateUploadRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_CreateUpload_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreateUpload(ctx, &protoReq) - return msg, metadata, err -} - -var filter_UploadService_UpdateUpload_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - -func request_UploadService_UpdateUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateUploadRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["data.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_UpdateUpload_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdateUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UploadService_UpdateUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateUploadRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["data.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_UpdateUpload_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdateUpload(ctx, &protoReq) - return msg, metadata, err -} - -func request_UploadService_DeleteUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteUploadRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.DeleteUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UploadService_DeleteUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteUploadRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.DeleteUpload(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterUploadServiceHandlerServer registers the http handlers for service UploadService to "mux". -// UnaryRPC :call UploadServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUploadServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterUploadServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UploadServiceServer) error { - mux.Handle(http.MethodGet, pattern_UploadService_ListUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/ListUpload", runtime.WithHTTPPathPattern("/upload")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UploadService_ListUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UploadService_ListUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_UploadService_GetUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/GetUpload", runtime.WithHTTPPathPattern("/upload/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UploadService_GetUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UploadService_GetUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_UploadService_CreateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/CreateUpload", runtime.WithHTTPPathPattern("/upload")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UploadService_CreateUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UploadService_CreateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_UploadService_UpdateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/UpdateUpload", runtime.WithHTTPPathPattern("/upload/{data.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UploadService_UpdateUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UploadService_UpdateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_UploadService_DeleteUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/DeleteUpload", runtime.WithHTTPPathPattern("/upload/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UploadService_DeleteUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UploadService_DeleteUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterUploadServiceHandlerFromEndpoint is same as RegisterUploadServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterUploadServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterUploadServiceHandler(ctx, mux, conn) -} - -// RegisterUploadServiceHandler registers the http handlers for service UploadService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterUploadServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterUploadServiceHandlerClient(ctx, mux, NewUploadServiceClient(conn)) -} - -// RegisterUploadServiceHandlerClient registers the http handlers for service UploadService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UploadServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UploadServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "UploadServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterUploadServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UploadServiceClient) error { - mux.Handle(http.MethodGet, pattern_UploadService_ListUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/ListUpload", runtime.WithHTTPPathPattern("/upload")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UploadService_ListUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UploadService_ListUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_UploadService_GetUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/GetUpload", runtime.WithHTTPPathPattern("/upload/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UploadService_GetUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UploadService_GetUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_UploadService_CreateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/CreateUpload", runtime.WithHTTPPathPattern("/upload")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UploadService_CreateUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UploadService_CreateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_UploadService_UpdateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/UpdateUpload", runtime.WithHTTPPathPattern("/upload/{data.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UploadService_UpdateUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UploadService_UpdateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_UploadService_DeleteUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/DeleteUpload", runtime.WithHTTPPathPattern("/upload/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UploadService_DeleteUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UploadService_DeleteUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_UploadService_ListUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"upload"}, "")) - pattern_UploadService_GetUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"upload", "id"}, "")) - pattern_UploadService_CreateUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"upload"}, "")) - pattern_UploadService_UpdateUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"upload", "data.id"}, "")) - pattern_UploadService_DeleteUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"upload", "id"}, "")) -) - -var ( - forward_UploadService_ListUpload_0 = runtime.ForwardResponseMessage - forward_UploadService_GetUpload_0 = runtime.ForwardResponseMessage - forward_UploadService_CreateUpload_0 = runtime.ForwardResponseMessage - forward_UploadService_UpdateUpload_0 = runtime.ForwardResponseMessage - forward_UploadService_DeleteUpload_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/datastore/upload.pb.validate.go b/api/v1/services/datastore/upload.pb.validate.go deleted file mode 100644 index 57c44c58..00000000 --- a/api/v1/services/datastore/upload.pb.validate.go +++ /dev/null @@ -1,1327 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: datastore/upload.proto - -package upload - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListUploadRequest 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 *ListUploadRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListUploadRequest 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 -// ListUploadRequestMultiError, or nil if none found. -func (m *ListUploadRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListUploadRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - // no validation rules for Type - - if len(errors) > 0 { - return ListUploadRequestMultiError(errors) - } - - return nil -} - -// ListUploadRequestMultiError is an error wrapping multiple validation errors -// returned by ListUploadRequest.ValidateAll() if the designated constraints -// aren't met. -type ListUploadRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListUploadRequestMultiError) 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 ListUploadRequestMultiError) AllErrors() []error { return m } - -// ListUploadRequestValidationError is the validation error returned by -// ListUploadRequest.Validate if the designated constraints aren't met. -type ListUploadRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListUploadRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListUploadRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListUploadRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListUploadRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListUploadRequestValidationError) ErrorName() string { - return "ListUploadRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListUploadRequestValidationError) 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 %sListUploadRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListUploadRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListUploadRequestValidationError{} - -// Validate checks the field values on ListUploadResponse 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 *ListUploadResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListUploadResponse 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 -// ListUploadResponseMultiError, or nil if none found. -func (m *ListUploadResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListUploadResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetData() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListUploadResponseValidationError{ - field: fmt.Sprintf("Data[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListUploadResponseValidationError{ - field: fmt.Sprintf("Data[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListUploadResponseValidationError{ - field: fmt.Sprintf("Data[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for NextPageToken - - if m.Extra != nil { - - if all { - switch v := interface{}(m.GetExtra()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListUploadResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListUploadResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListUploadResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListUploadResponseMultiError(errors) - } - - return nil -} - -// ListUploadResponseMultiError is an error wrapping multiple validation errors -// returned by ListUploadResponse.ValidateAll() if the designated constraints -// aren't met. -type ListUploadResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListUploadResponseMultiError) 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 ListUploadResponseMultiError) AllErrors() []error { return m } - -// ListUploadResponseValidationError is the validation error returned by -// ListUploadResponse.Validate if the designated constraints aren't met. -type ListUploadResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListUploadResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListUploadResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListUploadResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListUploadResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListUploadResponseValidationError) ErrorName() string { - return "ListUploadResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListUploadResponseValidationError) 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 %sListUploadResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListUploadResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListUploadResponseValidationError{} - -// Validate checks the field values on GetUploadRequest 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 *GetUploadRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetUploadRequest 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 -// GetUploadRequestMultiError, or nil if none found. -func (m *GetUploadRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetUploadRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return GetUploadRequestMultiError(errors) - } - - return nil -} - -// GetUploadRequestMultiError is an error wrapping multiple validation errors -// returned by GetUploadRequest.ValidateAll() if the designated constraints -// aren't met. -type GetUploadRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetUploadRequestMultiError) 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 GetUploadRequestMultiError) AllErrors() []error { return m } - -// GetUploadRequestValidationError is the validation error returned by -// GetUploadRequest.Validate if the designated constraints aren't met. -type GetUploadRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetUploadRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetUploadRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetUploadRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetUploadRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetUploadRequestValidationError) ErrorName() string { return "GetUploadRequestValidationError" } - -// Error satisfies the builtin error interface -func (e GetUploadRequestValidationError) 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 %sGetUploadRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetUploadRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetUploadRequestValidationError{} - -// Validate checks the field values on GetUploadResponse 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 *GetUploadResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetUploadResponse 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 -// GetUploadResponseMultiError, or nil if none found. -func (m *GetUploadResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetUploadResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetUploadResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetUploadResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetUploadResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetUploadResponseMultiError(errors) - } - - return nil -} - -// GetUploadResponseMultiError is an error wrapping multiple validation errors -// returned by GetUploadResponse.ValidateAll() if the designated constraints -// aren't met. -type GetUploadResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetUploadResponseMultiError) 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 GetUploadResponseMultiError) AllErrors() []error { return m } - -// GetUploadResponseValidationError is the validation error returned by -// GetUploadResponse.Validate if the designated constraints aren't met. -type GetUploadResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetUploadResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetUploadResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetUploadResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetUploadResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetUploadResponseValidationError) ErrorName() string { - return "GetUploadResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetUploadResponseValidationError) 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 %sGetUploadResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetUploadResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetUploadResponseValidationError{} - -// Validate checks the field values on CreateUploadRequest 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 *CreateUploadRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateUploadRequest 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 -// CreateUploadRequestMultiError, or nil if none found. -func (m *CreateUploadRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateUploadRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Parent - - // no validation rules for DataId - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateUploadRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateUploadRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateUploadRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateUploadRequestMultiError(errors) - } - - return nil -} - -// CreateUploadRequestMultiError is an error wrapping multiple validation -// errors returned by CreateUploadRequest.ValidateAll() if the designated -// constraints aren't met. -type CreateUploadRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateUploadRequestMultiError) 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 CreateUploadRequestMultiError) AllErrors() []error { return m } - -// CreateUploadRequestValidationError is the validation error returned by -// CreateUploadRequest.Validate if the designated constraints aren't met. -type CreateUploadRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateUploadRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateUploadRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateUploadRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateUploadRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateUploadRequestValidationError) ErrorName() string { - return "CreateUploadRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateUploadRequestValidationError) 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 %sCreateUploadRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateUploadRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateUploadRequestValidationError{} - -// Validate checks the field values on CreateUploadResponse 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 *CreateUploadResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateUploadResponse 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 -// CreateUploadResponseMultiError, or nil if none found. -func (m *CreateUploadResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateUploadResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateUploadResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateUploadResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateUploadResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateUploadResponseMultiError(errors) - } - - return nil -} - -// CreateUploadResponseMultiError is an error wrapping multiple validation -// errors returned by CreateUploadResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateUploadResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateUploadResponseMultiError) 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 CreateUploadResponseMultiError) AllErrors() []error { return m } - -// CreateUploadResponseValidationError is the validation error returned by -// CreateUploadResponse.Validate if the designated constraints aren't met. -type CreateUploadResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateUploadResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateUploadResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateUploadResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateUploadResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateUploadResponseValidationError) ErrorName() string { - return "CreateUploadResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateUploadResponseValidationError) 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 %sCreateUploadResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateUploadResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateUploadResponseValidationError{} - -// Validate checks the field values on UpdateUploadRequest 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 *UpdateUploadRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateUploadRequest 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 -// UpdateUploadRequestMultiError, or nil if none found. -func (m *UpdateUploadRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateUploadRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateUploadRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateUploadRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateUploadRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateUploadRequestMultiError(errors) - } - - return nil -} - -// UpdateUploadRequestMultiError is an error wrapping multiple validation -// errors returned by UpdateUploadRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateUploadRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateUploadRequestMultiError) 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 UpdateUploadRequestMultiError) AllErrors() []error { return m } - -// UpdateUploadRequestValidationError is the validation error returned by -// UpdateUploadRequest.Validate if the designated constraints aren't met. -type UpdateUploadRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateUploadRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateUploadRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateUploadRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateUploadRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateUploadRequestValidationError) ErrorName() string { - return "UpdateUploadRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateUploadRequestValidationError) 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 %sUpdateUploadRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateUploadRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateUploadRequestValidationError{} - -// Validate checks the field values on UpdateUploadResponse 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 *UpdateUploadResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateUploadResponse 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 -// UpdateUploadResponseMultiError, or nil if none found. -func (m *UpdateUploadResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateUploadResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateUploadResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateUploadResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateUploadResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateUploadResponseMultiError(errors) - } - - return nil -} - -// UpdateUploadResponseMultiError is an error wrapping multiple validation -// errors returned by UpdateUploadResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateUploadResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateUploadResponseMultiError) 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 UpdateUploadResponseMultiError) AllErrors() []error { return m } - -// UpdateUploadResponseValidationError is the validation error returned by -// UpdateUploadResponse.Validate if the designated constraints aren't met. -type UpdateUploadResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateUploadResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateUploadResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateUploadResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateUploadResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateUploadResponseValidationError) ErrorName() string { - return "UpdateUploadResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateUploadResponseValidationError) 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 %sUpdateUploadResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateUploadResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateUploadResponseValidationError{} - -// Validate checks the field values on DeleteUploadRequest 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 *DeleteUploadRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteUploadRequest 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 -// DeleteUploadRequestMultiError, or nil if none found. -func (m *DeleteUploadRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteUploadRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return DeleteUploadRequestMultiError(errors) - } - - return nil -} - -// DeleteUploadRequestMultiError is an error wrapping multiple validation -// errors returned by DeleteUploadRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteUploadRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteUploadRequestMultiError) 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 DeleteUploadRequestMultiError) AllErrors() []error { return m } - -// DeleteUploadRequestValidationError is the validation error returned by -// DeleteUploadRequest.Validate if the designated constraints aren't met. -type DeleteUploadRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteUploadRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteUploadRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteUploadRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteUploadRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteUploadRequestValidationError) ErrorName() string { - return "DeleteUploadRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteUploadRequestValidationError) 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 %sDeleteUploadRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteUploadRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteUploadRequestValidationError{} - -// Validate checks the field values on DeleteUploadResponse 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 *DeleteUploadResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteUploadResponse 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 -// DeleteUploadResponseMultiError, or nil if none found. -func (m *DeleteUploadResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteUploadResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteUploadResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteUploadResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteUploadResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteUploadResponseMultiError(errors) - } - - return nil -} - -// DeleteUploadResponseMultiError is an error wrapping multiple validation -// errors returned by DeleteUploadResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteUploadResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteUploadResponseMultiError) 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 DeleteUploadResponseMultiError) AllErrors() []error { return m } - -// DeleteUploadResponseValidationError is the validation error returned by -// DeleteUploadResponse.Validate if the designated constraints aren't met. -type DeleteUploadResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteUploadResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteUploadResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteUploadResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteUploadResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteUploadResponseValidationError) ErrorName() string { - return "DeleteUploadResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteUploadResponseValidationError) 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 %sDeleteUploadResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteUploadResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteUploadResponseValidationError{} diff --git a/api/v1/services/datastore/upload_bridge.pb.go b/api/v1/services/datastore/upload_bridge.pb.go deleted file mode 100644 index 0043c929..00000000 --- a/api/v1/services/datastore/upload_bridge.pb.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: datastore/upload.proto - -package upload - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const UploadServiceCreateUploadBridgeOperation = "/api.v1.services.upload.UploadService/CreateUpload" -const UploadServiceDeleteUploadBridgeOperation = "/api.v1.services.upload.UploadService/DeleteUpload" -const UploadServiceGetUploadBridgeOperation = "/api.v1.services.upload.UploadService/GetUpload" -const UploadServiceListUploadBridgeOperation = "/api.v1.services.upload.UploadService/ListUpload" -const UploadServiceUpdateUploadBridgeOperation = "/api.v1.services.upload.UploadService/UpdateUpload" - -type UploadServiceBridgeServer interface { - CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) - DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) - GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) - ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) - UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) -} - -type UploadServiceHooker interface { - UploadServiceCreateUploadHooker - UploadServiceDeleteUploadHooker - UploadServiceGetUploadHooker - UploadServiceListUploadHooker - UploadServiceUpdateUploadHooker -} - -type UploadServiceHookedBridger interface { - UploadServiceHooker - UploadServiceBridgeServer -} -type UploadServiceCreateUploadHooker interface { - PrepareCreateUpload(http.Context, *CreateUploadRequest) (context.Context, error) - CompleteCreateUpload(http.Context, *CreateUploadRequest, *CreateUploadResponse) error -} -type UploadServiceDeleteUploadHooker interface { - PrepareDeleteUpload(http.Context, *DeleteUploadRequest) (context.Context, error) - CompleteDeleteUpload(http.Context, *DeleteUploadRequest, *DeleteUploadResponse) error -} -type UploadServiceGetUploadHooker interface { - PrepareGetUpload(http.Context, *GetUploadRequest) (context.Context, error) - CompleteGetUpload(http.Context, *GetUploadRequest, *GetUploadResponse) error -} -type UploadServiceListUploadHooker interface { - PrepareListUpload(http.Context, *ListUploadRequest) (context.Context, error) - CompleteListUpload(http.Context, *ListUploadRequest, *ListUploadResponse) error -} -type UploadServiceUpdateUploadHooker interface { - PrepareUpdateUpload(http.Context, *UpdateUploadRequest) (context.Context, error) - CompleteUpdateUpload(http.Context, *UpdateUploadRequest, *UpdateUploadResponse) error -} - -func RegisterUploadServiceBridgeServer(s *http.Server, srv UploadServiceHookedBridger) { - r := s.Route("/") - r.GET("/upload", _UploadService_ListUpload0_Bridge_Handler(srv)) - r.GET("/upload/:id", _UploadService_GetUpload0_Bridge_Handler(srv)) - r.POST("/upload", _UploadService_CreateUpload0_Bridge_Handler(srv)) - r.PUT("/upload/:data.id", _UploadService_UpdateUpload0_Bridge_Handler(srv)) - r.DELETE("/upload/:id", _UploadService_DeleteUpload0_Bridge_Handler(srv)) -} - -func _UploadService_ListUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListUploadRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUploadServiceListUpload) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListUpload(ctx, req.(*ListUploadRequest)) - }) - - newctx, err := srv.PrepareListUpload(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListUpload(ctx, &in, out.(*ListUploadResponse)) - } -} - -func _UploadService_GetUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetUploadRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUploadServiceGetUpload) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetUpload(ctx, req.(*GetUploadRequest)) - }) - - newctx, err := srv.PrepareGetUpload(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetUpload(ctx, &in, out.(*GetUploadResponse)) - } -} - -func _UploadService_CreateUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateUploadRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUploadServiceCreateUpload) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateUpload(ctx, req.(*CreateUploadRequest)) - }) - - newctx, err := srv.PrepareCreateUpload(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreateUpload(ctx, &in, out.(*CreateUploadResponse)) - } -} - -func _UploadService_UpdateUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateUploadRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUploadServiceUpdateUpload) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateUpload(ctx, req.(*UpdateUploadRequest)) - }) - - newctx, err := srv.PrepareUpdateUpload(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateUpload(ctx, &in, out.(*UpdateUploadResponse)) - } -} - -func _UploadService_DeleteUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteUploadRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUploadServiceDeleteUpload) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteUpload(ctx, req.(*DeleteUploadRequest)) - }) - - newctx, err := srv.PrepareDeleteUpload(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeleteUpload(ctx, &in, out.(*DeleteUploadResponse)) - } -} - -// UnimplementedUploadServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedUploadServiceHooked struct{} - -func (UnimplementedUploadServiceHooked) PrepareCreateUpload(ctx http.Context, in *CreateUploadRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUploadServiceHooked) CompleteCreateUpload(ctx http.Context, in *CreateUploadRequest, out *CreateUploadResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUploadServiceHooked) PrepareDeleteUpload(ctx http.Context, in *DeleteUploadRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUploadServiceHooked) CompleteDeleteUpload(ctx http.Context, in *DeleteUploadRequest, out *DeleteUploadResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUploadServiceHooked) PrepareGetUpload(ctx http.Context, in *GetUploadRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUploadServiceHooked) CompleteGetUpload(ctx http.Context, in *GetUploadRequest, out *GetUploadResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUploadServiceHooked) PrepareListUpload(ctx http.Context, in *ListUploadRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUploadServiceHooked) CompleteListUpload(ctx http.Context, in *ListUploadRequest, out *ListUploadResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUploadServiceHooked) PrepareUpdateUpload(ctx http.Context, in *UpdateUploadRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUploadServiceHooked) CompleteUpdateUpload(ctx http.Context, in *UpdateUploadRequest, out *UpdateUploadResponse) error { - return ctx.Result(200, out) -} - -func WithUploadServiceHook(h UploadServiceHooker) func(UploadServiceBridgeServer) UploadServiceHookedBridger { - return func(srv UploadServiceBridgeServer) UploadServiceHookedBridger { - return UploadServiceHookedBridge{UploadServiceBridgeServer: srv, UploadServiceHooker: h} - } -} - -// UploadServiceHookedBridge is a bridge between the HTTP and gRPC implementations of UploadService. -// It implements the HTTP and gRPC implementations of UploadService. -// It forwards requests and responses between the two implementations. -type UploadServiceHookedBridge struct { - UploadServiceBridgeServer - UploadServiceHooker -} - -type UploadServiceHTTPBridgeImpl struct { - client UploadServiceHTTPClient -} - -func NewUploadServiceHTTPBridge(client *http.Client) UploadServiceHTTPServer { - return &UploadServiceHTTPBridgeImpl{client: NewUploadServiceHTTPClient(client)} -} - -func (c *UploadServiceHTTPBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { - return c.client.CreateUpload(ctx, in) -} - -func (c *UploadServiceHTTPBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { - return c.client.DeleteUpload(ctx, in) -} - -func (c *UploadServiceHTTPBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { - return c.client.GetUpload(ctx, in) -} - -func (c *UploadServiceHTTPBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { - return c.client.ListUpload(ctx, in) -} - -func (c *UploadServiceHTTPBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { - return c.client.UpdateUpload(ctx, in) -} - -type UploadServiceBridgeImpl struct { - client UploadServiceClient -} - -func NewUploadServiceBridge(client grpc.ClientConnInterface) UploadServiceServer { - return &UploadServiceBridgeImpl{client: NewUploadServiceClient(client)} -} - -func (c *UploadServiceBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { - return c.client.CreateUpload(ctx, in) -} - -func (c *UploadServiceBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { - return c.client.DeleteUpload(ctx, in) -} - -func (c *UploadServiceBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { - return c.client.GetUpload(ctx, in) -} - -func (c *UploadServiceBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { - return c.client.ListUpload(ctx, in) -} - -func (c *UploadServiceBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { - return c.client.UpdateUpload(ctx, in) -} - -func (c *UploadServiceBridgeImpl) mustEmbedUnimplementedUploadServiceServer() {} - -type UploadServiceGRPC2HTTPBridgeImpl struct { - client UploadServiceClient -} - -func NewUploadServiceGRPC2HTTP(client grpc.ClientConnInterface) UploadServiceHTTPServer { - return &UploadServiceGRPC2HTTPBridgeImpl{client: NewUploadServiceClient(client)} -} - -func (c *UploadServiceGRPC2HTTPBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { - return c.client.CreateUpload(ctx, in) -} - -func (c *UploadServiceGRPC2HTTPBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { - return c.client.DeleteUpload(ctx, in) -} - -func (c *UploadServiceGRPC2HTTPBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { - return c.client.GetUpload(ctx, in) -} - -func (c *UploadServiceGRPC2HTTPBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { - return c.client.ListUpload(ctx, in) -} - -func (c *UploadServiceGRPC2HTTPBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { - return c.client.UpdateUpload(ctx, in) -} - -type UploadServiceHTTP2GRPCBridgeImpl struct { - client UploadServiceHTTPClient -} - -func NewUploadServiceHTTP2GRPC(client *http.Client) UploadServiceServer { - return &UploadServiceHTTP2GRPCBridgeImpl{client: NewUploadServiceHTTPClient(client)} -} - -func (c *UploadServiceHTTP2GRPCBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { - return c.client.CreateUpload(ctx, in) -} - -func (c *UploadServiceHTTP2GRPCBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { - return c.client.DeleteUpload(ctx, in) -} - -func (c *UploadServiceHTTP2GRPCBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { - return c.client.GetUpload(ctx, in) -} - -func (c *UploadServiceHTTP2GRPCBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { - return c.client.ListUpload(ctx, in) -} - -func (c *UploadServiceHTTP2GRPCBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { - return c.client.UpdateUpload(ctx, in) -} - -func (c *UploadServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedUploadServiceServer() {} diff --git a/api/v1/services/datastore/upload_grpc.pb.go b/api/v1/services/datastore/upload_grpc.pb.go deleted file mode 100644 index 8f0238b8..00000000 --- a/api/v1/services/datastore/upload_grpc.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: datastore/upload.proto - -package upload - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - UploadService_ListUpload_FullMethodName = "/api.v1.services.upload.UploadService/ListUpload" - UploadService_GetUpload_FullMethodName = "/api.v1.services.upload.UploadService/GetUpload" - UploadService_CreateUpload_FullMethodName = "/api.v1.services.upload.UploadService/CreateUpload" - UploadService_UpdateUpload_FullMethodName = "/api.v1.services.upload.UploadService/UpdateUpload" - UploadService_DeleteUpload_FullMethodName = "/api.v1.services.upload.UploadService/DeleteUpload" -) - -// UploadServiceClient is the client API for UploadService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The data service definition. -type UploadServiceClient interface { - ListUpload(ctx context.Context, in *ListUploadRequest, opts ...grpc.CallOption) (*ListUploadResponse, error) - GetUpload(ctx context.Context, in *GetUploadRequest, opts ...grpc.CallOption) (*GetUploadResponse, error) - CreateUpload(ctx context.Context, in *CreateUploadRequest, opts ...grpc.CallOption) (*CreateUploadResponse, error) - UpdateUpload(ctx context.Context, in *UpdateUploadRequest, opts ...grpc.CallOption) (*UpdateUploadResponse, error) - DeleteUpload(ctx context.Context, in *DeleteUploadRequest, opts ...grpc.CallOption) (*DeleteUploadResponse, error) -} - -type uploadServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewUploadServiceClient(cc grpc.ClientConnInterface) UploadServiceClient { - return &uploadServiceClient{cc} -} - -func (c *uploadServiceClient) ListUpload(ctx context.Context, in *ListUploadRequest, opts ...grpc.CallOption) (*ListUploadResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListUploadResponse) - err := c.cc.Invoke(ctx, UploadService_ListUpload_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *uploadServiceClient) GetUpload(ctx context.Context, in *GetUploadRequest, opts ...grpc.CallOption) (*GetUploadResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetUploadResponse) - err := c.cc.Invoke(ctx, UploadService_GetUpload_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *uploadServiceClient) CreateUpload(ctx context.Context, in *CreateUploadRequest, opts ...grpc.CallOption) (*CreateUploadResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateUploadResponse) - err := c.cc.Invoke(ctx, UploadService_CreateUpload_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *uploadServiceClient) UpdateUpload(ctx context.Context, in *UpdateUploadRequest, opts ...grpc.CallOption) (*UpdateUploadResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateUploadResponse) - err := c.cc.Invoke(ctx, UploadService_UpdateUpload_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *uploadServiceClient) DeleteUpload(ctx context.Context, in *DeleteUploadRequest, opts ...grpc.CallOption) (*DeleteUploadResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeleteUploadResponse) - err := c.cc.Invoke(ctx, UploadService_DeleteUpload_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// UploadServiceServer is the server API for UploadService service. -// All implementations must embed UnimplementedUploadServiceServer -// for forward compatibility. -// -// The data service definition. -type UploadServiceServer interface { - ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) - GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) - CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) - UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) - DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) - mustEmbedUnimplementedUploadServiceServer() -} - -// UnimplementedUploadServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedUploadServiceServer struct{} - -func (UnimplementedUploadServiceServer) ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListUpload not implemented") -} -func (UnimplementedUploadServiceServer) GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetUpload not implemented") -} -func (UnimplementedUploadServiceServer) CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateUpload not implemented") -} -func (UnimplementedUploadServiceServer) UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateUpload not implemented") -} -func (UnimplementedUploadServiceServer) DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteUpload not implemented") -} -func (UnimplementedUploadServiceServer) mustEmbedUnimplementedUploadServiceServer() {} -func (UnimplementedUploadServiceServer) testEmbeddedByValue() {} - -// UnsafeUploadServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to UploadServiceServer will -// result in compilation errors. -type UnsafeUploadServiceServer interface { - mustEmbedUnimplementedUploadServiceServer() -} - -func RegisterUploadServiceServer(s grpc.ServiceRegistrar, srv UploadServiceServer) { - // If the following call pancis, it indicates UnimplementedUploadServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&UploadService_ServiceDesc, srv) -} - -func _UploadService_ListUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListUploadRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UploadServiceServer).ListUpload(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UploadService_ListUpload_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UploadServiceServer).ListUpload(ctx, req.(*ListUploadRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UploadService_GetUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetUploadRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UploadServiceServer).GetUpload(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UploadService_GetUpload_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UploadServiceServer).GetUpload(ctx, req.(*GetUploadRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UploadService_CreateUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateUploadRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UploadServiceServer).CreateUpload(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UploadService_CreateUpload_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UploadServiceServer).CreateUpload(ctx, req.(*CreateUploadRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UploadService_UpdateUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateUploadRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UploadServiceServer).UpdateUpload(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UploadService_UpdateUpload_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UploadServiceServer).UpdateUpload(ctx, req.(*UpdateUploadRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UploadService_DeleteUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteUploadRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UploadServiceServer).DeleteUpload(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UploadService_DeleteUpload_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UploadServiceServer).DeleteUpload(ctx, req.(*DeleteUploadRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// UploadService_ServiceDesc is the grpc.ServiceDesc for UploadService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var UploadService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.upload.UploadService", - HandlerType: (*UploadServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListUpload", - Handler: _UploadService_ListUpload_Handler, - }, - { - MethodName: "GetUpload", - Handler: _UploadService_GetUpload_Handler, - }, - { - MethodName: "CreateUpload", - Handler: _UploadService_CreateUpload_Handler, - }, - { - MethodName: "UpdateUpload", - Handler: _UploadService_UpdateUpload_Handler, - }, - { - MethodName: "DeleteUpload", - Handler: _UploadService_DeleteUpload_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "datastore/upload.proto", -} diff --git a/api/v1/services/datastore/upload_http.pb.go b/api/v1/services/datastore/upload_http.pb.go deleted file mode 100644 index 2162bd5d..00000000 --- a/api/v1/services/datastore/upload_http.pb.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: datastore/upload.proto - -package upload - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationUploadServiceCreateUpload = "/api.v1.services.upload.UploadService/CreateUpload" -const OperationUploadServiceDeleteUpload = "/api.v1.services.upload.UploadService/DeleteUpload" -const OperationUploadServiceGetUpload = "/api.v1.services.upload.UploadService/GetUpload" -const OperationUploadServiceListUpload = "/api.v1.services.upload.UploadService/ListUpload" -const OperationUploadServiceUpdateUpload = "/api.v1.services.upload.UploadService/UpdateUpload" - -type UploadServiceHTTPServer interface { - CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) - DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) - GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) - ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) - UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) -} - -func RegisterUploadServiceHTTPServer(s *http.Server, srv UploadServiceHTTPServer) { - r := s.Route("/") - r.GET("/upload", _UploadService_ListUpload0_HTTP_Handler(srv)) - r.GET("/upload/{id}", _UploadService_GetUpload0_HTTP_Handler(srv)) - r.POST("/upload", _UploadService_CreateUpload0_HTTP_Handler(srv)) - r.PUT("/upload/{data.id}", _UploadService_UpdateUpload0_HTTP_Handler(srv)) - r.DELETE("/upload/{id}", _UploadService_DeleteUpload0_HTTP_Handler(srv)) -} - -func _UploadService_ListUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListUploadRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUploadServiceListUpload) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListUpload(ctx, req.(*ListUploadRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListUploadResponse) - return ctx.Result(200, reply) - } -} - -func _UploadService_GetUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetUploadRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUploadServiceGetUpload) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetUpload(ctx, req.(*GetUploadRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetUploadResponse) - return ctx.Result(200, reply) - } -} - -func _UploadService_CreateUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateUploadRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUploadServiceCreateUpload) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateUpload(ctx, req.(*CreateUploadRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreateUploadResponse) - return ctx.Result(200, reply) - } -} - -func _UploadService_UpdateUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateUploadRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUploadServiceUpdateUpload) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateUpload(ctx, req.(*UpdateUploadRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateUploadResponse) - return ctx.Result(200, reply) - } -} - -func _UploadService_DeleteUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteUploadRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUploadServiceDeleteUpload) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteUpload(ctx, req.(*DeleteUploadRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteUploadResponse) - return ctx.Result(200, reply) - } -} - -type UploadServiceHTTPClient interface { - CreateUpload(ctx context.Context, req *CreateUploadRequest, opts ...http.CallOption) (rsp *CreateUploadResponse, err error) - DeleteUpload(ctx context.Context, req *DeleteUploadRequest, opts ...http.CallOption) (rsp *DeleteUploadResponse, err error) - GetUpload(ctx context.Context, req *GetUploadRequest, opts ...http.CallOption) (rsp *GetUploadResponse, err error) - ListUpload(ctx context.Context, req *ListUploadRequest, opts ...http.CallOption) (rsp *ListUploadResponse, err error) - UpdateUpload(ctx context.Context, req *UpdateUploadRequest, opts ...http.CallOption) (rsp *UpdateUploadResponse, err error) -} - -type UploadServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewUploadServiceHTTPClient(client *http.Client) UploadServiceHTTPClient { - return &UploadServiceHTTPClientImpl{client} -} - -func (c *UploadServiceHTTPClientImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest, opts ...http.CallOption) (*CreateUploadResponse, error) { - var out CreateUploadResponse - pattern := "/upload" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationUploadServiceCreateUpload)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *UploadServiceHTTPClientImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest, opts ...http.CallOption) (*DeleteUploadResponse, error) { - var out DeleteUploadResponse - pattern := "/upload/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationUploadServiceDeleteUpload)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *UploadServiceHTTPClientImpl) GetUpload(ctx context.Context, in *GetUploadRequest, opts ...http.CallOption) (*GetUploadResponse, error) { - var out GetUploadResponse - pattern := "/upload/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationUploadServiceGetUpload)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *UploadServiceHTTPClientImpl) ListUpload(ctx context.Context, in *ListUploadRequest, opts ...http.CallOption) (*ListUploadResponse, error) { - var out ListUploadResponse - pattern := "/upload" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationUploadServiceListUpload)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *UploadServiceHTTPClientImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest, opts ...http.CallOption) (*UpdateUploadResponse, error) { - var out UpdateUploadResponse - pattern := "/upload/{data.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationUploadServiceUpdateUpload)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/message/message.pb.go b/api/v1/services/message/message.pb.go deleted file mode 100644 index be871264..00000000 --- a/api/v1/services/message/message.pb.go +++ /dev/null @@ -1,1074 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: message/message.proto - -package message - -import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type UpdatePersonalSettingRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalSettingRequest) Reset() { - *x = UpdatePersonalSettingRequest{} - mi := &file_message_message_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalSettingRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalSettingRequest) ProtoMessage() {} - -func (x *UpdatePersonalSettingRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[0] - 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 UpdatePersonalSettingRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalSettingRequest) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{0} -} - -func (x *UpdatePersonalSettingRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalSettingResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalSettingResponse) Reset() { - *x = UpdatePersonalSettingResponse{} - mi := &file_message_message_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalSettingResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalSettingResponse) ProtoMessage() {} - -func (x *UpdatePersonalSettingResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[1] - 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 UpdatePersonalSettingResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalSettingResponse) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{1} -} - -type UpdatePersonalRoleRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalRoleRequest) Reset() { - *x = UpdatePersonalRoleRequest{} - mi := &file_message_message_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalRoleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalRoleRequest) ProtoMessage() {} - -func (x *UpdatePersonalRoleRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[2] - 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 UpdatePersonalRoleRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalRoleRequest) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{2} -} - -func (x *UpdatePersonalRoleRequest) GetRole() *types.Role { - if x != nil { - return x.Role - } - return nil -} - -type UpdatePersonalRoleResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalRoleResponse) Reset() { - *x = UpdatePersonalRoleResponse{} - mi := &file_message_message_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalRoleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalRoleResponse) ProtoMessage() {} - -func (x *UpdatePersonalRoleResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[3] - 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 UpdatePersonalRoleResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalRoleResponse) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{3} -} - -type ListPersonalResourcesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalResourcesRequest) Reset() { - *x = ListPersonalResourcesRequest{} - mi := &file_message_message_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalResourcesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalResourcesRequest) ProtoMessage() {} - -func (x *ListPersonalResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[4] - 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 ListPersonalResourcesRequest.ProtoReflect.Descriptor instead. -func (*ListPersonalResourcesRequest) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{4} -} - -func (x *ListPersonalResourcesRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListPersonalResourcesRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListPersonalResourcesRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -type ListPersonalResourcesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int64 `protobuf:"varint,1,opt,name=total_size,json=total,proto3" json:"total_size,omitempty"` - // list of resources - Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalResourcesResponse) Reset() { - *x = ListPersonalResourcesResponse{} - mi := &file_message_message_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalResourcesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalResourcesResponse) ProtoMessage() {} - -func (x *ListPersonalResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[5] - 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 ListPersonalResourcesResponse.ProtoReflect.Descriptor instead. -func (*ListPersonalResourcesResponse) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{5} -} - -func (x *ListPersonalResourcesResponse) GetTotalSize() int64 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListPersonalResourcesResponse) GetResources() []*types.Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *ListPersonalResourcesResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -type UpdatePersonalPasswordRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalPasswordRequest) Reset() { - *x = UpdatePersonalPasswordRequest{} - mi := &file_message_message_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalPasswordRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalPasswordRequest) ProtoMessage() {} - -func (x *UpdatePersonalPasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_message_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 UpdatePersonalPasswordRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalPasswordRequest) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdatePersonalPasswordRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalPasswordResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalPasswordResponse) Reset() { - *x = UpdatePersonalPasswordResponse{} - mi := &file_message_message_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalPasswordResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalPasswordResponse) ProtoMessage() {} - -func (x *UpdatePersonalPasswordResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdatePersonalPasswordResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalPasswordResponse) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{7} -} - -type PersonalPasswordRestRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalPasswordRestRequest) Reset() { - *x = PersonalPasswordRestRequest{} - mi := &file_message_message_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalPasswordRestRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalPasswordRestRequest) ProtoMessage() {} - -func (x *PersonalPasswordRestRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[8] - 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 PersonalPasswordRestRequest.ProtoReflect.Descriptor instead. -func (*PersonalPasswordRestRequest) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{8} -} - -func (x *PersonalPasswordRestRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type PersonalPasswordRestResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalPasswordRestResponse) Reset() { - *x = PersonalPasswordRestResponse{} - mi := &file_message_message_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalPasswordRestResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalPasswordRestResponse) ProtoMessage() {} - -func (x *PersonalPasswordRestResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[9] - 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 PersonalPasswordRestResponse.ProtoReflect.Descriptor instead. -func (*PersonalPasswordRestResponse) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{9} -} - -type UpdatePersonalProfileRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalProfileRequest) Reset() { - *x = UpdatePersonalProfileRequest{} - mi := &file_message_message_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalProfileRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalProfileRequest) ProtoMessage() {} - -func (x *UpdatePersonalProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[10] - 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 UpdatePersonalProfileRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalProfileRequest) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{10} -} - -func (x *UpdatePersonalProfileRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalProfileResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalProfileResponse) Reset() { - *x = UpdatePersonalProfileResponse{} - mi := &file_message_message_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalProfileResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalProfileResponse) ProtoMessage() {} - -func (x *UpdatePersonalProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[11] - 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 UpdatePersonalProfileResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalProfileResponse) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{11} -} - -type PersonalLogoutRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalLogoutRequest) Reset() { - *x = PersonalLogoutRequest{} - mi := &file_message_message_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalLogoutRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalLogoutRequest) ProtoMessage() {} - -func (x *PersonalLogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[12] - 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 PersonalLogoutRequest.ProtoReflect.Descriptor instead. -func (*PersonalLogoutRequest) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{12} -} - -func (x *PersonalLogoutRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type PersonalLogoutResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalLogoutResponse) Reset() { - *x = PersonalLogoutResponse{} - mi := &file_message_message_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalLogoutResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalLogoutResponse) ProtoMessage() {} - -func (x *PersonalLogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[13] - 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 PersonalLogoutResponse.ProtoReflect.Descriptor instead. -func (*PersonalLogoutResponse) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{13} -} - -func (x *PersonalLogoutResponse) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -type ListPersonalRolesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalRolesRequest) Reset() { - *x = ListPersonalRolesRequest{} - mi := &file_message_message_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalRolesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalRolesRequest) ProtoMessage() {} - -func (x *ListPersonalRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[14] - 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 ListPersonalRolesRequest.ProtoReflect.Descriptor instead. -func (*ListPersonalRolesRequest) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{14} -} - -type ListPersonalRolesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Roles []*types.Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalRolesResponse) Reset() { - *x = ListPersonalRolesResponse{} - mi := &file_message_message_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalRolesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalRolesResponse) ProtoMessage() {} - -func (x *ListPersonalRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[15] - 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 ListPersonalRolesResponse.ProtoReflect.Descriptor instead. -func (*ListPersonalRolesResponse) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{15} -} - -func (x *ListPersonalRolesResponse) GetRoles() []*types.Role { - if x != nil { - return x.Roles - } - return nil -} - -type GetPersonalProfileRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPersonalProfileRequest) Reset() { - *x = GetPersonalProfileRequest{} - mi := &file_message_message_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPersonalProfileRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPersonalProfileRequest) ProtoMessage() {} - -func (x *GetPersonalProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[16] - 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 GetPersonalProfileRequest.ProtoReflect.Descriptor instead. -func (*GetPersonalProfileRequest) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{16} -} - -type GetPersonalProfileResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPersonalProfileResponse) Reset() { - *x = GetPersonalProfileResponse{} - mi := &file_message_message_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPersonalProfileResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPersonalProfileResponse) ProtoMessage() {} - -func (x *GetPersonalProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[17] - 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 GetPersonalProfileResponse.ProtoReflect.Descriptor instead. -func (*GetPersonalProfileResponse) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{17} -} - -func (x *GetPersonalProfileResponse) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -type RefreshPersonalTokenRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RefreshPersonalTokenRequest) Reset() { - *x = RefreshPersonalTokenRequest{} - mi := &file_message_message_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RefreshPersonalTokenRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RefreshPersonalTokenRequest) ProtoMessage() {} - -func (x *RefreshPersonalTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[18] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RefreshPersonalTokenRequest.ProtoReflect.Descriptor instead. -func (*RefreshPersonalTokenRequest) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{18} -} - -func (x *RefreshPersonalTokenRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type RefreshPersonalTokenResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RefreshPersonalTokenResponse) Reset() { - *x = RefreshPersonalTokenResponse{} - mi := &file_message_message_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RefreshPersonalTokenResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RefreshPersonalTokenResponse) ProtoMessage() {} - -func (x *RefreshPersonalTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_message_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RefreshPersonalTokenResponse.ProtoReflect.Descriptor instead. -func (*RefreshPersonalTokenResponse) Descriptor() ([]byte, []int) { - return file_message_message_proto_rawDescGZIP(), []int{19} -} - -func (x *RefreshPersonalTokenResponse) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -var File_message_message_proto protoreflect.FileDescriptor - -const file_message_message_proto_rawDesc = "" + - "\n" + - "\x15message/message.proto\x12\x17api.v1.services.message\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12types/system.proto\x1a\x17validate/validate.proto\"H\n" + - "\x1cUpdatePersonalSettingRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + - "\x1dUpdatePersonalSettingResponse\"L\n" + - "\x19UpdatePersonalRoleRequest\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\x1c\n" + - "\x1aUpdatePersonalRoleResponse\"\xc4\x01\n" + - "\x1cListPersonalResourcesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\xa3\x01\n" + - "\x1dListPersonalResourcesResponse\x12\x19\n" + - "\n" + - "total_size\x18\x01 \x01(\x03R\x05total\x12=\n" + - "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\"I\n" + - "\x1dUpdatePersonalPasswordRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\" \n" + - "\x1eUpdatePersonalPasswordResponse\"6\n" + - "\x1bPersonalPasswordRestRequest\x12\x17\n" + - "\x02id\x18\x01 \x01(\x03B\a\xfaB\x04\"\x02 \x00R\x02id\"\x1e\n" + - "\x1cPersonalPasswordRestResponse\"H\n" + - "\x1cUpdatePersonalProfileRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + - "\x1dUpdatePersonalProfileResponse\"A\n" + - "\x15PersonalLogoutRequest\x12(\n" + - "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"2\n" + - "\x16PersonalLogoutResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\"\x1a\n" + - "\x18ListPersonalRolesRequest\"N\n" + - "\x19ListPersonalRolesResponse\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x1b\n" + - "\x19GetPersonalProfileRequest\"M\n" + - "\x1aGetPersonalProfileResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + - "\x1bRefreshPersonalTokenRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"4\n" + - "\x1cRefreshPersonalTokenResponse\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token2\xeb\n" + - "\n" + - "\x0fPersonalService\x12\xa0\x01\n" + - "\x12GetPersonalProfile\x122.api.v1.services.message.GetPersonalProfileRequest\x1a3.api.v1.services.message.GetPersonalProfileResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/message/personal/profile\x12\xab\x01\n" + - "\x15ListPersonalResources\x125.api.v1.services.message.ListPersonalResourcesRequest\x1a6.api.v1.services.message.ListPersonalResourcesResponse\"#\x82\xd3\xe4\x93\x02\x1d\x12\x1b/message/personal/resources\x12\x9b\x01\n" + - "\x11ListPersonalRoles\x121.api.v1.services.message.ListPersonalRolesRequest\x1a2.api.v1.services.message.ListPersonalRolesResponse\"\x1f\x82\xd3\xe4\x93\x02\x19\x12\x17/message/personal/roles\x12\x99\x01\n" + - "\x0ePersonalLogout\x12..api.v1.services.message.PersonalLogoutRequest\x1a/.api.v1.services.message.PersonalLogoutResponse\"&\x82\xd3\xe4\x93\x02 :\x04data\"\x18/message/personal/logout\x12\xb2\x01\n" + - "\x14RefreshPersonalToken\x124.api.v1.services.message.RefreshPersonalTokenRequest\x1a5.api.v1.services.message.RefreshPersonalTokenResponse\"-\x82\xd3\xe4\x93\x02':\x04data\"\x1f/message/personal/token/refresh\x12\xb3\x01\n" + - "\x16UpdatePersonalPassword\x126.api.v1.services.message.UpdatePersonalPasswordRequest\x1a7.api.v1.services.message.UpdatePersonalPasswordResponse\"(\x82\xd3\xe4\x93\x02\":\x04data\x1a\x1a/message/personal/password\x12\xaf\x01\n" + - "\x15UpdatePersonalProfile\x125.api.v1.services.message.UpdatePersonalProfileRequest\x1a6.api.v1.services.message.UpdatePersonalProfileResponse\"'\x82\xd3\xe4\x93\x02!:\x04data\x1a\x19/message/personal/profile\x12\xaf\x01\n" + - "\x15UpdatePersonalSetting\x125.api.v1.services.message.UpdatePersonalSettingRequest\x1a6.api.v1.services.message.UpdatePersonalSettingResponse\"'\x82\xd3\xe4\x93\x02!:\x04data\x1a\x19/message/personal/settingB\xe8\x01\n" + - "\x1bcom.api.v1.services.messageB\fMessageProtoP\x01Z;origadmin/application/admin/api/v1/services/message;message\xa2\x02\x04AVSM\xaa\x02\x17Api.V1.Services.Message\xca\x02\x17Api\\V1\\Services\\Message\xe2\x02#Api\\V1\\Services\\Message\\GPBMetadata\xea\x02\x1aApi::V1::Services::Messageb\x06proto3" - -var ( - file_message_message_proto_rawDescOnce sync.Once - file_message_message_proto_rawDescData []byte -) - -func file_message_message_proto_rawDescGZIP() []byte { - file_message_message_proto_rawDescOnce.Do(func() { - file_message_message_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_message_message_proto_rawDesc), len(file_message_message_proto_rawDesc))) - }) - return file_message_message_proto_rawDescData -} - -var file_message_message_proto_msgTypes = make([]protoimpl.MessageInfo, 20) -var file_message_message_proto_goTypes = []any{ - (*UpdatePersonalSettingRequest)(nil), // 0: api.v1.services.message.UpdatePersonalSettingRequest - (*UpdatePersonalSettingResponse)(nil), // 1: api.v1.services.message.UpdatePersonalSettingResponse - (*UpdatePersonalRoleRequest)(nil), // 2: api.v1.services.message.UpdatePersonalRoleRequest - (*UpdatePersonalRoleResponse)(nil), // 3: api.v1.services.message.UpdatePersonalRoleResponse - (*ListPersonalResourcesRequest)(nil), // 4: api.v1.services.message.ListPersonalResourcesRequest - (*ListPersonalResourcesResponse)(nil), // 5: api.v1.services.message.ListPersonalResourcesResponse - (*UpdatePersonalPasswordRequest)(nil), // 6: api.v1.services.message.UpdatePersonalPasswordRequest - (*UpdatePersonalPasswordResponse)(nil), // 7: api.v1.services.message.UpdatePersonalPasswordResponse - (*PersonalPasswordRestRequest)(nil), // 8: api.v1.services.message.PersonalPasswordRestRequest - (*PersonalPasswordRestResponse)(nil), // 9: api.v1.services.message.PersonalPasswordRestResponse - (*UpdatePersonalProfileRequest)(nil), // 10: api.v1.services.message.UpdatePersonalProfileRequest - (*UpdatePersonalProfileResponse)(nil), // 11: api.v1.services.message.UpdatePersonalProfileResponse - (*PersonalLogoutRequest)(nil), // 12: api.v1.services.message.PersonalLogoutRequest - (*PersonalLogoutResponse)(nil), // 13: api.v1.services.message.PersonalLogoutResponse - (*ListPersonalRolesRequest)(nil), // 14: api.v1.services.message.ListPersonalRolesRequest - (*ListPersonalRolesResponse)(nil), // 15: api.v1.services.message.ListPersonalRolesResponse - (*GetPersonalProfileRequest)(nil), // 16: api.v1.services.message.GetPersonalProfileRequest - (*GetPersonalProfileResponse)(nil), // 17: api.v1.services.message.GetPersonalProfileResponse - (*RefreshPersonalTokenRequest)(nil), // 18: api.v1.services.message.RefreshPersonalTokenRequest - (*RefreshPersonalTokenResponse)(nil), // 19: api.v1.services.message.RefreshPersonalTokenResponse - (*anypb.Any)(nil), // 20: google.protobuf.Any - (*types.Role)(nil), // 21: api.v1.services.types.Role - (*types.Resource)(nil), // 22: api.v1.services.types.Resource - (*types.User)(nil), // 23: api.v1.services.types.User -} -var file_message_message_proto_depIdxs = []int32{ - 20, // 0: api.v1.services.message.UpdatePersonalSettingRequest.data:type_name -> google.protobuf.Any - 21, // 1: api.v1.services.message.UpdatePersonalRoleRequest.role:type_name -> api.v1.services.types.Role - 22, // 2: api.v1.services.message.ListPersonalResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 20, // 3: api.v1.services.message.UpdatePersonalPasswordRequest.data:type_name -> google.protobuf.Any - 20, // 4: api.v1.services.message.UpdatePersonalProfileRequest.data:type_name -> google.protobuf.Any - 20, // 5: api.v1.services.message.PersonalLogoutRequest.data:type_name -> google.protobuf.Any - 21, // 6: api.v1.services.message.ListPersonalRolesResponse.roles:type_name -> api.v1.services.types.Role - 23, // 7: api.v1.services.message.GetPersonalProfileResponse.user:type_name -> api.v1.services.types.User - 20, // 8: api.v1.services.message.RefreshPersonalTokenRequest.data:type_name -> google.protobuf.Any - 16, // 9: api.v1.services.message.PersonalService.GetPersonalProfile:input_type -> api.v1.services.message.GetPersonalProfileRequest - 4, // 10: api.v1.services.message.PersonalService.ListPersonalResources:input_type -> api.v1.services.message.ListPersonalResourcesRequest - 14, // 11: api.v1.services.message.PersonalService.ListPersonalRoles:input_type -> api.v1.services.message.ListPersonalRolesRequest - 12, // 12: api.v1.services.message.PersonalService.PersonalLogout:input_type -> api.v1.services.message.PersonalLogoutRequest - 18, // 13: api.v1.services.message.PersonalService.RefreshPersonalToken:input_type -> api.v1.services.message.RefreshPersonalTokenRequest - 6, // 14: api.v1.services.message.PersonalService.UpdatePersonalPassword:input_type -> api.v1.services.message.UpdatePersonalPasswordRequest - 10, // 15: api.v1.services.message.PersonalService.UpdatePersonalProfile:input_type -> api.v1.services.message.UpdatePersonalProfileRequest - 0, // 16: api.v1.services.message.PersonalService.UpdatePersonalSetting:input_type -> api.v1.services.message.UpdatePersonalSettingRequest - 17, // 17: api.v1.services.message.PersonalService.GetPersonalProfile:output_type -> api.v1.services.message.GetPersonalProfileResponse - 5, // 18: api.v1.services.message.PersonalService.ListPersonalResources:output_type -> api.v1.services.message.ListPersonalResourcesResponse - 15, // 19: api.v1.services.message.PersonalService.ListPersonalRoles:output_type -> api.v1.services.message.ListPersonalRolesResponse - 13, // 20: api.v1.services.message.PersonalService.PersonalLogout:output_type -> api.v1.services.message.PersonalLogoutResponse - 19, // 21: api.v1.services.message.PersonalService.RefreshPersonalToken:output_type -> api.v1.services.message.RefreshPersonalTokenResponse - 7, // 22: api.v1.services.message.PersonalService.UpdatePersonalPassword:output_type -> api.v1.services.message.UpdatePersonalPasswordResponse - 11, // 23: api.v1.services.message.PersonalService.UpdatePersonalProfile:output_type -> api.v1.services.message.UpdatePersonalProfileResponse - 1, // 24: api.v1.services.message.PersonalService.UpdatePersonalSetting:output_type -> api.v1.services.message.UpdatePersonalSettingResponse - 17, // [17:25] is the sub-list for method output_type - 9, // [9:17] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name -} - -func init() { file_message_message_proto_init() } -func file_message_message_proto_init() { - if File_message_message_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_message_message_proto_rawDesc), len(file_message_message_proto_rawDesc)), - NumEnums: 0, - NumMessages: 20, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_message_message_proto_goTypes, - DependencyIndexes: file_message_message_proto_depIdxs, - MessageInfos: file_message_message_proto_msgTypes, - }.Build() - File_message_message_proto = out.File - file_message_message_proto_goTypes = nil - file_message_message_proto_depIdxs = nil -} diff --git a/api/v1/services/message/message.pb.gw.go b/api/v1/services/message/message.pb.gw.go deleted file mode 100644 index 96398dee..00000000 --- a/api/v1/services/message/message.pb.gw.go +++ /dev/null @@ -1,594 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: message/message.proto - -/* -Package message is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package message - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -func request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPersonalProfileRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.GetPersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPersonalProfileRequest - metadata runtime.ServerMetadata - ) - msg, err := server.GetPersonalProfile(ctx, &protoReq) - return msg, metadata, err -} - -var filter_PersonalService_ListPersonalResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalResourcesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListPersonalResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalResourcesRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListPersonalResources(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalRolesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.ListPersonalRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalRolesRequest - metadata runtime.ServerMetadata - ) - msg, err := server.ListPersonalRoles(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq PersonalLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.PersonalLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq PersonalLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.PersonalLogout(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RefreshPersonalTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.RefreshPersonalToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RefreshPersonalTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.RefreshPersonalToken(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalPasswordRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalPasswordRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalPassword(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalProfileRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalProfileRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalProfile(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalSettingRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalSetting(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalSettingRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalSetting(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterPersonalServiceHandlerServer registers the http handlers for service PersonalService to "mux". -// UnaryRPC :call PersonalServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPersonalServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterPersonalServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PersonalServiceServer) error { - mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/message/personal/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/message/personal/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/message/personal/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/message/personal/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/message/personal/password")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/message/personal/setting")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterPersonalServiceHandlerFromEndpoint is same as RegisterPersonalServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterPersonalServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterPersonalServiceHandler(ctx, mux, conn) -} - -// RegisterPersonalServiceHandler registers the http handlers for service PersonalService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterPersonalServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterPersonalServiceHandlerClient(ctx, mux, NewPersonalServiceClient(conn)) -} - -// RegisterPersonalServiceHandlerClient registers the http handlers for service PersonalService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PersonalServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PersonalServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "PersonalServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterPersonalServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PersonalServiceClient) error { - mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/message/personal/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/message/personal/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/message/personal/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/message/personal/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/message/personal/password")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/message/personal/setting")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_PersonalService_GetPersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "profile"}, "")) - pattern_PersonalService_ListPersonalResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "resources"}, "")) - pattern_PersonalService_ListPersonalRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "roles"}, "")) - pattern_PersonalService_PersonalLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "logout"}, "")) - pattern_PersonalService_RefreshPersonalToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"message", "personal", "token", "refresh"}, "")) - pattern_PersonalService_UpdatePersonalPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "password"}, "")) - pattern_PersonalService_UpdatePersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "profile"}, "")) - pattern_PersonalService_UpdatePersonalSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "setting"}, "")) -) - -var ( - forward_PersonalService_GetPersonalProfile_0 = runtime.ForwardResponseMessage - forward_PersonalService_ListPersonalResources_0 = runtime.ForwardResponseMessage - forward_PersonalService_ListPersonalRoles_0 = runtime.ForwardResponseMessage - forward_PersonalService_PersonalLogout_0 = runtime.ForwardResponseMessage - forward_PersonalService_RefreshPersonalToken_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalPassword_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalProfile_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalSetting_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/message/message.pb.validate.go b/api/v1/services/message/message.pb.validate.go deleted file mode 100644 index 772c5e54..00000000 --- a/api/v1/services/message/message.pb.validate.go +++ /dev/null @@ -1,2390 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: message/message.proto - -package message - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on UpdatePersonalSettingRequest 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 *UpdatePersonalSettingRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalSettingRequest 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 -// UpdatePersonalSettingRequestMultiError, or nil if none found. -func (m *UpdatePersonalSettingRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalSettingRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalSettingRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalSettingRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalSettingRequest.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalSettingRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalSettingRequestMultiError) 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 UpdatePersonalSettingRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalSettingRequestValidationError is the validation error returned -// by UpdatePersonalSettingRequest.Validate if the designated constraints -// aren't met. -type UpdatePersonalSettingRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalSettingRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalSettingRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalSettingRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalSettingRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalSettingRequestValidationError) ErrorName() string { - return "UpdatePersonalSettingRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalSettingRequestValidationError) 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 %sUpdatePersonalSettingRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalSettingRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalSettingRequestValidationError{} - -// Validate checks the field values on UpdatePersonalSettingResponse 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 *UpdatePersonalSettingResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalSettingResponse 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 -// UpdatePersonalSettingResponseMultiError, or nil if none found. -func (m *UpdatePersonalSettingResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalSettingResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalSettingResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalSettingResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalSettingResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalSettingResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalSettingResponseMultiError) 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 UpdatePersonalSettingResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalSettingResponseValidationError is the validation error -// returned by UpdatePersonalSettingResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalSettingResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalSettingResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalSettingResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalSettingResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalSettingResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalSettingResponseValidationError) ErrorName() string { - return "UpdatePersonalSettingResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalSettingResponseValidationError) 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 %sUpdatePersonalSettingResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalSettingResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalSettingResponseValidationError{} - -// Validate checks the field values on UpdatePersonalRoleRequest 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 *UpdatePersonalRoleRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalRoleRequest 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 -// UpdatePersonalRoleRequestMultiError, or nil if none found. -func (m *UpdatePersonalRoleRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalRoleRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalRoleRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalRoleRequestMultiError is an error wrapping multiple validation -// errors returned by UpdatePersonalRoleRequest.ValidateAll() if the -// designated constraints aren't met. -type UpdatePersonalRoleRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalRoleRequestMultiError) 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 UpdatePersonalRoleRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalRoleRequestValidationError is the validation error returned by -// UpdatePersonalRoleRequest.Validate if the designated constraints aren't met. -type UpdatePersonalRoleRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalRoleRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalRoleRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalRoleRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalRoleRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalRoleRequestValidationError) ErrorName() string { - return "UpdatePersonalRoleRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalRoleRequestValidationError) 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 %sUpdatePersonalRoleRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalRoleRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalRoleRequestValidationError{} - -// Validate checks the field values on UpdatePersonalRoleResponse 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 *UpdatePersonalRoleResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalRoleResponse 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 -// UpdatePersonalRoleResponseMultiError, or nil if none found. -func (m *UpdatePersonalRoleResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalRoleResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalRoleResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalRoleResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalRoleResponse.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalRoleResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalRoleResponseMultiError) 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 UpdatePersonalRoleResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalRoleResponseValidationError is the validation error returned -// by UpdatePersonalRoleResponse.Validate if the designated constraints aren't met. -type UpdatePersonalRoleResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalRoleResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalRoleResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalRoleResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalRoleResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalRoleResponseValidationError) ErrorName() string { - return "UpdatePersonalRoleResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalRoleResponseValidationError) 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 %sUpdatePersonalRoleResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalRoleResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalRoleResponseValidationError{} - -// Validate checks the field values on ListPersonalResourcesRequest 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 *ListPersonalResourcesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalResourcesRequest 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 -// ListPersonalResourcesRequestMultiError, or nil if none found. -func (m *ListPersonalResourcesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalResourcesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - if len(errors) > 0 { - return ListPersonalResourcesRequestMultiError(errors) - } - - return nil -} - -// ListPersonalResourcesRequestMultiError is an error wrapping multiple -// validation errors returned by ListPersonalResourcesRequest.ValidateAll() if -// the designated constraints aren't met. -type ListPersonalResourcesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalResourcesRequestMultiError) 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 ListPersonalResourcesRequestMultiError) AllErrors() []error { return m } - -// ListPersonalResourcesRequestValidationError is the validation error returned -// by ListPersonalResourcesRequest.Validate if the designated constraints -// aren't met. -type ListPersonalResourcesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalResourcesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalResourcesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalResourcesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalResourcesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalResourcesRequestValidationError) ErrorName() string { - return "ListPersonalResourcesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalResourcesRequestValidationError) 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 %sListPersonalResourcesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalResourcesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalResourcesRequestValidationError{} - -// Validate checks the field values on ListPersonalResourcesResponse 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 *ListPersonalResourcesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalResourcesResponse 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 -// ListPersonalResourcesResponseMultiError, or nil if none found. -func (m *ListPersonalResourcesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalResourcesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for NextPageToken - - if len(errors) > 0 { - return ListPersonalResourcesResponseMultiError(errors) - } - - return nil -} - -// ListPersonalResourcesResponseMultiError is an error wrapping multiple -// validation errors returned by ListPersonalResourcesResponse.ValidateAll() -// if the designated constraints aren't met. -type ListPersonalResourcesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalResourcesResponseMultiError) 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 ListPersonalResourcesResponseMultiError) AllErrors() []error { return m } - -// ListPersonalResourcesResponseValidationError is the validation error -// returned by ListPersonalResourcesResponse.Validate if the designated -// constraints aren't met. -type ListPersonalResourcesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalResourcesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalResourcesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalResourcesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalResourcesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalResourcesResponseValidationError) ErrorName() string { - return "ListPersonalResourcesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalResourcesResponseValidationError) 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 %sListPersonalResourcesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalResourcesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalResourcesResponseValidationError{} - -// Validate checks the field values on UpdatePersonalPasswordRequest 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 *UpdatePersonalPasswordRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalPasswordRequest 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 -// UpdatePersonalPasswordRequestMultiError, or nil if none found. -func (m *UpdatePersonalPasswordRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalPasswordRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalPasswordRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalPasswordRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalPasswordRequest.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalPasswordRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalPasswordRequestMultiError) 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 UpdatePersonalPasswordRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalPasswordRequestValidationError is the validation error -// returned by UpdatePersonalPasswordRequest.Validate if the designated -// constraints aren't met. -type UpdatePersonalPasswordRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalPasswordRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalPasswordRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalPasswordRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalPasswordRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalPasswordRequestValidationError) ErrorName() string { - return "UpdatePersonalPasswordRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalPasswordRequestValidationError) 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 %sUpdatePersonalPasswordRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalPasswordRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalPasswordRequestValidationError{} - -// Validate checks the field values on UpdatePersonalPasswordResponse 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 *UpdatePersonalPasswordResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalPasswordResponse 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 -// UpdatePersonalPasswordResponseMultiError, or nil if none found. -func (m *UpdatePersonalPasswordResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalPasswordResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalPasswordResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalPasswordResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalPasswordResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalPasswordResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalPasswordResponseMultiError) 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 UpdatePersonalPasswordResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalPasswordResponseValidationError is the validation error -// returned by UpdatePersonalPasswordResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalPasswordResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalPasswordResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalPasswordResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalPasswordResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalPasswordResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalPasswordResponseValidationError) ErrorName() string { - return "UpdatePersonalPasswordResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalPasswordResponseValidationError) 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 %sUpdatePersonalPasswordResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalPasswordResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalPasswordResponseValidationError{} - -// Validate checks the field values on PersonalPasswordRestRequest 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 *PersonalPasswordRestRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalPasswordRestRequest 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 -// PersonalPasswordRestRequestMultiError, or nil if none found. -func (m *PersonalPasswordRestRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalPasswordRestRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetId() <= 0 { - err := PersonalPasswordRestRequestValidationError{ - field: "Id", - reason: "value must be greater than 0", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return PersonalPasswordRestRequestMultiError(errors) - } - - return nil -} - -// PersonalPasswordRestRequestMultiError is an error wrapping multiple -// validation errors returned by PersonalPasswordRestRequest.ValidateAll() if -// the designated constraints aren't met. -type PersonalPasswordRestRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalPasswordRestRequestMultiError) 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 PersonalPasswordRestRequestMultiError) AllErrors() []error { return m } - -// PersonalPasswordRestRequestValidationError is the validation error returned -// by PersonalPasswordRestRequest.Validate if the designated constraints -// aren't met. -type PersonalPasswordRestRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalPasswordRestRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalPasswordRestRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalPasswordRestRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalPasswordRestRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalPasswordRestRequestValidationError) ErrorName() string { - return "PersonalPasswordRestRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalPasswordRestRequestValidationError) 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 %sPersonalPasswordRestRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalPasswordRestRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalPasswordRestRequestValidationError{} - -// Validate checks the field values on PersonalPasswordRestResponse 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 *PersonalPasswordRestResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalPasswordRestResponse 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 -// PersonalPasswordRestResponseMultiError, or nil if none found. -func (m *PersonalPasswordRestResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalPasswordRestResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return PersonalPasswordRestResponseMultiError(errors) - } - - return nil -} - -// PersonalPasswordRestResponseMultiError is an error wrapping multiple -// validation errors returned by PersonalPasswordRestResponse.ValidateAll() if -// the designated constraints aren't met. -type PersonalPasswordRestResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalPasswordRestResponseMultiError) 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 PersonalPasswordRestResponseMultiError) AllErrors() []error { return m } - -// PersonalPasswordRestResponseValidationError is the validation error returned -// by PersonalPasswordRestResponse.Validate if the designated constraints -// aren't met. -type PersonalPasswordRestResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalPasswordRestResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalPasswordRestResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalPasswordRestResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalPasswordRestResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalPasswordRestResponseValidationError) ErrorName() string { - return "PersonalPasswordRestResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalPasswordRestResponseValidationError) 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 %sPersonalPasswordRestResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalPasswordRestResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalPasswordRestResponseValidationError{} - -// Validate checks the field values on UpdatePersonalProfileRequest 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 *UpdatePersonalProfileRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalProfileRequest 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 -// UpdatePersonalProfileRequestMultiError, or nil if none found. -func (m *UpdatePersonalProfileRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalProfileRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalProfileRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalProfileRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalProfileRequest.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalProfileRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalProfileRequestMultiError) 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 UpdatePersonalProfileRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalProfileRequestValidationError is the validation error returned -// by UpdatePersonalProfileRequest.Validate if the designated constraints -// aren't met. -type UpdatePersonalProfileRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalProfileRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalProfileRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalProfileRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalProfileRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalProfileRequestValidationError) ErrorName() string { - return "UpdatePersonalProfileRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalProfileRequestValidationError) 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 %sUpdatePersonalProfileRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalProfileRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalProfileRequestValidationError{} - -// Validate checks the field values on UpdatePersonalProfileResponse 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 *UpdatePersonalProfileResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalProfileResponse 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 -// UpdatePersonalProfileResponseMultiError, or nil if none found. -func (m *UpdatePersonalProfileResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalProfileResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalProfileResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalProfileResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalProfileResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalProfileResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalProfileResponseMultiError) 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 UpdatePersonalProfileResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalProfileResponseValidationError is the validation error -// returned by UpdatePersonalProfileResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalProfileResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalProfileResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalProfileResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalProfileResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalProfileResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalProfileResponseValidationError) ErrorName() string { - return "UpdatePersonalProfileResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalProfileResponseValidationError) 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 %sUpdatePersonalProfileResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalProfileResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalProfileResponseValidationError{} - -// Validate checks the field values on PersonalLogoutRequest 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 *PersonalLogoutRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalLogoutRequest 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 -// PersonalLogoutRequestMultiError, or nil if none found. -func (m *PersonalLogoutRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalLogoutRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return PersonalLogoutRequestMultiError(errors) - } - - return nil -} - -// PersonalLogoutRequestMultiError is an error wrapping multiple validation -// errors returned by PersonalLogoutRequest.ValidateAll() if the designated -// constraints aren't met. -type PersonalLogoutRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalLogoutRequestMultiError) 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 PersonalLogoutRequestMultiError) AllErrors() []error { return m } - -// PersonalLogoutRequestValidationError is the validation error returned by -// PersonalLogoutRequest.Validate if the designated constraints aren't met. -type PersonalLogoutRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalLogoutRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalLogoutRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalLogoutRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalLogoutRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalLogoutRequestValidationError) ErrorName() string { - return "PersonalLogoutRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalLogoutRequestValidationError) 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 %sPersonalLogoutRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalLogoutRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalLogoutRequestValidationError{} - -// Validate checks the field values on PersonalLogoutResponse 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 *PersonalLogoutResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalLogoutResponse 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 -// PersonalLogoutResponseMultiError, or nil if none found. -func (m *PersonalLogoutResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalLogoutResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Success - - if len(errors) > 0 { - return PersonalLogoutResponseMultiError(errors) - } - - return nil -} - -// PersonalLogoutResponseMultiError is an error wrapping multiple validation -// errors returned by PersonalLogoutResponse.ValidateAll() if the designated -// constraints aren't met. -type PersonalLogoutResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalLogoutResponseMultiError) 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 PersonalLogoutResponseMultiError) AllErrors() []error { return m } - -// PersonalLogoutResponseValidationError is the validation error returned by -// PersonalLogoutResponse.Validate if the designated constraints aren't met. -type PersonalLogoutResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalLogoutResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalLogoutResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalLogoutResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalLogoutResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalLogoutResponseValidationError) ErrorName() string { - return "PersonalLogoutResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalLogoutResponseValidationError) 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 %sPersonalLogoutResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalLogoutResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalLogoutResponseValidationError{} - -// Validate checks the field values on ListPersonalRolesRequest 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 *ListPersonalRolesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalRolesRequest 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 -// ListPersonalRolesRequestMultiError, or nil if none found. -func (m *ListPersonalRolesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalRolesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return ListPersonalRolesRequestMultiError(errors) - } - - return nil -} - -// ListPersonalRolesRequestMultiError is an error wrapping multiple validation -// errors returned by ListPersonalRolesRequest.ValidateAll() if the designated -// constraints aren't met. -type ListPersonalRolesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalRolesRequestMultiError) 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 ListPersonalRolesRequestMultiError) AllErrors() []error { return m } - -// ListPersonalRolesRequestValidationError is the validation error returned by -// ListPersonalRolesRequest.Validate if the designated constraints aren't met. -type ListPersonalRolesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalRolesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalRolesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalRolesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalRolesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalRolesRequestValidationError) ErrorName() string { - return "ListPersonalRolesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalRolesRequestValidationError) 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 %sListPersonalRolesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalRolesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalRolesRequestValidationError{} - -// Validate checks the field values on ListPersonalRolesResponse 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 *ListPersonalRolesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalRolesResponse 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 -// ListPersonalRolesResponseMultiError, or nil if none found. -func (m *ListPersonalRolesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalRolesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListPersonalRolesResponseMultiError(errors) - } - - return nil -} - -// ListPersonalRolesResponseMultiError is an error wrapping multiple validation -// errors returned by ListPersonalRolesResponse.ValidateAll() if the -// designated constraints aren't met. -type ListPersonalRolesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalRolesResponseMultiError) 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 ListPersonalRolesResponseMultiError) AllErrors() []error { return m } - -// ListPersonalRolesResponseValidationError is the validation error returned by -// ListPersonalRolesResponse.Validate if the designated constraints aren't met. -type ListPersonalRolesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalRolesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalRolesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalRolesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalRolesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalRolesResponseValidationError) ErrorName() string { - return "ListPersonalRolesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalRolesResponseValidationError) 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 %sListPersonalRolesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalRolesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalRolesResponseValidationError{} - -// Validate checks the field values on GetPersonalProfileRequest 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 *GetPersonalProfileRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPersonalProfileRequest 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 -// GetPersonalProfileRequestMultiError, or nil if none found. -func (m *GetPersonalProfileRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPersonalProfileRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return GetPersonalProfileRequestMultiError(errors) - } - - return nil -} - -// GetPersonalProfileRequestMultiError is an error wrapping multiple validation -// errors returned by GetPersonalProfileRequest.ValidateAll() if the -// designated constraints aren't met. -type GetPersonalProfileRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPersonalProfileRequestMultiError) 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 GetPersonalProfileRequestMultiError) AllErrors() []error { return m } - -// GetPersonalProfileRequestValidationError is the validation error returned by -// GetPersonalProfileRequest.Validate if the designated constraints aren't met. -type GetPersonalProfileRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPersonalProfileRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPersonalProfileRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPersonalProfileRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPersonalProfileRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPersonalProfileRequestValidationError) ErrorName() string { - return "GetPersonalProfileRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPersonalProfileRequestValidationError) 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 %sGetPersonalProfileRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPersonalProfileRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPersonalProfileRequestValidationError{} - -// Validate checks the field values on GetPersonalProfileResponse 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 *GetPersonalProfileResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPersonalProfileResponse 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 -// GetPersonalProfileResponseMultiError, or nil if none found. -func (m *GetPersonalProfileResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPersonalProfileResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetPersonalProfileResponseMultiError(errors) - } - - return nil -} - -// GetPersonalProfileResponseMultiError is an error wrapping multiple -// validation errors returned by GetPersonalProfileResponse.ValidateAll() if -// the designated constraints aren't met. -type GetPersonalProfileResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPersonalProfileResponseMultiError) 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 GetPersonalProfileResponseMultiError) AllErrors() []error { return m } - -// GetPersonalProfileResponseValidationError is the validation error returned -// by GetPersonalProfileResponse.Validate if the designated constraints aren't met. -type GetPersonalProfileResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPersonalProfileResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPersonalProfileResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPersonalProfileResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPersonalProfileResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPersonalProfileResponseValidationError) ErrorName() string { - return "GetPersonalProfileResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPersonalProfileResponseValidationError) 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 %sGetPersonalProfileResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPersonalProfileResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPersonalProfileResponseValidationError{} - -// Validate checks the field values on RefreshPersonalTokenRequest 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 *RefreshPersonalTokenRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RefreshPersonalTokenRequest 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 -// RefreshPersonalTokenRequestMultiError, or nil if none found. -func (m *RefreshPersonalTokenRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *RefreshPersonalTokenRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RefreshPersonalTokenRequestMultiError(errors) - } - - return nil -} - -// RefreshPersonalTokenRequestMultiError is an error wrapping multiple -// validation errors returned by RefreshPersonalTokenRequest.ValidateAll() if -// the designated constraints aren't met. -type RefreshPersonalTokenRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RefreshPersonalTokenRequestMultiError) 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 RefreshPersonalTokenRequestMultiError) AllErrors() []error { return m } - -// RefreshPersonalTokenRequestValidationError is the validation error returned -// by RefreshPersonalTokenRequest.Validate if the designated constraints -// aren't met. -type RefreshPersonalTokenRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RefreshPersonalTokenRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RefreshPersonalTokenRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RefreshPersonalTokenRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RefreshPersonalTokenRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RefreshPersonalTokenRequestValidationError) ErrorName() string { - return "RefreshPersonalTokenRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e RefreshPersonalTokenRequestValidationError) 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 %sRefreshPersonalTokenRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RefreshPersonalTokenRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RefreshPersonalTokenRequestValidationError{} - -// Validate checks the field values on RefreshPersonalTokenResponse 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 *RefreshPersonalTokenResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RefreshPersonalTokenResponse 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 -// RefreshPersonalTokenResponseMultiError, or nil if none found. -func (m *RefreshPersonalTokenResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *RefreshPersonalTokenResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - if len(errors) > 0 { - return RefreshPersonalTokenResponseMultiError(errors) - } - - return nil -} - -// RefreshPersonalTokenResponseMultiError is an error wrapping multiple -// validation errors returned by RefreshPersonalTokenResponse.ValidateAll() if -// the designated constraints aren't met. -type RefreshPersonalTokenResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RefreshPersonalTokenResponseMultiError) 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 RefreshPersonalTokenResponseMultiError) AllErrors() []error { return m } - -// RefreshPersonalTokenResponseValidationError is the validation error returned -// by RefreshPersonalTokenResponse.Validate if the designated constraints -// aren't met. -type RefreshPersonalTokenResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RefreshPersonalTokenResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RefreshPersonalTokenResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RefreshPersonalTokenResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RefreshPersonalTokenResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RefreshPersonalTokenResponseValidationError) ErrorName() string { - return "RefreshPersonalTokenResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e RefreshPersonalTokenResponseValidationError) 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 %sRefreshPersonalTokenResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RefreshPersonalTokenResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RefreshPersonalTokenResponseValidationError{} diff --git a/api/v1/services/message/message_bridge.pb.go b/api/v1/services/message/message_bridge.pb.go deleted file mode 100644 index 14cefe32..00000000 --- a/api/v1/services/message/message_bridge.pb.go +++ /dev/null @@ -1,565 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: message/message.proto - -package message - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const PersonalServiceGetPersonalProfileBridgeOperation = "/api.v1.services.message.PersonalService/GetPersonalProfile" -const PersonalServiceListPersonalResourcesBridgeOperation = "/api.v1.services.message.PersonalService/ListPersonalResources" -const PersonalServiceListPersonalRolesBridgeOperation = "/api.v1.services.message.PersonalService/ListPersonalRoles" -const PersonalServicePersonalLogoutBridgeOperation = "/api.v1.services.message.PersonalService/PersonalLogout" -const PersonalServiceRefreshPersonalTokenBridgeOperation = "/api.v1.services.message.PersonalService/RefreshPersonalToken" -const PersonalServiceUpdatePersonalPasswordBridgeOperation = "/api.v1.services.message.PersonalService/UpdatePersonalPassword" -const PersonalServiceUpdatePersonalProfileBridgeOperation = "/api.v1.services.message.PersonalService/UpdatePersonalProfile" -const PersonalServiceUpdatePersonalSettingBridgeOperation = "/api.v1.services.message.PersonalService/UpdatePersonalSetting" - -type PersonalServiceBridgeServer interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) -} - -type PersonalServiceHooker interface { - PersonalServiceGetPersonalProfileHooker - PersonalServiceListPersonalResourcesHooker - PersonalServiceListPersonalRolesHooker - PersonalServicePersonalLogoutHooker - PersonalServiceRefreshPersonalTokenHooker - PersonalServiceUpdatePersonalPasswordHooker - PersonalServiceUpdatePersonalProfileHooker - PersonalServiceUpdatePersonalSettingHooker -} - -type PersonalServiceHookedBridger interface { - PersonalServiceHooker - PersonalServiceBridgeServer -} -type PersonalServiceGetPersonalProfileHooker interface { - PrepareGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) - CompleteGetPersonalProfile(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error -} -type PersonalServiceListPersonalResourcesHooker interface { - PrepareListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) - CompleteListPersonalResources(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error -} -type PersonalServiceListPersonalRolesHooker interface { - PrepareListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) - CompleteListPersonalRoles(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error -} -type PersonalServicePersonalLogoutHooker interface { - PreparePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) - CompletePersonalLogout(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error -} -type PersonalServiceRefreshPersonalTokenHooker interface { - PrepareRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) - CompleteRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error -} -type PersonalServiceUpdatePersonalPasswordHooker interface { - PrepareUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) - CompleteUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error -} -type PersonalServiceUpdatePersonalProfileHooker interface { - PrepareUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) - CompleteUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error -} -type PersonalServiceUpdatePersonalSettingHooker interface { - PrepareUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) - CompleteUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error -} - -func RegisterPersonalServiceBridgeServer(s *http.Server, srv PersonalServiceHookedBridger) { - r := s.Route("/") - r.GET("/message/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) - r.GET("/message/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) - r.GET("/message/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) - r.POST("/message/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(srv)) - r.POST("/message/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv)) - r.PUT("/message/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv)) - r.PUT("/message/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv)) - r.PUT("/message/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv)) -} - -func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPersonalProfileRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - }) - - newctx, err := srv.PrepareGetPersonalProfile(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetPersonalProfile(ctx, &in, out.(*GetPersonalProfileResponse)) - } -} - -func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - }) - - newctx, err := srv.PrepareListPersonalResources(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPersonalResources(ctx, &in, out.(*ListPersonalResourcesResponse)) - } -} - -func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalRolesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - }) - - newctx, err := srv.PrepareListPersonalRoles(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPersonalRoles(ctx, &in, out.(*ListPersonalRolesResponse)) - } -} - -func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in PersonalLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServicePersonalLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - }) - - newctx, err := srv.PreparePersonalLogout(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompletePersonalLogout(ctx, &in, out.(*PersonalLogoutResponse)) - } -} - -func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RefreshPersonalTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - }) - - newctx, err := srv.PrepareRefreshPersonalToken(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteRefreshPersonalToken(ctx, &in, out.(*RefreshPersonalTokenResponse)) - } -} - -func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalPassword(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalPassword(ctx, &in, out.(*UpdatePersonalPasswordResponse)) - } -} - -func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalProfileRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalProfile(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalProfile(ctx, &in, out.(*UpdatePersonalProfileResponse)) - } -} - -func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalSettingRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalSetting(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalSetting(ctx, &in, out.(*UpdatePersonalSettingResponse)) - } -} - -// UnimplementedPersonalServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPersonalServiceHooked struct{} - -func (UnimplementedPersonalServiceHooked) PrepareGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PreparePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompletePersonalLogout(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { - return ctx.Result(200, out) -} - -func WithPersonalServiceHook(h PersonalServiceHooker) func(PersonalServiceBridgeServer) PersonalServiceHookedBridger { - return func(srv PersonalServiceBridgeServer) PersonalServiceHookedBridger { - return PersonalServiceHookedBridge{PersonalServiceBridgeServer: srv, PersonalServiceHooker: h} - } -} - -// PersonalServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PersonalService. -// It implements the HTTP and gRPC implementations of PersonalService. -// It forwards requests and responses between the two implementations. -type PersonalServiceHookedBridge struct { - PersonalServiceBridgeServer - PersonalServiceHooker -} - -type PersonalServiceHTTPBridgeImpl struct { - client PersonalServiceHTTPClient -} - -func NewPersonalServiceHTTPBridge(client *http.Client) PersonalServiceHTTPServer { - return &PersonalServiceHTTPBridgeImpl{client: NewPersonalServiceHTTPClient(client)} -} - -func (c *PersonalServiceHTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -type PersonalServiceBridgeImpl struct { - client PersonalServiceClient -} - -func NewPersonalServiceBridge(client grpc.ClientConnInterface) PersonalServiceServer { - return &PersonalServiceBridgeImpl{client: NewPersonalServiceClient(client)} -} - -func (c *PersonalServiceBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} - -type PersonalServiceGRPC2HTTPBridgeImpl struct { - client PersonalServiceClient -} - -func NewPersonalServiceGRPC2HTTP(client grpc.ClientConnInterface) PersonalServiceHTTPServer { - return &PersonalServiceGRPC2HTTPBridgeImpl{client: NewPersonalServiceClient(client)} -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -type PersonalServiceHTTP2GRPCBridgeImpl struct { - client PersonalServiceHTTPClient -} - -func NewPersonalServiceHTTP2GRPC(client *http.Client) PersonalServiceServer { - return &PersonalServiceHTTP2GRPCBridgeImpl{client: NewPersonalServiceHTTPClient(client)} -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} diff --git a/api/v1/services/message/message_grpc.pb.go b/api/v1/services/message/message_grpc.pb.go deleted file mode 100644 index 2e0bc3e2..00000000 --- a/api/v1/services/message/message_grpc.pb.go +++ /dev/null @@ -1,407 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: message/message.proto - -package message - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - PersonalService_GetPersonalProfile_FullMethodName = "/api.v1.services.message.PersonalService/GetPersonalProfile" - PersonalService_ListPersonalResources_FullMethodName = "/api.v1.services.message.PersonalService/ListPersonalResources" - PersonalService_ListPersonalRoles_FullMethodName = "/api.v1.services.message.PersonalService/ListPersonalRoles" - PersonalService_PersonalLogout_FullMethodName = "/api.v1.services.message.PersonalService/PersonalLogout" - PersonalService_RefreshPersonalToken_FullMethodName = "/api.v1.services.message.PersonalService/RefreshPersonalToken" - PersonalService_UpdatePersonalPassword_FullMethodName = "/api.v1.services.message.PersonalService/UpdatePersonalPassword" - PersonalService_UpdatePersonalProfile_FullMethodName = "/api.v1.services.message.PersonalService/UpdatePersonalProfile" - PersonalService_UpdatePersonalSetting_FullMethodName = "/api.v1.services.message.PersonalService/UpdatePersonalSetting" -) - -// PersonalServiceClient is the client API for PersonalService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// PersonalService Personal user service -type PersonalServiceClient interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) -} - -type personalServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewPersonalServiceClient(cc grpc.ClientConnInterface) PersonalServiceClient { - return &personalServiceClient{cc} -} - -func (c *personalServiceClient) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetPersonalProfileResponse) - err := c.cc.Invoke(ctx, PersonalService_GetPersonalProfile_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPersonalResourcesResponse) - err := c.cc.Invoke(ctx, PersonalService_ListPersonalResources_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPersonalRolesResponse) - err := c.cc.Invoke(ctx, PersonalService_ListPersonalRoles_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(PersonalLogoutResponse) - err := c.cc.Invoke(ctx, PersonalService_PersonalLogout_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(RefreshPersonalTokenResponse) - err := c.cc.Invoke(ctx, PersonalService_RefreshPersonalToken_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalPasswordResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalPassword_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalProfileResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalProfile_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalSettingResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalSetting_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// PersonalServiceServer is the server API for PersonalService service. -// All implementations must embed UnimplementedPersonalServiceServer -// for forward compatibility. -// -// PersonalService Personal user service -type PersonalServiceServer interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) - mustEmbedUnimplementedPersonalServiceServer() -} - -// UnimplementedPersonalServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPersonalServiceServer struct{} - -func (UnimplementedPersonalServiceServer) GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetPersonalProfile not implemented") -} -func (UnimplementedPersonalServiceServer) ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPersonalResources not implemented") -} -func (UnimplementedPersonalServiceServer) ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPersonalRoles not implemented") -} -func (UnimplementedPersonalServiceServer) PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PersonalLogout not implemented") -} -func (UnimplementedPersonalServiceServer) RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RefreshPersonalToken not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalPassword not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalProfile not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalSetting not implemented") -} -func (UnimplementedPersonalServiceServer) mustEmbedUnimplementedPersonalServiceServer() {} -func (UnimplementedPersonalServiceServer) testEmbeddedByValue() {} - -// UnsafePersonalServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to PersonalServiceServer will -// result in compilation errors. -type UnsafePersonalServiceServer interface { - mustEmbedUnimplementedPersonalServiceServer() -} - -func RegisterPersonalServiceServer(s grpc.ServiceRegistrar, srv PersonalServiceServer) { - // If the following call pancis, it indicates UnimplementedPersonalServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&PersonalService_ServiceDesc, srv) -} - -func _PersonalService_GetPersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPersonalProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).GetPersonalProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_GetPersonalProfile_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_ListPersonalResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPersonalResourcesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).ListPersonalResources(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_ListPersonalResources_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_ListPersonalRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPersonalRolesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).ListPersonalRoles(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_ListPersonalRoles_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_PersonalLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PersonalLogoutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).PersonalLogout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_PersonalLogout_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_RefreshPersonalToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RefreshPersonalTokenRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_RefreshPersonalToken_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalPasswordRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalPassword_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalProfile_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalSettingRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalSetting_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// PersonalService_ServiceDesc is the grpc.ServiceDesc for PersonalService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var PersonalService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.message.PersonalService", - HandlerType: (*PersonalServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetPersonalProfile", - Handler: _PersonalService_GetPersonalProfile_Handler, - }, - { - MethodName: "ListPersonalResources", - Handler: _PersonalService_ListPersonalResources_Handler, - }, - { - MethodName: "ListPersonalRoles", - Handler: _PersonalService_ListPersonalRoles_Handler, - }, - { - MethodName: "PersonalLogout", - Handler: _PersonalService_PersonalLogout_Handler, - }, - { - MethodName: "RefreshPersonalToken", - Handler: _PersonalService_RefreshPersonalToken_Handler, - }, - { - MethodName: "UpdatePersonalPassword", - Handler: _PersonalService_UpdatePersonalPassword_Handler, - }, - { - MethodName: "UpdatePersonalProfile", - Handler: _PersonalService_UpdatePersonalProfile_Handler, - }, - { - MethodName: "UpdatePersonalSetting", - Handler: _PersonalService_UpdatePersonalSetting_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "message/message.proto", -} diff --git a/api/v1/services/message/message_http.pb.go b/api/v1/services/message/message_http.pb.go deleted file mode 100644 index a01701c9..00000000 --- a/api/v1/services/message/message_http.pb.go +++ /dev/null @@ -1,366 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: message/message.proto - -package message - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationPersonalServiceGetPersonalProfile = "/api.v1.services.message.PersonalService/GetPersonalProfile" -const OperationPersonalServiceListPersonalResources = "/api.v1.services.message.PersonalService/ListPersonalResources" -const OperationPersonalServiceListPersonalRoles = "/api.v1.services.message.PersonalService/ListPersonalRoles" -const OperationPersonalServicePersonalLogout = "/api.v1.services.message.PersonalService/PersonalLogout" -const OperationPersonalServiceRefreshPersonalToken = "/api.v1.services.message.PersonalService/RefreshPersonalToken" -const OperationPersonalServiceUpdatePersonalPassword = "/api.v1.services.message.PersonalService/UpdatePersonalPassword" -const OperationPersonalServiceUpdatePersonalProfile = "/api.v1.services.message.PersonalService/UpdatePersonalProfile" -const OperationPersonalServiceUpdatePersonalSetting = "/api.v1.services.message.PersonalService/UpdatePersonalSetting" - -type PersonalServiceHTTPServer interface { - // GetPersonalProfile GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalRoles ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) -} - -func RegisterPersonalServiceHTTPServer(s *http.Server, srv PersonalServiceHTTPServer) { - r := s.Route("/") - r.GET("/message/personal/profile", _PersonalService_GetPersonalProfile0_HTTP_Handler(srv)) - r.GET("/message/personal/resources", _PersonalService_ListPersonalResources0_HTTP_Handler(srv)) - r.GET("/message/personal/roles", _PersonalService_ListPersonalRoles0_HTTP_Handler(srv)) - r.POST("/message/personal/logout", _PersonalService_PersonalLogout0_HTTP_Handler(srv)) - r.POST("/message/personal/token/refresh", _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv)) - r.PUT("/message/personal/password", _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv)) - r.PUT("/message/personal/profile", _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv)) - r.PUT("/message/personal/setting", _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv)) -} - -func _PersonalService_GetPersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPersonalProfileRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetPersonalProfileResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_ListPersonalResources0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPersonalResourcesResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_ListPersonalRoles0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalRolesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPersonalRolesResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_PersonalLogout0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in PersonalLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServicePersonalLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*PersonalLogoutResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RefreshPersonalTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*RefreshPersonalTokenResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalPasswordResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalProfileRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalProfileResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalSettingRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalSettingResponse) - return ctx.Result(200, reply) - } -} - -type PersonalServiceHTTPClient interface { - // GetPersonalProfile GetPersonalProfile Update the personal user information - GetPersonalProfile(ctx context.Context, req *GetPersonalProfileRequest, opts ...http.CallOption) (rsp *GetPersonalProfileResponse, err error) - // ListPersonalResources ListPersonalResources List the personal user's menu - ListPersonalResources(ctx context.Context, req *ListPersonalResourcesRequest, opts ...http.CallOption) (rsp *ListPersonalResourcesResponse, err error) - // ListPersonalRoles ListPersonalResources List the personal user's menu - ListPersonalRoles(ctx context.Context, req *ListPersonalRolesRequest, opts ...http.CallOption) (rsp *ListPersonalRolesResponse, err error) - // PersonalLogout PersonalLogout Personal user logs out - PersonalLogout(ctx context.Context, req *PersonalLogoutRequest, opts ...http.CallOption) (rsp *PersonalLogoutResponse, err error) - // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(ctx context.Context, req *RefreshPersonalTokenRequest, opts ...http.CallOption) (rsp *RefreshPersonalTokenResponse, err error) - // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(ctx context.Context, req *UpdatePersonalPasswordRequest, opts ...http.CallOption) (rsp *UpdatePersonalPasswordResponse, err error) - // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(ctx context.Context, req *UpdatePersonalProfileRequest, opts ...http.CallOption) (rsp *UpdatePersonalProfileResponse, err error) - // UpdatePersonalSetting UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(ctx context.Context, req *UpdatePersonalSettingRequest, opts ...http.CallOption) (rsp *UpdatePersonalSettingResponse, err error) -} - -type PersonalServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewPersonalServiceHTTPClient(client *http.Client) PersonalServiceHTTPClient { - return &PersonalServiceHTTPClientImpl{client} -} - -// GetPersonalProfile GetPersonalProfile Update the personal user information -func (c *PersonalServiceHTTPClientImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...http.CallOption) (*GetPersonalProfileResponse, error) { - var out GetPersonalProfileResponse - pattern := "/message/personal/profile" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceGetPersonalProfile)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ListPersonalResources ListPersonalResources List the personal user's menu -func (c *PersonalServiceHTTPClientImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...http.CallOption) (*ListPersonalResourcesResponse, error) { - var out ListPersonalResourcesResponse - pattern := "/message/personal/resources" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceListPersonalResources)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ListPersonalRoles ListPersonalResources List the personal user's menu -func (c *PersonalServiceHTTPClientImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...http.CallOption) (*ListPersonalRolesResponse, error) { - var out ListPersonalRolesResponse - pattern := "/message/personal/roles" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceListPersonalRoles)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// PersonalLogout PersonalLogout Personal user logs out -func (c *PersonalServiceHTTPClientImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...http.CallOption) (*PersonalLogoutResponse, error) { - var out PersonalLogoutResponse - pattern := "/message/personal/logout" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServicePersonalLogout)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token -func (c *PersonalServiceHTTPClientImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...http.CallOption) (*RefreshPersonalTokenResponse, error) { - var out RefreshPersonalTokenResponse - pattern := "/message/personal/token/refresh" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceRefreshPersonalToken)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...http.CallOption) (*UpdatePersonalPasswordResponse, error) { - var out UpdatePersonalPasswordResponse - pattern := "/message/personal/password" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalPassword)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdatePersonalProfile UpdatePersonalProfile Update the personal user information -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...http.CallOption) (*UpdatePersonalProfileResponse, error) { - var out UpdatePersonalProfileResponse - pattern := "/message/personal/profile" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalProfile)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdatePersonalSetting UpdatePersonalSetting User settings are saved -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...http.CallOption) (*UpdatePersonalSettingResponse, error) { - var out UpdatePersonalSettingResponse - pattern := "/message/personal/setting" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalSetting)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/system/department.pb.go b/api/v1/services/system/department.pb.go deleted file mode 100644 index 79817e54..00000000 --- a/api/v1/services/system/department.pb.go +++ /dev/null @@ -1,738 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: system/department.proto - -package system - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ListDepartmentsRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListDepartmentsRequest) Reset() { - *x = ListDepartmentsRequest{} - mi := &file_system_department_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListDepartmentsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListDepartmentsRequest) ProtoMessage() {} - -func (x *ListDepartmentsRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_department_proto_msgTypes[0] - 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 ListDepartmentsRequest.ProtoReflect.Descriptor instead. -func (*ListDepartmentsRequest) Descriptor() ([]byte, []int) { - return file_system_department_proto_rawDescGZIP(), []int{0} -} - -func (x *ListDepartmentsRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListDepartmentsRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListDepartmentsRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListDepartmentsRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListDepartmentsRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListDepartmentsRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -type ListDepartmentsResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - // The paging menus - Departments []*types.Department `protobuf:"bytes,2,rep,name=departments,proto3" json:"departments,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListDepartmentsResponse) Reset() { - *x = ListDepartmentsResponse{} - mi := &file_system_department_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListDepartmentsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListDepartmentsResponse) ProtoMessage() {} - -func (x *ListDepartmentsResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_department_proto_msgTypes[1] - 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 ListDepartmentsResponse.ProtoReflect.Descriptor instead. -func (*ListDepartmentsResponse) Descriptor() ([]byte, []int) { - return file_system_department_proto_rawDescGZIP(), []int{1} -} - -func (x *ListDepartmentsResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListDepartmentsResponse) GetDepartments() []*types.Department { - if x != nil { - return x.Departments - } - return nil -} - -func (x *ListDepartmentsResponse) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListDepartmentsResponse) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListDepartmentsResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -func (x *ListDepartmentsResponse) GetExtra() *anypb.Any { - if x != nil { - return x.Extra - } - return nil -} - -type GetDepartmentRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/departments/department2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetDepartmentRequest) Reset() { - *x = GetDepartmentRequest{} - mi := &file_system_department_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetDepartmentRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetDepartmentRequest) ProtoMessage() {} - -func (x *GetDepartmentRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_department_proto_msgTypes[2] - 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 GetDepartmentRequest.ProtoReflect.Descriptor instead. -func (*GetDepartmentRequest) Descriptor() ([]byte, []int) { - return file_system_department_proto_rawDescGZIP(), []int{2} -} - -func (x *GetDepartmentRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type GetDepartmentResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Department *types.Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetDepartmentResponse) Reset() { - *x = GetDepartmentResponse{} - mi := &file_system_department_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetDepartmentResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetDepartmentResponse) ProtoMessage() {} - -func (x *GetDepartmentResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_department_proto_msgTypes[3] - 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 GetDepartmentResponse.ProtoReflect.Descriptor instead. -func (*GetDepartmentResponse) Descriptor() ([]byte, []int) { - return file_system_department_proto_rawDescGZIP(), []int{3} -} - -func (x *GetDepartmentResponse) GetDepartment() *types.Department { - if x != nil { - return x.Department - } - return nil -} - -type CreateDepartmentRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id where the department is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The department id to use for this department. - DepartmentId string `protobuf:"bytes,3,opt,name=department_id,proto3" json:"department_id,omitempty"` - // The department resource to create. - // The field id should match the Noun in the method id. - Department *types.Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateDepartmentRequest) Reset() { - *x = CreateDepartmentRequest{} - mi := &file_system_department_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateDepartmentRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateDepartmentRequest) ProtoMessage() {} - -func (x *CreateDepartmentRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_department_proto_msgTypes[4] - 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 CreateDepartmentRequest.ProtoReflect.Descriptor instead. -func (*CreateDepartmentRequest) Descriptor() ([]byte, []int) { - return file_system_department_proto_rawDescGZIP(), []int{4} -} - -func (x *CreateDepartmentRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreateDepartmentRequest) GetDepartmentId() string { - if x != nil { - return x.DepartmentId - } - return "" -} - -func (x *CreateDepartmentRequest) GetDepartment() *types.Department { - if x != nil { - return x.Department - } - return nil -} - -type CreateDepartmentResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Department *types.Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateDepartmentResponse) Reset() { - *x = CreateDepartmentResponse{} - mi := &file_system_department_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateDepartmentResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateDepartmentResponse) ProtoMessage() {} - -func (x *CreateDepartmentResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_department_proto_msgTypes[5] - 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 CreateDepartmentResponse.ProtoReflect.Descriptor instead. -func (*CreateDepartmentResponse) Descriptor() ([]byte, []int) { - return file_system_department_proto_rawDescGZIP(), []int{5} -} - -func (x *CreateDepartmentResponse) GetDepartment() *types.Department { - if x != nil { - return x.Department - } - return nil -} - -type UpdateDepartmentRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The department id to use for this department. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The department resource which replaces the resource on the server. - Department *types.Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateDepartmentRequest) Reset() { - *x = UpdateDepartmentRequest{} - mi := &file_system_department_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateDepartmentRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateDepartmentRequest) ProtoMessage() {} - -func (x *UpdateDepartmentRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_department_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 UpdateDepartmentRequest.ProtoReflect.Descriptor instead. -func (*UpdateDepartmentRequest) Descriptor() ([]byte, []int) { - return file_system_department_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdateDepartmentRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UpdateDepartmentRequest) GetDepartment() *types.Department { - if x != nil { - return x.Department - } - return nil -} - -type UpdateDepartmentResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Department *types.Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateDepartmentResponse) Reset() { - *x = UpdateDepartmentResponse{} - mi := &file_system_department_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateDepartmentResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateDepartmentResponse) ProtoMessage() {} - -func (x *UpdateDepartmentResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_department_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateDepartmentResponse.ProtoReflect.Descriptor instead. -func (*UpdateDepartmentResponse) Descriptor() ([]byte, []int) { - return file_system_department_proto_rawDescGZIP(), []int{7} -} - -func (x *UpdateDepartmentResponse) GetDepartment() *types.Department { - if x != nil { - return x.Department - } - return nil -} - -type DeleteDepartmentRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The resource id of the department to be deleted, for example: - // "shelves/shelf1/departments/department2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteDepartmentRequest) Reset() { - *x = DeleteDepartmentRequest{} - mi := &file_system_department_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteDepartmentRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteDepartmentRequest) ProtoMessage() {} - -func (x *DeleteDepartmentRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_department_proto_msgTypes[8] - 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 DeleteDepartmentRequest.ProtoReflect.Descriptor instead. -func (*DeleteDepartmentRequest) Descriptor() ([]byte, []int) { - return file_system_department_proto_rawDescGZIP(), []int{8} -} - -func (x *DeleteDepartmentRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type DeleteDepartmentResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteDepartmentResponse) Reset() { - *x = DeleteDepartmentResponse{} - mi := &file_system_department_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteDepartmentResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteDepartmentResponse) ProtoMessage() {} - -func (x *DeleteDepartmentResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_department_proto_msgTypes[9] - 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 DeleteDepartmentResponse.ProtoReflect.Descriptor instead. -func (*DeleteDepartmentResponse) Descriptor() ([]byte, []int) { - return file_system_department_proto_rawDescGZIP(), []int{9} -} - -func (x *DeleteDepartmentResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -var File_system_department_proto protoreflect.FileDescriptor - -const file_system_department_proto_rawDesc = "" + - "\n" + - "\x17system/department.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xbe\x01\n" + - "\x16ListDepartmentsRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\x9b\x02\n" + - "\x17ListDepartmentsResponse\x12\x1e\n" + - "\n" + - "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x12C\n" + - "\vdepartments\x18\x02 \x03(\v2!.api.v1.services.types.DepartmentR\vdepartments\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + - "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + - "\x06_extra\"&\n" + - "\x14GetDepartmentRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"Z\n" + - "\x15GetDepartmentResponse\x12A\n" + - "\n" + - "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + - "department\"\x9a\x01\n" + - "\x17CreateDepartmentRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12$\n" + - "\rdepartment_id\x18\x03 \x01(\tR\rdepartment_id\x12A\n" + - "\n" + - "department\x18\x02 \x01(\v2!.api.v1.services.types.DepartmentR\n" + - "department\"]\n" + - "\x18CreateDepartmentResponse\x12A\n" + - "\n" + - "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + - "department\"l\n" + - "\x17UpdateDepartmentRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12A\n" + - "\n" + - "department\x18\x02 \x01(\v2!.api.v1.services.types.DepartmentR\n" + - "department\"]\n" + - "\x18UpdateDepartmentResponse\x12A\n" + - "\n" + - "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + - "department\")\n" + - "\x17DeleteDepartmentRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + - "\x18DeleteDepartmentResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x93\x06\n" + - "\x11DepartmentService\x12\x8c\x01\n" + - "\x0fListDepartments\x12..api.v1.services.system.ListDepartmentsRequest\x1a/.api.v1.services.system.ListDepartmentsResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/departments\x12\x8b\x01\n" + - "\rGetDepartment\x12,.api.v1.services.system.GetDepartmentRequest\x1a-.api.v1.services.system.GetDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/departments/{id}\x12\x9b\x01\n" + - "\x10CreateDepartment\x12/.api.v1.services.system.CreateDepartmentRequest\x1a0.api.v1.services.system.CreateDepartmentResponse\"$\x82\xd3\xe4\x93\x02\x1e:\n" + - "department\"\x10/sys/departments\x12\xab\x01\n" + - "\x10UpdateDepartment\x12/.api.v1.services.system.UpdateDepartmentRequest\x1a0.api.v1.services.system.UpdateDepartmentResponse\"4\x82\xd3\xe4\x93\x02.:\n" + - "department\x1a /sys/departments/{department.id}\x12\x94\x01\n" + - "\x10DeleteDepartment\x12/.api.v1.services.system.DeleteDepartmentRequest\x1a0.api.v1.services.system.DeleteDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/departments/{id}B\xe4\x01\n" + - "\x1acom.api.v1.services.systemB\x0fDepartmentProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_department_proto_rawDescOnce sync.Once - file_system_department_proto_rawDescData []byte -) - -func file_system_department_proto_rawDescGZIP() []byte { - file_system_department_proto_rawDescOnce.Do(func() { - file_system_department_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_department_proto_rawDesc), len(file_system_department_proto_rawDesc))) - }) - return file_system_department_proto_rawDescData -} - -var file_system_department_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_system_department_proto_goTypes = []any{ - (*ListDepartmentsRequest)(nil), // 0: api.v1.services.system.ListDepartmentsRequest - (*ListDepartmentsResponse)(nil), // 1: api.v1.services.system.ListDepartmentsResponse - (*GetDepartmentRequest)(nil), // 2: api.v1.services.system.GetDepartmentRequest - (*GetDepartmentResponse)(nil), // 3: api.v1.services.system.GetDepartmentResponse - (*CreateDepartmentRequest)(nil), // 4: api.v1.services.system.CreateDepartmentRequest - (*CreateDepartmentResponse)(nil), // 5: api.v1.services.system.CreateDepartmentResponse - (*UpdateDepartmentRequest)(nil), // 6: api.v1.services.system.UpdateDepartmentRequest - (*UpdateDepartmentResponse)(nil), // 7: api.v1.services.system.UpdateDepartmentResponse - (*DeleteDepartmentRequest)(nil), // 8: api.v1.services.system.DeleteDepartmentRequest - (*DeleteDepartmentResponse)(nil), // 9: api.v1.services.system.DeleteDepartmentResponse - (*types.Department)(nil), // 10: api.v1.services.types.Department - (*anypb.Any)(nil), // 11: google.protobuf.Any - (*emptypb.Empty)(nil), // 12: google.protobuf.Empty -} -var file_system_department_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListDepartmentsResponse.departments:type_name -> api.v1.services.types.Department - 11, // 1: api.v1.services.system.ListDepartmentsResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetDepartmentResponse.department:type_name -> api.v1.services.types.Department - 10, // 3: api.v1.services.system.CreateDepartmentRequest.department:type_name -> api.v1.services.types.Department - 10, // 4: api.v1.services.system.CreateDepartmentResponse.department:type_name -> api.v1.services.types.Department - 10, // 5: api.v1.services.system.UpdateDepartmentRequest.department:type_name -> api.v1.services.types.Department - 10, // 6: api.v1.services.system.UpdateDepartmentResponse.department:type_name -> api.v1.services.types.Department - 12, // 7: api.v1.services.system.DeleteDepartmentResponse.empty:type_name -> google.protobuf.Empty - 0, // 8: api.v1.services.system.DepartmentService.ListDepartments:input_type -> api.v1.services.system.ListDepartmentsRequest - 2, // 9: api.v1.services.system.DepartmentService.GetDepartment:input_type -> api.v1.services.system.GetDepartmentRequest - 4, // 10: api.v1.services.system.DepartmentService.CreateDepartment:input_type -> api.v1.services.system.CreateDepartmentRequest - 6, // 11: api.v1.services.system.DepartmentService.UpdateDepartment:input_type -> api.v1.services.system.UpdateDepartmentRequest - 8, // 12: api.v1.services.system.DepartmentService.DeleteDepartment:input_type -> api.v1.services.system.DeleteDepartmentRequest - 1, // 13: api.v1.services.system.DepartmentService.ListDepartments:output_type -> api.v1.services.system.ListDepartmentsResponse - 3, // 14: api.v1.services.system.DepartmentService.GetDepartment:output_type -> api.v1.services.system.GetDepartmentResponse - 5, // 15: api.v1.services.system.DepartmentService.CreateDepartment:output_type -> api.v1.services.system.CreateDepartmentResponse - 7, // 16: api.v1.services.system.DepartmentService.UpdateDepartment:output_type -> api.v1.services.system.UpdateDepartmentResponse - 9, // 17: api.v1.services.system.DepartmentService.DeleteDepartment:output_type -> api.v1.services.system.DeleteDepartmentResponse - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_system_department_proto_init() } -func file_system_department_proto_init() { - if File_system_department_proto != nil { - return - } - file_system_department_proto_msgTypes[1].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_department_proto_rawDesc), len(file_system_department_proto_rawDesc)), - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_system_department_proto_goTypes, - DependencyIndexes: file_system_department_proto_depIdxs, - MessageInfos: file_system_department_proto_msgTypes, - }.Build() - File_system_department_proto = out.File - file_system_department_proto_goTypes = nil - file_system_department_proto_depIdxs = nil -} diff --git a/api/v1/services/system/department.pb.gw.go b/api/v1/services/system/department.pb.gw.go deleted file mode 100644 index 6a34e28f..00000000 --- a/api/v1/services/system/department.pb.gw.go +++ /dev/null @@ -1,487 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/department.proto - -/* -Package system is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package system - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_DepartmentService_ListDepartments_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_DepartmentService_ListDepartments_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListDepartmentsRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_ListDepartments_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListDepartments(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_DepartmentService_ListDepartments_0(ctx context.Context, marshaler runtime.Marshaler, server DepartmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListDepartmentsRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_ListDepartments_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListDepartments(ctx, &protoReq) - return msg, metadata, err -} - -func request_DepartmentService_GetDepartment_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetDepartmentRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetDepartment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_DepartmentService_GetDepartment_0(ctx context.Context, marshaler runtime.Marshaler, server DepartmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetDepartmentRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetDepartment(ctx, &protoReq) - return msg, metadata, err -} - -var filter_DepartmentService_CreateDepartment_0 = &utilities.DoubleArray{Encoding: map[string]int{"department": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - -func request_DepartmentService_CreateDepartment_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateDepartmentRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Department); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_CreateDepartment_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreateDepartment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_DepartmentService_CreateDepartment_0(ctx context.Context, marshaler runtime.Marshaler, server DepartmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateDepartmentRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Department); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_CreateDepartment_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreateDepartment(ctx, &protoReq) - return msg, metadata, err -} - -var filter_DepartmentService_UpdateDepartment_0 = &utilities.DoubleArray{Encoding: map[string]int{"department": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - -func request_DepartmentService_UpdateDepartment_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateDepartmentRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Department); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["department.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "department.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "department.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "department.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_UpdateDepartment_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdateDepartment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_DepartmentService_UpdateDepartment_0(ctx context.Context, marshaler runtime.Marshaler, server DepartmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateDepartmentRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Department); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["department.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "department.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "department.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "department.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_UpdateDepartment_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdateDepartment(ctx, &protoReq) - return msg, metadata, err -} - -func request_DepartmentService_DeleteDepartment_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteDepartmentRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.DeleteDepartment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_DepartmentService_DeleteDepartment_0(ctx context.Context, marshaler runtime.Marshaler, server DepartmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteDepartmentRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.DeleteDepartment(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterDepartmentServiceHandlerServer registers the http handlers for service DepartmentService to "mux". -// UnaryRPC :call DepartmentServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterDepartmentServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterDepartmentServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DepartmentServiceServer) error { - mux.Handle(http.MethodGet, pattern_DepartmentService_ListDepartments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/ListDepartments", runtime.WithHTTPPathPattern("/sys/departments")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_DepartmentService_ListDepartments_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DepartmentService_ListDepartments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_DepartmentService_GetDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/GetDepartment", runtime.WithHTTPPathPattern("/sys/departments/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_DepartmentService_GetDepartment_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DepartmentService_GetDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_DepartmentService_CreateDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/CreateDepartment", runtime.WithHTTPPathPattern("/sys/departments")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_DepartmentService_CreateDepartment_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DepartmentService_CreateDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_DepartmentService_UpdateDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/UpdateDepartment", runtime.WithHTTPPathPattern("/sys/departments/{department.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_DepartmentService_UpdateDepartment_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DepartmentService_UpdateDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_DepartmentService_DeleteDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/DeleteDepartment", runtime.WithHTTPPathPattern("/sys/departments/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_DepartmentService_DeleteDepartment_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DepartmentService_DeleteDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterDepartmentServiceHandlerFromEndpoint is same as RegisterDepartmentServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterDepartmentServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterDepartmentServiceHandler(ctx, mux, conn) -} - -// RegisterDepartmentServiceHandler registers the http handlers for service DepartmentService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterDepartmentServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterDepartmentServiceHandlerClient(ctx, mux, NewDepartmentServiceClient(conn)) -} - -// RegisterDepartmentServiceHandlerClient registers the http handlers for service DepartmentService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DepartmentServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DepartmentServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "DepartmentServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterDepartmentServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DepartmentServiceClient) error { - mux.Handle(http.MethodGet, pattern_DepartmentService_ListDepartments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/ListDepartments", runtime.WithHTTPPathPattern("/sys/departments")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_DepartmentService_ListDepartments_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DepartmentService_ListDepartments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_DepartmentService_GetDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/GetDepartment", runtime.WithHTTPPathPattern("/sys/departments/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_DepartmentService_GetDepartment_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DepartmentService_GetDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_DepartmentService_CreateDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/CreateDepartment", runtime.WithHTTPPathPattern("/sys/departments")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_DepartmentService_CreateDepartment_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DepartmentService_CreateDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_DepartmentService_UpdateDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/UpdateDepartment", runtime.WithHTTPPathPattern("/sys/departments/{department.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_DepartmentService_UpdateDepartment_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DepartmentService_UpdateDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_DepartmentService_DeleteDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/DeleteDepartment", runtime.WithHTTPPathPattern("/sys/departments/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_DepartmentService_DeleteDepartment_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_DepartmentService_DeleteDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_DepartmentService_ListDepartments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "departments"}, "")) - pattern_DepartmentService_GetDepartment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "departments", "id"}, "")) - pattern_DepartmentService_CreateDepartment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "departments"}, "")) - pattern_DepartmentService_UpdateDepartment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "departments", "department.id"}, "")) - pattern_DepartmentService_DeleteDepartment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "departments", "id"}, "")) -) - -var ( - forward_DepartmentService_ListDepartments_0 = runtime.ForwardResponseMessage - forward_DepartmentService_GetDepartment_0 = runtime.ForwardResponseMessage - forward_DepartmentService_CreateDepartment_0 = runtime.ForwardResponseMessage - forward_DepartmentService_UpdateDepartment_0 = runtime.ForwardResponseMessage - forward_DepartmentService_DeleteDepartment_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/system/department.pb.validate.go b/api/v1/services/system/department.pb.validate.go deleted file mode 100644 index 3c32bc5e..00000000 --- a/api/v1/services/system/department.pb.validate.go +++ /dev/null @@ -1,1327 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/department.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListDepartmentsRequest 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 *ListDepartmentsRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListDepartmentsRequest 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 -// ListDepartmentsRequestMultiError, or nil if none found. -func (m *ListDepartmentsRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListDepartmentsRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - if len(errors) > 0 { - return ListDepartmentsRequestMultiError(errors) - } - - return nil -} - -// ListDepartmentsRequestMultiError is an error wrapping multiple validation -// errors returned by ListDepartmentsRequest.ValidateAll() if the designated -// constraints aren't met. -type ListDepartmentsRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListDepartmentsRequestMultiError) 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 ListDepartmentsRequestMultiError) AllErrors() []error { return m } - -// ListDepartmentsRequestValidationError is the validation error returned by -// ListDepartmentsRequest.Validate if the designated constraints aren't met. -type ListDepartmentsRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListDepartmentsRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListDepartmentsRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListDepartmentsRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListDepartmentsRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListDepartmentsRequestValidationError) ErrorName() string { - return "ListDepartmentsRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListDepartmentsRequestValidationError) 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 %sListDepartmentsRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListDepartmentsRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListDepartmentsRequestValidationError{} - -// Validate checks the field values on ListDepartmentsResponse 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 *ListDepartmentsResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListDepartmentsResponse 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 -// ListDepartmentsResponseMultiError, or nil if none found. -func (m *ListDepartmentsResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListDepartmentsResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetDepartments() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListDepartmentsResponseValidationError{ - field: fmt.Sprintf("Departments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListDepartmentsResponseValidationError{ - field: fmt.Sprintf("Departments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListDepartmentsResponseValidationError{ - field: fmt.Sprintf("Departments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for NextPageToken - - if m.Extra != nil { - - if all { - switch v := interface{}(m.GetExtra()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListDepartmentsResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListDepartmentsResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListDepartmentsResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListDepartmentsResponseMultiError(errors) - } - - return nil -} - -// ListDepartmentsResponseMultiError is an error wrapping multiple validation -// errors returned by ListDepartmentsResponse.ValidateAll() if the designated -// constraints aren't met. -type ListDepartmentsResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListDepartmentsResponseMultiError) 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 ListDepartmentsResponseMultiError) AllErrors() []error { return m } - -// ListDepartmentsResponseValidationError is the validation error returned by -// ListDepartmentsResponse.Validate if the designated constraints aren't met. -type ListDepartmentsResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListDepartmentsResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListDepartmentsResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListDepartmentsResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListDepartmentsResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListDepartmentsResponseValidationError) ErrorName() string { - return "ListDepartmentsResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListDepartmentsResponseValidationError) 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 %sListDepartmentsResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListDepartmentsResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListDepartmentsResponseValidationError{} - -// Validate checks the field values on GetDepartmentRequest 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 *GetDepartmentRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetDepartmentRequest 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 -// GetDepartmentRequestMultiError, or nil if none found. -func (m *GetDepartmentRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetDepartmentRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return GetDepartmentRequestMultiError(errors) - } - - return nil -} - -// GetDepartmentRequestMultiError is an error wrapping multiple validation -// errors returned by GetDepartmentRequest.ValidateAll() if the designated -// constraints aren't met. -type GetDepartmentRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetDepartmentRequestMultiError) 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 GetDepartmentRequestMultiError) AllErrors() []error { return m } - -// GetDepartmentRequestValidationError is the validation error returned by -// GetDepartmentRequest.Validate if the designated constraints aren't met. -type GetDepartmentRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetDepartmentRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetDepartmentRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetDepartmentRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetDepartmentRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetDepartmentRequestValidationError) ErrorName() string { - return "GetDepartmentRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetDepartmentRequestValidationError) 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 %sGetDepartmentRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetDepartmentRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetDepartmentRequestValidationError{} - -// Validate checks the field values on GetDepartmentResponse 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 *GetDepartmentResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetDepartmentResponse 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 -// GetDepartmentResponseMultiError, or nil if none found. -func (m *GetDepartmentResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetDepartmentResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetDepartmentResponseValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetDepartmentResponseValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetDepartmentResponseValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetDepartmentResponseMultiError(errors) - } - - return nil -} - -// GetDepartmentResponseMultiError is an error wrapping multiple validation -// errors returned by GetDepartmentResponse.ValidateAll() if the designated -// constraints aren't met. -type GetDepartmentResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetDepartmentResponseMultiError) 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 GetDepartmentResponseMultiError) AllErrors() []error { return m } - -// GetDepartmentResponseValidationError is the validation error returned by -// GetDepartmentResponse.Validate if the designated constraints aren't met. -type GetDepartmentResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetDepartmentResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetDepartmentResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetDepartmentResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetDepartmentResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetDepartmentResponseValidationError) ErrorName() string { - return "GetDepartmentResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetDepartmentResponseValidationError) 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 %sGetDepartmentResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetDepartmentResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetDepartmentResponseValidationError{} - -// Validate checks the field values on CreateDepartmentRequest 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 *CreateDepartmentRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateDepartmentRequest 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 -// CreateDepartmentRequestMultiError, or nil if none found. -func (m *CreateDepartmentRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateDepartmentRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Parent - - // no validation rules for DepartmentId - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateDepartmentRequestValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateDepartmentRequestValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateDepartmentRequestValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateDepartmentRequestMultiError(errors) - } - - return nil -} - -// CreateDepartmentRequestMultiError is an error wrapping multiple validation -// errors returned by CreateDepartmentRequest.ValidateAll() if the designated -// constraints aren't met. -type CreateDepartmentRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateDepartmentRequestMultiError) 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 CreateDepartmentRequestMultiError) AllErrors() []error { return m } - -// CreateDepartmentRequestValidationError is the validation error returned by -// CreateDepartmentRequest.Validate if the designated constraints aren't met. -type CreateDepartmentRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateDepartmentRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateDepartmentRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateDepartmentRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateDepartmentRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateDepartmentRequestValidationError) ErrorName() string { - return "CreateDepartmentRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateDepartmentRequestValidationError) 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 %sCreateDepartmentRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateDepartmentRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateDepartmentRequestValidationError{} - -// Validate checks the field values on CreateDepartmentResponse 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 *CreateDepartmentResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateDepartmentResponse 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 -// CreateDepartmentResponseMultiError, or nil if none found. -func (m *CreateDepartmentResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateDepartmentResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateDepartmentResponseValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateDepartmentResponseValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateDepartmentResponseValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateDepartmentResponseMultiError(errors) - } - - return nil -} - -// CreateDepartmentResponseMultiError is an error wrapping multiple validation -// errors returned by CreateDepartmentResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateDepartmentResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateDepartmentResponseMultiError) 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 CreateDepartmentResponseMultiError) AllErrors() []error { return m } - -// CreateDepartmentResponseValidationError is the validation error returned by -// CreateDepartmentResponse.Validate if the designated constraints aren't met. -type CreateDepartmentResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateDepartmentResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateDepartmentResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateDepartmentResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateDepartmentResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateDepartmentResponseValidationError) ErrorName() string { - return "CreateDepartmentResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateDepartmentResponseValidationError) 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 %sCreateDepartmentResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateDepartmentResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateDepartmentResponseValidationError{} - -// Validate checks the field values on UpdateDepartmentRequest 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 *UpdateDepartmentRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateDepartmentRequest 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 -// UpdateDepartmentRequestMultiError, or nil if none found. -func (m *UpdateDepartmentRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateDepartmentRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateDepartmentRequestValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateDepartmentRequestValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateDepartmentRequestValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateDepartmentRequestMultiError(errors) - } - - return nil -} - -// UpdateDepartmentRequestMultiError is an error wrapping multiple validation -// errors returned by UpdateDepartmentRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateDepartmentRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateDepartmentRequestMultiError) 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 UpdateDepartmentRequestMultiError) AllErrors() []error { return m } - -// UpdateDepartmentRequestValidationError is the validation error returned by -// UpdateDepartmentRequest.Validate if the designated constraints aren't met. -type UpdateDepartmentRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateDepartmentRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateDepartmentRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateDepartmentRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateDepartmentRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateDepartmentRequestValidationError) ErrorName() string { - return "UpdateDepartmentRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateDepartmentRequestValidationError) 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 %sUpdateDepartmentRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateDepartmentRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateDepartmentRequestValidationError{} - -// Validate checks the field values on UpdateDepartmentResponse 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 *UpdateDepartmentResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateDepartmentResponse 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 -// UpdateDepartmentResponseMultiError, or nil if none found. -func (m *UpdateDepartmentResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateDepartmentResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateDepartmentResponseValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateDepartmentResponseValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateDepartmentResponseValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateDepartmentResponseMultiError(errors) - } - - return nil -} - -// UpdateDepartmentResponseMultiError is an error wrapping multiple validation -// errors returned by UpdateDepartmentResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateDepartmentResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateDepartmentResponseMultiError) 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 UpdateDepartmentResponseMultiError) AllErrors() []error { return m } - -// UpdateDepartmentResponseValidationError is the validation error returned by -// UpdateDepartmentResponse.Validate if the designated constraints aren't met. -type UpdateDepartmentResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateDepartmentResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateDepartmentResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateDepartmentResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateDepartmentResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateDepartmentResponseValidationError) ErrorName() string { - return "UpdateDepartmentResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateDepartmentResponseValidationError) 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 %sUpdateDepartmentResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateDepartmentResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateDepartmentResponseValidationError{} - -// Validate checks the field values on DeleteDepartmentRequest 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 *DeleteDepartmentRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteDepartmentRequest 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 -// DeleteDepartmentRequestMultiError, or nil if none found. -func (m *DeleteDepartmentRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteDepartmentRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return DeleteDepartmentRequestMultiError(errors) - } - - return nil -} - -// DeleteDepartmentRequestMultiError is an error wrapping multiple validation -// errors returned by DeleteDepartmentRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteDepartmentRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteDepartmentRequestMultiError) 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 DeleteDepartmentRequestMultiError) AllErrors() []error { return m } - -// DeleteDepartmentRequestValidationError is the validation error returned by -// DeleteDepartmentRequest.Validate if the designated constraints aren't met. -type DeleteDepartmentRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteDepartmentRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteDepartmentRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteDepartmentRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteDepartmentRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteDepartmentRequestValidationError) ErrorName() string { - return "DeleteDepartmentRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteDepartmentRequestValidationError) 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 %sDeleteDepartmentRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteDepartmentRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteDepartmentRequestValidationError{} - -// Validate checks the field values on DeleteDepartmentResponse 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 *DeleteDepartmentResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteDepartmentResponse 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 -// DeleteDepartmentResponseMultiError, or nil if none found. -func (m *DeleteDepartmentResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteDepartmentResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteDepartmentResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteDepartmentResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteDepartmentResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteDepartmentResponseMultiError(errors) - } - - return nil -} - -// DeleteDepartmentResponseMultiError is an error wrapping multiple validation -// errors returned by DeleteDepartmentResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteDepartmentResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteDepartmentResponseMultiError) 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 DeleteDepartmentResponseMultiError) AllErrors() []error { return m } - -// DeleteDepartmentResponseValidationError is the validation error returned by -// DeleteDepartmentResponse.Validate if the designated constraints aren't met. -type DeleteDepartmentResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteDepartmentResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteDepartmentResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteDepartmentResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteDepartmentResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteDepartmentResponseValidationError) ErrorName() string { - return "DeleteDepartmentResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteDepartmentResponseValidationError) 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 %sDeleteDepartmentResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteDepartmentResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteDepartmentResponseValidationError{} diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go deleted file mode 100644 index 65ca7403..00000000 --- a/api/v1/services/system/department_bridge.pb.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: system/department.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const DepartmentServiceCreateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/CreateDepartment" -const DepartmentServiceDeleteDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/DeleteDepartment" -const DepartmentServiceGetDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/GetDepartment" -const DepartmentServiceListDepartmentsBridgeOperation = "/api.v1.services.system.DepartmentService/ListDepartments" -const DepartmentServiceUpdateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/UpdateDepartment" - -type DepartmentServiceBridgeServer interface { - CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) - DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) - GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) - ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) - UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) -} - -type DepartmentServiceHooker interface { - DepartmentServiceCreateDepartmentHooker - DepartmentServiceDeleteDepartmentHooker - DepartmentServiceGetDepartmentHooker - DepartmentServiceListDepartmentsHooker - DepartmentServiceUpdateDepartmentHooker -} - -type DepartmentServiceHookedBridger interface { - DepartmentServiceHooker - DepartmentServiceBridgeServer -} -type DepartmentServiceCreateDepartmentHooker interface { - PrepareCreateDepartment(http.Context, *CreateDepartmentRequest) (context.Context, error) - CompleteCreateDepartment(http.Context, *CreateDepartmentRequest, *CreateDepartmentResponse) error -} -type DepartmentServiceDeleteDepartmentHooker interface { - PrepareDeleteDepartment(http.Context, *DeleteDepartmentRequest) (context.Context, error) - CompleteDeleteDepartment(http.Context, *DeleteDepartmentRequest, *DeleteDepartmentResponse) error -} -type DepartmentServiceGetDepartmentHooker interface { - PrepareGetDepartment(http.Context, *GetDepartmentRequest) (context.Context, error) - CompleteGetDepartment(http.Context, *GetDepartmentRequest, *GetDepartmentResponse) error -} -type DepartmentServiceListDepartmentsHooker interface { - PrepareListDepartments(http.Context, *ListDepartmentsRequest) (context.Context, error) - CompleteListDepartments(http.Context, *ListDepartmentsRequest, *ListDepartmentsResponse) error -} -type DepartmentServiceUpdateDepartmentHooker interface { - PrepareUpdateDepartment(http.Context, *UpdateDepartmentRequest) (context.Context, error) - CompleteUpdateDepartment(http.Context, *UpdateDepartmentRequest, *UpdateDepartmentResponse) error -} - -func RegisterDepartmentServiceBridgeServer(s *http.Server, srv DepartmentServiceHookedBridger) { - r := s.Route("/") - r.GET("/sys/departments", _DepartmentService_ListDepartments0_Bridge_Handler(srv)) - r.GET("/sys/departments/:id", _DepartmentService_GetDepartment0_Bridge_Handler(srv)) - r.POST("/sys/departments", _DepartmentService_CreateDepartment0_Bridge_Handler(srv)) - r.PUT("/sys/departments/:department.id", _DepartmentService_UpdateDepartment0_Bridge_Handler(srv)) - r.DELETE("/sys/departments/:id", _DepartmentService_DeleteDepartment0_Bridge_Handler(srv)) -} - -func _DepartmentService_ListDepartments0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListDepartmentsRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDepartmentServiceListDepartments) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListDepartments(ctx, req.(*ListDepartmentsRequest)) - }) - - newctx, err := srv.PrepareListDepartments(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListDepartments(ctx, &in, out.(*ListDepartmentsResponse)) - } -} - -func _DepartmentService_GetDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetDepartmentRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDepartmentServiceGetDepartment) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetDepartment(ctx, req.(*GetDepartmentRequest)) - }) - - newctx, err := srv.PrepareGetDepartment(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetDepartment(ctx, &in, out.(*GetDepartmentResponse)) - } -} - -func _DepartmentService_CreateDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateDepartmentRequest - if err := ctx.Bind(&in.Department); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDepartmentServiceCreateDepartment) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateDepartment(ctx, req.(*CreateDepartmentRequest)) - }) - - newctx, err := srv.PrepareCreateDepartment(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreateDepartment(ctx, &in, out.(*CreateDepartmentResponse)) - } -} - -func _DepartmentService_UpdateDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateDepartmentRequest - if err := ctx.Bind(&in.Department); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDepartmentServiceUpdateDepartment) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateDepartment(ctx, req.(*UpdateDepartmentRequest)) - }) - - newctx, err := srv.PrepareUpdateDepartment(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateDepartment(ctx, &in, out.(*UpdateDepartmentResponse)) - } -} - -func _DepartmentService_DeleteDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteDepartmentRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDepartmentServiceDeleteDepartment) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteDepartment(ctx, req.(*DeleteDepartmentRequest)) - }) - - newctx, err := srv.PrepareDeleteDepartment(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeleteDepartment(ctx, &in, out.(*DeleteDepartmentResponse)) - } -} - -// UnimplementedDepartmentServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedDepartmentServiceHooked struct{} - -func (UnimplementedDepartmentServiceHooked) PrepareCreateDepartment(ctx http.Context, in *CreateDepartmentRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedDepartmentServiceHooked) CompleteCreateDepartment(ctx http.Context, in *CreateDepartmentRequest, out *CreateDepartmentResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedDepartmentServiceHooked) PrepareDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedDepartmentServiceHooked) CompleteDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest, out *DeleteDepartmentResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedDepartmentServiceHooked) PrepareGetDepartment(ctx http.Context, in *GetDepartmentRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedDepartmentServiceHooked) CompleteGetDepartment(ctx http.Context, in *GetDepartmentRequest, out *GetDepartmentResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedDepartmentServiceHooked) PrepareListDepartments(ctx http.Context, in *ListDepartmentsRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedDepartmentServiceHooked) CompleteListDepartments(ctx http.Context, in *ListDepartmentsRequest, out *ListDepartmentsResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedDepartmentServiceHooked) PrepareUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedDepartmentServiceHooked) CompleteUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest, out *UpdateDepartmentResponse) error { - return ctx.Result(200, out) -} - -func WithDepartmentServiceHook(h DepartmentServiceHooker) func(DepartmentServiceBridgeServer) DepartmentServiceHookedBridger { - return func(srv DepartmentServiceBridgeServer) DepartmentServiceHookedBridger { - return DepartmentServiceHookedBridge{DepartmentServiceBridgeServer: srv, DepartmentServiceHooker: h} - } -} - -// DepartmentServiceHookedBridge is a bridge between the HTTP and gRPC implementations of DepartmentService. -// It implements the HTTP and gRPC implementations of DepartmentService. -// It forwards requests and responses between the two implementations. -type DepartmentServiceHookedBridge struct { - DepartmentServiceBridgeServer - DepartmentServiceHooker -} - -type DepartmentServiceHTTPBridgeImpl struct { - client DepartmentServiceHTTPClient -} - -func NewDepartmentServiceHTTPBridge(client *http.Client) DepartmentServiceHTTPServer { - return &DepartmentServiceHTTPBridgeImpl{client: NewDepartmentServiceHTTPClient(client)} -} - -func (c *DepartmentServiceHTTPBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { - return c.client.CreateDepartment(ctx, in) -} - -func (c *DepartmentServiceHTTPBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { - return c.client.DeleteDepartment(ctx, in) -} - -func (c *DepartmentServiceHTTPBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { - return c.client.GetDepartment(ctx, in) -} - -func (c *DepartmentServiceHTTPBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { - return c.client.ListDepartments(ctx, in) -} - -func (c *DepartmentServiceHTTPBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { - return c.client.UpdateDepartment(ctx, in) -} - -type DepartmentServiceBridgeImpl struct { - client DepartmentServiceClient -} - -func NewDepartmentServiceBridge(client grpc.ClientConnInterface) DepartmentServiceServer { - return &DepartmentServiceBridgeImpl{client: NewDepartmentServiceClient(client)} -} - -func (c *DepartmentServiceBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { - return c.client.CreateDepartment(ctx, in) -} - -func (c *DepartmentServiceBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { - return c.client.DeleteDepartment(ctx, in) -} - -func (c *DepartmentServiceBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { - return c.client.GetDepartment(ctx, in) -} - -func (c *DepartmentServiceBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { - return c.client.ListDepartments(ctx, in) -} - -func (c *DepartmentServiceBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { - return c.client.UpdateDepartment(ctx, in) -} - -func (c *DepartmentServiceBridgeImpl) mustEmbedUnimplementedDepartmentServiceServer() {} - -type DepartmentServiceGRPC2HTTPBridgeImpl struct { - client DepartmentServiceClient -} - -func NewDepartmentServiceGRPC2HTTP(client grpc.ClientConnInterface) DepartmentServiceHTTPServer { - return &DepartmentServiceGRPC2HTTPBridgeImpl{client: NewDepartmentServiceClient(client)} -} - -func (c *DepartmentServiceGRPC2HTTPBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { - return c.client.CreateDepartment(ctx, in) -} - -func (c *DepartmentServiceGRPC2HTTPBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { - return c.client.DeleteDepartment(ctx, in) -} - -func (c *DepartmentServiceGRPC2HTTPBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { - return c.client.GetDepartment(ctx, in) -} - -func (c *DepartmentServiceGRPC2HTTPBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { - return c.client.ListDepartments(ctx, in) -} - -func (c *DepartmentServiceGRPC2HTTPBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { - return c.client.UpdateDepartment(ctx, in) -} - -type DepartmentServiceHTTP2GRPCBridgeImpl struct { - client DepartmentServiceHTTPClient -} - -func NewDepartmentServiceHTTP2GRPC(client *http.Client) DepartmentServiceServer { - return &DepartmentServiceHTTP2GRPCBridgeImpl{client: NewDepartmentServiceHTTPClient(client)} -} - -func (c *DepartmentServiceHTTP2GRPCBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { - return c.client.CreateDepartment(ctx, in) -} - -func (c *DepartmentServiceHTTP2GRPCBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { - return c.client.DeleteDepartment(ctx, in) -} - -func (c *DepartmentServiceHTTP2GRPCBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { - return c.client.GetDepartment(ctx, in) -} - -func (c *DepartmentServiceHTTP2GRPCBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { - return c.client.ListDepartments(ctx, in) -} - -func (c *DepartmentServiceHTTP2GRPCBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { - return c.client.UpdateDepartment(ctx, in) -} - -func (c *DepartmentServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedDepartmentServiceServer() {} diff --git a/api/v1/services/system/department_grpc.pb.go b/api/v1/services/system/department_grpc.pb.go deleted file mode 100644 index 0372a61a..00000000 --- a/api/v1/services/system/department_grpc.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: system/department.proto - -package system - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - DepartmentService_ListDepartments_FullMethodName = "/api.v1.services.system.DepartmentService/ListDepartments" - DepartmentService_GetDepartment_FullMethodName = "/api.v1.services.system.DepartmentService/GetDepartment" - DepartmentService_CreateDepartment_FullMethodName = "/api.v1.services.system.DepartmentService/CreateDepartment" - DepartmentService_UpdateDepartment_FullMethodName = "/api.v1.services.system.DepartmentService/UpdateDepartment" - DepartmentService_DeleteDepartment_FullMethodName = "/api.v1.services.system.DepartmentService/DeleteDepartment" -) - -// DepartmentServiceClient is the client API for DepartmentService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The login service definition. -type DepartmentServiceClient interface { - ListDepartments(ctx context.Context, in *ListDepartmentsRequest, opts ...grpc.CallOption) (*ListDepartmentsResponse, error) - GetDepartment(ctx context.Context, in *GetDepartmentRequest, opts ...grpc.CallOption) (*GetDepartmentResponse, error) - CreateDepartment(ctx context.Context, in *CreateDepartmentRequest, opts ...grpc.CallOption) (*CreateDepartmentResponse, error) - UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest, opts ...grpc.CallOption) (*UpdateDepartmentResponse, error) - DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest, opts ...grpc.CallOption) (*DeleteDepartmentResponse, error) -} - -type departmentServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewDepartmentServiceClient(cc grpc.ClientConnInterface) DepartmentServiceClient { - return &departmentServiceClient{cc} -} - -func (c *departmentServiceClient) ListDepartments(ctx context.Context, in *ListDepartmentsRequest, opts ...grpc.CallOption) (*ListDepartmentsResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListDepartmentsResponse) - err := c.cc.Invoke(ctx, DepartmentService_ListDepartments_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *departmentServiceClient) GetDepartment(ctx context.Context, in *GetDepartmentRequest, opts ...grpc.CallOption) (*GetDepartmentResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetDepartmentResponse) - err := c.cc.Invoke(ctx, DepartmentService_GetDepartment_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *departmentServiceClient) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest, opts ...grpc.CallOption) (*CreateDepartmentResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateDepartmentResponse) - err := c.cc.Invoke(ctx, DepartmentService_CreateDepartment_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *departmentServiceClient) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest, opts ...grpc.CallOption) (*UpdateDepartmentResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateDepartmentResponse) - err := c.cc.Invoke(ctx, DepartmentService_UpdateDepartment_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *departmentServiceClient) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest, opts ...grpc.CallOption) (*DeleteDepartmentResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeleteDepartmentResponse) - err := c.cc.Invoke(ctx, DepartmentService_DeleteDepartment_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// DepartmentServiceServer is the server API for DepartmentService service. -// All implementations must embed UnimplementedDepartmentServiceServer -// for forward compatibility. -// -// The login service definition. -type DepartmentServiceServer interface { - ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) - GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) - CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) - UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) - DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) - mustEmbedUnimplementedDepartmentServiceServer() -} - -// UnimplementedDepartmentServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedDepartmentServiceServer struct{} - -func (UnimplementedDepartmentServiceServer) ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListDepartments not implemented") -} -func (UnimplementedDepartmentServiceServer) GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetDepartment not implemented") -} -func (UnimplementedDepartmentServiceServer) CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateDepartment not implemented") -} -func (UnimplementedDepartmentServiceServer) UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateDepartment not implemented") -} -func (UnimplementedDepartmentServiceServer) DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteDepartment not implemented") -} -func (UnimplementedDepartmentServiceServer) mustEmbedUnimplementedDepartmentServiceServer() {} -func (UnimplementedDepartmentServiceServer) testEmbeddedByValue() {} - -// UnsafeDepartmentServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to DepartmentServiceServer will -// result in compilation errors. -type UnsafeDepartmentServiceServer interface { - mustEmbedUnimplementedDepartmentServiceServer() -} - -func RegisterDepartmentServiceServer(s grpc.ServiceRegistrar, srv DepartmentServiceServer) { - // If the following call pancis, it indicates UnimplementedDepartmentServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&DepartmentService_ServiceDesc, srv) -} - -func _DepartmentService_ListDepartments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListDepartmentsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DepartmentServiceServer).ListDepartments(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: DepartmentService_ListDepartments_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DepartmentServiceServer).ListDepartments(ctx, req.(*ListDepartmentsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DepartmentService_GetDepartment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetDepartmentRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DepartmentServiceServer).GetDepartment(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: DepartmentService_GetDepartment_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DepartmentServiceServer).GetDepartment(ctx, req.(*GetDepartmentRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DepartmentService_CreateDepartment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateDepartmentRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DepartmentServiceServer).CreateDepartment(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: DepartmentService_CreateDepartment_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DepartmentServiceServer).CreateDepartment(ctx, req.(*CreateDepartmentRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DepartmentService_UpdateDepartment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateDepartmentRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DepartmentServiceServer).UpdateDepartment(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: DepartmentService_UpdateDepartment_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DepartmentServiceServer).UpdateDepartment(ctx, req.(*UpdateDepartmentRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _DepartmentService_DeleteDepartment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteDepartmentRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(DepartmentServiceServer).DeleteDepartment(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: DepartmentService_DeleteDepartment_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(DepartmentServiceServer).DeleteDepartment(ctx, req.(*DeleteDepartmentRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// DepartmentService_ServiceDesc is the grpc.ServiceDesc for DepartmentService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var DepartmentService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.DepartmentService", - HandlerType: (*DepartmentServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListDepartments", - Handler: _DepartmentService_ListDepartments_Handler, - }, - { - MethodName: "GetDepartment", - Handler: _DepartmentService_GetDepartment_Handler, - }, - { - MethodName: "CreateDepartment", - Handler: _DepartmentService_CreateDepartment_Handler, - }, - { - MethodName: "UpdateDepartment", - Handler: _DepartmentService_UpdateDepartment_Handler, - }, - { - MethodName: "DeleteDepartment", - Handler: _DepartmentService_DeleteDepartment_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "system/department.proto", -} diff --git a/api/v1/services/system/department_http.pb.go b/api/v1/services/system/department_http.pb.go deleted file mode 100644 index 1420bdf9..00000000 --- a/api/v1/services/system/department_http.pb.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: system/department.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationDepartmentServiceCreateDepartment = "/api.v1.services.system.DepartmentService/CreateDepartment" -const OperationDepartmentServiceDeleteDepartment = "/api.v1.services.system.DepartmentService/DeleteDepartment" -const OperationDepartmentServiceGetDepartment = "/api.v1.services.system.DepartmentService/GetDepartment" -const OperationDepartmentServiceListDepartments = "/api.v1.services.system.DepartmentService/ListDepartments" -const OperationDepartmentServiceUpdateDepartment = "/api.v1.services.system.DepartmentService/UpdateDepartment" - -type DepartmentServiceHTTPServer interface { - CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) - DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) - GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) - ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) - UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) -} - -func RegisterDepartmentServiceHTTPServer(s *http.Server, srv DepartmentServiceHTTPServer) { - r := s.Route("/") - r.GET("/sys/departments", _DepartmentService_ListDepartments0_HTTP_Handler(srv)) - r.GET("/sys/departments/{id}", _DepartmentService_GetDepartment0_HTTP_Handler(srv)) - r.POST("/sys/departments", _DepartmentService_CreateDepartment0_HTTP_Handler(srv)) - r.PUT("/sys/departments/{department.id}", _DepartmentService_UpdateDepartment0_HTTP_Handler(srv)) - r.DELETE("/sys/departments/{id}", _DepartmentService_DeleteDepartment0_HTTP_Handler(srv)) -} - -func _DepartmentService_ListDepartments0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListDepartmentsRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDepartmentServiceListDepartments) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListDepartments(ctx, req.(*ListDepartmentsRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListDepartmentsResponse) - return ctx.Result(200, reply) - } -} - -func _DepartmentService_GetDepartment0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetDepartmentRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDepartmentServiceGetDepartment) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetDepartment(ctx, req.(*GetDepartmentRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetDepartmentResponse) - return ctx.Result(200, reply) - } -} - -func _DepartmentService_CreateDepartment0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateDepartmentRequest - if err := ctx.Bind(&in.Department); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDepartmentServiceCreateDepartment) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateDepartment(ctx, req.(*CreateDepartmentRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreateDepartmentResponse) - return ctx.Result(200, reply) - } -} - -func _DepartmentService_UpdateDepartment0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateDepartmentRequest - if err := ctx.Bind(&in.Department); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDepartmentServiceUpdateDepartment) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateDepartment(ctx, req.(*UpdateDepartmentRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateDepartmentResponse) - return ctx.Result(200, reply) - } -} - -func _DepartmentService_DeleteDepartment0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteDepartmentRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationDepartmentServiceDeleteDepartment) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteDepartment(ctx, req.(*DeleteDepartmentRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteDepartmentResponse) - return ctx.Result(200, reply) - } -} - -type DepartmentServiceHTTPClient interface { - CreateDepartment(ctx context.Context, req *CreateDepartmentRequest, opts ...http.CallOption) (rsp *CreateDepartmentResponse, err error) - DeleteDepartment(ctx context.Context, req *DeleteDepartmentRequest, opts ...http.CallOption) (rsp *DeleteDepartmentResponse, err error) - GetDepartment(ctx context.Context, req *GetDepartmentRequest, opts ...http.CallOption) (rsp *GetDepartmentResponse, err error) - ListDepartments(ctx context.Context, req *ListDepartmentsRequest, opts ...http.CallOption) (rsp *ListDepartmentsResponse, err error) - UpdateDepartment(ctx context.Context, req *UpdateDepartmentRequest, opts ...http.CallOption) (rsp *UpdateDepartmentResponse, err error) -} - -type DepartmentServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewDepartmentServiceHTTPClient(client *http.Client) DepartmentServiceHTTPClient { - return &DepartmentServiceHTTPClientImpl{client} -} - -func (c *DepartmentServiceHTTPClientImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest, opts ...http.CallOption) (*CreateDepartmentResponse, error) { - var out CreateDepartmentResponse - pattern := "/sys/departments" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationDepartmentServiceCreateDepartment)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Department, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *DepartmentServiceHTTPClientImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest, opts ...http.CallOption) (*DeleteDepartmentResponse, error) { - var out DeleteDepartmentResponse - pattern := "/sys/departments/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationDepartmentServiceDeleteDepartment)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *DepartmentServiceHTTPClientImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest, opts ...http.CallOption) (*GetDepartmentResponse, error) { - var out GetDepartmentResponse - pattern := "/sys/departments/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationDepartmentServiceGetDepartment)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *DepartmentServiceHTTPClientImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest, opts ...http.CallOption) (*ListDepartmentsResponse, error) { - var out ListDepartmentsResponse - pattern := "/sys/departments" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationDepartmentServiceListDepartments)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *DepartmentServiceHTTPClientImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest, opts ...http.CallOption) (*UpdateDepartmentResponse, error) { - var out UpdateDepartmentResponse - pattern := "/sys/departments/{department.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationDepartmentServiceUpdateDepartment)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Department, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/system/menu.pb.go b/api/v1/services/system/menu.pb.go deleted file mode 100644 index 356ecb46..00000000 --- a/api/v1/services/system/menu.pb.go +++ /dev/null @@ -1,731 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: system/menu.proto - -package system - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// ListMenusRequest is the request for the MenuService.ListMenus method. -type ListMenusRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,json=noPaging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,json=onlyCount,proto3" json:"only_count,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListMenusRequest) Reset() { - *x = ListMenusRequest{} - mi := &file_system_menu_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListMenusRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListMenusRequest) ProtoMessage() {} - -func (x *ListMenusRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[0] - 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 ListMenusRequest.ProtoReflect.Descriptor instead. -func (*ListMenusRequest) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{0} -} - -func (x *ListMenusRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListMenusRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListMenusRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListMenusRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListMenusRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListMenusRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -// ListMenusResponse is the response for the MenuService.ListMenus method. -type ListMenusResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - // The paging menus - Menus []*types.Menu `protobuf:"bytes,2,rep,name=menus,proto3" json:"menus,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListMenusResponse) Reset() { - *x = ListMenusResponse{} - mi := &file_system_menu_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListMenusResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListMenusResponse) ProtoMessage() {} - -func (x *ListMenusResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[1] - 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 ListMenusResponse.ProtoReflect.Descriptor instead. -func (*ListMenusResponse) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{1} -} - -func (x *ListMenusResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListMenusResponse) GetMenus() []*types.Menu { - if x != nil { - return x.Menus - } - return nil -} - -func (x *ListMenusResponse) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListMenusResponse) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListMenusResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -func (x *ListMenusResponse) GetExtra() *anypb.Any { - if x != nil { - return x.Extra - } - return nil -} - -// GetMenuRequest is the request for the MenuService.GetMenu method. -type GetMenuRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/menus/menu2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetMenuRequest) Reset() { - *x = GetMenuRequest{} - mi := &file_system_menu_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetMenuRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetMenuRequest) ProtoMessage() {} - -func (x *GetMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[2] - 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 GetMenuRequest.ProtoReflect.Descriptor instead. -func (*GetMenuRequest) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{2} -} - -func (x *GetMenuRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -// GetMenuResponse is the response for the MenuService.GetMenu method. -type GetMenuResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field id should match the Noun in the method id. - Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetMenuResponse) Reset() { - *x = GetMenuResponse{} - mi := &file_system_menu_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetMenuResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetMenuResponse) ProtoMessage() {} - -func (x *GetMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[3] - 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 GetMenuResponse.ProtoReflect.Descriptor instead. -func (*GetMenuResponse) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{3} -} - -func (x *GetMenuResponse) GetMenu() *types.Menu { - if x != nil { - return x.Menu - } - return nil -} - -// CreateMenuRequest is the request for the MenuService.CreateMenu method. -type CreateMenuRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id where the menu is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The menu id to use for this menu. - MenuId string `protobuf:"bytes,3,opt,name=menu_id,json=menuId,proto3" json:"menu_id,omitempty"` - // The menu resource to create. - // The field id should match the Noun in the method id. - Menu *types.Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateMenuRequest) Reset() { - *x = CreateMenuRequest{} - mi := &file_system_menu_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateMenuRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateMenuRequest) ProtoMessage() {} - -func (x *CreateMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[4] - 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 CreateMenuRequest.ProtoReflect.Descriptor instead. -func (*CreateMenuRequest) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{4} -} - -func (x *CreateMenuRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreateMenuRequest) GetMenuId() string { - if x != nil { - return x.MenuId - } - return "" -} - -func (x *CreateMenuRequest) GetMenu() *types.Menu { - if x != nil { - return x.Menu - } - return nil -} - -// CreateMenuResponse is the response for the MenuService.CreateMenu method. -type CreateMenuResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateMenuResponse) Reset() { - *x = CreateMenuResponse{} - mi := &file_system_menu_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateMenuResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateMenuResponse) ProtoMessage() {} - -func (x *CreateMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[5] - 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 CreateMenuResponse.ProtoReflect.Descriptor instead. -func (*CreateMenuResponse) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{5} -} - -func (x *CreateMenuResponse) GetMenu() *types.Menu { - if x != nil { - return x.Menu - } - return nil -} - -// UpdateMenuRequest is the request for the MenuService.UpdateMenu method. -type UpdateMenuRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The menu resource which replaces the resource on the server. - Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateMenuRequest) Reset() { - *x = UpdateMenuRequest{} - mi := &file_system_menu_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateMenuRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateMenuRequest) ProtoMessage() {} - -func (x *UpdateMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_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 UpdateMenuRequest.ProtoReflect.Descriptor instead. -func (*UpdateMenuRequest) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdateMenuRequest) GetMenu() *types.Menu { - if x != nil { - return x.Menu - } - return nil -} - -// UpdateMenuResponse is the response for the MenuService.UpdateMenu method. -type UpdateMenuResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateMenuResponse) Reset() { - *x = UpdateMenuResponse{} - mi := &file_system_menu_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateMenuResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateMenuResponse) ProtoMessage() {} - -func (x *UpdateMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateMenuResponse.ProtoReflect.Descriptor instead. -func (*UpdateMenuResponse) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{7} -} - -func (x *UpdateMenuResponse) GetMenu() *types.Menu { - if x != nil { - return x.Menu - } - return nil -} - -// DeleteMenuRequest is the request for the MenuService.DeleteMenu method. -type DeleteMenuRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The resource id of the menu to be deleted, for example: - // "shelves/shelf1/menus/menu2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteMenuRequest) Reset() { - *x = DeleteMenuRequest{} - mi := &file_system_menu_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteMenuRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteMenuRequest) ProtoMessage() {} - -func (x *DeleteMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[8] - 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 DeleteMenuRequest.ProtoReflect.Descriptor instead. -func (*DeleteMenuRequest) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{8} -} - -func (x *DeleteMenuRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -// DeleteMenuResponse is the response for the MenuService.DeleteMenu method. -type DeleteMenuResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // or Menu menu = 1; or google.protobuf.Empty empty = 1; - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteMenuResponse) Reset() { - *x = DeleteMenuResponse{} - mi := &file_system_menu_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteMenuResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteMenuResponse) ProtoMessage() {} - -func (x *DeleteMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[9] - 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 DeleteMenuResponse.ProtoReflect.Descriptor instead. -func (*DeleteMenuResponse) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{9} -} - -func (x *DeleteMenuResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -var File_system_menu_proto protoreflect.FileDescriptor - -const file_system_menu_proto_rawDesc = "" + - "\n" + - "\x11system/menu.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xb4\x01\n" + - "\x10ListMenusRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1b\n" + - "\tpage_size\x18\x03 \x01(\x05R\bpageSize\x12\x1d\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\tpageToken\x12\x1b\n" + - "\tno_paging\x18\x05 \x01(\bR\bnoPaging\x12\x1d\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\tonlyCount\"\x83\x02\n" + - "\x11ListMenusResponse\x12\x1e\n" + - "\n" + - "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x121\n" + - "\x05menus\x18\x02 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + - "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + - "\x06_extra\" \n" + - "\x0eGetMenuRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + - "\x0fGetMenuResponse\x12/\n" + - "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"u\n" + - "\x11CreateMenuRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x17\n" + - "\amenu_id\x18\x03 \x01(\tR\x06menuId\x12/\n" + - "\x04menu\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"E\n" + - "\x12CreateMenuResponse\x12/\n" + - "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"D\n" + - "\x11UpdateMenuRequest\x12/\n" + - "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"E\n" + - "\x12UpdateMenuResponse\x12/\n" + - "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"#\n" + - "\x11DeleteMenuRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + - "\x12DeleteMenuResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xff\x04\n" + - "\vMenuService\x12t\n" + - "\tListMenus\x12(.api.v1.services.system.ListMenusRequest\x1a).api.v1.services.system.ListMenusResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + - "/sys/menus\x12s\n" + - "\aGetMenu\x12&.api.v1.services.system.GetMenuRequest\x1a'.api.v1.services.system.GetMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/menus/{id}\x12}\n" + - "\n" + - "CreateMenu\x12).api.v1.services.system.CreateMenuRequest\x1a*.api.v1.services.system.CreateMenuResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04menu\"\n" + - "/sys/menus\x12\x87\x01\n" + - "\n" + - "UpdateMenu\x12).api.v1.services.system.UpdateMenuRequest\x1a*.api.v1.services.system.UpdateMenuResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04menu\x1a\x14/sys/menus/{menu.id}\x12|\n" + - "\n" + - "DeleteMenu\x12).api.v1.services.system.DeleteMenuRequest\x1a*.api.v1.services.system.DeleteMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/menus/{id}B\xde\x01\n" + - "\x1acom.api.v1.services.systemB\tMenuProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_menu_proto_rawDescOnce sync.Once - file_system_menu_proto_rawDescData []byte -) - -func file_system_menu_proto_rawDescGZIP() []byte { - file_system_menu_proto_rawDescOnce.Do(func() { - file_system_menu_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_menu_proto_rawDesc), len(file_system_menu_proto_rawDesc))) - }) - return file_system_menu_proto_rawDescData -} - -var file_system_menu_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_system_menu_proto_goTypes = []any{ - (*ListMenusRequest)(nil), // 0: api.v1.services.system.ListMenusRequest - (*ListMenusResponse)(nil), // 1: api.v1.services.system.ListMenusResponse - (*GetMenuRequest)(nil), // 2: api.v1.services.system.GetMenuRequest - (*GetMenuResponse)(nil), // 3: api.v1.services.system.GetMenuResponse - (*CreateMenuRequest)(nil), // 4: api.v1.services.system.CreateMenuRequest - (*CreateMenuResponse)(nil), // 5: api.v1.services.system.CreateMenuResponse - (*UpdateMenuRequest)(nil), // 6: api.v1.services.system.UpdateMenuRequest - (*UpdateMenuResponse)(nil), // 7: api.v1.services.system.UpdateMenuResponse - (*DeleteMenuRequest)(nil), // 8: api.v1.services.system.DeleteMenuRequest - (*DeleteMenuResponse)(nil), // 9: api.v1.services.system.DeleteMenuResponse - (*types.Menu)(nil), // 10: api.v1.services.types.Menu - (*anypb.Any)(nil), // 11: google.protobuf.Any - (*emptypb.Empty)(nil), // 12: google.protobuf.Empty -} -var file_system_menu_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListMenusResponse.menus:type_name -> api.v1.services.types.Menu - 11, // 1: api.v1.services.system.ListMenusResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetMenuResponse.menu:type_name -> api.v1.services.types.Menu - 10, // 3: api.v1.services.system.CreateMenuRequest.menu:type_name -> api.v1.services.types.Menu - 10, // 4: api.v1.services.system.CreateMenuResponse.menu:type_name -> api.v1.services.types.Menu - 10, // 5: api.v1.services.system.UpdateMenuRequest.menu:type_name -> api.v1.services.types.Menu - 10, // 6: api.v1.services.system.UpdateMenuResponse.menu:type_name -> api.v1.services.types.Menu - 12, // 7: api.v1.services.system.DeleteMenuResponse.empty:type_name -> google.protobuf.Empty - 0, // 8: api.v1.services.system.MenuService.ListMenus:input_type -> api.v1.services.system.ListMenusRequest - 2, // 9: api.v1.services.system.MenuService.GetMenu:input_type -> api.v1.services.system.GetMenuRequest - 4, // 10: api.v1.services.system.MenuService.CreateMenu:input_type -> api.v1.services.system.CreateMenuRequest - 6, // 11: api.v1.services.system.MenuService.UpdateMenu:input_type -> api.v1.services.system.UpdateMenuRequest - 8, // 12: api.v1.services.system.MenuService.DeleteMenu:input_type -> api.v1.services.system.DeleteMenuRequest - 1, // 13: api.v1.services.system.MenuService.ListMenus:output_type -> api.v1.services.system.ListMenusResponse - 3, // 14: api.v1.services.system.MenuService.GetMenu:output_type -> api.v1.services.system.GetMenuResponse - 5, // 15: api.v1.services.system.MenuService.CreateMenu:output_type -> api.v1.services.system.CreateMenuResponse - 7, // 16: api.v1.services.system.MenuService.UpdateMenu:output_type -> api.v1.services.system.UpdateMenuResponse - 9, // 17: api.v1.services.system.MenuService.DeleteMenu:output_type -> api.v1.services.system.DeleteMenuResponse - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_system_menu_proto_init() } -func file_system_menu_proto_init() { - if File_system_menu_proto != nil { - return - } - file_system_menu_proto_msgTypes[1].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_menu_proto_rawDesc), len(file_system_menu_proto_rawDesc)), - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_system_menu_proto_goTypes, - DependencyIndexes: file_system_menu_proto_depIdxs, - MessageInfos: file_system_menu_proto_msgTypes, - }.Build() - File_system_menu_proto = out.File - file_system_menu_proto_goTypes = nil - file_system_menu_proto_depIdxs = nil -} diff --git a/api/v1/services/system/menu.pb.gw.go b/api/v1/services/system/menu.pb.gw.go deleted file mode 100644 index 507b36f2..00000000 --- a/api/v1/services/system/menu.pb.gw.go +++ /dev/null @@ -1,473 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/menu.proto - -/* -Package system is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package system - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_MenuService_ListMenus_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_MenuService_ListMenus_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListMenusRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_ListMenus_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListMenus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_MenuService_ListMenus_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListMenusRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_ListMenus_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListMenus(ctx, &protoReq) - return msg, metadata, err -} - -func request_MenuService_GetMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetMenuRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_MenuService_GetMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetMenuRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetMenu(ctx, &protoReq) - return msg, metadata, err -} - -var filter_MenuService_CreateMenu_0 = &utilities.DoubleArray{Encoding: map[string]int{"menu": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - -func request_MenuService_CreateMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateMenuRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_CreateMenu_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreateMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_MenuService_CreateMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateMenuRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_CreateMenu_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreateMenu(ctx, &protoReq) - return msg, metadata, err -} - -func request_MenuService_UpdateMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateMenuRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["menu.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "menu.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "menu.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "menu.id", err) - } - msg, err := client.UpdateMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_MenuService_UpdateMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateMenuRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["menu.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "menu.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "menu.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "menu.id", err) - } - msg, err := server.UpdateMenu(ctx, &protoReq) - return msg, metadata, err -} - -func request_MenuService_DeleteMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteMenuRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.DeleteMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_MenuService_DeleteMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteMenuRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.DeleteMenu(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterMenuServiceHandlerServer registers the http handlers for service MenuService to "mux". -// UnaryRPC :call MenuServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMenuServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterMenuServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MenuServiceServer) error { - mux.Handle(http.MethodGet, pattern_MenuService_ListMenus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/ListMenus", runtime.WithHTTPPathPattern("/sys/menus")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_MenuService_ListMenus_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_ListMenus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_MenuService_GetMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/GetMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_MenuService_GetMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_GetMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_MenuService_CreateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/CreateMenu", runtime.WithHTTPPathPattern("/sys/menus")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_MenuService_CreateMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_CreateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_MenuService_UpdateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/UpdateMenu", runtime.WithHTTPPathPattern("/sys/menus/{menu.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_MenuService_UpdateMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_UpdateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_MenuService_DeleteMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/DeleteMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_MenuService_DeleteMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_DeleteMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterMenuServiceHandlerFromEndpoint is same as RegisterMenuServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMenuServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterMenuServiceHandler(ctx, mux, conn) -} - -// RegisterMenuServiceHandler registers the http handlers for service MenuService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMenuServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMenuServiceHandlerClient(ctx, mux, NewMenuServiceClient(conn)) -} - -// RegisterMenuServiceHandlerClient registers the http handlers for service MenuService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MenuServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MenuServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MenuServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterMenuServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MenuServiceClient) error { - mux.Handle(http.MethodGet, pattern_MenuService_ListMenus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/ListMenus", runtime.WithHTTPPathPattern("/sys/menus")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_MenuService_ListMenus_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_ListMenus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_MenuService_GetMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/GetMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_MenuService_GetMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_GetMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_MenuService_CreateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/CreateMenu", runtime.WithHTTPPathPattern("/sys/menus")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_MenuService_CreateMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_CreateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_MenuService_UpdateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/UpdateMenu", runtime.WithHTTPPathPattern("/sys/menus/{menu.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_MenuService_UpdateMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_UpdateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_MenuService_DeleteMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/DeleteMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_MenuService_DeleteMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_DeleteMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_MenuService_ListMenus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "menus"}, "")) - pattern_MenuService_GetMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "menus", "id"}, "")) - pattern_MenuService_CreateMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "menus"}, "")) - pattern_MenuService_UpdateMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "menus", "menu.id"}, "")) - pattern_MenuService_DeleteMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "menus", "id"}, "")) -) - -var ( - forward_MenuService_ListMenus_0 = runtime.ForwardResponseMessage - forward_MenuService_GetMenu_0 = runtime.ForwardResponseMessage - forward_MenuService_CreateMenu_0 = runtime.ForwardResponseMessage - forward_MenuService_UpdateMenu_0 = runtime.ForwardResponseMessage - forward_MenuService_DeleteMenu_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/system/menu.pb.validate.go b/api/v1/services/system/menu.pb.validate.go deleted file mode 100644 index c39c7c0b..00000000 --- a/api/v1/services/system/menu.pb.validate.go +++ /dev/null @@ -1,1319 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/menu.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListMenusRequest 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 *ListMenusRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListMenusRequest 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 -// ListMenusRequestMultiError, or nil if none found. -func (m *ListMenusRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListMenusRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - if len(errors) > 0 { - return ListMenusRequestMultiError(errors) - } - - return nil -} - -// ListMenusRequestMultiError is an error wrapping multiple validation errors -// returned by ListMenusRequest.ValidateAll() if the designated constraints -// aren't met. -type ListMenusRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListMenusRequestMultiError) 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 ListMenusRequestMultiError) AllErrors() []error { return m } - -// ListMenusRequestValidationError is the validation error returned by -// ListMenusRequest.Validate if the designated constraints aren't met. -type ListMenusRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListMenusRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListMenusRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListMenusRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListMenusRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListMenusRequestValidationError) ErrorName() string { return "ListMenusRequestValidationError" } - -// Error satisfies the builtin error interface -func (e ListMenusRequestValidationError) 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 %sListMenusRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListMenusRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListMenusRequestValidationError{} - -// Validate checks the field values on ListMenusResponse 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 *ListMenusResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListMenusResponse 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 -// ListMenusResponseMultiError, or nil if none found. -func (m *ListMenusResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListMenusResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetMenus() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListMenusResponseValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListMenusResponseValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListMenusResponseValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for NextPageToken - - if m.Extra != nil { - - if all { - switch v := interface{}(m.GetExtra()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListMenusResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListMenusResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListMenusResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListMenusResponseMultiError(errors) - } - - return nil -} - -// ListMenusResponseMultiError is an error wrapping multiple validation errors -// returned by ListMenusResponse.ValidateAll() if the designated constraints -// aren't met. -type ListMenusResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListMenusResponseMultiError) 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 ListMenusResponseMultiError) AllErrors() []error { return m } - -// ListMenusResponseValidationError is the validation error returned by -// ListMenusResponse.Validate if the designated constraints aren't met. -type ListMenusResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListMenusResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListMenusResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListMenusResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListMenusResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListMenusResponseValidationError) ErrorName() string { - return "ListMenusResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListMenusResponseValidationError) 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 %sListMenusResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListMenusResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListMenusResponseValidationError{} - -// Validate checks the field values on GetMenuRequest 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 *GetMenuRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetMenuRequest 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 GetMenuRequestMultiError, -// or nil if none found. -func (m *GetMenuRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetMenuRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return GetMenuRequestMultiError(errors) - } - - return nil -} - -// GetMenuRequestMultiError is an error wrapping multiple validation errors -// returned by GetMenuRequest.ValidateAll() if the designated constraints -// aren't met. -type GetMenuRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetMenuRequestMultiError) 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 GetMenuRequestMultiError) AllErrors() []error { return m } - -// GetMenuRequestValidationError is the validation error returned by -// GetMenuRequest.Validate if the designated constraints aren't met. -type GetMenuRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetMenuRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetMenuRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetMenuRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetMenuRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetMenuRequestValidationError) ErrorName() string { return "GetMenuRequestValidationError" } - -// Error satisfies the builtin error interface -func (e GetMenuRequestValidationError) 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 %sGetMenuRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetMenuRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetMenuRequestValidationError{} - -// Validate checks the field values on GetMenuResponse 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 *GetMenuResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetMenuResponse 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 -// GetMenuResponseMultiError, or nil if none found. -func (m *GetMenuResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetMenuResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetMenuResponseMultiError(errors) - } - - return nil -} - -// GetMenuResponseMultiError is an error wrapping multiple validation errors -// returned by GetMenuResponse.ValidateAll() if the designated constraints -// aren't met. -type GetMenuResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetMenuResponseMultiError) 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 GetMenuResponseMultiError) AllErrors() []error { return m } - -// GetMenuResponseValidationError is the validation error returned by -// GetMenuResponse.Validate if the designated constraints aren't met. -type GetMenuResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetMenuResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetMenuResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetMenuResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetMenuResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetMenuResponseValidationError) ErrorName() string { return "GetMenuResponseValidationError" } - -// Error satisfies the builtin error interface -func (e GetMenuResponseValidationError) 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 %sGetMenuResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetMenuResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetMenuResponseValidationError{} - -// Validate checks the field values on CreateMenuRequest 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 *CreateMenuRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateMenuRequest 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 -// CreateMenuRequestMultiError, or nil if none found. -func (m *CreateMenuRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateMenuRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Parent - - // no validation rules for MenuId - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateMenuRequestMultiError(errors) - } - - return nil -} - -// CreateMenuRequestMultiError is an error wrapping multiple validation errors -// returned by CreateMenuRequest.ValidateAll() if the designated constraints -// aren't met. -type CreateMenuRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateMenuRequestMultiError) 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 CreateMenuRequestMultiError) AllErrors() []error { return m } - -// CreateMenuRequestValidationError is the validation error returned by -// CreateMenuRequest.Validate if the designated constraints aren't met. -type CreateMenuRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateMenuRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateMenuRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateMenuRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateMenuRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateMenuRequestValidationError) ErrorName() string { - return "CreateMenuRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateMenuRequestValidationError) 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 %sCreateMenuRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateMenuRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateMenuRequestValidationError{} - -// Validate checks the field values on CreateMenuResponse 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 *CreateMenuResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateMenuResponse 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 -// CreateMenuResponseMultiError, or nil if none found. -func (m *CreateMenuResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateMenuResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateMenuResponseMultiError(errors) - } - - return nil -} - -// CreateMenuResponseMultiError is an error wrapping multiple validation errors -// returned by CreateMenuResponse.ValidateAll() if the designated constraints -// aren't met. -type CreateMenuResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateMenuResponseMultiError) 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 CreateMenuResponseMultiError) AllErrors() []error { return m } - -// CreateMenuResponseValidationError is the validation error returned by -// CreateMenuResponse.Validate if the designated constraints aren't met. -type CreateMenuResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateMenuResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateMenuResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateMenuResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateMenuResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateMenuResponseValidationError) ErrorName() string { - return "CreateMenuResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateMenuResponseValidationError) 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 %sCreateMenuResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateMenuResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateMenuResponseValidationError{} - -// Validate checks the field values on UpdateMenuRequest 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 *UpdateMenuRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateMenuRequest 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 -// UpdateMenuRequestMultiError, or nil if none found. -func (m *UpdateMenuRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateMenuRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateMenuRequestMultiError(errors) - } - - return nil -} - -// UpdateMenuRequestMultiError is an error wrapping multiple validation errors -// returned by UpdateMenuRequest.ValidateAll() if the designated constraints -// aren't met. -type UpdateMenuRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateMenuRequestMultiError) 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 UpdateMenuRequestMultiError) AllErrors() []error { return m } - -// UpdateMenuRequestValidationError is the validation error returned by -// UpdateMenuRequest.Validate if the designated constraints aren't met. -type UpdateMenuRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateMenuRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateMenuRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateMenuRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateMenuRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateMenuRequestValidationError) ErrorName() string { - return "UpdateMenuRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateMenuRequestValidationError) 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 %sUpdateMenuRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateMenuRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateMenuRequestValidationError{} - -// Validate checks the field values on UpdateMenuResponse 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 *UpdateMenuResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateMenuResponse 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 -// UpdateMenuResponseMultiError, or nil if none found. -func (m *UpdateMenuResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateMenuResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateMenuResponseMultiError(errors) - } - - return nil -} - -// UpdateMenuResponseMultiError is an error wrapping multiple validation errors -// returned by UpdateMenuResponse.ValidateAll() if the designated constraints -// aren't met. -type UpdateMenuResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateMenuResponseMultiError) 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 UpdateMenuResponseMultiError) AllErrors() []error { return m } - -// UpdateMenuResponseValidationError is the validation error returned by -// UpdateMenuResponse.Validate if the designated constraints aren't met. -type UpdateMenuResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateMenuResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateMenuResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateMenuResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateMenuResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateMenuResponseValidationError) ErrorName() string { - return "UpdateMenuResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateMenuResponseValidationError) 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 %sUpdateMenuResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateMenuResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateMenuResponseValidationError{} - -// Validate checks the field values on DeleteMenuRequest 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 *DeleteMenuRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteMenuRequest 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 -// DeleteMenuRequestMultiError, or nil if none found. -func (m *DeleteMenuRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteMenuRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return DeleteMenuRequestMultiError(errors) - } - - return nil -} - -// DeleteMenuRequestMultiError is an error wrapping multiple validation errors -// returned by DeleteMenuRequest.ValidateAll() if the designated constraints -// aren't met. -type DeleteMenuRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteMenuRequestMultiError) 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 DeleteMenuRequestMultiError) AllErrors() []error { return m } - -// DeleteMenuRequestValidationError is the validation error returned by -// DeleteMenuRequest.Validate if the designated constraints aren't met. -type DeleteMenuRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteMenuRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteMenuRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteMenuRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteMenuRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteMenuRequestValidationError) ErrorName() string { - return "DeleteMenuRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteMenuRequestValidationError) 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 %sDeleteMenuRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteMenuRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteMenuRequestValidationError{} - -// Validate checks the field values on DeleteMenuResponse 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 *DeleteMenuResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteMenuResponse 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 -// DeleteMenuResponseMultiError, or nil if none found. -func (m *DeleteMenuResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteMenuResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteMenuResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteMenuResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteMenuResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteMenuResponseMultiError(errors) - } - - return nil -} - -// DeleteMenuResponseMultiError is an error wrapping multiple validation errors -// returned by DeleteMenuResponse.ValidateAll() if the designated constraints -// aren't met. -type DeleteMenuResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteMenuResponseMultiError) 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 DeleteMenuResponseMultiError) AllErrors() []error { return m } - -// DeleteMenuResponseValidationError is the validation error returned by -// DeleteMenuResponse.Validate if the designated constraints aren't met. -type DeleteMenuResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteMenuResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteMenuResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteMenuResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteMenuResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteMenuResponseValidationError) ErrorName() string { - return "DeleteMenuResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteMenuResponseValidationError) 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 %sDeleteMenuResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteMenuResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteMenuResponseValidationError{} diff --git a/api/v1/services/system/menu_bridge.pb.go b/api/v1/services/system/menu_bridge.pb.go deleted file mode 100644 index 03afbf8b..00000000 --- a/api/v1/services/system/menu_bridge.pb.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: system/menu.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const MenuServiceCreateMenuBridgeOperation = "/api.v1.services.system.MenuService/CreateMenu" -const MenuServiceDeleteMenuBridgeOperation = "/api.v1.services.system.MenuService/DeleteMenu" -const MenuServiceGetMenuBridgeOperation = "/api.v1.services.system.MenuService/GetMenu" -const MenuServiceListMenusBridgeOperation = "/api.v1.services.system.MenuService/ListMenus" -const MenuServiceUpdateMenuBridgeOperation = "/api.v1.services.system.MenuService/UpdateMenu" - -type MenuServiceBridgeServer interface { - CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) - DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) - GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) - ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) - UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) -} - -type MenuServiceHooker interface { - MenuServiceCreateMenuHooker - MenuServiceDeleteMenuHooker - MenuServiceGetMenuHooker - MenuServiceListMenusHooker - MenuServiceUpdateMenuHooker -} - -type MenuServiceHookedBridger interface { - MenuServiceHooker - MenuServiceBridgeServer -} -type MenuServiceCreateMenuHooker interface { - PrepareCreateMenu(http.Context, *CreateMenuRequest) (context.Context, error) - CompleteCreateMenu(http.Context, *CreateMenuRequest, *CreateMenuResponse) error -} -type MenuServiceDeleteMenuHooker interface { - PrepareDeleteMenu(http.Context, *DeleteMenuRequest) (context.Context, error) - CompleteDeleteMenu(http.Context, *DeleteMenuRequest, *DeleteMenuResponse) error -} -type MenuServiceGetMenuHooker interface { - PrepareGetMenu(http.Context, *GetMenuRequest) (context.Context, error) - CompleteGetMenu(http.Context, *GetMenuRequest, *GetMenuResponse) error -} -type MenuServiceListMenusHooker interface { - PrepareListMenus(http.Context, *ListMenusRequest) (context.Context, error) - CompleteListMenus(http.Context, *ListMenusRequest, *ListMenusResponse) error -} -type MenuServiceUpdateMenuHooker interface { - PrepareUpdateMenu(http.Context, *UpdateMenuRequest) (context.Context, error) - CompleteUpdateMenu(http.Context, *UpdateMenuRequest, *UpdateMenuResponse) error -} - -func RegisterMenuServiceBridgeServer(s *http.Server, srv MenuServiceHookedBridger) { - r := s.Route("/") - r.GET("/sys/menus", _MenuService_ListMenus0_Bridge_Handler(srv)) - r.GET("/sys/menus/:id", _MenuService_GetMenu0_Bridge_Handler(srv)) - r.POST("/sys/menus", _MenuService_CreateMenu0_Bridge_Handler(srv)) - r.PUT("/sys/menus/:menu.id", _MenuService_UpdateMenu0_Bridge_Handler(srv)) - r.DELETE("/sys/menus/:id", _MenuService_DeleteMenu0_Bridge_Handler(srv)) -} - -func _MenuService_ListMenus0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListMenusRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceListMenus) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListMenus(ctx, req.(*ListMenusRequest)) - }) - - newctx, err := srv.PrepareListMenus(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListMenus(ctx, &in, out.(*ListMenusResponse)) - } -} - -func _MenuService_GetMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetMenuRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceGetMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetMenu(ctx, req.(*GetMenuRequest)) - }) - - newctx, err := srv.PrepareGetMenu(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetMenu(ctx, &in, out.(*GetMenuResponse)) - } -} - -func _MenuService_CreateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateMenuRequest - if err := ctx.Bind(&in.Menu); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceCreateMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateMenu(ctx, req.(*CreateMenuRequest)) - }) - - newctx, err := srv.PrepareCreateMenu(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreateMenu(ctx, &in, out.(*CreateMenuResponse)) - } -} - -func _MenuService_UpdateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateMenuRequest - if err := ctx.Bind(&in.Menu); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceUpdateMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateMenu(ctx, req.(*UpdateMenuRequest)) - }) - - newctx, err := srv.PrepareUpdateMenu(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateMenu(ctx, &in, out.(*UpdateMenuResponse)) - } -} - -func _MenuService_DeleteMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteMenuRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceDeleteMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteMenu(ctx, req.(*DeleteMenuRequest)) - }) - - newctx, err := srv.PrepareDeleteMenu(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeleteMenu(ctx, &in, out.(*DeleteMenuResponse)) - } -} - -// UnimplementedMenuServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedMenuServiceHooked struct{} - -func (UnimplementedMenuServiceHooked) PrepareCreateMenu(ctx http.Context, in *CreateMenuRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedMenuServiceHooked) CompleteCreateMenu(ctx http.Context, in *CreateMenuRequest, out *CreateMenuResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedMenuServiceHooked) PrepareDeleteMenu(ctx http.Context, in *DeleteMenuRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedMenuServiceHooked) CompleteDeleteMenu(ctx http.Context, in *DeleteMenuRequest, out *DeleteMenuResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedMenuServiceHooked) PrepareGetMenu(ctx http.Context, in *GetMenuRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedMenuServiceHooked) CompleteGetMenu(ctx http.Context, in *GetMenuRequest, out *GetMenuResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedMenuServiceHooked) PrepareListMenus(ctx http.Context, in *ListMenusRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedMenuServiceHooked) CompleteListMenus(ctx http.Context, in *ListMenusRequest, out *ListMenusResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedMenuServiceHooked) PrepareUpdateMenu(ctx http.Context, in *UpdateMenuRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedMenuServiceHooked) CompleteUpdateMenu(ctx http.Context, in *UpdateMenuRequest, out *UpdateMenuResponse) error { - return ctx.Result(200, out) -} - -func WithMenuServiceHook(h MenuServiceHooker) func(MenuServiceBridgeServer) MenuServiceHookedBridger { - return func(srv MenuServiceBridgeServer) MenuServiceHookedBridger { - return MenuServiceHookedBridge{MenuServiceBridgeServer: srv, MenuServiceHooker: h} - } -} - -// MenuServiceHookedBridge is a bridge between the HTTP and gRPC implementations of MenuService. -// It implements the HTTP and gRPC implementations of MenuService. -// It forwards requests and responses between the two implementations. -type MenuServiceHookedBridge struct { - MenuServiceBridgeServer - MenuServiceHooker -} - -type MenuServiceHTTPBridgeImpl struct { - client MenuServiceHTTPClient -} - -func NewMenuServiceHTTPBridge(client *http.Client) MenuServiceHTTPServer { - return &MenuServiceHTTPBridgeImpl{client: NewMenuServiceHTTPClient(client)} -} - -func (c *MenuServiceHTTPBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { - return c.client.CreateMenu(ctx, in) -} - -func (c *MenuServiceHTTPBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { - return c.client.DeleteMenu(ctx, in) -} - -func (c *MenuServiceHTTPBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { - return c.client.GetMenu(ctx, in) -} - -func (c *MenuServiceHTTPBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { - return c.client.ListMenus(ctx, in) -} - -func (c *MenuServiceHTTPBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { - return c.client.UpdateMenu(ctx, in) -} - -type MenuServiceBridgeImpl struct { - client MenuServiceClient -} - -func NewMenuServiceBridge(client grpc.ClientConnInterface) MenuServiceServer { - return &MenuServiceBridgeImpl{client: NewMenuServiceClient(client)} -} - -func (c *MenuServiceBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { - return c.client.CreateMenu(ctx, in) -} - -func (c *MenuServiceBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { - return c.client.DeleteMenu(ctx, in) -} - -func (c *MenuServiceBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { - return c.client.GetMenu(ctx, in) -} - -func (c *MenuServiceBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { - return c.client.ListMenus(ctx, in) -} - -func (c *MenuServiceBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { - return c.client.UpdateMenu(ctx, in) -} - -func (c *MenuServiceBridgeImpl) mustEmbedUnimplementedMenuServiceServer() {} - -type MenuServiceGRPC2HTTPBridgeImpl struct { - client MenuServiceClient -} - -func NewMenuServiceGRPC2HTTP(client grpc.ClientConnInterface) MenuServiceHTTPServer { - return &MenuServiceGRPC2HTTPBridgeImpl{client: NewMenuServiceClient(client)} -} - -func (c *MenuServiceGRPC2HTTPBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { - return c.client.CreateMenu(ctx, in) -} - -func (c *MenuServiceGRPC2HTTPBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { - return c.client.DeleteMenu(ctx, in) -} - -func (c *MenuServiceGRPC2HTTPBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { - return c.client.GetMenu(ctx, in) -} - -func (c *MenuServiceGRPC2HTTPBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { - return c.client.ListMenus(ctx, in) -} - -func (c *MenuServiceGRPC2HTTPBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { - return c.client.UpdateMenu(ctx, in) -} - -type MenuServiceHTTP2GRPCBridgeImpl struct { - client MenuServiceHTTPClient -} - -func NewMenuServiceHTTP2GRPC(client *http.Client) MenuServiceServer { - return &MenuServiceHTTP2GRPCBridgeImpl{client: NewMenuServiceHTTPClient(client)} -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { - return c.client.CreateMenu(ctx, in) -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { - return c.client.DeleteMenu(ctx, in) -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { - return c.client.GetMenu(ctx, in) -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { - return c.client.ListMenus(ctx, in) -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { - return c.client.UpdateMenu(ctx, in) -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedMenuServiceServer() {} diff --git a/api/v1/services/system/menu_grpc.pb.go b/api/v1/services/system/menu_grpc.pb.go deleted file mode 100644 index 69f1f159..00000000 --- a/api/v1/services/system/menu_grpc.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: system/menu.proto - -package system - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - MenuService_ListMenus_FullMethodName = "/api.v1.services.system.MenuService/ListMenus" - MenuService_GetMenu_FullMethodName = "/api.v1.services.system.MenuService/GetMenu" - MenuService_CreateMenu_FullMethodName = "/api.v1.services.system.MenuService/CreateMenu" - MenuService_UpdateMenu_FullMethodName = "/api.v1.services.system.MenuService/UpdateMenu" - MenuService_DeleteMenu_FullMethodName = "/api.v1.services.system.MenuService/DeleteMenu" -) - -// MenuServiceClient is the client API for MenuService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The menu service definition. -type MenuServiceClient interface { - ListMenus(ctx context.Context, in *ListMenusRequest, opts ...grpc.CallOption) (*ListMenusResponse, error) - GetMenu(ctx context.Context, in *GetMenuRequest, opts ...grpc.CallOption) (*GetMenuResponse, error) - CreateMenu(ctx context.Context, in *CreateMenuRequest, opts ...grpc.CallOption) (*CreateMenuResponse, error) - UpdateMenu(ctx context.Context, in *UpdateMenuRequest, opts ...grpc.CallOption) (*UpdateMenuResponse, error) - DeleteMenu(ctx context.Context, in *DeleteMenuRequest, opts ...grpc.CallOption) (*DeleteMenuResponse, error) -} - -type menuServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewMenuServiceClient(cc grpc.ClientConnInterface) MenuServiceClient { - return &menuServiceClient{cc} -} - -func (c *menuServiceClient) ListMenus(ctx context.Context, in *ListMenusRequest, opts ...grpc.CallOption) (*ListMenusResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListMenusResponse) - err := c.cc.Invoke(ctx, MenuService_ListMenus_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *menuServiceClient) GetMenu(ctx context.Context, in *GetMenuRequest, opts ...grpc.CallOption) (*GetMenuResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetMenuResponse) - err := c.cc.Invoke(ctx, MenuService_GetMenu_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *menuServiceClient) CreateMenu(ctx context.Context, in *CreateMenuRequest, opts ...grpc.CallOption) (*CreateMenuResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateMenuResponse) - err := c.cc.Invoke(ctx, MenuService_CreateMenu_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *menuServiceClient) UpdateMenu(ctx context.Context, in *UpdateMenuRequest, opts ...grpc.CallOption) (*UpdateMenuResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateMenuResponse) - err := c.cc.Invoke(ctx, MenuService_UpdateMenu_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *menuServiceClient) DeleteMenu(ctx context.Context, in *DeleteMenuRequest, opts ...grpc.CallOption) (*DeleteMenuResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeleteMenuResponse) - err := c.cc.Invoke(ctx, MenuService_DeleteMenu_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MenuServiceServer is the server API for MenuService service. -// All implementations must embed UnimplementedMenuServiceServer -// for forward compatibility. -// -// The menu service definition. -type MenuServiceServer interface { - ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) - GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) - CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) - UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) - DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) - mustEmbedUnimplementedMenuServiceServer() -} - -// UnimplementedMenuServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedMenuServiceServer struct{} - -func (UnimplementedMenuServiceServer) ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListMenus not implemented") -} -func (UnimplementedMenuServiceServer) GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetMenu not implemented") -} -func (UnimplementedMenuServiceServer) CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateMenu not implemented") -} -func (UnimplementedMenuServiceServer) UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateMenu not implemented") -} -func (UnimplementedMenuServiceServer) DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteMenu not implemented") -} -func (UnimplementedMenuServiceServer) mustEmbedUnimplementedMenuServiceServer() {} -func (UnimplementedMenuServiceServer) testEmbeddedByValue() {} - -// UnsafeMenuServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to MenuServiceServer will -// result in compilation errors. -type UnsafeMenuServiceServer interface { - mustEmbedUnimplementedMenuServiceServer() -} - -func RegisterMenuServiceServer(s grpc.ServiceRegistrar, srv MenuServiceServer) { - // If the following call pancis, it indicates UnimplementedMenuServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&MenuService_ServiceDesc, srv) -} - -func _MenuService_ListMenus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListMenusRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MenuServiceServer).ListMenus(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MenuService_ListMenus_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).ListMenus(ctx, req.(*ListMenusRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MenuService_GetMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetMenuRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MenuServiceServer).GetMenu(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MenuService_GetMenu_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).GetMenu(ctx, req.(*GetMenuRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MenuService_CreateMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateMenuRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MenuServiceServer).CreateMenu(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MenuService_CreateMenu_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).CreateMenu(ctx, req.(*CreateMenuRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MenuService_UpdateMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateMenuRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MenuServiceServer).UpdateMenu(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MenuService_UpdateMenu_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).UpdateMenu(ctx, req.(*UpdateMenuRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MenuService_DeleteMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteMenuRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MenuServiceServer).DeleteMenu(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MenuService_DeleteMenu_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).DeleteMenu(ctx, req.(*DeleteMenuRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// MenuService_ServiceDesc is the grpc.ServiceDesc for MenuService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var MenuService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.MenuService", - HandlerType: (*MenuServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListMenus", - Handler: _MenuService_ListMenus_Handler, - }, - { - MethodName: "GetMenu", - Handler: _MenuService_GetMenu_Handler, - }, - { - MethodName: "CreateMenu", - Handler: _MenuService_CreateMenu_Handler, - }, - { - MethodName: "UpdateMenu", - Handler: _MenuService_UpdateMenu_Handler, - }, - { - MethodName: "DeleteMenu", - Handler: _MenuService_DeleteMenu_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "system/menu.proto", -} diff --git a/api/v1/services/system/menu_http.pb.go b/api/v1/services/system/menu_http.pb.go deleted file mode 100644 index ff62da43..00000000 --- a/api/v1/services/system/menu_http.pb.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: system/menu.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationMenuServiceCreateMenu = "/api.v1.services.system.MenuService/CreateMenu" -const OperationMenuServiceDeleteMenu = "/api.v1.services.system.MenuService/DeleteMenu" -const OperationMenuServiceGetMenu = "/api.v1.services.system.MenuService/GetMenu" -const OperationMenuServiceListMenus = "/api.v1.services.system.MenuService/ListMenus" -const OperationMenuServiceUpdateMenu = "/api.v1.services.system.MenuService/UpdateMenu" - -type MenuServiceHTTPServer interface { - CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) - DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) - GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) - ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) - UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) -} - -func RegisterMenuServiceHTTPServer(s *http.Server, srv MenuServiceHTTPServer) { - r := s.Route("/") - r.GET("/sys/menus", _MenuService_ListMenus0_HTTP_Handler(srv)) - r.GET("/sys/menus/{id}", _MenuService_GetMenu0_HTTP_Handler(srv)) - r.POST("/sys/menus", _MenuService_CreateMenu0_HTTP_Handler(srv)) - r.PUT("/sys/menus/{menu.id}", _MenuService_UpdateMenu0_HTTP_Handler(srv)) - r.DELETE("/sys/menus/{id}", _MenuService_DeleteMenu0_HTTP_Handler(srv)) -} - -func _MenuService_ListMenus0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListMenusRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceListMenus) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListMenus(ctx, req.(*ListMenusRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListMenusResponse) - return ctx.Result(200, reply) - } -} - -func _MenuService_GetMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetMenuRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceGetMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetMenu(ctx, req.(*GetMenuRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetMenuResponse) - return ctx.Result(200, reply) - } -} - -func _MenuService_CreateMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateMenuRequest - if err := ctx.Bind(&in.Menu); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceCreateMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateMenu(ctx, req.(*CreateMenuRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreateMenuResponse) - return ctx.Result(200, reply) - } -} - -func _MenuService_UpdateMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateMenuRequest - if err := ctx.Bind(&in.Menu); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceUpdateMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateMenu(ctx, req.(*UpdateMenuRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateMenuResponse) - return ctx.Result(200, reply) - } -} - -func _MenuService_DeleteMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteMenuRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceDeleteMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteMenu(ctx, req.(*DeleteMenuRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteMenuResponse) - return ctx.Result(200, reply) - } -} - -type MenuServiceHTTPClient interface { - CreateMenu(ctx context.Context, req *CreateMenuRequest, opts ...http.CallOption) (rsp *CreateMenuResponse, err error) - DeleteMenu(ctx context.Context, req *DeleteMenuRequest, opts ...http.CallOption) (rsp *DeleteMenuResponse, err error) - GetMenu(ctx context.Context, req *GetMenuRequest, opts ...http.CallOption) (rsp *GetMenuResponse, err error) - ListMenus(ctx context.Context, req *ListMenusRequest, opts ...http.CallOption) (rsp *ListMenusResponse, err error) - UpdateMenu(ctx context.Context, req *UpdateMenuRequest, opts ...http.CallOption) (rsp *UpdateMenuResponse, err error) -} - -type MenuServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewMenuServiceHTTPClient(client *http.Client) MenuServiceHTTPClient { - return &MenuServiceHTTPClientImpl{client} -} - -func (c *MenuServiceHTTPClientImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest, opts ...http.CallOption) (*CreateMenuResponse, error) { - var out CreateMenuResponse - pattern := "/sys/menus" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationMenuServiceCreateMenu)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Menu, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *MenuServiceHTTPClientImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest, opts ...http.CallOption) (*DeleteMenuResponse, error) { - var out DeleteMenuResponse - pattern := "/sys/menus/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationMenuServiceDeleteMenu)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *MenuServiceHTTPClientImpl) GetMenu(ctx context.Context, in *GetMenuRequest, opts ...http.CallOption) (*GetMenuResponse, error) { - var out GetMenuResponse - pattern := "/sys/menus/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationMenuServiceGetMenu)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *MenuServiceHTTPClientImpl) ListMenus(ctx context.Context, in *ListMenusRequest, opts ...http.CallOption) (*ListMenusResponse, error) { - var out ListMenusResponse - pattern := "/sys/menus" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationMenuServiceListMenus)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *MenuServiceHTTPClientImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest, opts ...http.CallOption) (*UpdateMenuResponse, error) { - var out UpdateMenuResponse - pattern := "/sys/menus/{menu.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationMenuServiceUpdateMenu)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Menu, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/system/permission.pb.go b/api/v1/services/system/permission.pb.go deleted file mode 100644 index 65266a72..00000000 --- a/api/v1/services/system/permission.pb.go +++ /dev/null @@ -1,748 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: system/permission.proto - -package system - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ListPermissionsRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - // The data_scopes is used to query the permission by data scopes. - DataScopes []string `protobuf:"bytes,7,rep,name=data_scopes,proto3" json:"data_scopes,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPermissionsRequest) Reset() { - *x = ListPermissionsRequest{} - mi := &file_system_permission_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPermissionsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPermissionsRequest) ProtoMessage() {} - -func (x *ListPermissionsRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_permission_proto_msgTypes[0] - 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 ListPermissionsRequest.ProtoReflect.Descriptor instead. -func (*ListPermissionsRequest) Descriptor() ([]byte, []int) { - return file_system_permission_proto_rawDescGZIP(), []int{0} -} - -func (x *ListPermissionsRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListPermissionsRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListPermissionsRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListPermissionsRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListPermissionsRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListPermissionsRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -func (x *ListPermissionsRequest) GetDataScopes() []string { - if x != nil { - return x.DataScopes - } - return nil -} - -type ListPermissionsResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - // The paging menus - Permissions []*types.Permission `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPermissionsResponse) Reset() { - *x = ListPermissionsResponse{} - mi := &file_system_permission_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPermissionsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPermissionsResponse) ProtoMessage() {} - -func (x *ListPermissionsResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_permission_proto_msgTypes[1] - 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 ListPermissionsResponse.ProtoReflect.Descriptor instead. -func (*ListPermissionsResponse) Descriptor() ([]byte, []int) { - return file_system_permission_proto_rawDescGZIP(), []int{1} -} - -func (x *ListPermissionsResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListPermissionsResponse) GetPermissions() []*types.Permission { - if x != nil { - return x.Permissions - } - return nil -} - -func (x *ListPermissionsResponse) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListPermissionsResponse) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListPermissionsResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -func (x *ListPermissionsResponse) GetExtra() *anypb.Any { - if x != nil { - return x.Extra - } - return nil -} - -type GetPermissionRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/permissions/permission2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPermissionRequest) Reset() { - *x = GetPermissionRequest{} - mi := &file_system_permission_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPermissionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPermissionRequest) ProtoMessage() {} - -func (x *GetPermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_permission_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetPermissionRequest.ProtoReflect.Descriptor instead. -func (*GetPermissionRequest) Descriptor() ([]byte, []int) { - return file_system_permission_proto_rawDescGZIP(), []int{2} -} - -func (x *GetPermissionRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type GetPermissionResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Permission *types.Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPermissionResponse) Reset() { - *x = GetPermissionResponse{} - mi := &file_system_permission_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPermissionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPermissionResponse) ProtoMessage() {} - -func (x *GetPermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_permission_proto_msgTypes[3] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetPermissionResponse.ProtoReflect.Descriptor instead. -func (*GetPermissionResponse) Descriptor() ([]byte, []int) { - return file_system_permission_proto_rawDescGZIP(), []int{3} -} - -func (x *GetPermissionResponse) GetPermission() *types.Permission { - if x != nil { - return x.Permission - } - return nil -} - -type CreatePermissionRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id where the permission is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The permission id to use for this permission. - PermissionId string `protobuf:"bytes,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` - // The permission resource to create. - // The field id should match the Noun in the method id. - Permission *types.Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreatePermissionRequest) Reset() { - *x = CreatePermissionRequest{} - mi := &file_system_permission_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreatePermissionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreatePermissionRequest) ProtoMessage() {} - -func (x *CreatePermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_permission_proto_msgTypes[4] - 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 CreatePermissionRequest.ProtoReflect.Descriptor instead. -func (*CreatePermissionRequest) Descriptor() ([]byte, []int) { - return file_system_permission_proto_rawDescGZIP(), []int{4} -} - -func (x *CreatePermissionRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreatePermissionRequest) GetPermissionId() string { - if x != nil { - return x.PermissionId - } - return "" -} - -func (x *CreatePermissionRequest) GetPermission() *types.Permission { - if x != nil { - return x.Permission - } - return nil -} - -type CreatePermissionResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Permission *types.Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreatePermissionResponse) Reset() { - *x = CreatePermissionResponse{} - mi := &file_system_permission_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreatePermissionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreatePermissionResponse) ProtoMessage() {} - -func (x *CreatePermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_permission_proto_msgTypes[5] - 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 CreatePermissionResponse.ProtoReflect.Descriptor instead. -func (*CreatePermissionResponse) Descriptor() ([]byte, []int) { - return file_system_permission_proto_rawDescGZIP(), []int{5} -} - -func (x *CreatePermissionResponse) GetPermission() *types.Permission { - if x != nil { - return x.Permission - } - return nil -} - -type UpdatePermissionRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The resource name of the permission to update. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The permission resource which replaces the resource on the server. - Permission *types.Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePermissionRequest) Reset() { - *x = UpdatePermissionRequest{} - mi := &file_system_permission_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePermissionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePermissionRequest) ProtoMessage() {} - -func (x *UpdatePermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_permission_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 UpdatePermissionRequest.ProtoReflect.Descriptor instead. -func (*UpdatePermissionRequest) Descriptor() ([]byte, []int) { - return file_system_permission_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdatePermissionRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UpdatePermissionRequest) GetPermission() *types.Permission { - if x != nil { - return x.Permission - } - return nil -} - -type UpdatePermissionResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Permission *types.Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePermissionResponse) Reset() { - *x = UpdatePermissionResponse{} - mi := &file_system_permission_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePermissionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePermissionResponse) ProtoMessage() {} - -func (x *UpdatePermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_permission_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdatePermissionResponse.ProtoReflect.Descriptor instead. -func (*UpdatePermissionResponse) Descriptor() ([]byte, []int) { - return file_system_permission_proto_rawDescGZIP(), []int{7} -} - -func (x *UpdatePermissionResponse) GetPermission() *types.Permission { - if x != nil { - return x.Permission - } - return nil -} - -type DeletePermissionRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The resource id of the permission to be deleted, for example: - // "shelves/shelf1/permissions/permission2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeletePermissionRequest) Reset() { - *x = DeletePermissionRequest{} - mi := &file_system_permission_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeletePermissionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeletePermissionRequest) ProtoMessage() {} - -func (x *DeletePermissionRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_permission_proto_msgTypes[8] - 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 DeletePermissionRequest.ProtoReflect.Descriptor instead. -func (*DeletePermissionRequest) Descriptor() ([]byte, []int) { - return file_system_permission_proto_rawDescGZIP(), []int{8} -} - -func (x *DeletePermissionRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type DeletePermissionResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeletePermissionResponse) Reset() { - *x = DeletePermissionResponse{} - mi := &file_system_permission_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeletePermissionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeletePermissionResponse) ProtoMessage() {} - -func (x *DeletePermissionResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_permission_proto_msgTypes[9] - 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 DeletePermissionResponse.ProtoReflect.Descriptor instead. -func (*DeletePermissionResponse) Descriptor() ([]byte, []int) { - return file_system_permission_proto_rawDescGZIP(), []int{9} -} - -func (x *DeletePermissionResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -var File_system_permission_proto protoreflect.FileDescriptor - -const file_system_permission_proto_rawDesc = "" + - "\n" + - "\x17system/permission.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xe0\x01\n" + - "\x16ListPermissionsRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\x12 \n" + - "\vdata_scopes\x18\a \x03(\tR\vdata_scopes\"\x9b\x02\n" + - "\x17ListPermissionsResponse\x12\x1e\n" + - "\n" + - "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x12C\n" + - "\vpermissions\x18\x02 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + - "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + - "\x06_extra\"&\n" + - "\x14GetPermissionRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"Z\n" + - "\x15GetPermissionResponse\x12A\n" + - "\n" + - "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\"\x9a\x01\n" + - "\x17CreatePermissionRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12$\n" + - "\rpermission_id\x18\x03 \x01(\tR\rpermission_id\x12A\n" + - "\n" + - "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\"]\n" + - "\x18CreatePermissionResponse\x12A\n" + - "\n" + - "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\"l\n" + - "\x17UpdatePermissionRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12A\n" + - "\n" + - "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\"]\n" + - "\x18UpdatePermissionResponse\x12A\n" + - "\n" + - "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\")\n" + - "\x17DeletePermissionRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + - "\x18DeletePermissionResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x93\x06\n" + - "\x11PermissionService\x12\x8c\x01\n" + - "\x0fListPermissions\x12..api.v1.services.system.ListPermissionsRequest\x1a/.api.v1.services.system.ListPermissionsResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/permissions\x12\x8b\x01\n" + - "\rGetPermission\x12,.api.v1.services.system.GetPermissionRequest\x1a-.api.v1.services.system.GetPermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/permissions/{id}\x12\x9b\x01\n" + - "\x10CreatePermission\x12/.api.v1.services.system.CreatePermissionRequest\x1a0.api.v1.services.system.CreatePermissionResponse\"$\x82\xd3\xe4\x93\x02\x1e:\n" + - "permission\"\x10/sys/permissions\x12\xab\x01\n" + - "\x10UpdatePermission\x12/.api.v1.services.system.UpdatePermissionRequest\x1a0.api.v1.services.system.UpdatePermissionResponse\"4\x82\xd3\xe4\x93\x02.:\n" + - "permission\x1a /sys/permissions/{permission.id}\x12\x94\x01\n" + - "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xe4\x01\n" + - "\x1acom.api.v1.services.systemB\x0fPermissionProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_permission_proto_rawDescOnce sync.Once - file_system_permission_proto_rawDescData []byte -) - -func file_system_permission_proto_rawDescGZIP() []byte { - file_system_permission_proto_rawDescOnce.Do(func() { - file_system_permission_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_permission_proto_rawDesc), len(file_system_permission_proto_rawDesc))) - }) - return file_system_permission_proto_rawDescData -} - -var file_system_permission_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_system_permission_proto_goTypes = []any{ - (*ListPermissionsRequest)(nil), // 0: api.v1.services.system.ListPermissionsRequest - (*ListPermissionsResponse)(nil), // 1: api.v1.services.system.ListPermissionsResponse - (*GetPermissionRequest)(nil), // 2: api.v1.services.system.GetPermissionRequest - (*GetPermissionResponse)(nil), // 3: api.v1.services.system.GetPermissionResponse - (*CreatePermissionRequest)(nil), // 4: api.v1.services.system.CreatePermissionRequest - (*CreatePermissionResponse)(nil), // 5: api.v1.services.system.CreatePermissionResponse - (*UpdatePermissionRequest)(nil), // 6: api.v1.services.system.UpdatePermissionRequest - (*UpdatePermissionResponse)(nil), // 7: api.v1.services.system.UpdatePermissionResponse - (*DeletePermissionRequest)(nil), // 8: api.v1.services.system.DeletePermissionRequest - (*DeletePermissionResponse)(nil), // 9: api.v1.services.system.DeletePermissionResponse - (*types.Permission)(nil), // 10: api.v1.services.types.Permission - (*anypb.Any)(nil), // 11: google.protobuf.Any - (*emptypb.Empty)(nil), // 12: google.protobuf.Empty -} -var file_system_permission_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListPermissionsResponse.permissions:type_name -> api.v1.services.types.Permission - 11, // 1: api.v1.services.system.ListPermissionsResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetPermissionResponse.permission:type_name -> api.v1.services.types.Permission - 10, // 3: api.v1.services.system.CreatePermissionRequest.permission:type_name -> api.v1.services.types.Permission - 10, // 4: api.v1.services.system.CreatePermissionResponse.permission:type_name -> api.v1.services.types.Permission - 10, // 5: api.v1.services.system.UpdatePermissionRequest.permission:type_name -> api.v1.services.types.Permission - 10, // 6: api.v1.services.system.UpdatePermissionResponse.permission:type_name -> api.v1.services.types.Permission - 12, // 7: api.v1.services.system.DeletePermissionResponse.empty:type_name -> google.protobuf.Empty - 0, // 8: api.v1.services.system.PermissionService.ListPermissions:input_type -> api.v1.services.system.ListPermissionsRequest - 2, // 9: api.v1.services.system.PermissionService.GetPermission:input_type -> api.v1.services.system.GetPermissionRequest - 4, // 10: api.v1.services.system.PermissionService.CreatePermission:input_type -> api.v1.services.system.CreatePermissionRequest - 6, // 11: api.v1.services.system.PermissionService.UpdatePermission:input_type -> api.v1.services.system.UpdatePermissionRequest - 8, // 12: api.v1.services.system.PermissionService.DeletePermission:input_type -> api.v1.services.system.DeletePermissionRequest - 1, // 13: api.v1.services.system.PermissionService.ListPermissions:output_type -> api.v1.services.system.ListPermissionsResponse - 3, // 14: api.v1.services.system.PermissionService.GetPermission:output_type -> api.v1.services.system.GetPermissionResponse - 5, // 15: api.v1.services.system.PermissionService.CreatePermission:output_type -> api.v1.services.system.CreatePermissionResponse - 7, // 16: api.v1.services.system.PermissionService.UpdatePermission:output_type -> api.v1.services.system.UpdatePermissionResponse - 9, // 17: api.v1.services.system.PermissionService.DeletePermission:output_type -> api.v1.services.system.DeletePermissionResponse - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_system_permission_proto_init() } -func file_system_permission_proto_init() { - if File_system_permission_proto != nil { - return - } - file_system_permission_proto_msgTypes[1].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_permission_proto_rawDesc), len(file_system_permission_proto_rawDesc)), - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_system_permission_proto_goTypes, - DependencyIndexes: file_system_permission_proto_depIdxs, - MessageInfos: file_system_permission_proto_msgTypes, - }.Build() - File_system_permission_proto = out.File - file_system_permission_proto_goTypes = nil - file_system_permission_proto_depIdxs = nil -} diff --git a/api/v1/services/system/permission.pb.gw.go b/api/v1/services/system/permission.pb.gw.go deleted file mode 100644 index 77dfdf2c..00000000 --- a/api/v1/services/system/permission.pb.gw.go +++ /dev/null @@ -1,487 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/permission.proto - -/* -Package system is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package system - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_PermissionService_ListPermissions_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_PermissionService_ListPermissions_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPermissionsRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_ListPermissions_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListPermissions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PermissionService_ListPermissions_0(ctx context.Context, marshaler runtime.Marshaler, server PermissionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPermissionsRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_ListPermissions_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListPermissions(ctx, &protoReq) - return msg, metadata, err -} - -func request_PermissionService_GetPermission_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPermissionRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetPermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PermissionService_GetPermission_0(ctx context.Context, marshaler runtime.Marshaler, server PermissionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPermissionRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetPermission(ctx, &protoReq) - return msg, metadata, err -} - -var filter_PermissionService_CreatePermission_0 = &utilities.DoubleArray{Encoding: map[string]int{"permission": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - -func request_PermissionService_CreatePermission_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreatePermissionRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_CreatePermission_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreatePermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PermissionService_CreatePermission_0(ctx context.Context, marshaler runtime.Marshaler, server PermissionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreatePermissionRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_CreatePermission_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreatePermission(ctx, &protoReq) - return msg, metadata, err -} - -var filter_PermissionService_UpdatePermission_0 = &utilities.DoubleArray{Encoding: map[string]int{"permission": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - -func request_PermissionService_UpdatePermission_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePermissionRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["permission.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "permission.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "permission.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "permission.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_UpdatePermission_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PermissionService_UpdatePermission_0(ctx context.Context, marshaler runtime.Marshaler, server PermissionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePermissionRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["permission.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "permission.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "permission.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "permission.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_UpdatePermission_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePermission(ctx, &protoReq) - return msg, metadata, err -} - -func request_PermissionService_DeletePermission_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeletePermissionRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.DeletePermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PermissionService_DeletePermission_0(ctx context.Context, marshaler runtime.Marshaler, server PermissionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeletePermissionRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.DeletePermission(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterPermissionServiceHandlerServer registers the http handlers for service PermissionService to "mux". -// UnaryRPC :call PermissionServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPermissionServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterPermissionServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PermissionServiceServer) error { - mux.Handle(http.MethodGet, pattern_PermissionService_ListPermissions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PermissionService/ListPermissions", runtime.WithHTTPPathPattern("/sys/permissions")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PermissionService_ListPermissions_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PermissionService_ListPermissions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PermissionService_GetPermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PermissionService/GetPermission", runtime.WithHTTPPathPattern("/sys/permissions/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PermissionService_GetPermission_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PermissionService_GetPermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PermissionService_CreatePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PermissionService/CreatePermission", runtime.WithHTTPPathPattern("/sys/permissions")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PermissionService_CreatePermission_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PermissionService_CreatePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PermissionService_UpdatePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PermissionService/UpdatePermission", runtime.WithHTTPPathPattern("/sys/permissions/{permission.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PermissionService_UpdatePermission_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PermissionService_UpdatePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_PermissionService_DeletePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PermissionService/DeletePermission", runtime.WithHTTPPathPattern("/sys/permissions/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PermissionService_DeletePermission_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PermissionService_DeletePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterPermissionServiceHandlerFromEndpoint is same as RegisterPermissionServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterPermissionServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterPermissionServiceHandler(ctx, mux, conn) -} - -// RegisterPermissionServiceHandler registers the http handlers for service PermissionService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterPermissionServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterPermissionServiceHandlerClient(ctx, mux, NewPermissionServiceClient(conn)) -} - -// RegisterPermissionServiceHandlerClient registers the http handlers for service PermissionService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PermissionServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PermissionServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "PermissionServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterPermissionServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PermissionServiceClient) error { - mux.Handle(http.MethodGet, pattern_PermissionService_ListPermissions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PermissionService/ListPermissions", runtime.WithHTTPPathPattern("/sys/permissions")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PermissionService_ListPermissions_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PermissionService_ListPermissions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PermissionService_GetPermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PermissionService/GetPermission", runtime.WithHTTPPathPattern("/sys/permissions/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PermissionService_GetPermission_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PermissionService_GetPermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PermissionService_CreatePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PermissionService/CreatePermission", runtime.WithHTTPPathPattern("/sys/permissions")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PermissionService_CreatePermission_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PermissionService_CreatePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PermissionService_UpdatePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PermissionService/UpdatePermission", runtime.WithHTTPPathPattern("/sys/permissions/{permission.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PermissionService_UpdatePermission_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PermissionService_UpdatePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_PermissionService_DeletePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PermissionService/DeletePermission", runtime.WithHTTPPathPattern("/sys/permissions/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PermissionService_DeletePermission_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PermissionService_DeletePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_PermissionService_ListPermissions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "permissions"}, "")) - pattern_PermissionService_GetPermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "permissions", "id"}, "")) - pattern_PermissionService_CreatePermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "permissions"}, "")) - pattern_PermissionService_UpdatePermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "permissions", "permission.id"}, "")) - pattern_PermissionService_DeletePermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "permissions", "id"}, "")) -) - -var ( - forward_PermissionService_ListPermissions_0 = runtime.ForwardResponseMessage - forward_PermissionService_GetPermission_0 = runtime.ForwardResponseMessage - forward_PermissionService_CreatePermission_0 = runtime.ForwardResponseMessage - forward_PermissionService_UpdatePermission_0 = runtime.ForwardResponseMessage - forward_PermissionService_DeletePermission_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/system/permission.pb.validate.go b/api/v1/services/system/permission.pb.validate.go deleted file mode 100644 index 4e4555e6..00000000 --- a/api/v1/services/system/permission.pb.validate.go +++ /dev/null @@ -1,1327 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/permission.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListPermissionsRequest 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 *ListPermissionsRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPermissionsRequest 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 -// ListPermissionsRequestMultiError, or nil if none found. -func (m *ListPermissionsRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPermissionsRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - if len(errors) > 0 { - return ListPermissionsRequestMultiError(errors) - } - - return nil -} - -// ListPermissionsRequestMultiError is an error wrapping multiple validation -// errors returned by ListPermissionsRequest.ValidateAll() if the designated -// constraints aren't met. -type ListPermissionsRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPermissionsRequestMultiError) 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 ListPermissionsRequestMultiError) AllErrors() []error { return m } - -// ListPermissionsRequestValidationError is the validation error returned by -// ListPermissionsRequest.Validate if the designated constraints aren't met. -type ListPermissionsRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPermissionsRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPermissionsRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPermissionsRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPermissionsRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPermissionsRequestValidationError) ErrorName() string { - return "ListPermissionsRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPermissionsRequestValidationError) 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 %sListPermissionsRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPermissionsRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPermissionsRequestValidationError{} - -// Validate checks the field values on ListPermissionsResponse 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 *ListPermissionsResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPermissionsResponse 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 -// ListPermissionsResponseMultiError, or nil if none found. -func (m *ListPermissionsResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPermissionsResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPermissionsResponseValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPermissionsResponseValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPermissionsResponseValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for NextPageToken - - if m.Extra != nil { - - if all { - switch v := interface{}(m.GetExtra()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPermissionsResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPermissionsResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPermissionsResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListPermissionsResponseMultiError(errors) - } - - return nil -} - -// ListPermissionsResponseMultiError is an error wrapping multiple validation -// errors returned by ListPermissionsResponse.ValidateAll() if the designated -// constraints aren't met. -type ListPermissionsResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPermissionsResponseMultiError) 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 ListPermissionsResponseMultiError) AllErrors() []error { return m } - -// ListPermissionsResponseValidationError is the validation error returned by -// ListPermissionsResponse.Validate if the designated constraints aren't met. -type ListPermissionsResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPermissionsResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPermissionsResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPermissionsResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPermissionsResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPermissionsResponseValidationError) ErrorName() string { - return "ListPermissionsResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPermissionsResponseValidationError) 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 %sListPermissionsResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPermissionsResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPermissionsResponseValidationError{} - -// Validate checks the field values on GetPermissionRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *GetPermissionRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPermissionRequest with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// GetPermissionRequestMultiError, or nil if none found. -func (m *GetPermissionRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPermissionRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return GetPermissionRequestMultiError(errors) - } - - return nil -} - -// GetPermissionRequestMultiError is an error wrapping multiple validation -// errors returned by GetPermissionRequest.ValidateAll() if the designated -// constraints aren't met. -type GetPermissionRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPermissionRequestMultiError) Error() string { - msgs := make([]string, 0, len(m)) - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m GetPermissionRequestMultiError) AllErrors() []error { return m } - -// GetPermissionRequestValidationError is the validation error returned by -// GetPermissionRequest.Validate if the designated constraints aren't met. -type GetPermissionRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPermissionRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPermissionRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPermissionRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPermissionRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPermissionRequestValidationError) ErrorName() string { - return "GetPermissionRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPermissionRequestValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sGetPermissionRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPermissionRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPermissionRequestValidationError{} - -// Validate checks the field values on GetPermissionResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the first error encountered is returned, or nil if there are no violations. -func (m *GetPermissionResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPermissionResponse with the rules -// defined in the proto definition for this message. If any rules are -// violated, the result is a list of violation errors wrapped in -// GetPermissionResponseMultiError, or nil if none found. -func (m *GetPermissionResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPermissionResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetPermissionResponseValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetPermissionResponseValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetPermissionResponseValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetPermissionResponseMultiError(errors) - } - - return nil -} - -// GetPermissionResponseMultiError is an error wrapping multiple validation -// errors returned by GetPermissionResponse.ValidateAll() if the designated -// constraints aren't met. -type GetPermissionResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPermissionResponseMultiError) Error() string { - msgs := make([]string, 0, len(m)) - for _, err := range m { - msgs = append(msgs, err.Error()) - } - return strings.Join(msgs, "; ") -} - -// AllErrors returns a list of validation violation errors. -func (m GetPermissionResponseMultiError) AllErrors() []error { return m } - -// GetPermissionResponseValidationError is the validation error returned by -// GetPermissionResponse.Validate if the designated constraints aren't met. -type GetPermissionResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPermissionResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPermissionResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPermissionResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPermissionResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPermissionResponseValidationError) ErrorName() string { - return "GetPermissionResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPermissionResponseValidationError) Error() string { - cause := "" - if e.cause != nil { - cause = fmt.Sprintf(" | caused by: %v", e.cause) - } - - key := "" - if e.key { - key = "key for " - } - - return fmt.Sprintf( - "invalid %sGetPermissionResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPermissionResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPermissionResponseValidationError{} - -// Validate checks the field values on CreatePermissionRequest 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 *CreatePermissionRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreatePermissionRequest 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 -// CreatePermissionRequestMultiError, or nil if none found. -func (m *CreatePermissionRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreatePermissionRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Parent - - // no validation rules for PermissionId - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreatePermissionRequestValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreatePermissionRequestValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreatePermissionRequestValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreatePermissionRequestMultiError(errors) - } - - return nil -} - -// CreatePermissionRequestMultiError is an error wrapping multiple validation -// errors returned by CreatePermissionRequest.ValidateAll() if the designated -// constraints aren't met. -type CreatePermissionRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreatePermissionRequestMultiError) 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 CreatePermissionRequestMultiError) AllErrors() []error { return m } - -// CreatePermissionRequestValidationError is the validation error returned by -// CreatePermissionRequest.Validate if the designated constraints aren't met. -type CreatePermissionRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreatePermissionRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreatePermissionRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreatePermissionRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreatePermissionRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreatePermissionRequestValidationError) ErrorName() string { - return "CreatePermissionRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreatePermissionRequestValidationError) 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 %sCreatePermissionRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreatePermissionRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreatePermissionRequestValidationError{} - -// Validate checks the field values on CreatePermissionResponse 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 *CreatePermissionResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreatePermissionResponse 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 -// CreatePermissionResponseMultiError, or nil if none found. -func (m *CreatePermissionResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreatePermissionResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreatePermissionResponseValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreatePermissionResponseValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreatePermissionResponseValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreatePermissionResponseMultiError(errors) - } - - return nil -} - -// CreatePermissionResponseMultiError is an error wrapping multiple validation -// errors returned by CreatePermissionResponse.ValidateAll() if the designated -// constraints aren't met. -type CreatePermissionResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreatePermissionResponseMultiError) 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 CreatePermissionResponseMultiError) AllErrors() []error { return m } - -// CreatePermissionResponseValidationError is the validation error returned by -// CreatePermissionResponse.Validate if the designated constraints aren't met. -type CreatePermissionResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreatePermissionResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreatePermissionResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreatePermissionResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreatePermissionResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreatePermissionResponseValidationError) ErrorName() string { - return "CreatePermissionResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreatePermissionResponseValidationError) 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 %sCreatePermissionResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreatePermissionResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreatePermissionResponseValidationError{} - -// Validate checks the field values on UpdatePermissionRequest 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 *UpdatePermissionRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePermissionRequest 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 -// UpdatePermissionRequestMultiError, or nil if none found. -func (m *UpdatePermissionRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePermissionRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePermissionRequestValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePermissionRequestValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePermissionRequestValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePermissionRequestMultiError(errors) - } - - return nil -} - -// UpdatePermissionRequestMultiError is an error wrapping multiple validation -// errors returned by UpdatePermissionRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdatePermissionRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePermissionRequestMultiError) 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 UpdatePermissionRequestMultiError) AllErrors() []error { return m } - -// UpdatePermissionRequestValidationError is the validation error returned by -// UpdatePermissionRequest.Validate if the designated constraints aren't met. -type UpdatePermissionRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePermissionRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePermissionRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePermissionRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePermissionRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePermissionRequestValidationError) ErrorName() string { - return "UpdatePermissionRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePermissionRequestValidationError) 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 %sUpdatePermissionRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePermissionRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePermissionRequestValidationError{} - -// Validate checks the field values on UpdatePermissionResponse 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 *UpdatePermissionResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePermissionResponse 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 -// UpdatePermissionResponseMultiError, or nil if none found. -func (m *UpdatePermissionResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePermissionResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePermissionResponseValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePermissionResponseValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePermissionResponseValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePermissionResponseMultiError(errors) - } - - return nil -} - -// UpdatePermissionResponseMultiError is an error wrapping multiple validation -// errors returned by UpdatePermissionResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdatePermissionResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePermissionResponseMultiError) 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 UpdatePermissionResponseMultiError) AllErrors() []error { return m } - -// UpdatePermissionResponseValidationError is the validation error returned by -// UpdatePermissionResponse.Validate if the designated constraints aren't met. -type UpdatePermissionResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePermissionResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePermissionResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePermissionResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePermissionResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePermissionResponseValidationError) ErrorName() string { - return "UpdatePermissionResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePermissionResponseValidationError) 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 %sUpdatePermissionResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePermissionResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePermissionResponseValidationError{} - -// Validate checks the field values on DeletePermissionRequest 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 *DeletePermissionRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeletePermissionRequest 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 -// DeletePermissionRequestMultiError, or nil if none found. -func (m *DeletePermissionRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeletePermissionRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return DeletePermissionRequestMultiError(errors) - } - - return nil -} - -// DeletePermissionRequestMultiError is an error wrapping multiple validation -// errors returned by DeletePermissionRequest.ValidateAll() if the designated -// constraints aren't met. -type DeletePermissionRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeletePermissionRequestMultiError) 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 DeletePermissionRequestMultiError) AllErrors() []error { return m } - -// DeletePermissionRequestValidationError is the validation error returned by -// DeletePermissionRequest.Validate if the designated constraints aren't met. -type DeletePermissionRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeletePermissionRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeletePermissionRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeletePermissionRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeletePermissionRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeletePermissionRequestValidationError) ErrorName() string { - return "DeletePermissionRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeletePermissionRequestValidationError) 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 %sDeletePermissionRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeletePermissionRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeletePermissionRequestValidationError{} - -// Validate checks the field values on DeletePermissionResponse 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 *DeletePermissionResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeletePermissionResponse 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 -// DeletePermissionResponseMultiError, or nil if none found. -func (m *DeletePermissionResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeletePermissionResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeletePermissionResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeletePermissionResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeletePermissionResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeletePermissionResponseMultiError(errors) - } - - return nil -} - -// DeletePermissionResponseMultiError is an error wrapping multiple validation -// errors returned by DeletePermissionResponse.ValidateAll() if the designated -// constraints aren't met. -type DeletePermissionResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeletePermissionResponseMultiError) 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 DeletePermissionResponseMultiError) AllErrors() []error { return m } - -// DeletePermissionResponseValidationError is the validation error returned by -// DeletePermissionResponse.Validate if the designated constraints aren't met. -type DeletePermissionResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeletePermissionResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeletePermissionResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeletePermissionResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeletePermissionResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeletePermissionResponseValidationError) ErrorName() string { - return "DeletePermissionResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeletePermissionResponseValidationError) 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 %sDeletePermissionResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeletePermissionResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeletePermissionResponseValidationError{} diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go deleted file mode 100644 index 9648b59b..00000000 --- a/api/v1/services/system/permission_bridge.pb.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: system/permission.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const PermissionServiceCreatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/CreatePermission" -const PermissionServiceDeletePermissionBridgeOperation = "/api.v1.services.system.PermissionService/DeletePermission" -const PermissionServiceGetPermissionBridgeOperation = "/api.v1.services.system.PermissionService/GetPermission" -const PermissionServiceListPermissionsBridgeOperation = "/api.v1.services.system.PermissionService/ListPermissions" -const PermissionServiceUpdatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/UpdatePermission" - -type PermissionServiceBridgeServer interface { - CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) - DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) - GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) - ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) - UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) -} - -type PermissionServiceHooker interface { - PermissionServiceCreatePermissionHooker - PermissionServiceDeletePermissionHooker - PermissionServiceGetPermissionHooker - PermissionServiceListPermissionsHooker - PermissionServiceUpdatePermissionHooker -} - -type PermissionServiceHookedBridger interface { - PermissionServiceHooker - PermissionServiceBridgeServer -} -type PermissionServiceCreatePermissionHooker interface { - PrepareCreatePermission(http.Context, *CreatePermissionRequest) (context.Context, error) - CompleteCreatePermission(http.Context, *CreatePermissionRequest, *CreatePermissionResponse) error -} -type PermissionServiceDeletePermissionHooker interface { - PrepareDeletePermission(http.Context, *DeletePermissionRequest) (context.Context, error) - CompleteDeletePermission(http.Context, *DeletePermissionRequest, *DeletePermissionResponse) error -} -type PermissionServiceGetPermissionHooker interface { - PrepareGetPermission(http.Context, *GetPermissionRequest) (context.Context, error) - CompleteGetPermission(http.Context, *GetPermissionRequest, *GetPermissionResponse) error -} -type PermissionServiceListPermissionsHooker interface { - PrepareListPermissions(http.Context, *ListPermissionsRequest) (context.Context, error) - CompleteListPermissions(http.Context, *ListPermissionsRequest, *ListPermissionsResponse) error -} -type PermissionServiceUpdatePermissionHooker interface { - PrepareUpdatePermission(http.Context, *UpdatePermissionRequest) (context.Context, error) - CompleteUpdatePermission(http.Context, *UpdatePermissionRequest, *UpdatePermissionResponse) error -} - -func RegisterPermissionServiceBridgeServer(s *http.Server, srv PermissionServiceHookedBridger) { - r := s.Route("/") - r.GET("/sys/permissions", _PermissionService_ListPermissions0_Bridge_Handler(srv)) - r.GET("/sys/permissions/:id", _PermissionService_GetPermission0_Bridge_Handler(srv)) - r.POST("/sys/permissions", _PermissionService_CreatePermission0_Bridge_Handler(srv)) - r.PUT("/sys/permissions/:permission.id", _PermissionService_UpdatePermission0_Bridge_Handler(srv)) - r.DELETE("/sys/permissions/:id", _PermissionService_DeletePermission0_Bridge_Handler(srv)) -} - -func _PermissionService_ListPermissions0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPermissionsRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPermissionServiceListPermissions) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPermissions(ctx, req.(*ListPermissionsRequest)) - }) - - newctx, err := srv.PrepareListPermissions(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPermissions(ctx, &in, out.(*ListPermissionsResponse)) - } -} - -func _PermissionService_GetPermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPermissionRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPermissionServiceGetPermission) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPermission(ctx, req.(*GetPermissionRequest)) - }) - - newctx, err := srv.PrepareGetPermission(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetPermission(ctx, &in, out.(*GetPermissionResponse)) - } -} - -func _PermissionService_CreatePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreatePermissionRequest - if err := ctx.Bind(&in.Permission); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPermissionServiceCreatePermission) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreatePermission(ctx, req.(*CreatePermissionRequest)) - }) - - newctx, err := srv.PrepareCreatePermission(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreatePermission(ctx, &in, out.(*CreatePermissionResponse)) - } -} - -func _PermissionService_UpdatePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePermissionRequest - if err := ctx.Bind(&in.Permission); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPermissionServiceUpdatePermission) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePermission(ctx, req.(*UpdatePermissionRequest)) - }) - - newctx, err := srv.PrepareUpdatePermission(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePermission(ctx, &in, out.(*UpdatePermissionResponse)) - } -} - -func _PermissionService_DeletePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeletePermissionRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPermissionServiceDeletePermission) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeletePermission(ctx, req.(*DeletePermissionRequest)) - }) - - newctx, err := srv.PrepareDeletePermission(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeletePermission(ctx, &in, out.(*DeletePermissionResponse)) - } -} - -// UnimplementedPermissionServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPermissionServiceHooked struct{} - -func (UnimplementedPermissionServiceHooked) PrepareCreatePermission(ctx http.Context, in *CreatePermissionRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPermissionServiceHooked) CompleteCreatePermission(ctx http.Context, in *CreatePermissionRequest, out *CreatePermissionResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPermissionServiceHooked) PrepareDeletePermission(ctx http.Context, in *DeletePermissionRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPermissionServiceHooked) CompleteDeletePermission(ctx http.Context, in *DeletePermissionRequest, out *DeletePermissionResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPermissionServiceHooked) PrepareGetPermission(ctx http.Context, in *GetPermissionRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPermissionServiceHooked) CompleteGetPermission(ctx http.Context, in *GetPermissionRequest, out *GetPermissionResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPermissionServiceHooked) PrepareListPermissions(ctx http.Context, in *ListPermissionsRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPermissionServiceHooked) CompleteListPermissions(ctx http.Context, in *ListPermissionsRequest, out *ListPermissionsResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPermissionServiceHooked) PrepareUpdatePermission(ctx http.Context, in *UpdatePermissionRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPermissionServiceHooked) CompleteUpdatePermission(ctx http.Context, in *UpdatePermissionRequest, out *UpdatePermissionResponse) error { - return ctx.Result(200, out) -} - -func WithPermissionServiceHook(h PermissionServiceHooker) func(PermissionServiceBridgeServer) PermissionServiceHookedBridger { - return func(srv PermissionServiceBridgeServer) PermissionServiceHookedBridger { - return PermissionServiceHookedBridge{PermissionServiceBridgeServer: srv, PermissionServiceHooker: h} - } -} - -// PermissionServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PermissionService. -// It implements the HTTP and gRPC implementations of PermissionService. -// It forwards requests and responses between the two implementations. -type PermissionServiceHookedBridge struct { - PermissionServiceBridgeServer - PermissionServiceHooker -} - -type PermissionServiceHTTPBridgeImpl struct { - client PermissionServiceHTTPClient -} - -func NewPermissionServiceHTTPBridge(client *http.Client) PermissionServiceHTTPServer { - return &PermissionServiceHTTPBridgeImpl{client: NewPermissionServiceHTTPClient(client)} -} - -func (c *PermissionServiceHTTPBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { - return c.client.CreatePermission(ctx, in) -} - -func (c *PermissionServiceHTTPBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { - return c.client.DeletePermission(ctx, in) -} - -func (c *PermissionServiceHTTPBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { - return c.client.GetPermission(ctx, in) -} - -func (c *PermissionServiceHTTPBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { - return c.client.ListPermissions(ctx, in) -} - -func (c *PermissionServiceHTTPBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { - return c.client.UpdatePermission(ctx, in) -} - -type PermissionServiceBridgeImpl struct { - client PermissionServiceClient -} - -func NewPermissionServiceBridge(client grpc.ClientConnInterface) PermissionServiceServer { - return &PermissionServiceBridgeImpl{client: NewPermissionServiceClient(client)} -} - -func (c *PermissionServiceBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { - return c.client.CreatePermission(ctx, in) -} - -func (c *PermissionServiceBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { - return c.client.DeletePermission(ctx, in) -} - -func (c *PermissionServiceBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { - return c.client.GetPermission(ctx, in) -} - -func (c *PermissionServiceBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { - return c.client.ListPermissions(ctx, in) -} - -func (c *PermissionServiceBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { - return c.client.UpdatePermission(ctx, in) -} - -func (c *PermissionServiceBridgeImpl) mustEmbedUnimplementedPermissionServiceServer() {} - -type PermissionServiceGRPC2HTTPBridgeImpl struct { - client PermissionServiceClient -} - -func NewPermissionServiceGRPC2HTTP(client grpc.ClientConnInterface) PermissionServiceHTTPServer { - return &PermissionServiceGRPC2HTTPBridgeImpl{client: NewPermissionServiceClient(client)} -} - -func (c *PermissionServiceGRPC2HTTPBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { - return c.client.CreatePermission(ctx, in) -} - -func (c *PermissionServiceGRPC2HTTPBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { - return c.client.DeletePermission(ctx, in) -} - -func (c *PermissionServiceGRPC2HTTPBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { - return c.client.GetPermission(ctx, in) -} - -func (c *PermissionServiceGRPC2HTTPBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { - return c.client.ListPermissions(ctx, in) -} - -func (c *PermissionServiceGRPC2HTTPBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { - return c.client.UpdatePermission(ctx, in) -} - -type PermissionServiceHTTP2GRPCBridgeImpl struct { - client PermissionServiceHTTPClient -} - -func NewPermissionServiceHTTP2GRPC(client *http.Client) PermissionServiceServer { - return &PermissionServiceHTTP2GRPCBridgeImpl{client: NewPermissionServiceHTTPClient(client)} -} - -func (c *PermissionServiceHTTP2GRPCBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { - return c.client.CreatePermission(ctx, in) -} - -func (c *PermissionServiceHTTP2GRPCBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { - return c.client.DeletePermission(ctx, in) -} - -func (c *PermissionServiceHTTP2GRPCBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { - return c.client.GetPermission(ctx, in) -} - -func (c *PermissionServiceHTTP2GRPCBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { - return c.client.ListPermissions(ctx, in) -} - -func (c *PermissionServiceHTTP2GRPCBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { - return c.client.UpdatePermission(ctx, in) -} - -func (c *PermissionServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPermissionServiceServer() {} diff --git a/api/v1/services/system/permission_grpc.pb.go b/api/v1/services/system/permission_grpc.pb.go deleted file mode 100644 index 5e63a801..00000000 --- a/api/v1/services/system/permission_grpc.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: system/permission.proto - -package system - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - PermissionService_ListPermissions_FullMethodName = "/api.v1.services.system.PermissionService/ListPermissions" - PermissionService_GetPermission_FullMethodName = "/api.v1.services.system.PermissionService/GetPermission" - PermissionService_CreatePermission_FullMethodName = "/api.v1.services.system.PermissionService/CreatePermission" - PermissionService_UpdatePermission_FullMethodName = "/api.v1.services.system.PermissionService/UpdatePermission" - PermissionService_DeletePermission_FullMethodName = "/api.v1.services.system.PermissionService/DeletePermission" -) - -// PermissionServiceClient is the client API for PermissionService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The login service definition. -type PermissionServiceClient interface { - ListPermissions(ctx context.Context, in *ListPermissionsRequest, opts ...grpc.CallOption) (*ListPermissionsResponse, error) - GetPermission(ctx context.Context, in *GetPermissionRequest, opts ...grpc.CallOption) (*GetPermissionResponse, error) - CreatePermission(ctx context.Context, in *CreatePermissionRequest, opts ...grpc.CallOption) (*CreatePermissionResponse, error) - UpdatePermission(ctx context.Context, in *UpdatePermissionRequest, opts ...grpc.CallOption) (*UpdatePermissionResponse, error) - DeletePermission(ctx context.Context, in *DeletePermissionRequest, opts ...grpc.CallOption) (*DeletePermissionResponse, error) -} - -type permissionServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewPermissionServiceClient(cc grpc.ClientConnInterface) PermissionServiceClient { - return &permissionServiceClient{cc} -} - -func (c *permissionServiceClient) ListPermissions(ctx context.Context, in *ListPermissionsRequest, opts ...grpc.CallOption) (*ListPermissionsResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPermissionsResponse) - err := c.cc.Invoke(ctx, PermissionService_ListPermissions_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *permissionServiceClient) GetPermission(ctx context.Context, in *GetPermissionRequest, opts ...grpc.CallOption) (*GetPermissionResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetPermissionResponse) - err := c.cc.Invoke(ctx, PermissionService_GetPermission_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *permissionServiceClient) CreatePermission(ctx context.Context, in *CreatePermissionRequest, opts ...grpc.CallOption) (*CreatePermissionResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreatePermissionResponse) - err := c.cc.Invoke(ctx, PermissionService_CreatePermission_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *permissionServiceClient) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest, opts ...grpc.CallOption) (*UpdatePermissionResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePermissionResponse) - err := c.cc.Invoke(ctx, PermissionService_UpdatePermission_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *permissionServiceClient) DeletePermission(ctx context.Context, in *DeletePermissionRequest, opts ...grpc.CallOption) (*DeletePermissionResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeletePermissionResponse) - err := c.cc.Invoke(ctx, PermissionService_DeletePermission_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// PermissionServiceServer is the server API for PermissionService service. -// All implementations must embed UnimplementedPermissionServiceServer -// for forward compatibility. -// -// The login service definition. -type PermissionServiceServer interface { - ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) - GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) - CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) - UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) - DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) - mustEmbedUnimplementedPermissionServiceServer() -} - -// UnimplementedPermissionServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPermissionServiceServer struct{} - -func (UnimplementedPermissionServiceServer) ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPermissions not implemented") -} -func (UnimplementedPermissionServiceServer) GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetPermission not implemented") -} -func (UnimplementedPermissionServiceServer) CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreatePermission not implemented") -} -func (UnimplementedPermissionServiceServer) UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePermission not implemented") -} -func (UnimplementedPermissionServiceServer) DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeletePermission not implemented") -} -func (UnimplementedPermissionServiceServer) mustEmbedUnimplementedPermissionServiceServer() {} -func (UnimplementedPermissionServiceServer) testEmbeddedByValue() {} - -// UnsafePermissionServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to PermissionServiceServer will -// result in compilation errors. -type UnsafePermissionServiceServer interface { - mustEmbedUnimplementedPermissionServiceServer() -} - -func RegisterPermissionServiceServer(s grpc.ServiceRegistrar, srv PermissionServiceServer) { - // If the following call pancis, it indicates UnimplementedPermissionServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&PermissionService_ServiceDesc, srv) -} - -func _PermissionService_ListPermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPermissionsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PermissionServiceServer).ListPermissions(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PermissionService_ListPermissions_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PermissionServiceServer).ListPermissions(ctx, req.(*ListPermissionsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PermissionService_GetPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPermissionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PermissionServiceServer).GetPermission(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PermissionService_GetPermission_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PermissionServiceServer).GetPermission(ctx, req.(*GetPermissionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PermissionService_CreatePermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreatePermissionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PermissionServiceServer).CreatePermission(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PermissionService_CreatePermission_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PermissionServiceServer).CreatePermission(ctx, req.(*CreatePermissionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PermissionService_UpdatePermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePermissionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PermissionServiceServer).UpdatePermission(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PermissionService_UpdatePermission_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PermissionServiceServer).UpdatePermission(ctx, req.(*UpdatePermissionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PermissionService_DeletePermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeletePermissionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PermissionServiceServer).DeletePermission(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PermissionService_DeletePermission_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PermissionServiceServer).DeletePermission(ctx, req.(*DeletePermissionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// PermissionService_ServiceDesc is the grpc.ServiceDesc for PermissionService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var PermissionService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.PermissionService", - HandlerType: (*PermissionServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListPermissions", - Handler: _PermissionService_ListPermissions_Handler, - }, - { - MethodName: "GetPermission", - Handler: _PermissionService_GetPermission_Handler, - }, - { - MethodName: "CreatePermission", - Handler: _PermissionService_CreatePermission_Handler, - }, - { - MethodName: "UpdatePermission", - Handler: _PermissionService_UpdatePermission_Handler, - }, - { - MethodName: "DeletePermission", - Handler: _PermissionService_DeletePermission_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "system/permission.proto", -} diff --git a/api/v1/services/system/permission_http.pb.go b/api/v1/services/system/permission_http.pb.go deleted file mode 100644 index 51616cbb..00000000 --- a/api/v1/services/system/permission_http.pb.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: system/permission.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationPermissionServiceCreatePermission = "/api.v1.services.system.PermissionService/CreatePermission" -const OperationPermissionServiceDeletePermission = "/api.v1.services.system.PermissionService/DeletePermission" -const OperationPermissionServiceGetPermission = "/api.v1.services.system.PermissionService/GetPermission" -const OperationPermissionServiceListPermissions = "/api.v1.services.system.PermissionService/ListPermissions" -const OperationPermissionServiceUpdatePermission = "/api.v1.services.system.PermissionService/UpdatePermission" - -type PermissionServiceHTTPServer interface { - CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) - DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) - GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) - ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) - UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) -} - -func RegisterPermissionServiceHTTPServer(s *http.Server, srv PermissionServiceHTTPServer) { - r := s.Route("/") - r.GET("/sys/permissions", _PermissionService_ListPermissions0_HTTP_Handler(srv)) - r.GET("/sys/permissions/{id}", _PermissionService_GetPermission0_HTTP_Handler(srv)) - r.POST("/sys/permissions", _PermissionService_CreatePermission0_HTTP_Handler(srv)) - r.PUT("/sys/permissions/{permission.id}", _PermissionService_UpdatePermission0_HTTP_Handler(srv)) - r.DELETE("/sys/permissions/{id}", _PermissionService_DeletePermission0_HTTP_Handler(srv)) -} - -func _PermissionService_ListPermissions0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPermissionsRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPermissionServiceListPermissions) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPermissions(ctx, req.(*ListPermissionsRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPermissionsResponse) - return ctx.Result(200, reply) - } -} - -func _PermissionService_GetPermission0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPermissionRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPermissionServiceGetPermission) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPermission(ctx, req.(*GetPermissionRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetPermissionResponse) - return ctx.Result(200, reply) - } -} - -func _PermissionService_CreatePermission0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreatePermissionRequest - if err := ctx.Bind(&in.Permission); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPermissionServiceCreatePermission) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreatePermission(ctx, req.(*CreatePermissionRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreatePermissionResponse) - return ctx.Result(200, reply) - } -} - -func _PermissionService_UpdatePermission0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePermissionRequest - if err := ctx.Bind(&in.Permission); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPermissionServiceUpdatePermission) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePermission(ctx, req.(*UpdatePermissionRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePermissionResponse) - return ctx.Result(200, reply) - } -} - -func _PermissionService_DeletePermission0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeletePermissionRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPermissionServiceDeletePermission) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeletePermission(ctx, req.(*DeletePermissionRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeletePermissionResponse) - return ctx.Result(200, reply) - } -} - -type PermissionServiceHTTPClient interface { - CreatePermission(ctx context.Context, req *CreatePermissionRequest, opts ...http.CallOption) (rsp *CreatePermissionResponse, err error) - DeletePermission(ctx context.Context, req *DeletePermissionRequest, opts ...http.CallOption) (rsp *DeletePermissionResponse, err error) - GetPermission(ctx context.Context, req *GetPermissionRequest, opts ...http.CallOption) (rsp *GetPermissionResponse, err error) - ListPermissions(ctx context.Context, req *ListPermissionsRequest, opts ...http.CallOption) (rsp *ListPermissionsResponse, err error) - UpdatePermission(ctx context.Context, req *UpdatePermissionRequest, opts ...http.CallOption) (rsp *UpdatePermissionResponse, err error) -} - -type PermissionServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewPermissionServiceHTTPClient(client *http.Client) PermissionServiceHTTPClient { - return &PermissionServiceHTTPClientImpl{client} -} - -func (c *PermissionServiceHTTPClientImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest, opts ...http.CallOption) (*CreatePermissionResponse, error) { - var out CreatePermissionResponse - pattern := "/sys/permissions" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPermissionServiceCreatePermission)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Permission, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PermissionServiceHTTPClientImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest, opts ...http.CallOption) (*DeletePermissionResponse, error) { - var out DeletePermissionResponse - pattern := "/sys/permissions/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPermissionServiceDeletePermission)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PermissionServiceHTTPClientImpl) GetPermission(ctx context.Context, in *GetPermissionRequest, opts ...http.CallOption) (*GetPermissionResponse, error) { - var out GetPermissionResponse - pattern := "/sys/permissions/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPermissionServiceGetPermission)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PermissionServiceHTTPClientImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest, opts ...http.CallOption) (*ListPermissionsResponse, error) { - var out ListPermissionsResponse - pattern := "/sys/permissions" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPermissionServiceListPermissions)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PermissionServiceHTTPClientImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest, opts ...http.CallOption) (*UpdatePermissionResponse, error) { - var out UpdatePermissionResponse - pattern := "/sys/permissions/{permission.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPermissionServiceUpdatePermission)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Permission, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/system/position.pb.go b/api/v1/services/system/position.pb.go deleted file mode 100644 index 6c2a4ad7..00000000 --- a/api/v1/services/system/position.pb.go +++ /dev/null @@ -1,725 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: system/position.proto - -package system - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ListPositionsRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPositionsRequest) Reset() { - *x = ListPositionsRequest{} - mi := &file_system_position_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPositionsRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPositionsRequest) ProtoMessage() {} - -func (x *ListPositionsRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_position_proto_msgTypes[0] - 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 ListPositionsRequest.ProtoReflect.Descriptor instead. -func (*ListPositionsRequest) Descriptor() ([]byte, []int) { - return file_system_position_proto_rawDescGZIP(), []int{0} -} - -func (x *ListPositionsRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListPositionsRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListPositionsRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListPositionsRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListPositionsRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListPositionsRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -type ListPositionsResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - // The paging menus - Positions []*types.Position `protobuf:"bytes,2,rep,name=positions,proto3" json:"positions,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPositionsResponse) Reset() { - *x = ListPositionsResponse{} - mi := &file_system_position_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPositionsResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPositionsResponse) ProtoMessage() {} - -func (x *ListPositionsResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_position_proto_msgTypes[1] - 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 ListPositionsResponse.ProtoReflect.Descriptor instead. -func (*ListPositionsResponse) Descriptor() ([]byte, []int) { - return file_system_position_proto_rawDescGZIP(), []int{1} -} - -func (x *ListPositionsResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListPositionsResponse) GetPositions() []*types.Position { - if x != nil { - return x.Positions - } - return nil -} - -func (x *ListPositionsResponse) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListPositionsResponse) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListPositionsResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -func (x *ListPositionsResponse) GetExtra() *anypb.Any { - if x != nil { - return x.Extra - } - return nil -} - -type GetPositionRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/positions/position2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPositionRequest) Reset() { - *x = GetPositionRequest{} - mi := &file_system_position_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPositionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPositionRequest) ProtoMessage() {} - -func (x *GetPositionRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_position_proto_msgTypes[2] - 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 GetPositionRequest.ProtoReflect.Descriptor instead. -func (*GetPositionRequest) Descriptor() ([]byte, []int) { - return file_system_position_proto_rawDescGZIP(), []int{2} -} - -func (x *GetPositionRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type GetPositionResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Position *types.Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPositionResponse) Reset() { - *x = GetPositionResponse{} - mi := &file_system_position_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPositionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPositionResponse) ProtoMessage() {} - -func (x *GetPositionResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_position_proto_msgTypes[3] - 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 GetPositionResponse.ProtoReflect.Descriptor instead. -func (*GetPositionResponse) Descriptor() ([]byte, []int) { - return file_system_position_proto_rawDescGZIP(), []int{3} -} - -func (x *GetPositionResponse) GetPosition() *types.Position { - if x != nil { - return x.Position - } - return nil -} - -type CreatePositionRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id where the position is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The position id to use for this position. - PositionId string `protobuf:"bytes,2,opt,name=position_id,proto3" json:"position_id,omitempty"` - // The position object to create. - Position *types.Position `protobuf:"bytes,3,opt,name=position,proto3" json:"position,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreatePositionRequest) Reset() { - *x = CreatePositionRequest{} - mi := &file_system_position_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreatePositionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreatePositionRequest) ProtoMessage() {} - -func (x *CreatePositionRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_position_proto_msgTypes[4] - 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 CreatePositionRequest.ProtoReflect.Descriptor instead. -func (*CreatePositionRequest) Descriptor() ([]byte, []int) { - return file_system_position_proto_rawDescGZIP(), []int{4} -} - -func (x *CreatePositionRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreatePositionRequest) GetPositionId() string { - if x != nil { - return x.PositionId - } - return "" -} - -func (x *CreatePositionRequest) GetPosition() *types.Position { - if x != nil { - return x.Position - } - return nil -} - -type CreatePositionResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Position *types.Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreatePositionResponse) Reset() { - *x = CreatePositionResponse{} - mi := &file_system_position_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreatePositionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreatePositionResponse) ProtoMessage() {} - -func (x *CreatePositionResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_position_proto_msgTypes[5] - 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 CreatePositionResponse.ProtoReflect.Descriptor instead. -func (*CreatePositionResponse) Descriptor() ([]byte, []int) { - return file_system_position_proto_rawDescGZIP(), []int{5} -} - -func (x *CreatePositionResponse) GetPosition() *types.Position { - if x != nil { - return x.Position - } - return nil -} - -type UpdatePositionRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The id of the position resource to update. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The position resource which replaces the resource on the server. - Position *types.Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePositionRequest) Reset() { - *x = UpdatePositionRequest{} - mi := &file_system_position_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePositionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePositionRequest) ProtoMessage() {} - -func (x *UpdatePositionRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_position_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 UpdatePositionRequest.ProtoReflect.Descriptor instead. -func (*UpdatePositionRequest) Descriptor() ([]byte, []int) { - return file_system_position_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdatePositionRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UpdatePositionRequest) GetPosition() *types.Position { - if x != nil { - return x.Position - } - return nil -} - -type UpdatePositionResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Position *types.Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePositionResponse) Reset() { - *x = UpdatePositionResponse{} - mi := &file_system_position_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePositionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePositionResponse) ProtoMessage() {} - -func (x *UpdatePositionResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_position_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdatePositionResponse.ProtoReflect.Descriptor instead. -func (*UpdatePositionResponse) Descriptor() ([]byte, []int) { - return file_system_position_proto_rawDescGZIP(), []int{7} -} - -func (x *UpdatePositionResponse) GetPosition() *types.Position { - if x != nil { - return x.Position - } - return nil -} - -type DeletePositionRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The resource id of the position to be deleted, for example: - // "shelves/shelf1/positions/position2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeletePositionRequest) Reset() { - *x = DeletePositionRequest{} - mi := &file_system_position_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeletePositionRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeletePositionRequest) ProtoMessage() {} - -func (x *DeletePositionRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_position_proto_msgTypes[8] - 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 DeletePositionRequest.ProtoReflect.Descriptor instead. -func (*DeletePositionRequest) Descriptor() ([]byte, []int) { - return file_system_position_proto_rawDescGZIP(), []int{8} -} - -func (x *DeletePositionRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type DeletePositionResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeletePositionResponse) Reset() { - *x = DeletePositionResponse{} - mi := &file_system_position_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeletePositionResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeletePositionResponse) ProtoMessage() {} - -func (x *DeletePositionResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_position_proto_msgTypes[9] - 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 DeletePositionResponse.ProtoReflect.Descriptor instead. -func (*DeletePositionResponse) Descriptor() ([]byte, []int) { - return file_system_position_proto_rawDescGZIP(), []int{9} -} - -func (x *DeletePositionResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -var File_system_position_proto protoreflect.FileDescriptor - -const file_system_position_proto_rawDesc = "" + - "\n" + - "\x15system/position.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xbc\x01\n" + - "\x14ListPositionsRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\x93\x02\n" + - "\x15ListPositionsResponse\x12\x1e\n" + - "\n" + - "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x12=\n" + - "\tpositions\x18\x02 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + - "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + - "\x06_extra\"$\n" + - "\x12GetPositionRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"R\n" + - "\x13GetPositionResponse\x12;\n" + - "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"\x8e\x01\n" + - "\x15CreatePositionRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12 \n" + - "\vposition_id\x18\x02 \x01(\tR\vposition_id\x12;\n" + - "\bposition\x18\x03 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"U\n" + - "\x16CreatePositionResponse\x12;\n" + - "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"d\n" + - "\x15UpdatePositionRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12;\n" + - "\bposition\x18\x02 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"U\n" + - "\x16UpdatePositionResponse\x12;\n" + - "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"'\n" + - "\x15DeletePositionRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + - "\x16DeletePositionResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xe3\x05\n" + - "\x0fPositionService\x12\x84\x01\n" + - "\rListPositions\x12,.api.v1.services.system.ListPositionsRequest\x1a-.api.v1.services.system.ListPositionsResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/positions\x12\x83\x01\n" + - "\vGetPosition\x12*.api.v1.services.system.GetPositionRequest\x1a+.api.v1.services.system.GetPositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/positions/{id}\x12\x91\x01\n" + - "\x0eCreatePosition\x12-.api.v1.services.system.CreatePositionRequest\x1a..api.v1.services.system.CreatePositionResponse\" \x82\xd3\xe4\x93\x02\x1a:\bposition\"\x0e/sys/positions\x12\x9f\x01\n" + - "\x0eUpdatePosition\x12-.api.v1.services.system.UpdatePositionRequest\x1a..api.v1.services.system.UpdatePositionResponse\".\x82\xd3\xe4\x93\x02(:\bposition\x1a\x1c/sys/positions/{position.id}\x12\x8c\x01\n" + - "\x0eDeletePosition\x12-.api.v1.services.system.DeletePositionRequest\x1a..api.v1.services.system.DeletePositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/positions/{id}B\xe2\x01\n" + - "\x1acom.api.v1.services.systemB\rPositionProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_position_proto_rawDescOnce sync.Once - file_system_position_proto_rawDescData []byte -) - -func file_system_position_proto_rawDescGZIP() []byte { - file_system_position_proto_rawDescOnce.Do(func() { - file_system_position_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_position_proto_rawDesc), len(file_system_position_proto_rawDesc))) - }) - return file_system_position_proto_rawDescData -} - -var file_system_position_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_system_position_proto_goTypes = []any{ - (*ListPositionsRequest)(nil), // 0: api.v1.services.system.ListPositionsRequest - (*ListPositionsResponse)(nil), // 1: api.v1.services.system.ListPositionsResponse - (*GetPositionRequest)(nil), // 2: api.v1.services.system.GetPositionRequest - (*GetPositionResponse)(nil), // 3: api.v1.services.system.GetPositionResponse - (*CreatePositionRequest)(nil), // 4: api.v1.services.system.CreatePositionRequest - (*CreatePositionResponse)(nil), // 5: api.v1.services.system.CreatePositionResponse - (*UpdatePositionRequest)(nil), // 6: api.v1.services.system.UpdatePositionRequest - (*UpdatePositionResponse)(nil), // 7: api.v1.services.system.UpdatePositionResponse - (*DeletePositionRequest)(nil), // 8: api.v1.services.system.DeletePositionRequest - (*DeletePositionResponse)(nil), // 9: api.v1.services.system.DeletePositionResponse - (*types.Position)(nil), // 10: api.v1.services.types.Position - (*anypb.Any)(nil), // 11: google.protobuf.Any - (*emptypb.Empty)(nil), // 12: google.protobuf.Empty -} -var file_system_position_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListPositionsResponse.positions:type_name -> api.v1.services.types.Position - 11, // 1: api.v1.services.system.ListPositionsResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetPositionResponse.position:type_name -> api.v1.services.types.Position - 10, // 3: api.v1.services.system.CreatePositionRequest.position:type_name -> api.v1.services.types.Position - 10, // 4: api.v1.services.system.CreatePositionResponse.position:type_name -> api.v1.services.types.Position - 10, // 5: api.v1.services.system.UpdatePositionRequest.position:type_name -> api.v1.services.types.Position - 10, // 6: api.v1.services.system.UpdatePositionResponse.position:type_name -> api.v1.services.types.Position - 12, // 7: api.v1.services.system.DeletePositionResponse.empty:type_name -> google.protobuf.Empty - 0, // 8: api.v1.services.system.PositionService.ListPositions:input_type -> api.v1.services.system.ListPositionsRequest - 2, // 9: api.v1.services.system.PositionService.GetPosition:input_type -> api.v1.services.system.GetPositionRequest - 4, // 10: api.v1.services.system.PositionService.CreatePosition:input_type -> api.v1.services.system.CreatePositionRequest - 6, // 11: api.v1.services.system.PositionService.UpdatePosition:input_type -> api.v1.services.system.UpdatePositionRequest - 8, // 12: api.v1.services.system.PositionService.DeletePosition:input_type -> api.v1.services.system.DeletePositionRequest - 1, // 13: api.v1.services.system.PositionService.ListPositions:output_type -> api.v1.services.system.ListPositionsResponse - 3, // 14: api.v1.services.system.PositionService.GetPosition:output_type -> api.v1.services.system.GetPositionResponse - 5, // 15: api.v1.services.system.PositionService.CreatePosition:output_type -> api.v1.services.system.CreatePositionResponse - 7, // 16: api.v1.services.system.PositionService.UpdatePosition:output_type -> api.v1.services.system.UpdatePositionResponse - 9, // 17: api.v1.services.system.PositionService.DeletePosition:output_type -> api.v1.services.system.DeletePositionResponse - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_system_position_proto_init() } -func file_system_position_proto_init() { - if File_system_position_proto != nil { - return - } - file_system_position_proto_msgTypes[1].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_position_proto_rawDesc), len(file_system_position_proto_rawDesc)), - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_system_position_proto_goTypes, - DependencyIndexes: file_system_position_proto_depIdxs, - MessageInfos: file_system_position_proto_msgTypes, - }.Build() - File_system_position_proto = out.File - file_system_position_proto_goTypes = nil - file_system_position_proto_depIdxs = nil -} diff --git a/api/v1/services/system/position.pb.gw.go b/api/v1/services/system/position.pb.gw.go deleted file mode 100644 index 1d7fcf6b..00000000 --- a/api/v1/services/system/position.pb.gw.go +++ /dev/null @@ -1,487 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/position.proto - -/* -Package system is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package system - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_PositionService_ListPositions_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_PositionService_ListPositions_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPositionsRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_ListPositions_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListPositions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PositionService_ListPositions_0(ctx context.Context, marshaler runtime.Marshaler, server PositionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPositionsRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_ListPositions_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListPositions(ctx, &protoReq) - return msg, metadata, err -} - -func request_PositionService_GetPosition_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPositionRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetPosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PositionService_GetPosition_0(ctx context.Context, marshaler runtime.Marshaler, server PositionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPositionRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetPosition(ctx, &protoReq) - return msg, metadata, err -} - -var filter_PositionService_CreatePosition_0 = &utilities.DoubleArray{Encoding: map[string]int{"position": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - -func request_PositionService_CreatePosition_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreatePositionRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Position); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_CreatePosition_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreatePosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PositionService_CreatePosition_0(ctx context.Context, marshaler runtime.Marshaler, server PositionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreatePositionRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Position); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_CreatePosition_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreatePosition(ctx, &protoReq) - return msg, metadata, err -} - -var filter_PositionService_UpdatePosition_0 = &utilities.DoubleArray{Encoding: map[string]int{"position": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - -func request_PositionService_UpdatePosition_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePositionRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Position); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["position.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "position.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "position.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "position.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_UpdatePosition_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PositionService_UpdatePosition_0(ctx context.Context, marshaler runtime.Marshaler, server PositionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePositionRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Position); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["position.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "position.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "position.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "position.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_UpdatePosition_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePosition(ctx, &protoReq) - return msg, metadata, err -} - -func request_PositionService_DeletePosition_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeletePositionRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.DeletePosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PositionService_DeletePosition_0(ctx context.Context, marshaler runtime.Marshaler, server PositionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeletePositionRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.DeletePosition(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterPositionServiceHandlerServer registers the http handlers for service PositionService to "mux". -// UnaryRPC :call PositionServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPositionServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterPositionServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PositionServiceServer) error { - mux.Handle(http.MethodGet, pattern_PositionService_ListPositions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PositionService/ListPositions", runtime.WithHTTPPathPattern("/sys/positions")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PositionService_ListPositions_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PositionService_ListPositions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PositionService_GetPosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PositionService/GetPosition", runtime.WithHTTPPathPattern("/sys/positions/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PositionService_GetPosition_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PositionService_GetPosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PositionService_CreatePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PositionService/CreatePosition", runtime.WithHTTPPathPattern("/sys/positions")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PositionService_CreatePosition_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PositionService_CreatePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PositionService_UpdatePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PositionService/UpdatePosition", runtime.WithHTTPPathPattern("/sys/positions/{position.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PositionService_UpdatePosition_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PositionService_UpdatePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_PositionService_DeletePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PositionService/DeletePosition", runtime.WithHTTPPathPattern("/sys/positions/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PositionService_DeletePosition_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PositionService_DeletePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterPositionServiceHandlerFromEndpoint is same as RegisterPositionServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterPositionServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterPositionServiceHandler(ctx, mux, conn) -} - -// RegisterPositionServiceHandler registers the http handlers for service PositionService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterPositionServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterPositionServiceHandlerClient(ctx, mux, NewPositionServiceClient(conn)) -} - -// RegisterPositionServiceHandlerClient registers the http handlers for service PositionService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PositionServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PositionServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "PositionServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterPositionServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PositionServiceClient) error { - mux.Handle(http.MethodGet, pattern_PositionService_ListPositions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PositionService/ListPositions", runtime.WithHTTPPathPattern("/sys/positions")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PositionService_ListPositions_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PositionService_ListPositions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PositionService_GetPosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PositionService/GetPosition", runtime.WithHTTPPathPattern("/sys/positions/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PositionService_GetPosition_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PositionService_GetPosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PositionService_CreatePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PositionService/CreatePosition", runtime.WithHTTPPathPattern("/sys/positions")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PositionService_CreatePosition_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PositionService_CreatePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PositionService_UpdatePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PositionService/UpdatePosition", runtime.WithHTTPPathPattern("/sys/positions/{position.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PositionService_UpdatePosition_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PositionService_UpdatePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_PositionService_DeletePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PositionService/DeletePosition", runtime.WithHTTPPathPattern("/sys/positions/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PositionService_DeletePosition_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PositionService_DeletePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_PositionService_ListPositions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "positions"}, "")) - pattern_PositionService_GetPosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "positions", "id"}, "")) - pattern_PositionService_CreatePosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "positions"}, "")) - pattern_PositionService_UpdatePosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "positions", "position.id"}, "")) - pattern_PositionService_DeletePosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "positions", "id"}, "")) -) - -var ( - forward_PositionService_ListPositions_0 = runtime.ForwardResponseMessage - forward_PositionService_GetPosition_0 = runtime.ForwardResponseMessage - forward_PositionService_CreatePosition_0 = runtime.ForwardResponseMessage - forward_PositionService_UpdatePosition_0 = runtime.ForwardResponseMessage - forward_PositionService_DeletePosition_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/system/position.pb.validate.go b/api/v1/services/system/position.pb.validate.go deleted file mode 100644 index 795208ed..00000000 --- a/api/v1/services/system/position.pb.validate.go +++ /dev/null @@ -1,1327 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/position.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListPositionsRequest 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 *ListPositionsRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPositionsRequest 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 -// ListPositionsRequestMultiError, or nil if none found. -func (m *ListPositionsRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPositionsRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - if len(errors) > 0 { - return ListPositionsRequestMultiError(errors) - } - - return nil -} - -// ListPositionsRequestMultiError is an error wrapping multiple validation -// errors returned by ListPositionsRequest.ValidateAll() if the designated -// constraints aren't met. -type ListPositionsRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPositionsRequestMultiError) 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 ListPositionsRequestMultiError) AllErrors() []error { return m } - -// ListPositionsRequestValidationError is the validation error returned by -// ListPositionsRequest.Validate if the designated constraints aren't met. -type ListPositionsRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPositionsRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPositionsRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPositionsRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPositionsRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPositionsRequestValidationError) ErrorName() string { - return "ListPositionsRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPositionsRequestValidationError) 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 %sListPositionsRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPositionsRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPositionsRequestValidationError{} - -// Validate checks the field values on ListPositionsResponse 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 *ListPositionsResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPositionsResponse 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 -// ListPositionsResponseMultiError, or nil if none found. -func (m *ListPositionsResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPositionsResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetPositions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPositionsResponseValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPositionsResponseValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPositionsResponseValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for NextPageToken - - if m.Extra != nil { - - if all { - switch v := interface{}(m.GetExtra()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPositionsResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPositionsResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPositionsResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListPositionsResponseMultiError(errors) - } - - return nil -} - -// ListPositionsResponseMultiError is an error wrapping multiple validation -// errors returned by ListPositionsResponse.ValidateAll() if the designated -// constraints aren't met. -type ListPositionsResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPositionsResponseMultiError) 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 ListPositionsResponseMultiError) AllErrors() []error { return m } - -// ListPositionsResponseValidationError is the validation error returned by -// ListPositionsResponse.Validate if the designated constraints aren't met. -type ListPositionsResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPositionsResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPositionsResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPositionsResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPositionsResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPositionsResponseValidationError) ErrorName() string { - return "ListPositionsResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPositionsResponseValidationError) 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 %sListPositionsResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPositionsResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPositionsResponseValidationError{} - -// Validate checks the field values on GetPositionRequest 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 *GetPositionRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPositionRequest 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 -// GetPositionRequestMultiError, or nil if none found. -func (m *GetPositionRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPositionRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return GetPositionRequestMultiError(errors) - } - - return nil -} - -// GetPositionRequestMultiError is an error wrapping multiple validation errors -// returned by GetPositionRequest.ValidateAll() if the designated constraints -// aren't met. -type GetPositionRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPositionRequestMultiError) 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 GetPositionRequestMultiError) AllErrors() []error { return m } - -// GetPositionRequestValidationError is the validation error returned by -// GetPositionRequest.Validate if the designated constraints aren't met. -type GetPositionRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPositionRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPositionRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPositionRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPositionRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPositionRequestValidationError) ErrorName() string { - return "GetPositionRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPositionRequestValidationError) 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 %sGetPositionRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPositionRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPositionRequestValidationError{} - -// Validate checks the field values on GetPositionResponse 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 *GetPositionResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPositionResponse 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 -// GetPositionResponseMultiError, or nil if none found. -func (m *GetPositionResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPositionResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPosition()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetPositionResponseValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetPositionResponseValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetPositionResponseValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetPositionResponseMultiError(errors) - } - - return nil -} - -// GetPositionResponseMultiError is an error wrapping multiple validation -// errors returned by GetPositionResponse.ValidateAll() if the designated -// constraints aren't met. -type GetPositionResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPositionResponseMultiError) 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 GetPositionResponseMultiError) AllErrors() []error { return m } - -// GetPositionResponseValidationError is the validation error returned by -// GetPositionResponse.Validate if the designated constraints aren't met. -type GetPositionResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPositionResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPositionResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPositionResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPositionResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPositionResponseValidationError) ErrorName() string { - return "GetPositionResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPositionResponseValidationError) 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 %sGetPositionResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPositionResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPositionResponseValidationError{} - -// Validate checks the field values on CreatePositionRequest 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 *CreatePositionRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreatePositionRequest 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 -// CreatePositionRequestMultiError, or nil if none found. -func (m *CreatePositionRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreatePositionRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Parent - - // no validation rules for PositionId - - if all { - switch v := interface{}(m.GetPosition()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreatePositionRequestValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreatePositionRequestValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreatePositionRequestValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreatePositionRequestMultiError(errors) - } - - return nil -} - -// CreatePositionRequestMultiError is an error wrapping multiple validation -// errors returned by CreatePositionRequest.ValidateAll() if the designated -// constraints aren't met. -type CreatePositionRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreatePositionRequestMultiError) 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 CreatePositionRequestMultiError) AllErrors() []error { return m } - -// CreatePositionRequestValidationError is the validation error returned by -// CreatePositionRequest.Validate if the designated constraints aren't met. -type CreatePositionRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreatePositionRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreatePositionRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreatePositionRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreatePositionRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreatePositionRequestValidationError) ErrorName() string { - return "CreatePositionRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreatePositionRequestValidationError) 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 %sCreatePositionRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreatePositionRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreatePositionRequestValidationError{} - -// Validate checks the field values on CreatePositionResponse 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 *CreatePositionResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreatePositionResponse 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 -// CreatePositionResponseMultiError, or nil if none found. -func (m *CreatePositionResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreatePositionResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPosition()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreatePositionResponseValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreatePositionResponseValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreatePositionResponseValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreatePositionResponseMultiError(errors) - } - - return nil -} - -// CreatePositionResponseMultiError is an error wrapping multiple validation -// errors returned by CreatePositionResponse.ValidateAll() if the designated -// constraints aren't met. -type CreatePositionResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreatePositionResponseMultiError) 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 CreatePositionResponseMultiError) AllErrors() []error { return m } - -// CreatePositionResponseValidationError is the validation error returned by -// CreatePositionResponse.Validate if the designated constraints aren't met. -type CreatePositionResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreatePositionResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreatePositionResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreatePositionResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreatePositionResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreatePositionResponseValidationError) ErrorName() string { - return "CreatePositionResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreatePositionResponseValidationError) 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 %sCreatePositionResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreatePositionResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreatePositionResponseValidationError{} - -// Validate checks the field values on UpdatePositionRequest 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 *UpdatePositionRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePositionRequest 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 -// UpdatePositionRequestMultiError, or nil if none found. -func (m *UpdatePositionRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePositionRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetPosition()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePositionRequestValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePositionRequestValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePositionRequestValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePositionRequestMultiError(errors) - } - - return nil -} - -// UpdatePositionRequestMultiError is an error wrapping multiple validation -// errors returned by UpdatePositionRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdatePositionRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePositionRequestMultiError) 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 UpdatePositionRequestMultiError) AllErrors() []error { return m } - -// UpdatePositionRequestValidationError is the validation error returned by -// UpdatePositionRequest.Validate if the designated constraints aren't met. -type UpdatePositionRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePositionRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePositionRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePositionRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePositionRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePositionRequestValidationError) ErrorName() string { - return "UpdatePositionRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePositionRequestValidationError) 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 %sUpdatePositionRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePositionRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePositionRequestValidationError{} - -// Validate checks the field values on UpdatePositionResponse 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 *UpdatePositionResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePositionResponse 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 -// UpdatePositionResponseMultiError, or nil if none found. -func (m *UpdatePositionResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePositionResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPosition()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePositionResponseValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePositionResponseValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePositionResponseValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePositionResponseMultiError(errors) - } - - return nil -} - -// UpdatePositionResponseMultiError is an error wrapping multiple validation -// errors returned by UpdatePositionResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdatePositionResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePositionResponseMultiError) 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 UpdatePositionResponseMultiError) AllErrors() []error { return m } - -// UpdatePositionResponseValidationError is the validation error returned by -// UpdatePositionResponse.Validate if the designated constraints aren't met. -type UpdatePositionResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePositionResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePositionResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePositionResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePositionResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePositionResponseValidationError) ErrorName() string { - return "UpdatePositionResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePositionResponseValidationError) 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 %sUpdatePositionResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePositionResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePositionResponseValidationError{} - -// Validate checks the field values on DeletePositionRequest 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 *DeletePositionRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeletePositionRequest 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 -// DeletePositionRequestMultiError, or nil if none found. -func (m *DeletePositionRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeletePositionRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return DeletePositionRequestMultiError(errors) - } - - return nil -} - -// DeletePositionRequestMultiError is an error wrapping multiple validation -// errors returned by DeletePositionRequest.ValidateAll() if the designated -// constraints aren't met. -type DeletePositionRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeletePositionRequestMultiError) 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 DeletePositionRequestMultiError) AllErrors() []error { return m } - -// DeletePositionRequestValidationError is the validation error returned by -// DeletePositionRequest.Validate if the designated constraints aren't met. -type DeletePositionRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeletePositionRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeletePositionRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeletePositionRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeletePositionRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeletePositionRequestValidationError) ErrorName() string { - return "DeletePositionRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeletePositionRequestValidationError) 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 %sDeletePositionRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeletePositionRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeletePositionRequestValidationError{} - -// Validate checks the field values on DeletePositionResponse 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 *DeletePositionResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeletePositionResponse 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 -// DeletePositionResponseMultiError, or nil if none found. -func (m *DeletePositionResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeletePositionResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeletePositionResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeletePositionResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeletePositionResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeletePositionResponseMultiError(errors) - } - - return nil -} - -// DeletePositionResponseMultiError is an error wrapping multiple validation -// errors returned by DeletePositionResponse.ValidateAll() if the designated -// constraints aren't met. -type DeletePositionResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeletePositionResponseMultiError) 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 DeletePositionResponseMultiError) AllErrors() []error { return m } - -// DeletePositionResponseValidationError is the validation error returned by -// DeletePositionResponse.Validate if the designated constraints aren't met. -type DeletePositionResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeletePositionResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeletePositionResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeletePositionResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeletePositionResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeletePositionResponseValidationError) ErrorName() string { - return "DeletePositionResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeletePositionResponseValidationError) 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 %sDeletePositionResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeletePositionResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeletePositionResponseValidationError{} diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go deleted file mode 100644 index 037f1db0..00000000 --- a/api/v1/services/system/position_bridge.pb.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: system/position.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const PositionServiceCreatePositionBridgeOperation = "/api.v1.services.system.PositionService/CreatePosition" -const PositionServiceDeletePositionBridgeOperation = "/api.v1.services.system.PositionService/DeletePosition" -const PositionServiceGetPositionBridgeOperation = "/api.v1.services.system.PositionService/GetPosition" -const PositionServiceListPositionsBridgeOperation = "/api.v1.services.system.PositionService/ListPositions" -const PositionServiceUpdatePositionBridgeOperation = "/api.v1.services.system.PositionService/UpdatePosition" - -type PositionServiceBridgeServer interface { - CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) - DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) - GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) - ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) - UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) -} - -type PositionServiceHooker interface { - PositionServiceCreatePositionHooker - PositionServiceDeletePositionHooker - PositionServiceGetPositionHooker - PositionServiceListPositionsHooker - PositionServiceUpdatePositionHooker -} - -type PositionServiceHookedBridger interface { - PositionServiceHooker - PositionServiceBridgeServer -} -type PositionServiceCreatePositionHooker interface { - PrepareCreatePosition(http.Context, *CreatePositionRequest) (context.Context, error) - CompleteCreatePosition(http.Context, *CreatePositionRequest, *CreatePositionResponse) error -} -type PositionServiceDeletePositionHooker interface { - PrepareDeletePosition(http.Context, *DeletePositionRequest) (context.Context, error) - CompleteDeletePosition(http.Context, *DeletePositionRequest, *DeletePositionResponse) error -} -type PositionServiceGetPositionHooker interface { - PrepareGetPosition(http.Context, *GetPositionRequest) (context.Context, error) - CompleteGetPosition(http.Context, *GetPositionRequest, *GetPositionResponse) error -} -type PositionServiceListPositionsHooker interface { - PrepareListPositions(http.Context, *ListPositionsRequest) (context.Context, error) - CompleteListPositions(http.Context, *ListPositionsRequest, *ListPositionsResponse) error -} -type PositionServiceUpdatePositionHooker interface { - PrepareUpdatePosition(http.Context, *UpdatePositionRequest) (context.Context, error) - CompleteUpdatePosition(http.Context, *UpdatePositionRequest, *UpdatePositionResponse) error -} - -func RegisterPositionServiceBridgeServer(s *http.Server, srv PositionServiceHookedBridger) { - r := s.Route("/") - r.GET("/sys/positions", _PositionService_ListPositions0_Bridge_Handler(srv)) - r.GET("/sys/positions/:id", _PositionService_GetPosition0_Bridge_Handler(srv)) - r.POST("/sys/positions", _PositionService_CreatePosition0_Bridge_Handler(srv)) - r.PUT("/sys/positions/:position.id", _PositionService_UpdatePosition0_Bridge_Handler(srv)) - r.DELETE("/sys/positions/:id", _PositionService_DeletePosition0_Bridge_Handler(srv)) -} - -func _PositionService_ListPositions0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPositionsRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPositionServiceListPositions) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPositions(ctx, req.(*ListPositionsRequest)) - }) - - newctx, err := srv.PrepareListPositions(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPositions(ctx, &in, out.(*ListPositionsResponse)) - } -} - -func _PositionService_GetPosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPositionRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPositionServiceGetPosition) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPosition(ctx, req.(*GetPositionRequest)) - }) - - newctx, err := srv.PrepareGetPosition(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetPosition(ctx, &in, out.(*GetPositionResponse)) - } -} - -func _PositionService_CreatePosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreatePositionRequest - if err := ctx.Bind(&in.Position); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPositionServiceCreatePosition) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreatePosition(ctx, req.(*CreatePositionRequest)) - }) - - newctx, err := srv.PrepareCreatePosition(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreatePosition(ctx, &in, out.(*CreatePositionResponse)) - } -} - -func _PositionService_UpdatePosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePositionRequest - if err := ctx.Bind(&in.Position); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPositionServiceUpdatePosition) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePosition(ctx, req.(*UpdatePositionRequest)) - }) - - newctx, err := srv.PrepareUpdatePosition(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePosition(ctx, &in, out.(*UpdatePositionResponse)) - } -} - -func _PositionService_DeletePosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeletePositionRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPositionServiceDeletePosition) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeletePosition(ctx, req.(*DeletePositionRequest)) - }) - - newctx, err := srv.PrepareDeletePosition(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeletePosition(ctx, &in, out.(*DeletePositionResponse)) - } -} - -// UnimplementedPositionServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPositionServiceHooked struct{} - -func (UnimplementedPositionServiceHooked) PrepareCreatePosition(ctx http.Context, in *CreatePositionRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPositionServiceHooked) CompleteCreatePosition(ctx http.Context, in *CreatePositionRequest, out *CreatePositionResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPositionServiceHooked) PrepareDeletePosition(ctx http.Context, in *DeletePositionRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPositionServiceHooked) CompleteDeletePosition(ctx http.Context, in *DeletePositionRequest, out *DeletePositionResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPositionServiceHooked) PrepareGetPosition(ctx http.Context, in *GetPositionRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPositionServiceHooked) CompleteGetPosition(ctx http.Context, in *GetPositionRequest, out *GetPositionResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPositionServiceHooked) PrepareListPositions(ctx http.Context, in *ListPositionsRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPositionServiceHooked) CompleteListPositions(ctx http.Context, in *ListPositionsRequest, out *ListPositionsResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPositionServiceHooked) PrepareUpdatePosition(ctx http.Context, in *UpdatePositionRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPositionServiceHooked) CompleteUpdatePosition(ctx http.Context, in *UpdatePositionRequest, out *UpdatePositionResponse) error { - return ctx.Result(200, out) -} - -func WithPositionServiceHook(h PositionServiceHooker) func(PositionServiceBridgeServer) PositionServiceHookedBridger { - return func(srv PositionServiceBridgeServer) PositionServiceHookedBridger { - return PositionServiceHookedBridge{PositionServiceBridgeServer: srv, PositionServiceHooker: h} - } -} - -// PositionServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PositionService. -// It implements the HTTP and gRPC implementations of PositionService. -// It forwards requests and responses between the two implementations. -type PositionServiceHookedBridge struct { - PositionServiceBridgeServer - PositionServiceHooker -} - -type PositionServiceHTTPBridgeImpl struct { - client PositionServiceHTTPClient -} - -func NewPositionServiceHTTPBridge(client *http.Client) PositionServiceHTTPServer { - return &PositionServiceHTTPBridgeImpl{client: NewPositionServiceHTTPClient(client)} -} - -func (c *PositionServiceHTTPBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { - return c.client.CreatePosition(ctx, in) -} - -func (c *PositionServiceHTTPBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { - return c.client.DeletePosition(ctx, in) -} - -func (c *PositionServiceHTTPBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { - return c.client.GetPosition(ctx, in) -} - -func (c *PositionServiceHTTPBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { - return c.client.ListPositions(ctx, in) -} - -func (c *PositionServiceHTTPBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { - return c.client.UpdatePosition(ctx, in) -} - -type PositionServiceBridgeImpl struct { - client PositionServiceClient -} - -func NewPositionServiceBridge(client grpc.ClientConnInterface) PositionServiceServer { - return &PositionServiceBridgeImpl{client: NewPositionServiceClient(client)} -} - -func (c *PositionServiceBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { - return c.client.CreatePosition(ctx, in) -} - -func (c *PositionServiceBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { - return c.client.DeletePosition(ctx, in) -} - -func (c *PositionServiceBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { - return c.client.GetPosition(ctx, in) -} - -func (c *PositionServiceBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { - return c.client.ListPositions(ctx, in) -} - -func (c *PositionServiceBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { - return c.client.UpdatePosition(ctx, in) -} - -func (c *PositionServiceBridgeImpl) mustEmbedUnimplementedPositionServiceServer() {} - -type PositionServiceGRPC2HTTPBridgeImpl struct { - client PositionServiceClient -} - -func NewPositionServiceGRPC2HTTP(client grpc.ClientConnInterface) PositionServiceHTTPServer { - return &PositionServiceGRPC2HTTPBridgeImpl{client: NewPositionServiceClient(client)} -} - -func (c *PositionServiceGRPC2HTTPBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { - return c.client.CreatePosition(ctx, in) -} - -func (c *PositionServiceGRPC2HTTPBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { - return c.client.DeletePosition(ctx, in) -} - -func (c *PositionServiceGRPC2HTTPBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { - return c.client.GetPosition(ctx, in) -} - -func (c *PositionServiceGRPC2HTTPBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { - return c.client.ListPositions(ctx, in) -} - -func (c *PositionServiceGRPC2HTTPBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { - return c.client.UpdatePosition(ctx, in) -} - -type PositionServiceHTTP2GRPCBridgeImpl struct { - client PositionServiceHTTPClient -} - -func NewPositionServiceHTTP2GRPC(client *http.Client) PositionServiceServer { - return &PositionServiceHTTP2GRPCBridgeImpl{client: NewPositionServiceHTTPClient(client)} -} - -func (c *PositionServiceHTTP2GRPCBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { - return c.client.CreatePosition(ctx, in) -} - -func (c *PositionServiceHTTP2GRPCBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { - return c.client.DeletePosition(ctx, in) -} - -func (c *PositionServiceHTTP2GRPCBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { - return c.client.GetPosition(ctx, in) -} - -func (c *PositionServiceHTTP2GRPCBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { - return c.client.ListPositions(ctx, in) -} - -func (c *PositionServiceHTTP2GRPCBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { - return c.client.UpdatePosition(ctx, in) -} - -func (c *PositionServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPositionServiceServer() {} diff --git a/api/v1/services/system/position_grpc.pb.go b/api/v1/services/system/position_grpc.pb.go deleted file mode 100644 index 27fb4973..00000000 --- a/api/v1/services/system/position_grpc.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: system/position.proto - -package system - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - PositionService_ListPositions_FullMethodName = "/api.v1.services.system.PositionService/ListPositions" - PositionService_GetPosition_FullMethodName = "/api.v1.services.system.PositionService/GetPosition" - PositionService_CreatePosition_FullMethodName = "/api.v1.services.system.PositionService/CreatePosition" - PositionService_UpdatePosition_FullMethodName = "/api.v1.services.system.PositionService/UpdatePosition" - PositionService_DeletePosition_FullMethodName = "/api.v1.services.system.PositionService/DeletePosition" -) - -// PositionServiceClient is the client API for PositionService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The login service definition. -type PositionServiceClient interface { - ListPositions(ctx context.Context, in *ListPositionsRequest, opts ...grpc.CallOption) (*ListPositionsResponse, error) - GetPosition(ctx context.Context, in *GetPositionRequest, opts ...grpc.CallOption) (*GetPositionResponse, error) - CreatePosition(ctx context.Context, in *CreatePositionRequest, opts ...grpc.CallOption) (*CreatePositionResponse, error) - UpdatePosition(ctx context.Context, in *UpdatePositionRequest, opts ...grpc.CallOption) (*UpdatePositionResponse, error) - DeletePosition(ctx context.Context, in *DeletePositionRequest, opts ...grpc.CallOption) (*DeletePositionResponse, error) -} - -type positionServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewPositionServiceClient(cc grpc.ClientConnInterface) PositionServiceClient { - return &positionServiceClient{cc} -} - -func (c *positionServiceClient) ListPositions(ctx context.Context, in *ListPositionsRequest, opts ...grpc.CallOption) (*ListPositionsResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPositionsResponse) - err := c.cc.Invoke(ctx, PositionService_ListPositions_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *positionServiceClient) GetPosition(ctx context.Context, in *GetPositionRequest, opts ...grpc.CallOption) (*GetPositionResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetPositionResponse) - err := c.cc.Invoke(ctx, PositionService_GetPosition_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *positionServiceClient) CreatePosition(ctx context.Context, in *CreatePositionRequest, opts ...grpc.CallOption) (*CreatePositionResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreatePositionResponse) - err := c.cc.Invoke(ctx, PositionService_CreatePosition_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *positionServiceClient) UpdatePosition(ctx context.Context, in *UpdatePositionRequest, opts ...grpc.CallOption) (*UpdatePositionResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePositionResponse) - err := c.cc.Invoke(ctx, PositionService_UpdatePosition_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *positionServiceClient) DeletePosition(ctx context.Context, in *DeletePositionRequest, opts ...grpc.CallOption) (*DeletePositionResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeletePositionResponse) - err := c.cc.Invoke(ctx, PositionService_DeletePosition_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// PositionServiceServer is the server API for PositionService service. -// All implementations must embed UnimplementedPositionServiceServer -// for forward compatibility. -// -// The login service definition. -type PositionServiceServer interface { - ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) - GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) - CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) - UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) - DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) - mustEmbedUnimplementedPositionServiceServer() -} - -// UnimplementedPositionServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPositionServiceServer struct{} - -func (UnimplementedPositionServiceServer) ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPositions not implemented") -} -func (UnimplementedPositionServiceServer) GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetPosition not implemented") -} -func (UnimplementedPositionServiceServer) CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreatePosition not implemented") -} -func (UnimplementedPositionServiceServer) UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePosition not implemented") -} -func (UnimplementedPositionServiceServer) DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeletePosition not implemented") -} -func (UnimplementedPositionServiceServer) mustEmbedUnimplementedPositionServiceServer() {} -func (UnimplementedPositionServiceServer) testEmbeddedByValue() {} - -// UnsafePositionServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to PositionServiceServer will -// result in compilation errors. -type UnsafePositionServiceServer interface { - mustEmbedUnimplementedPositionServiceServer() -} - -func RegisterPositionServiceServer(s grpc.ServiceRegistrar, srv PositionServiceServer) { - // If the following call pancis, it indicates UnimplementedPositionServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&PositionService_ServiceDesc, srv) -} - -func _PositionService_ListPositions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPositionsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PositionServiceServer).ListPositions(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PositionService_ListPositions_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PositionServiceServer).ListPositions(ctx, req.(*ListPositionsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PositionService_GetPosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPositionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PositionServiceServer).GetPosition(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PositionService_GetPosition_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PositionServiceServer).GetPosition(ctx, req.(*GetPositionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PositionService_CreatePosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreatePositionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PositionServiceServer).CreatePosition(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PositionService_CreatePosition_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PositionServiceServer).CreatePosition(ctx, req.(*CreatePositionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PositionService_UpdatePosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePositionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PositionServiceServer).UpdatePosition(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PositionService_UpdatePosition_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PositionServiceServer).UpdatePosition(ctx, req.(*UpdatePositionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PositionService_DeletePosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeletePositionRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PositionServiceServer).DeletePosition(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PositionService_DeletePosition_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PositionServiceServer).DeletePosition(ctx, req.(*DeletePositionRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// PositionService_ServiceDesc is the grpc.ServiceDesc for PositionService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var PositionService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.PositionService", - HandlerType: (*PositionServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListPositions", - Handler: _PositionService_ListPositions_Handler, - }, - { - MethodName: "GetPosition", - Handler: _PositionService_GetPosition_Handler, - }, - { - MethodName: "CreatePosition", - Handler: _PositionService_CreatePosition_Handler, - }, - { - MethodName: "UpdatePosition", - Handler: _PositionService_UpdatePosition_Handler, - }, - { - MethodName: "DeletePosition", - Handler: _PositionService_DeletePosition_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "system/position.proto", -} diff --git a/api/v1/services/system/position_http.pb.go b/api/v1/services/system/position_http.pb.go deleted file mode 100644 index 6ded04a3..00000000 --- a/api/v1/services/system/position_http.pb.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: system/position.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationPositionServiceCreatePosition = "/api.v1.services.system.PositionService/CreatePosition" -const OperationPositionServiceDeletePosition = "/api.v1.services.system.PositionService/DeletePosition" -const OperationPositionServiceGetPosition = "/api.v1.services.system.PositionService/GetPosition" -const OperationPositionServiceListPositions = "/api.v1.services.system.PositionService/ListPositions" -const OperationPositionServiceUpdatePosition = "/api.v1.services.system.PositionService/UpdatePosition" - -type PositionServiceHTTPServer interface { - CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) - DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) - GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) - ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) - UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) -} - -func RegisterPositionServiceHTTPServer(s *http.Server, srv PositionServiceHTTPServer) { - r := s.Route("/") - r.GET("/sys/positions", _PositionService_ListPositions0_HTTP_Handler(srv)) - r.GET("/sys/positions/{id}", _PositionService_GetPosition0_HTTP_Handler(srv)) - r.POST("/sys/positions", _PositionService_CreatePosition0_HTTP_Handler(srv)) - r.PUT("/sys/positions/{position.id}", _PositionService_UpdatePosition0_HTTP_Handler(srv)) - r.DELETE("/sys/positions/{id}", _PositionService_DeletePosition0_HTTP_Handler(srv)) -} - -func _PositionService_ListPositions0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPositionsRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPositionServiceListPositions) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPositions(ctx, req.(*ListPositionsRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPositionsResponse) - return ctx.Result(200, reply) - } -} - -func _PositionService_GetPosition0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPositionRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPositionServiceGetPosition) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPosition(ctx, req.(*GetPositionRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetPositionResponse) - return ctx.Result(200, reply) - } -} - -func _PositionService_CreatePosition0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreatePositionRequest - if err := ctx.Bind(&in.Position); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPositionServiceCreatePosition) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreatePosition(ctx, req.(*CreatePositionRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreatePositionResponse) - return ctx.Result(200, reply) - } -} - -func _PositionService_UpdatePosition0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePositionRequest - if err := ctx.Bind(&in.Position); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPositionServiceUpdatePosition) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePosition(ctx, req.(*UpdatePositionRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePositionResponse) - return ctx.Result(200, reply) - } -} - -func _PositionService_DeletePosition0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeletePositionRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPositionServiceDeletePosition) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeletePosition(ctx, req.(*DeletePositionRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeletePositionResponse) - return ctx.Result(200, reply) - } -} - -type PositionServiceHTTPClient interface { - CreatePosition(ctx context.Context, req *CreatePositionRequest, opts ...http.CallOption) (rsp *CreatePositionResponse, err error) - DeletePosition(ctx context.Context, req *DeletePositionRequest, opts ...http.CallOption) (rsp *DeletePositionResponse, err error) - GetPosition(ctx context.Context, req *GetPositionRequest, opts ...http.CallOption) (rsp *GetPositionResponse, err error) - ListPositions(ctx context.Context, req *ListPositionsRequest, opts ...http.CallOption) (rsp *ListPositionsResponse, err error) - UpdatePosition(ctx context.Context, req *UpdatePositionRequest, opts ...http.CallOption) (rsp *UpdatePositionResponse, err error) -} - -type PositionServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewPositionServiceHTTPClient(client *http.Client) PositionServiceHTTPClient { - return &PositionServiceHTTPClientImpl{client} -} - -func (c *PositionServiceHTTPClientImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest, opts ...http.CallOption) (*CreatePositionResponse, error) { - var out CreatePositionResponse - pattern := "/sys/positions" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPositionServiceCreatePosition)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Position, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PositionServiceHTTPClientImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest, opts ...http.CallOption) (*DeletePositionResponse, error) { - var out DeletePositionResponse - pattern := "/sys/positions/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPositionServiceDeletePosition)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PositionServiceHTTPClientImpl) GetPosition(ctx context.Context, in *GetPositionRequest, opts ...http.CallOption) (*GetPositionResponse, error) { - var out GetPositionResponse - pattern := "/sys/positions/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPositionServiceGetPosition)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PositionServiceHTTPClientImpl) ListPositions(ctx context.Context, in *ListPositionsRequest, opts ...http.CallOption) (*ListPositionsResponse, error) { - var out ListPositionsResponse - pattern := "/sys/positions" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPositionServiceListPositions)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *PositionServiceHTTPClientImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest, opts ...http.CallOption) (*UpdatePositionResponse, error) { - var out UpdatePositionResponse - pattern := "/sys/positions/{position.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPositionServiceUpdatePosition)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Position, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go deleted file mode 100644 index ae1d6757..00000000 --- a/api/v1/services/system/resource.pb.go +++ /dev/null @@ -1,747 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: system/resource.proto - -package system - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// ListResourcesRequest is the request for the ResourceService.ListResources method. -type ListResourcesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - // resource type - Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListResourcesRequest) Reset() { - *x = ListResourcesRequest{} - mi := &file_system_resource_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListResourcesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListResourcesRequest) ProtoMessage() {} - -func (x *ListResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_resource_proto_msgTypes[0] - 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 ListResourcesRequest.ProtoReflect.Descriptor instead. -func (*ListResourcesRequest) Descriptor() ([]byte, []int) { - return file_system_resource_proto_rawDescGZIP(), []int{0} -} - -func (x *ListResourcesRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListResourcesRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListResourcesRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListResourcesRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListResourcesRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListResourcesRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -func (x *ListResourcesRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -// ListResourcesResponse is the response for the ResourceService.ListResources method. -type ListResourcesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - // The paging resources - Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListResourcesResponse) Reset() { - *x = ListResourcesResponse{} - mi := &file_system_resource_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListResourcesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListResourcesResponse) ProtoMessage() {} - -func (x *ListResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_resource_proto_msgTypes[1] - 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 ListResourcesResponse.ProtoReflect.Descriptor instead. -func (*ListResourcesResponse) Descriptor() ([]byte, []int) { - return file_system_resource_proto_rawDescGZIP(), []int{1} -} - -func (x *ListResourcesResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListResourcesResponse) GetResources() []*types.Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *ListResourcesResponse) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListResourcesResponse) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListResourcesResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -func (x *ListResourcesResponse) GetExtra() *anypb.Any { - if x != nil { - return x.Extra - } - return nil -} - -// GetResourceRequest is the request for the ResourceService.GetResource method. -type GetResourceRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/resources/resource2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetResourceRequest) Reset() { - *x = GetResourceRequest{} - mi := &file_system_resource_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetResourceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetResourceRequest) ProtoMessage() {} - -func (x *GetResourceRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_resource_proto_msgTypes[2] - 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 GetResourceRequest.ProtoReflect.Descriptor instead. -func (*GetResourceRequest) Descriptor() ([]byte, []int) { - return file_system_resource_proto_rawDescGZIP(), []int{2} -} - -func (x *GetResourceRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -// GetResourceResponse is the response for the ResourceService.GetResource method. -type GetResourceResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field id should match the Noun in the method id. - Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetResourceResponse) Reset() { - *x = GetResourceResponse{} - mi := &file_system_resource_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetResourceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetResourceResponse) ProtoMessage() {} - -func (x *GetResourceResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_resource_proto_msgTypes[3] - 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 GetResourceResponse.ProtoReflect.Descriptor instead. -func (*GetResourceResponse) Descriptor() ([]byte, []int) { - return file_system_resource_proto_rawDescGZIP(), []int{3} -} - -func (x *GetResourceResponse) GetResource() *types.Resource { - if x != nil { - return x.Resource - } - return nil -} - -// CreateResourceRequest is the request for the ResourceService.CreateResource method. -type CreateResourceRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id where the resource is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The resource id to use for this resource. - ResourceId string `protobuf:"bytes,2,opt,name=resource_id,proto3" json:"resource_id,omitempty"` - // The resource object to create. - Resource *types.Resource `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateResourceRequest) Reset() { - *x = CreateResourceRequest{} - mi := &file_system_resource_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateResourceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateResourceRequest) ProtoMessage() {} - -func (x *CreateResourceRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_resource_proto_msgTypes[4] - 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 CreateResourceRequest.ProtoReflect.Descriptor instead. -func (*CreateResourceRequest) Descriptor() ([]byte, []int) { - return file_system_resource_proto_rawDescGZIP(), []int{4} -} - -func (x *CreateResourceRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreateResourceRequest) GetResourceId() string { - if x != nil { - return x.ResourceId - } - return "" -} - -func (x *CreateResourceRequest) GetResource() *types.Resource { - if x != nil { - return x.Resource - } - return nil -} - -// CreateResourceResponse is the response for the ResourceService.CreateResource method. -type CreateResourceResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateResourceResponse) Reset() { - *x = CreateResourceResponse{} - mi := &file_system_resource_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateResourceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateResourceResponse) ProtoMessage() {} - -func (x *CreateResourceResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_resource_proto_msgTypes[5] - 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 CreateResourceResponse.ProtoReflect.Descriptor instead. -func (*CreateResourceResponse) Descriptor() ([]byte, []int) { - return file_system_resource_proto_rawDescGZIP(), []int{5} -} - -func (x *CreateResourceResponse) GetResource() *types.Resource { - if x != nil { - return x.Resource - } - return nil -} - -// UpdateResourceRequest is the request for the ResourceService.UpdateResource method. -type UpdateResourceRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The id of the resource object to update. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The resource object which replaces the resource on the server. - Resource *types.Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateResourceRequest) Reset() { - *x = UpdateResourceRequest{} - mi := &file_system_resource_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateResourceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateResourceRequest) ProtoMessage() {} - -func (x *UpdateResourceRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_resource_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 UpdateResourceRequest.ProtoReflect.Descriptor instead. -func (*UpdateResourceRequest) Descriptor() ([]byte, []int) { - return file_system_resource_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdateResourceRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UpdateResourceRequest) GetResource() *types.Resource { - if x != nil { - return x.Resource - } - return nil -} - -// UpdateResourceResponse is the response for the ResourceService.UpdateResource method. -type UpdateResourceResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateResourceResponse) Reset() { - *x = UpdateResourceResponse{} - mi := &file_system_resource_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateResourceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateResourceResponse) ProtoMessage() {} - -func (x *UpdateResourceResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_resource_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateResourceResponse.ProtoReflect.Descriptor instead. -func (*UpdateResourceResponse) Descriptor() ([]byte, []int) { - return file_system_resource_proto_rawDescGZIP(), []int{7} -} - -func (x *UpdateResourceResponse) GetResource() *types.Resource { - if x != nil { - return x.Resource - } - return nil -} - -// DeleteResourceRequest is the request for the ResourceService.DeleteResource method. -type DeleteResourceRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The resource id of the resource to be deleted, for example: - // "shelves/shelf1/resources/resource2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteResourceRequest) Reset() { - *x = DeleteResourceRequest{} - mi := &file_system_resource_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteResourceRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteResourceRequest) ProtoMessage() {} - -func (x *DeleteResourceRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_resource_proto_msgTypes[8] - 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 DeleteResourceRequest.ProtoReflect.Descriptor instead. -func (*DeleteResourceRequest) Descriptor() ([]byte, []int) { - return file_system_resource_proto_rawDescGZIP(), []int{8} -} - -func (x *DeleteResourceRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -// DeleteResourceResponse is the response for the ResourceService.DeleteResource method. -type DeleteResourceResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // or Resource resource = 1; or google.protobuf.Empty empty = 1; - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteResourceResponse) Reset() { - *x = DeleteResourceResponse{} - mi := &file_system_resource_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteResourceResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteResourceResponse) ProtoMessage() {} - -func (x *DeleteResourceResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_resource_proto_msgTypes[9] - 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 DeleteResourceResponse.ProtoReflect.Descriptor instead. -func (*DeleteResourceResponse) Descriptor() ([]byte, []int) { - return file_system_resource_proto_rawDescGZIP(), []int{9} -} - -func (x *DeleteResourceResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -var File_system_resource_proto protoreflect.FileDescriptor - -const file_system_resource_proto_rawDesc = "" + - "\n" + - "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xd0\x01\n" + - "\x14ListResourcesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\x12\x12\n" + - "\x04type\x18\a \x01(\tR\x04type\"\x93\x02\n" + - "\x15ListResourcesResponse\x12\x1e\n" + - "\n" + - "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x12=\n" + - "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + - "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + - "\x06_extra\"$\n" + - "\x12GetResourceRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"R\n" + - "\x13GetResourceResponse\x12;\n" + - "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"\x8e\x01\n" + - "\x15CreateResourceRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12 \n" + - "\vresource_id\x18\x02 \x01(\tR\vresource_id\x12;\n" + - "\bresource\x18\x03 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"U\n" + - "\x16CreateResourceResponse\x12;\n" + - "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"d\n" + - "\x15UpdateResourceRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12;\n" + - "\bresource\x18\x02 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"U\n" + - "\x16UpdateResourceResponse\x12;\n" + - "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"'\n" + - "\x15DeleteResourceRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + - "\x16DeleteResourceResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xe3\x05\n" + - "\x0fResourceService\x12\x84\x01\n" + - "\rListResources\x12,.api.v1.services.system.ListResourcesRequest\x1a-.api.v1.services.system.ListResourcesResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/resources\x12\x83\x01\n" + - "\vGetResource\x12*.api.v1.services.system.GetResourceRequest\x1a+.api.v1.services.system.GetResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/resources/{id}\x12\x91\x01\n" + - "\x0eCreateResource\x12-.api.v1.services.system.CreateResourceRequest\x1a..api.v1.services.system.CreateResourceResponse\" \x82\xd3\xe4\x93\x02\x1a:\bresource\"\x0e/sys/resources\x12\x9f\x01\n" + - "\x0eUpdateResource\x12-.api.v1.services.system.UpdateResourceRequest\x1a..api.v1.services.system.UpdateResourceResponse\".\x82\xd3\xe4\x93\x02(:\bresource\x1a\x1c/sys/resources/{resource.id}\x12\x8c\x01\n" + - "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xe2\x01\n" + - "\x1acom.api.v1.services.systemB\rResourceProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_resource_proto_rawDescOnce sync.Once - file_system_resource_proto_rawDescData []byte -) - -func file_system_resource_proto_rawDescGZIP() []byte { - file_system_resource_proto_rawDescOnce.Do(func() { - file_system_resource_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_resource_proto_rawDesc), len(file_system_resource_proto_rawDesc))) - }) - return file_system_resource_proto_rawDescData -} - -var file_system_resource_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_system_resource_proto_goTypes = []any{ - (*ListResourcesRequest)(nil), // 0: api.v1.services.system.ListResourcesRequest - (*ListResourcesResponse)(nil), // 1: api.v1.services.system.ListResourcesResponse - (*GetResourceRequest)(nil), // 2: api.v1.services.system.GetResourceRequest - (*GetResourceResponse)(nil), // 3: api.v1.services.system.GetResourceResponse - (*CreateResourceRequest)(nil), // 4: api.v1.services.system.CreateResourceRequest - (*CreateResourceResponse)(nil), // 5: api.v1.services.system.CreateResourceResponse - (*UpdateResourceRequest)(nil), // 6: api.v1.services.system.UpdateResourceRequest - (*UpdateResourceResponse)(nil), // 7: api.v1.services.system.UpdateResourceResponse - (*DeleteResourceRequest)(nil), // 8: api.v1.services.system.DeleteResourceRequest - (*DeleteResourceResponse)(nil), // 9: api.v1.services.system.DeleteResourceResponse - (*types.Resource)(nil), // 10: api.v1.services.types.Resource - (*anypb.Any)(nil), // 11: google.protobuf.Any - (*emptypb.Empty)(nil), // 12: google.protobuf.Empty -} -var file_system_resource_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 11, // 1: api.v1.services.system.ListResourcesResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetResourceResponse.resource:type_name -> api.v1.services.types.Resource - 10, // 3: api.v1.services.system.CreateResourceRequest.resource:type_name -> api.v1.services.types.Resource - 10, // 4: api.v1.services.system.CreateResourceResponse.resource:type_name -> api.v1.services.types.Resource - 10, // 5: api.v1.services.system.UpdateResourceRequest.resource:type_name -> api.v1.services.types.Resource - 10, // 6: api.v1.services.system.UpdateResourceResponse.resource:type_name -> api.v1.services.types.Resource - 12, // 7: api.v1.services.system.DeleteResourceResponse.empty:type_name -> google.protobuf.Empty - 0, // 8: api.v1.services.system.ResourceService.ListResources:input_type -> api.v1.services.system.ListResourcesRequest - 2, // 9: api.v1.services.system.ResourceService.GetResource:input_type -> api.v1.services.system.GetResourceRequest - 4, // 10: api.v1.services.system.ResourceService.CreateResource:input_type -> api.v1.services.system.CreateResourceRequest - 6, // 11: api.v1.services.system.ResourceService.UpdateResource:input_type -> api.v1.services.system.UpdateResourceRequest - 8, // 12: api.v1.services.system.ResourceService.DeleteResource:input_type -> api.v1.services.system.DeleteResourceRequest - 1, // 13: api.v1.services.system.ResourceService.ListResources:output_type -> api.v1.services.system.ListResourcesResponse - 3, // 14: api.v1.services.system.ResourceService.GetResource:output_type -> api.v1.services.system.GetResourceResponse - 5, // 15: api.v1.services.system.ResourceService.CreateResource:output_type -> api.v1.services.system.CreateResourceResponse - 7, // 16: api.v1.services.system.ResourceService.UpdateResource:output_type -> api.v1.services.system.UpdateResourceResponse - 9, // 17: api.v1.services.system.ResourceService.DeleteResource:output_type -> api.v1.services.system.DeleteResourceResponse - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_system_resource_proto_init() } -func file_system_resource_proto_init() { - if File_system_resource_proto != nil { - return - } - file_system_resource_proto_msgTypes[1].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_resource_proto_rawDesc), len(file_system_resource_proto_rawDesc)), - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_system_resource_proto_goTypes, - DependencyIndexes: file_system_resource_proto_depIdxs, - MessageInfos: file_system_resource_proto_msgTypes, - }.Build() - File_system_resource_proto = out.File - file_system_resource_proto_goTypes = nil - file_system_resource_proto_depIdxs = nil -} diff --git a/api/v1/services/system/resource.pb.gw.go b/api/v1/services/system/resource.pb.gw.go deleted file mode 100644 index 36912fc0..00000000 --- a/api/v1/services/system/resource.pb.gw.go +++ /dev/null @@ -1,487 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/resource.proto - -/* -Package system is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package system - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_ResourceService_ListResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_ResourceService_ListResources_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListResourcesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_ListResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_ResourceService_ListResources_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListResourcesRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_ListResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListResources(ctx, &protoReq) - return msg, metadata, err -} - -func request_ResourceService_GetResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetResourceRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_ResourceService_GetResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetResourceRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetResource(ctx, &protoReq) - return msg, metadata, err -} - -var filter_ResourceService_CreateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{"resource": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - -func request_ResourceService_CreateResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateResourceRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_CreateResource_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreateResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_ResourceService_CreateResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateResourceRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_CreateResource_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreateResource(ctx, &protoReq) - return msg, metadata, err -} - -var filter_ResourceService_UpdateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{"resource": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - -func request_ResourceService_UpdateResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateResourceRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["resource.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "resource.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "resource.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_UpdateResource_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdateResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_ResourceService_UpdateResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateResourceRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["resource.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "resource.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "resource.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_UpdateResource_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdateResource(ctx, &protoReq) - return msg, metadata, err -} - -func request_ResourceService_DeleteResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteResourceRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.DeleteResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_ResourceService_DeleteResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteResourceRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.DeleteResource(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterResourceServiceHandlerServer registers the http handlers for service ResourceService to "mux". -// UnaryRPC :call ResourceServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterResourceServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ResourceServiceServer) error { - mux.Handle(http.MethodGet, pattern_ResourceService_ListResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ResourceService/ListResources", runtime.WithHTTPPathPattern("/sys/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_ResourceService_ListResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_ResourceService_ListResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_ResourceService_GetResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ResourceService/GetResource", runtime.WithHTTPPathPattern("/sys/resources/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_ResourceService_GetResource_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_ResourceService_GetResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_ResourceService_CreateResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ResourceService/CreateResource", runtime.WithHTTPPathPattern("/sys/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_ResourceService_CreateResource_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_ResourceService_CreateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_ResourceService_UpdateResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ResourceService/UpdateResource", runtime.WithHTTPPathPattern("/sys/resources/{resource.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_ResourceService_UpdateResource_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_ResourceService_UpdateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_ResourceService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ResourceService/DeleteResource", runtime.WithHTTPPathPattern("/sys/resources/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_ResourceService_DeleteResource_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_ResourceService_DeleteResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterResourceServiceHandlerFromEndpoint is same as RegisterResourceServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterResourceServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterResourceServiceHandler(ctx, mux, conn) -} - -// RegisterResourceServiceHandler registers the http handlers for service ResourceService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterResourceServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterResourceServiceHandlerClient(ctx, mux, NewResourceServiceClient(conn)) -} - -// RegisterResourceServiceHandlerClient registers the http handlers for service ResourceService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ResourceServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ResourceServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "ResourceServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ResourceServiceClient) error { - mux.Handle(http.MethodGet, pattern_ResourceService_ListResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ResourceService/ListResources", runtime.WithHTTPPathPattern("/sys/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_ResourceService_ListResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_ResourceService_ListResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_ResourceService_GetResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ResourceService/GetResource", runtime.WithHTTPPathPattern("/sys/resources/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_ResourceService_GetResource_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_ResourceService_GetResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_ResourceService_CreateResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ResourceService/CreateResource", runtime.WithHTTPPathPattern("/sys/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_ResourceService_CreateResource_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_ResourceService_CreateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_ResourceService_UpdateResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ResourceService/UpdateResource", runtime.WithHTTPPathPattern("/sys/resources/{resource.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_ResourceService_UpdateResource_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_ResourceService_UpdateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_ResourceService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ResourceService/DeleteResource", runtime.WithHTTPPathPattern("/sys/resources/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_ResourceService_DeleteResource_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_ResourceService_DeleteResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_ResourceService_ListResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "resources"}, "")) - pattern_ResourceService_GetResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "resources", "id"}, "")) - pattern_ResourceService_CreateResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "resources"}, "")) - pattern_ResourceService_UpdateResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "resources", "resource.id"}, "")) - pattern_ResourceService_DeleteResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "resources", "id"}, "")) -) - -var ( - forward_ResourceService_ListResources_0 = runtime.ForwardResponseMessage - forward_ResourceService_GetResource_0 = runtime.ForwardResponseMessage - forward_ResourceService_CreateResource_0 = runtime.ForwardResponseMessage - forward_ResourceService_UpdateResource_0 = runtime.ForwardResponseMessage - forward_ResourceService_DeleteResource_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/system/resource.pb.validate.go b/api/v1/services/system/resource.pb.validate.go deleted file mode 100644 index aa7567f4..00000000 --- a/api/v1/services/system/resource.pb.validate.go +++ /dev/null @@ -1,1329 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/resource.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListResourcesRequest 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 *ListResourcesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListResourcesRequest 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 -// ListResourcesRequestMultiError, or nil if none found. -func (m *ListResourcesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListResourcesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - // no validation rules for Type - - if len(errors) > 0 { - return ListResourcesRequestMultiError(errors) - } - - return nil -} - -// ListResourcesRequestMultiError is an error wrapping multiple validation -// errors returned by ListResourcesRequest.ValidateAll() if the designated -// constraints aren't met. -type ListResourcesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListResourcesRequestMultiError) 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 ListResourcesRequestMultiError) AllErrors() []error { return m } - -// ListResourcesRequestValidationError is the validation error returned by -// ListResourcesRequest.Validate if the designated constraints aren't met. -type ListResourcesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListResourcesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListResourcesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListResourcesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListResourcesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListResourcesRequestValidationError) ErrorName() string { - return "ListResourcesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListResourcesRequestValidationError) 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 %sListResourcesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListResourcesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListResourcesRequestValidationError{} - -// Validate checks the field values on ListResourcesResponse 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 *ListResourcesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListResourcesResponse 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 -// ListResourcesResponseMultiError, or nil if none found. -func (m *ListResourcesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListResourcesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for NextPageToken - - if m.Extra != nil { - - if all { - switch v := interface{}(m.GetExtra()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListResourcesResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListResourcesResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListResourcesResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListResourcesResponseMultiError(errors) - } - - return nil -} - -// ListResourcesResponseMultiError is an error wrapping multiple validation -// errors returned by ListResourcesResponse.ValidateAll() if the designated -// constraints aren't met. -type ListResourcesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListResourcesResponseMultiError) 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 ListResourcesResponseMultiError) AllErrors() []error { return m } - -// ListResourcesResponseValidationError is the validation error returned by -// ListResourcesResponse.Validate if the designated constraints aren't met. -type ListResourcesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListResourcesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListResourcesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListResourcesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListResourcesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListResourcesResponseValidationError) ErrorName() string { - return "ListResourcesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListResourcesResponseValidationError) 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 %sListResourcesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListResourcesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListResourcesResponseValidationError{} - -// Validate checks the field values on GetResourceRequest 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 *GetResourceRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetResourceRequest 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 -// GetResourceRequestMultiError, or nil if none found. -func (m *GetResourceRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetResourceRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return GetResourceRequestMultiError(errors) - } - - return nil -} - -// GetResourceRequestMultiError is an error wrapping multiple validation errors -// returned by GetResourceRequest.ValidateAll() if the designated constraints -// aren't met. -type GetResourceRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetResourceRequestMultiError) 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 GetResourceRequestMultiError) AllErrors() []error { return m } - -// GetResourceRequestValidationError is the validation error returned by -// GetResourceRequest.Validate if the designated constraints aren't met. -type GetResourceRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetResourceRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetResourceRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetResourceRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetResourceRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetResourceRequestValidationError) ErrorName() string { - return "GetResourceRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetResourceRequestValidationError) 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 %sGetResourceRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetResourceRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetResourceRequestValidationError{} - -// Validate checks the field values on GetResourceResponse 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 *GetResourceResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetResourceResponse 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 -// GetResourceResponseMultiError, or nil if none found. -func (m *GetResourceResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetResourceResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetResource()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetResourceResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetResourceResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetResourceResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetResourceResponseMultiError(errors) - } - - return nil -} - -// GetResourceResponseMultiError is an error wrapping multiple validation -// errors returned by GetResourceResponse.ValidateAll() if the designated -// constraints aren't met. -type GetResourceResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetResourceResponseMultiError) 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 GetResourceResponseMultiError) AllErrors() []error { return m } - -// GetResourceResponseValidationError is the validation error returned by -// GetResourceResponse.Validate if the designated constraints aren't met. -type GetResourceResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetResourceResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetResourceResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetResourceResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetResourceResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetResourceResponseValidationError) ErrorName() string { - return "GetResourceResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetResourceResponseValidationError) 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 %sGetResourceResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetResourceResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetResourceResponseValidationError{} - -// Validate checks the field values on CreateResourceRequest 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 *CreateResourceRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateResourceRequest 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 -// CreateResourceRequestMultiError, or nil if none found. -func (m *CreateResourceRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateResourceRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Parent - - // no validation rules for ResourceId - - if all { - switch v := interface{}(m.GetResource()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateResourceRequestValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateResourceRequestValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateResourceRequestValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateResourceRequestMultiError(errors) - } - - return nil -} - -// CreateResourceRequestMultiError is an error wrapping multiple validation -// errors returned by CreateResourceRequest.ValidateAll() if the designated -// constraints aren't met. -type CreateResourceRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateResourceRequestMultiError) 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 CreateResourceRequestMultiError) AllErrors() []error { return m } - -// CreateResourceRequestValidationError is the validation error returned by -// CreateResourceRequest.Validate if the designated constraints aren't met. -type CreateResourceRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateResourceRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateResourceRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateResourceRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateResourceRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateResourceRequestValidationError) ErrorName() string { - return "CreateResourceRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateResourceRequestValidationError) 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 %sCreateResourceRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateResourceRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateResourceRequestValidationError{} - -// Validate checks the field values on CreateResourceResponse 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 *CreateResourceResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateResourceResponse 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 -// CreateResourceResponseMultiError, or nil if none found. -func (m *CreateResourceResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateResourceResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetResource()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateResourceResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateResourceResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateResourceResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateResourceResponseMultiError(errors) - } - - return nil -} - -// CreateResourceResponseMultiError is an error wrapping multiple validation -// errors returned by CreateResourceResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateResourceResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateResourceResponseMultiError) 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 CreateResourceResponseMultiError) AllErrors() []error { return m } - -// CreateResourceResponseValidationError is the validation error returned by -// CreateResourceResponse.Validate if the designated constraints aren't met. -type CreateResourceResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateResourceResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateResourceResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateResourceResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateResourceResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateResourceResponseValidationError) ErrorName() string { - return "CreateResourceResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateResourceResponseValidationError) 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 %sCreateResourceResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateResourceResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateResourceResponseValidationError{} - -// Validate checks the field values on UpdateResourceRequest 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 *UpdateResourceRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateResourceRequest 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 -// UpdateResourceRequestMultiError, or nil if none found. -func (m *UpdateResourceRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateResourceRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetResource()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateResourceRequestValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateResourceRequestValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateResourceRequestValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateResourceRequestMultiError(errors) - } - - return nil -} - -// UpdateResourceRequestMultiError is an error wrapping multiple validation -// errors returned by UpdateResourceRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateResourceRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateResourceRequestMultiError) 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 UpdateResourceRequestMultiError) AllErrors() []error { return m } - -// UpdateResourceRequestValidationError is the validation error returned by -// UpdateResourceRequest.Validate if the designated constraints aren't met. -type UpdateResourceRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateResourceRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateResourceRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateResourceRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateResourceRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateResourceRequestValidationError) ErrorName() string { - return "UpdateResourceRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateResourceRequestValidationError) 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 %sUpdateResourceRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateResourceRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateResourceRequestValidationError{} - -// Validate checks the field values on UpdateResourceResponse 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 *UpdateResourceResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateResourceResponse 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 -// UpdateResourceResponseMultiError, or nil if none found. -func (m *UpdateResourceResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateResourceResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetResource()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateResourceResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateResourceResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateResourceResponseValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateResourceResponseMultiError(errors) - } - - return nil -} - -// UpdateResourceResponseMultiError is an error wrapping multiple validation -// errors returned by UpdateResourceResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateResourceResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateResourceResponseMultiError) 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 UpdateResourceResponseMultiError) AllErrors() []error { return m } - -// UpdateResourceResponseValidationError is the validation error returned by -// UpdateResourceResponse.Validate if the designated constraints aren't met. -type UpdateResourceResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateResourceResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateResourceResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateResourceResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateResourceResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateResourceResponseValidationError) ErrorName() string { - return "UpdateResourceResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateResourceResponseValidationError) 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 %sUpdateResourceResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateResourceResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateResourceResponseValidationError{} - -// Validate checks the field values on DeleteResourceRequest 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 *DeleteResourceRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteResourceRequest 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 -// DeleteResourceRequestMultiError, or nil if none found. -func (m *DeleteResourceRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteResourceRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return DeleteResourceRequestMultiError(errors) - } - - return nil -} - -// DeleteResourceRequestMultiError is an error wrapping multiple validation -// errors returned by DeleteResourceRequest.ValidateAll() if the designated -// constraints aren't met. -type DeleteResourceRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteResourceRequestMultiError) 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 DeleteResourceRequestMultiError) AllErrors() []error { return m } - -// DeleteResourceRequestValidationError is the validation error returned by -// DeleteResourceRequest.Validate if the designated constraints aren't met. -type DeleteResourceRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteResourceRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteResourceRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteResourceRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteResourceRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteResourceRequestValidationError) ErrorName() string { - return "DeleteResourceRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteResourceRequestValidationError) 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 %sDeleteResourceRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteResourceRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteResourceRequestValidationError{} - -// Validate checks the field values on DeleteResourceResponse 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 *DeleteResourceResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteResourceResponse 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 -// DeleteResourceResponseMultiError, or nil if none found. -func (m *DeleteResourceResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteResourceResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteResourceResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteResourceResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteResourceResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteResourceResponseMultiError(errors) - } - - return nil -} - -// DeleteResourceResponseMultiError is an error wrapping multiple validation -// errors returned by DeleteResourceResponse.ValidateAll() if the designated -// constraints aren't met. -type DeleteResourceResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteResourceResponseMultiError) 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 DeleteResourceResponseMultiError) AllErrors() []error { return m } - -// DeleteResourceResponseValidationError is the validation error returned by -// DeleteResourceResponse.Validate if the designated constraints aren't met. -type DeleteResourceResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteResourceResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteResourceResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteResourceResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteResourceResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteResourceResponseValidationError) ErrorName() string { - return "DeleteResourceResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteResourceResponseValidationError) 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 %sDeleteResourceResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteResourceResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteResourceResponseValidationError{} diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go deleted file mode 100644 index 4b19f3e1..00000000 --- a/api/v1/services/system/resource_bridge.pb.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: system/resource.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const ResourceServiceCreateResourceBridgeOperation = "/api.v1.services.system.ResourceService/CreateResource" -const ResourceServiceDeleteResourceBridgeOperation = "/api.v1.services.system.ResourceService/DeleteResource" -const ResourceServiceGetResourceBridgeOperation = "/api.v1.services.system.ResourceService/GetResource" -const ResourceServiceListResourcesBridgeOperation = "/api.v1.services.system.ResourceService/ListResources" -const ResourceServiceUpdateResourceBridgeOperation = "/api.v1.services.system.ResourceService/UpdateResource" - -type ResourceServiceBridgeServer interface { - CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) - DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) - GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) - ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) - UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) -} - -type ResourceServiceHooker interface { - ResourceServiceCreateResourceHooker - ResourceServiceDeleteResourceHooker - ResourceServiceGetResourceHooker - ResourceServiceListResourcesHooker - ResourceServiceUpdateResourceHooker -} - -type ResourceServiceHookedBridger interface { - ResourceServiceHooker - ResourceServiceBridgeServer -} -type ResourceServiceCreateResourceHooker interface { - PrepareCreateResource(http.Context, *CreateResourceRequest) (context.Context, error) - CompleteCreateResource(http.Context, *CreateResourceRequest, *CreateResourceResponse) error -} -type ResourceServiceDeleteResourceHooker interface { - PrepareDeleteResource(http.Context, *DeleteResourceRequest) (context.Context, error) - CompleteDeleteResource(http.Context, *DeleteResourceRequest, *DeleteResourceResponse) error -} -type ResourceServiceGetResourceHooker interface { - PrepareGetResource(http.Context, *GetResourceRequest) (context.Context, error) - CompleteGetResource(http.Context, *GetResourceRequest, *GetResourceResponse) error -} -type ResourceServiceListResourcesHooker interface { - PrepareListResources(http.Context, *ListResourcesRequest) (context.Context, error) - CompleteListResources(http.Context, *ListResourcesRequest, *ListResourcesResponse) error -} -type ResourceServiceUpdateResourceHooker interface { - PrepareUpdateResource(http.Context, *UpdateResourceRequest) (context.Context, error) - CompleteUpdateResource(http.Context, *UpdateResourceRequest, *UpdateResourceResponse) error -} - -func RegisterResourceServiceBridgeServer(s *http.Server, srv ResourceServiceHookedBridger) { - r := s.Route("/") - r.GET("/sys/resources", _ResourceService_ListResources0_Bridge_Handler(srv)) - r.GET("/sys/resources/:id", _ResourceService_GetResource0_Bridge_Handler(srv)) - r.POST("/sys/resources", _ResourceService_CreateResource0_Bridge_Handler(srv)) - r.PUT("/sys/resources/:resource.id", _ResourceService_UpdateResource0_Bridge_Handler(srv)) - r.DELETE("/sys/resources/:id", _ResourceService_DeleteResource0_Bridge_Handler(srv)) -} - -func _ResourceService_ListResources0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationResourceServiceListResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListResources(ctx, req.(*ListResourcesRequest)) - }) - - newctx, err := srv.PrepareListResources(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListResources(ctx, &in, out.(*ListResourcesResponse)) - } -} - -func _ResourceService_GetResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetResourceRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationResourceServiceGetResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetResource(ctx, req.(*GetResourceRequest)) - }) - - newctx, err := srv.PrepareGetResource(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetResource(ctx, &in, out.(*GetResourceResponse)) - } -} - -func _ResourceService_CreateResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateResourceRequest - if err := ctx.Bind(&in.Resource); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationResourceServiceCreateResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateResource(ctx, req.(*CreateResourceRequest)) - }) - - newctx, err := srv.PrepareCreateResource(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreateResource(ctx, &in, out.(*CreateResourceResponse)) - } -} - -func _ResourceService_UpdateResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateResourceRequest - if err := ctx.Bind(&in.Resource); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationResourceServiceUpdateResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateResource(ctx, req.(*UpdateResourceRequest)) - }) - - newctx, err := srv.PrepareUpdateResource(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateResource(ctx, &in, out.(*UpdateResourceResponse)) - } -} - -func _ResourceService_DeleteResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteResourceRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationResourceServiceDeleteResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteResource(ctx, req.(*DeleteResourceRequest)) - }) - - newctx, err := srv.PrepareDeleteResource(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeleteResource(ctx, &in, out.(*DeleteResourceResponse)) - } -} - -// UnimplementedResourceServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedResourceServiceHooked struct{} - -func (UnimplementedResourceServiceHooked) PrepareCreateResource(ctx http.Context, in *CreateResourceRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedResourceServiceHooked) CompleteCreateResource(ctx http.Context, in *CreateResourceRequest, out *CreateResourceResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedResourceServiceHooked) PrepareDeleteResource(ctx http.Context, in *DeleteResourceRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedResourceServiceHooked) CompleteDeleteResource(ctx http.Context, in *DeleteResourceRequest, out *DeleteResourceResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedResourceServiceHooked) PrepareGetResource(ctx http.Context, in *GetResourceRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedResourceServiceHooked) CompleteGetResource(ctx http.Context, in *GetResourceRequest, out *GetResourceResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedResourceServiceHooked) PrepareListResources(ctx http.Context, in *ListResourcesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedResourceServiceHooked) CompleteListResources(ctx http.Context, in *ListResourcesRequest, out *ListResourcesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedResourceServiceHooked) PrepareUpdateResource(ctx http.Context, in *UpdateResourceRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedResourceServiceHooked) CompleteUpdateResource(ctx http.Context, in *UpdateResourceRequest, out *UpdateResourceResponse) error { - return ctx.Result(200, out) -} - -func WithResourceServiceHook(h ResourceServiceHooker) func(ResourceServiceBridgeServer) ResourceServiceHookedBridger { - return func(srv ResourceServiceBridgeServer) ResourceServiceHookedBridger { - return ResourceServiceHookedBridge{ResourceServiceBridgeServer: srv, ResourceServiceHooker: h} - } -} - -// ResourceServiceHookedBridge is a bridge between the HTTP and gRPC implementations of ResourceService. -// It implements the HTTP and gRPC implementations of ResourceService. -// It forwards requests and responses between the two implementations. -type ResourceServiceHookedBridge struct { - ResourceServiceBridgeServer - ResourceServiceHooker -} - -type ResourceServiceHTTPBridgeImpl struct { - client ResourceServiceHTTPClient -} - -func NewResourceServiceHTTPBridge(client *http.Client) ResourceServiceHTTPServer { - return &ResourceServiceHTTPBridgeImpl{client: NewResourceServiceHTTPClient(client)} -} - -func (c *ResourceServiceHTTPBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { - return c.client.CreateResource(ctx, in) -} - -func (c *ResourceServiceHTTPBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { - return c.client.DeleteResource(ctx, in) -} - -func (c *ResourceServiceHTTPBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { - return c.client.GetResource(ctx, in) -} - -func (c *ResourceServiceHTTPBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { - return c.client.ListResources(ctx, in) -} - -func (c *ResourceServiceHTTPBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { - return c.client.UpdateResource(ctx, in) -} - -type ResourceServiceBridgeImpl struct { - client ResourceServiceClient -} - -func NewResourceServiceBridge(client grpc.ClientConnInterface) ResourceServiceServer { - return &ResourceServiceBridgeImpl{client: NewResourceServiceClient(client)} -} - -func (c *ResourceServiceBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { - return c.client.CreateResource(ctx, in) -} - -func (c *ResourceServiceBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { - return c.client.DeleteResource(ctx, in) -} - -func (c *ResourceServiceBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { - return c.client.GetResource(ctx, in) -} - -func (c *ResourceServiceBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { - return c.client.ListResources(ctx, in) -} - -func (c *ResourceServiceBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { - return c.client.UpdateResource(ctx, in) -} - -func (c *ResourceServiceBridgeImpl) mustEmbedUnimplementedResourceServiceServer() {} - -type ResourceServiceGRPC2HTTPBridgeImpl struct { - client ResourceServiceClient -} - -func NewResourceServiceGRPC2HTTP(client grpc.ClientConnInterface) ResourceServiceHTTPServer { - return &ResourceServiceGRPC2HTTPBridgeImpl{client: NewResourceServiceClient(client)} -} - -func (c *ResourceServiceGRPC2HTTPBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { - return c.client.CreateResource(ctx, in) -} - -func (c *ResourceServiceGRPC2HTTPBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { - return c.client.DeleteResource(ctx, in) -} - -func (c *ResourceServiceGRPC2HTTPBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { - return c.client.GetResource(ctx, in) -} - -func (c *ResourceServiceGRPC2HTTPBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { - return c.client.ListResources(ctx, in) -} - -func (c *ResourceServiceGRPC2HTTPBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { - return c.client.UpdateResource(ctx, in) -} - -type ResourceServiceHTTP2GRPCBridgeImpl struct { - client ResourceServiceHTTPClient -} - -func NewResourceServiceHTTP2GRPC(client *http.Client) ResourceServiceServer { - return &ResourceServiceHTTP2GRPCBridgeImpl{client: NewResourceServiceHTTPClient(client)} -} - -func (c *ResourceServiceHTTP2GRPCBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { - return c.client.CreateResource(ctx, in) -} - -func (c *ResourceServiceHTTP2GRPCBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { - return c.client.DeleteResource(ctx, in) -} - -func (c *ResourceServiceHTTP2GRPCBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { - return c.client.GetResource(ctx, in) -} - -func (c *ResourceServiceHTTP2GRPCBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { - return c.client.ListResources(ctx, in) -} - -func (c *ResourceServiceHTTP2GRPCBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { - return c.client.UpdateResource(ctx, in) -} - -func (c *ResourceServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedResourceServiceServer() {} diff --git a/api/v1/services/system/resource_grpc.pb.go b/api/v1/services/system/resource_grpc.pb.go deleted file mode 100644 index e730965e..00000000 --- a/api/v1/services/system/resource_grpc.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: system/resource.proto - -package system - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - ResourceService_ListResources_FullMethodName = "/api.v1.services.system.ResourceService/ListResources" - ResourceService_GetResource_FullMethodName = "/api.v1.services.system.ResourceService/GetResource" - ResourceService_CreateResource_FullMethodName = "/api.v1.services.system.ResourceService/CreateResource" - ResourceService_UpdateResource_FullMethodName = "/api.v1.services.system.ResourceService/UpdateResource" - ResourceService_DeleteResource_FullMethodName = "/api.v1.services.system.ResourceService/DeleteResource" -) - -// ResourceServiceClient is the client API for ResourceService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The resource service definition. -type ResourceServiceClient interface { - ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error) - GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) - CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error) - UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error) - DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error) -} - -type resourceServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewResourceServiceClient(cc grpc.ClientConnInterface) ResourceServiceClient { - return &resourceServiceClient{cc} -} - -func (c *resourceServiceClient) ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListResourcesResponse) - err := c.cc.Invoke(ctx, ResourceService_ListResources_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *resourceServiceClient) GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetResourceResponse) - err := c.cc.Invoke(ctx, ResourceService_GetResource_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *resourceServiceClient) CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateResourceResponse) - err := c.cc.Invoke(ctx, ResourceService_CreateResource_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *resourceServiceClient) UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateResourceResponse) - err := c.cc.Invoke(ctx, ResourceService_UpdateResource_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *resourceServiceClient) DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeleteResourceResponse) - err := c.cc.Invoke(ctx, ResourceService_DeleteResource_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ResourceServiceServer is the server API for ResourceService service. -// All implementations must embed UnimplementedResourceServiceServer -// for forward compatibility. -// -// The resource service definition. -type ResourceServiceServer interface { - ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) - GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) - CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) - UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) - DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) - mustEmbedUnimplementedResourceServiceServer() -} - -// UnimplementedResourceServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedResourceServiceServer struct{} - -func (UnimplementedResourceServiceServer) ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListResources not implemented") -} -func (UnimplementedResourceServiceServer) GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetResource not implemented") -} -func (UnimplementedResourceServiceServer) CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateResource not implemented") -} -func (UnimplementedResourceServiceServer) UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateResource not implemented") -} -func (UnimplementedResourceServiceServer) DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteResource not implemented") -} -func (UnimplementedResourceServiceServer) mustEmbedUnimplementedResourceServiceServer() {} -func (UnimplementedResourceServiceServer) testEmbeddedByValue() {} - -// UnsafeResourceServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ResourceServiceServer will -// result in compilation errors. -type UnsafeResourceServiceServer interface { - mustEmbedUnimplementedResourceServiceServer() -} - -func RegisterResourceServiceServer(s grpc.ServiceRegistrar, srv ResourceServiceServer) { - // If the following call pancis, it indicates UnimplementedResourceServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&ResourceService_ServiceDesc, srv) -} - -func _ResourceService_ListResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListResourcesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ResourceServiceServer).ListResources(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ResourceService_ListResources_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ResourceServiceServer).ListResources(ctx, req.(*ListResourcesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _ResourceService_GetResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetResourceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ResourceServiceServer).GetResource(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ResourceService_GetResource_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ResourceServiceServer).GetResource(ctx, req.(*GetResourceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _ResourceService_CreateResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateResourceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ResourceServiceServer).CreateResource(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ResourceService_CreateResource_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ResourceServiceServer).CreateResource(ctx, req.(*CreateResourceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _ResourceService_UpdateResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateResourceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ResourceServiceServer).UpdateResource(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ResourceService_UpdateResource_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ResourceServiceServer).UpdateResource(ctx, req.(*UpdateResourceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _ResourceService_DeleteResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteResourceRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ResourceServiceServer).DeleteResource(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ResourceService_DeleteResource_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ResourceServiceServer).DeleteResource(ctx, req.(*DeleteResourceRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// ResourceService_ServiceDesc is the grpc.ServiceDesc for ResourceService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var ResourceService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.ResourceService", - HandlerType: (*ResourceServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListResources", - Handler: _ResourceService_ListResources_Handler, - }, - { - MethodName: "GetResource", - Handler: _ResourceService_GetResource_Handler, - }, - { - MethodName: "CreateResource", - Handler: _ResourceService_CreateResource_Handler, - }, - { - MethodName: "UpdateResource", - Handler: _ResourceService_UpdateResource_Handler, - }, - { - MethodName: "DeleteResource", - Handler: _ResourceService_DeleteResource_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "system/resource.proto", -} diff --git a/api/v1/services/system/resource_http.pb.go b/api/v1/services/system/resource_http.pb.go deleted file mode 100644 index 05816b6c..00000000 --- a/api/v1/services/system/resource_http.pb.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: system/resource.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationResourceServiceCreateResource = "/api.v1.services.system.ResourceService/CreateResource" -const OperationResourceServiceDeleteResource = "/api.v1.services.system.ResourceService/DeleteResource" -const OperationResourceServiceGetResource = "/api.v1.services.system.ResourceService/GetResource" -const OperationResourceServiceListResources = "/api.v1.services.system.ResourceService/ListResources" -const OperationResourceServiceUpdateResource = "/api.v1.services.system.ResourceService/UpdateResource" - -type ResourceServiceHTTPServer interface { - CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) - DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) - GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) - ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) - UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) -} - -func RegisterResourceServiceHTTPServer(s *http.Server, srv ResourceServiceHTTPServer) { - r := s.Route("/") - r.GET("/sys/resources", _ResourceService_ListResources0_HTTP_Handler(srv)) - r.GET("/sys/resources/{id}", _ResourceService_GetResource0_HTTP_Handler(srv)) - r.POST("/sys/resources", _ResourceService_CreateResource0_HTTP_Handler(srv)) - r.PUT("/sys/resources/{resource.id}", _ResourceService_UpdateResource0_HTTP_Handler(srv)) - r.DELETE("/sys/resources/{id}", _ResourceService_DeleteResource0_HTTP_Handler(srv)) -} - -func _ResourceService_ListResources0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationResourceServiceListResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListResources(ctx, req.(*ListResourcesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListResourcesResponse) - return ctx.Result(200, reply) - } -} - -func _ResourceService_GetResource0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetResourceRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationResourceServiceGetResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetResource(ctx, req.(*GetResourceRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetResourceResponse) - return ctx.Result(200, reply) - } -} - -func _ResourceService_CreateResource0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateResourceRequest - if err := ctx.Bind(&in.Resource); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationResourceServiceCreateResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateResource(ctx, req.(*CreateResourceRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreateResourceResponse) - return ctx.Result(200, reply) - } -} - -func _ResourceService_UpdateResource0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateResourceRequest - if err := ctx.Bind(&in.Resource); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationResourceServiceUpdateResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateResource(ctx, req.(*UpdateResourceRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateResourceResponse) - return ctx.Result(200, reply) - } -} - -func _ResourceService_DeleteResource0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteResourceRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationResourceServiceDeleteResource) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteResource(ctx, req.(*DeleteResourceRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteResourceResponse) - return ctx.Result(200, reply) - } -} - -type ResourceServiceHTTPClient interface { - CreateResource(ctx context.Context, req *CreateResourceRequest, opts ...http.CallOption) (rsp *CreateResourceResponse, err error) - DeleteResource(ctx context.Context, req *DeleteResourceRequest, opts ...http.CallOption) (rsp *DeleteResourceResponse, err error) - GetResource(ctx context.Context, req *GetResourceRequest, opts ...http.CallOption) (rsp *GetResourceResponse, err error) - ListResources(ctx context.Context, req *ListResourcesRequest, opts ...http.CallOption) (rsp *ListResourcesResponse, err error) - UpdateResource(ctx context.Context, req *UpdateResourceRequest, opts ...http.CallOption) (rsp *UpdateResourceResponse, err error) -} - -type ResourceServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewResourceServiceHTTPClient(client *http.Client) ResourceServiceHTTPClient { - return &ResourceServiceHTTPClientImpl{client} -} - -func (c *ResourceServiceHTTPClientImpl) CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...http.CallOption) (*CreateResourceResponse, error) { - var out CreateResourceResponse - pattern := "/sys/resources" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationResourceServiceCreateResource)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Resource, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *ResourceServiceHTTPClientImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...http.CallOption) (*DeleteResourceResponse, error) { - var out DeleteResourceResponse - pattern := "/sys/resources/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationResourceServiceDeleteResource)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *ResourceServiceHTTPClientImpl) GetResource(ctx context.Context, in *GetResourceRequest, opts ...http.CallOption) (*GetResourceResponse, error) { - var out GetResourceResponse - pattern := "/sys/resources/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationResourceServiceGetResource)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *ResourceServiceHTTPClientImpl) ListResources(ctx context.Context, in *ListResourcesRequest, opts ...http.CallOption) (*ListResourcesResponse, error) { - var out ListResourcesResponse - pattern := "/sys/resources" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationResourceServiceListResources)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *ResourceServiceHTTPClientImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...http.CallOption) (*UpdateResourceResponse, error) { - var out UpdateResourceResponse - pattern := "/sys/resources/{resource.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationResourceServiceUpdateResource)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Resource, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/system/role.pb.go b/api/v1/services/system/role.pb.go deleted file mode 100644 index 37d20a2d..00000000 --- a/api/v1/services/system/role.pb.go +++ /dev/null @@ -1,731 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: system/role.proto - -package system - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ListRolesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListRolesRequest) Reset() { - *x = ListRolesRequest{} - mi := &file_system_role_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListRolesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListRolesRequest) ProtoMessage() {} - -func (x *ListRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_role_proto_msgTypes[0] - 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 ListRolesRequest.ProtoReflect.Descriptor instead. -func (*ListRolesRequest) Descriptor() ([]byte, []int) { - return file_system_role_proto_rawDescGZIP(), []int{0} -} - -func (x *ListRolesRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListRolesRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListRolesRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListRolesRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListRolesRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListRolesRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -type ListRolesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - // The paging menus - Roles []*types.Role `protobuf:"bytes,2,rep,name=roles,proto3" json:"roles,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListRolesResponse) Reset() { - *x = ListRolesResponse{} - mi := &file_system_role_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListRolesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListRolesResponse) ProtoMessage() {} - -func (x *ListRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_role_proto_msgTypes[1] - 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 ListRolesResponse.ProtoReflect.Descriptor instead. -func (*ListRolesResponse) Descriptor() ([]byte, []int) { - return file_system_role_proto_rawDescGZIP(), []int{1} -} - -func (x *ListRolesResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListRolesResponse) GetRoles() []*types.Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *ListRolesResponse) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListRolesResponse) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListRolesResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -func (x *ListRolesResponse) GetExtra() *anypb.Any { - if x != nil { - return x.Extra - } - return nil -} - -type GetRoleRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/roles/role2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetRoleRequest) Reset() { - *x = GetRoleRequest{} - mi := &file_system_role_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetRoleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetRoleRequest) ProtoMessage() {} - -func (x *GetRoleRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_role_proto_msgTypes[2] - 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 GetRoleRequest.ProtoReflect.Descriptor instead. -func (*GetRoleRequest) Descriptor() ([]byte, []int) { - return file_system_role_proto_rawDescGZIP(), []int{2} -} - -func (x *GetRoleRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type GetRoleResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetRoleResponse) Reset() { - *x = GetRoleResponse{} - mi := &file_system_role_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetRoleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetRoleResponse) ProtoMessage() {} - -func (x *GetRoleResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_role_proto_msgTypes[3] - 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 GetRoleResponse.ProtoReflect.Descriptor instead. -func (*GetRoleResponse) Descriptor() ([]byte, []int) { - return file_system_role_proto_rawDescGZIP(), []int{3} -} - -func (x *GetRoleResponse) GetRole() *types.Role { - if x != nil { - return x.Role - } - return nil -} - -type CreateRoleRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id where the role is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The role id to use for this role. - RoleId string `protobuf:"bytes,3,opt,name=role_id,proto3" json:"role_id,omitempty"` - // The role resource to create. - // The field id should match the Noun in the method id. - Role *types.Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateRoleRequest) Reset() { - *x = CreateRoleRequest{} - mi := &file_system_role_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateRoleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateRoleRequest) ProtoMessage() {} - -func (x *CreateRoleRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_role_proto_msgTypes[4] - 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 CreateRoleRequest.ProtoReflect.Descriptor instead. -func (*CreateRoleRequest) Descriptor() ([]byte, []int) { - return file_system_role_proto_rawDescGZIP(), []int{4} -} - -func (x *CreateRoleRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreateRoleRequest) GetRoleId() string { - if x != nil { - return x.RoleId - } - return "" -} - -func (x *CreateRoleRequest) GetRole() *types.Role { - if x != nil { - return x.Role - } - return nil -} - -type CreateRoleResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateRoleResponse) Reset() { - *x = CreateRoleResponse{} - mi := &file_system_role_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateRoleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateRoleResponse) ProtoMessage() {} - -func (x *CreateRoleResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_role_proto_msgTypes[5] - 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 CreateRoleResponse.ProtoReflect.Descriptor instead. -func (*CreateRoleResponse) Descriptor() ([]byte, []int) { - return file_system_role_proto_rawDescGZIP(), []int{5} -} - -func (x *CreateRoleResponse) GetRole() *types.Role { - if x != nil { - return x.Role - } - return nil -} - -type UpdateRoleRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The id of the role resource to update. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The role resource which replaces the resource on the server. - Role *types.Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateRoleRequest) Reset() { - *x = UpdateRoleRequest{} - mi := &file_system_role_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateRoleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateRoleRequest) ProtoMessage() {} - -func (x *UpdateRoleRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_role_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 UpdateRoleRequest.ProtoReflect.Descriptor instead. -func (*UpdateRoleRequest) Descriptor() ([]byte, []int) { - return file_system_role_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdateRoleRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UpdateRoleRequest) GetRole() *types.Role { - if x != nil { - return x.Role - } - return nil -} - -type UpdateRoleResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateRoleResponse) Reset() { - *x = UpdateRoleResponse{} - mi := &file_system_role_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateRoleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateRoleResponse) ProtoMessage() {} - -func (x *UpdateRoleResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_role_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateRoleResponse.ProtoReflect.Descriptor instead. -func (*UpdateRoleResponse) Descriptor() ([]byte, []int) { - return file_system_role_proto_rawDescGZIP(), []int{7} -} - -func (x *UpdateRoleResponse) GetRole() *types.Role { - if x != nil { - return x.Role - } - return nil -} - -type DeleteRoleRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The resource id of the role to be deleted, for example: - // "shelves/shelf1/roles/role2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteRoleRequest) Reset() { - *x = DeleteRoleRequest{} - mi := &file_system_role_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteRoleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteRoleRequest) ProtoMessage() {} - -func (x *DeleteRoleRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_role_proto_msgTypes[8] - 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 DeleteRoleRequest.ProtoReflect.Descriptor instead. -func (*DeleteRoleRequest) Descriptor() ([]byte, []int) { - return file_system_role_proto_rawDescGZIP(), []int{8} -} - -func (x *DeleteRoleRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type DeleteRoleResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteRoleResponse) Reset() { - *x = DeleteRoleResponse{} - mi := &file_system_role_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteRoleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteRoleResponse) ProtoMessage() {} - -func (x *DeleteRoleResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_role_proto_msgTypes[9] - 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 DeleteRoleResponse.ProtoReflect.Descriptor instead. -func (*DeleteRoleResponse) Descriptor() ([]byte, []int) { - return file_system_role_proto_rawDescGZIP(), []int{9} -} - -func (x *DeleteRoleResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -var File_system_role_proto protoreflect.FileDescriptor - -const file_system_role_proto_rawDesc = "" + - "\n" + - "\x11system/role.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xb8\x01\n" + - "\x10ListRolesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\x83\x02\n" + - "\x11ListRolesResponse\x12\x1e\n" + - "\n" + - "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x121\n" + - "\x05roles\x18\x02 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + - "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + - "\x06_extra\" \n" + - "\x0eGetRoleRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + - "\x0fGetRoleResponse\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"v\n" + - "\x11CreateRoleRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x18\n" + - "\arole_id\x18\x03 \x01(\tR\arole_id\x12/\n" + - "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"E\n" + - "\x12CreateRoleResponse\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"T\n" + - "\x11UpdateRoleRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12/\n" + - "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"E\n" + - "\x12UpdateRoleResponse\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"#\n" + - "\x11DeleteRoleRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + - "\x12DeleteRoleResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xff\x04\n" + - "\vRoleService\x12t\n" + - "\tListRoles\x12(.api.v1.services.system.ListRolesRequest\x1a).api.v1.services.system.ListRolesResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + - "/sys/roles\x12s\n" + - "\aGetRole\x12&.api.v1.services.system.GetRoleRequest\x1a'.api.v1.services.system.GetRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/roles/{id}\x12}\n" + - "\n" + - "CreateRole\x12).api.v1.services.system.CreateRoleRequest\x1a*.api.v1.services.system.CreateRoleResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04role\"\n" + - "/sys/roles\x12\x87\x01\n" + - "\n" + - "UpdateRole\x12).api.v1.services.system.UpdateRoleRequest\x1a*.api.v1.services.system.UpdateRoleResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04role\x1a\x14/sys/roles/{role.id}\x12|\n" + - "\n" + - "DeleteRole\x12).api.v1.services.system.DeleteRoleRequest\x1a*.api.v1.services.system.DeleteRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/roles/{id}B\xde\x01\n" + - "\x1acom.api.v1.services.systemB\tRoleProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_role_proto_rawDescOnce sync.Once - file_system_role_proto_rawDescData []byte -) - -func file_system_role_proto_rawDescGZIP() []byte { - file_system_role_proto_rawDescOnce.Do(func() { - file_system_role_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_role_proto_rawDesc), len(file_system_role_proto_rawDesc))) - }) - return file_system_role_proto_rawDescData -} - -var file_system_role_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_system_role_proto_goTypes = []any{ - (*ListRolesRequest)(nil), // 0: api.v1.services.system.ListRolesRequest - (*ListRolesResponse)(nil), // 1: api.v1.services.system.ListRolesResponse - (*GetRoleRequest)(nil), // 2: api.v1.services.system.GetRoleRequest - (*GetRoleResponse)(nil), // 3: api.v1.services.system.GetRoleResponse - (*CreateRoleRequest)(nil), // 4: api.v1.services.system.CreateRoleRequest - (*CreateRoleResponse)(nil), // 5: api.v1.services.system.CreateRoleResponse - (*UpdateRoleRequest)(nil), // 6: api.v1.services.system.UpdateRoleRequest - (*UpdateRoleResponse)(nil), // 7: api.v1.services.system.UpdateRoleResponse - (*DeleteRoleRequest)(nil), // 8: api.v1.services.system.DeleteRoleRequest - (*DeleteRoleResponse)(nil), // 9: api.v1.services.system.DeleteRoleResponse - (*types.Role)(nil), // 10: api.v1.services.types.Role - (*anypb.Any)(nil), // 11: google.protobuf.Any - (*emptypb.Empty)(nil), // 12: google.protobuf.Empty -} -var file_system_role_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListRolesResponse.roles:type_name -> api.v1.services.types.Role - 11, // 1: api.v1.services.system.ListRolesResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetRoleResponse.role:type_name -> api.v1.services.types.Role - 10, // 3: api.v1.services.system.CreateRoleRequest.role:type_name -> api.v1.services.types.Role - 10, // 4: api.v1.services.system.CreateRoleResponse.role:type_name -> api.v1.services.types.Role - 10, // 5: api.v1.services.system.UpdateRoleRequest.role:type_name -> api.v1.services.types.Role - 10, // 6: api.v1.services.system.UpdateRoleResponse.role:type_name -> api.v1.services.types.Role - 12, // 7: api.v1.services.system.DeleteRoleResponse.empty:type_name -> google.protobuf.Empty - 0, // 8: api.v1.services.system.RoleService.ListRoles:input_type -> api.v1.services.system.ListRolesRequest - 2, // 9: api.v1.services.system.RoleService.GetRole:input_type -> api.v1.services.system.GetRoleRequest - 4, // 10: api.v1.services.system.RoleService.CreateRole:input_type -> api.v1.services.system.CreateRoleRequest - 6, // 11: api.v1.services.system.RoleService.UpdateRole:input_type -> api.v1.services.system.UpdateRoleRequest - 8, // 12: api.v1.services.system.RoleService.DeleteRole:input_type -> api.v1.services.system.DeleteRoleRequest - 1, // 13: api.v1.services.system.RoleService.ListRoles:output_type -> api.v1.services.system.ListRolesResponse - 3, // 14: api.v1.services.system.RoleService.GetRole:output_type -> api.v1.services.system.GetRoleResponse - 5, // 15: api.v1.services.system.RoleService.CreateRole:output_type -> api.v1.services.system.CreateRoleResponse - 7, // 16: api.v1.services.system.RoleService.UpdateRole:output_type -> api.v1.services.system.UpdateRoleResponse - 9, // 17: api.v1.services.system.RoleService.DeleteRole:output_type -> api.v1.services.system.DeleteRoleResponse - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_system_role_proto_init() } -func file_system_role_proto_init() { - if File_system_role_proto != nil { - return - } - file_system_role_proto_msgTypes[1].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_role_proto_rawDesc), len(file_system_role_proto_rawDesc)), - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_system_role_proto_goTypes, - DependencyIndexes: file_system_role_proto_depIdxs, - MessageInfos: file_system_role_proto_msgTypes, - }.Build() - File_system_role_proto = out.File - file_system_role_proto_goTypes = nil - file_system_role_proto_depIdxs = nil -} diff --git a/api/v1/services/system/role.pb.gw.go b/api/v1/services/system/role.pb.gw.go deleted file mode 100644 index 7f3f6e9a..00000000 --- a/api/v1/services/system/role.pb.gw.go +++ /dev/null @@ -1,487 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/role.proto - -/* -Package system is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package system - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_RoleService_ListRoles_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_RoleService_ListRoles_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListRolesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_ListRoles_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_RoleService_ListRoles_0(ctx context.Context, marshaler runtime.Marshaler, server RoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListRolesRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_ListRoles_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListRoles(ctx, &protoReq) - return msg, metadata, err -} - -func request_RoleService_GetRole_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetRoleRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_RoleService_GetRole_0(ctx context.Context, marshaler runtime.Marshaler, server RoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetRoleRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetRole(ctx, &protoReq) - return msg, metadata, err -} - -var filter_RoleService_CreateRole_0 = &utilities.DoubleArray{Encoding: map[string]int{"role": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - -func request_RoleService_CreateRole_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateRoleRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_CreateRole_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreateRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_RoleService_CreateRole_0(ctx context.Context, marshaler runtime.Marshaler, server RoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateRoleRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_CreateRole_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreateRole(ctx, &protoReq) - return msg, metadata, err -} - -var filter_RoleService_UpdateRole_0 = &utilities.DoubleArray{Encoding: map[string]int{"role": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - -func request_RoleService_UpdateRole_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateRoleRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["role.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "role.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "role.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_UpdateRole_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdateRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_RoleService_UpdateRole_0(ctx context.Context, marshaler runtime.Marshaler, server RoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateRoleRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["role.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "role.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "role.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_UpdateRole_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdateRole(ctx, &protoReq) - return msg, metadata, err -} - -func request_RoleService_DeleteRole_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteRoleRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.DeleteRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_RoleService_DeleteRole_0(ctx context.Context, marshaler runtime.Marshaler, server RoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteRoleRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.DeleteRole(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterRoleServiceHandlerServer registers the http handlers for service RoleService to "mux". -// UnaryRPC :call RoleServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterRoleServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterRoleServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RoleServiceServer) error { - mux.Handle(http.MethodGet, pattern_RoleService_ListRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.RoleService/ListRoles", runtime.WithHTTPPathPattern("/sys/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_RoleService_ListRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_RoleService_ListRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_RoleService_GetRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.RoleService/GetRole", runtime.WithHTTPPathPattern("/sys/roles/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_RoleService_GetRole_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_RoleService_GetRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_RoleService_CreateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.RoleService/CreateRole", runtime.WithHTTPPathPattern("/sys/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_RoleService_CreateRole_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_RoleService_CreateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_RoleService_UpdateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.RoleService/UpdateRole", runtime.WithHTTPPathPattern("/sys/roles/{role.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_RoleService_UpdateRole_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_RoleService_UpdateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_RoleService_DeleteRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.RoleService/DeleteRole", runtime.WithHTTPPathPattern("/sys/roles/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_RoleService_DeleteRole_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_RoleService_DeleteRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterRoleServiceHandlerFromEndpoint is same as RegisterRoleServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterRoleServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterRoleServiceHandler(ctx, mux, conn) -} - -// RegisterRoleServiceHandler registers the http handlers for service RoleService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterRoleServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterRoleServiceHandlerClient(ctx, mux, NewRoleServiceClient(conn)) -} - -// RegisterRoleServiceHandlerClient registers the http handlers for service RoleService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "RoleServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "RoleServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "RoleServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterRoleServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RoleServiceClient) error { - mux.Handle(http.MethodGet, pattern_RoleService_ListRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.RoleService/ListRoles", runtime.WithHTTPPathPattern("/sys/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_RoleService_ListRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_RoleService_ListRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_RoleService_GetRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.RoleService/GetRole", runtime.WithHTTPPathPattern("/sys/roles/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_RoleService_GetRole_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_RoleService_GetRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_RoleService_CreateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.RoleService/CreateRole", runtime.WithHTTPPathPattern("/sys/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_RoleService_CreateRole_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_RoleService_CreateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_RoleService_UpdateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.RoleService/UpdateRole", runtime.WithHTTPPathPattern("/sys/roles/{role.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_RoleService_UpdateRole_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_RoleService_UpdateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_RoleService_DeleteRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.RoleService/DeleteRole", runtime.WithHTTPPathPattern("/sys/roles/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_RoleService_DeleteRole_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_RoleService_DeleteRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_RoleService_ListRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "roles"}, "")) - pattern_RoleService_GetRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "roles", "id"}, "")) - pattern_RoleService_CreateRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "roles"}, "")) - pattern_RoleService_UpdateRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "roles", "role.id"}, "")) - pattern_RoleService_DeleteRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "roles", "id"}, "")) -) - -var ( - forward_RoleService_ListRoles_0 = runtime.ForwardResponseMessage - forward_RoleService_GetRole_0 = runtime.ForwardResponseMessage - forward_RoleService_CreateRole_0 = runtime.ForwardResponseMessage - forward_RoleService_UpdateRole_0 = runtime.ForwardResponseMessage - forward_RoleService_DeleteRole_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/system/role.pb.validate.go b/api/v1/services/system/role.pb.validate.go deleted file mode 100644 index d4113bc2..00000000 --- a/api/v1/services/system/role.pb.validate.go +++ /dev/null @@ -1,1321 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/role.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListRolesRequest 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 *ListRolesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListRolesRequest 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 -// ListRolesRequestMultiError, or nil if none found. -func (m *ListRolesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListRolesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - if len(errors) > 0 { - return ListRolesRequestMultiError(errors) - } - - return nil -} - -// ListRolesRequestMultiError is an error wrapping multiple validation errors -// returned by ListRolesRequest.ValidateAll() if the designated constraints -// aren't met. -type ListRolesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListRolesRequestMultiError) 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 ListRolesRequestMultiError) AllErrors() []error { return m } - -// ListRolesRequestValidationError is the validation error returned by -// ListRolesRequest.Validate if the designated constraints aren't met. -type ListRolesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListRolesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListRolesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListRolesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListRolesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListRolesRequestValidationError) ErrorName() string { return "ListRolesRequestValidationError" } - -// Error satisfies the builtin error interface -func (e ListRolesRequestValidationError) 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 %sListRolesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListRolesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListRolesRequestValidationError{} - -// Validate checks the field values on ListRolesResponse 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 *ListRolesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListRolesResponse 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 -// ListRolesResponseMultiError, or nil if none found. -func (m *ListRolesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListRolesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for NextPageToken - - if m.Extra != nil { - - if all { - switch v := interface{}(m.GetExtra()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListRolesResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListRolesResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListRolesResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListRolesResponseMultiError(errors) - } - - return nil -} - -// ListRolesResponseMultiError is an error wrapping multiple validation errors -// returned by ListRolesResponse.ValidateAll() if the designated constraints -// aren't met. -type ListRolesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListRolesResponseMultiError) 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 ListRolesResponseMultiError) AllErrors() []error { return m } - -// ListRolesResponseValidationError is the validation error returned by -// ListRolesResponse.Validate if the designated constraints aren't met. -type ListRolesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListRolesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListRolesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListRolesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListRolesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListRolesResponseValidationError) ErrorName() string { - return "ListRolesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListRolesResponseValidationError) 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 %sListRolesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListRolesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListRolesResponseValidationError{} - -// Validate checks the field values on GetRoleRequest 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 *GetRoleRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetRoleRequest 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 GetRoleRequestMultiError, -// or nil if none found. -func (m *GetRoleRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetRoleRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return GetRoleRequestMultiError(errors) - } - - return nil -} - -// GetRoleRequestMultiError is an error wrapping multiple validation errors -// returned by GetRoleRequest.ValidateAll() if the designated constraints -// aren't met. -type GetRoleRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetRoleRequestMultiError) 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 GetRoleRequestMultiError) AllErrors() []error { return m } - -// GetRoleRequestValidationError is the validation error returned by -// GetRoleRequest.Validate if the designated constraints aren't met. -type GetRoleRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetRoleRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetRoleRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetRoleRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetRoleRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetRoleRequestValidationError) ErrorName() string { return "GetRoleRequestValidationError" } - -// Error satisfies the builtin error interface -func (e GetRoleRequestValidationError) 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 %sGetRoleRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetRoleRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetRoleRequestValidationError{} - -// Validate checks the field values on GetRoleResponse 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 *GetRoleResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetRoleResponse 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 -// GetRoleResponseMultiError, or nil if none found. -func (m *GetRoleResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetRoleResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetRoleResponseValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetRoleResponseValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetRoleResponseValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetRoleResponseMultiError(errors) - } - - return nil -} - -// GetRoleResponseMultiError is an error wrapping multiple validation errors -// returned by GetRoleResponse.ValidateAll() if the designated constraints -// aren't met. -type GetRoleResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetRoleResponseMultiError) 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 GetRoleResponseMultiError) AllErrors() []error { return m } - -// GetRoleResponseValidationError is the validation error returned by -// GetRoleResponse.Validate if the designated constraints aren't met. -type GetRoleResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetRoleResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetRoleResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetRoleResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetRoleResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetRoleResponseValidationError) ErrorName() string { return "GetRoleResponseValidationError" } - -// Error satisfies the builtin error interface -func (e GetRoleResponseValidationError) 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 %sGetRoleResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetRoleResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetRoleResponseValidationError{} - -// Validate checks the field values on CreateRoleRequest 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 *CreateRoleRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateRoleRequest 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 -// CreateRoleRequestMultiError, or nil if none found. -func (m *CreateRoleRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateRoleRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Parent - - // no validation rules for RoleId - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateRoleRequestMultiError(errors) - } - - return nil -} - -// CreateRoleRequestMultiError is an error wrapping multiple validation errors -// returned by CreateRoleRequest.ValidateAll() if the designated constraints -// aren't met. -type CreateRoleRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateRoleRequestMultiError) 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 CreateRoleRequestMultiError) AllErrors() []error { return m } - -// CreateRoleRequestValidationError is the validation error returned by -// CreateRoleRequest.Validate if the designated constraints aren't met. -type CreateRoleRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateRoleRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateRoleRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateRoleRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateRoleRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateRoleRequestValidationError) ErrorName() string { - return "CreateRoleRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateRoleRequestValidationError) 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 %sCreateRoleRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateRoleRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateRoleRequestValidationError{} - -// Validate checks the field values on CreateRoleResponse 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 *CreateRoleResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateRoleResponse 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 -// CreateRoleResponseMultiError, or nil if none found. -func (m *CreateRoleResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateRoleResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateRoleResponseValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateRoleResponseValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateRoleResponseValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateRoleResponseMultiError(errors) - } - - return nil -} - -// CreateRoleResponseMultiError is an error wrapping multiple validation errors -// returned by CreateRoleResponse.ValidateAll() if the designated constraints -// aren't met. -type CreateRoleResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateRoleResponseMultiError) 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 CreateRoleResponseMultiError) AllErrors() []error { return m } - -// CreateRoleResponseValidationError is the validation error returned by -// CreateRoleResponse.Validate if the designated constraints aren't met. -type CreateRoleResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateRoleResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateRoleResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateRoleResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateRoleResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateRoleResponseValidationError) ErrorName() string { - return "CreateRoleResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateRoleResponseValidationError) 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 %sCreateRoleResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateRoleResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateRoleResponseValidationError{} - -// Validate checks the field values on UpdateRoleRequest 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 *UpdateRoleRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateRoleRequest 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 -// UpdateRoleRequestMultiError, or nil if none found. -func (m *UpdateRoleRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateRoleRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateRoleRequestMultiError(errors) - } - - return nil -} - -// UpdateRoleRequestMultiError is an error wrapping multiple validation errors -// returned by UpdateRoleRequest.ValidateAll() if the designated constraints -// aren't met. -type UpdateRoleRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateRoleRequestMultiError) 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 UpdateRoleRequestMultiError) AllErrors() []error { return m } - -// UpdateRoleRequestValidationError is the validation error returned by -// UpdateRoleRequest.Validate if the designated constraints aren't met. -type UpdateRoleRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateRoleRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateRoleRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateRoleRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateRoleRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateRoleRequestValidationError) ErrorName() string { - return "UpdateRoleRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateRoleRequestValidationError) 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 %sUpdateRoleRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateRoleRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateRoleRequestValidationError{} - -// Validate checks the field values on UpdateRoleResponse 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 *UpdateRoleResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateRoleResponse 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 -// UpdateRoleResponseMultiError, or nil if none found. -func (m *UpdateRoleResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateRoleResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateRoleResponseValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateRoleResponseValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateRoleResponseValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateRoleResponseMultiError(errors) - } - - return nil -} - -// UpdateRoleResponseMultiError is an error wrapping multiple validation errors -// returned by UpdateRoleResponse.ValidateAll() if the designated constraints -// aren't met. -type UpdateRoleResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateRoleResponseMultiError) 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 UpdateRoleResponseMultiError) AllErrors() []error { return m } - -// UpdateRoleResponseValidationError is the validation error returned by -// UpdateRoleResponse.Validate if the designated constraints aren't met. -type UpdateRoleResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateRoleResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateRoleResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateRoleResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateRoleResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateRoleResponseValidationError) ErrorName() string { - return "UpdateRoleResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateRoleResponseValidationError) 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 %sUpdateRoleResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateRoleResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateRoleResponseValidationError{} - -// Validate checks the field values on DeleteRoleRequest 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 *DeleteRoleRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteRoleRequest 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 -// DeleteRoleRequestMultiError, or nil if none found. -func (m *DeleteRoleRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteRoleRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return DeleteRoleRequestMultiError(errors) - } - - return nil -} - -// DeleteRoleRequestMultiError is an error wrapping multiple validation errors -// returned by DeleteRoleRequest.ValidateAll() if the designated constraints -// aren't met. -type DeleteRoleRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteRoleRequestMultiError) 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 DeleteRoleRequestMultiError) AllErrors() []error { return m } - -// DeleteRoleRequestValidationError is the validation error returned by -// DeleteRoleRequest.Validate if the designated constraints aren't met. -type DeleteRoleRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteRoleRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteRoleRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteRoleRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteRoleRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteRoleRequestValidationError) ErrorName() string { - return "DeleteRoleRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteRoleRequestValidationError) 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 %sDeleteRoleRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteRoleRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteRoleRequestValidationError{} - -// Validate checks the field values on DeleteRoleResponse 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 *DeleteRoleResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteRoleResponse 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 -// DeleteRoleResponseMultiError, or nil if none found. -func (m *DeleteRoleResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteRoleResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteRoleResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteRoleResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteRoleResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteRoleResponseMultiError(errors) - } - - return nil -} - -// DeleteRoleResponseMultiError is an error wrapping multiple validation errors -// returned by DeleteRoleResponse.ValidateAll() if the designated constraints -// aren't met. -type DeleteRoleResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteRoleResponseMultiError) 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 DeleteRoleResponseMultiError) AllErrors() []error { return m } - -// DeleteRoleResponseValidationError is the validation error returned by -// DeleteRoleResponse.Validate if the designated constraints aren't met. -type DeleteRoleResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteRoleResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteRoleResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteRoleResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteRoleResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteRoleResponseValidationError) ErrorName() string { - return "DeleteRoleResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteRoleResponseValidationError) 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 %sDeleteRoleResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteRoleResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteRoleResponseValidationError{} diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go deleted file mode 100644 index bb313daf..00000000 --- a/api/v1/services/system/role_bridge.pb.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: system/role.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const RoleServiceCreateRoleBridgeOperation = "/api.v1.services.system.RoleService/CreateRole" -const RoleServiceDeleteRoleBridgeOperation = "/api.v1.services.system.RoleService/DeleteRole" -const RoleServiceGetRoleBridgeOperation = "/api.v1.services.system.RoleService/GetRole" -const RoleServiceListRolesBridgeOperation = "/api.v1.services.system.RoleService/ListRoles" -const RoleServiceUpdateRoleBridgeOperation = "/api.v1.services.system.RoleService/UpdateRole" - -type RoleServiceBridgeServer interface { - CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) - DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) - GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) - ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) - UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) -} - -type RoleServiceHooker interface { - RoleServiceCreateRoleHooker - RoleServiceDeleteRoleHooker - RoleServiceGetRoleHooker - RoleServiceListRolesHooker - RoleServiceUpdateRoleHooker -} - -type RoleServiceHookedBridger interface { - RoleServiceHooker - RoleServiceBridgeServer -} -type RoleServiceCreateRoleHooker interface { - PrepareCreateRole(http.Context, *CreateRoleRequest) (context.Context, error) - CompleteCreateRole(http.Context, *CreateRoleRequest, *CreateRoleResponse) error -} -type RoleServiceDeleteRoleHooker interface { - PrepareDeleteRole(http.Context, *DeleteRoleRequest) (context.Context, error) - CompleteDeleteRole(http.Context, *DeleteRoleRequest, *DeleteRoleResponse) error -} -type RoleServiceGetRoleHooker interface { - PrepareGetRole(http.Context, *GetRoleRequest) (context.Context, error) - CompleteGetRole(http.Context, *GetRoleRequest, *GetRoleResponse) error -} -type RoleServiceListRolesHooker interface { - PrepareListRoles(http.Context, *ListRolesRequest) (context.Context, error) - CompleteListRoles(http.Context, *ListRolesRequest, *ListRolesResponse) error -} -type RoleServiceUpdateRoleHooker interface { - PrepareUpdateRole(http.Context, *UpdateRoleRequest) (context.Context, error) - CompleteUpdateRole(http.Context, *UpdateRoleRequest, *UpdateRoleResponse) error -} - -func RegisterRoleServiceBridgeServer(s *http.Server, srv RoleServiceHookedBridger) { - r := s.Route("/") - r.GET("/sys/roles", _RoleService_ListRoles0_Bridge_Handler(srv)) - r.GET("/sys/roles/:id", _RoleService_GetRole0_Bridge_Handler(srv)) - r.POST("/sys/roles", _RoleService_CreateRole0_Bridge_Handler(srv)) - r.PUT("/sys/roles/:role.id", _RoleService_UpdateRole0_Bridge_Handler(srv)) - r.DELETE("/sys/roles/:id", _RoleService_DeleteRole0_Bridge_Handler(srv)) -} - -func _RoleService_ListRoles0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListRolesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationRoleServiceListRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListRoles(ctx, req.(*ListRolesRequest)) - }) - - newctx, err := srv.PrepareListRoles(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListRoles(ctx, &in, out.(*ListRolesResponse)) - } -} - -func _RoleService_GetRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetRoleRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationRoleServiceGetRole) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetRole(ctx, req.(*GetRoleRequest)) - }) - - newctx, err := srv.PrepareGetRole(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetRole(ctx, &in, out.(*GetRoleResponse)) - } -} - -func _RoleService_CreateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateRoleRequest - if err := ctx.Bind(&in.Role); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationRoleServiceCreateRole) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateRole(ctx, req.(*CreateRoleRequest)) - }) - - newctx, err := srv.PrepareCreateRole(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreateRole(ctx, &in, out.(*CreateRoleResponse)) - } -} - -func _RoleService_UpdateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateRoleRequest - if err := ctx.Bind(&in.Role); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationRoleServiceUpdateRole) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateRole(ctx, req.(*UpdateRoleRequest)) - }) - - newctx, err := srv.PrepareUpdateRole(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateRole(ctx, &in, out.(*UpdateRoleResponse)) - } -} - -func _RoleService_DeleteRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteRoleRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationRoleServiceDeleteRole) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteRole(ctx, req.(*DeleteRoleRequest)) - }) - - newctx, err := srv.PrepareDeleteRole(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeleteRole(ctx, &in, out.(*DeleteRoleResponse)) - } -} - -// UnimplementedRoleServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedRoleServiceHooked struct{} - -func (UnimplementedRoleServiceHooked) PrepareCreateRole(ctx http.Context, in *CreateRoleRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedRoleServiceHooked) CompleteCreateRole(ctx http.Context, in *CreateRoleRequest, out *CreateRoleResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedRoleServiceHooked) PrepareDeleteRole(ctx http.Context, in *DeleteRoleRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedRoleServiceHooked) CompleteDeleteRole(ctx http.Context, in *DeleteRoleRequest, out *DeleteRoleResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedRoleServiceHooked) PrepareGetRole(ctx http.Context, in *GetRoleRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedRoleServiceHooked) CompleteGetRole(ctx http.Context, in *GetRoleRequest, out *GetRoleResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedRoleServiceHooked) PrepareListRoles(ctx http.Context, in *ListRolesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedRoleServiceHooked) CompleteListRoles(ctx http.Context, in *ListRolesRequest, out *ListRolesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedRoleServiceHooked) PrepareUpdateRole(ctx http.Context, in *UpdateRoleRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedRoleServiceHooked) CompleteUpdateRole(ctx http.Context, in *UpdateRoleRequest, out *UpdateRoleResponse) error { - return ctx.Result(200, out) -} - -func WithRoleServiceHook(h RoleServiceHooker) func(RoleServiceBridgeServer) RoleServiceHookedBridger { - return func(srv RoleServiceBridgeServer) RoleServiceHookedBridger { - return RoleServiceHookedBridge{RoleServiceBridgeServer: srv, RoleServiceHooker: h} - } -} - -// RoleServiceHookedBridge is a bridge between the HTTP and gRPC implementations of RoleService. -// It implements the HTTP and gRPC implementations of RoleService. -// It forwards requests and responses between the two implementations. -type RoleServiceHookedBridge struct { - RoleServiceBridgeServer - RoleServiceHooker -} - -type RoleServiceHTTPBridgeImpl struct { - client RoleServiceHTTPClient -} - -func NewRoleServiceHTTPBridge(client *http.Client) RoleServiceHTTPServer { - return &RoleServiceHTTPBridgeImpl{client: NewRoleServiceHTTPClient(client)} -} - -func (c *RoleServiceHTTPBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { - return c.client.CreateRole(ctx, in) -} - -func (c *RoleServiceHTTPBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { - return c.client.DeleteRole(ctx, in) -} - -func (c *RoleServiceHTTPBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { - return c.client.GetRole(ctx, in) -} - -func (c *RoleServiceHTTPBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { - return c.client.ListRoles(ctx, in) -} - -func (c *RoleServiceHTTPBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { - return c.client.UpdateRole(ctx, in) -} - -type RoleServiceBridgeImpl struct { - client RoleServiceClient -} - -func NewRoleServiceBridge(client grpc.ClientConnInterface) RoleServiceServer { - return &RoleServiceBridgeImpl{client: NewRoleServiceClient(client)} -} - -func (c *RoleServiceBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { - return c.client.CreateRole(ctx, in) -} - -func (c *RoleServiceBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { - return c.client.DeleteRole(ctx, in) -} - -func (c *RoleServiceBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { - return c.client.GetRole(ctx, in) -} - -func (c *RoleServiceBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { - return c.client.ListRoles(ctx, in) -} - -func (c *RoleServiceBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { - return c.client.UpdateRole(ctx, in) -} - -func (c *RoleServiceBridgeImpl) mustEmbedUnimplementedRoleServiceServer() {} - -type RoleServiceGRPC2HTTPBridgeImpl struct { - client RoleServiceClient -} - -func NewRoleServiceGRPC2HTTP(client grpc.ClientConnInterface) RoleServiceHTTPServer { - return &RoleServiceGRPC2HTTPBridgeImpl{client: NewRoleServiceClient(client)} -} - -func (c *RoleServiceGRPC2HTTPBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { - return c.client.CreateRole(ctx, in) -} - -func (c *RoleServiceGRPC2HTTPBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { - return c.client.DeleteRole(ctx, in) -} - -func (c *RoleServiceGRPC2HTTPBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { - return c.client.GetRole(ctx, in) -} - -func (c *RoleServiceGRPC2HTTPBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { - return c.client.ListRoles(ctx, in) -} - -func (c *RoleServiceGRPC2HTTPBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { - return c.client.UpdateRole(ctx, in) -} - -type RoleServiceHTTP2GRPCBridgeImpl struct { - client RoleServiceHTTPClient -} - -func NewRoleServiceHTTP2GRPC(client *http.Client) RoleServiceServer { - return &RoleServiceHTTP2GRPCBridgeImpl{client: NewRoleServiceHTTPClient(client)} -} - -func (c *RoleServiceHTTP2GRPCBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { - return c.client.CreateRole(ctx, in) -} - -func (c *RoleServiceHTTP2GRPCBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { - return c.client.DeleteRole(ctx, in) -} - -func (c *RoleServiceHTTP2GRPCBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { - return c.client.GetRole(ctx, in) -} - -func (c *RoleServiceHTTP2GRPCBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { - return c.client.ListRoles(ctx, in) -} - -func (c *RoleServiceHTTP2GRPCBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { - return c.client.UpdateRole(ctx, in) -} - -func (c *RoleServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedRoleServiceServer() {} diff --git a/api/v1/services/system/role_grpc.pb.go b/api/v1/services/system/role_grpc.pb.go deleted file mode 100644 index fc8b02e9..00000000 --- a/api/v1/services/system/role_grpc.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: system/role.proto - -package system - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - RoleService_ListRoles_FullMethodName = "/api.v1.services.system.RoleService/ListRoles" - RoleService_GetRole_FullMethodName = "/api.v1.services.system.RoleService/GetRole" - RoleService_CreateRole_FullMethodName = "/api.v1.services.system.RoleService/CreateRole" - RoleService_UpdateRole_FullMethodName = "/api.v1.services.system.RoleService/UpdateRole" - RoleService_DeleteRole_FullMethodName = "/api.v1.services.system.RoleService/DeleteRole" -) - -// RoleServiceClient is the client API for RoleService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The login service definition. -type RoleServiceClient interface { - ListRoles(ctx context.Context, in *ListRolesRequest, opts ...grpc.CallOption) (*ListRolesResponse, error) - GetRole(ctx context.Context, in *GetRoleRequest, opts ...grpc.CallOption) (*GetRoleResponse, error) - CreateRole(ctx context.Context, in *CreateRoleRequest, opts ...grpc.CallOption) (*CreateRoleResponse, error) - UpdateRole(ctx context.Context, in *UpdateRoleRequest, opts ...grpc.CallOption) (*UpdateRoleResponse, error) - DeleteRole(ctx context.Context, in *DeleteRoleRequest, opts ...grpc.CallOption) (*DeleteRoleResponse, error) -} - -type roleServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewRoleServiceClient(cc grpc.ClientConnInterface) RoleServiceClient { - return &roleServiceClient{cc} -} - -func (c *roleServiceClient) ListRoles(ctx context.Context, in *ListRolesRequest, opts ...grpc.CallOption) (*ListRolesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListRolesResponse) - err := c.cc.Invoke(ctx, RoleService_ListRoles_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *roleServiceClient) GetRole(ctx context.Context, in *GetRoleRequest, opts ...grpc.CallOption) (*GetRoleResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetRoleResponse) - err := c.cc.Invoke(ctx, RoleService_GetRole_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *roleServiceClient) CreateRole(ctx context.Context, in *CreateRoleRequest, opts ...grpc.CallOption) (*CreateRoleResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateRoleResponse) - err := c.cc.Invoke(ctx, RoleService_CreateRole_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *roleServiceClient) UpdateRole(ctx context.Context, in *UpdateRoleRequest, opts ...grpc.CallOption) (*UpdateRoleResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateRoleResponse) - err := c.cc.Invoke(ctx, RoleService_UpdateRole_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *roleServiceClient) DeleteRole(ctx context.Context, in *DeleteRoleRequest, opts ...grpc.CallOption) (*DeleteRoleResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeleteRoleResponse) - err := c.cc.Invoke(ctx, RoleService_DeleteRole_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. -// -// The login service definition. -type RoleServiceServer interface { - ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) - GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) - CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) - UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) - DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) - mustEmbedUnimplementedRoleServiceServer() -} - -// UnimplementedRoleServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedRoleServiceServer struct{} - -func (UnimplementedRoleServiceServer) ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListRoles not implemented") -} -func (UnimplementedRoleServiceServer) GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetRole not implemented") -} -func (UnimplementedRoleServiceServer) CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateRole not implemented") -} -func (UnimplementedRoleServiceServer) UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateRole not implemented") -} -func (UnimplementedRoleServiceServer) DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteRole not implemented") -} -func (UnimplementedRoleServiceServer) mustEmbedUnimplementedRoleServiceServer() {} -func (UnimplementedRoleServiceServer) testEmbeddedByValue() {} - -// UnsafeRoleServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to RoleServiceServer will -// result in compilation errors. -type UnsafeRoleServiceServer interface { - mustEmbedUnimplementedRoleServiceServer() -} - -func RegisterRoleServiceServer(s grpc.ServiceRegistrar, srv RoleServiceServer) { - // If the following call pancis, it indicates UnimplementedRoleServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&RoleService_ServiceDesc, srv) -} - -func _RoleService_ListRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListRolesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RoleServiceServer).ListRoles(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: RoleService_ListRoles_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RoleServiceServer).ListRoles(ctx, req.(*ListRolesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _RoleService_GetRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRoleRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RoleServiceServer).GetRole(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: RoleService_GetRole_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RoleServiceServer).GetRole(ctx, req.(*GetRoleRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _RoleService_CreateRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateRoleRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RoleServiceServer).CreateRole(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: RoleService_CreateRole_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RoleServiceServer).CreateRole(ctx, req.(*CreateRoleRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _RoleService_UpdateRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateRoleRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RoleServiceServer).UpdateRole(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: RoleService_UpdateRole_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RoleServiceServer).UpdateRole(ctx, req.(*UpdateRoleRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _RoleService_DeleteRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteRoleRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(RoleServiceServer).DeleteRole(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: RoleService_DeleteRole_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RoleServiceServer).DeleteRole(ctx, req.(*DeleteRoleRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// RoleService_ServiceDesc is the grpc.ServiceDesc for RoleService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var RoleService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.RoleService", - HandlerType: (*RoleServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListRoles", - Handler: _RoleService_ListRoles_Handler, - }, - { - MethodName: "GetRole", - Handler: _RoleService_GetRole_Handler, - }, - { - MethodName: "CreateRole", - Handler: _RoleService_CreateRole_Handler, - }, - { - MethodName: "UpdateRole", - Handler: _RoleService_UpdateRole_Handler, - }, - { - MethodName: "DeleteRole", - Handler: _RoleService_DeleteRole_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "system/role.proto", -} diff --git a/api/v1/services/system/role_http.pb.go b/api/v1/services/system/role_http.pb.go deleted file mode 100644 index 4b10fbf7..00000000 --- a/api/v1/services/system/role_http.pb.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: system/role.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationRoleServiceCreateRole = "/api.v1.services.system.RoleService/CreateRole" -const OperationRoleServiceDeleteRole = "/api.v1.services.system.RoleService/DeleteRole" -const OperationRoleServiceGetRole = "/api.v1.services.system.RoleService/GetRole" -const OperationRoleServiceListRoles = "/api.v1.services.system.RoleService/ListRoles" -const OperationRoleServiceUpdateRole = "/api.v1.services.system.RoleService/UpdateRole" - -type RoleServiceHTTPServer interface { - CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) - DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) - GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) - ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) - UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) -} - -func RegisterRoleServiceHTTPServer(s *http.Server, srv RoleServiceHTTPServer) { - r := s.Route("/") - r.GET("/sys/roles", _RoleService_ListRoles0_HTTP_Handler(srv)) - r.GET("/sys/roles/{id}", _RoleService_GetRole0_HTTP_Handler(srv)) - r.POST("/sys/roles", _RoleService_CreateRole0_HTTP_Handler(srv)) - r.PUT("/sys/roles/{role.id}", _RoleService_UpdateRole0_HTTP_Handler(srv)) - r.DELETE("/sys/roles/{id}", _RoleService_DeleteRole0_HTTP_Handler(srv)) -} - -func _RoleService_ListRoles0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListRolesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationRoleServiceListRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListRoles(ctx, req.(*ListRolesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListRolesResponse) - return ctx.Result(200, reply) - } -} - -func _RoleService_GetRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetRoleRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationRoleServiceGetRole) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetRole(ctx, req.(*GetRoleRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetRoleResponse) - return ctx.Result(200, reply) - } -} - -func _RoleService_CreateRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateRoleRequest - if err := ctx.Bind(&in.Role); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationRoleServiceCreateRole) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateRole(ctx, req.(*CreateRoleRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreateRoleResponse) - return ctx.Result(200, reply) - } -} - -func _RoleService_UpdateRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateRoleRequest - if err := ctx.Bind(&in.Role); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationRoleServiceUpdateRole) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateRole(ctx, req.(*UpdateRoleRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateRoleResponse) - return ctx.Result(200, reply) - } -} - -func _RoleService_DeleteRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteRoleRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationRoleServiceDeleteRole) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteRole(ctx, req.(*DeleteRoleRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteRoleResponse) - return ctx.Result(200, reply) - } -} - -type RoleServiceHTTPClient interface { - CreateRole(ctx context.Context, req *CreateRoleRequest, opts ...http.CallOption) (rsp *CreateRoleResponse, err error) - DeleteRole(ctx context.Context, req *DeleteRoleRequest, opts ...http.CallOption) (rsp *DeleteRoleResponse, err error) - GetRole(ctx context.Context, req *GetRoleRequest, opts ...http.CallOption) (rsp *GetRoleResponse, err error) - ListRoles(ctx context.Context, req *ListRolesRequest, opts ...http.CallOption) (rsp *ListRolesResponse, err error) - UpdateRole(ctx context.Context, req *UpdateRoleRequest, opts ...http.CallOption) (rsp *UpdateRoleResponse, err error) -} - -type RoleServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewRoleServiceHTTPClient(client *http.Client) RoleServiceHTTPClient { - return &RoleServiceHTTPClientImpl{client} -} - -func (c *RoleServiceHTTPClientImpl) CreateRole(ctx context.Context, in *CreateRoleRequest, opts ...http.CallOption) (*CreateRoleResponse, error) { - var out CreateRoleResponse - pattern := "/sys/roles" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationRoleServiceCreateRole)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Role, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *RoleServiceHTTPClientImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest, opts ...http.CallOption) (*DeleteRoleResponse, error) { - var out DeleteRoleResponse - pattern := "/sys/roles/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationRoleServiceDeleteRole)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *RoleServiceHTTPClientImpl) GetRole(ctx context.Context, in *GetRoleRequest, opts ...http.CallOption) (*GetRoleResponse, error) { - var out GetRoleResponse - pattern := "/sys/roles/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationRoleServiceGetRole)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *RoleServiceHTTPClientImpl) ListRoles(ctx context.Context, in *ListRolesRequest, opts ...http.CallOption) (*ListRolesResponse, error) { - var out ListRolesResponse - pattern := "/sys/roles" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationRoleServiceListRoles)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *RoleServiceHTTPClientImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest, opts ...http.CallOption) (*UpdateRoleResponse, error) { - var out UpdateRoleResponse - pattern := "/sys/roles/{role.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationRoleServiceUpdateRole)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Role, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go deleted file mode 100644 index 09030a6b..00000000 --- a/api/v1/services/system/user.pb.go +++ /dev/null @@ -1,1196 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: system/user.proto - -package system - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ListUserResourcesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListUserResourcesRequest) Reset() { - *x = ListUserResourcesRequest{} - mi := &file_system_user_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListUserResourcesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUserResourcesRequest) ProtoMessage() {} - -func (x *ListUserResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[0] - 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 ListUserResourcesRequest.ProtoReflect.Descriptor instead. -func (*ListUserResourcesRequest) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{0} -} - -func (x *ListUserResourcesRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type ListUserResourcesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListUserResourcesResponse) Reset() { - *x = ListUserResourcesResponse{} - mi := &file_system_user_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListUserResourcesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUserResourcesResponse) ProtoMessage() {} - -func (x *ListUserResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[1] - 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 ListUserResourcesResponse.ProtoReflect.Descriptor instead. -func (*ListUserResourcesResponse) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{1} -} - -func (x *ListUserResourcesResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListUserResourcesResponse) GetResources() []*types.Resource { - if x != nil { - return x.Resources - } - return nil -} - -type UpdateUserStatusRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateUserStatusRequest) Reset() { - *x = UpdateUserStatusRequest{} - mi := &file_system_user_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateUserStatusRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateUserStatusRequest) ProtoMessage() {} - -func (x *UpdateUserStatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[2] - 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 UpdateUserStatusRequest.ProtoReflect.Descriptor instead. -func (*UpdateUserStatusRequest) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{2} -} - -func (x *UpdateUserStatusRequest) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -type UpdateUserStatusResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateUserStatusResponse) Reset() { - *x = UpdateUserStatusResponse{} - mi := &file_system_user_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateUserStatusResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateUserStatusResponse) ProtoMessage() {} - -func (x *UpdateUserStatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[3] - 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 UpdateUserStatusResponse.ProtoReflect.Descriptor instead. -func (*UpdateUserStatusResponse) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{3} -} - -type ResetUserPasswordRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ResetUserPasswordRequest) Reset() { - *x = ResetUserPasswordRequest{} - mi := &file_system_user_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ResetUserPasswordRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ResetUserPasswordRequest) ProtoMessage() {} - -func (x *ResetUserPasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[4] - 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 ResetUserPasswordRequest.ProtoReflect.Descriptor instead. -func (*ResetUserPasswordRequest) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{4} -} - -func (x *ResetUserPasswordRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *ResetUserPasswordRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type ResetUserPasswordResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ResetUserPasswordResponse) Reset() { - *x = ResetUserPasswordResponse{} - mi := &file_system_user_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ResetUserPasswordResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ResetUserPasswordResponse) ProtoMessage() {} - -func (x *ResetUserPasswordResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[5] - 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 ResetUserPasswordResponse.ProtoReflect.Descriptor instead. -func (*ResetUserPasswordResponse) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{5} -} - -type ListUsersRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - // The title query parameter for set only to query the title - Title string `protobuf:"bytes,7,opt,name=title,proto3" json:"title,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListUsersRequest) Reset() { - *x = ListUsersRequest{} - mi := &file_system_user_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListUsersRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUsersRequest) ProtoMessage() {} - -func (x *ListUsersRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_user_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 ListUsersRequest.ProtoReflect.Descriptor instead. -func (*ListUsersRequest) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{6} -} - -func (x *ListUsersRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListUsersRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListUsersRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListUsersRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListUsersRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListUsersRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -func (x *ListUsersRequest) GetTitle() string { - if x != nil { - return x.Title - } - return "" -} - -type ListUsersResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` - // The paging menus - Users []*types.User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the current data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListUsersResponse) Reset() { - *x = ListUsersResponse{} - mi := &file_system_user_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListUsersResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListUsersResponse) ProtoMessage() {} - -func (x *ListUsersResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ListUsersResponse.ProtoReflect.Descriptor instead. -func (*ListUsersResponse) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{7} -} - -func (x *ListUsersResponse) GetTotalSize() int32 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListUsersResponse) GetUsers() []*types.User { - if x != nil { - return x.Users - } - return nil -} - -func (x *ListUsersResponse) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListUsersResponse) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListUsersResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -func (x *ListUsersResponse) GetExtra() *anypb.Any { - if x != nil { - return x.Extra - } - return nil -} - -type GetUserRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/users/user2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetUserRequest) Reset() { - *x = GetUserRequest{} - mi := &file_system_user_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetUserRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetUserRequest) ProtoMessage() {} - -func (x *GetUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[8] - 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 GetUserRequest.ProtoReflect.Descriptor instead. -func (*GetUserRequest) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{8} -} - -func (x *GetUserRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type GetUserResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetUserResponse) Reset() { - *x = GetUserResponse{} - mi := &file_system_user_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetUserResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetUserResponse) ProtoMessage() {} - -func (x *GetUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[9] - 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 GetUserResponse.ProtoReflect.Descriptor instead. -func (*GetUserResponse) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{9} -} - -func (x *GetUserResponse) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -type CreateUserRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id where the user is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The user resource to be created. - User *types.User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` - // The user id to use for this user. - UserId string `protobuf:"bytes,3,opt,name=user_id,proto3" json:"user_id,omitempty"` - // The user is_system to use for this user. - IsSystem bool `protobuf:"varint,4,opt,name=is_system,proto3" json:"is_system,omitempty"` - // The random_password is the query parameter for set only to generate a random password - RandomPassword bool `protobuf:"varint,5,opt,name=random_password,proto3" json:"random_password,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateUserRequest) Reset() { - *x = CreateUserRequest{} - mi := &file_system_user_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateUserRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateUserRequest) ProtoMessage() {} - -func (x *CreateUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[10] - 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 CreateUserRequest.ProtoReflect.Descriptor instead. -func (*CreateUserRequest) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{10} -} - -func (x *CreateUserRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreateUserRequest) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -func (x *CreateUserRequest) GetUserId() string { - if x != nil { - return x.UserId - } - return "" -} - -func (x *CreateUserRequest) GetIsSystem() bool { - if x != nil { - return x.IsSystem - } - return false -} - -func (x *CreateUserRequest) GetRandomPassword() bool { - if x != nil { - return x.RandomPassword - } - return false -} - -type CreateUserResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateUserResponse) Reset() { - *x = CreateUserResponse{} - mi := &file_system_user_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateUserResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateUserResponse) ProtoMessage() {} - -func (x *CreateUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[11] - 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 CreateUserResponse.ProtoReflect.Descriptor instead. -func (*CreateUserResponse) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{11} -} - -func (x *CreateUserResponse) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -type UpdateUserRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The user resource which replaces the resource on the server. - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // The user id to use for this user. - UserId string `protobuf:"bytes,3,opt,name=user_id,proto3" json:"user_id,omitempty"` - // The user is_system to use for this user. - IsSystem bool `protobuf:"varint,4,opt,name=is_system,proto3" json:"is_system,omitempty"` - // The random_password is the query parameter for set only to generate a random password - RandomPassword bool `protobuf:"varint,2,opt,name=random_password,proto3" json:"random_password,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateUserRequest) Reset() { - *x = UpdateUserRequest{} - mi := &file_system_user_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateUserRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateUserRequest) ProtoMessage() {} - -func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[12] - 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 UpdateUserRequest.ProtoReflect.Descriptor instead. -func (*UpdateUserRequest) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{12} -} - -func (x *UpdateUserRequest) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -func (x *UpdateUserRequest) GetUserId() string { - if x != nil { - return x.UserId - } - return "" -} - -func (x *UpdateUserRequest) GetIsSystem() bool { - if x != nil { - return x.IsSystem - } - return false -} - -func (x *UpdateUserRequest) GetRandomPassword() bool { - if x != nil { - return x.RandomPassword - } - return false -} - -type UpdateUserResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateUserResponse) Reset() { - *x = UpdateUserResponse{} - mi := &file_system_user_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateUserResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateUserResponse) ProtoMessage() {} - -func (x *UpdateUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[13] - 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 UpdateUserResponse.ProtoReflect.Descriptor instead. -func (*UpdateUserResponse) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{13} -} - -func (x *UpdateUserResponse) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -type DeleteUserRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The resource id of the user to be deleted, for example: - // "shelves/shelf1/users/user2" - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteUserRequest) Reset() { - *x = DeleteUserRequest{} - mi := &file_system_user_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteUserRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteUserRequest) ProtoMessage() {} - -func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[14] - 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 DeleteUserRequest.ProtoReflect.Descriptor instead. -func (*DeleteUserRequest) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{14} -} - -func (x *DeleteUserRequest) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -type DeleteUserResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteUserResponse) Reset() { - *x = DeleteUserResponse{} - mi := &file_system_user_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteUserResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteUserResponse) ProtoMessage() {} - -func (x *DeleteUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[15] - 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 DeleteUserResponse.ProtoReflect.Descriptor instead. -func (*DeleteUserResponse) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{15} -} - -func (x *DeleteUserResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -type UpdateUserRolesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - User *types.User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` - RoleIds []int64 `protobuf:"varint,3,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` // bool is_add = 5 [json_name = "is_add"]; - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateUserRolesRequest) Reset() { - *x = UpdateUserRolesRequest{} - mi := &file_system_user_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateUserRolesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateUserRolesRequest) ProtoMessage() {} - -func (x *UpdateUserRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[16] - 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 UpdateUserRolesRequest.ProtoReflect.Descriptor instead. -func (*UpdateUserRolesRequest) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{16} -} - -func (x *UpdateUserRolesRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UpdateUserRolesRequest) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -func (x *UpdateUserRolesRequest) GetRoleIds() []int64 { - if x != nil { - return x.RoleIds - } - return nil -} - -type UpdateUserRolesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateUserRolesResponse) Reset() { - *x = UpdateUserRolesResponse{} - mi := &file_system_user_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateUserRolesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateUserRolesResponse) ProtoMessage() {} - -func (x *UpdateUserRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_user_proto_msgTypes[17] - 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 UpdateUserRolesResponse.ProtoReflect.Descriptor instead. -func (*UpdateUserRolesResponse) Descriptor() ([]byte, []int) { - return file_system_user_proto_rawDescGZIP(), []int{17} -} - -func (x *UpdateUserRolesResponse) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -var File_system_user_proto protoreflect.FileDescriptor - -const file_system_user_proto_rawDesc = "" + - "\n" + - "\x11system/user.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"*\n" + - "\x18ListUserResourcesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"z\n" + - "\x19ListUserResourcesResponse\x12\x1e\n" + - "\n" + - "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x12=\n" + - "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"J\n" + - "\x17UpdateUserStatusRequest\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\x1a\n" + - "\x18UpdateUserStatusResponse\"T\n" + - "\x18ResetUserPasswordRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12(\n" + - "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1b\n" + - "\x19ResetUserPasswordResponse\"\xce\x01\n" + - "\x10ListUsersRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\x12\x14\n" + - "\x05title\x18\a \x01(\tR\x05title\"\x83\x02\n" + - "\x11ListUsersResponse\x12\x1e\n" + - "\n" + - "total_size\x18\x01 \x01(\x05R\n" + - "total_size\x121\n" + - "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + - "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + - "\x06_extra\" \n" + - "\x0eGetUserRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + - "\x0fGetUserResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\xbe\x01\n" + - "\x11CreateUserRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12/\n" + - "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x18\n" + - "\auser_id\x18\x03 \x01(\tR\auser_id\x12\x1c\n" + - "\tis_system\x18\x04 \x01(\bR\tis_system\x12(\n" + - "\x0frandom_password\x18\x05 \x01(\bR\x0frandom_password\"E\n" + - "\x12CreateUserResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\xa6\x01\n" + - "\x11UpdateUserRequest\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x18\n" + - "\auser_id\x18\x03 \x01(\tR\auser_id\x12\x1c\n" + - "\tis_system\x18\x04 \x01(\bR\tis_system\x12(\n" + - "\x0frandom_password\x18\x02 \x01(\bR\x0frandom_password\"E\n" + - "\x12UpdateUserResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"D\n" + - "\x11DeleteUserRequest\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"B\n" + - "\x12DeleteUserResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"u\n" + - "\x16UpdateUserRolesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12/\n" + - "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x1a\n" + - "\brole_ids\x18\x03 \x03(\x03R\brole_ids\"J\n" + - "\x17UpdateUserRolesResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\x8e\n" + - "\n" + - "\vUserService\x12t\n" + - "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + - "/sys/users\x12\x9b\x01\n" + - "\x11ListUserResources\x120.api.v1.services.system.ListUserResourcesRequest\x1a1.api.v1.services.system.ListUserResourcesResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/sys/users/{id}/resources\x12s\n" + - "\aGetUser\x12&.api.v1.services.system.GetUserRequest\x1a'.api.v1.services.system.GetUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/users/{id}\x12}\n" + - "\n" + - "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a*.api.v1.services.system.CreateUserResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04user\"\n" + - "/sys/users\x12\x87\x01\n" + - "\n" + - "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04user\x1a\x14/sys/users/{user.id}\x12\x81\x01\n" + - "\n" + - "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x1c\x82\xd3\xe4\x93\x02\x16*\x14/sys/users/{user.id}\x12\xa0\x01\n" + - "\x10UpdateUserStatus\x12/.api.v1.services.system.UpdateUserStatusRequest\x1a0.api.v1.services.system.UpdateUserStatusResponse\")\x82\xd3\xe4\x93\x02#:\x04user\x1a\x1b/sys/users/{user.id}/status\x12\x9c\x01\n" + - "\x0fUpdateUserRoles\x12..api.v1.services.system.UpdateUserRolesRequest\x1a/.api.v1.services.system.UpdateUserRolesResponse\"(\x82\xd3\xe4\x93\x02\":\x04user\x1a\x1a/sys/users/{user.id}/roles\x12\xa6\x01\n" + - "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\",\x82\xd3\xe4\x93\x02&:\x04data\"\x1e/sys/users/{id}/password/resetB\xde\x01\n" + - "\x1acom.api.v1.services.systemB\tUserProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_user_proto_rawDescOnce sync.Once - file_system_user_proto_rawDescData []byte -) - -func file_system_user_proto_rawDescGZIP() []byte { - file_system_user_proto_rawDescOnce.Do(func() { - file_system_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_user_proto_rawDesc), len(file_system_user_proto_rawDesc))) - }) - return file_system_user_proto_rawDescData -} - -var file_system_user_proto_msgTypes = make([]protoimpl.MessageInfo, 18) -var file_system_user_proto_goTypes = []any{ - (*ListUserResourcesRequest)(nil), // 0: api.v1.services.system.ListUserResourcesRequest - (*ListUserResourcesResponse)(nil), // 1: api.v1.services.system.ListUserResourcesResponse - (*UpdateUserStatusRequest)(nil), // 2: api.v1.services.system.UpdateUserStatusRequest - (*UpdateUserStatusResponse)(nil), // 3: api.v1.services.system.UpdateUserStatusResponse - (*ResetUserPasswordRequest)(nil), // 4: api.v1.services.system.ResetUserPasswordRequest - (*ResetUserPasswordResponse)(nil), // 5: api.v1.services.system.ResetUserPasswordResponse - (*ListUsersRequest)(nil), // 6: api.v1.services.system.ListUsersRequest - (*ListUsersResponse)(nil), // 7: api.v1.services.system.ListUsersResponse - (*GetUserRequest)(nil), // 8: api.v1.services.system.GetUserRequest - (*GetUserResponse)(nil), // 9: api.v1.services.system.GetUserResponse - (*CreateUserRequest)(nil), // 10: api.v1.services.system.CreateUserRequest - (*CreateUserResponse)(nil), // 11: api.v1.services.system.CreateUserResponse - (*UpdateUserRequest)(nil), // 12: api.v1.services.system.UpdateUserRequest - (*UpdateUserResponse)(nil), // 13: api.v1.services.system.UpdateUserResponse - (*DeleteUserRequest)(nil), // 14: api.v1.services.system.DeleteUserRequest - (*DeleteUserResponse)(nil), // 15: api.v1.services.system.DeleteUserResponse - (*UpdateUserRolesRequest)(nil), // 16: api.v1.services.system.UpdateUserRolesRequest - (*UpdateUserRolesResponse)(nil), // 17: api.v1.services.system.UpdateUserRolesResponse - (*types.Resource)(nil), // 18: api.v1.services.types.Resource - (*types.User)(nil), // 19: api.v1.services.types.User - (*anypb.Any)(nil), // 20: google.protobuf.Any - (*emptypb.Empty)(nil), // 21: google.protobuf.Empty -} -var file_system_user_proto_depIdxs = []int32{ - 18, // 0: api.v1.services.system.ListUserResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 19, // 1: api.v1.services.system.UpdateUserStatusRequest.user:type_name -> api.v1.services.types.User - 20, // 2: api.v1.services.system.ResetUserPasswordRequest.data:type_name -> google.protobuf.Any - 19, // 3: api.v1.services.system.ListUsersResponse.users:type_name -> api.v1.services.types.User - 20, // 4: api.v1.services.system.ListUsersResponse.extra:type_name -> google.protobuf.Any - 19, // 5: api.v1.services.system.GetUserResponse.user:type_name -> api.v1.services.types.User - 19, // 6: api.v1.services.system.CreateUserRequest.user:type_name -> api.v1.services.types.User - 19, // 7: api.v1.services.system.CreateUserResponse.user:type_name -> api.v1.services.types.User - 19, // 8: api.v1.services.system.UpdateUserRequest.user:type_name -> api.v1.services.types.User - 19, // 9: api.v1.services.system.UpdateUserResponse.user:type_name -> api.v1.services.types.User - 19, // 10: api.v1.services.system.DeleteUserRequest.user:type_name -> api.v1.services.types.User - 21, // 11: api.v1.services.system.DeleteUserResponse.empty:type_name -> google.protobuf.Empty - 19, // 12: api.v1.services.system.UpdateUserRolesRequest.user:type_name -> api.v1.services.types.User - 19, // 13: api.v1.services.system.UpdateUserRolesResponse.user:type_name -> api.v1.services.types.User - 6, // 14: api.v1.services.system.UserService.ListUsers:input_type -> api.v1.services.system.ListUsersRequest - 0, // 15: api.v1.services.system.UserService.ListUserResources:input_type -> api.v1.services.system.ListUserResourcesRequest - 8, // 16: api.v1.services.system.UserService.GetUser:input_type -> api.v1.services.system.GetUserRequest - 10, // 17: api.v1.services.system.UserService.CreateUser:input_type -> api.v1.services.system.CreateUserRequest - 12, // 18: api.v1.services.system.UserService.UpdateUser:input_type -> api.v1.services.system.UpdateUserRequest - 14, // 19: api.v1.services.system.UserService.DeleteUser:input_type -> api.v1.services.system.DeleteUserRequest - 2, // 20: api.v1.services.system.UserService.UpdateUserStatus:input_type -> api.v1.services.system.UpdateUserStatusRequest - 16, // 21: api.v1.services.system.UserService.UpdateUserRoles:input_type -> api.v1.services.system.UpdateUserRolesRequest - 4, // 22: api.v1.services.system.UserService.ResetUserPassword:input_type -> api.v1.services.system.ResetUserPasswordRequest - 7, // 23: api.v1.services.system.UserService.ListUsers:output_type -> api.v1.services.system.ListUsersResponse - 1, // 24: api.v1.services.system.UserService.ListUserResources:output_type -> api.v1.services.system.ListUserResourcesResponse - 9, // 25: api.v1.services.system.UserService.GetUser:output_type -> api.v1.services.system.GetUserResponse - 11, // 26: api.v1.services.system.UserService.CreateUser:output_type -> api.v1.services.system.CreateUserResponse - 13, // 27: api.v1.services.system.UserService.UpdateUser:output_type -> api.v1.services.system.UpdateUserResponse - 15, // 28: api.v1.services.system.UserService.DeleteUser:output_type -> api.v1.services.system.DeleteUserResponse - 3, // 29: api.v1.services.system.UserService.UpdateUserStatus:output_type -> api.v1.services.system.UpdateUserStatusResponse - 17, // 30: api.v1.services.system.UserService.UpdateUserRoles:output_type -> api.v1.services.system.UpdateUserRolesResponse - 5, // 31: api.v1.services.system.UserService.ResetUserPassword:output_type -> api.v1.services.system.ResetUserPasswordResponse - 23, // [23:32] is the sub-list for method output_type - 14, // [14:23] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name -} - -func init() { file_system_user_proto_init() } -func file_system_user_proto_init() { - if File_system_user_proto != nil { - return - } - file_system_user_proto_msgTypes[7].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_user_proto_rawDesc), len(file_system_user_proto_rawDesc)), - NumEnums: 0, - NumMessages: 18, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_system_user_proto_goTypes, - DependencyIndexes: file_system_user_proto_depIdxs, - MessageInfos: file_system_user_proto_msgTypes, - }.Build() - File_system_user_proto = out.File - file_system_user_proto_goTypes = nil - file_system_user_proto_depIdxs = nil -} diff --git a/api/v1/services/system/user.pb.gw.go b/api/v1/services/system/user.pb.gw.go deleted file mode 100644 index 6958ef75..00000000 --- a/api/v1/services/system/user.pb.gw.go +++ /dev/null @@ -1,834 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/user.proto - -/* -Package system is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package system - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_UserService_ListUsers_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_UserService_ListUsers_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListUsersRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_ListUsers_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListUsers(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UserService_ListUsers_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListUsersRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_ListUsers_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListUsers(ctx, &protoReq) - return msg, metadata, err -} - -func request_UserService_ListUserResources_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListUserResourcesRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.ListUserResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UserService_ListUserResources_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListUserResourcesRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.ListUserResources(ctx, &protoReq) - return msg, metadata, err -} - -func request_UserService_GetUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetUserRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UserService_GetUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetUserRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetUser(ctx, &protoReq) - return msg, metadata, err -} - -var filter_UserService_CreateUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - -func request_UserService_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateUserRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_CreateUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreateUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UserService_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateUserRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_CreateUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreateUser(ctx, &protoReq) - return msg, metadata, err -} - -var filter_UserService_UpdateUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - -func request_UserService_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateUserRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["user.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdateUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UserService_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateUserRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["user.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdateUser(ctx, &protoReq) - return msg, metadata, err -} - -var filter_UserService_DeleteUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} - -func request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteUserRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["user.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_DeleteUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.DeleteUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteUserRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["user.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_DeleteUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.DeleteUser(ctx, &protoReq) - return msg, metadata, err -} - -func request_UserService_UpdateUserStatus_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateUserStatusRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["user.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - msg, err := client.UpdateUserStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UserService_UpdateUserStatus_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateUserStatusRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["user.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - msg, err := server.UpdateUserStatus(ctx, &protoReq) - return msg, metadata, err -} - -var filter_UserService_UpdateUserRoles_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - -func request_UserService_UpdateUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateUserRolesRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["user.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUserRoles_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdateUserRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UserService_UpdateUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateUserRolesRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["user.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUserRoles_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdateUserRoles(ctx, &protoReq) - return msg, metadata, err -} - -func request_UserService_ResetUserPassword_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ResetUserPasswordRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.ResetUserPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_UserService_ResetUserPassword_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ResetUserPasswordRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.String(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.ResetUserPassword(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterUserServiceHandlerServer registers the http handlers for service UserService to "mux". -// UnaryRPC :call UserServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUserServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceServer) error { - mux.Handle(http.MethodGet, pattern_UserService_ListUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/ListUsers", runtime.WithHTTPPathPattern("/sys/users")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_ListUsers_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_ListUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_UserService_ListUserResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/ListUserResources", runtime.WithHTTPPathPattern("/sys/users/{id}/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_ListUserResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_ListUserResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_UserService_GetUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/GetUser", runtime.WithHTTPPathPattern("/sys/users/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_GetUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_GetUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_UserService_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/CreateUser", runtime.WithHTTPPathPattern("/sys/users")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_CreateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUser", runtime.WithHTTPPathPattern("/sys/users/{user.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_UpdateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_UserService_DeleteUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/DeleteUser", runtime.WithHTTPPathPattern("/sys/users/{user.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_DeleteUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_DeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_UserService_UpdateUserStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserStatus", runtime.WithHTTPPathPattern("/sys/users/{user.id}/status")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_UpdateUserStatus_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_UpdateUserStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_UserService_UpdateUserRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserRoles", runtime.WithHTTPPathPattern("/sys/users/{user.id}/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_UpdateUserRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_UpdateUserRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_UserService_ResetUserPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/ResetUserPassword", runtime.WithHTTPPathPattern("/sys/users/{id}/password/reset")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_UserService_ResetUserPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_ResetUserPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterUserServiceHandlerFromEndpoint is same as RegisterUserServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterUserServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterUserServiceHandler(ctx, mux, conn) -} - -// RegisterUserServiceHandler registers the http handlers for service UserService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterUserServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterUserServiceHandlerClient(ctx, mux, NewUserServiceClient(conn)) -} - -// RegisterUserServiceHandlerClient registers the http handlers for service UserService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "UserServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserServiceClient) error { - mux.Handle(http.MethodGet, pattern_UserService_ListUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/ListUsers", runtime.WithHTTPPathPattern("/sys/users")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_ListUsers_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_ListUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_UserService_ListUserResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/ListUserResources", runtime.WithHTTPPathPattern("/sys/users/{id}/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_ListUserResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_ListUserResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_UserService_GetUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/GetUser", runtime.WithHTTPPathPattern("/sys/users/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_GetUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_GetUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_UserService_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/CreateUser", runtime.WithHTTPPathPattern("/sys/users")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_CreateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUser", runtime.WithHTTPPathPattern("/sys/users/{user.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_UpdateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_UserService_DeleteUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/DeleteUser", runtime.WithHTTPPathPattern("/sys/users/{user.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_DeleteUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_DeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_UserService_UpdateUserStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserStatus", runtime.WithHTTPPathPattern("/sys/users/{user.id}/status")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_UpdateUserStatus_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_UpdateUserStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_UserService_UpdateUserRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserRoles", runtime.WithHTTPPathPattern("/sys/users/{user.id}/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_UpdateUserRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_UpdateUserRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_UserService_ResetUserPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/ResetUserPassword", runtime.WithHTTPPathPattern("/sys/users/{id}/password/reset")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_UserService_ResetUserPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_UserService_ResetUserPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_UserService_ListUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "users"}, "")) - pattern_UserService_ListUserResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"sys", "users", "id", "resources"}, "")) - pattern_UserService_GetUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "users", "id"}, "")) - pattern_UserService_CreateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "users"}, "")) - pattern_UserService_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "users", "user.id"}, "")) - pattern_UserService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "users", "user.id"}, "")) - pattern_UserService_UpdateUserStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"sys", "users", "user.id", "status"}, "")) - pattern_UserService_UpdateUserRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"sys", "users", "user.id", "roles"}, "")) - pattern_UserService_ResetUserPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4}, []string{"sys", "users", "id", "password", "reset"}, "")) -) - -var ( - forward_UserService_ListUsers_0 = runtime.ForwardResponseMessage - forward_UserService_ListUserResources_0 = runtime.ForwardResponseMessage - forward_UserService_GetUser_0 = runtime.ForwardResponseMessage - forward_UserService_CreateUser_0 = runtime.ForwardResponseMessage - forward_UserService_UpdateUser_0 = runtime.ForwardResponseMessage - forward_UserService_DeleteUser_0 = runtime.ForwardResponseMessage - forward_UserService_UpdateUserStatus_0 = runtime.ForwardResponseMessage - forward_UserService_UpdateUserRoles_0 = runtime.ForwardResponseMessage - forward_UserService_ResetUserPassword_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/system/user.pb.validate.go b/api/v1/services/system/user.pb.validate.go deleted file mode 100644 index b9c2345d..00000000 --- a/api/v1/services/system/user.pb.validate.go +++ /dev/null @@ -1,2332 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/user.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListUserResourcesRequest 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 *ListUserResourcesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListUserResourcesRequest 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 -// ListUserResourcesRequestMultiError, or nil if none found. -func (m *ListUserResourcesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListUserResourcesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return ListUserResourcesRequestMultiError(errors) - } - - return nil -} - -// ListUserResourcesRequestMultiError is an error wrapping multiple validation -// errors returned by ListUserResourcesRequest.ValidateAll() if the designated -// constraints aren't met. -type ListUserResourcesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListUserResourcesRequestMultiError) 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 ListUserResourcesRequestMultiError) AllErrors() []error { return m } - -// ListUserResourcesRequestValidationError is the validation error returned by -// ListUserResourcesRequest.Validate if the designated constraints aren't met. -type ListUserResourcesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListUserResourcesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListUserResourcesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListUserResourcesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListUserResourcesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListUserResourcesRequestValidationError) ErrorName() string { - return "ListUserResourcesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListUserResourcesRequestValidationError) 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 %sListUserResourcesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListUserResourcesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListUserResourcesRequestValidationError{} - -// Validate checks the field values on ListUserResourcesResponse 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 *ListUserResourcesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListUserResourcesResponse 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 -// ListUserResourcesResponseMultiError, or nil if none found. -func (m *ListUserResourcesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListUserResourcesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListUserResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListUserResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListUserResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListUserResourcesResponseMultiError(errors) - } - - return nil -} - -// ListUserResourcesResponseMultiError is an error wrapping multiple validation -// errors returned by ListUserResourcesResponse.ValidateAll() if the -// designated constraints aren't met. -type ListUserResourcesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListUserResourcesResponseMultiError) 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 ListUserResourcesResponseMultiError) AllErrors() []error { return m } - -// ListUserResourcesResponseValidationError is the validation error returned by -// ListUserResourcesResponse.Validate if the designated constraints aren't met. -type ListUserResourcesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListUserResourcesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListUserResourcesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListUserResourcesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListUserResourcesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListUserResourcesResponseValidationError) ErrorName() string { - return "ListUserResourcesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListUserResourcesResponseValidationError) 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 %sListUserResourcesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListUserResourcesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListUserResourcesResponseValidationError{} - -// Validate checks the field values on UpdateUserStatusRequest 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 *UpdateUserStatusRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateUserStatusRequest 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 -// UpdateUserStatusRequestMultiError, or nil if none found. -func (m *UpdateUserStatusRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateUserStatusRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateUserStatusRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateUserStatusRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateUserStatusRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateUserStatusRequestMultiError(errors) - } - - return nil -} - -// UpdateUserStatusRequestMultiError is an error wrapping multiple validation -// errors returned by UpdateUserStatusRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateUserStatusRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateUserStatusRequestMultiError) 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 UpdateUserStatusRequestMultiError) AllErrors() []error { return m } - -// UpdateUserStatusRequestValidationError is the validation error returned by -// UpdateUserStatusRequest.Validate if the designated constraints aren't met. -type UpdateUserStatusRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateUserStatusRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateUserStatusRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateUserStatusRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateUserStatusRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateUserStatusRequestValidationError) ErrorName() string { - return "UpdateUserStatusRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateUserStatusRequestValidationError) 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 %sUpdateUserStatusRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateUserStatusRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateUserStatusRequestValidationError{} - -// Validate checks the field values on UpdateUserStatusResponse 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 *UpdateUserStatusResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateUserStatusResponse 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 -// UpdateUserStatusResponseMultiError, or nil if none found. -func (m *UpdateUserStatusResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateUserStatusResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdateUserStatusResponseMultiError(errors) - } - - return nil -} - -// UpdateUserStatusResponseMultiError is an error wrapping multiple validation -// errors returned by UpdateUserStatusResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateUserStatusResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateUserStatusResponseMultiError) 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 UpdateUserStatusResponseMultiError) AllErrors() []error { return m } - -// UpdateUserStatusResponseValidationError is the validation error returned by -// UpdateUserStatusResponse.Validate if the designated constraints aren't met. -type UpdateUserStatusResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateUserStatusResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateUserStatusResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateUserStatusResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateUserStatusResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateUserStatusResponseValidationError) ErrorName() string { - return "UpdateUserStatusResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateUserStatusResponseValidationError) 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 %sUpdateUserStatusResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateUserStatusResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateUserStatusResponseValidationError{} - -// Validate checks the field values on ResetUserPasswordRequest 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 *ResetUserPasswordRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ResetUserPasswordRequest 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 -// ResetUserPasswordRequestMultiError, or nil if none found. -func (m *ResetUserPasswordRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ResetUserPasswordRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResetUserPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResetUserPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResetUserPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ResetUserPasswordRequestMultiError(errors) - } - - return nil -} - -// ResetUserPasswordRequestMultiError is an error wrapping multiple validation -// errors returned by ResetUserPasswordRequest.ValidateAll() if the designated -// constraints aren't met. -type ResetUserPasswordRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResetUserPasswordRequestMultiError) 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 ResetUserPasswordRequestMultiError) AllErrors() []error { return m } - -// ResetUserPasswordRequestValidationError is the validation error returned by -// ResetUserPasswordRequest.Validate if the designated constraints aren't met. -type ResetUserPasswordRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResetUserPasswordRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResetUserPasswordRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResetUserPasswordRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResetUserPasswordRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResetUserPasswordRequestValidationError) ErrorName() string { - return "ResetUserPasswordRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ResetUserPasswordRequestValidationError) 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 %sResetUserPasswordRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResetUserPasswordRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResetUserPasswordRequestValidationError{} - -// Validate checks the field values on ResetUserPasswordResponse 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 *ResetUserPasswordResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ResetUserPasswordResponse 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 -// ResetUserPasswordResponseMultiError, or nil if none found. -func (m *ResetUserPasswordResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ResetUserPasswordResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return ResetUserPasswordResponseMultiError(errors) - } - - return nil -} - -// ResetUserPasswordResponseMultiError is an error wrapping multiple validation -// errors returned by ResetUserPasswordResponse.ValidateAll() if the -// designated constraints aren't met. -type ResetUserPasswordResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResetUserPasswordResponseMultiError) 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 ResetUserPasswordResponseMultiError) AllErrors() []error { return m } - -// ResetUserPasswordResponseValidationError is the validation error returned by -// ResetUserPasswordResponse.Validate if the designated constraints aren't met. -type ResetUserPasswordResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResetUserPasswordResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResetUserPasswordResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResetUserPasswordResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResetUserPasswordResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResetUserPasswordResponseValidationError) ErrorName() string { - return "ResetUserPasswordResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ResetUserPasswordResponseValidationError) 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 %sResetUserPasswordResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResetUserPasswordResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResetUserPasswordResponseValidationError{} - -// Validate checks the field values on ListUsersRequest 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 *ListUsersRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListUsersRequest 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 -// ListUsersRequestMultiError, or nil if none found. -func (m *ListUsersRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListUsersRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - // no validation rules for Title - - if len(errors) > 0 { - return ListUsersRequestMultiError(errors) - } - - return nil -} - -// ListUsersRequestMultiError is an error wrapping multiple validation errors -// returned by ListUsersRequest.ValidateAll() if the designated constraints -// aren't met. -type ListUsersRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListUsersRequestMultiError) 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 ListUsersRequestMultiError) AllErrors() []error { return m } - -// ListUsersRequestValidationError is the validation error returned by -// ListUsersRequest.Validate if the designated constraints aren't met. -type ListUsersRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListUsersRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListUsersRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListUsersRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListUsersRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListUsersRequestValidationError) ErrorName() string { return "ListUsersRequestValidationError" } - -// Error satisfies the builtin error interface -func (e ListUsersRequestValidationError) 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 %sListUsersRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListUsersRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListUsersRequestValidationError{} - -// Validate checks the field values on ListUsersResponse 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 *ListUsersResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListUsersResponse 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 -// ListUsersResponseMultiError, or nil if none found. -func (m *ListUsersResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListUsersResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListUsersResponseValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListUsersResponseValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListUsersResponseValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for NextPageToken - - if m.Extra != nil { - - if all { - switch v := interface{}(m.GetExtra()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListUsersResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListUsersResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListUsersResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListUsersResponseMultiError(errors) - } - - return nil -} - -// ListUsersResponseMultiError is an error wrapping multiple validation errors -// returned by ListUsersResponse.ValidateAll() if the designated constraints -// aren't met. -type ListUsersResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListUsersResponseMultiError) 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 ListUsersResponseMultiError) AllErrors() []error { return m } - -// ListUsersResponseValidationError is the validation error returned by -// ListUsersResponse.Validate if the designated constraints aren't met. -type ListUsersResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListUsersResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListUsersResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListUsersResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListUsersResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListUsersResponseValidationError) ErrorName() string { - return "ListUsersResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListUsersResponseValidationError) 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 %sListUsersResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListUsersResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListUsersResponseValidationError{} - -// Validate checks the field values on GetUserRequest 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 *GetUserRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetUserRequest 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 GetUserRequestMultiError, -// or nil if none found. -func (m *GetUserRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetUserRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return GetUserRequestMultiError(errors) - } - - return nil -} - -// GetUserRequestMultiError is an error wrapping multiple validation errors -// returned by GetUserRequest.ValidateAll() if the designated constraints -// aren't met. -type GetUserRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetUserRequestMultiError) 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 GetUserRequestMultiError) AllErrors() []error { return m } - -// GetUserRequestValidationError is the validation error returned by -// GetUserRequest.Validate if the designated constraints aren't met. -type GetUserRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetUserRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetUserRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetUserRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetUserRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetUserRequestValidationError) ErrorName() string { return "GetUserRequestValidationError" } - -// Error satisfies the builtin error interface -func (e GetUserRequestValidationError) 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 %sGetUserRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetUserRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetUserRequestValidationError{} - -// Validate checks the field values on GetUserResponse 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 *GetUserResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetUserResponse 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 -// GetUserResponseMultiError, or nil if none found. -func (m *GetUserResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetUserResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetUserResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetUserResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetUserResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetUserResponseMultiError(errors) - } - - return nil -} - -// GetUserResponseMultiError is an error wrapping multiple validation errors -// returned by GetUserResponse.ValidateAll() if the designated constraints -// aren't met. -type GetUserResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetUserResponseMultiError) 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 GetUserResponseMultiError) AllErrors() []error { return m } - -// GetUserResponseValidationError is the validation error returned by -// GetUserResponse.Validate if the designated constraints aren't met. -type GetUserResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetUserResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetUserResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetUserResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetUserResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetUserResponseValidationError) ErrorName() string { return "GetUserResponseValidationError" } - -// Error satisfies the builtin error interface -func (e GetUserResponseValidationError) 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 %sGetUserResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetUserResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetUserResponseValidationError{} - -// Validate checks the field values on CreateUserRequest 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 *CreateUserRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateUserRequest 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 -// CreateUserRequestMultiError, or nil if none found. -func (m *CreateUserRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateUserRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Parent - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for UserId - - // no validation rules for IsSystem - - // no validation rules for RandomPassword - - if len(errors) > 0 { - return CreateUserRequestMultiError(errors) - } - - return nil -} - -// CreateUserRequestMultiError is an error wrapping multiple validation errors -// returned by CreateUserRequest.ValidateAll() if the designated constraints -// aren't met. -type CreateUserRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateUserRequestMultiError) 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 CreateUserRequestMultiError) AllErrors() []error { return m } - -// CreateUserRequestValidationError is the validation error returned by -// CreateUserRequest.Validate if the designated constraints aren't met. -type CreateUserRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateUserRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateUserRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateUserRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateUserRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateUserRequestValidationError) ErrorName() string { - return "CreateUserRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateUserRequestValidationError) 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 %sCreateUserRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateUserRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateUserRequestValidationError{} - -// Validate checks the field values on CreateUserResponse 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 *CreateUserResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateUserResponse 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 -// CreateUserResponseMultiError, or nil if none found. -func (m *CreateUserResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateUserResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateUserResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateUserResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateUserResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateUserResponseMultiError(errors) - } - - return nil -} - -// CreateUserResponseMultiError is an error wrapping multiple validation errors -// returned by CreateUserResponse.ValidateAll() if the designated constraints -// aren't met. -type CreateUserResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateUserResponseMultiError) 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 CreateUserResponseMultiError) AllErrors() []error { return m } - -// CreateUserResponseValidationError is the validation error returned by -// CreateUserResponse.Validate if the designated constraints aren't met. -type CreateUserResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateUserResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateUserResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateUserResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateUserResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateUserResponseValidationError) ErrorName() string { - return "CreateUserResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateUserResponseValidationError) 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 %sCreateUserResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateUserResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateUserResponseValidationError{} - -// Validate checks the field values on UpdateUserRequest 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 *UpdateUserRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateUserRequest 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 -// UpdateUserRequestMultiError, or nil if none found. -func (m *UpdateUserRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateUserRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for UserId - - // no validation rules for IsSystem - - // no validation rules for RandomPassword - - if len(errors) > 0 { - return UpdateUserRequestMultiError(errors) - } - - return nil -} - -// UpdateUserRequestMultiError is an error wrapping multiple validation errors -// returned by UpdateUserRequest.ValidateAll() if the designated constraints -// aren't met. -type UpdateUserRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateUserRequestMultiError) 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 UpdateUserRequestMultiError) AllErrors() []error { return m } - -// UpdateUserRequestValidationError is the validation error returned by -// UpdateUserRequest.Validate if the designated constraints aren't met. -type UpdateUserRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateUserRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateUserRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateUserRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateUserRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateUserRequestValidationError) ErrorName() string { - return "UpdateUserRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateUserRequestValidationError) 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 %sUpdateUserRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateUserRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateUserRequestValidationError{} - -// Validate checks the field values on UpdateUserResponse 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 *UpdateUserResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateUserResponse 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 -// UpdateUserResponseMultiError, or nil if none found. -func (m *UpdateUserResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateUserResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateUserResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateUserResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateUserResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateUserResponseMultiError(errors) - } - - return nil -} - -// UpdateUserResponseMultiError is an error wrapping multiple validation errors -// returned by UpdateUserResponse.ValidateAll() if the designated constraints -// aren't met. -type UpdateUserResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateUserResponseMultiError) 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 UpdateUserResponseMultiError) AllErrors() []error { return m } - -// UpdateUserResponseValidationError is the validation error returned by -// UpdateUserResponse.Validate if the designated constraints aren't met. -type UpdateUserResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateUserResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateUserResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateUserResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateUserResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateUserResponseValidationError) ErrorName() string { - return "UpdateUserResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateUserResponseValidationError) 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 %sUpdateUserResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateUserResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateUserResponseValidationError{} - -// Validate checks the field values on DeleteUserRequest 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 *DeleteUserRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteUserRequest 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 -// DeleteUserRequestMultiError, or nil if none found. -func (m *DeleteUserRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteUserRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteUserRequestMultiError(errors) - } - - return nil -} - -// DeleteUserRequestMultiError is an error wrapping multiple validation errors -// returned by DeleteUserRequest.ValidateAll() if the designated constraints -// aren't met. -type DeleteUserRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteUserRequestMultiError) 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 DeleteUserRequestMultiError) AllErrors() []error { return m } - -// DeleteUserRequestValidationError is the validation error returned by -// DeleteUserRequest.Validate if the designated constraints aren't met. -type DeleteUserRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteUserRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteUserRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteUserRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteUserRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteUserRequestValidationError) ErrorName() string { - return "DeleteUserRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteUserRequestValidationError) 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 %sDeleteUserRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteUserRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteUserRequestValidationError{} - -// Validate checks the field values on DeleteUserResponse 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 *DeleteUserResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteUserResponse 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 -// DeleteUserResponseMultiError, or nil if none found. -func (m *DeleteUserResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteUserResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteUserResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteUserResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteUserResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteUserResponseMultiError(errors) - } - - return nil -} - -// DeleteUserResponseMultiError is an error wrapping multiple validation errors -// returned by DeleteUserResponse.ValidateAll() if the designated constraints -// aren't met. -type DeleteUserResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteUserResponseMultiError) 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 DeleteUserResponseMultiError) AllErrors() []error { return m } - -// DeleteUserResponseValidationError is the validation error returned by -// DeleteUserResponse.Validate if the designated constraints aren't met. -type DeleteUserResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteUserResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteUserResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteUserResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteUserResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteUserResponseValidationError) ErrorName() string { - return "DeleteUserResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteUserResponseValidationError) 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 %sDeleteUserResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteUserResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteUserResponseValidationError{} - -// Validate checks the field values on UpdateUserRolesRequest 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 *UpdateUserRolesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateUserRolesRequest 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 -// UpdateUserRolesRequestMultiError, or nil if none found. -func (m *UpdateUserRolesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateUserRolesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateUserRolesRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateUserRolesRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateUserRolesRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateUserRolesRequestMultiError(errors) - } - - return nil -} - -// UpdateUserRolesRequestMultiError is an error wrapping multiple validation -// errors returned by UpdateUserRolesRequest.ValidateAll() if the designated -// constraints aren't met. -type UpdateUserRolesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateUserRolesRequestMultiError) 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 UpdateUserRolesRequestMultiError) AllErrors() []error { return m } - -// UpdateUserRolesRequestValidationError is the validation error returned by -// UpdateUserRolesRequest.Validate if the designated constraints aren't met. -type UpdateUserRolesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateUserRolesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateUserRolesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateUserRolesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateUserRolesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateUserRolesRequestValidationError) ErrorName() string { - return "UpdateUserRolesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateUserRolesRequestValidationError) 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 %sUpdateUserRolesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateUserRolesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateUserRolesRequestValidationError{} - -// Validate checks the field values on UpdateUserRolesResponse 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 *UpdateUserRolesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateUserRolesResponse 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 -// UpdateUserRolesResponseMultiError, or nil if none found. -func (m *UpdateUserRolesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateUserRolesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateUserRolesResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateUserRolesResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateUserRolesResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateUserRolesResponseMultiError(errors) - } - - return nil -} - -// UpdateUserRolesResponseMultiError is an error wrapping multiple validation -// errors returned by UpdateUserRolesResponse.ValidateAll() if the designated -// constraints aren't met. -type UpdateUserRolesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateUserRolesResponseMultiError) 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 UpdateUserRolesResponseMultiError) AllErrors() []error { return m } - -// UpdateUserRolesResponseValidationError is the validation error returned by -// UpdateUserRolesResponse.Validate if the designated constraints aren't met. -type UpdateUserRolesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateUserRolesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateUserRolesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateUserRolesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateUserRolesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateUserRolesResponseValidationError) ErrorName() string { - return "UpdateUserRolesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateUserRolesResponseValidationError) 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 %sUpdateUserRolesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateUserRolesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateUserRolesResponseValidationError{} diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go deleted file mode 100644 index 85075ca1..00000000 --- a/api/v1/services/system/user_bridge.pb.go +++ /dev/null @@ -1,636 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: system/user.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const UserServiceCreateUserBridgeOperation = "/api.v1.services.system.UserService/CreateUser" -const UserServiceDeleteUserBridgeOperation = "/api.v1.services.system.UserService/DeleteUser" -const UserServiceGetUserBridgeOperation = "/api.v1.services.system.UserService/GetUser" -const UserServiceListUserResourcesBridgeOperation = "/api.v1.services.system.UserService/ListUserResources" -const UserServiceListUsersBridgeOperation = "/api.v1.services.system.UserService/ListUsers" -const UserServiceResetUserPasswordBridgeOperation = "/api.v1.services.system.UserService/ResetUserPassword" -const UserServiceUpdateUserBridgeOperation = "/api.v1.services.system.UserService/UpdateUser" -const UserServiceUpdateUserRolesBridgeOperation = "/api.v1.services.system.UserService/UpdateUserRoles" -const UserServiceUpdateUserStatusBridgeOperation = "/api.v1.services.system.UserService/UpdateUserStatus" - -type UserServiceBridgeServer interface { - CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) - DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) - GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) - ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) - ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) - // ResetUserPassword reset the user s password - ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) - UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) - // UpdateUserRoles update the user roles - UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) - // UpdateUserStatus Update the status of the user information - UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) -} - -type UserServiceHooker interface { - UserServiceCreateUserHooker - UserServiceDeleteUserHooker - UserServiceGetUserHooker - UserServiceListUserResourcesHooker - UserServiceListUsersHooker - UserServiceResetUserPasswordHooker - UserServiceUpdateUserHooker - UserServiceUpdateUserRolesHooker - UserServiceUpdateUserStatusHooker -} - -type UserServiceHookedBridger interface { - UserServiceHooker - UserServiceBridgeServer -} -type UserServiceCreateUserHooker interface { - PrepareCreateUser(http.Context, *CreateUserRequest) (context.Context, error) - CompleteCreateUser(http.Context, *CreateUserRequest, *CreateUserResponse) error -} -type UserServiceDeleteUserHooker interface { - PrepareDeleteUser(http.Context, *DeleteUserRequest) (context.Context, error) - CompleteDeleteUser(http.Context, *DeleteUserRequest, *DeleteUserResponse) error -} -type UserServiceGetUserHooker interface { - PrepareGetUser(http.Context, *GetUserRequest) (context.Context, error) - CompleteGetUser(http.Context, *GetUserRequest, *GetUserResponse) error -} -type UserServiceListUserResourcesHooker interface { - PrepareListUserResources(http.Context, *ListUserResourcesRequest) (context.Context, error) - CompleteListUserResources(http.Context, *ListUserResourcesRequest, *ListUserResourcesResponse) error -} -type UserServiceListUsersHooker interface { - PrepareListUsers(http.Context, *ListUsersRequest) (context.Context, error) - CompleteListUsers(http.Context, *ListUsersRequest, *ListUsersResponse) error -} -type UserServiceResetUserPasswordHooker interface { - PrepareResetUserPassword(http.Context, *ResetUserPasswordRequest) (context.Context, error) - CompleteResetUserPassword(http.Context, *ResetUserPasswordRequest, *ResetUserPasswordResponse) error -} -type UserServiceUpdateUserHooker interface { - PrepareUpdateUser(http.Context, *UpdateUserRequest) (context.Context, error) - CompleteUpdateUser(http.Context, *UpdateUserRequest, *UpdateUserResponse) error -} -type UserServiceUpdateUserRolesHooker interface { - PrepareUpdateUserRoles(http.Context, *UpdateUserRolesRequest) (context.Context, error) - CompleteUpdateUserRoles(http.Context, *UpdateUserRolesRequest, *UpdateUserRolesResponse) error -} -type UserServiceUpdateUserStatusHooker interface { - PrepareUpdateUserStatus(http.Context, *UpdateUserStatusRequest) (context.Context, error) - CompleteUpdateUserStatus(http.Context, *UpdateUserStatusRequest, *UpdateUserStatusResponse) error -} - -func RegisterUserServiceBridgeServer(s *http.Server, srv UserServiceHookedBridger) { - r := s.Route("/") - r.GET("/sys/users", _UserService_ListUsers0_Bridge_Handler(srv)) - r.GET("/sys/users/:id/resources", _UserService_ListUserResources0_Bridge_Handler(srv)) - r.GET("/sys/users/:id", _UserService_GetUser0_Bridge_Handler(srv)) - r.POST("/sys/users", _UserService_CreateUser0_Bridge_Handler(srv)) - r.PUT("/sys/users/:user.id", _UserService_UpdateUser0_Bridge_Handler(srv)) - r.DELETE("/sys/users/:user.id", _UserService_DeleteUser0_Bridge_Handler(srv)) - r.PUT("/sys/users/:user.id/status", _UserService_UpdateUserStatus0_Bridge_Handler(srv)) - r.PUT("/sys/users/:user.id/roles", _UserService_UpdateUserRoles0_Bridge_Handler(srv)) - r.POST("/sys/users/:id/password/reset", _UserService_ResetUserPassword0_Bridge_Handler(srv)) -} - -func _UserService_ListUsers0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListUsersRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceListUsers) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListUsers(ctx, req.(*ListUsersRequest)) - }) - - newctx, err := srv.PrepareListUsers(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListUsers(ctx, &in, out.(*ListUsersResponse)) - } -} - -func _UserService_ListUserResources0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListUserResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceListUserResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListUserResources(ctx, req.(*ListUserResourcesRequest)) - }) - - newctx, err := srv.PrepareListUserResources(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListUserResources(ctx, &in, out.(*ListUserResourcesResponse)) - } -} - -func _UserService_GetUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetUserRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceGetUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetUser(ctx, req.(*GetUserRequest)) - }) - - newctx, err := srv.PrepareGetUser(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetUser(ctx, &in, out.(*GetUserResponse)) - } -} - -func _UserService_CreateUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateUserRequest - if err := ctx.Bind(&in.User); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceCreateUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateUser(ctx, req.(*CreateUserRequest)) - }) - - newctx, err := srv.PrepareCreateUser(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreateUser(ctx, &in, out.(*CreateUserResponse)) - } -} - -func _UserService_UpdateUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateUserRequest - if err := ctx.Bind(&in.User); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceUpdateUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateUser(ctx, req.(*UpdateUserRequest)) - }) - - newctx, err := srv.PrepareUpdateUser(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateUser(ctx, &in, out.(*UpdateUserResponse)) - } -} - -func _UserService_DeleteUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteUserRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceDeleteUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteUser(ctx, req.(*DeleteUserRequest)) - }) - - newctx, err := srv.PrepareDeleteUser(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeleteUser(ctx, &in, out.(*DeleteUserResponse)) - } -} - -func _UserService_UpdateUserStatus0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateUserStatusRequest - if err := ctx.Bind(&in.User); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceUpdateUserStatus) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateUserStatus(ctx, req.(*UpdateUserStatusRequest)) - }) - - newctx, err := srv.PrepareUpdateUserStatus(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateUserStatus(ctx, &in, out.(*UpdateUserStatusResponse)) - } -} - -func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateUserRolesRequest - if err := ctx.Bind(&in.User); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceUpdateUserRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateUserRoles(ctx, req.(*UpdateUserRolesRequest)) - }) - - newctx, err := srv.PrepareUpdateUserRoles(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateUserRoles(ctx, &in, out.(*UpdateUserRolesResponse)) - } -} - -func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ResetUserPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceResetUserPassword) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ResetUserPassword(ctx, req.(*ResetUserPasswordRequest)) - }) - - newctx, err := srv.PrepareResetUserPassword(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteResetUserPassword(ctx, &in, out.(*ResetUserPasswordResponse)) - } -} - -// UnimplementedUserServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedUserServiceHooked struct{} - -func (UnimplementedUserServiceHooked) PrepareCreateUser(ctx http.Context, in *CreateUserRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUserServiceHooked) CompleteCreateUser(ctx http.Context, in *CreateUserRequest, out *CreateUserResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUserServiceHooked) PrepareDeleteUser(ctx http.Context, in *DeleteUserRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUserServiceHooked) CompleteDeleteUser(ctx http.Context, in *DeleteUserRequest, out *DeleteUserResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUserServiceHooked) PrepareGetUser(ctx http.Context, in *GetUserRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUserServiceHooked) CompleteGetUser(ctx http.Context, in *GetUserRequest, out *GetUserResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUserServiceHooked) PrepareListUserResources(ctx http.Context, in *ListUserResourcesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUserServiceHooked) CompleteListUserResources(ctx http.Context, in *ListUserResourcesRequest, out *ListUserResourcesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUserServiceHooked) PrepareListUsers(ctx http.Context, in *ListUsersRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUserServiceHooked) CompleteListUsers(ctx http.Context, in *ListUsersRequest, out *ListUsersResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUserServiceHooked) PrepareResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUserServiceHooked) CompleteResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest, out *ResetUserPasswordResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUserServiceHooked) PrepareUpdateUser(ctx http.Context, in *UpdateUserRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUserServiceHooked) CompleteUpdateUser(ctx http.Context, in *UpdateUserRequest, out *UpdateUserResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUserServiceHooked) PrepareUpdateUserRoles(ctx http.Context, in *UpdateUserRolesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUserServiceHooked) CompleteUpdateUserRoles(ctx http.Context, in *UpdateUserRolesRequest, out *UpdateUserRolesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedUserServiceHooked) PrepareUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedUserServiceHooked) CompleteUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest, out *UpdateUserStatusResponse) error { - return ctx.Result(200, out) -} - -func WithUserServiceHook(h UserServiceHooker) func(UserServiceBridgeServer) UserServiceHookedBridger { - return func(srv UserServiceBridgeServer) UserServiceHookedBridger { - return UserServiceHookedBridge{UserServiceBridgeServer: srv, UserServiceHooker: h} - } -} - -// UserServiceHookedBridge is a bridge between the HTTP and gRPC implementations of UserService. -// It implements the HTTP and gRPC implementations of UserService. -// It forwards requests and responses between the two implementations. -type UserServiceHookedBridge struct { - UserServiceBridgeServer - UserServiceHooker -} - -type UserServiceHTTPBridgeImpl struct { - client UserServiceHTTPClient -} - -func NewUserServiceHTTPBridge(client *http.Client) UserServiceHTTPServer { - return &UserServiceHTTPBridgeImpl{client: NewUserServiceHTTPClient(client)} -} - -func (c *UserServiceHTTPBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { - return c.client.CreateUser(ctx, in) -} - -func (c *UserServiceHTTPBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) -} - -func (c *UserServiceHTTPBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { - return c.client.GetUser(ctx, in) -} - -func (c *UserServiceHTTPBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { - return c.client.ListUserResources(ctx, in) -} - -func (c *UserServiceHTTPBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) -} - -func (c *UserServiceHTTPBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { - return c.client.ResetUserPassword(ctx, in) -} - -func (c *UserServiceHTTPBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { - return c.client.UpdateUser(ctx, in) -} - -func (c *UserServiceHTTPBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { - return c.client.UpdateUserRoles(ctx, in) -} - -func (c *UserServiceHTTPBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { - return c.client.UpdateUserStatus(ctx, in) -} - -type UserServiceBridgeImpl struct { - client UserServiceClient -} - -func NewUserServiceBridge(client grpc.ClientConnInterface) UserServiceServer { - return &UserServiceBridgeImpl{client: NewUserServiceClient(client)} -} - -func (c *UserServiceBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { - return c.client.CreateUser(ctx, in) -} - -func (c *UserServiceBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) -} - -func (c *UserServiceBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { - return c.client.GetUser(ctx, in) -} - -func (c *UserServiceBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { - return c.client.ListUserResources(ctx, in) -} - -func (c *UserServiceBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) -} - -func (c *UserServiceBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { - return c.client.ResetUserPassword(ctx, in) -} - -func (c *UserServiceBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { - return c.client.UpdateUser(ctx, in) -} - -func (c *UserServiceBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { - return c.client.UpdateUserRoles(ctx, in) -} - -func (c *UserServiceBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { - return c.client.UpdateUserStatus(ctx, in) -} - -func (c *UserServiceBridgeImpl) mustEmbedUnimplementedUserServiceServer() {} - -type UserServiceGRPC2HTTPBridgeImpl struct { - client UserServiceClient -} - -func NewUserServiceGRPC2HTTP(client grpc.ClientConnInterface) UserServiceHTTPServer { - return &UserServiceGRPC2HTTPBridgeImpl{client: NewUserServiceClient(client)} -} - -func (c *UserServiceGRPC2HTTPBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { - return c.client.CreateUser(ctx, in) -} - -func (c *UserServiceGRPC2HTTPBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) -} - -func (c *UserServiceGRPC2HTTPBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { - return c.client.GetUser(ctx, in) -} - -func (c *UserServiceGRPC2HTTPBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { - return c.client.ListUserResources(ctx, in) -} - -func (c *UserServiceGRPC2HTTPBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) -} - -func (c *UserServiceGRPC2HTTPBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { - return c.client.ResetUserPassword(ctx, in) -} - -func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { - return c.client.UpdateUser(ctx, in) -} - -func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { - return c.client.UpdateUserRoles(ctx, in) -} - -func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { - return c.client.UpdateUserStatus(ctx, in) -} - -type UserServiceHTTP2GRPCBridgeImpl struct { - client UserServiceHTTPClient -} - -func NewUserServiceHTTP2GRPC(client *http.Client) UserServiceServer { - return &UserServiceHTTP2GRPCBridgeImpl{client: NewUserServiceHTTPClient(client)} -} - -func (c *UserServiceHTTP2GRPCBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { - return c.client.CreateUser(ctx, in) -} - -func (c *UserServiceHTTP2GRPCBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) -} - -func (c *UserServiceHTTP2GRPCBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { - return c.client.GetUser(ctx, in) -} - -func (c *UserServiceHTTP2GRPCBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { - return c.client.ListUserResources(ctx, in) -} - -func (c *UserServiceHTTP2GRPCBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) -} - -func (c *UserServiceHTTP2GRPCBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { - return c.client.ResetUserPassword(ctx, in) -} - -func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { - return c.client.UpdateUser(ctx, in) -} - -func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { - return c.client.UpdateUserRoles(ctx, in) -} - -func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { - return c.client.UpdateUserStatus(ctx, in) -} - -func (c *UserServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedUserServiceServer() {} diff --git a/api/v1/services/system/user_grpc.pb.go b/api/v1/services/system/user_grpc.pb.go deleted file mode 100644 index 042a4821..00000000 --- a/api/v1/services/system/user_grpc.pb.go +++ /dev/null @@ -1,435 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: system/user.proto - -package system - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - UserService_ListUsers_FullMethodName = "/api.v1.services.system.UserService/ListUsers" - UserService_ListUserResources_FullMethodName = "/api.v1.services.system.UserService/ListUserResources" - UserService_GetUser_FullMethodName = "/api.v1.services.system.UserService/GetUser" - UserService_CreateUser_FullMethodName = "/api.v1.services.system.UserService/CreateUser" - UserService_UpdateUser_FullMethodName = "/api.v1.services.system.UserService/UpdateUser" - UserService_DeleteUser_FullMethodName = "/api.v1.services.system.UserService/DeleteUser" - UserService_UpdateUserStatus_FullMethodName = "/api.v1.services.system.UserService/UpdateUserStatus" - UserService_UpdateUserRoles_FullMethodName = "/api.v1.services.system.UserService/UpdateUserRoles" - UserService_ResetUserPassword_FullMethodName = "/api.v1.services.system.UserService/ResetUserPassword" -) - -// UserServiceClient is the client API for UserService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The login service definition. -type UserServiceClient interface { - ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error) - ListUserResources(ctx context.Context, in *ListUserResourcesRequest, opts ...grpc.CallOption) (*ListUserResourcesResponse, error) - GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) - CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error) - UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error) - DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*DeleteUserResponse, error) - // UpdateUserStatus Update the status of the user information - UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest, opts ...grpc.CallOption) (*UpdateUserStatusResponse, error) - // UpdateUserRoles update the user roles - UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest, opts ...grpc.CallOption) (*UpdateUserRolesResponse, error) - // ResetUserPassword reset the user s password - ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest, opts ...grpc.CallOption) (*ResetUserPasswordResponse, error) -} - -type userServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient { - return &userServiceClient{cc} -} - -func (c *userServiceClient) ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListUsersResponse) - err := c.cc.Invoke(ctx, UserService_ListUsers_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) ListUserResources(ctx context.Context, in *ListUserResourcesRequest, opts ...grpc.CallOption) (*ListUserResourcesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListUserResourcesResponse) - err := c.cc.Invoke(ctx, UserService_ListUserResources_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetUserResponse) - err := c.cc.Invoke(ctx, UserService_GetUser_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateUserResponse) - err := c.cc.Invoke(ctx, UserService_CreateUser_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateUserResponse) - err := c.cc.Invoke(ctx, UserService_UpdateUser_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*DeleteUserResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeleteUserResponse) - err := c.cc.Invoke(ctx, UserService_DeleteUser_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest, opts ...grpc.CallOption) (*UpdateUserStatusResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateUserStatusResponse) - err := c.cc.Invoke(ctx, UserService_UpdateUserStatus_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest, opts ...grpc.CallOption) (*UpdateUserRolesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateUserRolesResponse) - err := c.cc.Invoke(ctx, UserService_UpdateUserRoles_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userServiceClient) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest, opts ...grpc.CallOption) (*ResetUserPasswordResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ResetUserPasswordResponse) - err := c.cc.Invoke(ctx, UserService_ResetUserPassword_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// UserServiceServer is the server API for UserService service. -// All implementations must embed UnimplementedUserServiceServer -// for forward compatibility. -// -// The login service definition. -type UserServiceServer interface { - ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) - ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) - GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) - CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) - UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) - DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) - // UpdateUserStatus Update the status of the user information - UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) - // UpdateUserRoles update the user roles - UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) - // ResetUserPassword reset the user s password - ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) - mustEmbedUnimplementedUserServiceServer() -} - -// UnimplementedUserServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedUserServiceServer struct{} - -func (UnimplementedUserServiceServer) ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListUsers not implemented") -} -func (UnimplementedUserServiceServer) ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListUserResources not implemented") -} -func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented") -} -func (UnimplementedUserServiceServer) CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateUser not implemented") -} -func (UnimplementedUserServiceServer) UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateUser not implemented") -} -func (UnimplementedUserServiceServer) DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteUser not implemented") -} -func (UnimplementedUserServiceServer) UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateUserStatus not implemented") -} -func (UnimplementedUserServiceServer) UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateUserRoles not implemented") -} -func (UnimplementedUserServiceServer) ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ResetUserPassword not implemented") -} -func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {} -func (UnimplementedUserServiceServer) testEmbeddedByValue() {} - -// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to UserServiceServer will -// result in compilation errors. -type UnsafeUserServiceServer interface { - mustEmbedUnimplementedUserServiceServer() -} - -func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) { - // If the following call pancis, it indicates UnimplementedUserServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&UserService_ServiceDesc, srv) -} - -func _UserService_ListUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListUsersRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).ListUsers(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UserService_ListUsers_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).ListUsers(ctx, req.(*ListUsersRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_ListUserResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListUserResourcesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).ListUserResources(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UserService_ListUserResources_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).ListUserResources(ctx, req.(*ListUserResourcesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetUserRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).GetUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UserService_GetUser_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).GetUser(ctx, req.(*GetUserRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateUserRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).CreateUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UserService_CreateUser_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).CreateUser(ctx, req.(*CreateUserRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateUserRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).UpdateUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UserService_UpdateUser_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).UpdateUser(ctx, req.(*UpdateUserRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteUserRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).DeleteUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UserService_DeleteUser_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).DeleteUser(ctx, req.(*DeleteUserRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_UpdateUserStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateUserStatusRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).UpdateUserStatus(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UserService_UpdateUserStatus_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).UpdateUserStatus(ctx, req.(*UpdateUserStatusRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_UpdateUserRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateUserRolesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).UpdateUserRoles(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UserService_UpdateUserRoles_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).UpdateUserRoles(ctx, req.(*UpdateUserRolesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _UserService_ResetUserPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ResetUserPasswordRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServiceServer).ResetUserPassword(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: UserService_ResetUserPassword_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServiceServer).ResetUserPassword(ctx, req.(*ResetUserPasswordRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var UserService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.UserService", - HandlerType: (*UserServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListUsers", - Handler: _UserService_ListUsers_Handler, - }, - { - MethodName: "ListUserResources", - Handler: _UserService_ListUserResources_Handler, - }, - { - MethodName: "GetUser", - Handler: _UserService_GetUser_Handler, - }, - { - MethodName: "CreateUser", - Handler: _UserService_CreateUser_Handler, - }, - { - MethodName: "UpdateUser", - Handler: _UserService_UpdateUser_Handler, - }, - { - MethodName: "DeleteUser", - Handler: _UserService_DeleteUser_Handler, - }, - { - MethodName: "UpdateUserStatus", - Handler: _UserService_UpdateUserStatus_Handler, - }, - { - MethodName: "UpdateUserRoles", - Handler: _UserService_UpdateUserRoles_Handler, - }, - { - MethodName: "ResetUserPassword", - Handler: _UserService_ResetUserPassword_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "system/user.proto", -} diff --git a/api/v1/services/system/user_http.pb.go b/api/v1/services/system/user_http.pb.go deleted file mode 100644 index 4ab1e025..00000000 --- a/api/v1/services/system/user_http.pb.go +++ /dev/null @@ -1,408 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: system/user.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationUserServiceCreateUser = "/api.v1.services.system.UserService/CreateUser" -const OperationUserServiceDeleteUser = "/api.v1.services.system.UserService/DeleteUser" -const OperationUserServiceGetUser = "/api.v1.services.system.UserService/GetUser" -const OperationUserServiceListUserResources = "/api.v1.services.system.UserService/ListUserResources" -const OperationUserServiceListUsers = "/api.v1.services.system.UserService/ListUsers" -const OperationUserServiceResetUserPassword = "/api.v1.services.system.UserService/ResetUserPassword" -const OperationUserServiceUpdateUser = "/api.v1.services.system.UserService/UpdateUser" -const OperationUserServiceUpdateUserRoles = "/api.v1.services.system.UserService/UpdateUserRoles" -const OperationUserServiceUpdateUserStatus = "/api.v1.services.system.UserService/UpdateUserStatus" - -type UserServiceHTTPServer interface { - CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) - DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) - GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) - ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) - ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) - // ResetUserPassword ResetUserPassword reset the user s password - ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) - UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) - // UpdateUserRoles UpdateUserRoles update the user roles - UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) - // UpdateUserStatus UpdateUserStatus Update the status of the user information - UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) -} - -func RegisterUserServiceHTTPServer(s *http.Server, srv UserServiceHTTPServer) { - r := s.Route("/") - r.GET("/sys/users", _UserService_ListUsers0_HTTP_Handler(srv)) - r.GET("/sys/users/{id}/resources", _UserService_ListUserResources0_HTTP_Handler(srv)) - r.GET("/sys/users/{id}", _UserService_GetUser0_HTTP_Handler(srv)) - r.POST("/sys/users", _UserService_CreateUser0_HTTP_Handler(srv)) - r.PUT("/sys/users/{user.id}", _UserService_UpdateUser0_HTTP_Handler(srv)) - r.DELETE("/sys/users/{user.id}", _UserService_DeleteUser0_HTTP_Handler(srv)) - r.PUT("/sys/users/{user.id}/status", _UserService_UpdateUserStatus0_HTTP_Handler(srv)) - r.PUT("/sys/users/{user.id}/roles", _UserService_UpdateUserRoles0_HTTP_Handler(srv)) - r.POST("/sys/users/{id}/password/reset", _UserService_ResetUserPassword0_HTTP_Handler(srv)) -} - -func _UserService_ListUsers0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListUsersRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceListUsers) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListUsers(ctx, req.(*ListUsersRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListUsersResponse) - return ctx.Result(200, reply) - } -} - -func _UserService_ListUserResources0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListUserResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceListUserResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListUserResources(ctx, req.(*ListUserResourcesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListUserResourcesResponse) - return ctx.Result(200, reply) - } -} - -func _UserService_GetUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetUserRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceGetUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetUser(ctx, req.(*GetUserRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetUserResponse) - return ctx.Result(200, reply) - } -} - -func _UserService_CreateUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateUserRequest - if err := ctx.Bind(&in.User); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceCreateUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateUser(ctx, req.(*CreateUserRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreateUserResponse) - return ctx.Result(200, reply) - } -} - -func _UserService_UpdateUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateUserRequest - if err := ctx.Bind(&in.User); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceUpdateUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateUser(ctx, req.(*UpdateUserRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateUserResponse) - return ctx.Result(200, reply) - } -} - -func _UserService_DeleteUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteUserRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceDeleteUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteUser(ctx, req.(*DeleteUserRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteUserResponse) - return ctx.Result(200, reply) - } -} - -func _UserService_UpdateUserStatus0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateUserStatusRequest - if err := ctx.Bind(&in.User); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceUpdateUserStatus) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateUserStatus(ctx, req.(*UpdateUserStatusRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateUserStatusResponse) - return ctx.Result(200, reply) - } -} - -func _UserService_UpdateUserRoles0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateUserRolesRequest - if err := ctx.Bind(&in.User); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceUpdateUserRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateUserRoles(ctx, req.(*UpdateUserRolesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateUserRolesResponse) - return ctx.Result(200, reply) - } -} - -func _UserService_ResetUserPassword0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ResetUserPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationUserServiceResetUserPassword) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ResetUserPassword(ctx, req.(*ResetUserPasswordRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ResetUserPasswordResponse) - return ctx.Result(200, reply) - } -} - -type UserServiceHTTPClient interface { - CreateUser(ctx context.Context, req *CreateUserRequest, opts ...http.CallOption) (rsp *CreateUserResponse, err error) - DeleteUser(ctx context.Context, req *DeleteUserRequest, opts ...http.CallOption) (rsp *DeleteUserResponse, err error) - GetUser(ctx context.Context, req *GetUserRequest, opts ...http.CallOption) (rsp *GetUserResponse, err error) - ListUserResources(ctx context.Context, req *ListUserResourcesRequest, opts ...http.CallOption) (rsp *ListUserResourcesResponse, err error) - ListUsers(ctx context.Context, req *ListUsersRequest, opts ...http.CallOption) (rsp *ListUsersResponse, err error) - // ResetUserPassword ResetUserPassword reset the user s password - ResetUserPassword(ctx context.Context, req *ResetUserPasswordRequest, opts ...http.CallOption) (rsp *ResetUserPasswordResponse, err error) - UpdateUser(ctx context.Context, req *UpdateUserRequest, opts ...http.CallOption) (rsp *UpdateUserResponse, err error) - // UpdateUserRoles UpdateUserRoles update the user roles - UpdateUserRoles(ctx context.Context, req *UpdateUserRolesRequest, opts ...http.CallOption) (rsp *UpdateUserRolesResponse, err error) - // UpdateUserStatus UpdateUserStatus Update the status of the user information - UpdateUserStatus(ctx context.Context, req *UpdateUserStatusRequest, opts ...http.CallOption) (rsp *UpdateUserStatusResponse, err error) -} - -type UserServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewUserServiceHTTPClient(client *http.Client) UserServiceHTTPClient { - return &UserServiceHTTPClientImpl{client} -} - -func (c *UserServiceHTTPClientImpl) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...http.CallOption) (*CreateUserResponse, error) { - var out CreateUserResponse - pattern := "/sys/users" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationUserServiceCreateUser)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.User, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *UserServiceHTTPClientImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...http.CallOption) (*DeleteUserResponse, error) { - var out DeleteUserResponse - pattern := "/sys/users/{user.id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationUserServiceDeleteUser)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *UserServiceHTTPClientImpl) GetUser(ctx context.Context, in *GetUserRequest, opts ...http.CallOption) (*GetUserResponse, error) { - var out GetUserResponse - pattern := "/sys/users/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationUserServiceGetUser)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *UserServiceHTTPClientImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest, opts ...http.CallOption) (*ListUserResourcesResponse, error) { - var out ListUserResourcesResponse - pattern := "/sys/users/{id}/resources" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationUserServiceListUserResources)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *UserServiceHTTPClientImpl) ListUsers(ctx context.Context, in *ListUsersRequest, opts ...http.CallOption) (*ListUsersResponse, error) { - var out ListUsersResponse - pattern := "/sys/users" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationUserServiceListUsers)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ResetUserPassword ResetUserPassword reset the user s password -func (c *UserServiceHTTPClientImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest, opts ...http.CallOption) (*ResetUserPasswordResponse, error) { - var out ResetUserPasswordResponse - pattern := "/sys/users/{id}/password/reset" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationUserServiceResetUserPassword)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *UserServiceHTTPClientImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...http.CallOption) (*UpdateUserResponse, error) { - var out UpdateUserResponse - pattern := "/sys/users/{user.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationUserServiceUpdateUser)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdateUserRoles UpdateUserRoles update the user roles -func (c *UserServiceHTTPClientImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest, opts ...http.CallOption) (*UpdateUserRolesResponse, error) { - var out UpdateUserRolesResponse - pattern := "/sys/users/{user.id}/roles" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationUserServiceUpdateUserRoles)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdateUserStatus UpdateUserStatus Update the status of the user information -func (c *UserServiceHTTPClientImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest, opts ...http.CallOption) (*UpdateUserStatusResponse, error) { - var out UpdateUserStatusResponse - pattern := "/sys/users/{user.id}/status" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationUserServiceUpdateUserStatus)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/types/auth_error.pb.go b/api/v1/services/types/auth_error.pb.go deleted file mode 100644 index e05ea522..00000000 --- a/api/v1/services/types/auth_error.pb.go +++ /dev/null @@ -1,131 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: types/auth_error.proto - -package types - -import ( - _ "github.com/go-kratos/kratos/v2/errors" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type AuthErrorReason int32 - -const ( - AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED AuthErrorReason = 0 - AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND AuthErrorReason = 2001 - AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED AuthErrorReason = 2002 -) - -// Enum value maps for AuthErrorReason. -var ( - AuthErrorReason_name = map[int32]string{ - 0: "AUTH_ERROR_REASON_UNSPECIFIED", - 2001: "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND", - 2002: "AUTH_ERROR_REASON_TOKEN_EXPIRED", - } - AuthErrorReason_value = map[string]int32{ - "AUTH_ERROR_REASON_UNSPECIFIED": 0, - "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND": 2001, - "AUTH_ERROR_REASON_TOKEN_EXPIRED": 2002, - } -) - -func (x AuthErrorReason) Enum() *AuthErrorReason { - p := new(AuthErrorReason) - *p = x - return p -} - -func (x AuthErrorReason) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (AuthErrorReason) Descriptor() protoreflect.EnumDescriptor { - return file_types_auth_error_proto_enumTypes[0].Descriptor() -} - -func (AuthErrorReason) Type() protoreflect.EnumType { - return &file_types_auth_error_proto_enumTypes[0] -} - -func (x AuthErrorReason) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use AuthErrorReason.Descriptor instead. -func (AuthErrorReason) EnumDescriptor() ([]byte, []int) { - return file_types_auth_error_proto_rawDescGZIP(), []int{0} -} - -var File_types_auth_error_proto protoreflect.FileDescriptor - -const file_types_auth_error_proto_rawDesc = "" + - "\n" + - "\x16types/auth_error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*\x96\x01\n" + - "\x0fAuthErrorReason\x12!\n" + - "\x1dAUTH_ERROR_REASON_UNSPECIFIED\x10\x00\x12.\n" + - "#AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x12*\n" + - "\x1fAUTH_ERROR_REASON_TOKEN_EXPIRED\x10\xd2\x0f\x1a\x04\xa8E\x91\x03\x1a\x04\xa0E\xf4\x03B\xdc\x01\n" + - "\x19com.api.v1.services.typesB\x0eAuthErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" - -var ( - file_types_auth_error_proto_rawDescOnce sync.Once - file_types_auth_error_proto_rawDescData []byte -) - -func file_types_auth_error_proto_rawDescGZIP() []byte { - file_types_auth_error_proto_rawDescOnce.Do(func() { - file_types_auth_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_auth_error_proto_rawDesc), len(file_types_auth_error_proto_rawDesc))) - }) - return file_types_auth_error_proto_rawDescData -} - -var file_types_auth_error_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_types_auth_error_proto_goTypes = []any{ - (AuthErrorReason)(0), // 0: api.v1.services.types.AuthErrorReason -} -var file_types_auth_error_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_types_auth_error_proto_init() } -func file_types_auth_error_proto_init() { - if File_types_auth_error_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_auth_error_proto_rawDesc), len(file_types_auth_error_proto_rawDesc)), - NumEnums: 1, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_types_auth_error_proto_goTypes, - DependencyIndexes: file_types_auth_error_proto_depIdxs, - EnumInfos: file_types_auth_error_proto_enumTypes, - }.Build() - File_types_auth_error_proto = out.File - file_types_auth_error_proto_goTypes = nil - file_types_auth_error_proto_depIdxs = nil -} diff --git a/api/v1/services/types/auth_error.pb.validate.go b/api/v1/services/types/auth_error.pb.validate.go deleted file mode 100644 index f8f94fbd..00000000 --- a/api/v1/services/types/auth_error.pb.validate.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: types/auth_error.proto - -package types - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) diff --git a/api/v1/services/types/auth_error_errors.pb.go b/api/v1/services/types/auth_error_errors.pb.go deleted file mode 100644 index b4915c00..00000000 --- a/api/v1/services/types/auth_error_errors.pb.go +++ /dev/null @@ -1,48 +0,0 @@ -// Code generated by protoc-gen-go-errors. DO NOT EDIT. - -package types - -import ( - fmt "fmt" - errors "github.com/go-kratos/kratos/v2/errors" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -const _ = errors.SupportPackageIsVersion1 - -func IsAuthErrorReasonUnspecified(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 -} - -func ErrorAuthErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { - return errors.New(500, AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) -} - -func IsAuthErrorReasonCaptchaNotFound(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String() && e.Code == 404 -} - -func ErrorAuthErrorReasonCaptchaNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(404, AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsAuthErrorReasonTokenExpired(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 -} - -func ErrorAuthErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { - return errors.New(401, AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) -} diff --git a/api/v1/services/types/datastore.pb.go b/api/v1/services/types/datastore.pb.go deleted file mode 100644 index c97a2396..00000000 --- a/api/v1/services/types/datastore.pb.go +++ /dev/null @@ -1,206 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: types/datastore.proto - -package types - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// DataObject is the model entity for the DataObject schema. -type DataObject struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // DeleteTime holds the value of the "delete_time" field. - DeleteTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=delete_time,proto3" json:"delete_time,omitempty"` - // Version holds the value of the "version" field. - Version int64 `protobuf:"varint,5,opt,name=version,proto3" json:"version,omitempty"` - // OwnerID holds the value of the "owner_id" field. - OwnerId string `protobuf:"bytes,6,opt,name=owner_id,proto3" json:"owner_id,omitempty"` - // Metadata holds the value of the "metadata" field. - Metadata map[string]string `protobuf:"bytes,7,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - // Payload holds the value of the "payload" field. - Payload []byte `protobuf:"bytes,8,opt,name=payload,proto3" json:"payload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DataObject) Reset() { - *x = DataObject{} - mi := &file_types_datastore_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DataObject) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DataObject) ProtoMessage() {} - -func (x *DataObject) ProtoReflect() protoreflect.Message { - mi := &file_types_datastore_proto_msgTypes[0] - 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 DataObject.ProtoReflect.Descriptor instead. -func (*DataObject) Descriptor() ([]byte, []int) { - return file_types_datastore_proto_rawDescGZIP(), []int{0} -} - -func (x *DataObject) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *DataObject) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *DataObject) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *DataObject) GetDeleteTime() *timestamppb.Timestamp { - if x != nil { - return x.DeleteTime - } - return nil -} - -func (x *DataObject) GetVersion() int64 { - if x != nil { - return x.Version - } - return 0 -} - -func (x *DataObject) GetOwnerId() string { - if x != nil { - return x.OwnerId - } - return "" -} - -func (x *DataObject) GetMetadata() map[string]string { - if x != nil { - return x.Metadata - } - return nil -} - -func (x *DataObject) GetPayload() []byte { - if x != nil { - return x.Payload - } - return nil -} - -var File_types_datastore_proto protoreflect.FileDescriptor - -const file_types_datastore_proto_rawDesc = "" + - "\n" + - "\x15types/datastore.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xb0\x03\n" + - "\n" + - "DataObject\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12<\n" + - "\vdelete_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\vdelete_time\x12\x18\n" + - "\aversion\x18\x05 \x01(\x03R\aversion\x12\x1a\n" + - "\bowner_id\x18\x06 \x01(\tR\bowner_id\x12K\n" + - "\bmetadata\x18\a \x03(\v2/.api.v1.services.types.DataObject.MetadataEntryR\bmetadata\x12\x18\n" + - "\apayload\x18\b \x01(\fR\apayload\x1a;\n" + - "\rMetadataEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01B\xdc\x01\n" + - "\x19com.api.v1.services.typesB\x0eDatastoreProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" - -var ( - file_types_datastore_proto_rawDescOnce sync.Once - file_types_datastore_proto_rawDescData []byte -) - -func file_types_datastore_proto_rawDescGZIP() []byte { - file_types_datastore_proto_rawDescOnce.Do(func() { - file_types_datastore_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_datastore_proto_rawDesc), len(file_types_datastore_proto_rawDesc))) - }) - return file_types_datastore_proto_rawDescData -} - -var file_types_datastore_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_types_datastore_proto_goTypes = []any{ - (*DataObject)(nil), // 0: api.v1.services.types.DataObject - nil, // 1: api.v1.services.types.DataObject.MetadataEntry - (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp -} -var file_types_datastore_proto_depIdxs = []int32{ - 2, // 0: api.v1.services.types.DataObject.create_time:type_name -> google.protobuf.Timestamp - 2, // 1: api.v1.services.types.DataObject.update_time:type_name -> google.protobuf.Timestamp - 2, // 2: api.v1.services.types.DataObject.delete_time:type_name -> google.protobuf.Timestamp - 1, // 3: api.v1.services.types.DataObject.metadata:type_name -> api.v1.services.types.DataObject.MetadataEntry - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_types_datastore_proto_init() } -func file_types_datastore_proto_init() { - if File_types_datastore_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_datastore_proto_rawDesc), len(file_types_datastore_proto_rawDesc)), - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_types_datastore_proto_goTypes, - DependencyIndexes: file_types_datastore_proto_depIdxs, - MessageInfos: file_types_datastore_proto_msgTypes, - }.Build() - File_types_datastore_proto = out.File - file_types_datastore_proto_goTypes = nil - file_types_datastore_proto_depIdxs = nil -} diff --git a/api/v1/services/types/datastore.pb.validate.go b/api/v1/services/types/datastore.pb.validate.go deleted file mode 100644 index 4cd8afdc..00000000 --- a/api/v1/services/types/datastore.pb.validate.go +++ /dev/null @@ -1,232 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: types/datastore.proto - -package types - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on DataObject 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 *DataObject) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DataObject 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 DataObjectMultiError, or -// nil if none found. -func (m *DataObject) ValidateAll() error { - return m.validate(true) -} - -func (m *DataObject) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DataObjectValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DataObjectValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DataObjectValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DataObjectValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DataObjectValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DataObjectValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetDeleteTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DataObjectValidationError{ - field: "DeleteTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DataObjectValidationError{ - field: "DeleteTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDeleteTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DataObjectValidationError{ - field: "DeleteTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Version - - // no validation rules for OwnerId - - // no validation rules for Metadata - - // no validation rules for Payload - - if len(errors) > 0 { - return DataObjectMultiError(errors) - } - - return nil -} - -// DataObjectMultiError is an error wrapping multiple validation errors -// returned by DataObject.ValidateAll() if the designated constraints aren't met. -type DataObjectMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DataObjectMultiError) 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 DataObjectMultiError) AllErrors() []error { return m } - -// DataObjectValidationError is the validation error returned by -// DataObject.Validate if the designated constraints aren't met. -type DataObjectValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DataObjectValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DataObjectValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DataObjectValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DataObjectValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DataObjectValidationError) ErrorName() string { return "DataObjectValidationError" } - -// Error satisfies the builtin error interface -func (e DataObjectValidationError) 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 %sDataObject.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DataObjectValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DataObjectValidationError{} diff --git a/api/v1/services/types/error.pb.go b/api/v1/services/types/error.pb.go deleted file mode 100644 index ef7d92f7..00000000 --- a/api/v1/services/types/error.pb.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: types/error.proto - -package types - -import ( - _ "github.com/go-kratos/kratos/v2/errors" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type ErrorReason int32 - -const ( - ErrorReason_ERROR_REASON_UNSPECIFIED ErrorReason = 0 - ErrorReason_ERROR_REASON_CUSTOMIZED ErrorReason = 1000 -) - -// Enum value maps for ErrorReason. -var ( - ErrorReason_name = map[int32]string{ - 0: "ERROR_REASON_UNSPECIFIED", - 1000: "ERROR_REASON_CUSTOMIZED", - } - ErrorReason_value = map[string]int32{ - "ERROR_REASON_UNSPECIFIED": 0, - "ERROR_REASON_CUSTOMIZED": 1000, - } -) - -func (x ErrorReason) Enum() *ErrorReason { - p := new(ErrorReason) - *p = x - return p -} - -func (x ErrorReason) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (ErrorReason) Descriptor() protoreflect.EnumDescriptor { - return file_types_error_proto_enumTypes[0].Descriptor() -} - -func (ErrorReason) Type() protoreflect.EnumType { - return &file_types_error_proto_enumTypes[0] -} - -func (x ErrorReason) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use ErrorReason.Descriptor instead. -func (ErrorReason) EnumDescriptor() ([]byte, []int) { - return file_types_error_proto_rawDescGZIP(), []int{0} -} - -var File_types_error_proto protoreflect.FileDescriptor - -const file_types_error_proto_rawDesc = "" + - "\n" + - "\x11types/error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*O\n" + - "\vErrorReason\x12\x1c\n" + - "\x18ERROR_REASON_UNSPECIFIED\x10\x00\x12\x1c\n" + - "\x17ERROR_REASON_CUSTOMIZED\x10\xe8\a\x1a\x04\xa0E\xf4\x03B\xd8\x01\n" + - "\x19com.api.v1.services.typesB\n" + - "ErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" - -var ( - file_types_error_proto_rawDescOnce sync.Once - file_types_error_proto_rawDescData []byte -) - -func file_types_error_proto_rawDescGZIP() []byte { - file_types_error_proto_rawDescOnce.Do(func() { - file_types_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_error_proto_rawDesc), len(file_types_error_proto_rawDesc))) - }) - return file_types_error_proto_rawDescData -} - -var file_types_error_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_types_error_proto_goTypes = []any{ - (ErrorReason)(0), // 0: api.v1.services.types.ErrorReason -} -var file_types_error_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_types_error_proto_init() } -func file_types_error_proto_init() { - if File_types_error_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_error_proto_rawDesc), len(file_types_error_proto_rawDesc)), - NumEnums: 1, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_types_error_proto_goTypes, - DependencyIndexes: file_types_error_proto_depIdxs, - EnumInfos: file_types_error_proto_enumTypes, - }.Build() - File_types_error_proto = out.File - file_types_error_proto_goTypes = nil - file_types_error_proto_depIdxs = nil -} diff --git a/api/v1/services/types/error.pb.validate.go b/api/v1/services/types/error.pb.validate.go deleted file mode 100644 index c78c8d37..00000000 --- a/api/v1/services/types/error.pb.validate.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: types/error.proto - -package types - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) diff --git a/api/v1/services/types/error_errors.pb.go b/api/v1/services/types/error_errors.pb.go deleted file mode 100644 index ff776353..00000000 --- a/api/v1/services/types/error_errors.pb.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by protoc-gen-go-errors. DO NOT EDIT. - -package types - -import ( - fmt "fmt" - errors "github.com/go-kratos/kratos/v2/errors" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -const _ = errors.SupportPackageIsVersion1 - -func IsErrorReasonUnspecified(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == ErrorReason_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 -} - -func ErrorErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { - return errors.New(500, ErrorReason_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) -} - -func IsErrorReasonCustomized(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == ErrorReason_ERROR_REASON_CUSTOMIZED.String() && e.Code == 500 -} - -func ErrorErrorReasonCustomized(format string, args ...interface{}) *errors.Error { - return errors.New(500, ErrorReason_ERROR_REASON_CUSTOMIZED.String(), fmt.Sprintf(format, args...)) -} diff --git a/api/v1/services/types/message.pb.go b/api/v1/services/types/message.pb.go deleted file mode 100644 index 17b6aa72..00000000 --- a/api/v1/services/types/message.pb.go +++ /dev/null @@ -1,128 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: types/message.proto - -package types - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - _ "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Message is the model entity for the Message schema. -// NOTE: This message definition is currently incomplete and only contains an ID field. -// It should be extended with actual message content as needed. -type Message struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Message) Reset() { - *x = Message{} - mi := &file_types_message_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Message) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Message) ProtoMessage() {} - -func (x *Message) ProtoReflect() protoreflect.Message { - mi := &file_types_message_proto_msgTypes[0] - 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 Message.ProtoReflect.Descriptor instead. -func (*Message) Descriptor() ([]byte, []int) { - return file_types_message_proto_rawDescGZIP(), []int{0} -} - -func (x *Message) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -var File_types_message_proto protoreflect.FileDescriptor - -const file_types_message_proto_rawDesc = "" + - "\n" + - "\x13types/message.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x19\n" + - "\aMessage\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02idB\xda\x01\n" + - "\x19com.api.v1.services.typesB\fMessageProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" - -var ( - file_types_message_proto_rawDescOnce sync.Once - file_types_message_proto_rawDescData []byte -) - -func file_types_message_proto_rawDescGZIP() []byte { - file_types_message_proto_rawDescOnce.Do(func() { - file_types_message_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_message_proto_rawDesc), len(file_types_message_proto_rawDesc))) - }) - return file_types_message_proto_rawDescData -} - -var file_types_message_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_types_message_proto_goTypes = []any{ - (*Message)(nil), // 0: api.v1.services.types.Message -} -var file_types_message_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_types_message_proto_init() } -func file_types_message_proto_init() { - if File_types_message_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_message_proto_rawDesc), len(file_types_message_proto_rawDesc)), - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_types_message_proto_goTypes, - DependencyIndexes: file_types_message_proto_depIdxs, - MessageInfos: file_types_message_proto_msgTypes, - }.Build() - File_types_message_proto = out.File - file_types_message_proto_goTypes = nil - file_types_message_proto_depIdxs = nil -} diff --git a/api/v1/services/types/message.pb.validate.go b/api/v1/services/types/message.pb.validate.go deleted file mode 100644 index e03ac545..00000000 --- a/api/v1/services/types/message.pb.validate.go +++ /dev/null @@ -1,136 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: types/message.proto - -package types - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on Message 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 *Message) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Message 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 MessageMultiError, or nil if none found. -func (m *Message) ValidateAll() error { - return m.validate(true) -} - -func (m *Message) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return MessageMultiError(errors) - } - - return nil -} - -// MessageMultiError is an error wrapping multiple validation errors returned -// by Message.ValidateAll() if the designated constraints aren't met. -type MessageMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m MessageMultiError) 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 MessageMultiError) AllErrors() []error { return m } - -// MessageValidationError is the validation error returned by Message.Validate -// if the designated constraints aren't met. -type MessageValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e MessageValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e MessageValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e MessageValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e MessageValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e MessageValidationError) ErrorName() string { return "MessageValidationError" } - -// Error satisfies the builtin error interface -func (e MessageValidationError) 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 %sMessage.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = MessageValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = MessageValidationError{} diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go deleted file mode 100644 index 36899fd2..00000000 --- a/api/v1/services/types/system.pb.go +++ /dev/null @@ -1,3205 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: types/system.proto - -package types - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - timestamppb "google.golang.org/protobuf/types/known/timestamppb" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Menu is the model entity for the Menu schema. -type Menu struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // Code holds the value of the "keyword" field. - Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` - // Name holds the value of the "name" field. - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - // I18nKey holds the value - I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` - // Description holds the value of the "description" field. - Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` - // Sequence holds the value of the "sequence" field. - Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` - // Type holds the value of the "type" field. - Type string `protobuf:"bytes,9,opt,name=type,proto3" json:"type,omitempty"` - // Icon holds the value of the "icon" field. - Icon string `protobuf:"bytes,10,opt,name=icon,proto3" json:"icon,omitempty"` - // Path holds the value of the "path" field. - Path string `protobuf:"bytes,11,opt,name=path,proto3" json:"path,omitempty"` - // Properties holds the value of the "properties" field. - Properties string `protobuf:"bytes,12,opt,name=properties,proto3" json:"properties,omitempty"` - // Status holds the value of the "status" field. - Status int32 `protobuf:"varint,13,opt,name=status,proto3" json:"status,omitempty"` - // ParentID holds the value of the "parent_id" field. - ParentId int64 `protobuf:"varint,14,opt,name=parent_id,proto3" json:"parent_id,omitempty"` - // ParentPath holds the value of the "parent_path" field. - ParentPath string `protobuf:"bytes,15,opt,name=parent_path,proto3" json:"parent_path,omitempty"` - // Children holds the value of the children edge. - Children []*Menu `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Menu `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Menu) Reset() { - *x = Menu{} - mi := &file_types_system_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Menu) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Menu) ProtoMessage() {} - -func (x *Menu) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[0] - 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 Menu.ProtoReflect.Descriptor instead. -func (*Menu) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{0} -} - -func (x *Menu) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Menu) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Menu) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Menu) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Menu) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Menu) GetI18NKey() string { - if x != nil { - return x.I18NKey - } - return "" -} - -func (x *Menu) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Menu) GetSequence() int32 { - if x != nil { - return x.Sequence - } - return 0 -} - -func (x *Menu) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Menu) GetIcon() string { - if x != nil { - return x.Icon - } - return "" -} - -func (x *Menu) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *Menu) GetProperties() string { - if x != nil { - return x.Properties - } - return "" -} - -func (x *Menu) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *Menu) GetParentId() int64 { - if x != nil { - return x.ParentId - } - return 0 -} - -func (x *Menu) GetParentPath() string { - if x != nil { - return x.ParentPath - } - return "" -} - -func (x *Menu) GetChildren() []*Menu { - if x != nil { - return x.Children - } - return nil -} - -func (x *Menu) GetParent() *Menu { - if x != nil { - return x.Parent - } - return nil -} - -func (x *Menu) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *Menu) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -// MenuEdges holds the relations/edges for other nodes in the graph. -type MenuEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Children holds the value of the children edge. - Children []*Menu `protobuf:"bytes,1,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Menu `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,3,rep,name=resources,proto3" json:"resources,omitempty"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,4,rep,name=roles,proto3" json:"roles,omitempty"` - // RoleMenu holds the value of the role_menu edge. - RoleMenus []*RoleMenu `protobuf:"bytes,5,rep,name=role_menus,proto3" json:"role_menus,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *MenuEdges) Reset() { - *x = MenuEdges{} - mi := &file_types_system_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *MenuEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MenuEdges) ProtoMessage() {} - -func (x *MenuEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[1] - 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 MenuEdges.ProtoReflect.Descriptor instead. -func (*MenuEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{1} -} - -func (x *MenuEdges) GetChildren() []*Menu { - if x != nil { - return x.Children - } - return nil -} - -func (x *MenuEdges) GetParent() *Menu { - if x != nil { - return x.Parent - } - return nil -} - -func (x *MenuEdges) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *MenuEdges) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *MenuEdges) GetRoleMenus() []*RoleMenu { - if x != nil { - return x.RoleMenus - } - return nil -} - -// Role is the model entity for the Role schema. -type Role struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // role.field.keyword - Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` - // role.field.name - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - // role.field.description - Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` - // role.field.type - Type int32 `protobuf:"varint,7,opt,name=type,proto3" json:"type,omitempty"` - // role.field.sequence - Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` - // role.field.status - Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"` - // role.field.is_types - IsTypes bool `protobuf:"varint,10,opt,name=is_types,proto3" json:"is_types,omitempty"` - // Menus holds the value of the menus edge. - Menus []*Menu `protobuf:"bytes,21,rep,name=menus,proto3" json:"menus,omitempty"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,22,rep,name=users,proto3" json:"users,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` - // Resource Ids holds the value of the resource_ids edge. - ResourceIds []int64 `protobuf:"varint,24,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` - // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,25,rep,name=permissions,proto3" json:"permissions,omitempty"` - // Permission Ids holds the value of the permission_ids edge. - PermissionIds []int64 `protobuf:"varint,26,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Role) Reset() { - *x = Role{} - mi := &file_types_system_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Role) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Role) ProtoMessage() {} - -func (x *Role) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[2] - 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 Role.ProtoReflect.Descriptor instead. -func (*Role) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{2} -} - -func (x *Role) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Role) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Role) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Role) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Role) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Role) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Role) GetType() int32 { - if x != nil { - return x.Type - } - return 0 -} - -func (x *Role) GetSequence() int32 { - if x != nil { - return x.Sequence - } - return 0 -} - -func (x *Role) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *Role) GetIsTypes() bool { - if x != nil { - return x.IsTypes - } - return false -} - -func (x *Role) GetMenus() []*Menu { - if x != nil { - return x.Menus - } - return nil -} - -func (x *Role) GetUsers() []*User { - if x != nil { - return x.Users - } - return nil -} - -func (x *Role) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *Role) GetResourceIds() []int64 { - if x != nil { - return x.ResourceIds - } - return nil -} - -func (x *Role) GetPermissions() []*Permission { - if x != nil { - return x.Permissions - } - return nil -} - -func (x *Role) GetPermissionIds() []int64 { - if x != nil { - return x.PermissionIds - } - return nil -} - -// RoleEdges holds the relations/edges for other nodes in the graph. -type RoleEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Menus holds the value of the menus edge. - Menus []*Menu `protobuf:"bytes,1,rep,name=menus,proto3" json:"menus,omitempty"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` - // RoleMenu holds the value of the role_menu edge. - RoleMenus []*RoleMenu `protobuf:"bytes,3,rep,name=role_menus,proto3" json:"role_menus,omitempty"` - // UserRole holds the value of the user_role edge. - UserRoles []*UserRole `protobuf:"bytes,4,rep,name=user_roles,proto3" json:"user_roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RoleEdges) Reset() { - *x = RoleEdges{} - mi := &file_types_system_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RoleEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RoleEdges) ProtoMessage() {} - -func (x *RoleEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[3] - 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 RoleEdges.ProtoReflect.Descriptor instead. -func (*RoleEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{3} -} - -func (x *RoleEdges) GetMenus() []*Menu { - if x != nil { - return x.Menus - } - return nil -} - -func (x *RoleEdges) GetUsers() []*User { - if x != nil { - return x.Users - } - return nil -} - -func (x *RoleEdges) GetRoleMenus() []*RoleMenu { - if x != nil { - return x.RoleMenus - } - return nil -} - -func (x *RoleEdges) GetUserRoles() []*UserRole { - if x != nil { - return x.UserRoles - } - return nil -} - -// User is the model entity for the User schema. -type User struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_author.field.comment - CreateAuthor int64 `protobuf:"varint,2,opt,name=create_author,proto3" json:"create_author,omitempty"` - // update_author.field.comment - UpdateAuthor int64 `protobuf:"varint,3,opt,name=update_author,proto3" json:"update_author,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=update_time,proto3" json:"update_time,omitempty"` - // user.field.uuid - Uuid string `protobuf:"bytes,6,opt,name=uuid,proto3" json:"uuid,omitempty"` - // user.field.allowed_ip - AllowedIp string `protobuf:"bytes,7,opt,name=allowed_ip,proto3" json:"allowed_ip,omitempty"` - // user.field.username - Username string `protobuf:"bytes,8,opt,name=username,proto3" json:"username,omitempty"` - // user.field.nickname - Nickname string `protobuf:"bytes,9,opt,name=nickname,proto3" json:"nickname,omitempty"` - // user.field.avatar - Avatar string `protobuf:"bytes,10,opt,name=avatar,proto3" json:"avatar,omitempty"` - // user.field.nickname - Name string `protobuf:"bytes,11,opt,name=name,proto3" json:"name,omitempty"` - // user.field.gender - Gender string `protobuf:"bytes,12,opt,name=gender,proto3" json:"gender,omitempty"` - // user.field.password - // @Decrypted don't show this field in response - Password string `protobuf:"bytes,13,opt,name=password,proto3" json:"password,omitempty"` - // user.field.confirm_password - ConfirmPassword string `protobuf:"bytes,14,opt,name=confirm_password,proto3" json:"confirm_password,omitempty"` - // user.field.salt - // @Decrypted don't show this field in response - Salt string `protobuf:"bytes,15,opt,name=salt,proto3" json:"salt,omitempty"` - // user.field.phone - Phone string `protobuf:"bytes,16,opt,name=phone,proto3" json:"phone,omitempty"` - // user.field.email - Email string `protobuf:"bytes,17,opt,name=email,proto3" json:"email,omitempty"` - // user.field.remark - Remark string `protobuf:"bytes,18,opt,name=remark,proto3" json:"remark,omitempty"` - // user.field.token - Token string `protobuf:"bytes,19,opt,name=token,proto3" json:"token,omitempty"` - // user.field.status - Status int32 `protobuf:"varint,20,opt,name=status,proto3" json:"status,omitempty"` - // user.field.last_login_ip - LastLoginIp string `protobuf:"bytes,21,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` - // user.field.last_login_time - LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` - // user.field.sanction_date - SanctionDate *timestamppb.Timestamp `protobuf:"bytes,23,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` - // user.field.manager_id - ManagerId int64 `protobuf:"varint,24,opt,name=manager_id,proto3" json:"manager_id,omitempty"` - // user.field.manager - Manager string `protobuf:"bytes,25,opt,name=manager,proto3" json:"manager,omitempty"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,26,rep,name=roles,proto3" json:"roles,omitempty"` - // Role Ids holds the value of the role_ids - RoleIds []int64 `protobuf:"varint,27,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *User) Reset() { - *x = User{} - mi := &file_types_system_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *User) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*User) ProtoMessage() {} - -func (x *User) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[4] - 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 User.ProtoReflect.Descriptor instead. -func (*User) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{4} -} - -func (x *User) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *User) GetCreateAuthor() int64 { - if x != nil { - return x.CreateAuthor - } - return 0 -} - -func (x *User) GetUpdateAuthor() int64 { - if x != nil { - return x.UpdateAuthor - } - return 0 -} - -func (x *User) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *User) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *User) GetUuid() string { - if x != nil { - return x.Uuid - } - return "" -} - -func (x *User) GetAllowedIp() string { - if x != nil { - return x.AllowedIp - } - return "" -} - -func (x *User) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *User) GetNickname() string { - if x != nil { - return x.Nickname - } - return "" -} - -func (x *User) GetAvatar() string { - if x != nil { - return x.Avatar - } - return "" -} - -func (x *User) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *User) GetGender() string { - if x != nil { - return x.Gender - } - return "" -} - -func (x *User) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -func (x *User) GetConfirmPassword() string { - if x != nil { - return x.ConfirmPassword - } - return "" -} - -func (x *User) GetSalt() string { - if x != nil { - return x.Salt - } - return "" -} - -func (x *User) GetPhone() string { - if x != nil { - return x.Phone - } - return "" -} - -func (x *User) GetEmail() string { - if x != nil { - return x.Email - } - return "" -} - -func (x *User) GetRemark() string { - if x != nil { - return x.Remark - } - return "" -} - -func (x *User) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -func (x *User) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *User) GetLastLoginIp() string { - if x != nil { - return x.LastLoginIp - } - return "" -} - -func (x *User) GetLastLoginTime() *timestamppb.Timestamp { - if x != nil { - return x.LastLoginTime - } - return nil -} - -func (x *User) GetSanctionDate() *timestamppb.Timestamp { - if x != nil { - return x.SanctionDate - } - return nil -} - -func (x *User) GetManagerId() int64 { - if x != nil { - return x.ManagerId - } - return 0 -} - -func (x *User) GetManager() string { - if x != nil { - return x.Manager - } - return "" -} - -func (x *User) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *User) GetRoleIds() []int64 { - if x != nil { - return x.RoleIds - } - return nil -} - -// UserEdges holds the relations/edges for other nodes in the graph. -type UserEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` - // UserRole holds the value of the user_role edge. - UserRoles []*UserRole `protobuf:"bytes,2,rep,name=user_roles,proto3" json:"user_roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserEdges) Reset() { - *x = UserEdges{} - mi := &file_types_system_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserEdges) ProtoMessage() {} - -func (x *UserEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[5] - 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 UserEdges.ProtoReflect.Descriptor instead. -func (*UserEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{5} -} - -func (x *UserEdges) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *UserEdges) GetUserRoles() []*UserRole { - if x != nil { - return x.UserRoles - } - return nil -} - -// UserRole is the model entity for the UserRole schema. -type UserRole struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // UserID holds the value of the "user_id" field. - UserId int64 `protobuf:"varint,4,opt,name=user_id,proto3" json:"user_id,omitempty"` - // RoleID holds the value of the "role_id" field. - RoleId int64 `protobuf:"varint,5,opt,name=role_id,proto3" json:"role_id,omitempty"` - // RoleName holds the value of the "role_name" field. - RoleName string `protobuf:"bytes,6,opt,name=role_name,proto3" json:"role_name,omitempty"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,21,opt,name=user,proto3" json:"user,omitempty"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,22,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserRole) Reset() { - *x = UserRole{} - mi := &file_types_system_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserRole) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserRole) ProtoMessage() {} - -func (x *UserRole) ProtoReflect() protoreflect.Message { - mi := &file_types_system_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 UserRole.ProtoReflect.Descriptor instead. -func (*UserRole) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{6} -} - -func (x *UserRole) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UserRole) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *UserRole) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *UserRole) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *UserRole) GetRoleId() int64 { - if x != nil { - return x.RoleId - } - return 0 -} - -func (x *UserRole) GetRoleName() string { - if x != nil { - return x.RoleName - } - return "" -} - -func (x *UserRole) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserRole) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -// UserRoleEdges holds the relations/edges for other nodes in the graph. -type UserRoleEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserRoleEdges) Reset() { - *x = UserRoleEdges{} - mi := &file_types_system_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserRoleEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserRoleEdges) ProtoMessage() {} - -func (x *UserRoleEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserRoleEdges.ProtoReflect.Descriptor instead. -func (*UserRoleEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{7} -} - -func (x *UserRoleEdges) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserRoleEdges) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -// RoleMenu is the model entity for the RoleMenu schema. -type RoleMenu struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // RoleID holds the value of the "role_id" field. - RoleId int64 `protobuf:"varint,4,opt,name=role_id,proto3" json:"role_id,omitempty"` - // MenuID holds the value of the "menu_id" field. - MenuId int64 `protobuf:"varint,5,opt,name=menu_id,proto3" json:"menu_id,omitempty"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,21,opt,name=role,proto3" json:"role,omitempty"` - // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,22,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RoleMenu) Reset() { - *x = RoleMenu{} - mi := &file_types_system_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RoleMenu) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RoleMenu) ProtoMessage() {} - -func (x *RoleMenu) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[8] - 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 RoleMenu.ProtoReflect.Descriptor instead. -func (*RoleMenu) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{8} -} - -func (x *RoleMenu) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *RoleMenu) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *RoleMenu) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *RoleMenu) GetRoleId() int64 { - if x != nil { - return x.RoleId - } - return 0 -} - -func (x *RoleMenu) GetMenuId() int64 { - if x != nil { - return x.MenuId - } - return 0 -} - -func (x *RoleMenu) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -func (x *RoleMenu) GetMenu() *Menu { - if x != nil { - return x.Menu - } - return nil -} - -// RoleMenuEdges holds the relations/edges for other nodes in the graph. -type RoleMenuEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RoleMenuEdges) Reset() { - *x = RoleMenuEdges{} - mi := &file_types_system_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RoleMenuEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RoleMenuEdges) ProtoMessage() {} - -func (x *RoleMenuEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[9] - 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 RoleMenuEdges.ProtoReflect.Descriptor instead. -func (*RoleMenuEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{9} -} - -func (x *RoleMenuEdges) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -func (x *RoleMenuEdges) GetMenu() *Menu { - if x != nil { - return x.Menu - } - return nil -} - -// Resource is the model entity for the Resource schema. -type Resource struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // resource.field.name - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - // resource.field.keyword - Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` - // resource.field.i18n_key - I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` - // resource.field.type - Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` - // resource.field.status - Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` - // resource.field.path - Path string `protobuf:"bytes,9,opt,name=path,proto3" json:"path,omitempty"` - // resource.field.operation - Operation string `protobuf:"bytes,10,opt,name=operation,proto3" json:"operation,omitempty"` - // resource.field.method - Method string `protobuf:"bytes,11,opt,name=method,proto3" json:"method,omitempty"` - // resource.field.component - Component string `protobuf:"bytes,12,opt,name=component,proto3" json:"component,omitempty"` - // resource.field.icon - Icon string `protobuf:"bytes,13,opt,name=icon,proto3" json:"icon,omitempty"` - // resource.field.sequence - Sequence int32 `protobuf:"varint,14,opt,name=sequence,proto3" json:"sequence,omitempty"` - // resource.field.visible - Visible bool `protobuf:"varint,15,opt,name=visible,proto3" json:"visible,omitempty"` - // resource.field.tree_path - TreePath string `protobuf:"bytes,16,opt,name=tree_path,proto3" json:"tree_path,omitempty"` - // resource.field.properties - Properties map[string]string `protobuf:"bytes,17,rep,name=properties,proto3" json:"properties,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - // resource.field.description - Description string `protobuf:"bytes,18,opt,name=description,proto3" json:"description,omitempty"` - // resource.field.parent_id - ParentId int64 `protobuf:"varint,19,opt,name=parent_id,proto3" json:"parent_id,omitempty"` - // Children holds the value of the children edge. - Children []*Resource `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Resource `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` - // Permission Ids holds the value of the permission_ids edge. - PermissionIds []int64 `protobuf:"varint,23,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` - // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,24,rep,name=permissions,proto3" json:"permissions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Resource) Reset() { - *x = Resource{} - mi := &file_types_system_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Resource) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Resource) ProtoMessage() {} - -func (x *Resource) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[10] - 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 Resource.ProtoReflect.Descriptor instead. -func (*Resource) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{10} -} - -func (x *Resource) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Resource) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Resource) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Resource) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Resource) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Resource) GetI18NKey() string { - if x != nil { - return x.I18NKey - } - return "" -} - -func (x *Resource) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *Resource) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *Resource) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *Resource) GetOperation() string { - if x != nil { - return x.Operation - } - return "" -} - -func (x *Resource) GetMethod() string { - if x != nil { - return x.Method - } - return "" -} - -func (x *Resource) GetComponent() string { - if x != nil { - return x.Component - } - return "" -} - -func (x *Resource) GetIcon() string { - if x != nil { - return x.Icon - } - return "" -} - -func (x *Resource) GetSequence() int32 { - if x != nil { - return x.Sequence - } - return 0 -} - -func (x *Resource) GetVisible() bool { - if x != nil { - return x.Visible - } - return false -} - -func (x *Resource) GetTreePath() string { - if x != nil { - return x.TreePath - } - return "" -} - -func (x *Resource) GetProperties() map[string]string { - if x != nil { - return x.Properties - } - return nil -} - -func (x *Resource) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Resource) GetParentId() int64 { - if x != nil { - return x.ParentId - } - return 0 -} - -func (x *Resource) GetChildren() []*Resource { - if x != nil { - return x.Children - } - return nil -} - -func (x *Resource) GetParent() *Resource { - if x != nil { - return x.Parent - } - return nil -} - -func (x *Resource) GetPermissionIds() []int64 { - if x != nil { - return x.PermissionIds - } - return nil -} - -func (x *Resource) GetPermissions() []*Permission { - if x != nil { - return x.Permissions - } - return nil -} - -// ResourceEdges holds the relations/edges for other nodes in the graph. -type ResourceEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ResourceEdges) Reset() { - *x = ResourceEdges{} - mi := &file_types_system_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ResourceEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ResourceEdges) ProtoMessage() {} - -func (x *ResourceEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[11] - 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 ResourceEdges.ProtoReflect.Descriptor instead. -func (*ResourceEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{11} -} - -func (x *ResourceEdges) GetMenu() *Menu { - if x != nil { - return x.Menu - } - return nil -} - -// department.table.comment -type Department struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // department.field.keyword - Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` - // department.field.name - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - // menu.field.tree_path - TreePath string `protobuf:"bytes,6,opt,name=tree_path,proto3" json:"tree_path,omitempty"` - // department.field.sequence - Sequence int32 `protobuf:"varint,7,opt,name=sequence,proto3" json:"sequence,omitempty"` - // department.field.status - Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` - // department.field.level - Level int32 `protobuf:"varint,9,opt,name=level,proto3" json:"level,omitempty"` - // department.field.description - Description string `protobuf:"bytes,10,opt,name=description,proto3" json:"description,omitempty"` - // department.field.parent_id - ParentId int64 `protobuf:"varint,11,opt,name=parent_id,proto3" json:"parent_id,omitempty"` - // Children holds the value of the children edge. - Children []*Department `protobuf:"bytes,12,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Department `protobuf:"bytes,13,opt,name=parent,proto3" json:"parent,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Department) Reset() { - *x = Department{} - mi := &file_types_system_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Department) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Department) ProtoMessage() {} - -func (x *Department) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[12] - 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 Department.ProtoReflect.Descriptor instead. -func (*Department) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{12} -} - -func (x *Department) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Department) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Department) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Department) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Department) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Department) GetTreePath() string { - if x != nil { - return x.TreePath - } - return "" -} - -func (x *Department) GetSequence() int32 { - if x != nil { - return x.Sequence - } - return 0 -} - -func (x *Department) GetStatus() int32 { - if x != nil { - return x.Status - } - return 0 -} - -func (x *Department) GetLevel() int32 { - if x != nil { - return x.Level - } - return 0 -} - -func (x *Department) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Department) GetParentId() int64 { - if x != nil { - return x.ParentId - } - return 0 -} - -func (x *Department) GetChildren() []*Department { - if x != nil { - return x.Children - } - return nil -} - -func (x *Department) GetParent() *Department { - if x != nil { - return x.Parent - } - return nil -} - -type DepartmentEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` - // Positions holds the value of the positions edge. - Positions []*Position `protobuf:"bytes,2,rep,name=positions,proto3" json:"positions,omitempty"` - // Children holds the value of the children edge. - Children []*Department `protobuf:"bytes,3,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Department `protobuf:"bytes,4,opt,name=parent,proto3" json:"parent,omitempty"` - // UserDepartments holds the value of the user_departments edge. - UserDepartments []*UserDepartment `protobuf:"bytes,5,rep,name=user_departments,proto3" json:"user_departments,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DepartmentEdges) Reset() { - *x = DepartmentEdges{} - mi := &file_types_system_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DepartmentEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DepartmentEdges) ProtoMessage() {} - -func (x *DepartmentEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[13] - 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 DepartmentEdges.ProtoReflect.Descriptor instead. -func (*DepartmentEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{13} -} - -func (x *DepartmentEdges) GetUsers() []*User { - if x != nil { - return x.Users - } - return nil -} - -func (x *DepartmentEdges) GetPositions() []*Position { - if x != nil { - return x.Positions - } - return nil -} - -func (x *DepartmentEdges) GetChildren() []*Department { - if x != nil { - return x.Children - } - return nil -} - -func (x *DepartmentEdges) GetParent() *Department { - if x != nil { - return x.Parent - } - return nil -} - -func (x *DepartmentEdges) GetUserDepartments() []*UserDepartment { - if x != nil { - return x.UserDepartments - } - return nil -} - -// user_department.table.comment -type UserDepartment struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // field.foreign_key.comment - UserId int64 `protobuf:"varint,2,opt,name=user_id,proto3" json:"user_id,omitempty"` - // field.foreign_key.comment - DepartmentId int64 `protobuf:"varint,3,opt,name=department_id,proto3" json:"department_id,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the UserDepartmentQuery when eager-loading is set. - Edges *UserDepartmentEdges `protobuf:"bytes,4,opt,name=edges,proto3" json:"edges,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserDepartment) Reset() { - *x = UserDepartment{} - mi := &file_types_system_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserDepartment) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserDepartment) ProtoMessage() {} - -func (x *UserDepartment) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[14] - 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 UserDepartment.ProtoReflect.Descriptor instead. -func (*UserDepartment) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{14} -} - -func (x *UserDepartment) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UserDepartment) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *UserDepartment) GetDepartmentId() int64 { - if x != nil { - return x.DepartmentId - } - return 0 -} - -func (x *UserDepartment) GetEdges() *UserDepartmentEdges { - if x != nil { - return x.Edges - } - return nil -} - -// UserDepartmentEdges holds the relations/edges for other nodes in the graph. -type UserDepartmentEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // Department holds the value of the department edge. - Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserDepartmentEdges) Reset() { - *x = UserDepartmentEdges{} - mi := &file_types_system_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserDepartmentEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserDepartmentEdges) ProtoMessage() {} - -func (x *UserDepartmentEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[15] - 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 UserDepartmentEdges.ProtoReflect.Descriptor instead. -func (*UserDepartmentEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{15} -} - -func (x *UserDepartmentEdges) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserDepartmentEdges) GetDepartment() *Department { - if x != nil { - return x.Department - } - return nil -} - -// position.table.comment -type Position struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // position.field.name - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - // position.field.keyword - Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` - // position.field.description - Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` - // department.field.department_id - DepartmentId int64 `protobuf:"varint,7,opt,name=department_id,proto3" json:"department_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Position) Reset() { - *x = Position{} - mi := &file_types_system_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Position) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Position) ProtoMessage() {} - -func (x *Position) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[16] - 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 Position.ProtoReflect.Descriptor instead. -func (*Position) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{16} -} - -func (x *Position) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Position) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Position) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Position) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Position) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Position) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Position) GetDepartmentId() int64 { - if x != nil { - return x.DepartmentId - } - return 0 -} - -// PositionEdges holds the relations/edges for other nodes in the graph. -type PositionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Department holds the value of the department edge. - Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` - // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,3,rep,name=permissions,proto3" json:"permissions,omitempty"` - // UserPositions holds the value of the user_positions edge. - UserPositions []*UserPosition `protobuf:"bytes,4,rep,name=user_positions,proto3" json:"user_positions,omitempty"` - // PositionPermissions holds the value of the position_permissions edge. - PositionPermissions []*PositionPermission `protobuf:"bytes,5,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PositionEdges) Reset() { - *x = PositionEdges{} - mi := &file_types_system_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PositionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PositionEdges) ProtoMessage() {} - -func (x *PositionEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[17] - 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 PositionEdges.ProtoReflect.Descriptor instead. -func (*PositionEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{17} -} - -func (x *PositionEdges) GetDepartment() *Department { - if x != nil { - return x.Department - } - return nil -} - -func (x *PositionEdges) GetUsers() []*User { - if x != nil { - return x.Users - } - return nil -} - -func (x *PositionEdges) GetPermissions() []*Permission { - if x != nil { - return x.Permissions - } - return nil -} - -func (x *PositionEdges) GetUserPositions() []*UserPosition { - if x != nil { - return x.UserPositions - } - return nil -} - -func (x *PositionEdges) GetPositionPermissions() []*PositionPermission { - if x != nil { - return x.PositionPermissions - } - return nil -} - -// permission.table.comment -type Permission struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // permission.field.name - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - // permission.field.keyword - Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` - // permission.field.description - Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` - // permission.field.data_scope - DataScope string `protobuf:"bytes,7,opt,name=data_scope,proto3" json:"data_scope,omitempty"` - // permission.field.data_rules - DataRules map[string]string `protobuf:"bytes,8,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - // permission.field.resource_ids - ResourceIds []int64 `protobuf:"varint,9,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` - // permission.field.resources - Resources []*Resource `protobuf:"bytes,10,rep,name=resources,proto3" json:"resources,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *Permission) Reset() { - *x = Permission{} - mi := &file_types_system_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Permission) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Permission) ProtoMessage() {} - -func (x *Permission) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[18] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Permission.ProtoReflect.Descriptor instead. -func (*Permission) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{18} -} - -func (x *Permission) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *Permission) GetCreateTime() *timestamppb.Timestamp { - if x != nil { - return x.CreateTime - } - return nil -} - -func (x *Permission) GetUpdateTime() *timestamppb.Timestamp { - if x != nil { - return x.UpdateTime - } - return nil -} - -func (x *Permission) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Permission) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -func (x *Permission) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Permission) GetDataScope() string { - if x != nil { - return x.DataScope - } - return "" -} - -func (x *Permission) GetDataRules() map[string]string { - if x != nil { - return x.DataRules - } - return nil -} - -func (x *Permission) GetResourceIds() []int64 { - if x != nil { - return x.ResourceIds - } - return nil -} - -func (x *Permission) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -// PermissionEdges holds the relations/edges for other nodes in the graph. -type PermissionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` - // Positions holds the value of the positions edge. - Positions []*Position `protobuf:"bytes,3,rep,name=positions,proto3" json:"positions,omitempty"` - // RolePermissions holds the value of the role_permissions edge. - RolePermissions []*RolePermission `protobuf:"bytes,4,rep,name=role_permissions,proto3" json:"role_permissions,omitempty"` - // PermissionResources holds the value of the permission_resources edge. - PermissionResources []*PermissionResource `protobuf:"bytes,5,rep,name=permission_resources,proto3" json:"permission_resources,omitempty"` - // PositionPermissions holds the value of the position_permissions edge. - PositionPermissions []*PositionPermission `protobuf:"bytes,6,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PermissionEdges) Reset() { - *x = PermissionEdges{} - mi := &file_types_system_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PermissionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PermissionEdges) ProtoMessage() {} - -func (x *PermissionEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PermissionEdges.ProtoReflect.Descriptor instead. -func (*PermissionEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{19} -} - -func (x *PermissionEdges) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *PermissionEdges) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *PermissionEdges) GetPositions() []*Position { - if x != nil { - return x.Positions - } - return nil -} - -func (x *PermissionEdges) GetRolePermissions() []*RolePermission { - if x != nil { - return x.RolePermissions - } - return nil -} - -func (x *PermissionEdges) GetPermissionResources() []*PermissionResource { - if x != nil { - return x.PermissionResources - } - return nil -} - -func (x *PermissionEdges) GetPositionPermissions() []*PositionPermission { - if x != nil { - return x.PositionPermissions - } - return nil -} - -// user_position.table.comment -type UserPosition struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // field.foreign_key.comment - UserId int64 `protobuf:"varint,2,opt,name=user_id,proto3" json:"user_id,omitempty"` - // field.foreign_key.comment - PositionId int64 `protobuf:"varint,3,opt,name=position_id,proto3" json:"position_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserPosition) Reset() { - *x = UserPosition{} - mi := &file_types_system_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserPosition) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserPosition) ProtoMessage() {} - -func (x *UserPosition) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[20] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserPosition.ProtoReflect.Descriptor instead. -func (*UserPosition) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{20} -} - -func (x *UserPosition) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *UserPosition) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *UserPosition) GetPositionId() int64 { - if x != nil { - return x.PositionId - } - return 0 -} - -// UserPositionEdges holds the relations/edges for other nodes in the graph. -type UserPositionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // Position holds the value of the position edge. - Position *Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserPositionEdges) Reset() { - *x = UserPositionEdges{} - mi := &file_types_system_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserPositionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserPositionEdges) ProtoMessage() {} - -func (x *UserPositionEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[21] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserPositionEdges.ProtoReflect.Descriptor instead. -func (*UserPositionEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{21} -} - -func (x *UserPositionEdges) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserPositionEdges) GetPosition() *Position { - if x != nil { - return x.Position - } - return nil -} - -// position_permission.table.comment -type PositionPermission struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // position_permission.field.position_id - PositionId int64 `protobuf:"varint,2,opt,name=position_id,proto3" json:"position_id,omitempty"` - // position_permission.field.permission_id - PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PositionPermission) Reset() { - *x = PositionPermission{} - mi := &file_types_system_proto_msgTypes[22] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PositionPermission) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PositionPermission) ProtoMessage() {} - -func (x *PositionPermission) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[22] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PositionPermission.ProtoReflect.Descriptor instead. -func (*PositionPermission) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{22} -} - -func (x *PositionPermission) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *PositionPermission) GetPositionId() int64 { - if x != nil { - return x.PositionId - } - return 0 -} - -func (x *PositionPermission) GetPermissionId() int64 { - if x != nil { - return x.PermissionId - } - return 0 -} - -// PositionPermissionEdges holds the relations/edges for other nodes in the graph. -type PositionPermissionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Position holds the value of the position edge. - Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` - // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PositionPermissionEdges) Reset() { - *x = PositionPermissionEdges{} - mi := &file_types_system_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PositionPermissionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PositionPermissionEdges) ProtoMessage() {} - -func (x *PositionPermissionEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[23] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PositionPermissionEdges.ProtoReflect.Descriptor instead. -func (*PositionPermissionEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{23} -} - -func (x *PositionPermissionEdges) GetPosition() *Position { - if x != nil { - return x.Position - } - return nil -} - -func (x *PositionPermissionEdges) GetPermission() *Permission { - if x != nil { - return x.Permission - } - return nil -} - -// role_permission.table.comment -type RolePermission struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // field.foreign_key.comment - RoleId int64 `protobuf:"varint,2,opt,name=role_id,proto3" json:"role_id,omitempty"` - // field.foreign_key.comment - PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RolePermission) Reset() { - *x = RolePermission{} - mi := &file_types_system_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RolePermission) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RolePermission) ProtoMessage() {} - -func (x *RolePermission) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[24] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RolePermission.ProtoReflect.Descriptor instead. -func (*RolePermission) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{24} -} - -func (x *RolePermission) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *RolePermission) GetRoleId() int64 { - if x != nil { - return x.RoleId - } - return 0 -} - -func (x *RolePermission) GetPermissionId() int64 { - if x != nil { - return x.PermissionId - } - return 0 -} - -// RolePermissionEdges holds the relations/edges for other nodes in the graph. -type RolePermissionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RolePermissionEdges) Reset() { - *x = RolePermissionEdges{} - mi := &file_types_system_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RolePermissionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RolePermissionEdges) ProtoMessage() {} - -func (x *RolePermissionEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_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 RolePermissionEdges.ProtoReflect.Descriptor instead. -func (*RolePermissionEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{25} -} - -func (x *RolePermissionEdges) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -func (x *RolePermissionEdges) GetPermission() *Permission { - if x != nil { - return x.Permission - } - return nil -} - -// permission_resource.table.comment -type PermissionResource struct { - state protoimpl.MessageState `protogen:"open.v1"` - // ID of the ent. - // field.primary_key.comment - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // field.foreign_key.comment - PermissionId int64 `protobuf:"varint,2,opt,name=permission_id,proto3" json:"permission_id,omitempty"` - // field.foreign_key.comment - ResourceId int64 `protobuf:"varint,3,opt,name=resource_id,proto3" json:"resource_id,omitempty"` - // permission_resource.field.actions - Actions string `protobuf:"bytes,4,opt,name=actions,proto3" json:"actions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PermissionResource) Reset() { - *x = PermissionResource{} - mi := &file_types_system_proto_msgTypes[26] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PermissionResource) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PermissionResource) ProtoMessage() {} - -func (x *PermissionResource) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[26] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PermissionResource.ProtoReflect.Descriptor instead. -func (*PermissionResource) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{26} -} - -func (x *PermissionResource) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *PermissionResource) GetPermissionId() int64 { - if x != nil { - return x.PermissionId - } - return 0 -} - -func (x *PermissionResource) GetResourceId() int64 { - if x != nil { - return x.ResourceId - } - return 0 -} - -func (x *PermissionResource) GetActions() string { - if x != nil { - return x.Actions - } - return "" -} - -// PermissionResourceEdges holds the relations/edges for other nodes in the graph. -type PermissionResourceEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` - // Resource holds the value of the resource edge. - Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PermissionResourceEdges) Reset() { - *x = PermissionResourceEdges{} - mi := &file_types_system_proto_msgTypes[27] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PermissionResourceEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PermissionResourceEdges) ProtoMessage() {} - -func (x *PermissionResourceEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[27] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PermissionResourceEdges.ProtoReflect.Descriptor instead. -func (*PermissionResourceEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{27} -} - -func (x *PermissionResourceEdges) GetPermission() *Permission { - if x != nil { - return x.Permission - } - return nil -} - -func (x *PermissionResourceEdges) GetResource() *Resource { - if x != nil { - return x.Resource - } - return nil -} - -var File_types_system_proto protoreflect.FileDescriptor - -const file_types_system_proto_rawDesc = "" + - "\n" + - "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xae\x05\n" + - "\x04Menu\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\x05 \x01(\tR\x04name\x12\x1a\n" + - "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12 \n" + - "\vdescription\x18\a \x01(\tR\vdescription\x12\x1a\n" + - "\bsequence\x18\b \x01(\x05R\bsequence\x12\x12\n" + - "\x04type\x18\t \x01(\tR\x04type\x12\x12\n" + - "\x04icon\x18\n" + - " \x01(\tR\x04icon\x12\x12\n" + - "\x04path\x18\v \x01(\tR\x04path\x12\x1e\n" + - "\n" + - "properties\x18\f \x01(\tR\n" + - "properties\x12\x16\n" + - "\x06status\x18\r \x01(\x05R\x06status\x12\x1c\n" + - "\tparent_id\x18\x0e \x01(\x03R\tparent_id\x12 \n" + - "\vparent_path\x18\x0f \x01(\tR\vparent_path\x127\n" + - "\bchildren\x18\x15 \x03(\v2\x1b.api.v1.services.types.MenuR\bchildren\x123\n" + - "\x06parent\x18\x16 \x01(\v2\x1b.api.v1.services.types.MenuR\x06parent\x12=\n" + - "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + - "\x05roles\x18\x18 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xac\x02\n" + - "\tMenuEdges\x127\n" + - "\bchildren\x18\x01 \x03(\v2\x1b.api.v1.services.types.MenuR\bchildren\x123\n" + - "\x06parent\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x06parent\x12=\n" + - "\tresources\x18\x03 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + - "\x05roles\x18\x04 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12?\n" + - "\n" + - "role_menus\x18\x05 \x03(\v2\x1f.api.v1.services.types.RoleMenuR\n" + - "role_menus\"\xfc\x04\n" + - "\x04Role\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\x05 \x01(\tR\x04name\x12 \n" + - "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x12\n" + - "\x04type\x18\a \x01(\x05R\x04type\x12\x1a\n" + - "\bsequence\x18\b \x01(\x05R\bsequence\x12\x16\n" + - "\x06status\x18\t \x01(\x05R\x06status\x12\x1a\n" + - "\bis_types\x18\n" + - " \x01(\bR\bis_types\x121\n" + - "\x05menus\x18\x15 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x121\n" + - "\x05users\x18\x16 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + - "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\"\n" + - "\fresource_ids\x18\x18 \x03(\x03R\fresource_ids\x12C\n" + - "\vpermissions\x18\x19 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12&\n" + - "\x0epermission_ids\x18\x1a \x03(\x03R\x0epermission_ids\"\xf3\x01\n" + - "\tRoleEdges\x121\n" + - "\x05menus\x18\x01 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x121\n" + - "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12?\n" + - "\n" + - "role_menus\x18\x03 \x03(\v2\x1f.api.v1.services.types.RoleMenuR\n" + - "role_menus\x12?\n" + - "\n" + - "user_roles\x18\x04 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + - "user_roles\"\xaa\a\n" + - "\x04User\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + - "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + - "\rupdate_author\x18\x03 \x01(\x03R\rupdate_author\x12<\n" + - "\vcreate_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04uuid\x18\x06 \x01(\tR\x04uuid\x12\x1e\n" + - "\n" + - "allowed_ip\x18\a \x01(\tR\n" + - "allowed_ip\x12\x1a\n" + - "\busername\x18\b \x01(\tR\busername\x12\x1a\n" + - "\bnickname\x18\t \x01(\tR\bnickname\x12\x16\n" + - "\x06avatar\x18\n" + - " \x01(\tR\x06avatar\x12\x12\n" + - "\x04name\x18\v \x01(\tR\x04name\x12\x16\n" + - "\x06gender\x18\f \x01(\tR\x06gender\x12\x1a\n" + - "\bpassword\x18\r \x01(\tR\bpassword\x12*\n" + - "\x10confirm_password\x18\x0e \x01(\tR\x10confirm_password\x12\x12\n" + - "\x04salt\x18\x0f \x01(\tR\x04salt\x12\x14\n" + - "\x05phone\x18\x10 \x01(\tR\x05phone\x12\x14\n" + - "\x05email\x18\x11 \x01(\tR\x05email\x12\x16\n" + - "\x06remark\x18\x12 \x01(\tR\x06remark\x12\x14\n" + - "\x05token\x18\x13 \x01(\tR\x05token\x12\x16\n" + - "\x06status\x18\x14 \x01(\x05R\x06status\x12$\n" + - "\rlast_login_ip\x18\x15 \x01(\tR\rlast_login_ip\x12D\n" + - "\x0flast_login_time\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12E\n" + - "\rsanction_date\x18\x17 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x12\x1e\n" + - "\n" + - "manager_id\x18\x18 \x01(\x03R\n" + - "manager_id\x12\x18\n" + - "\amanager\x18\x19 \x01(\tR\amanager\x121\n" + - "\x05roles\x18\x1a \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + - "\brole_ids\x18\x1b \x03(\x03R\brole_idsB\x10\n" + - "\x0e_sanction_date\"\x7f\n" + - "\tUserEdges\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12?\n" + - "\n" + - "user_roles\x18\x02 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + - "user_roles\"\xca\x02\n" + - "\bUserRole\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\auser_id\x18\x04 \x01(\x03R\auser_id\x12\x18\n" + - "\arole_id\x18\x05 \x01(\x03R\arole_id\x12\x1c\n" + - "\trole_name\x18\x06 \x01(\tR\trole_name\x12/\n" + - "\x04user\x18\x15 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + - "\x04role\x18\x16 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"q\n" + - "\rUserRoleEdges\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + - "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\xac\x02\n" + - "\bRoleMenu\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\arole_id\x18\x04 \x01(\x03R\arole_id\x12\x18\n" + - "\amenu_id\x18\x05 \x01(\x03R\amenu_id\x12/\n" + - "\x04role\x18\x15 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + - "\x04menu\x18\x16 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"q\n" + - "\rRoleMenuEdges\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + - "\x04menu\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"\x8f\a\n" + - "\bResource\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x1a\n" + - "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12\x12\n" + - "\x04type\x18\a \x01(\tR\x04type\x12\x16\n" + - "\x06status\x18\b \x01(\x05R\x06status\x12\x12\n" + - "\x04path\x18\t \x01(\tR\x04path\x12\x1c\n" + - "\toperation\x18\n" + - " \x01(\tR\toperation\x12\x16\n" + - "\x06method\x18\v \x01(\tR\x06method\x12\x1c\n" + - "\tcomponent\x18\f \x01(\tR\tcomponent\x12\x12\n" + - "\x04icon\x18\r \x01(\tR\x04icon\x12\x1a\n" + - "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x18\n" + - "\avisible\x18\x0f \x01(\bR\avisible\x12\x1c\n" + - "\ttree_path\x18\x10 \x01(\tR\ttree_path\x12O\n" + - "\n" + - "properties\x18\x11 \x03(\v2/.api.v1.services.types.Resource.PropertiesEntryR\n" + - "properties\x12 \n" + - "\vdescription\x18\x12 \x01(\tR\vdescription\x12\x1c\n" + - "\tparent_id\x18\x13 \x01(\x03R\tparent_id\x12;\n" + - "\bchildren\x18\x15 \x03(\v2\x1f.api.v1.services.types.ResourceR\bchildren\x127\n" + - "\x06parent\x18\x16 \x01(\v2\x1f.api.v1.services.types.ResourceR\x06parent\x12&\n" + - "\x0epermission_ids\x18\x17 \x03(\x03R\x0epermission_ids\x12C\n" + - "\vpermissions\x18\x18 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x1a=\n" + - "\x0fPropertiesEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"@\n" + - "\rResourceEdges\x12/\n" + - "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"\xe8\x03\n" + - "\n" + - "Department\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\x05 \x01(\tR\x04name\x12\x1c\n" + - "\ttree_path\x18\x06 \x01(\tR\ttree_path\x12\x1a\n" + - "\bsequence\x18\a \x01(\x05R\bsequence\x12\x16\n" + - "\x06status\x18\b \x01(\x05R\x06status\x12\x14\n" + - "\x05level\x18\t \x01(\x05R\x05level\x12 \n" + - "\vdescription\x18\n" + - " \x01(\tR\vdescription\x12\x1c\n" + - "\tparent_id\x18\v \x01(\x03R\tparent_id\x12=\n" + - "\bchildren\x18\f \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + - "\x06parent\x18\r \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\"\xd0\x02\n" + - "\x0fDepartmentEdges\x121\n" + - "\x05users\x18\x01 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + - "\tpositions\x18\x02 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12=\n" + - "\bchildren\x18\x03 \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + - "\x06parent\x18\x04 \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\x12Q\n" + - "\x10user_departments\x18\x05 \x03(\v2%.api.v1.services.types.UserDepartmentR\x10user_departments\"\xa2\x01\n" + - "\x0eUserDepartment\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\auser_id\x18\x02 \x01(\x03R\auser_id\x12$\n" + - "\rdepartment_id\x18\x03 \x01(\x03R\rdepartment_id\x12@\n" + - "\x05edges\x18\x04 \x01(\v2*.api.v1.services.types.UserDepartmentEdgesR\x05edges\"\x89\x01\n" + - "\x13UserDepartmentEdges\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12A\n" + - "\n" + - "department\x18\x02 \x01(\v2!.api.v1.services.types.DepartmentR\n" + - "department\"\x8c\x02\n" + - "\bPosition\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + - "\vdescription\x18\x06 \x01(\tR\vdescription\x12$\n" + - "\rdepartment_id\x18\a \x01(\x03R\rdepartment_id\"\xf6\x02\n" + - "\rPositionEdges\x12A\n" + - "\n" + - "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + - "department\x121\n" + - "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12C\n" + - "\vpermissions\x18\x03 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12K\n" + - "\x0euser_positions\x18\x04 \x03(\v2#.api.v1.services.types.UserPositionR\x0euser_positions\x12]\n" + - "\x14position_permissions\x18\x05 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"\xfb\x03\n" + - "\n" + - "Permission\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + - "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x1e\n" + - "\n" + - "data_scope\x18\a \x01(\tR\n" + - "data_scope\x12P\n" + - "\n" + - "data_rules\x18\b \x03(\v20.api.v1.services.types.Permission.DataRulesEntryR\n" + - "data_rules\x12\"\n" + - "\fresource_ids\x18\t \x03(\x03R\fresource_ids\x12=\n" + - "\tresources\x18\n" + - " \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x1a<\n" + - "\x0eDataRulesEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xd3\x03\n" + - "\x0fPermissionEdges\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12=\n" + - "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12=\n" + - "\tpositions\x18\x03 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12Q\n" + - "\x10role_permissions\x18\x04 \x03(\v2%.api.v1.services.types.RolePermissionR\x10role_permissions\x12]\n" + - "\x14permission_resources\x18\x05 \x03(\v2).api.v1.services.types.PermissionResourceR\x14permission_resources\x12]\n" + - "\x14position_permissions\x18\x06 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"Z\n" + - "\fUserPosition\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\auser_id\x18\x02 \x01(\x03R\auser_id\x12 \n" + - "\vposition_id\x18\x03 \x01(\x03R\vposition_id\"\x81\x01\n" + - "\x11UserPositionEdges\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12;\n" + - "\bposition\x18\x02 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"l\n" + - "\x12PositionPermission\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12 \n" + - "\vposition_id\x18\x02 \x01(\x03R\vposition_id\x12$\n" + - "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x99\x01\n" + - "\x17PositionPermissionEdges\x12;\n" + - "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\x12A\n" + - "\n" + - "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\"`\n" + - "\x0eRolePermission\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\arole_id\x18\x02 \x01(\x03R\arole_id\x12$\n" + - "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x89\x01\n" + - "\x13RolePermissionEdges\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12A\n" + - "\n" + - "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\"\x86\x01\n" + - "\x12PermissionResource\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + - "\rpermission_id\x18\x02 \x01(\x03R\rpermission_id\x12 \n" + - "\vresource_id\x18\x03 \x01(\x03R\vresource_id\x12\x18\n" + - "\aactions\x18\x04 \x01(\tR\aactions\"\x99\x01\n" + - "\x17PermissionResourceEdges\x12A\n" + - "\n" + - "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\x12;\n" + - "\bresource\x18\x02 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresourceB\xd9\x01\n" + - "\x19com.api.v1.services.typesB\vSystemProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" - -var ( - file_types_system_proto_rawDescOnce sync.Once - file_types_system_proto_rawDescData []byte -) - -func file_types_system_proto_rawDescGZIP() []byte { - file_types_system_proto_rawDescOnce.Do(func() { - file_types_system_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_system_proto_rawDesc), len(file_types_system_proto_rawDesc))) - }) - return file_types_system_proto_rawDescData -} - -var file_types_system_proto_msgTypes = make([]protoimpl.MessageInfo, 30) -var file_types_system_proto_goTypes = []any{ - (*Menu)(nil), // 0: api.v1.services.types.Menu - (*MenuEdges)(nil), // 1: api.v1.services.types.MenuEdges - (*Role)(nil), // 2: api.v1.services.types.Role - (*RoleEdges)(nil), // 3: api.v1.services.types.RoleEdges - (*User)(nil), // 4: api.v1.services.types.User - (*UserEdges)(nil), // 5: api.v1.services.types.UserEdges - (*UserRole)(nil), // 6: api.v1.services.types.UserRole - (*UserRoleEdges)(nil), // 7: api.v1.services.types.UserRoleEdges - (*RoleMenu)(nil), // 8: api.v1.services.types.RoleMenu - (*RoleMenuEdges)(nil), // 9: api.v1.services.types.RoleMenuEdges - (*Resource)(nil), // 10: api.v1.services.types.Resource - (*ResourceEdges)(nil), // 11: api.v1.services.types.ResourceEdges - (*Department)(nil), // 12: api.v1.services.types.Department - (*DepartmentEdges)(nil), // 13: api.v1.services.types.DepartmentEdges - (*UserDepartment)(nil), // 14: api.v1.services.types.UserDepartment - (*UserDepartmentEdges)(nil), // 15: api.v1.services.types.UserDepartmentEdges - (*Position)(nil), // 16: api.v1.services.types.Position - (*PositionEdges)(nil), // 17: api.v1.services.types.PositionEdges - (*Permission)(nil), // 18: api.v1.services.types.Permission - (*PermissionEdges)(nil), // 19: api.v1.services.types.PermissionEdges - (*UserPosition)(nil), // 20: api.v1.services.types.UserPosition - (*UserPositionEdges)(nil), // 21: api.v1.services.types.UserPositionEdges - (*PositionPermission)(nil), // 22: api.v1.services.types.PositionPermission - (*PositionPermissionEdges)(nil), // 23: api.v1.services.types.PositionPermissionEdges - (*RolePermission)(nil), // 24: api.v1.services.types.RolePermission - (*RolePermissionEdges)(nil), // 25: api.v1.services.types.RolePermissionEdges - (*PermissionResource)(nil), // 26: api.v1.services.types.PermissionResource - (*PermissionResourceEdges)(nil), // 27: api.v1.services.types.PermissionResourceEdges - nil, // 28: api.v1.services.types.Resource.PropertiesEntry - nil, // 29: api.v1.services.types.Permission.DataRulesEntry - (*timestamppb.Timestamp)(nil), // 30: google.protobuf.Timestamp -} -var file_types_system_proto_depIdxs = []int32{ - 30, // 0: api.v1.services.types.Menu.create_time:type_name -> google.protobuf.Timestamp - 30, // 1: api.v1.services.types.Menu.update_time:type_name -> google.protobuf.Timestamp - 0, // 2: api.v1.services.types.Menu.children:type_name -> api.v1.services.types.Menu - 0, // 3: api.v1.services.types.Menu.parent:type_name -> api.v1.services.types.Menu - 10, // 4: api.v1.services.types.Menu.resources:type_name -> api.v1.services.types.Resource - 2, // 5: api.v1.services.types.Menu.roles:type_name -> api.v1.services.types.Role - 0, // 6: api.v1.services.types.MenuEdges.children:type_name -> api.v1.services.types.Menu - 0, // 7: api.v1.services.types.MenuEdges.parent:type_name -> api.v1.services.types.Menu - 10, // 8: api.v1.services.types.MenuEdges.resources:type_name -> api.v1.services.types.Resource - 2, // 9: api.v1.services.types.MenuEdges.roles:type_name -> api.v1.services.types.Role - 8, // 10: api.v1.services.types.MenuEdges.role_menus:type_name -> api.v1.services.types.RoleMenu - 30, // 11: api.v1.services.types.Role.create_time:type_name -> google.protobuf.Timestamp - 30, // 12: api.v1.services.types.Role.update_time:type_name -> google.protobuf.Timestamp - 0, // 13: api.v1.services.types.Role.menus:type_name -> api.v1.services.types.Menu - 4, // 14: api.v1.services.types.Role.users:type_name -> api.v1.services.types.User - 10, // 15: api.v1.services.types.Role.resources:type_name -> api.v1.services.types.Resource - 18, // 16: api.v1.services.types.Role.permissions:type_name -> api.v1.services.types.Permission - 0, // 17: api.v1.services.types.RoleEdges.menus:type_name -> api.v1.services.types.Menu - 4, // 18: api.v1.services.types.RoleEdges.users:type_name -> api.v1.services.types.User - 8, // 19: api.v1.services.types.RoleEdges.role_menus:type_name -> api.v1.services.types.RoleMenu - 6, // 20: api.v1.services.types.RoleEdges.user_roles:type_name -> api.v1.services.types.UserRole - 30, // 21: api.v1.services.types.User.create_time:type_name -> google.protobuf.Timestamp - 30, // 22: api.v1.services.types.User.update_time:type_name -> google.protobuf.Timestamp - 30, // 23: api.v1.services.types.User.last_login_time:type_name -> google.protobuf.Timestamp - 30, // 24: api.v1.services.types.User.sanction_date:type_name -> google.protobuf.Timestamp - 2, // 25: api.v1.services.types.User.roles:type_name -> api.v1.services.types.Role - 2, // 26: api.v1.services.types.UserEdges.roles:type_name -> api.v1.services.types.Role - 6, // 27: api.v1.services.types.UserEdges.user_roles:type_name -> api.v1.services.types.UserRole - 30, // 28: api.v1.services.types.UserRole.create_time:type_name -> google.protobuf.Timestamp - 30, // 29: api.v1.services.types.UserRole.update_time:type_name -> google.protobuf.Timestamp - 4, // 30: api.v1.services.types.UserRole.user:type_name -> api.v1.services.types.User - 2, // 31: api.v1.services.types.UserRole.role:type_name -> api.v1.services.types.Role - 4, // 32: api.v1.services.types.UserRoleEdges.user:type_name -> api.v1.services.types.User - 2, // 33: api.v1.services.types.UserRoleEdges.role:type_name -> api.v1.services.types.Role - 30, // 34: api.v1.services.types.RoleMenu.create_time:type_name -> google.protobuf.Timestamp - 30, // 35: api.v1.services.types.RoleMenu.update_time:type_name -> google.protobuf.Timestamp - 2, // 36: api.v1.services.types.RoleMenu.role:type_name -> api.v1.services.types.Role - 0, // 37: api.v1.services.types.RoleMenu.menu:type_name -> api.v1.services.types.Menu - 2, // 38: api.v1.services.types.RoleMenuEdges.role:type_name -> api.v1.services.types.Role - 0, // 39: api.v1.services.types.RoleMenuEdges.menu:type_name -> api.v1.services.types.Menu - 30, // 40: api.v1.services.types.Resource.create_time:type_name -> google.protobuf.Timestamp - 30, // 41: api.v1.services.types.Resource.update_time:type_name -> google.protobuf.Timestamp - 28, // 42: api.v1.services.types.Resource.properties:type_name -> api.v1.services.types.Resource.PropertiesEntry - 10, // 43: api.v1.services.types.Resource.children:type_name -> api.v1.services.types.Resource - 10, // 44: api.v1.services.types.Resource.parent:type_name -> api.v1.services.types.Resource - 18, // 45: api.v1.services.types.Resource.permissions:type_name -> api.v1.services.types.Permission - 0, // 46: api.v1.services.types.ResourceEdges.menu:type_name -> api.v1.services.types.Menu - 30, // 47: api.v1.services.types.Department.create_time:type_name -> google.protobuf.Timestamp - 30, // 48: api.v1.services.types.Department.update_time:type_name -> google.protobuf.Timestamp - 12, // 49: api.v1.services.types.Department.children:type_name -> api.v1.services.types.Department - 12, // 50: api.v1.services.types.Department.parent:type_name -> api.v1.services.types.Department - 4, // 51: api.v1.services.types.DepartmentEdges.users:type_name -> api.v1.services.types.User - 16, // 52: api.v1.services.types.DepartmentEdges.positions:type_name -> api.v1.services.types.Position - 12, // 53: api.v1.services.types.DepartmentEdges.children:type_name -> api.v1.services.types.Department - 12, // 54: api.v1.services.types.DepartmentEdges.parent:type_name -> api.v1.services.types.Department - 14, // 55: api.v1.services.types.DepartmentEdges.user_departments:type_name -> api.v1.services.types.UserDepartment - 15, // 56: api.v1.services.types.UserDepartment.edges:type_name -> api.v1.services.types.UserDepartmentEdges - 4, // 57: api.v1.services.types.UserDepartmentEdges.user:type_name -> api.v1.services.types.User - 12, // 58: api.v1.services.types.UserDepartmentEdges.department:type_name -> api.v1.services.types.Department - 30, // 59: api.v1.services.types.Position.create_time:type_name -> google.protobuf.Timestamp - 30, // 60: api.v1.services.types.Position.update_time:type_name -> google.protobuf.Timestamp - 12, // 61: api.v1.services.types.PositionEdges.department:type_name -> api.v1.services.types.Department - 4, // 62: api.v1.services.types.PositionEdges.users:type_name -> api.v1.services.types.User - 18, // 63: api.v1.services.types.PositionEdges.permissions:type_name -> api.v1.services.types.Permission - 20, // 64: api.v1.services.types.PositionEdges.user_positions:type_name -> api.v1.services.types.UserPosition - 22, // 65: api.v1.services.types.PositionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission - 30, // 66: api.v1.services.types.Permission.create_time:type_name -> google.protobuf.Timestamp - 30, // 67: api.v1.services.types.Permission.update_time:type_name -> google.protobuf.Timestamp - 29, // 68: api.v1.services.types.Permission.data_rules:type_name -> api.v1.services.types.Permission.DataRulesEntry - 10, // 69: api.v1.services.types.Permission.resources:type_name -> api.v1.services.types.Resource - 2, // 70: api.v1.services.types.PermissionEdges.roles:type_name -> api.v1.services.types.Role - 10, // 71: api.v1.services.types.PermissionEdges.resources:type_name -> api.v1.services.types.Resource - 16, // 72: api.v1.services.types.PermissionEdges.positions:type_name -> api.v1.services.types.Position - 24, // 73: api.v1.services.types.PermissionEdges.role_permissions:type_name -> api.v1.services.types.RolePermission - 26, // 74: api.v1.services.types.PermissionEdges.permission_resources:type_name -> api.v1.services.types.PermissionResource - 22, // 75: api.v1.services.types.PermissionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission - 4, // 76: api.v1.services.types.UserPositionEdges.user:type_name -> api.v1.services.types.User - 16, // 77: api.v1.services.types.UserPositionEdges.position:type_name -> api.v1.services.types.Position - 16, // 78: api.v1.services.types.PositionPermissionEdges.position:type_name -> api.v1.services.types.Position - 18, // 79: api.v1.services.types.PositionPermissionEdges.permission:type_name -> api.v1.services.types.Permission - 2, // 80: api.v1.services.types.RolePermissionEdges.role:type_name -> api.v1.services.types.Role - 18, // 81: api.v1.services.types.RolePermissionEdges.permission:type_name -> api.v1.services.types.Permission - 18, // 82: api.v1.services.types.PermissionResourceEdges.permission:type_name -> api.v1.services.types.Permission - 10, // 83: api.v1.services.types.PermissionResourceEdges.resource:type_name -> api.v1.services.types.Resource - 84, // [84:84] is the sub-list for method output_type - 84, // [84:84] is the sub-list for method input_type - 84, // [84:84] is the sub-list for extension type_name - 84, // [84:84] is the sub-list for extension extendee - 0, // [0:84] is the sub-list for field type_name -} - -func init() { file_types_system_proto_init() } -func file_types_system_proto_init() { - if File_types_system_proto != nil { - return - } - file_types_system_proto_msgTypes[4].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_system_proto_rawDesc), len(file_types_system_proto_rawDesc)), - NumEnums: 0, - NumMessages: 30, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_types_system_proto_goTypes, - DependencyIndexes: file_types_system_proto_depIdxs, - MessageInfos: file_types_system_proto_msgTypes, - }.Build() - File_types_system_proto = out.File - file_types_system_proto_goTypes = nil - file_types_system_proto_depIdxs = nil -} diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go deleted file mode 100644 index f9a8dc81..00000000 --- a/api/v1/services/types/system.pb.validate.go +++ /dev/null @@ -1,5600 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: types/system.proto - -package types - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on Menu 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 *Menu) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Menu 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 MenuMultiError, or nil if none found. -func (m *Menu) ValidateAll() error { - return m.validate(true) -} - -func (m *Menu) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Keyword - - // no validation rules for Name - - // no validation rules for I18NKey - - // no validation rules for Description - - // no validation rules for Sequence - - // no validation rules for Type - - // no validation rules for Icon - - // no validation rules for Path - - // no validation rules for Properties - - // no validation rules for Status - - // no validation rules for ParentId - - // no validation rules for ParentPath - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return MenuMultiError(errors) - } - - return nil -} - -// MenuMultiError is an error wrapping multiple validation errors returned by -// Menu.ValidateAll() if the designated constraints aren't met. -type MenuMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m MenuMultiError) 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 MenuMultiError) AllErrors() []error { return m } - -// MenuValidationError is the validation error returned by Menu.Validate if the -// designated constraints aren't met. -type MenuValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e MenuValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e MenuValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e MenuValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e MenuValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e MenuValidationError) ErrorName() string { return "MenuValidationError" } - -// Error satisfies the builtin error interface -func (e MenuValidationError) 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 %sMenu.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = MenuValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = MenuValidationError{} - -// Validate checks the field values on MenuEdges 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 *MenuEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on MenuEdges 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 MenuEdgesMultiError, or nil -// if none found. -func (m *MenuEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *MenuEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoleMenus() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return MenuEdgesMultiError(errors) - } - - return nil -} - -// MenuEdgesMultiError is an error wrapping multiple validation errors returned -// by MenuEdges.ValidateAll() if the designated constraints aren't met. -type MenuEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m MenuEdgesMultiError) 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 MenuEdgesMultiError) AllErrors() []error { return m } - -// MenuEdgesValidationError is the validation error returned by -// MenuEdges.Validate if the designated constraints aren't met. -type MenuEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e MenuEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e MenuEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e MenuEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e MenuEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e MenuEdgesValidationError) ErrorName() string { return "MenuEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e MenuEdgesValidationError) 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 %sMenuEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = MenuEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = MenuEdgesValidationError{} - -// Validate checks the field values on Role 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 *Role) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Role 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 RoleMultiError, or nil if none found. -func (m *Role) ValidateAll() error { - return m.validate(true) -} - -func (m *Role) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Keyword - - // no validation rules for Name - - // no validation rules for Description - - // no validation rules for Type - - // no validation rules for Sequence - - // no validation rules for Status - - // no validation rules for IsTypes - - for idx, item := range m.GetMenus() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return RoleMultiError(errors) - } - - return nil -} - -// RoleMultiError is an error wrapping multiple validation errors returned by -// Role.ValidateAll() if the designated constraints aren't met. -type RoleMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RoleMultiError) 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 RoleMultiError) AllErrors() []error { return m } - -// RoleValidationError is the validation error returned by Role.Validate if the -// designated constraints aren't met. -type RoleValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RoleValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RoleValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RoleValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RoleValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RoleValidationError) ErrorName() string { return "RoleValidationError" } - -// Error satisfies the builtin error interface -func (e RoleValidationError) 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 %sRole.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RoleValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RoleValidationError{} - -// Validate checks the field values on RoleEdges 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 *RoleEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RoleEdges 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 RoleEdgesMultiError, or nil -// if none found. -func (m *RoleEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *RoleEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetMenus() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoleMenus() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUserRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return RoleEdgesMultiError(errors) - } - - return nil -} - -// RoleEdgesMultiError is an error wrapping multiple validation errors returned -// by RoleEdges.ValidateAll() if the designated constraints aren't met. -type RoleEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RoleEdgesMultiError) 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 RoleEdgesMultiError) AllErrors() []error { return m } - -// RoleEdgesValidationError is the validation error returned by -// RoleEdges.Validate if the designated constraints aren't met. -type RoleEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RoleEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RoleEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RoleEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RoleEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RoleEdgesValidationError) ErrorName() string { return "RoleEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e RoleEdgesValidationError) 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 %sRoleEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RoleEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RoleEdgesValidationError{} - -// Validate checks the field values on User 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 *User) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on User 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 UserMultiError, or nil if none found. -func (m *User) ValidateAll() error { - return m.validate(true) -} - -func (m *User) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for CreateAuthor - - // no validation rules for UpdateAuthor - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Uuid - - // no validation rules for AllowedIp - - // no validation rules for Username - - // no validation rules for Nickname - - // no validation rules for Avatar - - // no validation rules for Name - - // no validation rules for Gender - - // no validation rules for Password - - // no validation rules for ConfirmPassword - - // no validation rules for Salt - - // no validation rules for Phone - - // no validation rules for Email - - // no validation rules for Remark - - // no validation rules for Token - - // no validation rules for Status - - // no validation rules for LastLoginIp - - if all { - switch v := interface{}(m.GetLastLoginTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserValidationError{ - field: "LastLoginTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserValidationError{ - field: "LastLoginTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetLastLoginTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserValidationError{ - field: "LastLoginTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for ManagerId - - // no validation rules for Manager - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if m.SanctionDate != nil { - - if all { - switch v := interface{}(m.GetSanctionDate()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserValidationError{ - field: "SanctionDate", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserValidationError{ - field: "SanctionDate", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetSanctionDate()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserValidationError{ - field: "SanctionDate", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return UserMultiError(errors) - } - - return nil -} - -// UserMultiError is an error wrapping multiple validation errors returned by -// User.ValidateAll() if the designated constraints aren't met. -type UserMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserMultiError) 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 UserMultiError) AllErrors() []error { return m } - -// UserValidationError is the validation error returned by User.Validate if the -// designated constraints aren't met. -type UserValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserValidationError) ErrorName() string { return "UserValidationError" } - -// Error satisfies the builtin error interface -func (e UserValidationError) 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 %sUser.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserValidationError{} - -// Validate checks the field values on UserEdges 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 *UserEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserEdges 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 UserEdgesMultiError, or nil -// if none found. -func (m *UserEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUserRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return UserEdgesMultiError(errors) - } - - return nil -} - -// UserEdgesMultiError is an error wrapping multiple validation errors returned -// by UserEdges.ValidateAll() if the designated constraints aren't met. -type UserEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserEdgesMultiError) 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 UserEdgesMultiError) AllErrors() []error { return m } - -// UserEdgesValidationError is the validation error returned by -// UserEdges.Validate if the designated constraints aren't met. -type UserEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserEdgesValidationError) ErrorName() string { return "UserEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e UserEdgesValidationError) 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 %sUserEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserEdgesValidationError{} - -// Validate checks the field values on UserRole 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 *UserRole) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserRole 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 UserRoleMultiError, or nil -// if none found. -func (m *UserRole) ValidateAll() error { - return m.validate(true) -} - -func (m *UserRole) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for UserId - - // no validation rules for RoleId - - // no validation rules for RoleName - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserRoleMultiError(errors) - } - - return nil -} - -// UserRoleMultiError is an error wrapping multiple validation errors returned -// by UserRole.ValidateAll() if the designated constraints aren't met. -type UserRoleMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserRoleMultiError) 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 UserRoleMultiError) AllErrors() []error { return m } - -// UserRoleValidationError is the validation error returned by -// UserRole.Validate if the designated constraints aren't met. -type UserRoleValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserRoleValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserRoleValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserRoleValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserRoleValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserRoleValidationError) ErrorName() string { return "UserRoleValidationError" } - -// Error satisfies the builtin error interface -func (e UserRoleValidationError) 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 %sUserRole.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserRoleValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserRoleValidationError{} - -// Validate checks the field values on UserRoleEdges 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 *UserRoleEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserRoleEdges 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 UserRoleEdgesMultiError, or -// nil if none found. -func (m *UserRoleEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserRoleEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserRoleEdgesMultiError(errors) - } - - return nil -} - -// UserRoleEdgesMultiError is an error wrapping multiple validation errors -// returned by UserRoleEdges.ValidateAll() if the designated constraints -// aren't met. -type UserRoleEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserRoleEdgesMultiError) 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 UserRoleEdgesMultiError) AllErrors() []error { return m } - -// UserRoleEdgesValidationError is the validation error returned by -// UserRoleEdges.Validate if the designated constraints aren't met. -type UserRoleEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserRoleEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserRoleEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserRoleEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserRoleEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserRoleEdgesValidationError) ErrorName() string { return "UserRoleEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e UserRoleEdgesValidationError) 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 %sUserRoleEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserRoleEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserRoleEdgesValidationError{} - -// Validate checks the field values on RoleMenu 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 *RoleMenu) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RoleMenu 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 RoleMenuMultiError, or nil -// if none found. -func (m *RoleMenu) ValidateAll() error { - return m.validate(true) -} - -func (m *RoleMenu) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for RoleId - - // no validation rules for MenuId - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RoleMenuMultiError(errors) - } - - return nil -} - -// RoleMenuMultiError is an error wrapping multiple validation errors returned -// by RoleMenu.ValidateAll() if the designated constraints aren't met. -type RoleMenuMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RoleMenuMultiError) 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 RoleMenuMultiError) AllErrors() []error { return m } - -// RoleMenuValidationError is the validation error returned by -// RoleMenu.Validate if the designated constraints aren't met. -type RoleMenuValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RoleMenuValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RoleMenuValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RoleMenuValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RoleMenuValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RoleMenuValidationError) ErrorName() string { return "RoleMenuValidationError" } - -// Error satisfies the builtin error interface -func (e RoleMenuValidationError) 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 %sRoleMenu.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RoleMenuValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RoleMenuValidationError{} - -// Validate checks the field values on RoleMenuEdges 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 *RoleMenuEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RoleMenuEdges 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 RoleMenuEdgesMultiError, or -// nil if none found. -func (m *RoleMenuEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *RoleMenuEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleMenuEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RoleMenuEdgesMultiError(errors) - } - - return nil -} - -// RoleMenuEdgesMultiError is an error wrapping multiple validation errors -// returned by RoleMenuEdges.ValidateAll() if the designated constraints -// aren't met. -type RoleMenuEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RoleMenuEdgesMultiError) 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 RoleMenuEdgesMultiError) AllErrors() []error { return m } - -// RoleMenuEdgesValidationError is the validation error returned by -// RoleMenuEdges.Validate if the designated constraints aren't met. -type RoleMenuEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RoleMenuEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RoleMenuEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RoleMenuEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RoleMenuEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RoleMenuEdgesValidationError) ErrorName() string { return "RoleMenuEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e RoleMenuEdgesValidationError) 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 %sRoleMenuEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RoleMenuEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RoleMenuEdgesValidationError{} - -// Validate checks the field values on Resource 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 *Resource) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Resource 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 ResourceMultiError, or nil -// if none found. -func (m *Resource) ValidateAll() error { - return m.validate(true) -} - -func (m *Resource) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Name - - // no validation rules for Keyword - - // no validation rules for I18NKey - - // no validation rules for Type - - // no validation rules for Status - - // no validation rules for Path - - // no validation rules for Operation - - // no validation rules for Method - - // no validation rules for Component - - // no validation rules for Icon - - // no validation rules for Sequence - - // no validation rules for Visible - - // no validation rules for TreePath - - // no validation rules for Properties - - // no validation rules for Description - - // no validation rules for ParentId - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ResourceMultiError(errors) - } - - return nil -} - -// ResourceMultiError is an error wrapping multiple validation errors returned -// by Resource.ValidateAll() if the designated constraints aren't met. -type ResourceMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResourceMultiError) 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 ResourceMultiError) AllErrors() []error { return m } - -// ResourceValidationError is the validation error returned by -// Resource.Validate if the designated constraints aren't met. -type ResourceValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResourceValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResourceValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResourceValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResourceValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResourceValidationError) ErrorName() string { return "ResourceValidationError" } - -// Error satisfies the builtin error interface -func (e ResourceValidationError) 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 %sResource.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResourceValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResourceValidationError{} - -// Validate checks the field values on ResourceEdges 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 *ResourceEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ResourceEdges 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 ResourceEdgesMultiError, or -// nil if none found. -func (m *ResourceEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *ResourceEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceEdgesValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ResourceEdgesMultiError(errors) - } - - return nil -} - -// ResourceEdgesMultiError is an error wrapping multiple validation errors -// returned by ResourceEdges.ValidateAll() if the designated constraints -// aren't met. -type ResourceEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResourceEdgesMultiError) 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 ResourceEdgesMultiError) AllErrors() []error { return m } - -// ResourceEdgesValidationError is the validation error returned by -// ResourceEdges.Validate if the designated constraints aren't met. -type ResourceEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResourceEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResourceEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResourceEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResourceEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResourceEdgesValidationError) ErrorName() string { return "ResourceEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e ResourceEdgesValidationError) 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 %sResourceEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResourceEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResourceEdgesValidationError{} - -// Validate checks the field values on Department 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 *Department) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Department 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 DepartmentMultiError, or -// nil if none found. -func (m *Department) ValidateAll() error { - return m.validate(true) -} - -func (m *Department) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Keyword - - // no validation rules for Name - - // no validation rules for TreePath - - // no validation rules for Sequence - - // no validation rules for Status - - // no validation rules for Level - - // no validation rules for Description - - // no validation rules for ParentId - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DepartmentMultiError(errors) - } - - return nil -} - -// DepartmentMultiError is an error wrapping multiple validation errors -// returned by Department.ValidateAll() if the designated constraints aren't met. -type DepartmentMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DepartmentMultiError) 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 DepartmentMultiError) AllErrors() []error { return m } - -// DepartmentValidationError is the validation error returned by -// Department.Validate if the designated constraints aren't met. -type DepartmentValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DepartmentValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DepartmentValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DepartmentValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DepartmentValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DepartmentValidationError) ErrorName() string { return "DepartmentValidationError" } - -// Error satisfies the builtin error interface -func (e DepartmentValidationError) 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 %sDepartment.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DepartmentValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DepartmentValidationError{} - -// Validate checks the field values on DepartmentEdges 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 *DepartmentEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DepartmentEdges 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 -// DepartmentEdgesMultiError, or nil if none found. -func (m *DepartmentEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *DepartmentEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetUserDepartments() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("UserDepartments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("UserDepartments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("UserDepartments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return DepartmentEdgesMultiError(errors) - } - - return nil -} - -// DepartmentEdgesMultiError is an error wrapping multiple validation errors -// returned by DepartmentEdges.ValidateAll() if the designated constraints -// aren't met. -type DepartmentEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DepartmentEdgesMultiError) 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 DepartmentEdgesMultiError) AllErrors() []error { return m } - -// DepartmentEdgesValidationError is the validation error returned by -// DepartmentEdges.Validate if the designated constraints aren't met. -type DepartmentEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DepartmentEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DepartmentEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DepartmentEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DepartmentEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DepartmentEdgesValidationError) ErrorName() string { return "DepartmentEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e DepartmentEdgesValidationError) 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 %sDepartmentEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DepartmentEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DepartmentEdgesValidationError{} - -// Validate checks the field values on UserDepartment 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 *UserDepartment) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserDepartment 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 UserDepartmentMultiError, -// or nil if none found. -func (m *UserDepartment) ValidateAll() error { - return m.validate(true) -} - -func (m *UserDepartment) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for UserId - - // no validation rules for DepartmentId - - if all { - switch v := interface{}(m.GetEdges()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserDepartmentValidationError{ - field: "Edges", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserDepartmentValidationError{ - field: "Edges", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEdges()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserDepartmentValidationError{ - field: "Edges", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserDepartmentMultiError(errors) - } - - return nil -} - -// UserDepartmentMultiError is an error wrapping multiple validation errors -// returned by UserDepartment.ValidateAll() if the designated constraints -// aren't met. -type UserDepartmentMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserDepartmentMultiError) 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 UserDepartmentMultiError) AllErrors() []error { return m } - -// UserDepartmentValidationError is the validation error returned by -// UserDepartment.Validate if the designated constraints aren't met. -type UserDepartmentValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserDepartmentValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserDepartmentValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserDepartmentValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserDepartmentValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserDepartmentValidationError) ErrorName() string { return "UserDepartmentValidationError" } - -// Error satisfies the builtin error interface -func (e UserDepartmentValidationError) 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 %sUserDepartment.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserDepartmentValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserDepartmentValidationError{} - -// Validate checks the field values on UserDepartmentEdges 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 *UserDepartmentEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserDepartmentEdges 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 -// UserDepartmentEdgesMultiError, or nil if none found. -func (m *UserDepartmentEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserDepartmentEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserDepartmentEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserDepartmentEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserDepartmentEdgesMultiError(errors) - } - - return nil -} - -// UserDepartmentEdgesMultiError is an error wrapping multiple validation -// errors returned by UserDepartmentEdges.ValidateAll() if the designated -// constraints aren't met. -type UserDepartmentEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserDepartmentEdgesMultiError) 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 UserDepartmentEdgesMultiError) AllErrors() []error { return m } - -// UserDepartmentEdgesValidationError is the validation error returned by -// UserDepartmentEdges.Validate if the designated constraints aren't met. -type UserDepartmentEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserDepartmentEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserDepartmentEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserDepartmentEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserDepartmentEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserDepartmentEdgesValidationError) ErrorName() string { - return "UserDepartmentEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e UserDepartmentEdgesValidationError) 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 %sUserDepartmentEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserDepartmentEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserDepartmentEdgesValidationError{} - -// Validate checks the field values on Position 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 *Position) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Position 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 PositionMultiError, or nil -// if none found. -func (m *Position) ValidateAll() error { - return m.validate(true) -} - -func (m *Position) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Name - - // no validation rules for Keyword - - // no validation rules for Description - - // no validation rules for DepartmentId - - if len(errors) > 0 { - return PositionMultiError(errors) - } - - return nil -} - -// PositionMultiError is an error wrapping multiple validation errors returned -// by Position.ValidateAll() if the designated constraints aren't met. -type PositionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionMultiError) 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 PositionMultiError) AllErrors() []error { return m } - -// PositionValidationError is the validation error returned by -// Position.Validate if the designated constraints aren't met. -type PositionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PositionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PositionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PositionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PositionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PositionValidationError) ErrorName() string { return "PositionValidationError" } - -// Error satisfies the builtin error interface -func (e PositionValidationError) 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 %sPosition.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PositionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PositionValidationError{} - -// Validate checks the field values on PositionEdges 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 *PositionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PositionEdges 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 PositionEdgesMultiError, or -// nil if none found. -func (m *PositionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *PositionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUserPositions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("UserPositions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("UserPositions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("UserPositions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositionPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return PositionEdgesMultiError(errors) - } - - return nil -} - -// PositionEdgesMultiError is an error wrapping multiple validation errors -// returned by PositionEdges.ValidateAll() if the designated constraints -// aren't met. -type PositionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionEdgesMultiError) 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 PositionEdgesMultiError) AllErrors() []error { return m } - -// PositionEdgesValidationError is the validation error returned by -// PositionEdges.Validate if the designated constraints aren't met. -type PositionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PositionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PositionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PositionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PositionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PositionEdgesValidationError) ErrorName() string { return "PositionEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e PositionEdgesValidationError) 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 %sPositionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PositionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PositionEdgesValidationError{} - -// Validate checks the field values on Permission 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 *Permission) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Permission 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 PermissionMultiError, or -// nil if none found. -func (m *Permission) ValidateAll() error { - return m.validate(true) -} - -func (m *Permission) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Name - - // no validation rules for Keyword - - // no validation rules for Description - - // no validation rules for DataScope - - // no validation rules for DataRules - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return PermissionMultiError(errors) - } - - return nil -} - -// PermissionMultiError is an error wrapping multiple validation errors -// returned by Permission.ValidateAll() if the designated constraints aren't met. -type PermissionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PermissionMultiError) 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 PermissionMultiError) AllErrors() []error { return m } - -// PermissionValidationError is the validation error returned by -// Permission.Validate if the designated constraints aren't met. -type PermissionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PermissionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PermissionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PermissionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PermissionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PermissionValidationError) ErrorName() string { return "PermissionValidationError" } - -// Error satisfies the builtin error interface -func (e PermissionValidationError) 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 %sPermission.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PermissionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PermissionValidationError{} - -// Validate checks the field values on PermissionEdges 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 *PermissionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PermissionEdges 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 -// PermissionEdgesMultiError, or nil if none found. -func (m *PermissionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *PermissionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRolePermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("RolePermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("RolePermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("RolePermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPermissionResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PermissionResources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PermissionResources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("PermissionResources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositionPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return PermissionEdgesMultiError(errors) - } - - return nil -} - -// PermissionEdgesMultiError is an error wrapping multiple validation errors -// returned by PermissionEdges.ValidateAll() if the designated constraints -// aren't met. -type PermissionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PermissionEdgesMultiError) 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 PermissionEdgesMultiError) AllErrors() []error { return m } - -// PermissionEdgesValidationError is the validation error returned by -// PermissionEdges.Validate if the designated constraints aren't met. -type PermissionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PermissionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PermissionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PermissionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PermissionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PermissionEdgesValidationError) ErrorName() string { return "PermissionEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e PermissionEdgesValidationError) 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 %sPermissionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PermissionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PermissionEdgesValidationError{} - -// Validate checks the field values on UserPosition 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 *UserPosition) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserPosition 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 UserPositionMultiError, or -// nil if none found. -func (m *UserPosition) ValidateAll() error { - return m.validate(true) -} - -func (m *UserPosition) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for UserId - - // no validation rules for PositionId - - if len(errors) > 0 { - return UserPositionMultiError(errors) - } - - return nil -} - -// UserPositionMultiError is an error wrapping multiple validation errors -// returned by UserPosition.ValidateAll() if the designated constraints aren't met. -type UserPositionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserPositionMultiError) 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 UserPositionMultiError) AllErrors() []error { return m } - -// UserPositionValidationError is the validation error returned by -// UserPosition.Validate if the designated constraints aren't met. -type UserPositionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserPositionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserPositionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserPositionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserPositionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserPositionValidationError) ErrorName() string { return "UserPositionValidationError" } - -// Error satisfies the builtin error interface -func (e UserPositionValidationError) 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 %sUserPosition.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserPositionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserPositionValidationError{} - -// Validate checks the field values on UserPositionEdges 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 *UserPositionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserPositionEdges 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 -// UserPositionEdgesMultiError, or nil if none found. -func (m *UserPositionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserPositionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserPositionEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetPosition()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserPositionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserPositionEdgesMultiError(errors) - } - - return nil -} - -// UserPositionEdgesMultiError is an error wrapping multiple validation errors -// returned by UserPositionEdges.ValidateAll() if the designated constraints -// aren't met. -type UserPositionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserPositionEdgesMultiError) 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 UserPositionEdgesMultiError) AllErrors() []error { return m } - -// UserPositionEdgesValidationError is the validation error returned by -// UserPositionEdges.Validate if the designated constraints aren't met. -type UserPositionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserPositionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserPositionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserPositionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserPositionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserPositionEdgesValidationError) ErrorName() string { - return "UserPositionEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e UserPositionEdgesValidationError) 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 %sUserPositionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserPositionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserPositionEdgesValidationError{} - -// Validate checks the field values on PositionPermission 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 *PositionPermission) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PositionPermission 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 -// PositionPermissionMultiError, or nil if none found. -func (m *PositionPermission) ValidateAll() error { - return m.validate(true) -} - -func (m *PositionPermission) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for PositionId - - // no validation rules for PermissionId - - if len(errors) > 0 { - return PositionPermissionMultiError(errors) - } - - return nil -} - -// PositionPermissionMultiError is an error wrapping multiple validation errors -// returned by PositionPermission.ValidateAll() if the designated constraints -// aren't met. -type PositionPermissionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionPermissionMultiError) 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 PositionPermissionMultiError) AllErrors() []error { return m } - -// PositionPermissionValidationError is the validation error returned by -// PositionPermission.Validate if the designated constraints aren't met. -type PositionPermissionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PositionPermissionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PositionPermissionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PositionPermissionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PositionPermissionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PositionPermissionValidationError) ErrorName() string { - return "PositionPermissionValidationError" -} - -// Error satisfies the builtin error interface -func (e PositionPermissionValidationError) 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 %sPositionPermission.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PositionPermissionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PositionPermissionValidationError{} - -// Validate checks the field values on PositionPermissionEdges 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 *PositionPermissionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PositionPermissionEdges 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 -// PositionPermissionEdgesMultiError, or nil if none found. -func (m *PositionPermissionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *PositionPermissionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPosition()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionPermissionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionPermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return PositionPermissionEdgesMultiError(errors) - } - - return nil -} - -// PositionPermissionEdgesMultiError is an error wrapping multiple validation -// errors returned by PositionPermissionEdges.ValidateAll() if the designated -// constraints aren't met. -type PositionPermissionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionPermissionEdgesMultiError) 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 PositionPermissionEdgesMultiError) AllErrors() []error { return m } - -// PositionPermissionEdgesValidationError is the validation error returned by -// PositionPermissionEdges.Validate if the designated constraints aren't met. -type PositionPermissionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PositionPermissionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PositionPermissionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PositionPermissionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PositionPermissionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PositionPermissionEdgesValidationError) ErrorName() string { - return "PositionPermissionEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e PositionPermissionEdgesValidationError) 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 %sPositionPermissionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PositionPermissionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PositionPermissionEdgesValidationError{} - -// Validate checks the field values on RolePermission 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 *RolePermission) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RolePermission 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 RolePermissionMultiError, -// or nil if none found. -func (m *RolePermission) ValidateAll() error { - return m.validate(true) -} - -func (m *RolePermission) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for RoleId - - // no validation rules for PermissionId - - if len(errors) > 0 { - return RolePermissionMultiError(errors) - } - - return nil -} - -// RolePermissionMultiError is an error wrapping multiple validation errors -// returned by RolePermission.ValidateAll() if the designated constraints -// aren't met. -type RolePermissionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RolePermissionMultiError) 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 RolePermissionMultiError) AllErrors() []error { return m } - -// RolePermissionValidationError is the validation error returned by -// RolePermission.Validate if the designated constraints aren't met. -type RolePermissionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RolePermissionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RolePermissionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RolePermissionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RolePermissionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RolePermissionValidationError) ErrorName() string { return "RolePermissionValidationError" } - -// Error satisfies the builtin error interface -func (e RolePermissionValidationError) 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 %sRolePermission.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RolePermissionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RolePermissionValidationError{} - -// Validate checks the field values on RolePermissionEdges 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 *RolePermissionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RolePermissionEdges 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 -// RolePermissionEdgesMultiError, or nil if none found. -func (m *RolePermissionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *RolePermissionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RolePermissionEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RolePermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RolePermissionEdgesMultiError(errors) - } - - return nil -} - -// RolePermissionEdgesMultiError is an error wrapping multiple validation -// errors returned by RolePermissionEdges.ValidateAll() if the designated -// constraints aren't met. -type RolePermissionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RolePermissionEdgesMultiError) 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 RolePermissionEdgesMultiError) AllErrors() []error { return m } - -// RolePermissionEdgesValidationError is the validation error returned by -// RolePermissionEdges.Validate if the designated constraints aren't met. -type RolePermissionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RolePermissionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RolePermissionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RolePermissionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RolePermissionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RolePermissionEdgesValidationError) ErrorName() string { - return "RolePermissionEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e RolePermissionEdgesValidationError) 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 %sRolePermissionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RolePermissionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RolePermissionEdgesValidationError{} - -// Validate checks the field values on PermissionResource 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 *PermissionResource) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PermissionResource 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 -// PermissionResourceMultiError, or nil if none found. -func (m *PermissionResource) ValidateAll() error { - return m.validate(true) -} - -func (m *PermissionResource) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for PermissionId - - // no validation rules for ResourceId - - // no validation rules for Actions - - if len(errors) > 0 { - return PermissionResourceMultiError(errors) - } - - return nil -} - -// PermissionResourceMultiError is an error wrapping multiple validation errors -// returned by PermissionResource.ValidateAll() if the designated constraints -// aren't met. -type PermissionResourceMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PermissionResourceMultiError) 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 PermissionResourceMultiError) AllErrors() []error { return m } - -// PermissionResourceValidationError is the validation error returned by -// PermissionResource.Validate if the designated constraints aren't met. -type PermissionResourceValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PermissionResourceValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PermissionResourceValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PermissionResourceValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PermissionResourceValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PermissionResourceValidationError) ErrorName() string { - return "PermissionResourceValidationError" -} - -// Error satisfies the builtin error interface -func (e PermissionResourceValidationError) 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 %sPermissionResource.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PermissionResourceValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PermissionResourceValidationError{} - -// Validate checks the field values on PermissionResourceEdges 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 *PermissionResourceEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PermissionResourceEdges 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 -// PermissionResourceEdgesMultiError, or nil if none found. -func (m *PermissionResourceEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *PermissionResourceEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionResourceEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetResource()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionResourceEdgesValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return PermissionResourceEdgesMultiError(errors) - } - - return nil -} - -// PermissionResourceEdgesMultiError is an error wrapping multiple validation -// errors returned by PermissionResourceEdges.ValidateAll() if the designated -// constraints aren't met. -type PermissionResourceEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PermissionResourceEdgesMultiError) 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 PermissionResourceEdgesMultiError) AllErrors() []error { return m } - -// PermissionResourceEdgesValidationError is the validation error returned by -// PermissionResourceEdges.Validate if the designated constraints aren't met. -type PermissionResourceEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PermissionResourceEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PermissionResourceEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PermissionResourceEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PermissionResourceEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PermissionResourceEdgesValidationError) ErrorName() string { - return "PermissionResourceEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e PermissionResourceEdgesValidationError) 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 %sPermissionResourceEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PermissionResourceEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PermissionResourceEdgesValidationError{} diff --git a/api/v1/services/types/system_error.pb.go b/api/v1/services/types/system_error.pb.go deleted file mode 100644 index 39371eb2..00000000 --- a/api/v1/services/types/system_error.pb.go +++ /dev/null @@ -1,195 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: types/system_error.proto - -package types - -import ( - _ "github.com/go-kratos/kratos/v2/errors" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type SystemErrorReason int32 - -const ( - SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED SystemErrorReason = 0 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND SystemErrorReason = 2001 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS SystemErrorReason = 2002 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN SystemErrorReason = 2003 - SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT SystemErrorReason = 2004 - SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED SystemErrorReason = 2005 - SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND SystemErrorReason = 2006 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN SystemErrorReason = 2007 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS SystemErrorReason = 2008 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION SystemErrorReason = 2009 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION SystemErrorReason = 2010 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST SystemErrorReason = 2011 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE SystemErrorReason = 2012 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER SystemErrorReason = 2013 - SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND SystemErrorReason = 3001 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID SystemErrorReason = 3002 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE SystemErrorReason = 3003 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME SystemErrorReason = 3005 - SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD SystemErrorReason = 3006 -) - -// Enum value maps for SystemErrorReason. -var ( - SystemErrorReason_name = map[int32]string{ - 0: "SYSTEM_ERROR_REASON_UNSPECIFIED", - 2001: "SYSTEM_ERROR_REASON_USER_NOT_FOUND", - 2002: "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS", - 2003: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN", - 2004: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT", - 2005: "SYSTEM_ERROR_REASON_TOKEN_EXPIRED", - 2006: "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND", - 2007: "SYSTEM_ERROR_REASON_INVALID_TOKEN", - 2008: "SYSTEM_ERROR_REASON_INVALID_CLAIMS", - 2009: "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION", - 2010: "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION", - 2011: "SYSTEM_ERROR_REASON_INVALID_REQUEST", - 2012: "SYSTEM_ERROR_REASON_INVALID_RESPONSE", - 2013: "SYSTEM_ERROR_REASON_INVALID_SERVER", - 3001: "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND", - 3002: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID", - 3003: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE", - 3005: "SYSTEM_ERROR_REASON_INVALID_USERNAME", - 3006: "SYSTEM_ERROR_REASON_INVALID_PASSWORD", - } - SystemErrorReason_value = map[string]int32{ - "SYSTEM_ERROR_REASON_UNSPECIFIED": 0, - "SYSTEM_ERROR_REASON_USER_NOT_FOUND": 2001, - "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS": 2002, - "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN": 2003, - "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT": 2004, - "SYSTEM_ERROR_REASON_TOKEN_EXPIRED": 2005, - "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND": 2006, - "SYSTEM_ERROR_REASON_INVALID_TOKEN": 2007, - "SYSTEM_ERROR_REASON_INVALID_CLAIMS": 2008, - "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION": 2009, - "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION": 2010, - "SYSTEM_ERROR_REASON_INVALID_REQUEST": 2011, - "SYSTEM_ERROR_REASON_INVALID_RESPONSE": 2012, - "SYSTEM_ERROR_REASON_INVALID_SERVER": 2013, - "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND": 3001, - "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID": 3002, - "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE": 3003, - "SYSTEM_ERROR_REASON_INVALID_USERNAME": 3005, - "SYSTEM_ERROR_REASON_INVALID_PASSWORD": 3006, - } -) - -func (x SystemErrorReason) Enum() *SystemErrorReason { - p := new(SystemErrorReason) - *p = x - return p -} - -func (x SystemErrorReason) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SystemErrorReason) Descriptor() protoreflect.EnumDescriptor { - return file_types_system_error_proto_enumTypes[0].Descriptor() -} - -func (SystemErrorReason) Type() protoreflect.EnumType { - return &file_types_system_error_proto_enumTypes[0] -} - -func (x SystemErrorReason) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use SystemErrorReason.Descriptor instead. -func (SystemErrorReason) EnumDescriptor() ([]byte, []int) { - return file_types_system_error_proto_rawDescGZIP(), []int{0} -} - -var File_types_system_error_proto protoreflect.FileDescriptor - -const file_types_system_error_proto_rawDesc = "" + - "\n" + - "\x18types/system_error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*\xbf\a\n" + - "\x11SystemErrorReason\x12#\n" + - "\x1fSYSTEM_ERROR_REASON_UNSPECIFIED\x10\x00\x12-\n" + - "\"SYSTEM_ERROR_REASON_USER_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x122\n" + - "'SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS\x10\xd2\x0f\x1a\x04\xa8E\x99\x03\x121\n" + - "&SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN\x10\xd3\x0f\x1a\x04\xa8E\x91\x03\x122\n" + - "'SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT\x10\xd4\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + - "!SYSTEM_ERROR_REASON_TOKEN_EXPIRED\x10\xd5\x0f\x1a\x04\xa8E\x91\x03\x12.\n" + - "#SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND\x10\xd6\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + - "!SYSTEM_ERROR_REASON_INVALID_TOKEN\x10\xd7\x0f\x1a\x04\xa8E\x91\x03\x12-\n" + - "\"SYSTEM_ERROR_REASON_INVALID_CLAIMS\x10\xd8\x0f\x1a\x04\xa8E\x91\x03\x125\n" + - "*SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION\x10\xd9\x0f\x1a\x04\xa8E\x91\x03\x124\n" + - ")SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION\x10\xda\x0f\x1a\x04\xa8E\x93\x03\x12.\n" + - "#SYSTEM_ERROR_REASON_INVALID_REQUEST\x10\xdb\x0f\x1a\x04\xa8E\x90\x03\x12/\n" + - "$SYSTEM_ERROR_REASON_INVALID_RESPONSE\x10\xdc\x0f\x1a\x04\xa8E\xf4\x03\x12-\n" + - "\"SYSTEM_ERROR_REASON_INVALID_SERVER\x10\xdd\x0f\x1a\x04\xa8E\xf4\x03\x123\n" + - "(SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND\x10\xb9\x17\x1a\x04\xa8E\x94\x03\x121\n" + - "&SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID\x10\xba\x17\x1a\x04\xa8E\x90\x03\x123\n" + - "(SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE\x10\xbb\x17\x1a\x04\xa8E\x90\x03\x12/\n" + - "$SYSTEM_ERROR_REASON_INVALID_USERNAME\x10\xbd\x17\x1a\x04\xa8E\x90\x03\x12/\n" + - "$SYSTEM_ERROR_REASON_INVALID_PASSWORD\x10\xbe\x17\x1a\x04\xa8E\x90\x03\x1a\x04\xa0E\xf4\x03B\xde\x01\n" + - "\x19com.api.v1.services.typesB\x10SystemErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" - -var ( - file_types_system_error_proto_rawDescOnce sync.Once - file_types_system_error_proto_rawDescData []byte -) - -func file_types_system_error_proto_rawDescGZIP() []byte { - file_types_system_error_proto_rawDescOnce.Do(func() { - file_types_system_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_system_error_proto_rawDesc), len(file_types_system_error_proto_rawDesc))) - }) - return file_types_system_error_proto_rawDescData -} - -var file_types_system_error_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_types_system_error_proto_goTypes = []any{ - (SystemErrorReason)(0), // 0: api.v1.services.types.SystemErrorReason -} -var file_types_system_error_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_types_system_error_proto_init() } -func file_types_system_error_proto_init() { - if File_types_system_error_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_system_error_proto_rawDesc), len(file_types_system_error_proto_rawDesc)), - NumEnums: 1, - NumMessages: 0, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_types_system_error_proto_goTypes, - DependencyIndexes: file_types_system_error_proto_depIdxs, - EnumInfos: file_types_system_error_proto_enumTypes, - }.Build() - File_types_system_error_proto = out.File - file_types_system_error_proto_goTypes = nil - file_types_system_error_proto_depIdxs = nil -} diff --git a/api/v1/services/types/system_error.pb.validate.go b/api/v1/services/types/system_error.pb.validate.go deleted file mode 100644 index ffc4ec92..00000000 --- a/api/v1/services/types/system_error.pb.validate.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: types/system_error.proto - -package types - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) diff --git a/api/v1/services/types/system_error_errors.pb.go b/api/v1/services/types/system_error_errors.pb.go deleted file mode 100644 index b5fa9310..00000000 --- a/api/v1/services/types/system_error_errors.pb.go +++ /dev/null @@ -1,240 +0,0 @@ -// Code generated by protoc-gen-go-errors. DO NOT EDIT. - -package types - -import ( - fmt "fmt" - errors "github.com/go-kratos/kratos/v2/errors" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -const _ = errors.SupportPackageIsVersion1 - -func IsSystemErrorReasonUnspecified(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 -} - -func ErrorSystemErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { - return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserNotFound(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String() && e.Code == 404 -} - -func ErrorSystemErrorReasonUserNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserAlreadyExists(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String() && e.Code == 409 -} - -func ErrorSystemErrorReasonUserAlreadyExists(format string, args ...interface{}) *errors.Error { - return errors.New(409, SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserNotLoggedIn(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonUserNotLoggedIn(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonUserNotLoggedOut(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonUserNotLoggedOut(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonTokenExpired(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonTokenNotFound(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonTokenNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidToken(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonInvalidToken(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidClaims(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonInvalidClaims(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidAuthentication(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String() && e.Code == 401 -} - -func ErrorSystemErrorReasonInvalidAuthentication(format string, args ...interface{}) *errors.Error { - return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidAuthorization(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String() && e.Code == 403 -} - -func ErrorSystemErrorReasonInvalidAuthorization(format string, args ...interface{}) *errors.Error { - return errors.New(403, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidRequest(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidRequest(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidResponse(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String() && e.Code == 500 -} - -func ErrorSystemErrorReasonInvalidResponse(format string, args ...interface{}) *errors.Error { - return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidServer(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String() && e.Code == 500 -} - -func ErrorSystemErrorReasonInvalidServer(format string, args ...interface{}) *errors.Error { - return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonCaptchaIdNotFound(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String() && e.Code == 404 -} - -func ErrorSystemErrorReasonCaptchaIdNotFound(format string, args ...interface{}) *errors.Error { - return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidCaptchaId(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidCaptchaId(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidCaptchaCode(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidCaptchaCode(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidUsername(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidUsername(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), fmt.Sprintf(format, args...)) -} - -func IsSystemErrorReasonInvalidPassword(err error) bool { - if err == nil { - return false - } - e := errors.FromError(err) - return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String() && e.Code == 400 -} - -func ErrorSystemErrorReasonInvalidPassword(format string, args ...interface{}) *errors.Error { - return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), fmt.Sprintf(format, args...)) -} diff --git a/buf.lock b/buf.lock index fef6ea1f..008f0975 100644 --- a/buf.lock +++ b/buf.lock @@ -8,14 +8,17 @@ deps: commit: 087bc8072ce44e339f213209e4d57bf0 digest: b5:c4eebcd04bc2fdd5dd0b8d695eb419682a650b600cdb56ff2ed61208a24603e0eb1b8ae0d467925c69a24bde6d322f3c4112bd2b8efdd682d8c3128384cdac9a - name: buf.build/googleapis/googleapis - commit: 61b203b9a9164be9a834f58c37be6f62 - digest: b5:7811a98b35bd2e4ae5c3ac73c8b3d9ae429f3a790da15de188dc98fc2b77d6bb10e45711f14903af9553fa9821dff256054f2e4b7795789265bc476bec2f088c + commit: 004180b77378443887d3b55cabc00384 + digest: b5:e8f475fe3330f31f5fd86ac689093bcd274e19611a09db91f41d637cb9197881ce89882b94d13a58738e53c91c6e4bae7dc1feba85f590164c975a89e25115dc - name: buf.build/kratos/apis commit: c2de25f14fa445a79a054214f31d17a8 digest: b5:3e4dac0d26ce9db17309aeb845f0efb38ec7db1af06ee3c6b8dce2f4f7f53f126d62233c4910410384ead7f0a0edb6448cb389e62d1e3da5e927c3a980828f0b + - name: buf.build/origadmin/contrib + commit: 07f4502d733e4f55a9f1e1726b5717e2 + digest: b5:cf6505bb8ba0973c6e3327626689e68533410f26354f27af916339fb6b2cd1ce39b7a6efe023d67d5fa2184785a6c1f6959c7ea1b1aef496fa4ea25a98e72d16 - name: buf.build/origadmin/runtime - commit: 67cc18c9322e48e78a0282fb854970bb - digest: b5:8d14f8cf309734eddd71f02c03b7c2612542fe1935ecc3329c5d2c949dec14f098360cf610a9d03e35ccb764740f37090b5c228b04ff3be539861a4cd39ed617 + commit: 7e6455be0f4e46b2bae60c64017ea644 + digest: b5:e7f88ce9864519fe26d98d2424587a94a6a771fbfd0711da75a597a2e8b8bcb51db619456245b558c60ebc8662fa4aeeb0d867b3412c299f833f82100770ce3e - name: buf.build/protocolbuffers/wellknowntypes - commit: 3ddd61d1f53d485abd3d3a2b47a62b8e - digest: b5:09e4405493fa16fef2af6b667fcaea9d2280ec44ed4943eddb96fb5a32daa1e8a353331dd4ef33b7df3783d17e912a703d57b73b236cd749d6a87ce83f60e2c9 + commit: 9220c3cb4fac4bb4a8587d4fd7aa7582 + digest: b5:412c81d3f1549cc9ef52b364a11ab41d9ea6ba5e8e22a2b3f1f614c180b991a76503d715574e94ff77e33f216a1614a8026f1fc01aeaefdaf701155cb125e8bc diff --git a/cmd/auth/wire.go b/cmd/auth/wire.go index e6c69ff3..a9addaa2 100644 --- a/cmd/auth/wire.go +++ b/cmd/auth/wire.go @@ -15,10 +15,10 @@ import ( "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/data" - authbiz "origadmin/application/admin/internal/mods/auth/biz" - authdal "origadmin/application/admin/internal/mods/auth/dal" - authserver "origadmin/application/admin/internal/mods/auth/server" - authservice "origadmin/application/admin/internal/mods/auth/service" + authbiz "origadmin/application/admin/internal/features/auth/biz" // Corrected import path + authdal "origadmin/application/admin/internal/features/auth/dal" // Corrected import path + authserver "origadmin/application/admin/internal/features/auth/server" // Corrected import path + authservice "origadmin/application/admin/internal/features/auth/service" // Corrected import path ) // buildInjectors init kratos application. diff --git a/cmd/auth/wire_gen.go b/cmd/auth/wire_gen.go index 5534ae47..33a6d386 100644 --- a/cmd/auth/wire_gen.go +++ b/cmd/auth/wire_gen.go @@ -11,10 +11,10 @@ import ( "github.com/origadmin/runtime" "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/mods/auth/biz" - "origadmin/application/admin/internal/mods/auth/dal" - "origadmin/application/admin/internal/mods/auth/server" - "origadmin/application/admin/internal/mods/auth/service" + "origadmin/application/admin/internal/features/auth/biz" // Corrected import path + "origadmin/application/admin/internal/features/auth/dal" // Corrected import path + "origadmin/application/admin/internal/features/auth/server" // Corrected import path + "origadmin/application/admin/internal/features/auth/service" // Corrected import path ) import ( diff --git a/cmd/internal/start/start.go b/cmd/gateway/main.go similarity index 77% rename from cmd/internal/start/start.go rename to cmd/gateway/main.go index 178fd305..f7397a7c 100644 --- a/cmd/internal/start/start.go +++ b/cmd/gateway/main.go @@ -2,32 +2,33 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package start is the start command for the application. -package start +// Package main is the main entry point for the gateway application. +package main import ( "context" "fmt" "log/slog" + "os" "github.com/go-kratos/kratos/v2" "github.com/go-kratos/kratos/v2/encoding" "github.com/go-kratos/kratos/v2/middleware/tracing" + "github.com/go-kratos/kratos/v2/transport" "github.com/goexts/generic/cmp" + "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - middlewarev1 "github.com/origadmin/runtime/api/gen/go/middleware/v1" + middlewarev1 "github.com/origadmin/runtime/api/gen/go/config/middleware/v1" "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/config" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/codec/toml" - "github.com/spf13/cobra" + "origadmin/application/admin/internal/conf" // Updated import // _ "origadmin/application/admin/contrib/consul/config" // Removed // _ "origadmin/application/admin/contrib/consul/registry" // Removed // _ "origadmin/application/admin/contrib/database/drivers" // Removed - _ "github.com/origadmin/backend/internal/data/entity/ent/runtime" // Updated import - "github.com/origadmin/backend/internal/conf" // Updated import + _ "origadmin/application/admin/internal/data/entity/ent/runtime" // Updated import ) const ( @@ -48,29 +49,11 @@ var ( flags = bootstrap.New() ) -var cmd = &cobra.Command{ - Use: "start", - Short: "start the server", - RunE: startCommandRun, -} - func init() { encoding.RegisterCodec(toml.Codec) flags.SetServiceInfo(Name, Version) } -// Cmd The function defines a CLI command to start a server with various flags and options, including the -// ability to run as a daemon. -func Cmd() *cobra.Command { - cmd.Flags().BoolP(startRandom, "r", false, "start with random password") - cmd.Flags().StringP(startConfig, "c", "bootstrap.toml", - "runtime configuration files or directory (relative to workdir, multiple separated by commas)") - cmd.Flags().StringP(startStatic, "s", "", "static files directory") - cmd.Flags().BoolP(startDebug, "d", false, "set debug mode, eg: --debug") - cmd.Flags().Bool(startDaemon, false, "run as a daemon") - return cmd -} - // ResolvedBootstrap implements config.Resolver for the application's bootstrap configuration. type ResolvedBootstrap struct { bootstrap *conf.Bootstrap @@ -126,11 +109,17 @@ func (r *ResolvedBootstrap) Logger() *configv1.Logger { return r.bootstrap.GetLogger() } -func startCommandRun(cmd *cobra.Command, args []string) error { - debug, err := cmd.Flags().GetBool(startDebug) - if err != nil { - debug = false +func main() { + // Simplified flag parsing for demonstration, replace with actual flag parsing if needed + // For now, hardcode debug mode for testing, or use os.Args to parse + debug := false // Default to false + for _, arg := range os.Args { + if arg == "--debug" || arg == "-d" { + debug = true + break + } } + if debug { flags.SetEnv("debug") flags.SetConfigPath("resources/configs/bootstrap.toml") // Updated path @@ -145,9 +134,10 @@ func startCommandRun(cmd *cobra.Command, args []string) error { rb := &ResolvedBootstrap{ bootstrap: &conf.Bootstrap{}, // Initialize with new conf.Bootstrap } - r, err := runtime.Load(flags, runtime.WithResolver(rb), runtime.WithContext(cmd.Context())) + r, err := runtime.Load(flags, runtime.WithResolver(rb), runtime.WithContext(context.Background())) // Use context.Background() as no cobra.Command context if err != nil { - return err + ll.Errorf("failed to load runtime: %v", err) + os.Exit(1) } rb.FillServiceInfo(flags) r = r.WithLoggerAttrs( @@ -161,14 +151,14 @@ func startCommandRun(cmd *cobra.Command, args []string) error { ) app, clean, err := buildInjectors(r, rb.bootstrap) // Use rb.bootstrap if err != nil { - return err + ll.Errorf("failed to build injectors: %v", err) + os.Exit(1) } defer clean() if err := app.Run(); err != nil { - return err + ll.Errorf("application run failed: %v", err) + os.Exit(1) } - - return nil } func NewApp(r runtime.Runtime, servers []transport.Server) *kratos.App { diff --git a/cmd/internal/start/wire.go b/cmd/gateway/wire.go similarity index 61% rename from cmd/internal/start/wire.go rename to cmd/gateway/wire.go index a6ba65db..95a0a4c9 100644 --- a/cmd/internal/start/wire.go +++ b/cmd/gateway/wire.go @@ -6,23 +6,25 @@ */ // The build tag makes sure the stub is not built in the final build. -package start +package main import ( "github.com/go-kratos/kratos/v2" "github.com/google/wire" + "github.com/origadmin/runtime" "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/loader" - authbiz "origadmin/application/admin/internal/mods/auth/biz" - authdal "origadmin/application/admin/internal/mods/auth/dal" - authservice "origadmin/application/admin/internal/mods/auth/service" - "origadmin/application/admin/internal/mods/gateway" - systembiz "origadmin/application/admin/internal/mods/system/biz" - systemdal "origadmin/application/admin/internal/mods/system/dal" - systemservice "origadmin/application/admin/internal/mods/system/service" + authbiz "origadmin/application/admin/internal/features/auth/biz" // Corrected import path + authdal "origadmin/application/admin/internal/features/auth/dal" // Corrected import path + authservice "origadmin/application/admin/internal/features/auth/service" // Corrected import path + "origadmin/application/admin/internal/features/gateway" // Corrected import path + systembiz "origadmin/application/admin/internal/features/system/biz" // Corrected import path + systemdal "origadmin/application/admin/internal/features/system/dal" // Corrected import path + systemservice "origadmin/application/admin/internal/features/system/service" // Corrected import path + + "origadmin/application/admin/internal/data" ) // buildInjectors init kratos application. diff --git a/cmd/internal/start/wire.work.go b/cmd/internal/start/wire.work.go deleted file mode 100644 index 1a00c30d..00000000 --- a/cmd/internal/start/wire.work.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build !wireinject && GOWORK -// +build !wireinject,GOWORK - -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// The build tag makes sure the stub is not built in the final build. -// -//go:generate go run github.com/google/wire/cmd/wire -package start diff --git a/cmd/internal/start/wire_gen.go b/cmd/internal/start/wire_gen.go deleted file mode 100644 index b21abf97..00000000 --- a/cmd/internal/start/wire_gen.go +++ /dev/null @@ -1,112 +0,0 @@ -// Code generated by Wire. DO NOT EDIT. - -//go:generate go run -mod=mod github.com/google/wire/cmd/wire -//go:build !wireinject -// +build !wireinject - -package start - -import ( - "github.com/go-kratos/kratos/v2" - "github.com/origadmin/runtime" - "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/loader" - "origadmin/application/admin/internal/mods/auth/biz" - "origadmin/application/admin/internal/mods/auth/dal" - "origadmin/application/admin/internal/mods/auth/service" - "origadmin/application/admin/internal/mods/gateway" - biz2 "origadmin/application/admin/internal/mods/system/biz" - dal2 "origadmin/application/admin/internal/mods/system/dal" - service2 "origadmin/application/admin/internal/mods/system/service" -) - -import ( - _ "origadmin/application/admin/contrib/consul/config" - _ "origadmin/application/admin/contrib/consul/registry" - _ "origadmin/application/admin/contrib/database" - _ "origadmin/application/admin/internal/data/entity/ent/runtime" -) - -// Injectors from wire.go: - -// buildInjectors init kratos application. -func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { - dataData, cleanup, err := data.NewData(r, bootstrap) - if err != nil { - return nil, nil, err - } - casbinSourceRepo, err := dal.NewCasbinSourceRepo(dataData) - if err != nil { - cleanup() - return nil, nil, err - } - casbinSourceServiceBiz := biz.NewCasbinSourceServiceBiz(r, casbinSourceRepo) - ruleSource := service.NewCasbinSourceBiz(r, casbinSourceServiceBiz) - resourceRepo := dal2.NewResourceRepo(r, dataData) - resourceServiceBiz := biz2.NewResourceServiceBiz(r, resourceRepo) - resourceServiceServer := service2.NewResourceServiceServerPB(r, resourceServiceBiz) - roleRepo := dal2.NewRoleRepo(r, dataData) - roleServiceBiz := biz2.NewRoleServiceBiz(r, roleRepo) - roleServiceServer := service2.NewRoleServiceServerPB(r, roleServiceBiz) - userRepo := dal2.NewUserRepo(r, dataData) - userServiceBiz := biz2.NewUserServiceBiz(r, userRepo) - userServiceServer := service2.NewUserServiceServerPB(r, userServiceBiz) - permissionRepo := dal2.NewPermissionRepo(r, dataData) - permissionServiceBiz := biz2.NewPermissionServiceBiz(r, permissionRepo) - permissionServiceServer := service2.NewPermissionServiceServerPB(r, permissionServiceBiz) - systemServerRegistrar := service2.NewRegisterBridgeServer(r, resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) - authRepo := dal.NewAuthRepo(r, dataData) - authServiceBiz := biz.NewAuthServiceBiz(r, authRepo) - authServiceServer := service.NewAuthServiceServerPB(authServiceBiz) - casbinSourceServiceServer := service.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) - tokenizer, err := data.NewTokenizer(bootstrap) - if err != nil { - cleanup() - return nil, nil, err - } - refreshTokenizer := dal.RefreshTokenizer(tokenizer) - loginData := data.NewLoginData(bootstrap, refreshTokenizer) - loginRepo := dal.NewLoginRepo(dataData, loginData) - loginServiceBiz := biz.NewLoginServiceBiz(r, loginRepo) - loginServiceServer := service.NewLoginServiceServerPB(loginServiceBiz) - personalRepo := dal.NewPersonalRepo(r, dataData) - personalServiceBiz := biz.NewPersonalServiceBiz(r, personalRepo) - personalServiceServer := service.NewPersonalServiceServerPB(r, personalServiceBiz) - authServerRegistrar := service.NewRegisterBridgeServer(r, authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) - v := loader.NewServiceServerRegistrars(systemServerRegistrar, authServerRegistrar) - proxyOptions, err := gateway.NewProxyOptions(r, bootstrap, ruleSource, v) - if err != nil { - cleanup() - return nil, nil, err - } - v2 := gateway.NewProxyServer(r, bootstrap, proxyOptions) - app := NewApp(r, v2) - return app, func() { - cleanup() - }, nil -} - -func buildRemoteInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { - v := gateway.NewProxyGRPCClients(r, bootstrap) - ruleSource := service.NewCasbinSourceClient(r, v) - resourceServiceServer := service2.NewResourceServiceBridgeClient(r, v) - roleServiceServer := service2.NewRoleServiceBridgeClient(r, v) - userServiceServer := service2.NewUserServiceBridgeClient(r, v) - permissionServiceServer := service2.NewPermissionServiceBridgeClient(r, v) - systemServerRegistrar := service2.NewRegisterBridgeServer(r, resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) - authServiceServer := service.NewAuthServiceBridgeClient(r, v) - casbinSourceServiceServer := service.NewCasbinServiceBridgeClient(r, v) - loginServiceServer := service.NewLoginServiceBridgeClient(r, v) - personalServiceServer := service.NewPersonalServiceBridgeClient(r, v) - authServerRegistrar := service.NewRegisterBridgeServer(r, authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) - v2 := loader.NewServiceServerRegistrars(systemServerRegistrar, authServerRegistrar) - proxyOptions, err := gateway.NewProxyOptions(r, bootstrap, ruleSource, v2) - if err != nil { - return nil, nil, err - } - v3 := gateway.NewProxyServer(r, bootstrap, proxyOptions) - app := NewApp(r, v3) - return app, func() { - }, nil -} diff --git a/cmd/system/main.go b/cmd/system/main.go index 6fbb63ce..b83fad24 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -5,74 +5,90 @@ package main import ( - "log/slog" - "os" + "flag" + "log" - goversion "github.com/caarlos0/go-version" - "github.com/go-kratos/kratos/v2/encoding" - "github.com/origadmin/runtime/bootstrap" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/codec/toml" + "github.com/go-kratos/kratos/v2" + "github.com/go-kratos/kratos/v2/transport" + "github.com/joho/godotenv" + _ "github.com/sqlite3ent/sqlite3" // Import for sqlite3 driver - _ "github.com/origadmin/backend/internal/data/entity/ent/runtime" // Updated import - "origadmin/application/admin/cmd/internal/start" // Import the start command + _ "github.com/origadmin/contrib/config/consul" + _ "github.com/origadmin/contrib/registry/consul" + "github.com/origadmin/runtime" + runtimebootstrap "github.com/origadmin/runtime/bootstrap" + "origadmin/application/admin/internal/conf" // Corrected import path + confhelper "origadmin/application/admin/internal/helpers/conf" ) -// go build -ldflags "-X main.Version=vx.y.z -X main.Name=origadmin.service.system.v1" var ( - // Name is the Name of the compiled software. + // Name is the name of the compiled software. Name = "origadmin.service.system.v1" - // Version is the Version of the compiled software. + // Version is the version of the compiled software. Version = "v1.0.0" - // flags are the bootstrap flags. - flags = bootstrap.New() - - version = "" - commit = "" - treeState = "" - date = "" - builtBy = "" + + // flagconf is the config flag. + flagconf string ) -func buildVersion(version, commit, date, builtBy, treeState string) goversion.Info { - return goversion.GetVersionInfo( - goversion.WithAppDetails(Name, "System Service", ""), // Use Name for app details - func(i *goversion.Info) { - if commit != "" { - i.GitCommit = commit - } - if version != "" { - i.GitVersion = version - } - if treeState != "" { - i.GitTreeState = treeState - } - if date != "" { - i.BuildDate = date - } - if builtBy != "" { - i.BuiltBy = builtBy - } - }, - ) +func init() { + // The config path should be the directory containing configuration files. + // The default is empty, so we can detect if the user has provided it. + flag.StringVar(&flagconf, "conf", "", "config path, eg: -conf bootstrap.yaml") } -func init() { - encoding.RegisterCodec(toml.Codec) - flags.SetServiceInfo(Name, Version) +func NewApp(r *runtime.App, servers ...transport.Server) *kratos.App { // Changed runtime.Runtime to *runtime.App + return kratos.New( + kratos.ID(r.AppInfo().ID()), + kratos.Name(r.AppInfo().Name()), + kratos.Version(r.AppInfo().Version()), + kratos.Metadata(r.AppInfo().Metadata()), + kratos.Logger(r.Logger()), + kratos.Server( + servers..., + ), + ) } func main() { - // Initialize cobra command for the system service - rootCmd := start.Cmd() - rootCmd.Use = "system" - rootCmd.Short = "System service for OrigAdmin backend." + // Load .env file for local development from resources directory. + // It's safe to ignore the error, as the file may not exist in production. + _ = godotenv.Load("resources/.env.system") + + flag.Parse() + + confPath := confhelper.FindConfPath(flagconf) + if confPath == "" { + log.Fatalf("Could not find configuration file. Searched -conf flag, executable path, and development path.") + } + + // Log the config path for debugging + log.Printf("Loading configuration from: %s\n", confPath) + + // NewFromBootstrap handles config loading, logging, and container setup. + rt := runtime.New(Name, Version) + err := rt.Load(confPath, runtimebootstrap.WithConfigTransformer(conf.New())) + if err != nil { + log.Fatalf("failed to create runtime: %v", err) + } + defer rt.Config().Close() + log.Printf("Starting %s %s (ID: %s)\n", rt.AppInfo().Name(), rt.AppInfo().Version(), rt.AppInfo().ID()) - info := buildVersion(version, commit, date, builtBy, treeState) - rootCmd.Version = info.String() + // Get bootstrap config + bootstrapConfig, ok := rt.StructuredConfig().(*conf.Config) // Changed *configs.Bootstrap to *conf.Config + if !ok { + log.Fatalf("failed to get bootstrap config") + } + + // wireApp now takes the runtime instance and builds the kratos app. + app, cleanupApp, err := wireApp(rt, bootstrapConfig) // Pass bootstrapConfig + if err != nil { + log.Fatalf("failed to wire app: %v", err) + } + defer cleanupApp() - if err := rootCmd.Execute(); err != nil { - slog.Error("failed to execute system service command", "error", err) - os.Exit(1) + // Run the application + if err := app.Run(); err != nil { + log.Fatalf("app run failed: %v", err) } } diff --git a/cmd/system/wire.go b/cmd/system/wire.go index 680ec4f5..c5a8c3b1 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -11,20 +11,21 @@ package main import ( "github.com/go-kratos/kratos/v2" "github.com/google/wire" + "github.com/origadmin/runtime" - "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/data" - systembiz "origadmin/application/admin/internal/mods/system/biz" - systemdal "origadmin/application/admin/internal/mods/system/dal" - systemserver "origadmin/application/admin/internal/mods/system/server" - systemservice "origadmin/application/admin/internal/mods/system/service" + "origadmin/application/admin/internal/conf" + "origadmin/application/admin/internal/data" // Added missing import for data package + systembiz "origadmin/application/admin/internal/features/system/biz" + systemdal "origadmin/application/admin/internal/features/system/dal" + systemserver "origadmin/application/admin/internal/features/system/server" + systemservice "origadmin/application/admin/internal/features/system/service" ) -// buildInjectors init kratos application. -func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { +// wireApp init kratos application. +func wireApp(r *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { panic(wire.Build( - //loader.ProviderSet, + //loader.ProviderSet, // Uncomment if loader.ProviderSet is needed data.ProviderSet, systemdal.ProviderSet, systembiz.ProviderSet, diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index 5f4ba22c..f8f7962c 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -6,28 +6,27 @@ package main -import ( - "github.com/go-kratos/kratos/v2" - "github.com/origadmin/runtime" - "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/mods/system/biz" - "origadmin/application/admin/internal/mods/system/dal" - "origadmin/application/admin/internal/mods/system/server" - "origadmin/application/admin/internal/mods/system/service" -) - import ( _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" + + "github.com/go-kratos/kratos/v2" + + "github.com/origadmin/runtime" + confpb "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/data" _ "origadmin/application/admin/internal/data/entity/ent/runtime" + "origadmin/application/admin/internal/features/system/biz" + "origadmin/application/admin/internal/features/system/dal" + "origadmin/application/admin/internal/features/system/server" + "origadmin/application/admin/internal/features/system/service" ) // Injectors from wire.go: // buildInjectors init kratos application. -func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { +func buildInjectors(r *runtime.App, bootstrap *confpb.Bootstrap) (*kratos.App, func(), error) { dataData, cleanup, err := data.NewData(r, bootstrap) if err != nil { return nil, nil, err diff --git a/generate.go b/generate.go deleted file mode 100644 index 9e6945eb..00000000 --- a/generate.go +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package main is the main package -package main - -//go:generate buf dep update -//go:generate buf build -//go:generate buf generate - -//go:generate protoc -I. -I./third_party --go_out=paths=source_relative:. ./helpers/resp/data/v1/*.proto - -// for linux or macos you can use make generate -// for windows you can use make this generate - -//generate helloworld proto file -// if you want to generate the client code to the same directory, please use the following command -////go:generate kratos proto client -p=../third_party . - -//=paths=source_relative:. outputs to the same directory with the proto file -////go:generate protoc -I. -I../third_party --go_out=. --go-http_out=. --go-grpc_out=. --validate_out=lang=go:. --go-gins_out=. ./v1/proto/helloworld/*.proto - -//// generate *.pb.go -////go:generate protoc -I. -I./third_party --go_out=. ./api/v1/proto/helloworld/*.proto -//// generate *_http.pb.go -////go:generate protoc -I. -I./third_party --go-http_out=. ./api/v1/proto/helloworld/*.proto -//// generate *_grpc.pb.go -////go:generate protoc -I. -I./third_party --go-grpc_out=. ./api/v1/proto/helloworld/*.proto -//// generate *_gins.pb.go -////go:generate protoc -I. -I./third_party --go-gins_out=. ./api/v1/proto/helloworld/*.proto -//// generate *_errors.pb.go -////go:generate protoc -I. -I./third_party --go-errors_out=. ./api/v1/proto/helloworld/*.proto -//// generate *.pb.validate.go - -//// generate openapi.yaml -////go:generate protoc -I. -I./third_party --openapi_out=naming=proto,fq_schema_naming=true,default_response=false:api/v1/services ./api/v1/proto/helloworld/*.proto - -// generate a greeter server template -// kratos proto server -t ./internal/agent api/v1/proto/system/menu.proto -// kratos proto server -t ./internal/agent api/v1/proto/system/role.proto -// kratos proto server -t ./internal/agent api/v1/proto/system/user.proto diff --git a/go.mod b/go.mod index a21e1089..aedc9f5a 100644 --- a/go.mod +++ b/go.mod @@ -1,179 +1,201 @@ module origadmin/application/admin -go 1.23.1 +go 1.25.3 replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0.5.4 +replace github.com/origadmin/toolkits/i18n v0.0.0 => ../../toolkits/i18n + require ( - entgo.io/ent v0.14.4 - github.com/caarlos0/go-version v0.2.0 - github.com/casbin/casbin/v2 v2.105.0 - github.com/dchest/uniuri v1.2.0 - github.com/denisenkom/go-mssqldb v0.12.3 + entgo.io/ent v0.14.5 + github.com/casbin/casbin/v2 v2.134.0 github.com/envoyproxy/protoc-gen-validate v1.2.1 - github.com/gin-gonic/gin v1.10.0 - github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250427030626-b463dc514714 - github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250427030626-b463dc514714 - github.com/go-kratos/kratos/v2 v2.8.4 - github.com/go-sql-driver/mysql v1.9.2 - github.com/goexts/generic v0.3.0 - github.com/golang-jwt/jwt/v5 v5.2.2 - github.com/google/gnostic v0.7.0 + github.com/go-kratos/kratos/v2 v2.9.1 + github.com/goexts/generic v0.14.0 + github.com/golang-jwt/jwt/v5 v5.3.0 // indirect + github.com/google/gnostic v0.7.1 // indirect github.com/google/uuid v1.6.0 - github.com/google/wire v0.6.0 + github.com/google/wire v0.7.0 github.com/gorilla/handlers v1.5.2 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 - github.com/hashicorp/consul/api v1.32.0 - github.com/jackc/pgx/v5 v5.7.4 - github.com/lib/pq v1.10.9 - github.com/mattn/go-sqlite3 v1.14.28 + github.com/mattn/go-sqlite3 v1.14.28 // indirect github.com/mojocn/base64Captcha v1.3.8 - github.com/origadmin/contrib/database v0.0.34 - github.com/origadmin/contrib/i18n v0.0.33 - github.com/origadmin/contrib/replacer v0.0.33 - github.com/origadmin/contrib/transport/gins v0.0.33 github.com/origadmin/entslog/v3 v3.1.0 - github.com/origadmin/runtime v0.2.3 - github.com/origadmin/slog-kratos v1.0.4 - github.com/origadmin/toolkits v0.3.16 - github.com/origadmin/toolkits/codec v0.3.16 - github.com/origadmin/toolkits/crypto v0.3.15 - github.com/origadmin/toolkits/errors v0.3.16 - github.com/origadmin/toolkits/identifier v0.3.15 - github.com/prometheus/client_golang v1.22.0 - github.com/sony/sonyflake v1.2.0 - github.com/spf13/cobra v1.9.1 - github.com/sqlite3ent/sqlite3 v1.34.1 - github.com/stretchr/testify v1.10.0 - golang.org/x/net v0.41.0 - google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 - google.golang.org/grpc v1.73.0 - google.golang.org/protobuf v1.36.6 + github.com/origadmin/runtime v0.2.13 + github.com/origadmin/slog-kratos v1.0.5 // indirect + github.com/origadmin/toolkits v1.2.0 + github.com/origadmin/toolkits/codec v1.2.0 + github.com/origadmin/toolkits/crypto v1.2.0 + github.com/origadmin/toolkits/errors v1.2.0 + github.com/sony/sonyflake v1.3.0 + github.com/sqlite3ent/sqlite3 v1.40.0 + golang.org/x/net v0.47.0 + google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect + google.golang.org/grpc v1.77.0 + google.golang.org/protobuf v1.36.10 ) +require github.com/joho/godotenv v1.5.1 + require ( - ariga.io/atlas v0.32.0 // indirect - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250613055000-fd99550722dc.1 // indirect - buf.build/go/protovalidate v0.13.0 // indirect - cel.dev/expr v0.24.0 // indirect - cloud.google.com/go/iam v1.5.2 // indirect - cloud.google.com/go/longrunning v0.6.7 // indirect + ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 // indirect + buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.10-20250718181942-e35f9b667443.1 // indirect + buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.10-20250109164928-1da0de137947.1 // indirect + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 // indirect + buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251027152159-f1066ce064ca.2 // indirect + buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.10-20251027152159-f1066ce064ca.1 // indirect + buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.10-20241007202033-cf42259fcbfc.1 // indirect + buf.build/go/app v0.2.0 // indirect + buf.build/go/bufplugin v0.9.0 // indirect + buf.build/go/bufprivateusage v0.1.0 // indirect + buf.build/go/interrupt v1.1.0 // indirect + buf.build/go/protovalidate v1.0.1 // indirect + buf.build/go/protoyaml v0.6.0 // indirect + buf.build/go/spdx v0.2.0 // indirect + buf.build/go/standard v0.1.0 // indirect + cel.dev/expr v0.25.0 // indirect + connectrpc.com/connect v1.19.1 // indirect + connectrpc.com/otelconnect v0.8.0 // indirect dario.cat/mergo v1.0.2 // indirect - filippo.io/edwards25519 v1.1.0 // indirect + github.com/AlecAivazis/survey/v2 v2.3.7 // indirect + github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect github.com/BurntSushi/toml v1.5.0 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect - github.com/armon/go-metrics v0.5.4 // indirect - github.com/beorn7/perks v1.0.1 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect - github.com/bmatcuk/doublestar/v4 v4.8.1 // indirect - github.com/bytedance/sonic v1.13.3 // indirect - github.com/bytedance/sonic/loader v0.2.4 // indirect + github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect + github.com/bufbuild/buf v1.61.0 // indirect + github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8 // indirect + github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1 // indirect + github.com/bytedance/sonic v1.14.1 // indirect + github.com/bytedance/sonic/loader v0.3.0 // indirect github.com/casbin/govaluate v1.3.0 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/cloudwego/base64x v0.1.5 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/cli/browser v1.3.0 // indirect + github.com/cloudwego/base64x v0.1.6 // indirect + github.com/containerd/errdefs v1.0.0 // indirect + github.com/containerd/errdefs/pkg v0.3.0 // indirect + github.com/containerd/stargz-snapshotter/estargz v0.18.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect + github.com/distribution/reference v0.6.0 // indirect + github.com/docker/cli v28.5.1+incompatible // indirect + github.com/docker/distribution v2.8.3+incompatible // indirect + github.com/docker/docker v28.5.2+incompatible // indirect + github.com/docker/docker-credential-helpers v0.9.4 // indirect + github.com/docker/go-connections v0.6.0 // indirect + github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect + github.com/emicklei/proto v1.14.2 // indirect github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.9.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.9 // indirect - github.com/ghodss/yaml v1.0.0 // indirect - github.com/gin-contrib/sse v1.1.0 // indirect + github.com/go-chi/chi/v5 v5.2.3 // indirect github.com/go-kratos/aegis v0.2.0 // indirect + github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251106012513-9262193e351a // indirect + github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251106012513-9262193e351a // indirect + github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251106012513-9262193e351a // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-openapi/inflect v0.21.2 // indirect - github.com/go-playground/form/v4 v4.2.2 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.26.0 // indirect - github.com/goccy/go-json v0.10.5 // indirect - github.com/golang-cz/devslog v0.0.14 // indirect - github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect - github.com/golang-sql/sqlexp v0.1.0 // indirect + github.com/go-playground/form/v4 v4.3.0 // indirect + github.com/gofrs/flock v0.13.0 // indirect + github.com/golang-cz/devslog v0.0.15 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/google/cel-go v0.25.0 // indirect - github.com/google/gnostic-models v0.6.9 // indirect + github.com/golang/mock v1.7.0-rc.1 // indirect + github.com/google/cel-go v0.26.1 // indirect + github.com/google/gnostic-models v0.7.0 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/googleapis/gapic-generator-go v0.53.1 // indirect + github.com/google/go-containerregistry v0.20.6 // indirect + github.com/google/subcommands v1.2.0 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-hclog v1.6.3 // indirect - github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-metrics v0.5.4 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-rootcerts v1.0.2 // indirect - github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/hcl/v2 v2.23.0 // indirect - github.com/hashicorp/serf v0.10.2 // indirect + github.com/iancoleman/strcase v0.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect - github.com/jackc/puddle/v2 v2.2.2 // indirect + github.com/jdx/go-netrc v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.10 // indirect - github.com/leodido/go-urn v1.4.0 // indirect + github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect + github.com/klauspost/compress v1.18.1 // indirect + github.com/klauspost/cpuid/v2 v2.3.0 // indirect + github.com/klauspost/pgzip v1.2.6 // indirect github.com/lmittmann/tint v1.1.2 // indirect - github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect + github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 // indirect + github.com/lyft/protoc-gen-star/v2 v2.0.4 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect + github.com/moby/term v0.5.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/morikuni/aec v1.0.0 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect - github.com/origadmin/toolkits/slogx v0.3.16 // indirect - github.com/pelletier/go-toml/v2 v2.2.4 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.1 // indirect + github.com/origadmin/contrib v1.1.0 // indirect + github.com/origadmin/toolkits/slogx v1.1.0 // indirect + github.com/petermattis/goid v0.0.0-20250904145737-900bdf8bb490 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.62.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect + github.com/quic-go/qpack v0.5.1 // indirect + github.com/quic-go/quic-go v0.56.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect + github.com/rivo/uniseg v0.4.7 // indirect + github.com/rs/cors v1.11.1 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/segmentio/asm v1.2.1 // indirect + github.com/segmentio/encoding v0.5.3 // indirect github.com/shirou/gopsutil/v3 v3.24.5 // indirect - github.com/shoenig/go-m1cpu v0.1.6 // indirect - github.com/spf13/pflag v1.0.6 // indirect - github.com/stoewer/go-strcase v1.3.0 // indirect + github.com/shoenig/go-m1cpu v0.1.7 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/spf13/afero v1.15.0 // indirect + github.com/spf13/cobra v1.10.1 // indirect + github.com/spf13/pflag v1.0.10 // indirect + github.com/stoewer/go-strcase v1.3.1 // indirect + github.com/tetratelabs/wazero v1.9.0 // indirect + github.com/tidwall/btree v1.8.1 // indirect github.com/tklauser/go-sysconf v0.3.15 // indirect github.com/tklauser/numcpus v0.10.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.12 // indirect + github.com/vbatts/tar-split v0.12.2 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect github.com/zclconf/go-cty v1.16.2 // indirect github.com/zclconf/go-cty-yaml v1.1.0 // indirect - gitlab.com/golang-commonmark/html v0.0.0-20191124015941-a22733972181 // indirect - gitlab.com/golang-commonmark/linkify v0.0.0-20200225224916-64bca66f6ad3 // indirect - gitlab.com/golang-commonmark/markdown v0.0.0-20211110145824-bf3e522c626a // indirect - gitlab.com/golang-commonmark/mdurl v0.0.0-20191124015652-932350d1cb84 // indirect - gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f // indirect - go.opentelemetry.io/auto/sdk v1.1.0 // indirect - go.opentelemetry.io/otel v1.36.0 // indirect - go.opentelemetry.io/otel/metric v1.36.0 // indirect - go.opentelemetry.io/otel/trace v1.36.0 // indirect - golang.org/x/arch v0.18.0 // indirect - golang.org/x/crypto v0.39.0 // indirect - golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 // indirect + go.lsp.dev/jsonrpc2 v0.10.0 // indirect + go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 // indirect + go.lsp.dev/protocol v0.12.0 // indirect + go.lsp.dev/uri v0.3.0 // indirect + go.opentelemetry.io/auto/sdk v1.2.1 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect + go.opentelemetry.io/otel v1.38.0 // indirect + go.opentelemetry.io/otel/metric v1.38.0 // indirect + go.opentelemetry.io/otel/trace v1.38.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.1 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/arch v0.22.0 // indirect + golang.org/x/crypto v0.45.0 // indirect + golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect golang.org/x/image v0.26.0 // indirect - golang.org/x/mod v0.25.0 // indirect - golang.org/x/sync v0.15.0 // indirect - golang.org/x/sys v0.33.0 // indirect - golang.org/x/text v0.26.0 // indirect - golang.org/x/tools v0.34.0 // indirect - google.golang.org/genproto v0.0.0-20250519155744-55703ea1f237 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect + golang.org/x/mod v0.30.0 // indirect + golang.org/x/sync v0.18.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/term v0.37.0 // indirect + golang.org/x/text v0.31.0 // indirect + golang.org/x/tools v0.39.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 // indirect + google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - modernc.org/libc v1.64.0 // indirect + modernc.org/libc v1.66.10 // indirect modernc.org/mathutil v1.7.1 // indirect - modernc.org/memory v1.10.0 // indirect - modernc.org/sqlite v1.37.0 // indirect + modernc.org/memory v1.11.0 // indirect + modernc.org/sqlite v1.40.0 // indirect + pluginrpc.com/pluginrpc v0.5.0 // indirect ) diff --git a/go.sum b/go.sum index e6283942..5cf9ea1b 100644 --- a/go.sum +++ b/go.sum @@ -1,793 +1,145 @@ -ariga.io/atlas v0.32.0 h1:y+77nueMrExLiKlz1CcPKh/nU7VSlWfBbwCShsJyvCw= -ariga.io/atlas v0.32.0/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1 h1:YhMSc48s25kr7kv31Z8vf7sPUIq5YJva9z1mn/hAt0M= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250425153114-8976f5be98c1.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250613055000-fd99550722dc.1 h1:27bzfkfQ3baaLXt1yrLOUplBRUqy8sptpNqRl+Pb5/A= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250613055000-fd99550722dc.1/go.mod h1:avRlCjnFzl98VPaeCtJ24RrV/wwHFzB8sWXhj26+n/U= -buf.build/go/protovalidate v0.12.0 h1:4GKJotbspQjRCcqZMGVSuC8SjwZ/FmgtSuKDpKUTZew= -buf.build/go/protovalidate v0.12.0/go.mod h1:q3PFfbzI05LeqxSwq+begW2syjy2Z6hLxZSkP1OH/D0= -buf.build/go/protovalidate v0.13.0 h1:t7nC2w79q8M2KaZfFTaXmyFhnYWTPbGFtZS2rebdIQM= -buf.build/go/protovalidate v0.13.0/go.mod h1:b0ZWMqcwgx2sa1IXTFT9EpJlMp03ESY4f8t9yulcykg= -cel.dev/expr v0.23.1 h1:K4KOtPCJQjVggkARsjG9RWXP6O4R73aHeJMa/dmCQQg= -cel.dev/expr v0.23.1/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= -cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY= -cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw= -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.1/go.mod h1:fs4QogzfH5n2pBXBP9vRiU+eCny7lD2vmFZy79Iuw1U= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= -cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= -cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= -cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= -cloud.google.com/go v0.107.0/go.mod h1:wpc2eNrD7hXUTy8EKS10jkxpZBjASrORK7goS+3YX2I= -cloud.google.com/go v0.110.0/go.mod h1:SJnCLqQ0FCFGSZMUNUf84MV3Aia54kn7pi8st7tMzaY= -cloud.google.com/go/accessapproval v1.4.0/go.mod h1:zybIuC3KpDOvotz59lFe5qxRZx6C75OtwbisN56xYB4= -cloud.google.com/go/accessapproval v1.5.0/go.mod h1:HFy3tuiGvMdcd/u+Cu5b9NkO1pEICJ46IR82PoUdplw= -cloud.google.com/go/accessapproval v1.6.0/go.mod h1:R0EiYnwV5fsRFiKZkPHr6mwyk2wxUJ30nL4j2pcFY2E= -cloud.google.com/go/accesscontextmanager v1.3.0/go.mod h1:TgCBehyr5gNMz7ZaH9xubp+CE8dkrszb4oK9CWyvD4o= -cloud.google.com/go/accesscontextmanager v1.4.0/go.mod h1:/Kjh7BBu/Gh83sv+K60vN9QE5NJcd80sU33vIe2IFPE= -cloud.google.com/go/accesscontextmanager v1.6.0/go.mod h1:8XCvZWfYw3K/ji0iVnp+6pu7huxoQTLmxAbVjbloTtM= -cloud.google.com/go/accesscontextmanager v1.7.0/go.mod h1:CEGLewx8dwa33aDAZQujl7Dx+uYhS0eay198wB/VumQ= -cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= -cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= -cloud.google.com/go/aiplatform v1.27.0/go.mod h1:Bvxqtl40l0WImSb04d0hXFU7gDOiq9jQmorivIiWcKg= -cloud.google.com/go/aiplatform v1.35.0/go.mod h1:7MFT/vCaOyZT/4IIFfxH4ErVg/4ku6lKv3w0+tFTgXQ= -cloud.google.com/go/aiplatform v1.36.1/go.mod h1:WTm12vJRPARNvJ+v6P52RDHCNe4AhvjcIZ/9/RRHy/k= -cloud.google.com/go/aiplatform v1.37.0/go.mod h1:IU2Cv29Lv9oCn/9LkFiiuKfwrRTq+QQMbW+hPCxJGZw= -cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= -cloud.google.com/go/analytics v0.12.0/go.mod h1:gkfj9h6XRf9+TS4bmuhPEShsh3hH8PAZzm/41OOhQd4= -cloud.google.com/go/analytics v0.17.0/go.mod h1:WXFa3WSym4IZ+JiKmavYdJwGG/CvpqiqczmL59bTD9M= -cloud.google.com/go/analytics v0.18.0/go.mod h1:ZkeHGQlcIPkw0R/GW+boWHhCOR43xz9RN/jn7WcqfIE= -cloud.google.com/go/analytics v0.19.0/go.mod h1:k8liqf5/HCnOUkbawNtrWWc+UAzyDlW89doe8TtoDsE= -cloud.google.com/go/apigateway v1.3.0/go.mod h1:89Z8Bhpmxu6AmUxuVRg/ECRGReEdiP3vQtk4Z1J9rJk= -cloud.google.com/go/apigateway v1.4.0/go.mod h1:pHVY9MKGaH9PQ3pJ4YLzoj6U5FUDeDFBllIz7WmzJoc= -cloud.google.com/go/apigateway v1.5.0/go.mod h1:GpnZR3Q4rR7LVu5951qfXPJCHquZt02jf7xQx7kpqN8= -cloud.google.com/go/apigeeconnect v1.3.0/go.mod h1:G/AwXFAKo0gIXkPTVfZDd2qA1TxBXJ3MgMRBQkIi9jc= -cloud.google.com/go/apigeeconnect v1.4.0/go.mod h1:kV4NwOKqjvt2JYR0AoIWo2QGfoRtn/pkS3QlHp0Ni04= -cloud.google.com/go/apigeeconnect v1.5.0/go.mod h1:KFaCqvBRU6idyhSNyn3vlHXc8VMDJdRmwDF6JyFRqZ8= -cloud.google.com/go/apigeeregistry v0.4.0/go.mod h1:EUG4PGcsZvxOXAdyEghIdXwAEi/4MEaoqLMLDMIwKXY= -cloud.google.com/go/apigeeregistry v0.5.0/go.mod h1:YR5+s0BVNZfVOUkMa5pAR2xGd0A473vA5M7j247o1wM= -cloud.google.com/go/apigeeregistry v0.6.0/go.mod h1:BFNzW7yQVLZ3yj0TKcwzb8n25CFBri51GVGOEUcgQsc= -cloud.google.com/go/apikeys v0.4.0/go.mod h1:XATS/yqZbaBK0HOssf+ALHp8jAlNHUgyfprvNcBIszU= -cloud.google.com/go/apikeys v0.5.0/go.mod h1:5aQfwY4D+ewMMWScd3hm2en3hCj+BROlyrt3ytS7KLI= -cloud.google.com/go/apikeys v0.6.0/go.mod h1:kbpXu5upyiAlGkKrJgQl8A0rKNNJ7dQ377pdroRSSi8= -cloud.google.com/go/appengine v1.4.0/go.mod h1:CS2NhuBuDXM9f+qscZ6V86m1MIIqPj3WC/UoEuR1Sno= -cloud.google.com/go/appengine v1.5.0/go.mod h1:TfasSozdkFI0zeoxW3PTBLiNqRmzraodCWatWI9Dmak= -cloud.google.com/go/appengine v1.6.0/go.mod h1:hg6i0J/BD2cKmDJbaFSYHFyZkgBEfQrDg/X0V5fJn84= -cloud.google.com/go/appengine v1.7.0/go.mod h1:eZqpbHFCqRGa2aCdope7eC0SWLV1j0neb/QnMJVWx6A= -cloud.google.com/go/appengine v1.7.1/go.mod h1:IHLToyb/3fKutRysUlFO0BPt5j7RiQ45nrzEJmKTo6E= -cloud.google.com/go/area120 v0.5.0/go.mod h1:DE/n4mp+iqVyvxHN41Vf1CR602GiHQjFPusMFW6bGR4= -cloud.google.com/go/area120 v0.6.0/go.mod h1:39yFJqWVgm0UZqWTOdqkLhjoC7uFfgXRC8g/ZegeAh0= -cloud.google.com/go/area120 v0.7.0/go.mod h1:a3+8EUD1SX5RUcCs3MY5YasiO1z6yLiNLRiFrykbynY= -cloud.google.com/go/area120 v0.7.1/go.mod h1:j84i4E1RboTWjKtZVWXPqvK5VHQFJRF2c1Nm69pWm9k= -cloud.google.com/go/artifactregistry v1.6.0/go.mod h1:IYt0oBPSAGYj/kprzsBjZ/4LnG/zOcHyFHjWPCi6SAQ= -cloud.google.com/go/artifactregistry v1.7.0/go.mod h1:mqTOFOnGZx8EtSqK/ZWcsm/4U8B77rbcLP6ruDU2Ixk= -cloud.google.com/go/artifactregistry v1.8.0/go.mod h1:w3GQXkJX8hiKN0v+at4b0qotwijQbYUqF2GWkZzAhC0= -cloud.google.com/go/artifactregistry v1.9.0/go.mod h1:2K2RqvA2CYvAeARHRkLDhMDJ3OXy26h3XW+3/Jh2uYc= -cloud.google.com/go/artifactregistry v1.11.1/go.mod h1:lLYghw+Itq9SONbCa1YWBoWs1nOucMH0pwXN1rOBZFI= -cloud.google.com/go/artifactregistry v1.11.2/go.mod h1:nLZns771ZGAwVLzTX/7Al6R9ehma4WUEhZGWV6CeQNQ= -cloud.google.com/go/artifactregistry v1.12.0/go.mod h1:o6P3MIvtzTOnmvGagO9v/rOjjA0HmhJ+/6KAXrmYDCI= -cloud.google.com/go/artifactregistry v1.13.0/go.mod h1:uy/LNfoOIivepGhooAUpL1i30Hgee3Cu0l4VTWHUC08= -cloud.google.com/go/asset v1.5.0/go.mod h1:5mfs8UvcM5wHhqtSv8J1CtxxaQq3AdBxxQi2jGW/K4o= -cloud.google.com/go/asset v1.7.0/go.mod h1:YbENsRK4+xTiL+Ofoj5Ckf+O17kJtgp3Y3nn4uzZz5s= -cloud.google.com/go/asset v1.8.0/go.mod h1:mUNGKhiqIdbr8X7KNayoYvyc4HbbFO9URsjbytpUaW0= -cloud.google.com/go/asset v1.9.0/go.mod h1:83MOE6jEJBMqFKadM9NLRcs80Gdw76qGuHn8m3h8oHQ= -cloud.google.com/go/asset v1.10.0/go.mod h1:pLz7uokL80qKhzKr4xXGvBQXnzHn5evJAEAtZiIb0wY= -cloud.google.com/go/asset v1.11.1/go.mod h1:fSwLhbRvC9p9CXQHJ3BgFeQNM4c9x10lqlrdEUYXlJo= -cloud.google.com/go/asset v1.12.0/go.mod h1:h9/sFOa4eDIyKmH6QMpm4eUK3pDojWnUhTgJlk762Hg= -cloud.google.com/go/asset v1.13.0/go.mod h1:WQAMyYek/b7NBpYq/K4KJWcRqzoalEsxz/t/dTk4THw= -cloud.google.com/go/assuredworkloads v1.5.0/go.mod h1:n8HOZ6pff6re5KYfBXcFvSViQjDwxFkAkmUFffJRbbY= -cloud.google.com/go/assuredworkloads v1.6.0/go.mod h1:yo2YOk37Yc89Rsd5QMVECvjaMKymF9OP+QXWlKXUkXw= -cloud.google.com/go/assuredworkloads v1.7.0/go.mod h1:z/736/oNmtGAyU47reJgGN+KVoYoxeLBoj4XkKYscNI= -cloud.google.com/go/assuredworkloads v1.8.0/go.mod h1:AsX2cqyNCOvEQC8RMPnoc0yEarXQk6WEKkxYfL6kGIo= -cloud.google.com/go/assuredworkloads v1.9.0/go.mod h1:kFuI1P78bplYtT77Tb1hi0FMxM0vVpRC7VVoJC3ZoT0= -cloud.google.com/go/assuredworkloads v1.10.0/go.mod h1:kwdUQuXcedVdsIaKgKTp9t0UJkE5+PAVNhdQm4ZVq2E= -cloud.google.com/go/automl v1.5.0/go.mod h1:34EjfoFGMZ5sgJ9EoLsRtdPSNZLcfflJR39VbVNS2M0= -cloud.google.com/go/automl v1.6.0/go.mod h1:ugf8a6Fx+zP0D59WLhqgTDsQI9w07o64uf/Is3Nh5p8= -cloud.google.com/go/automl v1.7.0/go.mod h1:RL9MYCCsJEOmt0Wf3z9uzG0a7adTT1fe+aObgSpkCt8= -cloud.google.com/go/automl v1.8.0/go.mod h1:xWx7G/aPEe/NP+qzYXktoBSDfjO+vnKMGgsApGJJquM= -cloud.google.com/go/automl v1.12.0/go.mod h1:tWDcHDp86aMIuHmyvjuKeeHEGq76lD7ZqfGLN6B0NuU= -cloud.google.com/go/baremetalsolution v0.3.0/go.mod h1:XOrocE+pvK1xFfleEnShBlNAXf+j5blPPxrhjKgnIFc= -cloud.google.com/go/baremetalsolution v0.4.0/go.mod h1:BymplhAadOO/eBa7KewQ0Ppg4A4Wplbn+PsFKRLo0uI= -cloud.google.com/go/baremetalsolution v0.5.0/go.mod h1:dXGxEkmR9BMwxhzBhV0AioD0ULBmuLZI8CdwalUxuss= -cloud.google.com/go/batch v0.3.0/go.mod h1:TR18ZoAekj1GuirsUsR1ZTKN3FC/4UDnScjT8NXImFE= -cloud.google.com/go/batch v0.4.0/go.mod h1:WZkHnP43R/QCGQsZ+0JyG4i79ranE2u8xvjq/9+STPE= -cloud.google.com/go/batch v0.7.0/go.mod h1:vLZN95s6teRUqRQ4s3RLDsH8PvboqBK+rn1oevL159g= -cloud.google.com/go/beyondcorp v0.2.0/go.mod h1:TB7Bd+EEtcw9PCPQhCJtJGjk/7TC6ckmnSFS+xwTfm4= -cloud.google.com/go/beyondcorp v0.3.0/go.mod h1:E5U5lcrcXMsCuoDNyGrpyTm/hn7ne941Jz2vmksAxW8= -cloud.google.com/go/beyondcorp v0.4.0/go.mod h1:3ApA0mbhHx6YImmuubf5pyW8srKnCEPON32/5hj+RmM= -cloud.google.com/go/beyondcorp v0.5.0/go.mod h1:uFqj9X+dSfrheVp7ssLTaRHd2EHqSL4QZmH4e8WXGGU= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/bigquery v1.42.0/go.mod h1:8dRTJxhtG+vwBKzE5OseQn/hiydoQN3EedCaOdYmxRA= -cloud.google.com/go/bigquery v1.43.0/go.mod h1:ZMQcXHsl+xmU1z36G2jNGZmKp9zNY5BUua5wDgmNCfw= -cloud.google.com/go/bigquery v1.44.0/go.mod h1:0Y33VqXTEsbamHJvJHdFmtqHvMIY28aK1+dFsvaChGc= -cloud.google.com/go/bigquery v1.47.0/go.mod h1:sA9XOgy0A8vQK9+MWhEQTY6Tix87M/ZurWFIxmF9I/E= -cloud.google.com/go/bigquery v1.48.0/go.mod h1:QAwSz+ipNgfL5jxiaK7weyOhzdoAy1zFm0Nf1fysJac= -cloud.google.com/go/bigquery v1.49.0/go.mod h1:Sv8hMmTFFYBlt/ftw2uN6dFdQPzBlREY9yBh7Oy7/4Q= -cloud.google.com/go/bigquery v1.50.0/go.mod h1:YrleYEh2pSEbgTBZYMJ5SuSr0ML3ypjRB1zgf7pvQLU= -cloud.google.com/go/billing v1.4.0/go.mod h1:g9IdKBEFlItS8bTtlrZdVLWSSdSyFUZKXNS02zKMOZY= -cloud.google.com/go/billing v1.5.0/go.mod h1:mztb1tBc3QekhjSgmpf/CV4LzWXLzCArwpLmP2Gm88s= -cloud.google.com/go/billing v1.6.0/go.mod h1:WoXzguj+BeHXPbKfNWkqVtDdzORazmCjraY+vrxcyvI= -cloud.google.com/go/billing v1.7.0/go.mod h1:q457N3Hbj9lYwwRbnlD7vUpyjq6u5U1RAOArInEiD5Y= -cloud.google.com/go/billing v1.12.0/go.mod h1:yKrZio/eu+okO/2McZEbch17O5CB5NpZhhXG6Z766ss= -cloud.google.com/go/billing v1.13.0/go.mod h1:7kB2W9Xf98hP9Sr12KfECgfGclsH3CQR0R08tnRlRbc= -cloud.google.com/go/binaryauthorization v1.1.0/go.mod h1:xwnoWu3Y84jbuHa0zd526MJYmtnVXn0syOjaJgy4+dM= -cloud.google.com/go/binaryauthorization v1.2.0/go.mod h1:86WKkJHtRcv5ViNABtYMhhNWRrD1Vpi//uKEy7aYEfI= -cloud.google.com/go/binaryauthorization v1.3.0/go.mod h1:lRZbKgjDIIQvzYQS1p99A7/U1JqvqeZg0wiI5tp6tg0= -cloud.google.com/go/binaryauthorization v1.4.0/go.mod h1:tsSPQrBd77VLplV70GUhBf/Zm3FsKmgSqgm4UmiDItk= -cloud.google.com/go/binaryauthorization v1.5.0/go.mod h1:OSe4OU1nN/VswXKRBmciKpo9LulY41gch5c68htf3/Q= -cloud.google.com/go/certificatemanager v1.3.0/go.mod h1:n6twGDvcUBFu9uBgt4eYvvf3sQ6My8jADcOVwHmzadg= -cloud.google.com/go/certificatemanager v1.4.0/go.mod h1:vowpercVFyqs8ABSmrdV+GiFf2H/ch3KyudYQEMM590= -cloud.google.com/go/certificatemanager v1.6.0/go.mod h1:3Hh64rCKjRAX8dXgRAyOcY5vQ/fE1sh8o+Mdd6KPgY8= -cloud.google.com/go/channel v1.8.0/go.mod h1:W5SwCXDJsq/rg3tn3oG0LOxpAo6IMxNa09ngphpSlnk= -cloud.google.com/go/channel v1.9.0/go.mod h1:jcu05W0my9Vx4mt3/rEHpfxc9eKi9XwsdDL8yBMbKUk= -cloud.google.com/go/channel v1.11.0/go.mod h1:IdtI0uWGqhEeatSB62VOoJ8FSUhJ9/+iGkJVqp74CGE= -cloud.google.com/go/channel v1.12.0/go.mod h1:VkxCGKASi4Cq7TbXxlaBezonAYpp1GCnKMY6tnMQnLU= -cloud.google.com/go/cloudbuild v1.3.0/go.mod h1:WequR4ULxlqvMsjDEEEFnOG5ZSRSgWOywXYDb1vPE6U= -cloud.google.com/go/cloudbuild v1.4.0/go.mod h1:5Qwa40LHiOXmz3386FrjrYM93rM/hdRr7b53sySrTqA= -cloud.google.com/go/cloudbuild v1.6.0/go.mod h1:UIbc/w9QCbH12xX+ezUsgblrWv+Cv4Tw83GiSMHOn9M= -cloud.google.com/go/cloudbuild v1.7.0/go.mod h1:zb5tWh2XI6lR9zQmsm1VRA+7OCuve5d8S+zJUul8KTg= -cloud.google.com/go/cloudbuild v1.9.0/go.mod h1:qK1d7s4QlO0VwfYn5YuClDGg2hfmLZEb4wQGAbIgL1s= -cloud.google.com/go/clouddms v1.3.0/go.mod h1:oK6XsCDdW4Ib3jCCBugx+gVjevp2TMXFtgxvPSee3OM= -cloud.google.com/go/clouddms v1.4.0/go.mod h1:Eh7sUGCC+aKry14O1NRljhjyrr0NFC0G2cjwX0cByRk= -cloud.google.com/go/clouddms v1.5.0/go.mod h1:QSxQnhikCLUw13iAbffF2CZxAER3xDGNHjsTAkQJcQA= -cloud.google.com/go/cloudtasks v1.5.0/go.mod h1:fD92REy1x5woxkKEkLdvavGnPJGEn8Uic9nWuLzqCpY= -cloud.google.com/go/cloudtasks v1.6.0/go.mod h1:C6Io+sxuke9/KNRkbQpihnW93SWDU3uXt92nu85HkYI= -cloud.google.com/go/cloudtasks v1.7.0/go.mod h1:ImsfdYWwlWNJbdgPIIGJWC+gemEGTBK/SunNQQNCAb4= -cloud.google.com/go/cloudtasks v1.8.0/go.mod h1:gQXUIwCSOI4yPVK7DgTVFiiP0ZW/eQkydWzwVMdHxrI= -cloud.google.com/go/cloudtasks v1.9.0/go.mod h1:w+EyLsVkLWHcOaqNEyvcKAsWp9p29dL6uL9Nst1cI7Y= -cloud.google.com/go/cloudtasks v1.10.0/go.mod h1:NDSoTLkZ3+vExFEWu2UJV1arUyzVDAiZtdWcsUyNwBs= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= -cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= -cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= -cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.12.0/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU= -cloud.google.com/go/compute v1.12.1/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU= -cloud.google.com/go/compute v1.13.0/go.mod h1:5aPTS0cUNMIc1CE546K+Th6weJUNQErARyZtRXDJ8GE= -cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvjxega5vAdo= -cloud.google.com/go/compute v1.15.1/go.mod h1:bjjoF/NtFUrkD/urWfdHaKuOPDR5nWIs63rR+SXhcpA= -cloud.google.com/go/compute v1.18.0/go.mod h1:1X7yHxec2Ga+Ss6jPyjxRxpu2uu7PLgsOVXvgU0yacs= -cloud.google.com/go/compute v1.19.0/go.mod h1:rikpw2y+UMidAe9tISo04EHNOIf42RLYF/q8Bs93scU= -cloud.google.com/go/compute/metadata v0.1.0/go.mod h1:Z1VN+bulIf6bt4P/C37K4DyZYZEXYonfTBHHFPO/4UU= -cloud.google.com/go/compute/metadata v0.2.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= -cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/contactcenterinsights v1.3.0/go.mod h1:Eu2oemoePuEFc/xKFPjbTuPSj0fYJcPls9TFlPNnHHY= -cloud.google.com/go/contactcenterinsights v1.4.0/go.mod h1:L2YzkGbPsv+vMQMCADxJoT9YiTTnSEd6fEvCeHTYVck= -cloud.google.com/go/contactcenterinsights v1.6.0/go.mod h1:IIDlT6CLcDoyv79kDv8iWxMSTZhLxSCofVV5W6YFM/w= -cloud.google.com/go/container v1.6.0/go.mod h1:Xazp7GjJSeUYo688S+6J5V+n/t+G5sKBTFkKNudGRxg= -cloud.google.com/go/container v1.7.0/go.mod h1:Dp5AHtmothHGX3DwwIHPgq45Y8KmNsgN3amoYfxVkLo= -cloud.google.com/go/container v1.13.1/go.mod h1:6wgbMPeQRw9rSnKBCAJXnds3Pzj03C4JHamr8asWKy4= -cloud.google.com/go/container v1.14.0/go.mod h1:3AoJMPhHfLDxLvrlVWaK57IXzaPnLaZq63WX59aQBfM= -cloud.google.com/go/container v1.15.0/go.mod h1:ft+9S0WGjAyjDggg5S06DXj+fHJICWg8L7isCQe9pQA= -cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= -cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4= -cloud.google.com/go/containeranalysis v0.7.0/go.mod h1:9aUL+/vZ55P2CXfuZjS4UjQ9AgXoSw8Ts6lemfmxBxI= -cloud.google.com/go/containeranalysis v0.9.0/go.mod h1:orbOANbwk5Ejoom+s+DUCTTJ7IBdBQJDcSylAx/on9s= -cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0= -cloud.google.com/go/datacatalog v1.5.0/go.mod h1:M7GPLNQeLfWqeIm3iuiruhPzkt65+Bx8dAKvScX8jvs= -cloud.google.com/go/datacatalog v1.6.0/go.mod h1:+aEyF8JKg+uXcIdAmmaMUmZ3q1b/lKLtXCmXdnc0lbc= -cloud.google.com/go/datacatalog v1.7.0/go.mod h1:9mEl4AuDYWw81UGc41HonIHH7/sn52H0/tc8f8ZbZIE= -cloud.google.com/go/datacatalog v1.8.0/go.mod h1:KYuoVOv9BM8EYz/4eMFxrr4DUKhGIOXxZoKYF5wdISM= -cloud.google.com/go/datacatalog v1.8.1/go.mod h1:RJ58z4rMp3gvETA465Vg+ag8BGgBdnRPEMMSTr5Uv+M= -cloud.google.com/go/datacatalog v1.12.0/go.mod h1:CWae8rFkfp6LzLumKOnmVh4+Zle4A3NXLzVJ1d1mRm0= -cloud.google.com/go/datacatalog v1.13.0/go.mod h1:E4Rj9a5ZtAxcQJlEBTLgMTphfP11/lNaAshpoBgemX8= -cloud.google.com/go/dataflow v0.6.0/go.mod h1:9QwV89cGoxjjSR9/r7eFDqqjtvbKxAK2BaYU6PVk9UM= -cloud.google.com/go/dataflow v0.7.0/go.mod h1:PX526vb4ijFMesO1o202EaUmouZKBpjHsTlCtB4parQ= -cloud.google.com/go/dataflow v0.8.0/go.mod h1:Rcf5YgTKPtQyYz8bLYhFoIV/vP39eL7fWNcSOyFfLJE= -cloud.google.com/go/dataform v0.3.0/go.mod h1:cj8uNliRlHpa6L3yVhDOBrUXH+BPAO1+KFMQQNSThKo= -cloud.google.com/go/dataform v0.4.0/go.mod h1:fwV6Y4Ty2yIFL89huYlEkwUPtS7YZinZbzzj5S9FzCE= -cloud.google.com/go/dataform v0.5.0/go.mod h1:GFUYRe8IBa2hcomWplodVmUx/iTL0FrsauObOM3Ipr0= -cloud.google.com/go/dataform v0.6.0/go.mod h1:QPflImQy33e29VuapFdf19oPbE4aYTJxr31OAPV+ulA= -cloud.google.com/go/dataform v0.7.0/go.mod h1:7NulqnVozfHvWUBpMDfKMUESr+85aJsC/2O0o3jWPDE= -cloud.google.com/go/datafusion v1.4.0/go.mod h1:1Zb6VN+W6ALo85cXnM1IKiPw+yQMKMhB9TsTSRDo/38= -cloud.google.com/go/datafusion v1.5.0/go.mod h1:Kz+l1FGHB0J+4XF2fud96WMmRiq/wj8N9u007vyXZ2w= -cloud.google.com/go/datafusion v1.6.0/go.mod h1:WBsMF8F1RhSXvVM8rCV3AeyWVxcC2xY6vith3iw3S+8= -cloud.google.com/go/datalabeling v0.5.0/go.mod h1:TGcJ0G2NzcsXSE/97yWjIZO0bXj0KbVlINXMG9ud42I= -cloud.google.com/go/datalabeling v0.6.0/go.mod h1:WqdISuk/+WIGeMkpw/1q7bK/tFEZxsrFJOJdY2bXvTQ= -cloud.google.com/go/datalabeling v0.7.0/go.mod h1:WPQb1y08RJbmpM3ww0CSUAGweL0SxByuW2E+FU+wXcM= -cloud.google.com/go/dataplex v1.3.0/go.mod h1:hQuRtDg+fCiFgC8j0zV222HvzFQdRd+SVX8gdmFcZzA= -cloud.google.com/go/dataplex v1.4.0/go.mod h1:X51GfLXEMVJ6UN47ESVqvlsRplbLhcsAt0kZCCKsU0A= -cloud.google.com/go/dataplex v1.5.2/go.mod h1:cVMgQHsmfRoI5KFYq4JtIBEUbYwc3c7tXmIDhRmNNVQ= -cloud.google.com/go/dataplex v1.6.0/go.mod h1:bMsomC/aEJOSpHXdFKFGQ1b0TDPIeL28nJObeO1ppRs= -cloud.google.com/go/dataproc v1.7.0/go.mod h1:CKAlMjII9H90RXaMpSxQ8EU6dQx6iAYNPcYPOkSbi8s= -cloud.google.com/go/dataproc v1.8.0/go.mod h1:5OW+zNAH0pMpw14JVrPONsxMQYMBqJuzORhIBfBn9uI= -cloud.google.com/go/dataproc v1.12.0/go.mod h1:zrF3aX0uV3ikkMz6z4uBbIKyhRITnxvr4i3IjKsKrw4= -cloud.google.com/go/dataqna v0.5.0/go.mod h1:90Hyk596ft3zUQ8NkFfvICSIfHFh1Bc7C4cK3vbhkeo= -cloud.google.com/go/dataqna v0.6.0/go.mod h1:1lqNpM7rqNLVgWBJyk5NF6Uen2PHym0jtVJonplVsDA= -cloud.google.com/go/dataqna v0.7.0/go.mod h1:Lx9OcIIeqCrw1a6KdO3/5KMP1wAmTc0slZWwP12Qq3c= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/datastore v1.10.0/go.mod h1:PC5UzAmDEkAmkfaknstTYbNpgE49HAgW2J1gcgUfmdM= -cloud.google.com/go/datastore v1.11.0/go.mod h1:TvGxBIHCS50u8jzG+AW/ppf87v1of8nwzFNgEZU1D3c= -cloud.google.com/go/datastream v1.2.0/go.mod h1:i/uTP8/fZwgATHS/XFu0TcNUhuA0twZxxQ3EyCUQMwo= -cloud.google.com/go/datastream v1.3.0/go.mod h1:cqlOX8xlyYF/uxhiKn6Hbv6WjwPPuI9W2M9SAXwaLLQ= -cloud.google.com/go/datastream v1.4.0/go.mod h1:h9dpzScPhDTs5noEMQVWP8Wx8AFBRyS0s8KWPx/9r0g= -cloud.google.com/go/datastream v1.5.0/go.mod h1:6TZMMNPwjUqZHBKPQ1wwXpb0d5VDVPl2/XoS5yi88q4= -cloud.google.com/go/datastream v1.6.0/go.mod h1:6LQSuswqLa7S4rPAOZFVjHIG3wJIjZcZrw8JDEDJuIs= -cloud.google.com/go/datastream v1.7.0/go.mod h1:uxVRMm2elUSPuh65IbZpzJNMbuzkcvu5CjMqVIUHrww= -cloud.google.com/go/deploy v1.4.0/go.mod h1:5Xghikd4VrmMLNaF6FiRFDlHb59VM59YoDQnOUdsH/c= -cloud.google.com/go/deploy v1.5.0/go.mod h1:ffgdD0B89tToyW/U/D2eL0jN2+IEV/3EMuXHA0l4r+s= -cloud.google.com/go/deploy v1.6.0/go.mod h1:f9PTHehG/DjCom3QH0cntOVRm93uGBDt2vKzAPwpXQI= -cloud.google.com/go/deploy v1.8.0/go.mod h1:z3myEJnA/2wnB4sgjqdMfgxCA0EqC3RBTNcVPs93mtQ= -cloud.google.com/go/dialogflow v1.15.0/go.mod h1:HbHDWs33WOGJgn6rfzBW1Kv807BE3O1+xGbn59zZWI4= -cloud.google.com/go/dialogflow v1.16.1/go.mod h1:po6LlzGfK+smoSmTBnbkIZY2w8ffjz/RcGSS+sh1el0= -cloud.google.com/go/dialogflow v1.17.0/go.mod h1:YNP09C/kXA1aZdBgC/VtXX74G/TKn7XVCcVumTflA+8= -cloud.google.com/go/dialogflow v1.18.0/go.mod h1:trO7Zu5YdyEuR+BhSNOqJezyFQ3aUzz0njv7sMx/iek= -cloud.google.com/go/dialogflow v1.19.0/go.mod h1:JVmlG1TwykZDtxtTXujec4tQ+D8SBFMoosgy+6Gn0s0= -cloud.google.com/go/dialogflow v1.29.0/go.mod h1:b+2bzMe+k1s9V+F2jbJwpHPzrnIyHihAdRFMtn2WXuM= -cloud.google.com/go/dialogflow v1.31.0/go.mod h1:cuoUccuL1Z+HADhyIA7dci3N5zUssgpBJmCzI6fNRB4= -cloud.google.com/go/dialogflow v1.32.0/go.mod h1:jG9TRJl8CKrDhMEcvfcfFkkpp8ZhgPz3sBGmAUYJ2qE= -cloud.google.com/go/dlp v1.6.0/go.mod h1:9eyB2xIhpU0sVwUixfBubDoRwP+GjeUoxxeueZmqvmM= -cloud.google.com/go/dlp v1.7.0/go.mod h1:68ak9vCiMBjbasxeVD17hVPxDEck+ExiHavX8kiHG+Q= -cloud.google.com/go/dlp v1.9.0/go.mod h1:qdgmqgTyReTz5/YNSSuueR8pl7hO0o9bQ39ZhtgkWp4= -cloud.google.com/go/documentai v1.7.0/go.mod h1:lJvftZB5NRiFSX4moiye1SMxHx0Bc3x1+p9e/RfXYiU= -cloud.google.com/go/documentai v1.8.0/go.mod h1:xGHNEB7CtsnySCNrCFdCyyMz44RhFEEX2Q7UD0c5IhU= -cloud.google.com/go/documentai v1.9.0/go.mod h1:FS5485S8R00U10GhgBC0aNGrJxBP8ZVpEeJ7PQDZd6k= -cloud.google.com/go/documentai v1.10.0/go.mod h1:vod47hKQIPeCfN2QS/jULIvQTugbmdc0ZvxxfQY1bg4= -cloud.google.com/go/documentai v1.16.0/go.mod h1:o0o0DLTEZ+YnJZ+J4wNfTxmDVyrkzFvttBXXtYRMHkM= -cloud.google.com/go/documentai v1.18.0/go.mod h1:F6CK6iUH8J81FehpskRmhLq/3VlwQvb7TvwOceQ2tbs= -cloud.google.com/go/domains v0.6.0/go.mod h1:T9Rz3GasrpYk6mEGHh4rymIhjlnIuB4ofT1wTxDeT4Y= -cloud.google.com/go/domains v0.7.0/go.mod h1:PtZeqS1xjnXuRPKE/88Iru/LdfoRyEHYA9nFQf4UKpg= -cloud.google.com/go/domains v0.8.0/go.mod h1:M9i3MMDzGFXsydri9/vW+EWz9sWb4I6WyHqdlAk0idE= -cloud.google.com/go/edgecontainer v0.1.0/go.mod h1:WgkZ9tp10bFxqO8BLPqv2LlfmQF1X8lZqwW4r1BTajk= -cloud.google.com/go/edgecontainer v0.2.0/go.mod h1:RTmLijy+lGpQ7BXuTDa4C4ssxyXT34NIuHIgKuP4s5w= -cloud.google.com/go/edgecontainer v0.3.0/go.mod h1:FLDpP4nykgwwIfcLt6zInhprzw0lEi2P1fjO6Ie0qbc= -cloud.google.com/go/edgecontainer v1.0.0/go.mod h1:cttArqZpBB2q58W/upSG++ooo6EsblxDIolxa3jSjbY= -cloud.google.com/go/errorreporting v0.3.0/go.mod h1:xsP2yaAp+OAW4OIm60An2bbLpqIhKXdWR/tawvl7QzU= -cloud.google.com/go/essentialcontacts v1.3.0/go.mod h1:r+OnHa5jfj90qIfZDO/VztSFqbQan7HV75p8sA+mdGI= -cloud.google.com/go/essentialcontacts v1.4.0/go.mod h1:8tRldvHYsmnBCHdFpvU+GL75oWiBKl80BiqlFh9tp+8= -cloud.google.com/go/essentialcontacts v1.5.0/go.mod h1:ay29Z4zODTuwliK7SnX8E86aUF2CTzdNtvv42niCX0M= -cloud.google.com/go/eventarc v1.7.0/go.mod h1:6ctpF3zTnaQCxUjHUdcfgcA1A2T309+omHZth7gDfmc= -cloud.google.com/go/eventarc v1.8.0/go.mod h1:imbzxkyAU4ubfsaKYdQg04WS1NvncblHEup4kvF+4gw= -cloud.google.com/go/eventarc v1.10.0/go.mod h1:u3R35tmZ9HvswGRBnF48IlYgYeBcPUCjkr4BTdem2Kw= -cloud.google.com/go/eventarc v1.11.0/go.mod h1:PyUjsUKPWoRBCHeOxZd/lbOOjahV41icXyUY5kSTvVY= -cloud.google.com/go/filestore v1.3.0/go.mod h1:+qbvHGvXU1HaKX2nD0WEPo92TP/8AQuCVEBXNY9z0+w= -cloud.google.com/go/filestore v1.4.0/go.mod h1:PaG5oDfo9r224f8OYXURtAsY+Fbyq/bLYoINEK8XQAI= -cloud.google.com/go/filestore v1.5.0/go.mod h1:FqBXDWBp4YLHqRnVGveOkHDf8svj9r5+mUDLupOWEDs= -cloud.google.com/go/filestore v1.6.0/go.mod h1:di5unNuss/qfZTw2U9nhFqo8/ZDSc466dre85Kydllg= -cloud.google.com/go/firestore v1.9.0/go.mod h1:HMkjKHNTtRyZNiMzu7YAsLr9K3X2udY2AMwDaMEQiiE= -cloud.google.com/go/functions v1.6.0/go.mod h1:3H1UA3qiIPRWD7PeZKLvHZ9SaQhR26XIJcC0A5GbvAk= -cloud.google.com/go/functions v1.7.0/go.mod h1:+d+QBcWM+RsrgZfV9xo6KfA1GlzJfxcfZcRPEhDDfzg= -cloud.google.com/go/functions v1.8.0/go.mod h1:RTZ4/HsQjIqIYP9a9YPbU+QFoQsAlYgrwOXJWHn1POY= -cloud.google.com/go/functions v1.9.0/go.mod h1:Y+Dz8yGguzO3PpIjhLTbnqV1CWmgQ5UwtlpzoyquQ08= -cloud.google.com/go/functions v1.10.0/go.mod h1:0D3hEOe3DbEvCXtYOZHQZmD+SzYsi1YbI7dGvHfldXw= -cloud.google.com/go/functions v1.12.0/go.mod h1:AXWGrF3e2C/5ehvwYo/GH6O5s09tOPksiKhz+hH8WkA= -cloud.google.com/go/functions v1.13.0/go.mod h1:EU4O007sQm6Ef/PwRsI8N2umygGqPBS/IZQKBQBcJ3c= -cloud.google.com/go/gaming v1.5.0/go.mod h1:ol7rGcxP/qHTRQE/RO4bxkXq+Fix0j6D4LFPzYTIrDM= -cloud.google.com/go/gaming v1.6.0/go.mod h1:YMU1GEvA39Qt3zWGyAVA9bpYz/yAhTvaQ1t2sK4KPUA= -cloud.google.com/go/gaming v1.7.0/go.mod h1:LrB8U7MHdGgFG851iHAfqUdLcKBdQ55hzXy9xBJz0+w= -cloud.google.com/go/gaming v1.8.0/go.mod h1:xAqjS8b7jAVW0KFYeRUxngo9My3f33kFmua++Pi+ggM= -cloud.google.com/go/gaming v1.9.0/go.mod h1:Fc7kEmCObylSWLO334NcO+O9QMDyz+TKC4v1D7X+Bc0= -cloud.google.com/go/gkebackup v0.2.0/go.mod h1:XKvv/4LfG829/B8B7xRkk8zRrOEbKtEam6yNfuQNH60= -cloud.google.com/go/gkebackup v0.3.0/go.mod h1:n/E671i1aOQvUxT541aTkCwExO/bTer2HDlj4TsBRAo= -cloud.google.com/go/gkebackup v0.4.0/go.mod h1:byAyBGUwYGEEww7xsbnUTBHIYcOPy/PgUWUtOeRm9Vg= -cloud.google.com/go/gkeconnect v0.5.0/go.mod h1:c5lsNAg5EwAy7fkqX/+goqFsU1Da/jQFqArp+wGNr/o= -cloud.google.com/go/gkeconnect v0.6.0/go.mod h1:Mln67KyU/sHJEBY8kFZ0xTeyPtzbq9StAVvEULYK16A= -cloud.google.com/go/gkeconnect v0.7.0/go.mod h1:SNfmVqPkaEi3bF/B3CNZOAYPYdg7sU+obZ+QTky2Myw= -cloud.google.com/go/gkehub v0.9.0/go.mod h1:WYHN6WG8w9bXU0hqNxt8rm5uxnk8IH+lPY9J2TV7BK0= -cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y977wO+hBH0= -cloud.google.com/go/gkehub v0.11.0/go.mod h1:JOWHlmN+GHyIbuWQPl47/C2RFhnFKH38jH9Ascu3n0E= -cloud.google.com/go/gkehub v0.12.0/go.mod h1:djiIwwzTTBrF5NaXCGv3mf7klpEMcST17VBTVVDcuaw= -cloud.google.com/go/gkemulticloud v0.3.0/go.mod h1:7orzy7O0S+5kq95e4Hpn7RysVA7dPs8W/GgfUtsPbrA= -cloud.google.com/go/gkemulticloud v0.4.0/go.mod h1:E9gxVBnseLWCk24ch+P9+B2CoDFJZTyIgLKSalC7tuI= -cloud.google.com/go/gkemulticloud v0.5.0/go.mod h1:W0JDkiyi3Tqh0TJr//y19wyb1yf8llHVto2Htf2Ja3Y= -cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= -cloud.google.com/go/gsuiteaddons v1.3.0/go.mod h1:EUNK/J1lZEZO8yPtykKxLXI6JSVN2rg9bN8SXOa0bgM= -cloud.google.com/go/gsuiteaddons v1.4.0/go.mod h1:rZK5I8hht7u7HxFQcFei0+AtfS9uSushomRlg+3ua1o= -cloud.google.com/go/gsuiteaddons v1.5.0/go.mod h1:TFCClYLd64Eaa12sFVmUyG62tk4mdIsI7pAnSXRkcFo= -cloud.google.com/go/iam v0.1.0/go.mod h1:vcUNEa0pEm0qRVpmWepWaFMIAI8/hjB9mO8rNCJtF6c= -cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= -cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= -cloud.google.com/go/iam v0.6.0/go.mod h1:+1AH33ueBne5MzYccyMHtEKqLE4/kJOibtffMHDMFMc= -cloud.google.com/go/iam v0.7.0/go.mod h1:H5Br8wRaDGNc8XP3keLc4unfUUZeyH3Sfl9XpQEYOeg= -cloud.google.com/go/iam v0.8.0/go.mod h1:lga0/y3iH6CX7sYqypWJ33hf7kkfXJag67naqGESjkE= -cloud.google.com/go/iam v0.11.0/go.mod h1:9PiLDanza5D+oWFZiH1uG+RnRCfEGKoyl6yo4cgWZGY= -cloud.google.com/go/iam v0.12.0/go.mod h1:knyHGviacl11zrtZUoDuYpDgLjvr28sLQaG0YB2GYAY= -cloud.google.com/go/iam v0.13.0/go.mod h1:ljOg+rcNfzZ5d6f1nAUJ8ZIxOaZUVoS14bKCtaLZ/D0= -cloud.google.com/go/iam v1.5.2 h1:qgFRAGEmd8z6dJ/qyEchAuL9jpswyODjA2lS+w234g8= -cloud.google.com/go/iam v1.5.2/go.mod h1:SE1vg0N81zQqLzQEwxL2WI6yhetBdbNQuTvIKCSkUHE= -cloud.google.com/go/iap v1.4.0/go.mod h1:RGFwRJdihTINIe4wZ2iCP0zF/qu18ZwyKxrhMhygBEc= -cloud.google.com/go/iap v1.5.0/go.mod h1:UH/CGgKd4KyohZL5Pt0jSKE4m3FR51qg6FKQ/z/Ix9A= -cloud.google.com/go/iap v1.6.0/go.mod h1:NSuvI9C/j7UdjGjIde7t7HBz+QTwBcapPE07+sSRcLk= -cloud.google.com/go/iap v1.7.0/go.mod h1:beqQx56T9O1G1yNPph+spKpNibDlYIiIixiqsQXxLIo= -cloud.google.com/go/iap v1.7.1/go.mod h1:WapEwPc7ZxGt2jFGB/C/bm+hP0Y6NXzOYGjpPnmMS74= -cloud.google.com/go/ids v1.1.0/go.mod h1:WIuwCaYVOzHIj2OhN9HAwvW+DBdmUAdcWlFxRl+KubM= -cloud.google.com/go/ids v1.2.0/go.mod h1:5WXvp4n25S0rA/mQWAg1YEEBBq6/s+7ml1RDCW1IrcY= -cloud.google.com/go/ids v1.3.0/go.mod h1:JBdTYwANikFKaDP6LtW5JAi4gubs57SVNQjemdt6xV4= -cloud.google.com/go/iot v1.3.0/go.mod h1:r7RGh2B61+B8oz0AGE+J72AhA0G7tdXItODWsaA2oLs= -cloud.google.com/go/iot v1.4.0/go.mod h1:dIDxPOn0UvNDUMD8Ger7FIaTuvMkj+aGk94RPP0iV+g= -cloud.google.com/go/iot v1.5.0/go.mod h1:mpz5259PDl3XJthEmh9+ap0affn/MqNSP4My77Qql9o= -cloud.google.com/go/iot v1.6.0/go.mod h1:IqdAsmE2cTYYNO1Fvjfzo9po179rAtJeVGUvkLN3rLE= -cloud.google.com/go/kms v1.4.0/go.mod h1:fajBHndQ+6ubNw6Ss2sSd+SWvjL26RNo/dr7uxsnnOA= -cloud.google.com/go/kms v1.5.0/go.mod h1:QJS2YY0eJGBg3mnDfuaCyLauWwBJiHRboYxJ++1xJNg= -cloud.google.com/go/kms v1.6.0/go.mod h1:Jjy850yySiasBUDi6KFUwUv2n1+o7QZFyuUJg6OgjA0= -cloud.google.com/go/kms v1.8.0/go.mod h1:4xFEhYFqvW+4VMELtZyxomGSYtSQKzM178ylFW4jMAg= -cloud.google.com/go/kms v1.9.0/go.mod h1:qb1tPTgfF9RQP8e1wq4cLFErVuTJv7UsSC915J8dh3w= -cloud.google.com/go/kms v1.10.0/go.mod h1:ng3KTUtQQU9bPX3+QGLsflZIHlkbn8amFAMY63m8d24= -cloud.google.com/go/kms v1.10.1/go.mod h1:rIWk/TryCkR59GMC3YtHtXeLzd634lBbKenvyySAyYI= -cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= -cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= -cloud.google.com/go/language v1.7.0/go.mod h1:DJ6dYN/W+SQOjF8e1hLQXMF21AkH2w9wiPzPCJa2MIE= -cloud.google.com/go/language v1.8.0/go.mod h1:qYPVHf7SPoNNiCL2Dr0FfEFNil1qi3pQEyygwpgVKB8= -cloud.google.com/go/language v1.9.0/go.mod h1:Ns15WooPM5Ad/5no/0n81yUetis74g3zrbeJBE+ptUY= -cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= -cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08= -cloud.google.com/go/lifesciences v0.8.0/go.mod h1:lFxiEOMqII6XggGbOnKiyZ7IBwoIqA84ClvoezaA/bo= -cloud.google.com/go/logging v1.6.1/go.mod h1:5ZO0mHHbvm8gEmeEUHrmDlTDSu5imF6MUP9OfilNXBw= -cloud.google.com/go/logging v1.7.0/go.mod h1:3xjP2CjkM3ZkO73aj4ASA5wRPGGCRrPIAeNqVNkzY8M= -cloud.google.com/go/longrunning v0.1.1/go.mod h1:UUFxuDWkv22EuY93jjmDMFT5GPQKeFVJBIF6QlTqdsE= -cloud.google.com/go/longrunning v0.3.0/go.mod h1:qth9Y41RRSUE69rDcOn6DdK3HfQfsUI0YSmW3iIlLJc= -cloud.google.com/go/longrunning v0.4.1/go.mod h1:4iWDqhBZ70CvZ6BfETbvam3T8FMvLK+eFj0E6AaRQTo= -cloud.google.com/go/longrunning v0.6.7 h1:IGtfDWHhQCgCjwQjV9iiLnUta9LBCo8R9QmAFsS/PrE= -cloud.google.com/go/longrunning v0.6.7/go.mod h1:EAFV3IZAKmM56TyiE6VAP3VoTzhZzySwI/YI1s/nRsY= -cloud.google.com/go/managedidentities v1.3.0/go.mod h1:UzlW3cBOiPrzucO5qWkNkh0w33KFtBJU281hacNvsdE= -cloud.google.com/go/managedidentities v1.4.0/go.mod h1:NWSBYbEMgqmbZsLIyKvxrYbtqOsxY1ZrGM+9RgDqInM= -cloud.google.com/go/managedidentities v1.5.0/go.mod h1:+dWcZ0JlUmpuxpIDfyP5pP5y0bLdRwOS4Lp7gMni/LA= -cloud.google.com/go/maps v0.1.0/go.mod h1:BQM97WGyfw9FWEmQMpZ5T6cpovXXSd1cGmFma94eubI= -cloud.google.com/go/maps v0.6.0/go.mod h1:o6DAMMfb+aINHz/p/jbcY+mYeXBoZoxTfdSQ8VAJaCw= -cloud.google.com/go/maps v0.7.0/go.mod h1:3GnvVl3cqeSvgMcpRlQidXsPYuDGQ8naBis7MVzpXsY= -cloud.google.com/go/mediatranslation v0.5.0/go.mod h1:jGPUhGTybqsPQn91pNXw0xVHfuJ3leR1wj37oU3y1f4= -cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w= -cloud.google.com/go/mediatranslation v0.7.0/go.mod h1:LCnB/gZr90ONOIQLgSXagp8XUW1ODs2UmUMvcgMfI2I= -cloud.google.com/go/memcache v1.4.0/go.mod h1:rTOfiGZtJX1AaFUrOgsMHX5kAzaTQ8azHiuDoTPzNsE= -cloud.google.com/go/memcache v1.5.0/go.mod h1:dk3fCK7dVo0cUU2c36jKb4VqKPS22BTkf81Xq617aWM= -cloud.google.com/go/memcache v1.6.0/go.mod h1:XS5xB0eQZdHtTuTF9Hf8eJkKtR3pVRCcvJwtm68T3rA= -cloud.google.com/go/memcache v1.7.0/go.mod h1:ywMKfjWhNtkQTxrWxCkCFkoPjLHPW6A7WOTVI8xy3LY= -cloud.google.com/go/memcache v1.9.0/go.mod h1:8oEyzXCu+zo9RzlEaEjHl4KkgjlNDaXbCQeQWlzNFJM= -cloud.google.com/go/metastore v1.5.0/go.mod h1:2ZNrDcQwghfdtCwJ33nM0+GrBGlVuh8rakL3vdPY3XY= -cloud.google.com/go/metastore v1.6.0/go.mod h1:6cyQTls8CWXzk45G55x57DVQ9gWg7RiH65+YgPsNh9s= -cloud.google.com/go/metastore v1.7.0/go.mod h1:s45D0B4IlsINu87/AsWiEVYbLaIMeUSoxlKKDqBGFS8= -cloud.google.com/go/metastore v1.8.0/go.mod h1:zHiMc4ZUpBiM7twCIFQmJ9JMEkDSyZS9U12uf7wHqSI= -cloud.google.com/go/metastore v1.10.0/go.mod h1:fPEnH3g4JJAk+gMRnrAnoqyv2lpUCqJPWOodSaf45Eo= -cloud.google.com/go/monitoring v1.7.0/go.mod h1:HpYse6kkGo//7p6sT0wsIC6IBDET0RhIsnmlA53dvEk= -cloud.google.com/go/monitoring v1.8.0/go.mod h1:E7PtoMJ1kQXWxPjB6mv2fhC5/15jInuulFdYYtlcvT4= -cloud.google.com/go/monitoring v1.12.0/go.mod h1:yx8Jj2fZNEkL/GYZyTLS4ZtZEZN8WtDEiEqG4kLK50w= -cloud.google.com/go/monitoring v1.13.0/go.mod h1:k2yMBAB1H9JT/QETjNkgdCGD9bPF712XiLTVr+cBrpw= -cloud.google.com/go/networkconnectivity v1.4.0/go.mod h1:nOl7YL8odKyAOtzNX73/M5/mGZgqqMeryi6UPZTk/rA= -cloud.google.com/go/networkconnectivity v1.5.0/go.mod h1:3GzqJx7uhtlM3kln0+x5wyFvuVH1pIBJjhCpjzSt75o= -cloud.google.com/go/networkconnectivity v1.6.0/go.mod h1:OJOoEXW+0LAxHh89nXd64uGG+FbQoeH8DtxCHVOMlaM= -cloud.google.com/go/networkconnectivity v1.7.0/go.mod h1:RMuSbkdbPwNMQjB5HBWD5MpTBnNm39iAVpC3TmsExt8= -cloud.google.com/go/networkconnectivity v1.10.0/go.mod h1:UP4O4sWXJG13AqrTdQCD9TnLGEbtNRqjuaaA7bNjF5E= -cloud.google.com/go/networkconnectivity v1.11.0/go.mod h1:iWmDD4QF16VCDLXUqvyspJjIEtBR/4zq5hwnY2X3scM= -cloud.google.com/go/networkmanagement v1.4.0/go.mod h1:Q9mdLLRn60AsOrPc8rs8iNV6OHXaGcDdsIQe1ohekq8= -cloud.google.com/go/networkmanagement v1.5.0/go.mod h1:ZnOeZ/evzUdUsnvRt792H0uYEnHQEMaz+REhhzJRcf4= -cloud.google.com/go/networkmanagement v1.6.0/go.mod h1:5pKPqyXjB/sgtvB5xqOemumoQNB7y95Q7S+4rjSOPYY= -cloud.google.com/go/networksecurity v0.5.0/go.mod h1:xS6fOCoqpVC5zx15Z/MqkfDwH4+m/61A3ODiDV1xmiQ= -cloud.google.com/go/networksecurity v0.6.0/go.mod h1:Q5fjhTr9WMI5mbpRYEbiexTzROf7ZbDzvzCrNl14nyU= -cloud.google.com/go/networksecurity v0.7.0/go.mod h1:mAnzoxx/8TBSyXEeESMy9OOYwo1v+gZ5eMRnsT5bC8k= -cloud.google.com/go/networksecurity v0.8.0/go.mod h1:B78DkqsxFG5zRSVuwYFRZ9Xz8IcQ5iECsNrPn74hKHU= -cloud.google.com/go/notebooks v1.2.0/go.mod h1:9+wtppMfVPUeJ8fIWPOq1UnATHISkGXGqTkxeieQ6UY= -cloud.google.com/go/notebooks v1.3.0/go.mod h1:bFR5lj07DtCPC7YAAJ//vHskFBxA5JzYlH68kXVdk34= -cloud.google.com/go/notebooks v1.4.0/go.mod h1:4QPMngcwmgb6uw7Po99B2xv5ufVoIQ7nOGDyL4P8AgA= -cloud.google.com/go/notebooks v1.5.0/go.mod h1:q8mwhnP9aR8Hpfnrc5iN5IBhrXUy8S2vuYs+kBJ/gu0= -cloud.google.com/go/notebooks v1.7.0/go.mod h1:PVlaDGfJgj1fl1S3dUwhFMXFgfYGhYQt2164xOMONmE= -cloud.google.com/go/notebooks v1.8.0/go.mod h1:Lq6dYKOYOWUCTvw5t2q1gp1lAp0zxAxRycayS0iJcqQ= -cloud.google.com/go/optimization v1.1.0/go.mod h1:5po+wfvX5AQlPznyVEZjGJTMr4+CAkJf2XSTQOOl9l4= -cloud.google.com/go/optimization v1.2.0/go.mod h1:Lr7SOHdRDENsh+WXVmQhQTrzdu9ybg0NecjHidBq6xs= -cloud.google.com/go/optimization v1.3.1/go.mod h1:IvUSefKiwd1a5p0RgHDbWCIbDFgKuEdB+fPPuP0IDLI= -cloud.google.com/go/orchestration v1.3.0/go.mod h1:Sj5tq/JpWiB//X/q3Ngwdl5K7B7Y0KZ7bfv0wL6fqVA= -cloud.google.com/go/orchestration v1.4.0/go.mod h1:6W5NLFWs2TlniBphAViZEVhrXRSMgUGDfW7vrWKvsBk= -cloud.google.com/go/orchestration v1.6.0/go.mod h1:M62Bevp7pkxStDfFfTuCOaXgaaqRAga1yKyoMtEoWPQ= -cloud.google.com/go/orgpolicy v1.4.0/go.mod h1:xrSLIV4RePWmP9P3tBl8S93lTmlAxjm06NSm2UTmKvE= -cloud.google.com/go/orgpolicy v1.5.0/go.mod h1:hZEc5q3wzwXJaKrsx5+Ewg0u1LxJ51nNFlext7Tanwc= -cloud.google.com/go/orgpolicy v1.10.0/go.mod h1:w1fo8b7rRqlXlIJbVhOMPrwVljyuW5mqssvBtU18ONc= -cloud.google.com/go/osconfig v1.7.0/go.mod h1:oVHeCeZELfJP7XLxcBGTMBvRO+1nQ5tFG9VQTmYS2Fs= -cloud.google.com/go/osconfig v1.8.0/go.mod h1:EQqZLu5w5XA7eKizepumcvWx+m8mJUhEwiPqWiZeEdg= -cloud.google.com/go/osconfig v1.9.0/go.mod h1:Yx+IeIZJ3bdWmzbQU4fxNl8xsZ4amB+dygAwFPlvnNo= -cloud.google.com/go/osconfig v1.10.0/go.mod h1:uMhCzqC5I8zfD9zDEAfvgVhDS8oIjySWh+l4WK6GnWw= -cloud.google.com/go/osconfig v1.11.0/go.mod h1:aDICxrur2ogRd9zY5ytBLV89KEgT2MKB2L/n6x1ooPw= -cloud.google.com/go/oslogin v1.4.0/go.mod h1:YdgMXWRaElXz/lDk1Na6Fh5orF7gvmJ0FGLIs9LId4E= -cloud.google.com/go/oslogin v1.5.0/go.mod h1:D260Qj11W2qx/HVF29zBg+0fd6YCSjSqLUkY/qEenQU= -cloud.google.com/go/oslogin v1.6.0/go.mod h1:zOJ1O3+dTU8WPlGEkFSh7qeHPPSoxrcMbbK1Nm2iX70= -cloud.google.com/go/oslogin v1.7.0/go.mod h1:e04SN0xO1UNJ1M5GP0vzVBFicIe4O53FOfcixIqTyXo= -cloud.google.com/go/oslogin v1.9.0/go.mod h1:HNavntnH8nzrn8JCTT5fj18FuJLFJc4NaZJtBnQtKFs= -cloud.google.com/go/phishingprotection v0.5.0/go.mod h1:Y3HZknsK9bc9dMi+oE8Bim0lczMU6hrX0UpADuMefr0= -cloud.google.com/go/phishingprotection v0.6.0/go.mod h1:9Y3LBLgy0kDTcYET8ZH3bq/7qni15yVUoAxiFxnlSUA= -cloud.google.com/go/phishingprotection v0.7.0/go.mod h1:8qJI4QKHoda/sb/7/YmMQ2omRLSLYSu9bU0EKCNI+Lk= -cloud.google.com/go/policytroubleshooter v1.3.0/go.mod h1:qy0+VwANja+kKrjlQuOzmlvscn4RNsAc0e15GGqfMxg= -cloud.google.com/go/policytroubleshooter v1.4.0/go.mod h1:DZT4BcRw3QoO8ota9xw/LKtPa8lKeCByYeKTIf/vxdE= -cloud.google.com/go/policytroubleshooter v1.5.0/go.mod h1:Rz1WfV+1oIpPdN2VvvuboLVRsB1Hclg3CKQ53j9l8vw= -cloud.google.com/go/policytroubleshooter v1.6.0/go.mod h1:zYqaPTsmfvpjm5ULxAyD/lINQxJ0DDsnWOP/GZ7xzBc= -cloud.google.com/go/privatecatalog v0.5.0/go.mod h1:XgosMUvvPyxDjAVNDYxJ7wBW8//hLDDYmnsNcMGq1K0= -cloud.google.com/go/privatecatalog v0.6.0/go.mod h1:i/fbkZR0hLN29eEWiiwue8Pb+GforiEIBnV9yrRUOKI= -cloud.google.com/go/privatecatalog v0.7.0/go.mod h1:2s5ssIFO69F5csTXcwBP7NPFTZvps26xGzvQ2PQaBYg= -cloud.google.com/go/privatecatalog v0.8.0/go.mod h1:nQ6pfaegeDAq/Q5lrfCQzQLhubPiZhSaNhIgfJlnIXs= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/pubsub v1.26.0/go.mod h1:QgBH3U/jdJy/ftjPhTkyXNj543Tin1pRYcdcPRnFIRI= -cloud.google.com/go/pubsub v1.27.1/go.mod h1:hQN39ymbV9geqBnfQq6Xf63yNhUAhv9CZhzp5O6qsW0= -cloud.google.com/go/pubsub v1.28.0/go.mod h1:vuXFpwaVoIPQMGXqRyUQigu/AX1S3IWugR9xznmcXX8= -cloud.google.com/go/pubsub v1.30.0/go.mod h1:qWi1OPS0B+b5L+Sg6Gmc9zD1Y+HaM0MdUr7LsupY1P4= -cloud.google.com/go/pubsublite v1.5.0/go.mod h1:xapqNQ1CuLfGi23Yda/9l4bBCKz/wC3KIJ5gKcxveZg= -cloud.google.com/go/pubsublite v1.6.0/go.mod h1:1eFCS0U11xlOuMFV/0iBqw3zP12kddMeCbj/F3FSj9k= -cloud.google.com/go/pubsublite v1.7.0/go.mod h1:8hVMwRXfDfvGm3fahVbtDbiLePT3gpoiJYJY+vxWxVM= -cloud.google.com/go/recaptchaenterprise v1.3.1/go.mod h1:OdD+q+y4XGeAlxRaMn1Y7/GveP6zmq76byL6tjPE7d4= -cloud.google.com/go/recaptchaenterprise/v2 v2.1.0/go.mod h1:w9yVqajwroDNTfGuhmOjPDN//rZGySaf6PtFVcSCa7o= -cloud.google.com/go/recaptchaenterprise/v2 v2.2.0/go.mod h1:/Zu5jisWGeERrd5HnlS3EUGb/D335f9k51B/FVil0jk= -cloud.google.com/go/recaptchaenterprise/v2 v2.3.0/go.mod h1:O9LwGCjrhGHBQET5CA7dd5NwwNQUErSgEDit1DLNTdo= -cloud.google.com/go/recaptchaenterprise/v2 v2.4.0/go.mod h1:Am3LHfOuBstrLrNCBrlI5sbwx9LBg3te2N6hGvHn2mE= -cloud.google.com/go/recaptchaenterprise/v2 v2.5.0/go.mod h1:O8LzcHXN3rz0j+LBC91jrwI3R+1ZSZEWrfL7XHgNo9U= -cloud.google.com/go/recaptchaenterprise/v2 v2.6.0/go.mod h1:RPauz9jeLtB3JVzg6nCbe12qNoaa8pXc4d/YukAmcnA= -cloud.google.com/go/recaptchaenterprise/v2 v2.7.0/go.mod h1:19wVj/fs5RtYtynAPJdDTb69oW0vNHYDBTbB4NvMD9c= -cloud.google.com/go/recommendationengine v0.5.0/go.mod h1:E5756pJcVFeVgaQv3WNpImkFP8a+RptV6dDLGPILjvg= -cloud.google.com/go/recommendationengine v0.6.0/go.mod h1:08mq2umu9oIqc7tDy8sx+MNJdLG0fUi3vaSVbztHgJ4= -cloud.google.com/go/recommendationengine v0.7.0/go.mod h1:1reUcE3GIu6MeBz/h5xZJqNLuuVjNg1lmWMPyjatzac= -cloud.google.com/go/recommender v1.5.0/go.mod h1:jdoeiBIVrJe9gQjwd759ecLJbxCDED4A6p+mqoqDvTg= -cloud.google.com/go/recommender v1.6.0/go.mod h1:+yETpm25mcoiECKh9DEScGzIRyDKpZ0cEhWGo+8bo+c= -cloud.google.com/go/recommender v1.7.0/go.mod h1:XLHs/W+T8olwlGOgfQenXBTbIseGclClff6lhFVe9Bs= -cloud.google.com/go/recommender v1.8.0/go.mod h1:PkjXrTT05BFKwxaUxQmtIlrtj0kph108r02ZZQ5FE70= -cloud.google.com/go/recommender v1.9.0/go.mod h1:PnSsnZY7q+VL1uax2JWkt/UegHssxjUVVCrX52CuEmQ= -cloud.google.com/go/redis v1.7.0/go.mod h1:V3x5Jq1jzUcg+UNsRvdmsfuFnit1cfe3Z/PGyq/lm4Y= -cloud.google.com/go/redis v1.8.0/go.mod h1:Fm2szCDavWzBk2cDKxrkmWBqoCiL1+Ctwq7EyqBCA/A= -cloud.google.com/go/redis v1.9.0/go.mod h1:HMYQuajvb2D0LvMgZmLDZW8V5aOC/WxstZHiy4g8OiA= -cloud.google.com/go/redis v1.10.0/go.mod h1:ThJf3mMBQtW18JzGgh41/Wld6vnDDc/F/F35UolRZPM= -cloud.google.com/go/redis v1.11.0/go.mod h1:/X6eicana+BWcUda5PpwZC48o37SiFVTFSs0fWAJ7uQ= -cloud.google.com/go/resourcemanager v1.3.0/go.mod h1:bAtrTjZQFJkiWTPDb1WBjzvc6/kifjj4QBYuKCCoqKA= -cloud.google.com/go/resourcemanager v1.4.0/go.mod h1:MwxuzkumyTX7/a3n37gmsT3py7LIXwrShilPh3P1tR0= -cloud.google.com/go/resourcemanager v1.5.0/go.mod h1:eQoXNAiAvCf5PXxWxXjhKQoTMaUSNrEfg+6qdf/wots= -cloud.google.com/go/resourcemanager v1.6.0/go.mod h1:YcpXGRs8fDzcUl1Xw8uOVmI8JEadvhRIkoXXUNVYcVo= -cloud.google.com/go/resourcemanager v1.7.0/go.mod h1:HlD3m6+bwhzj9XCouqmeiGuni95NTrExfhoSrkC/3EI= -cloud.google.com/go/resourcesettings v1.3.0/go.mod h1:lzew8VfESA5DQ8gdlHwMrqZs1S9V87v3oCnKCWoOuQU= -cloud.google.com/go/resourcesettings v1.4.0/go.mod h1:ldiH9IJpcrlC3VSuCGvjR5of/ezRrOxFtpJoJo5SmXg= -cloud.google.com/go/resourcesettings v1.5.0/go.mod h1:+xJF7QSG6undsQDfsCJyqWXyBwUoJLhetkRMDRnIoXA= -cloud.google.com/go/retail v1.8.0/go.mod h1:QblKS8waDmNUhghY2TI9O3JLlFk8jybHeV4BF19FrE4= -cloud.google.com/go/retail v1.9.0/go.mod h1:g6jb6mKuCS1QKnH/dpu7isX253absFl6iE92nHwlBUY= -cloud.google.com/go/retail v1.10.0/go.mod h1:2gDk9HsL4HMS4oZwz6daui2/jmKvqShXKQuB2RZ+cCc= -cloud.google.com/go/retail v1.11.0/go.mod h1:MBLk1NaWPmh6iVFSz9MeKG/Psyd7TAgm6y/9L2B4x9Y= -cloud.google.com/go/retail v1.12.0/go.mod h1:UMkelN/0Z8XvKymXFbD4EhFJlYKRx1FGhQkVPU5kF14= -cloud.google.com/go/run v0.2.0/go.mod h1:CNtKsTA1sDcnqqIFR3Pb5Tq0usWxJJvsWOCPldRU3Do= -cloud.google.com/go/run v0.3.0/go.mod h1:TuyY1+taHxTjrD0ZFk2iAR+xyOXEA0ztb7U3UNA0zBo= -cloud.google.com/go/run v0.8.0/go.mod h1:VniEnuBwqjigv0A7ONfQUaEItaiCRVujlMqerPPiktM= -cloud.google.com/go/run v0.9.0/go.mod h1:Wwu+/vvg8Y+JUApMwEDfVfhetv30hCG4ZwDR/IXl2Qg= -cloud.google.com/go/scheduler v1.4.0/go.mod h1:drcJBmxF3aqZJRhmkHQ9b3uSSpQoltBPGPxGAWROx6s= -cloud.google.com/go/scheduler v1.5.0/go.mod h1:ri073ym49NW3AfT6DZi21vLZrG07GXr5p3H1KxN5QlI= -cloud.google.com/go/scheduler v1.6.0/go.mod h1:SgeKVM7MIwPn3BqtcBntpLyrIJftQISRrYB5ZtT+KOk= -cloud.google.com/go/scheduler v1.7.0/go.mod h1:jyCiBqWW956uBjjPMMuX09n3x37mtyPJegEWKxRsn44= -cloud.google.com/go/scheduler v1.8.0/go.mod h1:TCET+Y5Gp1YgHT8py4nlg2Sew8nUHMqcpousDgXJVQc= -cloud.google.com/go/scheduler v1.9.0/go.mod h1:yexg5t+KSmqu+njTIh3b7oYPheFtBWGcbVUYF1GGMIc= -cloud.google.com/go/secretmanager v1.6.0/go.mod h1:awVa/OXF6IiyaU1wQ34inzQNc4ISIDIrId8qE5QGgKA= -cloud.google.com/go/secretmanager v1.8.0/go.mod h1:hnVgi/bN5MYHd3Gt0SPuTPPp5ENina1/LxM+2W9U9J4= -cloud.google.com/go/secretmanager v1.9.0/go.mod h1:b71qH2l1yHmWQHt9LC80akm86mX8AL6X1MA01dW8ht4= -cloud.google.com/go/secretmanager v1.10.0/go.mod h1:MfnrdvKMPNra9aZtQFvBcvRU54hbPD8/HayQdlUgJpU= -cloud.google.com/go/security v1.5.0/go.mod h1:lgxGdyOKKjHL4YG3/YwIL2zLqMFCKs0UbQwgyZmfJl4= -cloud.google.com/go/security v1.7.0/go.mod h1:mZklORHl6Bg7CNnnjLH//0UlAlaXqiG7Lb9PsPXLfD0= -cloud.google.com/go/security v1.8.0/go.mod h1:hAQOwgmaHhztFhiQ41CjDODdWP0+AE1B3sX4OFlq+GU= -cloud.google.com/go/security v1.9.0/go.mod h1:6Ta1bO8LXI89nZnmnsZGp9lVoVWXqsVbIq/t9dzI+2Q= -cloud.google.com/go/security v1.10.0/go.mod h1:QtOMZByJVlibUT2h9afNDWRZ1G96gVywH8T5GUSb9IA= -cloud.google.com/go/security v1.12.0/go.mod h1:rV6EhrpbNHrrxqlvW0BWAIawFWq3X90SduMJdFwtLB8= -cloud.google.com/go/security v1.13.0/go.mod h1:Q1Nvxl1PAgmeW0y3HTt54JYIvUdtcpYKVfIB8AOMZ+0= -cloud.google.com/go/securitycenter v1.13.0/go.mod h1:cv5qNAqjY84FCN6Y9z28WlkKXyWsgLO832YiWwkCWcU= -cloud.google.com/go/securitycenter v1.14.0/go.mod h1:gZLAhtyKv85n52XYWt6RmeBdydyxfPeTrpToDPw4Auc= -cloud.google.com/go/securitycenter v1.15.0/go.mod h1:PeKJ0t8MoFmmXLXWm41JidyzI3PJjd8sXWaVqg43WWk= -cloud.google.com/go/securitycenter v1.16.0/go.mod h1:Q9GMaLQFUD+5ZTabrbujNWLtSLZIZF7SAR0wWECrjdk= -cloud.google.com/go/securitycenter v1.18.1/go.mod h1:0/25gAzCM/9OL9vVx4ChPeM/+DlfGQJDwBy/UC8AKK0= -cloud.google.com/go/securitycenter v1.19.0/go.mod h1:LVLmSg8ZkkyaNy4u7HCIshAngSQ8EcIRREP3xBnyfag= -cloud.google.com/go/servicecontrol v1.4.0/go.mod h1:o0hUSJ1TXJAmi/7fLJAedOovnujSEvjKCAFNXPQ1RaU= -cloud.google.com/go/servicecontrol v1.5.0/go.mod h1:qM0CnXHhyqKVuiZnGKrIurvVImCs8gmqWsDoqe9sU1s= -cloud.google.com/go/servicecontrol v1.10.0/go.mod h1:pQvyvSRh7YzUF2efw7H87V92mxU8FnFDawMClGCNuAA= -cloud.google.com/go/servicecontrol v1.11.0/go.mod h1:kFmTzYzTUIuZs0ycVqRHNaNhgR+UMUpw9n02l/pY+mc= -cloud.google.com/go/servicecontrol v1.11.1/go.mod h1:aSnNNlwEFBY+PWGQ2DoM0JJ/QUXqV5/ZD9DOLB7SnUk= -cloud.google.com/go/servicedirectory v1.4.0/go.mod h1:gH1MUaZCgtP7qQiI+F+A+OpeKF/HQWgtAddhTbhL2bs= -cloud.google.com/go/servicedirectory v1.5.0/go.mod h1:QMKFL0NUySbpZJ1UZs3oFAmdvVxhhxB6eJ/Vlp73dfg= -cloud.google.com/go/servicedirectory v1.6.0/go.mod h1:pUlbnWsLH9c13yGkxCmfumWEPjsRs1RlmJ4pqiNjVL4= -cloud.google.com/go/servicedirectory v1.7.0/go.mod h1:5p/U5oyvgYGYejufvxhgwjL8UVXjkuw7q5XcG10wx1U= -cloud.google.com/go/servicedirectory v1.8.0/go.mod h1:srXodfhY1GFIPvltunswqXpVxFPpZjf8nkKQT7XcXaY= -cloud.google.com/go/servicedirectory v1.9.0/go.mod h1:29je5JjiygNYlmsGz8k6o+OZ8vd4f//bQLtvzkPPT/s= -cloud.google.com/go/servicemanagement v1.4.0/go.mod h1:d8t8MDbezI7Z2R1O/wu8oTggo3BI2GKYbdG4y/SJTco= -cloud.google.com/go/servicemanagement v1.5.0/go.mod h1:XGaCRe57kfqu4+lRxaFEAuqmjzF0r+gWHjWqKqBvKFo= -cloud.google.com/go/servicemanagement v1.6.0/go.mod h1:aWns7EeeCOtGEX4OvZUWCCJONRZeFKiptqKf1D0l/Jc= -cloud.google.com/go/servicemanagement v1.8.0/go.mod h1:MSS2TDlIEQD/fzsSGfCdJItQveu9NXnUniTrq/L8LK4= -cloud.google.com/go/serviceusage v1.3.0/go.mod h1:Hya1cozXM4SeSKTAgGXgj97GlqUvF5JaoXacR1JTP/E= -cloud.google.com/go/serviceusage v1.4.0/go.mod h1:SB4yxXSaYVuUBYUml6qklyONXNLt83U0Rb+CXyhjEeU= -cloud.google.com/go/serviceusage v1.5.0/go.mod h1:w8U1JvqUqwJNPEOTQjrMHkw3IaIFLoLsPLvsE3xueec= -cloud.google.com/go/serviceusage v1.6.0/go.mod h1:R5wwQcbOWsyuOfbP9tGdAnCAc6B9DRwPG1xtWMDeuPA= -cloud.google.com/go/shell v1.3.0/go.mod h1:VZ9HmRjZBsjLGXusm7K5Q5lzzByZmJHf1d0IWHEN5X4= -cloud.google.com/go/shell v1.4.0/go.mod h1:HDxPzZf3GkDdhExzD/gs8Grqk+dmYcEjGShZgYa9URw= -cloud.google.com/go/shell v1.6.0/go.mod h1:oHO8QACS90luWgxP3N9iZVuEiSF84zNyLytb+qE2f9A= -cloud.google.com/go/spanner v1.41.0/go.mod h1:MLYDBJR/dY4Wt7ZaMIQ7rXOTLjYrmxLE/5ve9vFfWos= -cloud.google.com/go/spanner v1.44.0/go.mod h1:G8XIgYdOK+Fbcpbs7p2fiprDw4CaZX63whnSMLVBxjk= -cloud.google.com/go/spanner v1.45.0/go.mod h1:FIws5LowYz8YAE1J8fOS7DJup8ff7xJeetWEo5REA2M= -cloud.google.com/go/speech v1.6.0/go.mod h1:79tcr4FHCimOp56lwC01xnt/WPJZc4v3gzyT7FoBkCM= -cloud.google.com/go/speech v1.7.0/go.mod h1:KptqL+BAQIhMsj1kOP2la5DSEEerPDuOP/2mmkhHhZQ= -cloud.google.com/go/speech v1.8.0/go.mod h1:9bYIl1/tjsAnMgKGHKmBZzXKEkGgtU+MpdDPTE9f7y0= -cloud.google.com/go/speech v1.9.0/go.mod h1:xQ0jTcmnRFFM2RfX/U+rk6FQNUF6DQlydUSyoooSpco= -cloud.google.com/go/speech v1.14.1/go.mod h1:gEosVRPJ9waG7zqqnsHpYTOoAS4KouMRLDFMekpJ0J0= -cloud.google.com/go/speech v1.15.0/go.mod h1:y6oH7GhqCaZANH7+Oe0BhgIogsNInLlz542tg3VqeYI= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= -cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= -cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= -cloud.google.com/go/storage v1.28.1/go.mod h1:Qnisd4CqDdo6BGs2AD5LLnEsmSQ80wQ5ogcBBKhU86Y= -cloud.google.com/go/storage v1.29.0/go.mod h1:4puEjyTKnku6gfKoTfNOU/W+a9JyuVNxjpS5GBrB8h4= -cloud.google.com/go/storagetransfer v1.5.0/go.mod h1:dxNzUopWy7RQevYFHewchb29POFv3/AaBgnhqzqiK0w= -cloud.google.com/go/storagetransfer v1.6.0/go.mod h1:y77xm4CQV/ZhFZH75PLEXY0ROiS7Gh6pSKrM8dJyg6I= -cloud.google.com/go/storagetransfer v1.7.0/go.mod h1:8Giuj1QNb1kfLAiWM1bN6dHzfdlDAVC9rv9abHot2W4= -cloud.google.com/go/storagetransfer v1.8.0/go.mod h1:JpegsHHU1eXg7lMHkvf+KE5XDJ7EQu0GwNJbbVGanEw= -cloud.google.com/go/talent v1.1.0/go.mod h1:Vl4pt9jiHKvOgF9KoZo6Kob9oV4lwd/ZD5Cto54zDRw= -cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g= -cloud.google.com/go/talent v1.3.0/go.mod h1:CmcxwJ/PKfRgd1pBjQgU6W3YBwiewmUzQYH5HHmSCmM= -cloud.google.com/go/talent v1.4.0/go.mod h1:ezFtAgVuRf8jRsvyE6EwmbTK5LKciD4KVnHuDEFmOOA= -cloud.google.com/go/talent v1.5.0/go.mod h1:G+ODMj9bsasAEJkQSzO2uHQWXHHXUomArjWQQYkqK6c= -cloud.google.com/go/texttospeech v1.4.0/go.mod h1:FX8HQHA6sEpJ7rCMSfXuzBcysDAuWusNNNvN9FELDd8= -cloud.google.com/go/texttospeech v1.5.0/go.mod h1:oKPLhR4n4ZdQqWKURdwxMy0uiTS1xU161C8W57Wkea4= -cloud.google.com/go/texttospeech v1.6.0/go.mod h1:YmwmFT8pj1aBblQOI3TfKmwibnsfvhIBzPXcW4EBovc= -cloud.google.com/go/tpu v1.3.0/go.mod h1:aJIManG0o20tfDQlRIej44FcwGGl/cD0oiRyMKG19IQ= -cloud.google.com/go/tpu v1.4.0/go.mod h1:mjZaX8p0VBgllCzF6wcU2ovUXN9TONFLd7iz227X2Xg= -cloud.google.com/go/tpu v1.5.0/go.mod h1:8zVo1rYDFuW2l4yZVY0R0fb/v44xLh3llq7RuV61fPM= -cloud.google.com/go/trace v1.3.0/go.mod h1:FFUE83d9Ca57C+K8rDl/Ih8LwOzWIV1krKgxg6N0G28= -cloud.google.com/go/trace v1.4.0/go.mod h1:UG0v8UBqzusp+z63o7FK74SdFE+AXpCLdFb1rshXG+Y= -cloud.google.com/go/trace v1.8.0/go.mod h1:zH7vcsbAhklH8hWFig58HvxcxyQbaIqMarMg9hn5ECA= -cloud.google.com/go/trace v1.9.0/go.mod h1:lOQqpE5IaWY0Ixg7/r2SjixMuc6lfTFeO4QGM4dQWOk= -cloud.google.com/go/translate v1.3.0/go.mod h1:gzMUwRjvOqj5i69y/LYLd8RrNQk+hOmIXTi9+nb3Djs= -cloud.google.com/go/translate v1.4.0/go.mod h1:06Dn/ppvLD6WvA5Rhdp029IX2Mi3Mn7fpMRLPvXT5Wg= -cloud.google.com/go/translate v1.5.0/go.mod h1:29YDSYveqqpA1CQFD7NQuP49xymq17RXNaUDdc0mNu0= -cloud.google.com/go/translate v1.6.0/go.mod h1:lMGRudH1pu7I3n3PETiOB2507gf3HnfLV8qlkHZEyos= -cloud.google.com/go/translate v1.7.0/go.mod h1:lMGRudH1pu7I3n3PETiOB2507gf3HnfLV8qlkHZEyos= -cloud.google.com/go/video v1.8.0/go.mod h1:sTzKFc0bUSByE8Yoh8X0mn8bMymItVGPfTuUBUyRgxk= -cloud.google.com/go/video v1.9.0/go.mod h1:0RhNKFRF5v92f8dQt0yhaHrEuH95m068JYOvLZYnJSw= -cloud.google.com/go/video v1.12.0/go.mod h1:MLQew95eTuaNDEGriQdcYn0dTwf9oWiA4uYebxM5kdg= -cloud.google.com/go/video v1.13.0/go.mod h1:ulzkYlYgCp15N2AokzKjy7MQ9ejuynOJdf1tR5lGthk= -cloud.google.com/go/video v1.14.0/go.mod h1:SkgaXwT+lIIAKqWAJfktHT/RbgjSuY6DobxEp0C5yTQ= -cloud.google.com/go/video v1.15.0/go.mod h1:SkgaXwT+lIIAKqWAJfktHT/RbgjSuY6DobxEp0C5yTQ= -cloud.google.com/go/videointelligence v1.6.0/go.mod h1:w0DIDlVRKtwPCn/C4iwZIJdvC69yInhW0cfi+p546uU= -cloud.google.com/go/videointelligence v1.7.0/go.mod h1:k8pI/1wAhjznARtVT9U1llUaFNPh7muw8QyOUpavru4= -cloud.google.com/go/videointelligence v1.8.0/go.mod h1:dIcCn4gVDdS7yte/w+koiXn5dWVplOZkE+xwG9FgK+M= -cloud.google.com/go/videointelligence v1.9.0/go.mod h1:29lVRMPDYHikk3v8EdPSaL8Ku+eMzDljjuvRs105XoU= -cloud.google.com/go/videointelligence v1.10.0/go.mod h1:LHZngX1liVtUhZvi2uNS0VQuOzNi2TkY1OakiuoUOjU= -cloud.google.com/go/vision v1.2.0/go.mod h1:SmNwgObm5DpFBme2xpyOyasvBc1aPdjvMk2bBk0tKD0= -cloud.google.com/go/vision/v2 v2.2.0/go.mod h1:uCdV4PpN1S0jyCyq8sIM42v2Y6zOLkZs+4R9LrGYwFo= -cloud.google.com/go/vision/v2 v2.3.0/go.mod h1:UO61abBx9QRMFkNBbf1D8B1LXdS2cGiiCRx0vSpZoUo= -cloud.google.com/go/vision/v2 v2.4.0/go.mod h1:VtI579ll9RpVTrdKdkMzckdnwMyX2JILb+MhPqRbPsY= -cloud.google.com/go/vision/v2 v2.5.0/go.mod h1:MmaezXOOE+IWa+cS7OhRRLK2cNv1ZL98zhqFFZaaH2E= -cloud.google.com/go/vision/v2 v2.6.0/go.mod h1:158Hes0MvOS9Z/bDMSFpjwsUrZ5fPrdwuyyvKSGAGMY= -cloud.google.com/go/vision/v2 v2.7.0/go.mod h1:H89VysHy21avemp6xcf9b9JvZHVehWbET0uT/bcuY/0= -cloud.google.com/go/vmmigration v1.2.0/go.mod h1:IRf0o7myyWFSmVR1ItrBSFLFD/rJkfDCUTO4vLlJvsE= -cloud.google.com/go/vmmigration v1.3.0/go.mod h1:oGJ6ZgGPQOFdjHuocGcLqX4lc98YQ7Ygq8YQwHh9A7g= -cloud.google.com/go/vmmigration v1.5.0/go.mod h1:E4YQ8q7/4W9gobHjQg4JJSgXXSgY21nA5r8swQV+Xxc= -cloud.google.com/go/vmmigration v1.6.0/go.mod h1:bopQ/g4z+8qXzichC7GW1w2MjbErL54rk3/C843CjfY= -cloud.google.com/go/vmwareengine v0.1.0/go.mod h1:RsdNEf/8UDvKllXhMz5J40XxDrNJNN4sagiox+OI208= -cloud.google.com/go/vmwareengine v0.2.2/go.mod h1:sKdctNJxb3KLZkE/6Oui94iw/xs9PRNC2wnNLXsHvH8= -cloud.google.com/go/vmwareengine v0.3.0/go.mod h1:wvoyMvNWdIzxMYSpH/R7y2h5h3WFkx6d+1TIsP39WGY= -cloud.google.com/go/vpcaccess v1.4.0/go.mod h1:aQHVbTWDYUR1EbTApSVvMq1EnT57ppDmQzZ3imqIk4w= -cloud.google.com/go/vpcaccess v1.5.0/go.mod h1:drmg4HLk9NkZpGfCmZ3Tz0Bwnm2+DKqViEpeEpOq0m8= -cloud.google.com/go/vpcaccess v1.6.0/go.mod h1:wX2ILaNhe7TlVa4vC5xce1bCnqE3AeH27RV31lnmZes= -cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xXZmFiHmGE= -cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= -cloud.google.com/go/webrisk v1.6.0/go.mod h1:65sW9V9rOosnc9ZY7A7jsy1zoHS5W9IAXv6dGqhMQMc= -cloud.google.com/go/webrisk v1.7.0/go.mod h1:mVMHgEYH0r337nmt1JyLthzMr6YxwN1aAIEc2fTcq7A= -cloud.google.com/go/webrisk v1.8.0/go.mod h1:oJPDuamzHXgUc+b8SiHRcVInZQuybnvEW72PqTc7sSg= -cloud.google.com/go/websecurityscanner v1.3.0/go.mod h1:uImdKm2wyeXQevQJXeh8Uun/Ym1VqworNDlBXQevGMo= -cloud.google.com/go/websecurityscanner v1.4.0/go.mod h1:ebit/Fp0a+FWu5j4JOmJEV8S8CzdTkAS77oDsiSqYWQ= -cloud.google.com/go/websecurityscanner v1.5.0/go.mod h1:Y6xdCPy81yi0SQnDY1xdNTNpfY1oAgXUlcfN3B3eSng= -cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= -cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -cloud.google.com/go/workflows v1.8.0/go.mod h1:ysGhmEajwZxGn1OhGOGKsTXc5PyxOc0vfKf5Af+to4M= -cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT3ujaO/WwSA= -cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcPALq2CxzdePw= -dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= -dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 h1:E0wvcUXTkgyN4wy4LGtNzMNGMytJN8afmIWXJVMi4cc= +ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= +buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.10-20250718181942-e35f9b667443.1 h1:FzJGrb8r7vir+P3zJ5Ebey8p54LYTYtQsrM/U35YO9Q= +buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.10-20250718181942-e35f9b667443.1/go.mod h1:E6HwqUm4Ag7bXtg/tX7jHWO7CgpknbmeACgDax0icV0= +buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.10-20250109164928-1da0de137947.1 h1:9hkMnVoImDlY7rTlAWIWXdkGUKOjf3YlyZeSbYT29uA= +buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.10-20250109164928-1da0de137947.1/go.mod h1:/AouMCAeQ+kB7+RRFpdUlZe3503p18VoUNcU2AFqZXM= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 h1:31on4W/yPcV4nZHL4+UCiCvLPsMqe/vJcNg8Rci0scc= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1/go.mod h1:fUl8CEN/6ZAMk6bP8ahBJPUJw7rbp+j4x+wCcYi2IG4= +buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251027152159-f1066ce064ca.2 h1:Dbh4Edwy5qHlz1/boPAQ7T5Q7ZDMgEuQlEbXa94+JEo= +buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251027152159-f1066ce064ca.2/go.mod h1:SqqTA3aiYVDkpDINxgbxDT6QBjkVjdqUXtbiz6DiWIg= +buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.10-20251027152159-f1066ce064ca.1 h1:5tUFlRgcC+N2JJtjwlwyb2J4bBk/bJYLXk50zlewtzk= +buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.10-20251027152159-f1066ce064ca.1/go.mod h1:AaYXXeRvnOc151wEuupAmn58Mh9bccKce2kk3QKMIrQ= +buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.10-20241007202033-cf42259fcbfc.1 h1:CzM0kZcoaIr8+R4i8QVorUNRM/CqMr87i3j+w2pdpCc= +buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.10-20241007202033-cf42259fcbfc.1/go.mod h1:bG+Fa7tcA+4pW0JdOh4h7iKjleyZIKhfVzVS10qfrnk= +buf.build/go/app v0.2.0 h1:NYaH13A+RzPb7M5vO8uZYZ2maBZI5+MS9A9tQm66fy8= +buf.build/go/app v0.2.0/go.mod h1:0XVOYemubVbxNXVY0DnsVgWeGkcbbAvjDa1fmhBC+Wo= +buf.build/go/bufplugin v0.9.0 h1:ktZJNP3If7ldcWVqh46XKeiYJVPxHQxCfjzVQDzZ/lo= +buf.build/go/bufplugin v0.9.0/go.mod h1:Z0CxA3sKQ6EPz/Os4kJJneeRO6CjPeidtP1ABh5jPPY= +buf.build/go/bufprivateusage v0.1.0 h1:SzCoCcmzS3zyXHEXHeSQhGI7OTkgtljoknLzsUz9Gg4= +buf.build/go/bufprivateusage v0.1.0/go.mod h1:GlCCJ3VVF7EqqU0CoRmo1FzAwwaKymEWSr+ty69xU5w= +buf.build/go/interrupt v1.1.0 h1:olBuhgv9Sav4/9pkSLoxgiOsZDgM5VhRhvRpn3DL0lE= +buf.build/go/interrupt v1.1.0/go.mod h1:ql56nXPG1oHlvZa6efNC7SKAQ/tUjS6z0mhJl0gyeRM= +buf.build/go/protovalidate v1.0.1 h1:Fwmf08OOUuKVeMvEnDmcKxQam4PJc/zFgvVX64BhTms= +buf.build/go/protovalidate v1.0.1/go.mod h1:SoZmvk/3ZzOVg9YSkTdm4grMAByjf8zgZq4ZNaLZXoQ= +buf.build/go/protoyaml v0.6.0 h1:Nzz1lvcXF8YgNZXk+voPPwdU8FjDPTUV4ndNTXN0n2w= +buf.build/go/protoyaml v0.6.0/go.mod h1:RgUOsBu/GYKLDSIRgQXniXbNgFlGEZnQpRAUdLAFV2Q= +buf.build/go/spdx v0.2.0 h1:IItqM0/cMxvFJJumcBuP8NrsIzMs/UYjp/6WSpq8LTw= +buf.build/go/spdx v0.2.0/go.mod h1:bXdwQFem9Si3nsbNy8aJKGPoaPi5DKwdeEp5/ArZ6w8= +buf.build/go/standard v0.1.0 h1:g98T9IyvAl0vS3Pq8iVk6Cvj2ZiFvoUJRtfyGa0120U= +buf.build/go/standard v0.1.0/go.mod h1:PiqpHz/7ZFq+kqvYhc/SK3lxFIB9N/aiH2CFC2JHIQg= +cel.dev/expr v0.25.0 h1:qbCFvDJJthxLvf3TqeF9Ys7pjjWrO7LMzfYhpJUc30g= +cel.dev/expr v0.25.0/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= +connectrpc.com/connect v1.19.1 h1:R5M57z05+90EfEvCY1b7hBxDVOUl45PrtXtAV2fOC14= +connectrpc.com/connect v1.19.1/go.mod h1:tN20fjdGlewnSFeZxLKb0xwIZ6ozc3OQs2hTXy4du9w= +connectrpc.com/otelconnect v0.8.0 h1:a4qrN4H8aEE2jAoCxheZYYfEjXMgVPyL9OzPQLBEFXU= +connectrpc.com/otelconnect v0.8.0/go.mod h1:AEkVLjCPXra+ObGFCOClcJkNjS7zPaQSqvO0lCyjfZc= dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -entgo.io/ent v0.14.4 h1:/DhDraSLXIkBhyiVoJeSshr4ZYi7femzhj6/TckzZuI= -entgo.io/ent v0.14.4/go.mod h1:aDPE/OziPEu8+OWbzy4UlvWmD2/kbRuWfK2A40hcxJM= -filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= -filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= -gioui.org v0.0.0-20210308172011-57750fc8a0a6/go.mod h1:RSH6KIUZ0p2xy5zHDxgAM4zumjgTw83q2ge/PI+yyw8= -git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3pc= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4= +entgo.io/ent v0.14.5/go.mod h1:zTzLmWtPvGpmSwtkaayM2cm5m819NdM7z7tYPq3vN0U= +github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= +github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= +github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg= +github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= -github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= -github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= -github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= -github.com/apache/arrow/go/v10 v10.0.1/go.mod h1:YvhnlEePVnBS4+0z3fhPfUy7W1Ikj0Ih0vcRo/gZ1M0= -github.com/apache/arrow/go/v11 v11.0.0/go.mod h1:Eg5OsL5H+e299f7u5ssuXsuHQVEGC4xei5aX110hRiI= -github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= -github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= -github.com/bmatcuk/doublestar/v4 v4.8.1 h1:54Bopc5c2cAvhLRAzqOGCYHYyhcDHsFF4wWIR5wKP38= -github.com/bmatcuk/doublestar/v4 v4.8.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= -github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= -github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ= -github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= +github.com/bmatcuk/doublestar/v4 v4.9.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/avrEXE= +github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4= +github.com/bufbuild/buf v1.61.0 h1:JPaK/RM2eoheyzznW+1LxaFgN6xjBCi8s25q2kUbH9A= +github.com/bufbuild/buf v1.61.0/go.mod h1:Xs3leBmxjL5tTnSVYfNwNXHXD1k5et3fR/tJyIyQl4s= +github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8 h1:l4PKzJ7Usff8j5/e+YaWZPaM+rJHIghgDxRn8vDNxNo= +github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8/go.mod h1:HKN246DRQwavs64sr2xYmSL+RFOFxmLti+WGCZ2jh9U= +github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1 h1:V1xulAoqLqVg44rY97xOR+mQpD2N+GzhMHVwJ030WEU= +github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1/go.mod h1:c5D8gWRIZ2HLWO3gXYTtUfw/hbJyD8xikv2ooPxnklQ= github.com/bytedance/sonic v1.13.3 h1:MS8gmaH16Gtirygw7jV91pDCN33NyMrPbN7qiYhEsF0= github.com/bytedance/sonic v1.13.3/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= +github.com/bytedance/sonic v1.14.1/go.mod h1:gi6uhQLMbTdeP0muCnrjHLeCUPyb70ujhnNlhOylAFc= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY= github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= -github.com/caarlos0/go-version v0.2.0 h1:TTD5dF3PBAtRHbfCKRE173SrVVpbE0yX95EDQ4BwTGs= -github.com/caarlos0/go-version v0.2.0/go.mod h1:X+rI5VAtJDpcjCjeEIXpxGa5+rTcgur1FK66wS0/944= -github.com/casbin/casbin/v2 v2.105.0 h1:dLj5P6pLApBRat9SADGiLxLZjiDPvA1bsPkyV4PGx6I= -github.com/casbin/casbin/v2 v2.105.0/go.mod h1:Ee33aqGrmES+GNL17L0h9X28wXuo829wnNUnS0edAco= +github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= +github.com/casbin/casbin/v2 v2.134.0 h1:wyO3hZb487GzlGVAI2hUoHQT0ehFD+9B5P+HVG9BVTM= +github.com/casbin/casbin/v2 v2.134.0/go.mod h1:FmcfntdXLTcYXv/hxgNntcRPqAbwOG9xsism0yXT+18= github.com/casbin/govaluate v1.3.0 h1:VA0eSY0M2lA86dYd5kPPuNZMUD9QkWnOCnavGrw9myc= github.com/casbin/govaluate v1.3.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= +github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20220314180256-7f1daf1720fc/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20230105202645-06c439db220b/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 h1:Om6kYQYDUk5wWbT0t0q6pvyM49i9XZAv9dDrkDA7gjk= -github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8= -github.com/cncf/xds/go v0.0.0-20250326154945-ae57f3c0d45f h1:C5bqEmzEPLsHm9Mv73lSE9e9bKV23aB1vxOsmZrkl3k= +github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f h1:Y8xYupdHxryycyPlc9Y+bSQAYZnetRJ70VMVKm5CKI0= +github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= +github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= +github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= +github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= +github.com/containerd/stargz-snapshotter/estargz v0.18.0 h1:Ny5yptQgEXSkDFKvlKJGTvf1YJ+4xD8V+hXqoRG0n74= +github.com/containerd/stargz-snapshotter/estargz v0.18.0/go.mod h1:7hfU1BO2KB3axZl0dRQCdnHrIWw7TRDdK6L44Rdeuo0= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= +github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dchest/uniuri v1.2.0 h1:koIcOUdrTIivZgSLhHQvKgqdWZq5d7KdMEWF1Ud6+5g= -github.com/dchest/uniuri v1.2.0/go.mod h1:fSzm4SLHzNZvWLvWJew423PhAzkpNQYq+uNLq4kxhkY= -github.com/denisenkom/go-mssqldb v0.12.3 h1:pBSGx9Tq67pBOTLmxNuirNTeB8Vjmf886Kx+8Y+8shw= -github.com/denisenkom/go-mssqldb v0.12.3/go.mod h1:k0mtMFOnU+AihqFxPMiF05rtiDrorD1Vrm1KEz5hxDo= -github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/docker/cli v28.5.1+incompatible h1:ESutzBALAD6qyCLqbQSEf1a/U8Ybms5agw59yGVc+yY= +github.com/docker/cli v28.5.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= +github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/docker v28.5.2+incompatible h1:DBX0Y0zAjZbSrm1uzOkdr1onVghKaftjlSWt4AFexzM= +github.com/docker/docker v28.5.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker-credential-helpers v0.9.4 h1:76ItO69/AP/V4yT9V4uuuItG0B1N8hvt0T0c0NN/DzI= +github.com/docker/docker-credential-helpers v0.9.4/go.mod h1:v1S+hepowrQXITkEfw6o4+BMbGot02wiKpzWhGUZK6c= +github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94= +github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE= +github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= +github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= -github.com/envoyproxy/go-control-plane v0.10.3/go.mod h1:fJJn/j26vwOu972OllsvAgJJM//w9BV6Fxbg2LuVd34= -github.com/envoyproxy/go-control-plane v0.13.4 h1:zEqyPVyku6IvWCFwux4x9RxkLOMUL+1vC9xUFv5l2/M= -github.com/envoyproxy/go-control-plane/envoy v1.32.4 h1:jb83lalDRZSpPWW2Z7Mck/8kXZ5CQAFYVjQcdVIr83A= -github.com/envoyproxy/go-control-plane/envoy v1.32.4/go.mod h1:Gzjc5k8JcJswLjAx1Zm+wSYE20UrLtt7JZMWiWQXQEw= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.6.7/go.mod h1:dyJXwwfPK2VSqiB9Klm1J6romD608Ba7Hij42vrOBCo= -github.com/envoyproxy/protoc-gen-validate v0.9.1/go.mod h1:OKNgG7TCp5pF4d6XftA0++PMirau2/yoOwVac3AbF2w= +github.com/emicklei/proto v1.14.2 h1:wJPxPy2Xifja9cEMrcA/g08art5+7CGJNFNk35iXC1I= +github.com/emicklei/proto v1.14.2/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= +github.com/envoyproxy/go-control-plane v0.13.5-0.20251024222203-75eaa193e329 h1:K+fnvUM0VZ7ZFJf0n4L/BRlnsb9pL/GuDG6FqaH+PwM= +github.com/envoyproxy/go-control-plane/envoy v1.35.0 h1:ixjkELDE+ru6idPxcHLj8LBVc2bFP7iBytj353BoHUo= github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8= github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= -github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= -github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY= -github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w= -github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM= -github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= -github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= -github.com/go-fonts/dejavu v0.1.0/go.mod h1:4Wt4I4OU2Nq9asgDCteaAaWZOV24E+0/Pwo0gppep4g= -github.com/go-fonts/latin-modern v0.2.0/go.mod h1:rQVLdDMK+mK1xscDwsqM5J8U2jrRa3T0ecnM9pNujks= -github.com/go-fonts/liberation v0.1.1/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= -github.com/go-fonts/liberation v0.2.0/go.mod h1:K6qoJYypsmfVjWg8KOVDQhLc8UDgIK2HYqyqAO9z7GY= -github.com/go-fonts/stix v0.1.0/go.mod h1:w/c1f0ldAUlJmLBvlbkvVXLAD+tAMqobIIQpmnUIzUY= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE= +github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= github.com/go-kratos/aegis v0.2.0 h1:dObzCDWn3XVjUkgxyBp6ZeWtx/do0DPZ7LY3yNSJLUQ= github.com/go-kratos/aegis v0.2.0/go.mod h1:v0R2m73WgEEYB3XYu6aE2WcMwsZkJ/Rzuf5eVccm7bI= -github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250427030626-b463dc514714 h1:QR7Fl4tegayNFvhUyxnwZwmWxtaegjYV7PbHxLcXo18= -github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20250427030626-b463dc514714/go.mod h1:bmXodVT3GSKZAfYskkDAZHCTeN3K04+vDZsho5SOPJg= -github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250427030626-b463dc514714 h1:iPVz2v4+Z6v54pg+B+Z5O8cwRGcrA1SsHNO1enNffRs= -github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20250427030626-b463dc514714/go.mod h1:I3L2JB86WBDlvBEICeJ39X/0KF0JJ4fkfbSg8LRSfRU= -github.com/go-kratos/kratos/v2 v2.8.4 h1:eIJLE9Qq9WSoKx+Buy2uPyrahtF/lPh+Xf4MTpxhmjs= -github.com/go-kratos/kratos/v2 v2.8.4/go.mod h1:mq62W2101a5uYyRxe+7IdWubu7gZCGYqSNKwGFiiRcw= -github.com/go-latex/latex v0.0.0-20210118124228-b3d85cf34e07/go.mod h1:CO1AlKB2CSIqUrmQPqA0gdRIlnLEY0gK5JGjh37zN5U= -github.com/go-latex/latex v0.0.0-20210823091927-c0d11ff05a81/go.mod h1:SX0U8uGpxhq9o2S/CELCSUxEWWAuoCUcVCQWv7G2OCk= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251106012513-9262193e351a h1:hXTsD6lWaAU7UQchbmafi9WLTyBMjoLttEnVpWMiGJA= +github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:tr3LJLUypg8Js3bClD6s7p2eWLTIitvq9Paf7FAK3R4= +github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251106012513-9262193e351a h1:3nyCH1sGH9sSWnnVDpvxywg8r+Esr1lObU6wTzW3ups= +github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= +github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251106012513-9262193e351a h1:lyM6XpKxtzwcII0cvVk8QsGyJvu9xMJT8yoW6fwIbT4= +github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= +github.com/go-kratos/kratos/v2 v2.9.1 h1:EGif6/S/aK/RCR5clIbyhioTNyoSrii3FC118jG40Z0= +github.com/go-kratos/kratos/v2 v2.9.1/go.mod h1:a1MQLjMhIh7R0kcJS9SzJYR43BRI7EPzzN0J1Ksu2bA= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= @@ -797,355 +149,157 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-openapi/inflect v0.21.2 h1:0gClGlGcxifcJR56zwvhaOulnNgnhc4qTAkob5ObnSM= github.com/go-openapi/inflect v0.21.2/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw= -github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= -github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M= -github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/form/v4 v4.2.2 h1:pIt/C1OwOw5W/KsxYK1tGq1C4IfPoE5eju44IlTzMlM= -github.com/go-playground/form/v4 v4.2.2/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k= -github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo= -github.com/go-sql-driver/mysql v1.9.2 h1:4cNKDYQ1I84SXslGddlsrMhc8k4LeDVj6Ad6WRjiHuU= -github.com/go-sql-driver/mysql v1.9.2/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-playground/form/v4 v4.3.0 h1:OVttojbQv2WNCs4P+VnjPtrt/+30Ipw4890W3OaFlvk= +github.com/go-playground/form/v4 v4.3.0/go.mod h1:Cpe1iYJKoXb1vILRXEwxpWMGWyQuqplQ/4cvPecy+Jo= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= -github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= -github.com/goexts/generic v0.3.0 h1:IimURW0H6QS6XBBf6H/wTRhtKtFub14n0aNDIYud4A4= -github.com/goexts/generic v0.3.0/go.mod h1:SZddH3gsbpBCE8JezA87mLXvM0aVrHivRWmnTn+enI4= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang-cz/devslog v0.0.13 h1:JkJ6PPNSOCBpYyU03v3xw7WgpChQ3AYFqgRbYBhUk/Y= -github.com/golang-cz/devslog v0.0.13/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= -github.com/golang-cz/devslog v0.0.14 h1:hZY6VuZ/+MmG4djP9X1YDSmX/z5zPDDVgFlO0fyb+CY= -github.com/golang-cz/devslog v0.0.14/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= -github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= -github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= -github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= -github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI= +github.com/goexts/generic v0.14.0 h1:Lw8QKwgN9w6vnHuEbs3K+42frxi7MHS2pJrg7/ZCkJc= +github.com/goexts/generic v0.14.0/go.mod h1:3L0Ou9PAX35WPvO+aSeZsoENlGIRSDAuZ8/GNqUqaEs= +github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw= +github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0= +github.com/golang-cz/devslog v0.0.15 h1:ejoBLTCwJHWGbAmDf2fyTJJQO3AkzcPjw8SC9LaOQMI= +github.com/golang-cz/devslog v0.0.15/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= +github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= +github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U= +github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= -github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/cel-go v0.25.0 h1:jsFw9Fhn+3y2kBbltZR4VEz5xKkcIFRPDnuEzAGv5GY= -github.com/google/cel-go v0.25.0/go.mod h1:hjEb6r5SuOSlhCHmFoLzu8HGCERvIsDAbxDAyNU/MmI= -github.com/google/flatbuffers v2.0.8+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= -github.com/google/gnostic v0.7.0 h1:d7EpuFp8vVdML+y0JJJYiKeOLjKTdH/GvVkLOBWqJpw= -github.com/google/gnostic v0.7.0/go.mod h1:IAcUyMl6vtC95f60EZ8oXyqTsOersP6HbwjeG7EyDPM= -github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49/go.mod h1:BkkQ4L1KS1xMt2aWSPStnn55ChGC0DPOn2FQYj+f25M= -github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= -github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/cel-go v0.26.1 h1:iPbVVEdkhTX++hpe3lzSk7D3G3QSYqLGoHOcEio+UXQ= +github.com/google/cel-go v0.26.1/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM= +github.com/google/gnostic v0.7.1 h1:t5Kc7j/8kYr8t2u11rykRrPPovlEMG4+xdc/SpekATs= +github.com/google/gnostic v0.7.1/go.mod h1:KSw6sxnxEBFM8jLPfJd46xZP+yQcfE8XkiqfZx5zR28= +github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= +github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/go-containerregistry v0.20.6 h1:cvWX87UxxLgaH76b4hIvya6Dzz9qHB31qAwjAohdSTU= +github.com/google/go-containerregistry v0.20.6/go.mod h1:T0x8MuoAoKX/873bkeSfLD2FAkwCDf9/HZgsFJ02E2Y= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/wire v0.6.0 h1:HBkoIh4BdSxoyo9PveV8giw7ZsaBOvzWKfcg/6MrVwI= -github.com/google/wire v0.6.0/go.mod h1:F4QhpQ9EDIdJ1Mbop/NZBRB+5yrR6qg3BnctaoUk6NA= -github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= -github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= -github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= -github.com/googleapis/gapic-generator-go v0.53.1 h1:Pd5hB9uegjh5T131ew5ddsTpRW5RDPJ34CcSHZSUAzE= -github.com/googleapis/gapic-generator-go v0.53.1/go.mod h1:bpi4lyj6DRGfEZcf6YiywBHon4NEC1+VdENKNKmrBqU= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= -github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= -github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= -github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= -github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= -github.com/googleapis/gax-go/v2 v2.7.0/go.mod h1:TEop28CZZQ2y+c0VxMUmu1lV+fQx57QpBWsYpwqHJx8= -github.com/googleapis/gax-go/v2 v2.7.1/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI= -github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= -github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4= +github.com/google/wire v0.7.0/go.mod h1:n6YbUQD9cPKTnHXEBN2DXlOp/mVADhVErcMFb0v3J18= github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3/go.mod h1:o//XUCC/F+yRGJoPO/VU0GSB0f8Nhgmxx0VIRUvaC0w= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= -github.com/hashicorp/consul/api v1.32.0 h1:5wp5u780Gri7c4OedGEPzmlUEzi0g2KyiPphSr6zjVg= -github.com/hashicorp/consul/api v1.32.0/go.mod h1:Z8YgY0eVPukT/17ejW+l+C7zJmKwgPHtjU1q16v/Y40= -github.com/hashicorp/consul/sdk v0.16.1 h1:V8TxTnImoPD5cj0U9Spl0TUxcytjcbbJeADFF07KdHg= -github.com/hashicorp/consul/sdk v0.16.1/go.mod h1:fSXvwxB2hmh1FMZCNl6PwX0Q/1wdWtHJcZ7Ea5tns0s= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= -github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= -github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-metrics v0.5.4 h1:8mmPiIJkTPPEbAiV97IxdAGNdRdaWwVap1BU6elejKY= -github.com/hashicorp/go-metrics v0.5.4/go.mod h1:CG5yz4NZ/AI/aQt9Ucm/vdBnbh7fvmv4lxZ350i+QQI= -github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= -github.com/hashicorp/go-msgpack/v2 v2.1.2 h1:4Ee8FTp834e+ewB71RDrQ0VKpyFdrKOjvYtnQ/ltVj0= -github.com/hashicorp/go-msgpack/v2 v2.1.2/go.mod h1:upybraOAblm4S7rx0+jeNy+CWWhzywQsSRV5033mMu4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.5 h1:dvk7TIXCZpmfOlM+9mlcrWmWjw/wlKT+VDq2wMvfPJU= -github.com/hashicorp/go-sockaddr v1.0.5/go.mod h1:uoUUmtwU7n9Dv3O4SNLeFvg0SxQ3lyjsj6+CCykpaxI= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= -github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= -github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= -github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl/v2 v2.23.0 h1:Fphj1/gCylPxHutVSEOf2fBOh1VE4AuLV7+kbJf3qos= github.com/hashicorp/hcl/v2 v2.23.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= -github.com/hashicorp/memberlist v0.5.2 h1:rJoNPWZ0juJBgqn48gjy59K5H4rNgvUoM1kUD7bXiuI= -github.com/hashicorp/memberlist v0.5.2/go.mod h1:Ri9p/tRShbjYnpNf4FFPXG7wxEGY4Nrcn6E7jrVa//4= -github.com/hashicorp/serf v0.10.2 h1:m5IORhuNSjaxeljg5DeQVDlQyVkhRIjJDimbkCa8aAc= -github.com/hashicorp/serf v0.10.2/go.mod h1:T1CmSGfSeGfnfNy/w0odXQUR1rfECGd2Qdsp84DjOiY= -github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68= +github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= -github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= -github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgx/v5 v5.7.4 h1:9wKznZrhWa2QiHL+NjTSPP6yjl3451BX3imWDnokYlg= -github.com/jackc/pgx/v5 v5.7.4/go.mod h1:ncY89UGWxg82EykZUwSpUKEfccBGGYq1xjrOpsbsfGQ= -github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= -github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jdx/go-netrc v1.0.0 h1:QbLMLyCZGj0NA8glAhxUpf1zDg6cxnWgMBbjq40W0gQ= +github.com/jdx/go-netrc v1.0.0/go.mod h1:Gh9eFQJnoTNIRHXl2j5bJXA1u84hQWJWgGh569zF3v8= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= +github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/asmfmt v1.3.2/go.mod h1:AG8TuvYojzulgDAMCnYn50l/5QV3Bs/tp6j0HLHbNSE= -github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= +github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU= +github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= -github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= -github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= -github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lmittmann/tint v1.0.7 h1:D/0OqWZ0YOGZ6AyC+5Y2kD8PBEzBk6rFHVSfOqCkF9Y= -github.com/lmittmann/tint v1.0.7/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= github.com/lmittmann/tint v1.1.2 h1:2CQzrL6rslrsyjqLDwD11bZ5OpLBPU+g3G/r5LSfS8w= github.com/lmittmann/tint v1.1.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= -github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr325bN2FD2ISlRRztXibcX6e8f5FR5Dc= -github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= -github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= -github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 h1:PwQumkgq4/acIiZhtifTV5OUqqiP82UAl0h87xj/l9k= +github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= +github.com/lyft/protoc-gen-star/v2 v2.0.4 h1:JDlNKttNIRd68AAIychs0AqEpO8/I/WYi01OQ7Raw6Q= +github.com/lyft/protoc-gen-star/v2 v2.0.4/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE= -github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY= -github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= -github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= +github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= +github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= +github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= +github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 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/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/mojocn/base64Captcha v1.3.8 h1:rrN9BhCwXKS8ht1e21kvR3iTaMgf4qPC9sRoV52bqEg= github.com/mojocn/base64Captcha v1.3.8/go.mod h1:QFZy927L8HVP3+VV5z2b1EAEiv1KxVJKZbAucVgLUy4= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= +github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/origadmin/contrib/database v0.0.34 h1:vh6nN4Kl85BWU73kTa/Q0+yEA72o1ZCh+HnUELJ9TXo= -github.com/origadmin/contrib/database v0.0.34/go.mod h1:C789sBJhECVWe/4095eHFaenjE9VOydwEGCdh+KK4Pg= -github.com/origadmin/contrib/i18n v0.0.33 h1:d5i60H2cd1+aqoDPE3WIvznimCAiHBsTITg2aGNqg1s= -github.com/origadmin/contrib/i18n v0.0.33/go.mod h1:dNURdi4+YbtKueS5cZyZmwT98FPKOfPwaDfhAtE/lr4= -github.com/origadmin/contrib/replacer v0.0.33 h1:Zmc7n4Q8oOnUZu8xNLacHhOWGDpGH+MjZh2bs5MjNv0= -github.com/origadmin/contrib/replacer v0.0.33/go.mod h1:zTR4fcc/K43ImF8jFPYK0uHbk+VEPg5fnXLKKAb4EA0= -github.com/origadmin/contrib/transport/gins v0.0.33 h1:9WKZYyLI3QQq6fCDFyeeEKLMTt5q6FLstizyRILmmSA= -github.com/origadmin/contrib/transport/gins v0.0.33/go.mod h1:LVNgg47PYSFVWABQfZqOaCmMFsehf7jbd7JZOG5IYO8= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= +github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= +github.com/origadmin/contrib v1.1.0 h1:5ZMuxPas9+WIDNDlG+99Y5JHGwQRq2rZ4TjJXM5/Oek= +github.com/origadmin/contrib v1.1.0/go.mod h1:lqSKEAQHNRf96zWG3XvZZv96oFUeMBstLAWBGP7VIus= github.com/origadmin/entslog/v3 v3.1.0 h1:1SPjs2CWytl08obWW2wAk8UTiwoc0ak/doWdQHN64Rk= github.com/origadmin/entslog/v3 v3.1.0/go.mod h1:cIFyIZprNlJ69T18DnXBpylvO2CWvEGPhW1r2Sm/51s= -github.com/origadmin/go-metrics v0.5.4 h1:odg6zeZUGkTCl6cGJ/bS5GlvjZ3x3GU2zyw9WtNmKFY= -github.com/origadmin/go-metrics v0.5.4/go.mod h1:KiuAdjBbuXAkjTjy7p7F4g6sjO6WuvH+6hTlMKUxPkg= -github.com/origadmin/runtime v0.2.0 h1:4FbuNYqJbQZFZrKQB6l/L5RXlC3hr40uWFKjUMUYMgA= -github.com/origadmin/runtime v0.2.0/go.mod h1:b+TK2xaJlTsna1RESE4+y9Do+qz80Wnz2+KqrA4gLnI= +github.com/origadmin/runtime v0.2.3 h1:1DEiXawwftHOOWwHM5ScSSOk8CuMRyfvAQDAUUvGhDs= github.com/origadmin/runtime v0.2.3/go.mod h1:rgOxokXjWXXbzzHr2ICXW3KNsQ8KNGFqjMcpGo54aOM= +github.com/origadmin/runtime v0.2.13/go.mod h1:P4X8gBcPhGpH778JV/VVlj7xi4iX1WYDfir3lJOoTwg= github.com/origadmin/slog-kratos v1.0.4 h1:1et3TBy61Uwf5N1ZbEBFhMqCjgxqfRXmz2w0Q1dujG0= github.com/origadmin/slog-kratos v1.0.4/go.mod h1:WUdhcWLyN0i8TbdemqE2Y/muoj0GaZ86OcdpumAWHPo= +github.com/origadmin/slog-kratos v1.0.5/go.mod h1:zuOf6B1cMjPwwMJ2or2sPbzNAdx/fMn/6MekdG30Xh4= github.com/origadmin/toolkits v0.3.16 h1:R/Ws2S2W64ZScSkBz4QQ8HPXWpuH/ac+z1z0iHPyG0M= github.com/origadmin/toolkits v0.3.16/go.mod h1:l0H6drsQuWNiSDagDwI2jvLqxlNGtF1LI++fPrz5KAg= +github.com/origadmin/toolkits v1.2.0 h1:7L/hgf0WC/q7yIJH9V0uENrxkAN0oU3D2EobfqKO4uw= +github.com/origadmin/toolkits v1.2.0/go.mod h1:ylurxc+wCcSK3FyT7a6bnGfR2l4tu11b128X+dh1fbw= github.com/origadmin/toolkits/codec v0.3.16 h1:fRyWCMwyXz032I1ZHpsRuG/8YfWRS4YlfqYNdjeziMw= github.com/origadmin/toolkits/codec v0.3.16/go.mod h1:XqlOlTxdD3lLDPmC82cZEVoiD4/r4QA3umKKRVrgGu4= +github.com/origadmin/toolkits/codec v1.2.0/go.mod h1:NgbdOtowlFY79/CXZzRhes1tRHTBr3XZX+VBWL7yUpw= github.com/origadmin/toolkits/crypto v0.3.15 h1:OHgIXLvB2jCvKH55YVdSyTjcOAwB05FmvCQLKn2BoMQ= github.com/origadmin/toolkits/crypto v0.3.15/go.mod h1:ozRQi1rYHAIL/NSw0hJEWITEkZlSZ7wA9pCQKpqFv2s= -github.com/origadmin/toolkits/errors v0.3.16 h1:W6Izq84z3dkusnWZC5nMHGd7DYCYM2sZZYiga/hg8iU= -github.com/origadmin/toolkits/errors v0.3.16/go.mod h1:kqVUSV6sz+wiUeesrBxZ3oyUPrNl0alF0+jO0qehBvM= -github.com/origadmin/toolkits/identifier v0.3.15 h1:hl4xYINV3ywDGlqrVYCf/tePx7tjZZ8LWvqzlhzv3rA= -github.com/origadmin/toolkits/identifier v0.3.15/go.mod h1:M1IodkORni12hNmpFd5/9xrBHqjUkoDzBmPWyHGhIp8= +github.com/origadmin/toolkits/crypto v1.2.0/go.mod h1:PlR7+Dh88bVl8z+wKjAcxVBHxl3fllwfhLGOvzAO9nQ= +github.com/origadmin/toolkits/errors v1.1.0 h1:Vh5ic7kU6e01koOuGpu3c6etbSZ7gEfesXQMpOsO2D8= +github.com/origadmin/toolkits/errors v1.1.0/go.mod h1:YCPShNuAmn0ns0JB43iKbVdWcPA8XCTiFG+7UA2+tJw= +github.com/origadmin/toolkits/errors v1.2.0/go.mod h1:YCPShNuAmn0ns0JB43iKbVdWcPA8XCTiFG+7UA2+tJw= github.com/origadmin/toolkits/slogx v0.3.16 h1:+sJAKM2t/3ZyT6qi+Q1CwnzXO/ObXJlKTfPA6RdJno0= github.com/origadmin/toolkits/slogx v0.3.16/go.mod h1:6ODf/5T3M7XBc0aKHHkMgOLawkASDzaPCj99JzabYME= -github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= -github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= -github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= -github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= -github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= -github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/origadmin/toolkits/slogx v1.1.0/go.mod h1:rpyegD2CZypR+ctlpVz4q3KROwb3xc6mUKQQZ9ow+qI= +github.com/petermattis/goid v0.0.0-20250904145737-900bdf8bb490 h1:QTvNkZ5ylY0PGgA+Lih+GdboMLY/G9SEGLMEGVjTVA4= +github.com/petermattis/goid v0.0.0-20250904145737-900bdf8bb490/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= -github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -1153,106 +307,66 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRI github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q= -github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= -github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io= -github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= -github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= +github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= +github.com/quic-go/quic-go v0.56.0 h1:q/TW+OLismmXAehgFLczhCDTYB3bFmua4D9lsNBWxvY= +github.com/quic-go/quic-go v0.56.0/go.mod h1:9gx5KsFQtw2oZ6GZTyh+7YEvOxWCL9WZAepnHxgAo6c= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= -github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= -github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rodaine/protogofakeit v0.1.1 h1:ZKouljuRM3A+TArppfBqnH8tGZHOwM/pjvtXe9DaXH8= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= +github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= -github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0= +github.com/segmentio/asm v1.2.1/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= +github.com/segmentio/encoding v0.5.3 h1:OjMgICtcSFuNvQCdwqMCv9Tg7lEOXGwm1J5RPQccx6w= +github.com/segmentio/encoding v0.5.3/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0= github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk= -github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= -github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= -github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= -github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sony/sonyflake v1.2.0 h1:Pfr3A+ejSg+0SPqpoAmQgEtNDAhc2G1SUYk205qVMLQ= -github.com/sony/sonyflake v1.2.0/go.mod h1:LORtCywH/cq10ZbyfhKrHYgAUGH7mOBa76enV9txy/Y= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= -github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo= -github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0= -github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= -github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/sqlite3ent/sqlite3 v1.34.1 h1:chgkn9XP4JBKEGUV2pDEW1pELrXI6JEFIz6T1GLydMU= -github.com/sqlite3ent/sqlite3 v1.34.1/go.mod h1:lvwiZ8ARb9J4EE4wDVn4jflOfzHtkKAIXB5rBsp8L6k= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= -github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= -github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= +github.com/shoenig/go-m1cpu v0.1.7 h1:C76Yd0ObKR82W4vhfjZiCp0HxcSZ8Nqd84v+HZ0qyI0= +github.com/shoenig/go-m1cpu v0.1.7/go.mod h1:KkDOw6m3ZJQAPHbrzkZki4hnx+pDRR1Lo+ldA56wD5w= +github.com/shoenig/test v1.7.0 h1:eWcHtTXa6QLnBvm0jgEabMRN/uJ4DMV3M8xUGgRkZmk= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sony/sonyflake v1.3.0 h1:tiB4Dlp0lnmKp/h6BLXA14P8Qi+LYS9+0QRpcrKHvg4= +github.com/sony/sonyflake v1.3.0/go.mod h1:LORtCywH/cq10ZbyfhKrHYgAUGH7mOBa76enV9txy/Y= +github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= +github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= +github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= +github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= +github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/sqlite3ent/sqlite3 v1.40.0 h1:zQs4O0AA0Jwa/UfpS1VJLVuYv7576yjtFtLty5KuSDY= +github.com/sqlite3ent/sqlite3 v1.40.0/go.mod h1:WIpC0Synq6v0xDJ179B/epHrs/Lkv5Exu7h3kt2NJMM= +github.com/stoewer/go-strcase v1.3.1 h1:iS0MdW+kVTxgMoE1LAZyMiYJFKlOzLooE4MxjirtkAs= +github.com/stoewer/go-strcase v1.3.1/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I= +github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM= +github.com/tidwall/btree v1.8.1 h1:27ehoXvm5AG/g+1VxLS1SD3vRhp/H7LuEfwNvddEdmA= +github.com/tidwall/btree v1.8.1/go.mod h1:jBbTdUWhSZClZWoDg54VnvV7/54modSOzDN7VXftj1A= github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= -github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= -github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= -github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= -github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/vbatts/tar-split v0.12.2 h1:w/Y6tjxpeiFMR47yzZPlPj/FcPLpXbTUi/9H7d3CPa4= +github.com/vbatts/tar-split v0.12.2/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVOpnNdfTMFA= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= @@ -1263,855 +377,181 @@ github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6 github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWBdig0= github.com/zclconf/go-cty-yaml v1.1.0/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JAprQNgxSZ1Gyxs= -github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0= -github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA= -gitlab.com/golang-commonmark/html v0.0.0-20191124015941-a22733972181 h1:K+bMSIx9A7mLES1rtG+qKduLIXq40DAzYHtb0XuCukA= -gitlab.com/golang-commonmark/html v0.0.0-20191124015941-a22733972181/go.mod h1:dzYhVIwWCtzPAa4QP98wfB9+mzt33MSmM8wsKiMi2ow= -gitlab.com/golang-commonmark/linkify v0.0.0-20191026162114-a0c2df6c8f82/go.mod h1:Gn+LZmCrhPECMD3SOKlE+BOHwhOYD9j7WT9NUtkCrC8= -gitlab.com/golang-commonmark/linkify v0.0.0-20200225224916-64bca66f6ad3 h1:1Coh5BsUBlXoEJmIEaNzVAWrtg9k7/eJzailMQr1grw= -gitlab.com/golang-commonmark/linkify v0.0.0-20200225224916-64bca66f6ad3/go.mod h1:Gn+LZmCrhPECMD3SOKlE+BOHwhOYD9j7WT9NUtkCrC8= -gitlab.com/golang-commonmark/markdown v0.0.0-20211110145824-bf3e522c626a h1:O85GKETcmnCNAfv4Aym9tepU8OE0NmcZNqPlXcsBKBs= -gitlab.com/golang-commonmark/markdown v0.0.0-20211110145824-bf3e522c626a/go.mod h1:LaSIs30YPGs1H5jwGgPhLzc8vkNc/k0rDX/fEZqiU/M= -gitlab.com/golang-commonmark/mdurl v0.0.0-20191124015652-932350d1cb84 h1:qqjvoVXdWIcZCLPMlzgA7P9FZWdPGPvP/l3ef8GzV6o= -gitlab.com/golang-commonmark/mdurl v0.0.0-20191124015652-932350d1cb84/go.mod h1:IJZ+fdMvbW2qW6htJx7sLJ04FEs4Ldl/MDsJtMKywfw= -gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f h1:Wku8eEdeJqIOFHtrfkYUByc4bCaTeA6fL0UJgfEiFMI= -gitlab.com/golang-commonmark/puny v0.0.0-20191124015043-9f83538fa04f/go.mod h1:Tiuhl+njh/JIg0uS/sOJVYi0x2HEa5rc1OAaVsb5tAs= -gitlab.com/opennota/wd v0.0.0-20180912061657-c5d65f63c638/go.mod h1:EGRJaqe2eO9XGmFtQCvV3Lm9NLico3UhFwUpCG/+mVU= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= -go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= -go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= -go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg= -go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E= -go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M= -go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= -go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE= -go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs= -go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= -go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= -go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= -go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= -go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o= -go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs= -go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= -go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w= -go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= -golang.org/x/arch v0.17.0 h1:4O3dfLzd+lQewptAHqjewQZQDyEdejz3VwgeYwkZneU= -golang.org/x/arch v0.17.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= +go.lsp.dev/jsonrpc2 v0.10.0 h1:Pr/YcXJoEOTMc/b6OTmcR1DPJ3mSWl/SWiU1Cct6VmI= +go.lsp.dev/jsonrpc2 v0.10.0/go.mod h1:fmEzIdXPi/rf6d4uFcayi8HpFP1nBF99ERP1htC72Ac= +go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 h1:hCzQgh6UcwbKgNSRurYWSqh8MufqRRPODRBblutn4TE= +go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2/go.mod h1:gtSHRuYfbCT0qnbLnovpie/WEmqyJ7T4n6VXiFMBtcw= +go.lsp.dev/protocol v0.12.0 h1:tNprUI9klQW5FAFVM4Sa+AbPFuVQByWhP1ttNUAjIWg= +go.lsp.dev/protocol v0.12.0/go.mod h1:Qb11/HgZQ72qQbeyPfJbu3hZBH23s1sr4st8czGeDMQ= +go.lsp.dev/uri v0.3.0 h1:KcZJmh6nFIBeJzTugn5JTU6OOyG0lDOo3R9KwTxTYbo= +go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I= +go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= +go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0/go.mod h1:h06DGIukJOevXaj/xrNjhi/2098RZzcLTbc0jDAUbsg= +go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= +go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= +go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= +go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= +go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= +go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= +go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= +go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= +go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/arch v0.18.0 h1:WN9poc33zL4AzGxqf8VtpKUnGvMi8O9lhNyBMF/85qc= golang.org/x/arch v0.18.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= -golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= -golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= -golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= -golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE= -golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI= -golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ= -golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476 h1:bsqhLWFR6G6xiQcb+JoGqdKdRU6WzPWmK8E0jxTjzo4= -golang.org/x/exp v0.0.0-20250606033433-dcc06ee1d476/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8= -golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20190910094157-69e4b8554b2a/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20200618115811-c13761719519/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20201208152932-35266b937fa6/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20210216034530-4410531fe030/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/image v0.0.0-20210607152325-775e3b0c77b9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/image v0.0.0-20211028202545-6944b10bf410/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= -golang.org/x/image v0.0.0-20220302094943-723b81ca9867/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= +golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= +golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= +golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY= +golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70= golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= golang.org/x/image v0.26.0 h1:4XjIFEZWQmCZi6Wv8BoxsDhRU3RVnLX04dToTDAEPlY= golang.org/x/image v0.26.0/go.mod h1:lcxbMFAovzpnJxzXS3nyL83K27tmqtKzIJpctK8YO5c= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= -golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= -golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= -golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= -golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= -golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20221006150949-b44042a4b9c1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= -golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= -golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= -golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= -golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= -golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= +golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= -golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= -golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= -golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190927191325-030b2cf1153e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= -golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= -golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo= -golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg= +golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= +golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= -gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= -gonum.org/v1/gonum v0.9.3/go.mod h1:TZumC3NeyVQskjXqmyWt4S3bINhy7B4eYwW69EbyX+0= -gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA= -gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= -gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= -gonum.org/v1/plot v0.9.0/go.mod h1:3Pcqqmp6RHvJI72kgb8fThyUnav364FOsdDo2aGW5lY= -gonum.org/v1/plot v0.10.1/go.mod h1:VZW5OlhkL1mysU9vaqNHnsy86inf6Ot+jB3r+BczCEo= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= -google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= -google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.77.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= -google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= -google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= -google.golang.org/api v0.85.0/go.mod h1:AqZf8Ep9uZ2pyTvgL+x0D3Zt0eoT9b5E8fmzfu6FO2g= -google.golang.org/api v0.90.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.93.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.95.0/go.mod h1:eADj+UBuxkh5zlrSntJghuNeg8HwQ1w5lTKkuqaETEI= -google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.99.0/go.mod h1:1YOf74vkVndF7pG6hIHuINsM7eWwpVTAfNMNiL91A08= -google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= -google.golang.org/api v0.102.0/go.mod h1:3VFl6/fzoA+qNuS1N1/VfXY4LjoXN/wzeIp7TweWwGo= -google.golang.org/api v0.103.0/go.mod h1:hGtW6nK1AC+d9si/UBhw8Xli+QMOf6xyNAyJw4qU9w0= -google.golang.org/api v0.106.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= -google.golang.org/api v0.107.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= -google.golang.org/api v0.108.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= -google.golang.org/api v0.110.0/go.mod h1:7FC4Vvx1Mooxh8C5HWjzZHcavuS2f6pmJpZx60ca7iI= -google.golang.org/api v0.111.0/go.mod h1:qtFHvU9mhgTJegR31csQ+rwxyUTHOKFqCKWp1J0fdw0= -google.golang.org/api v0.114.0/go.mod h1:ifYI2ZsFK6/uGddGfAD5BMxlnkBqCmqHSDUVi45N5Yg= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220329172620-7be39ac1afc7/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220722212130-b98a9ff5e252/go.mod h1:GkXuJDJ6aQ7lnJcRF+SJVgFdQhypqgl3LB1C9vabdRE= -google.golang.org/genproto v0.0.0-20220801145646-83ce21fca29f/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= -google.golang.org/genproto v0.0.0-20220815135757-37a418bb8959/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220817144833-d7fd3f11b9b1/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220829144015-23454907ede3/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220913154956-18f8339a66a5/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220914142337-ca0e39ece12f/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220915135415-7fd63a7952de/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220916172020-2692e8806bfa/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220919141832-68c03719ef51/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220920201722-2b89144ce006/go.mod h1:ht8XFiar2npT/g4vkk7O0WYS1sHOHbdujxbEp7CJWbw= -google.golang.org/genproto v0.0.0-20220926165614-551eb538f295/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= -google.golang.org/genproto v0.0.0-20220926220553-6981cbe3cfce/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= -google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqwhZAwq4wsRUaVG555sVgsNmIjRtO7t/JH29U= -google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= -google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= -google.golang.org/genproto v0.0.0-20221024153911-1573dae28c9c/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo= -google.golang.org/genproto v0.0.0-20221109142239-94d6d90a7d66/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221117204609-8f9c96812029/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221201164419-0e50fba7f41c/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221201204527-e3fa12d562f3/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20221202195650-67e5cbc046fd/go.mod h1:cTsE614GARnxrLsqKREzmNYJACSWWpAWdNMwnD7c2BE= -google.golang.org/genproto v0.0.0-20221227171554-f9683d7f8bef/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230112194545-e10362b5ecf9/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230113154510-dbe35b8444a5/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230123190316-2c411cf9d197/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230124163310-31e0e69b6fc2/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230125152338-dcaf20b6aeaa/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230127162408-596548ed4efa/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44/go.mod h1:8B0gmkoRebU8ukX6HP+4wrVQUY1+6PkQ44BSyIlflHA= -google.golang.org/genproto v0.0.0-20230222225845-10f96fb3dbec/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= -google.golang.org/genproto v0.0.0-20230223222841-637eb2293923/go.mod h1:3Dl5ZL0q0isWJt+FVcfpQyirqemEuLAK/iFvg1UP1Hw= -google.golang.org/genproto v0.0.0-20230303212802-e74f57abe488/go.mod h1:TvhZT5f700eVlTNwND1xoEZQeWTB2RY/65kplwl/bFA= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= -google.golang.org/genproto v0.0.0-20230320184635-7606e756e683/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= -google.golang.org/genproto v0.0.0-20230323212658-478b75c54725/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= -google.golang.org/genproto v0.0.0-20230330154414-c0448cd141ea/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= -google.golang.org/genproto v0.0.0-20230331144136-dcfb400f0633/go.mod h1:UUQDJDOlWu4KYeJZffbWgBkS1YFobzKbLVfK69pe0Ak= -google.golang.org/genproto v0.0.0-20230525234025-438c736192d0/go.mod h1:9ExIQyXL5hZrHzQceCwuSYwZZ5QZBazOcprJ5rgs3lY= -google.golang.org/genproto v0.0.0-20230526161137-0005af68ea54/go.mod h1:zqTuNwFlFRsw5zIts5VnzLQxSRqh+CGOTVMlYbY0Eyk= -google.golang.org/genproto v0.0.0-20250519155744-55703ea1f237 h1:2zGWyk04EwQ3mmV4dd4M4U7P/igHi5p7CBJEg1rI6A8= -google.golang.org/genproto v0.0.0-20250519155744-55703ea1f237/go.mod h1:LhI4bRmX3rqllzQ+BGneexULkEjBf2gsAfkbeCA8IbU= -google.golang.org/genproto/googleapis/api v0.0.0-20230525234020-1aefcd67740a/go.mod h1:ts19tUU+Z0ZShN1y3aPyq2+O3d5FUNNgT6FtOzmrNn8= -google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34 h1:0PeQib/pH3nB/5pEmFeVQJotzGohV0dq4Vcp09H5yhE= -google.golang.org/genproto/googleapis/api v0.0.0-20250428153025-10db94c68c34/go.mod h1:0awUlEkap+Pb1UMeJwJQQAdJQrt3moU7J2moTy69irI= -google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237 h1:Kog3KlB4xevJlAcbbbzPfRG0+X9fdoGM+UBRKVz6Wr0= -google.golang.org/genproto/googleapis/api v0.0.0-20250519155744-55703ea1f237/go.mod h1:ezi0AVyMKDWy5xAncvjLWH7UcLBB5n7y2fQ8MzjJcto= -google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 h1:oWVWY3NzT7KJppx2UKhKmzPq4SRe0LdCijVRwvGeikY= -google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822/go.mod h1:h3c4v36UTKzUiuaOKQ6gr3S+0hovBtUrXzTG/i3+XEc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234015-3fc162c6f38a/go.mod h1:xURIpW9ES5+/GZhnV6beoEtxQrnkRGIfP5VQG2tCBLc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34 h1:h6p3mQqrmT1XkHVTfzLdNz1u7IhINeZkz67/xTbOuWs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 h1:cJfm9zPbe1e873mHJzmQ1nwVEeRDU/T1wXDK2kUSU34= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 h1:fc6jSaCT0vBduLYZHYrBBNY4dsWuvgyff9noRNDdBeE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= -google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= -google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= -google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= -google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= -google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= -google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok= -google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= -google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= +google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls= +google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 h1:Wgl1rcDNThT+Zn47YyCXOXyX/COgMTIdhJ717F0l4xk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= +google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM= +google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1/go.mod h1:5KF+wpkbTSbGcR9zteSqZV6fqFOWBl4Yde8En8MryZA= +google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= +google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= -lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= -modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= -modernc.org/cc/v3 v3.36.2/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= -modernc.org/cc/v3 v3.36.3/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= -modernc.org/cc/v4 v4.26.0 h1:QMYvbVduUGH0rrO+5mqF/PSPPRZNpRtg2CLELy7vUpA= -modernc.org/cc/v4 v4.26.0/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= -modernc.org/ccgo/v3 v3.0.0-20220428102840-41399a37e894/go.mod h1:eI31LL8EwEBKPpNpA4bU1/i+sKOwOrQy8D87zWUcRZc= -modernc.org/ccgo/v3 v3.0.0-20220430103911-bc99d88307be/go.mod h1:bwdAnOoaIt8Ax9YdWGjxWsdkPcZyRPHqrOvJxaKAKGw= -modernc.org/ccgo/v3 v3.16.4/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ= -modernc.org/ccgo/v3 v3.16.6/go.mod h1:tGtX0gE9Jn7hdZFeU88slbTh1UtCYKusWOoCJuvkWsQ= -modernc.org/ccgo/v3 v3.16.8/go.mod h1:zNjwkizS+fIFDrDjIAgBSCLkWbJuHF+ar3QRn+Z9aws= -modernc.org/ccgo/v3 v3.16.9/go.mod h1:zNMzC9A9xeNUepy6KuZBbugn3c0Mc9TeiJO4lgvkJDo= -modernc.org/ccgo/v4 v4.26.0 h1:gVzXaDzGeBYJ2uXTOpR8FR7OlksDOe9jxnjhIKCsiTc= -modernc.org/ccgo/v4 v4.26.0/go.mod h1:Sem8f7TFUtVXkG2fiaChQtyyfkqhJBg/zjEJBkmuAVY= -modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ= -modernc.org/fileutil v1.3.1 h1:8vq5fe7jdtEvoCf3Zf9Nm0Q05sH6kGx0Op2CPx1wTC8= -modernc.org/fileutil v1.3.1/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc= +modernc.org/cc/v4 v4.26.5 h1:xM3bX7Mve6G8K8b+T11ReenJOT+BmVqQj0FY5T4+5Y4= +modernc.org/ccgo/v4 v4.28.1 h1:wPKYn5EC/mYTqBO373jKjvX2n+3+aK7+sICCv4Fjy1A= +modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA= modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= -modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= -modernc.org/libc v0.0.0-20220428101251-2d5f3daf273b/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA= -modernc.org/libc v1.16.0/go.mod h1:N4LD6DBE9cf+Dzf9buBlzVJndKr/iJHG97vGLHYnb5A= -modernc.org/libc v1.16.1/go.mod h1:JjJE0eu4yeK7tab2n4S1w8tlWd9MxXLRzheaRnAKymU= -modernc.org/libc v1.16.17/go.mod h1:hYIV5VZczAmGZAnG15Vdngn5HSF5cSkbvfz2B7GRuVU= -modernc.org/libc v1.16.19/go.mod h1:p7Mg4+koNjc8jkqwcoFBJx7tXkpj00G77X7A72jXPXA= -modernc.org/libc v1.17.0/go.mod h1:XsgLldpP4aWlPlsjqKRdHPqCxCjISdHfM/yeWC5GyW0= -modernc.org/libc v1.17.1/go.mod h1:FZ23b+8LjxZs7XtFMbSzL/EhPxNbfZbErxEHc7cbD9s= -modernc.org/libc v1.64.0 h1:U0k8BD2d3cD3e9I8RLcZgJBHAcsJzbXx5mKGSb5pyJA= -modernc.org/libc v1.64.0/go.mod h1:7m9VzGq7APssBTydds2zBcxGREwvIGpuUBaKTXdm2Qs= -modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= +modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= +modernc.org/libc v1.66.10 h1:yZkb3YeLx4oynyR+iUsXsybsX4Ubx7MQlSYEw4yj59A= +modernc.org/libc v1.66.10/go.mod h1:8vGSEwvoUoltr4dlywvHqjtAqHBaw0j1jI7iFBTAr2I= modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= -modernc.org/memory v1.1.1/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= -modernc.org/memory v1.2.0/go.mod h1:/0wo5ibyrQiaoUoH7f9D8dnglAmILJ5/cxZlRECf+Nw= -modernc.org/memory v1.2.1/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU= -modernc.org/memory v1.10.0 h1:fzumd51yQ1DxcOxSO+S6X7+QTuVU+n8/Aj7swYjFfC4= -modernc.org/memory v1.10.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= -modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= -modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= +modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= +modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= -modernc.org/sqlite v1.18.1/go.mod h1:6ho+Gow7oX5V+OiOQ6Tr4xeqbx13UZ6t+Fw9IRUG4d4= -modernc.org/sqlite v1.37.0 h1:s1TMe7T3Q3ovQiK2Ouz4Jwh7dw4ZDqbebSDTlSJdfjI= -modernc.org/sqlite v1.37.0/go.mod h1:5YiWv+YviqGMuGw4V+PNplcyaJ5v+vQd7TQOgkACoJM= -modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw= -modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw= +modernc.org/sqlite v1.40.0 h1:bNWEDlYhNPAUdUdBzjAvn8icAs/2gaKlj4vM+tQ6KdQ= +modernc.org/sqlite v1.40.0/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE= modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= -modernc.org/tcl v1.13.1/go.mod h1:XOLfOwzhkljL4itZkK6T72ckMgvj0BDsnKNdZVUOecw= -modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= -modernc.org/z v1.5.1/go.mod h1:eWFB510QWW5Th9YGZT81s+LwvaAs3Q2yr4sP0rmLkv8= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +pluginrpc.com/pluginrpc v0.5.0 h1:tOQj2D35hOmvHyPu8e7ohW2/QvAnEtKscy2IJYWQ2yo= +pluginrpc.com/pluginrpc v0.5.0/go.mod h1:UNWZ941hcVAoOZUn8YZsMmOZBzbUjQa3XMns8RQLp9o= diff --git a/internal/conf/config.go b/internal/conf/config.go new file mode 100644 index 00000000..1d9e95ca --- /dev/null +++ b/internal/conf/config.go @@ -0,0 +1,82 @@ +// Package conf implements the functions, types, and interfaces for the module. +package conf + +import ( + datav1 "github.com/origadmin/runtime/api/gen/go/config/data/v1" + discoveryv1 "github.com/origadmin/runtime/api/gen/go/config/discovery/v1" + loggerv1 "github.com/origadmin/runtime/api/gen/go/config/logger/v1" + middlewarev1 "github.com/origadmin/runtime/api/gen/go/config/middleware/v1" + transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" + "github.com/origadmin/runtime/bootstrap" + "github.com/origadmin/runtime/interfaces" + confpb "origadmin/application/admin/internal/conf/pb" +) + +type Config struct { + bootstrap confpb.Bootstrap +} + +func (c *Config) DecodeData() (*datav1.Data, error) { + return c.bootstrap.GetData(), nil +} + +func (c *Config) DecodeCaches() (*datav1.Caches, error) { + return c.bootstrap.GetData().GetCaches(), nil +} + +func (c *Config) DecodeDatabases() (*datav1.Databases, error) { + return c.bootstrap.GetData().GetDatabases(), nil +} + +func (c *Config) DecodeObjectStores() (*datav1.ObjectStores, error) { + return c.bootstrap.GetData().GetObjectStores(), nil +} + +func (c *Config) DecodeDefaultDiscovery() (string, error) { + return c.bootstrap.GetDefaultDiscovery(), nil +} + +func (c *Config) DecodeDiscoveries() (*discoveryv1.Discoveries, error) { + return c.bootstrap.GetDiscoveries(), nil +} + +func (c *Config) DecodeLogger() (*loggerv1.Logger, error) { + return c.bootstrap.GetLogger(), nil +} + +func (c *Config) DecodeMiddlewares() (*middlewarev1.Middlewares, error) { + return c.bootstrap.GetMiddlewares(), nil +} + +func (c *Config) DecodeServers() (*transportv1.Servers, error) { + return c.bootstrap.GetServers(), nil +} + +func (c *Config) DecodeClients() (*transportv1.Clients, error) { + return c.bootstrap.GetClients(), nil +} + +func (c *Config) GetCaptcha() (*confpb.Captcha, error) { + return c.bootstrap.GetCaptcha(), nil +} + +func (c *Config) GetRootUser() (*confpb.RootUser, error) { + return c.bootstrap.GetRootUser(), nil +} + +func (c *Config) GetBootstrap() *confpb.Bootstrap { + return &c.bootstrap +} + +func (c *Config) DecodedConfig() any { + return &c.bootstrap +} + +func (c *Config) Transform(config interfaces.Config, config2 interfaces.StructuredConfig) (interfaces. +StructuredConfig, error) { + return c, nil +} + +func New() bootstrap.ConfigTransformer { + return &Config{} +} diff --git a/internal/conf/pb/conf.proto b/internal/conf/pb/conf.proto index 04441eb0..f4735e96 100644 --- a/internal/conf/pb/conf.proto +++ b/internal/conf/pb/conf.proto @@ -4,6 +4,10 @@ package conf.pb; option go_package = "origadmin/application/admin/internal/conf/pb;confpb"; +import "config/data/v1/data.proto"; +import "config/discovery/v1/discovery.proto"; +import "config/logger/v1/logger.proto"; +import "config/middleware/v1/middleware.proto"; import "config/transport/v1/transport.proto"; import "conf/pb/captcha.proto"; import "conf/pb/root.proto"; @@ -24,6 +28,21 @@ message Bootstrap { // RootUser feature specific configuration for initial user setup. conf.pb.RootUser root_user = 5; + + // Data configuration, including databases, caches, and object stores. + runtime.api.config.data.v1.Data data = 6; + + // Discovery configuration for service discovery. + runtime.api.config.discovery.v1.Discoveries discoveries = 7; + + // Logger configuration for application logging. + runtime.api.config.logger.v1.Logger logger = 8; + + // Middleware configuration for request processing. + runtime.api.config.middleware.v1.Middlewares middlewares = 9; + + // Default discovery service name. + string default_discovery = 10; } // SelectorGlobal defines the global selector/load-balancing strategy. diff --git a/internal/data/casbin-adapter.dal.go b/internal/data/casbin-adapter.dal.go index 489fd092..7da9ed2a 100644 --- a/internal/data/casbin-adapter.dal.go +++ b/internal/data/casbin-adapter.dal.go @@ -15,7 +15,7 @@ import ( entsql "entgo.io/ent/dialect/sql" "github.com/casbin/casbin/v2/model" "github.com/casbin/casbin/v2/persist" - "github.com/goexts/generic/settings" + "github.com/goexts/generic/configure" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/casbinrule" @@ -76,7 +76,7 @@ func NewAdapter(data *Data, options ...Option) (persist.Adapter, error) { data: data, filtered: false, } - opts, err := settings.ApplyE(&CasbinOptions{}, options) + opts, err := configure.ApplyE(&CasbinOptions{}, options) if err != nil { return nil, err } diff --git a/internal/data/data.go b/internal/data/data.go index f6c8c05c..e4965aa3 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -6,563 +6,84 @@ package data import ( - "errors" - "fmt" - "os" - "path/filepath" - "strconv" - "time" + "context" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" + entsql "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/schema" "github.com/google/wire" - "github.com/origadmin/entslog/v3" + "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/runtime/data/storage" + "github.com/origadmin/runtime/interfaces" + ifacestorage "github.com/origadmin/runtime/interfaces/storage" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/codec" - "origadmin/application/admin/contrib/database" - "origadmin/application/admin/helpers/id" - "origadmin/application/admin/helpers/securityx" - "origadmin/application/admin/internal/configs" "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/department" - "origadmin/application/admin/internal/data/entity/ent/predicate" - "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dto" -) - -const ( - TreePathDelimiter = "." ) // ProviderSet is data providers. -var ProviderSet = wire.NewSet( - NewData, - NewLoginData, - NewAuthenticator, - NewTokenizer, - NewAuthorizer, -) +var ProviderSet = wire.NewSet(NewData) +// Data encapsulates ent client and cache. type Data struct { - *ent.Database - Delimiter string - Log *log.KHelper -} - -type LoginData struct { - Captcha *configs.Captcha - RootUser *configs.RootUser - Tokenizer security.RefreshTokenizer - //Resource systemdto.ResourceRepo - //Role systemdto.RoleRepo - //User systemdto.UserRepo -} - -func NewLoginData(cfg *configs.Bootstrap, tokenizer security.RefreshTokenizer) *LoginData { - return &LoginData{ - Captcha: cfg.GetSecurity().GetCaptcha(), - RootUser: cfg.GetSecurity().GetRootUser(), - Tokenizer: tokenizer, - } -} - -func NewDataWithClient(client *ent.Client) *Data { - return &Data{ - Database: ent.NewDatabaseWithClient(client), - } -} - -func NewAuthenticator(bootstrap *configs.Bootstrap) (security.Authenticator, error) { - return securityx.NewAuthenticator(bootstrap) -} - -func NewTokenizer(bootstrap *configs.Bootstrap) (security.Tokenizer, error) { - authenticator, err := securityx.NewTokenizer(bootstrap) - if err != nil { - return nil, err - } - return authenticator, nil + database *ent.Database + cache ifacestorage.Cache + provider storage.Provider + config interfaces.StructuredConfig + Log *log.Helper } -func NewAuthorizer(bootstrap *configs.Bootstrap) (security.Authorizer, error) { - return securityx.NewAuthorizer(bootstrap) -} - -func debugDatabase(driver dialect.Driver, debug bool) dialect.Driver { - if debug { - return entslog.New(driver) - } - return driver -} - -// NewData . -func NewData(r runtime.Runtime, bootstrap *configs.Bootstrap) (*Data, func(), error) { - if bootstrap == nil { - return nil, nil, errors.New("bootstrap is nil") - } - ll := log.NewHelper(r.WithLogger("module", "data")) - ll.Infow("msg", "bootstrap config", "value", bootstrap) - cfg := bootstrap.GetStorage().GetDatabase() - if cfg == nil { - return nil, nil, errors.New("data source not found") - } +// NewData creates a new Data instance. +func NewData(rt *runtime.App) (*Data, func(), error) { + logHelper := log.NewHelper(rt.Logger()) - drv, err := database.Open(cfg) - ll.Infow("msg", "connecting to database", "dialect", cfg.Dialect, "source", cfg.Source) + provider, err := storage.New(rt.StructuredConfig()) if err != nil { - ll.Errorw("msg", "failed opening connection to database", "error", err) return nil, nil, err } - // Run the auto migration tool. - //sqldb := debugDatabase(sql.OpenDB(cfg.Dialect, drv), cfg.Debug) - - db := ent.NewDatabase(ent.Driver(sql.OpenDB(cfg.Dialect, drv)), ent.WithDebug(func(driver dialect.Driver, f ...func(...any)) dialect.Driver { - return debugDatabase(driver, cfg.Debug) - })) - if true || cfg.GetMigration().GetEnabled() { - if err := db.Migration( - r.Context(), - schema.WithDropIndex(true), - schema.WithDropColumn(true), - schema.WithForeignKeys(false)); err != nil { - log.Errorw("msg", "failed creating schema resources", "error", err) - return nil, nil, err - } - } - - data := &Data{ - Log: ll, - Database: db, - Delimiter: TreePathDelimiter, - } - - return data, func() { - ll.Info("closing the data resources") - if err := drv.Close(); err != nil { - log.Error(err) - } - }, nil -} - -// InitDataFromPath . -func (obj *Data) InitDataFromPath(ctx context.Context, path string, filters ...string) error { - type data struct { - name string - fn func(ctx context.Context, filename string) error - } - initializers := []data{ - { - name: "resource", - fn: obj.InitResourceFromFile, - }, - { - name: "role", - fn: obj.InitRoleFromFile, - }, - { - name: "user", - fn: obj.InitUserFromFile, - }, - { - name: "department", - fn: obj.InitDepartmentFromFile, - }, - { - name: "position", - fn: obj.InitPositionFromFile, - }, - { - name: "permission", - fn: obj.InitPermissionFromFile, - }, - } - actions := make([]data, 0) - for _, di := range initializers { - for _, filter := range filters { - if di.name == filter { - actions = append(actions, di) - } - } - - } - for _, action := range actions { - action.name = filepath.Join(path, action.name+".json") - err := action.fn(ctx, action.name) - if err != nil { - return err - } - } - - return nil -} -func (obj *Data) InitResourceFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var resources []*dto.ResourceNode - err = codec.DecodeFromFile(abs, &resources) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Resource data file not found, skip init resource data from file", "file", abs) - return nil - } - return err - } - for i, pb := range resources { - log.Infow("msg", "Processing resource", "index", i, "resourceId", pb.Id, "resourceKeyword", pb.Keyword, "resourceName", pb.Name) - if pb.Children != nil { - for i2, child := range pb.Children { - log.Infow("msg", "Processing child", "index", i2, "childId", child.Id, "childKeyword", child.Keyword, "childName", child.Name) - } - } - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createResourceBatchWithParent(ctx, resources, nil) - }) -} - -func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto.ResourceNode, parent *dto.ResourcePB) error { - total := len(items) - log.Infow("msg", "Starting createResourceBatchWithParent", "totalItems", total) - - for i, item := range items { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - var pid int64 - if parent != nil { - pid = parent.Id - log.Infow("msg", "Parent ID set", "parentId", pid) - } - founded := false - switch { - case item.Id != 0: - log.Infow("Checking item by ID", "itemId", item.Id) - exists, err := obj.Resource(ctx).Query().Where(resource.ID(item.Id)).Exist(ctx) - if err != nil { - log.Errorw("msg", "Error checking item by ID", "itemId", item.Id, "error", err) - return err - } - if exists { - log.Infow("msg", "Item already exists by ID", "itemId", item.Id) - continue - } - case item.Keyword != "": - log.Infow("msg", "Checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid) - var wheres = []predicate.Resource{ - resource.Keyword(item.Keyword), - } - if pid != 0 { - wheres = append(wheres, resource.ParentID(pid)) - } - exists, err := obj.Resource(ctx).Query().Where(wheres...).Exist(ctx) - if err != nil { - log.Errorw("msg", "Error checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) - return err - } - if exists { - resourceItem, err := obj.Resource(ctx).Query().Where(wheres...).First(ctx) - if err != nil { - log.Errorw("msg", "Error fetching item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) - return err - } - founded = true - item.Id = resourceItem.ID - log.Infow("msg", "Item found by Keyword", "itemKeyword", item.Keyword, "itemId", item.Id) - } - case item.Name != "": - log.Infow("msg", "Checking item by Name", "itemName", item.Name, "parentId", pid) - var conditions = []predicate.Resource{ - resource.Name(item.Name), - } - if pid != 0 { - conditions = append(conditions, resource.ParentID(pid)) - } - exists, err := obj.Resource(ctx).Query().Where(conditions...).Exist(ctx) - if err != nil { - log.Errorw("msg", "Error checking item by Name", "itemName", item.Name, "parentId", pid, "error", err) - return err - } - if exists { - resourceItem, err := obj.Resource(ctx).Query().Where(conditions...).First(ctx) - if err != nil { - log.Errorw("msg", "Error fetching item by Name", "itemName", item.Name, "parentId", pid, "error", err) - return err - } - founded = true - item.Id = resourceItem.ID - log.Infow("msg", "Item found by Name", "itemName", item.Name, "itemId", item.Id) - } - default: - log.Infow("msg", "No ID, Keyword, or Name provided for item") - } - - if !founded { - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if item.Status == 0 { - item.Status = int32(dto.UserStatusActive) - log.Infow("msg", "Setting default status for item", "itemId", item.Id, "status", item.Status) - } - if item.Sequence == 0 { - item.Sequence = int32(total - i) - log.Infow("msg", "Setting default sequence for item", "itemId", item.Id, "sequence", item.Sequence) - } - - item.ParentId = pid - if parent != nil { - item.TreePath = parent.TreePath + strconv.Itoa(int(pid)) + TreePathDelimiter - log.Infow("msg", "Setting parent path for item", "itemId", item.Id, "treePath", item.TreePath) - } - itemObj := dto.ConvertResourcePB2Object(&item.ResourcePB) - itemObj.UpdateTime = time.Now() - itemObj.CreateTime = time.Now() - if _, err := obj.Resource(ctx).Create().SetResource(itemObj).Save(ctx); err != nil { - log.Errorw("msg", "Error creating resource item", "itemId", item.Id, "sequence", item.Sequence, "error", err) - return err - } - log.Infow("msg", "Resource item created successfully", "itemId", item.Id) - } - - if len(item.Children) != 0 { - log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) - if err := obj.createResourceBatchWithParent(ctx, item.Children, &item.ResourcePB); err != nil { - log.Errorw("Error processing children", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Children processed successfully", "itemId", item.Id) - } - } - log.Infow("msg", "Finished createResourceBatchWithParent") - return nil -} - -func (obj *Data) InitUserFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var users []*dto.UserNode - err = codec.DecodeFromFile(abs, &users) + db, err := provider.DefaultDatabase() if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("User data file not found, skip init user data from file", "file", abs) - return nil - } - return err + return nil, nil, err } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createUserBatch(ctx, users) - }) -} -func (obj *Data) createUserBatch(ctx context.Context, users []*dto.UserNode) error { - total := len(users) - log.Infow("msg", "Starting createUserBatch", "totalItems", total) - for i, item := range users { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemUsername", item.Username, "itemNickname", item.Nickname) - user, ps, err := dto.MakeCreateUser(&item.UserPB, item.Username, item.Password, dto.UserMutationOption{}) - if err != nil { - return err - } - fmt.Println("generate user: ", user.Username, "with password: ", ps) - if _, err := obj.User(ctx).Create().SetIsSystem(item.IsSystem).SetUser(dto.ConvertUserPB2Object(user)). - Save(ctx); err != nil { - log.Errorw("msg", "Error creating user item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "User item created successfully", "itemId", item.Id, "itemUuid", item.Uuid) - } - log.Infow("msg", "Finished createUserBatch") - return nil -} + activeDB := entsql.OpenDB(db.Dialect(), db.DB()) + database := ent.NewDatabase(ent.Driver(activeDB)) -func (obj *Data) InitRoleFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var roles []*dto.RolePB - err = codec.DecodeFromFile(abs, &roles) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Role data file not found, skip init role data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createRoleBatch(ctx, roles) - }) -} - -func (obj *Data) createRoleBatch(ctx context.Context, roles []*dto.RolePB) error { - total := len(roles) - log.Infow("msg", "Starting createRoleBatch", "totalItems", total) - for i, item := range roles { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if _, err := obj.Role(ctx).Create().SetRole(dto.ConvertRolePB2Object(item)).Save(ctx); err != nil { - log.Errorw("msg", "Error creating role item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Role item created successfully", "itemId", item.Id) + // Run the auto migration tool. + // Note: context.Background() is used here as the schema creation is a one-time setup. + if err := database.Client(context.Background()).Schema.Create(context.Background(), + schema.WithDropIndex(true), + schema.WithDropColumn(true), + schema.WithForeignKeys(false)); err != nil { + logHelper.Fatalf("failed creating schema resources: %v", err) } - log.Infow("msg", "Finished createRoleBatch") - return nil -} -func (obj *Data) InitDepartmentFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var departments []*dto.DepartmentNode - err = codec.DecodeFromFile(abs, &departments) + cache, err := provider.DefaultCache() if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Department data file not found, skip init department data from file", "file", abs) - return nil - } - return err + return nil, nil, err } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createDepartmentBatch(ctx, departments, nil) - }) -} - -func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.DepartmentNode, parent *dto.DepartmentPB) error { - total := len(departments) - log.Infow("msg", "Starting createDepartmentBatch", "totalItems", total) - for i, item := range departments { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if parent != nil { - item.ParentId = parent.Id - item.TreePath = parent.TreePath + strconv.Itoa(int(parent.Id)) + TreePathDelimiter - } - if _, err := obj.Department(ctx).Create(). - SetDepartment(dto.ConvertDepartmentPB2Object(&item.DepartmentPB)). - Save(ctx); err != nil { - log.Errorw("msg", "Error creating department item", "itemId", item.Id, "error", err) - return err - } - - log.Infow("msg", "Department item created successfully", "itemId", item.Id) - if len(item.Children) != 0 { - log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) - if err := obj.createDepartmentBatch(ctx, item.Children, &item.DepartmentPB); err != nil { - log.Errorw("Error processing children", "itemId", item.Id, "error", err) - return err + cleanup := func() { + logHelper.Info("closing the data resources") + if database != nil { + if err := database.Client(context.Background()).Close(); err != nil { + logHelper.Errorf("failed to close ent client: %v", err) } - log.Infow("msg", "Children processed successfully", "itemId", item.Id) - } - } - log.Infow("msg", "Finished createDepartmentBatch") - return nil -} - -func (obj *Data) InitPositionFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var positions []*dto.PositionNode - err = codec.DecodeFromFile(abs, &positions) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Position data file not found, skip init position data from file", "file", abs) - return nil } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createPositionBatch(ctx, positions) - }) -} -func (obj *Data) createPositionBatch(ctx context.Context, positions []*dto.PositionNode) error { - total := len(positions) - log.Infow("msg", "Starting createPositionBatch", "totalItems", total) - for i, item := range positions { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - dept, err := obj.Department(ctx).Query().Where(department.Keyword(item.DepartmentKeyword)).Only(ctx) - if err != nil { - return err - } - - if _, err := obj.Position(ctx).Create().SetPosition(&dto.Position{ - ID: item.Id, - CreateTime: time.Now(), - UpdateTime: time.Now(), - Name: item.Name, - Keyword: item.Keyword, - Description: item.Description, - DepartmentID: dept.ID, - }).Save(ctx); err != nil { - log.Errorw("msg", "Error creating position item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Position item created successfully", "itemId", item.Id) } - log.Infow("msg", "Finished createPositionBatch") - return nil -} -func (obj *Data) InitPermissionFromFile(ctx context.Context, filename string) error { - abs, err := filepath.Abs(filename) - if err != nil { - return err - } - var permissions []*dto.PermissionNode - err = codec.DecodeFromFile(abs, &permissions) - if err != nil { - if errors.Is(err, os.ErrNotExist) { - log.Warnw("Permission data file not found, skip init permission data from file", "file", abs) - return nil - } - return err - } - return obj.Tx(ctx, func(ctx context.Context) error { - return obj.createPermissionBatch(ctx, permissions) - }) + return &Data{ + config: rt.StructuredConfig(), + provider: provider, + database: database, + cache: cache, + Log: logHelper, + }, cleanup, nil } -func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.PermissionNode) error { - total := len(permissions) - log.Infow("msg", "Starting createPermissionBatch", "totalItems", total) - for i, item := range permissions { - log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) - if item.Id == 0 { - item.Id = id.Gen() - log.Infow("msg", "Generated new ID for item", "itemId", item.Id) - } - if _, err := obj.Permission(ctx).Create(). - SetPermission(dto.ConvertPermissionPB2Object(&item.PermissionPB)). - Save(ctx); err != nil { - log.Errorw("msg", "Error creating permission item", "itemId", item.Id, "error", err) - return err - } - log.Infow("msg", "Permission item created successfully", "itemId", item.Id) - } - log.Infow("msg", "Finished createPermissionBatch") - return nil +// DB returns the ent.Client instance. +func (d *Data) DB() *ent.Database { + return d.database } diff --git a/internal/data/entity/ent/database.go b/internal/data/entity/ent/database.go index 8d3b61b1..a21918bc 100644 --- a/internal/data/entity/ent/database.go +++ b/internal/data/entity/ent/database.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/schema" - "github.com/origadmin/runtime/interfaces/database" + "github.com/origadmin/runtime/interfaces/storage/database" ) // Database is the client that holds all ent builders. diff --git a/internal/data/entity/ent/schema/department.go b/internal/data/entity/ent/schema/department.go index d8ee96cd..a50a6c3b 100644 --- a/internal/data/entity/ent/schema/department.go +++ b/internal/data/entity/ent/schema/department.go @@ -13,8 +13,8 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" ) // Department holds the schema definition for the Department domain. diff --git a/internal/data/entity/ent/schema/notification.go b/internal/data/entity/ent/schema/notification.go index 757de96d..02372872 100644 --- a/internal/data/entity/ent/schema/notification.go +++ b/internal/data/entity/ent/schema/notification.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/schema" "entgo.io/ent/schema/field" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" "origadmin/application/admin/internal/data/entity/ent/schema/types" ) diff --git a/internal/data/entity/ent/schema/permission.go b/internal/data/entity/ent/schema/permission.go index 5b4244d7..267cf6f5 100644 --- a/internal/data/entity/ent/schema/permission.go +++ b/internal/data/entity/ent/schema/permission.go @@ -12,8 +12,8 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" ) // Permission holds the schema definition for the Permission entity. diff --git a/internal/data/entity/ent/schema/permissionresource.go b/internal/data/entity/ent/schema/permissionresource.go index 4b914b0f..d825f9e3 100644 --- a/internal/data/entity/ent/schema/permissionresource.go +++ b/internal/data/entity/ent/schema/permissionresource.go @@ -12,8 +12,8 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/index" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" ) type PermissionResource struct { diff --git a/internal/data/entity/ent/schema/position.go b/internal/data/entity/ent/schema/position.go index 7785bd44..e2d2c5b8 100644 --- a/internal/data/entity/ent/schema/position.go +++ b/internal/data/entity/ent/schema/position.go @@ -12,8 +12,8 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" ) // Position holds the schema definition for the Position entity. diff --git a/internal/data/entity/ent/schema/positionpermission.go b/internal/data/entity/ent/schema/positionpermission.go index 97f08233..a56bc514 100644 --- a/internal/data/entity/ent/schema/positionpermission.go +++ b/internal/data/entity/ent/schema/positionpermission.go @@ -12,8 +12,8 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/index" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" ) // PositionPermission holds the schema definition for the PositionPermission domain. diff --git a/internal/data/entity/ent/schema/resource.go b/internal/data/entity/ent/schema/resource.go index a4604da7..fa02298a 100644 --- a/internal/data/entity/ent/schema/resource.go +++ b/internal/data/entity/ent/schema/resource.go @@ -13,8 +13,8 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" ) const ( diff --git a/internal/data/entity/ent/schema/role.go b/internal/data/entity/ent/schema/role.go index 10642b69..a56cadde 100644 --- a/internal/data/entity/ent/schema/role.go +++ b/internal/data/entity/ent/schema/role.go @@ -13,8 +13,8 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" "origadmin/application/admin/internal/data/entity/ent/schema/types" ) diff --git a/internal/data/entity/ent/schema/rolepermission.go b/internal/data/entity/ent/schema/rolepermission.go index 022f13f7..f1d5a44d 100644 --- a/internal/data/entity/ent/schema/rolepermission.go +++ b/internal/data/entity/ent/schema/rolepermission.go @@ -12,8 +12,8 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/index" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" ) // RolePermission holds the schema definition for the RolePermission entity. diff --git a/internal/data/entity/ent/schema/softdelete.go b/internal/data/entity/ent/schema/softdelete.go index 40f1e9ea..602008bf 100644 --- a/internal/data/entity/ent/schema/softdelete.go +++ b/internal/data/entity/ent/schema/softdelete.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql" - "origadmin/application/admin/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/ent/mixin" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/hook" "origadmin/application/admin/internal/data/entity/ent/intercept" diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 66ff5335..76b660f0 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -13,8 +13,8 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" "origadmin/application/admin/internal/data/entity/ent/hook" "origadmin/application/admin/internal/data/entity/ent/schema/audit" "origadmin/application/admin/internal/data/entity/ent/schema/types" diff --git a/internal/data/entity/ent/schema/userdepartment.go b/internal/data/entity/ent/schema/userdepartment.go index 0a281992..d3b275d9 100644 --- a/internal/data/entity/ent/schema/userdepartment.go +++ b/internal/data/entity/ent/schema/userdepartment.go @@ -12,8 +12,8 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/index" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" ) // UserDepartment holds the schema definition for the UserDepartment domain. diff --git a/internal/data/entity/ent/schema/userposition.go b/internal/data/entity/ent/schema/userposition.go index 74cf7d26..23caac7d 100644 --- a/internal/data/entity/ent/schema/userposition.go +++ b/internal/data/entity/ent/schema/userposition.go @@ -12,8 +12,8 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/index" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" ) // UserPosition holds the schema definition for the UserPosition entity. diff --git a/internal/data/entity/ent/schema/userrole.go b/internal/data/entity/ent/schema/userrole.go index be34f221..ce456616 100644 --- a/internal/data/entity/ent/schema/userrole.go +++ b/internal/data/entity/ent/schema/userrole.go @@ -12,8 +12,8 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/index" - "origadmin/application/admin/helpers/ent/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" ) // UserRole holds the schema definition for the UserRole domain. diff --git a/internal/data/entity/ent/template/database.tpl b/internal/data/entity/ent/template/database.tpl index 86a38099..05bbdd69 100644 --- a/internal/data/entity/ent/template/database.tpl +++ b/internal/data/entity/ent/template/database.tpl @@ -13,7 +13,7 @@ "context" "fmt" "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime/interfaces/database" + "github.com/origadmin/runtime/interfaces/storage/database" ) // Database is the client that holds all ent builders. diff --git a/internal/features/auth/biz/auth.biz.go b/internal/features/auth/biz/auth.biz.go index 3004a1ec..2f84015e 100644 --- a/internal/features/auth/biz/auth.biz.go +++ b/internal/features/auth/biz/auth.biz.go @@ -8,9 +8,10 @@ package biz import ( "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/helpers/pagination" + pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/mods/auth/dto" ) diff --git a/internal/features/auth/biz/biz.go b/internal/features/auth/biz/biz.go index ea170208..9ba4b24a 100644 --- a/internal/features/auth/biz/biz.go +++ b/internal/features/auth/biz/biz.go @@ -5,7 +5,7 @@ package biz import ( - "github.com/origadmin/runtime/interfaces/pagination" + "origadmin/application/admin/internal/helpers/pagination" ) var ( diff --git a/internal/features/auth/biz/casbin.biz.go b/internal/features/auth/biz/casbin.biz.go index 9dc73ca5..7a35d17a 100644 --- a/internal/features/auth/biz/casbin.biz.go +++ b/internal/features/auth/biz/casbin.biz.go @@ -11,10 +11,11 @@ import ( "time" "github.com/origadmin/runtime" - "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" "google.golang.org/grpc" + "origadmin/application/admin/internal/helpers/pagination" + pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/mods/auth/dto" ) diff --git a/internal/features/auth/biz/login.biz.go b/internal/features/auth/biz/login.biz.go index 124d3bf4..07e5aeb2 100644 --- a/internal/features/auth/biz/login.biz.go +++ b/internal/features/auth/biz/login.biz.go @@ -9,9 +9,10 @@ import ( "context" "github.com/origadmin/runtime" - "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/helpers/pagination" + pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/mods/auth/dto" ) diff --git a/internal/features/auth/biz/personal.biz.go b/internal/features/auth/biz/personal.biz.go index 830b840b..9528e4dd 100644 --- a/internal/features/auth/biz/personal.biz.go +++ b/internal/features/auth/biz/personal.biz.go @@ -9,9 +9,10 @@ import ( "context" "github.com/origadmin/runtime" - "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/helpers/pagination" + pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/mods/auth/dto" ) diff --git a/internal/features/auth/dal/auth.dal.go b/internal/features/auth/dal/auth.dal.go index 6894fca2..7169bbaa 100644 --- a/internal/features/auth/dal/auth.dal.go +++ b/internal/features/auth/dal/auth.dal.go @@ -18,7 +18,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" _ "origadmin/application/admin/internal/data/entity/ent/runtime" - "origadmin/application/admin/internal/mods/auth/dto" + "origadmin/application/admin/internal/features/auth/dto" // Corrected import path ) type authRepo struct { @@ -142,10 +142,10 @@ func authResourceQueryPage(query *ent.ResourceQuery, in *pb.ListAuthResourcesReq func authResourceQueryOptions(query *ent.ResourceQuery, option dto.AuthResourceQueryOption) *ent.ResourceQuery { if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).ResourceQuery + query = query.Select(option.SelectFields...).(*ent.ResourceQuery) } if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).ResourceQuery + query = query.Omit(option.OmitFields...).(*ent.ResourceQuery) } if len(option.OrderFields) > 0 { query = query.Order(resourceOrderBy(option.OrderFields)...) diff --git a/internal/features/auth/dal/casbin.dal.go b/internal/features/auth/dal/casbin.dal.go index c663ea09..4aae8655 100644 --- a/internal/features/auth/dal/casbin.dal.go +++ b/internal/features/auth/dal/casbin.dal.go @@ -12,7 +12,7 @@ import ( pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/mods/auth/dto" + "origadmin/application/admin/internal/features/auth/dto" // Corrected import path ) type CasbinSourceConfig struct { diff --git a/internal/features/auth/dal/dal.go b/internal/features/auth/dal/dal.go index 6d771a97..89700737 100644 --- a/internal/features/auth/dal/dal.go +++ b/internal/features/auth/dal/dal.go @@ -19,7 +19,7 @@ import ( "origadmin/application/admin/helpers/id" "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/mods/auth/dto" + "origadmin/application/admin/internal/features/auth/dto" // Corrected import path ) const ( diff --git a/internal/features/auth/dal/login.dal.go b/internal/features/auth/dal/login.dal.go index 9a4c30c2..585d7403 100644 --- a/internal/features/auth/dal/login.dal.go +++ b/internal/features/auth/dal/login.dal.go @@ -10,24 +10,21 @@ import ( "sync" kerr "github.com/go-kratos/kratos/v2/errors" - jwtv1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" - securityv1 "github.com/origadmin/runtime/api/gen/go/security/v1" + + jwtv1 "github.com/origadmin/contrib/api/gen/go/security/authn/jwt/v1" + securityv1 "github.com/origadmin/contrib/api/gen/go/security/v1" + "github.com/origadmin/contrib/security" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/security" + "github.com/origadmin/runtime/errors" // Changed from httperr "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/rand" - "github.com/origadmin/toolkits/errors/httperr" - "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent/user" - - "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/helpers/captcha" - "origadmin/application/admin/helpers/resp" - "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/mods/auth/dto" - authdto "origadmin/application/admin/internal/mods/auth/dto" + "origadmin/application/admin/internal/features/auth/dto" // Corrected import path + authdto "origadmin/application/admin/internal/features/auth/dto" // Corrected import path + "origadmin/application/admin/internal/helpers/captcha" + "origadmin/application/admin/internal/helpers/resp" ) type loginRepo struct { @@ -113,7 +110,7 @@ func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.Log return nil, dto.ErrInvalidUsername case userData.Status != authdto.UserStatusActive: log.Warnf("User %s is not activated", data.Username) - return nil, httperr.New("unknown", 400, "User status is not activated, please contact the administrator") + return nil, errors.New(400, "unknown", "User status is not activated, please contact the administrator") // Corrected errors.New usage default: log.Debugf("User found with ID %d and status %d", userData.ID, userData.Status) } diff --git a/internal/features/auth/dal/user.dal.go b/internal/features/auth/dal/user.dal.go index e30b728e..a7487141 100644 --- a/internal/features/auth/dal/user.dal.go +++ b/internal/features/auth/dal/user.dal.go @@ -13,7 +13,7 @@ import ( "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/mods/auth/dto" + "origadmin/application/admin/internal/features/auth/dto" // Corrected import path ) type userRepo struct { diff --git a/internal/features/auth/dto/auth.go b/internal/features/auth/dto/auth.go index 8a28c04e..cc77dca7 100644 --- a/internal/features/auth/dto/auth.go +++ b/internal/features/auth/dto/auth.go @@ -8,7 +8,7 @@ package dto import ( "context" - "github.com/origadmin/runtime/interfaces/pagination" + "origadmin/application/admin/internal/helpers/pagination" pb "origadmin/application/admin/api/v1/services/auth" ) diff --git a/internal/features/auth/dto/dto.go b/internal/features/auth/dto/dto.go index afdbbd9f..26898cd2 100644 --- a/internal/features/auth/dto/dto.go +++ b/internal/features/auth/dto/dto.go @@ -8,7 +8,7 @@ package dto import ( "net/http" - "github.com/origadmin/toolkits/errors/httperr" + "github.com/origadmin/runtime/errors" // Changed from httperr "google.golang.org/protobuf/types/known/timestamppb" typespb "origadmin/application/admin/api/v1/services/types" @@ -45,11 +45,11 @@ type ( var ( // ErrUserNotFound is user not found. - ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") - ErrInvalidCaptchaID = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") - ErrInvalidPassword = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") - ErrInvalidUsername = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") - ErrCaptchaIDNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") + ErrUserNotFound = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") + ErrInvalidCaptchaID = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") + ErrInvalidPassword = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") + ErrInvalidUsername = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") + ErrCaptchaIDNotFound = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") ) // ConvertUser2PB user.table.comment diff --git a/internal/features/auth/server/server.go b/internal/features/auth/server/server.go index 9aefdb9a..f755e544 100644 --- a/internal/features/auth/server/server.go +++ b/internal/features/auth/server/server.go @@ -19,7 +19,7 @@ import ( "github.com/origadmin/toolkits/errors" "origadmin/application/admin/internal/configs" - authservice "origadmin/application/admin/internal/mods/auth/service" + authservice "origadmin/application/admin/internal/features/auth/service" // Corrected import path ) const ( diff --git a/internal/features/auth/service/auth.grpc.go b/internal/features/auth/service/auth.grpc.go index 078501cc..1eaedb28 100644 --- a/internal/features/auth/service/auth.grpc.go +++ b/internal/features/auth/service/auth.grpc.go @@ -8,7 +8,7 @@ import ( "github.com/origadmin/runtime/context" pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/mods/auth/biz" + "origadmin/application/admin/internal/features/auth/biz" // Corrected import path ) // AuthServiceServer is a menu service. diff --git a/internal/features/auth/service/casbin.go b/internal/features/auth/service/casbin.go index 1e1bba03..4125045d 100644 --- a/internal/features/auth/service/casbin.go +++ b/internal/features/auth/service/casbin.go @@ -15,7 +15,7 @@ import ( pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/contrib/security/authz/casbin" - "origadmin/application/admin/internal/mods/auth/biz" + "origadmin/application/admin/internal/features/auth/biz" // Corrected import path ) // CasbinSourceBiz is a Casbin rule source service. diff --git a/internal/features/auth/service/casbin.grpc.go b/internal/features/auth/service/casbin.grpc.go index a596212b..5fc556e4 100644 --- a/internal/features/auth/service/casbin.grpc.go +++ b/internal/features/auth/service/casbin.grpc.go @@ -12,7 +12,7 @@ import ( "google.golang.org/grpc" pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/mods/auth/biz" + "origadmin/application/admin/internal/features/auth/biz" // Corrected import path ) type CasbinSourceServiceServer struct { diff --git a/internal/features/auth/service/login.grpc.go b/internal/features/auth/service/login.grpc.go index 7cdf6540..dede06d2 100644 --- a/internal/features/auth/service/login.grpc.go +++ b/internal/features/auth/service/login.grpc.go @@ -8,7 +8,7 @@ import ( "golang.org/x/net/context" pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/mods/auth/biz" + "origadmin/application/admin/internal/features/auth/biz" // Corrected import path ) // LoginServiceServer is a login service. diff --git a/internal/features/auth/service/personal.grpc.go b/internal/features/auth/service/personal.grpc.go index 5d5915b8..a9b9acd6 100644 --- a/internal/features/auth/service/personal.grpc.go +++ b/internal/features/auth/service/personal.grpc.go @@ -10,7 +10,7 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/mods/auth/biz" + "origadmin/application/admin/internal/features/auth/biz" // Corrected import path ) // PersonalServiceServer is a login service. diff --git a/internal/features/datastore/biz/biz.go b/internal/features/datastore/biz/biz.go index 0e4b98d9..7c11317b 100644 --- a/internal/features/datastore/biz/biz.go +++ b/internal/features/datastore/biz/biz.go @@ -5,21 +5,18 @@ package biz import ( - "net/http" - - "github.com/origadmin/runtime/interfaces/pagination" - "github.com/origadmin/toolkits/errors/httperr" - + "github.com/origadmin/runtime/errors" typespb "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/helpers/pagination" ) var ( // ErrUserNotFound is user not found. - ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") + ErrUserNotFound = errors.New(50001, typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), "user not found") ) var ( - defaultLimiter = pagination.DefaultLimiter() + defaultLimiter = pagination.PageLimiter{} ) type UpdateHooker interface { diff --git a/internal/features/datastore/biz/datastore.go b/internal/features/datastore/biz/datastore.go index df9acc06..ebfbcae5 100644 --- a/internal/features/datastore/biz/datastore.go +++ b/internal/features/datastore/biz/datastore.go @@ -8,11 +8,12 @@ package biz import ( "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/helpers/pagination" + pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) // PermissionServiceBiz is a PermissionPB use case. diff --git a/internal/features/datastore/dal/menu.dal.go b/internal/features/datastore/dal/menu.dal.go index e37e4e8e..b6dfa1b3 100644 --- a/internal/features/datastore/dal/menu.dal.go +++ b/internal/features/datastore/dal/menu.dal.go @@ -8,7 +8,7 @@ import ( "github.com/origadmin/runtime" "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) type menuRepo struct { diff --git a/internal/features/datastore/dal/permission.dal.go b/internal/features/datastore/dal/permission.dal.go index ebeb9958..a79b5fb8 100644 --- a/internal/features/datastore/dal/permission.dal.go +++ b/internal/features/datastore/dal/permission.dal.go @@ -15,7 +15,7 @@ import ( "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) type permissionRepo struct { @@ -152,10 +152,10 @@ func permissionQueryPage(query *ent.PermissionQuery, in *pb.ListPermissionsReque func permissionQueryOptions(query *ent.PermissionQuery, option dto.PermissionQueryOption) *ent.PermissionQuery { if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).PermissionQuery + query = query.Select(option.SelectFields...).(*ent.PermissionQuery) } if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).PermissionQuery + query = query.Omit(option.OmitFields...).(*ent.PermissionQuery) } if len(option.OrderFields) > 0 { query = query.Order(permissionOrderBy(option.OrderFields)...) diff --git a/internal/features/datastore/dal/resource.dal.go b/internal/features/datastore/dal/resource.dal.go index 86a69c22..137a1b10 100644 --- a/internal/features/datastore/dal/resource.dal.go +++ b/internal/features/datastore/dal/resource.dal.go @@ -15,7 +15,7 @@ import ( "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) type resourceRepo struct { @@ -140,10 +140,10 @@ func resourceOrderBy(orders []string) []resource.OrderOption { func resourceQueryOptions(query *ent.ResourceQuery, option dto.ResourceQueryOption) *ent.ResourceQuery { if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).ResourceQuery + query = query.Select(option.SelectFields...).(*ent.ResourceQuery) } if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).ResourceQuery + query = query.Omit(option.OmitFields...).(*ent.ResourceQuery) } if len(option.OrderFields) > 0 { query = query.Order(resourceOrderBy(option.OrderFields)...) diff --git a/internal/features/datastore/dal/role.dal.go b/internal/features/datastore/dal/role.dal.go index 843bfd61..aa79e75c 100644 --- a/internal/features/datastore/dal/role.dal.go +++ b/internal/features/datastore/dal/role.dal.go @@ -18,7 +18,7 @@ import ( "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) type roleRepo struct { @@ -156,10 +156,10 @@ func rolePageQuery(ctx context.Context, query *ent.RoleQuery, in *pb.ListRolesRe func roleQueryOptions(query *ent.RoleQuery, option dto.RoleQueryOption) *ent.RoleQuery { if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).RoleQuery + query = query.Select(option.SelectFields...).(*ent.RoleQuery) } if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).RoleQuery + query = query.Omit(option.OmitFields...).(*ent.RoleQuery) } if len(option.OrderFields) > 0 { query = query.Order(roleOrderBy(option.OrderFields)...) diff --git a/internal/features/datastore/dal/user.dal.go b/internal/features/datastore/dal/user.dal.go index 216df004..3ed61bd1 100644 --- a/internal/features/datastore/dal/user.dal.go +++ b/internal/features/datastore/dal/user.dal.go @@ -18,7 +18,7 @@ import ( "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) type userRepo struct { @@ -207,10 +207,10 @@ func userPageQuery(ctx context.Context, query *ent.UserQuery, in *pb.ListUsersRe func userQueryOptions(query *ent.UserQuery, option dto.UserQueryOption) *ent.UserQuery { if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).UserQuery + query = query.Select(option.SelectFields...).(*ent.UserQuery) } if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).UserQuery + query = query.Omit(option.OmitFields...).(*ent.UserQuery) } if len(option.OrderFields) > 0 { query = query.Order(userOrderBy(option.OrderFields)...) diff --git a/internal/features/datastore/dto/dto.go b/internal/features/datastore/dto/dto.go index bdca763d..a2616597 100644 --- a/internal/features/datastore/dto/dto.go +++ b/internal/features/datastore/dto/dto.go @@ -8,7 +8,7 @@ package dto import ( "net/http" - "github.com/origadmin/toolkits/errors/httperr" + "github.com/origadmin/runtime/errors" "google.golang.org/protobuf/types/known/timestamppb" typespb "origadmin/application/admin/api/v1/services/types" @@ -19,11 +19,11 @@ import ( var ( // ErrUserNotFound is user not found. - ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") - ErrInvalidCaptchaID = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") - ErrInvalidPassword = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") - ErrInvalidUsername = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") - ErrCaptchaIDNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") + ErrUserNotFound = errors.New(http.errors"http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") + ErrInvalidCaptchaID = errors.New(http.errors"http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") + ErrInvalidPassword = errors.New(http.errors"http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") + ErrInvalidUsername = errors.New(http.errors"http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") + ErrCaptchaIDNotFound = errors.New(http.errors"http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") ) const ( diff --git a/internal/features/datastore/dto/menu.go b/internal/features/datastore/dto/menu.go index 9568d083..3542e0b6 100644 --- a/internal/features/datastore/dto/menu.go +++ b/internal/features/datastore/dto/menu.go @@ -6,7 +6,7 @@ package dto import ( - "github.com/origadmin/runtime/interfaces/pagination" + "origadmin/application/admin/internal/helpers/pagination" pb "origadmin/application/admin/api/v1/services/system" ) diff --git a/internal/features/datastore/dto/permission.go b/internal/features/datastore/dto/permission.go index 39dd6487..0c9a1e63 100644 --- a/internal/features/datastore/dto/permission.go +++ b/internal/features/datastore/dto/permission.go @@ -8,7 +8,7 @@ package dto import ( "context" - "github.com/origadmin/runtime/interfaces/pagination" + "origadmin/application/admin/internal/helpers/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/resp" diff --git a/internal/features/datastore/dto/resource.go b/internal/features/datastore/dto/resource.go index 74a0c30a..7ee531b0 100644 --- a/internal/features/datastore/dto/resource.go +++ b/internal/features/datastore/dto/resource.go @@ -8,7 +8,7 @@ package dto import ( "context" - "github.com/origadmin/runtime/interfaces/pagination" + "origadmin/application/admin/internal/helpers/pagination" pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/helpers/resp" diff --git a/internal/features/datastore/dto/role.go b/internal/features/datastore/dto/role.go index 0ddbc33c..061a07c9 100644 --- a/internal/features/datastore/dto/role.go +++ b/internal/features/datastore/dto/role.go @@ -9,7 +9,7 @@ import ( "context" "time" - "github.com/origadmin/runtime/interfaces/pagination" + "origadmin/application/admin/internal/helpers/pagination" "google.golang.org/protobuf/proto" pb "origadmin/application/admin/api/v1/services/system" diff --git a/internal/features/datastore/dto/user.go b/internal/features/datastore/dto/user.go index b9eb649b..ed8e552f 100644 --- a/internal/features/datastore/dto/user.go +++ b/internal/features/datastore/dto/user.go @@ -9,11 +9,12 @@ import ( "context" "github.com/google/uuid" - "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/rand" + "origadmin/application/admin/internal/helpers/pagination" + pb "origadmin/application/admin/api/v1/services/system" typespb "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/helpers/id" diff --git a/internal/features/datastore/server/server.go b/internal/features/datastore/server/server.go index 1fc8a7bd..2c0a8a6e 100644 --- a/internal/features/datastore/server/server.go +++ b/internal/features/datastore/server/server.go @@ -19,7 +19,7 @@ import ( "github.com/origadmin/toolkits/errors" "origadmin/application/admin/internal/configs" - systemservice "origadmin/application/admin/internal/mods/system/service" + systemservice "origadmin/application/admin/internal/features/system/service" // Corrected import path ) const ( diff --git a/internal/features/datastore/service/permission.grpc.go b/internal/features/datastore/service/permission.grpc.go index 5a4d716c..f8473a5e 100644 --- a/internal/features/datastore/service/permission.grpc.go +++ b/internal/features/datastore/service/permission.grpc.go @@ -10,7 +10,7 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + "origadmin/application/admin/internal/features/system/biz" // Corrected import path ) // PermissionServiceServer is a menu service. diff --git a/internal/features/datastore/service/permission.http.go b/internal/features/datastore/service/permission.http.go index e16657f0..545ab348 100644 --- a/internal/features/datastore/service/permission.http.go +++ b/internal/features/datastore/service/permission.http.go @@ -10,7 +10,7 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + "origadmin/application/admin/internal/features/system/biz" // Corrected import path ) // PermissionServiceHTTPServer is a menu service. diff --git a/internal/features/datastore/service/resource.grpc.go b/internal/features/datastore/service/resource.grpc.go index dc570f60..75ab8a57 100644 --- a/internal/features/datastore/service/resource.grpc.go +++ b/internal/features/datastore/service/resource.grpc.go @@ -10,7 +10,7 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + "origadmin/application/admin/internal/features/system/biz" // Corrected import path ) // ResourceServiceServer is a menu service. diff --git a/internal/features/system/biz/biz.go b/internal/features/system/biz/biz.go index 0e4b98d9..b8b993f1 100644 --- a/internal/features/system/biz/biz.go +++ b/internal/features/system/biz/biz.go @@ -7,15 +7,16 @@ package biz import ( "net/http" - "github.com/origadmin/runtime/interfaces/pagination" - "github.com/origadmin/toolkits/errors/httperr" + "github.com/origadmin/runtime/errors" // Changed from httperr + + "origadmin/application/admin/internal/helpers/pagination" typespb "origadmin/application/admin/api/v1/services/types" ) var ( // ErrUserNotFound is user not found. - ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") + ErrUserNotFound = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") ) var ( diff --git a/internal/features/system/biz/permission.biz.go b/internal/features/system/biz/permission.biz.go index df9acc06..ebfbcae5 100644 --- a/internal/features/system/biz/permission.biz.go +++ b/internal/features/system/biz/permission.biz.go @@ -8,11 +8,12 @@ package biz import ( "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/helpers/pagination" + pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) // PermissionServiceBiz is a PermissionPB use case. diff --git a/internal/features/system/biz/resource.biz.go b/internal/features/system/biz/resource.biz.go index 2b980143..9b4f1947 100644 --- a/internal/features/system/biz/resource.biz.go +++ b/internal/features/system/biz/resource.biz.go @@ -8,12 +8,13 @@ package biz import ( "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/helpers/pagination" + pb "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) // ResourceServiceBiz is a ResourcePB use case. diff --git a/internal/features/system/biz/role.biz.go b/internal/features/system/biz/role.biz.go index 78afc8d2..3e6b746e 100644 --- a/internal/features/system/biz/role.biz.go +++ b/internal/features/system/biz/role.biz.go @@ -8,11 +8,12 @@ package biz import ( "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/helpers/pagination" + pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) // RoleServiceBiz is a RolePB use case. diff --git a/internal/features/system/biz/user.biz.go b/internal/features/system/biz/user.biz.go index ad8ddc0b..eb061468 100644 --- a/internal/features/system/biz/user.biz.go +++ b/internal/features/system/biz/user.biz.go @@ -10,11 +10,12 @@ import ( "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/pagination" "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/helpers/pagination" + pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) // UserServiceBiz is a UserPB use case. diff --git a/internal/features/system/dal/dal.go b/internal/features/system/dal/dal.go index 18173605..2d0cd078 100644 --- a/internal/features/system/dal/dal.go +++ b/internal/features/system/dal/dal.go @@ -3,7 +3,3 @@ */ package dal - -import ( - "github.com/google/wire" -) diff --git a/internal/features/system/dal/menu.dal.go b/internal/features/system/dal/menu.dal.go index e37e4e8e..186bf6d3 100644 --- a/internal/features/system/dal/menu.dal.go +++ b/internal/features/system/dal/menu.dal.go @@ -5,173 +5,182 @@ package dal import ( - "github.com/origadmin/runtime" + "context" + "strings" + + "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime" "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path + "origadmin/application/admin/internal/helpers/db" ) type menuRepo struct { - db *data.Data + data *data.Data + db *ent.Database +} + +func (repo menuRepo) Get(ctx context.Context, id int64, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { + var option dto.MenuQueryOption + if len(options) > 0 { + option = options[0] + } + query := repo.db.Resource(ctx).Query().Where(resource.ID(id)) + query = menuQueryOptions(query, option) + result, err := query.First(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResourceToMenuPB(result), nil +} + +func (repo menuRepo) Create(ctx context.Context, menuPB *dto.MenuPB, + options ...dto.MenuQueryOption) (*dto.MenuPB, error) { + var option dto.MenuQueryOption + if len(options) > 0 { + option = options[0] + } + err := repo.db.Tx(ctx, func(ctx context.Context) error { + create := repo.db.Resource(ctx).Create() + create.SetResource(dto.ConvertMenuPBToResource(menuPB), option.Fields...) + saved, err := create.Save(ctx) + if err != nil { + return err + } + menuPB = dto.ConvertResourceToMenuPB(saved) + return nil + }) + if err != nil { + return nil, err + } + return menuPB, nil } -// -//func (repo menuRepo) Get(ctx context.Context, id int64, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { -// var option dto.MenuQueryOption -// if len(options) > 0 { -// option = options[0] -// } -// query := repo.db.Menu(ctx).Query().Where(menu.ID(id)) -// query = menuQueryOptions(query, option) -// result, err := query.First(ctx) -// if err != nil { -// return nil, err -// } -// return dto.ConvertMenu2PB(result), nil -//} -// -//func (repo menuRepo) Create(ctx context.Context, menuPB *dto.MenuPB, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { -// var option dto.MenuQueryOption -// if len(options) > 0 { -// option = options[0] -// } -// err := repo.db.Tx(ctx, func(ctx context.Context) error { -// create := repo.db.Menu(ctx).Create() -// create.SetMenu(dto.ConvertMenuPB2Object(menuPB), option.Fields...) -// saved, err := create.Save(ctx) -// if err != nil { -// return err -// } -// menuPB = dto.ConvertMenu2PB(saved) -// return nil -// }) -// if err != nil { -// return nil, err -// } -// return menuPB, nil -//} -// -//func (repo menuRepo) Delete(ctx context.Context, id int64) error { -// return repo.db.Tx(ctx, func(ctx context.Context) error { -// return repo.db.Menu(ctx).DeleteOneID(id).Exec(ctx) -// }) -//} -// -//func (repo menuRepo) Update(ctx context.Context, menuPB *dto.MenuPB, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { -// err := repo.db.Tx(ctx, func(ctx context.Context) error { -// update := repo.db.Menu(ctx).UpdateOneID(menuPB.Id) -// update.SetMenu(dto.ConvertMenuPB2Object(menuPB)) -// saved, err := update.Save(ctx) -// if err != nil { -// return err -// } -// menuPB = dto.ConvertMenu2PB(saved) -// return nil -// }) -// if err != nil { -// return nil, err -// } -// return menuPB, nil -//} -// -//func (repo menuRepo) List(ctx context.Context, in *dto.ListMenusRequest, options ...dto.MenuQueryOption) ([]*dto.MenuPB, int32, error) { -// var option dto.MenuQueryOption -// if len(options) > 0 { -// option = options[0] -// } -// -// query := repo.db.Menu(ctx).Query() -// if option.IncludeResources { -// query = query.WithResources() -// } -// if v := option.UserID; v > 0 { -// query = query.Where(menu.HasRolesWith(role.HasUsersWith(user.ID(v)))) -// } -// if v := option.RoleID; v > 0 { -// query = query.Where(menu.HasRolesWith(role.ID(v))) -// } -// if v := option.InIDs; len(v) > 0 { -// query = query.Where(menu.IDIn(v...)) -// } -// if v := option.Name; len(v) > 0 { -// query = query.Where(menu.ParentPathContains(v)) -// } -// if v := option.Status; v > 0 { -// query = query.Where(menu.StatusEQ(v)) -// } -// if v := option.ParentID; v > 0 { -// query = query.Where(menu.ParentID(v)) -// } -// if v := option.ParentPathPrefix; len(v) > 0 { -// query = query.Where(menu.ParentPathHasPrefix(v)) -// } -// -// return menuPageQuery(ctx, query, in, option) -//} +func (repo menuRepo) Delete(ctx context.Context, id int64) error { + return repo.db.Tx(ctx, func(ctx context.Context) error { + return repo.db.Resource(ctx).DeleteOneID(id).Exec(ctx) + }) +} + +func (repo menuRepo) Update(ctx context.Context, menuPB *dto.MenuPB, options ...dto.MenuQueryOption) (*dto.MenuPB, + error) { + err := repo.db.Tx(ctx, func(ctx context.Context) error { + update := repo.db.Resource(ctx).UpdateOneID(menuPB.Id) + update.SetResource(dto.ConvertMenuPBToResource(menuPB)) + saved, err := update.Save(ctx) + if err != nil { + return err + } + menuPB = dto.ConvertResourceToMenuPB(saved) + return nil + }) + if err != nil { + return nil, err + } + return menuPB, nil +} + +func (repo menuRepo) List(ctx context.Context, in *dto.ListMenusRequest, options ...dto.MenuQueryOption) ([]*dto.MenuPB, int32, error) { + var option dto.MenuQueryOption + if len(options) > 0 { + option = options[0] + } + + query := repo.db.Resource(ctx).Query() + //if option.IncludeResources { + // query = query.WithResources() + //} + //if v := option.UserID; v > 0 { + // query = query.Where(resource.HasRolesWith(role.HasUsersWith(user.ID(v)))) + //} + //if v := option.RoleID; v > 0 { + // query = query.Where(resource.HasRolesWith(role.ID(v))) + //} + if v := option.InIDs; len(v) > 0 { + query = query.Where(resource.IDIn(v...)) + } + //if v := option.Name; len(v) > 0 { + // query = query.Where(resource.ParentPathContains(v)) + //} + if v := option.Status; v > 0 { + query = query.Where(resource.StatusEQ(v)) + } + if v := option.ParentID; v > 0 { + query = query.Where(resource.ParentID(v)) + } + //if v := option.ParentPathPrefix; len(v) > 0 { + // query = query.Where(resource.ParentPathHasPrefix(v)) + //} + + return menuPageQuery(ctx, query, in, option) +} // NewMenuRepo . -func NewMenuRepo(r runtime.Runtime, db *data.Data) dto.MenuRepo { +func NewMenuRepo(r *runtime.App, d *data.Data) dto.MenuRepo { return &menuRepo{ - db: db, + data: d, + db: d.DB(), } } -// -//func menuPageQuery(ctx context.Context, query *ent.MenuQuery, in *pb.ListMenusRequest, option dto.MenuQueryOption) ([]*dto.MenuPB, int32, error) { -// if in.OnlyCount { -// count, err := query.Count(ctx) -// if err != nil { -// return nil, 0, err -// } -// return nil, int32(count), nil -// } -// count, err := query.Clone().Count(ctx) -// if err != nil { -// return nil, 0, err -// } -// query = menuQueryPage(query, in) -// query = menuQueryOptions(query, option) -// result, err := query.Clone().All(ctx) -// return dto.ConvertMenus(result), int32(count), err -//} -// -//func menuQueryPage(query *ent.MenuQuery, in *pb.ListMenusRequest) *ent.MenuQuery { -// if in.NoPaging { -// pageSize := in.PageSize -// if pageSize > 0 { -// query = query.Limit(int(pageSize)) -// } -// return query -// } -// -// pageSize := in.PageSize -// if pageSize > 0 { -// query = query.Limit(int(pageSize)) -// } -// current := in.Current -// if current > 0 { -// query = query.Offset(int((current - 1) * pageSize)) -// } -// return query -//} -// -//func menuQueryOptions(query *ent.MenuQuery, option dto.MenuQueryOption) *ent.MenuQuery { -// if len(option.SelectFields) > 0 { -// query = query.Select(option.SelectFields...).MenuQuery -// } -// if len(option.OmitFields) > 0 { -// query = query.Omit(option.OmitFields...).MenuQuery -// } -// if len(option.OrderFields) > 0 { -// query = query.Order(menuOrderBy(option.OrderFields)...) -// } -// return query -//} -// -//func menuOrderBy(fields []string, opts ...sql.OrderTermOption) []menu.OrderOption { -// var orders []menu.OrderOption -// for _, field := range fields { -// orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) -// } -// return orders -//} +func menuPageQuery(ctx context.Context, query *ent.ResourceQuery, in *dto.ListMenusRequest, + option dto.MenuQueryOption) ([]*dto.MenuPB, int32, error) { + if in.OnlyCount { + count, err := query.Count(ctx) + if err != nil { + return nil, 0, err + } + return nil, int32(count), nil + } + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, 0, err + } + query = db.QueryPage(query, in) + query = menuQueryOptions(query, option) + result, err := query.Clone().All(ctx) + menus := make([]*dto.MenuPB, len(result)) + for i, r := range result { + menus[i] = dto.ConvertResourceToMenuPB(r) + } + return menus, int32(count), err +} + +func menuQueryOptions(query *ent.ResourceQuery, option dto.MenuQueryOption) *ent.ResourceQuery { + //if len(option.SelectFields) > 0 { + // query = query.Select(option.SelectFields...).(*ent.ResourceQuery) + //} + //if len(option.OmitFields) > 0 { + // query = query.Omit(option.OmitFields...).(*ent.ResourceQuery) + //} + if len(option.OrderFields) > 0 { + query = query.Order(menuOrderBy(option.OrderFields)...) + } + return query +} + +func menuOrderBy(fields []string, opts ...sql.OrderTermOption) []resource.OrderOption { + var orders []resource.OrderOption + for _, field := range fields { + parts := strings.Split(field, ",") + fieldName := parts[0] + var orderOpt sql.OrderTermOption + + if len(parts) > 1 { + switch strings.ToLower(parts[1]) { + case "desc": + orderOpt = sql.OrderDesc() + default: + orderOpt = sql.OrderAsc() + } + } else { + orderOpt = sql.OrderAsc() + } + + orders = append(orders, sql.OrderByField(fieldName, orderOpt).ToFunc()) + } + return orders +} diff --git a/internal/features/system/dal/permission.dal.go b/internal/features/system/dal/permission.dal.go index ebeb9958..dde86113 100644 --- a/internal/features/system/dal/permission.dal.go +++ b/internal/features/system/dal/permission.dal.go @@ -8,18 +8,18 @@ import ( "context" "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime" + "github.com/origadmin/runtime" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/db" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/permission" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path + "origadmin/application/admin/internal/helpers/db" ) type permissionRepo struct { - db *data.Data + db *ent.Database } func (repo permissionRepo) Get(ctx context.Context, id int64, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { @@ -33,7 +33,7 @@ func (repo permissionRepo) Get(ctx context.Context, id int64, options ...dto.Per if err != nil { return nil, err } - return dto.ConvertPermission2PB(result), nil + return dto.ConvertPermissionToPermissionPB(result), nil } func (repo permissionRepo) Create(ctx context.Context, permission *dto.PermissionPB, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { @@ -41,20 +41,20 @@ func (repo permissionRepo) Create(ctx context.Context, permission *dto.Permissio if len(options) > 0 { option = options[0] } - obj := dto.ConvertPermissionPB2Object(permission) + obj := dto.ConvertPermissionPBToPermission(permission) create := repo.db.Permission(ctx).Create() if len(permission.ResourceIds) > 0 { create.AddResourceIDs(permission.ResourceIds...) } if len(permission.Resources) > 0 { - create.AddResources(dto.ConvertResourcesPB2Object(permission.Resources)...) + create.AddResources(dto.ConvertResourcesPBToResources(permission.Resources)...) } create.SetPermission(obj, option.Fields...) saved, err := create.Save(ctx) if err != nil { return nil, err } - return dto.ConvertPermission2PB(saved), nil + return dto.ConvertPermissionToPermissionPB(saved), nil } func (repo permissionRepo) Delete(ctx context.Context, id int64) error { @@ -68,21 +68,21 @@ func (repo permissionRepo) Update(ctx context.Context, permission *dto.Permissio } update := repo.db.Permission(ctx).UpdateOneID(permission.Id) - obj := dto.ConvertPermissionPB2Object(permission) + obj := dto.ConvertPermissionPBToPermission(permission) if len(permission.ResourceIds) > 0 { update.ClearResources() update.AddResourceIDs(permission.ResourceIds...) } if len(permission.Resources) > 0 { update.ClearResources() - update.AddResources(dto.ConvertResourcesPB2Object(permission.Resources)...) + update.AddResources(dto.ConvertResourcesPBToResources(permission.Resources)...) } update.SetPermission(obj, option.Fields...) saved, err := update.Save(ctx) if err != nil { return nil, err } - return dto.ConvertPermission2PB(saved), nil + return dto.ConvertPermissionToPermissionPB(saved), nil } func (repo permissionRepo) List(ctx context.Context, in *dto.ListPermissionsRequest, options ...dto.PermissionQueryOption) ([]*dto.PermissionPB, int32, error) { @@ -105,9 +105,9 @@ func (repo permissionRepo) List(ctx context.Context, in *dto.ListPermissionsRequ } // NewPermissionRepo . -func NewPermissionRepo(r runtime.Runtime, db *data.Data) dto.PermissionRepo { +func NewPermissionRepo(r *runtime.App, d *data.Data) dto.PermissionRepo { return &permissionRepo{ - db: db, + db: d.DB(), } } @@ -127,7 +127,7 @@ func permissionPageQuery(ctx context.Context, query *ent.PermissionQuery, in *pb } query = db.Query(query, in, !in.NoPaging) result, err := query.All(ctx) - return dto.ConvertPermissions(result), int32(count), err + return dto.ConvertPermissionsToPermissionsPB(result), int32(count), err } func permissionQueryPage(query *ent.PermissionQuery, in *pb.ListPermissionsRequest) *ent.PermissionQuery { diff --git a/internal/features/system/dal/provider.go b/internal/features/system/dal/provider.go index e013feb9..db5cd8fc 100644 --- a/internal/features/system/dal/provider.go +++ b/internal/features/system/dal/provider.go @@ -7,18 +7,42 @@ package dal import ( "github.com/google/wire" + + "origadmin/application/admin/internal/features/system/dto" // Corrected import path ) +// Repositories is a collection of all repositories. +type Repositories struct { + MenuRepo dto.MenuRepo + ResourceRepo dto.ResourceRepo + RoleRepo dto.RoleRepo + UserRepo dto.UserRepo + PermissionRepo dto.PermissionRepo +} + +// NewRepositories creates a new Repositories instance. +func NewRepositories( + menuRepo dto.MenuRepo, + resourceRepo dto.ResourceRepo, + roleRepo dto.RoleRepo, + userRepo dto.UserRepo, + permissionRepo dto.PermissionRepo, +) *Repositories { + return &Repositories{ + MenuRepo: menuRepo, + ResourceRepo: resourceRepo, + RoleRepo: roleRepo, + UserRepo: userRepo, + PermissionRepo: permissionRepo, + } +} + // ProviderSet is data providers. var ProviderSet = wire.NewSet( - //NewAuthRepo, - //NewLoginRepo, - //NewPersonalRepo, NewMenuRepo, NewResourceRepo, NewRoleRepo, NewUserRepo, NewPermissionRepo, - //NewCasbinSourceRepo, - //RefreshTokenizer, + NewRepositories, // Provide the aggregated Repositories struct ) diff --git a/internal/features/system/dal/resource.dal.go b/internal/features/system/dal/resource.dal.go index 86a69c22..d74291f3 100644 --- a/internal/features/system/dal/resource.dal.go +++ b/internal/features/system/dal/resource.dal.go @@ -9,17 +9,17 @@ import ( "strconv" "github.com/origadmin/runtime" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/db" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/db" ) type resourceRepo struct { - db *data.Data + db *ent.Database + Delimiter string } func (repo resourceRepo) Get(ctx context.Context, id int64, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { @@ -29,14 +29,14 @@ func (repo resourceRepo) Get(ctx context.Context, id int64, options ...dto.Resou } query := repo.db.Resource(ctx).Query().Where(resource.ID(id)) query = resourceQueryOptions(query, option) - if option.IncludePermissions { - query.WithPermissions() - } + //if option.IncludePermissions { + // query.WithPermissions() + //} result, err := query.First(ctx) if err != nil { return nil, err } - return dto.ConvertResource2PB(result), nil + return dto.ConvertResourceToResourcePB(result), nil } func (repo resourceRepo) Create(ctx context.Context, resource *dto.ResourcePB, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { @@ -44,13 +44,13 @@ func (repo resourceRepo) Create(ctx context.Context, resource *dto.ResourcePB, o if len(options) > 0 { option = options[0] } - obj := dto.ConvertResourcePB2Object(resource) + obj := dto.ConvertResourcePBToResource(resource) if obj.ParentID > 0 { parent, err := repo.db.Resource(ctx).Get(ctx, obj.ParentID) if err != nil { return nil, err } - obj.TreePath = parent.TreePath + strconv.Itoa(int(parent.ID)) + repo.db.Delimiter + obj.TreePath = parent.TreePath + strconv.Itoa(int(parent.ID)) + repo.Delimiter } create := repo.db.Resource(ctx).Create() @@ -59,13 +59,13 @@ func (repo resourceRepo) Create(ctx context.Context, resource *dto.ResourcePB, o create.AddPermissionIDs(resource.PermissionIds...) } if len(resource.Permissions) > 0 { - create.AddPermissions(dto.ConvertPermissionsPB2Object(resource.Permissions)...) + create.AddPermissions(dto.ConvertPermissionsPBToPermissions(resource.Permissions)...) } saved, err := create.Save(ctx) if err != nil { return nil, err } - return dto.ConvertResource2PB(saved), nil + return dto.ConvertResourceToResourcePB(saved), nil } func (repo resourceRepo) Delete(ctx context.Context, id int64) error { @@ -79,18 +79,18 @@ func (repo resourceRepo) Update(ctx context.Context, resource *dto.ResourcePB, o } err := repo.db.Tx(ctx, func(ctx context.Context) error { update := repo.db.Resource(ctx).UpdateOneID(resource.Id) - update.SetResourceWithZero(dto.ConvertResourcePB2Object(resource), option.Fields...) + update.SetResourceWithZero(dto.ConvertResourcePBToResource(resource), option.Fields...) if len(resource.PermissionIds) > 0 { update.AddPermissionIDs(resource.PermissionIds...) } if len(resource.Permissions) > 0 { - update.AddPermissions(dto.ConvertPermissionsPB2Object(resource.Permissions)...) + update.AddPermissions(dto.ConvertPermissionsPBToPermissions(resource.Permissions)...) } saved, err := update.Save(ctx) if err != nil { return err } - resource = dto.ConvertResource2PB(saved) + resource = dto.ConvertResourceToResourcePB(saved) return nil }) if err != nil { @@ -110,9 +110,9 @@ func (repo resourceRepo) List(ctx context.Context, in *dto.ListResourcesRequest, } // NewResourceRepo . -func NewResourceRepo(r runtime.Runtime, db *data.Data) dto.ResourceRepo { +func NewResourceRepo(r *runtime.App, d *data.Data) dto.ResourceRepo { return &resourceRepo{ - db: db, + db: d.DB(), } } @@ -131,7 +131,7 @@ func resourcePageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.Lis } query = db.Query(query, in, !in.NoPaging) result, err := query.All(ctx) - return dto.ConvertResources(result), int32(count), err + return dto.ConvertResourcesToResourcesPB(result), int32(count), err } func resourceOrderBy(orders []string) []resource.OrderOption { diff --git a/internal/features/system/dal/role.dal.go b/internal/features/system/dal/role.dal.go index 843bfd61..489c8119 100644 --- a/internal/features/system/dal/role.dal.go +++ b/internal/features/system/dal/role.dal.go @@ -9,21 +9,21 @@ import ( "errors" "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" "github.com/origadmin/toolkits/crypto/rand" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/db" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/role" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path + "origadmin/application/admin/internal/helpers/db" ) type roleRepo struct { - gen *rand.Rand - db *data.Data + gen rand.Generator + db *ent.Database } func (repo roleRepo) Get(ctx context.Context, id int64, options ...dto.RoleQueryOption) (*dto.RolePB, error) { @@ -37,7 +37,7 @@ func (repo roleRepo) Get(ctx context.Context, id int64, options ...dto.RoleQuery if err != nil { return nil, err } - return dto.ConvertRole2PB(result), nil + return dto.ConvertRoleToRolePB(result), nil } func (repo roleRepo) Create(ctx context.Context, rolePB *dto.RolePB, options ...dto.RoleUpdateOption) (*dto.RolePB, error) { @@ -45,9 +45,13 @@ func (repo roleRepo) Create(ctx context.Context, rolePB *dto.RolePB, options ... if len(options) > 0 { option = options[0] } - obj := dto.ConvertRolePB2Object(rolePB) + obj := dto.ConvertRolePBToRole(rolePB) if obj.Keyword == "" { - obj.Keyword = "system:role:" + repo.gen.RandString(12) + randString, err := repo.gen.RandString(12) + if err != nil { + randString = "" + } + obj.Keyword = "system:role:" + randString } exist, err := repo.db.Role(ctx).Query().Where(role.KeywordEqualFold(rolePB.Keyword)).Exist(ctx) if err != nil || exist { @@ -60,7 +64,7 @@ func (repo roleRepo) Create(ctx context.Context, rolePB *dto.RolePB, options ... if err != nil { return err } - rolePB = dto.ConvertRole2PB(saved) + rolePB = dto.ConvertRoleToRolePB(saved) return nil }) if err != nil { @@ -91,13 +95,13 @@ func (repo roleRepo) Update(ctx context.Context, rolePB *dto.RolePB, options ... } if len(rolePB.Permissions) > 0 { update.ClearPermissions() - update.AddPermissions(dto.ConvertPermissionsPB2Object(rolePB.Permissions)...) + update.AddPermissions(dto.ConvertPermissionsPBToPermissions(rolePB.Permissions)...) } - saved, err := update.SetRoleWithZero(dto.ConvertRolePB2Object(rolePB), option.Fields...).Save(ctx) + saved, err := update.SetRoleWithZero(dto.ConvertRolePBToRole(rolePB), option.Fields...).Save(ctx) if err != nil { return nil, err } - rolePB = dto.ConvertRole2PB(saved) + rolePB = dto.ConvertRoleToRolePB(saved) return rolePB, nil } @@ -128,10 +132,10 @@ func (repo roleRepo) List(ctx context.Context, in *pb.ListRolesRequest, options } // NewRoleRepo . -func NewRoleRepo(r runtime.Runtime, db *data.Data) dto.RoleRepo { +func NewRoleRepo(r *runtime.App, d *data.Data) dto.RoleRepo { return &roleRepo{ - gen: rand.DigitAndLowerCase, - db: db, + gen: rand.NewGenerator(rand.KindDigit | rand.KindLowerCase), + db: d.DB(), } } @@ -151,16 +155,16 @@ func rolePageQuery(ctx context.Context, query *ent.RoleQuery, in *pb.ListRolesRe } query = db.Query(query, in, !in.NoPaging) result, err := query.All(ctx) - return dto.ConvertRoles(result), int32(count), err + return dto.ConvertRolesToRolesPB(result), int32(count), err } func roleQueryOptions(query *ent.RoleQuery, option dto.RoleQueryOption) *ent.RoleQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).RoleQuery - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).RoleQuery - } + //if len(option.SelectFields) > 0 { + // query = query.Select(option.SelectFields...).(*ent.RoleQuery) + //} + //if len(option.OmitFields) > 0 { + // query = query.Omit(option.OmitFields...).(*ent.RoleQuery) + //} if len(option.OrderFields) > 0 { query = query.Order(roleOrderBy(option.OrderFields)...) } diff --git a/internal/features/system/dal/user.dal.go b/internal/features/system/dal/user.dal.go index 216df004..6809a3a9 100644 --- a/internal/features/system/dal/user.dal.go +++ b/internal/features/system/dal/user.dal.go @@ -10,19 +10,18 @@ import ( "time" "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime" "github.com/origadmin/runtime/context" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/db" - "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/mods/system/dto" + "origadmin/application/admin/internal/features/system/dto" // Corrected import path + "origadmin/application/admin/internal/helpers/db" ) type userRepo struct { - db *data.Data + db *ent.Database } func (repo userRepo) AddRoleIDs(ctx context.Context, i int64, int64s []int64, option ...dto.UserMutationOption) error { @@ -48,7 +47,7 @@ func (repo userRepo) ListResourceByUserID(ctx context.Context, id int64, if err != nil { return nil, err } - return dto.ConvertResources(resources), nil + return dto.ConvertResourcesToResourcesPB(resources), nil } func (repo userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*dto.UserNode, error) { @@ -63,7 +62,7 @@ func (repo userRepo) GetByUsername(ctx context.Context, username string, fields return nil, err } return &dto.UserNode{ - UserPB: *dto.ConvertUser2PB(result), + UserPB: *dto.ConvertUserToUserPB(result), EncryptedPassword: result.EncryptedPassword, }, nil } @@ -83,7 +82,7 @@ func (repo userRepo) Get(ctx context.Context, id int64, options ...dto.UserQuery if err != nil { return nil, err } - return dto.ConvertUser2PB(result), nil + return dto.ConvertUserToUserPB(result), nil } func (repo userRepo) Create(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { @@ -97,7 +96,7 @@ func (repo userRepo) Create(ctx context.Context, userPB *dto.UserPB, options ... if err != nil || exist { return nil, errors.New("user already exists") } - obj := dto.ConvertUserPB2Object(userPB) + obj := dto.ConvertUserPBToUser(userPB) obj.CreateTime = time.Now() obj.UpdateTime = time.Now() err = repo.db.Tx(ctx, func(ctx context.Context) error { @@ -107,7 +106,7 @@ func (repo userRepo) Create(ctx context.Context, userPB *dto.UserPB, options ... if err != nil { return err } - userPB = dto.ConvertUser2PB(saved) + userPB = dto.ConvertUserToUserPB(saved) return nil }) if err != nil { @@ -123,13 +122,13 @@ func (repo userRepo) Delete(ctx context.Context, id int64) error { } func (repo userRepo) Update(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { - obj := dto.ConvertUserPB2Object(userPB) + obj := dto.ConvertUserPBToUser(userPB) obj.UpdateTime = time.Now() err := repo.db.Tx(ctx, func(ctx context.Context) error { update := repo.db.User(ctx).UpdateOneID(userPB.Id) if len(userPB.Roles) > 0 { update.ClearRoles() - update.AddRoles(dto.ConvertRolesPB2Object(userPB.Roles)...) + update.AddRoles(dto.ConvertRolesPBToRoles(userPB.Roles)...) } else { update.ClearRoles() } @@ -149,7 +148,7 @@ func (repo userRepo) Update(ctx context.Context, userPB *dto.UserPB, options ... if err != nil { return err } - userPB = dto.ConvertUser2PB(saved) + userPB = dto.ConvertUserToUserPB(saved) return nil }) if err != nil { @@ -180,7 +179,7 @@ func (repo userRepo) List(ctx context.Context, in *pb.ListUsersRequest, options } // NewUserRepo . -func NewUserRepo(r runtime.Runtime, db *data.Data) dto.UserRepo { +func NewUserRepo(r *runtime.App, db *ent.Database) dto.UserRepo { return &userRepo{ db: db, } @@ -202,16 +201,16 @@ func userPageQuery(ctx context.Context, query *ent.UserQuery, in *pb.ListUsersRe } query = db.Query(query, in, !in.NoPaging) result, err := query.All(ctx) - return dto.ConvertUsers(result), int32(count), err + return dto.ConvertUsersToUsersPB(result), int32(count), err } func userQueryOptions(query *ent.UserQuery, option dto.UserQueryOption) *ent.UserQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).UserQuery - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).UserQuery - } + //if len(option.SelectFields) > 0 { + // query = query.Select(option.SelectFields...).(*ent.UserQuery) + //} + //if len(option.OmitFields) > 0 { + // query = query.Omit(option.OmitFields...).(*ent.UserQuery) + //} if len(option.OrderFields) > 0 { query = query.Order(userOrderBy(option.OrderFields)...) } diff --git a/internal/features/system/dto/custom.gen.go b/internal/features/system/dto/custom.gen.go new file mode 100644 index 00000000..eb2a0284 --- /dev/null +++ b/internal/features/system/dto/custom.gen.go @@ -0,0 +1,17 @@ +package dto + +func ConvertMenuPBPropertiesToResourceProperties(from string) map[string]string { + panic("stub! not implemented") +} + +func ConvertResourcePropertiesToMenuPBProperties(from map[string]string) string { + panic("stub! not implemented") +} + +func ConvertUserGenderToUserPBGender(from Gender) string { + panic("stub! not implemented") +} + +func ConvertUserPBGenderToUserGender(from string) Gender { + panic("stub! not implemented") +} diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go new file mode 100644 index 00000000..1b80a282 --- /dev/null +++ b/internal/features/system/dto/dto.gen.go @@ -0,0 +1,1149 @@ +package dto + +import ( + "time" + + "google.golang.org/protobuf/types/known/timestamppb" + + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" +) + +type ( + Department = ent.Department + DepartmentEdges = ent.DepartmentEdges + DepartmentEdgesPB = types.DepartmentEdges + DepartmentPB = types.Department + Departments = []*ent.Department + DepartmentsPB = []*types.Department + MenuPB = types.Menu + MenusPB = []*types.Menu + Permission = ent.Permission + PermissionEdges = ent.PermissionEdges + PermissionEdgesPB = types.PermissionEdges + PermissionPB = types.Permission + PermissionResource = ent.PermissionResource + PermissionResourceEdges = ent.PermissionResourceEdges + PermissionResourceEdgesPB = types.PermissionResourceEdges + PermissionResourcePB = types.PermissionResource + PermissionResources = []*ent.PermissionResource + PermissionResourcesPB = []*types.PermissionResource + Permissions = []*ent.Permission + PermissionsPB = []*types.Permission + Position = ent.Position + PositionEdges = ent.PositionEdges + PositionEdgesPB = types.PositionEdges + PositionPB = types.Position + PositionPermission = ent.PositionPermission + PositionPermissionEdges = ent.PositionPermissionEdges + PositionPermissionEdgesPB = types.PositionPermissionEdges + PositionPermissionPB = types.PositionPermission + PositionPermissions = []*ent.PositionPermission + PositionPermissionsPB = []*types.PositionPermission + Positions = []*ent.Position + PositionsPB = []*types.Position + Resource = ent.Resource + ResourceEdges = ent.ResourceEdges + ResourceEdgesPB = types.ResourceEdges + ResourcePB = types.Resource + Resources = []*ent.Resource + ResourcesPB = []*types.Resource + Role = ent.Role + RoleEdges = ent.RoleEdges + RoleEdgesPB = types.RoleEdges + RoleMenuPB = types.RoleMenu + RoleMenusPB = []*types.RoleMenu + RolePB = types.Role + RolePermission = ent.RolePermission + RolePermissionEdges = ent.RolePermissionEdges + RolePermissionEdgesPB = types.RolePermissionEdges + RolePermissionPB = types.RolePermission + RolePermissions = []*ent.RolePermission + RolePermissionsPB = []*types.RolePermission + Roles = []*ent.Role + RolesPB = []*types.Role + TimestampPB = timestamppb.Timestamp + User = ent.User + UserDepartment = ent.UserDepartment + UserDepartmentEdges = ent.UserDepartmentEdges + UserDepartmentEdgesPB = types.UserDepartmentEdges + UserDepartmentPB = types.UserDepartment + UserDepartments = []*ent.UserDepartment + UserDepartmentsPB = []*types.UserDepartment + UserEdges = ent.UserEdges + UserEdgesPB = types.UserEdges + UserPB = types.User + UserPosition = ent.UserPosition + UserPositionEdges = ent.UserPositionEdges + UserPositionEdgesPB = types.UserPositionEdges + UserPositionPB = types.UserPosition + UserPositions = []*ent.UserPosition + UserPositionsPB = []*types.UserPosition + UserRole = ent.UserRole + UserRoleEdges = ent.UserRoleEdges + UserRoleEdgesPB = types.UserRoleEdges + UserRolePB = types.UserRole + UserRoles = []*ent.UserRole + UserRolesPB = []*types.UserRole + Users = []*ent.User + UsersPB = []*types.User +) + +func ConvertDepartmentEdgesPBToDepartmentEdges(from *DepartmentEdgesPB) *DepartmentEdges { + if from == nil { + return nil + } + + to := &DepartmentEdges{ + Users: ConvertUsersPBToUsers(from.Users), + Positions: ConvertPositionsPBToPositions(from.Positions), + Children: ConvertDepartmentsPBToDepartments(from.Children), + Parent: ConvertDepartmentPBToDepartment(from.Parent), + UserDepartments: ConvertUserDepartmentsPBToUserDepartments(from.UserDepartments), + } + return to +} + +func ConvertDepartmentEdgesToDepartmentEdgesPB(from *DepartmentEdges) *DepartmentEdgesPB { + if from == nil { + return nil + } + + to := &DepartmentEdgesPB{ + Users: ConvertUsersToUsersPB(from.Users), + Positions: ConvertPositionsToPositionsPB(from.Positions), + Parent: ConvertDepartmentToDepartmentPB(from.Parent), + Children: ConvertDepartmentsToDepartmentsPB(from.Children), + UserDepartments: ConvertUserDepartmentsToUserDepartmentsPB(from.UserDepartments), + } + return to +} + +func ConvertDepartmentPBToDepartment(from *DepartmentPB) *Department { + if from == nil { + return nil + } + + to := &Department{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + TreePath: from.TreePath, + Sequence: int(from.Sequence), + Status: int8(from.Status), + Level: int(from.Level), + Description: from.Description, + ParentID: from.ParentId, + } + return to +} + +func ConvertDepartmentToDepartmentPB(from *Department) *DepartmentPB { + if from == nil { + return nil + } + + to := &DepartmentPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + TreePath: from.TreePath, + Sequence: int32(from.Sequence), + Status: int32(from.Status), + Level: int32(from.Level), + Description: from.Description, + ParentId: from.ParentID, + } + return to +} + +func ConvertDepartmentsPBToDepartments(froms DepartmentsPB) Departments { + if froms == nil { + return nil + } + tos := make(Departments, len(froms)) + for i, f := range froms { + tos[i] = ConvertDepartmentPBToDepartment(f) + } + return tos +} + +func ConvertDepartmentsToDepartmentsPB(froms Departments) DepartmentsPB { + if froms == nil { + return nil + } + tos := make(DepartmentsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertDepartmentToDepartmentPB(f) + } + return tos +} + +func ConvertMenuPBToResource(from *MenuPB) *Resource { + if from == nil { + return nil + } + + to := &Resource{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + I18nKey: from.I18NKey, + Description: from.Description, + Sequence: int(from.Sequence), + Type: from.Type, + Icon: from.Icon, + Path: from.Path, + Properties: ConvertMenuPBPropertiesToResourceProperties(from.Properties), + Status: int8(from.Status), + ParentID: from.ParentId, + } + return to +} + +func ConvertPermissionEdgesPBToPermissionEdges(from *PermissionEdgesPB) *PermissionEdges { + if from == nil { + return nil + } + + to := &PermissionEdges{ + Roles: ConvertRolesPBToRoles(from.Roles), + Resources: ConvertResourcesPBToResources(from.Resources), + Positions: ConvertPositionsPBToPositions(from.Positions), + RolePermissions: ConvertRolePermissionsPBToRolePermissions(from.RolePermissions), + PermissionResources: ConvertPermissionResourcesPBToPermissionResources(from.PermissionResources), + PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), + } + return to +} + +func ConvertPermissionEdgesToPermissionEdgesPB(from *PermissionEdges) *PermissionEdgesPB { + if from == nil { + return nil + } + + to := &PermissionEdgesPB{ + Roles: ConvertRolesToRolesPB(from.Roles), + Positions: ConvertPositionsToPositionsPB(from.Positions), + Resources: ConvertResourcesToResourcesPB(from.Resources), + RolePermissions: ConvertRolePermissionsToRolePermissionsPB(from.RolePermissions), + PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), + PermissionResources: ConvertPermissionResourcesToPermissionResourcesPB(from.PermissionResources), + } + return to +} + +func ConvertPermissionPBToPermission(from *PermissionPB) *Permission { + if from == nil { + return nil + } + + to := &Permission{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DataScope: from.DataScope, + DataRules: from.DataRules, + } + return to +} + +func ConvertPermissionResourceEdgesPBToPermissionResourceEdges(from *PermissionResourceEdgesPB) *PermissionResourceEdges { + if from == nil { + return nil + } + + to := &PermissionResourceEdges{ + Permission: ConvertPermissionPBToPermission(from.Permission), + Resource: ConvertResourcePBToResource(from.Resource), + } + return to +} + +func ConvertPermissionResourceEdgesToPermissionResourceEdgesPB(from *PermissionResourceEdges) *PermissionResourceEdgesPB { + if from == nil { + return nil + } + + to := &PermissionResourceEdgesPB{ + Permission: ConvertPermissionToPermissionPB(from.Permission), + Resource: ConvertResourceToResourcePB(from.Resource), + } + return to +} + +func ConvertPermissionResourcePBToPermissionResource(from *PermissionResourcePB) *PermissionResource { + if from == nil { + return nil + } + + to := &PermissionResource{ + ID: int(from.Id), + PermissionID: from.PermissionId, + ResourceID: from.ResourceId, + } + return to +} + +func ConvertPermissionResourceToPermissionResourcePB(from *PermissionResource) *PermissionResourcePB { + if from == nil { + return nil + } + + to := &PermissionResourcePB{ + Id: int64(from.ID), + PermissionId: from.PermissionID, + ResourceId: from.ResourceID, + } + return to +} + +func ConvertPermissionResourcesPBToPermissionResources(froms PermissionResourcesPB) PermissionResources { + if froms == nil { + return nil + } + tos := make(PermissionResources, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionResourcePBToPermissionResource(f) + } + return tos +} + +func ConvertPermissionResourcesToPermissionResourcesPB(froms PermissionResources) PermissionResourcesPB { + if froms == nil { + return nil + } + tos := make(PermissionResourcesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionResourceToPermissionResourcePB(f) + } + return tos +} + +func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { + if from == nil { + return nil + } + + to := &PermissionPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DataScope: from.DataScope, + DataRules: from.DataRules, + } + return to +} + +func ConvertPermissionsPBToPermissions(froms PermissionsPB) Permissions { + if froms == nil { + return nil + } + tos := make(Permissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionPBToPermission(f) + } + return tos +} + +func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { + if froms == nil { + return nil + } + tos := make(PermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionToPermissionPB(f) + } + return tos +} + +func ConvertPositionEdgesPBToPositionEdges(from *PositionEdgesPB) *PositionEdges { + if from == nil { + return nil + } + + to := &PositionEdges{ + Department: ConvertDepartmentPBToDepartment(from.Department), + Users: ConvertUsersPBToUsers(from.Users), + Permissions: ConvertPermissionsPBToPermissions(from.Permissions), + UserPositions: ConvertUserPositionsPBToUserPositions(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), + } + return to +} + +func ConvertPositionEdgesToPositionEdgesPB(from *PositionEdges) *PositionEdgesPB { + if from == nil { + return nil + } + + to := &PositionEdgesPB{ + Department: ConvertDepartmentToDepartmentPB(from.Department), + Users: ConvertUsersToUsersPB(from.Users), + Permissions: ConvertPermissionsToPermissionsPB(from.Permissions), + UserPositions: ConvertUserPositionsToUserPositionsPB(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), + } + return to +} + +func ConvertPositionPBToPosition(from *PositionPB) *Position { + if from == nil { + return nil + } + + to := &Position{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DepartmentID: from.DepartmentId, + } + return to +} + +func ConvertPositionPermissionEdgesPBToPositionPermissionEdges(from *PositionPermissionEdgesPB) *PositionPermissionEdges { + if from == nil { + return nil + } + + to := &PositionPermissionEdges{ + Position: ConvertPositionPBToPosition(from.Position), + Permission: ConvertPermissionPBToPermission(from.Permission), + } + return to +} + +func ConvertPositionPermissionEdgesToPositionPermissionEdgesPB(from *PositionPermissionEdges) *PositionPermissionEdgesPB { + if from == nil { + return nil + } + + to := &PositionPermissionEdgesPB{ + Position: ConvertPositionToPositionPB(from.Position), + Permission: ConvertPermissionToPermissionPB(from.Permission), + } + return to +} + +func ConvertPositionPermissionPBToPositionPermission(from *PositionPermissionPB) *PositionPermission { + if from == nil { + return nil + } + + to := &PositionPermission{ + ID: int(from.Id), + PositionID: from.PositionId, + PermissionID: from.PermissionId, + } + return to +} + +func ConvertPositionPermissionToPositionPermissionPB(from *PositionPermission) *PositionPermissionPB { + if from == nil { + return nil + } + + to := &PositionPermissionPB{ + Id: int64(from.ID), + PositionId: from.PositionID, + PermissionId: from.PermissionID, + } + return to +} + +func ConvertPositionPermissionsPBToPositionPermissions(froms PositionPermissionsPB) PositionPermissions { + if froms == nil { + return nil + } + tos := make(PositionPermissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionPBToPositionPermission(f) + } + return tos +} + +func ConvertPositionPermissionsToPositionPermissionsPB(froms PositionPermissions) PositionPermissionsPB { + if froms == nil { + return nil + } + tos := make(PositionPermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionToPositionPermissionPB(f) + } + return tos +} + +func ConvertPositionToPositionPB(from *Position) *PositionPB { + if from == nil { + return nil + } + + to := &PositionPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DepartmentId: from.DepartmentID, + } + return to +} + +func ConvertPositionsPBToPositions(froms PositionsPB) Positions { + if froms == nil { + return nil + } + tos := make(Positions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPBToPosition(f) + } + return tos +} + +func ConvertPositionsToPositionsPB(froms Positions) PositionsPB { + if froms == nil { + return nil + } + tos := make(PositionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionToPositionPB(f) + } + return tos +} + +func ConvertResourceEdgesPBToResourceEdges(from *ResourceEdgesPB) *ResourceEdges { + if from == nil { + return nil + } + + to := &ResourceEdges{} + return to +} + +func ConvertResourceEdgesToResourceEdgesPB(from *ResourceEdges) *ResourceEdgesPB { + if from == nil { + return nil + } + + to := &ResourceEdgesPB{} + return to +} + +func ConvertResourcePBToResource(from *ResourcePB) *Resource { + if from == nil { + return nil + } + + to := &Resource{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + I18nKey: from.I18NKey, + Type: from.Type, + Status: int8(from.Status), + Path: from.Path, + Operation: from.Operation, + Method: from.Method, + Component: from.Component, + Icon: from.Icon, + Sequence: int(from.Sequence), + Visible: from.Visible, + TreePath: from.TreePath, + Properties: from.Properties, + Description: from.Description, + ParentID: from.ParentId, + } + return to +} + +func ConvertResourceToMenuPB(from *Resource) *MenuPB { + if from == nil { + return nil + } + + to := &MenuPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + I18NKey: from.I18nKey, + Type: from.Type, + Status: int32(from.Status), + Path: from.Path, + Icon: from.Icon, + Sequence: int32(from.Sequence), + Properties: ConvertResourcePropertiesToMenuPBProperties(from.Properties), + Description: from.Description, + ParentId: from.ParentID, + } + return to +} + +func ConvertResourceToResourcePB(from *Resource) *ResourcePB { + if from == nil { + return nil + } + + to := &ResourcePB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + I18NKey: from.I18nKey, + Type: from.Type, + Status: int32(from.Status), + Path: from.Path, + Operation: from.Operation, + Method: from.Method, + Component: from.Component, + Icon: from.Icon, + Sequence: int32(from.Sequence), + Visible: from.Visible, + TreePath: from.TreePath, + Properties: from.Properties, + Description: from.Description, + ParentId: from.ParentID, + } + return to +} + +func ConvertResourcesPBToResources(froms ResourcesPB) Resources { + if froms == nil { + return nil + } + tos := make(Resources, len(froms)) + for i, f := range froms { + tos[i] = ConvertResourcePBToResource(f) + } + return tos +} + +func ConvertResourcesToResourcesPB(froms Resources) ResourcesPB { + if froms == nil { + return nil + } + tos := make(ResourcesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertResourceToResourcePB(f) + } + return tos +} + +func ConvertRoleEdgesPBToRoleEdges(from *RoleEdgesPB) *RoleEdges { + if from == nil { + return nil + } + + to := &RoleEdges{ + Users: ConvertUsersPBToUsers(from.Users), + UserRoles: ConvertUserRolesPBToUserRoles(from.UserRoles), + } + return to +} + +func ConvertRoleEdgesToRoleEdgesPB(from *RoleEdges) *RoleEdgesPB { + if from == nil { + return nil + } + + to := &RoleEdgesPB{ + Users: ConvertUsersToUsersPB(from.Users), + UserRoles: ConvertUserRolesToUserRolesPB(from.UserRoles), + } + return to +} + +func ConvertRolePBToRole(from *RolePB) *Role { + if from == nil { + return nil + } + + to := &Role{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Description: from.Description, + Type: int8(from.Type), + Sequence: int(from.Sequence), + Status: int8(from.Status), + } + return to +} + +func ConvertRolePermissionEdgesPBToRolePermissionEdges(from *RolePermissionEdgesPB) *RolePermissionEdges { + if from == nil { + return nil + } + + to := &RolePermissionEdges{ + Role: ConvertRolePBToRole(from.Role), + Permission: ConvertPermissionPBToPermission(from.Permission), + } + return to +} + +func ConvertRolePermissionEdgesToRolePermissionEdgesPB(from *RolePermissionEdges) *RolePermissionEdgesPB { + if from == nil { + return nil + } + + to := &RolePermissionEdgesPB{ + Role: ConvertRoleToRolePB(from.Role), + Permission: ConvertPermissionToPermissionPB(from.Permission), + } + return to +} + +func ConvertRolePermissionPBToRolePermission(from *RolePermissionPB) *RolePermission { + if from == nil { + return nil + } + + to := &RolePermission{ + ID: int(from.Id), + RoleID: from.RoleId, + PermissionID: from.PermissionId, + } + return to +} + +func ConvertRolePermissionToRolePermissionPB(from *RolePermission) *RolePermissionPB { + if from == nil { + return nil + } + + to := &RolePermissionPB{ + Id: int64(from.ID), + RoleId: from.RoleID, + PermissionId: from.PermissionID, + } + return to +} + +func ConvertRolePermissionsPBToRolePermissions(froms RolePermissionsPB) RolePermissions { + if froms == nil { + return nil + } + tos := make(RolePermissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertRolePermissionPBToRolePermission(f) + } + return tos +} + +func ConvertRolePermissionsToRolePermissionsPB(froms RolePermissions) RolePermissionsPB { + if froms == nil { + return nil + } + tos := make(RolePermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertRolePermissionToRolePermissionPB(f) + } + return tos +} + +func ConvertRoleToRolePB(from *Role) *RolePB { + if from == nil { + return nil + } + + to := &RolePB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Description: from.Description, + Type: int32(from.Type), + Sequence: int32(from.Sequence), + Status: int32(from.Status), + } + return to +} + +func ConvertRolesPBToRoles(froms RolesPB) Roles { + if froms == nil { + return nil + } + tos := make(Roles, len(froms)) + for i, f := range froms { + tos[i] = ConvertRolePBToRole(f) + } + return tos +} + +func ConvertRolesToRolesPB(froms Roles) RolesPB { + if froms == nil { + return nil + } + tos := make(RolesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertRoleToRolePB(f) + } + return tos +} + +func ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from *UserDepartmentEdgesPB) *UserDepartmentEdges { + if from == nil { + return nil + } + + to := &UserDepartmentEdges{ + User: ConvertUserPBToUser(from.User), + Department: ConvertDepartmentPBToDepartment(from.Department), + } + return to +} + +func ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(from *UserDepartmentEdges) *UserDepartmentEdgesPB { + if from == nil { + return nil + } + + to := &UserDepartmentEdgesPB{ + User: ConvertUserToUserPB(from.User), + Department: ConvertDepartmentToDepartmentPB(from.Department), + } + return to +} + +func ConvertUserDepartmentPBToUserDepartment(from *UserDepartmentPB) *UserDepartment { + if from == nil { + return nil + } + + to := &UserDepartment{ + ID: int(from.Id), + UserID: from.UserId, + DepartmentID: from.DepartmentId, + Edges: *ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from.Edges), + } + return to +} + +func ConvertUserDepartmentToUserDepartmentPB(from *UserDepartment) *UserDepartmentPB { + if from == nil { + return nil + } + + to := &UserDepartmentPB{ + Id: int64(from.ID), + UserId: from.UserID, + DepartmentId: from.DepartmentID, + Edges: ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(&from.Edges), + } + return to +} + +func ConvertUserDepartmentsPBToUserDepartments(froms UserDepartmentsPB) UserDepartments { + if froms == nil { + return nil + } + tos := make(UserDepartments, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserDepartmentPBToUserDepartment(f) + } + return tos +} + +func ConvertUserDepartmentsToUserDepartmentsPB(froms UserDepartments) UserDepartmentsPB { + if froms == nil { + return nil + } + tos := make(UserDepartmentsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserDepartmentToUserDepartmentPB(f) + } + return tos +} + +func ConvertUserEdgesPBToUserEdges(from *UserEdgesPB) *UserEdges { + if from == nil { + return nil + } + + to := &UserEdges{ + Roles: ConvertRolesPBToRoles(from.Roles), + UserRoles: ConvertUserRolesPBToUserRoles(from.UserRoles), + } + return to +} + +func ConvertUserEdgesToUserEdgesPB(from *UserEdges) *UserEdgesPB { + if from == nil { + return nil + } + + to := &UserEdgesPB{ + Roles: ConvertRolesToRolesPB(from.Roles), + UserRoles: ConvertUserRolesToUserRolesPB(from.UserRoles), + } + return to +} + +func ConvertUserPBToUser(from *UserPB) *User { + if from == nil { + return nil + } + + to := &User{ + ID: from.Id, + CreateAuthor: from.CreateAuthor, + UpdateAuthor: from.UpdateAuthor, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + UUID: from.Uuid, + AllowedIP: from.AllowedIp, + Username: from.Username, + Nickname: from.Nickname, + Avatar: from.Avatar, + Name: from.Name, + Gender: ConvertUserPBGenderToUserGender(from.Gender), + Salt: from.Salt, + Phone: from.Phone, + Email: from.Email, + Remark: from.Remark, + Token: from.Token, + Status: int8(from.Status), + LastLoginIP: from.LastLoginIp, + LastLoginTime: ConvertTimestampToTime(from.LastLoginTime), + SanctionDate: ConvertTimestampToTime(from.SanctionDate), + ManagerID: from.ManagerId, + Manager: from.Manager, + } + return to +} + +func ConvertUserPositionEdgesPBToUserPositionEdges(from *UserPositionEdgesPB) *UserPositionEdges { + if from == nil { + return nil + } + + to := &UserPositionEdges{ + User: ConvertUserPBToUser(from.User), + Position: ConvertPositionPBToPosition(from.Position), + } + return to +} + +func ConvertUserPositionEdgesToUserPositionEdgesPB(from *UserPositionEdges) *UserPositionEdgesPB { + if from == nil { + return nil + } + + to := &UserPositionEdgesPB{ + User: ConvertUserToUserPB(from.User), + Position: ConvertPositionToPositionPB(from.Position), + } + return to +} + +func ConvertUserPositionPBToUserPosition(from *UserPositionPB) *UserPosition { + if from == nil { + return nil + } + + to := &UserPosition{ + ID: int(from.Id), + UserID: from.UserId, + PositionID: from.PositionId, + } + return to +} + +func ConvertUserPositionToUserPositionPB(from *UserPosition) *UserPositionPB { + if from == nil { + return nil + } + + to := &UserPositionPB{ + Id: int64(from.ID), + UserId: from.UserID, + PositionId: from.PositionID, + } + return to +} + +func ConvertUserPositionsPBToUserPositions(froms UserPositionsPB) UserPositions { + if froms == nil { + return nil + } + tos := make(UserPositions, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionPBToUserPosition(f) + } + return tos +} + +func ConvertUserPositionsToUserPositionsPB(froms UserPositions) UserPositionsPB { + if froms == nil { + return nil + } + tos := make(UserPositionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionToUserPositionPB(f) + } + return tos +} + +func ConvertUserRoleEdgesPBToUserRoleEdges(from *UserRoleEdgesPB) *UserRoleEdges { + if from == nil { + return nil + } + + to := &UserRoleEdges{ + User: ConvertUserPBToUser(from.User), + Role: ConvertRolePBToRole(from.Role), + } + return to +} + +func ConvertUserRoleEdgesToUserRoleEdgesPB(from *UserRoleEdges) *UserRoleEdgesPB { + if from == nil { + return nil + } + + to := &UserRoleEdgesPB{ + User: ConvertUserToUserPB(from.User), + Role: ConvertRoleToRolePB(from.Role), + } + return to +} + +func ConvertUserRolePBToUserRole(from *UserRolePB) *UserRole { + if from == nil { + return nil + } + + to := &UserRole{ + ID: int(from.Id), + UserID: from.UserId, + RoleID: from.RoleId, + } + return to +} + +func ConvertUserRoleToUserRolePB(from *UserRole) *UserRolePB { + if from == nil { + return nil + } + + to := &UserRolePB{ + Id: int64(from.ID), + UserId: from.UserID, + RoleId: from.RoleID, + } + return to +} + +func ConvertUserRolesPBToUserRoles(froms UserRolesPB) UserRoles { + if froms == nil { + return nil + } + tos := make(UserRoles, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserRolePBToUserRole(f) + } + return tos +} + +func ConvertUserRolesToUserRolesPB(froms UserRoles) UserRolesPB { + if froms == nil { + return nil + } + tos := make(UserRolesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserRoleToUserRolePB(f) + } + return tos +} + +func ConvertUserToUserPB(from *User) *UserPB { + if from == nil { + return nil + } + + to := &UserPB{ + Id: from.ID, + CreateAuthor: from.CreateAuthor, + UpdateAuthor: from.UpdateAuthor, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Uuid: from.UUID, + AllowedIp: from.AllowedIP, + Username: from.Username, + Nickname: from.Nickname, + Avatar: from.Avatar, + Name: from.Name, + Gender: ConvertUserGenderToUserPBGender(from.Gender), + Salt: from.Salt, + Phone: from.Phone, + Email: from.Email, + Remark: from.Remark, + Token: from.Token, + Status: int32(from.Status), + LastLoginIp: from.LastLoginIP, + LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), + SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), + ManagerId: from.ManagerID, + Manager: from.Manager, + } + return to +} + +func ConvertUsersPBToUsers(froms UsersPB) Users { + if froms == nil { + return nil + } + tos := make(Users, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPBToUser(f) + } + return tos +} + +func ConvertUsersToUsersPB(froms Users) UsersPB { + if froms == nil { + return nil + } + tos := make(UsersPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserToUserPB(f) + } + return tos +} + +func ConvertTimeToTimestamp(t time.Time) *timestamppb.Timestamp { + if t.IsZero() { + return nil + } + return timestamppb.New(t) +} +func ConvertTimestampToTime(ts *timestamppb.Timestamp) time.Time { + if ts == nil { + return time.Time{} + } + return ts.AsTime() +} diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index bdca763d..883e089e 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -1,1019 +1,17 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the system module. package dto import ( - "net/http" - - "github.com/origadmin/toolkits/errors/httperr" - "google.golang.org/protobuf/types/known/timestamppb" - - typespb "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/schema/types" "origadmin/application/admin/internal/data/entity/ent/user" ) -var ( - // ErrUserNotFound is user not found. - ErrUserNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") - ErrInvalidCaptchaID = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") - ErrInvalidPassword = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") - ErrInvalidUsername = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") - ErrCaptchaIDNotFound = httperr.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") -) - -const ( - UserStatusActive = types.Active - UserStatusFrozen = types.Frozen -) - -const ( - ResourceStatusEnabled = types.Enabled - ResourceStatusDisabled = types.Disabled -) - -type ( - // User 用户类型 - // @Convert( - // target = "UserPB", - // direction = "both", - // ignoreFields = ["password", "salt"] - // ) - User = ent.User - // UserPB - // @Convert( - // target="User", - // direction="both" - // ) - UserPB = typespb.User -) - -// ConvertUser2PB user.table.comment -func ConvertUser2PB(goModel *User) (pbModel *UserPB) { - pbModel = &UserPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.CreateAuthor = int64(goModel.CreateAuthor) - pbModel.UpdateAuthor = int64(goModel.UpdateAuthor) - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Uuid = goModel.UUID - pbModel.AllowedIp = goModel.AllowedIP - pbModel.Username = goModel.Username - pbModel.Nickname = goModel.Nickname - pbModel.Avatar = goModel.Avatar - pbModel.Name = goModel.Name - pbModel.Gender = ConvertGender2PB(goModel.Gender) - //pbModel.Password = goModel.EncryptedPassword - //pbModel.Salt = goModel.Salt - pbModel.Phone = goModel.Phone - pbModel.Email = goModel.Email - pbModel.Remark = goModel.Remark - pbModel.Token = goModel.Token - pbModel.Status = int32(goModel.Status) - pbModel.LastLoginIp = goModel.LastLoginIP - pbModel.LastLoginTime = timestamppb.New(goModel.LastLoginTime) - pbModel.SanctionDate = timestamppb.New(goModel.SanctionDate) - pbModel.ManagerId = int64(goModel.ManagerID) - pbModel.Manager = goModel.Manager - //pbModel.Roles = ConvertRoles(goModel.Edges.Roles) - for _, role := range goModel.Edges.Roles { - pbModel.RoleIds = append(pbModel.RoleIds, role.ID) - } - pbModel.Roles = ConvertRoles(goModel.Edges.Roles) - return pbModel -} - -func ConvertGender2PB(gender user.Gender) string { - return gender.String() -} - -// ConvertUserPB2Object user.table.comment -func ConvertUserPB2Object(pbModel *UserPB) (goModel *User) { - goModel = &User{} - if pbModel == nil { - return goModel - } - - goModel.ID = int64(pbModel.Id) - goModel.CreateAuthor = int64(pbModel.CreateAuthor) - goModel.UpdateAuthor = int64(pbModel.UpdateAuthor) - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.UUID = pbModel.Uuid - goModel.AllowedIP = pbModel.AllowedIp - goModel.Username = pbModel.Username - goModel.Nickname = pbModel.Nickname - goModel.Avatar = pbModel.Avatar - goModel.Name = pbModel.Name - goModel.Gender = user.Gender(pbModel.Gender) - //goModel.Password = pbModel.Password - //goModel.Salt = pbModel.Salt - goModel.Phone = pbModel.Phone - goModel.Email = pbModel.Email - goModel.Remark = pbModel.Remark - goModel.Token = pbModel.Token - goModel.Status = int8(pbModel.Status) - goModel.LastLoginIP = pbModel.LastLoginIp - goModel.LastLoginTime = pbModel.LastLoginTime.AsTime() - goModel.SanctionDate = pbModel.SanctionDate.AsTime() - goModel.ManagerID = pbModel.ManagerId - goModel.Manager = pbModel.Manager - return goModel -} - -type ( - Resource = ent.Resource - ResourcePB = typespb.Resource -) - -func ConvertResource2PB(goModel *Resource) (pbModel *ResourcePB) { - pbModel = &ResourcePB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = goModel.ID - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Name = goModel.Name - pbModel.Keyword = goModel.Keyword - pbModel.I18NKey = goModel.I18nKey - pbModel.Type = goModel.Type - pbModel.Status = int32(goModel.Status) - pbModel.Path = goModel.Path - pbModel.Operation = goModel.Operation - pbModel.Method = goModel.Method - pbModel.Component = goModel.Component - pbModel.Icon = goModel.Icon - pbModel.Sequence = int32(goModel.Sequence) - pbModel.Visible = goModel.Visible - pbModel.TreePath = goModel.TreePath - pbModel.Properties = goModel.Properties - pbModel.Description = goModel.Description - pbModel.ParentId = int64(goModel.ParentID) - return pbModel -} - -func ConvertResourcePB2Object(pbModel *ResourcePB) (goModel *Resource) { - goModel = &Resource{} - if pbModel == nil { - return goModel - } - - goModel.ID = pbModel.Id - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Name = pbModel.Name - goModel.Keyword = pbModel.Keyword - goModel.I18nKey = pbModel.I18NKey - goModel.Type = pbModel.Type - goModel.Status = int8(pbModel.Status) - goModel.Path = pbModel.Path - goModel.Operation = pbModel.Operation - goModel.Method = pbModel.Method - goModel.Component = pbModel.Component - goModel.Icon = pbModel.Icon - goModel.Sequence = int(pbModel.Sequence) - goModel.Visible = pbModel.Visible - goModel.TreePath = pbModel.TreePath - goModel.Properties = pbModel.Properties - goModel.Description = pbModel.Description - goModel.ParentID = pbModel.ParentId - return goModel -} - -type ( - Role = ent.Role - RolePB = typespb.Role -) - -// ConvertRole2PB role.table.comment -func ConvertRole2PB(goModel *Role) (pbModel *RolePB) { - pbModel = &RolePB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = goModel.ID - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Keyword = goModel.Keyword - pbModel.Name = goModel.Name - pbModel.Description = goModel.Description - pbModel.Type = int32(goModel.Type) - pbModel.Sequence = int32(goModel.Sequence) - pbModel.Status = int32(goModel.Status) - for _, permission := range goModel.Edges.Permissions { - pbModel.PermissionIds = append(pbModel.PermissionIds, int64(permission.ID)) - } - pbModel.Permissions = ConvertPermissions(goModel.Edges.Permissions) - //pbModel.IsSystem = goModel.IsSystem - return pbModel -} - -// ConvertRolePB2Object role.table.comment -func ConvertRolePB2Object(pbModel *RolePB) (goModel *Role) { - goModel = &Role{} - if pbModel == nil { - return goModel - } - - goModel.ID = pbModel.Id - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Keyword = pbModel.Keyword - goModel.Name = pbModel.Name - goModel.Description = pbModel.Description - goModel.Type = int8(pbModel.Type) - goModel.Sequence = int(pbModel.Sequence) - goModel.Status = int8(pbModel.Status) - - //goModel.IsSystem = pbModel.IsSystem - return goModel -} - -type ( - Department = ent.Department - DepartmentPB = typespb.Department -) - -// ConvertDepartment2PB department.table.comment -func ConvertDepartment2PB(goModel *Department) (pbModel *DepartmentPB) { - pbModel = &DepartmentPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = goModel.ID - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Keyword = goModel.Keyword - pbModel.Name = goModel.Name - pbModel.Description = goModel.Description - pbModel.Sequence = int32(goModel.Sequence) - pbModel.Status = int32(goModel.Status) - pbModel.Level = int32(goModel.Level) - pbModel.ParentId = goModel.ParentID - return pbModel -} - -// ConvertDepartmentPB2Object department.table.comment -func ConvertDepartmentPB2Object(pbModel *DepartmentPB) (goModel *Department) { - goModel = &Department{} - if pbModel == nil { - return goModel - } - - goModel.ID = pbModel.Id - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Keyword = pbModel.Keyword - goModel.Name = pbModel.Name - goModel.TreePath = pbModel.TreePath - goModel.Description = pbModel.Description - goModel.Sequence = int(pbModel.Sequence) - goModel.Status = int8(pbModel.Status) - goModel.Level = int(pbModel.Level) - goModel.ParentID = pbModel.ParentId - return goModel -} +//go:abgen:package:path=origadmin/application/admin/internal/data/entity/ent,alias=ent +//go:abgen:package:path=origadmin/application/admin/api/v1/services/types,alias=types +//go:abgen:pair:packages="origadmin/application/admin/internal/data/entity/ent,origadmin/application/admin/api/v1/services/types" +//go:abgen:convert:source:suffix="" +//go:abgen:convert:target:suffix="PB" +//go:abgen:convert:direction="both" +//go:abgen:convert="source=ent.Resource,target=types.Menu" type ( - Departments = []*ent.Department - DepartmentsPB = []*typespb.Department + Gender = user.Gender ) - -// ConvertDepartments2PB Children holds the value of the children edge. -func ConvertDepartments2PB(gosModel Departments) (pbsModel DepartmentsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertDepartment2PB(model)) - } - return pbsModel -} - -// ConvertDepartmentsPB2Object Children holds the value of the children edge. -func ConvertDepartmentsPB2Object(pbsModel DepartmentsPB) (gosModel Departments) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertDepartmentPB2Object(model)) - } - return gosModel -} - -type ( - UserDepartments = []*ent.UserDepartment - UserDepartmentsPB = []*typespb.UserDepartment -) - -// ConvertUserDepartments2PB UserDepartments holds the value of the user_departments edge. -func ConvertUserDepartments2PB(gosModel UserDepartments) (pbsModel UserDepartmentsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertUserDepartment2PB(model)) - } - return pbsModel -} - -// ConvertUserDepartmentsPB2Object UserDepartments holds the value of the user_departments edge. -func ConvertUserDepartmentsPB2Object(pbsModel UserDepartmentsPB) (gosModel UserDepartments) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertUserDepartmentPB2Object(model)) - } - return gosModel -} - -type ( - DepartmentEdges = ent.DepartmentEdges - DepartmentEdgesPB = typespb.DepartmentEdges -) - -// ConvertDepartmentEdges2PB DepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertDepartmentEdges2PB(goModel *DepartmentEdges) (pbModel *DepartmentEdgesPB) { - pbModel = &DepartmentEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Users = ConvertUsers2PB(goModel.Users) - pbModel.Positions = ConvertPositions2PB(goModel.Positions) - pbModel.Children = ConvertDepartments2PB(goModel.Children) - pbModel.Parent = ConvertDepartment2PB(goModel.Parent) - pbModel.UserDepartments = ConvertUserDepartments2PB(goModel.UserDepartments) - return pbModel -} - -// ConvertDepartmentEdgesPB2Object DepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertDepartmentEdgesPB2Object(pbModel *DepartmentEdgesPB) (goModel *DepartmentEdges) { - goModel = &DepartmentEdges{} - if pbModel == nil { - return goModel - } - - goModel.Users = ConvertUsersPB2Object(pbModel.Users) - goModel.Positions = ConvertPositionsPB2Object(pbModel.Positions) - goModel.Children = ConvertDepartmentsPB2Object(pbModel.Children) - goModel.Parent = ConvertDepartmentPB2Object(pbModel.Parent) - goModel.UserDepartments = ConvertUserDepartmentsPB2Object(pbModel.UserDepartments) - return goModel -} - -type ( - UserDepartment = ent.UserDepartment - UserDepartmentPB = typespb.UserDepartment -) - -// ConvertUserDepartment2PB user_department.table.comment -func ConvertUserDepartment2PB(goModel *UserDepartment) (pbModel *UserDepartmentPB) { - pbModel = &UserDepartmentPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.UserId = int64(goModel.UserID) - pbModel.DepartmentId = int64(goModel.DepartmentID) - return pbModel -} - -// ConvertUserDepartmentPB2Object user_department.table.comment -func ConvertUserDepartmentPB2Object(pbModel *UserDepartmentPB) (goModel *UserDepartment) { - goModel = &UserDepartment{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.UserID = int64(pbModel.UserId) - goModel.DepartmentID = int64(pbModel.DepartmentId) - return goModel -} - -type ( - UserDepartmentEdges = ent.UserDepartmentEdges - UserDepartmentEdgesPB = typespb.UserDepartmentEdges -) - -// ConvertUserDepartmentEdges2PB UserDepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertUserDepartmentEdges2PB(goModel *UserDepartmentEdges) (pbModel *UserDepartmentEdgesPB) { - pbModel = &UserDepartmentEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.User = ConvertUser2PB(goModel.User) - pbModel.Department = ConvertDepartment2PB(goModel.Department) - return pbModel -} - -// ConvertUserDepartmentEdgesPB2Object UserDepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertUserDepartmentEdgesPB2Object(pbModel *UserDepartmentEdgesPB) (goModel *UserDepartmentEdges) { - goModel = &UserDepartmentEdges{} - if pbModel == nil { - return goModel - } - - goModel.User = ConvertUserPB2Object(pbModel.User) - goModel.Department = ConvertDepartmentPB2Object(pbModel.Department) - return goModel -} - -type ( - Position = ent.Position - PositionPB = typespb.Position -) - -// ConvertPosition2PB position.table.comment -func ConvertPosition2PB(goModel *Position) (pbModel *PositionPB) { - pbModel = &PositionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Name = goModel.Name - pbModel.Description = goModel.Description - pbModel.DepartmentId = int64(goModel.DepartmentID) - return pbModel -} - -// ConvertPositionPB2Object position.table.comment -func ConvertPositionPB2Object(pbModel *PositionPB) (goModel *Position) { - goModel = &Position{} - if pbModel == nil { - return goModel - } - - goModel.ID = int64(pbModel.Id) - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Name = pbModel.Name - goModel.Description = pbModel.Description - goModel.DepartmentID = int64(pbModel.DepartmentId) - return goModel -} - -type ( - Users = []*ent.User - UsersPB = []*typespb.User -) - -// ConvertUsers2PB Users holds the value of the users edge. -func ConvertUsers2PB(gosModel Users) (pbsModel UsersPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertUser2PB(model)) - } - return pbsModel -} - -// ConvertUsersPB2Object Users holds the value of the users edge. -func ConvertUsersPB2Object(pbsModel UsersPB) (gosModel Users) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertUserPB2Object(model)) - } - return gosModel -} - -type ( - Permissions = []*ent.Permission - PermissionsPB = []*typespb.Permission -) - -// ConvertPermissions2PB Permissions holds the value of the permissions edge. -func ConvertPermissions2PB(gosModel Permissions) (pbsModel PermissionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPermission2PB(model)) - } - return pbsModel -} - -// ConvertPermissionsPB2Object Permissions holds the value of the permissions edge. -func ConvertPermissionsPB2Object(pbsModel PermissionsPB) (gosModel Permissions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPermissionPB2Object(model)) - } - return gosModel -} - -type ( - UserPositions = []*ent.UserPosition - UserPositionsPB = []*typespb.UserPosition -) - -// ConvertUserPositions2PB UserPositions holds the value of the user_positions edge. -func ConvertUserPositions2PB(gosModel UserPositions) (pbsModel UserPositionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertUserPosition2PB(model)) - } - return pbsModel -} - -// ConvertUserPositionsPB2Object UserPositions holds the value of the user_positions edge. -func ConvertUserPositionsPB2Object(pbsModel UserPositionsPB) (gosModel UserPositions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertUserPositionPB2Object(model)) - } - return gosModel -} - -type ( - PositionEdges = ent.PositionEdges - PositionEdgesPB = typespb.PositionEdges -) - -// ConvertPositionEdges2PB PositionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionEdges2PB(goModel *PositionEdges) (pbModel *PositionEdgesPB) { - pbModel = &PositionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Department = ConvertDepartment2PB(goModel.Department) - pbModel.Users = ConvertUsers2PB(goModel.Users) - pbModel.Permissions = ConvertPermissions2PB(goModel.Permissions) - pbModel.UserPositions = ConvertUserPositions2PB(goModel.UserPositions) - pbModel.PositionPermissions = ConvertPositionPermissions2PB(goModel.PositionPermissions) - return pbModel -} - -// ConvertPositionEdgesPB2Object PositionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionEdgesPB2Object(pbModel *PositionEdgesPB) (goModel *PositionEdges) { - goModel = &PositionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Department = ConvertDepartmentPB2Object(pbModel.Department) - goModel.Users = ConvertUsersPB2Object(pbModel.Users) - goModel.Permissions = ConvertPermissionsPB2Object(pbModel.Permissions) - goModel.UserPositions = ConvertUserPositionsPB2Object(pbModel.UserPositions) - goModel.PositionPermissions = ConvertPositionPermissionsPB2Object(pbModel.PositionPermissions) - return goModel -} - -// ConvertDataRules2PB permission.field.data_rules -func ConvertDataRules2PB(gosModel map[string]string) map[string]string { - return gosModel -} - -// ConvertDataRulesPB2Object permission.field.data_rules -func ConvertDataRulesPB2Object(pbsModel map[string]string) map[string]string { - return pbsModel -} - -type ( - Permission = ent.Permission - PermissionPB = typespb.Permission -) - -// ConvertPermission2PB permission.table.comment -func ConvertPermission2PB(goModel *Permission) (pbModel *PermissionPB) { - pbModel = &PermissionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Name = goModel.Name - pbModel.Keyword = goModel.Keyword - pbModel.Description = goModel.Description - pbModel.DataScope = goModel.DataScope - pbModel.DataRules = ConvertDataRules2PB(goModel.DataRules) - for _, resource := range goModel.Edges.Resources { - pbModel.ResourceIds = append(pbModel.ResourceIds, resource.ID) - } - pbModel.Resources = ConvertResources2PB(goModel.Edges.Resources) - return pbModel -} - -// ConvertPermissionPB2Object permission.table.comment -func ConvertPermissionPB2Object(pbModel *PermissionPB) (goModel *Permission) { - goModel = &Permission{} - if pbModel == nil { - return goModel - } - - goModel.ID = int64(pbModel.Id) - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Name = pbModel.Name - goModel.Keyword = pbModel.Keyword - goModel.Description = pbModel.Description - goModel.DataScope = pbModel.DataScope - goModel.DataRules = ConvertDataRulesPB2Object(pbModel.DataRules) - return goModel -} - -type ( - Roles = []*ent.Role - RolesPB = []*typespb.Role -) - -// ConvertRoles2PB Roles holds the value of the roles edge. -func ConvertRoles2PB(gosModel Roles) (pbsModel RolesPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertRole2PB(model)) - } - return pbsModel -} - -// ConvertRolesPB2Object Roles holds the value of the roles edge. -func ConvertRolesPB2Object(pbsModel RolesPB) (gosModel Roles) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertRolePB2Object(model)) - } - return gosModel -} - -type ( - Resources = []*ent.Resource - ResourcesPB = []*typespb.Resource -) - -// ConvertResources2PB Resources holds the value of the resources edge. -func ConvertResources2PB(gosModel Resources) (pbsModel ResourcesPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertResource2PB(model)) - } - return pbsModel -} - -// ConvertResourcesPB2Object Resources holds the value of the resources edge. -func ConvertResourcesPB2Object(pbsModel ResourcesPB) (gosModel Resources) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertResourcePB2Object(model)) - } - return gosModel -} - -type ( - Positions = []*ent.Position - PositionsPB = []*typespb.Position -) - -// ConvertPositions2PB Positions holds the value of the positions edge. -func ConvertPositions2PB(gosModel Positions) (pbsModel PositionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPosition2PB(model)) - } - return pbsModel -} - -// ConvertPositionsPB2Object Positions holds the value of the positions edge. -func ConvertPositionsPB2Object(pbsModel PositionsPB) (gosModel Positions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPositionPB2Object(model)) - } - return gosModel -} - -type ( - RolePermissions = []*ent.RolePermission - RolePermissionsPB = []*typespb.RolePermission -) - -// ConvertRolePermissions2PB RolePermissions holds the value of the role_permissions edge. -func ConvertRolePermissions2PB(gosModel RolePermissions) (pbsModel RolePermissionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertRolePermission2PB(model)) - } - return pbsModel -} - -// ConvertRolePermissionsPB2Object RolePermissions holds the value of the role_permissions edge. -func ConvertRolePermissionsPB2Object(pbsModel RolePermissionsPB) (gosModel RolePermissions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertRolePermissionPB2Object(model)) - } - return gosModel -} - -type ( - PermissionResources = []*ent.PermissionResource - PermissionResourcesPB = []*typespb.PermissionResource -) - -// ConvertPermissionResources2PB PermissionResources holds the value of the permission_resources edge. -func ConvertPermissionResources2PB(gosModel PermissionResources) (pbsModel PermissionResourcesPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPermissionResource2PB(model)) - } - return pbsModel -} - -// ConvertPermissionResourcesPB2Object PermissionResources holds the value of the permission_resources edge. -func ConvertPermissionResourcesPB2Object(pbsModel PermissionResourcesPB) (gosModel PermissionResources) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPermissionResourcePB2Object(model)) - } - return gosModel -} - -type ( - PositionPermissions = []*ent.PositionPermission - PositionPermissionsPB = []*typespb.PositionPermission -) - -// ConvertPositionPermissions2PB PositionPermissions holds the value of the position_permissions edge. -func ConvertPositionPermissions2PB(gosModel PositionPermissions) (pbsModel PositionPermissionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPositionPermission2PB(model)) - } - return pbsModel -} - -// ConvertPositionPermissionsPB2Object PositionPermissions holds the value of the position_permissions edge. -func ConvertPositionPermissionsPB2Object(pbsModel PositionPermissionsPB) (gosModel PositionPermissions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPositionPermissionPB2Object(model)) - } - return gosModel -} - -type ( - PermissionEdges = ent.PermissionEdges - PermissionEdgesPB = typespb.PermissionEdges -) - -// ConvertPermissionEdges2PB PermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionEdges2PB(goModel *PermissionEdges) (pbModel *PermissionEdgesPB) { - pbModel = &PermissionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Roles = ConvertRoles2PB(goModel.Roles) - pbModel.Resources = ConvertResources2PB(goModel.Resources) - pbModel.Positions = ConvertPositions2PB(goModel.Positions) - pbModel.RolePermissions = ConvertRolePermissions2PB(goModel.RolePermissions) - pbModel.PermissionResources = ConvertPermissionResources2PB(goModel.PermissionResources) - pbModel.PositionPermissions = ConvertPositionPermissions2PB(goModel.PositionPermissions) - return pbModel -} - -// ConvertPermissionEdgesPB2Object PermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionEdgesPB2Object(pbModel *PermissionEdgesPB) (goModel *PermissionEdges) { - goModel = &PermissionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Roles = ConvertRolesPB2Object(pbModel.Roles) - goModel.Resources = ConvertResourcesPB2Object(pbModel.Resources) - goModel.Positions = ConvertPositionsPB2Object(pbModel.Positions) - goModel.RolePermissions = ConvertRolePermissionsPB2Object(pbModel.RolePermissions) - goModel.PermissionResources = ConvertPermissionResourcesPB2Object(pbModel.PermissionResources) - goModel.PositionPermissions = ConvertPositionPermissionsPB2Object(pbModel.PositionPermissions) - return goModel -} - -type ( - UserPosition = ent.UserPosition - UserPositionPB = typespb.UserPosition -) - -// ConvertUserPosition2PB user_position.table.comment -func ConvertUserPosition2PB(goModel *UserPosition) (pbModel *UserPositionPB) { - pbModel = &UserPositionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.UserId = int64(goModel.UserID) - pbModel.PositionId = int64(goModel.PositionID) - return pbModel -} - -// ConvertUserPositionPB2Object user_position.table.comment -func ConvertUserPositionPB2Object(pbModel *UserPositionPB) (goModel *UserPosition) { - goModel = &UserPosition{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.UserID = int64(pbModel.UserId) - goModel.PositionID = int64(pbModel.PositionId) - return goModel -} - -type ( - UserPositionEdges = ent.UserPositionEdges - UserPositionEdgesPB = typespb.UserPositionEdges -) - -// ConvertUserPositionEdges2PB UserPositionEdges holds the relations/edges for other nodes in the graph. -func ConvertUserPositionEdges2PB(goModel *UserPositionEdges) (pbModel *UserPositionEdgesPB) { - pbModel = &UserPositionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.User = ConvertUser2PB(goModel.User) - pbModel.Position = ConvertPosition2PB(goModel.Position) - return pbModel -} - -// ConvertUserPositionEdgesPB2Object UserPositionEdges holds the relations/edges for other nodes in the graph. -func ConvertUserPositionEdgesPB2Object(pbModel *UserPositionEdgesPB) (goModel *UserPositionEdges) { - goModel = &UserPositionEdges{} - if pbModel == nil { - return goModel - } - - goModel.User = ConvertUserPB2Object(pbModel.User) - goModel.Position = ConvertPositionPB2Object(pbModel.Position) - return goModel -} - -type ( - PositionPermission = ent.PositionPermission - PositionPermissionPB = typespb.PositionPermission -) - -// ConvertPositionPermission2PB position_permission.table.comment -func ConvertPositionPermission2PB(goModel *PositionPermission) (pbModel *PositionPermissionPB) { - pbModel = &PositionPermissionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.PositionId = int64(goModel.PositionID) - pbModel.PermissionId = int64(goModel.PermissionID) - return pbModel -} - -// ConvertPositionPermissionPB2Object position_permission.table.comment -func ConvertPositionPermissionPB2Object(pbModel *PositionPermissionPB) (goModel *PositionPermission) { - goModel = &PositionPermission{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.PositionID = int64(pbModel.PositionId) - goModel.PermissionID = int64(pbModel.PermissionId) - return goModel -} - -type ( - PositionPermissionEdges = ent.PositionPermissionEdges - PositionPermissionEdgesPB = typespb.PositionPermissionEdges -) - -// ConvertPositionPermissionEdges2PB PositionPermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionPermissionEdges2PB(goModel *PositionPermissionEdges) (pbModel *PositionPermissionEdgesPB) { - pbModel = &PositionPermissionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Position = ConvertPosition2PB(goModel.Position) - pbModel.Permission = ConvertPermission2PB(goModel.Permission) - return pbModel -} - -// ConvertPositionPermissionEdgesPB2Object PositionPermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionPermissionEdgesPB2Object(pbModel *PositionPermissionEdgesPB) (goModel *PositionPermissionEdges) { - goModel = &PositionPermissionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Position = ConvertPositionPB2Object(pbModel.Position) - goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) - return goModel -} - -type ( - RolePermission = ent.RolePermission - RolePermissionPB = typespb.RolePermission -) - -// ConvertRolePermission2PB role_permission.table.comment -func ConvertRolePermission2PB(goModel *RolePermission) (pbModel *RolePermissionPB) { - pbModel = &RolePermissionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.RoleId = int64(goModel.RoleID) - pbModel.PermissionId = int64(goModel.PermissionID) - return pbModel -} - -// ConvertRolePermissionPB2Object role_permission.table.comment -func ConvertRolePermissionPB2Object(pbModel *RolePermissionPB) (goModel *RolePermission) { - goModel = &RolePermission{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.RoleID = int64(pbModel.RoleId) - goModel.PermissionID = int64(pbModel.PermissionId) - return goModel -} - -type ( - RolePermissionEdges = ent.RolePermissionEdges - RolePermissionEdgesPB = typespb.RolePermissionEdges -) - -// ConvertRolePermissionEdges2PB RolePermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertRolePermissionEdges2PB(goModel *RolePermissionEdges) (pbModel *RolePermissionEdgesPB) { - pbModel = &RolePermissionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Role = ConvertRole2PB(goModel.Role) - pbModel.Permission = ConvertPermission2PB(goModel.Permission) - return pbModel -} - -// ConvertRolePermissionEdgesPB2Object RolePermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertRolePermissionEdgesPB2Object(pbModel *RolePermissionEdgesPB) (goModel *RolePermissionEdges) { - goModel = &RolePermissionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Role = ConvertRolePB2Object(pbModel.Role) - goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) - return goModel -} - -type ( - PermissionResource = ent.PermissionResource - PermissionResourcePB = typespb.PermissionResource -) - -// ConvertPermissionResource2PB permission_resource.table.comment -func ConvertPermissionResource2PB(goModel *PermissionResource) (pbModel *PermissionResourcePB) { - pbModel = &PermissionResourcePB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.PermissionId = int64(goModel.PermissionID) - pbModel.ResourceId = int64(goModel.ResourceID) - //pbModel.Actions = goModel.Actions - return pbModel -} - -// ConvertPermissionResourcePB2Object permission_resource.table.comment -func ConvertPermissionResourcePB2Object(pbModel *PermissionResourcePB) (goModel *PermissionResource) { - goModel = &PermissionResource{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.PermissionID = int64(pbModel.PermissionId) - goModel.ResourceID = int64(pbModel.ResourceId) - //goModel.Actions = pbModel.Actions - return goModel -} - -type ( - PermissionResourceEdges = ent.PermissionResourceEdges - PermissionResourceEdgesPB = typespb.PermissionResourceEdges -) - -// ConvertPermissionResourceEdges2PB PermissionResourceEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionResourceEdges2PB(goModel *PermissionResourceEdges) (pbModel *PermissionResourceEdgesPB) { - pbModel = &PermissionResourceEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Permission = ConvertPermission2PB(goModel.Permission) - pbModel.Resource = ConvertResource2PB(goModel.Resource) - return pbModel -} - -// ConvertPermissionResourceEdgesPB2Object PermissionResourceEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionResourceEdgesPB2Object(pbModel *PermissionResourceEdgesPB) (goModel *PermissionResourceEdges) { - goModel = &PermissionResourceEdges{} - if pbModel == nil { - return goModel - } - - goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) - goModel.Resource = ConvertResourcePB2Object(pbModel.Resource) - return goModel -} diff --git a/internal/features/system/dto/menu.go b/internal/features/system/dto/menu.go index 9568d083..74ca23bb 100644 --- a/internal/features/system/dto/menu.go +++ b/internal/features/system/dto/menu.go @@ -6,7 +6,9 @@ package dto import ( - "github.com/origadmin/runtime/interfaces/pagination" + "context" + + "origadmin/application/admin/internal/helpers/pagination" pb "origadmin/application/admin/api/v1/services/system" ) @@ -18,11 +20,11 @@ type ( // MenuRepo is a Menu repository interface. type MenuRepo interface { - //Get(context.Context, int64, ...MenuQueryOption) (*MenuPB, error) - //Create(context.Context, *MenuPB, ...MenuQueryOption) (*MenuPB, error) - //Delete(context.Context, int64) error - //Update(context.Context, *MenuPB, ...MenuQueryOption) (*MenuPB, error) - //List(context.Context, *ListMenusRequest, ...MenuQueryOption) ([]*MenuPB, int32, error) + Get(context.Context, int64, ...MenuQueryOption) (*MenuPB, error) + Create(context.Context, *MenuPB, ...MenuQueryOption) (*MenuPB, error) + Delete(context.Context, int64) error + Update(context.Context, *MenuPB, ...MenuQueryOption) (*MenuPB, error) + List(context.Context, *ListMenusRequest, ...MenuQueryOption) ([]*MenuPB, int32, error) } type MenuQueryOption struct { diff --git a/internal/features/system/dto/permission.go b/internal/features/system/dto/permission.go index 39dd6487..c27ffb89 100644 --- a/internal/features/system/dto/permission.go +++ b/internal/features/system/dto/permission.go @@ -8,10 +8,9 @@ package dto import ( "context" - "github.com/origadmin/runtime/interfaces/pagination" + "origadmin/application/admin/internal/helpers/pagination" // Corrected import path pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/resp" ) type ( @@ -49,35 +48,16 @@ type PermissionQueryOption struct { IncludeRoles bool } -func (o PermissionQueryOption) FromListRequest(in *ListPermissionsRequest, limiter pagination.PageLimiter) error { +func (o PermissionQueryOption) FromListRequest(in *ListPermissionsRequest, limiter pagination.PageLimiter) error { // Updated usage in.Current = limiter.Current(in.Current) in.PageSize = limiter.PerPage(in.PageSize) return nil } -func (o PermissionQueryOption) FromGetRequest(in *pb.GetPermissionRequest, limiter pagination.PageLimiter) error { +func (o PermissionQueryOption) FromGetRequest(in *pb.GetPermissionRequest, limiter pagination.PageLimiter) error { // Updated usage return nil } -func (o PermissionQueryOption) FromCreateRequest(in *pb.CreatePermissionRequest, limiter pagination.PageLimiter) error { +func (o PermissionQueryOption) FromCreateRequest(in *pb.CreatePermissionRequest, limiter pagination.PageLimiter) error { // Updated usage return nil } - -func ToListPermissionsResponse(result []*PermissionPB, in *ListPermissionsRequest, total int32, args ...any) (*ListPermissionsResponse, error) { - response := &ListPermissionsResponse{ - TotalSize: total, - Current: in.Current, - PageSize: in.PageSize, - Permissions: result, - Extra: resp.Any(args...), - } - return response, nil -} - -func ConvertPermissions(permissions []*Permission) []*PermissionPB { - var result []*PermissionPB - for _, permission := range permissions { - result = append(result, ConvertPermission2PB(permission)) - } - return result -} diff --git a/internal/features/system/dto/resource.go b/internal/features/system/dto/resource.go index 74a0c30a..6e25caeb 100644 --- a/internal/features/system/dto/resource.go +++ b/internal/features/system/dto/resource.go @@ -8,10 +8,9 @@ package dto import ( "context" - "github.com/origadmin/runtime/interfaces/pagination" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/resp" + "origadmin/application/admin/internal/helpers/pagination" + "origadmin/application/admin/internal/helpers/resp" ) type ( @@ -34,32 +33,32 @@ type ResourceRepo interface { } type ResourceQueryOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - InIDs []string `form:"-" json:"-"` - UserID string `form:"-" json:"-"` // UserPB ID - RoleID string `form:"-" json:"-"` // RolePB ID - ParentID string `form:"-" json:"-"` // Parent ID - ParentPathPrefix string `form:"-" json:"-"` - IncludeResources bool `form:"-" json:"-"` // Include resources - IncludePermissions bool `form:"-" json:"-"` + Name string `form:"name" json:"name,omitempty"` + Status int8 `form:"status" json:"status,omitempty"` + InIDs []int64 `form:"-" json:"-"` + UserID string `form:"-" json:"-"` // UserPB ID + RoleID string `form:"-" json:"-"` // RolePB ID + ParentID int64 `form:"-" json:"-"` // Parent ID + ParentPathPrefix string `form:"-" json:"-"` + IncludeResources bool `form:"-" json:"-"` // Include resources + IncludePermissions bool `form:"-" json:"-"` SelectFields []string OmitFields []string OrderFields []string Fields []string } -func (o ResourceQueryOption) FromListRequest(in *ListResourcesRequest, limiter pagination.PageLimiter) error { +func (o ResourceQueryOption) FromListRequest(in *ListResourcesRequest, limiter pagination.PageLimiter) error { // Updated usage in.Current = limiter.Current(in.Current) in.PageSize = limiter.PerPage(in.PageSize) return nil } -func (o ResourceQueryOption) FromGetRequest(in *pb.GetResourceRequest, limiter pagination.PageLimiter) error { +func (o ResourceQueryOption) FromGetRequest(in *pb.GetResourceRequest, limiter pagination.PageLimiter) error { // Updated usage return nil } -func (o ResourceQueryOption) FromCreateRequest(in *pb.CreateResourceRequest, limiter pagination.PageLimiter) error { +func (o ResourceQueryOption) FromCreateRequest(in *pb.CreateResourceRequest, limiter pagination.PageLimiter) error { // Updated usage return nil } @@ -73,11 +72,3 @@ func ToListResourcesResponse(result []*ResourcePB, in *ListResourcesRequest, tot } return response, nil } - -func ConvertResources(resources []*Resource) []*ResourcePB { - var result []*ResourcePB - for _, resource := range resources { - result = append(result, ConvertResource2PB(resource)) - } - return result -} diff --git a/internal/features/system/dto/role.go b/internal/features/system/dto/role.go index 0ddbc33c..ea532c0a 100644 --- a/internal/features/system/dto/role.go +++ b/internal/features/system/dto/role.go @@ -9,19 +9,14 @@ import ( "context" "time" - "github.com/origadmin/runtime/interfaces/pagination" "google.golang.org/protobuf/proto" pb "origadmin/application/admin/api/v1/services/system" - typespb "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/helpers/resp" - "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/helpers/pagination" + "origadmin/application/admin/internal/helpers/resp" ) type ( - RoleEdges = ent.RoleEdges - RoleEdgesPB = typespb.RoleEdges - ListRolesRequest = pb.ListRolesRequest ListRolesResponse = pb.ListRolesResponse ) @@ -47,17 +42,17 @@ type RoleQueryOption struct { IncludePermissions bool } -func (o RoleQueryOption) FromListRequest(in *ListRolesRequest, limiter pagination.PageLimiter) error { +func (o RoleQueryOption) FromListRequest(in *ListRolesRequest, limiter pagination.PageLimiter) error { // Updated usage in.Current = limiter.Current(in.Current) in.PageSize = limiter.PerPage(in.PageSize) return nil } -func (o RoleQueryOption) FromGetRequest(in *pb.GetRoleRequest, limiter pagination.PageLimiter) error { +func (o RoleQueryOption) FromGetRequest(in *pb.GetRoleRequest, limiter pagination.PageLimiter) error { // Updated usage return nil } -func (o RoleQueryOption) FromCreateRequest(in *pb.CreateRoleRequest, limiter pagination.PageLimiter) error { +func (o RoleQueryOption) FromCreateRequest(in *pb.CreateRoleRequest, limiter pagination.PageLimiter) error { // Updated usage return nil } @@ -92,14 +87,6 @@ func ToListRolesResponse(result []*RolePB, in *ListRolesRequest, total int32, ar return response, nil } -func ConvertRoles(roles []*Role) []*RolePB { - var result []*RolePB - for _, role := range roles { - result = append(result, ConvertRole2PB(role)) - } - return result -} - type RoleQueryResult struct { Current int `json:"current"` PageSize int `json:"page_size"` diff --git a/internal/features/system/dto/user.go b/internal/features/system/dto/user.go index b9eb649b..509b9372 100644 --- a/internal/features/system/dto/user.go +++ b/internal/features/system/dto/user.go @@ -8,25 +8,19 @@ package dto import ( "context" + "github.com/goexts/generic/must" "github.com/google/uuid" - "github.com/origadmin/runtime/interfaces/pagination" + "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/rand" + "github.com/origadmin/toolkits/identifier" + "origadmin/application/admin/internal/helpers/pagination" // Corrected import path pb "origadmin/application/admin/api/v1/services/system" - typespb "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/helpers/id" - "origadmin/application/admin/helpers/resp" - "origadmin/application/admin/internal/data/entity/ent" ) type ( - UserRole = ent.UserRole - UserRolePB = typespb.UserRole - UserRoleEdges = ent.UserRoleEdges - UserRoleEdgesPB = typespb.UserRoleEdges - ListUsersRequest = pb.ListUsersRequest ListUsersResponse = pb.ListUsersResponse ) @@ -71,41 +65,21 @@ type UserQueryOption struct { Fields []string } -func (o *UserQueryOption) FromListRequest(in *ListUsersRequest, limiter pagination.PageLimiter) error { +func (o *UserQueryOption) FromListRequest(in *ListUsersRequest, limiter pagination.PageLimiter) error { // Updated usage in.Current = limiter.Current(in.Current) in.PageSize = limiter.PerPage(in.PageSize) return nil } -func (o *UserQueryOption) FromGetRequest(in *pb.GetUserRequest, limiter pagination.PageLimiter) error { +func (o *UserQueryOption) FromGetRequest(in *pb.GetUserRequest, limiter pagination.PageLimiter) error { // Updated usage return nil } -func (o *UserMutationOption) FromCreateRequest(in *pb.CreateUserRequest, limiter pagination.PageLimiter) error { +func (o *UserMutationOption) FromCreateRequest(in *pb.CreateUserRequest, limiter pagination.PageLimiter) error { // Updated usage o.RandomPasswd = in.RandomPassword return nil } -func ToListUsersResponse(result []*UserPB, in *ListUsersRequest, total int32, args ...any) (*ListUsersResponse, error) { - response := &ListUsersResponse{ - TotalSize: total, - Current: in.Current, - PageSize: in.PageSize, - Users: result, - Extra: resp.Any(args...), - } - - return response, nil -} - -func ConvertUsers(users []*User) []*UserPB { - var result []*UserPB - for _, user := range users { - result = append(result, ConvertUser2PB(user)) - } - return result -} - // MakeCreateUser functions are used to create new users func MakeCreateUser(user *UserPB, username, password string, option UserMutationOption) (*UserPB, string, error) { log.Debugf("Creating user with options: %+v", option) @@ -113,8 +87,13 @@ func MakeCreateUser(user *UserPB, username, password string, option UserMutation log.Debugf("NoPasswd is false, checking for RandomPasswd") if option.RandomPasswd && (user.Email != "" || user.Phone != "") { log.Debugf("RandomPasswd is true and user has email or phone, generating random password") - password = rand.GenerateRandom(8) - log.Debugf("Generated random password: %s", password) + pwd, err := rand.RandomString(8) + if err != nil { + log.Errorf("Error generating random password: %v", err) + return nil, "", err + } + log.Debugf("Generated random password: %s", pwd) + password = pwd } else { log.Debugf("RandomPasswd is false or user has no email or phone") } @@ -134,13 +113,11 @@ func MakeCreateUser(user *UserPB, username, password string, option UserMutation } log.Debugf("Generated password hash: %s", user.Password) } - registerID := id.Gen() + registerID := identifier.GenerateNumber() user.Id = registerID user.Uuid = uuid.Must(uuid.NewRandom()).String() user.Username = username - user.Name = "user_" + random.RandString(8) + user.Name = "user_" + must.Do(rand.RandomString(8)) user.Status = 1 return user, password, nil } - -var random = rand.NewRand(rand.KindDigit | rand.KindLowerCase | rand.KindUpperCase) diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index 1fc8a7bd..d622908c 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -11,15 +11,15 @@ import ( "github.com/origadmin/runtime" configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/context" + "github.com/origadmin/runtime/errors" // Changed from toolkits/errors "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/middleware" "github.com/origadmin/runtime/service" servicegrpc "github.com/origadmin/runtime/service/grpc" servicehttp "github.com/origadmin/runtime/service/http" - "github.com/origadmin/toolkits/errors" "origadmin/application/admin/internal/configs" - systemservice "origadmin/application/admin/internal/mods/system/service" + systemservice "origadmin/application/admin/internal/features/system/service" ) const ( diff --git a/internal/features/system/service/permission.grpc.go b/internal/features/system/service/permission.grpc.go index 5a4d716c..f8473a5e 100644 --- a/internal/features/system/service/permission.grpc.go +++ b/internal/features/system/service/permission.grpc.go @@ -10,7 +10,7 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + "origadmin/application/admin/internal/features/system/biz" // Corrected import path ) // PermissionServiceServer is a menu service. diff --git a/internal/features/system/service/permission.http.go b/internal/features/system/service/permission.http.go index e16657f0..545ab348 100644 --- a/internal/features/system/service/permission.http.go +++ b/internal/features/system/service/permission.http.go @@ -10,7 +10,7 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + "origadmin/application/admin/internal/features/system/biz" // Corrected import path ) // PermissionServiceHTTPServer is a menu service. diff --git a/internal/features/system/service/resource.grpc.go b/internal/features/system/service/resource.grpc.go index dc570f60..75ab8a57 100644 --- a/internal/features/system/service/resource.grpc.go +++ b/internal/features/system/service/resource.grpc.go @@ -10,7 +10,7 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + "origadmin/application/admin/internal/features/system/biz" // Corrected import path ) // ResourceServiceServer is a menu service. diff --git a/internal/features/system/service/role.grpc.go b/internal/features/system/service/role.grpc.go index 8bc01690..447be76f 100644 --- a/internal/features/system/service/role.grpc.go +++ b/internal/features/system/service/role.grpc.go @@ -11,7 +11,7 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + "origadmin/application/admin/internal/features/system/biz" // Corrected import path ) type RoleServiceServer struct { diff --git a/internal/features/system/service/user.grpc.go b/internal/features/system/service/user.grpc.go index 9a50871e..e8984b66 100644 --- a/internal/features/system/service/user.grpc.go +++ b/internal/features/system/service/user.grpc.go @@ -11,7 +11,7 @@ import ( "github.com/origadmin/runtime/log" pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/mods/system/biz" + "origadmin/application/admin/internal/features/system/biz" // Corrected import path ) type UserServiceServer struct { diff --git a/internal/generate.go b/internal/generate.go deleted file mode 100644 index 6869ff47..00000000 --- a/internal/generate.go +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package internal - -//generate helloworld proto file -// if you want to generate the client code to the same directory, please use the following command -////go:generate kratos proto client -p=../toolkits -p=../third_party ./conf/*.proto - -//=paths=source_relative:. outputs to the same directory with the proto file - -// uncomment this line to generate the client code to the same directory -//go:generate protoc -I. -I../third_party --go_out=paths=source_relative:../internal ./conf/pb/*.proto -//go:generate protoc -I. -I../third_party --validate_out=paths=source_relative,lang=go:../internal ./conf/pb/*.proto diff --git a/internal/helpers/captcha/captcha.go b/internal/helpers/captcha/captcha.go index 518416f7..445200d8 100644 --- a/internal/helpers/captcha/captcha.go +++ b/internal/helpers/captcha/captcha.go @@ -9,13 +9,14 @@ import ( "net/http" "github.com/mojocn/base64Captcha" - "github.com/origadmin/toolkits/errors/httperr" + + "github.com/origadmin/runtime/errors" typespb "origadmin/application/admin/api/v1/services/types" ) var ( - ErrNotFound = httperr.New("http.response.status."+typespb.AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), http.StatusBadRequest, "captcha not found") + ErrNotFound = errors.New(400, typespb.AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), http.StatusBadRequest, "captcha not found") ) const ( diff --git a/internal/helpers/command/lower.go b/internal/helpers/command/lower.go deleted file mode 100644 index 8fca0477..00000000 --- a/internal/helpers/command/lower.go +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package command implements the functions, types, and interfaces for the module. -package command - -import ( - "strings" - - "github.com/spf13/cobra" -) - -func ToLower(cmd *cobra.Command) string { - return strings.ToLower(cmd.Root().Name()) -} diff --git a/internal/helpers/conf/bootstrap.go b/internal/helpers/conf/bootstrap.go new file mode 100644 index 00000000..a2947253 --- /dev/null +++ b/internal/helpers/conf/bootstrap.go @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package conf provides helper functions for application startup. +package conf + +import ( + "log" + "os" + "path/filepath" +) + +// FindConfPath searches for the configuration file in a prioritized order. +// +// It checks the following locations in order: +// 1. The path provided by the -conf flag. +// 2. Deployed environment: 'configs/bootstrap.yaml' or 'bootstrap.yaml' relative to the executable. +// 3. Development environment: './resources/configs/bootstrap.yaml' relative to the project root. +// +// The `flagPath` argument should be the value from a command-line flag. +// It returns the found path or an empty string if not found. +func FindConfPath(flagPath string) string { + // 1. Highest Priority: User-provided flag. + if flagPath != "" { + log.Printf("Using configuration from -conf flag: %s", flagPath) + return flagPath + } + + wd, _ := os.Getwd() + log.Printf("Current working directory: %s", wd) + + // 2. Second Priority: Deployed environment (relative to executable). + exec, err := os.Executable() + if err == nil { + execDir := filepath.Dir(exec) + deployPaths := []string{ + filepath.Join(execDir, "configs", "bootstrap.yaml"), + filepath.Join(execDir, "bootstrap.yaml"), + } + for _, p := range deployPaths { + if _, err := os.Stat(p); err == nil { + log.Printf("Found configuration in deployed environment: %s", p) + return p + } + } + } + + // 3. Lowest Priority: Development environment (relative to project root). + devPath := "./resources/configs/bootstrap.yaml" + if _, err := os.Stat(devPath); err == nil { + log.Printf("Found configuration in development environment: %s", devPath) + return devPath + } + + return "" // Not found +} diff --git a/internal/helpers/db/db.go b/internal/helpers/db/db.go index cb4039ca..790040e3 100644 --- a/internal/helpers/db/db.go +++ b/internal/helpers/db/db.go @@ -10,7 +10,8 @@ import ( "strings" "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime/interfaces/pagination" + + "origadmin/application/admin/internal/helpers/pagination" ) type Paginator[T any] interface { @@ -34,7 +35,13 @@ func Query[P Paginator[P]](query P, in pagination.PageRequest, paging bool) P { return QueryPage(query, in) } -func QueryNoPage[P Paginator[P]](query P, in pagination.PageSizeGetter) P { +type PageRequest interface { + GetPageSize() int32 + GetPageToken() string + GetCurrent() int32 +} + +func QueryNoPage[P Paginator[P]](query P, in PageRequest) P { pageSize := in.GetPageSize() if pageSize > 0 { query = query.Limit(int(pageSize)) @@ -43,14 +50,14 @@ func QueryNoPage[P Paginator[P]](query P, in pagination.PageSizeGetter) P { } func handleTokenPagination[P Paginator[P]](query P, token string) P { - // TODO: 实现游标分页逻辑 - // 示例伪代码: + // TODO: Implement cursor pagination logic + // Example pseudocode: // decodedToken := decodeToken(token) // query = query.Where(...).Order(...).Limit(...) return query } -func QueryPage[P Paginator[P]](query P, in pagination.PageRequest) P { +func QueryPage[P Paginator[P]](query P, in PageRequest) P { pageSize := in.GetPageSize() if pageSize > 0 { query = query.Limit(int(pageSize)) diff --git a/internal/helpers/ent/mixin/field.go b/internal/helpers/ent/mixin/field.go index 1d69f83d..d48cd186 100644 --- a/internal/helpers/ent/mixin/field.go +++ b/internal/helpers/ent/mixin/field.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect" "entgo.io/ent/schema/field" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/i18n" ) // ZeroTime represents the zero value for time.Time. diff --git a/internal/helpers/ent/mixin/mixin.go b/internal/helpers/ent/mixin/mixin.go index 296797fe..cc46849a 100644 --- a/internal/helpers/ent/mixin/mixin.go +++ b/internal/helpers/ent/mixin/mixin.go @@ -14,7 +14,7 @@ import ( "entgo.io/ent/schema/index" "entgo.io/ent/schema/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/i18n" ) type IDGenerator interface { diff --git a/internal/helpers/ent/mixin/mixin_id.go b/internal/helpers/ent/mixin/mixin_id.go index d2ce3b38..0cc9e162 100644 --- a/internal/helpers/ent/mixin/mixin_id.go +++ b/internal/helpers/ent/mixin/mixin_id.go @@ -11,8 +11,8 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/mixin" - "origadmin/application/admin/helpers/i18n" - "origadmin/application/admin/helpers/id" + "origadmin/application/admin/internal/helpers/i18n" + "origadmin/application/admin/internal/helpers/id" ) type ID struct { diff --git a/internal/helpers/ent/mixin/mixin_uuid.go b/internal/helpers/ent/mixin/mixin_uuid.go index 8ebfac24..32927d22 100644 --- a/internal/helpers/ent/mixin/mixin_uuid.go +++ b/internal/helpers/ent/mixin/mixin_uuid.go @@ -10,7 +10,7 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/mixin" - "origadmin/application/admin/helpers/i18n" + "origadmin/application/admin/internal/helpers/i18n" ) // UUID schema to include control and time fields. diff --git a/internal/helpers/resp/error.go b/internal/helpers/resp/error.go index d9105c29..62b539af 100644 --- a/internal/helpers/resp/error.go +++ b/internal/helpers/resp/error.go @@ -11,6 +11,7 @@ import ( "net/http" kerr "github.com/go-kratos/kratos/v2/errors" + "github.com/origadmin/runtime/log" ) diff --git a/internal/helpers/resp/marshal.go b/internal/helpers/resp/marshal.go index 97e8ca6a..2b41e265 100644 --- a/internal/helpers/resp/marshal.go +++ b/internal/helpers/resp/marshal.go @@ -14,7 +14,7 @@ import ( "google.golang.org/protobuf/types/known/structpb" "google.golang.org/protobuf/types/known/wrapperspb" - datav1 "origadmin/application/admin/helpers/resp/data/v1" + datav1 "origadmin/application/admin/internal/helpers/resp/data/v1" ) // Any converts the given arguments into a protobuf Any type. diff --git a/internal/helpers/resp/resp.go b/internal/helpers/resp/resp.go index 9c0f8aa5..0619a080 100644 --- a/internal/helpers/resp/resp.go +++ b/internal/helpers/resp/resp.go @@ -10,12 +10,13 @@ import ( "net/http" transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/origadmin/runtime/log" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" - datav1 "origadmin/application/admin/helpers/resp/data/v1" + "github.com/origadmin/runtime/log" + + datav1 "origadmin/application/admin/internal/helpers/resp/data/v1" ) const ( diff --git a/internal/helpers/resp/result.go b/internal/helpers/resp/result.go index 4ebaf9ea..9bfb4fd1 100644 --- a/internal/helpers/resp/result.go +++ b/internal/helpers/resp/result.go @@ -15,7 +15,7 @@ import ( "github.com/origadmin/toolkits/errors/httperr" "google.golang.org/protobuf/proto" - datav1 "origadmin/application/admin/helpers/resp/data/v1" + datav1 "origadmin/application/admin/internal/helpers/resp/data/v1" ) type Message interface { diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 056d91cd..005a6ae4 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -11,7 +11,7 @@ info: email: waitforadding@gmail.com license: name: MIT - url: https://github.com/origadmin/backend/blob/master/LICENSE + url: https://origadmin/application/admin/blob/master/LICENSE version: Version from annotation servers: - url: https://api.foo.com @@ -2984,7 +2984,7 @@ components: type: object properties: token: - $ref: '#/components/schemas/security.jwt.v1.Token' + $ref: '#/components/schemas/contrib.api.security.v1.TokenCredential' api.v1.services.auth.LogoutResponse: type: object properties: @@ -3041,7 +3041,7 @@ components: type: object properties: token: - $ref: '#/components/schemas/security.jwt.v1.Token' + $ref: '#/components/schemas/contrib.api.security.v1.TokenCredential' api.v1.services.auth.UpdatePersonalPasswordResponse: type: object properties: {} @@ -4084,6 +4084,22 @@ components: data: $ref: '#/components/schemas/api.v1.services.types.DataObject' description: UpdateUploadResponse is the response for the UploadService.UpdateUpload method. + contrib.api.security.v1.TokenCredential: + type: object + properties: + access_token: + type: string + description: The access token used for authentication. + refresh_token: + type: string + description: The refresh token used to obtain a new access token. + expires_in: + type: string + description: The remaining lifetime of the access token in seconds. + token_type: + type: string + description: The type of the token, typically 'Bearer'. + description: "TokenCredential holds the credentials for token-based authentication flows\r\n like OAuth2 and JWT.\r\n\r\n IMPORTANT: This message represents the full set of tokens typically returned\r\n from a token issuance endpoint (e.g., /login). It is designed for use in\r\n CredentialResponse." google.protobuf.Any: type: object properties: @@ -4108,25 +4124,6 @@ components: $ref: '#/components/schemas/google.protobuf.Any' description: A list of messages that carry the error details. There is a common set of message types for APIs to use. description: 'The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).' - security.jwt.v1.Token: - type: object - properties: - client_id: - type: string - description: The client ID associated with the token. - user_id: - type: string - description: The ID of the user associated with the token. - access_token: - type: string - description: The web access token used for authentication. - refresh_token: - type: string - description: The refresh token used to obtain a new access token. - expiration_time: - type: string - description: The expiration time of the token. - description: PWT is a web token that can be used to authenticate a user with protobuf services. securitySchemes: Basic: type: http diff --git a/test/token_test.go b/test/token_test.go index dd5590d9..44767ee3 100644 --- a/test/token_test.go +++ b/test/token_test.go @@ -23,8 +23,8 @@ import ( "origadmin/application/admin/helpers/securityx" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/loader" - "origadmin/application/admin/internal/mods/auth/dal" - "origadmin/application/admin/internal/mods/auth/service" + "origadmin/application/admin/internal/features/auth/dal" // Corrected import path + "origadmin/application/admin/internal/features/auth/service" // Corrected import path ) type mockData struct { diff --git a/third_party/buf/validate/validate.proto b/third_party/buf/validate/validate.proto new file mode 100644 index 00000000..519545dd --- /dev/null +++ b/third_party/buf/validate/validate.proto @@ -0,0 +1,5004 @@ +// Copyright 2023-2025 Buf Technologies, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto2"; + +package buf.validate; + +import "google/protobuf/descriptor.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"; +option java_multiple_files = true; +option java_outer_classname = "ValidateProto"; +option java_package = "build.buf.validate"; + +// MessageOptions is an extension to google.protobuf.MessageOptions. It allows +// the addition of validation rules at the message level. These rules can be +// applied to incoming messages to ensure they meet certain criteria before +// being processed. +extend google.protobuf.MessageOptions { + // Rules specify the validations to be performed on this message. By default, + // no validation is performed against a message. + optional MessageRules message = 1159; +} + +// OneofOptions is an extension to google.protobuf.OneofOptions. It allows +// the addition of validation rules on a oneof. These rules can be +// applied to incoming messages to ensure they meet certain criteria before +// being processed. +extend google.protobuf.OneofOptions { + // Rules specify the validations to be performed on this oneof. By default, + // no validation is performed against a oneof. + optional OneofRules oneof = 1159; +} + +// FieldOptions is an extension to google.protobuf.FieldOptions. It allows +// the addition of validation rules at the field level. These rules can be +// applied to incoming messages to ensure they meet certain criteria before +// being processed. +extend google.protobuf.FieldOptions { + // Rules specify the validations to be performed on this field. By default, + // no validation is performed against a field. + optional FieldRules field = 1159; + + // Specifies predefined rules. When extending a standard rule message, + // this adds additional CEL expressions that apply when the extension is used. + // + // ```proto + // extend buf.validate.Int32Rules { + // bool is_zero [(buf.validate.predefined).cel = { + // id: "int32.is_zero", + // message: "value must be zero", + // expression: "!rule || this == 0", + // }]; + // } + // + // message Foo { + // int32 reserved = 1 [(buf.validate.field).int32.(is_zero) = true]; + // } + // ``` + optional PredefinedRules predefined = 1160; +} + +// `Rule` represents a validation rule written in the Common Expression +// Language (CEL) syntax. Each Rule includes a unique identifier, an +// optional error message, and the CEL expression to evaluate. For more +// information, [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). +// +// ```proto +// message Foo { +// option (buf.validate.message).cel = { +// id: "foo.bar" +// message: "bar must be greater than 0" +// expression: "this.bar > 0" +// }; +// int32 bar = 1; +// } +// ``` +message Rule { + // `id` is a string that serves as a machine-readable name for this Rule. + // It should be unique within its scope, which could be either a message or a field. + optional string id = 1; + + // `message` is an optional field that provides a human-readable error message + // for this Rule when the CEL expression evaluates to false. If a + // non-empty message is provided, any strings resulting from the CEL + // expression evaluation are ignored. + optional string message = 2; + + // `expression` is the actual CEL expression that will be evaluated for + // validation. This string must resolve to either a boolean or a string + // value. If the expression evaluates to false or a non-empty string, the + // validation is considered failed, and the message is rejected. + optional string expression = 3; +} + +// MessageRules represents validation rules that are applied to the entire message. +// It includes disabling options and a list of Rule messages representing Common Expression Language (CEL) validation rules. +message MessageRules { + // `cel` is a repeated field of type Rule. Each Rule specifies a validation rule to be applied to this message. + // These rules are written in Common Expression Language (CEL) syntax. For more information, + // [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). + // + // + // ```proto + // message MyMessage { + // // The field `foo` must be greater than 42. + // option (buf.validate.message).cel = { + // id: "my_message.value", + // message: "value must be greater than 42", + // expression: "this.foo > 42", + // }; + // optional int32 foo = 1; + // } + // ``` + repeated Rule cel = 3; + + // `oneof` is a repeated field of type MessageOneofRule that specifies a list of fields + // of which at most one can be present. If `required` is also specified, then exactly one + // of the specified fields _must_ be present. + // + // This will enforce oneof-like constraints with a few features not provided by + // actual Protobuf oneof declarations: + // 1. Repeated and map fields are allowed in this validation. In a Protobuf oneof, + // only scalar fields are allowed. + // 2. Fields with implicit presence are allowed. In a Protobuf oneof, all member + // fields have explicit presence. This means that, for the purpose of determining + // how many fields are set, explicitly setting such a field to its zero value is + // effectively the same as not setting it at all. + // 3. This will always generate validation errors for a message unmarshalled from + // serialized data that sets more than one field. With a Protobuf oneof, when + // multiple fields are present in the serialized form, earlier values are usually + // silently ignored when unmarshalling, with only the last field being set when + // unmarshalling completes. + // + // Note that adding a field to a `oneof` will also set the IGNORE_IF_ZERO_VALUE on the fields. This means + // only the field that is set will be validated and the unset fields are not validated according to the field rules. + // This behavior can be overridden by setting `ignore` against a field. + // + // ```proto + // message MyMessage { + // // Only one of `field1` or `field2` _can_ be present in this message. + // option (buf.validate.message).oneof = { fields: ["field1", "field2"] }; + // // Exactly one of `field3` or `field4` _must_ be present in this message. + // option (buf.validate.message).oneof = { fields: ["field3", "field4"], required: true }; + // string field1 = 1; + // bytes field2 = 2; + // bool field3 = 3; + // int32 field4 = 4; + // } + // ``` + repeated MessageOneofRule oneof = 4; + + reserved 1; + reserved "disabled"; +} + +message MessageOneofRule { + // A list of field names to include in the oneof. All field names must be + // defined in the message. At least one field must be specified, and + // duplicates are not permitted. + repeated string fields = 1; + // If true, one of the fields specified _must_ be set. + optional bool required = 2; +} + +// The `OneofRules` message type enables you to manage rules for +// oneof fields in your protobuf messages. +message OneofRules { + // If `required` is true, exactly one field of the oneof must be set. A + // validation error is returned if no fields in the oneof are set. Further rules + // should be placed on the fields themselves to ensure they are valid values, + // such as `min_len` or `gt`. + // + // ```proto + // message MyMessage { + // oneof value { + // // Either `a` or `b` must be set. If `a` is set, it must also be + // // non-empty; whereas if `b` is set, it can still be an empty string. + // option (buf.validate.oneof).required = true; + // string a = 1 [(buf.validate.field).string.min_len = 1]; + // string b = 2; + // } + // } + // ``` + optional bool required = 1; +} + +// FieldRules encapsulates the rules for each type of field. Depending on +// the field, the correct set should be used to ensure proper validations. +message FieldRules { + // `cel` is a repeated field used to represent a textual expression + // in the Common Expression Language (CEL) syntax. For more information, + // [see our documentation](https://buf.build/docs/protovalidate/schemas/custom-rules/). + // + // ```proto + // message MyMessage { + // // The field `value` must be greater than 42. + // optional int32 value = 1 [(buf.validate.field).cel = { + // id: "my_message.value", + // message: "value must be greater than 42", + // expression: "this > 42", + // }]; + // } + // ``` + repeated Rule cel = 23; + // If `required` is true, the field must be set. A validation error is returned + // if the field is not set. + // + // ```proto + // syntax="proto3"; + // + // message FieldsWithPresence { + // // Requires any string to be set, including the empty string. + // optional string link = 1 [ + // (buf.validate.field).required = true + // ]; + // // Requires true or false to be set. + // optional bool disabled = 2 [ + // (buf.validate.field).required = true + // ]; + // // Requires a message to be set, including the empty message. + // SomeMessage msg = 4 [ + // (buf.validate.field).required = true + // ]; + // } + // ``` + // + // All fields in the example above track presence. By default, Protovalidate + // ignores rules on those fields if no value is set. `required` ensures that + // the fields are set and valid. + // + // Fields that don't track presence are always validated by Protovalidate, + // whether they are set or not. It is not necessary to add `required`. It + // can be added to indicate that the field cannot be the zero value. + // + // ```proto + // syntax="proto3"; + // + // message FieldsWithoutPresence { + // // `string.email` always applies, even to an empty string. + // string link = 1 [ + // (buf.validate.field).string.email = true + // ]; + // // `repeated.min_items` always applies, even to an empty list. + // repeated string labels = 2 [ + // (buf.validate.field).repeated.min_items = 1 + // ]; + // // `required`, for fields that don't track presence, indicates + // // the value of the field can't be the zero value. + // int32 zero_value_not_allowed = 3 [ + // (buf.validate.field).required = true + // ]; + // } + // ``` + // + // To learn which fields track presence, see the + // [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat). + // + // Note: While field rules can be applied to repeated items, map keys, and map + // values, the elements are always considered to be set. Consequently, + // specifying `repeated.items.required` is redundant. + optional bool required = 25; + // Ignore validation rules on the field if its value matches the specified + // criteria. See the `Ignore` enum for details. + // + // ```proto + // message UpdateRequest { + // // The uri rule only applies if the field is not an empty string. + // string url = 1 [ + // (buf.validate.field).ignore = IGNORE_IF_ZERO_VALUE, + // (buf.validate.field).string.uri = true + // ]; + // } + // ``` + optional Ignore ignore = 27; + + oneof type { + // Scalar Field Types + FloatRules float = 1; + DoubleRules double = 2; + Int32Rules int32 = 3; + Int64Rules int64 = 4; + UInt32Rules uint32 = 5; + UInt64Rules uint64 = 6; + SInt32Rules sint32 = 7; + SInt64Rules sint64 = 8; + Fixed32Rules fixed32 = 9; + Fixed64Rules fixed64 = 10; + SFixed32Rules sfixed32 = 11; + SFixed64Rules sfixed64 = 12; + BoolRules bool = 13; + StringRules string = 14; + BytesRules bytes = 15; + + // Complex Field Types + EnumRules enum = 16; + RepeatedRules repeated = 18; + MapRules map = 19; + + // Well-Known Field Types + AnyRules any = 20; + DurationRules duration = 21; + TimestampRules timestamp = 22; + } + + reserved 24, 26; + reserved "skipped", "ignore_empty"; +} + +// PredefinedRules are custom rules that can be re-used with +// multiple fields. +message PredefinedRules { + // `cel` is a repeated field used to represent a textual expression + // in the Common Expression Language (CEL) syntax. For more information, + // [see our documentation](https://buf.build/docs/protovalidate/schemas/predefined-rules/). + // + // ```proto + // message MyMessage { + // // The field `value` must be greater than 42. + // optional int32 value = 1 [(buf.validate.predefined).cel = { + // id: "my_message.value", + // message: "value must be greater than 42", + // expression: "this > 42", + // }]; + // } + // ``` + repeated Rule cel = 1; + + reserved 24, 26; + reserved "skipped", "ignore_empty"; +} + +// Specifies how `FieldRules.ignore` behaves, depending on the field's value, and +// whether the field tracks presence. +enum Ignore { + // Ignore rules if the field tracks presence and is unset. This is the default + // behavior. + // + // In proto3, only message fields, members of a Protobuf `oneof`, and fields + // with the `optional` label track presence. Consequently, the following fields + // are always validated, whether a value is set or not: + // + // ```proto + // syntax="proto3"; + // + // message RulesApply { + // string email = 1 [ + // (buf.validate.field).string.email = true + // ]; + // int32 age = 2 [ + // (buf.validate.field).int32.gt = 0 + // ]; + // repeated string labels = 3 [ + // (buf.validate.field).repeated.min_items = 1 + // ]; + // } + // ``` + // + // In contrast, the following fields track presence, and are only validated if + // a value is set: + // + // ```proto + // syntax="proto3"; + // + // message RulesApplyIfSet { + // optional string email = 1 [ + // (buf.validate.field).string.email = true + // ]; + // oneof ref { + // string reference = 2 [ + // (buf.validate.field).string.uuid = true + // ]; + // string name = 3 [ + // (buf.validate.field).string.min_len = 4 + // ]; + // } + // SomeMessage msg = 4 [ + // (buf.validate.field).cel = {/* ... */} + // ]; + // } + // ``` + // + // To ensure that such a field is set, add the `required` rule. + // + // To learn which fields track presence, see the + // [Field Presence cheat sheet](https://protobuf.dev/programming-guides/field_presence/#cheat). + IGNORE_UNSPECIFIED = 0; + + // Ignore rules if the field is unset, or set to the zero value. + // + // The zero value depends on the field type: + // - For strings, the zero value is the empty string. + // - For bytes, the zero value is empty bytes. + // - For bool, the zero value is false. + // - For numeric types, the zero value is zero. + // - For enums, the zero value is the first defined enum value. + // - For repeated fields, the zero is an empty list. + // - For map fields, the zero is an empty map. + // - For message fields, absence of the message (typically a null-value) is considered zero value. + // + // For fields that track presence (e.g. adding the `optional` label in proto3), + // this a no-op and behavior is the same as the default `IGNORE_UNSPECIFIED`. + IGNORE_IF_ZERO_VALUE = 1; + + // Always ignore rules, including the `required` rule. + // + // This is useful for ignoring the rules of a referenced message, or to + // temporarily ignore rules during development. + // + // ```proto + // message MyMessage { + // // The field's rules will always be ignored, including any validations + // // on value's fields. + // MyOtherMessage value = 1 [ + // (buf.validate.field).ignore = IGNORE_ALWAYS + // ]; + // } + // ``` + IGNORE_ALWAYS = 3; + + reserved 2; + reserved "IGNORE_EMPTY", "IGNORE_DEFAULT", "IGNORE_IF_DEFAULT_VALUE", "IGNORE_IF_UNPOPULATED"; +} + +// FloatRules describes the rules applied to `float` values. These +// rules may also be applied to the `google.protobuf.FloatValue` Well-Known-Type. +message FloatRules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyFloat { + // // value must equal 42.0 + // float value = 1 [(buf.validate.field).float.const = 42.0]; + // } + // ``` + optional float const = 1 [(predefined).cel = { + id: "float.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be less than 10.0 + // float value = 1 [(buf.validate.field).float.lt = 10.0]; + // } + // ``` + float lt = 2 [(predefined).cel = { + id: "float.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be less than or equal to 10.0 + // float value = 1 [(buf.validate.field).float.lte = 10.0]; + // } + // ``` + float lte = 3 [(predefined).cel = { + id: "float.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be greater than 5.0 [float.gt] + // float value = 1 [(buf.validate.field).float.gt = 5.0]; + // + // // value must be greater than 5 and less than 10.0 [float.gt_lt] + // float other_value = 2 [(buf.validate.field).float = { gt: 5.0, lt: 10.0 }]; + // + // // value must be greater than 10 or less than 5.0 [float.gt_lt_exclusive] + // float another_value = 3 [(buf.validate.field).float = { gt: 10.0, lt: 5.0 }]; + // } + // ``` + float gt = 4 [ + (predefined).cel = { + id: "float.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "float.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "float.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFloat { + // // value must be greater than or equal to 5.0 [float.gte] + // float value = 1 [(buf.validate.field).float.gte = 5.0]; + // + // // value must be greater than or equal to 5.0 and less than 10.0 [float.gte_lt] + // float other_value = 2 [(buf.validate.field).float = { gte: 5.0, lt: 10.0 }]; + // + // // value must be greater than or equal to 10.0 or less than 5.0 [float.gte_lt_exclusive] + // float another_value = 3 [(buf.validate.field).float = { gte: 10.0, lt: 5.0 }]; + // } + // ``` + float gte = 5 [ + (predefined).cel = { + id: "float.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "float.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "float.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "float.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message + // is generated. + // + // ```proto + // message MyFloat { + // // value must be in list [1.0, 2.0, 3.0] + // float value = 1 [(buf.validate.field).float = { in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated float in = 6 [(predefined).cel = { + id: "float.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyFloat { + // // value must not be in list [1.0, 2.0, 3.0] + // float value = 1 [(buf.validate.field).float = { not_in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated float not_in = 7 [(predefined).cel = { + id: "float.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `finite` requires the field value to be finite. If the field value is + // infinite or NaN, an error message is generated. + optional bool finite = 8 [(predefined).cel = { + id: "float.finite" + expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFloat { + // float value = 1 [ + // (buf.validate.field).float.example = 1.0, + // (buf.validate.field).float.example = inf + // ]; + // } + // ``` + repeated float example = 9 [(predefined).cel = { + id: "float.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// DoubleRules describes the rules applied to `double` values. These +// rules may also be applied to the `google.protobuf.DoubleValue` Well-Known-Type. +message DoubleRules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyDouble { + // // value must equal 42.0 + // double value = 1 [(buf.validate.field).double.const = 42.0]; + // } + // ``` + optional double const = 1 [(predefined).cel = { + id: "double.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyDouble { + // // value must be less than 10.0 + // double value = 1 [(buf.validate.field).double.lt = 10.0]; + // } + // ``` + double lt = 2 [(predefined).cel = { + id: "double.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this >= rules.lt)" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified value + // (field <= value). If the field value is greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyDouble { + // // value must be less than or equal to 10.0 + // double value = 1 [(buf.validate.field).double.lte = 10.0]; + // } + // ``` + double lte = 3 [(predefined).cel = { + id: "double.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && (this.isNan() || this > rules.lte)" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or `lte`, + // the range is reversed, and the field value must be outside the specified + // range. If the field value doesn't meet the required conditions, an error + // message is generated. + // + // ```proto + // message MyDouble { + // // value must be greater than 5.0 [double.gt] + // double value = 1 [(buf.validate.field).double.gt = 5.0]; + // + // // value must be greater than 5 and less than 10.0 [double.gt_lt] + // double other_value = 2 [(buf.validate.field).double = { gt: 5.0, lt: 10.0 }]; + // + // // value must be greater than 10 or less than 5.0 [double.gt_lt_exclusive] + // double another_value = 3 [(buf.validate.field).double = { gt: 10.0, lt: 5.0 }]; + // } + // ``` + double gt = 4 [ + (predefined).cel = { + id: "double.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this <= rules.gt)" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "double.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this.isNan() || this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (this.isNan() || (rules.lt <= this && this <= rules.gt))" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this.isNan() || this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "double.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (this.isNan() || (rules.lte < this && this <= rules.gt))" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyDouble { + // // value must be greater than or equal to 5.0 [double.gte] + // double value = 1 [(buf.validate.field).double.gte = 5.0]; + // + // // value must be greater than or equal to 5.0 and less than 10.0 [double.gte_lt] + // double other_value = 2 [(buf.validate.field).double = { gte: 5.0, lt: 10.0 }]; + // + // // value must be greater than or equal to 10.0 or less than 5.0 [double.gte_lt_exclusive] + // double another_value = 3 [(buf.validate.field).double = { gte: 10.0, lt: 5.0 }]; + // } + // ``` + double gte = 5 [ + (predefined).cel = { + id: "double.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && (this.isNan() || this < rules.gte)" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "double.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this.isNan() || this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (this.isNan() || (rules.lt <= this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "double.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this.isNan() || this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "double.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (this.isNan() || (rules.lte < this && this < rules.gte))" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyDouble { + // // value must be in list [1.0, 2.0, 3.0] + // double value = 1 [(buf.validate.field).double = { in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated double in = 6 [(predefined).cel = { + id: "double.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyDouble { + // // value must not be in list [1.0, 2.0, 3.0] + // double value = 1 [(buf.validate.field).double = { not_in: [1.0, 2.0, 3.0] }]; + // } + // ``` + repeated double not_in = 7 [(predefined).cel = { + id: "double.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `finite` requires the field value to be finite. If the field value is + // infinite or NaN, an error message is generated. + optional bool finite = 8 [(predefined).cel = { + id: "double.finite" + expression: "rules.finite ? (this.isNan() || this.isInf() ? 'value must be finite' : '') : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyDouble { + // double value = 1 [ + // (buf.validate.field).double.example = 1.0, + // (buf.validate.field).double.example = inf + // ]; + // } + // ``` + repeated double example = 9 [(predefined).cel = { + id: "double.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// Int32Rules describes the rules applied to `int32` values. These +// rules may also be applied to the `google.protobuf.Int32Value` Well-Known-Type. +message Int32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must equal 42 + // int32 value = 1 [(buf.validate.field).int32.const = 42]; + // } + // ``` + optional int32 const = 1 [(predefined).cel = { + id: "int32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field + // < value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be less than 10 + // int32 value = 1 [(buf.validate.field).int32.lt = 10]; + // } + // ``` + int32 lt = 2 [(predefined).cel = { + id: "int32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be less than or equal to 10 + // int32 value = 1 [(buf.validate.field).int32.lte = 10]; + // } + // ``` + int32 lte = 3 [(predefined).cel = { + id: "int32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be greater than 5 [int32.gt] + // int32 value = 1 [(buf.validate.field).int32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [int32.gt_lt] + // int32 other_value = 2 [(buf.validate.field).int32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [int32.gt_lt_exclusive] + // int32 another_value = 3 [(buf.validate.field).int32 = { gt: 10, lt: 5 }]; + // } + // ``` + int32 gt = 4 [ + (predefined).cel = { + id: "int32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified value + // (exclusive). If the value of `gte` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt32 { + // // value must be greater than or equal to 5 [int32.gte] + // int32 value = 1 [(buf.validate.field).int32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [int32.gte_lt] + // int32 other_value = 2 [(buf.validate.field).int32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [int32.gte_lt_exclusive] + // int32 another_value = 3 [(buf.validate.field).int32 = { gte: 10, lt: 5 }]; + // } + // ``` + int32 gte = 5 [ + (predefined).cel = { + id: "int32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyInt32 { + // // value must be in list [1, 2, 3] + // int32 value = 1 [(buf.validate.field).int32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated int32 in = 6 [(predefined).cel = { + id: "int32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error message + // is generated. + // + // ```proto + // message MyInt32 { + // // value must not be in list [1, 2, 3] + // int32 value = 1 [(buf.validate.field).int32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated int32 not_in = 7 [(predefined).cel = { + id: "int32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyInt32 { + // int32 value = 1 [ + // (buf.validate.field).int32.example = 1, + // (buf.validate.field).int32.example = -10 + // ]; + // } + // ``` + repeated int32 example = 8 [(predefined).cel = { + id: "int32.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// Int64Rules describes the rules applied to `int64` values. These +// rules may also be applied to the `google.protobuf.Int64Value` Well-Known-Type. +message Int64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must equal 42 + // int64 value = 1 [(buf.validate.field).int64.const = 42]; + // } + // ``` + optional int64 const = 1 [(predefined).cel = { + id: "int64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be less than 10 + // int64 value = 1 [(buf.validate.field).int64.lt = 10]; + // } + // ``` + int64 lt = 2 [(predefined).cel = { + id: "int64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be less than or equal to 10 + // int64 value = 1 [(buf.validate.field).int64.lte = 10]; + // } + // ``` + int64 lte = 3 [(predefined).cel = { + id: "int64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be greater than 5 [int64.gt] + // int64 value = 1 [(buf.validate.field).int64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [int64.gt_lt] + // int64 other_value = 2 [(buf.validate.field).int64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [int64.gt_lt_exclusive] + // int64 another_value = 3 [(buf.validate.field).int64 = { gt: 10, lt: 5 }]; + // } + // ``` + int64 gt = 4 [ + (predefined).cel = { + id: "int64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyInt64 { + // // value must be greater than or equal to 5 [int64.gte] + // int64 value = 1 [(buf.validate.field).int64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [int64.gte_lt] + // int64 other_value = 2 [(buf.validate.field).int64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [int64.gte_lt_exclusive] + // int64 another_value = 3 [(buf.validate.field).int64 = { gte: 10, lt: 5 }]; + // } + // ``` + int64 gte = 5 [ + (predefined).cel = { + id: "int64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "int64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyInt64 { + // // value must be in list [1, 2, 3] + // int64 value = 1 [(buf.validate.field).int64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated int64 in = 6 [(predefined).cel = { + id: "int64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyInt64 { + // // value must not be in list [1, 2, 3] + // int64 value = 1 [(buf.validate.field).int64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated int64 not_in = 7 [(predefined).cel = { + id: "int64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyInt64 { + // int64 value = 1 [ + // (buf.validate.field).int64.example = 1, + // (buf.validate.field).int64.example = -10 + // ]; + // } + // ``` + repeated int64 example = 9 [(predefined).cel = { + id: "int64.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// UInt32Rules describes the rules applied to `uint32` values. These +// rules may also be applied to the `google.protobuf.UInt32Value` Well-Known-Type. +message UInt32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must equal 42 + // uint32 value = 1 [(buf.validate.field).uint32.const = 42]; + // } + // ``` + optional uint32 const = 1 [(predefined).cel = { + id: "uint32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be less than 10 + // uint32 value = 1 [(buf.validate.field).uint32.lt = 10]; + // } + // ``` + uint32 lt = 2 [(predefined).cel = { + id: "uint32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be less than or equal to 10 + // uint32 value = 1 [(buf.validate.field).uint32.lte = 10]; + // } + // ``` + uint32 lte = 3 [(predefined).cel = { + id: "uint32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be greater than 5 [uint32.gt] + // uint32 value = 1 [(buf.validate.field).uint32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [uint32.gt_lt] + // uint32 other_value = 2 [(buf.validate.field).uint32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [uint32.gt_lt_exclusive] + // uint32 another_value = 3 [(buf.validate.field).uint32 = { gt: 10, lt: 5 }]; + // } + // ``` + uint32 gt = 4 [ + (predefined).cel = { + id: "uint32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt32 { + // // value must be greater than or equal to 5 [uint32.gte] + // uint32 value = 1 [(buf.validate.field).uint32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [uint32.gte_lt] + // uint32 other_value = 2 [(buf.validate.field).uint32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [uint32.gte_lt_exclusive] + // uint32 another_value = 3 [(buf.validate.field).uint32 = { gte: 10, lt: 5 }]; + // } + // ``` + uint32 gte = 5 [ + (predefined).cel = { + id: "uint32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyUInt32 { + // // value must be in list [1, 2, 3] + // uint32 value = 1 [(buf.validate.field).uint32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated uint32 in = 6 [(predefined).cel = { + id: "uint32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyUInt32 { + // // value must not be in list [1, 2, 3] + // uint32 value = 1 [(buf.validate.field).uint32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated uint32 not_in = 7 [(predefined).cel = { + id: "uint32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyUInt32 { + // uint32 value = 1 [ + // (buf.validate.field).uint32.example = 1, + // (buf.validate.field).uint32.example = 10 + // ]; + // } + // ``` + repeated uint32 example = 8 [(predefined).cel = { + id: "uint32.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// UInt64Rules describes the rules applied to `uint64` values. These +// rules may also be applied to the `google.protobuf.UInt64Value` Well-Known-Type. +message UInt64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must equal 42 + // uint64 value = 1 [(buf.validate.field).uint64.const = 42]; + // } + // ``` + optional uint64 const = 1 [(predefined).cel = { + id: "uint64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be less than 10 + // uint64 value = 1 [(buf.validate.field).uint64.lt = 10]; + // } + // ``` + uint64 lt = 2 [(predefined).cel = { + id: "uint64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be less than or equal to 10 + // uint64 value = 1 [(buf.validate.field).uint64.lte = 10]; + // } + // ``` + uint64 lte = 3 [(predefined).cel = { + id: "uint64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be greater than 5 [uint64.gt] + // uint64 value = 1 [(buf.validate.field).uint64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [uint64.gt_lt] + // uint64 other_value = 2 [(buf.validate.field).uint64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [uint64.gt_lt_exclusive] + // uint64 another_value = 3 [(buf.validate.field).uint64 = { gt: 10, lt: 5 }]; + // } + // ``` + uint64 gt = 4 [ + (predefined).cel = { + id: "uint64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyUInt64 { + // // value must be greater than or equal to 5 [uint64.gte] + // uint64 value = 1 [(buf.validate.field).uint64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [uint64.gte_lt] + // uint64 other_value = 2 [(buf.validate.field).uint64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [uint64.gte_lt_exclusive] + // uint64 another_value = 3 [(buf.validate.field).uint64 = { gte: 10, lt: 5 }]; + // } + // ``` + uint64 gte = 5 [ + (predefined).cel = { + id: "uint64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "uint64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyUInt64 { + // // value must be in list [1, 2, 3] + // uint64 value = 1 [(buf.validate.field).uint64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated uint64 in = 6 [(predefined).cel = { + id: "uint64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyUInt64 { + // // value must not be in list [1, 2, 3] + // uint64 value = 1 [(buf.validate.field).uint64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated uint64 not_in = 7 [(predefined).cel = { + id: "uint64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyUInt64 { + // uint64 value = 1 [ + // (buf.validate.field).uint64.example = 1, + // (buf.validate.field).uint64.example = -10 + // ]; + // } + // ``` + repeated uint64 example = 8 [(predefined).cel = { + id: "uint64.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// SInt32Rules describes the rules applied to `sint32` values. +message SInt32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must equal 42 + // sint32 value = 1 [(buf.validate.field).sint32.const = 42]; + // } + // ``` + optional sint32 const = 1 [(predefined).cel = { + id: "sint32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field + // < value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be less than 10 + // sint32 value = 1 [(buf.validate.field).sint32.lt = 10]; + // } + // ``` + sint32 lt = 2 [(predefined).cel = { + id: "sint32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be less than or equal to 10 + // sint32 value = 1 [(buf.validate.field).sint32.lte = 10]; + // } + // ``` + sint32 lte = 3 [(predefined).cel = { + id: "sint32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be greater than 5 [sint32.gt] + // sint32 value = 1 [(buf.validate.field).sint32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sint32.gt_lt] + // sint32 other_value = 2 [(buf.validate.field).sint32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sint32.gt_lt_exclusive] + // sint32 another_value = 3 [(buf.validate.field).sint32 = { gt: 10, lt: 5 }]; + // } + // ``` + sint32 gt = 4 [ + (predefined).cel = { + id: "sint32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt32 { + // // value must be greater than or equal to 5 [sint32.gte] + // sint32 value = 1 [(buf.validate.field).sint32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sint32.gte_lt] + // sint32 other_value = 2 [(buf.validate.field).sint32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sint32.gte_lt_exclusive] + // sint32 another_value = 3 [(buf.validate.field).sint32 = { gte: 10, lt: 5 }]; + // } + // ``` + sint32 gte = 5 [ + (predefined).cel = { + id: "sint32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MySInt32 { + // // value must be in list [1, 2, 3] + // sint32 value = 1 [(buf.validate.field).sint32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sint32 in = 6 [(predefined).cel = { + id: "sint32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySInt32 { + // // value must not be in list [1, 2, 3] + // sint32 value = 1 [(buf.validate.field).sint32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sint32 not_in = 7 [(predefined).cel = { + id: "sint32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySInt32 { + // sint32 value = 1 [ + // (buf.validate.field).sint32.example = 1, + // (buf.validate.field).sint32.example = -10 + // ]; + // } + // ``` + repeated sint32 example = 8 [(predefined).cel = { + id: "sint32.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// SInt64Rules describes the rules applied to `sint64` values. +message SInt64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must equal 42 + // sint64 value = 1 [(buf.validate.field).sint64.const = 42]; + // } + // ``` + optional sint64 const = 1 [(predefined).cel = { + id: "sint64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field + // < value). If the field value is equal to or greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be less than 10 + // sint64 value = 1 [(buf.validate.field).sint64.lt = 10]; + // } + // ``` + sint64 lt = 2 [(predefined).cel = { + id: "sint64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be less than or equal to 10 + // sint64 value = 1 [(buf.validate.field).sint64.lte = 10]; + // } + // ``` + sint64 lte = 3 [(predefined).cel = { + id: "sint64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be greater than 5 [sint64.gt] + // sint64 value = 1 [(buf.validate.field).sint64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sint64.gt_lt] + // sint64 other_value = 2 [(buf.validate.field).sint64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sint64.gt_lt_exclusive] + // sint64 another_value = 3 [(buf.validate.field).sint64 = { gt: 10, lt: 5 }]; + // } + // ``` + sint64 gt = 4 [ + (predefined).cel = { + id: "sint64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySInt64 { + // // value must be greater than or equal to 5 [sint64.gte] + // sint64 value = 1 [(buf.validate.field).sint64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sint64.gte_lt] + // sint64 other_value = 2 [(buf.validate.field).sint64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sint64.gte_lt_exclusive] + // sint64 another_value = 3 [(buf.validate.field).sint64 = { gte: 10, lt: 5 }]; + // } + // ``` + sint64 gte = 5 [ + (predefined).cel = { + id: "sint64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sint64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message + // is generated. + // + // ```proto + // message MySInt64 { + // // value must be in list [1, 2, 3] + // sint64 value = 1 [(buf.validate.field).sint64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sint64 in = 6 [(predefined).cel = { + id: "sint64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySInt64 { + // // value must not be in list [1, 2, 3] + // sint64 value = 1 [(buf.validate.field).sint64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sint64 not_in = 7 [(predefined).cel = { + id: "sint64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySInt64 { + // sint64 value = 1 [ + // (buf.validate.field).sint64.example = 1, + // (buf.validate.field).sint64.example = -10 + // ]; + // } + // ``` + repeated sint64 example = 8 [(predefined).cel = { + id: "sint64.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// Fixed32Rules describes the rules applied to `fixed32` values. +message Fixed32Rules { + // `const` requires the field value to exactly match the specified value. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must equal 42 + // fixed32 value = 1 [(buf.validate.field).fixed32.const = 42]; + // } + // ``` + optional fixed32 const = 1 [(predefined).cel = { + id: "fixed32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be less than 10 + // fixed32 value = 1 [(buf.validate.field).fixed32.lt = 10]; + // } + // ``` + fixed32 lt = 2 [(predefined).cel = { + id: "fixed32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be less than or equal to 10 + // fixed32 value = 1 [(buf.validate.field).fixed32.lte = 10]; + // } + // ``` + fixed32 lte = 3 [(predefined).cel = { + id: "fixed32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be greater than 5 [fixed32.gt] + // fixed32 value = 1 [(buf.validate.field).fixed32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [fixed32.gt_lt] + // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [fixed32.gt_lt_exclusive] + // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gt: 10, lt: 5 }]; + // } + // ``` + fixed32 gt = 4 [ + (predefined).cel = { + id: "fixed32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed32 { + // // value must be greater than or equal to 5 [fixed32.gte] + // fixed32 value = 1 [(buf.validate.field).fixed32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [fixed32.gte_lt] + // fixed32 other_value = 2 [(buf.validate.field).fixed32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [fixed32.gte_lt_exclusive] + // fixed32 another_value = 3 [(buf.validate.field).fixed32 = { gte: 10, lt: 5 }]; + // } + // ``` + fixed32 gte = 5 [ + (predefined).cel = { + id: "fixed32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message + // is generated. + // + // ```proto + // message MyFixed32 { + // // value must be in list [1, 2, 3] + // fixed32 value = 1 [(buf.validate.field).fixed32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated fixed32 in = 6 [(predefined).cel = { + id: "fixed32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyFixed32 { + // // value must not be in list [1, 2, 3] + // fixed32 value = 1 [(buf.validate.field).fixed32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated fixed32 not_in = 7 [(predefined).cel = { + id: "fixed32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFixed32 { + // fixed32 value = 1 [ + // (buf.validate.field).fixed32.example = 1, + // (buf.validate.field).fixed32.example = 2 + // ]; + // } + // ``` + repeated fixed32 example = 8 [(predefined).cel = { + id: "fixed32.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// Fixed64Rules describes the rules applied to `fixed64` values. +message Fixed64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must equal 42 + // fixed64 value = 1 [(buf.validate.field).fixed64.const = 42]; + // } + // ``` + optional fixed64 const = 1 [(predefined).cel = { + id: "fixed64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be less than 10 + // fixed64 value = 1 [(buf.validate.field).fixed64.lt = 10]; + // } + // ``` + fixed64 lt = 2 [(predefined).cel = { + id: "fixed64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be less than or equal to 10 + // fixed64 value = 1 [(buf.validate.field).fixed64.lte = 10]; + // } + // ``` + fixed64 lte = 3 [(predefined).cel = { + id: "fixed64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be greater than 5 [fixed64.gt] + // fixed64 value = 1 [(buf.validate.field).fixed64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [fixed64.gt_lt] + // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [fixed64.gt_lt_exclusive] + // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gt: 10, lt: 5 }]; + // } + // ``` + fixed64 gt = 4 [ + (predefined).cel = { + id: "fixed64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyFixed64 { + // // value must be greater than or equal to 5 [fixed64.gte] + // fixed64 value = 1 [(buf.validate.field).fixed64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [fixed64.gte_lt] + // fixed64 other_value = 2 [(buf.validate.field).fixed64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [fixed64.gte_lt_exclusive] + // fixed64 another_value = 3 [(buf.validate.field).fixed64 = { gte: 10, lt: 5 }]; + // } + // ``` + fixed64 gte = 5 [ + (predefined).cel = { + id: "fixed64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "fixed64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MyFixed64 { + // // value must be in list [1, 2, 3] + // fixed64 value = 1 [(buf.validate.field).fixed64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated fixed64 in = 6 [(predefined).cel = { + id: "fixed64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MyFixed64 { + // // value must not be in list [1, 2, 3] + // fixed64 value = 1 [(buf.validate.field).fixed64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated fixed64 not_in = 7 [(predefined).cel = { + id: "fixed64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyFixed64 { + // fixed64 value = 1 [ + // (buf.validate.field).fixed64.example = 1, + // (buf.validate.field).fixed64.example = 2 + // ]; + // } + // ``` + repeated fixed64 example = 8 [(predefined).cel = { + id: "fixed64.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// SFixed32Rules describes the rules applied to `fixed32` values. +message SFixed32Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must equal 42 + // sfixed32 value = 1 [(buf.validate.field).sfixed32.const = 42]; + // } + // ``` + optional sfixed32 const = 1 [(predefined).cel = { + id: "sfixed32.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be less than 10 + // sfixed32 value = 1 [(buf.validate.field).sfixed32.lt = 10]; + // } + // ``` + sfixed32 lt = 2 [(predefined).cel = { + id: "sfixed32.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be less than or equal to 10 + // sfixed32 value = 1 [(buf.validate.field).sfixed32.lte = 10]; + // } + // ``` + sfixed32 lte = 3 [(predefined).cel = { + id: "sfixed32.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be greater than 5 [sfixed32.gt] + // sfixed32 value = 1 [(buf.validate.field).sfixed32.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sfixed32.gt_lt] + // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sfixed32.gt_lt_exclusive] + // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gt: 10, lt: 5 }]; + // } + // ``` + sfixed32 gt = 4 [ + (predefined).cel = { + id: "sfixed32.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed32 { + // // value must be greater than or equal to 5 [sfixed32.gte] + // sfixed32 value = 1 [(buf.validate.field).sfixed32.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sfixed32.gte_lt] + // sfixed32 other_value = 2 [(buf.validate.field).sfixed32 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sfixed32.gte_lt_exclusive] + // sfixed32 another_value = 3 [(buf.validate.field).sfixed32 = { gte: 10, lt: 5 }]; + // } + // ``` + sfixed32 gte = 5 [ + (predefined).cel = { + id: "sfixed32.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed32.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MySFixed32 { + // // value must be in list [1, 2, 3] + // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed32 in = 6 [(predefined).cel = { + id: "sfixed32.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySFixed32 { + // // value must not be in list [1, 2, 3] + // sfixed32 value = 1 [(buf.validate.field).sfixed32 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed32 not_in = 7 [(predefined).cel = { + id: "sfixed32.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySFixed32 { + // sfixed32 value = 1 [ + // (buf.validate.field).sfixed32.example = 1, + // (buf.validate.field).sfixed32.example = 2 + // ]; + // } + // ``` + repeated sfixed32 example = 8 [(predefined).cel = { + id: "sfixed32.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// SFixed64Rules describes the rules applied to `fixed64` values. +message SFixed64Rules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must equal 42 + // sfixed64 value = 1 [(buf.validate.field).sfixed64.const = 42]; + // } + // ``` + optional sfixed64 const = 1 [(predefined).cel = { + id: "sfixed64.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` requires the field value to be less than the specified value (field < + // value). If the field value is equal to or greater than the specified value, + // an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be less than 10 + // sfixed64 value = 1 [(buf.validate.field).sfixed64.lt = 10]; + // } + // ``` + sfixed64 lt = 2 [(predefined).cel = { + id: "sfixed64.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` requires the field value to be less than or equal to the specified + // value (field <= value). If the field value is greater than the specified + // value, an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be less than or equal to 10 + // sfixed64 value = 1 [(buf.validate.field).sfixed64.lte = 10]; + // } + // ``` + sfixed64 lte = 3 [(predefined).cel = { + id: "sfixed64.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the field value to be greater than the specified value + // (exclusive). If the value of `gt` is larger than a specified `lt` or + // `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be greater than 5 [sfixed64.gt] + // sfixed64 value = 1 [(buf.validate.field).sfixed64.gt = 5]; + // + // // value must be greater than 5 and less than 10 [sfixed64.gt_lt] + // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gt: 5, lt: 10 }]; + // + // // value must be greater than 10 or less than 5 [sfixed64.gt_lt_exclusive] + // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gt: 10, lt: 5 }]; + // } + // ``` + sfixed64 gt = 4 [ + (predefined).cel = { + id: "sfixed64.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the field value to be greater than or equal to the specified + // value (exclusive). If the value of `gte` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MySFixed64 { + // // value must be greater than or equal to 5 [sfixed64.gte] + // sfixed64 value = 1 [(buf.validate.field).sfixed64.gte = 5]; + // + // // value must be greater than or equal to 5 and less than 10 [sfixed64.gte_lt] + // sfixed64 other_value = 2 [(buf.validate.field).sfixed64 = { gte: 5, lt: 10 }]; + // + // // value must be greater than or equal to 10 or less than 5 [sfixed64.gte_lt_exclusive] + // sfixed64 another_value = 3 [(buf.validate.field).sfixed64 = { gte: 10, lt: 5 }]; + // } + // ``` + sfixed64 gte = 5 [ + (predefined).cel = { + id: "sfixed64.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "sfixed64.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` requires the field value to be equal to one of the specified values. + // If the field value isn't one of the specified values, an error message is + // generated. + // + // ```proto + // message MySFixed64 { + // // value must be in list [1, 2, 3] + // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed64 in = 6 [(predefined).cel = { + id: "sfixed64.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to not be equal to any of the specified + // values. If the field value is one of the specified values, an error + // message is generated. + // + // ```proto + // message MySFixed64 { + // // value must not be in list [1, 2, 3] + // sfixed64 value = 1 [(buf.validate.field).sfixed64 = { not_in: [1, 2, 3] }]; + // } + // ``` + repeated sfixed64 not_in = 7 [(predefined).cel = { + id: "sfixed64.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MySFixed64 { + // sfixed64 value = 1 [ + // (buf.validate.field).sfixed64.example = 1, + // (buf.validate.field).sfixed64.example = 2 + // ]; + // } + // ``` + repeated sfixed64 example = 8 [(predefined).cel = { + id: "sfixed64.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// BoolRules describes the rules applied to `bool` values. These rules +// may also be applied to the `google.protobuf.BoolValue` Well-Known-Type. +message BoolRules { + // `const` requires the field value to exactly match the specified boolean value. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyBool { + // // value must equal true + // bool value = 1 [(buf.validate.field).bool.const = true]; + // } + // ``` + optional bool const = 1 [(predefined).cel = { + id: "bool.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyBool { + // bool value = 1 [ + // (buf.validate.field).bool.example = 1, + // (buf.validate.field).bool.example = 2 + // ]; + // } + // ``` + repeated bool example = 2 [(predefined).cel = { + id: "bool.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// StringRules describes the rules applied to `string` values These +// rules may also be applied to the `google.protobuf.StringValue` Well-Known-Type. +message StringRules { + // `const` requires the field value to exactly match the specified value. If + // the field value doesn't match, an error message is generated. + // + // ```proto + // message MyString { + // // value must equal `hello` + // string value = 1 [(buf.validate.field).string.const = "hello"]; + // } + // ``` + optional string const = 1 [(predefined).cel = { + id: "string.const" + expression: "this != getField(rules, 'const') ? 'value must equal `%s`'.format([getField(rules, 'const')]) : ''" + }]; + + // `len` dictates that the field value must have the specified + // number of characters (Unicode code points), which may differ from the number + // of bytes in the string. If the field value does not meet the specified + // length, an error message will be generated. + // + // ```proto + // message MyString { + // // value length must be 5 characters + // string value = 1 [(buf.validate.field).string.len = 5]; + // } + // ``` + optional uint64 len = 19 [(predefined).cel = { + id: "string.len" + expression: "uint(this.size()) != rules.len ? 'value length must be %s characters'.format([rules.len]) : ''" + }]; + + // `min_len` specifies that the field value must have at least the specified + // number of characters (Unicode code points), which may differ from the number + // of bytes in the string. If the field value contains fewer characters, an error + // message will be generated. + // + // ```proto + // message MyString { + // // value length must be at least 3 characters + // string value = 1 [(buf.validate.field).string.min_len = 3]; + // } + // ``` + optional uint64 min_len = 2 [(predefined).cel = { + id: "string.min_len" + expression: "uint(this.size()) < rules.min_len ? 'value length must be at least %s characters'.format([rules.min_len]) : ''" + }]; + + // `max_len` specifies that the field value must have no more than the specified + // number of characters (Unicode code points), which may differ from the + // number of bytes in the string. If the field value contains more characters, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value length must be at most 10 characters + // string value = 1 [(buf.validate.field).string.max_len = 10]; + // } + // ``` + optional uint64 max_len = 3 [(predefined).cel = { + id: "string.max_len" + expression: "uint(this.size()) > rules.max_len ? 'value length must be at most %s characters'.format([rules.max_len]) : ''" + }]; + + // `len_bytes` dictates that the field value must have the specified number of + // bytes. If the field value does not match the specified length in bytes, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value length must be 6 bytes + // string value = 1 [(buf.validate.field).string.len_bytes = 6]; + // } + // ``` + optional uint64 len_bytes = 20 [(predefined).cel = { + id: "string.len_bytes" + expression: "uint(bytes(this).size()) != rules.len_bytes ? 'value length must be %s bytes'.format([rules.len_bytes]) : ''" + }]; + + // `min_bytes` specifies that the field value must have at least the specified + // number of bytes. If the field value contains fewer bytes, an error message + // will be generated. + // + // ```proto + // message MyString { + // // value length must be at least 4 bytes + // string value = 1 [(buf.validate.field).string.min_bytes = 4]; + // } + // + // ``` + optional uint64 min_bytes = 4 [(predefined).cel = { + id: "string.min_bytes" + expression: "uint(bytes(this).size()) < rules.min_bytes ? 'value length must be at least %s bytes'.format([rules.min_bytes]) : ''" + }]; + + // `max_bytes` specifies that the field value must have no more than the + //specified number of bytes. If the field value contains more bytes, an + // error message will be generated. + // + // ```proto + // message MyString { + // // value length must be at most 8 bytes + // string value = 1 [(buf.validate.field).string.max_bytes = 8]; + // } + // ``` + optional uint64 max_bytes = 5 [(predefined).cel = { + id: "string.max_bytes" + expression: "uint(bytes(this).size()) > rules.max_bytes ? 'value length must be at most %s bytes'.format([rules.max_bytes]) : ''" + }]; + + // `pattern` specifies that the field value must match the specified + // regular expression (RE2 syntax), with the expression provided without any + // delimiters. If the field value doesn't match the regular expression, an + // error message will be generated. + // + // ```proto + // message MyString { + // // value does not match regex pattern `^[a-zA-Z]//$` + // string value = 1 [(buf.validate.field).string.pattern = "^[a-zA-Z]//$"]; + // } + // ``` + optional string pattern = 6 [(predefined).cel = { + id: "string.pattern" + expression: "!this.matches(rules.pattern) ? 'value does not match regex pattern `%s`'.format([rules.pattern]) : ''" + }]; + + // `prefix` specifies that the field value must have the + //specified substring at the beginning of the string. If the field value + // doesn't start with the specified prefix, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value does not have prefix `pre` + // string value = 1 [(buf.validate.field).string.prefix = "pre"]; + // } + // ``` + optional string prefix = 7 [(predefined).cel = { + id: "string.prefix" + expression: "!this.startsWith(rules.prefix) ? 'value does not have prefix `%s`'.format([rules.prefix]) : ''" + }]; + + // `suffix` specifies that the field value must have the + //specified substring at the end of the string. If the field value doesn't + // end with the specified suffix, an error message will be generated. + // + // ```proto + // message MyString { + // // value does not have suffix `post` + // string value = 1 [(buf.validate.field).string.suffix = "post"]; + // } + // ``` + optional string suffix = 8 [(predefined).cel = { + id: "string.suffix" + expression: "!this.endsWith(rules.suffix) ? 'value does not have suffix `%s`'.format([rules.suffix]) : ''" + }]; + + // `contains` specifies that the field value must have the + //specified substring anywhere in the string. If the field value doesn't + // contain the specified substring, an error message will be generated. + // + // ```proto + // message MyString { + // // value does not contain substring `inside`. + // string value = 1 [(buf.validate.field).string.contains = "inside"]; + // } + // ``` + optional string contains = 9 [(predefined).cel = { + id: "string.contains" + expression: "!this.contains(rules.contains) ? 'value does not contain substring `%s`'.format([rules.contains]) : ''" + }]; + + // `not_contains` specifies that the field value must not have the + //specified substring anywhere in the string. If the field value contains + // the specified substring, an error message will be generated. + // + // ```proto + // message MyString { + // // value contains substring `inside`. + // string value = 1 [(buf.validate.field).string.not_contains = "inside"]; + // } + // ``` + optional string not_contains = 23 [(predefined).cel = { + id: "string.not_contains" + expression: "this.contains(rules.not_contains) ? 'value contains substring `%s`'.format([rules.not_contains]) : ''" + }]; + + // `in` specifies that the field value must be equal to one of the specified + // values. If the field value isn't one of the specified values, an error + // message will be generated. + // + // ```proto + // message MyString { + // // value must be in list ["apple", "banana"] + // string value = 1 [(buf.validate.field).string.in = "apple", (buf.validate.field).string.in = "banana"]; + // } + // ``` + repeated string in = 10 [(predefined).cel = { + id: "string.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` specifies that the field value cannot be equal to any + // of the specified values. If the field value is one of the specified values, + // an error message will be generated. + // ```proto + // message MyString { + // // value must not be in list ["orange", "grape"] + // string value = 1 [(buf.validate.field).string.not_in = "orange", (buf.validate.field).string.not_in = "grape"]; + // } + // ``` + repeated string not_in = 11 [(predefined).cel = { + id: "string.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `WellKnown` rules provide advanced rules against common string + // patterns. + oneof well_known { + // `email` specifies that the field value must be a valid email address, for + // example "foo@example.com". + // + // Conforms to the definition for a valid email address from the [HTML standard](https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address). + // Note that this standard willfully deviates from [RFC 5322](https://datatracker.ietf.org/doc/html/rfc5322), + // which allows many unexpected forms of email addresses and will easily match + // a typographical error. + // + // If the field value isn't a valid email address, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid email address + // string value = 1 [(buf.validate.field).string.email = true]; + // } + // ``` + bool email = 12 [ + (predefined).cel = { + id: "string.email" + message: "value must be a valid email address" + expression: "!rules.email || this == '' || this.isEmail()" + }, + (predefined).cel = { + id: "string.email_empty" + message: "value is empty, which is not a valid email address" + expression: "!rules.email || this != ''" + } + ]; + + // `hostname` specifies that the field value must be a valid hostname, for + // example "foo.example.com". + // + // A valid hostname follows the rules below: + // - The name consists of one or more labels, separated by a dot ("."). + // - Each label can be 1 to 63 alphanumeric characters. + // - A label can contain hyphens ("-"), but must not start or end with a hyphen. + // - The right-most label must not be digits only. + // - The name can have a trailing dot—for example, "foo.example.com.". + // - The name can be 253 characters at most, excluding the optional trailing dot. + // + // If the field value isn't a valid hostname, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid hostname + // string value = 1 [(buf.validate.field).string.hostname = true]; + // } + // ``` + bool hostname = 13 [ + (predefined).cel = { + id: "string.hostname" + message: "value must be a valid hostname" + expression: "!rules.hostname || this == '' || this.isHostname()" + }, + (predefined).cel = { + id: "string.hostname_empty" + message: "value is empty, which is not a valid hostname" + expression: "!rules.hostname || this != ''" + } + ]; + + // `ip` specifies that the field value must be a valid IP (v4 or v6) address. + // + // IPv4 addresses are expected in the dotted decimal format—for example, "192.168.5.21". + // IPv6 addresses are expected in their text representation—for example, "::1", + // or "2001:0DB8:ABCD:0012::0". + // + // Both formats are well-defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). + // Zone identifiers for IPv6 addresses (for example, "fe80::a%en1") are supported. + // + // If the field value isn't a valid IP address, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid IP address + // string value = 1 [(buf.validate.field).string.ip = true]; + // } + // ``` + bool ip = 14 [ + (predefined).cel = { + id: "string.ip" + message: "value must be a valid IP address" + expression: "!rules.ip || this == '' || this.isIp()" + }, + (predefined).cel = { + id: "string.ip_empty" + message: "value is empty, which is not a valid IP address" + expression: "!rules.ip || this != ''" + } + ]; + + // `ipv4` specifies that the field value must be a valid IPv4 address—for + // example "192.168.5.21". If the field value isn't a valid IPv4 address, an + // error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv4 address + // string value = 1 [(buf.validate.field).string.ipv4 = true]; + // } + // ``` + bool ipv4 = 15 [ + (predefined).cel = { + id: "string.ipv4" + message: "value must be a valid IPv4 address" + expression: "!rules.ipv4 || this == '' || this.isIp(4)" + }, + (predefined).cel = { + id: "string.ipv4_empty" + message: "value is empty, which is not a valid IPv4 address" + expression: "!rules.ipv4 || this != ''" + } + ]; + + // `ipv6` specifies that the field value must be a valid IPv6 address—for + // example "::1", or "d7a:115c:a1e0:ab12:4843:cd96:626b:430b". If the field + // value is not a valid IPv6 address, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv6 address + // string value = 1 [(buf.validate.field).string.ipv6 = true]; + // } + // ``` + bool ipv6 = 16 [ + (predefined).cel = { + id: "string.ipv6" + message: "value must be a valid IPv6 address" + expression: "!rules.ipv6 || this == '' || this.isIp(6)" + }, + (predefined).cel = { + id: "string.ipv6_empty" + message: "value is empty, which is not a valid IPv6 address" + expression: "!rules.ipv6 || this != ''" + } + ]; + + // `uri` specifies that the field value must be a valid URI, for example + // "https://example.com/foo/bar?baz=quux#frag". + // + // URI is defined in the internet standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). + // Zone Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)). + // + // If the field value isn't a valid URI, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid URI + // string value = 1 [(buf.validate.field).string.uri = true]; + // } + // ``` + bool uri = 17 [ + (predefined).cel = { + id: "string.uri" + message: "value must be a valid URI" + expression: "!rules.uri || this == '' || this.isUri()" + }, + (predefined).cel = { + id: "string.uri_empty" + message: "value is empty, which is not a valid URI" + expression: "!rules.uri || this != ''" + } + ]; + + // `uri_ref` specifies that the field value must be a valid URI Reference—either + // a URI such as "https://example.com/foo/bar?baz=quux#frag", or a Relative + // Reference such as "./foo/bar?query". + // + // URI, URI Reference, and Relative Reference are defined in the internet + // standard [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986). Zone + // Identifiers in IPv6 address literals are supported ([RFC 6874](https://datatracker.ietf.org/doc/html/rfc6874)). + // + // If the field value isn't a valid URI Reference, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid URI Reference + // string value = 1 [(buf.validate.field).string.uri_ref = true]; + // } + // ``` + bool uri_ref = 18 [(predefined).cel = { + id: "string.uri_ref" + message: "value must be a valid URI Reference" + expression: "!rules.uri_ref || this.isUriRef()" + }]; + + // `address` specifies that the field value must be either a valid hostname + // (for example, "example.com"), or a valid IP (v4 or v6) address (for example, + // "192.168.0.1", or "::1"). If the field value isn't a valid hostname or IP, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid hostname, or ip address + // string value = 1 [(buf.validate.field).string.address = true]; + // } + // ``` + bool address = 21 [ + (predefined).cel = { + id: "string.address" + message: "value must be a valid hostname, or ip address" + expression: "!rules.address || this == '' || this.isHostname() || this.isIp()" + }, + (predefined).cel = { + id: "string.address_empty" + message: "value is empty, which is not a valid hostname, or ip address" + expression: "!rules.address || this != ''" + } + ]; + + // `uuid` specifies that the field value must be a valid UUID as defined by + // [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2). If the + // field value isn't a valid UUID, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid UUID + // string value = 1 [(buf.validate.field).string.uuid = true]; + // } + // ``` + bool uuid = 22 [ + (predefined).cel = { + id: "string.uuid" + message: "value must be a valid UUID" + expression: "!rules.uuid || this == '' || this.matches('^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$')" + }, + (predefined).cel = { + id: "string.uuid_empty" + message: "value is empty, which is not a valid UUID" + expression: "!rules.uuid || this != ''" + } + ]; + + // `tuuid` (trimmed UUID) specifies that the field value must be a valid UUID as + // defined by [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2) with all dashes + // omitted. If the field value isn't a valid UUID without dashes, an error message + // will be generated. + // + // ```proto + // message MyString { + // // value must be a valid trimmed UUID + // string value = 1 [(buf.validate.field).string.tuuid = true]; + // } + // ``` + bool tuuid = 33 [ + (predefined).cel = { + id: "string.tuuid" + message: "value must be a valid trimmed UUID" + expression: "!rules.tuuid || this == '' || this.matches('^[0-9a-fA-F]{32}$')" + }, + (predefined).cel = { + id: "string.tuuid_empty" + message: "value is empty, which is not a valid trimmed UUID" + expression: "!rules.tuuid || this != ''" + } + ]; + + // `ip_with_prefixlen` specifies that the field value must be a valid IP + // (v4 or v6) address with prefix length—for example, "192.168.5.21/16" or + // "2001:0DB8:ABCD:0012::F1/64". If the field value isn't a valid IP with + // prefix length, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IP with prefix length + // string value = 1 [(buf.validate.field).string.ip_with_prefixlen = true]; + // } + // ``` + bool ip_with_prefixlen = 26 [ + (predefined).cel = { + id: "string.ip_with_prefixlen" + message: "value must be a valid IP prefix" + expression: "!rules.ip_with_prefixlen || this == '' || this.isIpPrefix()" + }, + (predefined).cel = { + id: "string.ip_with_prefixlen_empty" + message: "value is empty, which is not a valid IP prefix" + expression: "!rules.ip_with_prefixlen || this != ''" + } + ]; + + // `ipv4_with_prefixlen` specifies that the field value must be a valid + // IPv4 address with prefix length—for example, "192.168.5.21/16". If the + // field value isn't a valid IPv4 address with prefix length, an error + // message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv4 address with prefix length + // string value = 1 [(buf.validate.field).string.ipv4_with_prefixlen = true]; + // } + // ``` + bool ipv4_with_prefixlen = 27 [ + (predefined).cel = { + id: "string.ipv4_with_prefixlen" + message: "value must be a valid IPv4 address with prefix length" + expression: "!rules.ipv4_with_prefixlen || this == '' || this.isIpPrefix(4)" + }, + (predefined).cel = { + id: "string.ipv4_with_prefixlen_empty" + message: "value is empty, which is not a valid IPv4 address with prefix length" + expression: "!rules.ipv4_with_prefixlen || this != ''" + } + ]; + + // `ipv6_with_prefixlen` specifies that the field value must be a valid + // IPv6 address with prefix length—for example, "2001:0DB8:ABCD:0012::F1/64". + // If the field value is not a valid IPv6 address with prefix length, + // an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv6 address prefix length + // string value = 1 [(buf.validate.field).string.ipv6_with_prefixlen = true]; + // } + // ``` + bool ipv6_with_prefixlen = 28 [ + (predefined).cel = { + id: "string.ipv6_with_prefixlen" + message: "value must be a valid IPv6 address with prefix length" + expression: "!rules.ipv6_with_prefixlen || this == '' || this.isIpPrefix(6)" + }, + (predefined).cel = { + id: "string.ipv6_with_prefixlen_empty" + message: "value is empty, which is not a valid IPv6 address with prefix length" + expression: "!rules.ipv6_with_prefixlen || this != ''" + } + ]; + + // `ip_prefix` specifies that the field value must be a valid IP (v4 or v6) + // prefix—for example, "192.168.0.0/16" or "2001:0DB8:ABCD:0012::0/64". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the + // prefix, and the remaining 64 bits must be zero. + // + // If the field value isn't a valid IP prefix, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid IP prefix + // string value = 1 [(buf.validate.field).string.ip_prefix = true]; + // } + // ``` + bool ip_prefix = 29 [ + (predefined).cel = { + id: "string.ip_prefix" + message: "value must be a valid IP prefix" + expression: "!rules.ip_prefix || this == '' || this.isIpPrefix(true)" + }, + (predefined).cel = { + id: "string.ip_prefix_empty" + message: "value is empty, which is not a valid IP prefix" + expression: "!rules.ip_prefix || this != ''" + } + ]; + + // `ipv4_prefix` specifies that the field value must be a valid IPv4 + // prefix, for example "192.168.0.0/16". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "192.168.0.0/16" designates the left-most 16 bits for the prefix, + // and the remaining 16 bits must be zero. + // + // If the field value isn't a valid IPv4 prefix, an error message + // will be generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv4 prefix + // string value = 1 [(buf.validate.field).string.ipv4_prefix = true]; + // } + // ``` + bool ipv4_prefix = 30 [ + (predefined).cel = { + id: "string.ipv4_prefix" + message: "value must be a valid IPv4 prefix" + expression: "!rules.ipv4_prefix || this == '' || this.isIpPrefix(4, true)" + }, + (predefined).cel = { + id: "string.ipv4_prefix_empty" + message: "value is empty, which is not a valid IPv4 prefix" + expression: "!rules.ipv4_prefix || this != ''" + } + ]; + + // `ipv6_prefix` specifies that the field value must be a valid IPv6 prefix—for + // example, "2001:0DB8:ABCD:0012::0/64". + // + // The prefix must have all zeros for the unmasked bits. For example, + // "2001:0DB8:ABCD:0012::0/64" designates the left-most 64 bits for the + // prefix, and the remaining 64 bits must be zero. + // + // If the field value is not a valid IPv6 prefix, an error message will be + // generated. + // + // ```proto + // message MyString { + // // value must be a valid IPv6 prefix + // string value = 1 [(buf.validate.field).string.ipv6_prefix = true]; + // } + // ``` + bool ipv6_prefix = 31 [ + (predefined).cel = { + id: "string.ipv6_prefix" + message: "value must be a valid IPv6 prefix" + expression: "!rules.ipv6_prefix || this == '' || this.isIpPrefix(6, true)" + }, + (predefined).cel = { + id: "string.ipv6_prefix_empty" + message: "value is empty, which is not a valid IPv6 prefix" + expression: "!rules.ipv6_prefix || this != ''" + } + ]; + + // `host_and_port` specifies that the field value must be valid host/port + // pair—for example, "example.com:8080". + // + // The host can be one of: + //- An IPv4 address in dotted decimal format—for example, "192.168.5.21". + //- An IPv6 address enclosed in square brackets—for example, "[2001:0DB8:ABCD:0012::F1]". + //- A hostname—for example, "example.com". + // + // The port is separated by a colon. It must be non-empty, with a decimal number + // in the range of 0-65535, inclusive. + bool host_and_port = 32 [ + (predefined).cel = { + id: "string.host_and_port" + message: "value must be a valid host (hostname or IP address) and port pair" + expression: "!rules.host_and_port || this == '' || this.isHostAndPort(true)" + }, + (predefined).cel = { + id: "string.host_and_port_empty" + message: "value is empty, which is not a valid host and port pair" + expression: "!rules.host_and_port || this != ''" + } + ]; + + // `well_known_regex` specifies a common well-known pattern + // defined as a regex. If the field value doesn't match the well-known + // regex, an error message will be generated. + // + // ```proto + // message MyString { + // // value must be a valid HTTP header value + // string value = 1 [(buf.validate.field).string.well_known_regex = KNOWN_REGEX_HTTP_HEADER_VALUE]; + // } + // ``` + // + // #### KnownRegex + // + // `well_known_regex` contains some well-known patterns. + // + // | Name | Number | Description | + // |-------------------------------|--------|-------------------------------------------| + // | KNOWN_REGEX_UNSPECIFIED | 0 | | + // | KNOWN_REGEX_HTTP_HEADER_NAME | 1 | HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2) | + // | KNOWN_REGEX_HTTP_HEADER_VALUE | 2 | HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4) | + KnownRegex well_known_regex = 24 [ + (predefined).cel = { + id: "string.well_known_regex.header_name" + message: "value must be a valid HTTP header name" + expression: + "rules.well_known_regex != 1 || this == '' || this.matches(!has(rules.strict) || rules.strict ?" + "'^:?[0-9a-zA-Z!#$%&\\'*+-.^_|~\\x60]+$' :" + "'^[^\\u0000\\u000A\\u000D]+$')" + }, + (predefined).cel = { + id: "string.well_known_regex.header_name_empty" + message: "value is empty, which is not a valid HTTP header name" + expression: "rules.well_known_regex != 1 || this != ''" + }, + (predefined).cel = { + id: "string.well_known_regex.header_value" + message: "value must be a valid HTTP header value" + expression: + "rules.well_known_regex != 2 || this.matches(!has(rules.strict) || rules.strict ?" + "'^[^\\u0000-\\u0008\\u000A-\\u001F\\u007F]*$' :" + "'^[^\\u0000\\u000A\\u000D]*$')" + } + ]; + } + + // This applies to regexes `HTTP_HEADER_NAME` and `HTTP_HEADER_VALUE` to + // enable strict header validation. By default, this is true, and HTTP header + // validations are [RFC-compliant](https://datatracker.ietf.org/doc/html/rfc7230#section-3). Setting to false will enable looser + // validations that only disallow `\r\n\0` characters, which can be used to + // bypass header matching rules. + // + // ```proto + // message MyString { + // // The field `value` must have be a valid HTTP headers, but not enforced with strict rules. + // string value = 1 [(buf.validate.field).string.strict = false]; + // } + // ``` + optional bool strict = 25; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyString { + // string value = 1 [ + // (buf.validate.field).string.example = "hello", + // (buf.validate.field).string.example = "world" + // ]; + // } + // ``` + repeated string example = 34 [(predefined).cel = { + id: "string.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// KnownRegex contains some well-known patterns. +enum KnownRegex { + KNOWN_REGEX_UNSPECIFIED = 0; + + // HTTP header name as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2). + KNOWN_REGEX_HTTP_HEADER_NAME = 1; + + // HTTP header value as defined by [RFC 7230](https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4). + KNOWN_REGEX_HTTP_HEADER_VALUE = 2; +} + +// BytesRules describe the rules applied to `bytes` values. These rules +// may also be applied to the `google.protobuf.BytesValue` Well-Known-Type. +message BytesRules { + // `const` requires the field value to exactly match the specified bytes + // value. If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be "\x01\x02\x03\x04" + // bytes value = 1 [(buf.validate.field).bytes.const = "\x01\x02\x03\x04"]; + // } + // ``` + optional bytes const = 1 [(predefined).cel = { + id: "bytes.const" + expression: "this != getField(rules, 'const') ? 'value must be %x'.format([getField(rules, 'const')]) : ''" + }]; + + // `len` requires the field value to have the specified length in bytes. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // message MyBytes { + // // value length must be 4 bytes. + // optional bytes value = 1 [(buf.validate.field).bytes.len = 4]; + // } + // ``` + optional uint64 len = 13 [(predefined).cel = { + id: "bytes.len" + expression: "uint(this.size()) != rules.len ? 'value length must be %s bytes'.format([rules.len]) : ''" + }]; + + // `min_len` requires the field value to have at least the specified minimum + // length in bytes. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value length must be at least 2 bytes. + // optional bytes value = 1 [(buf.validate.field).bytes.min_len = 2]; + // } + // ``` + optional uint64 min_len = 2 [(predefined).cel = { + id: "bytes.min_len" + expression: "uint(this.size()) < rules.min_len ? 'value length must be at least %s bytes'.format([rules.min_len]) : ''" + }]; + + // `max_len` requires the field value to have at most the specified maximum + // length in bytes. + // If the field value exceeds the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be at most 6 bytes. + // optional bytes value = 1 [(buf.validate.field).bytes.max_len = 6]; + // } + // ``` + optional uint64 max_len = 3 [(predefined).cel = { + id: "bytes.max_len" + expression: "uint(this.size()) > rules.max_len ? 'value must be at most %s bytes'.format([rules.max_len]) : ''" + }]; + + // `pattern` requires the field value to match the specified regular + // expression ([RE2 syntax](https://github.com/google/re2/wiki/Syntax)). + // The value of the field must be valid UTF-8 or validation will fail with a + // runtime error. + // If the field value doesn't match the pattern, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must match regex pattern "^[a-zA-Z0-9]+$". + // optional bytes value = 1 [(buf.validate.field).bytes.pattern = "^[a-zA-Z0-9]+$"]; + // } + // ``` + optional string pattern = 4 [(predefined).cel = { + id: "bytes.pattern" + expression: "!string(this).matches(rules.pattern) ? 'value must match regex pattern `%s`'.format([rules.pattern]) : ''" + }]; + + // `prefix` requires the field value to have the specified bytes at the + // beginning of the string. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value does not have prefix \x01\x02 + // optional bytes value = 1 [(buf.validate.field).bytes.prefix = "\x01\x02"]; + // } + // ``` + optional bytes prefix = 5 [(predefined).cel = { + id: "bytes.prefix" + expression: "!this.startsWith(rules.prefix) ? 'value does not have prefix %x'.format([rules.prefix]) : ''" + }]; + + // `suffix` requires the field value to have the specified bytes at the end + // of the string. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```proto + // message MyBytes { + // // value does not have suffix \x03\x04 + // optional bytes value = 1 [(buf.validate.field).bytes.suffix = "\x03\x04"]; + // } + // ``` + optional bytes suffix = 6 [(predefined).cel = { + id: "bytes.suffix" + expression: "!this.endsWith(rules.suffix) ? 'value does not have suffix %x'.format([rules.suffix]) : ''" + }]; + + // `contains` requires the field value to have the specified bytes anywhere in + // the string. + // If the field value doesn't meet the requirement, an error message is generated. + // + // ```protobuf + // message MyBytes { + // // value does not contain \x02\x03 + // optional bytes value = 1 [(buf.validate.field).bytes.contains = "\x02\x03"]; + // } + // ``` + optional bytes contains = 7 [(predefined).cel = { + id: "bytes.contains" + expression: "!this.contains(rules.contains) ? 'value does not contain %x'.format([rules.contains]) : ''" + }]; + + // `in` requires the field value to be equal to one of the specified + // values. If the field value doesn't match any of the specified values, an + // error message is generated. + // + // ```protobuf + // message MyBytes { + // // value must in ["\x01\x02", "\x02\x03", "\x03\x04"] + // optional bytes value = 1 [(buf.validate.field).bytes.in = {"\x01\x02", "\x02\x03", "\x03\x04"}]; + // } + // ``` + repeated bytes in = 8 [(predefined).cel = { + id: "bytes.in" + expression: "getField(rules, 'in').size() > 0 && !(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to be not equal to any of the specified + // values. + // If the field value matches any of the specified values, an error message is + // generated. + // + // ```proto + // message MyBytes { + // // value must not in ["\x01\x02", "\x02\x03", "\x03\x04"] + // optional bytes value = 1 [(buf.validate.field).bytes.not_in = {"\x01\x02", "\x02\x03", "\x03\x04"}]; + // } + // ``` + repeated bytes not_in = 9 [(predefined).cel = { + id: "bytes.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // WellKnown rules provide advanced rules against common byte + // patterns + oneof well_known { + // `ip` ensures that the field `value` is a valid IP address (v4 or v6) in byte format. + // If the field value doesn't meet this rule, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be a valid IP address + // optional bytes value = 1 [(buf.validate.field).bytes.ip = true]; + // } + // ``` + bool ip = 10 [ + (predefined).cel = { + id: "bytes.ip" + message: "value must be a valid IP address" + expression: "!rules.ip || this.size() == 0 || this.size() == 4 || this.size() == 16" + }, + (predefined).cel = { + id: "bytes.ip_empty" + message: "value is empty, which is not a valid IP address" + expression: "!rules.ip || this.size() != 0" + } + ]; + + // `ipv4` ensures that the field `value` is a valid IPv4 address in byte format. + // If the field value doesn't meet this rule, an error message is generated. + // + // ```proto + // message MyBytes { + // // value must be a valid IPv4 address + // optional bytes value = 1 [(buf.validate.field).bytes.ipv4 = true]; + // } + // ``` + bool ipv4 = 11 [ + (predefined).cel = { + id: "bytes.ipv4" + message: "value must be a valid IPv4 address" + expression: "!rules.ipv4 || this.size() == 0 || this.size() == 4" + }, + (predefined).cel = { + id: "bytes.ipv4_empty" + message: "value is empty, which is not a valid IPv4 address" + expression: "!rules.ipv4 || this.size() != 0" + } + ]; + + // `ipv6` ensures that the field `value` is a valid IPv6 address in byte format. + // If the field value doesn't meet this rule, an error message is generated. + // ```proto + // message MyBytes { + // // value must be a valid IPv6 address + // optional bytes value = 1 [(buf.validate.field).bytes.ipv6 = true]; + // } + // ``` + bool ipv6 = 12 [ + (predefined).cel = { + id: "bytes.ipv6" + message: "value must be a valid IPv6 address" + expression: "!rules.ipv6 || this.size() == 0 || this.size() == 16" + }, + (predefined).cel = { + id: "bytes.ipv6_empty" + message: "value is empty, which is not a valid IPv6 address" + expression: "!rules.ipv6 || this.size() != 0" + } + ]; + } + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyBytes { + // bytes value = 1 [ + // (buf.validate.field).bytes.example = "\x01\x02", + // (buf.validate.field).bytes.example = "\x02\x03" + // ]; + // } + // ``` + repeated bytes example = 14 [(predefined).cel = { + id: "bytes.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// EnumRules describe the rules applied to `enum` values. +message EnumRules { + // `const` requires the field value to exactly match the specified enum value. + // If the field value doesn't match, an error message is generated. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must be exactly MY_ENUM_VALUE1. + // MyEnum value = 1 [(buf.validate.field).enum.const = 1]; + // } + // ``` + optional int32 const = 1 [(predefined).cel = { + id: "enum.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + + // `defined_only` requires the field value to be one of the defined values for + // this enum, failing on any undefined value. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must be a defined value of MyEnum. + // MyEnum value = 1 [(buf.validate.field).enum.defined_only = true]; + // } + // ``` + optional bool defined_only = 2; + + // `in` requires the field value to be equal to one of the + //specified enum values. If the field value doesn't match any of the + //specified values, an error message is generated. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must be equal to one of the specified values. + // MyEnum value = 1 [(buf.validate.field).enum = { in: [1, 2]}]; + // } + // ``` + repeated int32 in = 3 [(predefined).cel = { + id: "enum.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` requires the field value to be not equal to any of the + //specified enum values. If the field value matches one of the specified + // values, an error message is generated. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // // The field `value` must not be equal to any of the specified values. + // MyEnum value = 1 [(buf.validate.field).enum = { not_in: [1, 2]}]; + // } + // ``` + repeated int32 not_in = 4 [(predefined).cel = { + id: "enum.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // enum MyEnum { + // MY_ENUM_UNSPECIFIED = 0; + // MY_ENUM_VALUE1 = 1; + // MY_ENUM_VALUE2 = 2; + // } + // + // message MyMessage { + // (buf.validate.field).enum.example = 1, + // (buf.validate.field).enum.example = 2 + // } + // ``` + repeated int32 example = 5 [(predefined).cel = { + id: "enum.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// RepeatedRules describe the rules applied to `repeated` values. +message RepeatedRules { + // `min_items` requires that this field must contain at least the specified + // minimum number of items. + // + // Note that `min_items = 1` is equivalent to setting a field as `required`. + // + // ```proto + // message MyRepeated { + // // value must contain at least 2 items + // repeated string value = 1 [(buf.validate.field).repeated.min_items = 2]; + // } + // ``` + optional uint64 min_items = 1 [(predefined).cel = { + id: "repeated.min_items" + expression: "uint(this.size()) < rules.min_items ? 'value must contain at least %d item(s)'.format([rules.min_items]) : ''" + }]; + + // `max_items` denotes that this field must not exceed a + // certain number of items as the upper limit. If the field contains more + // items than specified, an error message will be generated, requiring the + // field to maintain no more than the specified number of items. + // + // ```proto + // message MyRepeated { + // // value must contain no more than 3 item(s) + // repeated string value = 1 [(buf.validate.field).repeated.max_items = 3]; + // } + // ``` + optional uint64 max_items = 2 [(predefined).cel = { + id: "repeated.max_items" + expression: "uint(this.size()) > rules.max_items ? 'value must contain no more than %s item(s)'.format([rules.max_items]) : ''" + }]; + + // `unique` indicates that all elements in this field must + // be unique. This rule is strictly applicable to scalar and enum + // types, with message types not being supported. + // + // ```proto + // message MyRepeated { + // // repeated value must contain unique items + // repeated string value = 1 [(buf.validate.field).repeated.unique = true]; + // } + // ``` + optional bool unique = 3 [(predefined).cel = { + id: "repeated.unique" + message: "repeated value must contain unique items" + expression: "!rules.unique || this.unique()" + }]; + + // `items` details the rules to be applied to each item + // in the field. Even for repeated message fields, validation is executed + // against each item unless `ignore` is specified. + // + // ```proto + // message MyRepeated { + // // The items in the field `value` must follow the specified rules. + // repeated string value = 1 [(buf.validate.field).repeated.items = { + // string: { + // min_len: 3 + // max_len: 10 + // } + // }]; + // } + // ``` + // + // Note that the `required` rule does not apply. Repeated items + // cannot be unset. + optional FieldRules items = 4; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// MapRules describe the rules applied to `map` values. +message MapRules { + // Specifies the minimum number of key-value pairs allowed. If the field has + // fewer key-value pairs than specified, an error message is generated. + // + // ```proto + // message MyMap { + // // The field `value` must have at least 2 key-value pairs. + // map value = 1 [(buf.validate.field).map.min_pairs = 2]; + // } + // ``` + optional uint64 min_pairs = 1 [(predefined).cel = { + id: "map.min_pairs" + expression: "uint(this.size()) < rules.min_pairs ? 'map must be at least %d entries'.format([rules.min_pairs]) : ''" + }]; + + // Specifies the maximum number of key-value pairs allowed. If the field has + // more key-value pairs than specified, an error message is generated. + // + // ```proto + // message MyMap { + // // The field `value` must have at most 3 key-value pairs. + // map value = 1 [(buf.validate.field).map.max_pairs = 3]; + // } + // ``` + optional uint64 max_pairs = 2 [(predefined).cel = { + id: "map.max_pairs" + expression: "uint(this.size()) > rules.max_pairs ? 'map must be at most %d entries'.format([rules.max_pairs]) : ''" + }]; + + // Specifies the rules to be applied to each key in the field. + // + // ```proto + // message MyMap { + // // The keys in the field `value` must follow the specified rules. + // map value = 1 [(buf.validate.field).map.keys = { + // string: { + // min_len: 3 + // max_len: 10 + // } + // }]; + // } + // ``` + // + // Note that the `required` rule does not apply. Map keys cannot be unset. + optional FieldRules keys = 4; + + // Specifies the rules to be applied to the value of each key in the + // field. Message values will still have their validations evaluated unless + // `ignore` is specified. + // + // ```proto + // message MyMap { + // // The values in the field `value` must follow the specified rules. + // map value = 1 [(buf.validate.field).map.values = { + // string: { + // min_len: 5 + // max_len: 20 + // } + // }]; + // } + // ``` + // Note that the `required` rule does not apply. Map values cannot be unset. + optional FieldRules values = 5; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// AnyRules describe rules applied exclusively to the `google.protobuf.Any` well-known type. +message AnyRules { + // `in` requires the field's `type_url` to be equal to one of the + //specified values. If it doesn't match any of the specified values, an error + // message is generated. + // + // ```proto + // message MyAny { + // // The `value` field must have a `type_url` equal to one of the specified values. + // google.protobuf.Any value = 1 [(buf.validate.field).any = { + // in: ["type.googleapis.com/MyType1", "type.googleapis.com/MyType2"] + // }]; + // } + // ``` + repeated string in = 2; + + // requires the field's type_url to be not equal to any of the specified values. If it matches any of the specified values, an error message is generated. + // + // ```proto + // message MyAny { + // // The `value` field must not have a `type_url` equal to any of the specified values. + // google.protobuf.Any value = 1 [(buf.validate.field).any = { + // not_in: ["type.googleapis.com/ForbiddenType1", "type.googleapis.com/ForbiddenType2"] + // }]; + // } + // ``` + repeated string not_in = 3; +} + +// DurationRules describe the rules applied exclusively to the `google.protobuf.Duration` well-known type. +message DurationRules { + // `const` dictates that the field must match the specified value of the `google.protobuf.Duration` type exactly. + // If the field's value deviates from the specified value, an error message + // will be generated. + // + // ```proto + // message MyDuration { + // // value must equal 5s + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.const = "5s"]; + // } + // ``` + optional google.protobuf.Duration const = 2 [(predefined).cel = { + id: "duration.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // `lt` stipulates that the field must be less than the specified value of the `google.protobuf.Duration` type, + // exclusive. If the field's value is greater than or equal to the specified + // value, an error message will be generated. + // + // ```proto + // message MyDuration { + // // value must be less than 5s + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = "5s"]; + // } + // ``` + google.protobuf.Duration lt = 3 [(predefined).cel = { + id: "duration.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // `lte` indicates that the field must be less than or equal to the specified + // value of the `google.protobuf.Duration` type, inclusive. If the field's value is greater than the specified value, + // an error message will be generated. + // + // ```proto + // message MyDuration { + // // value must be less than or equal to 10s + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lte = "10s"]; + // } + // ``` + google.protobuf.Duration lte = 4 [(predefined).cel = { + id: "duration.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + } + oneof greater_than { + // `gt` requires the duration field value to be greater than the specified + // value (exclusive). If the value of `gt` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyDuration { + // // duration must be greater than 5s [duration.gt] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gt = { seconds: 5 }]; + // + // // duration must be greater than 5s and less than 10s [duration.gt_lt] + // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gt: { seconds: 5 }, lt: { seconds: 10 } }]; + // + // // duration must be greater than 10s or less than 5s [duration.gt_lt_exclusive] + // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gt: { seconds: 10 }, lt: { seconds: 5 } }]; + // } + // ``` + google.protobuf.Duration gt = 5 [ + (predefined).cel = { + id: "duration.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "duration.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the duration field value to be greater than or equal to the + // specified value (exclusive). If the value of `gte` is larger than a + // specified `lt` or `lte`, the range is reversed, and the field value must + // be outside the specified range. If the field value doesn't meet the + // required conditions, an error message is generated. + // + // ```proto + // message MyDuration { + // // duration must be greater than or equal to 5s [duration.gte] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.gte = { seconds: 5 }]; + // + // // duration must be greater than or equal to 5s and less than 10s [duration.gte_lt] + // google.protobuf.Duration another_value = 2 [(buf.validate.field).duration = { gte: { seconds: 5 }, lt: { seconds: 10 } }]; + // + // // duration must be greater than or equal to 10s or less than 5s [duration.gte_lt_exclusive] + // google.protobuf.Duration other_value = 3 [(buf.validate.field).duration = { gte: { seconds: 10 }, lt: { seconds: 5 } }]; + // } + // ``` + google.protobuf.Duration gte = 6 [ + (predefined).cel = { + id: "duration.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "duration.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + } + + // `in` asserts that the field must be equal to one of the specified values of the `google.protobuf.Duration` type. + // If the field's value doesn't correspond to any of the specified values, + // an error message will be generated. + // + // ```proto + // message MyDuration { + // // value must be in list [1s, 2s, 3s] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.in = ["1s", "2s", "3s"]]; + // } + // ``` + repeated google.protobuf.Duration in = 7 [(predefined).cel = { + id: "duration.in" + expression: "!(this in getField(rules, 'in')) ? 'value must be in list %s'.format([getField(rules, 'in')]) : ''" + }]; + + // `not_in` denotes that the field must not be equal to + // any of the specified values of the `google.protobuf.Duration` type. + // If the field's value matches any of these values, an error message will be + // generated. + // + // ```proto + // message MyDuration { + // // value must not be in list [1s, 2s, 3s] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.not_in = ["1s", "2s", "3s"]]; + // } + // ``` + repeated google.protobuf.Duration not_in = 8 [(predefined).cel = { + id: "duration.not_in" + expression: "this in rules.not_in ? 'value must not be in list %s'.format([rules.not_in]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyDuration { + // google.protobuf.Duration value = 1 [ + // (buf.validate.field).duration.example = { seconds: 1 }, + // (buf.validate.field).duration.example = { seconds: 2 }, + // ]; + // } + // ``` + repeated google.protobuf.Duration example = 9 [(predefined).cel = { + id: "duration.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// TimestampRules describe the rules applied exclusively to the `google.protobuf.Timestamp` well-known type. +message TimestampRules { + // `const` dictates that this field, of the `google.protobuf.Timestamp` type, must exactly match the specified value. If the field value doesn't correspond to the specified timestamp, an error message will be generated. + // + // ```proto + // message MyTimestamp { + // // value must equal 2023-05-03T10:00:00Z + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.const = {seconds: 1727998800}]; + // } + // ``` + optional google.protobuf.Timestamp const = 2 [(predefined).cel = { + id: "timestamp.const" + expression: "this != getField(rules, 'const') ? 'value must equal %s'.format([getField(rules, 'const')]) : ''" + }]; + oneof less_than { + // requires the duration field value to be less than the specified value (field < value). If the field value doesn't meet the required conditions, an error message is generated. + // + // ```proto + // message MyDuration { + // // duration must be less than 'P3D' [duration.lt] + // google.protobuf.Duration value = 1 [(buf.validate.field).duration.lt = { seconds: 259200 }]; + // } + // ``` + google.protobuf.Timestamp lt = 3 [(predefined).cel = { + id: "timestamp.lt" + expression: + "!has(rules.gte) && !has(rules.gt) && this >= rules.lt" + "? 'value must be less than %s'.format([rules.lt]) : ''" + }]; + + // requires the timestamp field value to be less than or equal to the specified value (field <= value). If the field value doesn't meet the required conditions, an error message is generated. + // + // ```proto + // message MyTimestamp { + // // timestamp must be less than or equal to '2023-05-14T00:00:00Z' [timestamp.lte] + // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.lte = { seconds: 1678867200 }]; + // } + // ``` + google.protobuf.Timestamp lte = 4 [(predefined).cel = { + id: "timestamp.lte" + expression: + "!has(rules.gte) && !has(rules.gt) && this > rules.lte" + "? 'value must be less than or equal to %s'.format([rules.lte]) : ''" + }]; + + // `lt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be less than the current time. `lt_now` can only be used with the `within` rule. + // + // ```proto + // message MyTimestamp { + // // value must be less than now + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.lt_now = true]; + // } + // ``` + bool lt_now = 7 [(predefined).cel = { + id: "timestamp.lt_now" + expression: "(rules.lt_now && this > now) ? 'value must be less than now' : ''" + }]; + } + oneof greater_than { + // `gt` requires the timestamp field value to be greater than the specified + // value (exclusive). If the value of `gt` is larger than a specified `lt` + // or `lte`, the range is reversed, and the field value must be outside the + // specified range. If the field value doesn't meet the required conditions, + // an error message is generated. + // + // ```proto + // message MyTimestamp { + // // timestamp must be greater than '2023-01-01T00:00:00Z' [timestamp.gt] + // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gt = { seconds: 1672444800 }]; + // + // // timestamp must be greater than '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gt_lt] + // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gt: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }]; + // + // // timestamp must be greater than '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gt_lt_exclusive] + // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gt: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }]; + // } + // ``` + google.protobuf.Timestamp gt = 5 [ + (predefined).cel = { + id: "timestamp.gt" + expression: + "!has(rules.lt) && !has(rules.lte) && this <= rules.gt" + "? 'value must be greater than %s'.format([rules.gt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gt && (this >= rules.lt || this <= rules.gt)" + "? 'value must be greater than %s and less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gt && (rules.lt <= this && this <= rules.gt)" + "? 'value must be greater than %s or less than %s'.format([rules.gt, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gt && (this > rules.lte || this <= rules.gt)" + "? 'value must be greater than %s and less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + }, + (predefined).cel = { + id: "timestamp.gt_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gt && (rules.lte < this && this <= rules.gt)" + "? 'value must be greater than %s or less than or equal to %s'.format([rules.gt, rules.lte]) : ''" + } + ]; + + // `gte` requires the timestamp field value to be greater than or equal to the + // specified value (exclusive). If the value of `gte` is larger than a + // specified `lt` or `lte`, the range is reversed, and the field value + // must be outside the specified range. If the field value doesn't meet + // the required conditions, an error message is generated. + // + // ```proto + // message MyTimestamp { + // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' [timestamp.gte] + // google.protobuf.Timestamp value = 1 [(buf.validate.field).timestamp.gte = { seconds: 1672444800 }]; + // + // // timestamp must be greater than or equal to '2023-01-01T00:00:00Z' and less than '2023-01-02T00:00:00Z' [timestamp.gte_lt] + // google.protobuf.Timestamp another_value = 2 [(buf.validate.field).timestamp = { gte: { seconds: 1672444800 }, lt: { seconds: 1672531200 } }]; + // + // // timestamp must be greater than or equal to '2023-01-02T00:00:00Z' or less than '2023-01-01T00:00:00Z' [timestamp.gte_lt_exclusive] + // google.protobuf.Timestamp other_value = 3 [(buf.validate.field).timestamp = { gte: { seconds: 1672531200 }, lt: { seconds: 1672444800 } }]; + // } + // ``` + google.protobuf.Timestamp gte = 6 [ + (predefined).cel = { + id: "timestamp.gte" + expression: + "!has(rules.lt) && !has(rules.lte) && this < rules.gte" + "? 'value must be greater than or equal to %s'.format([rules.gte]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lt" + expression: + "has(rules.lt) && rules.lt >= rules.gte && (this >= rules.lt || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lt_exclusive" + expression: + "has(rules.lt) && rules.lt < rules.gte && (rules.lt <= this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than %s'.format([rules.gte, rules.lt]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lte" + expression: + "has(rules.lte) && rules.lte >= rules.gte && (this > rules.lte || this < rules.gte)" + "? 'value must be greater than or equal to %s and less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + }, + (predefined).cel = { + id: "timestamp.gte_lte_exclusive" + expression: + "has(rules.lte) && rules.lte < rules.gte && (rules.lte < this && this < rules.gte)" + "? 'value must be greater than or equal to %s or less than or equal to %s'.format([rules.gte, rules.lte]) : ''" + } + ]; + + // `gt_now` specifies that this field, of the `google.protobuf.Timestamp` type, must be greater than the current time. `gt_now` can only be used with the `within` rule. + // + // ```proto + // message MyTimestamp { + // // value must be greater than now + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.gt_now = true]; + // } + // ``` + bool gt_now = 8 [(predefined).cel = { + id: "timestamp.gt_now" + expression: "(rules.gt_now && this < now) ? 'value must be greater than now' : ''" + }]; + } + + // `within` specifies that this field, of the `google.protobuf.Timestamp` type, must be within the specified duration of the current time. If the field value isn't within the duration, an error message is generated. + // + // ```proto + // message MyTimestamp { + // // value must be within 1 hour of now + // google.protobuf.Timestamp created_at = 1 [(buf.validate.field).timestamp.within = {seconds: 3600}]; + // } + // ``` + optional google.protobuf.Duration within = 9 [(predefined).cel = { + id: "timestamp.within" + expression: "this < now-rules.within || this > now+rules.within ? 'value must be within %s of now'.format([rules.within]) : ''" + }]; + + // `example` specifies values that the field may have. These values SHOULD + // conform to other rules. `example` values will not impact validation + // but may be used as helpful guidance on how to populate the given field. + // + // ```proto + // message MyTimestamp { + // google.protobuf.Timestamp value = 1 [ + // (buf.validate.field).timestamp.example = { seconds: 1672444800 }, + // (buf.validate.field).timestamp.example = { seconds: 1672531200 }, + // ]; + // } + // ``` + repeated google.protobuf.Timestamp example = 10 [(predefined).cel = { + id: "timestamp.example" + expression: "true" + }]; + + // Extension fields in this range that have the (buf.validate.predefined) + // option set will be treated as predefined field rules that can then be + // set on the field options of other fields to apply field rules. + // Extension numbers 1000 to 99999 are reserved for extension numbers that are + // defined in the [Protobuf Global Extension Registry][1]. Extension numbers + // above this range are reserved for extension numbers that are not explicitly + // assigned. For rules defined in publicly-consumed schemas, use of extensions + // above 99999 is discouraged due to the risk of conflicts. + // + // [1]: https://github.com/protocolbuffers/protobuf/blob/main/docs/options.md + extensions 1000 to max; +} + +// `Violations` is a collection of `Violation` messages. This message type is returned by +// Protovalidate when a proto message fails to meet the requirements set by the `Rule` validation rules. +// Each individual violation is represented by a `Violation` message. +message Violations { + // `violations` is a repeated field that contains all the `Violation` messages corresponding to the violations detected. + repeated Violation violations = 1; +} + +// `Violation` represents a single instance where a validation rule, expressed +// as a `Rule`, was not met. It provides information about the field that +// caused the violation, the specific rule that wasn't fulfilled, and a +// human-readable error message. +// +// For example, consider the following message: +// +// ```proto +// message User { +// int32 age = 1 [(buf.validate.field).cel = { +// id: "user.age", +// expression: "this < 18 ? 'User must be at least 18 years old' : ''", +// }]; +// } +// ``` +// +// It could produce the following violation: +// +// ```json +// { +// "ruleId": "user.age", +// "message": "User must be at least 18 years old", +// "field": { +// "elements": [ +// { +// "fieldNumber": 1, +// "fieldName": "age", +// "fieldType": "TYPE_INT32" +// } +// ] +// }, +// "rule": { +// "elements": [ +// { +// "fieldNumber": 23, +// "fieldName": "cel", +// "fieldType": "TYPE_MESSAGE", +// "index": "0" +// } +// ] +// } +// } +// ``` +message Violation { + // `field` is a machine-readable path to the field that failed validation. + // This could be a nested field, in which case the path will include all the parent fields leading to the actual field that caused the violation. + // + // For example, consider the following message: + // + // ```proto + // message Message { + // bool a = 1 [(buf.validate.field).required = true]; + // } + // ``` + // + // It could produce the following violation: + // + // ```textproto + // violation { + // field { element { field_number: 1, field_name: "a", field_type: 8 } } + // ... + // } + // ``` + optional FieldPath field = 5; + + // `rule` is a machine-readable path that points to the specific rule that failed validation. + // This will be a nested field starting from the FieldRules of the field that failed validation. + // For custom rules, this will provide the path of the rule, e.g. `cel[0]`. + // + // For example, consider the following message: + // + // ```proto + // message Message { + // bool a = 1 [(buf.validate.field).required = true]; + // bool b = 2 [(buf.validate.field).cel = { + // id: "custom_rule", + // expression: "!this ? 'b must be true': ''" + // }] + // } + // ``` + // + // It could produce the following violations: + // + // ```textproto + // violation { + // rule { element { field_number: 25, field_name: "required", field_type: 8 } } + // ... + // } + // violation { + // rule { element { field_number: 23, field_name: "cel", field_type: 11, index: 0 } } + // ... + // } + // ``` + optional FieldPath rule = 6; + + // `rule_id` is the unique identifier of the `Rule` that was not fulfilled. + // This is the same `id` that was specified in the `Rule` message, allowing easy tracing of which rule was violated. + optional string rule_id = 2; + + // `message` is a human-readable error message that describes the nature of the violation. + // This can be the default error message from the violated `Rule`, or it can be a custom message that gives more context about the violation. + optional string message = 3; + + // `for_key` indicates whether the violation was caused by a map key, rather than a value. + optional bool for_key = 4; + + reserved 1; + reserved "field_path"; +} + +// `FieldPath` provides a path to a nested protobuf field. +// +// This message provides enough information to render a dotted field path even without protobuf descriptors. +// It also provides enough information to resolve a nested field through unknown wire data. +message FieldPath { + // `elements` contains each element of the path, starting from the root and recursing downward. + repeated FieldPathElement elements = 1; +} + +// `FieldPathElement` provides enough information to nest through a single protobuf field. +// +// If the selected field is a map or repeated field, the `subscript` value selects a specific element from it. +// A path that refers to a value nested under a map key or repeated field index will have a `subscript` value. +// The `field_type` field allows unambiguous resolution of a field even if descriptors are not available. +message FieldPathElement { + // `field_number` is the field number this path element refers to. + optional int32 field_number = 1; + + // `field_name` contains the field name this path element refers to. + // This can be used to display a human-readable path even if the field number is unknown. + optional string field_name = 2; + + // `field_type` specifies the type of this field. When using reflection, this value is not needed. + // + // This value is provided to make it possible to traverse unknown fields through wire data. + // When traversing wire data, be mindful of both packed[1] and delimited[2] encoding schemes. + // + // [1]: https://protobuf.dev/programming-guides/encoding/#packed + // [2]: https://protobuf.dev/programming-guides/encoding/#groups + // + // N.B.: Although groups are deprecated, the corresponding delimited encoding scheme is not, and + // can be explicitly used in Protocol Buffers 2023 Edition. + optional google.protobuf.FieldDescriptorProto.Type field_type = 3; + + // `key_type` specifies the map key type of this field. This value is useful when traversing + // unknown fields through wire data: specifically, it allows handling the differences between + // different integer encodings. + optional google.protobuf.FieldDescriptorProto.Type key_type = 4; + + // `value_type` specifies map value type of this field. This is useful if you want to display a + // value inside unknown fields through wire data. + optional google.protobuf.FieldDescriptorProto.Type value_type = 5; + + // `subscript` contains a repeated index or map key, if this path element nests into a repeated or map field. + oneof subscript { + // `index` specifies a 0-based index into a repeated field. + uint64 index = 6; + + // `bool_key` specifies a map key of type bool. + bool bool_key = 7; + + // `int_key` specifies a map key of type int32, int64, sint32, sint64, sfixed32 or sfixed64. + int64 int_key = 8; + + // `uint_key` specifies a map key of type uint32, uint64, fixed32 or fixed64. + uint64 uint_key = 9; + + // `string_key` specifies a map key of type string. + string string_key = 10; + } +} diff --git a/third_party/config/app/v1/app.proto b/third_party/config/app/v1/app.proto new file mode 100644 index 00000000..6933feea --- /dev/null +++ b/third_party/config/app/v1/app.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +package runtime.api.config.app.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/app/v1;appv1"; + +// App defines the application's identity and metadata. +// StartTime is intentionally excluded as it's a runtime generated value. +message App { + // Unique identifier of the application + string id = 1 [ + json_name = "id", + (gnostic.openapi.v3.property) = {description: "Unique identifier of the application"} + ]; + // Application name + string name = 2 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "Application name"} + ]; + // Application version + string version = 3 [ + json_name = "version", + (gnostic.openapi.v3.property) = {description: "Application version"} + ]; + // Application running environment (e.g.: dev, test, prod) + string env = 4 [ + json_name = "env", + (gnostic.openapi.v3.property) = {description: "Application running environment (e.g.: dev, test, prod)"} + ]; + // Application metadata stored as key-value pairs + map metadata = 5 [ + json_name = "metadata", + (gnostic.openapi.v3.property) = {description: "Application metadata stored as key-value pairs"} + ]; +} diff --git a/third_party/config/bootstrap/v1/bootstrap.proto b/third_party/config/bootstrap/v1/bootstrap.proto new file mode 100644 index 00000000..6325d9f4 --- /dev/null +++ b/third_party/config/bootstrap/v1/bootstrap.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package runtime.api.config.bootstrap.v1; + +import "config/source/v1/source.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "config/app/v1/app.proto"; // Import app.proto + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/bootstrap/v1;v1"; + +// Bootstrap defines the structure of the bootstrap configuration file. +message Bootstrap { + // app provides application-specific information that can be defined in the bootstrap configuration. + // This information is typically used to establish the application's identity and environment early in the startup process. + app.v1.App app = 1 [ + json_name = "app", + (gnostic.openapi.v3.property) = {description: "Application-specific information defined in bootstrap."} + ]; + + // sources defines the list of configuration sources to be loaded. + // These sources are typically remote configuration services or local files. + repeated source.v1.SourceConfig sources = 2 [ + json_name = "sources", + (gnostic.openapi.v3.property) = {description: "List of configuration sources to be loaded."} + ]; + + // paths provides an optional mapping from a component name to its configuration path. + // The keys of this map should correspond to the predefined Component* constants + // in the Go bootstrap package (e.g., "logger", "registries"). + map paths = 3 [ + json_name = "paths", + (gnostic.openapi.v3.property) = {description: "Optional mapping from a component name to its configuration path."} + ]; +} diff --git a/third_party/config/broker/kafka/v1/kafka.proto b/third_party/config/broker/kafka/v1/kafka.proto new file mode 100644 index 00000000..297ab3d3 --- /dev/null +++ b/third_party/config/broker/kafka/v1/kafka.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; + +package runtime.api.config.broker.kafka.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/kafka/v1;kafkav1"; + +// KafkaConfig defines the configuration for a Kafka message queue. +message KafkaConfig { + // List of Kafka broker addresses (e.g., "localhost:9092"). + repeated string addresses = 1 [(gnostic.openapi.v3.property) = {description: "List of Kafka broker addresses."}]; + // Default topic for producers or consumers. + string topic = 2 [(gnostic.openapi.v3.property) = {description: "Default topic for producers or consumers."}]; + // Consumer group ID for Kafka consumers. + optional string consumer_group_id = 3 [(gnostic.openapi.v3.property) = {description: "Consumer group ID for Kafka consumers."}]; + // Client ID for the Kafka client. + optional string client_id = 4 [(gnostic.openapi.v3.property) = {description: "Client ID for the Kafka client."}]; + // SASL mechanism for authentication (e.g., "PLAIN", "SCRAM-SHA-256"). + optional string sasl_mechanism = 5 [(gnostic.openapi.v3.property) = {description: "SASL mechanism for authentication."}]; + // SASL username. + optional string sasl_username = 6 [(gnostic.openapi.v3.property) = {description: "SASL username."}]; + // SASL password. + optional string sasl_password = 7 [(gnostic.openapi.v3.property) = {description: "SASL password."}]; + // Path to TLS client certificate file. + optional string tls_client_cert_file = 8 [(gnostic.openapi.v3.property) = {description: "Path to TLS client certificate file."}]; + // Path to TLS client key file. + optional string tls_client_key_file = 9 [(gnostic.openapi.v3.property) = {description: "Path to TLS client key file."}]; + // Path to TLS CA certificate file. + optional string tls_ca_cert_file = 10 [(gnostic.openapi.v3.property) = {description: "Path to TLS CA certificate file."}]; + // Enable TLS insecure skip verify. + optional bool tls_insecure_skip_verify = 11 [(gnostic.openapi.v3.property) = {description: "Enable TLS insecure skip verify."}]; + // Auto offset reset policy (e.g., "earliest", "latest", "none"). + optional string auto_offset_reset = 12 [(gnostic.openapi.v3.property) = {description: "Auto offset reset policy."}]; + // Max bytes per partition for fetching messages. + optional int32 max_bytes_per_partition = 13 [(gnostic.openapi.v3.property) = {description: "Max bytes per partition for fetching messages."}]; + // Max wait time in milliseconds for fetching messages. + optional int32 max_wait_ms = 14 [(gnostic.openapi.v3.property) = {description: "Max wait time in milliseconds for fetching messages."}]; + // Whether to enable idempotence for producers. + optional bool enable_idempotence = 15 [(gnostic.openapi.v3.property) = {description: "Whether to enable idempotence for producers."}]; + // Acknowledge level for producers (e.g., "all", "1", "0"). + optional string acks = 16 [(gnostic.openapi.v3.property) = {description: "Acknowledge level for producers."}]; + // Compression type for producers (e.g., "none", "gzip", "snappy", "lz4", "zstd"). + optional string compression_type = 17 [(gnostic.openapi.v3.property) = {description: "Compression type for producers."}]; +} diff --git a/third_party/config/broker/mqtt/v1/mqtt.proto b/third_party/config/broker/mqtt/v1/mqtt.proto new file mode 100644 index 00000000..32f85998 --- /dev/null +++ b/third_party/config/broker/mqtt/v1/mqtt.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; + +package runtime.api.config.broker.mqtt.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/mqtt/v1;mqttv1"; + +// MqttConfig defines the configuration for an MQTT message queue. +message MqttConfig { + // MQTT broker address (e.g., "tcp://localhost:1883"). + string address = 1 [(gnostic.openapi.v3.property) = {description: "MQTT broker address (e.g., \"tcp://localhost:1883\")."}]; + // Client ID for the MQTT client. + optional string client_id = 2 [(gnostic.openapi.v3.property) = {description: "Client ID for the MQTT client."}]; + // Username for authentication. + optional string username = 3 [(gnostic.openapi.v3.property) = {description: "Username for authentication."}]; + // Password for authentication. + optional string password = 4 [(gnostic.openapi.v3.property) = {description: "Password for authentication."}]; + // Default topic for publishing or subscribing. + optional string topic = 5 [(gnostic.openapi.v3.property) = {description: "Default topic for publishing or subscribing."}]; + // QoS level for messages (0, 1, or 2). + optional int32 qos = 6 [(gnostic.openapi.v3.property) = {description: "QoS level for messages (0, 1, or 2)."}]; + // Whether to retain messages. + optional bool retained = 7 [(gnostic.openapi.v3.property) = {description: "Whether to retain messages."}]; + // Whether to enable TLS. + optional bool tls_enabled = 8 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS."}]; + // Path to TLS client certificate file. + optional string tls_client_cert_file = 9 [(gnostic.openapi.v3.property) = {description: "Path to TLS client certificate file."}]; + // Path to TLS client key file. + optional string tls_client_key_file = 10 [(gnostic.openapi.v3.property) = {description: "Path to TLS client key file."}]; + // Path to TLS CA certificate file. + optional string tls_ca_cert_file = 11 [(gnostic.openapi.v3.property) = {description: "Path to TLS CA certificate file."}]; + // Whether to enable TLS insecure skip verify. + optional bool tls_insecure_skip_verify = 12 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS insecure skip verify."}]; + // Keep alive interval in seconds. + optional int32 keep_alive_interval_seconds = 13 [(gnostic.openapi.v3.property) = {description: "Keep alive interval in seconds."}]; + // Clean session flag. + optional bool clean_session = 14 [(gnostic.openapi.v3.property) = {description: "Clean session flag."}]; +} diff --git a/third_party/config/broker/nats/v1/nats.proto b/third_party/config/broker/nats/v1/nats.proto new file mode 100644 index 00000000..a3daf2eb --- /dev/null +++ b/third_party/config/broker/nats/v1/nats.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +package runtime.api.config.broker.nats.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/nats/v1;natsv1"; + +// NatsConfig defines the configuration for a NATS message queue. +message NatsConfig { + // NATS server address (e.g., "nats://localhost:4222"). + string address = 1 [(gnostic.openapi.v3.property) = {description: "NATS server address (e.g., \"nats://localhost:4222\")."}]; + // Default subject for publishing or subscribing. + optional string subject = 2 [(gnostic.openapi.v3.property) = {description: "Default subject for publishing or subscribing."}]; + // Queue group name for subscribers. + optional string queue_group = 3 [(gnostic.openapi.v3.property) = {description: "Queue group name for subscribers."}]; + // Path to a user credentials file (.creds). + optional string user_credentials_file = 4 [(gnostic.openapi.v3.property) = {description: "Path to a user credentials file (.creds)."}]; + // NKey seed file for authentication. + optional string nkey_seed_file = 5 [(gnostic.openapi.v3.property) = {description: "NKey seed file for authentication."}]; + // JWT for authentication. + optional string jwt = 6 [(gnostic.openapi.v3.property) = {description: "JWT for authentication."}]; + // Authentication token. + optional string token = 7 [(gnostic.openapi.v3.property) = {description: "Authentication token."}]; + // Path to TLS client certificate file. + optional string tls_client_cert_file = 8 [(gnostic.openapi.v3.property) = {description: "Path to TLS client certificate file."}]; + // Path to TLS client key file. + optional string tls_client_key_file = 9 [(gnostic.openapi.v3.property) = {description: "Path to TLS client key file."}]; + // Path to TLS CA certificate file. + optional string tls_ca_cert_file = 10 [(gnostic.openapi.v3.property) = {description: "Path to TLS CA certificate file."}]; + // Whether to enable TLS insecure skip verify. + optional bool tls_insecure_skip_verify = 11 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS insecure skip verify."}]; + // Whether to use JetStream for persistence. + optional bool jetstream_enabled = 12 [(gnostic.openapi.v3.property) = {description: "Whether to use JetStream for persistence."}]; + // JetStream stream name. + optional string jetstream_stream_name = 13 [(gnostic.openapi.v3.property) = {description: "JetStream stream name."}]; +} diff --git a/third_party/config/broker/nsq/v1/nsq.proto b/third_party/config/broker/nsq/v1/nsq.proto new file mode 100644 index 00000000..059e3afb --- /dev/null +++ b/third_party/config/broker/nsq/v1/nsq.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package runtime.api.config.broker.nsq.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/nsq/v1;nsqv1"; + +// NsqConfig defines the configuration for an NSQ message queue. +message NsqConfig { + // List of NSQD addresses (e.g., "localhost:4150"). + repeated string nsqd_addresses = 1 [(gnostic.openapi.v3.property) = {description: "List of NSQD addresses (e.g., \"localhost:4150\")."}]; + // List of NSQLookupD addresses (e.g., "localhost:4161"). + repeated string nsqlookupd_addresses = 2 [(gnostic.openapi.v3.property) = {description: "List of NSQLookupD addresses (e.g., \"localhost:4161\")."}]; + // Default topic for publishing or subscribing. + string topic = 3 [(gnostic.openapi.v3.property) = {description: "Default topic for publishing or subscribing."}]; + // Channel name for consumers. + optional string channel = 4 [(gnostic.openapi.v3.property) = {description: "Channel name for consumers."}]; + // Max in flight messages for consumers. + optional int32 max_in_flight = 5 [(gnostic.openapi.v3.property) = {description: "Max in flight messages for consumers."}]; + // Lookupd poll interval in seconds. + optional int32 lookupd_poll_interval_seconds = 6 [(gnostic.openapi.v3.property) = {description: "Lookupd poll interval in seconds."}]; + // Whether to enable TLS. + optional bool tls_enabled = 7 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS."}]; + // Path to TLS client certificate file. + optional string tls_client_cert_file = 8 [(gnostic.openapi.v3.property) = {description: "Path to TLS client certificate file."}]; + // Path to TLS client key file. + optional string tls_client_key_file = 9 [(gnostic.openapi.v3.property) = {description: "Path to TLS client key file."}]; + // Path to TLS CA certificate file. + optional string tls_ca_cert_file = 10 [(gnostic.openapi.v3.property) = {description: "Path to TLS CA certificate file."}]; + // Whether to enable TLS insecure skip verify. + optional bool tls_insecure_skip_verify = 11 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS insecure skip verify."}]; +} diff --git a/third_party/config/broker/pulsar/v1/pulsar.proto b/third_party/config/broker/pulsar/v1/pulsar.proto new file mode 100644 index 00000000..b8ed458c --- /dev/null +++ b/third_party/config/broker/pulsar/v1/pulsar.proto @@ -0,0 +1,33 @@ +syntax = "proto3"; + +package runtime.api.config.broker.pulsar.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/pulsar/v1;pulsarv1"; + +// PulsarConfig defines the configuration for a Pulsar message queue. +message PulsarConfig { + // Pulsar broker service URL (e.g., "pulsar://localhost:6650"). + string service_url = 1 [(gnostic.openapi.v3.property) = {description: "Pulsar broker service URL (e.g., \"pulsar://localhost:6650\")."}]; + // Default topic for producers or consumers. + string topic = 2 [(gnostic.openapi.v3.property) = {description: "Default topic for producers or consumers."}]; + // Subscription name for consumers. + optional string subscription_name = 3 [(gnostic.openapi.v3.property) = {description: "Subscription name for consumers."}]; + // Authentication token. + optional string auth_token = 4 [(gnostic.openapi.v3.property) = {description: "Authentication token."}]; + // Path to TLS client certificate file. + optional string tls_client_cert_file = 5 [(gnostic.openapi.v3.property) = {description: "Path to TLS client certificate file."}]; + // Path to TLS client key file. + optional string tls_client_key_file = 6 [(gnostic.openapi.v3.property) = {description: "Path to TLS client key file."}]; + // Path to TLS CA certificate file. + optional string tls_ca_cert_file = 7 [(gnostic.openapi.v3.property) = {description: "Path to TLS CA certificate file."}]; + // Whether to enable TLS insecure skip verify. + optional bool tls_insecure_skip_verify = 8 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS insecure skip verify."}]; + // Operation timeout in milliseconds. + optional int32 operation_timeout_ms = 9 [(gnostic.openapi.v3.property) = {description: "Operation timeout in milliseconds."}]; + // Number of message listeners. + optional int32 num_message_listeners = 10 [(gnostic.openapi.v3.property) = {description: "Number of message listeners."}]; + // Max pending messages. + optional int32 max_pending_messages = 11 [(gnostic.openapi.v3.property) = {description: "Max pending messages."}]; +} diff --git a/third_party/config/broker/rabbitmq/v1/rabbitmq.proto b/third_party/config/broker/rabbitmq/v1/rabbitmq.proto new file mode 100644 index 00000000..d275279c --- /dev/null +++ b/third_party/config/broker/rabbitmq/v1/rabbitmq.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; + +package runtime.api.config.broker.rabbitmq.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/rabbitmq/v1;rabbitmqv1"; + +// RabbitMQConfig defines the configuration for a RabbitMQ message queue. +message RabbitMQConfig { + // RabbitMQ connection URI (e.g., "amqp://guest:guest@localhost:5672/"). + string uri = 1 [(gnostic.openapi.v3.property) = {description: "RabbitMQ connection URI (e.g., \"amqp://guest:guest@localhost:5672/\")."}]; + // Default exchange name. + optional string exchange = 2 [(gnostic.openapi.v3.property) = {description: "Default exchange name."}]; + // Default queue name. + optional string queue = 3 [(gnostic.openapi.v3.property) = {description: "Default queue name."}]; + // Virtual host to connect to. + optional string vhost = 4 [(gnostic.openapi.v3.property) = {description: "Virtual host to connect to."}]; + // Username for authentication. + optional string username = 5 [(gnostic.openapi.v3.property) = {description: "Username for authentication."}]; + // Password for authentication. + optional string password = 6 [(gnostic.openapi.v3.property) = {description: "Password for authentication."}]; + // Whether to enable TLS. + optional bool tls_enabled = 7 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS."}]; + // Path to TLS client certificate file. + optional string tls_client_cert_file = 8 [(gnostic.openapi.v3.property) = {description: "Path to TLS client certificate file."}]; + // Path to TLS client key file. + optional string tls_client_key_file = 9 [(gnostic.openapi.v3.property) = {description: "Path to TLS client key file."}]; + // Path to TLS CA certificate file. + optional string tls_ca_cert_file = 10 [(gnostic.openapi.v3.property) = {description: "Path to TLS CA certificate file."}]; + // Whether to enable TLS insecure skip verify. + optional bool tls_insecure_skip_verify = 11 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS insecure skip verify."}]; + // Consumer tag for consumers. + optional string consumer_tag = 12 [(gnostic.openapi.v3.property) = {description: "Consumer tag for consumers."}]; + // Qos prefetch count. + optional int32 qos_prefetch_count = 13 [(gnostic.openapi.v3.property) = {description: "Qos prefetch count."}]; + // Qos prefetch size. + optional int32 qos_prefetch_size = 14 [(gnostic.openapi.v3.property) = {description: "Qos prefetch size."}]; + // Qos global. + optional bool qos_global = 15 [(gnostic.openapi.v3.property) = {description: "Qos global."}]; + // Whether to auto-ack messages. + optional bool auto_ack = 16 [(gnostic.openapi.v3.property) = {description: "Whether to auto-ack messages."}]; + // Whether to publish messages as persistent. + optional bool persistent_messages = 17 [(gnostic.openapi.v3.property) = {description: "Whether to publish messages as persistent."}]; +} diff --git a/third_party/config/broker/redis_mq/v1/redis_mq.proto b/third_party/config/broker/redis_mq/v1/redis_mq.proto new file mode 100644 index 00000000..b6c46c7b --- /dev/null +++ b/third_party/config/broker/redis_mq/v1/redis_mq.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package runtime.api.config.broker.redis_mq.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/redis_mq/v1;redismqv1"; + +// RedisMqConfig defines the configuration for Redis used as a message queue (Pub/Sub or List). +message RedisMqConfig { + // Redis address (e.g., "localhost:6379"). + string address = 1 [(gnostic.openapi.v3.property) = {description: "Redis address (e.g., \"localhost:6379\")."}]; + // Redis password. + optional string password = 2 [(gnostic.openapi.v3.property) = {description: "Redis password."}]; + // Redis DB number. + optional int32 db = 3 [(gnostic.openapi.v3.property) = {description: "Redis DB number."}]; + // Default channel or list key for Pub/Sub or List operations. + string channel_or_list_key = 4 [(gnostic.openapi.v3.property) = {description: "Default channel or list key for Pub/Sub or List operations."}]; + // Whether to use Redis Pub/Sub (true) or List (false) for messaging. + optional bool use_pubsub = 5 [(gnostic.openapi.v3.property) = {description: "Whether to use Redis Pub/Sub (true) or List (false) for messaging."}]; + // Max number of messages to block for when using List as a queue. + optional int32 list_block_timeout_seconds = 6 [(gnostic.openapi.v3.property) = {description: "Max number of messages to block for when using List as a queue."}]; + // Path to TLS client certificate file. + optional string tls_client_cert_file = 7 [(gnostic.openapi.v3.property) = {description: "Path to TLS client certificate file."}]; + // Path to TLS client key file. + optional string tls_client_key_file = 8 [(gnostic.openapi.v3.property) = {description: "Path to TLS client key file."}]; + // Path to TLS CA certificate file. + optional string tls_ca_cert_file = 9 [(gnostic.openapi.v3.property) = {description: "Path to TLS CA certificate file."}]; + // Whether to enable TLS insecure skip verify. + optional bool tls_insecure_skip_verify = 10 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS insecure skip verify."}]; +} diff --git a/third_party/config/broker/rocketmq/v1/rocketmq.proto b/third_party/config/broker/rocketmq/v1/rocketmq.proto new file mode 100644 index 00000000..951418ea --- /dev/null +++ b/third_party/config/broker/rocketmq/v1/rocketmq.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package runtime.api.config.broker.rocketmq.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/rocketmq/v1;rocketmqv1"; + +// RocketMQConfig defines the configuration for a RocketMQ message queue. +message RocketMQConfig { + // List of NameServer addresses (e.g., "localhost:9876"). + repeated string name_server_addresses = 1 [(gnostic.openapi.v3.property) = {description: "List of NameServer addresses (e.g., \"localhost:9876\")."}]; + // Default topic for publishing or subscribing. + string topic = 2 [(gnostic.openapi.v3.property) = {description: "Default topic for publishing or subscribing."}]; + // Consumer group ID for consumers. + optional string consumer_group_id = 3 [(gnostic.openapi.v3.property) = {description: "Consumer group ID for consumers."}]; + // Producer group ID for producers. + optional string producer_group_id = 4 [(gnostic.openapi.v3.property) = {description: "Producer group ID for producers."}]; + // Access key for authentication. + optional string access_key = 5 [(gnostic.openapi.v3.property) = {description: "Access key for authentication."}]; + // Secret key for authentication. + optional string secret_key = 6 [(gnostic.openapi.v3.property) = {description: "Secret key for authentication."}]; + // Namespace for message isolation. + optional string namespace = 7 [(gnostic.openapi.v3.property) = {description: "Namespace for message isolation."}]; + // Send message timeout in milliseconds. + optional int32 send_timeout_ms = 8 [(gnostic.openapi.v3.property) = {description: "Send message timeout in milliseconds."}]; + // Consume message timeout in milliseconds. + optional int32 consume_timeout_ms = 9 [(gnostic.openapi.v3.property) = {description: "Consume message timeout in milliseconds."}]; + // Whether to enable TLS. + optional bool tls_enabled = 10 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS."}]; +} diff --git a/third_party/config/broker/sqs/v1/sqs.proto b/third_party/config/broker/sqs/v1/sqs.proto new file mode 100644 index 00000000..927d5538 --- /dev/null +++ b/third_party/config/broker/sqs/v1/sqs.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package runtime.api.config.broker.sqs.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/sqs/v1;sqsv1"; + +// SqsConfig defines the configuration for an AWS SQS message queue. +message SqsConfig { + // AWS region (e.g., "us-east-1"). + string region = 1 [(gnostic.openapi.v3.property) = {description: "AWS region (e.g., \"us-east-1\")."}]; + // AWS Access Key ID. + optional string access_key_id = 2 [(gnostic.openapi.v3.property) = {description: "AWS Access Key ID."}]; + // AWS Secret Access Key. + optional string secret_access_key = 3 [(gnostic.openapi.v3.property) = {description: "AWS Secret Access Key."}]; + // AWS Session Token (for temporary credentials). + optional string session_token = 4 [(gnostic.openapi.v3.property) = {description: "AWS Session Token (for temporary credentials)."}]; + // SQS queue URL. + string queue_url = 5 [(gnostic.openapi.v3.property) = {description: "SQS queue URL."}]; + // Max number of messages to receive in one request. + optional int32 max_number_of_messages = 6 [(gnostic.openapi.v3.property) = {description: "Max number of messages to receive in one request."}]; + // How long to wait for messages (in seconds) before returning. + optional int32 wait_time_seconds = 7 [(gnostic.openapi.v3.property) = {description: "How long to wait for messages (in seconds) before returning."}]; + // Message visibility timeout in seconds. + optional int32 visibility_timeout_seconds = 8 [(gnostic.openapi.v3.property) = {description: "Message visibility timeout in seconds."}]; + // Whether to use long polling. + optional bool long_polling_enabled = 9 [(gnostic.openapi.v3.property) = {description: "Whether to use long polling."}]; +} diff --git a/third_party/config/broker/stomp/v1/stomp.proto b/third_party/config/broker/stomp/v1/stomp.proto new file mode 100644 index 00000000..7787be8a --- /dev/null +++ b/third_party/config/broker/stomp/v1/stomp.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; + +package runtime.api.config.broker.stomp.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/stomp/v1;stompv1"; + +// StompConfig defines the configuration for a STOMP message queue. +message StompConfig { + // STOMP broker address (e.g., "localhost:61613"). + string address = 1 [(gnostic.openapi.v3.property) = {description: "STOMP broker address (e.g., \"localhost:61613\")."}]; + // Username for authentication. + optional string username = 2 [(gnostic.openapi.v3.property) = {description: "Username for authentication."}]; + // Password for authentication. + optional string password = 3 [(gnostic.openapi.v3.property) = {description: "Password for authentication."}]; + // Default destination for sending or subscribing. + string destination = 4 [(gnostic.openapi.v3.property) = {description: "Default destination for sending or subscribing."}]; + // Whether to enable TLS. + optional bool tls_enabled = 5 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS."}]; + // Path to TLS client certificate file. + optional string tls_client_cert_file = 6 [(gnostic.openapi.v3.property) = {description: "Path to TLS client certificate file."}]; + // Path to TLS client key file. + optional string tls_client_key_file = 7 [(gnostic.openapi.v3.property) = {description: "Path to TLS client key file."}]; + // Path to TLS CA certificate file. + optional string tls_ca_cert_file = 8 [(gnostic.openapi.v3.property) = {description: "Path to TLS CA certificate file."}]; + // Whether to enable TLS insecure skip verify. + optional bool tls_insecure_skip_verify = 9 [(gnostic.openapi.v3.property) = {description: "Whether to enable TLS insecure skip verify."}]; + // Heartbeat interval in milliseconds. + optional int32 heartbeat_interval_ms = 10 [(gnostic.openapi.v3.property) = {description: "Heartbeat interval in milliseconds."}]; +} diff --git a/third_party/config/broker/v1/broker.proto b/third_party/config/broker/v1/broker.proto new file mode 100644 index 00000000..c99ee5c3 --- /dev/null +++ b/third_party/config/broker/v1/broker.proto @@ -0,0 +1,114 @@ +syntax = "proto3"; + +package runtime.api.config.broker.v1; + +import "config/broker/kafka/v1/kafka.proto"; +import "config/broker/mqtt/v1/mqtt.proto"; +import "config/broker/nats/v1/nats.proto"; +import "config/broker/nsq/v1/nsq.proto"; +import "config/broker/pulsar/v1/pulsar.proto"; +import "config/broker/rabbitmq/v1/rabbitmq.proto"; +import "config/broker/redis_mq/v1/redis_mq.proto"; +import "config/broker/rocketmq/v1/rocketmq.proto"; +import "config/broker/sqs/v1/sqs.proto"; +import "config/broker/stomp/v1/stomp.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/broker/v1;brokerv1"; + +// Changed from ORC to ORBV1 for Broker V1 + +// Broker defines the configuration for a message queue service. +// It can contain configurations for different message queue implementations. +message Broker { + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "The name of the broker configuration."} + ]; + // The 'type' field determines which message broker to use. + // For built-in types, specify "kafka", "rabbitmq", "mqtt", etc. + // For custom types, specify the registered name of the custom broker. + // When a custom type is used, its configuration should be placed in the 'customize' field. + string type = 2 [ + json_name = "type", + (gnostic.openapi.v3.property) = {description: "The type of the message broker. Built-in: 'kafka', 'rabbitmq', 'mqtt', etc. Custom types use their registered name."} + ]; + + // Optional Kafka configuration. + optional kafka.v1.KafkaConfig kafka = 3 [ + json_name = "kafka", + (gnostic.openapi.v3.property) = {description: "Kafka specific configuration."} + ]; + // Optional RabbitMQ configuration. + optional rabbitmq.v1.RabbitMQConfig rabbitmq = 4 [ + json_name = "rabbitmq", + (gnostic.openapi.v3.property) = {description: "RabbitMQ specific configuration."} + ]; + // Optional MQTT configuration. + optional mqtt.v1.MqttConfig mqtt = 5 [ + json_name = "mqtt", + (gnostic.openapi.v3.property) = {description: "MQTT specific configuration."} + ]; + // Optional NATS configuration. + optional nats.v1.NatsConfig nats = 6 [ + json_name = "nats", + (gnostic.openapi.v3.property) = {description: "NATS specific configuration."} + ]; + // Optional NSQ configuration. + optional nsq.v1.NsqConfig nsq = 7 [ + json_name = "nsq", + (gnostic.openapi.v3.property) = {description: "NSQ specific configuration."} + ]; + // Optional Pulsar configuration. + optional pulsar.v1.PulsarConfig pulsar = 8 [ + json_name = "pulsar", + (gnostic.openapi.v3.property) = {description: "Pulsar specific configuration."} + ]; + // Optional Redis (as MQ) configuration. + optional redis_mq.v1.RedisMqConfig redis_mq = 9 [ + json_name = "redis_mq", + (gnostic.openapi.v3.property) = {description: "Redis (as MQ) specific configuration."} + ]; + // Optional RocketMQ configuration. + optional rocketmq.v1.RocketMQConfig rocketmq = 10 [ + json_name = "rocketmq", + (gnostic.openapi.v3.property) = {description: "RocketMQ specific configuration."} + ]; + // Optional SQS configuration. + optional sqs.v1.SqsConfig sqs = 11 [ + json_name = "sqs", + (gnostic.openapi.v3.property) = {description: "SQS specific configuration."} + ]; + // Optional STOMP configuration. + optional stomp.v1.StompConfig stomp = 12 [ + json_name = "stomp", + (gnostic.openapi.v3.property) = {description: "STOMP specific configuration."} + ]; + // Optional customize configuration. + optional google.protobuf.Struct customize = 100 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Custom broker configuration."} + ]; + + // Add other common configurations here if applicable to all implementations, + // or if they are used to select the implementation type in Go code. + // For example: + // optional string type = 11; // e.g., "kafka", "rabbitmq" +} + +message Brokers { + optional string default = 1 [ + json_name = "default", + (gnostic.openapi.v3.property) = {description: "The default broker to use."} + ]; + optional string active = 2 [ + json_name = "active", + (gnostic.openapi.v3.property) = {description: "The active broker to use, overrides default."} + ]; + + repeated Broker brokers = 3 [ + json_name = "brokers", + (gnostic.openapi.v3.property) = {description: "A list of broker configurations."} + ]; +} diff --git a/third_party/config/common/v1/errors.proto b/third_party/config/common/v1/errors.proto new file mode 100644 index 00000000..6b057e8c --- /dev/null +++ b/third_party/config/common/v1/errors.proto @@ -0,0 +1,93 @@ +syntax = "proto3"; + +package runtime.api.config.common.v1; + +import "errors/errors.proto"; +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/common/v1;commonv1"; + +// ErrorCategory defines the category of an error. +// This helps in grouping related errors together for monitoring and client handling. +enum ErrorCategory { + // General errors not specific to any category. + ERROR_CATEGORY_GENERAL_UNSPECIFIED = 0; + // Authentication and authorization related errors. + ERROR_CATEGORY_AUTHENTICATION = 1; + // Database related errors. + ERROR_CATEGORY_DATABASE = 2; + // Business logic related errors. + ERROR_CATEGORY_BUSINESS = 3; + // External service related errors. + ERROR_CATEGORY_EXTERNAL_SERVICE = 4; +} + +// ErrorMetadata contains additional, structured context about an error. +// It can be used for logging and debugging purposes. +message ErrorMetadata { + // The category of the error. + ErrorCategory category = 1 [ + json_name = "category", + (gnostic.openapi.v3.property) = {description: "The category of the error."} + ]; + // Additional key-value pairs providing context about the error. + map metadata = 2 [ + json_name = "metadata", + (gnostic.openapi.v3.property) = {description: "Additional key-value pairs providing context about the error."} + ]; +} + +// ErrorReason defines the application's common error codes. +// These codes are mapped to HTTP status codes and are consistent across all services. +// +// The enum values are structured to allow for future expansion by domain-specific errors. +// - 0-999: General framework errors +// - 1000-1999: Common Authentication & Authorization Errors +// - 2000-2999: Common Database Errors +// - 3000-3999: Common Business Logic Errors +// - 4000-4999: Common External Service Errors +// +// Specific reasons for these errors should be defined within the specific domain's error file. +enum ErrorReason { + option (errors.default_code) = 500; + + // --- General Framework Errors (0-999) --- + ERROR_REASON_UNKNOWN_UNSPECIFIED = 0 [(errors.code) = 500]; + ERROR_REASON_VALIDATION_ERROR = 1 [(errors.code) = 400]; + ERROR_REASON_NOT_FOUND = 2 [(errors.code) = 404]; + ERROR_REASON_INTERNAL_SERVER_ERROR = 3 [(errors.code) = 500]; + ERROR_REASON_METHOD_NOT_ALLOWED = 4 [(errors.code) = 405]; + ERROR_REASON_REQUEST_TIMEOUT = 5 [(errors.code) = 408]; + ERROR_REASON_CONFLICT = 6 [(errors.code) = 409]; + ERROR_REASON_TOO_MANY_REQUESTS = 7 [(errors.code) = 429]; + ERROR_REASON_SERVICE_UNAVAILABLE = 8 [(errors.code) = 503]; + ERROR_REASON_GATEWAY_TIMEOUT = 9 [(errors.code) = 504]; + + // --- Common Authentication & Authorization Errors (1000-1999) --- + ERROR_REASON_UNAUTHENTICATED = 1000 [(errors.code) = 401]; + ERROR_REASON_FORBIDDEN = 1001 [(errors.code) = 403]; + + // --- Common Database Errors (2000-2999) --- + ERROR_REASON_DATABASE_ERROR = 2000 [(errors.code) = 500]; + ERROR_REASON_RECORD_NOT_FOUND = 2001 [(errors.code) = 404]; + ERROR_REASON_CONSTRAINT_VIOLATION = 2002 [(errors.code) = 409]; + ERROR_REASON_DUPLICATE_KEY = 2003 [(errors.code) = 409]; + ERROR_REASON_DATABASE_CONNECTION_FAILED = 2004 [(errors.code) = 503]; + + // --- Common Business Logic Errors (3000-3999) --- + ERROR_REASON_INVALID_STATE = 3000 [(errors.code) = 400]; + ERROR_REASON_RESOURCE_EXISTS = 3001 [(errors.code) = 409]; + ERROR_REASON_RESOURCE_IN_USE = 3002 [(errors.code) = 409]; + ERROR_REASON_CANCELLED = 3003 [(errors.code) = 499]; + ERROR_REASON_ABORTED = 3004 [(errors.code) = 409]; + ERROR_REASON_MISSING_PARAMETER = 3005 [(errors.code) = 400]; + ERROR_REASON_INVALID_PARAMETER = 3006 [(errors.code) = 400]; + ERROR_REASON_OPERATION_NOT_ALLOWED = 3007 [(errors.code) = 403]; + + // --- Common External Service Errors (4000-4999) --- + ERROR_REASON_EXTERNAL_SERVICE_UNAVAILABLE = 4000 [(errors.code) = 503]; + ERROR_REASON_EXTERNAL_SERVICE_ERROR = 4001 [(errors.code) = 502]; + + // --- Common Registry Errors (6000-6999) --- + ERROR_REASON_REGISTRY_NOT_FOUND = 6000 [(errors.code) = 404]; +} diff --git a/third_party/config/common/v1/pagination.proto b/third_party/config/common/v1/pagination.proto new file mode 100644 index 00000000..ac06d4fe --- /dev/null +++ b/third_party/config/common/v1/pagination.proto @@ -0,0 +1,109 @@ +syntax = "proto3"; + +package runtime.api.config.common.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/field_mask.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/common/v1;commonv1"; + +// PaginationRequest provides a flexible structure for pagination requests, supporting +// both cursor-based (infinite scroll) and offset-based (numbered pages) pagination. +// The server should prioritize `page_token` if both `page_token` and `page` are provided. +message PaginationRequest { + // For offset-based pagination: the page number to retrieve (1-indexed). + optional int32 page = 1 [ + json_name = "page", + (gnostic.openapi.v3.property) = { + description: "The page number to retrieve (1-indexed)." + default: {number: 1} + } + ]; + + // The maximum number of items to return per page. The server may enforce a + // maximum limit to this value. + optional int32 page_size = 2 [ + json_name = "page_size", + (gnostic.openapi.v3.property) = { + description: "The maximum number of items to return per page. The server may enforce a maximum limit to this value." + default: {number: 15} + } + ]; + + // For cursor-based pagination: a token identifying a page of results the server + // should return. This is the `next_page_token` from a previous response. + string page_token = 3 [ + json_name = "page_token", + (gnostic.openapi.v3.property) = {description: "A token identifying a page of results the server should return. This is the `next_page_token` from a previous response."} + ]; + + // If true, the server will only return the `total_size` in the response Pagination + // message, and the `items` list will be empty. This is useful for fetching + // only the total count of items. + bool only_count = 4 [ + json_name = "only_count", + (gnostic.openapi.v3.property) = {description: "If true, only the total count of items will be returned, and the items list will be empty."} + ]; + + // The no_paging is used to disable pagination. + optional bool no_paging = 5 [ + json_name = "no_paging", + (gnostic.openapi.v3.property) = {description: "Set to true to disable pagination and return all available items."} + ]; + + // sort condition + string order_by = 6 [ + json_name = "order_by", + (gnostic.openapi.v3.property) = { + description: "Sort condition, field name followed by 'asc' (ascending) or 'desc' (descending)." + example: {yaml: "id:asc"} + } + ]; + + // Field mask + google.protobuf.FieldMask field_mask = 7 [ + json_name = "field_mask", + (gnostic.openapi.v3.property) = { + description: "Used to specify which fields to return in the response, or which fields to update in a partial update request." + example: {yaml: "id,name,age"} + } + ]; +} + +// Pagination provides a comprehensive structure for pagination responses, supporting +// both cursor-based (infinite scroll) and offset-based (numbered pages) pagination. +message Pagination { + // For offset-based pagination: the current page number (1-indexed). + int32 page = 1 [ + json_name = "page", + (gnostic.openapi.v3.property) = {description: "The current page number (1-indexed)."} + ]; + + // The number of items retrieved on the current page. + int32 page_size = 2 [ + json_name = "page_size", + (gnostic.openapi.v3.property) = {description: "The number of items retrieved on the current page."} + ]; + + // For offset-based pagination: the total number of items available across all pages. + // This is optional and may be expensive to calculate for large datasets. + int64 total_size = 3 [ + json_name = "total_size", + (gnostic.openapi.v3.property) = {description: "The total number of items available across all pages. This is optional and may be expensive to calculate for large datasets."} + ]; + + // For cursor-based pagination: a token to retrieve the next page of results. + // If empty, there are no more results. + string next_page_token = 4 [ + json_name = "next_page_token", + (gnostic.openapi.v3.property) = {description: "A token to retrieve the next page of results. If empty, there are no more results."} + ]; + + // Additional information about this response. + // content to be added without destroying the current data format + map extra = 5 [ + json_name = "extra", + (gnostic.openapi.v3.property) = {description: "Additional information about this response, stored as key-value pairs."} + ]; +} diff --git a/third_party/config/config/v1/gateway.proto b/third_party/config/config/v1/gateway.proto new file mode 100644 index 00000000..e6f6c6a0 --- /dev/null +++ b/third_party/config/config/v1/gateway.proto @@ -0,0 +1,110 @@ +syntax = "proto3"; + +package runtime.api.config.config.v1; + +import "config/transport/tls/v1/tls.proto"; +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/config/v1;configv1"; + +message Gateway { + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "The name of the gateway."} + ]; + string version = 2 [ + json_name = "version", + (gnostic.openapi.v3.property) = {description: "The version of the gateway."} + ]; + repeated string hosts = 3 [ + json_name = "hosts", + deprecated = true, + (gnostic.openapi.v3.property) = {description: "Deprecated: Use host in Endpoint instead. List of hosts the gateway serves."} + ]; + repeated Endpoint endpoints = 4 [ + json_name = "endpoints", + (gnostic.openapi.v3.property) = {description: "List of API endpoints configured for the gateway."} + ]; + repeated Middleware middlewares = 5 [ + json_name = "middlewares", + (gnostic.openapi.v3.property) = {description: "List of global middlewares applied to the gateway."} + ]; + map tls_store = 6 [ + json_name = "tls_store", + (gnostic.openapi.v3.property) = {description: "TLS configurations stored by name."} + ]; +} + +message PriorityConfig { + string name = 1 [(gnostic.openapi.v3.property) = {description: "The name of the priority configuration."}]; + string version = 2 [(gnostic.openapi.v3.property) = {description: "The version of the priority configuration."}]; + repeated Endpoint endpoints = 3 [(gnostic.openapi.v3.property) = {description: "List of endpoints for this priority configuration."}]; +} + +message Endpoint { + string path = 1 [(gnostic.openapi.v3.property) = {description: "The URL path for the endpoint."}]; + string method = 2 [(gnostic.openapi.v3.property) = {description: "The HTTP method for the endpoint (e.g., GET, POST)."}]; + string description = 3 [(gnostic.openapi.v3.property) = {description: "A description of the endpoint."}]; + Protocol protocol = 4 [(gnostic.openapi.v3.property) = {description: "The communication protocol used by the endpoint."}]; + int64 timeout = 5 [(gnostic.openapi.v3.property) = {description: "The timeout for the endpoint in milliseconds."}]; + repeated Middleware middlewares = 6 [(gnostic.openapi.v3.property) = {description: "List of middlewares applied to this specific endpoint."}]; + repeated Backend backends = 7 [(gnostic.openapi.v3.property) = {description: "List of backend services for this endpoint."}]; + Retry retry = 8 [(gnostic.openapi.v3.property) = {description: "Retry policy for the endpoint."}]; + map metadata = 9 [(gnostic.openapi.v3.property) = {description: "Additional metadata for the endpoint."}]; + string host = 10 [(gnostic.openapi.v3.property) = {description: "The host for the endpoint."}]; +} + +message Middleware { + string name = 1 [(gnostic.openapi.v3.property) = {description: "The name of the middleware."}]; + bytes options = 2 [(gnostic.openapi.v3.property) = {description: "Configuration options for the middleware, as a byte array."}]; + bool required = 3 [(gnostic.openapi.v3.property) = {description: "Whether the middleware is required."}]; +} + +message Backend { + // localhost + // 127.0.0.1:8000 + // discovery:///service_name + string target = 1 [(gnostic.openapi.v3.property) = {description: "The target address of the backend service (e.g., IP:Port, discovery URL)."}]; + optional int64 weight = 2 [(gnostic.openapi.v3.property) = {description: "The weight for load balancing among multiple backends."}]; + HealthCheck health_check = 3 [(gnostic.openapi.v3.property) = {description: "Health check configuration for the backend."}]; + bool tls = 4 [(gnostic.openapi.v3.property) = {description: "Whether TLS is enabled for the backend connection."}]; + string tls_config_name = 5 [(gnostic.openapi.v3.property) = {description: "The name of the TLS configuration to use from the tls_store."}]; + map metadata = 6 [(gnostic.openapi.v3.property) = {description: "Additional metadata for the backend."}]; +} + +enum Protocol { + PROTOCOL_UNSPECIFIED = 0; + PROTOCOL_HTTP = 1; + PROTOCOL_GRPC = 2; + PROTOCOL_CUSTOM = 3; +} + +message HealthCheck { + enum CheckType { + CHECK_TYPE_UNSPECIFIED = 0; + CHECK_TYPE_HTTP = 1; + CHECK_TYPE_TCP = 2; + } + CheckType type = 1 [(gnostic.openapi.v3.property) = {description: "The type of health check to perform."}]; + string endpoint = 2 [(gnostic.openapi.v3.property) = {description: "The endpoint to check for health."}]; +} + +message Retry { + // default attempts is 1 + uint32 attempts = 1 [(gnostic.openapi.v3.property) = {description: "The number of retry attempts (default is 1)."}]; + int64 per_try_timeout = 2 [(gnostic.openapi.v3.property) = {description: "The timeout for each individual retry attempt in milliseconds."}]; + repeated Condition conditions = 3 [(gnostic.openapi.v3.property) = {description: "Conditions under which a retry should be performed."}]; + // primary,secondary + repeated string priorities = 4 [(gnostic.openapi.v3.property) = {description: "List of priorities for retrying (e.g., primary, secondary)."}]; +} + +message Condition { + message Header { + string name = 1 [(gnostic.openapi.v3.property) = {description: "The name of the HTTP header."}]; + string value = 2 [(gnostic.openapi.v3.property) = {description: "The expected value of the HTTP header."}]; + } + // "500-599", "429" + optional string by_status_code = 1 [(gnostic.openapi.v3.property) = {description: "Retry if the response status code matches this pattern (e.g., \"500-599\", \"429\")."}]; + // {"name": "grpc-status", "value": "14"} + optional Header by_header = 2 [(gnostic.openapi.v3.property) = {description: "Retry if a specific HTTP header matches the given value."}]; +} diff --git a/third_party/config/data/cache/v1/cache.proto b/third_party/config/data/cache/v1/cache.proto new file mode 100644 index 00000000..729d2c60 --- /dev/null +++ b/third_party/config/data/cache/v1/cache.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; + +package runtime.api.config.data.cache.v1; + +import "config/data/cache/v1/memcached.proto"; // Import MemcachedConfig +import "config/data/cache/v1/memory.proto"; // Import MemoryConfig +import "config/data/cache/v1/redis.proto"; // Import RedisConfig +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/cache/v1;cachev1"; + +// CacheConfig defines the configuration for various caching mechanisms. +// This message was extracted from storage.proto and renamed for consistency. +message CacheConfig { + // The 'driver' field determines which configuration block to use. + // For built-in drivers, specify "redis", "memcached", or "memory". + // For custom drivers, specify the registered name of the custom driver. + // When a custom driver is used, its configuration should be placed in the 'customize' field. + string driver = 1 [ + json_name = "driver", + (gnostic.openapi.v3.property) = {description: "Cache driver name. Built-in: 'redis', 'memcached', 'memory'. Custom drivers use their registered name."} + ]; + string name = 2 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "cache name"} + ]; + // Memcached + MemcachedConfig memcached = 10 [ + json_name = "memcached", + (gnostic.openapi.v3.property) = {description: "memcached cache configuration"} + ]; + // Memory cache + MemoryConfig memory = 11 [ + json_name = "memory", + (gnostic.openapi.v3.property) = {description: "memory cache configuration"} + ]; + // Redis + RedisConfig redis = 12 [ + json_name = "redis", + (gnostic.openapi.v3.property) = {description: "redis cache configuration"} + ]; + // Cleanup interval for memory cache in seconds. + // If 0 or not set, a default (e.g., 5 minutes) will be used by the implementation. + int64 cleanup_interval = 13 [ + json_name = "cleanup_interval", + (gnostic.openapi.v3.property) = {description: "Cleanup interval for memory cache in seconds."} + ]; + + // Optional custom configuration for cache types not explicitly defined. + optional google.protobuf.Struct customize = 14 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Custom configuration for cache types not explicitly defined."} + ]; +} diff --git a/third_party/config/data/cache/v1/memcached.proto b/third_party/config/data/cache/v1/memcached.proto new file mode 100644 index 00000000..95a8a372 --- /dev/null +++ b/third_party/config/data/cache/v1/memcached.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +package runtime.api.config.data.cache.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/cache/v1;cachev1"; + +// MemcachedConfig defines the configuration for a Memcached client. +// This message was extracted from storage.proto and renamed for consistency. +message MemcachedConfig { + string addr = 1 [ + json_name = "addr", + (gnostic.openapi.v3.property) = {description: "address"} + ]; + string username = 2 [ + json_name = "username", + (gnostic.openapi.v3.property) = {description: "username"} + ]; + string password = 3 [ + json_name = "password", + (gnostic.openapi.v3.property) = {description: "cipher"} + ]; + int32 max_idle = 4 [ + json_name = "max_idle", + (gnostic.openapi.v3.property) = { + description: "maximum number of idle connections" + minimum: 1 + } + ]; + int64 timeout = 5 [ + json_name = "timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "overtime"} + ]; +} diff --git a/third_party/config/data/cache/v1/memory.proto b/third_party/config/data/cache/v1/memory.proto new file mode 100644 index 00000000..82d9528c --- /dev/null +++ b/third_party/config/data/cache/v1/memory.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package runtime.api.config.data.cache.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/cache/v1;cachev1"; + +// MemoryConfig defines the configuration for an in-memory cache. +// This message was extracted from storage.proto and renamed for consistency. +message MemoryConfig { + int32 size = 1 [ + json_name = "size", + (gnostic.openapi.v3.property) = {description: "size"} + ]; + int32 capacity = 2 [ + json_name = "capacity", + (gnostic.openapi.v3.property) = {description: "capacity"} + ]; + int64 expiration = 3 [ + json_name = "expiration", + (gnostic.openapi.v3.property) = {description: "expiration time"} + ]; + int64 cleanup_interval = 4 [ + json_name = "cleanup_interval", + (gnostic.openapi.v3.property) = {description: "clearance interval"} + ]; +} diff --git a/third_party/config/data/cache/v1/redis.proto b/third_party/config/data/cache/v1/redis.proto new file mode 100644 index 00000000..70d343f2 --- /dev/null +++ b/third_party/config/data/cache/v1/redis.proto @@ -0,0 +1,92 @@ +syntax = "proto3"; + +package runtime.api.config.data.cache.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/cache/v1;cachev1"; + +// RedisConfig defines the configuration for a Redis client used as a data store (e.g., cache, key-value store). +message RedisConfig { + string network = 1 [ + json_name = "network", + (gnostic.openapi.v3.property) = {description: "Network type (e.g., tcp)"} + ]; + string addr = 2 [ + json_name = "addr", + (gnostic.openapi.v3.property) = {description: "Redis server address (e.g., localhost:6379)"} + ]; + string password = 3 [ + json_name = "password", + (gnostic.openapi.v3.property) = {description: "Password for Redis authentication"} + ]; + int32 db = 4 [ + json_name = "db", + (gnostic.openapi.v3.property) = {description: "Database index to use"} + ]; + int64 dial_timeout = 5 [ + json_name = "dial_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Dial timeout in milliseconds"} + ]; + int64 read_timeout = 6 [ + json_name = "read_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Read timeout in milliseconds"} + ]; + int64 write_timeout = 7 [ + json_name = "write_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Write timeout in milliseconds"} + ]; + // Maximum number of connections in the connection pool. + optional int32 pool_size = 8 [ + json_name = "pool_size", + (validate.rules).int32.gte = 0, + (gnostic.openapi.v3.property) = {description: "Maximum number of connections in the connection pool"} + ]; + // Minimum number of idle connections in the connection pool. + optional int32 min_idle_conns = 9 [ + json_name = "min_idle_conns", + (validate.rules).int32.gte = 0, + (gnostic.openapi.v3.property) = {description: "Minimum number of idle connections in the connection pool"} + ]; + // Maximum duration a connection can be idle before being closed. + optional int64 idle_timeout = 10 [ + json_name = "idle_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Maximum duration a connection can be idle before being closed (in milliseconds)"} + ]; + // Maximum duration to wait for a connection from the pool. + optional int64 pool_timeout = 11 [ + json_name = "pool_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Maximum duration to wait for a connection from the pool (in milliseconds)"} + ]; + // Whether to enable TLS. + optional bool tls_enabled = 12 [ + json_name = "tls_enabled", + (gnostic.openapi.v3.property) = {description: "Whether to enable TLS for the connection"} + ]; + // Path to TLS client certificate file. + optional string tls_client_cert_file = 13 [ + json_name = "tls_client_cert_file", + (gnostic.openapi.v3.property) = {description: "Path to TLS client certificate file"} + ]; + // Path to TLS client key file. + optional string tls_client_key_file = 14 [ + json_name = "tls_client_key_file", + (gnostic.openapi.v3.property) = {description: "Path to TLS client key file"} + ]; + // Path to TLS CA certificate file. + optional string tls_ca_cert_file = 15 [ + json_name = "tls_ca_cert_file", + (gnostic.openapi.v3.property) = {description: "Path to TLS CA certificate file"} + ]; + // Whether to enable TLS insecure skip verify. + optional bool tls_insecure_skip_verify = 16 [ + json_name = "tls_insecure_skip_verify", + (gnostic.openapi.v3.property) = {description: "Whether to enable TLS insecure skip verify"} + ]; +} diff --git a/third_party/config/data/database/v1/database.proto b/third_party/config/data/database/v1/database.proto new file mode 100644 index 00000000..7ac7f6c0 --- /dev/null +++ b/third_party/config/data/database/v1/database.proto @@ -0,0 +1,78 @@ +syntax = "proto3"; + +package runtime.api.config.data.database.v1; + +import "config/data/database/v1/migration.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/database/v1;databasev1"; + +// DatabaseConfig defines the configuration for a generic database connection. +// This message was extracted from mysql.proto and renamed for consistency. +message DatabaseConfig { + // Unique name for this database configuration instance. + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "Unique name for this database configuration instance."} + ]; + // Debugging + bool debug = 2 [ + json_name = "debug", + (gnostic.openapi.v3.property) = {description: "whether to enable debug mode "} + ]; + // The 'dialect' field determines the database type. + // For built-in dialects, specify "mysql", "postgresql", "sqlite", etc. + // For custom dialects, specify the registered name of the custom dialect. + // When a custom dialect is used, its configuration should be placed in the 'customize' field. + string dialect = 3 [ + json_name = "dialect", + (gnostic.openapi.v3.property) = {description: "Database dialect name. Built-in: 'mysql', 'postgresql', 'sqlite', etc. Custom dialects use their registered name."} + ]; + // Data source (DSN string) + string source = 4 [ + json_name = "source", + (gnostic.openapi.v3.property) = {description: "data source dsn string"} + ]; + // Data migration + Migration migration = 10 [ + json_name = "migration", + (gnostic.openapi.v3.property) = {description: "data migration"} + ]; + // Link tracking switch + bool enable_trace = 12 [ + json_name = "enable_trace", + (gnostic.openapi.v3.property) = {description: "link tracking switch"} + ]; + // Performance analysis switch + bool enable_metrics = 13 [ + json_name = "enable_metrics", + (gnostic.openapi.v3.property) = {description: "performance analysis switch"} + ]; + // Maximum number of free connections in the connection pool + int32 max_idle_connections = 20 [ + json_name = "max_idle_connections", + (gnostic.openapi.v3.property) = {description: "The maximum number of free connections in the connection pool"} + ]; + // Maximum number of open connections in the connection pool + int32 max_open_connections = 21 [ + json_name = "max_open_connections", + (gnostic.openapi.v3.property) = {description: "The maximum number of open connections in the connection pool"} + ]; + // Maximum length of time that the connection can be reused + int64 connection_max_lifetime = 22 [ + json_name = "connection_max_lifetime", + (gnostic.openapi.v3.property) = {description: "The maximum length of time a connection can be reused"} + ]; + // Maximum number of connections in the connection pool for reading + int64 connection_max_idle_time = 23 [ + json_name = "connection_max_idle_time", + (gnostic.openapi.v3.property) = {description: "The maximum number of connections in the connection pool for reading"} + ]; + + // Optional custom configuration for database types not explicitly defined. + optional google.protobuf.Struct customize = 100 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Custom configuration for database types not explicitly defined."} + ]; +} diff --git a/third_party/config/data/database/v1/document.proto b/third_party/config/data/database/v1/document.proto new file mode 100644 index 00000000..68102b76 --- /dev/null +++ b/third_party/config/data/database/v1/document.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; + +package runtime.api.config.data.database.v1; + +import "config/data/database/v1/mongo.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/database/v1;databasev1"; + +// DocumentConfig defines the configuration for a document database instance. +message DocumentConfig { + // Unique name for this document database configuration instance. + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "Unique name for this document database configuration instance."} + ]; + // The 'type' field determines which document database to use. + // For built-in types, specify "mongo". + // For custom types, specify the registered name of the custom document database. + // When a custom type is used, its configuration should be placed in the 'customize' field. + string type = 2 [ + json_name = "type", + (gnostic.openapi.v3.property) = {description: "The type of document database. Built-in: 'mongo'. Custom types use their registered name."} + ]; + + // Optional MongoDB configuration. + optional MongoConfig mongo = 10 [ + json_name = "mongo", + (gnostic.openapi.v3.property) = {description: "MongoDB specific configuration."} + ]; + + // Optional custom configuration for document database types not explicitly defined. + optional google.protobuf.Struct customize = 100 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Custom configuration for document database types not explicitly defined."} + ]; +} diff --git a/third_party/config/data/database/v1/migration.proto b/third_party/config/data/database/v1/migration.proto new file mode 100644 index 00000000..8154483c --- /dev/null +++ b/third_party/config/data/database/v1/migration.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; + +package runtime.api.config.data.database.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/database/v1;databasev1"; + +// Migration defines database migration settings. +// This message was extracted from mysql.proto for better modularity. +message Migration { + bool enabled = 1 [ + json_name = "enabled", + (gnostic.openapi.v3.property) = {description: "whether to enable migration"} + ]; + string path = 2 [ + json_name = "path", + (gnostic.openapi.v3.property) = {description: "migration path"} + ]; + repeated string names = 3 [ + json_name = "names", + (gnostic.openapi.v3.property) = {description: "migration name"} + ]; + string version = 4 [ + json_name = "version", + (gnostic.openapi.v3.property) = {description: "migration version"} + ]; + string mode = 5 [ + json_name = "mode", + (gnostic.openapi.v3.property) = {description: "migration mode"} + ]; +} diff --git a/third_party/config/data/database/v1/mongo.proto b/third_party/config/data/database/v1/mongo.proto new file mode 100644 index 00000000..c919bda1 --- /dev/null +++ b/third_party/config/data/database/v1/mongo.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; + +package runtime.api.config.data.database.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/database/v1;databasev1"; + +// MongoConfig defines the configuration for a MongoDB connection. +// This message was extracted from storage.proto and renamed for consistency. +message MongoConfig { + string uri = 1 [ + json_name = "uri", + (gnostic.openapi.v3.property) = {description: "MongoDB connection URI"} + ]; + string database = 2 [ + json_name = "database", + (gnostic.openapi.v3.property) = {description: "Database name"} + ]; + string username = 3 [ + json_name = "username", + (gnostic.openapi.v3.property) = {description: "username"} + ]; + string password = 4 [ + json_name = "password", + (gnostic.openapi.v3.property) = {description: "password"} + ]; + bool auth_source = 5 [ + json_name = "auth_source", + (gnostic.openapi.v3.property) = {description: "auth source"} + ]; + int32 max_pool_size = 6 [ + json_name = "max_pool_size", + (gnostic.openapi.v3.property) = {description: "max pool size"} + ]; + int32 min_pool_size = 7 [ + json_name = "min_pool_size", + (gnostic.openapi.v3.property) = {description: "min pool size"} + ]; + int64 connect_timeout = 8 [ + json_name = "connect_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Connection timeout in milliseconds"} + ]; +} diff --git a/third_party/config/data/oss/v1/object_meta.proto b/third_party/config/data/oss/v1/object_meta.proto new file mode 100644 index 00000000..53ed2242 --- /dev/null +++ b/third_party/config/data/oss/v1/object_meta.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; + +package runtime.api.config.data.oss.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/oss/v1;ossv1"; + +// ObjectMeta defines the metadata for an object in object storage. +message ObjectMeta { + string id = 1 [ + json_name = "id", + (gnostic.openapi.v3.property) = {description: "The unique identifier for the object."} + ]; + string name = 2 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "The name of the object."} + ]; + string hash = 3 [ + json_name = "hash", + (gnostic.openapi.v3.property) = {description: "The hash of the object content (e.g., SHA256)."} + ]; + int64 size = 4 [ + json_name = "size", + (gnostic.openapi.v3.property) = {description: "The size of the object in bytes."} + ]; + string mime_type = 5 [ + json_name = "mime_type", + (gnostic.openapi.v3.property) = {description: "The MIME type of the object."} + ]; + int64 mod_time = 6 [ + json_name = "mod_time", + (gnostic.openapi.v3.property) = {description: "The last modification time as a Unix timestamp."} + ]; +} diff --git a/third_party/config/data/oss/v1/object_service.proto b/third_party/config/data/oss/v1/object_service.proto new file mode 100644 index 00000000..a285285b --- /dev/null +++ b/third_party/config/data/oss/v1/object_service.proto @@ -0,0 +1,200 @@ +syntax = "proto3"; + +package runtime.api.config.data.oss.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/oss/v1;ossv1"; + +// ObjectInfo describes an object or a directory-like prefix in object storage. +message ObjectInfo { + string name = 1 [(gnostic.openapi.v3.property) = {description: "The name of the object or directory-like prefix."}]; + string path = 2 [(gnostic.openapi.v3.property) = {description: "The full path of the object or directory-like prefix."}]; + bool is_dir = 3 [(gnostic.openapi.v3.property) = {description: "Whether the entry is a directory-like prefix."}]; + int64 size = 4 [(gnostic.openapi.v3.property) = {description: "The size of the object in bytes."}]; + google.protobuf.Timestamp mod_time = 5 [(gnostic.openapi.v3.property) = {description: "The last modification time."}]; +} + +// ObjectService defines the operations for object and directory-like prefix manipulation in object storage. +service ObjectService { + // --- Basic Operations --- + + // List objects and directory-like prefixes at a given path. + rpc List(ListRequest) returns (ListResponse) { + option (google.api.http) = {get: "/v1/object/list"}; + } + + // Get information about a single object or directory-like prefix. + rpc Stat(StatRequest) returns (StatResponse) { + option (google.api.http) = {get: "/v1/object/stat"}; + } + + // Create a new directory-like prefix. + rpc Mkdir(MkdirRequest) returns (MkdirResponse) { + option (google.api.http) = { + post: "/v1/object/mkdir" + body: "*" + }; + } + + // Delete an object or directory-like prefix. + rpc Delete(DeleteRequest) returns (DeleteResponse) { + option (google.api.http) = { + post: "/v1/object/delete" + body: "*" + }; + } + + // Rename or move an object or directory-like prefix. + rpc Rename(RenameRequest) returns (RenameResponse) { + option (google.api.http) = { + post: "/v1/object/rename" + body: "*" + }; + } + + // --- Streaming Operations --- + + // Read an object's content as a stream. + rpc Read(ReadRequest) returns (stream ReadResponse) { + option (google.api.http) = {get: "/v1/object/read"}; + } + + // Write an object's content via a stream. + // NOTE: This is suitable for reliable networks. For client-side uploads, + // use the chunked upload methods. + rpc Write(stream WriteRequest) returns (WriteResponse) {} + + // --- Chunked Upload Operations --- + + // Initiates a new chunked upload and returns an upload_id. + rpc InitiateUpload(InitiateUploadRequest) returns (InitiateUploadResponse) { + option (google.api.http) = { + post: "/v1/object/uploads:initiate" + body: "*" + }; + } + + // Uploads a chunk of data for a given upload_id. + // NOTE: gRPC-Gateway does not support client-streaming RPCs well for object uploads. + // This RPC should be called directly via gRPC or a custom HTTP handler. + rpc UploadChunk(stream UploadChunkRequest) returns (UploadChunkResponse) {} + + // Finalizes a chunked upload, assembling the chunks into the final object. + rpc FinalizeUpload(FinalizeUploadRequest) returns (FinalizeUploadResponse) { + option (google.api.http) = { + post: "/v1/object/uploads:finalize" + body: "*" + }; + } +} + +// --- Message Definitions for Basic Operations --- + +message ListRequest { + string path = 1 [(gnostic.openapi.v3.property) = {description: "The path of the directory-like prefix to list."}]; +} + +message ListResponse { + repeated ObjectInfo files = 1 [(gnostic.openapi.v3.property) = {description: "A list of objects and directory-like prefixes."}]; +} + +message StatRequest { + string path = 1 [(gnostic.openapi.v3.property) = {description: "The path of the object or directory-like prefix to get information about."}]; +} + +message StatResponse { + ObjectInfo file = 1 [(gnostic.openapi.v3.property) = {description: "Information about the object or directory-like prefix."}]; +} + +message MkdirRequest { + string path = 1 [(gnostic.openapi.v3.property) = {description: "The path of the directory-like prefix to create."}]; +} + +message MkdirResponse {} + +message DeleteRequest { + string path = 1 [(gnostic.openapi.v3.property) = {description: "The path of the object or directory-like prefix to delete."}]; + // Optional: If true and path is a directory-like prefix, delete it recursively. + bool recursive = 2 [(gnostic.openapi.v3.property) = {description: "Whether to delete recursively if the path is a directory-like prefix."}]; +} + +message DeleteResponse {} + +message RenameRequest { + string from_path = 1 [(gnostic.openapi.v3.property) = {description: "The original path of the object or directory-like prefix."}]; + string to_path = 2 [(gnostic.openapi.v3.property) = {description: "The new path for the object or directory-like prefix."}]; +} + +message RenameResponse {} + +// --- Message Definitions for Streaming Operations --- + +message ReadRequest { + string path = 1 [(gnostic.openapi.v3.property) = {description: "The path of the object to read."}]; +} + +message ReadResponse { + bytes chunk = 1 [(gnostic.openapi.v3.property) = {description: "A chunk of the object's content."}]; +} + +message WriteRequest { + oneof data { + // The first message must contain the metadata. + WriteRequestMetadata metadata = 1; + // Subsequent messages contain the object's binary chunks. + bytes chunk = 2; + } +} + +message WriteRequestMetadata { + string path = 1 [(gnostic.openapi.v3.property) = {description: "The path of the object to write to."}]; +} + +message WriteResponse { + int64 size = 1 [(gnostic.openapi.v3.property) = {description: "The total size of the written object."}]; + string path = 2 [(gnostic.openapi.v3.property) = {description: "The path of the written object."}]; +} + +// --- Message Definitions for Chunked Upload --- + +message InitiateUploadRequest { + string path = 1 [(gnostic.openapi.v3.property) = {description: "The final path for the object being uploaded."}]; +} + +message InitiateUploadResponse { + string upload_id = 1 [(gnostic.openapi.v3.property) = {description: "A unique ID for the chunked upload session."}]; +} + +message UploadChunkRequest { + oneof data { + // The first message of a new chunk stream can contain metadata. + UploadChunkMetadata metadata = 1; + // Subsequent messages contain the object's binary chunks. + bytes chunk = 2; + } +} + +message UploadChunkMetadata { + string upload_id = 1 [(gnostic.openapi.v3.property) = {description: "The ID of the chunked upload session."}]; + // The position in the object to write this chunk. + int64 offset = 2 [(gnostic.openapi.v3.property) = {description: "The byte offset in the object to write this chunk."}]; +} + +message UploadChunkResponse { + string upload_id = 1 [(gnostic.openapi.v3.property) = {description: "The ID of the chunked upload session."}]; + // The number of bytes successfully written. + int64 written_size = 2 [(gnostic.openapi.v3.property) = {description: "The number of bytes successfully written in this chunk."}]; +} + +message FinalizeUploadRequest { + string upload_id = 1 [(gnostic.openapi.v3.property) = {description: "The ID of the chunked upload session to finalize."}]; + // Optional: The SHA256 checksum of the entire object for validation. + string content_sha256 = 2 [(gnostic.openapi.v3.property) = {description: "Optional SHA256 checksum of the entire object for validation."}]; +} + +message FinalizeUploadResponse { + ObjectInfo file = 1 [(gnostic.openapi.v3.property) = {description: "Information about the finalized object."}]; +} diff --git a/third_party/config/data/oss/v1/objectstore.proto b/third_party/config/data/oss/v1/objectstore.proto new file mode 100644 index 00000000..6208557c --- /dev/null +++ b/third_party/config/data/oss/v1/objectstore.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; + +package runtime.api.config.data.oss.v1; + +import "config/data/oss/v1/oss_local.proto"; +import "config/data/oss/v1/oss.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/oss/v1;ossv1"; + +// ObjectStoreConfig groups all "object storage" type backends into one category. +// It uses the 'driver' field to determine which specific implementation to use. +// This message was extracted from storage.proto and renamed for consistency. +message ObjectStoreConfig { + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "object store name"} + ]; + + // The 'driver' field determines which configuration block to use. + // For built-in drivers, specify "local" or "oss". + // For custom drivers, specify the registered name of the custom driver (e.g., "sftp"). + // When a custom driver is used, its configuration should be placed in the 'customize' field. + string driver = 2 [ + json_name = "driver", + (gnostic.openapi.v3.property) = {description: "Object store driver name. Built-in: 'local', 'oss'. Custom drivers use their registered name."} + ]; + + // Local file system configuration. Only effective when driver is "local". + optional OssLocalConfig local = 3 [ + json_name = "local", + (gnostic.openapi.v3.property) = {description: "local object storage configuration"} + ]; + + // Cloud object storage configuration. Only effective when driver is "oss". + optional OssConfig oss = 4 [ + json_name = "oss", + (gnostic.openapi.v3.property) = {description: "cloud object storage configuration"} + ]; + + // Chunk size in bytes for splitting large objects. + // For OSS, this corresponds to the multipart upload part size. + // For local storage, it defines the size of individual blob files. + // If 0 or not set, a reasonable default (e.g., 4MB) will be used by the implementation. + int64 chunk_size = 5 [ + json_name = "chunk_size", + (gnostic.openapi.v3.property) = {description: "chunk size in bytes"} + ]; + + // Optional custom configuration for drivers not explicitly defined as 'local' or 'oss'. + optional google.protobuf.Struct customize = 6 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Custom configuration for drivers not explicitly defined as 'local' or 'oss'."} + ]; +} diff --git a/third_party/config/data/oss/v1/oss.proto b/third_party/config/data/oss/v1/oss.proto new file mode 100644 index 00000000..96d3bee9 --- /dev/null +++ b/third_party/config/data/oss/v1/oss.proto @@ -0,0 +1,144 @@ +syntax = "proto3"; + +package runtime.api.config.data.oss.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/oss/v1;ossv1"; + +// OssConfig defines the configuration for cloud object storage. +// This message was extracted from storage.proto and renamed for consistency. +message OssConfig { + string endpoint = 1 [ + json_name = "endpoint", + (gnostic.openapi.v3.property) = {description: "Storage service endpoint"} + ]; + string access_key_id = 2 [ + json_name = "access_key_id", + (gnostic.openapi.v3.property) = {description: "The access key ID for authentication."} + ]; + string access_key_secret = 3 [ + json_name = "access_key_secret", + (gnostic.openapi.v3.property) = {description: "The access key secret for authentication."} + ]; + string bucket = 4 [ + json_name = "bucket", + (gnostic.openapi.v3.property) = {description: "The name of the bucket to use."} + ]; + string region = 5 [ + json_name = "region", + (gnostic.openapi.v3.property) = {description: "The geographic region of the bucket."} + ]; + bool ssl = 6 [ + json_name = "ssl", + (gnostic.openapi.v3.property) = {description: "Whether to use SSL for the connection."} + ]; + int64 connect_timeout = 7 [ + json_name = "connect_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Connection timeout in milliseconds"} + ]; + int64 read_timeout = 8 [ + json_name = "read_timeout", + (validate.rules).int64.gte = 0, + (gnostic.openapi.v3.property) = {description: "Read timeout in milliseconds"} + ]; + + // Optional: Bucket policy configuration. + optional BucketPolicy bucket_policy = 9 [ + json_name = "bucket_policy", + (gnostic.openapi.v3.property) = {description: "Bucket access policy configuration"} + ]; + + // Optional: Lifecycle management rules. + repeated LifecycleRule lifecycle_rules = 10 [ + json_name = "lifecycle_rules", + (gnostic.openapi.v3.property) = {description: "List of lifecycle management rules"} + ]; + + // Optional: Versioning configuration. + optional bool versioning_enabled = 11 [ + json_name = "versioning_enabled", + (gnostic.openapi.v3.property) = {description: "Whether to enable object versioning for the bucket"} + ]; +} + +// BucketPolicy defines the access control policy for an OSS bucket. +message BucketPolicy { + // Policy document in JSON format. + string policy_document = 1 [ + json_name = "policy_document", + (gnostic.openapi.v3.property) = {description: "Access policy document in JSON format"} + ]; +} + +// LifecycleRule defines a single lifecycle management rule for objects in an OSS bucket. +message LifecycleRule { + // Unique ID for the rule. + string id = 1 [ + json_name = "id", + (gnostic.openapi.v3.property) = {description: "Unique ID for the lifecycle rule"} + ]; + // Prefix for objects to which the rule applies. + optional string prefix = 2 [ + json_name = "prefix", + (gnostic.openapi.v3.property) = {description: "Object key prefix to which the rule applies"} + ]; + // Status of the rule (e.g., "Enabled", "Disabled"). + string status = 3 [ + json_name = "status", + (gnostic.openapi.v3.property) = {description: "Status of the lifecycle rule (e.g., Enabled, Disabled)"} + ]; + + // Actions to take on objects. + optional Expiration expiration = 4 [ + json_name = "expiration", + (gnostic.openapi.v3.property) = {description: "Object expiration configuration"} + ]; + optional Transition transition = 5 [ + json_name = "transition", + (gnostic.openapi.v3.property) = {description: "Object transition to another storage class configuration"} + ]; + optional NoncurrentVersionExpiration noncurrent_version_expiration = 6 [ + json_name = "noncurrent_version_expiration", + (gnostic.openapi.v3.property) = {description: "Noncurrent object version expiration configuration"} + ]; +} + +// Expiration defines when objects expire. +message Expiration { + // Number of days after object creation when it expires. + optional int32 days = 1 [ + json_name = "days", + (gnostic.openapi.v3.property) = {description: "Number of days after object creation when it expires"} + ]; + // Specific date when objects expire (YYYY-MM-DD format). + optional string date = 2 [ + json_name = "date", + (gnostic.openapi.v3.property) = {description: "Specific date when objects expire (YYYY-MM-DD format)"} + ]; +} + +// Transition defines when objects transition to another storage class. +message Transition { + // Number of days after object creation when it transitions. + optional int32 days = 1 [ + json_name = "days", + (gnostic.openapi.v3.property) = {description: "Number of days after object creation when it transitions"} + ]; + // Target storage class (e.g., "IA", "Archive"). + string storage_class = 2 [ + json_name = "storage_class", + (gnostic.openapi.v3.property) = {description: "Target storage class (e.g., IA, Archive)"} + ]; +} + +// NoncurrentVersionExpiration defines when noncurrent object versions expire. +message NoncurrentVersionExpiration { + // Number of days after the object becomes noncurrent when it expires. + int32 noncurrent_days = 1 [ + json_name = "noncurrent_days", + (gnostic.openapi.v3.property) = {description: "Number of days after the object becomes noncurrent when it expires"} + ]; +} diff --git a/third_party/config/data/oss/v1/oss_local.proto b/third_party/config/data/oss/v1/oss_local.proto new file mode 100644 index 00000000..1301e4f9 --- /dev/null +++ b/third_party/config/data/oss/v1/oss_local.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package runtime.api.config.data.oss.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/oss/v1;ossv1"; + +// OssLocalConfig defines the configuration for local object storage. +// This message was extracted from storage.proto and renamed for consistency. +message OssLocalConfig { + string root = 1 [ + json_name = "root", + (gnostic.openapi.v3.property) = {description: "root directory"} + ]; +} diff --git a/third_party/config/data/v1/data.proto b/third_party/config/data/v1/data.proto new file mode 100644 index 00000000..89b34045 --- /dev/null +++ b/third_party/config/data/v1/data.proto @@ -0,0 +1,121 @@ +syntax = "proto3"; + +package runtime.api.config.data.v1; + +import "config/data/cache/v1/cache.proto"; +import "config/data/database/v1/database.proto"; +import "config/data/database/v1/document.proto"; +import "config/data/oss/v1/objectstore.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/data/v1;datav1"; + +// Data is the top-level configuration for all data-related components. +message Data { + // FileStore configurations. + optional ObjectStores object_stores = 1 [ + json_name = "object_stores", + (gnostic.openapi.v3.property) = {description: "ObjectStore configurations"} + ]; + + // Cache configurations. + optional Caches caches = 2 [ + json_name = "caches", + (gnostic.openapi.v3.property) = {description: "Cache configurations"} + ]; + + // Relational Database configurations (SQL). + optional Databases databases = 3 [ + json_name = "databases", + (gnostic.openapi.v3.property) = {description: "Relational Database configurations (SQL)"} + ]; + + // Document Database configurations (e.g., MongoDB). + optional Documents documents = 4 [ + json_name = "documents", + (gnostic.openapi.v3.property) = {description: "Document Database configurations (e.g., MongoDB)"} + ]; + + // Optional custom configuration for Data components not explicitly defined. + optional google.protobuf.Struct customize = 100 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Custom configuration for Data components not explicitly defined."} + ]; +} + +// FileStores is a collection of named FileStore configurations. +message ObjectStores { + // Default filestore name. + optional string default = 1 [ + json_name = "default", + (gnostic.openapi.v3.property) = {description: "Default filestore name"} + ]; + // Active filestore name, overrides default. + optional string active = 2 [ + json_name = "active", + (gnostic.openapi.v3.property) = {description: "Active filestore name, overrides default"} + ]; + // List of named FileStore configurations. + repeated config.data.oss.v1.ObjectStoreConfig configs = 3 [ + json_name = "configs", + (gnostic.openapi.v3.property) = {description: "List of named FileStore configurations"} + ]; +} + +// Caches is a collection of named Cache configurations. +message Caches { + // Default cache name. + optional string default = 1 [ + json_name = "default", + (gnostic.openapi.v3.property) = {description: "Default cache name"} + ]; + // Active cache name, overrides default. + optional string active = 2 [ + json_name = "active", + (gnostic.openapi.v3.property) = {description: "Active cache name, overrides default"} + ]; + // List of named Cache configurations. + repeated config.data.cache.v1.CacheConfig configs = 3 [ + json_name = "configs", + (gnostic.openapi.v3.property) = {description: "List of named Cache configurations"} + ]; +} + +// Databases is a collection of named Relational Database configurations. +message Databases { + // Default database name. + optional string default = 1 [ + json_name = "default", + (gnostic.openapi.v3.property) = {description: "Default database name"} + ]; + // Active database name, overrides default. + optional string active = 2 [ + json_name = "active", + (gnostic.openapi.v3.property) = {description: "Active database name, overrides default"} + ]; + // List of named Relational Database configurations. + repeated config.data.database.v1.DatabaseConfig configs = 3 [ + json_name = "configs", + (gnostic.openapi.v3.property) = {description: "List of named Relational Database configurations"} + ]; +} + +// Documents is a collection of named Document Database configurations. +message Documents { + // Default document database name. + optional string default = 1 [ + json_name = "default", + (gnostic.openapi.v3.property) = {description: "Default document database name"} + ]; + // Active document database name, overrides default. + optional string active = 2 [ + json_name = "active", + (gnostic.openapi.v3.property) = {description: "Active document database name, overrides default"} + ]; + // List of named Document Database configurations. + repeated config.data.database.v1.DocumentConfig configs = 3 [ + json_name = "configs", + (gnostic.openapi.v3.property) = {description: "List of named Document Database configurations"} + ]; +} diff --git a/third_party/config/discovery/v1/discovery.proto b/third_party/config/discovery/v1/discovery.proto new file mode 100644 index 00000000..9ce68337 --- /dev/null +++ b/third_party/config/discovery/v1/discovery.proto @@ -0,0 +1,152 @@ +syntax = "proto3"; + +package runtime.api.config.discovery.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/discovery/v1;discoveryv1"; + +// Discovery defines the configuration for service registration. +message Discovery { + // name is the the service key in the registry. + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "The name of the discovery service configuration."} + ]; + + // The 'type' field determines which discovery provider to use. + // For built-in types, specify "consul", "etcd", "nacos", etc. + // For custom types, specify the registered name of the custom discovery provider. + // When a custom type is used, its configuration should be placed in the 'customize' field. + string type = 2 [ + json_name = "type", + (gnostic.openapi.v3.property) = {description: "The type of discovery provider to use. Built-in: 'consul', 'etcd', 'nacos', etc. Custom types use their registered name."} + ]; + + // debug enables verbose logging for the discovery client. + bool debug = 5 [ + json_name = "debug", + (gnostic.openapi.v3.property) = {description: "Enables verbose logging for the discovery client."} + ]; + + // --- Standard Provider Configurations --- + optional Consul consul = 10 [ + json_name = "consul", + (gnostic.openapi.v3.property) = {description: "Consul provider specific configuration."} + ]; + optional ETCD etcd = 11 [ + json_name = "etcd", + (gnostic.openapi.v3.property) = {description: "ETCD provider specific configuration."} + ]; + optional Nacos nacos = 12 [ + json_name = "nacos", + (gnostic.openapi.v3.property) = {description: "Nacos provider specific configuration."} + ]; + optional Apollo apollo = 13 [ + json_name = "apollo", + (gnostic.openapi.v3.property) = {description: "Apollo provider specific configuration."} + ]; + optional Kubernetes kubernetes = 14 [ + json_name = "kubernetes", + (gnostic.openapi.v3.property) = {description: "Kubernetes provider specific configuration."} + ]; + optional Polaris polaris = 15 [ + json_name = "polaris", + (gnostic.openapi.v3.property) = {description: "Polaris provider specific configuration."} + ]; + optional google.protobuf.Struct customize = 100 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Custom discovery provider configuration."} + ]; +} + +message Discoveries { + // default is the name of the discovery service to use by default. + optional string default = 1 [ + json_name = "default", + (gnostic.openapi.v3.property) = {description: "The name of the discovery service to use by default."} + ]; + + // active specifies the name of the discovery service to use, overriding the default. + optional string active = 2 [ + json_name = "active", + (gnostic.openapi.v3.property) = {description: "The name of the discovery service to use, overriding the default."} + ]; + + repeated Discovery configs = 3 [ + json_name = "configs", + (gnostic.openapi.v3.property) = {description: "A list of discovery service configurations."} + ]; +} + +// --- Message Definitions for Each Provider --- + +// Consul provider specific configuration. +message Consul { + string address = 1 [ + json_name = "address", + (gnostic.openapi.v3.property) = {description: "The address of the Consul agent."} + ]; + string scheme = 2 [ + json_name = "scheme", + (gnostic.openapi.v3.property) = {description: "The scheme to use for connecting to Consul (e.g., http, https)."} + ]; + string token = 3 [ + json_name = "token", + (gnostic.openapi.v3.property) = {description: "The ACL token for Consul authentication."} + ]; + bool heart_beat = 4 [ + json_name = "heart_beat", + (gnostic.openapi.v3.property) = {description: "Whether to enable heartbeating for service health checks."} + ]; + bool health_check = 5 [ + json_name = "health_check", + (gnostic.openapi.v3.property) = {description: "Whether to enable health checks for registered services."} + ]; + string datacenter = 6 [ + json_name = "datacenter", + (gnostic.openapi.v3.property) = {description: "The datacenter to use for Consul operations."} + ]; + uint32 health_check_interval = 8 [ + json_name = "health_check_interval", + (gnostic.openapi.v3.property) = {description: "The interval (in seconds) for health checks."} + ]; + int64 timeout = 10 [ + json_name = "timeout", + (gnostic.openapi.v3.property) = {description: "The timeout (in milliseconds) for Consul operations."} + ]; + uint32 deregister_critical_service_after = 11 [ + json_name = "deregister_critical_service_after", + (gnostic.openapi.v3.property) = {description: "The time (in seconds) after which a critical service will be deregistered."} + ]; +} + +// ETCD provider specific configuration. +message ETCD { + repeated string endpoints = 1 [(gnostic.openapi.v3.property) = {description: "List of ETCD server endpoints."}]; +} + +// Nacos provider specific configuration (placeholder). +message Nacos { + // e.g., string server_addr = 1; + // e.g., string namespace_id = 2; +} + +// Apollo provider specific configuration (placeholder). +message Apollo { + // e.g., string meta_server_addr = 1; + // e.g., string app_id = 2; +} + +// Kubernetes provider specific configuration (placeholder). +message Kubernetes { + // e.g., string kube_config_path = 1; +} + +// Polaris provider specific configuration (placeholder). +message Polaris { + string address = 1 [(gnostic.openapi.v3.property) = {description: "The address of the Polaris server."}]; + string scheme = 2 [(gnostic.openapi.v3.property) = {description: "The scheme to use for connecting to Polaris (e.g., http, https)."}]; + string token = 3 [(gnostic.openapi.v3.property) = {description: "The token for Polaris authentication."}]; +} diff --git a/third_party/config/discovery/v1/endpoint.proto b/third_party/config/discovery/v1/endpoint.proto new file mode 100644 index 00000000..05cde21e --- /dev/null +++ b/third_party/config/discovery/v1/endpoint.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package runtime.api.config.discovery.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/discovery/v1;discoveryv1"; + +// +// DEPRECATED: This file is deprecated and will be removed in a future version. +// The concepts of Endpoint and Selector have been merged into the ClientConfig +// messages within `transport/v1/transport.proto` for better cohesion and clarity. +// +// - Use `GrpcClientConfig.discovery_filter` or `HttpClientConfig.discovery_filter` +// instead of `Selector`. +// - Use `GrpcClientConfig.endpoint` or `HttpClientConfig.endpoint` +// instead of `Endpoint.uri`. +// + +// Endpoint holds the complete, resolved configuration for a client-side service endpoint. +message Endpoint { + option deprecated = true; + + // The name is the name of the service key in the endpoint. + string name = 1 [(gnostic.openapi.v3.property) = {description: "The name of the service key in the endpoint."}]; + + // The discovery_name is the name of the service key in the discovery service. + string discovery_name = 2 [ + json_name = "discovery_name", + (gnostic.openapi.v3.property) = {description: "The name of the service key in the discovery service."} + ]; + + // The endpoint URI to resolve, e.g., "discovery:///user-service". + string uri = 3 [(gnostic.openapi.v3.property) = {description: "The endpoint URI to resolve, e.g., \"discovery:///user-service\"."}]; + + // Selector for client-side load balancing and node filtering. + Selector selector = 4 [(gnostic.openapi.v3.property) = {description: "Selector for client-side load balancing and node filtering."}]; +} + +// Selector defines the client-side node selection strategy. +message Selector { + option deprecated = true; + + // The type of selector to use, e.g., "random", "wrr", "p2c". + string type = 1 [(gnostic.openapi.v3.property) = {description: "The type of selector to use, e.g., \"random\", \"wrr\", \"p2c\"."}]; + // version is used for version-based routing. + string version = 2 [(gnostic.openapi.v3.property) = {description: "Version is used for version-based routing."}]; +} diff --git a/third_party/config/logger/v1/logger.proto b/third_party/config/logger/v1/logger.proto new file mode 100644 index 00000000..7d9bb36d --- /dev/null +++ b/third_party/config/logger/v1/logger.proto @@ -0,0 +1,182 @@ +syntax = "proto3"; + +package runtime.api.config.logger.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/logger/v1;loggerv1"; + +// Logger level +enum LoggerLevel { + LOGGER_LEVEL_UNSPECIFIED = 0; + LOGGER_LEVEL_DEBUG = 1; + LOGGER_LEVEL_INFO = 2; + LOGGER_LEVEL_WARN = 3; + LOGGER_LEVEL_ERROR = 4; + LOGGER_LEVEL_FATAL = 5; +} + +// Logger hook message +message LoggerHookMessage { + string level = 1 [ + json_name = "level", + (gnostic.openapi.v3.property) = {description: "The log level of the message."} + ]; + string message = 2 [ + json_name = "message", + (gnostic.openapi.v3.property) = {description: "The log message content."} + ]; + string stacktrace = 3 [ + json_name = "stacktrace", + (gnostic.openapi.v3.property) = {description: "The stack trace if available."} + ]; + string error = 4 [ + json_name = "error", + (gnostic.openapi.v3.property) = {description: "The error message if available."} + ]; + map fields = 5 [ + json_name = "fields", + (gnostic.openapi.v3.property) = {description: "Additional fields associated with the log message."} + ]; +} + +// Logger +message Logger { + // Logger file + message File { + string path = 1 [ + json_name = "path", + (gnostic.openapi.v3.property) = {description: "The path to the log file."} + ]; + bool lumberjack = 2 [ + json_name = "lumberjack", + (gnostic.openapi.v3.property) = {description: "Whether to use lumberjack for log rotation."} + ]; + bool compress = 3 [ + json_name = "compress", + (gnostic.openapi.v3.property) = {description: "Whether to compress old log files."} + ]; + bool local_time = 4 [ + json_name = "local_time", + (gnostic.openapi.v3.property) = {description: "Whether to use local time for log timestamps."} + ]; + int32 max_size = 5 [ + json_name = "max_size", + (gnostic.openapi.v3.property) = {description: "The maximum size in megabytes of the log file before rotation."} + ]; + int32 max_age = 6 [ + json_name = "max_age", + (gnostic.openapi.v3.property) = {description: "The maximum number of days to retain old log files."} + ]; + int32 max_backups = 7 [ + json_name = "max_backups", + (gnostic.openapi.v3.property) = {description: "The maximum number of old log files to retain."} + ]; + } + + // Dev logger + message DevLogger { + uint32 max_slice = 1 [ + json_name = "max_slice", + (gnostic.openapi.v3.property) = {description: "Maximum slice length for development logger."} + ]; + bool sort_keys = 2 [ + json_name = "sort_keys", + (gnostic.openapi.v3.property) = {description: "Whether to sort keys in development logger output."} + ]; + bool newline = 3 [ + json_name = "newline", + (gnostic.openapi.v3.property) = {description: "Whether to add a newline at the end of development logger output."} + ]; + bool indent = 4 [ + json_name = "indent", + (gnostic.openapi.v3.property) = {description: "Whether to indent development logger output."} + ]; + uint32 debug_color = 5 [ + json_name = "debug_color", + (gnostic.openapi.v3.property) = {description: "Color code for debug level in development logger."} + ]; + uint32 info_color = 6 [ + json_name = "info_color", + (gnostic.openapi.v3.property) = {description: "Color code for info level in development logger."} + ]; + uint32 warn_color = 7 [ + json_name = "warn_color", + (gnostic.openapi.v3.property) = {description: "Color code for warn level in development logger."} + ]; + uint32 error_color = 8 [ + json_name = "error_color", + (gnostic.openapi.v3.property) = {description: "Color code for error level in development logger."} + ]; + uint32 max_trace = 9 [ + json_name = "max_trace", + (gnostic.openapi.v3.property) = {description: "Maximum trace depth for development logger."} + ]; + bool formatter = 10 [ + json_name = "formatter", + (gnostic.openapi.v3.property) = {description: "Whether to use a custom formatter for development logger."} + ]; + } + + // Disable logger + bool disabled = 1 [ + json_name = "disabled", + (gnostic.openapi.v3.property) = {description: "Whether to disable the logger."} + ]; + // Enable dev logger output + bool develop = 2 [ + json_name = "develop", + (gnostic.openapi.v3.property) = {description: "Whether to enable development logger output."} + ]; + // Set default logger + bool default = 3 [ + json_name = "default", + (gnostic.openapi.v3.property) = {description: "Whether this is the default logger configuration."} + ]; + // Logger name + string name = 4 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "The name of the logger instance."} + ]; + // Logger format json text or tint + string format = 5 [ + json_name = "format", + (gnostic.openapi.v3.property) = {description: "The output format of the logger (e.g., json, text, tint)."} + ]; + // Logger level + string level = 6 [ + json_name = "level", + (gnostic.openapi.v3.property) = {description: "The minimum logging level (e.g., debug, info, warn, error, fatal)."} + ]; + // Logger output stdout + bool stdout = 7 [ + json_name = "stdout", + (gnostic.openapi.v3.property) = {description: "Whether to output logs to standard output."} + ]; + // Disable logger caller + bool disable_caller = 8 [ + json_name = "disable_caller", + (gnostic.openapi.v3.property) = {description: "Whether to disable logging the caller's file and line number."} + ]; + // Logger caller skip + uint32 caller_skip = 9 [ + json_name = "caller_skip", + (gnostic.openapi.v3.property) = {description: "The number of stack frames to skip when determining the caller."} + ]; + // Logger time format + string time_format = 10 [ + json_name = "time_format", + (gnostic.openapi.v3.property) = {description: "The format for log timestamps (e.g., RFC3339)."} + ]; + + // Logger file output logger + File file = 100 [ + json_name = "file", + (gnostic.openapi.v3.property) = {description: "File output configuration for the logger."} + ]; + // Logger dev logger logger + DevLogger dev_logger = 101 [ + json_name = "dev_logger", + (gnostic.openapi.v3.property) = {description: "Development logger configuration."} + ]; //DevLogger +} diff --git a/third_party/config/mail/v1/mail.proto b/third_party/config/mail/v1/mail.proto new file mode 100644 index 00000000..1392a65a --- /dev/null +++ b/third_party/config/mail/v1/mail.proto @@ -0,0 +1,65 @@ +syntax = "proto3"; + +package runtime.api.config.mail.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/mail/v1;mailv1"; + +// Mail represents the general configuration for a mail service. +message Mail { + // Common mailer settings + string nickname = 1 [ + json_name = "nickname", + (gnostic.openapi.v3.property) = {description: "The nickname or sender name for the mailer."} + ]; + string from = 2 [ + json_name = "from", + (gnostic.openapi.v3.property) = {description: "The sender email address."} + ]; + int32 max_retries = 3 [ + json_name = "max_retries", + (gnostic.openapi.v3.property) = {description: "Maximum number of retries for sending emails."} + ]; + int64 retry_interval = 4 [ + json_name = "retry_interval", + (gnostic.openapi.v3.property) = {description: "Interval in milliseconds between retries."} + ]; + + // Mailer-specific configuration. Only one of these should be set. + optional SmtpConfig smtp_config = 10 [ + json_name = "smtp_config", + (gnostic.openapi.v3.property) = {description: "SMTP mailer configuration."} + ]; + // Add other mailer types here as needed, e.g.: + // optional SendgridConfig sendgrid_config = 11 [json_name = "sendgrid_config"]; + // optional MailgunConfig mailgun_config = 12 [json_name = "mailgun_config"]; +} + +// SmtpConfig represents the configuration for an SMTP mailer. +message SmtpConfig { + string host = 1 [ + json_name = "host", + (gnostic.openapi.v3.property) = {description: "The SMTP server host."} + ]; + int32 port = 2 [ + json_name = "port", + (gnostic.openapi.v3.property) = {description: "The SMTP server port."} + ]; + string username = 3 [ + json_name = "username", + (gnostic.openapi.v3.property) = {description: "Username for SMTP authentication."} + ]; + string password = 4 [ + json_name = "password", + (gnostic.openapi.v3.property) = {description: "Password for SMTP authentication."} + ]; + string token_secret = 5 [ + json_name = "token_secret", + (gnostic.openapi.v3.property) = {description: "Token secret for some SMTP setups or OAuth."} + ]; + bool ssl = 6 [ + json_name = "ssl", + (gnostic.openapi.v3.property) = {description: "Whether to use SSL/TLS for the SMTP connection."} + ]; +} diff --git a/third_party/config/middleware/circuitbreaker/v1/circuitbreaker.proto b/third_party/config/middleware/circuitbreaker/v1/circuitbreaker.proto new file mode 100644 index 00000000..33e98e03 --- /dev/null +++ b/third_party/config/middleware/circuitbreaker/v1/circuitbreaker.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; + +package runtime.api.config.middleware.circuitbreaker.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/middleware/circuitbreaker/v1;circuitbreakerv1"; + +// Endpoint defines a backend service endpoint. +// This is a local copy to avoid circular dependencies. +message Endpoint { + string path = 1 [(gnostic.openapi.v3.property) = {description: "The URL path for the endpoint."}]; + string method = 2 [(gnostic.openapi.v3.property) = {description: "The HTTP method for the endpoint (e.g., GET, POST)."}]; + string host = 10 [(gnostic.openapi.v3.property) = {description: "The host for the endpoint."}]; +} + +// Condition defines a condition for retry or other policies. +// This is a local copy to avoid circular dependencies. +message Condition { + message Header { + string name = 1 [(gnostic.openapi.v3.property) = {description: "The name of the HTTP header."}]; + string value = 2 [(gnostic.openapi.v3.property) = {description: "The expected value of the HTTP header."}]; + } + // "500-599", "429" + optional string by_status_code = 1 [(gnostic.openapi.v3.property) = {description: "Retry if the response status code matches this pattern (e.g., \"500-599\", \"429\")."}]; + // {"name": "grpc-status", "value": "14"} + optional Header by_header = 2 [(gnostic.openapi.v3.property) = {description: "Retry if a specific HTTP header matches the given value."}]; +} + +message Header { + string key = 1; + repeated string value = 2; +} + +message ResponseData { + int32 status_code = 1; + repeated Header header = 2; + bytes body = 3; +} + +message BackupService { + Endpoint endpoint = 1 [json_name = "endpoint"]; +} + +message SuccessRatio { + double success = 1; + int32 request = 2; + int32 bucket = 3; + int64 window = 4; +} + +// CircuitBreaker middleware config. +message CircuitBreaker { + // Only one of success_ratio or ratio should be set. + optional SuccessRatio success_ratio = 1 [json_name = "success_ratio"]; + optional int64 ratio = 2 [json_name = "ratio"]; + + // Only one of response_data or backup_service should be set. + optional ResponseData response_data = 3 [json_name = "response_data"]; + optional BackupService backup_service = 4 [json_name = "backup_service"]; + + repeated Condition assert_condtions = 5 [json_name = "assert_condtions"]; +} diff --git a/third_party/config/middleware/cors/v1/cors.proto b/third_party/config/middleware/cors/v1/cors.proto new file mode 100644 index 00000000..5320a3ed --- /dev/null +++ b/third_party/config/middleware/cors/v1/cors.proto @@ -0,0 +1,101 @@ +syntax = "proto3"; + +package runtime.api.config.middleware.cors.v1; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/middleware/cors/v1;corsv1"; + +// CORS configuration for cross-origin resource sharing +message Cors { + // ===== Basic Configuration ===== + + // Enable debug logging for CORS processing + bool debug = 1 [json_name = "debug"]; + + // ===== Origin Control ===== + + // When true, allows any origin (equivalent to allowed_origins = ["*"]). + // Security Note: Cannot be used with allow_credentials = true. + bool allow_any_origin = 2 [json_name = "allow_any_origin"]; + + // List of allowed origins (e.g., https://example.com). + // Use "*" to allow all origins (not recommended for production). + repeated string allowed_origins = 3 [json_name = "allowed_origins"]; + + // List of origin patterns that are allowed to make requests. + // Supports wildcards (*) for subdomains (e.g., https://*.example.com). + // Example: ["https://*.example.com", "http://localhost:*"] + repeated string allowed_origin_patterns = 4 [json_name = "allowed_origin_patterns"]; + + // Use regular expression to match allowed origins + // Example: ".*\\.example\\.com$" + string allow_origin_regex = 5 [json_name = "allow_origin_regex"]; + + // Allow wildcard (*) in allowed_origins (e.g., "*.example.com") + bool allow_wildcard = 6 [json_name = "allow_wildcard"]; + + // Allow credentials with wildcard origin (not recommended for security reasons) + bool allow_credentials_with_wildcard = 7 [json_name = "allow_credentials_with_wildcard"]; + + // ===== Method & Header Control ===== + + // List of allowed HTTP methods (e.g., GET, POST, PUT, DELETE, OPTIONS) + repeated string allowed_methods = 9 [json_name = "allowed_methods"]; + + // When true, allows any HTTP method in the Access-Control-Request-Method header. + // If false, only methods listed in allowed_methods are allowed. + bool allow_any_method = 10 [json_name = "allow_any_method"]; + + // List of allowed HTTP headers in cross-origin requests + repeated string allowed_headers = 11 [json_name = "allowed_headers"]; + + // When true, allows any header in the Access-Control-Request-Headers header. + // If false, only headers listed in allowed_headers are allowed. + bool allow_any_header = 12 [json_name = "allow_any_header"]; + + // List of headers that can be exposed to the browser in the response + repeated string exposed_headers = 13 [json_name = "exposed_headers"]; + + // List of allowed request header patterns (supports wildcards) + repeated string allowed_request_headers_patterns = 14 [json_name = "allowed_request_headers_patterns"]; + + // ===== Preflight & Caching ===== + + // Maximum age (in seconds) to cache preflight requests + int64 max_age = 19 [json_name = "max_age"]; + + // Custom header name for Max-Age (default: "Access-Control-Max-Age") + string max_age_header = 20 [json_name = "max_age_header"]; + + // When true, passes preflight requests to the next handler + bool preflight_continue = 21 [json_name = "preflight_continue"]; + + // When true, passes OPTIONS requests to the next handler + bool options_passthrough = 22 [json_name = "options_passthrough"]; + + // Status code to return for successful OPTIONS requests + int32 options_success_status = 23 [json_name = "options_success_status"]; + + // ===== Security & Advanced ===== + + // Indicates whether the request can include user credentials (cookies, HTTP authentication). + // Security Note: Cannot be used with wildcard origins ("*") or allow_any_origin = true. + bool allow_credentials = 29 [json_name = "allow_credentials"]; + + // List of HTTP status codes that should be exposed to the CORS client + repeated int32 exposed_status_codes = 30 [json_name = "exposed_status_codes"]; + + // List of response headers that can be exposed to the client + repeated string allowed_response_headers = 31 [json_name = "allowed_response_headers"]; + + // Allow browser extension schemes (chrome-extension://, moz-extension://, etc.) + bool allow_browser_extensions = 32 [json_name = "allow_browser_extensions"]; + + // Allow WebSocket connections + bool allow_web_sockets = 33 [json_name = "allow_web_sockets"]; + + // Allow requests from private network addresses (127.0.0.1, [::1], localhost) + bool allow_private_network = 34 [json_name = "allow_private_network"]; + + // Allow file:// schema (use with caution, not recommended for production) + bool allow_files = 35 [json_name = "allow_files"]; +} diff --git a/third_party/config/middleware/jwt/v1/jwt.proto b/third_party/config/middleware/jwt/v1/jwt.proto new file mode 100644 index 00000000..bea393b1 --- /dev/null +++ b/third_party/config/middleware/jwt/v1/jwt.proto @@ -0,0 +1,84 @@ +syntax = "proto3"; + +package runtime.api.config.middleware.jwt.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/middleware/jwt/v1;jwtv1"; + +// JSON Web Token +message JWT { + string claim_type = 1 [ + json_name = 'claim_type', + (gnostic.openapi.v3.property) = {description: "The type of the claim used to extract the token."} + ]; + google.protobuf.Struct token_header = 2 [json_name = 'token_header']; + // The configuration for creating and validating a JWT. + AuthConfig config = 100 [ + json_name = "config", + (gnostic.openapi.v3.property) = {description: "The configuration used to create the token."} + ]; +} + +// AuthConfig contains configuration parameters for creating and validating a JWT. +message AuthConfig { + string signing_method = 1 [ + json_name = "signing_method", + (validate.rules).string = { + min_len: 1 + max_len: 1024 + pattern: "^[A-Z0-9]+$" + }, + (gnostic.openapi.v3.property) = {description: "The signing method used for the token (e.g., HS256, RS256)."} + ]; + string signing_key = 2 [ + json_name = "signing_key", + (validate.rules).string = { + min_len: 1 + max_len: 1024 + }, + (gnostic.openapi.v3.property) = {description: "The signing key used for signing the token."} + ]; + string secondary_signing_key = 3 [ + json_name = "secondary_signing_key", + (gnostic.openapi.v3.property) = {description: "The secondary signing key used for signing the token."} + ]; + int64 access_token_lifetime = 4 [ + json_name = "access_token_lifetime", + (validate.rules).int64 = { + gte: 1 + lte: 31536000 + }, + (gnostic.openapi.v3.property) = {description: "The lifetime of the access token in seconds. A common value is 7200 (2 hours)."} + ]; + int64 refresh_token_lifetime = 5 [ + json_name = "refresh_token_lifetime", + (validate.rules).int64 = { + gte: 1 + lte: 31536000 + }, + (gnostic.openapi.v3.property) = {description: "The lifetime of the refresh token in seconds."} + ]; + string issuer = 6 [ + json_name = "issuer", + (gnostic.openapi.v3.property) = {description: "The issuer of the token."} + ]; + repeated string audience = 7 [ + json_name = "audience", + (validate.rules).repeated = { + min_items: 1 + max_items: 1024 + unique: true + }, + (gnostic.openapi.v3.property) = {description: "The audience for which the token is intended."} + ]; // Audience + // Optional: Defines how to extract the token from the request. + // Defaults to "header:Authorization" with "Bearer " prefix. + // Example: "cookie:access_token" + optional string token_source = 8 [ + json_name = "token_source", + (gnostic.openapi.v3.property) = {description: "Defines how to extract the token from the request. Defaults to 'header:Authorization'."} + ]; +} diff --git a/third_party/config/middleware/metrics/v1/metrics.proto b/third_party/config/middleware/metrics/v1/metrics.proto new file mode 100644 index 00000000..a290863d --- /dev/null +++ b/third_party/config/middleware/metrics/v1/metrics.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +package runtime.api.config.middleware.metrics.v1; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/middleware/metrics/v1;metricsv1"; + +message UserMetric { + // Timestamp: indicates the time of indicator data + int64 timestamp = 1; + // Indicator name + string name = 2; + // Indicator value + double value = 3; + // Indicator label for classification or filtering + map labels = 4; + // Indicator unit + string unit = 5; + // Type of indicator (e.g. counter, timer, histogram, etc.) + enum MetricType { + METRIC_TYPE_UNSPECIFIED = 0; + METRIC_TYPE_COUNTER = 1; + METRIC_TYPE_GAUGE = 2; + METRIC_TYPE_HISTOGRAM = 3; + METRIC_TYPE_SUMMARY = 4; + } + MetricType type = 6; + // Description of indicators + string description = 7; + // Indicator context information + string context = 8; + // Additional information for metrics that can be used to store arbitrary metadata + map metadata = 9; +} + +// Metrics +message Metrics { + // System-generated timestamp for the metrics report + // int64 report_timestamp = 1 [json_name = "report_timestamp"]; + // System-generated unique identifier for the metrics report + // string report_id = 2 [json_name = "report_id"]; + // System-generated status code indicating the success or failure of the metrics collection + // int32 status_code = 3 [json_name = "status_code"]; + // System-generated message providing additional context about the metrics collection + // string status_message = 4 [json_name = "status_message"]; + + // Add a list of supported metrics for enabling or disabling specific metrics + repeated string supported_metrics = 5 [json_name = "supported_metrics"]; + // Repeated field for user-defined metrics + repeated UserMetric user_metrics = 6 [json_name = "user_metrics"]; +} diff --git a/third_party/config/middleware/optimize/v1/optimize.proto b/third_party/config/middleware/optimize/v1/optimize.proto new file mode 100644 index 00000000..66a97575 --- /dev/null +++ b/third_party/config/middleware/optimize/v1/optimize.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package runtime.api.config.middleware.optimize.v1; + +import "google/protobuf/duration.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/middleware/optimize/v1;optimizev1"; + +// Optimize defines the configuration for the "optimization" middleware. +// This middleware provides a configurable delay to "optimize" the perceived +// performance of your application. +message Optimize { + // Min is the minimum sleep time in seconds. + // Default: 2 + int64 min = 1 [json_name = "min"]; + + // Max is the maximum sleep time in seconds. + // Default: 30 + int64 max = 2 [json_name = "max"]; + + // Interval is the time interval between sleep time increments. + // Default: 24h + google.protobuf.Duration interval = 3 [json_name = "interval"]; +} diff --git a/third_party/config/middleware/ratelimit/v1/ratelimiter.proto b/third_party/config/middleware/ratelimit/v1/ratelimiter.proto new file mode 100644 index 00000000..f3e6e881 --- /dev/null +++ b/third_party/config/middleware/ratelimit/v1/ratelimiter.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; + +package runtime.api.config.middleware.ratelimit.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/middleware/ratelimit/v1;ratelimitv1"; + +// Rate limiter +message RateLimiter { + message Redis { + string addr = 1 [json_name = "addr"]; + string username = 2 [json_name = "username"]; + string password = 3 [json_name = "password"]; + int32 db = 4 [json_name = "db"]; + } + message Memory { + int64 expiration = 1 [json_name = "expiration"]; + int64 cleanup_interval = 2 [json_name = "cleanup_interval"]; + } + // The 'name' field determines which rate limiter to use. + // For built-in types, specify "bbr", "memory", or "redis". + // For custom types, specify the registered name of the custom rate limiter. + // When a custom type is used, its configuration should be placed in the 'customize' field. + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "Rate limiter name. Built-in: 'bbr', 'memory', 'redis'. Custom types use their registered name."} + ]; + // The number of seconds in a rate limit window + int32 period = 2 [json_name = "period"]; + + // The number of requests allowed in a window of time + int32 x_ratelimit_limit = 4 [json_name = "x_ratelimit_limit"]; + // The number of requests that can still be made in the current window of time + int32 x_ratelimit_remaining = 5 [json_name = "x_ratelimit_remaining"]; + // The number of seconds until the current rate limit window completely resets + int32 x_ratelimit_reset = 6 [json_name = "x_ratelimit_reset"]; + // When rate limited, the number of seconds to wait before another request will be accepted + int32 retry_after = 7 [json_name = "retry_after"]; + + Memory memory = 101 [json_name = "memory"]; + Redis redis = 102 [json_name = "redis"]; + // Optional custom configuration for rate limiter types not explicitly defined. + optional google.protobuf.Struct customize = 103 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Custom configuration for rate limiter types not explicitly defined."} + ]; +} diff --git a/third_party/config/middleware/selector/v1/selector.proto b/third_party/config/middleware/selector/v1/selector.proto new file mode 100644 index 00000000..7214e099 --- /dev/null +++ b/third_party/config/middleware/selector/v1/selector.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package runtime.api.config.middleware.selector.v1; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/middleware/selector/v1;selectorv1"; + +// Selector +message Selector { + repeated string includes = 1 [json_name = "includes"]; + repeated string excludes = 2 [json_name = "excludes"]; + repeated string paths = 3 [json_name = "paths"]; + repeated string prefixes = 4 [json_name = "prefixes"]; + string regex = 5 [json_name = "regex"]; +} diff --git a/third_party/config/middleware/v1/middleware.proto b/third_party/config/middleware/v1/middleware.proto new file mode 100644 index 00000000..7a174ab3 --- /dev/null +++ b/third_party/config/middleware/v1/middleware.proto @@ -0,0 +1,118 @@ +syntax = "proto3"; + +package runtime.api.config.middleware.v1; + +import "config/middleware/circuitbreaker/v1/circuitbreaker.proto"; +import "config/middleware/cors/v1/cors.proto"; +import "config/middleware/jwt/v1/jwt.proto"; +import "config/middleware/metrics/v1/metrics.proto"; +import "config/middleware/ratelimit/v1/ratelimiter.proto"; +import "config/middleware/selector/v1/selector.proto"; +import "config/middleware/v1/security.proto"; // Import the new security config +import "config/middleware/validator/v1/validator.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/middleware/v1;middlewarev1"; + +// Metadata configuration for the middleware. +message Metadata { + repeated string prefixes = 1 [ + json_name = "prefixes", + (gnostic.openapi.v3.property) = {description: "List of prefixes for the metadata."} + ]; + map data = 2 [ + json_name = "data", + (gnostic.openapi.v3.property) = {description: "Key-value pairs of metadata."} + ]; +} + +message Logging { + // empty is allowed, because parent type will handle it + // to decide whether to enable or not logging middleware +} + +message Recovery { + // empty is allowed, because parent type will handle it + // to decide whether to enable or not recovery middleware +} + +// Middleware represents a single middleware configuration with an enable switch. +message Middleware { + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "The name of the middleware instance."} + ]; + // The 'type' field determines which configuration block to use. + // For built-in types, specify "logging", "recovery", "rate_limiter", etc. + // For custom types, specify the registered name of the custom middleware. + // When a custom type is used, its configuration should be placed in the 'customize' field. + string type = 2 [ + json_name = "type", + (gnostic.openapi.v3.property) = {description: "The type of the middleware. Built-in: 'logging', 'recovery', 'rate_limiter', etc. Custom types use their registered name."} + ]; + + bool enabled = 3 [ + json_name = "enabled", + (gnostic.openapi.v3.property) = {description: "Whether the middleware is enabled."} + ]; + + optional runtime.api.config.middleware.ratelimit.v1.RateLimiter rate_limiter = 4 [ + json_name = "rate_limiter", + (gnostic.openapi.v3.property) = {description: "Rate limiter configuration."} + ]; + optional runtime.api.config.middleware.metrics.v1.Metrics metrics = 5 [ + json_name = "metrics", + (gnostic.openapi.v3.property) = {description: "Metrics configuration."} + ]; + optional runtime.api.config.middleware.validator.v1.Validator validator = 6 [ + json_name = "validator", + (gnostic.openapi.v3.property) = {description: "Validator configuration."} + ]; + optional runtime.api.config.middleware.jwt.v1.JWT jwt = 7 [ + json_name = "jwt", + (gnostic.openapi.v3.property) = {description: "JWT middleware configuration."} + ]; + optional runtime.api.config.middleware.selector.v1.Selector selector = 8 [ + json_name = "selector", + (gnostic.openapi.v3.property) = {description: "Selector middleware configuration."} + ]; + optional runtime.api.config.middleware.cors.v1.Cors cors = 9 [ + json_name = "cors", + (gnostic.openapi.v3.property) = {description: "CORS middleware configuration."} + ]; + optional runtime.api.config.middleware.circuitbreaker.v1.CircuitBreaker circuit_breaker = 10 [ + json_name = "circuit_breaker", + (gnostic.openapi.v3.property) = {description: "Circuit breaker configuration."} + ]; + optional Logging logging = 11 [ + json_name = "logging", + (gnostic.openapi.v3.property) = {description: "Logging middleware configuration."} + ]; + optional Recovery recovery = 12 [ + json_name = "recovery", + (gnostic.openapi.v3.property) = {description: "Recovery middleware configuration."} + ]; + optional Metadata metadata = 13 [ + json_name = "metadata", + (gnostic.openapi.v3.property) = {description: "Metadata configuration for the middleware."} + ]; + optional Security security = 14 [ + json_name = "security", + (gnostic.openapi.v3.property) = {description: "Declarative security middleware configuration."} + ]; + optional google.protobuf.Struct customize = 100 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Custom middleware configuration."} + ]; + // Add other specific middleware types here as they are defined +} + +// Middlewares is used to configure a chain of middlewares for an entry point. +message Middlewares { + // A list of middleware configurations to be applied in order. + repeated Middleware configs = 1 [ + json_name = "configs", + (gnostic.openapi.v3.property) = {description: "A list of middleware configurations to be applied in order."} + ]; +} diff --git a/third_party/config/middleware/v1/security.proto b/third_party/config/middleware/v1/security.proto new file mode 100644 index 00000000..10309623 --- /dev/null +++ b/third_party/config/middleware/v1/security.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package runtime.api.config.middleware.v1; + +import "gnostic/openapi/v3/annotations.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/middleware/v1;middlewarev1"; + +// Security defines the configuration for the declarative security middleware. +message Security { + // The name of the default security policy to apply if a route does not specify one. + // If not set, and a route has no policy, access will be denied. + string default_policy = 1 [ + json_name = "default_policy", + (gnostic.openapi.v3.property) = {description: "The name of the default security policy to apply if a route does not specify one."} + ]; +} diff --git a/third_party/config/middleware/validator/v1/validator.proto b/third_party/config/middleware/validator/v1/validator.proto new file mode 100644 index 00000000..61885c37 --- /dev/null +++ b/third_party/config/middleware/validator/v1/validator.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package runtime.api.config.middleware.validator.v1; + +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/middleware/validator/v1;validatorv1"; + +message Validator { + int32 version = 1 [ + json_name = "version", + (validate.rules).int32 = { + gt: 0 + lt: 3 + } + ]; + bool fail_fast = 2 [json_name = "fail_fast"]; +} diff --git a/third_party/config/selector/v1/selector.proto b/third_party/config/selector/v1/selector.proto new file mode 100644 index 00000000..bc02a306 --- /dev/null +++ b/third_party/config/selector/v1/selector.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package runtime.api.config.selector.v1; + +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/selector/v1;selectorv1"; + +// SelectorConfig defines the configuration for a client-side selector (e.g., load balancer). +message SelectorConfig { + // version is a filter for the service version. + // e.g., "v1.0.0" + string version = 1 [json_name = "version"]; + // strategy specifies the load balancing strategy (e.g., "round_robin", "random", "consistent_hash"). + optional string strategy = 2 [json_name = "strategy"]; + // balancer_name specifies the name of the load balancer to use. + optional string balancer_name = 3 [json_name = "balancer_name"]; + // filter_name specifies the name of the filter to use for endpoint selection. + optional string filter_name = 4 [json_name = "filter_name"]; + // custom_config allows for custom configuration for the selector. + // It can be used for non-standard or user-defined selector implementations. + optional google.protobuf.Struct customize = 100 [json_name = "customize"]; +} diff --git a/third_party/config/source/v1/apollo_source.proto b/third_party/config/source/v1/apollo_source.proto new file mode 100644 index 00000000..c8b9e599 --- /dev/null +++ b/third_party/config/source/v1/apollo_source.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; + +package runtime.api.config.source.v1; + +import "config/transport/tls/v1/tls.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/source/v1;sourcev1"; + +// Apollo defines the configuration for Apollo configuration center +message ApolloSource { + // Apollo server address (e.g., "http://localhost:8080") + string address = 1 [json_name = "address"]; + // App ID + string app_id = 2 [json_name = "app_id"]; + // Cluster name + string cluster = 3 [json_name = "cluster"]; + // Namespace name + string namespace = 4 [json_name = "namespace"]; + // Secret key for authentication + string secret = 5 [json_name = "secret"]; + // Cluster list + repeated string clusters = 6 [json_name = "clusters"]; + // TLS configuration + runtime.api.config.transport.tls.v1.TLSConfig tls = 10 [json_name = "tls"]; +} diff --git a/third_party/config/source/v1/consul_source.proto b/third_party/config/source/v1/consul_source.proto new file mode 100644 index 00000000..6f1d05c1 --- /dev/null +++ b/third_party/config/source/v1/consul_source.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +package runtime.api.config.source.v1; + +import "config/transport/tls/v1/tls.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/source/v1;sourcev1"; + +// ConsulSource is the consul source +message ConsulSource { + string address = 1 [json_name = "address"]; + string scheme = 2 [json_name = "scheme"]; + string token = 3 [json_name = "token"]; + string path = 4 [json_name = "path"]; + string datacenter = 5 [json_name = "datacenter"]; + string namespace = 6 [json_name = "namespace"]; + string wait_time = 7 [json_name = "wait_time"]; // e.g., "10s" + string timeout = 8 [json_name = "timeout"]; // e.g., "5s" + runtime.api.config.transport.tls.v1.TLSConfig tls = 10 [json_name = "tls"]; +} diff --git a/third_party/config/source/v1/env_source.proto b/third_party/config/source/v1/env_source.proto new file mode 100644 index 00000000..aa5e0ccb --- /dev/null +++ b/third_party/config/source/v1/env_source.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package runtime.api.config.source.v1; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/source/v1;sourcev1"; + +// EnvSource is the environment variable source +message EnvSource { + // Environment variable prefixes to include + repeated string prefixes = 1 [json_name = "prefixes"]; + // Additional environment variables to set + map args = 2 [json_name = "args"]; + // Whether to watch for environment variable changes + bool watch = 3 [json_name = "watch"]; + // Whether to treat environment variables as nested structure + bool nested = 4 [json_name = "nested"]; +} diff --git a/third_party/config/source/v1/etcd_source.proto b/third_party/config/source/v1/etcd_source.proto new file mode 100644 index 00000000..ed0e5920 --- /dev/null +++ b/third_party/config/source/v1/etcd_source.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package runtime.api.config.source.v1; + +import "config/transport/tls/v1/tls.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/source/v1;sourcev1"; + +// ETCDSource defines the configuration for ETCD configuration source +message ETCDSource { + // ETCD server address (e.g., "localhost:2379") + string address = 1 [json_name = "address"]; + // Username for authentication (if required) + string username = 2 [json_name = "username"]; + // Password for authentication (if required) + string password = 3 [json_name = "password"]; + // Path to the configuration in ETCD (e.g., "/config/app") + string path = 4 [json_name = "path"]; + // TLS configuration for secure connection + runtime.api.config.transport.tls.v1.TLSConfig tls = 10 [json_name = "tls"]; +} diff --git a/third_party/config/source/v1/file_source.proto b/third_party/config/source/v1/file_source.proto new file mode 100644 index 00000000..1ee89c45 --- /dev/null +++ b/third_party/config/source/v1/file_source.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package runtime.api.config.source.v1; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/source/v1;sourcev1"; + +// FileSource is the file source +message FileSource { + string path = 1 [json_name = "path"]; + string format = 2 [json_name = "format"]; + repeated string ignores = 3 [json_name = "ignores"]; + // supported file formats, if not set, all formats are supported + repeated string formats = 4 [json_name = "formats"]; + bool reload = 6 [json_name = "reload"]; + bool optional = 7 [json_name = "optional"]; +} diff --git a/third_party/config/source/v1/kubernetes_source.proto b/third_party/config/source/v1/kubernetes_source.proto new file mode 100644 index 00000000..9bbf8545 --- /dev/null +++ b/third_party/config/source/v1/kubernetes_source.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +package runtime.api.config.source.v1; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/source/v1;sourcev1"; + +// Kubernetes defines the configuration for Kubernetes configuration source +message KubernetesSource { + // Namespace where the configmap/secret is located + string namespace = 1 [json_name = "namespace"]; + // ConfigMap name + string config_map = 2 [json_name = "config_map"]; + // Secret name + string secret = 3 [json_name = "secret"]; + // Key in the configmap/secret + string key = 4 [json_name = "key"]; + // Whether to watch for changes + bool watch = 5 [json_name = "watch"]; + // Kubeconfig path, if not set will use in-cluster config + string kubeconfig = 6 [json_name = "kubeconfig"]; +} diff --git a/third_party/config/source/v1/nacos_source.proto b/third_party/config/source/v1/nacos_source.proto new file mode 100644 index 00000000..324a8994 --- /dev/null +++ b/third_party/config/source/v1/nacos_source.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; + +package runtime.api.config.source.v1; + +import "config/transport/tls/v1/tls.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/source/v1;sourcev1"; + +// Nacos defines the configuration for Nacos configuration center +message NacosSource { + // Nacos server address (e.g., "localhost:8848") + string address = 1 [json_name = "address"]; + // Namespace ID + string namespace = 2 [json_name = "namespace"]; + // Group name + string group = 3 [json_name = "group"]; + // Data ID + string data_id = 4 [json_name = "data_id"]; + // Username for authentication + string username = 5 [json_name = "username"]; + // Password for authentication + string password = 6 [json_name = "password"]; + // Configuration format (e.g., "yaml", "json") + string format = 7 [json_name = "format"]; + // TLS configuration + runtime.api.config.transport.tls.v1.TLSConfig tls = 10 [json_name = "tls"]; +} diff --git a/third_party/config/source/v1/polaris_source.proto b/third_party/config/source/v1/polaris_source.proto new file mode 100644 index 00000000..20f93488 --- /dev/null +++ b/third_party/config/source/v1/polaris_source.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package runtime.api.config.source.v1; + +import "config/transport/tls/v1/tls.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/source/v1;sourcev1"; + +// Polaris defines the configuration for Polaris configuration center +message PolarisSource { + // Polaris server address (e.g., "127.0.0.1:8091") + string address = 1 [json_name = "address"]; + // Namespace + string namespace = 2 [json_name = "namespace"]; + // File group + string group = 3 [json_name = "group"]; + // File name + string file = 4 [json_name = "file"]; + // Timeout in seconds + int32 timeout = 5 [json_name = "timeout"]; + // TLS configuration + runtime.api.config.transport.tls.v1.TLSConfig tls = 10 [json_name = "tls"]; +} diff --git a/third_party/config/source/v1/source.proto b/third_party/config/source/v1/source.proto new file mode 100644 index 00000000..6eae62be --- /dev/null +++ b/third_party/config/source/v1/source.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; + +package runtime.api.config.source.v1; + +import "config/source/v1/apollo_source.proto"; +import "config/source/v1/consul_source.proto"; +import "config/source/v1/env_source.proto"; +import "config/source/v1/etcd_source.proto"; +import "config/source/v1/file_source.proto"; +import "config/source/v1/kubernetes_source.proto"; +import "config/source/v1/nacos_source.proto"; +import "config/source/v1/polaris_source.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/source/v1;sourcev1"; + +message Sources { + // name specifies the configuration set name + string name = 1 [json_name = "name"]; + // version specifies the configuration set version + string version = 2 [json_name = "version"]; + // sources is a list of configuration sources + repeated SourceConfig configs = 3 [json_name = "configs"]; +} + +// SourceConfig is the source file for load configuration +message SourceConfig { + // name specifies the configuration name + string name = 1 [json_name = "name"]; + + // type specifies the type of the configuration source. + // For built-in types, specify "env", "file", "etcd", "consul", "apollo", "nacos", "kubernetes", or "polaris". + // For custom types, specify the registered name of the custom source. + // When a custom type is used, its configuration should be placed in the 'customize' field. + string type = 2 [json_name = "type"]; + + // set the supported file format, if not set, all formats are supported + repeated string formats = 3 [json_name = "formats"]; + + // priority for this configuration source. + // Sources will be loaded in ascending order of priority (e.g., 0, 1, 2, ...), + // with later sources (higher priority value) overriding earlier ones. + int32 priority = 4 [json_name = "priority"]; + + // Configuration source specific settings. Only one of these should be set based on the 'type' field. + optional EnvSource env = 10 [json_name = "env"]; + optional FileSource file = 11 [json_name = "file"]; + optional ETCDSource etcd = 12 [json_name = "etcd"]; + optional ConsulSource consul = 13 [json_name = "consul"]; + optional NacosSource nacos = 14 [json_name = "nacos"]; + optional ApolloSource apollo = 15 [json_name = "apollo"]; + optional KubernetesSource kubernetes = 16 [json_name = "kubernetes"]; + optional PolarisSource polaris = 17 [json_name = "polaris"]; + optional google.protobuf.Struct customize = 100 [json_name = "customize"]; +} diff --git a/third_party/config/task/v1/task.proto b/third_party/config/task/v1/task.proto new file mode 100644 index 00000000..2b76565d --- /dev/null +++ b/third_party/config/task/v1/task.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package runtime.api.config.task.v1; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/task/v1;taskv1"; + +// Task defines the configuration for a background task or cron job service. +message Task { + // Add task-specific configurations here. + // For example, scheduler settings, concurrency limits, etc. +} diff --git a/third_party/config/trace/v1/trace.proto b/third_party/config/trace/v1/trace.proto new file mode 100644 index 00000000..00c1dc09 --- /dev/null +++ b/third_party/config/trace/v1/trace.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; + +package runtime.api.config.trace.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/trace/v1;tracev1"; + +// Trace defines the basic configuration for distributed tracing. +// This provides a minimal set of options, allowing for future expansion. +message Trace { + // name specifies the tracing system to use (e.g., "jaeger", "zipkin", "otlp"). + // This can be used to select a registered TracerProvider. + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "The tracing system to use, e.g., \"jaeger\", \"zipkin\", \"otlp\"."} + ]; + + // endpoint is the address of the tracing collector/agent. + // e.g., "localhost:6831" for Jaeger agent, or "localhost:4317" for OTLP gRPC. + string endpoint = 2 [ + json_name = "endpoint", + (gnostic.openapi.v3.property) = {description: "The address of the tracing collector/agent, e.g., \"localhost:6831\" for Jaeger agent, or \"localhost:4317\" for OTLP gRPC."} + ]; + + // service_name is the name of the service reporting traces. + // If not set, it might default to the application's name. + string service_name = 3 [ + json_name = "service_name", + (gnostic.openapi.v3.property) = {description: "The name of the service reporting traces. If not set, it might default to the application's name."} + ]; + + // timeout for trace operations, e.g., exporting spans. + optional google.protobuf.Duration timeout = 4 [ + json_name = "timeout", + (gnostic.openapi.v3.property) = {description: "Timeout for trace operations, e.g., exporting spans."} + ]; + + // ratio is the sampling probability (e.g., 0.01 for 1%). + // A value of 1.0 means always sample, 0.0 means never sample. + // If not set, a default sampling strategy might be applied. + optional double ratio = 5 [ + json_name = "ratio", + (gnostic.openapi.v3.property) = {description: "The sampling probability (e.g., 0.01 for 1%). A value of 1.0 means always sample, 0.0 means never sample."} + ]; +} diff --git a/third_party/config/transport/grpc/v1/grpc.proto b/third_party/config/transport/grpc/v1/grpc.proto new file mode 100644 index 00000000..aaa1b6fc --- /dev/null +++ b/third_party/config/transport/grpc/v1/grpc.proto @@ -0,0 +1,70 @@ +syntax = "proto3"; + +package runtime.api.config.transport.grpc.v1; + +import "config/selector/v1/selector.proto"; +import "config/transport/tls/v1/tls.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/transport/grpc/v1;grpcv1"; + +// Server defines the core configuration for a Kratos gRPC server. +message Server { + // network is the network type for the server to listen on. + // e.g., "tcp", "unix" + string network = 1 [ + json_name = "network", + (gnostic.openapi.v3.property) = {description: "The network type for the server to listen on, e.g., \"tcp\", \"unix\"."} + ]; + + // addr is the address for the server to listen on. + // e.g., "0.0.0.0:9000" + string addr = 2 [ + json_name = "addr", + (gnostic.openapi.v3.property) = {description: "The address for the server to listen on, e.g., \"0.0.0.0:9000\"."} + ]; + + // timeout is the request handling timeout. + google.protobuf.Duration timeout = 3 [ + json_name = "timeout", + (gnostic.openapi.v3.property) = {description: "The request handling timeout."} + ]; + + // middlewares is a list of middleware names to be applied to the server. + // The framework will look up these names in a middleware provider. + repeated string middlewares = 4 [ + json_name = "middlewares", + (gnostic.openapi.v3.property) = {description: "A list of middleware names to be applied to the server."} + ]; + + // tls_config defines the TLS settings for the gRPC server. + optional runtime.api.config.transport.tls.v1.TLSConfig tls_config = 5 [ + json_name = "tls_config", + (gnostic.openapi.v3.property) = {description: "The TLS settings for the gRPC server."} + ]; +} + +// Client defines the core configuration for creating a Kratos gRPC client. +message Client { + // endpoint is the target to connect to. + // It can be a direct address or a discovery service URI. + // e.g., "direct://127.0.0.1:9000" or "discovery:///your-service-name" + string endpoint = 1; + + // timeout is the request timeout for a single RPC call. + google.protobuf.Duration timeout = 2; + + // middlewares is a list of middleware names to be applied to the client. + repeated string middlewares = 3; + + // selector defines the node selection strategy for the client. + config.selector.v1.SelectorConfig selector = 4; // Updated type reference + + // discovery_name specifies the name of the discovery client to use from the application container. + // If empty, and multiple discovery clients are available, an error will be returned. + optional string discovery_name = 5; + + // tls_config defines the TLS settings for the gRPC client. + optional runtime.api.config.transport.tls.v1.TLSConfig tls_config = 6; +} diff --git a/third_party/config/transport/http/v1/http.proto b/third_party/config/transport/http/v1/http.proto new file mode 100644 index 00000000..5027f7d9 --- /dev/null +++ b/third_party/config/transport/http/v1/http.proto @@ -0,0 +1,85 @@ +syntax = "proto3"; + +package runtime.api.config.transport.http.v1; + +import "config/middleware/cors/v1/cors.proto"; +import "config/selector/v1/selector.proto"; +import "config/transport/tls/v1/tls.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1;httpv1"; + +// Server defines the core configuration for a Kratos HTTP server. +message Server { + // addr is the address for the server to listen on. + // e.g., "0.0.0.0:8000" + string addr = 1 [ + json_name = "addr", + (gnostic.openapi.v3.property) = {description: "The address for the server to listen on, e.g., \"0.0.0.0:8000\"."} + ]; + + // timeout is the request handling timeout. + google.protobuf.Duration timeout = 2 [ + json_name = "timeout", + (gnostic.openapi.v3.property) = {description: "The request handling timeout."} + ]; + + // middlewares is a list of middleware names to be applied to the server. + // The framework will look up these names in a middleware provider. + repeated string middlewares = 3 [ + json_name = "middlewares", + (gnostic.openapi.v3.property) = {description: "A list of middleware names to be applied to the server."} + ]; + + // tls_config defines the TLS settings for the HTTP server. + optional runtime.api.config.transport.tls.v1.TLSConfig tls_config = 4 [ + json_name = "tls_config", + (gnostic.openapi.v3.property) = {description: "The TLS settings for the HTTP server."} + ]; + + // network specifies the network type, e.g., "tcp", "tcp4", "tcp6". + string network = 5 [ + json_name = "network", + (gnostic.openapi.v3.property) = {description: "The network type, e.g., \"tcp\", \"tcp4\", \"tcp6\"."} + ]; + + // cors configuration for the HTTP server + optional runtime.api.config.middleware.cors.v1.Cors cors = 6; + + // enable_pprof indicates whether to enable pprof debugging endpoints. + bool enable_pprof = 7; +} + +// Client defines the core configuration for creating a Kratos HTTP client. +message Client { + // endpoint is the target to connect to. + // It can be a direct address or a discovery service URI. + // e.g., "http://127.0.0.1:8000" or "discovery:///your-service-name" + string endpoint = 1; + + // timeout is the request timeout for a single HTTP call. + google.protobuf.Duration timeout = 2 [ + json_name = "timeout", + (gnostic.openapi.v3.property) = {description: "The request handling timeout."} + ]; + + // middlewares is a list of middleware names to be applied to the client. + repeated string middlewares = 3 [ + json_name = "middlewares", + (gnostic.openapi.v3.property) = {description: "A list of middleware names to be applied to the server."} + ]; + + // selector defines the node selection strategy for the client. + config.selector.v1.SelectorConfig selector = 4; // Updated type reference + + // discovery_name is the name of the discovery client to use for service discovery. + // This is used when the endpoint is a discovery service URI. + string discovery_name = 5; + + // tls_config defines the TLS settings for the HTTP client. + optional runtime.api.config.transport.tls.v1.TLSConfig tls_config = 6; + + // dial_timeout is the timeout for establishing a connection. + optional google.protobuf.Duration dial_timeout = 7; +} diff --git a/third_party/config/transport/tls/v1/tls.proto b/third_party/config/transport/tls/v1/tls.proto new file mode 100644 index 00000000..e73e9f94 --- /dev/null +++ b/third_party/config/transport/tls/v1/tls.proto @@ -0,0 +1,149 @@ +syntax = "proto3"; + +package runtime.api.config.transport.tls.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/transport/tls/v1;tlsv1"; + +// TLS configuration for secure connections +message TLSConfig { + // Unique name for this TLS configuration instance. + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "Unique name for this TLS configuration instance."} + ]; + // Whether TLS is enabled + bool enabled = 2 [ + json_name = "enabled", + (gnostic.openapi.v3.property) = {description: "Whether TLS is enabled for this configuration."} + ]; + + // Certificate configuration + // File-based certificate configuration + optional FileConfig file = 3 [ + json_name = "file", + (gnostic.openapi.v3.property) = {description: "File-based certificate configuration."} + ]; + // Inline PEM certificate data + optional PEMConfig pem = 4 [ + json_name = "pem", + (gnostic.openapi.v3.property) = {description: "Inline PEM-encoded certificate data."} + ]; + + // Minimum TLS version + // Allowed values: "1.0", "1.1", "1.2", "1.3" + // Default: "1.2" + string min_version = 5 [ + (validate.rules).string = { + in: [ + "1.0", + "1.1", + "1.2", + "1.3" + ] + }, + json_name = "min_version", + (gnostic.openapi.v3.property) = {description: "Minimum TLS version to use. Allowed values: \"1.0\", \"1.1\", \"1.2\", \"1.3\". Default: \"1.2\""} + ]; + + // List of supported cipher suites + // Example: ["TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"] + repeated string cipher_suites = 6 [ + json_name = "cipher_suites", + (gnostic.openapi.v3.property) = {description: "List of supported cipher suites. Example: [\"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256\"]"} + ]; + + // Require client certificate + // Default: false + bool require_client_cert = 7 [ + json_name = "require_client_cert", + (gnostic.openapi.v3.property) = {description: "Whether to require client certificate for mutual TLS authentication. Default: false"} + ]; + + // Client CA certificate file path (for client cert validation) + string client_ca_file = 8 [ + json_name = "client_ca_file", + (gnostic.openapi.v3.property) = {description: "Path to the client CA certificate file used for client certificate validation."} + ]; + + // Whether to skip server certificate verification + // Default: false + bool insecure_skip_verify = 9 [ + json_name = "insecure_skip_verify", + (gnostic.openapi.v3.property) = {description: "If true, skips server certificate verification. Only use in development. Default: false"} + ]; + + // Server name for SNI (Server Name Indication), used by client + // Default: "" + string server_name = 10 [ + json_name = "server_name", + (gnostic.openapi.v3.property) = {description: "Server name for SNI (Server Name Indication), used by client to specify the hostname being contacted."} + ]; + + // Optional custom configuration for TLS settings not explicitly defined. + optional google.protobuf.Struct customize = 11 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Custom configuration for TLS settings not explicitly defined."} + ]; +} + +// File-based certificate configuration +message FileConfig { + // Path to certificate file + string cert = 1 [ + (validate.rules).string.min_len = 1, + json_name = "cert", + (gnostic.openapi.v3.property) = { + description: "Path to the certificate file in PEM format." + required: ["cert"] + } + ]; + + // Path to private key file + string key = 2 [ + (validate.rules).string.min_len = 1, + json_name = "key", + (gnostic.openapi.v3.property) = { + description: "Path to the private key file in PEM format." + required: ["key"] + } + ]; + + // Path to CA certificate file (optional) + string ca = 3 [ + json_name = "ca", + (gnostic.openapi.v3.property) = {description: "Path to the CA certificate file for verifying peer certificates. Optional."} + ]; +} + +// Inline PEM certificate configuration +message PEMConfig { + // Certificate data in PEM format + bytes cert = 1 [ + (validate.rules).bytes.min_len = 1, + json_name = "cert", + (gnostic.openapi.v3.property) = { + description: "PEM-encoded certificate data." + required: ["cert"] + } + ]; + + // Private key data in PEM format + bytes key = 2 [ + (validate.rules).bytes.min_len = 1, + json_name = "key", + (gnostic.openapi.v3.property) = { + description: "PEM-encoded private key data." + required: ["key"] + } + ]; + + // CA certificate data in PEM format (optional) + bytes ca = 3 [ + json_name = "ca", + (gnostic.openapi.v3.property) = {description: "PEM-encoded CA certificate data for verifying peer certificates. Optional."} + ]; +} diff --git a/third_party/config/transport/v1/transport.proto b/third_party/config/transport/v1/transport.proto new file mode 100644 index 00000000..8358ed95 --- /dev/null +++ b/third_party/config/transport/v1/transport.proto @@ -0,0 +1,121 @@ +syntax = "proto3"; + +package runtime.api.config.transport.v1; + +import "config/transport/grpc/v1/grpc.proto"; +import "config/transport/http/v1/http.proto"; +import "config/transport/websocket/v1/websocket.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/transport/v1;transportv1"; + +// ================================================================= +// Server Definitions +// ================================================================= + +// Server is a generic container for a single server-side transport configuration. +// It uses optional fields to represent different protocol types, avoiding the use of `oneof`. +message Server { + // name is the logical name for this server configuration. + // It is used to identify this server in the application's configuration. + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "The logical name for this server configuration."} + ]; + + // protocol is the name of the transport protocol to use. + // e.g., "grpc", "http", "websocket". This name is used to look up a registered ProtocolFactory. + string protocol = 2 [ + json_name = "protocol", + (gnostic.openapi.v3.property) = {description: "The name of the transport protocol to use, e.g., \"grpc\", \"http\", \"websocket\"."} + ]; + + // The following fields are transport-specific configurations. + // Only one of these should be set for a given Server instance. + + // gRPC server configuration. + optional runtime.api.config.transport.grpc.v1.Server grpc = 3 [ + json_name = "grpc", + (gnostic.openapi.v3.property) = {description: "gRPC server configuration."} + ]; + + // HTTP server configuration. + optional runtime.api.config.transport.http.v1.Server http = 4 [ + json_name = "http", + (gnostic.openapi.v3.property) = {description: "HTTP server configuration."} + ]; + + // WebSocket server configuration. + optional runtime.api.config.transport.websocket.v1.Server websocket = 5 [ + json_name = "websocket", + (gnostic.openapi.v3.property) = {description: "WebSocket server configuration."} + ]; + + // customize is used for non-standard or user-defined transport protocols. + // It allows for flexible configuration without modifying this core proto file. + optional google.protobuf.Struct customize = 100 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Non-standard or user-defined transport protocols configuration."} + ]; +} + +// Servers defines a collection of server configurations. +// This message aggregates all server instances that an application needs to run. +// It does not include `default` or `active` fields, as all configured servers are typically started. +message Servers { + // servers is a list of all available server configurations. + // Each server in this list will typically be started by the application. + repeated Server configs = 1 [json_name = "configs"]; +} + +// ================================================================= +// Client Definitions +// ================================================================= + +// Client is a generic container for a single client-side transport configuration. +message Client { + // name is the logical name for this client configuration. + // It is used to uniquely identify this client dependency in the application. + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "The logical name for this server configuration."} + ]; + + // protocol is the name of the transport protocol to use. + // e.g., "grpc", "http", "websocket". This name is used to look up a registered ProtocolFactory. + string protocol = 2 [ + json_name = "protocol", + (gnostic.openapi.v3.property) = {description: "The name of the transport protocol to use, e.g., \"grpc\", \"http\", \"websocket\"."} + ]; + + // The following fields are transport-specific configurations. + // Only one of these should be set for a given Client instance. + + // gRPC client configuration. + optional runtime.api.config.transport.grpc.v1.Client grpc = 3 [json_name = "grpc"]; + + // HTTP client configuration. + optional runtime.api.config.transport.http.v1.Client http = 4 [json_name = "http"]; + + // customize is used for non-standard or user-defined transport protocols. + optional google.protobuf.Struct customize = 100 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Non-standard or user-defined transport protocols configuration."} + ]; +} + +// Clients defines a collection of client configurations for services that this service depends on. +// This structure follows the "Broker Pattern" to avoid using maps, providing a clear +// and explicit way to manage multiple named client instances. +message Clients { + // default is the name of the default client configuration to use from the `clients` list. + // If not set, the application can use a predefined default or infer one. + optional string default = 1 [json_name = "default"]; + // active is the name of the active client configuration to use from the `clients` list. + // If set, it overrides the `default` selection. + optional string active = 2 [json_name = "active"]; + + // clients is a list of all available client configurations. + repeated Client configs = 3 [json_name = "configs"]; +} diff --git a/third_party/config/transport/websocket/v1/websocket.proto b/third_party/config/transport/websocket/v1/websocket.proto new file mode 100644 index 00000000..b3de1f5d --- /dev/null +++ b/third_party/config/transport/websocket/v1/websocket.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package runtime.api.config.transport.websocket.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/origadmin/runtime/api/gen/go/config/transport/websocket/v1;websocketv1"; + +// Server defines the configuration for a WebSocket server. +message Server { + string network = 1 [ + json_name = "network", + (gnostic.openapi.v3.property) = {description: "The network type for the WebSocket server to listen on."} + ]; + string addr = 2 [ + json_name = "addr", + (gnostic.openapi.v3.property) = {description: "The address for the WebSocket server to listen on."} + ]; + google.protobuf.Duration timeout = 3 [ + json_name = "timeout", + (gnostic.openapi.v3.property) = {description: "The request handling timeout for the WebSocket server."} + ]; + // The endpoint that this server advertises to the service registry. + string endpoint = 4 [ + json_name = "endpoint", + (gnostic.openapi.v3.property) = {description: "The endpoint that this server advertises to the service registry."} + ]; +} diff --git a/third_party/errors/errors.proto b/third_party/errors/errors.proto new file mode 100644 index 00000000..331f0fba --- /dev/null +++ b/third_party/errors/errors.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package errors; + +option go_package = "github.com/go-kratos/kratos/v2/errors;errors"; +option java_multiple_files = true; +option java_package = "com.github.kratos.errors"; +option objc_class_prefix = "KratosErrors"; + +import "google/protobuf/descriptor.proto"; + +extend google.protobuf.EnumOptions { + int32 default_code = 1108; +} + +extend google.protobuf.EnumValueOptions { + int32 code = 1109; +} diff --git a/third_party/gnostic/discovery/v1/discovery.proto b/third_party/gnostic/discovery/v1/discovery.proto new file mode 100644 index 00000000..392bb8a5 --- /dev/null +++ b/third_party/gnostic/discovery/v1/discovery.proto @@ -0,0 +1,269 @@ +// Copyright 2020 Google LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// THIS FILE IS AUTOMATICALLY GENERATED. + +syntax = "proto3"; + +package gnostic.discovery.v1; + +import "google/protobuf/any.proto"; + +// This option lets the proto compiler generate Java code inside the package +// name (see below) instead of inside an outer class. It creates a simpler +// developer experience by reducing one-level of name nesting and be +// consistent with most programming languages that don't support outer classes. +option java_multiple_files = true; + +// The Java outer classname should be the filename in UpperCamelCase. This +// class is only used to hold proto descriptor, so developers don't need to +// work with it directly. +option java_outer_classname = "OpenAPIProto"; + +// The Java package name must be proto package name with proper prefix. +option java_package = "org.discovery_v1"; + +// A reasonable prefix for the Objective-C symbols generated from the package. +// It should at a minimum be 3 characters long, all uppercase, and convention +// is to use an abbreviation of the package name. Something short, but +// hopefully unique enough to not conflict with things that may come along in +// the future. 'GPB' is reserved for the protocol buffer implementation itself. +option objc_class_prefix = "OAS"; + +// The Go package name. +option go_package = "github.com/google/gnostic/discovery;discovery_v1"; + +message Annotations { + repeated string required = 1; +} + +message Any { + google.protobuf.Any value = 1; + string yaml = 2; +} + +message Auth { + Oauth2 oauth2 = 1; +} + +message Document { + string kind = 1; + string discovery_version = 2; + string id = 3; + string name = 4; + string version = 5; + string revision = 6; + string title = 7; + string description = 8; + Icons icons = 9; + string documentation_link = 10; + repeated string labels = 11; + string protocol = 12; + string base_url = 13; + string base_path = 14; + string root_url = 15; + string service_path = 16; + string batch_path = 17; + Parameters parameters = 18; + Auth auth = 19; + repeated string features = 20; + Schemas schemas = 21; + Methods methods = 22; + Resources resources = 23; + string etag = 24; + string owner_domain = 25; + string owner_name = 26; + bool version_module = 27; + string canonical_name = 28; + bool fully_encode_reserved_expansion = 29; + string package_path = 30; + string mtls_root_url = 31; +} + +// Icons that represent the API. +message Icons { + string x16 = 1; + string x32 = 2; +} + +message MediaUpload { + repeated string accept = 1; + string max_size = 2; + Protocols protocols = 3; + bool supports_subscription = 4; +} + +message Method { + string id = 1; + string path = 2; + string http_method = 3; + string description = 4; + Parameters parameters = 5; + repeated string parameter_order = 6; + Request request = 7; + Response response = 8; + repeated string scopes = 9; + bool supports_media_download = 10; + bool supports_media_upload = 11; + bool use_media_download_service = 12; + MediaUpload media_upload = 13; + bool supports_subscription = 14; + string flat_path = 15; + bool etag_required = 16; + string streaming_type = 17; +} + +message Methods { + repeated NamedMethod additional_properties = 1; +} + +// Automatically-generated message used to represent maps of Method as ordered (name,value) pairs. +message NamedMethod { + // Map key + string name = 1; + // Mapped value + Method value = 2; +} + +// Automatically-generated message used to represent maps of Parameter as ordered (name,value) pairs. +message NamedParameter { + // Map key + string name = 1; + // Mapped value + Parameter value = 2; +} + +// Automatically-generated message used to represent maps of Resource as ordered (name,value) pairs. +message NamedResource { + // Map key + string name = 1; + // Mapped value + Resource value = 2; +} + +// Automatically-generated message used to represent maps of Schema as ordered (name,value) pairs. +message NamedSchema { + // Map key + string name = 1; + // Mapped value + Schema value = 2; +} + +// Automatically-generated message used to represent maps of Scope as ordered (name,value) pairs. +message NamedScope { + // Map key + string name = 1; + // Mapped value + Scope value = 2; +} + +message Oauth2 { + Scopes scopes = 1; +} + +message Parameter { + string id = 1; + string type = 2; + string _ref = 3; + string description = 4; + string default = 5; + bool required = 6; + string format = 7; + string pattern = 8; + string minimum = 9; + string maximum = 10; + repeated string enum = 11; + repeated string enum_descriptions = 12; + bool repeated = 13; + string location = 14; + Schemas properties = 15; + Schema additional_properties = 16; + Schema items = 17; + Annotations annotations = 18; +} + +message Parameters { + repeated NamedParameter additional_properties = 1; +} + +message Protocols { + Simple simple = 1; + Resumable resumable = 2; +} + +message Request { + string _ref = 1; + string parameter_name = 2; +} + +message Resource { + Methods methods = 1; + Resources resources = 2; +} + +message Resources { + repeated NamedResource additional_properties = 1; +} + +message Response { + string _ref = 1; +} + +message Resumable { + bool multipart = 1; + string path = 2; +} + +message Schema { + string id = 1; + string type = 2; + string description = 3; + string default = 4; + bool required = 5; + string format = 6; + string pattern = 7; + string minimum = 8; + string maximum = 9; + repeated string enum = 10; + repeated string enum_descriptions = 11; + bool repeated = 12; + string location = 13; + Schemas properties = 14; + Schema additional_properties = 15; + Schema items = 16; + string _ref = 17; + Annotations annotations = 18; + bool read_only = 19; +} + +message Schemas { + repeated NamedSchema additional_properties = 1; +} + +message Scope { + string description = 1; +} + +message Scopes { + repeated NamedScope additional_properties = 1; +} + +message Simple { + bool multipart = 1; + string path = 2; +} + +message StringArray { + repeated string value = 1; +} \ No newline at end of file diff --git a/third_party/gnostic/openapi/v2/openapiv2.proto b/third_party/gnostic/openapi/v2/openapiv2.proto new file mode 100644 index 00000000..899d2710 --- /dev/null +++ b/third_party/gnostic/openapi/v2/openapiv2.proto @@ -0,0 +1,665 @@ +// Copyright 2020 Google LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// THIS FILE IS AUTOMATICALLY GENERATED. + +syntax = "proto3"; + +package gnostic.openapi.v2; + +import "google/protobuf/any.proto"; + +// This option lets the proto compiler generate Java code inside the package +// name (see below) instead of inside an outer class. It creates a simpler +// developer experience by reducing one-level of name nesting and be +// consistent with most programming languages that don't support outer classes. +option java_multiple_files = true; + +// The Java outer classname should be the filename in UpperCamelCase. This +// class is only used to hold proto descriptor, so developers don't need to +// work with it directly. +option java_outer_classname = "OpenAPIProto"; + +// The Java package name must be proto package name with proper prefix. +option java_package = "org.openapi_v2"; + +// A reasonable prefix for the Objective-C symbols generated from the package. +// It should at a minimum be 3 characters long, all uppercase, and convention +// is to use an abbreviation of the package name. Something short, but +// hopefully unique enough to not conflict with things that may come along in +// the future. 'GPB' is reserved for the protocol buffer implementation itself. +option objc_class_prefix = "OAS"; + +// The Go package name. +option go_package = "github.com/google/gnostic/openapiv2;openapi_v2"; + +message AdditionalPropertiesItem { + oneof oneof { + Schema schema = 1; + bool boolean = 2; + } +} + +message Any { + google.protobuf.Any value = 1; + string yaml = 2; +} + +message ApiKeySecurity { + string type = 1; + string name = 2; + string in = 3; + string description = 4; + repeated NamedAny vendor_extension = 5; +} + +message BasicAuthenticationSecurity { + string type = 1; + string description = 2; + repeated NamedAny vendor_extension = 3; +} + +message BodyParameter { + // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. + string description = 1; + // The name of the parameter. + string name = 2; + // Determines the location of the parameter. + string in = 3; + // Determines whether or not this parameter is required or optional. + bool required = 4; + Schema schema = 5; + repeated NamedAny vendor_extension = 6; +} + +// Contact information for the owners of the API. +message Contact { + // The identifying name of the contact person/organization. + string name = 1; + // The URL pointing to the contact information. + string url = 2; + // The email address of the contact person/organization. + string email = 3; + repeated NamedAny vendor_extension = 4; +} + +message Default { + repeated NamedAny additional_properties = 1; +} + +// One or more JSON objects describing the schemas being consumed and produced by the API. +message Definitions { + repeated NamedSchema additional_properties = 1; +} + +message Document { + // The Swagger version of this document. + string swagger = 1; + Info info = 2; + // The host (name or ip) of the API. Example: 'swagger.io' + string host = 3; + // The base path to the API. Example: '/api'. + string base_path = 4; + // The transfer protocol of the API. + repeated string schemes = 5; + // A list of MIME types accepted by the API. + repeated string consumes = 6; + // A list of MIME types the API can produce. + repeated string produces = 7; + Paths paths = 8; + Definitions definitions = 9; + ParameterDefinitions parameters = 10; + ResponseDefinitions responses = 11; + repeated SecurityRequirement security = 12; + SecurityDefinitions security_definitions = 13; + repeated Tag tags = 14; + ExternalDocs external_docs = 15; + repeated NamedAny vendor_extension = 16; +} + +message Examples { + repeated NamedAny additional_properties = 1; +} + +// information about external documentation +message ExternalDocs { + string description = 1; + string url = 2; + repeated NamedAny vendor_extension = 3; +} + +// A deterministic version of a JSON Schema object. +message FileSchema { + string format = 1; + string title = 2; + string description = 3; + Any default = 4; + repeated string required = 5; + string type = 6; + bool read_only = 7; + ExternalDocs external_docs = 8; + Any example = 9; + repeated NamedAny vendor_extension = 10; +} + +message FormDataParameterSubSchema { + // Determines whether or not this parameter is required or optional. + bool required = 1; + // Determines the location of the parameter. + string in = 2; + // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. + string description = 3; + // The name of the parameter. + string name = 4; + // allows sending a parameter by name only or with an empty value. + bool allow_empty_value = 5; + string type = 6; + string format = 7; + PrimitivesItems items = 8; + string collection_format = 9; + Any default = 10; + double maximum = 11; + bool exclusive_maximum = 12; + double minimum = 13; + bool exclusive_minimum = 14; + int64 max_length = 15; + int64 min_length = 16; + string pattern = 17; + int64 max_items = 18; + int64 min_items = 19; + bool unique_items = 20; + repeated Any enum = 21; + double multiple_of = 22; + repeated NamedAny vendor_extension = 23; +} + +message Header { + string type = 1; + string format = 2; + PrimitivesItems items = 3; + string collection_format = 4; + Any default = 5; + double maximum = 6; + bool exclusive_maximum = 7; + double minimum = 8; + bool exclusive_minimum = 9; + int64 max_length = 10; + int64 min_length = 11; + string pattern = 12; + int64 max_items = 13; + int64 min_items = 14; + bool unique_items = 15; + repeated Any enum = 16; + double multiple_of = 17; + string description = 18; + repeated NamedAny vendor_extension = 19; +} + +message HeaderParameterSubSchema { + // Determines whether or not this parameter is required or optional. + bool required = 1; + // Determines the location of the parameter. + string in = 2; + // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. + string description = 3; + // The name of the parameter. + string name = 4; + string type = 5; + string format = 6; + PrimitivesItems items = 7; + string collection_format = 8; + Any default = 9; + double maximum = 10; + bool exclusive_maximum = 11; + double minimum = 12; + bool exclusive_minimum = 13; + int64 max_length = 14; + int64 min_length = 15; + string pattern = 16; + int64 max_items = 17; + int64 min_items = 18; + bool unique_items = 19; + repeated Any enum = 20; + double multiple_of = 21; + repeated NamedAny vendor_extension = 22; +} + +message Headers { + repeated NamedHeader additional_properties = 1; +} + +// General information about the API. +message Info { + // A unique and precise title of the API. + string title = 1; + // A semantic version number of the API. + string version = 2; + // A longer description of the API. Should be different from the title. GitHub Flavored Markdown is allowed. + string description = 3; + // The terms of service for the API. + string terms_of_service = 4; + Contact contact = 5; + License license = 6; + repeated NamedAny vendor_extension = 7; +} + +message ItemsItem { + repeated Schema schema = 1; +} + +message JsonReference { + string _ref = 1; + string description = 2; +} + +message License { + // The name of the license type. It's encouraged to use an OSI compatible license. + string name = 1; + // The URL pointing to the license. + string url = 2; + repeated NamedAny vendor_extension = 3; +} + +// Automatically-generated message used to represent maps of Any as ordered (name,value) pairs. +message NamedAny { + // Map key + string name = 1; + // Mapped value + Any value = 2; +} + +// Automatically-generated message used to represent maps of Header as ordered (name,value) pairs. +message NamedHeader { + // Map key + string name = 1; + // Mapped value + Header value = 2; +} + +// Automatically-generated message used to represent maps of Parameter as ordered (name,value) pairs. +message NamedParameter { + // Map key + string name = 1; + // Mapped value + Parameter value = 2; +} + +// Automatically-generated message used to represent maps of PathItem as ordered (name,value) pairs. +message NamedPathItem { + // Map key + string name = 1; + // Mapped value + PathItem value = 2; +} + +// Automatically-generated message used to represent maps of Response as ordered (name,value) pairs. +message NamedResponse { + // Map key + string name = 1; + // Mapped value + Response value = 2; +} + +// Automatically-generated message used to represent maps of ResponseValue as ordered (name,value) pairs. +message NamedResponseValue { + // Map key + string name = 1; + // Mapped value + ResponseValue value = 2; +} + +// Automatically-generated message used to represent maps of Schema as ordered (name,value) pairs. +message NamedSchema { + // Map key + string name = 1; + // Mapped value + Schema value = 2; +} + +// Automatically-generated message used to represent maps of SecurityDefinitionsItem as ordered (name,value) pairs. +message NamedSecurityDefinitionsItem { + // Map key + string name = 1; + // Mapped value + SecurityDefinitionsItem value = 2; +} + +// Automatically-generated message used to represent maps of string as ordered (name,value) pairs. +message NamedString { + // Map key + string name = 1; + // Mapped value + string value = 2; +} + +// Automatically-generated message used to represent maps of StringArray as ordered (name,value) pairs. +message NamedStringArray { + // Map key + string name = 1; + // Mapped value + StringArray value = 2; +} + +message NonBodyParameter { + oneof oneof { + HeaderParameterSubSchema header_parameter_sub_schema = 1; + FormDataParameterSubSchema form_data_parameter_sub_schema = 2; + QueryParameterSubSchema query_parameter_sub_schema = 3; + PathParameterSubSchema path_parameter_sub_schema = 4; + } +} + +message Oauth2AccessCodeSecurity { + string type = 1; + string flow = 2; + Oauth2Scopes scopes = 3; + string authorization_url = 4; + string token_url = 5; + string description = 6; + repeated NamedAny vendor_extension = 7; +} + +message Oauth2ApplicationSecurity { + string type = 1; + string flow = 2; + Oauth2Scopes scopes = 3; + string token_url = 4; + string description = 5; + repeated NamedAny vendor_extension = 6; +} + +message Oauth2ImplicitSecurity { + string type = 1; + string flow = 2; + Oauth2Scopes scopes = 3; + string authorization_url = 4; + string description = 5; + repeated NamedAny vendor_extension = 6; +} + +message Oauth2PasswordSecurity { + string type = 1; + string flow = 2; + Oauth2Scopes scopes = 3; + string token_url = 4; + string description = 5; + repeated NamedAny vendor_extension = 6; +} + +message Oauth2Scopes { + repeated NamedString additional_properties = 1; +} + +message Operation { + repeated string tags = 1; + // A brief summary of the operation. + string summary = 2; + // A longer description of the operation, GitHub Flavored Markdown is allowed. + string description = 3; + ExternalDocs external_docs = 4; + // A unique identifier of the operation. + string operation_id = 5; + // A list of MIME types the API can produce. + repeated string produces = 6; + // A list of MIME types the API can consume. + repeated string consumes = 7; + // The parameters needed to send a valid API call. + repeated ParametersItem parameters = 8; + Responses responses = 9; + // The transfer protocol of the API. + repeated string schemes = 10; + bool deprecated = 11; + repeated SecurityRequirement security = 12; + repeated NamedAny vendor_extension = 13; +} + +message Parameter { + oneof oneof { + BodyParameter body_parameter = 1; + NonBodyParameter non_body_parameter = 2; + } +} + +// One or more JSON representations for parameters +message ParameterDefinitions { + repeated NamedParameter additional_properties = 1; +} + +message ParametersItem { + oneof oneof { + Parameter parameter = 1; + JsonReference json_reference = 2; + } +} + +message PathItem { + string _ref = 1; + Operation get = 2; + Operation put = 3; + Operation post = 4; + Operation delete = 5; + Operation options = 6; + Operation head = 7; + Operation patch = 8; + // The parameters needed to send a valid API call. + repeated ParametersItem parameters = 9; + repeated NamedAny vendor_extension = 10; +} + +message PathParameterSubSchema { + // Determines whether or not this parameter is required or optional. + bool required = 1; + // Determines the location of the parameter. + string in = 2; + // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. + string description = 3; + // The name of the parameter. + string name = 4; + string type = 5; + string format = 6; + PrimitivesItems items = 7; + string collection_format = 8; + Any default = 9; + double maximum = 10; + bool exclusive_maximum = 11; + double minimum = 12; + bool exclusive_minimum = 13; + int64 max_length = 14; + int64 min_length = 15; + string pattern = 16; + int64 max_items = 17; + int64 min_items = 18; + bool unique_items = 19; + repeated Any enum = 20; + double multiple_of = 21; + repeated NamedAny vendor_extension = 22; +} + +// Relative paths to the individual endpoints. They must be relative to the 'basePath'. +message Paths { + repeated NamedAny vendor_extension = 1; + repeated NamedPathItem path = 2; +} + +message PrimitivesItems { + string type = 1; + string format = 2; + PrimitivesItems items = 3; + string collection_format = 4; + Any default = 5; + double maximum = 6; + bool exclusive_maximum = 7; + double minimum = 8; + bool exclusive_minimum = 9; + int64 max_length = 10; + int64 min_length = 11; + string pattern = 12; + int64 max_items = 13; + int64 min_items = 14; + bool unique_items = 15; + repeated Any enum = 16; + double multiple_of = 17; + repeated NamedAny vendor_extension = 18; +} + +message Properties { + repeated NamedSchema additional_properties = 1; +} + +message QueryParameterSubSchema { + // Determines whether or not this parameter is required or optional. + bool required = 1; + // Determines the location of the parameter. + string in = 2; + // A brief description of the parameter. This could contain examples of use. GitHub Flavored Markdown is allowed. + string description = 3; + // The name of the parameter. + string name = 4; + // allows sending a parameter by name only or with an empty value. + bool allow_empty_value = 5; + string type = 6; + string format = 7; + PrimitivesItems items = 8; + string collection_format = 9; + Any default = 10; + double maximum = 11; + bool exclusive_maximum = 12; + double minimum = 13; + bool exclusive_minimum = 14; + int64 max_length = 15; + int64 min_length = 16; + string pattern = 17; + int64 max_items = 18; + int64 min_items = 19; + bool unique_items = 20; + repeated Any enum = 21; + double multiple_of = 22; + repeated NamedAny vendor_extension = 23; +} + +message Response { + string description = 1; + SchemaItem schema = 2; + Headers headers = 3; + Examples examples = 4; + repeated NamedAny vendor_extension = 5; +} + +// One or more JSON representations for responses +message ResponseDefinitions { + repeated NamedResponse additional_properties = 1; +} + +message ResponseValue { + oneof oneof { + Response response = 1; + JsonReference json_reference = 2; + } +} + +// Response objects names can either be any valid HTTP status code or 'default'. +message Responses { + repeated NamedResponseValue response_code = 1; + repeated NamedAny vendor_extension = 2; +} + +// A deterministic version of a JSON Schema object. +message Schema { + string _ref = 1; + string format = 2; + string title = 3; + string description = 4; + Any default = 5; + double multiple_of = 6; + double maximum = 7; + bool exclusive_maximum = 8; + double minimum = 9; + bool exclusive_minimum = 10; + int64 max_length = 11; + int64 min_length = 12; + string pattern = 13; + int64 max_items = 14; + int64 min_items = 15; + bool unique_items = 16; + int64 max_properties = 17; + int64 min_properties = 18; + repeated string required = 19; + repeated Any enum = 20; + AdditionalPropertiesItem additional_properties = 21; + TypeItem type = 22; + ItemsItem items = 23; + repeated Schema all_of = 24; + Properties properties = 25; + string discriminator = 26; + bool read_only = 27; + Xml xml = 28; + ExternalDocs external_docs = 29; + Any example = 30; + repeated NamedAny vendor_extension = 31; +} + +message SchemaItem { + oneof oneof { + Schema schema = 1; + FileSchema file_schema = 2; + } +} + +message SecurityDefinitions { + repeated NamedSecurityDefinitionsItem additional_properties = 1; +} + +message SecurityDefinitionsItem { + oneof oneof { + BasicAuthenticationSecurity basic_authentication_security = 1; + ApiKeySecurity api_key_security = 2; + Oauth2ImplicitSecurity oauth2_implicit_security = 3; + Oauth2PasswordSecurity oauth2_password_security = 4; + Oauth2ApplicationSecurity oauth2_application_security = 5; + Oauth2AccessCodeSecurity oauth2_access_code_security = 6; + } +} + +message SecurityRequirement { + repeated NamedStringArray additional_properties = 1; +} + +message StringArray { + repeated string value = 1; +} + +message Tag { + string name = 1; + string description = 2; + ExternalDocs external_docs = 3; + repeated NamedAny vendor_extension = 4; +} + +message TypeItem { + repeated string value = 1; +} + +// Any property starting with x- is valid. +message VendorExtension { + repeated NamedAny additional_properties = 1; +} + +message Xml { + string name = 1; + string namespace = 2; + string prefix = 3; + bool attribute = 4; + bool wrapped = 5; + repeated NamedAny vendor_extension = 6; +} diff --git a/third_party/gnostic/openapi/v3/annotations.proto b/third_party/gnostic/openapi/v3/annotations.proto new file mode 100644 index 00000000..1b1a13fe --- /dev/null +++ b/third_party/gnostic/openapi/v3/annotations.proto @@ -0,0 +1,60 @@ +// Copyright 2022 Google LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package gnostic.openapi.v3; + +import "gnostic/openapi/v3/openapiv3.proto"; +import "google/protobuf/descriptor.proto"; + +// This option lets the proto compiler generate Java code inside the package +// name (see below) instead of inside an outer class. It creates a simpler +// developer experience by reducing one-level of name nesting and be +// consistent with most programming languages that don't support outer classes. +option java_multiple_files = true; + +// The Java outer classname should be the filename in UpperCamelCase. This +// class is only used to hold proto descriptor, so developers don't need to +// work with it directly. +option java_outer_classname = "AnnotationsProto"; + +// The Java package name must be proto package name with proper prefix. +option java_package = "org.openapi_v3"; + +// A reasonable prefix for the Objective-C symbols generated from the package. +// It should at a minimum be 3 characters long, all uppercase, and convention +// is to use an abbreviation of the package name. Something short, but +// hopefully unique enough to not conflict with things that may come along in +// the future. 'GPB' is reserved for the protocol buffer implementation itself. +option objc_class_prefix = "OAS"; + +// The Go package name. +option go_package = "github.com/google/gnostic/openapiv3;openapi_v3"; + +extend google.protobuf.FileOptions { + Document document = 1143; +} + +extend google.protobuf.MethodOptions { + Operation operation = 1143; +} + +extend google.protobuf.MessageOptions { + Schema schema = 1143; +} + +extend google.protobuf.FieldOptions { + Schema property = 1143; +} diff --git a/third_party/gnostic/openapi/v3/openapiv3.proto b/third_party/gnostic/openapi/v3/openapiv3.proto new file mode 100644 index 00000000..e7835644 --- /dev/null +++ b/third_party/gnostic/openapi/v3/openapiv3.proto @@ -0,0 +1,671 @@ +// Copyright 2020 Google LLC. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// THIS FILE IS AUTOMATICALLY GENERATED. + +syntax = "proto3"; + +package gnostic.openapi.v3; + +import "google/protobuf/any.proto"; + +// This option lets the proto compiler generate Java code inside the package +// name (see below) instead of inside an outer class. It creates a simpler +// developer experience by reducing one-level of name nesting and be +// consistent with most programming languages that don't support outer classes. +option java_multiple_files = true; + +// The Java outer classname should be the filename in UpperCamelCase. This +// class is only used to hold proto descriptor, so developers don't need to +// work with it directly. +option java_outer_classname = "OpenAPIProto"; + +// The Java package name must be proto package name with proper prefix. +option java_package = "org.openapi_v3"; + +// A reasonable prefix for the Objective-C symbols generated from the package. +// It should at a minimum be 3 characters long, all uppercase, and convention +// is to use an abbreviation of the package name. Something short, but +// hopefully unique enough to not conflict with things that may come along in +// the future. 'GPB' is reserved for the protocol buffer implementation itself. +option objc_class_prefix = "OAS"; + +// The Go package name. +option go_package = "github.com/google/gnostic/openapiv3;openapi_v3"; + +message AdditionalPropertiesItem { + oneof oneof { + SchemaOrReference schema_or_reference = 1; + bool boolean = 2; + } +} + +message Any { + google.protobuf.Any value = 1; + string yaml = 2; +} + +message AnyOrExpression { + oneof oneof { + Any any = 1; + Expression expression = 2; + } +} + +// A map of possible out-of band callbacks related to the parent operation. Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation. +message Callback { + repeated NamedPathItem path = 1; + repeated NamedAny specification_extension = 2; +} + +message CallbackOrReference { + oneof oneof { + Callback callback = 1; + Reference reference = 2; + } +} + +message CallbacksOrReferences { + repeated NamedCallbackOrReference additional_properties = 1; +} + +// Holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object. +message Components { + SchemasOrReferences schemas = 1; + ResponsesOrReferences responses = 2; + ParametersOrReferences parameters = 3; + ExamplesOrReferences examples = 4; + RequestBodiesOrReferences request_bodies = 5; + HeadersOrReferences headers = 6; + SecuritySchemesOrReferences security_schemes = 7; + LinksOrReferences links = 8; + CallbacksOrReferences callbacks = 9; + repeated NamedAny specification_extension = 10; +} + +// Contact information for the exposed API. +message Contact { + string name = 1; + string url = 2; + string email = 3; + repeated NamedAny specification_extension = 4; +} + +message DefaultType { + oneof oneof { + double number = 1; + bool boolean = 2; + string string = 3; + } +} + +// When request bodies or response payloads may be one of a number of different schemas, a `discriminator` object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it. When using the discriminator, _inline_ schemas will not be considered. +message Discriminator { + string property_name = 1; + Strings mapping = 2; + repeated NamedAny specification_extension = 3; +} + +message Document { + string openapi = 1; + Info info = 2; + repeated Server servers = 3; + Paths paths = 4; + Components components = 5; + repeated SecurityRequirement security = 6; + repeated Tag tags = 7; + ExternalDocs external_docs = 8; + repeated NamedAny specification_extension = 9; +} + +// A single encoding definition applied to a single schema property. +message Encoding { + string content_type = 1; + HeadersOrReferences headers = 2; + string style = 3; + bool explode = 4; + bool allow_reserved = 5; + repeated NamedAny specification_extension = 6; +} + +message Encodings { + repeated NamedEncoding additional_properties = 1; +} + +message Example { + string summary = 1; + string description = 2; + Any value = 3; + string external_value = 4; + repeated NamedAny specification_extension = 5; +} + +message ExampleOrReference { + oneof oneof { + Example example = 1; + Reference reference = 2; + } +} + +message ExamplesOrReferences { + repeated NamedExampleOrReference additional_properties = 1; +} + +message Expression { + repeated NamedAny additional_properties = 1; +} + +// Allows referencing an external resource for extended documentation. +message ExternalDocs { + string description = 1; + string url = 2; + repeated NamedAny specification_extension = 3; +} + +// The Header Object follows the structure of the Parameter Object with the following changes: 1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. 1. `in` MUST NOT be specified, it is implicitly in `header`. 1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, `style`). +message Header { + string description = 1; + bool required = 2; + bool deprecated = 3; + bool allow_empty_value = 4; + string style = 5; + bool explode = 6; + bool allow_reserved = 7; + SchemaOrReference schema = 8; + Any example = 9; + ExamplesOrReferences examples = 10; + MediaTypes content = 11; + repeated NamedAny specification_extension = 12; +} + +message HeaderOrReference { + oneof oneof { + Header header = 1; + Reference reference = 2; + } +} + +message HeadersOrReferences { + repeated NamedHeaderOrReference additional_properties = 1; +} + +// The object provides metadata about the API. The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience. +message Info { + string title = 1; + string description = 2; + string terms_of_service = 3; + Contact contact = 4; + License license = 5; + string version = 6; + repeated NamedAny specification_extension = 7; + string summary = 8; +} + +message ItemsItem { + repeated SchemaOrReference schema_or_reference = 1; +} + +// License information for the exposed API. +message License { + string name = 1; + string url = 2; + repeated NamedAny specification_extension = 3; +} + +// The `Link object` represents a possible design-time link for a response. The presence of a link does not guarantee the caller's ability to successfully invoke it, rather it provides a known relationship and traversal mechanism between responses and other operations. Unlike _dynamic_ links (i.e. links provided **in** the response payload), the OAS linking mechanism does not require link information in the runtime response. For computing links, and providing instructions to execute them, a runtime expression is used for accessing values in an operation and using them as parameters while invoking the linked operation. +message Link { + string operation_ref = 1; + string operation_id = 2; + AnyOrExpression parameters = 3; + AnyOrExpression request_body = 4; + string description = 5; + Server server = 6; + repeated NamedAny specification_extension = 7; +} + +message LinkOrReference { + oneof oneof { + Link link = 1; + Reference reference = 2; + } +} + +message LinksOrReferences { + repeated NamedLinkOrReference additional_properties = 1; +} + +// Each Media Type Object provides schema and examples for the media type identified by its key. +message MediaType { + SchemaOrReference schema = 1; + Any example = 2; + ExamplesOrReferences examples = 3; + Encodings encoding = 4; + repeated NamedAny specification_extension = 5; +} + +message MediaTypes { + repeated NamedMediaType additional_properties = 1; +} + +// Automatically-generated message used to represent maps of Any as ordered (name,value) pairs. +message NamedAny { + // Map key + string name = 1; + // Mapped value + Any value = 2; +} + +// Automatically-generated message used to represent maps of CallbackOrReference as ordered (name,value) pairs. +message NamedCallbackOrReference { + // Map key + string name = 1; + // Mapped value + CallbackOrReference value = 2; +} + +// Automatically-generated message used to represent maps of Encoding as ordered (name,value) pairs. +message NamedEncoding { + // Map key + string name = 1; + // Mapped value + Encoding value = 2; +} + +// Automatically-generated message used to represent maps of ExampleOrReference as ordered (name,value) pairs. +message NamedExampleOrReference { + // Map key + string name = 1; + // Mapped value + ExampleOrReference value = 2; +} + +// Automatically-generated message used to represent maps of HeaderOrReference as ordered (name,value) pairs. +message NamedHeaderOrReference { + // Map key + string name = 1; + // Mapped value + HeaderOrReference value = 2; +} + +// Automatically-generated message used to represent maps of LinkOrReference as ordered (name,value) pairs. +message NamedLinkOrReference { + // Map key + string name = 1; + // Mapped value + LinkOrReference value = 2; +} + +// Automatically-generated message used to represent maps of MediaType as ordered (name,value) pairs. +message NamedMediaType { + // Map key + string name = 1; + // Mapped value + MediaType value = 2; +} + +// Automatically-generated message used to represent maps of ParameterOrReference as ordered (name,value) pairs. +message NamedParameterOrReference { + // Map key + string name = 1; + // Mapped value + ParameterOrReference value = 2; +} + +// Automatically-generated message used to represent maps of PathItem as ordered (name,value) pairs. +message NamedPathItem { + // Map key + string name = 1; + // Mapped value + PathItem value = 2; +} + +// Automatically-generated message used to represent maps of RequestBodyOrReference as ordered (name,value) pairs. +message NamedRequestBodyOrReference { + // Map key + string name = 1; + // Mapped value + RequestBodyOrReference value = 2; +} + +// Automatically-generated message used to represent maps of ResponseOrReference as ordered (name,value) pairs. +message NamedResponseOrReference { + // Map key + string name = 1; + // Mapped value + ResponseOrReference value = 2; +} + +// Automatically-generated message used to represent maps of SchemaOrReference as ordered (name,value) pairs. +message NamedSchemaOrReference { + // Map key + string name = 1; + // Mapped value + SchemaOrReference value = 2; +} + +// Automatically-generated message used to represent maps of SecuritySchemeOrReference as ordered (name,value) pairs. +message NamedSecuritySchemeOrReference { + // Map key + string name = 1; + // Mapped value + SecuritySchemeOrReference value = 2; +} + +// Automatically-generated message used to represent maps of ServerVariable as ordered (name,value) pairs. +message NamedServerVariable { + // Map key + string name = 1; + // Mapped value + ServerVariable value = 2; +} + +// Automatically-generated message used to represent maps of string as ordered (name,value) pairs. +message NamedString { + // Map key + string name = 1; + // Mapped value + string value = 2; +} + +// Automatically-generated message used to represent maps of StringArray as ordered (name,value) pairs. +message NamedStringArray { + // Map key + string name = 1; + // Mapped value + StringArray value = 2; +} + +// Configuration details for a supported OAuth Flow +message OauthFlow { + string authorization_url = 1; + string token_url = 2; + string refresh_url = 3; + Strings scopes = 4; + repeated NamedAny specification_extension = 5; +} + +// Allows configuration of the supported OAuth Flows. +message OauthFlows { + OauthFlow implicit = 1; + OauthFlow password = 2; + OauthFlow client_credentials = 3; + OauthFlow authorization_code = 4; + repeated NamedAny specification_extension = 5; +} + +message Object { + repeated NamedAny additional_properties = 1; +} + +// Describes a single API operation on a path. +message Operation { + repeated string tags = 1; + string summary = 2; + string description = 3; + ExternalDocs external_docs = 4; + string operation_id = 5; + repeated ParameterOrReference parameters = 6; + RequestBodyOrReference request_body = 7; + Responses responses = 8; + CallbacksOrReferences callbacks = 9; + bool deprecated = 10; + repeated SecurityRequirement security = 11; + repeated Server servers = 12; + repeated NamedAny specification_extension = 13; +} + +// Describes a single operation parameter. A unique parameter is defined by a combination of a name and location. +message Parameter { + string name = 1; + string in = 2; + string description = 3; + bool required = 4; + bool deprecated = 5; + bool allow_empty_value = 6; + string style = 7; + bool explode = 8; + bool allow_reserved = 9; + SchemaOrReference schema = 10; + Any example = 11; + ExamplesOrReferences examples = 12; + MediaTypes content = 13; + repeated NamedAny specification_extension = 14; +} + +message ParameterOrReference { + oneof oneof { + Parameter parameter = 1; + Reference reference = 2; + } +} + +message ParametersOrReferences { + repeated NamedParameterOrReference additional_properties = 1; +} + +// Describes the operations available on a single path. A Path Item MAY be empty, due to ACL constraints. The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available. +message PathItem { + string _ref = 1; + string summary = 2; + string description = 3; + Operation get = 4; + Operation put = 5; + Operation post = 6; + Operation delete = 7; + Operation options = 8; + Operation head = 9; + Operation patch = 10; + Operation trace = 11; + repeated Server servers = 12; + repeated ParameterOrReference parameters = 13; + repeated NamedAny specification_extension = 14; +} + +// Holds the relative paths to the individual endpoints and their operations. The path is appended to the URL from the `Server Object` in order to construct the full URL. The Paths MAY be empty, due to ACL constraints. +message Paths { + repeated NamedPathItem path = 1; + repeated NamedAny specification_extension = 2; +} + +message Properties { + repeated NamedSchemaOrReference additional_properties = 1; +} + +// A simple object to allow referencing other components in the specification, internally and externally. The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules. For this specification, reference resolution is accomplished as defined by the JSON Reference specification and not by the JSON Schema specification. +message Reference { + string _ref = 1; + string summary = 2; + string description = 3; +} + +message RequestBodiesOrReferences { + repeated NamedRequestBodyOrReference additional_properties = 1; +} + +// Describes a single request body. +message RequestBody { + string description = 1; + MediaTypes content = 2; + bool required = 3; + repeated NamedAny specification_extension = 4; +} + +message RequestBodyOrReference { + oneof oneof { + RequestBody request_body = 1; + Reference reference = 2; + } +} + +// Describes a single response from an API Operation, including design-time, static `links` to operations based on the response. +message Response { + string description = 1; + HeadersOrReferences headers = 2; + MediaTypes content = 3; + LinksOrReferences links = 4; + repeated NamedAny specification_extension = 5; +} + +message ResponseOrReference { + oneof oneof { + Response response = 1; + Reference reference = 2; + } +} + +// A container for the expected responses of an operation. The container maps a HTTP response code to the expected response. The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors. The `default` MAY be used as a default response object for all HTTP codes that are not covered individually by the specification. The `Responses Object` MUST contain at least one response code, and it SHOULD be the response for a successful operation call. +message Responses { + ResponseOrReference default = 1; + repeated NamedResponseOrReference response_or_reference = 2; + repeated NamedAny specification_extension = 3; +} + +message ResponsesOrReferences { + repeated NamedResponseOrReference additional_properties = 1; +} + +// The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is an extended subset of the JSON Schema Specification Wright Draft 00. For more information about the properties, see JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema. +message Schema { + bool nullable = 1; + Discriminator discriminator = 2; + bool read_only = 3; + bool write_only = 4; + Xml xml = 5; + ExternalDocs external_docs = 6; + Any example = 7; + bool deprecated = 8; + string title = 9; + double multiple_of = 10; + double maximum = 11; + bool exclusive_maximum = 12; + double minimum = 13; + bool exclusive_minimum = 14; + int64 max_length = 15; + int64 min_length = 16; + string pattern = 17; + int64 max_items = 18; + int64 min_items = 19; + bool unique_items = 20; + int64 max_properties = 21; + int64 min_properties = 22; + repeated string required = 23; + repeated Any enum = 24; + string type = 25; + repeated SchemaOrReference all_of = 26; + repeated SchemaOrReference one_of = 27; + repeated SchemaOrReference any_of = 28; + Schema not = 29; + ItemsItem items = 30; + Properties properties = 31; + AdditionalPropertiesItem additional_properties = 32; + DefaultType default = 33; + string description = 34; + string format = 35; + repeated NamedAny specification_extension = 36; +} + +message SchemaOrReference { + oneof oneof { + Schema schema = 1; + Reference reference = 2; + } +} + +message SchemasOrReferences { + repeated NamedSchemaOrReference additional_properties = 1; +} + +// Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object. Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information. When a list of Security Requirement Objects is defined on the OpenAPI Object or Operation Object, only one of the Security Requirement Objects in the list needs to be satisfied to authorize the request. +message SecurityRequirement { + repeated NamedStringArray additional_properties = 1; +} + +// Defines a security scheme that can be used by the operations. Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), mutual TLS (use of a client certificate), OAuth2's common flows (implicit, password, application and access code) as defined in RFC6749, and OpenID Connect. Please note that currently (2019) the implicit flow is about to be deprecated OAuth 2.0 Security Best Current Practice. Recommended for most use case is Authorization Code Grant flow with PKCE. +message SecurityScheme { + string type = 1; + string description = 2; + string name = 3; + string in = 4; + string scheme = 5; + string bearer_format = 6; + OauthFlows flows = 7; + string open_id_connect_url = 8; + repeated NamedAny specification_extension = 9; +} + +message SecuritySchemeOrReference { + oneof oneof { + SecurityScheme security_scheme = 1; + Reference reference = 2; + } +} + +message SecuritySchemesOrReferences { + repeated NamedSecuritySchemeOrReference additional_properties = 1; +} + +// An object representing a Server. +message Server { + string url = 1; + string description = 2; + ServerVariables variables = 3; + repeated NamedAny specification_extension = 4; +} + +// An object representing a Server Variable for server URL template substitution. +message ServerVariable { + repeated string enum = 1; + string default = 2; + string description = 3; + repeated NamedAny specification_extension = 4; +} + +message ServerVariables { + repeated NamedServerVariable additional_properties = 1; +} + +// Any property starting with x- is valid. +message SpecificationExtension { + oneof oneof { + double number = 1; + bool boolean = 2; + string string = 3; + } +} + +message StringArray { + repeated string value = 1; +} + +message Strings { + repeated NamedString additional_properties = 1; +} + +// Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a Tag Object per tag defined in the Operation Object instances. +message Tag { + string name = 1; + string description = 2; + ExternalDocs external_docs = 3; + repeated NamedAny specification_extension = 4; +} + +// A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML element names are *not* inferred (for singular/plural forms) and the `name` property SHOULD be used to add that information. See examples for expected behavior. +message Xml { + string name = 1; + string namespace = 2; + string prefix = 3; + bool attribute = 4; + bool wrapped = 5; + repeated NamedAny specification_extension = 6; +} diff --git a/third_party/google/api/annotations.proto b/third_party/google/api/annotations.proto new file mode 100644 index 00000000..417edd8f --- /dev/null +++ b/third_party/google/api/annotations.proto @@ -0,0 +1,31 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/api/http.proto"; +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "AnnotationsProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.MethodOptions { + // See `HttpRule`. + HttpRule http = 72295728; +} diff --git a/third_party/google/api/client.proto b/third_party/google/api/client.proto new file mode 100644 index 00000000..3d692560 --- /dev/null +++ b/third_party/google/api/client.proto @@ -0,0 +1,486 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/api/launch_stage.proto"; +import "google/protobuf/descriptor.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "ClientProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.MethodOptions { + // A definition of a client library method signature. + // + // In client libraries, each proto RPC corresponds to one or more methods + // which the end user is able to call, and calls the underlying RPC. + // Normally, this method receives a single argument (a struct or instance + // corresponding to the RPC request object). Defining this field will + // add one or more overloads providing flattened or simpler method signatures + // in some languages. + // + // The fields on the method signature are provided as a comma-separated + // string. + // + // For example, the proto RPC and annotation: + // + // rpc CreateSubscription(CreateSubscriptionRequest) + // returns (Subscription) { + // option (google.api.method_signature) = "name,topic"; + // } + // + // Would add the following Java overload (in addition to the method accepting + // the request object): + // + // public final Subscription createSubscription(String name, String topic) + // + // The following backwards-compatibility guidelines apply: + // + // * Adding this annotation to an unannotated method is backwards + // compatible. + // * Adding this annotation to a method which already has existing + // method signature annotations is backwards compatible if and only if + // the new method signature annotation is last in the sequence. + // * Modifying or removing an existing method signature annotation is + // a breaking change. + // * Re-ordering existing method signature annotations is a breaking + // change. + repeated string method_signature = 1051; +} + +extend google.protobuf.ServiceOptions { + // The hostname for this service. + // This should be specified with no prefix or protocol. + // + // Example: + // + // service Foo { + // option (google.api.default_host) = "foo.googleapi.com"; + // ... + // } + string default_host = 1049; + + // OAuth scopes needed for the client. + // + // Example: + // + // service Foo { + // option (google.api.oauth_scopes) = \ + // "https://www.googleapis.com/auth/cloud-platform"; + // ... + // } + // + // If there is more than one scope, use a comma-separated string: + // + // Example: + // + // service Foo { + // option (google.api.oauth_scopes) = \ + // "https://www.googleapis.com/auth/cloud-platform," + // "https://www.googleapis.com/auth/monitoring"; + // ... + // } + string oauth_scopes = 1050; + + // The API version of this service, which should be sent by version-aware + // clients to the service. This allows services to abide by the schema and + // behavior of the service at the time this API version was deployed. + // The format of the API version must be treated as opaque by clients. + // Services may use a format with an apparent structure, but clients must + // not rely on this to determine components within an API version, or attempt + // to construct other valid API versions. Note that this is for upcoming + // functionality and may not be implemented for all services. + // + // Example: + // + // service Foo { + // option (google.api.api_version) = "v1_20230821_preview"; + // } + string api_version = 525000001; +} + +// Required information for every language. +message CommonLanguageSettings { + // Link to automatically generated reference documentation. Example: + // https://cloud.google.com/nodejs/docs/reference/asset/latest + string reference_docs_uri = 1 [deprecated = true]; + + // The destination where API teams want this client library to be published. + repeated ClientLibraryDestination destinations = 2; + + // Configuration for which RPCs should be generated in the GAPIC client. + SelectiveGapicGeneration selective_gapic_generation = 3; +} + +// Details about how and where to publish client libraries. +message ClientLibrarySettings { + // Version of the API to apply these settings to. This is the full protobuf + // package for the API, ending in the version element. + // Examples: "google.cloud.speech.v1" and "google.spanner.admin.database.v1". + string version = 1; + + // Launch stage of this version of the API. + LaunchStage launch_stage = 2; + + // When using transport=rest, the client request will encode enums as + // numbers rather than strings. + bool rest_numeric_enums = 3; + + // Settings for legacy Java features, supported in the Service YAML. + JavaSettings java_settings = 21; + + // Settings for C++ client libraries. + CppSettings cpp_settings = 22; + + // Settings for PHP client libraries. + PhpSettings php_settings = 23; + + // Settings for Python client libraries. + PythonSettings python_settings = 24; + + // Settings for Node client libraries. + NodeSettings node_settings = 25; + + // Settings for .NET client libraries. + DotnetSettings dotnet_settings = 26; + + // Settings for Ruby client libraries. + RubySettings ruby_settings = 27; + + // Settings for Go client libraries. + GoSettings go_settings = 28; +} + +// This message configures the settings for publishing [Google Cloud Client +// libraries](https://cloud.google.com/apis/docs/cloud-client-libraries) +// generated from the service config. +message Publishing { + // A list of API method settings, e.g. the behavior for methods that use the + // long-running operation pattern. + repeated MethodSettings method_settings = 2; + + // Link to a *public* URI where users can report issues. Example: + // https://issuetracker.google.com/issues/new?component=190865&template=1161103 + string new_issue_uri = 101; + + // Link to product home page. Example: + // https://cloud.google.com/asset-inventory/docs/overview + string documentation_uri = 102; + + // Used as a tracking tag when collecting data about the APIs developer + // relations artifacts like docs, packages delivered to package managers, + // etc. Example: "speech". + string api_short_name = 103; + + // GitHub label to apply to issues and pull requests opened for this API. + string github_label = 104; + + // GitHub teams to be added to CODEOWNERS in the directory in GitHub + // containing source code for the client libraries for this API. + repeated string codeowner_github_teams = 105; + + // A prefix used in sample code when demarking regions to be included in + // documentation. + string doc_tag_prefix = 106; + + // For whom the client library is being published. + ClientLibraryOrganization organization = 107; + + // Client library settings. If the same version string appears multiple + // times in this list, then the last one wins. Settings from earlier + // settings with the same version string are discarded. + repeated ClientLibrarySettings library_settings = 109; + + // Optional link to proto reference documentation. Example: + // https://cloud.google.com/pubsub/lite/docs/reference/rpc + string proto_reference_documentation_uri = 110; + + // Optional link to REST reference documentation. Example: + // https://cloud.google.com/pubsub/lite/docs/reference/rest + string rest_reference_documentation_uri = 111; +} + +// Settings for Java client libraries. +message JavaSettings { + // The package name to use in Java. Clobbers the java_package option + // set in the protobuf. This should be used **only** by APIs + // who have already set the language_settings.java.package_name" field + // in gapic.yaml. API teams should use the protobuf java_package option + // where possible. + // + // Example of a YAML configuration:: + // + // publishing: + // java_settings: + // library_package: com.google.cloud.pubsub.v1 + string library_package = 1; + + // Configure the Java class name to use instead of the service's for its + // corresponding generated GAPIC client. Keys are fully-qualified + // service names as they appear in the protobuf (including the full + // the language_settings.java.interface_names" field in gapic.yaml. API + // teams should otherwise use the service name as it appears in the + // protobuf. + // + // Example of a YAML configuration:: + // + // publishing: + // java_settings: + // service_class_names: + // - google.pubsub.v1.Publisher: TopicAdmin + // - google.pubsub.v1.Subscriber: SubscriptionAdmin + map service_class_names = 2; + + // Some settings. + CommonLanguageSettings common = 3; +} + +// Settings for C++ client libraries. +message CppSettings { + // Some settings. + CommonLanguageSettings common = 1; +} + +// Settings for Php client libraries. +message PhpSettings { + // Some settings. + CommonLanguageSettings common = 1; +} + +// Settings for Python client libraries. +message PythonSettings { + // Experimental features to be included during client library generation. + // These fields will be deprecated once the feature graduates and is enabled + // by default. + message ExperimentalFeatures { + // Enables generation of asynchronous REST clients if `rest` transport is + // enabled. By default, asynchronous REST clients will not be generated. + // This feature will be enabled by default 1 month after launching the + // feature in preview packages. + bool rest_async_io_enabled = 1; + + // Enables generation of protobuf code using new types that are more + // Pythonic which are included in `protobuf>=5.29.x`. This feature will be + // enabled by default 1 month after launching the feature in preview + // packages. + bool protobuf_pythonic_types_enabled = 2; + + // Disables generation of an unversioned Python package for this client + // library. This means that the module names will need to be versioned in + // import statements. For example `import google.cloud.library_v2` instead + // of `import google.cloud.library`. + bool unversioned_package_disabled = 3; + } + + // Some settings. + CommonLanguageSettings common = 1; + + // Experimental features to be included during client library generation. + ExperimentalFeatures experimental_features = 2; +} + +// Settings for Node client libraries. +message NodeSettings { + // Some settings. + CommonLanguageSettings common = 1; +} + +// Settings for Dotnet client libraries. +message DotnetSettings { + // Some settings. + CommonLanguageSettings common = 1; + + // Map from original service names to renamed versions. + // This is used when the default generated types + // would cause a naming conflict. (Neither name is + // fully-qualified.) + // Example: Subscriber to SubscriberServiceApi. + map renamed_services = 2; + + // Map from full resource types to the effective short name + // for the resource. This is used when otherwise resource + // named from different services would cause naming collisions. + // Example entry: + // "datalabeling.googleapis.com/Dataset": "DataLabelingDataset" + map renamed_resources = 3; + + // List of full resource types to ignore during generation. + // This is typically used for API-specific Location resources, + // which should be handled by the generator as if they were actually + // the common Location resources. + // Example entry: "documentai.googleapis.com/Location" + repeated string ignored_resources = 4; + + // Namespaces which must be aliased in snippets due to + // a known (but non-generator-predictable) naming collision + repeated string forced_namespace_aliases = 5; + + // Method signatures (in the form "service.method(signature)") + // which are provided separately, so shouldn't be generated. + // Snippets *calling* these methods are still generated, however. + repeated string handwritten_signatures = 6; +} + +// Settings for Ruby client libraries. +message RubySettings { + // Some settings. + CommonLanguageSettings common = 1; +} + +// Settings for Go client libraries. +message GoSettings { + // Some settings. + CommonLanguageSettings common = 1; + + // Map of service names to renamed services. Keys are the package relative + // service names and values are the name to be used for the service client + // and call options. + // + // publishing: + // go_settings: + // renamed_services: + // Publisher: TopicAdmin + map renamed_services = 2; +} + +// Describes the generator configuration for a method. +message MethodSettings { + // Describes settings to use when generating API methods that use the + // long-running operation pattern. + // All default values below are from those used in the client library + // generators (e.g. + // [Java](https://github.com/googleapis/gapic-generator-java/blob/04c2faa191a9b5a10b92392fe8482279c4404803/src/main/java/com/google/api/generator/gapic/composer/common/RetrySettingsComposer.java)). + message LongRunning { + // Initial delay after which the first poll request will be made. + // Default value: 5 seconds. + google.protobuf.Duration initial_poll_delay = 1; + + // Multiplier to gradually increase delay between subsequent polls until it + // reaches max_poll_delay. + // Default value: 1.5. + float poll_delay_multiplier = 2; + + // Maximum time between two subsequent poll requests. + // Default value: 45 seconds. + google.protobuf.Duration max_poll_delay = 3; + + // Total polling timeout. + // Default value: 5 minutes. + google.protobuf.Duration total_poll_timeout = 4; + } + + // The fully qualified name of the method, for which the options below apply. + // This is used to find the method to apply the options. + // + // Example: + // + // publishing: + // method_settings: + // - selector: google.storage.control.v2.StorageControl.CreateFolder + // # method settings for CreateFolder... + string selector = 1; + + // Describes settings to use for long-running operations when generating + // API methods for RPCs. Complements RPCs that use the annotations in + // google/longrunning/operations.proto. + // + // Example of a YAML configuration:: + // + // publishing: + // method_settings: + // - selector: google.cloud.speech.v2.Speech.BatchRecognize + // long_running: + // initial_poll_delay: 60s # 1 minute + // poll_delay_multiplier: 1.5 + // max_poll_delay: 360s # 6 minutes + // total_poll_timeout: 54000s # 90 minutes + LongRunning long_running = 2; + + // List of top-level fields of the request message, that should be + // automatically populated by the client libraries based on their + // (google.api.field_info).format. Currently supported format: UUID4. + // + // Example of a YAML configuration: + // + // publishing: + // method_settings: + // - selector: google.example.v1.ExampleService.CreateExample + // auto_populated_fields: + // - request_id + repeated string auto_populated_fields = 3; +} + +// The organization for which the client libraries are being published. +// Affects the url where generated docs are published, etc. +enum ClientLibraryOrganization { + // Not useful. + CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED = 0; + + // Google Cloud Platform Org. + CLOUD = 1; + + // Ads (Advertising) Org. + ADS = 2; + + // Photos Org. + PHOTOS = 3; + + // Street View Org. + STREET_VIEW = 4; + + // Shopping Org. + SHOPPING = 5; + + // Geo Org. + GEO = 6; + + // Generative AI - https://developers.generativeai.google + GENERATIVE_AI = 7; +} + +// To where should client libraries be published? +enum ClientLibraryDestination { + // Client libraries will neither be generated nor published to package + // managers. + CLIENT_LIBRARY_DESTINATION_UNSPECIFIED = 0; + + // Generate the client library in a repo under github.com/googleapis, + // but don't publish it to package managers. + GITHUB = 10; + + // Publish the library to package managers like nuget.org and npmjs.com. + PACKAGE_MANAGER = 20; +} + +// This message is used to configure the generation of a subset of the RPCs in +// a service for client libraries. +message SelectiveGapicGeneration { + // An allowlist of the fully qualified names of RPCs that should be included + // on public client surfaces. + repeated string methods = 1; + + // Setting this to true indicates to the client generators that methods + // that would be excluded from the generation should instead be generated + // in a way that indicates these methods should not be consumed by + // end users. How this is expressed is up to individual language + // implementations to decide. Some examples may be: added annotations, + // obfuscated identifiers, or other language idiomatic patterns. + bool generate_omitted_as_internal = 2; +} diff --git a/third_party/google/api/expr/v1alpha1/checked.proto b/third_party/google/api/expr/v1alpha1/checked.proto new file mode 100644 index 00000000..ffdbee5f --- /dev/null +++ b/third_party/google/api/expr/v1alpha1/checked.proto @@ -0,0 +1,343 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api.expr.v1alpha1; + +import "google/api/expr/v1alpha1/syntax.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/struct.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr"; +option java_multiple_files = true; +option java_outer_classname = "DeclProto"; +option java_package = "com.google.api.expr.v1alpha1"; + +// Protos for representing CEL declarations and typed checked expressions. + +// A CEL expression which has been successfully type checked. +message CheckedExpr { + // A map from expression ids to resolved references. + // + // The following entries are in this table: + // + // - An Ident or Select expression is represented here if it resolves to a + // declaration. For instance, if `a.b.c` is represented by + // `select(select(id(a), b), c)`, and `a.b` resolves to a declaration, + // while `c` is a field selection, then the reference is attached to the + // nested select expression (but not to the id or or the outer select). + // In turn, if `a` resolves to a declaration and `b.c` are field selections, + // the reference is attached to the ident expression. + // - Every Call expression has an entry here, identifying the function being + // called. + // - Every CreateStruct expression for a message has an entry, identifying + // the message. + map reference_map = 2; + + // A map from expression ids to types. + // + // Every expression node which has a type different than DYN has a mapping + // here. If an expression has type DYN, it is omitted from this map to save + // space. + map type_map = 3; + + // The source info derived from input that generated the parsed `expr` and + // any optimizations made during the type-checking pass. + SourceInfo source_info = 5; + + // The expr version indicates the major / minor version number of the `expr` + // representation. + // + // The most common reason for a version change will be to indicate to the CEL + // runtimes that transformations have been performed on the expr during static + // analysis. In some cases, this will save the runtime the work of applying + // the same or similar transformations prior to evaluation. + string expr_version = 6; + + // The checked expression. Semantically equivalent to the parsed `expr`, but + // may have structural differences. + Expr expr = 4; +} + +// Represents a CEL type. +message Type { + // List type with typed elements, e.g. `list`. + message ListType { + // The element type. + Type elem_type = 1; + } + + // Map type with parameterized key and value types, e.g. `map`. + message MapType { + // The type of the key. + Type key_type = 1; + + // The type of the value. + Type value_type = 2; + } + + // Function type with result and arg types. + message FunctionType { + // Result type of the function. + Type result_type = 1; + + // Argument types of the function. + repeated Type arg_types = 2; + } + + // Application defined abstract type. + message AbstractType { + // The fully qualified name of this abstract type. + string name = 1; + + // Parameter types for this abstract type. + repeated Type parameter_types = 2; + } + + // CEL primitive types. + enum PrimitiveType { + // Unspecified type. + PRIMITIVE_TYPE_UNSPECIFIED = 0; + + // Boolean type. + BOOL = 1; + + // Int64 type. + // + // Proto-based integer values are widened to int64. + INT64 = 2; + + // Uint64 type. + // + // Proto-based unsigned integer values are widened to uint64. + UINT64 = 3; + + // Double type. + // + // Proto-based float values are widened to double values. + DOUBLE = 4; + + // String type. + STRING = 5; + + // Bytes type. + BYTES = 6; + } + + // Well-known protobuf types treated with first-class support in CEL. + enum WellKnownType { + // Unspecified type. + WELL_KNOWN_TYPE_UNSPECIFIED = 0; + + // Well-known protobuf.Any type. + // + // Any types are a polymorphic message type. During type-checking they are + // treated like `DYN` types, but at runtime they are resolved to a specific + // message type specified at evaluation time. + ANY = 1; + + // Well-known protobuf.Timestamp type, internally referenced as `timestamp`. + TIMESTAMP = 2; + + // Well-known protobuf.Duration type, internally referenced as `duration`. + DURATION = 3; + } + + // The kind of type. + oneof type_kind { + // Dynamic type. + google.protobuf.Empty dyn = 1; + + // Null value. + google.protobuf.NullValue null = 2; + + // Primitive types: `true`, `1u`, `-2.0`, `'string'`, `b'bytes'`. + PrimitiveType primitive = 3; + + // Wrapper of a primitive type, e.g. `google.protobuf.Int64Value`. + PrimitiveType wrapper = 4; + + // Well-known protobuf type such as `google.protobuf.Timestamp`. + WellKnownType well_known = 5; + + // Parameterized list with elements of `list_type`, e.g. `list`. + ListType list_type = 6; + + // Parameterized map with typed keys and values. + MapType map_type = 7; + + // Function type. + FunctionType function = 8; + + // Protocol buffer message type. + // + // The `message_type` string specifies the qualified message type name. For + // example, `google.plus.Profile`. + string message_type = 9; + + // Type param type. + // + // The `type_param` string specifies the type parameter name, e.g. `list` + // would be a `list_type` whose element type was a `type_param` type + // named `E`. + string type_param = 10; + + // Type type. + // + // The `type` value specifies the target type. e.g. int is type with a + // target type of `Primitive.INT`. + Type type = 11; + + // Error type. + // + // During type-checking if an expression is an error, its type is propagated + // as the `ERROR` type. This permits the type-checker to discover other + // errors present in the expression. + google.protobuf.Empty error = 12; + + // Abstract, application defined type. + AbstractType abstract_type = 14; + } +} + +// Represents a declaration of a named value or function. +// +// A declaration is part of the contract between the expression, the agent +// evaluating that expression, and the caller requesting evaluation. +message Decl { + // Identifier declaration which specifies its type and optional `Expr` value. + // + // An identifier without a value is a declaration that must be provided at + // evaluation time. An identifier with a value should resolve to a constant, + // but may be used in conjunction with other identifiers bound at evaluation + // time. + message IdentDecl { + // Required. The type of the identifier. + Type type = 1; + + // The constant value of the identifier. If not specified, the identifier + // must be supplied at evaluation time. + Constant value = 2; + + // Documentation string for the identifier. + string doc = 3; + } + + // Function declaration specifies one or more overloads which indicate the + // function's parameter types and return type. + // + // Functions have no observable side-effects (there may be side-effects like + // logging which are not observable from CEL). + message FunctionDecl { + // An overload indicates a function's parameter types and return type, and + // may optionally include a function body described in terms of + // [Expr][google.api.expr.v1alpha1.Expr] values. + // + // Functions overloads are declared in either a function or method + // call-style. For methods, the `params[0]` is the expected type of the + // target receiver. + // + // Overloads must have non-overlapping argument types after erasure of all + // parameterized type variables (similar as type erasure in Java). + message Overload { + // Required. Globally unique overload name of the function which reflects + // the function name and argument types. + // + // This will be used by a [Reference][google.api.expr.v1alpha1.Reference] + // to indicate the `overload_id` that was resolved for the function + // `name`. + string overload_id = 1; + + // List of function parameter [Type][google.api.expr.v1alpha1.Type] + // values. + // + // Param types are disjoint after generic type parameters have been + // replaced with the type `DYN`. Since the `DYN` type is compatible with + // any other type, this means that if `A` is a type parameter, the + // function types `int` and `int` are not disjoint. Likewise, + // `map` is not disjoint from `map`. + // + // When the `result_type` of a function is a generic type param, the + // type param name also appears as the `type` of on at least one params. + repeated Type params = 2; + + // The type param names associated with the function declaration. + // + // For example, `function ex(K key, map map) : V` would yield + // the type params of `K, V`. + repeated string type_params = 3; + + // Required. The result type of the function. For example, the operator + // `string.isEmpty()` would have `result_type` of `kind: BOOL`. + Type result_type = 4; + + // Whether the function is to be used in a method call-style `x.f(...)` + // or a function call-style `f(x, ...)`. + // + // For methods, the first parameter declaration, `params[0]` is the + // expected type of the target receiver. + bool is_instance_function = 5; + + // Documentation string for the overload. + string doc = 6; + } + + // Required. List of function overloads, must contain at least one overload. + repeated Overload overloads = 1; + } + + // The fully qualified name of the declaration. + // + // Declarations are organized in containers and this represents the full path + // to the declaration in its container, as in `google.api.expr.Decl`. + // + // Declarations used as + // [FunctionDecl.Overload][google.api.expr.v1alpha1.Decl.FunctionDecl.Overload] + // parameters may or may not have a name depending on whether the overload is + // function declaration or a function definition containing a result + // [Expr][google.api.expr.v1alpha1.Expr]. + string name = 1; + + // Required. The declaration kind. + oneof decl_kind { + // Identifier declaration. + IdentDecl ident = 2; + + // Function declaration. + FunctionDecl function = 3; + } +} + +// Describes a resolved reference to a declaration. +message Reference { + // The fully qualified name of the declaration. + string name = 1; + + // For references to functions, this is a list of `Overload.overload_id` + // values which match according to typing rules. + // + // If the list has more than one element, overload resolution among the + // presented candidates must happen at runtime because of dynamic types. The + // type checker attempts to narrow down this list as much as possible. + // + // Empty if this is not a reference to a + // [Decl.FunctionDecl][google.api.expr.v1alpha1.Decl.FunctionDecl]. + repeated string overload_id = 3; + + // For references to constants, this may contain the value of the + // constant if known at compile time. + Constant value = 4; +} diff --git a/third_party/google/api/expr/v1alpha1/eval.proto b/third_party/google/api/expr/v1alpha1/eval.proto new file mode 100644 index 00000000..cdf1d48d --- /dev/null +++ b/third_party/google/api/expr/v1alpha1/eval.proto @@ -0,0 +1,118 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api.expr.v1alpha1; + +import "google/api/expr/v1alpha1/value.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr"; +option java_multiple_files = true; +option java_outer_classname = "EvalProto"; +option java_package = "com.google.api.expr.v1alpha1"; + +// The state of an evaluation. +// +// Can represent an inital, partial, or completed state of evaluation. +message EvalState { + // A single evalution result. + message Result { + // The id of the expression this result if for. + int64 expr = 1; + + // The index in `values` of the resulting value. + int64 value = 2; + } + + // The unique values referenced in this message. + repeated ExprValue values = 1; + + // An ordered list of results. + // + // Tracks the flow of evaluation through the expression. + // May be sparse. + repeated Result results = 3; +} + +// The value of an evaluated expression. +message ExprValue { + // An expression can resolve to a value, error or unknown. + oneof kind { + // A concrete value. + Value value = 1; + + // The set of errors in the critical path of evalution. + // + // Only errors in the critical path are included. For example, + // `( || true) && ` will only result in ``, + // while ` || ` will result in both `` and + // ``. + // + // Errors cause by the presence of other errors are not included in the + // set. For example `.foo`, `foo()`, and ` + 1` will + // only result in ``. + // + // Multiple errors *might* be included when evaluation could result + // in different errors. For example ` + ` and + // `foo(, )` may result in ``, `` or both. + // The exact subset of errors included for this case is unspecified and + // depends on the implementation details of the evaluator. + ErrorSet error = 2; + + // The set of unknowns in the critical path of evaluation. + // + // Unknown behaves identically to Error with regards to propagation. + // Specifically, only unknowns in the critical path are included, unknowns + // caused by the presence of other unknowns are not included, and multiple + // unknowns *might* be included included when evaluation could result in + // different unknowns. For example: + // + // ( || true) && -> + // || -> + // .foo -> + // foo() -> + // + -> or + // + // Unknown takes precidence over Error in cases where a `Value` can short + // circuit the result: + // + // || -> + // && -> + // + // Errors take precidence in all other cases: + // + // + -> + // foo(, ) -> + UnknownSet unknown = 3; + } +} + +// A set of errors. +// +// The errors included depend on the context. See `ExprValue.error`. +message ErrorSet { + // The errors in the set. + repeated google.rpc.Status errors = 1; +} + +// A set of expressions for which the value is unknown. +// +// The unknowns included depend on the context. See `ExprValue.unknown`. +message UnknownSet { + // The ids of the expressions with unknown values. + repeated int64 exprs = 1; +} diff --git a/third_party/google/api/expr/v1alpha1/explain.proto b/third_party/google/api/expr/v1alpha1/explain.proto new file mode 100644 index 00000000..cd5ffc29 --- /dev/null +++ b/third_party/google/api/expr/v1alpha1/explain.proto @@ -0,0 +1,53 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api.expr.v1alpha1; + +import "google/api/expr/v1alpha1/value.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr"; +option java_multiple_files = true; +option java_outer_classname = "ExplainProto"; +option java_package = "com.google.api.expr.v1alpha1"; + +// Values of intermediate expressions produced when evaluating expression. +// Deprecated, use `EvalState` instead. +message Explain { + option deprecated = true; + + // ID and value index of one step. + message ExprStep { + // ID of corresponding Expr node. + int64 id = 1; + + // Index of the value in the values list. + int32 value_index = 2; + } + + // All of the observed values. + // + // The field value_index is an index in the values list. + // Separating values from steps is needed to remove redundant values. + repeated Value values = 1; + + // List of steps. + // + // Repeated evaluations of the same expression generate new ExprStep + // instances. The order of such ExprStep instances matches the order of + // elements returned by Comprehension.iter_range. + repeated ExprStep expr_steps = 2; +} diff --git a/third_party/google/api/expr/v1alpha1/syntax.proto b/third_party/google/api/expr/v1alpha1/syntax.proto new file mode 100644 index 00000000..b0cdd4d4 --- /dev/null +++ b/third_party/google/api/expr/v1alpha1/syntax.proto @@ -0,0 +1,438 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api.expr.v1alpha1; + +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr"; +option java_multiple_files = true; +option java_outer_classname = "SyntaxProto"; +option java_package = "com.google.api.expr.v1alpha1"; + +// A representation of the abstract syntax of the Common Expression Language. + +// An expression together with source information as returned by the parser. +message ParsedExpr { + // The parsed expression. + Expr expr = 2; + + // The source info derived from input that generated the parsed `expr`. + SourceInfo source_info = 3; +} + +// An abstract representation of a common expression. +// +// Expressions are abstractly represented as a collection of identifiers, +// select statements, function calls, literals, and comprehensions. All +// operators with the exception of the '.' operator are modelled as function +// calls. This makes it easy to represent new operators into the existing AST. +// +// All references within expressions must resolve to a +// [Decl][google.api.expr.v1alpha1.Decl] provided at type-check for an +// expression to be valid. A reference may either be a bare identifier `name` or +// a qualified identifier `google.api.name`. References may either refer to a +// value or a function declaration. +// +// For example, the expression `google.api.name.startsWith('expr')` references +// the declaration `google.api.name` within a +// [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression, and the +// function declaration `startsWith`. +message Expr { + // An identifier expression. e.g. `request`. + message Ident { + // Required. Holds a single, unqualified identifier, possibly preceded by a + // '.'. + // + // Qualified names are represented by the + // [Expr.Select][google.api.expr.v1alpha1.Expr.Select] expression. + string name = 1; + } + + // A field selection expression. e.g. `request.auth`. + message Select { + // Required. The target of the selection expression. + // + // For example, in the select expression `request.auth`, the `request` + // portion of the expression is the `operand`. + Expr operand = 1; + + // Required. The name of the field to select. + // + // For example, in the select expression `request.auth`, the `auth` portion + // of the expression would be the `field`. + string field = 2; + + // Whether the select is to be interpreted as a field presence test. + // + // This results from the macro `has(request.auth)`. + bool test_only = 3; + } + + // A call expression, including calls to predefined functions and operators. + // + // For example, `value == 10`, `size(map_value)`. + message Call { + // The target of an method call-style expression. For example, `x` in + // `x.f()`. + Expr target = 1; + + // Required. The name of the function or method being called. + string function = 2; + + // The arguments. + repeated Expr args = 3; + } + + // A list creation expression. + // + // Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogeneous, e.g. + // `dyn([1, 'hello', 2.0])` + message CreateList { + // The elements part of the list. + repeated Expr elements = 1; + + // The indices within the elements list which are marked as optional + // elements. + // + // When an optional-typed value is present, the value it contains + // is included in the list. If the optional-typed value is absent, the list + // element is omitted from the CreateList result. + repeated int32 optional_indices = 2; + } + + // A map or message creation expression. + // + // Maps are constructed as `{'key_name': 'value'}`. Message construction is + // similar, but prefixed with a type name and composed of field ids: + // `types.MyType{field_id: 'value'}`. + message CreateStruct { + // Represents an entry. + message Entry { + // Required. An id assigned to this node by the parser which is unique + // in a given expression tree. This is used to associate type + // information and other attributes to the node. + int64 id = 1; + + // The `Entry` key kinds. + oneof key_kind { + // The field key for a message creator statement. + string field_key = 2; + + // The key expression for a map creation statement. + Expr map_key = 3; + } + + // Required. The value assigned to the key. + // + // If the optional_entry field is true, the expression must resolve to an + // optional-typed value. If the optional value is present, the key will be + // set; however, if the optional value is absent, the key will be unset. + Expr value = 4; + + // Whether the key-value pair is optional. + bool optional_entry = 5; + } + + // The type name of the message to be created, empty when creating map + // literals. + string message_name = 1; + + // The entries in the creation expression. + repeated Entry entries = 2; + } + + // A comprehension expression applied to a list or map. + // + // Comprehensions are not part of the core syntax, but enabled with macros. + // A macro matches a specific call signature within a parsed AST and replaces + // the call with an alternate AST block. Macro expansion happens at parse + // time. + // + // The following macros are supported within CEL: + // + // Aggregate type macros may be applied to all elements in a list or all keys + // in a map: + // + // * `all`, `exists`, `exists_one` - test a predicate expression against + // the inputs and return `true` if the predicate is satisfied for all, + // any, or only one value `list.all(x, x < 10)`. + // * `filter` - test a predicate expression against the inputs and return + // the subset of elements which satisfy the predicate: + // `payments.filter(p, p > 1000)`. + // * `map` - apply an expression to all elements in the input and return the + // output aggregate type: `[1, 2, 3].map(i, i * i)`. + // + // The `has(m.x)` macro tests whether the property `x` is present in struct + // `m`. The semantics of this macro depend on the type of `m`. For proto2 + // messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the + // macro tests whether the property is set to its default. For map and struct + // types, the macro tests whether the property `x` is defined on `m`. + // + // Comprehensions for the standard environment macros evaluation can be best + // visualized as the following pseudocode: + // + // ``` + // let `accu_var` = `accu_init` + // for (let `iter_var` in `iter_range`) { + // if (!`loop_condition`) { + // break + // } + // `accu_var` = `loop_step` + // } + // return `result` + // ``` + // + // Comprehensions for the optional V2 macros which support map-to-map + // translation differ slightly from the standard environment macros in that + // they expose both the key or index in addition to the value for each list + // or map entry: + // + // ``` + // let `accu_var` = `accu_init` + // for (let `iter_var`, `iter_var2` in `iter_range`) { + // if (!`loop_condition`) { + // break + // } + // `accu_var` = `loop_step` + // } + // return `result` + // ``` + message Comprehension { + // The name of the first iteration variable. + // When the iter_range is a list, this variable is the list element. + // When the iter_range is a map, this variable is the map entry key. + string iter_var = 1; + + // The name of the second iteration variable, empty if not set. + // When the iter_range is a list, this variable is the integer index. + // When the iter_range is a map, this variable is the map entry value. + // This field is only set for comprehension v2 macros. + string iter_var2 = 8; + + // The range over which the comprehension iterates. + Expr iter_range = 2; + + // The name of the variable used for accumulation of the result. + string accu_var = 3; + + // The initial value of the accumulator. + Expr accu_init = 4; + + // An expression which can contain iter_var, iter_var2, and accu_var. + // + // Returns false when the result has been computed and may be used as + // a hint to short-circuit the remainder of the comprehension. + Expr loop_condition = 5; + + // An expression which can contain iter_var, iter_var2, and accu_var. + // + // Computes the next value of accu_var. + Expr loop_step = 6; + + // An expression which can contain accu_var. + // + // Computes the result. + Expr result = 7; + } + + // Required. An id assigned to this node by the parser which is unique in a + // given expression tree. This is used to associate type information and other + // attributes to a node in the parse tree. + int64 id = 2; + + // Required. Variants of expressions. + oneof expr_kind { + // A literal expression. + Constant const_expr = 3; + + // An identifier expression. + Ident ident_expr = 4; + + // A field selection expression, e.g. `request.auth`. + Select select_expr = 5; + + // A call expression, including calls to predefined functions and operators. + Call call_expr = 6; + + // A list creation expression. + CreateList list_expr = 7; + + // A map or message creation expression. + CreateStruct struct_expr = 8; + + // A comprehension expression. + Comprehension comprehension_expr = 9; + } +} + +// Represents a primitive literal. +// +// Named 'Constant' here for backwards compatibility. +// +// This is similar as the primitives supported in the well-known type +// `google.protobuf.Value`, but richer so it can represent CEL's full range of +// primitives. +// +// Lists and structs are not included as constants as these aggregate types may +// contain [Expr][google.api.expr.v1alpha1.Expr] elements which require +// evaluation and are thus not constant. +// +// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`, +// `true`, `null`. +message Constant { + // Required. The valid constant kinds. + oneof constant_kind { + // null value. + google.protobuf.NullValue null_value = 1; + + // boolean value. + bool bool_value = 2; + + // int64 value. + int64 int64_value = 3; + + // uint64 value. + uint64 uint64_value = 4; + + // double value. + double double_value = 5; + + // string value. + string string_value = 6; + + // bytes value. + bytes bytes_value = 7; + + // protobuf.Duration value. + // + // Deprecated: duration is no longer considered a builtin cel type. + google.protobuf.Duration duration_value = 8 [deprecated = true]; + + // protobuf.Timestamp value. + // + // Deprecated: timestamp is no longer considered a builtin cel type. + google.protobuf.Timestamp timestamp_value = 9 [deprecated = true]; + } +} + +// Source information collected at parse time. +message SourceInfo { + // An extension that was requested for the source expression. + message Extension { + // Version + message Version { + // Major version changes indicate different required support level from + // the required components. + int64 major = 1; + + // Minor version changes must not change the observed behavior from + // existing implementations, but may be provided informationally. + int64 minor = 2; + } + + // CEL component specifier. + enum Component { + // Unspecified, default. + COMPONENT_UNSPECIFIED = 0; + + // Parser. Converts a CEL string to an AST. + COMPONENT_PARSER = 1; + + // Type checker. Checks that references in an AST are defined and types + // agree. + COMPONENT_TYPE_CHECKER = 2; + + // Runtime. Evaluates a parsed and optionally checked CEL AST against a + // context. + COMPONENT_RUNTIME = 3; + } + + // Identifier for the extension. Example: constant_folding + string id = 1; + + // If set, the listed components must understand the extension for the + // expression to evaluate correctly. + // + // This field has set semantics, repeated values should be deduplicated. + repeated Component affected_components = 2; + + // Version info. May be skipped if it isn't meaningful for the extension. + // (for example constant_folding might always be v0.0). + Version version = 3; + } + + // The syntax version of the source, e.g. `cel1`. + string syntax_version = 1; + + // The location name. All position information attached to an expression is + // relative to this location. + // + // The location could be a file, UI element, or similar. For example, + // `acme/app/AnvilPolicy.cel`. + string location = 2; + + // Monotonically increasing list of code point offsets where newlines + // `\n` appear. + // + // The line number of a given position is the index `i` where for a given + // `id` the `line_offsets[i] < id_positions[id] < line_offsets[i+1]`. The + // column may be derivd from `id_positions[id] - line_offsets[i]`. + repeated int32 line_offsets = 3; + + // A map from the parse node id (e.g. `Expr.id`) to the code point offset + // within the source. + map positions = 4; + + // A map from the parse node id where a macro replacement was made to the + // call `Expr` that resulted in a macro expansion. + // + // For example, `has(value.field)` is a function call that is replaced by a + // `test_only` field selection in the AST. Likewise, the call + // `list.exists(e, e > 10)` translates to a comprehension expression. The key + // in the map corresponds to the expression id of the expanded macro, and the + // value is the call `Expr` that was replaced. + map macro_calls = 5; + + // A list of tags for extensions that were used while parsing or type checking + // the source expression. For example, optimizations that require special + // runtime support may be specified. + // + // These are used to check feature support between components in separate + // implementations. This can be used to either skip redundant work or + // report an error if the extension is unsupported. + repeated Extension extensions = 6; +} + +// A specific position in source. +message SourcePosition { + // The soucre location name (e.g. file name). + string location = 1; + + // The UTF-8 code unit offset. + int32 offset = 2; + + // The 1-based index of the starting line in the source text + // where the issue occurs, or 0 if unknown. + int32 line = 3; + + // The 0-based index of the starting position within the line of source text + // where the issue occurs. Only meaningful if line is nonzero. + int32 column = 4; +} diff --git a/third_party/google/api/expr/v1alpha1/value.proto b/third_party/google/api/expr/v1alpha1/value.proto new file mode 100644 index 00000000..9d695207 --- /dev/null +++ b/third_party/google/api/expr/v1alpha1/value.proto @@ -0,0 +1,115 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api.expr.v1alpha1; + +import "google/protobuf/any.proto"; +import "google/protobuf/struct.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/expr/v1alpha1;expr"; +option java_multiple_files = true; +option java_outer_classname = "ValueProto"; +option java_package = "com.google.api.expr.v1alpha1"; + +// Contains representations for CEL runtime values. + +// Represents a CEL value. +// +// This is similar to `google.protobuf.Value`, but can represent CEL's full +// range of values. +message Value { + // Required. The valid kinds of values. + oneof kind { + // Null value. + google.protobuf.NullValue null_value = 1; + + // Boolean value. + bool bool_value = 2; + + // Signed integer value. + int64 int64_value = 3; + + // Unsigned integer value. + uint64 uint64_value = 4; + + // Floating point value. + double double_value = 5; + + // UTF-8 string value. + string string_value = 6; + + // Byte string value. + bytes bytes_value = 7; + + // An enum value. + EnumValue enum_value = 9; + + // The proto message backing an object value. + google.protobuf.Any object_value = 10; + + // Map value. + MapValue map_value = 11; + + // List value. + ListValue list_value = 12; + + // Type value. + string type_value = 15; + } +} + +// An enum value. +message EnumValue { + // The fully qualified name of the enum type. + string type = 1; + + // The value of the enum. + int32 value = 2; +} + +// A list. +// +// Wrapped in a message so 'not set' and empty can be differentiated, which is +// required for use in a 'oneof'. +message ListValue { + // The ordered values in the list. + repeated Value values = 1; +} + +// A map. +// +// Wrapped in a message so 'not set' and empty can be differentiated, which is +// required for use in a 'oneof'. +message MapValue { + // An entry in the map. + message Entry { + // The key. + // + // Must be unique with in the map. + // Currently only boolean, int, uint, and string values can be keys. + Value key = 1; + + // The value. + Value value = 2; + } + + // The set of map entries. + // + // CEL has fewer restrictions on keys, so a protobuf map represenation + // cannot be used. + repeated Entry entries = 1; +} diff --git a/third_party/google/api/expr/v1beta1/decl.proto b/third_party/google/api/expr/v1beta1/decl.proto new file mode 100644 index 00000000..b433b2df --- /dev/null +++ b/third_party/google/api/expr/v1beta1/decl.proto @@ -0,0 +1,84 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.api.expr.v1beta1; + +import "google/api/expr/v1beta1/expr.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr"; +option java_multiple_files = true; +option java_outer_classname = "DeclProto"; +option java_package = "com.google.api.expr.v1beta1"; + +// A declaration. +message Decl { + // The id of the declaration. + int32 id = 1; + + // The name of the declaration. + string name = 2; + + // The documentation string for the declaration. + string doc = 3; + + // The kind of declaration. + oneof kind { + // An identifier declaration. + IdentDecl ident = 4; + + // A function declaration. + FunctionDecl function = 5; + } +} + +// The declared type of a variable. +// +// Extends runtime type values with extra information used for type checking +// and dispatching. +message DeclType { + // The expression id of the declared type, if applicable. + int32 id = 1; + + // The type name, e.g. 'int', 'my.type.Type' or 'T' + string type = 2; + + // An ordered list of type parameters, e.g. ``. + // Only applies to a subset of types, e.g. `map`, `list`. + repeated DeclType type_params = 4; +} + +// An identifier declaration. +message IdentDecl { + // Optional type of the identifier. + DeclType type = 3; + + // Optional value of the identifier. + Expr value = 4; +} + +// A function declaration. +message FunctionDecl { + // The function arguments. + repeated IdentDecl args = 1; + + // Optional declared return type. + DeclType return_type = 2; + + // If the first argument of the function is the receiver. + bool receiver_function = 3; +} diff --git a/third_party/google/api/expr/v1beta1/eval.proto b/third_party/google/api/expr/v1beta1/eval.proto new file mode 100644 index 00000000..cb8928c3 --- /dev/null +++ b/third_party/google/api/expr/v1beta1/eval.proto @@ -0,0 +1,125 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.api.expr.v1beta1; + +import "google/api/expr/v1beta1/value.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr"; +option java_multiple_files = true; +option java_outer_classname = "EvalProto"; +option java_package = "com.google.api.expr.v1beta1"; + +// The state of an evaluation. +// +// Can represent an initial, partial, or completed state of evaluation. +message EvalState { + // A single evaluation result. + message Result { + // The expression this result is for. + IdRef expr = 1; + + // The index in `values` of the resulting value. + int32 value = 2; + } + + // The unique values referenced in this message. + repeated ExprValue values = 1; + + // An ordered list of results. + // + // Tracks the flow of evaluation through the expression. + // May be sparse. + repeated Result results = 3; +} + +// The value of an evaluated expression. +message ExprValue { + // An expression can resolve to a value, error or unknown. + oneof kind { + // A concrete value. + Value value = 1; + + // The set of errors in the critical path of evalution. + // + // Only errors in the critical path are included. For example, + // `( || true) && ` will only result in ``, + // while ` || ` will result in both `` and + // ``. + // + // Errors cause by the presence of other errors are not included in the + // set. For example `.foo`, `foo()`, and ` + 1` will + // only result in ``. + // + // Multiple errors *might* be included when evaluation could result + // in different errors. For example ` + ` and + // `foo(, )` may result in ``, `` or both. + // The exact subset of errors included for this case is unspecified and + // depends on the implementation details of the evaluator. + ErrorSet error = 2; + + // The set of unknowns in the critical path of evaluation. + // + // Unknown behaves identically to Error with regards to propagation. + // Specifically, only unknowns in the critical path are included, unknowns + // caused by the presence of other unknowns are not included, and multiple + // unknowns *might* be included included when evaluation could result in + // different unknowns. For example: + // + // ( || true) && -> + // || -> + // .foo -> + // foo() -> + // + -> or + // + // Unknown takes precidence over Error in cases where a `Value` can short + // circuit the result: + // + // || -> + // && -> + // + // Errors take precidence in all other cases: + // + // + -> + // foo(, ) -> + UnknownSet unknown = 3; + } +} + +// A set of errors. +// +// The errors included depend on the context. See `ExprValue.error`. +message ErrorSet { + // The errors in the set. + repeated google.rpc.Status errors = 1; +} + +// A set of expressions for which the value is unknown. +// +// The unknowns included depend on the context. See `ExprValue.unknown`. +message UnknownSet { + // The ids of the expressions with unknown values. + repeated IdRef exprs = 1; +} + +// A reference to an expression id. +message IdRef { + // The expression id. + int32 id = 1; +} diff --git a/third_party/google/api/expr/v1beta1/expr.proto b/third_party/google/api/expr/v1beta1/expr.proto new file mode 100644 index 00000000..b20a860c --- /dev/null +++ b/third_party/google/api/expr/v1beta1/expr.proto @@ -0,0 +1,265 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.api.expr.v1beta1; + +import "google/api/expr/v1beta1/source.proto"; +import "google/protobuf/struct.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr"; +option java_multiple_files = true; +option java_outer_classname = "ExprProto"; +option java_package = "com.google.api.expr.v1beta1"; + +// An expression together with source information as returned by the parser. +message ParsedExpr { + // The parsed expression. + Expr expr = 2; + + // The source info derived from input that generated the parsed `expr`. + SourceInfo source_info = 3; + + // The syntax version of the source, e.g. `cel1`. + string syntax_version = 4; +} + +// An abstract representation of a common expression. +// +// Expressions are abstractly represented as a collection of identifiers, +// select statements, function calls, literals, and comprehensions. All +// operators with the exception of the '.' operator are modelled as function +// calls. This makes it easy to represent new operators into the existing AST. +// +// All references within expressions must resolve to a [Decl][google.api.expr.v1beta1.Decl] provided at +// type-check for an expression to be valid. A reference may either be a bare +// identifier `name` or a qualified identifier `google.api.name`. References +// may either refer to a value or a function declaration. +// +// For example, the expression `google.api.name.startsWith('expr')` references +// the declaration `google.api.name` within a [Expr.Select][google.api.expr.v1beta1.Expr.Select] expression, and +// the function declaration `startsWith`. +message Expr { + // An identifier expression. e.g. `request`. + message Ident { + // Required. Holds a single, unqualified identifier, possibly preceded by a + // '.'. + // + // Qualified names are represented by the [Expr.Select][google.api.expr.v1beta1.Expr.Select] expression. + string name = 1; + } + + // A field selection expression. e.g. `request.auth`. + message Select { + // Required. The target of the selection expression. + // + // For example, in the select expression `request.auth`, the `request` + // portion of the expression is the `operand`. + Expr operand = 1; + + // Required. The name of the field to select. + // + // For example, in the select expression `request.auth`, the `auth` portion + // of the expression would be the `field`. + string field = 2; + + // Whether the select is to be interpreted as a field presence test. + // + // This results from the macro `has(request.auth)`. + bool test_only = 3; + } + + // A call expression, including calls to predefined functions and operators. + // + // For example, `value == 10`, `size(map_value)`. + message Call { + // The target of an method call-style expression. For example, `x` in + // `x.f()`. + Expr target = 1; + + // Required. The name of the function or method being called. + string function = 2; + + // The arguments. + repeated Expr args = 3; + } + + // A list creation expression. + // + // Lists may either be homogenous, e.g. `[1, 2, 3]`, or heterogenous, e.g. + // `dyn([1, 'hello', 2.0])` + message CreateList { + // The elements part of the list. + repeated Expr elements = 1; + } + + // A map or message creation expression. + // + // Maps are constructed as `{'key_name': 'value'}`. Message construction is + // similar, but prefixed with a type name and composed of field ids: + // `types.MyType{field_id: 'value'}`. + message CreateStruct { + // Represents an entry. + message Entry { + // Required. An id assigned to this node by the parser which is unique + // in a given expression tree. This is used to associate type + // information and other attributes to the node. + int32 id = 1; + + // The `Entry` key kinds. + oneof key_kind { + // The field key for a message creator statement. + string field_key = 2; + + // The key expression for a map creation statement. + Expr map_key = 3; + } + + // Required. The value assigned to the key. + Expr value = 4; + } + + // The type name of the message to be created, empty when creating map + // literals. + string type = 1; + + // The entries in the creation expression. + repeated Entry entries = 2; + } + + // A comprehension expression applied to a list or map. + // + // Comprehensions are not part of the core syntax, but enabled with macros. + // A macro matches a specific call signature within a parsed AST and replaces + // the call with an alternate AST block. Macro expansion happens at parse + // time. + // + // The following macros are supported within CEL: + // + // Aggregate type macros may be applied to all elements in a list or all keys + // in a map: + // + // * `all`, `exists`, `exists_one` - test a predicate expression against + // the inputs and return `true` if the predicate is satisfied for all, + // any, or only one value `list.all(x, x < 10)`. + // * `filter` - test a predicate expression against the inputs and return + // the subset of elements which satisfy the predicate: + // `payments.filter(p, p > 1000)`. + // * `map` - apply an expression to all elements in the input and return the + // output aggregate type: `[1, 2, 3].map(i, i * i)`. + // + // The `has(m.x)` macro tests whether the property `x` is present in struct + // `m`. The semantics of this macro depend on the type of `m`. For proto2 + // messages `has(m.x)` is defined as 'defined, but not set`. For proto3, the + // macro tests whether the property is set to its default. For map and struct + // types, the macro tests whether the property `x` is defined on `m`. + message Comprehension { + // The name of the iteration variable. + string iter_var = 1; + + // The range over which var iterates. + Expr iter_range = 2; + + // The name of the variable used for accumulation of the result. + string accu_var = 3; + + // The initial value of the accumulator. + Expr accu_init = 4; + + // An expression which can contain iter_var and accu_var. + // + // Returns false when the result has been computed and may be used as + // a hint to short-circuit the remainder of the comprehension. + Expr loop_condition = 5; + + // An expression which can contain iter_var and accu_var. + // + // Computes the next value of accu_var. + Expr loop_step = 6; + + // An expression which can contain accu_var. + // + // Computes the result. + Expr result = 7; + } + + // Required. An id assigned to this node by the parser which is unique in a + // given expression tree. This is used to associate type information and other + // attributes to a node in the parse tree. + int32 id = 2; + + // Required. Variants of expressions. + oneof expr_kind { + // A literal expression. + Literal literal_expr = 3; + + // An identifier expression. + Ident ident_expr = 4; + + // A field selection expression, e.g. `request.auth`. + Select select_expr = 5; + + // A call expression, including calls to predefined functions and operators. + Call call_expr = 6; + + // A list creation expression. + CreateList list_expr = 7; + + // A map or object creation expression. + CreateStruct struct_expr = 8; + + // A comprehension expression. + Comprehension comprehension_expr = 9; + } +} + +// Represents a primitive literal. +// +// This is similar to the primitives supported in the well-known type +// `google.protobuf.Value`, but richer so it can represent CEL's full range of +// primitives. +// +// Lists and structs are not included as constants as these aggregate types may +// contain [Expr][google.api.expr.v1beta1.Expr] elements which require evaluation and are thus not constant. +// +// Examples of literals include: `"hello"`, `b'bytes'`, `1u`, `4.2`, `-2`, +// `true`, `null`. +message Literal { + // Required. The valid constant kinds. + oneof constant_kind { + // null value. + google.protobuf.NullValue null_value = 1; + + // boolean value. + bool bool_value = 2; + + // int64 value. + int64 int64_value = 3; + + // uint64 value. + uint64 uint64_value = 4; + + // double value. + double double_value = 5; + + // string value. + string string_value = 6; + + // bytes value. + bytes bytes_value = 7; + } +} diff --git a/third_party/google/api/expr/v1beta1/source.proto b/third_party/google/api/expr/v1beta1/source.proto new file mode 100644 index 00000000..fdf173ba --- /dev/null +++ b/third_party/google/api/expr/v1beta1/source.proto @@ -0,0 +1,62 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.api.expr.v1beta1; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr"; +option java_multiple_files = true; +option java_outer_classname = "SourceProto"; +option java_package = "com.google.api.expr.v1beta1"; + +// Source information collected at parse time. +message SourceInfo { + // The location name. All position information attached to an expression is + // relative to this location. + // + // The location could be a file, UI element, or similar. For example, + // `acme/app/AnvilPolicy.cel`. + string location = 2; + + // Monotonically increasing list of character offsets where newlines appear. + // + // The line number of a given position is the index `i` where for a given + // `id` the `line_offsets[i] < id_positions[id] < line_offsets[i+1]`. The + // column may be derivd from `id_positions[id] - line_offsets[i]`. + repeated int32 line_offsets = 3; + + // A map from the parse node id (e.g. `Expr.id`) to the character offset + // within source. + map positions = 4; +} + +// A specific position in source. +message SourcePosition { + // The soucre location name (e.g. file name). + string location = 1; + + // The character offset. + int32 offset = 2; + + // The 1-based index of the starting line in the source text + // where the issue occurs, or 0 if unknown. + int32 line = 3; + + // The 0-based index of the starting position within the line of source text + // where the issue occurs. Only meaningful if line is nonzer.. + int32 column = 4; +} diff --git a/third_party/google/api/expr/v1beta1/value.proto b/third_party/google/api/expr/v1beta1/value.proto new file mode 100644 index 00000000..098e92e3 --- /dev/null +++ b/third_party/google/api/expr/v1beta1/value.proto @@ -0,0 +1,114 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.api.expr.v1beta1; + +import "google/protobuf/any.proto"; +import "google/protobuf/struct.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/api/expr/v1beta1;expr"; +option java_multiple_files = true; +option java_outer_classname = "ValueProto"; +option java_package = "com.google.api.expr.v1beta1"; + +// Represents a CEL value. +// +// This is similar to `google.protobuf.Value`, but can represent CEL's full +// range of values. +message Value { + // Required. The valid kinds of values. + oneof kind { + // Null value. + google.protobuf.NullValue null_value = 1; + + // Boolean value. + bool bool_value = 2; + + // Signed integer value. + int64 int64_value = 3; + + // Unsigned integer value. + uint64 uint64_value = 4; + + // Floating point value. + double double_value = 5; + + // UTF-8 string value. + string string_value = 6; + + // Byte string value. + bytes bytes_value = 7; + + // An enum value. + EnumValue enum_value = 9; + + // The proto message backing an object value. + google.protobuf.Any object_value = 10; + + // Map value. + MapValue map_value = 11; + + // List value. + ListValue list_value = 12; + + // A Type value represented by the fully qualified name of the type. + string type_value = 15; + } +} + +// An enum value. +message EnumValue { + // The fully qualified name of the enum type. + string type = 1; + + // The value of the enum. + int32 value = 2; +} + +// A list. +// +// Wrapped in a message so 'not set' and empty can be differentiated, which is +// required for use in a 'oneof'. +message ListValue { + // The ordered values in the list. + repeated Value values = 1; +} + +// A map. +// +// Wrapped in a message so 'not set' and empty can be differentiated, which is +// required for use in a 'oneof'. +message MapValue { + // An entry in the map. + message Entry { + // The key. + // + // Must be unique with in the map. + // Currently only boolean, int, uint, and string values can be keys. + Value key = 1; + + // The value. + Value value = 2; + } + + // The set of map entries. + // + // CEL has fewer restrictions on keys, so a protobuf map represenation + // cannot be used. + repeated Entry entries = 1; +} diff --git a/third_party/google/api/field_behavior.proto b/third_party/google/api/field_behavior.proto new file mode 100644 index 00000000..1fdaaed1 --- /dev/null +++ b/third_party/google/api/field_behavior.proto @@ -0,0 +1,104 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "FieldBehaviorProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.FieldOptions { + // A designation of a specific field behavior (required, output only, etc.) + // in protobuf messages. + // + // Examples: + // + // string name = 1 [(google.api.field_behavior) = REQUIRED]; + // State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + // google.protobuf.Duration ttl = 1 + // [(google.api.field_behavior) = INPUT_ONLY]; + // google.protobuf.Timestamp expire_time = 1 + // [(google.api.field_behavior) = OUTPUT_ONLY, + // (google.api.field_behavior) = IMMUTABLE]; + repeated google.api.FieldBehavior field_behavior = 1052 [packed = false]; +} + +// An indicator of the behavior of a given field (for example, that a field +// is required in requests, or given as output but ignored as input). +// This **does not** change the behavior in protocol buffers itself; it only +// denotes the behavior and may affect how API tooling handles the field. +// +// Note: This enum **may** receive new values in the future. +enum FieldBehavior { + // Conventional default for enums. Do not use this. + FIELD_BEHAVIOR_UNSPECIFIED = 0; + + // Specifically denotes a field as optional. + // While all fields in protocol buffers are optional, this may be specified + // for emphasis if appropriate. + OPTIONAL = 1; + + // Denotes a field as required. + // This indicates that the field **must** be provided as part of the request, + // and failure to do so will cause an error (usually `INVALID_ARGUMENT`). + REQUIRED = 2; + + // Denotes a field as output only. + // This indicates that the field is provided in responses, but including the + // field in a request does nothing (the server *must* ignore it and + // *must not* throw an error as a result of the field's presence). + OUTPUT_ONLY = 3; + + // Denotes a field as input only. + // This indicates that the field is provided in requests, and the + // corresponding field is not included in output. + INPUT_ONLY = 4; + + // Denotes a field as immutable. + // This indicates that the field may be set once in a request to create a + // resource, but may not be changed thereafter. + IMMUTABLE = 5; + + // Denotes that a (repeated) field is an unordered list. + // This indicates that the service may provide the elements of the list + // in any arbitrary order, rather than the order the user originally + // provided. Additionally, the list's order may or may not be stable. + UNORDERED_LIST = 6; + + // Denotes that this field returns a non-empty default value if not set. + // This indicates that if the user provides the empty value in a request, + // a non-empty value will be returned. The user will not be aware of what + // non-empty value to expect. + NON_EMPTY_DEFAULT = 7; + + // Denotes that the field in a resource (a message annotated with + // google.api.resource) is used in the resource name to uniquely identify the + // resource. For AIP-compliant APIs, this should only be applied to the + // `name` field on the resource. + // + // This behavior should not be applied to references to other resources within + // the message. + // + // The identifier field of resources often have different field behavior + // depending on the request it is embedded in (e.g. for Create methods name + // is optional and unused, while for Update methods it is required). Instead + // of method-specific annotations, only `IDENTIFIER` is required. + IDENTIFIER = 8; +} diff --git a/third_party/google/api/field_info.proto b/third_party/google/api/field_info.proto new file mode 100644 index 00000000..aaa07a18 --- /dev/null +++ b/third_party/google/api/field_info.proto @@ -0,0 +1,106 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "FieldInfoProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.FieldOptions { + // Rich semantic descriptor of an API field beyond the basic typing. + // + // Examples: + // + // string request_id = 1 [(google.api.field_info).format = UUID4]; + // string old_ip_address = 2 [(google.api.field_info).format = IPV4]; + // string new_ip_address = 3 [(google.api.field_info).format = IPV6]; + // string actual_ip_address = 4 [ + // (google.api.field_info).format = IPV4_OR_IPV6 + // ]; + // google.protobuf.Any generic_field = 5 [ + // (google.api.field_info).referenced_types = {type_name: "ActualType"}, + // (google.api.field_info).referenced_types = {type_name: "OtherType"}, + // ]; + // google.protobuf.Any generic_user_input = 5 [ + // (google.api.field_info).referenced_types = {type_name: "*"}, + // ]; + google.api.FieldInfo field_info = 291403980; +} + +// Rich semantic information of an API field beyond basic typing. +message FieldInfo { + // The standard format of a field value. The supported formats are all backed + // by either an RFC defined by the IETF or a Google-defined AIP. + enum Format { + // Default, unspecified value. + FORMAT_UNSPECIFIED = 0; + + // Universally Unique Identifier, version 4, value as defined by + // https://datatracker.ietf.org/doc/html/rfc4122. The value may be + // normalized to entirely lowercase letters. For example, the value + // `F47AC10B-58CC-0372-8567-0E02B2C3D479` would be normalized to + // `f47ac10b-58cc-0372-8567-0e02b2c3d479`. + UUID4 = 1; + + // Internet Protocol v4 value as defined by [RFC + // 791](https://datatracker.ietf.org/doc/html/rfc791). The value may be + // condensed, with leading zeros in each octet stripped. For example, + // `001.022.233.040` would be condensed to `1.22.233.40`. + IPV4 = 2; + + // Internet Protocol v6 value as defined by [RFC + // 2460](https://datatracker.ietf.org/doc/html/rfc2460). The value may be + // normalized to entirely lowercase letters with zeros compressed, following + // [RFC 5952](https://datatracker.ietf.org/doc/html/rfc5952). For example, + // the value `2001:0DB8:0::0` would be normalized to `2001:db8::`. + IPV6 = 3; + + // An IP address in either v4 or v6 format as described by the individual + // values defined herein. See the comments on the IPV4 and IPV6 types for + // allowed normalizations of each. + IPV4_OR_IPV6 = 4; + } + + // The standard format of a field value. This does not explicitly configure + // any API consumer, just documents the API's format for the field it is + // applied to. + Format format = 1; + + // The type(s) that the annotated, generic field may represent. + // + // Currently, this must only be used on fields of type `google.protobuf.Any`. + // Supporting other generic types may be considered in the future. + repeated TypeReference referenced_types = 2; +} + +// A reference to a message type, for use in [FieldInfo][google.api.FieldInfo]. +message TypeReference { + // The name of the type that the annotated, generic field may represent. + // If the type is in the same protobuf package, the value can be the simple + // message name e.g., `"MyMessage"`. Otherwise, the value must be the + // fully-qualified message name e.g., `"google.library.v1.Book"`. + // + // If the type(s) are unknown to the service (e.g. the field accepts generic + // user input), use the wildcard `"*"` to denote this behavior. + // + // See [AIP-202](https://google.aip.dev/202#type-references) for more details. + string type_name = 1; +} diff --git a/third_party/google/api/http.proto b/third_party/google/api/http.proto new file mode 100644 index 00000000..57621b53 --- /dev/null +++ b/third_party/google/api/http.proto @@ -0,0 +1,370 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "HttpProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// Defines the HTTP configuration for an API service. It contains a list of +// [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method +// to one or more HTTP REST API methods. +message Http { + // A list of HTTP configuration rules that apply to individual API methods. + // + // **NOTE:** All service configuration rules follow "last one wins" order. + repeated HttpRule rules = 1; + + // When set to true, URL path parameters will be fully URI-decoded except in + // cases of single segment matches in reserved expansion, where "%2F" will be + // left encoded. + // + // The default behavior is to not decode RFC 6570 reserved characters in multi + // segment matches. + bool fully_decode_reserved_expansion = 2; +} + +// gRPC Transcoding +// +// gRPC Transcoding is a feature for mapping between a gRPC method and one or +// more HTTP REST endpoints. It allows developers to build a single API service +// that supports both gRPC APIs and REST APIs. Many systems, including [Google +// APIs](https://github.com/googleapis/googleapis), +// [Cloud Endpoints](https://cloud.google.com/endpoints), [gRPC +// Gateway](https://github.com/grpc-ecosystem/grpc-gateway), +// and [Envoy](https://github.com/envoyproxy/envoy) proxy support this feature +// and use it for large scale production services. +// +// `HttpRule` defines the schema of the gRPC/REST mapping. The mapping specifies +// how different portions of the gRPC request message are mapped to the URL +// path, URL query parameters, and HTTP request body. It also controls how the +// gRPC response message is mapped to the HTTP response body. `HttpRule` is +// typically specified as an `google.api.http` annotation on the gRPC method. +// +// Each mapping specifies a URL path template and an HTTP method. The path +// template may refer to one or more fields in the gRPC request message, as long +// as each field is a non-repeated field with a primitive (non-message) type. +// The path template controls how fields of the request message are mapped to +// the URL path. +// +// Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/{name=messages/*}" +// }; +// } +// } +// message GetMessageRequest { +// string name = 1; // Mapped to URL path. +// } +// message Message { +// string text = 1; // The resource content. +// } +// +// This enables an HTTP REST to gRPC mapping as below: +// +// - HTTP: `GET /v1/messages/123456` +// - gRPC: `GetMessage(name: "messages/123456")` +// +// Any fields in the request message which are not bound by the path template +// automatically become HTTP query parameters if there is no HTTP request body. +// For example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get:"/v1/messages/{message_id}" +// }; +// } +// } +// message GetMessageRequest { +// message SubMessage { +// string subfield = 1; +// } +// string message_id = 1; // Mapped to URL path. +// int64 revision = 2; // Mapped to URL query parameter `revision`. +// SubMessage sub = 3; // Mapped to URL query parameter `sub.subfield`. +// } +// +// This enables a HTTP JSON to RPC mapping as below: +// +// - HTTP: `GET /v1/messages/123456?revision=2&sub.subfield=foo` +// - gRPC: `GetMessage(message_id: "123456" revision: 2 sub: +// SubMessage(subfield: "foo"))` +// +// Note that fields which are mapped to URL query parameters must have a +// primitive type or a repeated primitive type or a non-repeated message type. +// In the case of a repeated type, the parameter can be repeated in the URL +// as `...?param=A¶m=B`. In the case of a message type, each field of the +// message is mapped to a separate parameter, such as +// `...?foo.a=A&foo.b=B&foo.c=C`. +// +// For HTTP methods that allow a request body, the `body` field +// specifies the mapping. Consider a REST update method on the +// message resource collection: +// +// service Messaging { +// rpc UpdateMessage(UpdateMessageRequest) returns (Message) { +// option (google.api.http) = { +// patch: "/v1/messages/{message_id}" +// body: "message" +// }; +// } +// } +// message UpdateMessageRequest { +// string message_id = 1; // mapped to the URL +// Message message = 2; // mapped to the body +// } +// +// The following HTTP JSON to RPC mapping is enabled, where the +// representation of the JSON in the request body is determined by +// protos JSON encoding: +// +// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` +// - gRPC: `UpdateMessage(message_id: "123456" message { text: "Hi!" })` +// +// The special name `*` can be used in the body mapping to define that +// every field not bound by the path template should be mapped to the +// request body. This enables the following alternative definition of +// the update method: +// +// service Messaging { +// rpc UpdateMessage(Message) returns (Message) { +// option (google.api.http) = { +// patch: "/v1/messages/{message_id}" +// body: "*" +// }; +// } +// } +// message Message { +// string message_id = 1; +// string text = 2; +// } +// +// +// The following HTTP JSON to RPC mapping is enabled: +// +// - HTTP: `PATCH /v1/messages/123456 { "text": "Hi!" }` +// - gRPC: `UpdateMessage(message_id: "123456" text: "Hi!")` +// +// Note that when using `*` in the body mapping, it is not possible to +// have HTTP parameters, as all fields not bound by the path end in +// the body. This makes this option more rarely used in practice when +// defining REST APIs. The common usage of `*` is in custom methods +// which don't use the URL at all for transferring data. +// +// It is possible to define multiple HTTP methods for one RPC by using +// the `additional_bindings` option. Example: +// +// service Messaging { +// rpc GetMessage(GetMessageRequest) returns (Message) { +// option (google.api.http) = { +// get: "/v1/messages/{message_id}" +// additional_bindings { +// get: "/v1/users/{user_id}/messages/{message_id}" +// } +// }; +// } +// } +// message GetMessageRequest { +// string message_id = 1; +// string user_id = 2; +// } +// +// This enables the following two alternative HTTP JSON to RPC mappings: +// +// - HTTP: `GET /v1/messages/123456` +// - gRPC: `GetMessage(message_id: "123456")` +// +// - HTTP: `GET /v1/users/me/messages/123456` +// - gRPC: `GetMessage(user_id: "me" message_id: "123456")` +// +// Rules for HTTP mapping +// +// 1. Leaf request fields (recursive expansion nested messages in the request +// message) are classified into three categories: +// - Fields referred by the path template. They are passed via the URL path. +// - Fields referred by the [HttpRule.body][google.api.HttpRule.body]. They +// are passed via the HTTP +// request body. +// - All other fields are passed via the URL query parameters, and the +// parameter name is the field path in the request message. A repeated +// field can be represented as multiple query parameters under the same +// name. +// 2. If [HttpRule.body][google.api.HttpRule.body] is "*", there is no URL +// query parameter, all fields +// are passed via URL path and HTTP request body. +// 3. If [HttpRule.body][google.api.HttpRule.body] is omitted, there is no HTTP +// request body, all +// fields are passed via URL path and URL query parameters. +// +// Path template syntax +// +// Template = "/" Segments [ Verb ] ; +// Segments = Segment { "/" Segment } ; +// Segment = "*" | "**" | LITERAL | Variable ; +// Variable = "{" FieldPath [ "=" Segments ] "}" ; +// FieldPath = IDENT { "." IDENT } ; +// Verb = ":" LITERAL ; +// +// The syntax `*` matches a single URL path segment. The syntax `**` matches +// zero or more URL path segments, which must be the last part of the URL path +// except the `Verb`. +// +// The syntax `Variable` matches part of the URL path as specified by its +// template. A variable template must not contain other variables. If a variable +// matches a single path segment, its template may be omitted, e.g. `{var}` +// is equivalent to `{var=*}`. +// +// The syntax `LITERAL` matches literal text in the URL path. If the `LITERAL` +// contains any reserved character, such characters should be percent-encoded +// before the matching. +// +// If a variable contains exactly one path segment, such as `"{var}"` or +// `"{var=*}"`, when such a variable is expanded into a URL path on the client +// side, all characters except `[-_.~0-9a-zA-Z]` are percent-encoded. The +// server side does the reverse decoding. Such variables show up in the +// [Discovery +// Document](https://developers.google.com/discovery/v1/reference/apis) as +// `{var}`. +// +// If a variable contains multiple path segments, such as `"{var=foo/*}"` +// or `"{var=**}"`, when such a variable is expanded into a URL path on the +// client side, all characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. +// The server side does the reverse decoding, except "%2F" and "%2f" are left +// unchanged. Such variables show up in the +// [Discovery +// Document](https://developers.google.com/discovery/v1/reference/apis) as +// `{+var}`. +// +// Using gRPC API Service Configuration +// +// gRPC API Service Configuration (service config) is a configuration language +// for configuring a gRPC service to become a user-facing product. The +// service config is simply the YAML representation of the `google.api.Service` +// proto message. +// +// As an alternative to annotating your proto file, you can configure gRPC +// transcoding in your service config YAML files. You do this by specifying a +// `HttpRule` that maps the gRPC method to a REST endpoint, achieving the same +// effect as the proto annotation. This can be particularly useful if you +// have a proto that is reused in multiple services. Note that any transcoding +// specified in the service config will override any matching transcoding +// configuration in the proto. +// +// The following example selects a gRPC method and applies an `HttpRule` to it: +// +// http: +// rules: +// - selector: example.v1.Messaging.GetMessage +// get: /v1/messages/{message_id}/{sub.subfield} +// +// Special notes +// +// When gRPC Transcoding is used to map a gRPC to JSON REST endpoints, the +// proto to JSON conversion must follow the [proto3 +// specification](https://developers.google.com/protocol-buffers/docs/proto3#json). +// +// While the single segment variable follows the semantics of +// [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String +// Expansion, the multi segment variable **does not** follow RFC 6570 Section +// 3.2.3 Reserved Expansion. The reason is that the Reserved Expansion +// does not expand special characters like `?` and `#`, which would lead +// to invalid URLs. As the result, gRPC Transcoding uses a custom encoding +// for multi segment variables. +// +// The path variables **must not** refer to any repeated or mapped field, +// because client libraries are not capable of handling such variable expansion. +// +// The path variables **must not** capture the leading "/" character. The reason +// is that the most common use case "{var}" does not capture the leading "/" +// character. For consistency, all path variables must share the same behavior. +// +// Repeated message fields must not be mapped to URL query parameters, because +// no client library can support such complicated mapping. +// +// If an API needs to use a JSON array for request or response body, it can map +// the request or response body to a repeated field. However, some gRPC +// Transcoding implementations may not support this feature. +message HttpRule { + // Selects a method to which this rule applies. + // + // Refer to [selector][google.api.DocumentationRule.selector] for syntax + // details. + string selector = 1; + + // Determines the URL pattern is matched by this rules. This pattern can be + // used with any of the {get|put|post|delete|patch} methods. A custom method + // can be defined using the 'custom' field. + oneof pattern { + // Maps to HTTP GET. Used for listing and getting information about + // resources. + string get = 2; + + // Maps to HTTP PUT. Used for replacing a resource. + string put = 3; + + // Maps to HTTP POST. Used for creating a resource or performing an action. + string post = 4; + + // Maps to HTTP DELETE. Used for deleting a resource. + string delete = 5; + + // Maps to HTTP PATCH. Used for updating a resource. + string patch = 6; + + // The custom pattern is used for specifying an HTTP method that is not + // included in the `pattern` field, such as HEAD, or "*" to leave the + // HTTP method unspecified for this rule. The wild-card rule is useful + // for services that provide content to Web (HTML) clients. + CustomHttpPattern custom = 8; + } + + // The name of the request field whose value is mapped to the HTTP request + // body, or `*` for mapping all request fields not captured by the path + // pattern to the HTTP body, or omitted for not having any HTTP request body. + // + // NOTE: the referred field must be present at the top-level of the request + // message type. + string body = 7; + + // Optional. The name of the response field whose value is mapped to the HTTP + // response body. When omitted, the entire response message will be used + // as the HTTP response body. + // + // NOTE: The referred field must be present at the top-level of the response + // message type. + string response_body = 12; + + // Additional HTTP bindings for the selector. Nested bindings must + // not contain an `additional_bindings` field themselves (that is, + // the nesting may only be one level deep). + repeated HttpRule additional_bindings = 11; +} + +// A custom pattern is used for defining custom HTTP verb. +message CustomHttpPattern { + // The name of this custom HTTP verb. + string kind = 1; + + // The path matched by this custom verb. + string path = 2; +} diff --git a/third_party/google/api/httpbody.proto b/third_party/google/api/httpbody.proto new file mode 100644 index 00000000..e3e17c8a --- /dev/null +++ b/third_party/google/api/httpbody.proto @@ -0,0 +1,80 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/any.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/httpbody;httpbody"; +option java_multiple_files = true; +option java_outer_classname = "HttpBodyProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// Message that represents an arbitrary HTTP body. It should only be used for +// payload formats that can't be represented as JSON, such as raw binary or +// an HTML page. +// +// +// This message can be used both in streaming and non-streaming API methods in +// the request as well as the response. +// +// It can be used as a top-level request field, which is convenient if one +// wants to extract parameters from either the URL or HTTP template into the +// request fields and also want access to the raw HTTP body. +// +// Example: +// +// message GetResourceRequest { +// // A unique request id. +// string request_id = 1; +// +// // The raw HTTP body is bound to this field. +// google.api.HttpBody http_body = 2; +// +// } +// +// service ResourceService { +// rpc GetResource(GetResourceRequest) +// returns (google.api.HttpBody); +// rpc UpdateResource(google.api.HttpBody) +// returns (google.protobuf.Empty); +// +// } +// +// Example with streaming methods: +// +// service CaldavService { +// rpc GetCalendar(stream google.api.HttpBody) +// returns (stream google.api.HttpBody); +// rpc UpdateCalendar(stream google.api.HttpBody) +// returns (stream google.api.HttpBody); +// +// } +// +// Use of this type only changes how the request and response bodies are +// handled, all other features will continue to work unchanged. +message HttpBody { + // The HTTP Content-Type header value specifying the content type of the body. + string content_type = 1; + + // The HTTP request/response body as raw binary. + bytes data = 2; + + // Application specific response metadata. Must be set in the first response + // for streaming APIs. + repeated google.protobuf.Any extensions = 3; +} diff --git a/third_party/google/api/launch_stage.proto b/third_party/google/api/launch_stage.proto new file mode 100644 index 00000000..1e86c1ad --- /dev/null +++ b/third_party/google/api/launch_stage.proto @@ -0,0 +1,72 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +option go_package = "google.golang.org/genproto/googleapis/api;api"; +option java_multiple_files = true; +option java_outer_classname = "LaunchStageProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +// The launch stage as defined by [Google Cloud Platform +// Launch Stages](https://cloud.google.com/terms/launch-stages). +enum LaunchStage { + // Do not use this default value. + LAUNCH_STAGE_UNSPECIFIED = 0; + + // The feature is not yet implemented. Users can not use it. + UNIMPLEMENTED = 6; + + // Prelaunch features are hidden from users and are only visible internally. + PRELAUNCH = 7; + + // Early Access features are limited to a closed group of testers. To use + // these features, you must sign up in advance and sign a Trusted Tester + // agreement (which includes confidentiality provisions). These features may + // be unstable, changed in backward-incompatible ways, and are not + // guaranteed to be released. + EARLY_ACCESS = 1; + + // Alpha is a limited availability test for releases before they are cleared + // for widespread use. By Alpha, all significant design issues are resolved + // and we are in the process of verifying functionality. Alpha customers + // need to apply for access, agree to applicable terms, and have their + // projects allowlisted. Alpha releases don't have to be feature complete, + // no SLAs are provided, and there are no technical support obligations, but + // they will be far enough along that customers can actually use them in + // test environments or for limited-use tests -- just like they would in + // normal production cases. + ALPHA = 2; + + // Beta is the point at which we are ready to open a release for any + // customer to use. There are no SLA or technical support obligations in a + // Beta release. Products will be complete from a feature perspective, but + // may have some open outstanding issues. Beta releases are suitable for + // limited production use cases. + BETA = 3; + + // GA features are open to all developers and are considered stable and + // fully qualified for production use. + GA = 4; + + // Deprecated features are scheduled to be shut down and removed. For more + // information, see the "Deprecation Policy" section of our [Terms of + // Service](https://cloud.google.com/terms/) + // and the [Google Cloud Platform Subject to the Deprecation + // Policy](https://cloud.google.com/terms/deprecation) documentation. + DEPRECATED = 5; +} diff --git a/third_party/google/api/resource.proto b/third_party/google/api/resource.proto new file mode 100644 index 00000000..5669cbc9 --- /dev/null +++ b/third_party/google/api/resource.proto @@ -0,0 +1,242 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "ResourceProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.FieldOptions { + // An annotation that describes a resource reference, see + // [ResourceReference][]. + google.api.ResourceReference resource_reference = 1055; +} + +extend google.protobuf.FileOptions { + // An annotation that describes a resource definition without a corresponding + // message; see [ResourceDescriptor][]. + repeated google.api.ResourceDescriptor resource_definition = 1053; +} + +extend google.protobuf.MessageOptions { + // An annotation that describes a resource definition, see + // [ResourceDescriptor][]. + google.api.ResourceDescriptor resource = 1053; +} + +// A simple descriptor of a resource type. +// +// ResourceDescriptor annotates a resource message (either by means of a +// protobuf annotation or use in the service config), and associates the +// resource's schema, the resource type, and the pattern of the resource name. +// +// Example: +// +// message Topic { +// // Indicates this message defines a resource schema. +// // Declares the resource type in the format of {service}/{kind}. +// // For Kubernetes resources, the format is {api group}/{kind}. +// option (google.api.resource) = { +// type: "pubsub.googleapis.com/Topic" +// pattern: "projects/{project}/topics/{topic}" +// }; +// } +// +// The ResourceDescriptor Yaml config will look like: +// +// resources: +// - type: "pubsub.googleapis.com/Topic" +// pattern: "projects/{project}/topics/{topic}" +// +// Sometimes, resources have multiple patterns, typically because they can +// live under multiple parents. +// +// Example: +// +// message LogEntry { +// option (google.api.resource) = { +// type: "logging.googleapis.com/LogEntry" +// pattern: "projects/{project}/logs/{log}" +// pattern: "folders/{folder}/logs/{log}" +// pattern: "organizations/{organization}/logs/{log}" +// pattern: "billingAccounts/{billing_account}/logs/{log}" +// }; +// } +// +// The ResourceDescriptor Yaml config will look like: +// +// resources: +// - type: 'logging.googleapis.com/LogEntry' +// pattern: "projects/{project}/logs/{log}" +// pattern: "folders/{folder}/logs/{log}" +// pattern: "organizations/{organization}/logs/{log}" +// pattern: "billingAccounts/{billing_account}/logs/{log}" +message ResourceDescriptor { + // A description of the historical or future-looking state of the + // resource pattern. + enum History { + // The "unset" value. + HISTORY_UNSPECIFIED = 0; + + // The resource originally had one pattern and launched as such, and + // additional patterns were added later. + ORIGINALLY_SINGLE_PATTERN = 1; + + // The resource has one pattern, but the API owner expects to add more + // later. (This is the inverse of ORIGINALLY_SINGLE_PATTERN, and prevents + // that from being necessary once there are multiple patterns.) + FUTURE_MULTI_PATTERN = 2; + } + + // A flag representing a specific style that a resource claims to conform to. + enum Style { + // The unspecified value. Do not use. + STYLE_UNSPECIFIED = 0; + + // This resource is intended to be "declarative-friendly". + // + // Declarative-friendly resources must be more strictly consistent, and + // setting this to true communicates to tools that this resource should + // adhere to declarative-friendly expectations. + // + // Note: This is used by the API linter (linter.aip.dev) to enable + // additional checks. + DECLARATIVE_FRIENDLY = 1; + } + + // The resource type. It must be in the format of + // {service_name}/{resource_type_kind}. The `resource_type_kind` must be + // singular and must not include version numbers. + // + // Example: `storage.googleapis.com/Bucket` + // + // The value of the resource_type_kind must follow the regular expression + // /[A-Za-z][a-zA-Z0-9]+/. It should start with an upper case character and + // should use PascalCase (UpperCamelCase). The maximum number of + // characters allowed for the `resource_type_kind` is 100. + string type = 1; + + // Optional. The relative resource name pattern associated with this resource + // type. The DNS prefix of the full resource name shouldn't be specified here. + // + // The path pattern must follow the syntax, which aligns with HTTP binding + // syntax: + // + // Template = Segment { "/" Segment } ; + // Segment = LITERAL | Variable ; + // Variable = "{" LITERAL "}" ; + // + // Examples: + // + // - "projects/{project}/topics/{topic}" + // - "projects/{project}/knowledgeBases/{knowledge_base}" + // + // The components in braces correspond to the IDs for each resource in the + // hierarchy. It is expected that, if multiple patterns are provided, + // the same component name (e.g. "project") refers to IDs of the same + // type of resource. + repeated string pattern = 2; + + // Optional. The field on the resource that designates the resource name + // field. If omitted, this is assumed to be "name". + string name_field = 3; + + // Optional. The historical or future-looking state of the resource pattern. + // + // Example: + // + // // The InspectTemplate message originally only supported resource + // // names with organization, and project was added later. + // message InspectTemplate { + // option (google.api.resource) = { + // type: "dlp.googleapis.com/InspectTemplate" + // pattern: + // "organizations/{organization}/inspectTemplates/{inspect_template}" + // pattern: "projects/{project}/inspectTemplates/{inspect_template}" + // history: ORIGINALLY_SINGLE_PATTERN + // }; + // } + History history = 4; + + // The plural name used in the resource name and permission names, such as + // 'projects' for the resource name of 'projects/{project}' and the permission + // name of 'cloudresourcemanager.googleapis.com/projects.get'. One exception + // to this is for Nested Collections that have stuttering names, as defined + // in [AIP-122](https://google.aip.dev/122#nested-collections), where the + // collection ID in the resource name pattern does not necessarily directly + // match the `plural` value. + // + // It is the same concept of the `plural` field in k8s CRD spec + // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + // + // Note: The plural form is required even for singleton resources. See + // https://aip.dev/156 + string plural = 5; + + // The same concept of the `singular` field in k8s CRD spec + // https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/ + // Such as "project" for the `resourcemanager.googleapis.com/Project` type. + string singular = 6; + + // Style flag(s) for this resource. + // These indicate that a resource is expected to conform to a given + // style. See the specific style flags for additional information. + repeated Style style = 10; +} + +// Defines a proto annotation that describes a string field that refers to +// an API resource. +message ResourceReference { + // The resource type that the annotated field references. + // + // Example: + // + // message Subscription { + // string topic = 2 [(google.api.resource_reference) = { + // type: "pubsub.googleapis.com/Topic" + // }]; + // } + // + // Occasionally, a field may reference an arbitrary resource. In this case, + // APIs use the special value * in their resource reference. + // + // Example: + // + // message GetIamPolicyRequest { + // string resource = 2 [(google.api.resource_reference) = { + // type: "*" + // }]; + // } + string type = 1; + + // The resource type of a child collection that the annotated field + // references. This is useful for annotating the `parent` field that + // doesn't have a fixed resource type. + // + // Example: + // + // message ListLogEntriesRequest { + // string parent = 1 [(google.api.resource_reference) = { + // child_type: "logging.googleapis.com/LogEntry" + // }; + // } + string child_type = 2; +} diff --git a/third_party/google/api/routing.proto b/third_party/google/api/routing.proto new file mode 100644 index 00000000..4fcb2acb --- /dev/null +++ b/third_party/google/api/routing.proto @@ -0,0 +1,461 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; +option java_multiple_files = true; +option java_outer_classname = "RoutingProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.MethodOptions { + // See RoutingRule. + google.api.RoutingRule routing = 72295729; +} + +// Specifies the routing information that should be sent along with the request +// in the form of routing header. +// **NOTE:** All service configuration rules follow the "last one wins" order. +// +// The examples below will apply to an RPC which has the following request type: +// +// Message Definition: +// +// message Request { +// // The name of the Table +// // Values can be of the following formats: +// // - `projects//tables/` +// // - `projects//instances//tables/
` +// // - `region//zones//tables/
` +// string table_name = 1; +// +// // This value specifies routing for replication. +// // It can be in the following formats: +// // - `profiles/` +// // - a legacy `profile_id` that can be any string +// string app_profile_id = 2; +// } +// +// Example message: +// +// { +// table_name: projects/proj_foo/instances/instance_bar/table/table_baz, +// app_profile_id: profiles/prof_qux +// } +// +// The routing header consists of one or multiple key-value pairs. Every key +// and value must be percent-encoded, and joined together in the format of +// `key1=value1&key2=value2`. +// The examples below skip the percent-encoding for readability. +// +// Example 1 +// +// Extracting a field from the request to put into the routing header +// unchanged, with the key equal to the field name. +// +// annotation: +// +// option (google.api.routing) = { +// // Take the `app_profile_id`. +// routing_parameters { +// field: "app_profile_id" +// } +// }; +// +// result: +// +// x-goog-request-params: app_profile_id=profiles/prof_qux +// +// Example 2 +// +// Extracting a field from the request to put into the routing header +// unchanged, with the key different from the field name. +// +// annotation: +// +// option (google.api.routing) = { +// // Take the `app_profile_id`, but name it `routing_id` in the header. +// routing_parameters { +// field: "app_profile_id" +// path_template: "{routing_id=**}" +// } +// }; +// +// result: +// +// x-goog-request-params: routing_id=profiles/prof_qux +// +// Example 3 +// +// Extracting a field from the request to put into the routing +// header, while matching a path template syntax on the field's value. +// +// NB: it is more useful to send nothing than to send garbage for the purpose +// of dynamic routing, since garbage pollutes cache. Thus the matching. +// +// Sub-example 3a +// +// The field matches the template. +// +// annotation: +// +// option (google.api.routing) = { +// // Take the `table_name`, if it's well-formed (with project-based +// // syntax). +// routing_parameters { +// field: "table_name" +// path_template: "{table_name=projects/*/instances/*/**}" +// } +// }; +// +// result: +// +// x-goog-request-params: +// table_name=projects/proj_foo/instances/instance_bar/table/table_baz +// +// Sub-example 3b +// +// The field does not match the template. +// +// annotation: +// +// option (google.api.routing) = { +// // Take the `table_name`, if it's well-formed (with region-based +// // syntax). +// routing_parameters { +// field: "table_name" +// path_template: "{table_name=regions/*/zones/*/**}" +// } +// }; +// +// result: +// +// +// +// Sub-example 3c +// +// Multiple alternative conflictingly named path templates are +// specified. The one that matches is used to construct the header. +// +// annotation: +// +// option (google.api.routing) = { +// // Take the `table_name`, if it's well-formed, whether +// // using the region- or projects-based syntax. +// +// routing_parameters { +// field: "table_name" +// path_template: "{table_name=regions/*/zones/*/**}" +// } +// routing_parameters { +// field: "table_name" +// path_template: "{table_name=projects/*/instances/*/**}" +// } +// }; +// +// result: +// +// x-goog-request-params: +// table_name=projects/proj_foo/instances/instance_bar/table/table_baz +// +// Example 4 +// +// Extracting a single routing header key-value pair by matching a +// template syntax on (a part of) a single request field. +// +// annotation: +// +// option (google.api.routing) = { +// // Take just the project id from the `table_name` field. +// routing_parameters { +// field: "table_name" +// path_template: "{routing_id=projects/*}/**" +// } +// }; +// +// result: +// +// x-goog-request-params: routing_id=projects/proj_foo +// +// Example 5 +// +// Extracting a single routing header key-value pair by matching +// several conflictingly named path templates on (parts of) a single request +// field. The last template to match "wins" the conflict. +// +// annotation: +// +// option (google.api.routing) = { +// // If the `table_name` does not have instances information, +// // take just the project id for routing. +// // Otherwise take project + instance. +// +// routing_parameters { +// field: "table_name" +// path_template: "{routing_id=projects/*}/**" +// } +// routing_parameters { +// field: "table_name" +// path_template: "{routing_id=projects/*/instances/*}/**" +// } +// }; +// +// result: +// +// x-goog-request-params: +// routing_id=projects/proj_foo/instances/instance_bar +// +// Example 6 +// +// Extracting multiple routing header key-value pairs by matching +// several non-conflicting path templates on (parts of) a single request field. +// +// Sub-example 6a +// +// Make the templates strict, so that if the `table_name` does not +// have an instance information, nothing is sent. +// +// annotation: +// +// option (google.api.routing) = { +// // The routing code needs two keys instead of one composite +// // but works only for the tables with the "project-instance" name +// // syntax. +// +// routing_parameters { +// field: "table_name" +// path_template: "{project_id=projects/*}/instances/*/**" +// } +// routing_parameters { +// field: "table_name" +// path_template: "projects/*/{instance_id=instances/*}/**" +// } +// }; +// +// result: +// +// x-goog-request-params: +// project_id=projects/proj_foo&instance_id=instances/instance_bar +// +// Sub-example 6b +// +// Make the templates loose, so that if the `table_name` does not +// have an instance information, just the project id part is sent. +// +// annotation: +// +// option (google.api.routing) = { +// // The routing code wants two keys instead of one composite +// // but will work with just the `project_id` for tables without +// // an instance in the `table_name`. +// +// routing_parameters { +// field: "table_name" +// path_template: "{project_id=projects/*}/**" +// } +// routing_parameters { +// field: "table_name" +// path_template: "projects/*/{instance_id=instances/*}/**" +// } +// }; +// +// result (is the same as 6a for our example message because it has the instance +// information): +// +// x-goog-request-params: +// project_id=projects/proj_foo&instance_id=instances/instance_bar +// +// Example 7 +// +// Extracting multiple routing header key-value pairs by matching +// several path templates on multiple request fields. +// +// NB: note that here there is no way to specify sending nothing if one of the +// fields does not match its template. E.g. if the `table_name` is in the wrong +// format, the `project_id` will not be sent, but the `routing_id` will be. +// The backend routing code has to be aware of that and be prepared to not +// receive a full complement of keys if it expects multiple. +// +// annotation: +// +// option (google.api.routing) = { +// // The routing needs both `project_id` and `routing_id` +// // (from the `app_profile_id` field) for routing. +// +// routing_parameters { +// field: "table_name" +// path_template: "{project_id=projects/*}/**" +// } +// routing_parameters { +// field: "app_profile_id" +// path_template: "{routing_id=**}" +// } +// }; +// +// result: +// +// x-goog-request-params: +// project_id=projects/proj_foo&routing_id=profiles/prof_qux +// +// Example 8 +// +// Extracting a single routing header key-value pair by matching +// several conflictingly named path templates on several request fields. The +// last template to match "wins" the conflict. +// +// annotation: +// +// option (google.api.routing) = { +// // The `routing_id` can be a project id or a region id depending on +// // the table name format, but only if the `app_profile_id` is not set. +// // If `app_profile_id` is set it should be used instead. +// +// routing_parameters { +// field: "table_name" +// path_template: "{routing_id=projects/*}/**" +// } +// routing_parameters { +// field: "table_name" +// path_template: "{routing_id=regions/*}/**" +// } +// routing_parameters { +// field: "app_profile_id" +// path_template: "{routing_id=**}" +// } +// }; +// +// result: +// +// x-goog-request-params: routing_id=profiles/prof_qux +// +// Example 9 +// +// Bringing it all together. +// +// annotation: +// +// option (google.api.routing) = { +// // For routing both `table_location` and a `routing_id` are needed. +// // +// // table_location can be either an instance id or a region+zone id. +// // +// // For `routing_id`, take the value of `app_profile_id` +// // - If it's in the format `profiles/`, send +// // just the `` part. +// // - If it's any other literal, send it as is. +// // If the `app_profile_id` is empty, and the `table_name` starts with +// // the project_id, send that instead. +// +// routing_parameters { +// field: "table_name" +// path_template: "projects/*/{table_location=instances/*}/tables/*" +// } +// routing_parameters { +// field: "table_name" +// path_template: "{table_location=regions/*/zones/*}/tables/*" +// } +// routing_parameters { +// field: "table_name" +// path_template: "{routing_id=projects/*}/**" +// } +// routing_parameters { +// field: "app_profile_id" +// path_template: "{routing_id=**}" +// } +// routing_parameters { +// field: "app_profile_id" +// path_template: "profiles/{routing_id=*}" +// } +// }; +// +// result: +// +// x-goog-request-params: +// table_location=instances/instance_bar&routing_id=prof_qux +message RoutingRule { + // A collection of Routing Parameter specifications. + // **NOTE:** If multiple Routing Parameters describe the same key + // (via the `path_template` field or via the `field` field when + // `path_template` is not provided), "last one wins" rule + // determines which Parameter gets used. + // See the examples for more details. + repeated RoutingParameter routing_parameters = 2; +} + +// A projection from an input message to the GRPC or REST header. +message RoutingParameter { + // A request field to extract the header key-value pair from. + string field = 1; + + // A pattern matching the key-value field. Optional. + // If not specified, the whole field specified in the `field` field will be + // taken as value, and its name used as key. If specified, it MUST contain + // exactly one named segment (along with any number of unnamed segments) The + // pattern will be matched over the field specified in the `field` field, then + // if the match is successful: + // - the name of the single named segment will be used as a header name, + // - the match value of the segment will be used as a header value; + // if the match is NOT successful, nothing will be sent. + // + // Example: + // + // -- This is a field in the request message + // | that the header value will be extracted from. + // | + // | -- This is the key name in the + // | | routing header. + // V | + // field: "table_name" v + // path_template: "projects/*/{table_location=instances/*}/tables/*" + // ^ ^ + // | | + // In the {} brackets is the pattern that -- | + // specifies what to extract from the | + // field as a value to be sent. | + // | + // The string in the field must match the whole pattern -- + // before brackets, inside brackets, after brackets. + // + // When looking at this specific example, we can see that: + // - A key-value pair with the key `table_location` + // and the value matching `instances/*` should be added + // to the x-goog-request-params routing header. + // - The value is extracted from the request message's `table_name` field + // if it matches the full pattern specified: + // `projects/*/instances/*/tables/*`. + // + // **NB:** If the `path_template` field is not provided, the key name is + // equal to the field name, and the whole field should be sent as a value. + // This makes the pattern for the field and the value functionally equivalent + // to `**`, and the configuration + // + // { + // field: "table_name" + // } + // + // is a functionally equivalent shorthand to: + // + // { + // field: "table_name" + // path_template: "{table_name=**}" + // } + // + // See Example 1 for more details. + string path_template = 2; +} diff --git a/third_party/google/api/visibility.proto b/third_party/google/api/visibility.proto new file mode 100644 index 00000000..0ab5bdc1 --- /dev/null +++ b/third_party/google/api/visibility.proto @@ -0,0 +1,112 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.api; + +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/genproto/googleapis/api/visibility;visibility"; +option java_multiple_files = true; +option java_outer_classname = "VisibilityProto"; +option java_package = "com.google.api"; +option objc_class_prefix = "GAPI"; + +extend google.protobuf.EnumOptions { + // See `VisibilityRule`. + google.api.VisibilityRule enum_visibility = 72295727; +} + +extend google.protobuf.EnumValueOptions { + // See `VisibilityRule`. + google.api.VisibilityRule value_visibility = 72295727; +} + +extend google.protobuf.FieldOptions { + // See `VisibilityRule`. + google.api.VisibilityRule field_visibility = 72295727; +} + +extend google.protobuf.MessageOptions { + // See `VisibilityRule`. + google.api.VisibilityRule message_visibility = 72295727; +} + +extend google.protobuf.MethodOptions { + // See `VisibilityRule`. + google.api.VisibilityRule method_visibility = 72295727; +} + +extend google.protobuf.ServiceOptions { + // See `VisibilityRule`. + google.api.VisibilityRule api_visibility = 72295727; +} + +// `Visibility` restricts service consumer's access to service elements, +// such as whether an application can call a visibility-restricted method. +// The restriction is expressed by applying visibility labels on service +// elements. The visibility labels are elsewhere linked to service consumers. +// +// A service can define multiple visibility labels, but a service consumer +// should be granted at most one visibility label. Multiple visibility +// labels for a single service consumer are not supported. +// +// If an element and all its parents have no visibility label, its visibility +// is unconditionally granted. +// +// Example: +// +// visibility: +// rules: +// - selector: google.calendar.Calendar.EnhancedSearch +// restriction: PREVIEW +// - selector: google.calendar.Calendar.Delegate +// restriction: INTERNAL +// +// Here, all methods are publicly visible except for the restricted methods +// EnhancedSearch and Delegate. +message Visibility { + // A list of visibility rules that apply to individual API elements. + // + // **NOTE:** All service configuration rules follow "last one wins" order. + repeated VisibilityRule rules = 1; +} + +// A visibility rule provides visibility configuration for an individual API +// element. +message VisibilityRule { + // Selects methods, messages, fields, enums, etc. to which this rule applies. + // + // Refer to [selector][google.api.DocumentationRule.selector] for syntax + // details. + string selector = 1; + + // A comma-separated list of visibility labels that apply to the `selector`. + // Any of the listed labels can be used to grant the visibility. + // + // If a rule has multiple labels, removing one of the labels but not all of + // them can break clients. + // + // Example: + // + // visibility: + // rules: + // - selector: google.calendar.Calendar.EnhancedSearch + // restriction: INTERNAL, PREVIEW + // + // Removing INTERNAL from this restriction will break clients that rely on + // this method and only had access to it through INTERNAL. + string restriction = 2; +} diff --git a/third_party/google/bytestream/bytestream.proto b/third_party/google/bytestream/bytestream.proto new file mode 100644 index 00000000..26bc609e --- /dev/null +++ b/third_party/google/bytestream/bytestream.proto @@ -0,0 +1,178 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.bytestream; + +option go_package = "google.golang.org/genproto/googleapis/bytestream;bytestream"; +option java_outer_classname = "ByteStreamProto"; +option java_package = "com.google.bytestream"; + +// #### Introduction +// +// The Byte Stream API enables a client to read and write a stream of bytes to +// and from a resource. Resources have names, and these names are supplied in +// the API calls below to identify the resource that is being read from or +// written to. +// +// All implementations of the Byte Stream API export the interface defined here: +// +// * `Read()`: Reads the contents of a resource. +// +// * `Write()`: Writes the contents of a resource. The client can call `Write()` +// multiple times with the same resource and can check the status of the write +// by calling `QueryWriteStatus()`. +// +// #### Service parameters and metadata +// +// The ByteStream API provides no direct way to access/modify any metadata +// associated with the resource. +// +// #### Errors +// +// The errors returned by the service are in the Google canonical error space. +service ByteStream { + // `Read()` is used to retrieve the contents of a resource as a sequence + // of bytes. The bytes are returned in a sequence of responses, and the + // responses are delivered as the results of a server-side streaming RPC. + rpc Read(ReadRequest) returns (stream ReadResponse); + + // `Write()` is used to send the contents of a resource as a sequence of + // bytes. The bytes are sent in a sequence of request protos of a client-side + // streaming RPC. + // + // A `Write()` action is resumable. If there is an error or the connection is + // broken during the `Write()`, the client should check the status of the + // `Write()` by calling `QueryWriteStatus()` and continue writing from the + // returned `committed_size`. This may be less than the amount of data the + // client previously sent. + // + // Calling `Write()` on a resource name that was previously written and + // finalized could cause an error, depending on whether the underlying service + // allows over-writing of previously written resources. + // + // When the client closes the request channel, the service will respond with + // a `WriteResponse`. The service will not view the resource as `complete` + // until the client has sent a `WriteRequest` with `finish_write` set to + // `true`. Sending any requests on a stream after sending a request with + // `finish_write` set to `true` will cause an error. The client **should** + // check the `WriteResponse` it receives to determine how much data the + // service was able to commit and whether the service views the resource as + // `complete` or not. + rpc Write(stream WriteRequest) returns (WriteResponse); + + // `QueryWriteStatus()` is used to find the `committed_size` for a resource + // that is being written, which can then be used as the `write_offset` for + // the next `Write()` call. + // + // If the resource does not exist (i.e., the resource has been deleted, or the + // first `Write()` has not yet reached the service), this method returns the + // error `NOT_FOUND`. + // + // The client **may** call `QueryWriteStatus()` at any time to determine how + // much data has been processed for this resource. This is useful if the + // client is buffering data and needs to know which data can be safely + // evicted. For any sequence of `QueryWriteStatus()` calls for a given + // resource name, the sequence of returned `committed_size` values will be + // non-decreasing. + rpc QueryWriteStatus(QueryWriteStatusRequest) + returns (QueryWriteStatusResponse); +} + +// Request object for ByteStream.Read. +message ReadRequest { + // The name of the resource to read. + string resource_name = 1; + + // The offset for the first byte to return in the read, relative to the start + // of the resource. + // + // A `read_offset` that is negative or greater than the size of the resource + // will cause an `OUT_OF_RANGE` error. + int64 read_offset = 2; + + // The maximum number of `data` bytes the server is allowed to return in the + // sum of all `ReadResponse` messages. A `read_limit` of zero indicates that + // there is no limit, and a negative `read_limit` will cause an error. + // + // If the stream returns fewer bytes than allowed by the `read_limit` and no + // error occurred, the stream includes all data from the `read_offset` to the + // end of the resource. + int64 read_limit = 3; +} + +// Response object for ByteStream.Read. +message ReadResponse { + // A portion of the data for the resource. The service **may** leave `data` + // empty for any given `ReadResponse`. This enables the service to inform the + // client that the request is still live while it is running an operation to + // generate more data. + bytes data = 10; +} + +// Request object for ByteStream.Write. +message WriteRequest { + // The name of the resource to write. This **must** be set on the first + // `WriteRequest` of each `Write()` action. If it is set on subsequent calls, + // it **must** match the value of the first request. + string resource_name = 1; + + // The offset from the beginning of the resource at which the data should be + // written. It is required on all `WriteRequest`s. + // + // In the first `WriteRequest` of a `Write()` action, it indicates + // the initial offset for the `Write()` call. The value **must** be equal to + // the `committed_size` that a call to `QueryWriteStatus()` would return. + // + // On subsequent calls, this value **must** be set and **must** be equal to + // the sum of the first `write_offset` and the sizes of all `data` bundles + // sent previously on this stream. + // + // An incorrect value will cause an error. + int64 write_offset = 2; + + // If `true`, this indicates that the write is complete. Sending any + // `WriteRequest`s subsequent to one in which `finish_write` is `true` will + // cause an error. + bool finish_write = 3; + + // A portion of the data for the resource. The client **may** leave `data` + // empty for any given `WriteRequest`. This enables the client to inform the + // service that the request is still live while it is running an operation to + // generate more data. + bytes data = 10; +} + +// Response object for ByteStream.Write. +message WriteResponse { + // The number of bytes that have been processed for the given resource. + int64 committed_size = 1; +} + +// Request object for ByteStream.QueryWriteStatus. +message QueryWriteStatusRequest { + // The name of the resource whose write status is being requested. + string resource_name = 1; +} + +// Response object for ByteStream.QueryWriteStatus. +message QueryWriteStatusResponse { + // The number of bytes that have been processed for the given resource. + int64 committed_size = 1; + + // `complete` is `true` only if the client has sent a `WriteRequest` with + // `finish_write` set to true, and the server has processed that request. + bool complete = 2; +} diff --git a/third_party/google/geo/type/viewport.proto b/third_party/google/geo/type/viewport.proto new file mode 100644 index 00000000..08c0cce8 --- /dev/null +++ b/third_party/google/geo/type/viewport.proto @@ -0,0 +1,69 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.geo.type; + +import "google/type/latlng.proto"; + +option go_package = "google.golang.org/genproto/googleapis/geo/type/viewport;viewport"; +option java_multiple_files = true; +option java_outer_classname = "ViewportProto"; +option java_package = "com.google.geo.type"; +option objc_class_prefix = "GGTP"; + +// A latitude-longitude viewport, represented as two diagonally opposite `low` +// and `high` points. A viewport is considered a closed region, i.e. it includes +// its boundary. The latitude bounds must range between -90 to 90 degrees +// inclusive, and the longitude bounds must range between -180 to 180 degrees +// inclusive. Various cases include: +// +// - If `low` = `high`, the viewport consists of that single point. +// +// - If `low.longitude` > `high.longitude`, the longitude range is inverted +// (the viewport crosses the 180 degree longitude line). +// +// - If `low.longitude` = -180 degrees and `high.longitude` = 180 degrees, +// the viewport includes all longitudes. +// +// - If `low.longitude` = 180 degrees and `high.longitude` = -180 degrees, +// the longitude range is empty. +// +// - If `low.latitude` > `high.latitude`, the latitude range is empty. +// +// Both `low` and `high` must be populated, and the represented box cannot be +// empty (as specified by the definitions above). An empty viewport will result +// in an error. +// +// For example, this viewport fully encloses New York City: +// +// { +// "low": { +// "latitude": 40.477398, +// "longitude": -74.259087 +// }, +// "high": { +// "latitude": 40.91618, +// "longitude": -73.70018 +// } +// } +message Viewport { + // Required. The low point of the viewport. + google.type.LatLng low = 1; + + // Required. The high point of the viewport. + google.type.LatLng high = 2; +} diff --git a/third_party/google/iam/v1/iam_policy.proto b/third_party/google/iam/v1/iam_policy.proto new file mode 100644 index 00000000..a123ab84 --- /dev/null +++ b/third_party/google/iam/v1/iam_policy.proto @@ -0,0 +1,157 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.iam.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/iam/v1/options.proto"; +import "google/iam/v1/policy.proto"; +import "google/protobuf/field_mask.proto"; + +option csharp_namespace = "Google.Cloud.Iam.V1"; +option go_package = "cloud.google.com/go/iam/apiv1/iampb;iampb"; +option java_multiple_files = true; +option java_outer_classname = "IamPolicyProto"; +option java_package = "com.google.iam.v1"; +option php_namespace = "Google\\Cloud\\Iam\\V1"; + +// API Overview +// +// Manages Identity and Access Management (IAM) policies. +// +// Any implementation of an API that offers access control features +// implements the google.iam.v1.IAMPolicy interface. +// +// ## Data model +// +// Access control is applied when a principal (user or service account), takes +// some action on a resource exposed by a service. Resources, identified by +// URI-like names, are the unit of access control specification. Service +// implementations can choose the granularity of access control and the +// supported permissions for their resources. +// For example one database service may allow access control to be +// specified only at the Table level, whereas another might allow access control +// to also be specified at the Column level. +// +// ## Policy Structure +// +// See google.iam.v1.Policy +// +// This is intentionally not a CRUD style API because access control policies +// are created and deleted implicitly with the resources to which they are +// attached. +service IAMPolicy { + option (google.api.default_host) = "iam-meta-api.googleapis.com"; + + // Sets the access control policy on the specified resource. Replaces any + // existing policy. + // + // Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors. + rpc SetIamPolicy(SetIamPolicyRequest) returns (Policy) { + option (google.api.http) = { + post: "/v1/{resource=**}:setIamPolicy" + body: "*" + }; + } + + // Gets the access control policy for a resource. + // Returns an empty policy if the resource exists and does not have a policy + // set. + rpc GetIamPolicy(GetIamPolicyRequest) returns (Policy) { + option (google.api.http) = { + post: "/v1/{resource=**}:getIamPolicy" + body: "*" + }; + } + + // Returns permissions that a caller has on the specified resource. + // If the resource does not exist, this will return an empty set of + // permissions, not a `NOT_FOUND` error. + // + // Note: This operation is designed to be used for building permission-aware + // UIs and command-line tools, not for authorization checking. This operation + // may "fail open" without warning. + rpc TestIamPermissions(TestIamPermissionsRequest) + returns (TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v1/{resource=**}:testIamPermissions" + body: "*" + }; + } +} + +// Request message for `SetIamPolicy` method. +message SetIamPolicyRequest { + // REQUIRED: The resource for which the policy is being specified. + // See the operation documentation for the appropriate value for this field. + string resource = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "*" + ]; + + // REQUIRED: The complete policy to be applied to the `resource`. The size of + // the policy is limited to a few 10s of KB. An empty policy is a + // valid policy but certain Cloud Platform services (such as Projects) + // might reject them. + Policy policy = 2 [(google.api.field_behavior) = REQUIRED]; + + // OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + // the fields in the mask will be modified. If no mask is provided, the + // following default mask is used: + // + // `paths: "bindings, etag"` + google.protobuf.FieldMask update_mask = 3; +} + +// Request message for `GetIamPolicy` method. +message GetIamPolicyRequest { + // REQUIRED: The resource for which the policy is being requested. + // See the operation documentation for the appropriate value for this field. + string resource = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "*" + ]; + + // OPTIONAL: A `GetPolicyOptions` object for specifying options to + // `GetIamPolicy`. + GetPolicyOptions options = 2; +} + +// Request message for `TestIamPermissions` method. +message TestIamPermissionsRequest { + // REQUIRED: The resource for which the policy detail is being requested. + // See the operation documentation for the appropriate value for this field. + string resource = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference).type = "*" + ]; + + // The set of permissions to check for the `resource`. Permissions with + // wildcards (such as '*' or 'storage.*') are not allowed. For more + // information see + // [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + repeated string permissions = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Response message for `TestIamPermissions` method. +message TestIamPermissionsResponse { + // A subset of `TestPermissionsRequest.permissions` that the caller is + // allowed. + repeated string permissions = 1; +} diff --git a/third_party/google/iam/v1/options.proto b/third_party/google/iam/v1/options.proto new file mode 100644 index 00000000..53370587 --- /dev/null +++ b/third_party/google/iam/v1/options.proto @@ -0,0 +1,48 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.iam.v1; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Iam.V1"; +option go_package = "cloud.google.com/go/iam/apiv1/iampb;iampb"; +option java_multiple_files = true; +option java_outer_classname = "OptionsProto"; +option java_package = "com.google.iam.v1"; +option php_namespace = "Google\\Cloud\\Iam\\V1"; + +// Encapsulates settings provided to GetIamPolicy. +message GetPolicyOptions { + // Optional. The maximum policy version that will be used to format the + // policy. + // + // Valid values are 0, 1, and 3. Requests specifying an invalid value will be + // rejected. + // + // Requests for policies with any conditional role bindings must specify + // version 3. Policies with no conditional role bindings may specify any valid + // value or leave the field unset. + // + // The policy in the response might use the policy version that you specified, + // or it might use a lower policy version. For example, if you specify version + // 3, but the policy has no conditional role bindings, the response uses + // version 1. + // + // To learn which resources support conditions in their IAM policies, see the + // [IAM + // documentation](https://cloud.google.com/iam/help/conditions/resource-policies). + int32 requested_policy_version = 1; +} diff --git a/third_party/google/iam/v1/policy.proto b/third_party/google/iam/v1/policy.proto new file mode 100644 index 00000000..b5eac03c --- /dev/null +++ b/third_party/google/iam/v1/policy.proto @@ -0,0 +1,410 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.iam.v1; + +import "google/type/expr.proto"; + +option cc_enable_arenas = true; +option csharp_namespace = "Google.Cloud.Iam.V1"; +option go_package = "cloud.google.com/go/iam/apiv1/iampb;iampb"; +option java_multiple_files = true; +option java_outer_classname = "PolicyProto"; +option java_package = "com.google.iam.v1"; +option php_namespace = "Google\\Cloud\\Iam\\V1"; + +// An Identity and Access Management (IAM) policy, which specifies access +// controls for Google Cloud resources. +// +// +// A `Policy` is a collection of `bindings`. A `binding` binds one or more +// `members`, or principals, to a single `role`. Principals can be user +// accounts, service accounts, Google groups, and domains (such as G Suite). A +// `role` is a named list of permissions; each `role` can be an IAM predefined +// role or a user-created custom role. +// +// For some types of Google Cloud resources, a `binding` can also specify a +// `condition`, which is a logical expression that allows access to a resource +// only if the expression evaluates to `true`. A condition can add constraints +// based on attributes of the request, the resource, or both. To learn which +// resources support conditions in their IAM policies, see the +// [IAM +// documentation](https://cloud.google.com/iam/help/conditions/resource-policies). +// +// **JSON example:** +// +// ``` +// { +// "bindings": [ +// { +// "role": "roles/resourcemanager.organizationAdmin", +// "members": [ +// "user:mike@example.com", +// "group:admins@example.com", +// "domain:google.com", +// "serviceAccount:my-project-id@appspot.gserviceaccount.com" +// ] +// }, +// { +// "role": "roles/resourcemanager.organizationViewer", +// "members": [ +// "user:eve@example.com" +// ], +// "condition": { +// "title": "expirable access", +// "description": "Does not grant access after Sep 2020", +// "expression": "request.time < +// timestamp('2020-10-01T00:00:00.000Z')", +// } +// } +// ], +// "etag": "BwWWja0YfJA=", +// "version": 3 +// } +// ``` +// +// **YAML example:** +// +// ``` +// bindings: +// - members: +// - user:mike@example.com +// - group:admins@example.com +// - domain:google.com +// - serviceAccount:my-project-id@appspot.gserviceaccount.com +// role: roles/resourcemanager.organizationAdmin +// - members: +// - user:eve@example.com +// role: roles/resourcemanager.organizationViewer +// condition: +// title: expirable access +// description: Does not grant access after Sep 2020 +// expression: request.time < timestamp('2020-10-01T00:00:00.000Z') +// etag: BwWWja0YfJA= +// version: 3 +// ``` +// +// For a description of IAM and its features, see the +// [IAM documentation](https://cloud.google.com/iam/docs/). +message Policy { + // Specifies the format of the policy. + // + // Valid values are `0`, `1`, and `3`. Requests that specify an invalid value + // are rejected. + // + // Any operation that affects conditional role bindings must specify version + // `3`. This requirement applies to the following operations: + // + // * Getting a policy that includes a conditional role binding + // * Adding a conditional role binding to a policy + // * Changing a conditional role binding in a policy + // * Removing any role binding, with or without a condition, from a policy + // that includes conditions + // + // **Important:** If you use IAM Conditions, you must include the `etag` field + // whenever you call `setIamPolicy`. If you omit this field, then IAM allows + // you to overwrite a version `3` policy with a version `1` policy, and all of + // the conditions in the version `3` policy are lost. + // + // If a policy does not include any conditions, operations on that policy may + // specify any valid version or leave the field unset. + // + // To learn which resources support conditions in their IAM policies, see the + // [IAM + // documentation](https://cloud.google.com/iam/help/conditions/resource-policies). + int32 version = 1; + + // Associates a list of `members`, or principals, with a `role`. Optionally, + // may specify a `condition` that determines how and when the `bindings` are + // applied. Each of the `bindings` must contain at least one principal. + // + // The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 + // of these principals can be Google groups. Each occurrence of a principal + // counts towards these limits. For example, if the `bindings` grant 50 + // different roles to `user:alice@example.com`, and not to any other + // principal, then you can add another 1,450 principals to the `bindings` in + // the `Policy`. + repeated Binding bindings = 4; + + // Specifies cloud audit logging configuration for this policy. + repeated AuditConfig audit_configs = 6; + + // `etag` is used for optimistic concurrency control as a way to help + // prevent simultaneous updates of a policy from overwriting each other. + // It is strongly suggested that systems make use of the `etag` in the + // read-modify-write cycle to perform policy updates in order to avoid race + // conditions: An `etag` is returned in the response to `getIamPolicy`, and + // systems are expected to put that etag in the request to `setIamPolicy` to + // ensure that their change will be applied to the same version of the policy. + // + // **Important:** If you use IAM Conditions, you must include the `etag` field + // whenever you call `setIamPolicy`. If you omit this field, then IAM allows + // you to overwrite a version `3` policy with a version `1` policy, and all of + // the conditions in the version `3` policy are lost. + bytes etag = 3; +} + +// Associates `members`, or principals, with a `role`. +message Binding { + // Role that is assigned to the list of `members`, or principals. + // For example, `roles/viewer`, `roles/editor`, or `roles/owner`. + string role = 1; + + // Specifies the principals requesting access for a Google Cloud resource. + // `members` can have the following values: + // + // * `allUsers`: A special identifier that represents anyone who is + // on the internet; with or without a Google account. + // + // * `allAuthenticatedUsers`: A special identifier that represents anyone + // who is authenticated with a Google account or a service account. + // + // * `user:{emailid}`: An email address that represents a specific Google + // account. For example, `alice@example.com` . + // + // + // * `serviceAccount:{emailid}`: An email address that represents a service + // account. For example, `my-other-app@appspot.gserviceaccount.com`. + // + // * `group:{emailid}`: An email address that represents a Google group. + // For example, `admins@example.com`. + // + // * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique + // identifier) representing a user that has been recently deleted. For + // example, `alice@example.com?uid=123456789012345678901`. If the user is + // recovered, this value reverts to `user:{emailid}` and the recovered user + // retains the role in the binding. + // + // * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus + // unique identifier) representing a service account that has been recently + // deleted. For example, + // `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. + // If the service account is undeleted, this value reverts to + // `serviceAccount:{emailid}` and the undeleted service account retains the + // role in the binding. + // + // * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique + // identifier) representing a Google group that has been recently + // deleted. For example, `admins@example.com?uid=123456789012345678901`. If + // the group is recovered, this value reverts to `group:{emailid}` and the + // recovered group retains the role in the binding. + // + // + // * `domain:{domain}`: The G Suite domain (primary) that represents all the + // users of that domain. For example, `google.com` or `example.com`. + // + // + repeated string members = 2; + + // The condition that is associated with this binding. + // + // If the condition evaluates to `true`, then this binding applies to the + // current request. + // + // If the condition evaluates to `false`, then this binding does not apply to + // the current request. However, a different role binding might grant the same + // role to one or more of the principals in this binding. + // + // To learn which resources support conditions in their IAM policies, see the + // [IAM + // documentation](https://cloud.google.com/iam/help/conditions/resource-policies). + google.type.Expr condition = 3; +} + +// Specifies the audit configuration for a service. +// The configuration determines which permission types are logged, and what +// identities, if any, are exempted from logging. +// An AuditConfig must have one or more AuditLogConfigs. +// +// If there are AuditConfigs for both `allServices` and a specific service, +// the union of the two AuditConfigs is used for that service: the log_types +// specified in each AuditConfig are enabled, and the exempted_members in each +// AuditLogConfig are exempted. +// +// Example Policy with multiple AuditConfigs: +// +// { +// "audit_configs": [ +// { +// "service": "allServices", +// "audit_log_configs": [ +// { +// "log_type": "DATA_READ", +// "exempted_members": [ +// "user:jose@example.com" +// ] +// }, +// { +// "log_type": "DATA_WRITE" +// }, +// { +// "log_type": "ADMIN_READ" +// } +// ] +// }, +// { +// "service": "sampleservice.googleapis.com", +// "audit_log_configs": [ +// { +// "log_type": "DATA_READ" +// }, +// { +// "log_type": "DATA_WRITE", +// "exempted_members": [ +// "user:aliya@example.com" +// ] +// } +// ] +// } +// ] +// } +// +// For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ +// logging. It also exempts `jose@example.com` from DATA_READ logging, and +// `aliya@example.com` from DATA_WRITE logging. +message AuditConfig { + // Specifies a service that will be enabled for audit logging. + // For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. + // `allServices` is a special value that covers all services. + string service = 1; + + // The configuration for logging of each type of permission. + repeated AuditLogConfig audit_log_configs = 3; +} + +// Provides the configuration for logging a type of permissions. +// Example: +// +// { +// "audit_log_configs": [ +// { +// "log_type": "DATA_READ", +// "exempted_members": [ +// "user:jose@example.com" +// ] +// }, +// { +// "log_type": "DATA_WRITE" +// } +// ] +// } +// +// This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting +// jose@example.com from DATA_READ logging. +message AuditLogConfig { + // The list of valid permission types for which logging can be configured. + // Admin writes are always logged, and are not configurable. + enum LogType { + // Default case. Should never be this. + LOG_TYPE_UNSPECIFIED = 0; + + // Admin reads. Example: CloudIAM getIamPolicy + ADMIN_READ = 1; + + // Data writes. Example: CloudSQL Users create + DATA_WRITE = 2; + + // Data reads. Example: CloudSQL Users list + DATA_READ = 3; + } + + // The log type that this config enables. + LogType log_type = 1; + + // Specifies the identities that do not cause logging for this type of + // permission. + // Follows the same format of + // [Binding.members][google.iam.v1.Binding.members]. + repeated string exempted_members = 2; +} + +// The difference delta between two policies. +message PolicyDelta { + // The delta for Bindings between two policies. + repeated BindingDelta binding_deltas = 1; + + // The delta for AuditConfigs between two policies. + repeated AuditConfigDelta audit_config_deltas = 2; +} + +// One delta entry for Binding. Each individual change (only one member in each +// entry) to a binding will be a separate entry. +message BindingDelta { + // The type of action performed on a Binding in a policy. + enum Action { + // Unspecified. + ACTION_UNSPECIFIED = 0; + + // Addition of a Binding. + ADD = 1; + + // Removal of a Binding. + REMOVE = 2; + } + + // The action that was performed on a Binding. + // Required + Action action = 1; + + // Role that is assigned to `members`. + // For example, `roles/viewer`, `roles/editor`, or `roles/owner`. + // Required + string role = 2; + + // A single identity requesting access for a Google Cloud resource. + // Follows the same format of Binding.members. + // Required + string member = 3; + + // The condition that is associated with this binding. + google.type.Expr condition = 4; +} + +// One delta entry for AuditConfig. Each individual change (only one +// exempted_member in each entry) to a AuditConfig will be a separate entry. +message AuditConfigDelta { + // The type of action performed on an audit configuration in a policy. + enum Action { + // Unspecified. + ACTION_UNSPECIFIED = 0; + + // Addition of an audit configuration. + ADD = 1; + + // Removal of an audit configuration. + REMOVE = 2; + } + + // The action that was performed on an audit configuration in a policy. + // Required + Action action = 1; + + // Specifies a service that was configured for Cloud Audit Logging. + // For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. + // `allServices` is a special value that covers all services. + // Required + string service = 2; + + // A single identity that is exempted from "data access" audit + // logging for the `service` specified above. + // Follows the same format of Binding.members. + string exempted_member = 3; + + // Specifies the log_type that was be enabled. ADMIN_ACTIVITY is always + // enabled, and cannot be configured. + // Required + string log_type = 4; +} diff --git a/third_party/google/longrunning/operations.proto b/third_party/google/longrunning/operations.proto new file mode 100644 index 00000000..63df207d --- /dev/null +++ b/third_party/google/longrunning/operations.proto @@ -0,0 +1,265 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.longrunning; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/descriptor.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/empty.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.LongRunning"; +option go_package = "cloud.google.com/go/longrunning/autogen/longrunningpb;longrunningpb"; +option java_multiple_files = true; +option java_outer_classname = "OperationsProto"; +option java_package = "com.google.longrunning"; +option objc_class_prefix = "GLRUN"; +option php_namespace = "Google\\LongRunning"; + +extend google.protobuf.MethodOptions { + // Additional information regarding long-running operations. + // In particular, this specifies the types that are returned from + // long-running operations. + // + // Required for methods that return `google.longrunning.Operation`; invalid + // otherwise. + google.longrunning.OperationInfo operation_info = 1049; +} + +// Manages long-running operations with an API service. +// +// When an API method normally takes long time to complete, it can be designed +// to return [Operation][google.longrunning.Operation] to the client, and the +// client can use this interface to receive the real response asynchronously by +// polling the operation resource, or pass the operation resource to another API +// (such as Pub/Sub API) to receive the response. Any API service that returns +// long-running operations should implement the `Operations` interface so +// developers can have a consistent client experience. +service Operations { + option (google.api.default_host) = "longrunning.googleapis.com"; + + // Lists operations that match the specified filter in the request. If the + // server doesn't support this method, it returns `UNIMPLEMENTED`. + rpc ListOperations(ListOperationsRequest) returns (ListOperationsResponse) { + option (google.api.http) = { + get: "/v1/{name=operations}" + }; + option (google.api.method_signature) = "name,filter"; + } + + // Gets the latest state of a long-running operation. Clients can use this + // method to poll the operation result at intervals as recommended by the API + // service. + rpc GetOperation(GetOperationRequest) returns (Operation) { + option (google.api.http) = { + get: "/v1/{name=operations/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes a long-running operation. This method indicates that the client is + // no longer interested in the operation result. It does not cancel the + // operation. If the server doesn't support this method, it returns + // `google.rpc.Code.UNIMPLEMENTED`. + rpc DeleteOperation(DeleteOperationRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=operations/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Starts asynchronous cancellation on a long-running operation. The server + // makes a best effort to cancel the operation, but success is not + // guaranteed. If the server doesn't support this method, it returns + // `google.rpc.Code.UNIMPLEMENTED`. Clients can use + // [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + // other methods to check whether the cancellation succeeded or whether the + // operation completed despite cancellation. On successful cancellation, + // the operation is not deleted; instead, it becomes an operation with + // an [Operation.error][google.longrunning.Operation.error] value with a + // [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + // `Code.CANCELLED`. + rpc CancelOperation(CancelOperationRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{name=operations/**}:cancel" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Waits until the specified long-running operation is done or reaches at most + // a specified timeout, returning the latest state. If the operation is + // already done, the latest state is immediately returned. If the timeout + // specified is greater than the default HTTP/RPC timeout, the HTTP/RPC + // timeout is used. If the server does not support this method, it returns + // `google.rpc.Code.UNIMPLEMENTED`. + // Note that this method is on a best-effort basis. It may return the latest + // state before the specified timeout (including immediately), meaning even an + // immediate response is no guarantee that the operation is done. + rpc WaitOperation(WaitOperationRequest) returns (Operation) {} +} + +// This resource represents a long-running operation that is the result of a +// network API call. +message Operation { + // The server-assigned name, which is only unique within the same service that + // originally returns it. If you use the default HTTP mapping, the + // `name` should be a resource name ending with `operations/{unique_id}`. + string name = 1; + + // Service-specific metadata associated with the operation. It typically + // contains progress information and common metadata such as create time. + // Some services might not provide such metadata. Any method that returns a + // long-running operation should document the metadata type, if any. + google.protobuf.Any metadata = 2; + + // If the value is `false`, it means the operation is still in progress. + // If `true`, the operation is completed, and either `error` or `response` is + // available. + bool done = 3; + + // The operation result, which can be either an `error` or a valid `response`. + // If `done` == `false`, neither `error` nor `response` is set. + // If `done` == `true`, exactly one of `error` or `response` can be set. + // Some services might not provide the result. + oneof result { + // The error result of the operation in case of failure or cancellation. + google.rpc.Status error = 4; + + // The normal, successful response of the operation. If the original + // method returns no data on success, such as `Delete`, the response is + // `google.protobuf.Empty`. If the original method is standard + // `Get`/`Create`/`Update`, the response should be the resource. For other + // methods, the response should have the type `XxxResponse`, where `Xxx` + // is the original method name. For example, if the original method name + // is `TakeSnapshot()`, the inferred response type is + // `TakeSnapshotResponse`. + google.protobuf.Any response = 5; + } +} + +// The request message for +// [Operations.GetOperation][google.longrunning.Operations.GetOperation]. +message GetOperationRequest { + // The name of the operation resource. + string name = 1; +} + +// The request message for +// [Operations.ListOperations][google.longrunning.Operations.ListOperations]. +message ListOperationsRequest { + // The name of the operation's parent resource. + string name = 4; + + // The standard list filter. + string filter = 1; + + // The standard list page size. + int32 page_size = 2; + + // The standard list page token. + string page_token = 3; + + // When set to `true`, operations that are reachable are returned as normal, + // and those that are unreachable are returned in the + // [ListOperationsResponse.unreachable] field. + // + // This can only be `true` when reading across collections e.g. when `parent` + // is set to `"projects/example/locations/-"`. + // + // This field is not by default supported and will result in an + // `UNIMPLEMENTED` error if set unless explicitly documented otherwise in + // service or product specific documentation. + bool return_partial_success = 5; +} + +// The response message for +// [Operations.ListOperations][google.longrunning.Operations.ListOperations]. +message ListOperationsResponse { + // A list of operations that matches the specified filter in the request. + repeated Operation operations = 1; + + // The standard List next-page token. + string next_page_token = 2; + + // Unordered list. Unreachable resources. Populated when the request sets + // `ListOperationsRequest.return_partial_success` and reads across + // collections e.g. when attempting to list all resources across all supported + // locations. + repeated string unreachable = 3 + [(google.api.field_behavior) = UNORDERED_LIST]; +} + +// The request message for +// [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]. +message CancelOperationRequest { + // The name of the operation resource to be cancelled. + string name = 1; +} + +// The request message for +// [Operations.DeleteOperation][google.longrunning.Operations.DeleteOperation]. +message DeleteOperationRequest { + // The name of the operation resource to be deleted. + string name = 1; +} + +// The request message for +// [Operations.WaitOperation][google.longrunning.Operations.WaitOperation]. +message WaitOperationRequest { + // The name of the operation resource to wait on. + string name = 1; + + // The maximum duration to wait before timing out. If left blank, the wait + // will be at most the time permitted by the underlying HTTP/RPC protocol. + // If RPC context deadline is also specified, the shorter one will be used. + google.protobuf.Duration timeout = 2; +} + +// A message representing the message types used by a long-running operation. +// +// Example: +// +// rpc Export(ExportRequest) returns (google.longrunning.Operation) { +// option (google.longrunning.operation_info) = { +// response_type: "ExportResponse" +// metadata_type: "ExportMetadata" +// }; +// } +message OperationInfo { + // Required. The message name of the primary return type for this + // long-running operation. + // This type will be used to deserialize the LRO's response. + // + // If the response is in a different package from the rpc, a fully-qualified + // message name must be used (e.g. `google.protobuf.Struct`). + // + // Note: Altering this value constitutes a breaking change. + string response_type = 1; + + // Required. The message name of the metadata type for this long-running + // operation. + // + // If the response is in a different package from the rpc, a fully-qualified + // message name must be used (e.g. `google.protobuf.Struct`). + // + // Note: Altering this value constitutes a breaking change. + string metadata_type = 2; +} diff --git a/third_party/google/protobuf/any.proto b/third_party/google/protobuf/any.proto new file mode 100644 index 00000000..eff44e50 --- /dev/null +++ b/third_party/google/protobuf/any.proto @@ -0,0 +1,162 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option go_package = "google.golang.org/protobuf/types/known/anypb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "AnyProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; + +// `Any` contains an arbitrary serialized protocol buffer message along with a +// URL that describes the type of the serialized message. +// +// Protobuf library provides support to pack/unpack Any values in the form +// of utility functions or additional generated methods of the Any type. +// +// Example 1: Pack and unpack a message in C++. +// +// Foo foo = ...; +// Any any; +// any.PackFrom(foo); +// ... +// if (any.UnpackTo(&foo)) { +// ... +// } +// +// Example 2: Pack and unpack a message in Java. +// +// Foo foo = ...; +// Any any = Any.pack(foo); +// ... +// if (any.is(Foo.class)) { +// foo = any.unpack(Foo.class); +// } +// // or ... +// if (any.isSameTypeAs(Foo.getDefaultInstance())) { +// foo = any.unpack(Foo.getDefaultInstance()); +// } +// +// Example 3: Pack and unpack a message in Python. +// +// foo = Foo(...) +// any = Any() +// any.Pack(foo) +// ... +// if any.Is(Foo.DESCRIPTOR): +// any.Unpack(foo) +// ... +// +// Example 4: Pack and unpack a message in Go +// +// foo := &pb.Foo{...} +// any, err := anypb.New(foo) +// if err != nil { +// ... +// } +// ... +// foo := &pb.Foo{} +// if err := any.UnmarshalTo(foo); err != nil { +// ... +// } +// +// The pack methods provided by protobuf library will by default use +// 'type.googleapis.com/full.type.name' as the type URL and the unpack +// methods only use the fully qualified type name after the last '/' +// in the type URL, for example "foo.bar.com/x/y.z" will yield type +// name "y.z". +// +// JSON +// ==== +// The JSON representation of an `Any` value uses the regular +// representation of the deserialized, embedded message, with an +// additional field `@type` which contains the type URL. Example: +// +// package google.profile; +// message Person { +// string first_name = 1; +// string last_name = 2; +// } +// +// { +// "@type": "type.googleapis.com/google.profile.Person", +// "firstName": , +// "lastName": +// } +// +// If the embedded message type is well-known and has a custom JSON +// representation, that representation will be embedded adding a field +// `value` which holds the custom JSON in addition to the `@type` +// field. Example (for message [google.protobuf.Duration][]): +// +// { +// "@type": "type.googleapis.com/google.protobuf.Duration", +// "value": "1.212s" +// } +// +message Any { + // A URL/resource name that uniquely identifies the type of the serialized + // protocol buffer message. This string must contain at least + // one "/" character. The last segment of the URL's path must represent + // the fully qualified name of the type (as in + // `path/google.protobuf.Duration`). The name should be in a canonical form + // (e.g., leading "." is not accepted). + // + // In practice, teams usually precompile into the binary all types that they + // expect it to use in the context of Any. However, for URLs which use the + // scheme `http`, `https`, or no scheme, one can optionally set up a type + // server that maps type URLs to message definitions as follows: + // + // * If no scheme is provided, `https` is assumed. + // * An HTTP GET on the URL must yield a [google.protobuf.Type][] + // value in binary format, or produce an error. + // * Applications are allowed to cache lookup results based on the + // URL, or have them precompiled into a binary to avoid any + // lookup. Therefore, binary compatibility needs to be preserved + // on changes to types. (Use versioned type names to manage + // breaking changes.) + // + // Note: this functionality is not currently available in the official + // protobuf release, and it is not used for type URLs beginning with + // type.googleapis.com. As of May 2023, there are no widely used type server + // implementations and no plans to implement one. + // + // Schemes other than `http`, `https` (or the empty scheme) might be + // used with implementation specific semantics. + // + string type_url = 1; + + // Must be a valid serialized protocol buffer of the above specified type. + bytes value = 2; +} diff --git a/third_party/google/protobuf/api.proto b/third_party/google/protobuf/api.proto new file mode 100644 index 00000000..c8f74254 --- /dev/null +++ b/third_party/google/protobuf/api.proto @@ -0,0 +1,229 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +import "google/protobuf/source_context.proto"; +import "google/protobuf/type.proto"; + +option java_package = "com.google.protobuf"; +option java_outer_classname = "ApiProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option go_package = "google.golang.org/protobuf/types/known/apipb"; + +// Api is a light-weight descriptor for an API Interface. +// +// Interfaces are also described as "protocol buffer services" in some contexts, +// such as by the "service" keyword in a .proto file, but they are different +// from API Services, which represent a concrete implementation of an interface +// as opposed to simply a description of methods and bindings. They are also +// sometimes simply referred to as "APIs" in other contexts, such as the name of +// this message itself. See https://cloud.google.com/apis/design/glossary for +// detailed terminology. +// +// New usages of this message as an alternative to ServiceDescriptorProto are +// strongly discouraged. This message does not reliability preserve all +// information necessary to model the schema and preserve semantics. Instead +// make use of FileDescriptorSet which preserves the necessary information. +message Api { + // The fully qualified name of this interface, including package name + // followed by the interface's simple name. + string name = 1; + + // The methods of this interface, in unspecified order. + repeated Method methods = 2; + + // Any metadata attached to the interface. + repeated Option options = 3; + + // A version string for this interface. If specified, must have the form + // `major-version.minor-version`, as in `1.10`. If the minor version is + // omitted, it defaults to zero. If the entire version field is empty, the + // major version is derived from the package name, as outlined below. If the + // field is not empty, the version in the package name will be verified to be + // consistent with what is provided here. + // + // The versioning schema uses [semantic + // versioning](http://semver.org) where the major version number + // indicates a breaking change and the minor version an additive, + // non-breaking change. Both version numbers are signals to users + // what to expect from different versions, and should be carefully + // chosen based on the product plan. + // + // The major version is also reflected in the package name of the + // interface, which must end in `v`, as in + // `google.feature.v1`. For major versions 0 and 1, the suffix can + // be omitted. Zero major versions must only be used for + // experimental, non-GA interfaces. + // + string version = 4; + + // Source context for the protocol buffer service represented by this + // message. + SourceContext source_context = 5; + + // Included interfaces. See [Mixin][]. + repeated Mixin mixins = 6; + + // The source syntax of the service. + Syntax syntax = 7; + + // The source edition string, only valid when syntax is SYNTAX_EDITIONS. + string edition = 8; +} + +// Method represents a method of an API interface. +// +// New usages of this message as an alternative to MethodDescriptorProto are +// strongly discouraged. This message does not reliability preserve all +// information necessary to model the schema and preserve semantics. Instead +// make use of FileDescriptorSet which preserves the necessary information. +message Method { + // The simple name of this method. + string name = 1; + + // A URL of the input message type. + string request_type_url = 2; + + // If true, the request is streamed. + bool request_streaming = 3; + + // The URL of the output message type. + string response_type_url = 4; + + // If true, the response is streamed. + bool response_streaming = 5; + + // Any metadata attached to the method. + repeated Option options = 6; + + // The source syntax of this method. + // + // This field should be ignored, instead the syntax should be inherited from + // Api. This is similar to Field and EnumValue. + Syntax syntax = 7 [deprecated = true]; + + // The source edition string, only valid when syntax is SYNTAX_EDITIONS. + // + // This field should be ignored, instead the edition should be inherited from + // Api. This is similar to Field and EnumValue. + string edition = 8 [deprecated = true]; +} + +// Declares an API Interface to be included in this interface. The including +// interface must redeclare all the methods from the included interface, but +// documentation and options are inherited as follows: +// +// - If after comment and whitespace stripping, the documentation +// string of the redeclared method is empty, it will be inherited +// from the original method. +// +// - Each annotation belonging to the service config (http, +// visibility) which is not set in the redeclared method will be +// inherited. +// +// - If an http annotation is inherited, the path pattern will be +// modified as follows. Any version prefix will be replaced by the +// version of the including interface plus the [root][] path if +// specified. +// +// Example of a simple mixin: +// +// package google.acl.v1; +// service AccessControl { +// // Get the underlying ACL object. +// rpc GetAcl(GetAclRequest) returns (Acl) { +// option (google.api.http).get = "/v1/{resource=**}:getAcl"; +// } +// } +// +// package google.storage.v2; +// service Storage { +// rpc GetAcl(GetAclRequest) returns (Acl); +// +// // Get a data record. +// rpc GetData(GetDataRequest) returns (Data) { +// option (google.api.http).get = "/v2/{resource=**}"; +// } +// } +// +// Example of a mixin configuration: +// +// apis: +// - name: google.storage.v2.Storage +// mixins: +// - name: google.acl.v1.AccessControl +// +// The mixin construct implies that all methods in `AccessControl` are +// also declared with same name and request/response types in +// `Storage`. A documentation generator or annotation processor will +// see the effective `Storage.GetAcl` method after inheriting +// documentation and annotations as follows: +// +// service Storage { +// // Get the underlying ACL object. +// rpc GetAcl(GetAclRequest) returns (Acl) { +// option (google.api.http).get = "/v2/{resource=**}:getAcl"; +// } +// ... +// } +// +// Note how the version in the path pattern changed from `v1` to `v2`. +// +// If the `root` field in the mixin is specified, it should be a +// relative path under which inherited HTTP paths are placed. Example: +// +// apis: +// - name: google.storage.v2.Storage +// mixins: +// - name: google.acl.v1.AccessControl +// root: acls +// +// This implies the following inherited HTTP annotation: +// +// service Storage { +// // Get the underlying ACL object. +// rpc GetAcl(GetAclRequest) returns (Acl) { +// option (google.api.http).get = "/v2/acls/{resource=**}:getAcl"; +// } +// ... +// } +message Mixin { + // The fully qualified name of the interface which is included. + string name = 1; + + // If non-empty specifies a path under which inherited HTTP paths + // are rooted. + string root = 2; +} diff --git a/third_party/google/protobuf/compiler/plugin.proto b/third_party/google/protobuf/compiler/plugin.proto new file mode 100644 index 00000000..10d285f8 --- /dev/null +++ b/third_party/google/protobuf/compiler/plugin.proto @@ -0,0 +1,180 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +// Author: kenton@google.com (Kenton Varda) +// +// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is +// just a program that reads a CodeGeneratorRequest from stdin and writes a +// CodeGeneratorResponse to stdout. +// +// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead +// of dealing with the raw protocol defined here. +// +// A plugin executable needs only to be placed somewhere in the path. The +// plugin should be named "protoc-gen-$NAME", and will then be used when the +// flag "--${NAME}_out" is passed to protoc. + +syntax = "proto2"; + +package google.protobuf.compiler; +option java_package = "com.google.protobuf.compiler"; +option java_outer_classname = "PluginProtos"; + +import "google/protobuf/descriptor.proto"; + +option csharp_namespace = "Google.Protobuf.Compiler"; +option go_package = "google.golang.org/protobuf/types/pluginpb"; + +// The version number of protocol compiler. +message Version { + optional int32 major = 1; + optional int32 minor = 2; + optional int32 patch = 3; + // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should + // be empty for mainline stable releases. + optional string suffix = 4; +} + +// An encoded CodeGeneratorRequest is written to the plugin's stdin. +message CodeGeneratorRequest { + // The .proto files that were explicitly listed on the command-line. The + // code generator should generate code only for these files. Each file's + // descriptor will be included in proto_file, below. + repeated string file_to_generate = 1; + + // The generator parameter passed on the command-line. + optional string parameter = 2; + + // FileDescriptorProtos for all files in files_to_generate and everything + // they import. The files will appear in topological order, so each file + // appears before any file that imports it. + // + // Note: the files listed in files_to_generate will include runtime-retention + // options only, but all other files will include source-retention options. + // The source_file_descriptors field below is available in case you need + // source-retention options for files_to_generate. + // + // protoc guarantees that all proto_files will be written after + // the fields above, even though this is not technically guaranteed by the + // protobuf wire format. This theoretically could allow a plugin to stream + // in the FileDescriptorProtos and handle them one by one rather than read + // the entire set into memory at once. However, as of this writing, this + // is not similarly optimized on protoc's end -- it will store all fields in + // memory at once before sending them to the plugin. + // + // Type names of fields and extensions in the FileDescriptorProto are always + // fully qualified. + repeated FileDescriptorProto proto_file = 15; + + // File descriptors with all options, including source-retention options. + // These descriptors are only provided for the files listed in + // files_to_generate. + repeated FileDescriptorProto source_file_descriptors = 17; + + // The version number of protocol compiler. + optional Version compiler_version = 3; +} + +// The plugin writes an encoded CodeGeneratorResponse to stdout. +message CodeGeneratorResponse { + // Error message. If non-empty, code generation failed. The plugin process + // should exit with status code zero even if it reports an error in this way. + // + // This should be used to indicate errors in .proto files which prevent the + // code generator from generating correct code. Errors which indicate a + // problem in protoc itself -- such as the input CodeGeneratorRequest being + // unparseable -- should be reported by writing a message to stderr and + // exiting with a non-zero status code. + optional string error = 1; + + // A bitmask of supported features that the code generator supports. + // This is a bitwise "or" of values from the Feature enum. + optional uint64 supported_features = 2; + + // Sync with code_generator.h. + enum Feature { + FEATURE_NONE = 0; + FEATURE_PROTO3_OPTIONAL = 1; + FEATURE_SUPPORTS_EDITIONS = 2; + } + + // The minimum edition this plugin supports. This will be treated as an + // Edition enum, but we want to allow unknown values. It should be specified + // according the edition enum value, *not* the edition number. Only takes + // effect for plugins that have FEATURE_SUPPORTS_EDITIONS set. + optional int32 minimum_edition = 3; + + // The maximum edition this plugin supports. This will be treated as an + // Edition enum, but we want to allow unknown values. It should be specified + // according the edition enum value, *not* the edition number. Only takes + // effect for plugins that have FEATURE_SUPPORTS_EDITIONS set. + optional int32 maximum_edition = 4; + + // Represents a single generated file. + message File { + // The file name, relative to the output directory. The name must not + // contain "." or ".." components and must be relative, not be absolute (so, + // the file cannot lie outside the output directory). "/" must be used as + // the path separator, not "\". + // + // If the name is omitted, the content will be appended to the previous + // file. This allows the generator to break large files into small chunks, + // and allows the generated text to be streamed back to protoc so that large + // files need not reside completely in memory at one time. Note that as of + // this writing protoc does not optimize for this -- it will read the entire + // CodeGeneratorResponse before writing files to disk. + optional string name = 1; + + // If non-empty, indicates that the named file should already exist, and the + // content here is to be inserted into that file at a defined insertion + // point. This feature allows a code generator to extend the output + // produced by another code generator. The original generator may provide + // insertion points by placing special annotations in the file that look + // like: + // @@protoc_insertion_point(NAME) + // The annotation can have arbitrary text before and after it on the line, + // which allows it to be placed in a comment. NAME should be replaced with + // an identifier naming the point -- this is what other generators will use + // as the insertion_point. Code inserted at this point will be placed + // immediately above the line containing the insertion point (thus multiple + // insertions to the same point will come out in the order they were added). + // The double-@ is intended to make it unlikely that the generated code + // could contain things that look like insertion points by accident. + // + // For example, the C++ code generator places the following line in the + // .pb.h files that it generates: + // // @@protoc_insertion_point(namespace_scope) + // This line appears within the scope of the file's package namespace, but + // outside of any particular class. Another plugin can then specify the + // insertion_point "namespace_scope" to generate additional classes or + // other declarations that should be placed in this scope. + // + // Note that if the line containing the insertion point begins with + // whitespace, the same whitespace will be added to every line of the + // inserted text. This is useful for languages like Python, where + // indentation matters. In these languages, the insertion point comment + // should be indented the same amount as any inserted code will need to be + // in order to work correctly in that context. + // + // The code generator that generates the initial file and the one which + // inserts into it must both run as part of a single invocation of protoc. + // Code generators are executed in the order in which they appear on the + // command line. + // + // If |insertion_point| is present, |name| must also be present. + optional string insertion_point = 2; + + // The file contents. + optional string content = 15; + + // Information describing the file content being inserted. If an insertion + // point is used, this information will be appropriately offset and inserted + // into the code generation metadata for the generated files. + optional GeneratedCodeInfo generated_code_info = 16; + } + repeated File file = 15; +} diff --git a/third_party/google/protobuf/cpp_features.proto b/third_party/google/protobuf/cpp_features.proto new file mode 100644 index 00000000..75bf6b85 --- /dev/null +++ b/third_party/google/protobuf/cpp_features.proto @@ -0,0 +1,67 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +syntax = "proto2"; + +package pb; + +import "google/protobuf/descriptor.proto"; + +extend google.protobuf.FeatureSet { + optional CppFeatures cpp = 1000; +} + +message CppFeatures { + // Whether or not to treat an enum field as closed. This option is only + // applicable to enum fields, and will be removed in the future. It is + // consistent with the legacy behavior of using proto3 enum types for proto2 + // fields. + optional bool legacy_closed_enum = 1 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + edition_deprecated: EDITION_2023, + deprecation_warning: "The legacy closed enum behavior in C++ is " + "deprecated and is scheduled to be removed in " + "edition 2025. See http://protobuf.dev/programming-guides/enum/#cpp for " + "more information", + }, + edition_defaults = { edition: EDITION_LEGACY, value: "true" }, + edition_defaults = { edition: EDITION_PROTO3, value: "false" } + ]; + + enum StringType { + STRING_TYPE_UNKNOWN = 0; + VIEW = 1; + CORD = 2; + STRING = 3; + } + + optional StringType string_type = 2 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "STRING" }, + edition_defaults = { edition: EDITION_2024, value: "VIEW" } + ]; + + optional bool enum_name_uses_string_view = 3 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "false" }, + edition_defaults = { edition: EDITION_2024, value: "true" } + ]; +} diff --git a/third_party/google/protobuf/descriptor.proto b/third_party/google/protobuf/descriptor.proto new file mode 100644 index 00000000..333b7e99 --- /dev/null +++ b/third_party/google/protobuf/descriptor.proto @@ -0,0 +1,1426 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// The messages in this file describe the definitions found in .proto files. +// A valid .proto file can be translated directly to a FileDescriptorProto +// without any other information (e.g. without reading its imports). + +syntax = "proto2"; + +package google.protobuf; + +option go_package = "google.golang.org/protobuf/types/descriptorpb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "DescriptorProtos"; +option csharp_namespace = "Google.Protobuf.Reflection"; +option objc_class_prefix = "GPB"; +option cc_enable_arenas = true; + +// descriptor.proto must be optimized for speed because reflection-based +// algorithms don't work during bootstrapping. +option optimize_for = SPEED; + +// The protocol compiler can output a FileDescriptorSet containing the .proto +// files it parses. +message FileDescriptorSet { + repeated FileDescriptorProto file = 1; + + // Extensions for tooling. + extensions 536000000 [declaration = { + number: 536000000 + type: ".buf.descriptor.v1.FileDescriptorSetExtension" + full_name: ".buf.descriptor.v1.buf_file_descriptor_set_extension" + }]; +} + +// The full set of known editions. +enum Edition { + // A placeholder for an unknown edition value. + EDITION_UNKNOWN = 0; + + // A placeholder edition for specifying default behaviors *before* a feature + // was first introduced. This is effectively an "infinite past". + EDITION_LEGACY = 900; + + // Legacy syntax "editions". These pre-date editions, but behave much like + // distinct editions. These can't be used to specify the edition of proto + // files, but feature definitions must supply proto2/proto3 defaults for + // backwards compatibility. + EDITION_PROTO2 = 998; + EDITION_PROTO3 = 999; + + // Editions that have been released. The specific values are arbitrary and + // should not be depended on, but they will always be time-ordered for easy + // comparison. + EDITION_2023 = 1000; + EDITION_2024 = 1001; + + // Placeholder editions for testing feature resolution. These should not be + // used or relied on outside of tests. + EDITION_1_TEST_ONLY = 1; + EDITION_2_TEST_ONLY = 2; + EDITION_99997_TEST_ONLY = 99997; + EDITION_99998_TEST_ONLY = 99998; + EDITION_99999_TEST_ONLY = 99999; + + // Placeholder for specifying unbounded edition support. This should only + // ever be used by plugins that can expect to never require any changes to + // support a new edition. + EDITION_MAX = 0x7FFFFFFF; +} + +// Describes a complete .proto file. +message FileDescriptorProto { + optional string name = 1; // file name, relative to root of source tree + optional string package = 2; // e.g. "foo", "foo.bar", etc. + + // Names of files imported by this file. + repeated string dependency = 3; + // Indexes of the public imported files in the dependency list above. + repeated int32 public_dependency = 10; + // Indexes of the weak imported files in the dependency list. + // For Google-internal migration only. Do not use. + repeated int32 weak_dependency = 11; + + // Names of files imported by this file purely for the purpose of providing + // option extensions. These are excluded from the dependency list above. + repeated string option_dependency = 15; + + // All top-level definitions in this file. + repeated DescriptorProto message_type = 4; + repeated EnumDescriptorProto enum_type = 5; + repeated ServiceDescriptorProto service = 6; + repeated FieldDescriptorProto extension = 7; + + optional FileOptions options = 8; + + // This field contains optional information about the original source code. + // You may safely remove this entire field without harming runtime + // functionality of the descriptors -- the information is needed only by + // development tools. + optional SourceCodeInfo source_code_info = 9; + + // The syntax of the proto file. + // The supported values are "proto2", "proto3", and "editions". + // + // If `edition` is present, this value must be "editions". + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. + optional string syntax = 12; + + // The edition of the proto file. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. + optional Edition edition = 14; +} + +// Describes a message type. +message DescriptorProto { + optional string name = 1; + + repeated FieldDescriptorProto field = 2; + repeated FieldDescriptorProto extension = 6; + + repeated DescriptorProto nested_type = 3; + repeated EnumDescriptorProto enum_type = 4; + + message ExtensionRange { + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Exclusive. + + optional ExtensionRangeOptions options = 3; + } + repeated ExtensionRange extension_range = 5; + + repeated OneofDescriptorProto oneof_decl = 8; + + optional MessageOptions options = 7; + + // Range of reserved tag numbers. Reserved tag numbers may not be used by + // fields or extension ranges in the same message. Reserved ranges may + // not overlap. + message ReservedRange { + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Exclusive. + } + repeated ReservedRange reserved_range = 9; + // Reserved field names, which may not be used by fields in the same message. + // A given name may only be reserved once. + repeated string reserved_name = 10; + + // Support for `export` and `local` keywords on enums. + optional SymbolVisibility visibility = 11; +} + +message ExtensionRangeOptions { + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + message Declaration { + // The extension number declared within the extension range. + optional int32 number = 1; + + // The fully-qualified name of the extension field. There must be a leading + // dot in front of the full name. + optional string full_name = 2; + + // The fully-qualified type name of the extension field. Unlike + // Metadata.type, Declaration.type must have a leading dot for messages + // and enums. + optional string type = 3; + + // If true, indicates that the number is reserved in the extension range, + // and any extension field with the number will fail to compile. Set this + // when a declared extension field is deleted. + optional bool reserved = 5; + + // If true, indicates that the extension must be defined as repeated. + // Otherwise the extension must be defined as optional. + optional bool repeated = 6; + + reserved 4; // removed is_repeated + } + + // For external users: DO NOT USE. We are in the process of open sourcing + // extension declaration and executing internal cleanups before it can be + // used externally. + repeated Declaration declaration = 2 [retention = RETENTION_SOURCE]; + + // Any features defined in the specific edition. + optional FeatureSet features = 50; + + // The verification state of the extension range. + enum VerificationState { + // All the extensions of the range must be declared. + DECLARATION = 0; + UNVERIFIED = 1; + } + + // The verification state of the range. + // TODO: flip the default to DECLARATION once all empty ranges + // are marked as UNVERIFIED. + optional VerificationState verification = 3 + [default = UNVERIFIED, retention = RETENTION_SOURCE]; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +// Describes a field within a message. +message FieldDescriptorProto { + enum Type { + // 0 is reserved for errors. + // Order is weird for historical reasons. + TYPE_DOUBLE = 1; + TYPE_FLOAT = 2; + // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + // negative values are likely. + TYPE_INT64 = 3; + TYPE_UINT64 = 4; + // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + // negative values are likely. + TYPE_INT32 = 5; + TYPE_FIXED64 = 6; + TYPE_FIXED32 = 7; + TYPE_BOOL = 8; + TYPE_STRING = 9; + // Tag-delimited aggregate. + // Group type is deprecated and not supported after google.protobuf. However, Proto3 + // implementations should still be able to parse the group wire format and + // treat group fields as unknown fields. In Editions, the group wire format + // can be enabled via the `message_encoding` feature. + TYPE_GROUP = 10; + TYPE_MESSAGE = 11; // Length-delimited aggregate. + + // New in version 2. + TYPE_BYTES = 12; + TYPE_UINT32 = 13; + TYPE_ENUM = 14; + TYPE_SFIXED32 = 15; + TYPE_SFIXED64 = 16; + TYPE_SINT32 = 17; // Uses ZigZag encoding. + TYPE_SINT64 = 18; // Uses ZigZag encoding. + } + + enum Label { + // 0 is reserved for errors + LABEL_OPTIONAL = 1; + LABEL_REPEATED = 3; + // The required label is only allowed in google.protobuf. In proto3 and Editions + // it's explicitly prohibited. In Editions, the `field_presence` feature + // can be used to get this behavior. + LABEL_REQUIRED = 2; + } + + optional string name = 1; + optional int32 number = 3; + optional Label label = 4; + + // If type_name is set, this need not be set. If both this and type_name + // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + optional Type type = 5; + + // For message and enum types, this is the name of the type. If the name + // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + // rules are used to find the type (i.e. first the nested types within this + // message are searched, then within the parent, on up to the root + // namespace). + optional string type_name = 6; + + // For extensions, this is the name of the type being extended. It is + // resolved in the same manner as type_name. + optional string extendee = 2; + + // For numeric types, contains the original text representation of the value. + // For booleans, "true" or "false". + // For strings, contains the default text contents (not escaped in any way). + // For bytes, contains the C escaped value. All bytes >= 128 are escaped. + optional string default_value = 7; + + // If set, gives the index of a oneof in the containing type's oneof_decl + // list. This field is a member of that oneof. + optional int32 oneof_index = 9; + + // JSON name of this field. The value is set by protocol compiler. If the + // user has set a "json_name" option on this field, that option's value + // will be used. Otherwise, it's deduced from the field's name by converting + // it to camelCase. + optional string json_name = 10; + + optional FieldOptions options = 8; + + // If true, this is a proto3 "optional". When a proto3 field is optional, it + // tracks presence regardless of field type. + // + // When proto3_optional is true, this field must belong to a oneof to signal + // to old proto3 clients that presence is tracked for this field. This oneof + // is known as a "synthetic" oneof, and this field must be its sole member + // (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs + // exist in the descriptor only, and do not generate any API. Synthetic oneofs + // must be ordered after all "real" oneofs. + // + // For message fields, proto3_optional doesn't create any semantic change, + // since non-repeated message fields always track presence. However it still + // indicates the semantic detail of whether the user wrote "optional" or not. + // This can be useful for round-tripping the .proto file. For consistency we + // give message fields a synthetic oneof also, even though it is not required + // to track presence. This is especially important because the parser can't + // tell if a field is a message or an enum, so it must always create a + // synthetic oneof. + // + // Proto2 optional fields do not set this flag, because they already indicate + // optional with `LABEL_OPTIONAL`. + optional bool proto3_optional = 17; +} + +// Describes a oneof. +message OneofDescriptorProto { + optional string name = 1; + optional OneofOptions options = 2; +} + +// Describes an enum type. +message EnumDescriptorProto { + optional string name = 1; + + repeated EnumValueDescriptorProto value = 2; + + optional EnumOptions options = 3; + + // Range of reserved numeric values. Reserved values may not be used by + // entries in the same enum. Reserved ranges may not overlap. + // + // Note that this is distinct from DescriptorProto.ReservedRange in that it + // is inclusive such that it can appropriately represent the entire int32 + // domain. + message EnumReservedRange { + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Inclusive. + } + + // Range of reserved numeric values. Reserved numeric values may not be used + // by enum values in the same enum declaration. Reserved ranges may not + // overlap. + repeated EnumReservedRange reserved_range = 4; + + // Reserved enum value names, which may not be reused. A given name may only + // be reserved once. + repeated string reserved_name = 5; + + // Support for `export` and `local` keywords on enums. + optional SymbolVisibility visibility = 6; +} + +// Describes a value within an enum. +message EnumValueDescriptorProto { + optional string name = 1; + optional int32 number = 2; + + optional EnumValueOptions options = 3; +} + +// Describes a service. +message ServiceDescriptorProto { + optional string name = 1; + repeated MethodDescriptorProto method = 2; + + optional ServiceOptions options = 3; + + reserved 4; + reserved "stream"; +} + +// Describes a method of a service. +message MethodDescriptorProto { + optional string name = 1; + + // Input and output type names. These are resolved in the same way as + // FieldDescriptorProto.type_name, but must refer to a message type. + optional string input_type = 2; + optional string output_type = 3; + + optional MethodOptions options = 4; + + // Identifies if client streams multiple client messages + optional bool client_streaming = 5 [default = false]; + // Identifies if server streams multiple server messages + optional bool server_streaming = 6 [default = false]; +} + +// =================================================================== +// Options + +// Each of the definitions above may have "options" attached. These are +// just annotations which may cause code to be generated slightly differently +// or may contain hints for code that manipulates protocol messages. +// +// Clients may define custom options as extensions of the *Options messages. +// These extensions may not yet be known at parsing time, so the parser cannot +// store the values in them. Instead it stores them in a field in the *Options +// message called uninterpreted_option. This field must have the same name +// across all *Options messages. We then use this field to populate the +// extensions when we build a descriptor, at which point all protos have been +// parsed and so all extensions are known. +// +// Extension numbers for custom options may be chosen as follows: +// * For options which will only be used within a single application or +// organization, or for experimental options, use field numbers 50000 +// through 99999. It is up to you to ensure that you do not use the +// same number for multiple options. +// * For options which will be published and used publicly by multiple +// independent entities, e-mail protobuf-global-extension-registry@google.com +// to reserve extension numbers. Simply provide your project name (e.g. +// Objective-C plugin) and your project website (if available) -- there's no +// need to explain how you intend to use them. Usually you only need one +// extension number. You can declare multiple options with only one extension +// number by putting them in a sub-message. See the Custom Options section of +// the docs for examples: +// https://developers.google.com/protocol-buffers/docs/proto#options +// If this turns out to be popular, a web service will be set up +// to automatically assign option numbers. + +message FileOptions { + + // Sets the Java package where classes generated from this .proto will be + // placed. By default, the proto package is used, but this is often + // inappropriate because proto packages do not normally start with backwards + // domain names. + optional string java_package = 1; + + // Controls the name of the wrapper Java class generated for the .proto file. + // That class will always contain the .proto file's getDescriptor() method as + // well as any top-level extensions defined in the .proto file. + // If java_multiple_files is disabled, then all the other classes from the + // .proto file will be nested inside the single wrapper outer class. + optional string java_outer_classname = 8; + + // If enabled, then the Java code generator will generate a separate .java + // file for each top-level message, enum, and service defined in the .proto + // file. Thus, these types will *not* be nested inside the wrapper class + // named by java_outer_classname. However, the wrapper class will still be + // generated to contain the file's getDescriptor() method as well as any + // top-level extensions defined in the file. + optional bool java_multiple_files = 10 [default = false]; + + // This option does nothing. + optional bool java_generate_equals_and_hash = 20 [deprecated=true]; + + // A proto2 file can set this to true to opt in to UTF-8 checking for Java, + // which will throw an exception if invalid UTF-8 is parsed from the wire or + // assigned to a string field. + // + // TODO: clarify exactly what kinds of field types this option + // applies to, and update these docs accordingly. + // + // Proto3 files already perform these checks. Setting the option explicitly to + // false has no effect: it cannot be used to opt proto3 files out of UTF-8 + // checks. + optional bool java_string_check_utf8 = 27 [default = false]; + + // Generated classes can be optimized for speed or code size. + enum OptimizeMode { + SPEED = 1; // Generate complete code for parsing, serialization, + // etc. + CODE_SIZE = 2; // Use ReflectionOps to implement these methods. + LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. + } + optional OptimizeMode optimize_for = 9 [default = SPEED]; + + // Sets the Go package where structs generated from this .proto will be + // placed. If omitted, the Go package will be derived from the following: + // - The basename of the package import path, if provided. + // - Otherwise, the package statement in the .proto file, if present. + // - Otherwise, the basename of the .proto file, without extension. + optional string go_package = 11; + + // Should generic services be generated in each language? "Generic" services + // are not specific to any particular RPC system. They are generated by the + // main code generators in each language (without additional plugins). + // Generic services were the only kind of service generation supported by + // early versions of google.protobuf. + // + // Generic services are now considered deprecated in favor of using plugins + // that generate code specific to your particular RPC system. Therefore, + // these default to false. Old code which depends on generic services should + // explicitly set them to true. + optional bool cc_generic_services = 16 [default = false]; + optional bool java_generic_services = 17 [default = false]; + optional bool py_generic_services = 18 [default = false]; + reserved 42; // removed php_generic_services + reserved "php_generic_services"; + + // Is this file deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for everything in the file, or it will be completely ignored; in the very + // least, this is a formalization for deprecating files. + optional bool deprecated = 23 [default = false]; + + // Enables the use of arenas for the proto messages in this file. This applies + // only to generated classes for C++. + optional bool cc_enable_arenas = 31 [default = true]; + + // Sets the objective c class prefix which is prepended to all objective c + // generated classes from this .proto. There is no default. + optional string objc_class_prefix = 36; + + // Namespace for generated classes; defaults to the package. + optional string csharp_namespace = 37; + + // By default Swift generators will take the proto package and CamelCase it + // replacing '.' with underscore and use that to prefix the types/symbols + // defined. When this options is provided, they will use this value instead + // to prefix the types/symbols defined. + optional string swift_prefix = 39; + + // Sets the php class prefix which is prepended to all php generated classes + // from this .proto. Default is empty. + optional string php_class_prefix = 40; + + // Use this option to change the namespace of php generated classes. Default + // is empty. When this option is empty, the package name will be used for + // determining the namespace. + optional string php_namespace = 41; + + // Use this option to change the namespace of php generated metadata classes. + // Default is empty. When this option is empty, the proto file name will be + // used for determining the namespace. + optional string php_metadata_namespace = 44; + + // Use this option to change the package of ruby generated classes. Default + // is empty. When this option is not set, the package name will be used for + // determining the ruby package. + optional string ruby_package = 45; + + // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. + optional FeatureSet features = 50; + + // The parser stores options it doesn't recognize here. + // See the documentation for the "Options" section above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. + // See the documentation for the "Options" section above. + extensions 1000 to max; + + reserved 38; +} + +message MessageOptions { + // Set true to use the old proto1 MessageSet wire format for extensions. + // This is provided for backwards-compatibility with the MessageSet wire + // format. You should not use this for any other reason: It's less + // efficient, has fewer features, and is more complicated. + // + // The message must be defined exactly as follows: + // message Foo { + // option message_set_wire_format = true; + // extensions 4 to max; + // } + // Note that the message cannot have any defined fields; MessageSets only + // have extensions. + // + // All extensions of your type must be singular messages; e.g. they cannot + // be int32s, enums, or repeated messages. + // + // Because this is an option, the above two restrictions are not enforced by + // the protocol compiler. + optional bool message_set_wire_format = 1 [default = false]; + + // Disables the generation of the standard "descriptor()" accessor, which can + // conflict with a field of the same name. This is meant to make migration + // from proto1 easier; new code should avoid fields named "descriptor". + optional bool no_standard_descriptor_accessor = 2 [default = false]; + + // Is this message deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the message, or it will be completely ignored; in the very least, + // this is a formalization for deprecating messages. + optional bool deprecated = 3 [default = false]; + + reserved 4, 5, 6; + + // Whether the message is an automatically generated map entry type for the + // maps field. + // + // For maps fields: + // map map_field = 1; + // The parsed descriptor looks like: + // message MapFieldEntry { + // option map_entry = true; + // optional KeyType key = 1; + // optional ValueType value = 2; + // } + // repeated MapFieldEntry map_field = 1; + // + // Implementations may choose not to generate the map_entry=true message, but + // use a native map in the target language to hold the keys and values. + // The reflection APIs in such implementations still need to work as + // if the field is a repeated message field. + // + // NOTE: Do not set the option in .proto files. Always use the maps syntax + // instead. The option should only be implicitly set by the proto compiler + // parser. + optional bool map_entry = 7; + + reserved 8; // javalite_serializable + reserved 9; // javanano_as_lite + + // Enable the legacy handling of JSON field name conflicts. This lowercases + // and strips underscored from the fields before comparison in proto3 only. + // The new behavior takes `json_name` into account and applies to proto2 as + // well. + // + // This should only be used as a temporary measure against broken builds due + // to the change in behavior for JSON field name conflicts. + // + // TODO This is legacy behavior we plan to remove once downstream + // teams have had time to migrate. + optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true]; + + // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. + optional FeatureSet features = 12; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message FieldOptions { + // NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead. + // The ctype option instructs the C++ code generator to use a different + // representation of the field than it normally would. See the specific + // options below. This option is only implemented to support use of + // [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of + // type "bytes" in the open source release. + // TODO: make ctype actually deprecated. + optional CType ctype = 1 [/*deprecated = true,*/ default = STRING]; + enum CType { + // Default mode. + STRING = 0; + + // The option [ctype=CORD] may be applied to a non-repeated field of type + // "bytes". It indicates that in C++, the data should be stored in a Cord + // instead of a string. For very large strings, this may reduce memory + // fragmentation. It may also allow better performance when parsing from a + // Cord, or when parsing with aliasing enabled, as the parsed Cord may then + // alias the original buffer. + CORD = 1; + + STRING_PIECE = 2; + } + // The packed option can be enabled for repeated primitive fields to enable + // a more efficient representation on the wire. Rather than repeatedly + // writing the tag and type for each element, the entire array is encoded as + // a single length-delimited blob. In proto3, only explicit setting it to + // false will avoid using packed encoding. This option is prohibited in + // Editions, but the `repeated_field_encoding` feature can be used to control + // the behavior. + optional bool packed = 2; + + // The jstype option determines the JavaScript type used for values of the + // field. The option is permitted only for 64 bit integral and fixed types + // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + // is represented as JavaScript string, which avoids loss of precision that + // can happen when a large value is converted to a floating point JavaScript. + // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + // use the JavaScript "number" type. The behavior of the default option + // JS_NORMAL is implementation dependent. + // + // This option is an enum to permit additional types to be added, e.g. + // goog.math.Integer. + optional JSType jstype = 6 [default = JS_NORMAL]; + enum JSType { + // Use the default type. + JS_NORMAL = 0; + + // Use JavaScript strings. + JS_STRING = 1; + + // Use JavaScript numbers. + JS_NUMBER = 2; + } + + // Should this field be parsed lazily? Lazy applies only to message-type + // fields. It means that when the outer message is initially parsed, the + // inner message's contents will not be parsed but instead stored in encoded + // form. The inner message will actually be parsed when it is first accessed. + // + // This is only a hint. Implementations are free to choose whether to use + // eager or lazy parsing regardless of the value of this option. However, + // setting this option true suggests that the protocol author believes that + // using lazy parsing on this field is worth the additional bookkeeping + // overhead typically needed to implement it. + // + // This option does not affect the public interface of any generated code; + // all method signatures remain the same. Furthermore, thread-safety of the + // interface is not affected by this option; const methods remain safe to + // call from multiple threads concurrently, while non-const methods continue + // to require exclusive access. + // + // Note that lazy message fields are still eagerly verified to check + // ill-formed wireformat or missing required fields. Calling IsInitialized() + // on the outer message would fail if the inner message has missing required + // fields. Failed verification would result in parsing failure (except when + // uninitialized messages are acceptable). + optional bool lazy = 5 [default = false]; + + // unverified_lazy does no correctness checks on the byte stream. This should + // only be used where lazy with verification is prohibitive for performance + // reasons. + optional bool unverified_lazy = 15 [default = false]; + + // Is this field deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for accessors, or it will be completely ignored; in the very least, this + // is a formalization for deprecating fields. + optional bool deprecated = 3 [default = false]; + + // DEPRECATED. DO NOT USE! + // For Google-internal migration only. Do not use. + optional bool weak = 10 [default = false, deprecated = true]; + + // Indicate that the field value should not be printed out when using debug + // formats, e.g. when the field contains sensitive credentials. + optional bool debug_redact = 16 [default = false]; + + // If set to RETENTION_SOURCE, the option will be omitted from the binary. + enum OptionRetention { + RETENTION_UNKNOWN = 0; + RETENTION_RUNTIME = 1; + RETENTION_SOURCE = 2; + } + + optional OptionRetention retention = 17; + + // This indicates the types of entities that the field may apply to when used + // as an option. If it is unset, then the field may be freely used as an + // option on any kind of entity. + enum OptionTargetType { + TARGET_TYPE_UNKNOWN = 0; + TARGET_TYPE_FILE = 1; + TARGET_TYPE_EXTENSION_RANGE = 2; + TARGET_TYPE_MESSAGE = 3; + TARGET_TYPE_FIELD = 4; + TARGET_TYPE_ONEOF = 5; + TARGET_TYPE_ENUM = 6; + TARGET_TYPE_ENUM_ENTRY = 7; + TARGET_TYPE_SERVICE = 8; + TARGET_TYPE_METHOD = 9; + } + + repeated OptionTargetType targets = 19; + + message EditionDefault { + optional Edition edition = 3; + optional string value = 2; // Textproto value. + } + repeated EditionDefault edition_defaults = 20; + + // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. + optional FeatureSet features = 21; + + // Information about the support window of a feature. + message FeatureSupport { + // The edition that this feature was first available in. In editions + // earlier than this one, the default assigned to EDITION_LEGACY will be + // used, and proto files will not be able to override it. + optional Edition edition_introduced = 1; + + // The edition this feature becomes deprecated in. Using this after this + // edition may trigger warnings. + optional Edition edition_deprecated = 2; + + // The deprecation warning text if this feature is used after the edition it + // was marked deprecated in. + optional string deprecation_warning = 3; + + // The edition this feature is no longer available in. In editions after + // this one, the last default assigned will be used, and proto files will + // not be able to override it. + optional Edition edition_removed = 4; + } + optional FeatureSupport feature_support = 22; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; + + reserved 4; // removed jtype + reserved 18; // reserve target, target_obsolete_do_not_use +} + +message OneofOptions { + // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. + optional FeatureSet features = 1; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message EnumOptions { + + // Set this option to true to allow mapping different tag names to the same + // value. + optional bool allow_alias = 2; + + // Is this enum deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the enum, or it will be completely ignored; in the very least, this + // is a formalization for deprecating enums. + optional bool deprecated = 3 [default = false]; + + reserved 5; // javanano_as_lite + + // Enable the legacy handling of JSON field name conflicts. This lowercases + // and strips underscored from the fields before comparison in proto3 only. + // The new behavior takes `json_name` into account and applies to proto2 as + // well. + // TODO Remove this legacy behavior once downstream teams have + // had time to migrate. + optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true]; + + // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. + optional FeatureSet features = 7; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message EnumValueOptions { + // Is this enum value deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the enum value, or it will be completely ignored; in the very least, + // this is a formalization for deprecating enum values. + optional bool deprecated = 1 [default = false]; + + // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. + optional FeatureSet features = 2; + + // Indicate that fields annotated with this enum value should not be printed + // out when using debug formats, e.g. when the field contains sensitive + // credentials. + optional bool debug_redact = 3 [default = false]; + + // Information about the support window of a feature value. + optional FieldOptions.FeatureSupport feature_support = 4; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message ServiceOptions { + + // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. + optional FeatureSet features = 34; + + // Note: Field numbers 1 through 32 are reserved for Google's internal RPC + // framework. We apologize for hoarding these numbers to ourselves, but + // we were already using them long before we decided to release Protocol + // Buffers. + + // Is this service deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the service, or it will be completely ignored; in the very least, + // this is a formalization for deprecating services. + optional bool deprecated = 33 [default = false]; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message MethodOptions { + + // Note: Field numbers 1 through 32 are reserved for Google's internal RPC + // framework. We apologize for hoarding these numbers to ourselves, but + // we were already using them long before we decided to release Protocol + // Buffers. + + // Is this method deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the method, or it will be completely ignored; in the very least, + // this is a formalization for deprecating methods. + optional bool deprecated = 33 [default = false]; + + // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + // or neither? HTTP based RPC implementation may choose GET verb for safe + // methods, and PUT verb for idempotent methods instead of the default POST. + enum IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0; + NO_SIDE_EFFECTS = 1; // implies idempotent + IDEMPOTENT = 2; // idempotent, but may have side effects + } + optional IdempotencyLevel idempotency_level = 34 + [default = IDEMPOTENCY_UNKNOWN]; + + // Any features defined in the specific edition. + // WARNING: This field should only be used by protobuf plugins or special + // cases like the proto compiler. Other uses are discouraged and + // developers should rely on the protoreflect APIs for their client language. + optional FeatureSet features = 35; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +// A message representing a option the parser does not recognize. This only +// appears in options protos created by the compiler::Parser class. +// DescriptorPool resolves these when building Descriptor objects. Therefore, +// options protos in descriptor objects (e.g. returned by Descriptor::options(), +// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions +// in them. +message UninterpretedOption { + // The name of the uninterpreted option. Each string represents a segment in + // a dot-separated name. is_extension is true iff a segment represents an + // extension (denoted with parentheses in options specs in .proto files). + // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents + // "foo.(bar.baz).moo". + message NamePart { + required string name_part = 1; + required bool is_extension = 2; + } + repeated NamePart name = 2; + + // The value of the uninterpreted option, in whatever type the tokenizer + // identified it as during parsing. Exactly one of these should be set. + optional string identifier_value = 3; + optional uint64 positive_int_value = 4; + optional int64 negative_int_value = 5; + optional double double_value = 6; + optional bytes string_value = 7; + optional string aggregate_value = 8; +} + +// =================================================================== +// Features + +// TODO Enums in C++ gencode (and potentially other languages) are +// not well scoped. This means that each of the feature enums below can clash +// with each other. The short names we've chosen maximize call-site +// readability, but leave us very open to this scenario. A future feature will +// be designed and implemented to handle this, hopefully before we ever hit a +// conflict here. +message FeatureSet { + enum FieldPresence { + FIELD_PRESENCE_UNKNOWN = 0; + EXPLICIT = 1; + IMPLICIT = 2; + LEGACY_REQUIRED = 3; + } + optional FieldPresence field_presence = 1 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "EXPLICIT" }, + edition_defaults = { edition: EDITION_PROTO3, value: "IMPLICIT" }, + edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" } + ]; + + enum EnumType { + ENUM_TYPE_UNKNOWN = 0; + OPEN = 1; + CLOSED = 2; + } + optional EnumType enum_type = 2 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "CLOSED" }, + edition_defaults = { edition: EDITION_PROTO3, value: "OPEN" } + ]; + + enum RepeatedFieldEncoding { + REPEATED_FIELD_ENCODING_UNKNOWN = 0; + PACKED = 1; + EXPANDED = 2; + } + optional RepeatedFieldEncoding repeated_field_encoding = 3 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "EXPANDED" }, + edition_defaults = { edition: EDITION_PROTO3, value: "PACKED" } + ]; + + enum Utf8Validation { + UTF8_VALIDATION_UNKNOWN = 0; + VERIFY = 2; + NONE = 3; + reserved 1; + } + optional Utf8Validation utf8_validation = 4 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "NONE" }, + edition_defaults = { edition: EDITION_PROTO3, value: "VERIFY" } + ]; + + enum MessageEncoding { + MESSAGE_ENCODING_UNKNOWN = 0; + LENGTH_PREFIXED = 1; + DELIMITED = 2; + } + optional MessageEncoding message_encoding = 5 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "LENGTH_PREFIXED" } + ]; + + enum JsonFormat { + JSON_FORMAT_UNKNOWN = 0; + ALLOW = 1; + LEGACY_BEST_EFFORT = 2; + } + optional JsonFormat json_format = 6 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_MESSAGE, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY_BEST_EFFORT" }, + edition_defaults = { edition: EDITION_PROTO3, value: "ALLOW" } + ]; + + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0; + STYLE2024 = 1; + STYLE_LEGACY = 2; + } + optional EnforceNamingStyle enforce_naming_style = 7 [ + retention = RETENTION_SOURCE, + targets = TARGET_TYPE_FILE, + targets = TARGET_TYPE_EXTENSION_RANGE, + targets = TARGET_TYPE_MESSAGE, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_ONEOF, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_ENUM_ENTRY, + targets = TARGET_TYPE_SERVICE, + targets = TARGET_TYPE_METHOD, + feature_support = { + edition_introduced: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "STYLE_LEGACY" }, + edition_defaults = { edition: EDITION_2024, value: "STYLE2024" } + ]; + + message VisibilityFeature { + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0; + + // Default pre-EDITION_2024, all UNSET visibility are export. + EXPORT_ALL = 1; + + // All top-level symbols default to export, nested default to local. + EXPORT_TOP_LEVEL = 2; + + // All symbols default to local. + LOCAL_ALL = 3; + + // All symbols local by default. Nested types cannot be exported. + // With special case caveat for message { enum {} reserved 1 to max; } + // This is the recommended setting for new protos. + STRICT = 4; + } + reserved 1 to max; + } + optional VisibilityFeature.DefaultSymbolVisibility default_symbol_visibility = + 8 [ + retention = RETENTION_SOURCE, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "EXPORT_ALL" }, + edition_defaults = { edition: EDITION_2024, value: "EXPORT_TOP_LEVEL" } + ]; + + reserved 999; + + extensions 1000 to 9994 [ + declaration = { + number: 1000, + full_name: ".pb.cpp", + type: ".pb.CppFeatures" + }, + declaration = { + number: 1001, + full_name: ".pb.java", + type: ".pb.JavaFeatures" + }, + declaration = { number: 1002, full_name: ".pb.go", type: ".pb.GoFeatures" }, + declaration = { + number: 1003, + full_name: ".pb.python", + type: ".pb.PythonFeatures" + }, + declaration = { + number: 9989, + full_name: ".pb.java_mutable", + type: ".pb.JavaMutableFeatures" + }, + declaration = { + number: 9990, + full_name: ".pb.proto1", + type: ".pb.Proto1Features" + } + ]; + + extensions 9995 to 9999; // For internal testing + extensions 10000; // for https://github.com/bufbuild/protobuf-es +} + +// A compiled specification for the defaults of a set of features. These +// messages are generated from FeatureSet extensions and can be used to seed +// feature resolution. The resolution with this object becomes a simple search +// for the closest matching edition, followed by proto merges. +message FeatureSetDefaults { + // A map from every known edition with a unique set of defaults to its + // defaults. Not all editions may be contained here. For a given edition, + // the defaults at the closest matching edition ordered at or before it should + // be used. This field must be in strict ascending order by edition. + message FeatureSetEditionDefault { + optional Edition edition = 3; + + // Defaults of features that can be overridden in this edition. + optional FeatureSet overridable_features = 4; + + // Defaults of features that can't be overridden in this edition. + optional FeatureSet fixed_features = 5; + + reserved 1, 2; + reserved "features"; + } + repeated FeatureSetEditionDefault defaults = 1; + + // The minimum supported edition (inclusive) when this was constructed. + // Editions before this will not have defaults. + optional Edition minimum_edition = 4; + + // The maximum known edition (inclusive) when this was constructed. Editions + // after this will not have reliable defaults. + optional Edition maximum_edition = 5; +} + +// =================================================================== +// Optional source code info + +// Encapsulates information about the original source file from which a +// FileDescriptorProto was generated. +message SourceCodeInfo { + // A Location identifies a piece of source code in a .proto file which + // corresponds to a particular definition. This information is intended + // to be useful to IDEs, code indexers, documentation generators, and similar + // tools. + // + // For example, say we have a file like: + // message Foo { + // optional string foo = 1; + // } + // Let's look at just the field definition: + // optional string foo = 1; + // ^ ^^ ^^ ^ ^^^ + // a bc de f ghi + // We have the following locations: + // span path represents + // [a,i) [ 4, 0, 2, 0 ] The whole field definition. + // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + // + // Notes: + // - A location may refer to a repeated field itself (i.e. not to any + // particular index within it). This is used whenever a set of elements are + // logically enclosed in a single code segment. For example, an entire + // extend block (possibly containing multiple extension definitions) will + // have an outer location whose path refers to the "extensions" repeated + // field without an index. + // - Multiple locations may have the same path. This happens when a single + // logical declaration is spread out across multiple places. The most + // obvious example is the "extend" block again -- there may be multiple + // extend blocks in the same scope, each of which will have the same path. + // - A location's span is not always a subset of its parent's span. For + // example, the "extendee" of an extension declaration appears at the + // beginning of the "extend" block and is shared by all extensions within + // the block. + // - Just because a location's span is a subset of some other location's span + // does not mean that it is a descendant. For example, a "group" defines + // both a type and a field in a single declaration. Thus, the locations + // corresponding to the type and field and their components will overlap. + // - Code which tries to interpret locations should probably be designed to + // ignore those that it doesn't understand, as more types of locations could + // be recorded in the future. + repeated Location location = 1; + message Location { + // Identifies which part of the FileDescriptorProto was defined at this + // location. + // + // Each element is a field number or an index. They form a path from + // the root FileDescriptorProto to the place where the definition appears. + // For example, this path: + // [ 4, 3, 2, 7, 1 ] + // refers to: + // file.message_type(3) // 4, 3 + // .field(7) // 2, 7 + // .name() // 1 + // This is because FileDescriptorProto.message_type has field number 4: + // repeated DescriptorProto message_type = 4; + // and DescriptorProto.field has field number 2: + // repeated FieldDescriptorProto field = 2; + // and FieldDescriptorProto.name has field number 1: + // optional string name = 1; + // + // Thus, the above path gives the location of a field name. If we removed + // the last element: + // [ 4, 3, 2, 7 ] + // this path refers to the whole field declaration (from the beginning + // of the label to the terminating semicolon). + repeated int32 path = 1 [packed = true]; + + // Always has exactly three or four elements: start line, start column, + // end line (optional, otherwise assumed same as start line), end column. + // These are packed into a single field for efficiency. Note that line + // and column numbers are zero-based -- typically you will want to add + // 1 to each before displaying to a user. + repeated int32 span = 2 [packed = true]; + + // If this SourceCodeInfo represents a complete declaration, these are any + // comments appearing before and after the declaration which appear to be + // attached to the declaration. + // + // A series of line comments appearing on consecutive lines, with no other + // tokens appearing on those lines, will be treated as a single comment. + // + // leading_detached_comments will keep paragraphs of comments that appear + // before (but not connected to) the current element. Each paragraph, + // separated by empty lines, will be one comment element in the repeated + // field. + // + // Only the comment content is provided; comment markers (e.g. //) are + // stripped out. For block comments, leading whitespace and an asterisk + // will be stripped from the beginning of each line other than the first. + // Newlines are included in the output. + // + // Examples: + // + // optional int32 foo = 1; // Comment attached to foo. + // // Comment attached to bar. + // optional int32 bar = 2; + // + // optional string baz = 3; + // // Comment attached to baz. + // // Another line attached to baz. + // + // // Comment attached to moo. + // // + // // Another line attached to moo. + // optional double moo = 4; + // + // // Detached comment for corge. This is not leading or trailing comments + // // to moo or corge because there are blank lines separating it from + // // both. + // + // // Detached comment for corge paragraph 2. + // + // optional string corge = 5; + // /* Block comment attached + // * to corge. Leading asterisks + // * will be removed. */ + // /* Block comment attached to + // * grault. */ + // optional int32 grault = 6; + // + // // ignored detached comments. + optional string leading_comments = 3; + optional string trailing_comments = 4; + repeated string leading_detached_comments = 6; + } + + // Extensions for tooling. + extensions 536000000 [declaration = { + number: 536000000 + type: ".buf.descriptor.v1.SourceCodeInfoExtension" + full_name: ".buf.descriptor.v1.buf_source_code_info_extension" + }]; +} + +// Describes the relationship between generated code and its original source +// file. A GeneratedCodeInfo message is associated with only one generated +// source file, but may contain references to different source .proto files. +message GeneratedCodeInfo { + // An Annotation connects some span of text in generated code to an element + // of its generating .proto file. + repeated Annotation annotation = 1; + message Annotation { + // Identifies the element in the original source .proto file. This field + // is formatted the same as SourceCodeInfo.Location.path. + repeated int32 path = 1 [packed = true]; + + // Identifies the filesystem path to the original source .proto. + optional string source_file = 2; + + // Identifies the starting offset in bytes in the generated code + // that relates to the identified object. + optional int32 begin = 3; + + // Identifies the ending offset in bytes in the generated code that + // relates to the identified object. The end offset should be one past + // the last relevant byte (so the length of the text = end - begin). + optional int32 end = 4; + + // Represents the identified object's effect on the element in the original + // .proto file. + enum Semantic { + // There is no effect or the effect is indescribable. + NONE = 0; + // The element is set or otherwise mutated. + SET = 1; + // An alias to the element is returned. + ALIAS = 2; + } + optional Semantic semantic = 5; + } +} + +// Describes the 'visibility' of a symbol with respect to the proto import +// system. Symbols can only be imported when the visibility rules do not prevent +// it (ex: local symbols cannot be imported). Visibility modifiers can only set +// on `message` and `enum` as they are the only types available to be referenced +// from other files. +enum SymbolVisibility { + VISIBILITY_UNSET = 0; + VISIBILITY_LOCAL = 1; + VISIBILITY_EXPORT = 2; +} diff --git a/third_party/google/protobuf/duration.proto b/third_party/google/protobuf/duration.proto new file mode 100644 index 00000000..41f40c22 --- /dev/null +++ b/third_party/google/protobuf/duration.proto @@ -0,0 +1,115 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/protobuf/types/known/durationpb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "DurationProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; + +// A Duration represents a signed, fixed-length span of time represented +// as a count of seconds and fractions of seconds at nanosecond +// resolution. It is independent of any calendar and concepts like "day" +// or "month". It is related to Timestamp in that the difference between +// two Timestamp values is a Duration and it can be added or subtracted +// from a Timestamp. Range is approximately +-10,000 years. +// +// # Examples +// +// Example 1: Compute Duration from two Timestamps in pseudo code. +// +// Timestamp start = ...; +// Timestamp end = ...; +// Duration duration = ...; +// +// duration.seconds = end.seconds - start.seconds; +// duration.nanos = end.nanos - start.nanos; +// +// if (duration.seconds < 0 && duration.nanos > 0) { +// duration.seconds += 1; +// duration.nanos -= 1000000000; +// } else if (duration.seconds > 0 && duration.nanos < 0) { +// duration.seconds -= 1; +// duration.nanos += 1000000000; +// } +// +// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. +// +// Timestamp start = ...; +// Duration duration = ...; +// Timestamp end = ...; +// +// end.seconds = start.seconds + duration.seconds; +// end.nanos = start.nanos + duration.nanos; +// +// if (end.nanos < 0) { +// end.seconds -= 1; +// end.nanos += 1000000000; +// } else if (end.nanos >= 1000000000) { +// end.seconds += 1; +// end.nanos -= 1000000000; +// } +// +// Example 3: Compute Duration from datetime.timedelta in Python. +// +// td = datetime.timedelta(days=3, minutes=10) +// duration = Duration() +// duration.FromTimedelta(td) +// +// # JSON Mapping +// +// In JSON format, the Duration type is encoded as a string rather than an +// object, where the string ends in the suffix "s" (indicating seconds) and +// is preceded by the number of seconds, with nanoseconds expressed as +// fractional seconds. For example, 3 seconds with 0 nanoseconds should be +// encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should +// be expressed in JSON format as "3.000000001s", and 3 seconds and 1 +// microsecond should be expressed in JSON format as "3.000001s". +// +message Duration { + // Signed seconds of the span of time. Must be from -315,576,000,000 + // to +315,576,000,000 inclusive. Note: these bounds are computed from: + // 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + int64 seconds = 1; + + // Signed fractions of a second at nanosecond resolution of the span + // of time. Durations less than one second are represented with a 0 + // `seconds` field and a positive or negative `nanos` field. For durations + // of one second or more, a non-zero value for the `nanos` field must be + // of the same sign as the `seconds` field. Must be from -999,999,999 + // to +999,999,999 inclusive. + int32 nanos = 2; +} diff --git a/third_party/google/protobuf/empty.proto b/third_party/google/protobuf/empty.proto new file mode 100644 index 00000000..b87c89dc --- /dev/null +++ b/third_party/google/protobuf/empty.proto @@ -0,0 +1,51 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option go_package = "google.golang.org/protobuf/types/known/emptypb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "EmptyProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option cc_enable_arenas = true; + +// A generic empty message that you can re-use to avoid defining duplicated +// empty messages in your APIs. A typical example is to use it as the request +// or the response type of an API method. For instance: +// +// service Foo { +// rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); +// } +// +message Empty {} diff --git a/third_party/google/protobuf/field_mask.proto b/third_party/google/protobuf/field_mask.proto new file mode 100644 index 00000000..b28334b9 --- /dev/null +++ b/third_party/google/protobuf/field_mask.proto @@ -0,0 +1,245 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option java_package = "com.google.protobuf"; +option java_outer_classname = "FieldMaskProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option go_package = "google.golang.org/protobuf/types/known/fieldmaskpb"; +option cc_enable_arenas = true; + +// `FieldMask` represents a set of symbolic field paths, for example: +// +// paths: "f.a" +// paths: "f.b.d" +// +// Here `f` represents a field in some root message, `a` and `b` +// fields in the message found in `f`, and `d` a field found in the +// message in `f.b`. +// +// Field masks are used to specify a subset of fields that should be +// returned by a get operation or modified by an update operation. +// Field masks also have a custom JSON encoding (see below). +// +// # Field Masks in Projections +// +// When used in the context of a projection, a response message or +// sub-message is filtered by the API to only contain those fields as +// specified in the mask. For example, if the mask in the previous +// example is applied to a response message as follows: +// +// f { +// a : 22 +// b { +// d : 1 +// x : 2 +// } +// y : 13 +// } +// z: 8 +// +// The result will not contain specific values for fields x,y and z +// (their value will be set to the default, and omitted in proto text +// output): +// +// +// f { +// a : 22 +// b { +// d : 1 +// } +// } +// +// A repeated field is not allowed except at the last position of a +// paths string. +// +// If a FieldMask object is not present in a get operation, the +// operation applies to all fields (as if a FieldMask of all fields +// had been specified). +// +// Note that a field mask does not necessarily apply to the +// top-level response message. In case of a REST get operation, the +// field mask applies directly to the response, but in case of a REST +// list operation, the mask instead applies to each individual message +// in the returned resource list. In case of a REST custom method, +// other definitions may be used. Where the mask applies will be +// clearly documented together with its declaration in the API. In +// any case, the effect on the returned resource/resources is required +// behavior for APIs. +// +// # Field Masks in Update Operations +// +// A field mask in update operations specifies which fields of the +// targeted resource are going to be updated. The API is required +// to only change the values of the fields as specified in the mask +// and leave the others untouched. If a resource is passed in to +// describe the updated values, the API ignores the values of all +// fields not covered by the mask. +// +// If a repeated field is specified for an update operation, new values will +// be appended to the existing repeated field in the target resource. Note that +// a repeated field is only allowed in the last position of a `paths` string. +// +// If a sub-message is specified in the last position of the field mask for an +// update operation, then new value will be merged into the existing sub-message +// in the target resource. +// +// For example, given the target message: +// +// f { +// b { +// d: 1 +// x: 2 +// } +// c: [1] +// } +// +// And an update message: +// +// f { +// b { +// d: 10 +// } +// c: [2] +// } +// +// then if the field mask is: +// +// paths: ["f.b", "f.c"] +// +// then the result will be: +// +// f { +// b { +// d: 10 +// x: 2 +// } +// c: [1, 2] +// } +// +// An implementation may provide options to override this default behavior for +// repeated and message fields. +// +// In order to reset a field's value to the default, the field must +// be in the mask and set to the default value in the provided resource. +// Hence, in order to reset all fields of a resource, provide a default +// instance of the resource and set all fields in the mask, or do +// not provide a mask as described below. +// +// If a field mask is not present on update, the operation applies to +// all fields (as if a field mask of all fields has been specified). +// Note that in the presence of schema evolution, this may mean that +// fields the client does not know and has therefore not filled into +// the request will be reset to their default. If this is unwanted +// behavior, a specific service may require a client to always specify +// a field mask, producing an error if not. +// +// As with get operations, the location of the resource which +// describes the updated values in the request message depends on the +// operation kind. In any case, the effect of the field mask is +// required to be honored by the API. +// +// ## Considerations for HTTP REST +// +// The HTTP kind of an update operation which uses a field mask must +// be set to PATCH instead of PUT in order to satisfy HTTP semantics +// (PUT must only be used for full updates). +// +// # JSON Encoding of Field Masks +// +// In JSON, a field mask is encoded as a single string where paths are +// separated by a comma. Fields name in each path are converted +// to/from lower-camel naming conventions. +// +// As an example, consider the following message declarations: +// +// message Profile { +// User user = 1; +// Photo photo = 2; +// } +// message User { +// string display_name = 1; +// string address = 2; +// } +// +// In proto a field mask for `Profile` may look as such: +// +// mask { +// paths: "user.display_name" +// paths: "photo" +// } +// +// In JSON, the same mask is represented as below: +// +// { +// mask: "user.displayName,photo" +// } +// +// # Field Masks and Oneof Fields +// +// Field masks treat fields in oneofs just as regular fields. Consider the +// following message: +// +// message SampleMessage { +// oneof test_oneof { +// string name = 4; +// SubMessage sub_message = 9; +// } +// } +// +// The field mask can be: +// +// mask { +// paths: "name" +// } +// +// Or: +// +// mask { +// paths: "sub_message" +// } +// +// Note that oneof type names ("test_oneof" in this case) cannot be used in +// paths. +// +// ## Field Mask Verification +// +// The implementation of any API method which has a FieldMask type field in the +// request should verify the included field paths, and return an +// `INVALID_ARGUMENT` error if any path is unmappable. +message FieldMask { + // The set of field mask paths. + repeated string paths = 1; +} diff --git a/third_party/google/protobuf/go_features.proto b/third_party/google/protobuf/go_features.proto new file mode 100644 index 00000000..4d13a413 --- /dev/null +++ b/third_party/google/protobuf/go_features.proto @@ -0,0 +1,83 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +syntax = "proto2"; + +package pb; + +import "google/protobuf/descriptor.proto"; + +option go_package = "google.golang.org/protobuf/types/gofeaturespb"; + +extend google.protobuf.FeatureSet { + optional GoFeatures go = 1002; +} + +message GoFeatures { + // Whether or not to generate the deprecated UnmarshalJSON method for enums. + // Can only be true for proto using the Open Struct api. + optional bool legacy_unmarshal_json_enum = 1 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + edition_deprecated: EDITION_2023, + deprecation_warning: "The legacy UnmarshalJSON API is deprecated and " + "will be removed in a future edition.", + }, + edition_defaults = { edition: EDITION_LEGACY, value: "true" }, + edition_defaults = { edition: EDITION_PROTO3, value: "false" } + ]; + + enum APILevel { + // API_LEVEL_UNSPECIFIED results in selecting the OPEN API, + // but needs to be a separate value to distinguish between + // an explicitly set api level or a missing api level. + API_LEVEL_UNSPECIFIED = 0; + API_OPEN = 1; + API_HYBRID = 2; + API_OPAQUE = 3; + } + + // One of OPEN, HYBRID or OPAQUE. + optional APILevel api_level = 2 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_MESSAGE, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + }, + edition_defaults = { + edition: EDITION_LEGACY, + value: "API_LEVEL_UNSPECIFIED" + }, + edition_defaults = { edition: EDITION_2024, value: "API_OPAQUE" } + ]; + + enum StripEnumPrefix { + STRIP_ENUM_PREFIX_UNSPECIFIED = 0; + STRIP_ENUM_PREFIX_KEEP = 1; + STRIP_ENUM_PREFIX_GENERATE_BOTH = 2; + STRIP_ENUM_PREFIX_STRIP = 3; + } + + optional StripEnumPrefix strip_enum_prefix = 3 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_ENUM_ENTRY, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2024, + }, + // TODO: change the default to STRIP_ENUM_PREFIX_STRIP for edition 2025. + edition_defaults = { + edition: EDITION_LEGACY, + value: "STRIP_ENUM_PREFIX_KEEP" + } + ]; +} diff --git a/third_party/google/protobuf/java_features.proto b/third_party/google/protobuf/java_features.proto new file mode 100644 index 00000000..80ac6fa9 --- /dev/null +++ b/third_party/google/protobuf/java_features.proto @@ -0,0 +1,132 @@ + +// Protocol Buffers - Google's data interchange format +// Copyright 2023 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +syntax = "proto2"; + +package pb; + +import "google/protobuf/descriptor.proto"; + +option java_package = "com.google.protobuf"; +option java_outer_classname = "JavaFeaturesProto"; + +extend google.protobuf.FeatureSet { + optional JavaFeatures java = 1001; +} + +message JavaFeatures { + // Whether or not to treat an enum field as closed. This option is only + // applicable to enum fields, and will be removed in the future. It is + // consistent with the legacy behavior of using proto3 enum types for proto2 + // fields. + optional bool legacy_closed_enum = 1 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + edition_deprecated: EDITION_2023, + deprecation_warning: "The legacy closed enum behavior in Java is " + "deprecated and is scheduled to be removed in " + "edition 2025. See http://protobuf.dev/programming-guides/enum/#java for " + "more information.", + }, + edition_defaults = { edition: EDITION_LEGACY, value: "true" }, + edition_defaults = { edition: EDITION_PROTO3, value: "false" } + ]; + + // The UTF8 validation strategy to use. + enum Utf8Validation { + // Invalid default, which should never be used. + UTF8_VALIDATION_UNKNOWN = 0; + // Respect the UTF8 validation behavior specified by the global + // utf8_validation feature. + DEFAULT = 1; + // Verifies UTF8 validity overriding the global utf8_validation + // feature. This represents the legacy java_string_check_utf8 option. + VERIFY = 2; + } + optional Utf8Validation utf8_validation = 2 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FIELD, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2023, + edition_deprecated: EDITION_2024, + deprecation_warning: "The Java-specific utf8 validation feature is " + "deprecated and is scheduled to be removed in " + "edition 2025. Utf8 validation behavior should " + "use the global cross-language utf8_validation " + "feature.", + }, + edition_defaults = { edition: EDITION_LEGACY, value: "DEFAULT" } + ]; + + // Allows creation of large Java enums, extending beyond the standard + // constant limits imposed by the Java language. + optional bool large_enum = 3 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "false" } + ]; + + // Whether to use the old default outer class name scheme, or the new feature + // which adds a "Proto" suffix to the outer class name. + // + // Users will not be able to set this option, because we removed it in the + // same edition that it was introduced. But we use it to determine which + // naming scheme to use for outer class name defaults. + optional bool use_old_outer_classname_default = 4 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_FILE, + feature_support = { + edition_introduced: EDITION_2024, + edition_removed: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "true" }, + edition_defaults = { edition: EDITION_2024, value: "false" } + ]; + + message NestInFileClassFeature { + enum NestInFileClass { + // Invalid default, which should never be used. + NEST_IN_FILE_CLASS_UNKNOWN = 0; + // Do not nest the generated class in the file class. + NO = 1; + // Nest the generated class in the file class. + YES = 2; + // Fall back to the `java_multiple_files` option. Users won't be able to + // set this option. + LEGACY = 3 [feature_support = { + edition_introduced: EDITION_2024 + edition_removed: EDITION_2024 + }]; + } + reserved 1 to max; + } + + // Whether to nest the generated class in the generated file class. This is + // only applicable to *top-level* messages, enums, and services. + optional NestInFileClassFeature.NestInFileClass nest_in_file_class = 5 [ + retention = RETENTION_RUNTIME, + targets = TARGET_TYPE_MESSAGE, + targets = TARGET_TYPE_ENUM, + targets = TARGET_TYPE_SERVICE, + feature_support = { + edition_introduced: EDITION_2024, + }, + edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY" }, + edition_defaults = { edition: EDITION_2024, value: "NO" } + ]; + + reserved 6; // field `mutable_nest_in_file_class` removed. +} diff --git a/third_party/google/protobuf/source_context.proto b/third_party/google/protobuf/source_context.proto new file mode 100644 index 00000000..135f50fe --- /dev/null +++ b/third_party/google/protobuf/source_context.proto @@ -0,0 +1,48 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option java_package = "com.google.protobuf"; +option java_outer_classname = "SourceContextProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option go_package = "google.golang.org/protobuf/types/known/sourcecontextpb"; + +// `SourceContext` represents information about the source of a +// protobuf element, like the file in which it is defined. +message SourceContext { + // The path-qualified name of the .proto file that contained the associated + // protobuf element. For example: `"google/protobuf/source_context.proto"`. + string file_name = 1; +} diff --git a/third_party/google/protobuf/struct.proto b/third_party/google/protobuf/struct.proto new file mode 100644 index 00000000..1bf0c1ad --- /dev/null +++ b/third_party/google/protobuf/struct.proto @@ -0,0 +1,95 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/protobuf/types/known/structpb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "StructProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; + +// `Struct` represents a structured data value, consisting of fields +// which map to dynamically typed values. In some languages, `Struct` +// might be supported by a native representation. For example, in +// scripting languages like JS a struct is represented as an +// object. The details of that representation are described together +// with the proto support for the language. +// +// The JSON representation for `Struct` is JSON object. +message Struct { + // Unordered map of dynamically typed values. + map fields = 1; +} + +// `Value` represents a dynamically typed value which can be either +// null, a number, a string, a boolean, a recursive struct value, or a +// list of values. A producer of value is expected to set one of these +// variants. Absence of any variant indicates an error. +// +// The JSON representation for `Value` is JSON value. +message Value { + // The kind of value. + oneof kind { + // Represents a null value. + NullValue null_value = 1; + // Represents a double value. + double number_value = 2; + // Represents a string value. + string string_value = 3; + // Represents a boolean value. + bool bool_value = 4; + // Represents a structured value. + Struct struct_value = 5; + // Represents a repeated `Value`. + ListValue list_value = 6; + } +} + +// `NullValue` is a singleton enumeration to represent the null value for the +// `Value` type union. +// +// The JSON representation for `NullValue` is JSON `null`. +enum NullValue { + // Null value. + NULL_VALUE = 0; +} + +// `ListValue` is a wrapper around a repeated field of values. +// +// The JSON representation for `ListValue` is JSON array. +message ListValue { + // Repeated field of dynamically typed values. + repeated Value values = 1; +} diff --git a/third_party/google/protobuf/timestamp.proto b/third_party/google/protobuf/timestamp.proto new file mode 100644 index 00000000..fd308bd4 --- /dev/null +++ b/third_party/google/protobuf/timestamp.proto @@ -0,0 +1,145 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/protobuf/types/known/timestamppb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "TimestampProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; + +// A Timestamp represents a point in time independent of any time zone or local +// calendar, encoded as a count of seconds and fractions of seconds at +// nanosecond resolution. The count is relative to an epoch at UTC midnight on +// January 1, 1970, in the proleptic Gregorian calendar which extends the +// Gregorian calendar backwards to year one. +// +// All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap +// second table is needed for interpretation, using a [24-hour linear +// smear](https://developers.google.com/time/smear). +// +// The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By +// restricting to that range, we ensure that we can convert to and from [RFC +// 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. +// +// # Examples +// +// Example 1: Compute Timestamp from POSIX `time()`. +// +// Timestamp timestamp; +// timestamp.set_seconds(time(NULL)); +// timestamp.set_nanos(0); +// +// Example 2: Compute Timestamp from POSIX `gettimeofday()`. +// +// struct timeval tv; +// gettimeofday(&tv, NULL); +// +// Timestamp timestamp; +// timestamp.set_seconds(tv.tv_sec); +// timestamp.set_nanos(tv.tv_usec * 1000); +// +// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. +// +// FILETIME ft; +// GetSystemTimeAsFileTime(&ft); +// UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; +// +// // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z +// // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. +// Timestamp timestamp; +// timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); +// timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); +// +// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. +// +// long millis = System.currentTimeMillis(); +// +// Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) +// .setNanos((int) ((millis % 1000) * 1000000)).build(); +// +// Example 5: Compute Timestamp from Java `Instant.now()`. +// +// Instant now = Instant.now(); +// +// Timestamp timestamp = +// Timestamp.newBuilder().setSeconds(now.getEpochSecond()) +// .setNanos(now.getNano()).build(); +// +// Example 6: Compute Timestamp from current time in Python. +// +// timestamp = Timestamp() +// timestamp.GetCurrentTime() +// +// # JSON Mapping +// +// In JSON format, the Timestamp type is encoded as a string in the +// [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the +// format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" +// where {year} is always expressed using four digits while {month}, {day}, +// {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional +// seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), +// are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone +// is required. A proto3 JSON serializer should always use UTC (as indicated by +// "Z") when printing the Timestamp type and a proto3 JSON parser should be +// able to accept both UTC and other timezones (as indicated by an offset). +// +// For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past +// 01:30 UTC on January 15, 2017. +// +// In JavaScript, one can convert a Date object to this format using the +// standard +// [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) +// method. In Python, a standard `datetime.datetime` object can be converted +// to this format using +// [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with +// the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use +// the Joda Time's [`ISODateTimeFormat.dateTime()`]( +// http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime() +// ) to obtain a formatter capable of generating timestamps in this format. +// +message Timestamp { + // Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must + // be between -315576000000 and 315576000000 inclusive (which corresponds to + // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). + int64 seconds = 1; + + // Non-negative fractions of a second at nanosecond resolution. This field is + // the nanosecond portion of the duration, not an alternative to seconds. + // Negative second values with fractions must still have non-negative nanos + // values that count forward in time. Must be between 0 and 999,999,999 + // inclusive. + int32 nanos = 2; +} diff --git a/third_party/google/protobuf/type.proto b/third_party/google/protobuf/type.proto new file mode 100644 index 00000000..2c7615ed --- /dev/null +++ b/third_party/google/protobuf/type.proto @@ -0,0 +1,217 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +package google.protobuf; + +import "google/protobuf/any.proto"; +import "google/protobuf/source_context.proto"; + +option cc_enable_arenas = true; +option java_package = "com.google.protobuf"; +option java_outer_classname = "TypeProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; +option go_package = "google.golang.org/protobuf/types/known/typepb"; + +// A protocol buffer message type. +// +// New usages of this message as an alternative to DescriptorProto are strongly +// discouraged. This message does not reliability preserve all information +// necessary to model the schema and preserve semantics. Instead make use of +// FileDescriptorSet which preserves the necessary information. +message Type { + // The fully qualified message name. + string name = 1; + // The list of fields. + repeated Field fields = 2; + // The list of types appearing in `oneof` definitions in this type. + repeated string oneofs = 3; + // The protocol buffer options. + repeated Option options = 4; + // The source context. + SourceContext source_context = 5; + // The source syntax. + Syntax syntax = 6; + // The source edition string, only valid when syntax is SYNTAX_EDITIONS. + string edition = 7; +} + +// A single field of a message type. +// +// New usages of this message as an alternative to FieldDescriptorProto are +// strongly discouraged. This message does not reliability preserve all +// information necessary to model the schema and preserve semantics. Instead +// make use of FileDescriptorSet which preserves the necessary information. +message Field { + // Basic field types. + enum Kind { + // Field type unknown. + TYPE_UNKNOWN = 0; + // Field type double. + TYPE_DOUBLE = 1; + // Field type float. + TYPE_FLOAT = 2; + // Field type int64. + TYPE_INT64 = 3; + // Field type uint64. + TYPE_UINT64 = 4; + // Field type int32. + TYPE_INT32 = 5; + // Field type fixed64. + TYPE_FIXED64 = 6; + // Field type fixed32. + TYPE_FIXED32 = 7; + // Field type bool. + TYPE_BOOL = 8; + // Field type string. + TYPE_STRING = 9; + // Field type group. Proto2 syntax only, and deprecated. + TYPE_GROUP = 10; + // Field type message. + TYPE_MESSAGE = 11; + // Field type bytes. + TYPE_BYTES = 12; + // Field type uint32. + TYPE_UINT32 = 13; + // Field type enum. + TYPE_ENUM = 14; + // Field type sfixed32. + TYPE_SFIXED32 = 15; + // Field type sfixed64. + TYPE_SFIXED64 = 16; + // Field type sint32. + TYPE_SINT32 = 17; + // Field type sint64. + TYPE_SINT64 = 18; + } + + // Whether a field is optional, required, or repeated. + enum Cardinality { + // For fields with unknown cardinality. + CARDINALITY_UNKNOWN = 0; + // For optional fields. + CARDINALITY_OPTIONAL = 1; + // For required fields. Proto2 syntax only. + CARDINALITY_REQUIRED = 2; + // For repeated fields. + CARDINALITY_REPEATED = 3; + } + + // The field type. + Kind kind = 1; + // The field cardinality. + Cardinality cardinality = 2; + // The field number. + int32 number = 3; + // The field name. + string name = 4; + // The field type URL, without the scheme, for message or enumeration + // types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`. + string type_url = 6; + // The index of the field type in `Type.oneofs`, for message or enumeration + // types. The first type has index 1; zero means the type is not in the list. + int32 oneof_index = 7; + // Whether to use alternative packed wire representation. + bool packed = 8; + // The protocol buffer options. + repeated Option options = 9; + // The field JSON name. + string json_name = 10; + // The string value of the default value of this field. Proto2 syntax only. + string default_value = 11; +} + +// Enum type definition. +// +// New usages of this message as an alternative to EnumDescriptorProto are +// strongly discouraged. This message does not reliability preserve all +// information necessary to model the schema and preserve semantics. Instead +// make use of FileDescriptorSet which preserves the necessary information. +message Enum { + // Enum type name. + string name = 1; + // Enum value definitions. + repeated EnumValue enumvalue = 2; + // Protocol buffer options. + repeated Option options = 3; + // The source context. + SourceContext source_context = 4; + // The source syntax. + Syntax syntax = 5; + // The source edition string, only valid when syntax is SYNTAX_EDITIONS. + string edition = 6; +} + +// Enum value definition. +// +// New usages of this message as an alternative to EnumValueDescriptorProto are +// strongly discouraged. This message does not reliability preserve all +// information necessary to model the schema and preserve semantics. Instead +// make use of FileDescriptorSet which preserves the necessary information. +message EnumValue { + // Enum value name. + string name = 1; + // Enum value number. + int32 number = 2; + // Protocol buffer options. + repeated Option options = 3; +} + +// A protocol buffer option, which can be attached to a message, field, +// enumeration, etc. +// +// New usages of this message as an alternative to FileOptions, MessageOptions, +// FieldOptions, EnumOptions, EnumValueOptions, ServiceOptions, or MethodOptions +// are strongly discouraged. +message Option { + // The option's name. For protobuf built-in options (options defined in + // descriptor.proto), this is the short name. For example, `"map_entry"`. + // For custom options, it should be the fully-qualified name. For example, + // `"google.api.http"`. + string name = 1; + // The option's value packed in an Any message. If the value is a primitive, + // the corresponding wrapper type defined in google/protobuf/wrappers.proto + // should be used. If the value is an enum, it should be stored as an int32 + // value using the google.protobuf.Int32Value type. + Any value = 2; +} + +// The syntax in which a protocol buffer element is defined. +enum Syntax { + // Syntax `proto2`. + SYNTAX_PROTO2 = 0; + // Syntax `proto3`. + SYNTAX_PROTO3 = 1; + // Syntax `editions`. + SYNTAX_EDITIONS = 2; +} diff --git a/third_party/google/protobuf/wrappers.proto b/third_party/google/protobuf/wrappers.proto new file mode 100644 index 00000000..e583e7c4 --- /dev/null +++ b/third_party/google/protobuf/wrappers.proto @@ -0,0 +1,157 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Wrappers for primitive (non-message) types. These types were needed +// for legacy reasons and are not recommended for use in new APIs. +// +// Historically these wrappers were useful to have presence on proto3 primitive +// fields, but proto3 syntax has been updated to support the `optional` keyword. +// Using that keyword is now the strongly preferred way to add presence to +// proto3 primitive fields. +// +// A secondary usecase was to embed primitives in the `google.protobuf.Any` +// type: it is now recommended that you embed your value in your own wrapper +// message which can be specifically documented. +// +// These wrappers have no meaningful use within repeated fields as they lack +// the ability to detect presence on individual elements. +// These wrappers have no meaningful use within a map or a oneof since +// individual entries of a map or fields of a oneof can already detect presence. + +syntax = "proto3"; + +package google.protobuf; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/protobuf/types/known/wrapperspb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "WrappersProto"; +option java_multiple_files = true; +option objc_class_prefix = "GPB"; +option csharp_namespace = "Google.Protobuf.WellKnownTypes"; + +// Wrapper message for `double`. +// +// The JSON representation for `DoubleValue` is JSON number. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. +message DoubleValue { + // The double value. + double value = 1; +} + +// Wrapper message for `float`. +// +// The JSON representation for `FloatValue` is JSON number. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. +message FloatValue { + // The float value. + float value = 1; +} + +// Wrapper message for `int64`. +// +// The JSON representation for `Int64Value` is JSON string. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. +message Int64Value { + // The int64 value. + int64 value = 1; +} + +// Wrapper message for `uint64`. +// +// The JSON representation for `UInt64Value` is JSON string. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. +message UInt64Value { + // The uint64 value. + uint64 value = 1; +} + +// Wrapper message for `int32`. +// +// The JSON representation for `Int32Value` is JSON number. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. +message Int32Value { + // The int32 value. + int32 value = 1; +} + +// Wrapper message for `uint32`. +// +// The JSON representation for `UInt32Value` is JSON number. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. +message UInt32Value { + // The uint32 value. + uint32 value = 1; +} + +// Wrapper message for `bool`. +// +// The JSON representation for `BoolValue` is JSON `true` and `false`. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. +message BoolValue { + // The bool value. + bool value = 1; +} + +// Wrapper message for `string`. +// +// The JSON representation for `StringValue` is JSON string. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. +message StringValue { + // The string value. + string value = 1; +} + +// Wrapper message for `bytes`. +// +// The JSON representation for `BytesValue` is JSON string. +// +// Not recommended for use in new APIs, but still useful for legacy APIs and +// has no plan to be removed. +message BytesValue { + // The bytes value. + bytes value = 1; +} diff --git a/third_party/google/rpc/code.proto b/third_party/google/rpc/code.proto new file mode 100644 index 00000000..aa6ce153 --- /dev/null +++ b/third_party/google/rpc/code.proto @@ -0,0 +1,186 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.rpc; + +option go_package = "google.golang.org/genproto/googleapis/rpc/code;code"; +option java_multiple_files = true; +option java_outer_classname = "CodeProto"; +option java_package = "com.google.rpc"; +option objc_class_prefix = "RPC"; + +// The canonical error codes for gRPC APIs. +// +// +// Sometimes multiple error codes may apply. Services should return +// the most specific error code that applies. For example, prefer +// `OUT_OF_RANGE` over `FAILED_PRECONDITION` if both codes apply. +// Similarly prefer `NOT_FOUND` or `ALREADY_EXISTS` over `FAILED_PRECONDITION`. +enum Code { + // Not an error; returned on success. + // + // HTTP Mapping: 200 OK + OK = 0; + + // The operation was cancelled, typically by the caller. + // + // HTTP Mapping: 499 Client Closed Request + CANCELLED = 1; + + // Unknown error. For example, this error may be returned when + // a `Status` value received from another address space belongs to + // an error space that is not known in this address space. Also + // errors raised by APIs that do not return enough error information + // may be converted to this error. + // + // HTTP Mapping: 500 Internal Server Error + UNKNOWN = 2; + + // The client specified an invalid argument. Note that this differs + // from `FAILED_PRECONDITION`. `INVALID_ARGUMENT` indicates arguments + // that are problematic regardless of the state of the system + // (e.g., a malformed file name). + // + // HTTP Mapping: 400 Bad Request + INVALID_ARGUMENT = 3; + + // The deadline expired before the operation could complete. For operations + // that change the state of the system, this error may be returned + // even if the operation has completed successfully. For example, a + // successful response from a server could have been delayed long + // enough for the deadline to expire. + // + // HTTP Mapping: 504 Gateway Timeout + DEADLINE_EXCEEDED = 4; + + // Some requested entity (e.g., file or directory) was not found. + // + // Note to server developers: if a request is denied for an entire class + // of users, such as gradual feature rollout or undocumented allowlist, + // `NOT_FOUND` may be used. If a request is denied for some users within + // a class of users, such as user-based access control, `PERMISSION_DENIED` + // must be used. + // + // HTTP Mapping: 404 Not Found + NOT_FOUND = 5; + + // The entity that a client attempted to create (e.g., file or directory) + // already exists. + // + // HTTP Mapping: 409 Conflict + ALREADY_EXISTS = 6; + + // The caller does not have permission to execute the specified + // operation. `PERMISSION_DENIED` must not be used for rejections + // caused by exhausting some resource (use `RESOURCE_EXHAUSTED` + // instead for those errors). `PERMISSION_DENIED` must not be + // used if the caller can not be identified (use `UNAUTHENTICATED` + // instead for those errors). This error code does not imply the + // request is valid or the requested entity exists or satisfies + // other pre-conditions. + // + // HTTP Mapping: 403 Forbidden + PERMISSION_DENIED = 7; + + // The request does not have valid authentication credentials for the + // operation. + // + // HTTP Mapping: 401 Unauthorized + UNAUTHENTICATED = 16; + + // Some resource has been exhausted, perhaps a per-user quota, or + // perhaps the entire file system is out of space. + // + // HTTP Mapping: 429 Too Many Requests + RESOURCE_EXHAUSTED = 8; + + // The operation was rejected because the system is not in a state + // required for the operation's execution. For example, the directory + // to be deleted is non-empty, an rmdir operation is applied to + // a non-directory, etc. + // + // Service implementors can use the following guidelines to decide + // between `FAILED_PRECONDITION`, `ABORTED`, and `UNAVAILABLE`: + // (a) Use `UNAVAILABLE` if the client can retry just the failing call. + // (b) Use `ABORTED` if the client should retry at a higher level. For + // example, when a client-specified test-and-set fails, indicating the + // client should restart a read-modify-write sequence. + // (c) Use `FAILED_PRECONDITION` if the client should not retry until + // the system state has been explicitly fixed. For example, if an "rmdir" + // fails because the directory is non-empty, `FAILED_PRECONDITION` + // should be returned since the client should not retry unless + // the files are deleted from the directory. + // + // HTTP Mapping: 400 Bad Request + FAILED_PRECONDITION = 9; + + // The operation was aborted, typically due to a concurrency issue such as + // a sequencer check failure or transaction abort. + // + // See the guidelines above for deciding between `FAILED_PRECONDITION`, + // `ABORTED`, and `UNAVAILABLE`. + // + // HTTP Mapping: 409 Conflict + ABORTED = 10; + + // The operation was attempted past the valid range. E.g., seeking or + // reading past end-of-file. + // + // Unlike `INVALID_ARGUMENT`, this error indicates a problem that may + // be fixed if the system state changes. For example, a 32-bit file + // system will generate `INVALID_ARGUMENT` if asked to read at an + // offset that is not in the range [0,2^32-1], but it will generate + // `OUT_OF_RANGE` if asked to read from an offset past the current + // file size. + // + // There is a fair bit of overlap between `FAILED_PRECONDITION` and + // `OUT_OF_RANGE`. We recommend using `OUT_OF_RANGE` (the more specific + // error) when it applies so that callers who are iterating through + // a space can easily look for an `OUT_OF_RANGE` error to detect when + // they are done. + // + // HTTP Mapping: 400 Bad Request + OUT_OF_RANGE = 11; + + // The operation is not implemented or is not supported/enabled in this + // service. + // + // HTTP Mapping: 501 Not Implemented + UNIMPLEMENTED = 12; + + // Internal errors. This means that some invariants expected by the + // underlying system have been broken. This error code is reserved + // for serious errors. + // + // HTTP Mapping: 500 Internal Server Error + INTERNAL = 13; + + // The service is currently unavailable. This is most likely a + // transient condition, which can be corrected by retrying with + // a backoff. Note that it is not always safe to retry + // non-idempotent operations. + // + // See the guidelines above for deciding between `FAILED_PRECONDITION`, + // `ABORTED`, and `UNAVAILABLE`. + // + // HTTP Mapping: 503 Service Unavailable + UNAVAILABLE = 14; + + // Unrecoverable data loss or corruption. + // + // HTTP Mapping: 500 Internal Server Error + DATA_LOSS = 15; +} diff --git a/third_party/google/rpc/context/attribute_context.proto b/third_party/google/rpc/context/attribute_context.proto new file mode 100644 index 00000000..57276600 --- /dev/null +++ b/third_party/google/rpc/context/attribute_context.proto @@ -0,0 +1,345 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.rpc.context; + +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/rpc/context/attribute_context;attribute_context"; +option java_multiple_files = true; +option java_outer_classname = "AttributeContextProto"; +option java_package = "com.google.rpc.context"; + +// This message defines the standard attribute vocabulary for Google APIs. +// +// An attribute is a piece of metadata that describes an activity on a network +// service. For example, the size of an HTTP request, or the status code of +// an HTTP response. +// +// Each attribute has a type and a name, which is logically defined as +// a proto message field in `AttributeContext`. The field type becomes the +// attribute type, and the field path becomes the attribute name. For example, +// the attribute `source.ip` maps to field `AttributeContext.source.ip`. +// +// This message definition is guaranteed not to have any wire breaking change. +// So you can use it directly for passing attributes across different systems. +// +// NOTE: Different system may generate different subset of attributes. Please +// verify the system specification before relying on an attribute generated +// a system. +message AttributeContext { + // This message defines attributes for a node that handles a network request. + // The node can be either a service or an application that sends, forwards, + // or receives the request. Service peers should fill in + // `principal` and `labels` as appropriate. + message Peer { + // The IP address of the peer. + string ip = 1; + + // The network port of the peer. + int64 port = 2; + + // The labels associated with the peer. + map labels = 6; + + // The identity of this peer. Similar to `Request.auth.principal`, but + // relative to the peer instead of the request. For example, the + // identity associated with a load balancer that forwarded the request. + string principal = 7; + + // The CLDR country/region code associated with the above IP address. + // If the IP address is private, the `region_code` should reflect the + // physical location where this peer is running. + string region_code = 8; + } + + // This message defines attributes associated with API operations, such as + // a network API request. The terminology is based on the conventions used + // by Google APIs, Istio, and OpenAPI. + message Api { + // The API service name. It is a logical identifier for a networked API, + // such as "pubsub.googleapis.com". The naming syntax depends on the + // API management system being used for handling the request. + string service = 1; + + // The API operation name. For gRPC requests, it is the fully qualified API + // method name, such as "google.pubsub.v1.Publisher.Publish". For OpenAPI + // requests, it is the `operationId`, such as "getPet". + string operation = 2; + + // The API protocol used for sending the request, such as "http", "https", + // "grpc", or "internal". + string protocol = 3; + + // The API version associated with the API operation above, such as "v1" or + // "v1alpha1". + string version = 4; + } + + // This message defines request authentication attributes. Terminology is + // based on the JSON Web Token (JWT) standard, but the terms also + // correlate to concepts in other standards. + message Auth { + // The authenticated principal. Reflects the issuer (`iss`) and subject + // (`sub`) claims within a JWT. The issuer and subject should be `/` + // delimited, with `/` percent-encoded within the subject fragment. For + // Google accounts, the principal format is: + // "https://accounts.google.com/{id}" + string principal = 1; + + // The intended audience(s) for this authentication information. Reflects + // the audience (`aud`) claim within a JWT. The audience + // value(s) depends on the `issuer`, but typically include one or more of + // the following pieces of information: + // + // * The services intended to receive the credential. For example, + // ["https://pubsub.googleapis.com/", "https://storage.googleapis.com/"]. + // * A set of service-based scopes. For example, + // ["https://www.googleapis.com/auth/cloud-platform"]. + // * The client id of an app, such as the Firebase project id for JWTs + // from Firebase Auth. + // + // Consult the documentation for the credential issuer to determine the + // information provided. + repeated string audiences = 2; + + // The authorized presenter of the credential. Reflects the optional + // Authorized Presenter (`azp`) claim within a JWT or the + // OAuth client id. For example, a Google Cloud Platform client id looks + // as follows: "123456789012.apps.googleusercontent.com". + string presenter = 3; + + // Structured claims presented with the credential. JWTs include + // `{key: value}` pairs for standard and private claims. The following + // is a subset of the standard required and optional claims that would + // typically be presented for a Google-based JWT: + // + // {'iss': 'accounts.google.com', + // 'sub': '113289723416554971153', + // 'aud': ['123456789012', 'pubsub.googleapis.com'], + // 'azp': '123456789012.apps.googleusercontent.com', + // 'email': 'jsmith@example.com', + // 'iat': 1353601026, + // 'exp': 1353604926} + // + // SAML assertions are similarly specified, but with an identity provider + // dependent structure. + google.protobuf.Struct claims = 4; + + // A list of access level resource names that allow resources to be + // accessed by authenticated requester. It is part of Secure GCP processing + // for the incoming request. An access level string has the format: + // "//{api_service_name}/accessPolicies/{policy_id}/accessLevels/{short_name}" + // + // Example: + // "//accesscontextmanager.googleapis.com/accessPolicies/MY_POLICY_ID/accessLevels/MY_LEVEL" + repeated string access_levels = 5; + } + + // This message defines attributes for an HTTP request. If the actual + // request is not an HTTP request, the runtime system should try to map + // the actual request to an equivalent HTTP request. + message Request { + // The unique ID for a request, which can be propagated to downstream + // systems. The ID should have low probability of collision + // within a single day for a specific service. + string id = 1; + + // The HTTP request method, such as `GET`, `POST`. + string method = 2; + + // The HTTP request headers. If multiple headers share the same key, they + // must be merged according to the HTTP spec. All header keys must be + // lowercased, because HTTP header keys are case-insensitive. + map headers = 3; + + // The HTTP URL path, excluding the query parameters. + string path = 4; + + // The HTTP request `Host` header value. + string host = 5; + + // The HTTP URL scheme, such as `http` and `https`. + string scheme = 6; + + // The HTTP URL query in the format of `name1=value1&name2=value2`, as it + // appears in the first line of the HTTP request. No decoding is performed. + string query = 7; + + // The timestamp when the `destination` service receives the last byte of + // the request. + google.protobuf.Timestamp time = 9; + + // The HTTP request size in bytes. If unknown, it must be -1. + int64 size = 10; + + // The network protocol used with the request, such as "http/1.1", + // "spdy/3", "h2", "h2c", "webrtc", "tcp", "udp", "quic". See + // https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids + // for details. + string protocol = 11; + + // A special parameter for request reason. It is used by security systems + // to associate auditing information with a request. + string reason = 12; + + // The request authentication. May be absent for unauthenticated requests. + // Derived from the HTTP request `Authorization` header or equivalent. + Auth auth = 13; + } + + // This message defines attributes for a typical network response. It + // generally models semantics of an HTTP response. + message Response { + // The HTTP response status code, such as `200` and `404`. + int64 code = 1; + + // The HTTP response size in bytes. If unknown, it must be -1. + int64 size = 2; + + // The HTTP response headers. If multiple headers share the same key, they + // must be merged according to HTTP spec. All header keys must be + // lowercased, because HTTP header keys are case-insensitive. + map headers = 3; + + // The timestamp when the `destination` service sends the last byte of + // the response. + google.protobuf.Timestamp time = 4; + + // The amount of time it takes the backend service to fully respond to a + // request. Measured from when the destination service starts to send the + // request to the backend until when the destination service receives the + // complete response from the backend. + google.protobuf.Duration backend_latency = 5; + } + + // This message defines core attributes for a resource. A resource is an + // addressable (named) entity provided by the destination service. For + // example, a file stored on a network storage service. + message Resource { + // The name of the service that this resource belongs to, such as + // `pubsub.googleapis.com`. The service may be different from the DNS + // hostname that actually serves the request. + string service = 1; + + // The stable identifier (name) of a resource on the `service`. A resource + // can be logically identified as "//{resource.service}/{resource.name}". + // The differences between a resource name and a URI are: + // + // * Resource name is a logical identifier, independent of network + // protocol and API version. For example, + // `//pubsub.googleapis.com/projects/123/topics/news-feed`. + // * URI often includes protocol and version information, so it can + // be used directly by applications. For example, + // `https://pubsub.googleapis.com/v1/projects/123/topics/news-feed`. + // + // See https://cloud.google.com/apis/design/resource_names for details. + string name = 2; + + // The type of the resource. The syntax is platform-specific because + // different platforms define their resources differently. + // + // For Google APIs, the type format must be "{service}/{kind}", such as + // "pubsub.googleapis.com/Topic". + string type = 3; + + // The labels or tags on the resource, such as AWS resource tags and + // Kubernetes resource labels. + map labels = 4; + + // The unique identifier of the resource. UID is unique in the time + // and space for this resource within the scope of the service. It is + // typically generated by the server on successful creation of a resource + // and must not be changed. UID is used to uniquely identify resources + // with resource name reuses. This should be a UUID4. + string uid = 5; + + // Annotations is an unstructured key-value map stored with a resource that + // may be set by external tools to store and retrieve arbitrary metadata. + // They are not queryable and should be preserved when modifying objects. + // + // More info: + // https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ + map annotations = 6; + + // Mutable. The display name set by clients. Must be <= 63 characters. + string display_name = 7; + + // Output only. The timestamp when the resource was created. This may + // be either the time creation was initiated or when it was completed. + google.protobuf.Timestamp create_time = 8; + + // Output only. The timestamp when the resource was last updated. Any + // change to the resource made by users must refresh this value. + // Changes to a resource made by the service should refresh this value. + google.protobuf.Timestamp update_time = 9; + + // Output only. The timestamp when the resource was deleted. + // If the resource is not deleted, this must be empty. + google.protobuf.Timestamp delete_time = 10; + + // Output only. An opaque value that uniquely identifies a version or + // generation of a resource. It can be used to confirm that the client + // and server agree on the ordering of a resource being written. + string etag = 11; + + // Immutable. The location of the resource. The location encoding is + // specific to the service provider, and new encoding may be introduced + // as the service evolves. + // + // For Google Cloud products, the encoding is what is used by Google Cloud + // APIs, such as `us-east1`, `aws-us-east-1`, and `azure-eastus2`. The + // semantics of `location` is identical to the + // `cloud.googleapis.com/location` label used by some Google Cloud APIs. + string location = 12; + } + + // The origin of a network activity. In a multi hop network activity, + // the origin represents the sender of the first hop. For the first hop, + // the `source` and the `origin` must have the same content. + Peer origin = 7; + + // The source of a network activity, such as starting a TCP connection. + // In a multi hop network activity, the source represents the sender of the + // last hop. + Peer source = 1; + + // The destination of a network activity, such as accepting a TCP connection. + // In a multi hop network activity, the destination represents the receiver of + // the last hop. + Peer destination = 2; + + // Represents a network request, such as an HTTP request. + Request request = 3; + + // Represents a network response, such as an HTTP response. + Response response = 4; + + // Represents a target resource that is involved with a network activity. + // If multiple resources are involved with an activity, this must be the + // primary one. + Resource resource = 5; + + // Represents an API operation that is involved to a network activity. + Api api = 6; + + // Supports extensions for advanced use cases, such as logs and metrics. + repeated google.protobuf.Any extensions = 8; +} diff --git a/third_party/google/rpc/error_details.proto b/third_party/google/rpc/error_details.proto new file mode 100644 index 00000000..4f9ecff0 --- /dev/null +++ b/third_party/google/rpc/error_details.proto @@ -0,0 +1,363 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.rpc; + +import "google/protobuf/duration.proto"; + +option go_package = "google.golang.org/genproto/googleapis/rpc/errdetails;errdetails"; +option java_multiple_files = true; +option java_outer_classname = "ErrorDetailsProto"; +option java_package = "com.google.rpc"; +option objc_class_prefix = "RPC"; + +// Describes the cause of the error with structured details. +// +// Example of an error when contacting the "pubsub.googleapis.com" API when it +// is not enabled: +// +// { "reason": "API_DISABLED" +// "domain": "googleapis.com" +// "metadata": { +// "resource": "projects/123", +// "service": "pubsub.googleapis.com" +// } +// } +// +// This response indicates that the pubsub.googleapis.com API is not enabled. +// +// Example of an error that is returned when attempting to create a Spanner +// instance in a region that is out of stock: +// +// { "reason": "STOCKOUT" +// "domain": "spanner.googleapis.com", +// "metadata": { +// "availableRegions": "us-central1,us-east2" +// } +// } +message ErrorInfo { + // The reason of the error. This is a constant value that identifies the + // proximate cause of the error. Error reasons are unique within a particular + // domain of errors. This should be at most 63 characters and match a + // regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, which represents + // UPPER_SNAKE_CASE. + string reason = 1; + + // The logical grouping to which the "reason" belongs. The error domain + // is typically the registered service name of the tool or product that + // generates the error. Example: "pubsub.googleapis.com". If the error is + // generated by some common infrastructure, the error domain must be a + // globally unique value that identifies the infrastructure. For Google API + // infrastructure, the error domain is "googleapis.com". + string domain = 2; + + // Additional structured details about this error. + // + // Keys must match a regular expression of `[a-z][a-zA-Z0-9-_]+` but should + // ideally be lowerCamelCase. Also, they must be limited to 64 characters in + // length. When identifying the current value of an exceeded limit, the units + // should be contained in the key, not the value. For example, rather than + // `{"instanceLimit": "100/request"}`, should be returned as, + // `{"instanceLimitPerRequest": "100"}`, if the client exceeds the number of + // instances that can be created in a single (batch) request. + map metadata = 3; +} + +// Describes when the clients can retry a failed request. Clients could ignore +// the recommendation here or retry when this information is missing from error +// responses. +// +// It's always recommended that clients should use exponential backoff when +// retrying. +// +// Clients should wait until `retry_delay` amount of time has passed since +// receiving the error response before retrying. If retrying requests also +// fail, clients should use an exponential backoff scheme to gradually increase +// the delay between retries based on `retry_delay`, until either a maximum +// number of retries have been reached or a maximum retry delay cap has been +// reached. +message RetryInfo { + // Clients should wait at least this long between retrying the same request. + google.protobuf.Duration retry_delay = 1; +} + +// Describes additional debugging info. +message DebugInfo { + // The stack trace entries indicating where the error occurred. + repeated string stack_entries = 1; + + // Additional debugging information provided by the server. + string detail = 2; +} + +// Describes how a quota check failed. +// +// For example if a daily limit was exceeded for the calling project, +// a service could respond with a QuotaFailure detail containing the project +// id and the description of the quota limit that was exceeded. If the +// calling project hasn't enabled the service in the developer console, then +// a service could respond with the project id and set `service_disabled` +// to true. +// +// Also see RetryInfo and Help types for other details about handling a +// quota failure. +message QuotaFailure { + // A message type used to describe a single quota violation. For example, a + // daily quota or a custom quota that was exceeded. + message Violation { + // The subject on which the quota check failed. + // For example, "clientip:" or "project:". + string subject = 1; + + // A description of how the quota check failed. Clients can use this + // description to find more about the quota configuration in the service's + // public documentation, or find the relevant quota limit to adjust through + // developer console. + // + // For example: "Service disabled" or "Daily Limit for read operations + // exceeded". + string description = 2; + + // The API Service from which the `QuotaFailure.Violation` orginates. In + // some cases, Quota issues originate from an API Service other than the one + // that was called. In other words, a dependency of the called API Service + // could be the cause of the `QuotaFailure`, and this field would have the + // dependency API service name. + // + // For example, if the called API is Kubernetes Engine API + // (container.googleapis.com), and a quota violation occurs in the + // Kubernetes Engine API itself, this field would be + // "container.googleapis.com". On the other hand, if the quota violation + // occurs when the Kubernetes Engine API creates VMs in the Compute Engine + // API (compute.googleapis.com), this field would be + // "compute.googleapis.com". + string api_service = 3; + + // The metric of the violated quota. A quota metric is a named counter to + // measure usage, such as API requests or CPUs. When an activity occurs in a + // service, such as Virtual Machine allocation, one or more quota metrics + // may be affected. + // + // For example, "compute.googleapis.com/cpus_per_vm_family", + // "storage.googleapis.com/internet_egress_bandwidth". + string quota_metric = 4; + + // The id of the violated quota. Also know as "limit name", this is the + // unique identifier of a quota in the context of an API service. + // + // For example, "CPUS-PER-VM-FAMILY-per-project-region". + string quota_id = 5; + + // The dimensions of the violated quota. Every non-global quota is enforced + // on a set of dimensions. While quota metric defines what to count, the + // dimensions specify for what aspects the counter should be increased. + // + // For example, the quota "CPUs per region per VM family" enforces a limit + // on the metric "compute.googleapis.com/cpus_per_vm_family" on dimensions + // "region" and "vm_family". And if the violation occurred in region + // "us-central1" and for VM family "n1", the quota_dimensions would be, + // + // { + // "region": "us-central1", + // "vm_family": "n1", + // } + // + // When a quota is enforced globally, the quota_dimensions would always be + // empty. + map quota_dimensions = 6; + + // The enforced quota value at the time of the `QuotaFailure`. + // + // For example, if the enforced quota value at the time of the + // `QuotaFailure` on the number of CPUs is "10", then the value of this + // field would reflect this quantity. + int64 quota_value = 7; + + // The new quota value being rolled out at the time of the violation. At the + // completion of the rollout, this value will be enforced in place of + // quota_value. If no rollout is in progress at the time of the violation, + // this field is not set. + // + // For example, if at the time of the violation a rollout is in progress + // changing the number of CPUs quota from 10 to 20, 20 would be the value of + // this field. + optional int64 future_quota_value = 8; + } + + // Describes all quota violations. + repeated Violation violations = 1; +} + +// Describes what preconditions have failed. +// +// For example, if an RPC failed because it required the Terms of Service to be +// acknowledged, it could list the terms of service violation in the +// PreconditionFailure message. +message PreconditionFailure { + // A message type used to describe a single precondition failure. + message Violation { + // The type of PreconditionFailure. We recommend using a service-specific + // enum type to define the supported precondition violation subjects. For + // example, "TOS" for "Terms of Service violation". + string type = 1; + + // The subject, relative to the type, that failed. + // For example, "google.com/cloud" relative to the "TOS" type would indicate + // which terms of service is being referenced. + string subject = 2; + + // A description of how the precondition failed. Developers can use this + // description to understand how to fix the failure. + // + // For example: "Terms of service not accepted". + string description = 3; + } + + // Describes all precondition violations. + repeated Violation violations = 1; +} + +// Describes violations in a client request. This error type focuses on the +// syntactic aspects of the request. +message BadRequest { + // A message type used to describe a single bad request field. + message FieldViolation { + // A path that leads to a field in the request body. The value will be a + // sequence of dot-separated identifiers that identify a protocol buffer + // field. + // + // Consider the following: + // + // message CreateContactRequest { + // message EmailAddress { + // enum Type { + // TYPE_UNSPECIFIED = 0; + // HOME = 1; + // WORK = 2; + // } + // + // optional string email = 1; + // repeated EmailType type = 2; + // } + // + // string full_name = 1; + // repeated EmailAddress email_addresses = 2; + // } + // + // In this example, in proto `field` could take one of the following values: + // + // * `full_name` for a violation in the `full_name` value + // * `email_addresses[1].email` for a violation in the `email` field of the + // first `email_addresses` message + // * `email_addresses[3].type[2]` for a violation in the second `type` + // value in the third `email_addresses` message. + // + // In JSON, the same values are represented as: + // + // * `fullName` for a violation in the `fullName` value + // * `emailAddresses[1].email` for a violation in the `email` field of the + // first `emailAddresses` message + // * `emailAddresses[3].type[2]` for a violation in the second `type` + // value in the third `emailAddresses` message. + string field = 1; + + // A description of why the request element is bad. + string description = 2; + + // The reason of the field-level error. This is a constant value that + // identifies the proximate cause of the field-level error. It should + // uniquely identify the type of the FieldViolation within the scope of the + // google.rpc.ErrorInfo.domain. This should be at most 63 + // characters and match a regular expression of `[A-Z][A-Z0-9_]+[A-Z0-9]`, + // which represents UPPER_SNAKE_CASE. + string reason = 3; + + // Provides a localized error message for field-level errors that is safe to + // return to the API consumer. + LocalizedMessage localized_message = 4; + } + + // Describes all violations in a client request. + repeated FieldViolation field_violations = 1; +} + +// Contains metadata about the request that clients can attach when filing a bug +// or providing other forms of feedback. +message RequestInfo { + // An opaque string that should only be interpreted by the service generating + // it. For example, it can be used to identify requests in the service's logs. + string request_id = 1; + + // Any data that was used to serve this request. For example, an encrypted + // stack trace that can be sent back to the service provider for debugging. + string serving_data = 2; +} + +// Describes the resource that is being accessed. +message ResourceInfo { + // A name for the type of resource being accessed, e.g. "sql table", + // "cloud storage bucket", "file", "Google calendar"; or the type URL + // of the resource: e.g. "type.googleapis.com/google.pubsub.v1.Topic". + string resource_type = 1; + + // The name of the resource being accessed. For example, a shared calendar + // name: "example.com_4fghdhgsrgh@group.calendar.google.com", if the current + // error is + // [google.rpc.Code.PERMISSION_DENIED][google.rpc.Code.PERMISSION_DENIED]. + string resource_name = 2; + + // The owner of the resource (optional). + // For example, "user:" or "project:". + string owner = 3; + + // Describes what error is encountered when accessing this resource. + // For example, updating a cloud project may require the `writer` permission + // on the developer console project. + string description = 4; +} + +// Provides links to documentation or for performing an out of band action. +// +// For example, if a quota check failed with an error indicating the calling +// project hasn't enabled the accessed service, this can contain a URL pointing +// directly to the right place in the developer console to flip the bit. +message Help { + // Describes a URL link. + message Link { + // Describes what the link offers. + string description = 1; + + // The URL of the link. + string url = 2; + } + + // URL(s) pointing to additional information on handling the current error. + repeated Link links = 1; +} + +// Provides a localized error message that is safe to return to the user +// which can be attached to an RPC error. +message LocalizedMessage { + // The locale used following the specification defined at + // https://www.rfc-editor.org/rfc/bcp/bcp47.txt. + // Examples are: "en-US", "fr-CH", "es-MX" + string locale = 1; + + // The localized error message in the above locale. + string message = 2; +} diff --git a/third_party/google/rpc/status.proto b/third_party/google/rpc/status.proto new file mode 100644 index 00000000..dc14c943 --- /dev/null +++ b/third_party/google/rpc/status.proto @@ -0,0 +1,49 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.rpc; + +import "google/protobuf/any.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/rpc/status;status"; +option java_multiple_files = true; +option java_outer_classname = "StatusProto"; +option java_package = "com.google.rpc"; +option objc_class_prefix = "RPC"; + +// The `Status` type defines a logical error model that is suitable for +// different programming environments, including REST APIs and RPC APIs. It is +// used by [gRPC](https://github.com/grpc). Each `Status` message contains +// three pieces of data: error code, error message, and error details. +// +// You can find out more about this error model and how to work with it in the +// [API Design Guide](https://cloud.google.com/apis/design/errors). +message Status { + // The status code, which should be an enum value of + // [google.rpc.Code][google.rpc.Code]. + int32 code = 1; + + // A developer-facing error message, which should be in English. Any + // user-facing error message should be localized and sent in the + // [google.rpc.Status.details][google.rpc.Status.details] field, or localized + // by the client. + string message = 2; + + // A list of messages that carry the error details. There is a common set of + // message types for APIs to use. + repeated google.protobuf.Any details = 3; +} diff --git a/third_party/google/type/calendar_period.proto b/third_party/google/type/calendar_period.proto new file mode 100644 index 00000000..57d360ad --- /dev/null +++ b/third_party/google/type/calendar_period.proto @@ -0,0 +1,56 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option go_package = "google.golang.org/genproto/googleapis/type/calendarperiod;calendarperiod"; +option java_multiple_files = true; +option java_outer_classname = "CalendarPeriodProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// A `CalendarPeriod` represents the abstract concept of a time period that has +// a canonical start. Grammatically, "the start of the current +// `CalendarPeriod`." All calendar times begin at midnight UTC. +enum CalendarPeriod { + // Undefined period, raises an error. + CALENDAR_PERIOD_UNSPECIFIED = 0; + + // A day. + DAY = 1; + + // A week. Weeks begin on Monday, following + // [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date). + WEEK = 2; + + // A fortnight. The first calendar fortnight of the year begins at the start + // of week 1 according to + // [ISO 8601](https://en.wikipedia.org/wiki/ISO_week_date). + FORTNIGHT = 3; + + // A month. + MONTH = 4; + + // A quarter. Quarters start on dates 1-Jan, 1-Apr, 1-Jul, and 1-Oct of each + // year. + QUARTER = 5; + + // A half-year. Half-years start on dates 1-Jan and 1-Jul. + HALF = 6; + + // A year. + YEAR = 7; +} diff --git a/third_party/google/type/color.proto b/third_party/google/type/color.proto new file mode 100644 index 00000000..26508db9 --- /dev/null +++ b/third_party/google/type/color.proto @@ -0,0 +1,174 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +import "google/protobuf/wrappers.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/color;color"; +option java_multiple_files = true; +option java_outer_classname = "ColorProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents a color in the RGBA color space. This representation is designed +// for simplicity of conversion to/from color representations in various +// languages over compactness. For example, the fields of this representation +// can be trivially provided to the constructor of `java.awt.Color` in Java; it +// can also be trivially provided to UIColor's `+colorWithRed:green:blue:alpha` +// method in iOS; and, with just a little work, it can be easily formatted into +// a CSS `rgba()` string in JavaScript. +// +// This reference page doesn't carry information about the absolute color +// space +// that should be used to interpret the RGB value (e.g. sRGB, Adobe RGB, +// DCI-P3, BT.2020, etc.). By default, applications should assume the sRGB color +// space. +// +// When color equality needs to be decided, implementations, unless +// documented otherwise, treat two colors as equal if all their red, +// green, blue, and alpha values each differ by at most 1e-5. +// +// Example (Java): +// +// import com.google.type.Color; +// +// // ... +// public static java.awt.Color fromProto(Color protocolor) { +// float alpha = protocolor.hasAlpha() +// ? protocolor.getAlpha().getValue() +// : 1.0; +// +// return new java.awt.Color( +// protocolor.getRed(), +// protocolor.getGreen(), +// protocolor.getBlue(), +// alpha); +// } +// +// public static Color toProto(java.awt.Color color) { +// float red = (float) color.getRed(); +// float green = (float) color.getGreen(); +// float blue = (float) color.getBlue(); +// float denominator = 255.0; +// Color.Builder resultBuilder = +// Color +// .newBuilder() +// .setRed(red / denominator) +// .setGreen(green / denominator) +// .setBlue(blue / denominator); +// int alpha = color.getAlpha(); +// if (alpha != 255) { +// result.setAlpha( +// FloatValue +// .newBuilder() +// .setValue(((float) alpha) / denominator) +// .build()); +// } +// return resultBuilder.build(); +// } +// // ... +// +// Example (iOS / Obj-C): +// +// // ... +// static UIColor* fromProto(Color* protocolor) { +// float red = [protocolor red]; +// float green = [protocolor green]; +// float blue = [protocolor blue]; +// FloatValue* alpha_wrapper = [protocolor alpha]; +// float alpha = 1.0; +// if (alpha_wrapper != nil) { +// alpha = [alpha_wrapper value]; +// } +// return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; +// } +// +// static Color* toProto(UIColor* color) { +// CGFloat red, green, blue, alpha; +// if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) { +// return nil; +// } +// Color* result = [[Color alloc] init]; +// [result setRed:red]; +// [result setGreen:green]; +// [result setBlue:blue]; +// if (alpha <= 0.9999) { +// [result setAlpha:floatWrapperWithValue(alpha)]; +// } +// [result autorelease]; +// return result; +// } +// // ... +// +// Example (JavaScript): +// +// // ... +// +// var protoToCssColor = function(rgb_color) { +// var redFrac = rgb_color.red || 0.0; +// var greenFrac = rgb_color.green || 0.0; +// var blueFrac = rgb_color.blue || 0.0; +// var red = Math.floor(redFrac * 255); +// var green = Math.floor(greenFrac * 255); +// var blue = Math.floor(blueFrac * 255); +// +// if (!('alpha' in rgb_color)) { +// return rgbToCssColor(red, green, blue); +// } +// +// var alphaFrac = rgb_color.alpha.value || 0.0; +// var rgbParams = [red, green, blue].join(','); +// return ['rgba(', rgbParams, ',', alphaFrac, ')'].join(''); +// }; +// +// var rgbToCssColor = function(red, green, blue) { +// var rgbNumber = new Number((red << 16) | (green << 8) | blue); +// var hexString = rgbNumber.toString(16); +// var missingZeros = 6 - hexString.length; +// var resultBuilder = ['#']; +// for (var i = 0; i < missingZeros; i++) { +// resultBuilder.push('0'); +// } +// resultBuilder.push(hexString); +// return resultBuilder.join(''); +// }; +// +// // ... +message Color { + // The amount of red in the color as a value in the interval [0, 1]. + float red = 1; + + // The amount of green in the color as a value in the interval [0, 1]. + float green = 2; + + // The amount of blue in the color as a value in the interval [0, 1]. + float blue = 3; + + // The fraction of this color that should be applied to the pixel. That is, + // the final pixel color is defined by the equation: + // + // `pixel color = alpha * (this color) + (1.0 - alpha) * (background color)` + // + // This means that a value of 1.0 corresponds to a solid color, whereas + // a value of 0.0 corresponds to a completely transparent color. This + // uses a wrapper message rather than a simple float scalar so that it is + // possible to distinguish between a default value and the value being unset. + // If omitted, this color object is rendered as a solid color + // (as if the alpha value had been explicitly given a value of 1.0). + google.protobuf.FloatValue alpha = 4; +} diff --git a/third_party/google/type/date.proto b/third_party/google/type/date.proto new file mode 100644 index 00000000..6f63436e --- /dev/null +++ b/third_party/google/type/date.proto @@ -0,0 +1,52 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/date;date"; +option java_multiple_files = true; +option java_outer_classname = "DateProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents a whole or partial calendar date, such as a birthday. The time of +// day and time zone are either specified elsewhere or are insignificant. The +// date is relative to the Gregorian Calendar. This can represent one of the +// following: +// +// * A full date, with non-zero year, month, and day values +// * A month and day value, with a zero year, such as an anniversary +// * A year on its own, with zero month and day values +// * A year and month value, with a zero day, such as a credit card expiration +// date +// +// Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and +// `google.protobuf.Timestamp`. +message Date { + // Year of the date. Must be from 1 to 9999, or 0 to specify a date without + // a year. + int32 year = 1; + + // Month of a year. Must be from 1 to 12, or 0 to specify a year without a + // month and day. + int32 month = 2; + + // Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 + // to specify a year by itself or a year and month where the day isn't + // significant. + int32 day = 3; +} diff --git a/third_party/google/type/datetime.proto b/third_party/google/type/datetime.proto new file mode 100644 index 00000000..9f0d62b0 --- /dev/null +++ b/third_party/google/type/datetime.proto @@ -0,0 +1,104 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +import "google/protobuf/duration.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/datetime;datetime"; +option java_multiple_files = true; +option java_outer_classname = "DateTimeProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents civil time (or occasionally physical time). +// +// This type can represent a civil time in one of a few possible ways: +// +// * When utc_offset is set and time_zone is unset: a civil time on a calendar +// day with a particular offset from UTC. +// * When time_zone is set and utc_offset is unset: a civil time on a calendar +// day in a particular time zone. +// * When neither time_zone nor utc_offset is set: a civil time on a calendar +// day in local time. +// +// The date is relative to the Proleptic Gregorian Calendar. +// +// If year is 0, the DateTime is considered not to have a specific year. month +// and day must have valid, non-zero values. +// +// This type may also be used to represent a physical time if all the date and +// time fields are set and either case of the `time_offset` oneof is set. +// Consider using `Timestamp` message for physical time instead. If your use +// case also would like to store the user's timezone, that can be done in +// another field. +// +// This type is more flexible than some applications may want. Make sure to +// document and validate your application's limitations. +message DateTime { + // Optional. Year of date. Must be from 1 to 9999, or 0 if specifying a + // datetime without a year. + int32 year = 1; + + // Required. Month of year. Must be from 1 to 12. + int32 month = 2; + + // Required. Day of month. Must be from 1 to 31 and valid for the year and + // month. + int32 day = 3; + + // Required. Hours of day in 24 hour format. Should be from 0 to 23. An API + // may choose to allow the value "24:00:00" for scenarios like business + // closing time. + int32 hours = 4; + + // Required. Minutes of hour of day. Must be from 0 to 59. + int32 minutes = 5; + + // Required. Seconds of minutes of the time. Must normally be from 0 to 59. An + // API may allow the value 60 if it allows leap-seconds. + int32 seconds = 6; + + // Required. Fractions of seconds in nanoseconds. Must be from 0 to + // 999,999,999. + int32 nanos = 7; + + // Optional. Specifies either the UTC offset or the time zone of the DateTime. + // Choose carefully between them, considering that time zone data may change + // in the future (for example, a country modifies their DST start/end dates, + // and future DateTimes in the affected range had already been stored). + // If omitted, the DateTime is considered to be in local time. + oneof time_offset { + // UTC offset. Must be whole seconds, between -18 hours and +18 hours. + // For example, a UTC offset of -4:00 would be represented as + // { seconds: -14400 }. + google.protobuf.Duration utc_offset = 8; + + // Time zone. + TimeZone time_zone = 9; + } +} + +// Represents a time zone from the +// [IANA Time Zone Database](https://www.iana.org/time-zones). +message TimeZone { + // IANA Time Zone Database time zone, e.g. "America/New_York". + string id = 1; + + // Optional. IANA Time Zone Database version number, e.g. "2019a". + string version = 2; +} diff --git a/third_party/google/type/dayofweek.proto b/third_party/google/type/dayofweek.proto new file mode 100644 index 00000000..5684bec3 --- /dev/null +++ b/third_party/google/type/dayofweek.proto @@ -0,0 +1,50 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option go_package = "google.golang.org/genproto/googleapis/type/dayofweek;dayofweek"; +option java_multiple_files = true; +option java_outer_classname = "DayOfWeekProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents a day of the week. +enum DayOfWeek { + // The day of the week is unspecified. + DAY_OF_WEEK_UNSPECIFIED = 0; + + // Monday + MONDAY = 1; + + // Tuesday + TUESDAY = 2; + + // Wednesday + WEDNESDAY = 3; + + // Thursday + THURSDAY = 4; + + // Friday + FRIDAY = 5; + + // Saturday + SATURDAY = 6; + + // Sunday + SUNDAY = 7; +} diff --git a/third_party/google/type/decimal.proto b/third_party/google/type/decimal.proto new file mode 100644 index 00000000..77a06db0 --- /dev/null +++ b/third_party/google/type/decimal.proto @@ -0,0 +1,95 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/decimal;decimal"; +option java_multiple_files = true; +option java_outer_classname = "DecimalProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// A representation of a decimal value, such as 2.5. Clients may convert values +// into language-native decimal formats, such as Java's [BigDecimal][] or +// Python's [decimal.Decimal][]. +// +// [BigDecimal]: +// https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html +// [decimal.Decimal]: https://docs.python.org/3/library/decimal.html +message Decimal { + // The decimal value, as a string. + // + // The string representation consists of an optional sign, `+` (`U+002B`) + // or `-` (`U+002D`), followed by a sequence of zero or more decimal digits + // ("the integer"), optionally followed by a fraction, optionally followed + // by an exponent. + // + // The fraction consists of a decimal point followed by zero or more decimal + // digits. The string must contain at least one digit in either the integer + // or the fraction. The number formed by the sign, the integer and the + // fraction is referred to as the significand. + // + // The exponent consists of the character `e` (`U+0065`) or `E` (`U+0045`) + // followed by one or more decimal digits. + // + // Services **should** normalize decimal values before storing them by: + // + // - Removing an explicitly-provided `+` sign (`+2.5` -> `2.5`). + // - Replacing a zero-length integer value with `0` (`.5` -> `0.5`). + // - Coercing the exponent character to lower-case (`2.5E8` -> `2.5e8`). + // - Removing an explicitly-provided zero exponent (`2.5e0` -> `2.5`). + // + // Services **may** perform additional normalization based on its own needs + // and the internal decimal implementation selected, such as shifting the + // decimal point and exponent value together (example: `2.5e-1` <-> `0.25`). + // Additionally, services **may** preserve trailing zeroes in the fraction + // to indicate increased precision, but are not required to do so. + // + // Note that only the `.` character is supported to divide the integer + // and the fraction; `,` **should not** be supported regardless of locale. + // Additionally, thousand separators **should not** be supported. If a + // service does support them, values **must** be normalized. + // + // The ENBF grammar is: + // + // DecimalString = + // [Sign] Significand [Exponent]; + // + // Sign = '+' | '-'; + // + // Significand = + // Digits ['.'] [Digits] | [Digits] '.' Digits; + // + // Exponent = ('e' | 'E') [Sign] Digits; + // + // Digits = { '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' }; + // + // Services **should** clearly document the range of supported values, the + // maximum supported precision (total number of digits), and, if applicable, + // the scale (number of digits after the decimal point), as well as how it + // behaves when receiving out-of-bounds values. + // + // Services **may** choose to accept values passed as input even when the + // value has a higher precision or scale than the service supports, and + // **should** round the value to fit the supported scale. Alternatively, the + // service **may** error with `400 Bad Request` (`INVALID_ARGUMENT` in gRPC) + // if precision would be lost. + // + // Services **should** error with `400 Bad Request` (`INVALID_ARGUMENT` in + // gRPC) if the service receives a value outside of the supported range. + string value = 1; +} diff --git a/third_party/google/type/expr.proto b/third_party/google/type/expr.proto new file mode 100644 index 00000000..97c4f7da --- /dev/null +++ b/third_party/google/type/expr.proto @@ -0,0 +1,73 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option go_package = "google.golang.org/genproto/googleapis/type/expr;expr"; +option java_multiple_files = true; +option java_outer_classname = "ExprProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents a textual expression in the Common Expression Language (CEL) +// syntax. CEL is a C-like expression language. The syntax and semantics of CEL +// are documented at https://github.com/google/cel-spec. +// +// Example (Comparison): +// +// title: "Summary size limit" +// description: "Determines if a summary is less than 100 chars" +// expression: "document.summary.size() < 100" +// +// Example (Equality): +// +// title: "Requestor is owner" +// description: "Determines if requestor is the document owner" +// expression: "document.owner == request.auth.claims.email" +// +// Example (Logic): +// +// title: "Public documents" +// description: "Determine whether the document should be publicly visible" +// expression: "document.type != 'private' && document.type != 'internal'" +// +// Example (Data Manipulation): +// +// title: "Notification string" +// description: "Create a notification string with a timestamp." +// expression: "'New message received at ' + string(document.create_time)" +// +// The exact variables and functions that may be referenced within an expression +// are determined by the service that evaluates it. See the service +// documentation for additional information. +message Expr { + // Textual representation of an expression in Common Expression Language + // syntax. + string expression = 1; + + // Optional. Title for the expression, i.e. a short string describing + // its purpose. This can be used e.g. in UIs which allow to enter the + // expression. + string title = 2; + + // Optional. Description of the expression. This is a longer text which + // describes the expression, e.g. when hovered over it in a UI. + string description = 3; + + // Optional. String indicating the location of the expression for error + // reporting, e.g. a file name and a position in the file. + string location = 4; +} diff --git a/third_party/google/type/fraction.proto b/third_party/google/type/fraction.proto new file mode 100644 index 00000000..b3b0d0f3 --- /dev/null +++ b/third_party/google/type/fraction.proto @@ -0,0 +1,33 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option go_package = "google.golang.org/genproto/googleapis/type/fraction;fraction"; +option java_multiple_files = true; +option java_outer_classname = "FractionProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents a fraction in terms of a numerator divided by a denominator. +message Fraction { + // The numerator in the fraction, e.g. 2 in 2/3. + int64 numerator = 1; + + // The value by which the numerator is divided, e.g. 3 in 2/3. Must be + // positive. + int64 denominator = 2; +} diff --git a/third_party/google/type/interval.proto b/third_party/google/type/interval.proto new file mode 100644 index 00000000..d9b24271 --- /dev/null +++ b/third_party/google/type/interval.proto @@ -0,0 +1,46 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +import "google/protobuf/timestamp.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/interval;interval"; +option java_multiple_files = true; +option java_outer_classname = "IntervalProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents a time interval, encoded as a Timestamp start (inclusive) and a +// Timestamp end (exclusive). +// +// The start must be less than or equal to the end. +// When the start equals the end, the interval is empty (matches no time). +// When both start and end are unspecified, the interval matches any time. +message Interval { + // Optional. Inclusive start of the interval. + // + // If specified, a Timestamp matching this interval will have to be the same + // or after the start. + google.protobuf.Timestamp start_time = 1; + + // Optional. Exclusive end of the interval. + // + // If specified, a Timestamp matching this interval will have to be before the + // end. + google.protobuf.Timestamp end_time = 2; +} diff --git a/third_party/google/type/latlng.proto b/third_party/google/type/latlng.proto new file mode 100644 index 00000000..6714f65b --- /dev/null +++ b/third_party/google/type/latlng.proto @@ -0,0 +1,37 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/latlng;latlng"; +option java_multiple_files = true; +option java_outer_classname = "LatLngProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// An object that represents a latitude/longitude pair. This is expressed as a +// pair of doubles to represent degrees latitude and degrees longitude. Unless +// specified otherwise, this must conform to the +// WGS84 +// standard. Values must be within normalized ranges. +message LatLng { + // The latitude in degrees. It must be in the range [-90.0, +90.0]. + double latitude = 1; + + // The longitude in degrees. It must be in the range [-180.0, +180.0]. + double longitude = 2; +} diff --git a/third_party/google/type/localized_text.proto b/third_party/google/type/localized_text.proto new file mode 100644 index 00000000..3971e811 --- /dev/null +++ b/third_party/google/type/localized_text.proto @@ -0,0 +1,36 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/localized_text;localized_text"; +option java_multiple_files = true; +option java_outer_classname = "LocalizedTextProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Localized variant of a text in a particular language. +message LocalizedText { + // Localized string in the language corresponding to `language_code' below. + string text = 1; + + // The text's BCP-47 language code, such as "en-US" or "sr-Latn". + // + // For more information, see + // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier. + string language_code = 2; +} diff --git a/third_party/google/type/money.proto b/third_party/google/type/money.proto new file mode 100644 index 00000000..f67aa51f --- /dev/null +++ b/third_party/google/type/money.proto @@ -0,0 +1,42 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/money;money"; +option java_multiple_files = true; +option java_outer_classname = "MoneyProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents an amount of money with its currency type. +message Money { + // The three-letter currency code defined in ISO 4217. + string currency_code = 1; + + // The whole units of the amount. + // For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar. + int64 units = 2; + + // Number of nano (10^-9) units of the amount. + // The value must be between -999,999,999 and +999,999,999 inclusive. + // If `units` is positive, `nanos` must be positive or zero. + // If `units` is zero, `nanos` can be positive, zero, or negative. + // If `units` is negative, `nanos` must be negative or zero. + // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000. + int32 nanos = 3; +} diff --git a/third_party/google/type/month.proto b/third_party/google/type/month.proto new file mode 100644 index 00000000..169282ae --- /dev/null +++ b/third_party/google/type/month.proto @@ -0,0 +1,65 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option go_package = "google.golang.org/genproto/googleapis/type/month;month"; +option java_multiple_files = true; +option java_outer_classname = "MonthProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents a month in the Gregorian calendar. +enum Month { + // The unspecified month. + MONTH_UNSPECIFIED = 0; + + // The month of January. + JANUARY = 1; + + // The month of February. + FEBRUARY = 2; + + // The month of March. + MARCH = 3; + + // The month of April. + APRIL = 4; + + // The month of May. + MAY = 5; + + // The month of June. + JUNE = 6; + + // The month of July. + JULY = 7; + + // The month of August. + AUGUST = 8; + + // The month of September. + SEPTEMBER = 9; + + // The month of October. + OCTOBER = 10; + + // The month of November. + NOVEMBER = 11; + + // The month of December. + DECEMBER = 12; +} diff --git a/third_party/google/type/phone_number.proto b/third_party/google/type/phone_number.proto new file mode 100644 index 00000000..23dbc6bd --- /dev/null +++ b/third_party/google/type/phone_number.proto @@ -0,0 +1,113 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/phone_number;phone_number"; +option java_multiple_files = true; +option java_outer_classname = "PhoneNumberProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// An object representing a phone number, suitable as an API wire format. +// +// This representation: +// +// - should not be used for locale-specific formatting of a phone number, such +// as "+1 (650) 253-0000 ext. 123" +// +// - is not designed for efficient storage +// - may not be suitable for dialing - specialized libraries (see references) +// should be used to parse the number for that purpose +// +// To do something meaningful with this number, such as format it for various +// use-cases, convert it to an `i18n.phonenumbers.PhoneNumber` object first. +// +// For instance, in Java this would be: +// +// com.google.type.PhoneNumber wireProto = +// com.google.type.PhoneNumber.newBuilder().build(); +// com.google.i18n.phonenumbers.Phonenumber.PhoneNumber phoneNumber = +// PhoneNumberUtil.getInstance().parse(wireProto.getE164Number(), "ZZ"); +// if (!wireProto.getExtension().isEmpty()) { +// phoneNumber.setExtension(wireProto.getExtension()); +// } +// +// Reference(s): +// - https://github.com/google/libphonenumber +message PhoneNumber { + // An object representing a short code, which is a phone number that is + // typically much shorter than regular phone numbers and can be used to + // address messages in MMS and SMS systems, as well as for abbreviated dialing + // (e.g. "Text 611 to see how many minutes you have remaining on your plan."). + // + // Short codes are restricted to a region and are not internationally + // dialable, which means the same short code can exist in different regions, + // with different usage and pricing, even if those regions share the same + // country calling code (e.g. US and CA). + message ShortCode { + // Required. The BCP-47 region code of the location where calls to this + // short code can be made, such as "US" and "BB". + // + // Reference(s): + // - http://www.unicode.org/reports/tr35/#unicode_region_subtag + string region_code = 1; + + // Required. The short code digits, without a leading plus ('+') or country + // calling code, e.g. "611". + string number = 2; + } + + // Required. Either a regular number, or a short code. New fields may be + // added to the oneof below in the future, so clients should ignore phone + // numbers for which none of the fields they coded against are set. + oneof kind { + // The phone number, represented as a leading plus sign ('+'), followed by a + // phone number that uses a relaxed ITU E.164 format consisting of the + // country calling code (1 to 3 digits) and the subscriber number, with no + // additional spaces or formatting, e.g.: + // - correct: "+15552220123" + // - incorrect: "+1 (555) 222-01234 x123". + // + // The ITU E.164 format limits the latter to 12 digits, but in practice not + // all countries respect that, so we relax that restriction here. + // National-only numbers are not allowed. + // + // References: + // - https://www.itu.int/rec/T-REC-E.164-201011-I + // - https://en.wikipedia.org/wiki/E.164. + // - https://en.wikipedia.org/wiki/List_of_country_calling_codes + string e164_number = 1; + + // A short code. + // + // Reference(s): + // - https://en.wikipedia.org/wiki/Short_code + ShortCode short_code = 2; + } + + // The phone number's extension. The extension is not standardized in ITU + // recommendations, except for being defined as a series of numbers with a + // maximum length of 40 digits. Other than digits, some other dialing + // characters such as ',' (indicating a wait) or '#' may be stored here. + // + // Note that no regions currently use extensions with short codes, so this + // field is normally only set in conjunction with an E.164 number. It is held + // separately from the E.164 number to allow for short code extensions in the + // future. + string extension = 3; +} diff --git a/third_party/google/type/postal_address.proto b/third_party/google/type/postal_address.proto new file mode 100644 index 00000000..e58d5c35 --- /dev/null +++ b/third_party/google/type/postal_address.proto @@ -0,0 +1,134 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/postaladdress;postaladdress"; +option java_multiple_files = true; +option java_outer_classname = "PostalAddressProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents a postal address, e.g. for postal delivery or payments addresses. +// Given a postal address, a postal service can deliver items to a premise, P.O. +// Box or similar. +// It is not intended to model geographical locations (roads, towns, +// mountains). +// +// In typical usage an address would be created via user input or from importing +// existing data, depending on the type of process. +// +// Advice on address input / editing: +// - Use an i18n-ready address widget such as +// https://github.com/google/libaddressinput) +// - Users should not be presented with UI elements for input or editing of +// fields outside countries where that field is used. +// +// For more guidance on how to use this schema, please see: +// https://support.google.com/business/answer/6397478 +message PostalAddress { + // The schema revision of the `PostalAddress`. This must be set to 0, which is + // the latest revision. + // + // All new revisions **must** be backward compatible with old revisions. + int32 revision = 1; + + // Required. CLDR region code of the country/region of the address. This + // is never inferred and it is up to the user to ensure the value is + // correct. See http://cldr.unicode.org/ and + // http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html + // for details. Example: "CH" for Switzerland. + string region_code = 2; + + // Optional. BCP-47 language code of the contents of this address (if + // known). This is often the UI language of the input form or is expected + // to match one of the languages used in the address' country/region, or their + // transliterated equivalents. + // This can affect formatting in certain countries, but is not critical + // to the correctness of the data and will never affect any validation or + // other non-formatting related operations. + // + // If this value is not known, it should be omitted (rather than specifying a + // possibly incorrect default). + // + // Examples: "zh-Hant", "ja", "ja-Latn", "en". + string language_code = 3; + + // Optional. Postal code of the address. Not all countries use or require + // postal codes to be present, but where they are used, they may trigger + // additional validation with other parts of the address (e.g. state/zip + // validation in the U.S.A.). + string postal_code = 4; + + // Optional. Additional, country-specific, sorting code. This is not used + // in most regions. Where it is used, the value is either a string like + // "CEDEX", optionally followed by a number (e.g. "CEDEX 7"), or just a number + // alone, representing the "sector code" (Jamaica), "delivery area indicator" + // (Malawi) or "post office indicator" (e.g. Côte d'Ivoire). + string sorting_code = 5; + + // Optional. Highest administrative subdivision which is used for postal + // addresses of a country or region. + // For example, this can be a state, a province, an oblast, or a prefecture. + // Specifically, for Spain this is the province and not the autonomous + // community (e.g. "Barcelona" and not "Catalonia"). + // Many countries don't use an administrative area in postal addresses. E.g. + // in Switzerland this should be left unpopulated. + string administrative_area = 6; + + // Optional. Generally refers to the city/town portion of the address. + // Examples: US city, IT comune, UK post town. + // In regions of the world where localities are not well defined or do not fit + // into this structure well, leave locality empty and use address_lines. + string locality = 7; + + // Optional. Sublocality of the address. + // For example, this can be neighborhoods, boroughs, districts. + string sublocality = 8; + + // Unstructured address lines describing the lower levels of an address. + // + // Because values in address_lines do not have type information and may + // sometimes contain multiple values in a single field (e.g. + // "Austin, TX"), it is important that the line order is clear. The order of + // address lines should be "envelope order" for the country/region of the + // address. In places where this can vary (e.g. Japan), address_language is + // used to make it explicit (e.g. "ja" for large-to-small ordering and + // "ja-Latn" or "en" for small-to-large). This way, the most specific line of + // an address can be selected based on the language. + // + // The minimum permitted structural representation of an address consists + // of a region_code with all remaining information placed in the + // address_lines. It would be possible to format such an address very + // approximately without geocoding, but no semantic reasoning could be + // made about any of the address components until it was at least + // partially resolved. + // + // Creating an address only containing a region_code and address_lines, and + // then geocoding is the recommended way to handle completely unstructured + // addresses (as opposed to guessing which parts of the address should be + // localities or administrative areas). + repeated string address_lines = 9; + + // Optional. The recipient at the address. + // This field may, under certain circumstances, contain multiline information. + // For example, it might contain "care of" information. + repeated string recipients = 10; + + // Optional. The name of the organization at the address. + string organization = 11; +} diff --git a/third_party/google/type/quaternion.proto b/third_party/google/type/quaternion.proto new file mode 100644 index 00000000..18c7b742 --- /dev/null +++ b/third_party/google/type/quaternion.proto @@ -0,0 +1,94 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/quaternion;quaternion"; +option java_multiple_files = true; +option java_outer_classname = "QuaternionProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// A quaternion is defined as the quotient of two directed lines in a +// three-dimensional space or equivalently as the quotient of two Euclidean +// vectors (https://en.wikipedia.org/wiki/Quaternion). +// +// Quaternions are often used in calculations involving three-dimensional +// rotations (https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation), +// as they provide greater mathematical robustness by avoiding the gimbal lock +// problems that can be encountered when using Euler angles +// (https://en.wikipedia.org/wiki/Gimbal_lock). +// +// Quaternions are generally represented in this form: +// +// w + xi + yj + zk +// +// where x, y, z, and w are real numbers, and i, j, and k are three imaginary +// numbers. +// +// Our naming choice `(x, y, z, w)` comes from the desire to avoid confusion for +// those interested in the geometric properties of the quaternion in the 3D +// Cartesian space. Other texts often use alternative names or subscripts, such +// as `(a, b, c, d)`, `(1, i, j, k)`, or `(0, 1, 2, 3)`, which are perhaps +// better suited for mathematical interpretations. +// +// To avoid any confusion, as well as to maintain compatibility with a large +// number of software libraries, the quaternions represented using the protocol +// buffer below *must* follow the Hamilton convention, which defines `ij = k` +// (i.e. a right-handed algebra), and therefore: +// +// i^2 = j^2 = k^2 = ijk = −1 +// ij = −ji = k +// jk = −kj = i +// ki = −ik = j +// +// Please DO NOT use this to represent quaternions that follow the JPL +// convention, or any of the other quaternion flavors out there. +// +// Definitions: +// +// - Quaternion norm (or magnitude): `sqrt(x^2 + y^2 + z^2 + w^2)`. +// - Unit (or normalized) quaternion: a quaternion whose norm is 1. +// - Pure quaternion: a quaternion whose scalar component (`w`) is 0. +// - Rotation quaternion: a unit quaternion used to represent rotation. +// - Orientation quaternion: a unit quaternion used to represent orientation. +// +// A quaternion can be normalized by dividing it by its norm. The resulting +// quaternion maintains the same direction, but has a norm of 1, i.e. it moves +// on the unit sphere. This is generally necessary for rotation and orientation +// quaternions, to avoid rounding errors: +// https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions +// +// Note that `(x, y, z, w)` and `(-x, -y, -z, -w)` represent the same rotation, +// but normalization would be even more useful, e.g. for comparison purposes, if +// it would produce a unique representation. It is thus recommended that `w` be +// kept positive, which can be achieved by changing all the signs when `w` is +// negative. +// +message Quaternion { + // The x component. + double x = 1; + + // The y component. + double y = 2; + + // The z component. + double z = 3; + + // The scalar component. + double w = 4; +} diff --git a/third_party/google/type/timeofday.proto b/third_party/google/type/timeofday.proto new file mode 100644 index 00000000..cd6a8057 --- /dev/null +++ b/third_party/google/type/timeofday.proto @@ -0,0 +1,44 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.type; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/type/timeofday;timeofday"; +option java_multiple_files = true; +option java_outer_classname = "TimeOfDayProto"; +option java_package = "com.google.type"; +option objc_class_prefix = "GTP"; + +// Represents a time of day. The date and time zone are either not significant +// or are specified elsewhere. An API may choose to allow leap seconds. Related +// types are [google.type.Date][google.type.Date] and +// `google.protobuf.Timestamp`. +message TimeOfDay { + // Hours of day in 24 hour format. Should be from 0 to 23. An API may choose + // to allow the value "24:00:00" for scenarios like business closing time. + int32 hours = 1; + + // Minutes of hour of day. Must be from 0 to 59. + int32 minutes = 2; + + // Seconds of minutes of the time. Must normally be from 0 to 59. An API may + // allow the value 60 if it allows leap-seconds. + int32 seconds = 3; + + // Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999. + int32 nanos = 4; +} diff --git a/third_party/policy/v1/policy.proto b/third_party/policy/v1/policy.proto new file mode 100644 index 00000000..7eea0b06 --- /dev/null +++ b/third_party/policy/v1/policy.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +package contrib.api.policy.v1; + +import "google/protobuf/descriptor.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/policy/v1;policyv1"; + +// Extends MethodOptions with a 'policy' field to define security rules. +extend google.protobuf.MethodOptions { + // The extension number 57005 is in the user-defined range. + Policy policy = 57005; // Renamed from 'security_policy' to 'policy' +} + +// SecurityRule defines the security policy applied to a method. +message Policy { + // The 'name' field specifies the name of the security policy to apply. + // Examples: "jwt-auth", "admin-only", "public" + // If empty or not specified, it defaults to requiring authentication. + // If explicitly set to "public", all security checks are skipped. + string name = 1; // Field name is 'name' +} diff --git a/third_party/security/authn/apikey/v1/config.proto b/third_party/security/authn/apikey/v1/config.proto new file mode 100644 index 00000000..49a06eb4 --- /dev/null +++ b/third_party/security/authn/apikey/v1/config.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +package contrib.api.security.authn.apikey.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authn/apikey/v1;apikeyv1"; + +// Config defines the settings for an API Key authenticator. +message Config { + // Defines where to look for the API key in the incoming request. + // The format is ":", e.g., "header:X-API-Key" or "query:api_key". + string key_source = 1 [ + json_name = "key_source", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "Source of the API key in the request, e.g., 'header:X-API-Key'."} + ]; + + // A list of valid API keys and the principal information they map to. + // In a real-world scenario, this might point to a secret management system + // or a database instead of being a static list. + repeated APIKeyDef keys = 2 [ + json_name = "keys", + (gnostic.openapi.v3.property) = {description: "List of valid API keys and their associated principals."} + ]; +} + +// APIKeyDef maps a specific API key to a predefined principal. +message APIKeyDef { + // The secret API key string. + string key = 1 [ + json_name = "key", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "The secret API key string."} + ]; + + // The ID of the principal that this key represents. + string principal_id = 2 [ + json_name = "principal_id", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "The ID of the principal represented by this key."} + ]; + + // The roles associated with this principal. + repeated string roles = 3 [ + json_name = "roles", + (gnostic.openapi.v3.property) = {description: "A list of roles associated with the principal."} + ]; +} diff --git a/third_party/security/authn/apikey/v1/credential.proto b/third_party/security/authn/apikey/v1/credential.proto new file mode 100644 index 00000000..d8ad2c6b --- /dev/null +++ b/third_party/security/authn/apikey/v1/credential.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package contrib.api.security.authn.apikey.v1; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authn/apikey/v1;apikeyv1"; + +// KeyCredential holds the credential for any single-key-based authentication. +message KeyCredential { + string key = 1; +} diff --git a/third_party/security/authn/basic/v1/credential.proto b/third_party/security/authn/basic/v1/credential.proto new file mode 100644 index 00000000..0b53ef15 --- /dev/null +++ b/third_party/security/authn/basic/v1/credential.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package contrib.api.security.authn.basic.v1; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authn/basic/v1;basicv1"; + +// BasicCredential holds the credentials for HTTP Basic authentication. +message BasicCredential { + string username = 1; + string password = 2; +} diff --git a/third_party/security/authn/jwt/v1/claims.proto b/third_party/security/authn/jwt/v1/claims.proto new file mode 100644 index 00000000..cad483d1 --- /dev/null +++ b/third_party/security/authn/jwt/v1/claims.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; + +package contrib.api.security.authn.jwt.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authn/jwt/v1;jwtv1"; + +// Claims defines the standard claims for a JSON Web Token (JWT). +// This message is specifically used within the security module for JWT-related +// configuration and data transfer, ensuring clarity and preventing confusion +// with other potential 'Claims' concepts in the project. +message Claims { + string sub = 1 [ + json_name = "sub", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "The subject of the token."} + ]; // Subject + string iss = 2 [ + json_name = "iss", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "The issuer of the token."} + ]; // Issuer + repeated string aud = 3 [ + json_name = "aud", + (validate.rules).repeated.min_items = 1, + (gnostic.openapi.v3.property) = {description: "The audience for which the token is intended."} + ]; // Audience + int64 exp = 4 [ + json_name = "exp", + (gnostic.openapi.v3.property) = {description: "The expiration time of the token."} + ]; // Expiration Time + int64 nbf = 5 [ + json_name = "nbf", + (gnostic.openapi.v3.property) = {description: "The time before which the token must not be accepted."} + ]; // Not Before + int64 iat = 6 [ + json_name = "iat", + (gnostic.openapi.v3.property) = {description: "The time at which the token was issued."} + ]; // Issued At + string jti = 7 [ + json_name = "jti", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "The unique identifier for the token."} + ]; // JWT ID + map scopes = 8 [ + json_name = "scopes", + (gnostic.openapi.v3.property) = {description: "The scopes associated with the token."} + ]; // Scopes +} diff --git a/third_party/security/authn/jwt/v1/config.proto b/third_party/security/authn/jwt/v1/config.proto new file mode 100644 index 00000000..90a63c8e --- /dev/null +++ b/third_party/security/authn/jwt/v1/config.proto @@ -0,0 +1,69 @@ +syntax = "proto3"; + +package contrib.api.security.authn.jwt.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authn/jwt/v1;jwtv1"; + +// Config contains configuration parameters for creating and validating a JWT. +message Config { // Renamed message from JwtAuthConfig to Config + string signing_method = 1 [ + json_name = "signing_method", + (validate.rules).string = { + min_len: 1, + max_len: 1024, + pattern: "^[A-Z0-9]+$" + }, + (gnostic.openapi.v3.property) = {description: "The signing method used for the token (e.g., HS256, RS256)."} + ]; + string signing_key = 2 [ + json_name = "signing_key", + (validate.rules).string = { + min_len: 1, + max_len: 1024 + }, + (gnostic.openapi.v3.property) = {description: "The signing key used for signing the token."} + ]; + string secondary_signing_key = 3 [ + json_name = "secondary_signing_key", + (gnostic.openapi.v3.property) = {description: "The secondary signing key used for signing the token."} + ]; + int64 access_token_lifetime = 5 [ + json_name = "access_token_lifetime", + (validate.rules).int64 = { + gte: 1, + lte: 31536000 + }, + (gnostic.openapi.v3.property) = {description: "The lifetime of the access token in seconds. A common value is 7200 (2 hours)."} + ]; + int64 refresh_token_lifetime = 6 [ + json_name = "refresh_token_lifetime", + (validate.rules).int64 = { + gte: 1, + lte: 31536000 + }, + (gnostic.openapi.v3.property) = {description: "The lifetime of the refresh token in seconds."} + ]; + string issuer = 7 [ + json_name = "issuer", + (gnostic.openapi.v3.property) = {description: "The issuer of the token."} + ]; + repeated string audience = 8 [ + json_name = "audience", + (validate.rules).repeated = { + min_items: 1, + max_items: 1024, + unique: true + }, + (gnostic.openapi.v3.property) = {description: "The audience for which the token is intended."} + ]; // Audience + // Optional: Defines how to extract the token from the request. + // Defaults to "header:Authorization" with "Bearer " prefix. + // Example: "cookie:access_token" + optional string token_source = 9 [ + json_name = "token_source", + (gnostic.openapi.v3.property) = {description: "Defines how to extract the token from the request. Defaults to 'header:Authorization'."} + ]; +} diff --git a/third_party/security/authn/jwt/v1/data.proto b/third_party/security/authn/jwt/v1/data.proto new file mode 100644 index 00000000..a590da86 --- /dev/null +++ b/third_party/security/authn/jwt/v1/data.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; + +package contrib.api.security.authn.jwt.v1; + +import "security/authn/jwt/v1/claims.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authn/jwt/v1;jwtv1"; + +// JwtAuthData represents the data associated with a JWT authentication request or response. +message Data { + // string raw = 1 [ + // json_name = "raw", + // (validate.rules).string.min_len = 1, + // (gnostic.openapi.v3.property) = {description: "The raw JWT token string received in the request."} + // ]; + // // Parsed JWT token data. + // contrib.api.security.v1.Token parsed_token = 2 [ // Updated type reference + // json_name = "parsed_token", + // (gnostic.openapi.v3.property) = {description: "The parsed JWT token data."} + // ]; + // Claims extracted from the JWT token. + contrib.api.security.authn.jwt.v1.Claims claims = 3 [ // Updated type reference + json_name = "claims", + (gnostic.openapi.v3.property) = {description: "The claims extracted from the JWT token."} + ]; +} diff --git a/third_party/security/authn/oidc/v1/config.proto b/third_party/security/authn/oidc/v1/config.proto new file mode 100644 index 00000000..79455460 --- /dev/null +++ b/third_party/security/authn/oidc/v1/config.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package contrib.api.security.authn.oidc.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authn/oidc/v1;oidcv1"; + +// Config defines the settings for an OpenID Connect (OIDC) authenticator. +message Config { + // The URL of the OIDC provider (issuer). + // The provider's discovery document (.well-known/openid-configuration) will be fetched from this URL. + string issuer = 1 [ + json_name = "issuer", + (validate.rules).string.uri = true, + (gnostic.openapi.v3.property) = {description: "The URL of the OIDC provider (issuer)."} + ]; + + // The client ID registered with the OIDC provider. + string client_id = 2 [ + json_name = "client_id", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "The client ID registered with the OIDC provider."} + ]; + + // Optional: Defines how to extract the ID token from the request. + // Defaults to "header:Authorization" with "Bearer " prefix. + // Example: "cookie:id_token" + optional string token_source = 3 [ + json_name = "token_source", + (gnostic.openapi.v3.property) = {description: "Defines how to extract the ID token from the request. Defaults to 'header:Authorization'."} + ]; + + // Optional: A list of required claims that must be present in the ID token. + repeated string required_claims = 4 [ + json_name = "required_claims", + (gnostic.openapi.v3.property) = {description: "A list of required claims that must be present in the ID token."} + ]; +} diff --git a/third_party/security/authn/oidc/v1/credential.proto b/third_party/security/authn/oidc/v1/credential.proto new file mode 100644 index 00000000..e2c26606 --- /dev/null +++ b/third_party/security/authn/oidc/v1/credential.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package contrib.api.security.authn.oidc.v1; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authn/oidc/v1;oidcv1"; + +// OidcCredential holds the primary credential for OIDC authentication. +message OidcCredential { + string id_token = 1; +} diff --git a/third_party/security/authn/presharedkey/v1/config.proto b/third_party/security/authn/presharedkey/v1/config.proto new file mode 100644 index 00000000..05e5f8f2 --- /dev/null +++ b/third_party/security/authn/presharedkey/v1/config.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package contrib.api.security.authn.presharedkey.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authn/presharedkey/v1;presharedkeyv1"; + +// Config defines the settings for a Preshared Key authenticator. +message Config { + // Defines where to look for the key in the incoming request. + // The format is ":", e.g., "header:X-Service-Key". + string key_source = 1 [ + json_name = "key_source", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "Source of the preshared key in the request, e.g., 'header:X-Service-Key'."} + ]; + + // A list of valid keys and the principal information they map to. + repeated KeyDef keys = 2 [ + json_name = "keys", + (gnostic.openapi.v3.property) = {description: "List of valid preshared keys and their associated principals."} + ]; +} + +// KeyDef maps a specific preshared key to a predefined principal. +message KeyDef { + // The secret preshared key string. + string key = 1 [ + json_name = "key", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "The secret preshared key string."} + ]; + + // The ID of the principal that this key represents (e.g., a service name). + string principal_id = 2 [ + json_name = "principal_id", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "The ID of the principal (e.g., service name) represented by this key."} + ]; + + // The roles associated with this principal. + repeated string roles = 3 [ + json_name = "roles", + (gnostic.openapi.v3.property) = {description: "A list of roles associated with the principal."} + ]; +} diff --git a/third_party/security/authn/v1/authn.proto b/third_party/security/authn/v1/authn.proto new file mode 100644 index 00000000..6587bc9e --- /dev/null +++ b/third_party/security/authn/v1/authn.proto @@ -0,0 +1,69 @@ +syntax = "proto3"; + +package contrib.api.security.authn.v1; + +import "security/authn/apikey/v1/config.proto"; +import "security/authn/jwt/v1/config.proto"; +import "security/authn/oidc/v1/config.proto"; +import "security/authn/presharedkey/v1/config.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authn/v1;authnv1"; + +// Authenticator defines the configuration for a single authentication mechanism. +message Authenticator { + // A unique name for this authenticator instance. This name is used in + // security policies to reference which authenticator to apply. + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "A unique name for this authenticator instance."} + ]; + + // The type of the authenticator. This string MUST match one of the keys + // of the configuration fields below (e.g., "jwt", "apikey") or a registered + // custom authenticator type. It acts as a discriminator. + string type = 2 [ + json_name = "type", + (gnostic.openapi.v3.property) = {description: "The type of the authenticator, e.g., 'jwt', 'apikey', 'presharedkey', 'oidc'."} + ]; + + // --- Built-in Authenticator Configurations --- + + // Configuration for a JWT-based authenticator. + // Must be present if 'type' is "jwt". + optional contrib.api.security.authn.jwt.v1.Config jwt = 10 [ + json_name = "jwt", + (gnostic.openapi.v3.property) = {description: "Configuration for a JWT-based authenticator."} + ]; + + // Configuration for an API Key-based authenticator. + // Must be present if 'type' is "apikey". + optional contrib.api.security.authn.apikey.v1.Config apikey = 11 [ + json_name = "apikey", + (gnostic.openapi.v3.property) = {description: "Configuration for an API Key-based authenticator."} + ]; + + // Configuration for a Preshared Key-based authenticator. + // Must be present if 'type' is "presharedkey". + optional contrib.api.security.authn.presharedkey.v1.Config presharedkey = 12 [ + json_name = "presharedkey", + (gnostic.openapi.v3.property) = {description: "Configuration for a Preshared Key-based authenticator."} + ]; + + // Configuration for an OpenID Connect (OIDC) authenticator. + // Must be present if 'type' is "oidc". + optional contrib.api.security.authn.oidc.v1.Config oidc = 13 [ + json_name = "oidc", + (gnostic.openapi.v3.property) = {description: "Configuration for an OpenID Connect (OIDC) authenticator."} + ]; + + // --- Custom Authenticator Configuration --- + + // For custom types, the 'type' field will contain the custom name, + // and this 'customize' field will hold its configuration. + optional google.protobuf.Struct customize = 100 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Configuration for a custom authenticator."} + ]; +} diff --git a/third_party/security/authz/casbin/v1/config.proto b/third_party/security/authz/casbin/v1/config.proto new file mode 100644 index 00000000..58f9e03f --- /dev/null +++ b/third_party/security/authz/casbin/v1/config.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; + +package contrib.api.security.authz.casbin.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authz/casbin/v1;casbinv1"; + +// Config defines the settings for a Casbin authorizer. +message Config { + // The path to the Casbin model configuration file (e.g., rbac_model.conf). + string model_path = 1 [ + json_name = "model_path", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "Path to the Casbin model configuration file."} + ]; + + // The path to the Casbin policy file (e.g., rbac_policy.csv). + string policy_path = 2 [ + json_name = "policy_path", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "Path to the Casbin policy file."} + ]; + + // Optional: The content of the Casbin model configuration file embedded directly. + string model = 5 [ + json_name = "model", + (gnostic.openapi.v3.property) = {description: "Content of the Casbin model configuration file embedded directly."} + ]; + + + // Optional: Policy rules can also be embedded directly in the configuration. + repeated PolicyRule embedded_policies = 3 [ + json_name = "embedded_policies", + (gnostic.openapi.v3.property) = {description: "Embedded Casbin policy rules."} + ]; + + // Wildcard item used for domain matching. Defaults to "*". + string wildcard_item = 4 [ + json_name = "wildcard_item", + (gnostic.openapi.v3.property) = {description: "Wildcard item used for domain matching. Defaults to '*'"} + ]; +} + +// PolicyRule defines a single Casbin policy rule in a format that Casbin understands. +message PolicyRule { + // The type of the policy rule, e.g., "p" for policy or "g" for grouping/role. + string p_type = 1 [ + json_name = "p_type", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "The type of the policy rule (e.g., 'p' or 'g')."} + ]; + + // The content of the rule as a list of strings. + // e.g., for a "p" rule: ["alice", "data1", "read"] + // e.g., for a "g" rule: ["bob", "admin"] + repeated string rule = 2 [ + json_name = "rule", + (validate.rules).repeated.min_items = 1, + (gnostic.openapi.v3.property) = {description: "The content of the rule as a list of strings."} + ]; +} diff --git a/third_party/security/authz/v1/authz.proto b/third_party/security/authz/v1/authz.proto new file mode 100644 index 00000000..0955cb94 --- /dev/null +++ b/third_party/security/authz/v1/authz.proto @@ -0,0 +1,67 @@ +syntax = "proto3"; + +package contrib.api.security.authz.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; +import "security/authz/casbin/v1/config.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/authz/v1;authzv1"; + +// RuleSpec is the data transfer object for an authorization rule specification. +// It encapsulates the core components of a rule to be checked against the policy engine. +message RuleSpec { + // The domain or tenant for this rule check. Can be empty for non-multi-tenant models. + // e.g., "project-a", "tenant-blue-ocean" + string domain = 1; + + // The resource being accessed. + // e.g., "/api/v1/documents/123", "urn:document:456" + string resource = 2; + + // The action being performed on the resource. + // e.g., "read", "write", "edit", "POST" + string action = 3; + + // Attributes contains additional, dynamic properties related to this rule check, + // enabling Attribute-Based Access Control (ABAC). + // This can include properties of the resource (e.g., {"owner": "user-xyz", "status": "draft"}) + // or the context (e.g., {"ip_address": "192.168.1.100"}). + google.protobuf.Struct attributes = 4; +} + +// Authorizer defines the configuration for a single authorization mechanism. +message Authorizer { + // Unique name for this authorization configuration instance. + string name = 1 [ + json_name = "name", + (gnostic.openapi.v3.property) = {description: "Unique name for this authorizer instance."} + ]; + + // The type of authorization mechanism. + // This string MUST match one of the keys of the configuration fields below + // (e.g., "casbin") or a registered custom authorization mechanism. + // It acts as a discriminator. + string type = 2 [ + json_name = "type", + (gnostic.openapi.v3.property) = {description: "The type of authorization mechanism, e.g., 'casbin', 'opa'."} + ]; + + // --- Built-in Authorizer Configurations --- + + // Configuration for a Casbin authorizer. + // Must be present if 'type' is "casbin". + optional contrib.api.security.authz.casbin.v1.Config casbin = 10 [ + json_name = "casbin", + (gnostic.openapi.v3.property) = {description: "Configuration for a Casbin authorizer."} + ]; + + // --- Custom Authorizer Configuration --- + + // For custom types, the 'type' field will contain the custom name, + // and this 'customize' field will hold its configuration. + optional google.protobuf.Struct customize = 100 [ + json_name = "customize", + (gnostic.openapi.v3.property) = {description: "Configuration for a custom authorizer."} + ]; +} diff --git a/third_party/security/v1/credential.proto b/third_party/security/v1/credential.proto new file mode 100644 index 00000000..89ac1d73 --- /dev/null +++ b/third_party/security/v1/credential.proto @@ -0,0 +1,164 @@ +syntax = "proto3"; + +package contrib.api.security.v1; + +import "security/authn/apikey/v1/credential.proto"; +import "security/authn/basic/v1/credential.proto"; +import "security/authn/oidc/v1/credential.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/any.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/v1;securityv1"; + +// Payload is a union of structured credential types, primarily for use in +// CredentialResponse. +message Payload { + // Basic authentication credential. + optional contrib.api.security.authn.basic.v1.BasicCredential basic = 10 [ + json_name = "basic", + (gnostic.openapi.v3.property) = {description: "Basic authentication credential."} + ]; + + // API Key or Preshared Key credential. + optional contrib.api.security.authn.apikey.v1.KeyCredential key = 11 [ + json_name = "key", + (gnostic.openapi.v3.property) = {description: "API Key or Preshared Key credential."} + ]; + + // OIDC credential. + optional contrib.api.security.authn.oidc.v1.OidcCredential oidc = 12 [ + json_name = "oidc", + (gnostic.openapi.v3.property) = {description: "OIDC credential."} + ]; + + // Token-based credential (JWT, OAuth2). + // IMPORTANT: This structure is designed for OUTPUT (e.g., in CredentialResponse) + // after a token has been successfully issued. + optional TokenCredential token = 13 [ + json_name = "token", + (gnostic.openapi.v3.property) = {description: "Token-based credential (JWT, OAuth2), primarily for responses."} + ]; + + // Raw serialized data for unsupported credential types. + optional string raw_data = 14 [ + json_name = "rawData", + (gnostic.openapi.v3.property) = {description: "Raw serialized data for unsupported credential types."} + ]; +} + +// MetaValue is a wrapper for multi-value metadata entries, designed to +// losslessly and type-safely represent transport-layer metadata like HTTP headers. +message MetaValue { + repeated string values = 1; +} + +// CredentialSource is a generic container for transmitting credential data. +// It follows a "dumb pipe" philosophy, where it acts as a simple, unopinionated +// container for the raw credential data extracted from a request. The responsibility +// of parsing and interpreting the data lies solely with the consumer (the Authenticator). +message CredentialSource { + // Type indicates the kind of credential, e.g., "bearer", "basic", "apikey". + // This serves as a hint to the Authenticator on how to interpret the data. + string type = 1 [ + json_name = "type", + (gnostic.openapi.v3.property) = {description: "A hint indicating the credential type (e.g., 'bearer', 'basic')."} + ]; + + // Raw contains the original, unmodified credential string extracted from the request + // (e.g., the full content of the `Authorization` header). + // This field MUST be treated as the authoritative source of truth by any Authenticator. + string raw = 2 [ + json_name = "raw", + (gnostic.openapi.v3.property) = {description: "The original, unmodified credential string. This is the authoritative source of truth."} + ]; + + // Payload serves as an OPTIONAL, pre-parsed cache for the `raw` field to improve + // ease of use for consumers. + // + // Filling Rules: + // - CredentialExtractor SHOULD identify common credential patterns (e.g., "Bearer ") + // and pack a corresponding well-known type (e.g., `BearerCredential`) into this field. + // + // Usage Rules: + // - Authenticator SHOULD first attempt to unpack a known type from this field. + // If successful, it can use the structured data directly, avoiding reparsing. + // If it fails or the field is empty, it MUST fall back to parsing the `raw` field. + google.protobuf.Any payload = 3 [ + json_name = "payload", + (gnostic.openapi.v3.property) = {description: "Optional pre-parsed cache of the credential, for ease of use. Consumers must fallback to `raw`."} + ]; + + // Metadata contains additional, non-credential data extracted from the request + // (e.g., from headers) that may be relevant for authentication/authorization decisions. + // The CredentialExtractor MUST support configurable mapping from request metadata + // (e.g., HTTP headers which are map[string][]string) to this field. + map metadata = 4 [ + json_name = "metadata", + (gnostic.openapi.v3.property) = {description: "Configurable auxiliary data from the request context, perfectly representing multi-value headers."} + ]; +} + +// CredentialResponse represents a credential structure intended for +// transmission to clients (e.g., frontend applications) after a successful +// authentication or token issuance event. +message CredentialResponse { + // Type indicates the kind of credential being returned, e.g., "jwt", "apikey". + string type = 1 [ + json_name = "type", + (gnostic.openapi.v3.property) = {description: "Type of the credential being returned (e.g., 'jwt', 'apikey')."} + ]; + + // Payload contains the structured data of the issued credential. + Payload payload = 2 [ + json_name = "payload", + (gnostic.openapi.v3.property) = {description: "The structured data of the issued credential."} + ]; + + // Optional metadata to be sent to the client. + map metadata = 4 [ + json_name = "metadata", + (gnostic.openapi.v3.property) = {description: "Optional metadata to be sent to the client."} + ]; +} + +// BearerCredential represents the structured payload for a "Bearer" scheme credential. +// It is a well-known type intended to be packed into the `google.protobuf.Any` +// `payload` field of a `CredentialSource` message. +message BearerCredential { + // The token string, without the "Bearer " prefix. + string token = 1 [(gnostic.openapi.v3.property) = {description: "The token string, without the 'Bearer ' prefix."}]; +} + +// TokenCredential holds the credentials for token-based authentication flows +// like OAuth2 and JWT. +// +// IMPORTANT: This message represents the full set of tokens typically returned +// from a token issuance endpoint (e.g., /login). It is designed for use in +// CredentialResponse. +message TokenCredential { + // The access token used for authentication. + string access_token = 1 [ + json_name = "accessToken", + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "The access token used for authentication."} + ]; + + // The refresh token used to obtain a new access token. + string refresh_token = 2 [ + json_name = "refreshToken", + (gnostic.openapi.v3.property) = {description: "The refresh token used to obtain a new access token."} + ]; + + // The remaining lifetime of the access token in seconds. + int64 expires_in = 3 [ + json_name = "expiresIn", + (gnostic.openapi.v3.property) = {description: "The remaining lifetime of the access token in seconds."} + ]; + + // The type of the token, typically "Bearer". + string token_type = 4 [ + json_name = "tokenType", + (gnostic.openapi.v3.property) = {description: "The type of the token, typically 'Bearer'."} + ]; +} diff --git a/third_party/security/v1/error.proto b/third_party/security/v1/error.proto new file mode 100644 index 00000000..c92617b9 --- /dev/null +++ b/third_party/security/v1/error.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; + +package contrib.api.security.v1; + +import "errors/errors.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/v1;securityv1"; + +// SecurityErrorReason defines the application's specific security error codes. +// These codes supplement the common error codes and provide more specific details +// for authentication and authorization failures. The naming convention follows SUBJECT_MODIFIER format. +enum SecurityErrorReason { + option (errors.default_code) = 500; + + // The default, unspecified reason. This is required by proto3 syntax. + SECURITY_ERROR_REASON_UNSPECIFIED = 0 [(errors.code) = 500]; + + // --- Specific Authentication Errors (mapped to common.UNAUTHENTICATED) --- + + // The provided credentials (e.g., username/password) are invalid. + CREDENTIALS_INVALID = 1002 [(errors.code) = 401]; + // The authentication token has expired. + TOKEN_EXPIRED = 1003 [(errors.code) = 401]; + // The authentication token is malformed or invalid. + TOKEN_INVALID = 1004 [(errors.code) = 401]; + // The authentication token is missing from the request. + TOKEN_MISSING = 1005 [(errors.code) = 401]; + // The claims within the token are invalid. + CLAIMS_INVALID = 1006 [(errors.code) = 401]; + // The bearer token is specifically invalid or malformed. + BEARER_TOKEN_INVALID = 1007 [(errors.code) = 401]; + // The signing method used in the token is not supported. + SIGNING_METHOD_UNSUPPORTED = 1008 [(errors.code) = 401]; + // Failed to sign a new token. + TOKEN_SIGN_FAILED = 1009 [(errors.code) = 500]; + + // --- Specific Authorization Errors (mapped to common.FORBIDDEN) --- + + // The user is authenticated but does not have permission for the specific resource or action. + PERMISSION_DENIED = 2000 [(errors.code) = 403]; +} diff --git a/third_party/security/v1/principal.proto b/third_party/security/v1/principal.proto new file mode 100644 index 00000000..6e14de29 --- /dev/null +++ b/third_party/security/v1/principal.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; + +package contrib.api.security.v1; + +import "gnostic/openapi/v3/annotations.proto"; +import "google/protobuf/struct.proto"; +import "validate/validate.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/v1;securityv1"; + +// Principal represents the authenticated identity of a user or service. +// It serves as a standardized data transfer object for security context, +// carrying identity, roles, and various claims across service boundaries. +message Principal { + // The unique identifier for the principal (e.g., user ID, service account name). + string id = 1 [ + (validate.rules).string.min_len = 1, + (gnostic.openapi.v3.property) = {description: "Unique identifier for the principal."} + ]; + + // The domain associated with the principal. + // This is often used in multi-tenant or multi-project environments. + string domain = 2 [(gnostic.openapi.v3.property) = {description: "The domain associated with the principal."}]; + + // A list of roles assigned to the principal. + repeated string roles = 3 [(gnostic.openapi.v3.property) = {description: "List of roles assigned to the principal."}]; + + // A list of permissions assigned to the principal. + repeated string permissions = 4 [(gnostic.openapi.v3.property) = {description: "List of permissions assigned to the principal."}]; + + // A map of scopes assigned to the principal. + map scopes = 5 [(gnostic.openapi.v3.property) = {description: "Map of scopes assigned to the principal."}]; + + // A map of standardized, type-safe claims associated with the principal. + // Using google.protobuf.Value allows for flexible, JSON-like claims, + // with robust Go helper functions in the structpb package. + map claims = 6 [(gnostic.openapi.v3.property) = {description: "Standardized, flexible claims associated with the principal."}]; +} diff --git a/third_party/security/v1/security.proto b/third_party/security/v1/security.proto new file mode 100644 index 00000000..55b98da1 --- /dev/null +++ b/third_party/security/v1/security.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; + +package contrib.api.security.v1; + +import "config/transport/tls/v1/tls.proto"; +import "gnostic/openapi/v3/annotations.proto"; +import "security/authn/v1/authn.proto"; +import "security/authz/v1/authz.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/security/v1;securityv1"; + +// Security defines the top-level configuration for all security-related components. +message Security { + // List of authentication configurations. + AuthenticatorConfigs authn = 1 [ + json_name = "authn", + (gnostic.openapi.v3.property) = {description: "List of authentication configurations."} + ]; + // List of authorization configurations. + AuthorizerConfigs authz = 2 [ + json_name = "authz", + (gnostic.openapi.v3.property) = {description: "List of authorization configurations."} + ]; + // List of transport layer security (TLS) configurations. + TransportSecurityConfigs transport_security = 3 [ + json_name = "transport_security", + (gnostic.openapi.v3.property) = {description: "List of transport layer security (TLS) configurations."} + ]; +} + +message AuthenticatorConfigs { + optional string default = 1 [json_name = "default"]; + optional string active = 2 [json_name = "active"]; + repeated contrib.api.security.authn.v1.Authenticator configs = 3 [json_name = "configs"]; // Changed type to AuthNConfig +} + +message AuthorizerConfigs { + optional string default = 1 [json_name = "default"]; + optional string active = 2 [json_name = "active"]; + repeated contrib.api.security.authz.v1.Authorizer configs = 3 [json_name = "configs"]; +} + +message TransportSecurityConfigs { + optional string default = 1 [json_name = "default"]; + optional string active = 2 [json_name = "active"]; + repeated runtime.api.config.transport.tls.v1.TLSConfig configs = 3 [json_name = "configs"]; +} diff --git a/third_party/service/security/authz/v1/service.proto b/third_party/service/security/authz/v1/service.proto new file mode 100644 index 00000000..c73fb6b4 --- /dev/null +++ b/third_party/service/security/authz/v1/service.proto @@ -0,0 +1,123 @@ +syntax = "proto3"; + +package contrib.api.service.security.authz.v1; + +import "google/api/annotations.proto"; +import "security/authz/v1/authz.proto"; +import "security/v1/principal.proto"; + +option go_package = "github.com/origadmin/contrib/api/gen/go/service/security/authz/v1;authzv1"; + +// AuthorizerService provides endpoints for performing authorization checks. +service AuthorizerService { + // Authorized performs a single authorization check. + rpc Authorized(AuthorizedRequest) returns (AuthorizedResponse) { + option (google.api.http) = { + post: "/v1/authz/authorized" + body: "*" + }; + } + + // FilterAuthorized performs a batch authorization check on a list of rule specs. + rpc FilterAuthorized(FilterAuthorizedRequest) returns (FilterAuthorizedResponse) { + option (google.api.http) = { + post: "/v1/authz/filter" + body: "*" + }; + } + + // FilterAuthorizedResources filters a list of resources against a rule template. + rpc FilterAuthorizedResources(FilterAuthorizedResourcesRequest) returns (FilterAuthorizedResourcesResponse) { + option (google.api.http) = { + post: "/v1/authz/filter/resources" + body: "*" + }; + } + + // FilterAuthorizedActions filters a list of actions against a rule template. + rpc FilterAuthorizedActions(FilterAuthorizedActionsRequest) returns (FilterAuthorizedActionsResponse) { + option (google.api.http) = { + post: "/v1/authz/filter/actions" + body: "*" + }; + } + + // FilterAuthorizedDomains filters a list of domains against a rule template. + rpc FilterAuthorizedDomains(FilterAuthorizedDomainsRequest) returns (FilterAuthorizedDomainsResponse) { + option (google.api.http) = { + post: "/v1/authz/filter/domains" + body: "*" + }; + } +} + +// --- Messages for Authorized --- +message AuthorizedRequest { + // The principal performing the action. + contrib.api.security.v1.Principal principal = 1; + // The rule specification to be checked. + contrib.api.security.authz.v1.RuleSpec spec = 2; +} + +message AuthorizedResponse { + // True if the principal is authorized, false otherwise. + bool allowed = 1; +} + +// --- Messages for FilterAuthorized --- +message FilterAuthorizedRequest { + // The principal performing the action. + contrib.api.security.v1.Principal principal = 1; + // A list of rule specifications to be checked. + repeated contrib.api.security.authz.v1.RuleSpec specs = 2; +} + +message FilterAuthorizedResponse { + // A list containing only the rule specifications that the principal is authorized for. + repeated contrib.api.security.authz.v1.RuleSpec specs = 1; +} + +// --- Messages for FilterAuthorizedResources --- +message FilterAuthorizedResourcesRequest { + // The principal performing the action. + contrib.api.security.v1.Principal principal = 1; + // A template for the authorization check. The 'resource' field will be ignored. + contrib.api.security.authz.v1.RuleSpec spec_template = 2; + // The list of resources to check. + repeated string resources = 3; +} + +message FilterAuthorizedResourcesResponse { + // A list containing only the resources that the principal is authorized to access. + repeated string resources = 1; +} + +// --- Messages for FilterAuthorizedActions --- +message FilterAuthorizedActionsRequest { + // The principal performing the action. + contrib.api.security.v1.Principal principal = 1; + // A template for the authorization check. The 'action' field will be ignored. + contrib.api.security.authz.v1.RuleSpec spec_template = 2; + // The list of actions to check. + repeated string actions = 3; +} + +message FilterAuthorizedActionsResponse { + // A list containing only the actions that the principal is authorized to perform. + repeated string actions = 1; +} + +// --- Messages for FilterAuthorizedDomains --- +message FilterAuthorizedDomainsRequest { + // The principal performing the action. + contrib.api.security.v1.Principal principal = 1; + // A template for the authorization check. The 'domain' field will be ignored. + contrib.api.security.authz.v1.RuleSpec spec_template = 2; + // The list of domains to check. + repeated string domains = 3; +} + +message FilterAuthorizedDomainsResponse { + // A list containing only the domains that the principal is authorized to access. + repeated string domains = 1; +} diff --git a/third_party/validate/validate.proto b/third_party/validate/validate.proto new file mode 100644 index 00000000..5aa96539 --- /dev/null +++ b/third_party/validate/validate.proto @@ -0,0 +1,862 @@ +syntax = "proto2"; +package validate; + +option go_package = "github.com/envoyproxy/protoc-gen-validate/validate"; +option java_package = "io.envoyproxy.pgv.validate"; + +import "google/protobuf/descriptor.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +// Validation rules applied at the message level +extend google.protobuf.MessageOptions { + // Disabled nullifies any validation rules for this message, including any + // message fields associated with it that do support validation. + optional bool disabled = 1071; + // Ignore skips generation of validation methods for this message. + optional bool ignored = 1072; +} + +// Validation rules applied at the oneof level +extend google.protobuf.OneofOptions { + // Required ensures that exactly one the field options in a oneof is set; + // validation fails if no fields in the oneof are set. + optional bool required = 1071; +} + +// Validation rules applied at the field level +extend google.protobuf.FieldOptions { + // Rules specify the validations to be performed on this field. By default, + // no validation is performed against a field. + optional FieldRules rules = 1071; +} + +// FieldRules encapsulates the rules for each type of field. Depending on the +// field, the correct set should be used to ensure proper validations. +message FieldRules { + optional MessageRules message = 17; + oneof type { + // Scalar Field Types + FloatRules float = 1; + DoubleRules double = 2; + Int32Rules int32 = 3; + Int64Rules int64 = 4; + UInt32Rules uint32 = 5; + UInt64Rules uint64 = 6; + SInt32Rules sint32 = 7; + SInt64Rules sint64 = 8; + Fixed32Rules fixed32 = 9; + Fixed64Rules fixed64 = 10; + SFixed32Rules sfixed32 = 11; + SFixed64Rules sfixed64 = 12; + BoolRules bool = 13; + StringRules string = 14; + BytesRules bytes = 15; + + // Complex Field Types + EnumRules enum = 16; + RepeatedRules repeated = 18; + MapRules map = 19; + + // Well-Known Field Types + AnyRules any = 20; + DurationRules duration = 21; + TimestampRules timestamp = 22; + } +} + +// FloatRules describes the constraints applied to `float` values +message FloatRules { + // Const specifies that this field must be exactly the specified value + optional float const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional float lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional float lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional float gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional float gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated float in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated float not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// DoubleRules describes the constraints applied to `double` values +message DoubleRules { + // Const specifies that this field must be exactly the specified value + optional double const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional double lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional double lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional double gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional double gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated double in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated double not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// Int32Rules describes the constraints applied to `int32` values +message Int32Rules { + // Const specifies that this field must be exactly the specified value + optional int32 const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional int32 lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional int32 lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional int32 gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional int32 gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated int32 in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated int32 not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// Int64Rules describes the constraints applied to `int64` values +message Int64Rules { + // Const specifies that this field must be exactly the specified value + optional int64 const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional int64 lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional int64 lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional int64 gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional int64 gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated int64 in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated int64 not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// UInt32Rules describes the constraints applied to `uint32` values +message UInt32Rules { + // Const specifies that this field must be exactly the specified value + optional uint32 const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional uint32 lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional uint32 lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional uint32 gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional uint32 gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated uint32 in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated uint32 not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// UInt64Rules describes the constraints applied to `uint64` values +message UInt64Rules { + // Const specifies that this field must be exactly the specified value + optional uint64 const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional uint64 lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional uint64 lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional uint64 gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional uint64 gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated uint64 in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated uint64 not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// SInt32Rules describes the constraints applied to `sint32` values +message SInt32Rules { + // Const specifies that this field must be exactly the specified value + optional sint32 const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional sint32 lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional sint32 lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional sint32 gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional sint32 gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated sint32 in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated sint32 not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// SInt64Rules describes the constraints applied to `sint64` values +message SInt64Rules { + // Const specifies that this field must be exactly the specified value + optional sint64 const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional sint64 lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional sint64 lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional sint64 gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional sint64 gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated sint64 in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated sint64 not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// Fixed32Rules describes the constraints applied to `fixed32` values +message Fixed32Rules { + // Const specifies that this field must be exactly the specified value + optional fixed32 const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional fixed32 lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional fixed32 lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional fixed32 gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional fixed32 gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated fixed32 in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated fixed32 not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// Fixed64Rules describes the constraints applied to `fixed64` values +message Fixed64Rules { + // Const specifies that this field must be exactly the specified value + optional fixed64 const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional fixed64 lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional fixed64 lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional fixed64 gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional fixed64 gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated fixed64 in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated fixed64 not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// SFixed32Rules describes the constraints applied to `sfixed32` values +message SFixed32Rules { + // Const specifies that this field must be exactly the specified value + optional sfixed32 const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional sfixed32 lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional sfixed32 lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional sfixed32 gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional sfixed32 gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated sfixed32 in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated sfixed32 not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// SFixed64Rules describes the constraints applied to `sfixed64` values +message SFixed64Rules { + // Const specifies that this field must be exactly the specified value + optional sfixed64 const = 1; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional sfixed64 lt = 2; + + // Lte specifies that this field must be less than or equal to the + // specified value, inclusive + optional sfixed64 lte = 3; + + // Gt specifies that this field must be greater than the specified value, + // exclusive. If the value of Gt is larger than a specified Lt or Lte, the + // range is reversed. + optional sfixed64 gt = 4; + + // Gte specifies that this field must be greater than or equal to the + // specified value, inclusive. If the value of Gte is larger than a + // specified Lt or Lte, the range is reversed. + optional sfixed64 gte = 5; + + // In specifies that this field must be equal to one of the specified + // values + repeated sfixed64 in = 6; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated sfixed64 not_in = 7; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 8; +} + +// BoolRules describes the constraints applied to `bool` values +message BoolRules { + // Const specifies that this field must be exactly the specified value + optional bool const = 1; +} + +// StringRules describe the constraints applied to `string` values +message StringRules { + // Const specifies that this field must be exactly the specified value + optional string const = 1; + + // Len specifies that this field must be the specified number of + // characters (Unicode code points). Note that the number of + // characters may differ from the number of bytes in the string. + optional uint64 len = 19; + + // MinLen specifies that this field must be the specified number of + // characters (Unicode code points) at a minimum. Note that the number of + // characters may differ from the number of bytes in the string. + optional uint64 min_len = 2; + + // MaxLen specifies that this field must be the specified number of + // characters (Unicode code points) at a maximum. Note that the number of + // characters may differ from the number of bytes in the string. + optional uint64 max_len = 3; + + // LenBytes specifies that this field must be the specified number of bytes + optional uint64 len_bytes = 20; + + // MinBytes specifies that this field must be the specified number of bytes + // at a minimum + optional uint64 min_bytes = 4; + + // MaxBytes specifies that this field must be the specified number of bytes + // at a maximum + optional uint64 max_bytes = 5; + + // Pattern specifies that this field must match against the specified + // regular expression (RE2 syntax). The included expression should elide + // any delimiters. + optional string pattern = 6; + + // Prefix specifies that this field must have the specified substring at + // the beginning of the string. + optional string prefix = 7; + + // Suffix specifies that this field must have the specified substring at + // the end of the string. + optional string suffix = 8; + + // Contains specifies that this field must have the specified substring + // anywhere in the string. + optional string contains = 9; + + // NotContains specifies that this field cannot have the specified substring + // anywhere in the string. + optional string not_contains = 23; + + // In specifies that this field must be equal to one of the specified + // values + repeated string in = 10; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated string not_in = 11; + + // WellKnown rules provide advanced constraints against common string + // patterns + oneof well_known { + // Email specifies that the field must be a valid email address as + // defined by RFC 5322 + bool email = 12; + + // Hostname specifies that the field must be a valid hostname as + // defined by RFC 1034. This constraint does not support + // internationalized domain names (IDNs). + bool hostname = 13; + + // Ip specifies that the field must be a valid IP (v4 or v6) address. + // Valid IPv6 addresses should not include surrounding square brackets. + bool ip = 14; + + // Ipv4 specifies that the field must be a valid IPv4 address. + bool ipv4 = 15; + + // Ipv6 specifies that the field must be a valid IPv6 address. Valid + // IPv6 addresses should not include surrounding square brackets. + bool ipv6 = 16; + + // Uri specifies that the field must be a valid, absolute URI as defined + // by RFC 3986 + bool uri = 17; + + // UriRef specifies that the field must be a valid URI as defined by RFC + // 3986 and may be relative or absolute. + bool uri_ref = 18; + + // Address specifies that the field must be either a valid hostname as + // defined by RFC 1034 (which does not support internationalized domain + // names or IDNs), or it can be a valid IP (v4 or v6). + bool address = 21; + + // Uuid specifies that the field must be a valid UUID as defined by + // RFC 4122 + bool uuid = 22; + + // WellKnownRegex specifies a common well known pattern defined as a regex. + KnownRegex well_known_regex = 24; + } + + // This applies to regexes HTTP_HEADER_NAME and HTTP_HEADER_VALUE to enable + // strict header validation. + // By default, this is true, and HTTP header validations are RFC-compliant. + // Setting to false will enable a looser validations that only disallows + // \r\n\0 characters, which can be used to bypass header matching rules. + optional bool strict = 25 [default = true]; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 26; +} + +// WellKnownRegex contain some well-known patterns. +enum KnownRegex { + UNKNOWN = 0; + + // HTTP header name as defined by RFC 7230. + HTTP_HEADER_NAME = 1; + + // HTTP header value as defined by RFC 7230. + HTTP_HEADER_VALUE = 2; +} + +// BytesRules describe the constraints applied to `bytes` values +message BytesRules { + // Const specifies that this field must be exactly the specified value + optional bytes const = 1; + + // Len specifies that this field must be the specified number of bytes + optional uint64 len = 13; + + // MinLen specifies that this field must be the specified number of bytes + // at a minimum + optional uint64 min_len = 2; + + // MaxLen specifies that this field must be the specified number of bytes + // at a maximum + optional uint64 max_len = 3; + + // Pattern specifies that this field must match against the specified + // regular expression (RE2 syntax). The included expression should elide + // any delimiters. + optional string pattern = 4; + + // Prefix specifies that this field must have the specified bytes at the + // beginning of the string. + optional bytes prefix = 5; + + // Suffix specifies that this field must have the specified bytes at the + // end of the string. + optional bytes suffix = 6; + + // Contains specifies that this field must have the specified bytes + // anywhere in the string. + optional bytes contains = 7; + + // In specifies that this field must be equal to one of the specified + // values + repeated bytes in = 8; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated bytes not_in = 9; + + // WellKnown rules provide advanced constraints against common byte + // patterns + oneof well_known { + // Ip specifies that the field must be a valid IP (v4 or v6) address in + // byte format + bool ip = 10; + + // Ipv4 specifies that the field must be a valid IPv4 address in byte + // format + bool ipv4 = 11; + + // Ipv6 specifies that the field must be a valid IPv6 address in byte + // format + bool ipv6 = 12; + } + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 14; +} + +// EnumRules describe the constraints applied to enum values +message EnumRules { + // Const specifies that this field must be exactly the specified value + optional int32 const = 1; + + // DefinedOnly specifies that this field must be only one of the defined + // values for this enum, failing on any undefined value. + optional bool defined_only = 2; + + // In specifies that this field must be equal to one of the specified + // values + repeated int32 in = 3; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated int32 not_in = 4; +} + +// MessageRules describe the constraints applied to embedded message values. +// For message-type fields, validation is performed recursively. +message MessageRules { + // Skip specifies that the validation rules of this field should not be + // evaluated + optional bool skip = 1; + + // Required specifies that this field must be set + optional bool required = 2; +} + +// RepeatedRules describe the constraints applied to `repeated` values +message RepeatedRules { + // MinItems specifies that this field must have the specified number of + // items at a minimum + optional uint64 min_items = 1; + + // MaxItems specifies that this field must have the specified number of + // items at a maximum + optional uint64 max_items = 2; + + // Unique specifies that all elements in this field must be unique. This + // constraint is only applicable to scalar and enum types (messages are not + // supported). + optional bool unique = 3; + + // Items specifies the constraints to be applied to each item in the field. + // Repeated message fields will still execute validation against each item + // unless skip is specified here. + optional FieldRules items = 4; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 5; +} + +// MapRules describe the constraints applied to `map` values +message MapRules { + // MinPairs specifies that this field must have the specified number of + // KVs at a minimum + optional uint64 min_pairs = 1; + + // MaxPairs specifies that this field must have the specified number of + // KVs at a maximum + optional uint64 max_pairs = 2; + + // NoSparse specifies values in this field cannot be unset. This only + // applies to map's with message value types. + optional bool no_sparse = 3; + + // Keys specifies the constraints to be applied to each key in the field. + optional FieldRules keys = 4; + + // Values specifies the constraints to be applied to the value of each key + // in the field. Message values will still have their validations evaluated + // unless skip is specified here. + optional FieldRules values = 5; + + // IgnoreEmpty specifies that the validation rules of this field should be + // evaluated only if the field is not empty + optional bool ignore_empty = 6; +} + +// AnyRules describe constraints applied exclusively to the +// `google.protobuf.Any` well-known type +message AnyRules { + // Required specifies that this field must be set + optional bool required = 1; + + // In specifies that this field's `type_url` must be equal to one of the + // specified values. + repeated string in = 2; + + // NotIn specifies that this field's `type_url` must not be equal to any of + // the specified values. + repeated string not_in = 3; +} + +// DurationRules describe the constraints applied exclusively to the +// `google.protobuf.Duration` well-known type +message DurationRules { + // Required specifies that this field must be set + optional bool required = 1; + + // Const specifies that this field must be exactly the specified value + optional google.protobuf.Duration const = 2; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional google.protobuf.Duration lt = 3; + + // Lt specifies that this field must be less than the specified value, + // inclusive + optional google.protobuf.Duration lte = 4; + + // Gt specifies that this field must be greater than the specified value, + // exclusive + optional google.protobuf.Duration gt = 5; + + // Gte specifies that this field must be greater than the specified value, + // inclusive + optional google.protobuf.Duration gte = 6; + + // In specifies that this field must be equal to one of the specified + // values + repeated google.protobuf.Duration in = 7; + + // NotIn specifies that this field cannot be equal to one of the specified + // values + repeated google.protobuf.Duration not_in = 8; +} + +// TimestampRules describe the constraints applied exclusively to the +// `google.protobuf.Timestamp` well-known type +message TimestampRules { + // Required specifies that this field must be set + optional bool required = 1; + + // Const specifies that this field must be exactly the specified value + optional google.protobuf.Timestamp const = 2; + + // Lt specifies that this field must be less than the specified value, + // exclusive + optional google.protobuf.Timestamp lt = 3; + + // Lte specifies that this field must be less than the specified value, + // inclusive + optional google.protobuf.Timestamp lte = 4; + + // Gt specifies that this field must be greater than the specified value, + // exclusive + optional google.protobuf.Timestamp gt = 5; + + // Gte specifies that this field must be greater than the specified value, + // inclusive + optional google.protobuf.Timestamp gte = 6; + + // LtNow specifies that this must be less than the current time. LtNow + // can only be used with the Within rule. + optional bool lt_now = 7; + + // GtNow specifies that this must be greater than the current time. GtNow + // can only be used with the Within rule. + optional bool gt_now = 8; + + // Within specifies that this field must be within this duration of the + // current time. This constraint can be used alone or with the LtNow and + // GtNow rules. + optional google.protobuf.Duration within = 9; +} diff --git a/tools.go b/tools.go new file mode 100644 index 00000000..3c04584c --- /dev/null +++ b/tools.go @@ -0,0 +1,16 @@ +//go:build tools + +package tools + +import ( + _ "github.com/bufbuild/buf/cmd/buf" + _ "github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking" + _ "github.com/bufbuild/buf/cmd/protoc-gen-buf-lint" + _ "github.com/envoyproxy/protoc-gen-validate" + _ "github.com/go-kratos/kratos/cmd/kratos/v2" + _ "github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2" + _ "github.com/google/gnostic/cmd/protoc-gen-openapi" + _ "github.com/google/wire/cmd/wire" + _ "google.golang.org/grpc/cmd/protoc-gen-go-grpc" + _ "google.golang.org/protobuf/cmd/protoc-gen-go" +) \ No newline at end of file From 4a574cad42ed3d35ef0f0ae8854b42911bd4983c Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 24 Dec 2025 01:27:25 +0800 Subject: [PATCH 068/158] refactor(system): simplify biz layer by replacing *ServiceBiz with *UseCase pattern and standardize pagination fields --- api/v1/proto/system/permission.proto | 12 +- internal/features/system/biz/biz.go | 16 +- .../features/system/biz/permission.biz.go | 92 - internal/features/system/biz/permission.go | 62 + internal/features/system/biz/provider.go | 12 +- internal/features/system/biz/resource.biz.go | 101 - internal/features/system/biz/resource.go | 62 + internal/features/system/biz/role.biz.go | 104 - internal/features/system/biz/role.go | 62 + internal/features/system/biz/user.biz.go | 179 - internal/features/system/biz/user.go | 102 + internal/features/system/data/data.go | 89 + internal/features/system/data/ent/client.go | 1520 ++++ internal/features/system/data/ent/crud.go | 3 + internal/features/system/data/ent/database.go | 149 + internal/features/system/data/ent/ent.go | 620 ++ .../system/data/ent/enttest/enttest.go | 85 + internal/features/system/data/ent/generate.go | 8 + .../features/system/data/ent/hook/hook.go | 270 + .../system/data/ent/intercept/intercept.go | 330 + .../system/data/ent/migrate/migrate.go | 96 + .../system/data/ent/migrate/schema.go | 313 + internal/features/system/data/ent/mutation.go | 6791 +++++++++++++++++ .../system/data/ent/mutation_fields.go | 605 ++ .../features/system/data/ent/permission.go | 263 + .../system/data/ent/permission/permission.go | 338 + .../system/data/ent/permission/where.go | 563 ++ .../system/data/ent/permission_create.go | 530 ++ .../system/data/ent/permission_delete.go | 88 + .../system/data/ent/permission_query.go | 986 +++ .../system/data/ent/permission_update.go | 1198 +++ .../system/data/ent/permissionresource.go | 160 + .../permissionresource/permissionresource.go | 164 + .../data/ent/permissionresource/where.go | 166 + .../data/ent/permissionresource_create.go | 260 + .../data/ent/permissionresource_delete.go | 88 + .../data/ent/permissionresource_query.go | 763 ++ .../data/ent/permissionresource_update.go | 493 ++ .../system/data/ent/predicate/predicate.go | 28 + internal/features/system/data/ent/resource.go | 355 + .../system/data/ent/resource/resource.go | 385 + .../system/data/ent/resource/where.go | 1008 +++ .../system/data/ent/resource_create.go | 728 ++ .../system/data/ent/resource_delete.go | 88 + .../system/data/ent/resource_query.go | 970 +++ .../system/data/ent/resource_update.go | 1492 ++++ internal/features/system/data/ent/role.go | 258 + .../features/system/data/ent/role/role.go | 318 + .../features/system/data/ent/role/where.go | 598 ++ .../features/system/data/ent/role_create.go | 540 ++ .../features/system/data/ent/role_delete.go | 88 + .../features/system/data/ent/role_query.go | 984 +++ .../features/system/data/ent/role_update.go | 1246 +++ .../system/data/ent/rolepermission.go | 160 + .../data/ent/rolepermission/rolepermission.go | 164 + .../system/data/ent/rolepermission/where.go | 166 + .../system/data/ent/rolepermission_create.go | 260 + .../system/data/ent/rolepermission_delete.go | 88 + .../system/data/ent/rolepermission_query.go | 763 ++ .../system/data/ent/rolepermission_update.go | 493 ++ internal/features/system/data/ent/runtime.go | 262 + .../system/data/ent/runtime/runtime.go | 10 + .../system/data/ent/schema/permission.go | 70 + .../data/ent/schema/permissionresource.go | 54 + .../system/data/ent/schema/resource.go | 94 + .../features/system/data/ent/schema/role.go | 97 + .../system/data/ent/schema/rolepermission.go | 58 + .../features/system/data/ent/schema/user.go | 93 + .../system/data/ent/schema/userrole.go | 58 + .../system/data/ent/template/crud.tpl | 40 + .../system/data/ent/template/crud_create.tpl | 34 + .../system/data/ent/template/crud_query.tpl | 48 + .../system/data/ent/template/crud_update.tpl | 33 + .../data/ent/template/crud_update_one.tpl | 48 + .../system/data/ent/template/database.tpl | 126 + .../data/ent/template/mutation_fields.tpl | 119 + .../data/ent/template/type_meta_fields.tpl | 67 + .../data/ent/template/type_meta_where.tpl | 16 + internal/features/system/data/ent/tx.go | 228 + internal/features/system/data/ent/user.go | 337 + .../features/system/data/ent/user/user.go | 395 + .../features/system/data/ent/user/where.go | 1182 +++ .../features/system/data/ent/user_create.go | 752 ++ .../features/system/data/ent/user_delete.go | 88 + .../features/system/data/ent/user_query.go | 825 ++ .../features/system/data/ent/user_update.go | 1328 ++++ internal/features/system/data/ent/userrole.go | 160 + .../system/data/ent/userrole/userrole.go | 164 + .../system/data/ent/userrole/where.go | 166 + .../system/data/ent/userrole_create.go | 260 + .../system/data/ent/userrole_delete.go | 88 + .../system/data/ent/userrole_query.go | 763 ++ .../system/data/ent/userrole_update.go | 493 ++ internal/features/system/data/permission.go | 93 + internal/features/system/data/provider.go | 47 + internal/features/system/data/resource.go | 103 + internal/features/system/data/role.go | 110 + internal/features/system/data/user.go | 140 + internal/features/system/dto/custom.gen.go | 23 +- internal/features/system/dto/department.go | 12 - internal/features/system/dto/dto.gen.go | 622 +- internal/features/system/dto/dto.go | 15 +- internal/features/system/dto/menu.go | 77 - internal/features/system/dto/permission.go | 47 +- internal/features/system/dto/position.go | 12 - internal/features/system/dto/resource.go | 64 +- internal/features/system/dto/role.go | 84 +- internal/features/system/dto/user.go | 110 +- internal/features/system/service/dto.go | 126 + .../features/system/service/menu.bridge.go | 110 - internal/features/system/service/menu.grpc.go | 61 - internal/features/system/service/menu.http.go | 61 - .../system/service/permission.bridge.go | 110 - .../features/system/service/permission.go | 41 + .../system/service/permission.grpc.go | 62 - .../system/service/permission.http.go | 55 - internal/features/system/service/provider.go | 35 +- .../system/service/resource.bridge.go | 110 - internal/features/system/service/resource.go | 41 + .../features/system/service/resource.grpc.go | 61 - .../features/system/service/resource.http.go | 55 - .../features/system/service/role.bridge.go | 110 - internal/features/system/service/role.go | 38 + internal/features/system/service/role.grpc.go | 55 - internal/features/system/service/role.http.go | 49 - internal/features/system/service/service.go | 128 +- .../features/system/service/user.bridge.go | 110 - internal/features/system/service/user.go | 75 + internal/features/system/service/user.grpc.go | 83 - internal/features/system/service/user.http.go | 72 - internal/gateway/proxy.go | 2 +- resources/docs/openapi/openapi.yaml | 12 +- 132 files changed, 37971 insertions(+), 2729 deletions(-) delete mode 100644 internal/features/system/biz/permission.biz.go create mode 100644 internal/features/system/biz/permission.go delete mode 100644 internal/features/system/biz/resource.biz.go create mode 100644 internal/features/system/biz/resource.go delete mode 100644 internal/features/system/biz/role.biz.go create mode 100644 internal/features/system/biz/role.go delete mode 100644 internal/features/system/biz/user.biz.go create mode 100644 internal/features/system/biz/user.go create mode 100644 internal/features/system/data/data.go create mode 100644 internal/features/system/data/ent/client.go create mode 100644 internal/features/system/data/ent/crud.go create mode 100644 internal/features/system/data/ent/database.go create mode 100644 internal/features/system/data/ent/ent.go create mode 100644 internal/features/system/data/ent/enttest/enttest.go create mode 100644 internal/features/system/data/ent/generate.go create mode 100644 internal/features/system/data/ent/hook/hook.go create mode 100644 internal/features/system/data/ent/intercept/intercept.go create mode 100644 internal/features/system/data/ent/migrate/migrate.go create mode 100644 internal/features/system/data/ent/migrate/schema.go create mode 100644 internal/features/system/data/ent/mutation.go create mode 100644 internal/features/system/data/ent/mutation_fields.go create mode 100644 internal/features/system/data/ent/permission.go create mode 100644 internal/features/system/data/ent/permission/permission.go create mode 100644 internal/features/system/data/ent/permission/where.go create mode 100644 internal/features/system/data/ent/permission_create.go create mode 100644 internal/features/system/data/ent/permission_delete.go create mode 100644 internal/features/system/data/ent/permission_query.go create mode 100644 internal/features/system/data/ent/permission_update.go create mode 100644 internal/features/system/data/ent/permissionresource.go create mode 100644 internal/features/system/data/ent/permissionresource/permissionresource.go create mode 100644 internal/features/system/data/ent/permissionresource/where.go create mode 100644 internal/features/system/data/ent/permissionresource_create.go create mode 100644 internal/features/system/data/ent/permissionresource_delete.go create mode 100644 internal/features/system/data/ent/permissionresource_query.go create mode 100644 internal/features/system/data/ent/permissionresource_update.go create mode 100644 internal/features/system/data/ent/predicate/predicate.go create mode 100644 internal/features/system/data/ent/resource.go create mode 100644 internal/features/system/data/ent/resource/resource.go create mode 100644 internal/features/system/data/ent/resource/where.go create mode 100644 internal/features/system/data/ent/resource_create.go create mode 100644 internal/features/system/data/ent/resource_delete.go create mode 100644 internal/features/system/data/ent/resource_query.go create mode 100644 internal/features/system/data/ent/resource_update.go create mode 100644 internal/features/system/data/ent/role.go create mode 100644 internal/features/system/data/ent/role/role.go create mode 100644 internal/features/system/data/ent/role/where.go create mode 100644 internal/features/system/data/ent/role_create.go create mode 100644 internal/features/system/data/ent/role_delete.go create mode 100644 internal/features/system/data/ent/role_query.go create mode 100644 internal/features/system/data/ent/role_update.go create mode 100644 internal/features/system/data/ent/rolepermission.go create mode 100644 internal/features/system/data/ent/rolepermission/rolepermission.go create mode 100644 internal/features/system/data/ent/rolepermission/where.go create mode 100644 internal/features/system/data/ent/rolepermission_create.go create mode 100644 internal/features/system/data/ent/rolepermission_delete.go create mode 100644 internal/features/system/data/ent/rolepermission_query.go create mode 100644 internal/features/system/data/ent/rolepermission_update.go create mode 100644 internal/features/system/data/ent/runtime.go create mode 100644 internal/features/system/data/ent/runtime/runtime.go create mode 100644 internal/features/system/data/ent/schema/permission.go create mode 100644 internal/features/system/data/ent/schema/permissionresource.go create mode 100644 internal/features/system/data/ent/schema/resource.go create mode 100644 internal/features/system/data/ent/schema/role.go create mode 100644 internal/features/system/data/ent/schema/rolepermission.go create mode 100644 internal/features/system/data/ent/schema/user.go create mode 100644 internal/features/system/data/ent/schema/userrole.go create mode 100644 internal/features/system/data/ent/template/crud.tpl create mode 100644 internal/features/system/data/ent/template/crud_create.tpl create mode 100644 internal/features/system/data/ent/template/crud_query.tpl create mode 100644 internal/features/system/data/ent/template/crud_update.tpl create mode 100644 internal/features/system/data/ent/template/crud_update_one.tpl create mode 100644 internal/features/system/data/ent/template/database.tpl create mode 100644 internal/features/system/data/ent/template/mutation_fields.tpl create mode 100644 internal/features/system/data/ent/template/type_meta_fields.tpl create mode 100644 internal/features/system/data/ent/template/type_meta_where.tpl create mode 100644 internal/features/system/data/ent/tx.go create mode 100644 internal/features/system/data/ent/user.go create mode 100644 internal/features/system/data/ent/user/user.go create mode 100644 internal/features/system/data/ent/user/where.go create mode 100644 internal/features/system/data/ent/user_create.go create mode 100644 internal/features/system/data/ent/user_delete.go create mode 100644 internal/features/system/data/ent/user_query.go create mode 100644 internal/features/system/data/ent/user_update.go create mode 100644 internal/features/system/data/ent/userrole.go create mode 100644 internal/features/system/data/ent/userrole/userrole.go create mode 100644 internal/features/system/data/ent/userrole/where.go create mode 100644 internal/features/system/data/ent/userrole_create.go create mode 100644 internal/features/system/data/ent/userrole_delete.go create mode 100644 internal/features/system/data/ent/userrole_query.go create mode 100644 internal/features/system/data/ent/userrole_update.go create mode 100644 internal/features/system/data/permission.go create mode 100644 internal/features/system/data/provider.go create mode 100644 internal/features/system/data/resource.go create mode 100644 internal/features/system/data/role.go create mode 100644 internal/features/system/data/user.go delete mode 100644 internal/features/system/dto/department.go delete mode 100644 internal/features/system/dto/menu.go delete mode 100644 internal/features/system/dto/position.go create mode 100644 internal/features/system/service/dto.go delete mode 100644 internal/features/system/service/menu.bridge.go delete mode 100644 internal/features/system/service/menu.grpc.go delete mode 100644 internal/features/system/service/menu.http.go delete mode 100644 internal/features/system/service/permission.bridge.go create mode 100644 internal/features/system/service/permission.go delete mode 100644 internal/features/system/service/permission.grpc.go delete mode 100644 internal/features/system/service/permission.http.go delete mode 100644 internal/features/system/service/resource.bridge.go create mode 100644 internal/features/system/service/resource.go delete mode 100644 internal/features/system/service/resource.grpc.go delete mode 100644 internal/features/system/service/resource.http.go delete mode 100644 internal/features/system/service/role.bridge.go create mode 100644 internal/features/system/service/role.go delete mode 100644 internal/features/system/service/role.grpc.go delete mode 100644 internal/features/system/service/role.http.go delete mode 100644 internal/features/system/service/user.bridge.go create mode 100644 internal/features/system/service/user.go delete mode 100644 internal/features/system/service/user.grpc.go delete mode 100644 internal/features/system/service/user.http.go diff --git a/api/v1/proto/system/permission.proto b/api/v1/proto/system/permission.proto index 1b9130ef..c0e3c594 100644 --- a/api/v1/proto/system/permission.proto +++ b/api/v1/proto/system/permission.proto @@ -41,8 +41,8 @@ service PermissionService { message ListPermissionsRequest { // The parent resource id, for example, "shelves/shelf1". int64 id = 1 [json_name = "id"]; - // The current page number. - int32 current = 2 [json_name = "current"]; + // The page page number. + int32 page = 2 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 3 [json_name = "page_size"]; // The next_page_token value returned from a previous List request, if any. @@ -57,18 +57,18 @@ message ListPermissionsRequest { message ListPermissionsResponse { // The total number of items in the list. - int32 total_size = 1 [json_name = "total_size"]; + int32 total = 1 [json_name = "total"]; // The paging menus repeated api.v1.services.types.Permission permissions = 2 [json_name = "permissions"]; - // The current page number. - int32 current = 3 [json_name = "current"]; + // The page page number. + int32 page = 3 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 4 [json_name = "page_size"]; // Token to retrieve the next page of results, or empty if there are no // more results in the list. string next_page_token = 5 [json_name = "next_page_token"]; // Additional information about this response. - // content to be added without destroying the current data format + // content to be added without destroying the page data format optional google.protobuf.Any extra = 6 [json_name = "extra"]; } diff --git a/internal/features/system/biz/biz.go b/internal/features/system/biz/biz.go index b8b993f1..91f64b75 100644 --- a/internal/features/system/biz/biz.go +++ b/internal/features/system/biz/biz.go @@ -7,22 +7,10 @@ package biz import ( "net/http" - "github.com/origadmin/runtime/errors" // Changed from httperr - - "origadmin/application/admin/internal/helpers/pagination" - - typespb "origadmin/application/admin/api/v1/services/types" + "github.com/origadmin/toolkits/errors" ) var ( // ErrUserNotFound is user not found. - ErrUserNotFound = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") -) - -var ( - defaultLimiter = pagination.DefaultLimiter() + ErrUserNotFound = errors.New(http.StatusNotFound, "USER_NOT_FOUND", "user not found") ) - -type UpdateHooker interface { - UpdateRules() -} diff --git a/internal/features/system/biz/permission.biz.go b/internal/features/system/biz/permission.biz.go deleted file mode 100644 index ebfbcae5..00000000 --- a/internal/features/system/biz/permission.biz.go +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -// PermissionServiceBiz is a PermissionPB use case. -type PermissionServiceBiz struct { - dao dto.PermissionRepo - limiter pagination.PageLimiter - log *log.KHelper -} - -func (biz PermissionServiceBiz) ListPermissions(ctx context.Context, in *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { - var option dto.PermissionQueryOption - if err := option.FromListRequest(in, biz.limiter); err != nil { - return nil, err - } - option.IncludeResources = true - log.Info("ListPermissions") - result, total, err := biz.dao.List(ctx, in, option) - if err != nil { - return nil, err - } - return dto.ToListPermissionsResponse(result, in, total) -} - -func (biz PermissionServiceBiz) GetPermission(ctx context.Context, in *pb.GetPermissionRequest) (*pb.GetPermissionResponse, error) { - var option dto.PermissionQueryOption - if err := option.FromGetRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("GetPermission") - result, err := biz.dao.Get(ctx, in.GetId(), option) - if err != nil { - return nil, err - } - return &pb.GetPermissionResponse{ - Permission: result, - }, nil -} - -func (biz PermissionServiceBiz) CreatePermission(ctx context.Context, in *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { - var option dto.PermissionQueryOption - if err := option.FromCreateRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("CreatePermission") - result, err := biz.dao.Create(ctx, in.Permission, option) - if err != nil { - return nil, err - } - return &pb.CreatePermissionResponse{ - Permission: result, - }, nil -} - -func (biz PermissionServiceBiz) UpdatePermission(ctx context.Context, in *pb.UpdatePermissionRequest) (*pb.UpdatePermissionResponse, error) { - log.Info("UpdatePermission") - result, err := biz.dao.Update(ctx, in.Permission) - if err != nil { - return nil, err - } - return &pb.UpdatePermissionResponse{ - Permission: result, - }, nil -} - -func (biz PermissionServiceBiz) DeletePermission(ctx context.Context, in *pb.DeletePermissionRequest) (*pb.DeletePermissionResponse, error) { - log.Info("DeletePermission") - if err := biz.dao.Delete(ctx, in.GetId()); err != nil { - return nil, err - } - return &pb.DeletePermissionResponse{}, nil -} - -// NewPermissionServiceBiz new a PermissionPB use case. -func NewPermissionServiceBiz(r runtime.Runtime, repo dto.PermissionRepo) *PermissionServiceBiz { - return &PermissionServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} -} diff --git a/internal/features/system/biz/permission.go b/internal/features/system/biz/permission.go new file mode 100644 index 00000000..443b1410 --- /dev/null +++ b/internal/features/system/biz/permission.go @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "context" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/system/dto" +) + +// PermissionUseCase is a Permission use case. +type PermissionUseCase struct { + repo dto.PermissionRepo +} + +func (uc *PermissionUseCase) ListPermissions(ctx context.Context, in *system.ListPermissionsRequest) ([]*types.Permission, int32, error) { + result, total, err := uc.repo.List(ctx, in) + if err != nil { + return nil, 0, err + } + return result, total, nil +} + +func (uc *PermissionUseCase) GetPermission(ctx context.Context, id int64) (*types.Permission, error) { + result, err := uc.repo.Get(ctx, id) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *PermissionUseCase) CreatePermission(ctx context.Context, in *types.Permission) (*types.Permission, error) { + result, err := uc.repo.Create(ctx, in) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *PermissionUseCase) UpdatePermission(ctx context.Context, in *types.Permission) (*types.Permission, error) { + result, err := uc.repo.Update(ctx, in) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *PermissionUseCase) DeletePermission(ctx context.Context, id int64) error { + if err := uc.repo.Delete(ctx, id); err != nil { + return err + } + return nil +} + +// NewPermissionUseCase new a Permission use case. +func NewPermissionUseCase(repo dto.PermissionRepo) (*PermissionUseCase, error) { + return &PermissionUseCase{repo: repo}, nil +} diff --git a/internal/features/system/biz/provider.go b/internal/features/system/biz/provider.go index 8e15c2fc..2a6b5654 100644 --- a/internal/features/system/biz/provider.go +++ b/internal/features/system/biz/provider.go @@ -11,12 +11,8 @@ import ( // ProviderSet is biz providers. var ProviderSet = wire.NewSet( - //NewAuthServiceBiz, - //NewLoginServiceBiz, - //NewPersonalServiceBiz, - NewResourceServiceBiz, - NewRoleServiceBiz, - NewUserServiceBiz, - NewPermissionServiceBiz, - //NewCasbinSourceServiceBiz, + NewResourceUseCase, + NewRoleUseCase, + NewUserUseCase, + NewPermissionUseCase, ) diff --git a/internal/features/system/biz/resource.biz.go b/internal/features/system/biz/resource.biz.go deleted file mode 100644 index 9b4f1947..00000000 --- a/internal/features/system/biz/resource.biz.go +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -// ResourceServiceBiz is a ResourcePB use case. -type ResourceServiceBiz struct { - dao dto.ResourceRepo - limiter pagination.PageLimiter - log *log.KHelper -} - -func (biz ResourceServiceBiz) ListResources(ctx context.Context, in *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { - var option dto.ResourceQueryOption - if err := option.FromListRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("ListResources") - result, total, err := biz.dao.List(ctx, in, option) - if err != nil { - return nil, err - } - return dto.ToListResourcesResponse(result, in, total) -} - -func (biz ResourceServiceBiz) GetResource(ctx context.Context, in *pb.GetResourceRequest) (*pb.GetResourceResponse, error) { - var option dto.ResourceQueryOption - if err := option.FromGetRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("GetResource") - result, err := biz.dao.Get(ctx, in.GetId(), option) - if err != nil { - return nil, err - } - return &pb.GetResourceResponse{ - Resource: result, - }, nil -} - -func (biz ResourceServiceBiz) CreateResource(ctx context.Context, in *pb.CreateResourceRequest) (*pb.CreateResourceResponse, error) { - var option dto.ResourceQueryOption - if err := option.FromCreateRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("CreateResource") - result, err := biz.dao.Create(ctx, in.Resource, option) - if err != nil { - return nil, err - } - return &pb.CreateResourceResponse{ - Resource: result, - }, nil -} - -var updateFields = []string{ - resource.FieldIcon, resource.FieldType, resource.FieldStatus, - resource.FieldName, resource.FieldPath, resource.FieldKeyword, - resource.FieldSequence, resource.FieldProperties, resource.FieldDescription, -} - -func (biz ResourceServiceBiz) UpdateResource(ctx context.Context, in *pb.UpdateResourceRequest) (*pb.UpdateResourceResponse, error) { - var option dto.ResourceQueryOption - - log.Info("UpdateResource") - option.Fields = resource.SelectColumns(updateFields) - result, err := biz.dao.Update(ctx, in.Resource, option) - if err != nil { - return nil, err - } - return &pb.UpdateResourceResponse{ - Resource: result, - }, nil -} - -func (biz ResourceServiceBiz) DeleteResource(ctx context.Context, in *pb.DeleteResourceRequest) (*pb.DeleteResourceResponse, error) { - log.Info("DeleteResource") - if err := biz.dao.Delete(ctx, in.GetId()); err != nil { - return nil, err - } - return &pb.DeleteResourceResponse{}, nil -} - -// NewResourceServiceBiz new a ResourcePB use case. -func NewResourceServiceBiz(r runtime.Runtime, repo dto.ResourceRepo) *ResourceServiceBiz { - return &ResourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} -} diff --git a/internal/features/system/biz/resource.go b/internal/features/system/biz/resource.go new file mode 100644 index 00000000..76f7b593 --- /dev/null +++ b/internal/features/system/biz/resource.go @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "context" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/system/dto" +) + +// ResourceUseCase is a Resource use case. +type ResourceUseCase struct { + repo dto.ResourceRepo +} + +func (uc *ResourceUseCase) ListResources(ctx context.Context, in *system.ListResourcesRequest) ([]*types.Resource, int32, error) { + result, total, err := uc.repo.List(ctx, in) + if err != nil { + return nil, 0, err + } + return result, total, nil +} + +func (uc *ResourceUseCase) GetResource(ctx context.Context, id int64) (*types.Resource, error) { + result, err := uc.repo.Get(ctx, id) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *ResourceUseCase) CreateResource(ctx context.Context, in *types.Resource) (*types.Resource, error) { + result, err := uc.repo.Create(ctx, in) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *ResourceUseCase) UpdateResource(ctx context.Context, in *types.Resource) (*types.Resource, error) { + result, err := uc.repo.Update(ctx, in) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *ResourceUseCase) DeleteResource(ctx context.Context, id int64) error { + if err := uc.repo.Delete(ctx, id); err != nil { + return err + } + return nil +} + +// NewResourceUseCase new a Resource use case. +func NewResourceUseCase(repo dto.ResourceRepo) (*ResourceUseCase, error) { + return &ResourceUseCase{repo: repo}, nil +} diff --git a/internal/features/system/biz/role.biz.go b/internal/features/system/biz/role.biz.go deleted file mode 100644 index 3e6b746e..00000000 --- a/internal/features/system/biz/role.biz.go +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -// RoleServiceBiz is a RolePB use case. -type RoleServiceBiz struct { - dao dto.RoleRepo - limiter pagination.PageLimiter - log *log.KHelper -} - -func (biz RoleServiceBiz) ListRoles(ctx context.Context, in *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { - var option dto.RoleQueryOption - if err := option.FromListRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("ListRoles") - option.IncludePermissions = true - result, total, err := biz.dao.List(ctx, in, option) - if err != nil { - return nil, err - } - return dto.ToListRolesResponse(result, in, total) -} - -func (biz RoleServiceBiz) GetRole(ctx context.Context, in *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { - var option dto.RoleQueryOption - if err := option.FromGetRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("GetRole") - result, err := biz.dao.Get(ctx, in.GetId(), option) - if err != nil { - return nil, err - } - return &pb.GetRoleResponse{ - Role: result, - }, nil -} - -func (biz RoleServiceBiz) CreateRole(ctx context.Context, in *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { - var option dto.RoleUpdateOption - if err := option.FromCreateRequest(in); err != nil { - return nil, err - } - log.Info("CreateRole") - result, err := biz.dao.Create(ctx, in.Role, option) - if err != nil { - return nil, err - } - return &pb.CreateRoleResponse{ - Role: result, - }, nil -} - -func (biz RoleServiceBiz) UpdateRole(ctx context.Context, in *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { - //var option dto.UpdateRoleOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("UpdateRole") - result, err := biz.dao.Update(ctx, in.Role) - if err != nil { - return nil, err - } - return &pb.UpdateRoleResponse{ - Role: result, - }, nil -} - -func (biz RoleServiceBiz) DeleteRole(ctx context.Context, in *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { - //var option dto.DeleteRoleOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - //_, err := biz.dao.Get(ctx, in.GetId()) - //if err != nil { - // return nil, err - //} - log.Info("DeleteRole") - if err := biz.dao.Delete(ctx, in.GetId()); err != nil { - return nil, err - } - return &pb.DeleteRoleResponse{}, nil -} - -// NewRoleServiceBiz new a RolePB use case. -func NewRoleServiceBiz(r runtime.Runtime, repo dto.RoleRepo) *RoleServiceBiz { - return &RoleServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} -} diff --git a/internal/features/system/biz/role.go b/internal/features/system/biz/role.go new file mode 100644 index 00000000..01b48a73 --- /dev/null +++ b/internal/features/system/biz/role.go @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "context" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/system/dto" +) + +// RoleUseCase is a Role use case. +type RoleUseCase struct { + repo dto.RoleRepo +} + +func (uc *RoleUseCase) ListRoles(ctx context.Context, in *system.ListRolesRequest) ([]*types.Role, int32, error) { + result, total, err := uc.repo.List(ctx, in) + if err != nil { + return nil, 0, err + } + return result, total, nil +} + +func (uc *RoleUseCase) GetRole(ctx context.Context, id int64) (*types.Role, error) { + result, err := uc.repo.Get(ctx, id) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *RoleUseCase) CreateRole(ctx context.Context, in *types.Role) (*types.Role, error) { + result, err := uc.repo.Create(ctx, in) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *RoleUseCase) UpdateRole(ctx context.Context, in *types.Role) (*types.Role, error) { + result, err := uc.repo.Update(ctx, in) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *RoleUseCase) DeleteRole(ctx context.Context, id int64) error { + if err := uc.repo.Delete(ctx, id); err != nil { + return err + } + return nil +} + +// NewRoleUseCase new a Role use case. +func NewRoleUseCase(repo dto.RoleRepo) (*RoleUseCase, error) { + return &RoleUseCase{repo: repo}, nil +} diff --git a/internal/features/system/biz/user.biz.go b/internal/features/system/biz/user.biz.go deleted file mode 100644 index eb061468..00000000 --- a/internal/features/system/biz/user.biz.go +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "fmt" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -// UserServiceBiz is a UserPB use case. -type UserServiceBiz struct { - dao dto.UserRepo - limiter pagination.PageLimiter - log *log.KHelper -} - -func (biz UserServiceBiz) ListUserResources(ctx context.Context, in *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { - var option dto.UserQueryOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("ListUserResources") - //option.IncludeRoles = true - result, err := biz.dao.ListResourceByUserID(ctx, in.GetId(), option) - if err != nil { - return nil, err - } - log.Info("ListUserResources result:", result) - //return dto.ToListResourcesResponse(result, in, total) - return &pb.ListUserResourcesResponse{ - TotalSize: int32(len(result)), - //Current: in.Current, - //PageSize: in.PageSize, - Resources: result, - //Extra: resp.Any(args...), - }, nil -} - -func (biz UserServiceBiz) UpdateUserRoles(ctx context.Context, in *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { - var option dto.UserMutationOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("UpdateUserRoles") - //option.IncludeRoles = true - err := biz.dao.AddRoleIDs(ctx, in.GetUser().GetId(), in.GetRoleIds(), option) - if err != nil { - return nil, err - } - return &pb.UpdateUserRolesResponse{ - //User: result, - }, nil -} - -func (biz UserServiceBiz) UpdateUserStatus(ctx context.Context, in *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { - var option dto.UserQueryOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("UpdateUserStatus") - option.Fields = []string{"status"} - //option.IncludeRoles = true - err := biz.dao.UpdateUserStatus(ctx, in.GetUser().GetId(), int8(in.GetUser().GetStatus()), option) - if err != nil { - return nil, err - } - return &pb.UpdateUserStatusResponse{ - //User: result, - }, nil -} - -func (biz UserServiceBiz) ResetUserPassword(ctx context.Context, in *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { - var option dto.UserQueryOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("ResetUserPassword") - option.IncludeRoles = true - //result, total, err := biz.dao.ResetUserPassword(ctx, in, option) - //if err != nil { - // return nil, err - //} - //return dto.ToListUsersResponse(result, in, total) - return &pb.ResetUserPasswordResponse{}, nil -} - -func (biz UserServiceBiz) ListUsers(ctx context.Context, in *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { - var option dto.UserQueryOption - if err := option.FromListRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("ListUsers") - option.IncludeRoles = true - result, total, err := biz.dao.List(ctx, in, option) - if err != nil { - return nil, err - } - return dto.ToListUsersResponse(result, in, total) -} - -func (biz UserServiceBiz) GetUser(ctx context.Context, in *pb.GetUserRequest) (*pb.GetUserResponse, error) { - var option dto.UserQueryOption - if err := option.FromGetRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("GetUser") - result, err := biz.dao.Get(ctx, in.GetId(), option) - if err != nil { - return nil, err - } - return &pb.GetUserResponse{ - User: result, - }, nil -} - -func (biz UserServiceBiz) CreateUser(ctx context.Context, in *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { - var option dto.UserMutationOption - if err := option.FromCreateRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("MakeCreateUser") - username := in.GetUser().GetUsername() - password := in.GetUser().GetPassword() - createUser, ps, err := dto.MakeCreateUser(in.User, username, password, option) - if err != nil { - return nil, err - } - // TODO: Send email or sms to user - _ = ps - fmt.Println("Create new user username:", username, "password:", ps) - - result, err := biz.dao.Create(ctx, createUser, option) - if err != nil { - return nil, err - } - return &pb.CreateUserResponse{ - User: result, - }, nil -} - -func (biz UserServiceBiz) UpdateUser(ctx context.Context, in *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { - //var option dto.UpdateUserOption - //if err := option.FromListRequest(in, biz.limiter); err != nil { - // return nil, err - //} - log.Info("UpdateUser") - result, err := biz.dao.Update(ctx, in.User) - if err != nil { - return nil, err - } - return &pb.UpdateUserResponse{ - User: result, - }, nil -} - -func (biz UserServiceBiz) DeleteUser(ctx context.Context, in *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { - log.Info("DeleteUser") - if err := biz.dao.Delete(ctx, in.GetUser().GetId()); err != nil { - return nil, err - } - return &pb.DeleteUserResponse{}, nil -} - -// NewUserServiceBiz new a UserPB use case. - -func NewUserServiceBiz(r runtime.Runtime, repo dto.UserRepo) *UserServiceBiz { - return &UserServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} -} diff --git a/internal/features/system/biz/user.go b/internal/features/system/biz/user.go new file mode 100644 index 00000000..00fd18e9 --- /dev/null +++ b/internal/features/system/biz/user.go @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package biz is a biz layer for the system module of OrigAdmin. +package biz + +import ( + "context" + "fmt" + "github.com/origadmin/toolkits/auth/authenticator" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/system/dto" +) + +// UserUseCase is a User use case. +type UserUseCase struct { + repo dto.UserRepo + auth authenticator.Authenticator +} + +func (uc *UserUseCase) ListUserResources(ctx context.Context, id int64) ([]*types.Resource, error) { + result, err := uc.repo.ListResourceByUserID(ctx, id) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *UserUseCase) UpdateUserRoles(ctx context.Context, id int64, roleIDs []int64) error { + err := uc.repo.AddRoleIDs(ctx, id, roleIDs) + if err != nil { + return err + } + return nil +} + +func (uc *UserUseCase) UpdateUserStatus(ctx context.Context, id int64, status int32) error { + err := uc.repo.UpdateUserStatus(ctx, id, status) + if err != nil { + return err + } + return nil +} + +func (uc *UserUseCase) ResetUserPassword(ctx context.Context, id int64, password string) error { + // TODO + return nil +} + +func (uc *UserUseCase) ListUsers(ctx context.Context, in *system.ListUsersRequest) ([]*types.User, int32, error) { + result, total, err := uc.repo.List(ctx, in) + if err != nil { + return nil, 0, err + } + return result, total, nil +} + +func (uc *UserUseCase) GetUser(ctx context.Context, id int64) (*types.User, error) { + result, err := uc.repo.Get(ctx, id) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *UserUseCase) CreateUser(ctx context.Context, in *types.User, password string) (*types.User, error) { + encryptedPassword, err := uc.auth.Create(in.Username, password) + if err != nil { + return nil, err + } + in.Password = encryptedPassword + + fmt.Println("Create new user username:", in.Username, "password:", password) + + result, err := uc.repo.Create(ctx, in) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *UserUseCase) UpdateUser(ctx context.Context, in *types.User) (*types.User, error) { + result, err := uc.repo.Update(ctx, in) + if err != nil { + return nil, err + } + return result, nil +} + +func (uc *UserUseCase) DeleteUser(ctx context.Context, id int64) error { + if err := uc.repo.Delete(ctx, id); err != nil { + return err + } + return nil +} + +// NewUserUseCase new a User use case. +func NewUserUseCase(repo dto.UserRepo, auth authenticator.Authenticator) (*UserUseCase, error) { + return &UserUseCase{repo: repo, auth: auth}, nil +} diff --git a/internal/features/system/data/data.go b/internal/features/system/data/data.go new file mode 100644 index 00000000..59ccd550 --- /dev/null +++ b/internal/features/system/data/data.go @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package data implements the functions, types, and interfaces for the module. +package data + +import ( + "context" + + entsql "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/schema" + "github.com/google/wire" + + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/data/storage" + "github.com/origadmin/runtime/interfaces" + ifacestorage "github.com/origadmin/runtime/interfaces/storage" + "github.com/origadmin/runtime/log" + + "origadmin/application/admin/internal/features/system/data/ent" +) + +// ProviderSet is data providers. +var ProviderSet = wire.NewSet(NewData, NewUserRepo, NewRoleRepo, NewResourceRepo, NewPermissionRepo) + +// Data encapsulates ent client and cache. +type Data struct { + db *ent.Client + cache ifacestorage.Cache + provider storage.Provider + config interfaces.StructuredConfig + Log *log.Helper +} + +// NewData creates a new Data instance. +func NewData(rt *runtime.App) (*Data, func(), error) { + logHelper := log.NewHelper(rt.Logger()) + + provider, err := storage.New(rt.StructuredConfig()) + if err != nil { + return nil, nil, err + } + + db, err := provider.DefaultDatabase() + if err != nil { + return nil, nil, err + } + + activeDB := entsql.OpenDB(db.Dialect(), db.DB()) + client := ent.NewClient(ent.Driver(activeDB)) + + // Run the auto migration tool. + // Note: context.Background() is used here as the schema creation is a one-time setup. + if err := client.Schema.Create(context.Background(), + schema.WithDropIndex(true), + schema.WithDropColumn(true), + schema.WithForeignKeys(false)); err != nil { + logHelper.Fatalf("failed creating schema resources: %v", err) + } + + cache, err := provider.DefaultCache() + if err != nil { + return nil, nil, err + } + + cleanup := func() { + logHelper.Info("closing the data resources") + if client != nil { + if err := client.Close(); err != nil { + logHelper.Errorf("failed to close ent client: %v", err) + } + } + + } + + return &Data{ + config: rt.StructuredConfig(), + provider: provider, + db: client, + cache: cache, + Log: logHelper, + }, cleanup, nil +} + +// DB returns the ent.Client instance. +func (d *Data) DB() *ent.Client { + return d.db +} diff --git a/internal/features/system/data/ent/client.go b/internal/features/system/data/ent/client.go new file mode 100644 index 00000000..309e8573 --- /dev/null +++ b/internal/features/system/data/ent/client.go @@ -0,0 +1,1520 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "log" + "reflect" + + "origadmin/application/admin/internal/features/system/data/ent/migrate" + + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // Permission is the client for interacting with the Permission builders. + Permission *PermissionClient + // PermissionResource is the client for interacting with the PermissionResource builders. + PermissionResource *PermissionResourceClient + // Resource is the client for interacting with the Resource builders. + Resource *ResourceClient + // Role is the client for interacting with the Role builders. + Role *RoleClient + // RolePermission is the client for interacting with the RolePermission builders. + RolePermission *RolePermissionClient + // User is the client for interacting with the User builders. + User *UserClient + // UserRole is the client for interacting with the UserRole builders. + UserRole *UserRoleClient +} + +// NewClient creates a new client configured with the given options. +func NewClient(opts ...Option) *Client { + client := &Client{config: newConfig(opts...)} + client.init() + return client +} + +func (c *Client) init() { + c.Schema = migrate.NewSchema(c.driver) + c.Permission = NewPermissionClient(c.config) + c.PermissionResource = NewPermissionResourceClient(c.config) + c.Resource = NewResourceClient(c.config) + c.Role = NewRoleClient(c.config) + c.RolePermission = NewRolePermissionClient(c.config) + c.User = NewUserClient(c.config) + c.UserRole = NewUserRoleClient(c.config) +} + +type ( + // config is the configuration for the client and its builder. + config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...any) + // hooks to execute on mutations. + hooks *hooks + // interceptors to execute on queries. + inters *inters + } + // Option function to configure the client. + Option func(*config) +) + +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + +// options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...any)) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} + +// Open opens a database/sql.DB specified by the driver name and +// the data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.Postgres, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + +// Tx returns a new transactional client. The provided context +// is used until the transaction is committed or rolled back. +func (c *Client) Tx(ctx context.Context) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, ErrTxStarted + } + tx, err := newTx(ctx, c.driver) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = tx + return &Tx{ + ctx: ctx, + config: cfg, + Permission: NewPermissionClient(cfg), + PermissionResource: NewPermissionResourceClient(cfg), + Resource: NewResourceClient(cfg), + Role: NewRoleClient(cfg), + RolePermission: NewRolePermissionClient(cfg), + User: NewUserClient(cfg), + UserRole: NewUserRoleClient(cfg), + }, nil +} + +// BeginTx returns a transactional client with specified options. +func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, errors.New("ent: cannot start a transaction within a transaction") + } + tx, err := c.driver.(interface { + BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) + }).BeginTx(ctx, opts) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = &txDriver{tx: tx, drv: c.driver} + return &Tx{ + ctx: ctx, + config: cfg, + Permission: NewPermissionClient(cfg), + PermissionResource: NewPermissionResourceClient(cfg), + Resource: NewResourceClient(cfg), + Role: NewRoleClient(cfg), + RolePermission: NewRolePermissionClient(cfg), + User: NewUserClient(cfg), + UserRole: NewUserRoleClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Permission. +// Query(). +// Count(ctx) +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := c.config + cfg.driver = dialect.Debug(c.driver, c.log) + client := &Client{config: cfg} + client.init() + return client +} + +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + +// Use adds the mutation hooks to all the entity clients. +// In order to add hooks to a specific client, call: `client.Node.Use(...)`. +func (c *Client) Use(hooks ...Hook) { + for _, n := range []interface{ Use(...Hook) }{ + c.Permission, c.PermissionResource, c.Resource, c.Role, c.RolePermission, + c.User, c.UserRole, + } { + n.Use(hooks...) + } +} + +// Intercept adds the query interceptors to all the entity clients. +// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. +func (c *Client) Intercept(interceptors ...Interceptor) { + for _, n := range []interface{ Intercept(...Interceptor) }{ + c.Permission, c.PermissionResource, c.Resource, c.Role, c.RolePermission, + c.User, c.UserRole, + } { + n.Intercept(interceptors...) + } +} + +// Mutate implements the ent.Mutator interface. +func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { + switch m := m.(type) { + case *PermissionMutation: + return c.Permission.mutate(ctx, m) + case *PermissionResourceMutation: + return c.PermissionResource.mutate(ctx, m) + case *ResourceMutation: + return c.Resource.mutate(ctx, m) + case *RoleMutation: + return c.Role.mutate(ctx, m) + case *RolePermissionMutation: + return c.RolePermission.mutate(ctx, m) + case *UserMutation: + return c.User.mutate(ctx, m) + case *UserRoleMutation: + return c.UserRole.mutate(ctx, m) + default: + return nil, fmt.Errorf("ent: unknown mutation type %T", m) + } +} + +// PermissionClient is a client for the Permission schema. +type PermissionClient struct { + config +} + +// NewPermissionClient returns a client for the Permission from the given config. +func NewPermissionClient(c config) *PermissionClient { + return &PermissionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `permission.Hooks(f(g(h())))`. +func (c *PermissionClient) Use(hooks ...Hook) { + c.hooks.Permission = append(c.hooks.Permission, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `permission.Intercept(f(g(h())))`. +func (c *PermissionClient) Intercept(interceptors ...Interceptor) { + c.inters.Permission = append(c.inters.Permission, interceptors...) +} + +// Create returns a builder for creating a Permission entity. +func (c *PermissionClient) Create() *PermissionCreate { + mutation := newPermissionMutation(c.config, OpCreate) + return &PermissionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Permission entities. +func (c *PermissionClient) CreateBulk(builders ...*PermissionCreate) *PermissionCreateBulk { + return &PermissionCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PermissionClient) MapCreateBulk(slice any, setFunc func(*PermissionCreate, int)) *PermissionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PermissionCreateBulk{err: fmt.Errorf("calling to PermissionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PermissionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PermissionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Permission. +func (c *PermissionClient) Update() *PermissionUpdate { + mutation := newPermissionMutation(c.config, OpUpdate) + return &PermissionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PermissionClient) UpdateOne(_m *Permission) *PermissionUpdateOne { + mutation := newPermissionMutation(c.config, OpUpdateOne, withPermission(_m)) + return &PermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PermissionClient) UpdateOneID(id int64) *PermissionUpdateOne { + mutation := newPermissionMutation(c.config, OpUpdateOne, withPermissionID(id)) + return &PermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Permission. +func (c *PermissionClient) Delete() *PermissionDelete { + mutation := newPermissionMutation(c.config, OpDelete) + return &PermissionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PermissionClient) DeleteOne(_m *Permission) *PermissionDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PermissionClient) DeleteOneID(id int64) *PermissionDeleteOne { + builder := c.Delete().Where(permission.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PermissionDeleteOne{builder} +} + +// Query returns a query builder for Permission. +func (c *PermissionClient) Query() *PermissionQuery { + return &PermissionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePermission}, + inters: c.Interceptors(), + } +} + +// Get returns a Permission entity by its id. +func (c *PermissionClient) Get(ctx context.Context, id int64) (*Permission, error) { + return c.Query().Where(permission.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PermissionClient) GetX(ctx context.Context, id int64) *Permission { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryRoles queries the roles edge of a Permission. +func (c *PermissionClient) QueryRoles(_m *Permission) *RoleQuery { + query := (&RoleClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, id), + sqlgraph.To(role.Table, role.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, permission.RolesTable, permission.RolesPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryResources queries the resources edge of a Permission. +func (c *PermissionClient) QueryResources(_m *Permission) *ResourceQuery { + query := (&ResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, id), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, permission.ResourcesTable, permission.ResourcesPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryRolePermissions queries the role_permissions edge of a Permission. +func (c *PermissionClient) QueryRolePermissions(_m *Permission) *RolePermissionQuery { + query := (&RolePermissionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, id), + sqlgraph.To(rolepermission.Table, rolepermission.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, permission.RolePermissionsTable, permission.RolePermissionsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryPermissionResources queries the permission_resources edge of a Permission. +func (c *PermissionClient) QueryPermissionResources(_m *Permission) *PermissionResourceQuery { + query := (&PermissionResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, id), + sqlgraph.To(permissionresource.Table, permissionresource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, permission.PermissionResourcesTable, permission.PermissionResourcesColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PermissionClient) Hooks() []Hook { + return c.hooks.Permission +} + +// Interceptors returns the client interceptors. +func (c *PermissionClient) Interceptors() []Interceptor { + return c.inters.Permission +} + +func (c *PermissionClient) mutate(ctx context.Context, m *PermissionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PermissionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PermissionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PermissionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Permission mutation op: %q", m.Op()) + } +} + +// PermissionResourceClient is a client for the PermissionResource schema. +type PermissionResourceClient struct { + config +} + +// NewPermissionResourceClient returns a client for the PermissionResource from the given config. +func NewPermissionResourceClient(c config) *PermissionResourceClient { + return &PermissionResourceClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `permissionresource.Hooks(f(g(h())))`. +func (c *PermissionResourceClient) Use(hooks ...Hook) { + c.hooks.PermissionResource = append(c.hooks.PermissionResource, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `permissionresource.Intercept(f(g(h())))`. +func (c *PermissionResourceClient) Intercept(interceptors ...Interceptor) { + c.inters.PermissionResource = append(c.inters.PermissionResource, interceptors...) +} + +// Create returns a builder for creating a PermissionResource entity. +func (c *PermissionResourceClient) Create() *PermissionResourceCreate { + mutation := newPermissionResourceMutation(c.config, OpCreate) + return &PermissionResourceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of PermissionResource entities. +func (c *PermissionResourceClient) CreateBulk(builders ...*PermissionResourceCreate) *PermissionResourceCreateBulk { + return &PermissionResourceCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PermissionResourceClient) MapCreateBulk(slice any, setFunc func(*PermissionResourceCreate, int)) *PermissionResourceCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PermissionResourceCreateBulk{err: fmt.Errorf("calling to PermissionResourceClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PermissionResourceCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PermissionResourceCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for PermissionResource. +func (c *PermissionResourceClient) Update() *PermissionResourceUpdate { + mutation := newPermissionResourceMutation(c.config, OpUpdate) + return &PermissionResourceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PermissionResourceClient) UpdateOne(_m *PermissionResource) *PermissionResourceUpdateOne { + mutation := newPermissionResourceMutation(c.config, OpUpdateOne, withPermissionResource(_m)) + return &PermissionResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PermissionResourceClient) UpdateOneID(id int) *PermissionResourceUpdateOne { + mutation := newPermissionResourceMutation(c.config, OpUpdateOne, withPermissionResourceID(id)) + return &PermissionResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for PermissionResource. +func (c *PermissionResourceClient) Delete() *PermissionResourceDelete { + mutation := newPermissionResourceMutation(c.config, OpDelete) + return &PermissionResourceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PermissionResourceClient) DeleteOne(_m *PermissionResource) *PermissionResourceDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *PermissionResourceClient) DeleteOneID(id int) *PermissionResourceDeleteOne { + builder := c.Delete().Where(permissionresource.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PermissionResourceDeleteOne{builder} +} + +// Query returns a query builder for PermissionResource. +func (c *PermissionResourceClient) Query() *PermissionResourceQuery { + return &PermissionResourceQuery{ + config: c.config, + ctx: &QueryContext{Type: TypePermissionResource}, + inters: c.Interceptors(), + } +} + +// Get returns a PermissionResource entity by its id. +func (c *PermissionResourceClient) Get(ctx context.Context, id int) (*PermissionResource, error) { + return c.Query().Where(permissionresource.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PermissionResourceClient) GetX(ctx context.Context, id int) *PermissionResource { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryPermission queries the permission edge of a PermissionResource. +func (c *PermissionResourceClient) QueryPermission(_m *PermissionResource) *PermissionQuery { + query := (&PermissionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(permissionresource.Table, permissionresource.FieldID, id), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.PermissionTable, permissionresource.PermissionColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryResource queries the resource edge of a PermissionResource. +func (c *PermissionResourceClient) QueryResource(_m *PermissionResource) *ResourceQuery { + query := (&ResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(permissionresource.Table, permissionresource.FieldID, id), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.ResourceTable, permissionresource.ResourceColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *PermissionResourceClient) Hooks() []Hook { + return c.hooks.PermissionResource +} + +// Interceptors returns the client interceptors. +func (c *PermissionResourceClient) Interceptors() []Interceptor { + return c.inters.PermissionResource +} + +func (c *PermissionResourceClient) mutate(ctx context.Context, m *PermissionResourceMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PermissionResourceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PermissionResourceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PermissionResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PermissionResourceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown PermissionResource mutation op: %q", m.Op()) + } +} + +// ResourceClient is a client for the Resource schema. +type ResourceClient struct { + config +} + +// NewResourceClient returns a client for the Resource from the given config. +func NewResourceClient(c config) *ResourceClient { + return &ResourceClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `resource.Hooks(f(g(h())))`. +func (c *ResourceClient) Use(hooks ...Hook) { + c.hooks.Resource = append(c.hooks.Resource, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `resource.Intercept(f(g(h())))`. +func (c *ResourceClient) Intercept(interceptors ...Interceptor) { + c.inters.Resource = append(c.inters.Resource, interceptors...) +} + +// Create returns a builder for creating a Resource entity. +func (c *ResourceClient) Create() *ResourceCreate { + mutation := newResourceMutation(c.config, OpCreate) + return &ResourceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Resource entities. +func (c *ResourceClient) CreateBulk(builders ...*ResourceCreate) *ResourceCreateBulk { + return &ResourceCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ResourceClient) MapCreateBulk(slice any, setFunc func(*ResourceCreate, int)) *ResourceCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ResourceCreateBulk{err: fmt.Errorf("calling to ResourceClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ResourceCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ResourceCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Resource. +func (c *ResourceClient) Update() *ResourceUpdate { + mutation := newResourceMutation(c.config, OpUpdate) + return &ResourceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ResourceClient) UpdateOne(_m *Resource) *ResourceUpdateOne { + mutation := newResourceMutation(c.config, OpUpdateOne, withResource(_m)) + return &ResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ResourceClient) UpdateOneID(id int64) *ResourceUpdateOne { + mutation := newResourceMutation(c.config, OpUpdateOne, withResourceID(id)) + return &ResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Resource. +func (c *ResourceClient) Delete() *ResourceDelete { + mutation := newResourceMutation(c.config, OpDelete) + return &ResourceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ResourceClient) DeleteOne(_m *Resource) *ResourceDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ResourceClient) DeleteOneID(id int64) *ResourceDeleteOne { + builder := c.Delete().Where(resource.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ResourceDeleteOne{builder} +} + +// Query returns a query builder for Resource. +func (c *ResourceClient) Query() *ResourceQuery { + return &ResourceQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeResource}, + inters: c.Interceptors(), + } +} + +// Get returns a Resource entity by its id. +func (c *ResourceClient) Get(ctx context.Context, id int64) (*Resource, error) { + return c.Query().Where(resource.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ResourceClient) GetX(ctx context.Context, id int64) *Resource { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryParent queries the parent edge of a Resource. +func (c *ResourceClient) QueryParent(_m *Resource) *ResourceQuery { + query := (&ResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, id), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, resource.ParentTable, resource.ParentColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryChildren queries the children edge of a Resource. +func (c *ResourceClient) QueryChildren(_m *Resource) *ResourceQuery { + query := (&ResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, id), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, resource.ChildrenTable, resource.ChildrenColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryPermissions queries the permissions edge of a Resource. +func (c *ResourceClient) QueryPermissions(_m *Resource) *PermissionQuery { + query := (&PermissionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, id), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, resource.PermissionsTable, resource.PermissionsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryPermissionResources queries the permission_resources edge of a Resource. +func (c *ResourceClient) QueryPermissionResources(_m *Resource) *PermissionResourceQuery { + query := (&PermissionResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, id), + sqlgraph.To(permissionresource.Table, permissionresource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, resource.PermissionResourcesTable, resource.PermissionResourcesColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ResourceClient) Hooks() []Hook { + return c.hooks.Resource +} + +// Interceptors returns the client interceptors. +func (c *ResourceClient) Interceptors() []Interceptor { + return c.inters.Resource +} + +func (c *ResourceClient) mutate(ctx context.Context, m *ResourceMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ResourceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ResourceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ResourceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Resource mutation op: %q", m.Op()) + } +} + +// RoleClient is a client for the Role schema. +type RoleClient struct { + config +} + +// NewRoleClient returns a client for the Role from the given config. +func NewRoleClient(c config) *RoleClient { + return &RoleClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `role.Hooks(f(g(h())))`. +func (c *RoleClient) Use(hooks ...Hook) { + c.hooks.Role = append(c.hooks.Role, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `role.Intercept(f(g(h())))`. +func (c *RoleClient) Intercept(interceptors ...Interceptor) { + c.inters.Role = append(c.inters.Role, interceptors...) +} + +// Create returns a builder for creating a Role entity. +func (c *RoleClient) Create() *RoleCreate { + mutation := newRoleMutation(c.config, OpCreate) + return &RoleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Role entities. +func (c *RoleClient) CreateBulk(builders ...*RoleCreate) *RoleCreateBulk { + return &RoleCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *RoleClient) MapCreateBulk(slice any, setFunc func(*RoleCreate, int)) *RoleCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &RoleCreateBulk{err: fmt.Errorf("calling to RoleClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*RoleCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &RoleCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Role. +func (c *RoleClient) Update() *RoleUpdate { + mutation := newRoleMutation(c.config, OpUpdate) + return &RoleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *RoleClient) UpdateOne(_m *Role) *RoleUpdateOne { + mutation := newRoleMutation(c.config, OpUpdateOne, withRole(_m)) + return &RoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *RoleClient) UpdateOneID(id int64) *RoleUpdateOne { + mutation := newRoleMutation(c.config, OpUpdateOne, withRoleID(id)) + return &RoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Role. +func (c *RoleClient) Delete() *RoleDelete { + mutation := newRoleMutation(c.config, OpDelete) + return &RoleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *RoleClient) DeleteOne(_m *Role) *RoleDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *RoleClient) DeleteOneID(id int64) *RoleDeleteOne { + builder := c.Delete().Where(role.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &RoleDeleteOne{builder} +} + +// Query returns a query builder for Role. +func (c *RoleClient) Query() *RoleQuery { + return &RoleQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeRole}, + inters: c.Interceptors(), + } +} + +// Get returns a Role entity by its id. +func (c *RoleClient) Get(ctx context.Context, id int64) (*Role, error) { + return c.Query().Where(role.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *RoleClient) GetX(ctx context.Context, id int64) *Role { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryUsers queries the users edge of a Role. +func (c *RoleClient) QueryUsers(_m *Role) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(role.Table, role.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, role.UsersTable, role.UsersPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryPermissions queries the permissions edge of a Role. +func (c *RoleClient) QueryPermissions(_m *Role) *PermissionQuery { + query := (&PermissionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(role.Table, role.FieldID, id), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, role.PermissionsTable, role.PermissionsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryUserRoles queries the user_roles edge of a Role. +func (c *RoleClient) QueryUserRoles(_m *Role) *UserRoleQuery { + query := (&UserRoleClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(role.Table, role.FieldID, id), + sqlgraph.To(userrole.Table, userrole.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, role.UserRolesTable, role.UserRolesColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryRolePermissions queries the role_permissions edge of a Role. +func (c *RoleClient) QueryRolePermissions(_m *Role) *RolePermissionQuery { + query := (&RolePermissionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(role.Table, role.FieldID, id), + sqlgraph.To(rolepermission.Table, rolepermission.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, role.RolePermissionsTable, role.RolePermissionsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *RoleClient) Hooks() []Hook { + return c.hooks.Role +} + +// Interceptors returns the client interceptors. +func (c *RoleClient) Interceptors() []Interceptor { + return c.inters.Role +} + +func (c *RoleClient) mutate(ctx context.Context, m *RoleMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&RoleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&RoleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&RoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&RoleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Role mutation op: %q", m.Op()) + } +} + +// RolePermissionClient is a client for the RolePermission schema. +type RolePermissionClient struct { + config +} + +// NewRolePermissionClient returns a client for the RolePermission from the given config. +func NewRolePermissionClient(c config) *RolePermissionClient { + return &RolePermissionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `rolepermission.Hooks(f(g(h())))`. +func (c *RolePermissionClient) Use(hooks ...Hook) { + c.hooks.RolePermission = append(c.hooks.RolePermission, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `rolepermission.Intercept(f(g(h())))`. +func (c *RolePermissionClient) Intercept(interceptors ...Interceptor) { + c.inters.RolePermission = append(c.inters.RolePermission, interceptors...) +} + +// Create returns a builder for creating a RolePermission entity. +func (c *RolePermissionClient) Create() *RolePermissionCreate { + mutation := newRolePermissionMutation(c.config, OpCreate) + return &RolePermissionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of RolePermission entities. +func (c *RolePermissionClient) CreateBulk(builders ...*RolePermissionCreate) *RolePermissionCreateBulk { + return &RolePermissionCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *RolePermissionClient) MapCreateBulk(slice any, setFunc func(*RolePermissionCreate, int)) *RolePermissionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &RolePermissionCreateBulk{err: fmt.Errorf("calling to RolePermissionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*RolePermissionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &RolePermissionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for RolePermission. +func (c *RolePermissionClient) Update() *RolePermissionUpdate { + mutation := newRolePermissionMutation(c.config, OpUpdate) + return &RolePermissionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *RolePermissionClient) UpdateOne(_m *RolePermission) *RolePermissionUpdateOne { + mutation := newRolePermissionMutation(c.config, OpUpdateOne, withRolePermission(_m)) + return &RolePermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *RolePermissionClient) UpdateOneID(id int) *RolePermissionUpdateOne { + mutation := newRolePermissionMutation(c.config, OpUpdateOne, withRolePermissionID(id)) + return &RolePermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for RolePermission. +func (c *RolePermissionClient) Delete() *RolePermissionDelete { + mutation := newRolePermissionMutation(c.config, OpDelete) + return &RolePermissionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *RolePermissionClient) DeleteOne(_m *RolePermission) *RolePermissionDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *RolePermissionClient) DeleteOneID(id int) *RolePermissionDeleteOne { + builder := c.Delete().Where(rolepermission.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &RolePermissionDeleteOne{builder} +} + +// Query returns a query builder for RolePermission. +func (c *RolePermissionClient) Query() *RolePermissionQuery { + return &RolePermissionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeRolePermission}, + inters: c.Interceptors(), + } +} + +// Get returns a RolePermission entity by its id. +func (c *RolePermissionClient) Get(ctx context.Context, id int) (*RolePermission, error) { + return c.Query().Where(rolepermission.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *RolePermissionClient) GetX(ctx context.Context, id int) *RolePermission { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryRole queries the role edge of a RolePermission. +func (c *RolePermissionClient) QueryRole(_m *RolePermission) *RoleQuery { + query := (&RoleClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(rolepermission.Table, rolepermission.FieldID, id), + sqlgraph.To(role.Table, role.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.RoleTable, rolepermission.RoleColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryPermission queries the permission edge of a RolePermission. +func (c *RolePermissionClient) QueryPermission(_m *RolePermission) *PermissionQuery { + query := (&PermissionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(rolepermission.Table, rolepermission.FieldID, id), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.PermissionTable, rolepermission.PermissionColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *RolePermissionClient) Hooks() []Hook { + return c.hooks.RolePermission +} + +// Interceptors returns the client interceptors. +func (c *RolePermissionClient) Interceptors() []Interceptor { + return c.inters.RolePermission +} + +func (c *RolePermissionClient) mutate(ctx context.Context, m *RolePermissionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&RolePermissionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&RolePermissionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&RolePermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&RolePermissionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown RolePermission mutation op: %q", m.Op()) + } +} + +// UserClient is a client for the User schema. +type UserClient struct { + config +} + +// NewUserClient returns a client for the User from the given config. +func NewUserClient(c config) *UserClient { + return &UserClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`. +func (c *UserClient) Use(hooks ...Hook) { + c.hooks.User = append(c.hooks.User, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`. +func (c *UserClient) Intercept(interceptors ...Interceptor) { + c.inters.User = append(c.inters.User, interceptors...) +} + +// Create returns a builder for creating a User entity. +func (c *UserClient) Create() *UserCreate { + mutation := newUserMutation(c.config, OpCreate) + return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of User entities. +func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { + return &UserCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for User. +func (c *UserClient) Update() *UserUpdate { + mutation := newUserMutation(c.config, OpUpdate) + return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUser(_m)) + return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserClient) UpdateOneID(id int64) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id)) + return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for User. +func (c *UserClient) Delete() *UserDelete { + mutation := newUserMutation(c.config, OpDelete) + return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserClient) DeleteOneID(id int64) *UserDeleteOne { + builder := c.Delete().Where(user.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserDeleteOne{builder} +} + +// Query returns a query builder for User. +func (c *UserClient) Query() *UserQuery { + return &UserQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUser}, + inters: c.Interceptors(), + } +} + +// Get returns a User entity by its id. +func (c *UserClient) Get(ctx context.Context, id int64) (*User, error) { + return c.Query().Where(user.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserClient) GetX(ctx context.Context, id int64) *User { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryRoles queries the roles edge of a User. +func (c *UserClient) QueryRoles(_m *User) *RoleQuery { + query := (&RoleClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(role.Table, role.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, user.RolesTable, user.RolesPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryUserRoles queries the user_roles edge of a User. +func (c *UserClient) QueryUserRoles(_m *User) *UserRoleQuery { + query := (&UserRoleClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, id), + sqlgraph.To(userrole.Table, userrole.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, user.UserRolesTable, user.UserRolesColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *UserClient) Hooks() []Hook { + return c.hooks.User +} + +// Interceptors returns the client interceptors. +func (c *UserClient) Interceptors() []Interceptor { + return c.inters.User +} + +func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op()) + } +} + +// UserRoleClient is a client for the UserRole schema. +type UserRoleClient struct { + config +} + +// NewUserRoleClient returns a client for the UserRole from the given config. +func NewUserRoleClient(c config) *UserRoleClient { + return &UserRoleClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `userrole.Hooks(f(g(h())))`. +func (c *UserRoleClient) Use(hooks ...Hook) { + c.hooks.UserRole = append(c.hooks.UserRole, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `userrole.Intercept(f(g(h())))`. +func (c *UserRoleClient) Intercept(interceptors ...Interceptor) { + c.inters.UserRole = append(c.inters.UserRole, interceptors...) +} + +// Create returns a builder for creating a UserRole entity. +func (c *UserRoleClient) Create() *UserRoleCreate { + mutation := newUserRoleMutation(c.config, OpCreate) + return &UserRoleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of UserRole entities. +func (c *UserRoleClient) CreateBulk(builders ...*UserRoleCreate) *UserRoleCreateBulk { + return &UserRoleCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *UserRoleClient) MapCreateBulk(slice any, setFunc func(*UserRoleCreate, int)) *UserRoleCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &UserRoleCreateBulk{err: fmt.Errorf("calling to UserRoleClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*UserRoleCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &UserRoleCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for UserRole. +func (c *UserRoleClient) Update() *UserRoleUpdate { + mutation := newUserRoleMutation(c.config, OpUpdate) + return &UserRoleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserRoleClient) UpdateOne(_m *UserRole) *UserRoleUpdateOne { + mutation := newUserRoleMutation(c.config, OpUpdateOne, withUserRole(_m)) + return &UserRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserRoleClient) UpdateOneID(id int) *UserRoleUpdateOne { + mutation := newUserRoleMutation(c.config, OpUpdateOne, withUserRoleID(id)) + return &UserRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for UserRole. +func (c *UserRoleClient) Delete() *UserRoleDelete { + mutation := newUserRoleMutation(c.config, OpDelete) + return &UserRoleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserRoleClient) DeleteOne(_m *UserRole) *UserRoleDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *UserRoleClient) DeleteOneID(id int) *UserRoleDeleteOne { + builder := c.Delete().Where(userrole.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserRoleDeleteOne{builder} +} + +// Query returns a query builder for UserRole. +func (c *UserRoleClient) Query() *UserRoleQuery { + return &UserRoleQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeUserRole}, + inters: c.Interceptors(), + } +} + +// Get returns a UserRole entity by its id. +func (c *UserRoleClient) Get(ctx context.Context, id int) (*UserRole, error) { + return c.Query().Where(userrole.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserRoleClient) GetX(ctx context.Context, id int) *UserRole { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryUser queries the user edge of a UserRole. +func (c *UserRoleClient) QueryUser(_m *UserRole) *UserQuery { + query := (&UserClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(userrole.Table, userrole.FieldID, id), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, userrole.UserTable, userrole.UserColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryRole queries the role edge of a UserRole. +func (c *UserRoleClient) QueryRole(_m *UserRole) *RoleQuery { + query := (&RoleClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(userrole.Table, userrole.FieldID, id), + sqlgraph.To(role.Table, role.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, userrole.RoleTable, userrole.RoleColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *UserRoleClient) Hooks() []Hook { + return c.hooks.UserRole +} + +// Interceptors returns the client interceptors. +func (c *UserRoleClient) Interceptors() []Interceptor { + return c.inters.UserRole +} + +func (c *UserRoleClient) mutate(ctx context.Context, m *UserRoleMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&UserRoleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&UserRoleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&UserRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&UserRoleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown UserRole mutation op: %q", m.Op()) + } +} + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + Permission, PermissionResource, Resource, Role, RolePermission, User, + UserRole []ent.Hook + } + inters struct { + Permission, PermissionResource, Resource, Role, RolePermission, User, + UserRole []ent.Interceptor + } +) diff --git a/internal/features/system/data/ent/crud.go b/internal/features/system/data/ent/crud.go new file mode 100644 index 00000000..1aa9b3b5 --- /dev/null +++ b/internal/features/system/data/ent/crud.go @@ -0,0 +1,3 @@ +// Code generated by ent, DO NOT EDIT. + +package ent diff --git a/internal/features/system/data/ent/database.go b/internal/features/system/data/ent/database.go new file mode 100644 index 00000000..edbfaf14 --- /dev/null +++ b/internal/features/system/data/ent/database.go @@ -0,0 +1,149 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +/* Additional dependencies injected to config. */ + +import ( + "context" + "fmt" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/schema" + "github.com/origadmin/runtime/interfaces/storage/database" +) + +// Database is the client that holds all ent builders. +type Database struct { + client *Client +} + +// NewDatabase creates a new database configured with the given options. +func NewDatabase(opts ...Option) *Database { + client := NewClient(opts...) + return &Database{client: client} +} + +// NewDatabase creates a new database configured with the given options. +func NewDatabaseWithClient(client *Client, opts ...Option) *Database { + if client == nil { + client = NewClient(opts...) + } + return &Database{client: client} +} + +func (db *Database) clientDriver(ctx context.Context) dialect.Driver { + tx := TxFromContext(ctx) + c := db.client + if tx != nil { + c = tx.Client() + } + return c.driver +} + +// Tx runs the given function f within a transaction. +func (db *Database) Tx(ctx context.Context, fn func(context.Context) error) error { + tx := TxFromContext(ctx) + if tx != nil { + return fn(ctx) + } + + return db.InTx(ctx, func(tx database.Tx) error { + txv, ok := tx.(*Tx) + if !ok { + return fmt.Errorf("ent: expected tx context") + } + return fn(NewTxContext(ctx, txv)) + }) +} + +// InTx runs the given function f within a transaction. +func (db *Database) InTx(ctx context.Context, fn func(tx database.Tx) error) error { + tx := TxFromContext(ctx) + if tx != nil { + return fn(tx) + } + tx, err := db.client.Tx(ctx) + if err != nil { + return fmt.Errorf("starting transaction: %w", err) + } + if err = fn(tx); err != nil { + if txerr := tx.Rollback(); txerr != nil { + return fmt.Errorf("rolling back transaction: %v (original error: %w)", txerr, err) + } + return err + } + if err := tx.Commit(); err != nil { + return fmt.Errorf("committing transaction: %w", err) + } + return nil +} + +// Client returns the client that holds all ent builders. +func (db *Database) Client(ctx context.Context) *Client { + tx := TxFromContext(ctx) + if tx != nil { + return tx.Client() + } + return db.client +} + +// Exec executes a query that doesn't return rows. For example, in SQL, INSERT or UPDATE. +func (db *Database) Exec(ctx context.Context, query string, args ...interface{}) (*sql.Result, error) { + var res sql.Result + err := db.clientDriver(ctx).Exec(ctx, query, args, &res) + if err != nil { + return nil, err + } + return &res, nil +} + +// Query executes a query that returns rows, typically a SELECT in SQL. +func (db *Database) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) { + var rows sql.Rows + err := db.clientDriver(ctx).Query(ctx, query, args, &rows) + if err != nil { + return nil, err + } + return &rows, nil +} + +// Permission is the client for interacting with the Permission builders. +func (db *Database) Permission(ctx context.Context) *PermissionClient { + return db.Client(ctx).Permission +} + +// PermissionResource is the client for interacting with the PermissionResource builders. +func (db *Database) PermissionResource(ctx context.Context) *PermissionResourceClient { + return db.Client(ctx).PermissionResource +} + +// Resource is the client for interacting with the Resource builders. +func (db *Database) Resource(ctx context.Context) *ResourceClient { + return db.Client(ctx).Resource +} + +// Role is the client for interacting with the Role builders. +func (db *Database) Role(ctx context.Context) *RoleClient { + return db.Client(ctx).Role +} + +// RolePermission is the client for interacting with the RolePermission builders. +func (db *Database) RolePermission(ctx context.Context) *RolePermissionClient { + return db.Client(ctx).RolePermission +} + +// User is the client for interacting with the User builders. +func (db *Database) User(ctx context.Context) *UserClient { + return db.Client(ctx).User +} + +// UserRole is the client for interacting with the UserRole builders. +func (db *Database) UserRole(ctx context.Context) *UserRoleClient { + return db.Client(ctx).UserRole +} + +func (db *Database) Migration(ctx context.Context, opts ...schema.MigrateOption) error { + return db.Client(ctx).Schema.Create(ctx, opts...) +} diff --git a/internal/features/system/data/ent/ent.go b/internal/features/system/data/ent/ent.go new file mode 100644 index 00000000..3d2a7418 --- /dev/null +++ b/internal/features/system/data/ent/ent.go @@ -0,0 +1,620 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + "reflect" + "sync" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ent aliases to avoid import conflicts in user's code. +type ( + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + QueryContext = ent.QueryContext + Querier = ent.Querier + QuerierFunc = ent.QuerierFunc + Interceptor = ent.Interceptor + InterceptFunc = ent.InterceptFunc + Traverser = ent.Traverser + TraverseFunc = ent.TraverseFunc + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc +) + +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} + +// OrderFunc applies an ordering on the sql selector. +// Deprecated: Use Asc/Desc functions or the package builders instead. +type OrderFunc func(*sql.Selector) + +var ( + initCheck sync.Once + columnCheck sql.ColumnCheck +) + +// checkColumn checks if the column exists in the given table. +func checkColumn(t, c string) error { + initCheck.Do(func() { + columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ + permission.Table: permission.ValidColumn, + permissionresource.Table: permissionresource.ValidColumn, + resource.Table: resource.ValidColumn, + role.Table: role.ValidColumn, + rolepermission.Table: rolepermission.ValidColumn, + user.Table: user.ValidColumn, + userrole.Table: userrole.ValidColumn, + }) + }) + return columnCheck(t, c) +} + +// Asc applies the given fields in ASC order. +func Asc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Asc(s.C(f))) + } + } +} + +// Desc applies the given fields in DESC order. +func Desc(fields ...string) func(*sql.Selector) { + return func(s *sql.Selector) { + for _, f := range fields { + if err := checkColumn(s.TableName(), f); err != nil { + s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) + } + s.OrderBy(sql.Desc(s.C(f))) + } + } +} + +// AggregateFunc applies an aggregation step on the group-by traversal/selector. +type AggregateFunc func(*sql.Selector) string + +// As is a pseudo aggregation function for renaming another other functions with custom names. For example: +// +// GroupBy(field1, field2). +// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). +// Scan(ctx, &v) +func As(fn AggregateFunc, end string) AggregateFunc { + return func(s *sql.Selector) string { + return sql.As(fn(s), end) + } +} + +// Count applies the "count" aggregation function on each group. +func Count() AggregateFunc { + return func(s *sql.Selector) string { + return sql.Count("*") + } +} + +// Max applies the "max" aggregation function on the given field of each group. +func Max(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Max(s.C(field)) + } +} + +// Mean applies the "mean" aggregation function on the given field of each group. +func Mean(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Avg(s.C(field)) + } +} + +// Min applies the "min" aggregation function on the given field of each group. +func Min(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Min(s.C(field)) + } +} + +// Sum applies the "sum" aggregation function on the given field of each group. +func Sum(field string) AggregateFunc { + return func(s *sql.Selector) string { + if err := checkColumn(s.TableName(), field); err != nil { + s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) + return "" + } + return sql.Sum(s.C(field)) + } +} + +// ValidationError returns when validating a field or edge fails. +type ValidationError struct { + Name string // Field or edge name. + err error +} + +// Error implements the error interface. +func (e *ValidationError) Error() string { + return e.err.Error() +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ValidationError) Unwrap() error { + return e.err +} + +// IsValidationError returns a boolean indicating whether the error is a validation error. +func IsValidationError(err error) bool { + if err == nil { + return false + } + var e *ValidationError + return errors.As(err, &e) +} + +// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. +type NotFoundError struct { + label string +} + +// Error implements the error interface. +func (e *NotFoundError) Error() string { + return "ent: " + e.label + " not found" +} + +// IsNotFound returns a boolean indicating whether the error is a not found error. +func IsNotFound(err error) bool { + if err == nil { + return false + } + var e *NotFoundError + return errors.As(err, &e) +} + +// MaskNotFound masks not found error. +func MaskNotFound(err error) error { + if IsNotFound(err) { + return nil + } + return err +} + +// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. +type NotSingularError struct { + label string +} + +// Error implements the error interface. +func (e *NotSingularError) Error() string { + return "ent: " + e.label + " not singular" +} + +// IsNotSingular returns a boolean indicating whether the error is a not singular error. +func IsNotSingular(err error) bool { + if err == nil { + return false + } + var e *NotSingularError + return errors.As(err, &e) +} + +// NotLoadedError returns when trying to get a node that was not loaded by the query. +type NotLoadedError struct { + edge string +} + +// Error implements the error interface. +func (e *NotLoadedError) Error() string { + return "ent: " + e.edge + " edge was not loaded" +} + +// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. +func IsNotLoaded(err error) bool { + if err == nil { + return false + } + var e *NotLoadedError + return errors.As(err, &e) +} + +// ConstraintError returns when trying to create/update one or more entities and +// one or more of their constraints failed. For example, violation of edge or +// field uniqueness. +type ConstraintError struct { + msg string + wrap error +} + +// Error implements the error interface. +func (e ConstraintError) Error() string { + return "ent: constraint failed: " + e.msg +} + +// Unwrap implements the errors.Wrapper interface. +func (e *ConstraintError) Unwrap() error { + return e.wrap +} + +// IsConstraintError returns a boolean indicating whether the error is a constraint failure. +func IsConstraintError(err error) bool { + if err == nil { + return false + } + var e *ConstraintError + return errors.As(err, &e) +} + +// selector embedded by the different Select/GroupBy builders. +type selector struct { + label string + flds *[]string + fns []AggregateFunc + scan func(context.Context, any) error +} + +// ScanX is like Scan, but panics if an error occurs. +func (s *selector) ScanX(ctx context.Context, v any) { + if err := s.scan(ctx, v); err != nil { + panic(err) + } +} + +// Strings returns list of strings from a selector. It is only allowed when selecting one field. +func (s *selector) Strings(ctx context.Context) ([]string, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") + } + var v []string + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// StringsX is like Strings, but panics if an error occurs. +func (s *selector) StringsX(ctx context.Context) []string { + v, err := s.Strings(ctx) + if err != nil { + panic(err) + } + return v +} + +// String returns a single string from a selector. It is only allowed when selecting one field. +func (s *selector) String(ctx context.Context) (_ string, err error) { + var v []string + if v, err = s.Strings(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) + } + return +} + +// StringX is like String, but panics if an error occurs. +func (s *selector) StringX(ctx context.Context) string { + v, err := s.String(ctx) + if err != nil { + panic(err) + } + return v +} + +// Ints returns list of ints from a selector. It is only allowed when selecting one field. +func (s *selector) Ints(ctx context.Context) ([]int, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") + } + var v []int + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// IntsX is like Ints, but panics if an error occurs. +func (s *selector) IntsX(ctx context.Context) []int { + v, err := s.Ints(ctx) + if err != nil { + panic(err) + } + return v +} + +// Int returns a single int from a selector. It is only allowed when selecting one field. +func (s *selector) Int(ctx context.Context) (_ int, err error) { + var v []int + if v, err = s.Ints(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) + } + return +} + +// IntX is like Int, but panics if an error occurs. +func (s *selector) IntX(ctx context.Context) int { + v, err := s.Int(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. +func (s *selector) Float64s(ctx context.Context) ([]float64, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") + } + var v []float64 + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// Float64sX is like Float64s, but panics if an error occurs. +func (s *selector) Float64sX(ctx context.Context) []float64 { + v, err := s.Float64s(ctx) + if err != nil { + panic(err) + } + return v +} + +// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. +func (s *selector) Float64(ctx context.Context) (_ float64, err error) { + var v []float64 + if v, err = s.Float64s(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) + } + return +} + +// Float64X is like Float64, but panics if an error occurs. +func (s *selector) Float64X(ctx context.Context) float64 { + v, err := s.Float64(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bools returns list of bools from a selector. It is only allowed when selecting one field. +func (s *selector) Bools(ctx context.Context) ([]bool, error) { + if len(*s.flds) > 1 { + return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") + } + var v []bool + if err := s.scan(ctx, &v); err != nil { + return nil, err + } + return v, nil +} + +// BoolsX is like Bools, but panics if an error occurs. +func (s *selector) BoolsX(ctx context.Context) []bool { + v, err := s.Bools(ctx) + if err != nil { + panic(err) + } + return v +} + +// Bool returns a single bool from a selector. It is only allowed when selecting one field. +func (s *selector) Bool(ctx context.Context) (_ bool, err error) { + var v []bool + if v, err = s.Bools(ctx); err != nil { + return + } + switch len(v) { + case 1: + return v[0], nil + case 0: + err = &NotFoundError{s.label} + default: + err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) + } + return +} + +// BoolX is like Bool, but panics if an error occurs. +func (s *selector) BoolX(ctx context.Context) bool { + v, err := s.Bool(ctx) + if err != nil { + panic(err) + } + return v +} + +// withHooks invokes the builder operation with the given hooks, if any. +func withHooks[V Value, M any, PM interface { + *M + Mutation +}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { + if len(hooks) == 0 { + return exec(ctx) + } + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutationT, ok := any(m).(PM) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + // Set the mutation to the builder. + *mutation = *mutationT + return exec(ctx) + }) + for i := len(hooks) - 1; i >= 0; i-- { + if hooks[i] == nil { + return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = hooks[i](mut) + } + v, err := mut.Mutate(ctx, mutation) + if err != nil { + return value, err + } + nv, ok := v.(V) + if !ok { + return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) + } + return nv, nil +} + +// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. +func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { + if ent.QueryFromContext(ctx) == nil { + qc.Op = op + ctx = ent.NewQueryContext(ctx, qc) + } + return ctx +} + +func querierAll[V Value, Q interface { + sqlAll(context.Context, ...queryHook) (V, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlAll(ctx) + }) +} + +func querierCount[Q interface { + sqlCount(context.Context) (int, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlCount(ctx) + }) +} + +func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + rv, err := qr.Query(ctx, q) + if err != nil { + return v, err + } + vt, ok := rv.(V) + if !ok { + return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) + } + return vt, nil +} + +func scanWithInterceptors[Q1 ent.Query, Q2 interface { + sqlScan(context.Context, Q1, any) error +}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { + rv := reflect.ValueOf(v) + var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q1) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { + return nil, err + } + if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { + return rv.Elem().Interface(), nil + } + return v, nil + }) + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + vv, err := qr.Query(ctx, rootQuery) + if err != nil { + return err + } + switch rv2 := reflect.ValueOf(vv); { + case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: + case rv.Type() == rv2.Type(): + rv.Elem().Set(rv2.Elem()) + case rv.Elem().Type() == rv2.Type(): + rv.Elem().Set(rv2) + } + return nil +} + +// queryHook describes an internal hook for the different sqlAll methods. +type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/internal/features/system/data/ent/enttest/enttest.go b/internal/features/system/data/ent/enttest/enttest.go new file mode 100644 index 00000000..13cc1fd1 --- /dev/null +++ b/internal/features/system/data/ent/enttest/enttest.go @@ -0,0 +1,85 @@ +// Code generated by ent, DO NOT EDIT. + +package enttest + +import ( + "context" + + "origadmin/application/admin/internal/features/system/data/ent" + // required by schema hooks. + _ "origadmin/application/admin/internal/features/system/data/ent/runtime" + + "origadmin/application/admin/internal/features/system/data/ent/migrate" + + "entgo.io/ent/dialect/sql/schema" +) + +type ( + // TestingT is the interface that is shared between + // testing.T and testing.B and used by enttest. + TestingT interface { + FailNow() + Error(...any) + } + + // Option configures client creation. + Option func(*options) + + options struct { + opts []ent.Option + migrateOpts []schema.MigrateOption + } +) + +// WithOptions forwards options to client creation. +func WithOptions(opts ...ent.Option) Option { + return func(o *options) { + o.opts = append(o.opts, opts...) + } +} + +// WithMigrateOptions forwards options to auto migration. +func WithMigrateOptions(opts ...schema.MigrateOption) Option { + return func(o *options) { + o.migrateOpts = append(o.migrateOpts, opts...) + } +} + +func newOptions(opts []Option) *options { + o := &options{} + for _, opt := range opts { + opt(o) + } + return o +} + +// Open calls ent.Open and auto-run migration. +func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { + o := newOptions(opts) + c, err := ent.Open(driverName, dataSourceName, o.opts...) + if err != nil { + t.Error(err) + t.FailNow() + } + migrateSchema(t, c, o) + return c +} + +// NewClient calls ent.NewClient and auto-run migration. +func NewClient(t TestingT, opts ...Option) *ent.Client { + o := newOptions(opts) + c := ent.NewClient(o.opts...) + migrateSchema(t, c, o) + return c +} +func migrateSchema(t TestingT, c *ent.Client, o *options) { + tables, err := schema.CopyTables(migrate.Tables) + if err != nil { + t.Error(err) + t.FailNow() + } + if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { + t.Error(err) + t.FailNow() + } +} diff --git a/internal/features/system/data/ent/generate.go b/internal/features/system/data/ent/generate.go new file mode 100644 index 00000000..44a6c363 --- /dev/null +++ b/internal/features/system/data/ent/generate.go @@ -0,0 +1,8 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package entity is the data access object for SYS. +package ent + +//go:generate go run entgo.io/ent/cmd/ent generate --template ./template --feature intercept --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema diff --git a/internal/features/system/data/ent/hook/hook.go b/internal/features/system/data/ent/hook/hook.go new file mode 100644 index 00000000..b1102f59 --- /dev/null +++ b/internal/features/system/data/ent/hook/hook.go @@ -0,0 +1,270 @@ +// Code generated by ent, DO NOT EDIT. + +package hook + +import ( + "context" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent" +) + +// The PermissionFunc type is an adapter to allow the use of ordinary +// function as Permission mutator. +type PermissionFunc func(context.Context, *ent.PermissionMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f PermissionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.PermissionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PermissionMutation", m) +} + +// The PermissionResourceFunc type is an adapter to allow the use of ordinary +// function as PermissionResource mutator. +type PermissionResourceFunc func(context.Context, *ent.PermissionResourceMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f PermissionResourceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.PermissionResourceMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PermissionResourceMutation", m) +} + +// The ResourceFunc type is an adapter to allow the use of ordinary +// function as Resource mutator. +type ResourceFunc func(context.Context, *ent.ResourceMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ResourceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ResourceMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ResourceMutation", m) +} + +// The RoleFunc type is an adapter to allow the use of ordinary +// function as Role mutator. +type RoleFunc func(context.Context, *ent.RoleMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f RoleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.RoleMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RoleMutation", m) +} + +// The RolePermissionFunc type is an adapter to allow the use of ordinary +// function as RolePermission mutator. +type RolePermissionFunc func(context.Context, *ent.RolePermissionMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f RolePermissionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.RolePermissionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RolePermissionMutation", m) +} + +// The UserFunc type is an adapter to allow the use of ordinary +// function as User mutator. +type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m) +} + +// The UserRoleFunc type is an adapter to allow the use of ordinary +// function as UserRole mutator. +type UserRoleFunc func(context.Context, *ent.UserRoleMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f UserRoleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.UserRoleMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserRoleMutation", m) +} + +// Condition is a hook condition function. +type Condition func(context.Context, ent.Mutation) bool + +// And groups conditions with the AND operator. +func And(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if !first(ctx, m) || !second(ctx, m) { + return false + } + for _, cond := range rest { + if !cond(ctx, m) { + return false + } + } + return true + } +} + +// Or groups conditions with the OR operator. +func Or(first, second Condition, rest ...Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + if first(ctx, m) || second(ctx, m) { + return true + } + for _, cond := range rest { + if cond(ctx, m) { + return true + } + } + return false + } +} + +// Not negates a given condition. +func Not(cond Condition) Condition { + return func(ctx context.Context, m ent.Mutation) bool { + return !cond(ctx, m) + } +} + +// HasOp is a condition testing mutation operation. +func HasOp(op ent.Op) Condition { + return func(_ context.Context, m ent.Mutation) bool { + return m.Op().Is(op) + } +} + +// HasAddedFields is a condition validating `.AddedField` on fields. +func HasAddedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.AddedField(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.AddedField(field); !exists { + return false + } + } + return true + } +} + +// HasClearedFields is a condition validating `.FieldCleared` on fields. +func HasClearedFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if exists := m.FieldCleared(field); !exists { + return false + } + for _, field := range fields { + if exists := m.FieldCleared(field); !exists { + return false + } + } + return true + } +} + +// HasFields is a condition validating `.Field` on fields. +func HasFields(field string, fields ...string) Condition { + return func(_ context.Context, m ent.Mutation) bool { + if _, exists := m.Field(field); !exists { + return false + } + for _, field := range fields { + if _, exists := m.Field(field); !exists { + return false + } + } + return true + } +} + +// If executes the given hook under condition. +// +// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) +func If(hk ent.Hook, cond Condition) ent.Hook { + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if cond(ctx, m) { + return hk(next).Mutate(ctx, m) + } + return next.Mutate(ctx, m) + }) + } +} + +// On executes the given hook only for the given operation. +// +// hook.On(Log, ent.Delete|ent.Create) +func On(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, HasOp(op)) +} + +// Unless skips the given hook only for the given operation. +// +// hook.Unless(Log, ent.Update|ent.UpdateOne) +func Unless(hk ent.Hook, op ent.Op) ent.Hook { + return If(hk, Not(HasOp(op))) +} + +// FixedError is a hook returning a fixed error. +func FixedError(err error) ent.Hook { + return func(ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { + return nil, err + }) + } +} + +// Reject returns a hook that rejects all operations that match op. +// +// func (T) Hooks() []ent.Hook { +// return []ent.Hook{ +// Reject(ent.Delete|ent.Update), +// } +// } +func Reject(op ent.Op) ent.Hook { + hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) + return On(hk, op) +} + +// Chain acts as a list of hooks and is effectively immutable. +// Once created, it will always hold the same set of hooks in the same order. +type Chain struct { + hooks []ent.Hook +} + +// NewChain creates a new chain of hooks. +func NewChain(hooks ...ent.Hook) Chain { + return Chain{append([]ent.Hook(nil), hooks...)} +} + +// Hook chains the list of hooks and returns the final hook. +func (c Chain) Hook() ent.Hook { + return func(mutator ent.Mutator) ent.Mutator { + for i := len(c.hooks) - 1; i >= 0; i-- { + mutator = c.hooks[i](mutator) + } + return mutator + } +} + +// Append extends a chain, adding the specified hook +// as the last ones in the mutation flow. +func (c Chain) Append(hooks ...ent.Hook) Chain { + newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) + newHooks = append(newHooks, c.hooks...) + newHooks = append(newHooks, hooks...) + return Chain{newHooks} +} + +// Extend extends a chain, adding the specified chain +// as the last ones in the mutation flow. +func (c Chain) Extend(chain Chain) Chain { + return c.Append(chain.hooks...) +} diff --git a/internal/features/system/data/ent/intercept/intercept.go b/internal/features/system/data/ent/intercept/intercept.go new file mode 100644 index 00000000..a1a0b914 --- /dev/null +++ b/internal/features/system/data/ent/intercept/intercept.go @@ -0,0 +1,330 @@ +// Code generated by ent, DO NOT EDIT. + +package intercept + +import ( + "context" + "fmt" + + "origadmin/application/admin/internal/features/system/data/ent" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + + "entgo.io/ent/dialect/sql" +) + +// The Query interface represents an operation that queries a graph. +// By using this interface, users can write generic code that manipulates +// query builders of different types. +type Query interface { + // Type returns the string representation of the query type. + Type() string + // Limit the number of records to be returned by this query. + Limit(int) + // Offset to start from. + Offset(int) + // Unique configures the query builder to filter duplicate records. + Unique(bool) + // Order specifies how the records should be ordered. + Order(...func(*sql.Selector)) + // WhereP appends storage-level predicates to the query builder. Using this method, users + // can use type-assertion to append predicates that do not depend on any generated package. + WhereP(...func(*sql.Selector)) +} + +// The Func type is an adapter that allows ordinary functions to be used as interceptors. +// Unlike traversal functions, interceptors are skipped during graph traversals. Note that the +// implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc. +type Func func(context.Context, Query) error + +// Intercept calls f(ctx, q) and then applied the next Querier. +func (f Func) Intercept(next ent.Querier) ent.Querier { + return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) { + query, err := NewQuery(q) + if err != nil { + return nil, err + } + if err := f(ctx, query); err != nil { + return nil, err + } + return next.Query(ctx, q) + }) +} + +// The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser. +// If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f. +type TraverseFunc func(context.Context, Query) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error { + query, err := NewQuery(q) + if err != nil { + return err + } + return f(ctx, query) +} + +// The PermissionFunc type is an adapter to allow the use of ordinary function as a Querier. +type PermissionFunc func(context.Context, *ent.PermissionQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f PermissionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.PermissionQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.PermissionQuery", q) +} + +// The TraversePermission type is an adapter to allow the use of ordinary function as Traverser. +type TraversePermission func(context.Context, *ent.PermissionQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraversePermission) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraversePermission) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.PermissionQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.PermissionQuery", q) +} + +// The PermissionResourceFunc type is an adapter to allow the use of ordinary function as a Querier. +type PermissionResourceFunc func(context.Context, *ent.PermissionResourceQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f PermissionResourceFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.PermissionResourceQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.PermissionResourceQuery", q) +} + +// The TraversePermissionResource type is an adapter to allow the use of ordinary function as Traverser. +type TraversePermissionResource func(context.Context, *ent.PermissionResourceQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraversePermissionResource) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraversePermissionResource) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.PermissionResourceQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.PermissionResourceQuery", q) +} + +// The ResourceFunc type is an adapter to allow the use of ordinary function as a Querier. +type ResourceFunc func(context.Context, *ent.ResourceQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ResourceFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ResourceQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ResourceQuery", q) +} + +// The TraverseResource type is an adapter to allow the use of ordinary function as Traverser. +type TraverseResource func(context.Context, *ent.ResourceQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseResource) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseResource) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ResourceQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ResourceQuery", q) +} + +// The RoleFunc type is an adapter to allow the use of ordinary function as a Querier. +type RoleFunc func(context.Context, *ent.RoleQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f RoleFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.RoleQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.RoleQuery", q) +} + +// The TraverseRole type is an adapter to allow the use of ordinary function as Traverser. +type TraverseRole func(context.Context, *ent.RoleQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseRole) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseRole) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.RoleQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.RoleQuery", q) +} + +// The RolePermissionFunc type is an adapter to allow the use of ordinary function as a Querier. +type RolePermissionFunc func(context.Context, *ent.RolePermissionQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f RolePermissionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.RolePermissionQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.RolePermissionQuery", q) +} + +// The TraverseRolePermission type is an adapter to allow the use of ordinary function as Traverser. +type TraverseRolePermission func(context.Context, *ent.RolePermissionQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseRolePermission) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseRolePermission) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.RolePermissionQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.RolePermissionQuery", q) +} + +// The UserFunc type is an adapter to allow the use of ordinary function as a Querier. +type UserFunc func(context.Context, *ent.UserQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f UserFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.UserQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserQuery", q) +} + +// The TraverseUser type is an adapter to allow the use of ordinary function as Traverser. +type TraverseUser func(context.Context, *ent.UserQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseUser) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseUser) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.UserQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.UserQuery", q) +} + +// The UserRoleFunc type is an adapter to allow the use of ordinary function as a Querier. +type UserRoleFunc func(context.Context, *ent.UserRoleQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f UserRoleFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.UserRoleQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserRoleQuery", q) +} + +// The TraverseUserRole type is an adapter to allow the use of ordinary function as Traverser. +type TraverseUserRole func(context.Context, *ent.UserRoleQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseUserRole) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseUserRole) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.UserRoleQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.UserRoleQuery", q) +} + +// NewQuery returns the generic Query interface for the given typed query. +func NewQuery(q ent.Query) (Query, error) { + switch q := q.(type) { + case *ent.PermissionQuery: + return &query[*ent.PermissionQuery, predicate.Permission, permission.OrderOption]{typ: ent.TypePermission, tq: q}, nil + case *ent.PermissionResourceQuery: + return &query[*ent.PermissionResourceQuery, predicate.PermissionResource, permissionresource.OrderOption]{typ: ent.TypePermissionResource, tq: q}, nil + case *ent.ResourceQuery: + return &query[*ent.ResourceQuery, predicate.Resource, resource.OrderOption]{typ: ent.TypeResource, tq: q}, nil + case *ent.RoleQuery: + return &query[*ent.RoleQuery, predicate.Role, role.OrderOption]{typ: ent.TypeRole, tq: q}, nil + case *ent.RolePermissionQuery: + return &query[*ent.RolePermissionQuery, predicate.RolePermission, rolepermission.OrderOption]{typ: ent.TypeRolePermission, tq: q}, nil + case *ent.UserQuery: + return &query[*ent.UserQuery, predicate.User, user.OrderOption]{typ: ent.TypeUser, tq: q}, nil + case *ent.UserRoleQuery: + return &query[*ent.UserRoleQuery, predicate.UserRole, userrole.OrderOption]{typ: ent.TypeUserRole, tq: q}, nil + default: + return nil, fmt.Errorf("unknown query type %T", q) + } +} + +type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct { + typ string + tq interface { + Limit(int) T + Offset(int) T + Unique(bool) T + Order(...R) T + Where(...P) T + } +} + +func (q query[T, P, R]) Type() string { + return q.typ +} + +func (q query[T, P, R]) Limit(limit int) { + q.tq.Limit(limit) +} + +func (q query[T, P, R]) Offset(offset int) { + q.tq.Offset(offset) +} + +func (q query[T, P, R]) Unique(unique bool) { + q.tq.Unique(unique) +} + +func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) { + rs := make([]R, len(orders)) + for i := range orders { + rs[i] = orders[i] + } + q.tq.Order(rs...) +} + +func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) { + p := make([]P, len(ps)) + for i := range ps { + p[i] = ps[i] + } + q.tq.Where(p...) +} diff --git a/internal/features/system/data/ent/migrate/migrate.go b/internal/features/system/data/ent/migrate/migrate.go new file mode 100644 index 00000000..d8d3bcb8 --- /dev/null +++ b/internal/features/system/data/ent/migrate/migrate.go @@ -0,0 +1,96 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "context" + "fmt" + "io" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql/schema" +) + +var ( + // WithGlobalUniqueID sets the universal ids options to the migration. + // If this option is enabled, ent migration will allocate a 1<<32 range + // for the ids of each entity (table). + // Note that this option cannot be applied on tables that already exist. + WithGlobalUniqueID = schema.WithGlobalUniqueID + // WithDropColumn sets the drop column option to the migration. + // If this option is enabled, ent migration will drop old columns + // that were used for both fields and edges. This defaults to false. + WithDropColumn = schema.WithDropColumn + // WithDropIndex sets the drop index option to the migration. + // If this option is enabled, ent migration will drop old indexes + // that were defined in the schema. This defaults to false. + // Note that unique constraints are defined using `UNIQUE INDEX`, + // and therefore, it's recommended to enable this option to get more + // flexibility in the schema changes. + WithDropIndex = schema.WithDropIndex + // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. + WithForeignKeys = schema.WithForeignKeys +) + +// Schema is the API for creating, migrating and dropping a schema. +type Schema struct { + drv dialect.Driver +} + +// NewSchema creates a new schema client. +func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } + +// Create creates all schema resources. +func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { + return Create(ctx, s, Tables, opts...) +} + +// Create creates all table resources using the given schema driver. +func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Create(ctx, tables...) +} + +// Diff compares the state read from a database connection or migration directory with +// the state defined by the Ent schema. Changes will be written to new migration files. +func Diff(ctx context.Context, url string, opts ...schema.MigrateOption) error { + return NamedDiff(ctx, url, "changes", opts...) +} + +// NamedDiff compares the state read from a database connection or migration directory with +// the state defined by the Ent schema. Changes will be written to new named migration files. +func NamedDiff(ctx context.Context, url, name string, opts ...schema.MigrateOption) error { + return schema.Diff(ctx, url, name, Tables, opts...) +} + +// Diff creates a migration file containing the statements to resolve the diff +// between the Ent schema and the connected database. +func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.Diff(ctx, Tables...) +} + +// NamedDiff creates a named migration file containing the statements to resolve the diff +// between the Ent schema and the connected database. +func (s *Schema) NamedDiff(ctx context.Context, name string, opts ...schema.MigrateOption) error { + migrate, err := schema.NewMigrate(s.drv, opts...) + if err != nil { + return fmt.Errorf("ent/migrate: %w", err) + } + return migrate.NamedDiff(ctx, name, Tables...) +} + +// WriteTo writes the schema changes to w instead of running them against the database. +// +// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { +// log.Fatal(err) +// } +func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { + return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) +} diff --git a/internal/features/system/data/ent/migrate/schema.go b/internal/features/system/data/ent/migrate/schema.go new file mode 100644 index 00000000..29bfd6cf --- /dev/null +++ b/internal/features/system/data/ent/migrate/schema.go @@ -0,0 +1,313 @@ +// Code generated by ent, DO NOT EDIT. + +package migrate + +import ( + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/dialect/sql/schema" + "entgo.io/ent/schema/field" +) + +var ( + // SysPermissionsColumns holds the columns for the "sys_permissions" table. + SysPermissionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString, Size: 64, Comment: "Name", Default: ""}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 64, Comment: "Keyword"}, + {Name: "description", Type: field.TypeString, Size: 1024, Comment: "Description", Default: ""}, + {Name: "data_scope", Type: field.TypeString, Comment: "Data scope", Default: "self"}, + {Name: "data_rules", Type: field.TypeJSON, Nullable: true, Comment: "Data rules"}, + {Name: "actions", Type: field.TypeEnum, Comment: "Actions", Enums: []string{"read", "write", "delete", "manage"}, Default: "read"}, + } + // SysPermissionsTable holds the schema information for the "sys_permissions" table. + SysPermissionsTable = &schema.Table{ + Name: "sys_permissions", + Comment: "Permission table", + Columns: SysPermissionsColumns, + PrimaryKey: []*schema.Column{SysPermissionsColumns[0]}, + } + // SysPermissionResourcesColumns holds the columns for the "sys_permission_resources" table. + SysPermissionResourcesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "permission_id", Type: field.TypeInt64}, + {Name: "resource_id", Type: field.TypeInt64}, + } + // SysPermissionResourcesTable holds the schema information for the "sys_permission_resources" table. + SysPermissionResourcesTable = &schema.Table{ + Name: "sys_permission_resources", + Comment: "Permission-Resource mapping table", + Columns: SysPermissionResourcesColumns, + PrimaryKey: []*schema.Column{SysPermissionResourcesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "sys_permission_resources_sys_permissions_permission", + Columns: []*schema.Column{SysPermissionResourcesColumns[1]}, + RefColumns: []*schema.Column{SysPermissionsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "sys_permission_resources_sys_resources_resource", + Columns: []*schema.Column{SysPermissionResourcesColumns[2]}, + RefColumns: []*schema.Column{SysResourcesColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "permissionresource_permission_id_resource_id", + Unique: true, + Columns: []*schema.Column{SysPermissionResourcesColumns[1], SysPermissionResourcesColumns[2]}, + }, + }, + } + // SysResourcesColumns holds the columns for the "sys_resources" table. + SysResourcesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, + {Name: "name", Type: field.TypeString, Size: 128, Comment: "Name", Default: ""}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 64, Comment: "Keyword"}, + {Name: "type", Type: field.TypeString, Size: 2, Comment: "Type", Default: "M"}, + {Name: "status", Type: field.TypeInt8, Comment: "Status", Default: 1}, + {Name: "path", Type: field.TypeString, Size: 256, Comment: "Path", Default: ""}, + {Name: "component", Type: field.TypeString, Size: 128, Comment: "Component", Default: ""}, + {Name: "icon", Type: field.TypeString, Size: 64, Comment: "Icon", Default: ""}, + {Name: "sequence", Type: field.TypeInt, Comment: "Sequence", Default: 0}, + {Name: "visible", Type: field.TypeBool, Comment: "Visible", Default: true}, + {Name: "level", Type: field.TypeInt8, Comment: "Level", Default: 0}, + {Name: "tree_path", Type: field.TypeString, Size: 256, Comment: "Tree path", Default: ""}, + {Name: "properties", Type: field.TypeJSON, Nullable: true, Comment: "Properties"}, + {Name: "description", Type: field.TypeString, Size: 1024, Comment: "Description", Default: ""}, + {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "Parent ID"}, + } + // SysResourcesTable holds the schema information for the "sys_resources" table. + SysResourcesTable = &schema.Table{ + Name: "sys_resources", + Comment: "Resource table", + Columns: SysResourcesColumns, + PrimaryKey: []*schema.Column{SysResourcesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "sys_resources_sys_resources_children", + Columns: []*schema.Column{SysResourcesColumns[16]}, + RefColumns: []*schema.Column{SysResourcesColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + Indexes: []*schema.Index{ + { + Name: "resource_parent_id", + Unique: false, + Columns: []*schema.Column{SysResourcesColumns[16]}, + }, + { + Name: "resource_level", + Unique: false, + Columns: []*schema.Column{SysResourcesColumns[12]}, + }, + }, + } + // SysRolesColumns holds the columns for the "sys_roles" table. + SysRolesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 32, Comment: "keyword of role (unique)"}, + {Name: "name", Type: field.TypeString, Size: 128, Comment: "Display name of role", Default: ""}, + {Name: "description", Type: field.TypeString, Size: 1024, Comment: "Details about role", Default: ""}, + {Name: "type", Type: field.TypeInt8, Comment: "Role type: 1 - System role 2 - User role 3 - Department role", Default: 2}, + {Name: "sequence", Type: field.TypeInt, Comment: "Sequence for sorting", Default: 0}, + {Name: "status", Type: field.TypeInt8, Comment: "status", Default: 1}, + } + // SysRolesTable holds the schema information for the "sys_roles" table. + SysRolesTable = &schema.Table{ + Name: "sys_roles", + Comment: "Role table", + Columns: SysRolesColumns, + PrimaryKey: []*schema.Column{SysRolesColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "role_keyword", + Unique: false, + Columns: []*schema.Column{SysRolesColumns[3]}, + }, + { + Name: "role_name", + Unique: false, + Columns: []*schema.Column{SysRolesColumns[4]}, + }, + { + Name: "role_sequence", + Unique: false, + Columns: []*schema.Column{SysRolesColumns[7]}, + }, + { + Name: "role_status", + Unique: false, + Columns: []*schema.Column{SysRolesColumns[8]}, + }, + }, + } + // SysRolePermissionsColumns holds the columns for the "sys_role_permissions" table. + SysRolePermissionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "role_id", Type: field.TypeInt64}, + {Name: "permission_id", Type: field.TypeInt64}, + } + // SysRolePermissionsTable holds the schema information for the "sys_role_permissions" table. + SysRolePermissionsTable = &schema.Table{ + Name: "sys_role_permissions", + Comment: "Role-Permission mapping table", + Columns: SysRolePermissionsColumns, + PrimaryKey: []*schema.Column{SysRolePermissionsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "sys_role_permissions_sys_roles_role", + Columns: []*schema.Column{SysRolePermissionsColumns[1]}, + RefColumns: []*schema.Column{SysRolesColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "sys_role_permissions_sys_permissions_permission", + Columns: []*schema.Column{SysRolePermissionsColumns[2]}, + RefColumns: []*schema.Column{SysPermissionsColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "rolepermission_role_id_permission_id", + Unique: true, + Columns: []*schema.Column{SysRolePermissionsColumns[1], SysRolePermissionsColumns[2]}, + }, + }, + } + // SysUsersColumns holds the columns for the "sys_users" table. + SysUsersColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, + {Name: "uuid", Type: field.TypeString, Unique: true, Size: 36, Comment: "UUID"}, + {Name: "allowed_ip", Type: field.TypeString, Comment: "Allowed IP", Default: "0.0.0.0"}, + {Name: "username", Type: field.TypeString, Unique: true, Size: 32, Comment: "login username of user"}, + {Name: "nickname", Type: field.TypeString, Size: 64, Comment: "Nickname display name of user", Default: ""}, + {Name: "avatar", Type: field.TypeString, Size: 256, Comment: "Avatar display avatar of user", Default: ""}, + {Name: "name", Type: field.TypeString, Size: 64, Comment: "Name of user", Default: ""}, + {Name: "gender", Type: field.TypeEnum, Comment: "Gender of user", Enums: []string{"male", "female", "unknown"}, Default: "unknown"}, + {Name: "password", Type: field.TypeString, Size: 256, Comment: "Encrypted password", Default: ""}, + {Name: "phone", Type: field.TypeString, Size: 32, Comment: "login phone number of user", Default: ""}, + {Name: "email", Type: field.TypeString, Size: 64, Comment: "login email of user", Default: ""}, + {Name: "department", Type: field.TypeString, Size: 64, Comment: "Department of user", Default: ""}, + {Name: "remark", Type: field.TypeString, Size: 1024, Comment: "Remark of user", Default: ""}, + {Name: "status", Type: field.TypeInt8, Comment: "status", Default: 1}, + {Name: "is_system", Type: field.TypeBool, Comment: "Whether the system is built-in", Default: false}, + {Name: "last_login_ip", Type: field.TypeString, Size: 32, Comment: "Last login IP", Default: ""}, + {Name: "last_login_time", Type: field.TypeTime, Nullable: true, Comment: "Last login time"}, + } + // SysUsersTable holds the schema information for the "sys_users" table. + SysUsersTable = &schema.Table{ + Name: "sys_users", + Comment: "User table", + Columns: SysUsersColumns, + PrimaryKey: []*schema.Column{SysUsersColumns[0]}, + Indexes: []*schema.Index{ + { + Name: "user_username", + Unique: false, + Columns: []*schema.Column{SysUsersColumns[5]}, + }, + { + Name: "user_phone", + Unique: false, + Columns: []*schema.Column{SysUsersColumns[11]}, + }, + { + Name: "user_email", + Unique: false, + Columns: []*schema.Column{SysUsersColumns[12]}, + }, + { + Name: "user_status", + Unique: false, + Columns: []*schema.Column{SysUsersColumns[15]}, + }, + }, + } + // SysUserRolesColumns holds the columns for the "sys_user_roles" table. + SysUserRolesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt, Increment: true}, + {Name: "user_id", Type: field.TypeInt64}, + {Name: "role_id", Type: field.TypeInt64}, + } + // SysUserRolesTable holds the schema information for the "sys_user_roles" table. + SysUserRolesTable = &schema.Table{ + Name: "sys_user_roles", + Comment: "User-Role mapping table", + Columns: SysUserRolesColumns, + PrimaryKey: []*schema.Column{SysUserRolesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "sys_user_roles_sys_users_user", + Columns: []*schema.Column{SysUserRolesColumns[1]}, + RefColumns: []*schema.Column{SysUsersColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "sys_user_roles_sys_roles_role", + Columns: []*schema.Column{SysUserRolesColumns[2]}, + RefColumns: []*schema.Column{SysRolesColumns[0]}, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "userrole_user_id_role_id", + Unique: true, + Columns: []*schema.Column{SysUserRolesColumns[1], SysUserRolesColumns[2]}, + }, + }, + } + // Tables holds all the tables in the schema. + Tables = []*schema.Table{ + SysPermissionsTable, + SysPermissionResourcesTable, + SysResourcesTable, + SysRolesTable, + SysRolePermissionsTable, + SysUsersTable, + SysUserRolesTable, + } +) + +func init() { + SysPermissionsTable.Annotation = &entsql.Annotation{ + Table: "sys_permissions", + } + SysPermissionResourcesTable.ForeignKeys[0].RefTable = SysPermissionsTable + SysPermissionResourcesTable.ForeignKeys[1].RefTable = SysResourcesTable + SysPermissionResourcesTable.Annotation = &entsql.Annotation{ + Table: "sys_permission_resources", + } + SysResourcesTable.ForeignKeys[0].RefTable = SysResourcesTable + SysResourcesTable.Annotation = &entsql.Annotation{ + Table: "sys_resources", + } + SysRolesTable.Annotation = &entsql.Annotation{ + Table: "sys_roles", + } + SysRolePermissionsTable.ForeignKeys[0].RefTable = SysRolesTable + SysRolePermissionsTable.ForeignKeys[1].RefTable = SysPermissionsTable + SysRolePermissionsTable.Annotation = &entsql.Annotation{ + Table: "sys_role_permissions", + } + SysUsersTable.Annotation = &entsql.Annotation{ + Table: "sys_users", + } + SysUserRolesTable.ForeignKeys[0].RefTable = SysUsersTable + SysUserRolesTable.ForeignKeys[1].RefTable = SysRolesTable + SysUserRolesTable.Annotation = &entsql.Annotation{ + Table: "sys_user_roles", + } +} diff --git a/internal/features/system/data/ent/mutation.go b/internal/features/system/data/ent/mutation.go new file mode 100644 index 00000000..779bb6d8 --- /dev/null +++ b/internal/features/system/data/ent/mutation.go @@ -0,0 +1,6791 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + "sync" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +const ( + // Operation types. + OpCreate = ent.OpCreate + OpDelete = ent.OpDelete + OpDeleteOne = ent.OpDeleteOne + OpUpdate = ent.OpUpdate + OpUpdateOne = ent.OpUpdateOne + + // Node types. + TypePermission = "Permission" + TypePermissionResource = "PermissionResource" + TypeResource = "Resource" + TypeRole = "Role" + TypeRolePermission = "RolePermission" + TypeUser = "User" + TypeUserRole = "UserRole" +) + +// PermissionMutation represents an operation that mutates the Permission nodes in the graph. +type PermissionMutation struct { + config + op Op + typ string + id *int64 + create_time *time.Time + update_time *time.Time + name *string + keyword *string + description *string + data_scope *string + data_rules *map[string]string + actions *permission.Actions + clearedFields map[string]struct{} + roles map[int64]struct{} + removedroles map[int64]struct{} + clearedroles bool + resources map[int64]struct{} + removedresources map[int64]struct{} + clearedresources bool + role_permissions map[int]struct{} + removedrole_permissions map[int]struct{} + clearedrole_permissions bool + permission_resources map[int]struct{} + removedpermission_resources map[int]struct{} + clearedpermission_resources bool + done bool + oldValue func(context.Context) (*Permission, error) + predicates []predicate.Permission +} + +var _ ent.Mutation = (*PermissionMutation)(nil) + +// permissionOption allows management of the mutation configuration using functional options. +type permissionOption func(*PermissionMutation) + +// newPermissionMutation creates new mutation for the Permission entity. +func newPermissionMutation(c config, op Op, opts ...permissionOption) *PermissionMutation { + m := &PermissionMutation{ + config: c, + op: op, + typ: TypePermission, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPermissionID sets the ID field of the mutation. +func withPermissionID(id int64) permissionOption { + return func(m *PermissionMutation) { + var ( + err error + once sync.Once + value *Permission + ) + m.oldValue = func(ctx context.Context) (*Permission, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Permission.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPermission sets the old Permission of the mutation. +func withPermission(node *Permission) permissionOption { + return func(m *PermissionMutation) { + m.oldValue = func(context.Context) (*Permission, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PermissionMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PermissionMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Permission entities. +func (m *PermissionMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PermissionMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PermissionMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Permission.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateTime sets the "create_time" field. +func (m *PermissionMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *PermissionMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Permission entity. +// If the Permission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *PermissionMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *PermissionMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *PermissionMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Permission entity. +// If the Permission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *PermissionMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetName sets the "name" field. +func (m *PermissionMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *PermissionMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Permission entity. +// If the Permission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *PermissionMutation) ResetName() { + m.name = nil +} + +// SetKeyword sets the "keyword" field. +func (m *PermissionMutation) SetKeyword(s string) { + m.keyword = &s +} + +// Keyword returns the value of the "keyword" field in the mutation. +func (m *PermissionMutation) Keyword() (r string, exists bool) { + v := m.keyword + if v == nil { + return + } + return *v, true +} + +// OldKeyword returns the old "keyword" field's value of the Permission entity. +// If the Permission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionMutation) OldKeyword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKeyword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKeyword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKeyword: %w", err) + } + return oldValue.Keyword, nil +} + +// ResetKeyword resets all changes to the "keyword" field. +func (m *PermissionMutation) ResetKeyword() { + m.keyword = nil +} + +// SetDescription sets the "description" field. +func (m *PermissionMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *PermissionMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Permission entity. +// If the Permission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ResetDescription resets all changes to the "description" field. +func (m *PermissionMutation) ResetDescription() { + m.description = nil +} + +// SetDataScope sets the "data_scope" field. +func (m *PermissionMutation) SetDataScope(s string) { + m.data_scope = &s +} + +// DataScope returns the value of the "data_scope" field in the mutation. +func (m *PermissionMutation) DataScope() (r string, exists bool) { + v := m.data_scope + if v == nil { + return + } + return *v, true +} + +// OldDataScope returns the old "data_scope" field's value of the Permission entity. +// If the Permission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionMutation) OldDataScope(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDataScope is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDataScope requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDataScope: %w", err) + } + return oldValue.DataScope, nil +} + +// ResetDataScope resets all changes to the "data_scope" field. +func (m *PermissionMutation) ResetDataScope() { + m.data_scope = nil +} + +// SetDataRules sets the "data_rules" field. +func (m *PermissionMutation) SetDataRules(value map[string]string) { + m.data_rules = &value +} + +// DataRules returns the value of the "data_rules" field in the mutation. +func (m *PermissionMutation) DataRules() (r map[string]string, exists bool) { + v := m.data_rules + if v == nil { + return + } + return *v, true +} + +// OldDataRules returns the old "data_rules" field's value of the Permission entity. +// If the Permission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionMutation) OldDataRules(ctx context.Context) (v map[string]string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDataRules is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDataRules requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDataRules: %w", err) + } + return oldValue.DataRules, nil +} + +// ClearDataRules clears the value of the "data_rules" field. +func (m *PermissionMutation) ClearDataRules() { + m.data_rules = nil + m.clearedFields[permission.FieldDataRules] = struct{}{} +} + +// DataRulesCleared returns if the "data_rules" field was cleared in this mutation. +func (m *PermissionMutation) DataRulesCleared() bool { + _, ok := m.clearedFields[permission.FieldDataRules] + return ok +} + +// ResetDataRules resets all changes to the "data_rules" field. +func (m *PermissionMutation) ResetDataRules() { + m.data_rules = nil + delete(m.clearedFields, permission.FieldDataRules) +} + +// SetActions sets the "actions" field. +func (m *PermissionMutation) SetActions(pe permission.Actions) { + m.actions = &pe +} + +// Actions returns the value of the "actions" field in the mutation. +func (m *PermissionMutation) Actions() (r permission.Actions, exists bool) { + v := m.actions + if v == nil { + return + } + return *v, true +} + +// OldActions returns the old "actions" field's value of the Permission entity. +// If the Permission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionMutation) OldActions(ctx context.Context) (v permission.Actions, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldActions is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldActions requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldActions: %w", err) + } + return oldValue.Actions, nil +} + +// ResetActions resets all changes to the "actions" field. +func (m *PermissionMutation) ResetActions() { + m.actions = nil +} + +// AddRoleIDs adds the "roles" edge to the Role entity by ids. +func (m *PermissionMutation) AddRoleIDs(ids ...int64) { + if m.roles == nil { + m.roles = make(map[int64]struct{}) + } + for i := range ids { + m.roles[ids[i]] = struct{}{} + } +} + +// ClearRoles clears the "roles" edge to the Role entity. +func (m *PermissionMutation) ClearRoles() { + m.clearedroles = true +} + +// RolesCleared reports if the "roles" edge to the Role entity was cleared. +func (m *PermissionMutation) RolesCleared() bool { + return m.clearedroles +} + +// RemoveRoleIDs removes the "roles" edge to the Role entity by IDs. +func (m *PermissionMutation) RemoveRoleIDs(ids ...int64) { + if m.removedroles == nil { + m.removedroles = make(map[int64]struct{}) + } + for i := range ids { + delete(m.roles, ids[i]) + m.removedroles[ids[i]] = struct{}{} + } +} + +// RemovedRoles returns the removed IDs of the "roles" edge to the Role entity. +func (m *PermissionMutation) RemovedRolesIDs() (ids []int64) { + for id := range m.removedroles { + ids = append(ids, id) + } + return +} + +// RolesIDs returns the "roles" edge IDs in the mutation. +func (m *PermissionMutation) RolesIDs() (ids []int64) { + for id := range m.roles { + ids = append(ids, id) + } + return +} + +// ResetRoles resets all changes to the "roles" edge. +func (m *PermissionMutation) ResetRoles() { + m.roles = nil + m.clearedroles = false + m.removedroles = nil +} + +// AddResourceIDs adds the "resources" edge to the Resource entity by ids. +func (m *PermissionMutation) AddResourceIDs(ids ...int64) { + if m.resources == nil { + m.resources = make(map[int64]struct{}) + } + for i := range ids { + m.resources[ids[i]] = struct{}{} + } +} + +// ClearResources clears the "resources" edge to the Resource entity. +func (m *PermissionMutation) ClearResources() { + m.clearedresources = true +} + +// ResourcesCleared reports if the "resources" edge to the Resource entity was cleared. +func (m *PermissionMutation) ResourcesCleared() bool { + return m.clearedresources +} + +// RemoveResourceIDs removes the "resources" edge to the Resource entity by IDs. +func (m *PermissionMutation) RemoveResourceIDs(ids ...int64) { + if m.removedresources == nil { + m.removedresources = make(map[int64]struct{}) + } + for i := range ids { + delete(m.resources, ids[i]) + m.removedresources[ids[i]] = struct{}{} + } +} + +// RemovedResources returns the removed IDs of the "resources" edge to the Resource entity. +func (m *PermissionMutation) RemovedResourcesIDs() (ids []int64) { + for id := range m.removedresources { + ids = append(ids, id) + } + return +} + +// ResourcesIDs returns the "resources" edge IDs in the mutation. +func (m *PermissionMutation) ResourcesIDs() (ids []int64) { + for id := range m.resources { + ids = append(ids, id) + } + return +} + +// ResetResources resets all changes to the "resources" edge. +func (m *PermissionMutation) ResetResources() { + m.resources = nil + m.clearedresources = false + m.removedresources = nil +} + +// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by ids. +func (m *PermissionMutation) AddRolePermissionIDs(ids ...int) { + if m.role_permissions == nil { + m.role_permissions = make(map[int]struct{}) + } + for i := range ids { + m.role_permissions[ids[i]] = struct{}{} + } +} + +// ClearRolePermissions clears the "role_permissions" edge to the RolePermission entity. +func (m *PermissionMutation) ClearRolePermissions() { + m.clearedrole_permissions = true +} + +// RolePermissionsCleared reports if the "role_permissions" edge to the RolePermission entity was cleared. +func (m *PermissionMutation) RolePermissionsCleared() bool { + return m.clearedrole_permissions +} + +// RemoveRolePermissionIDs removes the "role_permissions" edge to the RolePermission entity by IDs. +func (m *PermissionMutation) RemoveRolePermissionIDs(ids ...int) { + if m.removedrole_permissions == nil { + m.removedrole_permissions = make(map[int]struct{}) + } + for i := range ids { + delete(m.role_permissions, ids[i]) + m.removedrole_permissions[ids[i]] = struct{}{} + } +} + +// RemovedRolePermissions returns the removed IDs of the "role_permissions" edge to the RolePermission entity. +func (m *PermissionMutation) RemovedRolePermissionsIDs() (ids []int) { + for id := range m.removedrole_permissions { + ids = append(ids, id) + } + return +} + +// RolePermissionsIDs returns the "role_permissions" edge IDs in the mutation. +func (m *PermissionMutation) RolePermissionsIDs() (ids []int) { + for id := range m.role_permissions { + ids = append(ids, id) + } + return +} + +// ResetRolePermissions resets all changes to the "role_permissions" edge. +func (m *PermissionMutation) ResetRolePermissions() { + m.role_permissions = nil + m.clearedrole_permissions = false + m.removedrole_permissions = nil +} + +// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by ids. +func (m *PermissionMutation) AddPermissionResourceIDs(ids ...int) { + if m.permission_resources == nil { + m.permission_resources = make(map[int]struct{}) + } + for i := range ids { + m.permission_resources[ids[i]] = struct{}{} + } +} + +// ClearPermissionResources clears the "permission_resources" edge to the PermissionResource entity. +func (m *PermissionMutation) ClearPermissionResources() { + m.clearedpermission_resources = true +} + +// PermissionResourcesCleared reports if the "permission_resources" edge to the PermissionResource entity was cleared. +func (m *PermissionMutation) PermissionResourcesCleared() bool { + return m.clearedpermission_resources +} + +// RemovePermissionResourceIDs removes the "permission_resources" edge to the PermissionResource entity by IDs. +func (m *PermissionMutation) RemovePermissionResourceIDs(ids ...int) { + if m.removedpermission_resources == nil { + m.removedpermission_resources = make(map[int]struct{}) + } + for i := range ids { + delete(m.permission_resources, ids[i]) + m.removedpermission_resources[ids[i]] = struct{}{} + } +} + +// RemovedPermissionResources returns the removed IDs of the "permission_resources" edge to the PermissionResource entity. +func (m *PermissionMutation) RemovedPermissionResourcesIDs() (ids []int) { + for id := range m.removedpermission_resources { + ids = append(ids, id) + } + return +} + +// PermissionResourcesIDs returns the "permission_resources" edge IDs in the mutation. +func (m *PermissionMutation) PermissionResourcesIDs() (ids []int) { + for id := range m.permission_resources { + ids = append(ids, id) + } + return +} + +// ResetPermissionResources resets all changes to the "permission_resources" edge. +func (m *PermissionMutation) ResetPermissionResources() { + m.permission_resources = nil + m.clearedpermission_resources = false + m.removedpermission_resources = nil +} + +// Where appends a list predicates to the PermissionMutation builder. +func (m *PermissionMutation) Where(ps ...predicate.Permission) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PermissionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PermissionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Permission, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PermissionMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PermissionMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Permission). +func (m *PermissionMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PermissionMutation) Fields() []string { + fields := make([]string, 0, 8) + if m.create_time != nil { + fields = append(fields, permission.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, permission.FieldUpdateTime) + } + if m.name != nil { + fields = append(fields, permission.FieldName) + } + if m.keyword != nil { + fields = append(fields, permission.FieldKeyword) + } + if m.description != nil { + fields = append(fields, permission.FieldDescription) + } + if m.data_scope != nil { + fields = append(fields, permission.FieldDataScope) + } + if m.data_rules != nil { + fields = append(fields, permission.FieldDataRules) + } + if m.actions != nil { + fields = append(fields, permission.FieldActions) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PermissionMutation) Field(name string) (ent.Value, bool) { + switch name { + case permission.FieldCreateTime: + return m.CreateTime() + case permission.FieldUpdateTime: + return m.UpdateTime() + case permission.FieldName: + return m.Name() + case permission.FieldKeyword: + return m.Keyword() + case permission.FieldDescription: + return m.Description() + case permission.FieldDataScope: + return m.DataScope() + case permission.FieldDataRules: + return m.DataRules() + case permission.FieldActions: + return m.Actions() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PermissionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case permission.FieldCreateTime: + return m.OldCreateTime(ctx) + case permission.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case permission.FieldName: + return m.OldName(ctx) + case permission.FieldKeyword: + return m.OldKeyword(ctx) + case permission.FieldDescription: + return m.OldDescription(ctx) + case permission.FieldDataScope: + return m.OldDataScope(ctx) + case permission.FieldDataRules: + return m.OldDataRules(ctx) + case permission.FieldActions: + return m.OldActions(ctx) + } + return nil, fmt.Errorf("unknown Permission field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PermissionMutation) SetField(name string, value ent.Value) error { + switch name { + case permission.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case permission.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case permission.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case permission.FieldKeyword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKeyword(v) + return nil + case permission.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case permission.FieldDataScope: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDataScope(v) + return nil + case permission.FieldDataRules: + v, ok := value.(map[string]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDataRules(v) + return nil + case permission.FieldActions: + v, ok := value.(permission.Actions) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetActions(v) + return nil + } + return fmt.Errorf("unknown Permission field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PermissionMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PermissionMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PermissionMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Permission numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PermissionMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(permission.FieldDataRules) { + fields = append(fields, permission.FieldDataRules) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PermissionMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PermissionMutation) ClearField(name string) error { + switch name { + case permission.FieldDataRules: + m.ClearDataRules() + return nil + } + return fmt.Errorf("unknown Permission nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PermissionMutation) ResetField(name string) error { + switch name { + case permission.FieldCreateTime: + m.ResetCreateTime() + return nil + case permission.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case permission.FieldName: + m.ResetName() + return nil + case permission.FieldKeyword: + m.ResetKeyword() + return nil + case permission.FieldDescription: + m.ResetDescription() + return nil + case permission.FieldDataScope: + m.ResetDataScope() + return nil + case permission.FieldDataRules: + m.ResetDataRules() + return nil + case permission.FieldActions: + m.ResetActions() + return nil + } + return fmt.Errorf("unknown Permission field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PermissionMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.roles != nil { + edges = append(edges, permission.EdgeRoles) + } + if m.resources != nil { + edges = append(edges, permission.EdgeResources) + } + if m.role_permissions != nil { + edges = append(edges, permission.EdgeRolePermissions) + } + if m.permission_resources != nil { + edges = append(edges, permission.EdgePermissionResources) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PermissionMutation) AddedIDs(name string) []ent.Value { + switch name { + case permission.EdgeRoles: + ids := make([]ent.Value, 0, len(m.roles)) + for id := range m.roles { + ids = append(ids, id) + } + return ids + case permission.EdgeResources: + ids := make([]ent.Value, 0, len(m.resources)) + for id := range m.resources { + ids = append(ids, id) + } + return ids + case permission.EdgeRolePermissions: + ids := make([]ent.Value, 0, len(m.role_permissions)) + for id := range m.role_permissions { + ids = append(ids, id) + } + return ids + case permission.EdgePermissionResources: + ids := make([]ent.Value, 0, len(m.permission_resources)) + for id := range m.permission_resources { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PermissionMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedroles != nil { + edges = append(edges, permission.EdgeRoles) + } + if m.removedresources != nil { + edges = append(edges, permission.EdgeResources) + } + if m.removedrole_permissions != nil { + edges = append(edges, permission.EdgeRolePermissions) + } + if m.removedpermission_resources != nil { + edges = append(edges, permission.EdgePermissionResources) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PermissionMutation) RemovedIDs(name string) []ent.Value { + switch name { + case permission.EdgeRoles: + ids := make([]ent.Value, 0, len(m.removedroles)) + for id := range m.removedroles { + ids = append(ids, id) + } + return ids + case permission.EdgeResources: + ids := make([]ent.Value, 0, len(m.removedresources)) + for id := range m.removedresources { + ids = append(ids, id) + } + return ids + case permission.EdgeRolePermissions: + ids := make([]ent.Value, 0, len(m.removedrole_permissions)) + for id := range m.removedrole_permissions { + ids = append(ids, id) + } + return ids + case permission.EdgePermissionResources: + ids := make([]ent.Value, 0, len(m.removedpermission_resources)) + for id := range m.removedpermission_resources { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PermissionMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedroles { + edges = append(edges, permission.EdgeRoles) + } + if m.clearedresources { + edges = append(edges, permission.EdgeResources) + } + if m.clearedrole_permissions { + edges = append(edges, permission.EdgeRolePermissions) + } + if m.clearedpermission_resources { + edges = append(edges, permission.EdgePermissionResources) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PermissionMutation) EdgeCleared(name string) bool { + switch name { + case permission.EdgeRoles: + return m.clearedroles + case permission.EdgeResources: + return m.clearedresources + case permission.EdgeRolePermissions: + return m.clearedrole_permissions + case permission.EdgePermissionResources: + return m.clearedpermission_resources + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PermissionMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Permission unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PermissionMutation) ResetEdge(name string) error { + switch name { + case permission.EdgeRoles: + m.ResetRoles() + return nil + case permission.EdgeResources: + m.ResetResources() + return nil + case permission.EdgeRolePermissions: + m.ResetRolePermissions() + return nil + case permission.EdgePermissionResources: + m.ResetPermissionResources() + return nil + } + return fmt.Errorf("unknown Permission edge %s", name) +} + +// PermissionResourceMutation represents an operation that mutates the PermissionResource nodes in the graph. +type PermissionResourceMutation struct { + config + op Op + typ string + id *int + clearedFields map[string]struct{} + permission *int64 + clearedpermission bool + resource *int64 + clearedresource bool + done bool + oldValue func(context.Context) (*PermissionResource, error) + predicates []predicate.PermissionResource +} + +var _ ent.Mutation = (*PermissionResourceMutation)(nil) + +// permissionresourceOption allows management of the mutation configuration using functional options. +type permissionresourceOption func(*PermissionResourceMutation) + +// newPermissionResourceMutation creates new mutation for the PermissionResource entity. +func newPermissionResourceMutation(c config, op Op, opts ...permissionresourceOption) *PermissionResourceMutation { + m := &PermissionResourceMutation{ + config: c, + op: op, + typ: TypePermissionResource, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPermissionResourceID sets the ID field of the mutation. +func withPermissionResourceID(id int) permissionresourceOption { + return func(m *PermissionResourceMutation) { + var ( + err error + once sync.Once + value *PermissionResource + ) + m.oldValue = func(ctx context.Context) (*PermissionResource, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().PermissionResource.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPermissionResource sets the old PermissionResource of the mutation. +func withPermissionResource(node *PermissionResource) permissionresourceOption { + return func(m *PermissionResourceMutation) { + m.oldValue = func(context.Context) (*PermissionResource, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PermissionResourceMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PermissionResourceMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PermissionResourceMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PermissionResourceMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().PermissionResource.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetPermissionID sets the "permission_id" field. +func (m *PermissionResourceMutation) SetPermissionID(i int64) { + m.permission = &i +} + +// PermissionID returns the value of the "permission_id" field in the mutation. +func (m *PermissionResourceMutation) PermissionID() (r int64, exists bool) { + v := m.permission + if v == nil { + return + } + return *v, true +} + +// OldPermissionID returns the old "permission_id" field's value of the PermissionResource entity. +// If the PermissionResource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionResourceMutation) OldPermissionID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPermissionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPermissionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPermissionID: %w", err) + } + return oldValue.PermissionID, nil +} + +// ResetPermissionID resets all changes to the "permission_id" field. +func (m *PermissionResourceMutation) ResetPermissionID() { + m.permission = nil +} + +// SetResourceID sets the "resource_id" field. +func (m *PermissionResourceMutation) SetResourceID(i int64) { + m.resource = &i +} + +// ResourceID returns the value of the "resource_id" field in the mutation. +func (m *PermissionResourceMutation) ResourceID() (r int64, exists bool) { + v := m.resource + if v == nil { + return + } + return *v, true +} + +// OldResourceID returns the old "resource_id" field's value of the PermissionResource entity. +// If the PermissionResource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionResourceMutation) OldResourceID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldResourceID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldResourceID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldResourceID: %w", err) + } + return oldValue.ResourceID, nil +} + +// ResetResourceID resets all changes to the "resource_id" field. +func (m *PermissionResourceMutation) ResetResourceID() { + m.resource = nil +} + +// ClearPermission clears the "permission" edge to the Permission entity. +func (m *PermissionResourceMutation) ClearPermission() { + m.clearedpermission = true + m.clearedFields[permissionresource.FieldPermissionID] = struct{}{} +} + +// PermissionCleared reports if the "permission" edge to the Permission entity was cleared. +func (m *PermissionResourceMutation) PermissionCleared() bool { + return m.clearedpermission +} + +// PermissionIDs returns the "permission" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PermissionID instead. It exists only for internal usage by the builders. +func (m *PermissionResourceMutation) PermissionIDs() (ids []int64) { + if id := m.permission; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetPermission resets all changes to the "permission" edge. +func (m *PermissionResourceMutation) ResetPermission() { + m.permission = nil + m.clearedpermission = false +} + +// ClearResource clears the "resource" edge to the Resource entity. +func (m *PermissionResourceMutation) ClearResource() { + m.clearedresource = true + m.clearedFields[permissionresource.FieldResourceID] = struct{}{} +} + +// ResourceCleared reports if the "resource" edge to the Resource entity was cleared. +func (m *PermissionResourceMutation) ResourceCleared() bool { + return m.clearedresource +} + +// ResourceIDs returns the "resource" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ResourceID instead. It exists only for internal usage by the builders. +func (m *PermissionResourceMutation) ResourceIDs() (ids []int64) { + if id := m.resource; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetResource resets all changes to the "resource" edge. +func (m *PermissionResourceMutation) ResetResource() { + m.resource = nil + m.clearedresource = false +} + +// Where appends a list predicates to the PermissionResourceMutation builder. +func (m *PermissionResourceMutation) Where(ps ...predicate.PermissionResource) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the PermissionResourceMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PermissionResourceMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.PermissionResource, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *PermissionResourceMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *PermissionResourceMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (PermissionResource). +func (m *PermissionResourceMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PermissionResourceMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.permission != nil { + fields = append(fields, permissionresource.FieldPermissionID) + } + if m.resource != nil { + fields = append(fields, permissionresource.FieldResourceID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PermissionResourceMutation) Field(name string) (ent.Value, bool) { + switch name { + case permissionresource.FieldPermissionID: + return m.PermissionID() + case permissionresource.FieldResourceID: + return m.ResourceID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PermissionResourceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case permissionresource.FieldPermissionID: + return m.OldPermissionID(ctx) + case permissionresource.FieldResourceID: + return m.OldResourceID(ctx) + } + return nil, fmt.Errorf("unknown PermissionResource field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PermissionResourceMutation) SetField(name string, value ent.Value) error { + switch name { + case permissionresource.FieldPermissionID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPermissionID(v) + return nil + case permissionresource.FieldResourceID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetResourceID(v) + return nil + } + return fmt.Errorf("unknown PermissionResource field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PermissionResourceMutation) AddedFields() []string { + var fields []string + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PermissionResourceMutation) AddedField(name string) (ent.Value, bool) { + switch name { + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PermissionResourceMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown PermissionResource numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PermissionResourceMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PermissionResourceMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PermissionResourceMutation) ClearField(name string) error { + return fmt.Errorf("unknown PermissionResource nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PermissionResourceMutation) ResetField(name string) error { + switch name { + case permissionresource.FieldPermissionID: + m.ResetPermissionID() + return nil + case permissionresource.FieldResourceID: + m.ResetResourceID() + return nil + } + return fmt.Errorf("unknown PermissionResource field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PermissionResourceMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.permission != nil { + edges = append(edges, permissionresource.EdgePermission) + } + if m.resource != nil { + edges = append(edges, permissionresource.EdgeResource) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PermissionResourceMutation) AddedIDs(name string) []ent.Value { + switch name { + case permissionresource.EdgePermission: + if id := m.permission; id != nil { + return []ent.Value{*id} + } + case permissionresource.EdgeResource: + if id := m.resource; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PermissionResourceMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PermissionResourceMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PermissionResourceMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedpermission { + edges = append(edges, permissionresource.EdgePermission) + } + if m.clearedresource { + edges = append(edges, permissionresource.EdgeResource) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PermissionResourceMutation) EdgeCleared(name string) bool { + switch name { + case permissionresource.EdgePermission: + return m.clearedpermission + case permissionresource.EdgeResource: + return m.clearedresource + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PermissionResourceMutation) ClearEdge(name string) error { + switch name { + case permissionresource.EdgePermission: + m.ClearPermission() + return nil + case permissionresource.EdgeResource: + m.ClearResource() + return nil + } + return fmt.Errorf("unknown PermissionResource unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PermissionResourceMutation) ResetEdge(name string) error { + switch name { + case permissionresource.EdgePermission: + m.ResetPermission() + return nil + case permissionresource.EdgeResource: + m.ResetResource() + return nil + } + return fmt.Errorf("unknown PermissionResource edge %s", name) +} + +// ResourceMutation represents an operation that mutates the Resource nodes in the graph. +type ResourceMutation struct { + config + op Op + typ string + id *int64 + create_time *time.Time + update_time *time.Time + name *string + keyword *string + _type *string + status *int8 + addstatus *int8 + _path *string + component *string + icon *string + sequence *int + addsequence *int + visible *bool + level *int8 + addlevel *int8 + tree_path *string + properties *map[string]string + description *string + clearedFields map[string]struct{} + parent *int64 + clearedparent bool + children map[int64]struct{} + removedchildren map[int64]struct{} + clearedchildren bool + permissions map[int64]struct{} + removedpermissions map[int64]struct{} + clearedpermissions bool + permission_resources map[int]struct{} + removedpermission_resources map[int]struct{} + clearedpermission_resources bool + done bool + oldValue func(context.Context) (*Resource, error) + predicates []predicate.Resource +} + +var _ ent.Mutation = (*ResourceMutation)(nil) + +// resourceOption allows management of the mutation configuration using functional options. +type resourceOption func(*ResourceMutation) + +// newResourceMutation creates new mutation for the Resource entity. +func newResourceMutation(c config, op Op, opts ...resourceOption) *ResourceMutation { + m := &ResourceMutation{ + config: c, + op: op, + typ: TypeResource, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withResourceID sets the ID field of the mutation. +func withResourceID(id int64) resourceOption { + return func(m *ResourceMutation) { + var ( + err error + once sync.Once + value *Resource + ) + m.oldValue = func(ctx context.Context) (*Resource, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Resource.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withResource sets the old Resource of the mutation. +func withResource(node *Resource) resourceOption { + return func(m *ResourceMutation) { + m.oldValue = func(context.Context) (*Resource, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ResourceMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ResourceMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Resource entities. +func (m *ResourceMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ResourceMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ResourceMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Resource.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateTime sets the "create_time" field. +func (m *ResourceMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *ResourceMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *ResourceMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *ResourceMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *ResourceMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *ResourceMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetName sets the "name" field. +func (m *ResourceMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *ResourceMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *ResourceMutation) ResetName() { + m.name = nil +} + +// SetKeyword sets the "keyword" field. +func (m *ResourceMutation) SetKeyword(s string) { + m.keyword = &s +} + +// Keyword returns the value of the "keyword" field in the mutation. +func (m *ResourceMutation) Keyword() (r string, exists bool) { + v := m.keyword + if v == nil { + return + } + return *v, true +} + +// OldKeyword returns the old "keyword" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldKeyword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKeyword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKeyword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKeyword: %w", err) + } + return oldValue.Keyword, nil +} + +// ResetKeyword resets all changes to the "keyword" field. +func (m *ResourceMutation) ResetKeyword() { + m.keyword = nil +} + +// SetType sets the "type" field. +func (m *ResourceMutation) SetType(s string) { + m._type = &s +} + +// GetType returns the value of the "type" field in the mutation. +func (m *ResourceMutation) GetType() (r string, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *ResourceMutation) ResetType() { + m._type = nil +} + +// SetStatus sets the "status" field. +func (m *ResourceMutation) SetStatus(i int8) { + m.status = &i + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *ResourceMutation) Status() (r int8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldStatus(ctx context.Context) (v int8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds i to the "status" field. +func (m *ResourceMutation) AddStatus(i int8) { + if m.addstatus != nil { + *m.addstatus += i + } else { + m.addstatus = &i + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *ResourceMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ResetStatus resets all changes to the "status" field. +func (m *ResourceMutation) ResetStatus() { + m.status = nil + m.addstatus = nil +} + +// SetPath sets the "path" field. +func (m *ResourceMutation) SetPath(s string) { + m._path = &s +} + +// Path returns the value of the "path" field in the mutation. +func (m *ResourceMutation) Path() (r string, exists bool) { + v := m._path + if v == nil { + return + } + return *v, true +} + +// OldPath returns the old "path" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldPath(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPath is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPath requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPath: %w", err) + } + return oldValue.Path, nil +} + +// ResetPath resets all changes to the "path" field. +func (m *ResourceMutation) ResetPath() { + m._path = nil +} + +// SetComponent sets the "component" field. +func (m *ResourceMutation) SetComponent(s string) { + m.component = &s +} + +// Component returns the value of the "component" field in the mutation. +func (m *ResourceMutation) Component() (r string, exists bool) { + v := m.component + if v == nil { + return + } + return *v, true +} + +// OldComponent returns the old "component" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldComponent(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldComponent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldComponent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldComponent: %w", err) + } + return oldValue.Component, nil +} + +// ResetComponent resets all changes to the "component" field. +func (m *ResourceMutation) ResetComponent() { + m.component = nil +} + +// SetIcon sets the "icon" field. +func (m *ResourceMutation) SetIcon(s string) { + m.icon = &s +} + +// Icon returns the value of the "icon" field in the mutation. +func (m *ResourceMutation) Icon() (r string, exists bool) { + v := m.icon + if v == nil { + return + } + return *v, true +} + +// OldIcon returns the old "icon" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldIcon(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIcon is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIcon requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIcon: %w", err) + } + return oldValue.Icon, nil +} + +// ResetIcon resets all changes to the "icon" field. +func (m *ResourceMutation) ResetIcon() { + m.icon = nil +} + +// SetSequence sets the "sequence" field. +func (m *ResourceMutation) SetSequence(i int) { + m.sequence = &i + m.addsequence = nil +} + +// Sequence returns the value of the "sequence" field in the mutation. +func (m *ResourceMutation) Sequence() (r int, exists bool) { + v := m.sequence + if v == nil { + return + } + return *v, true +} + +// OldSequence returns the old "sequence" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldSequence(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSequence is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSequence requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSequence: %w", err) + } + return oldValue.Sequence, nil +} + +// AddSequence adds i to the "sequence" field. +func (m *ResourceMutation) AddSequence(i int) { + if m.addsequence != nil { + *m.addsequence += i + } else { + m.addsequence = &i + } +} + +// AddedSequence returns the value that was added to the "sequence" field in this mutation. +func (m *ResourceMutation) AddedSequence() (r int, exists bool) { + v := m.addsequence + if v == nil { + return + } + return *v, true +} + +// ResetSequence resets all changes to the "sequence" field. +func (m *ResourceMutation) ResetSequence() { + m.sequence = nil + m.addsequence = nil +} + +// SetVisible sets the "visible" field. +func (m *ResourceMutation) SetVisible(b bool) { + m.visible = &b +} + +// Visible returns the value of the "visible" field in the mutation. +func (m *ResourceMutation) Visible() (r bool, exists bool) { + v := m.visible + if v == nil { + return + } + return *v, true +} + +// OldVisible returns the old "visible" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldVisible(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVisible is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVisible requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVisible: %w", err) + } + return oldValue.Visible, nil +} + +// ResetVisible resets all changes to the "visible" field. +func (m *ResourceMutation) ResetVisible() { + m.visible = nil +} + +// SetLevel sets the "level" field. +func (m *ResourceMutation) SetLevel(i int8) { + m.level = &i + m.addlevel = nil +} + +// Level returns the value of the "level" field in the mutation. +func (m *ResourceMutation) Level() (r int8, exists bool) { + v := m.level + if v == nil { + return + } + return *v, true +} + +// OldLevel returns the old "level" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldLevel(ctx context.Context) (v int8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLevel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLevel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLevel: %w", err) + } + return oldValue.Level, nil +} + +// AddLevel adds i to the "level" field. +func (m *ResourceMutation) AddLevel(i int8) { + if m.addlevel != nil { + *m.addlevel += i + } else { + m.addlevel = &i + } +} + +// AddedLevel returns the value that was added to the "level" field in this mutation. +func (m *ResourceMutation) AddedLevel() (r int8, exists bool) { + v := m.addlevel + if v == nil { + return + } + return *v, true +} + +// ResetLevel resets all changes to the "level" field. +func (m *ResourceMutation) ResetLevel() { + m.level = nil + m.addlevel = nil +} + +// SetTreePath sets the "tree_path" field. +func (m *ResourceMutation) SetTreePath(s string) { + m.tree_path = &s +} + +// TreePath returns the value of the "tree_path" field in the mutation. +func (m *ResourceMutation) TreePath() (r string, exists bool) { + v := m.tree_path + if v == nil { + return + } + return *v, true +} + +// OldTreePath returns the old "tree_path" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldTreePath(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTreePath is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTreePath requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTreePath: %w", err) + } + return oldValue.TreePath, nil +} + +// ResetTreePath resets all changes to the "tree_path" field. +func (m *ResourceMutation) ResetTreePath() { + m.tree_path = nil +} + +// SetProperties sets the "properties" field. +func (m *ResourceMutation) SetProperties(value map[string]string) { + m.properties = &value +} + +// Properties returns the value of the "properties" field in the mutation. +func (m *ResourceMutation) Properties() (r map[string]string, exists bool) { + v := m.properties + if v == nil { + return + } + return *v, true +} + +// OldProperties returns the old "properties" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldProperties(ctx context.Context) (v map[string]string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProperties is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProperties requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProperties: %w", err) + } + return oldValue.Properties, nil +} + +// ClearProperties clears the value of the "properties" field. +func (m *ResourceMutation) ClearProperties() { + m.properties = nil + m.clearedFields[resource.FieldProperties] = struct{}{} +} + +// PropertiesCleared returns if the "properties" field was cleared in this mutation. +func (m *ResourceMutation) PropertiesCleared() bool { + _, ok := m.clearedFields[resource.FieldProperties] + return ok +} + +// ResetProperties resets all changes to the "properties" field. +func (m *ResourceMutation) ResetProperties() { + m.properties = nil + delete(m.clearedFields, resource.FieldProperties) +} + +// SetDescription sets the "description" field. +func (m *ResourceMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *ResourceMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ResetDescription resets all changes to the "description" field. +func (m *ResourceMutation) ResetDescription() { + m.description = nil +} + +// SetParentID sets the "parent_id" field. +func (m *ResourceMutation) SetParentID(i int64) { + m.parent = &i +} + +// ParentID returns the value of the "parent_id" field in the mutation. +func (m *ResourceMutation) ParentID() (r int64, exists bool) { + v := m.parent + if v == nil { + return + } + return *v, true +} + +// OldParentID returns the old "parent_id" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldParentID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldParentID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldParentID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldParentID: %w", err) + } + return oldValue.ParentID, nil +} + +// ClearParentID clears the value of the "parent_id" field. +func (m *ResourceMutation) ClearParentID() { + m.parent = nil + m.clearedFields[resource.FieldParentID] = struct{}{} +} + +// ParentIDCleared returns if the "parent_id" field was cleared in this mutation. +func (m *ResourceMutation) ParentIDCleared() bool { + _, ok := m.clearedFields[resource.FieldParentID] + return ok +} + +// ResetParentID resets all changes to the "parent_id" field. +func (m *ResourceMutation) ResetParentID() { + m.parent = nil + delete(m.clearedFields, resource.FieldParentID) +} + +// ClearParent clears the "parent" edge to the Resource entity. +func (m *ResourceMutation) ClearParent() { + m.clearedparent = true + m.clearedFields[resource.FieldParentID] = struct{}{} +} + +// ParentCleared reports if the "parent" edge to the Resource entity was cleared. +func (m *ResourceMutation) ParentCleared() bool { + return m.ParentIDCleared() || m.clearedparent +} + +// ParentIDs returns the "parent" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ParentID instead. It exists only for internal usage by the builders. +func (m *ResourceMutation) ParentIDs() (ids []int64) { + if id := m.parent; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetParent resets all changes to the "parent" edge. +func (m *ResourceMutation) ResetParent() { + m.parent = nil + m.clearedparent = false +} + +// AddChildIDs adds the "children" edge to the Resource entity by ids. +func (m *ResourceMutation) AddChildIDs(ids ...int64) { + if m.children == nil { + m.children = make(map[int64]struct{}) + } + for i := range ids { + m.children[ids[i]] = struct{}{} + } +} + +// ClearChildren clears the "children" edge to the Resource entity. +func (m *ResourceMutation) ClearChildren() { + m.clearedchildren = true +} + +// ChildrenCleared reports if the "children" edge to the Resource entity was cleared. +func (m *ResourceMutation) ChildrenCleared() bool { + return m.clearedchildren +} + +// RemoveChildIDs removes the "children" edge to the Resource entity by IDs. +func (m *ResourceMutation) RemoveChildIDs(ids ...int64) { + if m.removedchildren == nil { + m.removedchildren = make(map[int64]struct{}) + } + for i := range ids { + delete(m.children, ids[i]) + m.removedchildren[ids[i]] = struct{}{} + } +} + +// RemovedChildren returns the removed IDs of the "children" edge to the Resource entity. +func (m *ResourceMutation) RemovedChildrenIDs() (ids []int64) { + for id := range m.removedchildren { + ids = append(ids, id) + } + return +} + +// ChildrenIDs returns the "children" edge IDs in the mutation. +func (m *ResourceMutation) ChildrenIDs() (ids []int64) { + for id := range m.children { + ids = append(ids, id) + } + return +} + +// ResetChildren resets all changes to the "children" edge. +func (m *ResourceMutation) ResetChildren() { + m.children = nil + m.clearedchildren = false + m.removedchildren = nil +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by ids. +func (m *ResourceMutation) AddPermissionIDs(ids ...int64) { + if m.permissions == nil { + m.permissions = make(map[int64]struct{}) + } + for i := range ids { + m.permissions[ids[i]] = struct{}{} + } +} + +// ClearPermissions clears the "permissions" edge to the Permission entity. +func (m *ResourceMutation) ClearPermissions() { + m.clearedpermissions = true +} + +// PermissionsCleared reports if the "permissions" edge to the Permission entity was cleared. +func (m *ResourceMutation) PermissionsCleared() bool { + return m.clearedpermissions +} + +// RemovePermissionIDs removes the "permissions" edge to the Permission entity by IDs. +func (m *ResourceMutation) RemovePermissionIDs(ids ...int64) { + if m.removedpermissions == nil { + m.removedpermissions = make(map[int64]struct{}) + } + for i := range ids { + delete(m.permissions, ids[i]) + m.removedpermissions[ids[i]] = struct{}{} + } +} + +// RemovedPermissions returns the removed IDs of the "permissions" edge to the Permission entity. +func (m *ResourceMutation) RemovedPermissionsIDs() (ids []int64) { + for id := range m.removedpermissions { + ids = append(ids, id) + } + return +} + +// PermissionsIDs returns the "permissions" edge IDs in the mutation. +func (m *ResourceMutation) PermissionsIDs() (ids []int64) { + for id := range m.permissions { + ids = append(ids, id) + } + return +} + +// ResetPermissions resets all changes to the "permissions" edge. +func (m *ResourceMutation) ResetPermissions() { + m.permissions = nil + m.clearedpermissions = false + m.removedpermissions = nil +} + +// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by ids. +func (m *ResourceMutation) AddPermissionResourceIDs(ids ...int) { + if m.permission_resources == nil { + m.permission_resources = make(map[int]struct{}) + } + for i := range ids { + m.permission_resources[ids[i]] = struct{}{} + } +} + +// ClearPermissionResources clears the "permission_resources" edge to the PermissionResource entity. +func (m *ResourceMutation) ClearPermissionResources() { + m.clearedpermission_resources = true +} + +// PermissionResourcesCleared reports if the "permission_resources" edge to the PermissionResource entity was cleared. +func (m *ResourceMutation) PermissionResourcesCleared() bool { + return m.clearedpermission_resources +} + +// RemovePermissionResourceIDs removes the "permission_resources" edge to the PermissionResource entity by IDs. +func (m *ResourceMutation) RemovePermissionResourceIDs(ids ...int) { + if m.removedpermission_resources == nil { + m.removedpermission_resources = make(map[int]struct{}) + } + for i := range ids { + delete(m.permission_resources, ids[i]) + m.removedpermission_resources[ids[i]] = struct{}{} + } +} + +// RemovedPermissionResources returns the removed IDs of the "permission_resources" edge to the PermissionResource entity. +func (m *ResourceMutation) RemovedPermissionResourcesIDs() (ids []int) { + for id := range m.removedpermission_resources { + ids = append(ids, id) + } + return +} + +// PermissionResourcesIDs returns the "permission_resources" edge IDs in the mutation. +func (m *ResourceMutation) PermissionResourcesIDs() (ids []int) { + for id := range m.permission_resources { + ids = append(ids, id) + } + return +} + +// ResetPermissionResources resets all changes to the "permission_resources" edge. +func (m *ResourceMutation) ResetPermissionResources() { + m.permission_resources = nil + m.clearedpermission_resources = false + m.removedpermission_resources = nil +} + +// Where appends a list predicates to the ResourceMutation builder. +func (m *ResourceMutation) Where(ps ...predicate.Resource) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ResourceMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ResourceMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Resource, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ResourceMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ResourceMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Resource). +func (m *ResourceMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ResourceMutation) Fields() []string { + fields := make([]string, 0, 16) + if m.create_time != nil { + fields = append(fields, resource.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, resource.FieldUpdateTime) + } + if m.name != nil { + fields = append(fields, resource.FieldName) + } + if m.keyword != nil { + fields = append(fields, resource.FieldKeyword) + } + if m._type != nil { + fields = append(fields, resource.FieldType) + } + if m.status != nil { + fields = append(fields, resource.FieldStatus) + } + if m._path != nil { + fields = append(fields, resource.FieldPath) + } + if m.component != nil { + fields = append(fields, resource.FieldComponent) + } + if m.icon != nil { + fields = append(fields, resource.FieldIcon) + } + if m.sequence != nil { + fields = append(fields, resource.FieldSequence) + } + if m.visible != nil { + fields = append(fields, resource.FieldVisible) + } + if m.level != nil { + fields = append(fields, resource.FieldLevel) + } + if m.tree_path != nil { + fields = append(fields, resource.FieldTreePath) + } + if m.properties != nil { + fields = append(fields, resource.FieldProperties) + } + if m.description != nil { + fields = append(fields, resource.FieldDescription) + } + if m.parent != nil { + fields = append(fields, resource.FieldParentID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ResourceMutation) Field(name string) (ent.Value, bool) { + switch name { + case resource.FieldCreateTime: + return m.CreateTime() + case resource.FieldUpdateTime: + return m.UpdateTime() + case resource.FieldName: + return m.Name() + case resource.FieldKeyword: + return m.Keyword() + case resource.FieldType: + return m.GetType() + case resource.FieldStatus: + return m.Status() + case resource.FieldPath: + return m.Path() + case resource.FieldComponent: + return m.Component() + case resource.FieldIcon: + return m.Icon() + case resource.FieldSequence: + return m.Sequence() + case resource.FieldVisible: + return m.Visible() + case resource.FieldLevel: + return m.Level() + case resource.FieldTreePath: + return m.TreePath() + case resource.FieldProperties: + return m.Properties() + case resource.FieldDescription: + return m.Description() + case resource.FieldParentID: + return m.ParentID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ResourceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case resource.FieldCreateTime: + return m.OldCreateTime(ctx) + case resource.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case resource.FieldName: + return m.OldName(ctx) + case resource.FieldKeyword: + return m.OldKeyword(ctx) + case resource.FieldType: + return m.OldType(ctx) + case resource.FieldStatus: + return m.OldStatus(ctx) + case resource.FieldPath: + return m.OldPath(ctx) + case resource.FieldComponent: + return m.OldComponent(ctx) + case resource.FieldIcon: + return m.OldIcon(ctx) + case resource.FieldSequence: + return m.OldSequence(ctx) + case resource.FieldVisible: + return m.OldVisible(ctx) + case resource.FieldLevel: + return m.OldLevel(ctx) + case resource.FieldTreePath: + return m.OldTreePath(ctx) + case resource.FieldProperties: + return m.OldProperties(ctx) + case resource.FieldDescription: + return m.OldDescription(ctx) + case resource.FieldParentID: + return m.OldParentID(ctx) + } + return nil, fmt.Errorf("unknown Resource field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ResourceMutation) SetField(name string, value ent.Value) error { + switch name { + case resource.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case resource.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case resource.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case resource.FieldKeyword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKeyword(v) + return nil + case resource.FieldType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case resource.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case resource.FieldPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPath(v) + return nil + case resource.FieldComponent: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetComponent(v) + return nil + case resource.FieldIcon: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIcon(v) + return nil + case resource.FieldSequence: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSequence(v) + return nil + case resource.FieldVisible: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVisible(v) + return nil + case resource.FieldLevel: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLevel(v) + return nil + case resource.FieldTreePath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTreePath(v) + return nil + case resource.FieldProperties: + v, ok := value.(map[string]string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProperties(v) + return nil + case resource.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case resource.FieldParentID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetParentID(v) + return nil + } + return fmt.Errorf("unknown Resource field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ResourceMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, resource.FieldStatus) + } + if m.addsequence != nil { + fields = append(fields, resource.FieldSequence) + } + if m.addlevel != nil { + fields = append(fields, resource.FieldLevel) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ResourceMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case resource.FieldStatus: + return m.AddedStatus() + case resource.FieldSequence: + return m.AddedSequence() + case resource.FieldLevel: + return m.AddedLevel() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ResourceMutation) AddField(name string, value ent.Value) error { + switch name { + case resource.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case resource.FieldSequence: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSequence(v) + return nil + case resource.FieldLevel: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLevel(v) + return nil + } + return fmt.Errorf("unknown Resource numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ResourceMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(resource.FieldProperties) { + fields = append(fields, resource.FieldProperties) + } + if m.FieldCleared(resource.FieldParentID) { + fields = append(fields, resource.FieldParentID) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ResourceMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ResourceMutation) ClearField(name string) error { + switch name { + case resource.FieldProperties: + m.ClearProperties() + return nil + case resource.FieldParentID: + m.ClearParentID() + return nil + } + return fmt.Errorf("unknown Resource nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ResourceMutation) ResetField(name string) error { + switch name { + case resource.FieldCreateTime: + m.ResetCreateTime() + return nil + case resource.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case resource.FieldName: + m.ResetName() + return nil + case resource.FieldKeyword: + m.ResetKeyword() + return nil + case resource.FieldType: + m.ResetType() + return nil + case resource.FieldStatus: + m.ResetStatus() + return nil + case resource.FieldPath: + m.ResetPath() + return nil + case resource.FieldComponent: + m.ResetComponent() + return nil + case resource.FieldIcon: + m.ResetIcon() + return nil + case resource.FieldSequence: + m.ResetSequence() + return nil + case resource.FieldVisible: + m.ResetVisible() + return nil + case resource.FieldLevel: + m.ResetLevel() + return nil + case resource.FieldTreePath: + m.ResetTreePath() + return nil + case resource.FieldProperties: + m.ResetProperties() + return nil + case resource.FieldDescription: + m.ResetDescription() + return nil + case resource.FieldParentID: + m.ResetParentID() + return nil + } + return fmt.Errorf("unknown Resource field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ResourceMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.parent != nil { + edges = append(edges, resource.EdgeParent) + } + if m.children != nil { + edges = append(edges, resource.EdgeChildren) + } + if m.permissions != nil { + edges = append(edges, resource.EdgePermissions) + } + if m.permission_resources != nil { + edges = append(edges, resource.EdgePermissionResources) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ResourceMutation) AddedIDs(name string) []ent.Value { + switch name { + case resource.EdgeParent: + if id := m.parent; id != nil { + return []ent.Value{*id} + } + case resource.EdgeChildren: + ids := make([]ent.Value, 0, len(m.children)) + for id := range m.children { + ids = append(ids, id) + } + return ids + case resource.EdgePermissions: + ids := make([]ent.Value, 0, len(m.permissions)) + for id := range m.permissions { + ids = append(ids, id) + } + return ids + case resource.EdgePermissionResources: + ids := make([]ent.Value, 0, len(m.permission_resources)) + for id := range m.permission_resources { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ResourceMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedchildren != nil { + edges = append(edges, resource.EdgeChildren) + } + if m.removedpermissions != nil { + edges = append(edges, resource.EdgePermissions) + } + if m.removedpermission_resources != nil { + edges = append(edges, resource.EdgePermissionResources) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ResourceMutation) RemovedIDs(name string) []ent.Value { + switch name { + case resource.EdgeChildren: + ids := make([]ent.Value, 0, len(m.removedchildren)) + for id := range m.removedchildren { + ids = append(ids, id) + } + return ids + case resource.EdgePermissions: + ids := make([]ent.Value, 0, len(m.removedpermissions)) + for id := range m.removedpermissions { + ids = append(ids, id) + } + return ids + case resource.EdgePermissionResources: + ids := make([]ent.Value, 0, len(m.removedpermission_resources)) + for id := range m.removedpermission_resources { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ResourceMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedparent { + edges = append(edges, resource.EdgeParent) + } + if m.clearedchildren { + edges = append(edges, resource.EdgeChildren) + } + if m.clearedpermissions { + edges = append(edges, resource.EdgePermissions) + } + if m.clearedpermission_resources { + edges = append(edges, resource.EdgePermissionResources) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ResourceMutation) EdgeCleared(name string) bool { + switch name { + case resource.EdgeParent: + return m.clearedparent + case resource.EdgeChildren: + return m.clearedchildren + case resource.EdgePermissions: + return m.clearedpermissions + case resource.EdgePermissionResources: + return m.clearedpermission_resources + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ResourceMutation) ClearEdge(name string) error { + switch name { + case resource.EdgeParent: + m.ClearParent() + return nil + } + return fmt.Errorf("unknown Resource unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ResourceMutation) ResetEdge(name string) error { + switch name { + case resource.EdgeParent: + m.ResetParent() + return nil + case resource.EdgeChildren: + m.ResetChildren() + return nil + case resource.EdgePermissions: + m.ResetPermissions() + return nil + case resource.EdgePermissionResources: + m.ResetPermissionResources() + return nil + } + return fmt.Errorf("unknown Resource edge %s", name) +} + +// RoleMutation represents an operation that mutates the Role nodes in the graph. +type RoleMutation struct { + config + op Op + typ string + id *int64 + create_time *time.Time + update_time *time.Time + keyword *string + name *string + description *string + _type *int8 + add_type *int8 + sequence *int + addsequence *int + status *int8 + addstatus *int8 + clearedFields map[string]struct{} + users map[int64]struct{} + removedusers map[int64]struct{} + clearedusers bool + permissions map[int64]struct{} + removedpermissions map[int64]struct{} + clearedpermissions bool + user_roles map[int]struct{} + removeduser_roles map[int]struct{} + cleareduser_roles bool + role_permissions map[int]struct{} + removedrole_permissions map[int]struct{} + clearedrole_permissions bool + done bool + oldValue func(context.Context) (*Role, error) + predicates []predicate.Role +} + +var _ ent.Mutation = (*RoleMutation)(nil) + +// roleOption allows management of the mutation configuration using functional options. +type roleOption func(*RoleMutation) + +// newRoleMutation creates new mutation for the Role entity. +func newRoleMutation(c config, op Op, opts ...roleOption) *RoleMutation { + m := &RoleMutation{ + config: c, + op: op, + typ: TypeRole, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withRoleID sets the ID field of the mutation. +func withRoleID(id int64) roleOption { + return func(m *RoleMutation) { + var ( + err error + once sync.Once + value *Role + ) + m.oldValue = func(ctx context.Context) (*Role, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Role.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withRole sets the old Role of the mutation. +func withRole(node *Role) roleOption { + return func(m *RoleMutation) { + m.oldValue = func(context.Context) (*Role, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m RoleMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m RoleMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Role entities. +func (m *RoleMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *RoleMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *RoleMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Role.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateTime sets the "create_time" field. +func (m *RoleMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *RoleMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *RoleMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *RoleMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *RoleMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *RoleMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetKeyword sets the "keyword" field. +func (m *RoleMutation) SetKeyword(s string) { + m.keyword = &s +} + +// Keyword returns the value of the "keyword" field in the mutation. +func (m *RoleMutation) Keyword() (r string, exists bool) { + v := m.keyword + if v == nil { + return + } + return *v, true +} + +// OldKeyword returns the old "keyword" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldKeyword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKeyword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKeyword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKeyword: %w", err) + } + return oldValue.Keyword, nil +} + +// ResetKeyword resets all changes to the "keyword" field. +func (m *RoleMutation) ResetKeyword() { + m.keyword = nil +} + +// SetName sets the "name" field. +func (m *RoleMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *RoleMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *RoleMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *RoleMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *RoleMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ResetDescription resets all changes to the "description" field. +func (m *RoleMutation) ResetDescription() { + m.description = nil +} + +// SetType sets the "type" field. +func (m *RoleMutation) SetType(i int8) { + m._type = &i + m.add_type = nil +} + +// GetType returns the value of the "type" field in the mutation. +func (m *RoleMutation) GetType() (r int8, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldType(ctx context.Context) (v int8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// AddType adds i to the "type" field. +func (m *RoleMutation) AddType(i int8) { + if m.add_type != nil { + *m.add_type += i + } else { + m.add_type = &i + } +} + +// AddedType returns the value that was added to the "type" field in this mutation. +func (m *RoleMutation) AddedType() (r int8, exists bool) { + v := m.add_type + if v == nil { + return + } + return *v, true +} + +// ResetType resets all changes to the "type" field. +func (m *RoleMutation) ResetType() { + m._type = nil + m.add_type = nil +} + +// SetSequence sets the "sequence" field. +func (m *RoleMutation) SetSequence(i int) { + m.sequence = &i + m.addsequence = nil +} + +// Sequence returns the value of the "sequence" field in the mutation. +func (m *RoleMutation) Sequence() (r int, exists bool) { + v := m.sequence + if v == nil { + return + } + return *v, true +} + +// OldSequence returns the old "sequence" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldSequence(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSequence is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSequence requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSequence: %w", err) + } + return oldValue.Sequence, nil +} + +// AddSequence adds i to the "sequence" field. +func (m *RoleMutation) AddSequence(i int) { + if m.addsequence != nil { + *m.addsequence += i + } else { + m.addsequence = &i + } +} + +// AddedSequence returns the value that was added to the "sequence" field in this mutation. +func (m *RoleMutation) AddedSequence() (r int, exists bool) { + v := m.addsequence + if v == nil { + return + } + return *v, true +} + +// ResetSequence resets all changes to the "sequence" field. +func (m *RoleMutation) ResetSequence() { + m.sequence = nil + m.addsequence = nil +} + +// SetStatus sets the "status" field. +func (m *RoleMutation) SetStatus(i int8) { + m.status = &i + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *RoleMutation) Status() (r int8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldStatus(ctx context.Context) (v int8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds i to the "status" field. +func (m *RoleMutation) AddStatus(i int8) { + if m.addstatus != nil { + *m.addstatus += i + } else { + m.addstatus = &i + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *RoleMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ResetStatus resets all changes to the "status" field. +func (m *RoleMutation) ResetStatus() { + m.status = nil + m.addstatus = nil +} + +// AddUserIDs adds the "users" edge to the User entity by ids. +func (m *RoleMutation) AddUserIDs(ids ...int64) { + if m.users == nil { + m.users = make(map[int64]struct{}) + } + for i := range ids { + m.users[ids[i]] = struct{}{} + } +} + +// ClearUsers clears the "users" edge to the User entity. +func (m *RoleMutation) ClearUsers() { + m.clearedusers = true +} + +// UsersCleared reports if the "users" edge to the User entity was cleared. +func (m *RoleMutation) UsersCleared() bool { + return m.clearedusers +} + +// RemoveUserIDs removes the "users" edge to the User entity by IDs. +func (m *RoleMutation) RemoveUserIDs(ids ...int64) { + if m.removedusers == nil { + m.removedusers = make(map[int64]struct{}) + } + for i := range ids { + delete(m.users, ids[i]) + m.removedusers[ids[i]] = struct{}{} + } +} + +// RemovedUsers returns the removed IDs of the "users" edge to the User entity. +func (m *RoleMutation) RemovedUsersIDs() (ids []int64) { + for id := range m.removedusers { + ids = append(ids, id) + } + return +} + +// UsersIDs returns the "users" edge IDs in the mutation. +func (m *RoleMutation) UsersIDs() (ids []int64) { + for id := range m.users { + ids = append(ids, id) + } + return +} + +// ResetUsers resets all changes to the "users" edge. +func (m *RoleMutation) ResetUsers() { + m.users = nil + m.clearedusers = false + m.removedusers = nil +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by ids. +func (m *RoleMutation) AddPermissionIDs(ids ...int64) { + if m.permissions == nil { + m.permissions = make(map[int64]struct{}) + } + for i := range ids { + m.permissions[ids[i]] = struct{}{} + } +} + +// ClearPermissions clears the "permissions" edge to the Permission entity. +func (m *RoleMutation) ClearPermissions() { + m.clearedpermissions = true +} + +// PermissionsCleared reports if the "permissions" edge to the Permission entity was cleared. +func (m *RoleMutation) PermissionsCleared() bool { + return m.clearedpermissions +} + +// RemovePermissionIDs removes the "permissions" edge to the Permission entity by IDs. +func (m *RoleMutation) RemovePermissionIDs(ids ...int64) { + if m.removedpermissions == nil { + m.removedpermissions = make(map[int64]struct{}) + } + for i := range ids { + delete(m.permissions, ids[i]) + m.removedpermissions[ids[i]] = struct{}{} + } +} + +// RemovedPermissions returns the removed IDs of the "permissions" edge to the Permission entity. +func (m *RoleMutation) RemovedPermissionsIDs() (ids []int64) { + for id := range m.removedpermissions { + ids = append(ids, id) + } + return +} + +// PermissionsIDs returns the "permissions" edge IDs in the mutation. +func (m *RoleMutation) PermissionsIDs() (ids []int64) { + for id := range m.permissions { + ids = append(ids, id) + } + return +} + +// ResetPermissions resets all changes to the "permissions" edge. +func (m *RoleMutation) ResetPermissions() { + m.permissions = nil + m.clearedpermissions = false + m.removedpermissions = nil +} + +// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by ids. +func (m *RoleMutation) AddUserRoleIDs(ids ...int) { + if m.user_roles == nil { + m.user_roles = make(map[int]struct{}) + } + for i := range ids { + m.user_roles[ids[i]] = struct{}{} + } +} + +// ClearUserRoles clears the "user_roles" edge to the UserRole entity. +func (m *RoleMutation) ClearUserRoles() { + m.cleareduser_roles = true +} + +// UserRolesCleared reports if the "user_roles" edge to the UserRole entity was cleared. +func (m *RoleMutation) UserRolesCleared() bool { + return m.cleareduser_roles +} + +// RemoveUserRoleIDs removes the "user_roles" edge to the UserRole entity by IDs. +func (m *RoleMutation) RemoveUserRoleIDs(ids ...int) { + if m.removeduser_roles == nil { + m.removeduser_roles = make(map[int]struct{}) + } + for i := range ids { + delete(m.user_roles, ids[i]) + m.removeduser_roles[ids[i]] = struct{}{} + } +} + +// RemovedUserRoles returns the removed IDs of the "user_roles" edge to the UserRole entity. +func (m *RoleMutation) RemovedUserRolesIDs() (ids []int) { + for id := range m.removeduser_roles { + ids = append(ids, id) + } + return +} + +// UserRolesIDs returns the "user_roles" edge IDs in the mutation. +func (m *RoleMutation) UserRolesIDs() (ids []int) { + for id := range m.user_roles { + ids = append(ids, id) + } + return +} + +// ResetUserRoles resets all changes to the "user_roles" edge. +func (m *RoleMutation) ResetUserRoles() { + m.user_roles = nil + m.cleareduser_roles = false + m.removeduser_roles = nil +} + +// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by ids. +func (m *RoleMutation) AddRolePermissionIDs(ids ...int) { + if m.role_permissions == nil { + m.role_permissions = make(map[int]struct{}) + } + for i := range ids { + m.role_permissions[ids[i]] = struct{}{} + } +} + +// ClearRolePermissions clears the "role_permissions" edge to the RolePermission entity. +func (m *RoleMutation) ClearRolePermissions() { + m.clearedrole_permissions = true +} + +// RolePermissionsCleared reports if the "role_permissions" edge to the RolePermission entity was cleared. +func (m *RoleMutation) RolePermissionsCleared() bool { + return m.clearedrole_permissions +} + +// RemoveRolePermissionIDs removes the "role_permissions" edge to the RolePermission entity by IDs. +func (m *RoleMutation) RemoveRolePermissionIDs(ids ...int) { + if m.removedrole_permissions == nil { + m.removedrole_permissions = make(map[int]struct{}) + } + for i := range ids { + delete(m.role_permissions, ids[i]) + m.removedrole_permissions[ids[i]] = struct{}{} + } +} + +// RemovedRolePermissions returns the removed IDs of the "role_permissions" edge to the RolePermission entity. +func (m *RoleMutation) RemovedRolePermissionsIDs() (ids []int) { + for id := range m.removedrole_permissions { + ids = append(ids, id) + } + return +} + +// RolePermissionsIDs returns the "role_permissions" edge IDs in the mutation. +func (m *RoleMutation) RolePermissionsIDs() (ids []int) { + for id := range m.role_permissions { + ids = append(ids, id) + } + return +} + +// ResetRolePermissions resets all changes to the "role_permissions" edge. +func (m *RoleMutation) ResetRolePermissions() { + m.role_permissions = nil + m.clearedrole_permissions = false + m.removedrole_permissions = nil +} + +// Where appends a list predicates to the RoleMutation builder. +func (m *RoleMutation) Where(ps ...predicate.Role) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the RoleMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *RoleMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Role, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *RoleMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *RoleMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (Role). +func (m *RoleMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *RoleMutation) Fields() []string { + fields := make([]string, 0, 8) + if m.create_time != nil { + fields = append(fields, role.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, role.FieldUpdateTime) + } + if m.keyword != nil { + fields = append(fields, role.FieldKeyword) + } + if m.name != nil { + fields = append(fields, role.FieldName) + } + if m.description != nil { + fields = append(fields, role.FieldDescription) + } + if m._type != nil { + fields = append(fields, role.FieldType) + } + if m.sequence != nil { + fields = append(fields, role.FieldSequence) + } + if m.status != nil { + fields = append(fields, role.FieldStatus) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *RoleMutation) Field(name string) (ent.Value, bool) { + switch name { + case role.FieldCreateTime: + return m.CreateTime() + case role.FieldUpdateTime: + return m.UpdateTime() + case role.FieldKeyword: + return m.Keyword() + case role.FieldName: + return m.Name() + case role.FieldDescription: + return m.Description() + case role.FieldType: + return m.GetType() + case role.FieldSequence: + return m.Sequence() + case role.FieldStatus: + return m.Status() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *RoleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case role.FieldCreateTime: + return m.OldCreateTime(ctx) + case role.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case role.FieldKeyword: + return m.OldKeyword(ctx) + case role.FieldName: + return m.OldName(ctx) + case role.FieldDescription: + return m.OldDescription(ctx) + case role.FieldType: + return m.OldType(ctx) + case role.FieldSequence: + return m.OldSequence(ctx) + case role.FieldStatus: + return m.OldStatus(ctx) + } + return nil, fmt.Errorf("unknown Role field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *RoleMutation) SetField(name string, value ent.Value) error { + switch name { + case role.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case role.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case role.FieldKeyword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKeyword(v) + return nil + case role.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case role.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case role.FieldType: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case role.FieldSequence: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSequence(v) + return nil + case role.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + } + return fmt.Errorf("unknown Role field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *RoleMutation) AddedFields() []string { + var fields []string + if m.add_type != nil { + fields = append(fields, role.FieldType) + } + if m.addsequence != nil { + fields = append(fields, role.FieldSequence) + } + if m.addstatus != nil { + fields = append(fields, role.FieldStatus) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *RoleMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case role.FieldType: + return m.AddedType() + case role.FieldSequence: + return m.AddedSequence() + case role.FieldStatus: + return m.AddedStatus() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *RoleMutation) AddField(name string, value ent.Value) error { + switch name { + case role.FieldType: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddType(v) + return nil + case role.FieldSequence: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSequence(v) + return nil + case role.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + } + return fmt.Errorf("unknown Role numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *RoleMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *RoleMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *RoleMutation) ClearField(name string) error { + return fmt.Errorf("unknown Role nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *RoleMutation) ResetField(name string) error { + switch name { + case role.FieldCreateTime: + m.ResetCreateTime() + return nil + case role.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case role.FieldKeyword: + m.ResetKeyword() + return nil + case role.FieldName: + m.ResetName() + return nil + case role.FieldDescription: + m.ResetDescription() + return nil + case role.FieldType: + m.ResetType() + return nil + case role.FieldSequence: + m.ResetSequence() + return nil + case role.FieldStatus: + m.ResetStatus() + return nil + } + return fmt.Errorf("unknown Role field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *RoleMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.users != nil { + edges = append(edges, role.EdgeUsers) + } + if m.permissions != nil { + edges = append(edges, role.EdgePermissions) + } + if m.user_roles != nil { + edges = append(edges, role.EdgeUserRoles) + } + if m.role_permissions != nil { + edges = append(edges, role.EdgeRolePermissions) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *RoleMutation) AddedIDs(name string) []ent.Value { + switch name { + case role.EdgeUsers: + ids := make([]ent.Value, 0, len(m.users)) + for id := range m.users { + ids = append(ids, id) + } + return ids + case role.EdgePermissions: + ids := make([]ent.Value, 0, len(m.permissions)) + for id := range m.permissions { + ids = append(ids, id) + } + return ids + case role.EdgeUserRoles: + ids := make([]ent.Value, 0, len(m.user_roles)) + for id := range m.user_roles { + ids = append(ids, id) + } + return ids + case role.EdgeRolePermissions: + ids := make([]ent.Value, 0, len(m.role_permissions)) + for id := range m.role_permissions { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *RoleMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedusers != nil { + edges = append(edges, role.EdgeUsers) + } + if m.removedpermissions != nil { + edges = append(edges, role.EdgePermissions) + } + if m.removeduser_roles != nil { + edges = append(edges, role.EdgeUserRoles) + } + if m.removedrole_permissions != nil { + edges = append(edges, role.EdgeRolePermissions) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *RoleMutation) RemovedIDs(name string) []ent.Value { + switch name { + case role.EdgeUsers: + ids := make([]ent.Value, 0, len(m.removedusers)) + for id := range m.removedusers { + ids = append(ids, id) + } + return ids + case role.EdgePermissions: + ids := make([]ent.Value, 0, len(m.removedpermissions)) + for id := range m.removedpermissions { + ids = append(ids, id) + } + return ids + case role.EdgeUserRoles: + ids := make([]ent.Value, 0, len(m.removeduser_roles)) + for id := range m.removeduser_roles { + ids = append(ids, id) + } + return ids + case role.EdgeRolePermissions: + ids := make([]ent.Value, 0, len(m.removedrole_permissions)) + for id := range m.removedrole_permissions { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *RoleMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedusers { + edges = append(edges, role.EdgeUsers) + } + if m.clearedpermissions { + edges = append(edges, role.EdgePermissions) + } + if m.cleareduser_roles { + edges = append(edges, role.EdgeUserRoles) + } + if m.clearedrole_permissions { + edges = append(edges, role.EdgeRolePermissions) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *RoleMutation) EdgeCleared(name string) bool { + switch name { + case role.EdgeUsers: + return m.clearedusers + case role.EdgePermissions: + return m.clearedpermissions + case role.EdgeUserRoles: + return m.cleareduser_roles + case role.EdgeRolePermissions: + return m.clearedrole_permissions + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *RoleMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Role unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *RoleMutation) ResetEdge(name string) error { + switch name { + case role.EdgeUsers: + m.ResetUsers() + return nil + case role.EdgePermissions: + m.ResetPermissions() + return nil + case role.EdgeUserRoles: + m.ResetUserRoles() + return nil + case role.EdgeRolePermissions: + m.ResetRolePermissions() + return nil + } + return fmt.Errorf("unknown Role edge %s", name) +} + +// RolePermissionMutation represents an operation that mutates the RolePermission nodes in the graph. +type RolePermissionMutation struct { + config + op Op + typ string + id *int + clearedFields map[string]struct{} + role *int64 + clearedrole bool + permission *int64 + clearedpermission bool + done bool + oldValue func(context.Context) (*RolePermission, error) + predicates []predicate.RolePermission +} + +var _ ent.Mutation = (*RolePermissionMutation)(nil) + +// rolepermissionOption allows management of the mutation configuration using functional options. +type rolepermissionOption func(*RolePermissionMutation) + +// newRolePermissionMutation creates new mutation for the RolePermission entity. +func newRolePermissionMutation(c config, op Op, opts ...rolepermissionOption) *RolePermissionMutation { + m := &RolePermissionMutation{ + config: c, + op: op, + typ: TypeRolePermission, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withRolePermissionID sets the ID field of the mutation. +func withRolePermissionID(id int) rolepermissionOption { + return func(m *RolePermissionMutation) { + var ( + err error + once sync.Once + value *RolePermission + ) + m.oldValue = func(ctx context.Context) (*RolePermission, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().RolePermission.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withRolePermission sets the old RolePermission of the mutation. +func withRolePermission(node *RolePermission) rolepermissionOption { + return func(m *RolePermissionMutation) { + m.oldValue = func(context.Context) (*RolePermission, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m RolePermissionMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m RolePermissionMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *RolePermissionMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *RolePermissionMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().RolePermission.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetRoleID sets the "role_id" field. +func (m *RolePermissionMutation) SetRoleID(i int64) { + m.role = &i +} + +// RoleID returns the value of the "role_id" field in the mutation. +func (m *RolePermissionMutation) RoleID() (r int64, exists bool) { + v := m.role + if v == nil { + return + } + return *v, true +} + +// OldRoleID returns the old "role_id" field's value of the RolePermission entity. +// If the RolePermission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RolePermissionMutation) OldRoleID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRoleID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRoleID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRoleID: %w", err) + } + return oldValue.RoleID, nil +} + +// ResetRoleID resets all changes to the "role_id" field. +func (m *RolePermissionMutation) ResetRoleID() { + m.role = nil +} + +// SetPermissionID sets the "permission_id" field. +func (m *RolePermissionMutation) SetPermissionID(i int64) { + m.permission = &i +} + +// PermissionID returns the value of the "permission_id" field in the mutation. +func (m *RolePermissionMutation) PermissionID() (r int64, exists bool) { + v := m.permission + if v == nil { + return + } + return *v, true +} + +// OldPermissionID returns the old "permission_id" field's value of the RolePermission entity. +// If the RolePermission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RolePermissionMutation) OldPermissionID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPermissionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPermissionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPermissionID: %w", err) + } + return oldValue.PermissionID, nil +} + +// ResetPermissionID resets all changes to the "permission_id" field. +func (m *RolePermissionMutation) ResetPermissionID() { + m.permission = nil +} + +// ClearRole clears the "role" edge to the Role entity. +func (m *RolePermissionMutation) ClearRole() { + m.clearedrole = true + m.clearedFields[rolepermission.FieldRoleID] = struct{}{} +} + +// RoleCleared reports if the "role" edge to the Role entity was cleared. +func (m *RolePermissionMutation) RoleCleared() bool { + return m.clearedrole +} + +// RoleIDs returns the "role" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// RoleID instead. It exists only for internal usage by the builders. +func (m *RolePermissionMutation) RoleIDs() (ids []int64) { + if id := m.role; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetRole resets all changes to the "role" edge. +func (m *RolePermissionMutation) ResetRole() { + m.role = nil + m.clearedrole = false +} + +// ClearPermission clears the "permission" edge to the Permission entity. +func (m *RolePermissionMutation) ClearPermission() { + m.clearedpermission = true + m.clearedFields[rolepermission.FieldPermissionID] = struct{}{} +} + +// PermissionCleared reports if the "permission" edge to the Permission entity was cleared. +func (m *RolePermissionMutation) PermissionCleared() bool { + return m.clearedpermission +} + +// PermissionIDs returns the "permission" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PermissionID instead. It exists only for internal usage by the builders. +func (m *RolePermissionMutation) PermissionIDs() (ids []int64) { + if id := m.permission; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetPermission resets all changes to the "permission" edge. +func (m *RolePermissionMutation) ResetPermission() { + m.permission = nil + m.clearedpermission = false +} + +// Where appends a list predicates to the RolePermissionMutation builder. +func (m *RolePermissionMutation) Where(ps ...predicate.RolePermission) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the RolePermissionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *RolePermissionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.RolePermission, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *RolePermissionMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *RolePermissionMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (RolePermission). +func (m *RolePermissionMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *RolePermissionMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.role != nil { + fields = append(fields, rolepermission.FieldRoleID) + } + if m.permission != nil { + fields = append(fields, rolepermission.FieldPermissionID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *RolePermissionMutation) Field(name string) (ent.Value, bool) { + switch name { + case rolepermission.FieldRoleID: + return m.RoleID() + case rolepermission.FieldPermissionID: + return m.PermissionID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *RolePermissionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case rolepermission.FieldRoleID: + return m.OldRoleID(ctx) + case rolepermission.FieldPermissionID: + return m.OldPermissionID(ctx) + } + return nil, fmt.Errorf("unknown RolePermission field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *RolePermissionMutation) SetField(name string, value ent.Value) error { + switch name { + case rolepermission.FieldRoleID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRoleID(v) + return nil + case rolepermission.FieldPermissionID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPermissionID(v) + return nil + } + return fmt.Errorf("unknown RolePermission field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *RolePermissionMutation) AddedFields() []string { + var fields []string + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *RolePermissionMutation) AddedField(name string) (ent.Value, bool) { + switch name { + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *RolePermissionMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown RolePermission numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *RolePermissionMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *RolePermissionMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *RolePermissionMutation) ClearField(name string) error { + return fmt.Errorf("unknown RolePermission nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *RolePermissionMutation) ResetField(name string) error { + switch name { + case rolepermission.FieldRoleID: + m.ResetRoleID() + return nil + case rolepermission.FieldPermissionID: + m.ResetPermissionID() + return nil + } + return fmt.Errorf("unknown RolePermission field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *RolePermissionMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.role != nil { + edges = append(edges, rolepermission.EdgeRole) + } + if m.permission != nil { + edges = append(edges, rolepermission.EdgePermission) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *RolePermissionMutation) AddedIDs(name string) []ent.Value { + switch name { + case rolepermission.EdgeRole: + if id := m.role; id != nil { + return []ent.Value{*id} + } + case rolepermission.EdgePermission: + if id := m.permission; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *RolePermissionMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *RolePermissionMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *RolePermissionMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedrole { + edges = append(edges, rolepermission.EdgeRole) + } + if m.clearedpermission { + edges = append(edges, rolepermission.EdgePermission) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *RolePermissionMutation) EdgeCleared(name string) bool { + switch name { + case rolepermission.EdgeRole: + return m.clearedrole + case rolepermission.EdgePermission: + return m.clearedpermission + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *RolePermissionMutation) ClearEdge(name string) error { + switch name { + case rolepermission.EdgeRole: + m.ClearRole() + return nil + case rolepermission.EdgePermission: + m.ClearPermission() + return nil + } + return fmt.Errorf("unknown RolePermission unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *RolePermissionMutation) ResetEdge(name string) error { + switch name { + case rolepermission.EdgeRole: + m.ResetRole() + return nil + case rolepermission.EdgePermission: + m.ResetPermission() + return nil + } + return fmt.Errorf("unknown RolePermission edge %s", name) +} + +// UserMutation represents an operation that mutates the User nodes in the graph. +type UserMutation struct { + config + op Op + typ string + id *int64 + create_time *time.Time + update_time *time.Time + uuid *string + allowed_ip *string + username *string + nickname *string + avatar *string + name *string + gender *user.Gender + password *string + phone *string + email *string + department *string + remark *string + status *int8 + addstatus *int8 + is_system *bool + last_login_ip *string + last_login_time *time.Time + clearedFields map[string]struct{} + roles map[int64]struct{} + removedroles map[int64]struct{} + clearedroles bool + user_roles map[int]struct{} + removeduser_roles map[int]struct{} + cleareduser_roles bool + done bool + oldValue func(context.Context) (*User, error) + predicates []predicate.User +} + +var _ ent.Mutation = (*UserMutation)(nil) + +// userOption allows management of the mutation configuration using functional options. +type userOption func(*UserMutation) + +// newUserMutation creates new mutation for the User entity. +func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { + m := &UserMutation{ + config: c, + op: op, + typ: TypeUser, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserID sets the ID field of the mutation. +func withUserID(id int64) userOption { + return func(m *UserMutation) { + var ( + err error + once sync.Once + value *User + ) + m.oldValue = func(ctx context.Context) (*User, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().User.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUser sets the old User of the mutation. +func withUser(node *User) userOption { + return func(m *UserMutation) { + m.oldValue = func(context.Context) (*User, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m UserMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m UserMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of User entities. +func (m *UserMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *UserMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *UserMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().User.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateTime sets the "create_time" field. +func (m *UserMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *UserMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *UserMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *UserMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *UserMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *UserMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetUUID sets the "uuid" field. +func (m *UserMutation) SetUUID(s string) { + m.uuid = &s +} + +// UUID returns the value of the "uuid" field in the mutation. +func (m *UserMutation) UUID() (r string, exists bool) { + v := m.uuid + if v == nil { + return + } + return *v, true +} + +// OldUUID returns the old "uuid" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUUID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUUID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUUID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUUID: %w", err) + } + return oldValue.UUID, nil +} + +// ResetUUID resets all changes to the "uuid" field. +func (m *UserMutation) ResetUUID() { + m.uuid = nil +} + +// SetAllowedIP sets the "allowed_ip" field. +func (m *UserMutation) SetAllowedIP(s string) { + m.allowed_ip = &s +} + +// AllowedIP returns the value of the "allowed_ip" field in the mutation. +func (m *UserMutation) AllowedIP() (r string, exists bool) { + v := m.allowed_ip + if v == nil { + return + } + return *v, true +} + +// OldAllowedIP returns the old "allowed_ip" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldAllowedIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAllowedIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAllowedIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAllowedIP: %w", err) + } + return oldValue.AllowedIP, nil +} + +// ResetAllowedIP resets all changes to the "allowed_ip" field. +func (m *UserMutation) ResetAllowedIP() { + m.allowed_ip = nil +} + +// SetUsername sets the "username" field. +func (m *UserMutation) SetUsername(s string) { + m.username = &s +} + +// Username returns the value of the "username" field in the mutation. +func (m *UserMutation) Username() (r string, exists bool) { + v := m.username + if v == nil { + return + } + return *v, true +} + +// OldUsername returns the old "username" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUsername is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUsername requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUsername: %w", err) + } + return oldValue.Username, nil +} + +// ResetUsername resets all changes to the "username" field. +func (m *UserMutation) ResetUsername() { + m.username = nil +} + +// SetNickname sets the "nickname" field. +func (m *UserMutation) SetNickname(s string) { + m.nickname = &s +} + +// Nickname returns the value of the "nickname" field in the mutation. +func (m *UserMutation) Nickname() (r string, exists bool) { + v := m.nickname + if v == nil { + return + } + return *v, true +} + +// OldNickname returns the old "nickname" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldNickname(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNickname is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNickname requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNickname: %w", err) + } + return oldValue.Nickname, nil +} + +// ResetNickname resets all changes to the "nickname" field. +func (m *UserMutation) ResetNickname() { + m.nickname = nil +} + +// SetAvatar sets the "avatar" field. +func (m *UserMutation) SetAvatar(s string) { + m.avatar = &s +} + +// Avatar returns the value of the "avatar" field in the mutation. +func (m *UserMutation) Avatar() (r string, exists bool) { + v := m.avatar + if v == nil { + return + } + return *v, true +} + +// OldAvatar returns the old "avatar" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldAvatar(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAvatar is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAvatar requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAvatar: %w", err) + } + return oldValue.Avatar, nil +} + +// ResetAvatar resets all changes to the "avatar" field. +func (m *UserMutation) ResetAvatar() { + m.avatar = nil +} + +// SetName sets the "name" field. +func (m *UserMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *UserMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return + } + return *v, true +} + +// OldName returns the old "name" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) + } + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *UserMutation) ResetName() { + m.name = nil +} + +// SetGender sets the "gender" field. +func (m *UserMutation) SetGender(u user.Gender) { + m.gender = &u +} + +// Gender returns the value of the "gender" field in the mutation. +func (m *UserMutation) Gender() (r user.Gender, exists bool) { + v := m.gender + if v == nil { + return + } + return *v, true +} + +// OldGender returns the old "gender" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldGender(ctx context.Context) (v user.Gender, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGender is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGender requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGender: %w", err) + } + return oldValue.Gender, nil +} + +// ResetGender resets all changes to the "gender" field. +func (m *UserMutation) ResetGender() { + m.gender = nil +} + +// SetPassword sets the "password" field. +func (m *UserMutation) SetPassword(s string) { + m.password = &s +} + +// Password returns the value of the "password" field in the mutation. +func (m *UserMutation) Password() (r string, exists bool) { + v := m.password + if v == nil { + return + } + return *v, true +} + +// OldPassword returns the old "password" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPassword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPassword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPassword: %w", err) + } + return oldValue.Password, nil +} + +// ResetPassword resets all changes to the "password" field. +func (m *UserMutation) ResetPassword() { + m.password = nil +} + +// SetPhone sets the "phone" field. +func (m *UserMutation) SetPhone(s string) { + m.phone = &s +} + +// Phone returns the value of the "phone" field in the mutation. +func (m *UserMutation) Phone() (r string, exists bool) { + v := m.phone + if v == nil { + return + } + return *v, true +} + +// OldPhone returns the old "phone" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldPhone(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPhone is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPhone requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPhone: %w", err) + } + return oldValue.Phone, nil +} + +// ResetPhone resets all changes to the "phone" field. +func (m *UserMutation) ResetPhone() { + m.phone = nil +} + +// SetEmail sets the "email" field. +func (m *UserMutation) SetEmail(s string) { + m.email = &s +} + +// Email returns the value of the "email" field in the mutation. +func (m *UserMutation) Email() (r string, exists bool) { + v := m.email + if v == nil { + return + } + return *v, true +} + +// OldEmail returns the old "email" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEmail is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEmail requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEmail: %w", err) + } + return oldValue.Email, nil +} + +// ResetEmail resets all changes to the "email" field. +func (m *UserMutation) ResetEmail() { + m.email = nil +} + +// SetDepartment sets the "department" field. +func (m *UserMutation) SetDepartment(s string) { + m.department = &s +} + +// Department returns the value of the "department" field in the mutation. +func (m *UserMutation) Department() (r string, exists bool) { + v := m.department + if v == nil { + return + } + return *v, true +} + +// OldDepartment returns the old "department" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldDepartment(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDepartment is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDepartment requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDepartment: %w", err) + } + return oldValue.Department, nil +} + +// ResetDepartment resets all changes to the "department" field. +func (m *UserMutation) ResetDepartment() { + m.department = nil +} + +// SetRemark sets the "remark" field. +func (m *UserMutation) SetRemark(s string) { + m.remark = &s +} + +// Remark returns the value of the "remark" field in the mutation. +func (m *UserMutation) Remark() (r string, exists bool) { + v := m.remark + if v == nil { + return + } + return *v, true +} + +// OldRemark returns the old "remark" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldRemark(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRemark is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRemark requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRemark: %w", err) + } + return oldValue.Remark, nil +} + +// ResetRemark resets all changes to the "remark" field. +func (m *UserMutation) ResetRemark() { + m.remark = nil +} + +// SetStatus sets the "status" field. +func (m *UserMutation) SetStatus(i int8) { + m.status = &i + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *UserMutation) Status() (r int8, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldStatus(ctx context.Context) (v int8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds i to the "status" field. +func (m *UserMutation) AddStatus(i int8) { + if m.addstatus != nil { + *m.addstatus += i + } else { + m.addstatus = &i + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *UserMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ResetStatus resets all changes to the "status" field. +func (m *UserMutation) ResetStatus() { + m.status = nil + m.addstatus = nil +} + +// SetIsSystem sets the "is_system" field. +func (m *UserMutation) SetIsSystem(b bool) { + m.is_system = &b +} + +// IsSystem returns the value of the "is_system" field in the mutation. +func (m *UserMutation) IsSystem() (r bool, exists bool) { + v := m.is_system + if v == nil { + return + } + return *v, true +} + +// OldIsSystem returns the old "is_system" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldIsSystem(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsSystem is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsSystem requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsSystem: %w", err) + } + return oldValue.IsSystem, nil +} + +// ResetIsSystem resets all changes to the "is_system" field. +func (m *UserMutation) ResetIsSystem() { + m.is_system = nil +} + +// SetLastLoginIP sets the "last_login_ip" field. +func (m *UserMutation) SetLastLoginIP(s string) { + m.last_login_ip = &s +} + +// LastLoginIP returns the value of the "last_login_ip" field in the mutation. +func (m *UserMutation) LastLoginIP() (r string, exists bool) { + v := m.last_login_ip + if v == nil { + return + } + return *v, true +} + +// OldLastLoginIP returns the old "last_login_ip" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldLastLoginIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastLoginIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastLoginIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastLoginIP: %w", err) + } + return oldValue.LastLoginIP, nil +} + +// ResetLastLoginIP resets all changes to the "last_login_ip" field. +func (m *UserMutation) ResetLastLoginIP() { + m.last_login_ip = nil +} + +// SetLastLoginTime sets the "last_login_time" field. +func (m *UserMutation) SetLastLoginTime(t time.Time) { + m.last_login_time = &t +} + +// LastLoginTime returns the value of the "last_login_time" field in the mutation. +func (m *UserMutation) LastLoginTime() (r time.Time, exists bool) { + v := m.last_login_time + if v == nil { + return + } + return *v, true +} + +// OldLastLoginTime returns the old "last_login_time" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldLastLoginTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLastLoginTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLastLoginTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLastLoginTime: %w", err) + } + return oldValue.LastLoginTime, nil +} + +// ClearLastLoginTime clears the value of the "last_login_time" field. +func (m *UserMutation) ClearLastLoginTime() { + m.last_login_time = nil + m.clearedFields[user.FieldLastLoginTime] = struct{}{} +} + +// LastLoginTimeCleared returns if the "last_login_time" field was cleared in this mutation. +func (m *UserMutation) LastLoginTimeCleared() bool { + _, ok := m.clearedFields[user.FieldLastLoginTime] + return ok +} + +// ResetLastLoginTime resets all changes to the "last_login_time" field. +func (m *UserMutation) ResetLastLoginTime() { + m.last_login_time = nil + delete(m.clearedFields, user.FieldLastLoginTime) +} + +// AddRoleIDs adds the "roles" edge to the Role entity by ids. +func (m *UserMutation) AddRoleIDs(ids ...int64) { + if m.roles == nil { + m.roles = make(map[int64]struct{}) + } + for i := range ids { + m.roles[ids[i]] = struct{}{} + } +} + +// ClearRoles clears the "roles" edge to the Role entity. +func (m *UserMutation) ClearRoles() { + m.clearedroles = true +} + +// RolesCleared reports if the "roles" edge to the Role entity was cleared. +func (m *UserMutation) RolesCleared() bool { + return m.clearedroles +} + +// RemoveRoleIDs removes the "roles" edge to the Role entity by IDs. +func (m *UserMutation) RemoveRoleIDs(ids ...int64) { + if m.removedroles == nil { + m.removedroles = make(map[int64]struct{}) + } + for i := range ids { + delete(m.roles, ids[i]) + m.removedroles[ids[i]] = struct{}{} + } +} + +// RemovedRoles returns the removed IDs of the "roles" edge to the Role entity. +func (m *UserMutation) RemovedRolesIDs() (ids []int64) { + for id := range m.removedroles { + ids = append(ids, id) + } + return +} + +// RolesIDs returns the "roles" edge IDs in the mutation. +func (m *UserMutation) RolesIDs() (ids []int64) { + for id := range m.roles { + ids = append(ids, id) + } + return +} + +// ResetRoles resets all changes to the "roles" edge. +func (m *UserMutation) ResetRoles() { + m.roles = nil + m.clearedroles = false + m.removedroles = nil +} + +// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by ids. +func (m *UserMutation) AddUserRoleIDs(ids ...int) { + if m.user_roles == nil { + m.user_roles = make(map[int]struct{}) + } + for i := range ids { + m.user_roles[ids[i]] = struct{}{} + } +} + +// ClearUserRoles clears the "user_roles" edge to the UserRole entity. +func (m *UserMutation) ClearUserRoles() { + m.cleareduser_roles = true +} + +// UserRolesCleared reports if the "user_roles" edge to the UserRole entity was cleared. +func (m *UserMutation) UserRolesCleared() bool { + return m.cleareduser_roles +} + +// RemoveUserRoleIDs removes the "user_roles" edge to the UserRole entity by IDs. +func (m *UserMutation) RemoveUserRoleIDs(ids ...int) { + if m.removeduser_roles == nil { + m.removeduser_roles = make(map[int]struct{}) + } + for i := range ids { + delete(m.user_roles, ids[i]) + m.removeduser_roles[ids[i]] = struct{}{} + } +} + +// RemovedUserRoles returns the removed IDs of the "user_roles" edge to the UserRole entity. +func (m *UserMutation) RemovedUserRolesIDs() (ids []int) { + for id := range m.removeduser_roles { + ids = append(ids, id) + } + return +} + +// UserRolesIDs returns the "user_roles" edge IDs in the mutation. +func (m *UserMutation) UserRolesIDs() (ids []int) { + for id := range m.user_roles { + ids = append(ids, id) + } + return +} + +// ResetUserRoles resets all changes to the "user_roles" edge. +func (m *UserMutation) ResetUserRoles() { + m.user_roles = nil + m.cleareduser_roles = false + m.removeduser_roles = nil +} + +// Where appends a list predicates to the UserMutation builder. +func (m *UserMutation) Where(ps ...predicate.User) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.User, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (User). +func (m *UserMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UserMutation) Fields() []string { + fields := make([]string, 0, 18) + if m.create_time != nil { + fields = append(fields, user.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, user.FieldUpdateTime) + } + if m.uuid != nil { + fields = append(fields, user.FieldUUID) + } + if m.allowed_ip != nil { + fields = append(fields, user.FieldAllowedIP) + } + if m.username != nil { + fields = append(fields, user.FieldUsername) + } + if m.nickname != nil { + fields = append(fields, user.FieldNickname) + } + if m.avatar != nil { + fields = append(fields, user.FieldAvatar) + } + if m.name != nil { + fields = append(fields, user.FieldName) + } + if m.gender != nil { + fields = append(fields, user.FieldGender) + } + if m.password != nil { + fields = append(fields, user.FieldPassword) + } + if m.phone != nil { + fields = append(fields, user.FieldPhone) + } + if m.email != nil { + fields = append(fields, user.FieldEmail) + } + if m.department != nil { + fields = append(fields, user.FieldDepartment) + } + if m.remark != nil { + fields = append(fields, user.FieldRemark) + } + if m.status != nil { + fields = append(fields, user.FieldStatus) + } + if m.is_system != nil { + fields = append(fields, user.FieldIsSystem) + } + if m.last_login_ip != nil { + fields = append(fields, user.FieldLastLoginIP) + } + if m.last_login_time != nil { + fields = append(fields, user.FieldLastLoginTime) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UserMutation) Field(name string) (ent.Value, bool) { + switch name { + case user.FieldCreateTime: + return m.CreateTime() + case user.FieldUpdateTime: + return m.UpdateTime() + case user.FieldUUID: + return m.UUID() + case user.FieldAllowedIP: + return m.AllowedIP() + case user.FieldUsername: + return m.Username() + case user.FieldNickname: + return m.Nickname() + case user.FieldAvatar: + return m.Avatar() + case user.FieldName: + return m.Name() + case user.FieldGender: + return m.Gender() + case user.FieldPassword: + return m.Password() + case user.FieldPhone: + return m.Phone() + case user.FieldEmail: + return m.Email() + case user.FieldDepartment: + return m.Department() + case user.FieldRemark: + return m.Remark() + case user.FieldStatus: + return m.Status() + case user.FieldIsSystem: + return m.IsSystem() + case user.FieldLastLoginIP: + return m.LastLoginIP() + case user.FieldLastLoginTime: + return m.LastLoginTime() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case user.FieldCreateTime: + return m.OldCreateTime(ctx) + case user.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case user.FieldUUID: + return m.OldUUID(ctx) + case user.FieldAllowedIP: + return m.OldAllowedIP(ctx) + case user.FieldUsername: + return m.OldUsername(ctx) + case user.FieldNickname: + return m.OldNickname(ctx) + case user.FieldAvatar: + return m.OldAvatar(ctx) + case user.FieldName: + return m.OldName(ctx) + case user.FieldGender: + return m.OldGender(ctx) + case user.FieldPassword: + return m.OldPassword(ctx) + case user.FieldPhone: + return m.OldPhone(ctx) + case user.FieldEmail: + return m.OldEmail(ctx) + case user.FieldDepartment: + return m.OldDepartment(ctx) + case user.FieldRemark: + return m.OldRemark(ctx) + case user.FieldStatus: + return m.OldStatus(ctx) + case user.FieldIsSystem: + return m.OldIsSystem(ctx) + case user.FieldLastLoginIP: + return m.OldLastLoginIP(ctx) + case user.FieldLastLoginTime: + return m.OldLastLoginTime(ctx) + } + return nil, fmt.Errorf("unknown User field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) SetField(name string, value ent.Value) error { + switch name { + case user.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case user.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case user.FieldUUID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUUID(v) + return nil + case user.FieldAllowedIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAllowedIP(v) + return nil + case user.FieldUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsername(v) + return nil + case user.FieldNickname: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetNickname(v) + return nil + case user.FieldAvatar: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAvatar(v) + return nil + case user.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case user.FieldGender: + v, ok := value.(user.Gender) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGender(v) + return nil + case user.FieldPassword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPassword(v) + return nil + case user.FieldPhone: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPhone(v) + return nil + case user.FieldEmail: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmail(v) + return nil + case user.FieldDepartment: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDepartment(v) + return nil + case user.FieldRemark: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRemark(v) + return nil + case user.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case user.FieldIsSystem: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsSystem(v) + return nil + case user.FieldLastLoginIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastLoginIP(v) + return nil + case user.FieldLastLoginTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastLoginTime(v) + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserMutation) AddedFields() []string { + var fields []string + if m.addstatus != nil { + fields = append(fields, user.FieldStatus) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UserMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case user.FieldStatus: + return m.AddedStatus() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) AddField(name string, value ent.Value) error { + switch name { + case user.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + } + return fmt.Errorf("unknown User numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(user.FieldLastLoginTime) { + fields = append(fields, user.FieldLastLoginTime) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UserMutation) ClearField(name string) error { + switch name { + case user.FieldLastLoginTime: + m.ClearLastLoginTime() + return nil + } + return fmt.Errorf("unknown User nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *UserMutation) ResetField(name string) error { + switch name { + case user.FieldCreateTime: + m.ResetCreateTime() + return nil + case user.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case user.FieldUUID: + m.ResetUUID() + return nil + case user.FieldAllowedIP: + m.ResetAllowedIP() + return nil + case user.FieldUsername: + m.ResetUsername() + return nil + case user.FieldNickname: + m.ResetNickname() + return nil + case user.FieldAvatar: + m.ResetAvatar() + return nil + case user.FieldName: + m.ResetName() + return nil + case user.FieldGender: + m.ResetGender() + return nil + case user.FieldPassword: + m.ResetPassword() + return nil + case user.FieldPhone: + m.ResetPhone() + return nil + case user.FieldEmail: + m.ResetEmail() + return nil + case user.FieldDepartment: + m.ResetDepartment() + return nil + case user.FieldRemark: + m.ResetRemark() + return nil + case user.FieldStatus: + m.ResetStatus() + return nil + case user.FieldIsSystem: + m.ResetIsSystem() + return nil + case user.FieldLastLoginIP: + m.ResetLastLoginIP() + return nil + case user.FieldLastLoginTime: + m.ResetLastLoginTime() + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.roles != nil { + edges = append(edges, user.EdgeRoles) + } + if m.user_roles != nil { + edges = append(edges, user.EdgeUserRoles) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserMutation) AddedIDs(name string) []ent.Value { + switch name { + case user.EdgeRoles: + ids := make([]ent.Value, 0, len(m.roles)) + for id := range m.roles { + ids = append(ids, id) + } + return ids + case user.EdgeUserRoles: + ids := make([]ent.Value, 0, len(m.user_roles)) + for id := range m.user_roles { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedroles != nil { + edges = append(edges, user.EdgeRoles) + } + if m.removeduser_roles != nil { + edges = append(edges, user.EdgeUserRoles) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserMutation) RemovedIDs(name string) []ent.Value { + switch name { + case user.EdgeRoles: + ids := make([]ent.Value, 0, len(m.removedroles)) + for id := range m.removedroles { + ids = append(ids, id) + } + return ids + case user.EdgeUserRoles: + ids := make([]ent.Value, 0, len(m.removeduser_roles)) + for id := range m.removeduser_roles { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedroles { + edges = append(edges, user.EdgeRoles) + } + if m.cleareduser_roles { + edges = append(edges, user.EdgeUserRoles) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserMutation) EdgeCleared(name string) bool { + switch name { + case user.EdgeRoles: + return m.clearedroles + case user.EdgeUserRoles: + return m.cleareduser_roles + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown User unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *UserMutation) ResetEdge(name string) error { + switch name { + case user.EdgeRoles: + m.ResetRoles() + return nil + case user.EdgeUserRoles: + m.ResetUserRoles() + return nil + } + return fmt.Errorf("unknown User edge %s", name) +} + +// UserRoleMutation represents an operation that mutates the UserRole nodes in the graph. +type UserRoleMutation struct { + config + op Op + typ string + id *int + clearedFields map[string]struct{} + user *int64 + cleareduser bool + role *int64 + clearedrole bool + done bool + oldValue func(context.Context) (*UserRole, error) + predicates []predicate.UserRole +} + +var _ ent.Mutation = (*UserRoleMutation)(nil) + +// userroleOption allows management of the mutation configuration using functional options. +type userroleOption func(*UserRoleMutation) + +// newUserRoleMutation creates new mutation for the UserRole entity. +func newUserRoleMutation(c config, op Op, opts ...userroleOption) *UserRoleMutation { + m := &UserRoleMutation{ + config: c, + op: op, + typ: TypeUserRole, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserRoleID sets the ID field of the mutation. +func withUserRoleID(id int) userroleOption { + return func(m *UserRoleMutation) { + var ( + err error + once sync.Once + value *UserRole + ) + m.oldValue = func(ctx context.Context) (*UserRole, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().UserRole.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUserRole sets the old UserRole of the mutation. +func withUserRole(node *UserRole) userroleOption { + return func(m *UserRoleMutation) { + m.oldValue = func(context.Context) (*UserRole, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m UserRoleMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m UserRoleMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *UserRoleMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *UserRoleMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().UserRole.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetUserID sets the "user_id" field. +func (m *UserRoleMutation) SetUserID(i int64) { + m.user = &i +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *UserRoleMutation) UserID() (r int64, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the UserRole entity. +// If the UserRole object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserRoleMutation) OldUserID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *UserRoleMutation) ResetUserID() { + m.user = nil +} + +// SetRoleID sets the "role_id" field. +func (m *UserRoleMutation) SetRoleID(i int64) { + m.role = &i +} + +// RoleID returns the value of the "role_id" field in the mutation. +func (m *UserRoleMutation) RoleID() (r int64, exists bool) { + v := m.role + if v == nil { + return + } + return *v, true +} + +// OldRoleID returns the old "role_id" field's value of the UserRole entity. +// If the UserRole object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserRoleMutation) OldRoleID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRoleID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRoleID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRoleID: %w", err) + } + return oldValue.RoleID, nil +} + +// ResetRoleID resets all changes to the "role_id" field. +func (m *UserRoleMutation) ResetRoleID() { + m.role = nil +} + +// ClearUser clears the "user" edge to the User entity. +func (m *UserRoleMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[userrole.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *UserRoleMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *UserRoleMutation) UserIDs() (ids []int64) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *UserRoleMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// ClearRole clears the "role" edge to the Role entity. +func (m *UserRoleMutation) ClearRole() { + m.clearedrole = true + m.clearedFields[userrole.FieldRoleID] = struct{}{} +} + +// RoleCleared reports if the "role" edge to the Role entity was cleared. +func (m *UserRoleMutation) RoleCleared() bool { + return m.clearedrole +} + +// RoleIDs returns the "role" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// RoleID instead. It exists only for internal usage by the builders. +func (m *UserRoleMutation) RoleIDs() (ids []int64) { + if id := m.role; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetRole resets all changes to the "role" edge. +func (m *UserRoleMutation) ResetRole() { + m.role = nil + m.clearedrole = false +} + +// Where appends a list predicates to the UserRoleMutation builder. +func (m *UserRoleMutation) Where(ps ...predicate.UserRole) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserRoleMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserRoleMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserRole, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserRoleMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserRoleMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (UserRole). +func (m *UserRoleMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UserRoleMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.user != nil { + fields = append(fields, userrole.FieldUserID) + } + if m.role != nil { + fields = append(fields, userrole.FieldRoleID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UserRoleMutation) Field(name string) (ent.Value, bool) { + switch name { + case userrole.FieldUserID: + return m.UserID() + case userrole.FieldRoleID: + return m.RoleID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *UserRoleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case userrole.FieldUserID: + return m.OldUserID(ctx) + case userrole.FieldRoleID: + return m.OldRoleID(ctx) + } + return nil, fmt.Errorf("unknown UserRole field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserRoleMutation) SetField(name string, value ent.Value) error { + switch name { + case userrole.FieldUserID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case userrole.FieldRoleID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRoleID(v) + return nil + } + return fmt.Errorf("unknown UserRole field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserRoleMutation) AddedFields() []string { + var fields []string + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UserRoleMutation) AddedField(name string) (ent.Value, bool) { + switch name { + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserRoleMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown UserRole numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserRoleMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserRoleMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UserRoleMutation) ClearField(name string) error { + return fmt.Errorf("unknown UserRole nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *UserRoleMutation) ResetField(name string) error { + switch name { + case userrole.FieldUserID: + m.ResetUserID() + return nil + case userrole.FieldRoleID: + m.ResetRoleID() + return nil + } + return fmt.Errorf("unknown UserRole field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserRoleMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.user != nil { + edges = append(edges, userrole.EdgeUser) + } + if m.role != nil { + edges = append(edges, userrole.EdgeRole) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserRoleMutation) AddedIDs(name string) []ent.Value { + switch name { + case userrole.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + case userrole.EdgeRole: + if id := m.role; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserRoleMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserRoleMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserRoleMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.cleareduser { + edges = append(edges, userrole.EdgeUser) + } + if m.clearedrole { + edges = append(edges, userrole.EdgeRole) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserRoleMutation) EdgeCleared(name string) bool { + switch name { + case userrole.EdgeUser: + return m.cleareduser + case userrole.EdgeRole: + return m.clearedrole + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserRoleMutation) ClearEdge(name string) error { + switch name { + case userrole.EdgeUser: + m.ClearUser() + return nil + case userrole.EdgeRole: + m.ClearRole() + return nil + } + return fmt.Errorf("unknown UserRole unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *UserRoleMutation) ResetEdge(name string) error { + switch name { + case userrole.EdgeUser: + m.ResetUser() + return nil + case userrole.EdgeRole: + m.ResetRole() + return nil + } + return fmt.Errorf("unknown UserRole edge %s", name) +} diff --git a/internal/features/system/data/ent/mutation_fields.go b/internal/features/system/data/ent/mutation_fields.go new file mode 100644 index 00000000..844bc7ca --- /dev/null +++ b/internal/features/system/data/ent/mutation_fields.go @@ -0,0 +1,605 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" +) + +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *PermissionMutation) SetFields(input *Permission, fields ...string) error { + for i := range fields { + switch fields[i] { + case permission.FieldCreateTime: + if input.CreateTime.Unix() != 0 { + m.SetCreateTime(input.CreateTime) + } + case permission.FieldUpdateTime: + if input.UpdateTime.Unix() != 0 { + m.SetUpdateTime(input.UpdateTime) + } + case permission.FieldName: + // check string with sql.NullString if it is empty + if input.Name != "" { + m.SetName(input.Name) + } + case permission.FieldKeyword: + // check string with sql.NullString if it is empty + if input.Keyword != "" { + m.SetKeyword(input.Keyword) + } + case permission.FieldDescription: + // check string with sql.NullString if it is empty + if input.Description != "" { + m.SetDescription(input.Description) + } + case permission.FieldDataScope: + // check string with sql.NullString if it is empty + if input.DataScope != "" { + m.SetDataScope(input.DataScope) + } + case permission.FieldDataRules: + if len(input.DataRules) > 0 { + m.SetDataRules(input.DataRules) + } + case permission.FieldActions: + var zero permission.Actions + // check permission.Actions with sql.NullString if it is empty + if input.Actions != zero { + m.SetActions(input.Actions) + } + case permission.FieldID: + // check int64 with sql.NullInt64 if it is zero + if input.ID != 0 { + m.SetID(input.ID) + } + default: + return fmt.Errorf("unknown Permission field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *PermissionMutation) SetFieldsWithZero(input *Permission, fields ...string) error { + for i := range fields { + switch fields[i] { + case permission.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case permission.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case permission.FieldName: + m.SetName(input.Name) + case permission.FieldKeyword: + m.SetKeyword(input.Keyword) + case permission.FieldDescription: + m.SetDescription(input.Description) + case permission.FieldDataScope: + m.SetDataScope(input.DataScope) + case permission.FieldDataRules: + m.SetDataRules(input.DataRules) + case permission.FieldActions: + m.SetActions(input.Actions) + case permission.FieldID: + m.SetID(input.ID) + default: + return fmt.Errorf("unknown Permission field %s", fields[i]) + } + } + return nil +} + +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *PermissionResourceMutation) SetFields(input *PermissionResource, fields ...string) error { + for i := range fields { + switch fields[i] { + case permissionresource.FieldPermissionID: + // check int64 with sql.NullInt64 if it is zero + if input.PermissionID != 0 { + m.SetPermissionID(input.PermissionID) + } + case permissionresource.FieldResourceID: + // check int64 with sql.NullInt64 if it is zero + if input.ResourceID != 0 { + m.SetResourceID(input.ResourceID) + } + default: + return fmt.Errorf("unknown PermissionResource field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *PermissionResourceMutation) SetFieldsWithZero(input *PermissionResource, fields ...string) error { + for i := range fields { + switch fields[i] { + case permissionresource.FieldPermissionID: + m.SetPermissionID(input.PermissionID) + case permissionresource.FieldResourceID: + m.SetResourceID(input.ResourceID) + default: + return fmt.Errorf("unknown PermissionResource field %s", fields[i]) + } + } + return nil +} + +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *ResourceMutation) SetFields(input *Resource, fields ...string) error { + for i := range fields { + switch fields[i] { + case resource.FieldCreateTime: + if input.CreateTime.Unix() != 0 { + m.SetCreateTime(input.CreateTime) + } + case resource.FieldUpdateTime: + if input.UpdateTime.Unix() != 0 { + m.SetUpdateTime(input.UpdateTime) + } + case resource.FieldName: + // check string with sql.NullString if it is empty + if input.Name != "" { + m.SetName(input.Name) + } + case resource.FieldKeyword: + // check string with sql.NullString if it is empty + if input.Keyword != "" { + m.SetKeyword(input.Keyword) + } + case resource.FieldType: + // check string with sql.NullString if it is empty + if input.Type != "" { + m.SetType(input.Type) + } + case resource.FieldStatus: + // check int8 with sql.NullInt64 if it is zero + if input.Status != 0 { + m.SetStatus(input.Status) + } + case resource.FieldPath: + // check string with sql.NullString if it is empty + if input.Path != "" { + m.SetPath(input.Path) + } + case resource.FieldComponent: + // check string with sql.NullString if it is empty + if input.Component != "" { + m.SetComponent(input.Component) + } + case resource.FieldIcon: + // check string with sql.NullString if it is empty + if input.Icon != "" { + m.SetIcon(input.Icon) + } + case resource.FieldSequence: + // check int with sql.NullInt64 if it is zero + if input.Sequence != 0 { + m.SetSequence(input.Sequence) + } + case resource.FieldVisible: + if input.Visible { + m.SetVisible(input.Visible) + } + case resource.FieldLevel: + // check int8 with sql.NullInt64 if it is zero + if input.Level != 0 { + m.SetLevel(input.Level) + } + case resource.FieldTreePath: + // check string with sql.NullString if it is empty + if input.TreePath != "" { + m.SetTreePath(input.TreePath) + } + case resource.FieldProperties: + if len(input.Properties) > 0 { + m.SetProperties(input.Properties) + } + case resource.FieldDescription: + // check string with sql.NullString if it is empty + if input.Description != "" { + m.SetDescription(input.Description) + } + case resource.FieldParentID: + // check int64 with sql.NullInt64 if it is zero + if input.ParentID != 0 { + m.SetParentID(input.ParentID) + } + case resource.FieldID: + // check int64 with sql.NullInt64 if it is zero + if input.ID != 0 { + m.SetID(input.ID) + } + default: + return fmt.Errorf("unknown Resource field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *ResourceMutation) SetFieldsWithZero(input *Resource, fields ...string) error { + for i := range fields { + switch fields[i] { + case resource.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case resource.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case resource.FieldName: + m.SetName(input.Name) + case resource.FieldKeyword: + m.SetKeyword(input.Keyword) + case resource.FieldType: + m.SetType(input.Type) + case resource.FieldStatus: + m.SetStatus(input.Status) + case resource.FieldPath: + m.SetPath(input.Path) + case resource.FieldComponent: + m.SetComponent(input.Component) + case resource.FieldIcon: + m.SetIcon(input.Icon) + case resource.FieldSequence: + m.SetSequence(input.Sequence) + case resource.FieldVisible: + m.SetVisible(input.Visible) + case resource.FieldLevel: + m.SetLevel(input.Level) + case resource.FieldTreePath: + m.SetTreePath(input.TreePath) + case resource.FieldProperties: + m.SetProperties(input.Properties) + case resource.FieldDescription: + m.SetDescription(input.Description) + case resource.FieldParentID: + m.SetParentID(input.ParentID) + case resource.FieldID: + m.SetID(input.ID) + default: + return fmt.Errorf("unknown Resource field %s", fields[i]) + } + } + return nil +} + +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *RoleMutation) SetFields(input *Role, fields ...string) error { + for i := range fields { + switch fields[i] { + case role.FieldCreateTime: + if input.CreateTime.Unix() != 0 { + m.SetCreateTime(input.CreateTime) + } + case role.FieldUpdateTime: + if input.UpdateTime.Unix() != 0 { + m.SetUpdateTime(input.UpdateTime) + } + case role.FieldKeyword: + // check string with sql.NullString if it is empty + if input.Keyword != "" { + m.SetKeyword(input.Keyword) + } + case role.FieldName: + // check string with sql.NullString if it is empty + if input.Name != "" { + m.SetName(input.Name) + } + case role.FieldDescription: + // check string with sql.NullString if it is empty + if input.Description != "" { + m.SetDescription(input.Description) + } + case role.FieldType: + // check int8 with sql.NullInt64 if it is zero + if input.Type != 0 { + m.SetType(input.Type) + } + case role.FieldSequence: + // check int with sql.NullInt64 if it is zero + if input.Sequence != 0 { + m.SetSequence(input.Sequence) + } + case role.FieldStatus: + // check int8 with sql.NullInt64 if it is zero + if input.Status != 0 { + m.SetStatus(input.Status) + } + case role.FieldID: + // check int64 with sql.NullInt64 if it is zero + if input.ID != 0 { + m.SetID(input.ID) + } + default: + return fmt.Errorf("unknown Role field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *RoleMutation) SetFieldsWithZero(input *Role, fields ...string) error { + for i := range fields { + switch fields[i] { + case role.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case role.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case role.FieldKeyword: + m.SetKeyword(input.Keyword) + case role.FieldName: + m.SetName(input.Name) + case role.FieldDescription: + m.SetDescription(input.Description) + case role.FieldType: + m.SetType(input.Type) + case role.FieldSequence: + m.SetSequence(input.Sequence) + case role.FieldStatus: + m.SetStatus(input.Status) + case role.FieldID: + m.SetID(input.ID) + default: + return fmt.Errorf("unknown Role field %s", fields[i]) + } + } + return nil +} + +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *RolePermissionMutation) SetFields(input *RolePermission, fields ...string) error { + for i := range fields { + switch fields[i] { + case rolepermission.FieldRoleID: + // check int64 with sql.NullInt64 if it is zero + if input.RoleID != 0 { + m.SetRoleID(input.RoleID) + } + case rolepermission.FieldPermissionID: + // check int64 with sql.NullInt64 if it is zero + if input.PermissionID != 0 { + m.SetPermissionID(input.PermissionID) + } + default: + return fmt.Errorf("unknown RolePermission field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *RolePermissionMutation) SetFieldsWithZero(input *RolePermission, fields ...string) error { + for i := range fields { + switch fields[i] { + case rolepermission.FieldRoleID: + m.SetRoleID(input.RoleID) + case rolepermission.FieldPermissionID: + m.SetPermissionID(input.PermissionID) + default: + return fmt.Errorf("unknown RolePermission field %s", fields[i]) + } + } + return nil +} + +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *UserMutation) SetFields(input *User, fields ...string) error { + for i := range fields { + switch fields[i] { + case user.FieldCreateTime: + if input.CreateTime.Unix() != 0 { + m.SetCreateTime(input.CreateTime) + } + case user.FieldUpdateTime: + if input.UpdateTime.Unix() != 0 { + m.SetUpdateTime(input.UpdateTime) + } + case user.FieldUUID: + // check string with sql.NullString if it is empty + if input.UUID != "" { + m.SetUUID(input.UUID) + } + case user.FieldAllowedIP: + // check string with sql.NullString if it is empty + if input.AllowedIP != "" { + m.SetAllowedIP(input.AllowedIP) + } + case user.FieldUsername: + // check string with sql.NullString if it is empty + if input.Username != "" { + m.SetUsername(input.Username) + } + case user.FieldNickname: + // check string with sql.NullString if it is empty + if input.Nickname != "" { + m.SetNickname(input.Nickname) + } + case user.FieldAvatar: + // check string with sql.NullString if it is empty + if input.Avatar != "" { + m.SetAvatar(input.Avatar) + } + case user.FieldName: + // check string with sql.NullString if it is empty + if input.Name != "" { + m.SetName(input.Name) + } + case user.FieldGender: + var zero user.Gender + // check user.Gender with sql.NullString if it is empty + if input.Gender != zero { + m.SetGender(input.Gender) + } + case user.FieldPassword: + // check string with sql.NullString if it is empty + if input.Password != "" { + m.SetPassword(input.Password) + } + case user.FieldPhone: + // check string with sql.NullString if it is empty + if input.Phone != "" { + m.SetPhone(input.Phone) + } + case user.FieldEmail: + // check string with sql.NullString if it is empty + if input.Email != "" { + m.SetEmail(input.Email) + } + case user.FieldDepartment: + // check string with sql.NullString if it is empty + if input.Department != "" { + m.SetDepartment(input.Department) + } + case user.FieldRemark: + // check string with sql.NullString if it is empty + if input.Remark != "" { + m.SetRemark(input.Remark) + } + case user.FieldStatus: + // check int8 with sql.NullInt64 if it is zero + if input.Status != 0 { + m.SetStatus(input.Status) + } + case user.FieldIsSystem: + if input.IsSystem { + m.SetIsSystem(input.IsSystem) + } + case user.FieldLastLoginIP: + // check string with sql.NullString if it is empty + if input.LastLoginIP != "" { + m.SetLastLoginIP(input.LastLoginIP) + } + case user.FieldLastLoginTime: + if input.LastLoginTime.Unix() != 0 { + m.SetLastLoginTime(input.LastLoginTime) + } + case user.FieldID: + // check int64 with sql.NullInt64 if it is zero + if input.ID != 0 { + m.SetID(input.ID) + } + default: + return fmt.Errorf("unknown User field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *UserMutation) SetFieldsWithZero(input *User, fields ...string) error { + for i := range fields { + switch fields[i] { + case user.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case user.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case user.FieldUUID: + m.SetUUID(input.UUID) + case user.FieldAllowedIP: + m.SetAllowedIP(input.AllowedIP) + case user.FieldUsername: + m.SetUsername(input.Username) + case user.FieldNickname: + m.SetNickname(input.Nickname) + case user.FieldAvatar: + m.SetAvatar(input.Avatar) + case user.FieldName: + m.SetName(input.Name) + case user.FieldGender: + m.SetGender(input.Gender) + case user.FieldPassword: + m.SetPassword(input.Password) + case user.FieldPhone: + m.SetPhone(input.Phone) + case user.FieldEmail: + m.SetEmail(input.Email) + case user.FieldDepartment: + m.SetDepartment(input.Department) + case user.FieldRemark: + m.SetRemark(input.Remark) + case user.FieldStatus: + m.SetStatus(input.Status) + case user.FieldIsSystem: + m.SetIsSystem(input.IsSystem) + case user.FieldLastLoginIP: + m.SetLastLoginIP(input.LastLoginIP) + case user.FieldLastLoginTime: + m.SetLastLoginTime(input.LastLoginTime) + case user.FieldID: + m.SetID(input.ID) + default: + return fmt.Errorf("unknown User field %s", fields[i]) + } + } + return nil +} + +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *UserRoleMutation) SetFields(input *UserRole, fields ...string) error { + for i := range fields { + switch fields[i] { + case userrole.FieldUserID: + // check int64 with sql.NullInt64 if it is zero + if input.UserID != 0 { + m.SetUserID(input.UserID) + } + case userrole.FieldRoleID: + // check int64 with sql.NullInt64 if it is zero + if input.RoleID != 0 { + m.SetRoleID(input.RoleID) + } + default: + return fmt.Errorf("unknown UserRole field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *UserRoleMutation) SetFieldsWithZero(input *UserRole, fields ...string) error { + for i := range fields { + switch fields[i] { + case userrole.FieldUserID: + m.SetUserID(input.UserID) + case userrole.FieldRoleID: + m.SetRoleID(input.RoleID) + default: + return fmt.Errorf("unknown UserRole field %s", fields[i]) + } + } + return nil +} diff --git a/internal/features/system/data/ent/permission.go b/internal/features/system/data/ent/permission.go new file mode 100644 index 00000000..e8eded72 --- /dev/null +++ b/internal/features/system/data/ent/permission.go @@ -0,0 +1,263 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// Permission table +type Permission struct { + config `json:"-"` + // ID of the ent. + // ID + ID int64 `json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime time.Time `json:"update_time,omitempty"` + // Name + Name string `json:"name,omitempty"` + // Keyword + Keyword string `json:"keyword,omitempty"` + // Description + Description string `json:"description,omitempty"` + // Data scope + DataScope string `json:"data_scope,omitempty"` + // Data rules + DataRules map[string]string `json:"data_rules,omitempty"` + // Actions + Actions permission.Actions `json:"actions,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PermissionQuery when eager-loading is set. + Edges PermissionEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PermissionEdges holds the relations/edges for other nodes in the graph. +type PermissionEdges struct { + // Roles holds the value of the roles edge. + Roles []*Role `json:"roles,omitempty"` + // Resources holds the value of the resources edge. + Resources []*Resource `json:"resources,omitempty"` + // RolePermissions holds the value of the role_permissions edge. + RolePermissions []*RolePermission `json:"role_permissions,omitempty"` + // PermissionResources holds the value of the permission_resources edge. + PermissionResources []*PermissionResource `json:"permission_resources,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [4]bool +} + +// RolesOrErr returns the Roles value or an error if the edge +// was not loaded in eager-loading. +func (e PermissionEdges) RolesOrErr() ([]*Role, error) { + if e.loadedTypes[0] { + return e.Roles, nil + } + return nil, &NotLoadedError{edge: "roles"} +} + +// ResourcesOrErr returns the Resources value or an error if the edge +// was not loaded in eager-loading. +func (e PermissionEdges) ResourcesOrErr() ([]*Resource, error) { + if e.loadedTypes[1] { + return e.Resources, nil + } + return nil, &NotLoadedError{edge: "resources"} +} + +// RolePermissionsOrErr returns the RolePermissions value or an error if the edge +// was not loaded in eager-loading. +func (e PermissionEdges) RolePermissionsOrErr() ([]*RolePermission, error) { + if e.loadedTypes[2] { + return e.RolePermissions, nil + } + return nil, &NotLoadedError{edge: "role_permissions"} +} + +// PermissionResourcesOrErr returns the PermissionResources value or an error if the edge +// was not loaded in eager-loading. +func (e PermissionEdges) PermissionResourcesOrErr() ([]*PermissionResource, error) { + if e.loadedTypes[3] { + return e.PermissionResources, nil + } + return nil, &NotLoadedError{edge: "permission_resources"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Permission) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case permission.FieldDataRules: + values[i] = new([]byte) + case permission.FieldID: + values[i] = new(sql.NullInt64) + case permission.FieldName, permission.FieldKeyword, permission.FieldDescription, permission.FieldDataScope, permission.FieldActions: + values[i] = new(sql.NullString) + case permission.FieldCreateTime, permission.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Permission fields. +func (_m *Permission) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case permission.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case permission.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = value.Time + } + case permission.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = value.Time + } + case permission.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case permission.FieldKeyword: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field keyword", values[i]) + } else if value.Valid { + _m.Keyword = value.String + } + case permission.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case permission.FieldDataScope: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field data_scope", values[i]) + } else if value.Valid { + _m.DataScope = value.String + } + case permission.FieldDataRules: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field data_rules", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.DataRules); err != nil { + return fmt.Errorf("unmarshal field data_rules: %w", err) + } + } + case permission.FieldActions: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field actions", values[i]) + } else if value.Valid { + _m.Actions = permission.Actions(value.String) + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Permission. +// This includes values selected through modifiers, order, etc. +func (_m *Permission) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryRoles queries the "roles" edge of the Permission entity. +func (_m *Permission) QueryRoles() *RoleQuery { + return NewPermissionClient(_m.config).QueryRoles(_m) +} + +// QueryResources queries the "resources" edge of the Permission entity. +func (_m *Permission) QueryResources() *ResourceQuery { + return NewPermissionClient(_m.config).QueryResources(_m) +} + +// QueryRolePermissions queries the "role_permissions" edge of the Permission entity. +func (_m *Permission) QueryRolePermissions() *RolePermissionQuery { + return NewPermissionClient(_m.config).QueryRolePermissions(_m) +} + +// QueryPermissionResources queries the "permission_resources" edge of the Permission entity. +func (_m *Permission) QueryPermissionResources() *PermissionResourceQuery { + return NewPermissionClient(_m.config).QueryPermissionResources(_m) +} + +// Update returns a builder for updating this Permission. +// Note that you need to call Permission.Unwrap() before calling this method if this Permission +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *Permission) Update() *PermissionUpdateOne { + return NewPermissionClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the Permission entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *Permission) Unwrap() *Permission { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: Permission is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *Permission) String() string { + var builder strings.Builder + builder.WriteString("Permission(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("create_time=") + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("keyword=") + builder.WriteString(_m.Keyword) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteString(", ") + builder.WriteString("data_scope=") + builder.WriteString(_m.DataScope) + builder.WriteString(", ") + builder.WriteString("data_rules=") + builder.WriteString(fmt.Sprintf("%v", _m.DataRules)) + builder.WriteString(", ") + builder.WriteString("actions=") + builder.WriteString(fmt.Sprintf("%v", _m.Actions)) + builder.WriteByte(')') + return builder.String() +} + +// Permissions is a parsable slice of Permission. +type Permissions []*Permission diff --git a/internal/features/system/data/ent/permission/permission.go b/internal/features/system/data/ent/permission/permission.go new file mode 100644 index 00000000..96aeb1c4 --- /dev/null +++ b/internal/features/system/data/ent/permission/permission.go @@ -0,0 +1,338 @@ +// Code generated by ent, DO NOT EDIT. + +package permission + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the permission type in the database. + Label = "permission" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldKeyword holds the string denoting the keyword field in the database. + FieldKeyword = "keyword" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldDataScope holds the string denoting the data_scope field in the database. + FieldDataScope = "data_scope" + // FieldDataRules holds the string denoting the data_rules field in the database. + FieldDataRules = "data_rules" + // FieldActions holds the string denoting the actions field in the database. + FieldActions = "actions" + // EdgeRoles holds the string denoting the roles edge name in mutations. + EdgeRoles = "roles" + // EdgeResources holds the string denoting the resources edge name in mutations. + EdgeResources = "resources" + // EdgeRolePermissions holds the string denoting the role_permissions edge name in mutations. + EdgeRolePermissions = "role_permissions" + // EdgePermissionResources holds the string denoting the permission_resources edge name in mutations. + EdgePermissionResources = "permission_resources" + // Table holds the table name of the permission in the database. + Table = "sys_permissions" + // RolesTable is the table that holds the roles relation/edge. The primary key declared below. + RolesTable = "sys_role_permissions" + // RolesInverseTable is the table name for the Role entity. + // It exists in this package in order to avoid circular dependency with the "role" package. + RolesInverseTable = "sys_roles" + // ResourcesTable is the table that holds the resources relation/edge. The primary key declared below. + ResourcesTable = "sys_permission_resources" + // ResourcesInverseTable is the table name for the Resource entity. + // It exists in this package in order to avoid circular dependency with the "resource" package. + ResourcesInverseTable = "sys_resources" + // RolePermissionsTable is the table that holds the role_permissions relation/edge. + RolePermissionsTable = "sys_role_permissions" + // RolePermissionsInverseTable is the table name for the RolePermission entity. + // It exists in this package in order to avoid circular dependency with the "rolepermission" package. + RolePermissionsInverseTable = "sys_role_permissions" + // RolePermissionsColumn is the table column denoting the role_permissions relation/edge. + RolePermissionsColumn = "permission_id" + // PermissionResourcesTable is the table that holds the permission_resources relation/edge. + PermissionResourcesTable = "sys_permission_resources" + // PermissionResourcesInverseTable is the table name for the PermissionResource entity. + // It exists in this package in order to avoid circular dependency with the "permissionresource" package. + PermissionResourcesInverseTable = "sys_permission_resources" + // PermissionResourcesColumn is the table column denoting the permission_resources relation/edge. + PermissionResourcesColumn = "permission_id" +) + +// Columns holds all SQL columns for permission fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldName, + FieldKeyword, + FieldDescription, + FieldDataScope, + FieldDataRules, + FieldActions, +} + +var ( + // RolesPrimaryKey and RolesColumn2 are the table columns denoting the + // primary key for the roles relation (M2M). + RolesPrimaryKey = []string{"role_id", "permission_id"} + // ResourcesPrimaryKey and ResourcesColumn2 are the table columns denoting the + // primary key for the resources relation (M2M). + ResourcesPrimaryKey = []string{"permission_id", "resource_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // DefaultName holds the default value on creation for the "name" field. + DefaultName string + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + KeywordValidator func(string) error + // DefaultDescription holds the default value on creation for the "description" field. + DefaultDescription string + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error + // DefaultDataScope holds the default value on creation for the "data_scope" field. + DefaultDataScope string +) + +// Actions defines the type for the "actions" enum field. +type Actions string + +// ActionsRead is the default value of the Actions enum. +const DefaultActions = ActionsRead + +// Actions values. +const ( + ActionsRead Actions = "read" + ActionsWrite Actions = "write" + ActionsDelete Actions = "delete" + ActionsManage Actions = "manage" +) + +func (a Actions) String() string { + return string(a) +} + +// ActionsValidator is a validator for the "actions" field enum values. It is called by the builders before save. +func ActionsValidator(a Actions) error { + switch a { + case ActionsRead, ActionsWrite, ActionsDelete, ActionsManage: + return nil + default: + return fmt.Errorf("permission: invalid enum value for actions field: %q", a) + } +} + +// OrderOption defines the ordering options for the Permission queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByKeyword orders the results by the keyword field. +func ByKeyword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKeyword, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByDataScope orders the results by the data_scope field. +func ByDataScope(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDataScope, opts...).ToFunc() +} + +// ByActions orders the results by the actions field. +func ByActions(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldActions, opts...).ToFunc() +} + +// ByRolesCount orders the results by roles count. +func ByRolesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...) + } +} + +// ByRoles orders the results by roles terms. +func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByResourcesCount orders the results by resources count. +func ByResourcesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newResourcesStep(), opts...) + } +} + +// ByResources orders the results by resources terms. +func ByResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByRolePermissionsCount orders the results by role_permissions count. +func ByRolePermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRolePermissionsStep(), opts...) + } +} + +// ByRolePermissions orders the results by role_permissions terms. +func ByRolePermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRolePermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPermissionResourcesCount orders the results by permission_resources count. +func ByPermissionResourcesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPermissionResourcesStep(), opts...) + } +} + +// ByPermissionResources orders the results by permission_resources terms. +func ByPermissionResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newRolesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RolesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, RolesTable, RolesPrimaryKey...), + ) +} +func newResourcesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ResourcesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), + ) +} +func newRolePermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RolePermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), + ) +} +func newPermissionResourcesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionResourcesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/features/system/data/ent/permission/where.go b/internal/features/system/data/ent/permission/where.go new file mode 100644 index 00000000..5c375213 --- /dev/null +++ b/internal/features/system/data/ent/permission/where.go @@ -0,0 +1,563 @@ +// Code generated by ent, DO NOT EDIT. + +package permission + +import ( + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldName, v)) +} + +// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. +func Keyword(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldKeyword, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldDescription, v)) +} + +// DataScope applies equality check predicate on the "data_scope" field. It's identical to DataScopeEQ. +func DataScope(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldDataScope, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldUpdateTime, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Permission { + return predicate.Permission(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldContainsFold(FieldName, v)) +} + +// KeywordEQ applies the EQ predicate on the "keyword" field. +func KeywordEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldKeyword, v)) +} + +// KeywordNEQ applies the NEQ predicate on the "keyword" field. +func KeywordNEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldKeyword, v)) +} + +// KeywordIn applies the In predicate on the "keyword" field. +func KeywordIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldKeyword, vs...)) +} + +// KeywordNotIn applies the NotIn predicate on the "keyword" field. +func KeywordNotIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldKeyword, vs...)) +} + +// KeywordGT applies the GT predicate on the "keyword" field. +func KeywordGT(v string) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldKeyword, v)) +} + +// KeywordGTE applies the GTE predicate on the "keyword" field. +func KeywordGTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldKeyword, v)) +} + +// KeywordLT applies the LT predicate on the "keyword" field. +func KeywordLT(v string) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldKeyword, v)) +} + +// KeywordLTE applies the LTE predicate on the "keyword" field. +func KeywordLTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldKeyword, v)) +} + +// KeywordContains applies the Contains predicate on the "keyword" field. +func KeywordContains(v string) predicate.Permission { + return predicate.Permission(sql.FieldContains(FieldKeyword, v)) +} + +// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. +func KeywordHasPrefix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasPrefix(FieldKeyword, v)) +} + +// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. +func KeywordHasSuffix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasSuffix(FieldKeyword, v)) +} + +// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. +func KeywordEqualFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldEqualFold(FieldKeyword, v)) +} + +// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. +func KeywordContainsFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldContainsFold(FieldKeyword, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Permission { + return predicate.Permission(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldContainsFold(FieldDescription, v)) +} + +// DataScopeEQ applies the EQ predicate on the "data_scope" field. +func DataScopeEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldDataScope, v)) +} + +// DataScopeNEQ applies the NEQ predicate on the "data_scope" field. +func DataScopeNEQ(v string) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldDataScope, v)) +} + +// DataScopeIn applies the In predicate on the "data_scope" field. +func DataScopeIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldDataScope, vs...)) +} + +// DataScopeNotIn applies the NotIn predicate on the "data_scope" field. +func DataScopeNotIn(vs ...string) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldDataScope, vs...)) +} + +// DataScopeGT applies the GT predicate on the "data_scope" field. +func DataScopeGT(v string) predicate.Permission { + return predicate.Permission(sql.FieldGT(FieldDataScope, v)) +} + +// DataScopeGTE applies the GTE predicate on the "data_scope" field. +func DataScopeGTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldGTE(FieldDataScope, v)) +} + +// DataScopeLT applies the LT predicate on the "data_scope" field. +func DataScopeLT(v string) predicate.Permission { + return predicate.Permission(sql.FieldLT(FieldDataScope, v)) +} + +// DataScopeLTE applies the LTE predicate on the "data_scope" field. +func DataScopeLTE(v string) predicate.Permission { + return predicate.Permission(sql.FieldLTE(FieldDataScope, v)) +} + +// DataScopeContains applies the Contains predicate on the "data_scope" field. +func DataScopeContains(v string) predicate.Permission { + return predicate.Permission(sql.FieldContains(FieldDataScope, v)) +} + +// DataScopeHasPrefix applies the HasPrefix predicate on the "data_scope" field. +func DataScopeHasPrefix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasPrefix(FieldDataScope, v)) +} + +// DataScopeHasSuffix applies the HasSuffix predicate on the "data_scope" field. +func DataScopeHasSuffix(v string) predicate.Permission { + return predicate.Permission(sql.FieldHasSuffix(FieldDataScope, v)) +} + +// DataScopeEqualFold applies the EqualFold predicate on the "data_scope" field. +func DataScopeEqualFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldEqualFold(FieldDataScope, v)) +} + +// DataScopeContainsFold applies the ContainsFold predicate on the "data_scope" field. +func DataScopeContainsFold(v string) predicate.Permission { + return predicate.Permission(sql.FieldContainsFold(FieldDataScope, v)) +} + +// DataRulesIsNil applies the IsNil predicate on the "data_rules" field. +func DataRulesIsNil() predicate.Permission { + return predicate.Permission(sql.FieldIsNull(FieldDataRules)) +} + +// DataRulesNotNil applies the NotNil predicate on the "data_rules" field. +func DataRulesNotNil() predicate.Permission { + return predicate.Permission(sql.FieldNotNull(FieldDataRules)) +} + +// ActionsEQ applies the EQ predicate on the "actions" field. +func ActionsEQ(v Actions) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldActions, v)) +} + +// ActionsNEQ applies the NEQ predicate on the "actions" field. +func ActionsNEQ(v Actions) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldActions, v)) +} + +// ActionsIn applies the In predicate on the "actions" field. +func ActionsIn(vs ...Actions) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldActions, vs...)) +} + +// ActionsNotIn applies the NotIn predicate on the "actions" field. +func ActionsNotIn(vs ...Actions) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldActions, vs...)) +} + +// HasRoles applies the HasEdge predicate on the "roles" edge. +func HasRoles() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, RolesTable, RolesPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRolesWith applies the HasEdge predicate on the "roles" edge with a given conditions (other predicates). +func HasRolesWith(preds ...predicate.Role) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newRolesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasResources applies the HasEdge predicate on the "resources" edge. +func HasResources() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasResourcesWith applies the HasEdge predicate on the "resources" edge with a given conditions (other predicates). +func HasResourcesWith(preds ...predicate.Resource) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newResourcesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasRolePermissions applies the HasEdge predicate on the "role_permissions" edge. +func HasRolePermissions() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRolePermissionsWith applies the HasEdge predicate on the "role_permissions" edge with a given conditions (other predicates). +func HasRolePermissionsWith(preds ...predicate.RolePermission) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newRolePermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermissionResources applies the HasEdge predicate on the "permission_resources" edge. +func HasPermissionResources() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionResourcesWith applies the HasEdge predicate on the "permission_resources" edge with a given conditions (other predicates). +func HasPermissionResourcesWith(preds ...predicate.PermissionResource) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newPermissionResourcesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Permission) predicate.Permission { + return predicate.Permission(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Permission) predicate.Permission { + return predicate.Permission(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Permission) predicate.Permission { + return predicate.Permission(sql.NotPredicates(p)) +} diff --git a/internal/features/system/data/ent/permission_create.go b/internal/features/system/data/ent/permission_create.go new file mode 100644 index 00000000..0cea43c2 --- /dev/null +++ b/internal/features/system/data/ent/permission_create.go @@ -0,0 +1,530 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PermissionCreate is the builder for creating a Permission entity. +type PermissionCreate struct { + config + mutation *PermissionMutation + hooks []Hook +} + +// SetCreateTime sets the "create_time" field. +func (_c *PermissionCreate) SetCreateTime(v time.Time) *PermissionCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *PermissionCreate) SetNillableCreateTime(v *time.Time) *PermissionCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *PermissionCreate) SetUpdateTime(v time.Time) *PermissionCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *PermissionCreate) SetNillableUpdateTime(v *time.Time) *PermissionCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetName sets the "name" field. +func (_c *PermissionCreate) SetName(v string) *PermissionCreate { + _c.mutation.SetName(v) + return _c +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_c *PermissionCreate) SetNillableName(v *string) *PermissionCreate { + if v != nil { + _c.SetName(*v) + } + return _c +} + +// SetKeyword sets the "keyword" field. +func (_c *PermissionCreate) SetKeyword(v string) *PermissionCreate { + _c.mutation.SetKeyword(v) + return _c +} + +// SetDescription sets the "description" field. +func (_c *PermissionCreate) SetDescription(v string) *PermissionCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *PermissionCreate) SetNillableDescription(v *string) *PermissionCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetDataScope sets the "data_scope" field. +func (_c *PermissionCreate) SetDataScope(v string) *PermissionCreate { + _c.mutation.SetDataScope(v) + return _c +} + +// SetNillableDataScope sets the "data_scope" field if the given value is not nil. +func (_c *PermissionCreate) SetNillableDataScope(v *string) *PermissionCreate { + if v != nil { + _c.SetDataScope(*v) + } + return _c +} + +// SetDataRules sets the "data_rules" field. +func (_c *PermissionCreate) SetDataRules(v map[string]string) *PermissionCreate { + _c.mutation.SetDataRules(v) + return _c +} + +// SetActions sets the "actions" field. +func (_c *PermissionCreate) SetActions(v permission.Actions) *PermissionCreate { + _c.mutation.SetActions(v) + return _c +} + +// SetNillableActions sets the "actions" field if the given value is not nil. +func (_c *PermissionCreate) SetNillableActions(v *permission.Actions) *PermissionCreate { + if v != nil { + _c.SetActions(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *PermissionCreate) SetID(v int64) *PermissionCreate { + _c.mutation.SetID(v) + return _c +} + +// AddRoleIDs adds the "roles" edge to the Role entity by IDs. +func (_c *PermissionCreate) AddRoleIDs(ids ...int64) *PermissionCreate { + _c.mutation.AddRoleIDs(ids...) + return _c +} + +// AddRoles adds the "roles" edges to the Role entity. +func (_c *PermissionCreate) AddRoles(v ...*Role) *PermissionCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddRoleIDs(ids...) +} + +// AddResourceIDs adds the "resources" edge to the Resource entity by IDs. +func (_c *PermissionCreate) AddResourceIDs(ids ...int64) *PermissionCreate { + _c.mutation.AddResourceIDs(ids...) + return _c +} + +// AddResources adds the "resources" edges to the Resource entity. +func (_c *PermissionCreate) AddResources(v ...*Resource) *PermissionCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddResourceIDs(ids...) +} + +// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. +func (_c *PermissionCreate) AddRolePermissionIDs(ids ...int) *PermissionCreate { + _c.mutation.AddRolePermissionIDs(ids...) + return _c +} + +// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. +func (_c *PermissionCreate) AddRolePermissions(v ...*RolePermission) *PermissionCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddRolePermissionIDs(ids...) +} + +// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. +func (_c *PermissionCreate) AddPermissionResourceIDs(ids ...int) *PermissionCreate { + _c.mutation.AddPermissionResourceIDs(ids...) + return _c +} + +// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. +func (_c *PermissionCreate) AddPermissionResources(v ...*PermissionResource) *PermissionCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddPermissionResourceIDs(ids...) +} + +// Mutation returns the PermissionMutation object of the builder. +func (_c *PermissionCreate) Mutation() *PermissionMutation { + return _c.mutation +} + +// Save creates the Permission in the database. +func (_c *PermissionCreate) Save(ctx context.Context) (*Permission, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *PermissionCreate) SaveX(ctx context.Context) *Permission { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PermissionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PermissionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *PermissionCreate) defaults() { + if _, ok := _c.mutation.CreateTime(); !ok { + v := permission.DefaultCreateTime() + _c.mutation.SetCreateTime(v) + } + if _, ok := _c.mutation.UpdateTime(); !ok { + v := permission.DefaultUpdateTime() + _c.mutation.SetUpdateTime(v) + } + if _, ok := _c.mutation.Name(); !ok { + v := permission.DefaultName + _c.mutation.SetName(v) + } + if _, ok := _c.mutation.Description(); !ok { + v := permission.DefaultDescription + _c.mutation.SetDescription(v) + } + if _, ok := _c.mutation.DataScope(); !ok { + v := permission.DefaultDataScope + _c.mutation.SetDataScope(v) + } + if _, ok := _c.mutation.Actions(); !ok { + v := permission.DefaultActions + _c.mutation.SetActions(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *PermissionCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Permission.create_time"`)} + } + if _, ok := _c.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Permission.update_time"`)} + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Permission.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := permission.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Permission.name": %w`, err)} + } + } + if _, ok := _c.mutation.Keyword(); !ok { + return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Permission.keyword"`)} + } + if v, ok := _c.mutation.Keyword(); ok { + if err := permission.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Permission.keyword": %w`, err)} + } + } + if _, ok := _c.mutation.Description(); !ok { + return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Permission.description"`)} + } + if v, ok := _c.mutation.Description(); ok { + if err := permission.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} + } + } + if _, ok := _c.mutation.DataScope(); !ok { + return &ValidationError{Name: "data_scope", err: errors.New(`ent: missing required field "Permission.data_scope"`)} + } + if _, ok := _c.mutation.Actions(); !ok { + return &ValidationError{Name: "actions", err: errors.New(`ent: missing required field "Permission.actions"`)} + } + if v, ok := _c.mutation.Actions(); ok { + if err := permission.ActionsValidator(v); err != nil { + return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} + } + } + return nil +} + +func (_c *PermissionCreate) sqlSave(ctx context.Context) (*Permission, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { + var ( + _node = &Permission{config: _c.config} + _spec = sqlgraph.NewCreateSpec(permission.Table, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(permission.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(permission.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(permission.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Keyword(); ok { + _spec.SetField(permission.FieldKeyword, field.TypeString, value) + _node.Keyword = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(permission.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := _c.mutation.DataScope(); ok { + _spec.SetField(permission.FieldDataScope, field.TypeString, value) + _node.DataScope = value + } + if value, ok := _c.mutation.DataRules(); ok { + _spec.SetField(permission.FieldDataRules, field.TypeJSON, value) + _node.DataRules = value + } + if value, ok := _c.mutation.Actions(); ok { + _spec.SetField(permission.FieldActions, field.TypeEnum, value) + _node.Actions = value + } + if nodes := _c.mutation.RolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: permission.RolesTable, + Columns: permission.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ResourcesTable, + Columns: permission.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.RolePermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.RolePermissionsTable, + Columns: []string{permission.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.PermissionResourcesTable, + Columns: []string{permission.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SetPermission set the Permission +func (_c *PermissionCreate) SetPermission(input *Permission, fields ...string) *PermissionCreate { + m := _c.mutation + if len(fields) == 0 { + fields = permission.Columns + } + _ = m.SetFields(input, fields...) + return _c +} + +// SetPermissionWithZero set the Permission +func (_c *PermissionCreate) SetPermissionWithZero(input *Permission, fields ...string) *PermissionCreate { + m := _c.mutation + if len(fields) == 0 { + fields = permission.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return _c +} + +// PermissionCreateBulk is the builder for creating many Permission entities in bulk. +type PermissionCreateBulk struct { + config + err error + builders []*PermissionCreate +} + +// Save creates the Permission entities in the database. +func (_c *PermissionCreateBulk) Save(ctx context.Context) ([]*Permission, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Permission, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PermissionMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *PermissionCreateBulk) SaveX(ctx context.Context) []*Permission { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PermissionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PermissionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/permission_delete.go b/internal/features/system/data/ent/permission_delete.go new file mode 100644 index 00000000..66512462 --- /dev/null +++ b/internal/features/system/data/ent/permission_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PermissionDelete is the builder for deleting a Permission entity. +type PermissionDelete struct { + config + hooks []Hook + mutation *PermissionMutation +} + +// Where appends a list predicates to the PermissionDelete builder. +func (_d *PermissionDelete) Where(ps ...predicate.Permission) *PermissionDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *PermissionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PermissionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *PermissionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(permission.Table, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// PermissionDeleteOne is the builder for deleting a single Permission entity. +type PermissionDeleteOne struct { + _d *PermissionDelete +} + +// Where appends a list predicates to the PermissionDelete builder. +func (_d *PermissionDeleteOne) Where(ps ...predicate.Permission) *PermissionDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *PermissionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{permission.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PermissionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/permission_query.go b/internal/features/system/data/ent/permission_query.go new file mode 100644 index 00000000..3d199e09 --- /dev/null +++ b/internal/features/system/data/ent/permission_query.go @@ -0,0 +1,986 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PermissionQuery is the builder for querying Permission entities. +type PermissionQuery struct { + config + ctx *QueryContext + order []permission.OrderOption + inters []Interceptor + predicates []predicate.Permission + withRoles *RoleQuery + withResources *ResourceQuery + withRolePermissions *RolePermissionQuery + withPermissionResources *PermissionResourceQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PermissionQuery builder. +func (_q *PermissionQuery) Where(ps ...predicate.Permission) *PermissionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *PermissionQuery) Limit(limit int) *PermissionQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *PermissionQuery) Offset(offset int) *PermissionQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *PermissionQuery) Unique(unique bool) *PermissionQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *PermissionQuery) Order(o ...permission.OrderOption) *PermissionQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryRoles chains the current query on the "roles" edge. +func (_q *PermissionQuery) QueryRoles() *RoleQuery { + query := (&RoleClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, selector), + sqlgraph.To(role.Table, role.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, permission.RolesTable, permission.RolesPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryResources chains the current query on the "resources" edge. +func (_q *PermissionQuery) QueryResources() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, selector), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, permission.ResourcesTable, permission.ResourcesPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryRolePermissions chains the current query on the "role_permissions" edge. +func (_q *PermissionQuery) QueryRolePermissions() *RolePermissionQuery { + query := (&RolePermissionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, selector), + sqlgraph.To(rolepermission.Table, rolepermission.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, permission.RolePermissionsTable, permission.RolePermissionsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryPermissionResources chains the current query on the "permission_resources" edge. +func (_q *PermissionQuery) QueryPermissionResources() *PermissionResourceQuery { + query := (&PermissionResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, selector), + sqlgraph.To(permissionresource.Table, permissionresource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, permission.PermissionResourcesTable, permission.PermissionResourcesColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Permission entity from the query. +// Returns a *NotFoundError when no Permission was found. +func (_q *PermissionQuery) First(ctx context.Context) (*Permission, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{permission.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *PermissionQuery) FirstX(ctx context.Context) *Permission { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Permission ID from the query. +// Returns a *NotFoundError when no Permission ID was found. +func (_q *PermissionQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{permission.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *PermissionQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Permission entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Permission entity is found. +// Returns a *NotFoundError when no Permission entities are found. +func (_q *PermissionQuery) Only(ctx context.Context) (*Permission, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{permission.Label} + default: + return nil, &NotSingularError{permission.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *PermissionQuery) OnlyX(ctx context.Context) *Permission { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Permission ID in the query. +// Returns a *NotSingularError when more than one Permission ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *PermissionQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{permission.Label} + default: + err = &NotSingularError{permission.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *PermissionQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Permissions. +func (_q *PermissionQuery) All(ctx context.Context) ([]*Permission, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Permission, *PermissionQuery]() + return withInterceptors[[]*Permission](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *PermissionQuery) AllX(ctx context.Context) []*Permission { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Permission IDs. +func (_q *PermissionQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(permission.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *PermissionQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *PermissionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*PermissionQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *PermissionQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *PermissionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *PermissionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PermissionQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *PermissionQuery) Clone() *PermissionQuery { + if _q == nil { + return nil + } + return &PermissionQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]permission.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Permission{}, _q.predicates...), + withRoles: _q.withRoles.Clone(), + withResources: _q.withResources.Clone(), + withRolePermissions: _q.withRolePermissions.Clone(), + withPermissionResources: _q.withPermissionResources.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithRoles tells the query-builder to eager-load the nodes that are connected to +// the "roles" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PermissionQuery) WithRoles(opts ...func(*RoleQuery)) *PermissionQuery { + query := (&RoleClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRoles = query + return _q +} + +// WithResources tells the query-builder to eager-load the nodes that are connected to +// the "resources" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PermissionQuery) WithResources(opts ...func(*ResourceQuery)) *PermissionQuery { + query := (&ResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withResources = query + return _q +} + +// WithRolePermissions tells the query-builder to eager-load the nodes that are connected to +// the "role_permissions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PermissionQuery) WithRolePermissions(opts ...func(*RolePermissionQuery)) *PermissionQuery { + query := (&RolePermissionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRolePermissions = query + return _q +} + +// WithPermissionResources tells the query-builder to eager-load the nodes that are connected to +// the "permission_resources" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PermissionQuery) WithPermissionResources(opts ...func(*PermissionResourceQuery)) *PermissionQuery { + query := (&PermissionResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withPermissionResources = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Permission.Query(). +// GroupBy(permission.FieldCreateTime). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *PermissionQuery) GroupBy(field string, fields ...string) *PermissionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PermissionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = permission.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// } +// +// client.Permission.Query(). +// Select(permission.FieldCreateTime). +// Scan(ctx, &v) +func (_q *PermissionQuery) Select(fields ...string) *PermissionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PermissionSelect{PermissionQuery: _q} + sbuild.label = permission.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PermissionSelect configured with the given aggregations. +func (_q *PermissionQuery) Aggregate(fns ...AggregateFunc) *PermissionSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *PermissionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !permission.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Permission, error) { + var ( + nodes = []*Permission{} + _spec = _q.querySpec() + loadedTypes = [4]bool{ + _q.withRoles != nil, + _q.withResources != nil, + _q.withRolePermissions != nil, + _q.withPermissionResources != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Permission).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Permission{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withRoles; query != nil { + if err := _q.loadRoles(ctx, query, nodes, + func(n *Permission) { n.Edges.Roles = []*Role{} }, + func(n *Permission, e *Role) { n.Edges.Roles = append(n.Edges.Roles, e) }); err != nil { + return nil, err + } + } + if query := _q.withResources; query != nil { + if err := _q.loadResources(ctx, query, nodes, + func(n *Permission) { n.Edges.Resources = []*Resource{} }, + func(n *Permission, e *Resource) { n.Edges.Resources = append(n.Edges.Resources, e) }); err != nil { + return nil, err + } + } + if query := _q.withRolePermissions; query != nil { + if err := _q.loadRolePermissions(ctx, query, nodes, + func(n *Permission) { n.Edges.RolePermissions = []*RolePermission{} }, + func(n *Permission, e *RolePermission) { n.Edges.RolePermissions = append(n.Edges.RolePermissions, e) }); err != nil { + return nil, err + } + } + if query := _q.withPermissionResources; query != nil { + if err := _q.loadPermissionResources(ctx, query, nodes, + func(n *Permission) { n.Edges.PermissionResources = []*PermissionResource{} }, + func(n *Permission, e *PermissionResource) { + n.Edges.PermissionResources = append(n.Edges.PermissionResources, e) + }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *PermissionQuery) loadRoles(ctx context.Context, query *RoleQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *Role)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int64]*Permission) + nids := make(map[int64]map[*Permission]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(permission.RolesTable) + s.Join(joinT).On(s.C(role.FieldID), joinT.C(permission.RolesPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(permission.RolesPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(permission.RolesPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullInt64).Int64 + inValue := values[1].(*sql.NullInt64).Int64 + if nids[inValue] == nil { + nids[inValue] = map[*Permission]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Role](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "roles" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (_q *PermissionQuery) loadResources(ctx context.Context, query *ResourceQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *Resource)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int64]*Permission) + nids := make(map[int64]map[*Permission]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(permission.ResourcesTable) + s.Join(joinT).On(s.C(resource.FieldID), joinT.C(permission.ResourcesPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(permission.ResourcesPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(permission.ResourcesPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullInt64).Int64 + inValue := values[1].(*sql.NullInt64).Int64 + if nids[inValue] == nil { + nids[inValue] = map[*Permission]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Resource](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "resources" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (_q *PermissionQuery) loadRolePermissions(ctx context.Context, query *RolePermissionQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *RolePermission)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*Permission) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(rolepermission.FieldPermissionID) + } + query.Where(predicate.RolePermission(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(permission.RolePermissionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.PermissionID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "permission_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *PermissionQuery) loadPermissionResources(ctx context.Context, query *PermissionResourceQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *PermissionResource)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*Permission) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(permissionresource.FieldPermissionID) + } + query.Where(predicate.PermissionResource(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(permission.PermissionResourcesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.PermissionID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "permission_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *PermissionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *PermissionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(permission.Table, permission.Columns, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, permission.FieldID) + for i := range fields { + if fields[i] != permission.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *PermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(permission.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = permission.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *PermissionQuery) ForUpdate(opts ...sql.LockOption) *PermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *PermissionQuery) ForShare(opts ...sql.LockOption) *PermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *PermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *PermissionSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// UpdateTime time.Time `json:"update_time,omitempty"` +// Name string `json:"name,omitempty"` +// Keyword string `json:"keyword,omitempty"` +// Description string `json:"description,omitempty"` +// DataScope string `json:"data_scope,omitempty"` +// DataRules map[string]string `json:"data_rules,omitempty"` +// Actions permission.Actions `json:"actions,omitempty"` +// } +// +// client.Permission.Query(). +// Omit( +// permission.FieldCreateTime, +// permission.FieldUpdateTime, +// permission.FieldName, +// permission.FieldKeyword, +// permission.FieldDescription, +// permission.FieldDataScope, +// permission.FieldDataRules, +// permission.FieldActions, +// ). +// Scan(ctx, &v) +func (pq *PermissionQuery) Omit(fields ...string) *PermissionSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range permission.Columns { + if _, ok := omits[col]; !ok { + pq.ctx.Fields = append(pq.ctx.Fields, col) + } + } + + sbuild := &PermissionSelect{PermissionQuery: pq} + sbuild.label = permission.Label + sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan + return sbuild +} + +// PermissionGroupBy is the group-by builder for Permission entities. +type PermissionGroupBy struct { + selector + build *PermissionQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *PermissionGroupBy) Aggregate(fns ...AggregateFunc) *PermissionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *PermissionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PermissionQuery, *PermissionGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *PermissionGroupBy) sqlScan(ctx context.Context, root *PermissionQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// PermissionSelect is the builder for selecting fields of Permission entities. +type PermissionSelect struct { + *PermissionQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *PermissionSelect) Aggregate(fns ...AggregateFunc) *PermissionSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *PermissionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PermissionQuery, *PermissionSelect](ctx, _s.PermissionQuery, _s, _s.inters, v) +} + +func (_s *PermissionSelect) sqlScan(ctx context.Context, root *PermissionQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *PermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *PermissionSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/internal/features/system/data/ent/permission_update.go b/internal/features/system/data/ent/permission_update.go new file mode 100644 index 00000000..8ee3a1db --- /dev/null +++ b/internal/features/system/data/ent/permission_update.go @@ -0,0 +1,1198 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PermissionUpdate is the builder for updating Permission entities. +type PermissionUpdate struct { + config + hooks []Hook + mutation *PermissionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the PermissionUpdate builder. +func (_u *PermissionUpdate) Where(ps ...predicate.Permission) *PermissionUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *PermissionUpdate) SetUpdateTime(v time.Time) *PermissionUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetName sets the "name" field. +func (_u *PermissionUpdate) SetName(v string) *PermissionUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *PermissionUpdate) SetNillableName(v *string) *PermissionUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetKeyword sets the "keyword" field. +func (_u *PermissionUpdate) SetKeyword(v string) *PermissionUpdate { + _u.mutation.SetKeyword(v) + return _u +} + +// SetNillableKeyword sets the "keyword" field if the given value is not nil. +func (_u *PermissionUpdate) SetNillableKeyword(v *string) *PermissionUpdate { + if v != nil { + _u.SetKeyword(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *PermissionUpdate) SetDescription(v string) *PermissionUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *PermissionUpdate) SetNillableDescription(v *string) *PermissionUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// SetDataScope sets the "data_scope" field. +func (_u *PermissionUpdate) SetDataScope(v string) *PermissionUpdate { + _u.mutation.SetDataScope(v) + return _u +} + +// SetNillableDataScope sets the "data_scope" field if the given value is not nil. +func (_u *PermissionUpdate) SetNillableDataScope(v *string) *PermissionUpdate { + if v != nil { + _u.SetDataScope(*v) + } + return _u +} + +// SetDataRules sets the "data_rules" field. +func (_u *PermissionUpdate) SetDataRules(v map[string]string) *PermissionUpdate { + _u.mutation.SetDataRules(v) + return _u +} + +// ClearDataRules clears the value of the "data_rules" field. +func (_u *PermissionUpdate) ClearDataRules() *PermissionUpdate { + _u.mutation.ClearDataRules() + return _u +} + +// SetActions sets the "actions" field. +func (_u *PermissionUpdate) SetActions(v permission.Actions) *PermissionUpdate { + _u.mutation.SetActions(v) + return _u +} + +// SetNillableActions sets the "actions" field if the given value is not nil. +func (_u *PermissionUpdate) SetNillableActions(v *permission.Actions) *PermissionUpdate { + if v != nil { + _u.SetActions(*v) + } + return _u +} + +// AddRoleIDs adds the "roles" edge to the Role entity by IDs. +func (_u *PermissionUpdate) AddRoleIDs(ids ...int64) *PermissionUpdate { + _u.mutation.AddRoleIDs(ids...) + return _u +} + +// AddRoles adds the "roles" edges to the Role entity. +func (_u *PermissionUpdate) AddRoles(v ...*Role) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRoleIDs(ids...) +} + +// AddResourceIDs adds the "resources" edge to the Resource entity by IDs. +func (_u *PermissionUpdate) AddResourceIDs(ids ...int64) *PermissionUpdate { + _u.mutation.AddResourceIDs(ids...) + return _u +} + +// AddResources adds the "resources" edges to the Resource entity. +func (_u *PermissionUpdate) AddResources(v ...*Resource) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddResourceIDs(ids...) +} + +// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. +func (_u *PermissionUpdate) AddRolePermissionIDs(ids ...int) *PermissionUpdate { + _u.mutation.AddRolePermissionIDs(ids...) + return _u +} + +// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. +func (_u *PermissionUpdate) AddRolePermissions(v ...*RolePermission) *PermissionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRolePermissionIDs(ids...) +} + +// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. +func (_u *PermissionUpdate) AddPermissionResourceIDs(ids ...int) *PermissionUpdate { + _u.mutation.AddPermissionResourceIDs(ids...) + return _u +} + +// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. +func (_u *PermissionUpdate) AddPermissionResources(v ...*PermissionResource) *PermissionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPermissionResourceIDs(ids...) +} + +// Mutation returns the PermissionMutation object of the builder. +func (_u *PermissionUpdate) Mutation() *PermissionMutation { + return _u.mutation +} + +// ClearRoles clears all "roles" edges to the Role entity. +func (_u *PermissionUpdate) ClearRoles() *PermissionUpdate { + _u.mutation.ClearRoles() + return _u +} + +// RemoveRoleIDs removes the "roles" edge to Role entities by IDs. +func (_u *PermissionUpdate) RemoveRoleIDs(ids ...int64) *PermissionUpdate { + _u.mutation.RemoveRoleIDs(ids...) + return _u +} + +// RemoveRoles removes "roles" edges to Role entities. +func (_u *PermissionUpdate) RemoveRoles(v ...*Role) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRoleIDs(ids...) +} + +// ClearResources clears all "resources" edges to the Resource entity. +func (_u *PermissionUpdate) ClearResources() *PermissionUpdate { + _u.mutation.ClearResources() + return _u +} + +// RemoveResourceIDs removes the "resources" edge to Resource entities by IDs. +func (_u *PermissionUpdate) RemoveResourceIDs(ids ...int64) *PermissionUpdate { + _u.mutation.RemoveResourceIDs(ids...) + return _u +} + +// RemoveResources removes "resources" edges to Resource entities. +func (_u *PermissionUpdate) RemoveResources(v ...*Resource) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveResourceIDs(ids...) +} + +// ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. +func (_u *PermissionUpdate) ClearRolePermissions() *PermissionUpdate { + _u.mutation.ClearRolePermissions() + return _u +} + +// RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. +func (_u *PermissionUpdate) RemoveRolePermissionIDs(ids ...int) *PermissionUpdate { + _u.mutation.RemoveRolePermissionIDs(ids...) + return _u +} + +// RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. +func (_u *PermissionUpdate) RemoveRolePermissions(v ...*RolePermission) *PermissionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRolePermissionIDs(ids...) +} + +// ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. +func (_u *PermissionUpdate) ClearPermissionResources() *PermissionUpdate { + _u.mutation.ClearPermissionResources() + return _u +} + +// RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. +func (_u *PermissionUpdate) RemovePermissionResourceIDs(ids ...int) *PermissionUpdate { + _u.mutation.RemovePermissionResourceIDs(ids...) + return _u +} + +// RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. +func (_u *PermissionUpdate) RemovePermissionResources(v ...*PermissionResource) *PermissionUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePermissionResourceIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *PermissionUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *PermissionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *PermissionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PermissionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *PermissionUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := permission.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PermissionUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := permission.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Permission.name": %w`, err)} + } + } + if v, ok := _u.mutation.Keyword(); ok { + if err := permission.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Permission.keyword": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := permission.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} + } + } + if v, ok := _u.mutation.Actions(); ok { + if err := permission.ActionsValidator(v); err != nil { + return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *PermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(permission.Table, permission.Columns, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(permission.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(permission.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Keyword(); ok { + _spec.SetField(permission.FieldKeyword, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(permission.FieldDescription, field.TypeString, value) + } + if value, ok := _u.mutation.DataScope(); ok { + _spec.SetField(permission.FieldDataScope, field.TypeString, value) + } + if value, ok := _u.mutation.DataRules(); ok { + _spec.SetField(permission.FieldDataRules, field.TypeJSON, value) + } + if _u.mutation.DataRulesCleared() { + _spec.ClearField(permission.FieldDataRules, field.TypeJSON) + } + if value, ok := _u.mutation.Actions(); ok { + _spec.SetField(permission.FieldActions, field.TypeEnum, value) + } + if _u.mutation.RolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: permission.RolesTable, + Columns: permission.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: permission.RolesTable, + Columns: permission.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: permission.RolesTable, + Columns: permission.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ResourcesTable, + Columns: permission.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !_u.mutation.ResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ResourcesTable, + Columns: permission.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ResourcesTable, + Columns: permission.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.RolePermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.RolePermissionsTable, + Columns: []string{permission.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.RolePermissionsTable, + Columns: []string{permission.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.RolePermissionsTable, + Columns: []string{permission.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.PermissionResourcesTable, + Columns: []string{permission.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.PermissionResourcesTable, + Columns: []string{permission.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.PermissionResourcesTable, + Columns: []string{permission.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{permission.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// PermissionUpdateOne is the builder for updating a single Permission entity. +type PermissionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PermissionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdateTime sets the "update_time" field. +func (_u *PermissionUpdateOne) SetUpdateTime(v time.Time) *PermissionUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetName sets the "name" field. +func (_u *PermissionUpdateOne) SetName(v string) *PermissionUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *PermissionUpdateOne) SetNillableName(v *string) *PermissionUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetKeyword sets the "keyword" field. +func (_u *PermissionUpdateOne) SetKeyword(v string) *PermissionUpdateOne { + _u.mutation.SetKeyword(v) + return _u +} + +// SetNillableKeyword sets the "keyword" field if the given value is not nil. +func (_u *PermissionUpdateOne) SetNillableKeyword(v *string) *PermissionUpdateOne { + if v != nil { + _u.SetKeyword(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *PermissionUpdateOne) SetDescription(v string) *PermissionUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *PermissionUpdateOne) SetNillableDescription(v *string) *PermissionUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// SetDataScope sets the "data_scope" field. +func (_u *PermissionUpdateOne) SetDataScope(v string) *PermissionUpdateOne { + _u.mutation.SetDataScope(v) + return _u +} + +// SetNillableDataScope sets the "data_scope" field if the given value is not nil. +func (_u *PermissionUpdateOne) SetNillableDataScope(v *string) *PermissionUpdateOne { + if v != nil { + _u.SetDataScope(*v) + } + return _u +} + +// SetDataRules sets the "data_rules" field. +func (_u *PermissionUpdateOne) SetDataRules(v map[string]string) *PermissionUpdateOne { + _u.mutation.SetDataRules(v) + return _u +} + +// ClearDataRules clears the value of the "data_rules" field. +func (_u *PermissionUpdateOne) ClearDataRules() *PermissionUpdateOne { + _u.mutation.ClearDataRules() + return _u +} + +// SetActions sets the "actions" field. +func (_u *PermissionUpdateOne) SetActions(v permission.Actions) *PermissionUpdateOne { + _u.mutation.SetActions(v) + return _u +} + +// SetNillableActions sets the "actions" field if the given value is not nil. +func (_u *PermissionUpdateOne) SetNillableActions(v *permission.Actions) *PermissionUpdateOne { + if v != nil { + _u.SetActions(*v) + } + return _u +} + +// AddRoleIDs adds the "roles" edge to the Role entity by IDs. +func (_u *PermissionUpdateOne) AddRoleIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.AddRoleIDs(ids...) + return _u +} + +// AddRoles adds the "roles" edges to the Role entity. +func (_u *PermissionUpdateOne) AddRoles(v ...*Role) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRoleIDs(ids...) +} + +// AddResourceIDs adds the "resources" edge to the Resource entity by IDs. +func (_u *PermissionUpdateOne) AddResourceIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.AddResourceIDs(ids...) + return _u +} + +// AddResources adds the "resources" edges to the Resource entity. +func (_u *PermissionUpdateOne) AddResources(v ...*Resource) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddResourceIDs(ids...) +} + +// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. +func (_u *PermissionUpdateOne) AddRolePermissionIDs(ids ...int) *PermissionUpdateOne { + _u.mutation.AddRolePermissionIDs(ids...) + return _u +} + +// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. +func (_u *PermissionUpdateOne) AddRolePermissions(v ...*RolePermission) *PermissionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRolePermissionIDs(ids...) +} + +// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. +func (_u *PermissionUpdateOne) AddPermissionResourceIDs(ids ...int) *PermissionUpdateOne { + _u.mutation.AddPermissionResourceIDs(ids...) + return _u +} + +// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. +func (_u *PermissionUpdateOne) AddPermissionResources(v ...*PermissionResource) *PermissionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPermissionResourceIDs(ids...) +} + +// Mutation returns the PermissionMutation object of the builder. +func (_u *PermissionUpdateOne) Mutation() *PermissionMutation { + return _u.mutation +} + +// ClearRoles clears all "roles" edges to the Role entity. +func (_u *PermissionUpdateOne) ClearRoles() *PermissionUpdateOne { + _u.mutation.ClearRoles() + return _u +} + +// RemoveRoleIDs removes the "roles" edge to Role entities by IDs. +func (_u *PermissionUpdateOne) RemoveRoleIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.RemoveRoleIDs(ids...) + return _u +} + +// RemoveRoles removes "roles" edges to Role entities. +func (_u *PermissionUpdateOne) RemoveRoles(v ...*Role) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRoleIDs(ids...) +} + +// ClearResources clears all "resources" edges to the Resource entity. +func (_u *PermissionUpdateOne) ClearResources() *PermissionUpdateOne { + _u.mutation.ClearResources() + return _u +} + +// RemoveResourceIDs removes the "resources" edge to Resource entities by IDs. +func (_u *PermissionUpdateOne) RemoveResourceIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.RemoveResourceIDs(ids...) + return _u +} + +// RemoveResources removes "resources" edges to Resource entities. +func (_u *PermissionUpdateOne) RemoveResources(v ...*Resource) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveResourceIDs(ids...) +} + +// ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. +func (_u *PermissionUpdateOne) ClearRolePermissions() *PermissionUpdateOne { + _u.mutation.ClearRolePermissions() + return _u +} + +// RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. +func (_u *PermissionUpdateOne) RemoveRolePermissionIDs(ids ...int) *PermissionUpdateOne { + _u.mutation.RemoveRolePermissionIDs(ids...) + return _u +} + +// RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. +func (_u *PermissionUpdateOne) RemoveRolePermissions(v ...*RolePermission) *PermissionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRolePermissionIDs(ids...) +} + +// ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. +func (_u *PermissionUpdateOne) ClearPermissionResources() *PermissionUpdateOne { + _u.mutation.ClearPermissionResources() + return _u +} + +// RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. +func (_u *PermissionUpdateOne) RemovePermissionResourceIDs(ids ...int) *PermissionUpdateOne { + _u.mutation.RemovePermissionResourceIDs(ids...) + return _u +} + +// RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. +func (_u *PermissionUpdateOne) RemovePermissionResources(v ...*PermissionResource) *PermissionUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePermissionResourceIDs(ids...) +} + +// Where appends a list predicates to the PermissionUpdate builder. +func (_u *PermissionUpdateOne) Where(ps ...predicate.Permission) *PermissionUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *PermissionUpdateOne) Select(field string, fields ...string) *PermissionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated Permission entity. +func (_u *PermissionUpdateOne) Save(ctx context.Context) (*Permission, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *PermissionUpdateOne) SaveX(ctx context.Context) *Permission { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *PermissionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PermissionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *PermissionUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := permission.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PermissionUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := permission.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Permission.name": %w`, err)} + } + } + if v, ok := _u.mutation.Keyword(); ok { + if err := permission.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Permission.keyword": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := permission.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} + } + } + if v, ok := _u.mutation.Actions(); ok { + if err := permission.ActionsValidator(v); err != nil { + return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *PermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(permission.Table, permission.Columns, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Permission.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, permission.FieldID) + for _, f := range fields { + if !permission.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != permission.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(permission.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(permission.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Keyword(); ok { + _spec.SetField(permission.FieldKeyword, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(permission.FieldDescription, field.TypeString, value) + } + if value, ok := _u.mutation.DataScope(); ok { + _spec.SetField(permission.FieldDataScope, field.TypeString, value) + } + if value, ok := _u.mutation.DataRules(); ok { + _spec.SetField(permission.FieldDataRules, field.TypeJSON, value) + } + if _u.mutation.DataRulesCleared() { + _spec.ClearField(permission.FieldDataRules, field.TypeJSON) + } + if value, ok := _u.mutation.Actions(); ok { + _spec.SetField(permission.FieldActions, field.TypeEnum, value) + } + if _u.mutation.RolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: permission.RolesTable, + Columns: permission.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: permission.RolesTable, + Columns: permission.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: permission.RolesTable, + Columns: permission.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ResourcesTable, + Columns: permission.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !_u.mutation.ResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ResourcesTable, + Columns: permission.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ResourcesTable, + Columns: permission.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.RolePermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.RolePermissionsTable, + Columns: []string{permission.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.RolePermissionsTable, + Columns: []string{permission.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.RolePermissionsTable, + Columns: []string{permission.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.PermissionResourcesTable, + Columns: []string{permission.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.PermissionResourcesTable, + Columns: []string{permission.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.PermissionResourcesTable, + Columns: []string{permission.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &Permission{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{permission.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} + +// SetPermission set the Permission +func (pu *PermissionUpdate) SetPermission(input *Permission, fields ...string) *PermissionUpdate { + m := pu.mutation + if len(fields) == 0 { + fields = permission.OmitColumns(permission.FieldID) + } + _ = m.SetFields(input, fields...) + return pu +} + +// SetPermissionWithZero set the Permission +func (pu *PermissionUpdate) SetPermissionWithZero(input *Permission, fields ...string) *PermissionUpdate { + m := pu.mutation + if len(fields) == 0 { + fields = permission.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return pu +} + +// SetPermission set the Permission +func (puo *PermissionUpdateOne) SetPermission(input *Permission, fields ...string) *PermissionUpdateOne { + m := puo.mutation + if len(fields) == 0 { + fields = permission.OmitColumns(permission.FieldID) + } + _ = m.SetFields(input, fields...) + return puo +} + +// SetPermissionWithZero set the Permission +func (puo *PermissionUpdateOne) SetPermissionWithZero(input *Permission, fields ...string) *PermissionUpdateOne { + m := puo.mutation + if len(fields) == 0 { + fields = permission.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return puo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (puo *PermissionUpdateOne) Omit(fields ...string) *PermissionUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + puo.fields = []string(nil) + for _, col := range permission.Columns { + if _, ok := omits[col]; !ok { + puo.fields = append(puo.fields, col) + } + } + return puo +} diff --git a/internal/features/system/data/ent/permissionresource.go b/internal/features/system/data/ent/permissionresource.go new file mode 100644 index 00000000..6b93d940 --- /dev/null +++ b/internal/features/system/data/ent/permissionresource.go @@ -0,0 +1,160 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// Permission-Resource mapping table +type PermissionResource struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // PermissionID holds the value of the "permission_id" field. + PermissionID int64 `json:"permission_id,omitempty"` + // ResourceID holds the value of the "resource_id" field. + ResourceID int64 `json:"resource_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the PermissionResourceQuery when eager-loading is set. + Edges PermissionResourceEdges `json:"edges"` + selectValues sql.SelectValues +} + +// PermissionResourceEdges holds the relations/edges for other nodes in the graph. +type PermissionResourceEdges struct { + // Permission holds the value of the permission edge. + Permission *Permission `json:"permission,omitempty"` + // Resource holds the value of the resource edge. + Resource *Resource `json:"resource,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// PermissionOrErr returns the Permission value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PermissionResourceEdges) PermissionOrErr() (*Permission, error) { + if e.Permission != nil { + return e.Permission, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: permission.Label} + } + return nil, &NotLoadedError{edge: "permission"} +} + +// ResourceOrErr returns the Resource value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e PermissionResourceEdges) ResourceOrErr() (*Resource, error) { + if e.Resource != nil { + return e.Resource, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: resource.Label} + } + return nil, &NotLoadedError{edge: "resource"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*PermissionResource) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case permissionresource.FieldID, permissionresource.FieldPermissionID, permissionresource.FieldResourceID: + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the PermissionResource fields. +func (_m *PermissionResource) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case permissionresource.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int(value.Int64) + case permissionresource.FieldPermissionID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field permission_id", values[i]) + } else if value.Valid { + _m.PermissionID = value.Int64 + } + case permissionresource.FieldResourceID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field resource_id", values[i]) + } else if value.Valid { + _m.ResourceID = value.Int64 + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the PermissionResource. +// This includes values selected through modifiers, order, etc. +func (_m *PermissionResource) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryPermission queries the "permission" edge of the PermissionResource entity. +func (_m *PermissionResource) QueryPermission() *PermissionQuery { + return NewPermissionResourceClient(_m.config).QueryPermission(_m) +} + +// QueryResource queries the "resource" edge of the PermissionResource entity. +func (_m *PermissionResource) QueryResource() *ResourceQuery { + return NewPermissionResourceClient(_m.config).QueryResource(_m) +} + +// Update returns a builder for updating this PermissionResource. +// Note that you need to call PermissionResource.Unwrap() before calling this method if this PermissionResource +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *PermissionResource) Update() *PermissionResourceUpdateOne { + return NewPermissionResourceClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the PermissionResource entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *PermissionResource) Unwrap() *PermissionResource { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: PermissionResource is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *PermissionResource) String() string { + var builder strings.Builder + builder.WriteString("PermissionResource(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("permission_id=") + builder.WriteString(fmt.Sprintf("%v", _m.PermissionID)) + builder.WriteString(", ") + builder.WriteString("resource_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ResourceID)) + builder.WriteByte(')') + return builder.String() +} + +// PermissionResources is a parsable slice of PermissionResource. +type PermissionResources []*PermissionResource diff --git a/internal/features/system/data/ent/permissionresource/permissionresource.go b/internal/features/system/data/ent/permissionresource/permissionresource.go new file mode 100644 index 00000000..80efab8e --- /dev/null +++ b/internal/features/system/data/ent/permissionresource/permissionresource.go @@ -0,0 +1,164 @@ +// Code generated by ent, DO NOT EDIT. + +package permissionresource + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the permissionresource type in the database. + Label = "permission_resource" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldPermissionID holds the string denoting the permission_id field in the database. + FieldPermissionID = "permission_id" + // FieldResourceID holds the string denoting the resource_id field in the database. + FieldResourceID = "resource_id" + // EdgePermission holds the string denoting the permission edge name in mutations. + EdgePermission = "permission" + // EdgeResource holds the string denoting the resource edge name in mutations. + EdgeResource = "resource" + // Table holds the table name of the permissionresource in the database. + Table = "sys_permission_resources" + // PermissionTable is the table that holds the permission relation/edge. + PermissionTable = "sys_permission_resources" + // PermissionInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionInverseTable = "sys_permissions" + // PermissionColumn is the table column denoting the permission relation/edge. + PermissionColumn = "permission_id" + // ResourceTable is the table that holds the resource relation/edge. + ResourceTable = "sys_permission_resources" + // ResourceInverseTable is the table name for the Resource entity. + // It exists in this package in order to avoid circular dependency with the "resource" package. + ResourceInverseTable = "sys_resources" + // ResourceColumn is the table column denoting the resource relation/edge. + ResourceColumn = "resource_id" +) + +// Columns holds all SQL columns for permissionresource fields. +var Columns = []string{ + FieldID, + FieldPermissionID, + FieldResourceID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +// OrderOption defines the ordering options for the PermissionResource queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByPermissionID orders the results by the permission_id field. +func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPermissionID, opts...).ToFunc() +} + +// ByResourceID orders the results by the resource_id field. +func ByResourceID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldResourceID, opts...).ToFunc() +} + +// ByPermissionField orders the results by permission field. +func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) + } +} + +// ByResourceField orders the results by resource field. +func ByResourceField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newResourceStep(), sql.OrderByField(field, opts...)) + } +} +func newPermissionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) +} +func newResourceStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ResourceInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ResourceTable, ResourceColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/features/system/data/ent/permissionresource/where.go b/internal/features/system/data/ent/permissionresource/where.go new file mode 100644 index 00000000..11fb6433 --- /dev/null +++ b/internal/features/system/data/ent/permissionresource/where.go @@ -0,0 +1,166 @@ +// Code generated by ent, DO NOT EDIT. + +package permissionresource + +import ( + "origadmin/application/admin/internal/features/system/data/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldLTE(FieldID, id)) +} + +// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. +func PermissionID(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldPermissionID, v)) +} + +// ResourceID applies equality check predicate on the "resource_id" field. It's identical to ResourceIDEQ. +func ResourceID(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldResourceID, v)) +} + +// PermissionIDEQ applies the EQ predicate on the "permission_id" field. +func PermissionIDEQ(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldPermissionID, v)) +} + +// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. +func PermissionIDNEQ(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNEQ(FieldPermissionID, v)) +} + +// PermissionIDIn applies the In predicate on the "permission_id" field. +func PermissionIDIn(vs ...int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldIn(FieldPermissionID, vs...)) +} + +// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. +func PermissionIDNotIn(vs ...int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNotIn(FieldPermissionID, vs...)) +} + +// ResourceIDEQ applies the EQ predicate on the "resource_id" field. +func ResourceIDEQ(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldEQ(FieldResourceID, v)) +} + +// ResourceIDNEQ applies the NEQ predicate on the "resource_id" field. +func ResourceIDNEQ(v int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNEQ(FieldResourceID, v)) +} + +// ResourceIDIn applies the In predicate on the "resource_id" field. +func ResourceIDIn(vs ...int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldIn(FieldResourceID, vs...)) +} + +// ResourceIDNotIn applies the NotIn predicate on the "resource_id" field. +func ResourceIDNotIn(vs ...int64) predicate.PermissionResource { + return predicate.PermissionResource(sql.FieldNotIn(FieldResourceID, vs...)) +} + +// HasPermission applies the HasEdge predicate on the "permission" edge. +func HasPermission() predicate.PermissionResource { + return predicate.PermissionResource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). +func HasPermissionWith(preds ...predicate.Permission) predicate.PermissionResource { + return predicate.PermissionResource(func(s *sql.Selector) { + step := newPermissionStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasResource applies the HasEdge predicate on the "resource" edge. +func HasResource() predicate.PermissionResource { + return predicate.PermissionResource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ResourceTable, ResourceColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasResourceWith applies the HasEdge predicate on the "resource" edge with a given conditions (other predicates). +func HasResourceWith(preds ...predicate.Resource) predicate.PermissionResource { + return predicate.PermissionResource(func(s *sql.Selector) { + step := newResourceStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.PermissionResource) predicate.PermissionResource { + return predicate.PermissionResource(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.PermissionResource) predicate.PermissionResource { + return predicate.PermissionResource(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.PermissionResource) predicate.PermissionResource { + return predicate.PermissionResource(sql.NotPredicates(p)) +} diff --git a/internal/features/system/data/ent/permissionresource_create.go b/internal/features/system/data/ent/permissionresource_create.go new file mode 100644 index 00000000..657da848 --- /dev/null +++ b/internal/features/system/data/ent/permissionresource_create.go @@ -0,0 +1,260 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/resource" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PermissionResourceCreate is the builder for creating a PermissionResource entity. +type PermissionResourceCreate struct { + config + mutation *PermissionResourceMutation + hooks []Hook +} + +// SetPermissionID sets the "permission_id" field. +func (_c *PermissionResourceCreate) SetPermissionID(v int64) *PermissionResourceCreate { + _c.mutation.SetPermissionID(v) + return _c +} + +// SetResourceID sets the "resource_id" field. +func (_c *PermissionResourceCreate) SetResourceID(v int64) *PermissionResourceCreate { + _c.mutation.SetResourceID(v) + return _c +} + +// SetPermission sets the "permission" edge to the Permission entity. +func (_c *PermissionResourceCreate) SetPermission(v *Permission) *PermissionResourceCreate { + return _c.SetPermissionID(v.ID) +} + +// SetResource sets the "resource" edge to the Resource entity. +func (_c *PermissionResourceCreate) SetResource(v *Resource) *PermissionResourceCreate { + return _c.SetResourceID(v.ID) +} + +// Mutation returns the PermissionResourceMutation object of the builder. +func (_c *PermissionResourceCreate) Mutation() *PermissionResourceMutation { + return _c.mutation +} + +// Save creates the PermissionResource in the database. +func (_c *PermissionResourceCreate) Save(ctx context.Context) (*PermissionResource, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *PermissionResourceCreate) SaveX(ctx context.Context) *PermissionResource { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PermissionResourceCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PermissionResourceCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *PermissionResourceCreate) check() error { + if _, ok := _c.mutation.PermissionID(); !ok { + return &ValidationError{Name: "permission_id", err: errors.New(`ent: missing required field "PermissionResource.permission_id"`)} + } + if _, ok := _c.mutation.ResourceID(); !ok { + return &ValidationError{Name: "resource_id", err: errors.New(`ent: missing required field "PermissionResource.resource_id"`)} + } + if len(_c.mutation.PermissionIDs()) == 0 { + return &ValidationError{Name: "permission", err: errors.New(`ent: missing required edge "PermissionResource.permission"`)} + } + if len(_c.mutation.ResourceIDs()) == 0 { + return &ValidationError{Name: "resource", err: errors.New(`ent: missing required edge "PermissionResource.resource"`)} + } + return nil +} + +func (_c *PermissionResourceCreate) sqlSave(ctx context.Context) (*PermissionResource, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *PermissionResourceCreate) createSpec() (*PermissionResource, *sqlgraph.CreateSpec) { + var ( + _node = &PermissionResource{config: _c.config} + _spec = sqlgraph.NewCreateSpec(permissionresource.Table, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) + ) + if nodes := _c.mutation.PermissionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: permissionresource.PermissionTable, + Columns: []string{permissionresource.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.PermissionID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ResourceIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: permissionresource.ResourceTable, + Columns: []string{permissionresource.ResourceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ResourceID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SetPermissionResource set the PermissionResource +func (_c *PermissionResourceCreate) SetPermissionResource(input *PermissionResource, fields ...string) *PermissionResourceCreate { + m := _c.mutation + if len(fields) == 0 { + fields = permissionresource.Columns + } + _ = m.SetFields(input, fields...) + return _c +} + +// SetPermissionResourceWithZero set the PermissionResource +func (_c *PermissionResourceCreate) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceCreate { + m := _c.mutation + if len(fields) == 0 { + fields = permissionresource.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return _c +} + +// PermissionResourceCreateBulk is the builder for creating many PermissionResource entities in bulk. +type PermissionResourceCreateBulk struct { + config + err error + builders []*PermissionResourceCreate +} + +// Save creates the PermissionResource entities in the database. +func (_c *PermissionResourceCreateBulk) Save(ctx context.Context) ([]*PermissionResource, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*PermissionResource, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*PermissionResourceMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *PermissionResourceCreateBulk) SaveX(ctx context.Context) []*PermissionResource { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *PermissionResourceCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *PermissionResourceCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/permissionresource_delete.go b/internal/features/system/data/ent/permissionresource_delete.go new file mode 100644 index 00000000..67f5f2a6 --- /dev/null +++ b/internal/features/system/data/ent/permissionresource_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PermissionResourceDelete is the builder for deleting a PermissionResource entity. +type PermissionResourceDelete struct { + config + hooks []Hook + mutation *PermissionResourceMutation +} + +// Where appends a list predicates to the PermissionResourceDelete builder. +func (_d *PermissionResourceDelete) Where(ps ...predicate.PermissionResource) *PermissionResourceDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *PermissionResourceDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PermissionResourceDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *PermissionResourceDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(permissionresource.Table, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// PermissionResourceDeleteOne is the builder for deleting a single PermissionResource entity. +type PermissionResourceDeleteOne struct { + _d *PermissionResourceDelete +} + +// Where appends a list predicates to the PermissionResourceDelete builder. +func (_d *PermissionResourceDeleteOne) Where(ps ...predicate.PermissionResource) *PermissionResourceDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *PermissionResourceDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{permissionresource.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *PermissionResourceDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/permissionresource_query.go b/internal/features/system/data/ent/permissionresource_query.go new file mode 100644 index 00000000..a991af18 --- /dev/null +++ b/internal/features/system/data/ent/permissionresource_query.go @@ -0,0 +1,763 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/resource" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PermissionResourceQuery is the builder for querying PermissionResource entities. +type PermissionResourceQuery struct { + config + ctx *QueryContext + order []permissionresource.OrderOption + inters []Interceptor + predicates []predicate.PermissionResource + withPermission *PermissionQuery + withResource *ResourceQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the PermissionResourceQuery builder. +func (_q *PermissionResourceQuery) Where(ps ...predicate.PermissionResource) *PermissionResourceQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *PermissionResourceQuery) Limit(limit int) *PermissionResourceQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *PermissionResourceQuery) Offset(offset int) *PermissionResourceQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *PermissionResourceQuery) Unique(unique bool) *PermissionResourceQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *PermissionResourceQuery) Order(o ...permissionresource.OrderOption) *PermissionResourceQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryPermission chains the current query on the "permission" edge. +func (_q *PermissionResourceQuery) QueryPermission() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(permissionresource.Table, permissionresource.FieldID, selector), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.PermissionTable, permissionresource.PermissionColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryResource chains the current query on the "resource" edge. +func (_q *PermissionResourceQuery) QueryResource() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(permissionresource.Table, permissionresource.FieldID, selector), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.ResourceTable, permissionresource.ResourceColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first PermissionResource entity from the query. +// Returns a *NotFoundError when no PermissionResource was found. +func (_q *PermissionResourceQuery) First(ctx context.Context) (*PermissionResource, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{permissionresource.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *PermissionResourceQuery) FirstX(ctx context.Context) *PermissionResource { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first PermissionResource ID from the query. +// Returns a *NotFoundError when no PermissionResource ID was found. +func (_q *PermissionResourceQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{permissionresource.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *PermissionResourceQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single PermissionResource entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one PermissionResource entity is found. +// Returns a *NotFoundError when no PermissionResource entities are found. +func (_q *PermissionResourceQuery) Only(ctx context.Context) (*PermissionResource, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{permissionresource.Label} + default: + return nil, &NotSingularError{permissionresource.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *PermissionResourceQuery) OnlyX(ctx context.Context) *PermissionResource { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only PermissionResource ID in the query. +// Returns a *NotSingularError when more than one PermissionResource ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *PermissionResourceQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{permissionresource.Label} + default: + err = &NotSingularError{permissionresource.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *PermissionResourceQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of PermissionResources. +func (_q *PermissionResourceQuery) All(ctx context.Context) ([]*PermissionResource, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*PermissionResource, *PermissionResourceQuery]() + return withInterceptors[[]*PermissionResource](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *PermissionResourceQuery) AllX(ctx context.Context) []*PermissionResource { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of PermissionResource IDs. +func (_q *PermissionResourceQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(permissionresource.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *PermissionResourceQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *PermissionResourceQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*PermissionResourceQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *PermissionResourceQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *PermissionResourceQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *PermissionResourceQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the PermissionResourceQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *PermissionResourceQuery) Clone() *PermissionResourceQuery { + if _q == nil { + return nil + } + return &PermissionResourceQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]permissionresource.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.PermissionResource{}, _q.predicates...), + withPermission: _q.withPermission.Clone(), + withResource: _q.withResource.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithPermission tells the query-builder to eager-load the nodes that are connected to +// the "permission" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PermissionResourceQuery) WithPermission(opts ...func(*PermissionQuery)) *PermissionResourceQuery { + query := (&PermissionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withPermission = query + return _q +} + +// WithResource tells the query-builder to eager-load the nodes that are connected to +// the "resource" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PermissionResourceQuery) WithResource(opts ...func(*ResourceQuery)) *PermissionResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withResource = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// PermissionID int64 `json:"permission_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.PermissionResource.Query(). +// GroupBy(permissionresource.FieldPermissionID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *PermissionResourceQuery) GroupBy(field string, fields ...string) *PermissionResourceGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PermissionResourceGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = permissionresource.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// PermissionID int64 `json:"permission_id,omitempty"` +// } +// +// client.PermissionResource.Query(). +// Select(permissionresource.FieldPermissionID). +// Scan(ctx, &v) +func (_q *PermissionResourceQuery) Select(fields ...string) *PermissionResourceSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PermissionResourceSelect{PermissionResourceQuery: _q} + sbuild.label = permissionresource.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a PermissionResourceSelect configured with the given aggregations. +func (_q *PermissionResourceQuery) Aggregate(fns ...AggregateFunc) *PermissionResourceSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *PermissionResourceQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !permissionresource.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *PermissionResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PermissionResource, error) { + var ( + nodes = []*PermissionResource{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withPermission != nil, + _q.withResource != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*PermissionResource).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &PermissionResource{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withPermission; query != nil { + if err := _q.loadPermission(ctx, query, nodes, nil, + func(n *PermissionResource, e *Permission) { n.Edges.Permission = e }); err != nil { + return nil, err + } + } + if query := _q.withResource; query != nil { + if err := _q.loadResource(ctx, query, nodes, nil, + func(n *PermissionResource, e *Resource) { n.Edges.Resource = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *PermissionResourceQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*PermissionResource, init func(*PermissionResource), assign func(*PermissionResource, *Permission)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*PermissionResource) + for i := range nodes { + fk := nodes[i].PermissionID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(permission.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "permission_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *PermissionResourceQuery) loadResource(ctx context.Context, query *ResourceQuery, nodes []*PermissionResource, init func(*PermissionResource), assign func(*PermissionResource, *Resource)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*PermissionResource) + for i := range nodes { + fk := nodes[i].ResourceID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(resource.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "resource_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *PermissionResourceQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *PermissionResourceQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(permissionresource.Table, permissionresource.Columns, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, permissionresource.FieldID) + for i := range fields { + if fields[i] != permissionresource.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withPermission != nil { + _spec.Node.AddColumnOnce(permissionresource.FieldPermissionID) + } + if _q.withResource != nil { + _spec.Node.AddColumnOnce(permissionresource.FieldResourceID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *PermissionResourceQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(permissionresource.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = permissionresource.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *PermissionResourceQuery) ForUpdate(opts ...sql.LockOption) *PermissionResourceQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *PermissionResourceQuery) ForShare(opts ...sql.LockOption) *PermissionResourceQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *PermissionResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *PermissionResourceSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// PermissionID int64 `json:"permission_id,omitempty"` +// ResourceID int64 `json:"resource_id,omitempty"` +// } +// +// client.PermissionResource.Query(). +// Omit( +// permissionresource.FieldPermissionID, +// permissionresource.FieldResourceID, +// ). +// Scan(ctx, &v) +func (prq *PermissionResourceQuery) Omit(fields ...string) *PermissionResourceSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range permissionresource.Columns { + if _, ok := omits[col]; !ok { + prq.ctx.Fields = append(prq.ctx.Fields, col) + } + } + + sbuild := &PermissionResourceSelect{PermissionResourceQuery: prq} + sbuild.label = permissionresource.Label + sbuild.flds, sbuild.scan = &prq.ctx.Fields, sbuild.Scan + return sbuild +} + +// PermissionResourceGroupBy is the group-by builder for PermissionResource entities. +type PermissionResourceGroupBy struct { + selector + build *PermissionResourceQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *PermissionResourceGroupBy) Aggregate(fns ...AggregateFunc) *PermissionResourceGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *PermissionResourceGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PermissionResourceQuery, *PermissionResourceGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *PermissionResourceGroupBy) sqlScan(ctx context.Context, root *PermissionResourceQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// PermissionResourceSelect is the builder for selecting fields of PermissionResource entities. +type PermissionResourceSelect struct { + *PermissionResourceQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *PermissionResourceSelect) Aggregate(fns ...AggregateFunc) *PermissionResourceSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *PermissionResourceSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*PermissionResourceQuery, *PermissionResourceSelect](ctx, _s.PermissionResourceQuery, _s, _s.inters, v) +} + +func (_s *PermissionResourceSelect) sqlScan(ctx context.Context, root *PermissionResourceQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *PermissionResourceSelect) Modify(modifiers ...func(s *sql.Selector)) *PermissionResourceSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/internal/features/system/data/ent/permissionresource_update.go b/internal/features/system/data/ent/permissionresource_update.go new file mode 100644 index 00000000..4e4fc345 --- /dev/null +++ b/internal/features/system/data/ent/permissionresource_update.go @@ -0,0 +1,493 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/resource" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// PermissionResourceUpdate is the builder for updating PermissionResource entities. +type PermissionResourceUpdate struct { + config + hooks []Hook + mutation *PermissionResourceMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the PermissionResourceUpdate builder. +func (_u *PermissionResourceUpdate) Where(ps ...predicate.PermissionResource) *PermissionResourceUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetPermissionID sets the "permission_id" field. +func (_u *PermissionResourceUpdate) SetPermissionID(v int64) *PermissionResourceUpdate { + _u.mutation.SetPermissionID(v) + return _u +} + +// SetNillablePermissionID sets the "permission_id" field if the given value is not nil. +func (_u *PermissionResourceUpdate) SetNillablePermissionID(v *int64) *PermissionResourceUpdate { + if v != nil { + _u.SetPermissionID(*v) + } + return _u +} + +// SetResourceID sets the "resource_id" field. +func (_u *PermissionResourceUpdate) SetResourceID(v int64) *PermissionResourceUpdate { + _u.mutation.SetResourceID(v) + return _u +} + +// SetNillableResourceID sets the "resource_id" field if the given value is not nil. +func (_u *PermissionResourceUpdate) SetNillableResourceID(v *int64) *PermissionResourceUpdate { + if v != nil { + _u.SetResourceID(*v) + } + return _u +} + +// SetPermission sets the "permission" edge to the Permission entity. +func (_u *PermissionResourceUpdate) SetPermission(v *Permission) *PermissionResourceUpdate { + return _u.SetPermissionID(v.ID) +} + +// SetResource sets the "resource" edge to the Resource entity. +func (_u *PermissionResourceUpdate) SetResource(v *Resource) *PermissionResourceUpdate { + return _u.SetResourceID(v.ID) +} + +// Mutation returns the PermissionResourceMutation object of the builder. +func (_u *PermissionResourceUpdate) Mutation() *PermissionResourceMutation { + return _u.mutation +} + +// ClearPermission clears the "permission" edge to the Permission entity. +func (_u *PermissionResourceUpdate) ClearPermission() *PermissionResourceUpdate { + _u.mutation.ClearPermission() + return _u +} + +// ClearResource clears the "resource" edge to the Resource entity. +func (_u *PermissionResourceUpdate) ClearResource() *PermissionResourceUpdate { + _u.mutation.ClearResource() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *PermissionResourceUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *PermissionResourceUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *PermissionResourceUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PermissionResourceUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PermissionResourceUpdate) check() error { + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PermissionResource.permission"`) + } + if _u.mutation.ResourceCleared() && len(_u.mutation.ResourceIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PermissionResource.resource"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *PermissionResourceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionResourceUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *PermissionResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(permissionresource.Table, permissionresource.Columns, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if _u.mutation.PermissionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: permissionresource.PermissionTable, + Columns: []string{permissionresource.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: permissionresource.PermissionTable, + Columns: []string{permissionresource.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ResourceCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: permissionresource.ResourceTable, + Columns: []string{permissionresource.ResourceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ResourceIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: permissionresource.ResourceTable, + Columns: []string{permissionresource.ResourceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{permissionresource.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// PermissionResourceUpdateOne is the builder for updating a single PermissionResource entity. +type PermissionResourceUpdateOne struct { + config + fields []string + hooks []Hook + mutation *PermissionResourceMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetPermissionID sets the "permission_id" field. +func (_u *PermissionResourceUpdateOne) SetPermissionID(v int64) *PermissionResourceUpdateOne { + _u.mutation.SetPermissionID(v) + return _u +} + +// SetNillablePermissionID sets the "permission_id" field if the given value is not nil. +func (_u *PermissionResourceUpdateOne) SetNillablePermissionID(v *int64) *PermissionResourceUpdateOne { + if v != nil { + _u.SetPermissionID(*v) + } + return _u +} + +// SetResourceID sets the "resource_id" field. +func (_u *PermissionResourceUpdateOne) SetResourceID(v int64) *PermissionResourceUpdateOne { + _u.mutation.SetResourceID(v) + return _u +} + +// SetNillableResourceID sets the "resource_id" field if the given value is not nil. +func (_u *PermissionResourceUpdateOne) SetNillableResourceID(v *int64) *PermissionResourceUpdateOne { + if v != nil { + _u.SetResourceID(*v) + } + return _u +} + +// SetPermission sets the "permission" edge to the Permission entity. +func (_u *PermissionResourceUpdateOne) SetPermission(v *Permission) *PermissionResourceUpdateOne { + return _u.SetPermissionID(v.ID) +} + +// SetResource sets the "resource" edge to the Resource entity. +func (_u *PermissionResourceUpdateOne) SetResource(v *Resource) *PermissionResourceUpdateOne { + return _u.SetResourceID(v.ID) +} + +// Mutation returns the PermissionResourceMutation object of the builder. +func (_u *PermissionResourceUpdateOne) Mutation() *PermissionResourceMutation { + return _u.mutation +} + +// ClearPermission clears the "permission" edge to the Permission entity. +func (_u *PermissionResourceUpdateOne) ClearPermission() *PermissionResourceUpdateOne { + _u.mutation.ClearPermission() + return _u +} + +// ClearResource clears the "resource" edge to the Resource entity. +func (_u *PermissionResourceUpdateOne) ClearResource() *PermissionResourceUpdateOne { + _u.mutation.ClearResource() + return _u +} + +// Where appends a list predicates to the PermissionResourceUpdate builder. +func (_u *PermissionResourceUpdateOne) Where(ps ...predicate.PermissionResource) *PermissionResourceUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *PermissionResourceUpdateOne) Select(field string, fields ...string) *PermissionResourceUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated PermissionResource entity. +func (_u *PermissionResourceUpdateOne) Save(ctx context.Context) (*PermissionResource, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *PermissionResourceUpdateOne) SaveX(ctx context.Context) *PermissionResource { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *PermissionResourceUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *PermissionResourceUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *PermissionResourceUpdateOne) check() error { + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PermissionResource.permission"`) + } + if _u.mutation.ResourceCleared() && len(_u.mutation.ResourceIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "PermissionResource.resource"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *PermissionResourceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionResourceUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *PermissionResource, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(permissionresource.Table, permissionresource.Columns, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PermissionResource.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, permissionresource.FieldID) + for _, f := range fields { + if !permissionresource.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != permissionresource.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if _u.mutation.PermissionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: permissionresource.PermissionTable, + Columns: []string{permissionresource.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: permissionresource.PermissionTable, + Columns: []string{permissionresource.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ResourceCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: permissionresource.ResourceTable, + Columns: []string{permissionresource.ResourceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ResourceIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: permissionresource.ResourceTable, + Columns: []string{permissionresource.ResourceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &PermissionResource{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{permissionresource.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} + +// SetPermissionResource set the PermissionResource +func (pru *PermissionResourceUpdate) SetPermissionResource(input *PermissionResource, fields ...string) *PermissionResourceUpdate { + m := pru.mutation + if len(fields) == 0 { + fields = permissionresource.OmitColumns(permissionresource.FieldID) + } + _ = m.SetFields(input, fields...) + return pru +} + +// SetPermissionResourceWithZero set the PermissionResource +func (pru *PermissionResourceUpdate) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceUpdate { + m := pru.mutation + if len(fields) == 0 { + fields = permissionresource.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return pru +} + +// SetPermissionResource set the PermissionResource +func (pruo *PermissionResourceUpdateOne) SetPermissionResource(input *PermissionResource, fields ...string) *PermissionResourceUpdateOne { + m := pruo.mutation + if len(fields) == 0 { + fields = permissionresource.OmitColumns(permissionresource.FieldID) + } + _ = m.SetFields(input, fields...) + return pruo +} + +// SetPermissionResourceWithZero set the PermissionResource +func (pruo *PermissionResourceUpdateOne) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceUpdateOne { + m := pruo.mutation + if len(fields) == 0 { + fields = permissionresource.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return pruo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (pruo *PermissionResourceUpdateOne) Omit(fields ...string) *PermissionResourceUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + pruo.fields = []string(nil) + for _, col := range permissionresource.Columns { + if _, ok := omits[col]; !ok { + pruo.fields = append(pruo.fields, col) + } + } + return pruo +} diff --git a/internal/features/system/data/ent/predicate/predicate.go b/internal/features/system/data/ent/predicate/predicate.go new file mode 100644 index 00000000..822f2f32 --- /dev/null +++ b/internal/features/system/data/ent/predicate/predicate.go @@ -0,0 +1,28 @@ +// Code generated by ent, DO NOT EDIT. + +package predicate + +import ( + "entgo.io/ent/dialect/sql" +) + +// Permission is the predicate function for permission builders. +type Permission func(*sql.Selector) + +// PermissionResource is the predicate function for permissionresource builders. +type PermissionResource func(*sql.Selector) + +// Resource is the predicate function for resource builders. +type Resource func(*sql.Selector) + +// Role is the predicate function for role builders. +type Role func(*sql.Selector) + +// RolePermission is the predicate function for rolepermission builders. +type RolePermission func(*sql.Selector) + +// User is the predicate function for user builders. +type User func(*sql.Selector) + +// UserRole is the predicate function for userrole builders. +type UserRole func(*sql.Selector) diff --git a/internal/features/system/data/ent/resource.go b/internal/features/system/data/ent/resource.go new file mode 100644 index 00000000..95b42f2d --- /dev/null +++ b/internal/features/system/data/ent/resource.go @@ -0,0 +1,355 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "encoding/json" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// Resource table +type Resource struct { + config `json:"-"` + // ID of the ent. + // ID + ID int64 `json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime time.Time `json:"update_time,omitempty"` + // Name + Name string `json:"name,omitempty"` + // Keyword + Keyword string `json:"keyword,omitempty"` + // Type + Type string `json:"type,omitempty"` + // Status + Status int8 `json:"status,omitempty"` + // Path + Path string `json:"path,omitempty"` + // Component + Component string `json:"component,omitempty"` + // Icon + Icon string `json:"icon,omitempty"` + // Sequence + Sequence int `json:"sequence,omitempty"` + // Visible + Visible bool `json:"visible,omitempty"` + // Level + Level int8 `json:"level,omitempty"` + // Tree path + TreePath string `json:"tree_path,omitempty"` + // Properties + Properties map[string]string `json:"properties,omitempty"` + // Description + Description string `json:"description,omitempty"` + // Parent ID + ParentID int64 `json:"parent_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ResourceQuery when eager-loading is set. + Edges ResourceEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ResourceEdges holds the relations/edges for other nodes in the graph. +type ResourceEdges struct { + // Parent holds the value of the parent edge. + Parent *Resource `json:"parent,omitempty"` + // Children holds the value of the children edge. + Children []*Resource `json:"children,omitempty"` + // Permissions holds the value of the permissions edge. + Permissions []*Permission `json:"permissions,omitempty"` + // PermissionResources holds the value of the permission_resources edge. + PermissionResources []*PermissionResource `json:"permission_resources,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [4]bool +} + +// ParentOrErr returns the Parent value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ResourceEdges) ParentOrErr() (*Resource, error) { + if e.Parent != nil { + return e.Parent, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: resource.Label} + } + return nil, &NotLoadedError{edge: "parent"} +} + +// ChildrenOrErr returns the Children value or an error if the edge +// was not loaded in eager-loading. +func (e ResourceEdges) ChildrenOrErr() ([]*Resource, error) { + if e.loadedTypes[1] { + return e.Children, nil + } + return nil, &NotLoadedError{edge: "children"} +} + +// PermissionsOrErr returns the Permissions value or an error if the edge +// was not loaded in eager-loading. +func (e ResourceEdges) PermissionsOrErr() ([]*Permission, error) { + if e.loadedTypes[2] { + return e.Permissions, nil + } + return nil, &NotLoadedError{edge: "permissions"} +} + +// PermissionResourcesOrErr returns the PermissionResources value or an error if the edge +// was not loaded in eager-loading. +func (e ResourceEdges) PermissionResourcesOrErr() ([]*PermissionResource, error) { + if e.loadedTypes[3] { + return e.PermissionResources, nil + } + return nil, &NotLoadedError{edge: "permission_resources"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Resource) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case resource.FieldProperties: + values[i] = new([]byte) + case resource.FieldVisible: + values[i] = new(sql.NullBool) + case resource.FieldID, resource.FieldStatus, resource.FieldSequence, resource.FieldLevel, resource.FieldParentID: + values[i] = new(sql.NullInt64) + case resource.FieldName, resource.FieldKeyword, resource.FieldType, resource.FieldPath, resource.FieldComponent, resource.FieldIcon, resource.FieldTreePath, resource.FieldDescription: + values[i] = new(sql.NullString) + case resource.FieldCreateTime, resource.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Resource fields. +func (_m *Resource) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case resource.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case resource.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = value.Time + } + case resource.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = value.Time + } + case resource.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case resource.FieldKeyword: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field keyword", values[i]) + } else if value.Valid { + _m.Keyword = value.String + } + case resource.FieldType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + _m.Type = value.String + } + case resource.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = int8(value.Int64) + } + case resource.FieldPath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field path", values[i]) + } else if value.Valid { + _m.Path = value.String + } + case resource.FieldComponent: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field component", values[i]) + } else if value.Valid { + _m.Component = value.String + } + case resource.FieldIcon: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field icon", values[i]) + } else if value.Valid { + _m.Icon = value.String + } + case resource.FieldSequence: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sequence", values[i]) + } else if value.Valid { + _m.Sequence = int(value.Int64) + } + case resource.FieldVisible: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field visible", values[i]) + } else if value.Valid { + _m.Visible = value.Bool + } + case resource.FieldLevel: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field level", values[i]) + } else if value.Valid { + _m.Level = int8(value.Int64) + } + case resource.FieldTreePath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field tree_path", values[i]) + } else if value.Valid { + _m.TreePath = value.String + } + case resource.FieldProperties: + if value, ok := values[i].(*[]byte); !ok { + return fmt.Errorf("unexpected type %T for field properties", values[i]) + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &_m.Properties); err != nil { + return fmt.Errorf("unmarshal field properties: %w", err) + } + } + case resource.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case resource.FieldParentID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field parent_id", values[i]) + } else if value.Valid { + _m.ParentID = value.Int64 + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Resource. +// This includes values selected through modifiers, order, etc. +func (_m *Resource) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryParent queries the "parent" edge of the Resource entity. +func (_m *Resource) QueryParent() *ResourceQuery { + return NewResourceClient(_m.config).QueryParent(_m) +} + +// QueryChildren queries the "children" edge of the Resource entity. +func (_m *Resource) QueryChildren() *ResourceQuery { + return NewResourceClient(_m.config).QueryChildren(_m) +} + +// QueryPermissions queries the "permissions" edge of the Resource entity. +func (_m *Resource) QueryPermissions() *PermissionQuery { + return NewResourceClient(_m.config).QueryPermissions(_m) +} + +// QueryPermissionResources queries the "permission_resources" edge of the Resource entity. +func (_m *Resource) QueryPermissionResources() *PermissionResourceQuery { + return NewResourceClient(_m.config).QueryPermissionResources(_m) +} + +// Update returns a builder for updating this Resource. +// Note that you need to call Resource.Unwrap() before calling this method if this Resource +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *Resource) Update() *ResourceUpdateOne { + return NewResourceClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the Resource entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *Resource) Unwrap() *Resource { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: Resource is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *Resource) String() string { + var builder strings.Builder + builder.WriteString("Resource(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("create_time=") + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("keyword=") + builder.WriteString(_m.Keyword) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(_m.Type) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("path=") + builder.WriteString(_m.Path) + builder.WriteString(", ") + builder.WriteString("component=") + builder.WriteString(_m.Component) + builder.WriteString(", ") + builder.WriteString("icon=") + builder.WriteString(_m.Icon) + builder.WriteString(", ") + builder.WriteString("sequence=") + builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) + builder.WriteString(", ") + builder.WriteString("visible=") + builder.WriteString(fmt.Sprintf("%v", _m.Visible)) + builder.WriteString(", ") + builder.WriteString("level=") + builder.WriteString(fmt.Sprintf("%v", _m.Level)) + builder.WriteString(", ") + builder.WriteString("tree_path=") + builder.WriteString(_m.TreePath) + builder.WriteString(", ") + builder.WriteString("properties=") + builder.WriteString(fmt.Sprintf("%v", _m.Properties)) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteString(", ") + builder.WriteString("parent_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ParentID)) + builder.WriteByte(')') + return builder.String() +} + +// Resources is a parsable slice of Resource. +type Resources []*Resource diff --git a/internal/features/system/data/ent/resource/resource.go b/internal/features/system/data/ent/resource/resource.go new file mode 100644 index 00000000..eee63d9e --- /dev/null +++ b/internal/features/system/data/ent/resource/resource.go @@ -0,0 +1,385 @@ +// Code generated by ent, DO NOT EDIT. + +package resource + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the resource type in the database. + Label = "resource" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldKeyword holds the string denoting the keyword field in the database. + FieldKeyword = "keyword" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldPath holds the string denoting the path field in the database. + FieldPath = "path" + // FieldComponent holds the string denoting the component field in the database. + FieldComponent = "component" + // FieldIcon holds the string denoting the icon field in the database. + FieldIcon = "icon" + // FieldSequence holds the string denoting the sequence field in the database. + FieldSequence = "sequence" + // FieldVisible holds the string denoting the visible field in the database. + FieldVisible = "visible" + // FieldLevel holds the string denoting the level field in the database. + FieldLevel = "level" + // FieldTreePath holds the string denoting the tree_path field in the database. + FieldTreePath = "tree_path" + // FieldProperties holds the string denoting the properties field in the database. + FieldProperties = "properties" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldParentID holds the string denoting the parent_id field in the database. + FieldParentID = "parent_id" + // EdgeParent holds the string denoting the parent edge name in mutations. + EdgeParent = "parent" + // EdgeChildren holds the string denoting the children edge name in mutations. + EdgeChildren = "children" + // EdgePermissions holds the string denoting the permissions edge name in mutations. + EdgePermissions = "permissions" + // EdgePermissionResources holds the string denoting the permission_resources edge name in mutations. + EdgePermissionResources = "permission_resources" + // Table holds the table name of the resource in the database. + Table = "sys_resources" + // ParentTable is the table that holds the parent relation/edge. + ParentTable = "sys_resources" + // ParentColumn is the table column denoting the parent relation/edge. + ParentColumn = "parent_id" + // ChildrenTable is the table that holds the children relation/edge. + ChildrenTable = "sys_resources" + // ChildrenColumn is the table column denoting the children relation/edge. + ChildrenColumn = "parent_id" + // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. + PermissionsTable = "sys_permission_resources" + // PermissionsInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionsInverseTable = "sys_permissions" + // PermissionResourcesTable is the table that holds the permission_resources relation/edge. + PermissionResourcesTable = "sys_permission_resources" + // PermissionResourcesInverseTable is the table name for the PermissionResource entity. + // It exists in this package in order to avoid circular dependency with the "permissionresource" package. + PermissionResourcesInverseTable = "sys_permission_resources" + // PermissionResourcesColumn is the table column denoting the permission_resources relation/edge. + PermissionResourcesColumn = "resource_id" +) + +// Columns holds all SQL columns for resource fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldName, + FieldKeyword, + FieldType, + FieldStatus, + FieldPath, + FieldComponent, + FieldIcon, + FieldSequence, + FieldVisible, + FieldLevel, + FieldTreePath, + FieldProperties, + FieldDescription, + FieldParentID, +} + +var ( + // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the + // primary key for the permissions relation (M2M). + PermissionsPrimaryKey = []string{"permission_id", "resource_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // DefaultName holds the default value on creation for the "name" field. + DefaultName string + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + KeywordValidator func(string) error + // DefaultType holds the default value on creation for the "type" field. + DefaultType string + // TypeValidator is a validator for the "type" field. It is called by the builders before save. + TypeValidator func(string) error + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int8 + // DefaultPath holds the default value on creation for the "path" field. + DefaultPath string + // PathValidator is a validator for the "path" field. It is called by the builders before save. + PathValidator func(string) error + // DefaultComponent holds the default value on creation for the "component" field. + DefaultComponent string + // ComponentValidator is a validator for the "component" field. It is called by the builders before save. + ComponentValidator func(string) error + // DefaultIcon holds the default value on creation for the "icon" field. + DefaultIcon string + // IconValidator is a validator for the "icon" field. It is called by the builders before save. + IconValidator func(string) error + // DefaultSequence holds the default value on creation for the "sequence" field. + DefaultSequence int + // DefaultVisible holds the default value on creation for the "visible" field. + DefaultVisible bool + // DefaultLevel holds the default value on creation for the "level" field. + DefaultLevel int8 + // DefaultTreePath holds the default value on creation for the "tree_path" field. + DefaultTreePath string + // TreePathValidator is a validator for the "tree_path" field. It is called by the builders before save. + TreePathValidator func(string) error + // DefaultDescription holds the default value on creation for the "description" field. + DefaultDescription string + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error +) + +// OrderOption defines the ordering options for the Resource queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByKeyword orders the results by the keyword field. +func ByKeyword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKeyword, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByPath orders the results by the path field. +func ByPath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPath, opts...).ToFunc() +} + +// ByComponent orders the results by the component field. +func ByComponent(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldComponent, opts...).ToFunc() +} + +// ByIcon orders the results by the icon field. +func ByIcon(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIcon, opts...).ToFunc() +} + +// BySequence orders the results by the sequence field. +func BySequence(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSequence, opts...).ToFunc() +} + +// ByVisible orders the results by the visible field. +func ByVisible(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVisible, opts...).ToFunc() +} + +// ByLevel orders the results by the level field. +func ByLevel(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLevel, opts...).ToFunc() +} + +// ByTreePath orders the results by the tree_path field. +func ByTreePath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTreePath, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByParentID orders the results by the parent_id field. +func ByParentID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldParentID, opts...).ToFunc() +} + +// ByParentField orders the results by parent field. +func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) + } +} + +// ByChildrenCount orders the results by children count. +func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) + } +} + +// ByChildren orders the results by children terms. +func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPermissionsCount orders the results by permissions count. +func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) + } +} + +// ByPermissions orders the results by permissions terms. +func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPermissionResourcesCount orders the results by permission_resources count. +func ByPermissionResourcesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPermissionResourcesStep(), opts...) + } +} + +// ByPermissionResources orders the results by permission_resources terms. +func ByPermissionResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newParentStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) +} +func newChildrenStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) +} +func newPermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), + ) +} +func newPermissionResourcesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionResourcesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/features/system/data/ent/resource/where.go b/internal/features/system/data/ent/resource/where.go new file mode 100644 index 00000000..9668d8ef --- /dev/null +++ b/internal/features/system/data/ent/resource/where.go @@ -0,0 +1,1008 @@ +// Code generated by ent, DO NOT EDIT. + +package resource + +import ( + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldName, v)) +} + +// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. +func Keyword(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) +} + +// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. +func Type(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldType, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int8) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldStatus, v)) +} + +// Path applies equality check predicate on the "path" field. It's identical to PathEQ. +func Path(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldPath, v)) +} + +// Component applies equality check predicate on the "component" field. It's identical to ComponentEQ. +func Component(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldComponent, v)) +} + +// Icon applies equality check predicate on the "icon" field. It's identical to IconEQ. +func Icon(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldIcon, v)) +} + +// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. +func Sequence(v int) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldSequence, v)) +} + +// Visible applies equality check predicate on the "visible" field. It's identical to VisibleEQ. +func Visible(v bool) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldVisible, v)) +} + +// Level applies equality check predicate on the "level" field. It's identical to LevelEQ. +func Level(v int8) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldLevel, v)) +} + +// TreePath applies equality check predicate on the "tree_path" field. It's identical to TreePathEQ. +func TreePath(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldDescription, v)) +} + +// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ. +func ParentID(v int64) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldParentID, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldUpdateTime, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldName, v)) +} + +// KeywordEQ applies the EQ predicate on the "keyword" field. +func KeywordEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) +} + +// KeywordNEQ applies the NEQ predicate on the "keyword" field. +func KeywordNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldKeyword, v)) +} + +// KeywordIn applies the In predicate on the "keyword" field. +func KeywordIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldKeyword, vs...)) +} + +// KeywordNotIn applies the NotIn predicate on the "keyword" field. +func KeywordNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldKeyword, vs...)) +} + +// KeywordGT applies the GT predicate on the "keyword" field. +func KeywordGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldKeyword, v)) +} + +// KeywordGTE applies the GTE predicate on the "keyword" field. +func KeywordGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldKeyword, v)) +} + +// KeywordLT applies the LT predicate on the "keyword" field. +func KeywordLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldKeyword, v)) +} + +// KeywordLTE applies the LTE predicate on the "keyword" field. +func KeywordLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldKeyword, v)) +} + +// KeywordContains applies the Contains predicate on the "keyword" field. +func KeywordContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldKeyword, v)) +} + +// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. +func KeywordHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldKeyword, v)) +} + +// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. +func KeywordHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldKeyword, v)) +} + +// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. +func KeywordEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldKeyword, v)) +} + +// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. +func KeywordContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldKeyword, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldType, vs...)) +} + +// TypeGT applies the GT predicate on the "type" field. +func TypeGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldType, v)) +} + +// TypeGTE applies the GTE predicate on the "type" field. +func TypeGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldType, v)) +} + +// TypeLT applies the LT predicate on the "type" field. +func TypeLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldType, v)) +} + +// TypeLTE applies the LTE predicate on the "type" field. +func TypeLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldType, v)) +} + +// TypeContains applies the Contains predicate on the "type" field. +func TypeContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldType, v)) +} + +// TypeHasPrefix applies the HasPrefix predicate on the "type" field. +func TypeHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldType, v)) +} + +// TypeHasSuffix applies the HasSuffix predicate on the "type" field. +func TypeHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldType, v)) +} + +// TypeEqualFold applies the EqualFold predicate on the "type" field. +func TypeEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldType, v)) +} + +// TypeContainsFold applies the ContainsFold predicate on the "type" field. +func TypeContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldType, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int8) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int8) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int8) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int8) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int8) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int8) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int8) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int8) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldStatus, v)) +} + +// PathEQ applies the EQ predicate on the "path" field. +func PathEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldPath, v)) +} + +// PathNEQ applies the NEQ predicate on the "path" field. +func PathNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldPath, v)) +} + +// PathIn applies the In predicate on the "path" field. +func PathIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldPath, vs...)) +} + +// PathNotIn applies the NotIn predicate on the "path" field. +func PathNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldPath, vs...)) +} + +// PathGT applies the GT predicate on the "path" field. +func PathGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldPath, v)) +} + +// PathGTE applies the GTE predicate on the "path" field. +func PathGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldPath, v)) +} + +// PathLT applies the LT predicate on the "path" field. +func PathLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldPath, v)) +} + +// PathLTE applies the LTE predicate on the "path" field. +func PathLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldPath, v)) +} + +// PathContains applies the Contains predicate on the "path" field. +func PathContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldPath, v)) +} + +// PathHasPrefix applies the HasPrefix predicate on the "path" field. +func PathHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldPath, v)) +} + +// PathHasSuffix applies the HasSuffix predicate on the "path" field. +func PathHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldPath, v)) +} + +// PathEqualFold applies the EqualFold predicate on the "path" field. +func PathEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldPath, v)) +} + +// PathContainsFold applies the ContainsFold predicate on the "path" field. +func PathContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldPath, v)) +} + +// ComponentEQ applies the EQ predicate on the "component" field. +func ComponentEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldComponent, v)) +} + +// ComponentNEQ applies the NEQ predicate on the "component" field. +func ComponentNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldComponent, v)) +} + +// ComponentIn applies the In predicate on the "component" field. +func ComponentIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldComponent, vs...)) +} + +// ComponentNotIn applies the NotIn predicate on the "component" field. +func ComponentNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldComponent, vs...)) +} + +// ComponentGT applies the GT predicate on the "component" field. +func ComponentGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldComponent, v)) +} + +// ComponentGTE applies the GTE predicate on the "component" field. +func ComponentGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldComponent, v)) +} + +// ComponentLT applies the LT predicate on the "component" field. +func ComponentLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldComponent, v)) +} + +// ComponentLTE applies the LTE predicate on the "component" field. +func ComponentLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldComponent, v)) +} + +// ComponentContains applies the Contains predicate on the "component" field. +func ComponentContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldComponent, v)) +} + +// ComponentHasPrefix applies the HasPrefix predicate on the "component" field. +func ComponentHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldComponent, v)) +} + +// ComponentHasSuffix applies the HasSuffix predicate on the "component" field. +func ComponentHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldComponent, v)) +} + +// ComponentEqualFold applies the EqualFold predicate on the "component" field. +func ComponentEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldComponent, v)) +} + +// ComponentContainsFold applies the ContainsFold predicate on the "component" field. +func ComponentContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldComponent, v)) +} + +// IconEQ applies the EQ predicate on the "icon" field. +func IconEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldIcon, v)) +} + +// IconNEQ applies the NEQ predicate on the "icon" field. +func IconNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldIcon, v)) +} + +// IconIn applies the In predicate on the "icon" field. +func IconIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldIcon, vs...)) +} + +// IconNotIn applies the NotIn predicate on the "icon" field. +func IconNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldIcon, vs...)) +} + +// IconGT applies the GT predicate on the "icon" field. +func IconGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldIcon, v)) +} + +// IconGTE applies the GTE predicate on the "icon" field. +func IconGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldIcon, v)) +} + +// IconLT applies the LT predicate on the "icon" field. +func IconLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldIcon, v)) +} + +// IconLTE applies the LTE predicate on the "icon" field. +func IconLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldIcon, v)) +} + +// IconContains applies the Contains predicate on the "icon" field. +func IconContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldIcon, v)) +} + +// IconHasPrefix applies the HasPrefix predicate on the "icon" field. +func IconHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldIcon, v)) +} + +// IconHasSuffix applies the HasSuffix predicate on the "icon" field. +func IconHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldIcon, v)) +} + +// IconEqualFold applies the EqualFold predicate on the "icon" field. +func IconEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldIcon, v)) +} + +// IconContainsFold applies the ContainsFold predicate on the "icon" field. +func IconContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldIcon, v)) +} + +// SequenceEQ applies the EQ predicate on the "sequence" field. +func SequenceEQ(v int) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldSequence, v)) +} + +// SequenceNEQ applies the NEQ predicate on the "sequence" field. +func SequenceNEQ(v int) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldSequence, v)) +} + +// SequenceIn applies the In predicate on the "sequence" field. +func SequenceIn(vs ...int) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldSequence, vs...)) +} + +// SequenceNotIn applies the NotIn predicate on the "sequence" field. +func SequenceNotIn(vs ...int) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldSequence, vs...)) +} + +// SequenceGT applies the GT predicate on the "sequence" field. +func SequenceGT(v int) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldSequence, v)) +} + +// SequenceGTE applies the GTE predicate on the "sequence" field. +func SequenceGTE(v int) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldSequence, v)) +} + +// SequenceLT applies the LT predicate on the "sequence" field. +func SequenceLT(v int) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldSequence, v)) +} + +// SequenceLTE applies the LTE predicate on the "sequence" field. +func SequenceLTE(v int) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldSequence, v)) +} + +// VisibleEQ applies the EQ predicate on the "visible" field. +func VisibleEQ(v bool) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldVisible, v)) +} + +// VisibleNEQ applies the NEQ predicate on the "visible" field. +func VisibleNEQ(v bool) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldVisible, v)) +} + +// LevelEQ applies the EQ predicate on the "level" field. +func LevelEQ(v int8) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldLevel, v)) +} + +// LevelNEQ applies the NEQ predicate on the "level" field. +func LevelNEQ(v int8) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldLevel, v)) +} + +// LevelIn applies the In predicate on the "level" field. +func LevelIn(vs ...int8) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldLevel, vs...)) +} + +// LevelNotIn applies the NotIn predicate on the "level" field. +func LevelNotIn(vs ...int8) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldLevel, vs...)) +} + +// LevelGT applies the GT predicate on the "level" field. +func LevelGT(v int8) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldLevel, v)) +} + +// LevelGTE applies the GTE predicate on the "level" field. +func LevelGTE(v int8) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldLevel, v)) +} + +// LevelLT applies the LT predicate on the "level" field. +func LevelLT(v int8) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldLevel, v)) +} + +// LevelLTE applies the LTE predicate on the "level" field. +func LevelLTE(v int8) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldLevel, v)) +} + +// TreePathEQ applies the EQ predicate on the "tree_path" field. +func TreePathEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) +} + +// TreePathNEQ applies the NEQ predicate on the "tree_path" field. +func TreePathNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldTreePath, v)) +} + +// TreePathIn applies the In predicate on the "tree_path" field. +func TreePathIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldTreePath, vs...)) +} + +// TreePathNotIn applies the NotIn predicate on the "tree_path" field. +func TreePathNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldTreePath, vs...)) +} + +// TreePathGT applies the GT predicate on the "tree_path" field. +func TreePathGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldTreePath, v)) +} + +// TreePathGTE applies the GTE predicate on the "tree_path" field. +func TreePathGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldTreePath, v)) +} + +// TreePathLT applies the LT predicate on the "tree_path" field. +func TreePathLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldTreePath, v)) +} + +// TreePathLTE applies the LTE predicate on the "tree_path" field. +func TreePathLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldTreePath, v)) +} + +// TreePathContains applies the Contains predicate on the "tree_path" field. +func TreePathContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldTreePath, v)) +} + +// TreePathHasPrefix applies the HasPrefix predicate on the "tree_path" field. +func TreePathHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldTreePath, v)) +} + +// TreePathHasSuffix applies the HasSuffix predicate on the "tree_path" field. +func TreePathHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldTreePath, v)) +} + +// TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. +func TreePathEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldTreePath, v)) +} + +// TreePathContainsFold applies the ContainsFold predicate on the "tree_path" field. +func TreePathContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldTreePath, v)) +} + +// PropertiesIsNil applies the IsNil predicate on the "properties" field. +func PropertiesIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldProperties)) +} + +// PropertiesNotNil applies the NotNil predicate on the "properties" field. +func PropertiesNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldProperties)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldDescription, v)) +} + +// ParentIDEQ applies the EQ predicate on the "parent_id" field. +func ParentIDEQ(v int64) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldParentID, v)) +} + +// ParentIDNEQ applies the NEQ predicate on the "parent_id" field. +func ParentIDNEQ(v int64) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldParentID, v)) +} + +// ParentIDIn applies the In predicate on the "parent_id" field. +func ParentIDIn(vs ...int64) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldParentID, vs...)) +} + +// ParentIDNotIn applies the NotIn predicate on the "parent_id" field. +func ParentIDNotIn(vs ...int64) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldParentID, vs...)) +} + +// ParentIDIsNil applies the IsNil predicate on the "parent_id" field. +func ParentIDIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldParentID)) +} + +// ParentIDNotNil applies the NotNil predicate on the "parent_id" field. +func ParentIDNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldParentID)) +} + +// HasParent applies the HasEdge predicate on the "parent" edge. +func HasParent() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). +func HasParentWith(preds ...predicate.Resource) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newParentStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasChildren applies the HasEdge predicate on the "children" edge. +func HasChildren() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates). +func HasChildrenWith(preds ...predicate.Resource) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newChildrenStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermissions applies the HasEdge predicate on the "permissions" edge. +func HasPermissions() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). +func HasPermissionsWith(preds ...predicate.Permission) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newPermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermissionResources applies the HasEdge predicate on the "permission_resources" edge. +func HasPermissionResources() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionResourcesWith applies the HasEdge predicate on the "permission_resources" edge with a given conditions (other predicates). +func HasPermissionResourcesWith(preds ...predicate.PermissionResource) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newPermissionResourcesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Resource) predicate.Resource { + return predicate.Resource(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Resource) predicate.Resource { + return predicate.Resource(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Resource) predicate.Resource { + return predicate.Resource(sql.NotPredicates(p)) +} diff --git a/internal/features/system/data/ent/resource_create.go b/internal/features/system/data/ent/resource_create.go new file mode 100644 index 00000000..b606d5df --- /dev/null +++ b/internal/features/system/data/ent/resource_create.go @@ -0,0 +1,728 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ResourceCreate is the builder for creating a Resource entity. +type ResourceCreate struct { + config + mutation *ResourceMutation + hooks []Hook +} + +// SetCreateTime sets the "create_time" field. +func (_c *ResourceCreate) SetCreateTime(v time.Time) *ResourceCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableCreateTime(v *time.Time) *ResourceCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *ResourceCreate) SetUpdateTime(v time.Time) *ResourceCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableUpdateTime(v *time.Time) *ResourceCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetName sets the "name" field. +func (_c *ResourceCreate) SetName(v string) *ResourceCreate { + _c.mutation.SetName(v) + return _c +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableName(v *string) *ResourceCreate { + if v != nil { + _c.SetName(*v) + } + return _c +} + +// SetKeyword sets the "keyword" field. +func (_c *ResourceCreate) SetKeyword(v string) *ResourceCreate { + _c.mutation.SetKeyword(v) + return _c +} + +// SetType sets the "type" field. +func (_c *ResourceCreate) SetType(v string) *ResourceCreate { + _c.mutation.SetType(v) + return _c +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableType(v *string) *ResourceCreate { + if v != nil { + _c.SetType(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *ResourceCreate) SetStatus(v int8) *ResourceCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableStatus(v *int8) *ResourceCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetPath sets the "path" field. +func (_c *ResourceCreate) SetPath(v string) *ResourceCreate { + _c.mutation.SetPath(v) + return _c +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (_c *ResourceCreate) SetNillablePath(v *string) *ResourceCreate { + if v != nil { + _c.SetPath(*v) + } + return _c +} + +// SetComponent sets the "component" field. +func (_c *ResourceCreate) SetComponent(v string) *ResourceCreate { + _c.mutation.SetComponent(v) + return _c +} + +// SetNillableComponent sets the "component" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableComponent(v *string) *ResourceCreate { + if v != nil { + _c.SetComponent(*v) + } + return _c +} + +// SetIcon sets the "icon" field. +func (_c *ResourceCreate) SetIcon(v string) *ResourceCreate { + _c.mutation.SetIcon(v) + return _c +} + +// SetNillableIcon sets the "icon" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableIcon(v *string) *ResourceCreate { + if v != nil { + _c.SetIcon(*v) + } + return _c +} + +// SetSequence sets the "sequence" field. +func (_c *ResourceCreate) SetSequence(v int) *ResourceCreate { + _c.mutation.SetSequence(v) + return _c +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableSequence(v *int) *ResourceCreate { + if v != nil { + _c.SetSequence(*v) + } + return _c +} + +// SetVisible sets the "visible" field. +func (_c *ResourceCreate) SetVisible(v bool) *ResourceCreate { + _c.mutation.SetVisible(v) + return _c +} + +// SetNillableVisible sets the "visible" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableVisible(v *bool) *ResourceCreate { + if v != nil { + _c.SetVisible(*v) + } + return _c +} + +// SetLevel sets the "level" field. +func (_c *ResourceCreate) SetLevel(v int8) *ResourceCreate { + _c.mutation.SetLevel(v) + return _c +} + +// SetNillableLevel sets the "level" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableLevel(v *int8) *ResourceCreate { + if v != nil { + _c.SetLevel(*v) + } + return _c +} + +// SetTreePath sets the "tree_path" field. +func (_c *ResourceCreate) SetTreePath(v string) *ResourceCreate { + _c.mutation.SetTreePath(v) + return _c +} + +// SetNillableTreePath sets the "tree_path" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableTreePath(v *string) *ResourceCreate { + if v != nil { + _c.SetTreePath(*v) + } + return _c +} + +// SetProperties sets the "properties" field. +func (_c *ResourceCreate) SetProperties(v map[string]string) *ResourceCreate { + _c.mutation.SetProperties(v) + return _c +} + +// SetDescription sets the "description" field. +func (_c *ResourceCreate) SetDescription(v string) *ResourceCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableDescription(v *string) *ResourceCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetParentID sets the "parent_id" field. +func (_c *ResourceCreate) SetParentID(v int64) *ResourceCreate { + _c.mutation.SetParentID(v) + return _c +} + +// SetNillableParentID sets the "parent_id" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableParentID(v *int64) *ResourceCreate { + if v != nil { + _c.SetParentID(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *ResourceCreate) SetID(v int64) *ResourceCreate { + _c.mutation.SetID(v) + return _c +} + +// SetParent sets the "parent" edge to the Resource entity. +func (_c *ResourceCreate) SetParent(v *Resource) *ResourceCreate { + return _c.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Resource entity by IDs. +func (_c *ResourceCreate) AddChildIDs(ids ...int64) *ResourceCreate { + _c.mutation.AddChildIDs(ids...) + return _c +} + +// AddChildren adds the "children" edges to the Resource entity. +func (_c *ResourceCreate) AddChildren(v ...*Resource) *ResourceCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddChildIDs(ids...) +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. +func (_c *ResourceCreate) AddPermissionIDs(ids ...int64) *ResourceCreate { + _c.mutation.AddPermissionIDs(ids...) + return _c +} + +// AddPermissions adds the "permissions" edges to the Permission entity. +func (_c *ResourceCreate) AddPermissions(v ...*Permission) *ResourceCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddPermissionIDs(ids...) +} + +// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. +func (_c *ResourceCreate) AddPermissionResourceIDs(ids ...int) *ResourceCreate { + _c.mutation.AddPermissionResourceIDs(ids...) + return _c +} + +// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. +func (_c *ResourceCreate) AddPermissionResources(v ...*PermissionResource) *ResourceCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddPermissionResourceIDs(ids...) +} + +// Mutation returns the ResourceMutation object of the builder. +func (_c *ResourceCreate) Mutation() *ResourceMutation { + return _c.mutation +} + +// Save creates the Resource in the database. +func (_c *ResourceCreate) Save(ctx context.Context) (*Resource, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *ResourceCreate) SaveX(ctx context.Context) *Resource { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ResourceCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ResourceCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *ResourceCreate) defaults() { + if _, ok := _c.mutation.CreateTime(); !ok { + v := resource.DefaultCreateTime() + _c.mutation.SetCreateTime(v) + } + if _, ok := _c.mutation.UpdateTime(); !ok { + v := resource.DefaultUpdateTime() + _c.mutation.SetUpdateTime(v) + } + if _, ok := _c.mutation.Name(); !ok { + v := resource.DefaultName + _c.mutation.SetName(v) + } + if _, ok := _c.mutation.GetType(); !ok { + v := resource.DefaultType + _c.mutation.SetType(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := resource.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.Path(); !ok { + v := resource.DefaultPath + _c.mutation.SetPath(v) + } + if _, ok := _c.mutation.Component(); !ok { + v := resource.DefaultComponent + _c.mutation.SetComponent(v) + } + if _, ok := _c.mutation.Icon(); !ok { + v := resource.DefaultIcon + _c.mutation.SetIcon(v) + } + if _, ok := _c.mutation.Sequence(); !ok { + v := resource.DefaultSequence + _c.mutation.SetSequence(v) + } + if _, ok := _c.mutation.Visible(); !ok { + v := resource.DefaultVisible + _c.mutation.SetVisible(v) + } + if _, ok := _c.mutation.Level(); !ok { + v := resource.DefaultLevel + _c.mutation.SetLevel(v) + } + if _, ok := _c.mutation.TreePath(); !ok { + v := resource.DefaultTreePath + _c.mutation.SetTreePath(v) + } + if _, ok := _c.mutation.Description(); !ok { + v := resource.DefaultDescription + _c.mutation.SetDescription(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *ResourceCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Resource.create_time"`)} + } + if _, ok := _c.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Resource.update_time"`)} + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Resource.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := resource.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} + } + } + if _, ok := _c.mutation.Keyword(); !ok { + return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Resource.keyword"`)} + } + if v, ok := _c.mutation.Keyword(); ok { + if err := resource.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} + } + } + if _, ok := _c.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Resource.type"`)} + } + if v, ok := _c.mutation.GetType(); ok { + if err := resource.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} + } + } + if _, ok := _c.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Resource.status"`)} + } + if _, ok := _c.mutation.Path(); !ok { + return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "Resource.path"`)} + } + if v, ok := _c.mutation.Path(); ok { + if err := resource.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} + } + } + if _, ok := _c.mutation.Component(); !ok { + return &ValidationError{Name: "component", err: errors.New(`ent: missing required field "Resource.component"`)} + } + if v, ok := _c.mutation.Component(); ok { + if err := resource.ComponentValidator(v); err != nil { + return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} + } + } + if _, ok := _c.mutation.Icon(); !ok { + return &ValidationError{Name: "icon", err: errors.New(`ent: missing required field "Resource.icon"`)} + } + if v, ok := _c.mutation.Icon(); ok { + if err := resource.IconValidator(v); err != nil { + return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} + } + } + if _, ok := _c.mutation.Sequence(); !ok { + return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "Resource.sequence"`)} + } + if _, ok := _c.mutation.Visible(); !ok { + return &ValidationError{Name: "visible", err: errors.New(`ent: missing required field "Resource.visible"`)} + } + if _, ok := _c.mutation.Level(); !ok { + return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "Resource.level"`)} + } + if _, ok := _c.mutation.TreePath(); !ok { + return &ValidationError{Name: "tree_path", err: errors.New(`ent: missing required field "Resource.tree_path"`)} + } + if v, ok := _c.mutation.TreePath(); ok { + if err := resource.TreePathValidator(v); err != nil { + return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} + } + } + if _, ok := _c.mutation.Description(); !ok { + return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Resource.description"`)} + } + if v, ok := _c.mutation.Description(); ok { + if err := resource.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} + } + } + return nil +} + +func (_c *ResourceCreate) sqlSave(ctx context.Context) (*Resource, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { + var ( + _node = &Resource{config: _c.config} + _spec = sqlgraph.NewCreateSpec(resource.Table, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(resource.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(resource.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Keyword(); ok { + _spec.SetField(resource.FieldKeyword, field.TypeString, value) + _node.Keyword = value + } + if value, ok := _c.mutation.GetType(); ok { + _spec.SetField(resource.FieldType, field.TypeString, value) + _node.Type = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(resource.FieldStatus, field.TypeInt8, value) + _node.Status = value + } + if value, ok := _c.mutation.Path(); ok { + _spec.SetField(resource.FieldPath, field.TypeString, value) + _node.Path = value + } + if value, ok := _c.mutation.Component(); ok { + _spec.SetField(resource.FieldComponent, field.TypeString, value) + _node.Component = value + } + if value, ok := _c.mutation.Icon(); ok { + _spec.SetField(resource.FieldIcon, field.TypeString, value) + _node.Icon = value + } + if value, ok := _c.mutation.Sequence(); ok { + _spec.SetField(resource.FieldSequence, field.TypeInt, value) + _node.Sequence = value + } + if value, ok := _c.mutation.Visible(); ok { + _spec.SetField(resource.FieldVisible, field.TypeBool, value) + _node.Visible = value + } + if value, ok := _c.mutation.Level(); ok { + _spec.SetField(resource.FieldLevel, field.TypeInt8, value) + _node.Level = value + } + if value, ok := _c.mutation.TreePath(); ok { + _spec.SetField(resource.FieldTreePath, field.TypeString, value) + _node.TreePath = value + } + if value, ok := _c.mutation.Properties(); ok { + _spec.SetField(resource.FieldProperties, field.TypeJSON, value) + _node.Properties = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(resource.FieldDescription, field.TypeString, value) + _node.Description = value + } + if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: resource.ParentTable, + Columns: []string{resource.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ParentID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: resource.PermissionsTable, + Columns: resource.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.PermissionResourcesTable, + Columns: []string{resource.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SetResource set the Resource +func (_c *ResourceCreate) SetResource(input *Resource, fields ...string) *ResourceCreate { + m := _c.mutation + if len(fields) == 0 { + fields = resource.Columns + } + _ = m.SetFields(input, fields...) + return _c +} + +// SetResourceWithZero set the Resource +func (_c *ResourceCreate) SetResourceWithZero(input *Resource, fields ...string) *ResourceCreate { + m := _c.mutation + if len(fields) == 0 { + fields = resource.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return _c +} + +// ResourceCreateBulk is the builder for creating many Resource entities in bulk. +type ResourceCreateBulk struct { + config + err error + builders []*ResourceCreate +} + +// Save creates the Resource entities in the database. +func (_c *ResourceCreateBulk) Save(ctx context.Context) ([]*Resource, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Resource, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ResourceMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *ResourceCreateBulk) SaveX(ctx context.Context) []*Resource { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ResourceCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ResourceCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/resource_delete.go b/internal/features/system/data/ent/resource_delete.go new file mode 100644 index 00000000..bd09d5eb --- /dev/null +++ b/internal/features/system/data/ent/resource_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/resource" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ResourceDelete is the builder for deleting a Resource entity. +type ResourceDelete struct { + config + hooks []Hook + mutation *ResourceMutation +} + +// Where appends a list predicates to the ResourceDelete builder. +func (_d *ResourceDelete) Where(ps ...predicate.Resource) *ResourceDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *ResourceDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ResourceDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *ResourceDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(resource.Table, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// ResourceDeleteOne is the builder for deleting a single Resource entity. +type ResourceDeleteOne struct { + _d *ResourceDelete +} + +// Where appends a list predicates to the ResourceDelete builder. +func (_d *ResourceDeleteOne) Where(ps ...predicate.Resource) *ResourceDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *ResourceDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{resource.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ResourceDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/resource_query.go b/internal/features/system/data/ent/resource_query.go new file mode 100644 index 00000000..8278f88a --- /dev/null +++ b/internal/features/system/data/ent/resource_query.go @@ -0,0 +1,970 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/resource" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ResourceQuery is the builder for querying Resource entities. +type ResourceQuery struct { + config + ctx *QueryContext + order []resource.OrderOption + inters []Interceptor + predicates []predicate.Resource + withParent *ResourceQuery + withChildren *ResourceQuery + withPermissions *PermissionQuery + withPermissionResources *PermissionResourceQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ResourceQuery builder. +func (_q *ResourceQuery) Where(ps ...predicate.Resource) *ResourceQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *ResourceQuery) Limit(limit int) *ResourceQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *ResourceQuery) Offset(offset int) *ResourceQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *ResourceQuery) Unique(unique bool) *ResourceQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *ResourceQuery) Order(o ...resource.OrderOption) *ResourceQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryParent chains the current query on the "parent" edge. +func (_q *ResourceQuery) QueryParent() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, selector), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, resource.ParentTable, resource.ParentColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryChildren chains the current query on the "children" edge. +func (_q *ResourceQuery) QueryChildren() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, selector), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, resource.ChildrenTable, resource.ChildrenColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryPermissions chains the current query on the "permissions" edge. +func (_q *ResourceQuery) QueryPermissions() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, selector), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, resource.PermissionsTable, resource.PermissionsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryPermissionResources chains the current query on the "permission_resources" edge. +func (_q *ResourceQuery) QueryPermissionResources() *PermissionResourceQuery { + query := (&PermissionResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, selector), + sqlgraph.To(permissionresource.Table, permissionresource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, resource.PermissionResourcesTable, resource.PermissionResourcesColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Resource entity from the query. +// Returns a *NotFoundError when no Resource was found. +func (_q *ResourceQuery) First(ctx context.Context) (*Resource, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{resource.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *ResourceQuery) FirstX(ctx context.Context) *Resource { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Resource ID from the query. +// Returns a *NotFoundError when no Resource ID was found. +func (_q *ResourceQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{resource.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *ResourceQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Resource entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Resource entity is found. +// Returns a *NotFoundError when no Resource entities are found. +func (_q *ResourceQuery) Only(ctx context.Context) (*Resource, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{resource.Label} + default: + return nil, &NotSingularError{resource.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *ResourceQuery) OnlyX(ctx context.Context) *Resource { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Resource ID in the query. +// Returns a *NotSingularError when more than one Resource ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *ResourceQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{resource.Label} + default: + err = &NotSingularError{resource.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *ResourceQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Resources. +func (_q *ResourceQuery) All(ctx context.Context) ([]*Resource, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Resource, *ResourceQuery]() + return withInterceptors[[]*Resource](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *ResourceQuery) AllX(ctx context.Context) []*Resource { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Resource IDs. +func (_q *ResourceQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(resource.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *ResourceQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *ResourceQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*ResourceQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *ResourceQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *ResourceQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *ResourceQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ResourceQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *ResourceQuery) Clone() *ResourceQuery { + if _q == nil { + return nil + } + return &ResourceQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]resource.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Resource{}, _q.predicates...), + withParent: _q.withParent.Clone(), + withChildren: _q.withChildren.Clone(), + withPermissions: _q.withPermissions.Clone(), + withPermissionResources: _q.withPermissionResources.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithParent tells the query-builder to eager-load the nodes that are connected to +// the "parent" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ResourceQuery) WithParent(opts ...func(*ResourceQuery)) *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withParent = query + return _q +} + +// WithChildren tells the query-builder to eager-load the nodes that are connected to +// the "children" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ResourceQuery) WithChildren(opts ...func(*ResourceQuery)) *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withChildren = query + return _q +} + +// WithPermissions tells the query-builder to eager-load the nodes that are connected to +// the "permissions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ResourceQuery) WithPermissions(opts ...func(*PermissionQuery)) *ResourceQuery { + query := (&PermissionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withPermissions = query + return _q +} + +// WithPermissionResources tells the query-builder to eager-load the nodes that are connected to +// the "permission_resources" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ResourceQuery) WithPermissionResources(opts ...func(*PermissionResourceQuery)) *ResourceQuery { + query := (&PermissionResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withPermissionResources = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Resource.Query(). +// GroupBy(resource.FieldCreateTime). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *ResourceQuery) GroupBy(field string, fields ...string) *ResourceGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &ResourceGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = resource.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// } +// +// client.Resource.Query(). +// Select(resource.FieldCreateTime). +// Scan(ctx, &v) +func (_q *ResourceQuery) Select(fields ...string) *ResourceSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &ResourceSelect{ResourceQuery: _q} + sbuild.label = resource.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ResourceSelect configured with the given aggregations. +func (_q *ResourceQuery) Aggregate(fns ...AggregateFunc) *ResourceSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *ResourceQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !resource.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Resource, error) { + var ( + nodes = []*Resource{} + _spec = _q.querySpec() + loadedTypes = [4]bool{ + _q.withParent != nil, + _q.withChildren != nil, + _q.withPermissions != nil, + _q.withPermissionResources != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Resource).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Resource{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withParent; query != nil { + if err := _q.loadParent(ctx, query, nodes, nil, + func(n *Resource, e *Resource) { n.Edges.Parent = e }); err != nil { + return nil, err + } + } + if query := _q.withChildren; query != nil { + if err := _q.loadChildren(ctx, query, nodes, + func(n *Resource) { n.Edges.Children = []*Resource{} }, + func(n *Resource, e *Resource) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil { + return nil, err + } + } + if query := _q.withPermissions; query != nil { + if err := _q.loadPermissions(ctx, query, nodes, + func(n *Resource) { n.Edges.Permissions = []*Permission{} }, + func(n *Resource, e *Permission) { n.Edges.Permissions = append(n.Edges.Permissions, e) }); err != nil { + return nil, err + } + } + if query := _q.withPermissionResources; query != nil { + if err := _q.loadPermissionResources(ctx, query, nodes, + func(n *Resource) { n.Edges.PermissionResources = []*PermissionResource{} }, + func(n *Resource, e *PermissionResource) { + n.Edges.PermissionResources = append(n.Edges.PermissionResources, e) + }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *ResourceQuery) loadParent(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*Resource) + for i := range nodes { + fk := nodes[i].ParentID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(resource.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "parent_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *ResourceQuery) loadChildren(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*Resource) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(resource.FieldParentID) + } + query.Where(predicate.Resource(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(resource.ChildrenColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ParentID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "parent_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *ResourceQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Permission)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int64]*Resource) + nids := make(map[int64]map[*Resource]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(resource.PermissionsTable) + s.Join(joinT).On(s.C(permission.FieldID), joinT.C(resource.PermissionsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(resource.PermissionsPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(resource.PermissionsPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullInt64).Int64 + inValue := values[1].(*sql.NullInt64).Int64 + if nids[inValue] == nil { + nids[inValue] = map[*Resource]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Permission](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "permissions" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (_q *ResourceQuery) loadPermissionResources(ctx context.Context, query *PermissionResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *PermissionResource)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*Resource) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(permissionresource.FieldResourceID) + } + query.Where(predicate.PermissionResource(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(resource.PermissionResourcesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ResourceID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "resource_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *ResourceQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *ResourceQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(resource.Table, resource.Columns, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, resource.FieldID) + for i := range fields { + if fields[i] != resource.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withParent != nil { + _spec.Node.AddColumnOnce(resource.FieldParentID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *ResourceQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(resource.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = resource.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *ResourceQuery) ForUpdate(opts ...sql.LockOption) *ResourceQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *ResourceQuery) ForShare(opts ...sql.LockOption) *ResourceQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *ResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *ResourceSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// UpdateTime time.Time `json:"update_time,omitempty"` +// Name string `json:"name,omitempty"` +// Keyword string `json:"keyword,omitempty"` +// Type string `json:"type,omitempty"` +// Status int8 `json:"status,omitempty"` +// Path string `json:"path,omitempty"` +// Component string `json:"component,omitempty"` +// Icon string `json:"icon,omitempty"` +// Sequence int `json:"sequence,omitempty"` +// Visible bool `json:"visible,omitempty"` +// Level int8 `json:"level,omitempty"` +// TreePath string `json:"tree_path,omitempty"` +// Properties map[string]string `json:"properties,omitempty"` +// Description string `json:"description,omitempty"` +// ParentID int64 `json:"parent_id,omitempty"` +// } +// +// client.Resource.Query(). +// Omit( +// resource.FieldCreateTime, +// resource.FieldUpdateTime, +// resource.FieldName, +// resource.FieldKeyword, +// resource.FieldType, +// resource.FieldStatus, +// resource.FieldPath, +// resource.FieldComponent, +// resource.FieldIcon, +// resource.FieldSequence, +// resource.FieldVisible, +// resource.FieldLevel, +// resource.FieldTreePath, +// resource.FieldProperties, +// resource.FieldDescription, +// resource.FieldParentID, +// ). +// Scan(ctx, &v) +func (rq *ResourceQuery) Omit(fields ...string) *ResourceSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range resource.Columns { + if _, ok := omits[col]; !ok { + rq.ctx.Fields = append(rq.ctx.Fields, col) + } + } + + sbuild := &ResourceSelect{ResourceQuery: rq} + sbuild.label = resource.Label + sbuild.flds, sbuild.scan = &rq.ctx.Fields, sbuild.Scan + return sbuild +} + +// ResourceGroupBy is the group-by builder for Resource entities. +type ResourceGroupBy struct { + selector + build *ResourceQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *ResourceGroupBy) Aggregate(fns ...AggregateFunc) *ResourceGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *ResourceGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ResourceQuery, *ResourceGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *ResourceGroupBy) sqlScan(ctx context.Context, root *ResourceQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ResourceSelect is the builder for selecting fields of Resource entities. +type ResourceSelect struct { + *ResourceQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *ResourceSelect) Aggregate(fns ...AggregateFunc) *ResourceSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *ResourceSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ResourceQuery, *ResourceSelect](ctx, _s.ResourceQuery, _s, _s.inters, v) +} + +func (_s *ResourceSelect) sqlScan(ctx context.Context, root *ResourceQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *ResourceSelect) Modify(modifiers ...func(s *sql.Selector)) *ResourceSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/internal/features/system/data/ent/resource_update.go b/internal/features/system/data/ent/resource_update.go new file mode 100644 index 00000000..fa1defcf --- /dev/null +++ b/internal/features/system/data/ent/resource_update.go @@ -0,0 +1,1492 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/permissionresource" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ResourceUpdate is the builder for updating Resource entities. +type ResourceUpdate struct { + config + hooks []Hook + mutation *ResourceMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ResourceUpdate builder. +func (_u *ResourceUpdate) Where(ps ...predicate.Resource) *ResourceUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *ResourceUpdate) SetUpdateTime(v time.Time) *ResourceUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetName sets the "name" field. +func (_u *ResourceUpdate) SetName(v string) *ResourceUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableName(v *string) *ResourceUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetKeyword sets the "keyword" field. +func (_u *ResourceUpdate) SetKeyword(v string) *ResourceUpdate { + _u.mutation.SetKeyword(v) + return _u +} + +// SetNillableKeyword sets the "keyword" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableKeyword(v *string) *ResourceUpdate { + if v != nil { + _u.SetKeyword(*v) + } + return _u +} + +// SetType sets the "type" field. +func (_u *ResourceUpdate) SetType(v string) *ResourceUpdate { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableType(v *string) *ResourceUpdate { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetStatus sets the "status" field. +func (_u *ResourceUpdate) SetStatus(v int8) *ResourceUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableStatus(v *int8) *ResourceUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *ResourceUpdate) AddStatus(v int8) *ResourceUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// SetPath sets the "path" field. +func (_u *ResourceUpdate) SetPath(v string) *ResourceUpdate { + _u.mutation.SetPath(v) + return _u +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillablePath(v *string) *ResourceUpdate { + if v != nil { + _u.SetPath(*v) + } + return _u +} + +// SetComponent sets the "component" field. +func (_u *ResourceUpdate) SetComponent(v string) *ResourceUpdate { + _u.mutation.SetComponent(v) + return _u +} + +// SetNillableComponent sets the "component" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableComponent(v *string) *ResourceUpdate { + if v != nil { + _u.SetComponent(*v) + } + return _u +} + +// SetIcon sets the "icon" field. +func (_u *ResourceUpdate) SetIcon(v string) *ResourceUpdate { + _u.mutation.SetIcon(v) + return _u +} + +// SetNillableIcon sets the "icon" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableIcon(v *string) *ResourceUpdate { + if v != nil { + _u.SetIcon(*v) + } + return _u +} + +// SetSequence sets the "sequence" field. +func (_u *ResourceUpdate) SetSequence(v int) *ResourceUpdate { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableSequence(v *int) *ResourceUpdate { + if v != nil { + _u.SetSequence(*v) + } + return _u +} + +// AddSequence adds value to the "sequence" field. +func (_u *ResourceUpdate) AddSequence(v int) *ResourceUpdate { + _u.mutation.AddSequence(v) + return _u +} + +// SetVisible sets the "visible" field. +func (_u *ResourceUpdate) SetVisible(v bool) *ResourceUpdate { + _u.mutation.SetVisible(v) + return _u +} + +// SetNillableVisible sets the "visible" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableVisible(v *bool) *ResourceUpdate { + if v != nil { + _u.SetVisible(*v) + } + return _u +} + +// SetLevel sets the "level" field. +func (_u *ResourceUpdate) SetLevel(v int8) *ResourceUpdate { + _u.mutation.ResetLevel() + _u.mutation.SetLevel(v) + return _u +} + +// SetNillableLevel sets the "level" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableLevel(v *int8) *ResourceUpdate { + if v != nil { + _u.SetLevel(*v) + } + return _u +} + +// AddLevel adds value to the "level" field. +func (_u *ResourceUpdate) AddLevel(v int8) *ResourceUpdate { + _u.mutation.AddLevel(v) + return _u +} + +// SetTreePath sets the "tree_path" field. +func (_u *ResourceUpdate) SetTreePath(v string) *ResourceUpdate { + _u.mutation.SetTreePath(v) + return _u +} + +// SetNillableTreePath sets the "tree_path" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableTreePath(v *string) *ResourceUpdate { + if v != nil { + _u.SetTreePath(*v) + } + return _u +} + +// SetProperties sets the "properties" field. +func (_u *ResourceUpdate) SetProperties(v map[string]string) *ResourceUpdate { + _u.mutation.SetProperties(v) + return _u +} + +// ClearProperties clears the value of the "properties" field. +func (_u *ResourceUpdate) ClearProperties() *ResourceUpdate { + _u.mutation.ClearProperties() + return _u +} + +// SetDescription sets the "description" field. +func (_u *ResourceUpdate) SetDescription(v string) *ResourceUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableDescription(v *string) *ResourceUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// SetParentID sets the "parent_id" field. +func (_u *ResourceUpdate) SetParentID(v int64) *ResourceUpdate { + _u.mutation.SetParentID(v) + return _u +} + +// SetNillableParentID sets the "parent_id" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableParentID(v *int64) *ResourceUpdate { + if v != nil { + _u.SetParentID(*v) + } + return _u +} + +// ClearParentID clears the value of the "parent_id" field. +func (_u *ResourceUpdate) ClearParentID() *ResourceUpdate { + _u.mutation.ClearParentID() + return _u +} + +// SetParent sets the "parent" edge to the Resource entity. +func (_u *ResourceUpdate) SetParent(v *Resource) *ResourceUpdate { + return _u.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Resource entity by IDs. +func (_u *ResourceUpdate) AddChildIDs(ids ...int64) *ResourceUpdate { + _u.mutation.AddChildIDs(ids...) + return _u +} + +// AddChildren adds the "children" edges to the Resource entity. +func (_u *ResourceUpdate) AddChildren(v ...*Resource) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChildIDs(ids...) +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. +func (_u *ResourceUpdate) AddPermissionIDs(ids ...int64) *ResourceUpdate { + _u.mutation.AddPermissionIDs(ids...) + return _u +} + +// AddPermissions adds the "permissions" edges to the Permission entity. +func (_u *ResourceUpdate) AddPermissions(v ...*Permission) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPermissionIDs(ids...) +} + +// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. +func (_u *ResourceUpdate) AddPermissionResourceIDs(ids ...int) *ResourceUpdate { + _u.mutation.AddPermissionResourceIDs(ids...) + return _u +} + +// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. +func (_u *ResourceUpdate) AddPermissionResources(v ...*PermissionResource) *ResourceUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPermissionResourceIDs(ids...) +} + +// Mutation returns the ResourceMutation object of the builder. +func (_u *ResourceUpdate) Mutation() *ResourceMutation { + return _u.mutation +} + +// ClearParent clears the "parent" edge to the Resource entity. +func (_u *ResourceUpdate) ClearParent() *ResourceUpdate { + _u.mutation.ClearParent() + return _u +} + +// ClearChildren clears all "children" edges to the Resource entity. +func (_u *ResourceUpdate) ClearChildren() *ResourceUpdate { + _u.mutation.ClearChildren() + return _u +} + +// RemoveChildIDs removes the "children" edge to Resource entities by IDs. +func (_u *ResourceUpdate) RemoveChildIDs(ids ...int64) *ResourceUpdate { + _u.mutation.RemoveChildIDs(ids...) + return _u +} + +// RemoveChildren removes "children" edges to Resource entities. +func (_u *ResourceUpdate) RemoveChildren(v ...*Resource) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChildIDs(ids...) +} + +// ClearPermissions clears all "permissions" edges to the Permission entity. +func (_u *ResourceUpdate) ClearPermissions() *ResourceUpdate { + _u.mutation.ClearPermissions() + return _u +} + +// RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. +func (_u *ResourceUpdate) RemovePermissionIDs(ids ...int64) *ResourceUpdate { + _u.mutation.RemovePermissionIDs(ids...) + return _u +} + +// RemovePermissions removes "permissions" edges to Permission entities. +func (_u *ResourceUpdate) RemovePermissions(v ...*Permission) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePermissionIDs(ids...) +} + +// ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. +func (_u *ResourceUpdate) ClearPermissionResources() *ResourceUpdate { + _u.mutation.ClearPermissionResources() + return _u +} + +// RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. +func (_u *ResourceUpdate) RemovePermissionResourceIDs(ids ...int) *ResourceUpdate { + _u.mutation.RemovePermissionResourceIDs(ids...) + return _u +} + +// RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. +func (_u *ResourceUpdate) RemovePermissionResources(v ...*PermissionResource) *ResourceUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePermissionResourceIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *ResourceUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ResourceUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *ResourceUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ResourceUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ResourceUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := resource.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ResourceUpdate) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := resource.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} + } + } + if v, ok := _u.mutation.Keyword(); ok { + if err := resource.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} + } + } + if v, ok := _u.mutation.GetType(); ok { + if err := resource.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} + } + } + if v, ok := _u.mutation.Path(); ok { + if err := resource.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} + } + } + if v, ok := _u.mutation.Component(); ok { + if err := resource.ComponentValidator(v); err != nil { + return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} + } + } + if v, ok := _u.mutation.Icon(); ok { + if err := resource.IconValidator(v); err != nil { + return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} + } + } + if v, ok := _u.mutation.TreePath(); ok { + if err := resource.TreePathValidator(v); err != nil { + return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := resource.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ResourceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ResourceUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(resource.Table, resource.Columns, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(resource.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Keyword(); ok { + _spec.SetField(resource.FieldKeyword, field.TypeString, value) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(resource.FieldType, field.TypeString, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(resource.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(resource.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.Path(); ok { + _spec.SetField(resource.FieldPath, field.TypeString, value) + } + if value, ok := _u.mutation.Component(); ok { + _spec.SetField(resource.FieldComponent, field.TypeString, value) + } + if value, ok := _u.mutation.Icon(); ok { + _spec.SetField(resource.FieldIcon, field.TypeString, value) + } + if value, ok := _u.mutation.Sequence(); ok { + _spec.SetField(resource.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSequence(); ok { + _spec.AddField(resource.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.Visible(); ok { + _spec.SetField(resource.FieldVisible, field.TypeBool, value) + } + if value, ok := _u.mutation.Level(); ok { + _spec.SetField(resource.FieldLevel, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedLevel(); ok { + _spec.AddField(resource.FieldLevel, field.TypeInt8, value) + } + if value, ok := _u.mutation.TreePath(); ok { + _spec.SetField(resource.FieldTreePath, field.TypeString, value) + } + if value, ok := _u.mutation.Properties(); ok { + _spec.SetField(resource.FieldProperties, field.TypeJSON, value) + } + if _u.mutation.PropertiesCleared() { + _spec.ClearField(resource.FieldProperties, field.TypeJSON) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(resource.FieldDescription, field.TypeString, value) + } + if _u.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: resource.ParentTable, + Columns: []string{resource.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: resource.ParentTable, + Columns: []string{resource.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: resource.PermissionsTable, + Columns: resource.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: resource.PermissionsTable, + Columns: resource.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: resource.PermissionsTable, + Columns: resource.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.PermissionResourcesTable, + Columns: []string{resource.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.PermissionResourcesTable, + Columns: []string{resource.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.PermissionResourcesTable, + Columns: []string{resource.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{resource.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// ResourceUpdateOne is the builder for updating a single Resource entity. +type ResourceUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ResourceMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdateTime sets the "update_time" field. +func (_u *ResourceUpdateOne) SetUpdateTime(v time.Time) *ResourceUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetName sets the "name" field. +func (_u *ResourceUpdateOne) SetName(v string) *ResourceUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableName(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetKeyword sets the "keyword" field. +func (_u *ResourceUpdateOne) SetKeyword(v string) *ResourceUpdateOne { + _u.mutation.SetKeyword(v) + return _u +} + +// SetNillableKeyword sets the "keyword" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableKeyword(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetKeyword(*v) + } + return _u +} + +// SetType sets the "type" field. +func (_u *ResourceUpdateOne) SetType(v string) *ResourceUpdateOne { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableType(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetStatus sets the "status" field. +func (_u *ResourceUpdateOne) SetStatus(v int8) *ResourceUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableStatus(v *int8) *ResourceUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *ResourceUpdateOne) AddStatus(v int8) *ResourceUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// SetPath sets the "path" field. +func (_u *ResourceUpdateOne) SetPath(v string) *ResourceUpdateOne { + _u.mutation.SetPath(v) + return _u +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillablePath(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetPath(*v) + } + return _u +} + +// SetComponent sets the "component" field. +func (_u *ResourceUpdateOne) SetComponent(v string) *ResourceUpdateOne { + _u.mutation.SetComponent(v) + return _u +} + +// SetNillableComponent sets the "component" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableComponent(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetComponent(*v) + } + return _u +} + +// SetIcon sets the "icon" field. +func (_u *ResourceUpdateOne) SetIcon(v string) *ResourceUpdateOne { + _u.mutation.SetIcon(v) + return _u +} + +// SetNillableIcon sets the "icon" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableIcon(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetIcon(*v) + } + return _u +} + +// SetSequence sets the "sequence" field. +func (_u *ResourceUpdateOne) SetSequence(v int) *ResourceUpdateOne { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableSequence(v *int) *ResourceUpdateOne { + if v != nil { + _u.SetSequence(*v) + } + return _u +} + +// AddSequence adds value to the "sequence" field. +func (_u *ResourceUpdateOne) AddSequence(v int) *ResourceUpdateOne { + _u.mutation.AddSequence(v) + return _u +} + +// SetVisible sets the "visible" field. +func (_u *ResourceUpdateOne) SetVisible(v bool) *ResourceUpdateOne { + _u.mutation.SetVisible(v) + return _u +} + +// SetNillableVisible sets the "visible" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableVisible(v *bool) *ResourceUpdateOne { + if v != nil { + _u.SetVisible(*v) + } + return _u +} + +// SetLevel sets the "level" field. +func (_u *ResourceUpdateOne) SetLevel(v int8) *ResourceUpdateOne { + _u.mutation.ResetLevel() + _u.mutation.SetLevel(v) + return _u +} + +// SetNillableLevel sets the "level" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableLevel(v *int8) *ResourceUpdateOne { + if v != nil { + _u.SetLevel(*v) + } + return _u +} + +// AddLevel adds value to the "level" field. +func (_u *ResourceUpdateOne) AddLevel(v int8) *ResourceUpdateOne { + _u.mutation.AddLevel(v) + return _u +} + +// SetTreePath sets the "tree_path" field. +func (_u *ResourceUpdateOne) SetTreePath(v string) *ResourceUpdateOne { + _u.mutation.SetTreePath(v) + return _u +} + +// SetNillableTreePath sets the "tree_path" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableTreePath(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetTreePath(*v) + } + return _u +} + +// SetProperties sets the "properties" field. +func (_u *ResourceUpdateOne) SetProperties(v map[string]string) *ResourceUpdateOne { + _u.mutation.SetProperties(v) + return _u +} + +// ClearProperties clears the value of the "properties" field. +func (_u *ResourceUpdateOne) ClearProperties() *ResourceUpdateOne { + _u.mutation.ClearProperties() + return _u +} + +// SetDescription sets the "description" field. +func (_u *ResourceUpdateOne) SetDescription(v string) *ResourceUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableDescription(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// SetParentID sets the "parent_id" field. +func (_u *ResourceUpdateOne) SetParentID(v int64) *ResourceUpdateOne { + _u.mutation.SetParentID(v) + return _u +} + +// SetNillableParentID sets the "parent_id" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableParentID(v *int64) *ResourceUpdateOne { + if v != nil { + _u.SetParentID(*v) + } + return _u +} + +// ClearParentID clears the value of the "parent_id" field. +func (_u *ResourceUpdateOne) ClearParentID() *ResourceUpdateOne { + _u.mutation.ClearParentID() + return _u +} + +// SetParent sets the "parent" edge to the Resource entity. +func (_u *ResourceUpdateOne) SetParent(v *Resource) *ResourceUpdateOne { + return _u.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Resource entity by IDs. +func (_u *ResourceUpdateOne) AddChildIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.AddChildIDs(ids...) + return _u +} + +// AddChildren adds the "children" edges to the Resource entity. +func (_u *ResourceUpdateOne) AddChildren(v ...*Resource) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChildIDs(ids...) +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. +func (_u *ResourceUpdateOne) AddPermissionIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.AddPermissionIDs(ids...) + return _u +} + +// AddPermissions adds the "permissions" edges to the Permission entity. +func (_u *ResourceUpdateOne) AddPermissions(v ...*Permission) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPermissionIDs(ids...) +} + +// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. +func (_u *ResourceUpdateOne) AddPermissionResourceIDs(ids ...int) *ResourceUpdateOne { + _u.mutation.AddPermissionResourceIDs(ids...) + return _u +} + +// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. +func (_u *ResourceUpdateOne) AddPermissionResources(v ...*PermissionResource) *ResourceUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPermissionResourceIDs(ids...) +} + +// Mutation returns the ResourceMutation object of the builder. +func (_u *ResourceUpdateOne) Mutation() *ResourceMutation { + return _u.mutation +} + +// ClearParent clears the "parent" edge to the Resource entity. +func (_u *ResourceUpdateOne) ClearParent() *ResourceUpdateOne { + _u.mutation.ClearParent() + return _u +} + +// ClearChildren clears all "children" edges to the Resource entity. +func (_u *ResourceUpdateOne) ClearChildren() *ResourceUpdateOne { + _u.mutation.ClearChildren() + return _u +} + +// RemoveChildIDs removes the "children" edge to Resource entities by IDs. +func (_u *ResourceUpdateOne) RemoveChildIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.RemoveChildIDs(ids...) + return _u +} + +// RemoveChildren removes "children" edges to Resource entities. +func (_u *ResourceUpdateOne) RemoveChildren(v ...*Resource) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChildIDs(ids...) +} + +// ClearPermissions clears all "permissions" edges to the Permission entity. +func (_u *ResourceUpdateOne) ClearPermissions() *ResourceUpdateOne { + _u.mutation.ClearPermissions() + return _u +} + +// RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. +func (_u *ResourceUpdateOne) RemovePermissionIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.RemovePermissionIDs(ids...) + return _u +} + +// RemovePermissions removes "permissions" edges to Permission entities. +func (_u *ResourceUpdateOne) RemovePermissions(v ...*Permission) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePermissionIDs(ids...) +} + +// ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. +func (_u *ResourceUpdateOne) ClearPermissionResources() *ResourceUpdateOne { + _u.mutation.ClearPermissionResources() + return _u +} + +// RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. +func (_u *ResourceUpdateOne) RemovePermissionResourceIDs(ids ...int) *ResourceUpdateOne { + _u.mutation.RemovePermissionResourceIDs(ids...) + return _u +} + +// RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. +func (_u *ResourceUpdateOne) RemovePermissionResources(v ...*PermissionResource) *ResourceUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePermissionResourceIDs(ids...) +} + +// Where appends a list predicates to the ResourceUpdate builder. +func (_u *ResourceUpdateOne) Where(ps ...predicate.Resource) *ResourceUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *ResourceUpdateOne) Select(field string, fields ...string) *ResourceUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated Resource entity. +func (_u *ResourceUpdateOne) Save(ctx context.Context) (*Resource, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ResourceUpdateOne) SaveX(ctx context.Context) *Resource { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *ResourceUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ResourceUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ResourceUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := resource.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ResourceUpdateOne) check() error { + if v, ok := _u.mutation.Name(); ok { + if err := resource.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} + } + } + if v, ok := _u.mutation.Keyword(); ok { + if err := resource.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} + } + } + if v, ok := _u.mutation.GetType(); ok { + if err := resource.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} + } + } + if v, ok := _u.mutation.Path(); ok { + if err := resource.PathValidator(v); err != nil { + return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} + } + } + if v, ok := _u.mutation.Component(); ok { + if err := resource.ComponentValidator(v); err != nil { + return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} + } + } + if v, ok := _u.mutation.Icon(); ok { + if err := resource.IconValidator(v); err != nil { + return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} + } + } + if v, ok := _u.mutation.TreePath(); ok { + if err := resource.TreePathValidator(v); err != nil { + return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := resource.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ResourceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ResourceUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(resource.Table, resource.Columns, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Resource.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, resource.FieldID) + for _, f := range fields { + if !resource.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != resource.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(resource.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Keyword(); ok { + _spec.SetField(resource.FieldKeyword, field.TypeString, value) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(resource.FieldType, field.TypeString, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(resource.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(resource.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.Path(); ok { + _spec.SetField(resource.FieldPath, field.TypeString, value) + } + if value, ok := _u.mutation.Component(); ok { + _spec.SetField(resource.FieldComponent, field.TypeString, value) + } + if value, ok := _u.mutation.Icon(); ok { + _spec.SetField(resource.FieldIcon, field.TypeString, value) + } + if value, ok := _u.mutation.Sequence(); ok { + _spec.SetField(resource.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSequence(); ok { + _spec.AddField(resource.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.Visible(); ok { + _spec.SetField(resource.FieldVisible, field.TypeBool, value) + } + if value, ok := _u.mutation.Level(); ok { + _spec.SetField(resource.FieldLevel, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedLevel(); ok { + _spec.AddField(resource.FieldLevel, field.TypeInt8, value) + } + if value, ok := _u.mutation.TreePath(); ok { + _spec.SetField(resource.FieldTreePath, field.TypeString, value) + } + if value, ok := _u.mutation.Properties(); ok { + _spec.SetField(resource.FieldProperties, field.TypeJSON, value) + } + if _u.mutation.PropertiesCleared() { + _spec.ClearField(resource.FieldProperties, field.TypeJSON) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(resource.FieldDescription, field.TypeString, value) + } + if _u.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: resource.ParentTable, + Columns: []string{resource.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: resource.ParentTable, + Columns: []string{resource.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: resource.PermissionsTable, + Columns: resource.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: resource.PermissionsTable, + Columns: resource.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: resource.PermissionsTable, + Columns: resource.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.PermissionResourcesTable, + Columns: []string{resource.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.PermissionResourcesTable, + Columns: []string{resource.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.PermissionResourcesTable, + Columns: []string{resource.PermissionResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &Resource{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{resource.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} + +// SetResource set the Resource +func (ru *ResourceUpdate) SetResource(input *Resource, fields ...string) *ResourceUpdate { + m := ru.mutation + if len(fields) == 0 { + fields = resource.OmitColumns(resource.FieldID) + } + _ = m.SetFields(input, fields...) + return ru +} + +// SetResourceWithZero set the Resource +func (ru *ResourceUpdate) SetResourceWithZero(input *Resource, fields ...string) *ResourceUpdate { + m := ru.mutation + if len(fields) == 0 { + fields = resource.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return ru +} + +// SetResource set the Resource +func (ruo *ResourceUpdateOne) SetResource(input *Resource, fields ...string) *ResourceUpdateOne { + m := ruo.mutation + if len(fields) == 0 { + fields = resource.OmitColumns(resource.FieldID) + } + _ = m.SetFields(input, fields...) + return ruo +} + +// SetResourceWithZero set the Resource +func (ruo *ResourceUpdateOne) SetResourceWithZero(input *Resource, fields ...string) *ResourceUpdateOne { + m := ruo.mutation + if len(fields) == 0 { + fields = resource.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return ruo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (ruo *ResourceUpdateOne) Omit(fields ...string) *ResourceUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + ruo.fields = []string(nil) + for _, col := range resource.Columns { + if _, ok := omits[col]; !ok { + ruo.fields = append(ruo.fields, col) + } + } + return ruo +} diff --git a/internal/features/system/data/ent/role.go b/internal/features/system/data/ent/role.go new file mode 100644 index 00000000..f4205e85 --- /dev/null +++ b/internal/features/system/data/ent/role.go @@ -0,0 +1,258 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/role" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// Role table +type Role struct { + config `json:"-"` + // ID of the ent. + // ID + ID int64 `json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime time.Time `json:"update_time,omitempty"` + // keyword of role (unique) + Keyword string `json:"keyword,omitempty"` + // Display name of role + Name string `json:"name,omitempty"` + // Details about role + Description string `json:"description,omitempty"` + // Role type: 1 - System role 2 - User role 3 - Department role + Type int8 `json:"type,omitempty"` + // Sequence for sorting + Sequence int `json:"sequence,omitempty"` + // status + Status int8 `json:"status,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the RoleQuery when eager-loading is set. + Edges RoleEdges `json:"edges"` + selectValues sql.SelectValues +} + +// RoleEdges holds the relations/edges for other nodes in the graph. +type RoleEdges struct { + // Users holds the value of the users edge. + Users []*User `json:"users,omitempty"` + // Permissions holds the value of the permissions edge. + Permissions []*Permission `json:"permissions,omitempty"` + // UserRoles holds the value of the user_roles edge. + UserRoles []*UserRole `json:"user_roles,omitempty"` + // RolePermissions holds the value of the role_permissions edge. + RolePermissions []*RolePermission `json:"role_permissions,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [4]bool +} + +// UsersOrErr returns the Users value or an error if the edge +// was not loaded in eager-loading. +func (e RoleEdges) UsersOrErr() ([]*User, error) { + if e.loadedTypes[0] { + return e.Users, nil + } + return nil, &NotLoadedError{edge: "users"} +} + +// PermissionsOrErr returns the Permissions value or an error if the edge +// was not loaded in eager-loading. +func (e RoleEdges) PermissionsOrErr() ([]*Permission, error) { + if e.loadedTypes[1] { + return e.Permissions, nil + } + return nil, &NotLoadedError{edge: "permissions"} +} + +// UserRolesOrErr returns the UserRoles value or an error if the edge +// was not loaded in eager-loading. +func (e RoleEdges) UserRolesOrErr() ([]*UserRole, error) { + if e.loadedTypes[2] { + return e.UserRoles, nil + } + return nil, &NotLoadedError{edge: "user_roles"} +} + +// RolePermissionsOrErr returns the RolePermissions value or an error if the edge +// was not loaded in eager-loading. +func (e RoleEdges) RolePermissionsOrErr() ([]*RolePermission, error) { + if e.loadedTypes[3] { + return e.RolePermissions, nil + } + return nil, &NotLoadedError{edge: "role_permissions"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Role) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case role.FieldID, role.FieldType, role.FieldSequence, role.FieldStatus: + values[i] = new(sql.NullInt64) + case role.FieldKeyword, role.FieldName, role.FieldDescription: + values[i] = new(sql.NullString) + case role.FieldCreateTime, role.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Role fields. +func (_m *Role) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case role.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case role.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = value.Time + } + case role.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = value.Time + } + case role.FieldKeyword: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field keyword", values[i]) + } else if value.Valid { + _m.Keyword = value.String + } + case role.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case role.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case role.FieldType: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + _m.Type = int8(value.Int64) + } + case role.FieldSequence: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sequence", values[i]) + } else if value.Valid { + _m.Sequence = int(value.Int64) + } + case role.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = int8(value.Int64) + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the Role. +// This includes values selected through modifiers, order, etc. +func (_m *Role) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryUsers queries the "users" edge of the Role entity. +func (_m *Role) QueryUsers() *UserQuery { + return NewRoleClient(_m.config).QueryUsers(_m) +} + +// QueryPermissions queries the "permissions" edge of the Role entity. +func (_m *Role) QueryPermissions() *PermissionQuery { + return NewRoleClient(_m.config).QueryPermissions(_m) +} + +// QueryUserRoles queries the "user_roles" edge of the Role entity. +func (_m *Role) QueryUserRoles() *UserRoleQuery { + return NewRoleClient(_m.config).QueryUserRoles(_m) +} + +// QueryRolePermissions queries the "role_permissions" edge of the Role entity. +func (_m *Role) QueryRolePermissions() *RolePermissionQuery { + return NewRoleClient(_m.config).QueryRolePermissions(_m) +} + +// Update returns a builder for updating this Role. +// Note that you need to call Role.Unwrap() before calling this method if this Role +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *Role) Update() *RoleUpdateOne { + return NewRoleClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the Role entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *Role) Unwrap() *Role { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: Role is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *Role) String() string { + var builder strings.Builder + builder.WriteString("Role(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("create_time=") + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("keyword=") + builder.WriteString(_m.Keyword) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(fmt.Sprintf("%v", _m.Type)) + builder.WriteString(", ") + builder.WriteString("sequence=") + builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteByte(')') + return builder.String() +} + +// Roles is a parsable slice of Role. +type Roles []*Role diff --git a/internal/features/system/data/ent/role/role.go b/internal/features/system/data/ent/role/role.go new file mode 100644 index 00000000..4ee5d7ce --- /dev/null +++ b/internal/features/system/data/ent/role/role.go @@ -0,0 +1,318 @@ +// Code generated by ent, DO NOT EDIT. + +package role + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the role type in the database. + Label = "role" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldKeyword holds the string denoting the keyword field in the database. + FieldKeyword = "keyword" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldSequence holds the string denoting the sequence field in the database. + FieldSequence = "sequence" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // EdgeUsers holds the string denoting the users edge name in mutations. + EdgeUsers = "users" + // EdgePermissions holds the string denoting the permissions edge name in mutations. + EdgePermissions = "permissions" + // EdgeUserRoles holds the string denoting the user_roles edge name in mutations. + EdgeUserRoles = "user_roles" + // EdgeRolePermissions holds the string denoting the role_permissions edge name in mutations. + EdgeRolePermissions = "role_permissions" + // Table holds the table name of the role in the database. + Table = "sys_roles" + // UsersTable is the table that holds the users relation/edge. The primary key declared below. + UsersTable = "sys_user_roles" + // UsersInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UsersInverseTable = "sys_users" + // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. + PermissionsTable = "sys_role_permissions" + // PermissionsInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionsInverseTable = "sys_permissions" + // UserRolesTable is the table that holds the user_roles relation/edge. + UserRolesTable = "sys_user_roles" + // UserRolesInverseTable is the table name for the UserRole entity. + // It exists in this package in order to avoid circular dependency with the "userrole" package. + UserRolesInverseTable = "sys_user_roles" + // UserRolesColumn is the table column denoting the user_roles relation/edge. + UserRolesColumn = "role_id" + // RolePermissionsTable is the table that holds the role_permissions relation/edge. + RolePermissionsTable = "sys_role_permissions" + // RolePermissionsInverseTable is the table name for the RolePermission entity. + // It exists in this package in order to avoid circular dependency with the "rolepermission" package. + RolePermissionsInverseTable = "sys_role_permissions" + // RolePermissionsColumn is the table column denoting the role_permissions relation/edge. + RolePermissionsColumn = "role_id" +) + +// Columns holds all SQL columns for role fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldKeyword, + FieldName, + FieldDescription, + FieldType, + FieldSequence, + FieldStatus, +} + +var ( + // UsersPrimaryKey and UsersColumn2 are the table columns denoting the + // primary key for the users relation (M2M). + UsersPrimaryKey = []string{"user_id", "role_id"} + // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the + // primary key for the permissions relation (M2M). + PermissionsPrimaryKey = []string{"role_id", "permission_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + KeywordValidator func(string) error + // DefaultName holds the default value on creation for the "name" field. + DefaultName string + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultDescription holds the default value on creation for the "description" field. + DefaultDescription string + // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + DescriptionValidator func(string) error + // DefaultType holds the default value on creation for the "type" field. + DefaultType int8 + // DefaultSequence holds the default value on creation for the "sequence" field. + DefaultSequence int + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int8 +) + +// OrderOption defines the ordering options for the Role queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByKeyword orders the results by the keyword field. +func ByKeyword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKeyword, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// BySequence orders the results by the sequence field. +func BySequence(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSequence, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByUsersCount orders the results by users count. +func ByUsersCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...) + } +} + +// ByUsers orders the results by users terms. +func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPermissionsCount orders the results by permissions count. +func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) + } +} + +// ByPermissions orders the results by permissions terms. +func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByUserRolesCount orders the results by user_roles count. +func ByUserRolesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserRolesStep(), opts...) + } +} + +// ByUserRoles orders the results by user_roles terms. +func ByUserRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserRolesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByRolePermissionsCount orders the results by role_permissions count. +func ByRolePermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRolePermissionsStep(), opts...) + } +} + +// ByRolePermissions orders the results by role_permissions terms. +func ByRolePermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRolePermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newUsersStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UsersInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), + ) +} +func newPermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), + ) +} +func newUserRolesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserRolesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), + ) +} +func newRolePermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RolePermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/features/system/data/ent/role/where.go b/internal/features/system/data/ent/role/where.go new file mode 100644 index 00000000..e037afe8 --- /dev/null +++ b/internal/features/system/data/ent/role/where.go @@ -0,0 +1,598 @@ +// Code generated by ent, DO NOT EDIT. + +package role + +import ( + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.Role { + return predicate.Role(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.Role { + return predicate.Role(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.Role { + return predicate.Role(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldUpdateTime, v)) +} + +// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. +func Keyword(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldKeyword, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldName, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldDescription, v)) +} + +// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. +func Type(v int8) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldType, v)) +} + +// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. +func Sequence(v int) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldSequence, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int8) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldStatus, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.Role { + return predicate.Role(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.Role { + return predicate.Role(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.Role { + return predicate.Role(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.Role { + return predicate.Role(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.Role { + return predicate.Role(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.Role { + return predicate.Role(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldUpdateTime, v)) +} + +// KeywordEQ applies the EQ predicate on the "keyword" field. +func KeywordEQ(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldKeyword, v)) +} + +// KeywordNEQ applies the NEQ predicate on the "keyword" field. +func KeywordNEQ(v string) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldKeyword, v)) +} + +// KeywordIn applies the In predicate on the "keyword" field. +func KeywordIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldIn(FieldKeyword, vs...)) +} + +// KeywordNotIn applies the NotIn predicate on the "keyword" field. +func KeywordNotIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldKeyword, vs...)) +} + +// KeywordGT applies the GT predicate on the "keyword" field. +func KeywordGT(v string) predicate.Role { + return predicate.Role(sql.FieldGT(FieldKeyword, v)) +} + +// KeywordGTE applies the GTE predicate on the "keyword" field. +func KeywordGTE(v string) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldKeyword, v)) +} + +// KeywordLT applies the LT predicate on the "keyword" field. +func KeywordLT(v string) predicate.Role { + return predicate.Role(sql.FieldLT(FieldKeyword, v)) +} + +// KeywordLTE applies the LTE predicate on the "keyword" field. +func KeywordLTE(v string) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldKeyword, v)) +} + +// KeywordContains applies the Contains predicate on the "keyword" field. +func KeywordContains(v string) predicate.Role { + return predicate.Role(sql.FieldContains(FieldKeyword, v)) +} + +// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. +func KeywordHasPrefix(v string) predicate.Role { + return predicate.Role(sql.FieldHasPrefix(FieldKeyword, v)) +} + +// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. +func KeywordHasSuffix(v string) predicate.Role { + return predicate.Role(sql.FieldHasSuffix(FieldKeyword, v)) +} + +// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. +func KeywordEqualFold(v string) predicate.Role { + return predicate.Role(sql.FieldEqualFold(FieldKeyword, v)) +} + +// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. +func KeywordContainsFold(v string) predicate.Role { + return predicate.Role(sql.FieldContainsFold(FieldKeyword, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Role { + return predicate.Role(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Role { + return predicate.Role(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Role { + return predicate.Role(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Role { + return predicate.Role(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Role { + return predicate.Role(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Role { + return predicate.Role(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Role { + return predicate.Role(sql.FieldContainsFold(FieldName, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Role { + return predicate.Role(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Role { + return predicate.Role(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Role { + return predicate.Role(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Role { + return predicate.Role(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Role { + return predicate.Role(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Role { + return predicate.Role(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Role { + return predicate.Role(sql.FieldContainsFold(FieldDescription, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v int8) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v int8) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...int8) predicate.Role { + return predicate.Role(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...int8) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldType, vs...)) +} + +// TypeGT applies the GT predicate on the "type" field. +func TypeGT(v int8) predicate.Role { + return predicate.Role(sql.FieldGT(FieldType, v)) +} + +// TypeGTE applies the GTE predicate on the "type" field. +func TypeGTE(v int8) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldType, v)) +} + +// TypeLT applies the LT predicate on the "type" field. +func TypeLT(v int8) predicate.Role { + return predicate.Role(sql.FieldLT(FieldType, v)) +} + +// TypeLTE applies the LTE predicate on the "type" field. +func TypeLTE(v int8) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldType, v)) +} + +// SequenceEQ applies the EQ predicate on the "sequence" field. +func SequenceEQ(v int) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldSequence, v)) +} + +// SequenceNEQ applies the NEQ predicate on the "sequence" field. +func SequenceNEQ(v int) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldSequence, v)) +} + +// SequenceIn applies the In predicate on the "sequence" field. +func SequenceIn(vs ...int) predicate.Role { + return predicate.Role(sql.FieldIn(FieldSequence, vs...)) +} + +// SequenceNotIn applies the NotIn predicate on the "sequence" field. +func SequenceNotIn(vs ...int) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldSequence, vs...)) +} + +// SequenceGT applies the GT predicate on the "sequence" field. +func SequenceGT(v int) predicate.Role { + return predicate.Role(sql.FieldGT(FieldSequence, v)) +} + +// SequenceGTE applies the GTE predicate on the "sequence" field. +func SequenceGTE(v int) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldSequence, v)) +} + +// SequenceLT applies the LT predicate on the "sequence" field. +func SequenceLT(v int) predicate.Role { + return predicate.Role(sql.FieldLT(FieldSequence, v)) +} + +// SequenceLTE applies the LTE predicate on the "sequence" field. +func SequenceLTE(v int) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldSequence, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int8) predicate.Role { + return predicate.Role(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int8) predicate.Role { + return predicate.Role(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int8) predicate.Role { + return predicate.Role(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int8) predicate.Role { + return predicate.Role(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int8) predicate.Role { + return predicate.Role(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int8) predicate.Role { + return predicate.Role(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int8) predicate.Role { + return predicate.Role(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int8) predicate.Role { + return predicate.Role(sql.FieldLTE(FieldStatus, v)) +} + +// HasUsers applies the HasEdge predicate on the "users" edge. +func HasUsers() predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUsersWith applies the HasEdge predicate on the "users" edge with a given conditions (other predicates). +func HasUsersWith(preds ...predicate.User) predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := newUsersStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermissions applies the HasEdge predicate on the "permissions" edge. +func HasPermissions() predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). +func HasPermissionsWith(preds ...predicate.Permission) predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := newPermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasUserRoles applies the HasEdge predicate on the "user_roles" edge. +func HasUserRoles() predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserRolesWith applies the HasEdge predicate on the "user_roles" edge with a given conditions (other predicates). +func HasUserRolesWith(preds ...predicate.UserRole) predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := newUserRolesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasRolePermissions applies the HasEdge predicate on the "role_permissions" edge. +func HasRolePermissions() predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRolePermissionsWith applies the HasEdge predicate on the "role_permissions" edge with a given conditions (other predicates). +func HasRolePermissionsWith(preds ...predicate.RolePermission) predicate.Role { + return predicate.Role(func(s *sql.Selector) { + step := newRolePermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Role) predicate.Role { + return predicate.Role(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.Role) predicate.Role { + return predicate.Role(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.Role) predicate.Role { + return predicate.Role(sql.NotPredicates(p)) +} diff --git a/internal/features/system/data/ent/role_create.go b/internal/features/system/data/ent/role_create.go new file mode 100644 index 00000000..9a6a9336 --- /dev/null +++ b/internal/features/system/data/ent/role_create.go @@ -0,0 +1,540 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// RoleCreate is the builder for creating a Role entity. +type RoleCreate struct { + config + mutation *RoleMutation + hooks []Hook +} + +// SetCreateTime sets the "create_time" field. +func (_c *RoleCreate) SetCreateTime(v time.Time) *RoleCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *RoleCreate) SetNillableCreateTime(v *time.Time) *RoleCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *RoleCreate) SetUpdateTime(v time.Time) *RoleCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *RoleCreate) SetNillableUpdateTime(v *time.Time) *RoleCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetKeyword sets the "keyword" field. +func (_c *RoleCreate) SetKeyword(v string) *RoleCreate { + _c.mutation.SetKeyword(v) + return _c +} + +// SetName sets the "name" field. +func (_c *RoleCreate) SetName(v string) *RoleCreate { + _c.mutation.SetName(v) + return _c +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_c *RoleCreate) SetNillableName(v *string) *RoleCreate { + if v != nil { + _c.SetName(*v) + } + return _c +} + +// SetDescription sets the "description" field. +func (_c *RoleCreate) SetDescription(v string) *RoleCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *RoleCreate) SetNillableDescription(v *string) *RoleCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetType sets the "type" field. +func (_c *RoleCreate) SetType(v int8) *RoleCreate { + _c.mutation.SetType(v) + return _c +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_c *RoleCreate) SetNillableType(v *int8) *RoleCreate { + if v != nil { + _c.SetType(*v) + } + return _c +} + +// SetSequence sets the "sequence" field. +func (_c *RoleCreate) SetSequence(v int) *RoleCreate { + _c.mutation.SetSequence(v) + return _c +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_c *RoleCreate) SetNillableSequence(v *int) *RoleCreate { + if v != nil { + _c.SetSequence(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *RoleCreate) SetStatus(v int8) *RoleCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *RoleCreate) SetNillableStatus(v *int8) *RoleCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *RoleCreate) SetID(v int64) *RoleCreate { + _c.mutation.SetID(v) + return _c +} + +// AddUserIDs adds the "users" edge to the User entity by IDs. +func (_c *RoleCreate) AddUserIDs(ids ...int64) *RoleCreate { + _c.mutation.AddUserIDs(ids...) + return _c +} + +// AddUsers adds the "users" edges to the User entity. +func (_c *RoleCreate) AddUsers(v ...*User) *RoleCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddUserIDs(ids...) +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. +func (_c *RoleCreate) AddPermissionIDs(ids ...int64) *RoleCreate { + _c.mutation.AddPermissionIDs(ids...) + return _c +} + +// AddPermissions adds the "permissions" edges to the Permission entity. +func (_c *RoleCreate) AddPermissions(v ...*Permission) *RoleCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddPermissionIDs(ids...) +} + +// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. +func (_c *RoleCreate) AddUserRoleIDs(ids ...int) *RoleCreate { + _c.mutation.AddUserRoleIDs(ids...) + return _c +} + +// AddUserRoles adds the "user_roles" edges to the UserRole entity. +func (_c *RoleCreate) AddUserRoles(v ...*UserRole) *RoleCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddUserRoleIDs(ids...) +} + +// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. +func (_c *RoleCreate) AddRolePermissionIDs(ids ...int) *RoleCreate { + _c.mutation.AddRolePermissionIDs(ids...) + return _c +} + +// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. +func (_c *RoleCreate) AddRolePermissions(v ...*RolePermission) *RoleCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddRolePermissionIDs(ids...) +} + +// Mutation returns the RoleMutation object of the builder. +func (_c *RoleCreate) Mutation() *RoleMutation { + return _c.mutation +} + +// Save creates the Role in the database. +func (_c *RoleCreate) Save(ctx context.Context) (*Role, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *RoleCreate) SaveX(ctx context.Context) *Role { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *RoleCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *RoleCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *RoleCreate) defaults() { + if _, ok := _c.mutation.CreateTime(); !ok { + v := role.DefaultCreateTime() + _c.mutation.SetCreateTime(v) + } + if _, ok := _c.mutation.UpdateTime(); !ok { + v := role.DefaultUpdateTime() + _c.mutation.SetUpdateTime(v) + } + if _, ok := _c.mutation.Name(); !ok { + v := role.DefaultName + _c.mutation.SetName(v) + } + if _, ok := _c.mutation.Description(); !ok { + v := role.DefaultDescription + _c.mutation.SetDescription(v) + } + if _, ok := _c.mutation.GetType(); !ok { + v := role.DefaultType + _c.mutation.SetType(v) + } + if _, ok := _c.mutation.Sequence(); !ok { + v := role.DefaultSequence + _c.mutation.SetSequence(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := role.DefaultStatus + _c.mutation.SetStatus(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *RoleCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Role.create_time"`)} + } + if _, ok := _c.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Role.update_time"`)} + } + if _, ok := _c.mutation.Keyword(); !ok { + return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Role.keyword"`)} + } + if v, ok := _c.mutation.Keyword(); ok { + if err := role.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Role.keyword": %w`, err)} + } + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Role.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := role.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Role.name": %w`, err)} + } + } + if _, ok := _c.mutation.Description(); !ok { + return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Role.description"`)} + } + if v, ok := _c.mutation.Description(); ok { + if err := role.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Role.description": %w`, err)} + } + } + if _, ok := _c.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Role.type"`)} + } + if _, ok := _c.mutation.Sequence(); !ok { + return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "Role.sequence"`)} + } + if _, ok := _c.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Role.status"`)} + } + return nil +} + +func (_c *RoleCreate) sqlSave(ctx context.Context) (*Role, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *RoleCreate) createSpec() (*Role, *sqlgraph.CreateSpec) { + var ( + _node = &Role{config: _c.config} + _spec = sqlgraph.NewCreateSpec(role.Table, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(role.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(role.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if value, ok := _c.mutation.Keyword(); ok { + _spec.SetField(role.FieldKeyword, field.TypeString, value) + _node.Keyword = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(role.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(role.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := _c.mutation.GetType(); ok { + _spec.SetField(role.FieldType, field.TypeInt8, value) + _node.Type = value + } + if value, ok := _c.mutation.Sequence(); ok { + _spec.SetField(role.FieldSequence, field.TypeInt, value) + _node.Sequence = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(role.FieldStatus, field.TypeInt8, value) + _node.Status = value + } + if nodes := _c.mutation.UsersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: role.UsersTable, + Columns: role.UsersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: role.PermissionsTable, + Columns: role.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.UserRolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.UserRolesTable, + Columns: []string{role.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.RolePermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.RolePermissionsTable, + Columns: []string{role.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SetRole set the Role +func (_c *RoleCreate) SetRole(input *Role, fields ...string) *RoleCreate { + m := _c.mutation + if len(fields) == 0 { + fields = role.Columns + } + _ = m.SetFields(input, fields...) + return _c +} + +// SetRoleWithZero set the Role +func (_c *RoleCreate) SetRoleWithZero(input *Role, fields ...string) *RoleCreate { + m := _c.mutation + if len(fields) == 0 { + fields = role.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return _c +} + +// RoleCreateBulk is the builder for creating many Role entities in bulk. +type RoleCreateBulk struct { + config + err error + builders []*RoleCreate +} + +// Save creates the Role entities in the database. +func (_c *RoleCreateBulk) Save(ctx context.Context) ([]*Role, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Role, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*RoleMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *RoleCreateBulk) SaveX(ctx context.Context) []*Role { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *RoleCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *RoleCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/role_delete.go b/internal/features/system/data/ent/role_delete.go new file mode 100644 index 00000000..81c933a9 --- /dev/null +++ b/internal/features/system/data/ent/role_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/role" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// RoleDelete is the builder for deleting a Role entity. +type RoleDelete struct { + config + hooks []Hook + mutation *RoleMutation +} + +// Where appends a list predicates to the RoleDelete builder. +func (_d *RoleDelete) Where(ps ...predicate.Role) *RoleDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *RoleDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *RoleDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *RoleDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(role.Table, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// RoleDeleteOne is the builder for deleting a single Role entity. +type RoleDeleteOne struct { + _d *RoleDelete +} + +// Where appends a list predicates to the RoleDelete builder. +func (_d *RoleDeleteOne) Where(ps ...predicate.Role) *RoleDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *RoleDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{role.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *RoleDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/role_query.go b/internal/features/system/data/ent/role_query.go new file mode 100644 index 00000000..4cfb77b6 --- /dev/null +++ b/internal/features/system/data/ent/role_query.go @@ -0,0 +1,984 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// RoleQuery is the builder for querying Role entities. +type RoleQuery struct { + config + ctx *QueryContext + order []role.OrderOption + inters []Interceptor + predicates []predicate.Role + withUsers *UserQuery + withPermissions *PermissionQuery + withUserRoles *UserRoleQuery + withRolePermissions *RolePermissionQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the RoleQuery builder. +func (_q *RoleQuery) Where(ps ...predicate.Role) *RoleQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *RoleQuery) Limit(limit int) *RoleQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *RoleQuery) Offset(offset int) *RoleQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *RoleQuery) Unique(unique bool) *RoleQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *RoleQuery) Order(o ...role.OrderOption) *RoleQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryUsers chains the current query on the "users" edge. +func (_q *RoleQuery) QueryUsers() *UserQuery { + query := (&UserClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(role.Table, role.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, role.UsersTable, role.UsersPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryPermissions chains the current query on the "permissions" edge. +func (_q *RoleQuery) QueryPermissions() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(role.Table, role.FieldID, selector), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, role.PermissionsTable, role.PermissionsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryUserRoles chains the current query on the "user_roles" edge. +func (_q *RoleQuery) QueryUserRoles() *UserRoleQuery { + query := (&UserRoleClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(role.Table, role.FieldID, selector), + sqlgraph.To(userrole.Table, userrole.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, role.UserRolesTable, role.UserRolesColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryRolePermissions chains the current query on the "role_permissions" edge. +func (_q *RoleQuery) QueryRolePermissions() *RolePermissionQuery { + query := (&RolePermissionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(role.Table, role.FieldID, selector), + sqlgraph.To(rolepermission.Table, rolepermission.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, role.RolePermissionsTable, role.RolePermissionsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first Role entity from the query. +// Returns a *NotFoundError when no Role was found. +func (_q *RoleQuery) First(ctx context.Context) (*Role, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{role.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *RoleQuery) FirstX(ctx context.Context) *Role { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Role ID from the query. +// Returns a *NotFoundError when no Role ID was found. +func (_q *RoleQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{role.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *RoleQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Role entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Role entity is found. +// Returns a *NotFoundError when no Role entities are found. +func (_q *RoleQuery) Only(ctx context.Context) (*Role, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{role.Label} + default: + return nil, &NotSingularError{role.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *RoleQuery) OnlyX(ctx context.Context) *Role { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Role ID in the query. +// Returns a *NotSingularError when more than one Role ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *RoleQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{role.Label} + default: + err = &NotSingularError{role.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *RoleQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Roles. +func (_q *RoleQuery) All(ctx context.Context) ([]*Role, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*Role, *RoleQuery]() + return withInterceptors[[]*Role](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *RoleQuery) AllX(ctx context.Context) []*Role { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Role IDs. +func (_q *RoleQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(role.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *RoleQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *RoleQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*RoleQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *RoleQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *RoleQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *RoleQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the RoleQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *RoleQuery) Clone() *RoleQuery { + if _q == nil { + return nil + } + return &RoleQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]role.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Role{}, _q.predicates...), + withUsers: _q.withUsers.Clone(), + withPermissions: _q.withPermissions.Clone(), + withUserRoles: _q.withUserRoles.Clone(), + withRolePermissions: _q.withRolePermissions.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithUsers tells the query-builder to eager-load the nodes that are connected to +// the "users" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *RoleQuery) WithUsers(opts ...func(*UserQuery)) *RoleQuery { + query := (&UserClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withUsers = query + return _q +} + +// WithPermissions tells the query-builder to eager-load the nodes that are connected to +// the "permissions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *RoleQuery) WithPermissions(opts ...func(*PermissionQuery)) *RoleQuery { + query := (&PermissionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withPermissions = query + return _q +} + +// WithUserRoles tells the query-builder to eager-load the nodes that are connected to +// the "user_roles" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *RoleQuery) WithUserRoles(opts ...func(*UserRoleQuery)) *RoleQuery { + query := (&UserRoleClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withUserRoles = query + return _q +} + +// WithRolePermissions tells the query-builder to eager-load the nodes that are connected to +// the "role_permissions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *RoleQuery) WithRolePermissions(opts ...func(*RolePermissionQuery)) *RoleQuery { + query := (&RolePermissionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRolePermissions = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Role.Query(). +// GroupBy(role.FieldCreateTime). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *RoleQuery) GroupBy(field string, fields ...string) *RoleGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &RoleGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = role.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// } +// +// client.Role.Query(). +// Select(role.FieldCreateTime). +// Scan(ctx, &v) +func (_q *RoleQuery) Select(fields ...string) *RoleSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &RoleSelect{RoleQuery: _q} + sbuild.label = role.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a RoleSelect configured with the given aggregations. +func (_q *RoleQuery) Aggregate(fns ...AggregateFunc) *RoleSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *RoleQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !role.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *RoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Role, error) { + var ( + nodes = []*Role{} + _spec = _q.querySpec() + loadedTypes = [4]bool{ + _q.withUsers != nil, + _q.withPermissions != nil, + _q.withUserRoles != nil, + _q.withRolePermissions != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*Role).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &Role{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withUsers; query != nil { + if err := _q.loadUsers(ctx, query, nodes, + func(n *Role) { n.Edges.Users = []*User{} }, + func(n *Role, e *User) { n.Edges.Users = append(n.Edges.Users, e) }); err != nil { + return nil, err + } + } + if query := _q.withPermissions; query != nil { + if err := _q.loadPermissions(ctx, query, nodes, + func(n *Role) { n.Edges.Permissions = []*Permission{} }, + func(n *Role, e *Permission) { n.Edges.Permissions = append(n.Edges.Permissions, e) }); err != nil { + return nil, err + } + } + if query := _q.withUserRoles; query != nil { + if err := _q.loadUserRoles(ctx, query, nodes, + func(n *Role) { n.Edges.UserRoles = []*UserRole{} }, + func(n *Role, e *UserRole) { n.Edges.UserRoles = append(n.Edges.UserRoles, e) }); err != nil { + return nil, err + } + } + if query := _q.withRolePermissions; query != nil { + if err := _q.loadRolePermissions(ctx, query, nodes, + func(n *Role) { n.Edges.RolePermissions = []*RolePermission{} }, + func(n *Role, e *RolePermission) { n.Edges.RolePermissions = append(n.Edges.RolePermissions, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *RoleQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*Role, init func(*Role), assign func(*Role, *User)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int64]*Role) + nids := make(map[int64]map[*Role]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(role.UsersTable) + s.Join(joinT).On(s.C(user.FieldID), joinT.C(role.UsersPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(role.UsersPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(role.UsersPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullInt64).Int64 + inValue := values[1].(*sql.NullInt64).Int64 + if nids[inValue] == nil { + nids[inValue] = map[*Role]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*User](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "users" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (_q *RoleQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*Role, init func(*Role), assign func(*Role, *Permission)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int64]*Role) + nids := make(map[int64]map[*Role]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(role.PermissionsTable) + s.Join(joinT).On(s.C(permission.FieldID), joinT.C(role.PermissionsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(role.PermissionsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(role.PermissionsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullInt64).Int64 + inValue := values[1].(*sql.NullInt64).Int64 + if nids[inValue] == nil { + nids[inValue] = map[*Role]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Permission](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "permissions" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (_q *RoleQuery) loadUserRoles(ctx context.Context, query *UserRoleQuery, nodes []*Role, init func(*Role), assign func(*Role, *UserRole)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*Role) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(userrole.FieldRoleID) + } + query.Where(predicate.UserRole(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(role.UserRolesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.RoleID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "role_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *RoleQuery) loadRolePermissions(ctx context.Context, query *RolePermissionQuery, nodes []*Role, init func(*Role), assign func(*Role, *RolePermission)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*Role) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(rolepermission.FieldRoleID) + } + query.Where(predicate.RolePermission(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(role.RolePermissionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.RoleID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "role_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *RoleQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *RoleQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, role.FieldID) + for i := range fields { + if fields[i] != role.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *RoleQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(role.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = role.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *RoleQuery) ForUpdate(opts ...sql.LockOption) *RoleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *RoleQuery) ForShare(opts ...sql.LockOption) *RoleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *RoleQuery) Modify(modifiers ...func(s *sql.Selector)) *RoleSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// UpdateTime time.Time `json:"update_time,omitempty"` +// Keyword string `json:"keyword,omitempty"` +// Name string `json:"name,omitempty"` +// Description string `json:"description,omitempty"` +// Type int8 `json:"type,omitempty"` +// Sequence int `json:"sequence,omitempty"` +// Status int8 `json:"status,omitempty"` +// } +// +// client.Role.Query(). +// Omit( +// role.FieldCreateTime, +// role.FieldUpdateTime, +// role.FieldKeyword, +// role.FieldName, +// role.FieldDescription, +// role.FieldType, +// role.FieldSequence, +// role.FieldStatus, +// ). +// Scan(ctx, &v) +func (rq *RoleQuery) Omit(fields ...string) *RoleSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range role.Columns { + if _, ok := omits[col]; !ok { + rq.ctx.Fields = append(rq.ctx.Fields, col) + } + } + + sbuild := &RoleSelect{RoleQuery: rq} + sbuild.label = role.Label + sbuild.flds, sbuild.scan = &rq.ctx.Fields, sbuild.Scan + return sbuild +} + +// RoleGroupBy is the group-by builder for Role entities. +type RoleGroupBy struct { + selector + build *RoleQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *RoleGroupBy) Aggregate(fns ...AggregateFunc) *RoleGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *RoleGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*RoleQuery, *RoleGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *RoleGroupBy) sqlScan(ctx context.Context, root *RoleQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// RoleSelect is the builder for selecting fields of Role entities. +type RoleSelect struct { + *RoleQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *RoleSelect) Aggregate(fns ...AggregateFunc) *RoleSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *RoleSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*RoleQuery, *RoleSelect](ctx, _s.RoleQuery, _s, _s.inters, v) +} + +func (_s *RoleSelect) sqlScan(ctx context.Context, root *RoleQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *RoleSelect) Modify(modifiers ...func(s *sql.Selector)) *RoleSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/internal/features/system/data/ent/role_update.go b/internal/features/system/data/ent/role_update.go new file mode 100644 index 00000000..c16827d1 --- /dev/null +++ b/internal/features/system/data/ent/role_update.go @@ -0,0 +1,1246 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// RoleUpdate is the builder for updating Role entities. +type RoleUpdate struct { + config + hooks []Hook + mutation *RoleMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the RoleUpdate builder. +func (_u *RoleUpdate) Where(ps ...predicate.Role) *RoleUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *RoleUpdate) SetUpdateTime(v time.Time) *RoleUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetKeyword sets the "keyword" field. +func (_u *RoleUpdate) SetKeyword(v string) *RoleUpdate { + _u.mutation.SetKeyword(v) + return _u +} + +// SetNillableKeyword sets the "keyword" field if the given value is not nil. +func (_u *RoleUpdate) SetNillableKeyword(v *string) *RoleUpdate { + if v != nil { + _u.SetKeyword(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *RoleUpdate) SetName(v string) *RoleUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *RoleUpdate) SetNillableName(v *string) *RoleUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *RoleUpdate) SetDescription(v string) *RoleUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *RoleUpdate) SetNillableDescription(v *string) *RoleUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// SetType sets the "type" field. +func (_u *RoleUpdate) SetType(v int8) *RoleUpdate { + _u.mutation.ResetType() + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *RoleUpdate) SetNillableType(v *int8) *RoleUpdate { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// AddType adds value to the "type" field. +func (_u *RoleUpdate) AddType(v int8) *RoleUpdate { + _u.mutation.AddType(v) + return _u +} + +// SetSequence sets the "sequence" field. +func (_u *RoleUpdate) SetSequence(v int) *RoleUpdate { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_u *RoleUpdate) SetNillableSequence(v *int) *RoleUpdate { + if v != nil { + _u.SetSequence(*v) + } + return _u +} + +// AddSequence adds value to the "sequence" field. +func (_u *RoleUpdate) AddSequence(v int) *RoleUpdate { + _u.mutation.AddSequence(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *RoleUpdate) SetStatus(v int8) *RoleUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *RoleUpdate) SetNillableStatus(v *int8) *RoleUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *RoleUpdate) AddStatus(v int8) *RoleUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// AddUserIDs adds the "users" edge to the User entity by IDs. +func (_u *RoleUpdate) AddUserIDs(ids ...int64) *RoleUpdate { + _u.mutation.AddUserIDs(ids...) + return _u +} + +// AddUsers adds the "users" edges to the User entity. +func (_u *RoleUpdate) AddUsers(v ...*User) *RoleUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddUserIDs(ids...) +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. +func (_u *RoleUpdate) AddPermissionIDs(ids ...int64) *RoleUpdate { + _u.mutation.AddPermissionIDs(ids...) + return _u +} + +// AddPermissions adds the "permissions" edges to the Permission entity. +func (_u *RoleUpdate) AddPermissions(v ...*Permission) *RoleUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPermissionIDs(ids...) +} + +// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. +func (_u *RoleUpdate) AddUserRoleIDs(ids ...int) *RoleUpdate { + _u.mutation.AddUserRoleIDs(ids...) + return _u +} + +// AddUserRoles adds the "user_roles" edges to the UserRole entity. +func (_u *RoleUpdate) AddUserRoles(v ...*UserRole) *RoleUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddUserRoleIDs(ids...) +} + +// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. +func (_u *RoleUpdate) AddRolePermissionIDs(ids ...int) *RoleUpdate { + _u.mutation.AddRolePermissionIDs(ids...) + return _u +} + +// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. +func (_u *RoleUpdate) AddRolePermissions(v ...*RolePermission) *RoleUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRolePermissionIDs(ids...) +} + +// Mutation returns the RoleMutation object of the builder. +func (_u *RoleUpdate) Mutation() *RoleMutation { + return _u.mutation +} + +// ClearUsers clears all "users" edges to the User entity. +func (_u *RoleUpdate) ClearUsers() *RoleUpdate { + _u.mutation.ClearUsers() + return _u +} + +// RemoveUserIDs removes the "users" edge to User entities by IDs. +func (_u *RoleUpdate) RemoveUserIDs(ids ...int64) *RoleUpdate { + _u.mutation.RemoveUserIDs(ids...) + return _u +} + +// RemoveUsers removes "users" edges to User entities. +func (_u *RoleUpdate) RemoveUsers(v ...*User) *RoleUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveUserIDs(ids...) +} + +// ClearPermissions clears all "permissions" edges to the Permission entity. +func (_u *RoleUpdate) ClearPermissions() *RoleUpdate { + _u.mutation.ClearPermissions() + return _u +} + +// RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. +func (_u *RoleUpdate) RemovePermissionIDs(ids ...int64) *RoleUpdate { + _u.mutation.RemovePermissionIDs(ids...) + return _u +} + +// RemovePermissions removes "permissions" edges to Permission entities. +func (_u *RoleUpdate) RemovePermissions(v ...*Permission) *RoleUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePermissionIDs(ids...) +} + +// ClearUserRoles clears all "user_roles" edges to the UserRole entity. +func (_u *RoleUpdate) ClearUserRoles() *RoleUpdate { + _u.mutation.ClearUserRoles() + return _u +} + +// RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. +func (_u *RoleUpdate) RemoveUserRoleIDs(ids ...int) *RoleUpdate { + _u.mutation.RemoveUserRoleIDs(ids...) + return _u +} + +// RemoveUserRoles removes "user_roles" edges to UserRole entities. +func (_u *RoleUpdate) RemoveUserRoles(v ...*UserRole) *RoleUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveUserRoleIDs(ids...) +} + +// ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. +func (_u *RoleUpdate) ClearRolePermissions() *RoleUpdate { + _u.mutation.ClearRolePermissions() + return _u +} + +// RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. +func (_u *RoleUpdate) RemoveRolePermissionIDs(ids ...int) *RoleUpdate { + _u.mutation.RemoveRolePermissionIDs(ids...) + return _u +} + +// RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. +func (_u *RoleUpdate) RemoveRolePermissions(v ...*RolePermission) *RoleUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRolePermissionIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *RoleUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *RoleUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *RoleUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *RoleUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *RoleUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := role.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *RoleUpdate) check() error { + if v, ok := _u.mutation.Keyword(); ok { + if err := role.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Role.keyword": %w`, err)} + } + } + if v, ok := _u.mutation.Name(); ok { + if err := role.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Role.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := role.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Role.description": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *RoleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoleUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *RoleUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(role.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.Keyword(); ok { + _spec.SetField(role.FieldKeyword, field.TypeString, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(role.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(role.FieldDescription, field.TypeString, value) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(role.FieldType, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedType(); ok { + _spec.AddField(role.FieldType, field.TypeInt8, value) + } + if value, ok := _u.mutation.Sequence(); ok { + _spec.SetField(role.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSequence(); ok { + _spec.AddField(role.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(role.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(role.FieldStatus, field.TypeInt8, value) + } + if _u.mutation.UsersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: role.UsersTable, + Columns: role.UsersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedUsersIDs(); len(nodes) > 0 && !_u.mutation.UsersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: role.UsersTable, + Columns: role.UsersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.UsersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: role.UsersTable, + Columns: role.UsersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: role.PermissionsTable, + Columns: role.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: role.PermissionsTable, + Columns: role.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: role.PermissionsTable, + Columns: role.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.UserRolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.UserRolesTable, + Columns: []string{role.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.UserRolesTable, + Columns: []string{role.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.UserRolesTable, + Columns: []string{role.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.RolePermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.RolePermissionsTable, + Columns: []string{role.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.RolePermissionsTable, + Columns: []string{role.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.RolePermissionsTable, + Columns: []string{role.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{role.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// RoleUpdateOne is the builder for updating a single Role entity. +type RoleUpdateOne struct { + config + fields []string + hooks []Hook + mutation *RoleMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdateTime sets the "update_time" field. +func (_u *RoleUpdateOne) SetUpdateTime(v time.Time) *RoleUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetKeyword sets the "keyword" field. +func (_u *RoleUpdateOne) SetKeyword(v string) *RoleUpdateOne { + _u.mutation.SetKeyword(v) + return _u +} + +// SetNillableKeyword sets the "keyword" field if the given value is not nil. +func (_u *RoleUpdateOne) SetNillableKeyword(v *string) *RoleUpdateOne { + if v != nil { + _u.SetKeyword(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *RoleUpdateOne) SetName(v string) *RoleUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *RoleUpdateOne) SetNillableName(v *string) *RoleUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetDescription sets the "description" field. +func (_u *RoleUpdateOne) SetDescription(v string) *RoleUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *RoleUpdateOne) SetNillableDescription(v *string) *RoleUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// SetType sets the "type" field. +func (_u *RoleUpdateOne) SetType(v int8) *RoleUpdateOne { + _u.mutation.ResetType() + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *RoleUpdateOne) SetNillableType(v *int8) *RoleUpdateOne { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// AddType adds value to the "type" field. +func (_u *RoleUpdateOne) AddType(v int8) *RoleUpdateOne { + _u.mutation.AddType(v) + return _u +} + +// SetSequence sets the "sequence" field. +func (_u *RoleUpdateOne) SetSequence(v int) *RoleUpdateOne { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_u *RoleUpdateOne) SetNillableSequence(v *int) *RoleUpdateOne { + if v != nil { + _u.SetSequence(*v) + } + return _u +} + +// AddSequence adds value to the "sequence" field. +func (_u *RoleUpdateOne) AddSequence(v int) *RoleUpdateOne { + _u.mutation.AddSequence(v) + return _u +} + +// SetStatus sets the "status" field. +func (_u *RoleUpdateOne) SetStatus(v int8) *RoleUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *RoleUpdateOne) SetNillableStatus(v *int8) *RoleUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *RoleUpdateOne) AddStatus(v int8) *RoleUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// AddUserIDs adds the "users" edge to the User entity by IDs. +func (_u *RoleUpdateOne) AddUserIDs(ids ...int64) *RoleUpdateOne { + _u.mutation.AddUserIDs(ids...) + return _u +} + +// AddUsers adds the "users" edges to the User entity. +func (_u *RoleUpdateOne) AddUsers(v ...*User) *RoleUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddUserIDs(ids...) +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. +func (_u *RoleUpdateOne) AddPermissionIDs(ids ...int64) *RoleUpdateOne { + _u.mutation.AddPermissionIDs(ids...) + return _u +} + +// AddPermissions adds the "permissions" edges to the Permission entity. +func (_u *RoleUpdateOne) AddPermissions(v ...*Permission) *RoleUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPermissionIDs(ids...) +} + +// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. +func (_u *RoleUpdateOne) AddUserRoleIDs(ids ...int) *RoleUpdateOne { + _u.mutation.AddUserRoleIDs(ids...) + return _u +} + +// AddUserRoles adds the "user_roles" edges to the UserRole entity. +func (_u *RoleUpdateOne) AddUserRoles(v ...*UserRole) *RoleUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddUserRoleIDs(ids...) +} + +// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. +func (_u *RoleUpdateOne) AddRolePermissionIDs(ids ...int) *RoleUpdateOne { + _u.mutation.AddRolePermissionIDs(ids...) + return _u +} + +// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. +func (_u *RoleUpdateOne) AddRolePermissions(v ...*RolePermission) *RoleUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRolePermissionIDs(ids...) +} + +// Mutation returns the RoleMutation object of the builder. +func (_u *RoleUpdateOne) Mutation() *RoleMutation { + return _u.mutation +} + +// ClearUsers clears all "users" edges to the User entity. +func (_u *RoleUpdateOne) ClearUsers() *RoleUpdateOne { + _u.mutation.ClearUsers() + return _u +} + +// RemoveUserIDs removes the "users" edge to User entities by IDs. +func (_u *RoleUpdateOne) RemoveUserIDs(ids ...int64) *RoleUpdateOne { + _u.mutation.RemoveUserIDs(ids...) + return _u +} + +// RemoveUsers removes "users" edges to User entities. +func (_u *RoleUpdateOne) RemoveUsers(v ...*User) *RoleUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveUserIDs(ids...) +} + +// ClearPermissions clears all "permissions" edges to the Permission entity. +func (_u *RoleUpdateOne) ClearPermissions() *RoleUpdateOne { + _u.mutation.ClearPermissions() + return _u +} + +// RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. +func (_u *RoleUpdateOne) RemovePermissionIDs(ids ...int64) *RoleUpdateOne { + _u.mutation.RemovePermissionIDs(ids...) + return _u +} + +// RemovePermissions removes "permissions" edges to Permission entities. +func (_u *RoleUpdateOne) RemovePermissions(v ...*Permission) *RoleUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePermissionIDs(ids...) +} + +// ClearUserRoles clears all "user_roles" edges to the UserRole entity. +func (_u *RoleUpdateOne) ClearUserRoles() *RoleUpdateOne { + _u.mutation.ClearUserRoles() + return _u +} + +// RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. +func (_u *RoleUpdateOne) RemoveUserRoleIDs(ids ...int) *RoleUpdateOne { + _u.mutation.RemoveUserRoleIDs(ids...) + return _u +} + +// RemoveUserRoles removes "user_roles" edges to UserRole entities. +func (_u *RoleUpdateOne) RemoveUserRoles(v ...*UserRole) *RoleUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveUserRoleIDs(ids...) +} + +// ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. +func (_u *RoleUpdateOne) ClearRolePermissions() *RoleUpdateOne { + _u.mutation.ClearRolePermissions() + return _u +} + +// RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. +func (_u *RoleUpdateOne) RemoveRolePermissionIDs(ids ...int) *RoleUpdateOne { + _u.mutation.RemoveRolePermissionIDs(ids...) + return _u +} + +// RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. +func (_u *RoleUpdateOne) RemoveRolePermissions(v ...*RolePermission) *RoleUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRolePermissionIDs(ids...) +} + +// Where appends a list predicates to the RoleUpdate builder. +func (_u *RoleUpdateOne) Where(ps ...predicate.Role) *RoleUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *RoleUpdateOne) Select(field string, fields ...string) *RoleUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated Role entity. +func (_u *RoleUpdateOne) Save(ctx context.Context) (*Role, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *RoleUpdateOne) SaveX(ctx context.Context) *Role { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *RoleUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *RoleUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *RoleUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := role.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *RoleUpdateOne) check() error { + if v, ok := _u.mutation.Keyword(); ok { + if err := role.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Role.keyword": %w`, err)} + } + } + if v, ok := _u.mutation.Name(); ok { + if err := role.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Role.name": %w`, err)} + } + } + if v, ok := _u.mutation.Description(); ok { + if err := role.DescriptionValidator(v); err != nil { + return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Role.description": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *RoleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoleUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Role.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, role.FieldID) + for _, f := range fields { + if !role.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != role.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(role.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.Keyword(); ok { + _spec.SetField(role.FieldKeyword, field.TypeString, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(role.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(role.FieldDescription, field.TypeString, value) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(role.FieldType, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedType(); ok { + _spec.AddField(role.FieldType, field.TypeInt8, value) + } + if value, ok := _u.mutation.Sequence(); ok { + _spec.SetField(role.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSequence(); ok { + _spec.AddField(role.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(role.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(role.FieldStatus, field.TypeInt8, value) + } + if _u.mutation.UsersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: role.UsersTable, + Columns: role.UsersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedUsersIDs(); len(nodes) > 0 && !_u.mutation.UsersCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: role.UsersTable, + Columns: role.UsersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.UsersIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: role.UsersTable, + Columns: role.UsersPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: role.PermissionsTable, + Columns: role.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: role.PermissionsTable, + Columns: role.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: role.PermissionsTable, + Columns: role.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.UserRolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.UserRolesTable, + Columns: []string{role.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.UserRolesTable, + Columns: []string{role.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.UserRolesTable, + Columns: []string{role.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.RolePermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.RolePermissionsTable, + Columns: []string{role.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.RolePermissionsTable, + Columns: []string{role.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: role.RolePermissionsTable, + Columns: []string{role.RolePermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &Role{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{role.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} + +// SetRole set the Role +func (ru *RoleUpdate) SetRole(input *Role, fields ...string) *RoleUpdate { + m := ru.mutation + if len(fields) == 0 { + fields = role.OmitColumns(role.FieldID) + } + _ = m.SetFields(input, fields...) + return ru +} + +// SetRoleWithZero set the Role +func (ru *RoleUpdate) SetRoleWithZero(input *Role, fields ...string) *RoleUpdate { + m := ru.mutation + if len(fields) == 0 { + fields = role.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return ru +} + +// SetRole set the Role +func (ruo *RoleUpdateOne) SetRole(input *Role, fields ...string) *RoleUpdateOne { + m := ruo.mutation + if len(fields) == 0 { + fields = role.OmitColumns(role.FieldID) + } + _ = m.SetFields(input, fields...) + return ruo +} + +// SetRoleWithZero set the Role +func (ruo *RoleUpdateOne) SetRoleWithZero(input *Role, fields ...string) *RoleUpdateOne { + m := ruo.mutation + if len(fields) == 0 { + fields = role.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return ruo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (ruo *RoleUpdateOne) Omit(fields ...string) *RoleUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + ruo.fields = []string(nil) + for _, col := range role.Columns { + if _, ok := omits[col]; !ok { + ruo.fields = append(ruo.fields, col) + } + } + return ruo +} diff --git a/internal/features/system/data/ent/rolepermission.go b/internal/features/system/data/ent/rolepermission.go new file mode 100644 index 00000000..ba3116f2 --- /dev/null +++ b/internal/features/system/data/ent/rolepermission.go @@ -0,0 +1,160 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// Role-Permission mapping table +type RolePermission struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // RoleID holds the value of the "role_id" field. + RoleID int64 `json:"role_id,omitempty"` + // PermissionID holds the value of the "permission_id" field. + PermissionID int64 `json:"permission_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the RolePermissionQuery when eager-loading is set. + Edges RolePermissionEdges `json:"edges"` + selectValues sql.SelectValues +} + +// RolePermissionEdges holds the relations/edges for other nodes in the graph. +type RolePermissionEdges struct { + // Role holds the value of the role edge. + Role *Role `json:"role,omitempty"` + // Permission holds the value of the permission edge. + Permission *Permission `json:"permission,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// RoleOrErr returns the Role value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e RolePermissionEdges) RoleOrErr() (*Role, error) { + if e.Role != nil { + return e.Role, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: role.Label} + } + return nil, &NotLoadedError{edge: "role"} +} + +// PermissionOrErr returns the Permission value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e RolePermissionEdges) PermissionOrErr() (*Permission, error) { + if e.Permission != nil { + return e.Permission, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: permission.Label} + } + return nil, &NotLoadedError{edge: "permission"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*RolePermission) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case rolepermission.FieldID, rolepermission.FieldRoleID, rolepermission.FieldPermissionID: + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the RolePermission fields. +func (_m *RolePermission) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case rolepermission.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int(value.Int64) + case rolepermission.FieldRoleID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field role_id", values[i]) + } else if value.Valid { + _m.RoleID = value.Int64 + } + case rolepermission.FieldPermissionID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field permission_id", values[i]) + } else if value.Valid { + _m.PermissionID = value.Int64 + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the RolePermission. +// This includes values selected through modifiers, order, etc. +func (_m *RolePermission) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryRole queries the "role" edge of the RolePermission entity. +func (_m *RolePermission) QueryRole() *RoleQuery { + return NewRolePermissionClient(_m.config).QueryRole(_m) +} + +// QueryPermission queries the "permission" edge of the RolePermission entity. +func (_m *RolePermission) QueryPermission() *PermissionQuery { + return NewRolePermissionClient(_m.config).QueryPermission(_m) +} + +// Update returns a builder for updating this RolePermission. +// Note that you need to call RolePermission.Unwrap() before calling this method if this RolePermission +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *RolePermission) Update() *RolePermissionUpdateOne { + return NewRolePermissionClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the RolePermission entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *RolePermission) Unwrap() *RolePermission { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: RolePermission is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *RolePermission) String() string { + var builder strings.Builder + builder.WriteString("RolePermission(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("role_id=") + builder.WriteString(fmt.Sprintf("%v", _m.RoleID)) + builder.WriteString(", ") + builder.WriteString("permission_id=") + builder.WriteString(fmt.Sprintf("%v", _m.PermissionID)) + builder.WriteByte(')') + return builder.String() +} + +// RolePermissions is a parsable slice of RolePermission. +type RolePermissions []*RolePermission diff --git a/internal/features/system/data/ent/rolepermission/rolepermission.go b/internal/features/system/data/ent/rolepermission/rolepermission.go new file mode 100644 index 00000000..7923e112 --- /dev/null +++ b/internal/features/system/data/ent/rolepermission/rolepermission.go @@ -0,0 +1,164 @@ +// Code generated by ent, DO NOT EDIT. + +package rolepermission + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the rolepermission type in the database. + Label = "role_permission" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldRoleID holds the string denoting the role_id field in the database. + FieldRoleID = "role_id" + // FieldPermissionID holds the string denoting the permission_id field in the database. + FieldPermissionID = "permission_id" + // EdgeRole holds the string denoting the role edge name in mutations. + EdgeRole = "role" + // EdgePermission holds the string denoting the permission edge name in mutations. + EdgePermission = "permission" + // Table holds the table name of the rolepermission in the database. + Table = "sys_role_permissions" + // RoleTable is the table that holds the role relation/edge. + RoleTable = "sys_role_permissions" + // RoleInverseTable is the table name for the Role entity. + // It exists in this package in order to avoid circular dependency with the "role" package. + RoleInverseTable = "sys_roles" + // RoleColumn is the table column denoting the role relation/edge. + RoleColumn = "role_id" + // PermissionTable is the table that holds the permission relation/edge. + PermissionTable = "sys_role_permissions" + // PermissionInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionInverseTable = "sys_permissions" + // PermissionColumn is the table column denoting the permission relation/edge. + PermissionColumn = "permission_id" +) + +// Columns holds all SQL columns for rolepermission fields. +var Columns = []string{ + FieldID, + FieldRoleID, + FieldPermissionID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +// OrderOption defines the ordering options for the RolePermission queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByRoleID orders the results by the role_id field. +func ByRoleID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRoleID, opts...).ToFunc() +} + +// ByPermissionID orders the results by the permission_id field. +func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPermissionID, opts...).ToFunc() +} + +// ByRoleField orders the results by role field. +func ByRoleField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRoleStep(), sql.OrderByField(field, opts...)) + } +} + +// ByPermissionField orders the results by permission field. +func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) + } +} +func newRoleStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RoleInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), + ) +} +func newPermissionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/features/system/data/ent/rolepermission/where.go b/internal/features/system/data/ent/rolepermission/where.go new file mode 100644 index 00000000..9e784297 --- /dev/null +++ b/internal/features/system/data/ent/rolepermission/where.go @@ -0,0 +1,166 @@ +// Code generated by ent, DO NOT EDIT. + +package rolepermission + +import ( + "origadmin/application/admin/internal/features/system/data/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.RolePermission { + return predicate.RolePermission(sql.FieldLTE(FieldID, id)) +} + +// RoleID applies equality check predicate on the "role_id" field. It's identical to RoleIDEQ. +func RoleID(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldRoleID, v)) +} + +// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. +func PermissionID(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldPermissionID, v)) +} + +// RoleIDEQ applies the EQ predicate on the "role_id" field. +func RoleIDEQ(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldRoleID, v)) +} + +// RoleIDNEQ applies the NEQ predicate on the "role_id" field. +func RoleIDNEQ(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNEQ(FieldRoleID, v)) +} + +// RoleIDIn applies the In predicate on the "role_id" field. +func RoleIDIn(vs ...int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldIn(FieldRoleID, vs...)) +} + +// RoleIDNotIn applies the NotIn predicate on the "role_id" field. +func RoleIDNotIn(vs ...int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNotIn(FieldRoleID, vs...)) +} + +// PermissionIDEQ applies the EQ predicate on the "permission_id" field. +func PermissionIDEQ(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldEQ(FieldPermissionID, v)) +} + +// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. +func PermissionIDNEQ(v int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNEQ(FieldPermissionID, v)) +} + +// PermissionIDIn applies the In predicate on the "permission_id" field. +func PermissionIDIn(vs ...int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldIn(FieldPermissionID, vs...)) +} + +// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. +func PermissionIDNotIn(vs ...int64) predicate.RolePermission { + return predicate.RolePermission(sql.FieldNotIn(FieldPermissionID, vs...)) +} + +// HasRole applies the HasEdge predicate on the "role" edge. +func HasRole() predicate.RolePermission { + return predicate.RolePermission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRoleWith applies the HasEdge predicate on the "role" edge with a given conditions (other predicates). +func HasRoleWith(preds ...predicate.Role) predicate.RolePermission { + return predicate.RolePermission(func(s *sql.Selector) { + step := newRoleStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermission applies the HasEdge predicate on the "permission" edge. +func HasPermission() predicate.RolePermission { + return predicate.RolePermission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). +func HasPermissionWith(preds ...predicate.Permission) predicate.RolePermission { + return predicate.RolePermission(func(s *sql.Selector) { + step := newPermissionStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.RolePermission) predicate.RolePermission { + return predicate.RolePermission(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.RolePermission) predicate.RolePermission { + return predicate.RolePermission(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.RolePermission) predicate.RolePermission { + return predicate.RolePermission(sql.NotPredicates(p)) +} diff --git a/internal/features/system/data/ent/rolepermission_create.go b/internal/features/system/data/ent/rolepermission_create.go new file mode 100644 index 00000000..1f68ce2b --- /dev/null +++ b/internal/features/system/data/ent/rolepermission_create.go @@ -0,0 +1,260 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// RolePermissionCreate is the builder for creating a RolePermission entity. +type RolePermissionCreate struct { + config + mutation *RolePermissionMutation + hooks []Hook +} + +// SetRoleID sets the "role_id" field. +func (_c *RolePermissionCreate) SetRoleID(v int64) *RolePermissionCreate { + _c.mutation.SetRoleID(v) + return _c +} + +// SetPermissionID sets the "permission_id" field. +func (_c *RolePermissionCreate) SetPermissionID(v int64) *RolePermissionCreate { + _c.mutation.SetPermissionID(v) + return _c +} + +// SetRole sets the "role" edge to the Role entity. +func (_c *RolePermissionCreate) SetRole(v *Role) *RolePermissionCreate { + return _c.SetRoleID(v.ID) +} + +// SetPermission sets the "permission" edge to the Permission entity. +func (_c *RolePermissionCreate) SetPermission(v *Permission) *RolePermissionCreate { + return _c.SetPermissionID(v.ID) +} + +// Mutation returns the RolePermissionMutation object of the builder. +func (_c *RolePermissionCreate) Mutation() *RolePermissionMutation { + return _c.mutation +} + +// Save creates the RolePermission in the database. +func (_c *RolePermissionCreate) Save(ctx context.Context) (*RolePermission, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *RolePermissionCreate) SaveX(ctx context.Context) *RolePermission { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *RolePermissionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *RolePermissionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *RolePermissionCreate) check() error { + if _, ok := _c.mutation.RoleID(); !ok { + return &ValidationError{Name: "role_id", err: errors.New(`ent: missing required field "RolePermission.role_id"`)} + } + if _, ok := _c.mutation.PermissionID(); !ok { + return &ValidationError{Name: "permission_id", err: errors.New(`ent: missing required field "RolePermission.permission_id"`)} + } + if len(_c.mutation.RoleIDs()) == 0 { + return &ValidationError{Name: "role", err: errors.New(`ent: missing required edge "RolePermission.role"`)} + } + if len(_c.mutation.PermissionIDs()) == 0 { + return &ValidationError{Name: "permission", err: errors.New(`ent: missing required edge "RolePermission.permission"`)} + } + return nil +} + +func (_c *RolePermissionCreate) sqlSave(ctx context.Context) (*RolePermission, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *RolePermissionCreate) createSpec() (*RolePermission, *sqlgraph.CreateSpec) { + var ( + _node = &RolePermission{config: _c.config} + _spec = sqlgraph.NewCreateSpec(rolepermission.Table, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) + ) + if nodes := _c.mutation.RoleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: rolepermission.RoleTable, + Columns: []string{rolepermission.RoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.RoleID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.PermissionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: rolepermission.PermissionTable, + Columns: []string{rolepermission.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.PermissionID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SetRolePermission set the RolePermission +func (_c *RolePermissionCreate) SetRolePermission(input *RolePermission, fields ...string) *RolePermissionCreate { + m := _c.mutation + if len(fields) == 0 { + fields = rolepermission.Columns + } + _ = m.SetFields(input, fields...) + return _c +} + +// SetRolePermissionWithZero set the RolePermission +func (_c *RolePermissionCreate) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionCreate { + m := _c.mutation + if len(fields) == 0 { + fields = rolepermission.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return _c +} + +// RolePermissionCreateBulk is the builder for creating many RolePermission entities in bulk. +type RolePermissionCreateBulk struct { + config + err error + builders []*RolePermissionCreate +} + +// Save creates the RolePermission entities in the database. +func (_c *RolePermissionCreateBulk) Save(ctx context.Context) ([]*RolePermission, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*RolePermission, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*RolePermissionMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *RolePermissionCreateBulk) SaveX(ctx context.Context) []*RolePermission { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *RolePermissionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *RolePermissionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/rolepermission_delete.go b/internal/features/system/data/ent/rolepermission_delete.go new file mode 100644 index 00000000..d2796477 --- /dev/null +++ b/internal/features/system/data/ent/rolepermission_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// RolePermissionDelete is the builder for deleting a RolePermission entity. +type RolePermissionDelete struct { + config + hooks []Hook + mutation *RolePermissionMutation +} + +// Where appends a list predicates to the RolePermissionDelete builder. +func (_d *RolePermissionDelete) Where(ps ...predicate.RolePermission) *RolePermissionDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *RolePermissionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *RolePermissionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *RolePermissionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(rolepermission.Table, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// RolePermissionDeleteOne is the builder for deleting a single RolePermission entity. +type RolePermissionDeleteOne struct { + _d *RolePermissionDelete +} + +// Where appends a list predicates to the RolePermissionDelete builder. +func (_d *RolePermissionDeleteOne) Where(ps ...predicate.RolePermission) *RolePermissionDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *RolePermissionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{rolepermission.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *RolePermissionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/rolepermission_query.go b/internal/features/system/data/ent/rolepermission_query.go new file mode 100644 index 00000000..6b14ebeb --- /dev/null +++ b/internal/features/system/data/ent/rolepermission_query.go @@ -0,0 +1,763 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// RolePermissionQuery is the builder for querying RolePermission entities. +type RolePermissionQuery struct { + config + ctx *QueryContext + order []rolepermission.OrderOption + inters []Interceptor + predicates []predicate.RolePermission + withRole *RoleQuery + withPermission *PermissionQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the RolePermissionQuery builder. +func (_q *RolePermissionQuery) Where(ps ...predicate.RolePermission) *RolePermissionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *RolePermissionQuery) Limit(limit int) *RolePermissionQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *RolePermissionQuery) Offset(offset int) *RolePermissionQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *RolePermissionQuery) Unique(unique bool) *RolePermissionQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *RolePermissionQuery) Order(o ...rolepermission.OrderOption) *RolePermissionQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryRole chains the current query on the "role" edge. +func (_q *RolePermissionQuery) QueryRole() *RoleQuery { + query := (&RoleClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(rolepermission.Table, rolepermission.FieldID, selector), + sqlgraph.To(role.Table, role.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.RoleTable, rolepermission.RoleColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryPermission chains the current query on the "permission" edge. +func (_q *RolePermissionQuery) QueryPermission() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(rolepermission.Table, rolepermission.FieldID, selector), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.PermissionTable, rolepermission.PermissionColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first RolePermission entity from the query. +// Returns a *NotFoundError when no RolePermission was found. +func (_q *RolePermissionQuery) First(ctx context.Context) (*RolePermission, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{rolepermission.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *RolePermissionQuery) FirstX(ctx context.Context) *RolePermission { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first RolePermission ID from the query. +// Returns a *NotFoundError when no RolePermission ID was found. +func (_q *RolePermissionQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{rolepermission.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *RolePermissionQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single RolePermission entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one RolePermission entity is found. +// Returns a *NotFoundError when no RolePermission entities are found. +func (_q *RolePermissionQuery) Only(ctx context.Context) (*RolePermission, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{rolepermission.Label} + default: + return nil, &NotSingularError{rolepermission.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *RolePermissionQuery) OnlyX(ctx context.Context) *RolePermission { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only RolePermission ID in the query. +// Returns a *NotSingularError when more than one RolePermission ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *RolePermissionQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{rolepermission.Label} + default: + err = &NotSingularError{rolepermission.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *RolePermissionQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of RolePermissions. +func (_q *RolePermissionQuery) All(ctx context.Context) ([]*RolePermission, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*RolePermission, *RolePermissionQuery]() + return withInterceptors[[]*RolePermission](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *RolePermissionQuery) AllX(ctx context.Context) []*RolePermission { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of RolePermission IDs. +func (_q *RolePermissionQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(rolepermission.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *RolePermissionQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *RolePermissionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*RolePermissionQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *RolePermissionQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *RolePermissionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *RolePermissionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the RolePermissionQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *RolePermissionQuery) Clone() *RolePermissionQuery { + if _q == nil { + return nil + } + return &RolePermissionQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]rolepermission.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.RolePermission{}, _q.predicates...), + withRole: _q.withRole.Clone(), + withPermission: _q.withPermission.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithRole tells the query-builder to eager-load the nodes that are connected to +// the "role" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *RolePermissionQuery) WithRole(opts ...func(*RoleQuery)) *RolePermissionQuery { + query := (&RoleClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRole = query + return _q +} + +// WithPermission tells the query-builder to eager-load the nodes that are connected to +// the "permission" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *RolePermissionQuery) WithPermission(opts ...func(*PermissionQuery)) *RolePermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withPermission = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// RoleID int64 `json:"role_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.RolePermission.Query(). +// GroupBy(rolepermission.FieldRoleID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *RolePermissionQuery) GroupBy(field string, fields ...string) *RolePermissionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &RolePermissionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = rolepermission.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// RoleID int64 `json:"role_id,omitempty"` +// } +// +// client.RolePermission.Query(). +// Select(rolepermission.FieldRoleID). +// Scan(ctx, &v) +func (_q *RolePermissionQuery) Select(fields ...string) *RolePermissionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &RolePermissionSelect{RolePermissionQuery: _q} + sbuild.label = rolepermission.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a RolePermissionSelect configured with the given aggregations. +func (_q *RolePermissionQuery) Aggregate(fns ...AggregateFunc) *RolePermissionSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *RolePermissionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !rolepermission.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *RolePermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*RolePermission, error) { + var ( + nodes = []*RolePermission{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withRole != nil, + _q.withPermission != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*RolePermission).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &RolePermission{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withRole; query != nil { + if err := _q.loadRole(ctx, query, nodes, nil, + func(n *RolePermission, e *Role) { n.Edges.Role = e }); err != nil { + return nil, err + } + } + if query := _q.withPermission; query != nil { + if err := _q.loadPermission(ctx, query, nodes, nil, + func(n *RolePermission, e *Permission) { n.Edges.Permission = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *RolePermissionQuery) loadRole(ctx context.Context, query *RoleQuery, nodes []*RolePermission, init func(*RolePermission), assign func(*RolePermission, *Role)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*RolePermission) + for i := range nodes { + fk := nodes[i].RoleID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(role.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "role_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *RolePermissionQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*RolePermission, init func(*RolePermission), assign func(*RolePermission, *Permission)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*RolePermission) + for i := range nodes { + fk := nodes[i].PermissionID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(permission.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "permission_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *RolePermissionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *RolePermissionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(rolepermission.Table, rolepermission.Columns, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, rolepermission.FieldID) + for i := range fields { + if fields[i] != rolepermission.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withRole != nil { + _spec.Node.AddColumnOnce(rolepermission.FieldRoleID) + } + if _q.withPermission != nil { + _spec.Node.AddColumnOnce(rolepermission.FieldPermissionID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *RolePermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(rolepermission.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = rolepermission.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *RolePermissionQuery) ForUpdate(opts ...sql.LockOption) *RolePermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *RolePermissionQuery) ForShare(opts ...sql.LockOption) *RolePermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *RolePermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *RolePermissionSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// RoleID int64 `json:"role_id,omitempty"` +// PermissionID int64 `json:"permission_id,omitempty"` +// } +// +// client.RolePermission.Query(). +// Omit( +// rolepermission.FieldRoleID, +// rolepermission.FieldPermissionID, +// ). +// Scan(ctx, &v) +func (rpq *RolePermissionQuery) Omit(fields ...string) *RolePermissionSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range rolepermission.Columns { + if _, ok := omits[col]; !ok { + rpq.ctx.Fields = append(rpq.ctx.Fields, col) + } + } + + sbuild := &RolePermissionSelect{RolePermissionQuery: rpq} + sbuild.label = rolepermission.Label + sbuild.flds, sbuild.scan = &rpq.ctx.Fields, sbuild.Scan + return sbuild +} + +// RolePermissionGroupBy is the group-by builder for RolePermission entities. +type RolePermissionGroupBy struct { + selector + build *RolePermissionQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *RolePermissionGroupBy) Aggregate(fns ...AggregateFunc) *RolePermissionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *RolePermissionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*RolePermissionQuery, *RolePermissionGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *RolePermissionGroupBy) sqlScan(ctx context.Context, root *RolePermissionQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// RolePermissionSelect is the builder for selecting fields of RolePermission entities. +type RolePermissionSelect struct { + *RolePermissionQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *RolePermissionSelect) Aggregate(fns ...AggregateFunc) *RolePermissionSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *RolePermissionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*RolePermissionQuery, *RolePermissionSelect](ctx, _s.RolePermissionQuery, _s, _s.inters, v) +} + +func (_s *RolePermissionSelect) sqlScan(ctx context.Context, root *RolePermissionQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *RolePermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *RolePermissionSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/internal/features/system/data/ent/rolepermission_update.go b/internal/features/system/data/ent/rolepermission_update.go new file mode 100644 index 00000000..822748e3 --- /dev/null +++ b/internal/features/system/data/ent/rolepermission_update.go @@ -0,0 +1,493 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/rolepermission" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// RolePermissionUpdate is the builder for updating RolePermission entities. +type RolePermissionUpdate struct { + config + hooks []Hook + mutation *RolePermissionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the RolePermissionUpdate builder. +func (_u *RolePermissionUpdate) Where(ps ...predicate.RolePermission) *RolePermissionUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetRoleID sets the "role_id" field. +func (_u *RolePermissionUpdate) SetRoleID(v int64) *RolePermissionUpdate { + _u.mutation.SetRoleID(v) + return _u +} + +// SetNillableRoleID sets the "role_id" field if the given value is not nil. +func (_u *RolePermissionUpdate) SetNillableRoleID(v *int64) *RolePermissionUpdate { + if v != nil { + _u.SetRoleID(*v) + } + return _u +} + +// SetPermissionID sets the "permission_id" field. +func (_u *RolePermissionUpdate) SetPermissionID(v int64) *RolePermissionUpdate { + _u.mutation.SetPermissionID(v) + return _u +} + +// SetNillablePermissionID sets the "permission_id" field if the given value is not nil. +func (_u *RolePermissionUpdate) SetNillablePermissionID(v *int64) *RolePermissionUpdate { + if v != nil { + _u.SetPermissionID(*v) + } + return _u +} + +// SetRole sets the "role" edge to the Role entity. +func (_u *RolePermissionUpdate) SetRole(v *Role) *RolePermissionUpdate { + return _u.SetRoleID(v.ID) +} + +// SetPermission sets the "permission" edge to the Permission entity. +func (_u *RolePermissionUpdate) SetPermission(v *Permission) *RolePermissionUpdate { + return _u.SetPermissionID(v.ID) +} + +// Mutation returns the RolePermissionMutation object of the builder. +func (_u *RolePermissionUpdate) Mutation() *RolePermissionMutation { + return _u.mutation +} + +// ClearRole clears the "role" edge to the Role entity. +func (_u *RolePermissionUpdate) ClearRole() *RolePermissionUpdate { + _u.mutation.ClearRole() + return _u +} + +// ClearPermission clears the "permission" edge to the Permission entity. +func (_u *RolePermissionUpdate) ClearPermission() *RolePermissionUpdate { + _u.mutation.ClearPermission() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *RolePermissionUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *RolePermissionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *RolePermissionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *RolePermissionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *RolePermissionUpdate) check() error { + if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "RolePermission.role"`) + } + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "RolePermission.permission"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *RolePermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RolePermissionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *RolePermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(rolepermission.Table, rolepermission.Columns, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if _u.mutation.RoleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: rolepermission.RoleTable, + Columns: []string{rolepermission.RoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: rolepermission.RoleTable, + Columns: []string{rolepermission.RoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: rolepermission.PermissionTable, + Columns: []string{rolepermission.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: rolepermission.PermissionTable, + Columns: []string{rolepermission.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{rolepermission.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// RolePermissionUpdateOne is the builder for updating a single RolePermission entity. +type RolePermissionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *RolePermissionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetRoleID sets the "role_id" field. +func (_u *RolePermissionUpdateOne) SetRoleID(v int64) *RolePermissionUpdateOne { + _u.mutation.SetRoleID(v) + return _u +} + +// SetNillableRoleID sets the "role_id" field if the given value is not nil. +func (_u *RolePermissionUpdateOne) SetNillableRoleID(v *int64) *RolePermissionUpdateOne { + if v != nil { + _u.SetRoleID(*v) + } + return _u +} + +// SetPermissionID sets the "permission_id" field. +func (_u *RolePermissionUpdateOne) SetPermissionID(v int64) *RolePermissionUpdateOne { + _u.mutation.SetPermissionID(v) + return _u +} + +// SetNillablePermissionID sets the "permission_id" field if the given value is not nil. +func (_u *RolePermissionUpdateOne) SetNillablePermissionID(v *int64) *RolePermissionUpdateOne { + if v != nil { + _u.SetPermissionID(*v) + } + return _u +} + +// SetRole sets the "role" edge to the Role entity. +func (_u *RolePermissionUpdateOne) SetRole(v *Role) *RolePermissionUpdateOne { + return _u.SetRoleID(v.ID) +} + +// SetPermission sets the "permission" edge to the Permission entity. +func (_u *RolePermissionUpdateOne) SetPermission(v *Permission) *RolePermissionUpdateOne { + return _u.SetPermissionID(v.ID) +} + +// Mutation returns the RolePermissionMutation object of the builder. +func (_u *RolePermissionUpdateOne) Mutation() *RolePermissionMutation { + return _u.mutation +} + +// ClearRole clears the "role" edge to the Role entity. +func (_u *RolePermissionUpdateOne) ClearRole() *RolePermissionUpdateOne { + _u.mutation.ClearRole() + return _u +} + +// ClearPermission clears the "permission" edge to the Permission entity. +func (_u *RolePermissionUpdateOne) ClearPermission() *RolePermissionUpdateOne { + _u.mutation.ClearPermission() + return _u +} + +// Where appends a list predicates to the RolePermissionUpdate builder. +func (_u *RolePermissionUpdateOne) Where(ps ...predicate.RolePermission) *RolePermissionUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *RolePermissionUpdateOne) Select(field string, fields ...string) *RolePermissionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated RolePermission entity. +func (_u *RolePermissionUpdateOne) Save(ctx context.Context) (*RolePermission, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *RolePermissionUpdateOne) SaveX(ctx context.Context) *RolePermission { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *RolePermissionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *RolePermissionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *RolePermissionUpdateOne) check() error { + if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "RolePermission.role"`) + } + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "RolePermission.permission"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *RolePermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RolePermissionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePermission, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(rolepermission.Table, rolepermission.Columns, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RolePermission.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, rolepermission.FieldID) + for _, f := range fields { + if !rolepermission.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != rolepermission.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if _u.mutation.RoleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: rolepermission.RoleTable, + Columns: []string{rolepermission.RoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: rolepermission.RoleTable, + Columns: []string{rolepermission.RoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: rolepermission.PermissionTable, + Columns: []string{rolepermission.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: rolepermission.PermissionTable, + Columns: []string{rolepermission.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &RolePermission{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{rolepermission.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} + +// SetRolePermission set the RolePermission +func (rpu *RolePermissionUpdate) SetRolePermission(input *RolePermission, fields ...string) *RolePermissionUpdate { + m := rpu.mutation + if len(fields) == 0 { + fields = rolepermission.OmitColumns(rolepermission.FieldID) + } + _ = m.SetFields(input, fields...) + return rpu +} + +// SetRolePermissionWithZero set the RolePermission +func (rpu *RolePermissionUpdate) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionUpdate { + m := rpu.mutation + if len(fields) == 0 { + fields = rolepermission.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return rpu +} + +// SetRolePermission set the RolePermission +func (rpuo *RolePermissionUpdateOne) SetRolePermission(input *RolePermission, fields ...string) *RolePermissionUpdateOne { + m := rpuo.mutation + if len(fields) == 0 { + fields = rolepermission.OmitColumns(rolepermission.FieldID) + } + _ = m.SetFields(input, fields...) + return rpuo +} + +// SetRolePermissionWithZero set the RolePermission +func (rpuo *RolePermissionUpdateOne) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionUpdateOne { + m := rpuo.mutation + if len(fields) == 0 { + fields = rolepermission.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return rpuo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (rpuo *RolePermissionUpdateOne) Omit(fields ...string) *RolePermissionUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + rpuo.fields = []string(nil) + for _, col := range rolepermission.Columns { + if _, ok := omits[col]; !ok { + rpuo.fields = append(rpuo.fields, col) + } + } + return rpuo +} diff --git a/internal/features/system/data/ent/runtime.go b/internal/features/system/data/ent/runtime.go new file mode 100644 index 00000000..e291b037 --- /dev/null +++ b/internal/features/system/data/ent/runtime.go @@ -0,0 +1,262 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/data/ent/resource" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/schema" + "origadmin/application/admin/internal/features/system/data/ent/user" + "time" +) + +// The init function reads all schema descriptors with runtime code +// (default values, validators, hooks and policies) and stitches it +// to their package variables. +func init() { + permissionMixin := schema.Permission{}.Mixin() + permissionMixinFields0 := permissionMixin[0].Fields() + _ = permissionMixinFields0 + permissionFields := schema.Permission{}.Fields() + _ = permissionFields + // permissionDescCreateTime is the schema descriptor for create_time field. + permissionDescCreateTime := permissionMixinFields0[0].Descriptor() + // permission.DefaultCreateTime holds the default value on creation for the create_time field. + permission.DefaultCreateTime = permissionDescCreateTime.Default.(func() time.Time) + // permissionDescUpdateTime is the schema descriptor for update_time field. + permissionDescUpdateTime := permissionMixinFields0[1].Descriptor() + // permission.DefaultUpdateTime holds the default value on creation for the update_time field. + permission.DefaultUpdateTime = permissionDescUpdateTime.Default.(func() time.Time) + // permission.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + permission.UpdateDefaultUpdateTime = permissionDescUpdateTime.UpdateDefault.(func() time.Time) + // permissionDescName is the schema descriptor for name field. + permissionDescName := permissionFields[1].Descriptor() + // permission.DefaultName holds the default value on creation for the name field. + permission.DefaultName = permissionDescName.Default.(string) + // permission.NameValidator is a validator for the "name" field. It is called by the builders before save. + permission.NameValidator = permissionDescName.Validators[0].(func(string) error) + // permissionDescKeyword is the schema descriptor for keyword field. + permissionDescKeyword := permissionFields[2].Descriptor() + // permission.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + permission.KeywordValidator = permissionDescKeyword.Validators[0].(func(string) error) + // permissionDescDescription is the schema descriptor for description field. + permissionDescDescription := permissionFields[3].Descriptor() + // permission.DefaultDescription holds the default value on creation for the description field. + permission.DefaultDescription = permissionDescDescription.Default.(string) + // permission.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + permission.DescriptionValidator = permissionDescDescription.Validators[0].(func(string) error) + // permissionDescDataScope is the schema descriptor for data_scope field. + permissionDescDataScope := permissionFields[4].Descriptor() + // permission.DefaultDataScope holds the default value on creation for the data_scope field. + permission.DefaultDataScope = permissionDescDataScope.Default.(string) + resourceMixin := schema.Resource{}.Mixin() + resourceMixinFields0 := resourceMixin[0].Fields() + _ = resourceMixinFields0 + resourceFields := schema.Resource{}.Fields() + _ = resourceFields + // resourceDescCreateTime is the schema descriptor for create_time field. + resourceDescCreateTime := resourceMixinFields0[0].Descriptor() + // resource.DefaultCreateTime holds the default value on creation for the create_time field. + resource.DefaultCreateTime = resourceDescCreateTime.Default.(func() time.Time) + // resourceDescUpdateTime is the schema descriptor for update_time field. + resourceDescUpdateTime := resourceMixinFields0[1].Descriptor() + // resource.DefaultUpdateTime holds the default value on creation for the update_time field. + resource.DefaultUpdateTime = resourceDescUpdateTime.Default.(func() time.Time) + // resource.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + resource.UpdateDefaultUpdateTime = resourceDescUpdateTime.UpdateDefault.(func() time.Time) + // resourceDescName is the schema descriptor for name field. + resourceDescName := resourceFields[1].Descriptor() + // resource.DefaultName holds the default value on creation for the name field. + resource.DefaultName = resourceDescName.Default.(string) + // resource.NameValidator is a validator for the "name" field. It is called by the builders before save. + resource.NameValidator = resourceDescName.Validators[0].(func(string) error) + // resourceDescKeyword is the schema descriptor for keyword field. + resourceDescKeyword := resourceFields[2].Descriptor() + // resource.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + resource.KeywordValidator = resourceDescKeyword.Validators[0].(func(string) error) + // resourceDescType is the schema descriptor for type field. + resourceDescType := resourceFields[3].Descriptor() + // resource.DefaultType holds the default value on creation for the type field. + resource.DefaultType = resourceDescType.Default.(string) + // resource.TypeValidator is a validator for the "type" field. It is called by the builders before save. + resource.TypeValidator = resourceDescType.Validators[0].(func(string) error) + // resourceDescStatus is the schema descriptor for status field. + resourceDescStatus := resourceFields[4].Descriptor() + // resource.DefaultStatus holds the default value on creation for the status field. + resource.DefaultStatus = resourceDescStatus.Default.(int8) + // resourceDescPath is the schema descriptor for path field. + resourceDescPath := resourceFields[5].Descriptor() + // resource.DefaultPath holds the default value on creation for the path field. + resource.DefaultPath = resourceDescPath.Default.(string) + // resource.PathValidator is a validator for the "path" field. It is called by the builders before save. + resource.PathValidator = resourceDescPath.Validators[0].(func(string) error) + // resourceDescComponent is the schema descriptor for component field. + resourceDescComponent := resourceFields[6].Descriptor() + // resource.DefaultComponent holds the default value on creation for the component field. + resource.DefaultComponent = resourceDescComponent.Default.(string) + // resource.ComponentValidator is a validator for the "component" field. It is called by the builders before save. + resource.ComponentValidator = resourceDescComponent.Validators[0].(func(string) error) + // resourceDescIcon is the schema descriptor for icon field. + resourceDescIcon := resourceFields[7].Descriptor() + // resource.DefaultIcon holds the default value on creation for the icon field. + resource.DefaultIcon = resourceDescIcon.Default.(string) + // resource.IconValidator is a validator for the "icon" field. It is called by the builders before save. + resource.IconValidator = resourceDescIcon.Validators[0].(func(string) error) + // resourceDescSequence is the schema descriptor for sequence field. + resourceDescSequence := resourceFields[8].Descriptor() + // resource.DefaultSequence holds the default value on creation for the sequence field. + resource.DefaultSequence = resourceDescSequence.Default.(int) + // resourceDescVisible is the schema descriptor for visible field. + resourceDescVisible := resourceFields[9].Descriptor() + // resource.DefaultVisible holds the default value on creation for the visible field. + resource.DefaultVisible = resourceDescVisible.Default.(bool) + // resourceDescLevel is the schema descriptor for level field. + resourceDescLevel := resourceFields[10].Descriptor() + // resource.DefaultLevel holds the default value on creation for the level field. + resource.DefaultLevel = resourceDescLevel.Default.(int8) + // resourceDescTreePath is the schema descriptor for tree_path field. + resourceDescTreePath := resourceFields[11].Descriptor() + // resource.DefaultTreePath holds the default value on creation for the tree_path field. + resource.DefaultTreePath = resourceDescTreePath.Default.(string) + // resource.TreePathValidator is a validator for the "tree_path" field. It is called by the builders before save. + resource.TreePathValidator = resourceDescTreePath.Validators[0].(func(string) error) + // resourceDescDescription is the schema descriptor for description field. + resourceDescDescription := resourceFields[13].Descriptor() + // resource.DefaultDescription holds the default value on creation for the description field. + resource.DefaultDescription = resourceDescDescription.Default.(string) + // resource.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + resource.DescriptionValidator = resourceDescDescription.Validators[0].(func(string) error) + roleMixin := schema.Role{}.Mixin() + roleMixinFields0 := roleMixin[0].Fields() + _ = roleMixinFields0 + roleFields := schema.Role{}.Fields() + _ = roleFields + // roleDescCreateTime is the schema descriptor for create_time field. + roleDescCreateTime := roleMixinFields0[0].Descriptor() + // role.DefaultCreateTime holds the default value on creation for the create_time field. + role.DefaultCreateTime = roleDescCreateTime.Default.(func() time.Time) + // roleDescUpdateTime is the schema descriptor for update_time field. + roleDescUpdateTime := roleMixinFields0[1].Descriptor() + // role.DefaultUpdateTime holds the default value on creation for the update_time field. + role.DefaultUpdateTime = roleDescUpdateTime.Default.(func() time.Time) + // role.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + role.UpdateDefaultUpdateTime = roleDescUpdateTime.UpdateDefault.(func() time.Time) + // roleDescKeyword is the schema descriptor for keyword field. + roleDescKeyword := roleFields[1].Descriptor() + // role.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + role.KeywordValidator = roleDescKeyword.Validators[0].(func(string) error) + // roleDescName is the schema descriptor for name field. + roleDescName := roleFields[2].Descriptor() + // role.DefaultName holds the default value on creation for the name field. + role.DefaultName = roleDescName.Default.(string) + // role.NameValidator is a validator for the "name" field. It is called by the builders before save. + role.NameValidator = roleDescName.Validators[0].(func(string) error) + // roleDescDescription is the schema descriptor for description field. + roleDescDescription := roleFields[3].Descriptor() + // role.DefaultDescription holds the default value on creation for the description field. + role.DefaultDescription = roleDescDescription.Default.(string) + // role.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. + role.DescriptionValidator = roleDescDescription.Validators[0].(func(string) error) + // roleDescType is the schema descriptor for type field. + roleDescType := roleFields[4].Descriptor() + // role.DefaultType holds the default value on creation for the type field. + role.DefaultType = roleDescType.Default.(int8) + // roleDescSequence is the schema descriptor for sequence field. + roleDescSequence := roleFields[5].Descriptor() + // role.DefaultSequence holds the default value on creation for the sequence field. + role.DefaultSequence = roleDescSequence.Default.(int) + // roleDescStatus is the schema descriptor for status field. + roleDescStatus := roleFields[6].Descriptor() + // role.DefaultStatus holds the default value on creation for the status field. + role.DefaultStatus = roleDescStatus.Default.(int8) + userMixin := schema.User{}.Mixin() + userMixinFields0 := userMixin[0].Fields() + _ = userMixinFields0 + userFields := schema.User{}.Fields() + _ = userFields + // userDescCreateTime is the schema descriptor for create_time field. + userDescCreateTime := userMixinFields0[0].Descriptor() + // user.DefaultCreateTime holds the default value on creation for the create_time field. + user.DefaultCreateTime = userDescCreateTime.Default.(func() time.Time) + // userDescUpdateTime is the schema descriptor for update_time field. + userDescUpdateTime := userMixinFields0[1].Descriptor() + // user.DefaultUpdateTime holds the default value on creation for the update_time field. + user.DefaultUpdateTime = userDescUpdateTime.Default.(func() time.Time) + // user.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + user.UpdateDefaultUpdateTime = userDescUpdateTime.UpdateDefault.(func() time.Time) + // userDescUUID is the schema descriptor for uuid field. + userDescUUID := userFields[1].Descriptor() + // user.UUIDValidator is a validator for the "uuid" field. It is called by the builders before save. + user.UUIDValidator = userDescUUID.Validators[0].(func(string) error) + // userDescAllowedIP is the schema descriptor for allowed_ip field. + userDescAllowedIP := userFields[2].Descriptor() + // user.DefaultAllowedIP holds the default value on creation for the allowed_ip field. + user.DefaultAllowedIP = userDescAllowedIP.Default.(string) + // userDescUsername is the schema descriptor for username field. + userDescUsername := userFields[3].Descriptor() + // user.UsernameValidator is a validator for the "username" field. It is called by the builders before save. + user.UsernameValidator = userDescUsername.Validators[0].(func(string) error) + // userDescNickname is the schema descriptor for nickname field. + userDescNickname := userFields[4].Descriptor() + // user.DefaultNickname holds the default value on creation for the nickname field. + user.DefaultNickname = userDescNickname.Default.(string) + // user.NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. + user.NicknameValidator = userDescNickname.Validators[0].(func(string) error) + // userDescAvatar is the schema descriptor for avatar field. + userDescAvatar := userFields[5].Descriptor() + // user.DefaultAvatar holds the default value on creation for the avatar field. + user.DefaultAvatar = userDescAvatar.Default.(string) + // user.AvatarValidator is a validator for the "avatar" field. It is called by the builders before save. + user.AvatarValidator = userDescAvatar.Validators[0].(func(string) error) + // userDescName is the schema descriptor for name field. + userDescName := userFields[6].Descriptor() + // user.DefaultName holds the default value on creation for the name field. + user.DefaultName = userDescName.Default.(string) + // user.NameValidator is a validator for the "name" field. It is called by the builders before save. + user.NameValidator = userDescName.Validators[0].(func(string) error) + // userDescPassword is the schema descriptor for password field. + userDescPassword := userFields[8].Descriptor() + // user.DefaultPassword holds the default value on creation for the password field. + user.DefaultPassword = userDescPassword.Default.(string) + // user.PasswordValidator is a validator for the "password" field. It is called by the builders before save. + user.PasswordValidator = userDescPassword.Validators[0].(func(string) error) + // userDescPhone is the schema descriptor for phone field. + userDescPhone := userFields[9].Descriptor() + // user.DefaultPhone holds the default value on creation for the phone field. + user.DefaultPhone = userDescPhone.Default.(string) + // user.PhoneValidator is a validator for the "phone" field. It is called by the builders before save. + user.PhoneValidator = userDescPhone.Validators[0].(func(string) error) + // userDescEmail is the schema descriptor for email field. + userDescEmail := userFields[10].Descriptor() + // user.DefaultEmail holds the default value on creation for the email field. + user.DefaultEmail = userDescEmail.Default.(string) + // user.EmailValidator is a validator for the "email" field. It is called by the builders before save. + user.EmailValidator = userDescEmail.Validators[0].(func(string) error) + // userDescDepartment is the schema descriptor for department field. + userDescDepartment := userFields[11].Descriptor() + // user.DefaultDepartment holds the default value on creation for the department field. + user.DefaultDepartment = userDescDepartment.Default.(string) + // user.DepartmentValidator is a validator for the "department" field. It is called by the builders before save. + user.DepartmentValidator = userDescDepartment.Validators[0].(func(string) error) + // userDescRemark is the schema descriptor for remark field. + userDescRemark := userFields[12].Descriptor() + // user.DefaultRemark holds the default value on creation for the remark field. + user.DefaultRemark = userDescRemark.Default.(string) + // user.RemarkValidator is a validator for the "remark" field. It is called by the builders before save. + user.RemarkValidator = userDescRemark.Validators[0].(func(string) error) + // userDescStatus is the schema descriptor for status field. + userDescStatus := userFields[13].Descriptor() + // user.DefaultStatus holds the default value on creation for the status field. + user.DefaultStatus = userDescStatus.Default.(int8) + // userDescIsSystem is the schema descriptor for is_system field. + userDescIsSystem := userFields[14].Descriptor() + // user.DefaultIsSystem holds the default value on creation for the is_system field. + user.DefaultIsSystem = userDescIsSystem.Default.(bool) + // userDescLastLoginIP is the schema descriptor for last_login_ip field. + userDescLastLoginIP := userFields[15].Descriptor() + // user.DefaultLastLoginIP holds the default value on creation for the last_login_ip field. + user.DefaultLastLoginIP = userDescLastLoginIP.Default.(string) + // user.LastLoginIPValidator is a validator for the "last_login_ip" field. It is called by the builders before save. + user.LastLoginIPValidator = userDescLastLoginIP.Validators[0].(func(string) error) +} diff --git a/internal/features/system/data/ent/runtime/runtime.go b/internal/features/system/data/ent/runtime/runtime.go new file mode 100644 index 00000000..6876c351 --- /dev/null +++ b/internal/features/system/data/ent/runtime/runtime.go @@ -0,0 +1,10 @@ +// Code generated by ent, DO NOT EDIT. + +package runtime + +// The schema-stitching logic is generated in origadmin/application/admin/internal/features/system/data/ent/runtime.go + +const ( + Version = "v0.14.5" // Version of ent codegen. + Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen. +) diff --git a/internal/features/system/data/ent/schema/permission.go b/internal/features/system/data/ent/schema/permission.go new file mode 100644 index 00000000..0e27e5fd --- /dev/null +++ b/internal/features/system/data/ent/schema/permission.go @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package schema implements the functions, types, and interfaces for the module. +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/mixin" +) + +// Permission holds the schema definition for the Permission entity. +type Permission struct { + ent.Schema +} + +// DataScope 数据范围 +const ( + DataScopeSelf string = "self" // 仅本人数据 + DataScopeDept string = "dept" // 部门数据 + DataScopeRole string = "role" // 角色数据 + DataScopeAll string = "all" // 所有数据 +) + +func (Permission) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_permissions"), + entsql.WithComments(true), + schema.Comment("Permission table"), + } +} + +// Fields of the Permission. +func (Permission) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id"). + Comment("ID"). + Immutable(). + Unique(), + field.String("name").MaxLen(64).Default("").Comment("Name"), + field.String("keyword").MaxLen(64).Unique().Comment("Keyword"), + field.String("description").MaxLen(1024).Default("").Comment("Description"), + field.String("data_scope").Default(DataScopeSelf).Comment("Data scope"), + field.JSON("data_rules", map[string]string{}).Optional().Comment("Data rules"), + field.Enum("actions").Values("read", "write", "delete", "manage").Default("read").Comment("Actions"), + } +} + +// Mixin of the Permission. +func (Permission) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixin.Time{}, + } +} + +// Edges of the Permission. +func (Permission) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("roles", Role.Type). + Ref("permissions"). + Through("role_permissions", RolePermission.Type), + edge.To("resources", Resource.Type). + Through("permission_resources", PermissionResource.Type), + } +} diff --git a/internal/features/system/data/ent/schema/permissionresource.go b/internal/features/system/data/ent/schema/permissionresource.go new file mode 100644 index 00000000..ce0cbbad --- /dev/null +++ b/internal/features/system/data/ent/schema/permissionresource.go @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package schema implements the functions, types, and interfaces for the module. +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +type PermissionResource struct { + ent.Schema +} + +func (PermissionResource) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_permission_resources"), + entsql.WithComments(true), + schema.Comment("Permission-Resource mapping table"), + } +} + +func (PermissionResource) Fields() []ent.Field { + return []ent.Field{ + field.Int64("permission_id"), + field.Int64("resource_id"), + } +} + +func (PermissionResource) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("permission_id", "resource_id"). + Unique(), + } +} + +func (PermissionResource) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("permission", Permission.Type). + Field("permission_id"). + Unique(). + Required(), + edge.To("resource", Resource.Type). + Field("resource_id"). + Unique(). + Required(), + } +} diff --git a/internal/features/system/data/ent/schema/resource.go b/internal/features/system/data/ent/schema/resource.go new file mode 100644 index 00000000..7dab39d5 --- /dev/null +++ b/internal/features/system/data/ent/schema/resource.go @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package schema implements the functions, types, and interfaces for the module. +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" +) + +const ( + ResourceStatusEnabled int8 = 1 // 启用 + ResourceStatusDisabled int8 = 2 // 禁用 +) +const ( + ResourceTypeUnknown = "U" // 未知 + ResourceTypeRoot = "ROOT" // 根目录 + ResourceTypeGroup = "G" // 分组 + ResourceTypeMenu = "M" // 目录 + ResourceTypePage = "P" // 页面 + ResourceTypeButton = "B" // 按钮 + ResourceTypeAPI = "A" // API接口 + ResourceTypeRedirect = "R" // 重定向 + +) + +// Resource holds the schema definition for the Resource domain. +type Resource struct { + ent.Schema +} + +func (Resource) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_resources"), + entsql.WithComments(true), + schema.Comment("Resource table"), + } +} + +// Fields of the Resource. +func (Resource) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id"). + Comment("ID"). + Immutable(). + Unique(), + field.String("name").MaxLen(128).Default("").Comment("Name"), + field.String("keyword").MaxLen(64).Unique().Comment("Keyword"), + field.String("type").MaxLen(2).Default(ResourceTypeMenu).Comment("Type"), + field.Int8("status").Default(ResourceStatusEnabled).Comment("Status"), + field.String("path").MaxLen(256).Default("").Comment("Path"), + field.String("component").MaxLen(128).Default("").Comment("Component"), + field.String("icon").MaxLen(64).Default("").Comment("Icon"), + field.Int("sequence").Default(0).Comment("Sequence"), + field.Bool("visible").Default(true).Comment("Visible"), + field.Int8("level").Default(0).Comment("Level"), + field.String("tree_path").MaxLen(256).Default("").Comment("Tree path"), + field.JSON("properties", map[string]string{}).Optional().Comment("Properties"), + field.String("description").MaxLen(1024).Default("").Comment("Description"), + field.Int64("parent_id").Optional().Comment("Parent ID"), + } +} + +// Mixin of the Resource. +func (Resource) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixin.Time{}, + } +} + +// Indexes of the Resource. +func (Resource) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("parent_id"), + index.Fields("level"), + } +} + +// Edges of the Resource. +func (Resource) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("children", Resource.Type).From("parent").Field("parent_id").Unique(), + edge.From("permissions", Permission.Type). + Ref("resources"). + Through("permission_resources", PermissionResource.Type), + } +} diff --git a/internal/features/system/data/ent/schema/role.go b/internal/features/system/data/ent/schema/role.go new file mode 100644 index 00000000..26cf9d14 --- /dev/null +++ b/internal/features/system/data/ent/schema/role.go @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package schema implements the functions, types, and interfaces for the module. +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" + + "origadmin/application/admin/internal/data/entity/ent/schema/types" +) + +// Role type constant +const ( + RoleTypeSystem int8 = 1 // System roles (e.g., Super Admin) + RoleTypeUser int8 = 2 // User roles (e.g., general user, operation, customer service) +) + +// Role holds the schema definition for the Role domain. +type Role struct { + ent.Schema +} + +func (Role) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_roles"), + entsql.WithComments(true), + schema.Comment("Role table"), + } +} + +// Fields of the Role. +func (Role) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id"). + Comment("ID"). + Immutable(). + Unique(), + field.String("keyword"). + MaxLen(32). + Unique(). + Comment("keyword of role (unique)"), + field.String("name"). + MaxLen(128). + Default(""). + Comment("Display name of role"), + field.String("description"). + MaxLen(1024). + Default(""). + Comment("Details about role"), + field.Int8("type"). + Default(RoleTypeUser). + Comment("Role type: 1 - System role 2 - User role 3 - Department role"), + field.Int("sequence"). + Default(0). + Comment("Sequence for sorting"), + field.Int8("status"). + Default(types.Active). + Comment("status"), + } +} + +// Mixin of the Role. +func (Role) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixin.Time{}, + } +} + +// Indexes of the Role. +func (Role) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("keyword"), + index.Fields("name"), + index.Fields("sequence"), + index.Fields("status"), + } +} + +// Edges of the Role. +func (Role) Edges() []ent.Edge { + return []ent.Edge{ + edge.From("users", User.Type). + Ref("roles"). + Through("user_roles", UserRole.Type), + edge.To("permissions", Permission.Type). + StorageKey(edge.Columns("role_id", "permission_id")). + Through("role_permissions", RolePermission.Type), + } +} diff --git a/internal/features/system/data/ent/schema/rolepermission.go b/internal/features/system/data/ent/schema/rolepermission.go new file mode 100644 index 00000000..5b96f816 --- /dev/null +++ b/internal/features/system/data/ent/schema/rolepermission.go @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package schema implements the functions, types, and interfaces for the module. +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +// RolePermission holds the schema definition for the RolePermission entity. +type RolePermission struct { + ent.Schema +} + +func (RolePermission) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_role_permissions"), + entsql.WithComments(true), + schema.Comment("Role-Permission mapping table"), + } +} + +// Fields of the RolePermission. +func (RolePermission) Fields() []ent.Field { + return []ent.Field{ + field.Int64("role_id"), + field.Int64("permission_id"), + } +} + +// Indexes of the RolePermission. +func (RolePermission) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("role_id", "permission_id"). + Unique(), + } +} + +// Edges of the RolePermission. +func (RolePermission) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("role", Role.Type). + Field("role_id"). + Unique(). + Required(), + edge.To("permission", Permission.Type). + Field("permission_id"). + Unique(). + Required(), + } +} diff --git a/internal/features/system/data/ent/schema/user.go b/internal/features/system/data/ent/schema/user.go new file mode 100644 index 00000000..3008ff96 --- /dev/null +++ b/internal/features/system/data/ent/schema/user.go @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package schema implements the functions, types, and interfaces for the module. +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" + "entgo.io/ent/schema/mixin" + + "origadmin/application/admin/internal/data/entity/ent/schema/types" +) + +const ( + UserStatusActive = types.Active + UserStatusFrozen = types.Frozen +) + +const ( + UserGenderMale = "male" + UserGenderFemale = "female" + UserGenderUnknown = "unknown" +) + +// User holds the schema definition for the User domain. +type User struct { + ent.Schema +} + +func (User) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_users"), + entsql.WithComments(true), + schema.Comment("User table"), + } +} + +// Fields of the User. +func (User) Fields() []ent.Field { + return []ent.Field{ + field.Int64("id"). + Comment("ID"). + Immutable(). + Unique(), + field.String("uuid").MaxLen(36).Unique().Comment("UUID"), + field.String("allowed_ip").Default("0.0.0.0").Comment("Allowed IP"), + field.String("username").MaxLen(32).Unique().Comment("login username of user"), + field.String("nickname").MaxLen(64).Default("").Comment("Nickname display name of user"), + field.String("avatar").MaxLen(256).Default("").Comment("Avatar display avatar of user"), + field.String("name").MaxLen(64).Default("").Comment("Name of user"), + field.Enum("gender").Values(UserGenderMale, UserGenderFemale, UserGenderUnknown).Default(UserGenderUnknown).Comment("Gender of user"), + field.String("password").MaxLen(256).Default("").Sensitive().Comment("Encrypted password"), + field.String("phone").MaxLen(32).Default("").Comment("login phone number of user"), + field.String("email").MaxLen(64).Default("").Comment("login email of user"), + field.String("department").MaxLen(64).Default("").Comment("Department of user"), + field.String("remark").MaxLen(1024).Default("").Comment("Remark of user"), + field.Int8("status").Default(UserStatusActive).Comment("status"), + field.Bool("is_system").Default(false).Comment("Whether the system is built-in"), + field.String("last_login_ip").MaxLen(32).Default("").Comment("Last login IP"), + field.Time("last_login_time").Optional().Comment("Last login time"), + } +} + +// Mixin of the User. +func (User) Mixin() []ent.Mixin { + return []ent.Mixin{ + mixin.Time{}, + } +} + +// Indexes of the User. +func (User) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("username"), + index.Fields("phone"), + index.Fields("email"), + index.Fields("status"), + } +} + +// Edges of the User. +func (User) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("roles", Role.Type). + Through("user_roles", UserRole.Type), + } +} diff --git a/internal/features/system/data/ent/schema/userrole.go b/internal/features/system/data/ent/schema/userrole.go new file mode 100644 index 00000000..aff01384 --- /dev/null +++ b/internal/features/system/data/ent/schema/userrole.go @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package schema implements the functions, types, and interfaces for the module. +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" +) + +// UserRole holds the schema definition for the UserRole domain. +type UserRole struct { + ent.Schema +} + +func (UserRole) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_user_roles"), + entsql.WithComments(true), + schema.Comment("User-Role mapping table"), + } +} + +// Fields of the UserRole. +func (UserRole) Fields() []ent.Field { + return []ent.Field{ + field.Int64("user_id"), + field.Int64("role_id"), + } +} + +// Indexes of the UserRole. +func (UserRole) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("user_id", "role_id"). + Unique(), + } +} + +// Edges of the UserRole. +func (UserRole) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("user", User.Type). + Field("user_id"). + Required(). + Unique(), + edge.To("role", Role.Type). + Field("role_id"). + Required(). + Unique(), + } +} diff --git a/internal/features/system/data/ent/template/crud.tpl b/internal/features/system/data/ent/template/crud.tpl new file mode 100644 index 00000000..d119b8c5 --- /dev/null +++ b/internal/features/system/data/ent/template/crud.tpl @@ -0,0 +1,40 @@ +{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} +{{/* gotype: entgo.io/ent/entc/gen.Graph */}} + +{{ define "crud" }} + {{- $pkg := base $.Config.Package -}} + {{- template "header" $ -}} + + {{/* Additional dependencies injected to config. */}} + {{ $deps := list }}{{ with $.Config.Annotations }}{{ $deps = $.Config.Annotations.Dependencies }}{{ end }} + + import ( + "log" + + "entgo.io/ent/dialect" + + {{- range $n := $.Nodes }} + {{ $n.PackageAlias }} "{{ $n.Config.Package }}/{{ $n.PackageDir }}" + {{- end }} + {{- range $dep := $deps }} + {{ $dep.Type.PkgName }} "{{ $dep.Type.PkgPath }}" + {{- end }} + "{{ $.Config.Package }}/migrate" + {{- range $import := $.Storage.Imports }} + "{{ $import }}" + {{- end -}} + {{- template "import/additional" $ }} + ) + + {{ range $n := $.Nodes }} + {{- /* Support adding create methods by global templates. */}} + {{- with $tmpls := matchTemplate "crud/helper/*" }} + {{- range $tmpl := $tmpls }} + {{ xtemplate $tmpl $n }} + {{- end }} + {{- end }} + {{ end }} + +{{ end }} + + diff --git a/internal/features/system/data/ent/template/crud_create.tpl b/internal/features/system/data/ent/template/crud_create.tpl new file mode 100644 index 00000000..bfd1fa84 --- /dev/null +++ b/internal/features/system/data/ent/template/crud_create.tpl @@ -0,0 +1,34 @@ +{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} +{{/* gotype: entgo.io/ent/entc/gen.Graph */}} + +{{ define "create/additional/crud" }} + + {{ $builder := .CreateName }} + {{ $receiver := .CreateReceiver }} + {{ $fields := .Fields }} + {{- $const := print .Package}} + {{- if .ID.UserDefined }} + {{ $fields = append $fields .ID }} + {{- end }} + + {{ print "// Set" .Name " set the " .Name }} + func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { + m := {{ $receiver }}.mutation + if len(fields) == 0 { + fields = {{ $const }}.Columns + } + _ = m.SetFields(input, fields...) + return {{ $receiver }} + } + + {{ print "// Set" .Name "WithZero set the " .Name }} + func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { + m := {{ $receiver }}.mutation + if len(fields) == 0 { + fields = {{ $const }}.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return {{ $receiver }} + } + +{{- end -}} diff --git a/internal/features/system/data/ent/template/crud_query.tpl b/internal/features/system/data/ent/template/crud_query.tpl new file mode 100644 index 00000000..da033c1d --- /dev/null +++ b/internal/features/system/data/ent/template/crud_query.tpl @@ -0,0 +1,48 @@ +{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} +{{/* gotype: entgo.io/ent/entc/gen.Type */}} + +{{ define "query/additional/crud" }} + + {{ $pkg := .Package }} + {{ $fields := .Fields }} + {{ $builder := .QueryName }} + {{ $receiver := receiver $builder }} + {{ $selectBuilder := pascal .Name | printf "%sSelect" }} + + // Omit allows the unselect one or more fields/columns for the given query, + // instead of selecting all fields in the entity. + {{- with len $fields }} + // Example: + // + // var v []struct { + {{- range $f := $fields }} + // {{ $f.StructField }} {{ $f.Type }} `{{ $f.StructTag }}` + {{- end }} + // } + // + // client.{{ pascal $.Name }}.Query(). + // Omit( + {{- range $f := $fields }} + // {{ $pkg }}.{{ $f.Constant }}, + {{- end }} + // ). + // Scan(ctx, &v) + {{- end }} + func ({{ $receiver }} *{{ $builder }}) Omit(fields ...string) *{{ $selectBuilder }} { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range {{ $pkg }}.Columns { + if _, ok := omits[col]; !ok { + {{ $receiver }}.ctx.Fields = append({{ $receiver }}.ctx.Fields, col) + } + } + + sbuild := &{{ $selectBuilder }}{ {{ $builder }}: {{ $receiver }} } + sbuild.label = {{ $pkg }}.Label + sbuild.flds, sbuild.scan = &{{ $receiver }}.ctx.Fields, sbuild.Scan + return sbuild + } + +{{- end -}} diff --git a/internal/features/system/data/ent/template/crud_update.tpl b/internal/features/system/data/ent/template/crud_update.tpl new file mode 100644 index 00000000..17b34147 --- /dev/null +++ b/internal/features/system/data/ent/template/crud_update.tpl @@ -0,0 +1,33 @@ +{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} +{{/* gotype: entgo.io/ent/entc/gen.Graph */}} + +{{ define "update/additional/crud/update" }} + + {{ $builder := .UpdateName }} + {{ $receiver := receiver $builder }} + {{ $fields := .Fields }} + {{- if or (hasSuffix $builder "Update") (hasSuffix $builder "UpdateOne") }} + {{ $fields = .MutableFields }} + {{- end }} + + {{ print "// Set" .Name " set the " .Name }} + func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { + {{- $const := print .Package}} + m := {{ $receiver }}.mutation + if len(fields) == 0 { + fields = {{$const}}.OmitColumns({{$const}}.FieldID) + } + _ = m.SetFields(input, fields...) + return {{ $receiver }} + } + + {{ print "// Set" .Name "WithZero set the " .Name }} + func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { + m := {{ $receiver }}.mutation + if len(fields) == 0 { + fields = {{ $const }}.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return {{ $receiver }} + } +{{- end -}} diff --git a/internal/features/system/data/ent/template/crud_update_one.tpl b/internal/features/system/data/ent/template/crud_update_one.tpl new file mode 100644 index 00000000..e384a498 --- /dev/null +++ b/internal/features/system/data/ent/template/crud_update_one.tpl @@ -0,0 +1,48 @@ +{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} +{{/* gotype: entgo.io/ent/entc/gen.Graph */}} + +{{ define "update/additional/crud_one" }} + {{ $builder := $.UpdateOneName }} + {{- if hasSuffix $builder "UpdateOne" }} + {{ $receiver := receiver $builder }} + {{ print "// Set" .Name " set the " .Name }} + func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { + {{- $const := print .Package}} + m := {{ $receiver }}.mutation + if len(fields) == 0 { + fields = {{$const}}.OmitColumns({{$const}}.FieldID) + } + _ = m.SetFields(input, fields...) + return {{ $receiver }} + } + + {{ print "// Set" .Name "WithZero set the " .Name }} + func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { + m := {{ $receiver }}.mutation + if len(fields) == 0 { + fields = {{ $const }}.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return {{ $receiver }} + } + + {{ $onebuilder := $.UpdateOneName }} + {{ $receiver = receiver $onebuilder }} + // Omit allows the unselect one or more fields/columns for the given query, + // instead of selecting all fields in the entity. + func ({{ $receiver }} *{{ $onebuilder }}) Omit(fields ...string) *{{ $onebuilder }} { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + {{ $receiver }}.fields = []string(nil) + for _, col := range {{ .Package }}.Columns { + if _, ok := omits[col]; !ok { + {{ $receiver }}.fields = append({{ $receiver }}.fields, col) + } + } + return {{ $receiver }} + } + {{- end }} + +{{- end -}} diff --git a/internal/features/system/data/ent/template/database.tpl b/internal/features/system/data/ent/template/database.tpl new file mode 100644 index 00000000..05bbdd69 --- /dev/null +++ b/internal/features/system/data/ent/template/database.tpl @@ -0,0 +1,126 @@ +{{/* The line below tells Intellij/GoLand to enable the autocompletion based *gen.Type type. */}} +{{/* gotype: entgo.io/ent/entc/gen.Type */}} + + +{{ define "database" }} + {{ $pkg := base $.Config.Package -}} + {{ template "header" $ }} + + /* Additional dependencies injected to config. */ + {{ $deps := list }}{{ with $.Config.Annotations }}{{ $deps = $.Config.Annotations.Dependencies }}{{ end }} + + import ( + "context" + "fmt" + "entgo.io/ent/dialect/sql" + "github.com/origadmin/runtime/interfaces/storage/database" + ) + + // Database is the client that holds all ent builders. + type Database struct { + client *Client + } + + // NewDatabase creates a new database configured with the given options. + func NewDatabase(opts ...Option) *Database { + client := NewClient(opts...) + return &Database{client: client} + } + + // NewDatabase creates a new database configured with the given options. + func NewDatabaseWithClient(client *Client,opts ...Option) *Database { + if client == nil { + client = NewClient(opts...) + } + return &Database{client: client} + } + + func (db *Database) clientDriver(ctx context.Context) dialect.Driver { + tx := TxFromContext(ctx) + c := db.client + if tx != nil { + c = tx.Client() + } + return c.driver + } + + // Tx runs the given function f within a transaction. + func (db *Database) Tx(ctx context.Context, fn func(context.Context) error) error { + tx := TxFromContext(ctx) + if tx != nil { + return fn(ctx) + } + + return db.InTx(ctx, func (tx database.Tx) error { + txv, ok := tx.(*Tx) + if !ok { + return fmt.Errorf("ent: expected tx context") + } + return fn(NewTxContext(ctx, txv)) + }) + } + + // InTx runs the given function f within a transaction. + func (db *Database) InTx(ctx context.Context, fn func(tx database.Tx) error) error { + tx := TxFromContext(ctx) + if tx != nil { + return fn(tx) + } + tx, err := db.client.Tx(ctx) + if err != nil { + return fmt.Errorf("starting transaction: %w", err) + } + if err = fn(tx); err != nil { + if txerr := tx.Rollback(); txerr != nil { + return fmt.Errorf("rolling back transaction: %v (original error: %w)", txerr, err) + } + return err + } + if err := tx.Commit(); err != nil { + return fmt.Errorf("committing transaction: %w", err) + } + return nil + } + + // Client returns the client that holds all ent builders. + func (db *Database) Client(ctx context.Context) *Client { + tx := TxFromContext(ctx) + if tx != nil { + return tx.Client() + } + return db.client + } + + // Exec executes a query that doesn't return rows. For example, in SQL, INSERT or UPDATE. + func (db *Database) Exec(ctx context.Context, query string, args ...interface{}) (*sql.Result, error) { + var res sql.Result + err := db.clientDriver(ctx).Exec(ctx, query, args, &res) + if err != nil { + return nil, err + } + return &res, nil + } + + // Query executes a query that returns rows, typically a SELECT in SQL. + func (db *Database) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) { + var rows sql.Rows + err := db.clientDriver(ctx).Query(ctx, query, args, &rows) + if err != nil { + return nil, err + } + return &rows, nil + } + + {{ range $n := $.Nodes }} + {{ $client := print $n.Name "Client" }} + // {{ $n.Name }} is the client for interacting with the {{ $n.Name }} builders. + func (db *Database) {{ $n.Name }}(ctx context.Context) *{{ $client }} { + return db.Client(ctx).{{ $n.Name }} + } + {{ end }} + + func (db *Database) Migration(ctx context.Context,opts ...schema.MigrateOption) error { + return db.Client(ctx).Schema.Create(ctx, opts...) + } + +{{ end }} \ No newline at end of file diff --git a/internal/features/system/data/ent/template/mutation_fields.tpl b/internal/features/system/data/ent/template/mutation_fields.tpl new file mode 100644 index 00000000..3f9fd0e6 --- /dev/null +++ b/internal/features/system/data/ent/template/mutation_fields.tpl @@ -0,0 +1,119 @@ +{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} +{{/* gotype: entgo.io/ent/entc/gen.Graph */}} + +{{ define "mutation_fields" }} + {{- $pkg := base $.Config.Package -}} + {{- template "header" $ -}} + + {{/* Additional dependencies injected to config. */}} + {{ $deps := list }}{{ with $.Config.Annotations }}{{ $deps = $.Config.Annotations.Dependencies }}{{ end }} + + import ( + "log" + + "entgo.io/ent/dialect" + + {{- range $n := $.Nodes }} + {{ $n.PackageAlias }} "{{ $n.Config.Package }}/{{ $n.PackageDir }}" + {{- end }} + {{- range $dep := $deps }} + {{ $dep.Type.PkgName }} "{{ $dep.Type.PkgPath }}" + {{- end }} + "{{ $.Config.Package }}/migrate" + {{- range $import := $.Storage.Imports }} + "{{ $import }}" + {{- end -}} + {{- template "import/additional" $ }} + ) + + {{ range $n := $.MutableNodes }} + {{ $fields := $n.Fields }} + {{- if .ID.UserDefined }} + {{ $fields = append $fields .ID }} + {{- end }} + {{ $mutation := $n.MutationName }} + // SetFields sets the values of the fields with the given names. It returns an + // error if the field is not defined in the schema, or if the type mismatched the + // field type. + func (m *{{ $mutation }}) SetFields(input *{{ .Name }}, fields ...string) error { + for i := range fields { + switch fields[i] { + {{- range $f := $fields }} + {{- $const := print $n.Package "." $f.Constant }} + {{- $setter := print "Set" $f.StructField }} + {{- $clear := print "Reset" $f.StructField }} + case {{ $const }}: + {{- if $f.Nillable}} + if input.{{ $f.StructField }} != nil { + m.{{ $setter }}(*input.{{ $f.StructField }}) + }else{ + m.{{ $clear }}() + } + {{- else if $f.IsBool}} + if input.{{ $f.StructField }} { + m.{{ $setter }}(input.{{ $f.StructField }}) + } + {{- else if $f.IsTime}} + if input.{{ $f.StructField }}.Unix() != 0 { + m.{{ $setter }}(input.{{ $f.StructField }}) + } + {{- else if $f.IsJSON}} + if len(input.{{ $f.StructField }}) > 0 { + m.{{ $setter }}(input.{{ $f.StructField }}) + } + {{- else if $f.IsString}} + // check {{$f.Type}} with {{$f.ScanType}} if it is empty + if input.{{ $f.StructField }} != "" { + m.{{ $setter }}(input.{{ $f.StructField }}) + } + {{- else if $f.Type.Numeric}} + // check {{$f.Type}} with {{$f.ScanType}} if it is zero + if input.{{ $f.StructField }} != 0 { + m.{{ $setter }}(input.{{ $f.StructField }}) + } + {{- else }} + var zero {{ $f.Type }} + // check {{$f.Type}} with {{$f.ScanType}} if it is empty + if input.{{ $f.StructField }} != zero { + m.{{ $setter }}(input.{{ $f.StructField }}) + } + {{- end}} + {{- end }} + default: + return fmt.Errorf("unknown {{ .Name }} field %s", fields[i]) + } + } + return nil + } + + // SetFieldsWithZero sets the values of the fields with the given names. It returns an + // error if the field is not defined in the schema, or if the type mismatched the + // field type. + func (m *{{ $mutation }}) SetFieldsWithZero(input *{{ .Name }}, fields ...string) error { + for i := range fields { + switch fields[i] { + {{- range $f := $fields }} + {{- $const := print $n.Package "." $f.Constant }} + {{- $setter := print "Set" $f.StructField }} + {{- $clear := print "Reset" $f.StructField }} + case {{ $const }}: + {{- if $f.Nillable}} + if input.{{ $f.StructField }}!= nil { + m.{{ $setter }}(*input.{{ $f.StructField }}) + }else{ + m.{{ $clear }}() + } + {{- else}} + m.{{ $setter }}(input.{{ $f.StructField }}) + {{- end}} + {{- end }} + default: + return fmt.Errorf("unknown {{ .Name }} field %s", fields[i]) + } + } + return nil + } + {{- end }} + +{{ end }} + diff --git a/internal/features/system/data/ent/template/type_meta_fields.tpl b/internal/features/system/data/ent/template/type_meta_fields.tpl new file mode 100644 index 00000000..5cd85559 --- /dev/null +++ b/internal/features/system/data/ent/template/type_meta_fields.tpl @@ -0,0 +1,67 @@ +{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} +{{/* gotype: entgo.io/ent/entc/gen.Type*/}} + +{{ define "meta/additional/fields" }} + + // SelectColumns returns all selected fields. + func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields + } + + // OmitColumns returns all fields that are not in the list of fields. + func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns,fields, true) + } + + // OmitCustomColumns returns all fields that are not in the list of fields. + func OmitCustomColumns(src []string,fields ...string) []string { + if len(src) == 0 { + src= Columns + } + // Default removal FieldID + return omitColumns(src,fields, true) + } + + // OmitColumnsWithID returns all fields that are not in the list of fields. + func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns,fields, false) + } + + // OmitCustomColumns returns all fields that are not in the list of fields. + func OmitCustomColumnsWithID(src []string,fields ...string) []string { + if len(src) == 0 { + src= Columns + } + // Not remove FieldID + return omitColumns(src,fields, false) + } + + func omitColumns(src []string,fields []string,omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields + } + + func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false + } +{{ end }} diff --git a/internal/features/system/data/ent/template/type_meta_where.tpl b/internal/features/system/data/ent/template/type_meta_where.tpl new file mode 100644 index 00000000..c0c8f095 --- /dev/null +++ b/internal/features/system/data/ent/template/type_meta_where.tpl @@ -0,0 +1,16 @@ +{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} +{{/* gotype: entgo.io/ent/entc/gen.Type*/}} + +{{ define "where/additional/with" }} +{{/* {{- $type := $.Name }}*/}} +{{/* {{- range $edge := $.Edges }}*/}} +{{/* {{- if $edge.StructField }}*/}} +{{/* {{ $func := print "With" $edge.StructField }}*/}} +{{/* // With{{ $edge.StructField }} tells the query-builder to eager-load the nodes that are connected to*/}} +{{/* // the "{{ $edge.StructField }}" edge. The optional arguments are used to configure the query builder of the edge.*/}} +{{/* func {{$func}}(query *{{ $edge.StructField }}Query) {*/}} +{{/* query.{{$func}}()*/}} +{{/* }*/}} +{{/* {{- end }}*/}} +{{/* {{- end }}*/}} +{{ end }} \ No newline at end of file diff --git a/internal/features/system/data/ent/tx.go b/internal/features/system/data/ent/tx.go new file mode 100644 index 00000000..f93d6ecc --- /dev/null +++ b/internal/features/system/data/ent/tx.go @@ -0,0 +1,228 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "sync" + + "entgo.io/ent/dialect" +) + +// Tx is a transactional client that is created by calling Client.Tx(). +type Tx struct { + config + // Permission is the client for interacting with the Permission builders. + Permission *PermissionClient + // PermissionResource is the client for interacting with the PermissionResource builders. + PermissionResource *PermissionResourceClient + // Resource is the client for interacting with the Resource builders. + Resource *ResourceClient + // Role is the client for interacting with the Role builders. + Role *RoleClient + // RolePermission is the client for interacting with the RolePermission builders. + RolePermission *RolePermissionClient + // User is the client for interacting with the User builders. + User *UserClient + // UserRole is the client for interacting with the UserRole builders. + UserRole *UserRoleClient + + // lazily loaded. + client *Client + clientOnce sync.Once + // ctx lives for the life of the transaction. It is + // the same context used by the underlying connection. + ctx context.Context +} + +type ( + // Committer is the interface that wraps the Commit method. + Committer interface { + Commit(context.Context, *Tx) error + } + + // The CommitFunc type is an adapter to allow the use of ordinary + // function as a Committer. If f is a function with the appropriate + // signature, CommitFunc(f) is a Committer that calls f. + CommitFunc func(context.Context, *Tx) error + + // CommitHook defines the "commit middleware". A function that gets a Committer + // and returns a Committer. For example: + // + // hook := func(next ent.Committer) ent.Committer { + // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Commit(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + CommitHook func(Committer) Committer +) + +// Commit calls f(ctx, m). +func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Commit commits the transaction. +func (tx *Tx) Commit() error { + txDriver := tx.config.driver.(*txDriver) + var fn Committer = CommitFunc(func(context.Context, *Tx) error { + return txDriver.tx.Commit() + }) + txDriver.mu.Lock() + hooks := append([]CommitHook(nil), txDriver.onCommit...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Commit(tx.ctx, tx) +} + +// OnCommit adds a hook to call on commit. +func (tx *Tx) OnCommit(f CommitHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onCommit = append(txDriver.onCommit, f) + txDriver.mu.Unlock() +} + +type ( + // Rollbacker is the interface that wraps the Rollback method. + Rollbacker interface { + Rollback(context.Context, *Tx) error + } + + // The RollbackFunc type is an adapter to allow the use of ordinary + // function as a Rollbacker. If f is a function with the appropriate + // signature, RollbackFunc(f) is a Rollbacker that calls f. + RollbackFunc func(context.Context, *Tx) error + + // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker + // and returns a Rollbacker. For example: + // + // hook := func(next ent.Rollbacker) ent.Rollbacker { + // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { + // // Do some stuff before. + // if err := next.Rollback(ctx, tx); err != nil { + // return err + // } + // // Do some stuff after. + // return nil + // }) + // } + // + RollbackHook func(Rollbacker) Rollbacker +) + +// Rollback calls f(ctx, m). +func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { + return f(ctx, tx) +} + +// Rollback rollbacks the transaction. +func (tx *Tx) Rollback() error { + txDriver := tx.config.driver.(*txDriver) + var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { + return txDriver.tx.Rollback() + }) + txDriver.mu.Lock() + hooks := append([]RollbackHook(nil), txDriver.onRollback...) + txDriver.mu.Unlock() + for i := len(hooks) - 1; i >= 0; i-- { + fn = hooks[i](fn) + } + return fn.Rollback(tx.ctx, tx) +} + +// OnRollback adds a hook to call on rollback. +func (tx *Tx) OnRollback(f RollbackHook) { + txDriver := tx.config.driver.(*txDriver) + txDriver.mu.Lock() + txDriver.onRollback = append(txDriver.onRollback, f) + txDriver.mu.Unlock() +} + +// Client returns a Client that binds to current transaction. +func (tx *Tx) Client() *Client { + tx.clientOnce.Do(func() { + tx.client = &Client{config: tx.config} + tx.client.init() + }) + return tx.client +} + +func (tx *Tx) init() { + tx.Permission = NewPermissionClient(tx.config) + tx.PermissionResource = NewPermissionResourceClient(tx.config) + tx.Resource = NewResourceClient(tx.config) + tx.Role = NewRoleClient(tx.config) + tx.RolePermission = NewRolePermissionClient(tx.config) + tx.User = NewUserClient(tx.config) + tx.UserRole = NewUserRoleClient(tx.config) +} + +// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. +// The idea is to support transactions without adding any extra code to the builders. +// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. +// Commit and Rollback are nop for the internal builders and the user must call one +// of them in order to commit or rollback the transaction. +// +// If a closed transaction is embedded in one of the generated entities, and the entity +// applies a query, for example: Permission.QueryXXX(), the query will be executed +// through the driver which created this transaction. +// +// Note that txDriver is not goroutine safe. +type txDriver struct { + // the driver we started the transaction from. + drv dialect.Driver + // tx is the underlying transaction. + tx dialect.Tx + // completion hooks. + mu sync.Mutex + onCommit []CommitHook + onRollback []RollbackHook +} + +// newTx creates a new transactional driver. +func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { + tx, err := drv.Tx(ctx) + if err != nil { + return nil, err + } + return &txDriver{tx: tx, drv: drv}, nil +} + +// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls +// from the internal builders. Should be called only by the internal builders. +func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } + +// Dialect returns the dialect of the driver we started the transaction from. +func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } + +// Close is a nop close. +func (*txDriver) Close() error { return nil } + +// Commit is a nop commit for the internal builders. +// User must call `Tx.Commit` in order to commit the transaction. +func (*txDriver) Commit() error { return nil } + +// Rollback is a nop rollback for the internal builders. +// User must call `Tx.Rollback` in order to rollback the transaction. +func (*txDriver) Rollback() error { return nil } + +// Exec calls tx.Exec. +func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error { + return tx.tx.Exec(ctx, query, args, v) +} + +// Query calls tx.Query. +func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error { + return tx.tx.Query(ctx, query, args, v) +} + +var _ dialect.Driver = (*txDriver)(nil) diff --git a/internal/features/system/data/ent/user.go b/internal/features/system/data/ent/user.go new file mode 100644 index 00000000..20bac1cf --- /dev/null +++ b/internal/features/system/data/ent/user.go @@ -0,0 +1,337 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/user" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// User table +type User struct { + config `json:"-"` + // ID of the ent. + // ID + ID int64 `json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime time.Time `json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime time.Time `json:"update_time,omitempty"` + // UUID + UUID string `json:"uuid,omitempty"` + // Allowed IP + AllowedIP string `json:"allowed_ip,omitempty"` + // login username of user + Username string `json:"username,omitempty"` + // Nickname display name of user + Nickname string `json:"nickname,omitempty"` + // Avatar display avatar of user + Avatar string `json:"avatar,omitempty"` + // Name of user + Name string `json:"name,omitempty"` + // Gender of user + Gender user.Gender `json:"gender,omitempty"` + // Encrypted password + Password string `json:"-"` + // login phone number of user + Phone string `json:"phone,omitempty"` + // login email of user + Email string `json:"email,omitempty"` + // Department of user + Department string `json:"department,omitempty"` + // Remark of user + Remark string `json:"remark,omitempty"` + // status + Status int8 `json:"status,omitempty"` + // Whether the system is built-in + IsSystem bool `json:"is_system,omitempty"` + // Last login IP + LastLoginIP string `json:"last_login_ip,omitempty"` + // Last login time + LastLoginTime time.Time `json:"last_login_time,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the UserQuery when eager-loading is set. + Edges UserEdges `json:"edges"` + selectValues sql.SelectValues +} + +// UserEdges holds the relations/edges for other nodes in the graph. +type UserEdges struct { + // Roles holds the value of the roles edge. + Roles []*Role `json:"roles,omitempty"` + // UserRoles holds the value of the user_roles edge. + UserRoles []*UserRole `json:"user_roles,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// RolesOrErr returns the Roles value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) RolesOrErr() ([]*Role, error) { + if e.loadedTypes[0] { + return e.Roles, nil + } + return nil, &NotLoadedError{edge: "roles"} +} + +// UserRolesOrErr returns the UserRoles value or an error if the edge +// was not loaded in eager-loading. +func (e UserEdges) UserRolesOrErr() ([]*UserRole, error) { + if e.loadedTypes[1] { + return e.UserRoles, nil + } + return nil, &NotLoadedError{edge: "user_roles"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*User) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case user.FieldIsSystem: + values[i] = new(sql.NullBool) + case user.FieldID, user.FieldStatus: + values[i] = new(sql.NullInt64) + case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldPassword, user.FieldPhone, user.FieldEmail, user.FieldDepartment, user.FieldRemark, user.FieldLastLoginIP: + values[i] = new(sql.NullString) + case user.FieldCreateTime, user.FieldUpdateTime, user.FieldLastLoginTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the User fields. +func (_m *User) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case user.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case user.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = value.Time + } + case user.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = value.Time + } + case user.FieldUUID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field uuid", values[i]) + } else if value.Valid { + _m.UUID = value.String + } + case user.FieldAllowedIP: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field allowed_ip", values[i]) + } else if value.Valid { + _m.AllowedIP = value.String + } + case user.FieldUsername: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field username", values[i]) + } else if value.Valid { + _m.Username = value.String + } + case user.FieldNickname: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field nickname", values[i]) + } else if value.Valid { + _m.Nickname = value.String + } + case user.FieldAvatar: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field avatar", values[i]) + } else if value.Valid { + _m.Avatar = value.String + } + case user.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case user.FieldGender: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field gender", values[i]) + } else if value.Valid { + _m.Gender = user.Gender(value.String) + } + case user.FieldPassword: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field password", values[i]) + } else if value.Valid { + _m.Password = value.String + } + case user.FieldPhone: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field phone", values[i]) + } else if value.Valid { + _m.Phone = value.String + } + case user.FieldEmail: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field email", values[i]) + } else if value.Valid { + _m.Email = value.String + } + case user.FieldDepartment: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field department", values[i]) + } else if value.Valid { + _m.Department = value.String + } + case user.FieldRemark: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field remark", values[i]) + } else if value.Valid { + _m.Remark = value.String + } + case user.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = int8(value.Int64) + } + case user.FieldIsSystem: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_system", values[i]) + } else if value.Valid { + _m.IsSystem = value.Bool + } + case user.FieldLastLoginIP: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field last_login_ip", values[i]) + } else if value.Valid { + _m.LastLoginIP = value.String + } + case user.FieldLastLoginTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field last_login_time", values[i]) + } else if value.Valid { + _m.LastLoginTime = value.Time + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the User. +// This includes values selected through modifiers, order, etc. +func (_m *User) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryRoles queries the "roles" edge of the User entity. +func (_m *User) QueryRoles() *RoleQuery { + return NewUserClient(_m.config).QueryRoles(_m) +} + +// QueryUserRoles queries the "user_roles" edge of the User entity. +func (_m *User) QueryUserRoles() *UserRoleQuery { + return NewUserClient(_m.config).QueryUserRoles(_m) +} + +// Update returns a builder for updating this User. +// Note that you need to call User.Unwrap() before calling this method if this User +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *User) Update() *UserUpdateOne { + return NewUserClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the User entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *User) Unwrap() *User { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: User is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *User) String() string { + var builder strings.Builder + builder.WriteString("User(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("create_time=") + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("uuid=") + builder.WriteString(_m.UUID) + builder.WriteString(", ") + builder.WriteString("allowed_ip=") + builder.WriteString(_m.AllowedIP) + builder.WriteString(", ") + builder.WriteString("username=") + builder.WriteString(_m.Username) + builder.WriteString(", ") + builder.WriteString("nickname=") + builder.WriteString(_m.Nickname) + builder.WriteString(", ") + builder.WriteString("avatar=") + builder.WriteString(_m.Avatar) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("gender=") + builder.WriteString(fmt.Sprintf("%v", _m.Gender)) + builder.WriteString(", ") + builder.WriteString("password=") + builder.WriteString(", ") + builder.WriteString("phone=") + builder.WriteString(_m.Phone) + builder.WriteString(", ") + builder.WriteString("email=") + builder.WriteString(_m.Email) + builder.WriteString(", ") + builder.WriteString("department=") + builder.WriteString(_m.Department) + builder.WriteString(", ") + builder.WriteString("remark=") + builder.WriteString(_m.Remark) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("is_system=") + builder.WriteString(fmt.Sprintf("%v", _m.IsSystem)) + builder.WriteString(", ") + builder.WriteString("last_login_ip=") + builder.WriteString(_m.LastLoginIP) + builder.WriteString(", ") + builder.WriteString("last_login_time=") + builder.WriteString(_m.LastLoginTime.Format(time.ANSIC)) + builder.WriteByte(')') + return builder.String() +} + +// Users is a parsable slice of User. +type Users []*User diff --git a/internal/features/system/data/ent/user/user.go b/internal/features/system/data/ent/user/user.go new file mode 100644 index 00000000..2b17d732 --- /dev/null +++ b/internal/features/system/data/ent/user/user.go @@ -0,0 +1,395 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +import ( + "fmt" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the user type in the database. + Label = "user" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldUUID holds the string denoting the uuid field in the database. + FieldUUID = "uuid" + // FieldAllowedIP holds the string denoting the allowed_ip field in the database. + FieldAllowedIP = "allowed_ip" + // FieldUsername holds the string denoting the username field in the database. + FieldUsername = "username" + // FieldNickname holds the string denoting the nickname field in the database. + FieldNickname = "nickname" + // FieldAvatar holds the string denoting the avatar field in the database. + FieldAvatar = "avatar" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldGender holds the string denoting the gender field in the database. + FieldGender = "gender" + // FieldPassword holds the string denoting the password field in the database. + FieldPassword = "password" + // FieldPhone holds the string denoting the phone field in the database. + FieldPhone = "phone" + // FieldEmail holds the string denoting the email field in the database. + FieldEmail = "email" + // FieldDepartment holds the string denoting the department field in the database. + FieldDepartment = "department" + // FieldRemark holds the string denoting the remark field in the database. + FieldRemark = "remark" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldIsSystem holds the string denoting the is_system field in the database. + FieldIsSystem = "is_system" + // FieldLastLoginIP holds the string denoting the last_login_ip field in the database. + FieldLastLoginIP = "last_login_ip" + // FieldLastLoginTime holds the string denoting the last_login_time field in the database. + FieldLastLoginTime = "last_login_time" + // EdgeRoles holds the string denoting the roles edge name in mutations. + EdgeRoles = "roles" + // EdgeUserRoles holds the string denoting the user_roles edge name in mutations. + EdgeUserRoles = "user_roles" + // Table holds the table name of the user in the database. + Table = "sys_users" + // RolesTable is the table that holds the roles relation/edge. The primary key declared below. + RolesTable = "sys_user_roles" + // RolesInverseTable is the table name for the Role entity. + // It exists in this package in order to avoid circular dependency with the "role" package. + RolesInverseTable = "sys_roles" + // UserRolesTable is the table that holds the user_roles relation/edge. + UserRolesTable = "sys_user_roles" + // UserRolesInverseTable is the table name for the UserRole entity. + // It exists in this package in order to avoid circular dependency with the "userrole" package. + UserRolesInverseTable = "sys_user_roles" + // UserRolesColumn is the table column denoting the user_roles relation/edge. + UserRolesColumn = "user_id" +) + +// Columns holds all SQL columns for user fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldUUID, + FieldAllowedIP, + FieldUsername, + FieldNickname, + FieldAvatar, + FieldName, + FieldGender, + FieldPassword, + FieldPhone, + FieldEmail, + FieldDepartment, + FieldRemark, + FieldStatus, + FieldIsSystem, + FieldLastLoginIP, + FieldLastLoginTime, +} + +var ( + // RolesPrimaryKey and RolesColumn2 are the table columns denoting the + // primary key for the roles relation (M2M). + RolesPrimaryKey = []string{"user_id", "role_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // UUIDValidator is a validator for the "uuid" field. It is called by the builders before save. + UUIDValidator func(string) error + // DefaultAllowedIP holds the default value on creation for the "allowed_ip" field. + DefaultAllowedIP string + // UsernameValidator is a validator for the "username" field. It is called by the builders before save. + UsernameValidator func(string) error + // DefaultNickname holds the default value on creation for the "nickname" field. + DefaultNickname string + // NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. + NicknameValidator func(string) error + // DefaultAvatar holds the default value on creation for the "avatar" field. + DefaultAvatar string + // AvatarValidator is a validator for the "avatar" field. It is called by the builders before save. + AvatarValidator func(string) error + // DefaultName holds the default value on creation for the "name" field. + DefaultName string + // NameValidator is a validator for the "name" field. It is called by the builders before save. + NameValidator func(string) error + // DefaultPassword holds the default value on creation for the "password" field. + DefaultPassword string + // PasswordValidator is a validator for the "password" field. It is called by the builders before save. + PasswordValidator func(string) error + // DefaultPhone holds the default value on creation for the "phone" field. + DefaultPhone string + // PhoneValidator is a validator for the "phone" field. It is called by the builders before save. + PhoneValidator func(string) error + // DefaultEmail holds the default value on creation for the "email" field. + DefaultEmail string + // EmailValidator is a validator for the "email" field. It is called by the builders before save. + EmailValidator func(string) error + // DefaultDepartment holds the default value on creation for the "department" field. + DefaultDepartment string + // DepartmentValidator is a validator for the "department" field. It is called by the builders before save. + DepartmentValidator func(string) error + // DefaultRemark holds the default value on creation for the "remark" field. + DefaultRemark string + // RemarkValidator is a validator for the "remark" field. It is called by the builders before save. + RemarkValidator func(string) error + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus int8 + // DefaultIsSystem holds the default value on creation for the "is_system" field. + DefaultIsSystem bool + // DefaultLastLoginIP holds the default value on creation for the "last_login_ip" field. + DefaultLastLoginIP string + // LastLoginIPValidator is a validator for the "last_login_ip" field. It is called by the builders before save. + LastLoginIPValidator func(string) error +) + +// Gender defines the type for the "gender" enum field. +type Gender string + +// GenderUnknown is the default value of the Gender enum. +const DefaultGender = GenderUnknown + +// Gender values. +const ( + GenderMale Gender = "male" + GenderFemale Gender = "female" + GenderUnknown Gender = "unknown" +) + +func (ge Gender) String() string { + return string(ge) +} + +// GenderValidator is a validator for the "gender" field enum values. It is called by the builders before save. +func GenderValidator(ge Gender) error { + switch ge { + case GenderMale, GenderFemale, GenderUnknown: + return nil + default: + return fmt.Errorf("user: invalid enum value for gender field: %q", ge) + } +} + +// OrderOption defines the ordering options for the User queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByUUID orders the results by the uuid field. +func ByUUID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUUID, opts...).ToFunc() +} + +// ByAllowedIP orders the results by the allowed_ip field. +func ByAllowedIP(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAllowedIP, opts...).ToFunc() +} + +// ByUsername orders the results by the username field. +func ByUsername(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUsername, opts...).ToFunc() +} + +// ByNickname orders the results by the nickname field. +func ByNickname(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNickname, opts...).ToFunc() +} + +// ByAvatar orders the results by the avatar field. +func ByAvatar(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldAvatar, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByGender orders the results by the gender field. +func ByGender(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldGender, opts...).ToFunc() +} + +// ByPassword orders the results by the password field. +func ByPassword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPassword, opts...).ToFunc() +} + +// ByPhone orders the results by the phone field. +func ByPhone(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPhone, opts...).ToFunc() +} + +// ByEmail orders the results by the email field. +func ByEmail(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldEmail, opts...).ToFunc() +} + +// ByDepartment orders the results by the department field. +func ByDepartment(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDepartment, opts...).ToFunc() +} + +// ByRemark orders the results by the remark field. +func ByRemark(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRemark, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// ByIsSystem orders the results by the is_system field. +func ByIsSystem(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsSystem, opts...).ToFunc() +} + +// ByLastLoginIP orders the results by the last_login_ip field. +func ByLastLoginIP(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastLoginIP, opts...).ToFunc() +} + +// ByLastLoginTime orders the results by the last_login_time field. +func ByLastLoginTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastLoginTime, opts...).ToFunc() +} + +// ByRolesCount orders the results by roles count. +func ByRolesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...) + } +} + +// ByRoles orders the results by roles terms. +func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByUserRolesCount orders the results by user_roles count. +func ByUserRolesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newUserRolesStep(), opts...) + } +} + +// ByUserRoles orders the results by user_roles terms. +func ByUserRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserRolesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newRolesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RolesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...), + ) +} +func newUserRolesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserRolesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/features/system/data/ent/user/where.go b/internal/features/system/data/ent/user/where.go new file mode 100644 index 00000000..9b236388 --- /dev/null +++ b/internal/features/system/data/ent/user/where.go @@ -0,0 +1,1182 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +import ( + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.User { + return predicate.User(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.User { + return predicate.User(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.User { + return predicate.User(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.User { + return predicate.User(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.User { + return predicate.User(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.User { + return predicate.User(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.User { + return predicate.User(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.User { + return predicate.User(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UUID applies equality check predicate on the "uuid" field. It's identical to UUIDEQ. +func UUID(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUUID, v)) +} + +// AllowedIP applies equality check predicate on the "allowed_ip" field. It's identical to AllowedIPEQ. +func AllowedIP(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAllowedIP, v)) +} + +// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. +func Username(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUsername, v)) +} + +// Nickname applies equality check predicate on the "nickname" field. It's identical to NicknameEQ. +func Nickname(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldNickname, v)) +} + +// Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ. +func Avatar(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAvatar, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldName, v)) +} + +// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ. +func Password(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldPassword, v)) +} + +// Phone applies equality check predicate on the "phone" field. It's identical to PhoneEQ. +func Phone(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldPhone, v)) +} + +// Email applies equality check predicate on the "email" field. It's identical to EmailEQ. +func Email(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEmail, v)) +} + +// Department applies equality check predicate on the "department" field. It's identical to DepartmentEQ. +func Department(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldDepartment, v)) +} + +// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ. +func Remark(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldRemark, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v int8) predicate.User { + return predicate.User(sql.FieldEQ(FieldStatus, v)) +} + +// IsSystem applies equality check predicate on the "is_system" field. It's identical to IsSystemEQ. +func IsSystem(v bool) predicate.User { + return predicate.User(sql.FieldEQ(FieldIsSystem, v)) +} + +// LastLoginIP applies equality check predicate on the "last_login_ip" field. It's identical to LastLoginIPEQ. +func LastLoginIP(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldLastLoginIP, v)) +} + +// LastLoginTime applies equality check predicate on the "last_login_time" field. It's identical to LastLoginTimeEQ. +func LastLoginTime(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldLastLoginTime, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldUpdateTime, v)) +} + +// UUIDEQ applies the EQ predicate on the "uuid" field. +func UUIDEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUUID, v)) +} + +// UUIDNEQ applies the NEQ predicate on the "uuid" field. +func UUIDNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUUID, v)) +} + +// UUIDIn applies the In predicate on the "uuid" field. +func UUIDIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldUUID, vs...)) +} + +// UUIDNotIn applies the NotIn predicate on the "uuid" field. +func UUIDNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUUID, vs...)) +} + +// UUIDGT applies the GT predicate on the "uuid" field. +func UUIDGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldUUID, v)) +} + +// UUIDGTE applies the GTE predicate on the "uuid" field. +func UUIDGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldUUID, v)) +} + +// UUIDLT applies the LT predicate on the "uuid" field. +func UUIDLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldUUID, v)) +} + +// UUIDLTE applies the LTE predicate on the "uuid" field. +func UUIDLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldUUID, v)) +} + +// UUIDContains applies the Contains predicate on the "uuid" field. +func UUIDContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldUUID, v)) +} + +// UUIDHasPrefix applies the HasPrefix predicate on the "uuid" field. +func UUIDHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldUUID, v)) +} + +// UUIDHasSuffix applies the HasSuffix predicate on the "uuid" field. +func UUIDHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldUUID, v)) +} + +// UUIDEqualFold applies the EqualFold predicate on the "uuid" field. +func UUIDEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldUUID, v)) +} + +// UUIDContainsFold applies the ContainsFold predicate on the "uuid" field. +func UUIDContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldUUID, v)) +} + +// AllowedIPEQ applies the EQ predicate on the "allowed_ip" field. +func AllowedIPEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAllowedIP, v)) +} + +// AllowedIPNEQ applies the NEQ predicate on the "allowed_ip" field. +func AllowedIPNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldAllowedIP, v)) +} + +// AllowedIPIn applies the In predicate on the "allowed_ip" field. +func AllowedIPIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldAllowedIP, vs...)) +} + +// AllowedIPNotIn applies the NotIn predicate on the "allowed_ip" field. +func AllowedIPNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldAllowedIP, vs...)) +} + +// AllowedIPGT applies the GT predicate on the "allowed_ip" field. +func AllowedIPGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldAllowedIP, v)) +} + +// AllowedIPGTE applies the GTE predicate on the "allowed_ip" field. +func AllowedIPGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldAllowedIP, v)) +} + +// AllowedIPLT applies the LT predicate on the "allowed_ip" field. +func AllowedIPLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldAllowedIP, v)) +} + +// AllowedIPLTE applies the LTE predicate on the "allowed_ip" field. +func AllowedIPLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldAllowedIP, v)) +} + +// AllowedIPContains applies the Contains predicate on the "allowed_ip" field. +func AllowedIPContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldAllowedIP, v)) +} + +// AllowedIPHasPrefix applies the HasPrefix predicate on the "allowed_ip" field. +func AllowedIPHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldAllowedIP, v)) +} + +// AllowedIPHasSuffix applies the HasSuffix predicate on the "allowed_ip" field. +func AllowedIPHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldAllowedIP, v)) +} + +// AllowedIPEqualFold applies the EqualFold predicate on the "allowed_ip" field. +func AllowedIPEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldAllowedIP, v)) +} + +// AllowedIPContainsFold applies the ContainsFold predicate on the "allowed_ip" field. +func AllowedIPContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldAllowedIP, v)) +} + +// UsernameEQ applies the EQ predicate on the "username" field. +func UsernameEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldUsername, v)) +} + +// UsernameNEQ applies the NEQ predicate on the "username" field. +func UsernameNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldUsername, v)) +} + +// UsernameIn applies the In predicate on the "username" field. +func UsernameIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldUsername, vs...)) +} + +// UsernameNotIn applies the NotIn predicate on the "username" field. +func UsernameNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldUsername, vs...)) +} + +// UsernameGT applies the GT predicate on the "username" field. +func UsernameGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldUsername, v)) +} + +// UsernameGTE applies the GTE predicate on the "username" field. +func UsernameGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldUsername, v)) +} + +// UsernameLT applies the LT predicate on the "username" field. +func UsernameLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldUsername, v)) +} + +// UsernameLTE applies the LTE predicate on the "username" field. +func UsernameLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldUsername, v)) +} + +// UsernameContains applies the Contains predicate on the "username" field. +func UsernameContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldUsername, v)) +} + +// UsernameHasPrefix applies the HasPrefix predicate on the "username" field. +func UsernameHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldUsername, v)) +} + +// UsernameHasSuffix applies the HasSuffix predicate on the "username" field. +func UsernameHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldUsername, v)) +} + +// UsernameEqualFold applies the EqualFold predicate on the "username" field. +func UsernameEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldUsername, v)) +} + +// UsernameContainsFold applies the ContainsFold predicate on the "username" field. +func UsernameContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldUsername, v)) +} + +// NicknameEQ applies the EQ predicate on the "nickname" field. +func NicknameEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldNickname, v)) +} + +// NicknameNEQ applies the NEQ predicate on the "nickname" field. +func NicknameNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldNickname, v)) +} + +// NicknameIn applies the In predicate on the "nickname" field. +func NicknameIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldNickname, vs...)) +} + +// NicknameNotIn applies the NotIn predicate on the "nickname" field. +func NicknameNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldNickname, vs...)) +} + +// NicknameGT applies the GT predicate on the "nickname" field. +func NicknameGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldNickname, v)) +} + +// NicknameGTE applies the GTE predicate on the "nickname" field. +func NicknameGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldNickname, v)) +} + +// NicknameLT applies the LT predicate on the "nickname" field. +func NicknameLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldNickname, v)) +} + +// NicknameLTE applies the LTE predicate on the "nickname" field. +func NicknameLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldNickname, v)) +} + +// NicknameContains applies the Contains predicate on the "nickname" field. +func NicknameContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldNickname, v)) +} + +// NicknameHasPrefix applies the HasPrefix predicate on the "nickname" field. +func NicknameHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldNickname, v)) +} + +// NicknameHasSuffix applies the HasSuffix predicate on the "nickname" field. +func NicknameHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldNickname, v)) +} + +// NicknameEqualFold applies the EqualFold predicate on the "nickname" field. +func NicknameEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldNickname, v)) +} + +// NicknameContainsFold applies the ContainsFold predicate on the "nickname" field. +func NicknameContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldNickname, v)) +} + +// AvatarEQ applies the EQ predicate on the "avatar" field. +func AvatarEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldAvatar, v)) +} + +// AvatarNEQ applies the NEQ predicate on the "avatar" field. +func AvatarNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldAvatar, v)) +} + +// AvatarIn applies the In predicate on the "avatar" field. +func AvatarIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldAvatar, vs...)) +} + +// AvatarNotIn applies the NotIn predicate on the "avatar" field. +func AvatarNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldAvatar, vs...)) +} + +// AvatarGT applies the GT predicate on the "avatar" field. +func AvatarGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldAvatar, v)) +} + +// AvatarGTE applies the GTE predicate on the "avatar" field. +func AvatarGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldAvatar, v)) +} + +// AvatarLT applies the LT predicate on the "avatar" field. +func AvatarLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldAvatar, v)) +} + +// AvatarLTE applies the LTE predicate on the "avatar" field. +func AvatarLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldAvatar, v)) +} + +// AvatarContains applies the Contains predicate on the "avatar" field. +func AvatarContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldAvatar, v)) +} + +// AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field. +func AvatarHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldAvatar, v)) +} + +// AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field. +func AvatarHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldAvatar, v)) +} + +// AvatarEqualFold applies the EqualFold predicate on the "avatar" field. +func AvatarEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldAvatar, v)) +} + +// AvatarContainsFold applies the ContainsFold predicate on the "avatar" field. +func AvatarContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldAvatar, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldName, v)) +} + +// GenderEQ applies the EQ predicate on the "gender" field. +func GenderEQ(v Gender) predicate.User { + return predicate.User(sql.FieldEQ(FieldGender, v)) +} + +// GenderNEQ applies the NEQ predicate on the "gender" field. +func GenderNEQ(v Gender) predicate.User { + return predicate.User(sql.FieldNEQ(FieldGender, v)) +} + +// GenderIn applies the In predicate on the "gender" field. +func GenderIn(vs ...Gender) predicate.User { + return predicate.User(sql.FieldIn(FieldGender, vs...)) +} + +// GenderNotIn applies the NotIn predicate on the "gender" field. +func GenderNotIn(vs ...Gender) predicate.User { + return predicate.User(sql.FieldNotIn(FieldGender, vs...)) +} + +// PasswordEQ applies the EQ predicate on the "password" field. +func PasswordEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldPassword, v)) +} + +// PasswordNEQ applies the NEQ predicate on the "password" field. +func PasswordNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldPassword, v)) +} + +// PasswordIn applies the In predicate on the "password" field. +func PasswordIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldPassword, vs...)) +} + +// PasswordNotIn applies the NotIn predicate on the "password" field. +func PasswordNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldPassword, vs...)) +} + +// PasswordGT applies the GT predicate on the "password" field. +func PasswordGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldPassword, v)) +} + +// PasswordGTE applies the GTE predicate on the "password" field. +func PasswordGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldPassword, v)) +} + +// PasswordLT applies the LT predicate on the "password" field. +func PasswordLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldPassword, v)) +} + +// PasswordLTE applies the LTE predicate on the "password" field. +func PasswordLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldPassword, v)) +} + +// PasswordContains applies the Contains predicate on the "password" field. +func PasswordContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldPassword, v)) +} + +// PasswordHasPrefix applies the HasPrefix predicate on the "password" field. +func PasswordHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldPassword, v)) +} + +// PasswordHasSuffix applies the HasSuffix predicate on the "password" field. +func PasswordHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldPassword, v)) +} + +// PasswordEqualFold applies the EqualFold predicate on the "password" field. +func PasswordEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldPassword, v)) +} + +// PasswordContainsFold applies the ContainsFold predicate on the "password" field. +func PasswordContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldPassword, v)) +} + +// PhoneEQ applies the EQ predicate on the "phone" field. +func PhoneEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldPhone, v)) +} + +// PhoneNEQ applies the NEQ predicate on the "phone" field. +func PhoneNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldPhone, v)) +} + +// PhoneIn applies the In predicate on the "phone" field. +func PhoneIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldPhone, vs...)) +} + +// PhoneNotIn applies the NotIn predicate on the "phone" field. +func PhoneNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldPhone, vs...)) +} + +// PhoneGT applies the GT predicate on the "phone" field. +func PhoneGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldPhone, v)) +} + +// PhoneGTE applies the GTE predicate on the "phone" field. +func PhoneGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldPhone, v)) +} + +// PhoneLT applies the LT predicate on the "phone" field. +func PhoneLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldPhone, v)) +} + +// PhoneLTE applies the LTE predicate on the "phone" field. +func PhoneLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldPhone, v)) +} + +// PhoneContains applies the Contains predicate on the "phone" field. +func PhoneContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldPhone, v)) +} + +// PhoneHasPrefix applies the HasPrefix predicate on the "phone" field. +func PhoneHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldPhone, v)) +} + +// PhoneHasSuffix applies the HasSuffix predicate on the "phone" field. +func PhoneHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldPhone, v)) +} + +// PhoneEqualFold applies the EqualFold predicate on the "phone" field. +func PhoneEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldPhone, v)) +} + +// PhoneContainsFold applies the ContainsFold predicate on the "phone" field. +func PhoneContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldPhone, v)) +} + +// EmailEQ applies the EQ predicate on the "email" field. +func EmailEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldEmail, v)) +} + +// EmailNEQ applies the NEQ predicate on the "email" field. +func EmailNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldEmail, v)) +} + +// EmailIn applies the In predicate on the "email" field. +func EmailIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldEmail, vs...)) +} + +// EmailNotIn applies the NotIn predicate on the "email" field. +func EmailNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldEmail, vs...)) +} + +// EmailGT applies the GT predicate on the "email" field. +func EmailGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldEmail, v)) +} + +// EmailGTE applies the GTE predicate on the "email" field. +func EmailGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldEmail, v)) +} + +// EmailLT applies the LT predicate on the "email" field. +func EmailLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldEmail, v)) +} + +// EmailLTE applies the LTE predicate on the "email" field. +func EmailLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldEmail, v)) +} + +// EmailContains applies the Contains predicate on the "email" field. +func EmailContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldEmail, v)) +} + +// EmailHasPrefix applies the HasPrefix predicate on the "email" field. +func EmailHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldEmail, v)) +} + +// EmailHasSuffix applies the HasSuffix predicate on the "email" field. +func EmailHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldEmail, v)) +} + +// EmailEqualFold applies the EqualFold predicate on the "email" field. +func EmailEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldEmail, v)) +} + +// EmailContainsFold applies the ContainsFold predicate on the "email" field. +func EmailContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldEmail, v)) +} + +// DepartmentEQ applies the EQ predicate on the "department" field. +func DepartmentEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldDepartment, v)) +} + +// DepartmentNEQ applies the NEQ predicate on the "department" field. +func DepartmentNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldDepartment, v)) +} + +// DepartmentIn applies the In predicate on the "department" field. +func DepartmentIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldDepartment, vs...)) +} + +// DepartmentNotIn applies the NotIn predicate on the "department" field. +func DepartmentNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldDepartment, vs...)) +} + +// DepartmentGT applies the GT predicate on the "department" field. +func DepartmentGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldDepartment, v)) +} + +// DepartmentGTE applies the GTE predicate on the "department" field. +func DepartmentGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldDepartment, v)) +} + +// DepartmentLT applies the LT predicate on the "department" field. +func DepartmentLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldDepartment, v)) +} + +// DepartmentLTE applies the LTE predicate on the "department" field. +func DepartmentLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldDepartment, v)) +} + +// DepartmentContains applies the Contains predicate on the "department" field. +func DepartmentContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldDepartment, v)) +} + +// DepartmentHasPrefix applies the HasPrefix predicate on the "department" field. +func DepartmentHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldDepartment, v)) +} + +// DepartmentHasSuffix applies the HasSuffix predicate on the "department" field. +func DepartmentHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldDepartment, v)) +} + +// DepartmentEqualFold applies the EqualFold predicate on the "department" field. +func DepartmentEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldDepartment, v)) +} + +// DepartmentContainsFold applies the ContainsFold predicate on the "department" field. +func DepartmentContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldDepartment, v)) +} + +// RemarkEQ applies the EQ predicate on the "remark" field. +func RemarkEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldRemark, v)) +} + +// RemarkNEQ applies the NEQ predicate on the "remark" field. +func RemarkNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldRemark, v)) +} + +// RemarkIn applies the In predicate on the "remark" field. +func RemarkIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldRemark, vs...)) +} + +// RemarkNotIn applies the NotIn predicate on the "remark" field. +func RemarkNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldRemark, vs...)) +} + +// RemarkGT applies the GT predicate on the "remark" field. +func RemarkGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldRemark, v)) +} + +// RemarkGTE applies the GTE predicate on the "remark" field. +func RemarkGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldRemark, v)) +} + +// RemarkLT applies the LT predicate on the "remark" field. +func RemarkLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldRemark, v)) +} + +// RemarkLTE applies the LTE predicate on the "remark" field. +func RemarkLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldRemark, v)) +} + +// RemarkContains applies the Contains predicate on the "remark" field. +func RemarkContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldRemark, v)) +} + +// RemarkHasPrefix applies the HasPrefix predicate on the "remark" field. +func RemarkHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldRemark, v)) +} + +// RemarkHasSuffix applies the HasSuffix predicate on the "remark" field. +func RemarkHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldRemark, v)) +} + +// RemarkEqualFold applies the EqualFold predicate on the "remark" field. +func RemarkEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldRemark, v)) +} + +// RemarkContainsFold applies the ContainsFold predicate on the "remark" field. +func RemarkContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldRemark, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v int8) predicate.User { + return predicate.User(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v int8) predicate.User { + return predicate.User(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...int8) predicate.User { + return predicate.User(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...int8) predicate.User { + return predicate.User(sql.FieldNotIn(FieldStatus, vs...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v int8) predicate.User { + return predicate.User(sql.FieldGT(FieldStatus, v)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v int8) predicate.User { + return predicate.User(sql.FieldGTE(FieldStatus, v)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v int8) predicate.User { + return predicate.User(sql.FieldLT(FieldStatus, v)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v int8) predicate.User { + return predicate.User(sql.FieldLTE(FieldStatus, v)) +} + +// IsSystemEQ applies the EQ predicate on the "is_system" field. +func IsSystemEQ(v bool) predicate.User { + return predicate.User(sql.FieldEQ(FieldIsSystem, v)) +} + +// IsSystemNEQ applies the NEQ predicate on the "is_system" field. +func IsSystemNEQ(v bool) predicate.User { + return predicate.User(sql.FieldNEQ(FieldIsSystem, v)) +} + +// LastLoginIPEQ applies the EQ predicate on the "last_login_ip" field. +func LastLoginIPEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldLastLoginIP, v)) +} + +// LastLoginIPNEQ applies the NEQ predicate on the "last_login_ip" field. +func LastLoginIPNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldLastLoginIP, v)) +} + +// LastLoginIPIn applies the In predicate on the "last_login_ip" field. +func LastLoginIPIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldLastLoginIP, vs...)) +} + +// LastLoginIPNotIn applies the NotIn predicate on the "last_login_ip" field. +func LastLoginIPNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldLastLoginIP, vs...)) +} + +// LastLoginIPGT applies the GT predicate on the "last_login_ip" field. +func LastLoginIPGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldLastLoginIP, v)) +} + +// LastLoginIPGTE applies the GTE predicate on the "last_login_ip" field. +func LastLoginIPGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldLastLoginIP, v)) +} + +// LastLoginIPLT applies the LT predicate on the "last_login_ip" field. +func LastLoginIPLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldLastLoginIP, v)) +} + +// LastLoginIPLTE applies the LTE predicate on the "last_login_ip" field. +func LastLoginIPLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldLastLoginIP, v)) +} + +// LastLoginIPContains applies the Contains predicate on the "last_login_ip" field. +func LastLoginIPContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldLastLoginIP, v)) +} + +// LastLoginIPHasPrefix applies the HasPrefix predicate on the "last_login_ip" field. +func LastLoginIPHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldLastLoginIP, v)) +} + +// LastLoginIPHasSuffix applies the HasSuffix predicate on the "last_login_ip" field. +func LastLoginIPHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldLastLoginIP, v)) +} + +// LastLoginIPEqualFold applies the EqualFold predicate on the "last_login_ip" field. +func LastLoginIPEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldLastLoginIP, v)) +} + +// LastLoginIPContainsFold applies the ContainsFold predicate on the "last_login_ip" field. +func LastLoginIPContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldLastLoginIP, v)) +} + +// LastLoginTimeEQ applies the EQ predicate on the "last_login_time" field. +func LastLoginTimeEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldEQ(FieldLastLoginTime, v)) +} + +// LastLoginTimeNEQ applies the NEQ predicate on the "last_login_time" field. +func LastLoginTimeNEQ(v time.Time) predicate.User { + return predicate.User(sql.FieldNEQ(FieldLastLoginTime, v)) +} + +// LastLoginTimeIn applies the In predicate on the "last_login_time" field. +func LastLoginTimeIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldIn(FieldLastLoginTime, vs...)) +} + +// LastLoginTimeNotIn applies the NotIn predicate on the "last_login_time" field. +func LastLoginTimeNotIn(vs ...time.Time) predicate.User { + return predicate.User(sql.FieldNotIn(FieldLastLoginTime, vs...)) +} + +// LastLoginTimeGT applies the GT predicate on the "last_login_time" field. +func LastLoginTimeGT(v time.Time) predicate.User { + return predicate.User(sql.FieldGT(FieldLastLoginTime, v)) +} + +// LastLoginTimeGTE applies the GTE predicate on the "last_login_time" field. +func LastLoginTimeGTE(v time.Time) predicate.User { + return predicate.User(sql.FieldGTE(FieldLastLoginTime, v)) +} + +// LastLoginTimeLT applies the LT predicate on the "last_login_time" field. +func LastLoginTimeLT(v time.Time) predicate.User { + return predicate.User(sql.FieldLT(FieldLastLoginTime, v)) +} + +// LastLoginTimeLTE applies the LTE predicate on the "last_login_time" field. +func LastLoginTimeLTE(v time.Time) predicate.User { + return predicate.User(sql.FieldLTE(FieldLastLoginTime, v)) +} + +// LastLoginTimeIsNil applies the IsNil predicate on the "last_login_time" field. +func LastLoginTimeIsNil() predicate.User { + return predicate.User(sql.FieldIsNull(FieldLastLoginTime)) +} + +// LastLoginTimeNotNil applies the NotNil predicate on the "last_login_time" field. +func LastLoginTimeNotNil() predicate.User { + return predicate.User(sql.FieldNotNull(FieldLastLoginTime)) +} + +// HasRoles applies the HasEdge predicate on the "roles" edge. +func HasRoles() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRolesWith applies the HasEdge predicate on the "roles" edge with a given conditions (other predicates). +func HasRolesWith(preds ...predicate.Role) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newRolesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasUserRoles applies the HasEdge predicate on the "user_roles" edge. +func HasUserRoles() predicate.User { + return predicate.User(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserRolesWith applies the HasEdge predicate on the "user_roles" edge with a given conditions (other predicates). +func HasUserRolesWith(preds ...predicate.UserRole) predicate.User { + return predicate.User(func(s *sql.Selector) { + step := newUserRolesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.User) predicate.User { + return predicate.User(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.User) predicate.User { + return predicate.User(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.User) predicate.User { + return predicate.User(sql.NotPredicates(p)) +} diff --git a/internal/features/system/data/ent/user_create.go b/internal/features/system/data/ent/user_create.go new file mode 100644 index 00000000..8cf2c1cf --- /dev/null +++ b/internal/features/system/data/ent/user_create.go @@ -0,0 +1,752 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserCreate is the builder for creating a User entity. +type UserCreate struct { + config + mutation *UserMutation + hooks []Hook +} + +// SetCreateTime sets the "create_time" field. +func (_c *UserCreate) SetCreateTime(v time.Time) *UserCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *UserCreate) SetNillableCreateTime(v *time.Time) *UserCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *UserCreate) SetUpdateTime(v time.Time) *UserCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *UserCreate) SetNillableUpdateTime(v *time.Time) *UserCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetUUID sets the "uuid" field. +func (_c *UserCreate) SetUUID(v string) *UserCreate { + _c.mutation.SetUUID(v) + return _c +} + +// SetAllowedIP sets the "allowed_ip" field. +func (_c *UserCreate) SetAllowedIP(v string) *UserCreate { + _c.mutation.SetAllowedIP(v) + return _c +} + +// SetNillableAllowedIP sets the "allowed_ip" field if the given value is not nil. +func (_c *UserCreate) SetNillableAllowedIP(v *string) *UserCreate { + if v != nil { + _c.SetAllowedIP(*v) + } + return _c +} + +// SetUsername sets the "username" field. +func (_c *UserCreate) SetUsername(v string) *UserCreate { + _c.mutation.SetUsername(v) + return _c +} + +// SetNickname sets the "nickname" field. +func (_c *UserCreate) SetNickname(v string) *UserCreate { + _c.mutation.SetNickname(v) + return _c +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (_c *UserCreate) SetNillableNickname(v *string) *UserCreate { + if v != nil { + _c.SetNickname(*v) + } + return _c +} + +// SetAvatar sets the "avatar" field. +func (_c *UserCreate) SetAvatar(v string) *UserCreate { + _c.mutation.SetAvatar(v) + return _c +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (_c *UserCreate) SetNillableAvatar(v *string) *UserCreate { + if v != nil { + _c.SetAvatar(*v) + } + return _c +} + +// SetName sets the "name" field. +func (_c *UserCreate) SetName(v string) *UserCreate { + _c.mutation.SetName(v) + return _c +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_c *UserCreate) SetNillableName(v *string) *UserCreate { + if v != nil { + _c.SetName(*v) + } + return _c +} + +// SetGender sets the "gender" field. +func (_c *UserCreate) SetGender(v user.Gender) *UserCreate { + _c.mutation.SetGender(v) + return _c +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (_c *UserCreate) SetNillableGender(v *user.Gender) *UserCreate { + if v != nil { + _c.SetGender(*v) + } + return _c +} + +// SetPassword sets the "password" field. +func (_c *UserCreate) SetPassword(v string) *UserCreate { + _c.mutation.SetPassword(v) + return _c +} + +// SetNillablePassword sets the "password" field if the given value is not nil. +func (_c *UserCreate) SetNillablePassword(v *string) *UserCreate { + if v != nil { + _c.SetPassword(*v) + } + return _c +} + +// SetPhone sets the "phone" field. +func (_c *UserCreate) SetPhone(v string) *UserCreate { + _c.mutation.SetPhone(v) + return _c +} + +// SetNillablePhone sets the "phone" field if the given value is not nil. +func (_c *UserCreate) SetNillablePhone(v *string) *UserCreate { + if v != nil { + _c.SetPhone(*v) + } + return _c +} + +// SetEmail sets the "email" field. +func (_c *UserCreate) SetEmail(v string) *UserCreate { + _c.mutation.SetEmail(v) + return _c +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (_c *UserCreate) SetNillableEmail(v *string) *UserCreate { + if v != nil { + _c.SetEmail(*v) + } + return _c +} + +// SetDepartment sets the "department" field. +func (_c *UserCreate) SetDepartment(v string) *UserCreate { + _c.mutation.SetDepartment(v) + return _c +} + +// SetNillableDepartment sets the "department" field if the given value is not nil. +func (_c *UserCreate) SetNillableDepartment(v *string) *UserCreate { + if v != nil { + _c.SetDepartment(*v) + } + return _c +} + +// SetRemark sets the "remark" field. +func (_c *UserCreate) SetRemark(v string) *UserCreate { + _c.mutation.SetRemark(v) + return _c +} + +// SetNillableRemark sets the "remark" field if the given value is not nil. +func (_c *UserCreate) SetNillableRemark(v *string) *UserCreate { + if v != nil { + _c.SetRemark(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *UserCreate) SetStatus(v int8) *UserCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *UserCreate) SetNillableStatus(v *int8) *UserCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetIsSystem sets the "is_system" field. +func (_c *UserCreate) SetIsSystem(v bool) *UserCreate { + _c.mutation.SetIsSystem(v) + return _c +} + +// SetNillableIsSystem sets the "is_system" field if the given value is not nil. +func (_c *UserCreate) SetNillableIsSystem(v *bool) *UserCreate { + if v != nil { + _c.SetIsSystem(*v) + } + return _c +} + +// SetLastLoginIP sets the "last_login_ip" field. +func (_c *UserCreate) SetLastLoginIP(v string) *UserCreate { + _c.mutation.SetLastLoginIP(v) + return _c +} + +// SetNillableLastLoginIP sets the "last_login_ip" field if the given value is not nil. +func (_c *UserCreate) SetNillableLastLoginIP(v *string) *UserCreate { + if v != nil { + _c.SetLastLoginIP(*v) + } + return _c +} + +// SetLastLoginTime sets the "last_login_time" field. +func (_c *UserCreate) SetLastLoginTime(v time.Time) *UserCreate { + _c.mutation.SetLastLoginTime(v) + return _c +} + +// SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. +func (_c *UserCreate) SetNillableLastLoginTime(v *time.Time) *UserCreate { + if v != nil { + _c.SetLastLoginTime(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *UserCreate) SetID(v int64) *UserCreate { + _c.mutation.SetID(v) + return _c +} + +// AddRoleIDs adds the "roles" edge to the Role entity by IDs. +func (_c *UserCreate) AddRoleIDs(ids ...int64) *UserCreate { + _c.mutation.AddRoleIDs(ids...) + return _c +} + +// AddRoles adds the "roles" edges to the Role entity. +func (_c *UserCreate) AddRoles(v ...*Role) *UserCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddRoleIDs(ids...) +} + +// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. +func (_c *UserCreate) AddUserRoleIDs(ids ...int) *UserCreate { + _c.mutation.AddUserRoleIDs(ids...) + return _c +} + +// AddUserRoles adds the "user_roles" edges to the UserRole entity. +func (_c *UserCreate) AddUserRoles(v ...*UserRole) *UserCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddUserRoleIDs(ids...) +} + +// Mutation returns the UserMutation object of the builder. +func (_c *UserCreate) Mutation() *UserMutation { + return _c.mutation +} + +// Save creates the User in the database. +func (_c *UserCreate) Save(ctx context.Context) (*User, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *UserCreate) SaveX(ctx context.Context) *User { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *UserCreate) defaults() { + if _, ok := _c.mutation.CreateTime(); !ok { + v := user.DefaultCreateTime() + _c.mutation.SetCreateTime(v) + } + if _, ok := _c.mutation.UpdateTime(); !ok { + v := user.DefaultUpdateTime() + _c.mutation.SetUpdateTime(v) + } + if _, ok := _c.mutation.AllowedIP(); !ok { + v := user.DefaultAllowedIP + _c.mutation.SetAllowedIP(v) + } + if _, ok := _c.mutation.Nickname(); !ok { + v := user.DefaultNickname + _c.mutation.SetNickname(v) + } + if _, ok := _c.mutation.Avatar(); !ok { + v := user.DefaultAvatar + _c.mutation.SetAvatar(v) + } + if _, ok := _c.mutation.Name(); !ok { + v := user.DefaultName + _c.mutation.SetName(v) + } + if _, ok := _c.mutation.Gender(); !ok { + v := user.DefaultGender + _c.mutation.SetGender(v) + } + if _, ok := _c.mutation.Password(); !ok { + v := user.DefaultPassword + _c.mutation.SetPassword(v) + } + if _, ok := _c.mutation.Phone(); !ok { + v := user.DefaultPhone + _c.mutation.SetPhone(v) + } + if _, ok := _c.mutation.Email(); !ok { + v := user.DefaultEmail + _c.mutation.SetEmail(v) + } + if _, ok := _c.mutation.Department(); !ok { + v := user.DefaultDepartment + _c.mutation.SetDepartment(v) + } + if _, ok := _c.mutation.Remark(); !ok { + v := user.DefaultRemark + _c.mutation.SetRemark(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := user.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.IsSystem(); !ok { + v := user.DefaultIsSystem + _c.mutation.SetIsSystem(v) + } + if _, ok := _c.mutation.LastLoginIP(); !ok { + v := user.DefaultLastLoginIP + _c.mutation.SetLastLoginIP(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *UserCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "User.create_time"`)} + } + if _, ok := _c.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "User.update_time"`)} + } + if _, ok := _c.mutation.UUID(); !ok { + return &ValidationError{Name: "uuid", err: errors.New(`ent: missing required field "User.uuid"`)} + } + if v, ok := _c.mutation.UUID(); ok { + if err := user.UUIDValidator(v); err != nil { + return &ValidationError{Name: "uuid", err: fmt.Errorf(`ent: validator failed for field "User.uuid": %w`, err)} + } + } + if _, ok := _c.mutation.AllowedIP(); !ok { + return &ValidationError{Name: "allowed_ip", err: errors.New(`ent: missing required field "User.allowed_ip"`)} + } + if _, ok := _c.mutation.Username(); !ok { + return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)} + } + if v, ok := _c.mutation.Username(); ok { + if err := user.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} + } + } + if _, ok := _c.mutation.Nickname(); !ok { + return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "User.nickname"`)} + } + if v, ok := _c.mutation.Nickname(); ok { + if err := user.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} + } + } + if _, ok := _c.mutation.Avatar(); !ok { + return &ValidationError{Name: "avatar", err: errors.New(`ent: missing required field "User.avatar"`)} + } + if v, ok := _c.mutation.Avatar(); ok { + if err := user.AvatarValidator(v); err != nil { + return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} + } + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "User.name"`)} + } + if v, ok := _c.mutation.Name(); ok { + if err := user.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} + } + } + if _, ok := _c.mutation.Gender(); !ok { + return &ValidationError{Name: "gender", err: errors.New(`ent: missing required field "User.gender"`)} + } + if v, ok := _c.mutation.Gender(); ok { + if err := user.GenderValidator(v); err != nil { + return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} + } + } + if _, ok := _c.mutation.Password(); !ok { + return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "User.password"`)} + } + if v, ok := _c.mutation.Password(); ok { + if err := user.PasswordValidator(v); err != nil { + return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} + } + } + if _, ok := _c.mutation.Phone(); !ok { + return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "User.phone"`)} + } + if v, ok := _c.mutation.Phone(); ok { + if err := user.PhoneValidator(v); err != nil { + return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "User.phone": %w`, err)} + } + } + if _, ok := _c.mutation.Email(); !ok { + return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "User.email"`)} + } + if v, ok := _c.mutation.Email(); ok { + if err := user.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} + } + } + if _, ok := _c.mutation.Department(); !ok { + return &ValidationError{Name: "department", err: errors.New(`ent: missing required field "User.department"`)} + } + if v, ok := _c.mutation.Department(); ok { + if err := user.DepartmentValidator(v); err != nil { + return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} + } + } + if _, ok := _c.mutation.Remark(); !ok { + return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "User.remark"`)} + } + if v, ok := _c.mutation.Remark(); ok { + if err := user.RemarkValidator(v); err != nil { + return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "User.remark": %w`, err)} + } + } + if _, ok := _c.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "User.status"`)} + } + if _, ok := _c.mutation.IsSystem(); !ok { + return &ValidationError{Name: "is_system", err: errors.New(`ent: missing required field "User.is_system"`)} + } + if _, ok := _c.mutation.LastLoginIP(); !ok { + return &ValidationError{Name: "last_login_ip", err: errors.New(`ent: missing required field "User.last_login_ip"`)} + } + if v, ok := _c.mutation.LastLoginIP(); ok { + if err := user.LastLoginIPValidator(v); err != nil { + return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} + } + } + return nil +} + +func (_c *UserCreate) sqlSave(ctx context.Context) (*User, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { + var ( + _node = &User{config: _c.config} + _spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(user.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if value, ok := _c.mutation.UUID(); ok { + _spec.SetField(user.FieldUUID, field.TypeString, value) + _node.UUID = value + } + if value, ok := _c.mutation.AllowedIP(); ok { + _spec.SetField(user.FieldAllowedIP, field.TypeString, value) + _node.AllowedIP = value + } + if value, ok := _c.mutation.Username(); ok { + _spec.SetField(user.FieldUsername, field.TypeString, value) + _node.Username = value + } + if value, ok := _c.mutation.Nickname(); ok { + _spec.SetField(user.FieldNickname, field.TypeString, value) + _node.Nickname = value + } + if value, ok := _c.mutation.Avatar(); ok { + _spec.SetField(user.FieldAvatar, field.TypeString, value) + _node.Avatar = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(user.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.Gender(); ok { + _spec.SetField(user.FieldGender, field.TypeEnum, value) + _node.Gender = value + } + if value, ok := _c.mutation.Password(); ok { + _spec.SetField(user.FieldPassword, field.TypeString, value) + _node.Password = value + } + if value, ok := _c.mutation.Phone(); ok { + _spec.SetField(user.FieldPhone, field.TypeString, value) + _node.Phone = value + } + if value, ok := _c.mutation.Email(); ok { + _spec.SetField(user.FieldEmail, field.TypeString, value) + _node.Email = value + } + if value, ok := _c.mutation.Department(); ok { + _spec.SetField(user.FieldDepartment, field.TypeString, value) + _node.Department = value + } + if value, ok := _c.mutation.Remark(); ok { + _spec.SetField(user.FieldRemark, field.TypeString, value) + _node.Remark = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(user.FieldStatus, field.TypeInt8, value) + _node.Status = value + } + if value, ok := _c.mutation.IsSystem(); ok { + _spec.SetField(user.FieldIsSystem, field.TypeBool, value) + _node.IsSystem = value + } + if value, ok := _c.mutation.LastLoginIP(); ok { + _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) + _node.LastLoginIP = value + } + if value, ok := _c.mutation.LastLoginTime(); ok { + _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) + _node.LastLoginTime = value + } + if nodes := _c.mutation.RolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.RolesTable, + Columns: user.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.UserRolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserRolesTable, + Columns: []string{user.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SetUser set the User +func (_c *UserCreate) SetUser(input *User, fields ...string) *UserCreate { + m := _c.mutation + if len(fields) == 0 { + fields = user.Columns + } + _ = m.SetFields(input, fields...) + return _c +} + +// SetUserWithZero set the User +func (_c *UserCreate) SetUserWithZero(input *User, fields ...string) *UserCreate { + m := _c.mutation + if len(fields) == 0 { + fields = user.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return _c +} + +// UserCreateBulk is the builder for creating many User entities in bulk. +type UserCreateBulk struct { + config + err error + builders []*UserCreate +} + +// Save creates the User entities in the database. +func (_c *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*User, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *UserCreateBulk) SaveX(ctx context.Context) []*User { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/user_delete.go b/internal/features/system/data/ent/user_delete.go new file mode 100644 index 00000000..6a43fc0a --- /dev/null +++ b/internal/features/system/data/ent/user_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/user" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserDelete is the builder for deleting a User entity. +type UserDelete struct { + config + hooks []Hook + mutation *UserMutation +} + +// Where appends a list predicates to the UserDelete builder. +func (_d *UserDelete) Where(ps ...predicate.User) *UserDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *UserDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *UserDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// UserDeleteOne is the builder for deleting a single User entity. +type UserDeleteOne struct { + _d *UserDelete +} + +// Where appends a list predicates to the UserDelete builder. +func (_d *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *UserDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{user.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/user_query.go b/internal/features/system/data/ent/user_query.go new file mode 100644 index 00000000..063e18e4 --- /dev/null +++ b/internal/features/system/data/ent/user_query.go @@ -0,0 +1,825 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserQuery is the builder for querying User entities. +type UserQuery struct { + config + ctx *QueryContext + order []user.OrderOption + inters []Interceptor + predicates []predicate.User + withRoles *RoleQuery + withUserRoles *UserRoleQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UserQuery builder. +func (_q *UserQuery) Where(ps ...predicate.User) *UserQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *UserQuery) Limit(limit int) *UserQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *UserQuery) Offset(offset int) *UserQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *UserQuery) Unique(unique bool) *UserQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *UserQuery) Order(o ...user.OrderOption) *UserQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryRoles chains the current query on the "roles" edge. +func (_q *UserQuery) QueryRoles() *RoleQuery { + query := (&RoleClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, selector), + sqlgraph.To(role.Table, role.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, user.RolesTable, user.RolesPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryUserRoles chains the current query on the "user_roles" edge. +func (_q *UserQuery) QueryUserRoles() *UserRoleQuery { + query := (&UserRoleClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(user.Table, user.FieldID, selector), + sqlgraph.To(userrole.Table, userrole.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, user.UserRolesTable, user.UserRolesColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first User entity from the query. +// Returns a *NotFoundError when no User was found. +func (_q *UserQuery) First(ctx context.Context) (*User, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{user.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *UserQuery) FirstX(ctx context.Context) *User { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first User ID from the query. +// Returns a *NotFoundError when no User ID was found. +func (_q *UserQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{user.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *UserQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single User entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one User entity is found. +// Returns a *NotFoundError when no User entities are found. +func (_q *UserQuery) Only(ctx context.Context) (*User, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{user.Label} + default: + return nil, &NotSingularError{user.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *UserQuery) OnlyX(ctx context.Context) *User { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only User ID in the query. +// Returns a *NotSingularError when more than one User ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *UserQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{user.Label} + default: + err = &NotSingularError{user.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *UserQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Users. +func (_q *UserQuery) All(ctx context.Context) ([]*User, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*User, *UserQuery]() + return withInterceptors[[]*User](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *UserQuery) AllX(ctx context.Context) []*User { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of User IDs. +func (_q *UserQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(user.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *UserQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *UserQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*UserQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *UserQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *UserQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *UserQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *UserQuery) Clone() *UserQuery { + if _q == nil { + return nil + } + return &UserQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]user.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.User{}, _q.predicates...), + withRoles: _q.withRoles.Clone(), + withUserRoles: _q.withUserRoles.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithRoles tells the query-builder to eager-load the nodes that are connected to +// the "roles" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *UserQuery) WithRoles(opts ...func(*RoleQuery)) *UserQuery { + query := (&RoleClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRoles = query + return _q +} + +// WithUserRoles tells the query-builder to eager-load the nodes that are connected to +// the "user_roles" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *UserQuery) WithUserRoles(opts ...func(*UserRoleQuery)) *UserQuery { + query := (&UserRoleClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withUserRoles = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.User.Query(). +// GroupBy(user.FieldCreateTime). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = user.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// } +// +// client.User.Query(). +// Select(user.FieldCreateTime). +// Scan(ctx, &v) +func (_q *UserQuery) Select(fields ...string) *UserSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &UserSelect{UserQuery: _q} + sbuild.label = user.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserSelect configured with the given aggregations. +func (_q *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *UserQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !user.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) { + var ( + nodes = []*User{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withRoles != nil, + _q.withUserRoles != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*User).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &User{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withRoles; query != nil { + if err := _q.loadRoles(ctx, query, nodes, + func(n *User) { n.Edges.Roles = []*Role{} }, + func(n *User, e *Role) { n.Edges.Roles = append(n.Edges.Roles, e) }); err != nil { + return nil, err + } + } + if query := _q.withUserRoles; query != nil { + if err := _q.loadUserRoles(ctx, query, nodes, + func(n *User) { n.Edges.UserRoles = []*UserRole{} }, + func(n *User, e *UserRole) { n.Edges.UserRoles = append(n.Edges.UserRoles, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *UserQuery) loadRoles(ctx context.Context, query *RoleQuery, nodes []*User, init func(*User), assign func(*User, *Role)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int64]*User) + nids := make(map[int64]map[*User]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(user.RolesTable) + s.Join(joinT).On(s.C(role.FieldID), joinT.C(user.RolesPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(user.RolesPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(user.RolesPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullInt64).Int64 + inValue := values[1].(*sql.NullInt64).Int64 + if nids[inValue] == nil { + nids[inValue] = map[*User]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Role](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "roles" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (_q *UserQuery) loadUserRoles(ctx context.Context, query *UserRoleQuery, nodes []*User, init func(*User), assign func(*User, *UserRole)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*User) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(userrole.FieldUserID) + } + query.Where(predicate.UserRole(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(user.UserRolesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.UserID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} + +func (_q *UserQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *UserQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) + for i := range fields { + if fields[i] != user.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(user.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = user.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *UserQuery) ForUpdate(opts ...sql.LockOption) *UserQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *UserQuery) ForShare(opts ...sql.LockOption) *UserQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// UpdateTime time.Time `json:"update_time,omitempty"` +// UUID string `json:"uuid,omitempty"` +// AllowedIP string `json:"allowed_ip,omitempty"` +// Username string `json:"username,omitempty"` +// Nickname string `json:"nickname,omitempty"` +// Avatar string `json:"avatar,omitempty"` +// Name string `json:"name,omitempty"` +// Gender user.Gender `json:"gender,omitempty"` +// Password string `json:"password,omitempty"` +// Phone string `json:"phone,omitempty"` +// Email string `json:"email,omitempty"` +// Department string `json:"department,omitempty"` +// Remark string `json:"remark,omitempty"` +// Status int8 `json:"status,omitempty"` +// IsSystem bool `json:"is_system,omitempty"` +// LastLoginIP string `json:"last_login_ip,omitempty"` +// LastLoginTime time.Time `json:"last_login_time,omitempty"` +// } +// +// client.User.Query(). +// Omit( +// user.FieldCreateTime, +// user.FieldUpdateTime, +// user.FieldUUID, +// user.FieldAllowedIP, +// user.FieldUsername, +// user.FieldNickname, +// user.FieldAvatar, +// user.FieldName, +// user.FieldGender, +// user.FieldPassword, +// user.FieldPhone, +// user.FieldEmail, +// user.FieldDepartment, +// user.FieldRemark, +// user.FieldStatus, +// user.FieldIsSystem, +// user.FieldLastLoginIP, +// user.FieldLastLoginTime, +// ). +// Scan(ctx, &v) +func (uq *UserQuery) Omit(fields ...string) *UserSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range user.Columns { + if _, ok := omits[col]; !ok { + uq.ctx.Fields = append(uq.ctx.Fields, col) + } + } + + sbuild := &UserSelect{UserQuery: uq} + sbuild.label = user.Label + sbuild.flds, sbuild.scan = &uq.ctx.Fields, sbuild.Scan + return sbuild +} + +// UserGroupBy is the group-by builder for User entities. +type UserGroupBy struct { + selector + build *UserQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *UserGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserSelect is the builder for selecting fields of User entities. +type UserSelect struct { + *UserQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *UserSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserQuery, *UserSelect](ctx, _s.UserQuery, _s, _s.inters, v) +} + +func (_s *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *UserSelect) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/internal/features/system/data/ent/user_update.go b/internal/features/system/data/ent/user_update.go new file mode 100644 index 00000000..d288b564 --- /dev/null +++ b/internal/features/system/data/ent/user_update.go @@ -0,0 +1,1328 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserUpdate is the builder for updating User entities. +type UserUpdate struct { + config + hooks []Hook + mutation *UserMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the UserUpdate builder. +func (_u *UserUpdate) Where(ps ...predicate.User) *UserUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *UserUpdate) SetUpdateTime(v time.Time) *UserUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetUUID sets the "uuid" field. +func (_u *UserUpdate) SetUUID(v string) *UserUpdate { + _u.mutation.SetUUID(v) + return _u +} + +// SetNillableUUID sets the "uuid" field if the given value is not nil. +func (_u *UserUpdate) SetNillableUUID(v *string) *UserUpdate { + if v != nil { + _u.SetUUID(*v) + } + return _u +} + +// SetAllowedIP sets the "allowed_ip" field. +func (_u *UserUpdate) SetAllowedIP(v string) *UserUpdate { + _u.mutation.SetAllowedIP(v) + return _u +} + +// SetNillableAllowedIP sets the "allowed_ip" field if the given value is not nil. +func (_u *UserUpdate) SetNillableAllowedIP(v *string) *UserUpdate { + if v != nil { + _u.SetAllowedIP(*v) + } + return _u +} + +// SetUsername sets the "username" field. +func (_u *UserUpdate) SetUsername(v string) *UserUpdate { + _u.mutation.SetUsername(v) + return _u +} + +// SetNillableUsername sets the "username" field if the given value is not nil. +func (_u *UserUpdate) SetNillableUsername(v *string) *UserUpdate { + if v != nil { + _u.SetUsername(*v) + } + return _u +} + +// SetNickname sets the "nickname" field. +func (_u *UserUpdate) SetNickname(v string) *UserUpdate { + _u.mutation.SetNickname(v) + return _u +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (_u *UserUpdate) SetNillableNickname(v *string) *UserUpdate { + if v != nil { + _u.SetNickname(*v) + } + return _u +} + +// SetAvatar sets the "avatar" field. +func (_u *UserUpdate) SetAvatar(v string) *UserUpdate { + _u.mutation.SetAvatar(v) + return _u +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (_u *UserUpdate) SetNillableAvatar(v *string) *UserUpdate { + if v != nil { + _u.SetAvatar(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *UserUpdate) SetName(v string) *UserUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *UserUpdate) SetNillableName(v *string) *UserUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetGender sets the "gender" field. +func (_u *UserUpdate) SetGender(v user.Gender) *UserUpdate { + _u.mutation.SetGender(v) + return _u +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (_u *UserUpdate) SetNillableGender(v *user.Gender) *UserUpdate { + if v != nil { + _u.SetGender(*v) + } + return _u +} + +// SetPassword sets the "password" field. +func (_u *UserUpdate) SetPassword(v string) *UserUpdate { + _u.mutation.SetPassword(v) + return _u +} + +// SetNillablePassword sets the "password" field if the given value is not nil. +func (_u *UserUpdate) SetNillablePassword(v *string) *UserUpdate { + if v != nil { + _u.SetPassword(*v) + } + return _u +} + +// SetPhone sets the "phone" field. +func (_u *UserUpdate) SetPhone(v string) *UserUpdate { + _u.mutation.SetPhone(v) + return _u +} + +// SetNillablePhone sets the "phone" field if the given value is not nil. +func (_u *UserUpdate) SetNillablePhone(v *string) *UserUpdate { + if v != nil { + _u.SetPhone(*v) + } + return _u +} + +// SetEmail sets the "email" field. +func (_u *UserUpdate) SetEmail(v string) *UserUpdate { + _u.mutation.SetEmail(v) + return _u +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate { + if v != nil { + _u.SetEmail(*v) + } + return _u +} + +// SetDepartment sets the "department" field. +func (_u *UserUpdate) SetDepartment(v string) *UserUpdate { + _u.mutation.SetDepartment(v) + return _u +} + +// SetNillableDepartment sets the "department" field if the given value is not nil. +func (_u *UserUpdate) SetNillableDepartment(v *string) *UserUpdate { + if v != nil { + _u.SetDepartment(*v) + } + return _u +} + +// SetRemark sets the "remark" field. +func (_u *UserUpdate) SetRemark(v string) *UserUpdate { + _u.mutation.SetRemark(v) + return _u +} + +// SetNillableRemark sets the "remark" field if the given value is not nil. +func (_u *UserUpdate) SetNillableRemark(v *string) *UserUpdate { + if v != nil { + _u.SetRemark(*v) + } + return _u +} + +// SetStatus sets the "status" field. +func (_u *UserUpdate) SetStatus(v int8) *UserUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *UserUpdate) SetNillableStatus(v *int8) *UserUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *UserUpdate) AddStatus(v int8) *UserUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// SetIsSystem sets the "is_system" field. +func (_u *UserUpdate) SetIsSystem(v bool) *UserUpdate { + _u.mutation.SetIsSystem(v) + return _u +} + +// SetNillableIsSystem sets the "is_system" field if the given value is not nil. +func (_u *UserUpdate) SetNillableIsSystem(v *bool) *UserUpdate { + if v != nil { + _u.SetIsSystem(*v) + } + return _u +} + +// SetLastLoginIP sets the "last_login_ip" field. +func (_u *UserUpdate) SetLastLoginIP(v string) *UserUpdate { + _u.mutation.SetLastLoginIP(v) + return _u +} + +// SetNillableLastLoginIP sets the "last_login_ip" field if the given value is not nil. +func (_u *UserUpdate) SetNillableLastLoginIP(v *string) *UserUpdate { + if v != nil { + _u.SetLastLoginIP(*v) + } + return _u +} + +// SetLastLoginTime sets the "last_login_time" field. +func (_u *UserUpdate) SetLastLoginTime(v time.Time) *UserUpdate { + _u.mutation.SetLastLoginTime(v) + return _u +} + +// SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. +func (_u *UserUpdate) SetNillableLastLoginTime(v *time.Time) *UserUpdate { + if v != nil { + _u.SetLastLoginTime(*v) + } + return _u +} + +// ClearLastLoginTime clears the value of the "last_login_time" field. +func (_u *UserUpdate) ClearLastLoginTime() *UserUpdate { + _u.mutation.ClearLastLoginTime() + return _u +} + +// AddRoleIDs adds the "roles" edge to the Role entity by IDs. +func (_u *UserUpdate) AddRoleIDs(ids ...int64) *UserUpdate { + _u.mutation.AddRoleIDs(ids...) + return _u +} + +// AddRoles adds the "roles" edges to the Role entity. +func (_u *UserUpdate) AddRoles(v ...*Role) *UserUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRoleIDs(ids...) +} + +// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. +func (_u *UserUpdate) AddUserRoleIDs(ids ...int) *UserUpdate { + _u.mutation.AddUserRoleIDs(ids...) + return _u +} + +// AddUserRoles adds the "user_roles" edges to the UserRole entity. +func (_u *UserUpdate) AddUserRoles(v ...*UserRole) *UserUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddUserRoleIDs(ids...) +} + +// Mutation returns the UserMutation object of the builder. +func (_u *UserUpdate) Mutation() *UserMutation { + return _u.mutation +} + +// ClearRoles clears all "roles" edges to the Role entity. +func (_u *UserUpdate) ClearRoles() *UserUpdate { + _u.mutation.ClearRoles() + return _u +} + +// RemoveRoleIDs removes the "roles" edge to Role entities by IDs. +func (_u *UserUpdate) RemoveRoleIDs(ids ...int64) *UserUpdate { + _u.mutation.RemoveRoleIDs(ids...) + return _u +} + +// RemoveRoles removes "roles" edges to Role entities. +func (_u *UserUpdate) RemoveRoles(v ...*Role) *UserUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRoleIDs(ids...) +} + +// ClearUserRoles clears all "user_roles" edges to the UserRole entity. +func (_u *UserUpdate) ClearUserRoles() *UserUpdate { + _u.mutation.ClearUserRoles() + return _u +} + +// RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. +func (_u *UserUpdate) RemoveUserRoleIDs(ids ...int) *UserUpdate { + _u.mutation.RemoveUserRoleIDs(ids...) + return _u +} + +// RemoveUserRoles removes "user_roles" edges to UserRole entities. +func (_u *UserUpdate) RemoveUserRoles(v ...*UserRole) *UserUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveUserRoleIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *UserUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *UserUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *UserUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := user.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserUpdate) check() error { + if v, ok := _u.mutation.UUID(); ok { + if err := user.UUIDValidator(v); err != nil { + return &ValidationError{Name: "uuid", err: fmt.Errorf(`ent: validator failed for field "User.uuid": %w`, err)} + } + } + if v, ok := _u.mutation.Username(); ok { + if err := user.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} + } + } + if v, ok := _u.mutation.Nickname(); ok { + if err := user.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} + } + } + if v, ok := _u.mutation.Avatar(); ok { + if err := user.AvatarValidator(v); err != nil { + return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} + } + } + if v, ok := _u.mutation.Name(); ok { + if err := user.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} + } + } + if v, ok := _u.mutation.Gender(); ok { + if err := user.GenderValidator(v); err != nil { + return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} + } + } + if v, ok := _u.mutation.Password(); ok { + if err := user.PasswordValidator(v); err != nil { + return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} + } + } + if v, ok := _u.mutation.Phone(); ok { + if err := user.PhoneValidator(v); err != nil { + return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "User.phone": %w`, err)} + } + } + if v, ok := _u.mutation.Email(); ok { + if err := user.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} + } + } + if v, ok := _u.mutation.Department(); ok { + if err := user.DepartmentValidator(v); err != nil { + return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} + } + } + if v, ok := _u.mutation.Remark(); ok { + if err := user.RemarkValidator(v); err != nil { + return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "User.remark": %w`, err)} + } + } + if v, ok := _u.mutation.LastLoginIP(); ok { + if err := user.LastLoginIPValidator(v); err != nil { + return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *UserUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.UUID(); ok { + _spec.SetField(user.FieldUUID, field.TypeString, value) + } + if value, ok := _u.mutation.AllowedIP(); ok { + _spec.SetField(user.FieldAllowedIP, field.TypeString, value) + } + if value, ok := _u.mutation.Username(); ok { + _spec.SetField(user.FieldUsername, field.TypeString, value) + } + if value, ok := _u.mutation.Nickname(); ok { + _spec.SetField(user.FieldNickname, field.TypeString, value) + } + if value, ok := _u.mutation.Avatar(); ok { + _spec.SetField(user.FieldAvatar, field.TypeString, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(user.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Gender(); ok { + _spec.SetField(user.FieldGender, field.TypeEnum, value) + } + if value, ok := _u.mutation.Password(); ok { + _spec.SetField(user.FieldPassword, field.TypeString, value) + } + if value, ok := _u.mutation.Phone(); ok { + _spec.SetField(user.FieldPhone, field.TypeString, value) + } + if value, ok := _u.mutation.Email(); ok { + _spec.SetField(user.FieldEmail, field.TypeString, value) + } + if value, ok := _u.mutation.Department(); ok { + _spec.SetField(user.FieldDepartment, field.TypeString, value) + } + if value, ok := _u.mutation.Remark(); ok { + _spec.SetField(user.FieldRemark, field.TypeString, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(user.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(user.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.IsSystem(); ok { + _spec.SetField(user.FieldIsSystem, field.TypeBool, value) + } + if value, ok := _u.mutation.LastLoginIP(); ok { + _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) + } + if value, ok := _u.mutation.LastLoginTime(); ok { + _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) + } + if _u.mutation.LastLoginTimeCleared() { + _spec.ClearField(user.FieldLastLoginTime, field.TypeTime) + } + if _u.mutation.RolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.RolesTable, + Columns: user.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.RolesTable, + Columns: user.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.RolesTable, + Columns: user.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.UserRolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserRolesTable, + Columns: []string{user.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserRolesTable, + Columns: []string{user.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserRolesTable, + Columns: []string{user.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{user.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// UserUpdateOne is the builder for updating a single User entity. +type UserUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdateTime sets the "update_time" field. +func (_u *UserUpdateOne) SetUpdateTime(v time.Time) *UserUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetUUID sets the "uuid" field. +func (_u *UserUpdateOne) SetUUID(v string) *UserUpdateOne { + _u.mutation.SetUUID(v) + return _u +} + +// SetNillableUUID sets the "uuid" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableUUID(v *string) *UserUpdateOne { + if v != nil { + _u.SetUUID(*v) + } + return _u +} + +// SetAllowedIP sets the "allowed_ip" field. +func (_u *UserUpdateOne) SetAllowedIP(v string) *UserUpdateOne { + _u.mutation.SetAllowedIP(v) + return _u +} + +// SetNillableAllowedIP sets the "allowed_ip" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableAllowedIP(v *string) *UserUpdateOne { + if v != nil { + _u.SetAllowedIP(*v) + } + return _u +} + +// SetUsername sets the "username" field. +func (_u *UserUpdateOne) SetUsername(v string) *UserUpdateOne { + _u.mutation.SetUsername(v) + return _u +} + +// SetNillableUsername sets the "username" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableUsername(v *string) *UserUpdateOne { + if v != nil { + _u.SetUsername(*v) + } + return _u +} + +// SetNickname sets the "nickname" field. +func (_u *UserUpdateOne) SetNickname(v string) *UserUpdateOne { + _u.mutation.SetNickname(v) + return _u +} + +// SetNillableNickname sets the "nickname" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableNickname(v *string) *UserUpdateOne { + if v != nil { + _u.SetNickname(*v) + } + return _u +} + +// SetAvatar sets the "avatar" field. +func (_u *UserUpdateOne) SetAvatar(v string) *UserUpdateOne { + _u.mutation.SetAvatar(v) + return _u +} + +// SetNillableAvatar sets the "avatar" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableAvatar(v *string) *UserUpdateOne { + if v != nil { + _u.SetAvatar(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *UserUpdateOne) SetName(v string) *UserUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableName(v *string) *UserUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetGender sets the "gender" field. +func (_u *UserUpdateOne) SetGender(v user.Gender) *UserUpdateOne { + _u.mutation.SetGender(v) + return _u +} + +// SetNillableGender sets the "gender" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableGender(v *user.Gender) *UserUpdateOne { + if v != nil { + _u.SetGender(*v) + } + return _u +} + +// SetPassword sets the "password" field. +func (_u *UserUpdateOne) SetPassword(v string) *UserUpdateOne { + _u.mutation.SetPassword(v) + return _u +} + +// SetNillablePassword sets the "password" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillablePassword(v *string) *UserUpdateOne { + if v != nil { + _u.SetPassword(*v) + } + return _u +} + +// SetPhone sets the "phone" field. +func (_u *UserUpdateOne) SetPhone(v string) *UserUpdateOne { + _u.mutation.SetPhone(v) + return _u +} + +// SetNillablePhone sets the "phone" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillablePhone(v *string) *UserUpdateOne { + if v != nil { + _u.SetPhone(*v) + } + return _u +} + +// SetEmail sets the "email" field. +func (_u *UserUpdateOne) SetEmail(v string) *UserUpdateOne { + _u.mutation.SetEmail(v) + return _u +} + +// SetNillableEmail sets the "email" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne { + if v != nil { + _u.SetEmail(*v) + } + return _u +} + +// SetDepartment sets the "department" field. +func (_u *UserUpdateOne) SetDepartment(v string) *UserUpdateOne { + _u.mutation.SetDepartment(v) + return _u +} + +// SetNillableDepartment sets the "department" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableDepartment(v *string) *UserUpdateOne { + if v != nil { + _u.SetDepartment(*v) + } + return _u +} + +// SetRemark sets the "remark" field. +func (_u *UserUpdateOne) SetRemark(v string) *UserUpdateOne { + _u.mutation.SetRemark(v) + return _u +} + +// SetNillableRemark sets the "remark" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableRemark(v *string) *UserUpdateOne { + if v != nil { + _u.SetRemark(*v) + } + return _u +} + +// SetStatus sets the "status" field. +func (_u *UserUpdateOne) SetStatus(v int8) *UserUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableStatus(v *int8) *UserUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *UserUpdateOne) AddStatus(v int8) *UserUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// SetIsSystem sets the "is_system" field. +func (_u *UserUpdateOne) SetIsSystem(v bool) *UserUpdateOne { + _u.mutation.SetIsSystem(v) + return _u +} + +// SetNillableIsSystem sets the "is_system" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableIsSystem(v *bool) *UserUpdateOne { + if v != nil { + _u.SetIsSystem(*v) + } + return _u +} + +// SetLastLoginIP sets the "last_login_ip" field. +func (_u *UserUpdateOne) SetLastLoginIP(v string) *UserUpdateOne { + _u.mutation.SetLastLoginIP(v) + return _u +} + +// SetNillableLastLoginIP sets the "last_login_ip" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableLastLoginIP(v *string) *UserUpdateOne { + if v != nil { + _u.SetLastLoginIP(*v) + } + return _u +} + +// SetLastLoginTime sets the "last_login_time" field. +func (_u *UserUpdateOne) SetLastLoginTime(v time.Time) *UserUpdateOne { + _u.mutation.SetLastLoginTime(v) + return _u +} + +// SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableLastLoginTime(v *time.Time) *UserUpdateOne { + if v != nil { + _u.SetLastLoginTime(*v) + } + return _u +} + +// ClearLastLoginTime clears the value of the "last_login_time" field. +func (_u *UserUpdateOne) ClearLastLoginTime() *UserUpdateOne { + _u.mutation.ClearLastLoginTime() + return _u +} + +// AddRoleIDs adds the "roles" edge to the Role entity by IDs. +func (_u *UserUpdateOne) AddRoleIDs(ids ...int64) *UserUpdateOne { + _u.mutation.AddRoleIDs(ids...) + return _u +} + +// AddRoles adds the "roles" edges to the Role entity. +func (_u *UserUpdateOne) AddRoles(v ...*Role) *UserUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddRoleIDs(ids...) +} + +// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. +func (_u *UserUpdateOne) AddUserRoleIDs(ids ...int) *UserUpdateOne { + _u.mutation.AddUserRoleIDs(ids...) + return _u +} + +// AddUserRoles adds the "user_roles" edges to the UserRole entity. +func (_u *UserUpdateOne) AddUserRoles(v ...*UserRole) *UserUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddUserRoleIDs(ids...) +} + +// Mutation returns the UserMutation object of the builder. +func (_u *UserUpdateOne) Mutation() *UserMutation { + return _u.mutation +} + +// ClearRoles clears all "roles" edges to the Role entity. +func (_u *UserUpdateOne) ClearRoles() *UserUpdateOne { + _u.mutation.ClearRoles() + return _u +} + +// RemoveRoleIDs removes the "roles" edge to Role entities by IDs. +func (_u *UserUpdateOne) RemoveRoleIDs(ids ...int64) *UserUpdateOne { + _u.mutation.RemoveRoleIDs(ids...) + return _u +} + +// RemoveRoles removes "roles" edges to Role entities. +func (_u *UserUpdateOne) RemoveRoles(v ...*Role) *UserUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveRoleIDs(ids...) +} + +// ClearUserRoles clears all "user_roles" edges to the UserRole entity. +func (_u *UserUpdateOne) ClearUserRoles() *UserUpdateOne { + _u.mutation.ClearUserRoles() + return _u +} + +// RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. +func (_u *UserUpdateOne) RemoveUserRoleIDs(ids ...int) *UserUpdateOne { + _u.mutation.RemoveUserRoleIDs(ids...) + return _u +} + +// RemoveUserRoles removes "user_roles" edges to UserRole entities. +func (_u *UserUpdateOne) RemoveUserRoles(v ...*UserRole) *UserUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveUserRoleIDs(ids...) +} + +// Where appends a list predicates to the UserUpdate builder. +func (_u *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated User entity. +func (_u *UserUpdateOne) Save(ctx context.Context) (*User, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserUpdateOne) SaveX(ctx context.Context) *User { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *UserUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *UserUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := user.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserUpdateOne) check() error { + if v, ok := _u.mutation.UUID(); ok { + if err := user.UUIDValidator(v); err != nil { + return &ValidationError{Name: "uuid", err: fmt.Errorf(`ent: validator failed for field "User.uuid": %w`, err)} + } + } + if v, ok := _u.mutation.Username(); ok { + if err := user.UsernameValidator(v); err != nil { + return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} + } + } + if v, ok := _u.mutation.Nickname(); ok { + if err := user.NicknameValidator(v); err != nil { + return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} + } + } + if v, ok := _u.mutation.Avatar(); ok { + if err := user.AvatarValidator(v); err != nil { + return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} + } + } + if v, ok := _u.mutation.Name(); ok { + if err := user.NameValidator(v); err != nil { + return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} + } + } + if v, ok := _u.mutation.Gender(); ok { + if err := user.GenderValidator(v); err != nil { + return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} + } + } + if v, ok := _u.mutation.Password(); ok { + if err := user.PasswordValidator(v); err != nil { + return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} + } + } + if v, ok := _u.mutation.Phone(); ok { + if err := user.PhoneValidator(v); err != nil { + return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "User.phone": %w`, err)} + } + } + if v, ok := _u.mutation.Email(); ok { + if err := user.EmailValidator(v); err != nil { + return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} + } + } + if v, ok := _u.mutation.Department(); ok { + if err := user.DepartmentValidator(v); err != nil { + return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} + } + } + if v, ok := _u.mutation.Remark(); ok { + if err := user.RemarkValidator(v); err != nil { + return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "User.remark": %w`, err)} + } + } + if v, ok := _u.mutation.LastLoginIP(); ok { + if err := user.LastLoginIPValidator(v); err != nil { + return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *UserUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) + for _, f := range fields { + if !user.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != user.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.UUID(); ok { + _spec.SetField(user.FieldUUID, field.TypeString, value) + } + if value, ok := _u.mutation.AllowedIP(); ok { + _spec.SetField(user.FieldAllowedIP, field.TypeString, value) + } + if value, ok := _u.mutation.Username(); ok { + _spec.SetField(user.FieldUsername, field.TypeString, value) + } + if value, ok := _u.mutation.Nickname(); ok { + _spec.SetField(user.FieldNickname, field.TypeString, value) + } + if value, ok := _u.mutation.Avatar(); ok { + _spec.SetField(user.FieldAvatar, field.TypeString, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(user.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.Gender(); ok { + _spec.SetField(user.FieldGender, field.TypeEnum, value) + } + if value, ok := _u.mutation.Password(); ok { + _spec.SetField(user.FieldPassword, field.TypeString, value) + } + if value, ok := _u.mutation.Phone(); ok { + _spec.SetField(user.FieldPhone, field.TypeString, value) + } + if value, ok := _u.mutation.Email(); ok { + _spec.SetField(user.FieldEmail, field.TypeString, value) + } + if value, ok := _u.mutation.Department(); ok { + _spec.SetField(user.FieldDepartment, field.TypeString, value) + } + if value, ok := _u.mutation.Remark(); ok { + _spec.SetField(user.FieldRemark, field.TypeString, value) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(user.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(user.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.IsSystem(); ok { + _spec.SetField(user.FieldIsSystem, field.TypeBool, value) + } + if value, ok := _u.mutation.LastLoginIP(); ok { + _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) + } + if value, ok := _u.mutation.LastLoginTime(); ok { + _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) + } + if _u.mutation.LastLoginTimeCleared() { + _spec.ClearField(user.FieldLastLoginTime, field.TypeTime) + } + if _u.mutation.RolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.RolesTable, + Columns: user.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.RolesTable, + Columns: user.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: user.RolesTable, + Columns: user.RolesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.UserRolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserRolesTable, + Columns: []string{user.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserRolesTable, + Columns: []string{user.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: user.UserRolesTable, + Columns: []string{user.UserRolesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &User{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{user.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} + +// SetUser set the User +func (uu *UserUpdate) SetUser(input *User, fields ...string) *UserUpdate { + m := uu.mutation + if len(fields) == 0 { + fields = user.OmitColumns(user.FieldID) + } + _ = m.SetFields(input, fields...) + return uu +} + +// SetUserWithZero set the User +func (uu *UserUpdate) SetUserWithZero(input *User, fields ...string) *UserUpdate { + m := uu.mutation + if len(fields) == 0 { + fields = user.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return uu +} + +// SetUser set the User +func (uuo *UserUpdateOne) SetUser(input *User, fields ...string) *UserUpdateOne { + m := uuo.mutation + if len(fields) == 0 { + fields = user.OmitColumns(user.FieldID) + } + _ = m.SetFields(input, fields...) + return uuo +} + +// SetUserWithZero set the User +func (uuo *UserUpdateOne) SetUserWithZero(input *User, fields ...string) *UserUpdateOne { + m := uuo.mutation + if len(fields) == 0 { + fields = user.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return uuo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (uuo *UserUpdateOne) Omit(fields ...string) *UserUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + uuo.fields = []string(nil) + for _, col := range user.Columns { + if _, ok := omits[col]; !ok { + uuo.fields = append(uuo.fields, col) + } + } + return uuo +} diff --git a/internal/features/system/data/ent/userrole.go b/internal/features/system/data/ent/userrole.go new file mode 100644 index 00000000..920ef7c3 --- /dev/null +++ b/internal/features/system/data/ent/userrole.go @@ -0,0 +1,160 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + "strings" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// User-Role mapping table +type UserRole struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // UserID holds the value of the "user_id" field. + UserID int64 `json:"user_id,omitempty"` + // RoleID holds the value of the "role_id" field. + RoleID int64 `json:"role_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the UserRoleQuery when eager-loading is set. + Edges UserRoleEdges `json:"edges"` + selectValues sql.SelectValues +} + +// UserRoleEdges holds the relations/edges for other nodes in the graph. +type UserRoleEdges struct { + // User holds the value of the user edge. + User *User `json:"user,omitempty"` + // Role holds the value of the role edge. + Role *Role `json:"role,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// UserOrErr returns the User value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e UserRoleEdges) UserOrErr() (*User, error) { + if e.User != nil { + return e.User, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} + } + return nil, &NotLoadedError{edge: "user"} +} + +// RoleOrErr returns the Role value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e UserRoleEdges) RoleOrErr() (*Role, error) { + if e.Role != nil { + return e.Role, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: role.Label} + } + return nil, &NotLoadedError{edge: "role"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*UserRole) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case userrole.FieldID, userrole.FieldUserID, userrole.FieldRoleID: + values[i] = new(sql.NullInt64) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the UserRole fields. +func (_m *UserRole) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case userrole.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int(value.Int64) + case userrole.FieldUserID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field user_id", values[i]) + } else if value.Valid { + _m.UserID = value.Int64 + } + case userrole.FieldRoleID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field role_id", values[i]) + } else if value.Valid { + _m.RoleID = value.Int64 + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the UserRole. +// This includes values selected through modifiers, order, etc. +func (_m *UserRole) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryUser queries the "user" edge of the UserRole entity. +func (_m *UserRole) QueryUser() *UserQuery { + return NewUserRoleClient(_m.config).QueryUser(_m) +} + +// QueryRole queries the "role" edge of the UserRole entity. +func (_m *UserRole) QueryRole() *RoleQuery { + return NewUserRoleClient(_m.config).QueryRole(_m) +} + +// Update returns a builder for updating this UserRole. +// Note that you need to call UserRole.Unwrap() before calling this method if this UserRole +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *UserRole) Update() *UserRoleUpdateOne { + return NewUserRoleClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the UserRole entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *UserRole) Unwrap() *UserRole { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: UserRole is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *UserRole) String() string { + var builder strings.Builder + builder.WriteString("UserRole(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("user_id=") + builder.WriteString(fmt.Sprintf("%v", _m.UserID)) + builder.WriteString(", ") + builder.WriteString("role_id=") + builder.WriteString(fmt.Sprintf("%v", _m.RoleID)) + builder.WriteByte(')') + return builder.String() +} + +// UserRoles is a parsable slice of UserRole. +type UserRoles []*UserRole diff --git a/internal/features/system/data/ent/userrole/userrole.go b/internal/features/system/data/ent/userrole/userrole.go new file mode 100644 index 00000000..71028bfd --- /dev/null +++ b/internal/features/system/data/ent/userrole/userrole.go @@ -0,0 +1,164 @@ +// Code generated by ent, DO NOT EDIT. + +package userrole + +import ( + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the userrole type in the database. + Label = "user_role" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldUserID holds the string denoting the user_id field in the database. + FieldUserID = "user_id" + // FieldRoleID holds the string denoting the role_id field in the database. + FieldRoleID = "role_id" + // EdgeUser holds the string denoting the user edge name in mutations. + EdgeUser = "user" + // EdgeRole holds the string denoting the role edge name in mutations. + EdgeRole = "role" + // Table holds the table name of the userrole in the database. + Table = "sys_user_roles" + // UserTable is the table that holds the user relation/edge. + UserTable = "sys_user_roles" + // UserInverseTable is the table name for the User entity. + // It exists in this package in order to avoid circular dependency with the "user" package. + UserInverseTable = "sys_users" + // UserColumn is the table column denoting the user relation/edge. + UserColumn = "user_id" + // RoleTable is the table that holds the role relation/edge. + RoleTable = "sys_user_roles" + // RoleInverseTable is the table name for the Role entity. + // It exists in this package in order to avoid circular dependency with the "role" package. + RoleInverseTable = "sys_roles" + // RoleColumn is the table column denoting the role relation/edge. + RoleColumn = "role_id" +) + +// Columns holds all SQL columns for userrole fields. +var Columns = []string{ + FieldID, + FieldUserID, + FieldRoleID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +// OrderOption defines the ordering options for the UserRole queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByUserID orders the results by the user_id field. +func ByUserID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUserID, opts...).ToFunc() +} + +// ByRoleID orders the results by the role_id field. +func ByRoleID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRoleID, opts...).ToFunc() +} + +// ByUserField orders the results by user field. +func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) + } +} + +// ByRoleField orders the results by role field. +func ByRoleField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newRoleStep(), sql.OrderByField(field, opts...)) + } +} +func newUserStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(UserInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) +} +func newRoleStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(RoleInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/features/system/data/ent/userrole/where.go b/internal/features/system/data/ent/userrole/where.go new file mode 100644 index 00000000..53430300 --- /dev/null +++ b/internal/features/system/data/ent/userrole/where.go @@ -0,0 +1,166 @@ +// Code generated by ent, DO NOT EDIT. + +package userrole + +import ( + "origadmin/application/admin/internal/features/system/data/ent/predicate" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int) predicate.UserRole { + return predicate.UserRole(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int) predicate.UserRole { + return predicate.UserRole(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int) predicate.UserRole { + return predicate.UserRole(sql.FieldLTE(FieldID, id)) +} + +// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. +func UserID(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldUserID, v)) +} + +// RoleID applies equality check predicate on the "role_id" field. It's identical to RoleIDEQ. +func RoleID(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldRoleID, v)) +} + +// UserIDEQ applies the EQ predicate on the "user_id" field. +func UserIDEQ(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldUserID, v)) +} + +// UserIDNEQ applies the NEQ predicate on the "user_id" field. +func UserIDNEQ(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldNEQ(FieldUserID, v)) +} + +// UserIDIn applies the In predicate on the "user_id" field. +func UserIDIn(vs ...int64) predicate.UserRole { + return predicate.UserRole(sql.FieldIn(FieldUserID, vs...)) +} + +// UserIDNotIn applies the NotIn predicate on the "user_id" field. +func UserIDNotIn(vs ...int64) predicate.UserRole { + return predicate.UserRole(sql.FieldNotIn(FieldUserID, vs...)) +} + +// RoleIDEQ applies the EQ predicate on the "role_id" field. +func RoleIDEQ(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldEQ(FieldRoleID, v)) +} + +// RoleIDNEQ applies the NEQ predicate on the "role_id" field. +func RoleIDNEQ(v int64) predicate.UserRole { + return predicate.UserRole(sql.FieldNEQ(FieldRoleID, v)) +} + +// RoleIDIn applies the In predicate on the "role_id" field. +func RoleIDIn(vs ...int64) predicate.UserRole { + return predicate.UserRole(sql.FieldIn(FieldRoleID, vs...)) +} + +// RoleIDNotIn applies the NotIn predicate on the "role_id" field. +func RoleIDNotIn(vs ...int64) predicate.UserRole { + return predicate.UserRole(sql.FieldNotIn(FieldRoleID, vs...)) +} + +// HasUser applies the HasEdge predicate on the "user" edge. +func HasUser() predicate.UserRole { + return predicate.UserRole(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). +func HasUserWith(preds ...predicate.User) predicate.UserRole { + return predicate.UserRole(func(s *sql.Selector) { + step := newUserStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasRole applies the HasEdge predicate on the "role" edge. +func HasRole() predicate.UserRole { + return predicate.UserRole(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasRoleWith applies the HasEdge predicate on the "role" edge with a given conditions (other predicates). +func HasRoleWith(preds ...predicate.Role) predicate.UserRole { + return predicate.UserRole(func(s *sql.Selector) { + step := newRoleStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.UserRole) predicate.UserRole { + return predicate.UserRole(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.UserRole) predicate.UserRole { + return predicate.UserRole(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.UserRole) predicate.UserRole { + return predicate.UserRole(sql.NotPredicates(p)) +} diff --git a/internal/features/system/data/ent/userrole_create.go b/internal/features/system/data/ent/userrole_create.go new file mode 100644 index 00000000..5fda64c2 --- /dev/null +++ b/internal/features/system/data/ent/userrole_create.go @@ -0,0 +1,260 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserRoleCreate is the builder for creating a UserRole entity. +type UserRoleCreate struct { + config + mutation *UserRoleMutation + hooks []Hook +} + +// SetUserID sets the "user_id" field. +func (_c *UserRoleCreate) SetUserID(v int64) *UserRoleCreate { + _c.mutation.SetUserID(v) + return _c +} + +// SetRoleID sets the "role_id" field. +func (_c *UserRoleCreate) SetRoleID(v int64) *UserRoleCreate { + _c.mutation.SetRoleID(v) + return _c +} + +// SetUser sets the "user" edge to the User entity. +func (_c *UserRoleCreate) SetUser(v *User) *UserRoleCreate { + return _c.SetUserID(v.ID) +} + +// SetRole sets the "role" edge to the Role entity. +func (_c *UserRoleCreate) SetRole(v *Role) *UserRoleCreate { + return _c.SetRoleID(v.ID) +} + +// Mutation returns the UserRoleMutation object of the builder. +func (_c *UserRoleCreate) Mutation() *UserRoleMutation { + return _c.mutation +} + +// Save creates the UserRole in the database. +func (_c *UserRoleCreate) Save(ctx context.Context) (*UserRole, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *UserRoleCreate) SaveX(ctx context.Context) *UserRole { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserRoleCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserRoleCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *UserRoleCreate) check() error { + if _, ok := _c.mutation.UserID(); !ok { + return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserRole.user_id"`)} + } + if _, ok := _c.mutation.RoleID(); !ok { + return &ValidationError{Name: "role_id", err: errors.New(`ent: missing required field "UserRole.role_id"`)} + } + if len(_c.mutation.UserIDs()) == 0 { + return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserRole.user"`)} + } + if len(_c.mutation.RoleIDs()) == 0 { + return &ValidationError{Name: "role", err: errors.New(`ent: missing required edge "UserRole.role"`)} + } + return nil +} + +func (_c *UserRoleCreate) sqlSave(ctx context.Context) (*UserRole, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + id := _spec.ID.Value.(int64) + _node.ID = int(id) + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *UserRoleCreate) createSpec() (*UserRole, *sqlgraph.CreateSpec) { + var ( + _node = &UserRole{config: _c.config} + _spec = sqlgraph.NewCreateSpec(userrole.Table, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) + ) + if nodes := _c.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: userrole.UserTable, + Columns: []string{userrole.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.UserID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.RoleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: userrole.RoleTable, + Columns: []string{userrole.RoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.RoleID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SetUserRole set the UserRole +func (_c *UserRoleCreate) SetUserRole(input *UserRole, fields ...string) *UserRoleCreate { + m := _c.mutation + if len(fields) == 0 { + fields = userrole.Columns + } + _ = m.SetFields(input, fields...) + return _c +} + +// SetUserRoleWithZero set the UserRole +func (_c *UserRoleCreate) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleCreate { + m := _c.mutation + if len(fields) == 0 { + fields = userrole.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return _c +} + +// UserRoleCreateBulk is the builder for creating many UserRole entities in bulk. +type UserRoleCreateBulk struct { + config + err error + builders []*UserRoleCreate +} + +// Save creates the UserRole entities in the database. +func (_c *UserRoleCreateBulk) Save(ctx context.Context) ([]*UserRole, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*UserRole, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserRoleMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *UserRoleCreateBulk) SaveX(ctx context.Context) []*UserRole { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *UserRoleCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *UserRoleCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/userrole_delete.go b/internal/features/system/data/ent/userrole_delete.go new file mode 100644 index 00000000..c81494d8 --- /dev/null +++ b/internal/features/system/data/ent/userrole_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserRoleDelete is the builder for deleting a UserRole entity. +type UserRoleDelete struct { + config + hooks []Hook + mutation *UserRoleMutation +} + +// Where appends a list predicates to the UserRoleDelete builder. +func (_d *UserRoleDelete) Where(ps ...predicate.UserRole) *UserRoleDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *UserRoleDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserRoleDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *UserRoleDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(userrole.Table, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// UserRoleDeleteOne is the builder for deleting a single UserRole entity. +type UserRoleDeleteOne struct { + _d *UserRoleDelete +} + +// Where appends a list predicates to the UserRoleDelete builder. +func (_d *UserRoleDeleteOne) Where(ps ...predicate.UserRole) *UserRoleDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *UserRoleDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{userrole.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *UserRoleDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/features/system/data/ent/userrole_query.go b/internal/features/system/data/ent/userrole_query.go new file mode 100644 index 00000000..15534ede --- /dev/null +++ b/internal/features/system/data/ent/userrole_query.go @@ -0,0 +1,763 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserRoleQuery is the builder for querying UserRole entities. +type UserRoleQuery struct { + config + ctx *QueryContext + order []userrole.OrderOption + inters []Interceptor + predicates []predicate.UserRole + withUser *UserQuery + withRole *RoleQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UserRoleQuery builder. +func (_q *UserRoleQuery) Where(ps ...predicate.UserRole) *UserRoleQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *UserRoleQuery) Limit(limit int) *UserRoleQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *UserRoleQuery) Offset(offset int) *UserRoleQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *UserRoleQuery) Unique(unique bool) *UserRoleQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *UserRoleQuery) Order(o ...userrole.OrderOption) *UserRoleQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryUser chains the current query on the "user" edge. +func (_q *UserRoleQuery) QueryUser() *UserQuery { + query := (&UserClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(userrole.Table, userrole.FieldID, selector), + sqlgraph.To(user.Table, user.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, userrole.UserTable, userrole.UserColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryRole chains the current query on the "role" edge. +func (_q *UserRoleQuery) QueryRole() *RoleQuery { + query := (&RoleClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(userrole.Table, userrole.FieldID, selector), + sqlgraph.To(role.Table, role.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, userrole.RoleTable, userrole.RoleColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first UserRole entity from the query. +// Returns a *NotFoundError when no UserRole was found. +func (_q *UserRoleQuery) First(ctx context.Context) (*UserRole, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{userrole.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *UserRoleQuery) FirstX(ctx context.Context) *UserRole { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first UserRole ID from the query. +// Returns a *NotFoundError when no UserRole ID was found. +func (_q *UserRoleQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{userrole.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *UserRoleQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single UserRole entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one UserRole entity is found. +// Returns a *NotFoundError when no UserRole entities are found. +func (_q *UserRoleQuery) Only(ctx context.Context) (*UserRole, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{userrole.Label} + default: + return nil, &NotSingularError{userrole.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *UserRoleQuery) OnlyX(ctx context.Context) *UserRole { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only UserRole ID in the query. +// Returns a *NotSingularError when more than one UserRole ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *UserRoleQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{userrole.Label} + default: + err = &NotSingularError{userrole.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *UserRoleQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of UserRoles. +func (_q *UserRoleQuery) All(ctx context.Context) ([]*UserRole, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*UserRole, *UserRoleQuery]() + return withInterceptors[[]*UserRole](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *UserRoleQuery) AllX(ctx context.Context) []*UserRole { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of UserRole IDs. +func (_q *UserRoleQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(userrole.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *UserRoleQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *UserRoleQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*UserRoleQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *UserRoleQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *UserRoleQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *UserRoleQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserRoleQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *UserRoleQuery) Clone() *UserRoleQuery { + if _q == nil { + return nil + } + return &UserRoleQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]userrole.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.UserRole{}, _q.predicates...), + withUser: _q.withUser.Clone(), + withRole: _q.withRole.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithUser tells the query-builder to eager-load the nodes that are connected to +// the "user" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *UserRoleQuery) WithUser(opts ...func(*UserQuery)) *UserRoleQuery { + query := (&UserClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withUser = query + return _q +} + +// WithRole tells the query-builder to eager-load the nodes that are connected to +// the "role" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *UserRoleQuery) WithRole(opts ...func(*RoleQuery)) *UserRoleQuery { + query := (&RoleClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withRole = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// UserID int64 `json:"user_id,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.UserRole.Query(). +// GroupBy(userrole.FieldUserID). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *UserRoleQuery) GroupBy(field string, fields ...string) *UserRoleGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &UserRoleGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = userrole.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// UserID int64 `json:"user_id,omitempty"` +// } +// +// client.UserRole.Query(). +// Select(userrole.FieldUserID). +// Scan(ctx, &v) +func (_q *UserRoleQuery) Select(fields ...string) *UserRoleSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &UserRoleSelect{UserRoleQuery: _q} + sbuild.label = userrole.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a UserRoleSelect configured with the given aggregations. +func (_q *UserRoleQuery) Aggregate(fns ...AggregateFunc) *UserRoleSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *UserRoleQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !userrole.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *UserRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserRole, error) { + var ( + nodes = []*UserRole{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withUser != nil, + _q.withRole != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*UserRole).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &UserRole{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withUser; query != nil { + if err := _q.loadUser(ctx, query, nodes, nil, + func(n *UserRole, e *User) { n.Edges.User = e }); err != nil { + return nil, err + } + } + if query := _q.withRole; query != nil { + if err := _q.loadRole(ctx, query, nodes, nil, + func(n *UserRole, e *Role) { n.Edges.Role = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *UserRoleQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserRole, init func(*UserRole), assign func(*UserRole, *User)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*UserRole) + for i := range nodes { + fk := nodes[i].UserID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(user.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "user_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *UserRoleQuery) loadRole(ctx context.Context, query *RoleQuery, nodes []*UserRole, init func(*UserRole), assign func(*UserRole, *Role)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*UserRole) + for i := range nodes { + fk := nodes[i].RoleID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(role.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "role_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *UserRoleQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *UserRoleQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(userrole.Table, userrole.Columns, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, userrole.FieldID) + for i := range fields { + if fields[i] != userrole.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withUser != nil { + _spec.Node.AddColumnOnce(userrole.FieldUserID) + } + if _q.withRole != nil { + _spec.Node.AddColumnOnce(userrole.FieldRoleID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *UserRoleQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(userrole.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = userrole.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *UserRoleQuery) ForUpdate(opts ...sql.LockOption) *UserRoleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *UserRoleQuery) ForShare(opts ...sql.LockOption) *UserRoleQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *UserRoleQuery) Modify(modifiers ...func(s *sql.Selector)) *UserRoleSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// UserID int64 `json:"user_id,omitempty"` +// RoleID int64 `json:"role_id,omitempty"` +// } +// +// client.UserRole.Query(). +// Omit( +// userrole.FieldUserID, +// userrole.FieldRoleID, +// ). +// Scan(ctx, &v) +func (urq *UserRoleQuery) Omit(fields ...string) *UserRoleSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range userrole.Columns { + if _, ok := omits[col]; !ok { + urq.ctx.Fields = append(urq.ctx.Fields, col) + } + } + + sbuild := &UserRoleSelect{UserRoleQuery: urq} + sbuild.label = userrole.Label + sbuild.flds, sbuild.scan = &urq.ctx.Fields, sbuild.Scan + return sbuild +} + +// UserRoleGroupBy is the group-by builder for UserRole entities. +type UserRoleGroupBy struct { + selector + build *UserRoleQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *UserRoleGroupBy) Aggregate(fns ...AggregateFunc) *UserRoleGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *UserRoleGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserRoleQuery, *UserRoleGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *UserRoleGroupBy) sqlScan(ctx context.Context, root *UserRoleQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// UserRoleSelect is the builder for selecting fields of UserRole entities. +type UserRoleSelect struct { + *UserRoleQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *UserRoleSelect) Aggregate(fns ...AggregateFunc) *UserRoleSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *UserRoleSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*UserRoleQuery, *UserRoleSelect](ctx, _s.UserRoleQuery, _s, _s.inters, v) +} + +func (_s *UserRoleSelect) sqlScan(ctx context.Context, root *UserRoleQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *UserRoleSelect) Modify(modifiers ...func(s *sql.Selector)) *UserRoleSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/internal/features/system/data/ent/userrole_update.go b/internal/features/system/data/ent/userrole_update.go new file mode 100644 index 00000000..c8e54ad8 --- /dev/null +++ b/internal/features/system/data/ent/userrole_update.go @@ -0,0 +1,493 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/features/system/data/ent/predicate" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/data/ent/userrole" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// UserRoleUpdate is the builder for updating UserRole entities. +type UserRoleUpdate struct { + config + hooks []Hook + mutation *UserRoleMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the UserRoleUpdate builder. +func (_u *UserRoleUpdate) Where(ps ...predicate.UserRole) *UserRoleUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUserID sets the "user_id" field. +func (_u *UserRoleUpdate) SetUserID(v int64) *UserRoleUpdate { + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *UserRoleUpdate) SetNillableUserID(v *int64) *UserRoleUpdate { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// SetRoleID sets the "role_id" field. +func (_u *UserRoleUpdate) SetRoleID(v int64) *UserRoleUpdate { + _u.mutation.SetRoleID(v) + return _u +} + +// SetNillableRoleID sets the "role_id" field if the given value is not nil. +func (_u *UserRoleUpdate) SetNillableRoleID(v *int64) *UserRoleUpdate { + if v != nil { + _u.SetRoleID(*v) + } + return _u +} + +// SetUser sets the "user" edge to the User entity. +func (_u *UserRoleUpdate) SetUser(v *User) *UserRoleUpdate { + return _u.SetUserID(v.ID) +} + +// SetRole sets the "role" edge to the Role entity. +func (_u *UserRoleUpdate) SetRole(v *Role) *UserRoleUpdate { + return _u.SetRoleID(v.ID) +} + +// Mutation returns the UserRoleMutation object of the builder. +func (_u *UserRoleUpdate) Mutation() *UserRoleMutation { + return _u.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (_u *UserRoleUpdate) ClearUser() *UserRoleUpdate { + _u.mutation.ClearUser() + return _u +} + +// ClearRole clears the "role" edge to the Role entity. +func (_u *UserRoleUpdate) ClearRole() *UserRoleUpdate { + _u.mutation.ClearRole() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *UserRoleUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserRoleUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *UserRoleUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserRoleUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserRoleUpdate) check() error { + if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "UserRole.user"`) + } + if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "UserRole.role"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *UserRoleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserRoleUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *UserRoleUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(userrole.Table, userrole.Columns, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if _u.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: userrole.UserTable, + Columns: []string{userrole.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: userrole.UserTable, + Columns: []string{userrole.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.RoleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: userrole.RoleTable, + Columns: []string{userrole.RoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: userrole.RoleTable, + Columns: []string{userrole.RoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{userrole.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// UserRoleUpdateOne is the builder for updating a single UserRole entity. +type UserRoleUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserRoleMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUserID sets the "user_id" field. +func (_u *UserRoleUpdateOne) SetUserID(v int64) *UserRoleUpdateOne { + _u.mutation.SetUserID(v) + return _u +} + +// SetNillableUserID sets the "user_id" field if the given value is not nil. +func (_u *UserRoleUpdateOne) SetNillableUserID(v *int64) *UserRoleUpdateOne { + if v != nil { + _u.SetUserID(*v) + } + return _u +} + +// SetRoleID sets the "role_id" field. +func (_u *UserRoleUpdateOne) SetRoleID(v int64) *UserRoleUpdateOne { + _u.mutation.SetRoleID(v) + return _u +} + +// SetNillableRoleID sets the "role_id" field if the given value is not nil. +func (_u *UserRoleUpdateOne) SetNillableRoleID(v *int64) *UserRoleUpdateOne { + if v != nil { + _u.SetRoleID(*v) + } + return _u +} + +// SetUser sets the "user" edge to the User entity. +func (_u *UserRoleUpdateOne) SetUser(v *User) *UserRoleUpdateOne { + return _u.SetUserID(v.ID) +} + +// SetRole sets the "role" edge to the Role entity. +func (_u *UserRoleUpdateOne) SetRole(v *Role) *UserRoleUpdateOne { + return _u.SetRoleID(v.ID) +} + +// Mutation returns the UserRoleMutation object of the builder. +func (_u *UserRoleUpdateOne) Mutation() *UserRoleMutation { + return _u.mutation +} + +// ClearUser clears the "user" edge to the User entity. +func (_u *UserRoleUpdateOne) ClearUser() *UserRoleUpdateOne { + _u.mutation.ClearUser() + return _u +} + +// ClearRole clears the "role" edge to the Role entity. +func (_u *UserRoleUpdateOne) ClearRole() *UserRoleUpdateOne { + _u.mutation.ClearRole() + return _u +} + +// Where appends a list predicates to the UserRoleUpdate builder. +func (_u *UserRoleUpdateOne) Where(ps ...predicate.UserRole) *UserRoleUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *UserRoleUpdateOne) Select(field string, fields ...string) *UserRoleUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated UserRole entity. +func (_u *UserRoleUpdateOne) Save(ctx context.Context) (*UserRole, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *UserRoleUpdateOne) SaveX(ctx context.Context) *UserRole { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *UserRoleUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *UserRoleUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *UserRoleUpdateOne) check() error { + if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "UserRole.user"`) + } + if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "UserRole.role"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *UserRoleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserRoleUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(userrole.Table, userrole.Columns, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserRole.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, userrole.FieldID) + for _, f := range fields { + if !userrole.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != userrole.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if _u.mutation.UserCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: userrole.UserTable, + Columns: []string{userrole.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: userrole.UserTable, + Columns: []string{userrole.UserColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.RoleCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: userrole.RoleTable, + Columns: []string{userrole.RoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: userrole.RoleTable, + Columns: []string{userrole.RoleColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &UserRole{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{userrole.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} + +// SetUserRole set the UserRole +func (uru *UserRoleUpdate) SetUserRole(input *UserRole, fields ...string) *UserRoleUpdate { + m := uru.mutation + if len(fields) == 0 { + fields = userrole.OmitColumns(userrole.FieldID) + } + _ = m.SetFields(input, fields...) + return uru +} + +// SetUserRoleWithZero set the UserRole +func (uru *UserRoleUpdate) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleUpdate { + m := uru.mutation + if len(fields) == 0 { + fields = userrole.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return uru +} + +// SetUserRole set the UserRole +func (uruo *UserRoleUpdateOne) SetUserRole(input *UserRole, fields ...string) *UserRoleUpdateOne { + m := uruo.mutation + if len(fields) == 0 { + fields = userrole.OmitColumns(userrole.FieldID) + } + _ = m.SetFields(input, fields...) + return uruo +} + +// SetUserRoleWithZero set the UserRole +func (uruo *UserRoleUpdateOne) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleUpdateOne { + m := uruo.mutation + if len(fields) == 0 { + fields = userrole.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return uruo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (uruo *UserRoleUpdateOne) Omit(fields ...string) *UserRoleUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + uruo.fields = []string(nil) + for _, col := range userrole.Columns { + if _, ok := omits[col]; !ok { + uruo.fields = append(uruo.fields, col) + } + } + return uruo +} diff --git a/internal/features/system/data/permission.go b/internal/features/system/data/permission.go new file mode 100644 index 00000000..f1011432 --- /dev/null +++ b/internal/features/system/data/permission.go @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package data + +import ( + "context" + + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/system/data/ent" + "origadmin/application/admin/internal/features/system/data/ent/permission" + "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/db" +) + +type permissionRepo struct { + db *ent.Client +} + +func (repo *permissionRepo) Get(ctx context.Context, id int64, options ...dto.PermissionQueryOption) (*types.Permission, error) { + result, err := repo.db.Permission.Get(ctx, int(id)) + if err != nil { + return nil, err + } + return dto.ConvertPermissionToPermissionPB(result), nil +} + +func (repo *permissionRepo) Create(ctx context.Context, p *types.Permission, options ...dto.PermissionQueryOption) (*types.Permission, error) { + create := repo.db.Permission.Create(). + SetName(p.Name) + + if len(p.ResourceIds) > 0 { + create.AddResourceIDs(p.ResourceIds...) + } + + // ... set other fields + + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertPermissionToPermissionPB(saved), nil +} + +func (repo *permissionRepo) Delete(ctx context.Context, id int64) error { + return repo.db.Permission.DeleteOneID(int(id)).Exec(ctx) +} + +func (repo *permissionRepo) Update(ctx context.Context, p *types.Permission, options ...dto.PermissionQueryOption) (*types.Permission, error) { + update := repo.db.Permission.UpdateOneID(int(p.Id)) + + if len(p.ResourceIds) > 0 { + update.ClearResources().AddResourceIDs(p.ResourceIds...) + } + + // ... set other fields + + saved, err := update.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertPermissionToPermissionPB(saved), nil +} + +func (repo *permissionRepo) List(ctx context.Context, in *system.ListPermissionsRequest, options ...dto.PermissionQueryOption) ([]*types.Permission, int32, error) { + query := repo.db.Permission.Query() + + if len(in.DataScopes) > 0 { + query = query.Where(permission.DataScopeIn(in.DataScopes...)) + } + + if in.OnlyCount { + count, err := query.Count(ctx) + return nil, int32(count), err + } + + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, 0, err + } + + query = db.QueryPage(query, in) + + result, err := query.All(ctx) + return dto.ConvertPermissionsToPermissionsPB(result), int32(count), err +} + +// NewPermissionRepo . +func NewPermissionRepo(d *Data) (dto.PermissionRepo, error) { + return &permissionRepo{db: d.db}, nil +} diff --git a/internal/features/system/data/provider.go b/internal/features/system/data/provider.go new file mode 100644 index 00000000..f9dae407 --- /dev/null +++ b/internal/features/system/data/provider.go @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package data implements the functions, types, and interfaces for the module. +package data + +import ( + "github.com/google/wire" + "origadmin/application/admin/internal/features/system/dto" +) + +// Repositories is a collection of all repositories. +type Repositories struct { + MenuRepo dto.MenuRepo + ResourceRepo dto.ResourceRepo + RoleRepo dto.RoleRepo + UserRepo dto.UserRepo + PermissionRepo dto.PermissionRepo +} + +// NewRepositories creates a new Repositories instance. +func NewRepositories( + menuRepo dto.MenuRepo, + resourceRepo dto.ResourceRepo, + roleRepo dto.RoleRepo, + userRepo dto.UserRepo, + permissionRepo dto.PermissionRepo, +) (*Repositories, error) { + return &Repositories{ + MenuRepo: menuRepo, + ResourceRepo: resourceRepo, + RoleRepo: roleRepo, + UserRepo: userRepo, + PermissionRepo: permissionRepo, + }, nil +} + +// ProviderSet is data providers. +var ProviderSet = wire.NewSet( + NewMenuRepo, + NewResourceRepo, + NewRoleRepo, + NewUserRepo, + NewPermissionRepo, + NewRepositories, // Provide the aggregated Repositories struct +) diff --git a/internal/features/system/data/resource.go b/internal/features/system/data/resource.go new file mode 100644 index 00000000..4d492a69 --- /dev/null +++ b/internal/features/system/data/resource.go @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package data + +import ( + "context" + "strconv" + + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/system/data/ent" + "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/db" +) + +type resourceRepo struct { + db *ent.Client + Delimiter string +} + +func (repo *resourceRepo) Get(ctx context.Context, id int64, options ...dto.ResourceQueryOption) (*types.Resource, error) { + result, err := repo.db.Resource.Get(ctx, int(id)) + if err != nil { + return nil, err + } + return dto.ConvertResourceToResourcePB(result), nil +} + +func (repo *resourceRepo) Create(ctx context.Context, r *types.Resource, options ...dto.ResourceQueryOption) (*types.Resource, error) { + if r.ParentId > 0 { + parent, err := repo.db.Resource.Get(ctx, int(r.ParentId)) + if err != nil { + return nil, err + } + r.TreePath = parent.TreePath + strconv.Itoa(parent.ID) + repo.Delimiter + } + + create := repo.db.Resource.Create(). + SetName(r.Name). + SetParentID(int(r.ParentId)). + SetTreePath(r.TreePath) + + if len(r.PermissionIds) > 0 { + create.AddPermissionIDs(r.PermissionIds...) + } + + // ... set other fields + + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResourceToResourcePB(saved), nil +} + +func (repo *resourceRepo) Delete(ctx context.Context, id int64) error { + return repo.db.Resource.DeleteOneID(int(id)).Exec(ctx) +} + +func (repo *resourceRepo) Update(ctx context.Context, r *types.Resource, options ...dto.ResourceQueryOption) (*types.Resource, error) { + update := repo.db.Resource.UpdateOneID(int(r.Id)) + + if len(r.PermissionIds) > 0 { + update.ClearPermissions().AddPermissionIDs(r.PermissionIds...) + } + + // ... set other fields + + saved, err := update.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResourceToResourcePB(saved), nil +} + +func (repo *resourceRepo) List(ctx context.Context, in *system.ListResourcesRequest, options ...dto.ResourceQueryOption) ([]*types.Resource, int32, error) { + query := repo.db.Resource.Query() + + if in.OnlyCount { + count, err := query.Count(ctx) + return nil, int32(count), err + } + + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, 0, err + } + + query = db.QueryPage(query, in) + + result, err := query.All(ctx) + return dto.ConvertResourcesToResourcesPB(result), int32(count), err +} + +// NewResourceRepo . +func NewResourceRepo(d *Data) (dto.ResourceRepo, error) { + return &resourceRepo{ + db: d.db, + Delimiter: "/", + }, nil +} diff --git a/internal/features/system/data/role.go b/internal/features/system/data/role.go new file mode 100644 index 00000000..672fc28a --- /dev/null +++ b/internal/features/system/data/role.go @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package data is the data access object +package data + +import ( + "context" + "errors" + + "github.com/origadmin/toolkits/crypto/rand" + + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/system/data/ent" + "origadmin/application/admin/internal/features/system/data/ent/role" + "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/db" +) + +type roleRepo struct { + gen rand.Generator + db *ent.Client +} + +func (repo *roleRepo) Get(ctx context.Context, id int64, options ...dto.RoleQueryOption) (*types.Role, error) { + result, err := repo.db.Role.Get(ctx, int(id)) + if err != nil { + return nil, err + } + return dto.ConvertRoleToRolePB(result), nil +} + +func (repo *roleRepo) Create(ctx context.Context, r *types.Role, options ...dto.RoleUpdateOption) (*types.Role, error) { + if r.Keyword == "" { + randString, err := repo.gen.RandString(12) + if err != nil { + randString = "" + } + r.Keyword = "system:role:" + randString + } + exist, err := repo.db.Role.Query().Where(role.KeywordEqualFold(r.Keyword)).Exist(ctx) + if err != nil || exist { + return nil, errors.New("role keyword already exists") + } + + create := repo.db.Role.Create(). + SetName(r.Name). + SetKeyword(r.Keyword) + + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertRoleToRolePB(saved), nil +} + +func (repo *roleRepo) Delete(ctx context.Context, id int64) error { + return repo.db.Role.DeleteOneID(int(id)).Exec(ctx) +} + +func (repo *roleRepo) Update(ctx context.Context, r *types.Role, options ...dto.RoleUpdateOption) (*types.Role, error) { + update := repo.db.Role.UpdateOneID(int(r.Id)) + if len(r.PermissionIds) > 0 { + update.ClearPermissions().AddPermissionIDs(r.PermissionIds...) + } + + // ... set other fields + + saved, err := update.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertRoleToRolePB(saved), nil +} + +func (repo *roleRepo) List(ctx context.Context, in *system.ListRolesRequest, options ...dto.RoleQueryOption) ([]*types.Role, int32, error) { + query := repo.db.Role.Query() + + if in.Name != nil { + query = query.Where(role.NameContains(*in.Name)) + } + if in.Status != nil { + query = query.Where(role.StatusEQ(*in.Status)) + } + + if in.OnlyCount { + count, err := query.Count(ctx) + return nil, int32(count), err + } + + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, 0, err + } + + query = db.QueryPage(query, in) + + result, err := query.All(ctx) + return dto.ConvertRolesToRolesPB(result), int32(count), err +} + +// NewRoleRepo . +func NewRoleRepo(d *Data) (dto.RoleRepo, error) { + return &roleRepo{ + gen: rand.NewGenerator(rand.KindDigit | rand.KindLowerCase), + db: d.db, + }, nil +} diff --git a/internal/features/system/data/user.go b/internal/features/system/data/user.go new file mode 100644 index 00000000..35b4c60d --- /dev/null +++ b/internal/features/system/data/user.go @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package data is the data access object +package data + +import ( + "context" + "errors" + + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/system/data/ent" + "origadmin/application/admin/internal/features/system/data/ent/user" + "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/db" +) + +type userRepo struct { + db *ent.Client +} + +func (repo *userRepo) Get(ctx context.Context, id int64, options ...dto.UserQueryOption) (*types.User, error) { + result, err := repo.db.User.Get(ctx, int(id)) + if err != nil { + return nil, err + } + return dto.ConvertUserToUserPB(result), nil +} + +func (repo *userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*types.User, error) { + result, err := repo.db.User.Query().Where(user.UsernameEQ(username)).Only(ctx) + if err != nil { + return nil, err + } + return dto.ConvertUserToUserPB(result), nil +} + +func (repo *userRepo) Create(ctx context.Context, u *types.User, options ...dto.UserMutationOption) (*types.User, error) { + exist, err := repo.db.User.Query().Where(user.UsernameEQ(u.Username)).Exist(ctx) + if err != nil || exist { + return nil, errors.New("user already exists") + } + + create := repo.db.User.Create(). + SetUsername(u.Username). + SetPassword(u.Password) + + // ... set other fields + + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertUserToUserPB(saved), nil +} + +func (repo *userRepo) Delete(ctx context.Context, id int64) error { + return repo.db.User.DeleteOneID(int(id)).Exec(ctx) +} + +func (repo *userRepo) Update(ctx context.Context, u *types.User, options ...dto.UserMutationOption) (*types.User, error) { + update := repo.db.User.UpdateOneID(int(u.Id)) + + if len(u.RoleIds) > 0 { + update.ClearRoles().AddRoleIDs(u.RoleIds...) + } + + // ... set other fields + + saved, err := update.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertUserToUserPB(saved), nil +} + +func (repo *userRepo) List(ctx context.Context, in *system.ListUsersRequest, options ...dto.UserQueryOption) ([]*types.User, int32, error) { + query := repo.db.User.Query() + + if in.Title != nil { + query = query.Where(user.Or(user.UsernameContainsFold(*in.Title), user.PhoneContainsFold(*in.Title), user.EmailContainsFold(*in.Title))) + } + if in.Status != nil { + query = query.Where(user.StatusEQ(int8(*in.Status))) + } + + if in.OnlyCount { + count, err := query.Count(ctx) + return nil, int32(count), err + } + + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, 0, err + } + + query = db.QueryPage(query, in) + + result, err := query.All(ctx) + return dto.ConvertUsersToUsersPB(result), int32(count), err +} + +func (repo *userRepo) AddRoleIDs(ctx context.Context, id int64, roleIDs []int64, options ...dto.UserMutationOption) error { + return repo.db.User.UpdateOneID(int(id)).AddRoleIDs(roleIDs...).Exec(ctx) +} + +func (repo *userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { + ids, err := repo.db.User.Query().Where(user.ID(int(id))).QueryRoles().IDs(ctx) + if err != nil { + return nil, err + } + var result []int64 + for _, i := range ids { + result = append(result, int64(i)) + } + return result, nil +} + +func (repo *userRepo) ListResourceByUserID(ctx context.Context, id int64, options ...dto.UserQueryOption) ([]*types.Resource, error) { + resources, err := repo.db.User.Query().Where(user.ID(int(id))).QueryRoles().QueryPermissions().QueryResources().All(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResourcesToResourcesPB(resources), nil +} + +func (repo *userRepo) UpdateUserStatus(ctx context.Context, id int64, status int32, options ...dto.UserQueryOption) error { + return repo.db.User.UpdateOneID(int(id)).SetStatus(int8(status)).Exec(ctx) +} + +func (repo *userRepo) Current(ctx context.Context, id int64) (*types.User, error) { + return repo.Get(ctx, id) +} + +// NewUserRepo . +func NewUserRepo(d *Data) (dto.UserRepo, error) { + return &userRepo{db: d.db}, nil +} diff --git a/internal/features/system/dto/custom.gen.go b/internal/features/system/dto/custom.gen.go index eb2a0284..3af06d81 100644 --- a/internal/features/system/dto/custom.gen.go +++ b/internal/features/system/dto/custom.gen.go @@ -1,17 +1,22 @@ -package dto +// This file is generated by abgen, but you can edit it. +// More info: https://github.com/origadmin/abgen -func ConvertMenuPBPropertiesToResourceProperties(from string) map[string]string { - panic("stub! not implemented") -} +package dto -func ConvertResourcePropertiesToMenuPBProperties(from map[string]string) string { - panic("stub! not implemented") -} +import ( + "origadmin/application/admin/internal/features/system/data/ent/user" +) -func ConvertUserGenderToUserPBGender(from Gender) string { +// ConvertGenderToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertGenderToString(from user.Gender) string { + // TODO: Implement this custom conversion panic("stub! not implemented") } -func ConvertUserPBGenderToUserGender(from string) Gender { +// ConvertStringToGender is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToGender(from string) user.Gender { + // TODO: Implement this custom conversion panic("stub! not implemented") } diff --git a/internal/features/system/dto/department.go b/internal/features/system/dto/department.go deleted file mode 100644 index 1e1fad52..00000000 --- a/internal/features/system/dto/department.go +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto implements the functions, types, and interfaces for the module. -package dto - -type DepartmentNode struct { - DepartmentPB - Children []*DepartmentNode `json:"children"` - PositionKeywords []string `json:"position_keywords"` -} diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index 1b80a282..ff7a56f1 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -1,21 +1,21 @@ +//go:build !abgen_source + +// Code generated by abgen. DO NOT EDIT. +// versions: v0.0.1 +// source: D:\workspace\project\golang\origadmin\framework\projects\backend\internal\features\system\dto + package dto import ( + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/system/data/ent" "time" "google.golang.org/protobuf/types/known/timestamppb" - - "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/data/entity/ent" ) +// Local type aliases for external types. type ( - Department = ent.Department - DepartmentEdges = ent.DepartmentEdges - DepartmentEdgesPB = types.DepartmentEdges - DepartmentPB = types.Department - Departments = []*ent.Department - DepartmentsPB = []*types.Department MenuPB = types.Menu MenusPB = []*types.Menu Permission = ent.Permission @@ -30,17 +30,9 @@ type ( PermissionResourcesPB = []*types.PermissionResource Permissions = []*ent.Permission PermissionsPB = []*types.Permission - Position = ent.Position - PositionEdges = ent.PositionEdges - PositionEdgesPB = types.PositionEdges PositionPB = types.Position - PositionPermission = ent.PositionPermission - PositionPermissionEdges = ent.PositionPermissionEdges - PositionPermissionEdgesPB = types.PositionPermissionEdges PositionPermissionPB = types.PositionPermission - PositionPermissions = []*ent.PositionPermission PositionPermissionsPB = []*types.PositionPermission - Positions = []*ent.Position PositionsPB = []*types.Position Resource = ent.Resource ResourceEdges = ent.ResourceEdges @@ -62,23 +54,10 @@ type ( RolePermissionsPB = []*types.RolePermission Roles = []*ent.Role RolesPB = []*types.Role - TimestampPB = timestamppb.Timestamp User = ent.User - UserDepartment = ent.UserDepartment - UserDepartmentEdges = ent.UserDepartmentEdges - UserDepartmentEdgesPB = types.UserDepartmentEdges - UserDepartmentPB = types.UserDepartment - UserDepartments = []*ent.UserDepartment - UserDepartmentsPB = []*types.UserDepartment UserEdges = ent.UserEdges UserEdgesPB = types.UserEdges UserPB = types.User - UserPosition = ent.UserPosition - UserPositionEdges = ent.UserPositionEdges - UserPositionEdgesPB = types.UserPositionEdges - UserPositionPB = types.UserPosition - UserPositions = []*ent.UserPosition - UserPositionsPB = []*types.UserPosition UserRole = ent.UserRole UserRoleEdges = ent.UserRoleEdges UserRoleEdgesPB = types.UserRoleEdges @@ -89,124 +68,7 @@ type ( UsersPB = []*types.User ) -func ConvertDepartmentEdgesPBToDepartmentEdges(from *DepartmentEdgesPB) *DepartmentEdges { - if from == nil { - return nil - } - - to := &DepartmentEdges{ - Users: ConvertUsersPBToUsers(from.Users), - Positions: ConvertPositionsPBToPositions(from.Positions), - Children: ConvertDepartmentsPBToDepartments(from.Children), - Parent: ConvertDepartmentPBToDepartment(from.Parent), - UserDepartments: ConvertUserDepartmentsPBToUserDepartments(from.UserDepartments), - } - return to -} - -func ConvertDepartmentEdgesToDepartmentEdgesPB(from *DepartmentEdges) *DepartmentEdgesPB { - if from == nil { - return nil - } - - to := &DepartmentEdgesPB{ - Users: ConvertUsersToUsersPB(from.Users), - Positions: ConvertPositionsToPositionsPB(from.Positions), - Parent: ConvertDepartmentToDepartmentPB(from.Parent), - Children: ConvertDepartmentsToDepartmentsPB(from.Children), - UserDepartments: ConvertUserDepartmentsToUserDepartmentsPB(from.UserDepartments), - } - return to -} - -func ConvertDepartmentPBToDepartment(from *DepartmentPB) *Department { - if from == nil { - return nil - } - - to := &Department{ - ID: from.Id, - CreateTime: ConvertTimestampToTime(from.CreateTime), - UpdateTime: ConvertTimestampToTime(from.UpdateTime), - Keyword: from.Keyword, - Name: from.Name, - TreePath: from.TreePath, - Sequence: int(from.Sequence), - Status: int8(from.Status), - Level: int(from.Level), - Description: from.Description, - ParentID: from.ParentId, - } - return to -} - -func ConvertDepartmentToDepartmentPB(from *Department) *DepartmentPB { - if from == nil { - return nil - } - - to := &DepartmentPB{ - Id: from.ID, - CreateTime: ConvertTimeToTimestamp(from.CreateTime), - UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), - Keyword: from.Keyword, - Name: from.Name, - TreePath: from.TreePath, - Sequence: int32(from.Sequence), - Status: int32(from.Status), - Level: int32(from.Level), - Description: from.Description, - ParentId: from.ParentID, - } - return to -} - -func ConvertDepartmentsPBToDepartments(froms DepartmentsPB) Departments { - if froms == nil { - return nil - } - tos := make(Departments, len(froms)) - for i, f := range froms { - tos[i] = ConvertDepartmentPBToDepartment(f) - } - return tos -} - -func ConvertDepartmentsToDepartmentsPB(froms Departments) DepartmentsPB { - if froms == nil { - return nil - } - tos := make(DepartmentsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertDepartmentToDepartmentPB(f) - } - return tos -} - -func ConvertMenuPBToResource(from *MenuPB) *Resource { - if from == nil { - return nil - } - - to := &Resource{ - ID: from.Id, - CreateTime: ConvertTimestampToTime(from.CreateTime), - UpdateTime: ConvertTimestampToTime(from.UpdateTime), - Keyword: from.Keyword, - Name: from.Name, - I18nKey: from.I18NKey, - Description: from.Description, - Sequence: int(from.Sequence), - Type: from.Type, - Icon: from.Icon, - Path: from.Path, - Properties: ConvertMenuPBPropertiesToResourceProperties(from.Properties), - Status: int8(from.Status), - ParentID: from.ParentId, - } - return to -} - +// ConvertPermissionEdgesPBToPermissionEdges converts PermissionEdgesPB to PermissionEdges. func ConvertPermissionEdgesPBToPermissionEdges(from *PermissionEdgesPB) *PermissionEdges { if from == nil { return nil @@ -215,14 +77,13 @@ func ConvertPermissionEdgesPBToPermissionEdges(from *PermissionEdgesPB) *Permiss to := &PermissionEdges{ Roles: ConvertRolesPBToRoles(from.Roles), Resources: ConvertResourcesPBToResources(from.Resources), - Positions: ConvertPositionsPBToPositions(from.Positions), RolePermissions: ConvertRolePermissionsPBToRolePermissions(from.RolePermissions), PermissionResources: ConvertPermissionResourcesPBToPermissionResources(from.PermissionResources), - PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), } return to } +// ConvertPermissionEdgesToPermissionEdgesPB converts PermissionEdges to PermissionEdgesPB. func ConvertPermissionEdgesToPermissionEdgesPB(from *PermissionEdges) *PermissionEdgesPB { if from == nil { return nil @@ -230,22 +91,21 @@ func ConvertPermissionEdgesToPermissionEdgesPB(from *PermissionEdges) *Permissio to := &PermissionEdgesPB{ Roles: ConvertRolesToRolesPB(from.Roles), - Positions: ConvertPositionsToPositionsPB(from.Positions), Resources: ConvertResourcesToResourcesPB(from.Resources), RolePermissions: ConvertRolePermissionsToRolePermissionsPB(from.RolePermissions), - PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), PermissionResources: ConvertPermissionResourcesToPermissionResourcesPB(from.PermissionResources), } return to } +// ConvertPermissionPBToPermission converts PermissionPB to Permission. func ConvertPermissionPBToPermission(from *PermissionPB) *Permission { if from == nil { return nil } to := &Permission{ - ID: from.Id, + ID: int(from.Id), CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), Name: from.Name, @@ -257,6 +117,7 @@ func ConvertPermissionPBToPermission(from *PermissionPB) *Permission { return to } +// ConvertPermissionResourceEdgesPBToPermissionResourceEdges converts PermissionResourceEdgesPB to PermissionResourceEdges. func ConvertPermissionResourceEdgesPBToPermissionResourceEdges(from *PermissionResourceEdgesPB) *PermissionResourceEdges { if from == nil { return nil @@ -269,6 +130,7 @@ func ConvertPermissionResourceEdgesPBToPermissionResourceEdges(from *PermissionR return to } +// ConvertPermissionResourceEdgesToPermissionResourceEdgesPB converts PermissionResourceEdges to PermissionResourceEdgesPB. func ConvertPermissionResourceEdgesToPermissionResourceEdgesPB(from *PermissionResourceEdges) *PermissionResourceEdgesPB { if from == nil { return nil @@ -281,6 +143,7 @@ func ConvertPermissionResourceEdgesToPermissionResourceEdgesPB(from *PermissionR return to } +// ConvertPermissionResourcePBToPermissionResource converts PermissionResourcePB to PermissionResource. func ConvertPermissionResourcePBToPermissionResource(from *PermissionResourcePB) *PermissionResource { if from == nil { return nil @@ -288,12 +151,13 @@ func ConvertPermissionResourcePBToPermissionResource(from *PermissionResourcePB) to := &PermissionResource{ ID: int(from.Id), - PermissionID: from.PermissionId, - ResourceID: from.ResourceId, + PermissionID: int(from.PermissionId), + ResourceID: int(from.ResourceId), } return to } +// ConvertPermissionResourceToPermissionResourcePB converts PermissionResource to PermissionResourcePB. func ConvertPermissionResourceToPermissionResourcePB(from *PermissionResource) *PermissionResourcePB { if from == nil { return nil @@ -301,12 +165,13 @@ func ConvertPermissionResourceToPermissionResourcePB(from *PermissionResource) * to := &PermissionResourcePB{ Id: int64(from.ID), - PermissionId: from.PermissionID, - ResourceId: from.ResourceID, + PermissionId: int64(from.PermissionID), + ResourceId: int64(from.ResourceID), } return to } +// ConvertPermissionResourcesPBToPermissionResources converts a slice of *PermissionResourcePB to a slice of *PermissionResource. func ConvertPermissionResourcesPBToPermissionResources(froms PermissionResourcesPB) PermissionResources { if froms == nil { return nil @@ -318,6 +183,7 @@ func ConvertPermissionResourcesPBToPermissionResources(froms PermissionResources return tos } +// ConvertPermissionResourcesToPermissionResourcesPB converts a slice of *PermissionResource to a slice of *PermissionResourcePB. func ConvertPermissionResourcesToPermissionResourcesPB(froms PermissionResources) PermissionResourcesPB { if froms == nil { return nil @@ -329,13 +195,14 @@ func ConvertPermissionResourcesToPermissionResourcesPB(froms PermissionResources return tos } +// ConvertPermissionToPermissionPB converts Permission to PermissionPB. func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { if from == nil { return nil } to := &PermissionPB{ - Id: from.ID, + Id: int64(from.ID), CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Name: from.Name, @@ -343,21 +210,12 @@ func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { Description: from.Description, DataScope: from.DataScope, DataRules: from.DataRules, + Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), } return to } -func ConvertPermissionsPBToPermissions(froms PermissionsPB) Permissions { - if froms == nil { - return nil - } - tos := make(Permissions, len(froms)) - for i, f := range froms { - tos[i] = ConvertPermissionPBToPermission(f) - } - return tos -} - +// ConvertPermissionsToPermissionsPB converts a slice of *Permission to a slice of *PermissionPB. func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { if froms == nil { return nil @@ -369,164 +227,7 @@ func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { return tos } -func ConvertPositionEdgesPBToPositionEdges(from *PositionEdgesPB) *PositionEdges { - if from == nil { - return nil - } - - to := &PositionEdges{ - Department: ConvertDepartmentPBToDepartment(from.Department), - Users: ConvertUsersPBToUsers(from.Users), - Permissions: ConvertPermissionsPBToPermissions(from.Permissions), - UserPositions: ConvertUserPositionsPBToUserPositions(from.UserPositions), - PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), - } - return to -} - -func ConvertPositionEdgesToPositionEdgesPB(from *PositionEdges) *PositionEdgesPB { - if from == nil { - return nil - } - - to := &PositionEdgesPB{ - Department: ConvertDepartmentToDepartmentPB(from.Department), - Users: ConvertUsersToUsersPB(from.Users), - Permissions: ConvertPermissionsToPermissionsPB(from.Permissions), - UserPositions: ConvertUserPositionsToUserPositionsPB(from.UserPositions), - PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), - } - return to -} - -func ConvertPositionPBToPosition(from *PositionPB) *Position { - if from == nil { - return nil - } - - to := &Position{ - ID: from.Id, - CreateTime: ConvertTimestampToTime(from.CreateTime), - UpdateTime: ConvertTimestampToTime(from.UpdateTime), - Name: from.Name, - Keyword: from.Keyword, - Description: from.Description, - DepartmentID: from.DepartmentId, - } - return to -} - -func ConvertPositionPermissionEdgesPBToPositionPermissionEdges(from *PositionPermissionEdgesPB) *PositionPermissionEdges { - if from == nil { - return nil - } - - to := &PositionPermissionEdges{ - Position: ConvertPositionPBToPosition(from.Position), - Permission: ConvertPermissionPBToPermission(from.Permission), - } - return to -} - -func ConvertPositionPermissionEdgesToPositionPermissionEdgesPB(from *PositionPermissionEdges) *PositionPermissionEdgesPB { - if from == nil { - return nil - } - - to := &PositionPermissionEdgesPB{ - Position: ConvertPositionToPositionPB(from.Position), - Permission: ConvertPermissionToPermissionPB(from.Permission), - } - return to -} - -func ConvertPositionPermissionPBToPositionPermission(from *PositionPermissionPB) *PositionPermission { - if from == nil { - return nil - } - - to := &PositionPermission{ - ID: int(from.Id), - PositionID: from.PositionId, - PermissionID: from.PermissionId, - } - return to -} - -func ConvertPositionPermissionToPositionPermissionPB(from *PositionPermission) *PositionPermissionPB { - if from == nil { - return nil - } - - to := &PositionPermissionPB{ - Id: int64(from.ID), - PositionId: from.PositionID, - PermissionId: from.PermissionID, - } - return to -} - -func ConvertPositionPermissionsPBToPositionPermissions(froms PositionPermissionsPB) PositionPermissions { - if froms == nil { - return nil - } - tos := make(PositionPermissions, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionPermissionPBToPositionPermission(f) - } - return tos -} - -func ConvertPositionPermissionsToPositionPermissionsPB(froms PositionPermissions) PositionPermissionsPB { - if froms == nil { - return nil - } - tos := make(PositionPermissionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionPermissionToPositionPermissionPB(f) - } - return tos -} - -func ConvertPositionToPositionPB(from *Position) *PositionPB { - if from == nil { - return nil - } - - to := &PositionPB{ - Id: from.ID, - CreateTime: ConvertTimeToTimestamp(from.CreateTime), - UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), - Name: from.Name, - Keyword: from.Keyword, - Description: from.Description, - DepartmentId: from.DepartmentID, - } - return to -} - -func ConvertPositionsPBToPositions(froms PositionsPB) Positions { - if froms == nil { - return nil - } - tos := make(Positions, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionPBToPosition(f) - } - return tos -} - -func ConvertPositionsToPositionsPB(froms Positions) PositionsPB { - if froms == nil { - return nil - } - tos := make(PositionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionToPositionPB(f) - } - return tos -} - +// ConvertResourceEdgesPBToResourceEdges converts ResourceEdgesPB to ResourceEdges. func ConvertResourceEdgesPBToResourceEdges(from *ResourceEdgesPB) *ResourceEdges { if from == nil { return nil @@ -536,6 +237,7 @@ func ConvertResourceEdgesPBToResourceEdges(from *ResourceEdgesPB) *ResourceEdges return to } +// ConvertResourceEdgesToResourceEdgesPB converts ResourceEdges to ResourceEdgesPB. func ConvertResourceEdgesToResourceEdgesPB(from *ResourceEdges) *ResourceEdgesPB { if from == nil { return nil @@ -545,23 +247,21 @@ func ConvertResourceEdgesToResourceEdgesPB(from *ResourceEdges) *ResourceEdgesPB return to } +// ConvertResourcePBToResource converts ResourcePB to Resource. func ConvertResourcePBToResource(from *ResourcePB) *Resource { if from == nil { return nil } to := &Resource{ - ID: from.Id, + ID: int(from.Id), CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), Name: from.Name, Keyword: from.Keyword, - I18nKey: from.I18NKey, Type: from.Type, Status: int8(from.Status), Path: from.Path, - Operation: from.Operation, - Method: from.Method, Component: from.Component, Icon: from.Icon, Sequence: int(from.Sequence), @@ -569,52 +269,26 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { TreePath: from.TreePath, Properties: from.Properties, Description: from.Description, - ParentID: from.ParentId, - } - return to -} - -func ConvertResourceToMenuPB(from *Resource) *MenuPB { - if from == nil { - return nil - } - - to := &MenuPB{ - Id: from.ID, - CreateTime: ConvertTimeToTimestamp(from.CreateTime), - UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), - Name: from.Name, - Keyword: from.Keyword, - I18NKey: from.I18nKey, - Type: from.Type, - Status: int32(from.Status), - Path: from.Path, - Icon: from.Icon, - Sequence: int32(from.Sequence), - Properties: ConvertResourcePropertiesToMenuPBProperties(from.Properties), - Description: from.Description, - ParentId: from.ParentID, + ParentID: int(from.ParentId), } return to } +// ConvertResourceToResourcePB converts Resource to ResourcePB. func ConvertResourceToResourcePB(from *Resource) *ResourcePB { if from == nil { return nil } to := &ResourcePB{ - Id: from.ID, + Id: int64(from.ID), CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Name: from.Name, Keyword: from.Keyword, - I18NKey: from.I18nKey, Type: from.Type, Status: int32(from.Status), Path: from.Path, - Operation: from.Operation, - Method: from.Method, Component: from.Component, Icon: from.Icon, Sequence: int32(from.Sequence), @@ -622,11 +296,15 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { TreePath: from.TreePath, Properties: from.Properties, Description: from.Description, - ParentId: from.ParentID, + ParentId: int64(from.ParentID), + Children: ConvertResourcesToResourcesPB(from.Edges.Children), + Parent: ConvertResourceToResourcePB(from.Edges.Parent), + Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), } return to } +// ConvertResourcesPBToResources converts a slice of *ResourcePB to a slice of *Resource. func ConvertResourcesPBToResources(froms ResourcesPB) Resources { if froms == nil { return nil @@ -638,6 +316,7 @@ func ConvertResourcesPBToResources(froms ResourcesPB) Resources { return tos } +// ConvertResourcesToResourcesPB converts a slice of *Resource to a slice of *ResourcePB. func ConvertResourcesToResourcesPB(froms Resources) ResourcesPB { if froms == nil { return nil @@ -649,6 +328,7 @@ func ConvertResourcesToResourcesPB(froms Resources) ResourcesPB { return tos } +// ConvertRoleEdgesPBToRoleEdges converts RoleEdgesPB to RoleEdges. func ConvertRoleEdgesPBToRoleEdges(from *RoleEdgesPB) *RoleEdges { if from == nil { return nil @@ -661,6 +341,7 @@ func ConvertRoleEdgesPBToRoleEdges(from *RoleEdgesPB) *RoleEdges { return to } +// ConvertRoleEdgesToRoleEdgesPB converts RoleEdges to RoleEdgesPB. func ConvertRoleEdgesToRoleEdgesPB(from *RoleEdges) *RoleEdgesPB { if from == nil { return nil @@ -673,13 +354,14 @@ func ConvertRoleEdgesToRoleEdgesPB(from *RoleEdges) *RoleEdgesPB { return to } +// ConvertRolePBToRole converts RolePB to Role. func ConvertRolePBToRole(from *RolePB) *Role { if from == nil { return nil } to := &Role{ - ID: from.Id, + ID: int(from.Id), CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), Keyword: from.Keyword, @@ -692,6 +374,7 @@ func ConvertRolePBToRole(from *RolePB) *Role { return to } +// ConvertRolePermissionEdgesPBToRolePermissionEdges converts RolePermissionEdgesPB to RolePermissionEdges. func ConvertRolePermissionEdgesPBToRolePermissionEdges(from *RolePermissionEdgesPB) *RolePermissionEdges { if from == nil { return nil @@ -704,6 +387,7 @@ func ConvertRolePermissionEdgesPBToRolePermissionEdges(from *RolePermissionEdges return to } +// ConvertRolePermissionEdgesToRolePermissionEdgesPB converts RolePermissionEdges to RolePermissionEdgesPB. func ConvertRolePermissionEdgesToRolePermissionEdgesPB(from *RolePermissionEdges) *RolePermissionEdgesPB { if from == nil { return nil @@ -716,6 +400,7 @@ func ConvertRolePermissionEdgesToRolePermissionEdgesPB(from *RolePermissionEdges return to } +// ConvertRolePermissionPBToRolePermission converts RolePermissionPB to RolePermission. func ConvertRolePermissionPBToRolePermission(from *RolePermissionPB) *RolePermission { if from == nil { return nil @@ -723,12 +408,13 @@ func ConvertRolePermissionPBToRolePermission(from *RolePermissionPB) *RolePermis to := &RolePermission{ ID: int(from.Id), - RoleID: from.RoleId, - PermissionID: from.PermissionId, + RoleID: int(from.RoleId), + PermissionID: int(from.PermissionId), } return to } +// ConvertRolePermissionToRolePermissionPB converts RolePermission to RolePermissionPB. func ConvertRolePermissionToRolePermissionPB(from *RolePermission) *RolePermissionPB { if from == nil { return nil @@ -736,12 +422,13 @@ func ConvertRolePermissionToRolePermissionPB(from *RolePermission) *RolePermissi to := &RolePermissionPB{ Id: int64(from.ID), - RoleId: from.RoleID, - PermissionId: from.PermissionID, + RoleId: int64(from.RoleID), + PermissionId: int64(from.PermissionID), } return to } +// ConvertRolePermissionsPBToRolePermissions converts a slice of *RolePermissionPB to a slice of *RolePermission. func ConvertRolePermissionsPBToRolePermissions(froms RolePermissionsPB) RolePermissions { if froms == nil { return nil @@ -753,6 +440,7 @@ func ConvertRolePermissionsPBToRolePermissions(froms RolePermissionsPB) RolePerm return tos } +// ConvertRolePermissionsToRolePermissionsPB converts a slice of *RolePermission to a slice of *RolePermissionPB. func ConvertRolePermissionsToRolePermissionsPB(froms RolePermissions) RolePermissionsPB { if froms == nil { return nil @@ -764,13 +452,14 @@ func ConvertRolePermissionsToRolePermissionsPB(froms RolePermissions) RolePermis return tos } +// ConvertRoleToRolePB converts Role to RolePB. func ConvertRoleToRolePB(from *Role) *RolePB { if from == nil { return nil } to := &RolePB{ - Id: from.ID, + Id: int64(from.ID), CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Keyword: from.Keyword, @@ -779,10 +468,13 @@ func ConvertRoleToRolePB(from *Role) *RolePB { Type: int32(from.Type), Sequence: int32(from.Sequence), Status: int32(from.Status), + Users: ConvertUsersToUsersPB(from.Edges.Users), + Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), } return to } +// ConvertRolesPBToRoles converts a slice of *RolePB to a slice of *Role. func ConvertRolesPBToRoles(froms RolesPB) Roles { if froms == nil { return nil @@ -794,6 +486,7 @@ func ConvertRolesPBToRoles(froms RolesPB) Roles { return tos } +// ConvertRolesToRolesPB converts a slice of *Role to a slice of *RolePB. func ConvertRolesToRolesPB(froms Roles) RolesPB { if froms == nil { return nil @@ -805,80 +498,7 @@ func ConvertRolesToRolesPB(froms Roles) RolesPB { return tos } -func ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from *UserDepartmentEdgesPB) *UserDepartmentEdges { - if from == nil { - return nil - } - - to := &UserDepartmentEdges{ - User: ConvertUserPBToUser(from.User), - Department: ConvertDepartmentPBToDepartment(from.Department), - } - return to -} - -func ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(from *UserDepartmentEdges) *UserDepartmentEdgesPB { - if from == nil { - return nil - } - - to := &UserDepartmentEdgesPB{ - User: ConvertUserToUserPB(from.User), - Department: ConvertDepartmentToDepartmentPB(from.Department), - } - return to -} - -func ConvertUserDepartmentPBToUserDepartment(from *UserDepartmentPB) *UserDepartment { - if from == nil { - return nil - } - - to := &UserDepartment{ - ID: int(from.Id), - UserID: from.UserId, - DepartmentID: from.DepartmentId, - Edges: *ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from.Edges), - } - return to -} - -func ConvertUserDepartmentToUserDepartmentPB(from *UserDepartment) *UserDepartmentPB { - if from == nil { - return nil - } - - to := &UserDepartmentPB{ - Id: int64(from.ID), - UserId: from.UserID, - DepartmentId: from.DepartmentID, - Edges: ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(&from.Edges), - } - return to -} - -func ConvertUserDepartmentsPBToUserDepartments(froms UserDepartmentsPB) UserDepartments { - if froms == nil { - return nil - } - tos := make(UserDepartments, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserDepartmentPBToUserDepartment(f) - } - return tos -} - -func ConvertUserDepartmentsToUserDepartmentsPB(froms UserDepartments) UserDepartmentsPB { - if froms == nil { - return nil - } - tos := make(UserDepartmentsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserDepartmentToUserDepartmentPB(f) - } - return tos -} - +// ConvertUserEdgesPBToUserEdges converts UserEdgesPB to UserEdges. func ConvertUserEdgesPBToUserEdges(from *UserEdgesPB) *UserEdges { if from == nil { return nil @@ -891,6 +511,7 @@ func ConvertUserEdgesPBToUserEdges(from *UserEdgesPB) *UserEdges { return to } +// ConvertUserEdgesToUserEdgesPB converts UserEdges to UserEdgesPB. func ConvertUserEdgesToUserEdgesPB(from *UserEdges) *UserEdgesPB { if from == nil { return nil @@ -903,15 +524,14 @@ func ConvertUserEdgesToUserEdgesPB(from *UserEdges) *UserEdgesPB { return to } +// ConvertUserPBToUser converts UserPB to User. func ConvertUserPBToUser(from *UserPB) *User { if from == nil { return nil } to := &User{ - ID: from.Id, - CreateAuthor: from.CreateAuthor, - UpdateAuthor: from.UpdateAuthor, + ID: int(from.Id), CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), UUID: from.Uuid, @@ -920,94 +540,19 @@ func ConvertUserPBToUser(from *UserPB) *User { Nickname: from.Nickname, Avatar: from.Avatar, Name: from.Name, - Gender: ConvertUserPBGenderToUserGender(from.Gender), - Salt: from.Salt, + Gender: ConvertStringToGender(from.Gender), + Password: from.Password, Phone: from.Phone, Email: from.Email, Remark: from.Remark, - Token: from.Token, Status: int8(from.Status), LastLoginIP: from.LastLoginIp, LastLoginTime: ConvertTimestampToTime(from.LastLoginTime), - SanctionDate: ConvertTimestampToTime(from.SanctionDate), - ManagerID: from.ManagerId, - Manager: from.Manager, - } - return to -} - -func ConvertUserPositionEdgesPBToUserPositionEdges(from *UserPositionEdgesPB) *UserPositionEdges { - if from == nil { - return nil - } - - to := &UserPositionEdges{ - User: ConvertUserPBToUser(from.User), - Position: ConvertPositionPBToPosition(from.Position), - } - return to -} - -func ConvertUserPositionEdgesToUserPositionEdgesPB(from *UserPositionEdges) *UserPositionEdgesPB { - if from == nil { - return nil - } - - to := &UserPositionEdgesPB{ - User: ConvertUserToUserPB(from.User), - Position: ConvertPositionToPositionPB(from.Position), - } - return to -} - -func ConvertUserPositionPBToUserPosition(from *UserPositionPB) *UserPosition { - if from == nil { - return nil - } - - to := &UserPosition{ - ID: int(from.Id), - UserID: from.UserId, - PositionID: from.PositionId, } return to } -func ConvertUserPositionToUserPositionPB(from *UserPosition) *UserPositionPB { - if from == nil { - return nil - } - - to := &UserPositionPB{ - Id: int64(from.ID), - UserId: from.UserID, - PositionId: from.PositionID, - } - return to -} - -func ConvertUserPositionsPBToUserPositions(froms UserPositionsPB) UserPositions { - if froms == nil { - return nil - } - tos := make(UserPositions, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserPositionPBToUserPosition(f) - } - return tos -} - -func ConvertUserPositionsToUserPositionsPB(froms UserPositions) UserPositionsPB { - if froms == nil { - return nil - } - tos := make(UserPositionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserPositionToUserPositionPB(f) - } - return tos -} - +// ConvertUserRoleEdgesPBToUserRoleEdges converts UserRoleEdgesPB to UserRoleEdges. func ConvertUserRoleEdgesPBToUserRoleEdges(from *UserRoleEdgesPB) *UserRoleEdges { if from == nil { return nil @@ -1020,6 +565,7 @@ func ConvertUserRoleEdgesPBToUserRoleEdges(from *UserRoleEdgesPB) *UserRoleEdges return to } +// ConvertUserRoleEdgesToUserRoleEdgesPB converts UserRoleEdges to UserRoleEdgesPB. func ConvertUserRoleEdgesToUserRoleEdgesPB(from *UserRoleEdges) *UserRoleEdgesPB { if from == nil { return nil @@ -1032,6 +578,7 @@ func ConvertUserRoleEdgesToUserRoleEdgesPB(from *UserRoleEdges) *UserRoleEdgesPB return to } +// ConvertUserRolePBToUserRole converts UserRolePB to UserRole. func ConvertUserRolePBToUserRole(from *UserRolePB) *UserRole { if from == nil { return nil @@ -1039,12 +586,13 @@ func ConvertUserRolePBToUserRole(from *UserRolePB) *UserRole { to := &UserRole{ ID: int(from.Id), - UserID: from.UserId, - RoleID: from.RoleId, + UserID: int(from.UserId), + RoleID: int(from.RoleId), } return to } +// ConvertUserRoleToUserRolePB converts UserRole to UserRolePB. func ConvertUserRoleToUserRolePB(from *UserRole) *UserRolePB { if from == nil { return nil @@ -1052,12 +600,15 @@ func ConvertUserRoleToUserRolePB(from *UserRole) *UserRolePB { to := &UserRolePB{ Id: int64(from.ID), - UserId: from.UserID, - RoleId: from.RoleID, + UserId: int64(from.UserID), + RoleId: int64(from.RoleID), + User: ConvertUserToUserPB(from.Edges.User), + Role: ConvertRoleToRolePB(from.Edges.Role), } return to } +// ConvertUserRolesPBToUserRoles converts a slice of *UserRolePB to a slice of *UserRole. func ConvertUserRolesPBToUserRoles(froms UserRolesPB) UserRoles { if froms == nil { return nil @@ -1069,6 +620,7 @@ func ConvertUserRolesPBToUserRoles(froms UserRolesPB) UserRoles { return tos } +// ConvertUserRolesToUserRolesPB converts a slice of *UserRole to a slice of *UserRolePB. func ConvertUserRolesToUserRolesPB(froms UserRoles) UserRolesPB { if froms == nil { return nil @@ -1080,15 +632,14 @@ func ConvertUserRolesToUserRolesPB(froms UserRoles) UserRolesPB { return tos } +// ConvertUserToUserPB converts User to UserPB. func ConvertUserToUserPB(from *User) *UserPB { if from == nil { return nil } to := &UserPB{ - Id: from.ID, - CreateAuthor: from.CreateAuthor, - UpdateAuthor: from.UpdateAuthor, + Id: int64(from.ID), CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Uuid: from.UUID, @@ -1097,22 +648,20 @@ func ConvertUserToUserPB(from *User) *UserPB { Nickname: from.Nickname, Avatar: from.Avatar, Name: from.Name, - Gender: ConvertUserGenderToUserPBGender(from.Gender), - Salt: from.Salt, + Gender: ConvertGenderToString(from.Gender), + Password: from.Password, Phone: from.Phone, Email: from.Email, Remark: from.Remark, - Token: from.Token, Status: int32(from.Status), LastLoginIp: from.LastLoginIP, LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), - SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), - ManagerId: from.ManagerID, - Manager: from.Manager, + Roles: ConvertRolesToRolesPB(from.Edges.Roles), } return to } +// ConvertUsersPBToUsers converts a slice of *UserPB to a slice of *User. func ConvertUsersPBToUsers(froms UsersPB) Users { if froms == nil { return nil @@ -1124,6 +673,7 @@ func ConvertUsersPBToUsers(froms UsersPB) Users { return tos } +// ConvertUsersToUsersPB converts a slice of *User to a slice of *UserPB. func ConvertUsersToUsersPB(froms Users) UsersPB { if froms == nil { return nil @@ -1135,6 +685,8 @@ func ConvertUsersToUsersPB(froms Users) UsersPB { return tos } +// --- Helper Functions --- + func ConvertTimeToTimestamp(t time.Time) *timestamppb.Timestamp { if t.IsZero() { return nil diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index 883e089e..5b62b93c 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -1,17 +1,10 @@ package dto -import ( - "origadmin/application/admin/internal/data/entity/ent/user" -) +//go:generate go run github.com/origadmin/abgen/cmd/abgen -debug go run ./cmd/abgen -debug . -//go:abgen:package:path=origadmin/application/admin/internal/data/entity/ent,alias=ent +//go:abgen:package:path=origadmin/application/admin/internal/features/system/data/ent,alias=ent //go:abgen:package:path=origadmin/application/admin/api/v1/services/types,alias=types -//go:abgen:pair:packages="origadmin/application/admin/internal/data/entity/ent,origadmin/application/admin/api/v1/services/types" +//go:abgen:pair:packages="ent,types" +//go:abgen:convert:direction="both" //go:abgen:convert:source:suffix="" //go:abgen:convert:target:suffix="PB" -//go:abgen:convert:direction="both" -//go:abgen:convert="source=ent.Resource,target=types.Menu" - -type ( - Gender = user.Gender -) diff --git a/internal/features/system/dto/menu.go b/internal/features/system/dto/menu.go deleted file mode 100644 index 74ca23bb..00000000 --- a/internal/features/system/dto/menu.go +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the system module. -package dto - -import ( - "context" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/system" -) - -type ( - ListMenusRequest = pb.ListMenusRequest - ListMenusResponse = pb.ListMenusResponse -) - -// MenuRepo is a Menu repository interface. -type MenuRepo interface { - Get(context.Context, int64, ...MenuQueryOption) (*MenuPB, error) - Create(context.Context, *MenuPB, ...MenuQueryOption) (*MenuPB, error) - Delete(context.Context, int64) error - Update(context.Context, *MenuPB, ...MenuQueryOption) (*MenuPB, error) - List(context.Context, *ListMenusRequest, ...MenuQueryOption) ([]*MenuPB, int32, error) -} - -type MenuQueryOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - InIDs []int64 `form:"-" json:"-"` - UserID int64 `form:"-" json:"-"` // UserPB ID - RoleID int64 `form:"-" json:"-"` // RolePB ID - ParentID int64 `form:"-" json:"-"` // Parent ID - ParentPathPrefix string `form:"-" json:"-"` - IncludeResources bool `form:"-" json:"-"` // Include resources - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string -} - -func (o MenuQueryOption) FromListRequest(in *ListMenusRequest, limiter pagination.PageLimiter) error { - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func (o MenuQueryOption) FromGetRequest(in *pb.GetMenuRequest, limiter pagination.PageLimiter) error { - return nil -} - -func (o MenuQueryOption) FromCreateRequest(in *pb.CreateMenuRequest, limiter pagination.PageLimiter) error { - return nil -} - -// -//func ToListMenusResponse(result []*MenuPB, in *ListMenusRequest, total int32, args ...any) (*ListMenusResponse, error) { -// response := &ListMenusResponse{ -// TotalSize: total, -// Current: in.Current, -// PageSize: in.PageSize, -// Menus: result, -// Extra: resp.Any(args...), -// } -// return response, nil -//} -// -//func ConvertMenus(menus []*Menu) []*MenuPB { -// var result []*MenuPB -// for _, menu := range menus { -// result = append(result, ConvertMenu2PB(menu)) -// } -// return result -//} diff --git a/internal/features/system/dto/permission.go b/internal/features/system/dto/permission.go index c27ffb89..0edfbfce 100644 --- a/internal/features/system/dto/permission.go +++ b/internal/features/system/dto/permission.go @@ -7,57 +7,22 @@ package dto import ( "context" - - "origadmin/application/admin/internal/helpers/pagination" // Corrected import path - - pb "origadmin/application/admin/api/v1/services/system" -) - -type ( - ListPermissionsRequest = pb.ListPermissionsRequest - ListPermissionsResponse = pb.ListPermissionsResponse + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" ) -type PermissionNode struct { - PermissionPB - ResourceKeywords []string `json:"resource_keywords"` -} - // PermissionRepo is a Permission repository interface. type PermissionRepo interface { - Get(context.Context, int64, ...PermissionQueryOption) (*PermissionPB, error) - Create(context.Context, *PermissionPB, ...PermissionQueryOption) (*PermissionPB, error) + Get(context.Context, int64, ...PermissionQueryOption) (*types.Permission, error) + Create(context.Context, *types.Permission, ...PermissionQueryOption) (*types.Permission, error) Delete(context.Context, int64) error - Update(context.Context, *PermissionPB, ...PermissionQueryOption) (*PermissionPB, error) - List(context.Context, *ListPermissionsRequest, ...PermissionQueryOption) ([]*PermissionPB, int32, error) + Update(context.Context, *types.Permission, ...PermissionQueryOption) (*types.Permission, error) + List(context.Context, *system.ListPermissionsRequest, ...PermissionQueryOption) ([]*types.Permission, int32, error) } type PermissionQueryOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - InIDs []string `form:"-" json:"-"` - UserID string `form:"-" json:"-"` // UserPB ID - RoleID string `form:"-" json:"-"` // RolePB ID - ParentID string `form:"-" json:"-"` // Parent ID - ParentPathPrefix string `form:"-" json:"-"` - SelectFields []string - OmitFields []string OrderFields []string Fields []string IncludeResources bool IncludeRoles bool } - -func (o PermissionQueryOption) FromListRequest(in *ListPermissionsRequest, limiter pagination.PageLimiter) error { // Updated usage - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func (o PermissionQueryOption) FromGetRequest(in *pb.GetPermissionRequest, limiter pagination.PageLimiter) error { // Updated usage - return nil -} - -func (o PermissionQueryOption) FromCreateRequest(in *pb.CreatePermissionRequest, limiter pagination.PageLimiter) error { // Updated usage - return nil -} diff --git a/internal/features/system/dto/position.go b/internal/features/system/dto/position.go deleted file mode 100644 index 6d294141..00000000 --- a/internal/features/system/dto/position.go +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto implements the functions, types, and interfaces for the module. -package dto - -// PositionNode position.table.comment -type PositionNode struct { - PositionPB - DepartmentKeyword string `json:"department_keyword,omitempty"` -} diff --git a/internal/features/system/dto/resource.go b/internal/features/system/dto/resource.go index 6e25caeb..5f5a604b 100644 --- a/internal/features/system/dto/resource.go +++ b/internal/features/system/dto/resource.go @@ -7,68 +7,20 @@ package dto import ( "context" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/helpers/pagination" - "origadmin/application/admin/internal/helpers/resp" -) - -type ( - ListResourcesRequest = pb.ListResourcesRequest - ListResourcesResponse = pb.ListResourcesResponse + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" ) -type ResourceNode struct { - ResourcePB - Children []*ResourceNode `json:"children"` -} - // ResourceRepo is a Resource repository interface. type ResourceRepo interface { - Get(context.Context, int64, ...ResourceQueryOption) (*ResourcePB, error) - Create(context.Context, *ResourcePB, ...ResourceQueryOption) (*ResourcePB, error) + Get(context.Context, int64, ...ResourceQueryOption) (*types.Resource, error) + Create(context.Context, *types.Resource, ...ResourceQueryOption) (*types.Resource, error) Delete(context.Context, int64) error - Update(context.Context, *ResourcePB, ...ResourceQueryOption) (*ResourcePB, error) - List(context.Context, *ListResourcesRequest, ...ResourceQueryOption) ([]*ResourcePB, int32, error) + Update(context.Context, *types.Resource, ...ResourceQueryOption) (*types.Resource, error) + List(context.Context, *system.ListResourcesRequest, ...ResourceQueryOption) ([]*types.Resource, int32, error) } type ResourceQueryOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - InIDs []int64 `form:"-" json:"-"` - UserID string `form:"-" json:"-"` // UserPB ID - RoleID string `form:"-" json:"-"` // RolePB ID - ParentID int64 `form:"-" json:"-"` // Parent ID - ParentPathPrefix string `form:"-" json:"-"` - IncludeResources bool `form:"-" json:"-"` // Include resources - IncludePermissions bool `form:"-" json:"-"` - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string -} - -func (o ResourceQueryOption) FromListRequest(in *ListResourcesRequest, limiter pagination.PageLimiter) error { // Updated usage - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func (o ResourceQueryOption) FromGetRequest(in *pb.GetResourceRequest, limiter pagination.PageLimiter) error { // Updated usage - return nil -} - -func (o ResourceQueryOption) FromCreateRequest(in *pb.CreateResourceRequest, limiter pagination.PageLimiter) error { // Updated usage - return nil -} - -func ToListResourcesResponse(result []*ResourcePB, in *ListResourcesRequest, total int32, args ...any) (*ListResourcesResponse, error) { - response := &ListResourcesResponse{ - TotalSize: total, - Current: in.Current, - PageSize: in.PageSize, - Resources: result, - Extra: resp.Any(args...), - } - return response, nil + OrderFields []string + Fields []string } diff --git a/internal/features/system/dto/role.go b/internal/features/system/dto/role.go index ea532c0a..f4e9edad 100644 --- a/internal/features/system/dto/role.go +++ b/internal/features/system/dto/role.go @@ -7,90 +7,24 @@ package dto import ( "context" - "time" - - "google.golang.org/protobuf/proto" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/helpers/pagination" - "origadmin/application/admin/internal/helpers/resp" -) - -type ( - ListRolesRequest = pb.ListRolesRequest - ListRolesResponse = pb.ListRolesResponse + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" ) -// RoleRepo is a RolePB repository interface. +// RoleRepo is a Role repository interface. type RoleRepo interface { - Get(context.Context, int64, ...RoleQueryOption) (*RolePB, error) - List(context.Context, *ListRolesRequest, ...RoleQueryOption) ([]*RolePB, int32, error) - Create(context.Context, *RolePB, ...RoleUpdateOption) (*RolePB, error) - Update(context.Context, *RolePB, ...RoleUpdateOption) (*RolePB, error) + Get(context.Context, int64, ...RoleQueryOption) (*types.Role, error) + List(context.Context, *system.ListRolesRequest, ...RoleQueryOption) ([]*types.Role, int32, error) + Create(context.Context, *types.Role, ...RoleUpdateOption) (*types.Role, error) + Update(context.Context, *types.Role, ...RoleUpdateOption) (*types.Role, error) Delete(context.Context, int64) error } type RoleQueryOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - InIDs []int64 `form:"-" json:"-"` - UpdateTimeGT *time.Time - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string IncludePermissions bool -} - -func (o RoleQueryOption) FromListRequest(in *ListRolesRequest, limiter pagination.PageLimiter) error { // Updated usage - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func (o RoleQueryOption) FromGetRequest(in *pb.GetRoleRequest, limiter pagination.PageLimiter) error { // Updated usage - return nil -} - -func (o RoleQueryOption) FromCreateRequest(in *pb.CreateRoleRequest, limiter pagination.PageLimiter) error { // Updated usage - return nil -} - -// RoleUpdateOption is used for creating and updating roles. -type RoleUpdateOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - UpdateTimeGT *time.Time - SelectFields []string - OmitFields []string OrderFields []string - Fields []string - IncludePermissions bool -} - -func (o RoleUpdateOption) FromCreateRequest(in *pb.CreateRoleRequest) error { - return nil } -func (o RoleUpdateOption) FromUpdateRequest(in *pb.UpdateRoleRequest) error { - return nil -} - -func ToListRolesResponse(result []*RolePB, in *ListRolesRequest, total int32, args ...any) (*ListRolesResponse, error) { - response := &ListRolesResponse{ - TotalSize: total, - Current: in.Current, - PageSize: in.PageSize, - Roles: result, - Extra: resp.Any(args...), - } - return response, nil -} - -type RoleQueryResult struct { - Current int `json:"current"` - PageSize int `json:"page_size"` - Data []*RolePB `json:"data"` - Total int64 `json:"total"` - Args map[string]proto.Message `json:"args"` +type RoleUpdateOption struct { + Fields []string } diff --git a/internal/features/system/dto/user.go b/internal/features/system/dto/user.go index 509b9372..327edf5a 100644 --- a/internal/features/system/dto/user.go +++ b/internal/features/system/dto/user.go @@ -7,117 +7,31 @@ package dto import ( "context" - - "github.com/goexts/generic/must" - "github.com/google/uuid" - - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/rand" - "github.com/origadmin/toolkits/identifier" - "origadmin/application/admin/internal/helpers/pagination" // Corrected import path - - pb "origadmin/application/admin/api/v1/services/system" -) - -type ( - ListUsersRequest = pb.ListUsersRequest - ListUsersResponse = pb.ListUsersResponse + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" ) -type UserNode struct { - UserPB - IsSystem bool `json:"is_system"` - RoleKeywords []string `json:"role_keywords"` - EncryptedPassword string `json:"encrypted_password"` -} - -// UserRepo is a UserPB repository interface. +// UserRepo is a User repository interface. type UserRepo interface { - Get(context.Context, int64, ...UserQueryOption) (*UserPB, error) - Create(context.Context, *UserPB, ...UserMutationOption) (*UserPB, error) + Get(context.Context, int64, ...UserQueryOption) (*types.User, error) + Create(context.Context, *types.User, ...UserMutationOption) (*types.User, error) Delete(context.Context, int64) error - Update(context.Context, *UserPB, ...UserMutationOption) (*UserPB, error) - List(context.Context, *ListUsersRequest, ...UserQueryOption) ([]*UserPB, int32, error) + Update(context.Context, *types.User, ...UserMutationOption) (*types.User, error) + List(context.Context, *system.ListUsersRequest, ...UserQueryOption) ([]*types.User, int32, error) AddRoleIDs(context.Context, int64, []int64, ...UserMutationOption) error - GetByUsername(context.Context, string, ...string) (*UserNode, error) + GetByUsername(context.Context, string, ...string) (*types.User, error) GetRoleIDs(context.Context, int64) ([]int64, error) - ListResourceByUserID(context.Context, int64, ...UserQueryOption) ([]*ResourcePB, error) - Current(context.Context, int64) (*UserPB, error) - UpdateUserStatus(ctx context.Context, id int64, status int8, options ...UserQueryOption) error + ListResourceByUserID(context.Context, int64, ...UserQueryOption) ([]*types.Resource, error) + Current(context.Context, int64) (*types.User, error) + UpdateUserStatus(ctx context.Context, id int64, status int32, options ...UserQueryOption) error } type UserMutationOption struct { - RandomPasswd bool - NoPasswd bool - Fields []string + Fields []string } type UserQueryOption struct { IncludeRoles bool - IsSystem bool - NoPasswd bool - RandomPasswd bool - Status int8 `form:"status" json:"status,omitempty"` - SelectFields []string - OmitFields []string OrderFields []string Fields []string } - -func (o *UserQueryOption) FromListRequest(in *ListUsersRequest, limiter pagination.PageLimiter) error { // Updated usage - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func (o *UserQueryOption) FromGetRequest(in *pb.GetUserRequest, limiter pagination.PageLimiter) error { // Updated usage - return nil -} - -func (o *UserMutationOption) FromCreateRequest(in *pb.CreateUserRequest, limiter pagination.PageLimiter) error { // Updated usage - o.RandomPasswd = in.RandomPassword - return nil -} - -// MakeCreateUser functions are used to create new users -func MakeCreateUser(user *UserPB, username, password string, option UserMutationOption) (*UserPB, string, error) { - log.Debugf("Creating user with options: %+v", option) - if !option.NoPasswd { - log.Debugf("NoPasswd is false, checking for RandomPasswd") - if option.RandomPasswd && (user.Email != "" || user.Phone != "") { - log.Debugf("RandomPasswd is true and user has email or phone, generating random password") - pwd, err := rand.RandomString(8) - if err != nil { - log.Errorf("Error generating random password: %v", err) - return nil, "", err - } - log.Debugf("Generated random password: %s", pwd) - password = pwd - } else { - log.Debugf("RandomPasswd is false or user has no email or phone") - } - } else { - log.Debugf("NoPasswd is true, setting password to empty string") - password = "" - } - var err error - if password != "" { - log.Debugf("Password is not empty, generating salt") - //user.Salt = rand.GenerateSalt() - //log.Debugf("Generated salt: %s", user.Salt) - user.Password, err = hash.Generate(password) - if err != nil { - log.Errorf("Error generating password hash: %v", err) - return nil, "", err - } - log.Debugf("Generated password hash: %s", user.Password) - } - registerID := identifier.GenerateNumber() - user.Id = registerID - user.Uuid = uuid.Must(uuid.NewRandom()).String() - user.Username = username - user.Name = "user_" + must.Do(rand.RandomString(8)) - user.Status = 1 - return user, password, nil -} diff --git a/internal/features/system/service/dto.go b/internal/features/system/service/dto.go new file mode 100644 index 00000000..b59d3911 --- /dev/null +++ b/internal/features/system/service/dto.go @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + system "origadmin/application/admin/api/v1/system" + "origadmin/application/admin/internal/features/system/biz" +) + +func toRoleDO(dto *system.Role) *biz.Role { + if dto == nil { + return nil + } + return &biz.Role{ + ID: int(dto.Id), + Name: dto.Name, + Keyword: dto.Keyword, + } +} + +func toRoleDTO(do *biz.Role) *system.Role { + if do == nil { + return nil + } + return &system.Role{ + Id: int32(do.ID), + Name: do.Name, + Keyword: do.Keyword, + } +} + +func toRoleDTOs(dos []*biz.Role) []*system.Role { + dtos := make([]*system.Role, len(dos)) + for i, do := range dos { + dtos[i] = toRoleDTO(do) + } + return dtos +} + +func toUserDO(dto *system.User) *biz.User { + if dto == nil { + return nil + } + return &biz.User{ + ID: int(dto.Id), + Username: dto.Username, + } +} + +func toUserDTO(do *biz.User) *system.User { + if do == nil { + return nil + } + return &system.User{ + Id: int32(do.ID), + Username: do.Username, + } +} + +func toUserDTOs(dos []*biz.User) []*system.User { + dtos := make([]*system.User, len(dos)) + for i, do := range dos { + dtos[i] = toUserDTO(do) + } + return dtos +} + +func toResourceDO(dto *system.Resource) *biz.Resource { + if dto == nil { + return nil + } + return &biz.Resource{ + ID: int(dto.Id), + Name: dto.Name, + ParentID: int(dto.ParentId), + } +} + +func toResourceDTO(do *biz.Resource) *system.Resource { + if do == nil { + return nil + } + return &system.Resource{ + Id: int32(do.ID), + Name: do.Name, + ParentId: int32(do.ParentID), + } +} + +func toResourceDTOs(dos []*biz.Resource) []*system.Resource { + dtos := make([]*system.Resource, len(dos)) + for i, do := range dos { + dtos[i] = toResourceDTO(do) + } + return dtos +} + +func toPermissionDO(dto *system.Permission) *biz.Permission { + if dto == nil { + return nil + } + return &biz.Permission{ + ID: int(dto.Id), + Name: dto.Name, + } +} + +func toPermissionDTO(do *biz.Permission) *system.Permission { + if do == nil { + return nil + } + return &system.Permission{ + Id: int32(do.ID), + Name: do.Name, + } +} + +func toPermissionDTOs(dos []*biz.Permission) []*system.Permission { + dtos := make([]*system.Permission, len(dos)) + for i, do := range dos { + dtos[i] = toPermissionDTO(do) + } + return dtos +} diff --git a/internal/features/system/service/menu.bridge.go b/internal/features/system/service/menu.bridge.go deleted file mode 100644 index a125a63b..00000000 --- a/internal/features/system/service/menu.bridge.go +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "encoding/json" - "net/http" - - transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/goexts/generic/cmp" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/resp" -) - -// MenuServiceHookedBridge is a menu service. -type MenuServiceHookedBridge struct { - pb.UnimplementedMenuServiceHooked - log *log.KHelper -} - -func (h MenuServiceHookedBridge) CompleteCreateMenu(ctx transhttp.Context, request *pb.CreateMenuRequest, response *pb.CreateMenuResponse) error { - marshal, err := json.Marshal(response.Menu) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func (h MenuServiceHookedBridge) CompleteDeleteMenu(ctx transhttp.Context, request *pb.DeleteMenuRequest, response *pb.DeleteMenuResponse) error { - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: nil, - }) -} - -func (h MenuServiceHookedBridge) CompleteGetMenu(ctx transhttp.Context, request *pb.GetMenuRequest, response *pb.GetMenuResponse) error { - marshal, err := json.Marshal(response.Menu) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func (h MenuServiceHookedBridge) CompleteListMenus(ctx transhttp.Context, request *pb.ListMenusRequest, response *pb.ListMenusResponse) error { - if response == nil { - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: false, - Data: nil, - }) - } - marshal, err := resp.Proto2JSON(response.Menus...) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: true, - Data: marshal, - Total: response.TotalSize, - NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), - }) -} - -func (h MenuServiceHookedBridge) CompleteUpdateMenu(ctx transhttp.Context, request *pb.UpdateMenuRequest, response *pb.UpdateMenuResponse) error { - marshal, err := json.Marshal(response.Menu) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func NewMenuServiceHookedBridge(r runtime.Runtime, client pb.MenuServiceHTTPServer) pb.MenuServiceHookedBridger { - return pb.WithMenuServiceHook(&MenuServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/system")), - })(client) -} - -// NewMenuServiceBridge new a menu service. -func NewMenuServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.MenuServiceServer { - return pb.NewMenuServiceBridge(client) -} - -func NewMenuServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.MenuServiceServer { - if c, ok := clients["system"]; ok { - return pb.NewMenuServiceBridge(c) - } else { - return pb.UnimplementedMenuServiceServer{} - } -} - -// NewMenuServiceHTTPBridge new a menu service. -func NewMenuServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.MenuServiceHTTPServer { - return pb.NewMenuServiceHTTPBridge(client) -} - -var _ pb.MenuServiceHooker = (*MenuServiceHookedBridge)(nil) diff --git a/internal/features/system/service/menu.grpc.go b/internal/features/system/service/menu.grpc.go deleted file mode 100644 index 8100b343..00000000 --- a/internal/features/system/service/menu.grpc.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" -) - -// MenuServiceServer is a menu service. -type MenuServiceServer struct { - pb.UnimplementedMenuServiceServer - - client pb.MenuServiceClient - log *log.KHelper -} - -func (s MenuServiceServer) ListMenus(ctx context.Context, request *pb.ListMenusRequest) (*pb.ListMenusResponse, error) { - return s.client.ListMenus(ctx, request) -} - -func (s MenuServiceServer) GetMenu(ctx context.Context, request *pb.GetMenuRequest) (*pb.GetMenuResponse, error) { - return s.client.GetMenu(ctx, request) -} - -func (s MenuServiceServer) CreateMenu(ctx context.Context, request *pb.CreateMenuRequest) (*pb.CreateMenuResponse, error) { - return s.client.CreateMenu(ctx, request) -} - -func (s MenuServiceServer) UpdateMenu(ctx context.Context, request *pb.UpdateMenuRequest) (*pb.UpdateMenuResponse, error) { - return s.client.UpdateMenu(ctx, request) -} - -func (s MenuServiceServer) DeleteMenu(ctx context.Context, request *pb.DeleteMenuRequest) (*pb.DeleteMenuResponse, error) { - return s.client.DeleteMenu(ctx, request) -} - -//func (m MenuServiceServer) mustEmbedUnimplementedMenuServiceServer() { -// //TODO implement me -// panic("implement me") -//} - -// NewMenuServiceServer new a menu service. -func NewMenuServiceServer(client pb.MenuServiceClient, logger log.KLogger) *MenuServiceServer { - return &MenuServiceServer{ - log: log.NewHelper(logger), - client: client, - } -} - -// NewMenuServiceServerPB new a menu service. -func NewMenuServiceServerPB(r runtime.Runtime, client pb.MenuServiceClient) pb.MenuServiceServer { - return NewMenuServiceServer(client, r.WithLogger("module", "service/system")) -} - -var _ pb.MenuServiceServer = (*MenuServiceServer)(nil) diff --git a/internal/features/system/service/menu.http.go b/internal/features/system/service/menu.http.go deleted file mode 100644 index 1ee6e627..00000000 --- a/internal/features/system/service/menu.http.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" -) - -// MenuServiceHTTPServer is a menu service. -type MenuServiceHTTPServer struct { - pb.UnimplementedMenuServiceServer - - client pb.MenuServiceHTTPClient - log *log.KHelper -} - -func (s MenuServiceHTTPServer) CreateMenu(ctx context.Context, request *pb.CreateMenuRequest) (*pb.CreateMenuResponse, error) { - return s.client.CreateMenu(ctx, request) -} - -func (s MenuServiceHTTPServer) DeleteMenu(ctx context.Context, request *pb.DeleteMenuRequest) (*pb.DeleteMenuResponse, error) { - return s.client.DeleteMenu(ctx, request) -} - -func (s MenuServiceHTTPServer) GetMenu(ctx context.Context, request *pb.GetMenuRequest) (*pb.GetMenuResponse, error) { - return s.client.GetMenu(ctx, request) -} - -func (s MenuServiceHTTPServer) ListMenus(ctx context.Context, request *pb.ListMenusRequest) (*pb.ListMenusResponse, error) { - return s.client.ListMenus(ctx, request) -} - -func (s MenuServiceHTTPServer) UpdateMenu(ctx context.Context, request *pb.UpdateMenuRequest) (*pb.UpdateMenuResponse, error) { - return s.client.UpdateMenu(ctx, request) -} - -//func (m MenuServiceHTTPServer) mustEmbedUnimplementedMenuServiceHTTPServer() { -// //TODO implement me -// panic("implement me") -//} - -// NewMenuServiceHTTPServer new a menu service. -func NewMenuServiceHTTPServer(client pb.MenuServiceHTTPClient, logger log.KLogger) *MenuServiceHTTPServer { - return &MenuServiceHTTPServer{ - client: client, - log: log.NewHelper(logger), - } -} - -// NewMenuServiceHTTPServerPB new a menu service. -func NewMenuServiceHTTPServerPB(r runtime.Runtime, client pb.MenuServiceHTTPClient) pb.MenuServiceHTTPServer { - return NewMenuServiceHTTPServer(client, r.WithLogger("module", "service/system")) -} - -var _ pb.MenuServiceServer = (*MenuServiceHTTPServer)(nil) diff --git a/internal/features/system/service/permission.bridge.go b/internal/features/system/service/permission.bridge.go deleted file mode 100644 index d575a36d..00000000 --- a/internal/features/system/service/permission.bridge.go +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "encoding/json" - "net/http" - - transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/goexts/generic/cmp" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/resp" -) - -// PermissionServiceHookedBridge is a menu service. -type PermissionServiceHookedBridge struct { - pb.UnimplementedPermissionServiceHooked - log *log.KHelper -} - -func (h PermissionServiceHookedBridge) CompleteCreatePermission(ctx transhttp.Context, request *pb.CreatePermissionRequest, response *pb.CreatePermissionResponse) error { - marshal, err := json.Marshal(response.Permission) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func (h PermissionServiceHookedBridge) CompleteDeletePermission(ctx transhttp.Context, request *pb.DeletePermissionRequest, response *pb.DeletePermissionResponse) error { - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: nil, - }) -} - -func (h PermissionServiceHookedBridge) CompleteGetPermission(ctx transhttp.Context, request *pb.GetPermissionRequest, response *pb.GetPermissionResponse) error { - marshal, err := json.Marshal(response.Permission) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func (h PermissionServiceHookedBridge) CompleteListPermissions(ctx transhttp.Context, request *pb.ListPermissionsRequest, response *pb.ListPermissionsResponse) error { - if response == nil { - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: false, - Data: nil, - }) - } - marshal, err := resp.Proto2JSON(response.Permissions...) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: true, - Data: marshal, - Total: response.TotalSize, - NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), - }) -} - -func (h PermissionServiceHookedBridge) CompleteUpdatePermission(ctx transhttp.Context, request *pb.UpdatePermissionRequest, response *pb.UpdatePermissionResponse) error { - marshal, err := json.Marshal(response.Permission) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func NewPermissionServiceHookedBridge(r runtime.Runtime, client pb.PermissionServiceHTTPServer) pb.PermissionServiceHookedBridger { - return pb.WithPermissionServiceHook(&PermissionServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/system")), - })(client) -} - -// NewPermissionServiceBridge new a menu service. -func NewPermissionServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.PermissionServiceServer { - return pb.NewPermissionServiceBridge(client) -} - -func NewPermissionServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.PermissionServiceServer { - if c, ok := clients["system"]; ok { - return pb.NewPermissionServiceBridge(c) - } else { - return pb.UnimplementedPermissionServiceServer{} - } -} - -// NewPermissionServiceHTTPBridge new a menu service. -func NewPermissionServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.PermissionServiceHTTPServer { - return pb.NewPermissionServiceHTTPBridge(client) -} - -var _ pb.PermissionServiceHooker = (*PermissionServiceHookedBridge)(nil) diff --git a/internal/features/system/service/permission.go b/internal/features/system/service/permission.go new file mode 100644 index 00000000..e83a36c4 --- /dev/null +++ b/internal/features/system/service/permission.go @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + "origadmin/application/admin/api/v1/services/system" +) + +func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPermissionsRequest) (*system.ListPermissionsResponse, error) { + permissions, total, err := s.permission.ListPermissions(ctx, req) + if err != nil { + return nil, err + } + return &system.ListPermissionsResponse{ + Permissions: permissions, + Total: total, + }, nil +} + +func (s *SystemService) GetPermission(ctx context.Context, req *system.GetPermissionRequest) (*system.Permission, error) { + return s.permission.GetPermission(ctx, req.Id) +} + +func (s *SystemService) CreatePermission(ctx context.Context, req *system.CreatePermissionRequest) (*system.Permission, error) { + return s.permission.CreatePermission(ctx, req.Permission) +} + +func (s *SystemService) UpdatePermission(ctx context.Context, req *system.UpdatePermissionRequest) (*system.Permission, error) { + return s.permission.UpdatePermission(ctx, req.Permission) +} + +func (s *SystemService) DeletePermission(ctx context.Context, req *system.DeletePermissionRequest) (*system.DeletePermissionResponse, error) { + err := s.permission.DeletePermission(ctx, req.Id) + if err != nil { + return nil, err + } + return &system.DeletePermissionResponse{}, nil +} diff --git a/internal/features/system/service/permission.grpc.go b/internal/features/system/service/permission.grpc.go deleted file mode 100644 index f8473a5e..00000000 --- a/internal/features/system/service/permission.grpc.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/biz" // Corrected import path -) - -// PermissionServiceServer is a menu service. -type PermissionServiceServer struct { - pb.UnimplementedPermissionServiceServer - - client *biz.PermissionServiceBiz - log *log.KHelper -} - -func (s PermissionServiceServer) ListPermissions(ctx context.Context, request *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { - return s.client.ListPermissions(ctx, request) -} - -func (s PermissionServiceServer) GetPermission(ctx context.Context, request *pb.GetPermissionRequest) (*pb.GetPermissionResponse, error) { - return s.client.GetPermission(ctx, request) -} - -func (s PermissionServiceServer) CreatePermission(ctx context.Context, request *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { - return s.client.CreatePermission(ctx, request) -} - -func (s PermissionServiceServer) UpdatePermission(ctx context.Context, request *pb.UpdatePermissionRequest) (*pb.UpdatePermissionResponse, error) { - return s.client.UpdatePermission(ctx, request) -} - -func (s PermissionServiceServer) DeletePermission(ctx context.Context, request *pb.DeletePermissionRequest) (*pb.DeletePermissionResponse, error) { - return s.client.DeletePermission(ctx, request) -} - -//func (m PermissionServiceServer) mustEmbedUnimplementedPermissionServiceServer() { -// //TODO implement me -// panic("implement me") -//} - -// NewPermissionServiceServer new a menu service. -func NewPermissionServiceServer(r runtime.Runtime, client *biz.PermissionServiceBiz) *PermissionServiceServer { - return &PermissionServiceServer{ - log: log.NewHelper(r.WithLogger("module", "service/system")), - client: client, - } -} - -// NewPermissionServiceServerPB new a menu service. -func NewPermissionServiceServerPB(r runtime.Runtime, client *biz.PermissionServiceBiz) pb.PermissionServiceServer { - return NewPermissionServiceServer(r, client) -} - -var _ pb.PermissionServiceServer = (*PermissionServiceServer)(nil) diff --git a/internal/features/system/service/permission.http.go b/internal/features/system/service/permission.http.go deleted file mode 100644 index 545ab348..00000000 --- a/internal/features/system/service/permission.http.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/biz" // Corrected import path -) - -// PermissionServiceHTTPServer is a menu service. -type PermissionServiceHTTPServer struct { - client *biz.PermissionServiceBiz - log *log.KHelper -} - -func (s PermissionServiceHTTPServer) CreatePermission(ctx context.Context, request *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { - return s.client.CreatePermission(ctx, request) -} - -func (s PermissionServiceHTTPServer) DeletePermission(ctx context.Context, request *pb.DeletePermissionRequest) (*pb.DeletePermissionResponse, error) { - return s.client.DeletePermission(ctx, request) -} - -func (s PermissionServiceHTTPServer) GetPermission(ctx context.Context, request *pb.GetPermissionRequest) (*pb.GetPermissionResponse, error) { - return s.client.GetPermission(ctx, request) -} - -func (s PermissionServiceHTTPServer) ListPermissions(ctx context.Context, request *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { - return s.client.ListPermissions(ctx, request) -} - -func (s PermissionServiceHTTPServer) UpdatePermission(ctx context.Context, request *pb.UpdatePermissionRequest) (*pb.UpdatePermissionResponse, error) { - return s.client.UpdatePermission(ctx, request) -} - -// NewPermissionServiceHTTPServer new a menu service. -func NewPermissionServiceHTTPServer(r runtime.Runtime, client *biz.PermissionServiceBiz) *PermissionServiceHTTPServer { - return &PermissionServiceHTTPServer{ - log: log.NewHelper(r.WithLogger("module", "service/system")), - client: client, - } -} - -// NewPermissionServiceHTTPServerPB new a menu service. -func NewPermissionServiceHTTPServerPB(r runtime.Runtime, client *biz.PermissionServiceBiz) pb.PermissionServiceHTTPServer { - return NewPermissionServiceHTTPServer(r, client) -} - -var _ pb.PermissionServiceHTTPServer = (*PermissionServiceHTTPServer)(nil) diff --git a/internal/features/system/service/provider.go b/internal/features/system/service/provider.go index 99a2a1d1..295fb7a2 100644 --- a/internal/features/system/service/provider.go +++ b/internal/features/system/service/provider.go @@ -11,38 +11,5 @@ import ( // ProviderSet is service providers. var ProviderSet = wire.NewSet( - NewRegisterServer, - NewResourceServiceServerPB, - NewResourceServiceHTTPServerPB, - NewRoleServiceServerPB, - NewRoleServiceHTTPServerPB, - NewUserServiceServerPB, - NewUserServiceHTTPServerPB, - NewPermissionServiceServerPB, - NewPermissionServiceHTTPServerPB, -) - -// LocalProviderSet is service providers. -var LocalProviderSet = wire.NewSet( - NewRegisterBridgeServer, - NewResourceServiceServerPB, - NewResourceServiceHTTPServerPB, - NewRoleServiceServerPB, - NewRoleServiceHTTPServerPB, - NewUserServiceServerPB, - NewUserServiceHTTPServerPB, - NewPermissionServiceServerPB, - NewPermissionServiceHTTPServerPB, -) - -var RemoteProviderSet = wire.NewSet( - NewRegisterBridgeServer, - NewResourceServiceBridgeClient, - //NewResourceServiceBridge, - NewRoleServiceBridgeClient, - //NewRoleServiceBridge, - NewUserServiceBridgeClient, - //NewUserServiceBridge, - NewPermissionServiceBridgeClient, - //NewPermissionServiceBridge, + New, ) diff --git a/internal/features/system/service/resource.bridge.go b/internal/features/system/service/resource.bridge.go deleted file mode 100644 index e24d35e0..00000000 --- a/internal/features/system/service/resource.bridge.go +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "encoding/json" - "net/http" - - transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/goexts/generic/cmp" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/resp" -) - -// ResourceServiceHookedBridge is a menu service. -type ResourceServiceHookedBridge struct { - pb.UnimplementedResourceServiceHooked - log *log.KHelper -} - -func (h ResourceServiceHookedBridge) CompleteCreateResource(ctx transhttp.Context, request *pb.CreateResourceRequest, response *pb.CreateResourceResponse) error { - marshal, err := json.Marshal(response.Resource) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func (h ResourceServiceHookedBridge) CompleteDeleteResource(ctx transhttp.Context, request *pb.DeleteResourceRequest, response *pb.DeleteResourceResponse) error { - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: nil, - }) -} - -func (h ResourceServiceHookedBridge) CompleteGetResource(ctx transhttp.Context, request *pb.GetResourceRequest, response *pb.GetResourceResponse) error { - marshal, err := json.Marshal(response.Resource) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func (h ResourceServiceHookedBridge) CompleteListResources(ctx transhttp.Context, request *pb.ListResourcesRequest, response *pb.ListResourcesResponse) error { - if response == nil { - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: false, - Data: nil, - }) - } - marshal, err := resp.Proto2JSON(response.Resources...) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: true, - Data: marshal, - Total: response.TotalSize, - NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), - }) -} - -func (h ResourceServiceHookedBridge) CompleteUpdateResource(ctx transhttp.Context, request *pb.UpdateResourceRequest, response *pb.UpdateResourceResponse) error { - marshal, err := json.Marshal(response.Resource) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func NewResourceServiceHookedBridge(r runtime.Runtime, client pb.ResourceServiceHTTPServer) pb.ResourceServiceHookedBridger { - return pb.WithResourceServiceHook(&ResourceServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/system")), - })(client) -} - -// NewResourceServiceBridge new a menu service. -func NewResourceServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.ResourceServiceServer { - return pb.NewResourceServiceBridge(client) -} - -func NewResourceServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.ResourceServiceServer { - if c, ok := clients["system"]; ok { - return pb.NewResourceServiceBridge(c) - } else { - return pb.UnimplementedResourceServiceServer{} - } -} - -// NewResourceServiceHTTPBridge new a menu service. -func NewResourceServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.ResourceServiceHTTPServer { - return pb.NewResourceServiceHTTPBridge(client) -} - -var _ pb.ResourceServiceHooker = (*ResourceServiceHookedBridge)(nil) diff --git a/internal/features/system/service/resource.go b/internal/features/system/service/resource.go new file mode 100644 index 00000000..ca9b80cb --- /dev/null +++ b/internal/features/system/service/resource.go @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + "origadmin/application/admin/api/v1/services/system" +) + +func (s *SystemService) ListResources(ctx context.Context, req *system.ListResourcesRequest) (*system.ListResourcesResponse, error) { + resources, total, err := s.resource.ListResources(ctx, req) + if err != nil { + return nil, err + } + return &system.ListResourcesResponse{ + Resources: resources, + Total: total, + }, nil +} + +func (s *SystemService) GetResource(ctx context.Context, req *system.GetResourceRequest) (*system.Resource, error) { + return s.resource.GetResource(ctx, req.Id) +} + +func (s *SystemService) CreateResource(ctx context.Context, req *system.CreateResourceRequest) (*system.Resource, error) { + return s.resource.CreateResource(ctx, req.Resource) +} + +func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateResourceRequest) (*system.Resource, error) { + return s.resource.UpdateResource(ctx, req.Resource) +} + +func (s *SystemService) DeleteResource(ctx context.Context, req *system.DeleteResourceRequest) (*system.DeleteResourceResponse, error) { + err := s.resource.DeleteResource(ctx, req.Id) + if err != nil { + return nil, err + } + return &system.DeleteResourceResponse{}, nil +} diff --git a/internal/features/system/service/resource.grpc.go b/internal/features/system/service/resource.grpc.go deleted file mode 100644 index 75ab8a57..00000000 --- a/internal/features/system/service/resource.grpc.go +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/biz" // Corrected import path -) - -// ResourceServiceServer is a menu service. -type ResourceServiceServer struct { - pb.UnimplementedResourceServiceServer - client *biz.ResourceServiceBiz - log *log.KHelper -} - -func (s ResourceServiceServer) ListResources(ctx context.Context, request *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { - return s.client.ListResources(ctx, request) -} - -func (s ResourceServiceServer) GetResource(ctx context.Context, request *pb.GetResourceRequest) (*pb.GetResourceResponse, error) { - return s.client.GetResource(ctx, request) -} - -func (s ResourceServiceServer) CreateResource(ctx context.Context, request *pb.CreateResourceRequest) (*pb.CreateResourceResponse, error) { - return s.client.CreateResource(ctx, request) -} - -func (s ResourceServiceServer) UpdateResource(ctx context.Context, request *pb.UpdateResourceRequest) (*pb.UpdateResourceResponse, error) { - return s.client.UpdateResource(ctx, request) -} - -func (s ResourceServiceServer) DeleteResource(ctx context.Context, request *pb.DeleteResourceRequest) (*pb.DeleteResourceResponse, error) { - return s.client.DeleteResource(ctx, request) -} - -//func (m ResourceServiceServer) mustEmbedUnimplementedResourceServiceServer() { -// //TODO implement me -// panic("implement me") -//} - -// NewResourceServiceServer new a menu service. -func NewResourceServiceServer(r runtime.Runtime, client *biz.ResourceServiceBiz) *ResourceServiceServer { - return &ResourceServiceServer{ - log: log.NewHelper(r.WithLogger("module", "service/system")), - client: client, - } -} - -// NewResourceServiceServerPB new a menu service. -func NewResourceServiceServerPB(r runtime.Runtime, client *biz.ResourceServiceBiz) pb.ResourceServiceServer { - return NewResourceServiceServer(r, client) -} - -var _ pb.ResourceServiceServer = (*ResourceServiceServer)(nil) diff --git a/internal/features/system/service/resource.http.go b/internal/features/system/service/resource.http.go deleted file mode 100644 index 1160bfb8..00000000 --- a/internal/features/system/service/resource.http.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime/context" - - pb "origadmin/application/admin/api/v1/services/system" -) - -// ResourceServiceHTTPServer is a menu service. -type ResourceServiceHTTPServer struct { - pb.UnimplementedResourceServiceServer - - client pb.ResourceServiceHTTPClient -} - -func (s ResourceServiceHTTPServer) CreateResource(ctx context.Context, request *pb.CreateResourceRequest) (*pb.CreateResourceResponse, error) { - return s.client.CreateResource(ctx, request) -} - -func (s ResourceServiceHTTPServer) DeleteResource(ctx context.Context, request *pb.DeleteResourceRequest) (*pb.DeleteResourceResponse, error) { - return s.client.DeleteResource(ctx, request) -} - -func (s ResourceServiceHTTPServer) GetResource(ctx context.Context, request *pb.GetResourceRequest) (*pb.GetResourceResponse, error) { - return s.client.GetResource(ctx, request) -} - -func (s ResourceServiceHTTPServer) ListResources(ctx context.Context, request *pb.ListResourcesRequest) (*pb.ListResourcesResponse, error) { - return s.client.ListResources(ctx, request) -} - -func (s ResourceServiceHTTPServer) UpdateResource(ctx context.Context, request *pb.UpdateResourceRequest) (*pb.UpdateResourceResponse, error) { - return s.client.UpdateResource(ctx, request) -} - -//func (m ResourceServiceHTTPServer) mustEmbedUnimplementedResourceServiceHTTPServer() { -// //TODO implement me -// panic("implement me") -//} - -// NewResourceServiceHTTPServer new a menu service. -func NewResourceServiceHTTPServer(client pb.ResourceServiceHTTPClient) *ResourceServiceHTTPServer { - return &ResourceServiceHTTPServer{client: client} -} - -// NewResourceServiceHTTPServerPB new a menu service. -func NewResourceServiceHTTPServerPB(client pb.ResourceServiceHTTPClient) pb.ResourceServiceHTTPServer { - return &ResourceServiceHTTPServer{client: client} -} - -var _ pb.ResourceServiceServer = (*ResourceServiceHTTPServer)(nil) diff --git a/internal/features/system/service/role.bridge.go b/internal/features/system/service/role.bridge.go deleted file mode 100644 index 1e55304c..00000000 --- a/internal/features/system/service/role.bridge.go +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "encoding/json" - "net/http" - - transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/goexts/generic/cmp" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/resp" -) - -// RoleServiceHookedBridge is a menu service. -type RoleServiceHookedBridge struct { - pb.UnimplementedRoleServiceHooked - log *log.KHelper -} - -func (h RoleServiceHookedBridge) CompleteCreateRole(ctx transhttp.Context, request *pb.CreateRoleRequest, response *pb.CreateRoleResponse) error { - marshal, err := json.Marshal(response.Role) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func (h RoleServiceHookedBridge) CompleteDeleteRole(ctx transhttp.Context, request *pb.DeleteRoleRequest, response *pb.DeleteRoleResponse) error { - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: nil, - }) -} - -func (h RoleServiceHookedBridge) CompleteGetRole(ctx transhttp.Context, request *pb.GetRoleRequest, response *pb.GetRoleResponse) error { - marshal, err := json.Marshal(response.Role) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func (h RoleServiceHookedBridge) CompleteListRoles(ctx transhttp.Context, request *pb.ListRolesRequest, response *pb.ListRolesResponse) error { - if response == nil { - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: false, - Data: nil, - }) - } - marshal, err := resp.Proto2JSON(response.Roles...) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: true, - Data: marshal, - Total: response.TotalSize, - NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), - }) -} - -func (h RoleServiceHookedBridge) CompleteUpdateRole(ctx transhttp.Context, request *pb.UpdateRoleRequest, response *pb.UpdateRoleResponse) error { - marshal, err := json.Marshal(response.Role) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func NewRoleServiceHookedBridge(r runtime.Runtime, client pb.RoleServiceHTTPServer) pb.RoleServiceHookedBridger { - return pb.WithRoleServiceHook(&RoleServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/system")), - })(client) -} - -// NewRoleServiceBridge new a menu service. -func NewRoleServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.RoleServiceServer { - return pb.NewRoleServiceBridge(client) -} - -func NewRoleServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.RoleServiceServer { - if v, ok := clients["system"]; ok { - return NewRoleServiceBridge(r, v) - } else { - return pb.UnimplementedRoleServiceServer{} - } -} - -// NewRoleServiceHTTPBridge new a menu service. -func NewRoleServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.RoleServiceHTTPServer { - return pb.NewRoleServiceHTTPBridge(client) -} - -var _ pb.RoleServiceHooker = (*RoleServiceHookedBridge)(nil) diff --git a/internal/features/system/service/role.go b/internal/features/system/service/role.go new file mode 100644 index 00000000..744e6616 --- /dev/null +++ b/internal/features/system/service/role.go @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + "origadmin/application/admin/api/v1/services/system" +) + +func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequest) (*system.ListRolesResponse, error) { + roles, total, err := s.role.ListRoles(ctx, req) + if err != nil { + return nil, err + } + + return &system.ListRolesResponse{ + Roles: roles, + Total: total, + }, nil +} +func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*system.Role, error) { + return s.role.GetRole(ctx, req.Id) +} +func (s *SystemService) CreateRole(ctx context.Context, req *system.CreateRoleRequest) (*system.Role, error) { + return s.role.CreateRole(ctx, req.Role) +} +func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRequest) (*system.Role, error) { + return s.role.UpdateRole(ctx, req.Role) +} +func (s *SystemService) DeleteRole(ctx context.Context, req *system.DeleteRoleRequest) (*system.DeleteRoleResponse, error) { + err := s.role.DeleteRole(ctx, req.Id) + if err != nil { + return nil, err + } + return &system.DeleteRoleResponse{}, nil +} diff --git a/internal/features/system/service/role.grpc.go b/internal/features/system/service/role.grpc.go deleted file mode 100644 index 447be76f..00000000 --- a/internal/features/system/service/role.grpc.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/biz" // Corrected import path -) - -type RoleServiceServer struct { - pb.UnimplementedRoleServiceServer - - client *biz.RoleServiceBiz - log *log.KHelper -} - -func (s RoleServiceServer) ListRoles(ctx context.Context, req *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { - return s.client.ListRoles(ctx, req) -} -func (s RoleServiceServer) GetRole(ctx context.Context, req *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { - return s.client.GetRole(ctx, req) -} -func (s RoleServiceServer) CreateRole(ctx context.Context, req *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { - return s.client.CreateRole(ctx, req) -} -func (s RoleServiceServer) UpdateRole(ctx context.Context, req *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { - return s.client.UpdateRole(ctx, req) -} -func (s RoleServiceServer) DeleteRole(ctx context.Context, req *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { - return s.client.DeleteRole(ctx, req) -} - -// NewRoleServiceServer new a user service. -func NewRoleServiceServer(r runtime.Runtime, client *biz.RoleServiceBiz) *RoleServiceServer { - return &RoleServiceServer{ - log: log.NewHelper(r.WithLogger( - "module", "service/system", - )), - client: client, - } -} - -// NewRoleServiceServerPB new a user service. -func NewRoleServiceServerPB(r runtime.Runtime, client *biz.RoleServiceBiz) pb.RoleServiceServer { - return NewRoleServiceServer(r, client) -} - -var _ pb.RoleServiceServer = (*RoleServiceServer)(nil) diff --git a/internal/features/system/service/role.http.go b/internal/features/system/service/role.http.go deleted file mode 100644 index 60089f9b..00000000 --- a/internal/features/system/service/role.http.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - - pb "origadmin/application/admin/api/v1/services/system" -) - -type RoleServiceHTTPServer struct { - pb.UnimplementedRoleServiceServer - - client pb.RoleServiceHTTPClient -} - -func (s RoleServiceHTTPServer) ListRoles(ctx context.Context, req *pb.ListRolesRequest) (*pb.ListRolesResponse, error) { - return s.client.ListRoles(ctx, req) -} -func (s RoleServiceHTTPServer) GetRole(ctx context.Context, req *pb.GetRoleRequest) (*pb.GetRoleResponse, error) { - return s.client.GetRole(ctx, req) -} -func (s RoleServiceHTTPServer) CreateRole(ctx context.Context, req *pb.CreateRoleRequest) (*pb.CreateRoleResponse, error) { - return s.client.CreateRole(ctx, req) -} -func (s RoleServiceHTTPServer) UpdateRole(ctx context.Context, req *pb.UpdateRoleRequest) (*pb.UpdateRoleResponse, error) { - return s.client.UpdateRole(ctx, req) -} -func (s RoleServiceHTTPServer) DeleteRole(ctx context.Context, req *pb.DeleteRoleRequest) (*pb.DeleteRoleResponse, error) { - return s.client.DeleteRole(ctx, req) -} - -// NewRoleServiceHTTPServer new a role service. -func NewRoleServiceHTTPServer(client pb.RoleServiceHTTPClient) *RoleServiceHTTPServer { - return &RoleServiceHTTPServer{ - client: client, - } -} - -// NewRoleServiceHTTPServerPB new a role service. -func NewRoleServiceHTTPServerPB(client pb.RoleServiceHTTPClient) pb.RoleServiceHTTPServer { - return &RoleServiceHTTPServer{ - client: client, - } -} - -var _ pb.RoleServiceServer = (*RoleServiceHTTPServer)(nil) diff --git a/internal/features/system/service/service.go b/internal/features/system/service/service.go index e398a718..0e9601a8 100644 --- a/internal/features/system/service/service.go +++ b/internal/features/system/service/service.go @@ -7,106 +7,46 @@ package service import ( "context" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service" - pb "origadmin/application/admin/api/v1/services/system" + system "origadmin/application/admin/api/v1/system" + "origadmin/application/admin/internal/features/system/biz" ) -type SystemServerRegistrar service.ServerRegistrar - -type RegisterServer struct { - Resource pb.ResourceServiceServer - Role pb.RoleServiceServer - User pb.UserServiceServer - Permission pb.PermissionServiceServer -} - -func (s RegisterServer) Register(ctx context.Context, svc any) { - switch v := svc.(type) { - case *service.GRPCServer: - s.RegisterGRPC(ctx, v) - case *service.HTTPServer: - s.RegisterHTTP(ctx, v) - } -} - -func (s RegisterServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { - log.Info("grpc server system init") - pb.RegisterResourceServiceServer(server, s.Resource) - pb.RegisterRoleServiceServer(server, s.Role) - pb.RegisterUserServiceServer(server, s.User) - pb.RegisterPermissionServiceServer(server, s.Permission) -} - -func (s RegisterServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { - log.Info("http server system init") - server.Route("/sys") - pb.RegisterResourceServiceHTTPServer(server, s.Resource) - pb.RegisterRoleServiceHTTPServer(server, s.Role) - pb.RegisterUserServiceHTTPServer(server, s.User) - pb.RegisterPermissionServiceHTTPServer(server, s.Permission) -} - -func NewRegisterServer( - Resource pb.ResourceServiceServer, - Role pb.RoleServiceServer, - User pb.UserServiceServer, - Permission pb.PermissionServiceServer, -) SystemServerRegistrar { - return &RegisterServer{ - Resource: Resource, - Role: Role, - User: User, - Permission: Permission, +type SystemService struct { + system.UnimplementedResourceServiceServer + system.UnimplementedRoleServiceServer + system.UnimplementedUserServiceServer + system.UnimplementedPermissionServiceServer + + resource *biz.ResourceUseCase + role *biz.RoleUseCase + user *biz.UserUseCase + permission *biz.PermissionUseCase +} + +func New( + resource *biz.ResourceUseCase, + role *biz.RoleUseCase, + user *biz.UserUseCase, + permission *biz.PermissionUseCase, +) *SystemService { + return &SystemService{ + resource: resource, + role: role, + user: user, + permission: permission, } } -type RegisterBridgeServer struct { - Resource pb.ResourceServiceHookedBridger - Role pb.RoleServiceHookedBridger - User pb.UserServiceHookedBridger - Permission pb.PermissionServiceHookedBridger -} - -func (s RegisterBridgeServer) Register(ctx context.Context, svc any) { - switch v := svc.(type) { - case *service.GRPCServer: - s.RegisterGRPC(ctx, v) - case *service.HTTPServer: - s.RegisterHTTP(ctx, v) - } -} - -func (s RegisterBridgeServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { - log.Info("http server system init") - pb.RegisterResourceServiceBridgeServer(server, s.Resource) - pb.RegisterRoleServiceBridgeServer(server, s.Role) - pb.RegisterUserServiceBridgeServer(server, s.User) - pb.RegisterPermissionServiceBridgeServer(server, s.Permission) -} +func (s *SystemService) Register(ctx context.Context, srv *service.Server) { + system.RegisterResourceServiceServer(srv.GRPC, s) + system.RegisterRoleServiceServer(srv.GRPC, s) + system.RegisterUserServiceServer(srv.GRPC, s) + system.RegisterPermissionServiceServer(srv.GRPC, s) -func (s RegisterBridgeServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { - log.Info("grpc server system init") - //pb.RegisterResourceServiceBridgeServer(server, s.Resource) - //pb.RegisterRoleServiceBridgeServer(server, s.Role) - //pb.RegisterUserServiceBridgeServer(server, s.User) - //pb.RegisterPermissionServiceBridgeServer(server, s.Permission) + system.RegisterResourceServiceHTTPServer(srv.HTTP, s) + system.RegisterRoleServiceHTTPServer(srv.HTTP, s) + system.RegisterUserServiceHTTPServer(srv.HTTP, s) + system.RegisterPermissionServiceHTTPServer(srv.HTTP, s) } - -func NewRegisterBridgeServer(r runtime.Runtime, - Resource pb.ResourceServiceServer, - Role pb.RoleServiceServer, - User pb.UserServiceServer, - Permission pb.PermissionServiceServer, -) SystemServerRegistrar { - return &RegisterBridgeServer{ - Resource: NewResourceServiceHookedBridge(r, Resource), - Role: NewRoleServiceHookedBridge(r, Role), - User: NewUserServiceHookedBridge(r, User), - Permission: NewPermissionServiceHookedBridge(r, Permission), - } -} - -var _ service.ServerRegistrar = (*RegisterServer)(nil) diff --git a/internal/features/system/service/user.bridge.go b/internal/features/system/service/user.bridge.go deleted file mode 100644 index b06a7663..00000000 --- a/internal/features/system/service/user.bridge.go +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "encoding/json" - "net/http" - - transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/goexts/generic/cmp" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/resp" -) - -// UserServiceHookedBridge is a menu service. -type UserServiceHookedBridge struct { - pb.UnimplementedUserServiceHooked - log *log.KHelper -} - -func (h UserServiceHookedBridge) CompleteCreateUser(ctx transhttp.Context, request *pb.CreateUserRequest, response *pb.CreateUserResponse) error { - marshal, err := json.Marshal(response.User) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func (h UserServiceHookedBridge) CompleteDeleteUser(ctx transhttp.Context, request *pb.DeleteUserRequest, response *pb.DeleteUserResponse) error { - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: nil, - }) -} - -func (h UserServiceHookedBridge) CompleteGetUser(ctx transhttp.Context, request *pb.GetUserRequest, response *pb.GetUserResponse) error { - marshal, err := json.Marshal(response.User) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func (h UserServiceHookedBridge) CompleteListUsers(ctx transhttp.Context, request *pb.ListUsersRequest, response *pb.ListUsersResponse) error { - if response == nil { - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: false, - Data: nil, - }) - } - marshal, err := resp.Proto2JSON(response.Users...) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: true, - Data: marshal, - Total: response.TotalSize, - NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), - }) -} - -func (h UserServiceHookedBridge) CompleteUpdateUser(ctx transhttp.Context, request *pb.UpdateUserRequest, response *pb.UpdateUserResponse) error { - marshal, err := json.Marshal(response.User) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.SourceData{ - Success: true, - Data: marshal, - }) -} - -func NewUserServiceHookedBridge(r runtime.Runtime, client pb.UserServiceHTTPServer) pb.UserServiceHookedBridger { - return pb.WithUserServiceHook(&UserServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/system")), - })(client) -} - -// NewUserServiceBridge new a menu service. -func NewUserServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.UserServiceServer { - return pb.NewUserServiceBridge(client) -} - -func NewUserServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.UserServiceServer { - if c, ok := clients["system"]; ok { - return pb.NewUserServiceBridge(c) - } else { - return pb.UnimplementedUserServiceServer{} - } -} - -// NewUserServiceHTTPBridge new a menu service. -func NewUserServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.UserServiceHTTPServer { - return pb.NewUserServiceHTTPBridge(client) -} - -var _ pb.UserServiceHooker = (*UserServiceHookedBridge)(nil) diff --git a/internal/features/system/service/user.go b/internal/features/system/service/user.go new file mode 100644 index 00000000..62828951 --- /dev/null +++ b/internal/features/system/service/user.go @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + "origadmin/application/admin/api/v1/services/system" +) + +func (s *SystemService) ListUserResources(ctx context.Context, req *system.ListUserResourcesRequest) (*system.ListUserResourcesResponse, error) { + resources, err := s.user.ListUserResources(ctx, req.Id) + if err != nil { + return nil, err + } + return &system.ListUserResourcesResponse{ + Resources: resources, + }, nil +} + +func (s *SystemService) UpdateUserRoles(ctx context.Context, req *system.UpdateUserRolesRequest) (*system.UpdateUserRolesResponse, error) { + err := s.user.UpdateUserRoles(ctx, req.Id, req.RoleIds) + if err != nil { + return nil, err + } + return &system.UpdateUserRolesResponse{}, nil +} + +func (s *SystemService) UpdateUserStatus(ctx context.Context, req *system.UpdateUserStatusRequest) (*system.UpdateUserStatusResponse, error) { + err := s.user.UpdateUserStatus(ctx, req.Id, req.Status) + if err != nil { + return nil, err + } + return &system.UpdateUserStatusResponse{}, nil +} + +func (s *SystemService) ResetUserPassword(ctx context.Context, req *system.ResetUserPasswordRequest) (*system.ResetUserPasswordResponse, error) { + err := s.user.ResetUserPassword(ctx, req.Id, req.Password) + if err != nil { + return nil, err + } + return &system.ResetUserPasswordResponse{}, nil +} + +func (s *SystemService) ListUsers(ctx context.Context, req *system.ListUsersRequest) (*system.ListUsersResponse, error) { + users, total, err := s.user.ListUsers(ctx, req) + if err != nil { + return nil, err + } + return &system.ListUsersResponse{ + Users: users, + Total: total, + }, nil +} + +func (s *SystemService) GetUser(ctx context.Context, req *system.GetUserRequest) (*system.User, error) { + return s.user.GetUser(ctx, req.Id) +} + +func (s *SystemService) CreateUser(ctx context.Context, req *system.CreateUserRequest) (*system.User, error) { + return s.user.CreateUser(ctx, req.User, req.Password) +} + +func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRequest) (*system.User, error) { + return s.user.UpdateUser(ctx, req.User) +} + +func (s *SystemService) DeleteUser(ctx context.Context, req *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { + err := s.user.DeleteUser(ctx, req.Id) + if err != nil { + return nil, err + } + return &system.DeleteUserResponse{}, nil +} diff --git a/internal/features/system/service/user.grpc.go b/internal/features/system/service/user.grpc.go deleted file mode 100644 index e8984b66..00000000 --- a/internal/features/system/service/user.grpc.go +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/biz" // Corrected import path -) - -type UserServiceServer struct { - pb.UnimplementedUserServiceServer - - client *biz.UserServiceBiz - log *log.KHelper -} - -func (s UserServiceServer) ListUserResources(ctx context.Context, request *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { - return s.client.ListUserResources(ctx, request) -} - -func (s UserServiceServer) UpdateUserStatus(ctx context.Context, request *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { - //TODO implement me - panic("implement me") -} - -func (s UserServiceServer) UpdateUserRoles(ctx context.Context, request *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (s UserServiceServer) ResetUserPassword(ctx context.Context, request *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { - //TODO implement me - panic("implement me") -} - -func (s UserServiceServer) mustEmbedUnimplementedUserServiceServer() { - //TODO implement me - panic("implement me") -} - -func (s UserServiceServer) ListUsers(ctx context.Context, req *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { - return s.client.ListUsers(ctx, req) -} - -func (s UserServiceServer) GetUser(ctx context.Context, req *pb.GetUserRequest) (*pb.GetUserResponse, error) { - return s.client.GetUser(ctx, req) -} - -func (s UserServiceServer) CreateUser(ctx context.Context, req *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { - return s.client.CreateUser(ctx, req) -} - -func (s UserServiceServer) UpdateUser(ctx context.Context, req *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { - return s.client.UpdateUser(ctx, req) -} - -func (s UserServiceServer) DeleteUser(ctx context.Context, req *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { - return s.client.DeleteUser(ctx, req) -} - -// NewUserServiceServer new a user service. -func NewUserServiceServer(r runtime.Runtime, client *biz.UserServiceBiz) *UserServiceServer { - return &UserServiceServer{ - log: log.NewHelper(r.WithLogger( - "module", "service/system", - )), - client: client, - } -} - -// NewUserServiceServerPB new a user service. -func NewUserServiceServerPB(r runtime.Runtime, client *biz.UserServiceBiz) pb.UserServiceServer { - return NewUserServiceServer(r, client) -} - -var _ pb.UserServiceServer = (*UserServiceServer)(nil) diff --git a/internal/features/system/service/user.http.go b/internal/features/system/service/user.http.go deleted file mode 100644 index 44afa0ad..00000000 --- a/internal/features/system/service/user.http.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - - pb "origadmin/application/admin/api/v1/services/system" -) - -type UserServiceHTTPServer struct { - pb.UnimplementedUserServiceServer - - client pb.UserServiceHTTPClient -} - -func (s UserServiceHTTPServer) ListUserResources(ctx context.Context, request *pb.ListUserResourcesRequest) (*pb.ListUserResourcesResponse, error) { - return s.client.ListUserResources(ctx, request) -} - -func (s UserServiceHTTPServer) ResetUserPassword(ctx context.Context, request *pb.ResetUserPasswordRequest) (*pb.ResetUserPasswordResponse, error) { - //TODO implement me - panic("implement me") -} - -func (s UserServiceHTTPServer) UpdateUserRoles(ctx context.Context, request *pb.UpdateUserRolesRequest) (*pb.UpdateUserRolesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (s UserServiceHTTPServer) UpdateUserStatus(ctx context.Context, request *pb.UpdateUserStatusRequest) (*pb.UpdateUserStatusResponse, error) { - //TODO implement me - panic("implement me") -} - -func (s UserServiceHTTPServer) ListUsers(ctx context.Context, req *pb.ListUsersRequest) (*pb.ListUsersResponse, error) { - return s.client.ListUsers(ctx, req) -} - -func (s UserServiceHTTPServer) GetUser(ctx context.Context, req *pb.GetUserRequest) (*pb.GetUserResponse, error) { - return s.client.GetUser(ctx, req) -} - -func (s UserServiceHTTPServer) CreateUser(ctx context.Context, req *pb.CreateUserRequest) (*pb.CreateUserResponse, error) { - return s.client.CreateUser(ctx, req) -} - -func (s UserServiceHTTPServer) UpdateUser(ctx context.Context, req *pb.UpdateUserRequest) (*pb.UpdateUserResponse, error) { - return s.client.UpdateUser(ctx, req) -} - -func (s UserServiceHTTPServer) DeleteUser(ctx context.Context, req *pb.DeleteUserRequest) (*pb.DeleteUserResponse, error) { - return s.client.DeleteUser(ctx, req) -} - -// NewUserServiceHTTPServer new a user service. -func NewUserServiceHTTPServer(client pb.UserServiceHTTPClient) *UserServiceHTTPServer { - return &UserServiceHTTPServer{ - client: client, - } -} - -// NewUserServiceHTTPServerPB new a user service. -func NewUserServiceHTTPServerPB(client pb.UserServiceHTTPClient) pb.UserServiceHTTPServer { - return &UserServiceHTTPServer{ - client: client, - } -} - -var _ pb.UserServiceServer = (*UserServiceHTTPServer)(nil) diff --git a/internal/gateway/proxy.go b/internal/gateway/proxy.go index 4880505a..fc72a6c6 100644 --- a/internal/gateway/proxy.go +++ b/internal/gateway/proxy.go @@ -2,7 +2,7 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package loader implements the functions, types, and interfaces for the module. +// Package gateway implements the functions, types, and interfaces for the module. package gateway import ( diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 005a6ae4..f33fbb82 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -1466,9 +1466,9 @@ paths: description: The parent resource id, for example, "shelves/shelf1". schema: type: string - - name: current + - name: page in: query - description: The current page number. + description: The page page number. schema: type: integer format: int32 @@ -3330,7 +3330,7 @@ components: api.v1.services.system.ListPermissionsResponse: type: object properties: - total_size: + total: type: integer description: The total number of items in the list. format: int32 @@ -3339,9 +3339,9 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.Permission' description: The paging menus - current: + page: type: integer - description: The current page number. + description: The page page number. format: int32 page_size: type: integer @@ -3357,7 +3357,7 @@ components: - $ref: '#/components/schemas/google.protobuf.Any' description: |- Additional information about this response. - content to be added without destroying the current data format + content to be added without destroying the page data format api.v1.services.system.ListPositionsResponse: type: object properties: From 4878b671c456a819943e2628a29972bda4351e52 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 24 Dec 2025 01:32:40 +0800 Subject: [PATCH 069/158] refactor(proto): standardize pagination field names from 'current' to 'page' and 'total_size' to 'total' across system APIs --- api/v1/proto/system/department.proto | 12 ++-- api/v1/proto/system/menu.proto | 12 ++-- api/v1/proto/system/permission.proto | 4 +- api/v1/proto/system/position.proto | 12 ++-- api/v1/proto/system/resource.proto | 12 ++-- api/v1/proto/system/role.proto | 12 ++-- api/v1/proto/system/user.proto | 14 ++-- internal/features/system/service/service.go | 11 ++- resources/docs/openapi/openapi.yaml | 78 ++++++++++----------- 9 files changed, 86 insertions(+), 81 deletions(-) diff --git a/api/v1/proto/system/department.proto b/api/v1/proto/system/department.proto index cfb7d8e3..54569ece 100644 --- a/api/v1/proto/system/department.proto +++ b/api/v1/proto/system/department.proto @@ -41,8 +41,8 @@ service DepartmentService { message ListDepartmentsRequest { // The parent resource id, for example, "shelves/shelf1". int64 id = 1 [json_name = "id"]; - // The current page number. - int32 current = 2 [json_name = "current"]; + // The page number. + int32 page = 2 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 3 [json_name = "page_size"]; // The next_page_token value returned from a previous List request, if any. @@ -55,18 +55,18 @@ message ListDepartmentsRequest { message ListDepartmentsResponse { // The total number of items in the list. - int32 total_size = 1 [json_name = "total_size"]; + int32 total = 1 [json_name = "total"]; // The paging menus repeated api.v1.services.types.Department departments = 2 [json_name = "departments"]; - // The current page number. - int32 current = 3 [json_name = "current"]; + // The page number. + int32 page = 3 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 4 [json_name = "page_size"]; // Token to retrieve the next page of results, or empty if there are no // more results in the list. string next_page_token = 5 [json_name = "next_page_token"]; // Additional information about this response. - // content to be added without destroying the current data format + // content to be added without destroying the page data format optional google.protobuf.Any extra = 6 [json_name = "extra"]; } diff --git a/api/v1/proto/system/menu.proto b/api/v1/proto/system/menu.proto index a935cd0f..9214370b 100644 --- a/api/v1/proto/system/menu.proto +++ b/api/v1/proto/system/menu.proto @@ -42,8 +42,8 @@ service MenuService { message ListMenusRequest { // The parent resource id, for example, "shelves/shelf1". int64 id = 1; - // The current page number. - int32 current = 2; + // The page number. + int32 page = 2; // The maximum number of items to return. int32 page_size = 3; // The next_page_token value returned from a previous List request, if any. @@ -57,18 +57,18 @@ message ListMenusRequest { // ListMenusResponse is the response for the MenuService.ListMenus method. message ListMenusResponse { // The total number of items in the list. - int32 total_size = 1 [json_name = "total_size"]; + int32 total = 1 [json_name = "total"]; // The paging menus repeated api.v1.services.types.Menu menus = 2 [json_name = "menus"]; - // The current page number. - int32 current = 3 [json_name = "current"]; + // The page number. + int32 page = 3 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 4 [json_name = "page_size"]; // Token to retrieve the next page of results, or empty if there are no // more results in the list. string next_page_token = 5 [json_name = "next_page_token"]; // Additional information about this response. - // content to be added without destroying the current data format + // content to be added without destroying the page data format optional google.protobuf.Any extra = 6 [json_name = "extra"]; } diff --git a/api/v1/proto/system/permission.proto b/api/v1/proto/system/permission.proto index c0e3c594..767232a8 100644 --- a/api/v1/proto/system/permission.proto +++ b/api/v1/proto/system/permission.proto @@ -41,7 +41,7 @@ service PermissionService { message ListPermissionsRequest { // The parent resource id, for example, "shelves/shelf1". int64 id = 1 [json_name = "id"]; - // The page page number. + // The page number. int32 page = 2 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 3 [json_name = "page_size"]; @@ -60,7 +60,7 @@ message ListPermissionsResponse { int32 total = 1 [json_name = "total"]; // The paging menus repeated api.v1.services.types.Permission permissions = 2 [json_name = "permissions"]; - // The page page number. + // The page number. int32 page = 3 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 4 [json_name = "page_size"]; diff --git a/api/v1/proto/system/position.proto b/api/v1/proto/system/position.proto index 9c708d12..e67ab7d7 100644 --- a/api/v1/proto/system/position.proto +++ b/api/v1/proto/system/position.proto @@ -41,8 +41,8 @@ service PositionService { message ListPositionsRequest { // The parent resource id, for example, "shelves/shelf1". int64 id = 1 [json_name = "id"]; - // The current page number. - int32 current = 2 [json_name = "current"]; + // The page number. + int32 page = 2 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 3 [json_name = "page_size"]; // The next_page_token value returned from a previous List request, if any. @@ -55,18 +55,18 @@ message ListPositionsRequest { message ListPositionsResponse { // The total number of items in the list. - int32 total_size = 1 [json_name = "total_size"]; + int32 total = 1 [json_name = "total"]; // The paging menus repeated api.v1.services.types.Position positions = 2 [json_name = "positions"]; - // The current page number. - int32 current = 3 [json_name = "current"]; + // The page number. + int32 page = 3 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 4 [json_name = "page_size"]; // Token to retrieve the next page of results, or empty if there are no // more results in the list. string next_page_token = 5 [json_name = "next_page_token"]; // Additional information about this response. - // content to be added without destroying the current data format + // content to be added without destroying the page data format optional google.protobuf.Any extra = 6 [json_name = "extra"]; } diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index d26aa42f..762457a0 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -42,8 +42,8 @@ service ResourceService { message ListResourcesRequest { // The parent resource id, for example, "shelves/shelf1". int64 id = 1 [json_name = "id"]; - // The current page number. - int32 current = 2 [json_name = "current"]; + // The page number. + int32 page = 2 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 3 [json_name = "page_size"]; // The next_page_token value returned from a previous List request, if any. @@ -59,18 +59,18 @@ message ListResourcesRequest { // ListResourcesResponse is the response for the ResourceService.ListResources method. message ListResourcesResponse { // The total number of items in the list. - int32 total_size = 1 [json_name = "total_size"]; + int32 total = 1 [json_name = "total"]; // The paging resources repeated api.v1.services.types.Resource resources = 2 [json_name = "resources"]; - // The current page number. - int32 current = 3 [json_name = "current"]; + // The page number. + int32 page = 3 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 4 [json_name = "page_size"]; // Token to retrieve the next page of results, or empty if there are no // more results in the list. string next_page_token = 5 [json_name = "next_page_token"]; // Additional information about this response. - // content to be added without destroying the current data format + // content to be added without destroying the page data format optional google.protobuf.Any extra = 6 [json_name = "extra"]; } diff --git a/api/v1/proto/system/role.proto b/api/v1/proto/system/role.proto index f1f3aa8b..6ae574be 100644 --- a/api/v1/proto/system/role.proto +++ b/api/v1/proto/system/role.proto @@ -41,8 +41,8 @@ service RoleService { message ListRolesRequest { // The parent resource id, for example, "shelves/shelf1". int64 id = 1 [json_name = "id"]; - // The current page number. - int32 current = 2 [json_name = "current"]; + // The page number. + int32 page = 2 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 3 [json_name = "page_size"]; // The next_page_token value returned from a previous List request, if any. @@ -55,18 +55,18 @@ message ListRolesRequest { message ListRolesResponse { // The total number of items in the list. - int32 total_size = 1 [json_name = "total_size"]; + int32 total = 1 [json_name = "total"]; // The paging menus repeated api.v1.services.types.Role roles = 2 [json_name = "roles"]; - // The current page number. - int32 current = 3 [json_name = "current"]; + // The page number. + int32 page = 3 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 4 [json_name = "page_size"]; // Token to retrieve the next page of results, or empty if there are no // more results in the list. string next_page_token = 5 [json_name = "next_page_token"]; // Additional information about this response. - // content to be added without destroying the current data format + // content to be added without destroying the page data format optional google.protobuf.Any extra = 6 [json_name = "extra"]; } diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index c09684f8..0398ef7d 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -71,7 +71,7 @@ message ListUserResourcesRequest { } message ListUserResourcesResponse { - int32 total_size = 1 [json_name = "total_size"]; + int32 total = 1 [json_name = "total"]; repeated api.v1.services.types.Resource resources = 2 [json_name = "resources"]; } @@ -91,8 +91,8 @@ message ResetUserPasswordResponse {} message ListUsersRequest { // The parent resource id, for example, "shelves/shelf1". int64 id = 1 [json_name = "id"]; - // The current page number. - int32 current = 2 [json_name = "current"]; + // The page number. + int32 page = 2 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 3 [json_name = "page_size"]; // The next_page_token value returned from a previous List request, if any. @@ -107,18 +107,18 @@ message ListUsersRequest { message ListUsersResponse { // The total number of items in the list. - int32 total_size = 1 [json_name = "total_size"]; + int32 total = 1 [json_name = "total"]; // The paging menus repeated api.v1.services.types.User users = 2 [json_name = "users"]; - // The current page number. - int32 current = 3 [json_name = "current"]; + // The page number. + int32 page = 3 [json_name = "page"]; // The maximum number of items to return. int32 page_size = 4 [json_name = "page_size"]; // Token to retrieve the next page of results, or empty if there are no // more results in the list. string next_page_token = 5 [json_name = "next_page_token"]; // Additional information about this response. - // content to be added without destroying the current data format + // content to be added without destroying the page data format optional google.protobuf.Any extra = 6 [json_name = "extra"]; } diff --git a/internal/features/system/service/service.go b/internal/features/system/service/service.go index 0e9601a8..305b6fe6 100644 --- a/internal/features/system/service/service.go +++ b/internal/features/system/service/service.go @@ -7,9 +7,10 @@ package service import ( "context" - "github.com/origadmin/runtime/service" + "github.com/go-kratos/kratos/v2/transport" - system "origadmin/application/admin/api/v1/system" + "github.com/origadmin/runtime/service" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/features/system/biz" ) @@ -39,7 +40,11 @@ func New( } } -func (s *SystemService) Register(ctx context.Context, srv *service.Server) { +func (s *SystemService) Register(ctx context.Context, srv any) { + switch srv.(type) { + case *transport.Server: + case *service.Server: + } system.RegisterResourceServiceServer(srv.GRPC, s) system.RegisterRoleServiceServer(srv.GRPC, s) system.RegisterUserServiceServer(srv.GRPC, s) diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index f33fbb82..64d0d457 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -1125,9 +1125,9 @@ paths: description: The parent resource id, for example, "shelves/shelf1". schema: type: string - - name: current + - name: page in: query - description: The current page number. + description: The page number. schema: type: integer format: int32 @@ -1298,9 +1298,9 @@ paths: description: The parent resource id, for example, "shelves/shelf1". schema: type: string - - name: current + - name: page in: query - description: The current page number. + description: The page number. schema: type: integer format: int32 @@ -1468,7 +1468,7 @@ paths: type: string - name: page in: query - description: The page page number. + description: The page number. schema: type: integer format: int32 @@ -1646,9 +1646,9 @@ paths: description: The parent resource id, for example, "shelves/shelf1". schema: type: string - - name: current + - name: page in: query - description: The current page number. + description: The page number. schema: type: integer format: int32 @@ -1819,9 +1819,9 @@ paths: description: The parent resource id, for example, "shelves/shelf1". schema: type: string - - name: current + - name: page in: query - description: The current page number. + description: The page number. schema: type: integer format: int32 @@ -1997,9 +1997,9 @@ paths: description: The parent resource id, for example, "shelves/shelf1". schema: type: string - - name: current + - name: page in: query - description: The current page number. + description: The page number. schema: type: integer format: int32 @@ -2170,9 +2170,9 @@ paths: description: The parent resource id, for example, "shelves/shelf1". schema: type: string - - name: current + - name: page in: query - description: The current page number. + description: The page number. schema: type: integer format: int32 @@ -3267,7 +3267,7 @@ components: api.v1.services.system.ListDepartmentsResponse: type: object properties: - total_size: + total: type: integer description: The total number of items in the list. format: int32 @@ -3276,9 +3276,9 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.Department' description: The paging menus - current: + page: type: integer - description: The current page number. + description: The page number. format: int32 page_size: type: integer @@ -3294,11 +3294,11 @@ components: - $ref: '#/components/schemas/google.protobuf.Any' description: |- Additional information about this response. - content to be added without destroying the current data format + content to be added without destroying the page data format api.v1.services.system.ListMenusResponse: type: object properties: - total_size: + total: type: integer description: The total number of items in the list. format: int32 @@ -3307,9 +3307,9 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.Menu' description: The paging menus - current: + page: type: integer - description: The current page number. + description: The page number. format: int32 page_size: type: integer @@ -3325,7 +3325,7 @@ components: - $ref: '#/components/schemas/google.protobuf.Any' description: |- Additional information about this response. - content to be added without destroying the current data format + content to be added without destroying the page data format description: ListMenusResponse is the response for the MenuService.ListMenus method. api.v1.services.system.ListPermissionsResponse: type: object @@ -3341,7 +3341,7 @@ components: description: The paging menus page: type: integer - description: The page page number. + description: The page number. format: int32 page_size: type: integer @@ -3361,7 +3361,7 @@ components: api.v1.services.system.ListPositionsResponse: type: object properties: - total_size: + total: type: integer description: The total number of items in the list. format: int32 @@ -3370,9 +3370,9 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.Position' description: The paging menus - current: + page: type: integer - description: The current page number. + description: The page number. format: int32 page_size: type: integer @@ -3388,11 +3388,11 @@ components: - $ref: '#/components/schemas/google.protobuf.Any' description: |- Additional information about this response. - content to be added without destroying the current data format + content to be added without destroying the page data format api.v1.services.system.ListResourcesResponse: type: object properties: - total_size: + total: type: integer description: The total number of items in the list. format: int32 @@ -3401,9 +3401,9 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.Resource' description: The paging resources - current: + page: type: integer - description: The current page number. + description: The page number. format: int32 page_size: type: integer @@ -3419,12 +3419,12 @@ components: - $ref: '#/components/schemas/google.protobuf.Any' description: |- Additional information about this response. - content to be added without destroying the current data format + content to be added without destroying the page data format description: ListResourcesResponse is the response for the ResourceService.ListResources method. api.v1.services.system.ListRolesResponse: type: object properties: - total_size: + total: type: integer description: The total number of items in the list. format: int32 @@ -3433,9 +3433,9 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.Role' description: The paging menus - current: + page: type: integer - description: The current page number. + description: The page number. format: int32 page_size: type: integer @@ -3451,11 +3451,11 @@ components: - $ref: '#/components/schemas/google.protobuf.Any' description: |- Additional information about this response. - content to be added without destroying the current data format + content to be added without destroying the page data format api.v1.services.system.ListUserResourcesResponse: type: object properties: - total_size: + total: type: integer format: int32 resources: @@ -3465,7 +3465,7 @@ components: api.v1.services.system.ListUsersResponse: type: object properties: - total_size: + total: type: integer description: The total number of items in the list. format: int32 @@ -3474,9 +3474,9 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.User' description: The paging menus - current: + page: type: integer - description: The current page number. + description: The page number. format: int32 page_size: type: integer @@ -3492,7 +3492,7 @@ components: - $ref: '#/components/schemas/google.protobuf.Any' description: |- Additional information about this response. - content to be added without destroying the current data format + content to be added without destroying the page data format api.v1.services.system.ResetUserPasswordResponse: type: object properties: {} From bb0b88144e5fe23ad9fc6f96b4e4d28e2bc3f68a Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 24 Dec 2025 05:47:01 +0800 Subject: [PATCH 070/158] feat(user): add password field to CreateUserRequest and refactor wire dependencies --- Makefile | 2 +- api/v1/proto/system/user.proto | 8 +- cmd/system/main.go | 24 +- cmd/system/wire.go | 37 ++- cmd/system/wire_gen.go | 13 +- go.mod | 6 +- internal/conf/config.go | 37 +-- internal/conf/pb/captcha.pb.go | 52 ++-- internal/conf/pb/captcha.pb.validate.go | 2 +- internal/conf/pb/conf.pb.go | 169 +++++++++---- internal/conf/pb/conf.pb.validate.go | 120 +++++++++- internal/conf/pb/conf.proto | 28 +-- internal/conf/pb/root.pb.go | 52 ++-- internal/conf/pb/root.pb.validate.go | 2 +- internal/data/data.go | 3 +- internal/features/system/biz/biz.go | 2 +- internal/features/system/biz/permission.go | 1 + internal/features/system/biz/resource.go | 1 + internal/features/system/biz/role.go | 1 + internal/features/system/biz/user.go | 19 +- internal/features/system/dal/README.md | 3 - internal/features/system/dal/dal.go | 5 - internal/features/system/dal/menu.dal.go | 186 -------------- .../features/system/dal/permission.dal.go | 172 ------------- internal/features/system/dal/provider.go | 48 ---- internal/features/system/dal/resource.dal.go | 152 ------------ internal/features/system/dal/role.dal.go | 180 -------------- internal/features/system/dal/user.dal.go | 226 ------------------ internal/features/system/data/data.go | 2 +- internal/features/system/data/permission.go | 15 +- internal/features/system/data/provider.go | 14 -- internal/features/system/data/resource.go | 21 +- internal/features/system/data/role.go | 31 ++- internal/features/system/data/user.go | 39 ++- internal/features/system/dto/dto.gen.go | 44 ++-- internal/features/system/server/gins.go | 67 ------ internal/features/system/server/grpc.go | 27 --- internal/features/system/server/http.go | 27 --- internal/features/system/server/server.go | 190 ++++++--------- internal/features/system/service/dto.go | 126 ---------- .../features/system/service/permission.go | 8 +- internal/features/system/service/resource.go | 8 +- internal/features/system/service/role.go | 10 +- internal/features/system/service/service.go | 21 -- internal/features/system/service/user.go | 10 +- resources/docs/openapi/openapi.yaml | 5 + 46 files changed, 560 insertions(+), 1656 deletions(-) delete mode 100644 internal/features/system/dal/README.md delete mode 100644 internal/features/system/dal/dal.go delete mode 100644 internal/features/system/dal/menu.dal.go delete mode 100644 internal/features/system/dal/permission.dal.go delete mode 100644 internal/features/system/dal/provider.go delete mode 100644 internal/features/system/dal/resource.dal.go delete mode 100644 internal/features/system/dal/role.dal.go delete mode 100644 internal/features/system/dal/user.dal.go delete mode 100644 internal/features/system/server/gins.go delete mode 100644 internal/features/system/server/grpc.go delete mode 100644 internal/features/system/server/http.go delete mode 100644 internal/features/system/service/dto.go diff --git a/Makefile b/Makefile index 69bf7c7e..44a7a4ff 100644 --- a/Makefile +++ b/Makefile @@ -159,7 +159,7 @@ gen: @protoc -I. -I./third_party --go_out=paths=source_relative:. ./helpers/resp/data/v1/*.proto @echo "Generating Protobuf code for conf/pb..." - @protoc -I. -I./third_party --go_out=paths=source_relative:./internal --validate_out=paths=source_relative,lang=go:./internal ./conf/pb/*.proto + @protoc -I. -I./third_party --go_out=paths=source_relative:./internal --validate_out=paths=source_relative,lang=go:./internal ./internal/conf/pb/*.proto go generate ./internal/data/entity/ent/generate.go go generate ./cmd/system diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index 0398ef7d..b972e29f 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -137,12 +137,14 @@ message CreateUserRequest { string parent = 1; // The user resource to be created. api.v1.services.types.User user = 2; + // The password to use for this user. + string password = 3 [json_name = "password"]; // The user id to use for this user. - string user_id = 3 [json_name = "user_id"]; + string user_id = 4 [json_name = "user_id"]; // The user is_system to use for this user. - bool is_system = 4 [json_name = "is_system"]; + bool is_system = 5 [json_name = "is_system"]; // The random_password is the query parameter for set only to generate a random password - bool random_password = 5 [json_name = "random_password"]; + bool random_password = 6 [json_name = "random_password"]; } message CreateUserResponse { diff --git a/cmd/system/main.go b/cmd/system/main.go index b83fad24..1c2220bb 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -6,7 +6,6 @@ package main import ( "flag" - "log" "github.com/go-kratos/kratos/v2" "github.com/go-kratos/kratos/v2/transport" @@ -17,7 +16,8 @@ import ( _ "github.com/origadmin/contrib/registry/consul" "github.com/origadmin/runtime" runtimebootstrap "github.com/origadmin/runtime/bootstrap" - "origadmin/application/admin/internal/conf" // Corrected import path + "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/conf" confhelper "origadmin/application/admin/internal/helpers/conf" ) @@ -37,13 +37,13 @@ func init() { flag.StringVar(&flagconf, "conf", "", "config path, eg: -conf bootstrap.yaml") } -func NewApp(r *runtime.App, servers ...transport.Server) *kratos.App { // Changed runtime.Runtime to *runtime.App +func NewApp(logger log.Logger, appInfo *runtime.AppInfo, servers []transport.Server) *kratos.App { return kratos.New( - kratos.ID(r.AppInfo().ID()), - kratos.Name(r.AppInfo().Name()), - kratos.Version(r.AppInfo().Version()), - kratos.Metadata(r.AppInfo().Metadata()), - kratos.Logger(r.Logger()), + kratos.ID(appInfo.ID()), + kratos.Name(appInfo.Name()), + kratos.Version(appInfo.Version()), + kratos.Metadata(appInfo.Metadata()), + kratos.Logger(logger), kratos.Server( servers..., ), @@ -63,7 +63,7 @@ func main() { } // Log the config path for debugging - log.Printf("Loading configuration from: %s\n", confPath) + log.Infof("Loading configuration from: %s\n", confPath) // NewFromBootstrap handles config loading, logging, and container setup. rt := runtime.New(Name, Version) @@ -72,16 +72,16 @@ func main() { log.Fatalf("failed to create runtime: %v", err) } defer rt.Config().Close() - log.Printf("Starting %s %s (ID: %s)\n", rt.AppInfo().Name(), rt.AppInfo().Version(), rt.AppInfo().ID()) + log.Infof("Starting %s %s (ID: %s)\n", rt.AppInfo().Name(), rt.AppInfo().Version(), rt.AppInfo().ID()) // Get bootstrap config - bootstrapConfig, ok := rt.StructuredConfig().(*conf.Config) // Changed *configs.Bootstrap to *conf.Config + bootstrapConfig, ok := rt.StructuredConfig().(*conf.Config) if !ok { log.Fatalf("failed to get bootstrap config") } // wireApp now takes the runtime instance and builds the kratos app. - app, cleanupApp, err := wireApp(rt, bootstrapConfig) // Pass bootstrapConfig + app, cleanupApp, err := wireApp(rt, bootstrapConfig) if err != nil { log.Fatalf("failed to wire app: %v", err) } diff --git a/cmd/system/wire.go b/cmd/system/wire.go index c5a8c3b1..256578f0 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -11,27 +11,40 @@ package main import ( "github.com/go-kratos/kratos/v2" "github.com/google/wire" - "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/crypto/hash" + "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" + "github.com/origadmin/toolkits/crypto/hash/types" "origadmin/application/admin/internal/conf" - "origadmin/application/admin/internal/data" // Added missing import for data package - systembiz "origadmin/application/admin/internal/features/system/biz" - systemdal "origadmin/application/admin/internal/features/system/dal" - systemserver "origadmin/application/admin/internal/features/system/server" - systemservice "origadmin/application/admin/internal/features/system/service" + confpb "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/features/system/biz" + "origadmin/application/admin/internal/features/system/data" + "origadmin/application/admin/internal/features/system/server" + "origadmin/application/admin/internal/features/system/service" ) +func provideLogger(r *runtime.App) log.Logger { + return r.Logger() +} + +func provideHasher() (hash.Crypto, error) { + return hash.NewCrypto(types.BCRYPT, bcrypt.WithCost(10)) +} + // wireApp init kratos application. func wireApp(r *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { panic(wire.Build( - //loader.ProviderSet, // Uncomment if loader.ProviderSet is needed + provideLogger, + provideHasher, + wire.FieldsOf(new(*runtime.App), "AppInfo"), + wire.FieldsOf(new(*conf.Config), "Bootstrap"), + wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), data.ProviderSet, - systemdal.ProviderSet, - systembiz.ProviderSet, - systemservice.ProviderSet, - systemserver.ProviderSet, - /* add your providers here */ + biz.ProviderSet, + service.ProviderSet, + server.ProviderSet, NewApp, )) } diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index f8f7962c..29d1e6b9 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -7,26 +7,19 @@ package main import ( - _ "origadmin/application/admin/contrib/consul/config" - _ "origadmin/application/admin/contrib/consul/registry" - _ "origadmin/application/admin/contrib/database" - "github.com/go-kratos/kratos/v2" - "github.com/origadmin/runtime" - confpb "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/data" - _ "origadmin/application/admin/internal/data/entity/ent/runtime" "origadmin/application/admin/internal/features/system/biz" - "origadmin/application/admin/internal/features/system/dal" "origadmin/application/admin/internal/features/system/server" "origadmin/application/admin/internal/features/system/service" ) // Injectors from wire.go: -// buildInjectors init kratos application. -func buildInjectors(r *runtime.App, bootstrap *confpb.Bootstrap) (*kratos.App, func(), error) { +// wireApp init kratos application. +func wireApp(r *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { dataData, cleanup, err := data.NewData(r, bootstrap) if err != nil { return nil, nil, err diff --git a/go.mod b/go.mod index aedc9f5a..716a0199 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,10 @@ replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0 replace github.com/origadmin/toolkits/i18n v0.0.0 => ../../toolkits/i18n +replace github.com/origadmin/runtime v0.2.13 => ../../runtime + +replace github.com/origadmin/contrib v1.1.0 => ../../contrib + require ( entgo.io/ent v0.14.5 github.com/casbin/casbin/v2 v2.134.0 @@ -19,6 +23,7 @@ require ( github.com/gorilla/handlers v1.5.2 github.com/mattn/go-sqlite3 v1.14.28 // indirect github.com/mojocn/base64Captcha v1.3.8 + github.com/origadmin/contrib v1.1.0 github.com/origadmin/entslog/v3 v3.1.0 github.com/origadmin/runtime v0.2.13 github.com/origadmin/slog-kratos v1.0.5 // indirect @@ -136,7 +141,6 @@ require ( github.com/ncruces/go-strftime v0.1.9 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect - github.com/origadmin/contrib v1.1.0 // indirect github.com/origadmin/toolkits/slogx v1.1.0 // indirect github.com/petermattis/goid v0.0.0-20250904145737-900bdf8bb490 // indirect github.com/pkg/errors v0.9.1 // indirect diff --git a/internal/conf/config.go b/internal/conf/config.go index 1d9e95ca..223d230c 100644 --- a/internal/conf/config.go +++ b/internal/conf/config.go @@ -7,69 +7,68 @@ import ( loggerv1 "github.com/origadmin/runtime/api/gen/go/config/logger/v1" middlewarev1 "github.com/origadmin/runtime/api/gen/go/config/middleware/v1" transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" - "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/interfaces" confpb "origadmin/application/admin/internal/conf/pb" ) type Config struct { - bootstrap confpb.Bootstrap + Bootstrap confpb.Bootstrap } func (c *Config) DecodeData() (*datav1.Data, error) { - return c.bootstrap.GetData(), nil + return c.Bootstrap.GetData(), nil } func (c *Config) DecodeCaches() (*datav1.Caches, error) { - return c.bootstrap.GetData().GetCaches(), nil + return c.Bootstrap.GetData().GetCaches(), nil } func (c *Config) DecodeDatabases() (*datav1.Databases, error) { - return c.bootstrap.GetData().GetDatabases(), nil + return c.Bootstrap.GetData().GetDatabases(), nil } func (c *Config) DecodeObjectStores() (*datav1.ObjectStores, error) { - return c.bootstrap.GetData().GetObjectStores(), nil + return c.Bootstrap.GetData().GetObjectStores(), nil } func (c *Config) DecodeDefaultDiscovery() (string, error) { - return c.bootstrap.GetDefaultDiscovery(), nil + return c.Bootstrap.GetDefaultDiscovery(), nil } func (c *Config) DecodeDiscoveries() (*discoveryv1.Discoveries, error) { - return c.bootstrap.GetDiscoveries(), nil + return c.Bootstrap.GetDiscoveries(), nil } func (c *Config) DecodeLogger() (*loggerv1.Logger, error) { - return c.bootstrap.GetLogger(), nil + return c.Bootstrap.GetLogger(), nil } func (c *Config) DecodeMiddlewares() (*middlewarev1.Middlewares, error) { - return c.bootstrap.GetMiddlewares(), nil + return c.Bootstrap.GetMiddlewares(), nil } func (c *Config) DecodeServers() (*transportv1.Servers, error) { - return c.bootstrap.GetServers(), nil + return c.Bootstrap.GetServers(), nil } func (c *Config) DecodeClients() (*transportv1.Clients, error) { - return c.bootstrap.GetClients(), nil + return c.Bootstrap.GetClients(), nil } func (c *Config) GetCaptcha() (*confpb.Captcha, error) { - return c.bootstrap.GetCaptcha(), nil + return c.Bootstrap.GetCaptcha(), nil } func (c *Config) GetRootUser() (*confpb.RootUser, error) { - return c.bootstrap.GetRootUser(), nil + return c.Bootstrap.GetRootUser(), nil } func (c *Config) GetBootstrap() *confpb.Bootstrap { - return &c.bootstrap + return &c.Bootstrap } func (c *Config) DecodedConfig() any { - return &c.bootstrap + return &c.Bootstrap } func (c *Config) Transform(config interfaces.Config, config2 interfaces.StructuredConfig) (interfaces. @@ -77,6 +76,8 @@ StructuredConfig, error) { return c, nil } -func New() bootstrap.ConfigTransformer { - return &Config{} +func New() Bootstrap.ConfigTransformer { + return &Config{ + Bootstrap: new(confpb.Bootstrap), + } } diff --git a/internal/conf/pb/captcha.pb.go b/internal/conf/pb/captcha.pb.go index 7a5ad4a7..931f4ec7 100644 --- a/internal/conf/pb/captcha.pb.go +++ b/internal/conf/pb/captcha.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.36.10 // protoc v5.28.3 -// source: conf/pb/captcha.proto +// source: internal/conf/pb/captcha.proto package confpb @@ -35,7 +35,7 @@ type Captcha struct { func (x *Captcha) Reset() { *x = Captcha{} - mi := &file_conf_pb_captcha_proto_msgTypes[0] + mi := &file_internal_conf_pb_captcha_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -47,7 +47,7 @@ func (x *Captcha) String() string { func (*Captcha) ProtoMessage() {} func (x *Captcha) ProtoReflect() protoreflect.Message { - mi := &file_conf_pb_captcha_proto_msgTypes[0] + mi := &file_internal_conf_pb_captcha_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -60,7 +60,7 @@ func (x *Captcha) ProtoReflect() protoreflect.Message { // Deprecated: Use Captcha.ProtoReflect.Descriptor instead. func (*Captcha) Descriptor() ([]byte, []int) { - return file_conf_pb_captcha_proto_rawDescGZIP(), []int{0} + return file_internal_conf_pb_captcha_proto_rawDescGZIP(), []int{0} } func (x *Captcha) GetLength() int32 { @@ -98,11 +98,11 @@ func (x *Captcha) GetCaches() *v1.Caches { return nil } -var File_conf_pb_captcha_proto protoreflect.FileDescriptor +var File_internal_conf_pb_captcha_proto protoreflect.FileDescriptor -const file_conf_pb_captcha_proto_rawDesc = "" + +const file_internal_conf_pb_captcha_proto_rawDesc = "" + "\n" + - "\x15conf/pb/captcha.proto\x12\aconf.pb\x1a\x19config/data/v1/data.proto\"\xab\x01\n" + + "\x1einternal/conf/pb/captcha.proto\x12\aconf.pb\x1a\x19config/data/v1/data.proto\"\xab\x01\n" + "\aCaptcha\x12\x16\n" + "\x06length\x18\x01 \x01(\x05R\x06length\x12\x14\n" + "\x05width\x18\x02 \x01(\x05R\x05width\x12\x16\n" + @@ -113,23 +113,23 @@ const file_conf_pb_captcha_proto_rawDesc = "" + "\x06caches\x18\x05 \x01(\v2\".runtime.api.config.data.v1.CachesR\x06cachesB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" var ( - file_conf_pb_captcha_proto_rawDescOnce sync.Once - file_conf_pb_captcha_proto_rawDescData []byte + file_internal_conf_pb_captcha_proto_rawDescOnce sync.Once + file_internal_conf_pb_captcha_proto_rawDescData []byte ) -func file_conf_pb_captcha_proto_rawDescGZIP() []byte { - file_conf_pb_captcha_proto_rawDescOnce.Do(func() { - file_conf_pb_captcha_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_conf_pb_captcha_proto_rawDesc), len(file_conf_pb_captcha_proto_rawDesc))) +func file_internal_conf_pb_captcha_proto_rawDescGZIP() []byte { + file_internal_conf_pb_captcha_proto_rawDescOnce.Do(func() { + file_internal_conf_pb_captcha_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_internal_conf_pb_captcha_proto_rawDesc), len(file_internal_conf_pb_captcha_proto_rawDesc))) }) - return file_conf_pb_captcha_proto_rawDescData + return file_internal_conf_pb_captcha_proto_rawDescData } -var file_conf_pb_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_conf_pb_captcha_proto_goTypes = []any{ +var file_internal_conf_pb_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_internal_conf_pb_captcha_proto_goTypes = []any{ (*Captcha)(nil), // 0: conf.pb.Captcha (*v1.Caches)(nil), // 1: runtime.api.config.data.v1.Caches } -var file_conf_pb_captcha_proto_depIdxs = []int32{ +var file_internal_conf_pb_captcha_proto_depIdxs = []int32{ 1, // 0: conf.pb.Captcha.caches:type_name -> runtime.api.config.data.v1.Caches 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type @@ -138,26 +138,26 @@ var file_conf_pb_captcha_proto_depIdxs = []int32{ 0, // [0:1] is the sub-list for field type_name } -func init() { file_conf_pb_captcha_proto_init() } -func file_conf_pb_captcha_proto_init() { - if File_conf_pb_captcha_proto != nil { +func init() { file_internal_conf_pb_captcha_proto_init() } +func file_internal_conf_pb_captcha_proto_init() { + if File_internal_conf_pb_captcha_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_conf_pb_captcha_proto_rawDesc), len(file_conf_pb_captcha_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_conf_pb_captcha_proto_rawDesc), len(file_internal_conf_pb_captcha_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_conf_pb_captcha_proto_goTypes, - DependencyIndexes: file_conf_pb_captcha_proto_depIdxs, - MessageInfos: file_conf_pb_captcha_proto_msgTypes, + GoTypes: file_internal_conf_pb_captcha_proto_goTypes, + DependencyIndexes: file_internal_conf_pb_captcha_proto_depIdxs, + MessageInfos: file_internal_conf_pb_captcha_proto_msgTypes, }.Build() - File_conf_pb_captcha_proto = out.File - file_conf_pb_captcha_proto_goTypes = nil - file_conf_pb_captcha_proto_depIdxs = nil + File_internal_conf_pb_captcha_proto = out.File + file_internal_conf_pb_captcha_proto_goTypes = nil + file_internal_conf_pb_captcha_proto_depIdxs = nil } diff --git a/internal/conf/pb/captcha.pb.validate.go b/internal/conf/pb/captcha.pb.validate.go index 865dd313..df99a14e 100644 --- a/internal/conf/pb/captcha.pb.validate.go +++ b/internal/conf/pb/captcha.pb.validate.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: conf/pb/captcha.proto +// source: internal/conf/pb/captcha.proto package confpb diff --git a/internal/conf/pb/conf.pb.go b/internal/conf/pb/conf.pb.go index b74213c3..42ae72e6 100644 --- a/internal/conf/pb/conf.pb.go +++ b/internal/conf/pb/conf.pb.go @@ -2,11 +2,15 @@ // versions: // protoc-gen-go v1.36.10 // protoc v5.28.3 -// source: conf/pb/conf.proto +// source: internal/conf/pb/conf.proto package confpb import ( + v11 "github.com/origadmin/runtime/api/gen/go/config/data/v1" + v12 "github.com/origadmin/runtime/api/gen/go/config/discovery/v1" + v13 "github.com/origadmin/runtime/api/gen/go/config/logger/v1" + v14 "github.com/origadmin/runtime/api/gen/go/config/middleware/v1" v1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -31,17 +35,27 @@ type Bootstrap struct { Clients *v1.Clients `protobuf:"bytes,2,opt,name=clients,proto3" json:"clients,omitempty"` // Global-level configurations can be placed here. SelectorGlobal *SelectorGlobal `protobuf:"bytes,3,opt,name=selector_global,json=selectorGlobal,proto3" json:"selector_global,omitempty"` + // Data configuration, including databases, caches, and object stores. + Data *v11.Data `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"` + // Discovery configuration for service discovery. + Discoveries *v12.Discoveries `protobuf:"bytes,5,opt,name=discoveries,proto3" json:"discoveries,omitempty"` + // Logger configuration for application logging. + Logger *v13.Logger `protobuf:"bytes,6,opt,name=logger,proto3" json:"logger,omitempty"` + // Middleware configuration for request processing. + Middlewares *v14.Middlewares `protobuf:"bytes,7,opt,name=middlewares,proto3" json:"middlewares,omitempty"` // Captcha feature specific configuration. - Captcha *Captcha `protobuf:"bytes,4,opt,name=captcha,proto3" json:"captcha,omitempty"` + Captcha *Captcha `protobuf:"bytes,8,opt,name=captcha,proto3" json:"captcha,omitempty"` // RootUser feature specific configuration for initial user setup. - RootUser *RootUser `protobuf:"bytes,5,opt,name=root_user,json=rootUser,proto3" json:"root_user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + RootUser *RootUser `protobuf:"bytes,9,opt,name=root_user,json=rootUser,proto3" json:"root_user,omitempty"` + // Default discovery service name. + DefaultDiscovery string `protobuf:"bytes,10,opt,name=default_discovery,json=defaultDiscovery,proto3" json:"default_discovery,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Bootstrap) Reset() { *x = Bootstrap{} - mi := &file_conf_pb_conf_proto_msgTypes[0] + mi := &file_internal_conf_pb_conf_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -53,7 +67,7 @@ func (x *Bootstrap) String() string { func (*Bootstrap) ProtoMessage() {} func (x *Bootstrap) ProtoReflect() protoreflect.Message { - mi := &file_conf_pb_conf_proto_msgTypes[0] + mi := &file_internal_conf_pb_conf_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -66,7 +80,7 @@ func (x *Bootstrap) ProtoReflect() protoreflect.Message { // Deprecated: Use Bootstrap.ProtoReflect.Descriptor instead. func (*Bootstrap) Descriptor() ([]byte, []int) { - return file_conf_pb_conf_proto_rawDescGZIP(), []int{0} + return file_internal_conf_pb_conf_proto_rawDescGZIP(), []int{0} } func (x *Bootstrap) GetServers() *v1.Servers { @@ -90,6 +104,34 @@ func (x *Bootstrap) GetSelectorGlobal() *SelectorGlobal { return nil } +func (x *Bootstrap) GetData() *v11.Data { + if x != nil { + return x.Data + } + return nil +} + +func (x *Bootstrap) GetDiscoveries() *v12.Discoveries { + if x != nil { + return x.Discoveries + } + return nil +} + +func (x *Bootstrap) GetLogger() *v13.Logger { + if x != nil { + return x.Logger + } + return nil +} + +func (x *Bootstrap) GetMiddlewares() *v14.Middlewares { + if x != nil { + return x.Middlewares + } + return nil +} + func (x *Bootstrap) GetCaptcha() *Captcha { if x != nil { return x.Captcha @@ -104,6 +146,13 @@ func (x *Bootstrap) GetRootUser() *RootUser { return nil } +func (x *Bootstrap) GetDefaultDiscovery() string { + if x != nil { + return x.DefaultDiscovery + } + return "" +} + // SelectorGlobal defines the global selector/load-balancing strategy. type SelectorGlobal struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -115,7 +164,7 @@ type SelectorGlobal struct { func (x *SelectorGlobal) Reset() { *x = SelectorGlobal{} - mi := &file_conf_pb_conf_proto_msgTypes[1] + mi := &file_internal_conf_pb_conf_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -127,7 +176,7 @@ func (x *SelectorGlobal) String() string { func (*SelectorGlobal) ProtoMessage() {} func (x *SelectorGlobal) ProtoReflect() protoreflect.Message { - mi := &file_conf_pb_conf_proto_msgTypes[1] + mi := &file_internal_conf_pb_conf_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -140,7 +189,7 @@ func (x *SelectorGlobal) ProtoReflect() protoreflect.Message { // Deprecated: Use SelectorGlobal.ProtoReflect.Descriptor instead. func (*SelectorGlobal) Descriptor() ([]byte, []int) { - return file_conf_pb_conf_proto_rawDescGZIP(), []int{1} + return file_internal_conf_pb_conf_proto_rawDescGZIP(), []int{1} } func (x *SelectorGlobal) GetBuilder() string { @@ -150,76 +199,90 @@ func (x *SelectorGlobal) GetBuilder() string { return "" } -var File_conf_pb_conf_proto protoreflect.FileDescriptor +var File_internal_conf_pb_conf_proto protoreflect.FileDescriptor -const file_conf_pb_conf_proto_rawDesc = "" + +const file_internal_conf_pb_conf_proto_rawDesc = "" + "\n" + - "\x12conf/pb/conf.proto\x12\aconf.pb\x1a#config/transport/v1/transport.proto\x1a\x15conf/pb/captcha.proto\x1a\x12conf/pb/root.proto\"\xb1\x02\n" + + "\x1binternal/conf/pb/conf.proto\x12\aconf.pb\x1a\x19config/data/v1/data.proto\x1a#config/discovery/v1/discovery.proto\x1a\x1dconfig/logger/v1/logger.proto\x1a%config/middleware/v1/middleware.proto\x1a#config/transport/v1/transport.proto\x1a\x1einternal/conf/pb/captcha.proto\x1a\x1binternal/conf/pb/root.proto\"\xf3\x04\n" + "\tBootstrap\x12B\n" + "\aservers\x18\x01 \x01(\v2(.runtime.api.config.transport.v1.ServersR\aservers\x12B\n" + "\aclients\x18\x02 \x01(\v2(.runtime.api.config.transport.v1.ClientsR\aclients\x12@\n" + - "\x0fselector_global\x18\x03 \x01(\v2\x17.conf.pb.SelectorGlobalR\x0eselectorGlobal\x12*\n" + - "\acaptcha\x18\x04 \x01(\v2\x10.conf.pb.CaptchaR\acaptcha\x12.\n" + - "\troot_user\x18\x05 \x01(\v2\x11.conf.pb.RootUserR\brootUser\"*\n" + + "\x0fselector_global\x18\x03 \x01(\v2\x17.conf.pb.SelectorGlobalR\x0eselectorGlobal\x124\n" + + "\x04data\x18\x04 \x01(\v2 .runtime.api.config.data.v1.DataR\x04data\x12N\n" + + "\vdiscoveries\x18\x05 \x01(\v2,.runtime.api.config.discovery.v1.DiscoveriesR\vdiscoveries\x12<\n" + + "\x06logger\x18\x06 \x01(\v2$.runtime.api.config.logger.v1.LoggerR\x06logger\x12O\n" + + "\vmiddlewares\x18\a \x01(\v2-.runtime.api.config.middleware.v1.MiddlewaresR\vmiddlewares\x12*\n" + + "\acaptcha\x18\b \x01(\v2\x10.conf.pb.CaptchaR\acaptcha\x12.\n" + + "\troot_user\x18\t \x01(\v2\x11.conf.pb.RootUserR\brootUser\x12+\n" + + "\x11default_discovery\x18\n" + + " \x01(\tR\x10defaultDiscovery\"*\n" + "\x0eSelectorGlobal\x12\x18\n" + "\abuilder\x18\x01 \x01(\tR\abuilderB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" var ( - file_conf_pb_conf_proto_rawDescOnce sync.Once - file_conf_pb_conf_proto_rawDescData []byte + file_internal_conf_pb_conf_proto_rawDescOnce sync.Once + file_internal_conf_pb_conf_proto_rawDescData []byte ) -func file_conf_pb_conf_proto_rawDescGZIP() []byte { - file_conf_pb_conf_proto_rawDescOnce.Do(func() { - file_conf_pb_conf_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_conf_pb_conf_proto_rawDesc), len(file_conf_pb_conf_proto_rawDesc))) +func file_internal_conf_pb_conf_proto_rawDescGZIP() []byte { + file_internal_conf_pb_conf_proto_rawDescOnce.Do(func() { + file_internal_conf_pb_conf_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_internal_conf_pb_conf_proto_rawDesc), len(file_internal_conf_pb_conf_proto_rawDesc))) }) - return file_conf_pb_conf_proto_rawDescData + return file_internal_conf_pb_conf_proto_rawDescData } -var file_conf_pb_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_conf_pb_conf_proto_goTypes = []any{ - (*Bootstrap)(nil), // 0: conf.pb.Bootstrap - (*SelectorGlobal)(nil), // 1: conf.pb.SelectorGlobal - (*v1.Servers)(nil), // 2: runtime.api.config.transport.v1.Servers - (*v1.Clients)(nil), // 3: runtime.api.config.transport.v1.Clients - (*Captcha)(nil), // 4: conf.pb.Captcha - (*RootUser)(nil), // 5: conf.pb.RootUser +var file_internal_conf_pb_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_internal_conf_pb_conf_proto_goTypes = []any{ + (*Bootstrap)(nil), // 0: conf.pb.Bootstrap + (*SelectorGlobal)(nil), // 1: conf.pb.SelectorGlobal + (*v1.Servers)(nil), // 2: runtime.api.config.transport.v1.Servers + (*v1.Clients)(nil), // 3: runtime.api.config.transport.v1.Clients + (*v11.Data)(nil), // 4: runtime.api.config.data.v1.Data + (*v12.Discoveries)(nil), // 5: runtime.api.config.discovery.v1.Discoveries + (*v13.Logger)(nil), // 6: runtime.api.config.logger.v1.Logger + (*v14.Middlewares)(nil), // 7: runtime.api.config.middleware.v1.Middlewares + (*Captcha)(nil), // 8: conf.pb.Captcha + (*RootUser)(nil), // 9: conf.pb.RootUser } -var file_conf_pb_conf_proto_depIdxs = []int32{ +var file_internal_conf_pb_conf_proto_depIdxs = []int32{ 2, // 0: conf.pb.Bootstrap.servers:type_name -> runtime.api.config.transport.v1.Servers 3, // 1: conf.pb.Bootstrap.clients:type_name -> runtime.api.config.transport.v1.Clients 1, // 2: conf.pb.Bootstrap.selector_global:type_name -> conf.pb.SelectorGlobal - 4, // 3: conf.pb.Bootstrap.captcha:type_name -> conf.pb.Captcha - 5, // 4: conf.pb.Bootstrap.root_user:type_name -> conf.pb.RootUser - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name -} - -func init() { file_conf_pb_conf_proto_init() } -func file_conf_pb_conf_proto_init() { - if File_conf_pb_conf_proto != nil { + 4, // 3: conf.pb.Bootstrap.data:type_name -> runtime.api.config.data.v1.Data + 5, // 4: conf.pb.Bootstrap.discoveries:type_name -> runtime.api.config.discovery.v1.Discoveries + 6, // 5: conf.pb.Bootstrap.logger:type_name -> runtime.api.config.logger.v1.Logger + 7, // 6: conf.pb.Bootstrap.middlewares:type_name -> runtime.api.config.middleware.v1.Middlewares + 8, // 7: conf.pb.Bootstrap.captcha:type_name -> conf.pb.Captcha + 9, // 8: conf.pb.Bootstrap.root_user:type_name -> conf.pb.RootUser + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_internal_conf_pb_conf_proto_init() } +func file_internal_conf_pb_conf_proto_init() { + if File_internal_conf_pb_conf_proto != nil { return } - file_conf_pb_captcha_proto_init() - file_conf_pb_root_proto_init() + file_internal_conf_pb_captcha_proto_init() + file_internal_conf_pb_root_proto_init() type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_conf_pb_conf_proto_rawDesc), len(file_conf_pb_conf_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_conf_pb_conf_proto_rawDesc), len(file_internal_conf_pb_conf_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_conf_pb_conf_proto_goTypes, - DependencyIndexes: file_conf_pb_conf_proto_depIdxs, - MessageInfos: file_conf_pb_conf_proto_msgTypes, + GoTypes: file_internal_conf_pb_conf_proto_goTypes, + DependencyIndexes: file_internal_conf_pb_conf_proto_depIdxs, + MessageInfos: file_internal_conf_pb_conf_proto_msgTypes, }.Build() - File_conf_pb_conf_proto = out.File - file_conf_pb_conf_proto_goTypes = nil - file_conf_pb_conf_proto_depIdxs = nil + File_internal_conf_pb_conf_proto = out.File + file_internal_conf_pb_conf_proto_goTypes = nil + file_internal_conf_pb_conf_proto_depIdxs = nil } diff --git a/internal/conf/pb/conf.pb.validate.go b/internal/conf/pb/conf.pb.validate.go index 4c64c27b..79a6dd58 100644 --- a/internal/conf/pb/conf.pb.validate.go +++ b/internal/conf/pb/conf.pb.validate.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: conf/pb/conf.proto +// source: internal/conf/pb/conf.proto package confpb @@ -144,6 +144,122 @@ func (m *Bootstrap) validate(all bool) error { } } + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetDiscoveries()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Discoveries", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Discoveries", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDiscoveries()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "Discoveries", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetLogger()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Logger", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Logger", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetLogger()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "Logger", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetMiddlewares()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Middlewares", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Middlewares", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMiddlewares()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "Middlewares", + reason: "embedded message failed validation", + cause: err, + } + } + } + if all { switch v := interface{}(m.GetCaptcha()).(type) { case interface{ ValidateAll() error }: @@ -202,6 +318,8 @@ func (m *Bootstrap) validate(all bool) error { } } + // no validation rules for DefaultDiscovery + if len(errors) > 0 { return BootstrapMultiError(errors) } diff --git a/internal/conf/pb/conf.proto b/internal/conf/pb/conf.proto index f4735e96..fc33e5e7 100644 --- a/internal/conf/pb/conf.proto +++ b/internal/conf/pb/conf.proto @@ -2,15 +2,15 @@ syntax = "proto3"; package conf.pb; -option go_package = "origadmin/application/admin/internal/conf/pb;confpb"; - import "config/data/v1/data.proto"; import "config/discovery/v1/discovery.proto"; import "config/logger/v1/logger.proto"; import "config/middleware/v1/middleware.proto"; import "config/transport/v1/transport.proto"; -import "conf/pb/captcha.proto"; -import "conf/pb/root.proto"; +import "internal/conf/pb/captcha.proto"; +import "internal/conf/pb/root.proto"; + +option go_package = "origadmin/application/admin/internal/conf/pb;confpb"; // Bootstrap is the top-level configuration structure for the application. message Bootstrap { @@ -23,23 +23,23 @@ message Bootstrap { // Global-level configurations can be placed here. SelectorGlobal selector_global = 3; - // Captcha feature specific configuration. - conf.pb.Captcha captcha = 4; - - // RootUser feature specific configuration for initial user setup. - conf.pb.RootUser root_user = 5; - // Data configuration, including databases, caches, and object stores. - runtime.api.config.data.v1.Data data = 6; + runtime.api.config.data.v1.Data data = 4; // Discovery configuration for service discovery. - runtime.api.config.discovery.v1.Discoveries discoveries = 7; + runtime.api.config.discovery.v1.Discoveries discoveries = 5; // Logger configuration for application logging. - runtime.api.config.logger.v1.Logger logger = 8; + runtime.api.config.logger.v1.Logger logger = 6; // Middleware configuration for request processing. - runtime.api.config.middleware.v1.Middlewares middlewares = 9; + runtime.api.config.middleware.v1.Middlewares middlewares = 7; + + // Captcha feature specific configuration. + conf.pb.Captcha captcha = 8; + + // RootUser feature specific configuration for initial user setup. + conf.pb.RootUser root_user = 9; // Default discovery service name. string default_discovery = 10; diff --git a/internal/conf/pb/root.pb.go b/internal/conf/pb/root.pb.go index c5ad0fe1..7842757c 100644 --- a/internal/conf/pb/root.pb.go +++ b/internal/conf/pb/root.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.36.10 // protoc v5.28.3 -// source: conf/pb/root.proto +// source: internal/conf/pb/root.proto package confpb @@ -43,7 +43,7 @@ type RootUser struct { func (x *RootUser) Reset() { *x = RootUser{} - mi := &file_conf_pb_root_proto_msgTypes[0] + mi := &file_internal_conf_pb_root_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -55,7 +55,7 @@ func (x *RootUser) String() string { func (*RootUser) ProtoMessage() {} func (x *RootUser) ProtoReflect() protoreflect.Message { - mi := &file_conf_pb_root_proto_msgTypes[0] + mi := &file_internal_conf_pb_root_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -68,7 +68,7 @@ func (x *RootUser) ProtoReflect() protoreflect.Message { // Deprecated: Use RootUser.ProtoReflect.Descriptor instead. func (*RootUser) Descriptor() ([]byte, []int) { - return file_conf_pb_root_proto_rawDescGZIP(), []int{0} + return file_internal_conf_pb_root_proto_rawDescGZIP(), []int{0} } func (x *RootUser) GetEnabled() bool { @@ -162,11 +162,11 @@ func (x *RootUser) GetRandomPassword() bool { return false } -var File_conf_pb_root_proto protoreflect.FileDescriptor +var File_internal_conf_pb_root_proto protoreflect.FileDescriptor -const file_conf_pb_root_proto_rawDesc = "" + +const file_internal_conf_pb_root_proto_rawDesc = "" + "\n" + - "\x12conf/pb/root.proto\x12\aconf.pb\x1a\x17validate/validate.proto\"\x8c\x03\n" + + "\x1binternal/conf/pb/root.proto\x12\aconf.pb\x1a\x17validate/validate.proto\"\x8c\x03\n" + "\bRootUser\x12\x18\n" + "\aenabled\x18\x01 \x01(\bR\aenabled\x12\x17\n" + "\x02id\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x02id\x12#\n" + @@ -184,22 +184,22 @@ const file_conf_pb_root_proto_rawDesc = "" + "\x0frandom_password\x18e \x01(\bR\x0frandom_passwordB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" var ( - file_conf_pb_root_proto_rawDescOnce sync.Once - file_conf_pb_root_proto_rawDescData []byte + file_internal_conf_pb_root_proto_rawDescOnce sync.Once + file_internal_conf_pb_root_proto_rawDescData []byte ) -func file_conf_pb_root_proto_rawDescGZIP() []byte { - file_conf_pb_root_proto_rawDescOnce.Do(func() { - file_conf_pb_root_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_conf_pb_root_proto_rawDesc), len(file_conf_pb_root_proto_rawDesc))) +func file_internal_conf_pb_root_proto_rawDescGZIP() []byte { + file_internal_conf_pb_root_proto_rawDescOnce.Do(func() { + file_internal_conf_pb_root_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_internal_conf_pb_root_proto_rawDesc), len(file_internal_conf_pb_root_proto_rawDesc))) }) - return file_conf_pb_root_proto_rawDescData + return file_internal_conf_pb_root_proto_rawDescData } -var file_conf_pb_root_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_conf_pb_root_proto_goTypes = []any{ +var file_internal_conf_pb_root_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_internal_conf_pb_root_proto_goTypes = []any{ (*RootUser)(nil), // 0: conf.pb.RootUser } -var file_conf_pb_root_proto_depIdxs = []int32{ +var file_internal_conf_pb_root_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -207,26 +207,26 @@ var file_conf_pb_root_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_conf_pb_root_proto_init() } -func file_conf_pb_root_proto_init() { - if File_conf_pb_root_proto != nil { +func init() { file_internal_conf_pb_root_proto_init() } +func file_internal_conf_pb_root_proto_init() { + if File_internal_conf_pb_root_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_conf_pb_root_proto_rawDesc), len(file_conf_pb_root_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_internal_conf_pb_root_proto_rawDesc), len(file_internal_conf_pb_root_proto_rawDesc)), NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_conf_pb_root_proto_goTypes, - DependencyIndexes: file_conf_pb_root_proto_depIdxs, - MessageInfos: file_conf_pb_root_proto_msgTypes, + GoTypes: file_internal_conf_pb_root_proto_goTypes, + DependencyIndexes: file_internal_conf_pb_root_proto_depIdxs, + MessageInfos: file_internal_conf_pb_root_proto_msgTypes, }.Build() - File_conf_pb_root_proto = out.File - file_conf_pb_root_proto_goTypes = nil - file_conf_pb_root_proto_depIdxs = nil + File_internal_conf_pb_root_proto = out.File + file_internal_conf_pb_root_proto_goTypes = nil + file_internal_conf_pb_root_proto_depIdxs = nil } diff --git a/internal/conf/pb/root.pb.validate.go b/internal/conf/pb/root.pb.validate.go index b49b77c9..63adc558 100644 --- a/internal/conf/pb/root.pb.validate.go +++ b/internal/conf/pb/root.pb.validate.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. -// source: conf/pb/root.proto +// source: internal/conf/pb/root.proto package confpb diff --git a/internal/data/data.go b/internal/data/data.go index e4965aa3..9562e3d3 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -18,6 +18,7 @@ import ( ifacestorage "github.com/origadmin/runtime/interfaces/storage" "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/data/entity/ent" ) @@ -34,7 +35,7 @@ type Data struct { } // NewData creates a new Data instance. -func NewData(rt *runtime.App) (*Data, func(), error) { +func NewData(rt *runtime.App, conf *conf.Config) (*Data, func(), error) { logHelper := log.NewHelper(rt.Logger()) provider, err := storage.New(rt.StructuredConfig()) diff --git a/internal/features/system/biz/biz.go b/internal/features/system/biz/biz.go index 91f64b75..73b39e02 100644 --- a/internal/features/system/biz/biz.go +++ b/internal/features/system/biz/biz.go @@ -7,7 +7,7 @@ package biz import ( "net/http" - "github.com/origadmin/toolkits/errors" + "github.com/origadmin/runtime/errors" ) var ( diff --git a/internal/features/system/biz/permission.go b/internal/features/system/biz/permission.go index 443b1410..e6d6b477 100644 --- a/internal/features/system/biz/permission.go +++ b/internal/features/system/biz/permission.go @@ -7,6 +7,7 @@ package biz import ( "context" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/features/system/dto" diff --git a/internal/features/system/biz/resource.go b/internal/features/system/biz/resource.go index 76f7b593..f8c2bb96 100644 --- a/internal/features/system/biz/resource.go +++ b/internal/features/system/biz/resource.go @@ -7,6 +7,7 @@ package biz import ( "context" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/features/system/dto" diff --git a/internal/features/system/biz/role.go b/internal/features/system/biz/role.go index 01b48a73..913a73b2 100644 --- a/internal/features/system/biz/role.go +++ b/internal/features/system/biz/role.go @@ -7,6 +7,7 @@ package biz import ( "context" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/features/system/dto" diff --git a/internal/features/system/biz/user.go b/internal/features/system/biz/user.go index 00fd18e9..d040cb0d 100644 --- a/internal/features/system/biz/user.go +++ b/internal/features/system/biz/user.go @@ -8,16 +8,17 @@ package biz import ( "context" "fmt" - "github.com/origadmin/toolkits/auth/authenticator" + + "github.com/origadmin/toolkits/crypto/hash" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/features/system/dal" ) // UserUseCase is a User use case. type UserUseCase struct { - repo dto.UserRepo - auth authenticator.Authenticator + repo dal.UserRepo + hasher hash.Crypto } func (uc *UserUseCase) ListUserResources(ctx context.Context, id int64) ([]*types.Resource, error) { @@ -66,12 +67,12 @@ func (uc *UserUseCase) GetUser(ctx context.Context, id int64) (*types.User, erro } func (uc *UserUseCase) CreateUser(ctx context.Context, in *types.User, password string) (*types.User, error) { - encryptedPassword, err := uc.auth.Create(in.Username, password) + hashedPassword, err := uc.hasher.Hash(password) if err != nil { return nil, err } - in.Password = encryptedPassword - + in.Password = hashedPassword + fmt.Println("Create new user username:", in.Username, "password:", password) result, err := uc.repo.Create(ctx, in) @@ -97,6 +98,6 @@ func (uc *UserUseCase) DeleteUser(ctx context.Context, id int64) error { } // NewUserUseCase new a User use case. -func NewUserUseCase(repo dto.UserRepo, auth authenticator.Authenticator) (*UserUseCase, error) { - return &UserUseCase{repo: repo, auth: auth}, nil +func NewUserUseCase(repo dal.UserRepo, hasher hash.Crypto) (*UserUseCase, error) { + return &UserUseCase{repo: repo, hasher: hasher}, nil } diff --git a/internal/features/system/dal/README.md b/internal/features/system/dal/README.md deleted file mode 100644 index 0f77dee7..00000000 --- a/internal/features/system/dal/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Dal - -This directory contains the data access layer (DAL) for the service. diff --git a/internal/features/system/dal/dal.go b/internal/features/system/dal/dal.go deleted file mode 100644 index 2d0cd078..00000000 --- a/internal/features/system/dal/dal.go +++ /dev/null @@ -1,5 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal diff --git a/internal/features/system/dal/menu.dal.go b/internal/features/system/dal/menu.dal.go deleted file mode 100644 index 186bf6d3..00000000 --- a/internal/features/system/dal/menu.dal.go +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "context" - "strings" - - "entgo.io/ent/dialect/sql" - - "github.com/origadmin/runtime" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path - "origadmin/application/admin/internal/helpers/db" -) - -type menuRepo struct { - data *data.Data - db *ent.Database -} - -func (repo menuRepo) Get(ctx context.Context, id int64, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { - var option dto.MenuQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.Resource(ctx).Query().Where(resource.ID(id)) - query = menuQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResourceToMenuPB(result), nil -} - -func (repo menuRepo) Create(ctx context.Context, menuPB *dto.MenuPB, - options ...dto.MenuQueryOption) (*dto.MenuPB, error) { - var option dto.MenuQueryOption - if len(options) > 0 { - option = options[0] - } - err := repo.db.Tx(ctx, func(ctx context.Context) error { - create := repo.db.Resource(ctx).Create() - create.SetResource(dto.ConvertMenuPBToResource(menuPB), option.Fields...) - saved, err := create.Save(ctx) - if err != nil { - return err - } - menuPB = dto.ConvertResourceToMenuPB(saved) - return nil - }) - if err != nil { - return nil, err - } - return menuPB, nil -} - -func (repo menuRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Tx(ctx, func(ctx context.Context) error { - return repo.db.Resource(ctx).DeleteOneID(id).Exec(ctx) - }) -} - -func (repo menuRepo) Update(ctx context.Context, menuPB *dto.MenuPB, options ...dto.MenuQueryOption) (*dto.MenuPB, - error) { - err := repo.db.Tx(ctx, func(ctx context.Context) error { - update := repo.db.Resource(ctx).UpdateOneID(menuPB.Id) - update.SetResource(dto.ConvertMenuPBToResource(menuPB)) - saved, err := update.Save(ctx) - if err != nil { - return err - } - menuPB = dto.ConvertResourceToMenuPB(saved) - return nil - }) - if err != nil { - return nil, err - } - return menuPB, nil -} - -func (repo menuRepo) List(ctx context.Context, in *dto.ListMenusRequest, options ...dto.MenuQueryOption) ([]*dto.MenuPB, int32, error) { - var option dto.MenuQueryOption - if len(options) > 0 { - option = options[0] - } - - query := repo.db.Resource(ctx).Query() - //if option.IncludeResources { - // query = query.WithResources() - //} - //if v := option.UserID; v > 0 { - // query = query.Where(resource.HasRolesWith(role.HasUsersWith(user.ID(v)))) - //} - //if v := option.RoleID; v > 0 { - // query = query.Where(resource.HasRolesWith(role.ID(v))) - //} - if v := option.InIDs; len(v) > 0 { - query = query.Where(resource.IDIn(v...)) - } - //if v := option.Name; len(v) > 0 { - // query = query.Where(resource.ParentPathContains(v)) - //} - if v := option.Status; v > 0 { - query = query.Where(resource.StatusEQ(v)) - } - if v := option.ParentID; v > 0 { - query = query.Where(resource.ParentID(v)) - } - //if v := option.ParentPathPrefix; len(v) > 0 { - // query = query.Where(resource.ParentPathHasPrefix(v)) - //} - - return menuPageQuery(ctx, query, in, option) -} - -// NewMenuRepo . -func NewMenuRepo(r *runtime.App, d *data.Data) dto.MenuRepo { - return &menuRepo{ - data: d, - db: d.DB(), - } -} - -func menuPageQuery(ctx context.Context, query *ent.ResourceQuery, in *dto.ListMenusRequest, - option dto.MenuQueryOption) ([]*dto.MenuPB, int32, error) { - if in.OnlyCount { - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - return nil, int32(count), nil - } - count, err := query.Clone().Count(ctx) - if err != nil { - return nil, 0, err - } - query = db.QueryPage(query, in) - query = menuQueryOptions(query, option) - result, err := query.Clone().All(ctx) - menus := make([]*dto.MenuPB, len(result)) - for i, r := range result { - menus[i] = dto.ConvertResourceToMenuPB(r) - } - return menus, int32(count), err -} - -func menuQueryOptions(query *ent.ResourceQuery, option dto.MenuQueryOption) *ent.ResourceQuery { - //if len(option.SelectFields) > 0 { - // query = query.Select(option.SelectFields...).(*ent.ResourceQuery) - //} - //if len(option.OmitFields) > 0 { - // query = query.Omit(option.OmitFields...).(*ent.ResourceQuery) - //} - if len(option.OrderFields) > 0 { - query = query.Order(menuOrderBy(option.OrderFields)...) - } - return query -} - -func menuOrderBy(fields []string, opts ...sql.OrderTermOption) []resource.OrderOption { - var orders []resource.OrderOption - for _, field := range fields { - parts := strings.Split(field, ",") - fieldName := parts[0] - var orderOpt sql.OrderTermOption - - if len(parts) > 1 { - switch strings.ToLower(parts[1]) { - case "desc": - orderOpt = sql.OrderDesc() - default: - orderOpt = sql.OrderAsc() - } - } else { - orderOpt = sql.OrderAsc() - } - - orders = append(orders, sql.OrderByField(fieldName, orderOpt).ToFunc()) - } - return orders -} diff --git a/internal/features/system/dal/permission.dal.go b/internal/features/system/dal/permission.dal.go deleted file mode 100644 index dde86113..00000000 --- a/internal/features/system/dal/permission.dal.go +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "context" - - "entgo.io/ent/dialect/sql" - - "github.com/origadmin/runtime" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/permission" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path - "origadmin/application/admin/internal/helpers/db" -) - -type permissionRepo struct { - db *ent.Database -} - -func (repo permissionRepo) Get(ctx context.Context, id int64, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { - var option dto.PermissionQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.Permission(ctx).Query().Where(permission.ID(id)) - query = permissionQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return dto.ConvertPermissionToPermissionPB(result), nil -} - -func (repo permissionRepo) Create(ctx context.Context, permission *dto.PermissionPB, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { - var option dto.PermissionQueryOption - if len(options) > 0 { - option = options[0] - } - obj := dto.ConvertPermissionPBToPermission(permission) - create := repo.db.Permission(ctx).Create() - if len(permission.ResourceIds) > 0 { - create.AddResourceIDs(permission.ResourceIds...) - } - if len(permission.Resources) > 0 { - create.AddResources(dto.ConvertResourcesPBToResources(permission.Resources)...) - } - create.SetPermission(obj, option.Fields...) - saved, err := create.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertPermissionToPermissionPB(saved), nil -} - -func (repo permissionRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Permission(ctx).DeleteOneID(id).Exec(ctx) -} - -func (repo permissionRepo) Update(ctx context.Context, permission *dto.PermissionPB, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { - var option dto.PermissionQueryOption - if len(options) > 0 { - option = options[0] - } - - update := repo.db.Permission(ctx).UpdateOneID(permission.Id) - obj := dto.ConvertPermissionPBToPermission(permission) - if len(permission.ResourceIds) > 0 { - update.ClearResources() - update.AddResourceIDs(permission.ResourceIds...) - } - if len(permission.Resources) > 0 { - update.ClearResources() - update.AddResources(dto.ConvertResourcesPBToResources(permission.Resources)...) - } - update.SetPermission(obj, option.Fields...) - saved, err := update.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertPermissionToPermissionPB(saved), nil -} - -func (repo permissionRepo) List(ctx context.Context, in *dto.ListPermissionsRequest, options ...dto.PermissionQueryOption) ([]*dto.PermissionPB, int32, error) { - var option dto.PermissionQueryOption - if len(options) > 0 { - option = options[0] - } - - query := repo.db.Permission(ctx).Query() - if option.IncludeResources { - query = query.WithResources() - } - if option.IncludeRoles { - query = query.WithRoles() - } - if len(in.DataScopes) > 0 { - query = query.Where(permission.DataScopeIn(in.DataScopes...)) - } - return permissionPageQuery(ctx, query, in, option) -} - -// NewPermissionRepo . -func NewPermissionRepo(r *runtime.App, d *data.Data) dto.PermissionRepo { - return &permissionRepo{ - db: d.DB(), - } -} - -func permissionPageQuery(ctx context.Context, query *ent.PermissionQuery, in *pb.ListPermissionsRequest, option dto.PermissionQueryOption) ([]*dto.PermissionPB, int32, error) { - if in.OnlyCount { - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - return nil, int32(count), nil - } - - query = permissionQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - query = db.Query(query, in, !in.NoPaging) - result, err := query.All(ctx) - return dto.ConvertPermissionsToPermissionsPB(result), int32(count), err -} - -func permissionQueryPage(query *ent.PermissionQuery, in *pb.ListPermissionsRequest) *ent.PermissionQuery { - if in.NoPaging { - pageSize := in.PageSize - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - return query - } - - pageSize := in.PageSize - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - current := in.Current - if current > 0 { - query = query.Offset(int((current - 1) * pageSize)) - } - return query -} - -func permissionQueryOptions(query *ent.PermissionQuery, option dto.PermissionQueryOption) *ent.PermissionQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).PermissionQuery - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).PermissionQuery - } - if len(option.OrderFields) > 0 { - query = query.Order(permissionOrderBy(option.OrderFields)...) - } - return query -} - -func permissionOrderBy(fields []string, opts ...sql.OrderTermOption) []permission.OrderOption { - var orders []permission.OrderOption - for _, field := range fields { - orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) - } - return orders -} diff --git a/internal/features/system/dal/provider.go b/internal/features/system/dal/provider.go deleted file mode 100644 index db5cd8fc..00000000 --- a/internal/features/system/dal/provider.go +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dal implements the functions, types, and interfaces for the module. -package dal - -import ( - "github.com/google/wire" - - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -// Repositories is a collection of all repositories. -type Repositories struct { - MenuRepo dto.MenuRepo - ResourceRepo dto.ResourceRepo - RoleRepo dto.RoleRepo - UserRepo dto.UserRepo - PermissionRepo dto.PermissionRepo -} - -// NewRepositories creates a new Repositories instance. -func NewRepositories( - menuRepo dto.MenuRepo, - resourceRepo dto.ResourceRepo, - roleRepo dto.RoleRepo, - userRepo dto.UserRepo, - permissionRepo dto.PermissionRepo, -) *Repositories { - return &Repositories{ - MenuRepo: menuRepo, - ResourceRepo: resourceRepo, - RoleRepo: roleRepo, - UserRepo: userRepo, - PermissionRepo: permissionRepo, - } -} - -// ProviderSet is data providers. -var ProviderSet = wire.NewSet( - NewMenuRepo, - NewResourceRepo, - NewRoleRepo, - NewUserRepo, - NewPermissionRepo, - NewRepositories, // Provide the aggregated Repositories struct -) diff --git a/internal/features/system/dal/resource.dal.go b/internal/features/system/dal/resource.dal.go deleted file mode 100644 index d74291f3..00000000 --- a/internal/features/system/dal/resource.dal.go +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "context" - "strconv" - - "github.com/origadmin/runtime" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/features/system/dto" - "origadmin/application/admin/internal/helpers/db" -) - -type resourceRepo struct { - db *ent.Database - Delimiter string -} - -func (repo resourceRepo) Get(ctx context.Context, id int64, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { - var option dto.ResourceQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.Resource(ctx).Query().Where(resource.ID(id)) - query = resourceQueryOptions(query, option) - //if option.IncludePermissions { - // query.WithPermissions() - //} - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResourceToResourcePB(result), nil -} - -func (repo resourceRepo) Create(ctx context.Context, resource *dto.ResourcePB, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { - var option dto.ResourceQueryOption - if len(options) > 0 { - option = options[0] - } - obj := dto.ConvertResourcePBToResource(resource) - if obj.ParentID > 0 { - parent, err := repo.db.Resource(ctx).Get(ctx, obj.ParentID) - if err != nil { - return nil, err - } - obj.TreePath = parent.TreePath + strconv.Itoa(int(parent.ID)) + repo.Delimiter - } - - create := repo.db.Resource(ctx).Create() - create.SetResource(obj, option.Fields...) - if len(resource.PermissionIds) > 0 { - create.AddPermissionIDs(resource.PermissionIds...) - } - if len(resource.Permissions) > 0 { - create.AddPermissions(dto.ConvertPermissionsPBToPermissions(resource.Permissions)...) - } - saved, err := create.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResourceToResourcePB(saved), nil -} - -func (repo resourceRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Resource(ctx).DeleteOneID(id).Exec(ctx) -} - -func (repo resourceRepo) Update(ctx context.Context, resource *dto.ResourcePB, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { - var option dto.ResourceQueryOption - if len(options) > 0 { - option = options[0] - } - err := repo.db.Tx(ctx, func(ctx context.Context) error { - update := repo.db.Resource(ctx).UpdateOneID(resource.Id) - update.SetResourceWithZero(dto.ConvertResourcePBToResource(resource), option.Fields...) - if len(resource.PermissionIds) > 0 { - update.AddPermissionIDs(resource.PermissionIds...) - } - if len(resource.Permissions) > 0 { - update.AddPermissions(dto.ConvertPermissionsPBToPermissions(resource.Permissions)...) - } - saved, err := update.Save(ctx) - if err != nil { - return err - } - resource = dto.ConvertResourceToResourcePB(saved) - return nil - }) - if err != nil { - return nil, err - } - return resource, nil -} - -func (repo resourceRepo) List(ctx context.Context, in *dto.ListResourcesRequest, options ...dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { - var option dto.ResourceQueryOption - if len(options) > 0 { - option = options[0] - } - - query := repo.db.Resource(ctx).Query() - return resourcePageQuery(ctx, query, in, option) -} - -// NewResourceRepo . -func NewResourceRepo(r *runtime.App, d *data.Data) dto.ResourceRepo { - return &resourceRepo{ - db: d.DB(), - } -} - -func resourcePageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.ListResourcesRequest, option dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { - if in.OnlyCount { - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - return nil, int32(count), nil - } - query = resourceQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - query = db.Query(query, in, !in.NoPaging) - result, err := query.All(ctx) - return dto.ConvertResourcesToResourcesPB(result), int32(count), err -} - -func resourceOrderBy(orders []string) []resource.OrderOption { - return db.OrderBy[resource.OrderOption](orders) -} - -func resourceQueryOptions(query *ent.ResourceQuery, option dto.ResourceQueryOption) *ent.ResourceQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).ResourceQuery - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).ResourceQuery - } - if len(option.OrderFields) > 0 { - query = query.Order(resourceOrderBy(option.OrderFields)...) - } - return query -} diff --git a/internal/features/system/dal/role.dal.go b/internal/features/system/dal/role.dal.go deleted file mode 100644 index 489c8119..00000000 --- a/internal/features/system/dal/role.dal.go +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dal is the data access object -package dal - -import ( - "errors" - - "entgo.io/ent/dialect/sql" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/toolkits/crypto/rand" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/role" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path - "origadmin/application/admin/internal/helpers/db" -) - -type roleRepo struct { - gen rand.Generator - db *ent.Database -} - -func (repo roleRepo) Get(ctx context.Context, id int64, options ...dto.RoleQueryOption) (*dto.RolePB, error) { - var option dto.RoleQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.Role(ctx).Query().Where(role.ID(id)) - query = roleQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return dto.ConvertRoleToRolePB(result), nil -} - -func (repo roleRepo) Create(ctx context.Context, rolePB *dto.RolePB, options ...dto.RoleUpdateOption) (*dto.RolePB, error) { - var option dto.RoleUpdateOption - if len(options) > 0 { - option = options[0] - } - obj := dto.ConvertRolePBToRole(rolePB) - if obj.Keyword == "" { - randString, err := repo.gen.RandString(12) - if err != nil { - randString = "" - } - obj.Keyword = "system:role:" + randString - } - exist, err := repo.db.Role(ctx).Query().Where(role.KeywordEqualFold(rolePB.Keyword)).Exist(ctx) - if err != nil || exist { - return nil, errors.New("role keyword already exists") - } - err = repo.db.Tx(ctx, func(ctx context.Context) error { - create := repo.db.Role(ctx).Create() - create.SetRole(obj, option.Fields...) - saved, err := create.Save(ctx) - if err != nil { - return err - } - rolePB = dto.ConvertRoleToRolePB(saved) - return nil - }) - if err != nil { - return nil, err - } - return rolePB, nil -} - -func (repo roleRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Tx(ctx, func(ctx context.Context) error { - err := repo.db.Role(ctx).DeleteOneID(id).Exec(ctx) - if err != nil { - return err - } - return nil - }) -} - -func (repo roleRepo) Update(ctx context.Context, rolePB *dto.RolePB, options ...dto.RoleUpdateOption) (*dto.RolePB, error) { - var option dto.RoleUpdateOption - if len(options) > 0 { - option = options[0] - } - update := repo.db.Role(ctx).UpdateOneID(rolePB.Id) - if len(rolePB.PermissionIds) > 0 { - update.ClearPermissions() - update.AddPermissionIDs(rolePB.PermissionIds...) - } - if len(rolePB.Permissions) > 0 { - update.ClearPermissions() - update.AddPermissions(dto.ConvertPermissionsPBToPermissions(rolePB.Permissions)...) - } - saved, err := update.SetRoleWithZero(dto.ConvertRolePBToRole(rolePB), option.Fields...).Save(ctx) - if err != nil { - return nil, err - } - rolePB = dto.ConvertRoleToRolePB(saved) - return rolePB, nil -} - -func (repo roleRepo) List(ctx context.Context, in *pb.ListRolesRequest, options ...dto.RoleQueryOption) ([]*dto.RolePB, int32, error) { - var option dto.RoleQueryOption - if len(options) > 0 { - option = options[0] - } - - query := repo.db.Role(ctx).Query() - if option.IncludePermissions { - query = query.WithPermissions() - } - if v := option.InIDs; len(v) > 0 { - query = query.Where(role.IDIn(v...)) - } - if v := option.Name; len(v) > 0 { - query = query.Where(role.NameContains(v)) - } - if v := option.Status; v > 0 { - query = query.Where(role.StatusEQ(v)) - } - if v := option.UpdateTimeGT; v != nil { - query = query.Where(role.UpdateTimeGT(*v)) - } - - return rolePageQuery(ctx, query, in, option) -} - -// NewRoleRepo . -func NewRoleRepo(r *runtime.App, d *data.Data) dto.RoleRepo { - return &roleRepo{ - gen: rand.NewGenerator(rand.KindDigit | rand.KindLowerCase), - db: d.DB(), - } -} - -func rolePageQuery(ctx context.Context, query *ent.RoleQuery, in *pb.ListRolesRequest, option dto.RoleQueryOption) ([]*dto.RolePB, int32, error) { - if in.OnlyCount { - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - return nil, int32(count), nil - } - - query = roleQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - query = db.Query(query, in, !in.NoPaging) - result, err := query.All(ctx) - return dto.ConvertRolesToRolesPB(result), int32(count), err -} - -func roleQueryOptions(query *ent.RoleQuery, option dto.RoleQueryOption) *ent.RoleQuery { - //if len(option.SelectFields) > 0 { - // query = query.Select(option.SelectFields...).(*ent.RoleQuery) - //} - //if len(option.OmitFields) > 0 { - // query = query.Omit(option.OmitFields...).(*ent.RoleQuery) - //} - if len(option.OrderFields) > 0 { - query = query.Order(roleOrderBy(option.OrderFields)...) - } - return query -} - -func roleOrderBy(fields []string, opts ...sql.OrderTermOption) []role.OrderOption { - var orders []role.OrderOption - for _, field := range fields { - orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) - } - return orders -} diff --git a/internal/features/system/dal/user.dal.go b/internal/features/system/dal/user.dal.go deleted file mode 100644 index 6809a3a9..00000000 --- a/internal/features/system/dal/user.dal.go +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dal is the data access object -package dal - -import ( - "errors" - "time" - - "entgo.io/ent/dialect/sql" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path - "origadmin/application/admin/internal/helpers/db" -) - -type userRepo struct { - db *ent.Database -} - -func (repo userRepo) AddRoleIDs(ctx context.Context, i int64, int64s []int64, option ...dto.UserMutationOption) error { - //TODO implement me - panic("implement me") -} - -func (repo userRepo) UpdateUserStatus(ctx context.Context, id int64, status int8, options ...dto.UserQueryOption) error { - err := repo.db.User(ctx).UpdateOneID(id).SetStatus(status).Exec(ctx) - if err != nil { - return err - } - return nil -} - -func (repo userRepo) Current(ctx context.Context, id int64) (*dto.UserPB, error) { - return repo.Get(ctx, id) -} - -func (repo userRepo) ListResourceByUserID(ctx context.Context, id int64, - option ...dto.UserQueryOption) ([]*dto.ResourcePB, error) { - resources, err := repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResourcesToResourcesPB(resources), nil -} - -func (repo userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*dto.UserNode, error) { - query := repo.db.User(ctx).Query().Where(user.UsernameEQ(username)) - var option dto.UserQueryOption - if len(fields) > 0 { - option.SelectFields = fields - } - query = userQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return &dto.UserNode{ - UserPB: *dto.ConvertUserToUserPB(result), - EncryptedPassword: result.EncryptedPassword, - }, nil -} - -func (repo userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { - return repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().IDs(ctx) -} - -func (repo userRepo) Get(ctx context.Context, id int64, options ...dto.UserQueryOption) (*dto.UserPB, error) { - var option dto.UserQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.User(ctx).Query().Where(user.ID(id)) - query = userQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return dto.ConvertUserToUserPB(result), nil -} - -func (repo userRepo) Create(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { - var option dto.UserMutationOption - if len(options) > 0 { - option = options[0] - } - - var err error - exist, err := repo.db.User(ctx).Query().Where(user.UsernameEQ(userPB.Username)).Exist(ctx) - if err != nil || exist { - return nil, errors.New("user already exists") - } - obj := dto.ConvertUserPBToUser(userPB) - obj.CreateTime = time.Now() - obj.UpdateTime = time.Now() - err = repo.db.Tx(ctx, func(ctx context.Context) error { - create := repo.db.User(ctx).Create() - create.SetUser(obj, option.Fields...) - saved, err := create.Save(ctx) - if err != nil { - return err - } - userPB = dto.ConvertUserToUserPB(saved) - return nil - }) - if err != nil { - return nil, err - } - return userPB, nil -} - -func (repo userRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Tx(ctx, func(ctx context.Context) error { - return repo.db.User(ctx).DeleteOneID(id).Exec(ctx) - }) -} - -func (repo userRepo) Update(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { - obj := dto.ConvertUserPBToUser(userPB) - obj.UpdateTime = time.Now() - err := repo.db.Tx(ctx, func(ctx context.Context) error { - update := repo.db.User(ctx).UpdateOneID(userPB.Id) - if len(userPB.Roles) > 0 { - update.ClearRoles() - update.AddRoles(dto.ConvertRolesPBToRoles(userPB.Roles)...) - } else { - update.ClearRoles() - } - if len(userPB.RoleIds) > 0 { - update.ClearRoles() - update.AddRoleIDs(userPB.RoleIds...) - } else { - update.ClearRoles() - } - update.SetUser(obj, user.SelectColumns([]string{ - user.FieldNickname, - user.FieldUsername, - user.FieldPhone, - user.FieldEmail, - user.FieldUpdateTime})...) - saved, err := update.Save(ctx) - if err != nil { - return err - } - userPB = dto.ConvertUserToUserPB(saved) - return nil - }) - if err != nil { - return nil, err - } - return userPB, nil -} - -func (repo userRepo) List(ctx context.Context, in *pb.ListUsersRequest, options ...dto.UserQueryOption) ([]*dto.UserPB, int32, error) { - var option dto.UserQueryOption - if len(options) > 0 { - option = options[0] - } - - query := repo.db.User(ctx).Query() - if option.IncludeRoles { - query = query.WithRoles() - } - if in.Title != "" { - query = query.Where(user.Or(user.UsernameContainsFold(in.Title), user.PhoneContainsFold(in.Title), user.EmailContainsFold(in.Title))) - } - - if v := option.Status; v > 0 { - query = query.Where(user.StatusEQ(v)) - } - - return userPageQuery(ctx, query, in, option) -} - -// NewUserRepo . -func NewUserRepo(r *runtime.App, db *ent.Database) dto.UserRepo { - return &userRepo{ - db: db, - } -} - -func userPageQuery(ctx context.Context, query *ent.UserQuery, in *pb.ListUsersRequest, option dto.UserQueryOption) ([]*dto.UserPB, int32, error) { - if in.OnlyCount { - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - return nil, int32(count), nil - } - - query = userQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - query = db.Query(query, in, !in.NoPaging) - result, err := query.All(ctx) - return dto.ConvertUsersToUsersPB(result), int32(count), err -} - -func userQueryOptions(query *ent.UserQuery, option dto.UserQueryOption) *ent.UserQuery { - //if len(option.SelectFields) > 0 { - // query = query.Select(option.SelectFields...).(*ent.UserQuery) - //} - //if len(option.OmitFields) > 0 { - // query = query.Omit(option.OmitFields...).(*ent.UserQuery) - //} - if len(option.OrderFields) > 0 { - query = query.Order(userOrderBy(option.OrderFields)...) - } - return query -} - -func userOrderBy(fields []string, opts ...sql.OrderTermOption) []user.OrderOption { - var orders []user.OrderOption - for _, field := range fields { - orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) - } - return orders -} diff --git a/internal/features/system/data/data.go b/internal/features/system/data/data.go index 59ccd550..37aa00bd 100644 --- a/internal/features/system/data/data.go +++ b/internal/features/system/data/data.go @@ -22,7 +22,7 @@ import ( ) // ProviderSet is data providers. -var ProviderSet = wire.NewSet(NewData, NewUserRepo, NewRoleRepo, NewResourceRepo, NewPermissionRepo) +var ProviderSet = wire.NewSet(NewData, NewUserRepo, NewRoleRepo, NewResourceRepo, NewPermissionRepo, NewRepositories) // Data encapsulates ent client and cache. type Data struct { diff --git a/internal/features/system/data/permission.go b/internal/features/system/data/permission.go index f1011432..f57794a4 100644 --- a/internal/features/system/data/permission.go +++ b/internal/features/system/data/permission.go @@ -12,7 +12,6 @@ import ( "origadmin/application/admin/internal/features/system/data/ent" "origadmin/application/admin/internal/features/system/data/ent/permission" "origadmin/application/admin/internal/features/system/dto" - "origadmin/application/admin/internal/helpers/db" ) type permissionRepo struct { @@ -20,7 +19,7 @@ type permissionRepo struct { } func (repo *permissionRepo) Get(ctx context.Context, id int64, options ...dto.PermissionQueryOption) (*types.Permission, error) { - result, err := repo.db.Permission.Get(ctx, int(id)) + result, err := repo.db.Permission.Get(ctx, (id)) if err != nil { return nil, err } @@ -34,7 +33,7 @@ func (repo *permissionRepo) Create(ctx context.Context, p *types.Permission, opt if len(p.ResourceIds) > 0 { create.AddResourceIDs(p.ResourceIds...) } - + // ... set other fields saved, err := create.Save(ctx) @@ -45,12 +44,12 @@ func (repo *permissionRepo) Create(ctx context.Context, p *types.Permission, opt } func (repo *permissionRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Permission.DeleteOneID(int(id)).Exec(ctx) + return repo.db.Permission.DeleteOneID((id)).Exec(ctx) } func (repo *permissionRepo) Update(ctx context.Context, p *types.Permission, options ...dto.PermissionQueryOption) (*types.Permission, error) { - update := repo.db.Permission.UpdateOneID(int(p.Id)) - + update := repo.db.Permission.UpdateOneID((p.Id)) + if len(p.ResourceIds) > 0 { update.ClearResources().AddResourceIDs(p.ResourceIds...) } @@ -80,8 +79,8 @@ func (repo *permissionRepo) List(ctx context.Context, in *system.ListPermissions if err != nil { return nil, 0, err } - - query = db.QueryPage(query, in) + + //query = db.QueryPage(query, in) result, err := query.All(ctx) return dto.ConvertPermissionsToPermissionsPB(result), int32(count), err diff --git a/internal/features/system/data/provider.go b/internal/features/system/data/provider.go index f9dae407..436a1c2a 100644 --- a/internal/features/system/data/provider.go +++ b/internal/features/system/data/provider.go @@ -6,13 +6,11 @@ package data import ( - "github.com/google/wire" "origadmin/application/admin/internal/features/system/dto" ) // Repositories is a collection of all repositories. type Repositories struct { - MenuRepo dto.MenuRepo ResourceRepo dto.ResourceRepo RoleRepo dto.RoleRepo UserRepo dto.UserRepo @@ -21,27 +19,15 @@ type Repositories struct { // NewRepositories creates a new Repositories instance. func NewRepositories( - menuRepo dto.MenuRepo, resourceRepo dto.ResourceRepo, roleRepo dto.RoleRepo, userRepo dto.UserRepo, permissionRepo dto.PermissionRepo, ) (*Repositories, error) { return &Repositories{ - MenuRepo: menuRepo, ResourceRepo: resourceRepo, RoleRepo: roleRepo, UserRepo: userRepo, PermissionRepo: permissionRepo, }, nil } - -// ProviderSet is data providers. -var ProviderSet = wire.NewSet( - NewMenuRepo, - NewResourceRepo, - NewRoleRepo, - NewUserRepo, - NewPermissionRepo, - NewRepositories, // Provide the aggregated Repositories struct -) diff --git a/internal/features/system/data/resource.go b/internal/features/system/data/resource.go index 4d492a69..d8251264 100644 --- a/internal/features/system/data/resource.go +++ b/internal/features/system/data/resource.go @@ -12,7 +12,6 @@ import ( "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/features/system/data/ent" "origadmin/application/admin/internal/features/system/dto" - "origadmin/application/admin/internal/helpers/db" ) type resourceRepo struct { @@ -21,7 +20,7 @@ type resourceRepo struct { } func (repo *resourceRepo) Get(ctx context.Context, id int64, options ...dto.ResourceQueryOption) (*types.Resource, error) { - result, err := repo.db.Resource.Get(ctx, int(id)) + result, err := repo.db.Resource.Get(ctx, (id)) if err != nil { return nil, err } @@ -30,22 +29,22 @@ func (repo *resourceRepo) Get(ctx context.Context, id int64, options ...dto.Reso func (repo *resourceRepo) Create(ctx context.Context, r *types.Resource, options ...dto.ResourceQueryOption) (*types.Resource, error) { if r.ParentId > 0 { - parent, err := repo.db.Resource.Get(ctx, int(r.ParentId)) + parent, err := repo.db.Resource.Get(ctx, r.ParentId) if err != nil { return nil, err } - r.TreePath = parent.TreePath + strconv.Itoa(parent.ID) + repo.Delimiter + r.TreePath = parent.TreePath + strconv.Itoa(int(parent.ID)) + repo.Delimiter } create := repo.db.Resource.Create(). SetName(r.Name). - SetParentID(int(r.ParentId)). + SetParentID(r.ParentId). SetTreePath(r.TreePath) if len(r.PermissionIds) > 0 { create.AddPermissionIDs(r.PermissionIds...) } - + // ... set other fields saved, err := create.Save(ctx) @@ -56,12 +55,12 @@ func (repo *resourceRepo) Create(ctx context.Context, r *types.Resource, options } func (repo *resourceRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Resource.DeleteOneID(int(id)).Exec(ctx) + return repo.db.Resource.DeleteOneID(id).Exec(ctx) } func (repo *resourceRepo) Update(ctx context.Context, r *types.Resource, options ...dto.ResourceQueryOption) (*types.Resource, error) { - update := repo.db.Resource.UpdateOneID(int(r.Id)) - + update := repo.db.Resource.UpdateOneID(r.Id) + if len(r.PermissionIds) > 0 { update.ClearPermissions().AddPermissionIDs(r.PermissionIds...) } @@ -87,8 +86,8 @@ func (repo *resourceRepo) List(ctx context.Context, in *system.ListResourcesRequ if err != nil { return nil, 0, err } - - query = db.QueryPage(query, in) + + //query = db.QueryPage(query, in) result, err := query.All(ctx) return dto.ConvertResourcesToResourcesPB(result), int32(count), err diff --git a/internal/features/system/data/role.go b/internal/features/system/data/role.go index 672fc28a..41bee718 100644 --- a/internal/features/system/data/role.go +++ b/internal/features/system/data/role.go @@ -16,7 +16,6 @@ import ( "origadmin/application/admin/internal/features/system/data/ent" "origadmin/application/admin/internal/features/system/data/ent/role" "origadmin/application/admin/internal/features/system/dto" - "origadmin/application/admin/internal/helpers/db" ) type roleRepo struct { @@ -25,7 +24,7 @@ type roleRepo struct { } func (repo *roleRepo) Get(ctx context.Context, id int64, options ...dto.RoleQueryOption) (*types.Role, error) { - result, err := repo.db.Role.Get(ctx, int(id)) + result, err := repo.db.Role.Get(ctx, (id)) if err != nil { return nil, err } @@ -44,7 +43,7 @@ func (repo *roleRepo) Create(ctx context.Context, r *types.Role, options ...dto. if err != nil || exist { return nil, errors.New("role keyword already exists") } - + create := repo.db.Role.Create(). SetName(r.Name). SetKeyword(r.Keyword) @@ -57,15 +56,15 @@ func (repo *roleRepo) Create(ctx context.Context, r *types.Role, options ...dto. } func (repo *roleRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Role.DeleteOneID(int(id)).Exec(ctx) + return repo.db.Role.DeleteOneID((id)).Exec(ctx) } func (repo *roleRepo) Update(ctx context.Context, r *types.Role, options ...dto.RoleUpdateOption) (*types.Role, error) { - update := repo.db.Role.UpdateOneID(int(r.Id)) + update := repo.db.Role.UpdateOneID((r.Id)) if len(r.PermissionIds) > 0 { update.ClearPermissions().AddPermissionIDs(r.PermissionIds...) } - + // ... set other fields saved, err := update.Save(ctx) @@ -77,14 +76,14 @@ func (repo *roleRepo) Update(ctx context.Context, r *types.Role, options ...dto. func (repo *roleRepo) List(ctx context.Context, in *system.ListRolesRequest, options ...dto.RoleQueryOption) ([]*types.Role, int32, error) { query := repo.db.Role.Query() - - if in.Name != nil { - query = query.Where(role.NameContains(*in.Name)) - } - if in.Status != nil { - query = query.Where(role.StatusEQ(*in.Status)) - } - + + //if in.Name != nil { + // query = query.Where(role.NameContains(*in.Name)) + //} + //if in.Status != nil { + // query = query.Where(role.StatusEQ(*in.Status)) + //} + if in.OnlyCount { count, err := query.Count(ctx) return nil, int32(count), err @@ -94,8 +93,8 @@ func (repo *roleRepo) List(ctx context.Context, in *system.ListRolesRequest, opt if err != nil { return nil, 0, err } - - query = db.QueryPage(query, in) + + //query = db.QueryPage(query, in) result, err := query.All(ctx) return dto.ConvertRolesToRolesPB(result), int32(count), err diff --git a/internal/features/system/data/user.go b/internal/features/system/data/user.go index 35b4c60d..78392ba6 100644 --- a/internal/features/system/data/user.go +++ b/internal/features/system/data/user.go @@ -14,7 +14,6 @@ import ( "origadmin/application/admin/internal/features/system/data/ent" "origadmin/application/admin/internal/features/system/data/ent/user" "origadmin/application/admin/internal/features/system/dto" - "origadmin/application/admin/internal/helpers/db" ) type userRepo struct { @@ -22,7 +21,7 @@ type userRepo struct { } func (repo *userRepo) Get(ctx context.Context, id int64, options ...dto.UserQueryOption) (*types.User, error) { - result, err := repo.db.User.Get(ctx, int(id)) + result, err := repo.db.User.Get(ctx, id) if err != nil { return nil, err } @@ -42,11 +41,11 @@ func (repo *userRepo) Create(ctx context.Context, u *types.User, options ...dto. if err != nil || exist { return nil, errors.New("user already exists") } - + create := repo.db.User.Create(). SetUsername(u.Username). SetPassword(u.Password) - + // ... set other fields saved, err := create.Save(ctx) @@ -57,16 +56,16 @@ func (repo *userRepo) Create(ctx context.Context, u *types.User, options ...dto. } func (repo *userRepo) Delete(ctx context.Context, id int64) error { - return repo.db.User.DeleteOneID(int(id)).Exec(ctx) + return repo.db.User.DeleteOneID(id).Exec(ctx) } func (repo *userRepo) Update(ctx context.Context, u *types.User, options ...dto.UserMutationOption) (*types.User, error) { - update := repo.db.User.UpdateOneID(int(u.Id)) - + update := repo.db.User.UpdateOneID(u.Id) + if len(u.RoleIds) > 0 { update.ClearRoles().AddRoleIDs(u.RoleIds...) } - + // ... set other fields saved, err := update.Save(ctx) @@ -78,13 +77,13 @@ func (repo *userRepo) Update(ctx context.Context, u *types.User, options ...dto. func (repo *userRepo) List(ctx context.Context, in *system.ListUsersRequest, options ...dto.UserQueryOption) ([]*types.User, int32, error) { query := repo.db.User.Query() - - if in.Title != nil { - query = query.Where(user.Or(user.UsernameContainsFold(*in.Title), user.PhoneContainsFold(*in.Title), user.EmailContainsFold(*in.Title))) - } - if in.Status != nil { - query = query.Where(user.StatusEQ(int8(*in.Status))) + + if in.Title != "" { + query = query.Where(user.Or(user.UsernameContainsFold(in.Title), user.PhoneContainsFold(in.Title), user.EmailContainsFold(in.Title))) } + //if in.Status != nil { + // query = query.Where(user.StatusEQ(int8(*in.Status))) + //} if in.OnlyCount { count, err := query.Count(ctx) @@ -95,19 +94,19 @@ func (repo *userRepo) List(ctx context.Context, in *system.ListUsersRequest, opt if err != nil { return nil, 0, err } - - query = db.QueryPage(query, in) + + //query = db.QueryPage(query, in) result, err := query.All(ctx) return dto.ConvertUsersToUsersPB(result), int32(count), err } func (repo *userRepo) AddRoleIDs(ctx context.Context, id int64, roleIDs []int64, options ...dto.UserMutationOption) error { - return repo.db.User.UpdateOneID(int(id)).AddRoleIDs(roleIDs...).Exec(ctx) + return repo.db.User.UpdateOneID(id).AddRoleIDs(roleIDs...).Exec(ctx) } func (repo *userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { - ids, err := repo.db.User.Query().Where(user.ID(int(id))).QueryRoles().IDs(ctx) + ids, err := repo.db.User.Query().Where(user.ID(id)).QueryRoles().IDs(ctx) if err != nil { return nil, err } @@ -119,7 +118,7 @@ func (repo *userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) } func (repo *userRepo) ListResourceByUserID(ctx context.Context, id int64, options ...dto.UserQueryOption) ([]*types.Resource, error) { - resources, err := repo.db.User.Query().Where(user.ID(int(id))).QueryRoles().QueryPermissions().QueryResources().All(ctx) + resources, err := repo.db.User.Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) if err != nil { return nil, err } @@ -127,7 +126,7 @@ func (repo *userRepo) ListResourceByUserID(ctx context.Context, id int64, option } func (repo *userRepo) UpdateUserStatus(ctx context.Context, id int64, status int32, options ...dto.UserQueryOption) error { - return repo.db.User.UpdateOneID(int(id)).SetStatus(int8(status)).Exec(ctx) + return repo.db.User.UpdateOneID(id).SetStatus(int8(status)).Exec(ctx) } func (repo *userRepo) Current(ctx context.Context, id int64) (*types.User, error) { diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index ff7a56f1..4a87db9f 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -105,7 +105,7 @@ func ConvertPermissionPBToPermission(from *PermissionPB) *Permission { } to := &Permission{ - ID: int(from.Id), + ID: from.Id, CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), Name: from.Name, @@ -151,8 +151,8 @@ func ConvertPermissionResourcePBToPermissionResource(from *PermissionResourcePB) to := &PermissionResource{ ID: int(from.Id), - PermissionID: int(from.PermissionId), - ResourceID: int(from.ResourceId), + PermissionID: from.PermissionId, + ResourceID: from.ResourceId, } return to } @@ -165,8 +165,8 @@ func ConvertPermissionResourceToPermissionResourcePB(from *PermissionResource) * to := &PermissionResourcePB{ Id: int64(from.ID), - PermissionId: int64(from.PermissionID), - ResourceId: int64(from.ResourceID), + PermissionId: from.PermissionID, + ResourceId: from.ResourceID, } return to } @@ -202,7 +202,7 @@ func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { } to := &PermissionPB{ - Id: int64(from.ID), + Id: from.ID, CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Name: from.Name, @@ -254,7 +254,7 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { } to := &Resource{ - ID: int(from.Id), + ID: from.Id, CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), Name: from.Name, @@ -269,7 +269,7 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { TreePath: from.TreePath, Properties: from.Properties, Description: from.Description, - ParentID: int(from.ParentId), + ParentID: from.ParentId, } return to } @@ -281,7 +281,7 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { } to := &ResourcePB{ - Id: int64(from.ID), + Id: from.ID, CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Name: from.Name, @@ -296,7 +296,7 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { TreePath: from.TreePath, Properties: from.Properties, Description: from.Description, - ParentId: int64(from.ParentID), + ParentId: from.ParentID, Children: ConvertResourcesToResourcesPB(from.Edges.Children), Parent: ConvertResourceToResourcePB(from.Edges.Parent), Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), @@ -361,7 +361,7 @@ func ConvertRolePBToRole(from *RolePB) *Role { } to := &Role{ - ID: int(from.Id), + ID: from.Id, CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), Keyword: from.Keyword, @@ -408,8 +408,8 @@ func ConvertRolePermissionPBToRolePermission(from *RolePermissionPB) *RolePermis to := &RolePermission{ ID: int(from.Id), - RoleID: int(from.RoleId), - PermissionID: int(from.PermissionId), + RoleID: from.RoleId, + PermissionID: from.PermissionId, } return to } @@ -422,8 +422,8 @@ func ConvertRolePermissionToRolePermissionPB(from *RolePermission) *RolePermissi to := &RolePermissionPB{ Id: int64(from.ID), - RoleId: int64(from.RoleID), - PermissionId: int64(from.PermissionID), + RoleId: from.RoleID, + PermissionId: from.PermissionID, } return to } @@ -459,7 +459,7 @@ func ConvertRoleToRolePB(from *Role) *RolePB { } to := &RolePB{ - Id: int64(from.ID), + Id: from.ID, CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Keyword: from.Keyword, @@ -531,7 +531,7 @@ func ConvertUserPBToUser(from *UserPB) *User { } to := &User{ - ID: int(from.Id), + ID: from.Id, CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), UUID: from.Uuid, @@ -586,8 +586,8 @@ func ConvertUserRolePBToUserRole(from *UserRolePB) *UserRole { to := &UserRole{ ID: int(from.Id), - UserID: int(from.UserId), - RoleID: int(from.RoleId), + UserID: from.UserId, + RoleID: from.RoleId, } return to } @@ -600,8 +600,8 @@ func ConvertUserRoleToUserRolePB(from *UserRole) *UserRolePB { to := &UserRolePB{ Id: int64(from.ID), - UserId: int64(from.UserID), - RoleId: int64(from.RoleID), + UserId: from.UserID, + RoleId: from.RoleID, User: ConvertUserToUserPB(from.Edges.User), Role: ConvertRoleToRolePB(from.Edges.Role), } @@ -639,7 +639,7 @@ func ConvertUserToUserPB(from *User) *UserPB { } to := &UserPB{ - Id: int64(from.ID), + Id: from.ID, CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Uuid: from.UUID, diff --git a/internal/features/system/server/gins.go b/internal/features/system/server/gins.go deleted file mode 100644 index 26373997..00000000 --- a/internal/features/system/server/gins.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "net/url" - - "github.com/origadmin/contrib/transport/gins" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/service" - "github.com/origadmin/toolkits/env" - "github.com/origadmin/toolkits/net" - - "origadmin/application/admin/internal/configs" -) - -// NewGINSServer new a gin server. -func NewGINSServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.ServerOption) *gins.Server { - ms := middleware.NewServer(bootstrap.GetMiddleware()) - //option := settings.ApplyOrZero(ss...) - var opts = []gins.ServerOption{ - gins.Middleware(ms...), - } - //serviceConfig := bootstrap.GetService() - //cfg := serviceConfig.GetGins() - //if cfg == nil { - // return nil - //} - // - //if cfg.Network != "" { - // opts = append(opts, gins.Network(cfg.Network)) - //} - //if cfg.Addr != "" { - // opts = append(opts, gins.Address(cfg.Addr)) - //} - //if cfg.Timeout != nil { - // opts = append(opts, gins.Timeout(cfg.Timeout.AsDuration())) - //} - - //middlewares, err := bootstrap.LoadMiddlewares(bootstrap.GetServiceName(), bootstrap, l) - //if err == nil && len(middlewares) > 0 { - // opts = append(opts, http.Middleware(middlewares...)) - //} - - if l != nil { - opts = append(opts, gins.WithLogger(log.With(l, "module", "gins"))) - } - log.Infof("GetHostName: %s", env.Var(runtime.DefaultEnvPrefix, "host")) - hostVar := env.Var(runtime.DefaultEnvPrefix, "host") - hostIP := env.GetEnv(env.Var(runtime.DefaultEnvPrefix, "host_ip")) - if hostIP == "" { - log.Debugf("HostIP is empty, replacing with HostAddr: %s", hostVar) - hostIP = net.HostAddr(net.WithEnvVar(hostVar)) - log.Debugf("HostIP after replacement: %s", hostIP) - } - - var endpoint string - log.Debugf("GINS.Endpoint: %v", endpoint) - ep, _ := url.Parse(endpoint) - opts = append(opts, gins.Endpoint(ep)) - srv := gins.NewServer(opts...) - return srv -} diff --git a/internal/features/system/server/grpc.go b/internal/features/system/server/grpc.go deleted file mode 100644 index 43cb5ac0..00000000 --- a/internal/features/system/server/grpc.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/service" - - "origadmin/application/admin/internal/configs" -) - -// NewGRPCServer new a gRPC server. -func NewGRPCServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.GRPCServer { - services := bootstrap.GetServer().GetServices() - for _, serviceConfig := range services { - if serviceConfig.GetType() == "grpc" { - grpcServer, err := r.Builder().NewGRPCServer(serviceConfig) - if err != nil { - return nil - } - return grpcServer - } - } - return nil -} diff --git a/internal/features/system/server/http.go b/internal/features/system/server/http.go deleted file mode 100644 index f1be2682..00000000 --- a/internal/features/system/server/http.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/service" - - "origadmin/application/admin/internal/configs" -) - -// NewHTTPServer new an HTTP server. -func NewHTTPServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.HTTPServer { - services := bootstrap.GetServer().GetServices() - for _, serviceConfig := range services { - if serviceConfig.GetType() == "http" { - httpServer, err := r.Builder().NewHTTPServer(serviceConfig) - if err != nil { - return nil - } - return httpServer - } - } - return nil -} diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index d622908c..eb602af5 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -5,147 +5,97 @@ package server import ( - "github.com/go-kratos/kratos/v2/metadata" + "errors" + "github.com/go-kratos/kratos/v2/transport" + "github.com/go-kratos/kratos/v2/transport/grpc" + "github.com/go-kratos/kratos/v2/transport/http" "github.com/google/wire" - "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/errors" // Changed from toolkits/errors - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/service" - servicegrpc "github.com/origadmin/runtime/service/grpc" - servicehttp "github.com/origadmin/runtime/service/http" - - "origadmin/application/admin/internal/configs" - systemservice "origadmin/application/admin/internal/features/system/service" -) -const ( - // ServiceName is service name. - ServiceName = "system" -) + "github.com/origadmin/runtime/log" + systemv1 "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/features/system/service" -var ( - // ProviderSet is server providers. - ProviderSet = wire.NewSet( - NewSystemClient, - NewSystemServer, - ) + grpcv1 "github.com/origadmin/runtime/api/gen/go/config/transport/grpc/v1" + httpv1 "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1" + transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" ) -func init() { - runtime.RegisterService(ServiceName, service.DefaultServiceFactory) -} +// ProviderSet is server providers. +var ProviderSet = wire.NewSet(NewServers) -func NewSystemServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc systemservice.SystemServerRegistrar) []transport. -Server { - var servers []transport.Server - serverConfig := bootstrap.GetServer() - if serverConfig == nil { - return servers +// NewServers creates and configures the system service servers (gRPC, HTTP). +func NewServers(cfg *transportv1.Servers, svc *service.SystemService, logger log.Logger) ([]transport.Server, error) { + if cfg == nil { + return nil, errors.New("servers config is nil") } - ll := log.NewHelper(r.WithLogger("module", "system/server")) - middlewares := r.Builder().Middleware().BuildServer(bootstrap.GetServer().GetMiddleware()) - services := bootstrap.GetServer().GetServices() - coreinfo := bootstrap.GetServer().GetCore() - for _, serviceConfig := range services { - ll.Infow("msg", "service init", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) - var option service.ServerOption - switch serviceConfig.GetType() { - case "grpc": - options := []servicegrpc.Option{ - servicegrpc.WithMiddlewares(middlewares...), - servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), - } - option = service.WithGRPC(options...) + var transportServers []transport.Server + for _, serverCfg := range cfg.GetConfigs() { + switch serverCfg.GetProtocol() { case "http": - options := []servicehttp.Option{ - servicehttp.WithMiddlewares(middlewares...), - servicehttp.WithPrefix(runtime.DefaultEnvPrefix), + srv, err := NewHTTPServer(serverCfg.GetHttp(), svc, logger) + if err != nil { + return nil, err } - //httpServer, err := r.Builder().NewServer(serviceConfig, options...) - //if err != nil { - // continue - //} - //ll.Infow("msg", "http server init", "name", coreinfo.GetName(), "version", - // coreinfo.GetVersion()) - //svc.Register(r.Context(), httpServer) - //servers = append(servers, httpServer) - option = service.WithHTTP(options...) + transportServers = append(transportServers, srv) + case "grpc": + srv, err := NewGRPCServer(serverCfg.GetGrpc(), svc, logger) + if err != nil { + return nil, err + } + transportServers = append(transportServers, srv) default: - ll.Warnw("msg", "service type not support", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) - continue - } - grpcServer, err := r.Builder().NewServer("system", serviceConfig, option) - if err != nil { - continue + return nil, errors.New("protocol is not supported: " + serverCfg.GetProtocol()) } - ll.Infow("msg", "system server init", "name", coreinfo.GetName(), "version", - coreinfo.GetVersion()) - svc.Register(r.Context(), grpcServer) - servers = append(servers, grpcServer) } - return servers + return transportServers, nil } -func NewSystemClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service.GRPCClient, error) { - discovery := bootstrap.GetDiscovery() - if discovery == nil { - return nil, errors.New("no discovery") +// NewHTTPServer new an HTTP server. +func NewHTTPServer(cfg *httpv1.Server, svc *service.SystemService, logger log.Logger) (*http.Server, error) { + if cfg == nil { + return nil, errors.New("http config is nil") } - serviceConfig := &configv1.Service{ - Name: ServiceName, - //Grpc: entry.GetGrpc(), - //Http: entry.GetHttp(), - Selector: &configv1.Service_Selector{ - Version: "v1.0.0", - Builder: "bbr", - }, + + var opts []http.ServerOption + if cfg.GetAddr() != "" { + opts = append(opts, http.Address(cfg.GetAddr())) } - //if v, ok := bootstrap.GetServices()[ServiceName]; ok { - // discovery.ServiceName = ServiceName - //} - helper := log.NewHelper(r.Logger()) - //discovery.ServiceName = ServiceName - helper.Infof("service name: %s", discovery.ServiceName) - discover, err := runtime.NewDiscovery(discovery) - if err != nil { - return nil, errors.Wrap(err, "create discovery") + if cfg.GetTimeout() != nil { + opts = append(opts, http.Timeout(cfg.GetTimeout().AsDuration())) } - var ms []middleware.KMiddleware - options := []servicegrpc.Option{ - servicegrpc.WithDiscovery(discovery.ServiceName, discover), + srv := http.NewServer(opts...) + + // Register HTTP handlers + systemv1.RegisterUserServiceHTTPServer(srv, svc.User) + systemv1.RegisterRoleServiceHTTPServer(srv, svc.Role) + systemv1.RegisterPermissionServiceHTTPServer(srv, svc.Permission) + systemv1.RegisterResourceServiceHTTPServer(srv, svc.Resource) + + return srv, nil +} + +// NewGRPCServer new a gRPC server. +func NewGRPCServer(cfg *grpcv1.Server, svc *service.SystemService, logger log.Logger) (*grpc.Server, error) { + if cfg == nil { + return nil, errors.New("grpc config is nil") } - ms = append(ms, middleware.NewClient(bootstrap.GetMiddleware())...) - ms = append(ms, MiddlewareServer()) - if len(ms) > 0 { - options = append(options, servicegrpc.WithMiddlewares(ms...)) + + var opts []grpc.ServerOption + if cfg.GetAddr() != "" { + opts = append(opts, grpc.Address(cfg.GetAddr())) } - client, err := runtime.NewGRPCServiceClient(context.Background(), serviceConfig, options...) - if err != nil { - return nil, errors.Wrap(err, "create menu grpc client") + if cfg.GetTimeout() != nil { + opts = append(opts, grpc.Timeout(cfg.GetTimeout().AsDuration())) } - return client, nil -} + srv := grpc.NewServer(opts...) -func MiddlewareServer() middleware.KMiddleware { - return func(handler middleware.KHandler) middleware.KHandler { - return func(ctx context.Context, req interface{}) (reply interface{}, err error) { - if md, ok := metadata.FromClientContext(ctx); ok { - log.Debugf("MiddlewareServer: found client context metadata: %+v", md) - } else { - log.Debugf("MiddlewareServer: no client context metadata found") - } - if md, ok := metadata.FromServerContext(ctx); ok { - log.Debugf("MiddlewareServer: found server context metadata: %+v", md) - } else { - log.Debugf("MiddlewareServer: no server context metadata found") - } - reply, err = handler(ctx, req) - return - } - } + // Register gRPC handlers + systemv1.RegisterUserServiceServer(srv, svc.User) + systemv1.RegisterRoleServiceServer(srv, svc.Role) + systemv1.RegisterPermissionServiceServer(srv, svc.Permission) + systemv1.RegisterResourceServiceServer(srv, svc.Resource) + + return srv, nil } diff --git a/internal/features/system/service/dto.go b/internal/features/system/service/dto.go deleted file mode 100644 index b59d3911..00000000 --- a/internal/features/system/service/dto.go +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - system "origadmin/application/admin/api/v1/system" - "origadmin/application/admin/internal/features/system/biz" -) - -func toRoleDO(dto *system.Role) *biz.Role { - if dto == nil { - return nil - } - return &biz.Role{ - ID: int(dto.Id), - Name: dto.Name, - Keyword: dto.Keyword, - } -} - -func toRoleDTO(do *biz.Role) *system.Role { - if do == nil { - return nil - } - return &system.Role{ - Id: int32(do.ID), - Name: do.Name, - Keyword: do.Keyword, - } -} - -func toRoleDTOs(dos []*biz.Role) []*system.Role { - dtos := make([]*system.Role, len(dos)) - for i, do := range dos { - dtos[i] = toRoleDTO(do) - } - return dtos -} - -func toUserDO(dto *system.User) *biz.User { - if dto == nil { - return nil - } - return &biz.User{ - ID: int(dto.Id), - Username: dto.Username, - } -} - -func toUserDTO(do *biz.User) *system.User { - if do == nil { - return nil - } - return &system.User{ - Id: int32(do.ID), - Username: do.Username, - } -} - -func toUserDTOs(dos []*biz.User) []*system.User { - dtos := make([]*system.User, len(dos)) - for i, do := range dos { - dtos[i] = toUserDTO(do) - } - return dtos -} - -func toResourceDO(dto *system.Resource) *biz.Resource { - if dto == nil { - return nil - } - return &biz.Resource{ - ID: int(dto.Id), - Name: dto.Name, - ParentID: int(dto.ParentId), - } -} - -func toResourceDTO(do *biz.Resource) *system.Resource { - if do == nil { - return nil - } - return &system.Resource{ - Id: int32(do.ID), - Name: do.Name, - ParentId: int32(do.ParentID), - } -} - -func toResourceDTOs(dos []*biz.Resource) []*system.Resource { - dtos := make([]*system.Resource, len(dos)) - for i, do := range dos { - dtos[i] = toResourceDTO(do) - } - return dtos -} - -func toPermissionDO(dto *system.Permission) *biz.Permission { - if dto == nil { - return nil - } - return &biz.Permission{ - ID: int(dto.Id), - Name: dto.Name, - } -} - -func toPermissionDTO(do *biz.Permission) *system.Permission { - if do == nil { - return nil - } - return &system.Permission{ - Id: int32(do.ID), - Name: do.Name, - } -} - -func toPermissionDTOs(dos []*biz.Permission) []*system.Permission { - dtos := make([]*system.Permission, len(dos)) - for i, do := range dos { - dtos[i] = toPermissionDTO(do) - } - return dtos -} diff --git a/internal/features/system/service/permission.go b/internal/features/system/service/permission.go index e83a36c4..103fa29b 100644 --- a/internal/features/system/service/permission.go +++ b/internal/features/system/service/permission.go @@ -6,7 +6,9 @@ package service import ( "context" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/features/system/dto" ) func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPermissionsRequest) (*system.ListPermissionsResponse, error) { @@ -20,15 +22,15 @@ func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPer }, nil } -func (s *SystemService) GetPermission(ctx context.Context, req *system.GetPermissionRequest) (*system.Permission, error) { +func (s *SystemService) GetPermission(ctx context.Context, req *system.GetPermissionRequest) (*dto.PermissionPB, error) { return s.permission.GetPermission(ctx, req.Id) } -func (s *SystemService) CreatePermission(ctx context.Context, req *system.CreatePermissionRequest) (*system.Permission, error) { +func (s *SystemService) CreatePermission(ctx context.Context, req *system.CreatePermissionRequest) (*dto.PermissionPB, error) { return s.permission.CreatePermission(ctx, req.Permission) } -func (s *SystemService) UpdatePermission(ctx context.Context, req *system.UpdatePermissionRequest) (*system.Permission, error) { +func (s *SystemService) UpdatePermission(ctx context.Context, req *system.UpdatePermissionRequest) (*dto.PermissionPB, error) { return s.permission.UpdatePermission(ctx, req.Permission) } diff --git a/internal/features/system/service/resource.go b/internal/features/system/service/resource.go index ca9b80cb..dea4d7d0 100644 --- a/internal/features/system/service/resource.go +++ b/internal/features/system/service/resource.go @@ -6,7 +6,9 @@ package service import ( "context" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/features/system/dto" ) func (s *SystemService) ListResources(ctx context.Context, req *system.ListResourcesRequest) (*system.ListResourcesResponse, error) { @@ -20,15 +22,15 @@ func (s *SystemService) ListResources(ctx context.Context, req *system.ListResou }, nil } -func (s *SystemService) GetResource(ctx context.Context, req *system.GetResourceRequest) (*system.Resource, error) { +func (s *SystemService) GetResource(ctx context.Context, req *system.GetResourceRequest) (*dto.ResourcePB, error) { return s.resource.GetResource(ctx, req.Id) } -func (s *SystemService) CreateResource(ctx context.Context, req *system.CreateResourceRequest) (*system.Resource, error) { +func (s *SystemService) CreateResource(ctx context.Context, req *system.CreateResourceRequest) (*dto.ResourcePB, error) { return s.resource.CreateResource(ctx, req.Resource) } -func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateResourceRequest) (*system.Resource, error) { +func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateResourceRequest) (*dto.ResourcePB, error) { return s.resource.UpdateResource(ctx, req.Resource) } diff --git a/internal/features/system/service/role.go b/internal/features/system/service/role.go index 744e6616..4a1917c8 100644 --- a/internal/features/system/service/role.go +++ b/internal/features/system/service/role.go @@ -6,7 +6,9 @@ package service import ( "context" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/features/system/dto" ) func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequest) (*system.ListRolesResponse, error) { @@ -14,19 +16,19 @@ func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequ if err != nil { return nil, err } - + return &system.ListRolesResponse{ Roles: roles, Total: total, }, nil } -func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*system.Role, error) { +func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*dto.RolePB, error) { return s.role.GetRole(ctx, req.Id) } -func (s *SystemService) CreateRole(ctx context.Context, req *system.CreateRoleRequest) (*system.Role, error) { +func (s *SystemService) CreateRole(ctx context.Context, req *system.CreateRoleRequest) (*dto.RolePB, error) { return s.role.CreateRole(ctx, req.Role) } -func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRequest) (*system.Role, error) { +func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRequest) (*dto.RolePB, error) { return s.role.UpdateRole(ctx, req.Role) } func (s *SystemService) DeleteRole(ctx context.Context, req *system.DeleteRoleRequest) (*system.DeleteRoleResponse, error) { diff --git a/internal/features/system/service/service.go b/internal/features/system/service/service.go index 305b6fe6..719befb9 100644 --- a/internal/features/system/service/service.go +++ b/internal/features/system/service/service.go @@ -5,11 +5,6 @@ package service import ( - "context" - - "github.com/go-kratos/kratos/v2/transport" - - "github.com/origadmin/runtime/service" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/features/system/biz" ) @@ -39,19 +34,3 @@ func New( permission: permission, } } - -func (s *SystemService) Register(ctx context.Context, srv any) { - switch srv.(type) { - case *transport.Server: - case *service.Server: - } - system.RegisterResourceServiceServer(srv.GRPC, s) - system.RegisterRoleServiceServer(srv.GRPC, s) - system.RegisterUserServiceServer(srv.GRPC, s) - system.RegisterPermissionServiceServer(srv.GRPC, s) - - system.RegisterResourceServiceHTTPServer(srv.HTTP, s) - system.RegisterRoleServiceHTTPServer(srv.HTTP, s) - system.RegisterUserServiceHTTPServer(srv.HTTP, s) - system.RegisterPermissionServiceHTTPServer(srv.HTTP, s) -} diff --git a/internal/features/system/service/user.go b/internal/features/system/service/user.go index 62828951..4cfdcaac 100644 --- a/internal/features/system/service/user.go +++ b/internal/features/system/service/user.go @@ -6,7 +6,9 @@ package service import ( "context" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/features/system/dto" ) func (s *SystemService) ListUserResources(ctx context.Context, req *system.ListUserResourcesRequest) (*system.ListUserResourcesResponse, error) { @@ -54,20 +56,20 @@ func (s *SystemService) ListUsers(ctx context.Context, req *system.ListUsersRequ }, nil } -func (s *SystemService) GetUser(ctx context.Context, req *system.GetUserRequest) (*system.User, error) { +func (s *SystemService) GetUser(ctx context.Context, req *system.GetUserRequest) (*dto.UserPB, error) { return s.user.GetUser(ctx, req.Id) } -func (s *SystemService) CreateUser(ctx context.Context, req *system.CreateUserRequest) (*system.User, error) { +func (s *SystemService) CreateUser(ctx context.Context, req *system.CreateUserRequest) (*dto.UserPB, error) { return s.user.CreateUser(ctx, req.User, req.Password) } -func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRequest) (*system.User, error) { +func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRequest) (*dto.UserPB, error) { return s.user.UpdateUser(ctx, req.User) } func (s *SystemService) DeleteUser(ctx context.Context, req *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { - err := s.user.DeleteUser(ctx, req.Id) + err := s.user.DeleteUser(ctx, req.GetUser().GetId()) if err != nil { return nil, err } diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 64d0d457..cf14d354 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -2225,6 +2225,11 @@ paths: description: The parent resource id where the user is to be created. schema: type: string + - name: password + in: query + description: The password to use for this user. + schema: + type: string - name: user_id in: query description: The user id to use for this user. From 4672ea009306df8fef63a47e66b519a661c42956 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 24 Dec 2025 17:40:13 +0800 Subject: [PATCH 071/158] feat(proto): add keyword field to system proto files for search functionality --- api/v1/proto/system/department.proto | 2 + api/v1/proto/system/menu.proto | 14 +- api/v1/proto/system/permission.proto | 2 + api/v1/proto/system/position.proto | 2 + api/v1/proto/system/resource.proto | 2 + api/v1/proto/system/role.proto | 2 + api/v1/proto/system/user.proto | 2 +- api/v1/services/annotations.pb.go | 74 + api/v1/services/annotations.pb.validate.go | 36 + api/v1/services/auth/auth.pb.go | 962 +++ api/v1/services/auth/auth.pb.gw.go | 487 ++ api/v1/services/auth/auth.pb.validate.go | 1910 +++++ api/v1/services/auth/auth_bridge.pb.go | 450 ++ api/v1/services/auth/auth_grpc.pb.go | 323 + api/v1/services/auth/auth_http.pb.go | 285 + api/v1/services/auth/casbin.pb.go | 618 ++ api/v1/services/auth/casbin.pb.gw.go | 279 + api/v1/services/auth/casbin.pb.validate.go | 1217 +++ api/v1/services/auth/casbin_bridge.pb.go | 291 + api/v1/services/auth/casbin_grpc.pb.go | 243 + api/v1/services/auth/casbin_http.pb.go | 147 + api/v1/services/auth/login.pb.go | 1461 ++++ api/v1/services/auth/login.pb.gw.go | 631 ++ api/v1/services/auth/login.pb.validate.go | 2930 +++++++ api/v1/services/auth/login_bridge.pb.go | 554 ++ api/v1/services/auth/login_grpc.pb.go | 391 + api/v1/services/auth/login_http.pb.go | 339 + api/v1/services/auth/personal.pb.go | 1074 +++ api/v1/services/auth/personal.pb.gw.go | 594 ++ api/v1/services/auth/personal.pb.validate.go | 2390 ++++++ api/v1/services/auth/personal_bridge.pb.go | 565 ++ api/v1/services/auth/personal_grpc.pb.go | 407 + api/v1/services/auth/personal_http.pb.go | 366 + api/v1/services/datastore/datastore.pb.go | 750 ++ api/v1/services/datastore/datastore.pb.gw.go | 487 ++ .../datastore/datastore.pb.validate.go | 1329 ++++ .../services/datastore/datastore_bridge.pb.go | 392 + .../services/datastore/datastore_grpc.pb.go | 277 + .../services/datastore/datastore_http.pb.go | 234 + api/v1/services/datastore/upload.pb.go | 749 ++ api/v1/services/datastore/upload.pb.gw.go | 487 ++ .../services/datastore/upload.pb.validate.go | 1327 ++++ api/v1/services/datastore/upload_bridge.pb.go | 392 + api/v1/services/datastore/upload_grpc.pb.go | 277 + api/v1/services/datastore/upload_http.pb.go | 234 + api/v1/services/message/message.pb.go | 1074 +++ api/v1/services/message/message.pb.gw.go | 594 ++ .../services/message/message.pb.validate.go | 2390 ++++++ api/v1/services/message/message_bridge.pb.go | 565 ++ api/v1/services/message/message_grpc.pb.go | 407 + api/v1/services/message/message_http.pb.go | 366 + api/v1/services/system/department.pb.go | 746 ++ api/v1/services/system/department.pb.gw.go | 487 ++ .../services/system/department.pb.validate.go | 1329 ++++ .../services/system/department_bridge.pb.go | 392 + api/v1/services/system/department_grpc.pb.go | 277 + api/v1/services/system/department_http.pb.go | 234 + api/v1/services/system/menu.pb.go | 741 ++ api/v1/services/system/menu.pb.gw.go | 473 ++ api/v1/services/system/menu.pb.validate.go | 1321 ++++ api/v1/services/system/menu_bridge.pb.go | 392 + api/v1/services/system/menu_grpc.pb.go | 277 + api/v1/services/system/menu_http.pb.go | 234 + api/v1/services/system/permission.pb.go | 756 ++ api/v1/services/system/permission.pb.gw.go | 487 ++ .../services/system/permission.pb.validate.go | 1329 ++++ .../services/system/permission_bridge.pb.go | 392 + api/v1/services/system/permission_grpc.pb.go | 277 + api/v1/services/system/permission_http.pb.go | 234 + api/v1/services/system/position.pb.go | 733 ++ api/v1/services/system/position.pb.gw.go | 487 ++ .../services/system/position.pb.validate.go | 1329 ++++ api/v1/services/system/position_bridge.pb.go | 392 + api/v1/services/system/position_grpc.pb.go | 277 + api/v1/services/system/position_http.pb.go | 234 + api/v1/services/system/resource.pb.go | 755 ++ api/v1/services/system/resource.pb.gw.go | 487 ++ .../services/system/resource.pb.validate.go | 1331 ++++ api/v1/services/system/resource_bridge.pb.go | 392 + api/v1/services/system/resource_grpc.pb.go | 277 + api/v1/services/system/resource_http.pb.go | 234 + api/v1/services/system/role.pb.go | 739 ++ api/v1/services/system/role.pb.gw.go | 487 ++ api/v1/services/system/role.pb.validate.go | 1323 ++++ api/v1/services/system/role_bridge.pb.go | 392 + api/v1/services/system/role_grpc.pb.go | 277 + api/v1/services/system/role_http.pb.go | 234 + api/v1/services/system/user.pb.go | 1202 +++ api/v1/services/system/user.pb.gw.go | 834 ++ api/v1/services/system/user.pb.validate.go | 2334 ++++++ api/v1/services/system/user_bridge.pb.go | 636 ++ api/v1/services/system/user_grpc.pb.go | 435 ++ api/v1/services/system/user_http.pb.go | 408 + api/v1/services/types/auth_error.pb.go | 131 + .../services/types/auth_error.pb.validate.go | 36 + api/v1/services/types/auth_error_errors.pb.go | 48 + api/v1/services/types/datastore.pb.go | 206 + .../services/types/datastore.pb.validate.go | 232 + api/v1/services/types/error.pb.go | 128 + api/v1/services/types/error.pb.validate.go | 36 + api/v1/services/types/error_errors.pb.go | 36 + api/v1/services/types/message.pb.go | 128 + api/v1/services/types/message.pb.validate.go | 136 + api/v1/services/types/system.pb.go | 3205 ++++++++ api/v1/services/types/system.pb.validate.go | 5600 ++++++++++++++ api/v1/services/types/system_error.pb.go | 195 + .../types/system_error.pb.validate.go | 36 + .../services/types/system_error_errors.pb.go | 240 + cmd/system/main.go | 13 +- cmd/system/provider.go | 25 + cmd/system/wire.go | 17 +- cmd/system/wire_gen.go | 77 +- internal/data/data.go | 60 +- internal/features/system/biz/user.go | 69 +- internal/features/system/dal/permission.go | 87 + internal/features/system/dal/provider.go | 10 + internal/features/system/dal/resource.go | 97 + internal/features/system/dal/role.go | 116 + internal/features/system/dal/user.go | 129 + internal/features/system/data/data.go | 89 - internal/features/system/data/ent/client.go | 1520 ---- internal/features/system/data/ent/crud.go | 3 - internal/features/system/data/ent/database.go | 149 - internal/features/system/data/ent/ent.go | 620 -- .../system/data/ent/enttest/enttest.go | 85 - internal/features/system/data/ent/generate.go | 8 - .../features/system/data/ent/hook/hook.go | 270 - .../system/data/ent/intercept/intercept.go | 330 - .../system/data/ent/migrate/migrate.go | 96 - .../system/data/ent/migrate/schema.go | 313 - internal/features/system/data/ent/mutation.go | 6791 ----------------- .../system/data/ent/mutation_fields.go | 605 -- .../features/system/data/ent/permission.go | 263 - .../system/data/ent/permission/permission.go | 338 - .../system/data/ent/permission/where.go | 563 -- .../system/data/ent/permission_create.go | 530 -- .../system/data/ent/permission_delete.go | 88 - .../system/data/ent/permission_query.go | 986 --- .../system/data/ent/permission_update.go | 1198 --- .../system/data/ent/permissionresource.go | 160 - .../permissionresource/permissionresource.go | 164 - .../data/ent/permissionresource/where.go | 166 - .../data/ent/permissionresource_create.go | 260 - .../data/ent/permissionresource_delete.go | 88 - .../data/ent/permissionresource_query.go | 763 -- .../data/ent/permissionresource_update.go | 493 -- .../system/data/ent/predicate/predicate.go | 28 - internal/features/system/data/ent/resource.go | 355 - .../system/data/ent/resource/resource.go | 385 - .../system/data/ent/resource/where.go | 1008 --- .../system/data/ent/resource_create.go | 728 -- .../system/data/ent/resource_delete.go | 88 - .../system/data/ent/resource_query.go | 970 --- .../system/data/ent/resource_update.go | 1492 ---- internal/features/system/data/ent/role.go | 258 - .../features/system/data/ent/role/role.go | 318 - .../features/system/data/ent/role/where.go | 598 -- .../features/system/data/ent/role_create.go | 540 -- .../features/system/data/ent/role_delete.go | 88 - .../features/system/data/ent/role_query.go | 984 --- .../features/system/data/ent/role_update.go | 1246 --- .../system/data/ent/rolepermission.go | 160 - .../data/ent/rolepermission/rolepermission.go | 164 - .../system/data/ent/rolepermission/where.go | 166 - .../system/data/ent/rolepermission_create.go | 260 - .../system/data/ent/rolepermission_delete.go | 88 - .../system/data/ent/rolepermission_query.go | 763 -- .../system/data/ent/rolepermission_update.go | 493 -- internal/features/system/data/ent/runtime.go | 262 - .../system/data/ent/runtime/runtime.go | 10 - .../system/data/ent/schema/permission.go | 70 - .../data/ent/schema/permissionresource.go | 54 - .../system/data/ent/schema/resource.go | 94 - .../features/system/data/ent/schema/role.go | 97 - .../system/data/ent/schema/rolepermission.go | 58 - .../features/system/data/ent/schema/user.go | 93 - .../system/data/ent/schema/userrole.go | 58 - .../system/data/ent/template/crud.tpl | 40 - .../system/data/ent/template/crud_create.tpl | 34 - .../system/data/ent/template/crud_query.tpl | 48 - .../system/data/ent/template/crud_update.tpl | 33 - .../data/ent/template/crud_update_one.tpl | 48 - .../system/data/ent/template/database.tpl | 126 - .../data/ent/template/mutation_fields.tpl | 119 - .../data/ent/template/type_meta_fields.tpl | 67 - .../data/ent/template/type_meta_where.tpl | 16 - internal/features/system/data/ent/tx.go | 228 - internal/features/system/data/ent/user.go | 337 - .../features/system/data/ent/user/user.go | 395 - .../features/system/data/ent/user/where.go | 1182 --- .../features/system/data/ent/user_create.go | 752 -- .../features/system/data/ent/user_delete.go | 88 - .../features/system/data/ent/user_query.go | 825 -- .../features/system/data/ent/user_update.go | 1328 ---- internal/features/system/data/ent/userrole.go | 160 - .../system/data/ent/userrole/userrole.go | 164 - .../system/data/ent/userrole/where.go | 166 - .../system/data/ent/userrole_create.go | 260 - .../system/data/ent/userrole_delete.go | 88 - .../system/data/ent/userrole_query.go | 763 -- .../system/data/ent/userrole_update.go | 493 -- internal/features/system/data/permission.go | 92 - internal/features/system/data/provider.go | 33 - internal/features/system/data/resource.go | 102 - internal/features/system/data/role.go | 109 - internal/features/system/data/user.go | 139 - internal/features/system/dto/custom.gen.go | 18 - internal/features/system/dto/dto.go | 18 + internal/features/system/service/service.go | 16 +- resources/docs/openapi/openapi.yaml | 32 +- 210 files changed, 69017 insertions(+), 37298 deletions(-) create mode 100644 api/v1/services/annotations.pb.go create mode 100644 api/v1/services/annotations.pb.validate.go create mode 100644 api/v1/services/auth/auth.pb.go create mode 100644 api/v1/services/auth/auth.pb.gw.go create mode 100644 api/v1/services/auth/auth.pb.validate.go create mode 100644 api/v1/services/auth/auth_bridge.pb.go create mode 100644 api/v1/services/auth/auth_grpc.pb.go create mode 100644 api/v1/services/auth/auth_http.pb.go create mode 100644 api/v1/services/auth/casbin.pb.go create mode 100644 api/v1/services/auth/casbin.pb.gw.go create mode 100644 api/v1/services/auth/casbin.pb.validate.go create mode 100644 api/v1/services/auth/casbin_bridge.pb.go create mode 100644 api/v1/services/auth/casbin_grpc.pb.go create mode 100644 api/v1/services/auth/casbin_http.pb.go create mode 100644 api/v1/services/auth/login.pb.go create mode 100644 api/v1/services/auth/login.pb.gw.go create mode 100644 api/v1/services/auth/login.pb.validate.go create mode 100644 api/v1/services/auth/login_bridge.pb.go create mode 100644 api/v1/services/auth/login_grpc.pb.go create mode 100644 api/v1/services/auth/login_http.pb.go create mode 100644 api/v1/services/auth/personal.pb.go create mode 100644 api/v1/services/auth/personal.pb.gw.go create mode 100644 api/v1/services/auth/personal.pb.validate.go create mode 100644 api/v1/services/auth/personal_bridge.pb.go create mode 100644 api/v1/services/auth/personal_grpc.pb.go create mode 100644 api/v1/services/auth/personal_http.pb.go create mode 100644 api/v1/services/datastore/datastore.pb.go create mode 100644 api/v1/services/datastore/datastore.pb.gw.go create mode 100644 api/v1/services/datastore/datastore.pb.validate.go create mode 100644 api/v1/services/datastore/datastore_bridge.pb.go create mode 100644 api/v1/services/datastore/datastore_grpc.pb.go create mode 100644 api/v1/services/datastore/datastore_http.pb.go create mode 100644 api/v1/services/datastore/upload.pb.go create mode 100644 api/v1/services/datastore/upload.pb.gw.go create mode 100644 api/v1/services/datastore/upload.pb.validate.go create mode 100644 api/v1/services/datastore/upload_bridge.pb.go create mode 100644 api/v1/services/datastore/upload_grpc.pb.go create mode 100644 api/v1/services/datastore/upload_http.pb.go create mode 100644 api/v1/services/message/message.pb.go create mode 100644 api/v1/services/message/message.pb.gw.go create mode 100644 api/v1/services/message/message.pb.validate.go create mode 100644 api/v1/services/message/message_bridge.pb.go create mode 100644 api/v1/services/message/message_grpc.pb.go create mode 100644 api/v1/services/message/message_http.pb.go create mode 100644 api/v1/services/system/department.pb.go create mode 100644 api/v1/services/system/department.pb.gw.go create mode 100644 api/v1/services/system/department.pb.validate.go create mode 100644 api/v1/services/system/department_bridge.pb.go create mode 100644 api/v1/services/system/department_grpc.pb.go create mode 100644 api/v1/services/system/department_http.pb.go create mode 100644 api/v1/services/system/menu.pb.go create mode 100644 api/v1/services/system/menu.pb.gw.go create mode 100644 api/v1/services/system/menu.pb.validate.go create mode 100644 api/v1/services/system/menu_bridge.pb.go create mode 100644 api/v1/services/system/menu_grpc.pb.go create mode 100644 api/v1/services/system/menu_http.pb.go create mode 100644 api/v1/services/system/permission.pb.go create mode 100644 api/v1/services/system/permission.pb.gw.go create mode 100644 api/v1/services/system/permission.pb.validate.go create mode 100644 api/v1/services/system/permission_bridge.pb.go create mode 100644 api/v1/services/system/permission_grpc.pb.go create mode 100644 api/v1/services/system/permission_http.pb.go create mode 100644 api/v1/services/system/position.pb.go create mode 100644 api/v1/services/system/position.pb.gw.go create mode 100644 api/v1/services/system/position.pb.validate.go create mode 100644 api/v1/services/system/position_bridge.pb.go create mode 100644 api/v1/services/system/position_grpc.pb.go create mode 100644 api/v1/services/system/position_http.pb.go create mode 100644 api/v1/services/system/resource.pb.go create mode 100644 api/v1/services/system/resource.pb.gw.go create mode 100644 api/v1/services/system/resource.pb.validate.go create mode 100644 api/v1/services/system/resource_bridge.pb.go create mode 100644 api/v1/services/system/resource_grpc.pb.go create mode 100644 api/v1/services/system/resource_http.pb.go create mode 100644 api/v1/services/system/role.pb.go create mode 100644 api/v1/services/system/role.pb.gw.go create mode 100644 api/v1/services/system/role.pb.validate.go create mode 100644 api/v1/services/system/role_bridge.pb.go create mode 100644 api/v1/services/system/role_grpc.pb.go create mode 100644 api/v1/services/system/role_http.pb.go create mode 100644 api/v1/services/system/user.pb.go create mode 100644 api/v1/services/system/user.pb.gw.go create mode 100644 api/v1/services/system/user.pb.validate.go create mode 100644 api/v1/services/system/user_bridge.pb.go create mode 100644 api/v1/services/system/user_grpc.pb.go create mode 100644 api/v1/services/system/user_http.pb.go create mode 100644 api/v1/services/types/auth_error.pb.go create mode 100644 api/v1/services/types/auth_error.pb.validate.go create mode 100644 api/v1/services/types/auth_error_errors.pb.go create mode 100644 api/v1/services/types/datastore.pb.go create mode 100644 api/v1/services/types/datastore.pb.validate.go create mode 100644 api/v1/services/types/error.pb.go create mode 100644 api/v1/services/types/error.pb.validate.go create mode 100644 api/v1/services/types/error_errors.pb.go create mode 100644 api/v1/services/types/message.pb.go create mode 100644 api/v1/services/types/message.pb.validate.go create mode 100644 api/v1/services/types/system.pb.go create mode 100644 api/v1/services/types/system.pb.validate.go create mode 100644 api/v1/services/types/system_error.pb.go create mode 100644 api/v1/services/types/system_error.pb.validate.go create mode 100644 api/v1/services/types/system_error_errors.pb.go create mode 100644 cmd/system/provider.go create mode 100644 internal/features/system/dal/permission.go create mode 100644 internal/features/system/dal/provider.go create mode 100644 internal/features/system/dal/resource.go create mode 100644 internal/features/system/dal/role.go create mode 100644 internal/features/system/dal/user.go delete mode 100644 internal/features/system/data/data.go delete mode 100644 internal/features/system/data/ent/client.go delete mode 100644 internal/features/system/data/ent/crud.go delete mode 100644 internal/features/system/data/ent/database.go delete mode 100644 internal/features/system/data/ent/ent.go delete mode 100644 internal/features/system/data/ent/enttest/enttest.go delete mode 100644 internal/features/system/data/ent/generate.go delete mode 100644 internal/features/system/data/ent/hook/hook.go delete mode 100644 internal/features/system/data/ent/intercept/intercept.go delete mode 100644 internal/features/system/data/ent/migrate/migrate.go delete mode 100644 internal/features/system/data/ent/migrate/schema.go delete mode 100644 internal/features/system/data/ent/mutation.go delete mode 100644 internal/features/system/data/ent/mutation_fields.go delete mode 100644 internal/features/system/data/ent/permission.go delete mode 100644 internal/features/system/data/ent/permission/permission.go delete mode 100644 internal/features/system/data/ent/permission/where.go delete mode 100644 internal/features/system/data/ent/permission_create.go delete mode 100644 internal/features/system/data/ent/permission_delete.go delete mode 100644 internal/features/system/data/ent/permission_query.go delete mode 100644 internal/features/system/data/ent/permission_update.go delete mode 100644 internal/features/system/data/ent/permissionresource.go delete mode 100644 internal/features/system/data/ent/permissionresource/permissionresource.go delete mode 100644 internal/features/system/data/ent/permissionresource/where.go delete mode 100644 internal/features/system/data/ent/permissionresource_create.go delete mode 100644 internal/features/system/data/ent/permissionresource_delete.go delete mode 100644 internal/features/system/data/ent/permissionresource_query.go delete mode 100644 internal/features/system/data/ent/permissionresource_update.go delete mode 100644 internal/features/system/data/ent/predicate/predicate.go delete mode 100644 internal/features/system/data/ent/resource.go delete mode 100644 internal/features/system/data/ent/resource/resource.go delete mode 100644 internal/features/system/data/ent/resource/where.go delete mode 100644 internal/features/system/data/ent/resource_create.go delete mode 100644 internal/features/system/data/ent/resource_delete.go delete mode 100644 internal/features/system/data/ent/resource_query.go delete mode 100644 internal/features/system/data/ent/resource_update.go delete mode 100644 internal/features/system/data/ent/role.go delete mode 100644 internal/features/system/data/ent/role/role.go delete mode 100644 internal/features/system/data/ent/role/where.go delete mode 100644 internal/features/system/data/ent/role_create.go delete mode 100644 internal/features/system/data/ent/role_delete.go delete mode 100644 internal/features/system/data/ent/role_query.go delete mode 100644 internal/features/system/data/ent/role_update.go delete mode 100644 internal/features/system/data/ent/rolepermission.go delete mode 100644 internal/features/system/data/ent/rolepermission/rolepermission.go delete mode 100644 internal/features/system/data/ent/rolepermission/where.go delete mode 100644 internal/features/system/data/ent/rolepermission_create.go delete mode 100644 internal/features/system/data/ent/rolepermission_delete.go delete mode 100644 internal/features/system/data/ent/rolepermission_query.go delete mode 100644 internal/features/system/data/ent/rolepermission_update.go delete mode 100644 internal/features/system/data/ent/runtime.go delete mode 100644 internal/features/system/data/ent/runtime/runtime.go delete mode 100644 internal/features/system/data/ent/schema/permission.go delete mode 100644 internal/features/system/data/ent/schema/permissionresource.go delete mode 100644 internal/features/system/data/ent/schema/resource.go delete mode 100644 internal/features/system/data/ent/schema/role.go delete mode 100644 internal/features/system/data/ent/schema/rolepermission.go delete mode 100644 internal/features/system/data/ent/schema/user.go delete mode 100644 internal/features/system/data/ent/schema/userrole.go delete mode 100644 internal/features/system/data/ent/template/crud.tpl delete mode 100644 internal/features/system/data/ent/template/crud_create.tpl delete mode 100644 internal/features/system/data/ent/template/crud_query.tpl delete mode 100644 internal/features/system/data/ent/template/crud_update.tpl delete mode 100644 internal/features/system/data/ent/template/crud_update_one.tpl delete mode 100644 internal/features/system/data/ent/template/database.tpl delete mode 100644 internal/features/system/data/ent/template/mutation_fields.tpl delete mode 100644 internal/features/system/data/ent/template/type_meta_fields.tpl delete mode 100644 internal/features/system/data/ent/template/type_meta_where.tpl delete mode 100644 internal/features/system/data/ent/tx.go delete mode 100644 internal/features/system/data/ent/user.go delete mode 100644 internal/features/system/data/ent/user/user.go delete mode 100644 internal/features/system/data/ent/user/where.go delete mode 100644 internal/features/system/data/ent/user_create.go delete mode 100644 internal/features/system/data/ent/user_delete.go delete mode 100644 internal/features/system/data/ent/user_query.go delete mode 100644 internal/features/system/data/ent/user_update.go delete mode 100644 internal/features/system/data/ent/userrole.go delete mode 100644 internal/features/system/data/ent/userrole/userrole.go delete mode 100644 internal/features/system/data/ent/userrole/where.go delete mode 100644 internal/features/system/data/ent/userrole_create.go delete mode 100644 internal/features/system/data/ent/userrole_delete.go delete mode 100644 internal/features/system/data/ent/userrole_query.go delete mode 100644 internal/features/system/data/ent/userrole_update.go delete mode 100644 internal/features/system/data/permission.go delete mode 100644 internal/features/system/data/provider.go delete mode 100644 internal/features/system/data/resource.go delete mode 100644 internal/features/system/data/role.go delete mode 100644 internal/features/system/data/user.go diff --git a/api/v1/proto/system/department.proto b/api/v1/proto/system/department.proto index 54569ece..18afbf30 100644 --- a/api/v1/proto/system/department.proto +++ b/api/v1/proto/system/department.proto @@ -51,6 +51,8 @@ message ListDepartmentsRequest { bool no_paging = 5 [json_name = "no_paging"]; // The only_count is the query parameter for set only to query the total number bool only_count = 6 [json_name = "only_count"]; + // The keyword is the query parameter for set only to query the department by keyword + string keyword = 7 [json_name = "keyword"]; } message ListDepartmentsResponse { diff --git a/api/v1/proto/system/menu.proto b/api/v1/proto/system/menu.proto index 9214370b..c038d35e 100644 --- a/api/v1/proto/system/menu.proto +++ b/api/v1/proto/system/menu.proto @@ -41,17 +41,19 @@ service MenuService { // ListMenusRequest is the request for the MenuService.ListMenus method. message ListMenusRequest { // The parent resource id, for example, "shelves/shelf1". - int64 id = 1; + int64 id = 1 [json_name = "id"]; // The page number. - int32 page = 2; + int32 page = 2 [json_name = "page"]; // The maximum number of items to return. - int32 page_size = 3; + int32 page_size = 3 [json_name = "page_size"]; // The next_page_token value returned from a previous List request, if any. - string page_token = 4; + string page_token = 4 [json_name = "page_token"]; // The no_paging is used to disable pagination. - bool no_paging = 5; + bool no_paging = 5 [json_name = "no_paging"]; // The only_count is the query parameter for set only to query the total number - bool only_count = 6; + bool only_count = 6 [json_name = "only_count"]; + // The keyword is the query parameter for set only to query the menu by keyword + string keyword = 7 [json_name = "keyword"]; } // ListMenusResponse is the response for the MenuService.ListMenus method. diff --git a/api/v1/proto/system/permission.proto b/api/v1/proto/system/permission.proto index 767232a8..3b9e2b98 100644 --- a/api/v1/proto/system/permission.proto +++ b/api/v1/proto/system/permission.proto @@ -53,6 +53,8 @@ message ListPermissionsRequest { bool only_count = 6 [json_name = "only_count"]; // The data_scopes is used to query the permission by data scopes. repeated string data_scopes = 7 [json_name = "data_scopes"]; + // The keyword is the query parameter for set only to query the permission by keyword + string keyword = 8 [json_name = "keyword"]; } message ListPermissionsResponse { diff --git a/api/v1/proto/system/position.proto b/api/v1/proto/system/position.proto index e67ab7d7..05fbccc0 100644 --- a/api/v1/proto/system/position.proto +++ b/api/v1/proto/system/position.proto @@ -51,6 +51,8 @@ message ListPositionsRequest { bool no_paging = 5 [json_name = "no_paging"]; // The only_count is the query parameter for set only to query the total number bool only_count = 6 [json_name = "only_count"]; + // The keyword is the query parameter for set only to query the position by keyword + string keyword = 7 [json_name = "keyword"]; } message ListPositionsResponse { diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index 762457a0..2bea3a3f 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -54,6 +54,8 @@ message ListResourcesRequest { bool only_count = 6 [json_name = "only_count"]; // resource type string type = 7 [json_name = "type"]; + // The resource name keyword + string keyword = 8 [json_name = "keyword"]; } // ListResourcesResponse is the response for the ResourceService.ListResources method. diff --git a/api/v1/proto/system/role.proto b/api/v1/proto/system/role.proto index 6ae574be..d4dac31c 100644 --- a/api/v1/proto/system/role.proto +++ b/api/v1/proto/system/role.proto @@ -51,6 +51,8 @@ message ListRolesRequest { bool no_paging = 5 [json_name = "no_paging"]; // The only_count is the query parameter for set only to query the total number bool only_count = 6 [json_name = "only_count"]; + // The keyword is the query parameter for set only to query the role by keyword + string keyword = 7 [json_name = "keyword"]; } message ListRolesResponse { diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index b972e29f..62d2b5c0 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -102,7 +102,7 @@ message ListUsersRequest { // The only_count is the query parameter for set only to query the total number bool only_count = 6 [json_name = "only_count"]; // The title query parameter for set only to query the title - string title = 7 [json_name = "title"]; + string keyword = 7 [json_name = "keyword"]; } message ListUsersResponse { diff --git a/api/v1/services/annotations.pb.go b/api/v1/services/annotations.pb.go new file mode 100644 index 00000000..2fb6ac97 --- /dev/null +++ b/api/v1/services/annotations.pb.go @@ -0,0 +1,74 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: annotations.proto + +package services + +import ( + _ "github.com/google/gnostic/openapiv3" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var File_annotations_proto protoreflect.FileDescriptor + +const file_annotations_proto_rawDesc = "" + + "\n" + + "\x11annotations.proto\x12\x0fapi.v1.services\x1a$gnostic/openapi/v3/annotations.protoB\xcd\x04\xbaG\x8e\x03\x12\x8b\x02\n" + + "\rOrigAdmin API\x12_A lightweight, flexible, elegant and full-featured RBAC scaffolding backend management project.\"@\n" + + "\aGodCong\x12\x1chttps://github.com/origadmin\x1a\x17waitforadding@gmail.com*>\n" + + "\x03MIT\x127https://origadmin/application/admin/blob/master/LICENSE2\x17Version from annotation\x1a\x18\n" + + "\x16http://localhost:10080\x1a\x19\n" + + "\x17https://localhost:10080*I:G\n" + + "\x18\n" + + "\x05Basic\x12\x0f\n" + + "\r\n" + + "\x04http*\x05basic\n" + + "+\n" + + "\x06Bearer\x12!\n" + + "\x1f\n" + + "\x06apiKey\x1a\rAuthorization\"\x06header\n" + + "\x13com.api.v1.servicesB\x10AnnotationsProtoP\x01Z4origadmin/application/admin/api/v1/services;services\xa2\x02\x03AVS\xaa\x02\x0fApi.V1.Services\xca\x02\x0fApi\\V1\\Services\xe2\x02\x1bApi\\V1\\Services\\GPBMetadata\xea\x02\x11Api::V1::Servicesb\x06proto3" + +var file_annotations_proto_goTypes = []any{} +var file_annotations_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_annotations_proto_init() } +func file_annotations_proto_init() { + if File_annotations_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_annotations_proto_rawDesc), len(file_annotations_proto_rawDesc)), + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_annotations_proto_goTypes, + DependencyIndexes: file_annotations_proto_depIdxs, + }.Build() + File_annotations_proto = out.File + file_annotations_proto_goTypes = nil + file_annotations_proto_depIdxs = nil +} diff --git a/api/v1/services/annotations.pb.validate.go b/api/v1/services/annotations.pb.validate.go new file mode 100644 index 00000000..c62ec169 --- /dev/null +++ b/api/v1/services/annotations.pb.validate.go @@ -0,0 +1,36 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: annotations.proto + +package services + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go new file mode 100644 index 00000000..e5c2c744 --- /dev/null +++ b/api/v1/services/auth/auth.pb.go @@ -0,0 +1,962 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: auth/auth.proto + +package auth + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type AuthLogoutRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *AuthLogoutRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AuthLogoutRequest) Reset() { + *x = AuthLogoutRequest{} + mi := &file_auth_auth_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AuthLogoutRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthLogoutRequest) ProtoMessage() {} + +func (x *AuthLogoutRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[0] + 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 AuthLogoutRequest.ProtoReflect.Descriptor instead. +func (*AuthLogoutRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{0} +} + +func (x *AuthLogoutRequest) GetData() *AuthLogoutRequest_Data { + if x != nil { + return x.Data + } + return nil +} + +type AuthLogoutResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AuthLogoutResponse) Reset() { + *x = AuthLogoutResponse{} + mi := &file_auth_auth_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AuthLogoutResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthLogoutResponse) ProtoMessage() {} + +func (x *AuthLogoutResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[1] + 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 AuthLogoutResponse.ProtoReflect.Descriptor instead. +func (*AuthLogoutResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{1} +} + +func (x *AuthLogoutResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +type ListAuthResourcesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The maximum number of Auths to return. + PageSize int32 `protobuf:"varint,1,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,2,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,4,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListAuthResourcesRequest) Reset() { + *x = ListAuthResourcesRequest{} + mi := &file_auth_auth_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListAuthResourcesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListAuthResourcesRequest) ProtoMessage() {} + +func (x *ListAuthResourcesRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[2] + 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 ListAuthResourcesRequest.ProtoReflect.Descriptor instead. +func (*ListAuthResourcesRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{2} +} + +func (x *ListAuthResourcesRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListAuthResourcesRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListAuthResourcesRequest) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListAuthResourcesRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +type ListAuthResourcesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The list of Auths. + Resources []*types.Resource `protobuf:"bytes,1,rep,name=resources,proto3" json:"resources,omitempty"` + // The total number of Auths in the result set. + TotalSize int32 `protobuf:"varint,2,opt,name=total_size,proto3" json:"total_size,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListAuthResourcesResponse) Reset() { + *x = ListAuthResourcesResponse{} + mi := &file_auth_auth_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListAuthResourcesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListAuthResourcesResponse) ProtoMessage() {} + +func (x *ListAuthResourcesResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[3] + 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 ListAuthResourcesResponse.ProtoReflect.Descriptor instead. +func (*ListAuthResourcesResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{3} +} + +func (x *ListAuthResourcesResponse) GetResources() []*types.Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *ListAuthResourcesResponse) GetTotalSize() int32 { + if x != nil { + return x.TotalSize + } + return 0 +} + +// CreateTokenRequest contains the information needed to create a token. +type CreateTokenRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *CreateTokenRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateTokenRequest) Reset() { + *x = CreateTokenRequest{} + mi := &file_auth_auth_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTokenRequest) ProtoMessage() {} + +func (x *CreateTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[4] + 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 CreateTokenRequest.ProtoReflect.Descriptor instead. +func (*CreateTokenRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateTokenRequest) GetData() *CreateTokenRequest_Data { + if x != nil { + return x.Data + } + return nil +} + +// CreateTokenResponse contains the generated token. +type CreateTokenResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateTokenResponse) Reset() { + *x = CreateTokenResponse{} + mi := &file_auth_auth_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateTokenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTokenResponse) ProtoMessage() {} + +func (x *CreateTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[5] + 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 CreateTokenResponse.ProtoReflect.Descriptor instead. +func (*CreateTokenResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateTokenResponse) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +// VerifyTokenRequest contains the token to be verified. +type ValidateTokenRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ValidateTokenRequest) Reset() { + *x = ValidateTokenRequest{} + mi := &file_auth_auth_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ValidateTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ValidateTokenRequest) ProtoMessage() {} + +func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_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 ValidateTokenRequest.ProtoReflect.Descriptor instead. +func (*ValidateTokenRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{6} +} + +func (x *ValidateTokenRequest) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +// VerifyTokenResponse contains the result of the verification. +type ValidateTokenResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + IsValid bool `protobuf:"varint,1,opt,name=is_valid,proto3" json:"is_valid,omitempty"` + Claims map[string]string `protobuf:"bytes,2,rep,name=claims,proto3" json:"claims,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ValidateTokenResponse) Reset() { + *x = ValidateTokenResponse{} + mi := &file_auth_auth_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ValidateTokenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ValidateTokenResponse) ProtoMessage() {} + +func (x *ValidateTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ValidateTokenResponse.ProtoReflect.Descriptor instead. +func (*ValidateTokenResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{7} +} + +func (x *ValidateTokenResponse) GetIsValid() bool { + if x != nil { + return x.IsValid + } + return false +} + +func (x *ValidateTokenResponse) GetClaims() map[string]string { + if x != nil { + return x.Claims + } + return nil +} + +// DestroyTokenRequest contains the token to be invalidated. +type DestroyTokenRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *DestroyTokenRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DestroyTokenRequest) Reset() { + *x = DestroyTokenRequest{} + mi := &file_auth_auth_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DestroyTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DestroyTokenRequest) ProtoMessage() {} + +func (x *DestroyTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[8] + 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 DestroyTokenRequest.ProtoReflect.Descriptor instead. +func (*DestroyTokenRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{8} +} + +func (x *DestroyTokenRequest) GetData() *DestroyTokenRequest_Data { + if x != nil { + return x.Data + } + return nil +} + +// DestroyTokenResponse contains the result of the invalidation. +type DestroyTokenResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DestroyTokenResponse) Reset() { + *x = DestroyTokenResponse{} + mi := &file_auth_auth_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DestroyTokenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DestroyTokenResponse) ProtoMessage() {} + +func (x *DestroyTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[9] + 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 DestroyTokenResponse.ProtoReflect.Descriptor instead. +func (*DestroyTokenResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{9} +} + +func (x *DestroyTokenResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +type AuthenticateRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *AuthenticateRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AuthenticateRequest) Reset() { + *x = AuthenticateRequest{} + mi := &file_auth_auth_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AuthenticateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthenticateRequest) ProtoMessage() {} + +func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[10] + 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 AuthenticateRequest.ProtoReflect.Descriptor instead. +func (*AuthenticateRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{10} +} + +func (x *AuthenticateRequest) GetData() *AuthenticateRequest_Data { + if x != nil { + return x.Data + } + return nil +} + +type AuthenticateResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + IsValid bool `protobuf:"varint,1,opt,name=is_valid,proto3" json:"is_valid,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AuthenticateResponse) Reset() { + *x = AuthenticateResponse{} + mi := &file_auth_auth_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AuthenticateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthenticateResponse) ProtoMessage() {} + +func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[11] + 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 AuthenticateResponse.ProtoReflect.Descriptor instead. +func (*AuthenticateResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{11} +} + +func (x *AuthenticateResponse) GetIsValid() bool { + if x != nil { + return x.IsValid + } + return false +} + +type AuthLogoutRequest_Data struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AuthLogoutRequest_Data) Reset() { + *x = AuthLogoutRequest_Data{} + mi := &file_auth_auth_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AuthLogoutRequest_Data) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthLogoutRequest_Data) ProtoMessage() {} + +func (x *AuthLogoutRequest_Data) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[12] + 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 AuthLogoutRequest_Data.ProtoReflect.Descriptor instead. +func (*AuthLogoutRequest_Data) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{0, 0} +} + +func (x *AuthLogoutRequest_Data) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +type CreateTokenRequest_Data struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId string `protobuf:"bytes,1,opt,name=user_id,proto3" json:"user_id,omitempty"` + Scopes []string `protobuf:"bytes,2,rep,name=scopes,proto3" json:"scopes,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateTokenRequest_Data) Reset() { + *x = CreateTokenRequest_Data{} + mi := &file_auth_auth_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateTokenRequest_Data) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateTokenRequest_Data) ProtoMessage() {} + +func (x *CreateTokenRequest_Data) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[13] + 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 CreateTokenRequest_Data.ProtoReflect.Descriptor instead. +func (*CreateTokenRequest_Data) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{4, 0} +} + +func (x *CreateTokenRequest_Data) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *CreateTokenRequest_Data) GetScopes() []string { + if x != nil { + return x.Scopes + } + return nil +} + +type DestroyTokenRequest_Data struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DestroyTokenRequest_Data) Reset() { + *x = DestroyTokenRequest_Data{} + mi := &file_auth_auth_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DestroyTokenRequest_Data) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DestroyTokenRequest_Data) ProtoMessage() {} + +func (x *DestroyTokenRequest_Data) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[15] + 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 DestroyTokenRequest_Data.ProtoReflect.Descriptor instead. +func (*DestroyTokenRequest_Data) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{8, 0} +} + +func (x *DestroyTokenRequest_Data) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +type AuthenticateRequest_Data struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` + Method string `protobuf:"bytes,4,opt,name=method,proto3" json:"method,omitempty"` + Operation string `protobuf:"bytes,5,opt,name=operation,proto3" json:"operation,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AuthenticateRequest_Data) Reset() { + *x = AuthenticateRequest_Data{} + mi := &file_auth_auth_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AuthenticateRequest_Data) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AuthenticateRequest_Data) ProtoMessage() {} + +func (x *AuthenticateRequest_Data) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[16] + 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 AuthenticateRequest_Data.ProtoReflect.Descriptor instead. +func (*AuthenticateRequest_Data) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{10, 0} +} + +func (x *AuthenticateRequest_Data) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +func (x *AuthenticateRequest_Data) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *AuthenticateRequest_Data) GetMethod() string { + if x != nil { + return x.Method + } + return "" +} + +func (x *AuthenticateRequest_Data) GetOperation() string { + if x != nil { + return x.Operation + } + return "" +} + +var File_auth_auth_proto protoreflect.FileDescriptor + +const file_auth_auth_proto_rawDesc = "" + + "\n" + + "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"s\n" + + "\x11AuthLogoutRequest\x12@\n" + + "\x04data\x18\x01 \x01(\v2,.api.v1.services.auth.AuthLogoutRequest.DataR\x04data\x1a\x1c\n" + + "\x04Data\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token\"B\n" + + "\x12AuthLogoutResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"\x90\x01\n" + + "\x18ListAuthResourcesRequest\x12\x1c\n" + + "\tpage_size\x18\x01 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x02 \x01(\tR\n" + + "page_token\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tno_paging\x18\x04 \x01(\bR\tno_paging\"z\n" + + "\x19ListAuthResourcesResponse\x12=\n" + + "\tresources\x18\x01 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x1e\n" + + "\n" + + "total_size\x18\x02 \x01(\x05R\n" + + "total_size\"\x91\x01\n" + + "\x12CreateTokenRequest\x12A\n" + + "\x04data\x18\x01 \x01(\v2-.api.v1.services.auth.CreateTokenRequest.DataR\x04data\x1a8\n" + + "\x04Data\x12\x18\n" + + "\auser_id\x18\x01 \x01(\tR\auser_id\x12\x16\n" + + "\x06scopes\x18\x02 \x03(\tR\x06scopes\"+\n" + + "\x13CreateTokenResponse\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token\",\n" + + "\x14ValidateTokenRequest\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token\"\xbf\x01\n" + + "\x15ValidateTokenResponse\x12\x1a\n" + + "\bis_valid\x18\x01 \x01(\bR\bis_valid\x12O\n" + + "\x06claims\x18\x02 \x03(\v27.api.v1.services.auth.ValidateTokenResponse.ClaimsEntryR\x06claims\x1a9\n" + + "\vClaimsEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"w\n" + + "\x13DestroyTokenRequest\x12B\n" + + "\x04data\x18\x01 \x01(\v2..api.v1.services.auth.DestroyTokenRequest.DataR\x04data\x1a\x1c\n" + + "\x04Data\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token\"D\n" + + "\x14DestroyTokenResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"\xc1\x01\n" + + "\x13AuthenticateRequest\x12B\n" + + "\x04data\x18\x01 \x01(\v2..api.v1.services.auth.AuthenticateRequest.DataR\x04data\x1af\n" + + "\x04Data\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token\x12\x12\n" + + "\x04path\x18\x03 \x01(\tR\x04path\x12\x16\n" + + "\x06method\x18\x04 \x01(\tR\x06method\x12\x1c\n" + + "\toperation\x18\x05 \x01(\tR\toperation\"2\n" + + "\x14AuthenticateResponse\x12\x1a\n" + + "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xbb\x06\n" + + "\vAuthService\x12\x8d\x01\n" + + "\x11ListAuthResources\x12..api.v1.services.auth.ListAuthResourcesRequest\x1a/.api.v1.services.auth.ListAuthResourcesResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/auth/resources\x12}\n" + + "\vCreateToken\x12(.api.v1.services.auth.CreateTokenRequest\x1a).api.v1.services.auth.CreateTokenResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x04data\"\v/auth/token\x12\x80\x01\n" + + "\rValidateToken\x12*.api.v1.services.auth.ValidateTokenRequest\x1a+.api.v1.services.auth.ValidateTokenResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/auth/validate\x12\x82\x01\n" + + "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x04data\"\r/auth/destroy\x12\x87\x01\n" + + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\" \x82\xd3\xe4\x93\x02\x1a:\x04data\"\x12/auth/authenticate\x12{\n" + + "\n" + + "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x04data\"\f/auth/logout\x1a\x0e\xcaA\vapi.foo.comB\xd0\x01\n" + + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + +var ( + file_auth_auth_proto_rawDescOnce sync.Once + file_auth_auth_proto_rawDescData []byte +) + +func file_auth_auth_proto_rawDescGZIP() []byte { + file_auth_auth_proto_rawDescOnce.Do(func() { + file_auth_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_auth_proto_rawDesc), len(file_auth_auth_proto_rawDesc))) + }) + return file_auth_auth_proto_rawDescData +} + +var file_auth_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_auth_auth_proto_goTypes = []any{ + (*AuthLogoutRequest)(nil), // 0: api.v1.services.auth.AuthLogoutRequest + (*AuthLogoutResponse)(nil), // 1: api.v1.services.auth.AuthLogoutResponse + (*ListAuthResourcesRequest)(nil), // 2: api.v1.services.auth.ListAuthResourcesRequest + (*ListAuthResourcesResponse)(nil), // 3: api.v1.services.auth.ListAuthResourcesResponse + (*CreateTokenRequest)(nil), // 4: api.v1.services.auth.CreateTokenRequest + (*CreateTokenResponse)(nil), // 5: api.v1.services.auth.CreateTokenResponse + (*ValidateTokenRequest)(nil), // 6: api.v1.services.auth.ValidateTokenRequest + (*ValidateTokenResponse)(nil), // 7: api.v1.services.auth.ValidateTokenResponse + (*DestroyTokenRequest)(nil), // 8: api.v1.services.auth.DestroyTokenRequest + (*DestroyTokenResponse)(nil), // 9: api.v1.services.auth.DestroyTokenResponse + (*AuthenticateRequest)(nil), // 10: api.v1.services.auth.AuthenticateRequest + (*AuthenticateResponse)(nil), // 11: api.v1.services.auth.AuthenticateResponse + (*AuthLogoutRequest_Data)(nil), // 12: api.v1.services.auth.AuthLogoutRequest.Data + (*CreateTokenRequest_Data)(nil), // 13: api.v1.services.auth.CreateTokenRequest.Data + nil, // 14: api.v1.services.auth.ValidateTokenResponse.ClaimsEntry + (*DestroyTokenRequest_Data)(nil), // 15: api.v1.services.auth.DestroyTokenRequest.Data + (*AuthenticateRequest_Data)(nil), // 16: api.v1.services.auth.AuthenticateRequest.Data + (*emptypb.Empty)(nil), // 17: google.protobuf.Empty + (*types.Resource)(nil), // 18: api.v1.services.types.Resource +} +var file_auth_auth_proto_depIdxs = []int32{ + 12, // 0: api.v1.services.auth.AuthLogoutRequest.data:type_name -> api.v1.services.auth.AuthLogoutRequest.Data + 17, // 1: api.v1.services.auth.AuthLogoutResponse.empty:type_name -> google.protobuf.Empty + 18, // 2: api.v1.services.auth.ListAuthResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 13, // 3: api.v1.services.auth.CreateTokenRequest.data:type_name -> api.v1.services.auth.CreateTokenRequest.Data + 14, // 4: api.v1.services.auth.ValidateTokenResponse.claims:type_name -> api.v1.services.auth.ValidateTokenResponse.ClaimsEntry + 15, // 5: api.v1.services.auth.DestroyTokenRequest.data:type_name -> api.v1.services.auth.DestroyTokenRequest.Data + 17, // 6: api.v1.services.auth.DestroyTokenResponse.empty:type_name -> google.protobuf.Empty + 16, // 7: api.v1.services.auth.AuthenticateRequest.data:type_name -> api.v1.services.auth.AuthenticateRequest.Data + 2, // 8: api.v1.services.auth.AuthService.ListAuthResources:input_type -> api.v1.services.auth.ListAuthResourcesRequest + 4, // 9: api.v1.services.auth.AuthService.CreateToken:input_type -> api.v1.services.auth.CreateTokenRequest + 6, // 10: api.v1.services.auth.AuthService.ValidateToken:input_type -> api.v1.services.auth.ValidateTokenRequest + 8, // 11: api.v1.services.auth.AuthService.DestroyToken:input_type -> api.v1.services.auth.DestroyTokenRequest + 10, // 12: api.v1.services.auth.AuthService.Authenticate:input_type -> api.v1.services.auth.AuthenticateRequest + 0, // 13: api.v1.services.auth.AuthService.AuthLogout:input_type -> api.v1.services.auth.AuthLogoutRequest + 3, // 14: api.v1.services.auth.AuthService.ListAuthResources:output_type -> api.v1.services.auth.ListAuthResourcesResponse + 5, // 15: api.v1.services.auth.AuthService.CreateToken:output_type -> api.v1.services.auth.CreateTokenResponse + 7, // 16: api.v1.services.auth.AuthService.ValidateToken:output_type -> api.v1.services.auth.ValidateTokenResponse + 9, // 17: api.v1.services.auth.AuthService.DestroyToken:output_type -> api.v1.services.auth.DestroyTokenResponse + 11, // 18: api.v1.services.auth.AuthService.Authenticate:output_type -> api.v1.services.auth.AuthenticateResponse + 1, // 19: api.v1.services.auth.AuthService.AuthLogout:output_type -> api.v1.services.auth.AuthLogoutResponse + 14, // [14:20] is the sub-list for method output_type + 8, // [8:14] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_auth_auth_proto_init() } +func file_auth_auth_proto_init() { + if File_auth_auth_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_auth_proto_rawDesc), len(file_auth_auth_proto_rawDesc)), + NumEnums: 0, + NumMessages: 17, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_auth_auth_proto_goTypes, + DependencyIndexes: file_auth_auth_proto_depIdxs, + MessageInfos: file_auth_auth_proto_msgTypes, + }.Build() + File_auth_auth_proto = out.File + file_auth_auth_proto_goTypes = nil + file_auth_auth_proto_depIdxs = nil +} diff --git a/api/v1/services/auth/auth.pb.gw.go b/api/v1/services/auth/auth.pb.gw.go new file mode 100644 index 00000000..40545037 --- /dev/null +++ b/api/v1/services/auth/auth.pb.gw.go @@ -0,0 +1,487 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: auth/auth.proto + +/* +Package auth is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package auth + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_AuthService_ListAuthResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_AuthService_ListAuthResources_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListAuthResourcesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ListAuthResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListAuthResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_AuthService_ListAuthResources_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListAuthResourcesRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ListAuthResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListAuthResources(ctx, &protoReq) + return msg, metadata, err +} + +func request_AuthService_CreateToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_AuthService_CreateToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateToken(ctx, &protoReq) + return msg, metadata, err +} + +var filter_AuthService_ValidateToken_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_AuthService_ValidateToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ValidateTokenRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ValidateToken_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ValidateToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_AuthService_ValidateToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ValidateTokenRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ValidateToken_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ValidateToken(ctx, &protoReq) + return msg, metadata, err +} + +func request_AuthService_DestroyToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DestroyTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.DestroyToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_AuthService_DestroyToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DestroyTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.DestroyToken(ctx, &protoReq) + return msg, metadata, err +} + +func request_AuthService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq AuthenticateRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.Authenticate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_AuthService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq AuthenticateRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.Authenticate(ctx, &protoReq) + return msg, metadata, err +} + +func request_AuthService_AuthLogout_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq AuthLogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.AuthLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_AuthService_AuthLogout_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq AuthLogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.AuthLogout(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterAuthServiceHandlerServer registers the http handlers for service AuthService to "mux". +// UnaryRPC :call AuthServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServiceServer) error { + mux.Handle(http.MethodGet, pattern_AuthService_ListAuthResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/auth/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_AuthService_ListAuthResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_ListAuthResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_AuthService_CreateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/auth/token")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_AuthService_CreateToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_CreateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_AuthService_ValidateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/auth/validate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_AuthService_ValidateToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_ValidateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_AuthService_DestroyToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/auth/destroy")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_AuthService_DestroyToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_DestroyToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_AuthService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/auth/authenticate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_AuthService_Authenticate_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_Authenticate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_AuthService_AuthLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/auth/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_AuthService_AuthLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_AuthLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterAuthServiceHandlerFromEndpoint is same as RegisterAuthServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterAuthServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterAuthServiceHandler(ctx, mux, conn) +} + +// RegisterAuthServiceHandler registers the http handlers for service AuthService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterAuthServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterAuthServiceHandlerClient(ctx, mux, NewAuthServiceClient(conn)) +} + +// RegisterAuthServiceHandlerClient registers the http handlers for service AuthService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AuthServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AuthServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "AuthServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthServiceClient) error { + mux.Handle(http.MethodGet, pattern_AuthService_ListAuthResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/auth/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_AuthService_ListAuthResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_ListAuthResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_AuthService_CreateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/auth/token")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_AuthService_CreateToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_CreateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_AuthService_ValidateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/auth/validate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_AuthService_ValidateToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_ValidateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_AuthService_DestroyToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/auth/destroy")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_AuthService_DestroyToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_DestroyToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_AuthService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/auth/authenticate")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_AuthService_Authenticate_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_Authenticate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_AuthService_AuthLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/auth/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_AuthService_AuthLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_AuthService_AuthLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_AuthService_ListAuthResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "resources"}, "")) + pattern_AuthService_CreateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "token"}, "")) + pattern_AuthService_ValidateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "validate"}, "")) + pattern_AuthService_DestroyToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "destroy"}, "")) + pattern_AuthService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "authenticate"}, "")) + pattern_AuthService_AuthLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "logout"}, "")) +) + +var ( + forward_AuthService_ListAuthResources_0 = runtime.ForwardResponseMessage + forward_AuthService_CreateToken_0 = runtime.ForwardResponseMessage + forward_AuthService_ValidateToken_0 = runtime.ForwardResponseMessage + forward_AuthService_DestroyToken_0 = runtime.ForwardResponseMessage + forward_AuthService_Authenticate_0 = runtime.ForwardResponseMessage + forward_AuthService_AuthLogout_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/auth/auth.pb.validate.go b/api/v1/services/auth/auth.pb.validate.go new file mode 100644 index 00000000..3cc97d16 --- /dev/null +++ b/api/v1/services/auth/auth.pb.validate.go @@ -0,0 +1,1910 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: auth/auth.proto + +package auth + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on AuthLogoutRequest 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 *AuthLogoutRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AuthLogoutRequest 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 +// AuthLogoutRequestMultiError, or nil if none found. +func (m *AuthLogoutRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *AuthLogoutRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AuthLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AuthLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AuthLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return AuthLogoutRequestMultiError(errors) + } + + return nil +} + +// AuthLogoutRequestMultiError is an error wrapping multiple validation errors +// returned by AuthLogoutRequest.ValidateAll() if the designated constraints +// aren't met. +type AuthLogoutRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AuthLogoutRequestMultiError) 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 AuthLogoutRequestMultiError) AllErrors() []error { return m } + +// AuthLogoutRequestValidationError is the validation error returned by +// AuthLogoutRequest.Validate if the designated constraints aren't met. +type AuthLogoutRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AuthLogoutRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AuthLogoutRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AuthLogoutRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AuthLogoutRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AuthLogoutRequestValidationError) ErrorName() string { + return "AuthLogoutRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e AuthLogoutRequestValidationError) 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 %sAuthLogoutRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AuthLogoutRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AuthLogoutRequestValidationError{} + +// Validate checks the field values on AuthLogoutResponse 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 *AuthLogoutResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AuthLogoutResponse 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 +// AuthLogoutResponseMultiError, or nil if none found. +func (m *AuthLogoutResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *AuthLogoutResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AuthLogoutResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AuthLogoutResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AuthLogoutResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return AuthLogoutResponseMultiError(errors) + } + + return nil +} + +// AuthLogoutResponseMultiError is an error wrapping multiple validation errors +// returned by AuthLogoutResponse.ValidateAll() if the designated constraints +// aren't met. +type AuthLogoutResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AuthLogoutResponseMultiError) 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 AuthLogoutResponseMultiError) AllErrors() []error { return m } + +// AuthLogoutResponseValidationError is the validation error returned by +// AuthLogoutResponse.Validate if the designated constraints aren't met. +type AuthLogoutResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AuthLogoutResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AuthLogoutResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AuthLogoutResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AuthLogoutResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AuthLogoutResponseValidationError) ErrorName() string { + return "AuthLogoutResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e AuthLogoutResponseValidationError) 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 %sAuthLogoutResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AuthLogoutResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AuthLogoutResponseValidationError{} + +// Validate checks the field values on ListAuthResourcesRequest 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 *ListAuthResourcesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListAuthResourcesRequest 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 +// ListAuthResourcesRequestMultiError, or nil if none found. +func (m *ListAuthResourcesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListAuthResourcesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for Current + + // no validation rules for NoPaging + + if len(errors) > 0 { + return ListAuthResourcesRequestMultiError(errors) + } + + return nil +} + +// ListAuthResourcesRequestMultiError is an error wrapping multiple validation +// errors returned by ListAuthResourcesRequest.ValidateAll() if the designated +// constraints aren't met. +type ListAuthResourcesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListAuthResourcesRequestMultiError) 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 ListAuthResourcesRequestMultiError) AllErrors() []error { return m } + +// ListAuthResourcesRequestValidationError is the validation error returned by +// ListAuthResourcesRequest.Validate if the designated constraints aren't met. +type ListAuthResourcesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListAuthResourcesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListAuthResourcesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListAuthResourcesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListAuthResourcesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListAuthResourcesRequestValidationError) ErrorName() string { + return "ListAuthResourcesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListAuthResourcesRequestValidationError) 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 %sListAuthResourcesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListAuthResourcesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListAuthResourcesRequestValidationError{} + +// Validate checks the field values on ListAuthResourcesResponse 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 *ListAuthResourcesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListAuthResourcesResponse 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 +// ListAuthResourcesResponseMultiError, or nil if none found. +func (m *ListAuthResourcesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListAuthResourcesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListAuthResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListAuthResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListAuthResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for TotalSize + + if len(errors) > 0 { + return ListAuthResourcesResponseMultiError(errors) + } + + return nil +} + +// ListAuthResourcesResponseMultiError is an error wrapping multiple validation +// errors returned by ListAuthResourcesResponse.ValidateAll() if the +// designated constraints aren't met. +type ListAuthResourcesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListAuthResourcesResponseMultiError) 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 ListAuthResourcesResponseMultiError) AllErrors() []error { return m } + +// ListAuthResourcesResponseValidationError is the validation error returned by +// ListAuthResourcesResponse.Validate if the designated constraints aren't met. +type ListAuthResourcesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListAuthResourcesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListAuthResourcesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListAuthResourcesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListAuthResourcesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListAuthResourcesResponseValidationError) ErrorName() string { + return "ListAuthResourcesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListAuthResourcesResponseValidationError) 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 %sListAuthResourcesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListAuthResourcesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListAuthResourcesResponseValidationError{} + +// Validate checks the field values on CreateTokenRequest 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 *CreateTokenRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateTokenRequest 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 +// CreateTokenRequestMultiError, or nil if none found. +func (m *CreateTokenRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateTokenRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateTokenRequestMultiError(errors) + } + + return nil +} + +// CreateTokenRequestMultiError is an error wrapping multiple validation errors +// returned by CreateTokenRequest.ValidateAll() if the designated constraints +// aren't met. +type CreateTokenRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateTokenRequestMultiError) 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 CreateTokenRequestMultiError) AllErrors() []error { return m } + +// CreateTokenRequestValidationError is the validation error returned by +// CreateTokenRequest.Validate if the designated constraints aren't met. +type CreateTokenRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateTokenRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateTokenRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateTokenRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateTokenRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateTokenRequestValidationError) ErrorName() string { + return "CreateTokenRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateTokenRequestValidationError) 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 %sCreateTokenRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateTokenRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateTokenRequestValidationError{} + +// Validate checks the field values on CreateTokenResponse 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 *CreateTokenResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateTokenResponse 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 +// CreateTokenResponseMultiError, or nil if none found. +func (m *CreateTokenResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateTokenResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Token + + if len(errors) > 0 { + return CreateTokenResponseMultiError(errors) + } + + return nil +} + +// CreateTokenResponseMultiError is an error wrapping multiple validation +// errors returned by CreateTokenResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateTokenResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateTokenResponseMultiError) 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 CreateTokenResponseMultiError) AllErrors() []error { return m } + +// CreateTokenResponseValidationError is the validation error returned by +// CreateTokenResponse.Validate if the designated constraints aren't met. +type CreateTokenResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateTokenResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateTokenResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateTokenResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateTokenResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateTokenResponseValidationError) ErrorName() string { + return "CreateTokenResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateTokenResponseValidationError) 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 %sCreateTokenResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateTokenResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateTokenResponseValidationError{} + +// Validate checks the field values on ValidateTokenRequest 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 *ValidateTokenRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ValidateTokenRequest 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 +// ValidateTokenRequestMultiError, or nil if none found. +func (m *ValidateTokenRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ValidateTokenRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Token + + if len(errors) > 0 { + return ValidateTokenRequestMultiError(errors) + } + + return nil +} + +// ValidateTokenRequestMultiError is an error wrapping multiple validation +// errors returned by ValidateTokenRequest.ValidateAll() if the designated +// constraints aren't met. +type ValidateTokenRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ValidateTokenRequestMultiError) 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 ValidateTokenRequestMultiError) AllErrors() []error { return m } + +// ValidateTokenRequestValidationError is the validation error returned by +// ValidateTokenRequest.Validate if the designated constraints aren't met. +type ValidateTokenRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ValidateTokenRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ValidateTokenRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ValidateTokenRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ValidateTokenRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ValidateTokenRequestValidationError) ErrorName() string { + return "ValidateTokenRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ValidateTokenRequestValidationError) 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 %sValidateTokenRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ValidateTokenRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ValidateTokenRequestValidationError{} + +// Validate checks the field values on ValidateTokenResponse 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 *ValidateTokenResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ValidateTokenResponse 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 +// ValidateTokenResponseMultiError, or nil if none found. +func (m *ValidateTokenResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ValidateTokenResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for IsValid + + // no validation rules for Claims + + if len(errors) > 0 { + return ValidateTokenResponseMultiError(errors) + } + + return nil +} + +// ValidateTokenResponseMultiError is an error wrapping multiple validation +// errors returned by ValidateTokenResponse.ValidateAll() if the designated +// constraints aren't met. +type ValidateTokenResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ValidateTokenResponseMultiError) 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 ValidateTokenResponseMultiError) AllErrors() []error { return m } + +// ValidateTokenResponseValidationError is the validation error returned by +// ValidateTokenResponse.Validate if the designated constraints aren't met. +type ValidateTokenResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ValidateTokenResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ValidateTokenResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ValidateTokenResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ValidateTokenResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ValidateTokenResponseValidationError) ErrorName() string { + return "ValidateTokenResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ValidateTokenResponseValidationError) 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 %sValidateTokenResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ValidateTokenResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ValidateTokenResponseValidationError{} + +// Validate checks the field values on DestroyTokenRequest 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 *DestroyTokenRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DestroyTokenRequest 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 +// DestroyTokenRequestMultiError, or nil if none found. +func (m *DestroyTokenRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DestroyTokenRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DestroyTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DestroyTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DestroyTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DestroyTokenRequestMultiError(errors) + } + + return nil +} + +// DestroyTokenRequestMultiError is an error wrapping multiple validation +// errors returned by DestroyTokenRequest.ValidateAll() if the designated +// constraints aren't met. +type DestroyTokenRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DestroyTokenRequestMultiError) 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 DestroyTokenRequestMultiError) AllErrors() []error { return m } + +// DestroyTokenRequestValidationError is the validation error returned by +// DestroyTokenRequest.Validate if the designated constraints aren't met. +type DestroyTokenRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DestroyTokenRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DestroyTokenRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DestroyTokenRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DestroyTokenRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DestroyTokenRequestValidationError) ErrorName() string { + return "DestroyTokenRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DestroyTokenRequestValidationError) 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 %sDestroyTokenRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DestroyTokenRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DestroyTokenRequestValidationError{} + +// Validate checks the field values on DestroyTokenResponse 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 *DestroyTokenResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DestroyTokenResponse 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 +// DestroyTokenResponseMultiError, or nil if none found. +func (m *DestroyTokenResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DestroyTokenResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DestroyTokenResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DestroyTokenResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DestroyTokenResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DestroyTokenResponseMultiError(errors) + } + + return nil +} + +// DestroyTokenResponseMultiError is an error wrapping multiple validation +// errors returned by DestroyTokenResponse.ValidateAll() if the designated +// constraints aren't met. +type DestroyTokenResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DestroyTokenResponseMultiError) 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 DestroyTokenResponseMultiError) AllErrors() []error { return m } + +// DestroyTokenResponseValidationError is the validation error returned by +// DestroyTokenResponse.Validate if the designated constraints aren't met. +type DestroyTokenResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DestroyTokenResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DestroyTokenResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DestroyTokenResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DestroyTokenResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DestroyTokenResponseValidationError) ErrorName() string { + return "DestroyTokenResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DestroyTokenResponseValidationError) 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 %sDestroyTokenResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DestroyTokenResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DestroyTokenResponseValidationError{} + +// Validate checks the field values on AuthenticateRequest 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 *AuthenticateRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AuthenticateRequest 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 +// AuthenticateRequestMultiError, or nil if none found. +func (m *AuthenticateRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *AuthenticateRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, AuthenticateRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, AuthenticateRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return AuthenticateRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return AuthenticateRequestMultiError(errors) + } + + return nil +} + +// AuthenticateRequestMultiError is an error wrapping multiple validation +// errors returned by AuthenticateRequest.ValidateAll() if the designated +// constraints aren't met. +type AuthenticateRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AuthenticateRequestMultiError) 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 AuthenticateRequestMultiError) AllErrors() []error { return m } + +// AuthenticateRequestValidationError is the validation error returned by +// AuthenticateRequest.Validate if the designated constraints aren't met. +type AuthenticateRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AuthenticateRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AuthenticateRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AuthenticateRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AuthenticateRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AuthenticateRequestValidationError) ErrorName() string { + return "AuthenticateRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e AuthenticateRequestValidationError) 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 %sAuthenticateRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AuthenticateRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AuthenticateRequestValidationError{} + +// Validate checks the field values on AuthenticateResponse 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 *AuthenticateResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AuthenticateResponse 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 +// AuthenticateResponseMultiError, or nil if none found. +func (m *AuthenticateResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *AuthenticateResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for IsValid + + if len(errors) > 0 { + return AuthenticateResponseMultiError(errors) + } + + return nil +} + +// AuthenticateResponseMultiError is an error wrapping multiple validation +// errors returned by AuthenticateResponse.ValidateAll() if the designated +// constraints aren't met. +type AuthenticateResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AuthenticateResponseMultiError) 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 AuthenticateResponseMultiError) AllErrors() []error { return m } + +// AuthenticateResponseValidationError is the validation error returned by +// AuthenticateResponse.Validate if the designated constraints aren't met. +type AuthenticateResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AuthenticateResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AuthenticateResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AuthenticateResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AuthenticateResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AuthenticateResponseValidationError) ErrorName() string { + return "AuthenticateResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e AuthenticateResponseValidationError) 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 %sAuthenticateResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AuthenticateResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AuthenticateResponseValidationError{} + +// Validate checks the field values on AuthLogoutRequest_Data 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 *AuthLogoutRequest_Data) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AuthLogoutRequest_Data 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 +// AuthLogoutRequest_DataMultiError, or nil if none found. +func (m *AuthLogoutRequest_Data) ValidateAll() error { + return m.validate(true) +} + +func (m *AuthLogoutRequest_Data) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Token + + if len(errors) > 0 { + return AuthLogoutRequest_DataMultiError(errors) + } + + return nil +} + +// AuthLogoutRequest_DataMultiError is an error wrapping multiple validation +// errors returned by AuthLogoutRequest_Data.ValidateAll() if the designated +// constraints aren't met. +type AuthLogoutRequest_DataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AuthLogoutRequest_DataMultiError) 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 AuthLogoutRequest_DataMultiError) AllErrors() []error { return m } + +// AuthLogoutRequest_DataValidationError is the validation error returned by +// AuthLogoutRequest_Data.Validate if the designated constraints aren't met. +type AuthLogoutRequest_DataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AuthLogoutRequest_DataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AuthLogoutRequest_DataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AuthLogoutRequest_DataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AuthLogoutRequest_DataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AuthLogoutRequest_DataValidationError) ErrorName() string { + return "AuthLogoutRequest_DataValidationError" +} + +// Error satisfies the builtin error interface +func (e AuthLogoutRequest_DataValidationError) 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 %sAuthLogoutRequest_Data.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AuthLogoutRequest_DataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AuthLogoutRequest_DataValidationError{} + +// Validate checks the field values on CreateTokenRequest_Data 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 *CreateTokenRequest_Data) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateTokenRequest_Data 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 +// CreateTokenRequest_DataMultiError, or nil if none found. +func (m *CreateTokenRequest_Data) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateTokenRequest_Data) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for UserId + + if len(errors) > 0 { + return CreateTokenRequest_DataMultiError(errors) + } + + return nil +} + +// CreateTokenRequest_DataMultiError is an error wrapping multiple validation +// errors returned by CreateTokenRequest_Data.ValidateAll() if the designated +// constraints aren't met. +type CreateTokenRequest_DataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateTokenRequest_DataMultiError) 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 CreateTokenRequest_DataMultiError) AllErrors() []error { return m } + +// CreateTokenRequest_DataValidationError is the validation error returned by +// CreateTokenRequest_Data.Validate if the designated constraints aren't met. +type CreateTokenRequest_DataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateTokenRequest_DataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateTokenRequest_DataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateTokenRequest_DataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateTokenRequest_DataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateTokenRequest_DataValidationError) ErrorName() string { + return "CreateTokenRequest_DataValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateTokenRequest_DataValidationError) 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 %sCreateTokenRequest_Data.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateTokenRequest_DataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateTokenRequest_DataValidationError{} + +// Validate checks the field values on DestroyTokenRequest_Data 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 *DestroyTokenRequest_Data) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DestroyTokenRequest_Data 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 +// DestroyTokenRequest_DataMultiError, or nil if none found. +func (m *DestroyTokenRequest_Data) ValidateAll() error { + return m.validate(true) +} + +func (m *DestroyTokenRequest_Data) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Token + + if len(errors) > 0 { + return DestroyTokenRequest_DataMultiError(errors) + } + + return nil +} + +// DestroyTokenRequest_DataMultiError is an error wrapping multiple validation +// errors returned by DestroyTokenRequest_Data.ValidateAll() if the designated +// constraints aren't met. +type DestroyTokenRequest_DataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DestroyTokenRequest_DataMultiError) 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 DestroyTokenRequest_DataMultiError) AllErrors() []error { return m } + +// DestroyTokenRequest_DataValidationError is the validation error returned by +// DestroyTokenRequest_Data.Validate if the designated constraints aren't met. +type DestroyTokenRequest_DataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DestroyTokenRequest_DataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DestroyTokenRequest_DataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DestroyTokenRequest_DataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DestroyTokenRequest_DataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DestroyTokenRequest_DataValidationError) ErrorName() string { + return "DestroyTokenRequest_DataValidationError" +} + +// Error satisfies the builtin error interface +func (e DestroyTokenRequest_DataValidationError) 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 %sDestroyTokenRequest_Data.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DestroyTokenRequest_DataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DestroyTokenRequest_DataValidationError{} + +// Validate checks the field values on AuthenticateRequest_Data 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 *AuthenticateRequest_Data) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on AuthenticateRequest_Data 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 +// AuthenticateRequest_DataMultiError, or nil if none found. +func (m *AuthenticateRequest_Data) ValidateAll() error { + return m.validate(true) +} + +func (m *AuthenticateRequest_Data) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Token + + // no validation rules for Path + + // no validation rules for Method + + // no validation rules for Operation + + if len(errors) > 0 { + return AuthenticateRequest_DataMultiError(errors) + } + + return nil +} + +// AuthenticateRequest_DataMultiError is an error wrapping multiple validation +// errors returned by AuthenticateRequest_Data.ValidateAll() if the designated +// constraints aren't met. +type AuthenticateRequest_DataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m AuthenticateRequest_DataMultiError) 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 AuthenticateRequest_DataMultiError) AllErrors() []error { return m } + +// AuthenticateRequest_DataValidationError is the validation error returned by +// AuthenticateRequest_Data.Validate if the designated constraints aren't met. +type AuthenticateRequest_DataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e AuthenticateRequest_DataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e AuthenticateRequest_DataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e AuthenticateRequest_DataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e AuthenticateRequest_DataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e AuthenticateRequest_DataValidationError) ErrorName() string { + return "AuthenticateRequest_DataValidationError" +} + +// Error satisfies the builtin error interface +func (e AuthenticateRequest_DataValidationError) 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 %sAuthenticateRequest_Data.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = AuthenticateRequest_DataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = AuthenticateRequest_DataValidationError{} diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go new file mode 100644 index 00000000..e2e5322b --- /dev/null +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -0,0 +1,450 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: auth/auth.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const AuthServiceAuthLogoutBridgeOperation = "/api.v1.services.auth.AuthService/AuthLogout" +const AuthServiceAuthenticateBridgeOperation = "/api.v1.services.auth.AuthService/Authenticate" +const AuthServiceCreateTokenBridgeOperation = "/api.v1.services.auth.AuthService/CreateToken" +const AuthServiceDestroyTokenBridgeOperation = "/api.v1.services.auth.AuthService/DestroyToken" +const AuthServiceListAuthResourcesBridgeOperation = "/api.v1.services.auth.AuthService/ListAuthResources" +const AuthServiceValidateTokenBridgeOperation = "/api.v1.services.auth.AuthService/ValidateToken" + +type AuthServiceBridgeServer interface { + // AuthLogout logs out a user. + AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) + // Authenticate authenticates a user. + Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) + // CreateToken generates a new JWT token for the given user. + CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) + // DestroyToken invalidates a JWT token. + DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) + // ListAuthResources returns a list of Auths. + ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) + // ValidateToken verifies the validity of a JWT token. + ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) +} + +type AuthServiceHooker interface { + AuthServiceAuthLogoutHooker + AuthServiceAuthenticateHooker + AuthServiceCreateTokenHooker + AuthServiceDestroyTokenHooker + AuthServiceListAuthResourcesHooker + AuthServiceValidateTokenHooker +} + +type AuthServiceHookedBridger interface { + AuthServiceHooker + AuthServiceBridgeServer +} +type AuthServiceAuthLogoutHooker interface { + PrepareAuthLogout(http.Context, *AuthLogoutRequest) (context.Context, error) + CompleteAuthLogout(http.Context, *AuthLogoutRequest, *AuthLogoutResponse) error +} +type AuthServiceAuthenticateHooker interface { + PrepareAuthenticate(http.Context, *AuthenticateRequest) (context.Context, error) + CompleteAuthenticate(http.Context, *AuthenticateRequest, *AuthenticateResponse) error +} +type AuthServiceCreateTokenHooker interface { + PrepareCreateToken(http.Context, *CreateTokenRequest) (context.Context, error) + CompleteCreateToken(http.Context, *CreateTokenRequest, *CreateTokenResponse) error +} +type AuthServiceDestroyTokenHooker interface { + PrepareDestroyToken(http.Context, *DestroyTokenRequest) (context.Context, error) + CompleteDestroyToken(http.Context, *DestroyTokenRequest, *DestroyTokenResponse) error +} +type AuthServiceListAuthResourcesHooker interface { + PrepareListAuthResources(http.Context, *ListAuthResourcesRequest) (context.Context, error) + CompleteListAuthResources(http.Context, *ListAuthResourcesRequest, *ListAuthResourcesResponse) error +} +type AuthServiceValidateTokenHooker interface { + PrepareValidateToken(http.Context, *ValidateTokenRequest) (context.Context, error) + CompleteValidateToken(http.Context, *ValidateTokenRequest, *ValidateTokenResponse) error +} + +func RegisterAuthServiceBridgeServer(s *http.Server, srv AuthServiceHookedBridger) { + r := s.Route("/") + r.GET("/auth/resources", _AuthService_ListAuthResources0_Bridge_Handler(srv)) + r.POST("/auth/token", _AuthService_CreateToken0_Bridge_Handler(srv)) + r.GET("/auth/validate", _AuthService_ValidateToken0_Bridge_Handler(srv)) + r.POST("/auth/destroy", _AuthService_DestroyToken0_Bridge_Handler(srv)) + r.POST("/auth/authenticate", _AuthService_Authenticate0_Bridge_Handler(srv)) + r.POST("/auth/logout", _AuthService_AuthLogout0_Bridge_Handler(srv)) +} + +func _AuthService_ListAuthResources0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListAuthResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceListAuthResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) + }) + + newctx, err := srv.PrepareListAuthResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListAuthResources(ctx, &in, out.(*ListAuthResourcesResponse)) + } +} + +func _AuthService_CreateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceCreateToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateToken(ctx, req.(*CreateTokenRequest)) + }) + + newctx, err := srv.PrepareCreateToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateToken(ctx, &in, out.(*CreateTokenResponse)) + } +} + +func _AuthService_ValidateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ValidateTokenRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceValidateToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ValidateToken(ctx, req.(*ValidateTokenRequest)) + }) + + newctx, err := srv.PrepareValidateToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteValidateToken(ctx, &in, out.(*ValidateTokenResponse)) + } +} + +func _AuthService_DestroyToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DestroyTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceDestroyToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DestroyToken(ctx, req.(*DestroyTokenRequest)) + }) + + newctx, err := srv.PrepareDestroyToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDestroyToken(ctx, &in, out.(*DestroyTokenResponse)) + } +} + +func _AuthService_Authenticate0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in AuthenticateRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceAuthenticate) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Authenticate(ctx, req.(*AuthenticateRequest)) + }) + + newctx, err := srv.PrepareAuthenticate(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteAuthenticate(ctx, &in, out.(*AuthenticateResponse)) + } +} + +func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in AuthLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceAuthLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.AuthLogout(ctx, req.(*AuthLogoutRequest)) + }) + + newctx, err := srv.PrepareAuthLogout(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteAuthLogout(ctx, &in, out.(*AuthLogoutResponse)) + } +} + +// UnimplementedAuthServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedAuthServiceHooked struct{} + +func (UnimplementedAuthServiceHooked) PrepareAuthLogout(ctx http.Context, in *AuthLogoutRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceHooked) CompleteAuthLogout(ctx http.Context, in *AuthLogoutRequest, out *AuthLogoutResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedAuthServiceHooked) PrepareAuthenticate(ctx http.Context, in *AuthenticateRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceHooked) CompleteAuthenticate(ctx http.Context, in *AuthenticateRequest, out *AuthenticateResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedAuthServiceHooked) PrepareCreateToken(ctx http.Context, in *CreateTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceHooked) CompleteCreateToken(ctx http.Context, in *CreateTokenRequest, out *CreateTokenResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedAuthServiceHooked) PrepareDestroyToken(ctx http.Context, in *DestroyTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceHooked) CompleteDestroyToken(ctx http.Context, in *DestroyTokenRequest, out *DestroyTokenResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedAuthServiceHooked) PrepareListAuthResources(ctx http.Context, in *ListAuthResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceHooked) CompleteListAuthResources(ctx http.Context, in *ListAuthResourcesRequest, out *ListAuthResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedAuthServiceHooked) PrepareValidateToken(ctx http.Context, in *ValidateTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceHooked) CompleteValidateToken(ctx http.Context, in *ValidateTokenRequest, out *ValidateTokenResponse) error { + return ctx.Result(200, out) +} + +func WithAuthServiceHook(h AuthServiceHooker) func(AuthServiceBridgeServer) AuthServiceHookedBridger { + return func(srv AuthServiceBridgeServer) AuthServiceHookedBridger { + return AuthServiceHookedBridge{AuthServiceBridgeServer: srv, AuthServiceHooker: h} + } +} + +// AuthServiceHookedBridge is a bridge between the HTTP and gRPC implementations of AuthService. +// It implements the HTTP and gRPC implementations of AuthService. +// It forwards requests and responses between the two implementations. +type AuthServiceHookedBridge struct { + AuthServiceBridgeServer + AuthServiceHooker +} + +type AuthServiceHTTPBridgeImpl struct { + client AuthServiceHTTPClient +} + +func NewAuthServiceHTTPBridge(client *http.Client) AuthServiceHTTPServer { + return &AuthServiceHTTPBridgeImpl{client: NewAuthServiceHTTPClient(client)} +} + +func (c *AuthServiceHTTPBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { + return c.client.AuthLogout(ctx, in) +} + +func (c *AuthServiceHTTPBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { + return c.client.Authenticate(ctx, in) +} + +func (c *AuthServiceHTTPBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { + return c.client.CreateToken(ctx, in) +} + +func (c *AuthServiceHTTPBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { + return c.client.DestroyToken(ctx, in) +} + +func (c *AuthServiceHTTPBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { + return c.client.ListAuthResources(ctx, in) +} + +func (c *AuthServiceHTTPBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { + return c.client.ValidateToken(ctx, in) +} + +type AuthServiceBridgeImpl struct { + client AuthServiceClient +} + +func NewAuthServiceBridge(client grpc.ClientConnInterface) AuthServiceServer { + return &AuthServiceBridgeImpl{client: NewAuthServiceClient(client)} +} + +func (c *AuthServiceBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { + return c.client.AuthLogout(ctx, in) +} + +func (c *AuthServiceBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { + return c.client.Authenticate(ctx, in) +} + +func (c *AuthServiceBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { + return c.client.CreateToken(ctx, in) +} + +func (c *AuthServiceBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { + return c.client.DestroyToken(ctx, in) +} + +func (c *AuthServiceBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { + return c.client.ListAuthResources(ctx, in) +} + +func (c *AuthServiceBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { + return c.client.ValidateToken(ctx, in) +} + +func (c *AuthServiceBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} + +type AuthServiceGRPC2HTTPBridgeImpl struct { + client AuthServiceClient +} + +func NewAuthServiceGRPC2HTTP(client grpc.ClientConnInterface) AuthServiceHTTPServer { + return &AuthServiceGRPC2HTTPBridgeImpl{client: NewAuthServiceClient(client)} +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { + return c.client.AuthLogout(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { + return c.client.Authenticate(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { + return c.client.CreateToken(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { + return c.client.DestroyToken(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { + return c.client.ListAuthResources(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { + return c.client.ValidateToken(ctx, in) +} + +type AuthServiceHTTP2GRPCBridgeImpl struct { + client AuthServiceHTTPClient +} + +func NewAuthServiceHTTP2GRPC(client *http.Client) AuthServiceServer { + return &AuthServiceHTTP2GRPCBridgeImpl{client: NewAuthServiceHTTPClient(client)} +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { + return c.client.AuthLogout(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { + return c.client.Authenticate(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { + return c.client.CreateToken(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { + return c.client.DestroyToken(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { + return c.client.ListAuthResources(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { + return c.client.ValidateToken(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} diff --git a/api/v1/services/auth/auth_grpc.pb.go b/api/v1/services/auth/auth_grpc.pb.go new file mode 100644 index 00000000..fcac5f0b --- /dev/null +++ b/api/v1/services/auth/auth_grpc.pb.go @@ -0,0 +1,323 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: auth/auth.proto + +package auth + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + AuthService_ListAuthResources_FullMethodName = "/api.v1.services.auth.AuthService/ListAuthResources" + AuthService_CreateToken_FullMethodName = "/api.v1.services.auth.AuthService/CreateToken" + AuthService_ValidateToken_FullMethodName = "/api.v1.services.auth.AuthService/ValidateToken" + AuthService_DestroyToken_FullMethodName = "/api.v1.services.auth.AuthService/DestroyToken" + AuthService_Authenticate_FullMethodName = "/api.v1.services.auth.AuthService/Authenticate" + AuthService_AuthLogout_FullMethodName = "/api.v1.services.auth.AuthService/AuthLogout" +) + +// AuthServiceClient is the client API for AuthService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type AuthServiceClient interface { + // ListAuthResources returns a list of Auths. + ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...grpc.CallOption) (*ListAuthResourcesResponse, error) + // CreateToken generates a new JWT token for the given user. + CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...grpc.CallOption) (*CreateTokenResponse, error) + // ValidateToken verifies the validity of a JWT token. + ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*ValidateTokenResponse, error) + // DestroyToken invalidates a JWT token. + DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...grpc.CallOption) (*DestroyTokenResponse, error) + // Authenticate authenticates a user. + Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) + // AuthLogout logs out a user. + AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...grpc.CallOption) (*AuthLogoutResponse, error) +} + +type authServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { + return &authServiceClient{cc} +} + +func (c *authServiceClient) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...grpc.CallOption) (*ListAuthResourcesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListAuthResourcesResponse) + err := c.cc.Invoke(ctx, AuthService_ListAuthResources_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authServiceClient) CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...grpc.CallOption) (*CreateTokenResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateTokenResponse) + err := c.cc.Invoke(ctx, AuthService_CreateToken_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authServiceClient) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*ValidateTokenResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ValidateTokenResponse) + err := c.cc.Invoke(ctx, AuthService_ValidateToken_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authServiceClient) DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...grpc.CallOption) (*DestroyTokenResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DestroyTokenResponse) + err := c.cc.Invoke(ctx, AuthService_DestroyToken_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authServiceClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(AuthenticateResponse) + err := c.cc.Invoke(ctx, AuthService_Authenticate_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authServiceClient) AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...grpc.CallOption) (*AuthLogoutResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(AuthLogoutResponse) + err := c.cc.Invoke(ctx, AuthService_AuthLogout_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AuthServiceServer is the server API for AuthService service. +// All implementations must embed UnimplementedAuthServiceServer +// for forward compatibility. +type AuthServiceServer interface { + // ListAuthResources returns a list of Auths. + ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) + // CreateToken generates a new JWT token for the given user. + CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) + // ValidateToken verifies the validity of a JWT token. + ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) + // DestroyToken invalidates a JWT token. + DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) + // Authenticate authenticates a user. + Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) + // AuthLogout logs out a user. + AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) + mustEmbedUnimplementedAuthServiceServer() +} + +// UnimplementedAuthServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedAuthServiceServer struct{} + +func (UnimplementedAuthServiceServer) ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListAuthResources not implemented") +} +func (UnimplementedAuthServiceServer) CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateToken not implemented") +} +func (UnimplementedAuthServiceServer) ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ValidateToken not implemented") +} +func (UnimplementedAuthServiceServer) DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DestroyToken not implemented") +} +func (UnimplementedAuthServiceServer) Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") +} +func (UnimplementedAuthServiceServer) AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AuthLogout not implemented") +} +func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} +func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} + +// UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AuthServiceServer will +// result in compilation errors. +type UnsafeAuthServiceServer interface { + mustEmbedUnimplementedAuthServiceServer() +} + +func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { + // If the following call pancis, it indicates UnimplementedAuthServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&AuthService_ServiceDesc, srv) +} + +func _AuthService_ListAuthResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListAuthResourcesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).ListAuthResources(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_ListAuthResources_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AuthService_CreateToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).CreateToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_CreateToken_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).CreateToken(ctx, req.(*CreateTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AuthService_ValidateToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ValidateTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).ValidateToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_ValidateToken_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).ValidateToken(ctx, req.(*ValidateTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AuthService_DestroyToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DestroyTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).DestroyToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_DestroyToken_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).DestroyToken(ctx, req.(*DestroyTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AuthService_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AuthenticateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).Authenticate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_Authenticate_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).Authenticate(ctx, req.(*AuthenticateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _AuthService_AuthLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AuthLogoutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).AuthLogout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_AuthLogout_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).AuthLogout(ctx, req.(*AuthLogoutRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var AuthService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.auth.AuthService", + HandlerType: (*AuthServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListAuthResources", + Handler: _AuthService_ListAuthResources_Handler, + }, + { + MethodName: "CreateToken", + Handler: _AuthService_CreateToken_Handler, + }, + { + MethodName: "ValidateToken", + Handler: _AuthService_ValidateToken_Handler, + }, + { + MethodName: "DestroyToken", + Handler: _AuthService_DestroyToken_Handler, + }, + { + MethodName: "Authenticate", + Handler: _AuthService_Authenticate_Handler, + }, + { + MethodName: "AuthLogout", + Handler: _AuthService_AuthLogout_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "auth/auth.proto", +} diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go new file mode 100644 index 00000000..cd009a40 --- /dev/null +++ b/api/v1/services/auth/auth_http.pb.go @@ -0,0 +1,285 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: auth/auth.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationAuthServiceAuthLogout = "/api.v1.services.auth.AuthService/AuthLogout" +const OperationAuthServiceAuthenticate = "/api.v1.services.auth.AuthService/Authenticate" +const OperationAuthServiceCreateToken = "/api.v1.services.auth.AuthService/CreateToken" +const OperationAuthServiceDestroyToken = "/api.v1.services.auth.AuthService/DestroyToken" +const OperationAuthServiceListAuthResources = "/api.v1.services.auth.AuthService/ListAuthResources" +const OperationAuthServiceValidateToken = "/api.v1.services.auth.AuthService/ValidateToken" + +type AuthServiceHTTPServer interface { + // AuthLogout AuthLogout logs out a user. + AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) + // Authenticate Authenticate authenticates a user. + Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) + // CreateToken CreateToken generates a new JWT token for the given user. + CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) + // DestroyToken DestroyToken invalidates a JWT token. + DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) + // ListAuthResources ListAuthResources returns a list of Auths. + ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) + // ValidateToken ValidateToken verifies the validity of a JWT token. + ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) +} + +func RegisterAuthServiceHTTPServer(s *http.Server, srv AuthServiceHTTPServer) { + r := s.Route("/") + r.GET("/auth/resources", _AuthService_ListAuthResources0_HTTP_Handler(srv)) + r.POST("/auth/token", _AuthService_CreateToken0_HTTP_Handler(srv)) + r.GET("/auth/validate", _AuthService_ValidateToken0_HTTP_Handler(srv)) + r.POST("/auth/destroy", _AuthService_DestroyToken0_HTTP_Handler(srv)) + r.POST("/auth/authenticate", _AuthService_Authenticate0_HTTP_Handler(srv)) + r.POST("/auth/logout", _AuthService_AuthLogout0_HTTP_Handler(srv)) +} + +func _AuthService_ListAuthResources0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListAuthResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceListAuthResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListAuthResourcesResponse) + return ctx.Result(200, reply) + } +} + +func _AuthService_CreateToken0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceCreateToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateToken(ctx, req.(*CreateTokenRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateTokenResponse) + return ctx.Result(200, reply) + } +} + +func _AuthService_ValidateToken0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ValidateTokenRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceValidateToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ValidateToken(ctx, req.(*ValidateTokenRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ValidateTokenResponse) + return ctx.Result(200, reply) + } +} + +func _AuthService_DestroyToken0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DestroyTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceDestroyToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DestroyToken(ctx, req.(*DestroyTokenRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DestroyTokenResponse) + return ctx.Result(200, reply) + } +} + +func _AuthService_Authenticate0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in AuthenticateRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceAuthenticate) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Authenticate(ctx, req.(*AuthenticateRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*AuthenticateResponse) + return ctx.Result(200, reply) + } +} + +func _AuthService_AuthLogout0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in AuthLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationAuthServiceAuthLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.AuthLogout(ctx, req.(*AuthLogoutRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*AuthLogoutResponse) + return ctx.Result(200, reply) + } +} + +type AuthServiceHTTPClient interface { + // AuthLogout AuthLogout logs out a user. + AuthLogout(ctx context.Context, req *AuthLogoutRequest, opts ...http.CallOption) (rsp *AuthLogoutResponse, err error) + // Authenticate Authenticate authenticates a user. + Authenticate(ctx context.Context, req *AuthenticateRequest, opts ...http.CallOption) (rsp *AuthenticateResponse, err error) + // CreateToken CreateToken generates a new JWT token for the given user. + CreateToken(ctx context.Context, req *CreateTokenRequest, opts ...http.CallOption) (rsp *CreateTokenResponse, err error) + // DestroyToken DestroyToken invalidates a JWT token. + DestroyToken(ctx context.Context, req *DestroyTokenRequest, opts ...http.CallOption) (rsp *DestroyTokenResponse, err error) + // ListAuthResources ListAuthResources returns a list of Auths. + ListAuthResources(ctx context.Context, req *ListAuthResourcesRequest, opts ...http.CallOption) (rsp *ListAuthResourcesResponse, err error) + // ValidateToken ValidateToken verifies the validity of a JWT token. + ValidateToken(ctx context.Context, req *ValidateTokenRequest, opts ...http.CallOption) (rsp *ValidateTokenResponse, err error) +} + +type AuthServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewAuthServiceHTTPClient(client *http.Client) AuthServiceHTTPClient { + return &AuthServiceHTTPClientImpl{client} +} + +// AuthLogout AuthLogout logs out a user. +func (c *AuthServiceHTTPClientImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...http.CallOption) (*AuthLogoutResponse, error) { + var out AuthLogoutResponse + pattern := "/auth/logout" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationAuthServiceAuthLogout)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// Authenticate Authenticate authenticates a user. +func (c *AuthServiceHTTPClientImpl) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...http.CallOption) (*AuthenticateResponse, error) { + var out AuthenticateResponse + pattern := "/auth/authenticate" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationAuthServiceAuthenticate)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// CreateToken CreateToken generates a new JWT token for the given user. +func (c *AuthServiceHTTPClientImpl) CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...http.CallOption) (*CreateTokenResponse, error) { + var out CreateTokenResponse + pattern := "/auth/token" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationAuthServiceCreateToken)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// DestroyToken DestroyToken invalidates a JWT token. +func (c *AuthServiceHTTPClientImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...http.CallOption) (*DestroyTokenResponse, error) { + var out DestroyTokenResponse + pattern := "/auth/destroy" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationAuthServiceDestroyToken)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ListAuthResources ListAuthResources returns a list of Auths. +func (c *AuthServiceHTTPClientImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...http.CallOption) (*ListAuthResourcesResponse, error) { + var out ListAuthResourcesResponse + pattern := "/auth/resources" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationAuthServiceListAuthResources)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ValidateToken ValidateToken verifies the validity of a JWT token. +func (c *AuthServiceHTTPClientImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...http.CallOption) (*ValidateTokenResponse, error) { + var out ValidateTokenResponse + pattern := "/auth/validate" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationAuthServiceValidateToken)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/auth/casbin.pb.go b/api/v1/services/auth/casbin.pb.go new file mode 100644 index 00000000..09c72623 --- /dev/null +++ b/api/v1/services/auth/casbin.pb.go @@ -0,0 +1,618 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: auth/casbin.proto + +package auth + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListPoliciesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPoliciesRequest) Reset() { + *x = ListPoliciesRequest{} + mi := &file_auth_casbin_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPoliciesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPoliciesRequest) ProtoMessage() {} + +func (x *ListPoliciesRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_casbin_proto_msgTypes[0] + 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 ListPoliciesRequest.ProtoReflect.Descriptor instead. +func (*ListPoliciesRequest) Descriptor() ([]byte, []int) { + return file_auth_casbin_proto_rawDescGZIP(), []int{0} +} + +type ListPoliciesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Rules []*PolicyRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPoliciesResponse) Reset() { + *x = ListPoliciesResponse{} + mi := &file_auth_casbin_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPoliciesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPoliciesResponse) ProtoMessage() {} + +func (x *ListPoliciesResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_casbin_proto_msgTypes[1] + 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 ListPoliciesResponse.ProtoReflect.Descriptor instead. +func (*ListPoliciesResponse) Descriptor() ([]byte, []int) { + return file_auth_casbin_proto_rawDescGZIP(), []int{1} +} + +func (x *ListPoliciesResponse) GetRules() []*PolicyRule { + if x != nil { + return x.Rules + } + return nil +} + +type PolicyRule struct { + state protoimpl.MessageState `protogen:"open.v1"` + PType string `protobuf:"bytes,1,opt,name=p_type,proto3" json:"p_type,omitempty"` + Params []string `protobuf:"bytes,2,rep,name=params,proto3" json:"params,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PolicyRule) Reset() { + *x = PolicyRule{} + mi := &file_auth_casbin_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PolicyRule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PolicyRule) ProtoMessage() {} + +func (x *PolicyRule) ProtoReflect() protoreflect.Message { + mi := &file_auth_casbin_proto_msgTypes[2] + 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 PolicyRule.ProtoReflect.Descriptor instead. +func (*PolicyRule) Descriptor() ([]byte, []int) { + return file_auth_casbin_proto_rawDescGZIP(), []int{2} +} + +func (x *PolicyRule) GetPType() string { + if x != nil { + return x.PType + } + return "" +} + +func (x *PolicyRule) GetParams() []string { + if x != nil { + return x.Params + } + return nil +} + +type ListGroupingsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListGroupingsRequest) Reset() { + *x = ListGroupingsRequest{} + mi := &file_auth_casbin_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListGroupingsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListGroupingsRequest) ProtoMessage() {} + +func (x *ListGroupingsRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_casbin_proto_msgTypes[3] + 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 ListGroupingsRequest.ProtoReflect.Descriptor instead. +func (*ListGroupingsRequest) Descriptor() ([]byte, []int) { + return file_auth_casbin_proto_rawDescGZIP(), []int{3} +} + +type ListGroupingsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Rules []*GroupingRule `protobuf:"bytes,1,rep,name=rules,proto3" json:"rules,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListGroupingsResponse) Reset() { + *x = ListGroupingsResponse{} + mi := &file_auth_casbin_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListGroupingsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListGroupingsResponse) ProtoMessage() {} + +func (x *ListGroupingsResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_casbin_proto_msgTypes[4] + 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 ListGroupingsResponse.ProtoReflect.Descriptor instead. +func (*ListGroupingsResponse) Descriptor() ([]byte, []int) { + return file_auth_casbin_proto_rawDescGZIP(), []int{4} +} + +func (x *ListGroupingsResponse) GetRules() []*GroupingRule { + if x != nil { + return x.Rules + } + return nil +} + +type GroupingRule struct { + state protoimpl.MessageState `protogen:"open.v1"` + PType string `protobuf:"bytes,1,opt,name=p_type,proto3" json:"p_type,omitempty"` + Params []string `protobuf:"bytes,2,rep,name=params,proto3" json:"params,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GroupingRule) Reset() { + *x = GroupingRule{} + mi := &file_auth_casbin_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GroupingRule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GroupingRule) ProtoMessage() {} + +func (x *GroupingRule) ProtoReflect() protoreflect.Message { + mi := &file_auth_casbin_proto_msgTypes[5] + 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 GroupingRule.ProtoReflect.Descriptor instead. +func (*GroupingRule) Descriptor() ([]byte, []int) { + return file_auth_casbin_proto_rawDescGZIP(), []int{5} +} + +func (x *GroupingRule) GetPType() string { + if x != nil { + return x.PType + } + return "" +} + +func (x *GroupingRule) GetParams() []string { + if x != nil { + return x.Params + } + return nil +} + +type StreamRulesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + WithPolicies bool `protobuf:"varint,1,opt,name=with_policies,proto3" json:"with_policies,omitempty"` + WithGroupings bool `protobuf:"varint,2,opt,name=with_groupings,proto3" json:"with_groupings,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StreamRulesRequest) Reset() { + *x = StreamRulesRequest{} + mi := &file_auth_casbin_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StreamRulesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StreamRulesRequest) ProtoMessage() {} + +func (x *StreamRulesRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_casbin_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 StreamRulesRequest.ProtoReflect.Descriptor instead. +func (*StreamRulesRequest) Descriptor() ([]byte, []int) { + return file_auth_casbin_proto_rawDescGZIP(), []int{6} +} + +func (x *StreamRulesRequest) GetWithPolicies() bool { + if x != nil { + return x.WithPolicies + } + return false +} + +func (x *StreamRulesRequest) GetWithGroupings() bool { + if x != nil { + return x.WithGroupings + } + return false +} + +type StreamRulesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to RuleType: + // + // *StreamRulesResponse_Policy + // *StreamRulesResponse_Grouping + RuleType isStreamRulesResponse_RuleType `protobuf_oneof:"rule_type"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *StreamRulesResponse) Reset() { + *x = StreamRulesResponse{} + mi := &file_auth_casbin_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *StreamRulesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StreamRulesResponse) ProtoMessage() {} + +func (x *StreamRulesResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_casbin_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StreamRulesResponse.ProtoReflect.Descriptor instead. +func (*StreamRulesResponse) Descriptor() ([]byte, []int) { + return file_auth_casbin_proto_rawDescGZIP(), []int{7} +} + +func (x *StreamRulesResponse) GetRuleType() isStreamRulesResponse_RuleType { + if x != nil { + return x.RuleType + } + return nil +} + +func (x *StreamRulesResponse) GetPolicy() *PolicyRule { + if x != nil { + if x, ok := x.RuleType.(*StreamRulesResponse_Policy); ok { + return x.Policy + } + } + return nil +} + +func (x *StreamRulesResponse) GetGrouping() *GroupingRule { + if x != nil { + if x, ok := x.RuleType.(*StreamRulesResponse_Grouping); ok { + return x.Grouping + } + } + return nil +} + +type isStreamRulesResponse_RuleType interface { + isStreamRulesResponse_RuleType() +} + +type StreamRulesResponse_Policy struct { + Policy *PolicyRule `protobuf:"bytes,1,opt,name=policy,proto3,oneof"` +} + +type StreamRulesResponse_Grouping struct { + Grouping *GroupingRule `protobuf:"bytes,2,opt,name=grouping,proto3,oneof"` +} + +func (*StreamRulesResponse_Policy) isStreamRulesResponse_RuleType() {} + +func (*StreamRulesResponse_Grouping) isStreamRulesResponse_RuleType() {} + +type WatchUpdateRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + LastModified int64 `protobuf:"varint,1,opt,name=last_modified,proto3" json:"last_modified,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WatchUpdateRequest) Reset() { + *x = WatchUpdateRequest{} + mi := &file_auth_casbin_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WatchUpdateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WatchUpdateRequest) ProtoMessage() {} + +func (x *WatchUpdateRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_casbin_proto_msgTypes[8] + 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 WatchUpdateRequest.ProtoReflect.Descriptor instead. +func (*WatchUpdateRequest) Descriptor() ([]byte, []int) { + return file_auth_casbin_proto_rawDescGZIP(), []int{8} +} + +func (x *WatchUpdateRequest) GetLastModified() int64 { + if x != nil { + return x.LastModified + } + return 0 +} + +type WatchUpdateResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + ModifiedDate int64 `protobuf:"varint,1,opt,name=modified_date,proto3" json:"modified_date,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WatchUpdateResponse) Reset() { + *x = WatchUpdateResponse{} + mi := &file_auth_casbin_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WatchUpdateResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WatchUpdateResponse) ProtoMessage() {} + +func (x *WatchUpdateResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_casbin_proto_msgTypes[9] + 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 WatchUpdateResponse.ProtoReflect.Descriptor instead. +func (*WatchUpdateResponse) Descriptor() ([]byte, []int) { + return file_auth_casbin_proto_rawDescGZIP(), []int{9} +} + +func (x *WatchUpdateResponse) GetModifiedDate() int64 { + if x != nil { + return x.ModifiedDate + } + return 0 +} + +var File_auth_casbin_proto protoreflect.FileDescriptor + +const file_auth_casbin_proto_rawDesc = "" + + "\n" + + "\x11auth/casbin.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\"\x15\n" + + "\x13ListPoliciesRequest\"N\n" + + "\x14ListPoliciesResponse\x126\n" + + "\x05rules\x18\x01 \x03(\v2 .api.v1.services.auth.PolicyRuleR\x05rules\"<\n" + + "\n" + + "PolicyRule\x12\x16\n" + + "\x06p_type\x18\x01 \x01(\tR\x06p_type\x12\x16\n" + + "\x06params\x18\x02 \x03(\tR\x06params\"\x16\n" + + "\x14ListGroupingsRequest\"Q\n" + + "\x15ListGroupingsResponse\x128\n" + + "\x05rules\x18\x01 \x03(\v2\".api.v1.services.auth.GroupingRuleR\x05rules\">\n" + + "\fGroupingRule\x12\x16\n" + + "\x06p_type\x18\x01 \x01(\tR\x06p_type\x12\x16\n" + + "\x06params\x18\x02 \x03(\tR\x06params\"b\n" + + "\x12StreamRulesRequest\x12$\n" + + "\rwith_policies\x18\x01 \x01(\bR\rwith_policies\x12&\n" + + "\x0ewith_groupings\x18\x02 \x01(\bR\x0ewith_groupings\"\xa0\x01\n" + + "\x13StreamRulesResponse\x12:\n" + + "\x06policy\x18\x01 \x01(\v2 .api.v1.services.auth.PolicyRuleH\x00R\x06policy\x12@\n" + + "\bgrouping\x18\x02 \x01(\v2\".api.v1.services.auth.GroupingRuleH\x00R\bgroupingB\v\n" + + "\trule_type\":\n" + + "\x12WatchUpdateRequest\x12$\n" + + "\rlast_modified\x18\x01 \x01(\x03R\rlast_modified\";\n" + + "\x13WatchUpdateResponse\x12$\n" + + "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\x89\x04\n" + + "\x13CasbinSourceService\x12\x82\x01\n" + + "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x86\x01\n" + + "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12|\n" + + "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12f\n" + + "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xd2\x01\n" + + "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + +var ( + file_auth_casbin_proto_rawDescOnce sync.Once + file_auth_casbin_proto_rawDescData []byte +) + +func file_auth_casbin_proto_rawDescGZIP() []byte { + file_auth_casbin_proto_rawDescOnce.Do(func() { + file_auth_casbin_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_casbin_proto_rawDesc), len(file_auth_casbin_proto_rawDesc))) + }) + return file_auth_casbin_proto_rawDescData +} + +var file_auth_casbin_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_auth_casbin_proto_goTypes = []any{ + (*ListPoliciesRequest)(nil), // 0: api.v1.services.auth.ListPoliciesRequest + (*ListPoliciesResponse)(nil), // 1: api.v1.services.auth.ListPoliciesResponse + (*PolicyRule)(nil), // 2: api.v1.services.auth.PolicyRule + (*ListGroupingsRequest)(nil), // 3: api.v1.services.auth.ListGroupingsRequest + (*ListGroupingsResponse)(nil), // 4: api.v1.services.auth.ListGroupingsResponse + (*GroupingRule)(nil), // 5: api.v1.services.auth.GroupingRule + (*StreamRulesRequest)(nil), // 6: api.v1.services.auth.StreamRulesRequest + (*StreamRulesResponse)(nil), // 7: api.v1.services.auth.StreamRulesResponse + (*WatchUpdateRequest)(nil), // 8: api.v1.services.auth.WatchUpdateRequest + (*WatchUpdateResponse)(nil), // 9: api.v1.services.auth.WatchUpdateResponse +} +var file_auth_casbin_proto_depIdxs = []int32{ + 2, // 0: api.v1.services.auth.ListPoliciesResponse.rules:type_name -> api.v1.services.auth.PolicyRule + 5, // 1: api.v1.services.auth.ListGroupingsResponse.rules:type_name -> api.v1.services.auth.GroupingRule + 2, // 2: api.v1.services.auth.StreamRulesResponse.policy:type_name -> api.v1.services.auth.PolicyRule + 5, // 3: api.v1.services.auth.StreamRulesResponse.grouping:type_name -> api.v1.services.auth.GroupingRule + 0, // 4: api.v1.services.auth.CasbinSourceService.ListPolicies:input_type -> api.v1.services.auth.ListPoliciesRequest + 3, // 5: api.v1.services.auth.CasbinSourceService.ListGroupings:input_type -> api.v1.services.auth.ListGroupingsRequest + 8, // 6: api.v1.services.auth.CasbinSourceService.WatchUpdate:input_type -> api.v1.services.auth.WatchUpdateRequest + 6, // 7: api.v1.services.auth.CasbinSourceService.StreamRules:input_type -> api.v1.services.auth.StreamRulesRequest + 1, // 8: api.v1.services.auth.CasbinSourceService.ListPolicies:output_type -> api.v1.services.auth.ListPoliciesResponse + 4, // 9: api.v1.services.auth.CasbinSourceService.ListGroupings:output_type -> api.v1.services.auth.ListGroupingsResponse + 9, // 10: api.v1.services.auth.CasbinSourceService.WatchUpdate:output_type -> api.v1.services.auth.WatchUpdateResponse + 7, // 11: api.v1.services.auth.CasbinSourceService.StreamRules:output_type -> api.v1.services.auth.StreamRulesResponse + 8, // [8:12] is the sub-list for method output_type + 4, // [4:8] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_auth_casbin_proto_init() } +func file_auth_casbin_proto_init() { + if File_auth_casbin_proto != nil { + return + } + file_auth_casbin_proto_msgTypes[7].OneofWrappers = []any{ + (*StreamRulesResponse_Policy)(nil), + (*StreamRulesResponse_Grouping)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_casbin_proto_rawDesc), len(file_auth_casbin_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_auth_casbin_proto_goTypes, + DependencyIndexes: file_auth_casbin_proto_depIdxs, + MessageInfos: file_auth_casbin_proto_msgTypes, + }.Build() + File_auth_casbin_proto = out.File + file_auth_casbin_proto_goTypes = nil + file_auth_casbin_proto_depIdxs = nil +} diff --git a/api/v1/services/auth/casbin.pb.gw.go b/api/v1/services/auth/casbin.pb.gw.go new file mode 100644 index 00000000..b20ef61b --- /dev/null +++ b/api/v1/services/auth/casbin.pb.gw.go @@ -0,0 +1,279 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: auth/casbin.proto + +/* +Package auth is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package auth + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +func request_CasbinSourceService_ListPolicies_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinSourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPoliciesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.ListPolicies(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_CasbinSourceService_ListPolicies_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinSourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPoliciesRequest + metadata runtime.ServerMetadata + ) + msg, err := server.ListPolicies(ctx, &protoReq) + return msg, metadata, err +} + +func request_CasbinSourceService_ListGroupings_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinSourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListGroupingsRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.ListGroupings(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_CasbinSourceService_ListGroupings_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinSourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListGroupingsRequest + metadata runtime.ServerMetadata + ) + msg, err := server.ListGroupings(ctx, &protoReq) + return msg, metadata, err +} + +var filter_CasbinSourceService_WatchUpdate_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_CasbinSourceService_WatchUpdate_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinSourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq WatchUpdateRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CasbinSourceService_WatchUpdate_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.WatchUpdate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_CasbinSourceService_WatchUpdate_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinSourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq WatchUpdateRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CasbinSourceService_WatchUpdate_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.WatchUpdate(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterCasbinSourceServiceHandlerServer registers the http handlers for service CasbinSourceService to "mux". +// UnaryRPC :call CasbinSourceServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterCasbinSourceServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterCasbinSourceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server CasbinSourceServiceServer) error { + mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListPolicies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_CasbinSourceService_ListPolicies_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_CasbinSourceService_ListPolicies_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListGroupings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_CasbinSourceService_ListGroupings_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_CasbinSourceService_ListGroupings_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_CasbinSourceService_WatchUpdate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_CasbinSourceService_WatchUpdate_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_CasbinSourceService_WatchUpdate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterCasbinSourceServiceHandlerFromEndpoint is same as RegisterCasbinSourceServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterCasbinSourceServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterCasbinSourceServiceHandler(ctx, mux, conn) +} + +// RegisterCasbinSourceServiceHandler registers the http handlers for service CasbinSourceService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterCasbinSourceServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterCasbinSourceServiceHandlerClient(ctx, mux, NewCasbinSourceServiceClient(conn)) +} + +// RegisterCasbinSourceServiceHandlerClient registers the http handlers for service CasbinSourceService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "CasbinSourceServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "CasbinSourceServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "CasbinSourceServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client CasbinSourceServiceClient) error { + mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListPolicies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_CasbinSourceService_ListPolicies_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_CasbinSourceService_ListPolicies_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListGroupings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_CasbinSourceService_ListGroupings_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_CasbinSourceService_ListGroupings_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_CasbinSourceService_WatchUpdate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_CasbinSourceService_WatchUpdate_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_CasbinSourceService_WatchUpdate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_CasbinSourceService_ListPolicies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "policies"}, "")) + pattern_CasbinSourceService_ListGroupings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "groupings"}, "")) + pattern_CasbinSourceService_WatchUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "watch"}, "")) +) + +var ( + forward_CasbinSourceService_ListPolicies_0 = runtime.ForwardResponseMessage + forward_CasbinSourceService_ListGroupings_0 = runtime.ForwardResponseMessage + forward_CasbinSourceService_WatchUpdate_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/auth/casbin.pb.validate.go b/api/v1/services/auth/casbin.pb.validate.go new file mode 100644 index 00000000..c40e5d7d --- /dev/null +++ b/api/v1/services/auth/casbin.pb.validate.go @@ -0,0 +1,1217 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: auth/casbin.proto + +package auth + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListPoliciesRequest 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 *ListPoliciesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPoliciesRequest 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 +// ListPoliciesRequestMultiError, or nil if none found. +func (m *ListPoliciesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPoliciesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return ListPoliciesRequestMultiError(errors) + } + + return nil +} + +// ListPoliciesRequestMultiError is an error wrapping multiple validation +// errors returned by ListPoliciesRequest.ValidateAll() if the designated +// constraints aren't met. +type ListPoliciesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPoliciesRequestMultiError) 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 ListPoliciesRequestMultiError) AllErrors() []error { return m } + +// ListPoliciesRequestValidationError is the validation error returned by +// ListPoliciesRequest.Validate if the designated constraints aren't met. +type ListPoliciesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPoliciesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPoliciesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPoliciesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPoliciesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPoliciesRequestValidationError) ErrorName() string { + return "ListPoliciesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPoliciesRequestValidationError) 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 %sListPoliciesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPoliciesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPoliciesRequestValidationError{} + +// Validate checks the field values on ListPoliciesResponse 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 *ListPoliciesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPoliciesResponse 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 +// ListPoliciesResponseMultiError, or nil if none found. +func (m *ListPoliciesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPoliciesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRules() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPoliciesResponseValidationError{ + field: fmt.Sprintf("Rules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPoliciesResponseValidationError{ + field: fmt.Sprintf("Rules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPoliciesResponseValidationError{ + field: fmt.Sprintf("Rules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListPoliciesResponseMultiError(errors) + } + + return nil +} + +// ListPoliciesResponseMultiError is an error wrapping multiple validation +// errors returned by ListPoliciesResponse.ValidateAll() if the designated +// constraints aren't met. +type ListPoliciesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPoliciesResponseMultiError) 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 ListPoliciesResponseMultiError) AllErrors() []error { return m } + +// ListPoliciesResponseValidationError is the validation error returned by +// ListPoliciesResponse.Validate if the designated constraints aren't met. +type ListPoliciesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPoliciesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPoliciesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPoliciesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPoliciesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPoliciesResponseValidationError) ErrorName() string { + return "ListPoliciesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPoliciesResponseValidationError) 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 %sListPoliciesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPoliciesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPoliciesResponseValidationError{} + +// Validate checks the field values on PolicyRule 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 *PolicyRule) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PolicyRule 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 PolicyRuleMultiError, or +// nil if none found. +func (m *PolicyRule) ValidateAll() error { + return m.validate(true) +} + +func (m *PolicyRule) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for PType + + if len(errors) > 0 { + return PolicyRuleMultiError(errors) + } + + return nil +} + +// PolicyRuleMultiError is an error wrapping multiple validation errors +// returned by PolicyRule.ValidateAll() if the designated constraints aren't met. +type PolicyRuleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PolicyRuleMultiError) 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 PolicyRuleMultiError) AllErrors() []error { return m } + +// PolicyRuleValidationError is the validation error returned by +// PolicyRule.Validate if the designated constraints aren't met. +type PolicyRuleValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PolicyRuleValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PolicyRuleValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PolicyRuleValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PolicyRuleValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PolicyRuleValidationError) ErrorName() string { return "PolicyRuleValidationError" } + +// Error satisfies the builtin error interface +func (e PolicyRuleValidationError) 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 %sPolicyRule.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PolicyRuleValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PolicyRuleValidationError{} + +// Validate checks the field values on ListGroupingsRequest 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 *ListGroupingsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListGroupingsRequest 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 +// ListGroupingsRequestMultiError, or nil if none found. +func (m *ListGroupingsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListGroupingsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return ListGroupingsRequestMultiError(errors) + } + + return nil +} + +// ListGroupingsRequestMultiError is an error wrapping multiple validation +// errors returned by ListGroupingsRequest.ValidateAll() if the designated +// constraints aren't met. +type ListGroupingsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListGroupingsRequestMultiError) 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 ListGroupingsRequestMultiError) AllErrors() []error { return m } + +// ListGroupingsRequestValidationError is the validation error returned by +// ListGroupingsRequest.Validate if the designated constraints aren't met. +type ListGroupingsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListGroupingsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListGroupingsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListGroupingsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListGroupingsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListGroupingsRequestValidationError) ErrorName() string { + return "ListGroupingsRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListGroupingsRequestValidationError) 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 %sListGroupingsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListGroupingsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListGroupingsRequestValidationError{} + +// Validate checks the field values on ListGroupingsResponse 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 *ListGroupingsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListGroupingsResponse 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 +// ListGroupingsResponseMultiError, or nil if none found. +func (m *ListGroupingsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListGroupingsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRules() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListGroupingsResponseValidationError{ + field: fmt.Sprintf("Rules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListGroupingsResponseValidationError{ + field: fmt.Sprintf("Rules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListGroupingsResponseValidationError{ + field: fmt.Sprintf("Rules[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListGroupingsResponseMultiError(errors) + } + + return nil +} + +// ListGroupingsResponseMultiError is an error wrapping multiple validation +// errors returned by ListGroupingsResponse.ValidateAll() if the designated +// constraints aren't met. +type ListGroupingsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListGroupingsResponseMultiError) 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 ListGroupingsResponseMultiError) AllErrors() []error { return m } + +// ListGroupingsResponseValidationError is the validation error returned by +// ListGroupingsResponse.Validate if the designated constraints aren't met. +type ListGroupingsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListGroupingsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListGroupingsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListGroupingsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListGroupingsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListGroupingsResponseValidationError) ErrorName() string { + return "ListGroupingsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListGroupingsResponseValidationError) 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 %sListGroupingsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListGroupingsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListGroupingsResponseValidationError{} + +// Validate checks the field values on GroupingRule 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 *GroupingRule) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GroupingRule 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 GroupingRuleMultiError, or +// nil if none found. +func (m *GroupingRule) ValidateAll() error { + return m.validate(true) +} + +func (m *GroupingRule) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for PType + + if len(errors) > 0 { + return GroupingRuleMultiError(errors) + } + + return nil +} + +// GroupingRuleMultiError is an error wrapping multiple validation errors +// returned by GroupingRule.ValidateAll() if the designated constraints aren't met. +type GroupingRuleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GroupingRuleMultiError) 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 GroupingRuleMultiError) AllErrors() []error { return m } + +// GroupingRuleValidationError is the validation error returned by +// GroupingRule.Validate if the designated constraints aren't met. +type GroupingRuleValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GroupingRuleValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GroupingRuleValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GroupingRuleValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GroupingRuleValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GroupingRuleValidationError) ErrorName() string { return "GroupingRuleValidationError" } + +// Error satisfies the builtin error interface +func (e GroupingRuleValidationError) 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 %sGroupingRule.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GroupingRuleValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GroupingRuleValidationError{} + +// Validate checks the field values on StreamRulesRequest 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 *StreamRulesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on StreamRulesRequest 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 +// StreamRulesRequestMultiError, or nil if none found. +func (m *StreamRulesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *StreamRulesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for WithPolicies + + // no validation rules for WithGroupings + + if len(errors) > 0 { + return StreamRulesRequestMultiError(errors) + } + + return nil +} + +// StreamRulesRequestMultiError is an error wrapping multiple validation errors +// returned by StreamRulesRequest.ValidateAll() if the designated constraints +// aren't met. +type StreamRulesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m StreamRulesRequestMultiError) 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 StreamRulesRequestMultiError) AllErrors() []error { return m } + +// StreamRulesRequestValidationError is the validation error returned by +// StreamRulesRequest.Validate if the designated constraints aren't met. +type StreamRulesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e StreamRulesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e StreamRulesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e StreamRulesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e StreamRulesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e StreamRulesRequestValidationError) ErrorName() string { + return "StreamRulesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e StreamRulesRequestValidationError) 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 %sStreamRulesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = StreamRulesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = StreamRulesRequestValidationError{} + +// Validate checks the field values on StreamRulesResponse 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 *StreamRulesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on StreamRulesResponse 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 +// StreamRulesResponseMultiError, or nil if none found. +func (m *StreamRulesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *StreamRulesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + switch v := m.RuleType.(type) { + case *StreamRulesResponse_Policy: + if v == nil { + err := StreamRulesResponseValidationError{ + field: "RuleType", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetPolicy()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, StreamRulesResponseValidationError{ + field: "Policy", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, StreamRulesResponseValidationError{ + field: "Policy", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPolicy()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return StreamRulesResponseValidationError{ + field: "Policy", + reason: "embedded message failed validation", + cause: err, + } + } + } + + case *StreamRulesResponse_Grouping: + if v == nil { + err := StreamRulesResponseValidationError{ + field: "RuleType", + reason: "oneof value cannot be a typed-nil", + } + if !all { + return err + } + errors = append(errors, err) + } + + if all { + switch v := interface{}(m.GetGrouping()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, StreamRulesResponseValidationError{ + field: "Grouping", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, StreamRulesResponseValidationError{ + field: "Grouping", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetGrouping()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return StreamRulesResponseValidationError{ + field: "Grouping", + reason: "embedded message failed validation", + cause: err, + } + } + } + + default: + _ = v // ensures v is used + } + + if len(errors) > 0 { + return StreamRulesResponseMultiError(errors) + } + + return nil +} + +// StreamRulesResponseMultiError is an error wrapping multiple validation +// errors returned by StreamRulesResponse.ValidateAll() if the designated +// constraints aren't met. +type StreamRulesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m StreamRulesResponseMultiError) 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 StreamRulesResponseMultiError) AllErrors() []error { return m } + +// StreamRulesResponseValidationError is the validation error returned by +// StreamRulesResponse.Validate if the designated constraints aren't met. +type StreamRulesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e StreamRulesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e StreamRulesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e StreamRulesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e StreamRulesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e StreamRulesResponseValidationError) ErrorName() string { + return "StreamRulesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e StreamRulesResponseValidationError) 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 %sStreamRulesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = StreamRulesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = StreamRulesResponseValidationError{} + +// Validate checks the field values on WatchUpdateRequest 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 *WatchUpdateRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on WatchUpdateRequest 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 +// WatchUpdateRequestMultiError, or nil if none found. +func (m *WatchUpdateRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *WatchUpdateRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for LastModified + + if len(errors) > 0 { + return WatchUpdateRequestMultiError(errors) + } + + return nil +} + +// WatchUpdateRequestMultiError is an error wrapping multiple validation errors +// returned by WatchUpdateRequest.ValidateAll() if the designated constraints +// aren't met. +type WatchUpdateRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m WatchUpdateRequestMultiError) 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 WatchUpdateRequestMultiError) AllErrors() []error { return m } + +// WatchUpdateRequestValidationError is the validation error returned by +// WatchUpdateRequest.Validate if the designated constraints aren't met. +type WatchUpdateRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e WatchUpdateRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e WatchUpdateRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e WatchUpdateRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e WatchUpdateRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e WatchUpdateRequestValidationError) ErrorName() string { + return "WatchUpdateRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e WatchUpdateRequestValidationError) 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 %sWatchUpdateRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = WatchUpdateRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = WatchUpdateRequestValidationError{} + +// Validate checks the field values on WatchUpdateResponse 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 *WatchUpdateResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on WatchUpdateResponse 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 +// WatchUpdateResponseMultiError, or nil if none found. +func (m *WatchUpdateResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *WatchUpdateResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for ModifiedDate + + if len(errors) > 0 { + return WatchUpdateResponseMultiError(errors) + } + + return nil +} + +// WatchUpdateResponseMultiError is an error wrapping multiple validation +// errors returned by WatchUpdateResponse.ValidateAll() if the designated +// constraints aren't met. +type WatchUpdateResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m WatchUpdateResponseMultiError) 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 WatchUpdateResponseMultiError) AllErrors() []error { return m } + +// WatchUpdateResponseValidationError is the validation error returned by +// WatchUpdateResponse.Validate if the designated constraints aren't met. +type WatchUpdateResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e WatchUpdateResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e WatchUpdateResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e WatchUpdateResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e WatchUpdateResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e WatchUpdateResponseValidationError) ErrorName() string { + return "WatchUpdateResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e WatchUpdateResponseValidationError) 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 %sWatchUpdateResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = WatchUpdateResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = WatchUpdateResponseValidationError{} diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go new file mode 100644 index 00000000..9e7e573b --- /dev/null +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -0,0 +1,291 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: auth/casbin.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const CasbinSourceServiceListGroupingsBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListGroupings" +const CasbinSourceServiceListPoliciesBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListPolicies" +const CasbinSourceServiceWatchUpdateBridgeOperation = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" + +type CasbinSourceServiceBridgeServer interface { + ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) + ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) + WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) +} + +type CasbinSourceServiceHooker interface { + CasbinSourceServiceListGroupingsHooker + CasbinSourceServiceListPoliciesHooker + CasbinSourceServiceWatchUpdateHooker +} + +type CasbinSourceServiceHookedBridger interface { + CasbinSourceServiceHooker + CasbinSourceServiceBridgeServer +} +type CasbinSourceServiceListGroupingsHooker interface { + PrepareListGroupings(http.Context, *ListGroupingsRequest) (context.Context, error) + CompleteListGroupings(http.Context, *ListGroupingsRequest, *ListGroupingsResponse) error +} +type CasbinSourceServiceListPoliciesHooker interface { + PrepareListPolicies(http.Context, *ListPoliciesRequest) (context.Context, error) + CompleteListPolicies(http.Context, *ListPoliciesRequest, *ListPoliciesResponse) error +} +type CasbinSourceServiceWatchUpdateHooker interface { + PrepareWatchUpdate(http.Context, *WatchUpdateRequest) (context.Context, error) + CompleteWatchUpdate(http.Context, *WatchUpdateRequest, *WatchUpdateResponse) error +} + +func RegisterCasbinSourceServiceBridgeServer(s *http.Server, srv CasbinSourceServiceHookedBridger) { + r := s.Route("/") + r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_Bridge_Handler(srv)) + r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_Bridge_Handler(srv)) + r.GET("/casbin/watch", _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv)) +} + +func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPoliciesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationCasbinSourceServiceListPolicies) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPolicies(ctx, req.(*ListPoliciesRequest)) + }) + + newctx, err := srv.PrepareListPolicies(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPolicies(ctx, &in, out.(*ListPoliciesResponse)) + } +} + +func _CasbinSourceService_ListGroupings0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListGroupingsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationCasbinSourceServiceListGroupings) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListGroupings(ctx, req.(*ListGroupingsRequest)) + }) + + newctx, err := srv.PrepareListGroupings(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListGroupings(ctx, &in, out.(*ListGroupingsResponse)) + } +} + +func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in WatchUpdateRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationCasbinSourceServiceWatchUpdate) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.WatchUpdate(ctx, req.(*WatchUpdateRequest)) + }) + + newctx, err := srv.PrepareWatchUpdate(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteWatchUpdate(ctx, &in, out.(*WatchUpdateResponse)) + } +} + +// UnimplementedCasbinSourceServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedCasbinSourceServiceHooked struct{} + +func (UnimplementedCasbinSourceServiceHooked) PrepareListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedCasbinSourceServiceHooked) CompleteListGroupings(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedCasbinSourceServiceHooked) PrepareListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedCasbinSourceServiceHooked) CompleteListPolicies(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedCasbinSourceServiceHooked) PrepareWatchUpdate(ctx http.Context, in *WatchUpdateRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedCasbinSourceServiceHooked) CompleteWatchUpdate(ctx http.Context, in *WatchUpdateRequest, out *WatchUpdateResponse) error { + return ctx.Result(200, out) +} + +func WithCasbinSourceServiceHook(h CasbinSourceServiceHooker) func(CasbinSourceServiceBridgeServer) CasbinSourceServiceHookedBridger { + return func(srv CasbinSourceServiceBridgeServer) CasbinSourceServiceHookedBridger { + return CasbinSourceServiceHookedBridge{CasbinSourceServiceBridgeServer: srv, CasbinSourceServiceHooker: h} + } +} + +// CasbinSourceServiceHookedBridge is a bridge between the HTTP and gRPC implementations of CasbinSourceService. +// It implements the HTTP and gRPC implementations of CasbinSourceService. +// It forwards requests and responses between the two implementations. +type CasbinSourceServiceHookedBridge struct { + CasbinSourceServiceBridgeServer + CasbinSourceServiceHooker +} + +type CasbinSourceServiceHTTPBridgeImpl struct { + client CasbinSourceServiceHTTPClient +} + +func NewCasbinSourceServiceHTTPBridge(client *http.Client) CasbinSourceServiceHTTPServer { + return &CasbinSourceServiceHTTPBridgeImpl{client: NewCasbinSourceServiceHTTPClient(client)} +} + +func (c *CasbinSourceServiceHTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + +func (c *CasbinSourceServiceHTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { + return c.client.ListPolicies(ctx, in) +} + +func (c *CasbinSourceServiceHTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { + return c.client.WatchUpdate(ctx, in) +} + +type CasbinSourceServiceBridgeImpl struct { + client CasbinSourceServiceClient +} + +func NewCasbinSourceServiceBridge(client grpc.ClientConnInterface) CasbinSourceServiceServer { + return &CasbinSourceServiceBridgeImpl{client: NewCasbinSourceServiceClient(client)} +} + +func (c *CasbinSourceServiceBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + +func (c *CasbinSourceServiceBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { + return c.client.ListPolicies(ctx, in) +} + +func (c *CasbinSourceServiceBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { + return c.client.WatchUpdate(ctx, in) +} + +func (c *CasbinSourceServiceBridgeImpl) StreamRules(request *StreamRulesRequest, g grpc.ServerStreamingServer[StreamRulesResponse]) error { + stream, err := c.client.StreamRules(g.Context(), request) + if err != nil { + return err + } + for { + rule, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return status.Errorf(status.Code(err), "received stream error: %v", err) + } + if err := g.Send(rule); err != nil { + return err + } + } + return nil +} + +func (c *CasbinSourceServiceBridgeImpl) mustEmbedUnimplementedCasbinSourceServiceServer() {} + +type CasbinSourceServiceGRPC2HTTPBridgeImpl struct { + client CasbinSourceServiceClient +} + +func NewCasbinSourceServiceGRPC2HTTP(client grpc.ClientConnInterface) CasbinSourceServiceHTTPServer { + return &CasbinSourceServiceGRPC2HTTPBridgeImpl{client: NewCasbinSourceServiceClient(client)} +} + +func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + +func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { + return c.client.ListPolicies(ctx, in) +} + +func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { + return c.client.WatchUpdate(ctx, in) +} + +type CasbinSourceServiceHTTP2GRPCBridgeImpl struct { + client CasbinSourceServiceHTTPClient +} + +func NewCasbinSourceServiceHTTP2GRPC(client *http.Client) CasbinSourceServiceServer { + return &CasbinSourceServiceHTTP2GRPCBridgeImpl{client: NewCasbinSourceServiceHTTPClient(client)} +} + +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { + return c.client.ListPolicies(ctx, in) +} + +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { + return c.client.WatchUpdate(ctx, in) +} + +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) StreamRules(request *StreamRulesRequest, g grpc.ServerStreamingServer[StreamRulesResponse]) error { + return status.Errorf(codes.Unimplemented, "StreamRules not implemented") +} + +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedCasbinSourceServiceServer() {} diff --git a/api/v1/services/auth/casbin_grpc.pb.go b/api/v1/services/auth/casbin_grpc.pb.go new file mode 100644 index 00000000..86911a12 --- /dev/null +++ b/api/v1/services/auth/casbin_grpc.pb.go @@ -0,0 +1,243 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: auth/casbin.proto + +package auth + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + CasbinSourceService_ListPolicies_FullMethodName = "/api.v1.services.auth.CasbinSourceService/ListPolicies" + CasbinSourceService_ListGroupings_FullMethodName = "/api.v1.services.auth.CasbinSourceService/ListGroupings" + CasbinSourceService_WatchUpdate_FullMethodName = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" + CasbinSourceService_StreamRules_FullMethodName = "/api.v1.services.auth.CasbinSourceService/StreamRules" +) + +// CasbinSourceServiceClient is the client API for CasbinSourceService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The Casbin source service definition. +type CasbinSourceServiceClient interface { + ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...grpc.CallOption) (*ListPoliciesResponse, error) + ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...grpc.CallOption) (*ListGroupingsResponse, error) + WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...grpc.CallOption) (*WatchUpdateResponse, error) + StreamRules(ctx context.Context, in *StreamRulesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamRulesResponse], error) +} + +type casbinSourceServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewCasbinSourceServiceClient(cc grpc.ClientConnInterface) CasbinSourceServiceClient { + return &casbinSourceServiceClient{cc} +} + +func (c *casbinSourceServiceClient) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...grpc.CallOption) (*ListPoliciesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPoliciesResponse) + err := c.cc.Invoke(ctx, CasbinSourceService_ListPolicies_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *casbinSourceServiceClient) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...grpc.CallOption) (*ListGroupingsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListGroupingsResponse) + err := c.cc.Invoke(ctx, CasbinSourceService_ListGroupings_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *casbinSourceServiceClient) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...grpc.CallOption) (*WatchUpdateResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(WatchUpdateResponse) + err := c.cc.Invoke(ctx, CasbinSourceService_WatchUpdate_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *casbinSourceServiceClient) StreamRules(ctx context.Context, in *StreamRulesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamRulesResponse], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &CasbinSourceService_ServiceDesc.Streams[0], CasbinSourceService_StreamRules_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[StreamRulesRequest, StreamRulesResponse]{ClientStream: stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type CasbinSourceService_StreamRulesClient = grpc.ServerStreamingClient[StreamRulesResponse] + +// CasbinSourceServiceServer is the server API for CasbinSourceService service. +// All implementations must embed UnimplementedCasbinSourceServiceServer +// for forward compatibility. +// +// The Casbin source service definition. +type CasbinSourceServiceServer interface { + ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) + ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) + WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) + StreamRules(*StreamRulesRequest, grpc.ServerStreamingServer[StreamRulesResponse]) error + mustEmbedUnimplementedCasbinSourceServiceServer() +} + +// UnimplementedCasbinSourceServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedCasbinSourceServiceServer struct{} + +func (UnimplementedCasbinSourceServiceServer) ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPolicies not implemented") +} +func (UnimplementedCasbinSourceServiceServer) ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListGroupings not implemented") +} +func (UnimplementedCasbinSourceServiceServer) WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WatchUpdate not implemented") +} +func (UnimplementedCasbinSourceServiceServer) StreamRules(*StreamRulesRequest, grpc.ServerStreamingServer[StreamRulesResponse]) error { + return status.Errorf(codes.Unimplemented, "method StreamRules not implemented") +} +func (UnimplementedCasbinSourceServiceServer) mustEmbedUnimplementedCasbinSourceServiceServer() {} +func (UnimplementedCasbinSourceServiceServer) testEmbeddedByValue() {} + +// UnsafeCasbinSourceServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to CasbinSourceServiceServer will +// result in compilation errors. +type UnsafeCasbinSourceServiceServer interface { + mustEmbedUnimplementedCasbinSourceServiceServer() +} + +func RegisterCasbinSourceServiceServer(s grpc.ServiceRegistrar, srv CasbinSourceServiceServer) { + // If the following call pancis, it indicates UnimplementedCasbinSourceServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&CasbinSourceService_ServiceDesc, srv) +} + +func _CasbinSourceService_ListPolicies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPoliciesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CasbinSourceServiceServer).ListPolicies(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: CasbinSourceService_ListPolicies_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CasbinSourceServiceServer).ListPolicies(ctx, req.(*ListPoliciesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CasbinSourceService_ListGroupings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListGroupingsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CasbinSourceServiceServer).ListGroupings(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: CasbinSourceService_ListGroupings_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CasbinSourceServiceServer).ListGroupings(ctx, req.(*ListGroupingsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CasbinSourceService_WatchUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WatchUpdateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CasbinSourceServiceServer).WatchUpdate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: CasbinSourceService_WatchUpdate_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CasbinSourceServiceServer).WatchUpdate(ctx, req.(*WatchUpdateRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _CasbinSourceService_StreamRules_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(StreamRulesRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(CasbinSourceServiceServer).StreamRules(m, &grpc.GenericServerStream[StreamRulesRequest, StreamRulesResponse]{ServerStream: stream}) +} + +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type CasbinSourceService_StreamRulesServer = grpc.ServerStreamingServer[StreamRulesResponse] + +// CasbinSourceService_ServiceDesc is the grpc.ServiceDesc for CasbinSourceService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var CasbinSourceService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.auth.CasbinSourceService", + HandlerType: (*CasbinSourceServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListPolicies", + Handler: _CasbinSourceService_ListPolicies_Handler, + }, + { + MethodName: "ListGroupings", + Handler: _CasbinSourceService_ListGroupings_Handler, + }, + { + MethodName: "WatchUpdate", + Handler: _CasbinSourceService_WatchUpdate_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "StreamRules", + Handler: _CasbinSourceService_StreamRules_Handler, + ServerStreams: true, + }, + }, + Metadata: "auth/casbin.proto", +} diff --git a/api/v1/services/auth/casbin_http.pb.go b/api/v1/services/auth/casbin_http.pb.go new file mode 100644 index 00000000..e66f87ae --- /dev/null +++ b/api/v1/services/auth/casbin_http.pb.go @@ -0,0 +1,147 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: auth/casbin.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationCasbinSourceServiceListGroupings = "/api.v1.services.auth.CasbinSourceService/ListGroupings" +const OperationCasbinSourceServiceListPolicies = "/api.v1.services.auth.CasbinSourceService/ListPolicies" +const OperationCasbinSourceServiceWatchUpdate = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" + +type CasbinSourceServiceHTTPServer interface { + ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) + ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) + WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) +} + +func RegisterCasbinSourceServiceHTTPServer(s *http.Server, srv CasbinSourceServiceHTTPServer) { + r := s.Route("/") + r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_HTTP_Handler(srv)) + r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_HTTP_Handler(srv)) + r.GET("/casbin/watch", _CasbinSourceService_WatchUpdate0_HTTP_Handler(srv)) +} + +func _CasbinSourceService_ListPolicies0_HTTP_Handler(srv CasbinSourceServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPoliciesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationCasbinSourceServiceListPolicies) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPolicies(ctx, req.(*ListPoliciesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPoliciesResponse) + return ctx.Result(200, reply) + } +} + +func _CasbinSourceService_ListGroupings0_HTTP_Handler(srv CasbinSourceServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListGroupingsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationCasbinSourceServiceListGroupings) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListGroupings(ctx, req.(*ListGroupingsRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListGroupingsResponse) + return ctx.Result(200, reply) + } +} + +func _CasbinSourceService_WatchUpdate0_HTTP_Handler(srv CasbinSourceServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in WatchUpdateRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationCasbinSourceServiceWatchUpdate) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.WatchUpdate(ctx, req.(*WatchUpdateRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*WatchUpdateResponse) + return ctx.Result(200, reply) + } +} + +type CasbinSourceServiceHTTPClient interface { + ListGroupings(ctx context.Context, req *ListGroupingsRequest, opts ...http.CallOption) (rsp *ListGroupingsResponse, err error) + ListPolicies(ctx context.Context, req *ListPoliciesRequest, opts ...http.CallOption) (rsp *ListPoliciesResponse, err error) + WatchUpdate(ctx context.Context, req *WatchUpdateRequest, opts ...http.CallOption) (rsp *WatchUpdateResponse, err error) +} + +type CasbinSourceServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewCasbinSourceServiceHTTPClient(client *http.Client) CasbinSourceServiceHTTPClient { + return &CasbinSourceServiceHTTPClientImpl{client} +} + +func (c *CasbinSourceServiceHTTPClientImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...http.CallOption) (*ListGroupingsResponse, error) { + var out ListGroupingsResponse + pattern := "/casbin/groupings" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationCasbinSourceServiceListGroupings)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *CasbinSourceServiceHTTPClientImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...http.CallOption) (*ListPoliciesResponse, error) { + var out ListPoliciesResponse + pattern := "/casbin/policies" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationCasbinSourceServiceListPolicies)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *CasbinSourceServiceHTTPClientImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...http.CallOption) (*WatchUpdateResponse, error) { + var out WatchUpdateResponse + pattern := "/casbin/watch" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationCasbinSourceServiceWatchUpdate)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/auth/login.pb.go b/api/v1/services/auth/login.pb.go new file mode 100644 index 00000000..4ca709a3 --- /dev/null +++ b/api/v1/services/auth/login.pb.go @@ -0,0 +1,1461 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: auth/login.proto + +package auth + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + v1 "github.com/origadmin/contrib/api/gen/go/security/v1" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type TokenRefreshRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *TokenRefreshRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TokenRefreshRequest) Reset() { + *x = TokenRefreshRequest{} + mi := &file_auth_login_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TokenRefreshRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TokenRefreshRequest) ProtoMessage() {} + +func (x *TokenRefreshRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[0] + 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 TokenRefreshRequest.ProtoReflect.Descriptor instead. +func (*TokenRefreshRequest) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{0} +} + +func (x *TokenRefreshRequest) GetData() *TokenRefreshRequest_Data { + if x != nil { + return x.Data + } + return nil +} + +type TokenRefreshResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token *v1.TokenCredential `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TokenRefreshResponse) Reset() { + *x = TokenRefreshResponse{} + mi := &file_auth_login_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TokenRefreshResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TokenRefreshResponse) ProtoMessage() {} + +func (x *TokenRefreshResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[1] + 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 TokenRefreshResponse.ProtoReflect.Descriptor instead. +func (*TokenRefreshResponse) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{1} +} + +func (x *TokenRefreshResponse) GetToken() *v1.TokenCredential { + if x != nil { + return x.Token + } + return nil +} + +type LoginRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *LoginRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LoginRequest) Reset() { + *x = LoginRequest{} + mi := &file_auth_login_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LoginRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginRequest) ProtoMessage() {} + +func (x *LoginRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[2] + 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 LoginRequest.ProtoReflect.Descriptor instead. +func (*LoginRequest) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{2} +} + +func (x *LoginRequest) GetData() *LoginRequest_Data { + if x != nil { + return x.Data + } + return nil +} + +type LoginResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token *v1.TokenCredential `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LoginResponse) Reset() { + *x = LoginResponse{} + mi := &file_auth_login_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LoginResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginResponse) ProtoMessage() {} + +func (x *LoginResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[3] + 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 LoginResponse.ProtoReflect.Descriptor instead. +func (*LoginResponse) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{3} +} + +func (x *LoginResponse) GetToken() *v1.TokenCredential { + if x != nil { + return x.Token + } + return nil +} + +type CurrentUserRequestQuery struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,proto3" json:"user_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CurrentUserRequestQuery) Reset() { + *x = CurrentUserRequestQuery{} + mi := &file_auth_login_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CurrentUserRequestQuery) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CurrentUserRequestQuery) ProtoMessage() {} + +func (x *CurrentUserRequestQuery) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[4] + 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 CurrentUserRequestQuery.ProtoReflect.Descriptor instead. +func (*CurrentUserRequestQuery) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{4} +} + +func (x *CurrentUserRequestQuery) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +type CurrentUserRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *CurrentUserRequestQuery `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CurrentUserRequest) Reset() { + *x = CurrentUserRequest{} + mi := &file_auth_login_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CurrentUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CurrentUserRequest) ProtoMessage() {} + +func (x *CurrentUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[5] + 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 CurrentUserRequest.ProtoReflect.Descriptor instead. +func (*CurrentUserRequest) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{5} +} + +func (x *CurrentUserRequest) GetData() *CurrentUserRequestQuery { + if x != nil { + return x.Data + } + return nil +} + +type CurrentUserResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CurrentUserResponse) Reset() { + *x = CurrentUserResponse{} + mi := &file_auth_login_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CurrentUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CurrentUserResponse) ProtoMessage() {} + +func (x *CurrentUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_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 CurrentUserResponse.ProtoReflect.Descriptor instead. +func (*CurrentUserResponse) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{6} +} + +func (x *CurrentUserResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *CurrentUserResponse) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type CaptchaIdRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The timestamp of the request prevent caching of the same result + Ts string `protobuf:"bytes,1,opt,name=ts,proto3" json:"ts,omitempty"` + Reload bool `protobuf:"varint,2,opt,name=reload,proto3" json:"reload,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CaptchaIdRequest) Reset() { + *x = CaptchaIdRequest{} + mi := &file_auth_login_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CaptchaIdRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaptchaIdRequest) ProtoMessage() {} + +func (x *CaptchaIdRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CaptchaIdRequest.ProtoReflect.Descriptor instead. +func (*CaptchaIdRequest) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{7} +} + +func (x *CaptchaIdRequest) GetTs() string { + if x != nil { + return x.Ts + } + return "" +} + +func (x *CaptchaIdRequest) GetReload() bool { + if x != nil { + return x.Reload + } + return false +} + +type CaptchaIdResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CaptchaIdResponse) Reset() { + *x = CaptchaIdResponse{} + mi := &file_auth_login_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CaptchaIdResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaptchaIdResponse) ProtoMessage() {} + +func (x *CaptchaIdResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[8] + 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 CaptchaIdResponse.ProtoReflect.Descriptor instead. +func (*CaptchaIdResponse) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{8} +} + +func (x *CaptchaIdResponse) GetData() string { + if x != nil { + return x.Data + } + return "" +} + +// The request message containing the user's name. +type CaptchaImageRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Reload string `protobuf:"bytes,2,opt,name=reload,proto3" json:"reload,omitempty"` + Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CaptchaImageRequest) Reset() { + *x = CaptchaImageRequest{} + mi := &file_auth_login_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CaptchaImageRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaptchaImageRequest) ProtoMessage() {} + +func (x *CaptchaImageRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[9] + 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 CaptchaImageRequest.ProtoReflect.Descriptor instead. +func (*CaptchaImageRequest) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{9} +} + +func (x *CaptchaImageRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CaptchaImageRequest) GetReload() string { + if x != nil { + return x.Reload + } + return "" +} + +func (x *CaptchaImageRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type CaptchaData struct { + state protoimpl.MessageState `protogen:"open.v1"` + CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` + CaptchaImg string `protobuf:"bytes,2,opt,name=captcha_img,json=captchaImg,proto3" json:"captcha_img,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CaptchaData) Reset() { + *x = CaptchaData{} + mi := &file_auth_login_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CaptchaData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaptchaData) ProtoMessage() {} + +func (x *CaptchaData) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[10] + 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 CaptchaData.ProtoReflect.Descriptor instead. +func (*CaptchaData) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{10} +} + +func (x *CaptchaData) GetCaptchaId() string { + if x != nil { + return x.CaptchaId + } + return "" +} + +func (x *CaptchaData) GetCaptchaImg() string { + if x != nil { + return x.CaptchaImg + } + return "" +} + +// The response message containing the greetings +type CaptchaImageResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Image []byte `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CaptchaImageResponse) Reset() { + *x = CaptchaImageResponse{} + mi := &file_auth_login_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CaptchaImageResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaptchaImageResponse) ProtoMessage() {} + +func (x *CaptchaImageResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[11] + 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 CaptchaImageResponse.ProtoReflect.Descriptor instead. +func (*CaptchaImageResponse) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{11} +} + +func (x *CaptchaImageResponse) GetHeaders() map[string]string { + if x != nil { + return x.Headers + } + return nil +} + +func (x *CaptchaImageResponse) GetImage() []byte { + if x != nil { + return x.Image + } + return nil +} + +// The request message containing the user's name. +type CaptchaAudioRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Reload string `protobuf:"bytes,2,opt,name=reload,proto3" json:"reload,omitempty"` + Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CaptchaAudioRequest) Reset() { + *x = CaptchaAudioRequest{} + mi := &file_auth_login_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CaptchaAudioRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaptchaAudioRequest) ProtoMessage() {} + +func (x *CaptchaAudioRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[12] + 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 CaptchaAudioRequest.ProtoReflect.Descriptor instead. +func (*CaptchaAudioRequest) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{12} +} + +func (x *CaptchaAudioRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CaptchaAudioRequest) GetReload() string { + if x != nil { + return x.Reload + } + return "" +} + +func (x *CaptchaAudioRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +// The response message containing the greetings +type CaptchaAudioResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Audio []byte `protobuf:"bytes,2,opt,name=audio,proto3" json:"audio,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CaptchaAudioResponse) Reset() { + *x = CaptchaAudioResponse{} + mi := &file_auth_login_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CaptchaAudioResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaptchaAudioResponse) ProtoMessage() {} + +func (x *CaptchaAudioResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[13] + 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 CaptchaAudioResponse.ProtoReflect.Descriptor instead. +func (*CaptchaAudioResponse) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{13} +} + +func (x *CaptchaAudioResponse) GetHeaders() map[string]string { + if x != nil { + return x.Headers + } + return nil +} + +func (x *CaptchaAudioResponse) GetAudio() []byte { + if x != nil { + return x.Audio + } + return nil +} + +type CaptchaRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The id of the captcha + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // The type of the captcha + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + // The reload is used to reload the captcha + Reload bool `protobuf:"varint,3,opt,name=reload,proto3" json:"reload,omitempty"` + // The timestamp of the request prevent caching of the same result + Ts string `protobuf:"bytes,4,opt,name=ts,proto3" json:"ts,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CaptchaRequest) Reset() { + *x = CaptchaRequest{} + mi := &file_auth_login_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CaptchaRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaptchaRequest) ProtoMessage() {} + +func (x *CaptchaRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[14] + 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 CaptchaRequest.ProtoReflect.Descriptor instead. +func (*CaptchaRequest) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{14} +} + +func (x *CaptchaRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CaptchaRequest) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *CaptchaRequest) GetReload() bool { + if x != nil { + return x.Reload + } + return false +} + +func (x *CaptchaRequest) GetTs() string { + if x != nil { + return x.Ts + } + return "" +} + +type CaptchaResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CaptchaResponse) Reset() { + *x = CaptchaResponse{} + mi := &file_auth_login_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CaptchaResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CaptchaResponse) ProtoMessage() {} + +func (x *CaptchaResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[15] + 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 CaptchaResponse.ProtoReflect.Descriptor instead. +func (*CaptchaResponse) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{15} +} + +func (x *CaptchaResponse) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *CaptchaResponse) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *CaptchaResponse) GetData() string { + if x != nil { + return x.Data + } + return "" +} + +type RegisterRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *RegisterRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RegisterRequest) Reset() { + *x = RegisterRequest{} + mi := &file_auth_login_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RegisterRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterRequest) ProtoMessage() {} + +func (x *RegisterRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[16] + 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 RegisterRequest.ProtoReflect.Descriptor instead. +func (*RegisterRequest) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{16} +} + +func (x *RegisterRequest) GetData() *RegisterRequest_Data { + if x != nil { + return x.Data + } + return nil +} + +type RegisterResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + Data *RegisterResponse_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RegisterResponse) Reset() { + *x = RegisterResponse{} + mi := &file_auth_login_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RegisterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterResponse) ProtoMessage() {} + +func (x *RegisterResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[17] + 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 RegisterResponse.ProtoReflect.Descriptor instead. +func (*RegisterResponse) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{17} +} + +func (x *RegisterResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +func (x *RegisterResponse) GetData() *RegisterResponse_Data { + if x != nil { + return x.Data + } + return nil +} + +type LogoutRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LogoutRequest) Reset() { + *x = LogoutRequest{} + mi := &file_auth_login_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LogoutRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogoutRequest) ProtoMessage() {} + +func (x *LogoutRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. +func (*LogoutRequest) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{18} +} + +func (x *LogoutRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type LogoutResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LogoutResponse) Reset() { + *x = LogoutResponse{} + mi := &file_auth_login_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LogoutResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogoutResponse) ProtoMessage() {} + +func (x *LogoutResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead. +func (*LogoutResponse) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{19} +} + +func (x *LogoutResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +type TokenRefreshRequest_Data struct { + state protoimpl.MessageState `protogen:"open.v1"` + RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TokenRefreshRequest_Data) Reset() { + *x = TokenRefreshRequest_Data{} + mi := &file_auth_login_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TokenRefreshRequest_Data) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TokenRefreshRequest_Data) ProtoMessage() {} + +func (x *TokenRefreshRequest_Data) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TokenRefreshRequest_Data.ProtoReflect.Descriptor instead. +func (*TokenRefreshRequest_Data) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{0, 0} +} + +func (x *TokenRefreshRequest_Data) GetRefreshToken() string { + if x != nil { + return x.RefreshToken + } + return "" +} + +type LoginRequest_Data struct { + state protoimpl.MessageState `protogen:"open.v1"` + Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` + CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LoginRequest_Data) Reset() { + *x = LoginRequest_Data{} + mi := &file_auth_login_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LoginRequest_Data) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LoginRequest_Data) ProtoMessage() {} + +func (x *LoginRequest_Data) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[21] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LoginRequest_Data.ProtoReflect.Descriptor instead. +func (*LoginRequest_Data) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{2, 0} +} + +func (x *LoginRequest_Data) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *LoginRequest_Data) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *LoginRequest_Data) GetCaptchaId() string { + if x != nil { + return x.CaptchaId + } + return "" +} + +func (x *LoginRequest_Data) GetCaptchaCode() string { + if x != nil { + return x.CaptchaCode + } + return "" +} + +type RegisterRequest_Data struct { + state protoimpl.MessageState `protogen:"open.v1"` + Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` + CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RegisterRequest_Data) Reset() { + *x = RegisterRequest_Data{} + mi := &file_auth_login_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RegisterRequest_Data) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterRequest_Data) ProtoMessage() {} + +func (x *RegisterRequest_Data) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_proto_msgTypes[24] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RegisterRequest_Data.ProtoReflect.Descriptor instead. +func (*RegisterRequest_Data) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{16, 0} +} + +func (x *RegisterRequest_Data) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *RegisterRequest_Data) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *RegisterRequest_Data) GetCaptchaId() string { + if x != nil { + return x.CaptchaId + } + return "" +} + +func (x *RegisterRequest_Data) GetCaptchaCode() string { + if x != nil { + return x.CaptchaCode + } + return "" +} + +type RegisterResponse_Data struct { + state protoimpl.MessageState `protogen:"open.v1"` + Redirect string `protobuf:"bytes,1,opt,name=redirect,proto3" json:"redirect,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RegisterResponse_Data) Reset() { + *x = RegisterResponse_Data{} + mi := &file_auth_login_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RegisterResponse_Data) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterResponse_Data) ProtoMessage() {} + +func (x *RegisterResponse_Data) ProtoReflect() protoreflect.Message { + mi := &file_auth_login_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 RegisterResponse_Data.ProtoReflect.Descriptor instead. +func (*RegisterResponse_Data) Descriptor() ([]byte, []int) { + return file_auth_login_proto_rawDescGZIP(), []int{17, 0} +} + +func (x *RegisterResponse_Data) GetRedirect() string { + if x != nil { + return x.Redirect + } + return "" +} + +var File_auth_login_proto protoreflect.FileDescriptor + +const file_auth_login_proto_rawDesc = "" + + "\n" + + "\x10auth/login.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1csecurity/v1/credential.proto\x1a\x17validate/validate.proto\"\x90\x01\n" + + "\x13TokenRefreshRequest\x12B\n" + + "\x04data\x18\x02 \x01(\v2..api.v1.services.auth.TokenRefreshRequest.DataR\x04data\x1a5\n" + + "\x04Data\x12-\n" + + "\rrefresh_token\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\rrefresh_token\"V\n" + + "\x14TokenRefreshResponse\x12>\n" + + "\x05token\x18\x01 \x01(\v2(.contrib.api.security.v1.TokenCredentialR\x05token\"\xf4\x01\n" + + "\fLoginRequest\x12;\n" + + "\x04data\x18\x02 \x01(\v2'.api.v1.services.auth.LoginRequest.DataR\x04data\x1a\xa6\x01\n" + + "\x04Data\x12#\n" + + "\busername\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12#\n" + + "\bpassword\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\bpassword\x12'\n" + + "\n" + + "captcha_id\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\n" + + "captcha_id\x12+\n" + + "\fcaptcha_code\x18\x04 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\fcaptcha_code\"O\n" + + "\rLoginResponse\x12>\n" + + "\x05token\x18\x01 \x01(\v2(.contrib.api.security.v1.TokenCredentialR\x05token\"3\n" + + "\x17CurrentUserRequestQuery\x12\x18\n" + + "\auser_id\x18\x01 \x01(\x03R\auser_id\"W\n" + + "\x12CurrentUserRequest\x12A\n" + + "\x04data\x18\x01 \x01(\v2-.api.v1.services.auth.CurrentUserRequestQueryR\x04data\"Y\n" + + "\x13CurrentUserResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\":\n" + + "\x10CaptchaIdRequest\x12\x0e\n" + + "\x02ts\x18\x01 \x01(\tR\x02ts\x12\x16\n" + + "\x06reload\x18\x02 \x01(\bR\x06reload\"'\n" + + "\x11CaptchaIdResponse\x12\x12\n" + + "\x04data\x18\x01 \x01(\tR\x04data\"g\n" + + "\x13CaptchaImageRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" + + "\x06reload\x18\x02 \x01(\tR\x06reload\x12(\n" + + "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\"M\n" + + "\vCaptchaData\x12\x1d\n" + + "\n" + + "captcha_id\x18\x01 \x01(\tR\tcaptchaId\x12\x1f\n" + + "\vcaptcha_img\x18\x02 \x01(\tR\n" + + "captchaImg\"\xbb\x01\n" + + "\x14CaptchaImageResponse\x12Q\n" + + "\aheaders\x18\x01 \x03(\v27.api.v1.services.auth.CaptchaImageResponse.HeadersEntryR\aheaders\x12\x14\n" + + "\x05image\x18\x02 \x01(\fR\x05image\x1a:\n" + + "\fHeadersEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"g\n" + + "\x13CaptchaAudioRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" + + "\x06reload\x18\x02 \x01(\tR\x06reload\x12(\n" + + "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\xbb\x01\n" + + "\x14CaptchaAudioResponse\x12Q\n" + + "\aheaders\x18\x01 \x03(\v27.api.v1.services.auth.CaptchaAudioResponse.HeadersEntryR\aheaders\x12\x14\n" + + "\x05audio\x18\x02 \x01(\fR\x05audio\x1a:\n" + + "\fHeadersEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\\\n" + + "\x0eCaptchaRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04type\x18\x02 \x01(\tR\x04type\x12\x16\n" + + "\x06reload\x18\x03 \x01(\bR\x06reload\x12\x0e\n" + + "\x02ts\x18\x04 \x01(\tR\x02ts\"I\n" + + "\x0fCaptchaResponse\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04type\x18\x02 \x01(\tR\x04type\x12\x12\n" + + "\x04data\x18\x03 \x01(\tR\x04data\"\xfa\x01\n" + + "\x0fRegisterRequest\x12>\n" + + "\x04data\x18\x02 \x01(\v2*.api.v1.services.auth.RegisterRequest.DataR\x04data\x1a\xa6\x01\n" + + "\x04Data\x12#\n" + + "\busername\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12#\n" + + "\bpassword\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\bpassword\x12'\n" + + "\n" + + "captcha_id\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\n" + + "captcha_id\x12+\n" + + "\fcaptcha_code\x18\x04 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\fcaptcha_code\"\x91\x01\n" + + "\x10RegisterResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\x12?\n" + + "\x04data\x18\x02 \x01(\v2+.api.v1.services.auth.RegisterResponse.DataR\x04data\x1a\"\n" + + "\x04Data\x12\x1a\n" + + "\bredirect\x18\x01 \x01(\tR\bredirect\"9\n" + + "\rLogoutRequest\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"*\n" + + "\x0eLogoutResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess2\xc2\a\n" + + "\fLoginService\x12k\n" + + "\aCaptcha\x12$.api.v1.services.auth.CaptchaRequest\x1a%.api.v1.services.auth.CaptchaResponse\"\x13\x82\xd3\xe4\x93\x02\rb\x01*\x12\b/captcha\x12q\n" + + "\tCaptchaId\x12&.api.v1.services.auth.CaptchaIdRequest\x1a'.api.v1.services.auth.CaptchaIdResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/captcha/id\x12\x80\x01\n" + + "\fCaptchaImage\x12).api.v1.services.auth.CaptchaImageRequest\x1a*.api.v1.services.auth.CaptchaImageResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/image\x12\x80\x01\n" + + "\fCaptchaAudio\x12).api.v1.services.auth.CaptchaAudioRequest\x1a*.api.v1.services.auth.CaptchaAudioResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/audio\x12f\n" + + "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x14\x82\xd3\xe4\x93\x02\x0e:\x04data\"\x06/login\x12j\n" + + "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/logout\x12r\n" + + "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a&.api.v1.services.auth.RegisterResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x04data\"\t/register\x12\x83\x01\n" + + "\fTokenRefresh\x12).api.v1.services.auth.TokenRefreshRequest\x1a*.api.v1.services.auth.TokenRefreshResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04data\"\x0e/token/refreshB\xd1\x01\n" + + "\x18com.api.v1.services.authB\n" + + "LoginProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + +var ( + file_auth_login_proto_rawDescOnce sync.Once + file_auth_login_proto_rawDescData []byte +) + +func file_auth_login_proto_rawDescGZIP() []byte { + file_auth_login_proto_rawDescOnce.Do(func() { + file_auth_login_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_login_proto_rawDesc), len(file_auth_login_proto_rawDesc))) + }) + return file_auth_login_proto_rawDescData +} + +var file_auth_login_proto_msgTypes = make([]protoimpl.MessageInfo, 26) +var file_auth_login_proto_goTypes = []any{ + (*TokenRefreshRequest)(nil), // 0: api.v1.services.auth.TokenRefreshRequest + (*TokenRefreshResponse)(nil), // 1: api.v1.services.auth.TokenRefreshResponse + (*LoginRequest)(nil), // 2: api.v1.services.auth.LoginRequest + (*LoginResponse)(nil), // 3: api.v1.services.auth.LoginResponse + (*CurrentUserRequestQuery)(nil), // 4: api.v1.services.auth.CurrentUserRequestQuery + (*CurrentUserRequest)(nil), // 5: api.v1.services.auth.CurrentUserRequest + (*CurrentUserResponse)(nil), // 6: api.v1.services.auth.CurrentUserResponse + (*CaptchaIdRequest)(nil), // 7: api.v1.services.auth.CaptchaIdRequest + (*CaptchaIdResponse)(nil), // 8: api.v1.services.auth.CaptchaIdResponse + (*CaptchaImageRequest)(nil), // 9: api.v1.services.auth.CaptchaImageRequest + (*CaptchaData)(nil), // 10: api.v1.services.auth.CaptchaData + (*CaptchaImageResponse)(nil), // 11: api.v1.services.auth.CaptchaImageResponse + (*CaptchaAudioRequest)(nil), // 12: api.v1.services.auth.CaptchaAudioRequest + (*CaptchaAudioResponse)(nil), // 13: api.v1.services.auth.CaptchaAudioResponse + (*CaptchaRequest)(nil), // 14: api.v1.services.auth.CaptchaRequest + (*CaptchaResponse)(nil), // 15: api.v1.services.auth.CaptchaResponse + (*RegisterRequest)(nil), // 16: api.v1.services.auth.RegisterRequest + (*RegisterResponse)(nil), // 17: api.v1.services.auth.RegisterResponse + (*LogoutRequest)(nil), // 18: api.v1.services.auth.LogoutRequest + (*LogoutResponse)(nil), // 19: api.v1.services.auth.LogoutResponse + (*TokenRefreshRequest_Data)(nil), // 20: api.v1.services.auth.TokenRefreshRequest.Data + (*LoginRequest_Data)(nil), // 21: api.v1.services.auth.LoginRequest.Data + nil, // 22: api.v1.services.auth.CaptchaImageResponse.HeadersEntry + nil, // 23: api.v1.services.auth.CaptchaAudioResponse.HeadersEntry + (*RegisterRequest_Data)(nil), // 24: api.v1.services.auth.RegisterRequest.Data + (*RegisterResponse_Data)(nil), // 25: api.v1.services.auth.RegisterResponse.Data + (*v1.TokenCredential)(nil), // 26: contrib.api.security.v1.TokenCredential + (*anypb.Any)(nil), // 27: google.protobuf.Any +} +var file_auth_login_proto_depIdxs = []int32{ + 20, // 0: api.v1.services.auth.TokenRefreshRequest.data:type_name -> api.v1.services.auth.TokenRefreshRequest.Data + 26, // 1: api.v1.services.auth.TokenRefreshResponse.token:type_name -> contrib.api.security.v1.TokenCredential + 21, // 2: api.v1.services.auth.LoginRequest.data:type_name -> api.v1.services.auth.LoginRequest.Data + 26, // 3: api.v1.services.auth.LoginResponse.token:type_name -> contrib.api.security.v1.TokenCredential + 4, // 4: api.v1.services.auth.CurrentUserRequest.data:type_name -> api.v1.services.auth.CurrentUserRequestQuery + 27, // 5: api.v1.services.auth.CurrentUserResponse.data:type_name -> google.protobuf.Any + 27, // 6: api.v1.services.auth.CaptchaImageRequest.data:type_name -> google.protobuf.Any + 22, // 7: api.v1.services.auth.CaptchaImageResponse.headers:type_name -> api.v1.services.auth.CaptchaImageResponse.HeadersEntry + 27, // 8: api.v1.services.auth.CaptchaAudioRequest.data:type_name -> google.protobuf.Any + 23, // 9: api.v1.services.auth.CaptchaAudioResponse.headers:type_name -> api.v1.services.auth.CaptchaAudioResponse.HeadersEntry + 24, // 10: api.v1.services.auth.RegisterRequest.data:type_name -> api.v1.services.auth.RegisterRequest.Data + 25, // 11: api.v1.services.auth.RegisterResponse.data:type_name -> api.v1.services.auth.RegisterResponse.Data + 27, // 12: api.v1.services.auth.LogoutRequest.data:type_name -> google.protobuf.Any + 14, // 13: api.v1.services.auth.LoginService.Captcha:input_type -> api.v1.services.auth.CaptchaRequest + 7, // 14: api.v1.services.auth.LoginService.CaptchaId:input_type -> api.v1.services.auth.CaptchaIdRequest + 9, // 15: api.v1.services.auth.LoginService.CaptchaImage:input_type -> api.v1.services.auth.CaptchaImageRequest + 12, // 16: api.v1.services.auth.LoginService.CaptchaAudio:input_type -> api.v1.services.auth.CaptchaAudioRequest + 2, // 17: api.v1.services.auth.LoginService.Login:input_type -> api.v1.services.auth.LoginRequest + 18, // 18: api.v1.services.auth.LoginService.Logout:input_type -> api.v1.services.auth.LogoutRequest + 16, // 19: api.v1.services.auth.LoginService.Register:input_type -> api.v1.services.auth.RegisterRequest + 0, // 20: api.v1.services.auth.LoginService.TokenRefresh:input_type -> api.v1.services.auth.TokenRefreshRequest + 15, // 21: api.v1.services.auth.LoginService.Captcha:output_type -> api.v1.services.auth.CaptchaResponse + 8, // 22: api.v1.services.auth.LoginService.CaptchaId:output_type -> api.v1.services.auth.CaptchaIdResponse + 11, // 23: api.v1.services.auth.LoginService.CaptchaImage:output_type -> api.v1.services.auth.CaptchaImageResponse + 13, // 24: api.v1.services.auth.LoginService.CaptchaAudio:output_type -> api.v1.services.auth.CaptchaAudioResponse + 3, // 25: api.v1.services.auth.LoginService.Login:output_type -> api.v1.services.auth.LoginResponse + 19, // 26: api.v1.services.auth.LoginService.Logout:output_type -> api.v1.services.auth.LogoutResponse + 17, // 27: api.v1.services.auth.LoginService.Register:output_type -> api.v1.services.auth.RegisterResponse + 1, // 28: api.v1.services.auth.LoginService.TokenRefresh:output_type -> api.v1.services.auth.TokenRefreshResponse + 21, // [21:29] is the sub-list for method output_type + 13, // [13:21] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name +} + +func init() { file_auth_login_proto_init() } +func file_auth_login_proto_init() { + if File_auth_login_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_login_proto_rawDesc), len(file_auth_login_proto_rawDesc)), + NumEnums: 0, + NumMessages: 26, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_auth_login_proto_goTypes, + DependencyIndexes: file_auth_login_proto_depIdxs, + MessageInfos: file_auth_login_proto_msgTypes, + }.Build() + File_auth_login_proto = out.File + file_auth_login_proto_goTypes = nil + file_auth_login_proto_depIdxs = nil +} diff --git a/api/v1/services/auth/login.pb.gw.go b/api/v1/services/auth/login.pb.gw.go new file mode 100644 index 00000000..6c520321 --- /dev/null +++ b/api/v1/services/auth/login.pb.gw.go @@ -0,0 +1,631 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: auth/login.proto + +/* +Package auth is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package auth + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_LoginService_Captcha_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_LoginService_Captcha_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CaptchaRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_Captcha_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.Captcha(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_LoginService_Captcha_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CaptchaRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_Captcha_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.Captcha(ctx, &protoReq) + return msg, metadata, err +} + +var filter_LoginService_CaptchaId_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_LoginService_CaptchaId_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CaptchaIdRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaId_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CaptchaId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_LoginService_CaptchaId_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CaptchaIdRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaId_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CaptchaId(ctx, &protoReq) + return msg, metadata, err +} + +var filter_LoginService_CaptchaImage_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_LoginService_CaptchaImage_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CaptchaImageRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaImage_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CaptchaImage(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_LoginService_CaptchaImage_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CaptchaImageRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaImage_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CaptchaImage(ctx, &protoReq) + return msg, metadata, err +} + +var filter_LoginService_CaptchaAudio_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_LoginService_CaptchaAudio_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CaptchaAudioRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaAudio_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CaptchaAudio(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_LoginService_CaptchaAudio_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CaptchaAudioRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaAudio_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CaptchaAudio(ctx, &protoReq) + return msg, metadata, err +} + +func request_LoginService_Login_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq LoginRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_LoginService_Login_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq LoginRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.Login(ctx, &protoReq) + return msg, metadata, err +} + +func request_LoginService_Logout_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq LogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.Logout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_LoginService_Logout_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq LogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.Logout(ctx, &protoReq) + return msg, metadata, err +} + +func request_LoginService_Register_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RegisterRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.Register(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_LoginService_Register_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RegisterRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.Register(ctx, &protoReq) + return msg, metadata, err +} + +func request_LoginService_TokenRefresh_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq TokenRefreshRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.TokenRefresh(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_LoginService_TokenRefresh_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq TokenRefreshRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.TokenRefresh(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterLoginServiceHandlerServer registers the http handlers for service LoginService to "mux". +// UnaryRPC :call LoginServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterLoginServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server LoginServiceServer) error { + mux.Handle(http.MethodGet, pattern_LoginService_Captcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Captcha", runtime.WithHTTPPathPattern("/captcha")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_LoginService_Captcha_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_Captcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_LoginService_CaptchaId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaId", runtime.WithHTTPPathPattern("/captcha/id")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_LoginService_CaptchaId_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_CaptchaId_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_LoginService_CaptchaImage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaImage", runtime.WithHTTPPathPattern("/captcha/image")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_LoginService_CaptchaImage_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_CaptchaImage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_LoginService_CaptchaAudio_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaAudio", runtime.WithHTTPPathPattern("/captcha/audio")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_LoginService_CaptchaAudio_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_CaptchaAudio_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_LoginService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Login", runtime.WithHTTPPathPattern("/login")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_LoginService_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_LoginService_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Logout", runtime.WithHTTPPathPattern("/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_LoginService_Logout_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_LoginService_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Register", runtime.WithHTTPPathPattern("/register")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_LoginService_Register_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_LoginService_TokenRefresh_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/TokenRefresh", runtime.WithHTTPPathPattern("/token/refresh")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_LoginService_TokenRefresh_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_TokenRefresh_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterLoginServiceHandlerFromEndpoint is same as RegisterLoginServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterLoginServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterLoginServiceHandler(ctx, mux, conn) +} + +// RegisterLoginServiceHandler registers the http handlers for service LoginService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterLoginServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterLoginServiceHandlerClient(ctx, mux, NewLoginServiceClient(conn)) +} + +// RegisterLoginServiceHandlerClient registers the http handlers for service LoginService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "LoginServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LoginServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "LoginServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client LoginServiceClient) error { + mux.Handle(http.MethodGet, pattern_LoginService_Captcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Captcha", runtime.WithHTTPPathPattern("/captcha")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_LoginService_Captcha_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_Captcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_LoginService_CaptchaId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaId", runtime.WithHTTPPathPattern("/captcha/id")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_LoginService_CaptchaId_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_CaptchaId_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_LoginService_CaptchaImage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaImage", runtime.WithHTTPPathPattern("/captcha/image")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_LoginService_CaptchaImage_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_CaptchaImage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_LoginService_CaptchaAudio_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaAudio", runtime.WithHTTPPathPattern("/captcha/audio")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_LoginService_CaptchaAudio_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_CaptchaAudio_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_LoginService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Login", runtime.WithHTTPPathPattern("/login")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_LoginService_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_LoginService_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Logout", runtime.WithHTTPPathPattern("/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_LoginService_Logout_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_LoginService_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Register", runtime.WithHTTPPathPattern("/register")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_LoginService_Register_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_LoginService_TokenRefresh_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/TokenRefresh", runtime.WithHTTPPathPattern("/token/refresh")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_LoginService_TokenRefresh_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_LoginService_TokenRefresh_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_LoginService_Captcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"captcha"}, "")) + pattern_LoginService_CaptchaId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"captcha", "id"}, "")) + pattern_LoginService_CaptchaImage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"captcha", "image"}, "")) + pattern_LoginService_CaptchaAudio_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"captcha", "audio"}, "")) + pattern_LoginService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"login"}, "")) + pattern_LoginService_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"logout"}, "")) + pattern_LoginService_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"register"}, "")) + pattern_LoginService_TokenRefresh_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"token", "refresh"}, "")) +) + +var ( + forward_LoginService_Captcha_0 = runtime.ForwardResponseMessage + forward_LoginService_CaptchaId_0 = runtime.ForwardResponseMessage + forward_LoginService_CaptchaImage_0 = runtime.ForwardResponseMessage + forward_LoginService_CaptchaAudio_0 = runtime.ForwardResponseMessage + forward_LoginService_Login_0 = runtime.ForwardResponseMessage + forward_LoginService_Logout_0 = runtime.ForwardResponseMessage + forward_LoginService_Register_0 = runtime.ForwardResponseMessage + forward_LoginService_TokenRefresh_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/auth/login.pb.validate.go b/api/v1/services/auth/login.pb.validate.go new file mode 100644 index 00000000..45969891 --- /dev/null +++ b/api/v1/services/auth/login.pb.validate.go @@ -0,0 +1,2930 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: auth/login.proto + +package auth + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on TokenRefreshRequest 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 *TokenRefreshRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on TokenRefreshRequest 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 +// TokenRefreshRequestMultiError, or nil if none found. +func (m *TokenRefreshRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *TokenRefreshRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, TokenRefreshRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, TokenRefreshRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return TokenRefreshRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return TokenRefreshRequestMultiError(errors) + } + + return nil +} + +// TokenRefreshRequestMultiError is an error wrapping multiple validation +// errors returned by TokenRefreshRequest.ValidateAll() if the designated +// constraints aren't met. +type TokenRefreshRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m TokenRefreshRequestMultiError) 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 TokenRefreshRequestMultiError) AllErrors() []error { return m } + +// TokenRefreshRequestValidationError is the validation error returned by +// TokenRefreshRequest.Validate if the designated constraints aren't met. +type TokenRefreshRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e TokenRefreshRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e TokenRefreshRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e TokenRefreshRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e TokenRefreshRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e TokenRefreshRequestValidationError) ErrorName() string { + return "TokenRefreshRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e TokenRefreshRequestValidationError) 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 %sTokenRefreshRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = TokenRefreshRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = TokenRefreshRequestValidationError{} + +// Validate checks the field values on TokenRefreshResponse 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 *TokenRefreshResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on TokenRefreshResponse 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 +// TokenRefreshResponseMultiError, or nil if none found. +func (m *TokenRefreshResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *TokenRefreshResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetToken()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, TokenRefreshResponseValidationError{ + field: "Token", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, TokenRefreshResponseValidationError{ + field: "Token", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetToken()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return TokenRefreshResponseValidationError{ + field: "Token", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return TokenRefreshResponseMultiError(errors) + } + + return nil +} + +// TokenRefreshResponseMultiError is an error wrapping multiple validation +// errors returned by TokenRefreshResponse.ValidateAll() if the designated +// constraints aren't met. +type TokenRefreshResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m TokenRefreshResponseMultiError) 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 TokenRefreshResponseMultiError) AllErrors() []error { return m } + +// TokenRefreshResponseValidationError is the validation error returned by +// TokenRefreshResponse.Validate if the designated constraints aren't met. +type TokenRefreshResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e TokenRefreshResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e TokenRefreshResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e TokenRefreshResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e TokenRefreshResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e TokenRefreshResponseValidationError) ErrorName() string { + return "TokenRefreshResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e TokenRefreshResponseValidationError) 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 %sTokenRefreshResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = TokenRefreshResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = TokenRefreshResponseValidationError{} + +// 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. +func (m *LoginRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on LoginRequest 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 LoginRequestMultiError, or +// nil if none found. +func (m *LoginRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *LoginRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, LoginRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, LoginRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return LoginRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return LoginRequestMultiError(errors) + } + + return nil +} + +// LoginRequestMultiError is an error wrapping multiple validation errors +// returned by LoginRequest.ValidateAll() if the designated constraints aren't met. +type LoginRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m LoginRequestMultiError) 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 LoginRequestMultiError) AllErrors() []error { return m } + +// LoginRequestValidationError is the validation error returned by +// LoginRequest.Validate if the designated constraints aren't met. +type LoginRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e LoginRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e LoginRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e LoginRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e LoginRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e LoginRequestValidationError) ErrorName() string { return "LoginRequestValidationError" } + +// Error satisfies the builtin error interface +func (e LoginRequestValidationError) 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 %sLoginRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = LoginRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = LoginRequestValidationError{} + +// Validate checks the field values on LoginResponse 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 *LoginResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on LoginResponse 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 LoginResponseMultiError, or +// nil if none found. +func (m *LoginResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *LoginResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetToken()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, LoginResponseValidationError{ + field: "Token", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, LoginResponseValidationError{ + field: "Token", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetToken()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return LoginResponseValidationError{ + field: "Token", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return LoginResponseMultiError(errors) + } + + return nil +} + +// LoginResponseMultiError is an error wrapping multiple validation errors +// returned by LoginResponse.ValidateAll() if the designated constraints +// aren't met. +type LoginResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m LoginResponseMultiError) 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 LoginResponseMultiError) AllErrors() []error { return m } + +// LoginResponseValidationError is the validation error returned by +// LoginResponse.Validate if the designated constraints aren't met. +type LoginResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e LoginResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e LoginResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e LoginResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e LoginResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e LoginResponseValidationError) ErrorName() string { return "LoginResponseValidationError" } + +// Error satisfies the builtin error interface +func (e LoginResponseValidationError) 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 %sLoginResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = LoginResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = LoginResponseValidationError{} + +// Validate checks the field values on CurrentUserRequestQuery 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 *CurrentUserRequestQuery) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CurrentUserRequestQuery 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 +// CurrentUserRequestQueryMultiError, or nil if none found. +func (m *CurrentUserRequestQuery) ValidateAll() error { + return m.validate(true) +} + +func (m *CurrentUserRequestQuery) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for UserId + + if len(errors) > 0 { + return CurrentUserRequestQueryMultiError(errors) + } + + return nil +} + +// CurrentUserRequestQueryMultiError is an error wrapping multiple validation +// errors returned by CurrentUserRequestQuery.ValidateAll() if the designated +// constraints aren't met. +type CurrentUserRequestQueryMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CurrentUserRequestQueryMultiError) 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 CurrentUserRequestQueryMultiError) AllErrors() []error { return m } + +// CurrentUserRequestQueryValidationError is the validation error returned by +// CurrentUserRequestQuery.Validate if the designated constraints aren't met. +type CurrentUserRequestQueryValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CurrentUserRequestQueryValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CurrentUserRequestQueryValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CurrentUserRequestQueryValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CurrentUserRequestQueryValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CurrentUserRequestQueryValidationError) ErrorName() string { + return "CurrentUserRequestQueryValidationError" +} + +// Error satisfies the builtin error interface +func (e CurrentUserRequestQueryValidationError) 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 %sCurrentUserRequestQuery.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CurrentUserRequestQueryValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CurrentUserRequestQueryValidationError{} + +// Validate checks the field values on CurrentUserRequest 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 *CurrentUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CurrentUserRequest 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 +// CurrentUserRequestMultiError, or nil if none found. +func (m *CurrentUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CurrentUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CurrentUserRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CurrentUserRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CurrentUserRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CurrentUserRequestMultiError(errors) + } + + return nil +} + +// CurrentUserRequestMultiError is an error wrapping multiple validation errors +// returned by CurrentUserRequest.ValidateAll() if the designated constraints +// aren't met. +type CurrentUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CurrentUserRequestMultiError) 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 CurrentUserRequestMultiError) AllErrors() []error { return m } + +// CurrentUserRequestValidationError is the validation error returned by +// CurrentUserRequest.Validate if the designated constraints aren't met. +type CurrentUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CurrentUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CurrentUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CurrentUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CurrentUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CurrentUserRequestValidationError) ErrorName() string { + return "CurrentUserRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CurrentUserRequestValidationError) 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 %sCurrentUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CurrentUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CurrentUserRequestValidationError{} + +// Validate checks the field values on CurrentUserResponse 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 *CurrentUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CurrentUserResponse 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 +// CurrentUserResponseMultiError, or nil if none found. +func (m *CurrentUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CurrentUserResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Success + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CurrentUserResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CurrentUserResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CurrentUserResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CurrentUserResponseMultiError(errors) + } + + return nil +} + +// CurrentUserResponseMultiError is an error wrapping multiple validation +// errors returned by CurrentUserResponse.ValidateAll() if the designated +// constraints aren't met. +type CurrentUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CurrentUserResponseMultiError) 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 CurrentUserResponseMultiError) AllErrors() []error { return m } + +// CurrentUserResponseValidationError is the validation error returned by +// CurrentUserResponse.Validate if the designated constraints aren't met. +type CurrentUserResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CurrentUserResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CurrentUserResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CurrentUserResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CurrentUserResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CurrentUserResponseValidationError) ErrorName() string { + return "CurrentUserResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CurrentUserResponseValidationError) 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 %sCurrentUserResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CurrentUserResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CurrentUserResponseValidationError{} + +// Validate checks the field values on CaptchaIdRequest 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 *CaptchaIdRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaptchaIdRequest 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 +// CaptchaIdRequestMultiError, or nil if none found. +func (m *CaptchaIdRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CaptchaIdRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Ts + + // no validation rules for Reload + + if len(errors) > 0 { + return CaptchaIdRequestMultiError(errors) + } + + return nil +} + +// CaptchaIdRequestMultiError is an error wrapping multiple validation errors +// returned by CaptchaIdRequest.ValidateAll() if the designated constraints +// aren't met. +type CaptchaIdRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaptchaIdRequestMultiError) 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 CaptchaIdRequestMultiError) AllErrors() []error { return m } + +// CaptchaIdRequestValidationError is the validation error returned by +// CaptchaIdRequest.Validate if the designated constraints aren't met. +type CaptchaIdRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaptchaIdRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaptchaIdRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaptchaIdRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaptchaIdRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaptchaIdRequestValidationError) ErrorName() string { return "CaptchaIdRequestValidationError" } + +// Error satisfies the builtin error interface +func (e CaptchaIdRequestValidationError) 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 %sCaptchaIdRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaptchaIdRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaptchaIdRequestValidationError{} + +// Validate checks the field values on CaptchaIdResponse 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 *CaptchaIdResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaptchaIdResponse 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 +// CaptchaIdResponseMultiError, or nil if none found. +func (m *CaptchaIdResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CaptchaIdResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Data + + if len(errors) > 0 { + return CaptchaIdResponseMultiError(errors) + } + + return nil +} + +// CaptchaIdResponseMultiError is an error wrapping multiple validation errors +// returned by CaptchaIdResponse.ValidateAll() if the designated constraints +// aren't met. +type CaptchaIdResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaptchaIdResponseMultiError) 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 CaptchaIdResponseMultiError) AllErrors() []error { return m } + +// CaptchaIdResponseValidationError is the validation error returned by +// CaptchaIdResponse.Validate if the designated constraints aren't met. +type CaptchaIdResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaptchaIdResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaptchaIdResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaptchaIdResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaptchaIdResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaptchaIdResponseValidationError) ErrorName() string { + return "CaptchaIdResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CaptchaIdResponseValidationError) 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 %sCaptchaIdResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaptchaIdResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaptchaIdResponseValidationError{} + +// Validate checks the field values on CaptchaImageRequest 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 *CaptchaImageRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaptchaImageRequest 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 +// CaptchaImageRequestMultiError, or nil if none found. +func (m *CaptchaImageRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CaptchaImageRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Reload + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CaptchaImageRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CaptchaImageRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CaptchaImageRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CaptchaImageRequestMultiError(errors) + } + + return nil +} + +// CaptchaImageRequestMultiError is an error wrapping multiple validation +// errors returned by CaptchaImageRequest.ValidateAll() if the designated +// constraints aren't met. +type CaptchaImageRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaptchaImageRequestMultiError) 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 CaptchaImageRequestMultiError) AllErrors() []error { return m } + +// CaptchaImageRequestValidationError is the validation error returned by +// CaptchaImageRequest.Validate if the designated constraints aren't met. +type CaptchaImageRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaptchaImageRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaptchaImageRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaptchaImageRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaptchaImageRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaptchaImageRequestValidationError) ErrorName() string { + return "CaptchaImageRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CaptchaImageRequestValidationError) 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 %sCaptchaImageRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaptchaImageRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaptchaImageRequestValidationError{} + +// Validate checks the field values on CaptchaData 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 *CaptchaData) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaptchaData 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 CaptchaDataMultiError, or +// nil if none found. +func (m *CaptchaData) ValidateAll() error { + return m.validate(true) +} + +func (m *CaptchaData) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for CaptchaId + + // no validation rules for CaptchaImg + + if len(errors) > 0 { + return CaptchaDataMultiError(errors) + } + + return nil +} + +// CaptchaDataMultiError is an error wrapping multiple validation errors +// returned by CaptchaData.ValidateAll() if the designated constraints aren't met. +type CaptchaDataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaptchaDataMultiError) 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 CaptchaDataMultiError) AllErrors() []error { return m } + +// CaptchaDataValidationError is the validation error returned by +// CaptchaData.Validate if the designated constraints aren't met. +type CaptchaDataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaptchaDataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaptchaDataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaptchaDataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaptchaDataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaptchaDataValidationError) ErrorName() string { return "CaptchaDataValidationError" } + +// Error satisfies the builtin error interface +func (e CaptchaDataValidationError) 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 %sCaptchaData.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaptchaDataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaptchaDataValidationError{} + +// Validate checks the field values on CaptchaImageResponse 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 *CaptchaImageResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaptchaImageResponse 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 +// CaptchaImageResponseMultiError, or nil if none found. +func (m *CaptchaImageResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CaptchaImageResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Headers + + // no validation rules for Image + + if len(errors) > 0 { + return CaptchaImageResponseMultiError(errors) + } + + return nil +} + +// CaptchaImageResponseMultiError is an error wrapping multiple validation +// errors returned by CaptchaImageResponse.ValidateAll() if the designated +// constraints aren't met. +type CaptchaImageResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaptchaImageResponseMultiError) 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 CaptchaImageResponseMultiError) AllErrors() []error { return m } + +// CaptchaImageResponseValidationError is the validation error returned by +// CaptchaImageResponse.Validate if the designated constraints aren't met. +type CaptchaImageResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaptchaImageResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaptchaImageResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaptchaImageResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaptchaImageResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaptchaImageResponseValidationError) ErrorName() string { + return "CaptchaImageResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CaptchaImageResponseValidationError) 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 %sCaptchaImageResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaptchaImageResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaptchaImageResponseValidationError{} + +// Validate checks the field values on CaptchaAudioRequest 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 *CaptchaAudioRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaptchaAudioRequest 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 +// CaptchaAudioRequestMultiError, or nil if none found. +func (m *CaptchaAudioRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CaptchaAudioRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Reload + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CaptchaAudioRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CaptchaAudioRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CaptchaAudioRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CaptchaAudioRequestMultiError(errors) + } + + return nil +} + +// CaptchaAudioRequestMultiError is an error wrapping multiple validation +// errors returned by CaptchaAudioRequest.ValidateAll() if the designated +// constraints aren't met. +type CaptchaAudioRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaptchaAudioRequestMultiError) 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 CaptchaAudioRequestMultiError) AllErrors() []error { return m } + +// CaptchaAudioRequestValidationError is the validation error returned by +// CaptchaAudioRequest.Validate if the designated constraints aren't met. +type CaptchaAudioRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaptchaAudioRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaptchaAudioRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaptchaAudioRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaptchaAudioRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaptchaAudioRequestValidationError) ErrorName() string { + return "CaptchaAudioRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CaptchaAudioRequestValidationError) 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 %sCaptchaAudioRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaptchaAudioRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaptchaAudioRequestValidationError{} + +// Validate checks the field values on CaptchaAudioResponse 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 *CaptchaAudioResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaptchaAudioResponse 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 +// CaptchaAudioResponseMultiError, or nil if none found. +func (m *CaptchaAudioResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CaptchaAudioResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Headers + + // no validation rules for Audio + + if len(errors) > 0 { + return CaptchaAudioResponseMultiError(errors) + } + + return nil +} + +// CaptchaAudioResponseMultiError is an error wrapping multiple validation +// errors returned by CaptchaAudioResponse.ValidateAll() if the designated +// constraints aren't met. +type CaptchaAudioResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaptchaAudioResponseMultiError) 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 CaptchaAudioResponseMultiError) AllErrors() []error { return m } + +// CaptchaAudioResponseValidationError is the validation error returned by +// CaptchaAudioResponse.Validate if the designated constraints aren't met. +type CaptchaAudioResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaptchaAudioResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaptchaAudioResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaptchaAudioResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaptchaAudioResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaptchaAudioResponseValidationError) ErrorName() string { + return "CaptchaAudioResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CaptchaAudioResponseValidationError) 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 %sCaptchaAudioResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaptchaAudioResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaptchaAudioResponseValidationError{} + +// Validate checks the field values on CaptchaRequest 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 *CaptchaRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaptchaRequest 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 CaptchaRequestMultiError, +// or nil if none found. +func (m *CaptchaRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CaptchaRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Type + + // no validation rules for Reload + + // no validation rules for Ts + + if len(errors) > 0 { + return CaptchaRequestMultiError(errors) + } + + return nil +} + +// CaptchaRequestMultiError is an error wrapping multiple validation errors +// returned by CaptchaRequest.ValidateAll() if the designated constraints +// aren't met. +type CaptchaRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaptchaRequestMultiError) 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 CaptchaRequestMultiError) AllErrors() []error { return m } + +// CaptchaRequestValidationError is the validation error returned by +// CaptchaRequest.Validate if the designated constraints aren't met. +type CaptchaRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaptchaRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaptchaRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaptchaRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaptchaRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaptchaRequestValidationError) ErrorName() string { return "CaptchaRequestValidationError" } + +// Error satisfies the builtin error interface +func (e CaptchaRequestValidationError) 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 %sCaptchaRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaptchaRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaptchaRequestValidationError{} + +// Validate checks the field values on CaptchaResponse 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 *CaptchaResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CaptchaResponse 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 +// CaptchaResponseMultiError, or nil if none found. +func (m *CaptchaResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CaptchaResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Type + + // no validation rules for Data + + if len(errors) > 0 { + return CaptchaResponseMultiError(errors) + } + + return nil +} + +// CaptchaResponseMultiError is an error wrapping multiple validation errors +// returned by CaptchaResponse.ValidateAll() if the designated constraints +// aren't met. +type CaptchaResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CaptchaResponseMultiError) 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 CaptchaResponseMultiError) AllErrors() []error { return m } + +// CaptchaResponseValidationError is the validation error returned by +// CaptchaResponse.Validate if the designated constraints aren't met. +type CaptchaResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CaptchaResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CaptchaResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CaptchaResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CaptchaResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CaptchaResponseValidationError) ErrorName() string { return "CaptchaResponseValidationError" } + +// Error satisfies the builtin error interface +func (e CaptchaResponseValidationError) 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 %sCaptchaResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CaptchaResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CaptchaResponseValidationError{} + +// Validate checks the field values on RegisterRequest 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 *RegisterRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RegisterRequest 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 +// RegisterRequestMultiError, or nil if none found. +func (m *RegisterRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *RegisterRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RegisterRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RegisterRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RegisterRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RegisterRequestMultiError(errors) + } + + return nil +} + +// RegisterRequestMultiError is an error wrapping multiple validation errors +// returned by RegisterRequest.ValidateAll() if the designated constraints +// aren't met. +type RegisterRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RegisterRequestMultiError) 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 RegisterRequestMultiError) AllErrors() []error { return m } + +// RegisterRequestValidationError is the validation error returned by +// RegisterRequest.Validate if the designated constraints aren't met. +type RegisterRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RegisterRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RegisterRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RegisterRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RegisterRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RegisterRequestValidationError) ErrorName() string { return "RegisterRequestValidationError" } + +// Error satisfies the builtin error interface +func (e RegisterRequestValidationError) 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 %sRegisterRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RegisterRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RegisterRequestValidationError{} + +// Validate checks the field values on RegisterResponse 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 *RegisterResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RegisterResponse 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 +// RegisterResponseMultiError, or nil if none found. +func (m *RegisterResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *RegisterResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Success + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RegisterResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RegisterResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RegisterResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RegisterResponseMultiError(errors) + } + + return nil +} + +// RegisterResponseMultiError is an error wrapping multiple validation errors +// returned by RegisterResponse.ValidateAll() if the designated constraints +// aren't met. +type RegisterResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RegisterResponseMultiError) 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 RegisterResponseMultiError) AllErrors() []error { return m } + +// RegisterResponseValidationError is the validation error returned by +// RegisterResponse.Validate if the designated constraints aren't met. +type RegisterResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RegisterResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RegisterResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RegisterResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RegisterResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RegisterResponseValidationError) ErrorName() string { return "RegisterResponseValidationError" } + +// Error satisfies the builtin error interface +func (e RegisterResponseValidationError) 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 %sRegisterResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RegisterResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RegisterResponseValidationError{} + +// Validate checks the field values on LogoutRequest 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 *LogoutRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on LogoutRequest 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 LogoutRequestMultiError, or +// nil if none found. +func (m *LogoutRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *LogoutRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, LogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, LogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return LogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return LogoutRequestMultiError(errors) + } + + return nil +} + +// LogoutRequestMultiError is an error wrapping multiple validation errors +// returned by LogoutRequest.ValidateAll() if the designated constraints +// aren't met. +type LogoutRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m LogoutRequestMultiError) 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 LogoutRequestMultiError) AllErrors() []error { return m } + +// LogoutRequestValidationError is the validation error returned by +// LogoutRequest.Validate if the designated constraints aren't met. +type LogoutRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e LogoutRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e LogoutRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e LogoutRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e LogoutRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e LogoutRequestValidationError) ErrorName() string { return "LogoutRequestValidationError" } + +// Error satisfies the builtin error interface +func (e LogoutRequestValidationError) 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 %sLogoutRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = LogoutRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = LogoutRequestValidationError{} + +// Validate checks the field values on LogoutResponse 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 *LogoutResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on LogoutResponse 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 LogoutResponseMultiError, +// or nil if none found. +func (m *LogoutResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *LogoutResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Success + + if len(errors) > 0 { + return LogoutResponseMultiError(errors) + } + + return nil +} + +// LogoutResponseMultiError is an error wrapping multiple validation errors +// returned by LogoutResponse.ValidateAll() if the designated constraints +// aren't met. +type LogoutResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m LogoutResponseMultiError) 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 LogoutResponseMultiError) AllErrors() []error { return m } + +// LogoutResponseValidationError is the validation error returned by +// LogoutResponse.Validate if the designated constraints aren't met. +type LogoutResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e LogoutResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e LogoutResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e LogoutResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e LogoutResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e LogoutResponseValidationError) ErrorName() string { return "LogoutResponseValidationError" } + +// Error satisfies the builtin error interface +func (e LogoutResponseValidationError) 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 %sLogoutResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = LogoutResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = LogoutResponseValidationError{} + +// Validate checks the field values on TokenRefreshRequest_Data 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 *TokenRefreshRequest_Data) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on TokenRefreshRequest_Data 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 +// TokenRefreshRequest_DataMultiError, or nil if none found. +func (m *TokenRefreshRequest_Data) ValidateAll() error { + return m.validate(true) +} + +func (m *TokenRefreshRequest_Data) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetRefreshToken()) < 1 { + err := TokenRefreshRequest_DataValidationError{ + field: "RefreshToken", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return TokenRefreshRequest_DataMultiError(errors) + } + + return nil +} + +// TokenRefreshRequest_DataMultiError is an error wrapping multiple validation +// errors returned by TokenRefreshRequest_Data.ValidateAll() if the designated +// constraints aren't met. +type TokenRefreshRequest_DataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m TokenRefreshRequest_DataMultiError) 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 TokenRefreshRequest_DataMultiError) AllErrors() []error { return m } + +// TokenRefreshRequest_DataValidationError is the validation error returned by +// TokenRefreshRequest_Data.Validate if the designated constraints aren't met. +type TokenRefreshRequest_DataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e TokenRefreshRequest_DataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e TokenRefreshRequest_DataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e TokenRefreshRequest_DataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e TokenRefreshRequest_DataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e TokenRefreshRequest_DataValidationError) ErrorName() string { + return "TokenRefreshRequest_DataValidationError" +} + +// Error satisfies the builtin error interface +func (e TokenRefreshRequest_DataValidationError) 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 %sTokenRefreshRequest_Data.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = TokenRefreshRequest_DataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = TokenRefreshRequest_DataValidationError{} + +// Validate checks the field values on LoginRequest_Data 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 *LoginRequest_Data) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on LoginRequest_Data 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 +// LoginRequest_DataMultiError, or nil if none found. +func (m *LoginRequest_Data) ValidateAll() error { + return m.validate(true) +} + +func (m *LoginRequest_Data) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetUsername()) < 1 { + err := LoginRequest_DataValidationError{ + field: "Username", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetPassword()) < 1 { + err := LoginRequest_DataValidationError{ + field: "Password", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetCaptchaId()) < 1 { + err := LoginRequest_DataValidationError{ + field: "CaptchaId", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetCaptchaCode()) < 1 { + err := LoginRequest_DataValidationError{ + field: "CaptchaCode", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return LoginRequest_DataMultiError(errors) + } + + return nil +} + +// LoginRequest_DataMultiError is an error wrapping multiple validation errors +// returned by LoginRequest_Data.ValidateAll() if the designated constraints +// aren't met. +type LoginRequest_DataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m LoginRequest_DataMultiError) 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 LoginRequest_DataMultiError) AllErrors() []error { return m } + +// LoginRequest_DataValidationError is the validation error returned by +// LoginRequest_Data.Validate if the designated constraints aren't met. +type LoginRequest_DataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e LoginRequest_DataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e LoginRequest_DataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e LoginRequest_DataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e LoginRequest_DataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e LoginRequest_DataValidationError) ErrorName() string { + return "LoginRequest_DataValidationError" +} + +// Error satisfies the builtin error interface +func (e LoginRequest_DataValidationError) 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 %sLoginRequest_Data.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = LoginRequest_DataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = LoginRequest_DataValidationError{} + +// Validate checks the field values on RegisterRequest_Data 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 *RegisterRequest_Data) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RegisterRequest_Data 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 +// RegisterRequest_DataMultiError, or nil if none found. +func (m *RegisterRequest_Data) ValidateAll() error { + return m.validate(true) +} + +func (m *RegisterRequest_Data) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if utf8.RuneCountInString(m.GetUsername()) < 1 { + err := RegisterRequest_DataValidationError{ + field: "Username", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetPassword()) < 1 { + err := RegisterRequest_DataValidationError{ + field: "Password", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetCaptchaId()) < 1 { + err := RegisterRequest_DataValidationError{ + field: "CaptchaId", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if utf8.RuneCountInString(m.GetCaptchaCode()) < 1 { + err := RegisterRequest_DataValidationError{ + field: "CaptchaCode", + reason: "value length must be at least 1 runes", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return RegisterRequest_DataMultiError(errors) + } + + return nil +} + +// RegisterRequest_DataMultiError is an error wrapping multiple validation +// errors returned by RegisterRequest_Data.ValidateAll() if the designated +// constraints aren't met. +type RegisterRequest_DataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RegisterRequest_DataMultiError) 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 RegisterRequest_DataMultiError) AllErrors() []error { return m } + +// RegisterRequest_DataValidationError is the validation error returned by +// RegisterRequest_Data.Validate if the designated constraints aren't met. +type RegisterRequest_DataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RegisterRequest_DataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RegisterRequest_DataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RegisterRequest_DataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RegisterRequest_DataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RegisterRequest_DataValidationError) ErrorName() string { + return "RegisterRequest_DataValidationError" +} + +// Error satisfies the builtin error interface +func (e RegisterRequest_DataValidationError) 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 %sRegisterRequest_Data.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RegisterRequest_DataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RegisterRequest_DataValidationError{} + +// Validate checks the field values on RegisterResponse_Data 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 *RegisterResponse_Data) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RegisterResponse_Data 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 +// RegisterResponse_DataMultiError, or nil if none found. +func (m *RegisterResponse_Data) ValidateAll() error { + return m.validate(true) +} + +func (m *RegisterResponse_Data) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Redirect + + if len(errors) > 0 { + return RegisterResponse_DataMultiError(errors) + } + + return nil +} + +// RegisterResponse_DataMultiError is an error wrapping multiple validation +// errors returned by RegisterResponse_Data.ValidateAll() if the designated +// constraints aren't met. +type RegisterResponse_DataMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RegisterResponse_DataMultiError) 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 RegisterResponse_DataMultiError) AllErrors() []error { return m } + +// RegisterResponse_DataValidationError is the validation error returned by +// RegisterResponse_Data.Validate if the designated constraints aren't met. +type RegisterResponse_DataValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RegisterResponse_DataValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RegisterResponse_DataValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RegisterResponse_DataValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RegisterResponse_DataValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RegisterResponse_DataValidationError) ErrorName() string { + return "RegisterResponse_DataValidationError" +} + +// Error satisfies the builtin error interface +func (e RegisterResponse_DataValidationError) 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 %sRegisterResponse_Data.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RegisterResponse_DataValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RegisterResponse_DataValidationError{} diff --git a/api/v1/services/auth/login_bridge.pb.go b/api/v1/services/auth/login_bridge.pb.go new file mode 100644 index 00000000..de674202 --- /dev/null +++ b/api/v1/services/auth/login_bridge.pb.go @@ -0,0 +1,554 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: auth/login.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const LoginServiceCaptchaBridgeOperation = "/api.v1.services.auth.LoginService/Captcha" +const LoginServiceCaptchaAudioBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaAudio" +const LoginServiceCaptchaIdBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaId" +const LoginServiceCaptchaImageBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaImage" +const LoginServiceLoginBridgeOperation = "/api.v1.services.auth.LoginService/Login" +const LoginServiceLogoutBridgeOperation = "/api.v1.services.auth.LoginService/Logout" +const LoginServiceRegisterBridgeOperation = "/api.v1.services.auth.LoginService/Register" +const LoginServiceTokenRefreshBridgeOperation = "/api.v1.services.auth.LoginService/TokenRefresh" + +type LoginServiceBridgeServer interface { + Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) + CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) + CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) + CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) + Login(context.Context, *LoginRequest) (*LoginResponse, error) + Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) + Register(context.Context, *RegisterRequest) (*RegisterResponse, error) + TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) +} + +type LoginServiceHooker interface { + LoginServiceCaptchaHooker + LoginServiceCaptchaAudioHooker + LoginServiceCaptchaIdHooker + LoginServiceCaptchaImageHooker + LoginServiceLoginHooker + LoginServiceLogoutHooker + LoginServiceRegisterHooker + LoginServiceTokenRefreshHooker +} + +type LoginServiceHookedBridger interface { + LoginServiceHooker + LoginServiceBridgeServer +} +type LoginServiceCaptchaHooker interface { + PrepareCaptcha(http.Context, *CaptchaRequest) (context.Context, error) + CompleteCaptcha(http.Context, *CaptchaRequest, *CaptchaResponse) error +} +type LoginServiceCaptchaAudioHooker interface { + PrepareCaptchaAudio(http.Context, *CaptchaAudioRequest) (context.Context, error) + CompleteCaptchaAudio(http.Context, *CaptchaAudioRequest, *CaptchaAudioResponse) error +} +type LoginServiceCaptchaIdHooker interface { + PrepareCaptchaId(http.Context, *CaptchaIdRequest) (context.Context, error) + CompleteCaptchaId(http.Context, *CaptchaIdRequest, *CaptchaIdResponse) error +} +type LoginServiceCaptchaImageHooker interface { + PrepareCaptchaImage(http.Context, *CaptchaImageRequest) (context.Context, error) + CompleteCaptchaImage(http.Context, *CaptchaImageRequest, *CaptchaImageResponse) error +} +type LoginServiceLoginHooker interface { + PrepareLogin(http.Context, *LoginRequest) (context.Context, error) + CompleteLogin(http.Context, *LoginRequest, *LoginResponse) error +} +type LoginServiceLogoutHooker interface { + PrepareLogout(http.Context, *LogoutRequest) (context.Context, error) + CompleteLogout(http.Context, *LogoutRequest, *LogoutResponse) error +} +type LoginServiceRegisterHooker interface { + PrepareRegister(http.Context, *RegisterRequest) (context.Context, error) + CompleteRegister(http.Context, *RegisterRequest, *RegisterResponse) error +} +type LoginServiceTokenRefreshHooker interface { + PrepareTokenRefresh(http.Context, *TokenRefreshRequest) (context.Context, error) + CompleteTokenRefresh(http.Context, *TokenRefreshRequest, *TokenRefreshResponse) error +} + +func RegisterLoginServiceBridgeServer(s *http.Server, srv LoginServiceHookedBridger) { + r := s.Route("/") + r.GET("/captcha", _LoginService_Captcha0_Bridge_Handler(srv)) + r.GET("/captcha/id", _LoginService_CaptchaId0_Bridge_Handler(srv)) + r.GET("/captcha/image", _LoginService_CaptchaImage0_Bridge_Handler(srv)) + r.GET("/captcha/audio", _LoginService_CaptchaAudio0_Bridge_Handler(srv)) + r.POST("/login", _LoginService_Login0_Bridge_Handler(srv)) + r.POST("/logout", _LoginService_Logout0_Bridge_Handler(srv)) + r.POST("/register", _LoginService_Register0_Bridge_Handler(srv)) + r.POST("/token/refresh", _LoginService_TokenRefresh0_Bridge_Handler(srv)) +} + +func _LoginService_Captcha0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptcha) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Captcha(ctx, req.(*CaptchaRequest)) + }) + + newctx, err := srv.PrepareCaptcha(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCaptcha(ctx, &in, out.(*CaptchaResponse)) + } +} + +func _LoginService_CaptchaId0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaIdRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptchaId) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CaptchaId(ctx, req.(*CaptchaIdRequest)) + }) + + newctx, err := srv.PrepareCaptchaId(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCaptchaId(ctx, &in, out.(*CaptchaIdResponse)) + } +} + +func _LoginService_CaptchaImage0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaImageRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptchaImage) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CaptchaImage(ctx, req.(*CaptchaImageRequest)) + }) + + newctx, err := srv.PrepareCaptchaImage(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCaptchaImage(ctx, &in, out.(*CaptchaImageResponse)) + } +} + +func _LoginService_CaptchaAudio0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaAudioRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptchaAudio) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) + }) + + newctx, err := srv.PrepareCaptchaAudio(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCaptchaAudio(ctx, &in, out.(*CaptchaAudioResponse)) + } +} + +func _LoginService_Login0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in LoginRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceLogin) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Login(ctx, req.(*LoginRequest)) + }) + + newctx, err := srv.PrepareLogin(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteLogin(ctx, &in, out.(*LoginResponse)) + } +} + +func _LoginService_Logout0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in LogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Logout(ctx, req.(*LogoutRequest)) + }) + + newctx, err := srv.PrepareLogout(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteLogout(ctx, &in, out.(*LogoutResponse)) + } +} + +func _LoginService_Register0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RegisterRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceRegister) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Register(ctx, req.(*RegisterRequest)) + }) + + newctx, err := srv.PrepareRegister(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteRegister(ctx, &in, out.(*RegisterResponse)) + } +} + +func _LoginService_TokenRefresh0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in TokenRefreshRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceTokenRefresh) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.TokenRefresh(ctx, req.(*TokenRefreshRequest)) + }) + + newctx, err := srv.PrepareTokenRefresh(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteTokenRefresh(ctx, &in, out.(*TokenRefreshResponse)) + } +} + +// UnimplementedLoginServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedLoginServiceHooked struct{} + +func (UnimplementedLoginServiceHooked) PrepareCaptcha(ctx http.Context, in *CaptchaRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceHooked) CompleteCaptcha(ctx http.Context, in *CaptchaRequest, out *CaptchaResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceHooked) PrepareCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceHooked) CompleteCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest, out *CaptchaAudioResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceHooked) PrepareCaptchaId(ctx http.Context, in *CaptchaIdRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceHooked) CompleteCaptchaId(ctx http.Context, in *CaptchaIdRequest, out *CaptchaIdResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceHooked) PrepareCaptchaImage(ctx http.Context, in *CaptchaImageRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceHooked) CompleteCaptchaImage(ctx http.Context, in *CaptchaImageRequest, out *CaptchaImageResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceHooked) PrepareLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceHooked) CompleteLogin(ctx http.Context, in *LoginRequest, out *LoginResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceHooked) PrepareLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceHooked) CompleteLogout(ctx http.Context, in *LogoutRequest, out *LogoutResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceHooked) PrepareRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceHooked) CompleteRegister(ctx http.Context, in *RegisterRequest, out *RegisterResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedLoginServiceHooked) PrepareTokenRefresh(ctx http.Context, in *TokenRefreshRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedLoginServiceHooked) CompleteTokenRefresh(ctx http.Context, in *TokenRefreshRequest, out *TokenRefreshResponse) error { + return ctx.Result(200, out) +} + +func WithLoginServiceHook(h LoginServiceHooker) func(LoginServiceBridgeServer) LoginServiceHookedBridger { + return func(srv LoginServiceBridgeServer) LoginServiceHookedBridger { + return LoginServiceHookedBridge{LoginServiceBridgeServer: srv, LoginServiceHooker: h} + } +} + +// LoginServiceHookedBridge is a bridge between the HTTP and gRPC implementations of LoginService. +// It implements the HTTP and gRPC implementations of LoginService. +// It forwards requests and responses between the two implementations. +type LoginServiceHookedBridge struct { + LoginServiceBridgeServer + LoginServiceHooker +} + +type LoginServiceHTTPBridgeImpl struct { + client LoginServiceHTTPClient +} + +func NewLoginServiceHTTPBridge(client *http.Client) LoginServiceHTTPServer { + return &LoginServiceHTTPBridgeImpl{client: NewLoginServiceHTTPClient(client)} +} + +func (c *LoginServiceHTTPBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { + return c.client.Captcha(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { + return c.client.CaptchaAudio(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { + return c.client.CaptchaId(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { + return c.client.CaptchaImage(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { + return c.client.Logout(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) +} + +func (c *LoginServiceHTTPBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { + return c.client.TokenRefresh(ctx, in) +} + +type LoginServiceBridgeImpl struct { + client LoginServiceClient +} + +func NewLoginServiceBridge(client grpc.ClientConnInterface) LoginServiceServer { + return &LoginServiceBridgeImpl{client: NewLoginServiceClient(client)} +} + +func (c *LoginServiceBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { + return c.client.Captcha(ctx, in) +} + +func (c *LoginServiceBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { + return c.client.CaptchaAudio(ctx, in) +} + +func (c *LoginServiceBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { + return c.client.CaptchaId(ctx, in) +} + +func (c *LoginServiceBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { + return c.client.CaptchaImage(ctx, in) +} + +func (c *LoginServiceBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *LoginServiceBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { + return c.client.Logout(ctx, in) +} + +func (c *LoginServiceBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) +} + +func (c *LoginServiceBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { + return c.client.TokenRefresh(ctx, in) +} + +func (c *LoginServiceBridgeImpl) mustEmbedUnimplementedLoginServiceServer() {} + +type LoginServiceGRPC2HTTPBridgeImpl struct { + client LoginServiceClient +} + +func NewLoginServiceGRPC2HTTP(client grpc.ClientConnInterface) LoginServiceHTTPServer { + return &LoginServiceGRPC2HTTPBridgeImpl{client: NewLoginServiceClient(client)} +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { + return c.client.Captcha(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { + return c.client.CaptchaAudio(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { + return c.client.CaptchaId(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { + return c.client.CaptchaImage(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { + return c.client.Logout(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) +} + +func (c *LoginServiceGRPC2HTTPBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { + return c.client.TokenRefresh(ctx, in) +} + +type LoginServiceHTTP2GRPCBridgeImpl struct { + client LoginServiceHTTPClient +} + +func NewLoginServiceHTTP2GRPC(client *http.Client) LoginServiceServer { + return &LoginServiceHTTP2GRPCBridgeImpl{client: NewLoginServiceHTTPClient(client)} +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { + return c.client.Captcha(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { + return c.client.CaptchaAudio(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { + return c.client.CaptchaId(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { + return c.client.CaptchaImage(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { + return c.client.Logout(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { + return c.client.TokenRefresh(ctx, in) +} + +func (c *LoginServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedLoginServiceServer() {} diff --git a/api/v1/services/auth/login_grpc.pb.go b/api/v1/services/auth/login_grpc.pb.go new file mode 100644 index 00000000..dbb951a2 --- /dev/null +++ b/api/v1/services/auth/login_grpc.pb.go @@ -0,0 +1,391 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: auth/login.proto + +package auth + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + LoginService_Captcha_FullMethodName = "/api.v1.services.auth.LoginService/Captcha" + LoginService_CaptchaId_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaId" + LoginService_CaptchaImage_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaImage" + LoginService_CaptchaAudio_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaAudio" + LoginService_Login_FullMethodName = "/api.v1.services.auth.LoginService/Login" + LoginService_Logout_FullMethodName = "/api.v1.services.auth.LoginService/Logout" + LoginService_Register_FullMethodName = "/api.v1.services.auth.LoginService/Register" + LoginService_TokenRefresh_FullMethodName = "/api.v1.services.auth.LoginService/TokenRefresh" +) + +// LoginServiceClient is the client API for LoginService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The login service definition. +type LoginServiceClient interface { + Captcha(ctx context.Context, in *CaptchaRequest, opts ...grpc.CallOption) (*CaptchaResponse, error) + CaptchaId(ctx context.Context, in *CaptchaIdRequest, opts ...grpc.CallOption) (*CaptchaIdResponse, error) + CaptchaImage(ctx context.Context, in *CaptchaImageRequest, opts ...grpc.CallOption) (*CaptchaImageResponse, error) + CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest, opts ...grpc.CallOption) (*CaptchaAudioResponse, error) + Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) + Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) + Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) + TokenRefresh(ctx context.Context, in *TokenRefreshRequest, opts ...grpc.CallOption) (*TokenRefreshResponse, error) +} + +type loginServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewLoginServiceClient(cc grpc.ClientConnInterface) LoginServiceClient { + return &loginServiceClient{cc} +} + +func (c *loginServiceClient) Captcha(ctx context.Context, in *CaptchaRequest, opts ...grpc.CallOption) (*CaptchaResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CaptchaResponse) + err := c.cc.Invoke(ctx, LoginService_Captcha_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *loginServiceClient) CaptchaId(ctx context.Context, in *CaptchaIdRequest, opts ...grpc.CallOption) (*CaptchaIdResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CaptchaIdResponse) + err := c.cc.Invoke(ctx, LoginService_CaptchaId_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *loginServiceClient) CaptchaImage(ctx context.Context, in *CaptchaImageRequest, opts ...grpc.CallOption) (*CaptchaImageResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CaptchaImageResponse) + err := c.cc.Invoke(ctx, LoginService_CaptchaImage_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *loginServiceClient) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest, opts ...grpc.CallOption) (*CaptchaAudioResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CaptchaAudioResponse) + err := c.cc.Invoke(ctx, LoginService_CaptchaAudio_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *loginServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(LoginResponse) + err := c.cc.Invoke(ctx, LoginService_Login_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *loginServiceClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(LogoutResponse) + err := c.cc.Invoke(ctx, LoginService_Logout_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *loginServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RegisterResponse) + err := c.cc.Invoke(ctx, LoginService_Register_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *loginServiceClient) TokenRefresh(ctx context.Context, in *TokenRefreshRequest, opts ...grpc.CallOption) (*TokenRefreshResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(TokenRefreshResponse) + err := c.cc.Invoke(ctx, LoginService_TokenRefresh_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// LoginServiceServer is the server API for LoginService service. +// All implementations must embed UnimplementedLoginServiceServer +// for forward compatibility. +// +// The login service definition. +type LoginServiceServer interface { + Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) + CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) + CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) + CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) + Login(context.Context, *LoginRequest) (*LoginResponse, error) + Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) + Register(context.Context, *RegisterRequest) (*RegisterResponse, error) + TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) + mustEmbedUnimplementedLoginServiceServer() +} + +// UnimplementedLoginServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedLoginServiceServer struct{} + +func (UnimplementedLoginServiceServer) Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Captcha not implemented") +} +func (UnimplementedLoginServiceServer) CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CaptchaId not implemented") +} +func (UnimplementedLoginServiceServer) CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CaptchaImage not implemented") +} +func (UnimplementedLoginServiceServer) CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CaptchaAudio not implemented") +} +func (UnimplementedLoginServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") +} +func (UnimplementedLoginServiceServer) Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented") +} +func (UnimplementedLoginServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") +} +func (UnimplementedLoginServiceServer) TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TokenRefresh not implemented") +} +func (UnimplementedLoginServiceServer) mustEmbedUnimplementedLoginServiceServer() {} +func (UnimplementedLoginServiceServer) testEmbeddedByValue() {} + +// UnsafeLoginServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to LoginServiceServer will +// result in compilation errors. +type UnsafeLoginServiceServer interface { + mustEmbedUnimplementedLoginServiceServer() +} + +func RegisterLoginServiceServer(s grpc.ServiceRegistrar, srv LoginServiceServer) { + // If the following call pancis, it indicates UnimplementedLoginServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&LoginService_ServiceDesc, srv) +} + +func _LoginService_Captcha_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CaptchaRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LoginServiceServer).Captcha(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: LoginService_Captcha_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LoginServiceServer).Captcha(ctx, req.(*CaptchaRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _LoginService_CaptchaId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CaptchaIdRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LoginServiceServer).CaptchaId(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: LoginService_CaptchaId_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LoginServiceServer).CaptchaId(ctx, req.(*CaptchaIdRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _LoginService_CaptchaImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CaptchaImageRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LoginServiceServer).CaptchaImage(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: LoginService_CaptchaImage_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LoginServiceServer).CaptchaImage(ctx, req.(*CaptchaImageRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _LoginService_CaptchaAudio_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CaptchaAudioRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LoginServiceServer).CaptchaAudio(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: LoginService_CaptchaAudio_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LoginServiceServer).CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _LoginService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LoginRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LoginServiceServer).Login(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: LoginService_Login_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LoginServiceServer).Login(ctx, req.(*LoginRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _LoginService_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LogoutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LoginServiceServer).Logout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: LoginService_Logout_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LoginServiceServer).Logout(ctx, req.(*LogoutRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _LoginService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RegisterRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LoginServiceServer).Register(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: LoginService_Register_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LoginServiceServer).Register(ctx, req.(*RegisterRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _LoginService_TokenRefresh_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TokenRefreshRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(LoginServiceServer).TokenRefresh(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: LoginService_TokenRefresh_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(LoginServiceServer).TokenRefresh(ctx, req.(*TokenRefreshRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// LoginService_ServiceDesc is the grpc.ServiceDesc for LoginService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var LoginService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.auth.LoginService", + HandlerType: (*LoginServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Captcha", + Handler: _LoginService_Captcha_Handler, + }, + { + MethodName: "CaptchaId", + Handler: _LoginService_CaptchaId_Handler, + }, + { + MethodName: "CaptchaImage", + Handler: _LoginService_CaptchaImage_Handler, + }, + { + MethodName: "CaptchaAudio", + Handler: _LoginService_CaptchaAudio_Handler, + }, + { + MethodName: "Login", + Handler: _LoginService_Login_Handler, + }, + { + MethodName: "Logout", + Handler: _LoginService_Logout_Handler, + }, + { + MethodName: "Register", + Handler: _LoginService_Register_Handler, + }, + { + MethodName: "TokenRefresh", + Handler: _LoginService_TokenRefresh_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "auth/login.proto", +} diff --git a/api/v1/services/auth/login_http.pb.go b/api/v1/services/auth/login_http.pb.go new file mode 100644 index 00000000..cd24ca67 --- /dev/null +++ b/api/v1/services/auth/login_http.pb.go @@ -0,0 +1,339 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: auth/login.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationLoginServiceCaptcha = "/api.v1.services.auth.LoginService/Captcha" +const OperationLoginServiceCaptchaAudio = "/api.v1.services.auth.LoginService/CaptchaAudio" +const OperationLoginServiceCaptchaId = "/api.v1.services.auth.LoginService/CaptchaId" +const OperationLoginServiceCaptchaImage = "/api.v1.services.auth.LoginService/CaptchaImage" +const OperationLoginServiceLogin = "/api.v1.services.auth.LoginService/Login" +const OperationLoginServiceLogout = "/api.v1.services.auth.LoginService/Logout" +const OperationLoginServiceRegister = "/api.v1.services.auth.LoginService/Register" +const OperationLoginServiceTokenRefresh = "/api.v1.services.auth.LoginService/TokenRefresh" + +type LoginServiceHTTPServer interface { + Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) + CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) + CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) + CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) + Login(context.Context, *LoginRequest) (*LoginResponse, error) + Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) + Register(context.Context, *RegisterRequest) (*RegisterResponse, error) + TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) +} + +func RegisterLoginServiceHTTPServer(s *http.Server, srv LoginServiceHTTPServer) { + r := s.Route("/") + r.GET("/captcha", _LoginService_Captcha0_HTTP_Handler(srv)) + r.GET("/captcha/id", _LoginService_CaptchaId0_HTTP_Handler(srv)) + r.GET("/captcha/image", _LoginService_CaptchaImage0_HTTP_Handler(srv)) + r.GET("/captcha/audio", _LoginService_CaptchaAudio0_HTTP_Handler(srv)) + r.POST("/login", _LoginService_Login0_HTTP_Handler(srv)) + r.POST("/logout", _LoginService_Logout0_HTTP_Handler(srv)) + r.POST("/register", _LoginService_Register0_HTTP_Handler(srv)) + r.POST("/token/refresh", _LoginService_TokenRefresh0_HTTP_Handler(srv)) +} + +func _LoginService_Captcha0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptcha) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Captcha(ctx, req.(*CaptchaRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CaptchaResponse) + return ctx.Result(200, reply) + } +} + +func _LoginService_CaptchaId0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaIdRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptchaId) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CaptchaId(ctx, req.(*CaptchaIdRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CaptchaIdResponse) + return ctx.Result(200, reply) + } +} + +func _LoginService_CaptchaImage0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaImageRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptchaImage) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CaptchaImage(ctx, req.(*CaptchaImageRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CaptchaImageResponse) + return ctx.Result(200, reply) + } +} + +func _LoginService_CaptchaAudio0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CaptchaAudioRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceCaptchaAudio) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CaptchaAudioResponse) + return ctx.Result(200, reply) + } +} + +func _LoginService_Login0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in LoginRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceLogin) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Login(ctx, req.(*LoginRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*LoginResponse) + return ctx.Result(200, reply) + } +} + +func _LoginService_Logout0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in LogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Logout(ctx, req.(*LogoutRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*LogoutResponse) + return ctx.Result(200, reply) + } +} + +func _LoginService_Register0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RegisterRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceRegister) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Register(ctx, req.(*RegisterRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*RegisterResponse) + return ctx.Result(200, reply) + } +} + +func _LoginService_TokenRefresh0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in TokenRefreshRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationLoginServiceTokenRefresh) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.TokenRefresh(ctx, req.(*TokenRefreshRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*TokenRefreshResponse) + return ctx.Result(200, reply) + } +} + +type LoginServiceHTTPClient interface { + Captcha(ctx context.Context, req *CaptchaRequest, opts ...http.CallOption) (rsp *CaptchaResponse, err error) + CaptchaAudio(ctx context.Context, req *CaptchaAudioRequest, opts ...http.CallOption) (rsp *CaptchaAudioResponse, err error) + CaptchaId(ctx context.Context, req *CaptchaIdRequest, opts ...http.CallOption) (rsp *CaptchaIdResponse, err error) + CaptchaImage(ctx context.Context, req *CaptchaImageRequest, opts ...http.CallOption) (rsp *CaptchaImageResponse, err error) + Login(ctx context.Context, req *LoginRequest, opts ...http.CallOption) (rsp *LoginResponse, err error) + Logout(ctx context.Context, req *LogoutRequest, opts ...http.CallOption) (rsp *LogoutResponse, err error) + Register(ctx context.Context, req *RegisterRequest, opts ...http.CallOption) (rsp *RegisterResponse, err error) + TokenRefresh(ctx context.Context, req *TokenRefreshRequest, opts ...http.CallOption) (rsp *TokenRefreshResponse, err error) +} + +type LoginServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewLoginServiceHTTPClient(client *http.Client) LoginServiceHTTPClient { + return &LoginServiceHTTPClientImpl{client} +} + +func (c *LoginServiceHTTPClientImpl) Captcha(ctx context.Context, in *CaptchaRequest, opts ...http.CallOption) (*CaptchaResponse, error) { + var out CaptchaResponse + pattern := "/captcha" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationLoginServiceCaptcha)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *LoginServiceHTTPClientImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest, opts ...http.CallOption) (*CaptchaAudioResponse, error) { + var out CaptchaAudioResponse + pattern := "/captcha/audio" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationLoginServiceCaptchaAudio)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *LoginServiceHTTPClientImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest, opts ...http.CallOption) (*CaptchaIdResponse, error) { + var out CaptchaIdResponse + pattern := "/captcha/id" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationLoginServiceCaptchaId)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *LoginServiceHTTPClientImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest, opts ...http.CallOption) (*CaptchaImageResponse, error) { + var out CaptchaImageResponse + pattern := "/captcha/image" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationLoginServiceCaptchaImage)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *LoginServiceHTTPClientImpl) Login(ctx context.Context, in *LoginRequest, opts ...http.CallOption) (*LoginResponse, error) { + var out LoginResponse + pattern := "/login" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationLoginServiceLogin)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *LoginServiceHTTPClientImpl) Logout(ctx context.Context, in *LogoutRequest, opts ...http.CallOption) (*LogoutResponse, error) { + var out LogoutResponse + pattern := "/logout" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationLoginServiceLogout)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *LoginServiceHTTPClientImpl) Register(ctx context.Context, in *RegisterRequest, opts ...http.CallOption) (*RegisterResponse, error) { + var out RegisterResponse + pattern := "/register" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationLoginServiceRegister)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *LoginServiceHTTPClientImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest, opts ...http.CallOption) (*TokenRefreshResponse, error) { + var out TokenRefreshResponse + pattern := "/token/refresh" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationLoginServiceTokenRefresh)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/auth/personal.pb.go b/api/v1/services/auth/personal.pb.go new file mode 100644 index 00000000..5d73ceaf --- /dev/null +++ b/api/v1/services/auth/personal.pb.go @@ -0,0 +1,1074 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: auth/personal.proto + +package auth + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UpdatePersonalSettingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalSettingRequest) Reset() { + *x = UpdatePersonalSettingRequest{} + mi := &file_auth_personal_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalSettingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalSettingRequest) ProtoMessage() {} + +func (x *UpdatePersonalSettingRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[0] + 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 UpdatePersonalSettingRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalSettingRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{0} +} + +func (x *UpdatePersonalSettingRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalSettingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalSettingResponse) Reset() { + *x = UpdatePersonalSettingResponse{} + mi := &file_auth_personal_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalSettingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalSettingResponse) ProtoMessage() {} + +func (x *UpdatePersonalSettingResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[1] + 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 UpdatePersonalSettingResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalSettingResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{1} +} + +type UpdatePersonalRoleRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalRoleRequest) Reset() { + *x = UpdatePersonalRoleRequest{} + mi := &file_auth_personal_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalRoleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalRoleRequest) ProtoMessage() {} + +func (x *UpdatePersonalRoleRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[2] + 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 UpdatePersonalRoleRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalRoleRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{2} +} + +func (x *UpdatePersonalRoleRequest) GetRole() *types.Role { + if x != nil { + return x.Role + } + return nil +} + +type UpdatePersonalRoleResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalRoleResponse) Reset() { + *x = UpdatePersonalRoleResponse{} + mi := &file_auth_personal_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalRoleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalRoleResponse) ProtoMessage() {} + +func (x *UpdatePersonalRoleResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[3] + 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 UpdatePersonalRoleResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalRoleResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{3} +} + +type ListPersonalResourcesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalResourcesRequest) Reset() { + *x = ListPersonalResourcesRequest{} + mi := &file_auth_personal_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalResourcesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalResourcesRequest) ProtoMessage() {} + +func (x *ListPersonalResourcesRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[4] + 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 ListPersonalResourcesRequest.ProtoReflect.Descriptor instead. +func (*ListPersonalResourcesRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{4} +} + +func (x *ListPersonalResourcesRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListPersonalResourcesRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListPersonalResourcesRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +type ListPersonalResourcesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + TotalSize int64 `protobuf:"varint,1,opt,name=total_size,json=total,proto3" json:"total_size,omitempty"` + // list of resources + Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalResourcesResponse) Reset() { + *x = ListPersonalResourcesResponse{} + mi := &file_auth_personal_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalResourcesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalResourcesResponse) ProtoMessage() {} + +func (x *ListPersonalResourcesResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[5] + 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 ListPersonalResourcesResponse.ProtoReflect.Descriptor instead. +func (*ListPersonalResourcesResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{5} +} + +func (x *ListPersonalResourcesResponse) GetTotalSize() int64 { + if x != nil { + return x.TotalSize + } + return 0 +} + +func (x *ListPersonalResourcesResponse) GetResources() []*types.Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *ListPersonalResourcesResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +type UpdatePersonalPasswordRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalPasswordRequest) Reset() { + *x = UpdatePersonalPasswordRequest{} + mi := &file_auth_personal_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalPasswordRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalPasswordRequest) ProtoMessage() {} + +func (x *UpdatePersonalPasswordRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_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 UpdatePersonalPasswordRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalPasswordRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdatePersonalPasswordRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalPasswordResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalPasswordResponse) Reset() { + *x = UpdatePersonalPasswordResponse{} + mi := &file_auth_personal_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalPasswordResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalPasswordResponse) ProtoMessage() {} + +func (x *UpdatePersonalPasswordResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdatePersonalPasswordResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalPasswordResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{7} +} + +type PersonalPasswordRestRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalPasswordRestRequest) Reset() { + *x = PersonalPasswordRestRequest{} + mi := &file_auth_personal_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalPasswordRestRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalPasswordRestRequest) ProtoMessage() {} + +func (x *PersonalPasswordRestRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[8] + 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 PersonalPasswordRestRequest.ProtoReflect.Descriptor instead. +func (*PersonalPasswordRestRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{8} +} + +func (x *PersonalPasswordRestRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type PersonalPasswordRestResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalPasswordRestResponse) Reset() { + *x = PersonalPasswordRestResponse{} + mi := &file_auth_personal_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalPasswordRestResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalPasswordRestResponse) ProtoMessage() {} + +func (x *PersonalPasswordRestResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[9] + 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 PersonalPasswordRestResponse.ProtoReflect.Descriptor instead. +func (*PersonalPasswordRestResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{9} +} + +type UpdatePersonalProfileRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalProfileRequest) Reset() { + *x = UpdatePersonalProfileRequest{} + mi := &file_auth_personal_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalProfileRequest) ProtoMessage() {} + +func (x *UpdatePersonalProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[10] + 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 UpdatePersonalProfileRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalProfileRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{10} +} + +func (x *UpdatePersonalProfileRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalProfileResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalProfileResponse) Reset() { + *x = UpdatePersonalProfileResponse{} + mi := &file_auth_personal_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalProfileResponse) ProtoMessage() {} + +func (x *UpdatePersonalProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[11] + 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 UpdatePersonalProfileResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalProfileResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{11} +} + +type PersonalLogoutRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalLogoutRequest) Reset() { + *x = PersonalLogoutRequest{} + mi := &file_auth_personal_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalLogoutRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalLogoutRequest) ProtoMessage() {} + +func (x *PersonalLogoutRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[12] + 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 PersonalLogoutRequest.ProtoReflect.Descriptor instead. +func (*PersonalLogoutRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{12} +} + +func (x *PersonalLogoutRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type PersonalLogoutResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalLogoutResponse) Reset() { + *x = PersonalLogoutResponse{} + mi := &file_auth_personal_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalLogoutResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalLogoutResponse) ProtoMessage() {} + +func (x *PersonalLogoutResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[13] + 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 PersonalLogoutResponse.ProtoReflect.Descriptor instead. +func (*PersonalLogoutResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{13} +} + +func (x *PersonalLogoutResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +type ListPersonalRolesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalRolesRequest) Reset() { + *x = ListPersonalRolesRequest{} + mi := &file_auth_personal_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalRolesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalRolesRequest) ProtoMessage() {} + +func (x *ListPersonalRolesRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[14] + 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 ListPersonalRolesRequest.ProtoReflect.Descriptor instead. +func (*ListPersonalRolesRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{14} +} + +type ListPersonalRolesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Roles []*types.Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalRolesResponse) Reset() { + *x = ListPersonalRolesResponse{} + mi := &file_auth_personal_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalRolesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalRolesResponse) ProtoMessage() {} + +func (x *ListPersonalRolesResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[15] + 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 ListPersonalRolesResponse.ProtoReflect.Descriptor instead. +func (*ListPersonalRolesResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{15} +} + +func (x *ListPersonalRolesResponse) GetRoles() []*types.Role { + if x != nil { + return x.Roles + } + return nil +} + +type GetPersonalProfileRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPersonalProfileRequest) Reset() { + *x = GetPersonalProfileRequest{} + mi := &file_auth_personal_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPersonalProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPersonalProfileRequest) ProtoMessage() {} + +func (x *GetPersonalProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[16] + 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 GetPersonalProfileRequest.ProtoReflect.Descriptor instead. +func (*GetPersonalProfileRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{16} +} + +type GetPersonalProfileResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPersonalProfileResponse) Reset() { + *x = GetPersonalProfileResponse{} + mi := &file_auth_personal_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPersonalProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPersonalProfileResponse) ProtoMessage() {} + +func (x *GetPersonalProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[17] + 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 GetPersonalProfileResponse.ProtoReflect.Descriptor instead. +func (*GetPersonalProfileResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{17} +} + +func (x *GetPersonalProfileResponse) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +type RefreshPersonalTokenRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshPersonalTokenRequest) Reset() { + *x = RefreshPersonalTokenRequest{} + mi := &file_auth_personal_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshPersonalTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshPersonalTokenRequest) ProtoMessage() {} + +func (x *RefreshPersonalTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshPersonalTokenRequest.ProtoReflect.Descriptor instead. +func (*RefreshPersonalTokenRequest) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{18} +} + +func (x *RefreshPersonalTokenRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type RefreshPersonalTokenResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshPersonalTokenResponse) Reset() { + *x = RefreshPersonalTokenResponse{} + mi := &file_auth_personal_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshPersonalTokenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshPersonalTokenResponse) ProtoMessage() {} + +func (x *RefreshPersonalTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_personal_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshPersonalTokenResponse.ProtoReflect.Descriptor instead. +func (*RefreshPersonalTokenResponse) Descriptor() ([]byte, []int) { + return file_auth_personal_proto_rawDescGZIP(), []int{19} +} + +func (x *RefreshPersonalTokenResponse) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +var File_auth_personal_proto protoreflect.FileDescriptor + +const file_auth_personal_proto_rawDesc = "" + + "\n" + + "\x13auth/personal.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12types/system.proto\x1a\x17validate/validate.proto\"H\n" + + "\x1cUpdatePersonalSettingRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + + "\x1dUpdatePersonalSettingResponse\"L\n" + + "\x19UpdatePersonalRoleRequest\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\x1c\n" + + "\x1aUpdatePersonalRoleResponse\"\xc4\x01\n" + + "\x1cListPersonalResourcesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\"\xa3\x01\n" + + "\x1dListPersonalResourcesResponse\x12\x19\n" + + "\n" + + "total_size\x18\x01 \x01(\x03R\x05total\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\"I\n" + + "\x1dUpdatePersonalPasswordRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\" \n" + + "\x1eUpdatePersonalPasswordResponse\"6\n" + + "\x1bPersonalPasswordRestRequest\x12\x17\n" + + "\x02id\x18\x01 \x01(\x03B\a\xfaB\x04\"\x02 \x00R\x02id\"\x1e\n" + + "\x1cPersonalPasswordRestResponse\"H\n" + + "\x1cUpdatePersonalProfileRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + + "\x1dUpdatePersonalProfileResponse\"A\n" + + "\x15PersonalLogoutRequest\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"2\n" + + "\x16PersonalLogoutResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\"\x1a\n" + + "\x18ListPersonalRolesRequest\"N\n" + + "\x19ListPersonalRolesResponse\x121\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x1b\n" + + "\x19GetPersonalProfileRequest\"M\n" + + "\x1aGetPersonalProfileResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + + "\x1bRefreshPersonalTokenRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"4\n" + + "\x1cRefreshPersonalTokenResponse\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token2\xa3\n" + + "\n" + + "\x0fPersonalService\x12\x97\x01\n" + + "\x12GetPersonalProfile\x12/.api.v1.services.auth.GetPersonalProfileRequest\x1a0.api.v1.services.auth.GetPersonalProfileResponse\"\x1e\x82\xd3\xe4\x93\x02\x18\x12\x16/auth/personal/profile\x12\xa2\x01\n" + + "\x15ListPersonalResources\x122.api.v1.services.auth.ListPersonalResourcesRequest\x1a3.api.v1.services.auth.ListPersonalResourcesResponse\" \x82\xd3\xe4\x93\x02\x1a\x12\x18/auth/personal/resources\x12\x92\x01\n" + + "\x11ListPersonalRoles\x12..api.v1.services.auth.ListPersonalRolesRequest\x1a/.api.v1.services.auth.ListPersonalRolesResponse\"\x1c\x82\xd3\xe4\x93\x02\x16\x12\x14/auth/personal/roles\x12\x90\x01\n" + + "\x0ePersonalLogout\x12+.api.v1.services.auth.PersonalLogoutRequest\x1a,.api.v1.services.auth.PersonalLogoutResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\"\x15/auth/personal/logout\x12\xa9\x01\n" + + "\x14RefreshPersonalToken\x121.api.v1.services.auth.RefreshPersonalTokenRequest\x1a2.api.v1.services.auth.RefreshPersonalTokenResponse\"*\x82\xd3\xe4\x93\x02$:\x04data\"\x1c/auth/personal/token/refresh\x12\xaa\x01\n" + + "\x16UpdatePersonalPassword\x123.api.v1.services.auth.UpdatePersonalPasswordRequest\x1a4.api.v1.services.auth.UpdatePersonalPasswordResponse\"%\x82\xd3\xe4\x93\x02\x1f:\x04data\x1a\x17/auth/personal/password\x12\xa6\x01\n" + + "\x15UpdatePersonalProfile\x122.api.v1.services.auth.UpdatePersonalProfileRequest\x1a3.api.v1.services.auth.UpdatePersonalProfileResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/profile\x12\xa6\x01\n" + + "\x15UpdatePersonalSetting\x122.api.v1.services.auth.UpdatePersonalSettingRequest\x1a3.api.v1.services.auth.UpdatePersonalSettingResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/settingB\xd4\x01\n" + + "\x18com.api.v1.services.authB\rPersonalProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + +var ( + file_auth_personal_proto_rawDescOnce sync.Once + file_auth_personal_proto_rawDescData []byte +) + +func file_auth_personal_proto_rawDescGZIP() []byte { + file_auth_personal_proto_rawDescOnce.Do(func() { + file_auth_personal_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_personal_proto_rawDesc), len(file_auth_personal_proto_rawDesc))) + }) + return file_auth_personal_proto_rawDescData +} + +var file_auth_personal_proto_msgTypes = make([]protoimpl.MessageInfo, 20) +var file_auth_personal_proto_goTypes = []any{ + (*UpdatePersonalSettingRequest)(nil), // 0: api.v1.services.auth.UpdatePersonalSettingRequest + (*UpdatePersonalSettingResponse)(nil), // 1: api.v1.services.auth.UpdatePersonalSettingResponse + (*UpdatePersonalRoleRequest)(nil), // 2: api.v1.services.auth.UpdatePersonalRoleRequest + (*UpdatePersonalRoleResponse)(nil), // 3: api.v1.services.auth.UpdatePersonalRoleResponse + (*ListPersonalResourcesRequest)(nil), // 4: api.v1.services.auth.ListPersonalResourcesRequest + (*ListPersonalResourcesResponse)(nil), // 5: api.v1.services.auth.ListPersonalResourcesResponse + (*UpdatePersonalPasswordRequest)(nil), // 6: api.v1.services.auth.UpdatePersonalPasswordRequest + (*UpdatePersonalPasswordResponse)(nil), // 7: api.v1.services.auth.UpdatePersonalPasswordResponse + (*PersonalPasswordRestRequest)(nil), // 8: api.v1.services.auth.PersonalPasswordRestRequest + (*PersonalPasswordRestResponse)(nil), // 9: api.v1.services.auth.PersonalPasswordRestResponse + (*UpdatePersonalProfileRequest)(nil), // 10: api.v1.services.auth.UpdatePersonalProfileRequest + (*UpdatePersonalProfileResponse)(nil), // 11: api.v1.services.auth.UpdatePersonalProfileResponse + (*PersonalLogoutRequest)(nil), // 12: api.v1.services.auth.PersonalLogoutRequest + (*PersonalLogoutResponse)(nil), // 13: api.v1.services.auth.PersonalLogoutResponse + (*ListPersonalRolesRequest)(nil), // 14: api.v1.services.auth.ListPersonalRolesRequest + (*ListPersonalRolesResponse)(nil), // 15: api.v1.services.auth.ListPersonalRolesResponse + (*GetPersonalProfileRequest)(nil), // 16: api.v1.services.auth.GetPersonalProfileRequest + (*GetPersonalProfileResponse)(nil), // 17: api.v1.services.auth.GetPersonalProfileResponse + (*RefreshPersonalTokenRequest)(nil), // 18: api.v1.services.auth.RefreshPersonalTokenRequest + (*RefreshPersonalTokenResponse)(nil), // 19: api.v1.services.auth.RefreshPersonalTokenResponse + (*anypb.Any)(nil), // 20: google.protobuf.Any + (*types.Role)(nil), // 21: api.v1.services.types.Role + (*types.Resource)(nil), // 22: api.v1.services.types.Resource + (*types.User)(nil), // 23: api.v1.services.types.User +} +var file_auth_personal_proto_depIdxs = []int32{ + 20, // 0: api.v1.services.auth.UpdatePersonalSettingRequest.data:type_name -> google.protobuf.Any + 21, // 1: api.v1.services.auth.UpdatePersonalRoleRequest.role:type_name -> api.v1.services.types.Role + 22, // 2: api.v1.services.auth.ListPersonalResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 20, // 3: api.v1.services.auth.UpdatePersonalPasswordRequest.data:type_name -> google.protobuf.Any + 20, // 4: api.v1.services.auth.UpdatePersonalProfileRequest.data:type_name -> google.protobuf.Any + 20, // 5: api.v1.services.auth.PersonalLogoutRequest.data:type_name -> google.protobuf.Any + 21, // 6: api.v1.services.auth.ListPersonalRolesResponse.roles:type_name -> api.v1.services.types.Role + 23, // 7: api.v1.services.auth.GetPersonalProfileResponse.user:type_name -> api.v1.services.types.User + 20, // 8: api.v1.services.auth.RefreshPersonalTokenRequest.data:type_name -> google.protobuf.Any + 16, // 9: api.v1.services.auth.PersonalService.GetPersonalProfile:input_type -> api.v1.services.auth.GetPersonalProfileRequest + 4, // 10: api.v1.services.auth.PersonalService.ListPersonalResources:input_type -> api.v1.services.auth.ListPersonalResourcesRequest + 14, // 11: api.v1.services.auth.PersonalService.ListPersonalRoles:input_type -> api.v1.services.auth.ListPersonalRolesRequest + 12, // 12: api.v1.services.auth.PersonalService.PersonalLogout:input_type -> api.v1.services.auth.PersonalLogoutRequest + 18, // 13: api.v1.services.auth.PersonalService.RefreshPersonalToken:input_type -> api.v1.services.auth.RefreshPersonalTokenRequest + 6, // 14: api.v1.services.auth.PersonalService.UpdatePersonalPassword:input_type -> api.v1.services.auth.UpdatePersonalPasswordRequest + 10, // 15: api.v1.services.auth.PersonalService.UpdatePersonalProfile:input_type -> api.v1.services.auth.UpdatePersonalProfileRequest + 0, // 16: api.v1.services.auth.PersonalService.UpdatePersonalSetting:input_type -> api.v1.services.auth.UpdatePersonalSettingRequest + 17, // 17: api.v1.services.auth.PersonalService.GetPersonalProfile:output_type -> api.v1.services.auth.GetPersonalProfileResponse + 5, // 18: api.v1.services.auth.PersonalService.ListPersonalResources:output_type -> api.v1.services.auth.ListPersonalResourcesResponse + 15, // 19: api.v1.services.auth.PersonalService.ListPersonalRoles:output_type -> api.v1.services.auth.ListPersonalRolesResponse + 13, // 20: api.v1.services.auth.PersonalService.PersonalLogout:output_type -> api.v1.services.auth.PersonalLogoutResponse + 19, // 21: api.v1.services.auth.PersonalService.RefreshPersonalToken:output_type -> api.v1.services.auth.RefreshPersonalTokenResponse + 7, // 22: api.v1.services.auth.PersonalService.UpdatePersonalPassword:output_type -> api.v1.services.auth.UpdatePersonalPasswordResponse + 11, // 23: api.v1.services.auth.PersonalService.UpdatePersonalProfile:output_type -> api.v1.services.auth.UpdatePersonalProfileResponse + 1, // 24: api.v1.services.auth.PersonalService.UpdatePersonalSetting:output_type -> api.v1.services.auth.UpdatePersonalSettingResponse + 17, // [17:25] is the sub-list for method output_type + 9, // [9:17] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_auth_personal_proto_init() } +func file_auth_personal_proto_init() { + if File_auth_personal_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_personal_proto_rawDesc), len(file_auth_personal_proto_rawDesc)), + NumEnums: 0, + NumMessages: 20, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_auth_personal_proto_goTypes, + DependencyIndexes: file_auth_personal_proto_depIdxs, + MessageInfos: file_auth_personal_proto_msgTypes, + }.Build() + File_auth_personal_proto = out.File + file_auth_personal_proto_goTypes = nil + file_auth_personal_proto_depIdxs = nil +} diff --git a/api/v1/services/auth/personal.pb.gw.go b/api/v1/services/auth/personal.pb.gw.go new file mode 100644 index 00000000..fb8ce2cc --- /dev/null +++ b/api/v1/services/auth/personal.pb.gw.go @@ -0,0 +1,594 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: auth/personal.proto + +/* +Package auth is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package auth + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +func request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPersonalProfileRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.GetPersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPersonalProfileRequest + metadata runtime.ServerMetadata + ) + msg, err := server.GetPersonalProfile(ctx, &protoReq) + return msg, metadata, err +} + +var filter_PersonalService_ListPersonalResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalResourcesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListPersonalResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalResourcesRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListPersonalResources(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalRolesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.ListPersonalRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalRolesRequest + metadata runtime.ServerMetadata + ) + msg, err := server.ListPersonalRoles(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq PersonalLogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.PersonalLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq PersonalLogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.PersonalLogout(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RefreshPersonalTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.RefreshPersonalToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RefreshPersonalTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.RefreshPersonalToken(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalPasswordRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalPasswordRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalPassword(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalProfileRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalProfileRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalProfile(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalSettingRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalSetting(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalSettingRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalSetting(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterPersonalServiceHandlerServer registers the http handlers for service PersonalService to "mux". +// UnaryRPC :call PersonalServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPersonalServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterPersonalServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PersonalServiceServer) error { + mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/auth/personal/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/auth/personal/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/auth/personal/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/auth/personal/token/refresh")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/auth/personal/password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/auth/personal/setting")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterPersonalServiceHandlerFromEndpoint is same as RegisterPersonalServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterPersonalServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterPersonalServiceHandler(ctx, mux, conn) +} + +// RegisterPersonalServiceHandler registers the http handlers for service PersonalService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterPersonalServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterPersonalServiceHandlerClient(ctx, mux, NewPersonalServiceClient(conn)) +} + +// RegisterPersonalServiceHandlerClient registers the http handlers for service PersonalService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PersonalServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PersonalServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "PersonalServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterPersonalServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PersonalServiceClient) error { + mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/auth/personal/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/auth/personal/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/auth/personal/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/auth/personal/token/refresh")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/auth/personal/password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/auth/personal/setting")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_PersonalService_GetPersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "profile"}, "")) + pattern_PersonalService_ListPersonalResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "resources"}, "")) + pattern_PersonalService_ListPersonalRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "roles"}, "")) + pattern_PersonalService_PersonalLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "logout"}, "")) + pattern_PersonalService_RefreshPersonalToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"auth", "personal", "token", "refresh"}, "")) + pattern_PersonalService_UpdatePersonalPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "password"}, "")) + pattern_PersonalService_UpdatePersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "profile"}, "")) + pattern_PersonalService_UpdatePersonalSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "setting"}, "")) +) + +var ( + forward_PersonalService_GetPersonalProfile_0 = runtime.ForwardResponseMessage + forward_PersonalService_ListPersonalResources_0 = runtime.ForwardResponseMessage + forward_PersonalService_ListPersonalRoles_0 = runtime.ForwardResponseMessage + forward_PersonalService_PersonalLogout_0 = runtime.ForwardResponseMessage + forward_PersonalService_RefreshPersonalToken_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalPassword_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalProfile_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalSetting_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/auth/personal.pb.validate.go b/api/v1/services/auth/personal.pb.validate.go new file mode 100644 index 00000000..92933952 --- /dev/null +++ b/api/v1/services/auth/personal.pb.validate.go @@ -0,0 +1,2390 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: auth/personal.proto + +package auth + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on UpdatePersonalSettingRequest 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 *UpdatePersonalSettingRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalSettingRequest 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 +// UpdatePersonalSettingRequestMultiError, or nil if none found. +func (m *UpdatePersonalSettingRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalSettingRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalSettingRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalSettingRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalSettingRequest.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalSettingRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalSettingRequestMultiError) 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 UpdatePersonalSettingRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalSettingRequestValidationError is the validation error returned +// by UpdatePersonalSettingRequest.Validate if the designated constraints +// aren't met. +type UpdatePersonalSettingRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalSettingRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalSettingRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalSettingRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalSettingRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalSettingRequestValidationError) ErrorName() string { + return "UpdatePersonalSettingRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalSettingRequestValidationError) 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 %sUpdatePersonalSettingRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalSettingRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalSettingRequestValidationError{} + +// Validate checks the field values on UpdatePersonalSettingResponse 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 *UpdatePersonalSettingResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalSettingResponse 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 +// UpdatePersonalSettingResponseMultiError, or nil if none found. +func (m *UpdatePersonalSettingResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalSettingResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalSettingResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalSettingResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalSettingResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalSettingResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalSettingResponseMultiError) 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 UpdatePersonalSettingResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalSettingResponseValidationError is the validation error +// returned by UpdatePersonalSettingResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalSettingResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalSettingResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalSettingResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalSettingResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalSettingResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalSettingResponseValidationError) ErrorName() string { + return "UpdatePersonalSettingResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalSettingResponseValidationError) 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 %sUpdatePersonalSettingResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalSettingResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalSettingResponseValidationError{} + +// Validate checks the field values on UpdatePersonalRoleRequest 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 *UpdatePersonalRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalRoleRequest 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 +// UpdatePersonalRoleRequestMultiError, or nil if none found. +func (m *UpdatePersonalRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalRoleRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalRoleRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalRoleRequestMultiError is an error wrapping multiple validation +// errors returned by UpdatePersonalRoleRequest.ValidateAll() if the +// designated constraints aren't met. +type UpdatePersonalRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalRoleRequestMultiError) 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 UpdatePersonalRoleRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalRoleRequestValidationError is the validation error returned by +// UpdatePersonalRoleRequest.Validate if the designated constraints aren't met. +type UpdatePersonalRoleRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalRoleRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalRoleRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalRoleRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalRoleRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalRoleRequestValidationError) ErrorName() string { + return "UpdatePersonalRoleRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalRoleRequestValidationError) 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 %sUpdatePersonalRoleRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalRoleRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalRoleRequestValidationError{} + +// Validate checks the field values on UpdatePersonalRoleResponse 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 *UpdatePersonalRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalRoleResponse 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 +// UpdatePersonalRoleResponseMultiError, or nil if none found. +func (m *UpdatePersonalRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalRoleResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalRoleResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalRoleResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalRoleResponse.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalRoleResponseMultiError) 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 UpdatePersonalRoleResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalRoleResponseValidationError is the validation error returned +// by UpdatePersonalRoleResponse.Validate if the designated constraints aren't met. +type UpdatePersonalRoleResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalRoleResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalRoleResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalRoleResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalRoleResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalRoleResponseValidationError) ErrorName() string { + return "UpdatePersonalRoleResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalRoleResponseValidationError) 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 %sUpdatePersonalRoleResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalRoleResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalRoleResponseValidationError{} + +// Validate checks the field values on ListPersonalResourcesRequest 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 *ListPersonalResourcesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalResourcesRequest 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 +// ListPersonalResourcesRequestMultiError, or nil if none found. +func (m *ListPersonalResourcesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalResourcesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + if len(errors) > 0 { + return ListPersonalResourcesRequestMultiError(errors) + } + + return nil +} + +// ListPersonalResourcesRequestMultiError is an error wrapping multiple +// validation errors returned by ListPersonalResourcesRequest.ValidateAll() if +// the designated constraints aren't met. +type ListPersonalResourcesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalResourcesRequestMultiError) 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 ListPersonalResourcesRequestMultiError) AllErrors() []error { return m } + +// ListPersonalResourcesRequestValidationError is the validation error returned +// by ListPersonalResourcesRequest.Validate if the designated constraints +// aren't met. +type ListPersonalResourcesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalResourcesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalResourcesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalResourcesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalResourcesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalResourcesRequestValidationError) ErrorName() string { + return "ListPersonalResourcesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalResourcesRequestValidationError) 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 %sListPersonalResourcesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalResourcesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalResourcesRequestValidationError{} + +// Validate checks the field values on ListPersonalResourcesResponse 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 *ListPersonalResourcesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalResourcesResponse 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 +// ListPersonalResourcesResponseMultiError, or nil if none found. +func (m *ListPersonalResourcesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalResourcesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TotalSize + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for NextPageToken + + if len(errors) > 0 { + return ListPersonalResourcesResponseMultiError(errors) + } + + return nil +} + +// ListPersonalResourcesResponseMultiError is an error wrapping multiple +// validation errors returned by ListPersonalResourcesResponse.ValidateAll() +// if the designated constraints aren't met. +type ListPersonalResourcesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalResourcesResponseMultiError) 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 ListPersonalResourcesResponseMultiError) AllErrors() []error { return m } + +// ListPersonalResourcesResponseValidationError is the validation error +// returned by ListPersonalResourcesResponse.Validate if the designated +// constraints aren't met. +type ListPersonalResourcesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalResourcesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalResourcesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalResourcesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalResourcesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalResourcesResponseValidationError) ErrorName() string { + return "ListPersonalResourcesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalResourcesResponseValidationError) 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 %sListPersonalResourcesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalResourcesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalResourcesResponseValidationError{} + +// Validate checks the field values on UpdatePersonalPasswordRequest 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 *UpdatePersonalPasswordRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalPasswordRequest 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 +// UpdatePersonalPasswordRequestMultiError, or nil if none found. +func (m *UpdatePersonalPasswordRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalPasswordRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalPasswordRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalPasswordRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalPasswordRequest.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalPasswordRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalPasswordRequestMultiError) 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 UpdatePersonalPasswordRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalPasswordRequestValidationError is the validation error +// returned by UpdatePersonalPasswordRequest.Validate if the designated +// constraints aren't met. +type UpdatePersonalPasswordRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalPasswordRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalPasswordRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalPasswordRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalPasswordRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalPasswordRequestValidationError) ErrorName() string { + return "UpdatePersonalPasswordRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalPasswordRequestValidationError) 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 %sUpdatePersonalPasswordRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalPasswordRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalPasswordRequestValidationError{} + +// Validate checks the field values on UpdatePersonalPasswordResponse 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 *UpdatePersonalPasswordResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalPasswordResponse 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 +// UpdatePersonalPasswordResponseMultiError, or nil if none found. +func (m *UpdatePersonalPasswordResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalPasswordResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalPasswordResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalPasswordResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalPasswordResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalPasswordResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalPasswordResponseMultiError) 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 UpdatePersonalPasswordResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalPasswordResponseValidationError is the validation error +// returned by UpdatePersonalPasswordResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalPasswordResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalPasswordResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalPasswordResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalPasswordResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalPasswordResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalPasswordResponseValidationError) ErrorName() string { + return "UpdatePersonalPasswordResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalPasswordResponseValidationError) 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 %sUpdatePersonalPasswordResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalPasswordResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalPasswordResponseValidationError{} + +// Validate checks the field values on PersonalPasswordRestRequest 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 *PersonalPasswordRestRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalPasswordRestRequest 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 +// PersonalPasswordRestRequestMultiError, or nil if none found. +func (m *PersonalPasswordRestRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalPasswordRestRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetId() <= 0 { + err := PersonalPasswordRestRequestValidationError{ + field: "Id", + reason: "value must be greater than 0", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return PersonalPasswordRestRequestMultiError(errors) + } + + return nil +} + +// PersonalPasswordRestRequestMultiError is an error wrapping multiple +// validation errors returned by PersonalPasswordRestRequest.ValidateAll() if +// the designated constraints aren't met. +type PersonalPasswordRestRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalPasswordRestRequestMultiError) 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 PersonalPasswordRestRequestMultiError) AllErrors() []error { return m } + +// PersonalPasswordRestRequestValidationError is the validation error returned +// by PersonalPasswordRestRequest.Validate if the designated constraints +// aren't met. +type PersonalPasswordRestRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalPasswordRestRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalPasswordRestRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalPasswordRestRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalPasswordRestRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalPasswordRestRequestValidationError) ErrorName() string { + return "PersonalPasswordRestRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalPasswordRestRequestValidationError) 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 %sPersonalPasswordRestRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalPasswordRestRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalPasswordRestRequestValidationError{} + +// Validate checks the field values on PersonalPasswordRestResponse 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 *PersonalPasswordRestResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalPasswordRestResponse 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 +// PersonalPasswordRestResponseMultiError, or nil if none found. +func (m *PersonalPasswordRestResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalPasswordRestResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return PersonalPasswordRestResponseMultiError(errors) + } + + return nil +} + +// PersonalPasswordRestResponseMultiError is an error wrapping multiple +// validation errors returned by PersonalPasswordRestResponse.ValidateAll() if +// the designated constraints aren't met. +type PersonalPasswordRestResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalPasswordRestResponseMultiError) 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 PersonalPasswordRestResponseMultiError) AllErrors() []error { return m } + +// PersonalPasswordRestResponseValidationError is the validation error returned +// by PersonalPasswordRestResponse.Validate if the designated constraints +// aren't met. +type PersonalPasswordRestResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalPasswordRestResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalPasswordRestResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalPasswordRestResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalPasswordRestResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalPasswordRestResponseValidationError) ErrorName() string { + return "PersonalPasswordRestResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalPasswordRestResponseValidationError) 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 %sPersonalPasswordRestResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalPasswordRestResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalPasswordRestResponseValidationError{} + +// Validate checks the field values on UpdatePersonalProfileRequest 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 *UpdatePersonalProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalProfileRequest 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 +// UpdatePersonalProfileRequestMultiError, or nil if none found. +func (m *UpdatePersonalProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalProfileRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalProfileRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalProfileRequest.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalProfileRequestMultiError) 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 UpdatePersonalProfileRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalProfileRequestValidationError is the validation error returned +// by UpdatePersonalProfileRequest.Validate if the designated constraints +// aren't met. +type UpdatePersonalProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalProfileRequestValidationError) ErrorName() string { + return "UpdatePersonalProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalProfileRequestValidationError) 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 %sUpdatePersonalProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalProfileRequestValidationError{} + +// Validate checks the field values on UpdatePersonalProfileResponse 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 *UpdatePersonalProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalProfileResponse 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 +// UpdatePersonalProfileResponseMultiError, or nil if none found. +func (m *UpdatePersonalProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalProfileResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalProfileResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalProfileResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalProfileResponseMultiError) 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 UpdatePersonalProfileResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalProfileResponseValidationError is the validation error +// returned by UpdatePersonalProfileResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalProfileResponseValidationError) ErrorName() string { + return "UpdatePersonalProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalProfileResponseValidationError) 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 %sUpdatePersonalProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalProfileResponseValidationError{} + +// Validate checks the field values on PersonalLogoutRequest 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 *PersonalLogoutRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalLogoutRequest 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 +// PersonalLogoutRequestMultiError, or nil if none found. +func (m *PersonalLogoutRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalLogoutRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return PersonalLogoutRequestMultiError(errors) + } + + return nil +} + +// PersonalLogoutRequestMultiError is an error wrapping multiple validation +// errors returned by PersonalLogoutRequest.ValidateAll() if the designated +// constraints aren't met. +type PersonalLogoutRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalLogoutRequestMultiError) 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 PersonalLogoutRequestMultiError) AllErrors() []error { return m } + +// PersonalLogoutRequestValidationError is the validation error returned by +// PersonalLogoutRequest.Validate if the designated constraints aren't met. +type PersonalLogoutRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalLogoutRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalLogoutRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalLogoutRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalLogoutRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalLogoutRequestValidationError) ErrorName() string { + return "PersonalLogoutRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalLogoutRequestValidationError) 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 %sPersonalLogoutRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalLogoutRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalLogoutRequestValidationError{} + +// Validate checks the field values on PersonalLogoutResponse 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 *PersonalLogoutResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalLogoutResponse 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 +// PersonalLogoutResponseMultiError, or nil if none found. +func (m *PersonalLogoutResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalLogoutResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Success + + if len(errors) > 0 { + return PersonalLogoutResponseMultiError(errors) + } + + return nil +} + +// PersonalLogoutResponseMultiError is an error wrapping multiple validation +// errors returned by PersonalLogoutResponse.ValidateAll() if the designated +// constraints aren't met. +type PersonalLogoutResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalLogoutResponseMultiError) 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 PersonalLogoutResponseMultiError) AllErrors() []error { return m } + +// PersonalLogoutResponseValidationError is the validation error returned by +// PersonalLogoutResponse.Validate if the designated constraints aren't met. +type PersonalLogoutResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalLogoutResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalLogoutResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalLogoutResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalLogoutResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalLogoutResponseValidationError) ErrorName() string { + return "PersonalLogoutResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalLogoutResponseValidationError) 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 %sPersonalLogoutResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalLogoutResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalLogoutResponseValidationError{} + +// Validate checks the field values on ListPersonalRolesRequest 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 *ListPersonalRolesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalRolesRequest 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 +// ListPersonalRolesRequestMultiError, or nil if none found. +func (m *ListPersonalRolesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalRolesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return ListPersonalRolesRequestMultiError(errors) + } + + return nil +} + +// ListPersonalRolesRequestMultiError is an error wrapping multiple validation +// errors returned by ListPersonalRolesRequest.ValidateAll() if the designated +// constraints aren't met. +type ListPersonalRolesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalRolesRequestMultiError) 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 ListPersonalRolesRequestMultiError) AllErrors() []error { return m } + +// ListPersonalRolesRequestValidationError is the validation error returned by +// ListPersonalRolesRequest.Validate if the designated constraints aren't met. +type ListPersonalRolesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalRolesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalRolesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalRolesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalRolesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalRolesRequestValidationError) ErrorName() string { + return "ListPersonalRolesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalRolesRequestValidationError) 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 %sListPersonalRolesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalRolesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalRolesRequestValidationError{} + +// Validate checks the field values on ListPersonalRolesResponse 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 *ListPersonalRolesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalRolesResponse 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 +// ListPersonalRolesResponseMultiError, or nil if none found. +func (m *ListPersonalRolesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalRolesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListPersonalRolesResponseMultiError(errors) + } + + return nil +} + +// ListPersonalRolesResponseMultiError is an error wrapping multiple validation +// errors returned by ListPersonalRolesResponse.ValidateAll() if the +// designated constraints aren't met. +type ListPersonalRolesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalRolesResponseMultiError) 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 ListPersonalRolesResponseMultiError) AllErrors() []error { return m } + +// ListPersonalRolesResponseValidationError is the validation error returned by +// ListPersonalRolesResponse.Validate if the designated constraints aren't met. +type ListPersonalRolesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalRolesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalRolesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalRolesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalRolesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalRolesResponseValidationError) ErrorName() string { + return "ListPersonalRolesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalRolesResponseValidationError) 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 %sListPersonalRolesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalRolesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalRolesResponseValidationError{} + +// Validate checks the field values on GetPersonalProfileRequest 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 *GetPersonalProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPersonalProfileRequest 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 +// GetPersonalProfileRequestMultiError, or nil if none found. +func (m *GetPersonalProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPersonalProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetPersonalProfileRequestMultiError(errors) + } + + return nil +} + +// GetPersonalProfileRequestMultiError is an error wrapping multiple validation +// errors returned by GetPersonalProfileRequest.ValidateAll() if the +// designated constraints aren't met. +type GetPersonalProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPersonalProfileRequestMultiError) 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 GetPersonalProfileRequestMultiError) AllErrors() []error { return m } + +// GetPersonalProfileRequestValidationError is the validation error returned by +// GetPersonalProfileRequest.Validate if the designated constraints aren't met. +type GetPersonalProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPersonalProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPersonalProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPersonalProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPersonalProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPersonalProfileRequestValidationError) ErrorName() string { + return "GetPersonalProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPersonalProfileRequestValidationError) 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 %sGetPersonalProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPersonalProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPersonalProfileRequestValidationError{} + +// Validate checks the field values on GetPersonalProfileResponse 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 *GetPersonalProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPersonalProfileResponse 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 +// GetPersonalProfileResponseMultiError, or nil if none found. +func (m *GetPersonalProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPersonalProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetPersonalProfileResponseMultiError(errors) + } + + return nil +} + +// GetPersonalProfileResponseMultiError is an error wrapping multiple +// validation errors returned by GetPersonalProfileResponse.ValidateAll() if +// the designated constraints aren't met. +type GetPersonalProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPersonalProfileResponseMultiError) 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 GetPersonalProfileResponseMultiError) AllErrors() []error { return m } + +// GetPersonalProfileResponseValidationError is the validation error returned +// by GetPersonalProfileResponse.Validate if the designated constraints aren't met. +type GetPersonalProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPersonalProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPersonalProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPersonalProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPersonalProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPersonalProfileResponseValidationError) ErrorName() string { + return "GetPersonalProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPersonalProfileResponseValidationError) 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 %sGetPersonalProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPersonalProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPersonalProfileResponseValidationError{} + +// Validate checks the field values on RefreshPersonalTokenRequest 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 *RefreshPersonalTokenRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RefreshPersonalTokenRequest 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 +// RefreshPersonalTokenRequestMultiError, or nil if none found. +func (m *RefreshPersonalTokenRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *RefreshPersonalTokenRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RefreshPersonalTokenRequestMultiError(errors) + } + + return nil +} + +// RefreshPersonalTokenRequestMultiError is an error wrapping multiple +// validation errors returned by RefreshPersonalTokenRequest.ValidateAll() if +// the designated constraints aren't met. +type RefreshPersonalTokenRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RefreshPersonalTokenRequestMultiError) 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 RefreshPersonalTokenRequestMultiError) AllErrors() []error { return m } + +// RefreshPersonalTokenRequestValidationError is the validation error returned +// by RefreshPersonalTokenRequest.Validate if the designated constraints +// aren't met. +type RefreshPersonalTokenRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RefreshPersonalTokenRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RefreshPersonalTokenRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RefreshPersonalTokenRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RefreshPersonalTokenRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RefreshPersonalTokenRequestValidationError) ErrorName() string { + return "RefreshPersonalTokenRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e RefreshPersonalTokenRequestValidationError) 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 %sRefreshPersonalTokenRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RefreshPersonalTokenRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RefreshPersonalTokenRequestValidationError{} + +// Validate checks the field values on RefreshPersonalTokenResponse 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 *RefreshPersonalTokenResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RefreshPersonalTokenResponse 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 +// RefreshPersonalTokenResponseMultiError, or nil if none found. +func (m *RefreshPersonalTokenResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *RefreshPersonalTokenResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Token + + if len(errors) > 0 { + return RefreshPersonalTokenResponseMultiError(errors) + } + + return nil +} + +// RefreshPersonalTokenResponseMultiError is an error wrapping multiple +// validation errors returned by RefreshPersonalTokenResponse.ValidateAll() if +// the designated constraints aren't met. +type RefreshPersonalTokenResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RefreshPersonalTokenResponseMultiError) 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 RefreshPersonalTokenResponseMultiError) AllErrors() []error { return m } + +// RefreshPersonalTokenResponseValidationError is the validation error returned +// by RefreshPersonalTokenResponse.Validate if the designated constraints +// aren't met. +type RefreshPersonalTokenResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RefreshPersonalTokenResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RefreshPersonalTokenResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RefreshPersonalTokenResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RefreshPersonalTokenResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RefreshPersonalTokenResponseValidationError) ErrorName() string { + return "RefreshPersonalTokenResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e RefreshPersonalTokenResponseValidationError) 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 %sRefreshPersonalTokenResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RefreshPersonalTokenResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RefreshPersonalTokenResponseValidationError{} diff --git a/api/v1/services/auth/personal_bridge.pb.go b/api/v1/services/auth/personal_bridge.pb.go new file mode 100644 index 00000000..25b430e6 --- /dev/null +++ b/api/v1/services/auth/personal_bridge.pb.go @@ -0,0 +1,565 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: auth/personal.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const PersonalServiceGetPersonalProfileBridgeOperation = "/api.v1.services.auth.PersonalService/GetPersonalProfile" +const PersonalServiceListPersonalResourcesBridgeOperation = "/api.v1.services.auth.PersonalService/ListPersonalResources" +const PersonalServiceListPersonalRolesBridgeOperation = "/api.v1.services.auth.PersonalService/ListPersonalRoles" +const PersonalServicePersonalLogoutBridgeOperation = "/api.v1.services.auth.PersonalService/PersonalLogout" +const PersonalServiceRefreshPersonalTokenBridgeOperation = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" +const PersonalServiceUpdatePersonalPasswordBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" +const PersonalServiceUpdatePersonalProfileBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" +const PersonalServiceUpdatePersonalSettingBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" + +type PersonalServiceBridgeServer interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) +} + +type PersonalServiceHooker interface { + PersonalServiceGetPersonalProfileHooker + PersonalServiceListPersonalResourcesHooker + PersonalServiceListPersonalRolesHooker + PersonalServicePersonalLogoutHooker + PersonalServiceRefreshPersonalTokenHooker + PersonalServiceUpdatePersonalPasswordHooker + PersonalServiceUpdatePersonalProfileHooker + PersonalServiceUpdatePersonalSettingHooker +} + +type PersonalServiceHookedBridger interface { + PersonalServiceHooker + PersonalServiceBridgeServer +} +type PersonalServiceGetPersonalProfileHooker interface { + PrepareGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) + CompleteGetPersonalProfile(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error +} +type PersonalServiceListPersonalResourcesHooker interface { + PrepareListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) + CompleteListPersonalResources(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error +} +type PersonalServiceListPersonalRolesHooker interface { + PrepareListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) + CompleteListPersonalRoles(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error +} +type PersonalServicePersonalLogoutHooker interface { + PreparePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) + CompletePersonalLogout(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error +} +type PersonalServiceRefreshPersonalTokenHooker interface { + PrepareRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) + CompleteRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error +} +type PersonalServiceUpdatePersonalPasswordHooker interface { + PrepareUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) + CompleteUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error +} +type PersonalServiceUpdatePersonalProfileHooker interface { + PrepareUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) + CompleteUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error +} +type PersonalServiceUpdatePersonalSettingHooker interface { + PrepareUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) + CompleteUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error +} + +func RegisterPersonalServiceBridgeServer(s *http.Server, srv PersonalServiceHookedBridger) { + r := s.Route("/") + r.GET("/auth/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) + r.GET("/auth/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) + r.GET("/auth/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) + r.POST("/auth/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(srv)) + r.POST("/auth/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv)) + r.PUT("/auth/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv)) + r.PUT("/auth/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv)) + r.PUT("/auth/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv)) +} + +func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPersonalProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + }) + + newctx, err := srv.PrepareGetPersonalProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetPersonalProfile(ctx, &in, out.(*GetPersonalProfileResponse)) + } +} + +func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + }) + + newctx, err := srv.PrepareListPersonalResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPersonalResources(ctx, &in, out.(*ListPersonalResourcesResponse)) + } +} + +func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + }) + + newctx, err := srv.PrepareListPersonalRoles(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPersonalRoles(ctx, &in, out.(*ListPersonalRolesResponse)) + } +} + +func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in PersonalLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServicePersonalLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + }) + + newctx, err := srv.PreparePersonalLogout(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompletePersonalLogout(ctx, &in, out.(*PersonalLogoutResponse)) + } +} + +func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RefreshPersonalTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + }) + + newctx, err := srv.PrepareRefreshPersonalToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteRefreshPersonalToken(ctx, &in, out.(*RefreshPersonalTokenResponse)) + } +} + +func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalPassword(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalPassword(ctx, &in, out.(*UpdatePersonalPasswordResponse)) + } +} + +func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalProfileRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalProfile(ctx, &in, out.(*UpdatePersonalProfileResponse)) + } +} + +func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalSettingRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalSetting(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalSetting(ctx, &in, out.(*UpdatePersonalSettingResponse)) + } +} + +// UnimplementedPersonalServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPersonalServiceHooked struct{} + +func (UnimplementedPersonalServiceHooked) PrepareGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PreparePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompletePersonalLogout(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { + return ctx.Result(200, out) +} + +func WithPersonalServiceHook(h PersonalServiceHooker) func(PersonalServiceBridgeServer) PersonalServiceHookedBridger { + return func(srv PersonalServiceBridgeServer) PersonalServiceHookedBridger { + return PersonalServiceHookedBridge{PersonalServiceBridgeServer: srv, PersonalServiceHooker: h} + } +} + +// PersonalServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PersonalService. +// It implements the HTTP and gRPC implementations of PersonalService. +// It forwards requests and responses between the two implementations. +type PersonalServiceHookedBridge struct { + PersonalServiceBridgeServer + PersonalServiceHooker +} + +type PersonalServiceHTTPBridgeImpl struct { + client PersonalServiceHTTPClient +} + +func NewPersonalServiceHTTPBridge(client *http.Client) PersonalServiceHTTPServer { + return &PersonalServiceHTTPBridgeImpl{client: NewPersonalServiceHTTPClient(client)} +} + +func (c *PersonalServiceHTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +type PersonalServiceBridgeImpl struct { + client PersonalServiceClient +} + +func NewPersonalServiceBridge(client grpc.ClientConnInterface) PersonalServiceServer { + return &PersonalServiceBridgeImpl{client: NewPersonalServiceClient(client)} +} + +func (c *PersonalServiceBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} + +type PersonalServiceGRPC2HTTPBridgeImpl struct { + client PersonalServiceClient +} + +func NewPersonalServiceGRPC2HTTP(client grpc.ClientConnInterface) PersonalServiceHTTPServer { + return &PersonalServiceGRPC2HTTPBridgeImpl{client: NewPersonalServiceClient(client)} +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +type PersonalServiceHTTP2GRPCBridgeImpl struct { + client PersonalServiceHTTPClient +} + +func NewPersonalServiceHTTP2GRPC(client *http.Client) PersonalServiceServer { + return &PersonalServiceHTTP2GRPCBridgeImpl{client: NewPersonalServiceHTTPClient(client)} +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} diff --git a/api/v1/services/auth/personal_grpc.pb.go b/api/v1/services/auth/personal_grpc.pb.go new file mode 100644 index 00000000..6f4d95e8 --- /dev/null +++ b/api/v1/services/auth/personal_grpc.pb.go @@ -0,0 +1,407 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: auth/personal.proto + +package auth + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + PersonalService_GetPersonalProfile_FullMethodName = "/api.v1.services.auth.PersonalService/GetPersonalProfile" + PersonalService_ListPersonalResources_FullMethodName = "/api.v1.services.auth.PersonalService/ListPersonalResources" + PersonalService_ListPersonalRoles_FullMethodName = "/api.v1.services.auth.PersonalService/ListPersonalRoles" + PersonalService_PersonalLogout_FullMethodName = "/api.v1.services.auth.PersonalService/PersonalLogout" + PersonalService_RefreshPersonalToken_FullMethodName = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" + PersonalService_UpdatePersonalPassword_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" + PersonalService_UpdatePersonalProfile_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" + PersonalService_UpdatePersonalSetting_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" +) + +// PersonalServiceClient is the client API for PersonalService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// PersonalService Personal user service +type PersonalServiceClient interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) +} + +type personalServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPersonalServiceClient(cc grpc.ClientConnInterface) PersonalServiceClient { + return &personalServiceClient{cc} +} + +func (c *personalServiceClient) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetPersonalProfileResponse) + err := c.cc.Invoke(ctx, PersonalService_GetPersonalProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPersonalResourcesResponse) + err := c.cc.Invoke(ctx, PersonalService_ListPersonalResources_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPersonalRolesResponse) + err := c.cc.Invoke(ctx, PersonalService_ListPersonalRoles_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(PersonalLogoutResponse) + err := c.cc.Invoke(ctx, PersonalService_PersonalLogout_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RefreshPersonalTokenResponse) + err := c.cc.Invoke(ctx, PersonalService_RefreshPersonalToken_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalPasswordResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalPassword_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalProfileResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalSettingResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalSetting_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PersonalServiceServer is the server API for PersonalService service. +// All implementations must embed UnimplementedPersonalServiceServer +// for forward compatibility. +// +// PersonalService Personal user service +type PersonalServiceServer interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) + mustEmbedUnimplementedPersonalServiceServer() +} + +// UnimplementedPersonalServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPersonalServiceServer struct{} + +func (UnimplementedPersonalServiceServer) GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPersonalProfile not implemented") +} +func (UnimplementedPersonalServiceServer) ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPersonalResources not implemented") +} +func (UnimplementedPersonalServiceServer) ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPersonalRoles not implemented") +} +func (UnimplementedPersonalServiceServer) PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PersonalLogout not implemented") +} +func (UnimplementedPersonalServiceServer) RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RefreshPersonalToken not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalPassword not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalProfile not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalSetting not implemented") +} +func (UnimplementedPersonalServiceServer) mustEmbedUnimplementedPersonalServiceServer() {} +func (UnimplementedPersonalServiceServer) testEmbeddedByValue() {} + +// UnsafePersonalServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PersonalServiceServer will +// result in compilation errors. +type UnsafePersonalServiceServer interface { + mustEmbedUnimplementedPersonalServiceServer() +} + +func RegisterPersonalServiceServer(s grpc.ServiceRegistrar, srv PersonalServiceServer) { + // If the following call pancis, it indicates UnimplementedPersonalServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&PersonalService_ServiceDesc, srv) +} + +func _PersonalService_GetPersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPersonalProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).GetPersonalProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_GetPersonalProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_ListPersonalResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPersonalResourcesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).ListPersonalResources(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_ListPersonalResources_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_ListPersonalRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPersonalRolesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).ListPersonalRoles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_ListPersonalRoles_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_PersonalLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PersonalLogoutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).PersonalLogout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_PersonalLogout_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_RefreshPersonalToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RefreshPersonalTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_RefreshPersonalToken_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalPasswordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalPassword_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalSettingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalSetting_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// PersonalService_ServiceDesc is the grpc.ServiceDesc for PersonalService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PersonalService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.auth.PersonalService", + HandlerType: (*PersonalServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetPersonalProfile", + Handler: _PersonalService_GetPersonalProfile_Handler, + }, + { + MethodName: "ListPersonalResources", + Handler: _PersonalService_ListPersonalResources_Handler, + }, + { + MethodName: "ListPersonalRoles", + Handler: _PersonalService_ListPersonalRoles_Handler, + }, + { + MethodName: "PersonalLogout", + Handler: _PersonalService_PersonalLogout_Handler, + }, + { + MethodName: "RefreshPersonalToken", + Handler: _PersonalService_RefreshPersonalToken_Handler, + }, + { + MethodName: "UpdatePersonalPassword", + Handler: _PersonalService_UpdatePersonalPassword_Handler, + }, + { + MethodName: "UpdatePersonalProfile", + Handler: _PersonalService_UpdatePersonalProfile_Handler, + }, + { + MethodName: "UpdatePersonalSetting", + Handler: _PersonalService_UpdatePersonalSetting_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "auth/personal.proto", +} diff --git a/api/v1/services/auth/personal_http.pb.go b/api/v1/services/auth/personal_http.pb.go new file mode 100644 index 00000000..1d00a291 --- /dev/null +++ b/api/v1/services/auth/personal_http.pb.go @@ -0,0 +1,366 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: auth/personal.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationPersonalServiceGetPersonalProfile = "/api.v1.services.auth.PersonalService/GetPersonalProfile" +const OperationPersonalServiceListPersonalResources = "/api.v1.services.auth.PersonalService/ListPersonalResources" +const OperationPersonalServiceListPersonalRoles = "/api.v1.services.auth.PersonalService/ListPersonalRoles" +const OperationPersonalServicePersonalLogout = "/api.v1.services.auth.PersonalService/PersonalLogout" +const OperationPersonalServiceRefreshPersonalToken = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" +const OperationPersonalServiceUpdatePersonalPassword = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" +const OperationPersonalServiceUpdatePersonalProfile = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" +const OperationPersonalServiceUpdatePersonalSetting = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" + +type PersonalServiceHTTPServer interface { + // GetPersonalProfile GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalRoles ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) +} + +func RegisterPersonalServiceHTTPServer(s *http.Server, srv PersonalServiceHTTPServer) { + r := s.Route("/") + r.GET("/auth/personal/profile", _PersonalService_GetPersonalProfile0_HTTP_Handler(srv)) + r.GET("/auth/personal/resources", _PersonalService_ListPersonalResources0_HTTP_Handler(srv)) + r.GET("/auth/personal/roles", _PersonalService_ListPersonalRoles0_HTTP_Handler(srv)) + r.POST("/auth/personal/logout", _PersonalService_PersonalLogout0_HTTP_Handler(srv)) + r.POST("/auth/personal/token/refresh", _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv)) + r.PUT("/auth/personal/password", _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv)) + r.PUT("/auth/personal/profile", _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv)) + r.PUT("/auth/personal/setting", _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv)) +} + +func _PersonalService_GetPersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPersonalProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetPersonalProfileResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_ListPersonalResources0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPersonalResourcesResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_ListPersonalRoles0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPersonalRolesResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_PersonalLogout0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in PersonalLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServicePersonalLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*PersonalLogoutResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RefreshPersonalTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*RefreshPersonalTokenResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalPasswordResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalProfileRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalProfileResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalSettingRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalSettingResponse) + return ctx.Result(200, reply) + } +} + +type PersonalServiceHTTPClient interface { + // GetPersonalProfile GetPersonalProfile Update the personal user information + GetPersonalProfile(ctx context.Context, req *GetPersonalProfileRequest, opts ...http.CallOption) (rsp *GetPersonalProfileResponse, err error) + // ListPersonalResources ListPersonalResources List the personal user's menu + ListPersonalResources(ctx context.Context, req *ListPersonalResourcesRequest, opts ...http.CallOption) (rsp *ListPersonalResourcesResponse, err error) + // ListPersonalRoles ListPersonalResources List the personal user's menu + ListPersonalRoles(ctx context.Context, req *ListPersonalRolesRequest, opts ...http.CallOption) (rsp *ListPersonalRolesResponse, err error) + // PersonalLogout PersonalLogout Personal user logs out + PersonalLogout(ctx context.Context, req *PersonalLogoutRequest, opts ...http.CallOption) (rsp *PersonalLogoutResponse, err error) + // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(ctx context.Context, req *RefreshPersonalTokenRequest, opts ...http.CallOption) (rsp *RefreshPersonalTokenResponse, err error) + // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(ctx context.Context, req *UpdatePersonalPasswordRequest, opts ...http.CallOption) (rsp *UpdatePersonalPasswordResponse, err error) + // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(ctx context.Context, req *UpdatePersonalProfileRequest, opts ...http.CallOption) (rsp *UpdatePersonalProfileResponse, err error) + // UpdatePersonalSetting UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(ctx context.Context, req *UpdatePersonalSettingRequest, opts ...http.CallOption) (rsp *UpdatePersonalSettingResponse, err error) +} + +type PersonalServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewPersonalServiceHTTPClient(client *http.Client) PersonalServiceHTTPClient { + return &PersonalServiceHTTPClientImpl{client} +} + +// GetPersonalProfile GetPersonalProfile Update the personal user information +func (c *PersonalServiceHTTPClientImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...http.CallOption) (*GetPersonalProfileResponse, error) { + var out GetPersonalProfileResponse + pattern := "/auth/personal/profile" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceGetPersonalProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ListPersonalResources ListPersonalResources List the personal user's menu +func (c *PersonalServiceHTTPClientImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...http.CallOption) (*ListPersonalResourcesResponse, error) { + var out ListPersonalResourcesResponse + pattern := "/auth/personal/resources" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceListPersonalResources)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ListPersonalRoles ListPersonalResources List the personal user's menu +func (c *PersonalServiceHTTPClientImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...http.CallOption) (*ListPersonalRolesResponse, error) { + var out ListPersonalRolesResponse + pattern := "/auth/personal/roles" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceListPersonalRoles)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// PersonalLogout PersonalLogout Personal user logs out +func (c *PersonalServiceHTTPClientImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...http.CallOption) (*PersonalLogoutResponse, error) { + var out PersonalLogoutResponse + pattern := "/auth/personal/logout" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServicePersonalLogout)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token +func (c *PersonalServiceHTTPClientImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...http.CallOption) (*RefreshPersonalTokenResponse, error) { + var out RefreshPersonalTokenResponse + pattern := "/auth/personal/token/refresh" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceRefreshPersonalToken)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...http.CallOption) (*UpdatePersonalPasswordResponse, error) { + var out UpdatePersonalPasswordResponse + pattern := "/auth/personal/password" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalPassword)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdatePersonalProfile UpdatePersonalProfile Update the personal user information +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...http.CallOption) (*UpdatePersonalProfileResponse, error) { + var out UpdatePersonalProfileResponse + pattern := "/auth/personal/profile" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdatePersonalSetting UpdatePersonalSetting User settings are saved +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...http.CallOption) (*UpdatePersonalSettingResponse, error) { + var out UpdatePersonalSettingResponse + pattern := "/auth/personal/setting" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalSetting)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/datastore/datastore.pb.go b/api/v1/services/datastore/datastore.pb.go new file mode 100644 index 00000000..f8e0be72 --- /dev/null +++ b/api/v1/services/datastore/datastore.pb.go @@ -0,0 +1,750 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: datastore/datastore.proto + +package datastore + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// ListDatastoreRequest is the request for the DatastoreService.ListDatastore method. +type ListDatastoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent data id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // data type + Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListDatastoreRequest) Reset() { + *x = ListDatastoreRequest{} + mi := &file_datastore_datastore_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListDatastoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDatastoreRequest) ProtoMessage() {} + +func (x *ListDatastoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[0] + 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 ListDatastoreRequest.ProtoReflect.Descriptor instead. +func (*ListDatastoreRequest) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{0} +} + +func (x *ListDatastoreRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListDatastoreRequest) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListDatastoreRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListDatastoreRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListDatastoreRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListDatastoreRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListDatastoreRequest) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +// ListDatastoreResponse is the response for the DatastoreService.ListDatastore method. +type ListDatastoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` + // The paging datastore + Data []*types.DataObject `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the current data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListDatastoreResponse) Reset() { + *x = ListDatastoreResponse{} + mi := &file_datastore_datastore_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListDatastoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDatastoreResponse) ProtoMessage() {} + +func (x *ListDatastoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[1] + 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 ListDatastoreResponse.ProtoReflect.Descriptor instead. +func (*ListDatastoreResponse) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{1} +} + +func (x *ListDatastoreResponse) GetTotalSize() int32 { + if x != nil { + return x.TotalSize + } + return 0 +} + +func (x *ListDatastoreResponse) GetData() []*types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +func (x *ListDatastoreResponse) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListDatastoreResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListDatastoreResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListDatastoreResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +// GetDatastoreRequest is the request for the DatastoreService.GetDatastore method. +type GetDatastoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the data requested, for example: + // "shelves/shelf1/datastore/data2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDatastoreRequest) Reset() { + *x = GetDatastoreRequest{} + mi := &file_datastore_datastore_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDatastoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDatastoreRequest) ProtoMessage() {} + +func (x *GetDatastoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[2] + 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 GetDatastoreRequest.ProtoReflect.Descriptor instead. +func (*GetDatastoreRequest) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{2} +} + +func (x *GetDatastoreRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// GetDatastoreResponse is the response for the DatastoreService.GetDatastore method. +type GetDatastoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field id should match the Noun in the method id. + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDatastoreResponse) Reset() { + *x = GetDatastoreResponse{} + mi := &file_datastore_datastore_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDatastoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDatastoreResponse) ProtoMessage() {} + +func (x *GetDatastoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[3] + 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 GetDatastoreResponse.ProtoReflect.Descriptor instead. +func (*GetDatastoreResponse) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{3} +} + +func (x *GetDatastoreResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// CreateDatastoreRequest is the request for the DatastoreService.CreateDatastore method. +type CreateDatastoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent data id where the data is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The data id to use for this data. + DataId string `protobuf:"bytes,2,opt,name=data_id,proto3" json:"data_id,omitempty"` + // The data object to create. + Data *types.DataObject `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateDatastoreRequest) Reset() { + *x = CreateDatastoreRequest{} + mi := &file_datastore_datastore_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateDatastoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateDatastoreRequest) ProtoMessage() {} + +func (x *CreateDatastoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[4] + 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 CreateDatastoreRequest.ProtoReflect.Descriptor instead. +func (*CreateDatastoreRequest) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateDatastoreRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateDatastoreRequest) GetDataId() string { + if x != nil { + return x.DataId + } + return "" +} + +func (x *CreateDatastoreRequest) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// CreateDatastoreResponse is the response for the DatastoreService.CreateDatastore method. +type CreateDatastoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateDatastoreResponse) Reset() { + *x = CreateDatastoreResponse{} + mi := &file_datastore_datastore_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateDatastoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateDatastoreResponse) ProtoMessage() {} + +func (x *CreateDatastoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[5] + 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 CreateDatastoreResponse.ProtoReflect.Descriptor instead. +func (*CreateDatastoreResponse) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateDatastoreResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// UpdateDatastoreRequest is the request for the DatastoreService.UpdateDatastore method. +type UpdateDatastoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The id of the data object to update. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The data object which replaces the data on the server. + Data *types.DataObject `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateDatastoreRequest) Reset() { + *x = UpdateDatastoreRequest{} + mi := &file_datastore_datastore_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateDatastoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateDatastoreRequest) ProtoMessage() {} + +func (x *UpdateDatastoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_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 UpdateDatastoreRequest.ProtoReflect.Descriptor instead. +func (*UpdateDatastoreRequest) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateDatastoreRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateDatastoreRequest) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// UpdateDatastoreResponse is the response for the DatastoreService.UpdateDatastore method. +type UpdateDatastoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateDatastoreResponse) Reset() { + *x = UpdateDatastoreResponse{} + mi := &file_datastore_datastore_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateDatastoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateDatastoreResponse) ProtoMessage() {} + +func (x *UpdateDatastoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateDatastoreResponse.ProtoReflect.Descriptor instead. +func (*UpdateDatastoreResponse) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateDatastoreResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// DeleteDatastoreRequest is the request for the DatastoreService.DeleteDatastore method. +type DeleteDatastoreRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The data id of the data to be deleted, for example: + // "shelves/shelf1/datastore/data2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteDatastoreRequest) Reset() { + *x = DeleteDatastoreRequest{} + mi := &file_datastore_datastore_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteDatastoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteDatastoreRequest) ProtoMessage() {} + +func (x *DeleteDatastoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[8] + 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 DeleteDatastoreRequest.ProtoReflect.Descriptor instead. +func (*DeleteDatastoreRequest) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteDatastoreRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// DeleteDatastoreResponse is the response for the DatastoreService.DeleteDatastore method. +type DeleteDatastoreResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // or Datastore data = 1; or google.protobuf.Empty empty = 1; + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteDatastoreResponse) Reset() { + *x = DeleteDatastoreResponse{} + mi := &file_datastore_datastore_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteDatastoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteDatastoreResponse) ProtoMessage() {} + +func (x *DeleteDatastoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_datastore_proto_msgTypes[9] + 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 DeleteDatastoreResponse.ProtoReflect.Descriptor instead. +func (*DeleteDatastoreResponse) Descriptor() ([]byte, []int) { + return file_datastore_datastore_proto_rawDescGZIP(), []int{9} +} + +func (x *DeleteDatastoreResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_datastore_datastore_proto protoreflect.FileDescriptor + +const file_datastore_datastore_proto_rawDesc = "" + + "\n" + + "\x19datastore/datastore.proto\x12\x19api.v1.services.datastore\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15types/datastore.proto\x1a\x17validate/validate.proto\"\xd0\x01\n" + + "\x14ListDatastoreRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x12\n" + + "\x04type\x18\a \x01(\tR\x04type\"\x8b\x02\n" + + "\x15ListDatastoreResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x125\n" + + "\x04data\x18\x02 \x03(\v2!.api.v1.services.types.DataObjectR\x04data\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"%\n" + + "\x13GetDatastoreRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"M\n" + + "\x14GetDatastoreResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"\x81\x01\n" + + "\x16CreateDatastoreRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x18\n" + + "\adata_id\x18\x02 \x01(\tR\adata_id\x125\n" + + "\x04data\x18\x03 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"P\n" + + "\x17CreateDatastoreResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"_\n" + + "\x16UpdateDatastoreRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x125\n" + + "\x04data\x18\x02 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"P\n" + + "\x17UpdateDatastoreResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"(\n" + + "\x16DeleteDatastoreRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"G\n" + + "\x17DeleteDatastoreResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xee\x05\n" + + "\x10DatastoreService\x12\x86\x01\n" + + "\rListDatastore\x12/.api.v1.services.datastore.ListDatastoreRequest\x1a0.api.v1.services.datastore.ListDatastoreResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + + "/datastore\x12\x88\x01\n" + + "\fGetDatastore\x12..api.v1.services.datastore.GetDatastoreRequest\x1a/.api.v1.services.datastore.GetDatastoreResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/datastore/{id}\x12\x92\x01\n" + + "\x0fCreateDatastore\x121.api.v1.services.datastore.CreateDatastoreRequest\x1a2.api.v1.services.datastore.CreateDatastoreResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04data\"\n" + + "/datastore\x12\x9c\x01\n" + + "\x0fUpdateDatastore\x121.api.v1.services.datastore.UpdateDatastoreRequest\x1a2.api.v1.services.datastore.UpdateDatastoreResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04data\x1a\x14/datastore/{data.id}\x12\x91\x01\n" + + "\x0fDeleteDatastore\x121.api.v1.services.datastore.DeleteDatastoreRequest\x1a2.api.v1.services.datastore.DeleteDatastoreResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/datastore/{id}B\xf8\x01\n" + + "\x1dcom.api.v1.services.datastoreB\x0eDatastoreProtoP\x01Z?origadmin/application/admin/api/v1/services/datastore;datastore\xa2\x02\x04AVSD\xaa\x02\x19Api.V1.Services.Datastore\xca\x02\x19Api\\V1\\Services\\Datastore\xe2\x02%Api\\V1\\Services\\Datastore\\GPBMetadata\xea\x02\x1cApi::V1::Services::Datastoreb\x06proto3" + +var ( + file_datastore_datastore_proto_rawDescOnce sync.Once + file_datastore_datastore_proto_rawDescData []byte +) + +func file_datastore_datastore_proto_rawDescGZIP() []byte { + file_datastore_datastore_proto_rawDescOnce.Do(func() { + file_datastore_datastore_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_datastore_datastore_proto_rawDesc), len(file_datastore_datastore_proto_rawDesc))) + }) + return file_datastore_datastore_proto_rawDescData +} + +var file_datastore_datastore_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_datastore_datastore_proto_goTypes = []any{ + (*ListDatastoreRequest)(nil), // 0: api.v1.services.datastore.ListDatastoreRequest + (*ListDatastoreResponse)(nil), // 1: api.v1.services.datastore.ListDatastoreResponse + (*GetDatastoreRequest)(nil), // 2: api.v1.services.datastore.GetDatastoreRequest + (*GetDatastoreResponse)(nil), // 3: api.v1.services.datastore.GetDatastoreResponse + (*CreateDatastoreRequest)(nil), // 4: api.v1.services.datastore.CreateDatastoreRequest + (*CreateDatastoreResponse)(nil), // 5: api.v1.services.datastore.CreateDatastoreResponse + (*UpdateDatastoreRequest)(nil), // 6: api.v1.services.datastore.UpdateDatastoreRequest + (*UpdateDatastoreResponse)(nil), // 7: api.v1.services.datastore.UpdateDatastoreResponse + (*DeleteDatastoreRequest)(nil), // 8: api.v1.services.datastore.DeleteDatastoreRequest + (*DeleteDatastoreResponse)(nil), // 9: api.v1.services.datastore.DeleteDatastoreResponse + (*types.DataObject)(nil), // 10: api.v1.services.types.DataObject + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_datastore_datastore_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.datastore.ListDatastoreResponse.data:type_name -> api.v1.services.types.DataObject + 11, // 1: api.v1.services.datastore.ListDatastoreResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.datastore.GetDatastoreResponse.data:type_name -> api.v1.services.types.DataObject + 10, // 3: api.v1.services.datastore.CreateDatastoreRequest.data:type_name -> api.v1.services.types.DataObject + 10, // 4: api.v1.services.datastore.CreateDatastoreResponse.data:type_name -> api.v1.services.types.DataObject + 10, // 5: api.v1.services.datastore.UpdateDatastoreRequest.data:type_name -> api.v1.services.types.DataObject + 10, // 6: api.v1.services.datastore.UpdateDatastoreResponse.data:type_name -> api.v1.services.types.DataObject + 12, // 7: api.v1.services.datastore.DeleteDatastoreResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.datastore.DatastoreService.ListDatastore:input_type -> api.v1.services.datastore.ListDatastoreRequest + 2, // 9: api.v1.services.datastore.DatastoreService.GetDatastore:input_type -> api.v1.services.datastore.GetDatastoreRequest + 4, // 10: api.v1.services.datastore.DatastoreService.CreateDatastore:input_type -> api.v1.services.datastore.CreateDatastoreRequest + 6, // 11: api.v1.services.datastore.DatastoreService.UpdateDatastore:input_type -> api.v1.services.datastore.UpdateDatastoreRequest + 8, // 12: api.v1.services.datastore.DatastoreService.DeleteDatastore:input_type -> api.v1.services.datastore.DeleteDatastoreRequest + 1, // 13: api.v1.services.datastore.DatastoreService.ListDatastore:output_type -> api.v1.services.datastore.ListDatastoreResponse + 3, // 14: api.v1.services.datastore.DatastoreService.GetDatastore:output_type -> api.v1.services.datastore.GetDatastoreResponse + 5, // 15: api.v1.services.datastore.DatastoreService.CreateDatastore:output_type -> api.v1.services.datastore.CreateDatastoreResponse + 7, // 16: api.v1.services.datastore.DatastoreService.UpdateDatastore:output_type -> api.v1.services.datastore.UpdateDatastoreResponse + 9, // 17: api.v1.services.datastore.DatastoreService.DeleteDatastore:output_type -> api.v1.services.datastore.DeleteDatastoreResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_datastore_datastore_proto_init() } +func file_datastore_datastore_proto_init() { + if File_datastore_datastore_proto != nil { + return + } + file_datastore_datastore_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_datastore_datastore_proto_rawDesc), len(file_datastore_datastore_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_datastore_datastore_proto_goTypes, + DependencyIndexes: file_datastore_datastore_proto_depIdxs, + MessageInfos: file_datastore_datastore_proto_msgTypes, + }.Build() + File_datastore_datastore_proto = out.File + file_datastore_datastore_proto_goTypes = nil + file_datastore_datastore_proto_depIdxs = nil +} diff --git a/api/v1/services/datastore/datastore.pb.gw.go b/api/v1/services/datastore/datastore.pb.gw.go new file mode 100644 index 00000000..bcf43768 --- /dev/null +++ b/api/v1/services/datastore/datastore.pb.gw.go @@ -0,0 +1,487 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: datastore/datastore.proto + +/* +Package datastore is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package datastore + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_DatastoreService_ListDatastore_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_DatastoreService_ListDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListDatastoreRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_ListDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DatastoreService_ListDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListDatastoreRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_ListDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListDatastore(ctx, &protoReq) + return msg, metadata, err +} + +func request_DatastoreService_GetDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DatastoreService_GetDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetDatastore(ctx, &protoReq) + return msg, metadata, err +} + +var filter_DatastoreService_CreateDatastore_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_DatastoreService_CreateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateDatastoreRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_CreateDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DatastoreService_CreateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateDatastoreRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_CreateDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateDatastore(ctx, &protoReq) + return msg, metadata, err +} + +var filter_DatastoreService_UpdateDatastore_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_DatastoreService_UpdateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["data.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_UpdateDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DatastoreService_UpdateDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["data.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DatastoreService_UpdateDatastore_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateDatastore(ctx, &protoReq) + return msg, metadata, err +} + +func request_DatastoreService_DeleteDatastore_0(ctx context.Context, marshaler runtime.Marshaler, client DatastoreServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteDatastore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DatastoreService_DeleteDatastore_0(ctx context.Context, marshaler runtime.Marshaler, server DatastoreServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteDatastoreRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteDatastore(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterDatastoreServiceHandlerServer registers the http handlers for service DatastoreService to "mux". +// UnaryRPC :call DatastoreServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterDatastoreServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterDatastoreServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DatastoreServiceServer) error { + mux.Handle(http.MethodGet, pattern_DatastoreService_ListDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/ListDatastore", runtime.WithHTTPPathPattern("/datastore")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DatastoreService_ListDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_ListDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_DatastoreService_GetDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/GetDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DatastoreService_GetDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_GetDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_DatastoreService_CreateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/CreateDatastore", runtime.WithHTTPPathPattern("/datastore")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DatastoreService_CreateDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_CreateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_DatastoreService_UpdateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/UpdateDatastore", runtime.WithHTTPPathPattern("/datastore/{data.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DatastoreService_UpdateDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_UpdateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_DatastoreService_DeleteDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/DeleteDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DatastoreService_DeleteDatastore_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_DeleteDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterDatastoreServiceHandlerFromEndpoint is same as RegisterDatastoreServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterDatastoreServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterDatastoreServiceHandler(ctx, mux, conn) +} + +// RegisterDatastoreServiceHandler registers the http handlers for service DatastoreService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterDatastoreServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterDatastoreServiceHandlerClient(ctx, mux, NewDatastoreServiceClient(conn)) +} + +// RegisterDatastoreServiceHandlerClient registers the http handlers for service DatastoreService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DatastoreServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DatastoreServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "DatastoreServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterDatastoreServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DatastoreServiceClient) error { + mux.Handle(http.MethodGet, pattern_DatastoreService_ListDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/ListDatastore", runtime.WithHTTPPathPattern("/datastore")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DatastoreService_ListDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_ListDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_DatastoreService_GetDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/GetDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DatastoreService_GetDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_GetDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_DatastoreService_CreateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/CreateDatastore", runtime.WithHTTPPathPattern("/datastore")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DatastoreService_CreateDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_CreateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_DatastoreService_UpdateDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/UpdateDatastore", runtime.WithHTTPPathPattern("/datastore/{data.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DatastoreService_UpdateDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_UpdateDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_DatastoreService_DeleteDatastore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.DatastoreService/DeleteDatastore", runtime.WithHTTPPathPattern("/datastore/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DatastoreService_DeleteDatastore_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DatastoreService_DeleteDatastore_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_DatastoreService_ListDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"datastore"}, "")) + pattern_DatastoreService_GetDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"datastore", "id"}, "")) + pattern_DatastoreService_CreateDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"datastore"}, "")) + pattern_DatastoreService_UpdateDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"datastore", "data.id"}, "")) + pattern_DatastoreService_DeleteDatastore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"datastore", "id"}, "")) +) + +var ( + forward_DatastoreService_ListDatastore_0 = runtime.ForwardResponseMessage + forward_DatastoreService_GetDatastore_0 = runtime.ForwardResponseMessage + forward_DatastoreService_CreateDatastore_0 = runtime.ForwardResponseMessage + forward_DatastoreService_UpdateDatastore_0 = runtime.ForwardResponseMessage + forward_DatastoreService_DeleteDatastore_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/datastore/datastore.pb.validate.go b/api/v1/services/datastore/datastore.pb.validate.go new file mode 100644 index 00000000..330c520f --- /dev/null +++ b/api/v1/services/datastore/datastore.pb.validate.go @@ -0,0 +1,1329 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: datastore/datastore.proto + +package datastore + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListDatastoreRequest 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 *ListDatastoreRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListDatastoreRequest 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 +// ListDatastoreRequestMultiError, or nil if none found. +func (m *ListDatastoreRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListDatastoreRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Type + + if len(errors) > 0 { + return ListDatastoreRequestMultiError(errors) + } + + return nil +} + +// ListDatastoreRequestMultiError is an error wrapping multiple validation +// errors returned by ListDatastoreRequest.ValidateAll() if the designated +// constraints aren't met. +type ListDatastoreRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListDatastoreRequestMultiError) 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 ListDatastoreRequestMultiError) AllErrors() []error { return m } + +// ListDatastoreRequestValidationError is the validation error returned by +// ListDatastoreRequest.Validate if the designated constraints aren't met. +type ListDatastoreRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListDatastoreRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListDatastoreRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListDatastoreRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListDatastoreRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListDatastoreRequestValidationError) ErrorName() string { + return "ListDatastoreRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListDatastoreRequestValidationError) 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 %sListDatastoreRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListDatastoreRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListDatastoreRequestValidationError{} + +// Validate checks the field values on ListDatastoreResponse 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 *ListDatastoreResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListDatastoreResponse 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 +// ListDatastoreResponseMultiError, or nil if none found. +func (m *ListDatastoreResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListDatastoreResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TotalSize + + for idx, item := range m.GetData() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListDatastoreResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListDatastoreResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListDatastoreResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListDatastoreResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListDatastoreResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListDatastoreResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListDatastoreResponseMultiError(errors) + } + + return nil +} + +// ListDatastoreResponseMultiError is an error wrapping multiple validation +// errors returned by ListDatastoreResponse.ValidateAll() if the designated +// constraints aren't met. +type ListDatastoreResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListDatastoreResponseMultiError) 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 ListDatastoreResponseMultiError) AllErrors() []error { return m } + +// ListDatastoreResponseValidationError is the validation error returned by +// ListDatastoreResponse.Validate if the designated constraints aren't met. +type ListDatastoreResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListDatastoreResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListDatastoreResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListDatastoreResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListDatastoreResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListDatastoreResponseValidationError) ErrorName() string { + return "ListDatastoreResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListDatastoreResponseValidationError) 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 %sListDatastoreResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListDatastoreResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListDatastoreResponseValidationError{} + +// Validate checks the field values on GetDatastoreRequest 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 *GetDatastoreRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDatastoreRequest 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 +// GetDatastoreRequestMultiError, or nil if none found. +func (m *GetDatastoreRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDatastoreRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetDatastoreRequestMultiError(errors) + } + + return nil +} + +// GetDatastoreRequestMultiError is an error wrapping multiple validation +// errors returned by GetDatastoreRequest.ValidateAll() if the designated +// constraints aren't met. +type GetDatastoreRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDatastoreRequestMultiError) 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 GetDatastoreRequestMultiError) AllErrors() []error { return m } + +// GetDatastoreRequestValidationError is the validation error returned by +// GetDatastoreRequest.Validate if the designated constraints aren't met. +type GetDatastoreRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDatastoreRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDatastoreRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDatastoreRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDatastoreRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDatastoreRequestValidationError) ErrorName() string { + return "GetDatastoreRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDatastoreRequestValidationError) 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 %sGetDatastoreRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDatastoreRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDatastoreRequestValidationError{} + +// Validate checks the field values on GetDatastoreResponse 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 *GetDatastoreResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDatastoreResponse 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 +// GetDatastoreResponseMultiError, or nil if none found. +func (m *GetDatastoreResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDatastoreResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetDatastoreResponseMultiError(errors) + } + + return nil +} + +// GetDatastoreResponseMultiError is an error wrapping multiple validation +// errors returned by GetDatastoreResponse.ValidateAll() if the designated +// constraints aren't met. +type GetDatastoreResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDatastoreResponseMultiError) 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 GetDatastoreResponseMultiError) AllErrors() []error { return m } + +// GetDatastoreResponseValidationError is the validation error returned by +// GetDatastoreResponse.Validate if the designated constraints aren't met. +type GetDatastoreResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDatastoreResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDatastoreResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDatastoreResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDatastoreResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDatastoreResponseValidationError) ErrorName() string { + return "GetDatastoreResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDatastoreResponseValidationError) 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 %sGetDatastoreResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDatastoreResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDatastoreResponseValidationError{} + +// Validate checks the field values on CreateDatastoreRequest 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 *CreateDatastoreRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateDatastoreRequest 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 +// CreateDatastoreRequestMultiError, or nil if none found. +func (m *CreateDatastoreRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateDatastoreRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for DataId + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateDatastoreRequestMultiError(errors) + } + + return nil +} + +// CreateDatastoreRequestMultiError is an error wrapping multiple validation +// errors returned by CreateDatastoreRequest.ValidateAll() if the designated +// constraints aren't met. +type CreateDatastoreRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateDatastoreRequestMultiError) 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 CreateDatastoreRequestMultiError) AllErrors() []error { return m } + +// CreateDatastoreRequestValidationError is the validation error returned by +// CreateDatastoreRequest.Validate if the designated constraints aren't met. +type CreateDatastoreRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateDatastoreRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateDatastoreRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateDatastoreRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateDatastoreRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateDatastoreRequestValidationError) ErrorName() string { + return "CreateDatastoreRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateDatastoreRequestValidationError) 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 %sCreateDatastoreRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateDatastoreRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateDatastoreRequestValidationError{} + +// Validate checks the field values on CreateDatastoreResponse 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 *CreateDatastoreResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateDatastoreResponse 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 +// CreateDatastoreResponseMultiError, or nil if none found. +func (m *CreateDatastoreResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateDatastoreResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateDatastoreResponseMultiError(errors) + } + + return nil +} + +// CreateDatastoreResponseMultiError is an error wrapping multiple validation +// errors returned by CreateDatastoreResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateDatastoreResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateDatastoreResponseMultiError) 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 CreateDatastoreResponseMultiError) AllErrors() []error { return m } + +// CreateDatastoreResponseValidationError is the validation error returned by +// CreateDatastoreResponse.Validate if the designated constraints aren't met. +type CreateDatastoreResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateDatastoreResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateDatastoreResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateDatastoreResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateDatastoreResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateDatastoreResponseValidationError) ErrorName() string { + return "CreateDatastoreResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateDatastoreResponseValidationError) 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 %sCreateDatastoreResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateDatastoreResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateDatastoreResponseValidationError{} + +// Validate checks the field values on UpdateDatastoreRequest 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 *UpdateDatastoreRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateDatastoreRequest 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 +// UpdateDatastoreRequestMultiError, or nil if none found. +func (m *UpdateDatastoreRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateDatastoreRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateDatastoreRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateDatastoreRequestMultiError(errors) + } + + return nil +} + +// UpdateDatastoreRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateDatastoreRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateDatastoreRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateDatastoreRequestMultiError) 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 UpdateDatastoreRequestMultiError) AllErrors() []error { return m } + +// UpdateDatastoreRequestValidationError is the validation error returned by +// UpdateDatastoreRequest.Validate if the designated constraints aren't met. +type UpdateDatastoreRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateDatastoreRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateDatastoreRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateDatastoreRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateDatastoreRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateDatastoreRequestValidationError) ErrorName() string { + return "UpdateDatastoreRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateDatastoreRequestValidationError) 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 %sUpdateDatastoreRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateDatastoreRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateDatastoreRequestValidationError{} + +// Validate checks the field values on UpdateDatastoreResponse 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 *UpdateDatastoreResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateDatastoreResponse 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 +// UpdateDatastoreResponseMultiError, or nil if none found. +func (m *UpdateDatastoreResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateDatastoreResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateDatastoreResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateDatastoreResponseMultiError(errors) + } + + return nil +} + +// UpdateDatastoreResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateDatastoreResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateDatastoreResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateDatastoreResponseMultiError) 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 UpdateDatastoreResponseMultiError) AllErrors() []error { return m } + +// UpdateDatastoreResponseValidationError is the validation error returned by +// UpdateDatastoreResponse.Validate if the designated constraints aren't met. +type UpdateDatastoreResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateDatastoreResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateDatastoreResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateDatastoreResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateDatastoreResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateDatastoreResponseValidationError) ErrorName() string { + return "UpdateDatastoreResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateDatastoreResponseValidationError) 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 %sUpdateDatastoreResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateDatastoreResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateDatastoreResponseValidationError{} + +// Validate checks the field values on DeleteDatastoreRequest 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 *DeleteDatastoreRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteDatastoreRequest 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 +// DeleteDatastoreRequestMultiError, or nil if none found. +func (m *DeleteDatastoreRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteDatastoreRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeleteDatastoreRequestMultiError(errors) + } + + return nil +} + +// DeleteDatastoreRequestMultiError is an error wrapping multiple validation +// errors returned by DeleteDatastoreRequest.ValidateAll() if the designated +// constraints aren't met. +type DeleteDatastoreRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteDatastoreRequestMultiError) 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 DeleteDatastoreRequestMultiError) AllErrors() []error { return m } + +// DeleteDatastoreRequestValidationError is the validation error returned by +// DeleteDatastoreRequest.Validate if the designated constraints aren't met. +type DeleteDatastoreRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteDatastoreRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteDatastoreRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteDatastoreRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteDatastoreRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteDatastoreRequestValidationError) ErrorName() string { + return "DeleteDatastoreRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteDatastoreRequestValidationError) 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 %sDeleteDatastoreRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteDatastoreRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteDatastoreRequestValidationError{} + +// Validate checks the field values on DeleteDatastoreResponse 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 *DeleteDatastoreResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteDatastoreResponse 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 +// DeleteDatastoreResponseMultiError, or nil if none found. +func (m *DeleteDatastoreResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteDatastoreResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteDatastoreResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteDatastoreResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteDatastoreResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteDatastoreResponseMultiError(errors) + } + + return nil +} + +// DeleteDatastoreResponseMultiError is an error wrapping multiple validation +// errors returned by DeleteDatastoreResponse.ValidateAll() if the designated +// constraints aren't met. +type DeleteDatastoreResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteDatastoreResponseMultiError) 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 DeleteDatastoreResponseMultiError) AllErrors() []error { return m } + +// DeleteDatastoreResponseValidationError is the validation error returned by +// DeleteDatastoreResponse.Validate if the designated constraints aren't met. +type DeleteDatastoreResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteDatastoreResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteDatastoreResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteDatastoreResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteDatastoreResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteDatastoreResponseValidationError) ErrorName() string { + return "DeleteDatastoreResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteDatastoreResponseValidationError) 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 %sDeleteDatastoreResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteDatastoreResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteDatastoreResponseValidationError{} diff --git a/api/v1/services/datastore/datastore_bridge.pb.go b/api/v1/services/datastore/datastore_bridge.pb.go new file mode 100644 index 00000000..34b94072 --- /dev/null +++ b/api/v1/services/datastore/datastore_bridge.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: datastore/datastore.proto + +package datastore + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const DatastoreServiceCreateDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/CreateDatastore" +const DatastoreServiceDeleteDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" +const DatastoreServiceGetDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/GetDatastore" +const DatastoreServiceListDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/ListDatastore" +const DatastoreServiceUpdateDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/UpdateDatastore" + +type DatastoreServiceBridgeServer interface { + CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) + DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) + GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) + ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) + UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) +} + +type DatastoreServiceHooker interface { + DatastoreServiceCreateDatastoreHooker + DatastoreServiceDeleteDatastoreHooker + DatastoreServiceGetDatastoreHooker + DatastoreServiceListDatastoreHooker + DatastoreServiceUpdateDatastoreHooker +} + +type DatastoreServiceHookedBridger interface { + DatastoreServiceHooker + DatastoreServiceBridgeServer +} +type DatastoreServiceCreateDatastoreHooker interface { + PrepareCreateDatastore(http.Context, *CreateDatastoreRequest) (context.Context, error) + CompleteCreateDatastore(http.Context, *CreateDatastoreRequest, *CreateDatastoreResponse) error +} +type DatastoreServiceDeleteDatastoreHooker interface { + PrepareDeleteDatastore(http.Context, *DeleteDatastoreRequest) (context.Context, error) + CompleteDeleteDatastore(http.Context, *DeleteDatastoreRequest, *DeleteDatastoreResponse) error +} +type DatastoreServiceGetDatastoreHooker interface { + PrepareGetDatastore(http.Context, *GetDatastoreRequest) (context.Context, error) + CompleteGetDatastore(http.Context, *GetDatastoreRequest, *GetDatastoreResponse) error +} +type DatastoreServiceListDatastoreHooker interface { + PrepareListDatastore(http.Context, *ListDatastoreRequest) (context.Context, error) + CompleteListDatastore(http.Context, *ListDatastoreRequest, *ListDatastoreResponse) error +} +type DatastoreServiceUpdateDatastoreHooker interface { + PrepareUpdateDatastore(http.Context, *UpdateDatastoreRequest) (context.Context, error) + CompleteUpdateDatastore(http.Context, *UpdateDatastoreRequest, *UpdateDatastoreResponse) error +} + +func RegisterDatastoreServiceBridgeServer(s *http.Server, srv DatastoreServiceHookedBridger) { + r := s.Route("/") + r.GET("/datastore", _DatastoreService_ListDatastore0_Bridge_Handler(srv)) + r.GET("/datastore/:id", _DatastoreService_GetDatastore0_Bridge_Handler(srv)) + r.POST("/datastore", _DatastoreService_CreateDatastore0_Bridge_Handler(srv)) + r.PUT("/datastore/:data.id", _DatastoreService_UpdateDatastore0_Bridge_Handler(srv)) + r.DELETE("/datastore/:id", _DatastoreService_DeleteDatastore0_Bridge_Handler(srv)) +} + +func _DatastoreService_ListDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceListDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListDatastore(ctx, req.(*ListDatastoreRequest)) + }) + + newctx, err := srv.PrepareListDatastore(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListDatastore(ctx, &in, out.(*ListDatastoreResponse)) + } +} + +func _DatastoreService_GetDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceGetDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetDatastore(ctx, req.(*GetDatastoreRequest)) + }) + + newctx, err := srv.PrepareGetDatastore(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetDatastore(ctx, &in, out.(*GetDatastoreResponse)) + } +} + +func _DatastoreService_CreateDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateDatastoreRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceCreateDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateDatastore(ctx, req.(*CreateDatastoreRequest)) + }) + + newctx, err := srv.PrepareCreateDatastore(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateDatastore(ctx, &in, out.(*CreateDatastoreResponse)) + } +} + +func _DatastoreService_UpdateDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateDatastoreRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceUpdateDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateDatastore(ctx, req.(*UpdateDatastoreRequest)) + }) + + newctx, err := srv.PrepareUpdateDatastore(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateDatastore(ctx, &in, out.(*UpdateDatastoreResponse)) + } +} + +func _DatastoreService_DeleteDatastore0_Bridge_Handler(srv DatastoreServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceDeleteDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteDatastore(ctx, req.(*DeleteDatastoreRequest)) + }) + + newctx, err := srv.PrepareDeleteDatastore(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteDatastore(ctx, &in, out.(*DeleteDatastoreResponse)) + } +} + +// UnimplementedDatastoreServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedDatastoreServiceHooked struct{} + +func (UnimplementedDatastoreServiceHooked) PrepareCreateDatastore(ctx http.Context, in *CreateDatastoreRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDatastoreServiceHooked) CompleteCreateDatastore(ctx http.Context, in *CreateDatastoreRequest, out *CreateDatastoreResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDatastoreServiceHooked) PrepareDeleteDatastore(ctx http.Context, in *DeleteDatastoreRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDatastoreServiceHooked) CompleteDeleteDatastore(ctx http.Context, in *DeleteDatastoreRequest, out *DeleteDatastoreResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDatastoreServiceHooked) PrepareGetDatastore(ctx http.Context, in *GetDatastoreRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDatastoreServiceHooked) CompleteGetDatastore(ctx http.Context, in *GetDatastoreRequest, out *GetDatastoreResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDatastoreServiceHooked) PrepareListDatastore(ctx http.Context, in *ListDatastoreRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDatastoreServiceHooked) CompleteListDatastore(ctx http.Context, in *ListDatastoreRequest, out *ListDatastoreResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDatastoreServiceHooked) PrepareUpdateDatastore(ctx http.Context, in *UpdateDatastoreRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDatastoreServiceHooked) CompleteUpdateDatastore(ctx http.Context, in *UpdateDatastoreRequest, out *UpdateDatastoreResponse) error { + return ctx.Result(200, out) +} + +func WithDatastoreServiceHook(h DatastoreServiceHooker) func(DatastoreServiceBridgeServer) DatastoreServiceHookedBridger { + return func(srv DatastoreServiceBridgeServer) DatastoreServiceHookedBridger { + return DatastoreServiceHookedBridge{DatastoreServiceBridgeServer: srv, DatastoreServiceHooker: h} + } +} + +// DatastoreServiceHookedBridge is a bridge between the HTTP and gRPC implementations of DatastoreService. +// It implements the HTTP and gRPC implementations of DatastoreService. +// It forwards requests and responses between the two implementations. +type DatastoreServiceHookedBridge struct { + DatastoreServiceBridgeServer + DatastoreServiceHooker +} + +type DatastoreServiceHTTPBridgeImpl struct { + client DatastoreServiceHTTPClient +} + +func NewDatastoreServiceHTTPBridge(client *http.Client) DatastoreServiceHTTPServer { + return &DatastoreServiceHTTPBridgeImpl{client: NewDatastoreServiceHTTPClient(client)} +} + +func (c *DatastoreServiceHTTPBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTPBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTPBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { + return c.client.GetDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTPBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTPBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { + return c.client.UpdateDatastore(ctx, in) +} + +type DatastoreServiceBridgeImpl struct { + client DatastoreServiceClient +} + +func NewDatastoreServiceBridge(client grpc.ClientConnInterface) DatastoreServiceServer { + return &DatastoreServiceBridgeImpl{client: NewDatastoreServiceClient(client)} +} + +func (c *DatastoreServiceBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) +} + +func (c *DatastoreServiceBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + +func (c *DatastoreServiceBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { + return c.client.GetDatastore(ctx, in) +} + +func (c *DatastoreServiceBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) +} + +func (c *DatastoreServiceBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { + return c.client.UpdateDatastore(ctx, in) +} + +func (c *DatastoreServiceBridgeImpl) mustEmbedUnimplementedDatastoreServiceServer() {} + +type DatastoreServiceGRPC2HTTPBridgeImpl struct { + client DatastoreServiceClient +} + +func NewDatastoreServiceGRPC2HTTP(client grpc.ClientConnInterface) DatastoreServiceHTTPServer { + return &DatastoreServiceGRPC2HTTPBridgeImpl{client: NewDatastoreServiceClient(client)} +} + +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) +} + +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { + return c.client.GetDatastore(ctx, in) +} + +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) +} + +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { + return c.client.UpdateDatastore(ctx, in) +} + +type DatastoreServiceHTTP2GRPCBridgeImpl struct { + client DatastoreServiceHTTPClient +} + +func NewDatastoreServiceHTTP2GRPC(client *http.Client) DatastoreServiceServer { + return &DatastoreServiceHTTP2GRPCBridgeImpl{client: NewDatastoreServiceHTTPClient(client)} +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { + return c.client.GetDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { + return c.client.UpdateDatastore(ctx, in) +} + +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedDatastoreServiceServer() {} diff --git a/api/v1/services/datastore/datastore_grpc.pb.go b/api/v1/services/datastore/datastore_grpc.pb.go new file mode 100644 index 00000000..94daa542 --- /dev/null +++ b/api/v1/services/datastore/datastore_grpc.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: datastore/datastore.proto + +package datastore + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + DatastoreService_ListDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/ListDatastore" + DatastoreService_GetDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/GetDatastore" + DatastoreService_CreateDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/CreateDatastore" + DatastoreService_UpdateDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/UpdateDatastore" + DatastoreService_DeleteDatastore_FullMethodName = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" +) + +// DatastoreServiceClient is the client API for DatastoreService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The data service definition. +type DatastoreServiceClient interface { + ListDatastore(ctx context.Context, in *ListDatastoreRequest, opts ...grpc.CallOption) (*ListDatastoreResponse, error) + GetDatastore(ctx context.Context, in *GetDatastoreRequest, opts ...grpc.CallOption) (*GetDatastoreResponse, error) + CreateDatastore(ctx context.Context, in *CreateDatastoreRequest, opts ...grpc.CallOption) (*CreateDatastoreResponse, error) + UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest, opts ...grpc.CallOption) (*UpdateDatastoreResponse, error) + DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest, opts ...grpc.CallOption) (*DeleteDatastoreResponse, error) +} + +type datastoreServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewDatastoreServiceClient(cc grpc.ClientConnInterface) DatastoreServiceClient { + return &datastoreServiceClient{cc} +} + +func (c *datastoreServiceClient) ListDatastore(ctx context.Context, in *ListDatastoreRequest, opts ...grpc.CallOption) (*ListDatastoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListDatastoreResponse) + err := c.cc.Invoke(ctx, DatastoreService_ListDatastore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *datastoreServiceClient) GetDatastore(ctx context.Context, in *GetDatastoreRequest, opts ...grpc.CallOption) (*GetDatastoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetDatastoreResponse) + err := c.cc.Invoke(ctx, DatastoreService_GetDatastore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *datastoreServiceClient) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest, opts ...grpc.CallOption) (*CreateDatastoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateDatastoreResponse) + err := c.cc.Invoke(ctx, DatastoreService_CreateDatastore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *datastoreServiceClient) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest, opts ...grpc.CallOption) (*UpdateDatastoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateDatastoreResponse) + err := c.cc.Invoke(ctx, DatastoreService_UpdateDatastore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *datastoreServiceClient) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest, opts ...grpc.CallOption) (*DeleteDatastoreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteDatastoreResponse) + err := c.cc.Invoke(ctx, DatastoreService_DeleteDatastore_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DatastoreServiceServer is the server API for DatastoreService service. +// All implementations must embed UnimplementedDatastoreServiceServer +// for forward compatibility. +// +// The data service definition. +type DatastoreServiceServer interface { + ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) + GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) + CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) + UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) + DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) + mustEmbedUnimplementedDatastoreServiceServer() +} + +// UnimplementedDatastoreServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedDatastoreServiceServer struct{} + +func (UnimplementedDatastoreServiceServer) ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListDatastore not implemented") +} +func (UnimplementedDatastoreServiceServer) GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDatastore not implemented") +} +func (UnimplementedDatastoreServiceServer) CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateDatastore not implemented") +} +func (UnimplementedDatastoreServiceServer) UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateDatastore not implemented") +} +func (UnimplementedDatastoreServiceServer) DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteDatastore not implemented") +} +func (UnimplementedDatastoreServiceServer) mustEmbedUnimplementedDatastoreServiceServer() {} +func (UnimplementedDatastoreServiceServer) testEmbeddedByValue() {} + +// UnsafeDatastoreServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to DatastoreServiceServer will +// result in compilation errors. +type UnsafeDatastoreServiceServer interface { + mustEmbedUnimplementedDatastoreServiceServer() +} + +func RegisterDatastoreServiceServer(s grpc.ServiceRegistrar, srv DatastoreServiceServer) { + // If the following call pancis, it indicates UnimplementedDatastoreServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&DatastoreService_ServiceDesc, srv) +} + +func _DatastoreService_ListDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListDatastoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DatastoreServiceServer).ListDatastore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DatastoreService_ListDatastore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DatastoreServiceServer).ListDatastore(ctx, req.(*ListDatastoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DatastoreService_GetDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetDatastoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DatastoreServiceServer).GetDatastore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DatastoreService_GetDatastore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DatastoreServiceServer).GetDatastore(ctx, req.(*GetDatastoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DatastoreService_CreateDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateDatastoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DatastoreServiceServer).CreateDatastore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DatastoreService_CreateDatastore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DatastoreServiceServer).CreateDatastore(ctx, req.(*CreateDatastoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DatastoreService_UpdateDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateDatastoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DatastoreServiceServer).UpdateDatastore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DatastoreService_UpdateDatastore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DatastoreServiceServer).UpdateDatastore(ctx, req.(*UpdateDatastoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DatastoreService_DeleteDatastore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteDatastoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DatastoreServiceServer).DeleteDatastore(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DatastoreService_DeleteDatastore_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DatastoreServiceServer).DeleteDatastore(ctx, req.(*DeleteDatastoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// DatastoreService_ServiceDesc is the grpc.ServiceDesc for DatastoreService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var DatastoreService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.datastore.DatastoreService", + HandlerType: (*DatastoreServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListDatastore", + Handler: _DatastoreService_ListDatastore_Handler, + }, + { + MethodName: "GetDatastore", + Handler: _DatastoreService_GetDatastore_Handler, + }, + { + MethodName: "CreateDatastore", + Handler: _DatastoreService_CreateDatastore_Handler, + }, + { + MethodName: "UpdateDatastore", + Handler: _DatastoreService_UpdateDatastore_Handler, + }, + { + MethodName: "DeleteDatastore", + Handler: _DatastoreService_DeleteDatastore_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "datastore/datastore.proto", +} diff --git a/api/v1/services/datastore/datastore_http.pb.go b/api/v1/services/datastore/datastore_http.pb.go new file mode 100644 index 00000000..955111fa --- /dev/null +++ b/api/v1/services/datastore/datastore_http.pb.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: datastore/datastore.proto + +package datastore + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationDatastoreServiceCreateDatastore = "/api.v1.services.datastore.DatastoreService/CreateDatastore" +const OperationDatastoreServiceDeleteDatastore = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" +const OperationDatastoreServiceGetDatastore = "/api.v1.services.datastore.DatastoreService/GetDatastore" +const OperationDatastoreServiceListDatastore = "/api.v1.services.datastore.DatastoreService/ListDatastore" +const OperationDatastoreServiceUpdateDatastore = "/api.v1.services.datastore.DatastoreService/UpdateDatastore" + +type DatastoreServiceHTTPServer interface { + CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) + DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) + GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) + ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) + UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) +} + +func RegisterDatastoreServiceHTTPServer(s *http.Server, srv DatastoreServiceHTTPServer) { + r := s.Route("/") + r.GET("/datastore", _DatastoreService_ListDatastore0_HTTP_Handler(srv)) + r.GET("/datastore/{id}", _DatastoreService_GetDatastore0_HTTP_Handler(srv)) + r.POST("/datastore", _DatastoreService_CreateDatastore0_HTTP_Handler(srv)) + r.PUT("/datastore/{data.id}", _DatastoreService_UpdateDatastore0_HTTP_Handler(srv)) + r.DELETE("/datastore/{id}", _DatastoreService_DeleteDatastore0_HTTP_Handler(srv)) +} + +func _DatastoreService_ListDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceListDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListDatastore(ctx, req.(*ListDatastoreRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListDatastoreResponse) + return ctx.Result(200, reply) + } +} + +func _DatastoreService_GetDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceGetDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetDatastore(ctx, req.(*GetDatastoreRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetDatastoreResponse) + return ctx.Result(200, reply) + } +} + +func _DatastoreService_CreateDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateDatastoreRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceCreateDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateDatastore(ctx, req.(*CreateDatastoreRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateDatastoreResponse) + return ctx.Result(200, reply) + } +} + +func _DatastoreService_UpdateDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateDatastoreRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceUpdateDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateDatastore(ctx, req.(*UpdateDatastoreRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateDatastoreResponse) + return ctx.Result(200, reply) + } +} + +func _DatastoreService_DeleteDatastore0_HTTP_Handler(srv DatastoreServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteDatastoreRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDatastoreServiceDeleteDatastore) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteDatastore(ctx, req.(*DeleteDatastoreRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeleteDatastoreResponse) + return ctx.Result(200, reply) + } +} + +type DatastoreServiceHTTPClient interface { + CreateDatastore(ctx context.Context, req *CreateDatastoreRequest, opts ...http.CallOption) (rsp *CreateDatastoreResponse, err error) + DeleteDatastore(ctx context.Context, req *DeleteDatastoreRequest, opts ...http.CallOption) (rsp *DeleteDatastoreResponse, err error) + GetDatastore(ctx context.Context, req *GetDatastoreRequest, opts ...http.CallOption) (rsp *GetDatastoreResponse, err error) + ListDatastore(ctx context.Context, req *ListDatastoreRequest, opts ...http.CallOption) (rsp *ListDatastoreResponse, err error) + UpdateDatastore(ctx context.Context, req *UpdateDatastoreRequest, opts ...http.CallOption) (rsp *UpdateDatastoreResponse, err error) +} + +type DatastoreServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewDatastoreServiceHTTPClient(client *http.Client) DatastoreServiceHTTPClient { + return &DatastoreServiceHTTPClientImpl{client} +} + +func (c *DatastoreServiceHTTPClientImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest, opts ...http.CallOption) (*CreateDatastoreResponse, error) { + var out CreateDatastoreResponse + pattern := "/datastore" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationDatastoreServiceCreateDatastore)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DatastoreServiceHTTPClientImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest, opts ...http.CallOption) (*DeleteDatastoreResponse, error) { + var out DeleteDatastoreResponse + pattern := "/datastore/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDatastoreServiceDeleteDatastore)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DatastoreServiceHTTPClientImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest, opts ...http.CallOption) (*GetDatastoreResponse, error) { + var out GetDatastoreResponse + pattern := "/datastore/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDatastoreServiceGetDatastore)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DatastoreServiceHTTPClientImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest, opts ...http.CallOption) (*ListDatastoreResponse, error) { + var out ListDatastoreResponse + pattern := "/datastore" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDatastoreServiceListDatastore)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DatastoreServiceHTTPClientImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest, opts ...http.CallOption) (*UpdateDatastoreResponse, error) { + var out UpdateDatastoreResponse + pattern := "/datastore/{data.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationDatastoreServiceUpdateDatastore)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/datastore/upload.pb.go b/api/v1/services/datastore/upload.pb.go new file mode 100644 index 00000000..227e8804 --- /dev/null +++ b/api/v1/services/datastore/upload.pb.go @@ -0,0 +1,749 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: datastore/upload.proto + +package upload + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// ListUploadRequest is the request for the UploadService.ListUpload method. +type ListUploadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent data id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // data type + Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListUploadRequest) Reset() { + *x = ListUploadRequest{} + mi := &file_datastore_upload_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListUploadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUploadRequest) ProtoMessage() {} + +func (x *ListUploadRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[0] + 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 ListUploadRequest.ProtoReflect.Descriptor instead. +func (*ListUploadRequest) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{0} +} + +func (x *ListUploadRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListUploadRequest) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListUploadRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListUploadRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListUploadRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListUploadRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListUploadRequest) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +// ListUploadResponse is the response for the UploadService.ListUpload method. +type ListUploadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + TotalSize int32 `protobuf:"varint,1,opt,name=total_size,proto3" json:"total_size,omitempty"` + // The paging upload + Data []*types.DataObject `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the current data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListUploadResponse) Reset() { + *x = ListUploadResponse{} + mi := &file_datastore_upload_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUploadResponse) ProtoMessage() {} + +func (x *ListUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[1] + 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 ListUploadResponse.ProtoReflect.Descriptor instead. +func (*ListUploadResponse) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{1} +} + +func (x *ListUploadResponse) GetTotalSize() int32 { + if x != nil { + return x.TotalSize + } + return 0 +} + +func (x *ListUploadResponse) GetData() []*types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +func (x *ListUploadResponse) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListUploadResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListUploadResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListUploadResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +// GetUploadRequest is the request for the UploadService.GetUpload method. +type GetUploadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the data requested, for example: + // "shelves/shelf1/upload/data2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUploadRequest) Reset() { + *x = GetUploadRequest{} + mi := &file_datastore_upload_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUploadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUploadRequest) ProtoMessage() {} + +func (x *GetUploadRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[2] + 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 GetUploadRequest.ProtoReflect.Descriptor instead. +func (*GetUploadRequest) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{2} +} + +func (x *GetUploadRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// GetUploadResponse is the response for the UploadService.GetUpload method. +type GetUploadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field id should match the Noun in the method id. + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUploadResponse) Reset() { + *x = GetUploadResponse{} + mi := &file_datastore_upload_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUploadResponse) ProtoMessage() {} + +func (x *GetUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[3] + 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 GetUploadResponse.ProtoReflect.Descriptor instead. +func (*GetUploadResponse) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{3} +} + +func (x *GetUploadResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// CreateUploadRequest is the request for the UploadService.CreateUpload method. +type CreateUploadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent data id where the data is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The data id to use for this data. + DataId string `protobuf:"bytes,2,opt,name=data_id,proto3" json:"data_id,omitempty"` + // The data object to create. + Data *types.DataObject `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateUploadRequest) Reset() { + *x = CreateUploadRequest{} + mi := &file_datastore_upload_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateUploadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateUploadRequest) ProtoMessage() {} + +func (x *CreateUploadRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[4] + 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 CreateUploadRequest.ProtoReflect.Descriptor instead. +func (*CreateUploadRequest) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateUploadRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateUploadRequest) GetDataId() string { + if x != nil { + return x.DataId + } + return "" +} + +func (x *CreateUploadRequest) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// CreateUploadResponse is the response for the UploadService.CreateUpload method. +type CreateUploadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateUploadResponse) Reset() { + *x = CreateUploadResponse{} + mi := &file_datastore_upload_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateUploadResponse) ProtoMessage() {} + +func (x *CreateUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[5] + 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 CreateUploadResponse.ProtoReflect.Descriptor instead. +func (*CreateUploadResponse) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateUploadResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// UpdateUploadRequest is the request for the UploadService.UpdateUpload method. +type UpdateUploadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The id of the data object to update. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The data object which replaces the data on the server. + Data *types.DataObject `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateUploadRequest) Reset() { + *x = UpdateUploadRequest{} + mi := &file_datastore_upload_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateUploadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUploadRequest) ProtoMessage() {} + +func (x *UpdateUploadRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_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 UpdateUploadRequest.ProtoReflect.Descriptor instead. +func (*UpdateUploadRequest) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateUploadRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateUploadRequest) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// UpdateUploadResponse is the response for the UploadService.UpdateUpload method. +type UpdateUploadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *types.DataObject `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateUploadResponse) Reset() { + *x = UpdateUploadResponse{} + mi := &file_datastore_upload_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUploadResponse) ProtoMessage() {} + +func (x *UpdateUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateUploadResponse.ProtoReflect.Descriptor instead. +func (*UpdateUploadResponse) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateUploadResponse) GetData() *types.DataObject { + if x != nil { + return x.Data + } + return nil +} + +// DeleteUploadRequest is the request for the UploadService.DeleteUpload method. +type DeleteUploadRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The data id of the data to be deleted, for example: + // "shelves/shelf1/upload/data2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteUploadRequest) Reset() { + *x = DeleteUploadRequest{} + mi := &file_datastore_upload_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteUploadRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUploadRequest) ProtoMessage() {} + +func (x *DeleteUploadRequest) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[8] + 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 DeleteUploadRequest.ProtoReflect.Descriptor instead. +func (*DeleteUploadRequest) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteUploadRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// DeleteUploadResponse is the response for the UploadService.DeleteUpload method. +type DeleteUploadResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // or Upload data = 1; or google.protobuf.Empty empty = 1; + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteUploadResponse) Reset() { + *x = DeleteUploadResponse{} + mi := &file_datastore_upload_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteUploadResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUploadResponse) ProtoMessage() {} + +func (x *DeleteUploadResponse) ProtoReflect() protoreflect.Message { + mi := &file_datastore_upload_proto_msgTypes[9] + 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 DeleteUploadResponse.ProtoReflect.Descriptor instead. +func (*DeleteUploadResponse) Descriptor() ([]byte, []int) { + return file_datastore_upload_proto_rawDescGZIP(), []int{9} +} + +func (x *DeleteUploadResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_datastore_upload_proto protoreflect.FileDescriptor + +const file_datastore_upload_proto_rawDesc = "" + + "\n" + + "\x16datastore/upload.proto\x12\x16api.v1.services.upload\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15types/datastore.proto\x1a\x17validate/validate.proto\"\xcd\x01\n" + + "\x11ListUploadRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x12\n" + + "\x04type\x18\a \x01(\tR\x04type\"\x88\x02\n" + + "\x12ListUploadResponse\x12\x1e\n" + + "\n" + + "total_size\x18\x01 \x01(\x05R\n" + + "total_size\x125\n" + + "\x04data\x18\x02 \x03(\v2!.api.v1.services.types.DataObjectR\x04data\x12\x18\n" + + "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"\"\n" + + "\x10GetUploadRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"J\n" + + "\x11GetUploadResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"~\n" + + "\x13CreateUploadRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x18\n" + + "\adata_id\x18\x02 \x01(\tR\adata_id\x125\n" + + "\x04data\x18\x03 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"M\n" + + "\x14CreateUploadResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"\\\n" + + "\x13UpdateUploadRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x125\n" + + "\x04data\x18\x02 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"M\n" + + "\x14UpdateUploadResponse\x125\n" + + "\x04data\x18\x01 \x01(\v2!.api.v1.services.types.DataObjectR\x04data\"%\n" + + "\x13DeleteUploadRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"D\n" + + "\x14DeleteUploadResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x8e\x05\n" + + "\rUploadService\x12t\n" + + "\n" + + "ListUpload\x12).api.v1.services.upload.ListUploadRequest\x1a*.api.v1.services.upload.ListUploadResponse\"\x0f\x82\xd3\xe4\x93\x02\t\x12\a/upload\x12v\n" + + "\tGetUpload\x12(.api.v1.services.upload.GetUploadRequest\x1a).api.v1.services.upload.GetUploadResponse\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/upload/{id}\x12\x80\x01\n" + + "\fCreateUpload\x12+.api.v1.services.upload.CreateUploadRequest\x1a,.api.v1.services.upload.CreateUploadResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/upload\x12\x8a\x01\n" + + "\fUpdateUpload\x12+.api.v1.services.upload.UpdateUploadRequest\x1a,.api.v1.services.upload.UpdateUploadResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x04data\x1a\x11/upload/{data.id}\x12\x7f\n" + + "\fDeleteUpload\x12+.api.v1.services.upload.DeleteUploadRequest\x1a,.api.v1.services.upload.DeleteUploadResponse\"\x14\x82\xd3\xe4\x93\x02\x0e*\f/upload/{id}B\xe0\x01\n" + + "\x1acom.api.v1.services.uploadB\vUploadProtoP\x01Z9origadmin/application/admin/api/v1/services/upload;upload\xa2\x02\x04AVSU\xaa\x02\x16Api.V1.Services.Upload\xca\x02\x16Api\\V1\\Services\\Upload\xe2\x02\"Api\\V1\\Services\\Upload\\GPBMetadata\xea\x02\x19Api::V1::Services::Uploadb\x06proto3" + +var ( + file_datastore_upload_proto_rawDescOnce sync.Once + file_datastore_upload_proto_rawDescData []byte +) + +func file_datastore_upload_proto_rawDescGZIP() []byte { + file_datastore_upload_proto_rawDescOnce.Do(func() { + file_datastore_upload_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_datastore_upload_proto_rawDesc), len(file_datastore_upload_proto_rawDesc))) + }) + return file_datastore_upload_proto_rawDescData +} + +var file_datastore_upload_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_datastore_upload_proto_goTypes = []any{ + (*ListUploadRequest)(nil), // 0: api.v1.services.upload.ListUploadRequest + (*ListUploadResponse)(nil), // 1: api.v1.services.upload.ListUploadResponse + (*GetUploadRequest)(nil), // 2: api.v1.services.upload.GetUploadRequest + (*GetUploadResponse)(nil), // 3: api.v1.services.upload.GetUploadResponse + (*CreateUploadRequest)(nil), // 4: api.v1.services.upload.CreateUploadRequest + (*CreateUploadResponse)(nil), // 5: api.v1.services.upload.CreateUploadResponse + (*UpdateUploadRequest)(nil), // 6: api.v1.services.upload.UpdateUploadRequest + (*UpdateUploadResponse)(nil), // 7: api.v1.services.upload.UpdateUploadResponse + (*DeleteUploadRequest)(nil), // 8: api.v1.services.upload.DeleteUploadRequest + (*DeleteUploadResponse)(nil), // 9: api.v1.services.upload.DeleteUploadResponse + (*types.DataObject)(nil), // 10: api.v1.services.types.DataObject + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_datastore_upload_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.upload.ListUploadResponse.data:type_name -> api.v1.services.types.DataObject + 11, // 1: api.v1.services.upload.ListUploadResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.upload.GetUploadResponse.data:type_name -> api.v1.services.types.DataObject + 10, // 3: api.v1.services.upload.CreateUploadRequest.data:type_name -> api.v1.services.types.DataObject + 10, // 4: api.v1.services.upload.CreateUploadResponse.data:type_name -> api.v1.services.types.DataObject + 10, // 5: api.v1.services.upload.UpdateUploadRequest.data:type_name -> api.v1.services.types.DataObject + 10, // 6: api.v1.services.upload.UpdateUploadResponse.data:type_name -> api.v1.services.types.DataObject + 12, // 7: api.v1.services.upload.DeleteUploadResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.upload.UploadService.ListUpload:input_type -> api.v1.services.upload.ListUploadRequest + 2, // 9: api.v1.services.upload.UploadService.GetUpload:input_type -> api.v1.services.upload.GetUploadRequest + 4, // 10: api.v1.services.upload.UploadService.CreateUpload:input_type -> api.v1.services.upload.CreateUploadRequest + 6, // 11: api.v1.services.upload.UploadService.UpdateUpload:input_type -> api.v1.services.upload.UpdateUploadRequest + 8, // 12: api.v1.services.upload.UploadService.DeleteUpload:input_type -> api.v1.services.upload.DeleteUploadRequest + 1, // 13: api.v1.services.upload.UploadService.ListUpload:output_type -> api.v1.services.upload.ListUploadResponse + 3, // 14: api.v1.services.upload.UploadService.GetUpload:output_type -> api.v1.services.upload.GetUploadResponse + 5, // 15: api.v1.services.upload.UploadService.CreateUpload:output_type -> api.v1.services.upload.CreateUploadResponse + 7, // 16: api.v1.services.upload.UploadService.UpdateUpload:output_type -> api.v1.services.upload.UpdateUploadResponse + 9, // 17: api.v1.services.upload.UploadService.DeleteUpload:output_type -> api.v1.services.upload.DeleteUploadResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_datastore_upload_proto_init() } +func file_datastore_upload_proto_init() { + if File_datastore_upload_proto != nil { + return + } + file_datastore_upload_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_datastore_upload_proto_rawDesc), len(file_datastore_upload_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_datastore_upload_proto_goTypes, + DependencyIndexes: file_datastore_upload_proto_depIdxs, + MessageInfos: file_datastore_upload_proto_msgTypes, + }.Build() + File_datastore_upload_proto = out.File + file_datastore_upload_proto_goTypes = nil + file_datastore_upload_proto_depIdxs = nil +} diff --git a/api/v1/services/datastore/upload.pb.gw.go b/api/v1/services/datastore/upload.pb.gw.go new file mode 100644 index 00000000..0084a218 --- /dev/null +++ b/api/v1/services/datastore/upload.pb.gw.go @@ -0,0 +1,487 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: datastore/upload.proto + +/* +Package upload is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package upload + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_UploadService_ListUpload_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_UploadService_ListUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListUploadRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_ListUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UploadService_ListUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListUploadRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_ListUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListUpload(ctx, &protoReq) + return msg, metadata, err +} + +func request_UploadService_GetUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetUploadRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UploadService_GetUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetUploadRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetUpload(ctx, &protoReq) + return msg, metadata, err +} + +var filter_UploadService_CreateUpload_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_UploadService_CreateUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateUploadRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_CreateUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UploadService_CreateUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateUploadRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_CreateUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateUpload(ctx, &protoReq) + return msg, metadata, err +} + +var filter_UploadService_UpdateUpload_0 = &utilities.DoubleArray{Encoding: map[string]int{"data": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_UploadService_UpdateUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateUploadRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["data.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_UpdateUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UploadService_UpdateUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateUploadRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["data.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "data.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "data.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "data.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UploadService_UpdateUpload_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateUpload(ctx, &protoReq) + return msg, metadata, err +} + +func request_UploadService_DeleteUpload_0(ctx context.Context, marshaler runtime.Marshaler, client UploadServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteUploadRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteUpload(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UploadService_DeleteUpload_0(ctx context.Context, marshaler runtime.Marshaler, server UploadServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteUploadRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteUpload(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterUploadServiceHandlerServer registers the http handlers for service UploadService to "mux". +// UnaryRPC :call UploadServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUploadServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterUploadServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UploadServiceServer) error { + mux.Handle(http.MethodGet, pattern_UploadService_ListUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/ListUpload", runtime.WithHTTPPathPattern("/upload")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UploadService_ListUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_ListUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_UploadService_GetUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/GetUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UploadService_GetUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_GetUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_UploadService_CreateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/CreateUpload", runtime.WithHTTPPathPattern("/upload")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UploadService_CreateUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_CreateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_UploadService_UpdateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/UpdateUpload", runtime.WithHTTPPathPattern("/upload/{data.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UploadService_UpdateUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_UpdateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_UploadService_DeleteUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/DeleteUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UploadService_DeleteUpload_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_DeleteUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterUploadServiceHandlerFromEndpoint is same as RegisterUploadServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterUploadServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterUploadServiceHandler(ctx, mux, conn) +} + +// RegisterUploadServiceHandler registers the http handlers for service UploadService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterUploadServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterUploadServiceHandlerClient(ctx, mux, NewUploadServiceClient(conn)) +} + +// RegisterUploadServiceHandlerClient registers the http handlers for service UploadService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UploadServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UploadServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "UploadServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterUploadServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UploadServiceClient) error { + mux.Handle(http.MethodGet, pattern_UploadService_ListUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/ListUpload", runtime.WithHTTPPathPattern("/upload")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UploadService_ListUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_ListUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_UploadService_GetUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/GetUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UploadService_GetUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_GetUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_UploadService_CreateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/CreateUpload", runtime.WithHTTPPathPattern("/upload")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UploadService_CreateUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_CreateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_UploadService_UpdateUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/UpdateUpload", runtime.WithHTTPPathPattern("/upload/{data.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UploadService_UpdateUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_UpdateUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_UploadService_DeleteUpload_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/DeleteUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UploadService_DeleteUpload_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UploadService_DeleteUpload_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_UploadService_ListUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"upload"}, "")) + pattern_UploadService_GetUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"upload", "id"}, "")) + pattern_UploadService_CreateUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"upload"}, "")) + pattern_UploadService_UpdateUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"upload", "data.id"}, "")) + pattern_UploadService_DeleteUpload_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1}, []string{"upload", "id"}, "")) +) + +var ( + forward_UploadService_ListUpload_0 = runtime.ForwardResponseMessage + forward_UploadService_GetUpload_0 = runtime.ForwardResponseMessage + forward_UploadService_CreateUpload_0 = runtime.ForwardResponseMessage + forward_UploadService_UpdateUpload_0 = runtime.ForwardResponseMessage + forward_UploadService_DeleteUpload_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/datastore/upload.pb.validate.go b/api/v1/services/datastore/upload.pb.validate.go new file mode 100644 index 00000000..57c44c58 --- /dev/null +++ b/api/v1/services/datastore/upload.pb.validate.go @@ -0,0 +1,1327 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: datastore/upload.proto + +package upload + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListUploadRequest 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 *ListUploadRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUploadRequest 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 +// ListUploadRequestMultiError, or nil if none found. +func (m *ListUploadRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUploadRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Type + + if len(errors) > 0 { + return ListUploadRequestMultiError(errors) + } + + return nil +} + +// ListUploadRequestMultiError is an error wrapping multiple validation errors +// returned by ListUploadRequest.ValidateAll() if the designated constraints +// aren't met. +type ListUploadRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUploadRequestMultiError) 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 ListUploadRequestMultiError) AllErrors() []error { return m } + +// ListUploadRequestValidationError is the validation error returned by +// ListUploadRequest.Validate if the designated constraints aren't met. +type ListUploadRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListUploadRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListUploadRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListUploadRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListUploadRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListUploadRequestValidationError) ErrorName() string { + return "ListUploadRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListUploadRequestValidationError) 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 %sListUploadRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListUploadRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListUploadRequestValidationError{} + +// Validate checks the field values on ListUploadResponse 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 *ListUploadResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUploadResponse 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 +// ListUploadResponseMultiError, or nil if none found. +func (m *ListUploadResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUploadResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TotalSize + + for idx, item := range m.GetData() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUploadResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUploadResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListUploadResponseValidationError{ + field: fmt.Sprintf("Data[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUploadResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUploadResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListUploadResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListUploadResponseMultiError(errors) + } + + return nil +} + +// ListUploadResponseMultiError is an error wrapping multiple validation errors +// returned by ListUploadResponse.ValidateAll() if the designated constraints +// aren't met. +type ListUploadResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUploadResponseMultiError) 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 ListUploadResponseMultiError) AllErrors() []error { return m } + +// ListUploadResponseValidationError is the validation error returned by +// ListUploadResponse.Validate if the designated constraints aren't met. +type ListUploadResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListUploadResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListUploadResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListUploadResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListUploadResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListUploadResponseValidationError) ErrorName() string { + return "ListUploadResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListUploadResponseValidationError) 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 %sListUploadResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListUploadResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListUploadResponseValidationError{} + +// Validate checks the field values on GetUploadRequest 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 *GetUploadRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUploadRequest 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 +// GetUploadRequestMultiError, or nil if none found. +func (m *GetUploadRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUploadRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetUploadRequestMultiError(errors) + } + + return nil +} + +// GetUploadRequestMultiError is an error wrapping multiple validation errors +// returned by GetUploadRequest.ValidateAll() if the designated constraints +// aren't met. +type GetUploadRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUploadRequestMultiError) 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 GetUploadRequestMultiError) AllErrors() []error { return m } + +// GetUploadRequestValidationError is the validation error returned by +// GetUploadRequest.Validate if the designated constraints aren't met. +type GetUploadRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUploadRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUploadRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUploadRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUploadRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUploadRequestValidationError) ErrorName() string { return "GetUploadRequestValidationError" } + +// Error satisfies the builtin error interface +func (e GetUploadRequestValidationError) 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 %sGetUploadRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUploadRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUploadRequestValidationError{} + +// Validate checks the field values on GetUploadResponse 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 *GetUploadResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUploadResponse 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 +// GetUploadResponseMultiError, or nil if none found. +func (m *GetUploadResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUploadResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetUploadResponseMultiError(errors) + } + + return nil +} + +// GetUploadResponseMultiError is an error wrapping multiple validation errors +// returned by GetUploadResponse.ValidateAll() if the designated constraints +// aren't met. +type GetUploadResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUploadResponseMultiError) 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 GetUploadResponseMultiError) AllErrors() []error { return m } + +// GetUploadResponseValidationError is the validation error returned by +// GetUploadResponse.Validate if the designated constraints aren't met. +type GetUploadResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUploadResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUploadResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUploadResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUploadResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUploadResponseValidationError) ErrorName() string { + return "GetUploadResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUploadResponseValidationError) 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 %sGetUploadResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUploadResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUploadResponseValidationError{} + +// Validate checks the field values on CreateUploadRequest 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 *CreateUploadRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateUploadRequest 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 +// CreateUploadRequestMultiError, or nil if none found. +func (m *CreateUploadRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateUploadRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for DataId + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateUploadRequestMultiError(errors) + } + + return nil +} + +// CreateUploadRequestMultiError is an error wrapping multiple validation +// errors returned by CreateUploadRequest.ValidateAll() if the designated +// constraints aren't met. +type CreateUploadRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateUploadRequestMultiError) 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 CreateUploadRequestMultiError) AllErrors() []error { return m } + +// CreateUploadRequestValidationError is the validation error returned by +// CreateUploadRequest.Validate if the designated constraints aren't met. +type CreateUploadRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateUploadRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateUploadRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateUploadRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateUploadRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateUploadRequestValidationError) ErrorName() string { + return "CreateUploadRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateUploadRequestValidationError) 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 %sCreateUploadRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateUploadRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateUploadRequestValidationError{} + +// Validate checks the field values on CreateUploadResponse 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 *CreateUploadResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateUploadResponse 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 +// CreateUploadResponseMultiError, or nil if none found. +func (m *CreateUploadResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateUploadResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateUploadResponseMultiError(errors) + } + + return nil +} + +// CreateUploadResponseMultiError is an error wrapping multiple validation +// errors returned by CreateUploadResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateUploadResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateUploadResponseMultiError) 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 CreateUploadResponseMultiError) AllErrors() []error { return m } + +// CreateUploadResponseValidationError is the validation error returned by +// CreateUploadResponse.Validate if the designated constraints aren't met. +type CreateUploadResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateUploadResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateUploadResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateUploadResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateUploadResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateUploadResponseValidationError) ErrorName() string { + return "CreateUploadResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateUploadResponseValidationError) 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 %sCreateUploadResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateUploadResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateUploadResponseValidationError{} + +// Validate checks the field values on UpdateUploadRequest 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 *UpdateUploadRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUploadRequest 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 +// UpdateUploadRequestMultiError, or nil if none found. +func (m *UpdateUploadRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUploadRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateUploadRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateUploadRequestMultiError(errors) + } + + return nil +} + +// UpdateUploadRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateUploadRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateUploadRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUploadRequestMultiError) 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 UpdateUploadRequestMultiError) AllErrors() []error { return m } + +// UpdateUploadRequestValidationError is the validation error returned by +// UpdateUploadRequest.Validate if the designated constraints aren't met. +type UpdateUploadRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUploadRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUploadRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUploadRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUploadRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUploadRequestValidationError) ErrorName() string { + return "UpdateUploadRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUploadRequestValidationError) 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 %sUpdateUploadRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUploadRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUploadRequestValidationError{} + +// Validate checks the field values on UpdateUploadResponse 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 *UpdateUploadResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUploadResponse 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 +// UpdateUploadResponseMultiError, or nil if none found. +func (m *UpdateUploadResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUploadResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateUploadResponseValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateUploadResponseMultiError(errors) + } + + return nil +} + +// UpdateUploadResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateUploadResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateUploadResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUploadResponseMultiError) 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 UpdateUploadResponseMultiError) AllErrors() []error { return m } + +// UpdateUploadResponseValidationError is the validation error returned by +// UpdateUploadResponse.Validate if the designated constraints aren't met. +type UpdateUploadResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUploadResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUploadResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUploadResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUploadResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUploadResponseValidationError) ErrorName() string { + return "UpdateUploadResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUploadResponseValidationError) 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 %sUpdateUploadResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUploadResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUploadResponseValidationError{} + +// Validate checks the field values on DeleteUploadRequest 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 *DeleteUploadRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteUploadRequest 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 +// DeleteUploadRequestMultiError, or nil if none found. +func (m *DeleteUploadRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteUploadRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeleteUploadRequestMultiError(errors) + } + + return nil +} + +// DeleteUploadRequestMultiError is an error wrapping multiple validation +// errors returned by DeleteUploadRequest.ValidateAll() if the designated +// constraints aren't met. +type DeleteUploadRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteUploadRequestMultiError) 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 DeleteUploadRequestMultiError) AllErrors() []error { return m } + +// DeleteUploadRequestValidationError is the validation error returned by +// DeleteUploadRequest.Validate if the designated constraints aren't met. +type DeleteUploadRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteUploadRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteUploadRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteUploadRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteUploadRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteUploadRequestValidationError) ErrorName() string { + return "DeleteUploadRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteUploadRequestValidationError) 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 %sDeleteUploadRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteUploadRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteUploadRequestValidationError{} + +// Validate checks the field values on DeleteUploadResponse 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 *DeleteUploadResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteUploadResponse 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 +// DeleteUploadResponseMultiError, or nil if none found. +func (m *DeleteUploadResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteUploadResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteUploadResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteUploadResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteUploadResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteUploadResponseMultiError(errors) + } + + return nil +} + +// DeleteUploadResponseMultiError is an error wrapping multiple validation +// errors returned by DeleteUploadResponse.ValidateAll() if the designated +// constraints aren't met. +type DeleteUploadResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteUploadResponseMultiError) 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 DeleteUploadResponseMultiError) AllErrors() []error { return m } + +// DeleteUploadResponseValidationError is the validation error returned by +// DeleteUploadResponse.Validate if the designated constraints aren't met. +type DeleteUploadResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteUploadResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteUploadResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteUploadResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteUploadResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteUploadResponseValidationError) ErrorName() string { + return "DeleteUploadResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteUploadResponseValidationError) 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 %sDeleteUploadResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteUploadResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteUploadResponseValidationError{} diff --git a/api/v1/services/datastore/upload_bridge.pb.go b/api/v1/services/datastore/upload_bridge.pb.go new file mode 100644 index 00000000..0043c929 --- /dev/null +++ b/api/v1/services/datastore/upload_bridge.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: datastore/upload.proto + +package upload + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const UploadServiceCreateUploadBridgeOperation = "/api.v1.services.upload.UploadService/CreateUpload" +const UploadServiceDeleteUploadBridgeOperation = "/api.v1.services.upload.UploadService/DeleteUpload" +const UploadServiceGetUploadBridgeOperation = "/api.v1.services.upload.UploadService/GetUpload" +const UploadServiceListUploadBridgeOperation = "/api.v1.services.upload.UploadService/ListUpload" +const UploadServiceUpdateUploadBridgeOperation = "/api.v1.services.upload.UploadService/UpdateUpload" + +type UploadServiceBridgeServer interface { + CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) + DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) + GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) + ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) + UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) +} + +type UploadServiceHooker interface { + UploadServiceCreateUploadHooker + UploadServiceDeleteUploadHooker + UploadServiceGetUploadHooker + UploadServiceListUploadHooker + UploadServiceUpdateUploadHooker +} + +type UploadServiceHookedBridger interface { + UploadServiceHooker + UploadServiceBridgeServer +} +type UploadServiceCreateUploadHooker interface { + PrepareCreateUpload(http.Context, *CreateUploadRequest) (context.Context, error) + CompleteCreateUpload(http.Context, *CreateUploadRequest, *CreateUploadResponse) error +} +type UploadServiceDeleteUploadHooker interface { + PrepareDeleteUpload(http.Context, *DeleteUploadRequest) (context.Context, error) + CompleteDeleteUpload(http.Context, *DeleteUploadRequest, *DeleteUploadResponse) error +} +type UploadServiceGetUploadHooker interface { + PrepareGetUpload(http.Context, *GetUploadRequest) (context.Context, error) + CompleteGetUpload(http.Context, *GetUploadRequest, *GetUploadResponse) error +} +type UploadServiceListUploadHooker interface { + PrepareListUpload(http.Context, *ListUploadRequest) (context.Context, error) + CompleteListUpload(http.Context, *ListUploadRequest, *ListUploadResponse) error +} +type UploadServiceUpdateUploadHooker interface { + PrepareUpdateUpload(http.Context, *UpdateUploadRequest) (context.Context, error) + CompleteUpdateUpload(http.Context, *UpdateUploadRequest, *UpdateUploadResponse) error +} + +func RegisterUploadServiceBridgeServer(s *http.Server, srv UploadServiceHookedBridger) { + r := s.Route("/") + r.GET("/upload", _UploadService_ListUpload0_Bridge_Handler(srv)) + r.GET("/upload/:id", _UploadService_GetUpload0_Bridge_Handler(srv)) + r.POST("/upload", _UploadService_CreateUpload0_Bridge_Handler(srv)) + r.PUT("/upload/:data.id", _UploadService_UpdateUpload0_Bridge_Handler(srv)) + r.DELETE("/upload/:id", _UploadService_DeleteUpload0_Bridge_Handler(srv)) +} + +func _UploadService_ListUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceListUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUpload(ctx, req.(*ListUploadRequest)) + }) + + newctx, err := srv.PrepareListUpload(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListUpload(ctx, &in, out.(*ListUploadResponse)) + } +} + +func _UploadService_GetUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceGetUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUpload(ctx, req.(*GetUploadRequest)) + }) + + newctx, err := srv.PrepareGetUpload(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetUpload(ctx, &in, out.(*GetUploadResponse)) + } +} + +func _UploadService_CreateUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateUploadRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceCreateUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateUpload(ctx, req.(*CreateUploadRequest)) + }) + + newctx, err := srv.PrepareCreateUpload(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateUpload(ctx, &in, out.(*CreateUploadResponse)) + } +} + +func _UploadService_UpdateUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUploadRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceUpdateUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUpload(ctx, req.(*UpdateUploadRequest)) + }) + + newctx, err := srv.PrepareUpdateUpload(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateUpload(ctx, &in, out.(*UpdateUploadResponse)) + } +} + +func _UploadService_DeleteUpload0_Bridge_Handler(srv UploadServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceDeleteUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteUpload(ctx, req.(*DeleteUploadRequest)) + }) + + newctx, err := srv.PrepareDeleteUpload(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteUpload(ctx, &in, out.(*DeleteUploadResponse)) + } +} + +// UnimplementedUploadServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedUploadServiceHooked struct{} + +func (UnimplementedUploadServiceHooked) PrepareCreateUpload(ctx http.Context, in *CreateUploadRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUploadServiceHooked) CompleteCreateUpload(ctx http.Context, in *CreateUploadRequest, out *CreateUploadResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUploadServiceHooked) PrepareDeleteUpload(ctx http.Context, in *DeleteUploadRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUploadServiceHooked) CompleteDeleteUpload(ctx http.Context, in *DeleteUploadRequest, out *DeleteUploadResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUploadServiceHooked) PrepareGetUpload(ctx http.Context, in *GetUploadRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUploadServiceHooked) CompleteGetUpload(ctx http.Context, in *GetUploadRequest, out *GetUploadResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUploadServiceHooked) PrepareListUpload(ctx http.Context, in *ListUploadRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUploadServiceHooked) CompleteListUpload(ctx http.Context, in *ListUploadRequest, out *ListUploadResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUploadServiceHooked) PrepareUpdateUpload(ctx http.Context, in *UpdateUploadRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUploadServiceHooked) CompleteUpdateUpload(ctx http.Context, in *UpdateUploadRequest, out *UpdateUploadResponse) error { + return ctx.Result(200, out) +} + +func WithUploadServiceHook(h UploadServiceHooker) func(UploadServiceBridgeServer) UploadServiceHookedBridger { + return func(srv UploadServiceBridgeServer) UploadServiceHookedBridger { + return UploadServiceHookedBridge{UploadServiceBridgeServer: srv, UploadServiceHooker: h} + } +} + +// UploadServiceHookedBridge is a bridge between the HTTP and gRPC implementations of UploadService. +// It implements the HTTP and gRPC implementations of UploadService. +// It forwards requests and responses between the two implementations. +type UploadServiceHookedBridge struct { + UploadServiceBridgeServer + UploadServiceHooker +} + +type UploadServiceHTTPBridgeImpl struct { + client UploadServiceHTTPClient +} + +func NewUploadServiceHTTPBridge(client *http.Client) UploadServiceHTTPServer { + return &UploadServiceHTTPBridgeImpl{client: NewUploadServiceHTTPClient(client)} +} + +func (c *UploadServiceHTTPBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) +} + +func (c *UploadServiceHTTPBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + +func (c *UploadServiceHTTPBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { + return c.client.GetUpload(ctx, in) +} + +func (c *UploadServiceHTTPBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) +} + +func (c *UploadServiceHTTPBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { + return c.client.UpdateUpload(ctx, in) +} + +type UploadServiceBridgeImpl struct { + client UploadServiceClient +} + +func NewUploadServiceBridge(client grpc.ClientConnInterface) UploadServiceServer { + return &UploadServiceBridgeImpl{client: NewUploadServiceClient(client)} +} + +func (c *UploadServiceBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) +} + +func (c *UploadServiceBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + +func (c *UploadServiceBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { + return c.client.GetUpload(ctx, in) +} + +func (c *UploadServiceBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) +} + +func (c *UploadServiceBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { + return c.client.UpdateUpload(ctx, in) +} + +func (c *UploadServiceBridgeImpl) mustEmbedUnimplementedUploadServiceServer() {} + +type UploadServiceGRPC2HTTPBridgeImpl struct { + client UploadServiceClient +} + +func NewUploadServiceGRPC2HTTP(client grpc.ClientConnInterface) UploadServiceHTTPServer { + return &UploadServiceGRPC2HTTPBridgeImpl{client: NewUploadServiceClient(client)} +} + +func (c *UploadServiceGRPC2HTTPBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) +} + +func (c *UploadServiceGRPC2HTTPBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + +func (c *UploadServiceGRPC2HTTPBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { + return c.client.GetUpload(ctx, in) +} + +func (c *UploadServiceGRPC2HTTPBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) +} + +func (c *UploadServiceGRPC2HTTPBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { + return c.client.UpdateUpload(ctx, in) +} + +type UploadServiceHTTP2GRPCBridgeImpl struct { + client UploadServiceHTTPClient +} + +func NewUploadServiceHTTP2GRPC(client *http.Client) UploadServiceServer { + return &UploadServiceHTTP2GRPCBridgeImpl{client: NewUploadServiceHTTPClient(client)} +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { + return c.client.GetUpload(ctx, in) +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { + return c.client.UpdateUpload(ctx, in) +} + +func (c *UploadServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedUploadServiceServer() {} diff --git a/api/v1/services/datastore/upload_grpc.pb.go b/api/v1/services/datastore/upload_grpc.pb.go new file mode 100644 index 00000000..8f0238b8 --- /dev/null +++ b/api/v1/services/datastore/upload_grpc.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: datastore/upload.proto + +package upload + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + UploadService_ListUpload_FullMethodName = "/api.v1.services.upload.UploadService/ListUpload" + UploadService_GetUpload_FullMethodName = "/api.v1.services.upload.UploadService/GetUpload" + UploadService_CreateUpload_FullMethodName = "/api.v1.services.upload.UploadService/CreateUpload" + UploadService_UpdateUpload_FullMethodName = "/api.v1.services.upload.UploadService/UpdateUpload" + UploadService_DeleteUpload_FullMethodName = "/api.v1.services.upload.UploadService/DeleteUpload" +) + +// UploadServiceClient is the client API for UploadService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The data service definition. +type UploadServiceClient interface { + ListUpload(ctx context.Context, in *ListUploadRequest, opts ...grpc.CallOption) (*ListUploadResponse, error) + GetUpload(ctx context.Context, in *GetUploadRequest, opts ...grpc.CallOption) (*GetUploadResponse, error) + CreateUpload(ctx context.Context, in *CreateUploadRequest, opts ...grpc.CallOption) (*CreateUploadResponse, error) + UpdateUpload(ctx context.Context, in *UpdateUploadRequest, opts ...grpc.CallOption) (*UpdateUploadResponse, error) + DeleteUpload(ctx context.Context, in *DeleteUploadRequest, opts ...grpc.CallOption) (*DeleteUploadResponse, error) +} + +type uploadServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewUploadServiceClient(cc grpc.ClientConnInterface) UploadServiceClient { + return &uploadServiceClient{cc} +} + +func (c *uploadServiceClient) ListUpload(ctx context.Context, in *ListUploadRequest, opts ...grpc.CallOption) (*ListUploadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListUploadResponse) + err := c.cc.Invoke(ctx, UploadService_ListUpload_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *uploadServiceClient) GetUpload(ctx context.Context, in *GetUploadRequest, opts ...grpc.CallOption) (*GetUploadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetUploadResponse) + err := c.cc.Invoke(ctx, UploadService_GetUpload_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *uploadServiceClient) CreateUpload(ctx context.Context, in *CreateUploadRequest, opts ...grpc.CallOption) (*CreateUploadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateUploadResponse) + err := c.cc.Invoke(ctx, UploadService_CreateUpload_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *uploadServiceClient) UpdateUpload(ctx context.Context, in *UpdateUploadRequest, opts ...grpc.CallOption) (*UpdateUploadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateUploadResponse) + err := c.cc.Invoke(ctx, UploadService_UpdateUpload_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *uploadServiceClient) DeleteUpload(ctx context.Context, in *DeleteUploadRequest, opts ...grpc.CallOption) (*DeleteUploadResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteUploadResponse) + err := c.cc.Invoke(ctx, UploadService_DeleteUpload_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// UploadServiceServer is the server API for UploadService service. +// All implementations must embed UnimplementedUploadServiceServer +// for forward compatibility. +// +// The data service definition. +type UploadServiceServer interface { + ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) + GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) + CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) + UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) + DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) + mustEmbedUnimplementedUploadServiceServer() +} + +// UnimplementedUploadServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedUploadServiceServer struct{} + +func (UnimplementedUploadServiceServer) ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListUpload not implemented") +} +func (UnimplementedUploadServiceServer) GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUpload not implemented") +} +func (UnimplementedUploadServiceServer) CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateUpload not implemented") +} +func (UnimplementedUploadServiceServer) UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateUpload not implemented") +} +func (UnimplementedUploadServiceServer) DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteUpload not implemented") +} +func (UnimplementedUploadServiceServer) mustEmbedUnimplementedUploadServiceServer() {} +func (UnimplementedUploadServiceServer) testEmbeddedByValue() {} + +// UnsafeUploadServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to UploadServiceServer will +// result in compilation errors. +type UnsafeUploadServiceServer interface { + mustEmbedUnimplementedUploadServiceServer() +} + +func RegisterUploadServiceServer(s grpc.ServiceRegistrar, srv UploadServiceServer) { + // If the following call pancis, it indicates UnimplementedUploadServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&UploadService_ServiceDesc, srv) +} + +func _UploadService_ListUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListUploadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UploadServiceServer).ListUpload(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UploadService_ListUpload_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UploadServiceServer).ListUpload(ctx, req.(*ListUploadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UploadService_GetUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUploadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UploadServiceServer).GetUpload(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UploadService_GetUpload_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UploadServiceServer).GetUpload(ctx, req.(*GetUploadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UploadService_CreateUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateUploadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UploadServiceServer).CreateUpload(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UploadService_CreateUpload_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UploadServiceServer).CreateUpload(ctx, req.(*CreateUploadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UploadService_UpdateUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateUploadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UploadServiceServer).UpdateUpload(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UploadService_UpdateUpload_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UploadServiceServer).UpdateUpload(ctx, req.(*UpdateUploadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UploadService_DeleteUpload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteUploadRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UploadServiceServer).DeleteUpload(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UploadService_DeleteUpload_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UploadServiceServer).DeleteUpload(ctx, req.(*DeleteUploadRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// UploadService_ServiceDesc is the grpc.ServiceDesc for UploadService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var UploadService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.upload.UploadService", + HandlerType: (*UploadServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListUpload", + Handler: _UploadService_ListUpload_Handler, + }, + { + MethodName: "GetUpload", + Handler: _UploadService_GetUpload_Handler, + }, + { + MethodName: "CreateUpload", + Handler: _UploadService_CreateUpload_Handler, + }, + { + MethodName: "UpdateUpload", + Handler: _UploadService_UpdateUpload_Handler, + }, + { + MethodName: "DeleteUpload", + Handler: _UploadService_DeleteUpload_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "datastore/upload.proto", +} diff --git a/api/v1/services/datastore/upload_http.pb.go b/api/v1/services/datastore/upload_http.pb.go new file mode 100644 index 00000000..2162bd5d --- /dev/null +++ b/api/v1/services/datastore/upload_http.pb.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: datastore/upload.proto + +package upload + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationUploadServiceCreateUpload = "/api.v1.services.upload.UploadService/CreateUpload" +const OperationUploadServiceDeleteUpload = "/api.v1.services.upload.UploadService/DeleteUpload" +const OperationUploadServiceGetUpload = "/api.v1.services.upload.UploadService/GetUpload" +const OperationUploadServiceListUpload = "/api.v1.services.upload.UploadService/ListUpload" +const OperationUploadServiceUpdateUpload = "/api.v1.services.upload.UploadService/UpdateUpload" + +type UploadServiceHTTPServer interface { + CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) + DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) + GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) + ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) + UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) +} + +func RegisterUploadServiceHTTPServer(s *http.Server, srv UploadServiceHTTPServer) { + r := s.Route("/") + r.GET("/upload", _UploadService_ListUpload0_HTTP_Handler(srv)) + r.GET("/upload/{id}", _UploadService_GetUpload0_HTTP_Handler(srv)) + r.POST("/upload", _UploadService_CreateUpload0_HTTP_Handler(srv)) + r.PUT("/upload/{data.id}", _UploadService_UpdateUpload0_HTTP_Handler(srv)) + r.DELETE("/upload/{id}", _UploadService_DeleteUpload0_HTTP_Handler(srv)) +} + +func _UploadService_ListUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceListUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUpload(ctx, req.(*ListUploadRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListUploadResponse) + return ctx.Result(200, reply) + } +} + +func _UploadService_GetUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceGetUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUpload(ctx, req.(*GetUploadRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetUploadResponse) + return ctx.Result(200, reply) + } +} + +func _UploadService_CreateUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateUploadRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceCreateUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateUpload(ctx, req.(*CreateUploadRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateUploadResponse) + return ctx.Result(200, reply) + } +} + +func _UploadService_UpdateUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUploadRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceUpdateUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUpload(ctx, req.(*UpdateUploadRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateUploadResponse) + return ctx.Result(200, reply) + } +} + +func _UploadService_DeleteUpload0_HTTP_Handler(srv UploadServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteUploadRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUploadServiceDeleteUpload) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteUpload(ctx, req.(*DeleteUploadRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeleteUploadResponse) + return ctx.Result(200, reply) + } +} + +type UploadServiceHTTPClient interface { + CreateUpload(ctx context.Context, req *CreateUploadRequest, opts ...http.CallOption) (rsp *CreateUploadResponse, err error) + DeleteUpload(ctx context.Context, req *DeleteUploadRequest, opts ...http.CallOption) (rsp *DeleteUploadResponse, err error) + GetUpload(ctx context.Context, req *GetUploadRequest, opts ...http.CallOption) (rsp *GetUploadResponse, err error) + ListUpload(ctx context.Context, req *ListUploadRequest, opts ...http.CallOption) (rsp *ListUploadResponse, err error) + UpdateUpload(ctx context.Context, req *UpdateUploadRequest, opts ...http.CallOption) (rsp *UpdateUploadResponse, err error) +} + +type UploadServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewUploadServiceHTTPClient(client *http.Client) UploadServiceHTTPClient { + return &UploadServiceHTTPClientImpl{client} +} + +func (c *UploadServiceHTTPClientImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest, opts ...http.CallOption) (*CreateUploadResponse, error) { + var out CreateUploadResponse + pattern := "/upload" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationUploadServiceCreateUpload)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UploadServiceHTTPClientImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest, opts ...http.CallOption) (*DeleteUploadResponse, error) { + var out DeleteUploadResponse + pattern := "/upload/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationUploadServiceDeleteUpload)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UploadServiceHTTPClientImpl) GetUpload(ctx context.Context, in *GetUploadRequest, opts ...http.CallOption) (*GetUploadResponse, error) { + var out GetUploadResponse + pattern := "/upload/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationUploadServiceGetUpload)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UploadServiceHTTPClientImpl) ListUpload(ctx context.Context, in *ListUploadRequest, opts ...http.CallOption) (*ListUploadResponse, error) { + var out ListUploadResponse + pattern := "/upload" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationUploadServiceListUpload)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UploadServiceHTTPClientImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest, opts ...http.CallOption) (*UpdateUploadResponse, error) { + var out UpdateUploadResponse + pattern := "/upload/{data.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationUploadServiceUpdateUpload)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/message/message.pb.go b/api/v1/services/message/message.pb.go new file mode 100644 index 00000000..be871264 --- /dev/null +++ b/api/v1/services/message/message.pb.go @@ -0,0 +1,1074 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: message/message.proto + +package message + +import ( + _ "github.com/envoyproxy/protoc-gen-validate/validate" + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type UpdatePersonalSettingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalSettingRequest) Reset() { + *x = UpdatePersonalSettingRequest{} + mi := &file_message_message_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalSettingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalSettingRequest) ProtoMessage() {} + +func (x *UpdatePersonalSettingRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[0] + 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 UpdatePersonalSettingRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalSettingRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{0} +} + +func (x *UpdatePersonalSettingRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalSettingResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalSettingResponse) Reset() { + *x = UpdatePersonalSettingResponse{} + mi := &file_message_message_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalSettingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalSettingResponse) ProtoMessage() {} + +func (x *UpdatePersonalSettingResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[1] + 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 UpdatePersonalSettingResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalSettingResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{1} +} + +type UpdatePersonalRoleRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalRoleRequest) Reset() { + *x = UpdatePersonalRoleRequest{} + mi := &file_message_message_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalRoleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalRoleRequest) ProtoMessage() {} + +func (x *UpdatePersonalRoleRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[2] + 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 UpdatePersonalRoleRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalRoleRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{2} +} + +func (x *UpdatePersonalRoleRequest) GetRole() *types.Role { + if x != nil { + return x.Role + } + return nil +} + +type UpdatePersonalRoleResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalRoleResponse) Reset() { + *x = UpdatePersonalRoleResponse{} + mi := &file_message_message_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalRoleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalRoleResponse) ProtoMessage() {} + +func (x *UpdatePersonalRoleResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[3] + 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 UpdatePersonalRoleResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalRoleResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{3} +} + +type ListPersonalResourcesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The current page number. + Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalResourcesRequest) Reset() { + *x = ListPersonalResourcesRequest{} + mi := &file_message_message_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalResourcesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalResourcesRequest) ProtoMessage() {} + +func (x *ListPersonalResourcesRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[4] + 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 ListPersonalResourcesRequest.ProtoReflect.Descriptor instead. +func (*ListPersonalResourcesRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{4} +} + +func (x *ListPersonalResourcesRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetCurrent() int32 { + if x != nil { + return x.Current + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListPersonalResourcesRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListPersonalResourcesRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListPersonalResourcesRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +type ListPersonalResourcesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + TotalSize int64 `protobuf:"varint,1,opt,name=total_size,json=total,proto3" json:"total_size,omitempty"` + // list of resources + Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalResourcesResponse) Reset() { + *x = ListPersonalResourcesResponse{} + mi := &file_message_message_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalResourcesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalResourcesResponse) ProtoMessage() {} + +func (x *ListPersonalResourcesResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[5] + 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 ListPersonalResourcesResponse.ProtoReflect.Descriptor instead. +func (*ListPersonalResourcesResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{5} +} + +func (x *ListPersonalResourcesResponse) GetTotalSize() int64 { + if x != nil { + return x.TotalSize + } + return 0 +} + +func (x *ListPersonalResourcesResponse) GetResources() []*types.Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *ListPersonalResourcesResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +type UpdatePersonalPasswordRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalPasswordRequest) Reset() { + *x = UpdatePersonalPasswordRequest{} + mi := &file_message_message_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalPasswordRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalPasswordRequest) ProtoMessage() {} + +func (x *UpdatePersonalPasswordRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_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 UpdatePersonalPasswordRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalPasswordRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdatePersonalPasswordRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalPasswordResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalPasswordResponse) Reset() { + *x = UpdatePersonalPasswordResponse{} + mi := &file_message_message_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalPasswordResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalPasswordResponse) ProtoMessage() {} + +func (x *UpdatePersonalPasswordResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdatePersonalPasswordResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalPasswordResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{7} +} + +type PersonalPasswordRestRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalPasswordRestRequest) Reset() { + *x = PersonalPasswordRestRequest{} + mi := &file_message_message_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalPasswordRestRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalPasswordRestRequest) ProtoMessage() {} + +func (x *PersonalPasswordRestRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[8] + 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 PersonalPasswordRestRequest.ProtoReflect.Descriptor instead. +func (*PersonalPasswordRestRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{8} +} + +func (x *PersonalPasswordRestRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type PersonalPasswordRestResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalPasswordRestResponse) Reset() { + *x = PersonalPasswordRestResponse{} + mi := &file_message_message_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalPasswordRestResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalPasswordRestResponse) ProtoMessage() {} + +func (x *PersonalPasswordRestResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[9] + 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 PersonalPasswordRestResponse.ProtoReflect.Descriptor instead. +func (*PersonalPasswordRestResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{9} +} + +type UpdatePersonalProfileRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalProfileRequest) Reset() { + *x = UpdatePersonalProfileRequest{} + mi := &file_message_message_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalProfileRequest) ProtoMessage() {} + +func (x *UpdatePersonalProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[10] + 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 UpdatePersonalProfileRequest.ProtoReflect.Descriptor instead. +func (*UpdatePersonalProfileRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{10} +} + +func (x *UpdatePersonalProfileRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type UpdatePersonalProfileResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePersonalProfileResponse) Reset() { + *x = UpdatePersonalProfileResponse{} + mi := &file_message_message_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePersonalProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePersonalProfileResponse) ProtoMessage() {} + +func (x *UpdatePersonalProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[11] + 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 UpdatePersonalProfileResponse.ProtoReflect.Descriptor instead. +func (*UpdatePersonalProfileResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{11} +} + +type PersonalLogoutRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalLogoutRequest) Reset() { + *x = PersonalLogoutRequest{} + mi := &file_message_message_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalLogoutRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalLogoutRequest) ProtoMessage() {} + +func (x *PersonalLogoutRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[12] + 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 PersonalLogoutRequest.ProtoReflect.Descriptor instead. +func (*PersonalLogoutRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{12} +} + +func (x *PersonalLogoutRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type PersonalLogoutResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PersonalLogoutResponse) Reset() { + *x = PersonalLogoutResponse{} + mi := &file_message_message_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PersonalLogoutResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PersonalLogoutResponse) ProtoMessage() {} + +func (x *PersonalLogoutResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[13] + 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 PersonalLogoutResponse.ProtoReflect.Descriptor instead. +func (*PersonalLogoutResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{13} +} + +func (x *PersonalLogoutResponse) GetSuccess() bool { + if x != nil { + return x.Success + } + return false +} + +type ListPersonalRolesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalRolesRequest) Reset() { + *x = ListPersonalRolesRequest{} + mi := &file_message_message_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalRolesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalRolesRequest) ProtoMessage() {} + +func (x *ListPersonalRolesRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[14] + 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 ListPersonalRolesRequest.ProtoReflect.Descriptor instead. +func (*ListPersonalRolesRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{14} +} + +type ListPersonalRolesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Roles []*types.Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPersonalRolesResponse) Reset() { + *x = ListPersonalRolesResponse{} + mi := &file_message_message_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPersonalRolesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPersonalRolesResponse) ProtoMessage() {} + +func (x *ListPersonalRolesResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[15] + 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 ListPersonalRolesResponse.ProtoReflect.Descriptor instead. +func (*ListPersonalRolesResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{15} +} + +func (x *ListPersonalRolesResponse) GetRoles() []*types.Role { + if x != nil { + return x.Roles + } + return nil +} + +type GetPersonalProfileRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPersonalProfileRequest) Reset() { + *x = GetPersonalProfileRequest{} + mi := &file_message_message_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPersonalProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPersonalProfileRequest) ProtoMessage() {} + +func (x *GetPersonalProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[16] + 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 GetPersonalProfileRequest.ProtoReflect.Descriptor instead. +func (*GetPersonalProfileRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{16} +} + +type GetPersonalProfileResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPersonalProfileResponse) Reset() { + *x = GetPersonalProfileResponse{} + mi := &file_message_message_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPersonalProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPersonalProfileResponse) ProtoMessage() {} + +func (x *GetPersonalProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[17] + 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 GetPersonalProfileResponse.ProtoReflect.Descriptor instead. +func (*GetPersonalProfileResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{17} +} + +func (x *GetPersonalProfileResponse) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +type RefreshPersonalTokenRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshPersonalTokenRequest) Reset() { + *x = RefreshPersonalTokenRequest{} + mi := &file_message_message_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshPersonalTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshPersonalTokenRequest) ProtoMessage() {} + +func (x *RefreshPersonalTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshPersonalTokenRequest.ProtoReflect.Descriptor instead. +func (*RefreshPersonalTokenRequest) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{18} +} + +func (x *RefreshPersonalTokenRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type RefreshPersonalTokenResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshPersonalTokenResponse) Reset() { + *x = RefreshPersonalTokenResponse{} + mi := &file_message_message_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshPersonalTokenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshPersonalTokenResponse) ProtoMessage() {} + +func (x *RefreshPersonalTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_message_message_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshPersonalTokenResponse.ProtoReflect.Descriptor instead. +func (*RefreshPersonalTokenResponse) Descriptor() ([]byte, []int) { + return file_message_message_proto_rawDescGZIP(), []int{19} +} + +func (x *RefreshPersonalTokenResponse) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +var File_message_message_proto protoreflect.FileDescriptor + +const file_message_message_proto_rawDesc = "" + + "\n" + + "\x15message/message.proto\x12\x17api.v1.services.message\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12types/system.proto\x1a\x17validate/validate.proto\"H\n" + + "\x1cUpdatePersonalSettingRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + + "\x1dUpdatePersonalSettingResponse\"L\n" + + "\x19UpdatePersonalRoleRequest\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\x1c\n" + + "\x1aUpdatePersonalRoleResponse\"\xc4\x01\n" + + "\x1cListPersonalResourcesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\"\xa3\x01\n" + + "\x1dListPersonalResourcesResponse\x12\x19\n" + + "\n" + + "total_size\x18\x01 \x01(\x03R\x05total\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\"I\n" + + "\x1dUpdatePersonalPasswordRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\" \n" + + "\x1eUpdatePersonalPasswordResponse\"6\n" + + "\x1bPersonalPasswordRestRequest\x12\x17\n" + + "\x02id\x18\x01 \x01(\x03B\a\xfaB\x04\"\x02 \x00R\x02id\"\x1e\n" + + "\x1cPersonalPasswordRestResponse\"H\n" + + "\x1cUpdatePersonalProfileRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + + "\x1dUpdatePersonalProfileResponse\"A\n" + + "\x15PersonalLogoutRequest\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"2\n" + + "\x16PersonalLogoutResponse\x12\x18\n" + + "\asuccess\x18\x01 \x01(\bR\asuccess\"\x1a\n" + + "\x18ListPersonalRolesRequest\"N\n" + + "\x19ListPersonalRolesResponse\x121\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x1b\n" + + "\x19GetPersonalProfileRequest\"M\n" + + "\x1aGetPersonalProfileResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + + "\x1bRefreshPersonalTokenRequest\x12(\n" + + "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"4\n" + + "\x1cRefreshPersonalTokenResponse\x12\x14\n" + + "\x05token\x18\x01 \x01(\tR\x05token2\xeb\n" + + "\n" + + "\x0fPersonalService\x12\xa0\x01\n" + + "\x12GetPersonalProfile\x122.api.v1.services.message.GetPersonalProfileRequest\x1a3.api.v1.services.message.GetPersonalProfileResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/message/personal/profile\x12\xab\x01\n" + + "\x15ListPersonalResources\x125.api.v1.services.message.ListPersonalResourcesRequest\x1a6.api.v1.services.message.ListPersonalResourcesResponse\"#\x82\xd3\xe4\x93\x02\x1d\x12\x1b/message/personal/resources\x12\x9b\x01\n" + + "\x11ListPersonalRoles\x121.api.v1.services.message.ListPersonalRolesRequest\x1a2.api.v1.services.message.ListPersonalRolesResponse\"\x1f\x82\xd3\xe4\x93\x02\x19\x12\x17/message/personal/roles\x12\x99\x01\n" + + "\x0ePersonalLogout\x12..api.v1.services.message.PersonalLogoutRequest\x1a/.api.v1.services.message.PersonalLogoutResponse\"&\x82\xd3\xe4\x93\x02 :\x04data\"\x18/message/personal/logout\x12\xb2\x01\n" + + "\x14RefreshPersonalToken\x124.api.v1.services.message.RefreshPersonalTokenRequest\x1a5.api.v1.services.message.RefreshPersonalTokenResponse\"-\x82\xd3\xe4\x93\x02':\x04data\"\x1f/message/personal/token/refresh\x12\xb3\x01\n" + + "\x16UpdatePersonalPassword\x126.api.v1.services.message.UpdatePersonalPasswordRequest\x1a7.api.v1.services.message.UpdatePersonalPasswordResponse\"(\x82\xd3\xe4\x93\x02\":\x04data\x1a\x1a/message/personal/password\x12\xaf\x01\n" + + "\x15UpdatePersonalProfile\x125.api.v1.services.message.UpdatePersonalProfileRequest\x1a6.api.v1.services.message.UpdatePersonalProfileResponse\"'\x82\xd3\xe4\x93\x02!:\x04data\x1a\x19/message/personal/profile\x12\xaf\x01\n" + + "\x15UpdatePersonalSetting\x125.api.v1.services.message.UpdatePersonalSettingRequest\x1a6.api.v1.services.message.UpdatePersonalSettingResponse\"'\x82\xd3\xe4\x93\x02!:\x04data\x1a\x19/message/personal/settingB\xe8\x01\n" + + "\x1bcom.api.v1.services.messageB\fMessageProtoP\x01Z;origadmin/application/admin/api/v1/services/message;message\xa2\x02\x04AVSM\xaa\x02\x17Api.V1.Services.Message\xca\x02\x17Api\\V1\\Services\\Message\xe2\x02#Api\\V1\\Services\\Message\\GPBMetadata\xea\x02\x1aApi::V1::Services::Messageb\x06proto3" + +var ( + file_message_message_proto_rawDescOnce sync.Once + file_message_message_proto_rawDescData []byte +) + +func file_message_message_proto_rawDescGZIP() []byte { + file_message_message_proto_rawDescOnce.Do(func() { + file_message_message_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_message_message_proto_rawDesc), len(file_message_message_proto_rawDesc))) + }) + return file_message_message_proto_rawDescData +} + +var file_message_message_proto_msgTypes = make([]protoimpl.MessageInfo, 20) +var file_message_message_proto_goTypes = []any{ + (*UpdatePersonalSettingRequest)(nil), // 0: api.v1.services.message.UpdatePersonalSettingRequest + (*UpdatePersonalSettingResponse)(nil), // 1: api.v1.services.message.UpdatePersonalSettingResponse + (*UpdatePersonalRoleRequest)(nil), // 2: api.v1.services.message.UpdatePersonalRoleRequest + (*UpdatePersonalRoleResponse)(nil), // 3: api.v1.services.message.UpdatePersonalRoleResponse + (*ListPersonalResourcesRequest)(nil), // 4: api.v1.services.message.ListPersonalResourcesRequest + (*ListPersonalResourcesResponse)(nil), // 5: api.v1.services.message.ListPersonalResourcesResponse + (*UpdatePersonalPasswordRequest)(nil), // 6: api.v1.services.message.UpdatePersonalPasswordRequest + (*UpdatePersonalPasswordResponse)(nil), // 7: api.v1.services.message.UpdatePersonalPasswordResponse + (*PersonalPasswordRestRequest)(nil), // 8: api.v1.services.message.PersonalPasswordRestRequest + (*PersonalPasswordRestResponse)(nil), // 9: api.v1.services.message.PersonalPasswordRestResponse + (*UpdatePersonalProfileRequest)(nil), // 10: api.v1.services.message.UpdatePersonalProfileRequest + (*UpdatePersonalProfileResponse)(nil), // 11: api.v1.services.message.UpdatePersonalProfileResponse + (*PersonalLogoutRequest)(nil), // 12: api.v1.services.message.PersonalLogoutRequest + (*PersonalLogoutResponse)(nil), // 13: api.v1.services.message.PersonalLogoutResponse + (*ListPersonalRolesRequest)(nil), // 14: api.v1.services.message.ListPersonalRolesRequest + (*ListPersonalRolesResponse)(nil), // 15: api.v1.services.message.ListPersonalRolesResponse + (*GetPersonalProfileRequest)(nil), // 16: api.v1.services.message.GetPersonalProfileRequest + (*GetPersonalProfileResponse)(nil), // 17: api.v1.services.message.GetPersonalProfileResponse + (*RefreshPersonalTokenRequest)(nil), // 18: api.v1.services.message.RefreshPersonalTokenRequest + (*RefreshPersonalTokenResponse)(nil), // 19: api.v1.services.message.RefreshPersonalTokenResponse + (*anypb.Any)(nil), // 20: google.protobuf.Any + (*types.Role)(nil), // 21: api.v1.services.types.Role + (*types.Resource)(nil), // 22: api.v1.services.types.Resource + (*types.User)(nil), // 23: api.v1.services.types.User +} +var file_message_message_proto_depIdxs = []int32{ + 20, // 0: api.v1.services.message.UpdatePersonalSettingRequest.data:type_name -> google.protobuf.Any + 21, // 1: api.v1.services.message.UpdatePersonalRoleRequest.role:type_name -> api.v1.services.types.Role + 22, // 2: api.v1.services.message.ListPersonalResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 20, // 3: api.v1.services.message.UpdatePersonalPasswordRequest.data:type_name -> google.protobuf.Any + 20, // 4: api.v1.services.message.UpdatePersonalProfileRequest.data:type_name -> google.protobuf.Any + 20, // 5: api.v1.services.message.PersonalLogoutRequest.data:type_name -> google.protobuf.Any + 21, // 6: api.v1.services.message.ListPersonalRolesResponse.roles:type_name -> api.v1.services.types.Role + 23, // 7: api.v1.services.message.GetPersonalProfileResponse.user:type_name -> api.v1.services.types.User + 20, // 8: api.v1.services.message.RefreshPersonalTokenRequest.data:type_name -> google.protobuf.Any + 16, // 9: api.v1.services.message.PersonalService.GetPersonalProfile:input_type -> api.v1.services.message.GetPersonalProfileRequest + 4, // 10: api.v1.services.message.PersonalService.ListPersonalResources:input_type -> api.v1.services.message.ListPersonalResourcesRequest + 14, // 11: api.v1.services.message.PersonalService.ListPersonalRoles:input_type -> api.v1.services.message.ListPersonalRolesRequest + 12, // 12: api.v1.services.message.PersonalService.PersonalLogout:input_type -> api.v1.services.message.PersonalLogoutRequest + 18, // 13: api.v1.services.message.PersonalService.RefreshPersonalToken:input_type -> api.v1.services.message.RefreshPersonalTokenRequest + 6, // 14: api.v1.services.message.PersonalService.UpdatePersonalPassword:input_type -> api.v1.services.message.UpdatePersonalPasswordRequest + 10, // 15: api.v1.services.message.PersonalService.UpdatePersonalProfile:input_type -> api.v1.services.message.UpdatePersonalProfileRequest + 0, // 16: api.v1.services.message.PersonalService.UpdatePersonalSetting:input_type -> api.v1.services.message.UpdatePersonalSettingRequest + 17, // 17: api.v1.services.message.PersonalService.GetPersonalProfile:output_type -> api.v1.services.message.GetPersonalProfileResponse + 5, // 18: api.v1.services.message.PersonalService.ListPersonalResources:output_type -> api.v1.services.message.ListPersonalResourcesResponse + 15, // 19: api.v1.services.message.PersonalService.ListPersonalRoles:output_type -> api.v1.services.message.ListPersonalRolesResponse + 13, // 20: api.v1.services.message.PersonalService.PersonalLogout:output_type -> api.v1.services.message.PersonalLogoutResponse + 19, // 21: api.v1.services.message.PersonalService.RefreshPersonalToken:output_type -> api.v1.services.message.RefreshPersonalTokenResponse + 7, // 22: api.v1.services.message.PersonalService.UpdatePersonalPassword:output_type -> api.v1.services.message.UpdatePersonalPasswordResponse + 11, // 23: api.v1.services.message.PersonalService.UpdatePersonalProfile:output_type -> api.v1.services.message.UpdatePersonalProfileResponse + 1, // 24: api.v1.services.message.PersonalService.UpdatePersonalSetting:output_type -> api.v1.services.message.UpdatePersonalSettingResponse + 17, // [17:25] is the sub-list for method output_type + 9, // [9:17] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_message_message_proto_init() } +func file_message_message_proto_init() { + if File_message_message_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_message_message_proto_rawDesc), len(file_message_message_proto_rawDesc)), + NumEnums: 0, + NumMessages: 20, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_message_message_proto_goTypes, + DependencyIndexes: file_message_message_proto_depIdxs, + MessageInfos: file_message_message_proto_msgTypes, + }.Build() + File_message_message_proto = out.File + file_message_message_proto_goTypes = nil + file_message_message_proto_depIdxs = nil +} diff --git a/api/v1/services/message/message.pb.gw.go b/api/v1/services/message/message.pb.gw.go new file mode 100644 index 00000000..96398dee --- /dev/null +++ b/api/v1/services/message/message.pb.gw.go @@ -0,0 +1,594 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: message/message.proto + +/* +Package message is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package message + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +func request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPersonalProfileRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.GetPersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPersonalProfileRequest + metadata runtime.ServerMetadata + ) + msg, err := server.GetPersonalProfile(ctx, &protoReq) + return msg, metadata, err +} + +var filter_PersonalService_ListPersonalResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalResourcesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListPersonalResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalResourcesRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListPersonalResources(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalRolesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.ListPersonalRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPersonalRolesRequest + metadata runtime.ServerMetadata + ) + msg, err := server.ListPersonalRoles(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq PersonalLogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.PersonalLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq PersonalLogoutRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.PersonalLogout(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RefreshPersonalTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.RefreshPersonalToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RefreshPersonalTokenRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.RefreshPersonalToken(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalPasswordRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalPasswordRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalPassword(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalProfileRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalProfileRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalProfile(ctx, &protoReq) + return msg, metadata, err +} + +func request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalSettingRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePersonalSetting(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePersonalSettingRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePersonalSetting(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterPersonalServiceHandlerServer registers the http handlers for service PersonalService to "mux". +// UnaryRPC :call PersonalServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPersonalServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterPersonalServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PersonalServiceServer) error { + mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/message/personal/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/message/personal/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/message/personal/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/message/personal/token/refresh")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/message/personal/password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/message/personal/setting")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterPersonalServiceHandlerFromEndpoint is same as RegisterPersonalServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterPersonalServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterPersonalServiceHandler(ctx, mux, conn) +} + +// RegisterPersonalServiceHandler registers the http handlers for service PersonalService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterPersonalServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterPersonalServiceHandlerClient(ctx, mux, NewPersonalServiceClient(conn)) +} + +// RegisterPersonalServiceHandlerClient registers the http handlers for service PersonalService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PersonalServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PersonalServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "PersonalServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterPersonalServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PersonalServiceClient) error { + mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/message/personal/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/message/personal/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/message/personal/logout")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/message/personal/token/refresh")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/message/personal/password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/message/personal/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.message.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/message/personal/setting")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_PersonalService_GetPersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "profile"}, "")) + pattern_PersonalService_ListPersonalResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "resources"}, "")) + pattern_PersonalService_ListPersonalRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "roles"}, "")) + pattern_PersonalService_PersonalLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "logout"}, "")) + pattern_PersonalService_RefreshPersonalToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"message", "personal", "token", "refresh"}, "")) + pattern_PersonalService_UpdatePersonalPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "password"}, "")) + pattern_PersonalService_UpdatePersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "profile"}, "")) + pattern_PersonalService_UpdatePersonalSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"message", "personal", "setting"}, "")) +) + +var ( + forward_PersonalService_GetPersonalProfile_0 = runtime.ForwardResponseMessage + forward_PersonalService_ListPersonalResources_0 = runtime.ForwardResponseMessage + forward_PersonalService_ListPersonalRoles_0 = runtime.ForwardResponseMessage + forward_PersonalService_PersonalLogout_0 = runtime.ForwardResponseMessage + forward_PersonalService_RefreshPersonalToken_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalPassword_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalProfile_0 = runtime.ForwardResponseMessage + forward_PersonalService_UpdatePersonalSetting_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/message/message.pb.validate.go b/api/v1/services/message/message.pb.validate.go new file mode 100644 index 00000000..772c5e54 --- /dev/null +++ b/api/v1/services/message/message.pb.validate.go @@ -0,0 +1,2390 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: message/message.proto + +package message + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on UpdatePersonalSettingRequest 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 *UpdatePersonalSettingRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalSettingRequest 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 +// UpdatePersonalSettingRequestMultiError, or nil if none found. +func (m *UpdatePersonalSettingRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalSettingRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalSettingRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalSettingRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalSettingRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalSettingRequest.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalSettingRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalSettingRequestMultiError) 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 UpdatePersonalSettingRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalSettingRequestValidationError is the validation error returned +// by UpdatePersonalSettingRequest.Validate if the designated constraints +// aren't met. +type UpdatePersonalSettingRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalSettingRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalSettingRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalSettingRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalSettingRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalSettingRequestValidationError) ErrorName() string { + return "UpdatePersonalSettingRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalSettingRequestValidationError) 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 %sUpdatePersonalSettingRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalSettingRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalSettingRequestValidationError{} + +// Validate checks the field values on UpdatePersonalSettingResponse 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 *UpdatePersonalSettingResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalSettingResponse 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 +// UpdatePersonalSettingResponseMultiError, or nil if none found. +func (m *UpdatePersonalSettingResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalSettingResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalSettingResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalSettingResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalSettingResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalSettingResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalSettingResponseMultiError) 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 UpdatePersonalSettingResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalSettingResponseValidationError is the validation error +// returned by UpdatePersonalSettingResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalSettingResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalSettingResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalSettingResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalSettingResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalSettingResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalSettingResponseValidationError) ErrorName() string { + return "UpdatePersonalSettingResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalSettingResponseValidationError) 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 %sUpdatePersonalSettingResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalSettingResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalSettingResponseValidationError{} + +// Validate checks the field values on UpdatePersonalRoleRequest 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 *UpdatePersonalRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalRoleRequest 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 +// UpdatePersonalRoleRequestMultiError, or nil if none found. +func (m *UpdatePersonalRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalRoleRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalRoleRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalRoleRequestMultiError is an error wrapping multiple validation +// errors returned by UpdatePersonalRoleRequest.ValidateAll() if the +// designated constraints aren't met. +type UpdatePersonalRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalRoleRequestMultiError) 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 UpdatePersonalRoleRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalRoleRequestValidationError is the validation error returned by +// UpdatePersonalRoleRequest.Validate if the designated constraints aren't met. +type UpdatePersonalRoleRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalRoleRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalRoleRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalRoleRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalRoleRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalRoleRequestValidationError) ErrorName() string { + return "UpdatePersonalRoleRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalRoleRequestValidationError) 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 %sUpdatePersonalRoleRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalRoleRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalRoleRequestValidationError{} + +// Validate checks the field values on UpdatePersonalRoleResponse 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 *UpdatePersonalRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalRoleResponse 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 +// UpdatePersonalRoleResponseMultiError, or nil if none found. +func (m *UpdatePersonalRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalRoleResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalRoleResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalRoleResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalRoleResponse.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalRoleResponseMultiError) 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 UpdatePersonalRoleResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalRoleResponseValidationError is the validation error returned +// by UpdatePersonalRoleResponse.Validate if the designated constraints aren't met. +type UpdatePersonalRoleResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalRoleResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalRoleResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalRoleResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalRoleResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalRoleResponseValidationError) ErrorName() string { + return "UpdatePersonalRoleResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalRoleResponseValidationError) 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 %sUpdatePersonalRoleResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalRoleResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalRoleResponseValidationError{} + +// Validate checks the field values on ListPersonalResourcesRequest 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 *ListPersonalResourcesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalResourcesRequest 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 +// ListPersonalResourcesRequestMultiError, or nil if none found. +func (m *ListPersonalResourcesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalResourcesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Current + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + if len(errors) > 0 { + return ListPersonalResourcesRequestMultiError(errors) + } + + return nil +} + +// ListPersonalResourcesRequestMultiError is an error wrapping multiple +// validation errors returned by ListPersonalResourcesRequest.ValidateAll() if +// the designated constraints aren't met. +type ListPersonalResourcesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalResourcesRequestMultiError) 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 ListPersonalResourcesRequestMultiError) AllErrors() []error { return m } + +// ListPersonalResourcesRequestValidationError is the validation error returned +// by ListPersonalResourcesRequest.Validate if the designated constraints +// aren't met. +type ListPersonalResourcesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalResourcesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalResourcesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalResourcesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalResourcesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalResourcesRequestValidationError) ErrorName() string { + return "ListPersonalResourcesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalResourcesRequestValidationError) 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 %sListPersonalResourcesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalResourcesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalResourcesRequestValidationError{} + +// Validate checks the field values on ListPersonalResourcesResponse 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 *ListPersonalResourcesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalResourcesResponse 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 +// ListPersonalResourcesResponseMultiError, or nil if none found. +func (m *ListPersonalResourcesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalResourcesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for TotalSize + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPersonalResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for NextPageToken + + if len(errors) > 0 { + return ListPersonalResourcesResponseMultiError(errors) + } + + return nil +} + +// ListPersonalResourcesResponseMultiError is an error wrapping multiple +// validation errors returned by ListPersonalResourcesResponse.ValidateAll() +// if the designated constraints aren't met. +type ListPersonalResourcesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalResourcesResponseMultiError) 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 ListPersonalResourcesResponseMultiError) AllErrors() []error { return m } + +// ListPersonalResourcesResponseValidationError is the validation error +// returned by ListPersonalResourcesResponse.Validate if the designated +// constraints aren't met. +type ListPersonalResourcesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalResourcesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalResourcesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalResourcesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalResourcesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalResourcesResponseValidationError) ErrorName() string { + return "ListPersonalResourcesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalResourcesResponseValidationError) 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 %sListPersonalResourcesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalResourcesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalResourcesResponseValidationError{} + +// Validate checks the field values on UpdatePersonalPasswordRequest 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 *UpdatePersonalPasswordRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalPasswordRequest 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 +// UpdatePersonalPasswordRequestMultiError, or nil if none found. +func (m *UpdatePersonalPasswordRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalPasswordRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalPasswordRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalPasswordRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalPasswordRequest.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalPasswordRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalPasswordRequestMultiError) 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 UpdatePersonalPasswordRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalPasswordRequestValidationError is the validation error +// returned by UpdatePersonalPasswordRequest.Validate if the designated +// constraints aren't met. +type UpdatePersonalPasswordRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalPasswordRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalPasswordRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalPasswordRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalPasswordRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalPasswordRequestValidationError) ErrorName() string { + return "UpdatePersonalPasswordRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalPasswordRequestValidationError) 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 %sUpdatePersonalPasswordRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalPasswordRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalPasswordRequestValidationError{} + +// Validate checks the field values on UpdatePersonalPasswordResponse 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 *UpdatePersonalPasswordResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalPasswordResponse 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 +// UpdatePersonalPasswordResponseMultiError, or nil if none found. +func (m *UpdatePersonalPasswordResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalPasswordResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalPasswordResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalPasswordResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalPasswordResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalPasswordResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalPasswordResponseMultiError) 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 UpdatePersonalPasswordResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalPasswordResponseValidationError is the validation error +// returned by UpdatePersonalPasswordResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalPasswordResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalPasswordResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalPasswordResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalPasswordResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalPasswordResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalPasswordResponseValidationError) ErrorName() string { + return "UpdatePersonalPasswordResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalPasswordResponseValidationError) 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 %sUpdatePersonalPasswordResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalPasswordResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalPasswordResponseValidationError{} + +// Validate checks the field values on PersonalPasswordRestRequest 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 *PersonalPasswordRestRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalPasswordRestRequest 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 +// PersonalPasswordRestRequestMultiError, or nil if none found. +func (m *PersonalPasswordRestRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalPasswordRestRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if m.GetId() <= 0 { + err := PersonalPasswordRestRequestValidationError{ + field: "Id", + reason: "value must be greater than 0", + } + if !all { + return err + } + errors = append(errors, err) + } + + if len(errors) > 0 { + return PersonalPasswordRestRequestMultiError(errors) + } + + return nil +} + +// PersonalPasswordRestRequestMultiError is an error wrapping multiple +// validation errors returned by PersonalPasswordRestRequest.ValidateAll() if +// the designated constraints aren't met. +type PersonalPasswordRestRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalPasswordRestRequestMultiError) 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 PersonalPasswordRestRequestMultiError) AllErrors() []error { return m } + +// PersonalPasswordRestRequestValidationError is the validation error returned +// by PersonalPasswordRestRequest.Validate if the designated constraints +// aren't met. +type PersonalPasswordRestRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalPasswordRestRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalPasswordRestRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalPasswordRestRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalPasswordRestRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalPasswordRestRequestValidationError) ErrorName() string { + return "PersonalPasswordRestRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalPasswordRestRequestValidationError) 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 %sPersonalPasswordRestRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalPasswordRestRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalPasswordRestRequestValidationError{} + +// Validate checks the field values on PersonalPasswordRestResponse 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 *PersonalPasswordRestResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalPasswordRestResponse 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 +// PersonalPasswordRestResponseMultiError, or nil if none found. +func (m *PersonalPasswordRestResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalPasswordRestResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return PersonalPasswordRestResponseMultiError(errors) + } + + return nil +} + +// PersonalPasswordRestResponseMultiError is an error wrapping multiple +// validation errors returned by PersonalPasswordRestResponse.ValidateAll() if +// the designated constraints aren't met. +type PersonalPasswordRestResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalPasswordRestResponseMultiError) 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 PersonalPasswordRestResponseMultiError) AllErrors() []error { return m } + +// PersonalPasswordRestResponseValidationError is the validation error returned +// by PersonalPasswordRestResponse.Validate if the designated constraints +// aren't met. +type PersonalPasswordRestResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalPasswordRestResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalPasswordRestResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalPasswordRestResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalPasswordRestResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalPasswordRestResponseValidationError) ErrorName() string { + return "PersonalPasswordRestResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalPasswordRestResponseValidationError) 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 %sPersonalPasswordRestResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalPasswordRestResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalPasswordRestResponseValidationError{} + +// Validate checks the field values on UpdatePersonalProfileRequest 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 *UpdatePersonalProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalProfileRequest 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 +// UpdatePersonalProfileRequestMultiError, or nil if none found. +func (m *UpdatePersonalProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePersonalProfileRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePersonalProfileRequestMultiError(errors) + } + + return nil +} + +// UpdatePersonalProfileRequestMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalProfileRequest.ValidateAll() if +// the designated constraints aren't met. +type UpdatePersonalProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalProfileRequestMultiError) 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 UpdatePersonalProfileRequestMultiError) AllErrors() []error { return m } + +// UpdatePersonalProfileRequestValidationError is the validation error returned +// by UpdatePersonalProfileRequest.Validate if the designated constraints +// aren't met. +type UpdatePersonalProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalProfileRequestValidationError) ErrorName() string { + return "UpdatePersonalProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalProfileRequestValidationError) 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 %sUpdatePersonalProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalProfileRequestValidationError{} + +// Validate checks the field values on UpdatePersonalProfileResponse 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 *UpdatePersonalProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePersonalProfileResponse 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 +// UpdatePersonalProfileResponseMultiError, or nil if none found. +func (m *UpdatePersonalProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePersonalProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePersonalProfileResponseMultiError(errors) + } + + return nil +} + +// UpdatePersonalProfileResponseMultiError is an error wrapping multiple +// validation errors returned by UpdatePersonalProfileResponse.ValidateAll() +// if the designated constraints aren't met. +type UpdatePersonalProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePersonalProfileResponseMultiError) 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 UpdatePersonalProfileResponseMultiError) AllErrors() []error { return m } + +// UpdatePersonalProfileResponseValidationError is the validation error +// returned by UpdatePersonalProfileResponse.Validate if the designated +// constraints aren't met. +type UpdatePersonalProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePersonalProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePersonalProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePersonalProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePersonalProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePersonalProfileResponseValidationError) ErrorName() string { + return "UpdatePersonalProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePersonalProfileResponseValidationError) 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 %sUpdatePersonalProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePersonalProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePersonalProfileResponseValidationError{} + +// Validate checks the field values on PersonalLogoutRequest 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 *PersonalLogoutRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalLogoutRequest 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 +// PersonalLogoutRequestMultiError, or nil if none found. +func (m *PersonalLogoutRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalLogoutRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PersonalLogoutRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return PersonalLogoutRequestMultiError(errors) + } + + return nil +} + +// PersonalLogoutRequestMultiError is an error wrapping multiple validation +// errors returned by PersonalLogoutRequest.ValidateAll() if the designated +// constraints aren't met. +type PersonalLogoutRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalLogoutRequestMultiError) 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 PersonalLogoutRequestMultiError) AllErrors() []error { return m } + +// PersonalLogoutRequestValidationError is the validation error returned by +// PersonalLogoutRequest.Validate if the designated constraints aren't met. +type PersonalLogoutRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalLogoutRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalLogoutRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalLogoutRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalLogoutRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalLogoutRequestValidationError) ErrorName() string { + return "PersonalLogoutRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalLogoutRequestValidationError) 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 %sPersonalLogoutRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalLogoutRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalLogoutRequestValidationError{} + +// Validate checks the field values on PersonalLogoutResponse 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 *PersonalLogoutResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PersonalLogoutResponse 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 +// PersonalLogoutResponseMultiError, or nil if none found. +func (m *PersonalLogoutResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *PersonalLogoutResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Success + + if len(errors) > 0 { + return PersonalLogoutResponseMultiError(errors) + } + + return nil +} + +// PersonalLogoutResponseMultiError is an error wrapping multiple validation +// errors returned by PersonalLogoutResponse.ValidateAll() if the designated +// constraints aren't met. +type PersonalLogoutResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PersonalLogoutResponseMultiError) 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 PersonalLogoutResponseMultiError) AllErrors() []error { return m } + +// PersonalLogoutResponseValidationError is the validation error returned by +// PersonalLogoutResponse.Validate if the designated constraints aren't met. +type PersonalLogoutResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PersonalLogoutResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PersonalLogoutResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PersonalLogoutResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PersonalLogoutResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PersonalLogoutResponseValidationError) ErrorName() string { + return "PersonalLogoutResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e PersonalLogoutResponseValidationError) 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 %sPersonalLogoutResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PersonalLogoutResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PersonalLogoutResponseValidationError{} + +// Validate checks the field values on ListPersonalRolesRequest 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 *ListPersonalRolesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalRolesRequest 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 +// ListPersonalRolesRequestMultiError, or nil if none found. +func (m *ListPersonalRolesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalRolesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return ListPersonalRolesRequestMultiError(errors) + } + + return nil +} + +// ListPersonalRolesRequestMultiError is an error wrapping multiple validation +// errors returned by ListPersonalRolesRequest.ValidateAll() if the designated +// constraints aren't met. +type ListPersonalRolesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalRolesRequestMultiError) 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 ListPersonalRolesRequestMultiError) AllErrors() []error { return m } + +// ListPersonalRolesRequestValidationError is the validation error returned by +// ListPersonalRolesRequest.Validate if the designated constraints aren't met. +type ListPersonalRolesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalRolesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalRolesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalRolesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalRolesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalRolesRequestValidationError) ErrorName() string { + return "ListPersonalRolesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalRolesRequestValidationError) 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 %sListPersonalRolesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalRolesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalRolesRequestValidationError{} + +// Validate checks the field values on ListPersonalRolesResponse 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 *ListPersonalRolesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPersonalRolesResponse 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 +// ListPersonalRolesResponseMultiError, or nil if none found. +func (m *ListPersonalRolesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPersonalRolesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPersonalRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListPersonalRolesResponseMultiError(errors) + } + + return nil +} + +// ListPersonalRolesResponseMultiError is an error wrapping multiple validation +// errors returned by ListPersonalRolesResponse.ValidateAll() if the +// designated constraints aren't met. +type ListPersonalRolesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPersonalRolesResponseMultiError) 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 ListPersonalRolesResponseMultiError) AllErrors() []error { return m } + +// ListPersonalRolesResponseValidationError is the validation error returned by +// ListPersonalRolesResponse.Validate if the designated constraints aren't met. +type ListPersonalRolesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPersonalRolesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPersonalRolesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPersonalRolesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPersonalRolesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPersonalRolesResponseValidationError) ErrorName() string { + return "ListPersonalRolesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPersonalRolesResponseValidationError) 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 %sListPersonalRolesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPersonalRolesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPersonalRolesResponseValidationError{} + +// Validate checks the field values on GetPersonalProfileRequest 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 *GetPersonalProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPersonalProfileRequest 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 +// GetPersonalProfileRequestMultiError, or nil if none found. +func (m *GetPersonalProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPersonalProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetPersonalProfileRequestMultiError(errors) + } + + return nil +} + +// GetPersonalProfileRequestMultiError is an error wrapping multiple validation +// errors returned by GetPersonalProfileRequest.ValidateAll() if the +// designated constraints aren't met. +type GetPersonalProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPersonalProfileRequestMultiError) 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 GetPersonalProfileRequestMultiError) AllErrors() []error { return m } + +// GetPersonalProfileRequestValidationError is the validation error returned by +// GetPersonalProfileRequest.Validate if the designated constraints aren't met. +type GetPersonalProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPersonalProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPersonalProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPersonalProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPersonalProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPersonalProfileRequestValidationError) ErrorName() string { + return "GetPersonalProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPersonalProfileRequestValidationError) 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 %sGetPersonalProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPersonalProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPersonalProfileRequestValidationError{} + +// Validate checks the field values on GetPersonalProfileResponse 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 *GetPersonalProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPersonalProfileResponse 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 +// GetPersonalProfileResponseMultiError, or nil if none found. +func (m *GetPersonalProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPersonalProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetPersonalProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetPersonalProfileResponseMultiError(errors) + } + + return nil +} + +// GetPersonalProfileResponseMultiError is an error wrapping multiple +// validation errors returned by GetPersonalProfileResponse.ValidateAll() if +// the designated constraints aren't met. +type GetPersonalProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPersonalProfileResponseMultiError) 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 GetPersonalProfileResponseMultiError) AllErrors() []error { return m } + +// GetPersonalProfileResponseValidationError is the validation error returned +// by GetPersonalProfileResponse.Validate if the designated constraints aren't met. +type GetPersonalProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPersonalProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPersonalProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPersonalProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPersonalProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPersonalProfileResponseValidationError) ErrorName() string { + return "GetPersonalProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPersonalProfileResponseValidationError) 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 %sGetPersonalProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPersonalProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPersonalProfileResponseValidationError{} + +// Validate checks the field values on RefreshPersonalTokenRequest 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 *RefreshPersonalTokenRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RefreshPersonalTokenRequest 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 +// RefreshPersonalTokenRequestMultiError, or nil if none found. +func (m *RefreshPersonalTokenRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *RefreshPersonalTokenRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RefreshPersonalTokenRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RefreshPersonalTokenRequestMultiError(errors) + } + + return nil +} + +// RefreshPersonalTokenRequestMultiError is an error wrapping multiple +// validation errors returned by RefreshPersonalTokenRequest.ValidateAll() if +// the designated constraints aren't met. +type RefreshPersonalTokenRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RefreshPersonalTokenRequestMultiError) 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 RefreshPersonalTokenRequestMultiError) AllErrors() []error { return m } + +// RefreshPersonalTokenRequestValidationError is the validation error returned +// by RefreshPersonalTokenRequest.Validate if the designated constraints +// aren't met. +type RefreshPersonalTokenRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RefreshPersonalTokenRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RefreshPersonalTokenRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RefreshPersonalTokenRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RefreshPersonalTokenRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RefreshPersonalTokenRequestValidationError) ErrorName() string { + return "RefreshPersonalTokenRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e RefreshPersonalTokenRequestValidationError) 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 %sRefreshPersonalTokenRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RefreshPersonalTokenRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RefreshPersonalTokenRequestValidationError{} + +// Validate checks the field values on RefreshPersonalTokenResponse 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 *RefreshPersonalTokenResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RefreshPersonalTokenResponse 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 +// RefreshPersonalTokenResponseMultiError, or nil if none found. +func (m *RefreshPersonalTokenResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *RefreshPersonalTokenResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Token + + if len(errors) > 0 { + return RefreshPersonalTokenResponseMultiError(errors) + } + + return nil +} + +// RefreshPersonalTokenResponseMultiError is an error wrapping multiple +// validation errors returned by RefreshPersonalTokenResponse.ValidateAll() if +// the designated constraints aren't met. +type RefreshPersonalTokenResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RefreshPersonalTokenResponseMultiError) 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 RefreshPersonalTokenResponseMultiError) AllErrors() []error { return m } + +// RefreshPersonalTokenResponseValidationError is the validation error returned +// by RefreshPersonalTokenResponse.Validate if the designated constraints +// aren't met. +type RefreshPersonalTokenResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RefreshPersonalTokenResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RefreshPersonalTokenResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RefreshPersonalTokenResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RefreshPersonalTokenResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RefreshPersonalTokenResponseValidationError) ErrorName() string { + return "RefreshPersonalTokenResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e RefreshPersonalTokenResponseValidationError) 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 %sRefreshPersonalTokenResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RefreshPersonalTokenResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RefreshPersonalTokenResponseValidationError{} diff --git a/api/v1/services/message/message_bridge.pb.go b/api/v1/services/message/message_bridge.pb.go new file mode 100644 index 00000000..14cefe32 --- /dev/null +++ b/api/v1/services/message/message_bridge.pb.go @@ -0,0 +1,565 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: message/message.proto + +package message + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const PersonalServiceGetPersonalProfileBridgeOperation = "/api.v1.services.message.PersonalService/GetPersonalProfile" +const PersonalServiceListPersonalResourcesBridgeOperation = "/api.v1.services.message.PersonalService/ListPersonalResources" +const PersonalServiceListPersonalRolesBridgeOperation = "/api.v1.services.message.PersonalService/ListPersonalRoles" +const PersonalServicePersonalLogoutBridgeOperation = "/api.v1.services.message.PersonalService/PersonalLogout" +const PersonalServiceRefreshPersonalTokenBridgeOperation = "/api.v1.services.message.PersonalService/RefreshPersonalToken" +const PersonalServiceUpdatePersonalPasswordBridgeOperation = "/api.v1.services.message.PersonalService/UpdatePersonalPassword" +const PersonalServiceUpdatePersonalProfileBridgeOperation = "/api.v1.services.message.PersonalService/UpdatePersonalProfile" +const PersonalServiceUpdatePersonalSettingBridgeOperation = "/api.v1.services.message.PersonalService/UpdatePersonalSetting" + +type PersonalServiceBridgeServer interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) +} + +type PersonalServiceHooker interface { + PersonalServiceGetPersonalProfileHooker + PersonalServiceListPersonalResourcesHooker + PersonalServiceListPersonalRolesHooker + PersonalServicePersonalLogoutHooker + PersonalServiceRefreshPersonalTokenHooker + PersonalServiceUpdatePersonalPasswordHooker + PersonalServiceUpdatePersonalProfileHooker + PersonalServiceUpdatePersonalSettingHooker +} + +type PersonalServiceHookedBridger interface { + PersonalServiceHooker + PersonalServiceBridgeServer +} +type PersonalServiceGetPersonalProfileHooker interface { + PrepareGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) + CompleteGetPersonalProfile(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error +} +type PersonalServiceListPersonalResourcesHooker interface { + PrepareListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) + CompleteListPersonalResources(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error +} +type PersonalServiceListPersonalRolesHooker interface { + PrepareListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) + CompleteListPersonalRoles(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error +} +type PersonalServicePersonalLogoutHooker interface { + PreparePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) + CompletePersonalLogout(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error +} +type PersonalServiceRefreshPersonalTokenHooker interface { + PrepareRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) + CompleteRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error +} +type PersonalServiceUpdatePersonalPasswordHooker interface { + PrepareUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) + CompleteUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error +} +type PersonalServiceUpdatePersonalProfileHooker interface { + PrepareUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) + CompleteUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error +} +type PersonalServiceUpdatePersonalSettingHooker interface { + PrepareUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) + CompleteUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error +} + +func RegisterPersonalServiceBridgeServer(s *http.Server, srv PersonalServiceHookedBridger) { + r := s.Route("/") + r.GET("/message/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) + r.GET("/message/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) + r.GET("/message/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) + r.POST("/message/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(srv)) + r.POST("/message/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv)) + r.PUT("/message/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv)) + r.PUT("/message/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv)) + r.PUT("/message/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv)) +} + +func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPersonalProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + }) + + newctx, err := srv.PrepareGetPersonalProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetPersonalProfile(ctx, &in, out.(*GetPersonalProfileResponse)) + } +} + +func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + }) + + newctx, err := srv.PrepareListPersonalResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPersonalResources(ctx, &in, out.(*ListPersonalResourcesResponse)) + } +} + +func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + }) + + newctx, err := srv.PrepareListPersonalRoles(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPersonalRoles(ctx, &in, out.(*ListPersonalRolesResponse)) + } +} + +func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in PersonalLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServicePersonalLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + }) + + newctx, err := srv.PreparePersonalLogout(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompletePersonalLogout(ctx, &in, out.(*PersonalLogoutResponse)) + } +} + +func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RefreshPersonalTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + }) + + newctx, err := srv.PrepareRefreshPersonalToken(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteRefreshPersonalToken(ctx, &in, out.(*RefreshPersonalTokenResponse)) + } +} + +func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalPassword(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalPassword(ctx, &in, out.(*UpdatePersonalPasswordResponse)) + } +} + +func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalProfileRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalProfile(ctx, &in, out.(*UpdatePersonalProfileResponse)) + } +} + +func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalSettingRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + }) + + newctx, err := srv.PrepareUpdatePersonalSetting(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePersonalSetting(ctx, &in, out.(*UpdatePersonalSettingResponse)) + } +} + +// UnimplementedPersonalServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPersonalServiceHooked struct{} + +func (UnimplementedPersonalServiceHooked) PrepareGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PreparePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompletePersonalLogout(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { + return ctx.Result(200, out) +} + +func WithPersonalServiceHook(h PersonalServiceHooker) func(PersonalServiceBridgeServer) PersonalServiceHookedBridger { + return func(srv PersonalServiceBridgeServer) PersonalServiceHookedBridger { + return PersonalServiceHookedBridge{PersonalServiceBridgeServer: srv, PersonalServiceHooker: h} + } +} + +// PersonalServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PersonalService. +// It implements the HTTP and gRPC implementations of PersonalService. +// It forwards requests and responses between the two implementations. +type PersonalServiceHookedBridge struct { + PersonalServiceBridgeServer + PersonalServiceHooker +} + +type PersonalServiceHTTPBridgeImpl struct { + client PersonalServiceHTTPClient +} + +func NewPersonalServiceHTTPBridge(client *http.Client) PersonalServiceHTTPServer { + return &PersonalServiceHTTPBridgeImpl{client: NewPersonalServiceHTTPClient(client)} +} + +func (c *PersonalServiceHTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +type PersonalServiceBridgeImpl struct { + client PersonalServiceClient +} + +func NewPersonalServiceBridge(client grpc.ClientConnInterface) PersonalServiceServer { + return &PersonalServiceBridgeImpl{client: NewPersonalServiceClient(client)} +} + +func (c *PersonalServiceBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +func (c *PersonalServiceBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} + +type PersonalServiceGRPC2HTTPBridgeImpl struct { + client PersonalServiceClient +} + +func NewPersonalServiceGRPC2HTTP(client grpc.ClientConnInterface) PersonalServiceHTTPServer { + return &PersonalServiceGRPC2HTTPBridgeImpl{client: NewPersonalServiceClient(client)} +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +type PersonalServiceHTTP2GRPCBridgeImpl struct { + client PersonalServiceHTTPClient +} + +func NewPersonalServiceHTTP2GRPC(client *http.Client) PersonalServiceServer { + return &PersonalServiceHTTP2GRPCBridgeImpl{client: NewPersonalServiceHTTPClient(client)} +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return c.client.GetPersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return c.client.ListPersonalResources(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return c.client.ListPersonalRoles(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return c.client.PersonalLogout(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return c.client.RefreshPersonalToken(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return c.client.UpdatePersonalPassword(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return c.client.UpdatePersonalProfile(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return c.client.UpdatePersonalSetting(ctx, in) +} + +func (c *PersonalServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} diff --git a/api/v1/services/message/message_grpc.pb.go b/api/v1/services/message/message_grpc.pb.go new file mode 100644 index 00000000..2e0bc3e2 --- /dev/null +++ b/api/v1/services/message/message_grpc.pb.go @@ -0,0 +1,407 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: message/message.proto + +package message + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + PersonalService_GetPersonalProfile_FullMethodName = "/api.v1.services.message.PersonalService/GetPersonalProfile" + PersonalService_ListPersonalResources_FullMethodName = "/api.v1.services.message.PersonalService/ListPersonalResources" + PersonalService_ListPersonalRoles_FullMethodName = "/api.v1.services.message.PersonalService/ListPersonalRoles" + PersonalService_PersonalLogout_FullMethodName = "/api.v1.services.message.PersonalService/PersonalLogout" + PersonalService_RefreshPersonalToken_FullMethodName = "/api.v1.services.message.PersonalService/RefreshPersonalToken" + PersonalService_UpdatePersonalPassword_FullMethodName = "/api.v1.services.message.PersonalService/UpdatePersonalPassword" + PersonalService_UpdatePersonalProfile_FullMethodName = "/api.v1.services.message.PersonalService/UpdatePersonalProfile" + PersonalService_UpdatePersonalSetting_FullMethodName = "/api.v1.services.message.PersonalService/UpdatePersonalSetting" +) + +// PersonalServiceClient is the client API for PersonalService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// PersonalService Personal user service +type PersonalServiceClient interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) +} + +type personalServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPersonalServiceClient(cc grpc.ClientConnInterface) PersonalServiceClient { + return &personalServiceClient{cc} +} + +func (c *personalServiceClient) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetPersonalProfileResponse) + err := c.cc.Invoke(ctx, PersonalService_GetPersonalProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPersonalResourcesResponse) + err := c.cc.Invoke(ctx, PersonalService_ListPersonalResources_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPersonalRolesResponse) + err := c.cc.Invoke(ctx, PersonalService_ListPersonalRoles_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(PersonalLogoutResponse) + err := c.cc.Invoke(ctx, PersonalService_PersonalLogout_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RefreshPersonalTokenResponse) + err := c.cc.Invoke(ctx, PersonalService_RefreshPersonalToken_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalPasswordResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalPassword_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalProfileResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *personalServiceClient) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePersonalSettingResponse) + err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalSetting_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PersonalServiceServer is the server API for PersonalService service. +// All implementations must embed UnimplementedPersonalServiceServer +// for forward compatibility. +// +// PersonalService Personal user service +type PersonalServiceServer interface { + // GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) + mustEmbedUnimplementedPersonalServiceServer() +} + +// UnimplementedPersonalServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPersonalServiceServer struct{} + +func (UnimplementedPersonalServiceServer) GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPersonalProfile not implemented") +} +func (UnimplementedPersonalServiceServer) ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPersonalResources not implemented") +} +func (UnimplementedPersonalServiceServer) ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPersonalRoles not implemented") +} +func (UnimplementedPersonalServiceServer) PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PersonalLogout not implemented") +} +func (UnimplementedPersonalServiceServer) RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RefreshPersonalToken not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalPassword not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalProfile not implemented") +} +func (UnimplementedPersonalServiceServer) UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalSetting not implemented") +} +func (UnimplementedPersonalServiceServer) mustEmbedUnimplementedPersonalServiceServer() {} +func (UnimplementedPersonalServiceServer) testEmbeddedByValue() {} + +// UnsafePersonalServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PersonalServiceServer will +// result in compilation errors. +type UnsafePersonalServiceServer interface { + mustEmbedUnimplementedPersonalServiceServer() +} + +func RegisterPersonalServiceServer(s grpc.ServiceRegistrar, srv PersonalServiceServer) { + // If the following call pancis, it indicates UnimplementedPersonalServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&PersonalService_ServiceDesc, srv) +} + +func _PersonalService_GetPersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPersonalProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).GetPersonalProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_GetPersonalProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_ListPersonalResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPersonalResourcesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).ListPersonalResources(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_ListPersonalResources_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_ListPersonalRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPersonalRolesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).ListPersonalRoles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_ListPersonalRoles_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_PersonalLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PersonalLogoutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).PersonalLogout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_PersonalLogout_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_RefreshPersonalToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RefreshPersonalTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_RefreshPersonalToken_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalPasswordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalPassword_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PersonalService_UpdatePersonalSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePersonalSettingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PersonalService_UpdatePersonalSetting_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// PersonalService_ServiceDesc is the grpc.ServiceDesc for PersonalService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PersonalService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.message.PersonalService", + HandlerType: (*PersonalServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetPersonalProfile", + Handler: _PersonalService_GetPersonalProfile_Handler, + }, + { + MethodName: "ListPersonalResources", + Handler: _PersonalService_ListPersonalResources_Handler, + }, + { + MethodName: "ListPersonalRoles", + Handler: _PersonalService_ListPersonalRoles_Handler, + }, + { + MethodName: "PersonalLogout", + Handler: _PersonalService_PersonalLogout_Handler, + }, + { + MethodName: "RefreshPersonalToken", + Handler: _PersonalService_RefreshPersonalToken_Handler, + }, + { + MethodName: "UpdatePersonalPassword", + Handler: _PersonalService_UpdatePersonalPassword_Handler, + }, + { + MethodName: "UpdatePersonalProfile", + Handler: _PersonalService_UpdatePersonalProfile_Handler, + }, + { + MethodName: "UpdatePersonalSetting", + Handler: _PersonalService_UpdatePersonalSetting_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "message/message.proto", +} diff --git a/api/v1/services/message/message_http.pb.go b/api/v1/services/message/message_http.pb.go new file mode 100644 index 00000000..a01701c9 --- /dev/null +++ b/api/v1/services/message/message_http.pb.go @@ -0,0 +1,366 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: message/message.proto + +package message + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationPersonalServiceGetPersonalProfile = "/api.v1.services.message.PersonalService/GetPersonalProfile" +const OperationPersonalServiceListPersonalResources = "/api.v1.services.message.PersonalService/ListPersonalResources" +const OperationPersonalServiceListPersonalRoles = "/api.v1.services.message.PersonalService/ListPersonalRoles" +const OperationPersonalServicePersonalLogout = "/api.v1.services.message.PersonalService/PersonalLogout" +const OperationPersonalServiceRefreshPersonalToken = "/api.v1.services.message.PersonalService/RefreshPersonalToken" +const OperationPersonalServiceUpdatePersonalPassword = "/api.v1.services.message.PersonalService/UpdatePersonalPassword" +const OperationPersonalServiceUpdatePersonalProfile = "/api.v1.services.message.PersonalService/UpdatePersonalProfile" +const OperationPersonalServiceUpdatePersonalSetting = "/api.v1.services.message.PersonalService/UpdatePersonalSetting" + +type PersonalServiceHTTPServer interface { + // GetPersonalProfile GetPersonalProfile Update the personal user information + GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) + // ListPersonalResources ListPersonalResources List the personal user's menu + ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) + // ListPersonalRoles ListPersonalResources List the personal user's menu + ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) + // PersonalLogout PersonalLogout Personal user logs out + PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) + // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) + // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) + // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) + // UpdatePersonalSetting UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) +} + +func RegisterPersonalServiceHTTPServer(s *http.Server, srv PersonalServiceHTTPServer) { + r := s.Route("/") + r.GET("/message/personal/profile", _PersonalService_GetPersonalProfile0_HTTP_Handler(srv)) + r.GET("/message/personal/resources", _PersonalService_ListPersonalResources0_HTTP_Handler(srv)) + r.GET("/message/personal/roles", _PersonalService_ListPersonalRoles0_HTTP_Handler(srv)) + r.POST("/message/personal/logout", _PersonalService_PersonalLogout0_HTTP_Handler(srv)) + r.POST("/message/personal/token/refresh", _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv)) + r.PUT("/message/personal/password", _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv)) + r.PUT("/message/personal/profile", _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv)) + r.PUT("/message/personal/setting", _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv)) +} + +func _PersonalService_GetPersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPersonalProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetPersonalProfileResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_ListPersonalResources0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPersonalResourcesResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_ListPersonalRoles0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPersonalRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPersonalRolesResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_PersonalLogout0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in PersonalLogoutRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServicePersonalLogout) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*PersonalLogoutResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in RefreshPersonalTokenRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*RefreshPersonalTokenResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalPasswordResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalProfileRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalProfileResponse) + return ctx.Result(200, reply) + } +} + +func _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePersonalSettingRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePersonalSettingResponse) + return ctx.Result(200, reply) + } +} + +type PersonalServiceHTTPClient interface { + // GetPersonalProfile GetPersonalProfile Update the personal user information + GetPersonalProfile(ctx context.Context, req *GetPersonalProfileRequest, opts ...http.CallOption) (rsp *GetPersonalProfileResponse, err error) + // ListPersonalResources ListPersonalResources List the personal user's menu + ListPersonalResources(ctx context.Context, req *ListPersonalResourcesRequest, opts ...http.CallOption) (rsp *ListPersonalResourcesResponse, err error) + // ListPersonalRoles ListPersonalResources List the personal user's menu + ListPersonalRoles(ctx context.Context, req *ListPersonalRolesRequest, opts ...http.CallOption) (rsp *ListPersonalRolesResponse, err error) + // PersonalLogout PersonalLogout Personal user logs out + PersonalLogout(ctx context.Context, req *PersonalLogoutRequest, opts ...http.CallOption) (rsp *PersonalLogoutResponse, err error) + // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token + RefreshPersonalToken(ctx context.Context, req *RefreshPersonalTokenRequest, opts ...http.CallOption) (rsp *RefreshPersonalTokenResponse, err error) + // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password + UpdatePersonalPassword(ctx context.Context, req *UpdatePersonalPasswordRequest, opts ...http.CallOption) (rsp *UpdatePersonalPasswordResponse, err error) + // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information + UpdatePersonalProfile(ctx context.Context, req *UpdatePersonalProfileRequest, opts ...http.CallOption) (rsp *UpdatePersonalProfileResponse, err error) + // UpdatePersonalSetting UpdatePersonalSetting User settings are saved + UpdatePersonalSetting(ctx context.Context, req *UpdatePersonalSettingRequest, opts ...http.CallOption) (rsp *UpdatePersonalSettingResponse, err error) +} + +type PersonalServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewPersonalServiceHTTPClient(client *http.Client) PersonalServiceHTTPClient { + return &PersonalServiceHTTPClientImpl{client} +} + +// GetPersonalProfile GetPersonalProfile Update the personal user information +func (c *PersonalServiceHTTPClientImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...http.CallOption) (*GetPersonalProfileResponse, error) { + var out GetPersonalProfileResponse + pattern := "/message/personal/profile" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceGetPersonalProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ListPersonalResources ListPersonalResources List the personal user's menu +func (c *PersonalServiceHTTPClientImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...http.CallOption) (*ListPersonalResourcesResponse, error) { + var out ListPersonalResourcesResponse + pattern := "/message/personal/resources" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceListPersonalResources)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ListPersonalRoles ListPersonalResources List the personal user's menu +func (c *PersonalServiceHTTPClientImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...http.CallOption) (*ListPersonalRolesResponse, error) { + var out ListPersonalRolesResponse + pattern := "/message/personal/roles" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPersonalServiceListPersonalRoles)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// PersonalLogout PersonalLogout Personal user logs out +func (c *PersonalServiceHTTPClientImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...http.CallOption) (*PersonalLogoutResponse, error) { + var out PersonalLogoutResponse + pattern := "/message/personal/logout" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServicePersonalLogout)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token +func (c *PersonalServiceHTTPClientImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...http.CallOption) (*RefreshPersonalTokenResponse, error) { + var out RefreshPersonalTokenResponse + pattern := "/message/personal/token/refresh" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceRefreshPersonalToken)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...http.CallOption) (*UpdatePersonalPasswordResponse, error) { + var out UpdatePersonalPasswordResponse + pattern := "/message/personal/password" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalPassword)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdatePersonalProfile UpdatePersonalProfile Update the personal user information +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...http.CallOption) (*UpdatePersonalProfileResponse, error) { + var out UpdatePersonalProfileResponse + pattern := "/message/personal/profile" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdatePersonalSetting UpdatePersonalSetting User settings are saved +func (c *PersonalServiceHTTPClientImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...http.CallOption) (*UpdatePersonalSettingResponse, error) { + var out UpdatePersonalSettingResponse + pattern := "/message/personal/setting" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalSetting)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/system/department.pb.go b/api/v1/services/system/department.pb.go new file mode 100644 index 00000000..7df2a2f1 --- /dev/null +++ b/api/v1/services/system/department.pb.go @@ -0,0 +1,746 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: system/department.proto + +package system + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListDepartmentsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The page number. + Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // The keyword is the query parameter for set only to query the department by keyword + Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListDepartmentsRequest) Reset() { + *x = ListDepartmentsRequest{} + mi := &file_system_department_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListDepartmentsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDepartmentsRequest) ProtoMessage() {} + +func (x *ListDepartmentsRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_department_proto_msgTypes[0] + 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 ListDepartmentsRequest.ProtoReflect.Descriptor instead. +func (*ListDepartmentsRequest) Descriptor() ([]byte, []int) { + return file_system_department_proto_rawDescGZIP(), []int{0} +} + +func (x *ListDepartmentsRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListDepartmentsRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListDepartmentsRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListDepartmentsRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListDepartmentsRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListDepartmentsRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListDepartmentsRequest) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +type ListDepartmentsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` + // The paging menus + Departments []*types.Department `protobuf:"bytes,2,rep,name=departments,proto3" json:"departments,omitempty"` + // The page number. + Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the page data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListDepartmentsResponse) Reset() { + *x = ListDepartmentsResponse{} + mi := &file_system_department_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListDepartmentsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListDepartmentsResponse) ProtoMessage() {} + +func (x *ListDepartmentsResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_department_proto_msgTypes[1] + 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 ListDepartmentsResponse.ProtoReflect.Descriptor instead. +func (*ListDepartmentsResponse) Descriptor() ([]byte, []int) { + return file_system_department_proto_rawDescGZIP(), []int{1} +} + +func (x *ListDepartmentsResponse) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *ListDepartmentsResponse) GetDepartments() []*types.Department { + if x != nil { + return x.Departments + } + return nil +} + +func (x *ListDepartmentsResponse) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListDepartmentsResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListDepartmentsResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListDepartmentsResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +type GetDepartmentRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the resource requested, for example: + // "shelves/shelf1/departments/department2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDepartmentRequest) Reset() { + *x = GetDepartmentRequest{} + mi := &file_system_department_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDepartmentRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDepartmentRequest) ProtoMessage() {} + +func (x *GetDepartmentRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_department_proto_msgTypes[2] + 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 GetDepartmentRequest.ProtoReflect.Descriptor instead. +func (*GetDepartmentRequest) Descriptor() ([]byte, []int) { + return file_system_department_proto_rawDescGZIP(), []int{2} +} + +func (x *GetDepartmentRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type GetDepartmentResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Department *types.Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetDepartmentResponse) Reset() { + *x = GetDepartmentResponse{} + mi := &file_system_department_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetDepartmentResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetDepartmentResponse) ProtoMessage() {} + +func (x *GetDepartmentResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_department_proto_msgTypes[3] + 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 GetDepartmentResponse.ProtoReflect.Descriptor instead. +func (*GetDepartmentResponse) Descriptor() ([]byte, []int) { + return file_system_department_proto_rawDescGZIP(), []int{3} +} + +func (x *GetDepartmentResponse) GetDepartment() *types.Department { + if x != nil { + return x.Department + } + return nil +} + +type CreateDepartmentRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id where the department is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The department id to use for this department. + DepartmentId string `protobuf:"bytes,3,opt,name=department_id,proto3" json:"department_id,omitempty"` + // The department resource to create. + // The field id should match the Noun in the method id. + Department *types.Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateDepartmentRequest) Reset() { + *x = CreateDepartmentRequest{} + mi := &file_system_department_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateDepartmentRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateDepartmentRequest) ProtoMessage() {} + +func (x *CreateDepartmentRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_department_proto_msgTypes[4] + 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 CreateDepartmentRequest.ProtoReflect.Descriptor instead. +func (*CreateDepartmentRequest) Descriptor() ([]byte, []int) { + return file_system_department_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateDepartmentRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateDepartmentRequest) GetDepartmentId() string { + if x != nil { + return x.DepartmentId + } + return "" +} + +func (x *CreateDepartmentRequest) GetDepartment() *types.Department { + if x != nil { + return x.Department + } + return nil +} + +type CreateDepartmentResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Department *types.Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateDepartmentResponse) Reset() { + *x = CreateDepartmentResponse{} + mi := &file_system_department_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateDepartmentResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateDepartmentResponse) ProtoMessage() {} + +func (x *CreateDepartmentResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_department_proto_msgTypes[5] + 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 CreateDepartmentResponse.ProtoReflect.Descriptor instead. +func (*CreateDepartmentResponse) Descriptor() ([]byte, []int) { + return file_system_department_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateDepartmentResponse) GetDepartment() *types.Department { + if x != nil { + return x.Department + } + return nil +} + +type UpdateDepartmentRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The department id to use for this department. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The department resource which replaces the resource on the server. + Department *types.Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateDepartmentRequest) Reset() { + *x = UpdateDepartmentRequest{} + mi := &file_system_department_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateDepartmentRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateDepartmentRequest) ProtoMessage() {} + +func (x *UpdateDepartmentRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_department_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 UpdateDepartmentRequest.ProtoReflect.Descriptor instead. +func (*UpdateDepartmentRequest) Descriptor() ([]byte, []int) { + return file_system_department_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateDepartmentRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateDepartmentRequest) GetDepartment() *types.Department { + if x != nil { + return x.Department + } + return nil +} + +type UpdateDepartmentResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Department *types.Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateDepartmentResponse) Reset() { + *x = UpdateDepartmentResponse{} + mi := &file_system_department_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateDepartmentResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateDepartmentResponse) ProtoMessage() {} + +func (x *UpdateDepartmentResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_department_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateDepartmentResponse.ProtoReflect.Descriptor instead. +func (*UpdateDepartmentResponse) Descriptor() ([]byte, []int) { + return file_system_department_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateDepartmentResponse) GetDepartment() *types.Department { + if x != nil { + return x.Department + } + return nil +} + +type DeleteDepartmentRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The resource id of the department to be deleted, for example: + // "shelves/shelf1/departments/department2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteDepartmentRequest) Reset() { + *x = DeleteDepartmentRequest{} + mi := &file_system_department_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteDepartmentRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteDepartmentRequest) ProtoMessage() {} + +func (x *DeleteDepartmentRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_department_proto_msgTypes[8] + 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 DeleteDepartmentRequest.ProtoReflect.Descriptor instead. +func (*DeleteDepartmentRequest) Descriptor() ([]byte, []int) { + return file_system_department_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteDepartmentRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type DeleteDepartmentResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteDepartmentResponse) Reset() { + *x = DeleteDepartmentResponse{} + mi := &file_system_department_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteDepartmentResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteDepartmentResponse) ProtoMessage() {} + +func (x *DeleteDepartmentResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_department_proto_msgTypes[9] + 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 DeleteDepartmentResponse.ProtoReflect.Descriptor instead. +func (*DeleteDepartmentResponse) Descriptor() ([]byte, []int) { + return file_system_department_proto_rawDescGZIP(), []int{9} +} + +func (x *DeleteDepartmentResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_system_department_proto protoreflect.FileDescriptor + +const file_system_department_proto_rawDesc = "" + + "\n" + + "\x17system/department.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xd2\x01\n" + + "\x16ListDepartmentsRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x18\n" + + "\akeyword\x18\a \x01(\tR\akeyword\"\x8b\x02\n" + + "\x17ListDepartmentsResponse\x12\x14\n" + + "\x05total\x18\x01 \x01(\x05R\x05total\x12C\n" + + "\vdepartments\x18\x02 \x03(\v2!.api.v1.services.types.DepartmentR\vdepartments\x12\x12\n" + + "\x04page\x18\x03 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"&\n" + + "\x14GetDepartmentRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"Z\n" + + "\x15GetDepartmentResponse\x12A\n" + + "\n" + + "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\"\x9a\x01\n" + + "\x17CreateDepartmentRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12$\n" + + "\rdepartment_id\x18\x03 \x01(\tR\rdepartment_id\x12A\n" + + "\n" + + "department\x18\x02 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\"]\n" + + "\x18CreateDepartmentResponse\x12A\n" + + "\n" + + "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\"l\n" + + "\x17UpdateDepartmentRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12A\n" + + "\n" + + "department\x18\x02 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\"]\n" + + "\x18UpdateDepartmentResponse\x12A\n" + + "\n" + + "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\")\n" + + "\x17DeleteDepartmentRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + + "\x18DeleteDepartmentResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x93\x06\n" + + "\x11DepartmentService\x12\x8c\x01\n" + + "\x0fListDepartments\x12..api.v1.services.system.ListDepartmentsRequest\x1a/.api.v1.services.system.ListDepartmentsResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/departments\x12\x8b\x01\n" + + "\rGetDepartment\x12,.api.v1.services.system.GetDepartmentRequest\x1a-.api.v1.services.system.GetDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/departments/{id}\x12\x9b\x01\n" + + "\x10CreateDepartment\x12/.api.v1.services.system.CreateDepartmentRequest\x1a0.api.v1.services.system.CreateDepartmentResponse\"$\x82\xd3\xe4\x93\x02\x1e:\n" + + "department\"\x10/sys/departments\x12\xab\x01\n" + + "\x10UpdateDepartment\x12/.api.v1.services.system.UpdateDepartmentRequest\x1a0.api.v1.services.system.UpdateDepartmentResponse\"4\x82\xd3\xe4\x93\x02.:\n" + + "department\x1a /sys/departments/{department.id}\x12\x94\x01\n" + + "\x10DeleteDepartment\x12/.api.v1.services.system.DeleteDepartmentRequest\x1a0.api.v1.services.system.DeleteDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/departments/{id}B\xe4\x01\n" + + "\x1acom.api.v1.services.systemB\x0fDepartmentProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + +var ( + file_system_department_proto_rawDescOnce sync.Once + file_system_department_proto_rawDescData []byte +) + +func file_system_department_proto_rawDescGZIP() []byte { + file_system_department_proto_rawDescOnce.Do(func() { + file_system_department_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_department_proto_rawDesc), len(file_system_department_proto_rawDesc))) + }) + return file_system_department_proto_rawDescData +} + +var file_system_department_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_system_department_proto_goTypes = []any{ + (*ListDepartmentsRequest)(nil), // 0: api.v1.services.system.ListDepartmentsRequest + (*ListDepartmentsResponse)(nil), // 1: api.v1.services.system.ListDepartmentsResponse + (*GetDepartmentRequest)(nil), // 2: api.v1.services.system.GetDepartmentRequest + (*GetDepartmentResponse)(nil), // 3: api.v1.services.system.GetDepartmentResponse + (*CreateDepartmentRequest)(nil), // 4: api.v1.services.system.CreateDepartmentRequest + (*CreateDepartmentResponse)(nil), // 5: api.v1.services.system.CreateDepartmentResponse + (*UpdateDepartmentRequest)(nil), // 6: api.v1.services.system.UpdateDepartmentRequest + (*UpdateDepartmentResponse)(nil), // 7: api.v1.services.system.UpdateDepartmentResponse + (*DeleteDepartmentRequest)(nil), // 8: api.v1.services.system.DeleteDepartmentRequest + (*DeleteDepartmentResponse)(nil), // 9: api.v1.services.system.DeleteDepartmentResponse + (*types.Department)(nil), // 10: api.v1.services.types.Department + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_system_department_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.system.ListDepartmentsResponse.departments:type_name -> api.v1.services.types.Department + 11, // 1: api.v1.services.system.ListDepartmentsResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.system.GetDepartmentResponse.department:type_name -> api.v1.services.types.Department + 10, // 3: api.v1.services.system.CreateDepartmentRequest.department:type_name -> api.v1.services.types.Department + 10, // 4: api.v1.services.system.CreateDepartmentResponse.department:type_name -> api.v1.services.types.Department + 10, // 5: api.v1.services.system.UpdateDepartmentRequest.department:type_name -> api.v1.services.types.Department + 10, // 6: api.v1.services.system.UpdateDepartmentResponse.department:type_name -> api.v1.services.types.Department + 12, // 7: api.v1.services.system.DeleteDepartmentResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.system.DepartmentService.ListDepartments:input_type -> api.v1.services.system.ListDepartmentsRequest + 2, // 9: api.v1.services.system.DepartmentService.GetDepartment:input_type -> api.v1.services.system.GetDepartmentRequest + 4, // 10: api.v1.services.system.DepartmentService.CreateDepartment:input_type -> api.v1.services.system.CreateDepartmentRequest + 6, // 11: api.v1.services.system.DepartmentService.UpdateDepartment:input_type -> api.v1.services.system.UpdateDepartmentRequest + 8, // 12: api.v1.services.system.DepartmentService.DeleteDepartment:input_type -> api.v1.services.system.DeleteDepartmentRequest + 1, // 13: api.v1.services.system.DepartmentService.ListDepartments:output_type -> api.v1.services.system.ListDepartmentsResponse + 3, // 14: api.v1.services.system.DepartmentService.GetDepartment:output_type -> api.v1.services.system.GetDepartmentResponse + 5, // 15: api.v1.services.system.DepartmentService.CreateDepartment:output_type -> api.v1.services.system.CreateDepartmentResponse + 7, // 16: api.v1.services.system.DepartmentService.UpdateDepartment:output_type -> api.v1.services.system.UpdateDepartmentResponse + 9, // 17: api.v1.services.system.DepartmentService.DeleteDepartment:output_type -> api.v1.services.system.DeleteDepartmentResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_system_department_proto_init() } +func file_system_department_proto_init() { + if File_system_department_proto != nil { + return + } + file_system_department_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_department_proto_rawDesc), len(file_system_department_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_system_department_proto_goTypes, + DependencyIndexes: file_system_department_proto_depIdxs, + MessageInfos: file_system_department_proto_msgTypes, + }.Build() + File_system_department_proto = out.File + file_system_department_proto_goTypes = nil + file_system_department_proto_depIdxs = nil +} diff --git a/api/v1/services/system/department.pb.gw.go b/api/v1/services/system/department.pb.gw.go new file mode 100644 index 00000000..6a34e28f --- /dev/null +++ b/api/v1/services/system/department.pb.gw.go @@ -0,0 +1,487 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: system/department.proto + +/* +Package system is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package system + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_DepartmentService_ListDepartments_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_DepartmentService_ListDepartments_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListDepartmentsRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_ListDepartments_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListDepartments(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DepartmentService_ListDepartments_0(ctx context.Context, marshaler runtime.Marshaler, server DepartmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListDepartmentsRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_ListDepartments_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListDepartments(ctx, &protoReq) + return msg, metadata, err +} + +func request_DepartmentService_GetDepartment_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetDepartmentRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetDepartment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DepartmentService_GetDepartment_0(ctx context.Context, marshaler runtime.Marshaler, server DepartmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetDepartmentRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetDepartment(ctx, &protoReq) + return msg, metadata, err +} + +var filter_DepartmentService_CreateDepartment_0 = &utilities.DoubleArray{Encoding: map[string]int{"department": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_DepartmentService_CreateDepartment_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateDepartmentRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Department); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_CreateDepartment_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateDepartment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DepartmentService_CreateDepartment_0(ctx context.Context, marshaler runtime.Marshaler, server DepartmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateDepartmentRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Department); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_CreateDepartment_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateDepartment(ctx, &protoReq) + return msg, metadata, err +} + +var filter_DepartmentService_UpdateDepartment_0 = &utilities.DoubleArray{Encoding: map[string]int{"department": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_DepartmentService_UpdateDepartment_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateDepartmentRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Department); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["department.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "department.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "department.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "department.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_UpdateDepartment_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateDepartment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DepartmentService_UpdateDepartment_0(ctx context.Context, marshaler runtime.Marshaler, server DepartmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateDepartmentRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Department); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["department.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "department.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "department.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "department.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_UpdateDepartment_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateDepartment(ctx, &protoReq) + return msg, metadata, err +} + +func request_DepartmentService_DeleteDepartment_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteDepartmentRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteDepartment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_DepartmentService_DeleteDepartment_0(ctx context.Context, marshaler runtime.Marshaler, server DepartmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteDepartmentRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteDepartment(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterDepartmentServiceHandlerServer registers the http handlers for service DepartmentService to "mux". +// UnaryRPC :call DepartmentServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterDepartmentServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterDepartmentServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server DepartmentServiceServer) error { + mux.Handle(http.MethodGet, pattern_DepartmentService_ListDepartments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/ListDepartments", runtime.WithHTTPPathPattern("/sys/departments")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DepartmentService_ListDepartments_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DepartmentService_ListDepartments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_DepartmentService_GetDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/GetDepartment", runtime.WithHTTPPathPattern("/sys/departments/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DepartmentService_GetDepartment_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DepartmentService_GetDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_DepartmentService_CreateDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/CreateDepartment", runtime.WithHTTPPathPattern("/sys/departments")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DepartmentService_CreateDepartment_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DepartmentService_CreateDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_DepartmentService_UpdateDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/UpdateDepartment", runtime.WithHTTPPathPattern("/sys/departments/{department.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DepartmentService_UpdateDepartment_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DepartmentService_UpdateDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_DepartmentService_DeleteDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/DeleteDepartment", runtime.WithHTTPPathPattern("/sys/departments/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_DepartmentService_DeleteDepartment_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DepartmentService_DeleteDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterDepartmentServiceHandlerFromEndpoint is same as RegisterDepartmentServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterDepartmentServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterDepartmentServiceHandler(ctx, mux, conn) +} + +// RegisterDepartmentServiceHandler registers the http handlers for service DepartmentService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterDepartmentServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterDepartmentServiceHandlerClient(ctx, mux, NewDepartmentServiceClient(conn)) +} + +// RegisterDepartmentServiceHandlerClient registers the http handlers for service DepartmentService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "DepartmentServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "DepartmentServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "DepartmentServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterDepartmentServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client DepartmentServiceClient) error { + mux.Handle(http.MethodGet, pattern_DepartmentService_ListDepartments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/ListDepartments", runtime.WithHTTPPathPattern("/sys/departments")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DepartmentService_ListDepartments_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DepartmentService_ListDepartments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_DepartmentService_GetDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/GetDepartment", runtime.WithHTTPPathPattern("/sys/departments/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DepartmentService_GetDepartment_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DepartmentService_GetDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_DepartmentService_CreateDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/CreateDepartment", runtime.WithHTTPPathPattern("/sys/departments")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DepartmentService_CreateDepartment_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DepartmentService_CreateDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_DepartmentService_UpdateDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/UpdateDepartment", runtime.WithHTTPPathPattern("/sys/departments/{department.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DepartmentService_UpdateDepartment_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DepartmentService_UpdateDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_DepartmentService_DeleteDepartment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.DepartmentService/DeleteDepartment", runtime.WithHTTPPathPattern("/sys/departments/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_DepartmentService_DeleteDepartment_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_DepartmentService_DeleteDepartment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_DepartmentService_ListDepartments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "departments"}, "")) + pattern_DepartmentService_GetDepartment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "departments", "id"}, "")) + pattern_DepartmentService_CreateDepartment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "departments"}, "")) + pattern_DepartmentService_UpdateDepartment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "departments", "department.id"}, "")) + pattern_DepartmentService_DeleteDepartment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "departments", "id"}, "")) +) + +var ( + forward_DepartmentService_ListDepartments_0 = runtime.ForwardResponseMessage + forward_DepartmentService_GetDepartment_0 = runtime.ForwardResponseMessage + forward_DepartmentService_CreateDepartment_0 = runtime.ForwardResponseMessage + forward_DepartmentService_UpdateDepartment_0 = runtime.ForwardResponseMessage + forward_DepartmentService_DeleteDepartment_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/system/department.pb.validate.go b/api/v1/services/system/department.pb.validate.go new file mode 100644 index 00000000..9b851e1a --- /dev/null +++ b/api/v1/services/system/department.pb.validate.go @@ -0,0 +1,1329 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: system/department.proto + +package system + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListDepartmentsRequest 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 *ListDepartmentsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListDepartmentsRequest 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 +// ListDepartmentsRequestMultiError, or nil if none found. +func (m *ListDepartmentsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListDepartmentsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Keyword + + if len(errors) > 0 { + return ListDepartmentsRequestMultiError(errors) + } + + return nil +} + +// ListDepartmentsRequestMultiError is an error wrapping multiple validation +// errors returned by ListDepartmentsRequest.ValidateAll() if the designated +// constraints aren't met. +type ListDepartmentsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListDepartmentsRequestMultiError) 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 ListDepartmentsRequestMultiError) AllErrors() []error { return m } + +// ListDepartmentsRequestValidationError is the validation error returned by +// ListDepartmentsRequest.Validate if the designated constraints aren't met. +type ListDepartmentsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListDepartmentsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListDepartmentsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListDepartmentsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListDepartmentsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListDepartmentsRequestValidationError) ErrorName() string { + return "ListDepartmentsRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListDepartmentsRequestValidationError) 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 %sListDepartmentsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListDepartmentsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListDepartmentsRequestValidationError{} + +// Validate checks the field values on ListDepartmentsResponse 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 *ListDepartmentsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListDepartmentsResponse 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 +// ListDepartmentsResponseMultiError, or nil if none found. +func (m *ListDepartmentsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListDepartmentsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Total + + for idx, item := range m.GetDepartments() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListDepartmentsResponseValidationError{ + field: fmt.Sprintf("Departments[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListDepartmentsResponseValidationError{ + field: fmt.Sprintf("Departments[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListDepartmentsResponseValidationError{ + field: fmt.Sprintf("Departments[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListDepartmentsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListDepartmentsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListDepartmentsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListDepartmentsResponseMultiError(errors) + } + + return nil +} + +// ListDepartmentsResponseMultiError is an error wrapping multiple validation +// errors returned by ListDepartmentsResponse.ValidateAll() if the designated +// constraints aren't met. +type ListDepartmentsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListDepartmentsResponseMultiError) 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 ListDepartmentsResponseMultiError) AllErrors() []error { return m } + +// ListDepartmentsResponseValidationError is the validation error returned by +// ListDepartmentsResponse.Validate if the designated constraints aren't met. +type ListDepartmentsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListDepartmentsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListDepartmentsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListDepartmentsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListDepartmentsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListDepartmentsResponseValidationError) ErrorName() string { + return "ListDepartmentsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListDepartmentsResponseValidationError) 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 %sListDepartmentsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListDepartmentsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListDepartmentsResponseValidationError{} + +// Validate checks the field values on GetDepartmentRequest 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 *GetDepartmentRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDepartmentRequest 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 +// GetDepartmentRequestMultiError, or nil if none found. +func (m *GetDepartmentRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDepartmentRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetDepartmentRequestMultiError(errors) + } + + return nil +} + +// GetDepartmentRequestMultiError is an error wrapping multiple validation +// errors returned by GetDepartmentRequest.ValidateAll() if the designated +// constraints aren't met. +type GetDepartmentRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDepartmentRequestMultiError) 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 GetDepartmentRequestMultiError) AllErrors() []error { return m } + +// GetDepartmentRequestValidationError is the validation error returned by +// GetDepartmentRequest.Validate if the designated constraints aren't met. +type GetDepartmentRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDepartmentRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDepartmentRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDepartmentRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDepartmentRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDepartmentRequestValidationError) ErrorName() string { + return "GetDepartmentRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDepartmentRequestValidationError) 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 %sGetDepartmentRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDepartmentRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDepartmentRequestValidationError{} + +// Validate checks the field values on GetDepartmentResponse 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 *GetDepartmentResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetDepartmentResponse 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 +// GetDepartmentResponseMultiError, or nil if none found. +func (m *GetDepartmentResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetDepartmentResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetDepartment()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetDepartmentResponseValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetDepartmentResponseValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetDepartmentResponseValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetDepartmentResponseMultiError(errors) + } + + return nil +} + +// GetDepartmentResponseMultiError is an error wrapping multiple validation +// errors returned by GetDepartmentResponse.ValidateAll() if the designated +// constraints aren't met. +type GetDepartmentResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetDepartmentResponseMultiError) 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 GetDepartmentResponseMultiError) AllErrors() []error { return m } + +// GetDepartmentResponseValidationError is the validation error returned by +// GetDepartmentResponse.Validate if the designated constraints aren't met. +type GetDepartmentResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetDepartmentResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetDepartmentResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetDepartmentResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetDepartmentResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetDepartmentResponseValidationError) ErrorName() string { + return "GetDepartmentResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetDepartmentResponseValidationError) 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 %sGetDepartmentResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetDepartmentResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetDepartmentResponseValidationError{} + +// Validate checks the field values on CreateDepartmentRequest 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 *CreateDepartmentRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateDepartmentRequest 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 +// CreateDepartmentRequestMultiError, or nil if none found. +func (m *CreateDepartmentRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateDepartmentRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for DepartmentId + + if all { + switch v := interface{}(m.GetDepartment()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateDepartmentRequestValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateDepartmentRequestValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateDepartmentRequestValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateDepartmentRequestMultiError(errors) + } + + return nil +} + +// CreateDepartmentRequestMultiError is an error wrapping multiple validation +// errors returned by CreateDepartmentRequest.ValidateAll() if the designated +// constraints aren't met. +type CreateDepartmentRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateDepartmentRequestMultiError) 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 CreateDepartmentRequestMultiError) AllErrors() []error { return m } + +// CreateDepartmentRequestValidationError is the validation error returned by +// CreateDepartmentRequest.Validate if the designated constraints aren't met. +type CreateDepartmentRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateDepartmentRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateDepartmentRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateDepartmentRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateDepartmentRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateDepartmentRequestValidationError) ErrorName() string { + return "CreateDepartmentRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateDepartmentRequestValidationError) 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 %sCreateDepartmentRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateDepartmentRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateDepartmentRequestValidationError{} + +// Validate checks the field values on CreateDepartmentResponse 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 *CreateDepartmentResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateDepartmentResponse 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 +// CreateDepartmentResponseMultiError, or nil if none found. +func (m *CreateDepartmentResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateDepartmentResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetDepartment()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateDepartmentResponseValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateDepartmentResponseValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateDepartmentResponseValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateDepartmentResponseMultiError(errors) + } + + return nil +} + +// CreateDepartmentResponseMultiError is an error wrapping multiple validation +// errors returned by CreateDepartmentResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateDepartmentResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateDepartmentResponseMultiError) 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 CreateDepartmentResponseMultiError) AllErrors() []error { return m } + +// CreateDepartmentResponseValidationError is the validation error returned by +// CreateDepartmentResponse.Validate if the designated constraints aren't met. +type CreateDepartmentResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateDepartmentResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateDepartmentResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateDepartmentResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateDepartmentResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateDepartmentResponseValidationError) ErrorName() string { + return "CreateDepartmentResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateDepartmentResponseValidationError) 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 %sCreateDepartmentResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateDepartmentResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateDepartmentResponseValidationError{} + +// Validate checks the field values on UpdateDepartmentRequest 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 *UpdateDepartmentRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateDepartmentRequest 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 +// UpdateDepartmentRequestMultiError, or nil if none found. +func (m *UpdateDepartmentRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateDepartmentRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetDepartment()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateDepartmentRequestValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateDepartmentRequestValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateDepartmentRequestValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateDepartmentRequestMultiError(errors) + } + + return nil +} + +// UpdateDepartmentRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateDepartmentRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateDepartmentRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateDepartmentRequestMultiError) 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 UpdateDepartmentRequestMultiError) AllErrors() []error { return m } + +// UpdateDepartmentRequestValidationError is the validation error returned by +// UpdateDepartmentRequest.Validate if the designated constraints aren't met. +type UpdateDepartmentRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateDepartmentRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateDepartmentRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateDepartmentRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateDepartmentRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateDepartmentRequestValidationError) ErrorName() string { + return "UpdateDepartmentRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateDepartmentRequestValidationError) 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 %sUpdateDepartmentRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateDepartmentRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateDepartmentRequestValidationError{} + +// Validate checks the field values on UpdateDepartmentResponse 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 *UpdateDepartmentResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateDepartmentResponse 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 +// UpdateDepartmentResponseMultiError, or nil if none found. +func (m *UpdateDepartmentResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateDepartmentResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetDepartment()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateDepartmentResponseValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateDepartmentResponseValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateDepartmentResponseValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateDepartmentResponseMultiError(errors) + } + + return nil +} + +// UpdateDepartmentResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateDepartmentResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateDepartmentResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateDepartmentResponseMultiError) 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 UpdateDepartmentResponseMultiError) AllErrors() []error { return m } + +// UpdateDepartmentResponseValidationError is the validation error returned by +// UpdateDepartmentResponse.Validate if the designated constraints aren't met. +type UpdateDepartmentResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateDepartmentResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateDepartmentResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateDepartmentResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateDepartmentResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateDepartmentResponseValidationError) ErrorName() string { + return "UpdateDepartmentResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateDepartmentResponseValidationError) 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 %sUpdateDepartmentResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateDepartmentResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateDepartmentResponseValidationError{} + +// Validate checks the field values on DeleteDepartmentRequest 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 *DeleteDepartmentRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteDepartmentRequest 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 +// DeleteDepartmentRequestMultiError, or nil if none found. +func (m *DeleteDepartmentRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteDepartmentRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeleteDepartmentRequestMultiError(errors) + } + + return nil +} + +// DeleteDepartmentRequestMultiError is an error wrapping multiple validation +// errors returned by DeleteDepartmentRequest.ValidateAll() if the designated +// constraints aren't met. +type DeleteDepartmentRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteDepartmentRequestMultiError) 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 DeleteDepartmentRequestMultiError) AllErrors() []error { return m } + +// DeleteDepartmentRequestValidationError is the validation error returned by +// DeleteDepartmentRequest.Validate if the designated constraints aren't met. +type DeleteDepartmentRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteDepartmentRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteDepartmentRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteDepartmentRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteDepartmentRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteDepartmentRequestValidationError) ErrorName() string { + return "DeleteDepartmentRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteDepartmentRequestValidationError) 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 %sDeleteDepartmentRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteDepartmentRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteDepartmentRequestValidationError{} + +// Validate checks the field values on DeleteDepartmentResponse 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 *DeleteDepartmentResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteDepartmentResponse 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 +// DeleteDepartmentResponseMultiError, or nil if none found. +func (m *DeleteDepartmentResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteDepartmentResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteDepartmentResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteDepartmentResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteDepartmentResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteDepartmentResponseMultiError(errors) + } + + return nil +} + +// DeleteDepartmentResponseMultiError is an error wrapping multiple validation +// errors returned by DeleteDepartmentResponse.ValidateAll() if the designated +// constraints aren't met. +type DeleteDepartmentResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteDepartmentResponseMultiError) 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 DeleteDepartmentResponseMultiError) AllErrors() []error { return m } + +// DeleteDepartmentResponseValidationError is the validation error returned by +// DeleteDepartmentResponse.Validate if the designated constraints aren't met. +type DeleteDepartmentResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteDepartmentResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteDepartmentResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteDepartmentResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteDepartmentResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteDepartmentResponseValidationError) ErrorName() string { + return "DeleteDepartmentResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteDepartmentResponseValidationError) 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 %sDeleteDepartmentResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteDepartmentResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteDepartmentResponseValidationError{} diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go new file mode 100644 index 00000000..65ca7403 --- /dev/null +++ b/api/v1/services/system/department_bridge.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/department.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const DepartmentServiceCreateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/CreateDepartment" +const DepartmentServiceDeleteDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/DeleteDepartment" +const DepartmentServiceGetDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/GetDepartment" +const DepartmentServiceListDepartmentsBridgeOperation = "/api.v1.services.system.DepartmentService/ListDepartments" +const DepartmentServiceUpdateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/UpdateDepartment" + +type DepartmentServiceBridgeServer interface { + CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) + DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) + GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) + ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) + UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) +} + +type DepartmentServiceHooker interface { + DepartmentServiceCreateDepartmentHooker + DepartmentServiceDeleteDepartmentHooker + DepartmentServiceGetDepartmentHooker + DepartmentServiceListDepartmentsHooker + DepartmentServiceUpdateDepartmentHooker +} + +type DepartmentServiceHookedBridger interface { + DepartmentServiceHooker + DepartmentServiceBridgeServer +} +type DepartmentServiceCreateDepartmentHooker interface { + PrepareCreateDepartment(http.Context, *CreateDepartmentRequest) (context.Context, error) + CompleteCreateDepartment(http.Context, *CreateDepartmentRequest, *CreateDepartmentResponse) error +} +type DepartmentServiceDeleteDepartmentHooker interface { + PrepareDeleteDepartment(http.Context, *DeleteDepartmentRequest) (context.Context, error) + CompleteDeleteDepartment(http.Context, *DeleteDepartmentRequest, *DeleteDepartmentResponse) error +} +type DepartmentServiceGetDepartmentHooker interface { + PrepareGetDepartment(http.Context, *GetDepartmentRequest) (context.Context, error) + CompleteGetDepartment(http.Context, *GetDepartmentRequest, *GetDepartmentResponse) error +} +type DepartmentServiceListDepartmentsHooker interface { + PrepareListDepartments(http.Context, *ListDepartmentsRequest) (context.Context, error) + CompleteListDepartments(http.Context, *ListDepartmentsRequest, *ListDepartmentsResponse) error +} +type DepartmentServiceUpdateDepartmentHooker interface { + PrepareUpdateDepartment(http.Context, *UpdateDepartmentRequest) (context.Context, error) + CompleteUpdateDepartment(http.Context, *UpdateDepartmentRequest, *UpdateDepartmentResponse) error +} + +func RegisterDepartmentServiceBridgeServer(s *http.Server, srv DepartmentServiceHookedBridger) { + r := s.Route("/") + r.GET("/sys/departments", _DepartmentService_ListDepartments0_Bridge_Handler(srv)) + r.GET("/sys/departments/:id", _DepartmentService_GetDepartment0_Bridge_Handler(srv)) + r.POST("/sys/departments", _DepartmentService_CreateDepartment0_Bridge_Handler(srv)) + r.PUT("/sys/departments/:department.id", _DepartmentService_UpdateDepartment0_Bridge_Handler(srv)) + r.DELETE("/sys/departments/:id", _DepartmentService_DeleteDepartment0_Bridge_Handler(srv)) +} + +func _DepartmentService_ListDepartments0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListDepartmentsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceListDepartments) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListDepartments(ctx, req.(*ListDepartmentsRequest)) + }) + + newctx, err := srv.PrepareListDepartments(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListDepartments(ctx, &in, out.(*ListDepartmentsResponse)) + } +} + +func _DepartmentService_GetDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetDepartmentRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceGetDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetDepartment(ctx, req.(*GetDepartmentRequest)) + }) + + newctx, err := srv.PrepareGetDepartment(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetDepartment(ctx, &in, out.(*GetDepartmentResponse)) + } +} + +func _DepartmentService_CreateDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateDepartmentRequest + if err := ctx.Bind(&in.Department); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceCreateDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateDepartment(ctx, req.(*CreateDepartmentRequest)) + }) + + newctx, err := srv.PrepareCreateDepartment(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateDepartment(ctx, &in, out.(*CreateDepartmentResponse)) + } +} + +func _DepartmentService_UpdateDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateDepartmentRequest + if err := ctx.Bind(&in.Department); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceUpdateDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateDepartment(ctx, req.(*UpdateDepartmentRequest)) + }) + + newctx, err := srv.PrepareUpdateDepartment(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateDepartment(ctx, &in, out.(*UpdateDepartmentResponse)) + } +} + +func _DepartmentService_DeleteDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteDepartmentRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceDeleteDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteDepartment(ctx, req.(*DeleteDepartmentRequest)) + }) + + newctx, err := srv.PrepareDeleteDepartment(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteDepartment(ctx, &in, out.(*DeleteDepartmentResponse)) + } +} + +// UnimplementedDepartmentServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedDepartmentServiceHooked struct{} + +func (UnimplementedDepartmentServiceHooked) PrepareCreateDepartment(ctx http.Context, in *CreateDepartmentRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDepartmentServiceHooked) CompleteCreateDepartment(ctx http.Context, in *CreateDepartmentRequest, out *CreateDepartmentResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDepartmentServiceHooked) PrepareDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDepartmentServiceHooked) CompleteDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest, out *DeleteDepartmentResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDepartmentServiceHooked) PrepareGetDepartment(ctx http.Context, in *GetDepartmentRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDepartmentServiceHooked) CompleteGetDepartment(ctx http.Context, in *GetDepartmentRequest, out *GetDepartmentResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDepartmentServiceHooked) PrepareListDepartments(ctx http.Context, in *ListDepartmentsRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDepartmentServiceHooked) CompleteListDepartments(ctx http.Context, in *ListDepartmentsRequest, out *ListDepartmentsResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedDepartmentServiceHooked) PrepareUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedDepartmentServiceHooked) CompleteUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest, out *UpdateDepartmentResponse) error { + return ctx.Result(200, out) +} + +func WithDepartmentServiceHook(h DepartmentServiceHooker) func(DepartmentServiceBridgeServer) DepartmentServiceHookedBridger { + return func(srv DepartmentServiceBridgeServer) DepartmentServiceHookedBridger { + return DepartmentServiceHookedBridge{DepartmentServiceBridgeServer: srv, DepartmentServiceHooker: h} + } +} + +// DepartmentServiceHookedBridge is a bridge between the HTTP and gRPC implementations of DepartmentService. +// It implements the HTTP and gRPC implementations of DepartmentService. +// It forwards requests and responses between the two implementations. +type DepartmentServiceHookedBridge struct { + DepartmentServiceBridgeServer + DepartmentServiceHooker +} + +type DepartmentServiceHTTPBridgeImpl struct { + client DepartmentServiceHTTPClient +} + +func NewDepartmentServiceHTTPBridge(client *http.Client) DepartmentServiceHTTPServer { + return &DepartmentServiceHTTPBridgeImpl{client: NewDepartmentServiceHTTPClient(client)} +} + +func (c *DepartmentServiceHTTPBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTPBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTPBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { + return c.client.GetDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTPBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) +} + +func (c *DepartmentServiceHTTPBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { + return c.client.UpdateDepartment(ctx, in) +} + +type DepartmentServiceBridgeImpl struct { + client DepartmentServiceClient +} + +func NewDepartmentServiceBridge(client grpc.ClientConnInterface) DepartmentServiceServer { + return &DepartmentServiceBridgeImpl{client: NewDepartmentServiceClient(client)} +} + +func (c *DepartmentServiceBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) +} + +func (c *DepartmentServiceBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + +func (c *DepartmentServiceBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { + return c.client.GetDepartment(ctx, in) +} + +func (c *DepartmentServiceBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) +} + +func (c *DepartmentServiceBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { + return c.client.UpdateDepartment(ctx, in) +} + +func (c *DepartmentServiceBridgeImpl) mustEmbedUnimplementedDepartmentServiceServer() {} + +type DepartmentServiceGRPC2HTTPBridgeImpl struct { + client DepartmentServiceClient +} + +func NewDepartmentServiceGRPC2HTTP(client grpc.ClientConnInterface) DepartmentServiceHTTPServer { + return &DepartmentServiceGRPC2HTTPBridgeImpl{client: NewDepartmentServiceClient(client)} +} + +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) +} + +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { + return c.client.GetDepartment(ctx, in) +} + +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) +} + +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { + return c.client.UpdateDepartment(ctx, in) +} + +type DepartmentServiceHTTP2GRPCBridgeImpl struct { + client DepartmentServiceHTTPClient +} + +func NewDepartmentServiceHTTP2GRPC(client *http.Client) DepartmentServiceServer { + return &DepartmentServiceHTTP2GRPCBridgeImpl{client: NewDepartmentServiceHTTPClient(client)} +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { + return c.client.GetDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { + return c.client.UpdateDepartment(ctx, in) +} + +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedDepartmentServiceServer() {} diff --git a/api/v1/services/system/department_grpc.pb.go b/api/v1/services/system/department_grpc.pb.go new file mode 100644 index 00000000..0372a61a --- /dev/null +++ b/api/v1/services/system/department_grpc.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: system/department.proto + +package system + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + DepartmentService_ListDepartments_FullMethodName = "/api.v1.services.system.DepartmentService/ListDepartments" + DepartmentService_GetDepartment_FullMethodName = "/api.v1.services.system.DepartmentService/GetDepartment" + DepartmentService_CreateDepartment_FullMethodName = "/api.v1.services.system.DepartmentService/CreateDepartment" + DepartmentService_UpdateDepartment_FullMethodName = "/api.v1.services.system.DepartmentService/UpdateDepartment" + DepartmentService_DeleteDepartment_FullMethodName = "/api.v1.services.system.DepartmentService/DeleteDepartment" +) + +// DepartmentServiceClient is the client API for DepartmentService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The login service definition. +type DepartmentServiceClient interface { + ListDepartments(ctx context.Context, in *ListDepartmentsRequest, opts ...grpc.CallOption) (*ListDepartmentsResponse, error) + GetDepartment(ctx context.Context, in *GetDepartmentRequest, opts ...grpc.CallOption) (*GetDepartmentResponse, error) + CreateDepartment(ctx context.Context, in *CreateDepartmentRequest, opts ...grpc.CallOption) (*CreateDepartmentResponse, error) + UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest, opts ...grpc.CallOption) (*UpdateDepartmentResponse, error) + DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest, opts ...grpc.CallOption) (*DeleteDepartmentResponse, error) +} + +type departmentServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewDepartmentServiceClient(cc grpc.ClientConnInterface) DepartmentServiceClient { + return &departmentServiceClient{cc} +} + +func (c *departmentServiceClient) ListDepartments(ctx context.Context, in *ListDepartmentsRequest, opts ...grpc.CallOption) (*ListDepartmentsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListDepartmentsResponse) + err := c.cc.Invoke(ctx, DepartmentService_ListDepartments_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *departmentServiceClient) GetDepartment(ctx context.Context, in *GetDepartmentRequest, opts ...grpc.CallOption) (*GetDepartmentResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetDepartmentResponse) + err := c.cc.Invoke(ctx, DepartmentService_GetDepartment_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *departmentServiceClient) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest, opts ...grpc.CallOption) (*CreateDepartmentResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateDepartmentResponse) + err := c.cc.Invoke(ctx, DepartmentService_CreateDepartment_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *departmentServiceClient) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest, opts ...grpc.CallOption) (*UpdateDepartmentResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateDepartmentResponse) + err := c.cc.Invoke(ctx, DepartmentService_UpdateDepartment_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *departmentServiceClient) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest, opts ...grpc.CallOption) (*DeleteDepartmentResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteDepartmentResponse) + err := c.cc.Invoke(ctx, DepartmentService_DeleteDepartment_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// DepartmentServiceServer is the server API for DepartmentService service. +// All implementations must embed UnimplementedDepartmentServiceServer +// for forward compatibility. +// +// The login service definition. +type DepartmentServiceServer interface { + ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) + GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) + CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) + UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) + DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) + mustEmbedUnimplementedDepartmentServiceServer() +} + +// UnimplementedDepartmentServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedDepartmentServiceServer struct{} + +func (UnimplementedDepartmentServiceServer) ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListDepartments not implemented") +} +func (UnimplementedDepartmentServiceServer) GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDepartment not implemented") +} +func (UnimplementedDepartmentServiceServer) CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateDepartment not implemented") +} +func (UnimplementedDepartmentServiceServer) UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateDepartment not implemented") +} +func (UnimplementedDepartmentServiceServer) DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteDepartment not implemented") +} +func (UnimplementedDepartmentServiceServer) mustEmbedUnimplementedDepartmentServiceServer() {} +func (UnimplementedDepartmentServiceServer) testEmbeddedByValue() {} + +// UnsafeDepartmentServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to DepartmentServiceServer will +// result in compilation errors. +type UnsafeDepartmentServiceServer interface { + mustEmbedUnimplementedDepartmentServiceServer() +} + +func RegisterDepartmentServiceServer(s grpc.ServiceRegistrar, srv DepartmentServiceServer) { + // If the following call pancis, it indicates UnimplementedDepartmentServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&DepartmentService_ServiceDesc, srv) +} + +func _DepartmentService_ListDepartments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListDepartmentsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DepartmentServiceServer).ListDepartments(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DepartmentService_ListDepartments_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DepartmentServiceServer).ListDepartments(ctx, req.(*ListDepartmentsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DepartmentService_GetDepartment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetDepartmentRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DepartmentServiceServer).GetDepartment(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DepartmentService_GetDepartment_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DepartmentServiceServer).GetDepartment(ctx, req.(*GetDepartmentRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DepartmentService_CreateDepartment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateDepartmentRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DepartmentServiceServer).CreateDepartment(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DepartmentService_CreateDepartment_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DepartmentServiceServer).CreateDepartment(ctx, req.(*CreateDepartmentRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DepartmentService_UpdateDepartment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateDepartmentRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DepartmentServiceServer).UpdateDepartment(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DepartmentService_UpdateDepartment_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DepartmentServiceServer).UpdateDepartment(ctx, req.(*UpdateDepartmentRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _DepartmentService_DeleteDepartment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteDepartmentRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(DepartmentServiceServer).DeleteDepartment(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: DepartmentService_DeleteDepartment_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(DepartmentServiceServer).DeleteDepartment(ctx, req.(*DeleteDepartmentRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// DepartmentService_ServiceDesc is the grpc.ServiceDesc for DepartmentService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var DepartmentService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.system.DepartmentService", + HandlerType: (*DepartmentServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListDepartments", + Handler: _DepartmentService_ListDepartments_Handler, + }, + { + MethodName: "GetDepartment", + Handler: _DepartmentService_GetDepartment_Handler, + }, + { + MethodName: "CreateDepartment", + Handler: _DepartmentService_CreateDepartment_Handler, + }, + { + MethodName: "UpdateDepartment", + Handler: _DepartmentService_UpdateDepartment_Handler, + }, + { + MethodName: "DeleteDepartment", + Handler: _DepartmentService_DeleteDepartment_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "system/department.proto", +} diff --git a/api/v1/services/system/department_http.pb.go b/api/v1/services/system/department_http.pb.go new file mode 100644 index 00000000..1420bdf9 --- /dev/null +++ b/api/v1/services/system/department_http.pb.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: system/department.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationDepartmentServiceCreateDepartment = "/api.v1.services.system.DepartmentService/CreateDepartment" +const OperationDepartmentServiceDeleteDepartment = "/api.v1.services.system.DepartmentService/DeleteDepartment" +const OperationDepartmentServiceGetDepartment = "/api.v1.services.system.DepartmentService/GetDepartment" +const OperationDepartmentServiceListDepartments = "/api.v1.services.system.DepartmentService/ListDepartments" +const OperationDepartmentServiceUpdateDepartment = "/api.v1.services.system.DepartmentService/UpdateDepartment" + +type DepartmentServiceHTTPServer interface { + CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) + DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) + GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) + ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) + UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) +} + +func RegisterDepartmentServiceHTTPServer(s *http.Server, srv DepartmentServiceHTTPServer) { + r := s.Route("/") + r.GET("/sys/departments", _DepartmentService_ListDepartments0_HTTP_Handler(srv)) + r.GET("/sys/departments/{id}", _DepartmentService_GetDepartment0_HTTP_Handler(srv)) + r.POST("/sys/departments", _DepartmentService_CreateDepartment0_HTTP_Handler(srv)) + r.PUT("/sys/departments/{department.id}", _DepartmentService_UpdateDepartment0_HTTP_Handler(srv)) + r.DELETE("/sys/departments/{id}", _DepartmentService_DeleteDepartment0_HTTP_Handler(srv)) +} + +func _DepartmentService_ListDepartments0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListDepartmentsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceListDepartments) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListDepartments(ctx, req.(*ListDepartmentsRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListDepartmentsResponse) + return ctx.Result(200, reply) + } +} + +func _DepartmentService_GetDepartment0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetDepartmentRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceGetDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetDepartment(ctx, req.(*GetDepartmentRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetDepartmentResponse) + return ctx.Result(200, reply) + } +} + +func _DepartmentService_CreateDepartment0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateDepartmentRequest + if err := ctx.Bind(&in.Department); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceCreateDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateDepartment(ctx, req.(*CreateDepartmentRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateDepartmentResponse) + return ctx.Result(200, reply) + } +} + +func _DepartmentService_UpdateDepartment0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateDepartmentRequest + if err := ctx.Bind(&in.Department); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceUpdateDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateDepartment(ctx, req.(*UpdateDepartmentRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateDepartmentResponse) + return ctx.Result(200, reply) + } +} + +func _DepartmentService_DeleteDepartment0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteDepartmentRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationDepartmentServiceDeleteDepartment) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteDepartment(ctx, req.(*DeleteDepartmentRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeleteDepartmentResponse) + return ctx.Result(200, reply) + } +} + +type DepartmentServiceHTTPClient interface { + CreateDepartment(ctx context.Context, req *CreateDepartmentRequest, opts ...http.CallOption) (rsp *CreateDepartmentResponse, err error) + DeleteDepartment(ctx context.Context, req *DeleteDepartmentRequest, opts ...http.CallOption) (rsp *DeleteDepartmentResponse, err error) + GetDepartment(ctx context.Context, req *GetDepartmentRequest, opts ...http.CallOption) (rsp *GetDepartmentResponse, err error) + ListDepartments(ctx context.Context, req *ListDepartmentsRequest, opts ...http.CallOption) (rsp *ListDepartmentsResponse, err error) + UpdateDepartment(ctx context.Context, req *UpdateDepartmentRequest, opts ...http.CallOption) (rsp *UpdateDepartmentResponse, err error) +} + +type DepartmentServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewDepartmentServiceHTTPClient(client *http.Client) DepartmentServiceHTTPClient { + return &DepartmentServiceHTTPClientImpl{client} +} + +func (c *DepartmentServiceHTTPClientImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest, opts ...http.CallOption) (*CreateDepartmentResponse, error) { + var out CreateDepartmentResponse + pattern := "/sys/departments" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationDepartmentServiceCreateDepartment)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Department, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DepartmentServiceHTTPClientImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest, opts ...http.CallOption) (*DeleteDepartmentResponse, error) { + var out DeleteDepartmentResponse + pattern := "/sys/departments/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDepartmentServiceDeleteDepartment)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DepartmentServiceHTTPClientImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest, opts ...http.CallOption) (*GetDepartmentResponse, error) { + var out GetDepartmentResponse + pattern := "/sys/departments/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDepartmentServiceGetDepartment)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DepartmentServiceHTTPClientImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest, opts ...http.CallOption) (*ListDepartmentsResponse, error) { + var out ListDepartmentsResponse + pattern := "/sys/departments" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationDepartmentServiceListDepartments)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *DepartmentServiceHTTPClientImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest, opts ...http.CallOption) (*UpdateDepartmentResponse, error) { + var out UpdateDepartmentResponse + pattern := "/sys/departments/{department.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationDepartmentServiceUpdateDepartment)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Department, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/system/menu.pb.go b/api/v1/services/system/menu.pb.go new file mode 100644 index 00000000..d423a9cb --- /dev/null +++ b/api/v1/services/system/menu.pb.go @@ -0,0 +1,741 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: system/menu.proto + +package system + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// ListMenusRequest is the request for the MenuService.ListMenus method. +type ListMenusRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The page number. + Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // The keyword is the query parameter for set only to query the menu by keyword + Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListMenusRequest) Reset() { + *x = ListMenusRequest{} + mi := &file_system_menu_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListMenusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListMenusRequest) ProtoMessage() {} + +func (x *ListMenusRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_menu_proto_msgTypes[0] + 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 ListMenusRequest.ProtoReflect.Descriptor instead. +func (*ListMenusRequest) Descriptor() ([]byte, []int) { + return file_system_menu_proto_rawDescGZIP(), []int{0} +} + +func (x *ListMenusRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListMenusRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListMenusRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListMenusRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListMenusRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListMenusRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListMenusRequest) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +// ListMenusResponse is the response for the MenuService.ListMenus method. +type ListMenusResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` + // The paging menus + Menus []*types.Menu `protobuf:"bytes,2,rep,name=menus,proto3" json:"menus,omitempty"` + // The page number. + Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the page data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListMenusResponse) Reset() { + *x = ListMenusResponse{} + mi := &file_system_menu_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListMenusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListMenusResponse) ProtoMessage() {} + +func (x *ListMenusResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_menu_proto_msgTypes[1] + 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 ListMenusResponse.ProtoReflect.Descriptor instead. +func (*ListMenusResponse) Descriptor() ([]byte, []int) { + return file_system_menu_proto_rawDescGZIP(), []int{1} +} + +func (x *ListMenusResponse) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *ListMenusResponse) GetMenus() []*types.Menu { + if x != nil { + return x.Menus + } + return nil +} + +func (x *ListMenusResponse) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListMenusResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListMenusResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListMenusResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +// GetMenuRequest is the request for the MenuService.GetMenu method. +type GetMenuRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the resource requested, for example: + // "shelves/shelf1/menus/menu2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetMenuRequest) Reset() { + *x = GetMenuRequest{} + mi := &file_system_menu_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetMenuRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetMenuRequest) ProtoMessage() {} + +func (x *GetMenuRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_menu_proto_msgTypes[2] + 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 GetMenuRequest.ProtoReflect.Descriptor instead. +func (*GetMenuRequest) Descriptor() ([]byte, []int) { + return file_system_menu_proto_rawDescGZIP(), []int{2} +} + +func (x *GetMenuRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// GetMenuResponse is the response for the MenuService.GetMenu method. +type GetMenuResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field id should match the Noun in the method id. + Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetMenuResponse) Reset() { + *x = GetMenuResponse{} + mi := &file_system_menu_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetMenuResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetMenuResponse) ProtoMessage() {} + +func (x *GetMenuResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_menu_proto_msgTypes[3] + 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 GetMenuResponse.ProtoReflect.Descriptor instead. +func (*GetMenuResponse) Descriptor() ([]byte, []int) { + return file_system_menu_proto_rawDescGZIP(), []int{3} +} + +func (x *GetMenuResponse) GetMenu() *types.Menu { + if x != nil { + return x.Menu + } + return nil +} + +// CreateMenuRequest is the request for the MenuService.CreateMenu method. +type CreateMenuRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id where the menu is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The menu id to use for this menu. + MenuId string `protobuf:"bytes,3,opt,name=menu_id,json=menuId,proto3" json:"menu_id,omitempty"` + // The menu resource to create. + // The field id should match the Noun in the method id. + Menu *types.Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateMenuRequest) Reset() { + *x = CreateMenuRequest{} + mi := &file_system_menu_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateMenuRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateMenuRequest) ProtoMessage() {} + +func (x *CreateMenuRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_menu_proto_msgTypes[4] + 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 CreateMenuRequest.ProtoReflect.Descriptor instead. +func (*CreateMenuRequest) Descriptor() ([]byte, []int) { + return file_system_menu_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateMenuRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateMenuRequest) GetMenuId() string { + if x != nil { + return x.MenuId + } + return "" +} + +func (x *CreateMenuRequest) GetMenu() *types.Menu { + if x != nil { + return x.Menu + } + return nil +} + +// CreateMenuResponse is the response for the MenuService.CreateMenu method. +type CreateMenuResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateMenuResponse) Reset() { + *x = CreateMenuResponse{} + mi := &file_system_menu_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateMenuResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateMenuResponse) ProtoMessage() {} + +func (x *CreateMenuResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_menu_proto_msgTypes[5] + 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 CreateMenuResponse.ProtoReflect.Descriptor instead. +func (*CreateMenuResponse) Descriptor() ([]byte, []int) { + return file_system_menu_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateMenuResponse) GetMenu() *types.Menu { + if x != nil { + return x.Menu + } + return nil +} + +// UpdateMenuRequest is the request for the MenuService.UpdateMenu method. +type UpdateMenuRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The menu resource which replaces the resource on the server. + Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateMenuRequest) Reset() { + *x = UpdateMenuRequest{} + mi := &file_system_menu_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateMenuRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateMenuRequest) ProtoMessage() {} + +func (x *UpdateMenuRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_menu_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 UpdateMenuRequest.ProtoReflect.Descriptor instead. +func (*UpdateMenuRequest) Descriptor() ([]byte, []int) { + return file_system_menu_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateMenuRequest) GetMenu() *types.Menu { + if x != nil { + return x.Menu + } + return nil +} + +// UpdateMenuResponse is the response for the MenuService.UpdateMenu method. +type UpdateMenuResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateMenuResponse) Reset() { + *x = UpdateMenuResponse{} + mi := &file_system_menu_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateMenuResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateMenuResponse) ProtoMessage() {} + +func (x *UpdateMenuResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_menu_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateMenuResponse.ProtoReflect.Descriptor instead. +func (*UpdateMenuResponse) Descriptor() ([]byte, []int) { + return file_system_menu_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateMenuResponse) GetMenu() *types.Menu { + if x != nil { + return x.Menu + } + return nil +} + +// DeleteMenuRequest is the request for the MenuService.DeleteMenu method. +type DeleteMenuRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The resource id of the menu to be deleted, for example: + // "shelves/shelf1/menus/menu2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteMenuRequest) Reset() { + *x = DeleteMenuRequest{} + mi := &file_system_menu_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteMenuRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteMenuRequest) ProtoMessage() {} + +func (x *DeleteMenuRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_menu_proto_msgTypes[8] + 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 DeleteMenuRequest.ProtoReflect.Descriptor instead. +func (*DeleteMenuRequest) Descriptor() ([]byte, []int) { + return file_system_menu_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteMenuRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// DeleteMenuResponse is the response for the MenuService.DeleteMenu method. +type DeleteMenuResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // or Menu menu = 1; or google.protobuf.Empty empty = 1; + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteMenuResponse) Reset() { + *x = DeleteMenuResponse{} + mi := &file_system_menu_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteMenuResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteMenuResponse) ProtoMessage() {} + +func (x *DeleteMenuResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_menu_proto_msgTypes[9] + 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 DeleteMenuResponse.ProtoReflect.Descriptor instead. +func (*DeleteMenuResponse) Descriptor() ([]byte, []int) { + return file_system_menu_proto_rawDescGZIP(), []int{9} +} + +func (x *DeleteMenuResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_system_menu_proto protoreflect.FileDescriptor + +const file_system_menu_proto_rawDesc = "" + + "\n" + + "\x11system/menu.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xcc\x01\n" + + "\x10ListMenusRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x18\n" + + "\akeyword\x18\a \x01(\tR\akeyword\"\xf3\x01\n" + + "\x11ListMenusResponse\x12\x14\n" + + "\x05total\x18\x01 \x01(\x05R\x05total\x121\n" + + "\x05menus\x18\x02 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x12\x12\n" + + "\x04page\x18\x03 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\" \n" + + "\x0eGetMenuRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x0fGetMenuResponse\x12/\n" + + "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"u\n" + + "\x11CreateMenuRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x17\n" + + "\amenu_id\x18\x03 \x01(\tR\x06menuId\x12/\n" + + "\x04menu\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"E\n" + + "\x12CreateMenuResponse\x12/\n" + + "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"D\n" + + "\x11UpdateMenuRequest\x12/\n" + + "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"E\n" + + "\x12UpdateMenuResponse\x12/\n" + + "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"#\n" + + "\x11DeleteMenuRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x12DeleteMenuResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xff\x04\n" + + "\vMenuService\x12t\n" + + "\tListMenus\x12(.api.v1.services.system.ListMenusRequest\x1a).api.v1.services.system.ListMenusResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + + "/sys/menus\x12s\n" + + "\aGetMenu\x12&.api.v1.services.system.GetMenuRequest\x1a'.api.v1.services.system.GetMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/menus/{id}\x12}\n" + + "\n" + + "CreateMenu\x12).api.v1.services.system.CreateMenuRequest\x1a*.api.v1.services.system.CreateMenuResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04menu\"\n" + + "/sys/menus\x12\x87\x01\n" + + "\n" + + "UpdateMenu\x12).api.v1.services.system.UpdateMenuRequest\x1a*.api.v1.services.system.UpdateMenuResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04menu\x1a\x14/sys/menus/{menu.id}\x12|\n" + + "\n" + + "DeleteMenu\x12).api.v1.services.system.DeleteMenuRequest\x1a*.api.v1.services.system.DeleteMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/menus/{id}B\xde\x01\n" + + "\x1acom.api.v1.services.systemB\tMenuProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + +var ( + file_system_menu_proto_rawDescOnce sync.Once + file_system_menu_proto_rawDescData []byte +) + +func file_system_menu_proto_rawDescGZIP() []byte { + file_system_menu_proto_rawDescOnce.Do(func() { + file_system_menu_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_menu_proto_rawDesc), len(file_system_menu_proto_rawDesc))) + }) + return file_system_menu_proto_rawDescData +} + +var file_system_menu_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_system_menu_proto_goTypes = []any{ + (*ListMenusRequest)(nil), // 0: api.v1.services.system.ListMenusRequest + (*ListMenusResponse)(nil), // 1: api.v1.services.system.ListMenusResponse + (*GetMenuRequest)(nil), // 2: api.v1.services.system.GetMenuRequest + (*GetMenuResponse)(nil), // 3: api.v1.services.system.GetMenuResponse + (*CreateMenuRequest)(nil), // 4: api.v1.services.system.CreateMenuRequest + (*CreateMenuResponse)(nil), // 5: api.v1.services.system.CreateMenuResponse + (*UpdateMenuRequest)(nil), // 6: api.v1.services.system.UpdateMenuRequest + (*UpdateMenuResponse)(nil), // 7: api.v1.services.system.UpdateMenuResponse + (*DeleteMenuRequest)(nil), // 8: api.v1.services.system.DeleteMenuRequest + (*DeleteMenuResponse)(nil), // 9: api.v1.services.system.DeleteMenuResponse + (*types.Menu)(nil), // 10: api.v1.services.types.Menu + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_system_menu_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.system.ListMenusResponse.menus:type_name -> api.v1.services.types.Menu + 11, // 1: api.v1.services.system.ListMenusResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.system.GetMenuResponse.menu:type_name -> api.v1.services.types.Menu + 10, // 3: api.v1.services.system.CreateMenuRequest.menu:type_name -> api.v1.services.types.Menu + 10, // 4: api.v1.services.system.CreateMenuResponse.menu:type_name -> api.v1.services.types.Menu + 10, // 5: api.v1.services.system.UpdateMenuRequest.menu:type_name -> api.v1.services.types.Menu + 10, // 6: api.v1.services.system.UpdateMenuResponse.menu:type_name -> api.v1.services.types.Menu + 12, // 7: api.v1.services.system.DeleteMenuResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.system.MenuService.ListMenus:input_type -> api.v1.services.system.ListMenusRequest + 2, // 9: api.v1.services.system.MenuService.GetMenu:input_type -> api.v1.services.system.GetMenuRequest + 4, // 10: api.v1.services.system.MenuService.CreateMenu:input_type -> api.v1.services.system.CreateMenuRequest + 6, // 11: api.v1.services.system.MenuService.UpdateMenu:input_type -> api.v1.services.system.UpdateMenuRequest + 8, // 12: api.v1.services.system.MenuService.DeleteMenu:input_type -> api.v1.services.system.DeleteMenuRequest + 1, // 13: api.v1.services.system.MenuService.ListMenus:output_type -> api.v1.services.system.ListMenusResponse + 3, // 14: api.v1.services.system.MenuService.GetMenu:output_type -> api.v1.services.system.GetMenuResponse + 5, // 15: api.v1.services.system.MenuService.CreateMenu:output_type -> api.v1.services.system.CreateMenuResponse + 7, // 16: api.v1.services.system.MenuService.UpdateMenu:output_type -> api.v1.services.system.UpdateMenuResponse + 9, // 17: api.v1.services.system.MenuService.DeleteMenu:output_type -> api.v1.services.system.DeleteMenuResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_system_menu_proto_init() } +func file_system_menu_proto_init() { + if File_system_menu_proto != nil { + return + } + file_system_menu_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_menu_proto_rawDesc), len(file_system_menu_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_system_menu_proto_goTypes, + DependencyIndexes: file_system_menu_proto_depIdxs, + MessageInfos: file_system_menu_proto_msgTypes, + }.Build() + File_system_menu_proto = out.File + file_system_menu_proto_goTypes = nil + file_system_menu_proto_depIdxs = nil +} diff --git a/api/v1/services/system/menu.pb.gw.go b/api/v1/services/system/menu.pb.gw.go new file mode 100644 index 00000000..507b36f2 --- /dev/null +++ b/api/v1/services/system/menu.pb.gw.go @@ -0,0 +1,473 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: system/menu.proto + +/* +Package system is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package system + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_MenuService_ListMenus_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_MenuService_ListMenus_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListMenusRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_ListMenus_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListMenus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_MenuService_ListMenus_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListMenusRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_ListMenus_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListMenus(ctx, &protoReq) + return msg, metadata, err +} + +func request_MenuService_GetMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetMenuRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_MenuService_GetMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetMenuRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetMenu(ctx, &protoReq) + return msg, metadata, err +} + +var filter_MenuService_CreateMenu_0 = &utilities.DoubleArray{Encoding: map[string]int{"menu": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_MenuService_CreateMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateMenuRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_CreateMenu_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_MenuService_CreateMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateMenuRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_CreateMenu_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateMenu(ctx, &protoReq) + return msg, metadata, err +} + +func request_MenuService_UpdateMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateMenuRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["menu.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "menu.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "menu.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "menu.id", err) + } + msg, err := client.UpdateMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_MenuService_UpdateMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateMenuRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["menu.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "menu.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "menu.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "menu.id", err) + } + msg, err := server.UpdateMenu(ctx, &protoReq) + return msg, metadata, err +} + +func request_MenuService_DeleteMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteMenuRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_MenuService_DeleteMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteMenuRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteMenu(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterMenuServiceHandlerServer registers the http handlers for service MenuService to "mux". +// UnaryRPC :call MenuServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMenuServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterMenuServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MenuServiceServer) error { + mux.Handle(http.MethodGet, pattern_MenuService_ListMenus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/ListMenus", runtime.WithHTTPPathPattern("/sys/menus")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_MenuService_ListMenus_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_MenuService_ListMenus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_MenuService_GetMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/GetMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_MenuService_GetMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_MenuService_GetMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_MenuService_CreateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/CreateMenu", runtime.WithHTTPPathPattern("/sys/menus")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_MenuService_CreateMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_MenuService_CreateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_MenuService_UpdateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/UpdateMenu", runtime.WithHTTPPathPattern("/sys/menus/{menu.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_MenuService_UpdateMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_MenuService_UpdateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_MenuService_DeleteMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/DeleteMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_MenuService_DeleteMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_MenuService_DeleteMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterMenuServiceHandlerFromEndpoint is same as RegisterMenuServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterMenuServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterMenuServiceHandler(ctx, mux, conn) +} + +// RegisterMenuServiceHandler registers the http handlers for service MenuService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterMenuServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterMenuServiceHandlerClient(ctx, mux, NewMenuServiceClient(conn)) +} + +// RegisterMenuServiceHandlerClient registers the http handlers for service MenuService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MenuServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MenuServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "MenuServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterMenuServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MenuServiceClient) error { + mux.Handle(http.MethodGet, pattern_MenuService_ListMenus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/ListMenus", runtime.WithHTTPPathPattern("/sys/menus")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_MenuService_ListMenus_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_MenuService_ListMenus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_MenuService_GetMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/GetMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_MenuService_GetMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_MenuService_GetMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_MenuService_CreateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/CreateMenu", runtime.WithHTTPPathPattern("/sys/menus")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_MenuService_CreateMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_MenuService_CreateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_MenuService_UpdateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/UpdateMenu", runtime.WithHTTPPathPattern("/sys/menus/{menu.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_MenuService_UpdateMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_MenuService_UpdateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_MenuService_DeleteMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/DeleteMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_MenuService_DeleteMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_MenuService_DeleteMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_MenuService_ListMenus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "menus"}, "")) + pattern_MenuService_GetMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "menus", "id"}, "")) + pattern_MenuService_CreateMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "menus"}, "")) + pattern_MenuService_UpdateMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "menus", "menu.id"}, "")) + pattern_MenuService_DeleteMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "menus", "id"}, "")) +) + +var ( + forward_MenuService_ListMenus_0 = runtime.ForwardResponseMessage + forward_MenuService_GetMenu_0 = runtime.ForwardResponseMessage + forward_MenuService_CreateMenu_0 = runtime.ForwardResponseMessage + forward_MenuService_UpdateMenu_0 = runtime.ForwardResponseMessage + forward_MenuService_DeleteMenu_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/system/menu.pb.validate.go b/api/v1/services/system/menu.pb.validate.go new file mode 100644 index 00000000..45670aa2 --- /dev/null +++ b/api/v1/services/system/menu.pb.validate.go @@ -0,0 +1,1321 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: system/menu.proto + +package system + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListMenusRequest 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 *ListMenusRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListMenusRequest 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 +// ListMenusRequestMultiError, or nil if none found. +func (m *ListMenusRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListMenusRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Keyword + + if len(errors) > 0 { + return ListMenusRequestMultiError(errors) + } + + return nil +} + +// ListMenusRequestMultiError is an error wrapping multiple validation errors +// returned by ListMenusRequest.ValidateAll() if the designated constraints +// aren't met. +type ListMenusRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListMenusRequestMultiError) 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 ListMenusRequestMultiError) AllErrors() []error { return m } + +// ListMenusRequestValidationError is the validation error returned by +// ListMenusRequest.Validate if the designated constraints aren't met. +type ListMenusRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListMenusRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListMenusRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListMenusRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListMenusRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListMenusRequestValidationError) ErrorName() string { return "ListMenusRequestValidationError" } + +// Error satisfies the builtin error interface +func (e ListMenusRequestValidationError) 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 %sListMenusRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListMenusRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListMenusRequestValidationError{} + +// Validate checks the field values on ListMenusResponse 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 *ListMenusResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListMenusResponse 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 +// ListMenusResponseMultiError, or nil if none found. +func (m *ListMenusResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListMenusResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Total + + for idx, item := range m.GetMenus() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListMenusResponseValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListMenusResponseValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListMenusResponseValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListMenusResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListMenusResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListMenusResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListMenusResponseMultiError(errors) + } + + return nil +} + +// ListMenusResponseMultiError is an error wrapping multiple validation errors +// returned by ListMenusResponse.ValidateAll() if the designated constraints +// aren't met. +type ListMenusResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListMenusResponseMultiError) 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 ListMenusResponseMultiError) AllErrors() []error { return m } + +// ListMenusResponseValidationError is the validation error returned by +// ListMenusResponse.Validate if the designated constraints aren't met. +type ListMenusResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListMenusResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListMenusResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListMenusResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListMenusResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListMenusResponseValidationError) ErrorName() string { + return "ListMenusResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListMenusResponseValidationError) 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 %sListMenusResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListMenusResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListMenusResponseValidationError{} + +// Validate checks the field values on GetMenuRequest 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 *GetMenuRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetMenuRequest 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 GetMenuRequestMultiError, +// or nil if none found. +func (m *GetMenuRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetMenuRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetMenuRequestMultiError(errors) + } + + return nil +} + +// GetMenuRequestMultiError is an error wrapping multiple validation errors +// returned by GetMenuRequest.ValidateAll() if the designated constraints +// aren't met. +type GetMenuRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetMenuRequestMultiError) 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 GetMenuRequestMultiError) AllErrors() []error { return m } + +// GetMenuRequestValidationError is the validation error returned by +// GetMenuRequest.Validate if the designated constraints aren't met. +type GetMenuRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetMenuRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetMenuRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetMenuRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetMenuRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetMenuRequestValidationError) ErrorName() string { return "GetMenuRequestValidationError" } + +// Error satisfies the builtin error interface +func (e GetMenuRequestValidationError) 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 %sGetMenuRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetMenuRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetMenuRequestValidationError{} + +// Validate checks the field values on GetMenuResponse 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 *GetMenuResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetMenuResponse 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 +// GetMenuResponseMultiError, or nil if none found. +func (m *GetMenuResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetMenuResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetMenuResponseValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetMenuResponseValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetMenuResponseValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetMenuResponseMultiError(errors) + } + + return nil +} + +// GetMenuResponseMultiError is an error wrapping multiple validation errors +// returned by GetMenuResponse.ValidateAll() if the designated constraints +// aren't met. +type GetMenuResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetMenuResponseMultiError) 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 GetMenuResponseMultiError) AllErrors() []error { return m } + +// GetMenuResponseValidationError is the validation error returned by +// GetMenuResponse.Validate if the designated constraints aren't met. +type GetMenuResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetMenuResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetMenuResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetMenuResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetMenuResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetMenuResponseValidationError) ErrorName() string { return "GetMenuResponseValidationError" } + +// Error satisfies the builtin error interface +func (e GetMenuResponseValidationError) 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 %sGetMenuResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetMenuResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetMenuResponseValidationError{} + +// Validate checks the field values on CreateMenuRequest 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 *CreateMenuRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateMenuRequest 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 +// CreateMenuRequestMultiError, or nil if none found. +func (m *CreateMenuRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateMenuRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for MenuId + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateMenuRequestValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateMenuRequestValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateMenuRequestValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateMenuRequestMultiError(errors) + } + + return nil +} + +// CreateMenuRequestMultiError is an error wrapping multiple validation errors +// returned by CreateMenuRequest.ValidateAll() if the designated constraints +// aren't met. +type CreateMenuRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateMenuRequestMultiError) 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 CreateMenuRequestMultiError) AllErrors() []error { return m } + +// CreateMenuRequestValidationError is the validation error returned by +// CreateMenuRequest.Validate if the designated constraints aren't met. +type CreateMenuRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateMenuRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateMenuRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateMenuRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateMenuRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateMenuRequestValidationError) ErrorName() string { + return "CreateMenuRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateMenuRequestValidationError) 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 %sCreateMenuRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateMenuRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateMenuRequestValidationError{} + +// Validate checks the field values on CreateMenuResponse 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 *CreateMenuResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateMenuResponse 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 +// CreateMenuResponseMultiError, or nil if none found. +func (m *CreateMenuResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateMenuResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateMenuResponseValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateMenuResponseValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateMenuResponseValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateMenuResponseMultiError(errors) + } + + return nil +} + +// CreateMenuResponseMultiError is an error wrapping multiple validation errors +// returned by CreateMenuResponse.ValidateAll() if the designated constraints +// aren't met. +type CreateMenuResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateMenuResponseMultiError) 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 CreateMenuResponseMultiError) AllErrors() []error { return m } + +// CreateMenuResponseValidationError is the validation error returned by +// CreateMenuResponse.Validate if the designated constraints aren't met. +type CreateMenuResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateMenuResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateMenuResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateMenuResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateMenuResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateMenuResponseValidationError) ErrorName() string { + return "CreateMenuResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateMenuResponseValidationError) 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 %sCreateMenuResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateMenuResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateMenuResponseValidationError{} + +// Validate checks the field values on UpdateMenuRequest 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 *UpdateMenuRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateMenuRequest 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 +// UpdateMenuRequestMultiError, or nil if none found. +func (m *UpdateMenuRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateMenuRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateMenuRequestValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateMenuRequestValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateMenuRequestValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateMenuRequestMultiError(errors) + } + + return nil +} + +// UpdateMenuRequestMultiError is an error wrapping multiple validation errors +// returned by UpdateMenuRequest.ValidateAll() if the designated constraints +// aren't met. +type UpdateMenuRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateMenuRequestMultiError) 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 UpdateMenuRequestMultiError) AllErrors() []error { return m } + +// UpdateMenuRequestValidationError is the validation error returned by +// UpdateMenuRequest.Validate if the designated constraints aren't met. +type UpdateMenuRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateMenuRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateMenuRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateMenuRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateMenuRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateMenuRequestValidationError) ErrorName() string { + return "UpdateMenuRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateMenuRequestValidationError) 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 %sUpdateMenuRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateMenuRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateMenuRequestValidationError{} + +// Validate checks the field values on UpdateMenuResponse 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 *UpdateMenuResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateMenuResponse 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 +// UpdateMenuResponseMultiError, or nil if none found. +func (m *UpdateMenuResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateMenuResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateMenuResponseValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateMenuResponseValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateMenuResponseValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateMenuResponseMultiError(errors) + } + + return nil +} + +// UpdateMenuResponseMultiError is an error wrapping multiple validation errors +// returned by UpdateMenuResponse.ValidateAll() if the designated constraints +// aren't met. +type UpdateMenuResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateMenuResponseMultiError) 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 UpdateMenuResponseMultiError) AllErrors() []error { return m } + +// UpdateMenuResponseValidationError is the validation error returned by +// UpdateMenuResponse.Validate if the designated constraints aren't met. +type UpdateMenuResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateMenuResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateMenuResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateMenuResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateMenuResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateMenuResponseValidationError) ErrorName() string { + return "UpdateMenuResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateMenuResponseValidationError) 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 %sUpdateMenuResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateMenuResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateMenuResponseValidationError{} + +// Validate checks the field values on DeleteMenuRequest 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 *DeleteMenuRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteMenuRequest 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 +// DeleteMenuRequestMultiError, or nil if none found. +func (m *DeleteMenuRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteMenuRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeleteMenuRequestMultiError(errors) + } + + return nil +} + +// DeleteMenuRequestMultiError is an error wrapping multiple validation errors +// returned by DeleteMenuRequest.ValidateAll() if the designated constraints +// aren't met. +type DeleteMenuRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteMenuRequestMultiError) 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 DeleteMenuRequestMultiError) AllErrors() []error { return m } + +// DeleteMenuRequestValidationError is the validation error returned by +// DeleteMenuRequest.Validate if the designated constraints aren't met. +type DeleteMenuRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteMenuRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteMenuRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteMenuRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteMenuRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteMenuRequestValidationError) ErrorName() string { + return "DeleteMenuRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteMenuRequestValidationError) 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 %sDeleteMenuRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteMenuRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteMenuRequestValidationError{} + +// Validate checks the field values on DeleteMenuResponse 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 *DeleteMenuResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteMenuResponse 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 +// DeleteMenuResponseMultiError, or nil if none found. +func (m *DeleteMenuResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteMenuResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteMenuResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteMenuResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteMenuResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteMenuResponseMultiError(errors) + } + + return nil +} + +// DeleteMenuResponseMultiError is an error wrapping multiple validation errors +// returned by DeleteMenuResponse.ValidateAll() if the designated constraints +// aren't met. +type DeleteMenuResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteMenuResponseMultiError) 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 DeleteMenuResponseMultiError) AllErrors() []error { return m } + +// DeleteMenuResponseValidationError is the validation error returned by +// DeleteMenuResponse.Validate if the designated constraints aren't met. +type DeleteMenuResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteMenuResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteMenuResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteMenuResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteMenuResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteMenuResponseValidationError) ErrorName() string { + return "DeleteMenuResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteMenuResponseValidationError) 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 %sDeleteMenuResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteMenuResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteMenuResponseValidationError{} diff --git a/api/v1/services/system/menu_bridge.pb.go b/api/v1/services/system/menu_bridge.pb.go new file mode 100644 index 00000000..03afbf8b --- /dev/null +++ b/api/v1/services/system/menu_bridge.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/menu.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const MenuServiceCreateMenuBridgeOperation = "/api.v1.services.system.MenuService/CreateMenu" +const MenuServiceDeleteMenuBridgeOperation = "/api.v1.services.system.MenuService/DeleteMenu" +const MenuServiceGetMenuBridgeOperation = "/api.v1.services.system.MenuService/GetMenu" +const MenuServiceListMenusBridgeOperation = "/api.v1.services.system.MenuService/ListMenus" +const MenuServiceUpdateMenuBridgeOperation = "/api.v1.services.system.MenuService/UpdateMenu" + +type MenuServiceBridgeServer interface { + CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) + DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) + GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) + ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) + UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) +} + +type MenuServiceHooker interface { + MenuServiceCreateMenuHooker + MenuServiceDeleteMenuHooker + MenuServiceGetMenuHooker + MenuServiceListMenusHooker + MenuServiceUpdateMenuHooker +} + +type MenuServiceHookedBridger interface { + MenuServiceHooker + MenuServiceBridgeServer +} +type MenuServiceCreateMenuHooker interface { + PrepareCreateMenu(http.Context, *CreateMenuRequest) (context.Context, error) + CompleteCreateMenu(http.Context, *CreateMenuRequest, *CreateMenuResponse) error +} +type MenuServiceDeleteMenuHooker interface { + PrepareDeleteMenu(http.Context, *DeleteMenuRequest) (context.Context, error) + CompleteDeleteMenu(http.Context, *DeleteMenuRequest, *DeleteMenuResponse) error +} +type MenuServiceGetMenuHooker interface { + PrepareGetMenu(http.Context, *GetMenuRequest) (context.Context, error) + CompleteGetMenu(http.Context, *GetMenuRequest, *GetMenuResponse) error +} +type MenuServiceListMenusHooker interface { + PrepareListMenus(http.Context, *ListMenusRequest) (context.Context, error) + CompleteListMenus(http.Context, *ListMenusRequest, *ListMenusResponse) error +} +type MenuServiceUpdateMenuHooker interface { + PrepareUpdateMenu(http.Context, *UpdateMenuRequest) (context.Context, error) + CompleteUpdateMenu(http.Context, *UpdateMenuRequest, *UpdateMenuResponse) error +} + +func RegisterMenuServiceBridgeServer(s *http.Server, srv MenuServiceHookedBridger) { + r := s.Route("/") + r.GET("/sys/menus", _MenuService_ListMenus0_Bridge_Handler(srv)) + r.GET("/sys/menus/:id", _MenuService_GetMenu0_Bridge_Handler(srv)) + r.POST("/sys/menus", _MenuService_CreateMenu0_Bridge_Handler(srv)) + r.PUT("/sys/menus/:menu.id", _MenuService_UpdateMenu0_Bridge_Handler(srv)) + r.DELETE("/sys/menus/:id", _MenuService_DeleteMenu0_Bridge_Handler(srv)) +} + +func _MenuService_ListMenus0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListMenusRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceListMenus) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListMenus(ctx, req.(*ListMenusRequest)) + }) + + newctx, err := srv.PrepareListMenus(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListMenus(ctx, &in, out.(*ListMenusResponse)) + } +} + +func _MenuService_GetMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetMenuRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceGetMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetMenu(ctx, req.(*GetMenuRequest)) + }) + + newctx, err := srv.PrepareGetMenu(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetMenu(ctx, &in, out.(*GetMenuResponse)) + } +} + +func _MenuService_CreateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateMenuRequest + if err := ctx.Bind(&in.Menu); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceCreateMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateMenu(ctx, req.(*CreateMenuRequest)) + }) + + newctx, err := srv.PrepareCreateMenu(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateMenu(ctx, &in, out.(*CreateMenuResponse)) + } +} + +func _MenuService_UpdateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateMenuRequest + if err := ctx.Bind(&in.Menu); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceUpdateMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateMenu(ctx, req.(*UpdateMenuRequest)) + }) + + newctx, err := srv.PrepareUpdateMenu(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateMenu(ctx, &in, out.(*UpdateMenuResponse)) + } +} + +func _MenuService_DeleteMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteMenuRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceDeleteMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteMenu(ctx, req.(*DeleteMenuRequest)) + }) + + newctx, err := srv.PrepareDeleteMenu(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteMenu(ctx, &in, out.(*DeleteMenuResponse)) + } +} + +// UnimplementedMenuServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMenuServiceHooked struct{} + +func (UnimplementedMenuServiceHooked) PrepareCreateMenu(ctx http.Context, in *CreateMenuRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMenuServiceHooked) CompleteCreateMenu(ctx http.Context, in *CreateMenuRequest, out *CreateMenuResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedMenuServiceHooked) PrepareDeleteMenu(ctx http.Context, in *DeleteMenuRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMenuServiceHooked) CompleteDeleteMenu(ctx http.Context, in *DeleteMenuRequest, out *DeleteMenuResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedMenuServiceHooked) PrepareGetMenu(ctx http.Context, in *GetMenuRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMenuServiceHooked) CompleteGetMenu(ctx http.Context, in *GetMenuRequest, out *GetMenuResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedMenuServiceHooked) PrepareListMenus(ctx http.Context, in *ListMenusRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMenuServiceHooked) CompleteListMenus(ctx http.Context, in *ListMenusRequest, out *ListMenusResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedMenuServiceHooked) PrepareUpdateMenu(ctx http.Context, in *UpdateMenuRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMenuServiceHooked) CompleteUpdateMenu(ctx http.Context, in *UpdateMenuRequest, out *UpdateMenuResponse) error { + return ctx.Result(200, out) +} + +func WithMenuServiceHook(h MenuServiceHooker) func(MenuServiceBridgeServer) MenuServiceHookedBridger { + return func(srv MenuServiceBridgeServer) MenuServiceHookedBridger { + return MenuServiceHookedBridge{MenuServiceBridgeServer: srv, MenuServiceHooker: h} + } +} + +// MenuServiceHookedBridge is a bridge between the HTTP and gRPC implementations of MenuService. +// It implements the HTTP and gRPC implementations of MenuService. +// It forwards requests and responses between the two implementations. +type MenuServiceHookedBridge struct { + MenuServiceBridgeServer + MenuServiceHooker +} + +type MenuServiceHTTPBridgeImpl struct { + client MenuServiceHTTPClient +} + +func NewMenuServiceHTTPBridge(client *http.Client) MenuServiceHTTPServer { + return &MenuServiceHTTPBridgeImpl{client: NewMenuServiceHTTPClient(client)} +} + +func (c *MenuServiceHTTPBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { + return c.client.CreateMenu(ctx, in) +} + +func (c *MenuServiceHTTPBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { + return c.client.DeleteMenu(ctx, in) +} + +func (c *MenuServiceHTTPBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { + return c.client.GetMenu(ctx, in) +} + +func (c *MenuServiceHTTPBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { + return c.client.ListMenus(ctx, in) +} + +func (c *MenuServiceHTTPBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { + return c.client.UpdateMenu(ctx, in) +} + +type MenuServiceBridgeImpl struct { + client MenuServiceClient +} + +func NewMenuServiceBridge(client grpc.ClientConnInterface) MenuServiceServer { + return &MenuServiceBridgeImpl{client: NewMenuServiceClient(client)} +} + +func (c *MenuServiceBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { + return c.client.CreateMenu(ctx, in) +} + +func (c *MenuServiceBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { + return c.client.DeleteMenu(ctx, in) +} + +func (c *MenuServiceBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { + return c.client.GetMenu(ctx, in) +} + +func (c *MenuServiceBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { + return c.client.ListMenus(ctx, in) +} + +func (c *MenuServiceBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { + return c.client.UpdateMenu(ctx, in) +} + +func (c *MenuServiceBridgeImpl) mustEmbedUnimplementedMenuServiceServer() {} + +type MenuServiceGRPC2HTTPBridgeImpl struct { + client MenuServiceClient +} + +func NewMenuServiceGRPC2HTTP(client grpc.ClientConnInterface) MenuServiceHTTPServer { + return &MenuServiceGRPC2HTTPBridgeImpl{client: NewMenuServiceClient(client)} +} + +func (c *MenuServiceGRPC2HTTPBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { + return c.client.CreateMenu(ctx, in) +} + +func (c *MenuServiceGRPC2HTTPBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { + return c.client.DeleteMenu(ctx, in) +} + +func (c *MenuServiceGRPC2HTTPBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { + return c.client.GetMenu(ctx, in) +} + +func (c *MenuServiceGRPC2HTTPBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { + return c.client.ListMenus(ctx, in) +} + +func (c *MenuServiceGRPC2HTTPBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { + return c.client.UpdateMenu(ctx, in) +} + +type MenuServiceHTTP2GRPCBridgeImpl struct { + client MenuServiceHTTPClient +} + +func NewMenuServiceHTTP2GRPC(client *http.Client) MenuServiceServer { + return &MenuServiceHTTP2GRPCBridgeImpl{client: NewMenuServiceHTTPClient(client)} +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { + return c.client.CreateMenu(ctx, in) +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { + return c.client.DeleteMenu(ctx, in) +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { + return c.client.GetMenu(ctx, in) +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { + return c.client.ListMenus(ctx, in) +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { + return c.client.UpdateMenu(ctx, in) +} + +func (c *MenuServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedMenuServiceServer() {} diff --git a/api/v1/services/system/menu_grpc.pb.go b/api/v1/services/system/menu_grpc.pb.go new file mode 100644 index 00000000..69f1f159 --- /dev/null +++ b/api/v1/services/system/menu_grpc.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: system/menu.proto + +package system + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + MenuService_ListMenus_FullMethodName = "/api.v1.services.system.MenuService/ListMenus" + MenuService_GetMenu_FullMethodName = "/api.v1.services.system.MenuService/GetMenu" + MenuService_CreateMenu_FullMethodName = "/api.v1.services.system.MenuService/CreateMenu" + MenuService_UpdateMenu_FullMethodName = "/api.v1.services.system.MenuService/UpdateMenu" + MenuService_DeleteMenu_FullMethodName = "/api.v1.services.system.MenuService/DeleteMenu" +) + +// MenuServiceClient is the client API for MenuService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The menu service definition. +type MenuServiceClient interface { + ListMenus(ctx context.Context, in *ListMenusRequest, opts ...grpc.CallOption) (*ListMenusResponse, error) + GetMenu(ctx context.Context, in *GetMenuRequest, opts ...grpc.CallOption) (*GetMenuResponse, error) + CreateMenu(ctx context.Context, in *CreateMenuRequest, opts ...grpc.CallOption) (*CreateMenuResponse, error) + UpdateMenu(ctx context.Context, in *UpdateMenuRequest, opts ...grpc.CallOption) (*UpdateMenuResponse, error) + DeleteMenu(ctx context.Context, in *DeleteMenuRequest, opts ...grpc.CallOption) (*DeleteMenuResponse, error) +} + +type menuServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewMenuServiceClient(cc grpc.ClientConnInterface) MenuServiceClient { + return &menuServiceClient{cc} +} + +func (c *menuServiceClient) ListMenus(ctx context.Context, in *ListMenusRequest, opts ...grpc.CallOption) (*ListMenusResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListMenusResponse) + err := c.cc.Invoke(ctx, MenuService_ListMenus_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *menuServiceClient) GetMenu(ctx context.Context, in *GetMenuRequest, opts ...grpc.CallOption) (*GetMenuResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetMenuResponse) + err := c.cc.Invoke(ctx, MenuService_GetMenu_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *menuServiceClient) CreateMenu(ctx context.Context, in *CreateMenuRequest, opts ...grpc.CallOption) (*CreateMenuResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateMenuResponse) + err := c.cc.Invoke(ctx, MenuService_CreateMenu_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *menuServiceClient) UpdateMenu(ctx context.Context, in *UpdateMenuRequest, opts ...grpc.CallOption) (*UpdateMenuResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateMenuResponse) + err := c.cc.Invoke(ctx, MenuService_UpdateMenu_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *menuServiceClient) DeleteMenu(ctx context.Context, in *DeleteMenuRequest, opts ...grpc.CallOption) (*DeleteMenuResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteMenuResponse) + err := c.cc.Invoke(ctx, MenuService_DeleteMenu_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MenuServiceServer is the server API for MenuService service. +// All implementations must embed UnimplementedMenuServiceServer +// for forward compatibility. +// +// The menu service definition. +type MenuServiceServer interface { + ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) + GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) + CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) + UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) + DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) + mustEmbedUnimplementedMenuServiceServer() +} + +// UnimplementedMenuServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMenuServiceServer struct{} + +func (UnimplementedMenuServiceServer) ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListMenus not implemented") +} +func (UnimplementedMenuServiceServer) GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetMenu not implemented") +} +func (UnimplementedMenuServiceServer) CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateMenu not implemented") +} +func (UnimplementedMenuServiceServer) UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateMenu not implemented") +} +func (UnimplementedMenuServiceServer) DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteMenu not implemented") +} +func (UnimplementedMenuServiceServer) mustEmbedUnimplementedMenuServiceServer() {} +func (UnimplementedMenuServiceServer) testEmbeddedByValue() {} + +// UnsafeMenuServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MenuServiceServer will +// result in compilation errors. +type UnsafeMenuServiceServer interface { + mustEmbedUnimplementedMenuServiceServer() +} + +func RegisterMenuServiceServer(s grpc.ServiceRegistrar, srv MenuServiceServer) { + // If the following call pancis, it indicates UnimplementedMenuServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&MenuService_ServiceDesc, srv) +} + +func _MenuService_ListMenus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListMenusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MenuServiceServer).ListMenus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: MenuService_ListMenus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MenuServiceServer).ListMenus(ctx, req.(*ListMenusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _MenuService_GetMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetMenuRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MenuServiceServer).GetMenu(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: MenuService_GetMenu_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MenuServiceServer).GetMenu(ctx, req.(*GetMenuRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _MenuService_CreateMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateMenuRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MenuServiceServer).CreateMenu(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: MenuService_CreateMenu_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MenuServiceServer).CreateMenu(ctx, req.(*CreateMenuRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _MenuService_UpdateMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateMenuRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MenuServiceServer).UpdateMenu(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: MenuService_UpdateMenu_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MenuServiceServer).UpdateMenu(ctx, req.(*UpdateMenuRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _MenuService_DeleteMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteMenuRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MenuServiceServer).DeleteMenu(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: MenuService_DeleteMenu_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MenuServiceServer).DeleteMenu(ctx, req.(*DeleteMenuRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// MenuService_ServiceDesc is the grpc.ServiceDesc for MenuService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var MenuService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.system.MenuService", + HandlerType: (*MenuServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListMenus", + Handler: _MenuService_ListMenus_Handler, + }, + { + MethodName: "GetMenu", + Handler: _MenuService_GetMenu_Handler, + }, + { + MethodName: "CreateMenu", + Handler: _MenuService_CreateMenu_Handler, + }, + { + MethodName: "UpdateMenu", + Handler: _MenuService_UpdateMenu_Handler, + }, + { + MethodName: "DeleteMenu", + Handler: _MenuService_DeleteMenu_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "system/menu.proto", +} diff --git a/api/v1/services/system/menu_http.pb.go b/api/v1/services/system/menu_http.pb.go new file mode 100644 index 00000000..ff62da43 --- /dev/null +++ b/api/v1/services/system/menu_http.pb.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: system/menu.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationMenuServiceCreateMenu = "/api.v1.services.system.MenuService/CreateMenu" +const OperationMenuServiceDeleteMenu = "/api.v1.services.system.MenuService/DeleteMenu" +const OperationMenuServiceGetMenu = "/api.v1.services.system.MenuService/GetMenu" +const OperationMenuServiceListMenus = "/api.v1.services.system.MenuService/ListMenus" +const OperationMenuServiceUpdateMenu = "/api.v1.services.system.MenuService/UpdateMenu" + +type MenuServiceHTTPServer interface { + CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) + DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) + GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) + ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) + UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) +} + +func RegisterMenuServiceHTTPServer(s *http.Server, srv MenuServiceHTTPServer) { + r := s.Route("/") + r.GET("/sys/menus", _MenuService_ListMenus0_HTTP_Handler(srv)) + r.GET("/sys/menus/{id}", _MenuService_GetMenu0_HTTP_Handler(srv)) + r.POST("/sys/menus", _MenuService_CreateMenu0_HTTP_Handler(srv)) + r.PUT("/sys/menus/{menu.id}", _MenuService_UpdateMenu0_HTTP_Handler(srv)) + r.DELETE("/sys/menus/{id}", _MenuService_DeleteMenu0_HTTP_Handler(srv)) +} + +func _MenuService_ListMenus0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListMenusRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceListMenus) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListMenus(ctx, req.(*ListMenusRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListMenusResponse) + return ctx.Result(200, reply) + } +} + +func _MenuService_GetMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetMenuRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceGetMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetMenu(ctx, req.(*GetMenuRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetMenuResponse) + return ctx.Result(200, reply) + } +} + +func _MenuService_CreateMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateMenuRequest + if err := ctx.Bind(&in.Menu); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceCreateMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateMenu(ctx, req.(*CreateMenuRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateMenuResponse) + return ctx.Result(200, reply) + } +} + +func _MenuService_UpdateMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateMenuRequest + if err := ctx.Bind(&in.Menu); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceUpdateMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateMenu(ctx, req.(*UpdateMenuRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateMenuResponse) + return ctx.Result(200, reply) + } +} + +func _MenuService_DeleteMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteMenuRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMenuServiceDeleteMenu) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteMenu(ctx, req.(*DeleteMenuRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeleteMenuResponse) + return ctx.Result(200, reply) + } +} + +type MenuServiceHTTPClient interface { + CreateMenu(ctx context.Context, req *CreateMenuRequest, opts ...http.CallOption) (rsp *CreateMenuResponse, err error) + DeleteMenu(ctx context.Context, req *DeleteMenuRequest, opts ...http.CallOption) (rsp *DeleteMenuResponse, err error) + GetMenu(ctx context.Context, req *GetMenuRequest, opts ...http.CallOption) (rsp *GetMenuResponse, err error) + ListMenus(ctx context.Context, req *ListMenusRequest, opts ...http.CallOption) (rsp *ListMenusResponse, err error) + UpdateMenu(ctx context.Context, req *UpdateMenuRequest, opts ...http.CallOption) (rsp *UpdateMenuResponse, err error) +} + +type MenuServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewMenuServiceHTTPClient(client *http.Client) MenuServiceHTTPClient { + return &MenuServiceHTTPClientImpl{client} +} + +func (c *MenuServiceHTTPClientImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest, opts ...http.CallOption) (*CreateMenuResponse, error) { + var out CreateMenuResponse + pattern := "/sys/menus" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationMenuServiceCreateMenu)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Menu, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *MenuServiceHTTPClientImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest, opts ...http.CallOption) (*DeleteMenuResponse, error) { + var out DeleteMenuResponse + pattern := "/sys/menus/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationMenuServiceDeleteMenu)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *MenuServiceHTTPClientImpl) GetMenu(ctx context.Context, in *GetMenuRequest, opts ...http.CallOption) (*GetMenuResponse, error) { + var out GetMenuResponse + pattern := "/sys/menus/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationMenuServiceGetMenu)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *MenuServiceHTTPClientImpl) ListMenus(ctx context.Context, in *ListMenusRequest, opts ...http.CallOption) (*ListMenusResponse, error) { + var out ListMenusResponse + pattern := "/sys/menus" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationMenuServiceListMenus)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *MenuServiceHTTPClientImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest, opts ...http.CallOption) (*UpdateMenuResponse, error) { + var out UpdateMenuResponse + pattern := "/sys/menus/{menu.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationMenuServiceUpdateMenu)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Menu, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/system/permission.pb.go b/api/v1/services/system/permission.pb.go new file mode 100644 index 00000000..beca8545 --- /dev/null +++ b/api/v1/services/system/permission.pb.go @@ -0,0 +1,756 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: system/permission.proto + +package system + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListPermissionsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The page number. + Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // The data_scopes is used to query the permission by data scopes. + DataScopes []string `protobuf:"bytes,7,rep,name=data_scopes,proto3" json:"data_scopes,omitempty"` + // The keyword is the query parameter for set only to query the permission by keyword + Keyword string `protobuf:"bytes,8,opt,name=keyword,proto3" json:"keyword,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPermissionsRequest) Reset() { + *x = ListPermissionsRequest{} + mi := &file_system_permission_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPermissionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPermissionsRequest) ProtoMessage() {} + +func (x *ListPermissionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_permission_proto_msgTypes[0] + 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 ListPermissionsRequest.ProtoReflect.Descriptor instead. +func (*ListPermissionsRequest) Descriptor() ([]byte, []int) { + return file_system_permission_proto_rawDescGZIP(), []int{0} +} + +func (x *ListPermissionsRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListPermissionsRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListPermissionsRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListPermissionsRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListPermissionsRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListPermissionsRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListPermissionsRequest) GetDataScopes() []string { + if x != nil { + return x.DataScopes + } + return nil +} + +func (x *ListPermissionsRequest) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +type ListPermissionsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` + // The paging menus + Permissions []*types.Permission `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty"` + // The page number. + Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the page data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPermissionsResponse) Reset() { + *x = ListPermissionsResponse{} + mi := &file_system_permission_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPermissionsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPermissionsResponse) ProtoMessage() {} + +func (x *ListPermissionsResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_permission_proto_msgTypes[1] + 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 ListPermissionsResponse.ProtoReflect.Descriptor instead. +func (*ListPermissionsResponse) Descriptor() ([]byte, []int) { + return file_system_permission_proto_rawDescGZIP(), []int{1} +} + +func (x *ListPermissionsResponse) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *ListPermissionsResponse) GetPermissions() []*types.Permission { + if x != nil { + return x.Permissions + } + return nil +} + +func (x *ListPermissionsResponse) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListPermissionsResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListPermissionsResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListPermissionsResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +type GetPermissionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the resource requested, for example: + // "shelves/shelf1/permissions/permission2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPermissionRequest) Reset() { + *x = GetPermissionRequest{} + mi := &file_system_permission_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPermissionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPermissionRequest) ProtoMessage() {} + +func (x *GetPermissionRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_permission_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPermissionRequest.ProtoReflect.Descriptor instead. +func (*GetPermissionRequest) Descriptor() ([]byte, []int) { + return file_system_permission_proto_rawDescGZIP(), []int{2} +} + +func (x *GetPermissionRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type GetPermissionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Permission *types.Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPermissionResponse) Reset() { + *x = GetPermissionResponse{} + mi := &file_system_permission_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPermissionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPermissionResponse) ProtoMessage() {} + +func (x *GetPermissionResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_permission_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetPermissionResponse.ProtoReflect.Descriptor instead. +func (*GetPermissionResponse) Descriptor() ([]byte, []int) { + return file_system_permission_proto_rawDescGZIP(), []int{3} +} + +func (x *GetPermissionResponse) GetPermission() *types.Permission { + if x != nil { + return x.Permission + } + return nil +} + +type CreatePermissionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id where the permission is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The permission id to use for this permission. + PermissionId string `protobuf:"bytes,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + // The permission resource to create. + // The field id should match the Noun in the method id. + Permission *types.Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreatePermissionRequest) Reset() { + *x = CreatePermissionRequest{} + mi := &file_system_permission_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreatePermissionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePermissionRequest) ProtoMessage() {} + +func (x *CreatePermissionRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_permission_proto_msgTypes[4] + 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 CreatePermissionRequest.ProtoReflect.Descriptor instead. +func (*CreatePermissionRequest) Descriptor() ([]byte, []int) { + return file_system_permission_proto_rawDescGZIP(), []int{4} +} + +func (x *CreatePermissionRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreatePermissionRequest) GetPermissionId() string { + if x != nil { + return x.PermissionId + } + return "" +} + +func (x *CreatePermissionRequest) GetPermission() *types.Permission { + if x != nil { + return x.Permission + } + return nil +} + +type CreatePermissionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Permission *types.Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreatePermissionResponse) Reset() { + *x = CreatePermissionResponse{} + mi := &file_system_permission_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreatePermissionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePermissionResponse) ProtoMessage() {} + +func (x *CreatePermissionResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_permission_proto_msgTypes[5] + 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 CreatePermissionResponse.ProtoReflect.Descriptor instead. +func (*CreatePermissionResponse) Descriptor() ([]byte, []int) { + return file_system_permission_proto_rawDescGZIP(), []int{5} +} + +func (x *CreatePermissionResponse) GetPermission() *types.Permission { + if x != nil { + return x.Permission + } + return nil +} + +type UpdatePermissionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The resource name of the permission to update. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The permission resource which replaces the resource on the server. + Permission *types.Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePermissionRequest) Reset() { + *x = UpdatePermissionRequest{} + mi := &file_system_permission_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePermissionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePermissionRequest) ProtoMessage() {} + +func (x *UpdatePermissionRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_permission_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 UpdatePermissionRequest.ProtoReflect.Descriptor instead. +func (*UpdatePermissionRequest) Descriptor() ([]byte, []int) { + return file_system_permission_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdatePermissionRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdatePermissionRequest) GetPermission() *types.Permission { + if x != nil { + return x.Permission + } + return nil +} + +type UpdatePermissionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Permission *types.Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePermissionResponse) Reset() { + *x = UpdatePermissionResponse{} + mi := &file_system_permission_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePermissionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePermissionResponse) ProtoMessage() {} + +func (x *UpdatePermissionResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_permission_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdatePermissionResponse.ProtoReflect.Descriptor instead. +func (*UpdatePermissionResponse) Descriptor() ([]byte, []int) { + return file_system_permission_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdatePermissionResponse) GetPermission() *types.Permission { + if x != nil { + return x.Permission + } + return nil +} + +type DeletePermissionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The resource id of the permission to be deleted, for example: + // "shelves/shelf1/permissions/permission2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeletePermissionRequest) Reset() { + *x = DeletePermissionRequest{} + mi := &file_system_permission_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeletePermissionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeletePermissionRequest) ProtoMessage() {} + +func (x *DeletePermissionRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_permission_proto_msgTypes[8] + 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 DeletePermissionRequest.ProtoReflect.Descriptor instead. +func (*DeletePermissionRequest) Descriptor() ([]byte, []int) { + return file_system_permission_proto_rawDescGZIP(), []int{8} +} + +func (x *DeletePermissionRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type DeletePermissionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeletePermissionResponse) Reset() { + *x = DeletePermissionResponse{} + mi := &file_system_permission_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeletePermissionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeletePermissionResponse) ProtoMessage() {} + +func (x *DeletePermissionResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_permission_proto_msgTypes[9] + 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 DeletePermissionResponse.ProtoReflect.Descriptor instead. +func (*DeletePermissionResponse) Descriptor() ([]byte, []int) { + return file_system_permission_proto_rawDescGZIP(), []int{9} +} + +func (x *DeletePermissionResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_system_permission_proto protoreflect.FileDescriptor + +const file_system_permission_proto_rawDesc = "" + + "\n" + + "\x17system/permission.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xf4\x01\n" + + "\x16ListPermissionsRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12 \n" + + "\vdata_scopes\x18\a \x03(\tR\vdata_scopes\x12\x18\n" + + "\akeyword\x18\b \x01(\tR\akeyword\"\x8b\x02\n" + + "\x17ListPermissionsResponse\x12\x14\n" + + "\x05total\x18\x01 \x01(\x05R\x05total\x12C\n" + + "\vpermissions\x18\x02 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12\x12\n" + + "\x04page\x18\x03 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"&\n" + + "\x14GetPermissionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"Z\n" + + "\x15GetPermissionResponse\x12A\n" + + "\n" + + "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"\x9a\x01\n" + + "\x17CreatePermissionRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12$\n" + + "\rpermission_id\x18\x03 \x01(\tR\rpermission_id\x12A\n" + + "\n" + + "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"]\n" + + "\x18CreatePermissionResponse\x12A\n" + + "\n" + + "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"l\n" + + "\x17UpdatePermissionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12A\n" + + "\n" + + "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"]\n" + + "\x18UpdatePermissionResponse\x12A\n" + + "\n" + + "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\")\n" + + "\x17DeletePermissionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + + "\x18DeletePermissionResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x93\x06\n" + + "\x11PermissionService\x12\x8c\x01\n" + + "\x0fListPermissions\x12..api.v1.services.system.ListPermissionsRequest\x1a/.api.v1.services.system.ListPermissionsResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/permissions\x12\x8b\x01\n" + + "\rGetPermission\x12,.api.v1.services.system.GetPermissionRequest\x1a-.api.v1.services.system.GetPermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/permissions/{id}\x12\x9b\x01\n" + + "\x10CreatePermission\x12/.api.v1.services.system.CreatePermissionRequest\x1a0.api.v1.services.system.CreatePermissionResponse\"$\x82\xd3\xe4\x93\x02\x1e:\n" + + "permission\"\x10/sys/permissions\x12\xab\x01\n" + + "\x10UpdatePermission\x12/.api.v1.services.system.UpdatePermissionRequest\x1a0.api.v1.services.system.UpdatePermissionResponse\"4\x82\xd3\xe4\x93\x02.:\n" + + "permission\x1a /sys/permissions/{permission.id}\x12\x94\x01\n" + + "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xe4\x01\n" + + "\x1acom.api.v1.services.systemB\x0fPermissionProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + +var ( + file_system_permission_proto_rawDescOnce sync.Once + file_system_permission_proto_rawDescData []byte +) + +func file_system_permission_proto_rawDescGZIP() []byte { + file_system_permission_proto_rawDescOnce.Do(func() { + file_system_permission_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_permission_proto_rawDesc), len(file_system_permission_proto_rawDesc))) + }) + return file_system_permission_proto_rawDescData +} + +var file_system_permission_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_system_permission_proto_goTypes = []any{ + (*ListPermissionsRequest)(nil), // 0: api.v1.services.system.ListPermissionsRequest + (*ListPermissionsResponse)(nil), // 1: api.v1.services.system.ListPermissionsResponse + (*GetPermissionRequest)(nil), // 2: api.v1.services.system.GetPermissionRequest + (*GetPermissionResponse)(nil), // 3: api.v1.services.system.GetPermissionResponse + (*CreatePermissionRequest)(nil), // 4: api.v1.services.system.CreatePermissionRequest + (*CreatePermissionResponse)(nil), // 5: api.v1.services.system.CreatePermissionResponse + (*UpdatePermissionRequest)(nil), // 6: api.v1.services.system.UpdatePermissionRequest + (*UpdatePermissionResponse)(nil), // 7: api.v1.services.system.UpdatePermissionResponse + (*DeletePermissionRequest)(nil), // 8: api.v1.services.system.DeletePermissionRequest + (*DeletePermissionResponse)(nil), // 9: api.v1.services.system.DeletePermissionResponse + (*types.Permission)(nil), // 10: api.v1.services.types.Permission + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_system_permission_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.system.ListPermissionsResponse.permissions:type_name -> api.v1.services.types.Permission + 11, // 1: api.v1.services.system.ListPermissionsResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.system.GetPermissionResponse.permission:type_name -> api.v1.services.types.Permission + 10, // 3: api.v1.services.system.CreatePermissionRequest.permission:type_name -> api.v1.services.types.Permission + 10, // 4: api.v1.services.system.CreatePermissionResponse.permission:type_name -> api.v1.services.types.Permission + 10, // 5: api.v1.services.system.UpdatePermissionRequest.permission:type_name -> api.v1.services.types.Permission + 10, // 6: api.v1.services.system.UpdatePermissionResponse.permission:type_name -> api.v1.services.types.Permission + 12, // 7: api.v1.services.system.DeletePermissionResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.system.PermissionService.ListPermissions:input_type -> api.v1.services.system.ListPermissionsRequest + 2, // 9: api.v1.services.system.PermissionService.GetPermission:input_type -> api.v1.services.system.GetPermissionRequest + 4, // 10: api.v1.services.system.PermissionService.CreatePermission:input_type -> api.v1.services.system.CreatePermissionRequest + 6, // 11: api.v1.services.system.PermissionService.UpdatePermission:input_type -> api.v1.services.system.UpdatePermissionRequest + 8, // 12: api.v1.services.system.PermissionService.DeletePermission:input_type -> api.v1.services.system.DeletePermissionRequest + 1, // 13: api.v1.services.system.PermissionService.ListPermissions:output_type -> api.v1.services.system.ListPermissionsResponse + 3, // 14: api.v1.services.system.PermissionService.GetPermission:output_type -> api.v1.services.system.GetPermissionResponse + 5, // 15: api.v1.services.system.PermissionService.CreatePermission:output_type -> api.v1.services.system.CreatePermissionResponse + 7, // 16: api.v1.services.system.PermissionService.UpdatePermission:output_type -> api.v1.services.system.UpdatePermissionResponse + 9, // 17: api.v1.services.system.PermissionService.DeletePermission:output_type -> api.v1.services.system.DeletePermissionResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_system_permission_proto_init() } +func file_system_permission_proto_init() { + if File_system_permission_proto != nil { + return + } + file_system_permission_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_permission_proto_rawDesc), len(file_system_permission_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_system_permission_proto_goTypes, + DependencyIndexes: file_system_permission_proto_depIdxs, + MessageInfos: file_system_permission_proto_msgTypes, + }.Build() + File_system_permission_proto = out.File + file_system_permission_proto_goTypes = nil + file_system_permission_proto_depIdxs = nil +} diff --git a/api/v1/services/system/permission.pb.gw.go b/api/v1/services/system/permission.pb.gw.go new file mode 100644 index 00000000..77dfdf2c --- /dev/null +++ b/api/v1/services/system/permission.pb.gw.go @@ -0,0 +1,487 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: system/permission.proto + +/* +Package system is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package system + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_PermissionService_ListPermissions_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_PermissionService_ListPermissions_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPermissionsRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_ListPermissions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListPermissions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PermissionService_ListPermissions_0(ctx context.Context, marshaler runtime.Marshaler, server PermissionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPermissionsRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_ListPermissions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListPermissions(ctx, &protoReq) + return msg, metadata, err +} + +func request_PermissionService_GetPermission_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPermissionRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetPermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PermissionService_GetPermission_0(ctx context.Context, marshaler runtime.Marshaler, server PermissionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPermissionRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetPermission(ctx, &protoReq) + return msg, metadata, err +} + +var filter_PermissionService_CreatePermission_0 = &utilities.DoubleArray{Encoding: map[string]int{"permission": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_PermissionService_CreatePermission_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreatePermissionRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_CreatePermission_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreatePermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PermissionService_CreatePermission_0(ctx context.Context, marshaler runtime.Marshaler, server PermissionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreatePermissionRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_CreatePermission_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreatePermission(ctx, &protoReq) + return msg, metadata, err +} + +var filter_PermissionService_UpdatePermission_0 = &utilities.DoubleArray{Encoding: map[string]int{"permission": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_PermissionService_UpdatePermission_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePermissionRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["permission.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "permission.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "permission.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "permission.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_UpdatePermission_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PermissionService_UpdatePermission_0(ctx context.Context, marshaler runtime.Marshaler, server PermissionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePermissionRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["permission.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "permission.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "permission.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "permission.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_UpdatePermission_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePermission(ctx, &protoReq) + return msg, metadata, err +} + +func request_PermissionService_DeletePermission_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeletePermissionRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeletePermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PermissionService_DeletePermission_0(ctx context.Context, marshaler runtime.Marshaler, server PermissionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeletePermissionRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeletePermission(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterPermissionServiceHandlerServer registers the http handlers for service PermissionService to "mux". +// UnaryRPC :call PermissionServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPermissionServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterPermissionServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PermissionServiceServer) error { + mux.Handle(http.MethodGet, pattern_PermissionService_ListPermissions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PermissionService/ListPermissions", runtime.WithHTTPPathPattern("/sys/permissions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PermissionService_ListPermissions_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PermissionService_ListPermissions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PermissionService_GetPermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PermissionService/GetPermission", runtime.WithHTTPPathPattern("/sys/permissions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PermissionService_GetPermission_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PermissionService_GetPermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PermissionService_CreatePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PermissionService/CreatePermission", runtime.WithHTTPPathPattern("/sys/permissions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PermissionService_CreatePermission_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PermissionService_CreatePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PermissionService_UpdatePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PermissionService/UpdatePermission", runtime.WithHTTPPathPattern("/sys/permissions/{permission.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PermissionService_UpdatePermission_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PermissionService_UpdatePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_PermissionService_DeletePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PermissionService/DeletePermission", runtime.WithHTTPPathPattern("/sys/permissions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PermissionService_DeletePermission_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PermissionService_DeletePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterPermissionServiceHandlerFromEndpoint is same as RegisterPermissionServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterPermissionServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterPermissionServiceHandler(ctx, mux, conn) +} + +// RegisterPermissionServiceHandler registers the http handlers for service PermissionService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterPermissionServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterPermissionServiceHandlerClient(ctx, mux, NewPermissionServiceClient(conn)) +} + +// RegisterPermissionServiceHandlerClient registers the http handlers for service PermissionService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PermissionServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PermissionServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "PermissionServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterPermissionServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PermissionServiceClient) error { + mux.Handle(http.MethodGet, pattern_PermissionService_ListPermissions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PermissionService/ListPermissions", runtime.WithHTTPPathPattern("/sys/permissions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PermissionService_ListPermissions_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PermissionService_ListPermissions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PermissionService_GetPermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PermissionService/GetPermission", runtime.WithHTTPPathPattern("/sys/permissions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PermissionService_GetPermission_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PermissionService_GetPermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PermissionService_CreatePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PermissionService/CreatePermission", runtime.WithHTTPPathPattern("/sys/permissions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PermissionService_CreatePermission_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PermissionService_CreatePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PermissionService_UpdatePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PermissionService/UpdatePermission", runtime.WithHTTPPathPattern("/sys/permissions/{permission.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PermissionService_UpdatePermission_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PermissionService_UpdatePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_PermissionService_DeletePermission_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PermissionService/DeletePermission", runtime.WithHTTPPathPattern("/sys/permissions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PermissionService_DeletePermission_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PermissionService_DeletePermission_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_PermissionService_ListPermissions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "permissions"}, "")) + pattern_PermissionService_GetPermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "permissions", "id"}, "")) + pattern_PermissionService_CreatePermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "permissions"}, "")) + pattern_PermissionService_UpdatePermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "permissions", "permission.id"}, "")) + pattern_PermissionService_DeletePermission_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "permissions", "id"}, "")) +) + +var ( + forward_PermissionService_ListPermissions_0 = runtime.ForwardResponseMessage + forward_PermissionService_GetPermission_0 = runtime.ForwardResponseMessage + forward_PermissionService_CreatePermission_0 = runtime.ForwardResponseMessage + forward_PermissionService_UpdatePermission_0 = runtime.ForwardResponseMessage + forward_PermissionService_DeletePermission_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/system/permission.pb.validate.go b/api/v1/services/system/permission.pb.validate.go new file mode 100644 index 00000000..fec6b6c2 --- /dev/null +++ b/api/v1/services/system/permission.pb.validate.go @@ -0,0 +1,1329 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: system/permission.proto + +package system + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListPermissionsRequest 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 *ListPermissionsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPermissionsRequest 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 +// ListPermissionsRequestMultiError, or nil if none found. +func (m *ListPermissionsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPermissionsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Keyword + + if len(errors) > 0 { + return ListPermissionsRequestMultiError(errors) + } + + return nil +} + +// ListPermissionsRequestMultiError is an error wrapping multiple validation +// errors returned by ListPermissionsRequest.ValidateAll() if the designated +// constraints aren't met. +type ListPermissionsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPermissionsRequestMultiError) 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 ListPermissionsRequestMultiError) AllErrors() []error { return m } + +// ListPermissionsRequestValidationError is the validation error returned by +// ListPermissionsRequest.Validate if the designated constraints aren't met. +type ListPermissionsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPermissionsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPermissionsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPermissionsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPermissionsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPermissionsRequestValidationError) ErrorName() string { + return "ListPermissionsRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPermissionsRequestValidationError) 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 %sListPermissionsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPermissionsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPermissionsRequestValidationError{} + +// Validate checks the field values on ListPermissionsResponse 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 *ListPermissionsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPermissionsResponse 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 +// ListPermissionsResponseMultiError, or nil if none found. +func (m *ListPermissionsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPermissionsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Total + + for idx, item := range m.GetPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPermissionsResponseValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPermissionsResponseValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPermissionsResponseValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPermissionsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPermissionsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPermissionsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListPermissionsResponseMultiError(errors) + } + + return nil +} + +// ListPermissionsResponseMultiError is an error wrapping multiple validation +// errors returned by ListPermissionsResponse.ValidateAll() if the designated +// constraints aren't met. +type ListPermissionsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPermissionsResponseMultiError) 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 ListPermissionsResponseMultiError) AllErrors() []error { return m } + +// ListPermissionsResponseValidationError is the validation error returned by +// ListPermissionsResponse.Validate if the designated constraints aren't met. +type ListPermissionsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPermissionsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPermissionsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPermissionsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPermissionsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPermissionsResponseValidationError) ErrorName() string { + return "ListPermissionsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPermissionsResponseValidationError) 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 %sListPermissionsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPermissionsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPermissionsResponseValidationError{} + +// Validate checks the field values on GetPermissionRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *GetPermissionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPermissionRequest with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetPermissionRequestMultiError, or nil if none found. +func (m *GetPermissionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPermissionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetPermissionRequestMultiError(errors) + } + + return nil +} + +// GetPermissionRequestMultiError is an error wrapping multiple validation +// errors returned by GetPermissionRequest.ValidateAll() if the designated +// constraints aren't met. +type GetPermissionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPermissionRequestMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetPermissionRequestMultiError) AllErrors() []error { return m } + +// GetPermissionRequestValidationError is the validation error returned by +// GetPermissionRequest.Validate if the designated constraints aren't met. +type GetPermissionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPermissionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPermissionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPermissionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPermissionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPermissionRequestValidationError) ErrorName() string { + return "GetPermissionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPermissionRequestValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetPermissionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPermissionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPermissionRequestValidationError{} + +// Validate checks the field values on GetPermissionResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the first error encountered is returned, or nil if there are no violations. +func (m *GetPermissionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPermissionResponse with the rules +// defined in the proto definition for this message. If any rules are +// violated, the result is a list of violation errors wrapped in +// GetPermissionResponseMultiError, or nil if none found. +func (m *GetPermissionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPermissionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetPermissionResponseValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetPermissionResponseValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetPermissionResponseValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetPermissionResponseMultiError(errors) + } + + return nil +} + +// GetPermissionResponseMultiError is an error wrapping multiple validation +// errors returned by GetPermissionResponse.ValidateAll() if the designated +// constraints aren't met. +type GetPermissionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPermissionResponseMultiError) Error() string { + msgs := make([]string, 0, len(m)) + for _, err := range m { + msgs = append(msgs, err.Error()) + } + return strings.Join(msgs, "; ") +} + +// AllErrors returns a list of validation violation errors. +func (m GetPermissionResponseMultiError) AllErrors() []error { return m } + +// GetPermissionResponseValidationError is the validation error returned by +// GetPermissionResponse.Validate if the designated constraints aren't met. +type GetPermissionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPermissionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPermissionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPermissionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPermissionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPermissionResponseValidationError) ErrorName() string { + return "GetPermissionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPermissionResponseValidationError) Error() string { + cause := "" + if e.cause != nil { + cause = fmt.Sprintf(" | caused by: %v", e.cause) + } + + key := "" + if e.key { + key = "key for " + } + + return fmt.Sprintf( + "invalid %sGetPermissionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPermissionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPermissionResponseValidationError{} + +// Validate checks the field values on CreatePermissionRequest 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 *CreatePermissionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreatePermissionRequest 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 +// CreatePermissionRequestMultiError, or nil if none found. +func (m *CreatePermissionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreatePermissionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for PermissionId + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreatePermissionRequestValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreatePermissionRequestValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreatePermissionRequestValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreatePermissionRequestMultiError(errors) + } + + return nil +} + +// CreatePermissionRequestMultiError is an error wrapping multiple validation +// errors returned by CreatePermissionRequest.ValidateAll() if the designated +// constraints aren't met. +type CreatePermissionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreatePermissionRequestMultiError) 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 CreatePermissionRequestMultiError) AllErrors() []error { return m } + +// CreatePermissionRequestValidationError is the validation error returned by +// CreatePermissionRequest.Validate if the designated constraints aren't met. +type CreatePermissionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreatePermissionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreatePermissionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreatePermissionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreatePermissionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreatePermissionRequestValidationError) ErrorName() string { + return "CreatePermissionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreatePermissionRequestValidationError) 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 %sCreatePermissionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreatePermissionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreatePermissionRequestValidationError{} + +// Validate checks the field values on CreatePermissionResponse 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 *CreatePermissionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreatePermissionResponse 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 +// CreatePermissionResponseMultiError, or nil if none found. +func (m *CreatePermissionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreatePermissionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreatePermissionResponseValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreatePermissionResponseValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreatePermissionResponseValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreatePermissionResponseMultiError(errors) + } + + return nil +} + +// CreatePermissionResponseMultiError is an error wrapping multiple validation +// errors returned by CreatePermissionResponse.ValidateAll() if the designated +// constraints aren't met. +type CreatePermissionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreatePermissionResponseMultiError) 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 CreatePermissionResponseMultiError) AllErrors() []error { return m } + +// CreatePermissionResponseValidationError is the validation error returned by +// CreatePermissionResponse.Validate if the designated constraints aren't met. +type CreatePermissionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreatePermissionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreatePermissionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreatePermissionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreatePermissionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreatePermissionResponseValidationError) ErrorName() string { + return "CreatePermissionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreatePermissionResponseValidationError) 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 %sCreatePermissionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreatePermissionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreatePermissionResponseValidationError{} + +// Validate checks the field values on UpdatePermissionRequest 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 *UpdatePermissionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePermissionRequest 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 +// UpdatePermissionRequestMultiError, or nil if none found. +func (m *UpdatePermissionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePermissionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePermissionRequestValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePermissionRequestValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePermissionRequestValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePermissionRequestMultiError(errors) + } + + return nil +} + +// UpdatePermissionRequestMultiError is an error wrapping multiple validation +// errors returned by UpdatePermissionRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdatePermissionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePermissionRequestMultiError) 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 UpdatePermissionRequestMultiError) AllErrors() []error { return m } + +// UpdatePermissionRequestValidationError is the validation error returned by +// UpdatePermissionRequest.Validate if the designated constraints aren't met. +type UpdatePermissionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePermissionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePermissionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePermissionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePermissionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePermissionRequestValidationError) ErrorName() string { + return "UpdatePermissionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePermissionRequestValidationError) 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 %sUpdatePermissionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePermissionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePermissionRequestValidationError{} + +// Validate checks the field values on UpdatePermissionResponse 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 *UpdatePermissionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePermissionResponse 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 +// UpdatePermissionResponseMultiError, or nil if none found. +func (m *UpdatePermissionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePermissionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePermissionResponseValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePermissionResponseValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePermissionResponseValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePermissionResponseMultiError(errors) + } + + return nil +} + +// UpdatePermissionResponseMultiError is an error wrapping multiple validation +// errors returned by UpdatePermissionResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdatePermissionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePermissionResponseMultiError) 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 UpdatePermissionResponseMultiError) AllErrors() []error { return m } + +// UpdatePermissionResponseValidationError is the validation error returned by +// UpdatePermissionResponse.Validate if the designated constraints aren't met. +type UpdatePermissionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePermissionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePermissionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePermissionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePermissionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePermissionResponseValidationError) ErrorName() string { + return "UpdatePermissionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePermissionResponseValidationError) 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 %sUpdatePermissionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePermissionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePermissionResponseValidationError{} + +// Validate checks the field values on DeletePermissionRequest 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 *DeletePermissionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeletePermissionRequest 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 +// DeletePermissionRequestMultiError, or nil if none found. +func (m *DeletePermissionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeletePermissionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeletePermissionRequestMultiError(errors) + } + + return nil +} + +// DeletePermissionRequestMultiError is an error wrapping multiple validation +// errors returned by DeletePermissionRequest.ValidateAll() if the designated +// constraints aren't met. +type DeletePermissionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeletePermissionRequestMultiError) 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 DeletePermissionRequestMultiError) AllErrors() []error { return m } + +// DeletePermissionRequestValidationError is the validation error returned by +// DeletePermissionRequest.Validate if the designated constraints aren't met. +type DeletePermissionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeletePermissionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeletePermissionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeletePermissionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeletePermissionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeletePermissionRequestValidationError) ErrorName() string { + return "DeletePermissionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeletePermissionRequestValidationError) 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 %sDeletePermissionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeletePermissionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeletePermissionRequestValidationError{} + +// Validate checks the field values on DeletePermissionResponse 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 *DeletePermissionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeletePermissionResponse 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 +// DeletePermissionResponseMultiError, or nil if none found. +func (m *DeletePermissionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeletePermissionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeletePermissionResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeletePermissionResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeletePermissionResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeletePermissionResponseMultiError(errors) + } + + return nil +} + +// DeletePermissionResponseMultiError is an error wrapping multiple validation +// errors returned by DeletePermissionResponse.ValidateAll() if the designated +// constraints aren't met. +type DeletePermissionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeletePermissionResponseMultiError) 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 DeletePermissionResponseMultiError) AllErrors() []error { return m } + +// DeletePermissionResponseValidationError is the validation error returned by +// DeletePermissionResponse.Validate if the designated constraints aren't met. +type DeletePermissionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeletePermissionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeletePermissionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeletePermissionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeletePermissionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeletePermissionResponseValidationError) ErrorName() string { + return "DeletePermissionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeletePermissionResponseValidationError) 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 %sDeletePermissionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeletePermissionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeletePermissionResponseValidationError{} diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go new file mode 100644 index 00000000..9648b59b --- /dev/null +++ b/api/v1/services/system/permission_bridge.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/permission.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const PermissionServiceCreatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/CreatePermission" +const PermissionServiceDeletePermissionBridgeOperation = "/api.v1.services.system.PermissionService/DeletePermission" +const PermissionServiceGetPermissionBridgeOperation = "/api.v1.services.system.PermissionService/GetPermission" +const PermissionServiceListPermissionsBridgeOperation = "/api.v1.services.system.PermissionService/ListPermissions" +const PermissionServiceUpdatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/UpdatePermission" + +type PermissionServiceBridgeServer interface { + CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) + DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) + GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) + ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) + UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) +} + +type PermissionServiceHooker interface { + PermissionServiceCreatePermissionHooker + PermissionServiceDeletePermissionHooker + PermissionServiceGetPermissionHooker + PermissionServiceListPermissionsHooker + PermissionServiceUpdatePermissionHooker +} + +type PermissionServiceHookedBridger interface { + PermissionServiceHooker + PermissionServiceBridgeServer +} +type PermissionServiceCreatePermissionHooker interface { + PrepareCreatePermission(http.Context, *CreatePermissionRequest) (context.Context, error) + CompleteCreatePermission(http.Context, *CreatePermissionRequest, *CreatePermissionResponse) error +} +type PermissionServiceDeletePermissionHooker interface { + PrepareDeletePermission(http.Context, *DeletePermissionRequest) (context.Context, error) + CompleteDeletePermission(http.Context, *DeletePermissionRequest, *DeletePermissionResponse) error +} +type PermissionServiceGetPermissionHooker interface { + PrepareGetPermission(http.Context, *GetPermissionRequest) (context.Context, error) + CompleteGetPermission(http.Context, *GetPermissionRequest, *GetPermissionResponse) error +} +type PermissionServiceListPermissionsHooker interface { + PrepareListPermissions(http.Context, *ListPermissionsRequest) (context.Context, error) + CompleteListPermissions(http.Context, *ListPermissionsRequest, *ListPermissionsResponse) error +} +type PermissionServiceUpdatePermissionHooker interface { + PrepareUpdatePermission(http.Context, *UpdatePermissionRequest) (context.Context, error) + CompleteUpdatePermission(http.Context, *UpdatePermissionRequest, *UpdatePermissionResponse) error +} + +func RegisterPermissionServiceBridgeServer(s *http.Server, srv PermissionServiceHookedBridger) { + r := s.Route("/") + r.GET("/sys/permissions", _PermissionService_ListPermissions0_Bridge_Handler(srv)) + r.GET("/sys/permissions/:id", _PermissionService_GetPermission0_Bridge_Handler(srv)) + r.POST("/sys/permissions", _PermissionService_CreatePermission0_Bridge_Handler(srv)) + r.PUT("/sys/permissions/:permission.id", _PermissionService_UpdatePermission0_Bridge_Handler(srv)) + r.DELETE("/sys/permissions/:id", _PermissionService_DeletePermission0_Bridge_Handler(srv)) +} + +func _PermissionService_ListPermissions0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPermissionsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceListPermissions) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPermissions(ctx, req.(*ListPermissionsRequest)) + }) + + newctx, err := srv.PrepareListPermissions(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPermissions(ctx, &in, out.(*ListPermissionsResponse)) + } +} + +func _PermissionService_GetPermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPermissionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceGetPermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPermission(ctx, req.(*GetPermissionRequest)) + }) + + newctx, err := srv.PrepareGetPermission(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetPermission(ctx, &in, out.(*GetPermissionResponse)) + } +} + +func _PermissionService_CreatePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreatePermissionRequest + if err := ctx.Bind(&in.Permission); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceCreatePermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreatePermission(ctx, req.(*CreatePermissionRequest)) + }) + + newctx, err := srv.PrepareCreatePermission(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreatePermission(ctx, &in, out.(*CreatePermissionResponse)) + } +} + +func _PermissionService_UpdatePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePermissionRequest + if err := ctx.Bind(&in.Permission); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceUpdatePermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePermission(ctx, req.(*UpdatePermissionRequest)) + }) + + newctx, err := srv.PrepareUpdatePermission(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePermission(ctx, &in, out.(*UpdatePermissionResponse)) + } +} + +func _PermissionService_DeletePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeletePermissionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceDeletePermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeletePermission(ctx, req.(*DeletePermissionRequest)) + }) + + newctx, err := srv.PrepareDeletePermission(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeletePermission(ctx, &in, out.(*DeletePermissionResponse)) + } +} + +// UnimplementedPermissionServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPermissionServiceHooked struct{} + +func (UnimplementedPermissionServiceHooked) PrepareCreatePermission(ctx http.Context, in *CreatePermissionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPermissionServiceHooked) CompleteCreatePermission(ctx http.Context, in *CreatePermissionRequest, out *CreatePermissionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPermissionServiceHooked) PrepareDeletePermission(ctx http.Context, in *DeletePermissionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPermissionServiceHooked) CompleteDeletePermission(ctx http.Context, in *DeletePermissionRequest, out *DeletePermissionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPermissionServiceHooked) PrepareGetPermission(ctx http.Context, in *GetPermissionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPermissionServiceHooked) CompleteGetPermission(ctx http.Context, in *GetPermissionRequest, out *GetPermissionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPermissionServiceHooked) PrepareListPermissions(ctx http.Context, in *ListPermissionsRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPermissionServiceHooked) CompleteListPermissions(ctx http.Context, in *ListPermissionsRequest, out *ListPermissionsResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPermissionServiceHooked) PrepareUpdatePermission(ctx http.Context, in *UpdatePermissionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPermissionServiceHooked) CompleteUpdatePermission(ctx http.Context, in *UpdatePermissionRequest, out *UpdatePermissionResponse) error { + return ctx.Result(200, out) +} + +func WithPermissionServiceHook(h PermissionServiceHooker) func(PermissionServiceBridgeServer) PermissionServiceHookedBridger { + return func(srv PermissionServiceBridgeServer) PermissionServiceHookedBridger { + return PermissionServiceHookedBridge{PermissionServiceBridgeServer: srv, PermissionServiceHooker: h} + } +} + +// PermissionServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PermissionService. +// It implements the HTTP and gRPC implementations of PermissionService. +// It forwards requests and responses between the two implementations. +type PermissionServiceHookedBridge struct { + PermissionServiceBridgeServer + PermissionServiceHooker +} + +type PermissionServiceHTTPBridgeImpl struct { + client PermissionServiceHTTPClient +} + +func NewPermissionServiceHTTPBridge(client *http.Client) PermissionServiceHTTPServer { + return &PermissionServiceHTTPBridgeImpl{client: NewPermissionServiceHTTPClient(client)} +} + +func (c *PermissionServiceHTTPBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) +} + +func (c *PermissionServiceHTTPBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + +func (c *PermissionServiceHTTPBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { + return c.client.GetPermission(ctx, in) +} + +func (c *PermissionServiceHTTPBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) +} + +func (c *PermissionServiceHTTPBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { + return c.client.UpdatePermission(ctx, in) +} + +type PermissionServiceBridgeImpl struct { + client PermissionServiceClient +} + +func NewPermissionServiceBridge(client grpc.ClientConnInterface) PermissionServiceServer { + return &PermissionServiceBridgeImpl{client: NewPermissionServiceClient(client)} +} + +func (c *PermissionServiceBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) +} + +func (c *PermissionServiceBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + +func (c *PermissionServiceBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { + return c.client.GetPermission(ctx, in) +} + +func (c *PermissionServiceBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) +} + +func (c *PermissionServiceBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { + return c.client.UpdatePermission(ctx, in) +} + +func (c *PermissionServiceBridgeImpl) mustEmbedUnimplementedPermissionServiceServer() {} + +type PermissionServiceGRPC2HTTPBridgeImpl struct { + client PermissionServiceClient +} + +func NewPermissionServiceGRPC2HTTP(client grpc.ClientConnInterface) PermissionServiceHTTPServer { + return &PermissionServiceGRPC2HTTPBridgeImpl{client: NewPermissionServiceClient(client)} +} + +func (c *PermissionServiceGRPC2HTTPBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) +} + +func (c *PermissionServiceGRPC2HTTPBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + +func (c *PermissionServiceGRPC2HTTPBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { + return c.client.GetPermission(ctx, in) +} + +func (c *PermissionServiceGRPC2HTTPBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) +} + +func (c *PermissionServiceGRPC2HTTPBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { + return c.client.UpdatePermission(ctx, in) +} + +type PermissionServiceHTTP2GRPCBridgeImpl struct { + client PermissionServiceHTTPClient +} + +func NewPermissionServiceHTTP2GRPC(client *http.Client) PermissionServiceServer { + return &PermissionServiceHTTP2GRPCBridgeImpl{client: NewPermissionServiceHTTPClient(client)} +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { + return c.client.GetPermission(ctx, in) +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { + return c.client.UpdatePermission(ctx, in) +} + +func (c *PermissionServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPermissionServiceServer() {} diff --git a/api/v1/services/system/permission_grpc.pb.go b/api/v1/services/system/permission_grpc.pb.go new file mode 100644 index 00000000..5e63a801 --- /dev/null +++ b/api/v1/services/system/permission_grpc.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: system/permission.proto + +package system + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + PermissionService_ListPermissions_FullMethodName = "/api.v1.services.system.PermissionService/ListPermissions" + PermissionService_GetPermission_FullMethodName = "/api.v1.services.system.PermissionService/GetPermission" + PermissionService_CreatePermission_FullMethodName = "/api.v1.services.system.PermissionService/CreatePermission" + PermissionService_UpdatePermission_FullMethodName = "/api.v1.services.system.PermissionService/UpdatePermission" + PermissionService_DeletePermission_FullMethodName = "/api.v1.services.system.PermissionService/DeletePermission" +) + +// PermissionServiceClient is the client API for PermissionService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The login service definition. +type PermissionServiceClient interface { + ListPermissions(ctx context.Context, in *ListPermissionsRequest, opts ...grpc.CallOption) (*ListPermissionsResponse, error) + GetPermission(ctx context.Context, in *GetPermissionRequest, opts ...grpc.CallOption) (*GetPermissionResponse, error) + CreatePermission(ctx context.Context, in *CreatePermissionRequest, opts ...grpc.CallOption) (*CreatePermissionResponse, error) + UpdatePermission(ctx context.Context, in *UpdatePermissionRequest, opts ...grpc.CallOption) (*UpdatePermissionResponse, error) + DeletePermission(ctx context.Context, in *DeletePermissionRequest, opts ...grpc.CallOption) (*DeletePermissionResponse, error) +} + +type permissionServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPermissionServiceClient(cc grpc.ClientConnInterface) PermissionServiceClient { + return &permissionServiceClient{cc} +} + +func (c *permissionServiceClient) ListPermissions(ctx context.Context, in *ListPermissionsRequest, opts ...grpc.CallOption) (*ListPermissionsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPermissionsResponse) + err := c.cc.Invoke(ctx, PermissionService_ListPermissions_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *permissionServiceClient) GetPermission(ctx context.Context, in *GetPermissionRequest, opts ...grpc.CallOption) (*GetPermissionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetPermissionResponse) + err := c.cc.Invoke(ctx, PermissionService_GetPermission_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *permissionServiceClient) CreatePermission(ctx context.Context, in *CreatePermissionRequest, opts ...grpc.CallOption) (*CreatePermissionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreatePermissionResponse) + err := c.cc.Invoke(ctx, PermissionService_CreatePermission_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *permissionServiceClient) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest, opts ...grpc.CallOption) (*UpdatePermissionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePermissionResponse) + err := c.cc.Invoke(ctx, PermissionService_UpdatePermission_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *permissionServiceClient) DeletePermission(ctx context.Context, in *DeletePermissionRequest, opts ...grpc.CallOption) (*DeletePermissionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeletePermissionResponse) + err := c.cc.Invoke(ctx, PermissionService_DeletePermission_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PermissionServiceServer is the server API for PermissionService service. +// All implementations must embed UnimplementedPermissionServiceServer +// for forward compatibility. +// +// The login service definition. +type PermissionServiceServer interface { + ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) + GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) + CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) + UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) + DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) + mustEmbedUnimplementedPermissionServiceServer() +} + +// UnimplementedPermissionServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPermissionServiceServer struct{} + +func (UnimplementedPermissionServiceServer) ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPermissions not implemented") +} +func (UnimplementedPermissionServiceServer) GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPermission not implemented") +} +func (UnimplementedPermissionServiceServer) CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePermission not implemented") +} +func (UnimplementedPermissionServiceServer) UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePermission not implemented") +} +func (UnimplementedPermissionServiceServer) DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeletePermission not implemented") +} +func (UnimplementedPermissionServiceServer) mustEmbedUnimplementedPermissionServiceServer() {} +func (UnimplementedPermissionServiceServer) testEmbeddedByValue() {} + +// UnsafePermissionServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PermissionServiceServer will +// result in compilation errors. +type UnsafePermissionServiceServer interface { + mustEmbedUnimplementedPermissionServiceServer() +} + +func RegisterPermissionServiceServer(s grpc.ServiceRegistrar, srv PermissionServiceServer) { + // If the following call pancis, it indicates UnimplementedPermissionServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&PermissionService_ServiceDesc, srv) +} + +func _PermissionService_ListPermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPermissionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PermissionServiceServer).ListPermissions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PermissionService_ListPermissions_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PermissionServiceServer).ListPermissions(ctx, req.(*ListPermissionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PermissionService_GetPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPermissionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PermissionServiceServer).GetPermission(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PermissionService_GetPermission_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PermissionServiceServer).GetPermission(ctx, req.(*GetPermissionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PermissionService_CreatePermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreatePermissionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PermissionServiceServer).CreatePermission(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PermissionService_CreatePermission_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PermissionServiceServer).CreatePermission(ctx, req.(*CreatePermissionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PermissionService_UpdatePermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePermissionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PermissionServiceServer).UpdatePermission(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PermissionService_UpdatePermission_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PermissionServiceServer).UpdatePermission(ctx, req.(*UpdatePermissionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PermissionService_DeletePermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeletePermissionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PermissionServiceServer).DeletePermission(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PermissionService_DeletePermission_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PermissionServiceServer).DeletePermission(ctx, req.(*DeletePermissionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// PermissionService_ServiceDesc is the grpc.ServiceDesc for PermissionService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PermissionService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.system.PermissionService", + HandlerType: (*PermissionServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListPermissions", + Handler: _PermissionService_ListPermissions_Handler, + }, + { + MethodName: "GetPermission", + Handler: _PermissionService_GetPermission_Handler, + }, + { + MethodName: "CreatePermission", + Handler: _PermissionService_CreatePermission_Handler, + }, + { + MethodName: "UpdatePermission", + Handler: _PermissionService_UpdatePermission_Handler, + }, + { + MethodName: "DeletePermission", + Handler: _PermissionService_DeletePermission_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "system/permission.proto", +} diff --git a/api/v1/services/system/permission_http.pb.go b/api/v1/services/system/permission_http.pb.go new file mode 100644 index 00000000..51616cbb --- /dev/null +++ b/api/v1/services/system/permission_http.pb.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: system/permission.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationPermissionServiceCreatePermission = "/api.v1.services.system.PermissionService/CreatePermission" +const OperationPermissionServiceDeletePermission = "/api.v1.services.system.PermissionService/DeletePermission" +const OperationPermissionServiceGetPermission = "/api.v1.services.system.PermissionService/GetPermission" +const OperationPermissionServiceListPermissions = "/api.v1.services.system.PermissionService/ListPermissions" +const OperationPermissionServiceUpdatePermission = "/api.v1.services.system.PermissionService/UpdatePermission" + +type PermissionServiceHTTPServer interface { + CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) + DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) + GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) + ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) + UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) +} + +func RegisterPermissionServiceHTTPServer(s *http.Server, srv PermissionServiceHTTPServer) { + r := s.Route("/") + r.GET("/sys/permissions", _PermissionService_ListPermissions0_HTTP_Handler(srv)) + r.GET("/sys/permissions/{id}", _PermissionService_GetPermission0_HTTP_Handler(srv)) + r.POST("/sys/permissions", _PermissionService_CreatePermission0_HTTP_Handler(srv)) + r.PUT("/sys/permissions/{permission.id}", _PermissionService_UpdatePermission0_HTTP_Handler(srv)) + r.DELETE("/sys/permissions/{id}", _PermissionService_DeletePermission0_HTTP_Handler(srv)) +} + +func _PermissionService_ListPermissions0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPermissionsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceListPermissions) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPermissions(ctx, req.(*ListPermissionsRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPermissionsResponse) + return ctx.Result(200, reply) + } +} + +func _PermissionService_GetPermission0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPermissionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceGetPermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPermission(ctx, req.(*GetPermissionRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetPermissionResponse) + return ctx.Result(200, reply) + } +} + +func _PermissionService_CreatePermission0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreatePermissionRequest + if err := ctx.Bind(&in.Permission); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceCreatePermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreatePermission(ctx, req.(*CreatePermissionRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreatePermissionResponse) + return ctx.Result(200, reply) + } +} + +func _PermissionService_UpdatePermission0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePermissionRequest + if err := ctx.Bind(&in.Permission); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceUpdatePermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePermission(ctx, req.(*UpdatePermissionRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePermissionResponse) + return ctx.Result(200, reply) + } +} + +func _PermissionService_DeletePermission0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeletePermissionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPermissionServiceDeletePermission) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeletePermission(ctx, req.(*DeletePermissionRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeletePermissionResponse) + return ctx.Result(200, reply) + } +} + +type PermissionServiceHTTPClient interface { + CreatePermission(ctx context.Context, req *CreatePermissionRequest, opts ...http.CallOption) (rsp *CreatePermissionResponse, err error) + DeletePermission(ctx context.Context, req *DeletePermissionRequest, opts ...http.CallOption) (rsp *DeletePermissionResponse, err error) + GetPermission(ctx context.Context, req *GetPermissionRequest, opts ...http.CallOption) (rsp *GetPermissionResponse, err error) + ListPermissions(ctx context.Context, req *ListPermissionsRequest, opts ...http.CallOption) (rsp *ListPermissionsResponse, err error) + UpdatePermission(ctx context.Context, req *UpdatePermissionRequest, opts ...http.CallOption) (rsp *UpdatePermissionResponse, err error) +} + +type PermissionServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewPermissionServiceHTTPClient(client *http.Client) PermissionServiceHTTPClient { + return &PermissionServiceHTTPClientImpl{client} +} + +func (c *PermissionServiceHTTPClientImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest, opts ...http.CallOption) (*CreatePermissionResponse, error) { + var out CreatePermissionResponse + pattern := "/sys/permissions" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPermissionServiceCreatePermission)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Permission, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PermissionServiceHTTPClientImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest, opts ...http.CallOption) (*DeletePermissionResponse, error) { + var out DeletePermissionResponse + pattern := "/sys/permissions/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPermissionServiceDeletePermission)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PermissionServiceHTTPClientImpl) GetPermission(ctx context.Context, in *GetPermissionRequest, opts ...http.CallOption) (*GetPermissionResponse, error) { + var out GetPermissionResponse + pattern := "/sys/permissions/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPermissionServiceGetPermission)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PermissionServiceHTTPClientImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest, opts ...http.CallOption) (*ListPermissionsResponse, error) { + var out ListPermissionsResponse + pattern := "/sys/permissions" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPermissionServiceListPermissions)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PermissionServiceHTTPClientImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest, opts ...http.CallOption) (*UpdatePermissionResponse, error) { + var out UpdatePermissionResponse + pattern := "/sys/permissions/{permission.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPermissionServiceUpdatePermission)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Permission, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/system/position.pb.go b/api/v1/services/system/position.pb.go new file mode 100644 index 00000000..ffbfbc02 --- /dev/null +++ b/api/v1/services/system/position.pb.go @@ -0,0 +1,733 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: system/position.proto + +package system + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListPositionsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The page number. + Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // The keyword is the query parameter for set only to query the position by keyword + Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPositionsRequest) Reset() { + *x = ListPositionsRequest{} + mi := &file_system_position_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPositionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPositionsRequest) ProtoMessage() {} + +func (x *ListPositionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_position_proto_msgTypes[0] + 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 ListPositionsRequest.ProtoReflect.Descriptor instead. +func (*ListPositionsRequest) Descriptor() ([]byte, []int) { + return file_system_position_proto_rawDescGZIP(), []int{0} +} + +func (x *ListPositionsRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListPositionsRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListPositionsRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListPositionsRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListPositionsRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListPositionsRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListPositionsRequest) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +type ListPositionsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` + // The paging menus + Positions []*types.Position `protobuf:"bytes,2,rep,name=positions,proto3" json:"positions,omitempty"` + // The page number. + Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the page data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListPositionsResponse) Reset() { + *x = ListPositionsResponse{} + mi := &file_system_position_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListPositionsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListPositionsResponse) ProtoMessage() {} + +func (x *ListPositionsResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_position_proto_msgTypes[1] + 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 ListPositionsResponse.ProtoReflect.Descriptor instead. +func (*ListPositionsResponse) Descriptor() ([]byte, []int) { + return file_system_position_proto_rawDescGZIP(), []int{1} +} + +func (x *ListPositionsResponse) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *ListPositionsResponse) GetPositions() []*types.Position { + if x != nil { + return x.Positions + } + return nil +} + +func (x *ListPositionsResponse) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListPositionsResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListPositionsResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListPositionsResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +type GetPositionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the resource requested, for example: + // "shelves/shelf1/positions/position2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPositionRequest) Reset() { + *x = GetPositionRequest{} + mi := &file_system_position_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPositionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPositionRequest) ProtoMessage() {} + +func (x *GetPositionRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_position_proto_msgTypes[2] + 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 GetPositionRequest.ProtoReflect.Descriptor instead. +func (*GetPositionRequest) Descriptor() ([]byte, []int) { + return file_system_position_proto_rawDescGZIP(), []int{2} +} + +func (x *GetPositionRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type GetPositionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Position *types.Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetPositionResponse) Reset() { + *x = GetPositionResponse{} + mi := &file_system_position_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetPositionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetPositionResponse) ProtoMessage() {} + +func (x *GetPositionResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_position_proto_msgTypes[3] + 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 GetPositionResponse.ProtoReflect.Descriptor instead. +func (*GetPositionResponse) Descriptor() ([]byte, []int) { + return file_system_position_proto_rawDescGZIP(), []int{3} +} + +func (x *GetPositionResponse) GetPosition() *types.Position { + if x != nil { + return x.Position + } + return nil +} + +type CreatePositionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id where the position is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The position id to use for this position. + PositionId string `protobuf:"bytes,2,opt,name=position_id,proto3" json:"position_id,omitempty"` + // The position object to create. + Position *types.Position `protobuf:"bytes,3,opt,name=position,proto3" json:"position,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreatePositionRequest) Reset() { + *x = CreatePositionRequest{} + mi := &file_system_position_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreatePositionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePositionRequest) ProtoMessage() {} + +func (x *CreatePositionRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_position_proto_msgTypes[4] + 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 CreatePositionRequest.ProtoReflect.Descriptor instead. +func (*CreatePositionRequest) Descriptor() ([]byte, []int) { + return file_system_position_proto_rawDescGZIP(), []int{4} +} + +func (x *CreatePositionRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreatePositionRequest) GetPositionId() string { + if x != nil { + return x.PositionId + } + return "" +} + +func (x *CreatePositionRequest) GetPosition() *types.Position { + if x != nil { + return x.Position + } + return nil +} + +type CreatePositionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Position *types.Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreatePositionResponse) Reset() { + *x = CreatePositionResponse{} + mi := &file_system_position_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreatePositionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreatePositionResponse) ProtoMessage() {} + +func (x *CreatePositionResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_position_proto_msgTypes[5] + 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 CreatePositionResponse.ProtoReflect.Descriptor instead. +func (*CreatePositionResponse) Descriptor() ([]byte, []int) { + return file_system_position_proto_rawDescGZIP(), []int{5} +} + +func (x *CreatePositionResponse) GetPosition() *types.Position { + if x != nil { + return x.Position + } + return nil +} + +type UpdatePositionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The id of the position resource to update. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The position resource which replaces the resource on the server. + Position *types.Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePositionRequest) Reset() { + *x = UpdatePositionRequest{} + mi := &file_system_position_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePositionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePositionRequest) ProtoMessage() {} + +func (x *UpdatePositionRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_position_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 UpdatePositionRequest.ProtoReflect.Descriptor instead. +func (*UpdatePositionRequest) Descriptor() ([]byte, []int) { + return file_system_position_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdatePositionRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdatePositionRequest) GetPosition() *types.Position { + if x != nil { + return x.Position + } + return nil +} + +type UpdatePositionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Position *types.Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePositionResponse) Reset() { + *x = UpdatePositionResponse{} + mi := &file_system_position_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePositionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePositionResponse) ProtoMessage() {} + +func (x *UpdatePositionResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_position_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdatePositionResponse.ProtoReflect.Descriptor instead. +func (*UpdatePositionResponse) Descriptor() ([]byte, []int) { + return file_system_position_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdatePositionResponse) GetPosition() *types.Position { + if x != nil { + return x.Position + } + return nil +} + +type DeletePositionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The resource id of the position to be deleted, for example: + // "shelves/shelf1/positions/position2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeletePositionRequest) Reset() { + *x = DeletePositionRequest{} + mi := &file_system_position_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeletePositionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeletePositionRequest) ProtoMessage() {} + +func (x *DeletePositionRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_position_proto_msgTypes[8] + 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 DeletePositionRequest.ProtoReflect.Descriptor instead. +func (*DeletePositionRequest) Descriptor() ([]byte, []int) { + return file_system_position_proto_rawDescGZIP(), []int{8} +} + +func (x *DeletePositionRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type DeletePositionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeletePositionResponse) Reset() { + *x = DeletePositionResponse{} + mi := &file_system_position_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeletePositionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeletePositionResponse) ProtoMessage() {} + +func (x *DeletePositionResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_position_proto_msgTypes[9] + 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 DeletePositionResponse.ProtoReflect.Descriptor instead. +func (*DeletePositionResponse) Descriptor() ([]byte, []int) { + return file_system_position_proto_rawDescGZIP(), []int{9} +} + +func (x *DeletePositionResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_system_position_proto protoreflect.FileDescriptor + +const file_system_position_proto_rawDesc = "" + + "\n" + + "\x15system/position.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xd0\x01\n" + + "\x14ListPositionsRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x18\n" + + "\akeyword\x18\a \x01(\tR\akeyword\"\x83\x02\n" + + "\x15ListPositionsResponse\x12\x14\n" + + "\x05total\x18\x01 \x01(\x05R\x05total\x12=\n" + + "\tpositions\x18\x02 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12\x12\n" + + "\x04page\x18\x03 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"$\n" + + "\x12GetPositionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"R\n" + + "\x13GetPositionResponse\x12;\n" + + "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"\x8e\x01\n" + + "\x15CreatePositionRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12 \n" + + "\vposition_id\x18\x02 \x01(\tR\vposition_id\x12;\n" + + "\bposition\x18\x03 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"U\n" + + "\x16CreatePositionResponse\x12;\n" + + "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"d\n" + + "\x15UpdatePositionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12;\n" + + "\bposition\x18\x02 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"U\n" + + "\x16UpdatePositionResponse\x12;\n" + + "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"'\n" + + "\x15DeletePositionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + + "\x16DeletePositionResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xe3\x05\n" + + "\x0fPositionService\x12\x84\x01\n" + + "\rListPositions\x12,.api.v1.services.system.ListPositionsRequest\x1a-.api.v1.services.system.ListPositionsResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/positions\x12\x83\x01\n" + + "\vGetPosition\x12*.api.v1.services.system.GetPositionRequest\x1a+.api.v1.services.system.GetPositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/positions/{id}\x12\x91\x01\n" + + "\x0eCreatePosition\x12-.api.v1.services.system.CreatePositionRequest\x1a..api.v1.services.system.CreatePositionResponse\" \x82\xd3\xe4\x93\x02\x1a:\bposition\"\x0e/sys/positions\x12\x9f\x01\n" + + "\x0eUpdatePosition\x12-.api.v1.services.system.UpdatePositionRequest\x1a..api.v1.services.system.UpdatePositionResponse\".\x82\xd3\xe4\x93\x02(:\bposition\x1a\x1c/sys/positions/{position.id}\x12\x8c\x01\n" + + "\x0eDeletePosition\x12-.api.v1.services.system.DeletePositionRequest\x1a..api.v1.services.system.DeletePositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/positions/{id}B\xe2\x01\n" + + "\x1acom.api.v1.services.systemB\rPositionProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + +var ( + file_system_position_proto_rawDescOnce sync.Once + file_system_position_proto_rawDescData []byte +) + +func file_system_position_proto_rawDescGZIP() []byte { + file_system_position_proto_rawDescOnce.Do(func() { + file_system_position_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_position_proto_rawDesc), len(file_system_position_proto_rawDesc))) + }) + return file_system_position_proto_rawDescData +} + +var file_system_position_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_system_position_proto_goTypes = []any{ + (*ListPositionsRequest)(nil), // 0: api.v1.services.system.ListPositionsRequest + (*ListPositionsResponse)(nil), // 1: api.v1.services.system.ListPositionsResponse + (*GetPositionRequest)(nil), // 2: api.v1.services.system.GetPositionRequest + (*GetPositionResponse)(nil), // 3: api.v1.services.system.GetPositionResponse + (*CreatePositionRequest)(nil), // 4: api.v1.services.system.CreatePositionRequest + (*CreatePositionResponse)(nil), // 5: api.v1.services.system.CreatePositionResponse + (*UpdatePositionRequest)(nil), // 6: api.v1.services.system.UpdatePositionRequest + (*UpdatePositionResponse)(nil), // 7: api.v1.services.system.UpdatePositionResponse + (*DeletePositionRequest)(nil), // 8: api.v1.services.system.DeletePositionRequest + (*DeletePositionResponse)(nil), // 9: api.v1.services.system.DeletePositionResponse + (*types.Position)(nil), // 10: api.v1.services.types.Position + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_system_position_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.system.ListPositionsResponse.positions:type_name -> api.v1.services.types.Position + 11, // 1: api.v1.services.system.ListPositionsResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.system.GetPositionResponse.position:type_name -> api.v1.services.types.Position + 10, // 3: api.v1.services.system.CreatePositionRequest.position:type_name -> api.v1.services.types.Position + 10, // 4: api.v1.services.system.CreatePositionResponse.position:type_name -> api.v1.services.types.Position + 10, // 5: api.v1.services.system.UpdatePositionRequest.position:type_name -> api.v1.services.types.Position + 10, // 6: api.v1.services.system.UpdatePositionResponse.position:type_name -> api.v1.services.types.Position + 12, // 7: api.v1.services.system.DeletePositionResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.system.PositionService.ListPositions:input_type -> api.v1.services.system.ListPositionsRequest + 2, // 9: api.v1.services.system.PositionService.GetPosition:input_type -> api.v1.services.system.GetPositionRequest + 4, // 10: api.v1.services.system.PositionService.CreatePosition:input_type -> api.v1.services.system.CreatePositionRequest + 6, // 11: api.v1.services.system.PositionService.UpdatePosition:input_type -> api.v1.services.system.UpdatePositionRequest + 8, // 12: api.v1.services.system.PositionService.DeletePosition:input_type -> api.v1.services.system.DeletePositionRequest + 1, // 13: api.v1.services.system.PositionService.ListPositions:output_type -> api.v1.services.system.ListPositionsResponse + 3, // 14: api.v1.services.system.PositionService.GetPosition:output_type -> api.v1.services.system.GetPositionResponse + 5, // 15: api.v1.services.system.PositionService.CreatePosition:output_type -> api.v1.services.system.CreatePositionResponse + 7, // 16: api.v1.services.system.PositionService.UpdatePosition:output_type -> api.v1.services.system.UpdatePositionResponse + 9, // 17: api.v1.services.system.PositionService.DeletePosition:output_type -> api.v1.services.system.DeletePositionResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_system_position_proto_init() } +func file_system_position_proto_init() { + if File_system_position_proto != nil { + return + } + file_system_position_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_position_proto_rawDesc), len(file_system_position_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_system_position_proto_goTypes, + DependencyIndexes: file_system_position_proto_depIdxs, + MessageInfos: file_system_position_proto_msgTypes, + }.Build() + File_system_position_proto = out.File + file_system_position_proto_goTypes = nil + file_system_position_proto_depIdxs = nil +} diff --git a/api/v1/services/system/position.pb.gw.go b/api/v1/services/system/position.pb.gw.go new file mode 100644 index 00000000..1d7fcf6b --- /dev/null +++ b/api/v1/services/system/position.pb.gw.go @@ -0,0 +1,487 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: system/position.proto + +/* +Package system is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package system + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_PositionService_ListPositions_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_PositionService_ListPositions_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPositionsRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_ListPositions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListPositions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PositionService_ListPositions_0(ctx context.Context, marshaler runtime.Marshaler, server PositionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListPositionsRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_ListPositions_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListPositions(ctx, &protoReq) + return msg, metadata, err +} + +func request_PositionService_GetPosition_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPositionRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetPosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PositionService_GetPosition_0(ctx context.Context, marshaler runtime.Marshaler, server PositionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetPositionRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetPosition(ctx, &protoReq) + return msg, metadata, err +} + +var filter_PositionService_CreatePosition_0 = &utilities.DoubleArray{Encoding: map[string]int{"position": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_PositionService_CreatePosition_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreatePositionRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Position); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_CreatePosition_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreatePosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PositionService_CreatePosition_0(ctx context.Context, marshaler runtime.Marshaler, server PositionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreatePositionRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Position); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_CreatePosition_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreatePosition(ctx, &protoReq) + return msg, metadata, err +} + +var filter_PositionService_UpdatePosition_0 = &utilities.DoubleArray{Encoding: map[string]int{"position": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_PositionService_UpdatePosition_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePositionRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Position); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["position.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "position.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "position.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "position.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_UpdatePosition_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PositionService_UpdatePosition_0(ctx context.Context, marshaler runtime.Marshaler, server PositionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePositionRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Position); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["position.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "position.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "position.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "position.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_UpdatePosition_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePosition(ctx, &protoReq) + return msg, metadata, err +} + +func request_PositionService_DeletePosition_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeletePositionRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeletePosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_PositionService_DeletePosition_0(ctx context.Context, marshaler runtime.Marshaler, server PositionServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeletePositionRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeletePosition(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterPositionServiceHandlerServer registers the http handlers for service PositionService to "mux". +// UnaryRPC :call PositionServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPositionServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterPositionServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PositionServiceServer) error { + mux.Handle(http.MethodGet, pattern_PositionService_ListPositions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PositionService/ListPositions", runtime.WithHTTPPathPattern("/sys/positions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PositionService_ListPositions_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PositionService_ListPositions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PositionService_GetPosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PositionService/GetPosition", runtime.WithHTTPPathPattern("/sys/positions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PositionService_GetPosition_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PositionService_GetPosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PositionService_CreatePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PositionService/CreatePosition", runtime.WithHTTPPathPattern("/sys/positions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PositionService_CreatePosition_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PositionService_CreatePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PositionService_UpdatePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PositionService/UpdatePosition", runtime.WithHTTPPathPattern("/sys/positions/{position.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PositionService_UpdatePosition_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PositionService_UpdatePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_PositionService_DeletePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.PositionService/DeletePosition", runtime.WithHTTPPathPattern("/sys/positions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_PositionService_DeletePosition_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PositionService_DeletePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterPositionServiceHandlerFromEndpoint is same as RegisterPositionServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterPositionServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterPositionServiceHandler(ctx, mux, conn) +} + +// RegisterPositionServiceHandler registers the http handlers for service PositionService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterPositionServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterPositionServiceHandlerClient(ctx, mux, NewPositionServiceClient(conn)) +} + +// RegisterPositionServiceHandlerClient registers the http handlers for service PositionService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PositionServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PositionServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "PositionServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterPositionServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PositionServiceClient) error { + mux.Handle(http.MethodGet, pattern_PositionService_ListPositions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PositionService/ListPositions", runtime.WithHTTPPathPattern("/sys/positions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PositionService_ListPositions_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PositionService_ListPositions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_PositionService_GetPosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PositionService/GetPosition", runtime.WithHTTPPathPattern("/sys/positions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PositionService_GetPosition_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PositionService_GetPosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_PositionService_CreatePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PositionService/CreatePosition", runtime.WithHTTPPathPattern("/sys/positions")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PositionService_CreatePosition_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PositionService_CreatePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_PositionService_UpdatePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PositionService/UpdatePosition", runtime.WithHTTPPathPattern("/sys/positions/{position.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PositionService_UpdatePosition_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PositionService_UpdatePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_PositionService_DeletePosition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.PositionService/DeletePosition", runtime.WithHTTPPathPattern("/sys/positions/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_PositionService_DeletePosition_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_PositionService_DeletePosition_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_PositionService_ListPositions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "positions"}, "")) + pattern_PositionService_GetPosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "positions", "id"}, "")) + pattern_PositionService_CreatePosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "positions"}, "")) + pattern_PositionService_UpdatePosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "positions", "position.id"}, "")) + pattern_PositionService_DeletePosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "positions", "id"}, "")) +) + +var ( + forward_PositionService_ListPositions_0 = runtime.ForwardResponseMessage + forward_PositionService_GetPosition_0 = runtime.ForwardResponseMessage + forward_PositionService_CreatePosition_0 = runtime.ForwardResponseMessage + forward_PositionService_UpdatePosition_0 = runtime.ForwardResponseMessage + forward_PositionService_DeletePosition_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/system/position.pb.validate.go b/api/v1/services/system/position.pb.validate.go new file mode 100644 index 00000000..bddd3c08 --- /dev/null +++ b/api/v1/services/system/position.pb.validate.go @@ -0,0 +1,1329 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: system/position.proto + +package system + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListPositionsRequest 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 *ListPositionsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPositionsRequest 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 +// ListPositionsRequestMultiError, or nil if none found. +func (m *ListPositionsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPositionsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Keyword + + if len(errors) > 0 { + return ListPositionsRequestMultiError(errors) + } + + return nil +} + +// ListPositionsRequestMultiError is an error wrapping multiple validation +// errors returned by ListPositionsRequest.ValidateAll() if the designated +// constraints aren't met. +type ListPositionsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPositionsRequestMultiError) 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 ListPositionsRequestMultiError) AllErrors() []error { return m } + +// ListPositionsRequestValidationError is the validation error returned by +// ListPositionsRequest.Validate if the designated constraints aren't met. +type ListPositionsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPositionsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPositionsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPositionsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPositionsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPositionsRequestValidationError) ErrorName() string { + return "ListPositionsRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPositionsRequestValidationError) 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 %sListPositionsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPositionsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPositionsRequestValidationError{} + +// Validate checks the field values on ListPositionsResponse 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 *ListPositionsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListPositionsResponse 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 +// ListPositionsResponseMultiError, or nil if none found. +func (m *ListPositionsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListPositionsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Total + + for idx, item := range m.GetPositions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPositionsResponseValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPositionsResponseValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPositionsResponseValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListPositionsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListPositionsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListPositionsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListPositionsResponseMultiError(errors) + } + + return nil +} + +// ListPositionsResponseMultiError is an error wrapping multiple validation +// errors returned by ListPositionsResponse.ValidateAll() if the designated +// constraints aren't met. +type ListPositionsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListPositionsResponseMultiError) 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 ListPositionsResponseMultiError) AllErrors() []error { return m } + +// ListPositionsResponseValidationError is the validation error returned by +// ListPositionsResponse.Validate if the designated constraints aren't met. +type ListPositionsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListPositionsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListPositionsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListPositionsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListPositionsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListPositionsResponseValidationError) ErrorName() string { + return "ListPositionsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListPositionsResponseValidationError) 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 %sListPositionsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListPositionsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListPositionsResponseValidationError{} + +// Validate checks the field values on GetPositionRequest 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 *GetPositionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPositionRequest 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 +// GetPositionRequestMultiError, or nil if none found. +func (m *GetPositionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPositionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetPositionRequestMultiError(errors) + } + + return nil +} + +// GetPositionRequestMultiError is an error wrapping multiple validation errors +// returned by GetPositionRequest.ValidateAll() if the designated constraints +// aren't met. +type GetPositionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPositionRequestMultiError) 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 GetPositionRequestMultiError) AllErrors() []error { return m } + +// GetPositionRequestValidationError is the validation error returned by +// GetPositionRequest.Validate if the designated constraints aren't met. +type GetPositionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPositionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPositionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPositionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPositionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPositionRequestValidationError) ErrorName() string { + return "GetPositionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPositionRequestValidationError) 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 %sGetPositionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPositionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPositionRequestValidationError{} + +// Validate checks the field values on GetPositionResponse 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 *GetPositionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetPositionResponse 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 +// GetPositionResponseMultiError, or nil if none found. +func (m *GetPositionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetPositionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetPosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetPositionResponseValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetPositionResponseValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetPositionResponseValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetPositionResponseMultiError(errors) + } + + return nil +} + +// GetPositionResponseMultiError is an error wrapping multiple validation +// errors returned by GetPositionResponse.ValidateAll() if the designated +// constraints aren't met. +type GetPositionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetPositionResponseMultiError) 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 GetPositionResponseMultiError) AllErrors() []error { return m } + +// GetPositionResponseValidationError is the validation error returned by +// GetPositionResponse.Validate if the designated constraints aren't met. +type GetPositionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetPositionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetPositionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetPositionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetPositionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetPositionResponseValidationError) ErrorName() string { + return "GetPositionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetPositionResponseValidationError) 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 %sGetPositionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetPositionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetPositionResponseValidationError{} + +// Validate checks the field values on CreatePositionRequest 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 *CreatePositionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreatePositionRequest 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 +// CreatePositionRequestMultiError, or nil if none found. +func (m *CreatePositionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreatePositionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for PositionId + + if all { + switch v := interface{}(m.GetPosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreatePositionRequestValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreatePositionRequestValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreatePositionRequestValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreatePositionRequestMultiError(errors) + } + + return nil +} + +// CreatePositionRequestMultiError is an error wrapping multiple validation +// errors returned by CreatePositionRequest.ValidateAll() if the designated +// constraints aren't met. +type CreatePositionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreatePositionRequestMultiError) 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 CreatePositionRequestMultiError) AllErrors() []error { return m } + +// CreatePositionRequestValidationError is the validation error returned by +// CreatePositionRequest.Validate if the designated constraints aren't met. +type CreatePositionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreatePositionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreatePositionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreatePositionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreatePositionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreatePositionRequestValidationError) ErrorName() string { + return "CreatePositionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreatePositionRequestValidationError) 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 %sCreatePositionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreatePositionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreatePositionRequestValidationError{} + +// Validate checks the field values on CreatePositionResponse 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 *CreatePositionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreatePositionResponse 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 +// CreatePositionResponseMultiError, or nil if none found. +func (m *CreatePositionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreatePositionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetPosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreatePositionResponseValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreatePositionResponseValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreatePositionResponseValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreatePositionResponseMultiError(errors) + } + + return nil +} + +// CreatePositionResponseMultiError is an error wrapping multiple validation +// errors returned by CreatePositionResponse.ValidateAll() if the designated +// constraints aren't met. +type CreatePositionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreatePositionResponseMultiError) 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 CreatePositionResponseMultiError) AllErrors() []error { return m } + +// CreatePositionResponseValidationError is the validation error returned by +// CreatePositionResponse.Validate if the designated constraints aren't met. +type CreatePositionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreatePositionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreatePositionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreatePositionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreatePositionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreatePositionResponseValidationError) ErrorName() string { + return "CreatePositionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreatePositionResponseValidationError) 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 %sCreatePositionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreatePositionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreatePositionResponseValidationError{} + +// Validate checks the field values on UpdatePositionRequest 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 *UpdatePositionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePositionRequest 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 +// UpdatePositionRequestMultiError, or nil if none found. +func (m *UpdatePositionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePositionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetPosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePositionRequestValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePositionRequestValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePositionRequestValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePositionRequestMultiError(errors) + } + + return nil +} + +// UpdatePositionRequestMultiError is an error wrapping multiple validation +// errors returned by UpdatePositionRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdatePositionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePositionRequestMultiError) 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 UpdatePositionRequestMultiError) AllErrors() []error { return m } + +// UpdatePositionRequestValidationError is the validation error returned by +// UpdatePositionRequest.Validate if the designated constraints aren't met. +type UpdatePositionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePositionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePositionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePositionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePositionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePositionRequestValidationError) ErrorName() string { + return "UpdatePositionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePositionRequestValidationError) 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 %sUpdatePositionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePositionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePositionRequestValidationError{} + +// Validate checks the field values on UpdatePositionResponse 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 *UpdatePositionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePositionResponse 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 +// UpdatePositionResponseMultiError, or nil if none found. +func (m *UpdatePositionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePositionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetPosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdatePositionResponseValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdatePositionResponseValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdatePositionResponseValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdatePositionResponseMultiError(errors) + } + + return nil +} + +// UpdatePositionResponseMultiError is an error wrapping multiple validation +// errors returned by UpdatePositionResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdatePositionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePositionResponseMultiError) 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 UpdatePositionResponseMultiError) AllErrors() []error { return m } + +// UpdatePositionResponseValidationError is the validation error returned by +// UpdatePositionResponse.Validate if the designated constraints aren't met. +type UpdatePositionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePositionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePositionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePositionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePositionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePositionResponseValidationError) ErrorName() string { + return "UpdatePositionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePositionResponseValidationError) 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 %sUpdatePositionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePositionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePositionResponseValidationError{} + +// Validate checks the field values on DeletePositionRequest 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 *DeletePositionRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeletePositionRequest 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 +// DeletePositionRequestMultiError, or nil if none found. +func (m *DeletePositionRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeletePositionRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeletePositionRequestMultiError(errors) + } + + return nil +} + +// DeletePositionRequestMultiError is an error wrapping multiple validation +// errors returned by DeletePositionRequest.ValidateAll() if the designated +// constraints aren't met. +type DeletePositionRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeletePositionRequestMultiError) 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 DeletePositionRequestMultiError) AllErrors() []error { return m } + +// DeletePositionRequestValidationError is the validation error returned by +// DeletePositionRequest.Validate if the designated constraints aren't met. +type DeletePositionRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeletePositionRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeletePositionRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeletePositionRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeletePositionRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeletePositionRequestValidationError) ErrorName() string { + return "DeletePositionRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeletePositionRequestValidationError) 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 %sDeletePositionRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeletePositionRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeletePositionRequestValidationError{} + +// Validate checks the field values on DeletePositionResponse 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 *DeletePositionResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeletePositionResponse 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 +// DeletePositionResponseMultiError, or nil if none found. +func (m *DeletePositionResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeletePositionResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeletePositionResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeletePositionResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeletePositionResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeletePositionResponseMultiError(errors) + } + + return nil +} + +// DeletePositionResponseMultiError is an error wrapping multiple validation +// errors returned by DeletePositionResponse.ValidateAll() if the designated +// constraints aren't met. +type DeletePositionResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeletePositionResponseMultiError) 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 DeletePositionResponseMultiError) AllErrors() []error { return m } + +// DeletePositionResponseValidationError is the validation error returned by +// DeletePositionResponse.Validate if the designated constraints aren't met. +type DeletePositionResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeletePositionResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeletePositionResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeletePositionResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeletePositionResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeletePositionResponseValidationError) ErrorName() string { + return "DeletePositionResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeletePositionResponseValidationError) 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 %sDeletePositionResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeletePositionResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeletePositionResponseValidationError{} diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go new file mode 100644 index 00000000..037f1db0 --- /dev/null +++ b/api/v1/services/system/position_bridge.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/position.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const PositionServiceCreatePositionBridgeOperation = "/api.v1.services.system.PositionService/CreatePosition" +const PositionServiceDeletePositionBridgeOperation = "/api.v1.services.system.PositionService/DeletePosition" +const PositionServiceGetPositionBridgeOperation = "/api.v1.services.system.PositionService/GetPosition" +const PositionServiceListPositionsBridgeOperation = "/api.v1.services.system.PositionService/ListPositions" +const PositionServiceUpdatePositionBridgeOperation = "/api.v1.services.system.PositionService/UpdatePosition" + +type PositionServiceBridgeServer interface { + CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) + DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) + GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) + ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) + UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) +} + +type PositionServiceHooker interface { + PositionServiceCreatePositionHooker + PositionServiceDeletePositionHooker + PositionServiceGetPositionHooker + PositionServiceListPositionsHooker + PositionServiceUpdatePositionHooker +} + +type PositionServiceHookedBridger interface { + PositionServiceHooker + PositionServiceBridgeServer +} +type PositionServiceCreatePositionHooker interface { + PrepareCreatePosition(http.Context, *CreatePositionRequest) (context.Context, error) + CompleteCreatePosition(http.Context, *CreatePositionRequest, *CreatePositionResponse) error +} +type PositionServiceDeletePositionHooker interface { + PrepareDeletePosition(http.Context, *DeletePositionRequest) (context.Context, error) + CompleteDeletePosition(http.Context, *DeletePositionRequest, *DeletePositionResponse) error +} +type PositionServiceGetPositionHooker interface { + PrepareGetPosition(http.Context, *GetPositionRequest) (context.Context, error) + CompleteGetPosition(http.Context, *GetPositionRequest, *GetPositionResponse) error +} +type PositionServiceListPositionsHooker interface { + PrepareListPositions(http.Context, *ListPositionsRequest) (context.Context, error) + CompleteListPositions(http.Context, *ListPositionsRequest, *ListPositionsResponse) error +} +type PositionServiceUpdatePositionHooker interface { + PrepareUpdatePosition(http.Context, *UpdatePositionRequest) (context.Context, error) + CompleteUpdatePosition(http.Context, *UpdatePositionRequest, *UpdatePositionResponse) error +} + +func RegisterPositionServiceBridgeServer(s *http.Server, srv PositionServiceHookedBridger) { + r := s.Route("/") + r.GET("/sys/positions", _PositionService_ListPositions0_Bridge_Handler(srv)) + r.GET("/sys/positions/:id", _PositionService_GetPosition0_Bridge_Handler(srv)) + r.POST("/sys/positions", _PositionService_CreatePosition0_Bridge_Handler(srv)) + r.PUT("/sys/positions/:position.id", _PositionService_UpdatePosition0_Bridge_Handler(srv)) + r.DELETE("/sys/positions/:id", _PositionService_DeletePosition0_Bridge_Handler(srv)) +} + +func _PositionService_ListPositions0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPositionsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceListPositions) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPositions(ctx, req.(*ListPositionsRequest)) + }) + + newctx, err := srv.PrepareListPositions(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListPositions(ctx, &in, out.(*ListPositionsResponse)) + } +} + +func _PositionService_GetPosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPositionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceGetPosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPosition(ctx, req.(*GetPositionRequest)) + }) + + newctx, err := srv.PrepareGetPosition(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetPosition(ctx, &in, out.(*GetPositionResponse)) + } +} + +func _PositionService_CreatePosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreatePositionRequest + if err := ctx.Bind(&in.Position); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceCreatePosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreatePosition(ctx, req.(*CreatePositionRequest)) + }) + + newctx, err := srv.PrepareCreatePosition(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreatePosition(ctx, &in, out.(*CreatePositionResponse)) + } +} + +func _PositionService_UpdatePosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePositionRequest + if err := ctx.Bind(&in.Position); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceUpdatePosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePosition(ctx, req.(*UpdatePositionRequest)) + }) + + newctx, err := srv.PrepareUpdatePosition(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePosition(ctx, &in, out.(*UpdatePositionResponse)) + } +} + +func _PositionService_DeletePosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeletePositionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceDeletePosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeletePosition(ctx, req.(*DeletePositionRequest)) + }) + + newctx, err := srv.PrepareDeletePosition(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeletePosition(ctx, &in, out.(*DeletePositionResponse)) + } +} + +// UnimplementedPositionServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPositionServiceHooked struct{} + +func (UnimplementedPositionServiceHooked) PrepareCreatePosition(ctx http.Context, in *CreatePositionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPositionServiceHooked) CompleteCreatePosition(ctx http.Context, in *CreatePositionRequest, out *CreatePositionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPositionServiceHooked) PrepareDeletePosition(ctx http.Context, in *DeletePositionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPositionServiceHooked) CompleteDeletePosition(ctx http.Context, in *DeletePositionRequest, out *DeletePositionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPositionServiceHooked) PrepareGetPosition(ctx http.Context, in *GetPositionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPositionServiceHooked) CompleteGetPosition(ctx http.Context, in *GetPositionRequest, out *GetPositionResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPositionServiceHooked) PrepareListPositions(ctx http.Context, in *ListPositionsRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPositionServiceHooked) CompleteListPositions(ctx http.Context, in *ListPositionsRequest, out *ListPositionsResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedPositionServiceHooked) PrepareUpdatePosition(ctx http.Context, in *UpdatePositionRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedPositionServiceHooked) CompleteUpdatePosition(ctx http.Context, in *UpdatePositionRequest, out *UpdatePositionResponse) error { + return ctx.Result(200, out) +} + +func WithPositionServiceHook(h PositionServiceHooker) func(PositionServiceBridgeServer) PositionServiceHookedBridger { + return func(srv PositionServiceBridgeServer) PositionServiceHookedBridger { + return PositionServiceHookedBridge{PositionServiceBridgeServer: srv, PositionServiceHooker: h} + } +} + +// PositionServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PositionService. +// It implements the HTTP and gRPC implementations of PositionService. +// It forwards requests and responses between the two implementations. +type PositionServiceHookedBridge struct { + PositionServiceBridgeServer + PositionServiceHooker +} + +type PositionServiceHTTPBridgeImpl struct { + client PositionServiceHTTPClient +} + +func NewPositionServiceHTTPBridge(client *http.Client) PositionServiceHTTPServer { + return &PositionServiceHTTPBridgeImpl{client: NewPositionServiceHTTPClient(client)} +} + +func (c *PositionServiceHTTPBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) +} + +func (c *PositionServiceHTTPBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + +func (c *PositionServiceHTTPBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { + return c.client.GetPosition(ctx, in) +} + +func (c *PositionServiceHTTPBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) +} + +func (c *PositionServiceHTTPBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { + return c.client.UpdatePosition(ctx, in) +} + +type PositionServiceBridgeImpl struct { + client PositionServiceClient +} + +func NewPositionServiceBridge(client grpc.ClientConnInterface) PositionServiceServer { + return &PositionServiceBridgeImpl{client: NewPositionServiceClient(client)} +} + +func (c *PositionServiceBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) +} + +func (c *PositionServiceBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + +func (c *PositionServiceBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { + return c.client.GetPosition(ctx, in) +} + +func (c *PositionServiceBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) +} + +func (c *PositionServiceBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { + return c.client.UpdatePosition(ctx, in) +} + +func (c *PositionServiceBridgeImpl) mustEmbedUnimplementedPositionServiceServer() {} + +type PositionServiceGRPC2HTTPBridgeImpl struct { + client PositionServiceClient +} + +func NewPositionServiceGRPC2HTTP(client grpc.ClientConnInterface) PositionServiceHTTPServer { + return &PositionServiceGRPC2HTTPBridgeImpl{client: NewPositionServiceClient(client)} +} + +func (c *PositionServiceGRPC2HTTPBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) +} + +func (c *PositionServiceGRPC2HTTPBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + +func (c *PositionServiceGRPC2HTTPBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { + return c.client.GetPosition(ctx, in) +} + +func (c *PositionServiceGRPC2HTTPBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) +} + +func (c *PositionServiceGRPC2HTTPBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { + return c.client.UpdatePosition(ctx, in) +} + +type PositionServiceHTTP2GRPCBridgeImpl struct { + client PositionServiceHTTPClient +} + +func NewPositionServiceHTTP2GRPC(client *http.Client) PositionServiceServer { + return &PositionServiceHTTP2GRPCBridgeImpl{client: NewPositionServiceHTTPClient(client)} +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { + return c.client.GetPosition(ctx, in) +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { + return c.client.UpdatePosition(ctx, in) +} + +func (c *PositionServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPositionServiceServer() {} diff --git a/api/v1/services/system/position_grpc.pb.go b/api/v1/services/system/position_grpc.pb.go new file mode 100644 index 00000000..27fb4973 --- /dev/null +++ b/api/v1/services/system/position_grpc.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: system/position.proto + +package system + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + PositionService_ListPositions_FullMethodName = "/api.v1.services.system.PositionService/ListPositions" + PositionService_GetPosition_FullMethodName = "/api.v1.services.system.PositionService/GetPosition" + PositionService_CreatePosition_FullMethodName = "/api.v1.services.system.PositionService/CreatePosition" + PositionService_UpdatePosition_FullMethodName = "/api.v1.services.system.PositionService/UpdatePosition" + PositionService_DeletePosition_FullMethodName = "/api.v1.services.system.PositionService/DeletePosition" +) + +// PositionServiceClient is the client API for PositionService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The login service definition. +type PositionServiceClient interface { + ListPositions(ctx context.Context, in *ListPositionsRequest, opts ...grpc.CallOption) (*ListPositionsResponse, error) + GetPosition(ctx context.Context, in *GetPositionRequest, opts ...grpc.CallOption) (*GetPositionResponse, error) + CreatePosition(ctx context.Context, in *CreatePositionRequest, opts ...grpc.CallOption) (*CreatePositionResponse, error) + UpdatePosition(ctx context.Context, in *UpdatePositionRequest, opts ...grpc.CallOption) (*UpdatePositionResponse, error) + DeletePosition(ctx context.Context, in *DeletePositionRequest, opts ...grpc.CallOption) (*DeletePositionResponse, error) +} + +type positionServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewPositionServiceClient(cc grpc.ClientConnInterface) PositionServiceClient { + return &positionServiceClient{cc} +} + +func (c *positionServiceClient) ListPositions(ctx context.Context, in *ListPositionsRequest, opts ...grpc.CallOption) (*ListPositionsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListPositionsResponse) + err := c.cc.Invoke(ctx, PositionService_ListPositions_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *positionServiceClient) GetPosition(ctx context.Context, in *GetPositionRequest, opts ...grpc.CallOption) (*GetPositionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetPositionResponse) + err := c.cc.Invoke(ctx, PositionService_GetPosition_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *positionServiceClient) CreatePosition(ctx context.Context, in *CreatePositionRequest, opts ...grpc.CallOption) (*CreatePositionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreatePositionResponse) + err := c.cc.Invoke(ctx, PositionService_CreatePosition_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *positionServiceClient) UpdatePosition(ctx context.Context, in *UpdatePositionRequest, opts ...grpc.CallOption) (*UpdatePositionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdatePositionResponse) + err := c.cc.Invoke(ctx, PositionService_UpdatePosition_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *positionServiceClient) DeletePosition(ctx context.Context, in *DeletePositionRequest, opts ...grpc.CallOption) (*DeletePositionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeletePositionResponse) + err := c.cc.Invoke(ctx, PositionService_DeletePosition_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PositionServiceServer is the server API for PositionService service. +// All implementations must embed UnimplementedPositionServiceServer +// for forward compatibility. +// +// The login service definition. +type PositionServiceServer interface { + ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) + GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) + CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) + UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) + DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) + mustEmbedUnimplementedPositionServiceServer() +} + +// UnimplementedPositionServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedPositionServiceServer struct{} + +func (UnimplementedPositionServiceServer) ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListPositions not implemented") +} +func (UnimplementedPositionServiceServer) GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPosition not implemented") +} +func (UnimplementedPositionServiceServer) CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreatePosition not implemented") +} +func (UnimplementedPositionServiceServer) UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePosition not implemented") +} +func (UnimplementedPositionServiceServer) DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeletePosition not implemented") +} +func (UnimplementedPositionServiceServer) mustEmbedUnimplementedPositionServiceServer() {} +func (UnimplementedPositionServiceServer) testEmbeddedByValue() {} + +// UnsafePositionServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PositionServiceServer will +// result in compilation errors. +type UnsafePositionServiceServer interface { + mustEmbedUnimplementedPositionServiceServer() +} + +func RegisterPositionServiceServer(s grpc.ServiceRegistrar, srv PositionServiceServer) { + // If the following call pancis, it indicates UnimplementedPositionServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&PositionService_ServiceDesc, srv) +} + +func _PositionService_ListPositions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListPositionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PositionServiceServer).ListPositions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PositionService_ListPositions_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PositionServiceServer).ListPositions(ctx, req.(*ListPositionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PositionService_GetPosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPositionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PositionServiceServer).GetPosition(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PositionService_GetPosition_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PositionServiceServer).GetPosition(ctx, req.(*GetPositionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PositionService_CreatePosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreatePositionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PositionServiceServer).CreatePosition(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PositionService_CreatePosition_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PositionServiceServer).CreatePosition(ctx, req.(*CreatePositionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PositionService_UpdatePosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePositionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PositionServiceServer).UpdatePosition(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PositionService_UpdatePosition_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PositionServiceServer).UpdatePosition(ctx, req.(*UpdatePositionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _PositionService_DeletePosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeletePositionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PositionServiceServer).DeletePosition(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: PositionService_DeletePosition_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PositionServiceServer).DeletePosition(ctx, req.(*DeletePositionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// PositionService_ServiceDesc is the grpc.ServiceDesc for PositionService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PositionService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.system.PositionService", + HandlerType: (*PositionServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListPositions", + Handler: _PositionService_ListPositions_Handler, + }, + { + MethodName: "GetPosition", + Handler: _PositionService_GetPosition_Handler, + }, + { + MethodName: "CreatePosition", + Handler: _PositionService_CreatePosition_Handler, + }, + { + MethodName: "UpdatePosition", + Handler: _PositionService_UpdatePosition_Handler, + }, + { + MethodName: "DeletePosition", + Handler: _PositionService_DeletePosition_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "system/position.proto", +} diff --git a/api/v1/services/system/position_http.pb.go b/api/v1/services/system/position_http.pb.go new file mode 100644 index 00000000..6ded04a3 --- /dev/null +++ b/api/v1/services/system/position_http.pb.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: system/position.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationPositionServiceCreatePosition = "/api.v1.services.system.PositionService/CreatePosition" +const OperationPositionServiceDeletePosition = "/api.v1.services.system.PositionService/DeletePosition" +const OperationPositionServiceGetPosition = "/api.v1.services.system.PositionService/GetPosition" +const OperationPositionServiceListPositions = "/api.v1.services.system.PositionService/ListPositions" +const OperationPositionServiceUpdatePosition = "/api.v1.services.system.PositionService/UpdatePosition" + +type PositionServiceHTTPServer interface { + CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) + DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) + GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) + ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) + UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) +} + +func RegisterPositionServiceHTTPServer(s *http.Server, srv PositionServiceHTTPServer) { + r := s.Route("/") + r.GET("/sys/positions", _PositionService_ListPositions0_HTTP_Handler(srv)) + r.GET("/sys/positions/{id}", _PositionService_GetPosition0_HTTP_Handler(srv)) + r.POST("/sys/positions", _PositionService_CreatePosition0_HTTP_Handler(srv)) + r.PUT("/sys/positions/{position.id}", _PositionService_UpdatePosition0_HTTP_Handler(srv)) + r.DELETE("/sys/positions/{id}", _PositionService_DeletePosition0_HTTP_Handler(srv)) +} + +func _PositionService_ListPositions0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListPositionsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceListPositions) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListPositions(ctx, req.(*ListPositionsRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListPositionsResponse) + return ctx.Result(200, reply) + } +} + +func _PositionService_GetPosition0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetPositionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceGetPosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetPosition(ctx, req.(*GetPositionRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetPositionResponse) + return ctx.Result(200, reply) + } +} + +func _PositionService_CreatePosition0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreatePositionRequest + if err := ctx.Bind(&in.Position); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceCreatePosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreatePosition(ctx, req.(*CreatePositionRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreatePositionResponse) + return ctx.Result(200, reply) + } +} + +func _PositionService_UpdatePosition0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePositionRequest + if err := ctx.Bind(&in.Position); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceUpdatePosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePosition(ctx, req.(*UpdatePositionRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdatePositionResponse) + return ctx.Result(200, reply) + } +} + +func _PositionService_DeletePosition0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeletePositionRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationPositionServiceDeletePosition) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeletePosition(ctx, req.(*DeletePositionRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeletePositionResponse) + return ctx.Result(200, reply) + } +} + +type PositionServiceHTTPClient interface { + CreatePosition(ctx context.Context, req *CreatePositionRequest, opts ...http.CallOption) (rsp *CreatePositionResponse, err error) + DeletePosition(ctx context.Context, req *DeletePositionRequest, opts ...http.CallOption) (rsp *DeletePositionResponse, err error) + GetPosition(ctx context.Context, req *GetPositionRequest, opts ...http.CallOption) (rsp *GetPositionResponse, err error) + ListPositions(ctx context.Context, req *ListPositionsRequest, opts ...http.CallOption) (rsp *ListPositionsResponse, err error) + UpdatePosition(ctx context.Context, req *UpdatePositionRequest, opts ...http.CallOption) (rsp *UpdatePositionResponse, err error) +} + +type PositionServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewPositionServiceHTTPClient(client *http.Client) PositionServiceHTTPClient { + return &PositionServiceHTTPClientImpl{client} +} + +func (c *PositionServiceHTTPClientImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest, opts ...http.CallOption) (*CreatePositionResponse, error) { + var out CreatePositionResponse + pattern := "/sys/positions" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPositionServiceCreatePosition)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Position, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PositionServiceHTTPClientImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest, opts ...http.CallOption) (*DeletePositionResponse, error) { + var out DeletePositionResponse + pattern := "/sys/positions/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPositionServiceDeletePosition)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PositionServiceHTTPClientImpl) GetPosition(ctx context.Context, in *GetPositionRequest, opts ...http.CallOption) (*GetPositionResponse, error) { + var out GetPositionResponse + pattern := "/sys/positions/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPositionServiceGetPosition)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PositionServiceHTTPClientImpl) ListPositions(ctx context.Context, in *ListPositionsRequest, opts ...http.CallOption) (*ListPositionsResponse, error) { + var out ListPositionsResponse + pattern := "/sys/positions" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationPositionServiceListPositions)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *PositionServiceHTTPClientImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest, opts ...http.CallOption) (*UpdatePositionResponse, error) { + var out UpdatePositionResponse + pattern := "/sys/positions/{position.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationPositionServiceUpdatePosition)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Position, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go new file mode 100644 index 00000000..be71731b --- /dev/null +++ b/api/v1/services/system/resource.pb.go @@ -0,0 +1,755 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: system/resource.proto + +package system + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// ListResourcesRequest is the request for the ResourceService.ListResources method. +type ListResourcesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The page number. + Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // resource type + Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + // The resource name keyword + Keyword string `protobuf:"bytes,8,opt,name=keyword,proto3" json:"keyword,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListResourcesRequest) Reset() { + *x = ListResourcesRequest{} + mi := &file_system_resource_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListResourcesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListResourcesRequest) ProtoMessage() {} + +func (x *ListResourcesRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_resource_proto_msgTypes[0] + 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 ListResourcesRequest.ProtoReflect.Descriptor instead. +func (*ListResourcesRequest) Descriptor() ([]byte, []int) { + return file_system_resource_proto_rawDescGZIP(), []int{0} +} + +func (x *ListResourcesRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListResourcesRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListResourcesRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListResourcesRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListResourcesRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListResourcesRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListResourcesRequest) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *ListResourcesRequest) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +// ListResourcesResponse is the response for the ResourceService.ListResources method. +type ListResourcesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` + // The paging resources + Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + // The page number. + Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the page data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListResourcesResponse) Reset() { + *x = ListResourcesResponse{} + mi := &file_system_resource_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListResourcesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListResourcesResponse) ProtoMessage() {} + +func (x *ListResourcesResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_resource_proto_msgTypes[1] + 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 ListResourcesResponse.ProtoReflect.Descriptor instead. +func (*ListResourcesResponse) Descriptor() ([]byte, []int) { + return file_system_resource_proto_rawDescGZIP(), []int{1} +} + +func (x *ListResourcesResponse) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *ListResourcesResponse) GetResources() []*types.Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *ListResourcesResponse) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListResourcesResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListResourcesResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListResourcesResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +// GetResourceRequest is the request for the ResourceService.GetResource method. +type GetResourceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the resource requested, for example: + // "shelves/shelf1/resources/resource2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetResourceRequest) Reset() { + *x = GetResourceRequest{} + mi := &file_system_resource_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetResourceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetResourceRequest) ProtoMessage() {} + +func (x *GetResourceRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_resource_proto_msgTypes[2] + 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 GetResourceRequest.ProtoReflect.Descriptor instead. +func (*GetResourceRequest) Descriptor() ([]byte, []int) { + return file_system_resource_proto_rawDescGZIP(), []int{2} +} + +func (x *GetResourceRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// GetResourceResponse is the response for the ResourceService.GetResource method. +type GetResourceResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field id should match the Noun in the method id. + Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetResourceResponse) Reset() { + *x = GetResourceResponse{} + mi := &file_system_resource_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetResourceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetResourceResponse) ProtoMessage() {} + +func (x *GetResourceResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_resource_proto_msgTypes[3] + 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 GetResourceResponse.ProtoReflect.Descriptor instead. +func (*GetResourceResponse) Descriptor() ([]byte, []int) { + return file_system_resource_proto_rawDescGZIP(), []int{3} +} + +func (x *GetResourceResponse) GetResource() *types.Resource { + if x != nil { + return x.Resource + } + return nil +} + +// CreateResourceRequest is the request for the ResourceService.CreateResource method. +type CreateResourceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id where the resource is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The resource id to use for this resource. + ResourceId string `protobuf:"bytes,2,opt,name=resource_id,proto3" json:"resource_id,omitempty"` + // The resource object to create. + Resource *types.Resource `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateResourceRequest) Reset() { + *x = CreateResourceRequest{} + mi := &file_system_resource_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateResourceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateResourceRequest) ProtoMessage() {} + +func (x *CreateResourceRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_resource_proto_msgTypes[4] + 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 CreateResourceRequest.ProtoReflect.Descriptor instead. +func (*CreateResourceRequest) Descriptor() ([]byte, []int) { + return file_system_resource_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateResourceRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateResourceRequest) GetResourceId() string { + if x != nil { + return x.ResourceId + } + return "" +} + +func (x *CreateResourceRequest) GetResource() *types.Resource { + if x != nil { + return x.Resource + } + return nil +} + +// CreateResourceResponse is the response for the ResourceService.CreateResource method. +type CreateResourceResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateResourceResponse) Reset() { + *x = CreateResourceResponse{} + mi := &file_system_resource_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateResourceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateResourceResponse) ProtoMessage() {} + +func (x *CreateResourceResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_resource_proto_msgTypes[5] + 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 CreateResourceResponse.ProtoReflect.Descriptor instead. +func (*CreateResourceResponse) Descriptor() ([]byte, []int) { + return file_system_resource_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateResourceResponse) GetResource() *types.Resource { + if x != nil { + return x.Resource + } + return nil +} + +// UpdateResourceRequest is the request for the ResourceService.UpdateResource method. +type UpdateResourceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The id of the resource object to update. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The resource object which replaces the resource on the server. + Resource *types.Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateResourceRequest) Reset() { + *x = UpdateResourceRequest{} + mi := &file_system_resource_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateResourceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateResourceRequest) ProtoMessage() {} + +func (x *UpdateResourceRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_resource_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 UpdateResourceRequest.ProtoReflect.Descriptor instead. +func (*UpdateResourceRequest) Descriptor() ([]byte, []int) { + return file_system_resource_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateResourceRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateResourceRequest) GetResource() *types.Resource { + if x != nil { + return x.Resource + } + return nil +} + +// UpdateResourceResponse is the response for the ResourceService.UpdateResource method. +type UpdateResourceResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateResourceResponse) Reset() { + *x = UpdateResourceResponse{} + mi := &file_system_resource_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateResourceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateResourceResponse) ProtoMessage() {} + +func (x *UpdateResourceResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_resource_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateResourceResponse.ProtoReflect.Descriptor instead. +func (*UpdateResourceResponse) Descriptor() ([]byte, []int) { + return file_system_resource_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateResourceResponse) GetResource() *types.Resource { + if x != nil { + return x.Resource + } + return nil +} + +// DeleteResourceRequest is the request for the ResourceService.DeleteResource method. +type DeleteResourceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The resource id of the resource to be deleted, for example: + // "shelves/shelf1/resources/resource2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteResourceRequest) Reset() { + *x = DeleteResourceRequest{} + mi := &file_system_resource_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteResourceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteResourceRequest) ProtoMessage() {} + +func (x *DeleteResourceRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_resource_proto_msgTypes[8] + 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 DeleteResourceRequest.ProtoReflect.Descriptor instead. +func (*DeleteResourceRequest) Descriptor() ([]byte, []int) { + return file_system_resource_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteResourceRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// DeleteResourceResponse is the response for the ResourceService.DeleteResource method. +type DeleteResourceResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // or Resource resource = 1; or google.protobuf.Empty empty = 1; + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteResourceResponse) Reset() { + *x = DeleteResourceResponse{} + mi := &file_system_resource_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteResourceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteResourceResponse) ProtoMessage() {} + +func (x *DeleteResourceResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_resource_proto_msgTypes[9] + 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 DeleteResourceResponse.ProtoReflect.Descriptor instead. +func (*DeleteResourceResponse) Descriptor() ([]byte, []int) { + return file_system_resource_proto_rawDescGZIP(), []int{9} +} + +func (x *DeleteResourceResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_system_resource_proto protoreflect.FileDescriptor + +const file_system_resource_proto_rawDesc = "" + + "\n" + + "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xe4\x01\n" + + "\x14ListResourcesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x12\n" + + "\x04type\x18\a \x01(\tR\x04type\x12\x18\n" + + "\akeyword\x18\b \x01(\tR\akeyword\"\x83\x02\n" + + "\x15ListResourcesResponse\x12\x14\n" + + "\x05total\x18\x01 \x01(\x05R\x05total\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x12\n" + + "\x04page\x18\x03 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\"$\n" + + "\x12GetResourceRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"R\n" + + "\x13GetResourceResponse\x12;\n" + + "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"\x8e\x01\n" + + "\x15CreateResourceRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12 \n" + + "\vresource_id\x18\x02 \x01(\tR\vresource_id\x12;\n" + + "\bresource\x18\x03 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"U\n" + + "\x16CreateResourceResponse\x12;\n" + + "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"d\n" + + "\x15UpdateResourceRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12;\n" + + "\bresource\x18\x02 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"U\n" + + "\x16UpdateResourceResponse\x12;\n" + + "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"'\n" + + "\x15DeleteResourceRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + + "\x16DeleteResourceResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xe3\x05\n" + + "\x0fResourceService\x12\x84\x01\n" + + "\rListResources\x12,.api.v1.services.system.ListResourcesRequest\x1a-.api.v1.services.system.ListResourcesResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/resources\x12\x83\x01\n" + + "\vGetResource\x12*.api.v1.services.system.GetResourceRequest\x1a+.api.v1.services.system.GetResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/resources/{id}\x12\x91\x01\n" + + "\x0eCreateResource\x12-.api.v1.services.system.CreateResourceRequest\x1a..api.v1.services.system.CreateResourceResponse\" \x82\xd3\xe4\x93\x02\x1a:\bresource\"\x0e/sys/resources\x12\x9f\x01\n" + + "\x0eUpdateResource\x12-.api.v1.services.system.UpdateResourceRequest\x1a..api.v1.services.system.UpdateResourceResponse\".\x82\xd3\xe4\x93\x02(:\bresource\x1a\x1c/sys/resources/{resource.id}\x12\x8c\x01\n" + + "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xe2\x01\n" + + "\x1acom.api.v1.services.systemB\rResourceProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + +var ( + file_system_resource_proto_rawDescOnce sync.Once + file_system_resource_proto_rawDescData []byte +) + +func file_system_resource_proto_rawDescGZIP() []byte { + file_system_resource_proto_rawDescOnce.Do(func() { + file_system_resource_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_resource_proto_rawDesc), len(file_system_resource_proto_rawDesc))) + }) + return file_system_resource_proto_rawDescData +} + +var file_system_resource_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_system_resource_proto_goTypes = []any{ + (*ListResourcesRequest)(nil), // 0: api.v1.services.system.ListResourcesRequest + (*ListResourcesResponse)(nil), // 1: api.v1.services.system.ListResourcesResponse + (*GetResourceRequest)(nil), // 2: api.v1.services.system.GetResourceRequest + (*GetResourceResponse)(nil), // 3: api.v1.services.system.GetResourceResponse + (*CreateResourceRequest)(nil), // 4: api.v1.services.system.CreateResourceRequest + (*CreateResourceResponse)(nil), // 5: api.v1.services.system.CreateResourceResponse + (*UpdateResourceRequest)(nil), // 6: api.v1.services.system.UpdateResourceRequest + (*UpdateResourceResponse)(nil), // 7: api.v1.services.system.UpdateResourceResponse + (*DeleteResourceRequest)(nil), // 8: api.v1.services.system.DeleteResourceRequest + (*DeleteResourceResponse)(nil), // 9: api.v1.services.system.DeleteResourceResponse + (*types.Resource)(nil), // 10: api.v1.services.types.Resource + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_system_resource_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.system.ListResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 11, // 1: api.v1.services.system.ListResourcesResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.system.GetResourceResponse.resource:type_name -> api.v1.services.types.Resource + 10, // 3: api.v1.services.system.CreateResourceRequest.resource:type_name -> api.v1.services.types.Resource + 10, // 4: api.v1.services.system.CreateResourceResponse.resource:type_name -> api.v1.services.types.Resource + 10, // 5: api.v1.services.system.UpdateResourceRequest.resource:type_name -> api.v1.services.types.Resource + 10, // 6: api.v1.services.system.UpdateResourceResponse.resource:type_name -> api.v1.services.types.Resource + 12, // 7: api.v1.services.system.DeleteResourceResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.system.ResourceService.ListResources:input_type -> api.v1.services.system.ListResourcesRequest + 2, // 9: api.v1.services.system.ResourceService.GetResource:input_type -> api.v1.services.system.GetResourceRequest + 4, // 10: api.v1.services.system.ResourceService.CreateResource:input_type -> api.v1.services.system.CreateResourceRequest + 6, // 11: api.v1.services.system.ResourceService.UpdateResource:input_type -> api.v1.services.system.UpdateResourceRequest + 8, // 12: api.v1.services.system.ResourceService.DeleteResource:input_type -> api.v1.services.system.DeleteResourceRequest + 1, // 13: api.v1.services.system.ResourceService.ListResources:output_type -> api.v1.services.system.ListResourcesResponse + 3, // 14: api.v1.services.system.ResourceService.GetResource:output_type -> api.v1.services.system.GetResourceResponse + 5, // 15: api.v1.services.system.ResourceService.CreateResource:output_type -> api.v1.services.system.CreateResourceResponse + 7, // 16: api.v1.services.system.ResourceService.UpdateResource:output_type -> api.v1.services.system.UpdateResourceResponse + 9, // 17: api.v1.services.system.ResourceService.DeleteResource:output_type -> api.v1.services.system.DeleteResourceResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_system_resource_proto_init() } +func file_system_resource_proto_init() { + if File_system_resource_proto != nil { + return + } + file_system_resource_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_resource_proto_rawDesc), len(file_system_resource_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_system_resource_proto_goTypes, + DependencyIndexes: file_system_resource_proto_depIdxs, + MessageInfos: file_system_resource_proto_msgTypes, + }.Build() + File_system_resource_proto = out.File + file_system_resource_proto_goTypes = nil + file_system_resource_proto_depIdxs = nil +} diff --git a/api/v1/services/system/resource.pb.gw.go b/api/v1/services/system/resource.pb.gw.go new file mode 100644 index 00000000..36912fc0 --- /dev/null +++ b/api/v1/services/system/resource.pb.gw.go @@ -0,0 +1,487 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: system/resource.proto + +/* +Package system is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package system + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_ResourceService_ListResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_ResourceService_ListResources_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListResourcesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_ListResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_ResourceService_ListResources_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListResourcesRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_ListResources_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListResources(ctx, &protoReq) + return msg, metadata, err +} + +func request_ResourceService_GetResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetResourceRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_ResourceService_GetResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetResourceRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetResource(ctx, &protoReq) + return msg, metadata, err +} + +var filter_ResourceService_CreateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{"resource": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_ResourceService_CreateResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateResourceRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_CreateResource_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_ResourceService_CreateResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateResourceRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_CreateResource_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateResource(ctx, &protoReq) + return msg, metadata, err +} + +var filter_ResourceService_UpdateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{"resource": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_ResourceService_UpdateResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateResourceRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["resource.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "resource.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "resource.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_UpdateResource_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_ResourceService_UpdateResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateResourceRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["resource.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "resource.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "resource.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_UpdateResource_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateResource(ctx, &protoReq) + return msg, metadata, err +} + +func request_ResourceService_DeleteResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteResourceRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_ResourceService_DeleteResource_0(ctx context.Context, marshaler runtime.Marshaler, server ResourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteResourceRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteResource(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterResourceServiceHandlerServer registers the http handlers for service ResourceService to "mux". +// UnaryRPC :call ResourceServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterResourceServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterResourceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ResourceServiceServer) error { + mux.Handle(http.MethodGet, pattern_ResourceService_ListResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ResourceService/ListResources", runtime.WithHTTPPathPattern("/sys/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ResourceService_ListResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ResourceService_ListResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_ResourceService_GetResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ResourceService/GetResource", runtime.WithHTTPPathPattern("/sys/resources/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ResourceService_GetResource_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ResourceService_GetResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_ResourceService_CreateResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ResourceService/CreateResource", runtime.WithHTTPPathPattern("/sys/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ResourceService_CreateResource_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ResourceService_CreateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_ResourceService_UpdateResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ResourceService/UpdateResource", runtime.WithHTTPPathPattern("/sys/resources/{resource.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ResourceService_UpdateResource_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ResourceService_UpdateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_ResourceService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ResourceService/DeleteResource", runtime.WithHTTPPathPattern("/sys/resources/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ResourceService_DeleteResource_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ResourceService_DeleteResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterResourceServiceHandlerFromEndpoint is same as RegisterResourceServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterResourceServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterResourceServiceHandler(ctx, mux, conn) +} + +// RegisterResourceServiceHandler registers the http handlers for service ResourceService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterResourceServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterResourceServiceHandlerClient(ctx, mux, NewResourceServiceClient(conn)) +} + +// RegisterResourceServiceHandlerClient registers the http handlers for service ResourceService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ResourceServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ResourceServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "ResourceServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterResourceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ResourceServiceClient) error { + mux.Handle(http.MethodGet, pattern_ResourceService_ListResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ResourceService/ListResources", runtime.WithHTTPPathPattern("/sys/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ResourceService_ListResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ResourceService_ListResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_ResourceService_GetResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ResourceService/GetResource", runtime.WithHTTPPathPattern("/sys/resources/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ResourceService_GetResource_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ResourceService_GetResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_ResourceService_CreateResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ResourceService/CreateResource", runtime.WithHTTPPathPattern("/sys/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ResourceService_CreateResource_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ResourceService_CreateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_ResourceService_UpdateResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ResourceService/UpdateResource", runtime.WithHTTPPathPattern("/sys/resources/{resource.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ResourceService_UpdateResource_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ResourceService_UpdateResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_ResourceService_DeleteResource_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ResourceService/DeleteResource", runtime.WithHTTPPathPattern("/sys/resources/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ResourceService_DeleteResource_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ResourceService_DeleteResource_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_ResourceService_ListResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "resources"}, "")) + pattern_ResourceService_GetResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "resources", "id"}, "")) + pattern_ResourceService_CreateResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "resources"}, "")) + pattern_ResourceService_UpdateResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "resources", "resource.id"}, "")) + pattern_ResourceService_DeleteResource_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "resources", "id"}, "")) +) + +var ( + forward_ResourceService_ListResources_0 = runtime.ForwardResponseMessage + forward_ResourceService_GetResource_0 = runtime.ForwardResponseMessage + forward_ResourceService_CreateResource_0 = runtime.ForwardResponseMessage + forward_ResourceService_UpdateResource_0 = runtime.ForwardResponseMessage + forward_ResourceService_DeleteResource_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/system/resource.pb.validate.go b/api/v1/services/system/resource.pb.validate.go new file mode 100644 index 00000000..daec38f1 --- /dev/null +++ b/api/v1/services/system/resource.pb.validate.go @@ -0,0 +1,1331 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: system/resource.proto + +package system + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListResourcesRequest 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 *ListResourcesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListResourcesRequest 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 +// ListResourcesRequestMultiError, or nil if none found. +func (m *ListResourcesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListResourcesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Type + + // no validation rules for Keyword + + if len(errors) > 0 { + return ListResourcesRequestMultiError(errors) + } + + return nil +} + +// ListResourcesRequestMultiError is an error wrapping multiple validation +// errors returned by ListResourcesRequest.ValidateAll() if the designated +// constraints aren't met. +type ListResourcesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListResourcesRequestMultiError) 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 ListResourcesRequestMultiError) AllErrors() []error { return m } + +// ListResourcesRequestValidationError is the validation error returned by +// ListResourcesRequest.Validate if the designated constraints aren't met. +type ListResourcesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListResourcesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListResourcesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListResourcesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListResourcesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListResourcesRequestValidationError) ErrorName() string { + return "ListResourcesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListResourcesRequestValidationError) 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 %sListResourcesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListResourcesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListResourcesRequestValidationError{} + +// Validate checks the field values on ListResourcesResponse 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 *ListResourcesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListResourcesResponse 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 +// ListResourcesResponseMultiError, or nil if none found. +func (m *ListResourcesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListResourcesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Total + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListResourcesResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListResourcesResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListResourcesResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListResourcesResponseMultiError(errors) + } + + return nil +} + +// ListResourcesResponseMultiError is an error wrapping multiple validation +// errors returned by ListResourcesResponse.ValidateAll() if the designated +// constraints aren't met. +type ListResourcesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListResourcesResponseMultiError) 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 ListResourcesResponseMultiError) AllErrors() []error { return m } + +// ListResourcesResponseValidationError is the validation error returned by +// ListResourcesResponse.Validate if the designated constraints aren't met. +type ListResourcesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListResourcesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListResourcesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListResourcesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListResourcesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListResourcesResponseValidationError) ErrorName() string { + return "ListResourcesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListResourcesResponseValidationError) 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 %sListResourcesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListResourcesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListResourcesResponseValidationError{} + +// Validate checks the field values on GetResourceRequest 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 *GetResourceRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetResourceRequest 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 +// GetResourceRequestMultiError, or nil if none found. +func (m *GetResourceRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetResourceRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetResourceRequestMultiError(errors) + } + + return nil +} + +// GetResourceRequestMultiError is an error wrapping multiple validation errors +// returned by GetResourceRequest.ValidateAll() if the designated constraints +// aren't met. +type GetResourceRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetResourceRequestMultiError) 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 GetResourceRequestMultiError) AllErrors() []error { return m } + +// GetResourceRequestValidationError is the validation error returned by +// GetResourceRequest.Validate if the designated constraints aren't met. +type GetResourceRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetResourceRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetResourceRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetResourceRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetResourceRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetResourceRequestValidationError) ErrorName() string { + return "GetResourceRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetResourceRequestValidationError) 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 %sGetResourceRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetResourceRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetResourceRequestValidationError{} + +// Validate checks the field values on GetResourceResponse 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 *GetResourceResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetResourceResponse 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 +// GetResourceResponseMultiError, or nil if none found. +func (m *GetResourceResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetResourceResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetResource()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetResourceResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetResourceResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetResourceResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetResourceResponseMultiError(errors) + } + + return nil +} + +// GetResourceResponseMultiError is an error wrapping multiple validation +// errors returned by GetResourceResponse.ValidateAll() if the designated +// constraints aren't met. +type GetResourceResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetResourceResponseMultiError) 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 GetResourceResponseMultiError) AllErrors() []error { return m } + +// GetResourceResponseValidationError is the validation error returned by +// GetResourceResponse.Validate if the designated constraints aren't met. +type GetResourceResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetResourceResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetResourceResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetResourceResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetResourceResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetResourceResponseValidationError) ErrorName() string { + return "GetResourceResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetResourceResponseValidationError) 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 %sGetResourceResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetResourceResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetResourceResponseValidationError{} + +// Validate checks the field values on CreateResourceRequest 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 *CreateResourceRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateResourceRequest 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 +// CreateResourceRequestMultiError, or nil if none found. +func (m *CreateResourceRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateResourceRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for ResourceId + + if all { + switch v := interface{}(m.GetResource()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateResourceRequestValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateResourceRequestValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateResourceRequestValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateResourceRequestMultiError(errors) + } + + return nil +} + +// CreateResourceRequestMultiError is an error wrapping multiple validation +// errors returned by CreateResourceRequest.ValidateAll() if the designated +// constraints aren't met. +type CreateResourceRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateResourceRequestMultiError) 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 CreateResourceRequestMultiError) AllErrors() []error { return m } + +// CreateResourceRequestValidationError is the validation error returned by +// CreateResourceRequest.Validate if the designated constraints aren't met. +type CreateResourceRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateResourceRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateResourceRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateResourceRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateResourceRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateResourceRequestValidationError) ErrorName() string { + return "CreateResourceRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateResourceRequestValidationError) 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 %sCreateResourceRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateResourceRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateResourceRequestValidationError{} + +// Validate checks the field values on CreateResourceResponse 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 *CreateResourceResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateResourceResponse 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 +// CreateResourceResponseMultiError, or nil if none found. +func (m *CreateResourceResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateResourceResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetResource()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateResourceResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateResourceResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateResourceResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateResourceResponseMultiError(errors) + } + + return nil +} + +// CreateResourceResponseMultiError is an error wrapping multiple validation +// errors returned by CreateResourceResponse.ValidateAll() if the designated +// constraints aren't met. +type CreateResourceResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateResourceResponseMultiError) 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 CreateResourceResponseMultiError) AllErrors() []error { return m } + +// CreateResourceResponseValidationError is the validation error returned by +// CreateResourceResponse.Validate if the designated constraints aren't met. +type CreateResourceResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateResourceResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateResourceResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateResourceResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateResourceResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateResourceResponseValidationError) ErrorName() string { + return "CreateResourceResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateResourceResponseValidationError) 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 %sCreateResourceResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateResourceResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateResourceResponseValidationError{} + +// Validate checks the field values on UpdateResourceRequest 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 *UpdateResourceRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateResourceRequest 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 +// UpdateResourceRequestMultiError, or nil if none found. +func (m *UpdateResourceRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateResourceRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetResource()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateResourceRequestValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateResourceRequestValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateResourceRequestValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateResourceRequestMultiError(errors) + } + + return nil +} + +// UpdateResourceRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateResourceRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateResourceRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateResourceRequestMultiError) 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 UpdateResourceRequestMultiError) AllErrors() []error { return m } + +// UpdateResourceRequestValidationError is the validation error returned by +// UpdateResourceRequest.Validate if the designated constraints aren't met. +type UpdateResourceRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateResourceRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateResourceRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateResourceRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateResourceRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateResourceRequestValidationError) ErrorName() string { + return "UpdateResourceRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateResourceRequestValidationError) 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 %sUpdateResourceRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateResourceRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateResourceRequestValidationError{} + +// Validate checks the field values on UpdateResourceResponse 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 *UpdateResourceResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateResourceResponse 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 +// UpdateResourceResponseMultiError, or nil if none found. +func (m *UpdateResourceResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateResourceResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetResource()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateResourceResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateResourceResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateResourceResponseValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateResourceResponseMultiError(errors) + } + + return nil +} + +// UpdateResourceResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateResourceResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateResourceResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateResourceResponseMultiError) 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 UpdateResourceResponseMultiError) AllErrors() []error { return m } + +// UpdateResourceResponseValidationError is the validation error returned by +// UpdateResourceResponse.Validate if the designated constraints aren't met. +type UpdateResourceResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateResourceResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateResourceResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateResourceResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateResourceResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateResourceResponseValidationError) ErrorName() string { + return "UpdateResourceResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateResourceResponseValidationError) 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 %sUpdateResourceResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateResourceResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateResourceResponseValidationError{} + +// Validate checks the field values on DeleteResourceRequest 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 *DeleteResourceRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteResourceRequest 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 +// DeleteResourceRequestMultiError, or nil if none found. +func (m *DeleteResourceRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteResourceRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeleteResourceRequestMultiError(errors) + } + + return nil +} + +// DeleteResourceRequestMultiError is an error wrapping multiple validation +// errors returned by DeleteResourceRequest.ValidateAll() if the designated +// constraints aren't met. +type DeleteResourceRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteResourceRequestMultiError) 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 DeleteResourceRequestMultiError) AllErrors() []error { return m } + +// DeleteResourceRequestValidationError is the validation error returned by +// DeleteResourceRequest.Validate if the designated constraints aren't met. +type DeleteResourceRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteResourceRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteResourceRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteResourceRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteResourceRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteResourceRequestValidationError) ErrorName() string { + return "DeleteResourceRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteResourceRequestValidationError) 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 %sDeleteResourceRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteResourceRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteResourceRequestValidationError{} + +// Validate checks the field values on DeleteResourceResponse 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 *DeleteResourceResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteResourceResponse 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 +// DeleteResourceResponseMultiError, or nil if none found. +func (m *DeleteResourceResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteResourceResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteResourceResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteResourceResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteResourceResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteResourceResponseMultiError(errors) + } + + return nil +} + +// DeleteResourceResponseMultiError is an error wrapping multiple validation +// errors returned by DeleteResourceResponse.ValidateAll() if the designated +// constraints aren't met. +type DeleteResourceResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteResourceResponseMultiError) 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 DeleteResourceResponseMultiError) AllErrors() []error { return m } + +// DeleteResourceResponseValidationError is the validation error returned by +// DeleteResourceResponse.Validate if the designated constraints aren't met. +type DeleteResourceResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteResourceResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteResourceResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteResourceResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteResourceResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteResourceResponseValidationError) ErrorName() string { + return "DeleteResourceResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteResourceResponseValidationError) 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 %sDeleteResourceResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteResourceResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteResourceResponseValidationError{} diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go new file mode 100644 index 00000000..4b19f3e1 --- /dev/null +++ b/api/v1/services/system/resource_bridge.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/resource.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const ResourceServiceCreateResourceBridgeOperation = "/api.v1.services.system.ResourceService/CreateResource" +const ResourceServiceDeleteResourceBridgeOperation = "/api.v1.services.system.ResourceService/DeleteResource" +const ResourceServiceGetResourceBridgeOperation = "/api.v1.services.system.ResourceService/GetResource" +const ResourceServiceListResourcesBridgeOperation = "/api.v1.services.system.ResourceService/ListResources" +const ResourceServiceUpdateResourceBridgeOperation = "/api.v1.services.system.ResourceService/UpdateResource" + +type ResourceServiceBridgeServer interface { + CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) + DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) + GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) + ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) + UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) +} + +type ResourceServiceHooker interface { + ResourceServiceCreateResourceHooker + ResourceServiceDeleteResourceHooker + ResourceServiceGetResourceHooker + ResourceServiceListResourcesHooker + ResourceServiceUpdateResourceHooker +} + +type ResourceServiceHookedBridger interface { + ResourceServiceHooker + ResourceServiceBridgeServer +} +type ResourceServiceCreateResourceHooker interface { + PrepareCreateResource(http.Context, *CreateResourceRequest) (context.Context, error) + CompleteCreateResource(http.Context, *CreateResourceRequest, *CreateResourceResponse) error +} +type ResourceServiceDeleteResourceHooker interface { + PrepareDeleteResource(http.Context, *DeleteResourceRequest) (context.Context, error) + CompleteDeleteResource(http.Context, *DeleteResourceRequest, *DeleteResourceResponse) error +} +type ResourceServiceGetResourceHooker interface { + PrepareGetResource(http.Context, *GetResourceRequest) (context.Context, error) + CompleteGetResource(http.Context, *GetResourceRequest, *GetResourceResponse) error +} +type ResourceServiceListResourcesHooker interface { + PrepareListResources(http.Context, *ListResourcesRequest) (context.Context, error) + CompleteListResources(http.Context, *ListResourcesRequest, *ListResourcesResponse) error +} +type ResourceServiceUpdateResourceHooker interface { + PrepareUpdateResource(http.Context, *UpdateResourceRequest) (context.Context, error) + CompleteUpdateResource(http.Context, *UpdateResourceRequest, *UpdateResourceResponse) error +} + +func RegisterResourceServiceBridgeServer(s *http.Server, srv ResourceServiceHookedBridger) { + r := s.Route("/") + r.GET("/sys/resources", _ResourceService_ListResources0_Bridge_Handler(srv)) + r.GET("/sys/resources/:id", _ResourceService_GetResource0_Bridge_Handler(srv)) + r.POST("/sys/resources", _ResourceService_CreateResource0_Bridge_Handler(srv)) + r.PUT("/sys/resources/:resource.id", _ResourceService_UpdateResource0_Bridge_Handler(srv)) + r.DELETE("/sys/resources/:id", _ResourceService_DeleteResource0_Bridge_Handler(srv)) +} + +func _ResourceService_ListResources0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceListResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListResources(ctx, req.(*ListResourcesRequest)) + }) + + newctx, err := srv.PrepareListResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListResources(ctx, &in, out.(*ListResourcesResponse)) + } +} + +func _ResourceService_GetResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetResourceRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceGetResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetResource(ctx, req.(*GetResourceRequest)) + }) + + newctx, err := srv.PrepareGetResource(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetResource(ctx, &in, out.(*GetResourceResponse)) + } +} + +func _ResourceService_CreateResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateResourceRequest + if err := ctx.Bind(&in.Resource); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceCreateResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateResource(ctx, req.(*CreateResourceRequest)) + }) + + newctx, err := srv.PrepareCreateResource(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateResource(ctx, &in, out.(*CreateResourceResponse)) + } +} + +func _ResourceService_UpdateResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateResourceRequest + if err := ctx.Bind(&in.Resource); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceUpdateResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateResource(ctx, req.(*UpdateResourceRequest)) + }) + + newctx, err := srv.PrepareUpdateResource(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateResource(ctx, &in, out.(*UpdateResourceResponse)) + } +} + +func _ResourceService_DeleteResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteResourceRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceDeleteResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteResource(ctx, req.(*DeleteResourceRequest)) + }) + + newctx, err := srv.PrepareDeleteResource(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteResource(ctx, &in, out.(*DeleteResourceResponse)) + } +} + +// UnimplementedResourceServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedResourceServiceHooked struct{} + +func (UnimplementedResourceServiceHooked) PrepareCreateResource(ctx http.Context, in *CreateResourceRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedResourceServiceHooked) CompleteCreateResource(ctx http.Context, in *CreateResourceRequest, out *CreateResourceResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedResourceServiceHooked) PrepareDeleteResource(ctx http.Context, in *DeleteResourceRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedResourceServiceHooked) CompleteDeleteResource(ctx http.Context, in *DeleteResourceRequest, out *DeleteResourceResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedResourceServiceHooked) PrepareGetResource(ctx http.Context, in *GetResourceRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedResourceServiceHooked) CompleteGetResource(ctx http.Context, in *GetResourceRequest, out *GetResourceResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedResourceServiceHooked) PrepareListResources(ctx http.Context, in *ListResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedResourceServiceHooked) CompleteListResources(ctx http.Context, in *ListResourcesRequest, out *ListResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedResourceServiceHooked) PrepareUpdateResource(ctx http.Context, in *UpdateResourceRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedResourceServiceHooked) CompleteUpdateResource(ctx http.Context, in *UpdateResourceRequest, out *UpdateResourceResponse) error { + return ctx.Result(200, out) +} + +func WithResourceServiceHook(h ResourceServiceHooker) func(ResourceServiceBridgeServer) ResourceServiceHookedBridger { + return func(srv ResourceServiceBridgeServer) ResourceServiceHookedBridger { + return ResourceServiceHookedBridge{ResourceServiceBridgeServer: srv, ResourceServiceHooker: h} + } +} + +// ResourceServiceHookedBridge is a bridge between the HTTP and gRPC implementations of ResourceService. +// It implements the HTTP and gRPC implementations of ResourceService. +// It forwards requests and responses between the two implementations. +type ResourceServiceHookedBridge struct { + ResourceServiceBridgeServer + ResourceServiceHooker +} + +type ResourceServiceHTTPBridgeImpl struct { + client ResourceServiceHTTPClient +} + +func NewResourceServiceHTTPBridge(client *http.Client) ResourceServiceHTTPServer { + return &ResourceServiceHTTPBridgeImpl{client: NewResourceServiceHTTPClient(client)} +} + +func (c *ResourceServiceHTTPBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) +} + +func (c *ResourceServiceHTTPBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + +func (c *ResourceServiceHTTPBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { + return c.client.GetResource(ctx, in) +} + +func (c *ResourceServiceHTTPBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) +} + +func (c *ResourceServiceHTTPBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { + return c.client.UpdateResource(ctx, in) +} + +type ResourceServiceBridgeImpl struct { + client ResourceServiceClient +} + +func NewResourceServiceBridge(client grpc.ClientConnInterface) ResourceServiceServer { + return &ResourceServiceBridgeImpl{client: NewResourceServiceClient(client)} +} + +func (c *ResourceServiceBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) +} + +func (c *ResourceServiceBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + +func (c *ResourceServiceBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { + return c.client.GetResource(ctx, in) +} + +func (c *ResourceServiceBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) +} + +func (c *ResourceServiceBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { + return c.client.UpdateResource(ctx, in) +} + +func (c *ResourceServiceBridgeImpl) mustEmbedUnimplementedResourceServiceServer() {} + +type ResourceServiceGRPC2HTTPBridgeImpl struct { + client ResourceServiceClient +} + +func NewResourceServiceGRPC2HTTP(client grpc.ClientConnInterface) ResourceServiceHTTPServer { + return &ResourceServiceGRPC2HTTPBridgeImpl{client: NewResourceServiceClient(client)} +} + +func (c *ResourceServiceGRPC2HTTPBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) +} + +func (c *ResourceServiceGRPC2HTTPBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + +func (c *ResourceServiceGRPC2HTTPBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { + return c.client.GetResource(ctx, in) +} + +func (c *ResourceServiceGRPC2HTTPBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) +} + +func (c *ResourceServiceGRPC2HTTPBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { + return c.client.UpdateResource(ctx, in) +} + +type ResourceServiceHTTP2GRPCBridgeImpl struct { + client ResourceServiceHTTPClient +} + +func NewResourceServiceHTTP2GRPC(client *http.Client) ResourceServiceServer { + return &ResourceServiceHTTP2GRPCBridgeImpl{client: NewResourceServiceHTTPClient(client)} +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { + return c.client.GetResource(ctx, in) +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { + return c.client.UpdateResource(ctx, in) +} + +func (c *ResourceServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedResourceServiceServer() {} diff --git a/api/v1/services/system/resource_grpc.pb.go b/api/v1/services/system/resource_grpc.pb.go new file mode 100644 index 00000000..e730965e --- /dev/null +++ b/api/v1/services/system/resource_grpc.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: system/resource.proto + +package system + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + ResourceService_ListResources_FullMethodName = "/api.v1.services.system.ResourceService/ListResources" + ResourceService_GetResource_FullMethodName = "/api.v1.services.system.ResourceService/GetResource" + ResourceService_CreateResource_FullMethodName = "/api.v1.services.system.ResourceService/CreateResource" + ResourceService_UpdateResource_FullMethodName = "/api.v1.services.system.ResourceService/UpdateResource" + ResourceService_DeleteResource_FullMethodName = "/api.v1.services.system.ResourceService/DeleteResource" +) + +// ResourceServiceClient is the client API for ResourceService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The resource service definition. +type ResourceServiceClient interface { + ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error) + GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) + CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error) + UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error) + DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error) +} + +type resourceServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewResourceServiceClient(cc grpc.ClientConnInterface) ResourceServiceClient { + return &resourceServiceClient{cc} +} + +func (c *resourceServiceClient) ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListResourcesResponse) + err := c.cc.Invoke(ctx, ResourceService_ListResources_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *resourceServiceClient) GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetResourceResponse) + err := c.cc.Invoke(ctx, ResourceService_GetResource_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *resourceServiceClient) CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateResourceResponse) + err := c.cc.Invoke(ctx, ResourceService_CreateResource_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *resourceServiceClient) UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateResourceResponse) + err := c.cc.Invoke(ctx, ResourceService_UpdateResource_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *resourceServiceClient) DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteResourceResponse) + err := c.cc.Invoke(ctx, ResourceService_DeleteResource_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ResourceServiceServer is the server API for ResourceService service. +// All implementations must embed UnimplementedResourceServiceServer +// for forward compatibility. +// +// The resource service definition. +type ResourceServiceServer interface { + ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) + GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) + CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) + UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) + DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) + mustEmbedUnimplementedResourceServiceServer() +} + +// UnimplementedResourceServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedResourceServiceServer struct{} + +func (UnimplementedResourceServiceServer) ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListResources not implemented") +} +func (UnimplementedResourceServiceServer) GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetResource not implemented") +} +func (UnimplementedResourceServiceServer) CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateResource not implemented") +} +func (UnimplementedResourceServiceServer) UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateResource not implemented") +} +func (UnimplementedResourceServiceServer) DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteResource not implemented") +} +func (UnimplementedResourceServiceServer) mustEmbedUnimplementedResourceServiceServer() {} +func (UnimplementedResourceServiceServer) testEmbeddedByValue() {} + +// UnsafeResourceServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ResourceServiceServer will +// result in compilation errors. +type UnsafeResourceServiceServer interface { + mustEmbedUnimplementedResourceServiceServer() +} + +func RegisterResourceServiceServer(s grpc.ServiceRegistrar, srv ResourceServiceServer) { + // If the following call pancis, it indicates UnimplementedResourceServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&ResourceService_ServiceDesc, srv) +} + +func _ResourceService_ListResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListResourcesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ResourceServiceServer).ListResources(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ResourceService_ListResources_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ResourceServiceServer).ListResources(ctx, req.(*ListResourcesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ResourceService_GetResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetResourceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ResourceServiceServer).GetResource(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ResourceService_GetResource_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ResourceServiceServer).GetResource(ctx, req.(*GetResourceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ResourceService_CreateResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateResourceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ResourceServiceServer).CreateResource(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ResourceService_CreateResource_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ResourceServiceServer).CreateResource(ctx, req.(*CreateResourceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ResourceService_UpdateResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateResourceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ResourceServiceServer).UpdateResource(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ResourceService_UpdateResource_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ResourceServiceServer).UpdateResource(ctx, req.(*UpdateResourceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ResourceService_DeleteResource_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteResourceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ResourceServiceServer).DeleteResource(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ResourceService_DeleteResource_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ResourceServiceServer).DeleteResource(ctx, req.(*DeleteResourceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ResourceService_ServiceDesc is the grpc.ServiceDesc for ResourceService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ResourceService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.system.ResourceService", + HandlerType: (*ResourceServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListResources", + Handler: _ResourceService_ListResources_Handler, + }, + { + MethodName: "GetResource", + Handler: _ResourceService_GetResource_Handler, + }, + { + MethodName: "CreateResource", + Handler: _ResourceService_CreateResource_Handler, + }, + { + MethodName: "UpdateResource", + Handler: _ResourceService_UpdateResource_Handler, + }, + { + MethodName: "DeleteResource", + Handler: _ResourceService_DeleteResource_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "system/resource.proto", +} diff --git a/api/v1/services/system/resource_http.pb.go b/api/v1/services/system/resource_http.pb.go new file mode 100644 index 00000000..05816b6c --- /dev/null +++ b/api/v1/services/system/resource_http.pb.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: system/resource.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationResourceServiceCreateResource = "/api.v1.services.system.ResourceService/CreateResource" +const OperationResourceServiceDeleteResource = "/api.v1.services.system.ResourceService/DeleteResource" +const OperationResourceServiceGetResource = "/api.v1.services.system.ResourceService/GetResource" +const OperationResourceServiceListResources = "/api.v1.services.system.ResourceService/ListResources" +const OperationResourceServiceUpdateResource = "/api.v1.services.system.ResourceService/UpdateResource" + +type ResourceServiceHTTPServer interface { + CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) + DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) + GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) + ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) + UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) +} + +func RegisterResourceServiceHTTPServer(s *http.Server, srv ResourceServiceHTTPServer) { + r := s.Route("/") + r.GET("/sys/resources", _ResourceService_ListResources0_HTTP_Handler(srv)) + r.GET("/sys/resources/{id}", _ResourceService_GetResource0_HTTP_Handler(srv)) + r.POST("/sys/resources", _ResourceService_CreateResource0_HTTP_Handler(srv)) + r.PUT("/sys/resources/{resource.id}", _ResourceService_UpdateResource0_HTTP_Handler(srv)) + r.DELETE("/sys/resources/{id}", _ResourceService_DeleteResource0_HTTP_Handler(srv)) +} + +func _ResourceService_ListResources0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceListResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListResources(ctx, req.(*ListResourcesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListResourcesResponse) + return ctx.Result(200, reply) + } +} + +func _ResourceService_GetResource0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetResourceRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceGetResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetResource(ctx, req.(*GetResourceRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetResourceResponse) + return ctx.Result(200, reply) + } +} + +func _ResourceService_CreateResource0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateResourceRequest + if err := ctx.Bind(&in.Resource); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceCreateResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateResource(ctx, req.(*CreateResourceRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateResourceResponse) + return ctx.Result(200, reply) + } +} + +func _ResourceService_UpdateResource0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateResourceRequest + if err := ctx.Bind(&in.Resource); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceUpdateResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateResource(ctx, req.(*UpdateResourceRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateResourceResponse) + return ctx.Result(200, reply) + } +} + +func _ResourceService_DeleteResource0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteResourceRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationResourceServiceDeleteResource) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteResource(ctx, req.(*DeleteResourceRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeleteResourceResponse) + return ctx.Result(200, reply) + } +} + +type ResourceServiceHTTPClient interface { + CreateResource(ctx context.Context, req *CreateResourceRequest, opts ...http.CallOption) (rsp *CreateResourceResponse, err error) + DeleteResource(ctx context.Context, req *DeleteResourceRequest, opts ...http.CallOption) (rsp *DeleteResourceResponse, err error) + GetResource(ctx context.Context, req *GetResourceRequest, opts ...http.CallOption) (rsp *GetResourceResponse, err error) + ListResources(ctx context.Context, req *ListResourcesRequest, opts ...http.CallOption) (rsp *ListResourcesResponse, err error) + UpdateResource(ctx context.Context, req *UpdateResourceRequest, opts ...http.CallOption) (rsp *UpdateResourceResponse, err error) +} + +type ResourceServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewResourceServiceHTTPClient(client *http.Client) ResourceServiceHTTPClient { + return &ResourceServiceHTTPClientImpl{client} +} + +func (c *ResourceServiceHTTPClientImpl) CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...http.CallOption) (*CreateResourceResponse, error) { + var out CreateResourceResponse + pattern := "/sys/resources" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationResourceServiceCreateResource)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Resource, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *ResourceServiceHTTPClientImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...http.CallOption) (*DeleteResourceResponse, error) { + var out DeleteResourceResponse + pattern := "/sys/resources/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationResourceServiceDeleteResource)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *ResourceServiceHTTPClientImpl) GetResource(ctx context.Context, in *GetResourceRequest, opts ...http.CallOption) (*GetResourceResponse, error) { + var out GetResourceResponse + pattern := "/sys/resources/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationResourceServiceGetResource)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *ResourceServiceHTTPClientImpl) ListResources(ctx context.Context, in *ListResourcesRequest, opts ...http.CallOption) (*ListResourcesResponse, error) { + var out ListResourcesResponse + pattern := "/sys/resources" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationResourceServiceListResources)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *ResourceServiceHTTPClientImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...http.CallOption) (*UpdateResourceResponse, error) { + var out UpdateResourceResponse + pattern := "/sys/resources/{resource.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationResourceServiceUpdateResource)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Resource, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/system/role.pb.go b/api/v1/services/system/role.pb.go new file mode 100644 index 00000000..9c5c692d --- /dev/null +++ b/api/v1/services/system/role.pb.go @@ -0,0 +1,739 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: system/role.proto + +package system + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListRolesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The page number. + Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // The keyword is the query parameter for set only to query the role by keyword + Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListRolesRequest) Reset() { + *x = ListRolesRequest{} + mi := &file_system_role_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListRolesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRolesRequest) ProtoMessage() {} + +func (x *ListRolesRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_role_proto_msgTypes[0] + 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 ListRolesRequest.ProtoReflect.Descriptor instead. +func (*ListRolesRequest) Descriptor() ([]byte, []int) { + return file_system_role_proto_rawDescGZIP(), []int{0} +} + +func (x *ListRolesRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListRolesRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListRolesRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListRolesRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListRolesRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListRolesRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListRolesRequest) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +type ListRolesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` + // The paging menus + Roles []*types.Role `protobuf:"bytes,2,rep,name=roles,proto3" json:"roles,omitempty"` + // The page number. + Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the page data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListRolesResponse) Reset() { + *x = ListRolesResponse{} + mi := &file_system_role_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListRolesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRolesResponse) ProtoMessage() {} + +func (x *ListRolesResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_role_proto_msgTypes[1] + 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 ListRolesResponse.ProtoReflect.Descriptor instead. +func (*ListRolesResponse) Descriptor() ([]byte, []int) { + return file_system_role_proto_rawDescGZIP(), []int{1} +} + +func (x *ListRolesResponse) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *ListRolesResponse) GetRoles() []*types.Role { + if x != nil { + return x.Roles + } + return nil +} + +func (x *ListRolesResponse) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListRolesResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListRolesResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListRolesResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +type GetRoleRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the resource requested, for example: + // "shelves/shelf1/roles/role2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRoleRequest) Reset() { + *x = GetRoleRequest{} + mi := &file_system_role_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRoleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRoleRequest) ProtoMessage() {} + +func (x *GetRoleRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_role_proto_msgTypes[2] + 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 GetRoleRequest.ProtoReflect.Descriptor instead. +func (*GetRoleRequest) Descriptor() ([]byte, []int) { + return file_system_role_proto_rawDescGZIP(), []int{2} +} + +func (x *GetRoleRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type GetRoleResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetRoleResponse) Reset() { + *x = GetRoleResponse{} + mi := &file_system_role_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetRoleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRoleResponse) ProtoMessage() {} + +func (x *GetRoleResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_role_proto_msgTypes[3] + 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 GetRoleResponse.ProtoReflect.Descriptor instead. +func (*GetRoleResponse) Descriptor() ([]byte, []int) { + return file_system_role_proto_rawDescGZIP(), []int{3} +} + +func (x *GetRoleResponse) GetRole() *types.Role { + if x != nil { + return x.Role + } + return nil +} + +type CreateRoleRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id where the role is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The role id to use for this role. + RoleId string `protobuf:"bytes,3,opt,name=role_id,proto3" json:"role_id,omitempty"` + // The role resource to create. + // The field id should match the Noun in the method id. + Role *types.Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateRoleRequest) Reset() { + *x = CreateRoleRequest{} + mi := &file_system_role_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateRoleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateRoleRequest) ProtoMessage() {} + +func (x *CreateRoleRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_role_proto_msgTypes[4] + 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 CreateRoleRequest.ProtoReflect.Descriptor instead. +func (*CreateRoleRequest) Descriptor() ([]byte, []int) { + return file_system_role_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateRoleRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateRoleRequest) GetRoleId() string { + if x != nil { + return x.RoleId + } + return "" +} + +func (x *CreateRoleRequest) GetRole() *types.Role { + if x != nil { + return x.Role + } + return nil +} + +type CreateRoleResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateRoleResponse) Reset() { + *x = CreateRoleResponse{} + mi := &file_system_role_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateRoleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateRoleResponse) ProtoMessage() {} + +func (x *CreateRoleResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_role_proto_msgTypes[5] + 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 CreateRoleResponse.ProtoReflect.Descriptor instead. +func (*CreateRoleResponse) Descriptor() ([]byte, []int) { + return file_system_role_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateRoleResponse) GetRole() *types.Role { + if x != nil { + return x.Role + } + return nil +} + +type UpdateRoleRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The id of the role resource to update. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The role resource which replaces the resource on the server. + Role *types.Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateRoleRequest) Reset() { + *x = UpdateRoleRequest{} + mi := &file_system_role_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateRoleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateRoleRequest) ProtoMessage() {} + +func (x *UpdateRoleRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_role_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 UpdateRoleRequest.ProtoReflect.Descriptor instead. +func (*UpdateRoleRequest) Descriptor() ([]byte, []int) { + return file_system_role_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateRoleRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateRoleRequest) GetRole() *types.Role { + if x != nil { + return x.Role + } + return nil +} + +type UpdateRoleResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateRoleResponse) Reset() { + *x = UpdateRoleResponse{} + mi := &file_system_role_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateRoleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateRoleResponse) ProtoMessage() {} + +func (x *UpdateRoleResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_role_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateRoleResponse.ProtoReflect.Descriptor instead. +func (*UpdateRoleResponse) Descriptor() ([]byte, []int) { + return file_system_role_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateRoleResponse) GetRole() *types.Role { + if x != nil { + return x.Role + } + return nil +} + +type DeleteRoleRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The resource id of the role to be deleted, for example: + // "shelves/shelf1/roles/role2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteRoleRequest) Reset() { + *x = DeleteRoleRequest{} + mi := &file_system_role_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteRoleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRoleRequest) ProtoMessage() {} + +func (x *DeleteRoleRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_role_proto_msgTypes[8] + 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 DeleteRoleRequest.ProtoReflect.Descriptor instead. +func (*DeleteRoleRequest) Descriptor() ([]byte, []int) { + return file_system_role_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteRoleRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type DeleteRoleResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteRoleResponse) Reset() { + *x = DeleteRoleResponse{} + mi := &file_system_role_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteRoleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteRoleResponse) ProtoMessage() {} + +func (x *DeleteRoleResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_role_proto_msgTypes[9] + 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 DeleteRoleResponse.ProtoReflect.Descriptor instead. +func (*DeleteRoleResponse) Descriptor() ([]byte, []int) { + return file_system_role_proto_rawDescGZIP(), []int{9} +} + +func (x *DeleteRoleResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_system_role_proto protoreflect.FileDescriptor + +const file_system_role_proto_rawDesc = "" + + "\n" + + "\x11system/role.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xcc\x01\n" + + "\x10ListRolesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x18\n" + + "\akeyword\x18\a \x01(\tR\akeyword\"\xf3\x01\n" + + "\x11ListRolesResponse\x12\x14\n" + + "\x05total\x18\x01 \x01(\x05R\x05total\x121\n" + + "\x05roles\x18\x02 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x12\n" + + "\x04page\x18\x03 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\" \n" + + "\x0eGetRoleRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x0fGetRoleResponse\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"v\n" + + "\x11CreateRoleRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x18\n" + + "\arole_id\x18\x03 \x01(\tR\arole_id\x12/\n" + + "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"E\n" + + "\x12CreateRoleResponse\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"T\n" + + "\x11UpdateRoleRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12/\n" + + "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"E\n" + + "\x12UpdateRoleResponse\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"#\n" + + "\x11DeleteRoleRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x12DeleteRoleResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xff\x04\n" + + "\vRoleService\x12t\n" + + "\tListRoles\x12(.api.v1.services.system.ListRolesRequest\x1a).api.v1.services.system.ListRolesResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + + "/sys/roles\x12s\n" + + "\aGetRole\x12&.api.v1.services.system.GetRoleRequest\x1a'.api.v1.services.system.GetRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/roles/{id}\x12}\n" + + "\n" + + "CreateRole\x12).api.v1.services.system.CreateRoleRequest\x1a*.api.v1.services.system.CreateRoleResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04role\"\n" + + "/sys/roles\x12\x87\x01\n" + + "\n" + + "UpdateRole\x12).api.v1.services.system.UpdateRoleRequest\x1a*.api.v1.services.system.UpdateRoleResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04role\x1a\x14/sys/roles/{role.id}\x12|\n" + + "\n" + + "DeleteRole\x12).api.v1.services.system.DeleteRoleRequest\x1a*.api.v1.services.system.DeleteRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/roles/{id}B\xde\x01\n" + + "\x1acom.api.v1.services.systemB\tRoleProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + +var ( + file_system_role_proto_rawDescOnce sync.Once + file_system_role_proto_rawDescData []byte +) + +func file_system_role_proto_rawDescGZIP() []byte { + file_system_role_proto_rawDescOnce.Do(func() { + file_system_role_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_role_proto_rawDesc), len(file_system_role_proto_rawDesc))) + }) + return file_system_role_proto_rawDescData +} + +var file_system_role_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_system_role_proto_goTypes = []any{ + (*ListRolesRequest)(nil), // 0: api.v1.services.system.ListRolesRequest + (*ListRolesResponse)(nil), // 1: api.v1.services.system.ListRolesResponse + (*GetRoleRequest)(nil), // 2: api.v1.services.system.GetRoleRequest + (*GetRoleResponse)(nil), // 3: api.v1.services.system.GetRoleResponse + (*CreateRoleRequest)(nil), // 4: api.v1.services.system.CreateRoleRequest + (*CreateRoleResponse)(nil), // 5: api.v1.services.system.CreateRoleResponse + (*UpdateRoleRequest)(nil), // 6: api.v1.services.system.UpdateRoleRequest + (*UpdateRoleResponse)(nil), // 7: api.v1.services.system.UpdateRoleResponse + (*DeleteRoleRequest)(nil), // 8: api.v1.services.system.DeleteRoleRequest + (*DeleteRoleResponse)(nil), // 9: api.v1.services.system.DeleteRoleResponse + (*types.Role)(nil), // 10: api.v1.services.types.Role + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_system_role_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.system.ListRolesResponse.roles:type_name -> api.v1.services.types.Role + 11, // 1: api.v1.services.system.ListRolesResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.system.GetRoleResponse.role:type_name -> api.v1.services.types.Role + 10, // 3: api.v1.services.system.CreateRoleRequest.role:type_name -> api.v1.services.types.Role + 10, // 4: api.v1.services.system.CreateRoleResponse.role:type_name -> api.v1.services.types.Role + 10, // 5: api.v1.services.system.UpdateRoleRequest.role:type_name -> api.v1.services.types.Role + 10, // 6: api.v1.services.system.UpdateRoleResponse.role:type_name -> api.v1.services.types.Role + 12, // 7: api.v1.services.system.DeleteRoleResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.system.RoleService.ListRoles:input_type -> api.v1.services.system.ListRolesRequest + 2, // 9: api.v1.services.system.RoleService.GetRole:input_type -> api.v1.services.system.GetRoleRequest + 4, // 10: api.v1.services.system.RoleService.CreateRole:input_type -> api.v1.services.system.CreateRoleRequest + 6, // 11: api.v1.services.system.RoleService.UpdateRole:input_type -> api.v1.services.system.UpdateRoleRequest + 8, // 12: api.v1.services.system.RoleService.DeleteRole:input_type -> api.v1.services.system.DeleteRoleRequest + 1, // 13: api.v1.services.system.RoleService.ListRoles:output_type -> api.v1.services.system.ListRolesResponse + 3, // 14: api.v1.services.system.RoleService.GetRole:output_type -> api.v1.services.system.GetRoleResponse + 5, // 15: api.v1.services.system.RoleService.CreateRole:output_type -> api.v1.services.system.CreateRoleResponse + 7, // 16: api.v1.services.system.RoleService.UpdateRole:output_type -> api.v1.services.system.UpdateRoleResponse + 9, // 17: api.v1.services.system.RoleService.DeleteRole:output_type -> api.v1.services.system.DeleteRoleResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_system_role_proto_init() } +func file_system_role_proto_init() { + if File_system_role_proto != nil { + return + } + file_system_role_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_role_proto_rawDesc), len(file_system_role_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_system_role_proto_goTypes, + DependencyIndexes: file_system_role_proto_depIdxs, + MessageInfos: file_system_role_proto_msgTypes, + }.Build() + File_system_role_proto = out.File + file_system_role_proto_goTypes = nil + file_system_role_proto_depIdxs = nil +} diff --git a/api/v1/services/system/role.pb.gw.go b/api/v1/services/system/role.pb.gw.go new file mode 100644 index 00000000..7f3f6e9a --- /dev/null +++ b/api/v1/services/system/role.pb.gw.go @@ -0,0 +1,487 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: system/role.proto + +/* +Package system is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package system + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_RoleService_ListRoles_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_RoleService_ListRoles_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListRolesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_ListRoles_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_RoleService_ListRoles_0(ctx context.Context, marshaler runtime.Marshaler, server RoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListRolesRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_ListRoles_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListRoles(ctx, &protoReq) + return msg, metadata, err +} + +func request_RoleService_GetRole_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetRoleRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_RoleService_GetRole_0(ctx context.Context, marshaler runtime.Marshaler, server RoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetRoleRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetRole(ctx, &protoReq) + return msg, metadata, err +} + +var filter_RoleService_CreateRole_0 = &utilities.DoubleArray{Encoding: map[string]int{"role": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_RoleService_CreateRole_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateRoleRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_CreateRole_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_RoleService_CreateRole_0(ctx context.Context, marshaler runtime.Marshaler, server RoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateRoleRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_CreateRole_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateRole(ctx, &protoReq) + return msg, metadata, err +} + +var filter_RoleService_UpdateRole_0 = &utilities.DoubleArray{Encoding: map[string]int{"role": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_RoleService_UpdateRole_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateRoleRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["role.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "role.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "role.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_UpdateRole_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_RoleService_UpdateRole_0(ctx context.Context, marshaler runtime.Marshaler, server RoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateRoleRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["role.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "role.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "role.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_UpdateRole_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateRole(ctx, &protoReq) + return msg, metadata, err +} + +func request_RoleService_DeleteRole_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteRoleRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_RoleService_DeleteRole_0(ctx context.Context, marshaler runtime.Marshaler, server RoleServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteRoleRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteRole(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterRoleServiceHandlerServer registers the http handlers for service RoleService to "mux". +// UnaryRPC :call RoleServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterRoleServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterRoleServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RoleServiceServer) error { + mux.Handle(http.MethodGet, pattern_RoleService_ListRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.RoleService/ListRoles", runtime.WithHTTPPathPattern("/sys/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_RoleService_ListRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_RoleService_ListRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_RoleService_GetRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.RoleService/GetRole", runtime.WithHTTPPathPattern("/sys/roles/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_RoleService_GetRole_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_RoleService_GetRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_RoleService_CreateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.RoleService/CreateRole", runtime.WithHTTPPathPattern("/sys/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_RoleService_CreateRole_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_RoleService_CreateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_RoleService_UpdateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.RoleService/UpdateRole", runtime.WithHTTPPathPattern("/sys/roles/{role.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_RoleService_UpdateRole_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_RoleService_UpdateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_RoleService_DeleteRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.RoleService/DeleteRole", runtime.WithHTTPPathPattern("/sys/roles/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_RoleService_DeleteRole_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_RoleService_DeleteRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterRoleServiceHandlerFromEndpoint is same as RegisterRoleServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterRoleServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterRoleServiceHandler(ctx, mux, conn) +} + +// RegisterRoleServiceHandler registers the http handlers for service RoleService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterRoleServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterRoleServiceHandlerClient(ctx, mux, NewRoleServiceClient(conn)) +} + +// RegisterRoleServiceHandlerClient registers the http handlers for service RoleService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "RoleServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "RoleServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "RoleServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterRoleServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RoleServiceClient) error { + mux.Handle(http.MethodGet, pattern_RoleService_ListRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.RoleService/ListRoles", runtime.WithHTTPPathPattern("/sys/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_RoleService_ListRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_RoleService_ListRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_RoleService_GetRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.RoleService/GetRole", runtime.WithHTTPPathPattern("/sys/roles/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_RoleService_GetRole_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_RoleService_GetRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_RoleService_CreateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.RoleService/CreateRole", runtime.WithHTTPPathPattern("/sys/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_RoleService_CreateRole_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_RoleService_CreateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_RoleService_UpdateRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.RoleService/UpdateRole", runtime.WithHTTPPathPattern("/sys/roles/{role.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_RoleService_UpdateRole_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_RoleService_UpdateRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_RoleService_DeleteRole_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.RoleService/DeleteRole", runtime.WithHTTPPathPattern("/sys/roles/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_RoleService_DeleteRole_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_RoleService_DeleteRole_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_RoleService_ListRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "roles"}, "")) + pattern_RoleService_GetRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "roles", "id"}, "")) + pattern_RoleService_CreateRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "roles"}, "")) + pattern_RoleService_UpdateRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "roles", "role.id"}, "")) + pattern_RoleService_DeleteRole_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "roles", "id"}, "")) +) + +var ( + forward_RoleService_ListRoles_0 = runtime.ForwardResponseMessage + forward_RoleService_GetRole_0 = runtime.ForwardResponseMessage + forward_RoleService_CreateRole_0 = runtime.ForwardResponseMessage + forward_RoleService_UpdateRole_0 = runtime.ForwardResponseMessage + forward_RoleService_DeleteRole_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/system/role.pb.validate.go b/api/v1/services/system/role.pb.validate.go new file mode 100644 index 00000000..a84bbc69 --- /dev/null +++ b/api/v1/services/system/role.pb.validate.go @@ -0,0 +1,1323 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: system/role.proto + +package system + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListRolesRequest 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 *ListRolesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListRolesRequest 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 +// ListRolesRequestMultiError, or nil if none found. +func (m *ListRolesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListRolesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Keyword + + if len(errors) > 0 { + return ListRolesRequestMultiError(errors) + } + + return nil +} + +// ListRolesRequestMultiError is an error wrapping multiple validation errors +// returned by ListRolesRequest.ValidateAll() if the designated constraints +// aren't met. +type ListRolesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListRolesRequestMultiError) 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 ListRolesRequestMultiError) AllErrors() []error { return m } + +// ListRolesRequestValidationError is the validation error returned by +// ListRolesRequest.Validate if the designated constraints aren't met. +type ListRolesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListRolesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListRolesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListRolesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListRolesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListRolesRequestValidationError) ErrorName() string { return "ListRolesRequestValidationError" } + +// Error satisfies the builtin error interface +func (e ListRolesRequestValidationError) 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 %sListRolesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListRolesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListRolesRequestValidationError{} + +// Validate checks the field values on ListRolesResponse 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 *ListRolesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListRolesResponse 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 +// ListRolesResponseMultiError, or nil if none found. +func (m *ListRolesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListRolesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Total + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListRolesResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListRolesResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListRolesResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListRolesResponseMultiError(errors) + } + + return nil +} + +// ListRolesResponseMultiError is an error wrapping multiple validation errors +// returned by ListRolesResponse.ValidateAll() if the designated constraints +// aren't met. +type ListRolesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListRolesResponseMultiError) 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 ListRolesResponseMultiError) AllErrors() []error { return m } + +// ListRolesResponseValidationError is the validation error returned by +// ListRolesResponse.Validate if the designated constraints aren't met. +type ListRolesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListRolesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListRolesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListRolesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListRolesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListRolesResponseValidationError) ErrorName() string { + return "ListRolesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListRolesResponseValidationError) 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 %sListRolesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListRolesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListRolesResponseValidationError{} + +// Validate checks the field values on GetRoleRequest 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 *GetRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetRoleRequest 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 GetRoleRequestMultiError, +// or nil if none found. +func (m *GetRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetRoleRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetRoleRequestMultiError(errors) + } + + return nil +} + +// GetRoleRequestMultiError is an error wrapping multiple validation errors +// returned by GetRoleRequest.ValidateAll() if the designated constraints +// aren't met. +type GetRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetRoleRequestMultiError) 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 GetRoleRequestMultiError) AllErrors() []error { return m } + +// GetRoleRequestValidationError is the validation error returned by +// GetRoleRequest.Validate if the designated constraints aren't met. +type GetRoleRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetRoleRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetRoleRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetRoleRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetRoleRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetRoleRequestValidationError) ErrorName() string { return "GetRoleRequestValidationError" } + +// Error satisfies the builtin error interface +func (e GetRoleRequestValidationError) 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 %sGetRoleRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetRoleRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetRoleRequestValidationError{} + +// Validate checks the field values on GetRoleResponse 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 *GetRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetRoleResponse 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 +// GetRoleResponseMultiError, or nil if none found. +func (m *GetRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetRoleResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetRoleResponseMultiError(errors) + } + + return nil +} + +// GetRoleResponseMultiError is an error wrapping multiple validation errors +// returned by GetRoleResponse.ValidateAll() if the designated constraints +// aren't met. +type GetRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetRoleResponseMultiError) 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 GetRoleResponseMultiError) AllErrors() []error { return m } + +// GetRoleResponseValidationError is the validation error returned by +// GetRoleResponse.Validate if the designated constraints aren't met. +type GetRoleResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetRoleResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetRoleResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetRoleResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetRoleResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetRoleResponseValidationError) ErrorName() string { return "GetRoleResponseValidationError" } + +// Error satisfies the builtin error interface +func (e GetRoleResponseValidationError) 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 %sGetRoleResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetRoleResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetRoleResponseValidationError{} + +// Validate checks the field values on CreateRoleRequest 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 *CreateRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateRoleRequest 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 +// CreateRoleRequestMultiError, or nil if none found. +func (m *CreateRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateRoleRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for RoleId + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateRoleRequestMultiError(errors) + } + + return nil +} + +// CreateRoleRequestMultiError is an error wrapping multiple validation errors +// returned by CreateRoleRequest.ValidateAll() if the designated constraints +// aren't met. +type CreateRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateRoleRequestMultiError) 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 CreateRoleRequestMultiError) AllErrors() []error { return m } + +// CreateRoleRequestValidationError is the validation error returned by +// CreateRoleRequest.Validate if the designated constraints aren't met. +type CreateRoleRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateRoleRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateRoleRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateRoleRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateRoleRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateRoleRequestValidationError) ErrorName() string { + return "CreateRoleRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateRoleRequestValidationError) 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 %sCreateRoleRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateRoleRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateRoleRequestValidationError{} + +// Validate checks the field values on CreateRoleResponse 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 *CreateRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateRoleResponse 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 +// CreateRoleResponseMultiError, or nil if none found. +func (m *CreateRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateRoleResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateRoleResponseMultiError(errors) + } + + return nil +} + +// CreateRoleResponseMultiError is an error wrapping multiple validation errors +// returned by CreateRoleResponse.ValidateAll() if the designated constraints +// aren't met. +type CreateRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateRoleResponseMultiError) 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 CreateRoleResponseMultiError) AllErrors() []error { return m } + +// CreateRoleResponseValidationError is the validation error returned by +// CreateRoleResponse.Validate if the designated constraints aren't met. +type CreateRoleResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateRoleResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateRoleResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateRoleResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateRoleResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateRoleResponseValidationError) ErrorName() string { + return "CreateRoleResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateRoleResponseValidationError) 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 %sCreateRoleResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateRoleResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateRoleResponseValidationError{} + +// Validate checks the field values on UpdateRoleRequest 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 *UpdateRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateRoleRequest 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 +// UpdateRoleRequestMultiError, or nil if none found. +func (m *UpdateRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateRoleRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateRoleRequestValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateRoleRequestMultiError(errors) + } + + return nil +} + +// UpdateRoleRequestMultiError is an error wrapping multiple validation errors +// returned by UpdateRoleRequest.ValidateAll() if the designated constraints +// aren't met. +type UpdateRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateRoleRequestMultiError) 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 UpdateRoleRequestMultiError) AllErrors() []error { return m } + +// UpdateRoleRequestValidationError is the validation error returned by +// UpdateRoleRequest.Validate if the designated constraints aren't met. +type UpdateRoleRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateRoleRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateRoleRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateRoleRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateRoleRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateRoleRequestValidationError) ErrorName() string { + return "UpdateRoleRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateRoleRequestValidationError) 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 %sUpdateRoleRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateRoleRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateRoleRequestValidationError{} + +// Validate checks the field values on UpdateRoleResponse 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 *UpdateRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateRoleResponse 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 +// UpdateRoleResponseMultiError, or nil if none found. +func (m *UpdateRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateRoleResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateRoleResponseValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateRoleResponseMultiError(errors) + } + + return nil +} + +// UpdateRoleResponseMultiError is an error wrapping multiple validation errors +// returned by UpdateRoleResponse.ValidateAll() if the designated constraints +// aren't met. +type UpdateRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateRoleResponseMultiError) 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 UpdateRoleResponseMultiError) AllErrors() []error { return m } + +// UpdateRoleResponseValidationError is the validation error returned by +// UpdateRoleResponse.Validate if the designated constraints aren't met. +type UpdateRoleResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateRoleResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateRoleResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateRoleResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateRoleResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateRoleResponseValidationError) ErrorName() string { + return "UpdateRoleResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateRoleResponseValidationError) 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 %sUpdateRoleResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateRoleResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateRoleResponseValidationError{} + +// Validate checks the field values on DeleteRoleRequest 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 *DeleteRoleRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteRoleRequest 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 +// DeleteRoleRequestMultiError, or nil if none found. +func (m *DeleteRoleRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteRoleRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeleteRoleRequestMultiError(errors) + } + + return nil +} + +// DeleteRoleRequestMultiError is an error wrapping multiple validation errors +// returned by DeleteRoleRequest.ValidateAll() if the designated constraints +// aren't met. +type DeleteRoleRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteRoleRequestMultiError) 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 DeleteRoleRequestMultiError) AllErrors() []error { return m } + +// DeleteRoleRequestValidationError is the validation error returned by +// DeleteRoleRequest.Validate if the designated constraints aren't met. +type DeleteRoleRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteRoleRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteRoleRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteRoleRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteRoleRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteRoleRequestValidationError) ErrorName() string { + return "DeleteRoleRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteRoleRequestValidationError) 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 %sDeleteRoleRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteRoleRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteRoleRequestValidationError{} + +// Validate checks the field values on DeleteRoleResponse 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 *DeleteRoleResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteRoleResponse 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 +// DeleteRoleResponseMultiError, or nil if none found. +func (m *DeleteRoleResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteRoleResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteRoleResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteRoleResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteRoleResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteRoleResponseMultiError(errors) + } + + return nil +} + +// DeleteRoleResponseMultiError is an error wrapping multiple validation errors +// returned by DeleteRoleResponse.ValidateAll() if the designated constraints +// aren't met. +type DeleteRoleResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteRoleResponseMultiError) 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 DeleteRoleResponseMultiError) AllErrors() []error { return m } + +// DeleteRoleResponseValidationError is the validation error returned by +// DeleteRoleResponse.Validate if the designated constraints aren't met. +type DeleteRoleResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteRoleResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteRoleResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteRoleResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteRoleResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteRoleResponseValidationError) ErrorName() string { + return "DeleteRoleResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteRoleResponseValidationError) 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 %sDeleteRoleResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteRoleResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteRoleResponseValidationError{} diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go new file mode 100644 index 00000000..bb313daf --- /dev/null +++ b/api/v1/services/system/role_bridge.pb.go @@ -0,0 +1,392 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/role.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const RoleServiceCreateRoleBridgeOperation = "/api.v1.services.system.RoleService/CreateRole" +const RoleServiceDeleteRoleBridgeOperation = "/api.v1.services.system.RoleService/DeleteRole" +const RoleServiceGetRoleBridgeOperation = "/api.v1.services.system.RoleService/GetRole" +const RoleServiceListRolesBridgeOperation = "/api.v1.services.system.RoleService/ListRoles" +const RoleServiceUpdateRoleBridgeOperation = "/api.v1.services.system.RoleService/UpdateRole" + +type RoleServiceBridgeServer interface { + CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) + DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) + GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) + ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) + UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) +} + +type RoleServiceHooker interface { + RoleServiceCreateRoleHooker + RoleServiceDeleteRoleHooker + RoleServiceGetRoleHooker + RoleServiceListRolesHooker + RoleServiceUpdateRoleHooker +} + +type RoleServiceHookedBridger interface { + RoleServiceHooker + RoleServiceBridgeServer +} +type RoleServiceCreateRoleHooker interface { + PrepareCreateRole(http.Context, *CreateRoleRequest) (context.Context, error) + CompleteCreateRole(http.Context, *CreateRoleRequest, *CreateRoleResponse) error +} +type RoleServiceDeleteRoleHooker interface { + PrepareDeleteRole(http.Context, *DeleteRoleRequest) (context.Context, error) + CompleteDeleteRole(http.Context, *DeleteRoleRequest, *DeleteRoleResponse) error +} +type RoleServiceGetRoleHooker interface { + PrepareGetRole(http.Context, *GetRoleRequest) (context.Context, error) + CompleteGetRole(http.Context, *GetRoleRequest, *GetRoleResponse) error +} +type RoleServiceListRolesHooker interface { + PrepareListRoles(http.Context, *ListRolesRequest) (context.Context, error) + CompleteListRoles(http.Context, *ListRolesRequest, *ListRolesResponse) error +} +type RoleServiceUpdateRoleHooker interface { + PrepareUpdateRole(http.Context, *UpdateRoleRequest) (context.Context, error) + CompleteUpdateRole(http.Context, *UpdateRoleRequest, *UpdateRoleResponse) error +} + +func RegisterRoleServiceBridgeServer(s *http.Server, srv RoleServiceHookedBridger) { + r := s.Route("/") + r.GET("/sys/roles", _RoleService_ListRoles0_Bridge_Handler(srv)) + r.GET("/sys/roles/:id", _RoleService_GetRole0_Bridge_Handler(srv)) + r.POST("/sys/roles", _RoleService_CreateRole0_Bridge_Handler(srv)) + r.PUT("/sys/roles/:role.id", _RoleService_UpdateRole0_Bridge_Handler(srv)) + r.DELETE("/sys/roles/:id", _RoleService_DeleteRole0_Bridge_Handler(srv)) +} + +func _RoleService_ListRoles0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceListRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListRoles(ctx, req.(*ListRolesRequest)) + }) + + newctx, err := srv.PrepareListRoles(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListRoles(ctx, &in, out.(*ListRolesResponse)) + } +} + +func _RoleService_GetRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetRoleRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceGetRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetRole(ctx, req.(*GetRoleRequest)) + }) + + newctx, err := srv.PrepareGetRole(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetRole(ctx, &in, out.(*GetRoleResponse)) + } +} + +func _RoleService_CreateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateRoleRequest + if err := ctx.Bind(&in.Role); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceCreateRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateRole(ctx, req.(*CreateRoleRequest)) + }) + + newctx, err := srv.PrepareCreateRole(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateRole(ctx, &in, out.(*CreateRoleResponse)) + } +} + +func _RoleService_UpdateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateRoleRequest + if err := ctx.Bind(&in.Role); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceUpdateRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateRole(ctx, req.(*UpdateRoleRequest)) + }) + + newctx, err := srv.PrepareUpdateRole(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateRole(ctx, &in, out.(*UpdateRoleResponse)) + } +} + +func _RoleService_DeleteRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteRoleRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceDeleteRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteRole(ctx, req.(*DeleteRoleRequest)) + }) + + newctx, err := srv.PrepareDeleteRole(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteRole(ctx, &in, out.(*DeleteRoleResponse)) + } +} + +// UnimplementedRoleServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedRoleServiceHooked struct{} + +func (UnimplementedRoleServiceHooked) PrepareCreateRole(ctx http.Context, in *CreateRoleRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedRoleServiceHooked) CompleteCreateRole(ctx http.Context, in *CreateRoleRequest, out *CreateRoleResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedRoleServiceHooked) PrepareDeleteRole(ctx http.Context, in *DeleteRoleRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedRoleServiceHooked) CompleteDeleteRole(ctx http.Context, in *DeleteRoleRequest, out *DeleteRoleResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedRoleServiceHooked) PrepareGetRole(ctx http.Context, in *GetRoleRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedRoleServiceHooked) CompleteGetRole(ctx http.Context, in *GetRoleRequest, out *GetRoleResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedRoleServiceHooked) PrepareListRoles(ctx http.Context, in *ListRolesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedRoleServiceHooked) CompleteListRoles(ctx http.Context, in *ListRolesRequest, out *ListRolesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedRoleServiceHooked) PrepareUpdateRole(ctx http.Context, in *UpdateRoleRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedRoleServiceHooked) CompleteUpdateRole(ctx http.Context, in *UpdateRoleRequest, out *UpdateRoleResponse) error { + return ctx.Result(200, out) +} + +func WithRoleServiceHook(h RoleServiceHooker) func(RoleServiceBridgeServer) RoleServiceHookedBridger { + return func(srv RoleServiceBridgeServer) RoleServiceHookedBridger { + return RoleServiceHookedBridge{RoleServiceBridgeServer: srv, RoleServiceHooker: h} + } +} + +// RoleServiceHookedBridge is a bridge between the HTTP and gRPC implementations of RoleService. +// It implements the HTTP and gRPC implementations of RoleService. +// It forwards requests and responses between the two implementations. +type RoleServiceHookedBridge struct { + RoleServiceBridgeServer + RoleServiceHooker +} + +type RoleServiceHTTPBridgeImpl struct { + client RoleServiceHTTPClient +} + +func NewRoleServiceHTTPBridge(client *http.Client) RoleServiceHTTPServer { + return &RoleServiceHTTPBridgeImpl{client: NewRoleServiceHTTPClient(client)} +} + +func (c *RoleServiceHTTPBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) +} + +func (c *RoleServiceHTTPBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + +func (c *RoleServiceHTTPBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { + return c.client.GetRole(ctx, in) +} + +func (c *RoleServiceHTTPBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) +} + +func (c *RoleServiceHTTPBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { + return c.client.UpdateRole(ctx, in) +} + +type RoleServiceBridgeImpl struct { + client RoleServiceClient +} + +func NewRoleServiceBridge(client grpc.ClientConnInterface) RoleServiceServer { + return &RoleServiceBridgeImpl{client: NewRoleServiceClient(client)} +} + +func (c *RoleServiceBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) +} + +func (c *RoleServiceBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + +func (c *RoleServiceBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { + return c.client.GetRole(ctx, in) +} + +func (c *RoleServiceBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) +} + +func (c *RoleServiceBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { + return c.client.UpdateRole(ctx, in) +} + +func (c *RoleServiceBridgeImpl) mustEmbedUnimplementedRoleServiceServer() {} + +type RoleServiceGRPC2HTTPBridgeImpl struct { + client RoleServiceClient +} + +func NewRoleServiceGRPC2HTTP(client grpc.ClientConnInterface) RoleServiceHTTPServer { + return &RoleServiceGRPC2HTTPBridgeImpl{client: NewRoleServiceClient(client)} +} + +func (c *RoleServiceGRPC2HTTPBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) +} + +func (c *RoleServiceGRPC2HTTPBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + +func (c *RoleServiceGRPC2HTTPBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { + return c.client.GetRole(ctx, in) +} + +func (c *RoleServiceGRPC2HTTPBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) +} + +func (c *RoleServiceGRPC2HTTPBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { + return c.client.UpdateRole(ctx, in) +} + +type RoleServiceHTTP2GRPCBridgeImpl struct { + client RoleServiceHTTPClient +} + +func NewRoleServiceHTTP2GRPC(client *http.Client) RoleServiceServer { + return &RoleServiceHTTP2GRPCBridgeImpl{client: NewRoleServiceHTTPClient(client)} +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { + return c.client.GetRole(ctx, in) +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { + return c.client.UpdateRole(ctx, in) +} + +func (c *RoleServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedRoleServiceServer() {} diff --git a/api/v1/services/system/role_grpc.pb.go b/api/v1/services/system/role_grpc.pb.go new file mode 100644 index 00000000..fc8b02e9 --- /dev/null +++ b/api/v1/services/system/role_grpc.pb.go @@ -0,0 +1,277 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: system/role.proto + +package system + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + RoleService_ListRoles_FullMethodName = "/api.v1.services.system.RoleService/ListRoles" + RoleService_GetRole_FullMethodName = "/api.v1.services.system.RoleService/GetRole" + RoleService_CreateRole_FullMethodName = "/api.v1.services.system.RoleService/CreateRole" + RoleService_UpdateRole_FullMethodName = "/api.v1.services.system.RoleService/UpdateRole" + RoleService_DeleteRole_FullMethodName = "/api.v1.services.system.RoleService/DeleteRole" +) + +// RoleServiceClient is the client API for RoleService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The login service definition. +type RoleServiceClient interface { + ListRoles(ctx context.Context, in *ListRolesRequest, opts ...grpc.CallOption) (*ListRolesResponse, error) + GetRole(ctx context.Context, in *GetRoleRequest, opts ...grpc.CallOption) (*GetRoleResponse, error) + CreateRole(ctx context.Context, in *CreateRoleRequest, opts ...grpc.CallOption) (*CreateRoleResponse, error) + UpdateRole(ctx context.Context, in *UpdateRoleRequest, opts ...grpc.CallOption) (*UpdateRoleResponse, error) + DeleteRole(ctx context.Context, in *DeleteRoleRequest, opts ...grpc.CallOption) (*DeleteRoleResponse, error) +} + +type roleServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewRoleServiceClient(cc grpc.ClientConnInterface) RoleServiceClient { + return &roleServiceClient{cc} +} + +func (c *roleServiceClient) ListRoles(ctx context.Context, in *ListRolesRequest, opts ...grpc.CallOption) (*ListRolesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListRolesResponse) + err := c.cc.Invoke(ctx, RoleService_ListRoles_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *roleServiceClient) GetRole(ctx context.Context, in *GetRoleRequest, opts ...grpc.CallOption) (*GetRoleResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetRoleResponse) + err := c.cc.Invoke(ctx, RoleService_GetRole_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *roleServiceClient) CreateRole(ctx context.Context, in *CreateRoleRequest, opts ...grpc.CallOption) (*CreateRoleResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateRoleResponse) + err := c.cc.Invoke(ctx, RoleService_CreateRole_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *roleServiceClient) UpdateRole(ctx context.Context, in *UpdateRoleRequest, opts ...grpc.CallOption) (*UpdateRoleResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateRoleResponse) + err := c.cc.Invoke(ctx, RoleService_UpdateRole_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *roleServiceClient) DeleteRole(ctx context.Context, in *DeleteRoleRequest, opts ...grpc.CallOption) (*DeleteRoleResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteRoleResponse) + err := c.cc.Invoke(ctx, RoleService_DeleteRole_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. +// +// The login service definition. +type RoleServiceServer interface { + ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) + GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) + CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) + UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) + DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) + mustEmbedUnimplementedRoleServiceServer() +} + +// UnimplementedRoleServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedRoleServiceServer struct{} + +func (UnimplementedRoleServiceServer) ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListRoles not implemented") +} +func (UnimplementedRoleServiceServer) GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetRole not implemented") +} +func (UnimplementedRoleServiceServer) CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateRole not implemented") +} +func (UnimplementedRoleServiceServer) UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateRole not implemented") +} +func (UnimplementedRoleServiceServer) DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteRole not implemented") +} +func (UnimplementedRoleServiceServer) mustEmbedUnimplementedRoleServiceServer() {} +func (UnimplementedRoleServiceServer) testEmbeddedByValue() {} + +// UnsafeRoleServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to RoleServiceServer will +// result in compilation errors. +type UnsafeRoleServiceServer interface { + mustEmbedUnimplementedRoleServiceServer() +} + +func RegisterRoleServiceServer(s grpc.ServiceRegistrar, srv RoleServiceServer) { + // If the following call pancis, it indicates UnimplementedRoleServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&RoleService_ServiceDesc, srv) +} + +func _RoleService_ListRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListRolesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoleServiceServer).ListRoles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RoleService_ListRoles_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoleServiceServer).ListRoles(ctx, req.(*ListRolesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RoleService_GetRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRoleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoleServiceServer).GetRole(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RoleService_GetRole_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoleServiceServer).GetRole(ctx, req.(*GetRoleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RoleService_CreateRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateRoleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoleServiceServer).CreateRole(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RoleService_CreateRole_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoleServiceServer).CreateRole(ctx, req.(*CreateRoleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RoleService_UpdateRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateRoleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoleServiceServer).UpdateRole(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RoleService_UpdateRole_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoleServiceServer).UpdateRole(ctx, req.(*UpdateRoleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RoleService_DeleteRole_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteRoleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoleServiceServer).DeleteRole(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RoleService_DeleteRole_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoleServiceServer).DeleteRole(ctx, req.(*DeleteRoleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// RoleService_ServiceDesc is the grpc.ServiceDesc for RoleService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var RoleService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.system.RoleService", + HandlerType: (*RoleServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListRoles", + Handler: _RoleService_ListRoles_Handler, + }, + { + MethodName: "GetRole", + Handler: _RoleService_GetRole_Handler, + }, + { + MethodName: "CreateRole", + Handler: _RoleService_CreateRole_Handler, + }, + { + MethodName: "UpdateRole", + Handler: _RoleService_UpdateRole_Handler, + }, + { + MethodName: "DeleteRole", + Handler: _RoleService_DeleteRole_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "system/role.proto", +} diff --git a/api/v1/services/system/role_http.pb.go b/api/v1/services/system/role_http.pb.go new file mode 100644 index 00000000..4b10fbf7 --- /dev/null +++ b/api/v1/services/system/role_http.pb.go @@ -0,0 +1,234 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: system/role.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationRoleServiceCreateRole = "/api.v1.services.system.RoleService/CreateRole" +const OperationRoleServiceDeleteRole = "/api.v1.services.system.RoleService/DeleteRole" +const OperationRoleServiceGetRole = "/api.v1.services.system.RoleService/GetRole" +const OperationRoleServiceListRoles = "/api.v1.services.system.RoleService/ListRoles" +const OperationRoleServiceUpdateRole = "/api.v1.services.system.RoleService/UpdateRole" + +type RoleServiceHTTPServer interface { + CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) + DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) + GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) + ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) + UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) +} + +func RegisterRoleServiceHTTPServer(s *http.Server, srv RoleServiceHTTPServer) { + r := s.Route("/") + r.GET("/sys/roles", _RoleService_ListRoles0_HTTP_Handler(srv)) + r.GET("/sys/roles/{id}", _RoleService_GetRole0_HTTP_Handler(srv)) + r.POST("/sys/roles", _RoleService_CreateRole0_HTTP_Handler(srv)) + r.PUT("/sys/roles/{role.id}", _RoleService_UpdateRole0_HTTP_Handler(srv)) + r.DELETE("/sys/roles/{id}", _RoleService_DeleteRole0_HTTP_Handler(srv)) +} + +func _RoleService_ListRoles0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceListRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListRoles(ctx, req.(*ListRolesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListRolesResponse) + return ctx.Result(200, reply) + } +} + +func _RoleService_GetRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetRoleRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceGetRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetRole(ctx, req.(*GetRoleRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetRoleResponse) + return ctx.Result(200, reply) + } +} + +func _RoleService_CreateRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateRoleRequest + if err := ctx.Bind(&in.Role); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceCreateRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateRole(ctx, req.(*CreateRoleRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateRoleResponse) + return ctx.Result(200, reply) + } +} + +func _RoleService_UpdateRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateRoleRequest + if err := ctx.Bind(&in.Role); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceUpdateRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateRole(ctx, req.(*UpdateRoleRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateRoleResponse) + return ctx.Result(200, reply) + } +} + +func _RoleService_DeleteRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteRoleRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationRoleServiceDeleteRole) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteRole(ctx, req.(*DeleteRoleRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeleteRoleResponse) + return ctx.Result(200, reply) + } +} + +type RoleServiceHTTPClient interface { + CreateRole(ctx context.Context, req *CreateRoleRequest, opts ...http.CallOption) (rsp *CreateRoleResponse, err error) + DeleteRole(ctx context.Context, req *DeleteRoleRequest, opts ...http.CallOption) (rsp *DeleteRoleResponse, err error) + GetRole(ctx context.Context, req *GetRoleRequest, opts ...http.CallOption) (rsp *GetRoleResponse, err error) + ListRoles(ctx context.Context, req *ListRolesRequest, opts ...http.CallOption) (rsp *ListRolesResponse, err error) + UpdateRole(ctx context.Context, req *UpdateRoleRequest, opts ...http.CallOption) (rsp *UpdateRoleResponse, err error) +} + +type RoleServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewRoleServiceHTTPClient(client *http.Client) RoleServiceHTTPClient { + return &RoleServiceHTTPClientImpl{client} +} + +func (c *RoleServiceHTTPClientImpl) CreateRole(ctx context.Context, in *CreateRoleRequest, opts ...http.CallOption) (*CreateRoleResponse, error) { + var out CreateRoleResponse + pattern := "/sys/roles" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationRoleServiceCreateRole)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Role, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *RoleServiceHTTPClientImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest, opts ...http.CallOption) (*DeleteRoleResponse, error) { + var out DeleteRoleResponse + pattern := "/sys/roles/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationRoleServiceDeleteRole)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *RoleServiceHTTPClientImpl) GetRole(ctx context.Context, in *GetRoleRequest, opts ...http.CallOption) (*GetRoleResponse, error) { + var out GetRoleResponse + pattern := "/sys/roles/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationRoleServiceGetRole)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *RoleServiceHTTPClientImpl) ListRoles(ctx context.Context, in *ListRolesRequest, opts ...http.CallOption) (*ListRolesResponse, error) { + var out ListRolesResponse + pattern := "/sys/roles" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationRoleServiceListRoles)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *RoleServiceHTTPClientImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest, opts ...http.CallOption) (*UpdateRoleResponse, error) { + var out UpdateRoleResponse + pattern := "/sys/roles/{role.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationRoleServiceUpdateRole)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.Role, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go new file mode 100644 index 00000000..a88e0619 --- /dev/null +++ b/api/v1/services/system/user.pb.go @@ -0,0 +1,1202 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: system/user.proto + +package system + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ListUserResourcesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListUserResourcesRequest) Reset() { + *x = ListUserResourcesRequest{} + mi := &file_system_user_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListUserResourcesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUserResourcesRequest) ProtoMessage() {} + +func (x *ListUserResourcesRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[0] + 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 ListUserResourcesRequest.ProtoReflect.Descriptor instead. +func (*ListUserResourcesRequest) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{0} +} + +func (x *ListUserResourcesRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type ListUserResourcesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` + Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListUserResourcesResponse) Reset() { + *x = ListUserResourcesResponse{} + mi := &file_system_user_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListUserResourcesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUserResourcesResponse) ProtoMessage() {} + +func (x *ListUserResourcesResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[1] + 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 ListUserResourcesResponse.ProtoReflect.Descriptor instead. +func (*ListUserResourcesResponse) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{1} +} + +func (x *ListUserResourcesResponse) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *ListUserResourcesResponse) GetResources() []*types.Resource { + if x != nil { + return x.Resources + } + return nil +} + +type UpdateUserStatusRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateUserStatusRequest) Reset() { + *x = UpdateUserStatusRequest{} + mi := &file_system_user_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateUserStatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUserStatusRequest) ProtoMessage() {} + +func (x *UpdateUserStatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[2] + 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 UpdateUserStatusRequest.ProtoReflect.Descriptor instead. +func (*UpdateUserStatusRequest) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{2} +} + +func (x *UpdateUserStatusRequest) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +type UpdateUserStatusResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateUserStatusResponse) Reset() { + *x = UpdateUserStatusResponse{} + mi := &file_system_user_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateUserStatusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUserStatusResponse) ProtoMessage() {} + +func (x *UpdateUserStatusResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[3] + 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 UpdateUserStatusResponse.ProtoReflect.Descriptor instead. +func (*UpdateUserStatusResponse) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{3} +} + +type ResetUserPasswordRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ResetUserPasswordRequest) Reset() { + *x = ResetUserPasswordRequest{} + mi := &file_system_user_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResetUserPasswordRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResetUserPasswordRequest) ProtoMessage() {} + +func (x *ResetUserPasswordRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[4] + 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 ResetUserPasswordRequest.ProtoReflect.Descriptor instead. +func (*ResetUserPasswordRequest) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{4} +} + +func (x *ResetUserPasswordRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *ResetUserPasswordRequest) GetData() *anypb.Any { + if x != nil { + return x.Data + } + return nil +} + +type ResetUserPasswordResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ResetUserPasswordResponse) Reset() { + *x = ResetUserPasswordResponse{} + mi := &file_system_user_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResetUserPasswordResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResetUserPasswordResponse) ProtoMessage() {} + +func (x *ResetUserPasswordResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[5] + 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 ResetUserPasswordResponse.ProtoReflect.Descriptor instead. +func (*ResetUserPasswordResponse) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{5} +} + +type ListUsersRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id, for example, "shelves/shelf1". + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The page number. + Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + // The next_page_token value returned from a previous List request, if any. + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + // The no_paging is used to disable pagination. + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + // The only_count is the query parameter for set only to query the total number + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + // The title query parameter for set only to query the title + Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListUsersRequest) Reset() { + *x = ListUsersRequest{} + mi := &file_system_user_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListUsersRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUsersRequest) ProtoMessage() {} + +func (x *ListUsersRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_user_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 ListUsersRequest.ProtoReflect.Descriptor instead. +func (*ListUsersRequest) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{6} +} + +func (x *ListUsersRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListUsersRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListUsersRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListUsersRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListUsersRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListUsersRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListUsersRequest) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +type ListUsersResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The total number of items in the list. + Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` + // The paging menus + Users []*types.User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` + // The page number. + Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` + // The maximum number of items to return. + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + // Token to retrieve the next page of results, or empty if there are no + // more results in the list. + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + // Additional information about this response. + // content to be added without destroying the page data format + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListUsersResponse) Reset() { + *x = ListUsersResponse{} + mi := &file_system_user_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListUsersResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListUsersResponse) ProtoMessage() {} + +func (x *ListUsersResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListUsersResponse.ProtoReflect.Descriptor instead. +func (*ListUsersResponse) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{7} +} + +func (x *ListUsersResponse) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *ListUsersResponse) GetUsers() []*types.User { + if x != nil { + return x.Users + } + return nil +} + +func (x *ListUsersResponse) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListUsersResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListUsersResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListUsersResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +type GetUserRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The field will contain id of the resource requested, for example: + // "shelves/shelf1/users/user2" + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserRequest) Reset() { + *x = GetUserRequest{} + mi := &file_system_user_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserRequest) ProtoMessage() {} + +func (x *GetUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[8] + 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 GetUserRequest.ProtoReflect.Descriptor instead. +func (*GetUserRequest) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{8} +} + +func (x *GetUserRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type GetUserResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserResponse) Reset() { + *x = GetUserResponse{} + mi := &file_system_user_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserResponse) ProtoMessage() {} + +func (x *GetUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[9] + 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 GetUserResponse.ProtoReflect.Descriptor instead. +func (*GetUserResponse) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{9} +} + +func (x *GetUserResponse) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +type CreateUserRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The parent resource id where the user is to be created. + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + // The user resource to be created. + User *types.User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` + // The password to use for this user. + Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` + // The user id to use for this user. + UserId string `protobuf:"bytes,4,opt,name=user_id,proto3" json:"user_id,omitempty"` + // The user is_system to use for this user. + IsSystem bool `protobuf:"varint,5,opt,name=is_system,proto3" json:"is_system,omitempty"` + // The random_password is the query parameter for set only to generate a random password + RandomPassword bool `protobuf:"varint,6,opt,name=random_password,proto3" json:"random_password,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateUserRequest) Reset() { + *x = CreateUserRequest{} + mi := &file_system_user_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateUserRequest) ProtoMessage() {} + +func (x *CreateUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[10] + 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 CreateUserRequest.ProtoReflect.Descriptor instead. +func (*CreateUserRequest) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{10} +} + +func (x *CreateUserRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateUserRequest) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +func (x *CreateUserRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *CreateUserRequest) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *CreateUserRequest) GetIsSystem() bool { + if x != nil { + return x.IsSystem + } + return false +} + +func (x *CreateUserRequest) GetRandomPassword() bool { + if x != nil { + return x.RandomPassword + } + return false +} + +type CreateUserResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateUserResponse) Reset() { + *x = CreateUserResponse{} + mi := &file_system_user_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateUserResponse) ProtoMessage() {} + +func (x *CreateUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[11] + 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 CreateUserResponse.ProtoReflect.Descriptor instead. +func (*CreateUserResponse) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{11} +} + +func (x *CreateUserResponse) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +type UpdateUserRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The user resource which replaces the resource on the server. + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // The user id to use for this user. + UserId string `protobuf:"bytes,3,opt,name=user_id,proto3" json:"user_id,omitempty"` + // The user is_system to use for this user. + IsSystem bool `protobuf:"varint,4,opt,name=is_system,proto3" json:"is_system,omitempty"` + // The random_password is the query parameter for set only to generate a random password + RandomPassword bool `protobuf:"varint,2,opt,name=random_password,proto3" json:"random_password,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateUserRequest) Reset() { + *x = UpdateUserRequest{} + mi := &file_system_user_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUserRequest) ProtoMessage() {} + +func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[12] + 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 UpdateUserRequest.ProtoReflect.Descriptor instead. +func (*UpdateUserRequest) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{12} +} + +func (x *UpdateUserRequest) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +func (x *UpdateUserRequest) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *UpdateUserRequest) GetIsSystem() bool { + if x != nil { + return x.IsSystem + } + return false +} + +func (x *UpdateUserRequest) GetRandomPassword() bool { + if x != nil { + return x.RandomPassword + } + return false +} + +type UpdateUserResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateUserResponse) Reset() { + *x = UpdateUserResponse{} + mi := &file_system_user_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUserResponse) ProtoMessage() {} + +func (x *UpdateUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[13] + 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 UpdateUserResponse.ProtoReflect.Descriptor instead. +func (*UpdateUserResponse) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{13} +} + +func (x *UpdateUserResponse) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +type DeleteUserRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The resource id of the user to be deleted, for example: + // "shelves/shelf1/users/user2" + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteUserRequest) Reset() { + *x = DeleteUserRequest{} + mi := &file_system_user_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUserRequest) ProtoMessage() {} + +func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[14] + 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 DeleteUserRequest.ProtoReflect.Descriptor instead. +func (*DeleteUserRequest) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{14} +} + +func (x *DeleteUserRequest) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +type DeleteUserResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteUserResponse) Reset() { + *x = DeleteUserResponse{} + mi := &file_system_user_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUserResponse) ProtoMessage() {} + +func (x *DeleteUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[15] + 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 DeleteUserResponse.ProtoReflect.Descriptor instead. +func (*DeleteUserResponse) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{15} +} + +func (x *DeleteUserResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +type UpdateUserRolesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + User *types.User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` + RoleIds []int64 `protobuf:"varint,3,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` // bool is_add = 5 [json_name = "is_add"]; + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateUserRolesRequest) Reset() { + *x = UpdateUserRolesRequest{} + mi := &file_system_user_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateUserRolesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUserRolesRequest) ProtoMessage() {} + +func (x *UpdateUserRolesRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[16] + 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 UpdateUserRolesRequest.ProtoReflect.Descriptor instead. +func (*UpdateUserRolesRequest) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{16} +} + +func (x *UpdateUserRolesRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateUserRolesRequest) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +func (x *UpdateUserRolesRequest) GetRoleIds() []int64 { + if x != nil { + return x.RoleIds + } + return nil +} + +type UpdateUserRolesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateUserRolesResponse) Reset() { + *x = UpdateUserRolesResponse{} + mi := &file_system_user_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateUserRolesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUserRolesResponse) ProtoMessage() {} + +func (x *UpdateUserRolesResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_user_proto_msgTypes[17] + 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 UpdateUserRolesResponse.ProtoReflect.Descriptor instead. +func (*UpdateUserRolesResponse) Descriptor() ([]byte, []int) { + return file_system_user_proto_rawDescGZIP(), []int{17} +} + +func (x *UpdateUserRolesResponse) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +var File_system_user_proto protoreflect.FileDescriptor + +const file_system_user_proto_rawDesc = "" + + "\n" + + "\x11system/user.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"*\n" + + "\x18ListUserResourcesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"p\n" + + "\x19ListUserResourcesResponse\x12\x14\n" + + "\x05total\x18\x01 \x01(\x05R\x05total\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"J\n" + + "\x17UpdateUserStatusRequest\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\x1a\n" + + "\x18UpdateUserStatusResponse\"T\n" + + "\x18ResetUserPasswordRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12(\n" + + "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1b\n" + + "\x19ResetUserPasswordResponse\"\xcc\x01\n" + + "\x10ListUsersRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x18\n" + + "\akeyword\x18\a \x01(\tR\akeyword\"\xf3\x01\n" + + "\x11ListUsersResponse\x12\x14\n" + + "\x05total\x18\x01 \x01(\x05R\x05total\x121\n" + + "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12\x12\n" + + "\x04page\x18\x03 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\" \n" + + "\x0eGetUserRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x0fGetUserResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\xda\x01\n" + + "\x11CreateUserRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12/\n" + + "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x1a\n" + + "\bpassword\x18\x03 \x01(\tR\bpassword\x12\x18\n" + + "\auser_id\x18\x04 \x01(\tR\auser_id\x12\x1c\n" + + "\tis_system\x18\x05 \x01(\bR\tis_system\x12(\n" + + "\x0frandom_password\x18\x06 \x01(\bR\x0frandom_password\"E\n" + + "\x12CreateUserResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\xa6\x01\n" + + "\x11UpdateUserRequest\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x18\n" + + "\auser_id\x18\x03 \x01(\tR\auser_id\x12\x1c\n" + + "\tis_system\x18\x04 \x01(\bR\tis_system\x12(\n" + + "\x0frandom_password\x18\x02 \x01(\bR\x0frandom_password\"E\n" + + "\x12UpdateUserResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"D\n" + + "\x11DeleteUserRequest\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"B\n" + + "\x12DeleteUserResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"u\n" + + "\x16UpdateUserRolesRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12/\n" + + "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x1a\n" + + "\brole_ids\x18\x03 \x03(\x03R\brole_ids\"J\n" + + "\x17UpdateUserRolesResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\x8e\n" + + "\n" + + "\vUserService\x12t\n" + + "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + + "/sys/users\x12\x9b\x01\n" + + "\x11ListUserResources\x120.api.v1.services.system.ListUserResourcesRequest\x1a1.api.v1.services.system.ListUserResourcesResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/sys/users/{id}/resources\x12s\n" + + "\aGetUser\x12&.api.v1.services.system.GetUserRequest\x1a'.api.v1.services.system.GetUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/users/{id}\x12}\n" + + "\n" + + "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a*.api.v1.services.system.CreateUserResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04user\"\n" + + "/sys/users\x12\x87\x01\n" + + "\n" + + "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04user\x1a\x14/sys/users/{user.id}\x12\x81\x01\n" + + "\n" + + "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x1c\x82\xd3\xe4\x93\x02\x16*\x14/sys/users/{user.id}\x12\xa0\x01\n" + + "\x10UpdateUserStatus\x12/.api.v1.services.system.UpdateUserStatusRequest\x1a0.api.v1.services.system.UpdateUserStatusResponse\")\x82\xd3\xe4\x93\x02#:\x04user\x1a\x1b/sys/users/{user.id}/status\x12\x9c\x01\n" + + "\x0fUpdateUserRoles\x12..api.v1.services.system.UpdateUserRolesRequest\x1a/.api.v1.services.system.UpdateUserRolesResponse\"(\x82\xd3\xe4\x93\x02\":\x04user\x1a\x1a/sys/users/{user.id}/roles\x12\xa6\x01\n" + + "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\",\x82\xd3\xe4\x93\x02&:\x04data\"\x1e/sys/users/{id}/password/resetB\xde\x01\n" + + "\x1acom.api.v1.services.systemB\tUserProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + +var ( + file_system_user_proto_rawDescOnce sync.Once + file_system_user_proto_rawDescData []byte +) + +func file_system_user_proto_rawDescGZIP() []byte { + file_system_user_proto_rawDescOnce.Do(func() { + file_system_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_user_proto_rawDesc), len(file_system_user_proto_rawDesc))) + }) + return file_system_user_proto_rawDescData +} + +var file_system_user_proto_msgTypes = make([]protoimpl.MessageInfo, 18) +var file_system_user_proto_goTypes = []any{ + (*ListUserResourcesRequest)(nil), // 0: api.v1.services.system.ListUserResourcesRequest + (*ListUserResourcesResponse)(nil), // 1: api.v1.services.system.ListUserResourcesResponse + (*UpdateUserStatusRequest)(nil), // 2: api.v1.services.system.UpdateUserStatusRequest + (*UpdateUserStatusResponse)(nil), // 3: api.v1.services.system.UpdateUserStatusResponse + (*ResetUserPasswordRequest)(nil), // 4: api.v1.services.system.ResetUserPasswordRequest + (*ResetUserPasswordResponse)(nil), // 5: api.v1.services.system.ResetUserPasswordResponse + (*ListUsersRequest)(nil), // 6: api.v1.services.system.ListUsersRequest + (*ListUsersResponse)(nil), // 7: api.v1.services.system.ListUsersResponse + (*GetUserRequest)(nil), // 8: api.v1.services.system.GetUserRequest + (*GetUserResponse)(nil), // 9: api.v1.services.system.GetUserResponse + (*CreateUserRequest)(nil), // 10: api.v1.services.system.CreateUserRequest + (*CreateUserResponse)(nil), // 11: api.v1.services.system.CreateUserResponse + (*UpdateUserRequest)(nil), // 12: api.v1.services.system.UpdateUserRequest + (*UpdateUserResponse)(nil), // 13: api.v1.services.system.UpdateUserResponse + (*DeleteUserRequest)(nil), // 14: api.v1.services.system.DeleteUserRequest + (*DeleteUserResponse)(nil), // 15: api.v1.services.system.DeleteUserResponse + (*UpdateUserRolesRequest)(nil), // 16: api.v1.services.system.UpdateUserRolesRequest + (*UpdateUserRolesResponse)(nil), // 17: api.v1.services.system.UpdateUserRolesResponse + (*types.Resource)(nil), // 18: api.v1.services.types.Resource + (*types.User)(nil), // 19: api.v1.services.types.User + (*anypb.Any)(nil), // 20: google.protobuf.Any + (*emptypb.Empty)(nil), // 21: google.protobuf.Empty +} +var file_system_user_proto_depIdxs = []int32{ + 18, // 0: api.v1.services.system.ListUserResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 19, // 1: api.v1.services.system.UpdateUserStatusRequest.user:type_name -> api.v1.services.types.User + 20, // 2: api.v1.services.system.ResetUserPasswordRequest.data:type_name -> google.protobuf.Any + 19, // 3: api.v1.services.system.ListUsersResponse.users:type_name -> api.v1.services.types.User + 20, // 4: api.v1.services.system.ListUsersResponse.extra:type_name -> google.protobuf.Any + 19, // 5: api.v1.services.system.GetUserResponse.user:type_name -> api.v1.services.types.User + 19, // 6: api.v1.services.system.CreateUserRequest.user:type_name -> api.v1.services.types.User + 19, // 7: api.v1.services.system.CreateUserResponse.user:type_name -> api.v1.services.types.User + 19, // 8: api.v1.services.system.UpdateUserRequest.user:type_name -> api.v1.services.types.User + 19, // 9: api.v1.services.system.UpdateUserResponse.user:type_name -> api.v1.services.types.User + 19, // 10: api.v1.services.system.DeleteUserRequest.user:type_name -> api.v1.services.types.User + 21, // 11: api.v1.services.system.DeleteUserResponse.empty:type_name -> google.protobuf.Empty + 19, // 12: api.v1.services.system.UpdateUserRolesRequest.user:type_name -> api.v1.services.types.User + 19, // 13: api.v1.services.system.UpdateUserRolesResponse.user:type_name -> api.v1.services.types.User + 6, // 14: api.v1.services.system.UserService.ListUsers:input_type -> api.v1.services.system.ListUsersRequest + 0, // 15: api.v1.services.system.UserService.ListUserResources:input_type -> api.v1.services.system.ListUserResourcesRequest + 8, // 16: api.v1.services.system.UserService.GetUser:input_type -> api.v1.services.system.GetUserRequest + 10, // 17: api.v1.services.system.UserService.CreateUser:input_type -> api.v1.services.system.CreateUserRequest + 12, // 18: api.v1.services.system.UserService.UpdateUser:input_type -> api.v1.services.system.UpdateUserRequest + 14, // 19: api.v1.services.system.UserService.DeleteUser:input_type -> api.v1.services.system.DeleteUserRequest + 2, // 20: api.v1.services.system.UserService.UpdateUserStatus:input_type -> api.v1.services.system.UpdateUserStatusRequest + 16, // 21: api.v1.services.system.UserService.UpdateUserRoles:input_type -> api.v1.services.system.UpdateUserRolesRequest + 4, // 22: api.v1.services.system.UserService.ResetUserPassword:input_type -> api.v1.services.system.ResetUserPasswordRequest + 7, // 23: api.v1.services.system.UserService.ListUsers:output_type -> api.v1.services.system.ListUsersResponse + 1, // 24: api.v1.services.system.UserService.ListUserResources:output_type -> api.v1.services.system.ListUserResourcesResponse + 9, // 25: api.v1.services.system.UserService.GetUser:output_type -> api.v1.services.system.GetUserResponse + 11, // 26: api.v1.services.system.UserService.CreateUser:output_type -> api.v1.services.system.CreateUserResponse + 13, // 27: api.v1.services.system.UserService.UpdateUser:output_type -> api.v1.services.system.UpdateUserResponse + 15, // 28: api.v1.services.system.UserService.DeleteUser:output_type -> api.v1.services.system.DeleteUserResponse + 3, // 29: api.v1.services.system.UserService.UpdateUserStatus:output_type -> api.v1.services.system.UpdateUserStatusResponse + 17, // 30: api.v1.services.system.UserService.UpdateUserRoles:output_type -> api.v1.services.system.UpdateUserRolesResponse + 5, // 31: api.v1.services.system.UserService.ResetUserPassword:output_type -> api.v1.services.system.ResetUserPasswordResponse + 23, // [23:32] is the sub-list for method output_type + 14, // [14:23] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name +} + +func init() { file_system_user_proto_init() } +func file_system_user_proto_init() { + if File_system_user_proto != nil { + return + } + file_system_user_proto_msgTypes[7].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_user_proto_rawDesc), len(file_system_user_proto_rawDesc)), + NumEnums: 0, + NumMessages: 18, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_system_user_proto_goTypes, + DependencyIndexes: file_system_user_proto_depIdxs, + MessageInfos: file_system_user_proto_msgTypes, + }.Build() + File_system_user_proto = out.File + file_system_user_proto_goTypes = nil + file_system_user_proto_depIdxs = nil +} diff --git a/api/v1/services/system/user.pb.gw.go b/api/v1/services/system/user.pb.gw.go new file mode 100644 index 00000000..6958ef75 --- /dev/null +++ b/api/v1/services/system/user.pb.gw.go @@ -0,0 +1,834 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: system/user.proto + +/* +Package system is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package system + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_UserService_ListUsers_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_UserService_ListUsers_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListUsersRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_ListUsers_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListUsers(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UserService_ListUsers_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListUsersRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_ListUsers_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListUsers(ctx, &protoReq) + return msg, metadata, err +} + +func request_UserService_ListUserResources_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListUserResourcesRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.ListUserResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UserService_ListUserResources_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListUserResourcesRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.ListUserResources(ctx, &protoReq) + return msg, metadata, err +} + +func request_UserService_GetUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetUserRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UserService_GetUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetUserRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetUser(ctx, &protoReq) + return msg, metadata, err +} + +var filter_UserService_CreateUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_UserService_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateUserRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_CreateUser_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UserService_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateUserRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_CreateUser_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateUser(ctx, &protoReq) + return msg, metadata, err +} + +var filter_UserService_UpdateUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_UserService_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateUserRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["user.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUser_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UserService_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateUserRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["user.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUser_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateUser(ctx, &protoReq) + return msg, metadata, err +} + +var filter_UserService_DeleteUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} + +func request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteUserRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["user.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_DeleteUser_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.DeleteUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteUserRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["user.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_DeleteUser_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.DeleteUser(ctx, &protoReq) + return msg, metadata, err +} + +func request_UserService_UpdateUserStatus_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateUserStatusRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["user.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + } + msg, err := client.UpdateUserStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UserService_UpdateUserStatus_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateUserStatusRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["user.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + } + msg, err := server.UpdateUserStatus(ctx, &protoReq) + return msg, metadata, err +} + +var filter_UserService_UpdateUserRoles_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_UserService_UpdateUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateUserRolesRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["user.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUserRoles_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateUserRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UserService_UpdateUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateUserRolesRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["user.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUserRoles_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateUserRoles(ctx, &protoReq) + return msg, metadata, err +} + +func request_UserService_ResetUserPassword_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ResetUserPasswordRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.ResetUserPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_UserService_ResetUserPassword_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ResetUserPasswordRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.String(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.ResetUserPassword(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterUserServiceHandlerServer registers the http handlers for service UserService to "mux". +// UnaryRPC :call UserServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUserServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceServer) error { + mux.Handle(http.MethodGet, pattern_UserService_ListUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/ListUsers", runtime.WithHTTPPathPattern("/sys/users")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UserService_ListUsers_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_ListUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_UserService_ListUserResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/ListUserResources", runtime.WithHTTPPathPattern("/sys/users/{id}/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UserService_ListUserResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_ListUserResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_UserService_GetUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/GetUser", runtime.WithHTTPPathPattern("/sys/users/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UserService_GetUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_GetUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_UserService_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/CreateUser", runtime.WithHTTPPathPattern("/sys/users")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UserService_CreateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUser", runtime.WithHTTPPathPattern("/sys/users/{user.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UserService_UpdateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_UserService_DeleteUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/DeleteUser", runtime.WithHTTPPathPattern("/sys/users/{user.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UserService_DeleteUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_DeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_UserService_UpdateUserStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserStatus", runtime.WithHTTPPathPattern("/sys/users/{user.id}/status")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UserService_UpdateUserStatus_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_UpdateUserStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_UserService_UpdateUserRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserRoles", runtime.WithHTTPPathPattern("/sys/users/{user.id}/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UserService_UpdateUserRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_UpdateUserRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_UserService_ResetUserPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/ResetUserPassword", runtime.WithHTTPPathPattern("/sys/users/{id}/password/reset")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_UserService_ResetUserPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_ResetUserPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterUserServiceHandlerFromEndpoint is same as RegisterUserServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterUserServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterUserServiceHandler(ctx, mux, conn) +} + +// RegisterUserServiceHandler registers the http handlers for service UserService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterUserServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterUserServiceHandlerClient(ctx, mux, NewUserServiceClient(conn)) +} + +// RegisterUserServiceHandlerClient registers the http handlers for service UserService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "UserServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserServiceClient) error { + mux.Handle(http.MethodGet, pattern_UserService_ListUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/ListUsers", runtime.WithHTTPPathPattern("/sys/users")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UserService_ListUsers_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_ListUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_UserService_ListUserResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/ListUserResources", runtime.WithHTTPPathPattern("/sys/users/{id}/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UserService_ListUserResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_ListUserResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_UserService_GetUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/GetUser", runtime.WithHTTPPathPattern("/sys/users/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UserService_GetUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_GetUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_UserService_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/CreateUser", runtime.WithHTTPPathPattern("/sys/users")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UserService_CreateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUser", runtime.WithHTTPPathPattern("/sys/users/{user.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UserService_UpdateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_UserService_DeleteUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/DeleteUser", runtime.WithHTTPPathPattern("/sys/users/{user.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UserService_DeleteUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_DeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_UserService_UpdateUserStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserStatus", runtime.WithHTTPPathPattern("/sys/users/{user.id}/status")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UserService_UpdateUserStatus_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_UpdateUserStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_UserService_UpdateUserRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserRoles", runtime.WithHTTPPathPattern("/sys/users/{user.id}/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UserService_UpdateUserRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_UpdateUserRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_UserService_ResetUserPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/ResetUserPassword", runtime.WithHTTPPathPattern("/sys/users/{id}/password/reset")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UserService_ResetUserPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_UserService_ResetUserPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_UserService_ListUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "users"}, "")) + pattern_UserService_ListUserResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"sys", "users", "id", "resources"}, "")) + pattern_UserService_GetUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "users", "id"}, "")) + pattern_UserService_CreateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "users"}, "")) + pattern_UserService_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "users", "user.id"}, "")) + pattern_UserService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "users", "user.id"}, "")) + pattern_UserService_UpdateUserStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"sys", "users", "user.id", "status"}, "")) + pattern_UserService_UpdateUserRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"sys", "users", "user.id", "roles"}, "")) + pattern_UserService_ResetUserPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4}, []string{"sys", "users", "id", "password", "reset"}, "")) +) + +var ( + forward_UserService_ListUsers_0 = runtime.ForwardResponseMessage + forward_UserService_ListUserResources_0 = runtime.ForwardResponseMessage + forward_UserService_GetUser_0 = runtime.ForwardResponseMessage + forward_UserService_CreateUser_0 = runtime.ForwardResponseMessage + forward_UserService_UpdateUser_0 = runtime.ForwardResponseMessage + forward_UserService_DeleteUser_0 = runtime.ForwardResponseMessage + forward_UserService_UpdateUserStatus_0 = runtime.ForwardResponseMessage + forward_UserService_UpdateUserRoles_0 = runtime.ForwardResponseMessage + forward_UserService_ResetUserPassword_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/system/user.pb.validate.go b/api/v1/services/system/user.pb.validate.go new file mode 100644 index 00000000..1dbd70f7 --- /dev/null +++ b/api/v1/services/system/user.pb.validate.go @@ -0,0 +1,2334 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: system/user.proto + +package system + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListUserResourcesRequest 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 *ListUserResourcesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUserResourcesRequest 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 +// ListUserResourcesRequestMultiError, or nil if none found. +func (m *ListUserResourcesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUserResourcesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return ListUserResourcesRequestMultiError(errors) + } + + return nil +} + +// ListUserResourcesRequestMultiError is an error wrapping multiple validation +// errors returned by ListUserResourcesRequest.ValidateAll() if the designated +// constraints aren't met. +type ListUserResourcesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUserResourcesRequestMultiError) 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 ListUserResourcesRequestMultiError) AllErrors() []error { return m } + +// ListUserResourcesRequestValidationError is the validation error returned by +// ListUserResourcesRequest.Validate if the designated constraints aren't met. +type ListUserResourcesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListUserResourcesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListUserResourcesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListUserResourcesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListUserResourcesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListUserResourcesRequestValidationError) ErrorName() string { + return "ListUserResourcesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ListUserResourcesRequestValidationError) 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 %sListUserResourcesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListUserResourcesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListUserResourcesRequestValidationError{} + +// Validate checks the field values on ListUserResourcesResponse 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 *ListUserResourcesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUserResourcesResponse 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 +// ListUserResourcesResponseMultiError, or nil if none found. +func (m *ListUserResourcesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUserResourcesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Total + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUserResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUserResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListUserResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListUserResourcesResponseMultiError(errors) + } + + return nil +} + +// ListUserResourcesResponseMultiError is an error wrapping multiple validation +// errors returned by ListUserResourcesResponse.ValidateAll() if the +// designated constraints aren't met. +type ListUserResourcesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUserResourcesResponseMultiError) 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 ListUserResourcesResponseMultiError) AllErrors() []error { return m } + +// ListUserResourcesResponseValidationError is the validation error returned by +// ListUserResourcesResponse.Validate if the designated constraints aren't met. +type ListUserResourcesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListUserResourcesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListUserResourcesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListUserResourcesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListUserResourcesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListUserResourcesResponseValidationError) ErrorName() string { + return "ListUserResourcesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListUserResourcesResponseValidationError) 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 %sListUserResourcesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListUserResourcesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListUserResourcesResponseValidationError{} + +// Validate checks the field values on UpdateUserStatusRequest 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 *UpdateUserStatusRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUserStatusRequest 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 +// UpdateUserStatusRequestMultiError, or nil if none found. +func (m *UpdateUserStatusRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUserStatusRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUserStatusRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUserStatusRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateUserStatusRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateUserStatusRequestMultiError(errors) + } + + return nil +} + +// UpdateUserStatusRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateUserStatusRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateUserStatusRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUserStatusRequestMultiError) 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 UpdateUserStatusRequestMultiError) AllErrors() []error { return m } + +// UpdateUserStatusRequestValidationError is the validation error returned by +// UpdateUserStatusRequest.Validate if the designated constraints aren't met. +type UpdateUserStatusRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUserStatusRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUserStatusRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUserStatusRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUserStatusRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUserStatusRequestValidationError) ErrorName() string { + return "UpdateUserStatusRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUserStatusRequestValidationError) 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 %sUpdateUserStatusRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUserStatusRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUserStatusRequestValidationError{} + +// Validate checks the field values on UpdateUserStatusResponse 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 *UpdateUserStatusResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUserStatusResponse 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 +// UpdateUserStatusResponseMultiError, or nil if none found. +func (m *UpdateUserStatusResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUserStatusResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdateUserStatusResponseMultiError(errors) + } + + return nil +} + +// UpdateUserStatusResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateUserStatusResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateUserStatusResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUserStatusResponseMultiError) 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 UpdateUserStatusResponseMultiError) AllErrors() []error { return m } + +// UpdateUserStatusResponseValidationError is the validation error returned by +// UpdateUserStatusResponse.Validate if the designated constraints aren't met. +type UpdateUserStatusResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUserStatusResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUserStatusResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUserStatusResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUserStatusResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUserStatusResponseValidationError) ErrorName() string { + return "UpdateUserStatusResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUserStatusResponseValidationError) 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 %sUpdateUserStatusResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUserStatusResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUserStatusResponseValidationError{} + +// Validate checks the field values on ResetUserPasswordRequest 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 *ResetUserPasswordRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ResetUserPasswordRequest 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 +// ResetUserPasswordRequestMultiError, or nil if none found. +func (m *ResetUserPasswordRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ResetUserPasswordRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetData()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResetUserPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResetUserPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResetUserPasswordRequestValidationError{ + field: "Data", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ResetUserPasswordRequestMultiError(errors) + } + + return nil +} + +// ResetUserPasswordRequestMultiError is an error wrapping multiple validation +// errors returned by ResetUserPasswordRequest.ValidateAll() if the designated +// constraints aren't met. +type ResetUserPasswordRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResetUserPasswordRequestMultiError) 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 ResetUserPasswordRequestMultiError) AllErrors() []error { return m } + +// ResetUserPasswordRequestValidationError is the validation error returned by +// ResetUserPasswordRequest.Validate if the designated constraints aren't met. +type ResetUserPasswordRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResetUserPasswordRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResetUserPasswordRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResetUserPasswordRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResetUserPasswordRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResetUserPasswordRequestValidationError) ErrorName() string { + return "ResetUserPasswordRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e ResetUserPasswordRequestValidationError) 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 %sResetUserPasswordRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResetUserPasswordRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResetUserPasswordRequestValidationError{} + +// Validate checks the field values on ResetUserPasswordResponse 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 *ResetUserPasswordResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ResetUserPasswordResponse 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 +// ResetUserPasswordResponseMultiError, or nil if none found. +func (m *ResetUserPasswordResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ResetUserPasswordResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return ResetUserPasswordResponseMultiError(errors) + } + + return nil +} + +// ResetUserPasswordResponseMultiError is an error wrapping multiple validation +// errors returned by ResetUserPasswordResponse.ValidateAll() if the +// designated constraints aren't met. +type ResetUserPasswordResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResetUserPasswordResponseMultiError) 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 ResetUserPasswordResponseMultiError) AllErrors() []error { return m } + +// ResetUserPasswordResponseValidationError is the validation error returned by +// ResetUserPasswordResponse.Validate if the designated constraints aren't met. +type ResetUserPasswordResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResetUserPasswordResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResetUserPasswordResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResetUserPasswordResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResetUserPasswordResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResetUserPasswordResponseValidationError) ErrorName() string { + return "ResetUserPasswordResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ResetUserPasswordResponseValidationError) 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 %sResetUserPasswordResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResetUserPasswordResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResetUserPasswordResponseValidationError{} + +// Validate checks the field values on ListUsersRequest 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 *ListUsersRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUsersRequest 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 +// ListUsersRequestMultiError, or nil if none found. +func (m *ListUsersRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUsersRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Keyword + + if len(errors) > 0 { + return ListUsersRequestMultiError(errors) + } + + return nil +} + +// ListUsersRequestMultiError is an error wrapping multiple validation errors +// returned by ListUsersRequest.ValidateAll() if the designated constraints +// aren't met. +type ListUsersRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUsersRequestMultiError) 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 ListUsersRequestMultiError) AllErrors() []error { return m } + +// ListUsersRequestValidationError is the validation error returned by +// ListUsersRequest.Validate if the designated constraints aren't met. +type ListUsersRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListUsersRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListUsersRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListUsersRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListUsersRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListUsersRequestValidationError) ErrorName() string { return "ListUsersRequestValidationError" } + +// Error satisfies the builtin error interface +func (e ListUsersRequestValidationError) 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 %sListUsersRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListUsersRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListUsersRequestValidationError{} + +// Validate checks the field values on ListUsersResponse 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 *ListUsersResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListUsersResponse 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 +// ListUsersResponseMultiError, or nil if none found. +func (m *ListUsersResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListUsersResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Total + + for idx, item := range m.GetUsers() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUsersResponseValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUsersResponseValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListUsersResponseValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListUsersResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListUsersResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListUsersResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListUsersResponseMultiError(errors) + } + + return nil +} + +// ListUsersResponseMultiError is an error wrapping multiple validation errors +// returned by ListUsersResponse.ValidateAll() if the designated constraints +// aren't met. +type ListUsersResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListUsersResponseMultiError) 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 ListUsersResponseMultiError) AllErrors() []error { return m } + +// ListUsersResponseValidationError is the validation error returned by +// ListUsersResponse.Validate if the designated constraints aren't met. +type ListUsersResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListUsersResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListUsersResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListUsersResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListUsersResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListUsersResponseValidationError) ErrorName() string { + return "ListUsersResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListUsersResponseValidationError) 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 %sListUsersResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListUsersResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListUsersResponseValidationError{} + +// Validate checks the field values on GetUserRequest 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 *GetUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserRequest 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 GetUserRequestMultiError, +// or nil if none found. +func (m *GetUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetUserRequestMultiError(errors) + } + + return nil +} + +// GetUserRequestMultiError is an error wrapping multiple validation errors +// returned by GetUserRequest.ValidateAll() if the designated constraints +// aren't met. +type GetUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserRequestMultiError) 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 GetUserRequestMultiError) AllErrors() []error { return m } + +// GetUserRequestValidationError is the validation error returned by +// GetUserRequest.Validate if the designated constraints aren't met. +type GetUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserRequestValidationError) ErrorName() string { return "GetUserRequestValidationError" } + +// Error satisfies the builtin error interface +func (e GetUserRequestValidationError) 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 %sGetUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserRequestValidationError{} + +// Validate checks the field values on GetUserResponse 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 *GetUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserResponse 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 +// GetUserResponseMultiError, or nil if none found. +func (m *GetUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetUserResponseMultiError(errors) + } + + return nil +} + +// GetUserResponseMultiError is an error wrapping multiple validation errors +// returned by GetUserResponse.ValidateAll() if the designated constraints +// aren't met. +type GetUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserResponseMultiError) 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 GetUserResponseMultiError) AllErrors() []error { return m } + +// GetUserResponseValidationError is the validation error returned by +// GetUserResponse.Validate if the designated constraints aren't met. +type GetUserResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserResponseValidationError) ErrorName() string { return "GetUserResponseValidationError" } + +// Error satisfies the builtin error interface +func (e GetUserResponseValidationError) 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 %sGetUserResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserResponseValidationError{} + +// Validate checks the field values on CreateUserRequest 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 *CreateUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateUserRequest 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 +// CreateUserRequestMultiError, or nil if none found. +func (m *CreateUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Password + + // no validation rules for UserId + + // no validation rules for IsSystem + + // no validation rules for RandomPassword + + if len(errors) > 0 { + return CreateUserRequestMultiError(errors) + } + + return nil +} + +// CreateUserRequestMultiError is an error wrapping multiple validation errors +// returned by CreateUserRequest.ValidateAll() if the designated constraints +// aren't met. +type CreateUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateUserRequestMultiError) 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 CreateUserRequestMultiError) AllErrors() []error { return m } + +// CreateUserRequestValidationError is the validation error returned by +// CreateUserRequest.Validate if the designated constraints aren't met. +type CreateUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateUserRequestValidationError) ErrorName() string { + return "CreateUserRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateUserRequestValidationError) 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 %sCreateUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateUserRequestValidationError{} + +// Validate checks the field values on CreateUserResponse 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 *CreateUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateUserResponse 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 +// CreateUserResponseMultiError, or nil if none found. +func (m *CreateUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateUserResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateUserResponseMultiError(errors) + } + + return nil +} + +// CreateUserResponseMultiError is an error wrapping multiple validation errors +// returned by CreateUserResponse.ValidateAll() if the designated constraints +// aren't met. +type CreateUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateUserResponseMultiError) 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 CreateUserResponseMultiError) AllErrors() []error { return m } + +// CreateUserResponseValidationError is the validation error returned by +// CreateUserResponse.Validate if the designated constraints aren't met. +type CreateUserResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateUserResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateUserResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateUserResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateUserResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateUserResponseValidationError) ErrorName() string { + return "CreateUserResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateUserResponseValidationError) 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 %sCreateUserResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateUserResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateUserResponseValidationError{} + +// Validate checks the field values on UpdateUserRequest 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 *UpdateUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUserRequest 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 +// UpdateUserRequestMultiError, or nil if none found. +func (m *UpdateUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for UserId + + // no validation rules for IsSystem + + // no validation rules for RandomPassword + + if len(errors) > 0 { + return UpdateUserRequestMultiError(errors) + } + + return nil +} + +// UpdateUserRequestMultiError is an error wrapping multiple validation errors +// returned by UpdateUserRequest.ValidateAll() if the designated constraints +// aren't met. +type UpdateUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUserRequestMultiError) 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 UpdateUserRequestMultiError) AllErrors() []error { return m } + +// UpdateUserRequestValidationError is the validation error returned by +// UpdateUserRequest.Validate if the designated constraints aren't met. +type UpdateUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUserRequestValidationError) ErrorName() string { + return "UpdateUserRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUserRequestValidationError) 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 %sUpdateUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUserRequestValidationError{} + +// Validate checks the field values on UpdateUserResponse 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 *UpdateUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUserResponse 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 +// UpdateUserResponseMultiError, or nil if none found. +func (m *UpdateUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUserResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateUserResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateUserResponseMultiError(errors) + } + + return nil +} + +// UpdateUserResponseMultiError is an error wrapping multiple validation errors +// returned by UpdateUserResponse.ValidateAll() if the designated constraints +// aren't met. +type UpdateUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUserResponseMultiError) 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 UpdateUserResponseMultiError) AllErrors() []error { return m } + +// UpdateUserResponseValidationError is the validation error returned by +// UpdateUserResponse.Validate if the designated constraints aren't met. +type UpdateUserResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUserResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUserResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUserResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUserResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUserResponseValidationError) ErrorName() string { + return "UpdateUserResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUserResponseValidationError) 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 %sUpdateUserResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUserResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUserResponseValidationError{} + +// Validate checks the field values on DeleteUserRequest 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 *DeleteUserRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteUserRequest 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 +// DeleteUserRequestMultiError, or nil if none found. +func (m *DeleteUserRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteUserRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteUserRequestMultiError(errors) + } + + return nil +} + +// DeleteUserRequestMultiError is an error wrapping multiple validation errors +// returned by DeleteUserRequest.ValidateAll() if the designated constraints +// aren't met. +type DeleteUserRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteUserRequestMultiError) 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 DeleteUserRequestMultiError) AllErrors() []error { return m } + +// DeleteUserRequestValidationError is the validation error returned by +// DeleteUserRequest.Validate if the designated constraints aren't met. +type DeleteUserRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteUserRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteUserRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteUserRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteUserRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteUserRequestValidationError) ErrorName() string { + return "DeleteUserRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteUserRequestValidationError) 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 %sDeleteUserRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteUserRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteUserRequestValidationError{} + +// Validate checks the field values on DeleteUserResponse 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 *DeleteUserResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteUserResponse 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 +// DeleteUserResponseMultiError, or nil if none found. +func (m *DeleteUserResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteUserResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteUserResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteUserResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteUserResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteUserResponseMultiError(errors) + } + + return nil +} + +// DeleteUserResponseMultiError is an error wrapping multiple validation errors +// returned by DeleteUserResponse.ValidateAll() if the designated constraints +// aren't met. +type DeleteUserResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteUserResponseMultiError) 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 DeleteUserResponseMultiError) AllErrors() []error { return m } + +// DeleteUserResponseValidationError is the validation error returned by +// DeleteUserResponse.Validate if the designated constraints aren't met. +type DeleteUserResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteUserResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteUserResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteUserResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteUserResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteUserResponseValidationError) ErrorName() string { + return "DeleteUserResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteUserResponseValidationError) 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 %sDeleteUserResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteUserResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteUserResponseValidationError{} + +// Validate checks the field values on UpdateUserRolesRequest 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 *UpdateUserRolesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUserRolesRequest 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 +// UpdateUserRolesRequestMultiError, or nil if none found. +func (m *UpdateUserRolesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUserRolesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUserRolesRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUserRolesRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateUserRolesRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateUserRolesRequestMultiError(errors) + } + + return nil +} + +// UpdateUserRolesRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateUserRolesRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateUserRolesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUserRolesRequestMultiError) 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 UpdateUserRolesRequestMultiError) AllErrors() []error { return m } + +// UpdateUserRolesRequestValidationError is the validation error returned by +// UpdateUserRolesRequest.Validate if the designated constraints aren't met. +type UpdateUserRolesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUserRolesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUserRolesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUserRolesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUserRolesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUserRolesRequestValidationError) ErrorName() string { + return "UpdateUserRolesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUserRolesRequestValidationError) 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 %sUpdateUserRolesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUserRolesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUserRolesRequestValidationError{} + +// Validate checks the field values on UpdateUserRolesResponse 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 *UpdateUserRolesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateUserRolesResponse 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 +// UpdateUserRolesResponseMultiError, or nil if none found. +func (m *UpdateUserRolesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateUserRolesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUserRolesResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUserRolesResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateUserRolesResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateUserRolesResponseMultiError(errors) + } + + return nil +} + +// UpdateUserRolesResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateUserRolesResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateUserRolesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateUserRolesResponseMultiError) 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 UpdateUserRolesResponseMultiError) AllErrors() []error { return m } + +// UpdateUserRolesResponseValidationError is the validation error returned by +// UpdateUserRolesResponse.Validate if the designated constraints aren't met. +type UpdateUserRolesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateUserRolesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateUserRolesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateUserRolesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateUserRolesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateUserRolesResponseValidationError) ErrorName() string { + return "UpdateUserRolesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateUserRolesResponseValidationError) 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 %sUpdateUserRolesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateUserRolesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateUserRolesResponseValidationError{} diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go new file mode 100644 index 00000000..85075ca1 --- /dev/null +++ b/api/v1/services/system/user_bridge.pb.go @@ -0,0 +1,636 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/user.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const UserServiceCreateUserBridgeOperation = "/api.v1.services.system.UserService/CreateUser" +const UserServiceDeleteUserBridgeOperation = "/api.v1.services.system.UserService/DeleteUser" +const UserServiceGetUserBridgeOperation = "/api.v1.services.system.UserService/GetUser" +const UserServiceListUserResourcesBridgeOperation = "/api.v1.services.system.UserService/ListUserResources" +const UserServiceListUsersBridgeOperation = "/api.v1.services.system.UserService/ListUsers" +const UserServiceResetUserPasswordBridgeOperation = "/api.v1.services.system.UserService/ResetUserPassword" +const UserServiceUpdateUserBridgeOperation = "/api.v1.services.system.UserService/UpdateUser" +const UserServiceUpdateUserRolesBridgeOperation = "/api.v1.services.system.UserService/UpdateUserRoles" +const UserServiceUpdateUserStatusBridgeOperation = "/api.v1.services.system.UserService/UpdateUserStatus" + +type UserServiceBridgeServer interface { + CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) + DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) + GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) + ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) + ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) + // ResetUserPassword reset the user s password + ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) + UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) + // UpdateUserRoles update the user roles + UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) + // UpdateUserStatus Update the status of the user information + UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) +} + +type UserServiceHooker interface { + UserServiceCreateUserHooker + UserServiceDeleteUserHooker + UserServiceGetUserHooker + UserServiceListUserResourcesHooker + UserServiceListUsersHooker + UserServiceResetUserPasswordHooker + UserServiceUpdateUserHooker + UserServiceUpdateUserRolesHooker + UserServiceUpdateUserStatusHooker +} + +type UserServiceHookedBridger interface { + UserServiceHooker + UserServiceBridgeServer +} +type UserServiceCreateUserHooker interface { + PrepareCreateUser(http.Context, *CreateUserRequest) (context.Context, error) + CompleteCreateUser(http.Context, *CreateUserRequest, *CreateUserResponse) error +} +type UserServiceDeleteUserHooker interface { + PrepareDeleteUser(http.Context, *DeleteUserRequest) (context.Context, error) + CompleteDeleteUser(http.Context, *DeleteUserRequest, *DeleteUserResponse) error +} +type UserServiceGetUserHooker interface { + PrepareGetUser(http.Context, *GetUserRequest) (context.Context, error) + CompleteGetUser(http.Context, *GetUserRequest, *GetUserResponse) error +} +type UserServiceListUserResourcesHooker interface { + PrepareListUserResources(http.Context, *ListUserResourcesRequest) (context.Context, error) + CompleteListUserResources(http.Context, *ListUserResourcesRequest, *ListUserResourcesResponse) error +} +type UserServiceListUsersHooker interface { + PrepareListUsers(http.Context, *ListUsersRequest) (context.Context, error) + CompleteListUsers(http.Context, *ListUsersRequest, *ListUsersResponse) error +} +type UserServiceResetUserPasswordHooker interface { + PrepareResetUserPassword(http.Context, *ResetUserPasswordRequest) (context.Context, error) + CompleteResetUserPassword(http.Context, *ResetUserPasswordRequest, *ResetUserPasswordResponse) error +} +type UserServiceUpdateUserHooker interface { + PrepareUpdateUser(http.Context, *UpdateUserRequest) (context.Context, error) + CompleteUpdateUser(http.Context, *UpdateUserRequest, *UpdateUserResponse) error +} +type UserServiceUpdateUserRolesHooker interface { + PrepareUpdateUserRoles(http.Context, *UpdateUserRolesRequest) (context.Context, error) + CompleteUpdateUserRoles(http.Context, *UpdateUserRolesRequest, *UpdateUserRolesResponse) error +} +type UserServiceUpdateUserStatusHooker interface { + PrepareUpdateUserStatus(http.Context, *UpdateUserStatusRequest) (context.Context, error) + CompleteUpdateUserStatus(http.Context, *UpdateUserStatusRequest, *UpdateUserStatusResponse) error +} + +func RegisterUserServiceBridgeServer(s *http.Server, srv UserServiceHookedBridger) { + r := s.Route("/") + r.GET("/sys/users", _UserService_ListUsers0_Bridge_Handler(srv)) + r.GET("/sys/users/:id/resources", _UserService_ListUserResources0_Bridge_Handler(srv)) + r.GET("/sys/users/:id", _UserService_GetUser0_Bridge_Handler(srv)) + r.POST("/sys/users", _UserService_CreateUser0_Bridge_Handler(srv)) + r.PUT("/sys/users/:user.id", _UserService_UpdateUser0_Bridge_Handler(srv)) + r.DELETE("/sys/users/:user.id", _UserService_DeleteUser0_Bridge_Handler(srv)) + r.PUT("/sys/users/:user.id/status", _UserService_UpdateUserStatus0_Bridge_Handler(srv)) + r.PUT("/sys/users/:user.id/roles", _UserService_UpdateUserRoles0_Bridge_Handler(srv)) + r.POST("/sys/users/:id/password/reset", _UserService_ResetUserPassword0_Bridge_Handler(srv)) +} + +func _UserService_ListUsers0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListUsersRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceListUsers) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUsers(ctx, req.(*ListUsersRequest)) + }) + + newctx, err := srv.PrepareListUsers(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListUsers(ctx, &in, out.(*ListUsersResponse)) + } +} + +func _UserService_ListUserResources0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListUserResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceListUserResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUserResources(ctx, req.(*ListUserResourcesRequest)) + }) + + newctx, err := srv.PrepareListUserResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListUserResources(ctx, &in, out.(*ListUserResourcesResponse)) + } +} + +func _UserService_GetUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUserRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceGetUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUser(ctx, req.(*GetUserRequest)) + }) + + newctx, err := srv.PrepareGetUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetUser(ctx, &in, out.(*GetUserResponse)) + } +} + +func _UserService_CreateUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateUserRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceCreateUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateUser(ctx, req.(*CreateUserRequest)) + }) + + newctx, err := srv.PrepareCreateUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateUser(ctx, &in, out.(*CreateUserResponse)) + } +} + +func _UserService_UpdateUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUserRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceUpdateUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUser(ctx, req.(*UpdateUserRequest)) + }) + + newctx, err := srv.PrepareUpdateUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateUser(ctx, &in, out.(*UpdateUserResponse)) + } +} + +func _UserService_DeleteUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteUserRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceDeleteUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteUser(ctx, req.(*DeleteUserRequest)) + }) + + newctx, err := srv.PrepareDeleteUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteUser(ctx, &in, out.(*DeleteUserResponse)) + } +} + +func _UserService_UpdateUserStatus0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUserStatusRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceUpdateUserStatus) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUserStatus(ctx, req.(*UpdateUserStatusRequest)) + }) + + newctx, err := srv.PrepareUpdateUserStatus(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateUserStatus(ctx, &in, out.(*UpdateUserStatusResponse)) + } +} + +func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUserRolesRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceUpdateUserRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUserRoles(ctx, req.(*UpdateUserRolesRequest)) + }) + + newctx, err := srv.PrepareUpdateUserRoles(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateUserRoles(ctx, &in, out.(*UpdateUserRolesResponse)) + } +} + +func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ResetUserPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceResetUserPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ResetUserPassword(ctx, req.(*ResetUserPasswordRequest)) + }) + + newctx, err := srv.PrepareResetUserPassword(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteResetUserPassword(ctx, &in, out.(*ResetUserPasswordResponse)) + } +} + +// UnimplementedUserServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedUserServiceHooked struct{} + +func (UnimplementedUserServiceHooked) PrepareCreateUser(ctx http.Context, in *CreateUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceHooked) CompleteCreateUser(ctx http.Context, in *CreateUserRequest, out *CreateUserResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceHooked) PrepareDeleteUser(ctx http.Context, in *DeleteUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceHooked) CompleteDeleteUser(ctx http.Context, in *DeleteUserRequest, out *DeleteUserResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceHooked) PrepareGetUser(ctx http.Context, in *GetUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceHooked) CompleteGetUser(ctx http.Context, in *GetUserRequest, out *GetUserResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceHooked) PrepareListUserResources(ctx http.Context, in *ListUserResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceHooked) CompleteListUserResources(ctx http.Context, in *ListUserResourcesRequest, out *ListUserResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceHooked) PrepareListUsers(ctx http.Context, in *ListUsersRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceHooked) CompleteListUsers(ctx http.Context, in *ListUsersRequest, out *ListUsersResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceHooked) PrepareResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceHooked) CompleteResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest, out *ResetUserPasswordResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceHooked) PrepareUpdateUser(ctx http.Context, in *UpdateUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceHooked) CompleteUpdateUser(ctx http.Context, in *UpdateUserRequest, out *UpdateUserResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceHooked) PrepareUpdateUserRoles(ctx http.Context, in *UpdateUserRolesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceHooked) CompleteUpdateUserRoles(ctx http.Context, in *UpdateUserRolesRequest, out *UpdateUserRolesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedUserServiceHooked) PrepareUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedUserServiceHooked) CompleteUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest, out *UpdateUserStatusResponse) error { + return ctx.Result(200, out) +} + +func WithUserServiceHook(h UserServiceHooker) func(UserServiceBridgeServer) UserServiceHookedBridger { + return func(srv UserServiceBridgeServer) UserServiceHookedBridger { + return UserServiceHookedBridge{UserServiceBridgeServer: srv, UserServiceHooker: h} + } +} + +// UserServiceHookedBridge is a bridge between the HTTP and gRPC implementations of UserService. +// It implements the HTTP and gRPC implementations of UserService. +// It forwards requests and responses between the two implementations. +type UserServiceHookedBridge struct { + UserServiceBridgeServer + UserServiceHooker +} + +type UserServiceHTTPBridgeImpl struct { + client UserServiceHTTPClient +} + +func NewUserServiceHTTPBridge(client *http.Client) UserServiceHTTPServer { + return &UserServiceHTTPBridgeImpl{client: NewUserServiceHTTPClient(client)} +} + +func (c *UserServiceHTTPBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { + return c.client.GetUser(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { + return c.client.UpdateUserRoles(ctx, in) +} + +func (c *UserServiceHTTPBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) +} + +type UserServiceBridgeImpl struct { + client UserServiceClient +} + +func NewUserServiceBridge(client grpc.ClientConnInterface) UserServiceServer { + return &UserServiceBridgeImpl{client: NewUserServiceClient(client)} +} + +func (c *UserServiceBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *UserServiceBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +func (c *UserServiceBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { + return c.client.GetUser(ctx, in) +} + +func (c *UserServiceBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) +} + +func (c *UserServiceBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *UserServiceBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) +} + +func (c *UserServiceBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *UserServiceBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { + return c.client.UpdateUserRoles(ctx, in) +} + +func (c *UserServiceBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) +} + +func (c *UserServiceBridgeImpl) mustEmbedUnimplementedUserServiceServer() {} + +type UserServiceGRPC2HTTPBridgeImpl struct { + client UserServiceClient +} + +func NewUserServiceGRPC2HTTP(client grpc.ClientConnInterface) UserServiceHTTPServer { + return &UserServiceGRPC2HTTPBridgeImpl{client: NewUserServiceClient(client)} +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { + return c.client.GetUser(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { + return c.client.UpdateUserRoles(ctx, in) +} + +func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) +} + +type UserServiceHTTP2GRPCBridgeImpl struct { + client UserServiceHTTPClient +} + +func NewUserServiceHTTP2GRPC(client *http.Client) UserServiceServer { + return &UserServiceHTTP2GRPCBridgeImpl{client: NewUserServiceHTTPClient(client)} +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { + return c.client.GetUser(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { + return c.client.UpdateUserRoles(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) +} + +func (c *UserServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedUserServiceServer() {} diff --git a/api/v1/services/system/user_grpc.pb.go b/api/v1/services/system/user_grpc.pb.go new file mode 100644 index 00000000..042a4821 --- /dev/null +++ b/api/v1/services/system/user_grpc.pb.go @@ -0,0 +1,435 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: system/user.proto + +package system + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + UserService_ListUsers_FullMethodName = "/api.v1.services.system.UserService/ListUsers" + UserService_ListUserResources_FullMethodName = "/api.v1.services.system.UserService/ListUserResources" + UserService_GetUser_FullMethodName = "/api.v1.services.system.UserService/GetUser" + UserService_CreateUser_FullMethodName = "/api.v1.services.system.UserService/CreateUser" + UserService_UpdateUser_FullMethodName = "/api.v1.services.system.UserService/UpdateUser" + UserService_DeleteUser_FullMethodName = "/api.v1.services.system.UserService/DeleteUser" + UserService_UpdateUserStatus_FullMethodName = "/api.v1.services.system.UserService/UpdateUserStatus" + UserService_UpdateUserRoles_FullMethodName = "/api.v1.services.system.UserService/UpdateUserRoles" + UserService_ResetUserPassword_FullMethodName = "/api.v1.services.system.UserService/ResetUserPassword" +) + +// UserServiceClient is the client API for UserService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The login service definition. +type UserServiceClient interface { + ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error) + ListUserResources(ctx context.Context, in *ListUserResourcesRequest, opts ...grpc.CallOption) (*ListUserResourcesResponse, error) + GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) + CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error) + UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error) + DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*DeleteUserResponse, error) + // UpdateUserStatus Update the status of the user information + UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest, opts ...grpc.CallOption) (*UpdateUserStatusResponse, error) + // UpdateUserRoles update the user roles + UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest, opts ...grpc.CallOption) (*UpdateUserRolesResponse, error) + // ResetUserPassword reset the user s password + ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest, opts ...grpc.CallOption) (*ResetUserPasswordResponse, error) +} + +type userServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient { + return &userServiceClient{cc} +} + +func (c *userServiceClient) ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListUsersResponse) + err := c.cc.Invoke(ctx, UserService_ListUsers_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) ListUserResources(ctx context.Context, in *ListUserResourcesRequest, opts ...grpc.CallOption) (*ListUserResourcesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListUserResourcesResponse) + err := c.cc.Invoke(ctx, UserService_ListUserResources_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetUserResponse) + err := c.cc.Invoke(ctx, UserService_GetUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateUserResponse) + err := c.cc.Invoke(ctx, UserService_CreateUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateUserResponse) + err := c.cc.Invoke(ctx, UserService_UpdateUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*DeleteUserResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteUserResponse) + err := c.cc.Invoke(ctx, UserService_DeleteUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest, opts ...grpc.CallOption) (*UpdateUserStatusResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateUserStatusResponse) + err := c.cc.Invoke(ctx, UserService_UpdateUserStatus_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest, opts ...grpc.CallOption) (*UpdateUserRolesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateUserRolesResponse) + err := c.cc.Invoke(ctx, UserService_UpdateUserRoles_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest, opts ...grpc.CallOption) (*ResetUserPasswordResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ResetUserPasswordResponse) + err := c.cc.Invoke(ctx, UserService_ResetUserPassword_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// UserServiceServer is the server API for UserService service. +// All implementations must embed UnimplementedUserServiceServer +// for forward compatibility. +// +// The login service definition. +type UserServiceServer interface { + ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) + ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) + GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) + CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) + UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) + DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) + // UpdateUserStatus Update the status of the user information + UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) + // UpdateUserRoles update the user roles + UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) + // ResetUserPassword reset the user s password + ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) + mustEmbedUnimplementedUserServiceServer() +} + +// UnimplementedUserServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedUserServiceServer struct{} + +func (UnimplementedUserServiceServer) ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListUsers not implemented") +} +func (UnimplementedUserServiceServer) ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListUserResources not implemented") +} +func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented") +} +func (UnimplementedUserServiceServer) CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateUser not implemented") +} +func (UnimplementedUserServiceServer) UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateUser not implemented") +} +func (UnimplementedUserServiceServer) DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteUser not implemented") +} +func (UnimplementedUserServiceServer) UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateUserStatus not implemented") +} +func (UnimplementedUserServiceServer) UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateUserRoles not implemented") +} +func (UnimplementedUserServiceServer) ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ResetUserPassword not implemented") +} +func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {} +func (UnimplementedUserServiceServer) testEmbeddedByValue() {} + +// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to UserServiceServer will +// result in compilation errors. +type UnsafeUserServiceServer interface { + mustEmbedUnimplementedUserServiceServer() +} + +func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) { + // If the following call pancis, it indicates UnimplementedUserServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&UserService_ServiceDesc, srv) +} + +func _UserService_ListUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListUsersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).ListUsers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_ListUsers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).ListUsers(ctx, req.(*ListUsersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_ListUserResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListUserResourcesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).ListUserResources(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_ListUserResources_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).ListUserResources(ctx, req.(*ListUserResourcesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_GetUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetUser(ctx, req.(*GetUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).CreateUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_CreateUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).CreateUser(ctx, req.(*CreateUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).UpdateUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_UpdateUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).UpdateUser(ctx, req.(*UpdateUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).DeleteUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_DeleteUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).DeleteUser(ctx, req.(*DeleteUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_UpdateUserStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateUserStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).UpdateUserStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_UpdateUserStatus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).UpdateUserStatus(ctx, req.(*UpdateUserStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_UpdateUserRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateUserRolesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).UpdateUserRoles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_UpdateUserRoles_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).UpdateUserRoles(ctx, req.(*UpdateUserRolesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_ResetUserPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ResetUserPasswordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).ResetUserPassword(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: UserService_ResetUserPassword_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).ResetUserPassword(ctx, req.(*ResetUserPasswordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var UserService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.system.UserService", + HandlerType: (*UserServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListUsers", + Handler: _UserService_ListUsers_Handler, + }, + { + MethodName: "ListUserResources", + Handler: _UserService_ListUserResources_Handler, + }, + { + MethodName: "GetUser", + Handler: _UserService_GetUser_Handler, + }, + { + MethodName: "CreateUser", + Handler: _UserService_CreateUser_Handler, + }, + { + MethodName: "UpdateUser", + Handler: _UserService_UpdateUser_Handler, + }, + { + MethodName: "DeleteUser", + Handler: _UserService_DeleteUser_Handler, + }, + { + MethodName: "UpdateUserStatus", + Handler: _UserService_UpdateUserStatus_Handler, + }, + { + MethodName: "UpdateUserRoles", + Handler: _UserService_UpdateUserRoles_Handler, + }, + { + MethodName: "ResetUserPassword", + Handler: _UserService_ResetUserPassword_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "system/user.proto", +} diff --git a/api/v1/services/system/user_http.pb.go b/api/v1/services/system/user_http.pb.go new file mode 100644 index 00000000..4ab1e025 --- /dev/null +++ b/api/v1/services/system/user_http.pb.go @@ -0,0 +1,408 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: system/user.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationUserServiceCreateUser = "/api.v1.services.system.UserService/CreateUser" +const OperationUserServiceDeleteUser = "/api.v1.services.system.UserService/DeleteUser" +const OperationUserServiceGetUser = "/api.v1.services.system.UserService/GetUser" +const OperationUserServiceListUserResources = "/api.v1.services.system.UserService/ListUserResources" +const OperationUserServiceListUsers = "/api.v1.services.system.UserService/ListUsers" +const OperationUserServiceResetUserPassword = "/api.v1.services.system.UserService/ResetUserPassword" +const OperationUserServiceUpdateUser = "/api.v1.services.system.UserService/UpdateUser" +const OperationUserServiceUpdateUserRoles = "/api.v1.services.system.UserService/UpdateUserRoles" +const OperationUserServiceUpdateUserStatus = "/api.v1.services.system.UserService/UpdateUserStatus" + +type UserServiceHTTPServer interface { + CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) + DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) + GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) + ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) + ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) + // ResetUserPassword ResetUserPassword reset the user s password + ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) + UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) + // UpdateUserRoles UpdateUserRoles update the user roles + UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) + // UpdateUserStatus UpdateUserStatus Update the status of the user information + UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) +} + +func RegisterUserServiceHTTPServer(s *http.Server, srv UserServiceHTTPServer) { + r := s.Route("/") + r.GET("/sys/users", _UserService_ListUsers0_HTTP_Handler(srv)) + r.GET("/sys/users/{id}/resources", _UserService_ListUserResources0_HTTP_Handler(srv)) + r.GET("/sys/users/{id}", _UserService_GetUser0_HTTP_Handler(srv)) + r.POST("/sys/users", _UserService_CreateUser0_HTTP_Handler(srv)) + r.PUT("/sys/users/{user.id}", _UserService_UpdateUser0_HTTP_Handler(srv)) + r.DELETE("/sys/users/{user.id}", _UserService_DeleteUser0_HTTP_Handler(srv)) + r.PUT("/sys/users/{user.id}/status", _UserService_UpdateUserStatus0_HTTP_Handler(srv)) + r.PUT("/sys/users/{user.id}/roles", _UserService_UpdateUserRoles0_HTTP_Handler(srv)) + r.POST("/sys/users/{id}/password/reset", _UserService_ResetUserPassword0_HTTP_Handler(srv)) +} + +func _UserService_ListUsers0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListUsersRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceListUsers) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUsers(ctx, req.(*ListUsersRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListUsersResponse) + return ctx.Result(200, reply) + } +} + +func _UserService_ListUserResources0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListUserResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceListUserResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUserResources(ctx, req.(*ListUserResourcesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListUserResourcesResponse) + return ctx.Result(200, reply) + } +} + +func _UserService_GetUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUserRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceGetUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUser(ctx, req.(*GetUserRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetUserResponse) + return ctx.Result(200, reply) + } +} + +func _UserService_CreateUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateUserRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceCreateUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateUser(ctx, req.(*CreateUserRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateUserResponse) + return ctx.Result(200, reply) + } +} + +func _UserService_UpdateUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUserRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceUpdateUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUser(ctx, req.(*UpdateUserRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateUserResponse) + return ctx.Result(200, reply) + } +} + +func _UserService_DeleteUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteUserRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceDeleteUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteUser(ctx, req.(*DeleteUserRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeleteUserResponse) + return ctx.Result(200, reply) + } +} + +func _UserService_UpdateUserStatus0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUserStatusRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceUpdateUserStatus) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUserStatus(ctx, req.(*UpdateUserStatusRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateUserStatusResponse) + return ctx.Result(200, reply) + } +} + +func _UserService_UpdateUserRoles0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateUserRolesRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceUpdateUserRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUserRoles(ctx, req.(*UpdateUserRolesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateUserRolesResponse) + return ctx.Result(200, reply) + } +} + +func _UserService_ResetUserPassword0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ResetUserPasswordRequest + if err := ctx.Bind(&in.Data); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationUserServiceResetUserPassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ResetUserPassword(ctx, req.(*ResetUserPasswordRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ResetUserPasswordResponse) + return ctx.Result(200, reply) + } +} + +type UserServiceHTTPClient interface { + CreateUser(ctx context.Context, req *CreateUserRequest, opts ...http.CallOption) (rsp *CreateUserResponse, err error) + DeleteUser(ctx context.Context, req *DeleteUserRequest, opts ...http.CallOption) (rsp *DeleteUserResponse, err error) + GetUser(ctx context.Context, req *GetUserRequest, opts ...http.CallOption) (rsp *GetUserResponse, err error) + ListUserResources(ctx context.Context, req *ListUserResourcesRequest, opts ...http.CallOption) (rsp *ListUserResourcesResponse, err error) + ListUsers(ctx context.Context, req *ListUsersRequest, opts ...http.CallOption) (rsp *ListUsersResponse, err error) + // ResetUserPassword ResetUserPassword reset the user s password + ResetUserPassword(ctx context.Context, req *ResetUserPasswordRequest, opts ...http.CallOption) (rsp *ResetUserPasswordResponse, err error) + UpdateUser(ctx context.Context, req *UpdateUserRequest, opts ...http.CallOption) (rsp *UpdateUserResponse, err error) + // UpdateUserRoles UpdateUserRoles update the user roles + UpdateUserRoles(ctx context.Context, req *UpdateUserRolesRequest, opts ...http.CallOption) (rsp *UpdateUserRolesResponse, err error) + // UpdateUserStatus UpdateUserStatus Update the status of the user information + UpdateUserStatus(ctx context.Context, req *UpdateUserStatusRequest, opts ...http.CallOption) (rsp *UpdateUserStatusResponse, err error) +} + +type UserServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewUserServiceHTTPClient(client *http.Client) UserServiceHTTPClient { + return &UserServiceHTTPClientImpl{client} +} + +func (c *UserServiceHTTPClientImpl) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...http.CallOption) (*CreateUserResponse, error) { + var out CreateUserResponse + pattern := "/sys/users" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationUserServiceCreateUser)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.User, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UserServiceHTTPClientImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...http.CallOption) (*DeleteUserResponse, error) { + var out DeleteUserResponse + pattern := "/sys/users/{user.id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationUserServiceDeleteUser)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UserServiceHTTPClientImpl) GetUser(ctx context.Context, in *GetUserRequest, opts ...http.CallOption) (*GetUserResponse, error) { + var out GetUserResponse + pattern := "/sys/users/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationUserServiceGetUser)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UserServiceHTTPClientImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest, opts ...http.CallOption) (*ListUserResourcesResponse, error) { + var out ListUserResourcesResponse + pattern := "/sys/users/{id}/resources" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationUserServiceListUserResources)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UserServiceHTTPClientImpl) ListUsers(ctx context.Context, in *ListUsersRequest, opts ...http.CallOption) (*ListUsersResponse, error) { + var out ListUsersResponse + pattern := "/sys/users" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationUserServiceListUsers)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ResetUserPassword ResetUserPassword reset the user s password +func (c *UserServiceHTTPClientImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest, opts ...http.CallOption) (*ResetUserPasswordResponse, error) { + var out ResetUserPasswordResponse + pattern := "/sys/users/{id}/password/reset" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationUserServiceResetUserPassword)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *UserServiceHTTPClientImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...http.CallOption) (*UpdateUserResponse, error) { + var out UpdateUserResponse + pattern := "/sys/users/{user.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationUserServiceUpdateUser)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdateUserRoles UpdateUserRoles update the user roles +func (c *UserServiceHTTPClientImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest, opts ...http.CallOption) (*UpdateUserRolesResponse, error) { + var out UpdateUserRolesResponse + pattern := "/sys/users/{user.id}/roles" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationUserServiceUpdateUserRoles)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdateUserStatus UpdateUserStatus Update the status of the user information +func (c *UserServiceHTTPClientImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest, opts ...http.CallOption) (*UpdateUserStatusResponse, error) { + var out UpdateUserStatusResponse + pattern := "/sys/users/{user.id}/status" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationUserServiceUpdateUserStatus)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/types/auth_error.pb.go b/api/v1/services/types/auth_error.pb.go new file mode 100644 index 00000000..e05ea522 --- /dev/null +++ b/api/v1/services/types/auth_error.pb.go @@ -0,0 +1,131 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: types/auth_error.proto + +package types + +import ( + _ "github.com/go-kratos/kratos/v2/errors" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type AuthErrorReason int32 + +const ( + AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED AuthErrorReason = 0 + AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND AuthErrorReason = 2001 + AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED AuthErrorReason = 2002 +) + +// Enum value maps for AuthErrorReason. +var ( + AuthErrorReason_name = map[int32]string{ + 0: "AUTH_ERROR_REASON_UNSPECIFIED", + 2001: "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND", + 2002: "AUTH_ERROR_REASON_TOKEN_EXPIRED", + } + AuthErrorReason_value = map[string]int32{ + "AUTH_ERROR_REASON_UNSPECIFIED": 0, + "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND": 2001, + "AUTH_ERROR_REASON_TOKEN_EXPIRED": 2002, + } +) + +func (x AuthErrorReason) Enum() *AuthErrorReason { + p := new(AuthErrorReason) + *p = x + return p +} + +func (x AuthErrorReason) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (AuthErrorReason) Descriptor() protoreflect.EnumDescriptor { + return file_types_auth_error_proto_enumTypes[0].Descriptor() +} + +func (AuthErrorReason) Type() protoreflect.EnumType { + return &file_types_auth_error_proto_enumTypes[0] +} + +func (x AuthErrorReason) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use AuthErrorReason.Descriptor instead. +func (AuthErrorReason) EnumDescriptor() ([]byte, []int) { + return file_types_auth_error_proto_rawDescGZIP(), []int{0} +} + +var File_types_auth_error_proto protoreflect.FileDescriptor + +const file_types_auth_error_proto_rawDesc = "" + + "\n" + + "\x16types/auth_error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*\x96\x01\n" + + "\x0fAuthErrorReason\x12!\n" + + "\x1dAUTH_ERROR_REASON_UNSPECIFIED\x10\x00\x12.\n" + + "#AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x12*\n" + + "\x1fAUTH_ERROR_REASON_TOKEN_EXPIRED\x10\xd2\x0f\x1a\x04\xa8E\x91\x03\x1a\x04\xa0E\xf4\x03B\xdc\x01\n" + + "\x19com.api.v1.services.typesB\x0eAuthErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_auth_error_proto_rawDescOnce sync.Once + file_types_auth_error_proto_rawDescData []byte +) + +func file_types_auth_error_proto_rawDescGZIP() []byte { + file_types_auth_error_proto_rawDescOnce.Do(func() { + file_types_auth_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_auth_error_proto_rawDesc), len(file_types_auth_error_proto_rawDesc))) + }) + return file_types_auth_error_proto_rawDescData +} + +var file_types_auth_error_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_types_auth_error_proto_goTypes = []any{ + (AuthErrorReason)(0), // 0: api.v1.services.types.AuthErrorReason +} +var file_types_auth_error_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_types_auth_error_proto_init() } +func file_types_auth_error_proto_init() { + if File_types_auth_error_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_auth_error_proto_rawDesc), len(file_types_auth_error_proto_rawDesc)), + NumEnums: 1, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_auth_error_proto_goTypes, + DependencyIndexes: file_types_auth_error_proto_depIdxs, + EnumInfos: file_types_auth_error_proto_enumTypes, + }.Build() + File_types_auth_error_proto = out.File + file_types_auth_error_proto_goTypes = nil + file_types_auth_error_proto_depIdxs = nil +} diff --git a/api/v1/services/types/auth_error.pb.validate.go b/api/v1/services/types/auth_error.pb.validate.go new file mode 100644 index 00000000..f8f94fbd --- /dev/null +++ b/api/v1/services/types/auth_error.pb.validate.go @@ -0,0 +1,36 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/auth_error.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) diff --git a/api/v1/services/types/auth_error_errors.pb.go b/api/v1/services/types/auth_error_errors.pb.go new file mode 100644 index 00000000..b4915c00 --- /dev/null +++ b/api/v1/services/types/auth_error_errors.pb.go @@ -0,0 +1,48 @@ +// Code generated by protoc-gen-go-errors. DO NOT EDIT. + +package types + +import ( + fmt "fmt" + errors "github.com/go-kratos/kratos/v2/errors" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +const _ = errors.SupportPackageIsVersion1 + +func IsAuthErrorReasonUnspecified(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 +} + +func ErrorAuthErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { + return errors.New(500, AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) +} + +func IsAuthErrorReasonCaptchaNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String() && e.Code == 404 +} + +func ErrorAuthErrorReasonCaptchaNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(404, AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsAuthErrorReasonTokenExpired(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 +} + +func ErrorAuthErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { + return errors.New(401, AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) +} diff --git a/api/v1/services/types/datastore.pb.go b/api/v1/services/types/datastore.pb.go new file mode 100644 index 00000000..c97a2396 --- /dev/null +++ b/api/v1/services/types/datastore.pb.go @@ -0,0 +1,206 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: types/datastore.proto + +package types + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// DataObject is the model entity for the DataObject schema. +type DataObject struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // DeleteTime holds the value of the "delete_time" field. + DeleteTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=delete_time,proto3" json:"delete_time,omitempty"` + // Version holds the value of the "version" field. + Version int64 `protobuf:"varint,5,opt,name=version,proto3" json:"version,omitempty"` + // OwnerID holds the value of the "owner_id" field. + OwnerId string `protobuf:"bytes,6,opt,name=owner_id,proto3" json:"owner_id,omitempty"` + // Metadata holds the value of the "metadata" field. + Metadata map[string]string `protobuf:"bytes,7,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + // Payload holds the value of the "payload" field. + Payload []byte `protobuf:"bytes,8,opt,name=payload,proto3" json:"payload,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DataObject) Reset() { + *x = DataObject{} + mi := &file_types_datastore_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DataObject) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DataObject) ProtoMessage() {} + +func (x *DataObject) ProtoReflect() protoreflect.Message { + mi := &file_types_datastore_proto_msgTypes[0] + 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 DataObject.ProtoReflect.Descriptor instead. +func (*DataObject) Descriptor() ([]byte, []int) { + return file_types_datastore_proto_rawDescGZIP(), []int{0} +} + +func (x *DataObject) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DataObject) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *DataObject) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *DataObject) GetDeleteTime() *timestamppb.Timestamp { + if x != nil { + return x.DeleteTime + } + return nil +} + +func (x *DataObject) GetVersion() int64 { + if x != nil { + return x.Version + } + return 0 +} + +func (x *DataObject) GetOwnerId() string { + if x != nil { + return x.OwnerId + } + return "" +} + +func (x *DataObject) GetMetadata() map[string]string { + if x != nil { + return x.Metadata + } + return nil +} + +func (x *DataObject) GetPayload() []byte { + if x != nil { + return x.Payload + } + return nil +} + +var File_types_datastore_proto protoreflect.FileDescriptor + +const file_types_datastore_proto_rawDesc = "" + + "\n" + + "\x15types/datastore.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xb0\x03\n" + + "\n" + + "DataObject\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12<\n" + + "\vdelete_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\vdelete_time\x12\x18\n" + + "\aversion\x18\x05 \x01(\x03R\aversion\x12\x1a\n" + + "\bowner_id\x18\x06 \x01(\tR\bowner_id\x12K\n" + + "\bmetadata\x18\a \x03(\v2/.api.v1.services.types.DataObject.MetadataEntryR\bmetadata\x12\x18\n" + + "\apayload\x18\b \x01(\fR\apayload\x1a;\n" + + "\rMetadataEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01B\xdc\x01\n" + + "\x19com.api.v1.services.typesB\x0eDatastoreProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_datastore_proto_rawDescOnce sync.Once + file_types_datastore_proto_rawDescData []byte +) + +func file_types_datastore_proto_rawDescGZIP() []byte { + file_types_datastore_proto_rawDescOnce.Do(func() { + file_types_datastore_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_datastore_proto_rawDesc), len(file_types_datastore_proto_rawDesc))) + }) + return file_types_datastore_proto_rawDescData +} + +var file_types_datastore_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_types_datastore_proto_goTypes = []any{ + (*DataObject)(nil), // 0: api.v1.services.types.DataObject + nil, // 1: api.v1.services.types.DataObject.MetadataEntry + (*timestamppb.Timestamp)(nil), // 2: google.protobuf.Timestamp +} +var file_types_datastore_proto_depIdxs = []int32{ + 2, // 0: api.v1.services.types.DataObject.create_time:type_name -> google.protobuf.Timestamp + 2, // 1: api.v1.services.types.DataObject.update_time:type_name -> google.protobuf.Timestamp + 2, // 2: api.v1.services.types.DataObject.delete_time:type_name -> google.protobuf.Timestamp + 1, // 3: api.v1.services.types.DataObject.metadata:type_name -> api.v1.services.types.DataObject.MetadataEntry + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_types_datastore_proto_init() } +func file_types_datastore_proto_init() { + if File_types_datastore_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_datastore_proto_rawDesc), len(file_types_datastore_proto_rawDesc)), + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_datastore_proto_goTypes, + DependencyIndexes: file_types_datastore_proto_depIdxs, + MessageInfos: file_types_datastore_proto_msgTypes, + }.Build() + File_types_datastore_proto = out.File + file_types_datastore_proto_goTypes = nil + file_types_datastore_proto_depIdxs = nil +} diff --git a/api/v1/services/types/datastore.pb.validate.go b/api/v1/services/types/datastore.pb.validate.go new file mode 100644 index 00000000..4cd8afdc --- /dev/null +++ b/api/v1/services/types/datastore.pb.validate.go @@ -0,0 +1,232 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/datastore.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on DataObject 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 *DataObject) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DataObject 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 DataObjectMultiError, or +// nil if none found. +func (m *DataObject) ValidateAll() error { + return m.validate(true) +} + +func (m *DataObject) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DataObjectValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DataObjectValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetDeleteTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "DeleteTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DataObjectValidationError{ + field: "DeleteTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDeleteTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DataObjectValidationError{ + field: "DeleteTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Version + + // no validation rules for OwnerId + + // no validation rules for Metadata + + // no validation rules for Payload + + if len(errors) > 0 { + return DataObjectMultiError(errors) + } + + return nil +} + +// DataObjectMultiError is an error wrapping multiple validation errors +// returned by DataObject.ValidateAll() if the designated constraints aren't met. +type DataObjectMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DataObjectMultiError) 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 DataObjectMultiError) AllErrors() []error { return m } + +// DataObjectValidationError is the validation error returned by +// DataObject.Validate if the designated constraints aren't met. +type DataObjectValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DataObjectValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DataObjectValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DataObjectValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DataObjectValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DataObjectValidationError) ErrorName() string { return "DataObjectValidationError" } + +// Error satisfies the builtin error interface +func (e DataObjectValidationError) 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 %sDataObject.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DataObjectValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DataObjectValidationError{} diff --git a/api/v1/services/types/error.pb.go b/api/v1/services/types/error.pb.go new file mode 100644 index 00000000..ef7d92f7 --- /dev/null +++ b/api/v1/services/types/error.pb.go @@ -0,0 +1,128 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: types/error.proto + +package types + +import ( + _ "github.com/go-kratos/kratos/v2/errors" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ErrorReason int32 + +const ( + ErrorReason_ERROR_REASON_UNSPECIFIED ErrorReason = 0 + ErrorReason_ERROR_REASON_CUSTOMIZED ErrorReason = 1000 +) + +// Enum value maps for ErrorReason. +var ( + ErrorReason_name = map[int32]string{ + 0: "ERROR_REASON_UNSPECIFIED", + 1000: "ERROR_REASON_CUSTOMIZED", + } + ErrorReason_value = map[string]int32{ + "ERROR_REASON_UNSPECIFIED": 0, + "ERROR_REASON_CUSTOMIZED": 1000, + } +) + +func (x ErrorReason) Enum() *ErrorReason { + p := new(ErrorReason) + *p = x + return p +} + +func (x ErrorReason) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ErrorReason) Descriptor() protoreflect.EnumDescriptor { + return file_types_error_proto_enumTypes[0].Descriptor() +} + +func (ErrorReason) Type() protoreflect.EnumType { + return &file_types_error_proto_enumTypes[0] +} + +func (x ErrorReason) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ErrorReason.Descriptor instead. +func (ErrorReason) EnumDescriptor() ([]byte, []int) { + return file_types_error_proto_rawDescGZIP(), []int{0} +} + +var File_types_error_proto protoreflect.FileDescriptor + +const file_types_error_proto_rawDesc = "" + + "\n" + + "\x11types/error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*O\n" + + "\vErrorReason\x12\x1c\n" + + "\x18ERROR_REASON_UNSPECIFIED\x10\x00\x12\x1c\n" + + "\x17ERROR_REASON_CUSTOMIZED\x10\xe8\a\x1a\x04\xa0E\xf4\x03B\xd8\x01\n" + + "\x19com.api.v1.services.typesB\n" + + "ErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_error_proto_rawDescOnce sync.Once + file_types_error_proto_rawDescData []byte +) + +func file_types_error_proto_rawDescGZIP() []byte { + file_types_error_proto_rawDescOnce.Do(func() { + file_types_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_error_proto_rawDesc), len(file_types_error_proto_rawDesc))) + }) + return file_types_error_proto_rawDescData +} + +var file_types_error_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_types_error_proto_goTypes = []any{ + (ErrorReason)(0), // 0: api.v1.services.types.ErrorReason +} +var file_types_error_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_types_error_proto_init() } +func file_types_error_proto_init() { + if File_types_error_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_error_proto_rawDesc), len(file_types_error_proto_rawDesc)), + NumEnums: 1, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_error_proto_goTypes, + DependencyIndexes: file_types_error_proto_depIdxs, + EnumInfos: file_types_error_proto_enumTypes, + }.Build() + File_types_error_proto = out.File + file_types_error_proto_goTypes = nil + file_types_error_proto_depIdxs = nil +} diff --git a/api/v1/services/types/error.pb.validate.go b/api/v1/services/types/error.pb.validate.go new file mode 100644 index 00000000..c78c8d37 --- /dev/null +++ b/api/v1/services/types/error.pb.validate.go @@ -0,0 +1,36 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/error.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) diff --git a/api/v1/services/types/error_errors.pb.go b/api/v1/services/types/error_errors.pb.go new file mode 100644 index 00000000..ff776353 --- /dev/null +++ b/api/v1/services/types/error_errors.pb.go @@ -0,0 +1,36 @@ +// Code generated by protoc-gen-go-errors. DO NOT EDIT. + +package types + +import ( + fmt "fmt" + errors "github.com/go-kratos/kratos/v2/errors" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +const _ = errors.SupportPackageIsVersion1 + +func IsErrorReasonUnspecified(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == ErrorReason_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 +} + +func ErrorErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { + return errors.New(500, ErrorReason_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) +} + +func IsErrorReasonCustomized(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == ErrorReason_ERROR_REASON_CUSTOMIZED.String() && e.Code == 500 +} + +func ErrorErrorReasonCustomized(format string, args ...interface{}) *errors.Error { + return errors.New(500, ErrorReason_ERROR_REASON_CUSTOMIZED.String(), fmt.Sprintf(format, args...)) +} diff --git a/api/v1/services/types/message.pb.go b/api/v1/services/types/message.pb.go new file mode 100644 index 00000000..17b6aa72 --- /dev/null +++ b/api/v1/services/types/message.pb.go @@ -0,0 +1,128 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: types/message.proto + +package types + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + _ "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Message is the model entity for the Message schema. +// NOTE: This message definition is currently incomplete and only contains an ID field. +// It should be extended with actual message content as needed. +type Message struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Message) Reset() { + *x = Message{} + mi := &file_types_message_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_types_message_proto_msgTypes[0] + 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 Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_types_message_proto_rawDescGZIP(), []int{0} +} + +func (x *Message) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +var File_types_message_proto protoreflect.FileDescriptor + +const file_types_message_proto_rawDesc = "" + + "\n" + + "\x13types/message.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x19\n" + + "\aMessage\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02idB\xda\x01\n" + + "\x19com.api.v1.services.typesB\fMessageProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_message_proto_rawDescOnce sync.Once + file_types_message_proto_rawDescData []byte +) + +func file_types_message_proto_rawDescGZIP() []byte { + file_types_message_proto_rawDescOnce.Do(func() { + file_types_message_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_message_proto_rawDesc), len(file_types_message_proto_rawDesc))) + }) + return file_types_message_proto_rawDescData +} + +var file_types_message_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_types_message_proto_goTypes = []any{ + (*Message)(nil), // 0: api.v1.services.types.Message +} +var file_types_message_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_types_message_proto_init() } +func file_types_message_proto_init() { + if File_types_message_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_message_proto_rawDesc), len(file_types_message_proto_rawDesc)), + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_message_proto_goTypes, + DependencyIndexes: file_types_message_proto_depIdxs, + MessageInfos: file_types_message_proto_msgTypes, + }.Build() + File_types_message_proto = out.File + file_types_message_proto_goTypes = nil + file_types_message_proto_depIdxs = nil +} diff --git a/api/v1/services/types/message.pb.validate.go b/api/v1/services/types/message.pb.validate.go new file mode 100644 index 00000000..e03ac545 --- /dev/null +++ b/api/v1/services/types/message.pb.validate.go @@ -0,0 +1,136 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/message.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on Message 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 *Message) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Message 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 MessageMultiError, or nil if none found. +func (m *Message) ValidateAll() error { + return m.validate(true) +} + +func (m *Message) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return MessageMultiError(errors) + } + + return nil +} + +// MessageMultiError is an error wrapping multiple validation errors returned +// by Message.ValidateAll() if the designated constraints aren't met. +type MessageMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m MessageMultiError) 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 MessageMultiError) AllErrors() []error { return m } + +// MessageValidationError is the validation error returned by Message.Validate +// if the designated constraints aren't met. +type MessageValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e MessageValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e MessageValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e MessageValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e MessageValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e MessageValidationError) ErrorName() string { return "MessageValidationError" } + +// Error satisfies the builtin error interface +func (e MessageValidationError) 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 %sMessage.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = MessageValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = MessageValidationError{} diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go new file mode 100644 index 00000000..36899fd2 --- /dev/null +++ b/api/v1/services/types/system.pb.go @@ -0,0 +1,3205 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: types/system.proto + +package types + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Menu is the model entity for the Menu schema. +type Menu struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // Code holds the value of the "keyword" field. + Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` + // Name holds the value of the "name" field. + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + // I18nKey holds the value + I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` + // Description holds the value of the "description" field. + Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` + // Sequence holds the value of the "sequence" field. + Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` + // Type holds the value of the "type" field. + Type string `protobuf:"bytes,9,opt,name=type,proto3" json:"type,omitempty"` + // Icon holds the value of the "icon" field. + Icon string `protobuf:"bytes,10,opt,name=icon,proto3" json:"icon,omitempty"` + // Path holds the value of the "path" field. + Path string `protobuf:"bytes,11,opt,name=path,proto3" json:"path,omitempty"` + // Properties holds the value of the "properties" field. + Properties string `protobuf:"bytes,12,opt,name=properties,proto3" json:"properties,omitempty"` + // Status holds the value of the "status" field. + Status int32 `protobuf:"varint,13,opt,name=status,proto3" json:"status,omitempty"` + // ParentID holds the value of the "parent_id" field. + ParentId int64 `protobuf:"varint,14,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + // ParentPath holds the value of the "parent_path" field. + ParentPath string `protobuf:"bytes,15,opt,name=parent_path,proto3" json:"parent_path,omitempty"` + // Children holds the value of the children edge. + Children []*Menu `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Menu `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` + // Resources holds the value of the resources edge. + Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` + // Roles holds the value of the roles edge. + Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Menu) Reset() { + *x = Menu{} + mi := &file_types_system_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Menu) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Menu) ProtoMessage() {} + +func (x *Menu) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[0] + 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 Menu.ProtoReflect.Descriptor instead. +func (*Menu) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{0} +} + +func (x *Menu) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Menu) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Menu) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Menu) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Menu) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Menu) GetI18NKey() string { + if x != nil { + return x.I18NKey + } + return "" +} + +func (x *Menu) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Menu) GetSequence() int32 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *Menu) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Menu) GetIcon() string { + if x != nil { + return x.Icon + } + return "" +} + +func (x *Menu) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *Menu) GetProperties() string { + if x != nil { + return x.Properties + } + return "" +} + +func (x *Menu) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *Menu) GetParentId() int64 { + if x != nil { + return x.ParentId + } + return 0 +} + +func (x *Menu) GetParentPath() string { + if x != nil { + return x.ParentPath + } + return "" +} + +func (x *Menu) GetChildren() []*Menu { + if x != nil { + return x.Children + } + return nil +} + +func (x *Menu) GetParent() *Menu { + if x != nil { + return x.Parent + } + return nil +} + +func (x *Menu) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *Menu) GetRoles() []*Role { + if x != nil { + return x.Roles + } + return nil +} + +// MenuEdges holds the relations/edges for other nodes in the graph. +type MenuEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Children holds the value of the children edge. + Children []*Menu `protobuf:"bytes,1,rep,name=children,proto3" json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Menu `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` + // Resources holds the value of the resources edge. + Resources []*Resource `protobuf:"bytes,3,rep,name=resources,proto3" json:"resources,omitempty"` + // Roles holds the value of the roles edge. + Roles []*Role `protobuf:"bytes,4,rep,name=roles,proto3" json:"roles,omitempty"` + // RoleMenu holds the value of the role_menu edge. + RoleMenus []*RoleMenu `protobuf:"bytes,5,rep,name=role_menus,proto3" json:"role_menus,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *MenuEdges) Reset() { + *x = MenuEdges{} + mi := &file_types_system_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *MenuEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MenuEdges) ProtoMessage() {} + +func (x *MenuEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[1] + 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 MenuEdges.ProtoReflect.Descriptor instead. +func (*MenuEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{1} +} + +func (x *MenuEdges) GetChildren() []*Menu { + if x != nil { + return x.Children + } + return nil +} + +func (x *MenuEdges) GetParent() *Menu { + if x != nil { + return x.Parent + } + return nil +} + +func (x *MenuEdges) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *MenuEdges) GetRoles() []*Role { + if x != nil { + return x.Roles + } + return nil +} + +func (x *MenuEdges) GetRoleMenus() []*RoleMenu { + if x != nil { + return x.RoleMenus + } + return nil +} + +// Role is the model entity for the Role schema. +type Role struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // role.field.keyword + Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` + // role.field.name + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + // role.field.description + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + // role.field.type + Type int32 `protobuf:"varint,7,opt,name=type,proto3" json:"type,omitempty"` + // role.field.sequence + Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` + // role.field.status + Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"` + // role.field.is_types + IsTypes bool `protobuf:"varint,10,opt,name=is_types,proto3" json:"is_types,omitempty"` + // Menus holds the value of the menus edge. + Menus []*Menu `protobuf:"bytes,21,rep,name=menus,proto3" json:"menus,omitempty"` + // Users holds the value of the users edge. + Users []*User `protobuf:"bytes,22,rep,name=users,proto3" json:"users,omitempty"` + // Resources holds the value of the resources edge. + Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` + // Resource Ids holds the value of the resource_ids edge. + ResourceIds []int64 `protobuf:"varint,24,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` + // Permissions holds the value of the permissions edge. + Permissions []*Permission `protobuf:"bytes,25,rep,name=permissions,proto3" json:"permissions,omitempty"` + // Permission Ids holds the value of the permission_ids edge. + PermissionIds []int64 `protobuf:"varint,26,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Role) Reset() { + *x = Role{} + mi := &file_types_system_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Role) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Role) ProtoMessage() {} + +func (x *Role) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[2] + 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 Role.ProtoReflect.Descriptor instead. +func (*Role) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{2} +} + +func (x *Role) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Role) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Role) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Role) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Role) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Role) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Role) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *Role) GetSequence() int32 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *Role) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *Role) GetIsTypes() bool { + if x != nil { + return x.IsTypes + } + return false +} + +func (x *Role) GetMenus() []*Menu { + if x != nil { + return x.Menus + } + return nil +} + +func (x *Role) GetUsers() []*User { + if x != nil { + return x.Users + } + return nil +} + +func (x *Role) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *Role) GetResourceIds() []int64 { + if x != nil { + return x.ResourceIds + } + return nil +} + +func (x *Role) GetPermissions() []*Permission { + if x != nil { + return x.Permissions + } + return nil +} + +func (x *Role) GetPermissionIds() []int64 { + if x != nil { + return x.PermissionIds + } + return nil +} + +// RoleEdges holds the relations/edges for other nodes in the graph. +type RoleEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Menus holds the value of the menus edge. + Menus []*Menu `protobuf:"bytes,1,rep,name=menus,proto3" json:"menus,omitempty"` + // Users holds the value of the users edge. + Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` + // RoleMenu holds the value of the role_menu edge. + RoleMenus []*RoleMenu `protobuf:"bytes,3,rep,name=role_menus,proto3" json:"role_menus,omitempty"` + // UserRole holds the value of the user_role edge. + UserRoles []*UserRole `protobuf:"bytes,4,rep,name=user_roles,proto3" json:"user_roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleEdges) Reset() { + *x = RoleEdges{} + mi := &file_types_system_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleEdges) ProtoMessage() {} + +func (x *RoleEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[3] + 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 RoleEdges.ProtoReflect.Descriptor instead. +func (*RoleEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{3} +} + +func (x *RoleEdges) GetMenus() []*Menu { + if x != nil { + return x.Menus + } + return nil +} + +func (x *RoleEdges) GetUsers() []*User { + if x != nil { + return x.Users + } + return nil +} + +func (x *RoleEdges) GetRoleMenus() []*RoleMenu { + if x != nil { + return x.RoleMenus + } + return nil +} + +func (x *RoleEdges) GetUserRoles() []*UserRole { + if x != nil { + return x.UserRoles + } + return nil +} + +// User is the model entity for the User schema. +type User struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_author.field.comment + CreateAuthor int64 `protobuf:"varint,2,opt,name=create_author,proto3" json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `protobuf:"varint,3,opt,name=update_author,proto3" json:"update_author,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=update_time,proto3" json:"update_time,omitempty"` + // user.field.uuid + Uuid string `protobuf:"bytes,6,opt,name=uuid,proto3" json:"uuid,omitempty"` + // user.field.allowed_ip + AllowedIp string `protobuf:"bytes,7,opt,name=allowed_ip,proto3" json:"allowed_ip,omitempty"` + // user.field.username + Username string `protobuf:"bytes,8,opt,name=username,proto3" json:"username,omitempty"` + // user.field.nickname + Nickname string `protobuf:"bytes,9,opt,name=nickname,proto3" json:"nickname,omitempty"` + // user.field.avatar + Avatar string `protobuf:"bytes,10,opt,name=avatar,proto3" json:"avatar,omitempty"` + // user.field.nickname + Name string `protobuf:"bytes,11,opt,name=name,proto3" json:"name,omitempty"` + // user.field.gender + Gender string `protobuf:"bytes,12,opt,name=gender,proto3" json:"gender,omitempty"` + // user.field.password + // @Decrypted don't show this field in response + Password string `protobuf:"bytes,13,opt,name=password,proto3" json:"password,omitempty"` + // user.field.confirm_password + ConfirmPassword string `protobuf:"bytes,14,opt,name=confirm_password,proto3" json:"confirm_password,omitempty"` + // user.field.salt + // @Decrypted don't show this field in response + Salt string `protobuf:"bytes,15,opt,name=salt,proto3" json:"salt,omitempty"` + // user.field.phone + Phone string `protobuf:"bytes,16,opt,name=phone,proto3" json:"phone,omitempty"` + // user.field.email + Email string `protobuf:"bytes,17,opt,name=email,proto3" json:"email,omitempty"` + // user.field.remark + Remark string `protobuf:"bytes,18,opt,name=remark,proto3" json:"remark,omitempty"` + // user.field.token + Token string `protobuf:"bytes,19,opt,name=token,proto3" json:"token,omitempty"` + // user.field.status + Status int32 `protobuf:"varint,20,opt,name=status,proto3" json:"status,omitempty"` + // user.field.last_login_ip + LastLoginIp string `protobuf:"bytes,21,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` + // user.field.last_login_time + LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` + // user.field.sanction_date + SanctionDate *timestamppb.Timestamp `protobuf:"bytes,23,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` + // user.field.manager_id + ManagerId int64 `protobuf:"varint,24,opt,name=manager_id,proto3" json:"manager_id,omitempty"` + // user.field.manager + Manager string `protobuf:"bytes,25,opt,name=manager,proto3" json:"manager,omitempty"` + // Roles holds the value of the roles edge. + Roles []*Role `protobuf:"bytes,26,rep,name=roles,proto3" json:"roles,omitempty"` + // Role Ids holds the value of the role_ids + RoleIds []int64 `protobuf:"varint,27,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *User) Reset() { + *x = User{} + mi := &file_types_system_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *User) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*User) ProtoMessage() {} + +func (x *User) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[4] + 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 User.ProtoReflect.Descriptor instead. +func (*User) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{4} +} + +func (x *User) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *User) GetCreateAuthor() int64 { + if x != nil { + return x.CreateAuthor + } + return 0 +} + +func (x *User) GetUpdateAuthor() int64 { + if x != nil { + return x.UpdateAuthor + } + return 0 +} + +func (x *User) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *User) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *User) GetUuid() string { + if x != nil { + return x.Uuid + } + return "" +} + +func (x *User) GetAllowedIp() string { + if x != nil { + return x.AllowedIp + } + return "" +} + +func (x *User) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *User) GetNickname() string { + if x != nil { + return x.Nickname + } + return "" +} + +func (x *User) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *User) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *User) GetGender() string { + if x != nil { + return x.Gender + } + return "" +} + +func (x *User) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +func (x *User) GetConfirmPassword() string { + if x != nil { + return x.ConfirmPassword + } + return "" +} + +func (x *User) GetSalt() string { + if x != nil { + return x.Salt + } + return "" +} + +func (x *User) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +func (x *User) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *User) GetRemark() string { + if x != nil { + return x.Remark + } + return "" +} + +func (x *User) GetToken() string { + if x != nil { + return x.Token + } + return "" +} + +func (x *User) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *User) GetLastLoginIp() string { + if x != nil { + return x.LastLoginIp + } + return "" +} + +func (x *User) GetLastLoginTime() *timestamppb.Timestamp { + if x != nil { + return x.LastLoginTime + } + return nil +} + +func (x *User) GetSanctionDate() *timestamppb.Timestamp { + if x != nil { + return x.SanctionDate + } + return nil +} + +func (x *User) GetManagerId() int64 { + if x != nil { + return x.ManagerId + } + return 0 +} + +func (x *User) GetManager() string { + if x != nil { + return x.Manager + } + return "" +} + +func (x *User) GetRoles() []*Role { + if x != nil { + return x.Roles + } + return nil +} + +func (x *User) GetRoleIds() []int64 { + if x != nil { + return x.RoleIds + } + return nil +} + +// UserEdges holds the relations/edges for other nodes in the graph. +type UserEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Roles holds the value of the roles edge. + Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + // UserRole holds the value of the user_role edge. + UserRoles []*UserRole `protobuf:"bytes,2,rep,name=user_roles,proto3" json:"user_roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserEdges) Reset() { + *x = UserEdges{} + mi := &file_types_system_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserEdges) ProtoMessage() {} + +func (x *UserEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[5] + 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 UserEdges.ProtoReflect.Descriptor instead. +func (*UserEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{5} +} + +func (x *UserEdges) GetRoles() []*Role { + if x != nil { + return x.Roles + } + return nil +} + +func (x *UserEdges) GetUserRoles() []*UserRole { + if x != nil { + return x.UserRoles + } + return nil +} + +// UserRole is the model entity for the UserRole schema. +type UserRole struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // UserID holds the value of the "user_id" field. + UserId int64 `protobuf:"varint,4,opt,name=user_id,proto3" json:"user_id,omitempty"` + // RoleID holds the value of the "role_id" field. + RoleId int64 `protobuf:"varint,5,opt,name=role_id,proto3" json:"role_id,omitempty"` + // RoleName holds the value of the "role_name" field. + RoleName string `protobuf:"bytes,6,opt,name=role_name,proto3" json:"role_name,omitempty"` + // User holds the value of the user edge. + User *User `protobuf:"bytes,21,opt,name=user,proto3" json:"user,omitempty"` + // Role holds the value of the role edge. + Role *Role `protobuf:"bytes,22,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserRole) Reset() { + *x = UserRole{} + mi := &file_types_system_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserRole) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserRole) ProtoMessage() {} + +func (x *UserRole) ProtoReflect() protoreflect.Message { + mi := &file_types_system_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 UserRole.ProtoReflect.Descriptor instead. +func (*UserRole) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{6} +} + +func (x *UserRole) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UserRole) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *UserRole) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *UserRole) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *UserRole) GetRoleId() int64 { + if x != nil { + return x.RoleId + } + return 0 +} + +func (x *UserRole) GetRoleName() string { + if x != nil { + return x.RoleName + } + return "" +} + +func (x *UserRole) GetUser() *User { + if x != nil { + return x.User + } + return nil +} + +func (x *UserRole) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +// UserRoleEdges holds the relations/edges for other nodes in the graph. +type UserRoleEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // User holds the value of the user edge. + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // Role holds the value of the role edge. + Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserRoleEdges) Reset() { + *x = UserRoleEdges{} + mi := &file_types_system_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserRoleEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserRoleEdges) ProtoMessage() {} + +func (x *UserRoleEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserRoleEdges.ProtoReflect.Descriptor instead. +func (*UserRoleEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{7} +} + +func (x *UserRoleEdges) GetUser() *User { + if x != nil { + return x.User + } + return nil +} + +func (x *UserRoleEdges) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +// RoleMenu is the model entity for the RoleMenu schema. +type RoleMenu struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // CreateTime holds the value of the "create_time" field. + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // UpdateTime holds the value of the "update_time" field. + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // RoleID holds the value of the "role_id" field. + RoleId int64 `protobuf:"varint,4,opt,name=role_id,proto3" json:"role_id,omitempty"` + // MenuID holds the value of the "menu_id" field. + MenuId int64 `protobuf:"varint,5,opt,name=menu_id,proto3" json:"menu_id,omitempty"` + // Role holds the value of the role edge. + Role *Role `protobuf:"bytes,21,opt,name=role,proto3" json:"role,omitempty"` + // Menu holds the value of the menu edge. + Menu *Menu `protobuf:"bytes,22,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleMenu) Reset() { + *x = RoleMenu{} + mi := &file_types_system_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleMenu) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleMenu) ProtoMessage() {} + +func (x *RoleMenu) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[8] + 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 RoleMenu.ProtoReflect.Descriptor instead. +func (*RoleMenu) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{8} +} + +func (x *RoleMenu) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *RoleMenu) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *RoleMenu) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *RoleMenu) GetRoleId() int64 { + if x != nil { + return x.RoleId + } + return 0 +} + +func (x *RoleMenu) GetMenuId() int64 { + if x != nil { + return x.MenuId + } + return 0 +} + +func (x *RoleMenu) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +func (x *RoleMenu) GetMenu() *Menu { + if x != nil { + return x.Menu + } + return nil +} + +// RoleMenuEdges holds the relations/edges for other nodes in the graph. +type RoleMenuEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Role holds the value of the role edge. + Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + // Menu holds the value of the menu edge. + Menu *Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RoleMenuEdges) Reset() { + *x = RoleMenuEdges{} + mi := &file_types_system_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RoleMenuEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RoleMenuEdges) ProtoMessage() {} + +func (x *RoleMenuEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[9] + 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 RoleMenuEdges.ProtoReflect.Descriptor instead. +func (*RoleMenuEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{9} +} + +func (x *RoleMenuEdges) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +func (x *RoleMenuEdges) GetMenu() *Menu { + if x != nil { + return x.Menu + } + return nil +} + +// Resource is the model entity for the Resource schema. +type Resource struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // resource.field.name + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // resource.field.keyword + Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` + // resource.field.i18n_key + I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` + // resource.field.type + Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + // resource.field.status + Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` + // resource.field.path + Path string `protobuf:"bytes,9,opt,name=path,proto3" json:"path,omitempty"` + // resource.field.operation + Operation string `protobuf:"bytes,10,opt,name=operation,proto3" json:"operation,omitempty"` + // resource.field.method + Method string `protobuf:"bytes,11,opt,name=method,proto3" json:"method,omitempty"` + // resource.field.component + Component string `protobuf:"bytes,12,opt,name=component,proto3" json:"component,omitempty"` + // resource.field.icon + Icon string `protobuf:"bytes,13,opt,name=icon,proto3" json:"icon,omitempty"` + // resource.field.sequence + Sequence int32 `protobuf:"varint,14,opt,name=sequence,proto3" json:"sequence,omitempty"` + // resource.field.visible + Visible bool `protobuf:"varint,15,opt,name=visible,proto3" json:"visible,omitempty"` + // resource.field.tree_path + TreePath string `protobuf:"bytes,16,opt,name=tree_path,proto3" json:"tree_path,omitempty"` + // resource.field.properties + Properties map[string]string `protobuf:"bytes,17,rep,name=properties,proto3" json:"properties,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + // resource.field.description + Description string `protobuf:"bytes,18,opt,name=description,proto3" json:"description,omitempty"` + // resource.field.parent_id + ParentId int64 `protobuf:"varint,19,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + // Children holds the value of the children edge. + Children []*Resource `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Resource `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` + // Permission Ids holds the value of the permission_ids edge. + PermissionIds []int64 `protobuf:"varint,23,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` + // Permissions holds the value of the permissions edge. + Permissions []*Permission `protobuf:"bytes,24,rep,name=permissions,proto3" json:"permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Resource) Reset() { + *x = Resource{} + mi := &file_types_system_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Resource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resource) ProtoMessage() {} + +func (x *Resource) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[10] + 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 Resource.ProtoReflect.Descriptor instead. +func (*Resource) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{10} +} + +func (x *Resource) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Resource) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Resource) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Resource) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Resource) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Resource) GetI18NKey() string { + if x != nil { + return x.I18NKey + } + return "" +} + +func (x *Resource) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *Resource) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *Resource) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *Resource) GetOperation() string { + if x != nil { + return x.Operation + } + return "" +} + +func (x *Resource) GetMethod() string { + if x != nil { + return x.Method + } + return "" +} + +func (x *Resource) GetComponent() string { + if x != nil { + return x.Component + } + return "" +} + +func (x *Resource) GetIcon() string { + if x != nil { + return x.Icon + } + return "" +} + +func (x *Resource) GetSequence() int32 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *Resource) GetVisible() bool { + if x != nil { + return x.Visible + } + return false +} + +func (x *Resource) GetTreePath() string { + if x != nil { + return x.TreePath + } + return "" +} + +func (x *Resource) GetProperties() map[string]string { + if x != nil { + return x.Properties + } + return nil +} + +func (x *Resource) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Resource) GetParentId() int64 { + if x != nil { + return x.ParentId + } + return 0 +} + +func (x *Resource) GetChildren() []*Resource { + if x != nil { + return x.Children + } + return nil +} + +func (x *Resource) GetParent() *Resource { + if x != nil { + return x.Parent + } + return nil +} + +func (x *Resource) GetPermissionIds() []int64 { + if x != nil { + return x.PermissionIds + } + return nil +} + +func (x *Resource) GetPermissions() []*Permission { + if x != nil { + return x.Permissions + } + return nil +} + +// ResourceEdges holds the relations/edges for other nodes in the graph. +type ResourceEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Menu holds the value of the menu edge. + Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ResourceEdges) Reset() { + *x = ResourceEdges{} + mi := &file_types_system_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ResourceEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResourceEdges) ProtoMessage() {} + +func (x *ResourceEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[11] + 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 ResourceEdges.ProtoReflect.Descriptor instead. +func (*ResourceEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{11} +} + +func (x *ResourceEdges) GetMenu() *Menu { + if x != nil { + return x.Menu + } + return nil +} + +// department.table.comment +type Department struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // department.field.keyword + Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` + // department.field.name + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + // menu.field.tree_path + TreePath string `protobuf:"bytes,6,opt,name=tree_path,proto3" json:"tree_path,omitempty"` + // department.field.sequence + Sequence int32 `protobuf:"varint,7,opt,name=sequence,proto3" json:"sequence,omitempty"` + // department.field.status + Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` + // department.field.level + Level int32 `protobuf:"varint,9,opt,name=level,proto3" json:"level,omitempty"` + // department.field.description + Description string `protobuf:"bytes,10,opt,name=description,proto3" json:"description,omitempty"` + // department.field.parent_id + ParentId int64 `protobuf:"varint,11,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + // Children holds the value of the children edge. + Children []*Department `protobuf:"bytes,12,rep,name=children,proto3" json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Department `protobuf:"bytes,13,opt,name=parent,proto3" json:"parent,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Department) Reset() { + *x = Department{} + mi := &file_types_system_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Department) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Department) ProtoMessage() {} + +func (x *Department) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[12] + 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 Department.ProtoReflect.Descriptor instead. +func (*Department) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{12} +} + +func (x *Department) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Department) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Department) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Department) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Department) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Department) GetTreePath() string { + if x != nil { + return x.TreePath + } + return "" +} + +func (x *Department) GetSequence() int32 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *Department) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *Department) GetLevel() int32 { + if x != nil { + return x.Level + } + return 0 +} + +func (x *Department) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Department) GetParentId() int64 { + if x != nil { + return x.ParentId + } + return 0 +} + +func (x *Department) GetChildren() []*Department { + if x != nil { + return x.Children + } + return nil +} + +func (x *Department) GetParent() *Department { + if x != nil { + return x.Parent + } + return nil +} + +type DepartmentEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Users holds the value of the users edge. + Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` + // Positions holds the value of the positions edge. + Positions []*Position `protobuf:"bytes,2,rep,name=positions,proto3" json:"positions,omitempty"` + // Children holds the value of the children edge. + Children []*Department `protobuf:"bytes,3,rep,name=children,proto3" json:"children,omitempty"` + // Parent holds the value of the parent edge. + Parent *Department `protobuf:"bytes,4,opt,name=parent,proto3" json:"parent,omitempty"` + // UserDepartments holds the value of the user_departments edge. + UserDepartments []*UserDepartment `protobuf:"bytes,5,rep,name=user_departments,proto3" json:"user_departments,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DepartmentEdges) Reset() { + *x = DepartmentEdges{} + mi := &file_types_system_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DepartmentEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DepartmentEdges) ProtoMessage() {} + +func (x *DepartmentEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[13] + 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 DepartmentEdges.ProtoReflect.Descriptor instead. +func (*DepartmentEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{13} +} + +func (x *DepartmentEdges) GetUsers() []*User { + if x != nil { + return x.Users + } + return nil +} + +func (x *DepartmentEdges) GetPositions() []*Position { + if x != nil { + return x.Positions + } + return nil +} + +func (x *DepartmentEdges) GetChildren() []*Department { + if x != nil { + return x.Children + } + return nil +} + +func (x *DepartmentEdges) GetParent() *Department { + if x != nil { + return x.Parent + } + return nil +} + +func (x *DepartmentEdges) GetUserDepartments() []*UserDepartment { + if x != nil { + return x.UserDepartments + } + return nil +} + +// user_department.table.comment +type UserDepartment struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // field.foreign_key.comment + UserId int64 `protobuf:"varint,2,opt,name=user_id,proto3" json:"user_id,omitempty"` + // field.foreign_key.comment + DepartmentId int64 `protobuf:"varint,3,opt,name=department_id,proto3" json:"department_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the UserDepartmentQuery when eager-loading is set. + Edges *UserDepartmentEdges `protobuf:"bytes,4,opt,name=edges,proto3" json:"edges,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserDepartment) Reset() { + *x = UserDepartment{} + mi := &file_types_system_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserDepartment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserDepartment) ProtoMessage() {} + +func (x *UserDepartment) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[14] + 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 UserDepartment.ProtoReflect.Descriptor instead. +func (*UserDepartment) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{14} +} + +func (x *UserDepartment) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UserDepartment) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *UserDepartment) GetDepartmentId() int64 { + if x != nil { + return x.DepartmentId + } + return 0 +} + +func (x *UserDepartment) GetEdges() *UserDepartmentEdges { + if x != nil { + return x.Edges + } + return nil +} + +// UserDepartmentEdges holds the relations/edges for other nodes in the graph. +type UserDepartmentEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // User holds the value of the user edge. + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // Department holds the value of the department edge. + Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserDepartmentEdges) Reset() { + *x = UserDepartmentEdges{} + mi := &file_types_system_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserDepartmentEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserDepartmentEdges) ProtoMessage() {} + +func (x *UserDepartmentEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[15] + 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 UserDepartmentEdges.ProtoReflect.Descriptor instead. +func (*UserDepartmentEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{15} +} + +func (x *UserDepartmentEdges) GetUser() *User { + if x != nil { + return x.User + } + return nil +} + +func (x *UserDepartmentEdges) GetDepartment() *Department { + if x != nil { + return x.Department + } + return nil +} + +// position.table.comment +type Position struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // position.field.name + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // position.field.keyword + Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` + // position.field.description + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + // department.field.department_id + DepartmentId int64 `protobuf:"varint,7,opt,name=department_id,proto3" json:"department_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Position) Reset() { + *x = Position{} + mi := &file_types_system_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Position) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Position) ProtoMessage() {} + +func (x *Position) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[16] + 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 Position.ProtoReflect.Descriptor instead. +func (*Position) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{16} +} + +func (x *Position) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Position) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Position) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Position) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Position) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Position) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Position) GetDepartmentId() int64 { + if x != nil { + return x.DepartmentId + } + return 0 +} + +// PositionEdges holds the relations/edges for other nodes in the graph. +type PositionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Department holds the value of the department edge. + Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + // Users holds the value of the users edge. + Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` + // Permissions holds the value of the permissions edge. + Permissions []*Permission `protobuf:"bytes,3,rep,name=permissions,proto3" json:"permissions,omitempty"` + // UserPositions holds the value of the user_positions edge. + UserPositions []*UserPosition `protobuf:"bytes,4,rep,name=user_positions,proto3" json:"user_positions,omitempty"` + // PositionPermissions holds the value of the position_permissions edge. + PositionPermissions []*PositionPermission `protobuf:"bytes,5,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PositionEdges) Reset() { + *x = PositionEdges{} + mi := &file_types_system_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PositionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PositionEdges) ProtoMessage() {} + +func (x *PositionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[17] + 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 PositionEdges.ProtoReflect.Descriptor instead. +func (*PositionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{17} +} + +func (x *PositionEdges) GetDepartment() *Department { + if x != nil { + return x.Department + } + return nil +} + +func (x *PositionEdges) GetUsers() []*User { + if x != nil { + return x.Users + } + return nil +} + +func (x *PositionEdges) GetPermissions() []*Permission { + if x != nil { + return x.Permissions + } + return nil +} + +func (x *PositionEdges) GetUserPositions() []*UserPosition { + if x != nil { + return x.UserPositions + } + return nil +} + +func (x *PositionEdges) GetPositionPermissions() []*PositionPermission { + if x != nil { + return x.PositionPermissions + } + return nil +} + +// permission.table.comment +type Permission struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // permission.field.name + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + // permission.field.keyword + Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` + // permission.field.description + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + // permission.field.data_scope + DataScope string `protobuf:"bytes,7,opt,name=data_scope,proto3" json:"data_scope,omitempty"` + // permission.field.data_rules + DataRules map[string]string `protobuf:"bytes,8,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + // permission.field.resource_ids + ResourceIds []int64 `protobuf:"varint,9,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` + // permission.field.resources + Resources []*Resource `protobuf:"bytes,10,rep,name=resources,proto3" json:"resources,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Permission) Reset() { + *x = Permission{} + mi := &file_types_system_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Permission) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Permission) ProtoMessage() {} + +func (x *Permission) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Permission.ProtoReflect.Descriptor instead. +func (*Permission) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{18} +} + +func (x *Permission) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Permission) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *Permission) GetUpdateTime() *timestamppb.Timestamp { + if x != nil { + return x.UpdateTime + } + return nil +} + +func (x *Permission) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Permission) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *Permission) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Permission) GetDataScope() string { + if x != nil { + return x.DataScope + } + return "" +} + +func (x *Permission) GetDataRules() map[string]string { + if x != nil { + return x.DataRules + } + return nil +} + +func (x *Permission) GetResourceIds() []int64 { + if x != nil { + return x.ResourceIds + } + return nil +} + +func (x *Permission) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +// PermissionEdges holds the relations/edges for other nodes in the graph. +type PermissionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Roles holds the value of the roles edge. + Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + // Resources holds the value of the resources edge. + Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + // Positions holds the value of the positions edge. + Positions []*Position `protobuf:"bytes,3,rep,name=positions,proto3" json:"positions,omitempty"` + // RolePermissions holds the value of the role_permissions edge. + RolePermissions []*RolePermission `protobuf:"bytes,4,rep,name=role_permissions,proto3" json:"role_permissions,omitempty"` + // PermissionResources holds the value of the permission_resources edge. + PermissionResources []*PermissionResource `protobuf:"bytes,5,rep,name=permission_resources,proto3" json:"permission_resources,omitempty"` + // PositionPermissions holds the value of the position_permissions edge. + PositionPermissions []*PositionPermission `protobuf:"bytes,6,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PermissionEdges) Reset() { + *x = PermissionEdges{} + mi := &file_types_system_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PermissionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PermissionEdges) ProtoMessage() {} + +func (x *PermissionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PermissionEdges.ProtoReflect.Descriptor instead. +func (*PermissionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{19} +} + +func (x *PermissionEdges) GetRoles() []*Role { + if x != nil { + return x.Roles + } + return nil +} + +func (x *PermissionEdges) GetResources() []*Resource { + if x != nil { + return x.Resources + } + return nil +} + +func (x *PermissionEdges) GetPositions() []*Position { + if x != nil { + return x.Positions + } + return nil +} + +func (x *PermissionEdges) GetRolePermissions() []*RolePermission { + if x != nil { + return x.RolePermissions + } + return nil +} + +func (x *PermissionEdges) GetPermissionResources() []*PermissionResource { + if x != nil { + return x.PermissionResources + } + return nil +} + +func (x *PermissionEdges) GetPositionPermissions() []*PositionPermission { + if x != nil { + return x.PositionPermissions + } + return nil +} + +// user_position.table.comment +type UserPosition struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // field.foreign_key.comment + UserId int64 `protobuf:"varint,2,opt,name=user_id,proto3" json:"user_id,omitempty"` + // field.foreign_key.comment + PositionId int64 `protobuf:"varint,3,opt,name=position_id,proto3" json:"position_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserPosition) Reset() { + *x = UserPosition{} + mi := &file_types_system_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserPosition) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserPosition) ProtoMessage() {} + +func (x *UserPosition) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserPosition.ProtoReflect.Descriptor instead. +func (*UserPosition) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{20} +} + +func (x *UserPosition) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UserPosition) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *UserPosition) GetPositionId() int64 { + if x != nil { + return x.PositionId + } + return 0 +} + +// UserPositionEdges holds the relations/edges for other nodes in the graph. +type UserPositionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // User holds the value of the user edge. + User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // Position holds the value of the position edge. + Position *Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UserPositionEdges) Reset() { + *x = UserPositionEdges{} + mi := &file_types_system_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UserPositionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserPositionEdges) ProtoMessage() {} + +func (x *UserPositionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[21] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserPositionEdges.ProtoReflect.Descriptor instead. +func (*UserPositionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{21} +} + +func (x *UserPositionEdges) GetUser() *User { + if x != nil { + return x.User + } + return nil +} + +func (x *UserPositionEdges) GetPosition() *Position { + if x != nil { + return x.Position + } + return nil +} + +// position_permission.table.comment +type PositionPermission struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // position_permission.field.position_id + PositionId int64 `protobuf:"varint,2,opt,name=position_id,proto3" json:"position_id,omitempty"` + // position_permission.field.permission_id + PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PositionPermission) Reset() { + *x = PositionPermission{} + mi := &file_types_system_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PositionPermission) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PositionPermission) ProtoMessage() {} + +func (x *PositionPermission) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[22] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PositionPermission.ProtoReflect.Descriptor instead. +func (*PositionPermission) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{22} +} + +func (x *PositionPermission) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *PositionPermission) GetPositionId() int64 { + if x != nil { + return x.PositionId + } + return 0 +} + +func (x *PositionPermission) GetPermissionId() int64 { + if x != nil { + return x.PermissionId + } + return 0 +} + +// PositionPermissionEdges holds the relations/edges for other nodes in the graph. +type PositionPermissionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Position holds the value of the position edge. + Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` + // Permission holds the value of the permission edge. + Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PositionPermissionEdges) Reset() { + *x = PositionPermissionEdges{} + mi := &file_types_system_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PositionPermissionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PositionPermissionEdges) ProtoMessage() {} + +func (x *PositionPermissionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[23] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PositionPermissionEdges.ProtoReflect.Descriptor instead. +func (*PositionPermissionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{23} +} + +func (x *PositionPermissionEdges) GetPosition() *Position { + if x != nil { + return x.Position + } + return nil +} + +func (x *PositionPermissionEdges) GetPermission() *Permission { + if x != nil { + return x.Permission + } + return nil +} + +// role_permission.table.comment +type RolePermission struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // field.foreign_key.comment + RoleId int64 `protobuf:"varint,2,opt,name=role_id,proto3" json:"role_id,omitempty"` + // field.foreign_key.comment + PermissionId int64 `protobuf:"varint,3,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RolePermission) Reset() { + *x = RolePermission{} + mi := &file_types_system_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RolePermission) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RolePermission) ProtoMessage() {} + +func (x *RolePermission) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[24] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RolePermission.ProtoReflect.Descriptor instead. +func (*RolePermission) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{24} +} + +func (x *RolePermission) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *RolePermission) GetRoleId() int64 { + if x != nil { + return x.RoleId + } + return 0 +} + +func (x *RolePermission) GetPermissionId() int64 { + if x != nil { + return x.PermissionId + } + return 0 +} + +// RolePermissionEdges holds the relations/edges for other nodes in the graph. +type RolePermissionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Role holds the value of the role edge. + Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` + // Permission holds the value of the permission edge. + Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RolePermissionEdges) Reset() { + *x = RolePermissionEdges{} + mi := &file_types_system_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RolePermissionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RolePermissionEdges) ProtoMessage() {} + +func (x *RolePermissionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_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 RolePermissionEdges.ProtoReflect.Descriptor instead. +func (*RolePermissionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{25} +} + +func (x *RolePermissionEdges) GetRole() *Role { + if x != nil { + return x.Role + } + return nil +} + +func (x *RolePermissionEdges) GetPermission() *Permission { + if x != nil { + return x.Permission + } + return nil +} + +// permission_resource.table.comment +type PermissionResource struct { + state protoimpl.MessageState `protogen:"open.v1"` + // ID of the ent. + // field.primary_key.comment + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // field.foreign_key.comment + PermissionId int64 `protobuf:"varint,2,opt,name=permission_id,proto3" json:"permission_id,omitempty"` + // field.foreign_key.comment + ResourceId int64 `protobuf:"varint,3,opt,name=resource_id,proto3" json:"resource_id,omitempty"` + // permission_resource.field.actions + Actions string `protobuf:"bytes,4,opt,name=actions,proto3" json:"actions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PermissionResource) Reset() { + *x = PermissionResource{} + mi := &file_types_system_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PermissionResource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PermissionResource) ProtoMessage() {} + +func (x *PermissionResource) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[26] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PermissionResource.ProtoReflect.Descriptor instead. +func (*PermissionResource) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{26} +} + +func (x *PermissionResource) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *PermissionResource) GetPermissionId() int64 { + if x != nil { + return x.PermissionId + } + return 0 +} + +func (x *PermissionResource) GetResourceId() int64 { + if x != nil { + return x.ResourceId + } + return 0 +} + +func (x *PermissionResource) GetActions() string { + if x != nil { + return x.Actions + } + return "" +} + +// PermissionResourceEdges holds the relations/edges for other nodes in the graph. +type PermissionResourceEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Permission holds the value of the permission edge. + Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` + // Resource holds the value of the resource edge. + Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PermissionResourceEdges) Reset() { + *x = PermissionResourceEdges{} + mi := &file_types_system_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PermissionResourceEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PermissionResourceEdges) ProtoMessage() {} + +func (x *PermissionResourceEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[27] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PermissionResourceEdges.ProtoReflect.Descriptor instead. +func (*PermissionResourceEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{27} +} + +func (x *PermissionResourceEdges) GetPermission() *Permission { + if x != nil { + return x.Permission + } + return nil +} + +func (x *PermissionResourceEdges) GetResource() *Resource { + if x != nil { + return x.Resource + } + return nil +} + +var File_types_system_proto protoreflect.FileDescriptor + +const file_types_system_proto_rawDesc = "" + + "\n" + + "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xae\x05\n" + + "\x04Menu\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12\x1a\n" + + "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12 \n" + + "\vdescription\x18\a \x01(\tR\vdescription\x12\x1a\n" + + "\bsequence\x18\b \x01(\x05R\bsequence\x12\x12\n" + + "\x04type\x18\t \x01(\tR\x04type\x12\x12\n" + + "\x04icon\x18\n" + + " \x01(\tR\x04icon\x12\x12\n" + + "\x04path\x18\v \x01(\tR\x04path\x12\x1e\n" + + "\n" + + "properties\x18\f \x01(\tR\n" + + "properties\x12\x16\n" + + "\x06status\x18\r \x01(\x05R\x06status\x12\x1c\n" + + "\tparent_id\x18\x0e \x01(\x03R\tparent_id\x12 \n" + + "\vparent_path\x18\x0f \x01(\tR\vparent_path\x127\n" + + "\bchildren\x18\x15 \x03(\v2\x1b.api.v1.services.types.MenuR\bchildren\x123\n" + + "\x06parent\x18\x16 \x01(\v2\x1b.api.v1.services.types.MenuR\x06parent\x12=\n" + + "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + + "\x05roles\x18\x18 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xac\x02\n" + + "\tMenuEdges\x127\n" + + "\bchildren\x18\x01 \x03(\v2\x1b.api.v1.services.types.MenuR\bchildren\x123\n" + + "\x06parent\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x06parent\x12=\n" + + "\tresources\x18\x03 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + + "\x05roles\x18\x04 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12?\n" + + "\n" + + "role_menus\x18\x05 \x03(\v2\x1f.api.v1.services.types.RoleMenuR\n" + + "role_menus\"\xfc\x04\n" + + "\x04Role\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x12\n" + + "\x04type\x18\a \x01(\x05R\x04type\x12\x1a\n" + + "\bsequence\x18\b \x01(\x05R\bsequence\x12\x16\n" + + "\x06status\x18\t \x01(\x05R\x06status\x12\x1a\n" + + "\bis_types\x18\n" + + " \x01(\bR\bis_types\x121\n" + + "\x05menus\x18\x15 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x121\n" + + "\x05users\x18\x16 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + + "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\"\n" + + "\fresource_ids\x18\x18 \x03(\x03R\fresource_ids\x12C\n" + + "\vpermissions\x18\x19 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12&\n" + + "\x0epermission_ids\x18\x1a \x03(\x03R\x0epermission_ids\"\xf3\x01\n" + + "\tRoleEdges\x121\n" + + "\x05menus\x18\x01 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x121\n" + + "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12?\n" + + "\n" + + "role_menus\x18\x03 \x03(\v2\x1f.api.v1.services.types.RoleMenuR\n" + + "role_menus\x12?\n" + + "\n" + + "user_roles\x18\x04 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + + "user_roles\"\xaa\a\n" + + "\x04User\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + + "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + + "\rupdate_author\x18\x03 \x01(\x03R\rupdate_author\x12<\n" + + "\vcreate_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04uuid\x18\x06 \x01(\tR\x04uuid\x12\x1e\n" + + "\n" + + "allowed_ip\x18\a \x01(\tR\n" + + "allowed_ip\x12\x1a\n" + + "\busername\x18\b \x01(\tR\busername\x12\x1a\n" + + "\bnickname\x18\t \x01(\tR\bnickname\x12\x16\n" + + "\x06avatar\x18\n" + + " \x01(\tR\x06avatar\x12\x12\n" + + "\x04name\x18\v \x01(\tR\x04name\x12\x16\n" + + "\x06gender\x18\f \x01(\tR\x06gender\x12\x1a\n" + + "\bpassword\x18\r \x01(\tR\bpassword\x12*\n" + + "\x10confirm_password\x18\x0e \x01(\tR\x10confirm_password\x12\x12\n" + + "\x04salt\x18\x0f \x01(\tR\x04salt\x12\x14\n" + + "\x05phone\x18\x10 \x01(\tR\x05phone\x12\x14\n" + + "\x05email\x18\x11 \x01(\tR\x05email\x12\x16\n" + + "\x06remark\x18\x12 \x01(\tR\x06remark\x12\x14\n" + + "\x05token\x18\x13 \x01(\tR\x05token\x12\x16\n" + + "\x06status\x18\x14 \x01(\x05R\x06status\x12$\n" + + "\rlast_login_ip\x18\x15 \x01(\tR\rlast_login_ip\x12D\n" + + "\x0flast_login_time\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12E\n" + + "\rsanction_date\x18\x17 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x12\x1e\n" + + "\n" + + "manager_id\x18\x18 \x01(\x03R\n" + + "manager_id\x12\x18\n" + + "\amanager\x18\x19 \x01(\tR\amanager\x121\n" + + "\x05roles\x18\x1a \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + + "\brole_ids\x18\x1b \x03(\x03R\brole_idsB\x10\n" + + "\x0e_sanction_date\"\x7f\n" + + "\tUserEdges\x121\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12?\n" + + "\n" + + "user_roles\x18\x02 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + + "user_roles\"\xca\x02\n" + + "\bUserRole\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\auser_id\x18\x04 \x01(\x03R\auser_id\x12\x18\n" + + "\arole_id\x18\x05 \x01(\x03R\arole_id\x12\x1c\n" + + "\trole_name\x18\x06 \x01(\tR\trole_name\x12/\n" + + "\x04user\x18\x15 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + + "\x04role\x18\x16 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"q\n" + + "\rUserRoleEdges\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + + "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\xac\x02\n" + + "\bRoleMenu\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\arole_id\x18\x04 \x01(\x03R\arole_id\x12\x18\n" + + "\amenu_id\x18\x05 \x01(\x03R\amenu_id\x12/\n" + + "\x04role\x18\x15 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + + "\x04menu\x18\x16 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"q\n" + + "\rRoleMenuEdges\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + + "\x04menu\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"\x8f\a\n" + + "\bResource\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x1a\n" + + "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12\x12\n" + + "\x04type\x18\a \x01(\tR\x04type\x12\x16\n" + + "\x06status\x18\b \x01(\x05R\x06status\x12\x12\n" + + "\x04path\x18\t \x01(\tR\x04path\x12\x1c\n" + + "\toperation\x18\n" + + " \x01(\tR\toperation\x12\x16\n" + + "\x06method\x18\v \x01(\tR\x06method\x12\x1c\n" + + "\tcomponent\x18\f \x01(\tR\tcomponent\x12\x12\n" + + "\x04icon\x18\r \x01(\tR\x04icon\x12\x1a\n" + + "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x18\n" + + "\avisible\x18\x0f \x01(\bR\avisible\x12\x1c\n" + + "\ttree_path\x18\x10 \x01(\tR\ttree_path\x12O\n" + + "\n" + + "properties\x18\x11 \x03(\v2/.api.v1.services.types.Resource.PropertiesEntryR\n" + + "properties\x12 \n" + + "\vdescription\x18\x12 \x01(\tR\vdescription\x12\x1c\n" + + "\tparent_id\x18\x13 \x01(\x03R\tparent_id\x12;\n" + + "\bchildren\x18\x15 \x03(\v2\x1f.api.v1.services.types.ResourceR\bchildren\x127\n" + + "\x06parent\x18\x16 \x01(\v2\x1f.api.v1.services.types.ResourceR\x06parent\x12&\n" + + "\x0epermission_ids\x18\x17 \x03(\x03R\x0epermission_ids\x12C\n" + + "\vpermissions\x18\x18 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x1a=\n" + + "\x0fPropertiesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"@\n" + + "\rResourceEdges\x12/\n" + + "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"\xe8\x03\n" + + "\n" + + "Department\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12\x1c\n" + + "\ttree_path\x18\x06 \x01(\tR\ttree_path\x12\x1a\n" + + "\bsequence\x18\a \x01(\x05R\bsequence\x12\x16\n" + + "\x06status\x18\b \x01(\x05R\x06status\x12\x14\n" + + "\x05level\x18\t \x01(\x05R\x05level\x12 \n" + + "\vdescription\x18\n" + + " \x01(\tR\vdescription\x12\x1c\n" + + "\tparent_id\x18\v \x01(\x03R\tparent_id\x12=\n" + + "\bchildren\x18\f \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + + "\x06parent\x18\r \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\"\xd0\x02\n" + + "\x0fDepartmentEdges\x121\n" + + "\x05users\x18\x01 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + + "\tpositions\x18\x02 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12=\n" + + "\bchildren\x18\x03 \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + + "\x06parent\x18\x04 \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\x12Q\n" + + "\x10user_departments\x18\x05 \x03(\v2%.api.v1.services.types.UserDepartmentR\x10user_departments\"\xa2\x01\n" + + "\x0eUserDepartment\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\auser_id\x18\x02 \x01(\x03R\auser_id\x12$\n" + + "\rdepartment_id\x18\x03 \x01(\x03R\rdepartment_id\x12@\n" + + "\x05edges\x18\x04 \x01(\v2*.api.v1.services.types.UserDepartmentEdgesR\x05edges\"\x89\x01\n" + + "\x13UserDepartmentEdges\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12A\n" + + "\n" + + "department\x18\x02 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\"\x8c\x02\n" + + "\bPosition\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12$\n" + + "\rdepartment_id\x18\a \x01(\x03R\rdepartment_id\"\xf6\x02\n" + + "\rPositionEdges\x12A\n" + + "\n" + + "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\x121\n" + + "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12C\n" + + "\vpermissions\x18\x03 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12K\n" + + "\x0euser_positions\x18\x04 \x03(\v2#.api.v1.services.types.UserPositionR\x0euser_positions\x12]\n" + + "\x14position_permissions\x18\x05 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"\xfb\x03\n" + + "\n" + + "Permission\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x1e\n" + + "\n" + + "data_scope\x18\a \x01(\tR\n" + + "data_scope\x12P\n" + + "\n" + + "data_rules\x18\b \x03(\v20.api.v1.services.types.Permission.DataRulesEntryR\n" + + "data_rules\x12\"\n" + + "\fresource_ids\x18\t \x03(\x03R\fresource_ids\x12=\n" + + "\tresources\x18\n" + + " \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x1a<\n" + + "\x0eDataRulesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xd3\x03\n" + + "\x0fPermissionEdges\x121\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12=\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12=\n" + + "\tpositions\x18\x03 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12Q\n" + + "\x10role_permissions\x18\x04 \x03(\v2%.api.v1.services.types.RolePermissionR\x10role_permissions\x12]\n" + + "\x14permission_resources\x18\x05 \x03(\v2).api.v1.services.types.PermissionResourceR\x14permission_resources\x12]\n" + + "\x14position_permissions\x18\x06 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"Z\n" + + "\fUserPosition\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\auser_id\x18\x02 \x01(\x03R\auser_id\x12 \n" + + "\vposition_id\x18\x03 \x01(\x03R\vposition_id\"\x81\x01\n" + + "\x11UserPositionEdges\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12;\n" + + "\bposition\x18\x02 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"l\n" + + "\x12PositionPermission\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12 \n" + + "\vposition_id\x18\x02 \x01(\x03R\vposition_id\x12$\n" + + "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x99\x01\n" + + "\x17PositionPermissionEdges\x12;\n" + + "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\x12A\n" + + "\n" + + "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"`\n" + + "\x0eRolePermission\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + + "\arole_id\x18\x02 \x01(\x03R\arole_id\x12$\n" + + "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x89\x01\n" + + "\x13RolePermissionEdges\x12/\n" + + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12A\n" + + "\n" + + "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\"\x86\x01\n" + + "\x12PermissionResource\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + + "\rpermission_id\x18\x02 \x01(\x03R\rpermission_id\x12 \n" + + "\vresource_id\x18\x03 \x01(\x03R\vresource_id\x12\x18\n" + + "\aactions\x18\x04 \x01(\tR\aactions\"\x99\x01\n" + + "\x17PermissionResourceEdges\x12A\n" + + "\n" + + "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + + "permission\x12;\n" + + "\bresource\x18\x02 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresourceB\xd9\x01\n" + + "\x19com.api.v1.services.typesB\vSystemProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_system_proto_rawDescOnce sync.Once + file_types_system_proto_rawDescData []byte +) + +func file_types_system_proto_rawDescGZIP() []byte { + file_types_system_proto_rawDescOnce.Do(func() { + file_types_system_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_system_proto_rawDesc), len(file_types_system_proto_rawDesc))) + }) + return file_types_system_proto_rawDescData +} + +var file_types_system_proto_msgTypes = make([]protoimpl.MessageInfo, 30) +var file_types_system_proto_goTypes = []any{ + (*Menu)(nil), // 0: api.v1.services.types.Menu + (*MenuEdges)(nil), // 1: api.v1.services.types.MenuEdges + (*Role)(nil), // 2: api.v1.services.types.Role + (*RoleEdges)(nil), // 3: api.v1.services.types.RoleEdges + (*User)(nil), // 4: api.v1.services.types.User + (*UserEdges)(nil), // 5: api.v1.services.types.UserEdges + (*UserRole)(nil), // 6: api.v1.services.types.UserRole + (*UserRoleEdges)(nil), // 7: api.v1.services.types.UserRoleEdges + (*RoleMenu)(nil), // 8: api.v1.services.types.RoleMenu + (*RoleMenuEdges)(nil), // 9: api.v1.services.types.RoleMenuEdges + (*Resource)(nil), // 10: api.v1.services.types.Resource + (*ResourceEdges)(nil), // 11: api.v1.services.types.ResourceEdges + (*Department)(nil), // 12: api.v1.services.types.Department + (*DepartmentEdges)(nil), // 13: api.v1.services.types.DepartmentEdges + (*UserDepartment)(nil), // 14: api.v1.services.types.UserDepartment + (*UserDepartmentEdges)(nil), // 15: api.v1.services.types.UserDepartmentEdges + (*Position)(nil), // 16: api.v1.services.types.Position + (*PositionEdges)(nil), // 17: api.v1.services.types.PositionEdges + (*Permission)(nil), // 18: api.v1.services.types.Permission + (*PermissionEdges)(nil), // 19: api.v1.services.types.PermissionEdges + (*UserPosition)(nil), // 20: api.v1.services.types.UserPosition + (*UserPositionEdges)(nil), // 21: api.v1.services.types.UserPositionEdges + (*PositionPermission)(nil), // 22: api.v1.services.types.PositionPermission + (*PositionPermissionEdges)(nil), // 23: api.v1.services.types.PositionPermissionEdges + (*RolePermission)(nil), // 24: api.v1.services.types.RolePermission + (*RolePermissionEdges)(nil), // 25: api.v1.services.types.RolePermissionEdges + (*PermissionResource)(nil), // 26: api.v1.services.types.PermissionResource + (*PermissionResourceEdges)(nil), // 27: api.v1.services.types.PermissionResourceEdges + nil, // 28: api.v1.services.types.Resource.PropertiesEntry + nil, // 29: api.v1.services.types.Permission.DataRulesEntry + (*timestamppb.Timestamp)(nil), // 30: google.protobuf.Timestamp +} +var file_types_system_proto_depIdxs = []int32{ + 30, // 0: api.v1.services.types.Menu.create_time:type_name -> google.protobuf.Timestamp + 30, // 1: api.v1.services.types.Menu.update_time:type_name -> google.protobuf.Timestamp + 0, // 2: api.v1.services.types.Menu.children:type_name -> api.v1.services.types.Menu + 0, // 3: api.v1.services.types.Menu.parent:type_name -> api.v1.services.types.Menu + 10, // 4: api.v1.services.types.Menu.resources:type_name -> api.v1.services.types.Resource + 2, // 5: api.v1.services.types.Menu.roles:type_name -> api.v1.services.types.Role + 0, // 6: api.v1.services.types.MenuEdges.children:type_name -> api.v1.services.types.Menu + 0, // 7: api.v1.services.types.MenuEdges.parent:type_name -> api.v1.services.types.Menu + 10, // 8: api.v1.services.types.MenuEdges.resources:type_name -> api.v1.services.types.Resource + 2, // 9: api.v1.services.types.MenuEdges.roles:type_name -> api.v1.services.types.Role + 8, // 10: api.v1.services.types.MenuEdges.role_menus:type_name -> api.v1.services.types.RoleMenu + 30, // 11: api.v1.services.types.Role.create_time:type_name -> google.protobuf.Timestamp + 30, // 12: api.v1.services.types.Role.update_time:type_name -> google.protobuf.Timestamp + 0, // 13: api.v1.services.types.Role.menus:type_name -> api.v1.services.types.Menu + 4, // 14: api.v1.services.types.Role.users:type_name -> api.v1.services.types.User + 10, // 15: api.v1.services.types.Role.resources:type_name -> api.v1.services.types.Resource + 18, // 16: api.v1.services.types.Role.permissions:type_name -> api.v1.services.types.Permission + 0, // 17: api.v1.services.types.RoleEdges.menus:type_name -> api.v1.services.types.Menu + 4, // 18: api.v1.services.types.RoleEdges.users:type_name -> api.v1.services.types.User + 8, // 19: api.v1.services.types.RoleEdges.role_menus:type_name -> api.v1.services.types.RoleMenu + 6, // 20: api.v1.services.types.RoleEdges.user_roles:type_name -> api.v1.services.types.UserRole + 30, // 21: api.v1.services.types.User.create_time:type_name -> google.protobuf.Timestamp + 30, // 22: api.v1.services.types.User.update_time:type_name -> google.protobuf.Timestamp + 30, // 23: api.v1.services.types.User.last_login_time:type_name -> google.protobuf.Timestamp + 30, // 24: api.v1.services.types.User.sanction_date:type_name -> google.protobuf.Timestamp + 2, // 25: api.v1.services.types.User.roles:type_name -> api.v1.services.types.Role + 2, // 26: api.v1.services.types.UserEdges.roles:type_name -> api.v1.services.types.Role + 6, // 27: api.v1.services.types.UserEdges.user_roles:type_name -> api.v1.services.types.UserRole + 30, // 28: api.v1.services.types.UserRole.create_time:type_name -> google.protobuf.Timestamp + 30, // 29: api.v1.services.types.UserRole.update_time:type_name -> google.protobuf.Timestamp + 4, // 30: api.v1.services.types.UserRole.user:type_name -> api.v1.services.types.User + 2, // 31: api.v1.services.types.UserRole.role:type_name -> api.v1.services.types.Role + 4, // 32: api.v1.services.types.UserRoleEdges.user:type_name -> api.v1.services.types.User + 2, // 33: api.v1.services.types.UserRoleEdges.role:type_name -> api.v1.services.types.Role + 30, // 34: api.v1.services.types.RoleMenu.create_time:type_name -> google.protobuf.Timestamp + 30, // 35: api.v1.services.types.RoleMenu.update_time:type_name -> google.protobuf.Timestamp + 2, // 36: api.v1.services.types.RoleMenu.role:type_name -> api.v1.services.types.Role + 0, // 37: api.v1.services.types.RoleMenu.menu:type_name -> api.v1.services.types.Menu + 2, // 38: api.v1.services.types.RoleMenuEdges.role:type_name -> api.v1.services.types.Role + 0, // 39: api.v1.services.types.RoleMenuEdges.menu:type_name -> api.v1.services.types.Menu + 30, // 40: api.v1.services.types.Resource.create_time:type_name -> google.protobuf.Timestamp + 30, // 41: api.v1.services.types.Resource.update_time:type_name -> google.protobuf.Timestamp + 28, // 42: api.v1.services.types.Resource.properties:type_name -> api.v1.services.types.Resource.PropertiesEntry + 10, // 43: api.v1.services.types.Resource.children:type_name -> api.v1.services.types.Resource + 10, // 44: api.v1.services.types.Resource.parent:type_name -> api.v1.services.types.Resource + 18, // 45: api.v1.services.types.Resource.permissions:type_name -> api.v1.services.types.Permission + 0, // 46: api.v1.services.types.ResourceEdges.menu:type_name -> api.v1.services.types.Menu + 30, // 47: api.v1.services.types.Department.create_time:type_name -> google.protobuf.Timestamp + 30, // 48: api.v1.services.types.Department.update_time:type_name -> google.protobuf.Timestamp + 12, // 49: api.v1.services.types.Department.children:type_name -> api.v1.services.types.Department + 12, // 50: api.v1.services.types.Department.parent:type_name -> api.v1.services.types.Department + 4, // 51: api.v1.services.types.DepartmentEdges.users:type_name -> api.v1.services.types.User + 16, // 52: api.v1.services.types.DepartmentEdges.positions:type_name -> api.v1.services.types.Position + 12, // 53: api.v1.services.types.DepartmentEdges.children:type_name -> api.v1.services.types.Department + 12, // 54: api.v1.services.types.DepartmentEdges.parent:type_name -> api.v1.services.types.Department + 14, // 55: api.v1.services.types.DepartmentEdges.user_departments:type_name -> api.v1.services.types.UserDepartment + 15, // 56: api.v1.services.types.UserDepartment.edges:type_name -> api.v1.services.types.UserDepartmentEdges + 4, // 57: api.v1.services.types.UserDepartmentEdges.user:type_name -> api.v1.services.types.User + 12, // 58: api.v1.services.types.UserDepartmentEdges.department:type_name -> api.v1.services.types.Department + 30, // 59: api.v1.services.types.Position.create_time:type_name -> google.protobuf.Timestamp + 30, // 60: api.v1.services.types.Position.update_time:type_name -> google.protobuf.Timestamp + 12, // 61: api.v1.services.types.PositionEdges.department:type_name -> api.v1.services.types.Department + 4, // 62: api.v1.services.types.PositionEdges.users:type_name -> api.v1.services.types.User + 18, // 63: api.v1.services.types.PositionEdges.permissions:type_name -> api.v1.services.types.Permission + 20, // 64: api.v1.services.types.PositionEdges.user_positions:type_name -> api.v1.services.types.UserPosition + 22, // 65: api.v1.services.types.PositionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission + 30, // 66: api.v1.services.types.Permission.create_time:type_name -> google.protobuf.Timestamp + 30, // 67: api.v1.services.types.Permission.update_time:type_name -> google.protobuf.Timestamp + 29, // 68: api.v1.services.types.Permission.data_rules:type_name -> api.v1.services.types.Permission.DataRulesEntry + 10, // 69: api.v1.services.types.Permission.resources:type_name -> api.v1.services.types.Resource + 2, // 70: api.v1.services.types.PermissionEdges.roles:type_name -> api.v1.services.types.Role + 10, // 71: api.v1.services.types.PermissionEdges.resources:type_name -> api.v1.services.types.Resource + 16, // 72: api.v1.services.types.PermissionEdges.positions:type_name -> api.v1.services.types.Position + 24, // 73: api.v1.services.types.PermissionEdges.role_permissions:type_name -> api.v1.services.types.RolePermission + 26, // 74: api.v1.services.types.PermissionEdges.permission_resources:type_name -> api.v1.services.types.PermissionResource + 22, // 75: api.v1.services.types.PermissionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission + 4, // 76: api.v1.services.types.UserPositionEdges.user:type_name -> api.v1.services.types.User + 16, // 77: api.v1.services.types.UserPositionEdges.position:type_name -> api.v1.services.types.Position + 16, // 78: api.v1.services.types.PositionPermissionEdges.position:type_name -> api.v1.services.types.Position + 18, // 79: api.v1.services.types.PositionPermissionEdges.permission:type_name -> api.v1.services.types.Permission + 2, // 80: api.v1.services.types.RolePermissionEdges.role:type_name -> api.v1.services.types.Role + 18, // 81: api.v1.services.types.RolePermissionEdges.permission:type_name -> api.v1.services.types.Permission + 18, // 82: api.v1.services.types.PermissionResourceEdges.permission:type_name -> api.v1.services.types.Permission + 10, // 83: api.v1.services.types.PermissionResourceEdges.resource:type_name -> api.v1.services.types.Resource + 84, // [84:84] is the sub-list for method output_type + 84, // [84:84] is the sub-list for method input_type + 84, // [84:84] is the sub-list for extension type_name + 84, // [84:84] is the sub-list for extension extendee + 0, // [0:84] is the sub-list for field type_name +} + +func init() { file_types_system_proto_init() } +func file_types_system_proto_init() { + if File_types_system_proto != nil { + return + } + file_types_system_proto_msgTypes[4].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_system_proto_rawDesc), len(file_types_system_proto_rawDesc)), + NumEnums: 0, + NumMessages: 30, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_system_proto_goTypes, + DependencyIndexes: file_types_system_proto_depIdxs, + MessageInfos: file_types_system_proto_msgTypes, + }.Build() + File_types_system_proto = out.File + file_types_system_proto_goTypes = nil + file_types_system_proto_depIdxs = nil +} diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go new file mode 100644 index 00000000..f9a8dc81 --- /dev/null +++ b/api/v1/services/types/system.pb.validate.go @@ -0,0 +1,5600 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/system.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on Menu 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 *Menu) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Menu 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 MenuMultiError, or nil if none found. +func (m *Menu) ValidateAll() error { + return m.validate(true) +} + +func (m *Menu) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Keyword + + // no validation rules for Name + + // no validation rules for I18NKey + + // no validation rules for Description + + // no validation rules for Sequence + + // no validation rules for Type + + // no validation rules for Icon + + // no validation rules for Path + + // no validation rules for Properties + + // no validation rules for Status + + // no validation rules for ParentId + + // no validation rules for ParentPath + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetParent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return MenuMultiError(errors) + } + + return nil +} + +// MenuMultiError is an error wrapping multiple validation errors returned by +// Menu.ValidateAll() if the designated constraints aren't met. +type MenuMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m MenuMultiError) 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 MenuMultiError) AllErrors() []error { return m } + +// MenuValidationError is the validation error returned by Menu.Validate if the +// designated constraints aren't met. +type MenuValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e MenuValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e MenuValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e MenuValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e MenuValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e MenuValidationError) ErrorName() string { return "MenuValidationError" } + +// Error satisfies the builtin error interface +func (e MenuValidationError) 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 %sMenu.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = MenuValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = MenuValidationError{} + +// Validate checks the field values on MenuEdges 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 *MenuEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on MenuEdges 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 MenuEdgesMultiError, or nil +// if none found. +func (m *MenuEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *MenuEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetParent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetRoleMenus() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, MenuEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return MenuEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return MenuEdgesMultiError(errors) + } + + return nil +} + +// MenuEdgesMultiError is an error wrapping multiple validation errors returned +// by MenuEdges.ValidateAll() if the designated constraints aren't met. +type MenuEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m MenuEdgesMultiError) 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 MenuEdgesMultiError) AllErrors() []error { return m } + +// MenuEdgesValidationError is the validation error returned by +// MenuEdges.Validate if the designated constraints aren't met. +type MenuEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e MenuEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e MenuEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e MenuEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e MenuEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e MenuEdgesValidationError) ErrorName() string { return "MenuEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e MenuEdgesValidationError) 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 %sMenuEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = MenuEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = MenuEdgesValidationError{} + +// Validate checks the field values on Role 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 *Role) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Role 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 RoleMultiError, or nil if none found. +func (m *Role) ValidateAll() error { + return m.validate(true) +} + +func (m *Role) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Keyword + + // no validation rules for Name + + // no validation rules for Description + + // no validation rules for Type + + // no validation rules for Sequence + + // no validation rules for Status + + // no validation rules for IsTypes + + for idx, item := range m.GetMenus() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUsers() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return RoleMultiError(errors) + } + + return nil +} + +// RoleMultiError is an error wrapping multiple validation errors returned by +// Role.ValidateAll() if the designated constraints aren't met. +type RoleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RoleMultiError) 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 RoleMultiError) AllErrors() []error { return m } + +// RoleValidationError is the validation error returned by Role.Validate if the +// designated constraints aren't met. +type RoleValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RoleValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RoleValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RoleValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RoleValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RoleValidationError) ErrorName() string { return "RoleValidationError" } + +// Error satisfies the builtin error interface +func (e RoleValidationError) 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 %sRole.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RoleValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RoleValidationError{} + +// Validate checks the field values on RoleEdges 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 *RoleEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RoleEdges 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 RoleEdgesMultiError, or nil +// if none found. +func (m *RoleEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *RoleEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetMenus() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleEdgesValidationError{ + field: fmt.Sprintf("Menus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUsers() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetRoleMenus() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleEdgesValidationError{ + field: fmt.Sprintf("RoleMenus[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUserRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return RoleEdgesMultiError(errors) + } + + return nil +} + +// RoleEdgesMultiError is an error wrapping multiple validation errors returned +// by RoleEdges.ValidateAll() if the designated constraints aren't met. +type RoleEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RoleEdgesMultiError) 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 RoleEdgesMultiError) AllErrors() []error { return m } + +// RoleEdgesValidationError is the validation error returned by +// RoleEdges.Validate if the designated constraints aren't met. +type RoleEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RoleEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RoleEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RoleEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RoleEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RoleEdgesValidationError) ErrorName() string { return "RoleEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e RoleEdgesValidationError) 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 %sRoleEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RoleEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RoleEdgesValidationError{} + +// Validate checks the field values on User 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 *User) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on User 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 UserMultiError, or nil if none found. +func (m *User) ValidateAll() error { + return m.validate(true) +} + +func (m *User) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for CreateAuthor + + // no validation rules for UpdateAuthor + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Uuid + + // no validation rules for AllowedIp + + // no validation rules for Username + + // no validation rules for Nickname + + // no validation rules for Avatar + + // no validation rules for Name + + // no validation rules for Gender + + // no validation rules for Password + + // no validation rules for ConfirmPassword + + // no validation rules for Salt + + // no validation rules for Phone + + // no validation rules for Email + + // no validation rules for Remark + + // no validation rules for Token + + // no validation rules for Status + + // no validation rules for LastLoginIp + + if all { + switch v := interface{}(m.GetLastLoginTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "LastLoginTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "LastLoginTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetLastLoginTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: "LastLoginTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for ManagerId + + // no validation rules for Manager + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if m.SanctionDate != nil { + + if all { + switch v := interface{}(m.GetSanctionDate()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "SanctionDate", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "SanctionDate", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSanctionDate()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: "SanctionDate", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return UserMultiError(errors) + } + + return nil +} + +// UserMultiError is an error wrapping multiple validation errors returned by +// User.ValidateAll() if the designated constraints aren't met. +type UserMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserMultiError) 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 UserMultiError) AllErrors() []error { return m } + +// UserValidationError is the validation error returned by User.Validate if the +// designated constraints aren't met. +type UserValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserValidationError) ErrorName() string { return "UserValidationError" } + +// Error satisfies the builtin error interface +func (e UserValidationError) 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 %sUser.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserValidationError{} + +// Validate checks the field values on UserEdges 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 *UserEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserEdges 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 UserEdgesMultiError, or nil +// if none found. +func (m *UserEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *UserEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUserRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserEdgesValidationError{ + field: fmt.Sprintf("UserRoles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return UserEdgesMultiError(errors) + } + + return nil +} + +// UserEdgesMultiError is an error wrapping multiple validation errors returned +// by UserEdges.ValidateAll() if the designated constraints aren't met. +type UserEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserEdgesMultiError) 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 UserEdgesMultiError) AllErrors() []error { return m } + +// UserEdgesValidationError is the validation error returned by +// UserEdges.Validate if the designated constraints aren't met. +type UserEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserEdgesValidationError) ErrorName() string { return "UserEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e UserEdgesValidationError) 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 %sUserEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserEdgesValidationError{} + +// Validate checks the field values on UserRole 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 *UserRole) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserRole 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 UserRoleMultiError, or nil +// if none found. +func (m *UserRole) ValidateAll() error { + return m.validate(true) +} + +func (m *UserRole) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for UserId + + // no validation rules for RoleId + + // no validation rules for RoleName + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UserRoleMultiError(errors) + } + + return nil +} + +// UserRoleMultiError is an error wrapping multiple validation errors returned +// by UserRole.ValidateAll() if the designated constraints aren't met. +type UserRoleMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserRoleMultiError) 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 UserRoleMultiError) AllErrors() []error { return m } + +// UserRoleValidationError is the validation error returned by +// UserRole.Validate if the designated constraints aren't met. +type UserRoleValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserRoleValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserRoleValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserRoleValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserRoleValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserRoleValidationError) ErrorName() string { return "UserRoleValidationError" } + +// Error satisfies the builtin error interface +func (e UserRoleValidationError) 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 %sUserRole.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserRoleValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserRoleValidationError{} + +// Validate checks the field values on UserRoleEdges 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 *UserRoleEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserRoleEdges 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 UserRoleEdgesMultiError, or +// nil if none found. +func (m *UserRoleEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *UserRoleEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserRoleEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserRoleEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UserRoleEdgesMultiError(errors) + } + + return nil +} + +// UserRoleEdgesMultiError is an error wrapping multiple validation errors +// returned by UserRoleEdges.ValidateAll() if the designated constraints +// aren't met. +type UserRoleEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserRoleEdgesMultiError) 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 UserRoleEdgesMultiError) AllErrors() []error { return m } + +// UserRoleEdgesValidationError is the validation error returned by +// UserRoleEdges.Validate if the designated constraints aren't met. +type UserRoleEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserRoleEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserRoleEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserRoleEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserRoleEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserRoleEdgesValidationError) ErrorName() string { return "UserRoleEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e UserRoleEdgesValidationError) 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 %sUserRoleEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserRoleEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserRoleEdgesValidationError{} + +// Validate checks the field values on RoleMenu 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 *RoleMenu) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RoleMenu 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 RoleMenuMultiError, or nil +// if none found. +func (m *RoleMenu) ValidateAll() error { + return m.validate(true) +} + +func (m *RoleMenu) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for RoleId + + // no validation rules for MenuId + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RoleMenuMultiError(errors) + } + + return nil +} + +// RoleMenuMultiError is an error wrapping multiple validation errors returned +// by RoleMenu.ValidateAll() if the designated constraints aren't met. +type RoleMenuMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RoleMenuMultiError) 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 RoleMenuMultiError) AllErrors() []error { return m } + +// RoleMenuValidationError is the validation error returned by +// RoleMenu.Validate if the designated constraints aren't met. +type RoleMenuValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RoleMenuValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RoleMenuValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RoleMenuValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RoleMenuValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RoleMenuValidationError) ErrorName() string { return "RoleMenuValidationError" } + +// Error satisfies the builtin error interface +func (e RoleMenuValidationError) 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 %sRoleMenu.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RoleMenuValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RoleMenuValidationError{} + +// Validate checks the field values on RoleMenuEdges 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 *RoleMenuEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RoleMenuEdges 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 RoleMenuEdgesMultiError, or +// nil if none found. +func (m *RoleMenuEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *RoleMenuEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RoleMenuEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RoleMenuEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RoleMenuEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RoleMenuEdgesMultiError(errors) + } + + return nil +} + +// RoleMenuEdgesMultiError is an error wrapping multiple validation errors +// returned by RoleMenuEdges.ValidateAll() if the designated constraints +// aren't met. +type RoleMenuEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RoleMenuEdgesMultiError) 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 RoleMenuEdgesMultiError) AllErrors() []error { return m } + +// RoleMenuEdgesValidationError is the validation error returned by +// RoleMenuEdges.Validate if the designated constraints aren't met. +type RoleMenuEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RoleMenuEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RoleMenuEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RoleMenuEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RoleMenuEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RoleMenuEdgesValidationError) ErrorName() string { return "RoleMenuEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e RoleMenuEdgesValidationError) 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 %sRoleMenuEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RoleMenuEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RoleMenuEdgesValidationError{} + +// Validate checks the field values on Resource 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 *Resource) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Resource 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 ResourceMultiError, or nil +// if none found. +func (m *Resource) ValidateAll() error { + return m.validate(true) +} + +func (m *Resource) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Name + + // no validation rules for Keyword + + // no validation rules for I18NKey + + // no validation rules for Type + + // no validation rules for Status + + // no validation rules for Path + + // no validation rules for Operation + + // no validation rules for Method + + // no validation rules for Component + + // no validation rules for Icon + + // no validation rules for Sequence + + // no validation rules for Visible + + // no validation rules for TreePath + + // no validation rules for Properties + + // no validation rules for Description + + // no validation rules for ParentId + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetParent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ResourceMultiError(errors) + } + + return nil +} + +// ResourceMultiError is an error wrapping multiple validation errors returned +// by Resource.ValidateAll() if the designated constraints aren't met. +type ResourceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResourceMultiError) 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 ResourceMultiError) AllErrors() []error { return m } + +// ResourceValidationError is the validation error returned by +// Resource.Validate if the designated constraints aren't met. +type ResourceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResourceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResourceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResourceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResourceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResourceValidationError) ErrorName() string { return "ResourceValidationError" } + +// Error satisfies the builtin error interface +func (e ResourceValidationError) 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 %sResource.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResourceValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResourceValidationError{} + +// Validate checks the field values on ResourceEdges 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 *ResourceEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ResourceEdges 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 ResourceEdgesMultiError, or +// nil if none found. +func (m *ResourceEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *ResourceEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetMenu()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ResourceEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ResourceEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ResourceEdgesValidationError{ + field: "Menu", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return ResourceEdgesMultiError(errors) + } + + return nil +} + +// ResourceEdgesMultiError is an error wrapping multiple validation errors +// returned by ResourceEdges.ValidateAll() if the designated constraints +// aren't met. +type ResourceEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ResourceEdgesMultiError) 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 ResourceEdgesMultiError) AllErrors() []error { return m } + +// ResourceEdgesValidationError is the validation error returned by +// ResourceEdges.Validate if the designated constraints aren't met. +type ResourceEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ResourceEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ResourceEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ResourceEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ResourceEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ResourceEdgesValidationError) ErrorName() string { return "ResourceEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e ResourceEdgesValidationError) 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 %sResourceEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ResourceEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ResourceEdgesValidationError{} + +// Validate checks the field values on Department 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 *Department) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Department 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 DepartmentMultiError, or +// nil if none found. +func (m *Department) ValidateAll() error { + return m.validate(true) +} + +func (m *Department) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Keyword + + // no validation rules for Name + + // no validation rules for TreePath + + // no validation rules for Sequence + + // no validation rules for Status + + // no validation rules for Level + + // no validation rules for Description + + // no validation rules for ParentId + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetParent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DepartmentMultiError(errors) + } + + return nil +} + +// DepartmentMultiError is an error wrapping multiple validation errors +// returned by Department.ValidateAll() if the designated constraints aren't met. +type DepartmentMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DepartmentMultiError) 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 DepartmentMultiError) AllErrors() []error { return m } + +// DepartmentValidationError is the validation error returned by +// Department.Validate if the designated constraints aren't met. +type DepartmentValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DepartmentValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DepartmentValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DepartmentValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DepartmentValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DepartmentValidationError) ErrorName() string { return "DepartmentValidationError" } + +// Error satisfies the builtin error interface +func (e DepartmentValidationError) 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 %sDepartment.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DepartmentValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DepartmentValidationError{} + +// Validate checks the field values on DepartmentEdges 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 *DepartmentEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DepartmentEdges 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 +// DepartmentEdgesMultiError, or nil if none found. +func (m *DepartmentEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *DepartmentEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetUsers() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPositions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetChildren() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentEdgesValidationError{ + field: fmt.Sprintf("Children[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if all { + switch v := interface{}(m.GetParent()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentEdgesValidationError{ + field: "Parent", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetUserDepartments() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("UserDepartments[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DepartmentEdgesValidationError{ + field: fmt.Sprintf("UserDepartments[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DepartmentEdgesValidationError{ + field: fmt.Sprintf("UserDepartments[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return DepartmentEdgesMultiError(errors) + } + + return nil +} + +// DepartmentEdgesMultiError is an error wrapping multiple validation errors +// returned by DepartmentEdges.ValidateAll() if the designated constraints +// aren't met. +type DepartmentEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DepartmentEdgesMultiError) 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 DepartmentEdgesMultiError) AllErrors() []error { return m } + +// DepartmentEdgesValidationError is the validation error returned by +// DepartmentEdges.Validate if the designated constraints aren't met. +type DepartmentEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DepartmentEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DepartmentEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DepartmentEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DepartmentEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DepartmentEdgesValidationError) ErrorName() string { return "DepartmentEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e DepartmentEdgesValidationError) 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 %sDepartmentEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DepartmentEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DepartmentEdgesValidationError{} + +// Validate checks the field values on UserDepartment 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 *UserDepartment) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserDepartment 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 UserDepartmentMultiError, +// or nil if none found. +func (m *UserDepartment) ValidateAll() error { + return m.validate(true) +} + +func (m *UserDepartment) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for UserId + + // no validation rules for DepartmentId + + if all { + switch v := interface{}(m.GetEdges()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserDepartmentValidationError{ + field: "Edges", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserDepartmentValidationError{ + field: "Edges", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEdges()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserDepartmentValidationError{ + field: "Edges", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UserDepartmentMultiError(errors) + } + + return nil +} + +// UserDepartmentMultiError is an error wrapping multiple validation errors +// returned by UserDepartment.ValidateAll() if the designated constraints +// aren't met. +type UserDepartmentMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserDepartmentMultiError) 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 UserDepartmentMultiError) AllErrors() []error { return m } + +// UserDepartmentValidationError is the validation error returned by +// UserDepartment.Validate if the designated constraints aren't met. +type UserDepartmentValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserDepartmentValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserDepartmentValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserDepartmentValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserDepartmentValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserDepartmentValidationError) ErrorName() string { return "UserDepartmentValidationError" } + +// Error satisfies the builtin error interface +func (e UserDepartmentValidationError) 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 %sUserDepartment.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserDepartmentValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserDepartmentValidationError{} + +// Validate checks the field values on UserDepartmentEdges 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 *UserDepartmentEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserDepartmentEdges 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 +// UserDepartmentEdgesMultiError, or nil if none found. +func (m *UserDepartmentEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *UserDepartmentEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserDepartmentEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserDepartmentEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserDepartmentEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetDepartment()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserDepartmentEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserDepartmentEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserDepartmentEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UserDepartmentEdgesMultiError(errors) + } + + return nil +} + +// UserDepartmentEdgesMultiError is an error wrapping multiple validation +// errors returned by UserDepartmentEdges.ValidateAll() if the designated +// constraints aren't met. +type UserDepartmentEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserDepartmentEdgesMultiError) 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 UserDepartmentEdgesMultiError) AllErrors() []error { return m } + +// UserDepartmentEdgesValidationError is the validation error returned by +// UserDepartmentEdges.Validate if the designated constraints aren't met. +type UserDepartmentEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserDepartmentEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserDepartmentEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserDepartmentEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserDepartmentEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserDepartmentEdgesValidationError) ErrorName() string { + return "UserDepartmentEdgesValidationError" +} + +// Error satisfies the builtin error interface +func (e UserDepartmentEdgesValidationError) 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 %sUserDepartmentEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserDepartmentEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserDepartmentEdgesValidationError{} + +// Validate checks the field values on Position 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 *Position) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Position 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 PositionMultiError, or nil +// if none found. +func (m *Position) ValidateAll() error { + return m.validate(true) +} + +func (m *Position) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Name + + // no validation rules for Keyword + + // no validation rules for Description + + // no validation rules for DepartmentId + + if len(errors) > 0 { + return PositionMultiError(errors) + } + + return nil +} + +// PositionMultiError is an error wrapping multiple validation errors returned +// by Position.ValidateAll() if the designated constraints aren't met. +type PositionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PositionMultiError) 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 PositionMultiError) AllErrors() []error { return m } + +// PositionValidationError is the validation error returned by +// Position.Validate if the designated constraints aren't met. +type PositionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PositionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PositionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PositionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PositionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PositionValidationError) ErrorName() string { return "PositionValidationError" } + +// Error satisfies the builtin error interface +func (e PositionValidationError) 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 %sPosition.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PositionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PositionValidationError{} + +// Validate checks the field values on PositionEdges 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 *PositionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PositionEdges 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 PositionEdgesMultiError, or +// nil if none found. +func (m *PositionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *PositionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetDepartment()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetUsers() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUserPositions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("UserPositions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("UserPositions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("UserPositions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPositionPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return PositionEdgesMultiError(errors) + } + + return nil +} + +// PositionEdgesMultiError is an error wrapping multiple validation errors +// returned by PositionEdges.ValidateAll() if the designated constraints +// aren't met. +type PositionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PositionEdgesMultiError) 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 PositionEdgesMultiError) AllErrors() []error { return m } + +// PositionEdgesValidationError is the validation error returned by +// PositionEdges.Validate if the designated constraints aren't met. +type PositionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PositionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PositionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PositionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PositionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PositionEdgesValidationError) ErrorName() string { return "PositionEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e PositionEdgesValidationError) 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 %sPositionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PositionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PositionEdgesValidationError{} + +// Validate checks the field values on Permission 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 *Permission) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on Permission 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 PermissionMultiError, or +// nil if none found. +func (m *Permission) ValidateAll() error { + return m.validate(true) +} + +func (m *Permission) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetUpdateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionValidationError{ + field: "UpdateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + + // no validation rules for Name + + // no validation rules for Keyword + + // no validation rules for Description + + // no validation rules for DataScope + + // no validation rules for DataRules + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return PermissionMultiError(errors) + } + + return nil +} + +// PermissionMultiError is an error wrapping multiple validation errors +// returned by Permission.ValidateAll() if the designated constraints aren't met. +type PermissionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PermissionMultiError) 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 PermissionMultiError) AllErrors() []error { return m } + +// PermissionValidationError is the validation error returned by +// Permission.Validate if the designated constraints aren't met. +type PermissionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PermissionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PermissionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PermissionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PermissionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PermissionValidationError) ErrorName() string { return "PermissionValidationError" } + +// Error satisfies the builtin error interface +func (e PermissionValidationError) 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 %sPermission.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PermissionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PermissionValidationError{} + +// Validate checks the field values on PermissionEdges 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 *PermissionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PermissionEdges 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 +// PermissionEdgesMultiError, or nil if none found. +func (m *PermissionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *PermissionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPositions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("Positions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetRolePermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("RolePermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("RolePermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("RolePermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPermissionResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("PermissionResources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("PermissionResources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("PermissionResources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPositionPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return PermissionEdgesMultiError(errors) + } + + return nil +} + +// PermissionEdgesMultiError is an error wrapping multiple validation errors +// returned by PermissionEdges.ValidateAll() if the designated constraints +// aren't met. +type PermissionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PermissionEdgesMultiError) 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 PermissionEdgesMultiError) AllErrors() []error { return m } + +// PermissionEdgesValidationError is the validation error returned by +// PermissionEdges.Validate if the designated constraints aren't met. +type PermissionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PermissionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PermissionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PermissionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PermissionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PermissionEdgesValidationError) ErrorName() string { return "PermissionEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e PermissionEdgesValidationError) 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 %sPermissionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PermissionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PermissionEdgesValidationError{} + +// Validate checks the field values on UserPosition 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 *UserPosition) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserPosition 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 UserPositionMultiError, or +// nil if none found. +func (m *UserPosition) ValidateAll() error { + return m.validate(true) +} + +func (m *UserPosition) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for UserId + + // no validation rules for PositionId + + if len(errors) > 0 { + return UserPositionMultiError(errors) + } + + return nil +} + +// UserPositionMultiError is an error wrapping multiple validation errors +// returned by UserPosition.ValidateAll() if the designated constraints aren't met. +type UserPositionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserPositionMultiError) 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 UserPositionMultiError) AllErrors() []error { return m } + +// UserPositionValidationError is the validation error returned by +// UserPosition.Validate if the designated constraints aren't met. +type UserPositionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserPositionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserPositionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserPositionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserPositionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserPositionValidationError) ErrorName() string { return "UserPositionValidationError" } + +// Error satisfies the builtin error interface +func (e UserPositionValidationError) 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 %sUserPosition.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserPositionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserPositionValidationError{} + +// Validate checks the field values on UserPositionEdges 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 *UserPositionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UserPositionEdges 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 +// UserPositionEdgesMultiError, or nil if none found. +func (m *UserPositionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *UserPositionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserPositionEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserPositionEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserPositionEdgesValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetPosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserPositionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserPositionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserPositionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UserPositionEdgesMultiError(errors) + } + + return nil +} + +// UserPositionEdgesMultiError is an error wrapping multiple validation errors +// returned by UserPositionEdges.ValidateAll() if the designated constraints +// aren't met. +type UserPositionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UserPositionEdgesMultiError) 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 UserPositionEdgesMultiError) AllErrors() []error { return m } + +// UserPositionEdgesValidationError is the validation error returned by +// UserPositionEdges.Validate if the designated constraints aren't met. +type UserPositionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UserPositionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UserPositionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UserPositionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UserPositionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UserPositionEdgesValidationError) ErrorName() string { + return "UserPositionEdgesValidationError" +} + +// Error satisfies the builtin error interface +func (e UserPositionEdgesValidationError) 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 %sUserPositionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UserPositionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UserPositionEdgesValidationError{} + +// Validate checks the field values on PositionPermission 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 *PositionPermission) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PositionPermission 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 +// PositionPermissionMultiError, or nil if none found. +func (m *PositionPermission) ValidateAll() error { + return m.validate(true) +} + +func (m *PositionPermission) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for PositionId + + // no validation rules for PermissionId + + if len(errors) > 0 { + return PositionPermissionMultiError(errors) + } + + return nil +} + +// PositionPermissionMultiError is an error wrapping multiple validation errors +// returned by PositionPermission.ValidateAll() if the designated constraints +// aren't met. +type PositionPermissionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PositionPermissionMultiError) 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 PositionPermissionMultiError) AllErrors() []error { return m } + +// PositionPermissionValidationError is the validation error returned by +// PositionPermission.Validate if the designated constraints aren't met. +type PositionPermissionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PositionPermissionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PositionPermissionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PositionPermissionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PositionPermissionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PositionPermissionValidationError) ErrorName() string { + return "PositionPermissionValidationError" +} + +// Error satisfies the builtin error interface +func (e PositionPermissionValidationError) 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 %sPositionPermission.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PositionPermissionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PositionPermissionValidationError{} + +// Validate checks the field values on PositionPermissionEdges 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 *PositionPermissionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PositionPermissionEdges 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 +// PositionPermissionEdgesMultiError, or nil if none found. +func (m *PositionPermissionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *PositionPermissionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetPosition()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionPermissionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionPermissionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionPermissionEdgesValidationError{ + field: "Position", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionPermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionPermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionPermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return PositionPermissionEdgesMultiError(errors) + } + + return nil +} + +// PositionPermissionEdgesMultiError is an error wrapping multiple validation +// errors returned by PositionPermissionEdges.ValidateAll() if the designated +// constraints aren't met. +type PositionPermissionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PositionPermissionEdgesMultiError) 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 PositionPermissionEdgesMultiError) AllErrors() []error { return m } + +// PositionPermissionEdgesValidationError is the validation error returned by +// PositionPermissionEdges.Validate if the designated constraints aren't met. +type PositionPermissionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PositionPermissionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PositionPermissionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PositionPermissionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PositionPermissionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PositionPermissionEdgesValidationError) ErrorName() string { + return "PositionPermissionEdgesValidationError" +} + +// Error satisfies the builtin error interface +func (e PositionPermissionEdgesValidationError) 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 %sPositionPermissionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PositionPermissionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PositionPermissionEdgesValidationError{} + +// Validate checks the field values on RolePermission 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 *RolePermission) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RolePermission 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 RolePermissionMultiError, +// or nil if none found. +func (m *RolePermission) ValidateAll() error { + return m.validate(true) +} + +func (m *RolePermission) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for RoleId + + // no validation rules for PermissionId + + if len(errors) > 0 { + return RolePermissionMultiError(errors) + } + + return nil +} + +// RolePermissionMultiError is an error wrapping multiple validation errors +// returned by RolePermission.ValidateAll() if the designated constraints +// aren't met. +type RolePermissionMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RolePermissionMultiError) 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 RolePermissionMultiError) AllErrors() []error { return m } + +// RolePermissionValidationError is the validation error returned by +// RolePermission.Validate if the designated constraints aren't met. +type RolePermissionValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RolePermissionValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RolePermissionValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RolePermissionValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RolePermissionValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RolePermissionValidationError) ErrorName() string { return "RolePermissionValidationError" } + +// Error satisfies the builtin error interface +func (e RolePermissionValidationError) 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 %sRolePermission.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RolePermissionValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RolePermissionValidationError{} + +// Validate checks the field values on RolePermissionEdges 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 *RolePermissionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RolePermissionEdges 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 +// RolePermissionEdgesMultiError, or nil if none found. +func (m *RolePermissionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *RolePermissionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetRole()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RolePermissionEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RolePermissionEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RolePermissionEdgesValidationError{ + field: "Role", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, RolePermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, RolePermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return RolePermissionEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return RolePermissionEdgesMultiError(errors) + } + + return nil +} + +// RolePermissionEdgesMultiError is an error wrapping multiple validation +// errors returned by RolePermissionEdges.ValidateAll() if the designated +// constraints aren't met. +type RolePermissionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RolePermissionEdgesMultiError) 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 RolePermissionEdgesMultiError) AllErrors() []error { return m } + +// RolePermissionEdgesValidationError is the validation error returned by +// RolePermissionEdges.Validate if the designated constraints aren't met. +type RolePermissionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RolePermissionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RolePermissionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RolePermissionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RolePermissionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RolePermissionEdgesValidationError) ErrorName() string { + return "RolePermissionEdgesValidationError" +} + +// Error satisfies the builtin error interface +func (e RolePermissionEdgesValidationError) 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 %sRolePermissionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RolePermissionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RolePermissionEdgesValidationError{} + +// Validate checks the field values on PermissionResource 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 *PermissionResource) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PermissionResource 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 +// PermissionResourceMultiError, or nil if none found. +func (m *PermissionResource) ValidateAll() error { + return m.validate(true) +} + +func (m *PermissionResource) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for PermissionId + + // no validation rules for ResourceId + + // no validation rules for Actions + + if len(errors) > 0 { + return PermissionResourceMultiError(errors) + } + + return nil +} + +// PermissionResourceMultiError is an error wrapping multiple validation errors +// returned by PermissionResource.ValidateAll() if the designated constraints +// aren't met. +type PermissionResourceMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PermissionResourceMultiError) 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 PermissionResourceMultiError) AllErrors() []error { return m } + +// PermissionResourceValidationError is the validation error returned by +// PermissionResource.Validate if the designated constraints aren't met. +type PermissionResourceValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PermissionResourceValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PermissionResourceValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PermissionResourceValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PermissionResourceValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PermissionResourceValidationError) ErrorName() string { + return "PermissionResourceValidationError" +} + +// Error satisfies the builtin error interface +func (e PermissionResourceValidationError) 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 %sPermissionResource.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PermissionResourceValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PermissionResourceValidationError{} + +// Validate checks the field values on PermissionResourceEdges 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 *PermissionResourceEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PermissionResourceEdges 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 +// PermissionResourceEdgesMultiError, or nil if none found. +func (m *PermissionResourceEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *PermissionResourceEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetPermission()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionResourceEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionResourceEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionResourceEdgesValidationError{ + field: "Permission", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if all { + switch v := interface{}(m.GetResource()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionResourceEdgesValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionResourceEdgesValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionResourceEdgesValidationError{ + field: "Resource", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return PermissionResourceEdgesMultiError(errors) + } + + return nil +} + +// PermissionResourceEdgesMultiError is an error wrapping multiple validation +// errors returned by PermissionResourceEdges.ValidateAll() if the designated +// constraints aren't met. +type PermissionResourceEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PermissionResourceEdgesMultiError) 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 PermissionResourceEdgesMultiError) AllErrors() []error { return m } + +// PermissionResourceEdgesValidationError is the validation error returned by +// PermissionResourceEdges.Validate if the designated constraints aren't met. +type PermissionResourceEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PermissionResourceEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PermissionResourceEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PermissionResourceEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PermissionResourceEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PermissionResourceEdgesValidationError) ErrorName() string { + return "PermissionResourceEdgesValidationError" +} + +// Error satisfies the builtin error interface +func (e PermissionResourceEdgesValidationError) 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 %sPermissionResourceEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PermissionResourceEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PermissionResourceEdgesValidationError{} diff --git a/api/v1/services/types/system_error.pb.go b/api/v1/services/types/system_error.pb.go new file mode 100644 index 00000000..39371eb2 --- /dev/null +++ b/api/v1/services/types/system_error.pb.go @@ -0,0 +1,195 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: types/system_error.proto + +package types + +import ( + _ "github.com/go-kratos/kratos/v2/errors" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type SystemErrorReason int32 + +const ( + SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED SystemErrorReason = 0 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND SystemErrorReason = 2001 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS SystemErrorReason = 2002 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN SystemErrorReason = 2003 + SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT SystemErrorReason = 2004 + SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED SystemErrorReason = 2005 + SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND SystemErrorReason = 2006 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN SystemErrorReason = 2007 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS SystemErrorReason = 2008 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION SystemErrorReason = 2009 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION SystemErrorReason = 2010 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST SystemErrorReason = 2011 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE SystemErrorReason = 2012 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER SystemErrorReason = 2013 + SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND SystemErrorReason = 3001 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID SystemErrorReason = 3002 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE SystemErrorReason = 3003 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME SystemErrorReason = 3005 + SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD SystemErrorReason = 3006 +) + +// Enum value maps for SystemErrorReason. +var ( + SystemErrorReason_name = map[int32]string{ + 0: "SYSTEM_ERROR_REASON_UNSPECIFIED", + 2001: "SYSTEM_ERROR_REASON_USER_NOT_FOUND", + 2002: "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS", + 2003: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN", + 2004: "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT", + 2005: "SYSTEM_ERROR_REASON_TOKEN_EXPIRED", + 2006: "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND", + 2007: "SYSTEM_ERROR_REASON_INVALID_TOKEN", + 2008: "SYSTEM_ERROR_REASON_INVALID_CLAIMS", + 2009: "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION", + 2010: "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION", + 2011: "SYSTEM_ERROR_REASON_INVALID_REQUEST", + 2012: "SYSTEM_ERROR_REASON_INVALID_RESPONSE", + 2013: "SYSTEM_ERROR_REASON_INVALID_SERVER", + 3001: "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND", + 3002: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID", + 3003: "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE", + 3005: "SYSTEM_ERROR_REASON_INVALID_USERNAME", + 3006: "SYSTEM_ERROR_REASON_INVALID_PASSWORD", + } + SystemErrorReason_value = map[string]int32{ + "SYSTEM_ERROR_REASON_UNSPECIFIED": 0, + "SYSTEM_ERROR_REASON_USER_NOT_FOUND": 2001, + "SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS": 2002, + "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN": 2003, + "SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT": 2004, + "SYSTEM_ERROR_REASON_TOKEN_EXPIRED": 2005, + "SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND": 2006, + "SYSTEM_ERROR_REASON_INVALID_TOKEN": 2007, + "SYSTEM_ERROR_REASON_INVALID_CLAIMS": 2008, + "SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION": 2009, + "SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION": 2010, + "SYSTEM_ERROR_REASON_INVALID_REQUEST": 2011, + "SYSTEM_ERROR_REASON_INVALID_RESPONSE": 2012, + "SYSTEM_ERROR_REASON_INVALID_SERVER": 2013, + "SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND": 3001, + "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID": 3002, + "SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE": 3003, + "SYSTEM_ERROR_REASON_INVALID_USERNAME": 3005, + "SYSTEM_ERROR_REASON_INVALID_PASSWORD": 3006, + } +) + +func (x SystemErrorReason) Enum() *SystemErrorReason { + p := new(SystemErrorReason) + *p = x + return p +} + +func (x SystemErrorReason) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (SystemErrorReason) Descriptor() protoreflect.EnumDescriptor { + return file_types_system_error_proto_enumTypes[0].Descriptor() +} + +func (SystemErrorReason) Type() protoreflect.EnumType { + return &file_types_system_error_proto_enumTypes[0] +} + +func (x SystemErrorReason) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use SystemErrorReason.Descriptor instead. +func (SystemErrorReason) EnumDescriptor() ([]byte, []int) { + return file_types_system_error_proto_rawDescGZIP(), []int{0} +} + +var File_types_system_error_proto protoreflect.FileDescriptor + +const file_types_system_error_proto_rawDesc = "" + + "\n" + + "\x18types/system_error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*\xbf\a\n" + + "\x11SystemErrorReason\x12#\n" + + "\x1fSYSTEM_ERROR_REASON_UNSPECIFIED\x10\x00\x12-\n" + + "\"SYSTEM_ERROR_REASON_USER_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x122\n" + + "'SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS\x10\xd2\x0f\x1a\x04\xa8E\x99\x03\x121\n" + + "&SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN\x10\xd3\x0f\x1a\x04\xa8E\x91\x03\x122\n" + + "'SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT\x10\xd4\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + + "!SYSTEM_ERROR_REASON_TOKEN_EXPIRED\x10\xd5\x0f\x1a\x04\xa8E\x91\x03\x12.\n" + + "#SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND\x10\xd6\x0f\x1a\x04\xa8E\x91\x03\x12,\n" + + "!SYSTEM_ERROR_REASON_INVALID_TOKEN\x10\xd7\x0f\x1a\x04\xa8E\x91\x03\x12-\n" + + "\"SYSTEM_ERROR_REASON_INVALID_CLAIMS\x10\xd8\x0f\x1a\x04\xa8E\x91\x03\x125\n" + + "*SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION\x10\xd9\x0f\x1a\x04\xa8E\x91\x03\x124\n" + + ")SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION\x10\xda\x0f\x1a\x04\xa8E\x93\x03\x12.\n" + + "#SYSTEM_ERROR_REASON_INVALID_REQUEST\x10\xdb\x0f\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_RESPONSE\x10\xdc\x0f\x1a\x04\xa8E\xf4\x03\x12-\n" + + "\"SYSTEM_ERROR_REASON_INVALID_SERVER\x10\xdd\x0f\x1a\x04\xa8E\xf4\x03\x123\n" + + "(SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND\x10\xb9\x17\x1a\x04\xa8E\x94\x03\x121\n" + + "&SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID\x10\xba\x17\x1a\x04\xa8E\x90\x03\x123\n" + + "(SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE\x10\xbb\x17\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_USERNAME\x10\xbd\x17\x1a\x04\xa8E\x90\x03\x12/\n" + + "$SYSTEM_ERROR_REASON_INVALID_PASSWORD\x10\xbe\x17\x1a\x04\xa8E\x90\x03\x1a\x04\xa0E\xf4\x03B\xde\x01\n" + + "\x19com.api.v1.services.typesB\x10SystemErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" + +var ( + file_types_system_error_proto_rawDescOnce sync.Once + file_types_system_error_proto_rawDescData []byte +) + +func file_types_system_error_proto_rawDescGZIP() []byte { + file_types_system_error_proto_rawDescOnce.Do(func() { + file_types_system_error_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_types_system_error_proto_rawDesc), len(file_types_system_error_proto_rawDesc))) + }) + return file_types_system_error_proto_rawDescData +} + +var file_types_system_error_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_types_system_error_proto_goTypes = []any{ + (SystemErrorReason)(0), // 0: api.v1.services.types.SystemErrorReason +} +var file_types_system_error_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_types_system_error_proto_init() } +func file_types_system_error_proto_init() { + if File_types_system_error_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_system_error_proto_rawDesc), len(file_types_system_error_proto_rawDesc)), + NumEnums: 1, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_types_system_error_proto_goTypes, + DependencyIndexes: file_types_system_error_proto_depIdxs, + EnumInfos: file_types_system_error_proto_enumTypes, + }.Build() + File_types_system_error_proto = out.File + file_types_system_error_proto_goTypes = nil + file_types_system_error_proto_depIdxs = nil +} diff --git a/api/v1/services/types/system_error.pb.validate.go b/api/v1/services/types/system_error.pb.validate.go new file mode 100644 index 00000000..ffc4ec92 --- /dev/null +++ b/api/v1/services/types/system_error.pb.validate.go @@ -0,0 +1,36 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: types/system_error.proto + +package types + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) diff --git a/api/v1/services/types/system_error_errors.pb.go b/api/v1/services/types/system_error_errors.pb.go new file mode 100644 index 00000000..b5fa9310 --- /dev/null +++ b/api/v1/services/types/system_error_errors.pb.go @@ -0,0 +1,240 @@ +// Code generated by protoc-gen-go-errors. DO NOT EDIT. + +package types + +import ( + fmt "fmt" + errors "github.com/go-kratos/kratos/v2/errors" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +const _ = errors.SupportPackageIsVersion1 + +func IsSystemErrorReasonUnspecified(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String() && e.Code == 500 +} + +func ErrorSystemErrorReasonUnspecified(format string, args ...interface{}) *errors.Error { + return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_UNSPECIFIED.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String() && e.Code == 404 +} + +func ErrorSystemErrorReasonUserNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserAlreadyExists(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String() && e.Code == 409 +} + +func ErrorSystemErrorReasonUserAlreadyExists(format string, args ...interface{}) *errors.Error { + return errors.New(409, SystemErrorReason_SYSTEM_ERROR_REASON_USER_ALREADY_EXISTS.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserNotLoggedIn(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonUserNotLoggedIn(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_IN.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonUserNotLoggedOut(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonUserNotLoggedOut(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_LOGGED_OUT.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonTokenExpired(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonTokenNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonTokenNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_TOKEN_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidToken(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonInvalidToken(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_TOKEN.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidClaims(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonInvalidClaims(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CLAIMS.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidAuthentication(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String() && e.Code == 401 +} + +func ErrorSystemErrorReasonInvalidAuthentication(format string, args ...interface{}) *errors.Error { + return errors.New(401, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHENTICATION.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidAuthorization(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String() && e.Code == 403 +} + +func ErrorSystemErrorReasonInvalidAuthorization(format string, args ...interface{}) *errors.Error { + return errors.New(403, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_AUTHORIZATION.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidRequest(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidRequest(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_REQUEST.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidResponse(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String() && e.Code == 500 +} + +func ErrorSystemErrorReasonInvalidResponse(format string, args ...interface{}) *errors.Error { + return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_RESPONSE.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidServer(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String() && e.Code == 500 +} + +func ErrorSystemErrorReasonInvalidServer(format string, args ...interface{}) *errors.Error { + return errors.New(500, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_SERVER.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonCaptchaIdNotFound(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String() && e.Code == 404 +} + +func ErrorSystemErrorReasonCaptchaIdNotFound(format string, args ...interface{}) *errors.Error { + return errors.New(404, SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidCaptchaId(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidCaptchaId(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidCaptchaCode(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidCaptchaCode(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_CODE.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidUsername(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidUsername(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), fmt.Sprintf(format, args...)) +} + +func IsSystemErrorReasonInvalidPassword(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String() && e.Code == 400 +} + +func ErrorSystemErrorReasonInvalidPassword(format string, args ...interface{}) *errors.Error { + return errors.New(400, SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), fmt.Sprintf(format, args...)) +} diff --git a/cmd/system/main.go b/cmd/system/main.go index 1c2220bb..daf8ee71 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -37,17 +37,8 @@ func init() { flag.StringVar(&flagconf, "conf", "", "config path, eg: -conf bootstrap.yaml") } -func NewApp(logger log.Logger, appInfo *runtime.AppInfo, servers []transport.Server) *kratos.App { - return kratos.New( - kratos.ID(appInfo.ID()), - kratos.Name(appInfo.Name()), - kratos.Version(appInfo.Version()), - kratos.Metadata(appInfo.Metadata()), - kratos.Logger(logger), - kratos.Server( - servers..., - ), - ) +func NewApp(app *runtime.App, servers []transport.Server) *kratos.App { + return app.NewApp(servers) } func main() { diff --git a/cmd/system/provider.go b/cmd/system/provider.go new file mode 100644 index 00000000..154d9aac --- /dev/null +++ b/cmd/system/provider.go @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package main + +import ( + "github.com/google/wire" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" + "github.com/origadmin/toolkits/crypto/hash" + "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" + "github.com/origadmin/toolkits/crypto/hash/types" +) + +func provideHasher() (hash.Crypto, error) { + // Using a default cost for bcrypt. In a real application, this might come from config. + return hash.NewCrypto(types.BCRYPT, bcrypt.WithCost(bcrypt.DefaultCost)) +} + +func provideLogger(app *runtime.App) log.Logger { + return app.Logger() +} + +var infraProviderSet = wire.NewSet(provideLogger, provideHasher) diff --git a/cmd/system/wire.go b/cmd/system/wire.go index 256578f0..a019ac3c 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -19,29 +19,32 @@ import ( "origadmin/application/admin/internal/conf" confpb "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/features/system/biz" - "origadmin/application/admin/internal/features/system/data" + "origadmin/application/admin/internal/features/system/dal" "origadmin/application/admin/internal/features/system/server" "origadmin/application/admin/internal/features/system/service" ) -func provideLogger(r *runtime.App) log.Logger { - return r.Logger() +func provideHasher() (hash.Crypto, error) { + // Using a default cost for bcrypt. In a real application, this might come from config. + return hash.NewCrypto(types.BCRYPT, bcrypt.WithCost(bcrypt.DefaultCost)) } -func provideHasher() (hash.Crypto, error) { - return hash.NewCrypto(types.BCRYPT, bcrypt.WithCost(10)) +func provideLogger(app *runtime.App) log.Logger { + return app.Logger() } // wireApp init kratos application. -func wireApp(r *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { +func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { panic(wire.Build( + // The injector function's parameter `app` is an implicit provider for *runtime.App. provideLogger, provideHasher, - wire.FieldsOf(new(*runtime.App), "AppInfo"), wire.FieldsOf(new(*conf.Config), "Bootstrap"), wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), data.ProviderSet, + dal.ProviderSet, biz.ProviderSet, service.ProviderSet, server.ProviderSet, diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index 29d1e6b9..3d191ef4 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -12,34 +12,69 @@ import ( "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/features/system/biz" + "origadmin/application/admin/internal/features/system/dal" "origadmin/application/admin/internal/features/system/server" "origadmin/application/admin/internal/features/system/service" ) +import ( + _ "github.com/origadmin/contrib/config/consul" + _ "github.com/origadmin/contrib/registry/consul" + _ "github.com/sqlite3ent/sqlite3" +) + // Injectors from wire.go: // wireApp init kratos application. -func wireApp(r *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { - dataData, cleanup, err := data.NewData(r, bootstrap) - if err != nil { - return nil, nil, err - } - resourceRepo := dal.NewResourceRepo(r, dataData) - resourceServiceBiz := biz.NewResourceServiceBiz(r, resourceRepo) - resourceServiceServer := service.NewResourceServiceServerPB(r, resourceServiceBiz) - roleRepo := dal.NewRoleRepo(r, dataData) - roleServiceBiz := biz.NewRoleServiceBiz(r, roleRepo) - roleServiceServer := service.NewRoleServiceServerPB(r, roleServiceBiz) - userRepo := dal.NewUserRepo(r, dataData) - userServiceBiz := biz.NewUserServiceBiz(r, userRepo) - userServiceServer := service.NewUserServiceServerPB(r, userServiceBiz) - permissionRepo := dal.NewPermissionRepo(r, dataData) - permissionServiceBiz := biz.NewPermissionServiceBiz(r, permissionRepo) - permissionServiceServer := service.NewPermissionServiceServerPB(r, permissionServiceBiz) - systemServerRegistrar := service.NewRegisterServer(resourceServiceServer, roleServiceServer, userServiceServer, permissionServiceServer) - v := server.NewSystemServer(r, bootstrap, systemServerRegistrar) - app := NewApp(r, v) - return app, func() { +func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { + confpbBootstrap := &bootstrap.Bootstrap + servers := confpbBootstrap.Servers + dataData, cleanup, err := data.NewData(app, bootstrap) + if err != nil { + return nil, nil, err + } + resourceRepo := dal.NewResourceRepo(dataData) + resourceUseCase, err := biz.NewResourceUseCase(resourceRepo) + if err != nil { + cleanup() + return nil, nil, err + } + roleRepo, err := dal.NewRoleRepo(dataData) + if err != nil { + cleanup() + return nil, nil, err + } + roleUseCase, err := biz.NewRoleUseCase(roleRepo) + if err != nil { + cleanup() + return nil, nil, err + } + userRepo := dal.NewUserRepo(dataData) + crypto, err := provideHasher() + if err != nil { + cleanup() + return nil, nil, err + } + userUseCase, err := biz.NewUserUseCase(userRepo, crypto) + if err != nil { + cleanup() + return nil, nil, err + } + permissionRepo := dal.NewPermissionRepo(dataData) + permissionUseCase, err := biz.NewPermissionUseCase(permissionRepo) + if err != nil { + cleanup() + return nil, nil, err + } + systemService := service.New(resourceUseCase, roleUseCase, userUseCase, permissionUseCase) + v := provideLogger(app) + v2, err := server.NewServers(servers, systemService, v) + if err != nil { + cleanup() + return nil, nil, err + } + kratosApp := NewApp(app, v2) + return kratosApp, func() { cleanup() }, nil } diff --git a/internal/data/data.go b/internal/data/data.go index 9562e3d3..5a7858ac 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -2,7 +2,7 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package data implements the functions, types, and interfaces for the module. +// Package data provides the foundational infrastructure for data access. package data import ( @@ -14,27 +14,28 @@ import ( "github.com/origadmin/runtime" "github.com/origadmin/runtime/data/storage" - "github.com/origadmin/runtime/interfaces" - ifacestorage "github.com/origadmin/runtime/interfaces/storage" "github.com/origadmin/runtime/log" - "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/data/entity/ent" ) // ProviderSet is data providers. -var ProviderSet = wire.NewSet(NewData) +var ProviderSet = wire.NewSet(NewData, ProvideDatabase) -// Data encapsulates ent client and cache. +// Data encapsulates the core data access components. +// It holds the ent.Database object for database operations and can be extended +// to hold other components like cache clients. type Data struct { - database *ent.Database - cache ifacestorage.Cache - provider storage.Provider - config interfaces.StructuredConfig - Log *log.Helper + DB *ent.Database + log *log.Helper +} + +// ProvideDatabase extracts and provides the *ent.Database from the *Data object. +func ProvideDatabase(d *Data) *ent.Database { + return d.DB } -// NewData creates a new Data instance. +// NewData creates a new Data instance, which encapsulates the core database object. func NewData(rt *runtime.App, conf *conf.Config) (*Data, func(), error) { logHelper := log.NewHelper(rt.Logger()) @@ -52,39 +53,32 @@ func NewData(rt *runtime.App, conf *conf.Config) (*Data, func(), error) { database := ent.NewDatabase(ent.Driver(activeDB)) // Run the auto migration tool. - // Note: context.Background() is used here as the schema creation is a one-time setup. - if err := database.Client(context.Background()).Schema.Create(context.Background(), + if err := database.Migration(context.Background(), schema.WithDropIndex(true), schema.WithDropColumn(true), - schema.WithForeignKeys(false)); err != nil { + schema.WithForeignKeys(false), + ); err != nil { logHelper.Fatalf("failed creating schema resources: %v", err) } - cache, err := provider.DefaultCache() - if err != nil { - return nil, nil, err + d := &Data{ + DB: database, + log: logHelper, } cleanup := func() { logHelper.Info("closing the data resources") - if database != nil { - if err := database.Client(context.Background()).Close(); err != nil { + if d.DB != nil { + if err := d.DB.Client(context.Background()).Close(); err != nil { logHelper.Errorf("failed to close ent client: %v", err) } } - + if activeDB != nil { + if err := activeDB.Close(); err != nil { + logHelper.Errorf("failed to close database: %v", err) + } + } } - return &Data{ - config: rt.StructuredConfig(), - provider: provider, - database: database, - cache: cache, - Log: logHelper, - }, cleanup, nil -} - -// DB returns the ent.Client instance. -func (d *Data) DB() *ent.Database { - return d.database + return d, cleanup, nil } diff --git a/internal/features/system/biz/user.go b/internal/features/system/biz/user.go index d040cb0d..b7b9612b 100644 --- a/internal/features/system/biz/user.go +++ b/internal/features/system/biz/user.go @@ -12,37 +12,31 @@ import ( "github.com/origadmin/toolkits/crypto/hash" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/features/system/dal" + "origadmin/application/admin/internal/features/system/dto" ) // UserUseCase is a User use case. type UserUseCase struct { - repo dal.UserRepo + repo dto.UserRepo hasher hash.Crypto } func (uc *UserUseCase) ListUserResources(ctx context.Context, id int64) ([]*types.Resource, error) { - result, err := uc.repo.ListResourceByUserID(ctx, id) - if err != nil { - return nil, err - } - return result, nil + // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer + // and added to the interface. For now, we'll return an error. + return nil, fmt.Errorf("ListUserResources not implemented") } func (uc *UserUseCase) UpdateUserRoles(ctx context.Context, id int64, roleIDs []int64) error { - err := uc.repo.AddRoleIDs(ctx, id, roleIDs) - if err != nil { - return err - } - return nil + // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer + // and added to the interface. For now, we'll return an error. + return fmt.Errorf("UpdateUserRoles not implemented") } func (uc *UserUseCase) UpdateUserStatus(ctx context.Context, id int64, status int32) error { - err := uc.repo.UpdateUserStatus(ctx, id, status) - if err != nil { - return err - } - return nil + // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer + // and added to the interface. For now, we'll return an error. + return fmt.Errorf("UpdateUserStatus not implemented") } func (uc *UserUseCase) ResetUserPassword(ctx context.Context, id int64, password string) error { @@ -51,19 +45,15 @@ func (uc *UserUseCase) ResetUserPassword(ctx context.Context, id int64, password } func (uc *UserUseCase) ListUsers(ctx context.Context, in *system.ListUsersRequest) ([]*types.User, int32, error) { - result, total, err := uc.repo.List(ctx, in) - if err != nil { - return nil, 0, err - } - return result, total, nil + // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer + // and added to the interface. For now, we'll return an error. + return nil, 0, fmt.Errorf("ListUsers not implemented") } func (uc *UserUseCase) GetUser(ctx context.Context, id int64) (*types.User, error) { - result, err := uc.repo.Get(ctx, id) - if err != nil { - return nil, err - } - return result, nil + // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer + // and added to the interface. For now, we'll return an error. + return nil, fmt.Errorf("GetUser not implemented") } func (uc *UserUseCase) CreateUser(ctx context.Context, in *types.User, password string) (*types.User, error) { @@ -75,29 +65,24 @@ func (uc *UserUseCase) CreateUser(ctx context.Context, in *types.User, password fmt.Println("Create new user username:", in.Username, "password:", password) - result, err := uc.repo.Create(ctx, in) - if err != nil { - return nil, err - } - return result, nil + // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer + // and added to the interface. For now, we'll return an error. + return nil, fmt.Errorf("CreateUser not implemented") } func (uc *UserUseCase) UpdateUser(ctx context.Context, in *types.User) (*types.User, error) { - result, err := uc.repo.Update(ctx, in) - if err != nil { - return nil, err - } - return result, nil + // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer + // and added to the interface. For now, we'll return an error. + return nil, fmt.Errorf("UpdateUser not implemented") } func (uc *UserUseCase) DeleteUser(ctx context.Context, id int64) error { - if err := uc.repo.Delete(ctx, id); err != nil { - return err - } - return nil + // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer + // and added to the interface. For now, we'll return an error. + return fmt.Errorf("DeleteUser not implemented") } // NewUserUseCase new a User use case. -func NewUserUseCase(repo dal.UserRepo, hasher hash.Crypto) (*UserUseCase, error) { +func NewUserUseCase(repo dto.UserRepo, hasher hash.Crypto) (*UserUseCase, error) { return &UserUseCase{repo: repo, hasher: hasher}, nil } diff --git a/internal/features/system/dal/permission.go b/internal/features/system/dal/permission.go new file mode 100644 index 00000000..0cacb279 --- /dev/null +++ b/internal/features/system/dal/permission.go @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "context" + + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/features/system/dto" +) + +type permissionRepo struct { + db *ent.Database +} + +// NewPermissionRepo . +func NewPermissionRepo(db *ent.Database) dto.PermissionRepo { + return &permissionRepo{db: db} +} + +func (r *permissionRepo) Get(ctx context.Context, id int64, opts ...dto.PermissionQueryOption) (*types.Permission, error) { + result, err := r.db.Permission(ctx).Get(ctx, id) + if err != nil { + return nil, err + } + return dto.ConvertPermissionToPermissionPB(result), nil +} + +func (r *permissionRepo) Create(ctx context.Context, p *types.Permission, opts ...dto.PermissionMutationOption) (*types.Permission, error) { + create := r.db.Permission(ctx).Create(). + SetName(p.Name) + + //if len(p.ResourceIds) > 0 { + // create.AddResourceIDs(p.ResourceIds...) + //} + + // ... set other fields + + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertPermissionToPermissionPB(saved), nil +} + +func (r *permissionRepo) Delete(ctx context.Context, id int64) error { + return r.db.Permission(ctx).DeleteOneID(id).Exec(ctx) +} + +func (r *permissionRepo) Update(ctx context.Context, p *types.Permission, opts ...dto.PermissionMutationOption) (*types.Permission, error) { + update := r.db.Permission(ctx).UpdateOneID(p.Id) + + //if len(p.ResourceIds) > 0 { + // update.ClearResources().AddResourceIDs(p.ResourceIds...) + //} + + // ... set other fields + + saved, err := update.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertPermissionToPermissionPB(saved), nil +} + +func (r *permissionRepo) List(ctx context.Context, in *system.ListPermissionsRequest, opts ...dto.PermissionQueryOption) ([]*types.Permission, int32, error) { + query := r.db.Permission(ctx).Query() + + if len(in.DataScopes) > 0 { + query = query.Where(permission.DataScopeIn(in.DataScopes...)) + } + + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, 0, err + } + + //query = db.QueryPage(query, in) + + result, err := query.All(ctx) + return dto.ConvertPermissionsToPermissionsPB(result), int32(count), err +} diff --git a/internal/features/system/dal/provider.go b/internal/features/system/dal/provider.go new file mode 100644 index 00000000..fffb44e8 --- /dev/null +++ b/internal/features/system/dal/provider.go @@ -0,0 +1,10 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import "github.com/google/wire" + +// ProviderSet is dal providers. +var ProviderSet = wire.NewSet(NewUserRepo, NewRoleRepo, NewPermissionRepo, NewResourceRepo) diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go new file mode 100644 index 00000000..5e69f4c3 --- /dev/null +++ b/internal/features/system/dal/resource.go @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "context" + "strconv" + + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/features/system/dto" +) + +type resourceRepo struct { + db *ent.Database + Delimiter string +} + +// NewResourceRepo . +func NewResourceRepo(db *ent.Database) dto.ResourceRepo { + return &resourceRepo{ + db: db, + Delimiter: "/", + } +} + +func (r *resourceRepo) Get(ctx context.Context, id int64, opts ...dto.ResourceQueryOption) (*types.Resource, error) { + result, err := r.db.Resource(ctx).Get(ctx, id) + if err != nil { + return nil, err + } + return dto.ConvertResourceToResourcePB(result), nil +} + +func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ...dto.ResourceMutationOption) (*types.Resource, error) { + if res.ParentId > 0 { + parent, err := r.db.Resource(ctx).Get(ctx, res.ParentId) + if err != nil { + return nil, err + } + res.TreePath = parent.TreePath + strconv.FormatInt(int64(parent.ID), 10) + r.Delimiter + } + + create := r.db.Resource(ctx).Create(). + SetName(res.Name). + SetParentID(res.ParentId). + SetTreePath(res.TreePath) + + //if len(res.PermissionIds) > 0 { + // create.AddPermissionIDs(res.PermissionIds...) + //} + + // ... set other fields + + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResourceToResourcePB(saved), nil +} + +func (r *resourceRepo) Delete(ctx context.Context, id int64) error { + return r.db.Resource(ctx).DeleteOneID(id).Exec(ctx) +} + +func (r *resourceRepo) Update(ctx context.Context, res *types.Resource, opts ...dto.ResourceMutationOption) (*types.Resource, error) { + update := r.db.Resource(ctx).UpdateOneID(res.Id) + + //if len(res.PermissionIds) > 0 { + // update.ClearPermissions().AddPermissionIDs(res.PermissionIds...) + //} + + // ... set other fields + + saved, err := update.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResourceToResourcePB(saved), nil +} + +func (r *resourceRepo) List(ctx context.Context, in *system.ListResourcesRequest, opts ...dto.ResourceQueryOption) ([]*types.Resource, int32, error) { + query := r.db.Resource(ctx).Query() + + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, 0, err + } + + //query = db.QueryPage(query, in) + + result, err := query.All(ctx) + return dto.ConvertResourcesToResourcesPB(result), int32(count), err +} diff --git a/internal/features/system/dal/role.go b/internal/features/system/dal/role.go new file mode 100644 index 00000000..c5de3114 --- /dev/null +++ b/internal/features/system/dal/role.go @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "context" + "errors" + + "github.com/origadmin/toolkits/crypto/rand" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/features/system/dto" +) + +type roleRepo struct { + db *ent.Database + gen rand.Generator +} + +// NewRoleRepo . +func NewRoleRepo(db *ent.Database) (dto.RoleRepo, error) { + generator, err := rand.NewGenerator(rand.KindDigit | rand.KindLowerCase) + if err != nil { + return nil, err + } + return &roleRepo{db: db, gen: generator}, nil +} + +func (r *roleRepo) Get(ctx context.Context, id int64, opts ...dto.RoleQueryOption) (*types.Role, error) { + result, err := r.db.Role(ctx).Get(ctx, id) + if err != nil { + return nil, err + } + return dto.ConvertRoleToRolePB(result), nil +} + +func (r *roleRepo) Create(ctx context.Context, rl *types.Role, opts ...dto.RoleMutationOption) (*types.Role, error) { + if rl.Keyword == "" { + randString, err := r.gen.RandString(12) + if err != nil { + randString = "" + } + rl.Keyword = "system:role:" + randString + } + exist, err := r.db.Role(ctx).Query().Where(role.KeywordEqualFold(rl.Keyword)).Exist(ctx) + if err != nil || exist { + return nil, errors.New("role keyword already exists") + } + + create := r.db.Role(ctx).Create(). + SetName(rl.Name). + SetKeyword(rl.Keyword) + + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertRoleToRolePB(saved), nil +} + +func (r *roleRepo) Delete(ctx context.Context, id int64) error { + return r.db.Role(ctx).DeleteOneID(id).Exec(ctx) +} + +func (r *roleRepo) Update(ctx context.Context, rl *types.Role, opts ...dto.RoleMutationOption) (*types.Role, error) { + update := r.db.Role(ctx).UpdateOneID(rl.Id) + //if len(rl.PermissionIds) > 0 { + // update.ClearPermissions().AddPermissionIDs(rl.PermissionIds...) + //} + + // ... set other fields + + saved, err := update.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertRoleToRolePB(saved), nil +} + +func (r *roleRepo) List(ctx context.Context, in *system.ListRolesRequest, opts ...dto.RoleQueryOption) ([]*types.Role, int32, error) { + query := r.db.Role(ctx).Query() + + if in.GetKeyword() != "" { + query = query.Where(role.NameContainsFold(in.GetKeyword())) + } + //if in.Status != nil { + // query = query.Where(role.StatusEQ(*in.Status)) + //} + + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, 0, err + } + + //query = db.QueryPage(query, in) + + result, err := query.All(ctx) + return dto.ConvertRolesToRolesPB(result), int32(count), err +} + +func (r *roleRepo) GetPermissions(ctx context.Context, id int64) ([]*types.Permission, error) { + permissions, err := r.db.Role(ctx).Query().Where(role.ID(id)).QueryPermissions().All(ctx) + if err != nil { + return nil, err + } + return dto.ConvertPermissionsToPermissionsPB(permissions), nil +} + +func (r *roleRepo) UpdatePermissions(ctx context.Context, id int64, permissionIDs []int64) error { + _, err := r.db.Role(ctx).UpdateOneID(id).ClearPermissions().AddPermissionIDs(permissionIDs...).Save(ctx) + return err +} diff --git a/internal/features/system/dal/user.go b/internal/features/system/dal/user.go new file mode 100644 index 00000000..9d0f8fc6 --- /dev/null +++ b/internal/features/system/dal/user.go @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "context" + "errors" + + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/features/system/dto" +) + +type userRepo struct { + db *ent.Database +} + +// NewUserRepo . +func NewUserRepo(db *ent.Database) dto.UserRepo { + return &userRepo{db: db} +} + +func (r *userRepo) Get(ctx context.Context, id int64, opts ...dto.UserQueryOption) (*types.User, error) { + result, err := r.db.User(ctx).Get(ctx, id) + if err != nil { + return nil, err + } + return dto.ConvertUserToUserPB(result), nil +} + +func (r *userRepo) Create(ctx context.Context, u *types.User, opts ...dto.UserMutationOption) (*types.User, error) { + exist, err := r.db.User(ctx).Query().Where(user.UsernameEQ(u.Username)).Exist(ctx) + if err != nil || exist { + return nil, errors.New("user already exists") + } + + create := r.db.User(ctx).Create(). + SetUsername(u.Username). + SetPassword(u.Password) + + // ... set other fields + + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertUserToUserPB(saved), nil +} + +func (r *userRepo) Delete(ctx context.Context, id int64) error { + return r.db.User(ctx).DeleteOneID(id).Exec(ctx) +} + +func (r *userRepo) Update(ctx context.Context, u *types.User, opts ...dto.UserMutationOption) (*types.User, error) { + update := r.db.User(ctx).UpdateOneID(u.Id) + + //if len(u.RoleIds) > 0 { + // update.ClearRoles().AddRoleIDs(u.RoleIds...) + //} + + // ... set other fields + + saved, err := update.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertUserToUserPB(saved), nil +} + +func (r *userRepo) List(ctx context.Context, in *system.ListUsersRequest, opts ...dto.UserQueryOption) ([]*types.User, int32, error) { + query := r.db.User(ctx).Query() + + if in.GetKeyword() != "" { + query = query.Where(user.Or(user.UsernameContainsFold(in.GetKeyword()), user.PhoneContainsFold(in.GetKeyword()), user.EmailContainsFold(in.GetKeyword()))) + } + //if in.Status != nil { + // query = query.Where(user.StatusEQ(int8(*in.Status))) + //} + + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, 0, err + } + + //query = db.QueryPage(query, in) + + result, err := query.All(ctx) + return dto.ConvertUsersToUsersPB(result), int32(count), err +} + +func (r *userRepo) AddRoleIDs(ctx context.Context, id int64, roleIDs []int64, opts ...dto.UserMutationOption) error { + return r.db.User(ctx).UpdateOneID(id).AddRoleIDs(roleIDs...).Exec(ctx) +} + +func (r *userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*types.User, error) { + result, err := r.db.User(ctx).Query().Where(user.UsernameEQ(username)).Only(ctx) + if err != nil { + return nil, err + } + return dto.ConvertUserToUserPB(result), nil +} + +func (r *userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { + ids, err := r.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().IDs(ctx) + if err != nil { + return nil, err + } + return ids, nil +} + +func (r *userRepo) ListResourceByUserID(ctx context.Context, id int64, opts ...dto.UserQueryOption) ([]*types.Resource, error) { + resources, err := r.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResourcesToResourcesPB(resources), nil +} + +func (r *userRepo) UpdateUserStatus(ctx context.Context, id int64, status int32, opts ...dto.UserQueryOption) error { + return r.db.User(ctx).UpdateOneID(id).SetStatus(int8(status)).Exec(ctx) +} + +func (r *userRepo) Current(ctx context.Context, id int64) (*types.User, error) { + return r.Get(ctx, id) +} diff --git a/internal/features/system/data/data.go b/internal/features/system/data/data.go deleted file mode 100644 index 37aa00bd..00000000 --- a/internal/features/system/data/data.go +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package data implements the functions, types, and interfaces for the module. -package data - -import ( - "context" - - entsql "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/schema" - "github.com/google/wire" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/data/storage" - "github.com/origadmin/runtime/interfaces" - ifacestorage "github.com/origadmin/runtime/interfaces/storage" - "github.com/origadmin/runtime/log" - - "origadmin/application/admin/internal/features/system/data/ent" -) - -// ProviderSet is data providers. -var ProviderSet = wire.NewSet(NewData, NewUserRepo, NewRoleRepo, NewResourceRepo, NewPermissionRepo, NewRepositories) - -// Data encapsulates ent client and cache. -type Data struct { - db *ent.Client - cache ifacestorage.Cache - provider storage.Provider - config interfaces.StructuredConfig - Log *log.Helper -} - -// NewData creates a new Data instance. -func NewData(rt *runtime.App) (*Data, func(), error) { - logHelper := log.NewHelper(rt.Logger()) - - provider, err := storage.New(rt.StructuredConfig()) - if err != nil { - return nil, nil, err - } - - db, err := provider.DefaultDatabase() - if err != nil { - return nil, nil, err - } - - activeDB := entsql.OpenDB(db.Dialect(), db.DB()) - client := ent.NewClient(ent.Driver(activeDB)) - - // Run the auto migration tool. - // Note: context.Background() is used here as the schema creation is a one-time setup. - if err := client.Schema.Create(context.Background(), - schema.WithDropIndex(true), - schema.WithDropColumn(true), - schema.WithForeignKeys(false)); err != nil { - logHelper.Fatalf("failed creating schema resources: %v", err) - } - - cache, err := provider.DefaultCache() - if err != nil { - return nil, nil, err - } - - cleanup := func() { - logHelper.Info("closing the data resources") - if client != nil { - if err := client.Close(); err != nil { - logHelper.Errorf("failed to close ent client: %v", err) - } - } - - } - - return &Data{ - config: rt.StructuredConfig(), - provider: provider, - db: client, - cache: cache, - Log: logHelper, - }, cleanup, nil -} - -// DB returns the ent.Client instance. -func (d *Data) DB() *ent.Client { - return d.db -} diff --git a/internal/features/system/data/ent/client.go b/internal/features/system/data/ent/client.go deleted file mode 100644 index 309e8573..00000000 --- a/internal/features/system/data/ent/client.go +++ /dev/null @@ -1,1520 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "log" - "reflect" - - "origadmin/application/admin/internal/features/system/data/ent/migrate" - - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// Client is the client that holds all ent builders. -type Client struct { - config - // Schema is the client for creating, migrating and dropping schema. - Schema *migrate.Schema - // Permission is the client for interacting with the Permission builders. - Permission *PermissionClient - // PermissionResource is the client for interacting with the PermissionResource builders. - PermissionResource *PermissionResourceClient - // Resource is the client for interacting with the Resource builders. - Resource *ResourceClient - // Role is the client for interacting with the Role builders. - Role *RoleClient - // RolePermission is the client for interacting with the RolePermission builders. - RolePermission *RolePermissionClient - // User is the client for interacting with the User builders. - User *UserClient - // UserRole is the client for interacting with the UserRole builders. - UserRole *UserRoleClient -} - -// NewClient creates a new client configured with the given options. -func NewClient(opts ...Option) *Client { - client := &Client{config: newConfig(opts...)} - client.init() - return client -} - -func (c *Client) init() { - c.Schema = migrate.NewSchema(c.driver) - c.Permission = NewPermissionClient(c.config) - c.PermissionResource = NewPermissionResourceClient(c.config) - c.Resource = NewResourceClient(c.config) - c.Role = NewRoleClient(c.config) - c.RolePermission = NewRolePermissionClient(c.config) - c.User = NewUserClient(c.config) - c.UserRole = NewUserRoleClient(c.config) -} - -type ( - // config is the configuration for the client and its builder. - config struct { - // driver used for executing database requests. - driver dialect.Driver - // debug enable a debug logging. - debug bool - // log used for logging on debug mode. - log func(...any) - // hooks to execute on mutations. - hooks *hooks - // interceptors to execute on queries. - inters *inters - } - // Option function to configure the client. - Option func(*config) -) - -// newConfig creates a new config for the client. -func newConfig(opts ...Option) config { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - return cfg -} - -// options applies the options on the config object. -func (c *config) options(opts ...Option) { - for _, opt := range opts { - opt(c) - } - if c.debug { - c.driver = dialect.Debug(c.driver, c.log) - } -} - -// Debug enables debug logging on the ent.Driver. -func Debug() Option { - return func(c *config) { - c.debug = true - } -} - -// Log sets the logging function for debug mode. -func Log(fn func(...any)) Option { - return func(c *config) { - c.log = fn - } -} - -// Driver configures the client driver. -func Driver(driver dialect.Driver) Option { - return func(c *config) { - c.driver = driver - } -} - -// Open opens a database/sql.DB specified by the driver name and -// the data source name, and returns a new client attached to it. -// Optional parameters can be added for configuring the client. -func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { - switch driverName { - case dialect.MySQL, dialect.Postgres, dialect.SQLite: - drv, err := sql.Open(driverName, dataSourceName) - if err != nil { - return nil, err - } - return NewClient(append(options, Driver(drv))...), nil - default: - return nil, fmt.Errorf("unsupported driver: %q", driverName) - } -} - -// ErrTxStarted is returned when trying to start a new transaction from a transactional client. -var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") - -// Tx returns a new transactional client. The provided context -// is used until the transaction is committed or rolled back. -func (c *Client) Tx(ctx context.Context) (*Tx, error) { - if _, ok := c.driver.(*txDriver); ok { - return nil, ErrTxStarted - } - tx, err := newTx(ctx, c.driver) - if err != nil { - return nil, fmt.Errorf("ent: starting a transaction: %w", err) - } - cfg := c.config - cfg.driver = tx - return &Tx{ - ctx: ctx, - config: cfg, - Permission: NewPermissionClient(cfg), - PermissionResource: NewPermissionResourceClient(cfg), - Resource: NewResourceClient(cfg), - Role: NewRoleClient(cfg), - RolePermission: NewRolePermissionClient(cfg), - User: NewUserClient(cfg), - UserRole: NewUserRoleClient(cfg), - }, nil -} - -// BeginTx returns a transactional client with specified options. -func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { - if _, ok := c.driver.(*txDriver); ok { - return nil, errors.New("ent: cannot start a transaction within a transaction") - } - tx, err := c.driver.(interface { - BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) - }).BeginTx(ctx, opts) - if err != nil { - return nil, fmt.Errorf("ent: starting a transaction: %w", err) - } - cfg := c.config - cfg.driver = &txDriver{tx: tx, drv: c.driver} - return &Tx{ - ctx: ctx, - config: cfg, - Permission: NewPermissionClient(cfg), - PermissionResource: NewPermissionResourceClient(cfg), - Resource: NewResourceClient(cfg), - Role: NewRoleClient(cfg), - RolePermission: NewRolePermissionClient(cfg), - User: NewUserClient(cfg), - UserRole: NewUserRoleClient(cfg), - }, nil -} - -// Debug returns a new debug-client. It's used to get verbose logging on specific operations. -// -// client.Debug(). -// Permission. -// Query(). -// Count(ctx) -func (c *Client) Debug() *Client { - if c.debug { - return c - } - cfg := c.config - cfg.driver = dialect.Debug(c.driver, c.log) - client := &Client{config: cfg} - client.init() - return client -} - -// Close closes the database connection and prevents new queries from starting. -func (c *Client) Close() error { - return c.driver.Close() -} - -// Use adds the mutation hooks to all the entity clients. -// In order to add hooks to a specific client, call: `client.Node.Use(...)`. -func (c *Client) Use(hooks ...Hook) { - for _, n := range []interface{ Use(...Hook) }{ - c.Permission, c.PermissionResource, c.Resource, c.Role, c.RolePermission, - c.User, c.UserRole, - } { - n.Use(hooks...) - } -} - -// Intercept adds the query interceptors to all the entity clients. -// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. -func (c *Client) Intercept(interceptors ...Interceptor) { - for _, n := range []interface{ Intercept(...Interceptor) }{ - c.Permission, c.PermissionResource, c.Resource, c.Role, c.RolePermission, - c.User, c.UserRole, - } { - n.Intercept(interceptors...) - } -} - -// Mutate implements the ent.Mutator interface. -func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { - switch m := m.(type) { - case *PermissionMutation: - return c.Permission.mutate(ctx, m) - case *PermissionResourceMutation: - return c.PermissionResource.mutate(ctx, m) - case *ResourceMutation: - return c.Resource.mutate(ctx, m) - case *RoleMutation: - return c.Role.mutate(ctx, m) - case *RolePermissionMutation: - return c.RolePermission.mutate(ctx, m) - case *UserMutation: - return c.User.mutate(ctx, m) - case *UserRoleMutation: - return c.UserRole.mutate(ctx, m) - default: - return nil, fmt.Errorf("ent: unknown mutation type %T", m) - } -} - -// PermissionClient is a client for the Permission schema. -type PermissionClient struct { - config -} - -// NewPermissionClient returns a client for the Permission from the given config. -func NewPermissionClient(c config) *PermissionClient { - return &PermissionClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `permission.Hooks(f(g(h())))`. -func (c *PermissionClient) Use(hooks ...Hook) { - c.hooks.Permission = append(c.hooks.Permission, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `permission.Intercept(f(g(h())))`. -func (c *PermissionClient) Intercept(interceptors ...Interceptor) { - c.inters.Permission = append(c.inters.Permission, interceptors...) -} - -// Create returns a builder for creating a Permission entity. -func (c *PermissionClient) Create() *PermissionCreate { - mutation := newPermissionMutation(c.config, OpCreate) - return &PermissionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Permission entities. -func (c *PermissionClient) CreateBulk(builders ...*PermissionCreate) *PermissionCreateBulk { - return &PermissionCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *PermissionClient) MapCreateBulk(slice any, setFunc func(*PermissionCreate, int)) *PermissionCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &PermissionCreateBulk{err: fmt.Errorf("calling to PermissionClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*PermissionCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &PermissionCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Permission. -func (c *PermissionClient) Update() *PermissionUpdate { - mutation := newPermissionMutation(c.config, OpUpdate) - return &PermissionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *PermissionClient) UpdateOne(_m *Permission) *PermissionUpdateOne { - mutation := newPermissionMutation(c.config, OpUpdateOne, withPermission(_m)) - return &PermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *PermissionClient) UpdateOneID(id int64) *PermissionUpdateOne { - mutation := newPermissionMutation(c.config, OpUpdateOne, withPermissionID(id)) - return &PermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Permission. -func (c *PermissionClient) Delete() *PermissionDelete { - mutation := newPermissionMutation(c.config, OpDelete) - return &PermissionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *PermissionClient) DeleteOne(_m *Permission) *PermissionDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *PermissionClient) DeleteOneID(id int64) *PermissionDeleteOne { - builder := c.Delete().Where(permission.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &PermissionDeleteOne{builder} -} - -// Query returns a query builder for Permission. -func (c *PermissionClient) Query() *PermissionQuery { - return &PermissionQuery{ - config: c.config, - ctx: &QueryContext{Type: TypePermission}, - inters: c.Interceptors(), - } -} - -// Get returns a Permission entity by its id. -func (c *PermissionClient) Get(ctx context.Context, id int64) (*Permission, error) { - return c.Query().Where(permission.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *PermissionClient) GetX(ctx context.Context, id int64) *Permission { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryRoles queries the roles edge of a Permission. -func (c *PermissionClient) QueryRoles(_m *Permission) *RoleQuery { - query := (&RoleClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(permission.Table, permission.FieldID, id), - sqlgraph.To(role.Table, role.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, permission.RolesTable, permission.RolesPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryResources queries the resources edge of a Permission. -func (c *PermissionClient) QueryResources(_m *Permission) *ResourceQuery { - query := (&ResourceClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(permission.Table, permission.FieldID, id), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, permission.ResourcesTable, permission.ResourcesPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryRolePermissions queries the role_permissions edge of a Permission. -func (c *PermissionClient) QueryRolePermissions(_m *Permission) *RolePermissionQuery { - query := (&RolePermissionClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(permission.Table, permission.FieldID, id), - sqlgraph.To(rolepermission.Table, rolepermission.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, permission.RolePermissionsTable, permission.RolePermissionsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryPermissionResources queries the permission_resources edge of a Permission. -func (c *PermissionClient) QueryPermissionResources(_m *Permission) *PermissionResourceQuery { - query := (&PermissionResourceClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(permission.Table, permission.FieldID, id), - sqlgraph.To(permissionresource.Table, permissionresource.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, permission.PermissionResourcesTable, permission.PermissionResourcesColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *PermissionClient) Hooks() []Hook { - return c.hooks.Permission -} - -// Interceptors returns the client interceptors. -func (c *PermissionClient) Interceptors() []Interceptor { - return c.inters.Permission -} - -func (c *PermissionClient) mutate(ctx context.Context, m *PermissionMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&PermissionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&PermissionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&PermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&PermissionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown Permission mutation op: %q", m.Op()) - } -} - -// PermissionResourceClient is a client for the PermissionResource schema. -type PermissionResourceClient struct { - config -} - -// NewPermissionResourceClient returns a client for the PermissionResource from the given config. -func NewPermissionResourceClient(c config) *PermissionResourceClient { - return &PermissionResourceClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `permissionresource.Hooks(f(g(h())))`. -func (c *PermissionResourceClient) Use(hooks ...Hook) { - c.hooks.PermissionResource = append(c.hooks.PermissionResource, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `permissionresource.Intercept(f(g(h())))`. -func (c *PermissionResourceClient) Intercept(interceptors ...Interceptor) { - c.inters.PermissionResource = append(c.inters.PermissionResource, interceptors...) -} - -// Create returns a builder for creating a PermissionResource entity. -func (c *PermissionResourceClient) Create() *PermissionResourceCreate { - mutation := newPermissionResourceMutation(c.config, OpCreate) - return &PermissionResourceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of PermissionResource entities. -func (c *PermissionResourceClient) CreateBulk(builders ...*PermissionResourceCreate) *PermissionResourceCreateBulk { - return &PermissionResourceCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *PermissionResourceClient) MapCreateBulk(slice any, setFunc func(*PermissionResourceCreate, int)) *PermissionResourceCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &PermissionResourceCreateBulk{err: fmt.Errorf("calling to PermissionResourceClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*PermissionResourceCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &PermissionResourceCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for PermissionResource. -func (c *PermissionResourceClient) Update() *PermissionResourceUpdate { - mutation := newPermissionResourceMutation(c.config, OpUpdate) - return &PermissionResourceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *PermissionResourceClient) UpdateOne(_m *PermissionResource) *PermissionResourceUpdateOne { - mutation := newPermissionResourceMutation(c.config, OpUpdateOne, withPermissionResource(_m)) - return &PermissionResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *PermissionResourceClient) UpdateOneID(id int) *PermissionResourceUpdateOne { - mutation := newPermissionResourceMutation(c.config, OpUpdateOne, withPermissionResourceID(id)) - return &PermissionResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for PermissionResource. -func (c *PermissionResourceClient) Delete() *PermissionResourceDelete { - mutation := newPermissionResourceMutation(c.config, OpDelete) - return &PermissionResourceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *PermissionResourceClient) DeleteOne(_m *PermissionResource) *PermissionResourceDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *PermissionResourceClient) DeleteOneID(id int) *PermissionResourceDeleteOne { - builder := c.Delete().Where(permissionresource.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &PermissionResourceDeleteOne{builder} -} - -// Query returns a query builder for PermissionResource. -func (c *PermissionResourceClient) Query() *PermissionResourceQuery { - return &PermissionResourceQuery{ - config: c.config, - ctx: &QueryContext{Type: TypePermissionResource}, - inters: c.Interceptors(), - } -} - -// Get returns a PermissionResource entity by its id. -func (c *PermissionResourceClient) Get(ctx context.Context, id int) (*PermissionResource, error) { - return c.Query().Where(permissionresource.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *PermissionResourceClient) GetX(ctx context.Context, id int) *PermissionResource { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryPermission queries the permission edge of a PermissionResource. -func (c *PermissionResourceClient) QueryPermission(_m *PermissionResource) *PermissionQuery { - query := (&PermissionClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(permissionresource.Table, permissionresource.FieldID, id), - sqlgraph.To(permission.Table, permission.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.PermissionTable, permissionresource.PermissionColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryResource queries the resource edge of a PermissionResource. -func (c *PermissionResourceClient) QueryResource(_m *PermissionResource) *ResourceQuery { - query := (&ResourceClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(permissionresource.Table, permissionresource.FieldID, id), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.ResourceTable, permissionresource.ResourceColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *PermissionResourceClient) Hooks() []Hook { - return c.hooks.PermissionResource -} - -// Interceptors returns the client interceptors. -func (c *PermissionResourceClient) Interceptors() []Interceptor { - return c.inters.PermissionResource -} - -func (c *PermissionResourceClient) mutate(ctx context.Context, m *PermissionResourceMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&PermissionResourceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&PermissionResourceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&PermissionResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&PermissionResourceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown PermissionResource mutation op: %q", m.Op()) - } -} - -// ResourceClient is a client for the Resource schema. -type ResourceClient struct { - config -} - -// NewResourceClient returns a client for the Resource from the given config. -func NewResourceClient(c config) *ResourceClient { - return &ResourceClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `resource.Hooks(f(g(h())))`. -func (c *ResourceClient) Use(hooks ...Hook) { - c.hooks.Resource = append(c.hooks.Resource, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `resource.Intercept(f(g(h())))`. -func (c *ResourceClient) Intercept(interceptors ...Interceptor) { - c.inters.Resource = append(c.inters.Resource, interceptors...) -} - -// Create returns a builder for creating a Resource entity. -func (c *ResourceClient) Create() *ResourceCreate { - mutation := newResourceMutation(c.config, OpCreate) - return &ResourceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Resource entities. -func (c *ResourceClient) CreateBulk(builders ...*ResourceCreate) *ResourceCreateBulk { - return &ResourceCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *ResourceClient) MapCreateBulk(slice any, setFunc func(*ResourceCreate, int)) *ResourceCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &ResourceCreateBulk{err: fmt.Errorf("calling to ResourceClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*ResourceCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &ResourceCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Resource. -func (c *ResourceClient) Update() *ResourceUpdate { - mutation := newResourceMutation(c.config, OpUpdate) - return &ResourceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *ResourceClient) UpdateOne(_m *Resource) *ResourceUpdateOne { - mutation := newResourceMutation(c.config, OpUpdateOne, withResource(_m)) - return &ResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *ResourceClient) UpdateOneID(id int64) *ResourceUpdateOne { - mutation := newResourceMutation(c.config, OpUpdateOne, withResourceID(id)) - return &ResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Resource. -func (c *ResourceClient) Delete() *ResourceDelete { - mutation := newResourceMutation(c.config, OpDelete) - return &ResourceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *ResourceClient) DeleteOne(_m *Resource) *ResourceDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *ResourceClient) DeleteOneID(id int64) *ResourceDeleteOne { - builder := c.Delete().Where(resource.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &ResourceDeleteOne{builder} -} - -// Query returns a query builder for Resource. -func (c *ResourceClient) Query() *ResourceQuery { - return &ResourceQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeResource}, - inters: c.Interceptors(), - } -} - -// Get returns a Resource entity by its id. -func (c *ResourceClient) Get(ctx context.Context, id int64) (*Resource, error) { - return c.Query().Where(resource.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *ResourceClient) GetX(ctx context.Context, id int64) *Resource { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryParent queries the parent edge of a Resource. -func (c *ResourceClient) QueryParent(_m *Resource) *ResourceQuery { - query := (&ResourceClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, id), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, resource.ParentTable, resource.ParentColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryChildren queries the children edge of a Resource. -func (c *ResourceClient) QueryChildren(_m *Resource) *ResourceQuery { - query := (&ResourceClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, id), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, resource.ChildrenTable, resource.ChildrenColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryPermissions queries the permissions edge of a Resource. -func (c *ResourceClient) QueryPermissions(_m *Resource) *PermissionQuery { - query := (&PermissionClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, id), - sqlgraph.To(permission.Table, permission.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, resource.PermissionsTable, resource.PermissionsPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryPermissionResources queries the permission_resources edge of a Resource. -func (c *ResourceClient) QueryPermissionResources(_m *Resource) *PermissionResourceQuery { - query := (&PermissionResourceClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, id), - sqlgraph.To(permissionresource.Table, permissionresource.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, resource.PermissionResourcesTable, resource.PermissionResourcesColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *ResourceClient) Hooks() []Hook { - return c.hooks.Resource -} - -// Interceptors returns the client interceptors. -func (c *ResourceClient) Interceptors() []Interceptor { - return c.inters.Resource -} - -func (c *ResourceClient) mutate(ctx context.Context, m *ResourceMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&ResourceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&ResourceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&ResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&ResourceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown Resource mutation op: %q", m.Op()) - } -} - -// RoleClient is a client for the Role schema. -type RoleClient struct { - config -} - -// NewRoleClient returns a client for the Role from the given config. -func NewRoleClient(c config) *RoleClient { - return &RoleClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `role.Hooks(f(g(h())))`. -func (c *RoleClient) Use(hooks ...Hook) { - c.hooks.Role = append(c.hooks.Role, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `role.Intercept(f(g(h())))`. -func (c *RoleClient) Intercept(interceptors ...Interceptor) { - c.inters.Role = append(c.inters.Role, interceptors...) -} - -// Create returns a builder for creating a Role entity. -func (c *RoleClient) Create() *RoleCreate { - mutation := newRoleMutation(c.config, OpCreate) - return &RoleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of Role entities. -func (c *RoleClient) CreateBulk(builders ...*RoleCreate) *RoleCreateBulk { - return &RoleCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *RoleClient) MapCreateBulk(slice any, setFunc func(*RoleCreate, int)) *RoleCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &RoleCreateBulk{err: fmt.Errorf("calling to RoleClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*RoleCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &RoleCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for Role. -func (c *RoleClient) Update() *RoleUpdate { - mutation := newRoleMutation(c.config, OpUpdate) - return &RoleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *RoleClient) UpdateOne(_m *Role) *RoleUpdateOne { - mutation := newRoleMutation(c.config, OpUpdateOne, withRole(_m)) - return &RoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *RoleClient) UpdateOneID(id int64) *RoleUpdateOne { - mutation := newRoleMutation(c.config, OpUpdateOne, withRoleID(id)) - return &RoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for Role. -func (c *RoleClient) Delete() *RoleDelete { - mutation := newRoleMutation(c.config, OpDelete) - return &RoleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *RoleClient) DeleteOne(_m *Role) *RoleDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *RoleClient) DeleteOneID(id int64) *RoleDeleteOne { - builder := c.Delete().Where(role.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &RoleDeleteOne{builder} -} - -// Query returns a query builder for Role. -func (c *RoleClient) Query() *RoleQuery { - return &RoleQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeRole}, - inters: c.Interceptors(), - } -} - -// Get returns a Role entity by its id. -func (c *RoleClient) Get(ctx context.Context, id int64) (*Role, error) { - return c.Query().Where(role.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *RoleClient) GetX(ctx context.Context, id int64) *Role { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryUsers queries the users edge of a Role. -func (c *RoleClient) QueryUsers(_m *Role) *UserQuery { - query := (&UserClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(role.Table, role.FieldID, id), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, role.UsersTable, role.UsersPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryPermissions queries the permissions edge of a Role. -func (c *RoleClient) QueryPermissions(_m *Role) *PermissionQuery { - query := (&PermissionClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(role.Table, role.FieldID, id), - sqlgraph.To(permission.Table, permission.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, role.PermissionsTable, role.PermissionsPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryUserRoles queries the user_roles edge of a Role. -func (c *RoleClient) QueryUserRoles(_m *Role) *UserRoleQuery { - query := (&UserRoleClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(role.Table, role.FieldID, id), - sqlgraph.To(userrole.Table, userrole.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, role.UserRolesTable, role.UserRolesColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryRolePermissions queries the role_permissions edge of a Role. -func (c *RoleClient) QueryRolePermissions(_m *Role) *RolePermissionQuery { - query := (&RolePermissionClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(role.Table, role.FieldID, id), - sqlgraph.To(rolepermission.Table, rolepermission.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, role.RolePermissionsTable, role.RolePermissionsColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *RoleClient) Hooks() []Hook { - return c.hooks.Role -} - -// Interceptors returns the client interceptors. -func (c *RoleClient) Interceptors() []Interceptor { - return c.inters.Role -} - -func (c *RoleClient) mutate(ctx context.Context, m *RoleMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&RoleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&RoleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&RoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&RoleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown Role mutation op: %q", m.Op()) - } -} - -// RolePermissionClient is a client for the RolePermission schema. -type RolePermissionClient struct { - config -} - -// NewRolePermissionClient returns a client for the RolePermission from the given config. -func NewRolePermissionClient(c config) *RolePermissionClient { - return &RolePermissionClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `rolepermission.Hooks(f(g(h())))`. -func (c *RolePermissionClient) Use(hooks ...Hook) { - c.hooks.RolePermission = append(c.hooks.RolePermission, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `rolepermission.Intercept(f(g(h())))`. -func (c *RolePermissionClient) Intercept(interceptors ...Interceptor) { - c.inters.RolePermission = append(c.inters.RolePermission, interceptors...) -} - -// Create returns a builder for creating a RolePermission entity. -func (c *RolePermissionClient) Create() *RolePermissionCreate { - mutation := newRolePermissionMutation(c.config, OpCreate) - return &RolePermissionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of RolePermission entities. -func (c *RolePermissionClient) CreateBulk(builders ...*RolePermissionCreate) *RolePermissionCreateBulk { - return &RolePermissionCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *RolePermissionClient) MapCreateBulk(slice any, setFunc func(*RolePermissionCreate, int)) *RolePermissionCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &RolePermissionCreateBulk{err: fmt.Errorf("calling to RolePermissionClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*RolePermissionCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &RolePermissionCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for RolePermission. -func (c *RolePermissionClient) Update() *RolePermissionUpdate { - mutation := newRolePermissionMutation(c.config, OpUpdate) - return &RolePermissionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *RolePermissionClient) UpdateOne(_m *RolePermission) *RolePermissionUpdateOne { - mutation := newRolePermissionMutation(c.config, OpUpdateOne, withRolePermission(_m)) - return &RolePermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *RolePermissionClient) UpdateOneID(id int) *RolePermissionUpdateOne { - mutation := newRolePermissionMutation(c.config, OpUpdateOne, withRolePermissionID(id)) - return &RolePermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for RolePermission. -func (c *RolePermissionClient) Delete() *RolePermissionDelete { - mutation := newRolePermissionMutation(c.config, OpDelete) - return &RolePermissionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *RolePermissionClient) DeleteOne(_m *RolePermission) *RolePermissionDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *RolePermissionClient) DeleteOneID(id int) *RolePermissionDeleteOne { - builder := c.Delete().Where(rolepermission.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &RolePermissionDeleteOne{builder} -} - -// Query returns a query builder for RolePermission. -func (c *RolePermissionClient) Query() *RolePermissionQuery { - return &RolePermissionQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeRolePermission}, - inters: c.Interceptors(), - } -} - -// Get returns a RolePermission entity by its id. -func (c *RolePermissionClient) Get(ctx context.Context, id int) (*RolePermission, error) { - return c.Query().Where(rolepermission.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *RolePermissionClient) GetX(ctx context.Context, id int) *RolePermission { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryRole queries the role edge of a RolePermission. -func (c *RolePermissionClient) QueryRole(_m *RolePermission) *RoleQuery { - query := (&RoleClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(rolepermission.Table, rolepermission.FieldID, id), - sqlgraph.To(role.Table, role.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.RoleTable, rolepermission.RoleColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryPermission queries the permission edge of a RolePermission. -func (c *RolePermissionClient) QueryPermission(_m *RolePermission) *PermissionQuery { - query := (&PermissionClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(rolepermission.Table, rolepermission.FieldID, id), - sqlgraph.To(permission.Table, permission.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.PermissionTable, rolepermission.PermissionColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *RolePermissionClient) Hooks() []Hook { - return c.hooks.RolePermission -} - -// Interceptors returns the client interceptors. -func (c *RolePermissionClient) Interceptors() []Interceptor { - return c.inters.RolePermission -} - -func (c *RolePermissionClient) mutate(ctx context.Context, m *RolePermissionMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&RolePermissionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&RolePermissionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&RolePermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&RolePermissionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown RolePermission mutation op: %q", m.Op()) - } -} - -// UserClient is a client for the User schema. -type UserClient struct { - config -} - -// NewUserClient returns a client for the User from the given config. -func NewUserClient(c config) *UserClient { - return &UserClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`. -func (c *UserClient) Use(hooks ...Hook) { - c.hooks.User = append(c.hooks.User, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `user.Intercept(f(g(h())))`. -func (c *UserClient) Intercept(interceptors ...Interceptor) { - c.inters.User = append(c.inters.User, interceptors...) -} - -// Create returns a builder for creating a User entity. -func (c *UserClient) Create() *UserCreate { - mutation := newUserMutation(c.config, OpCreate) - return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of User entities. -func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { - return &UserCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *UserClient) MapCreateBulk(slice any, setFunc func(*UserCreate, int)) *UserCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &UserCreateBulk{err: fmt.Errorf("calling to UserClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*UserCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &UserCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for User. -func (c *UserClient) Update() *UserUpdate { - mutation := newUserMutation(c.config, OpUpdate) - return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *UserClient) UpdateOne(_m *User) *UserUpdateOne { - mutation := newUserMutation(c.config, OpUpdateOne, withUser(_m)) - return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *UserClient) UpdateOneID(id int64) *UserUpdateOne { - mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id)) - return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for User. -func (c *UserClient) Delete() *UserDelete { - mutation := newUserMutation(c.config, OpDelete) - return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *UserClient) DeleteOne(_m *User) *UserDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *UserClient) DeleteOneID(id int64) *UserDeleteOne { - builder := c.Delete().Where(user.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &UserDeleteOne{builder} -} - -// Query returns a query builder for User. -func (c *UserClient) Query() *UserQuery { - return &UserQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeUser}, - inters: c.Interceptors(), - } -} - -// Get returns a User entity by its id. -func (c *UserClient) Get(ctx context.Context, id int64) (*User, error) { - return c.Query().Where(user.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *UserClient) GetX(ctx context.Context, id int64) *User { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryRoles queries the roles edge of a User. -func (c *UserClient) QueryRoles(_m *User) *RoleQuery { - query := (&RoleClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, id), - sqlgraph.To(role.Table, role.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, user.RolesTable, user.RolesPrimaryKey...), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryUserRoles queries the user_roles edge of a User. -func (c *UserClient) QueryUserRoles(_m *User) *UserRoleQuery { - query := (&UserRoleClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, id), - sqlgraph.To(userrole.Table, userrole.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, user.UserRolesTable, user.UserRolesColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *UserClient) Hooks() []Hook { - return c.hooks.User -} - -// Interceptors returns the client interceptors. -func (c *UserClient) Interceptors() []Interceptor { - return c.inters.User -} - -func (c *UserClient) mutate(ctx context.Context, m *UserMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&UserCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&UserUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&UserDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown User mutation op: %q", m.Op()) - } -} - -// UserRoleClient is a client for the UserRole schema. -type UserRoleClient struct { - config -} - -// NewUserRoleClient returns a client for the UserRole from the given config. -func NewUserRoleClient(c config) *UserRoleClient { - return &UserRoleClient{config: c} -} - -// Use adds a list of mutation hooks to the hooks stack. -// A call to `Use(f, g, h)` equals to `userrole.Hooks(f(g(h())))`. -func (c *UserRoleClient) Use(hooks ...Hook) { - c.hooks.UserRole = append(c.hooks.UserRole, hooks...) -} - -// Intercept adds a list of query interceptors to the interceptors stack. -// A call to `Intercept(f, g, h)` equals to `userrole.Intercept(f(g(h())))`. -func (c *UserRoleClient) Intercept(interceptors ...Interceptor) { - c.inters.UserRole = append(c.inters.UserRole, interceptors...) -} - -// Create returns a builder for creating a UserRole entity. -func (c *UserRoleClient) Create() *UserRoleCreate { - mutation := newUserRoleMutation(c.config, OpCreate) - return &UserRoleCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// CreateBulk returns a builder for creating a bulk of UserRole entities. -func (c *UserRoleClient) CreateBulk(builders ...*UserRoleCreate) *UserRoleCreateBulk { - return &UserRoleCreateBulk{config: c.config, builders: builders} -} - -// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates -// a builder and applies setFunc on it. -func (c *UserRoleClient) MapCreateBulk(slice any, setFunc func(*UserRoleCreate, int)) *UserRoleCreateBulk { - rv := reflect.ValueOf(slice) - if rv.Kind() != reflect.Slice { - return &UserRoleCreateBulk{err: fmt.Errorf("calling to UserRoleClient.MapCreateBulk with wrong type %T, need slice", slice)} - } - builders := make([]*UserRoleCreate, rv.Len()) - for i := 0; i < rv.Len(); i++ { - builders[i] = c.Create() - setFunc(builders[i], i) - } - return &UserRoleCreateBulk{config: c.config, builders: builders} -} - -// Update returns an update builder for UserRole. -func (c *UserRoleClient) Update() *UserRoleUpdate { - mutation := newUserRoleMutation(c.config, OpUpdate) - return &UserRoleUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOne returns an update builder for the given entity. -func (c *UserRoleClient) UpdateOne(_m *UserRole) *UserRoleUpdateOne { - mutation := newUserRoleMutation(c.config, OpUpdateOne, withUserRole(_m)) - return &UserRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// UpdateOneID returns an update builder for the given id. -func (c *UserRoleClient) UpdateOneID(id int) *UserRoleUpdateOne { - mutation := newUserRoleMutation(c.config, OpUpdateOne, withUserRoleID(id)) - return &UserRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// Delete returns a delete builder for UserRole. -func (c *UserRoleClient) Delete() *UserRoleDelete { - mutation := newUserRoleMutation(c.config, OpDelete) - return &UserRoleDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} -} - -// DeleteOne returns a builder for deleting the given entity. -func (c *UserRoleClient) DeleteOne(_m *UserRole) *UserRoleDeleteOne { - return c.DeleteOneID(_m.ID) -} - -// DeleteOneID returns a builder for deleting the given entity by its id. -func (c *UserRoleClient) DeleteOneID(id int) *UserRoleDeleteOne { - builder := c.Delete().Where(userrole.ID(id)) - builder.mutation.id = &id - builder.mutation.op = OpDeleteOne - return &UserRoleDeleteOne{builder} -} - -// Query returns a query builder for UserRole. -func (c *UserRoleClient) Query() *UserRoleQuery { - return &UserRoleQuery{ - config: c.config, - ctx: &QueryContext{Type: TypeUserRole}, - inters: c.Interceptors(), - } -} - -// Get returns a UserRole entity by its id. -func (c *UserRoleClient) Get(ctx context.Context, id int) (*UserRole, error) { - return c.Query().Where(userrole.ID(id)).Only(ctx) -} - -// GetX is like Get, but panics if an error occurs. -func (c *UserRoleClient) GetX(ctx context.Context, id int) *UserRole { - obj, err := c.Get(ctx, id) - if err != nil { - panic(err) - } - return obj -} - -// QueryUser queries the user edge of a UserRole. -func (c *UserRoleClient) QueryUser(_m *UserRole) *UserQuery { - query := (&UserClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(userrole.Table, userrole.FieldID, id), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, userrole.UserTable, userrole.UserColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryRole queries the role edge of a UserRole. -func (c *UserRoleClient) QueryRole(_m *UserRole) *RoleQuery { - query := (&RoleClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(userrole.Table, userrole.FieldID, id), - sqlgraph.To(role.Table, role.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, userrole.RoleTable, userrole.RoleColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// Hooks returns the client hooks. -func (c *UserRoleClient) Hooks() []Hook { - return c.hooks.UserRole -} - -// Interceptors returns the client interceptors. -func (c *UserRoleClient) Interceptors() []Interceptor { - return c.inters.UserRole -} - -func (c *UserRoleClient) mutate(ctx context.Context, m *UserRoleMutation) (Value, error) { - switch m.Op() { - case OpCreate: - return (&UserRoleCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdate: - return (&UserRoleUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpUpdateOne: - return (&UserRoleUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) - case OpDelete, OpDeleteOne: - return (&UserRoleDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) - default: - return nil, fmt.Errorf("ent: unknown UserRole mutation op: %q", m.Op()) - } -} - -// hooks and interceptors per client, for fast access. -type ( - hooks struct { - Permission, PermissionResource, Resource, Role, RolePermission, User, - UserRole []ent.Hook - } - inters struct { - Permission, PermissionResource, Resource, Role, RolePermission, User, - UserRole []ent.Interceptor - } -) diff --git a/internal/features/system/data/ent/crud.go b/internal/features/system/data/ent/crud.go deleted file mode 100644 index 1aa9b3b5..00000000 --- a/internal/features/system/data/ent/crud.go +++ /dev/null @@ -1,3 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent diff --git a/internal/features/system/data/ent/database.go b/internal/features/system/data/ent/database.go deleted file mode 100644 index edbfaf14..00000000 --- a/internal/features/system/data/ent/database.go +++ /dev/null @@ -1,149 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -/* Additional dependencies injected to config. */ - -import ( - "context" - "fmt" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/schema" - "github.com/origadmin/runtime/interfaces/storage/database" -) - -// Database is the client that holds all ent builders. -type Database struct { - client *Client -} - -// NewDatabase creates a new database configured with the given options. -func NewDatabase(opts ...Option) *Database { - client := NewClient(opts...) - return &Database{client: client} -} - -// NewDatabase creates a new database configured with the given options. -func NewDatabaseWithClient(client *Client, opts ...Option) *Database { - if client == nil { - client = NewClient(opts...) - } - return &Database{client: client} -} - -func (db *Database) clientDriver(ctx context.Context) dialect.Driver { - tx := TxFromContext(ctx) - c := db.client - if tx != nil { - c = tx.Client() - } - return c.driver -} - -// Tx runs the given function f within a transaction. -func (db *Database) Tx(ctx context.Context, fn func(context.Context) error) error { - tx := TxFromContext(ctx) - if tx != nil { - return fn(ctx) - } - - return db.InTx(ctx, func(tx database.Tx) error { - txv, ok := tx.(*Tx) - if !ok { - return fmt.Errorf("ent: expected tx context") - } - return fn(NewTxContext(ctx, txv)) - }) -} - -// InTx runs the given function f within a transaction. -func (db *Database) InTx(ctx context.Context, fn func(tx database.Tx) error) error { - tx := TxFromContext(ctx) - if tx != nil { - return fn(tx) - } - tx, err := db.client.Tx(ctx) - if err != nil { - return fmt.Errorf("starting transaction: %w", err) - } - if err = fn(tx); err != nil { - if txerr := tx.Rollback(); txerr != nil { - return fmt.Errorf("rolling back transaction: %v (original error: %w)", txerr, err) - } - return err - } - if err := tx.Commit(); err != nil { - return fmt.Errorf("committing transaction: %w", err) - } - return nil -} - -// Client returns the client that holds all ent builders. -func (db *Database) Client(ctx context.Context) *Client { - tx := TxFromContext(ctx) - if tx != nil { - return tx.Client() - } - return db.client -} - -// Exec executes a query that doesn't return rows. For example, in SQL, INSERT or UPDATE. -func (db *Database) Exec(ctx context.Context, query string, args ...interface{}) (*sql.Result, error) { - var res sql.Result - err := db.clientDriver(ctx).Exec(ctx, query, args, &res) - if err != nil { - return nil, err - } - return &res, nil -} - -// Query executes a query that returns rows, typically a SELECT in SQL. -func (db *Database) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) { - var rows sql.Rows - err := db.clientDriver(ctx).Query(ctx, query, args, &rows) - if err != nil { - return nil, err - } - return &rows, nil -} - -// Permission is the client for interacting with the Permission builders. -func (db *Database) Permission(ctx context.Context) *PermissionClient { - return db.Client(ctx).Permission -} - -// PermissionResource is the client for interacting with the PermissionResource builders. -func (db *Database) PermissionResource(ctx context.Context) *PermissionResourceClient { - return db.Client(ctx).PermissionResource -} - -// Resource is the client for interacting with the Resource builders. -func (db *Database) Resource(ctx context.Context) *ResourceClient { - return db.Client(ctx).Resource -} - -// Role is the client for interacting with the Role builders. -func (db *Database) Role(ctx context.Context) *RoleClient { - return db.Client(ctx).Role -} - -// RolePermission is the client for interacting with the RolePermission builders. -func (db *Database) RolePermission(ctx context.Context) *RolePermissionClient { - return db.Client(ctx).RolePermission -} - -// User is the client for interacting with the User builders. -func (db *Database) User(ctx context.Context) *UserClient { - return db.Client(ctx).User -} - -// UserRole is the client for interacting with the UserRole builders. -func (db *Database) UserRole(ctx context.Context) *UserRoleClient { - return db.Client(ctx).UserRole -} - -func (db *Database) Migration(ctx context.Context, opts ...schema.MigrateOption) error { - return db.Client(ctx).Schema.Create(ctx, opts...) -} diff --git a/internal/features/system/data/ent/ent.go b/internal/features/system/data/ent/ent.go deleted file mode 100644 index 3d2a7418..00000000 --- a/internal/features/system/data/ent/ent.go +++ /dev/null @@ -1,620 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - "reflect" - "sync" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ent aliases to avoid import conflicts in user's code. -type ( - Op = ent.Op - Hook = ent.Hook - Value = ent.Value - Query = ent.Query - QueryContext = ent.QueryContext - Querier = ent.Querier - QuerierFunc = ent.QuerierFunc - Interceptor = ent.Interceptor - InterceptFunc = ent.InterceptFunc - Traverser = ent.Traverser - TraverseFunc = ent.TraverseFunc - Policy = ent.Policy - Mutator = ent.Mutator - Mutation = ent.Mutation - MutateFunc = ent.MutateFunc -) - -type clientCtxKey struct{} - -// FromContext returns a Client stored inside a context, or nil if there isn't one. -func FromContext(ctx context.Context) *Client { - c, _ := ctx.Value(clientCtxKey{}).(*Client) - return c -} - -// NewContext returns a new context with the given Client attached. -func NewContext(parent context.Context, c *Client) context.Context { - return context.WithValue(parent, clientCtxKey{}, c) -} - -type txCtxKey struct{} - -// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. -func TxFromContext(ctx context.Context) *Tx { - tx, _ := ctx.Value(txCtxKey{}).(*Tx) - return tx -} - -// NewTxContext returns a new context with the given Tx attached. -func NewTxContext(parent context.Context, tx *Tx) context.Context { - return context.WithValue(parent, txCtxKey{}, tx) -} - -// OrderFunc applies an ordering on the sql selector. -// Deprecated: Use Asc/Desc functions or the package builders instead. -type OrderFunc func(*sql.Selector) - -var ( - initCheck sync.Once - columnCheck sql.ColumnCheck -) - -// checkColumn checks if the column exists in the given table. -func checkColumn(t, c string) error { - initCheck.Do(func() { - columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ - permission.Table: permission.ValidColumn, - permissionresource.Table: permissionresource.ValidColumn, - resource.Table: resource.ValidColumn, - role.Table: role.ValidColumn, - rolepermission.Table: rolepermission.ValidColumn, - user.Table: user.ValidColumn, - userrole.Table: userrole.ValidColumn, - }) - }) - return columnCheck(t, c) -} - -// Asc applies the given fields in ASC order. -func Asc(fields ...string) func(*sql.Selector) { - return func(s *sql.Selector) { - for _, f := range fields { - if err := checkColumn(s.TableName(), f); err != nil { - s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) - } - s.OrderBy(sql.Asc(s.C(f))) - } - } -} - -// Desc applies the given fields in DESC order. -func Desc(fields ...string) func(*sql.Selector) { - return func(s *sql.Selector) { - for _, f := range fields { - if err := checkColumn(s.TableName(), f); err != nil { - s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) - } - s.OrderBy(sql.Desc(s.C(f))) - } - } -} - -// AggregateFunc applies an aggregation step on the group-by traversal/selector. -type AggregateFunc func(*sql.Selector) string - -// As is a pseudo aggregation function for renaming another other functions with custom names. For example: -// -// GroupBy(field1, field2). -// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). -// Scan(ctx, &v) -func As(fn AggregateFunc, end string) AggregateFunc { - return func(s *sql.Selector) string { - return sql.As(fn(s), end) - } -} - -// Count applies the "count" aggregation function on each group. -func Count() AggregateFunc { - return func(s *sql.Selector) string { - return sql.Count("*") - } -} - -// Max applies the "max" aggregation function on the given field of each group. -func Max(field string) AggregateFunc { - return func(s *sql.Selector) string { - if err := checkColumn(s.TableName(), field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Max(s.C(field)) - } -} - -// Mean applies the "mean" aggregation function on the given field of each group. -func Mean(field string) AggregateFunc { - return func(s *sql.Selector) string { - if err := checkColumn(s.TableName(), field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Avg(s.C(field)) - } -} - -// Min applies the "min" aggregation function on the given field of each group. -func Min(field string) AggregateFunc { - return func(s *sql.Selector) string { - if err := checkColumn(s.TableName(), field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Min(s.C(field)) - } -} - -// Sum applies the "sum" aggregation function on the given field of each group. -func Sum(field string) AggregateFunc { - return func(s *sql.Selector) string { - if err := checkColumn(s.TableName(), field); err != nil { - s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) - return "" - } - return sql.Sum(s.C(field)) - } -} - -// ValidationError returns when validating a field or edge fails. -type ValidationError struct { - Name string // Field or edge name. - err error -} - -// Error implements the error interface. -func (e *ValidationError) Error() string { - return e.err.Error() -} - -// Unwrap implements the errors.Wrapper interface. -func (e *ValidationError) Unwrap() error { - return e.err -} - -// IsValidationError returns a boolean indicating whether the error is a validation error. -func IsValidationError(err error) bool { - if err == nil { - return false - } - var e *ValidationError - return errors.As(err, &e) -} - -// NotFoundError returns when trying to fetch a specific entity and it was not found in the database. -type NotFoundError struct { - label string -} - -// Error implements the error interface. -func (e *NotFoundError) Error() string { - return "ent: " + e.label + " not found" -} - -// IsNotFound returns a boolean indicating whether the error is a not found error. -func IsNotFound(err error) bool { - if err == nil { - return false - } - var e *NotFoundError - return errors.As(err, &e) -} - -// MaskNotFound masks not found error. -func MaskNotFound(err error) error { - if IsNotFound(err) { - return nil - } - return err -} - -// NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. -type NotSingularError struct { - label string -} - -// Error implements the error interface. -func (e *NotSingularError) Error() string { - return "ent: " + e.label + " not singular" -} - -// IsNotSingular returns a boolean indicating whether the error is a not singular error. -func IsNotSingular(err error) bool { - if err == nil { - return false - } - var e *NotSingularError - return errors.As(err, &e) -} - -// NotLoadedError returns when trying to get a node that was not loaded by the query. -type NotLoadedError struct { - edge string -} - -// Error implements the error interface. -func (e *NotLoadedError) Error() string { - return "ent: " + e.edge + " edge was not loaded" -} - -// IsNotLoaded returns a boolean indicating whether the error is a not loaded error. -func IsNotLoaded(err error) bool { - if err == nil { - return false - } - var e *NotLoadedError - return errors.As(err, &e) -} - -// ConstraintError returns when trying to create/update one or more entities and -// one or more of their constraints failed. For example, violation of edge or -// field uniqueness. -type ConstraintError struct { - msg string - wrap error -} - -// Error implements the error interface. -func (e ConstraintError) Error() string { - return "ent: constraint failed: " + e.msg -} - -// Unwrap implements the errors.Wrapper interface. -func (e *ConstraintError) Unwrap() error { - return e.wrap -} - -// IsConstraintError returns a boolean indicating whether the error is a constraint failure. -func IsConstraintError(err error) bool { - if err == nil { - return false - } - var e *ConstraintError - return errors.As(err, &e) -} - -// selector embedded by the different Select/GroupBy builders. -type selector struct { - label string - flds *[]string - fns []AggregateFunc - scan func(context.Context, any) error -} - -// ScanX is like Scan, but panics if an error occurs. -func (s *selector) ScanX(ctx context.Context, v any) { - if err := s.scan(ctx, v); err != nil { - panic(err) - } -} - -// Strings returns list of strings from a selector. It is only allowed when selecting one field. -func (s *selector) Strings(ctx context.Context) ([]string, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") - } - var v []string - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// StringsX is like Strings, but panics if an error occurs. -func (s *selector) StringsX(ctx context.Context) []string { - v, err := s.Strings(ctx) - if err != nil { - panic(err) - } - return v -} - -// String returns a single string from a selector. It is only allowed when selecting one field. -func (s *selector) String(ctx context.Context) (_ string, err error) { - var v []string - if v, err = s.Strings(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) - } - return -} - -// StringX is like String, but panics if an error occurs. -func (s *selector) StringX(ctx context.Context) string { - v, err := s.String(ctx) - if err != nil { - panic(err) - } - return v -} - -// Ints returns list of ints from a selector. It is only allowed when selecting one field. -func (s *selector) Ints(ctx context.Context) ([]int, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") - } - var v []int - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// IntsX is like Ints, but panics if an error occurs. -func (s *selector) IntsX(ctx context.Context) []int { - v, err := s.Ints(ctx) - if err != nil { - panic(err) - } - return v -} - -// Int returns a single int from a selector. It is only allowed when selecting one field. -func (s *selector) Int(ctx context.Context) (_ int, err error) { - var v []int - if v, err = s.Ints(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) - } - return -} - -// IntX is like Int, but panics if an error occurs. -func (s *selector) IntX(ctx context.Context) int { - v, err := s.Int(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64s returns list of float64s from a selector. It is only allowed when selecting one field. -func (s *selector) Float64s(ctx context.Context) ([]float64, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") - } - var v []float64 - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// Float64sX is like Float64s, but panics if an error occurs. -func (s *selector) Float64sX(ctx context.Context) []float64 { - v, err := s.Float64s(ctx) - if err != nil { - panic(err) - } - return v -} - -// Float64 returns a single float64 from a selector. It is only allowed when selecting one field. -func (s *selector) Float64(ctx context.Context) (_ float64, err error) { - var v []float64 - if v, err = s.Float64s(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) - } - return -} - -// Float64X is like Float64, but panics if an error occurs. -func (s *selector) Float64X(ctx context.Context) float64 { - v, err := s.Float64(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bools returns list of bools from a selector. It is only allowed when selecting one field. -func (s *selector) Bools(ctx context.Context) ([]bool, error) { - if len(*s.flds) > 1 { - return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") - } - var v []bool - if err := s.scan(ctx, &v); err != nil { - return nil, err - } - return v, nil -} - -// BoolsX is like Bools, but panics if an error occurs. -func (s *selector) BoolsX(ctx context.Context) []bool { - v, err := s.Bools(ctx) - if err != nil { - panic(err) - } - return v -} - -// Bool returns a single bool from a selector. It is only allowed when selecting one field. -func (s *selector) Bool(ctx context.Context) (_ bool, err error) { - var v []bool - if v, err = s.Bools(ctx); err != nil { - return - } - switch len(v) { - case 1: - return v[0], nil - case 0: - err = &NotFoundError{s.label} - default: - err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) - } - return -} - -// BoolX is like Bool, but panics if an error occurs. -func (s *selector) BoolX(ctx context.Context) bool { - v, err := s.Bool(ctx) - if err != nil { - panic(err) - } - return v -} - -// withHooks invokes the builder operation with the given hooks, if any. -func withHooks[V Value, M any, PM interface { - *M - Mutation -}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { - if len(hooks) == 0 { - return exec(ctx) - } - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutationT, ok := any(m).(PM) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - // Set the mutation to the builder. - *mutation = *mutationT - return exec(ctx) - }) - for i := len(hooks) - 1; i >= 0; i-- { - if hooks[i] == nil { - return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = hooks[i](mut) - } - v, err := mut.Mutate(ctx, mutation) - if err != nil { - return value, err - } - nv, ok := v.(V) - if !ok { - return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) - } - return nv, nil -} - -// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. -func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { - if ent.QueryFromContext(ctx) == nil { - qc.Op = op - ctx = ent.NewQueryContext(ctx, qc) - } - return ctx -} - -func querierAll[V Value, Q interface { - sqlAll(context.Context, ...queryHook) (V, error) -}]() Querier { - return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - query, ok := q.(Q) - if !ok { - return nil, fmt.Errorf("unexpected query type %T", q) - } - return query.sqlAll(ctx) - }) -} - -func querierCount[Q interface { - sqlCount(context.Context) (int, error) -}]() Querier { - return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - query, ok := q.(Q) - if !ok { - return nil, fmt.Errorf("unexpected query type %T", q) - } - return query.sqlCount(ctx) - }) -} - -func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { - for i := len(inters) - 1; i >= 0; i-- { - qr = inters[i].Intercept(qr) - } - rv, err := qr.Query(ctx, q) - if err != nil { - return v, err - } - vt, ok := rv.(V) - if !ok { - return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) - } - return vt, nil -} - -func scanWithInterceptors[Q1 ent.Query, Q2 interface { - sqlScan(context.Context, Q1, any) error -}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { - rv := reflect.ValueOf(v) - var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - query, ok := q.(Q1) - if !ok { - return nil, fmt.Errorf("unexpected query type %T", q) - } - if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { - return nil, err - } - if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { - return rv.Elem().Interface(), nil - } - return v, nil - }) - for i := len(inters) - 1; i >= 0; i-- { - qr = inters[i].Intercept(qr) - } - vv, err := qr.Query(ctx, rootQuery) - if err != nil { - return err - } - switch rv2 := reflect.ValueOf(vv); { - case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: - case rv.Type() == rv2.Type(): - rv.Elem().Set(rv2.Elem()) - case rv.Elem().Type() == rv2.Type(): - rv.Elem().Set(rv2) - } - return nil -} - -// queryHook describes an internal hook for the different sqlAll methods. -type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/internal/features/system/data/ent/enttest/enttest.go b/internal/features/system/data/ent/enttest/enttest.go deleted file mode 100644 index 13cc1fd1..00000000 --- a/internal/features/system/data/ent/enttest/enttest.go +++ /dev/null @@ -1,85 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package enttest - -import ( - "context" - - "origadmin/application/admin/internal/features/system/data/ent" - // required by schema hooks. - _ "origadmin/application/admin/internal/features/system/data/ent/runtime" - - "origadmin/application/admin/internal/features/system/data/ent/migrate" - - "entgo.io/ent/dialect/sql/schema" -) - -type ( - // TestingT is the interface that is shared between - // testing.T and testing.B and used by enttest. - TestingT interface { - FailNow() - Error(...any) - } - - // Option configures client creation. - Option func(*options) - - options struct { - opts []ent.Option - migrateOpts []schema.MigrateOption - } -) - -// WithOptions forwards options to client creation. -func WithOptions(opts ...ent.Option) Option { - return func(o *options) { - o.opts = append(o.opts, opts...) - } -} - -// WithMigrateOptions forwards options to auto migration. -func WithMigrateOptions(opts ...schema.MigrateOption) Option { - return func(o *options) { - o.migrateOpts = append(o.migrateOpts, opts...) - } -} - -func newOptions(opts []Option) *options { - o := &options{} - for _, opt := range opts { - opt(o) - } - return o -} - -// Open calls ent.Open and auto-run migration. -func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { - o := newOptions(opts) - c, err := ent.Open(driverName, dataSourceName, o.opts...) - if err != nil { - t.Error(err) - t.FailNow() - } - migrateSchema(t, c, o) - return c -} - -// NewClient calls ent.NewClient and auto-run migration. -func NewClient(t TestingT, opts ...Option) *ent.Client { - o := newOptions(opts) - c := ent.NewClient(o.opts...) - migrateSchema(t, c, o) - return c -} -func migrateSchema(t TestingT, c *ent.Client, o *options) { - tables, err := schema.CopyTables(migrate.Tables) - if err != nil { - t.Error(err) - t.FailNow() - } - if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { - t.Error(err) - t.FailNow() - } -} diff --git a/internal/features/system/data/ent/generate.go b/internal/features/system/data/ent/generate.go deleted file mode 100644 index 44a6c363..00000000 --- a/internal/features/system/data/ent/generate.go +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package entity is the data access object for SYS. -package ent - -//go:generate go run entgo.io/ent/cmd/ent generate --template ./template --feature intercept --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema diff --git a/internal/features/system/data/ent/hook/hook.go b/internal/features/system/data/ent/hook/hook.go deleted file mode 100644 index b1102f59..00000000 --- a/internal/features/system/data/ent/hook/hook.go +++ /dev/null @@ -1,270 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package hook - -import ( - "context" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent" -) - -// The PermissionFunc type is an adapter to allow the use of ordinary -// function as Permission mutator. -type PermissionFunc func(context.Context, *ent.PermissionMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f PermissionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.PermissionMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PermissionMutation", m) -} - -// The PermissionResourceFunc type is an adapter to allow the use of ordinary -// function as PermissionResource mutator. -type PermissionResourceFunc func(context.Context, *ent.PermissionResourceMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f PermissionResourceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.PermissionResourceMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PermissionResourceMutation", m) -} - -// The ResourceFunc type is an adapter to allow the use of ordinary -// function as Resource mutator. -type ResourceFunc func(context.Context, *ent.ResourceMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f ResourceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.ResourceMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ResourceMutation", m) -} - -// The RoleFunc type is an adapter to allow the use of ordinary -// function as Role mutator. -type RoleFunc func(context.Context, *ent.RoleMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f RoleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.RoleMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RoleMutation", m) -} - -// The RolePermissionFunc type is an adapter to allow the use of ordinary -// function as RolePermission mutator. -type RolePermissionFunc func(context.Context, *ent.RolePermissionMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f RolePermissionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.RolePermissionMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RolePermissionMutation", m) -} - -// The UserFunc type is an adapter to allow the use of ordinary -// function as User mutator. -type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.UserMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m) -} - -// The UserRoleFunc type is an adapter to allow the use of ordinary -// function as UserRole mutator. -type UserRoleFunc func(context.Context, *ent.UserRoleMutation) (ent.Value, error) - -// Mutate calls f(ctx, m). -func (f UserRoleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if mv, ok := m.(*ent.UserRoleMutation); ok { - return f(ctx, mv) - } - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserRoleMutation", m) -} - -// Condition is a hook condition function. -type Condition func(context.Context, ent.Mutation) bool - -// And groups conditions with the AND operator. -func And(first, second Condition, rest ...Condition) Condition { - return func(ctx context.Context, m ent.Mutation) bool { - if !first(ctx, m) || !second(ctx, m) { - return false - } - for _, cond := range rest { - if !cond(ctx, m) { - return false - } - } - return true - } -} - -// Or groups conditions with the OR operator. -func Or(first, second Condition, rest ...Condition) Condition { - return func(ctx context.Context, m ent.Mutation) bool { - if first(ctx, m) || second(ctx, m) { - return true - } - for _, cond := range rest { - if cond(ctx, m) { - return true - } - } - return false - } -} - -// Not negates a given condition. -func Not(cond Condition) Condition { - return func(ctx context.Context, m ent.Mutation) bool { - return !cond(ctx, m) - } -} - -// HasOp is a condition testing mutation operation. -func HasOp(op ent.Op) Condition { - return func(_ context.Context, m ent.Mutation) bool { - return m.Op().Is(op) - } -} - -// HasAddedFields is a condition validating `.AddedField` on fields. -func HasAddedFields(field string, fields ...string) Condition { - return func(_ context.Context, m ent.Mutation) bool { - if _, exists := m.AddedField(field); !exists { - return false - } - for _, field := range fields { - if _, exists := m.AddedField(field); !exists { - return false - } - } - return true - } -} - -// HasClearedFields is a condition validating `.FieldCleared` on fields. -func HasClearedFields(field string, fields ...string) Condition { - return func(_ context.Context, m ent.Mutation) bool { - if exists := m.FieldCleared(field); !exists { - return false - } - for _, field := range fields { - if exists := m.FieldCleared(field); !exists { - return false - } - } - return true - } -} - -// HasFields is a condition validating `.Field` on fields. -func HasFields(field string, fields ...string) Condition { - return func(_ context.Context, m ent.Mutation) bool { - if _, exists := m.Field(field); !exists { - return false - } - for _, field := range fields { - if _, exists := m.Field(field); !exists { - return false - } - } - return true - } -} - -// If executes the given hook under condition. -// -// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) -func If(hk ent.Hook, cond Condition) ent.Hook { - return func(next ent.Mutator) ent.Mutator { - return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { - if cond(ctx, m) { - return hk(next).Mutate(ctx, m) - } - return next.Mutate(ctx, m) - }) - } -} - -// On executes the given hook only for the given operation. -// -// hook.On(Log, ent.Delete|ent.Create) -func On(hk ent.Hook, op ent.Op) ent.Hook { - return If(hk, HasOp(op)) -} - -// Unless skips the given hook only for the given operation. -// -// hook.Unless(Log, ent.Update|ent.UpdateOne) -func Unless(hk ent.Hook, op ent.Op) ent.Hook { - return If(hk, Not(HasOp(op))) -} - -// FixedError is a hook returning a fixed error. -func FixedError(err error) ent.Hook { - return func(ent.Mutator) ent.Mutator { - return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { - return nil, err - }) - } -} - -// Reject returns a hook that rejects all operations that match op. -// -// func (T) Hooks() []ent.Hook { -// return []ent.Hook{ -// Reject(ent.Delete|ent.Update), -// } -// } -func Reject(op ent.Op) ent.Hook { - hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) - return On(hk, op) -} - -// Chain acts as a list of hooks and is effectively immutable. -// Once created, it will always hold the same set of hooks in the same order. -type Chain struct { - hooks []ent.Hook -} - -// NewChain creates a new chain of hooks. -func NewChain(hooks ...ent.Hook) Chain { - return Chain{append([]ent.Hook(nil), hooks...)} -} - -// Hook chains the list of hooks and returns the final hook. -func (c Chain) Hook() ent.Hook { - return func(mutator ent.Mutator) ent.Mutator { - for i := len(c.hooks) - 1; i >= 0; i-- { - mutator = c.hooks[i](mutator) - } - return mutator - } -} - -// Append extends a chain, adding the specified hook -// as the last ones in the mutation flow. -func (c Chain) Append(hooks ...ent.Hook) Chain { - newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) - newHooks = append(newHooks, c.hooks...) - newHooks = append(newHooks, hooks...) - return Chain{newHooks} -} - -// Extend extends a chain, adding the specified chain -// as the last ones in the mutation flow. -func (c Chain) Extend(chain Chain) Chain { - return c.Append(chain.hooks...) -} diff --git a/internal/features/system/data/ent/intercept/intercept.go b/internal/features/system/data/ent/intercept/intercept.go deleted file mode 100644 index a1a0b914..00000000 --- a/internal/features/system/data/ent/intercept/intercept.go +++ /dev/null @@ -1,330 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package intercept - -import ( - "context" - "fmt" - - "origadmin/application/admin/internal/features/system/data/ent" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - - "entgo.io/ent/dialect/sql" -) - -// The Query interface represents an operation that queries a graph. -// By using this interface, users can write generic code that manipulates -// query builders of different types. -type Query interface { - // Type returns the string representation of the query type. - Type() string - // Limit the number of records to be returned by this query. - Limit(int) - // Offset to start from. - Offset(int) - // Unique configures the query builder to filter duplicate records. - Unique(bool) - // Order specifies how the records should be ordered. - Order(...func(*sql.Selector)) - // WhereP appends storage-level predicates to the query builder. Using this method, users - // can use type-assertion to append predicates that do not depend on any generated package. - WhereP(...func(*sql.Selector)) -} - -// The Func type is an adapter that allows ordinary functions to be used as interceptors. -// Unlike traversal functions, interceptors are skipped during graph traversals. Note that the -// implementation of Func is different from the one defined in entgo.io/ent.InterceptFunc. -type Func func(context.Context, Query) error - -// Intercept calls f(ctx, q) and then applied the next Querier. -func (f Func) Intercept(next ent.Querier) ent.Querier { - return ent.QuerierFunc(func(ctx context.Context, q ent.Query) (ent.Value, error) { - query, err := NewQuery(q) - if err != nil { - return nil, err - } - if err := f(ctx, query); err != nil { - return nil, err - } - return next.Query(ctx, q) - }) -} - -// The TraverseFunc type is an adapter to allow the use of ordinary function as Traverser. -// If f is a function with the appropriate signature, TraverseFunc(f) is a Traverser that calls f. -type TraverseFunc func(context.Context, Query) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseFunc) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseFunc) Traverse(ctx context.Context, q ent.Query) error { - query, err := NewQuery(q) - if err != nil { - return err - } - return f(ctx, query) -} - -// The PermissionFunc type is an adapter to allow the use of ordinary function as a Querier. -type PermissionFunc func(context.Context, *ent.PermissionQuery) (ent.Value, error) - -// Query calls f(ctx, q). -func (f PermissionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { - if q, ok := q.(*ent.PermissionQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *ent.PermissionQuery", q) -} - -// The TraversePermission type is an adapter to allow the use of ordinary function as Traverser. -type TraversePermission func(context.Context, *ent.PermissionQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraversePermission) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraversePermission) Traverse(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.PermissionQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *ent.PermissionQuery", q) -} - -// The PermissionResourceFunc type is an adapter to allow the use of ordinary function as a Querier. -type PermissionResourceFunc func(context.Context, *ent.PermissionResourceQuery) (ent.Value, error) - -// Query calls f(ctx, q). -func (f PermissionResourceFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { - if q, ok := q.(*ent.PermissionResourceQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *ent.PermissionResourceQuery", q) -} - -// The TraversePermissionResource type is an adapter to allow the use of ordinary function as Traverser. -type TraversePermissionResource func(context.Context, *ent.PermissionResourceQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraversePermissionResource) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraversePermissionResource) Traverse(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.PermissionResourceQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *ent.PermissionResourceQuery", q) -} - -// The ResourceFunc type is an adapter to allow the use of ordinary function as a Querier. -type ResourceFunc func(context.Context, *ent.ResourceQuery) (ent.Value, error) - -// Query calls f(ctx, q). -func (f ResourceFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { - if q, ok := q.(*ent.ResourceQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *ent.ResourceQuery", q) -} - -// The TraverseResource type is an adapter to allow the use of ordinary function as Traverser. -type TraverseResource func(context.Context, *ent.ResourceQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseResource) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseResource) Traverse(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.ResourceQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *ent.ResourceQuery", q) -} - -// The RoleFunc type is an adapter to allow the use of ordinary function as a Querier. -type RoleFunc func(context.Context, *ent.RoleQuery) (ent.Value, error) - -// Query calls f(ctx, q). -func (f RoleFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { - if q, ok := q.(*ent.RoleQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *ent.RoleQuery", q) -} - -// The TraverseRole type is an adapter to allow the use of ordinary function as Traverser. -type TraverseRole func(context.Context, *ent.RoleQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseRole) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseRole) Traverse(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.RoleQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *ent.RoleQuery", q) -} - -// The RolePermissionFunc type is an adapter to allow the use of ordinary function as a Querier. -type RolePermissionFunc func(context.Context, *ent.RolePermissionQuery) (ent.Value, error) - -// Query calls f(ctx, q). -func (f RolePermissionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { - if q, ok := q.(*ent.RolePermissionQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *ent.RolePermissionQuery", q) -} - -// The TraverseRolePermission type is an adapter to allow the use of ordinary function as Traverser. -type TraverseRolePermission func(context.Context, *ent.RolePermissionQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseRolePermission) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseRolePermission) Traverse(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.RolePermissionQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *ent.RolePermissionQuery", q) -} - -// The UserFunc type is an adapter to allow the use of ordinary function as a Querier. -type UserFunc func(context.Context, *ent.UserQuery) (ent.Value, error) - -// Query calls f(ctx, q). -func (f UserFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { - if q, ok := q.(*ent.UserQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserQuery", q) -} - -// The TraverseUser type is an adapter to allow the use of ordinary function as Traverser. -type TraverseUser func(context.Context, *ent.UserQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseUser) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseUser) Traverse(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.UserQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *ent.UserQuery", q) -} - -// The UserRoleFunc type is an adapter to allow the use of ordinary function as a Querier. -type UserRoleFunc func(context.Context, *ent.UserRoleQuery) (ent.Value, error) - -// Query calls f(ctx, q). -func (f UserRoleFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { - if q, ok := q.(*ent.UserRoleQuery); ok { - return f(ctx, q) - } - return nil, fmt.Errorf("unexpected query type %T. expect *ent.UserRoleQuery", q) -} - -// The TraverseUserRole type is an adapter to allow the use of ordinary function as Traverser. -type TraverseUserRole func(context.Context, *ent.UserRoleQuery) error - -// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. -func (f TraverseUserRole) Intercept(next ent.Querier) ent.Querier { - return next -} - -// Traverse calls f(ctx, q). -func (f TraverseUserRole) Traverse(ctx context.Context, q ent.Query) error { - if q, ok := q.(*ent.UserRoleQuery); ok { - return f(ctx, q) - } - return fmt.Errorf("unexpected query type %T. expect *ent.UserRoleQuery", q) -} - -// NewQuery returns the generic Query interface for the given typed query. -func NewQuery(q ent.Query) (Query, error) { - switch q := q.(type) { - case *ent.PermissionQuery: - return &query[*ent.PermissionQuery, predicate.Permission, permission.OrderOption]{typ: ent.TypePermission, tq: q}, nil - case *ent.PermissionResourceQuery: - return &query[*ent.PermissionResourceQuery, predicate.PermissionResource, permissionresource.OrderOption]{typ: ent.TypePermissionResource, tq: q}, nil - case *ent.ResourceQuery: - return &query[*ent.ResourceQuery, predicate.Resource, resource.OrderOption]{typ: ent.TypeResource, tq: q}, nil - case *ent.RoleQuery: - return &query[*ent.RoleQuery, predicate.Role, role.OrderOption]{typ: ent.TypeRole, tq: q}, nil - case *ent.RolePermissionQuery: - return &query[*ent.RolePermissionQuery, predicate.RolePermission, rolepermission.OrderOption]{typ: ent.TypeRolePermission, tq: q}, nil - case *ent.UserQuery: - return &query[*ent.UserQuery, predicate.User, user.OrderOption]{typ: ent.TypeUser, tq: q}, nil - case *ent.UserRoleQuery: - return &query[*ent.UserRoleQuery, predicate.UserRole, userrole.OrderOption]{typ: ent.TypeUserRole, tq: q}, nil - default: - return nil, fmt.Errorf("unknown query type %T", q) - } -} - -type query[T any, P ~func(*sql.Selector), R ~func(*sql.Selector)] struct { - typ string - tq interface { - Limit(int) T - Offset(int) T - Unique(bool) T - Order(...R) T - Where(...P) T - } -} - -func (q query[T, P, R]) Type() string { - return q.typ -} - -func (q query[T, P, R]) Limit(limit int) { - q.tq.Limit(limit) -} - -func (q query[T, P, R]) Offset(offset int) { - q.tq.Offset(offset) -} - -func (q query[T, P, R]) Unique(unique bool) { - q.tq.Unique(unique) -} - -func (q query[T, P, R]) Order(orders ...func(*sql.Selector)) { - rs := make([]R, len(orders)) - for i := range orders { - rs[i] = orders[i] - } - q.tq.Order(rs...) -} - -func (q query[T, P, R]) WhereP(ps ...func(*sql.Selector)) { - p := make([]P, len(ps)) - for i := range ps { - p[i] = ps[i] - } - q.tq.Where(p...) -} diff --git a/internal/features/system/data/ent/migrate/migrate.go b/internal/features/system/data/ent/migrate/migrate.go deleted file mode 100644 index d8d3bcb8..00000000 --- a/internal/features/system/data/ent/migrate/migrate.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package migrate - -import ( - "context" - "fmt" - "io" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql/schema" -) - -var ( - // WithGlobalUniqueID sets the universal ids options to the migration. - // If this option is enabled, ent migration will allocate a 1<<32 range - // for the ids of each entity (table). - // Note that this option cannot be applied on tables that already exist. - WithGlobalUniqueID = schema.WithGlobalUniqueID - // WithDropColumn sets the drop column option to the migration. - // If this option is enabled, ent migration will drop old columns - // that were used for both fields and edges. This defaults to false. - WithDropColumn = schema.WithDropColumn - // WithDropIndex sets the drop index option to the migration. - // If this option is enabled, ent migration will drop old indexes - // that were defined in the schema. This defaults to false. - // Note that unique constraints are defined using `UNIQUE INDEX`, - // and therefore, it's recommended to enable this option to get more - // flexibility in the schema changes. - WithDropIndex = schema.WithDropIndex - // WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. - WithForeignKeys = schema.WithForeignKeys -) - -// Schema is the API for creating, migrating and dropping a schema. -type Schema struct { - drv dialect.Driver -} - -// NewSchema creates a new schema client. -func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } - -// Create creates all schema resources. -func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { - return Create(ctx, s, Tables, opts...) -} - -// Create creates all table resources using the given schema driver. -func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { - migrate, err := schema.NewMigrate(s.drv, opts...) - if err != nil { - return fmt.Errorf("ent/migrate: %w", err) - } - return migrate.Create(ctx, tables...) -} - -// Diff compares the state read from a database connection or migration directory with -// the state defined by the Ent schema. Changes will be written to new migration files. -func Diff(ctx context.Context, url string, opts ...schema.MigrateOption) error { - return NamedDiff(ctx, url, "changes", opts...) -} - -// NamedDiff compares the state read from a database connection or migration directory with -// the state defined by the Ent schema. Changes will be written to new named migration files. -func NamedDiff(ctx context.Context, url, name string, opts ...schema.MigrateOption) error { - return schema.Diff(ctx, url, name, Tables, opts...) -} - -// Diff creates a migration file containing the statements to resolve the diff -// between the Ent schema and the connected database. -func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error { - migrate, err := schema.NewMigrate(s.drv, opts...) - if err != nil { - return fmt.Errorf("ent/migrate: %w", err) - } - return migrate.Diff(ctx, Tables...) -} - -// NamedDiff creates a named migration file containing the statements to resolve the diff -// between the Ent schema and the connected database. -func (s *Schema) NamedDiff(ctx context.Context, name string, opts ...schema.MigrateOption) error { - migrate, err := schema.NewMigrate(s.drv, opts...) - if err != nil { - return fmt.Errorf("ent/migrate: %w", err) - } - return migrate.NamedDiff(ctx, name, Tables...) -} - -// WriteTo writes the schema changes to w instead of running them against the database. -// -// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { -// log.Fatal(err) -// } -func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { - return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) -} diff --git a/internal/features/system/data/ent/migrate/schema.go b/internal/features/system/data/ent/migrate/schema.go deleted file mode 100644 index 29bfd6cf..00000000 --- a/internal/features/system/data/ent/migrate/schema.go +++ /dev/null @@ -1,313 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package migrate - -import ( - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/dialect/sql/schema" - "entgo.io/ent/schema/field" -) - -var ( - // SysPermissionsColumns holds the columns for the "sys_permissions" table. - SysPermissionsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"}, - {Name: "create_time", Type: field.TypeTime}, - {Name: "update_time", Type: field.TypeTime}, - {Name: "name", Type: field.TypeString, Size: 64, Comment: "Name", Default: ""}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 64, Comment: "Keyword"}, - {Name: "description", Type: field.TypeString, Size: 1024, Comment: "Description", Default: ""}, - {Name: "data_scope", Type: field.TypeString, Comment: "Data scope", Default: "self"}, - {Name: "data_rules", Type: field.TypeJSON, Nullable: true, Comment: "Data rules"}, - {Name: "actions", Type: field.TypeEnum, Comment: "Actions", Enums: []string{"read", "write", "delete", "manage"}, Default: "read"}, - } - // SysPermissionsTable holds the schema information for the "sys_permissions" table. - SysPermissionsTable = &schema.Table{ - Name: "sys_permissions", - Comment: "Permission table", - Columns: SysPermissionsColumns, - PrimaryKey: []*schema.Column{SysPermissionsColumns[0]}, - } - // SysPermissionResourcesColumns holds the columns for the "sys_permission_resources" table. - SysPermissionResourcesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "permission_id", Type: field.TypeInt64}, - {Name: "resource_id", Type: field.TypeInt64}, - } - // SysPermissionResourcesTable holds the schema information for the "sys_permission_resources" table. - SysPermissionResourcesTable = &schema.Table{ - Name: "sys_permission_resources", - Comment: "Permission-Resource mapping table", - Columns: SysPermissionResourcesColumns, - PrimaryKey: []*schema.Column{SysPermissionResourcesColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "sys_permission_resources_sys_permissions_permission", - Columns: []*schema.Column{SysPermissionResourcesColumns[1]}, - RefColumns: []*schema.Column{SysPermissionsColumns[0]}, - OnDelete: schema.NoAction, - }, - { - Symbol: "sys_permission_resources_sys_resources_resource", - Columns: []*schema.Column{SysPermissionResourcesColumns[2]}, - RefColumns: []*schema.Column{SysResourcesColumns[0]}, - OnDelete: schema.NoAction, - }, - }, - Indexes: []*schema.Index{ - { - Name: "permissionresource_permission_id_resource_id", - Unique: true, - Columns: []*schema.Column{SysPermissionResourcesColumns[1], SysPermissionResourcesColumns[2]}, - }, - }, - } - // SysResourcesColumns holds the columns for the "sys_resources" table. - SysResourcesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"}, - {Name: "create_time", Type: field.TypeTime}, - {Name: "update_time", Type: field.TypeTime}, - {Name: "name", Type: field.TypeString, Size: 128, Comment: "Name", Default: ""}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 64, Comment: "Keyword"}, - {Name: "type", Type: field.TypeString, Size: 2, Comment: "Type", Default: "M"}, - {Name: "status", Type: field.TypeInt8, Comment: "Status", Default: 1}, - {Name: "path", Type: field.TypeString, Size: 256, Comment: "Path", Default: ""}, - {Name: "component", Type: field.TypeString, Size: 128, Comment: "Component", Default: ""}, - {Name: "icon", Type: field.TypeString, Size: 64, Comment: "Icon", Default: ""}, - {Name: "sequence", Type: field.TypeInt, Comment: "Sequence", Default: 0}, - {Name: "visible", Type: field.TypeBool, Comment: "Visible", Default: true}, - {Name: "level", Type: field.TypeInt8, Comment: "Level", Default: 0}, - {Name: "tree_path", Type: field.TypeString, Size: 256, Comment: "Tree path", Default: ""}, - {Name: "properties", Type: field.TypeJSON, Nullable: true, Comment: "Properties"}, - {Name: "description", Type: field.TypeString, Size: 1024, Comment: "Description", Default: ""}, - {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "Parent ID"}, - } - // SysResourcesTable holds the schema information for the "sys_resources" table. - SysResourcesTable = &schema.Table{ - Name: "sys_resources", - Comment: "Resource table", - Columns: SysResourcesColumns, - PrimaryKey: []*schema.Column{SysResourcesColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "sys_resources_sys_resources_children", - Columns: []*schema.Column{SysResourcesColumns[16]}, - RefColumns: []*schema.Column{SysResourcesColumns[0]}, - OnDelete: schema.SetNull, - }, - }, - Indexes: []*schema.Index{ - { - Name: "resource_parent_id", - Unique: false, - Columns: []*schema.Column{SysResourcesColumns[16]}, - }, - { - Name: "resource_level", - Unique: false, - Columns: []*schema.Column{SysResourcesColumns[12]}, - }, - }, - } - // SysRolesColumns holds the columns for the "sys_roles" table. - SysRolesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"}, - {Name: "create_time", Type: field.TypeTime}, - {Name: "update_time", Type: field.TypeTime}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 32, Comment: "keyword of role (unique)"}, - {Name: "name", Type: field.TypeString, Size: 128, Comment: "Display name of role", Default: ""}, - {Name: "description", Type: field.TypeString, Size: 1024, Comment: "Details about role", Default: ""}, - {Name: "type", Type: field.TypeInt8, Comment: "Role type: 1 - System role 2 - User role 3 - Department role", Default: 2}, - {Name: "sequence", Type: field.TypeInt, Comment: "Sequence for sorting", Default: 0}, - {Name: "status", Type: field.TypeInt8, Comment: "status", Default: 1}, - } - // SysRolesTable holds the schema information for the "sys_roles" table. - SysRolesTable = &schema.Table{ - Name: "sys_roles", - Comment: "Role table", - Columns: SysRolesColumns, - PrimaryKey: []*schema.Column{SysRolesColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "role_keyword", - Unique: false, - Columns: []*schema.Column{SysRolesColumns[3]}, - }, - { - Name: "role_name", - Unique: false, - Columns: []*schema.Column{SysRolesColumns[4]}, - }, - { - Name: "role_sequence", - Unique: false, - Columns: []*schema.Column{SysRolesColumns[7]}, - }, - { - Name: "role_status", - Unique: false, - Columns: []*schema.Column{SysRolesColumns[8]}, - }, - }, - } - // SysRolePermissionsColumns holds the columns for the "sys_role_permissions" table. - SysRolePermissionsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "role_id", Type: field.TypeInt64}, - {Name: "permission_id", Type: field.TypeInt64}, - } - // SysRolePermissionsTable holds the schema information for the "sys_role_permissions" table. - SysRolePermissionsTable = &schema.Table{ - Name: "sys_role_permissions", - Comment: "Role-Permission mapping table", - Columns: SysRolePermissionsColumns, - PrimaryKey: []*schema.Column{SysRolePermissionsColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "sys_role_permissions_sys_roles_role", - Columns: []*schema.Column{SysRolePermissionsColumns[1]}, - RefColumns: []*schema.Column{SysRolesColumns[0]}, - OnDelete: schema.NoAction, - }, - { - Symbol: "sys_role_permissions_sys_permissions_permission", - Columns: []*schema.Column{SysRolePermissionsColumns[2]}, - RefColumns: []*schema.Column{SysPermissionsColumns[0]}, - OnDelete: schema.NoAction, - }, - }, - Indexes: []*schema.Index{ - { - Name: "rolepermission_role_id_permission_id", - Unique: true, - Columns: []*schema.Column{SysRolePermissionsColumns[1], SysRolePermissionsColumns[2]}, - }, - }, - } - // SysUsersColumns holds the columns for the "sys_users" table. - SysUsersColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt64, Increment: true, Comment: "ID"}, - {Name: "create_time", Type: field.TypeTime}, - {Name: "update_time", Type: field.TypeTime}, - {Name: "uuid", Type: field.TypeString, Unique: true, Size: 36, Comment: "UUID"}, - {Name: "allowed_ip", Type: field.TypeString, Comment: "Allowed IP", Default: "0.0.0.0"}, - {Name: "username", Type: field.TypeString, Unique: true, Size: 32, Comment: "login username of user"}, - {Name: "nickname", Type: field.TypeString, Size: 64, Comment: "Nickname display name of user", Default: ""}, - {Name: "avatar", Type: field.TypeString, Size: 256, Comment: "Avatar display avatar of user", Default: ""}, - {Name: "name", Type: field.TypeString, Size: 64, Comment: "Name of user", Default: ""}, - {Name: "gender", Type: field.TypeEnum, Comment: "Gender of user", Enums: []string{"male", "female", "unknown"}, Default: "unknown"}, - {Name: "password", Type: field.TypeString, Size: 256, Comment: "Encrypted password", Default: ""}, - {Name: "phone", Type: field.TypeString, Size: 32, Comment: "login phone number of user", Default: ""}, - {Name: "email", Type: field.TypeString, Size: 64, Comment: "login email of user", Default: ""}, - {Name: "department", Type: field.TypeString, Size: 64, Comment: "Department of user", Default: ""}, - {Name: "remark", Type: field.TypeString, Size: 1024, Comment: "Remark of user", Default: ""}, - {Name: "status", Type: field.TypeInt8, Comment: "status", Default: 1}, - {Name: "is_system", Type: field.TypeBool, Comment: "Whether the system is built-in", Default: false}, - {Name: "last_login_ip", Type: field.TypeString, Size: 32, Comment: "Last login IP", Default: ""}, - {Name: "last_login_time", Type: field.TypeTime, Nullable: true, Comment: "Last login time"}, - } - // SysUsersTable holds the schema information for the "sys_users" table. - SysUsersTable = &schema.Table{ - Name: "sys_users", - Comment: "User table", - Columns: SysUsersColumns, - PrimaryKey: []*schema.Column{SysUsersColumns[0]}, - Indexes: []*schema.Index{ - { - Name: "user_username", - Unique: false, - Columns: []*schema.Column{SysUsersColumns[5]}, - }, - { - Name: "user_phone", - Unique: false, - Columns: []*schema.Column{SysUsersColumns[11]}, - }, - { - Name: "user_email", - Unique: false, - Columns: []*schema.Column{SysUsersColumns[12]}, - }, - { - Name: "user_status", - Unique: false, - Columns: []*schema.Column{SysUsersColumns[15]}, - }, - }, - } - // SysUserRolesColumns holds the columns for the "sys_user_roles" table. - SysUserRolesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt, Increment: true}, - {Name: "user_id", Type: field.TypeInt64}, - {Name: "role_id", Type: field.TypeInt64}, - } - // SysUserRolesTable holds the schema information for the "sys_user_roles" table. - SysUserRolesTable = &schema.Table{ - Name: "sys_user_roles", - Comment: "User-Role mapping table", - Columns: SysUserRolesColumns, - PrimaryKey: []*schema.Column{SysUserRolesColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "sys_user_roles_sys_users_user", - Columns: []*schema.Column{SysUserRolesColumns[1]}, - RefColumns: []*schema.Column{SysUsersColumns[0]}, - OnDelete: schema.NoAction, - }, - { - Symbol: "sys_user_roles_sys_roles_role", - Columns: []*schema.Column{SysUserRolesColumns[2]}, - RefColumns: []*schema.Column{SysRolesColumns[0]}, - OnDelete: schema.NoAction, - }, - }, - Indexes: []*schema.Index{ - { - Name: "userrole_user_id_role_id", - Unique: true, - Columns: []*schema.Column{SysUserRolesColumns[1], SysUserRolesColumns[2]}, - }, - }, - } - // Tables holds all the tables in the schema. - Tables = []*schema.Table{ - SysPermissionsTable, - SysPermissionResourcesTable, - SysResourcesTable, - SysRolesTable, - SysRolePermissionsTable, - SysUsersTable, - SysUserRolesTable, - } -) - -func init() { - SysPermissionsTable.Annotation = &entsql.Annotation{ - Table: "sys_permissions", - } - SysPermissionResourcesTable.ForeignKeys[0].RefTable = SysPermissionsTable - SysPermissionResourcesTable.ForeignKeys[1].RefTable = SysResourcesTable - SysPermissionResourcesTable.Annotation = &entsql.Annotation{ - Table: "sys_permission_resources", - } - SysResourcesTable.ForeignKeys[0].RefTable = SysResourcesTable - SysResourcesTable.Annotation = &entsql.Annotation{ - Table: "sys_resources", - } - SysRolesTable.Annotation = &entsql.Annotation{ - Table: "sys_roles", - } - SysRolePermissionsTable.ForeignKeys[0].RefTable = SysRolesTable - SysRolePermissionsTable.ForeignKeys[1].RefTable = SysPermissionsTable - SysRolePermissionsTable.Annotation = &entsql.Annotation{ - Table: "sys_role_permissions", - } - SysUsersTable.Annotation = &entsql.Annotation{ - Table: "sys_users", - } - SysUserRolesTable.ForeignKeys[0].RefTable = SysUsersTable - SysUserRolesTable.ForeignKeys[1].RefTable = SysRolesTable - SysUserRolesTable.Annotation = &entsql.Annotation{ - Table: "sys_user_roles", - } -} diff --git a/internal/features/system/data/ent/mutation.go b/internal/features/system/data/ent/mutation.go deleted file mode 100644 index 779bb6d8..00000000 --- a/internal/features/system/data/ent/mutation.go +++ /dev/null @@ -1,6791 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - "sync" - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" -) - -const ( - // Operation types. - OpCreate = ent.OpCreate - OpDelete = ent.OpDelete - OpDeleteOne = ent.OpDeleteOne - OpUpdate = ent.OpUpdate - OpUpdateOne = ent.OpUpdateOne - - // Node types. - TypePermission = "Permission" - TypePermissionResource = "PermissionResource" - TypeResource = "Resource" - TypeRole = "Role" - TypeRolePermission = "RolePermission" - TypeUser = "User" - TypeUserRole = "UserRole" -) - -// PermissionMutation represents an operation that mutates the Permission nodes in the graph. -type PermissionMutation struct { - config - op Op - typ string - id *int64 - create_time *time.Time - update_time *time.Time - name *string - keyword *string - description *string - data_scope *string - data_rules *map[string]string - actions *permission.Actions - clearedFields map[string]struct{} - roles map[int64]struct{} - removedroles map[int64]struct{} - clearedroles bool - resources map[int64]struct{} - removedresources map[int64]struct{} - clearedresources bool - role_permissions map[int]struct{} - removedrole_permissions map[int]struct{} - clearedrole_permissions bool - permission_resources map[int]struct{} - removedpermission_resources map[int]struct{} - clearedpermission_resources bool - done bool - oldValue func(context.Context) (*Permission, error) - predicates []predicate.Permission -} - -var _ ent.Mutation = (*PermissionMutation)(nil) - -// permissionOption allows management of the mutation configuration using functional options. -type permissionOption func(*PermissionMutation) - -// newPermissionMutation creates new mutation for the Permission entity. -func newPermissionMutation(c config, op Op, opts ...permissionOption) *PermissionMutation { - m := &PermissionMutation{ - config: c, - op: op, - typ: TypePermission, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withPermissionID sets the ID field of the mutation. -func withPermissionID(id int64) permissionOption { - return func(m *PermissionMutation) { - var ( - err error - once sync.Once - value *Permission - ) - m.oldValue = func(ctx context.Context) (*Permission, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Permission.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withPermission sets the old Permission of the mutation. -func withPermission(node *Permission) permissionOption { - return func(m *PermissionMutation) { - m.oldValue = func(context.Context) (*Permission, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m PermissionMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m PermissionMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Permission entities. -func (m *PermissionMutation) SetID(id int64) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *PermissionMutation) ID() (id int64, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *PermissionMutation) IDs(ctx context.Context) ([]int64, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int64{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().Permission.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetCreateTime sets the "create_time" field. -func (m *PermissionMutation) SetCreateTime(t time.Time) { - m.create_time = &t -} - -// CreateTime returns the value of the "create_time" field in the mutation. -func (m *PermissionMutation) CreateTime() (r time.Time, exists bool) { - v := m.create_time - if v == nil { - return - } - return *v, true -} - -// OldCreateTime returns the old "create_time" field's value of the Permission entity. -// If the Permission object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreateTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) - } - return oldValue.CreateTime, nil -} - -// ResetCreateTime resets all changes to the "create_time" field. -func (m *PermissionMutation) ResetCreateTime() { - m.create_time = nil -} - -// SetUpdateTime sets the "update_time" field. -func (m *PermissionMutation) SetUpdateTime(t time.Time) { - m.update_time = &t -} - -// UpdateTime returns the value of the "update_time" field in the mutation. -func (m *PermissionMutation) UpdateTime() (r time.Time, exists bool) { - v := m.update_time - if v == nil { - return - } - return *v, true -} - -// OldUpdateTime returns the old "update_time" field's value of the Permission entity. -// If the Permission object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) - } - return oldValue.UpdateTime, nil -} - -// ResetUpdateTime resets all changes to the "update_time" field. -func (m *PermissionMutation) ResetUpdateTime() { - m.update_time = nil -} - -// SetName sets the "name" field. -func (m *PermissionMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *PermissionMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the Permission entity. -// If the Permission object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *PermissionMutation) ResetName() { - m.name = nil -} - -// SetKeyword sets the "keyword" field. -func (m *PermissionMutation) SetKeyword(s string) { - m.keyword = &s -} - -// Keyword returns the value of the "keyword" field in the mutation. -func (m *PermissionMutation) Keyword() (r string, exists bool) { - v := m.keyword - if v == nil { - return - } - return *v, true -} - -// OldKeyword returns the old "keyword" field's value of the Permission entity. -// If the Permission object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionMutation) OldKeyword(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKeyword is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKeyword requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldKeyword: %w", err) - } - return oldValue.Keyword, nil -} - -// ResetKeyword resets all changes to the "keyword" field. -func (m *PermissionMutation) ResetKeyword() { - m.keyword = nil -} - -// SetDescription sets the "description" field. -func (m *PermissionMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *PermissionMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true -} - -// OldDescription returns the old "description" field's value of the Permission entity. -// If the Permission object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ResetDescription resets all changes to the "description" field. -func (m *PermissionMutation) ResetDescription() { - m.description = nil -} - -// SetDataScope sets the "data_scope" field. -func (m *PermissionMutation) SetDataScope(s string) { - m.data_scope = &s -} - -// DataScope returns the value of the "data_scope" field in the mutation. -func (m *PermissionMutation) DataScope() (r string, exists bool) { - v := m.data_scope - if v == nil { - return - } - return *v, true -} - -// OldDataScope returns the old "data_scope" field's value of the Permission entity. -// If the Permission object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionMutation) OldDataScope(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDataScope is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDataScope requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDataScope: %w", err) - } - return oldValue.DataScope, nil -} - -// ResetDataScope resets all changes to the "data_scope" field. -func (m *PermissionMutation) ResetDataScope() { - m.data_scope = nil -} - -// SetDataRules sets the "data_rules" field. -func (m *PermissionMutation) SetDataRules(value map[string]string) { - m.data_rules = &value -} - -// DataRules returns the value of the "data_rules" field in the mutation. -func (m *PermissionMutation) DataRules() (r map[string]string, exists bool) { - v := m.data_rules - if v == nil { - return - } - return *v, true -} - -// OldDataRules returns the old "data_rules" field's value of the Permission entity. -// If the Permission object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionMutation) OldDataRules(ctx context.Context) (v map[string]string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDataRules is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDataRules requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDataRules: %w", err) - } - return oldValue.DataRules, nil -} - -// ClearDataRules clears the value of the "data_rules" field. -func (m *PermissionMutation) ClearDataRules() { - m.data_rules = nil - m.clearedFields[permission.FieldDataRules] = struct{}{} -} - -// DataRulesCleared returns if the "data_rules" field was cleared in this mutation. -func (m *PermissionMutation) DataRulesCleared() bool { - _, ok := m.clearedFields[permission.FieldDataRules] - return ok -} - -// ResetDataRules resets all changes to the "data_rules" field. -func (m *PermissionMutation) ResetDataRules() { - m.data_rules = nil - delete(m.clearedFields, permission.FieldDataRules) -} - -// SetActions sets the "actions" field. -func (m *PermissionMutation) SetActions(pe permission.Actions) { - m.actions = &pe -} - -// Actions returns the value of the "actions" field in the mutation. -func (m *PermissionMutation) Actions() (r permission.Actions, exists bool) { - v := m.actions - if v == nil { - return - } - return *v, true -} - -// OldActions returns the old "actions" field's value of the Permission entity. -// If the Permission object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionMutation) OldActions(ctx context.Context) (v permission.Actions, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldActions is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldActions requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldActions: %w", err) - } - return oldValue.Actions, nil -} - -// ResetActions resets all changes to the "actions" field. -func (m *PermissionMutation) ResetActions() { - m.actions = nil -} - -// AddRoleIDs adds the "roles" edge to the Role entity by ids. -func (m *PermissionMutation) AddRoleIDs(ids ...int64) { - if m.roles == nil { - m.roles = make(map[int64]struct{}) - } - for i := range ids { - m.roles[ids[i]] = struct{}{} - } -} - -// ClearRoles clears the "roles" edge to the Role entity. -func (m *PermissionMutation) ClearRoles() { - m.clearedroles = true -} - -// RolesCleared reports if the "roles" edge to the Role entity was cleared. -func (m *PermissionMutation) RolesCleared() bool { - return m.clearedroles -} - -// RemoveRoleIDs removes the "roles" edge to the Role entity by IDs. -func (m *PermissionMutation) RemoveRoleIDs(ids ...int64) { - if m.removedroles == nil { - m.removedroles = make(map[int64]struct{}) - } - for i := range ids { - delete(m.roles, ids[i]) - m.removedroles[ids[i]] = struct{}{} - } -} - -// RemovedRoles returns the removed IDs of the "roles" edge to the Role entity. -func (m *PermissionMutation) RemovedRolesIDs() (ids []int64) { - for id := range m.removedroles { - ids = append(ids, id) - } - return -} - -// RolesIDs returns the "roles" edge IDs in the mutation. -func (m *PermissionMutation) RolesIDs() (ids []int64) { - for id := range m.roles { - ids = append(ids, id) - } - return -} - -// ResetRoles resets all changes to the "roles" edge. -func (m *PermissionMutation) ResetRoles() { - m.roles = nil - m.clearedroles = false - m.removedroles = nil -} - -// AddResourceIDs adds the "resources" edge to the Resource entity by ids. -func (m *PermissionMutation) AddResourceIDs(ids ...int64) { - if m.resources == nil { - m.resources = make(map[int64]struct{}) - } - for i := range ids { - m.resources[ids[i]] = struct{}{} - } -} - -// ClearResources clears the "resources" edge to the Resource entity. -func (m *PermissionMutation) ClearResources() { - m.clearedresources = true -} - -// ResourcesCleared reports if the "resources" edge to the Resource entity was cleared. -func (m *PermissionMutation) ResourcesCleared() bool { - return m.clearedresources -} - -// RemoveResourceIDs removes the "resources" edge to the Resource entity by IDs. -func (m *PermissionMutation) RemoveResourceIDs(ids ...int64) { - if m.removedresources == nil { - m.removedresources = make(map[int64]struct{}) - } - for i := range ids { - delete(m.resources, ids[i]) - m.removedresources[ids[i]] = struct{}{} - } -} - -// RemovedResources returns the removed IDs of the "resources" edge to the Resource entity. -func (m *PermissionMutation) RemovedResourcesIDs() (ids []int64) { - for id := range m.removedresources { - ids = append(ids, id) - } - return -} - -// ResourcesIDs returns the "resources" edge IDs in the mutation. -func (m *PermissionMutation) ResourcesIDs() (ids []int64) { - for id := range m.resources { - ids = append(ids, id) - } - return -} - -// ResetResources resets all changes to the "resources" edge. -func (m *PermissionMutation) ResetResources() { - m.resources = nil - m.clearedresources = false - m.removedresources = nil -} - -// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by ids. -func (m *PermissionMutation) AddRolePermissionIDs(ids ...int) { - if m.role_permissions == nil { - m.role_permissions = make(map[int]struct{}) - } - for i := range ids { - m.role_permissions[ids[i]] = struct{}{} - } -} - -// ClearRolePermissions clears the "role_permissions" edge to the RolePermission entity. -func (m *PermissionMutation) ClearRolePermissions() { - m.clearedrole_permissions = true -} - -// RolePermissionsCleared reports if the "role_permissions" edge to the RolePermission entity was cleared. -func (m *PermissionMutation) RolePermissionsCleared() bool { - return m.clearedrole_permissions -} - -// RemoveRolePermissionIDs removes the "role_permissions" edge to the RolePermission entity by IDs. -func (m *PermissionMutation) RemoveRolePermissionIDs(ids ...int) { - if m.removedrole_permissions == nil { - m.removedrole_permissions = make(map[int]struct{}) - } - for i := range ids { - delete(m.role_permissions, ids[i]) - m.removedrole_permissions[ids[i]] = struct{}{} - } -} - -// RemovedRolePermissions returns the removed IDs of the "role_permissions" edge to the RolePermission entity. -func (m *PermissionMutation) RemovedRolePermissionsIDs() (ids []int) { - for id := range m.removedrole_permissions { - ids = append(ids, id) - } - return -} - -// RolePermissionsIDs returns the "role_permissions" edge IDs in the mutation. -func (m *PermissionMutation) RolePermissionsIDs() (ids []int) { - for id := range m.role_permissions { - ids = append(ids, id) - } - return -} - -// ResetRolePermissions resets all changes to the "role_permissions" edge. -func (m *PermissionMutation) ResetRolePermissions() { - m.role_permissions = nil - m.clearedrole_permissions = false - m.removedrole_permissions = nil -} - -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by ids. -func (m *PermissionMutation) AddPermissionResourceIDs(ids ...int) { - if m.permission_resources == nil { - m.permission_resources = make(map[int]struct{}) - } - for i := range ids { - m.permission_resources[ids[i]] = struct{}{} - } -} - -// ClearPermissionResources clears the "permission_resources" edge to the PermissionResource entity. -func (m *PermissionMutation) ClearPermissionResources() { - m.clearedpermission_resources = true -} - -// PermissionResourcesCleared reports if the "permission_resources" edge to the PermissionResource entity was cleared. -func (m *PermissionMutation) PermissionResourcesCleared() bool { - return m.clearedpermission_resources -} - -// RemovePermissionResourceIDs removes the "permission_resources" edge to the PermissionResource entity by IDs. -func (m *PermissionMutation) RemovePermissionResourceIDs(ids ...int) { - if m.removedpermission_resources == nil { - m.removedpermission_resources = make(map[int]struct{}) - } - for i := range ids { - delete(m.permission_resources, ids[i]) - m.removedpermission_resources[ids[i]] = struct{}{} - } -} - -// RemovedPermissionResources returns the removed IDs of the "permission_resources" edge to the PermissionResource entity. -func (m *PermissionMutation) RemovedPermissionResourcesIDs() (ids []int) { - for id := range m.removedpermission_resources { - ids = append(ids, id) - } - return -} - -// PermissionResourcesIDs returns the "permission_resources" edge IDs in the mutation. -func (m *PermissionMutation) PermissionResourcesIDs() (ids []int) { - for id := range m.permission_resources { - ids = append(ids, id) - } - return -} - -// ResetPermissionResources resets all changes to the "permission_resources" edge. -func (m *PermissionMutation) ResetPermissionResources() { - m.permission_resources = nil - m.clearedpermission_resources = false - m.removedpermission_resources = nil -} - -// Where appends a list predicates to the PermissionMutation builder. -func (m *PermissionMutation) Where(ps ...predicate.Permission) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the PermissionMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *PermissionMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Permission, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *PermissionMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *PermissionMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Permission). -func (m *PermissionMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *PermissionMutation) Fields() []string { - fields := make([]string, 0, 8) - if m.create_time != nil { - fields = append(fields, permission.FieldCreateTime) - } - if m.update_time != nil { - fields = append(fields, permission.FieldUpdateTime) - } - if m.name != nil { - fields = append(fields, permission.FieldName) - } - if m.keyword != nil { - fields = append(fields, permission.FieldKeyword) - } - if m.description != nil { - fields = append(fields, permission.FieldDescription) - } - if m.data_scope != nil { - fields = append(fields, permission.FieldDataScope) - } - if m.data_rules != nil { - fields = append(fields, permission.FieldDataRules) - } - if m.actions != nil { - fields = append(fields, permission.FieldActions) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *PermissionMutation) Field(name string) (ent.Value, bool) { - switch name { - case permission.FieldCreateTime: - return m.CreateTime() - case permission.FieldUpdateTime: - return m.UpdateTime() - case permission.FieldName: - return m.Name() - case permission.FieldKeyword: - return m.Keyword() - case permission.FieldDescription: - return m.Description() - case permission.FieldDataScope: - return m.DataScope() - case permission.FieldDataRules: - return m.DataRules() - case permission.FieldActions: - return m.Actions() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *PermissionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case permission.FieldCreateTime: - return m.OldCreateTime(ctx) - case permission.FieldUpdateTime: - return m.OldUpdateTime(ctx) - case permission.FieldName: - return m.OldName(ctx) - case permission.FieldKeyword: - return m.OldKeyword(ctx) - case permission.FieldDescription: - return m.OldDescription(ctx) - case permission.FieldDataScope: - return m.OldDataScope(ctx) - case permission.FieldDataRules: - return m.OldDataRules(ctx) - case permission.FieldActions: - return m.OldActions(ctx) - } - return nil, fmt.Errorf("unknown Permission field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PermissionMutation) SetField(name string, value ent.Value) error { - switch name { - case permission.FieldCreateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreateTime(v) - return nil - case permission.FieldUpdateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdateTime(v) - return nil - case permission.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case permission.FieldKeyword: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKeyword(v) - return nil - case permission.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case permission.FieldDataScope: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDataScope(v) - return nil - case permission.FieldDataRules: - v, ok := value.(map[string]string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDataRules(v) - return nil - case permission.FieldActions: - v, ok := value.(permission.Actions) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetActions(v) - return nil - } - return fmt.Errorf("unknown Permission field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *PermissionMutation) AddedFields() []string { - return nil -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *PermissionMutation) AddedField(name string) (ent.Value, bool) { - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PermissionMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown Permission numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *PermissionMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(permission.FieldDataRules) { - fields = append(fields, permission.FieldDataRules) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *PermissionMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *PermissionMutation) ClearField(name string) error { - switch name { - case permission.FieldDataRules: - m.ClearDataRules() - return nil - } - return fmt.Errorf("unknown Permission nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *PermissionMutation) ResetField(name string) error { - switch name { - case permission.FieldCreateTime: - m.ResetCreateTime() - return nil - case permission.FieldUpdateTime: - m.ResetUpdateTime() - return nil - case permission.FieldName: - m.ResetName() - return nil - case permission.FieldKeyword: - m.ResetKeyword() - return nil - case permission.FieldDescription: - m.ResetDescription() - return nil - case permission.FieldDataScope: - m.ResetDataScope() - return nil - case permission.FieldDataRules: - m.ResetDataRules() - return nil - case permission.FieldActions: - m.ResetActions() - return nil - } - return fmt.Errorf("unknown Permission field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *PermissionMutation) AddedEdges() []string { - edges := make([]string, 0, 4) - if m.roles != nil { - edges = append(edges, permission.EdgeRoles) - } - if m.resources != nil { - edges = append(edges, permission.EdgeResources) - } - if m.role_permissions != nil { - edges = append(edges, permission.EdgeRolePermissions) - } - if m.permission_resources != nil { - edges = append(edges, permission.EdgePermissionResources) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *PermissionMutation) AddedIDs(name string) []ent.Value { - switch name { - case permission.EdgeRoles: - ids := make([]ent.Value, 0, len(m.roles)) - for id := range m.roles { - ids = append(ids, id) - } - return ids - case permission.EdgeResources: - ids := make([]ent.Value, 0, len(m.resources)) - for id := range m.resources { - ids = append(ids, id) - } - return ids - case permission.EdgeRolePermissions: - ids := make([]ent.Value, 0, len(m.role_permissions)) - for id := range m.role_permissions { - ids = append(ids, id) - } - return ids - case permission.EdgePermissionResources: - ids := make([]ent.Value, 0, len(m.permission_resources)) - for id := range m.permission_resources { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *PermissionMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - if m.removedroles != nil { - edges = append(edges, permission.EdgeRoles) - } - if m.removedresources != nil { - edges = append(edges, permission.EdgeResources) - } - if m.removedrole_permissions != nil { - edges = append(edges, permission.EdgeRolePermissions) - } - if m.removedpermission_resources != nil { - edges = append(edges, permission.EdgePermissionResources) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *PermissionMutation) RemovedIDs(name string) []ent.Value { - switch name { - case permission.EdgeRoles: - ids := make([]ent.Value, 0, len(m.removedroles)) - for id := range m.removedroles { - ids = append(ids, id) - } - return ids - case permission.EdgeResources: - ids := make([]ent.Value, 0, len(m.removedresources)) - for id := range m.removedresources { - ids = append(ids, id) - } - return ids - case permission.EdgeRolePermissions: - ids := make([]ent.Value, 0, len(m.removedrole_permissions)) - for id := range m.removedrole_permissions { - ids = append(ids, id) - } - return ids - case permission.EdgePermissionResources: - ids := make([]ent.Value, 0, len(m.removedpermission_resources)) - for id := range m.removedpermission_resources { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *PermissionMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) - if m.clearedroles { - edges = append(edges, permission.EdgeRoles) - } - if m.clearedresources { - edges = append(edges, permission.EdgeResources) - } - if m.clearedrole_permissions { - edges = append(edges, permission.EdgeRolePermissions) - } - if m.clearedpermission_resources { - edges = append(edges, permission.EdgePermissionResources) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *PermissionMutation) EdgeCleared(name string) bool { - switch name { - case permission.EdgeRoles: - return m.clearedroles - case permission.EdgeResources: - return m.clearedresources - case permission.EdgeRolePermissions: - return m.clearedrole_permissions - case permission.EdgePermissionResources: - return m.clearedpermission_resources - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *PermissionMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown Permission unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *PermissionMutation) ResetEdge(name string) error { - switch name { - case permission.EdgeRoles: - m.ResetRoles() - return nil - case permission.EdgeResources: - m.ResetResources() - return nil - case permission.EdgeRolePermissions: - m.ResetRolePermissions() - return nil - case permission.EdgePermissionResources: - m.ResetPermissionResources() - return nil - } - return fmt.Errorf("unknown Permission edge %s", name) -} - -// PermissionResourceMutation represents an operation that mutates the PermissionResource nodes in the graph. -type PermissionResourceMutation struct { - config - op Op - typ string - id *int - clearedFields map[string]struct{} - permission *int64 - clearedpermission bool - resource *int64 - clearedresource bool - done bool - oldValue func(context.Context) (*PermissionResource, error) - predicates []predicate.PermissionResource -} - -var _ ent.Mutation = (*PermissionResourceMutation)(nil) - -// permissionresourceOption allows management of the mutation configuration using functional options. -type permissionresourceOption func(*PermissionResourceMutation) - -// newPermissionResourceMutation creates new mutation for the PermissionResource entity. -func newPermissionResourceMutation(c config, op Op, opts ...permissionresourceOption) *PermissionResourceMutation { - m := &PermissionResourceMutation{ - config: c, - op: op, - typ: TypePermissionResource, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withPermissionResourceID sets the ID field of the mutation. -func withPermissionResourceID(id int) permissionresourceOption { - return func(m *PermissionResourceMutation) { - var ( - err error - once sync.Once - value *PermissionResource - ) - m.oldValue = func(ctx context.Context) (*PermissionResource, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().PermissionResource.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withPermissionResource sets the old PermissionResource of the mutation. -func withPermissionResource(node *PermissionResource) permissionresourceOption { - return func(m *PermissionResourceMutation) { - m.oldValue = func(context.Context) (*PermissionResource, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m PermissionResourceMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m PermissionResourceMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *PermissionResourceMutation) ID() (id int, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *PermissionResourceMutation) IDs(ctx context.Context) ([]int, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().PermissionResource.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetPermissionID sets the "permission_id" field. -func (m *PermissionResourceMutation) SetPermissionID(i int64) { - m.permission = &i -} - -// PermissionID returns the value of the "permission_id" field in the mutation. -func (m *PermissionResourceMutation) PermissionID() (r int64, exists bool) { - v := m.permission - if v == nil { - return - } - return *v, true -} - -// OldPermissionID returns the old "permission_id" field's value of the PermissionResource entity. -// If the PermissionResource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionResourceMutation) OldPermissionID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPermissionID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPermissionID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPermissionID: %w", err) - } - return oldValue.PermissionID, nil -} - -// ResetPermissionID resets all changes to the "permission_id" field. -func (m *PermissionResourceMutation) ResetPermissionID() { - m.permission = nil -} - -// SetResourceID sets the "resource_id" field. -func (m *PermissionResourceMutation) SetResourceID(i int64) { - m.resource = &i -} - -// ResourceID returns the value of the "resource_id" field in the mutation. -func (m *PermissionResourceMutation) ResourceID() (r int64, exists bool) { - v := m.resource - if v == nil { - return - } - return *v, true -} - -// OldResourceID returns the old "resource_id" field's value of the PermissionResource entity. -// If the PermissionResource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionResourceMutation) OldResourceID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldResourceID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldResourceID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldResourceID: %w", err) - } - return oldValue.ResourceID, nil -} - -// ResetResourceID resets all changes to the "resource_id" field. -func (m *PermissionResourceMutation) ResetResourceID() { - m.resource = nil -} - -// ClearPermission clears the "permission" edge to the Permission entity. -func (m *PermissionResourceMutation) ClearPermission() { - m.clearedpermission = true - m.clearedFields[permissionresource.FieldPermissionID] = struct{}{} -} - -// PermissionCleared reports if the "permission" edge to the Permission entity was cleared. -func (m *PermissionResourceMutation) PermissionCleared() bool { - return m.clearedpermission -} - -// PermissionIDs returns the "permission" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// PermissionID instead. It exists only for internal usage by the builders. -func (m *PermissionResourceMutation) PermissionIDs() (ids []int64) { - if id := m.permission; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetPermission resets all changes to the "permission" edge. -func (m *PermissionResourceMutation) ResetPermission() { - m.permission = nil - m.clearedpermission = false -} - -// ClearResource clears the "resource" edge to the Resource entity. -func (m *PermissionResourceMutation) ClearResource() { - m.clearedresource = true - m.clearedFields[permissionresource.FieldResourceID] = struct{}{} -} - -// ResourceCleared reports if the "resource" edge to the Resource entity was cleared. -func (m *PermissionResourceMutation) ResourceCleared() bool { - return m.clearedresource -} - -// ResourceIDs returns the "resource" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ResourceID instead. It exists only for internal usage by the builders. -func (m *PermissionResourceMutation) ResourceIDs() (ids []int64) { - if id := m.resource; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetResource resets all changes to the "resource" edge. -func (m *PermissionResourceMutation) ResetResource() { - m.resource = nil - m.clearedresource = false -} - -// Where appends a list predicates to the PermissionResourceMutation builder. -func (m *PermissionResourceMutation) Where(ps ...predicate.PermissionResource) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the PermissionResourceMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *PermissionResourceMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.PermissionResource, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *PermissionResourceMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *PermissionResourceMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (PermissionResource). -func (m *PermissionResourceMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *PermissionResourceMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.permission != nil { - fields = append(fields, permissionresource.FieldPermissionID) - } - if m.resource != nil { - fields = append(fields, permissionresource.FieldResourceID) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *PermissionResourceMutation) Field(name string) (ent.Value, bool) { - switch name { - case permissionresource.FieldPermissionID: - return m.PermissionID() - case permissionresource.FieldResourceID: - return m.ResourceID() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *PermissionResourceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case permissionresource.FieldPermissionID: - return m.OldPermissionID(ctx) - case permissionresource.FieldResourceID: - return m.OldResourceID(ctx) - } - return nil, fmt.Errorf("unknown PermissionResource field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PermissionResourceMutation) SetField(name string, value ent.Value) error { - switch name { - case permissionresource.FieldPermissionID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPermissionID(v) - return nil - case permissionresource.FieldResourceID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetResourceID(v) - return nil - } - return fmt.Errorf("unknown PermissionResource field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *PermissionResourceMutation) AddedFields() []string { - var fields []string - return fields -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *PermissionResourceMutation) AddedField(name string) (ent.Value, bool) { - switch name { - } - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *PermissionResourceMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown PermissionResource numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *PermissionResourceMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *PermissionResourceMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *PermissionResourceMutation) ClearField(name string) error { - return fmt.Errorf("unknown PermissionResource nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *PermissionResourceMutation) ResetField(name string) error { - switch name { - case permissionresource.FieldPermissionID: - m.ResetPermissionID() - return nil - case permissionresource.FieldResourceID: - m.ResetResourceID() - return nil - } - return fmt.Errorf("unknown PermissionResource field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *PermissionResourceMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.permission != nil { - edges = append(edges, permissionresource.EdgePermission) - } - if m.resource != nil { - edges = append(edges, permissionresource.EdgeResource) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *PermissionResourceMutation) AddedIDs(name string) []ent.Value { - switch name { - case permissionresource.EdgePermission: - if id := m.permission; id != nil { - return []ent.Value{*id} - } - case permissionresource.EdgeResource: - if id := m.resource; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *PermissionResourceMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *PermissionResourceMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *PermissionResourceMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedpermission { - edges = append(edges, permissionresource.EdgePermission) - } - if m.clearedresource { - edges = append(edges, permissionresource.EdgeResource) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *PermissionResourceMutation) EdgeCleared(name string) bool { - switch name { - case permissionresource.EdgePermission: - return m.clearedpermission - case permissionresource.EdgeResource: - return m.clearedresource - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *PermissionResourceMutation) ClearEdge(name string) error { - switch name { - case permissionresource.EdgePermission: - m.ClearPermission() - return nil - case permissionresource.EdgeResource: - m.ClearResource() - return nil - } - return fmt.Errorf("unknown PermissionResource unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *PermissionResourceMutation) ResetEdge(name string) error { - switch name { - case permissionresource.EdgePermission: - m.ResetPermission() - return nil - case permissionresource.EdgeResource: - m.ResetResource() - return nil - } - return fmt.Errorf("unknown PermissionResource edge %s", name) -} - -// ResourceMutation represents an operation that mutates the Resource nodes in the graph. -type ResourceMutation struct { - config - op Op - typ string - id *int64 - create_time *time.Time - update_time *time.Time - name *string - keyword *string - _type *string - status *int8 - addstatus *int8 - _path *string - component *string - icon *string - sequence *int - addsequence *int - visible *bool - level *int8 - addlevel *int8 - tree_path *string - properties *map[string]string - description *string - clearedFields map[string]struct{} - parent *int64 - clearedparent bool - children map[int64]struct{} - removedchildren map[int64]struct{} - clearedchildren bool - permissions map[int64]struct{} - removedpermissions map[int64]struct{} - clearedpermissions bool - permission_resources map[int]struct{} - removedpermission_resources map[int]struct{} - clearedpermission_resources bool - done bool - oldValue func(context.Context) (*Resource, error) - predicates []predicate.Resource -} - -var _ ent.Mutation = (*ResourceMutation)(nil) - -// resourceOption allows management of the mutation configuration using functional options. -type resourceOption func(*ResourceMutation) - -// newResourceMutation creates new mutation for the Resource entity. -func newResourceMutation(c config, op Op, opts ...resourceOption) *ResourceMutation { - m := &ResourceMutation{ - config: c, - op: op, - typ: TypeResource, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withResourceID sets the ID field of the mutation. -func withResourceID(id int64) resourceOption { - return func(m *ResourceMutation) { - var ( - err error - once sync.Once - value *Resource - ) - m.oldValue = func(ctx context.Context) (*Resource, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Resource.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withResource sets the old Resource of the mutation. -func withResource(node *Resource) resourceOption { - return func(m *ResourceMutation) { - m.oldValue = func(context.Context) (*Resource, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m ResourceMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m ResourceMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Resource entities. -func (m *ResourceMutation) SetID(id int64) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *ResourceMutation) ID() (id int64, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *ResourceMutation) IDs(ctx context.Context) ([]int64, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int64{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().Resource.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetCreateTime sets the "create_time" field. -func (m *ResourceMutation) SetCreateTime(t time.Time) { - m.create_time = &t -} - -// CreateTime returns the value of the "create_time" field in the mutation. -func (m *ResourceMutation) CreateTime() (r time.Time, exists bool) { - v := m.create_time - if v == nil { - return - } - return *v, true -} - -// OldCreateTime returns the old "create_time" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreateTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) - } - return oldValue.CreateTime, nil -} - -// ResetCreateTime resets all changes to the "create_time" field. -func (m *ResourceMutation) ResetCreateTime() { - m.create_time = nil -} - -// SetUpdateTime sets the "update_time" field. -func (m *ResourceMutation) SetUpdateTime(t time.Time) { - m.update_time = &t -} - -// UpdateTime returns the value of the "update_time" field in the mutation. -func (m *ResourceMutation) UpdateTime() (r time.Time, exists bool) { - v := m.update_time - if v == nil { - return - } - return *v, true -} - -// OldUpdateTime returns the old "update_time" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) - } - return oldValue.UpdateTime, nil -} - -// ResetUpdateTime resets all changes to the "update_time" field. -func (m *ResourceMutation) ResetUpdateTime() { - m.update_time = nil -} - -// SetName sets the "name" field. -func (m *ResourceMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *ResourceMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *ResourceMutation) ResetName() { - m.name = nil -} - -// SetKeyword sets the "keyword" field. -func (m *ResourceMutation) SetKeyword(s string) { - m.keyword = &s -} - -// Keyword returns the value of the "keyword" field in the mutation. -func (m *ResourceMutation) Keyword() (r string, exists bool) { - v := m.keyword - if v == nil { - return - } - return *v, true -} - -// OldKeyword returns the old "keyword" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldKeyword(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKeyword is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKeyword requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldKeyword: %w", err) - } - return oldValue.Keyword, nil -} - -// ResetKeyword resets all changes to the "keyword" field. -func (m *ResourceMutation) ResetKeyword() { - m.keyword = nil -} - -// SetType sets the "type" field. -func (m *ResourceMutation) SetType(s string) { - m._type = &s -} - -// GetType returns the value of the "type" field in the mutation. -func (m *ResourceMutation) GetType() (r string, exists bool) { - v := m._type - if v == nil { - return - } - return *v, true -} - -// OldType returns the old "type" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldType(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) - } - return oldValue.Type, nil -} - -// ResetType resets all changes to the "type" field. -func (m *ResourceMutation) ResetType() { - m._type = nil -} - -// SetStatus sets the "status" field. -func (m *ResourceMutation) SetStatus(i int8) { - m.status = &i - m.addstatus = nil -} - -// Status returns the value of the "status" field in the mutation. -func (m *ResourceMutation) Status() (r int8, exists bool) { - v := m.status - if v == nil { - return - } - return *v, true -} - -// OldStatus returns the old "status" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldStatus(ctx context.Context) (v int8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) - } - return oldValue.Status, nil -} - -// AddStatus adds i to the "status" field. -func (m *ResourceMutation) AddStatus(i int8) { - if m.addstatus != nil { - *m.addstatus += i - } else { - m.addstatus = &i - } -} - -// AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *ResourceMutation) AddedStatus() (r int8, exists bool) { - v := m.addstatus - if v == nil { - return - } - return *v, true -} - -// ResetStatus resets all changes to the "status" field. -func (m *ResourceMutation) ResetStatus() { - m.status = nil - m.addstatus = nil -} - -// SetPath sets the "path" field. -func (m *ResourceMutation) SetPath(s string) { - m._path = &s -} - -// Path returns the value of the "path" field in the mutation. -func (m *ResourceMutation) Path() (r string, exists bool) { - v := m._path - if v == nil { - return - } - return *v, true -} - -// OldPath returns the old "path" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldPath(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPath is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPath requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPath: %w", err) - } - return oldValue.Path, nil -} - -// ResetPath resets all changes to the "path" field. -func (m *ResourceMutation) ResetPath() { - m._path = nil -} - -// SetComponent sets the "component" field. -func (m *ResourceMutation) SetComponent(s string) { - m.component = &s -} - -// Component returns the value of the "component" field in the mutation. -func (m *ResourceMutation) Component() (r string, exists bool) { - v := m.component - if v == nil { - return - } - return *v, true -} - -// OldComponent returns the old "component" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldComponent(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldComponent is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldComponent requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldComponent: %w", err) - } - return oldValue.Component, nil -} - -// ResetComponent resets all changes to the "component" field. -func (m *ResourceMutation) ResetComponent() { - m.component = nil -} - -// SetIcon sets the "icon" field. -func (m *ResourceMutation) SetIcon(s string) { - m.icon = &s -} - -// Icon returns the value of the "icon" field in the mutation. -func (m *ResourceMutation) Icon() (r string, exists bool) { - v := m.icon - if v == nil { - return - } - return *v, true -} - -// OldIcon returns the old "icon" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldIcon(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIcon is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIcon requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIcon: %w", err) - } - return oldValue.Icon, nil -} - -// ResetIcon resets all changes to the "icon" field. -func (m *ResourceMutation) ResetIcon() { - m.icon = nil -} - -// SetSequence sets the "sequence" field. -func (m *ResourceMutation) SetSequence(i int) { - m.sequence = &i - m.addsequence = nil -} - -// Sequence returns the value of the "sequence" field in the mutation. -func (m *ResourceMutation) Sequence() (r int, exists bool) { - v := m.sequence - if v == nil { - return - } - return *v, true -} - -// OldSequence returns the old "sequence" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldSequence(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSequence is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSequence requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSequence: %w", err) - } - return oldValue.Sequence, nil -} - -// AddSequence adds i to the "sequence" field. -func (m *ResourceMutation) AddSequence(i int) { - if m.addsequence != nil { - *m.addsequence += i - } else { - m.addsequence = &i - } -} - -// AddedSequence returns the value that was added to the "sequence" field in this mutation. -func (m *ResourceMutation) AddedSequence() (r int, exists bool) { - v := m.addsequence - if v == nil { - return - } - return *v, true -} - -// ResetSequence resets all changes to the "sequence" field. -func (m *ResourceMutation) ResetSequence() { - m.sequence = nil - m.addsequence = nil -} - -// SetVisible sets the "visible" field. -func (m *ResourceMutation) SetVisible(b bool) { - m.visible = &b -} - -// Visible returns the value of the "visible" field in the mutation. -func (m *ResourceMutation) Visible() (r bool, exists bool) { - v := m.visible - if v == nil { - return - } - return *v, true -} - -// OldVisible returns the old "visible" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldVisible(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVisible is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVisible requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVisible: %w", err) - } - return oldValue.Visible, nil -} - -// ResetVisible resets all changes to the "visible" field. -func (m *ResourceMutation) ResetVisible() { - m.visible = nil -} - -// SetLevel sets the "level" field. -func (m *ResourceMutation) SetLevel(i int8) { - m.level = &i - m.addlevel = nil -} - -// Level returns the value of the "level" field in the mutation. -func (m *ResourceMutation) Level() (r int8, exists bool) { - v := m.level - if v == nil { - return - } - return *v, true -} - -// OldLevel returns the old "level" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldLevel(ctx context.Context) (v int8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLevel is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLevel requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLevel: %w", err) - } - return oldValue.Level, nil -} - -// AddLevel adds i to the "level" field. -func (m *ResourceMutation) AddLevel(i int8) { - if m.addlevel != nil { - *m.addlevel += i - } else { - m.addlevel = &i - } -} - -// AddedLevel returns the value that was added to the "level" field in this mutation. -func (m *ResourceMutation) AddedLevel() (r int8, exists bool) { - v := m.addlevel - if v == nil { - return - } - return *v, true -} - -// ResetLevel resets all changes to the "level" field. -func (m *ResourceMutation) ResetLevel() { - m.level = nil - m.addlevel = nil -} - -// SetTreePath sets the "tree_path" field. -func (m *ResourceMutation) SetTreePath(s string) { - m.tree_path = &s -} - -// TreePath returns the value of the "tree_path" field in the mutation. -func (m *ResourceMutation) TreePath() (r string, exists bool) { - v := m.tree_path - if v == nil { - return - } - return *v, true -} - -// OldTreePath returns the old "tree_path" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldTreePath(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTreePath is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTreePath requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTreePath: %w", err) - } - return oldValue.TreePath, nil -} - -// ResetTreePath resets all changes to the "tree_path" field. -func (m *ResourceMutation) ResetTreePath() { - m.tree_path = nil -} - -// SetProperties sets the "properties" field. -func (m *ResourceMutation) SetProperties(value map[string]string) { - m.properties = &value -} - -// Properties returns the value of the "properties" field in the mutation. -func (m *ResourceMutation) Properties() (r map[string]string, exists bool) { - v := m.properties - if v == nil { - return - } - return *v, true -} - -// OldProperties returns the old "properties" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldProperties(ctx context.Context) (v map[string]string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProperties is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProperties requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldProperties: %w", err) - } - return oldValue.Properties, nil -} - -// ClearProperties clears the value of the "properties" field. -func (m *ResourceMutation) ClearProperties() { - m.properties = nil - m.clearedFields[resource.FieldProperties] = struct{}{} -} - -// PropertiesCleared returns if the "properties" field was cleared in this mutation. -func (m *ResourceMutation) PropertiesCleared() bool { - _, ok := m.clearedFields[resource.FieldProperties] - return ok -} - -// ResetProperties resets all changes to the "properties" field. -func (m *ResourceMutation) ResetProperties() { - m.properties = nil - delete(m.clearedFields, resource.FieldProperties) -} - -// SetDescription sets the "description" field. -func (m *ResourceMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *ResourceMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true -} - -// OldDescription returns the old "description" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ResetDescription resets all changes to the "description" field. -func (m *ResourceMutation) ResetDescription() { - m.description = nil -} - -// SetParentID sets the "parent_id" field. -func (m *ResourceMutation) SetParentID(i int64) { - m.parent = &i -} - -// ParentID returns the value of the "parent_id" field in the mutation. -func (m *ResourceMutation) ParentID() (r int64, exists bool) { - v := m.parent - if v == nil { - return - } - return *v, true -} - -// OldParentID returns the old "parent_id" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldParentID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldParentID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldParentID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldParentID: %w", err) - } - return oldValue.ParentID, nil -} - -// ClearParentID clears the value of the "parent_id" field. -func (m *ResourceMutation) ClearParentID() { - m.parent = nil - m.clearedFields[resource.FieldParentID] = struct{}{} -} - -// ParentIDCleared returns if the "parent_id" field was cleared in this mutation. -func (m *ResourceMutation) ParentIDCleared() bool { - _, ok := m.clearedFields[resource.FieldParentID] - return ok -} - -// ResetParentID resets all changes to the "parent_id" field. -func (m *ResourceMutation) ResetParentID() { - m.parent = nil - delete(m.clearedFields, resource.FieldParentID) -} - -// ClearParent clears the "parent" edge to the Resource entity. -func (m *ResourceMutation) ClearParent() { - m.clearedparent = true - m.clearedFields[resource.FieldParentID] = struct{}{} -} - -// ParentCleared reports if the "parent" edge to the Resource entity was cleared. -func (m *ResourceMutation) ParentCleared() bool { - return m.ParentIDCleared() || m.clearedparent -} - -// ParentIDs returns the "parent" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ParentID instead. It exists only for internal usage by the builders. -func (m *ResourceMutation) ParentIDs() (ids []int64) { - if id := m.parent; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetParent resets all changes to the "parent" edge. -func (m *ResourceMutation) ResetParent() { - m.parent = nil - m.clearedparent = false -} - -// AddChildIDs adds the "children" edge to the Resource entity by ids. -func (m *ResourceMutation) AddChildIDs(ids ...int64) { - if m.children == nil { - m.children = make(map[int64]struct{}) - } - for i := range ids { - m.children[ids[i]] = struct{}{} - } -} - -// ClearChildren clears the "children" edge to the Resource entity. -func (m *ResourceMutation) ClearChildren() { - m.clearedchildren = true -} - -// ChildrenCleared reports if the "children" edge to the Resource entity was cleared. -func (m *ResourceMutation) ChildrenCleared() bool { - return m.clearedchildren -} - -// RemoveChildIDs removes the "children" edge to the Resource entity by IDs. -func (m *ResourceMutation) RemoveChildIDs(ids ...int64) { - if m.removedchildren == nil { - m.removedchildren = make(map[int64]struct{}) - } - for i := range ids { - delete(m.children, ids[i]) - m.removedchildren[ids[i]] = struct{}{} - } -} - -// RemovedChildren returns the removed IDs of the "children" edge to the Resource entity. -func (m *ResourceMutation) RemovedChildrenIDs() (ids []int64) { - for id := range m.removedchildren { - ids = append(ids, id) - } - return -} - -// ChildrenIDs returns the "children" edge IDs in the mutation. -func (m *ResourceMutation) ChildrenIDs() (ids []int64) { - for id := range m.children { - ids = append(ids, id) - } - return -} - -// ResetChildren resets all changes to the "children" edge. -func (m *ResourceMutation) ResetChildren() { - m.children = nil - m.clearedchildren = false - m.removedchildren = nil -} - -// AddPermissionIDs adds the "permissions" edge to the Permission entity by ids. -func (m *ResourceMutation) AddPermissionIDs(ids ...int64) { - if m.permissions == nil { - m.permissions = make(map[int64]struct{}) - } - for i := range ids { - m.permissions[ids[i]] = struct{}{} - } -} - -// ClearPermissions clears the "permissions" edge to the Permission entity. -func (m *ResourceMutation) ClearPermissions() { - m.clearedpermissions = true -} - -// PermissionsCleared reports if the "permissions" edge to the Permission entity was cleared. -func (m *ResourceMutation) PermissionsCleared() bool { - return m.clearedpermissions -} - -// RemovePermissionIDs removes the "permissions" edge to the Permission entity by IDs. -func (m *ResourceMutation) RemovePermissionIDs(ids ...int64) { - if m.removedpermissions == nil { - m.removedpermissions = make(map[int64]struct{}) - } - for i := range ids { - delete(m.permissions, ids[i]) - m.removedpermissions[ids[i]] = struct{}{} - } -} - -// RemovedPermissions returns the removed IDs of the "permissions" edge to the Permission entity. -func (m *ResourceMutation) RemovedPermissionsIDs() (ids []int64) { - for id := range m.removedpermissions { - ids = append(ids, id) - } - return -} - -// PermissionsIDs returns the "permissions" edge IDs in the mutation. -func (m *ResourceMutation) PermissionsIDs() (ids []int64) { - for id := range m.permissions { - ids = append(ids, id) - } - return -} - -// ResetPermissions resets all changes to the "permissions" edge. -func (m *ResourceMutation) ResetPermissions() { - m.permissions = nil - m.clearedpermissions = false - m.removedpermissions = nil -} - -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by ids. -func (m *ResourceMutation) AddPermissionResourceIDs(ids ...int) { - if m.permission_resources == nil { - m.permission_resources = make(map[int]struct{}) - } - for i := range ids { - m.permission_resources[ids[i]] = struct{}{} - } -} - -// ClearPermissionResources clears the "permission_resources" edge to the PermissionResource entity. -func (m *ResourceMutation) ClearPermissionResources() { - m.clearedpermission_resources = true -} - -// PermissionResourcesCleared reports if the "permission_resources" edge to the PermissionResource entity was cleared. -func (m *ResourceMutation) PermissionResourcesCleared() bool { - return m.clearedpermission_resources -} - -// RemovePermissionResourceIDs removes the "permission_resources" edge to the PermissionResource entity by IDs. -func (m *ResourceMutation) RemovePermissionResourceIDs(ids ...int) { - if m.removedpermission_resources == nil { - m.removedpermission_resources = make(map[int]struct{}) - } - for i := range ids { - delete(m.permission_resources, ids[i]) - m.removedpermission_resources[ids[i]] = struct{}{} - } -} - -// RemovedPermissionResources returns the removed IDs of the "permission_resources" edge to the PermissionResource entity. -func (m *ResourceMutation) RemovedPermissionResourcesIDs() (ids []int) { - for id := range m.removedpermission_resources { - ids = append(ids, id) - } - return -} - -// PermissionResourcesIDs returns the "permission_resources" edge IDs in the mutation. -func (m *ResourceMutation) PermissionResourcesIDs() (ids []int) { - for id := range m.permission_resources { - ids = append(ids, id) - } - return -} - -// ResetPermissionResources resets all changes to the "permission_resources" edge. -func (m *ResourceMutation) ResetPermissionResources() { - m.permission_resources = nil - m.clearedpermission_resources = false - m.removedpermission_resources = nil -} - -// Where appends a list predicates to the ResourceMutation builder. -func (m *ResourceMutation) Where(ps ...predicate.Resource) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the ResourceMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ResourceMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Resource, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *ResourceMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *ResourceMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Resource). -func (m *ResourceMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *ResourceMutation) Fields() []string { - fields := make([]string, 0, 16) - if m.create_time != nil { - fields = append(fields, resource.FieldCreateTime) - } - if m.update_time != nil { - fields = append(fields, resource.FieldUpdateTime) - } - if m.name != nil { - fields = append(fields, resource.FieldName) - } - if m.keyword != nil { - fields = append(fields, resource.FieldKeyword) - } - if m._type != nil { - fields = append(fields, resource.FieldType) - } - if m.status != nil { - fields = append(fields, resource.FieldStatus) - } - if m._path != nil { - fields = append(fields, resource.FieldPath) - } - if m.component != nil { - fields = append(fields, resource.FieldComponent) - } - if m.icon != nil { - fields = append(fields, resource.FieldIcon) - } - if m.sequence != nil { - fields = append(fields, resource.FieldSequence) - } - if m.visible != nil { - fields = append(fields, resource.FieldVisible) - } - if m.level != nil { - fields = append(fields, resource.FieldLevel) - } - if m.tree_path != nil { - fields = append(fields, resource.FieldTreePath) - } - if m.properties != nil { - fields = append(fields, resource.FieldProperties) - } - if m.description != nil { - fields = append(fields, resource.FieldDescription) - } - if m.parent != nil { - fields = append(fields, resource.FieldParentID) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *ResourceMutation) Field(name string) (ent.Value, bool) { - switch name { - case resource.FieldCreateTime: - return m.CreateTime() - case resource.FieldUpdateTime: - return m.UpdateTime() - case resource.FieldName: - return m.Name() - case resource.FieldKeyword: - return m.Keyword() - case resource.FieldType: - return m.GetType() - case resource.FieldStatus: - return m.Status() - case resource.FieldPath: - return m.Path() - case resource.FieldComponent: - return m.Component() - case resource.FieldIcon: - return m.Icon() - case resource.FieldSequence: - return m.Sequence() - case resource.FieldVisible: - return m.Visible() - case resource.FieldLevel: - return m.Level() - case resource.FieldTreePath: - return m.TreePath() - case resource.FieldProperties: - return m.Properties() - case resource.FieldDescription: - return m.Description() - case resource.FieldParentID: - return m.ParentID() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *ResourceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case resource.FieldCreateTime: - return m.OldCreateTime(ctx) - case resource.FieldUpdateTime: - return m.OldUpdateTime(ctx) - case resource.FieldName: - return m.OldName(ctx) - case resource.FieldKeyword: - return m.OldKeyword(ctx) - case resource.FieldType: - return m.OldType(ctx) - case resource.FieldStatus: - return m.OldStatus(ctx) - case resource.FieldPath: - return m.OldPath(ctx) - case resource.FieldComponent: - return m.OldComponent(ctx) - case resource.FieldIcon: - return m.OldIcon(ctx) - case resource.FieldSequence: - return m.OldSequence(ctx) - case resource.FieldVisible: - return m.OldVisible(ctx) - case resource.FieldLevel: - return m.OldLevel(ctx) - case resource.FieldTreePath: - return m.OldTreePath(ctx) - case resource.FieldProperties: - return m.OldProperties(ctx) - case resource.FieldDescription: - return m.OldDescription(ctx) - case resource.FieldParentID: - return m.OldParentID(ctx) - } - return nil, fmt.Errorf("unknown Resource field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *ResourceMutation) SetField(name string, value ent.Value) error { - switch name { - case resource.FieldCreateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreateTime(v) - return nil - case resource.FieldUpdateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdateTime(v) - return nil - case resource.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case resource.FieldKeyword: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKeyword(v) - return nil - case resource.FieldType: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case resource.FieldStatus: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetStatus(v) - return nil - case resource.FieldPath: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPath(v) - return nil - case resource.FieldComponent: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetComponent(v) - return nil - case resource.FieldIcon: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIcon(v) - return nil - case resource.FieldSequence: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSequence(v) - return nil - case resource.FieldVisible: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVisible(v) - return nil - case resource.FieldLevel: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLevel(v) - return nil - case resource.FieldTreePath: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTreePath(v) - return nil - case resource.FieldProperties: - v, ok := value.(map[string]string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetProperties(v) - return nil - case resource.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case resource.FieldParentID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetParentID(v) - return nil - } - return fmt.Errorf("unknown Resource field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *ResourceMutation) AddedFields() []string { - var fields []string - if m.addstatus != nil { - fields = append(fields, resource.FieldStatus) - } - if m.addsequence != nil { - fields = append(fields, resource.FieldSequence) - } - if m.addlevel != nil { - fields = append(fields, resource.FieldLevel) - } - return fields -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *ResourceMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case resource.FieldStatus: - return m.AddedStatus() - case resource.FieldSequence: - return m.AddedSequence() - case resource.FieldLevel: - return m.AddedLevel() - } - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *ResourceMutation) AddField(name string, value ent.Value) error { - switch name { - case resource.FieldStatus: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddStatus(v) - return nil - case resource.FieldSequence: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSequence(v) - return nil - case resource.FieldLevel: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddLevel(v) - return nil - } - return fmt.Errorf("unknown Resource numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *ResourceMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(resource.FieldProperties) { - fields = append(fields, resource.FieldProperties) - } - if m.FieldCleared(resource.FieldParentID) { - fields = append(fields, resource.FieldParentID) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *ResourceMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *ResourceMutation) ClearField(name string) error { - switch name { - case resource.FieldProperties: - m.ClearProperties() - return nil - case resource.FieldParentID: - m.ClearParentID() - return nil - } - return fmt.Errorf("unknown Resource nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *ResourceMutation) ResetField(name string) error { - switch name { - case resource.FieldCreateTime: - m.ResetCreateTime() - return nil - case resource.FieldUpdateTime: - m.ResetUpdateTime() - return nil - case resource.FieldName: - m.ResetName() - return nil - case resource.FieldKeyword: - m.ResetKeyword() - return nil - case resource.FieldType: - m.ResetType() - return nil - case resource.FieldStatus: - m.ResetStatus() - return nil - case resource.FieldPath: - m.ResetPath() - return nil - case resource.FieldComponent: - m.ResetComponent() - return nil - case resource.FieldIcon: - m.ResetIcon() - return nil - case resource.FieldSequence: - m.ResetSequence() - return nil - case resource.FieldVisible: - m.ResetVisible() - return nil - case resource.FieldLevel: - m.ResetLevel() - return nil - case resource.FieldTreePath: - m.ResetTreePath() - return nil - case resource.FieldProperties: - m.ResetProperties() - return nil - case resource.FieldDescription: - m.ResetDescription() - return nil - case resource.FieldParentID: - m.ResetParentID() - return nil - } - return fmt.Errorf("unknown Resource field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *ResourceMutation) AddedEdges() []string { - edges := make([]string, 0, 4) - if m.parent != nil { - edges = append(edges, resource.EdgeParent) - } - if m.children != nil { - edges = append(edges, resource.EdgeChildren) - } - if m.permissions != nil { - edges = append(edges, resource.EdgePermissions) - } - if m.permission_resources != nil { - edges = append(edges, resource.EdgePermissionResources) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *ResourceMutation) AddedIDs(name string) []ent.Value { - switch name { - case resource.EdgeParent: - if id := m.parent; id != nil { - return []ent.Value{*id} - } - case resource.EdgeChildren: - ids := make([]ent.Value, 0, len(m.children)) - for id := range m.children { - ids = append(ids, id) - } - return ids - case resource.EdgePermissions: - ids := make([]ent.Value, 0, len(m.permissions)) - for id := range m.permissions { - ids = append(ids, id) - } - return ids - case resource.EdgePermissionResources: - ids := make([]ent.Value, 0, len(m.permission_resources)) - for id := range m.permission_resources { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *ResourceMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - if m.removedchildren != nil { - edges = append(edges, resource.EdgeChildren) - } - if m.removedpermissions != nil { - edges = append(edges, resource.EdgePermissions) - } - if m.removedpermission_resources != nil { - edges = append(edges, resource.EdgePermissionResources) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *ResourceMutation) RemovedIDs(name string) []ent.Value { - switch name { - case resource.EdgeChildren: - ids := make([]ent.Value, 0, len(m.removedchildren)) - for id := range m.removedchildren { - ids = append(ids, id) - } - return ids - case resource.EdgePermissions: - ids := make([]ent.Value, 0, len(m.removedpermissions)) - for id := range m.removedpermissions { - ids = append(ids, id) - } - return ids - case resource.EdgePermissionResources: - ids := make([]ent.Value, 0, len(m.removedpermission_resources)) - for id := range m.removedpermission_resources { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ResourceMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) - if m.clearedparent { - edges = append(edges, resource.EdgeParent) - } - if m.clearedchildren { - edges = append(edges, resource.EdgeChildren) - } - if m.clearedpermissions { - edges = append(edges, resource.EdgePermissions) - } - if m.clearedpermission_resources { - edges = append(edges, resource.EdgePermissionResources) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *ResourceMutation) EdgeCleared(name string) bool { - switch name { - case resource.EdgeParent: - return m.clearedparent - case resource.EdgeChildren: - return m.clearedchildren - case resource.EdgePermissions: - return m.clearedpermissions - case resource.EdgePermissionResources: - return m.clearedpermission_resources - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *ResourceMutation) ClearEdge(name string) error { - switch name { - case resource.EdgeParent: - m.ClearParent() - return nil - } - return fmt.Errorf("unknown Resource unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *ResourceMutation) ResetEdge(name string) error { - switch name { - case resource.EdgeParent: - m.ResetParent() - return nil - case resource.EdgeChildren: - m.ResetChildren() - return nil - case resource.EdgePermissions: - m.ResetPermissions() - return nil - case resource.EdgePermissionResources: - m.ResetPermissionResources() - return nil - } - return fmt.Errorf("unknown Resource edge %s", name) -} - -// RoleMutation represents an operation that mutates the Role nodes in the graph. -type RoleMutation struct { - config - op Op - typ string - id *int64 - create_time *time.Time - update_time *time.Time - keyword *string - name *string - description *string - _type *int8 - add_type *int8 - sequence *int - addsequence *int - status *int8 - addstatus *int8 - clearedFields map[string]struct{} - users map[int64]struct{} - removedusers map[int64]struct{} - clearedusers bool - permissions map[int64]struct{} - removedpermissions map[int64]struct{} - clearedpermissions bool - user_roles map[int]struct{} - removeduser_roles map[int]struct{} - cleareduser_roles bool - role_permissions map[int]struct{} - removedrole_permissions map[int]struct{} - clearedrole_permissions bool - done bool - oldValue func(context.Context) (*Role, error) - predicates []predicate.Role -} - -var _ ent.Mutation = (*RoleMutation)(nil) - -// roleOption allows management of the mutation configuration using functional options. -type roleOption func(*RoleMutation) - -// newRoleMutation creates new mutation for the Role entity. -func newRoleMutation(c config, op Op, opts ...roleOption) *RoleMutation { - m := &RoleMutation{ - config: c, - op: op, - typ: TypeRole, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withRoleID sets the ID field of the mutation. -func withRoleID(id int64) roleOption { - return func(m *RoleMutation) { - var ( - err error - once sync.Once - value *Role - ) - m.oldValue = func(ctx context.Context) (*Role, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Role.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withRole sets the old Role of the mutation. -func withRole(node *Role) roleOption { - return func(m *RoleMutation) { - m.oldValue = func(context.Context) (*Role, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m RoleMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m RoleMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Role entities. -func (m *RoleMutation) SetID(id int64) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *RoleMutation) ID() (id int64, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *RoleMutation) IDs(ctx context.Context) ([]int64, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int64{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().Role.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetCreateTime sets the "create_time" field. -func (m *RoleMutation) SetCreateTime(t time.Time) { - m.create_time = &t -} - -// CreateTime returns the value of the "create_time" field in the mutation. -func (m *RoleMutation) CreateTime() (r time.Time, exists bool) { - v := m.create_time - if v == nil { - return - } - return *v, true -} - -// OldCreateTime returns the old "create_time" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreateTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) - } - return oldValue.CreateTime, nil -} - -// ResetCreateTime resets all changes to the "create_time" field. -func (m *RoleMutation) ResetCreateTime() { - m.create_time = nil -} - -// SetUpdateTime sets the "update_time" field. -func (m *RoleMutation) SetUpdateTime(t time.Time) { - m.update_time = &t -} - -// UpdateTime returns the value of the "update_time" field in the mutation. -func (m *RoleMutation) UpdateTime() (r time.Time, exists bool) { - v := m.update_time - if v == nil { - return - } - return *v, true -} - -// OldUpdateTime returns the old "update_time" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) - } - return oldValue.UpdateTime, nil -} - -// ResetUpdateTime resets all changes to the "update_time" field. -func (m *RoleMutation) ResetUpdateTime() { - m.update_time = nil -} - -// SetKeyword sets the "keyword" field. -func (m *RoleMutation) SetKeyword(s string) { - m.keyword = &s -} - -// Keyword returns the value of the "keyword" field in the mutation. -func (m *RoleMutation) Keyword() (r string, exists bool) { - v := m.keyword - if v == nil { - return - } - return *v, true -} - -// OldKeyword returns the old "keyword" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldKeyword(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKeyword is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKeyword requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldKeyword: %w", err) - } - return oldValue.Keyword, nil -} - -// ResetKeyword resets all changes to the "keyword" field. -func (m *RoleMutation) ResetKeyword() { - m.keyword = nil -} - -// SetName sets the "name" field. -func (m *RoleMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *RoleMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *RoleMutation) ResetName() { - m.name = nil -} - -// SetDescription sets the "description" field. -func (m *RoleMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *RoleMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true -} - -// OldDescription returns the old "description" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) - } - return oldValue.Description, nil -} - -// ResetDescription resets all changes to the "description" field. -func (m *RoleMutation) ResetDescription() { - m.description = nil -} - -// SetType sets the "type" field. -func (m *RoleMutation) SetType(i int8) { - m._type = &i - m.add_type = nil -} - -// GetType returns the value of the "type" field in the mutation. -func (m *RoleMutation) GetType() (r int8, exists bool) { - v := m._type - if v == nil { - return - } - return *v, true -} - -// OldType returns the old "type" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldType(ctx context.Context) (v int8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) - } - return oldValue.Type, nil -} - -// AddType adds i to the "type" field. -func (m *RoleMutation) AddType(i int8) { - if m.add_type != nil { - *m.add_type += i - } else { - m.add_type = &i - } -} - -// AddedType returns the value that was added to the "type" field in this mutation. -func (m *RoleMutation) AddedType() (r int8, exists bool) { - v := m.add_type - if v == nil { - return - } - return *v, true -} - -// ResetType resets all changes to the "type" field. -func (m *RoleMutation) ResetType() { - m._type = nil - m.add_type = nil -} - -// SetSequence sets the "sequence" field. -func (m *RoleMutation) SetSequence(i int) { - m.sequence = &i - m.addsequence = nil -} - -// Sequence returns the value of the "sequence" field in the mutation. -func (m *RoleMutation) Sequence() (r int, exists bool) { - v := m.sequence - if v == nil { - return - } - return *v, true -} - -// OldSequence returns the old "sequence" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldSequence(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSequence is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSequence requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSequence: %w", err) - } - return oldValue.Sequence, nil -} - -// AddSequence adds i to the "sequence" field. -func (m *RoleMutation) AddSequence(i int) { - if m.addsequence != nil { - *m.addsequence += i - } else { - m.addsequence = &i - } -} - -// AddedSequence returns the value that was added to the "sequence" field in this mutation. -func (m *RoleMutation) AddedSequence() (r int, exists bool) { - v := m.addsequence - if v == nil { - return - } - return *v, true -} - -// ResetSequence resets all changes to the "sequence" field. -func (m *RoleMutation) ResetSequence() { - m.sequence = nil - m.addsequence = nil -} - -// SetStatus sets the "status" field. -func (m *RoleMutation) SetStatus(i int8) { - m.status = &i - m.addstatus = nil -} - -// Status returns the value of the "status" field in the mutation. -func (m *RoleMutation) Status() (r int8, exists bool) { - v := m.status - if v == nil { - return - } - return *v, true -} - -// OldStatus returns the old "status" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldStatus(ctx context.Context) (v int8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) - } - return oldValue.Status, nil -} - -// AddStatus adds i to the "status" field. -func (m *RoleMutation) AddStatus(i int8) { - if m.addstatus != nil { - *m.addstatus += i - } else { - m.addstatus = &i - } -} - -// AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *RoleMutation) AddedStatus() (r int8, exists bool) { - v := m.addstatus - if v == nil { - return - } - return *v, true -} - -// ResetStatus resets all changes to the "status" field. -func (m *RoleMutation) ResetStatus() { - m.status = nil - m.addstatus = nil -} - -// AddUserIDs adds the "users" edge to the User entity by ids. -func (m *RoleMutation) AddUserIDs(ids ...int64) { - if m.users == nil { - m.users = make(map[int64]struct{}) - } - for i := range ids { - m.users[ids[i]] = struct{}{} - } -} - -// ClearUsers clears the "users" edge to the User entity. -func (m *RoleMutation) ClearUsers() { - m.clearedusers = true -} - -// UsersCleared reports if the "users" edge to the User entity was cleared. -func (m *RoleMutation) UsersCleared() bool { - return m.clearedusers -} - -// RemoveUserIDs removes the "users" edge to the User entity by IDs. -func (m *RoleMutation) RemoveUserIDs(ids ...int64) { - if m.removedusers == nil { - m.removedusers = make(map[int64]struct{}) - } - for i := range ids { - delete(m.users, ids[i]) - m.removedusers[ids[i]] = struct{}{} - } -} - -// RemovedUsers returns the removed IDs of the "users" edge to the User entity. -func (m *RoleMutation) RemovedUsersIDs() (ids []int64) { - for id := range m.removedusers { - ids = append(ids, id) - } - return -} - -// UsersIDs returns the "users" edge IDs in the mutation. -func (m *RoleMutation) UsersIDs() (ids []int64) { - for id := range m.users { - ids = append(ids, id) - } - return -} - -// ResetUsers resets all changes to the "users" edge. -func (m *RoleMutation) ResetUsers() { - m.users = nil - m.clearedusers = false - m.removedusers = nil -} - -// AddPermissionIDs adds the "permissions" edge to the Permission entity by ids. -func (m *RoleMutation) AddPermissionIDs(ids ...int64) { - if m.permissions == nil { - m.permissions = make(map[int64]struct{}) - } - for i := range ids { - m.permissions[ids[i]] = struct{}{} - } -} - -// ClearPermissions clears the "permissions" edge to the Permission entity. -func (m *RoleMutation) ClearPermissions() { - m.clearedpermissions = true -} - -// PermissionsCleared reports if the "permissions" edge to the Permission entity was cleared. -func (m *RoleMutation) PermissionsCleared() bool { - return m.clearedpermissions -} - -// RemovePermissionIDs removes the "permissions" edge to the Permission entity by IDs. -func (m *RoleMutation) RemovePermissionIDs(ids ...int64) { - if m.removedpermissions == nil { - m.removedpermissions = make(map[int64]struct{}) - } - for i := range ids { - delete(m.permissions, ids[i]) - m.removedpermissions[ids[i]] = struct{}{} - } -} - -// RemovedPermissions returns the removed IDs of the "permissions" edge to the Permission entity. -func (m *RoleMutation) RemovedPermissionsIDs() (ids []int64) { - for id := range m.removedpermissions { - ids = append(ids, id) - } - return -} - -// PermissionsIDs returns the "permissions" edge IDs in the mutation. -func (m *RoleMutation) PermissionsIDs() (ids []int64) { - for id := range m.permissions { - ids = append(ids, id) - } - return -} - -// ResetPermissions resets all changes to the "permissions" edge. -func (m *RoleMutation) ResetPermissions() { - m.permissions = nil - m.clearedpermissions = false - m.removedpermissions = nil -} - -// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by ids. -func (m *RoleMutation) AddUserRoleIDs(ids ...int) { - if m.user_roles == nil { - m.user_roles = make(map[int]struct{}) - } - for i := range ids { - m.user_roles[ids[i]] = struct{}{} - } -} - -// ClearUserRoles clears the "user_roles" edge to the UserRole entity. -func (m *RoleMutation) ClearUserRoles() { - m.cleareduser_roles = true -} - -// UserRolesCleared reports if the "user_roles" edge to the UserRole entity was cleared. -func (m *RoleMutation) UserRolesCleared() bool { - return m.cleareduser_roles -} - -// RemoveUserRoleIDs removes the "user_roles" edge to the UserRole entity by IDs. -func (m *RoleMutation) RemoveUserRoleIDs(ids ...int) { - if m.removeduser_roles == nil { - m.removeduser_roles = make(map[int]struct{}) - } - for i := range ids { - delete(m.user_roles, ids[i]) - m.removeduser_roles[ids[i]] = struct{}{} - } -} - -// RemovedUserRoles returns the removed IDs of the "user_roles" edge to the UserRole entity. -func (m *RoleMutation) RemovedUserRolesIDs() (ids []int) { - for id := range m.removeduser_roles { - ids = append(ids, id) - } - return -} - -// UserRolesIDs returns the "user_roles" edge IDs in the mutation. -func (m *RoleMutation) UserRolesIDs() (ids []int) { - for id := range m.user_roles { - ids = append(ids, id) - } - return -} - -// ResetUserRoles resets all changes to the "user_roles" edge. -func (m *RoleMutation) ResetUserRoles() { - m.user_roles = nil - m.cleareduser_roles = false - m.removeduser_roles = nil -} - -// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by ids. -func (m *RoleMutation) AddRolePermissionIDs(ids ...int) { - if m.role_permissions == nil { - m.role_permissions = make(map[int]struct{}) - } - for i := range ids { - m.role_permissions[ids[i]] = struct{}{} - } -} - -// ClearRolePermissions clears the "role_permissions" edge to the RolePermission entity. -func (m *RoleMutation) ClearRolePermissions() { - m.clearedrole_permissions = true -} - -// RolePermissionsCleared reports if the "role_permissions" edge to the RolePermission entity was cleared. -func (m *RoleMutation) RolePermissionsCleared() bool { - return m.clearedrole_permissions -} - -// RemoveRolePermissionIDs removes the "role_permissions" edge to the RolePermission entity by IDs. -func (m *RoleMutation) RemoveRolePermissionIDs(ids ...int) { - if m.removedrole_permissions == nil { - m.removedrole_permissions = make(map[int]struct{}) - } - for i := range ids { - delete(m.role_permissions, ids[i]) - m.removedrole_permissions[ids[i]] = struct{}{} - } -} - -// RemovedRolePermissions returns the removed IDs of the "role_permissions" edge to the RolePermission entity. -func (m *RoleMutation) RemovedRolePermissionsIDs() (ids []int) { - for id := range m.removedrole_permissions { - ids = append(ids, id) - } - return -} - -// RolePermissionsIDs returns the "role_permissions" edge IDs in the mutation. -func (m *RoleMutation) RolePermissionsIDs() (ids []int) { - for id := range m.role_permissions { - ids = append(ids, id) - } - return -} - -// ResetRolePermissions resets all changes to the "role_permissions" edge. -func (m *RoleMutation) ResetRolePermissions() { - m.role_permissions = nil - m.clearedrole_permissions = false - m.removedrole_permissions = nil -} - -// Where appends a list predicates to the RoleMutation builder. -func (m *RoleMutation) Where(ps ...predicate.Role) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the RoleMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *RoleMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Role, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *RoleMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *RoleMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (Role). -func (m *RoleMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *RoleMutation) Fields() []string { - fields := make([]string, 0, 8) - if m.create_time != nil { - fields = append(fields, role.FieldCreateTime) - } - if m.update_time != nil { - fields = append(fields, role.FieldUpdateTime) - } - if m.keyword != nil { - fields = append(fields, role.FieldKeyword) - } - if m.name != nil { - fields = append(fields, role.FieldName) - } - if m.description != nil { - fields = append(fields, role.FieldDescription) - } - if m._type != nil { - fields = append(fields, role.FieldType) - } - if m.sequence != nil { - fields = append(fields, role.FieldSequence) - } - if m.status != nil { - fields = append(fields, role.FieldStatus) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *RoleMutation) Field(name string) (ent.Value, bool) { - switch name { - case role.FieldCreateTime: - return m.CreateTime() - case role.FieldUpdateTime: - return m.UpdateTime() - case role.FieldKeyword: - return m.Keyword() - case role.FieldName: - return m.Name() - case role.FieldDescription: - return m.Description() - case role.FieldType: - return m.GetType() - case role.FieldSequence: - return m.Sequence() - case role.FieldStatus: - return m.Status() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *RoleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case role.FieldCreateTime: - return m.OldCreateTime(ctx) - case role.FieldUpdateTime: - return m.OldUpdateTime(ctx) - case role.FieldKeyword: - return m.OldKeyword(ctx) - case role.FieldName: - return m.OldName(ctx) - case role.FieldDescription: - return m.OldDescription(ctx) - case role.FieldType: - return m.OldType(ctx) - case role.FieldSequence: - return m.OldSequence(ctx) - case role.FieldStatus: - return m.OldStatus(ctx) - } - return nil, fmt.Errorf("unknown Role field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *RoleMutation) SetField(name string, value ent.Value) error { - switch name { - case role.FieldCreateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreateTime(v) - return nil - case role.FieldUpdateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdateTime(v) - return nil - case role.FieldKeyword: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKeyword(v) - return nil - case role.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case role.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case role.FieldType: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case role.FieldSequence: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSequence(v) - return nil - case role.FieldStatus: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetStatus(v) - return nil - } - return fmt.Errorf("unknown Role field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *RoleMutation) AddedFields() []string { - var fields []string - if m.add_type != nil { - fields = append(fields, role.FieldType) - } - if m.addsequence != nil { - fields = append(fields, role.FieldSequence) - } - if m.addstatus != nil { - fields = append(fields, role.FieldStatus) - } - return fields -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *RoleMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case role.FieldType: - return m.AddedType() - case role.FieldSequence: - return m.AddedSequence() - case role.FieldStatus: - return m.AddedStatus() - } - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *RoleMutation) AddField(name string, value ent.Value) error { - switch name { - case role.FieldType: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddType(v) - return nil - case role.FieldSequence: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSequence(v) - return nil - case role.FieldStatus: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddStatus(v) - return nil - } - return fmt.Errorf("unknown Role numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *RoleMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *RoleMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *RoleMutation) ClearField(name string) error { - return fmt.Errorf("unknown Role nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *RoleMutation) ResetField(name string) error { - switch name { - case role.FieldCreateTime: - m.ResetCreateTime() - return nil - case role.FieldUpdateTime: - m.ResetUpdateTime() - return nil - case role.FieldKeyword: - m.ResetKeyword() - return nil - case role.FieldName: - m.ResetName() - return nil - case role.FieldDescription: - m.ResetDescription() - return nil - case role.FieldType: - m.ResetType() - return nil - case role.FieldSequence: - m.ResetSequence() - return nil - case role.FieldStatus: - m.ResetStatus() - return nil - } - return fmt.Errorf("unknown Role field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *RoleMutation) AddedEdges() []string { - edges := make([]string, 0, 4) - if m.users != nil { - edges = append(edges, role.EdgeUsers) - } - if m.permissions != nil { - edges = append(edges, role.EdgePermissions) - } - if m.user_roles != nil { - edges = append(edges, role.EdgeUserRoles) - } - if m.role_permissions != nil { - edges = append(edges, role.EdgeRolePermissions) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *RoleMutation) AddedIDs(name string) []ent.Value { - switch name { - case role.EdgeUsers: - ids := make([]ent.Value, 0, len(m.users)) - for id := range m.users { - ids = append(ids, id) - } - return ids - case role.EdgePermissions: - ids := make([]ent.Value, 0, len(m.permissions)) - for id := range m.permissions { - ids = append(ids, id) - } - return ids - case role.EdgeUserRoles: - ids := make([]ent.Value, 0, len(m.user_roles)) - for id := range m.user_roles { - ids = append(ids, id) - } - return ids - case role.EdgeRolePermissions: - ids := make([]ent.Value, 0, len(m.role_permissions)) - for id := range m.role_permissions { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *RoleMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - if m.removedusers != nil { - edges = append(edges, role.EdgeUsers) - } - if m.removedpermissions != nil { - edges = append(edges, role.EdgePermissions) - } - if m.removeduser_roles != nil { - edges = append(edges, role.EdgeUserRoles) - } - if m.removedrole_permissions != nil { - edges = append(edges, role.EdgeRolePermissions) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *RoleMutation) RemovedIDs(name string) []ent.Value { - switch name { - case role.EdgeUsers: - ids := make([]ent.Value, 0, len(m.removedusers)) - for id := range m.removedusers { - ids = append(ids, id) - } - return ids - case role.EdgePermissions: - ids := make([]ent.Value, 0, len(m.removedpermissions)) - for id := range m.removedpermissions { - ids = append(ids, id) - } - return ids - case role.EdgeUserRoles: - ids := make([]ent.Value, 0, len(m.removeduser_roles)) - for id := range m.removeduser_roles { - ids = append(ids, id) - } - return ids - case role.EdgeRolePermissions: - ids := make([]ent.Value, 0, len(m.removedrole_permissions)) - for id := range m.removedrole_permissions { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *RoleMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) - if m.clearedusers { - edges = append(edges, role.EdgeUsers) - } - if m.clearedpermissions { - edges = append(edges, role.EdgePermissions) - } - if m.cleareduser_roles { - edges = append(edges, role.EdgeUserRoles) - } - if m.clearedrole_permissions { - edges = append(edges, role.EdgeRolePermissions) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *RoleMutation) EdgeCleared(name string) bool { - switch name { - case role.EdgeUsers: - return m.clearedusers - case role.EdgePermissions: - return m.clearedpermissions - case role.EdgeUserRoles: - return m.cleareduser_roles - case role.EdgeRolePermissions: - return m.clearedrole_permissions - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *RoleMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown Role unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *RoleMutation) ResetEdge(name string) error { - switch name { - case role.EdgeUsers: - m.ResetUsers() - return nil - case role.EdgePermissions: - m.ResetPermissions() - return nil - case role.EdgeUserRoles: - m.ResetUserRoles() - return nil - case role.EdgeRolePermissions: - m.ResetRolePermissions() - return nil - } - return fmt.Errorf("unknown Role edge %s", name) -} - -// RolePermissionMutation represents an operation that mutates the RolePermission nodes in the graph. -type RolePermissionMutation struct { - config - op Op - typ string - id *int - clearedFields map[string]struct{} - role *int64 - clearedrole bool - permission *int64 - clearedpermission bool - done bool - oldValue func(context.Context) (*RolePermission, error) - predicates []predicate.RolePermission -} - -var _ ent.Mutation = (*RolePermissionMutation)(nil) - -// rolepermissionOption allows management of the mutation configuration using functional options. -type rolepermissionOption func(*RolePermissionMutation) - -// newRolePermissionMutation creates new mutation for the RolePermission entity. -func newRolePermissionMutation(c config, op Op, opts ...rolepermissionOption) *RolePermissionMutation { - m := &RolePermissionMutation{ - config: c, - op: op, - typ: TypeRolePermission, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withRolePermissionID sets the ID field of the mutation. -func withRolePermissionID(id int) rolepermissionOption { - return func(m *RolePermissionMutation) { - var ( - err error - once sync.Once - value *RolePermission - ) - m.oldValue = func(ctx context.Context) (*RolePermission, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().RolePermission.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withRolePermission sets the old RolePermission of the mutation. -func withRolePermission(node *RolePermission) rolepermissionOption { - return func(m *RolePermissionMutation) { - m.oldValue = func(context.Context) (*RolePermission, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m RolePermissionMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m RolePermissionMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *RolePermissionMutation) ID() (id int, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *RolePermissionMutation) IDs(ctx context.Context) ([]int, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().RolePermission.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetRoleID sets the "role_id" field. -func (m *RolePermissionMutation) SetRoleID(i int64) { - m.role = &i -} - -// RoleID returns the value of the "role_id" field in the mutation. -func (m *RolePermissionMutation) RoleID() (r int64, exists bool) { - v := m.role - if v == nil { - return - } - return *v, true -} - -// OldRoleID returns the old "role_id" field's value of the RolePermission entity. -// If the RolePermission object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RolePermissionMutation) OldRoleID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRoleID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRoleID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRoleID: %w", err) - } - return oldValue.RoleID, nil -} - -// ResetRoleID resets all changes to the "role_id" field. -func (m *RolePermissionMutation) ResetRoleID() { - m.role = nil -} - -// SetPermissionID sets the "permission_id" field. -func (m *RolePermissionMutation) SetPermissionID(i int64) { - m.permission = &i -} - -// PermissionID returns the value of the "permission_id" field in the mutation. -func (m *RolePermissionMutation) PermissionID() (r int64, exists bool) { - v := m.permission - if v == nil { - return - } - return *v, true -} - -// OldPermissionID returns the old "permission_id" field's value of the RolePermission entity. -// If the RolePermission object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RolePermissionMutation) OldPermissionID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPermissionID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPermissionID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPermissionID: %w", err) - } - return oldValue.PermissionID, nil -} - -// ResetPermissionID resets all changes to the "permission_id" field. -func (m *RolePermissionMutation) ResetPermissionID() { - m.permission = nil -} - -// ClearRole clears the "role" edge to the Role entity. -func (m *RolePermissionMutation) ClearRole() { - m.clearedrole = true - m.clearedFields[rolepermission.FieldRoleID] = struct{}{} -} - -// RoleCleared reports if the "role" edge to the Role entity was cleared. -func (m *RolePermissionMutation) RoleCleared() bool { - return m.clearedrole -} - -// RoleIDs returns the "role" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// RoleID instead. It exists only for internal usage by the builders. -func (m *RolePermissionMutation) RoleIDs() (ids []int64) { - if id := m.role; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetRole resets all changes to the "role" edge. -func (m *RolePermissionMutation) ResetRole() { - m.role = nil - m.clearedrole = false -} - -// ClearPermission clears the "permission" edge to the Permission entity. -func (m *RolePermissionMutation) ClearPermission() { - m.clearedpermission = true - m.clearedFields[rolepermission.FieldPermissionID] = struct{}{} -} - -// PermissionCleared reports if the "permission" edge to the Permission entity was cleared. -func (m *RolePermissionMutation) PermissionCleared() bool { - return m.clearedpermission -} - -// PermissionIDs returns the "permission" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// PermissionID instead. It exists only for internal usage by the builders. -func (m *RolePermissionMutation) PermissionIDs() (ids []int64) { - if id := m.permission; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetPermission resets all changes to the "permission" edge. -func (m *RolePermissionMutation) ResetPermission() { - m.permission = nil - m.clearedpermission = false -} - -// Where appends a list predicates to the RolePermissionMutation builder. -func (m *RolePermissionMutation) Where(ps ...predicate.RolePermission) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the RolePermissionMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *RolePermissionMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.RolePermission, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *RolePermissionMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *RolePermissionMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (RolePermission). -func (m *RolePermissionMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *RolePermissionMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.role != nil { - fields = append(fields, rolepermission.FieldRoleID) - } - if m.permission != nil { - fields = append(fields, rolepermission.FieldPermissionID) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *RolePermissionMutation) Field(name string) (ent.Value, bool) { - switch name { - case rolepermission.FieldRoleID: - return m.RoleID() - case rolepermission.FieldPermissionID: - return m.PermissionID() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *RolePermissionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case rolepermission.FieldRoleID: - return m.OldRoleID(ctx) - case rolepermission.FieldPermissionID: - return m.OldPermissionID(ctx) - } - return nil, fmt.Errorf("unknown RolePermission field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *RolePermissionMutation) SetField(name string, value ent.Value) error { - switch name { - case rolepermission.FieldRoleID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRoleID(v) - return nil - case rolepermission.FieldPermissionID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPermissionID(v) - return nil - } - return fmt.Errorf("unknown RolePermission field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *RolePermissionMutation) AddedFields() []string { - var fields []string - return fields -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *RolePermissionMutation) AddedField(name string) (ent.Value, bool) { - switch name { - } - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *RolePermissionMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown RolePermission numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *RolePermissionMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *RolePermissionMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *RolePermissionMutation) ClearField(name string) error { - return fmt.Errorf("unknown RolePermission nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *RolePermissionMutation) ResetField(name string) error { - switch name { - case rolepermission.FieldRoleID: - m.ResetRoleID() - return nil - case rolepermission.FieldPermissionID: - m.ResetPermissionID() - return nil - } - return fmt.Errorf("unknown RolePermission field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *RolePermissionMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.role != nil { - edges = append(edges, rolepermission.EdgeRole) - } - if m.permission != nil { - edges = append(edges, rolepermission.EdgePermission) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *RolePermissionMutation) AddedIDs(name string) []ent.Value { - switch name { - case rolepermission.EdgeRole: - if id := m.role; id != nil { - return []ent.Value{*id} - } - case rolepermission.EdgePermission: - if id := m.permission; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *RolePermissionMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *RolePermissionMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *RolePermissionMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedrole { - edges = append(edges, rolepermission.EdgeRole) - } - if m.clearedpermission { - edges = append(edges, rolepermission.EdgePermission) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *RolePermissionMutation) EdgeCleared(name string) bool { - switch name { - case rolepermission.EdgeRole: - return m.clearedrole - case rolepermission.EdgePermission: - return m.clearedpermission - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *RolePermissionMutation) ClearEdge(name string) error { - switch name { - case rolepermission.EdgeRole: - m.ClearRole() - return nil - case rolepermission.EdgePermission: - m.ClearPermission() - return nil - } - return fmt.Errorf("unknown RolePermission unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *RolePermissionMutation) ResetEdge(name string) error { - switch name { - case rolepermission.EdgeRole: - m.ResetRole() - return nil - case rolepermission.EdgePermission: - m.ResetPermission() - return nil - } - return fmt.Errorf("unknown RolePermission edge %s", name) -} - -// UserMutation represents an operation that mutates the User nodes in the graph. -type UserMutation struct { - config - op Op - typ string - id *int64 - create_time *time.Time - update_time *time.Time - uuid *string - allowed_ip *string - username *string - nickname *string - avatar *string - name *string - gender *user.Gender - password *string - phone *string - email *string - department *string - remark *string - status *int8 - addstatus *int8 - is_system *bool - last_login_ip *string - last_login_time *time.Time - clearedFields map[string]struct{} - roles map[int64]struct{} - removedroles map[int64]struct{} - clearedroles bool - user_roles map[int]struct{} - removeduser_roles map[int]struct{} - cleareduser_roles bool - done bool - oldValue func(context.Context) (*User, error) - predicates []predicate.User -} - -var _ ent.Mutation = (*UserMutation)(nil) - -// userOption allows management of the mutation configuration using functional options. -type userOption func(*UserMutation) - -// newUserMutation creates new mutation for the User entity. -func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { - m := &UserMutation{ - config: c, - op: op, - typ: TypeUser, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withUserID sets the ID field of the mutation. -func withUserID(id int64) userOption { - return func(m *UserMutation) { - var ( - err error - once sync.Once - value *User - ) - m.oldValue = func(ctx context.Context) (*User, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().User.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withUser sets the old User of the mutation. -func withUser(node *User) userOption { - return func(m *UserMutation) { - m.oldValue = func(context.Context) (*User, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m UserMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m UserMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of User entities. -func (m *UserMutation) SetID(id int64) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *UserMutation) ID() (id int64, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *UserMutation) IDs(ctx context.Context) ([]int64, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int64{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().User.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetCreateTime sets the "create_time" field. -func (m *UserMutation) SetCreateTime(t time.Time) { - m.create_time = &t -} - -// CreateTime returns the value of the "create_time" field in the mutation. -func (m *UserMutation) CreateTime() (r time.Time, exists bool) { - v := m.create_time - if v == nil { - return - } - return *v, true -} - -// OldCreateTime returns the old "create_time" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreateTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) - } - return oldValue.CreateTime, nil -} - -// ResetCreateTime resets all changes to the "create_time" field. -func (m *UserMutation) ResetCreateTime() { - m.create_time = nil -} - -// SetUpdateTime sets the "update_time" field. -func (m *UserMutation) SetUpdateTime(t time.Time) { - m.update_time = &t -} - -// UpdateTime returns the value of the "update_time" field in the mutation. -func (m *UserMutation) UpdateTime() (r time.Time, exists bool) { - v := m.update_time - if v == nil { - return - } - return *v, true -} - -// OldUpdateTime returns the old "update_time" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) - } - return oldValue.UpdateTime, nil -} - -// ResetUpdateTime resets all changes to the "update_time" field. -func (m *UserMutation) ResetUpdateTime() { - m.update_time = nil -} - -// SetUUID sets the "uuid" field. -func (m *UserMutation) SetUUID(s string) { - m.uuid = &s -} - -// UUID returns the value of the "uuid" field in the mutation. -func (m *UserMutation) UUID() (r string, exists bool) { - v := m.uuid - if v == nil { - return - } - return *v, true -} - -// OldUUID returns the old "uuid" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUUID(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUUID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUUID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUUID: %w", err) - } - return oldValue.UUID, nil -} - -// ResetUUID resets all changes to the "uuid" field. -func (m *UserMutation) ResetUUID() { - m.uuid = nil -} - -// SetAllowedIP sets the "allowed_ip" field. -func (m *UserMutation) SetAllowedIP(s string) { - m.allowed_ip = &s -} - -// AllowedIP returns the value of the "allowed_ip" field in the mutation. -func (m *UserMutation) AllowedIP() (r string, exists bool) { - v := m.allowed_ip - if v == nil { - return - } - return *v, true -} - -// OldAllowedIP returns the old "allowed_ip" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldAllowedIP(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAllowedIP is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAllowedIP requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAllowedIP: %w", err) - } - return oldValue.AllowedIP, nil -} - -// ResetAllowedIP resets all changes to the "allowed_ip" field. -func (m *UserMutation) ResetAllowedIP() { - m.allowed_ip = nil -} - -// SetUsername sets the "username" field. -func (m *UserMutation) SetUsername(s string) { - m.username = &s -} - -// Username returns the value of the "username" field in the mutation. -func (m *UserMutation) Username() (r string, exists bool) { - v := m.username - if v == nil { - return - } - return *v, true -} - -// OldUsername returns the old "username" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUsername is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUsername requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUsername: %w", err) - } - return oldValue.Username, nil -} - -// ResetUsername resets all changes to the "username" field. -func (m *UserMutation) ResetUsername() { - m.username = nil -} - -// SetNickname sets the "nickname" field. -func (m *UserMutation) SetNickname(s string) { - m.nickname = &s -} - -// Nickname returns the value of the "nickname" field in the mutation. -func (m *UserMutation) Nickname() (r string, exists bool) { - v := m.nickname - if v == nil { - return - } - return *v, true -} - -// OldNickname returns the old "nickname" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldNickname(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNickname is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNickname requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldNickname: %w", err) - } - return oldValue.Nickname, nil -} - -// ResetNickname resets all changes to the "nickname" field. -func (m *UserMutation) ResetNickname() { - m.nickname = nil -} - -// SetAvatar sets the "avatar" field. -func (m *UserMutation) SetAvatar(s string) { - m.avatar = &s -} - -// Avatar returns the value of the "avatar" field in the mutation. -func (m *UserMutation) Avatar() (r string, exists bool) { - v := m.avatar - if v == nil { - return - } - return *v, true -} - -// OldAvatar returns the old "avatar" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldAvatar(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAvatar is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAvatar requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldAvatar: %w", err) - } - return oldValue.Avatar, nil -} - -// ResetAvatar resets all changes to the "avatar" field. -func (m *UserMutation) ResetAvatar() { - m.avatar = nil -} - -// SetName sets the "name" field. -func (m *UserMutation) SetName(s string) { - m.name = &s -} - -// Name returns the value of the "name" field in the mutation. -func (m *UserMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true -} - -// OldName returns the old "name" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *UserMutation) ResetName() { - m.name = nil -} - -// SetGender sets the "gender" field. -func (m *UserMutation) SetGender(u user.Gender) { - m.gender = &u -} - -// Gender returns the value of the "gender" field in the mutation. -func (m *UserMutation) Gender() (r user.Gender, exists bool) { - v := m.gender - if v == nil { - return - } - return *v, true -} - -// OldGender returns the old "gender" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldGender(ctx context.Context) (v user.Gender, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldGender is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldGender requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldGender: %w", err) - } - return oldValue.Gender, nil -} - -// ResetGender resets all changes to the "gender" field. -func (m *UserMutation) ResetGender() { - m.gender = nil -} - -// SetPassword sets the "password" field. -func (m *UserMutation) SetPassword(s string) { - m.password = &s -} - -// Password returns the value of the "password" field in the mutation. -func (m *UserMutation) Password() (r string, exists bool) { - v := m.password - if v == nil { - return - } - return *v, true -} - -// OldPassword returns the old "password" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPassword is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPassword requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPassword: %w", err) - } - return oldValue.Password, nil -} - -// ResetPassword resets all changes to the "password" field. -func (m *UserMutation) ResetPassword() { - m.password = nil -} - -// SetPhone sets the "phone" field. -func (m *UserMutation) SetPhone(s string) { - m.phone = &s -} - -// Phone returns the value of the "phone" field in the mutation. -func (m *UserMutation) Phone() (r string, exists bool) { - v := m.phone - if v == nil { - return - } - return *v, true -} - -// OldPhone returns the old "phone" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldPhone(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPhone is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPhone requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldPhone: %w", err) - } - return oldValue.Phone, nil -} - -// ResetPhone resets all changes to the "phone" field. -func (m *UserMutation) ResetPhone() { - m.phone = nil -} - -// SetEmail sets the "email" field. -func (m *UserMutation) SetEmail(s string) { - m.email = &s -} - -// Email returns the value of the "email" field in the mutation. -func (m *UserMutation) Email() (r string, exists bool) { - v := m.email - if v == nil { - return - } - return *v, true -} - -// OldEmail returns the old "email" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEmail is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEmail requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldEmail: %w", err) - } - return oldValue.Email, nil -} - -// ResetEmail resets all changes to the "email" field. -func (m *UserMutation) ResetEmail() { - m.email = nil -} - -// SetDepartment sets the "department" field. -func (m *UserMutation) SetDepartment(s string) { - m.department = &s -} - -// Department returns the value of the "department" field in the mutation. -func (m *UserMutation) Department() (r string, exists bool) { - v := m.department - if v == nil { - return - } - return *v, true -} - -// OldDepartment returns the old "department" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldDepartment(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDepartment is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDepartment requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDepartment: %w", err) - } - return oldValue.Department, nil -} - -// ResetDepartment resets all changes to the "department" field. -func (m *UserMutation) ResetDepartment() { - m.department = nil -} - -// SetRemark sets the "remark" field. -func (m *UserMutation) SetRemark(s string) { - m.remark = &s -} - -// Remark returns the value of the "remark" field in the mutation. -func (m *UserMutation) Remark() (r string, exists bool) { - v := m.remark - if v == nil { - return - } - return *v, true -} - -// OldRemark returns the old "remark" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldRemark(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRemark is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRemark requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRemark: %w", err) - } - return oldValue.Remark, nil -} - -// ResetRemark resets all changes to the "remark" field. -func (m *UserMutation) ResetRemark() { - m.remark = nil -} - -// SetStatus sets the "status" field. -func (m *UserMutation) SetStatus(i int8) { - m.status = &i - m.addstatus = nil -} - -// Status returns the value of the "status" field in the mutation. -func (m *UserMutation) Status() (r int8, exists bool) { - v := m.status - if v == nil { - return - } - return *v, true -} - -// OldStatus returns the old "status" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldStatus(ctx context.Context) (v int8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) - } - return oldValue.Status, nil -} - -// AddStatus adds i to the "status" field. -func (m *UserMutation) AddStatus(i int8) { - if m.addstatus != nil { - *m.addstatus += i - } else { - m.addstatus = &i - } -} - -// AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *UserMutation) AddedStatus() (r int8, exists bool) { - v := m.addstatus - if v == nil { - return - } - return *v, true -} - -// ResetStatus resets all changes to the "status" field. -func (m *UserMutation) ResetStatus() { - m.status = nil - m.addstatus = nil -} - -// SetIsSystem sets the "is_system" field. -func (m *UserMutation) SetIsSystem(b bool) { - m.is_system = &b -} - -// IsSystem returns the value of the "is_system" field in the mutation. -func (m *UserMutation) IsSystem() (r bool, exists bool) { - v := m.is_system - if v == nil { - return - } - return *v, true -} - -// OldIsSystem returns the old "is_system" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldIsSystem(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsSystem is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsSystem requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIsSystem: %w", err) - } - return oldValue.IsSystem, nil -} - -// ResetIsSystem resets all changes to the "is_system" field. -func (m *UserMutation) ResetIsSystem() { - m.is_system = nil -} - -// SetLastLoginIP sets the "last_login_ip" field. -func (m *UserMutation) SetLastLoginIP(s string) { - m.last_login_ip = &s -} - -// LastLoginIP returns the value of the "last_login_ip" field in the mutation. -func (m *UserMutation) LastLoginIP() (r string, exists bool) { - v := m.last_login_ip - if v == nil { - return - } - return *v, true -} - -// OldLastLoginIP returns the old "last_login_ip" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldLastLoginIP(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastLoginIP is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastLoginIP requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLastLoginIP: %w", err) - } - return oldValue.LastLoginIP, nil -} - -// ResetLastLoginIP resets all changes to the "last_login_ip" field. -func (m *UserMutation) ResetLastLoginIP() { - m.last_login_ip = nil -} - -// SetLastLoginTime sets the "last_login_time" field. -func (m *UserMutation) SetLastLoginTime(t time.Time) { - m.last_login_time = &t -} - -// LastLoginTime returns the value of the "last_login_time" field in the mutation. -func (m *UserMutation) LastLoginTime() (r time.Time, exists bool) { - v := m.last_login_time - if v == nil { - return - } - return *v, true -} - -// OldLastLoginTime returns the old "last_login_time" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldLastLoginTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastLoginTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastLoginTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLastLoginTime: %w", err) - } - return oldValue.LastLoginTime, nil -} - -// ClearLastLoginTime clears the value of the "last_login_time" field. -func (m *UserMutation) ClearLastLoginTime() { - m.last_login_time = nil - m.clearedFields[user.FieldLastLoginTime] = struct{}{} -} - -// LastLoginTimeCleared returns if the "last_login_time" field was cleared in this mutation. -func (m *UserMutation) LastLoginTimeCleared() bool { - _, ok := m.clearedFields[user.FieldLastLoginTime] - return ok -} - -// ResetLastLoginTime resets all changes to the "last_login_time" field. -func (m *UserMutation) ResetLastLoginTime() { - m.last_login_time = nil - delete(m.clearedFields, user.FieldLastLoginTime) -} - -// AddRoleIDs adds the "roles" edge to the Role entity by ids. -func (m *UserMutation) AddRoleIDs(ids ...int64) { - if m.roles == nil { - m.roles = make(map[int64]struct{}) - } - for i := range ids { - m.roles[ids[i]] = struct{}{} - } -} - -// ClearRoles clears the "roles" edge to the Role entity. -func (m *UserMutation) ClearRoles() { - m.clearedroles = true -} - -// RolesCleared reports if the "roles" edge to the Role entity was cleared. -func (m *UserMutation) RolesCleared() bool { - return m.clearedroles -} - -// RemoveRoleIDs removes the "roles" edge to the Role entity by IDs. -func (m *UserMutation) RemoveRoleIDs(ids ...int64) { - if m.removedroles == nil { - m.removedroles = make(map[int64]struct{}) - } - for i := range ids { - delete(m.roles, ids[i]) - m.removedroles[ids[i]] = struct{}{} - } -} - -// RemovedRoles returns the removed IDs of the "roles" edge to the Role entity. -func (m *UserMutation) RemovedRolesIDs() (ids []int64) { - for id := range m.removedroles { - ids = append(ids, id) - } - return -} - -// RolesIDs returns the "roles" edge IDs in the mutation. -func (m *UserMutation) RolesIDs() (ids []int64) { - for id := range m.roles { - ids = append(ids, id) - } - return -} - -// ResetRoles resets all changes to the "roles" edge. -func (m *UserMutation) ResetRoles() { - m.roles = nil - m.clearedroles = false - m.removedroles = nil -} - -// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by ids. -func (m *UserMutation) AddUserRoleIDs(ids ...int) { - if m.user_roles == nil { - m.user_roles = make(map[int]struct{}) - } - for i := range ids { - m.user_roles[ids[i]] = struct{}{} - } -} - -// ClearUserRoles clears the "user_roles" edge to the UserRole entity. -func (m *UserMutation) ClearUserRoles() { - m.cleareduser_roles = true -} - -// UserRolesCleared reports if the "user_roles" edge to the UserRole entity was cleared. -func (m *UserMutation) UserRolesCleared() bool { - return m.cleareduser_roles -} - -// RemoveUserRoleIDs removes the "user_roles" edge to the UserRole entity by IDs. -func (m *UserMutation) RemoveUserRoleIDs(ids ...int) { - if m.removeduser_roles == nil { - m.removeduser_roles = make(map[int]struct{}) - } - for i := range ids { - delete(m.user_roles, ids[i]) - m.removeduser_roles[ids[i]] = struct{}{} - } -} - -// RemovedUserRoles returns the removed IDs of the "user_roles" edge to the UserRole entity. -func (m *UserMutation) RemovedUserRolesIDs() (ids []int) { - for id := range m.removeduser_roles { - ids = append(ids, id) - } - return -} - -// UserRolesIDs returns the "user_roles" edge IDs in the mutation. -func (m *UserMutation) UserRolesIDs() (ids []int) { - for id := range m.user_roles { - ids = append(ids, id) - } - return -} - -// ResetUserRoles resets all changes to the "user_roles" edge. -func (m *UserMutation) ResetUserRoles() { - m.user_roles = nil - m.cleareduser_roles = false - m.removeduser_roles = nil -} - -// Where appends a list predicates to the UserMutation builder. -func (m *UserMutation) Where(ps ...predicate.User) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the UserMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.User, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *UserMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *UserMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (User). -func (m *UserMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 18) - if m.create_time != nil { - fields = append(fields, user.FieldCreateTime) - } - if m.update_time != nil { - fields = append(fields, user.FieldUpdateTime) - } - if m.uuid != nil { - fields = append(fields, user.FieldUUID) - } - if m.allowed_ip != nil { - fields = append(fields, user.FieldAllowedIP) - } - if m.username != nil { - fields = append(fields, user.FieldUsername) - } - if m.nickname != nil { - fields = append(fields, user.FieldNickname) - } - if m.avatar != nil { - fields = append(fields, user.FieldAvatar) - } - if m.name != nil { - fields = append(fields, user.FieldName) - } - if m.gender != nil { - fields = append(fields, user.FieldGender) - } - if m.password != nil { - fields = append(fields, user.FieldPassword) - } - if m.phone != nil { - fields = append(fields, user.FieldPhone) - } - if m.email != nil { - fields = append(fields, user.FieldEmail) - } - if m.department != nil { - fields = append(fields, user.FieldDepartment) - } - if m.remark != nil { - fields = append(fields, user.FieldRemark) - } - if m.status != nil { - fields = append(fields, user.FieldStatus) - } - if m.is_system != nil { - fields = append(fields, user.FieldIsSystem) - } - if m.last_login_ip != nil { - fields = append(fields, user.FieldLastLoginIP) - } - if m.last_login_time != nil { - fields = append(fields, user.FieldLastLoginTime) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *UserMutation) Field(name string) (ent.Value, bool) { - switch name { - case user.FieldCreateTime: - return m.CreateTime() - case user.FieldUpdateTime: - return m.UpdateTime() - case user.FieldUUID: - return m.UUID() - case user.FieldAllowedIP: - return m.AllowedIP() - case user.FieldUsername: - return m.Username() - case user.FieldNickname: - return m.Nickname() - case user.FieldAvatar: - return m.Avatar() - case user.FieldName: - return m.Name() - case user.FieldGender: - return m.Gender() - case user.FieldPassword: - return m.Password() - case user.FieldPhone: - return m.Phone() - case user.FieldEmail: - return m.Email() - case user.FieldDepartment: - return m.Department() - case user.FieldRemark: - return m.Remark() - case user.FieldStatus: - return m.Status() - case user.FieldIsSystem: - return m.IsSystem() - case user.FieldLastLoginIP: - return m.LastLoginIP() - case user.FieldLastLoginTime: - return m.LastLoginTime() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case user.FieldCreateTime: - return m.OldCreateTime(ctx) - case user.FieldUpdateTime: - return m.OldUpdateTime(ctx) - case user.FieldUUID: - return m.OldUUID(ctx) - case user.FieldAllowedIP: - return m.OldAllowedIP(ctx) - case user.FieldUsername: - return m.OldUsername(ctx) - case user.FieldNickname: - return m.OldNickname(ctx) - case user.FieldAvatar: - return m.OldAvatar(ctx) - case user.FieldName: - return m.OldName(ctx) - case user.FieldGender: - return m.OldGender(ctx) - case user.FieldPassword: - return m.OldPassword(ctx) - case user.FieldPhone: - return m.OldPhone(ctx) - case user.FieldEmail: - return m.OldEmail(ctx) - case user.FieldDepartment: - return m.OldDepartment(ctx) - case user.FieldRemark: - return m.OldRemark(ctx) - case user.FieldStatus: - return m.OldStatus(ctx) - case user.FieldIsSystem: - return m.OldIsSystem(ctx) - case user.FieldLastLoginIP: - return m.OldLastLoginIP(ctx) - case user.FieldLastLoginTime: - return m.OldLastLoginTime(ctx) - } - return nil, fmt.Errorf("unknown User field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *UserMutation) SetField(name string, value ent.Value) error { - switch name { - case user.FieldCreateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreateTime(v) - return nil - case user.FieldUpdateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdateTime(v) - return nil - case user.FieldUUID: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUUID(v) - return nil - case user.FieldAllowedIP: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAllowedIP(v) - return nil - case user.FieldUsername: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUsername(v) - return nil - case user.FieldNickname: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetNickname(v) - return nil - case user.FieldAvatar: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetAvatar(v) - return nil - case user.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case user.FieldGender: - v, ok := value.(user.Gender) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetGender(v) - return nil - case user.FieldPassword: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPassword(v) - return nil - case user.FieldPhone: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPhone(v) - return nil - case user.FieldEmail: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetEmail(v) - return nil - case user.FieldDepartment: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDepartment(v) - return nil - case user.FieldRemark: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRemark(v) - return nil - case user.FieldStatus: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetStatus(v) - return nil - case user.FieldIsSystem: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIsSystem(v) - return nil - case user.FieldLastLoginIP: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLastLoginIP(v) - return nil - case user.FieldLastLoginTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLastLoginTime(v) - return nil - } - return fmt.Errorf("unknown User field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *UserMutation) AddedFields() []string { - var fields []string - if m.addstatus != nil { - fields = append(fields, user.FieldStatus) - } - return fields -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *UserMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case user.FieldStatus: - return m.AddedStatus() - } - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *UserMutation) AddField(name string, value ent.Value) error { - switch name { - case user.FieldStatus: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddStatus(v) - return nil - } - return fmt.Errorf("unknown User numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *UserMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(user.FieldLastLoginTime) { - fields = append(fields, user.FieldLastLoginTime) - } - return fields -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *UserMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *UserMutation) ClearField(name string) error { - switch name { - case user.FieldLastLoginTime: - m.ClearLastLoginTime() - return nil - } - return fmt.Errorf("unknown User nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *UserMutation) ResetField(name string) error { - switch name { - case user.FieldCreateTime: - m.ResetCreateTime() - return nil - case user.FieldUpdateTime: - m.ResetUpdateTime() - return nil - case user.FieldUUID: - m.ResetUUID() - return nil - case user.FieldAllowedIP: - m.ResetAllowedIP() - return nil - case user.FieldUsername: - m.ResetUsername() - return nil - case user.FieldNickname: - m.ResetNickname() - return nil - case user.FieldAvatar: - m.ResetAvatar() - return nil - case user.FieldName: - m.ResetName() - return nil - case user.FieldGender: - m.ResetGender() - return nil - case user.FieldPassword: - m.ResetPassword() - return nil - case user.FieldPhone: - m.ResetPhone() - return nil - case user.FieldEmail: - m.ResetEmail() - return nil - case user.FieldDepartment: - m.ResetDepartment() - return nil - case user.FieldRemark: - m.ResetRemark() - return nil - case user.FieldStatus: - m.ResetStatus() - return nil - case user.FieldIsSystem: - m.ResetIsSystem() - return nil - case user.FieldLastLoginIP: - m.ResetLastLoginIP() - return nil - case user.FieldLastLoginTime: - m.ResetLastLoginTime() - return nil - } - return fmt.Errorf("unknown User field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *UserMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.roles != nil { - edges = append(edges, user.EdgeRoles) - } - if m.user_roles != nil { - edges = append(edges, user.EdgeUserRoles) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *UserMutation) AddedIDs(name string) []ent.Value { - switch name { - case user.EdgeRoles: - ids := make([]ent.Value, 0, len(m.roles)) - for id := range m.roles { - ids = append(ids, id) - } - return ids - case user.EdgeUserRoles: - ids := make([]ent.Value, 0, len(m.user_roles)) - for id := range m.user_roles { - ids = append(ids, id) - } - return ids - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *UserMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - if m.removedroles != nil { - edges = append(edges, user.EdgeRoles) - } - if m.removeduser_roles != nil { - edges = append(edges, user.EdgeUserRoles) - } - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *UserMutation) RemovedIDs(name string) []ent.Value { - switch name { - case user.EdgeRoles: - ids := make([]ent.Value, 0, len(m.removedroles)) - for id := range m.removedroles { - ids = append(ids, id) - } - return ids - case user.EdgeUserRoles: - ids := make([]ent.Value, 0, len(m.removeduser_roles)) - for id := range m.removeduser_roles { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *UserMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedroles { - edges = append(edges, user.EdgeRoles) - } - if m.cleareduser_roles { - edges = append(edges, user.EdgeUserRoles) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *UserMutation) EdgeCleared(name string) bool { - switch name { - case user.EdgeRoles: - return m.clearedroles - case user.EdgeUserRoles: - return m.cleareduser_roles - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *UserMutation) ClearEdge(name string) error { - switch name { - } - return fmt.Errorf("unknown User unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *UserMutation) ResetEdge(name string) error { - switch name { - case user.EdgeRoles: - m.ResetRoles() - return nil - case user.EdgeUserRoles: - m.ResetUserRoles() - return nil - } - return fmt.Errorf("unknown User edge %s", name) -} - -// UserRoleMutation represents an operation that mutates the UserRole nodes in the graph. -type UserRoleMutation struct { - config - op Op - typ string - id *int - clearedFields map[string]struct{} - user *int64 - cleareduser bool - role *int64 - clearedrole bool - done bool - oldValue func(context.Context) (*UserRole, error) - predicates []predicate.UserRole -} - -var _ ent.Mutation = (*UserRoleMutation)(nil) - -// userroleOption allows management of the mutation configuration using functional options. -type userroleOption func(*UserRoleMutation) - -// newUserRoleMutation creates new mutation for the UserRole entity. -func newUserRoleMutation(c config, op Op, opts ...userroleOption) *UserRoleMutation { - m := &UserRoleMutation{ - config: c, - op: op, - typ: TypeUserRole, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m -} - -// withUserRoleID sets the ID field of the mutation. -func withUserRoleID(id int) userroleOption { - return func(m *UserRoleMutation) { - var ( - err error - once sync.Once - value *UserRole - ) - m.oldValue = func(ctx context.Context) (*UserRole, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().UserRole.Get(ctx, id) - } - }) - return value, err - } - m.id = &id - } -} - -// withUserRole sets the old UserRole of the mutation. -func withUserRole(node *UserRole) userroleOption { - return func(m *UserRoleMutation) { - m.oldValue = func(context.Context) (*UserRole, error) { - return node, nil - } - m.id = &node.ID - } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m UserRoleMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m UserRoleMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") - } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *UserRoleMutation) ID() (id int, exists bool) { - if m.id == nil { - return - } - return *m.id, true -} - -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *UserRoleMutation) IDs(ctx context.Context) ([]int, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().UserRole.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } -} - -// SetUserID sets the "user_id" field. -func (m *UserRoleMutation) SetUserID(i int64) { - m.user = &i -} - -// UserID returns the value of the "user_id" field in the mutation. -func (m *UserRoleMutation) UserID() (r int64, exists bool) { - v := m.user - if v == nil { - return - } - return *v, true -} - -// OldUserID returns the old "user_id" field's value of the UserRole entity. -// If the UserRole object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserRoleMutation) OldUserID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) - } - return oldValue.UserID, nil -} - -// ResetUserID resets all changes to the "user_id" field. -func (m *UserRoleMutation) ResetUserID() { - m.user = nil -} - -// SetRoleID sets the "role_id" field. -func (m *UserRoleMutation) SetRoleID(i int64) { - m.role = &i -} - -// RoleID returns the value of the "role_id" field in the mutation. -func (m *UserRoleMutation) RoleID() (r int64, exists bool) { - v := m.role - if v == nil { - return - } - return *v, true -} - -// OldRoleID returns the old "role_id" field's value of the UserRole entity. -// If the UserRole object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserRoleMutation) OldRoleID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRoleID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRoleID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRoleID: %w", err) - } - return oldValue.RoleID, nil -} - -// ResetRoleID resets all changes to the "role_id" field. -func (m *UserRoleMutation) ResetRoleID() { - m.role = nil -} - -// ClearUser clears the "user" edge to the User entity. -func (m *UserRoleMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[userrole.FieldUserID] = struct{}{} -} - -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *UserRoleMutation) UserCleared() bool { - return m.cleareduser -} - -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *UserRoleMutation) UserIDs() (ids []int64) { - if id := m.user; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetUser resets all changes to the "user" edge. -func (m *UserRoleMutation) ResetUser() { - m.user = nil - m.cleareduser = false -} - -// ClearRole clears the "role" edge to the Role entity. -func (m *UserRoleMutation) ClearRole() { - m.clearedrole = true - m.clearedFields[userrole.FieldRoleID] = struct{}{} -} - -// RoleCleared reports if the "role" edge to the Role entity was cleared. -func (m *UserRoleMutation) RoleCleared() bool { - return m.clearedrole -} - -// RoleIDs returns the "role" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// RoleID instead. It exists only for internal usage by the builders. -func (m *UserRoleMutation) RoleIDs() (ids []int64) { - if id := m.role; id != nil { - ids = append(ids, *id) - } - return -} - -// ResetRole resets all changes to the "role" edge. -func (m *UserRoleMutation) ResetRole() { - m.role = nil - m.clearedrole = false -} - -// Where appends a list predicates to the UserRoleMutation builder. -func (m *UserRoleMutation) Where(ps ...predicate.UserRole) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the UserRoleMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *UserRoleMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.UserRole, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *UserRoleMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *UserRoleMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (UserRole). -func (m *UserRoleMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *UserRoleMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.user != nil { - fields = append(fields, userrole.FieldUserID) - } - if m.role != nil { - fields = append(fields, userrole.FieldRoleID) - } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *UserRoleMutation) Field(name string) (ent.Value, bool) { - switch name { - case userrole.FieldUserID: - return m.UserID() - case userrole.FieldRoleID: - return m.RoleID() - } - return nil, false -} - -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *UserRoleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case userrole.FieldUserID: - return m.OldUserID(ctx) - case userrole.FieldRoleID: - return m.OldRoleID(ctx) - } - return nil, fmt.Errorf("unknown UserRole field %s", name) -} - -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *UserRoleMutation) SetField(name string, value ent.Value) error { - switch name { - case userrole.FieldUserID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUserID(v) - return nil - case userrole.FieldRoleID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRoleID(v) - return nil - } - return fmt.Errorf("unknown UserRole field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *UserRoleMutation) AddedFields() []string { - var fields []string - return fields -} - -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *UserRoleMutation) AddedField(name string) (ent.Value, bool) { - switch name { - } - return nil, false -} - -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *UserRoleMutation) AddField(name string, value ent.Value) error { - switch name { - } - return fmt.Errorf("unknown UserRole numeric field %s", name) -} - -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *UserRoleMutation) ClearedFields() []string { - return nil -} - -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *UserRoleMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok -} - -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *UserRoleMutation) ClearField(name string) error { - return fmt.Errorf("unknown UserRole nullable field %s", name) -} - -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *UserRoleMutation) ResetField(name string) error { - switch name { - case userrole.FieldUserID: - m.ResetUserID() - return nil - case userrole.FieldRoleID: - m.ResetRoleID() - return nil - } - return fmt.Errorf("unknown UserRole field %s", name) -} - -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *UserRoleMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.user != nil { - edges = append(edges, userrole.EdgeUser) - } - if m.role != nil { - edges = append(edges, userrole.EdgeRole) - } - return edges -} - -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *UserRoleMutation) AddedIDs(name string) []ent.Value { - switch name { - case userrole.EdgeUser: - if id := m.user; id != nil { - return []ent.Value{*id} - } - case userrole.EdgeRole: - if id := m.role; id != nil { - return []ent.Value{*id} - } - } - return nil -} - -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *UserRoleMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - return edges -} - -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *UserRoleMutation) RemovedIDs(name string) []ent.Value { - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *UserRoleMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.cleareduser { - edges = append(edges, userrole.EdgeUser) - } - if m.clearedrole { - edges = append(edges, userrole.EdgeRole) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *UserRoleMutation) EdgeCleared(name string) bool { - switch name { - case userrole.EdgeUser: - return m.cleareduser - case userrole.EdgeRole: - return m.clearedrole - } - return false -} - -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *UserRoleMutation) ClearEdge(name string) error { - switch name { - case userrole.EdgeUser: - m.ClearUser() - return nil - case userrole.EdgeRole: - m.ClearRole() - return nil - } - return fmt.Errorf("unknown UserRole unique edge %s", name) -} - -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *UserRoleMutation) ResetEdge(name string) error { - switch name { - case userrole.EdgeUser: - m.ResetUser() - return nil - case userrole.EdgeRole: - m.ResetRole() - return nil - } - return fmt.Errorf("unknown UserRole edge %s", name) -} diff --git a/internal/features/system/data/ent/mutation_fields.go b/internal/features/system/data/ent/mutation_fields.go deleted file mode 100644 index 844bc7ca..00000000 --- a/internal/features/system/data/ent/mutation_fields.go +++ /dev/null @@ -1,605 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" -) - -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *PermissionMutation) SetFields(input *Permission, fields ...string) error { - for i := range fields { - switch fields[i] { - case permission.FieldCreateTime: - if input.CreateTime.Unix() != 0 { - m.SetCreateTime(input.CreateTime) - } - case permission.FieldUpdateTime: - if input.UpdateTime.Unix() != 0 { - m.SetUpdateTime(input.UpdateTime) - } - case permission.FieldName: - // check string with sql.NullString if it is empty - if input.Name != "" { - m.SetName(input.Name) - } - case permission.FieldKeyword: - // check string with sql.NullString if it is empty - if input.Keyword != "" { - m.SetKeyword(input.Keyword) - } - case permission.FieldDescription: - // check string with sql.NullString if it is empty - if input.Description != "" { - m.SetDescription(input.Description) - } - case permission.FieldDataScope: - // check string with sql.NullString if it is empty - if input.DataScope != "" { - m.SetDataScope(input.DataScope) - } - case permission.FieldDataRules: - if len(input.DataRules) > 0 { - m.SetDataRules(input.DataRules) - } - case permission.FieldActions: - var zero permission.Actions - // check permission.Actions with sql.NullString if it is empty - if input.Actions != zero { - m.SetActions(input.Actions) - } - case permission.FieldID: - // check int64 with sql.NullInt64 if it is zero - if input.ID != 0 { - m.SetID(input.ID) - } - default: - return fmt.Errorf("unknown Permission field %s", fields[i]) - } - } - return nil -} - -// SetFieldsWithZero sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *PermissionMutation) SetFieldsWithZero(input *Permission, fields ...string) error { - for i := range fields { - switch fields[i] { - case permission.FieldCreateTime: - m.SetCreateTime(input.CreateTime) - case permission.FieldUpdateTime: - m.SetUpdateTime(input.UpdateTime) - case permission.FieldName: - m.SetName(input.Name) - case permission.FieldKeyword: - m.SetKeyword(input.Keyword) - case permission.FieldDescription: - m.SetDescription(input.Description) - case permission.FieldDataScope: - m.SetDataScope(input.DataScope) - case permission.FieldDataRules: - m.SetDataRules(input.DataRules) - case permission.FieldActions: - m.SetActions(input.Actions) - case permission.FieldID: - m.SetID(input.ID) - default: - return fmt.Errorf("unknown Permission field %s", fields[i]) - } - } - return nil -} - -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *PermissionResourceMutation) SetFields(input *PermissionResource, fields ...string) error { - for i := range fields { - switch fields[i] { - case permissionresource.FieldPermissionID: - // check int64 with sql.NullInt64 if it is zero - if input.PermissionID != 0 { - m.SetPermissionID(input.PermissionID) - } - case permissionresource.FieldResourceID: - // check int64 with sql.NullInt64 if it is zero - if input.ResourceID != 0 { - m.SetResourceID(input.ResourceID) - } - default: - return fmt.Errorf("unknown PermissionResource field %s", fields[i]) - } - } - return nil -} - -// SetFieldsWithZero sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *PermissionResourceMutation) SetFieldsWithZero(input *PermissionResource, fields ...string) error { - for i := range fields { - switch fields[i] { - case permissionresource.FieldPermissionID: - m.SetPermissionID(input.PermissionID) - case permissionresource.FieldResourceID: - m.SetResourceID(input.ResourceID) - default: - return fmt.Errorf("unknown PermissionResource field %s", fields[i]) - } - } - return nil -} - -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *ResourceMutation) SetFields(input *Resource, fields ...string) error { - for i := range fields { - switch fields[i] { - case resource.FieldCreateTime: - if input.CreateTime.Unix() != 0 { - m.SetCreateTime(input.CreateTime) - } - case resource.FieldUpdateTime: - if input.UpdateTime.Unix() != 0 { - m.SetUpdateTime(input.UpdateTime) - } - case resource.FieldName: - // check string with sql.NullString if it is empty - if input.Name != "" { - m.SetName(input.Name) - } - case resource.FieldKeyword: - // check string with sql.NullString if it is empty - if input.Keyword != "" { - m.SetKeyword(input.Keyword) - } - case resource.FieldType: - // check string with sql.NullString if it is empty - if input.Type != "" { - m.SetType(input.Type) - } - case resource.FieldStatus: - // check int8 with sql.NullInt64 if it is zero - if input.Status != 0 { - m.SetStatus(input.Status) - } - case resource.FieldPath: - // check string with sql.NullString if it is empty - if input.Path != "" { - m.SetPath(input.Path) - } - case resource.FieldComponent: - // check string with sql.NullString if it is empty - if input.Component != "" { - m.SetComponent(input.Component) - } - case resource.FieldIcon: - // check string with sql.NullString if it is empty - if input.Icon != "" { - m.SetIcon(input.Icon) - } - case resource.FieldSequence: - // check int with sql.NullInt64 if it is zero - if input.Sequence != 0 { - m.SetSequence(input.Sequence) - } - case resource.FieldVisible: - if input.Visible { - m.SetVisible(input.Visible) - } - case resource.FieldLevel: - // check int8 with sql.NullInt64 if it is zero - if input.Level != 0 { - m.SetLevel(input.Level) - } - case resource.FieldTreePath: - // check string with sql.NullString if it is empty - if input.TreePath != "" { - m.SetTreePath(input.TreePath) - } - case resource.FieldProperties: - if len(input.Properties) > 0 { - m.SetProperties(input.Properties) - } - case resource.FieldDescription: - // check string with sql.NullString if it is empty - if input.Description != "" { - m.SetDescription(input.Description) - } - case resource.FieldParentID: - // check int64 with sql.NullInt64 if it is zero - if input.ParentID != 0 { - m.SetParentID(input.ParentID) - } - case resource.FieldID: - // check int64 with sql.NullInt64 if it is zero - if input.ID != 0 { - m.SetID(input.ID) - } - default: - return fmt.Errorf("unknown Resource field %s", fields[i]) - } - } - return nil -} - -// SetFieldsWithZero sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *ResourceMutation) SetFieldsWithZero(input *Resource, fields ...string) error { - for i := range fields { - switch fields[i] { - case resource.FieldCreateTime: - m.SetCreateTime(input.CreateTime) - case resource.FieldUpdateTime: - m.SetUpdateTime(input.UpdateTime) - case resource.FieldName: - m.SetName(input.Name) - case resource.FieldKeyword: - m.SetKeyword(input.Keyword) - case resource.FieldType: - m.SetType(input.Type) - case resource.FieldStatus: - m.SetStatus(input.Status) - case resource.FieldPath: - m.SetPath(input.Path) - case resource.FieldComponent: - m.SetComponent(input.Component) - case resource.FieldIcon: - m.SetIcon(input.Icon) - case resource.FieldSequence: - m.SetSequence(input.Sequence) - case resource.FieldVisible: - m.SetVisible(input.Visible) - case resource.FieldLevel: - m.SetLevel(input.Level) - case resource.FieldTreePath: - m.SetTreePath(input.TreePath) - case resource.FieldProperties: - m.SetProperties(input.Properties) - case resource.FieldDescription: - m.SetDescription(input.Description) - case resource.FieldParentID: - m.SetParentID(input.ParentID) - case resource.FieldID: - m.SetID(input.ID) - default: - return fmt.Errorf("unknown Resource field %s", fields[i]) - } - } - return nil -} - -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *RoleMutation) SetFields(input *Role, fields ...string) error { - for i := range fields { - switch fields[i] { - case role.FieldCreateTime: - if input.CreateTime.Unix() != 0 { - m.SetCreateTime(input.CreateTime) - } - case role.FieldUpdateTime: - if input.UpdateTime.Unix() != 0 { - m.SetUpdateTime(input.UpdateTime) - } - case role.FieldKeyword: - // check string with sql.NullString if it is empty - if input.Keyword != "" { - m.SetKeyword(input.Keyword) - } - case role.FieldName: - // check string with sql.NullString if it is empty - if input.Name != "" { - m.SetName(input.Name) - } - case role.FieldDescription: - // check string with sql.NullString if it is empty - if input.Description != "" { - m.SetDescription(input.Description) - } - case role.FieldType: - // check int8 with sql.NullInt64 if it is zero - if input.Type != 0 { - m.SetType(input.Type) - } - case role.FieldSequence: - // check int with sql.NullInt64 if it is zero - if input.Sequence != 0 { - m.SetSequence(input.Sequence) - } - case role.FieldStatus: - // check int8 with sql.NullInt64 if it is zero - if input.Status != 0 { - m.SetStatus(input.Status) - } - case role.FieldID: - // check int64 with sql.NullInt64 if it is zero - if input.ID != 0 { - m.SetID(input.ID) - } - default: - return fmt.Errorf("unknown Role field %s", fields[i]) - } - } - return nil -} - -// SetFieldsWithZero sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *RoleMutation) SetFieldsWithZero(input *Role, fields ...string) error { - for i := range fields { - switch fields[i] { - case role.FieldCreateTime: - m.SetCreateTime(input.CreateTime) - case role.FieldUpdateTime: - m.SetUpdateTime(input.UpdateTime) - case role.FieldKeyword: - m.SetKeyword(input.Keyword) - case role.FieldName: - m.SetName(input.Name) - case role.FieldDescription: - m.SetDescription(input.Description) - case role.FieldType: - m.SetType(input.Type) - case role.FieldSequence: - m.SetSequence(input.Sequence) - case role.FieldStatus: - m.SetStatus(input.Status) - case role.FieldID: - m.SetID(input.ID) - default: - return fmt.Errorf("unknown Role field %s", fields[i]) - } - } - return nil -} - -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *RolePermissionMutation) SetFields(input *RolePermission, fields ...string) error { - for i := range fields { - switch fields[i] { - case rolepermission.FieldRoleID: - // check int64 with sql.NullInt64 if it is zero - if input.RoleID != 0 { - m.SetRoleID(input.RoleID) - } - case rolepermission.FieldPermissionID: - // check int64 with sql.NullInt64 if it is zero - if input.PermissionID != 0 { - m.SetPermissionID(input.PermissionID) - } - default: - return fmt.Errorf("unknown RolePermission field %s", fields[i]) - } - } - return nil -} - -// SetFieldsWithZero sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *RolePermissionMutation) SetFieldsWithZero(input *RolePermission, fields ...string) error { - for i := range fields { - switch fields[i] { - case rolepermission.FieldRoleID: - m.SetRoleID(input.RoleID) - case rolepermission.FieldPermissionID: - m.SetPermissionID(input.PermissionID) - default: - return fmt.Errorf("unknown RolePermission field %s", fields[i]) - } - } - return nil -} - -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *UserMutation) SetFields(input *User, fields ...string) error { - for i := range fields { - switch fields[i] { - case user.FieldCreateTime: - if input.CreateTime.Unix() != 0 { - m.SetCreateTime(input.CreateTime) - } - case user.FieldUpdateTime: - if input.UpdateTime.Unix() != 0 { - m.SetUpdateTime(input.UpdateTime) - } - case user.FieldUUID: - // check string with sql.NullString if it is empty - if input.UUID != "" { - m.SetUUID(input.UUID) - } - case user.FieldAllowedIP: - // check string with sql.NullString if it is empty - if input.AllowedIP != "" { - m.SetAllowedIP(input.AllowedIP) - } - case user.FieldUsername: - // check string with sql.NullString if it is empty - if input.Username != "" { - m.SetUsername(input.Username) - } - case user.FieldNickname: - // check string with sql.NullString if it is empty - if input.Nickname != "" { - m.SetNickname(input.Nickname) - } - case user.FieldAvatar: - // check string with sql.NullString if it is empty - if input.Avatar != "" { - m.SetAvatar(input.Avatar) - } - case user.FieldName: - // check string with sql.NullString if it is empty - if input.Name != "" { - m.SetName(input.Name) - } - case user.FieldGender: - var zero user.Gender - // check user.Gender with sql.NullString if it is empty - if input.Gender != zero { - m.SetGender(input.Gender) - } - case user.FieldPassword: - // check string with sql.NullString if it is empty - if input.Password != "" { - m.SetPassword(input.Password) - } - case user.FieldPhone: - // check string with sql.NullString if it is empty - if input.Phone != "" { - m.SetPhone(input.Phone) - } - case user.FieldEmail: - // check string with sql.NullString if it is empty - if input.Email != "" { - m.SetEmail(input.Email) - } - case user.FieldDepartment: - // check string with sql.NullString if it is empty - if input.Department != "" { - m.SetDepartment(input.Department) - } - case user.FieldRemark: - // check string with sql.NullString if it is empty - if input.Remark != "" { - m.SetRemark(input.Remark) - } - case user.FieldStatus: - // check int8 with sql.NullInt64 if it is zero - if input.Status != 0 { - m.SetStatus(input.Status) - } - case user.FieldIsSystem: - if input.IsSystem { - m.SetIsSystem(input.IsSystem) - } - case user.FieldLastLoginIP: - // check string with sql.NullString if it is empty - if input.LastLoginIP != "" { - m.SetLastLoginIP(input.LastLoginIP) - } - case user.FieldLastLoginTime: - if input.LastLoginTime.Unix() != 0 { - m.SetLastLoginTime(input.LastLoginTime) - } - case user.FieldID: - // check int64 with sql.NullInt64 if it is zero - if input.ID != 0 { - m.SetID(input.ID) - } - default: - return fmt.Errorf("unknown User field %s", fields[i]) - } - } - return nil -} - -// SetFieldsWithZero sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *UserMutation) SetFieldsWithZero(input *User, fields ...string) error { - for i := range fields { - switch fields[i] { - case user.FieldCreateTime: - m.SetCreateTime(input.CreateTime) - case user.FieldUpdateTime: - m.SetUpdateTime(input.UpdateTime) - case user.FieldUUID: - m.SetUUID(input.UUID) - case user.FieldAllowedIP: - m.SetAllowedIP(input.AllowedIP) - case user.FieldUsername: - m.SetUsername(input.Username) - case user.FieldNickname: - m.SetNickname(input.Nickname) - case user.FieldAvatar: - m.SetAvatar(input.Avatar) - case user.FieldName: - m.SetName(input.Name) - case user.FieldGender: - m.SetGender(input.Gender) - case user.FieldPassword: - m.SetPassword(input.Password) - case user.FieldPhone: - m.SetPhone(input.Phone) - case user.FieldEmail: - m.SetEmail(input.Email) - case user.FieldDepartment: - m.SetDepartment(input.Department) - case user.FieldRemark: - m.SetRemark(input.Remark) - case user.FieldStatus: - m.SetStatus(input.Status) - case user.FieldIsSystem: - m.SetIsSystem(input.IsSystem) - case user.FieldLastLoginIP: - m.SetLastLoginIP(input.LastLoginIP) - case user.FieldLastLoginTime: - m.SetLastLoginTime(input.LastLoginTime) - case user.FieldID: - m.SetID(input.ID) - default: - return fmt.Errorf("unknown User field %s", fields[i]) - } - } - return nil -} - -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *UserRoleMutation) SetFields(input *UserRole, fields ...string) error { - for i := range fields { - switch fields[i] { - case userrole.FieldUserID: - // check int64 with sql.NullInt64 if it is zero - if input.UserID != 0 { - m.SetUserID(input.UserID) - } - case userrole.FieldRoleID: - // check int64 with sql.NullInt64 if it is zero - if input.RoleID != 0 { - m.SetRoleID(input.RoleID) - } - default: - return fmt.Errorf("unknown UserRole field %s", fields[i]) - } - } - return nil -} - -// SetFieldsWithZero sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *UserRoleMutation) SetFieldsWithZero(input *UserRole, fields ...string) error { - for i := range fields { - switch fields[i] { - case userrole.FieldUserID: - m.SetUserID(input.UserID) - case userrole.FieldRoleID: - m.SetRoleID(input.RoleID) - default: - return fmt.Errorf("unknown UserRole field %s", fields[i]) - } - } - return nil -} diff --git a/internal/features/system/data/ent/permission.go b/internal/features/system/data/ent/permission.go deleted file mode 100644 index e8eded72..00000000 --- a/internal/features/system/data/ent/permission.go +++ /dev/null @@ -1,263 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "encoding/json" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "strings" - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" -) - -// Permission table -type Permission struct { - config `json:"-"` - // ID of the ent. - // ID - ID int64 `json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime time.Time `json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime time.Time `json:"update_time,omitempty"` - // Name - Name string `json:"name,omitempty"` - // Keyword - Keyword string `json:"keyword,omitempty"` - // Description - Description string `json:"description,omitempty"` - // Data scope - DataScope string `json:"data_scope,omitempty"` - // Data rules - DataRules map[string]string `json:"data_rules,omitempty"` - // Actions - Actions permission.Actions `json:"actions,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the PermissionQuery when eager-loading is set. - Edges PermissionEdges `json:"edges"` - selectValues sql.SelectValues -} - -// PermissionEdges holds the relations/edges for other nodes in the graph. -type PermissionEdges struct { - // Roles holds the value of the roles edge. - Roles []*Role `json:"roles,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `json:"resources,omitempty"` - // RolePermissions holds the value of the role_permissions edge. - RolePermissions []*RolePermission `json:"role_permissions,omitempty"` - // PermissionResources holds the value of the permission_resources edge. - PermissionResources []*PermissionResource `json:"permission_resources,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [4]bool -} - -// RolesOrErr returns the Roles value or an error if the edge -// was not loaded in eager-loading. -func (e PermissionEdges) RolesOrErr() ([]*Role, error) { - if e.loadedTypes[0] { - return e.Roles, nil - } - return nil, &NotLoadedError{edge: "roles"} -} - -// ResourcesOrErr returns the Resources value or an error if the edge -// was not loaded in eager-loading. -func (e PermissionEdges) ResourcesOrErr() ([]*Resource, error) { - if e.loadedTypes[1] { - return e.Resources, nil - } - return nil, &NotLoadedError{edge: "resources"} -} - -// RolePermissionsOrErr returns the RolePermissions value or an error if the edge -// was not loaded in eager-loading. -func (e PermissionEdges) RolePermissionsOrErr() ([]*RolePermission, error) { - if e.loadedTypes[2] { - return e.RolePermissions, nil - } - return nil, &NotLoadedError{edge: "role_permissions"} -} - -// PermissionResourcesOrErr returns the PermissionResources value or an error if the edge -// was not loaded in eager-loading. -func (e PermissionEdges) PermissionResourcesOrErr() ([]*PermissionResource, error) { - if e.loadedTypes[3] { - return e.PermissionResources, nil - } - return nil, &NotLoadedError{edge: "permission_resources"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*Permission) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case permission.FieldDataRules: - values[i] = new([]byte) - case permission.FieldID: - values[i] = new(sql.NullInt64) - case permission.FieldName, permission.FieldKeyword, permission.FieldDescription, permission.FieldDataScope, permission.FieldActions: - values[i] = new(sql.NullString) - case permission.FieldCreateTime, permission.FieldUpdateTime: - values[i] = new(sql.NullTime) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the Permission fields. -func (_m *Permission) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case permission.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - _m.ID = int64(value.Int64) - case permission.FieldCreateTime: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field create_time", values[i]) - } else if value.Valid { - _m.CreateTime = value.Time - } - case permission.FieldUpdateTime: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field update_time", values[i]) - } else if value.Valid { - _m.UpdateTime = value.Time - } - case permission.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - _m.Name = value.String - } - case permission.FieldKeyword: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field keyword", values[i]) - } else if value.Valid { - _m.Keyword = value.String - } - case permission.FieldDescription: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field description", values[i]) - } else if value.Valid { - _m.Description = value.String - } - case permission.FieldDataScope: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field data_scope", values[i]) - } else if value.Valid { - _m.DataScope = value.String - } - case permission.FieldDataRules: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field data_rules", values[i]) - } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &_m.DataRules); err != nil { - return fmt.Errorf("unmarshal field data_rules: %w", err) - } - } - case permission.FieldActions: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field actions", values[i]) - } else if value.Valid { - _m.Actions = permission.Actions(value.String) - } - default: - _m.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the Permission. -// This includes values selected through modifiers, order, etc. -func (_m *Permission) Value(name string) (ent.Value, error) { - return _m.selectValues.Get(name) -} - -// QueryRoles queries the "roles" edge of the Permission entity. -func (_m *Permission) QueryRoles() *RoleQuery { - return NewPermissionClient(_m.config).QueryRoles(_m) -} - -// QueryResources queries the "resources" edge of the Permission entity. -func (_m *Permission) QueryResources() *ResourceQuery { - return NewPermissionClient(_m.config).QueryResources(_m) -} - -// QueryRolePermissions queries the "role_permissions" edge of the Permission entity. -func (_m *Permission) QueryRolePermissions() *RolePermissionQuery { - return NewPermissionClient(_m.config).QueryRolePermissions(_m) -} - -// QueryPermissionResources queries the "permission_resources" edge of the Permission entity. -func (_m *Permission) QueryPermissionResources() *PermissionResourceQuery { - return NewPermissionClient(_m.config).QueryPermissionResources(_m) -} - -// Update returns a builder for updating this Permission. -// Note that you need to call Permission.Unwrap() before calling this method if this Permission -// was returned from a transaction, and the transaction was committed or rolled back. -func (_m *Permission) Update() *PermissionUpdateOne { - return NewPermissionClient(_m.config).UpdateOne(_m) -} - -// Unwrap unwraps the Permission entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (_m *Permission) Unwrap() *Permission { - _tx, ok := _m.config.driver.(*txDriver) - if !ok { - panic("ent: Permission is not a transactional entity") - } - _m.config.driver = _tx.drv - return _m -} - -// String implements the fmt.Stringer. -func (_m *Permission) String() string { - var builder strings.Builder - builder.WriteString("Permission(") - builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - builder.WriteString("create_time=") - builder.WriteString(_m.CreateTime.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("update_time=") - builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("name=") - builder.WriteString(_m.Name) - builder.WriteString(", ") - builder.WriteString("keyword=") - builder.WriteString(_m.Keyword) - builder.WriteString(", ") - builder.WriteString("description=") - builder.WriteString(_m.Description) - builder.WriteString(", ") - builder.WriteString("data_scope=") - builder.WriteString(_m.DataScope) - builder.WriteString(", ") - builder.WriteString("data_rules=") - builder.WriteString(fmt.Sprintf("%v", _m.DataRules)) - builder.WriteString(", ") - builder.WriteString("actions=") - builder.WriteString(fmt.Sprintf("%v", _m.Actions)) - builder.WriteByte(')') - return builder.String() -} - -// Permissions is a parsable slice of Permission. -type Permissions []*Permission diff --git a/internal/features/system/data/ent/permission/permission.go b/internal/features/system/data/ent/permission/permission.go deleted file mode 100644 index 96aeb1c4..00000000 --- a/internal/features/system/data/ent/permission/permission.go +++ /dev/null @@ -1,338 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package permission - -import ( - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the permission type in the database. - Label = "permission" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldKeyword holds the string denoting the keyword field in the database. - FieldKeyword = "keyword" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldDataScope holds the string denoting the data_scope field in the database. - FieldDataScope = "data_scope" - // FieldDataRules holds the string denoting the data_rules field in the database. - FieldDataRules = "data_rules" - // FieldActions holds the string denoting the actions field in the database. - FieldActions = "actions" - // EdgeRoles holds the string denoting the roles edge name in mutations. - EdgeRoles = "roles" - // EdgeResources holds the string denoting the resources edge name in mutations. - EdgeResources = "resources" - // EdgeRolePermissions holds the string denoting the role_permissions edge name in mutations. - EdgeRolePermissions = "role_permissions" - // EdgePermissionResources holds the string denoting the permission_resources edge name in mutations. - EdgePermissionResources = "permission_resources" - // Table holds the table name of the permission in the database. - Table = "sys_permissions" - // RolesTable is the table that holds the roles relation/edge. The primary key declared below. - RolesTable = "sys_role_permissions" - // RolesInverseTable is the table name for the Role entity. - // It exists in this package in order to avoid circular dependency with the "role" package. - RolesInverseTable = "sys_roles" - // ResourcesTable is the table that holds the resources relation/edge. The primary key declared below. - ResourcesTable = "sys_permission_resources" - // ResourcesInverseTable is the table name for the Resource entity. - // It exists in this package in order to avoid circular dependency with the "resource" package. - ResourcesInverseTable = "sys_resources" - // RolePermissionsTable is the table that holds the role_permissions relation/edge. - RolePermissionsTable = "sys_role_permissions" - // RolePermissionsInverseTable is the table name for the RolePermission entity. - // It exists in this package in order to avoid circular dependency with the "rolepermission" package. - RolePermissionsInverseTable = "sys_role_permissions" - // RolePermissionsColumn is the table column denoting the role_permissions relation/edge. - RolePermissionsColumn = "permission_id" - // PermissionResourcesTable is the table that holds the permission_resources relation/edge. - PermissionResourcesTable = "sys_permission_resources" - // PermissionResourcesInverseTable is the table name for the PermissionResource entity. - // It exists in this package in order to avoid circular dependency with the "permissionresource" package. - PermissionResourcesInverseTable = "sys_permission_resources" - // PermissionResourcesColumn is the table column denoting the permission_resources relation/edge. - PermissionResourcesColumn = "permission_id" -) - -// Columns holds all SQL columns for permission fields. -var Columns = []string{ - FieldID, - FieldCreateTime, - FieldUpdateTime, - FieldName, - FieldKeyword, - FieldDescription, - FieldDataScope, - FieldDataRules, - FieldActions, -} - -var ( - // RolesPrimaryKey and RolesColumn2 are the table columns denoting the - // primary key for the roles relation (M2M). - RolesPrimaryKey = []string{"role_id", "permission_id"} - // ResourcesPrimaryKey and ResourcesColumn2 are the table columns denoting the - // primary key for the resources relation (M2M). - ResourcesPrimaryKey = []string{"permission_id", "resource_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() time.Time - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() time.Time - // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. - UpdateDefaultUpdateTime func() time.Time - // DefaultName holds the default value on creation for the "name" field. - DefaultName string - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - KeywordValidator func(string) error - // DefaultDescription holds the default value on creation for the "description" field. - DefaultDescription string - // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - DescriptionValidator func(string) error - // DefaultDataScope holds the default value on creation for the "data_scope" field. - DefaultDataScope string -) - -// Actions defines the type for the "actions" enum field. -type Actions string - -// ActionsRead is the default value of the Actions enum. -const DefaultActions = ActionsRead - -// Actions values. -const ( - ActionsRead Actions = "read" - ActionsWrite Actions = "write" - ActionsDelete Actions = "delete" - ActionsManage Actions = "manage" -) - -func (a Actions) String() string { - return string(a) -} - -// ActionsValidator is a validator for the "actions" field enum values. It is called by the builders before save. -func ActionsValidator(a Actions) error { - switch a { - case ActionsRead, ActionsWrite, ActionsDelete, ActionsManage: - return nil - default: - return fmt.Errorf("permission: invalid enum value for actions field: %q", a) - } -} - -// OrderOption defines the ordering options for the Permission queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByKeyword orders the results by the keyword field. -func ByKeyword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldKeyword, opts...).ToFunc() -} - -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() -} - -// ByDataScope orders the results by the data_scope field. -func ByDataScope(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDataScope, opts...).ToFunc() -} - -// ByActions orders the results by the actions field. -func ByActions(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldActions, opts...).ToFunc() -} - -// ByRolesCount orders the results by roles count. -func ByRolesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...) - } -} - -// ByRoles orders the results by roles terms. -func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByResourcesCount orders the results by resources count. -func ByResourcesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newResourcesStep(), opts...) - } -} - -// ByResources orders the results by resources terms. -func ByResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByRolePermissionsCount orders the results by role_permissions count. -func ByRolePermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newRolePermissionsStep(), opts...) - } -} - -// ByRolePermissions orders the results by role_permissions terms. -func ByRolePermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRolePermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPermissionResourcesCount orders the results by permission_resources count. -func ByPermissionResourcesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPermissionResourcesStep(), opts...) - } -} - -// ByPermissionResources orders the results by permission_resources terms. -func ByPermissionResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newRolesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RolesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, RolesTable, RolesPrimaryKey...), - ) -} -func newResourcesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(ResourcesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), - ) -} -func newRolePermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RolePermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), - ) -} -func newPermissionResourcesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionResourcesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/features/system/data/ent/permission/where.go b/internal/features/system/data/ent/permission/where.go deleted file mode 100644 index 5c375213..00000000 --- a/internal/features/system/data/ent/permission/where.go +++ /dev/null @@ -1,563 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package permission - -import ( - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldID, id)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldUpdateTime, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldName, v)) -} - -// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. -func Keyword(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldKeyword, v)) -} - -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldDescription, v)) -} - -// DataScope applies equality check predicate on the "data_scope" field. It's identical to DataScopeEQ. -func DataScope(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldDataScope, v)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...time.Time) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...time.Time) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldCreateTime, v)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...time.Time) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...time.Time) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v time.Time) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldUpdateTime, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Permission { - return predicate.Permission(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldContainsFold(FieldName, v)) -} - -// KeywordEQ applies the EQ predicate on the "keyword" field. -func KeywordEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldKeyword, v)) -} - -// KeywordNEQ applies the NEQ predicate on the "keyword" field. -func KeywordNEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldKeyword, v)) -} - -// KeywordIn applies the In predicate on the "keyword" field. -func KeywordIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldKeyword, vs...)) -} - -// KeywordNotIn applies the NotIn predicate on the "keyword" field. -func KeywordNotIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldKeyword, vs...)) -} - -// KeywordGT applies the GT predicate on the "keyword" field. -func KeywordGT(v string) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldKeyword, v)) -} - -// KeywordGTE applies the GTE predicate on the "keyword" field. -func KeywordGTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldKeyword, v)) -} - -// KeywordLT applies the LT predicate on the "keyword" field. -func KeywordLT(v string) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldKeyword, v)) -} - -// KeywordLTE applies the LTE predicate on the "keyword" field. -func KeywordLTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldKeyword, v)) -} - -// KeywordContains applies the Contains predicate on the "keyword" field. -func KeywordContains(v string) predicate.Permission { - return predicate.Permission(sql.FieldContains(FieldKeyword, v)) -} - -// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. -func KeywordHasPrefix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasPrefix(FieldKeyword, v)) -} - -// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. -func KeywordHasSuffix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasSuffix(FieldKeyword, v)) -} - -// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. -func KeywordEqualFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldEqualFold(FieldKeyword, v)) -} - -// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. -func KeywordContainsFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldContainsFold(FieldKeyword, v)) -} - -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldDescription, v)) -} - -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldDescription, v)) -} - -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldDescription, vs...)) -} - -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldDescription, vs...)) -} - -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldDescription, v)) -} - -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldDescription, v)) -} - -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldDescription, v)) -} - -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldDescription, v)) -} - -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.Permission { - return predicate.Permission(sql.FieldContains(FieldDescription, v)) -} - -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasPrefix(FieldDescription, v)) -} - -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasSuffix(FieldDescription, v)) -} - -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldEqualFold(FieldDescription, v)) -} - -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldContainsFold(FieldDescription, v)) -} - -// DataScopeEQ applies the EQ predicate on the "data_scope" field. -func DataScopeEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldDataScope, v)) -} - -// DataScopeNEQ applies the NEQ predicate on the "data_scope" field. -func DataScopeNEQ(v string) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldDataScope, v)) -} - -// DataScopeIn applies the In predicate on the "data_scope" field. -func DataScopeIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldDataScope, vs...)) -} - -// DataScopeNotIn applies the NotIn predicate on the "data_scope" field. -func DataScopeNotIn(vs ...string) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldDataScope, vs...)) -} - -// DataScopeGT applies the GT predicate on the "data_scope" field. -func DataScopeGT(v string) predicate.Permission { - return predicate.Permission(sql.FieldGT(FieldDataScope, v)) -} - -// DataScopeGTE applies the GTE predicate on the "data_scope" field. -func DataScopeGTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldGTE(FieldDataScope, v)) -} - -// DataScopeLT applies the LT predicate on the "data_scope" field. -func DataScopeLT(v string) predicate.Permission { - return predicate.Permission(sql.FieldLT(FieldDataScope, v)) -} - -// DataScopeLTE applies the LTE predicate on the "data_scope" field. -func DataScopeLTE(v string) predicate.Permission { - return predicate.Permission(sql.FieldLTE(FieldDataScope, v)) -} - -// DataScopeContains applies the Contains predicate on the "data_scope" field. -func DataScopeContains(v string) predicate.Permission { - return predicate.Permission(sql.FieldContains(FieldDataScope, v)) -} - -// DataScopeHasPrefix applies the HasPrefix predicate on the "data_scope" field. -func DataScopeHasPrefix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasPrefix(FieldDataScope, v)) -} - -// DataScopeHasSuffix applies the HasSuffix predicate on the "data_scope" field. -func DataScopeHasSuffix(v string) predicate.Permission { - return predicate.Permission(sql.FieldHasSuffix(FieldDataScope, v)) -} - -// DataScopeEqualFold applies the EqualFold predicate on the "data_scope" field. -func DataScopeEqualFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldEqualFold(FieldDataScope, v)) -} - -// DataScopeContainsFold applies the ContainsFold predicate on the "data_scope" field. -func DataScopeContainsFold(v string) predicate.Permission { - return predicate.Permission(sql.FieldContainsFold(FieldDataScope, v)) -} - -// DataRulesIsNil applies the IsNil predicate on the "data_rules" field. -func DataRulesIsNil() predicate.Permission { - return predicate.Permission(sql.FieldIsNull(FieldDataRules)) -} - -// DataRulesNotNil applies the NotNil predicate on the "data_rules" field. -func DataRulesNotNil() predicate.Permission { - return predicate.Permission(sql.FieldNotNull(FieldDataRules)) -} - -// ActionsEQ applies the EQ predicate on the "actions" field. -func ActionsEQ(v Actions) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldActions, v)) -} - -// ActionsNEQ applies the NEQ predicate on the "actions" field. -func ActionsNEQ(v Actions) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldActions, v)) -} - -// ActionsIn applies the In predicate on the "actions" field. -func ActionsIn(vs ...Actions) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldActions, vs...)) -} - -// ActionsNotIn applies the NotIn predicate on the "actions" field. -func ActionsNotIn(vs ...Actions) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldActions, vs...)) -} - -// HasRoles applies the HasEdge predicate on the "roles" edge. -func HasRoles() predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, RolesTable, RolesPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRolesWith applies the HasEdge predicate on the "roles" edge with a given conditions (other predicates). -func HasRolesWith(preds ...predicate.Role) predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := newRolesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasResources applies the HasEdge predicate on the "resources" edge. -func HasResources() predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasResourcesWith applies the HasEdge predicate on the "resources" edge with a given conditions (other predicates). -func HasResourcesWith(preds ...predicate.Resource) predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := newResourcesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasRolePermissions applies the HasEdge predicate on the "role_permissions" edge. -func HasRolePermissions() predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRolePermissionsWith applies the HasEdge predicate on the "role_permissions" edge with a given conditions (other predicates). -func HasRolePermissionsWith(preds ...predicate.RolePermission) predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := newRolePermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermissionResources applies the HasEdge predicate on the "permission_resources" edge. -func HasPermissionResources() predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionResourcesWith applies the HasEdge predicate on the "permission_resources" edge with a given conditions (other predicates). -func HasPermissionResourcesWith(preds ...predicate.PermissionResource) predicate.Permission { - return predicate.Permission(func(s *sql.Selector) { - step := newPermissionResourcesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Permission) predicate.Permission { - return predicate.Permission(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Permission) predicate.Permission { - return predicate.Permission(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Permission) predicate.Permission { - return predicate.Permission(sql.NotPredicates(p)) -} diff --git a/internal/features/system/data/ent/permission_create.go b/internal/features/system/data/ent/permission_create.go deleted file mode 100644 index 0cea43c2..00000000 --- a/internal/features/system/data/ent/permission_create.go +++ /dev/null @@ -1,530 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// PermissionCreate is the builder for creating a Permission entity. -type PermissionCreate struct { - config - mutation *PermissionMutation - hooks []Hook -} - -// SetCreateTime sets the "create_time" field. -func (_c *PermissionCreate) SetCreateTime(v time.Time) *PermissionCreate { - _c.mutation.SetCreateTime(v) - return _c -} - -// SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (_c *PermissionCreate) SetNillableCreateTime(v *time.Time) *PermissionCreate { - if v != nil { - _c.SetCreateTime(*v) - } - return _c -} - -// SetUpdateTime sets the "update_time" field. -func (_c *PermissionCreate) SetUpdateTime(v time.Time) *PermissionCreate { - _c.mutation.SetUpdateTime(v) - return _c -} - -// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (_c *PermissionCreate) SetNillableUpdateTime(v *time.Time) *PermissionCreate { - if v != nil { - _c.SetUpdateTime(*v) - } - return _c -} - -// SetName sets the "name" field. -func (_c *PermissionCreate) SetName(v string) *PermissionCreate { - _c.mutation.SetName(v) - return _c -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_c *PermissionCreate) SetNillableName(v *string) *PermissionCreate { - if v != nil { - _c.SetName(*v) - } - return _c -} - -// SetKeyword sets the "keyword" field. -func (_c *PermissionCreate) SetKeyword(v string) *PermissionCreate { - _c.mutation.SetKeyword(v) - return _c -} - -// SetDescription sets the "description" field. -func (_c *PermissionCreate) SetDescription(v string) *PermissionCreate { - _c.mutation.SetDescription(v) - return _c -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_c *PermissionCreate) SetNillableDescription(v *string) *PermissionCreate { - if v != nil { - _c.SetDescription(*v) - } - return _c -} - -// SetDataScope sets the "data_scope" field. -func (_c *PermissionCreate) SetDataScope(v string) *PermissionCreate { - _c.mutation.SetDataScope(v) - return _c -} - -// SetNillableDataScope sets the "data_scope" field if the given value is not nil. -func (_c *PermissionCreate) SetNillableDataScope(v *string) *PermissionCreate { - if v != nil { - _c.SetDataScope(*v) - } - return _c -} - -// SetDataRules sets the "data_rules" field. -func (_c *PermissionCreate) SetDataRules(v map[string]string) *PermissionCreate { - _c.mutation.SetDataRules(v) - return _c -} - -// SetActions sets the "actions" field. -func (_c *PermissionCreate) SetActions(v permission.Actions) *PermissionCreate { - _c.mutation.SetActions(v) - return _c -} - -// SetNillableActions sets the "actions" field if the given value is not nil. -func (_c *PermissionCreate) SetNillableActions(v *permission.Actions) *PermissionCreate { - if v != nil { - _c.SetActions(*v) - } - return _c -} - -// SetID sets the "id" field. -func (_c *PermissionCreate) SetID(v int64) *PermissionCreate { - _c.mutation.SetID(v) - return _c -} - -// AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (_c *PermissionCreate) AddRoleIDs(ids ...int64) *PermissionCreate { - _c.mutation.AddRoleIDs(ids...) - return _c -} - -// AddRoles adds the "roles" edges to the Role entity. -func (_c *PermissionCreate) AddRoles(v ...*Role) *PermissionCreate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddRoleIDs(ids...) -} - -// AddResourceIDs adds the "resources" edge to the Resource entity by IDs. -func (_c *PermissionCreate) AddResourceIDs(ids ...int64) *PermissionCreate { - _c.mutation.AddResourceIDs(ids...) - return _c -} - -// AddResources adds the "resources" edges to the Resource entity. -func (_c *PermissionCreate) AddResources(v ...*Resource) *PermissionCreate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddResourceIDs(ids...) -} - -// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (_c *PermissionCreate) AddRolePermissionIDs(ids ...int) *PermissionCreate { - _c.mutation.AddRolePermissionIDs(ids...) - return _c -} - -// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (_c *PermissionCreate) AddRolePermissions(v ...*RolePermission) *PermissionCreate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddRolePermissionIDs(ids...) -} - -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (_c *PermissionCreate) AddPermissionResourceIDs(ids ...int) *PermissionCreate { - _c.mutation.AddPermissionResourceIDs(ids...) - return _c -} - -// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (_c *PermissionCreate) AddPermissionResources(v ...*PermissionResource) *PermissionCreate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddPermissionResourceIDs(ids...) -} - -// Mutation returns the PermissionMutation object of the builder. -func (_c *PermissionCreate) Mutation() *PermissionMutation { - return _c.mutation -} - -// Save creates the Permission in the database. -func (_c *PermissionCreate) Save(ctx context.Context) (*Permission, error) { - _c.defaults() - return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (_c *PermissionCreate) SaveX(ctx context.Context) *Permission { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *PermissionCreate) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *PermissionCreate) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_c *PermissionCreate) defaults() { - if _, ok := _c.mutation.CreateTime(); !ok { - v := permission.DefaultCreateTime() - _c.mutation.SetCreateTime(v) - } - if _, ok := _c.mutation.UpdateTime(); !ok { - v := permission.DefaultUpdateTime() - _c.mutation.SetUpdateTime(v) - } - if _, ok := _c.mutation.Name(); !ok { - v := permission.DefaultName - _c.mutation.SetName(v) - } - if _, ok := _c.mutation.Description(); !ok { - v := permission.DefaultDescription - _c.mutation.SetDescription(v) - } - if _, ok := _c.mutation.DataScope(); !ok { - v := permission.DefaultDataScope - _c.mutation.SetDataScope(v) - } - if _, ok := _c.mutation.Actions(); !ok { - v := permission.DefaultActions - _c.mutation.SetActions(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_c *PermissionCreate) check() error { - if _, ok := _c.mutation.CreateTime(); !ok { - return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Permission.create_time"`)} - } - if _, ok := _c.mutation.UpdateTime(); !ok { - return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Permission.update_time"`)} - } - if _, ok := _c.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Permission.name"`)} - } - if v, ok := _c.mutation.Name(); ok { - if err := permission.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Permission.name": %w`, err)} - } - } - if _, ok := _c.mutation.Keyword(); !ok { - return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Permission.keyword"`)} - } - if v, ok := _c.mutation.Keyword(); ok { - if err := permission.KeywordValidator(v); err != nil { - return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Permission.keyword": %w`, err)} - } - } - if _, ok := _c.mutation.Description(); !ok { - return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Permission.description"`)} - } - if v, ok := _c.mutation.Description(); ok { - if err := permission.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} - } - } - if _, ok := _c.mutation.DataScope(); !ok { - return &ValidationError{Name: "data_scope", err: errors.New(`ent: missing required field "Permission.data_scope"`)} - } - if _, ok := _c.mutation.Actions(); !ok { - return &ValidationError{Name: "actions", err: errors.New(`ent: missing required field "Permission.actions"`)} - } - if v, ok := _c.mutation.Actions(); ok { - if err := permission.ActionsValidator(v); err != nil { - return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} - } - } - return nil -} - -func (_c *PermissionCreate) sqlSave(ctx context.Context) (*Permission, error) { - if err := _c.check(); err != nil { - return nil, err - } - _node, _spec := _c.createSpec() - if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != _node.ID { - id := _spec.ID.Value.(int64) - _node.ID = int64(id) - } - _c.mutation.id = &_node.ID - _c.mutation.done = true - return _node, nil -} - -func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { - var ( - _node = &Permission{config: _c.config} - _spec = sqlgraph.NewCreateSpec(permission.Table, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) - ) - if id, ok := _c.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = id - } - if value, ok := _c.mutation.CreateTime(); ok { - _spec.SetField(permission.FieldCreateTime, field.TypeTime, value) - _node.CreateTime = value - } - if value, ok := _c.mutation.UpdateTime(); ok { - _spec.SetField(permission.FieldUpdateTime, field.TypeTime, value) - _node.UpdateTime = value - } - if value, ok := _c.mutation.Name(); ok { - _spec.SetField(permission.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := _c.mutation.Keyword(); ok { - _spec.SetField(permission.FieldKeyword, field.TypeString, value) - _node.Keyword = value - } - if value, ok := _c.mutation.Description(); ok { - _spec.SetField(permission.FieldDescription, field.TypeString, value) - _node.Description = value - } - if value, ok := _c.mutation.DataScope(); ok { - _spec.SetField(permission.FieldDataScope, field.TypeString, value) - _node.DataScope = value - } - if value, ok := _c.mutation.DataRules(); ok { - _spec.SetField(permission.FieldDataRules, field.TypeJSON, value) - _node.DataRules = value - } - if value, ok := _c.mutation.Actions(); ok { - _spec.SetField(permission.FieldActions, field.TypeEnum, value) - _node.Actions = value - } - if nodes := _c.mutation.RolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: permission.RolesTable, - Columns: permission.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.ResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: permission.ResourcesTable, - Columns: permission.ResourcesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.RolePermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.RolePermissionsTable, - Columns: []string{permission.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.PermissionResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.PermissionResourcesTable, - Columns: []string{permission.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// SetPermission set the Permission -func (_c *PermissionCreate) SetPermission(input *Permission, fields ...string) *PermissionCreate { - m := _c.mutation - if len(fields) == 0 { - fields = permission.Columns - } - _ = m.SetFields(input, fields...) - return _c -} - -// SetPermissionWithZero set the Permission -func (_c *PermissionCreate) SetPermissionWithZero(input *Permission, fields ...string) *PermissionCreate { - m := _c.mutation - if len(fields) == 0 { - fields = permission.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return _c -} - -// PermissionCreateBulk is the builder for creating many Permission entities in bulk. -type PermissionCreateBulk struct { - config - err error - builders []*PermissionCreate -} - -// Save creates the Permission entities in the database. -func (_c *PermissionCreateBulk) Save(ctx context.Context) ([]*Permission, error) { - if _c.err != nil { - return nil, _c.err - } - specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*Permission, len(_c.builders)) - mutators := make([]Mutator, len(_c.builders)) - for i := range _c.builders { - func(i int, root context.Context) { - builder := _c.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PermissionMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil && nodes[i].ID == 0 { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int64(id) - } - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (_c *PermissionCreateBulk) SaveX(ctx context.Context) []*Permission { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *PermissionCreateBulk) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *PermissionCreateBulk) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/permission_delete.go b/internal/features/system/data/ent/permission_delete.go deleted file mode 100644 index 66512462..00000000 --- a/internal/features/system/data/ent/permission_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// PermissionDelete is the builder for deleting a Permission entity. -type PermissionDelete struct { - config - hooks []Hook - mutation *PermissionMutation -} - -// Where appends a list predicates to the PermissionDelete builder. -func (_d *PermissionDelete) Where(ps ...predicate.Permission) *PermissionDelete { - _d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (_d *PermissionDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *PermissionDelete) ExecX(ctx context.Context) int { - n, err := _d.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (_d *PermissionDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(permission.Table, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) - if ps := _d.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - _d.mutation.done = true - return affected, err -} - -// PermissionDeleteOne is the builder for deleting a single Permission entity. -type PermissionDeleteOne struct { - _d *PermissionDelete -} - -// Where appends a list predicates to the PermissionDelete builder. -func (_d *PermissionDeleteOne) Where(ps ...predicate.Permission) *PermissionDeleteOne { - _d._d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query. -func (_d *PermissionDeleteOne) Exec(ctx context.Context) error { - n, err := _d._d.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{permission.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *PermissionDeleteOne) ExecX(ctx context.Context) { - if err := _d.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/permission_query.go b/internal/features/system/data/ent/permission_query.go deleted file mode 100644 index 3d199e09..00000000 --- a/internal/features/system/data/ent/permission_query.go +++ /dev/null @@ -1,986 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// PermissionQuery is the builder for querying Permission entities. -type PermissionQuery struct { - config - ctx *QueryContext - order []permission.OrderOption - inters []Interceptor - predicates []predicate.Permission - withRoles *RoleQuery - withResources *ResourceQuery - withRolePermissions *RolePermissionQuery - withPermissionResources *PermissionResourceQuery - modifiers []func(*sql.Selector) - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the PermissionQuery builder. -func (_q *PermissionQuery) Where(ps ...predicate.Permission) *PermissionQuery { - _q.predicates = append(_q.predicates, ps...) - return _q -} - -// Limit the number of records to be returned by this query. -func (_q *PermissionQuery) Limit(limit int) *PermissionQuery { - _q.ctx.Limit = &limit - return _q -} - -// Offset to start from. -func (_q *PermissionQuery) Offset(offset int) *PermissionQuery { - _q.ctx.Offset = &offset - return _q -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (_q *PermissionQuery) Unique(unique bool) *PermissionQuery { - _q.ctx.Unique = &unique - return _q -} - -// Order specifies how the records should be ordered. -func (_q *PermissionQuery) Order(o ...permission.OrderOption) *PermissionQuery { - _q.order = append(_q.order, o...) - return _q -} - -// QueryRoles chains the current query on the "roles" edge. -func (_q *PermissionQuery) QueryRoles() *RoleQuery { - query := (&RoleClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(permission.Table, permission.FieldID, selector), - sqlgraph.To(role.Table, role.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, permission.RolesTable, permission.RolesPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryResources chains the current query on the "resources" edge. -func (_q *PermissionQuery) QueryResources() *ResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(permission.Table, permission.FieldID, selector), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, permission.ResourcesTable, permission.ResourcesPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryRolePermissions chains the current query on the "role_permissions" edge. -func (_q *PermissionQuery) QueryRolePermissions() *RolePermissionQuery { - query := (&RolePermissionClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(permission.Table, permission.FieldID, selector), - sqlgraph.To(rolepermission.Table, rolepermission.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, permission.RolePermissionsTable, permission.RolePermissionsColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryPermissionResources chains the current query on the "permission_resources" edge. -func (_q *PermissionQuery) QueryPermissionResources() *PermissionResourceQuery { - query := (&PermissionResourceClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(permission.Table, permission.FieldID, selector), - sqlgraph.To(permissionresource.Table, permissionresource.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, permission.PermissionResourcesTable, permission.PermissionResourcesColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Permission entity from the query. -// Returns a *NotFoundError when no Permission was found. -func (_q *PermissionQuery) First(ctx context.Context) (*Permission, error) { - nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{permission.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (_q *PermissionQuery) FirstX(ctx context.Context) *Permission { - node, err := _q.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first Permission ID from the query. -// Returns a *NotFoundError when no Permission ID was found. -func (_q *PermissionQuery) FirstID(ctx context.Context) (id int64, err error) { - var ids []int64 - if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{permission.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (_q *PermissionQuery) FirstIDX(ctx context.Context) int64 { - id, err := _q.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single Permission entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one Permission entity is found. -// Returns a *NotFoundError when no Permission entities are found. -func (_q *PermissionQuery) Only(ctx context.Context) (*Permission, error) { - nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{permission.Label} - default: - return nil, &NotSingularError{permission.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (_q *PermissionQuery) OnlyX(ctx context.Context) *Permission { - node, err := _q.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only Permission ID in the query. -// Returns a *NotSingularError when more than one Permission ID is found. -// Returns a *NotFoundError when no entities are found. -func (_q *PermissionQuery) OnlyID(ctx context.Context) (id int64, err error) { - var ids []int64 - if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{permission.Label} - default: - err = &NotSingularError{permission.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *PermissionQuery) OnlyIDX(ctx context.Context) int64 { - id, err := _q.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Permissions. -func (_q *PermissionQuery) All(ctx context.Context) ([]*Permission, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*Permission, *PermissionQuery]() - return withInterceptors[[]*Permission](ctx, _q, qr, _q.inters) -} - -// AllX is like All, but panics if an error occurs. -func (_q *PermissionQuery) AllX(ctx context.Context) []*Permission { - nodes, err := _q.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of Permission IDs. -func (_q *PermissionQuery) IDs(ctx context.Context) (ids []int64, err error) { - if _q.ctx.Unique == nil && _q.path != nil { - _q.Unique(true) - } - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(permission.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (_q *PermissionQuery) IDsX(ctx context.Context) []int64 { - ids, err := _q.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (_q *PermissionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) - if err := _q.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, _q, querierCount[*PermissionQuery](), _q.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (_q *PermissionQuery) CountX(ctx context.Context) int { - count, err := _q.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (_q *PermissionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) - switch _, err := _q.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - -// ExistX is like Exist, but panics if an error occurs. -func (_q *PermissionQuery) ExistX(ctx context.Context) bool { - exist, err := _q.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the PermissionQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (_q *PermissionQuery) Clone() *PermissionQuery { - if _q == nil { - return nil - } - return &PermissionQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]permission.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.Permission{}, _q.predicates...), - withRoles: _q.withRoles.Clone(), - withResources: _q.withResources.Clone(), - withRolePermissions: _q.withRolePermissions.Clone(), - withPermissionResources: _q.withPermissionResources.Clone(), - // clone intermediate query. - sql: _q.sql.Clone(), - path: _q.path, - modifiers: append([]func(*sql.Selector){}, _q.modifiers...), - } -} - -// WithRoles tells the query-builder to eager-load the nodes that are connected to -// the "roles" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *PermissionQuery) WithRoles(opts ...func(*RoleQuery)) *PermissionQuery { - query := (&RoleClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withRoles = query - return _q -} - -// WithResources tells the query-builder to eager-load the nodes that are connected to -// the "resources" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *PermissionQuery) WithResources(opts ...func(*ResourceQuery)) *PermissionQuery { - query := (&ResourceClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withResources = query - return _q -} - -// WithRolePermissions tells the query-builder to eager-load the nodes that are connected to -// the "role_permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *PermissionQuery) WithRolePermissions(opts ...func(*RolePermissionQuery)) *PermissionQuery { - query := (&RolePermissionClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withRolePermissions = query - return _q -} - -// WithPermissionResources tells the query-builder to eager-load the nodes that are connected to -// the "permission_resources" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *PermissionQuery) WithPermissionResources(opts ...func(*PermissionResourceQuery)) *PermissionQuery { - query := (&PermissionResourceClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withPermissionResources = query - return _q -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.Permission.Query(). -// GroupBy(permission.FieldCreateTime). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (_q *PermissionQuery) GroupBy(field string, fields ...string) *PermissionGroupBy { - _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &PermissionGroupBy{build: _q} - grbuild.flds = &_q.ctx.Fields - grbuild.label = permission.Label - grbuild.scan = grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// } -// -// client.Permission.Query(). -// Select(permission.FieldCreateTime). -// Scan(ctx, &v) -func (_q *PermissionQuery) Select(fields ...string) *PermissionSelect { - _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &PermissionSelect{PermissionQuery: _q} - sbuild.label = permission.Label - sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a PermissionSelect configured with the given aggregations. -func (_q *PermissionQuery) Aggregate(fns ...AggregateFunc) *PermissionSelect { - return _q.Select().Aggregate(fns...) -} - -func (_q *PermissionQuery) prepareQuery(ctx context.Context) error { - for _, inter := range _q.inters { - if inter == nil { - return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") - } - if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, _q); err != nil { - return err - } - } - } - for _, f := range _q.ctx.Fields { - if !permission.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if _q.path != nil { - prev, err := _q.path(ctx) - if err != nil { - return err - } - _q.sql = prev - } - return nil -} - -func (_q *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Permission, error) { - var ( - nodes = []*Permission{} - _spec = _q.querySpec() - loadedTypes = [4]bool{ - _q.withRoles != nil, - _q.withResources != nil, - _q.withRolePermissions != nil, - _q.withPermissionResources != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*Permission).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &Permission{config: _q.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := _q.withRoles; query != nil { - if err := _q.loadRoles(ctx, query, nodes, - func(n *Permission) { n.Edges.Roles = []*Role{} }, - func(n *Permission, e *Role) { n.Edges.Roles = append(n.Edges.Roles, e) }); err != nil { - return nil, err - } - } - if query := _q.withResources; query != nil { - if err := _q.loadResources(ctx, query, nodes, - func(n *Permission) { n.Edges.Resources = []*Resource{} }, - func(n *Permission, e *Resource) { n.Edges.Resources = append(n.Edges.Resources, e) }); err != nil { - return nil, err - } - } - if query := _q.withRolePermissions; query != nil { - if err := _q.loadRolePermissions(ctx, query, nodes, - func(n *Permission) { n.Edges.RolePermissions = []*RolePermission{} }, - func(n *Permission, e *RolePermission) { n.Edges.RolePermissions = append(n.Edges.RolePermissions, e) }); err != nil { - return nil, err - } - } - if query := _q.withPermissionResources; query != nil { - if err := _q.loadPermissionResources(ctx, query, nodes, - func(n *Permission) { n.Edges.PermissionResources = []*PermissionResource{} }, - func(n *Permission, e *PermissionResource) { - n.Edges.PermissionResources = append(n.Edges.PermissionResources, e) - }); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (_q *PermissionQuery) loadRoles(ctx context.Context, query *RoleQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *Role)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int64]*Permission) - nids := make(map[int64]map[*Permission]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(permission.RolesTable) - s.Join(joinT).On(s.C(role.FieldID), joinT.C(permission.RolesPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(permission.RolesPrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(permission.RolesPrimaryKey[1])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(sql.NullInt64)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := values[0].(*sql.NullInt64).Int64 - inValue := values[1].(*sql.NullInt64).Int64 - if nids[inValue] == nil { - nids[inValue] = map[*Permission]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Role](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "roles" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (_q *PermissionQuery) loadResources(ctx context.Context, query *ResourceQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *Resource)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int64]*Permission) - nids := make(map[int64]map[*Permission]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(permission.ResourcesTable) - s.Join(joinT).On(s.C(resource.FieldID), joinT.C(permission.ResourcesPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(permission.ResourcesPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(permission.ResourcesPrimaryKey[0])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(sql.NullInt64)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := values[0].(*sql.NullInt64).Int64 - inValue := values[1].(*sql.NullInt64).Int64 - if nids[inValue] == nil { - nids[inValue] = map[*Permission]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Resource](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "resources" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (_q *PermissionQuery) loadRolePermissions(ctx context.Context, query *RolePermissionQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *RolePermission)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int64]*Permission) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(rolepermission.FieldPermissionID) - } - query.Where(predicate.RolePermission(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(permission.RolePermissionsColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.PermissionID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "permission_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} -func (_q *PermissionQuery) loadPermissionResources(ctx context.Context, query *PermissionResourceQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *PermissionResource)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int64]*Permission) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(permissionresource.FieldPermissionID) - } - query.Where(predicate.PermissionResource(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(permission.PermissionResourcesColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.PermissionID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "permission_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} - -func (_q *PermissionQuery) sqlCount(ctx context.Context) (int, error) { - _spec := _q.querySpec() - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - _spec.Node.Columns = _q.ctx.Fields - if len(_q.ctx.Fields) > 0 { - _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique - } - return sqlgraph.CountNodes(ctx, _q.driver, _spec) -} - -func (_q *PermissionQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(permission.Table, permission.Columns, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) - _spec.From = _q.sql - if unique := _q.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if _q.path != nil { - _spec.Unique = true - } - if fields := _q.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, permission.FieldID) - for i := range fields { - if fields[i] != permission.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := _q.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := _q.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := _q.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := _q.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (_q *PermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(permission.Table) - columns := _q.ctx.Fields - if len(columns) == 0 { - columns = permission.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if _q.sql != nil { - selector = _q.sql - selector.Select(selector.Columns(columns...)...) - } - if _q.ctx.Unique != nil && *_q.ctx.Unique { - selector.Distinct() - } - for _, m := range _q.modifiers { - m(selector) - } - for _, p := range _q.predicates { - p(selector) - } - for _, p := range _q.order { - p(selector) - } - if offset := _q.ctx.Offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := _q.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// ForUpdate locks the selected rows against concurrent updates, and prevent them from being -// updated, deleted or "selected ... for update" by other sessions, until the transaction is -// either committed or rolled-back. -func (_q *PermissionQuery) ForUpdate(opts ...sql.LockOption) *PermissionQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForUpdate(opts...) - }) - return _q -} - -// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock -// on any rows that are read. Other sessions can read the rows, but cannot modify them -// until your transaction commits. -func (_q *PermissionQuery) ForShare(opts ...sql.LockOption) *PermissionQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForShare(opts...) - }) - return _q -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_q *PermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *PermissionSelect { - _q.modifiers = append(_q.modifiers, modifiers...) - return _q.Select() -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// UpdateTime time.Time `json:"update_time,omitempty"` -// Name string `json:"name,omitempty"` -// Keyword string `json:"keyword,omitempty"` -// Description string `json:"description,omitempty"` -// DataScope string `json:"data_scope,omitempty"` -// DataRules map[string]string `json:"data_rules,omitempty"` -// Actions permission.Actions `json:"actions,omitempty"` -// } -// -// client.Permission.Query(). -// Omit( -// permission.FieldCreateTime, -// permission.FieldUpdateTime, -// permission.FieldName, -// permission.FieldKeyword, -// permission.FieldDescription, -// permission.FieldDataScope, -// permission.FieldDataRules, -// permission.FieldActions, -// ). -// Scan(ctx, &v) -func (pq *PermissionQuery) Omit(fields ...string) *PermissionSelect { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - for _, col := range permission.Columns { - if _, ok := omits[col]; !ok { - pq.ctx.Fields = append(pq.ctx.Fields, col) - } - } - - sbuild := &PermissionSelect{PermissionQuery: pq} - sbuild.label = permission.Label - sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan - return sbuild -} - -// PermissionGroupBy is the group-by builder for Permission entities. -type PermissionGroupBy struct { - selector - build *PermissionQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (_g *PermissionGroupBy) Aggregate(fns ...AggregateFunc) *PermissionGroupBy { - _g.fns = append(_g.fns, fns...) - return _g -} - -// Scan applies the selector query and scans the result into the given value. -func (_g *PermissionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) - if err := _g.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*PermissionQuery, *PermissionGroupBy](ctx, _g.build, _g, _g.build.inters, v) -} - -func (_g *PermissionGroupBy) sqlScan(ctx context.Context, root *PermissionQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(_g.fns)) - for _, fn := range _g.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) - for _, f := range *_g.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*_g.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// PermissionSelect is the builder for selecting fields of Permission entities. -type PermissionSelect struct { - *PermissionQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (_s *PermissionSelect) Aggregate(fns ...AggregateFunc) *PermissionSelect { - _s.fns = append(_s.fns, fns...) - return _s -} - -// Scan applies the selector query and scans the result into the given value. -func (_s *PermissionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) - if err := _s.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*PermissionQuery, *PermissionSelect](ctx, _s.PermissionQuery, _s, _s.inters, v) -} - -func (_s *PermissionSelect) sqlScan(ctx context.Context, root *PermissionQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(_s.fns)) - for _, fn := range _s.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*_s.selector.flds); { - case n == 0 && len(aggregation) > 0: - selector.Select(aggregation...) - case n != 0 && len(aggregation) > 0: - selector.AppendSelect(aggregation...) - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _s.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_s *PermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *PermissionSelect { - _s.modifiers = append(_s.modifiers, modifiers...) - return _s -} diff --git a/internal/features/system/data/ent/permission_update.go b/internal/features/system/data/ent/permission_update.go deleted file mode 100644 index 8ee3a1db..00000000 --- a/internal/features/system/data/ent/permission_update.go +++ /dev/null @@ -1,1198 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// PermissionUpdate is the builder for updating Permission entities. -type PermissionUpdate struct { - config - hooks []Hook - mutation *PermissionMutation - modifiers []func(*sql.UpdateBuilder) -} - -// Where appends a list predicates to the PermissionUpdate builder. -func (_u *PermissionUpdate) Where(ps ...predicate.Permission) *PermissionUpdate { - _u.mutation.Where(ps...) - return _u -} - -// SetUpdateTime sets the "update_time" field. -func (_u *PermissionUpdate) SetUpdateTime(v time.Time) *PermissionUpdate { - _u.mutation.SetUpdateTime(v) - return _u -} - -// SetName sets the "name" field. -func (_u *PermissionUpdate) SetName(v string) *PermissionUpdate { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *PermissionUpdate) SetNillableName(v *string) *PermissionUpdate { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetKeyword sets the "keyword" field. -func (_u *PermissionUpdate) SetKeyword(v string) *PermissionUpdate { - _u.mutation.SetKeyword(v) - return _u -} - -// SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (_u *PermissionUpdate) SetNillableKeyword(v *string) *PermissionUpdate { - if v != nil { - _u.SetKeyword(*v) - } - return _u -} - -// SetDescription sets the "description" field. -func (_u *PermissionUpdate) SetDescription(v string) *PermissionUpdate { - _u.mutation.SetDescription(v) - return _u -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *PermissionUpdate) SetNillableDescription(v *string) *PermissionUpdate { - if v != nil { - _u.SetDescription(*v) - } - return _u -} - -// SetDataScope sets the "data_scope" field. -func (_u *PermissionUpdate) SetDataScope(v string) *PermissionUpdate { - _u.mutation.SetDataScope(v) - return _u -} - -// SetNillableDataScope sets the "data_scope" field if the given value is not nil. -func (_u *PermissionUpdate) SetNillableDataScope(v *string) *PermissionUpdate { - if v != nil { - _u.SetDataScope(*v) - } - return _u -} - -// SetDataRules sets the "data_rules" field. -func (_u *PermissionUpdate) SetDataRules(v map[string]string) *PermissionUpdate { - _u.mutation.SetDataRules(v) - return _u -} - -// ClearDataRules clears the value of the "data_rules" field. -func (_u *PermissionUpdate) ClearDataRules() *PermissionUpdate { - _u.mutation.ClearDataRules() - return _u -} - -// SetActions sets the "actions" field. -func (_u *PermissionUpdate) SetActions(v permission.Actions) *PermissionUpdate { - _u.mutation.SetActions(v) - return _u -} - -// SetNillableActions sets the "actions" field if the given value is not nil. -func (_u *PermissionUpdate) SetNillableActions(v *permission.Actions) *PermissionUpdate { - if v != nil { - _u.SetActions(*v) - } - return _u -} - -// AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (_u *PermissionUpdate) AddRoleIDs(ids ...int64) *PermissionUpdate { - _u.mutation.AddRoleIDs(ids...) - return _u -} - -// AddRoles adds the "roles" edges to the Role entity. -func (_u *PermissionUpdate) AddRoles(v ...*Role) *PermissionUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddRoleIDs(ids...) -} - -// AddResourceIDs adds the "resources" edge to the Resource entity by IDs. -func (_u *PermissionUpdate) AddResourceIDs(ids ...int64) *PermissionUpdate { - _u.mutation.AddResourceIDs(ids...) - return _u -} - -// AddResources adds the "resources" edges to the Resource entity. -func (_u *PermissionUpdate) AddResources(v ...*Resource) *PermissionUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddResourceIDs(ids...) -} - -// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (_u *PermissionUpdate) AddRolePermissionIDs(ids ...int) *PermissionUpdate { - _u.mutation.AddRolePermissionIDs(ids...) - return _u -} - -// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (_u *PermissionUpdate) AddRolePermissions(v ...*RolePermission) *PermissionUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddRolePermissionIDs(ids...) -} - -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (_u *PermissionUpdate) AddPermissionResourceIDs(ids ...int) *PermissionUpdate { - _u.mutation.AddPermissionResourceIDs(ids...) - return _u -} - -// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (_u *PermissionUpdate) AddPermissionResources(v ...*PermissionResource) *PermissionUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddPermissionResourceIDs(ids...) -} - -// Mutation returns the PermissionMutation object of the builder. -func (_u *PermissionUpdate) Mutation() *PermissionMutation { - return _u.mutation -} - -// ClearRoles clears all "roles" edges to the Role entity. -func (_u *PermissionUpdate) ClearRoles() *PermissionUpdate { - _u.mutation.ClearRoles() - return _u -} - -// RemoveRoleIDs removes the "roles" edge to Role entities by IDs. -func (_u *PermissionUpdate) RemoveRoleIDs(ids ...int64) *PermissionUpdate { - _u.mutation.RemoveRoleIDs(ids...) - return _u -} - -// RemoveRoles removes "roles" edges to Role entities. -func (_u *PermissionUpdate) RemoveRoles(v ...*Role) *PermissionUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveRoleIDs(ids...) -} - -// ClearResources clears all "resources" edges to the Resource entity. -func (_u *PermissionUpdate) ClearResources() *PermissionUpdate { - _u.mutation.ClearResources() - return _u -} - -// RemoveResourceIDs removes the "resources" edge to Resource entities by IDs. -func (_u *PermissionUpdate) RemoveResourceIDs(ids ...int64) *PermissionUpdate { - _u.mutation.RemoveResourceIDs(ids...) - return _u -} - -// RemoveResources removes "resources" edges to Resource entities. -func (_u *PermissionUpdate) RemoveResources(v ...*Resource) *PermissionUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveResourceIDs(ids...) -} - -// ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. -func (_u *PermissionUpdate) ClearRolePermissions() *PermissionUpdate { - _u.mutation.ClearRolePermissions() - return _u -} - -// RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. -func (_u *PermissionUpdate) RemoveRolePermissionIDs(ids ...int) *PermissionUpdate { - _u.mutation.RemoveRolePermissionIDs(ids...) - return _u -} - -// RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. -func (_u *PermissionUpdate) RemoveRolePermissions(v ...*RolePermission) *PermissionUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveRolePermissionIDs(ids...) -} - -// ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. -func (_u *PermissionUpdate) ClearPermissionResources() *PermissionUpdate { - _u.mutation.ClearPermissionResources() - return _u -} - -// RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. -func (_u *PermissionUpdate) RemovePermissionResourceIDs(ids ...int) *PermissionUpdate { - _u.mutation.RemovePermissionResourceIDs(ids...) - return _u -} - -// RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. -func (_u *PermissionUpdate) RemovePermissionResources(v ...*PermissionResource) *PermissionUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemovePermissionResourceIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (_u *PermissionUpdate) Save(ctx context.Context) (int, error) { - _u.defaults() - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *PermissionUpdate) SaveX(ctx context.Context) int { - affected, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (_u *PermissionUpdate) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *PermissionUpdate) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *PermissionUpdate) defaults() { - if _, ok := _u.mutation.UpdateTime(); !ok { - v := permission.UpdateDefaultUpdateTime() - _u.mutation.SetUpdateTime(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *PermissionUpdate) check() error { - if v, ok := _u.mutation.Name(); ok { - if err := permission.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Permission.name": %w`, err)} - } - } - if v, ok := _u.mutation.Keyword(); ok { - if err := permission.KeywordValidator(v); err != nil { - return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Permission.keyword": %w`, err)} - } - } - if v, ok := _u.mutation.Description(); ok { - if err := permission.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} - } - } - if v, ok := _u.mutation.Actions(); ok { - if err := permission.ActionsValidator(v); err != nil { - return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} - } - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *PermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionUpdate { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(permission.Table, permission.Columns, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.UpdateTime(); ok { - _spec.SetField(permission.FieldUpdateTime, field.TypeTime, value) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(permission.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Keyword(); ok { - _spec.SetField(permission.FieldKeyword, field.TypeString, value) - } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(permission.FieldDescription, field.TypeString, value) - } - if value, ok := _u.mutation.DataScope(); ok { - _spec.SetField(permission.FieldDataScope, field.TypeString, value) - } - if value, ok := _u.mutation.DataRules(); ok { - _spec.SetField(permission.FieldDataRules, field.TypeJSON, value) - } - if _u.mutation.DataRulesCleared() { - _spec.ClearField(permission.FieldDataRules, field.TypeJSON) - } - if value, ok := _u.mutation.Actions(); ok { - _spec.SetField(permission.FieldActions, field.TypeEnum, value) - } - if _u.mutation.RolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: permission.RolesTable, - Columns: permission.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: permission.RolesTable, - Columns: permission.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: permission.RolesTable, - Columns: permission.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.ResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: permission.ResourcesTable, - Columns: permission.ResourcesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !_u.mutation.ResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: permission.ResourcesTable, - Columns: permission.ResourcesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.ResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: permission.ResourcesTable, - Columns: permission.ResourcesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.RolePermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.RolePermissionsTable, - Columns: []string{permission.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.RolePermissionsTable, - Columns: []string{permission.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.RolePermissionsTable, - Columns: []string{permission.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.PermissionResourcesTable, - Columns: []string{permission.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.PermissionResourcesTable, - Columns: []string{permission.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.PermissionResourcesTable, - Columns: []string{permission.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{permission.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - _u.mutation.done = true - return _node, nil -} - -// PermissionUpdateOne is the builder for updating a single Permission entity. -type PermissionUpdateOne struct { - config - fields []string - hooks []Hook - mutation *PermissionMutation - modifiers []func(*sql.UpdateBuilder) -} - -// SetUpdateTime sets the "update_time" field. -func (_u *PermissionUpdateOne) SetUpdateTime(v time.Time) *PermissionUpdateOne { - _u.mutation.SetUpdateTime(v) - return _u -} - -// SetName sets the "name" field. -func (_u *PermissionUpdateOne) SetName(v string) *PermissionUpdateOne { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *PermissionUpdateOne) SetNillableName(v *string) *PermissionUpdateOne { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetKeyword sets the "keyword" field. -func (_u *PermissionUpdateOne) SetKeyword(v string) *PermissionUpdateOne { - _u.mutation.SetKeyword(v) - return _u -} - -// SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (_u *PermissionUpdateOne) SetNillableKeyword(v *string) *PermissionUpdateOne { - if v != nil { - _u.SetKeyword(*v) - } - return _u -} - -// SetDescription sets the "description" field. -func (_u *PermissionUpdateOne) SetDescription(v string) *PermissionUpdateOne { - _u.mutation.SetDescription(v) - return _u -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *PermissionUpdateOne) SetNillableDescription(v *string) *PermissionUpdateOne { - if v != nil { - _u.SetDescription(*v) - } - return _u -} - -// SetDataScope sets the "data_scope" field. -func (_u *PermissionUpdateOne) SetDataScope(v string) *PermissionUpdateOne { - _u.mutation.SetDataScope(v) - return _u -} - -// SetNillableDataScope sets the "data_scope" field if the given value is not nil. -func (_u *PermissionUpdateOne) SetNillableDataScope(v *string) *PermissionUpdateOne { - if v != nil { - _u.SetDataScope(*v) - } - return _u -} - -// SetDataRules sets the "data_rules" field. -func (_u *PermissionUpdateOne) SetDataRules(v map[string]string) *PermissionUpdateOne { - _u.mutation.SetDataRules(v) - return _u -} - -// ClearDataRules clears the value of the "data_rules" field. -func (_u *PermissionUpdateOne) ClearDataRules() *PermissionUpdateOne { - _u.mutation.ClearDataRules() - return _u -} - -// SetActions sets the "actions" field. -func (_u *PermissionUpdateOne) SetActions(v permission.Actions) *PermissionUpdateOne { - _u.mutation.SetActions(v) - return _u -} - -// SetNillableActions sets the "actions" field if the given value is not nil. -func (_u *PermissionUpdateOne) SetNillableActions(v *permission.Actions) *PermissionUpdateOne { - if v != nil { - _u.SetActions(*v) - } - return _u -} - -// AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (_u *PermissionUpdateOne) AddRoleIDs(ids ...int64) *PermissionUpdateOne { - _u.mutation.AddRoleIDs(ids...) - return _u -} - -// AddRoles adds the "roles" edges to the Role entity. -func (_u *PermissionUpdateOne) AddRoles(v ...*Role) *PermissionUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddRoleIDs(ids...) -} - -// AddResourceIDs adds the "resources" edge to the Resource entity by IDs. -func (_u *PermissionUpdateOne) AddResourceIDs(ids ...int64) *PermissionUpdateOne { - _u.mutation.AddResourceIDs(ids...) - return _u -} - -// AddResources adds the "resources" edges to the Resource entity. -func (_u *PermissionUpdateOne) AddResources(v ...*Resource) *PermissionUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddResourceIDs(ids...) -} - -// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (_u *PermissionUpdateOne) AddRolePermissionIDs(ids ...int) *PermissionUpdateOne { - _u.mutation.AddRolePermissionIDs(ids...) - return _u -} - -// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (_u *PermissionUpdateOne) AddRolePermissions(v ...*RolePermission) *PermissionUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddRolePermissionIDs(ids...) -} - -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (_u *PermissionUpdateOne) AddPermissionResourceIDs(ids ...int) *PermissionUpdateOne { - _u.mutation.AddPermissionResourceIDs(ids...) - return _u -} - -// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (_u *PermissionUpdateOne) AddPermissionResources(v ...*PermissionResource) *PermissionUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddPermissionResourceIDs(ids...) -} - -// Mutation returns the PermissionMutation object of the builder. -func (_u *PermissionUpdateOne) Mutation() *PermissionMutation { - return _u.mutation -} - -// ClearRoles clears all "roles" edges to the Role entity. -func (_u *PermissionUpdateOne) ClearRoles() *PermissionUpdateOne { - _u.mutation.ClearRoles() - return _u -} - -// RemoveRoleIDs removes the "roles" edge to Role entities by IDs. -func (_u *PermissionUpdateOne) RemoveRoleIDs(ids ...int64) *PermissionUpdateOne { - _u.mutation.RemoveRoleIDs(ids...) - return _u -} - -// RemoveRoles removes "roles" edges to Role entities. -func (_u *PermissionUpdateOne) RemoveRoles(v ...*Role) *PermissionUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveRoleIDs(ids...) -} - -// ClearResources clears all "resources" edges to the Resource entity. -func (_u *PermissionUpdateOne) ClearResources() *PermissionUpdateOne { - _u.mutation.ClearResources() - return _u -} - -// RemoveResourceIDs removes the "resources" edge to Resource entities by IDs. -func (_u *PermissionUpdateOne) RemoveResourceIDs(ids ...int64) *PermissionUpdateOne { - _u.mutation.RemoveResourceIDs(ids...) - return _u -} - -// RemoveResources removes "resources" edges to Resource entities. -func (_u *PermissionUpdateOne) RemoveResources(v ...*Resource) *PermissionUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveResourceIDs(ids...) -} - -// ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. -func (_u *PermissionUpdateOne) ClearRolePermissions() *PermissionUpdateOne { - _u.mutation.ClearRolePermissions() - return _u -} - -// RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. -func (_u *PermissionUpdateOne) RemoveRolePermissionIDs(ids ...int) *PermissionUpdateOne { - _u.mutation.RemoveRolePermissionIDs(ids...) - return _u -} - -// RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. -func (_u *PermissionUpdateOne) RemoveRolePermissions(v ...*RolePermission) *PermissionUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveRolePermissionIDs(ids...) -} - -// ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. -func (_u *PermissionUpdateOne) ClearPermissionResources() *PermissionUpdateOne { - _u.mutation.ClearPermissionResources() - return _u -} - -// RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. -func (_u *PermissionUpdateOne) RemovePermissionResourceIDs(ids ...int) *PermissionUpdateOne { - _u.mutation.RemovePermissionResourceIDs(ids...) - return _u -} - -// RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. -func (_u *PermissionUpdateOne) RemovePermissionResources(v ...*PermissionResource) *PermissionUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemovePermissionResourceIDs(ids...) -} - -// Where appends a list predicates to the PermissionUpdate builder. -func (_u *PermissionUpdateOne) Where(ps ...predicate.Permission) *PermissionUpdateOne { - _u.mutation.Where(ps...) - return _u -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (_u *PermissionUpdateOne) Select(field string, fields ...string) *PermissionUpdateOne { - _u.fields = append([]string{field}, fields...) - return _u -} - -// Save executes the query and returns the updated Permission entity. -func (_u *PermissionUpdateOne) Save(ctx context.Context) (*Permission, error) { - _u.defaults() - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *PermissionUpdateOne) SaveX(ctx context.Context) *Permission { - node, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (_u *PermissionUpdateOne) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *PermissionUpdateOne) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *PermissionUpdateOne) defaults() { - if _, ok := _u.mutation.UpdateTime(); !ok { - v := permission.UpdateDefaultUpdateTime() - _u.mutation.SetUpdateTime(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *PermissionUpdateOne) check() error { - if v, ok := _u.mutation.Name(); ok { - if err := permission.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Permission.name": %w`, err)} - } - } - if v, ok := _u.mutation.Keyword(); ok { - if err := permission.KeywordValidator(v); err != nil { - return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Permission.keyword": %w`, err)} - } - } - if v, ok := _u.mutation.Description(); ok { - if err := permission.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} - } - } - if v, ok := _u.mutation.Actions(); ok { - if err := permission.ActionsValidator(v); err != nil { - return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} - } - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *PermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionUpdateOne { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(permission.Table, permission.Columns, sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64)) - id, ok := _u.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Permission.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := _u.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, permission.FieldID) - for _, f := range fields { - if !permission.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != permission.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.UpdateTime(); ok { - _spec.SetField(permission.FieldUpdateTime, field.TypeTime, value) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(permission.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Keyword(); ok { - _spec.SetField(permission.FieldKeyword, field.TypeString, value) - } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(permission.FieldDescription, field.TypeString, value) - } - if value, ok := _u.mutation.DataScope(); ok { - _spec.SetField(permission.FieldDataScope, field.TypeString, value) - } - if value, ok := _u.mutation.DataRules(); ok { - _spec.SetField(permission.FieldDataRules, field.TypeJSON, value) - } - if _u.mutation.DataRulesCleared() { - _spec.ClearField(permission.FieldDataRules, field.TypeJSON) - } - if value, ok := _u.mutation.Actions(); ok { - _spec.SetField(permission.FieldActions, field.TypeEnum, value) - } - if _u.mutation.RolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: permission.RolesTable, - Columns: permission.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: permission.RolesTable, - Columns: permission.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: permission.RolesTable, - Columns: permission.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.ResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: permission.ResourcesTable, - Columns: permission.ResourcesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !_u.mutation.ResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: permission.ResourcesTable, - Columns: permission.ResourcesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.ResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: permission.ResourcesTable, - Columns: permission.ResourcesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.RolePermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.RolePermissionsTable, - Columns: []string{permission.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.RolePermissionsTable, - Columns: []string{permission.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.RolePermissionsTable, - Columns: []string{permission.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.PermissionResourcesTable, - Columns: []string{permission.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.PermissionResourcesTable, - Columns: []string{permission.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: permission.PermissionResourcesTable, - Columns: []string{permission.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - _node = &Permission{config: _u.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{permission.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - _u.mutation.done = true - return _node, nil -} - -// SetPermission set the Permission -func (pu *PermissionUpdate) SetPermission(input *Permission, fields ...string) *PermissionUpdate { - m := pu.mutation - if len(fields) == 0 { - fields = permission.OmitColumns(permission.FieldID) - } - _ = m.SetFields(input, fields...) - return pu -} - -// SetPermissionWithZero set the Permission -func (pu *PermissionUpdate) SetPermissionWithZero(input *Permission, fields ...string) *PermissionUpdate { - m := pu.mutation - if len(fields) == 0 { - fields = permission.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return pu -} - -// SetPermission set the Permission -func (puo *PermissionUpdateOne) SetPermission(input *Permission, fields ...string) *PermissionUpdateOne { - m := puo.mutation - if len(fields) == 0 { - fields = permission.OmitColumns(permission.FieldID) - } - _ = m.SetFields(input, fields...) - return puo -} - -// SetPermissionWithZero set the Permission -func (puo *PermissionUpdateOne) SetPermissionWithZero(input *Permission, fields ...string) *PermissionUpdateOne { - m := puo.mutation - if len(fields) == 0 { - fields = permission.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return puo -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -func (puo *PermissionUpdateOne) Omit(fields ...string) *PermissionUpdateOne { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - puo.fields = []string(nil) - for _, col := range permission.Columns { - if _, ok := omits[col]; !ok { - puo.fields = append(puo.fields, col) - } - } - return puo -} diff --git a/internal/features/system/data/ent/permissionresource.go b/internal/features/system/data/ent/permissionresource.go deleted file mode 100644 index 6b93d940..00000000 --- a/internal/features/system/data/ent/permissionresource.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" -) - -// Permission-Resource mapping table -type PermissionResource struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // PermissionID holds the value of the "permission_id" field. - PermissionID int64 `json:"permission_id,omitempty"` - // ResourceID holds the value of the "resource_id" field. - ResourceID int64 `json:"resource_id,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the PermissionResourceQuery when eager-loading is set. - Edges PermissionResourceEdges `json:"edges"` - selectValues sql.SelectValues -} - -// PermissionResourceEdges holds the relations/edges for other nodes in the graph. -type PermissionResourceEdges struct { - // Permission holds the value of the permission edge. - Permission *Permission `json:"permission,omitempty"` - // Resource holds the value of the resource edge. - Resource *Resource `json:"resource,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool -} - -// PermissionOrErr returns the Permission value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e PermissionResourceEdges) PermissionOrErr() (*Permission, error) { - if e.Permission != nil { - return e.Permission, nil - } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: permission.Label} - } - return nil, &NotLoadedError{edge: "permission"} -} - -// ResourceOrErr returns the Resource value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e PermissionResourceEdges) ResourceOrErr() (*Resource, error) { - if e.Resource != nil { - return e.Resource, nil - } else if e.loadedTypes[1] { - return nil, &NotFoundError{label: resource.Label} - } - return nil, &NotLoadedError{edge: "resource"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*PermissionResource) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case permissionresource.FieldID, permissionresource.FieldPermissionID, permissionresource.FieldResourceID: - values[i] = new(sql.NullInt64) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the PermissionResource fields. -func (_m *PermissionResource) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case permissionresource.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - _m.ID = int(value.Int64) - case permissionresource.FieldPermissionID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field permission_id", values[i]) - } else if value.Valid { - _m.PermissionID = value.Int64 - } - case permissionresource.FieldResourceID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field resource_id", values[i]) - } else if value.Valid { - _m.ResourceID = value.Int64 - } - default: - _m.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the PermissionResource. -// This includes values selected through modifiers, order, etc. -func (_m *PermissionResource) Value(name string) (ent.Value, error) { - return _m.selectValues.Get(name) -} - -// QueryPermission queries the "permission" edge of the PermissionResource entity. -func (_m *PermissionResource) QueryPermission() *PermissionQuery { - return NewPermissionResourceClient(_m.config).QueryPermission(_m) -} - -// QueryResource queries the "resource" edge of the PermissionResource entity. -func (_m *PermissionResource) QueryResource() *ResourceQuery { - return NewPermissionResourceClient(_m.config).QueryResource(_m) -} - -// Update returns a builder for updating this PermissionResource. -// Note that you need to call PermissionResource.Unwrap() before calling this method if this PermissionResource -// was returned from a transaction, and the transaction was committed or rolled back. -func (_m *PermissionResource) Update() *PermissionResourceUpdateOne { - return NewPermissionResourceClient(_m.config).UpdateOne(_m) -} - -// Unwrap unwraps the PermissionResource entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (_m *PermissionResource) Unwrap() *PermissionResource { - _tx, ok := _m.config.driver.(*txDriver) - if !ok { - panic("ent: PermissionResource is not a transactional entity") - } - _m.config.driver = _tx.drv - return _m -} - -// String implements the fmt.Stringer. -func (_m *PermissionResource) String() string { - var builder strings.Builder - builder.WriteString("PermissionResource(") - builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - builder.WriteString("permission_id=") - builder.WriteString(fmt.Sprintf("%v", _m.PermissionID)) - builder.WriteString(", ") - builder.WriteString("resource_id=") - builder.WriteString(fmt.Sprintf("%v", _m.ResourceID)) - builder.WriteByte(')') - return builder.String() -} - -// PermissionResources is a parsable slice of PermissionResource. -type PermissionResources []*PermissionResource diff --git a/internal/features/system/data/ent/permissionresource/permissionresource.go b/internal/features/system/data/ent/permissionresource/permissionresource.go deleted file mode 100644 index 80efab8e..00000000 --- a/internal/features/system/data/ent/permissionresource/permissionresource.go +++ /dev/null @@ -1,164 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package permissionresource - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the permissionresource type in the database. - Label = "permission_resource" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldPermissionID holds the string denoting the permission_id field in the database. - FieldPermissionID = "permission_id" - // FieldResourceID holds the string denoting the resource_id field in the database. - FieldResourceID = "resource_id" - // EdgePermission holds the string denoting the permission edge name in mutations. - EdgePermission = "permission" - // EdgeResource holds the string denoting the resource edge name in mutations. - EdgeResource = "resource" - // Table holds the table name of the permissionresource in the database. - Table = "sys_permission_resources" - // PermissionTable is the table that holds the permission relation/edge. - PermissionTable = "sys_permission_resources" - // PermissionInverseTable is the table name for the Permission entity. - // It exists in this package in order to avoid circular dependency with the "permission" package. - PermissionInverseTable = "sys_permissions" - // PermissionColumn is the table column denoting the permission relation/edge. - PermissionColumn = "permission_id" - // ResourceTable is the table that holds the resource relation/edge. - ResourceTable = "sys_permission_resources" - // ResourceInverseTable is the table name for the Resource entity. - // It exists in this package in order to avoid circular dependency with the "resource" package. - ResourceInverseTable = "sys_resources" - // ResourceColumn is the table column denoting the resource relation/edge. - ResourceColumn = "resource_id" -) - -// Columns holds all SQL columns for permissionresource fields. -var Columns = []string{ - FieldID, - FieldPermissionID, - FieldResourceID, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -// OrderOption defines the ordering options for the PermissionResource queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByPermissionID orders the results by the permission_id field. -func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPermissionID, opts...).ToFunc() -} - -// ByResourceID orders the results by the resource_id field. -func ByResourceID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldResourceID, opts...).ToFunc() -} - -// ByPermissionField orders the results by permission field. -func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) - } -} - -// ByResourceField orders the results by resource field. -func ByResourceField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newResourceStep(), sql.OrderByField(field, opts...)) - } -} -func newPermissionStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), - ) -} -func newResourceStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(ResourceInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, ResourceTable, ResourceColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/features/system/data/ent/permissionresource/where.go b/internal/features/system/data/ent/permissionresource/where.go deleted file mode 100644 index 11fb6433..00000000 --- a/internal/features/system/data/ent/permissionresource/where.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package permissionresource - -import ( - "origadmin/application/admin/internal/features/system/data/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldLTE(FieldID, id)) -} - -// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. -func PermissionID(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldPermissionID, v)) -} - -// ResourceID applies equality check predicate on the "resource_id" field. It's identical to ResourceIDEQ. -func ResourceID(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldResourceID, v)) -} - -// PermissionIDEQ applies the EQ predicate on the "permission_id" field. -func PermissionIDEQ(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldPermissionID, v)) -} - -// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. -func PermissionIDNEQ(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNEQ(FieldPermissionID, v)) -} - -// PermissionIDIn applies the In predicate on the "permission_id" field. -func PermissionIDIn(vs ...int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldIn(FieldPermissionID, vs...)) -} - -// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. -func PermissionIDNotIn(vs ...int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNotIn(FieldPermissionID, vs...)) -} - -// ResourceIDEQ applies the EQ predicate on the "resource_id" field. -func ResourceIDEQ(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldEQ(FieldResourceID, v)) -} - -// ResourceIDNEQ applies the NEQ predicate on the "resource_id" field. -func ResourceIDNEQ(v int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNEQ(FieldResourceID, v)) -} - -// ResourceIDIn applies the In predicate on the "resource_id" field. -func ResourceIDIn(vs ...int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldIn(FieldResourceID, vs...)) -} - -// ResourceIDNotIn applies the NotIn predicate on the "resource_id" field. -func ResourceIDNotIn(vs ...int64) predicate.PermissionResource { - return predicate.PermissionResource(sql.FieldNotIn(FieldResourceID, vs...)) -} - -// HasPermission applies the HasEdge predicate on the "permission" edge. -func HasPermission() predicate.PermissionResource { - return predicate.PermissionResource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). -func HasPermissionWith(preds ...predicate.Permission) predicate.PermissionResource { - return predicate.PermissionResource(func(s *sql.Selector) { - step := newPermissionStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasResource applies the HasEdge predicate on the "resource" edge. -func HasResource() predicate.PermissionResource { - return predicate.PermissionResource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, ResourceTable, ResourceColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasResourceWith applies the HasEdge predicate on the "resource" edge with a given conditions (other predicates). -func HasResourceWith(preds ...predicate.Resource) predicate.PermissionResource { - return predicate.PermissionResource(func(s *sql.Selector) { - step := newResourceStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.PermissionResource) predicate.PermissionResource { - return predicate.PermissionResource(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.PermissionResource) predicate.PermissionResource { - return predicate.PermissionResource(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.PermissionResource) predicate.PermissionResource { - return predicate.PermissionResource(sql.NotPredicates(p)) -} diff --git a/internal/features/system/data/ent/permissionresource_create.go b/internal/features/system/data/ent/permissionresource_create.go deleted file mode 100644 index 657da848..00000000 --- a/internal/features/system/data/ent/permissionresource_create.go +++ /dev/null @@ -1,260 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/resource" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// PermissionResourceCreate is the builder for creating a PermissionResource entity. -type PermissionResourceCreate struct { - config - mutation *PermissionResourceMutation - hooks []Hook -} - -// SetPermissionID sets the "permission_id" field. -func (_c *PermissionResourceCreate) SetPermissionID(v int64) *PermissionResourceCreate { - _c.mutation.SetPermissionID(v) - return _c -} - -// SetResourceID sets the "resource_id" field. -func (_c *PermissionResourceCreate) SetResourceID(v int64) *PermissionResourceCreate { - _c.mutation.SetResourceID(v) - return _c -} - -// SetPermission sets the "permission" edge to the Permission entity. -func (_c *PermissionResourceCreate) SetPermission(v *Permission) *PermissionResourceCreate { - return _c.SetPermissionID(v.ID) -} - -// SetResource sets the "resource" edge to the Resource entity. -func (_c *PermissionResourceCreate) SetResource(v *Resource) *PermissionResourceCreate { - return _c.SetResourceID(v.ID) -} - -// Mutation returns the PermissionResourceMutation object of the builder. -func (_c *PermissionResourceCreate) Mutation() *PermissionResourceMutation { - return _c.mutation -} - -// Save creates the PermissionResource in the database. -func (_c *PermissionResourceCreate) Save(ctx context.Context) (*PermissionResource, error) { - return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (_c *PermissionResourceCreate) SaveX(ctx context.Context) *PermissionResource { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *PermissionResourceCreate) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *PermissionResourceCreate) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_c *PermissionResourceCreate) check() error { - if _, ok := _c.mutation.PermissionID(); !ok { - return &ValidationError{Name: "permission_id", err: errors.New(`ent: missing required field "PermissionResource.permission_id"`)} - } - if _, ok := _c.mutation.ResourceID(); !ok { - return &ValidationError{Name: "resource_id", err: errors.New(`ent: missing required field "PermissionResource.resource_id"`)} - } - if len(_c.mutation.PermissionIDs()) == 0 { - return &ValidationError{Name: "permission", err: errors.New(`ent: missing required edge "PermissionResource.permission"`)} - } - if len(_c.mutation.ResourceIDs()) == 0 { - return &ValidationError{Name: "resource", err: errors.New(`ent: missing required edge "PermissionResource.resource"`)} - } - return nil -} - -func (_c *PermissionResourceCreate) sqlSave(ctx context.Context) (*PermissionResource, error) { - if err := _c.check(); err != nil { - return nil, err - } - _node, _spec := _c.createSpec() - if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - id := _spec.ID.Value.(int64) - _node.ID = int(id) - _c.mutation.id = &_node.ID - _c.mutation.done = true - return _node, nil -} - -func (_c *PermissionResourceCreate) createSpec() (*PermissionResource, *sqlgraph.CreateSpec) { - var ( - _node = &PermissionResource{config: _c.config} - _spec = sqlgraph.NewCreateSpec(permissionresource.Table, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) - ) - if nodes := _c.mutation.PermissionIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: permissionresource.PermissionTable, - Columns: []string{permissionresource.PermissionColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.PermissionID = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.ResourceIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: permissionresource.ResourceTable, - Columns: []string{permissionresource.ResourceColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.ResourceID = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// SetPermissionResource set the PermissionResource -func (_c *PermissionResourceCreate) SetPermissionResource(input *PermissionResource, fields ...string) *PermissionResourceCreate { - m := _c.mutation - if len(fields) == 0 { - fields = permissionresource.Columns - } - _ = m.SetFields(input, fields...) - return _c -} - -// SetPermissionResourceWithZero set the PermissionResource -func (_c *PermissionResourceCreate) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceCreate { - m := _c.mutation - if len(fields) == 0 { - fields = permissionresource.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return _c -} - -// PermissionResourceCreateBulk is the builder for creating many PermissionResource entities in bulk. -type PermissionResourceCreateBulk struct { - config - err error - builders []*PermissionResourceCreate -} - -// Save creates the PermissionResource entities in the database. -func (_c *PermissionResourceCreateBulk) Save(ctx context.Context) ([]*PermissionResource, error) { - if _c.err != nil { - return nil, _c.err - } - specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*PermissionResource, len(_c.builders)) - mutators := make([]Mutator, len(_c.builders)) - for i := range _c.builders { - func(i int, root context.Context) { - builder := _c.builders[i] - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PermissionResourceMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (_c *PermissionResourceCreateBulk) SaveX(ctx context.Context) []*PermissionResource { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *PermissionResourceCreateBulk) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *PermissionResourceCreateBulk) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/permissionresource_delete.go b/internal/features/system/data/ent/permissionresource_delete.go deleted file mode 100644 index 67f5f2a6..00000000 --- a/internal/features/system/data/ent/permissionresource_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// PermissionResourceDelete is the builder for deleting a PermissionResource entity. -type PermissionResourceDelete struct { - config - hooks []Hook - mutation *PermissionResourceMutation -} - -// Where appends a list predicates to the PermissionResourceDelete builder. -func (_d *PermissionResourceDelete) Where(ps ...predicate.PermissionResource) *PermissionResourceDelete { - _d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (_d *PermissionResourceDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *PermissionResourceDelete) ExecX(ctx context.Context) int { - n, err := _d.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (_d *PermissionResourceDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(permissionresource.Table, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) - if ps := _d.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - _d.mutation.done = true - return affected, err -} - -// PermissionResourceDeleteOne is the builder for deleting a single PermissionResource entity. -type PermissionResourceDeleteOne struct { - _d *PermissionResourceDelete -} - -// Where appends a list predicates to the PermissionResourceDelete builder. -func (_d *PermissionResourceDeleteOne) Where(ps ...predicate.PermissionResource) *PermissionResourceDeleteOne { - _d._d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query. -func (_d *PermissionResourceDeleteOne) Exec(ctx context.Context) error { - n, err := _d._d.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{permissionresource.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *PermissionResourceDeleteOne) ExecX(ctx context.Context) { - if err := _d.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/permissionresource_query.go b/internal/features/system/data/ent/permissionresource_query.go deleted file mode 100644 index a991af18..00000000 --- a/internal/features/system/data/ent/permissionresource_query.go +++ /dev/null @@ -1,763 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "math" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/resource" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// PermissionResourceQuery is the builder for querying PermissionResource entities. -type PermissionResourceQuery struct { - config - ctx *QueryContext - order []permissionresource.OrderOption - inters []Interceptor - predicates []predicate.PermissionResource - withPermission *PermissionQuery - withResource *ResourceQuery - modifiers []func(*sql.Selector) - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the PermissionResourceQuery builder. -func (_q *PermissionResourceQuery) Where(ps ...predicate.PermissionResource) *PermissionResourceQuery { - _q.predicates = append(_q.predicates, ps...) - return _q -} - -// Limit the number of records to be returned by this query. -func (_q *PermissionResourceQuery) Limit(limit int) *PermissionResourceQuery { - _q.ctx.Limit = &limit - return _q -} - -// Offset to start from. -func (_q *PermissionResourceQuery) Offset(offset int) *PermissionResourceQuery { - _q.ctx.Offset = &offset - return _q -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (_q *PermissionResourceQuery) Unique(unique bool) *PermissionResourceQuery { - _q.ctx.Unique = &unique - return _q -} - -// Order specifies how the records should be ordered. -func (_q *PermissionResourceQuery) Order(o ...permissionresource.OrderOption) *PermissionResourceQuery { - _q.order = append(_q.order, o...) - return _q -} - -// QueryPermission chains the current query on the "permission" edge. -func (_q *PermissionResourceQuery) QueryPermission() *PermissionQuery { - query := (&PermissionClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(permissionresource.Table, permissionresource.FieldID, selector), - sqlgraph.To(permission.Table, permission.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.PermissionTable, permissionresource.PermissionColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryResource chains the current query on the "resource" edge. -func (_q *PermissionResourceQuery) QueryResource() *ResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(permissionresource.Table, permissionresource.FieldID, selector), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, permissionresource.ResourceTable, permissionresource.ResourceColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first PermissionResource entity from the query. -// Returns a *NotFoundError when no PermissionResource was found. -func (_q *PermissionResourceQuery) First(ctx context.Context) (*PermissionResource, error) { - nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{permissionresource.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (_q *PermissionResourceQuery) FirstX(ctx context.Context) *PermissionResource { - node, err := _q.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first PermissionResource ID from the query. -// Returns a *NotFoundError when no PermissionResource ID was found. -func (_q *PermissionResourceQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{permissionresource.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (_q *PermissionResourceQuery) FirstIDX(ctx context.Context) int { - id, err := _q.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single PermissionResource entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one PermissionResource entity is found. -// Returns a *NotFoundError when no PermissionResource entities are found. -func (_q *PermissionResourceQuery) Only(ctx context.Context) (*PermissionResource, error) { - nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{permissionresource.Label} - default: - return nil, &NotSingularError{permissionresource.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (_q *PermissionResourceQuery) OnlyX(ctx context.Context) *PermissionResource { - node, err := _q.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only PermissionResource ID in the query. -// Returns a *NotSingularError when more than one PermissionResource ID is found. -// Returns a *NotFoundError when no entities are found. -func (_q *PermissionResourceQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{permissionresource.Label} - default: - err = &NotSingularError{permissionresource.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *PermissionResourceQuery) OnlyIDX(ctx context.Context) int { - id, err := _q.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of PermissionResources. -func (_q *PermissionResourceQuery) All(ctx context.Context) ([]*PermissionResource, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*PermissionResource, *PermissionResourceQuery]() - return withInterceptors[[]*PermissionResource](ctx, _q, qr, _q.inters) -} - -// AllX is like All, but panics if an error occurs. -func (_q *PermissionResourceQuery) AllX(ctx context.Context) []*PermissionResource { - nodes, err := _q.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of PermissionResource IDs. -func (_q *PermissionResourceQuery) IDs(ctx context.Context) (ids []int, err error) { - if _q.ctx.Unique == nil && _q.path != nil { - _q.Unique(true) - } - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(permissionresource.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (_q *PermissionResourceQuery) IDsX(ctx context.Context) []int { - ids, err := _q.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (_q *PermissionResourceQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) - if err := _q.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, _q, querierCount[*PermissionResourceQuery](), _q.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (_q *PermissionResourceQuery) CountX(ctx context.Context) int { - count, err := _q.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (_q *PermissionResourceQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) - switch _, err := _q.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - -// ExistX is like Exist, but panics if an error occurs. -func (_q *PermissionResourceQuery) ExistX(ctx context.Context) bool { - exist, err := _q.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the PermissionResourceQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (_q *PermissionResourceQuery) Clone() *PermissionResourceQuery { - if _q == nil { - return nil - } - return &PermissionResourceQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]permissionresource.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.PermissionResource{}, _q.predicates...), - withPermission: _q.withPermission.Clone(), - withResource: _q.withResource.Clone(), - // clone intermediate query. - sql: _q.sql.Clone(), - path: _q.path, - modifiers: append([]func(*sql.Selector){}, _q.modifiers...), - } -} - -// WithPermission tells the query-builder to eager-load the nodes that are connected to -// the "permission" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *PermissionResourceQuery) WithPermission(opts ...func(*PermissionQuery)) *PermissionResourceQuery { - query := (&PermissionClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withPermission = query - return _q -} - -// WithResource tells the query-builder to eager-load the nodes that are connected to -// the "resource" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *PermissionResourceQuery) WithResource(opts ...func(*ResourceQuery)) *PermissionResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withResource = query - return _q -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// PermissionID int64 `json:"permission_id,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.PermissionResource.Query(). -// GroupBy(permissionresource.FieldPermissionID). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (_q *PermissionResourceQuery) GroupBy(field string, fields ...string) *PermissionResourceGroupBy { - _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &PermissionResourceGroupBy{build: _q} - grbuild.flds = &_q.ctx.Fields - grbuild.label = permissionresource.Label - grbuild.scan = grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// PermissionID int64 `json:"permission_id,omitempty"` -// } -// -// client.PermissionResource.Query(). -// Select(permissionresource.FieldPermissionID). -// Scan(ctx, &v) -func (_q *PermissionResourceQuery) Select(fields ...string) *PermissionResourceSelect { - _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &PermissionResourceSelect{PermissionResourceQuery: _q} - sbuild.label = permissionresource.Label - sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a PermissionResourceSelect configured with the given aggregations. -func (_q *PermissionResourceQuery) Aggregate(fns ...AggregateFunc) *PermissionResourceSelect { - return _q.Select().Aggregate(fns...) -} - -func (_q *PermissionResourceQuery) prepareQuery(ctx context.Context) error { - for _, inter := range _q.inters { - if inter == nil { - return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") - } - if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, _q); err != nil { - return err - } - } - } - for _, f := range _q.ctx.Fields { - if !permissionresource.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if _q.path != nil { - prev, err := _q.path(ctx) - if err != nil { - return err - } - _q.sql = prev - } - return nil -} - -func (_q *PermissionResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*PermissionResource, error) { - var ( - nodes = []*PermissionResource{} - _spec = _q.querySpec() - loadedTypes = [2]bool{ - _q.withPermission != nil, - _q.withResource != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*PermissionResource).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &PermissionResource{config: _q.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := _q.withPermission; query != nil { - if err := _q.loadPermission(ctx, query, nodes, nil, - func(n *PermissionResource, e *Permission) { n.Edges.Permission = e }); err != nil { - return nil, err - } - } - if query := _q.withResource; query != nil { - if err := _q.loadResource(ctx, query, nodes, nil, - func(n *PermissionResource, e *Resource) { n.Edges.Resource = e }); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (_q *PermissionResourceQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*PermissionResource, init func(*PermissionResource), assign func(*PermissionResource, *Permission)) error { - ids := make([]int64, 0, len(nodes)) - nodeids := make(map[int64][]*PermissionResource) - for i := range nodes { - fk := nodes[i].PermissionID - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(permission.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "permission_id" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} -func (_q *PermissionResourceQuery) loadResource(ctx context.Context, query *ResourceQuery, nodes []*PermissionResource, init func(*PermissionResource), assign func(*PermissionResource, *Resource)) error { - ids := make([]int64, 0, len(nodes)) - nodeids := make(map[int64][]*PermissionResource) - for i := range nodes { - fk := nodes[i].ResourceID - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(resource.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "resource_id" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} - -func (_q *PermissionResourceQuery) sqlCount(ctx context.Context) (int, error) { - _spec := _q.querySpec() - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - _spec.Node.Columns = _q.ctx.Fields - if len(_q.ctx.Fields) > 0 { - _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique - } - return sqlgraph.CountNodes(ctx, _q.driver, _spec) -} - -func (_q *PermissionResourceQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(permissionresource.Table, permissionresource.Columns, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) - _spec.From = _q.sql - if unique := _q.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if _q.path != nil { - _spec.Unique = true - } - if fields := _q.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, permissionresource.FieldID) - for i := range fields { - if fields[i] != permissionresource.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - if _q.withPermission != nil { - _spec.Node.AddColumnOnce(permissionresource.FieldPermissionID) - } - if _q.withResource != nil { - _spec.Node.AddColumnOnce(permissionresource.FieldResourceID) - } - } - if ps := _q.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := _q.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := _q.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := _q.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (_q *PermissionResourceQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(permissionresource.Table) - columns := _q.ctx.Fields - if len(columns) == 0 { - columns = permissionresource.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if _q.sql != nil { - selector = _q.sql - selector.Select(selector.Columns(columns...)...) - } - if _q.ctx.Unique != nil && *_q.ctx.Unique { - selector.Distinct() - } - for _, m := range _q.modifiers { - m(selector) - } - for _, p := range _q.predicates { - p(selector) - } - for _, p := range _q.order { - p(selector) - } - if offset := _q.ctx.Offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := _q.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// ForUpdate locks the selected rows against concurrent updates, and prevent them from being -// updated, deleted or "selected ... for update" by other sessions, until the transaction is -// either committed or rolled-back. -func (_q *PermissionResourceQuery) ForUpdate(opts ...sql.LockOption) *PermissionResourceQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForUpdate(opts...) - }) - return _q -} - -// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock -// on any rows that are read. Other sessions can read the rows, but cannot modify them -// until your transaction commits. -func (_q *PermissionResourceQuery) ForShare(opts ...sql.LockOption) *PermissionResourceQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForShare(opts...) - }) - return _q -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_q *PermissionResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *PermissionResourceSelect { - _q.modifiers = append(_q.modifiers, modifiers...) - return _q.Select() -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// Example: -// -// var v []struct { -// PermissionID int64 `json:"permission_id,omitempty"` -// ResourceID int64 `json:"resource_id,omitempty"` -// } -// -// client.PermissionResource.Query(). -// Omit( -// permissionresource.FieldPermissionID, -// permissionresource.FieldResourceID, -// ). -// Scan(ctx, &v) -func (prq *PermissionResourceQuery) Omit(fields ...string) *PermissionResourceSelect { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - for _, col := range permissionresource.Columns { - if _, ok := omits[col]; !ok { - prq.ctx.Fields = append(prq.ctx.Fields, col) - } - } - - sbuild := &PermissionResourceSelect{PermissionResourceQuery: prq} - sbuild.label = permissionresource.Label - sbuild.flds, sbuild.scan = &prq.ctx.Fields, sbuild.Scan - return sbuild -} - -// PermissionResourceGroupBy is the group-by builder for PermissionResource entities. -type PermissionResourceGroupBy struct { - selector - build *PermissionResourceQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (_g *PermissionResourceGroupBy) Aggregate(fns ...AggregateFunc) *PermissionResourceGroupBy { - _g.fns = append(_g.fns, fns...) - return _g -} - -// Scan applies the selector query and scans the result into the given value. -func (_g *PermissionResourceGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) - if err := _g.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*PermissionResourceQuery, *PermissionResourceGroupBy](ctx, _g.build, _g, _g.build.inters, v) -} - -func (_g *PermissionResourceGroupBy) sqlScan(ctx context.Context, root *PermissionResourceQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(_g.fns)) - for _, fn := range _g.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) - for _, f := range *_g.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*_g.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// PermissionResourceSelect is the builder for selecting fields of PermissionResource entities. -type PermissionResourceSelect struct { - *PermissionResourceQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (_s *PermissionResourceSelect) Aggregate(fns ...AggregateFunc) *PermissionResourceSelect { - _s.fns = append(_s.fns, fns...) - return _s -} - -// Scan applies the selector query and scans the result into the given value. -func (_s *PermissionResourceSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) - if err := _s.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*PermissionResourceQuery, *PermissionResourceSelect](ctx, _s.PermissionResourceQuery, _s, _s.inters, v) -} - -func (_s *PermissionResourceSelect) sqlScan(ctx context.Context, root *PermissionResourceQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(_s.fns)) - for _, fn := range _s.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*_s.selector.flds); { - case n == 0 && len(aggregation) > 0: - selector.Select(aggregation...) - case n != 0 && len(aggregation) > 0: - selector.AppendSelect(aggregation...) - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _s.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_s *PermissionResourceSelect) Modify(modifiers ...func(s *sql.Selector)) *PermissionResourceSelect { - _s.modifiers = append(_s.modifiers, modifiers...) - return _s -} diff --git a/internal/features/system/data/ent/permissionresource_update.go b/internal/features/system/data/ent/permissionresource_update.go deleted file mode 100644 index 4e4fc345..00000000 --- a/internal/features/system/data/ent/permissionresource_update.go +++ /dev/null @@ -1,493 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/resource" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// PermissionResourceUpdate is the builder for updating PermissionResource entities. -type PermissionResourceUpdate struct { - config - hooks []Hook - mutation *PermissionResourceMutation - modifiers []func(*sql.UpdateBuilder) -} - -// Where appends a list predicates to the PermissionResourceUpdate builder. -func (_u *PermissionResourceUpdate) Where(ps ...predicate.PermissionResource) *PermissionResourceUpdate { - _u.mutation.Where(ps...) - return _u -} - -// SetPermissionID sets the "permission_id" field. -func (_u *PermissionResourceUpdate) SetPermissionID(v int64) *PermissionResourceUpdate { - _u.mutation.SetPermissionID(v) - return _u -} - -// SetNillablePermissionID sets the "permission_id" field if the given value is not nil. -func (_u *PermissionResourceUpdate) SetNillablePermissionID(v *int64) *PermissionResourceUpdate { - if v != nil { - _u.SetPermissionID(*v) - } - return _u -} - -// SetResourceID sets the "resource_id" field. -func (_u *PermissionResourceUpdate) SetResourceID(v int64) *PermissionResourceUpdate { - _u.mutation.SetResourceID(v) - return _u -} - -// SetNillableResourceID sets the "resource_id" field if the given value is not nil. -func (_u *PermissionResourceUpdate) SetNillableResourceID(v *int64) *PermissionResourceUpdate { - if v != nil { - _u.SetResourceID(*v) - } - return _u -} - -// SetPermission sets the "permission" edge to the Permission entity. -func (_u *PermissionResourceUpdate) SetPermission(v *Permission) *PermissionResourceUpdate { - return _u.SetPermissionID(v.ID) -} - -// SetResource sets the "resource" edge to the Resource entity. -func (_u *PermissionResourceUpdate) SetResource(v *Resource) *PermissionResourceUpdate { - return _u.SetResourceID(v.ID) -} - -// Mutation returns the PermissionResourceMutation object of the builder. -func (_u *PermissionResourceUpdate) Mutation() *PermissionResourceMutation { - return _u.mutation -} - -// ClearPermission clears the "permission" edge to the Permission entity. -func (_u *PermissionResourceUpdate) ClearPermission() *PermissionResourceUpdate { - _u.mutation.ClearPermission() - return _u -} - -// ClearResource clears the "resource" edge to the Resource entity. -func (_u *PermissionResourceUpdate) ClearResource() *PermissionResourceUpdate { - _u.mutation.ClearResource() - return _u -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (_u *PermissionResourceUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *PermissionResourceUpdate) SaveX(ctx context.Context) int { - affected, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (_u *PermissionResourceUpdate) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *PermissionResourceUpdate) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *PermissionResourceUpdate) check() error { - if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "PermissionResource.permission"`) - } - if _u.mutation.ResourceCleared() && len(_u.mutation.ResourceIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "PermissionResource.resource"`) - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *PermissionResourceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionResourceUpdate { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *PermissionResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(permissionresource.Table, permissionresource.Columns, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if _u.mutation.PermissionCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: permissionresource.PermissionTable, - Columns: []string{permissionresource.PermissionColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: permissionresource.PermissionTable, - Columns: []string{permissionresource.PermissionColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.ResourceCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: permissionresource.ResourceTable, - Columns: []string{permissionresource.ResourceColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.ResourceIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: permissionresource.ResourceTable, - Columns: []string{permissionresource.ResourceColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{permissionresource.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - _u.mutation.done = true - return _node, nil -} - -// PermissionResourceUpdateOne is the builder for updating a single PermissionResource entity. -type PermissionResourceUpdateOne struct { - config - fields []string - hooks []Hook - mutation *PermissionResourceMutation - modifiers []func(*sql.UpdateBuilder) -} - -// SetPermissionID sets the "permission_id" field. -func (_u *PermissionResourceUpdateOne) SetPermissionID(v int64) *PermissionResourceUpdateOne { - _u.mutation.SetPermissionID(v) - return _u -} - -// SetNillablePermissionID sets the "permission_id" field if the given value is not nil. -func (_u *PermissionResourceUpdateOne) SetNillablePermissionID(v *int64) *PermissionResourceUpdateOne { - if v != nil { - _u.SetPermissionID(*v) - } - return _u -} - -// SetResourceID sets the "resource_id" field. -func (_u *PermissionResourceUpdateOne) SetResourceID(v int64) *PermissionResourceUpdateOne { - _u.mutation.SetResourceID(v) - return _u -} - -// SetNillableResourceID sets the "resource_id" field if the given value is not nil. -func (_u *PermissionResourceUpdateOne) SetNillableResourceID(v *int64) *PermissionResourceUpdateOne { - if v != nil { - _u.SetResourceID(*v) - } - return _u -} - -// SetPermission sets the "permission" edge to the Permission entity. -func (_u *PermissionResourceUpdateOne) SetPermission(v *Permission) *PermissionResourceUpdateOne { - return _u.SetPermissionID(v.ID) -} - -// SetResource sets the "resource" edge to the Resource entity. -func (_u *PermissionResourceUpdateOne) SetResource(v *Resource) *PermissionResourceUpdateOne { - return _u.SetResourceID(v.ID) -} - -// Mutation returns the PermissionResourceMutation object of the builder. -func (_u *PermissionResourceUpdateOne) Mutation() *PermissionResourceMutation { - return _u.mutation -} - -// ClearPermission clears the "permission" edge to the Permission entity. -func (_u *PermissionResourceUpdateOne) ClearPermission() *PermissionResourceUpdateOne { - _u.mutation.ClearPermission() - return _u -} - -// ClearResource clears the "resource" edge to the Resource entity. -func (_u *PermissionResourceUpdateOne) ClearResource() *PermissionResourceUpdateOne { - _u.mutation.ClearResource() - return _u -} - -// Where appends a list predicates to the PermissionResourceUpdate builder. -func (_u *PermissionResourceUpdateOne) Where(ps ...predicate.PermissionResource) *PermissionResourceUpdateOne { - _u.mutation.Where(ps...) - return _u -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (_u *PermissionResourceUpdateOne) Select(field string, fields ...string) *PermissionResourceUpdateOne { - _u.fields = append([]string{field}, fields...) - return _u -} - -// Save executes the query and returns the updated PermissionResource entity. -func (_u *PermissionResourceUpdateOne) Save(ctx context.Context) (*PermissionResource, error) { - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *PermissionResourceUpdateOne) SaveX(ctx context.Context) *PermissionResource { - node, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (_u *PermissionResourceUpdateOne) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *PermissionResourceUpdateOne) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *PermissionResourceUpdateOne) check() error { - if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "PermissionResource.permission"`) - } - if _u.mutation.ResourceCleared() && len(_u.mutation.ResourceIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "PermissionResource.resource"`) - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *PermissionResourceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PermissionResourceUpdateOne { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *PermissionResource, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(permissionresource.Table, permissionresource.Columns, sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt)) - id, ok := _u.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PermissionResource.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := _u.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, permissionresource.FieldID) - for _, f := range fields { - if !permissionresource.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != permissionresource.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if _u.mutation.PermissionCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: permissionresource.PermissionTable, - Columns: []string{permissionresource.PermissionColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: permissionresource.PermissionTable, - Columns: []string{permissionresource.PermissionColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.ResourceCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: permissionresource.ResourceTable, - Columns: []string{permissionresource.ResourceColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.ResourceIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: permissionresource.ResourceTable, - Columns: []string{permissionresource.ResourceColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - _node = &PermissionResource{config: _u.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{permissionresource.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - _u.mutation.done = true - return _node, nil -} - -// SetPermissionResource set the PermissionResource -func (pru *PermissionResourceUpdate) SetPermissionResource(input *PermissionResource, fields ...string) *PermissionResourceUpdate { - m := pru.mutation - if len(fields) == 0 { - fields = permissionresource.OmitColumns(permissionresource.FieldID) - } - _ = m.SetFields(input, fields...) - return pru -} - -// SetPermissionResourceWithZero set the PermissionResource -func (pru *PermissionResourceUpdate) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceUpdate { - m := pru.mutation - if len(fields) == 0 { - fields = permissionresource.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return pru -} - -// SetPermissionResource set the PermissionResource -func (pruo *PermissionResourceUpdateOne) SetPermissionResource(input *PermissionResource, fields ...string) *PermissionResourceUpdateOne { - m := pruo.mutation - if len(fields) == 0 { - fields = permissionresource.OmitColumns(permissionresource.FieldID) - } - _ = m.SetFields(input, fields...) - return pruo -} - -// SetPermissionResourceWithZero set the PermissionResource -func (pruo *PermissionResourceUpdateOne) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceUpdateOne { - m := pruo.mutation - if len(fields) == 0 { - fields = permissionresource.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return pruo -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -func (pruo *PermissionResourceUpdateOne) Omit(fields ...string) *PermissionResourceUpdateOne { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - pruo.fields = []string(nil) - for _, col := range permissionresource.Columns { - if _, ok := omits[col]; !ok { - pruo.fields = append(pruo.fields, col) - } - } - return pruo -} diff --git a/internal/features/system/data/ent/predicate/predicate.go b/internal/features/system/data/ent/predicate/predicate.go deleted file mode 100644 index 822f2f32..00000000 --- a/internal/features/system/data/ent/predicate/predicate.go +++ /dev/null @@ -1,28 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package predicate - -import ( - "entgo.io/ent/dialect/sql" -) - -// Permission is the predicate function for permission builders. -type Permission func(*sql.Selector) - -// PermissionResource is the predicate function for permissionresource builders. -type PermissionResource func(*sql.Selector) - -// Resource is the predicate function for resource builders. -type Resource func(*sql.Selector) - -// Role is the predicate function for role builders. -type Role func(*sql.Selector) - -// RolePermission is the predicate function for rolepermission builders. -type RolePermission func(*sql.Selector) - -// User is the predicate function for user builders. -type User func(*sql.Selector) - -// UserRole is the predicate function for userrole builders. -type UserRole func(*sql.Selector) diff --git a/internal/features/system/data/ent/resource.go b/internal/features/system/data/ent/resource.go deleted file mode 100644 index 95b42f2d..00000000 --- a/internal/features/system/data/ent/resource.go +++ /dev/null @@ -1,355 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "encoding/json" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "strings" - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" -) - -// Resource table -type Resource struct { - config `json:"-"` - // ID of the ent. - // ID - ID int64 `json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime time.Time `json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime time.Time `json:"update_time,omitempty"` - // Name - Name string `json:"name,omitempty"` - // Keyword - Keyword string `json:"keyword,omitempty"` - // Type - Type string `json:"type,omitempty"` - // Status - Status int8 `json:"status,omitempty"` - // Path - Path string `json:"path,omitempty"` - // Component - Component string `json:"component,omitempty"` - // Icon - Icon string `json:"icon,omitempty"` - // Sequence - Sequence int `json:"sequence,omitempty"` - // Visible - Visible bool `json:"visible,omitempty"` - // Level - Level int8 `json:"level,omitempty"` - // Tree path - TreePath string `json:"tree_path,omitempty"` - // Properties - Properties map[string]string `json:"properties,omitempty"` - // Description - Description string `json:"description,omitempty"` - // Parent ID - ParentID int64 `json:"parent_id,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the ResourceQuery when eager-loading is set. - Edges ResourceEdges `json:"edges"` - selectValues sql.SelectValues -} - -// ResourceEdges holds the relations/edges for other nodes in the graph. -type ResourceEdges struct { - // Parent holds the value of the parent edge. - Parent *Resource `json:"parent,omitempty"` - // Children holds the value of the children edge. - Children []*Resource `json:"children,omitempty"` - // Permissions holds the value of the permissions edge. - Permissions []*Permission `json:"permissions,omitempty"` - // PermissionResources holds the value of the permission_resources edge. - PermissionResources []*PermissionResource `json:"permission_resources,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [4]bool -} - -// ParentOrErr returns the Parent value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e ResourceEdges) ParentOrErr() (*Resource, error) { - if e.Parent != nil { - return e.Parent, nil - } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: resource.Label} - } - return nil, &NotLoadedError{edge: "parent"} -} - -// ChildrenOrErr returns the Children value or an error if the edge -// was not loaded in eager-loading. -func (e ResourceEdges) ChildrenOrErr() ([]*Resource, error) { - if e.loadedTypes[1] { - return e.Children, nil - } - return nil, &NotLoadedError{edge: "children"} -} - -// PermissionsOrErr returns the Permissions value or an error if the edge -// was not loaded in eager-loading. -func (e ResourceEdges) PermissionsOrErr() ([]*Permission, error) { - if e.loadedTypes[2] { - return e.Permissions, nil - } - return nil, &NotLoadedError{edge: "permissions"} -} - -// PermissionResourcesOrErr returns the PermissionResources value or an error if the edge -// was not loaded in eager-loading. -func (e ResourceEdges) PermissionResourcesOrErr() ([]*PermissionResource, error) { - if e.loadedTypes[3] { - return e.PermissionResources, nil - } - return nil, &NotLoadedError{edge: "permission_resources"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*Resource) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case resource.FieldProperties: - values[i] = new([]byte) - case resource.FieldVisible: - values[i] = new(sql.NullBool) - case resource.FieldID, resource.FieldStatus, resource.FieldSequence, resource.FieldLevel, resource.FieldParentID: - values[i] = new(sql.NullInt64) - case resource.FieldName, resource.FieldKeyword, resource.FieldType, resource.FieldPath, resource.FieldComponent, resource.FieldIcon, resource.FieldTreePath, resource.FieldDescription: - values[i] = new(sql.NullString) - case resource.FieldCreateTime, resource.FieldUpdateTime: - values[i] = new(sql.NullTime) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the Resource fields. -func (_m *Resource) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case resource.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - _m.ID = int64(value.Int64) - case resource.FieldCreateTime: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field create_time", values[i]) - } else if value.Valid { - _m.CreateTime = value.Time - } - case resource.FieldUpdateTime: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field update_time", values[i]) - } else if value.Valid { - _m.UpdateTime = value.Time - } - case resource.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - _m.Name = value.String - } - case resource.FieldKeyword: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field keyword", values[i]) - } else if value.Valid { - _m.Keyword = value.String - } - case resource.FieldType: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field type", values[i]) - } else if value.Valid { - _m.Type = value.String - } - case resource.FieldStatus: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field status", values[i]) - } else if value.Valid { - _m.Status = int8(value.Int64) - } - case resource.FieldPath: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field path", values[i]) - } else if value.Valid { - _m.Path = value.String - } - case resource.FieldComponent: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field component", values[i]) - } else if value.Valid { - _m.Component = value.String - } - case resource.FieldIcon: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field icon", values[i]) - } else if value.Valid { - _m.Icon = value.String - } - case resource.FieldSequence: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field sequence", values[i]) - } else if value.Valid { - _m.Sequence = int(value.Int64) - } - case resource.FieldVisible: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field visible", values[i]) - } else if value.Valid { - _m.Visible = value.Bool - } - case resource.FieldLevel: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field level", values[i]) - } else if value.Valid { - _m.Level = int8(value.Int64) - } - case resource.FieldTreePath: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field tree_path", values[i]) - } else if value.Valid { - _m.TreePath = value.String - } - case resource.FieldProperties: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field properties", values[i]) - } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &_m.Properties); err != nil { - return fmt.Errorf("unmarshal field properties: %w", err) - } - } - case resource.FieldDescription: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field description", values[i]) - } else if value.Valid { - _m.Description = value.String - } - case resource.FieldParentID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field parent_id", values[i]) - } else if value.Valid { - _m.ParentID = value.Int64 - } - default: - _m.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the Resource. -// This includes values selected through modifiers, order, etc. -func (_m *Resource) Value(name string) (ent.Value, error) { - return _m.selectValues.Get(name) -} - -// QueryParent queries the "parent" edge of the Resource entity. -func (_m *Resource) QueryParent() *ResourceQuery { - return NewResourceClient(_m.config).QueryParent(_m) -} - -// QueryChildren queries the "children" edge of the Resource entity. -func (_m *Resource) QueryChildren() *ResourceQuery { - return NewResourceClient(_m.config).QueryChildren(_m) -} - -// QueryPermissions queries the "permissions" edge of the Resource entity. -func (_m *Resource) QueryPermissions() *PermissionQuery { - return NewResourceClient(_m.config).QueryPermissions(_m) -} - -// QueryPermissionResources queries the "permission_resources" edge of the Resource entity. -func (_m *Resource) QueryPermissionResources() *PermissionResourceQuery { - return NewResourceClient(_m.config).QueryPermissionResources(_m) -} - -// Update returns a builder for updating this Resource. -// Note that you need to call Resource.Unwrap() before calling this method if this Resource -// was returned from a transaction, and the transaction was committed or rolled back. -func (_m *Resource) Update() *ResourceUpdateOne { - return NewResourceClient(_m.config).UpdateOne(_m) -} - -// Unwrap unwraps the Resource entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (_m *Resource) Unwrap() *Resource { - _tx, ok := _m.config.driver.(*txDriver) - if !ok { - panic("ent: Resource is not a transactional entity") - } - _m.config.driver = _tx.drv - return _m -} - -// String implements the fmt.Stringer. -func (_m *Resource) String() string { - var builder strings.Builder - builder.WriteString("Resource(") - builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - builder.WriteString("create_time=") - builder.WriteString(_m.CreateTime.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("update_time=") - builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("name=") - builder.WriteString(_m.Name) - builder.WriteString(", ") - builder.WriteString("keyword=") - builder.WriteString(_m.Keyword) - builder.WriteString(", ") - builder.WriteString("type=") - builder.WriteString(_m.Type) - builder.WriteString(", ") - builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", _m.Status)) - builder.WriteString(", ") - builder.WriteString("path=") - builder.WriteString(_m.Path) - builder.WriteString(", ") - builder.WriteString("component=") - builder.WriteString(_m.Component) - builder.WriteString(", ") - builder.WriteString("icon=") - builder.WriteString(_m.Icon) - builder.WriteString(", ") - builder.WriteString("sequence=") - builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) - builder.WriteString(", ") - builder.WriteString("visible=") - builder.WriteString(fmt.Sprintf("%v", _m.Visible)) - builder.WriteString(", ") - builder.WriteString("level=") - builder.WriteString(fmt.Sprintf("%v", _m.Level)) - builder.WriteString(", ") - builder.WriteString("tree_path=") - builder.WriteString(_m.TreePath) - builder.WriteString(", ") - builder.WriteString("properties=") - builder.WriteString(fmt.Sprintf("%v", _m.Properties)) - builder.WriteString(", ") - builder.WriteString("description=") - builder.WriteString(_m.Description) - builder.WriteString(", ") - builder.WriteString("parent_id=") - builder.WriteString(fmt.Sprintf("%v", _m.ParentID)) - builder.WriteByte(')') - return builder.String() -} - -// Resources is a parsable slice of Resource. -type Resources []*Resource diff --git a/internal/features/system/data/ent/resource/resource.go b/internal/features/system/data/ent/resource/resource.go deleted file mode 100644 index eee63d9e..00000000 --- a/internal/features/system/data/ent/resource/resource.go +++ /dev/null @@ -1,385 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package resource - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the resource type in the database. - Label = "resource" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldKeyword holds the string denoting the keyword field in the database. - FieldKeyword = "keyword" - // FieldType holds the string denoting the type field in the database. - FieldType = "type" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" - // FieldPath holds the string denoting the path field in the database. - FieldPath = "path" - // FieldComponent holds the string denoting the component field in the database. - FieldComponent = "component" - // FieldIcon holds the string denoting the icon field in the database. - FieldIcon = "icon" - // FieldSequence holds the string denoting the sequence field in the database. - FieldSequence = "sequence" - // FieldVisible holds the string denoting the visible field in the database. - FieldVisible = "visible" - // FieldLevel holds the string denoting the level field in the database. - FieldLevel = "level" - // FieldTreePath holds the string denoting the tree_path field in the database. - FieldTreePath = "tree_path" - // FieldProperties holds the string denoting the properties field in the database. - FieldProperties = "properties" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldParentID holds the string denoting the parent_id field in the database. - FieldParentID = "parent_id" - // EdgeParent holds the string denoting the parent edge name in mutations. - EdgeParent = "parent" - // EdgeChildren holds the string denoting the children edge name in mutations. - EdgeChildren = "children" - // EdgePermissions holds the string denoting the permissions edge name in mutations. - EdgePermissions = "permissions" - // EdgePermissionResources holds the string denoting the permission_resources edge name in mutations. - EdgePermissionResources = "permission_resources" - // Table holds the table name of the resource in the database. - Table = "sys_resources" - // ParentTable is the table that holds the parent relation/edge. - ParentTable = "sys_resources" - // ParentColumn is the table column denoting the parent relation/edge. - ParentColumn = "parent_id" - // ChildrenTable is the table that holds the children relation/edge. - ChildrenTable = "sys_resources" - // ChildrenColumn is the table column denoting the children relation/edge. - ChildrenColumn = "parent_id" - // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. - PermissionsTable = "sys_permission_resources" - // PermissionsInverseTable is the table name for the Permission entity. - // It exists in this package in order to avoid circular dependency with the "permission" package. - PermissionsInverseTable = "sys_permissions" - // PermissionResourcesTable is the table that holds the permission_resources relation/edge. - PermissionResourcesTable = "sys_permission_resources" - // PermissionResourcesInverseTable is the table name for the PermissionResource entity. - // It exists in this package in order to avoid circular dependency with the "permissionresource" package. - PermissionResourcesInverseTable = "sys_permission_resources" - // PermissionResourcesColumn is the table column denoting the permission_resources relation/edge. - PermissionResourcesColumn = "resource_id" -) - -// Columns holds all SQL columns for resource fields. -var Columns = []string{ - FieldID, - FieldCreateTime, - FieldUpdateTime, - FieldName, - FieldKeyword, - FieldType, - FieldStatus, - FieldPath, - FieldComponent, - FieldIcon, - FieldSequence, - FieldVisible, - FieldLevel, - FieldTreePath, - FieldProperties, - FieldDescription, - FieldParentID, -} - -var ( - // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the - // primary key for the permissions relation (M2M). - PermissionsPrimaryKey = []string{"permission_id", "resource_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() time.Time - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() time.Time - // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. - UpdateDefaultUpdateTime func() time.Time - // DefaultName holds the default value on creation for the "name" field. - DefaultName string - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - KeywordValidator func(string) error - // DefaultType holds the default value on creation for the "type" field. - DefaultType string - // TypeValidator is a validator for the "type" field. It is called by the builders before save. - TypeValidator func(string) error - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 - // DefaultPath holds the default value on creation for the "path" field. - DefaultPath string - // PathValidator is a validator for the "path" field. It is called by the builders before save. - PathValidator func(string) error - // DefaultComponent holds the default value on creation for the "component" field. - DefaultComponent string - // ComponentValidator is a validator for the "component" field. It is called by the builders before save. - ComponentValidator func(string) error - // DefaultIcon holds the default value on creation for the "icon" field. - DefaultIcon string - // IconValidator is a validator for the "icon" field. It is called by the builders before save. - IconValidator func(string) error - // DefaultSequence holds the default value on creation for the "sequence" field. - DefaultSequence int - // DefaultVisible holds the default value on creation for the "visible" field. - DefaultVisible bool - // DefaultLevel holds the default value on creation for the "level" field. - DefaultLevel int8 - // DefaultTreePath holds the default value on creation for the "tree_path" field. - DefaultTreePath string - // TreePathValidator is a validator for the "tree_path" field. It is called by the builders before save. - TreePathValidator func(string) error - // DefaultDescription holds the default value on creation for the "description" field. - DefaultDescription string - // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - DescriptionValidator func(string) error -) - -// OrderOption defines the ordering options for the Resource queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByKeyword orders the results by the keyword field. -func ByKeyword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldKeyword, opts...).ToFunc() -} - -// ByType orders the results by the type field. -func ByType(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldType, opts...).ToFunc() -} - -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - -// ByPath orders the results by the path field. -func ByPath(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPath, opts...).ToFunc() -} - -// ByComponent orders the results by the component field. -func ByComponent(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldComponent, opts...).ToFunc() -} - -// ByIcon orders the results by the icon field. -func ByIcon(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldIcon, opts...).ToFunc() -} - -// BySequence orders the results by the sequence field. -func BySequence(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSequence, opts...).ToFunc() -} - -// ByVisible orders the results by the visible field. -func ByVisible(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldVisible, opts...).ToFunc() -} - -// ByLevel orders the results by the level field. -func ByLevel(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldLevel, opts...).ToFunc() -} - -// ByTreePath orders the results by the tree_path field. -func ByTreePath(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTreePath, opts...).ToFunc() -} - -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() -} - -// ByParentID orders the results by the parent_id field. -func ByParentID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldParentID, opts...).ToFunc() -} - -// ByParentField orders the results by parent field. -func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) - } -} - -// ByChildrenCount orders the results by children count. -func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) - } -} - -// ByChildren orders the results by children terms. -func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPermissionsCount orders the results by permissions count. -func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) - } -} - -// ByPermissions orders the results by permissions terms. -func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPermissionResourcesCount orders the results by permission_resources count. -func ByPermissionResourcesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPermissionResourcesStep(), opts...) - } -} - -// ByPermissionResources orders the results by permission_resources terms. -func ByPermissionResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newParentStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), - ) -} -func newChildrenStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), - ) -} -func newPermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), - ) -} -func newPermissionResourcesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionResourcesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/features/system/data/ent/resource/where.go b/internal/features/system/data/ent/resource/where.go deleted file mode 100644 index 9668d8ef..00000000 --- a/internal/features/system/data/ent/resource/where.go +++ /dev/null @@ -1,1008 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package resource - -import ( - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldID, id)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldUpdateTime, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldName, v)) -} - -// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. -func Keyword(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) -} - -// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. -func Type(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldType, v)) -} - -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldStatus, v)) -} - -// Path applies equality check predicate on the "path" field. It's identical to PathEQ. -func Path(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldPath, v)) -} - -// Component applies equality check predicate on the "component" field. It's identical to ComponentEQ. -func Component(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldComponent, v)) -} - -// Icon applies equality check predicate on the "icon" field. It's identical to IconEQ. -func Icon(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldIcon, v)) -} - -// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. -func Sequence(v int) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldSequence, v)) -} - -// Visible applies equality check predicate on the "visible" field. It's identical to VisibleEQ. -func Visible(v bool) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldVisible, v)) -} - -// Level applies equality check predicate on the "level" field. It's identical to LevelEQ. -func Level(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldLevel, v)) -} - -// TreePath applies equality check predicate on the "tree_path" field. It's identical to TreePathEQ. -func TreePath(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) -} - -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldDescription, v)) -} - -// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ. -func ParentID(v int64) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldParentID, v)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...time.Time) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...time.Time) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldCreateTime, v)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...time.Time) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...time.Time) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v time.Time) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldUpdateTime, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldName, v)) -} - -// KeywordEQ applies the EQ predicate on the "keyword" field. -func KeywordEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) -} - -// KeywordNEQ applies the NEQ predicate on the "keyword" field. -func KeywordNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldKeyword, v)) -} - -// KeywordIn applies the In predicate on the "keyword" field. -func KeywordIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldKeyword, vs...)) -} - -// KeywordNotIn applies the NotIn predicate on the "keyword" field. -func KeywordNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldKeyword, vs...)) -} - -// KeywordGT applies the GT predicate on the "keyword" field. -func KeywordGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldKeyword, v)) -} - -// KeywordGTE applies the GTE predicate on the "keyword" field. -func KeywordGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldKeyword, v)) -} - -// KeywordLT applies the LT predicate on the "keyword" field. -func KeywordLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldKeyword, v)) -} - -// KeywordLTE applies the LTE predicate on the "keyword" field. -func KeywordLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldKeyword, v)) -} - -// KeywordContains applies the Contains predicate on the "keyword" field. -func KeywordContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldKeyword, v)) -} - -// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. -func KeywordHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldKeyword, v)) -} - -// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. -func KeywordHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldKeyword, v)) -} - -// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. -func KeywordEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldKeyword, v)) -} - -// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. -func KeywordContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldKeyword, v)) -} - -// TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldType, v)) -} - -// TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldType, v)) -} - -// TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldType, vs...)) -} - -// TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldType, vs...)) -} - -// TypeGT applies the GT predicate on the "type" field. -func TypeGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldType, v)) -} - -// TypeGTE applies the GTE predicate on the "type" field. -func TypeGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldType, v)) -} - -// TypeLT applies the LT predicate on the "type" field. -func TypeLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldType, v)) -} - -// TypeLTE applies the LTE predicate on the "type" field. -func TypeLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldType, v)) -} - -// TypeContains applies the Contains predicate on the "type" field. -func TypeContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldType, v)) -} - -// TypeHasPrefix applies the HasPrefix predicate on the "type" field. -func TypeHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldType, v)) -} - -// TypeHasSuffix applies the HasSuffix predicate on the "type" field. -func TypeHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldType, v)) -} - -// TypeEqualFold applies the EqualFold predicate on the "type" field. -func TypeEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldType, v)) -} - -// TypeContainsFold applies the ContainsFold predicate on the "type" field. -func TypeContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldType, v)) -} - -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldStatus, vs...)) -} - -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldStatus, v)) -} - -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldStatus, v)) -} - -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldStatus, v)) -} - -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldStatus, v)) -} - -// PathEQ applies the EQ predicate on the "path" field. -func PathEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldPath, v)) -} - -// PathNEQ applies the NEQ predicate on the "path" field. -func PathNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldPath, v)) -} - -// PathIn applies the In predicate on the "path" field. -func PathIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldPath, vs...)) -} - -// PathNotIn applies the NotIn predicate on the "path" field. -func PathNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldPath, vs...)) -} - -// PathGT applies the GT predicate on the "path" field. -func PathGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldPath, v)) -} - -// PathGTE applies the GTE predicate on the "path" field. -func PathGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldPath, v)) -} - -// PathLT applies the LT predicate on the "path" field. -func PathLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldPath, v)) -} - -// PathLTE applies the LTE predicate on the "path" field. -func PathLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldPath, v)) -} - -// PathContains applies the Contains predicate on the "path" field. -func PathContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldPath, v)) -} - -// PathHasPrefix applies the HasPrefix predicate on the "path" field. -func PathHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldPath, v)) -} - -// PathHasSuffix applies the HasSuffix predicate on the "path" field. -func PathHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldPath, v)) -} - -// PathEqualFold applies the EqualFold predicate on the "path" field. -func PathEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldPath, v)) -} - -// PathContainsFold applies the ContainsFold predicate on the "path" field. -func PathContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldPath, v)) -} - -// ComponentEQ applies the EQ predicate on the "component" field. -func ComponentEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldComponent, v)) -} - -// ComponentNEQ applies the NEQ predicate on the "component" field. -func ComponentNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldComponent, v)) -} - -// ComponentIn applies the In predicate on the "component" field. -func ComponentIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldComponent, vs...)) -} - -// ComponentNotIn applies the NotIn predicate on the "component" field. -func ComponentNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldComponent, vs...)) -} - -// ComponentGT applies the GT predicate on the "component" field. -func ComponentGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldComponent, v)) -} - -// ComponentGTE applies the GTE predicate on the "component" field. -func ComponentGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldComponent, v)) -} - -// ComponentLT applies the LT predicate on the "component" field. -func ComponentLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldComponent, v)) -} - -// ComponentLTE applies the LTE predicate on the "component" field. -func ComponentLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldComponent, v)) -} - -// ComponentContains applies the Contains predicate on the "component" field. -func ComponentContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldComponent, v)) -} - -// ComponentHasPrefix applies the HasPrefix predicate on the "component" field. -func ComponentHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldComponent, v)) -} - -// ComponentHasSuffix applies the HasSuffix predicate on the "component" field. -func ComponentHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldComponent, v)) -} - -// ComponentEqualFold applies the EqualFold predicate on the "component" field. -func ComponentEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldComponent, v)) -} - -// ComponentContainsFold applies the ContainsFold predicate on the "component" field. -func ComponentContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldComponent, v)) -} - -// IconEQ applies the EQ predicate on the "icon" field. -func IconEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldIcon, v)) -} - -// IconNEQ applies the NEQ predicate on the "icon" field. -func IconNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldIcon, v)) -} - -// IconIn applies the In predicate on the "icon" field. -func IconIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldIcon, vs...)) -} - -// IconNotIn applies the NotIn predicate on the "icon" field. -func IconNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldIcon, vs...)) -} - -// IconGT applies the GT predicate on the "icon" field. -func IconGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldIcon, v)) -} - -// IconGTE applies the GTE predicate on the "icon" field. -func IconGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldIcon, v)) -} - -// IconLT applies the LT predicate on the "icon" field. -func IconLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldIcon, v)) -} - -// IconLTE applies the LTE predicate on the "icon" field. -func IconLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldIcon, v)) -} - -// IconContains applies the Contains predicate on the "icon" field. -func IconContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldIcon, v)) -} - -// IconHasPrefix applies the HasPrefix predicate on the "icon" field. -func IconHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldIcon, v)) -} - -// IconHasSuffix applies the HasSuffix predicate on the "icon" field. -func IconHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldIcon, v)) -} - -// IconEqualFold applies the EqualFold predicate on the "icon" field. -func IconEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldIcon, v)) -} - -// IconContainsFold applies the ContainsFold predicate on the "icon" field. -func IconContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldIcon, v)) -} - -// SequenceEQ applies the EQ predicate on the "sequence" field. -func SequenceEQ(v int) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldSequence, v)) -} - -// SequenceNEQ applies the NEQ predicate on the "sequence" field. -func SequenceNEQ(v int) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldSequence, v)) -} - -// SequenceIn applies the In predicate on the "sequence" field. -func SequenceIn(vs ...int) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldSequence, vs...)) -} - -// SequenceNotIn applies the NotIn predicate on the "sequence" field. -func SequenceNotIn(vs ...int) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldSequence, vs...)) -} - -// SequenceGT applies the GT predicate on the "sequence" field. -func SequenceGT(v int) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldSequence, v)) -} - -// SequenceGTE applies the GTE predicate on the "sequence" field. -func SequenceGTE(v int) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldSequence, v)) -} - -// SequenceLT applies the LT predicate on the "sequence" field. -func SequenceLT(v int) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldSequence, v)) -} - -// SequenceLTE applies the LTE predicate on the "sequence" field. -func SequenceLTE(v int) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldSequence, v)) -} - -// VisibleEQ applies the EQ predicate on the "visible" field. -func VisibleEQ(v bool) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldVisible, v)) -} - -// VisibleNEQ applies the NEQ predicate on the "visible" field. -func VisibleNEQ(v bool) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldVisible, v)) -} - -// LevelEQ applies the EQ predicate on the "level" field. -func LevelEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldLevel, v)) -} - -// LevelNEQ applies the NEQ predicate on the "level" field. -func LevelNEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldLevel, v)) -} - -// LevelIn applies the In predicate on the "level" field. -func LevelIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldLevel, vs...)) -} - -// LevelNotIn applies the NotIn predicate on the "level" field. -func LevelNotIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldLevel, vs...)) -} - -// LevelGT applies the GT predicate on the "level" field. -func LevelGT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldLevel, v)) -} - -// LevelGTE applies the GTE predicate on the "level" field. -func LevelGTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldLevel, v)) -} - -// LevelLT applies the LT predicate on the "level" field. -func LevelLT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldLevel, v)) -} - -// LevelLTE applies the LTE predicate on the "level" field. -func LevelLTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldLevel, v)) -} - -// TreePathEQ applies the EQ predicate on the "tree_path" field. -func TreePathEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) -} - -// TreePathNEQ applies the NEQ predicate on the "tree_path" field. -func TreePathNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldTreePath, v)) -} - -// TreePathIn applies the In predicate on the "tree_path" field. -func TreePathIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldTreePath, vs...)) -} - -// TreePathNotIn applies the NotIn predicate on the "tree_path" field. -func TreePathNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldTreePath, vs...)) -} - -// TreePathGT applies the GT predicate on the "tree_path" field. -func TreePathGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldTreePath, v)) -} - -// TreePathGTE applies the GTE predicate on the "tree_path" field. -func TreePathGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldTreePath, v)) -} - -// TreePathLT applies the LT predicate on the "tree_path" field. -func TreePathLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldTreePath, v)) -} - -// TreePathLTE applies the LTE predicate on the "tree_path" field. -func TreePathLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldTreePath, v)) -} - -// TreePathContains applies the Contains predicate on the "tree_path" field. -func TreePathContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldTreePath, v)) -} - -// TreePathHasPrefix applies the HasPrefix predicate on the "tree_path" field. -func TreePathHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldTreePath, v)) -} - -// TreePathHasSuffix applies the HasSuffix predicate on the "tree_path" field. -func TreePathHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldTreePath, v)) -} - -// TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. -func TreePathEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldTreePath, v)) -} - -// TreePathContainsFold applies the ContainsFold predicate on the "tree_path" field. -func TreePathContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldTreePath, v)) -} - -// PropertiesIsNil applies the IsNil predicate on the "properties" field. -func PropertiesIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldProperties)) -} - -// PropertiesNotNil applies the NotNil predicate on the "properties" field. -func PropertiesNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldProperties)) -} - -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldDescription, v)) -} - -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldDescription, v)) -} - -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldDescription, vs...)) -} - -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldDescription, vs...)) -} - -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldDescription, v)) -} - -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldDescription, v)) -} - -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldDescription, v)) -} - -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldDescription, v)) -} - -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldDescription, v)) -} - -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldDescription, v)) -} - -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldDescription, v)) -} - -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldDescription, v)) -} - -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldDescription, v)) -} - -// ParentIDEQ applies the EQ predicate on the "parent_id" field. -func ParentIDEQ(v int64) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldParentID, v)) -} - -// ParentIDNEQ applies the NEQ predicate on the "parent_id" field. -func ParentIDNEQ(v int64) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldParentID, v)) -} - -// ParentIDIn applies the In predicate on the "parent_id" field. -func ParentIDIn(vs ...int64) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldParentID, vs...)) -} - -// ParentIDNotIn applies the NotIn predicate on the "parent_id" field. -func ParentIDNotIn(vs ...int64) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldParentID, vs...)) -} - -// ParentIDIsNil applies the IsNil predicate on the "parent_id" field. -func ParentIDIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldParentID)) -} - -// ParentIDNotNil applies the NotNil predicate on the "parent_id" field. -func ParentIDNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldParentID)) -} - -// HasParent applies the HasEdge predicate on the "parent" edge. -func HasParent() predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). -func HasParentWith(preds ...predicate.Resource) predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := newParentStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasChildren applies the HasEdge predicate on the "children" edge. -func HasChildren() predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates). -func HasChildrenWith(preds ...predicate.Resource) predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := newChildrenStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermissions applies the HasEdge predicate on the "permissions" edge. -func HasPermissions() predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). -func HasPermissionsWith(preds ...predicate.Permission) predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := newPermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermissionResources applies the HasEdge predicate on the "permission_resources" edge. -func HasPermissionResources() predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionResourcesWith applies the HasEdge predicate on the "permission_resources" edge with a given conditions (other predicates). -func HasPermissionResourcesWith(preds ...predicate.PermissionResource) predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := newPermissionResourcesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Resource) predicate.Resource { - return predicate.Resource(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Resource) predicate.Resource { - return predicate.Resource(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Resource) predicate.Resource { - return predicate.Resource(sql.NotPredicates(p)) -} diff --git a/internal/features/system/data/ent/resource_create.go b/internal/features/system/data/ent/resource_create.go deleted file mode 100644 index b606d5df..00000000 --- a/internal/features/system/data/ent/resource_create.go +++ /dev/null @@ -1,728 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// ResourceCreate is the builder for creating a Resource entity. -type ResourceCreate struct { - config - mutation *ResourceMutation - hooks []Hook -} - -// SetCreateTime sets the "create_time" field. -func (_c *ResourceCreate) SetCreateTime(v time.Time) *ResourceCreate { - _c.mutation.SetCreateTime(v) - return _c -} - -// SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableCreateTime(v *time.Time) *ResourceCreate { - if v != nil { - _c.SetCreateTime(*v) - } - return _c -} - -// SetUpdateTime sets the "update_time" field. -func (_c *ResourceCreate) SetUpdateTime(v time.Time) *ResourceCreate { - _c.mutation.SetUpdateTime(v) - return _c -} - -// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableUpdateTime(v *time.Time) *ResourceCreate { - if v != nil { - _c.SetUpdateTime(*v) - } - return _c -} - -// SetName sets the "name" field. -func (_c *ResourceCreate) SetName(v string) *ResourceCreate { - _c.mutation.SetName(v) - return _c -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableName(v *string) *ResourceCreate { - if v != nil { - _c.SetName(*v) - } - return _c -} - -// SetKeyword sets the "keyword" field. -func (_c *ResourceCreate) SetKeyword(v string) *ResourceCreate { - _c.mutation.SetKeyword(v) - return _c -} - -// SetType sets the "type" field. -func (_c *ResourceCreate) SetType(v string) *ResourceCreate { - _c.mutation.SetType(v) - return _c -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableType(v *string) *ResourceCreate { - if v != nil { - _c.SetType(*v) - } - return _c -} - -// SetStatus sets the "status" field. -func (_c *ResourceCreate) SetStatus(v int8) *ResourceCreate { - _c.mutation.SetStatus(v) - return _c -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableStatus(v *int8) *ResourceCreate { - if v != nil { - _c.SetStatus(*v) - } - return _c -} - -// SetPath sets the "path" field. -func (_c *ResourceCreate) SetPath(v string) *ResourceCreate { - _c.mutation.SetPath(v) - return _c -} - -// SetNillablePath sets the "path" field if the given value is not nil. -func (_c *ResourceCreate) SetNillablePath(v *string) *ResourceCreate { - if v != nil { - _c.SetPath(*v) - } - return _c -} - -// SetComponent sets the "component" field. -func (_c *ResourceCreate) SetComponent(v string) *ResourceCreate { - _c.mutation.SetComponent(v) - return _c -} - -// SetNillableComponent sets the "component" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableComponent(v *string) *ResourceCreate { - if v != nil { - _c.SetComponent(*v) - } - return _c -} - -// SetIcon sets the "icon" field. -func (_c *ResourceCreate) SetIcon(v string) *ResourceCreate { - _c.mutation.SetIcon(v) - return _c -} - -// SetNillableIcon sets the "icon" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableIcon(v *string) *ResourceCreate { - if v != nil { - _c.SetIcon(*v) - } - return _c -} - -// SetSequence sets the "sequence" field. -func (_c *ResourceCreate) SetSequence(v int) *ResourceCreate { - _c.mutation.SetSequence(v) - return _c -} - -// SetNillableSequence sets the "sequence" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableSequence(v *int) *ResourceCreate { - if v != nil { - _c.SetSequence(*v) - } - return _c -} - -// SetVisible sets the "visible" field. -func (_c *ResourceCreate) SetVisible(v bool) *ResourceCreate { - _c.mutation.SetVisible(v) - return _c -} - -// SetNillableVisible sets the "visible" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableVisible(v *bool) *ResourceCreate { - if v != nil { - _c.SetVisible(*v) - } - return _c -} - -// SetLevel sets the "level" field. -func (_c *ResourceCreate) SetLevel(v int8) *ResourceCreate { - _c.mutation.SetLevel(v) - return _c -} - -// SetNillableLevel sets the "level" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableLevel(v *int8) *ResourceCreate { - if v != nil { - _c.SetLevel(*v) - } - return _c -} - -// SetTreePath sets the "tree_path" field. -func (_c *ResourceCreate) SetTreePath(v string) *ResourceCreate { - _c.mutation.SetTreePath(v) - return _c -} - -// SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableTreePath(v *string) *ResourceCreate { - if v != nil { - _c.SetTreePath(*v) - } - return _c -} - -// SetProperties sets the "properties" field. -func (_c *ResourceCreate) SetProperties(v map[string]string) *ResourceCreate { - _c.mutation.SetProperties(v) - return _c -} - -// SetDescription sets the "description" field. -func (_c *ResourceCreate) SetDescription(v string) *ResourceCreate { - _c.mutation.SetDescription(v) - return _c -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableDescription(v *string) *ResourceCreate { - if v != nil { - _c.SetDescription(*v) - } - return _c -} - -// SetParentID sets the "parent_id" field. -func (_c *ResourceCreate) SetParentID(v int64) *ResourceCreate { - _c.mutation.SetParentID(v) - return _c -} - -// SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableParentID(v *int64) *ResourceCreate { - if v != nil { - _c.SetParentID(*v) - } - return _c -} - -// SetID sets the "id" field. -func (_c *ResourceCreate) SetID(v int64) *ResourceCreate { - _c.mutation.SetID(v) - return _c -} - -// SetParent sets the "parent" edge to the Resource entity. -func (_c *ResourceCreate) SetParent(v *Resource) *ResourceCreate { - return _c.SetParentID(v.ID) -} - -// AddChildIDs adds the "children" edge to the Resource entity by IDs. -func (_c *ResourceCreate) AddChildIDs(ids ...int64) *ResourceCreate { - _c.mutation.AddChildIDs(ids...) - return _c -} - -// AddChildren adds the "children" edges to the Resource entity. -func (_c *ResourceCreate) AddChildren(v ...*Resource) *ResourceCreate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddChildIDs(ids...) -} - -// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (_c *ResourceCreate) AddPermissionIDs(ids ...int64) *ResourceCreate { - _c.mutation.AddPermissionIDs(ids...) - return _c -} - -// AddPermissions adds the "permissions" edges to the Permission entity. -func (_c *ResourceCreate) AddPermissions(v ...*Permission) *ResourceCreate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddPermissionIDs(ids...) -} - -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (_c *ResourceCreate) AddPermissionResourceIDs(ids ...int) *ResourceCreate { - _c.mutation.AddPermissionResourceIDs(ids...) - return _c -} - -// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (_c *ResourceCreate) AddPermissionResources(v ...*PermissionResource) *ResourceCreate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddPermissionResourceIDs(ids...) -} - -// Mutation returns the ResourceMutation object of the builder. -func (_c *ResourceCreate) Mutation() *ResourceMutation { - return _c.mutation -} - -// Save creates the Resource in the database. -func (_c *ResourceCreate) Save(ctx context.Context) (*Resource, error) { - _c.defaults() - return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (_c *ResourceCreate) SaveX(ctx context.Context) *Resource { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *ResourceCreate) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *ResourceCreate) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_c *ResourceCreate) defaults() { - if _, ok := _c.mutation.CreateTime(); !ok { - v := resource.DefaultCreateTime() - _c.mutation.SetCreateTime(v) - } - if _, ok := _c.mutation.UpdateTime(); !ok { - v := resource.DefaultUpdateTime() - _c.mutation.SetUpdateTime(v) - } - if _, ok := _c.mutation.Name(); !ok { - v := resource.DefaultName - _c.mutation.SetName(v) - } - if _, ok := _c.mutation.GetType(); !ok { - v := resource.DefaultType - _c.mutation.SetType(v) - } - if _, ok := _c.mutation.Status(); !ok { - v := resource.DefaultStatus - _c.mutation.SetStatus(v) - } - if _, ok := _c.mutation.Path(); !ok { - v := resource.DefaultPath - _c.mutation.SetPath(v) - } - if _, ok := _c.mutation.Component(); !ok { - v := resource.DefaultComponent - _c.mutation.SetComponent(v) - } - if _, ok := _c.mutation.Icon(); !ok { - v := resource.DefaultIcon - _c.mutation.SetIcon(v) - } - if _, ok := _c.mutation.Sequence(); !ok { - v := resource.DefaultSequence - _c.mutation.SetSequence(v) - } - if _, ok := _c.mutation.Visible(); !ok { - v := resource.DefaultVisible - _c.mutation.SetVisible(v) - } - if _, ok := _c.mutation.Level(); !ok { - v := resource.DefaultLevel - _c.mutation.SetLevel(v) - } - if _, ok := _c.mutation.TreePath(); !ok { - v := resource.DefaultTreePath - _c.mutation.SetTreePath(v) - } - if _, ok := _c.mutation.Description(); !ok { - v := resource.DefaultDescription - _c.mutation.SetDescription(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_c *ResourceCreate) check() error { - if _, ok := _c.mutation.CreateTime(); !ok { - return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Resource.create_time"`)} - } - if _, ok := _c.mutation.UpdateTime(); !ok { - return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Resource.update_time"`)} - } - if _, ok := _c.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Resource.name"`)} - } - if v, ok := _c.mutation.Name(); ok { - if err := resource.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} - } - } - if _, ok := _c.mutation.Keyword(); !ok { - return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Resource.keyword"`)} - } - if v, ok := _c.mutation.Keyword(); ok { - if err := resource.KeywordValidator(v); err != nil { - return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} - } - } - if _, ok := _c.mutation.GetType(); !ok { - return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Resource.type"`)} - } - if v, ok := _c.mutation.GetType(); ok { - if err := resource.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} - } - } - if _, ok := _c.mutation.Status(); !ok { - return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Resource.status"`)} - } - if _, ok := _c.mutation.Path(); !ok { - return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "Resource.path"`)} - } - if v, ok := _c.mutation.Path(); ok { - if err := resource.PathValidator(v); err != nil { - return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} - } - } - if _, ok := _c.mutation.Component(); !ok { - return &ValidationError{Name: "component", err: errors.New(`ent: missing required field "Resource.component"`)} - } - if v, ok := _c.mutation.Component(); ok { - if err := resource.ComponentValidator(v); err != nil { - return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} - } - } - if _, ok := _c.mutation.Icon(); !ok { - return &ValidationError{Name: "icon", err: errors.New(`ent: missing required field "Resource.icon"`)} - } - if v, ok := _c.mutation.Icon(); ok { - if err := resource.IconValidator(v); err != nil { - return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} - } - } - if _, ok := _c.mutation.Sequence(); !ok { - return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "Resource.sequence"`)} - } - if _, ok := _c.mutation.Visible(); !ok { - return &ValidationError{Name: "visible", err: errors.New(`ent: missing required field "Resource.visible"`)} - } - if _, ok := _c.mutation.Level(); !ok { - return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "Resource.level"`)} - } - if _, ok := _c.mutation.TreePath(); !ok { - return &ValidationError{Name: "tree_path", err: errors.New(`ent: missing required field "Resource.tree_path"`)} - } - if v, ok := _c.mutation.TreePath(); ok { - if err := resource.TreePathValidator(v); err != nil { - return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} - } - } - if _, ok := _c.mutation.Description(); !ok { - return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Resource.description"`)} - } - if v, ok := _c.mutation.Description(); ok { - if err := resource.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} - } - } - return nil -} - -func (_c *ResourceCreate) sqlSave(ctx context.Context) (*Resource, error) { - if err := _c.check(); err != nil { - return nil, err - } - _node, _spec := _c.createSpec() - if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != _node.ID { - id := _spec.ID.Value.(int64) - _node.ID = int64(id) - } - _c.mutation.id = &_node.ID - _c.mutation.done = true - return _node, nil -} - -func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { - var ( - _node = &Resource{config: _c.config} - _spec = sqlgraph.NewCreateSpec(resource.Table, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) - ) - if id, ok := _c.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = id - } - if value, ok := _c.mutation.CreateTime(); ok { - _spec.SetField(resource.FieldCreateTime, field.TypeTime, value) - _node.CreateTime = value - } - if value, ok := _c.mutation.UpdateTime(); ok { - _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) - _node.UpdateTime = value - } - if value, ok := _c.mutation.Name(); ok { - _spec.SetField(resource.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := _c.mutation.Keyword(); ok { - _spec.SetField(resource.FieldKeyword, field.TypeString, value) - _node.Keyword = value - } - if value, ok := _c.mutation.GetType(); ok { - _spec.SetField(resource.FieldType, field.TypeString, value) - _node.Type = value - } - if value, ok := _c.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeInt8, value) - _node.Status = value - } - if value, ok := _c.mutation.Path(); ok { - _spec.SetField(resource.FieldPath, field.TypeString, value) - _node.Path = value - } - if value, ok := _c.mutation.Component(); ok { - _spec.SetField(resource.FieldComponent, field.TypeString, value) - _node.Component = value - } - if value, ok := _c.mutation.Icon(); ok { - _spec.SetField(resource.FieldIcon, field.TypeString, value) - _node.Icon = value - } - if value, ok := _c.mutation.Sequence(); ok { - _spec.SetField(resource.FieldSequence, field.TypeInt, value) - _node.Sequence = value - } - if value, ok := _c.mutation.Visible(); ok { - _spec.SetField(resource.FieldVisible, field.TypeBool, value) - _node.Visible = value - } - if value, ok := _c.mutation.Level(); ok { - _spec.SetField(resource.FieldLevel, field.TypeInt8, value) - _node.Level = value - } - if value, ok := _c.mutation.TreePath(); ok { - _spec.SetField(resource.FieldTreePath, field.TypeString, value) - _node.TreePath = value - } - if value, ok := _c.mutation.Properties(); ok { - _spec.SetField(resource.FieldProperties, field.TypeJSON, value) - _node.Properties = value - } - if value, ok := _c.mutation.Description(); ok { - _spec.SetField(resource.FieldDescription, field.TypeString, value) - _node.Description = value - } - if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: resource.ParentTable, - Columns: []string{resource.ParentColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.ParentID = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: resource.PermissionsTable, - Columns: resource.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.PermissionResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// SetResource set the Resource -func (_c *ResourceCreate) SetResource(input *Resource, fields ...string) *ResourceCreate { - m := _c.mutation - if len(fields) == 0 { - fields = resource.Columns - } - _ = m.SetFields(input, fields...) - return _c -} - -// SetResourceWithZero set the Resource -func (_c *ResourceCreate) SetResourceWithZero(input *Resource, fields ...string) *ResourceCreate { - m := _c.mutation - if len(fields) == 0 { - fields = resource.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return _c -} - -// ResourceCreateBulk is the builder for creating many Resource entities in bulk. -type ResourceCreateBulk struct { - config - err error - builders []*ResourceCreate -} - -// Save creates the Resource entities in the database. -func (_c *ResourceCreateBulk) Save(ctx context.Context) ([]*Resource, error) { - if _c.err != nil { - return nil, _c.err - } - specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*Resource, len(_c.builders)) - mutators := make([]Mutator, len(_c.builders)) - for i := range _c.builders { - func(i int, root context.Context) { - builder := _c.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*ResourceMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil && nodes[i].ID == 0 { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int64(id) - } - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (_c *ResourceCreateBulk) SaveX(ctx context.Context) []*Resource { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *ResourceCreateBulk) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *ResourceCreateBulk) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/resource_delete.go b/internal/features/system/data/ent/resource_delete.go deleted file mode 100644 index bd09d5eb..00000000 --- a/internal/features/system/data/ent/resource_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/resource" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// ResourceDelete is the builder for deleting a Resource entity. -type ResourceDelete struct { - config - hooks []Hook - mutation *ResourceMutation -} - -// Where appends a list predicates to the ResourceDelete builder. -func (_d *ResourceDelete) Where(ps ...predicate.Resource) *ResourceDelete { - _d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (_d *ResourceDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *ResourceDelete) ExecX(ctx context.Context) int { - n, err := _d.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (_d *ResourceDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(resource.Table, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) - if ps := _d.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - _d.mutation.done = true - return affected, err -} - -// ResourceDeleteOne is the builder for deleting a single Resource entity. -type ResourceDeleteOne struct { - _d *ResourceDelete -} - -// Where appends a list predicates to the ResourceDelete builder. -func (_d *ResourceDeleteOne) Where(ps ...predicate.Resource) *ResourceDeleteOne { - _d._d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query. -func (_d *ResourceDeleteOne) Exec(ctx context.Context) error { - n, err := _d._d.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{resource.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *ResourceDeleteOne) ExecX(ctx context.Context) { - if err := _d.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/resource_query.go b/internal/features/system/data/ent/resource_query.go deleted file mode 100644 index 8278f88a..00000000 --- a/internal/features/system/data/ent/resource_query.go +++ /dev/null @@ -1,970 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/resource" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// ResourceQuery is the builder for querying Resource entities. -type ResourceQuery struct { - config - ctx *QueryContext - order []resource.OrderOption - inters []Interceptor - predicates []predicate.Resource - withParent *ResourceQuery - withChildren *ResourceQuery - withPermissions *PermissionQuery - withPermissionResources *PermissionResourceQuery - modifiers []func(*sql.Selector) - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the ResourceQuery builder. -func (_q *ResourceQuery) Where(ps ...predicate.Resource) *ResourceQuery { - _q.predicates = append(_q.predicates, ps...) - return _q -} - -// Limit the number of records to be returned by this query. -func (_q *ResourceQuery) Limit(limit int) *ResourceQuery { - _q.ctx.Limit = &limit - return _q -} - -// Offset to start from. -func (_q *ResourceQuery) Offset(offset int) *ResourceQuery { - _q.ctx.Offset = &offset - return _q -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (_q *ResourceQuery) Unique(unique bool) *ResourceQuery { - _q.ctx.Unique = &unique - return _q -} - -// Order specifies how the records should be ordered. -func (_q *ResourceQuery) Order(o ...resource.OrderOption) *ResourceQuery { - _q.order = append(_q.order, o...) - return _q -} - -// QueryParent chains the current query on the "parent" edge. -func (_q *ResourceQuery) QueryParent() *ResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, selector), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, resource.ParentTable, resource.ParentColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryChildren chains the current query on the "children" edge. -func (_q *ResourceQuery) QueryChildren() *ResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, selector), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, resource.ChildrenTable, resource.ChildrenColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryPermissions chains the current query on the "permissions" edge. -func (_q *ResourceQuery) QueryPermissions() *PermissionQuery { - query := (&PermissionClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, selector), - sqlgraph.To(permission.Table, permission.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, resource.PermissionsTable, resource.PermissionsPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryPermissionResources chains the current query on the "permission_resources" edge. -func (_q *ResourceQuery) QueryPermissionResources() *PermissionResourceQuery { - query := (&PermissionResourceClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, selector), - sqlgraph.To(permissionresource.Table, permissionresource.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, resource.PermissionResourcesTable, resource.PermissionResourcesColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Resource entity from the query. -// Returns a *NotFoundError when no Resource was found. -func (_q *ResourceQuery) First(ctx context.Context) (*Resource, error) { - nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{resource.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (_q *ResourceQuery) FirstX(ctx context.Context) *Resource { - node, err := _q.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first Resource ID from the query. -// Returns a *NotFoundError when no Resource ID was found. -func (_q *ResourceQuery) FirstID(ctx context.Context) (id int64, err error) { - var ids []int64 - if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{resource.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (_q *ResourceQuery) FirstIDX(ctx context.Context) int64 { - id, err := _q.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single Resource entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one Resource entity is found. -// Returns a *NotFoundError when no Resource entities are found. -func (_q *ResourceQuery) Only(ctx context.Context) (*Resource, error) { - nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{resource.Label} - default: - return nil, &NotSingularError{resource.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (_q *ResourceQuery) OnlyX(ctx context.Context) *Resource { - node, err := _q.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only Resource ID in the query. -// Returns a *NotSingularError when more than one Resource ID is found. -// Returns a *NotFoundError when no entities are found. -func (_q *ResourceQuery) OnlyID(ctx context.Context) (id int64, err error) { - var ids []int64 - if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{resource.Label} - default: - err = &NotSingularError{resource.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *ResourceQuery) OnlyIDX(ctx context.Context) int64 { - id, err := _q.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Resources. -func (_q *ResourceQuery) All(ctx context.Context) ([]*Resource, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*Resource, *ResourceQuery]() - return withInterceptors[[]*Resource](ctx, _q, qr, _q.inters) -} - -// AllX is like All, but panics if an error occurs. -func (_q *ResourceQuery) AllX(ctx context.Context) []*Resource { - nodes, err := _q.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of Resource IDs. -func (_q *ResourceQuery) IDs(ctx context.Context) (ids []int64, err error) { - if _q.ctx.Unique == nil && _q.path != nil { - _q.Unique(true) - } - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(resource.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (_q *ResourceQuery) IDsX(ctx context.Context) []int64 { - ids, err := _q.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (_q *ResourceQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) - if err := _q.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, _q, querierCount[*ResourceQuery](), _q.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (_q *ResourceQuery) CountX(ctx context.Context) int { - count, err := _q.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (_q *ResourceQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) - switch _, err := _q.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - -// ExistX is like Exist, but panics if an error occurs. -func (_q *ResourceQuery) ExistX(ctx context.Context) bool { - exist, err := _q.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the ResourceQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (_q *ResourceQuery) Clone() *ResourceQuery { - if _q == nil { - return nil - } - return &ResourceQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]resource.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.Resource{}, _q.predicates...), - withParent: _q.withParent.Clone(), - withChildren: _q.withChildren.Clone(), - withPermissions: _q.withPermissions.Clone(), - withPermissionResources: _q.withPermissionResources.Clone(), - // clone intermediate query. - sql: _q.sql.Clone(), - path: _q.path, - modifiers: append([]func(*sql.Selector){}, _q.modifiers...), - } -} - -// WithParent tells the query-builder to eager-load the nodes that are connected to -// the "parent" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *ResourceQuery) WithParent(opts ...func(*ResourceQuery)) *ResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withParent = query - return _q -} - -// WithChildren tells the query-builder to eager-load the nodes that are connected to -// the "children" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *ResourceQuery) WithChildren(opts ...func(*ResourceQuery)) *ResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withChildren = query - return _q -} - -// WithPermissions tells the query-builder to eager-load the nodes that are connected to -// the "permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *ResourceQuery) WithPermissions(opts ...func(*PermissionQuery)) *ResourceQuery { - query := (&PermissionClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withPermissions = query - return _q -} - -// WithPermissionResources tells the query-builder to eager-load the nodes that are connected to -// the "permission_resources" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *ResourceQuery) WithPermissionResources(opts ...func(*PermissionResourceQuery)) *ResourceQuery { - query := (&PermissionResourceClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withPermissionResources = query - return _q -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.Resource.Query(). -// GroupBy(resource.FieldCreateTime). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (_q *ResourceQuery) GroupBy(field string, fields ...string) *ResourceGroupBy { - _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &ResourceGroupBy{build: _q} - grbuild.flds = &_q.ctx.Fields - grbuild.label = resource.Label - grbuild.scan = grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// } -// -// client.Resource.Query(). -// Select(resource.FieldCreateTime). -// Scan(ctx, &v) -func (_q *ResourceQuery) Select(fields ...string) *ResourceSelect { - _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &ResourceSelect{ResourceQuery: _q} - sbuild.label = resource.Label - sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a ResourceSelect configured with the given aggregations. -func (_q *ResourceQuery) Aggregate(fns ...AggregateFunc) *ResourceSelect { - return _q.Select().Aggregate(fns...) -} - -func (_q *ResourceQuery) prepareQuery(ctx context.Context) error { - for _, inter := range _q.inters { - if inter == nil { - return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") - } - if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, _q); err != nil { - return err - } - } - } - for _, f := range _q.ctx.Fields { - if !resource.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if _q.path != nil { - prev, err := _q.path(ctx) - if err != nil { - return err - } - _q.sql = prev - } - return nil -} - -func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Resource, error) { - var ( - nodes = []*Resource{} - _spec = _q.querySpec() - loadedTypes = [4]bool{ - _q.withParent != nil, - _q.withChildren != nil, - _q.withPermissions != nil, - _q.withPermissionResources != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*Resource).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &Resource{config: _q.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := _q.withParent; query != nil { - if err := _q.loadParent(ctx, query, nodes, nil, - func(n *Resource, e *Resource) { n.Edges.Parent = e }); err != nil { - return nil, err - } - } - if query := _q.withChildren; query != nil { - if err := _q.loadChildren(ctx, query, nodes, - func(n *Resource) { n.Edges.Children = []*Resource{} }, - func(n *Resource, e *Resource) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil { - return nil, err - } - } - if query := _q.withPermissions; query != nil { - if err := _q.loadPermissions(ctx, query, nodes, - func(n *Resource) { n.Edges.Permissions = []*Permission{} }, - func(n *Resource, e *Permission) { n.Edges.Permissions = append(n.Edges.Permissions, e) }); err != nil { - return nil, err - } - } - if query := _q.withPermissionResources; query != nil { - if err := _q.loadPermissionResources(ctx, query, nodes, - func(n *Resource) { n.Edges.PermissionResources = []*PermissionResource{} }, - func(n *Resource, e *PermissionResource) { - n.Edges.PermissionResources = append(n.Edges.PermissionResources, e) - }); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (_q *ResourceQuery) loadParent(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { - ids := make([]int64, 0, len(nodes)) - nodeids := make(map[int64][]*Resource) - for i := range nodes { - fk := nodes[i].ParentID - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(resource.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "parent_id" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} -func (_q *ResourceQuery) loadChildren(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int64]*Resource) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(resource.FieldParentID) - } - query.Where(predicate.Resource(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(resource.ChildrenColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.ParentID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "parent_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} -func (_q *ResourceQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Permission)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int64]*Resource) - nids := make(map[int64]map[*Resource]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(resource.PermissionsTable) - s.Join(joinT).On(s.C(permission.FieldID), joinT.C(resource.PermissionsPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(resource.PermissionsPrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(resource.PermissionsPrimaryKey[1])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(sql.NullInt64)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := values[0].(*sql.NullInt64).Int64 - inValue := values[1].(*sql.NullInt64).Int64 - if nids[inValue] == nil { - nids[inValue] = map[*Resource]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Permission](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "permissions" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (_q *ResourceQuery) loadPermissionResources(ctx context.Context, query *PermissionResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *PermissionResource)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int64]*Resource) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(permissionresource.FieldResourceID) - } - query.Where(predicate.PermissionResource(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(resource.PermissionResourcesColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.ResourceID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "resource_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} - -func (_q *ResourceQuery) sqlCount(ctx context.Context) (int, error) { - _spec := _q.querySpec() - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - _spec.Node.Columns = _q.ctx.Fields - if len(_q.ctx.Fields) > 0 { - _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique - } - return sqlgraph.CountNodes(ctx, _q.driver, _spec) -} - -func (_q *ResourceQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(resource.Table, resource.Columns, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) - _spec.From = _q.sql - if unique := _q.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if _q.path != nil { - _spec.Unique = true - } - if fields := _q.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, resource.FieldID) - for i := range fields { - if fields[i] != resource.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - if _q.withParent != nil { - _spec.Node.AddColumnOnce(resource.FieldParentID) - } - } - if ps := _q.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := _q.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := _q.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := _q.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (_q *ResourceQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(resource.Table) - columns := _q.ctx.Fields - if len(columns) == 0 { - columns = resource.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if _q.sql != nil { - selector = _q.sql - selector.Select(selector.Columns(columns...)...) - } - if _q.ctx.Unique != nil && *_q.ctx.Unique { - selector.Distinct() - } - for _, m := range _q.modifiers { - m(selector) - } - for _, p := range _q.predicates { - p(selector) - } - for _, p := range _q.order { - p(selector) - } - if offset := _q.ctx.Offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := _q.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// ForUpdate locks the selected rows against concurrent updates, and prevent them from being -// updated, deleted or "selected ... for update" by other sessions, until the transaction is -// either committed or rolled-back. -func (_q *ResourceQuery) ForUpdate(opts ...sql.LockOption) *ResourceQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForUpdate(opts...) - }) - return _q -} - -// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock -// on any rows that are read. Other sessions can read the rows, but cannot modify them -// until your transaction commits. -func (_q *ResourceQuery) ForShare(opts ...sql.LockOption) *ResourceQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForShare(opts...) - }) - return _q -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_q *ResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *ResourceSelect { - _q.modifiers = append(_q.modifiers, modifiers...) - return _q.Select() -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// UpdateTime time.Time `json:"update_time,omitempty"` -// Name string `json:"name,omitempty"` -// Keyword string `json:"keyword,omitempty"` -// Type string `json:"type,omitempty"` -// Status int8 `json:"status,omitempty"` -// Path string `json:"path,omitempty"` -// Component string `json:"component,omitempty"` -// Icon string `json:"icon,omitempty"` -// Sequence int `json:"sequence,omitempty"` -// Visible bool `json:"visible,omitempty"` -// Level int8 `json:"level,omitempty"` -// TreePath string `json:"tree_path,omitempty"` -// Properties map[string]string `json:"properties,omitempty"` -// Description string `json:"description,omitempty"` -// ParentID int64 `json:"parent_id,omitempty"` -// } -// -// client.Resource.Query(). -// Omit( -// resource.FieldCreateTime, -// resource.FieldUpdateTime, -// resource.FieldName, -// resource.FieldKeyword, -// resource.FieldType, -// resource.FieldStatus, -// resource.FieldPath, -// resource.FieldComponent, -// resource.FieldIcon, -// resource.FieldSequence, -// resource.FieldVisible, -// resource.FieldLevel, -// resource.FieldTreePath, -// resource.FieldProperties, -// resource.FieldDescription, -// resource.FieldParentID, -// ). -// Scan(ctx, &v) -func (rq *ResourceQuery) Omit(fields ...string) *ResourceSelect { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - for _, col := range resource.Columns { - if _, ok := omits[col]; !ok { - rq.ctx.Fields = append(rq.ctx.Fields, col) - } - } - - sbuild := &ResourceSelect{ResourceQuery: rq} - sbuild.label = resource.Label - sbuild.flds, sbuild.scan = &rq.ctx.Fields, sbuild.Scan - return sbuild -} - -// ResourceGroupBy is the group-by builder for Resource entities. -type ResourceGroupBy struct { - selector - build *ResourceQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (_g *ResourceGroupBy) Aggregate(fns ...AggregateFunc) *ResourceGroupBy { - _g.fns = append(_g.fns, fns...) - return _g -} - -// Scan applies the selector query and scans the result into the given value. -func (_g *ResourceGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) - if err := _g.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*ResourceQuery, *ResourceGroupBy](ctx, _g.build, _g, _g.build.inters, v) -} - -func (_g *ResourceGroupBy) sqlScan(ctx context.Context, root *ResourceQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(_g.fns)) - for _, fn := range _g.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) - for _, f := range *_g.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*_g.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// ResourceSelect is the builder for selecting fields of Resource entities. -type ResourceSelect struct { - *ResourceQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (_s *ResourceSelect) Aggregate(fns ...AggregateFunc) *ResourceSelect { - _s.fns = append(_s.fns, fns...) - return _s -} - -// Scan applies the selector query and scans the result into the given value. -func (_s *ResourceSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) - if err := _s.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*ResourceQuery, *ResourceSelect](ctx, _s.ResourceQuery, _s, _s.inters, v) -} - -func (_s *ResourceSelect) sqlScan(ctx context.Context, root *ResourceQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(_s.fns)) - for _, fn := range _s.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*_s.selector.flds); { - case n == 0 && len(aggregation) > 0: - selector.Select(aggregation...) - case n != 0 && len(aggregation) > 0: - selector.AppendSelect(aggregation...) - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _s.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_s *ResourceSelect) Modify(modifiers ...func(s *sql.Selector)) *ResourceSelect { - _s.modifiers = append(_s.modifiers, modifiers...) - return _s -} diff --git a/internal/features/system/data/ent/resource_update.go b/internal/features/system/data/ent/resource_update.go deleted file mode 100644 index fa1defcf..00000000 --- a/internal/features/system/data/ent/resource_update.go +++ /dev/null @@ -1,1492 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/permissionresource" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// ResourceUpdate is the builder for updating Resource entities. -type ResourceUpdate struct { - config - hooks []Hook - mutation *ResourceMutation - modifiers []func(*sql.UpdateBuilder) -} - -// Where appends a list predicates to the ResourceUpdate builder. -func (_u *ResourceUpdate) Where(ps ...predicate.Resource) *ResourceUpdate { - _u.mutation.Where(ps...) - return _u -} - -// SetUpdateTime sets the "update_time" field. -func (_u *ResourceUpdate) SetUpdateTime(v time.Time) *ResourceUpdate { - _u.mutation.SetUpdateTime(v) - return _u -} - -// SetName sets the "name" field. -func (_u *ResourceUpdate) SetName(v string) *ResourceUpdate { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableName(v *string) *ResourceUpdate { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetKeyword sets the "keyword" field. -func (_u *ResourceUpdate) SetKeyword(v string) *ResourceUpdate { - _u.mutation.SetKeyword(v) - return _u -} - -// SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableKeyword(v *string) *ResourceUpdate { - if v != nil { - _u.SetKeyword(*v) - } - return _u -} - -// SetType sets the "type" field. -func (_u *ResourceUpdate) SetType(v string) *ResourceUpdate { - _u.mutation.SetType(v) - return _u -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableType(v *string) *ResourceUpdate { - if v != nil { - _u.SetType(*v) - } - return _u -} - -// SetStatus sets the "status" field. -func (_u *ResourceUpdate) SetStatus(v int8) *ResourceUpdate { - _u.mutation.ResetStatus() - _u.mutation.SetStatus(v) - return _u -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableStatus(v *int8) *ResourceUpdate { - if v != nil { - _u.SetStatus(*v) - } - return _u -} - -// AddStatus adds value to the "status" field. -func (_u *ResourceUpdate) AddStatus(v int8) *ResourceUpdate { - _u.mutation.AddStatus(v) - return _u -} - -// SetPath sets the "path" field. -func (_u *ResourceUpdate) SetPath(v string) *ResourceUpdate { - _u.mutation.SetPath(v) - return _u -} - -// SetNillablePath sets the "path" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillablePath(v *string) *ResourceUpdate { - if v != nil { - _u.SetPath(*v) - } - return _u -} - -// SetComponent sets the "component" field. -func (_u *ResourceUpdate) SetComponent(v string) *ResourceUpdate { - _u.mutation.SetComponent(v) - return _u -} - -// SetNillableComponent sets the "component" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableComponent(v *string) *ResourceUpdate { - if v != nil { - _u.SetComponent(*v) - } - return _u -} - -// SetIcon sets the "icon" field. -func (_u *ResourceUpdate) SetIcon(v string) *ResourceUpdate { - _u.mutation.SetIcon(v) - return _u -} - -// SetNillableIcon sets the "icon" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableIcon(v *string) *ResourceUpdate { - if v != nil { - _u.SetIcon(*v) - } - return _u -} - -// SetSequence sets the "sequence" field. -func (_u *ResourceUpdate) SetSequence(v int) *ResourceUpdate { - _u.mutation.ResetSequence() - _u.mutation.SetSequence(v) - return _u -} - -// SetNillableSequence sets the "sequence" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableSequence(v *int) *ResourceUpdate { - if v != nil { - _u.SetSequence(*v) - } - return _u -} - -// AddSequence adds value to the "sequence" field. -func (_u *ResourceUpdate) AddSequence(v int) *ResourceUpdate { - _u.mutation.AddSequence(v) - return _u -} - -// SetVisible sets the "visible" field. -func (_u *ResourceUpdate) SetVisible(v bool) *ResourceUpdate { - _u.mutation.SetVisible(v) - return _u -} - -// SetNillableVisible sets the "visible" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableVisible(v *bool) *ResourceUpdate { - if v != nil { - _u.SetVisible(*v) - } - return _u -} - -// SetLevel sets the "level" field. -func (_u *ResourceUpdate) SetLevel(v int8) *ResourceUpdate { - _u.mutation.ResetLevel() - _u.mutation.SetLevel(v) - return _u -} - -// SetNillableLevel sets the "level" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableLevel(v *int8) *ResourceUpdate { - if v != nil { - _u.SetLevel(*v) - } - return _u -} - -// AddLevel adds value to the "level" field. -func (_u *ResourceUpdate) AddLevel(v int8) *ResourceUpdate { - _u.mutation.AddLevel(v) - return _u -} - -// SetTreePath sets the "tree_path" field. -func (_u *ResourceUpdate) SetTreePath(v string) *ResourceUpdate { - _u.mutation.SetTreePath(v) - return _u -} - -// SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableTreePath(v *string) *ResourceUpdate { - if v != nil { - _u.SetTreePath(*v) - } - return _u -} - -// SetProperties sets the "properties" field. -func (_u *ResourceUpdate) SetProperties(v map[string]string) *ResourceUpdate { - _u.mutation.SetProperties(v) - return _u -} - -// ClearProperties clears the value of the "properties" field. -func (_u *ResourceUpdate) ClearProperties() *ResourceUpdate { - _u.mutation.ClearProperties() - return _u -} - -// SetDescription sets the "description" field. -func (_u *ResourceUpdate) SetDescription(v string) *ResourceUpdate { - _u.mutation.SetDescription(v) - return _u -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableDescription(v *string) *ResourceUpdate { - if v != nil { - _u.SetDescription(*v) - } - return _u -} - -// SetParentID sets the "parent_id" field. -func (_u *ResourceUpdate) SetParentID(v int64) *ResourceUpdate { - _u.mutation.SetParentID(v) - return _u -} - -// SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableParentID(v *int64) *ResourceUpdate { - if v != nil { - _u.SetParentID(*v) - } - return _u -} - -// ClearParentID clears the value of the "parent_id" field. -func (_u *ResourceUpdate) ClearParentID() *ResourceUpdate { - _u.mutation.ClearParentID() - return _u -} - -// SetParent sets the "parent" edge to the Resource entity. -func (_u *ResourceUpdate) SetParent(v *Resource) *ResourceUpdate { - return _u.SetParentID(v.ID) -} - -// AddChildIDs adds the "children" edge to the Resource entity by IDs. -func (_u *ResourceUpdate) AddChildIDs(ids ...int64) *ResourceUpdate { - _u.mutation.AddChildIDs(ids...) - return _u -} - -// AddChildren adds the "children" edges to the Resource entity. -func (_u *ResourceUpdate) AddChildren(v ...*Resource) *ResourceUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddChildIDs(ids...) -} - -// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (_u *ResourceUpdate) AddPermissionIDs(ids ...int64) *ResourceUpdate { - _u.mutation.AddPermissionIDs(ids...) - return _u -} - -// AddPermissions adds the "permissions" edges to the Permission entity. -func (_u *ResourceUpdate) AddPermissions(v ...*Permission) *ResourceUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddPermissionIDs(ids...) -} - -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (_u *ResourceUpdate) AddPermissionResourceIDs(ids ...int) *ResourceUpdate { - _u.mutation.AddPermissionResourceIDs(ids...) - return _u -} - -// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (_u *ResourceUpdate) AddPermissionResources(v ...*PermissionResource) *ResourceUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddPermissionResourceIDs(ids...) -} - -// Mutation returns the ResourceMutation object of the builder. -func (_u *ResourceUpdate) Mutation() *ResourceMutation { - return _u.mutation -} - -// ClearParent clears the "parent" edge to the Resource entity. -func (_u *ResourceUpdate) ClearParent() *ResourceUpdate { - _u.mutation.ClearParent() - return _u -} - -// ClearChildren clears all "children" edges to the Resource entity. -func (_u *ResourceUpdate) ClearChildren() *ResourceUpdate { - _u.mutation.ClearChildren() - return _u -} - -// RemoveChildIDs removes the "children" edge to Resource entities by IDs. -func (_u *ResourceUpdate) RemoveChildIDs(ids ...int64) *ResourceUpdate { - _u.mutation.RemoveChildIDs(ids...) - return _u -} - -// RemoveChildren removes "children" edges to Resource entities. -func (_u *ResourceUpdate) RemoveChildren(v ...*Resource) *ResourceUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveChildIDs(ids...) -} - -// ClearPermissions clears all "permissions" edges to the Permission entity. -func (_u *ResourceUpdate) ClearPermissions() *ResourceUpdate { - _u.mutation.ClearPermissions() - return _u -} - -// RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. -func (_u *ResourceUpdate) RemovePermissionIDs(ids ...int64) *ResourceUpdate { - _u.mutation.RemovePermissionIDs(ids...) - return _u -} - -// RemovePermissions removes "permissions" edges to Permission entities. -func (_u *ResourceUpdate) RemovePermissions(v ...*Permission) *ResourceUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemovePermissionIDs(ids...) -} - -// ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. -func (_u *ResourceUpdate) ClearPermissionResources() *ResourceUpdate { - _u.mutation.ClearPermissionResources() - return _u -} - -// RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. -func (_u *ResourceUpdate) RemovePermissionResourceIDs(ids ...int) *ResourceUpdate { - _u.mutation.RemovePermissionResourceIDs(ids...) - return _u -} - -// RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. -func (_u *ResourceUpdate) RemovePermissionResources(v ...*PermissionResource) *ResourceUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemovePermissionResourceIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (_u *ResourceUpdate) Save(ctx context.Context) (int, error) { - _u.defaults() - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *ResourceUpdate) SaveX(ctx context.Context) int { - affected, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (_u *ResourceUpdate) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *ResourceUpdate) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *ResourceUpdate) defaults() { - if _, ok := _u.mutation.UpdateTime(); !ok { - v := resource.UpdateDefaultUpdateTime() - _u.mutation.SetUpdateTime(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *ResourceUpdate) check() error { - if v, ok := _u.mutation.Name(); ok { - if err := resource.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} - } - } - if v, ok := _u.mutation.Keyword(); ok { - if err := resource.KeywordValidator(v); err != nil { - return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} - } - } - if v, ok := _u.mutation.GetType(); ok { - if err := resource.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} - } - } - if v, ok := _u.mutation.Path(); ok { - if err := resource.PathValidator(v); err != nil { - return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} - } - } - if v, ok := _u.mutation.Component(); ok { - if err := resource.ComponentValidator(v); err != nil { - return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} - } - } - if v, ok := _u.mutation.Icon(); ok { - if err := resource.IconValidator(v); err != nil { - return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} - } - } - if v, ok := _u.mutation.TreePath(); ok { - if err := resource.TreePathValidator(v); err != nil { - return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} - } - } - if v, ok := _u.mutation.Description(); ok { - if err := resource.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} - } - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *ResourceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ResourceUpdate { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(resource.Table, resource.Columns, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.UpdateTime(); ok { - _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(resource.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Keyword(); ok { - _spec.SetField(resource.FieldKeyword, field.TypeString, value) - } - if value, ok := _u.mutation.GetType(); ok { - _spec.SetField(resource.FieldType, field.TypeString, value) - } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedStatus(); ok { - _spec.AddField(resource.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.Path(); ok { - _spec.SetField(resource.FieldPath, field.TypeString, value) - } - if value, ok := _u.mutation.Component(); ok { - _spec.SetField(resource.FieldComponent, field.TypeString, value) - } - if value, ok := _u.mutation.Icon(); ok { - _spec.SetField(resource.FieldIcon, field.TypeString, value) - } - if value, ok := _u.mutation.Sequence(); ok { - _spec.SetField(resource.FieldSequence, field.TypeInt, value) - } - if value, ok := _u.mutation.AddedSequence(); ok { - _spec.AddField(resource.FieldSequence, field.TypeInt, value) - } - if value, ok := _u.mutation.Visible(); ok { - _spec.SetField(resource.FieldVisible, field.TypeBool, value) - } - if value, ok := _u.mutation.Level(); ok { - _spec.SetField(resource.FieldLevel, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedLevel(); ok { - _spec.AddField(resource.FieldLevel, field.TypeInt8, value) - } - if value, ok := _u.mutation.TreePath(); ok { - _spec.SetField(resource.FieldTreePath, field.TypeString, value) - } - if value, ok := _u.mutation.Properties(); ok { - _spec.SetField(resource.FieldProperties, field.TypeJSON, value) - } - if _u.mutation.PropertiesCleared() { - _spec.ClearField(resource.FieldProperties, field.TypeJSON) - } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(resource.FieldDescription, field.TypeString, value) - } - if _u.mutation.ParentCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: resource.ParentTable, - Columns: []string{resource.ParentColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: resource.ParentTable, - Columns: []string{resource.ParentColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.ChildrenCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.PermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: resource.PermissionsTable, - Columns: resource.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: resource.PermissionsTable, - Columns: resource.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: resource.PermissionsTable, - Columns: resource.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{resource.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - _u.mutation.done = true - return _node, nil -} - -// ResourceUpdateOne is the builder for updating a single Resource entity. -type ResourceUpdateOne struct { - config - fields []string - hooks []Hook - mutation *ResourceMutation - modifiers []func(*sql.UpdateBuilder) -} - -// SetUpdateTime sets the "update_time" field. -func (_u *ResourceUpdateOne) SetUpdateTime(v time.Time) *ResourceUpdateOne { - _u.mutation.SetUpdateTime(v) - return _u -} - -// SetName sets the "name" field. -func (_u *ResourceUpdateOne) SetName(v string) *ResourceUpdateOne { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableName(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetKeyword sets the "keyword" field. -func (_u *ResourceUpdateOne) SetKeyword(v string) *ResourceUpdateOne { - _u.mutation.SetKeyword(v) - return _u -} - -// SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableKeyword(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetKeyword(*v) - } - return _u -} - -// SetType sets the "type" field. -func (_u *ResourceUpdateOne) SetType(v string) *ResourceUpdateOne { - _u.mutation.SetType(v) - return _u -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableType(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetType(*v) - } - return _u -} - -// SetStatus sets the "status" field. -func (_u *ResourceUpdateOne) SetStatus(v int8) *ResourceUpdateOne { - _u.mutation.ResetStatus() - _u.mutation.SetStatus(v) - return _u -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableStatus(v *int8) *ResourceUpdateOne { - if v != nil { - _u.SetStatus(*v) - } - return _u -} - -// AddStatus adds value to the "status" field. -func (_u *ResourceUpdateOne) AddStatus(v int8) *ResourceUpdateOne { - _u.mutation.AddStatus(v) - return _u -} - -// SetPath sets the "path" field. -func (_u *ResourceUpdateOne) SetPath(v string) *ResourceUpdateOne { - _u.mutation.SetPath(v) - return _u -} - -// SetNillablePath sets the "path" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillablePath(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetPath(*v) - } - return _u -} - -// SetComponent sets the "component" field. -func (_u *ResourceUpdateOne) SetComponent(v string) *ResourceUpdateOne { - _u.mutation.SetComponent(v) - return _u -} - -// SetNillableComponent sets the "component" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableComponent(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetComponent(*v) - } - return _u -} - -// SetIcon sets the "icon" field. -func (_u *ResourceUpdateOne) SetIcon(v string) *ResourceUpdateOne { - _u.mutation.SetIcon(v) - return _u -} - -// SetNillableIcon sets the "icon" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableIcon(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetIcon(*v) - } - return _u -} - -// SetSequence sets the "sequence" field. -func (_u *ResourceUpdateOne) SetSequence(v int) *ResourceUpdateOne { - _u.mutation.ResetSequence() - _u.mutation.SetSequence(v) - return _u -} - -// SetNillableSequence sets the "sequence" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableSequence(v *int) *ResourceUpdateOne { - if v != nil { - _u.SetSequence(*v) - } - return _u -} - -// AddSequence adds value to the "sequence" field. -func (_u *ResourceUpdateOne) AddSequence(v int) *ResourceUpdateOne { - _u.mutation.AddSequence(v) - return _u -} - -// SetVisible sets the "visible" field. -func (_u *ResourceUpdateOne) SetVisible(v bool) *ResourceUpdateOne { - _u.mutation.SetVisible(v) - return _u -} - -// SetNillableVisible sets the "visible" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableVisible(v *bool) *ResourceUpdateOne { - if v != nil { - _u.SetVisible(*v) - } - return _u -} - -// SetLevel sets the "level" field. -func (_u *ResourceUpdateOne) SetLevel(v int8) *ResourceUpdateOne { - _u.mutation.ResetLevel() - _u.mutation.SetLevel(v) - return _u -} - -// SetNillableLevel sets the "level" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableLevel(v *int8) *ResourceUpdateOne { - if v != nil { - _u.SetLevel(*v) - } - return _u -} - -// AddLevel adds value to the "level" field. -func (_u *ResourceUpdateOne) AddLevel(v int8) *ResourceUpdateOne { - _u.mutation.AddLevel(v) - return _u -} - -// SetTreePath sets the "tree_path" field. -func (_u *ResourceUpdateOne) SetTreePath(v string) *ResourceUpdateOne { - _u.mutation.SetTreePath(v) - return _u -} - -// SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableTreePath(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetTreePath(*v) - } - return _u -} - -// SetProperties sets the "properties" field. -func (_u *ResourceUpdateOne) SetProperties(v map[string]string) *ResourceUpdateOne { - _u.mutation.SetProperties(v) - return _u -} - -// ClearProperties clears the value of the "properties" field. -func (_u *ResourceUpdateOne) ClearProperties() *ResourceUpdateOne { - _u.mutation.ClearProperties() - return _u -} - -// SetDescription sets the "description" field. -func (_u *ResourceUpdateOne) SetDescription(v string) *ResourceUpdateOne { - _u.mutation.SetDescription(v) - return _u -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableDescription(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetDescription(*v) - } - return _u -} - -// SetParentID sets the "parent_id" field. -func (_u *ResourceUpdateOne) SetParentID(v int64) *ResourceUpdateOne { - _u.mutation.SetParentID(v) - return _u -} - -// SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableParentID(v *int64) *ResourceUpdateOne { - if v != nil { - _u.SetParentID(*v) - } - return _u -} - -// ClearParentID clears the value of the "parent_id" field. -func (_u *ResourceUpdateOne) ClearParentID() *ResourceUpdateOne { - _u.mutation.ClearParentID() - return _u -} - -// SetParent sets the "parent" edge to the Resource entity. -func (_u *ResourceUpdateOne) SetParent(v *Resource) *ResourceUpdateOne { - return _u.SetParentID(v.ID) -} - -// AddChildIDs adds the "children" edge to the Resource entity by IDs. -func (_u *ResourceUpdateOne) AddChildIDs(ids ...int64) *ResourceUpdateOne { - _u.mutation.AddChildIDs(ids...) - return _u -} - -// AddChildren adds the "children" edges to the Resource entity. -func (_u *ResourceUpdateOne) AddChildren(v ...*Resource) *ResourceUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddChildIDs(ids...) -} - -// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (_u *ResourceUpdateOne) AddPermissionIDs(ids ...int64) *ResourceUpdateOne { - _u.mutation.AddPermissionIDs(ids...) - return _u -} - -// AddPermissions adds the "permissions" edges to the Permission entity. -func (_u *ResourceUpdateOne) AddPermissions(v ...*Permission) *ResourceUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddPermissionIDs(ids...) -} - -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (_u *ResourceUpdateOne) AddPermissionResourceIDs(ids ...int) *ResourceUpdateOne { - _u.mutation.AddPermissionResourceIDs(ids...) - return _u -} - -// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (_u *ResourceUpdateOne) AddPermissionResources(v ...*PermissionResource) *ResourceUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddPermissionResourceIDs(ids...) -} - -// Mutation returns the ResourceMutation object of the builder. -func (_u *ResourceUpdateOne) Mutation() *ResourceMutation { - return _u.mutation -} - -// ClearParent clears the "parent" edge to the Resource entity. -func (_u *ResourceUpdateOne) ClearParent() *ResourceUpdateOne { - _u.mutation.ClearParent() - return _u -} - -// ClearChildren clears all "children" edges to the Resource entity. -func (_u *ResourceUpdateOne) ClearChildren() *ResourceUpdateOne { - _u.mutation.ClearChildren() - return _u -} - -// RemoveChildIDs removes the "children" edge to Resource entities by IDs. -func (_u *ResourceUpdateOne) RemoveChildIDs(ids ...int64) *ResourceUpdateOne { - _u.mutation.RemoveChildIDs(ids...) - return _u -} - -// RemoveChildren removes "children" edges to Resource entities. -func (_u *ResourceUpdateOne) RemoveChildren(v ...*Resource) *ResourceUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveChildIDs(ids...) -} - -// ClearPermissions clears all "permissions" edges to the Permission entity. -func (_u *ResourceUpdateOne) ClearPermissions() *ResourceUpdateOne { - _u.mutation.ClearPermissions() - return _u -} - -// RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. -func (_u *ResourceUpdateOne) RemovePermissionIDs(ids ...int64) *ResourceUpdateOne { - _u.mutation.RemovePermissionIDs(ids...) - return _u -} - -// RemovePermissions removes "permissions" edges to Permission entities. -func (_u *ResourceUpdateOne) RemovePermissions(v ...*Permission) *ResourceUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemovePermissionIDs(ids...) -} - -// ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. -func (_u *ResourceUpdateOne) ClearPermissionResources() *ResourceUpdateOne { - _u.mutation.ClearPermissionResources() - return _u -} - -// RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. -func (_u *ResourceUpdateOne) RemovePermissionResourceIDs(ids ...int) *ResourceUpdateOne { - _u.mutation.RemovePermissionResourceIDs(ids...) - return _u -} - -// RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. -func (_u *ResourceUpdateOne) RemovePermissionResources(v ...*PermissionResource) *ResourceUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemovePermissionResourceIDs(ids...) -} - -// Where appends a list predicates to the ResourceUpdate builder. -func (_u *ResourceUpdateOne) Where(ps ...predicate.Resource) *ResourceUpdateOne { - _u.mutation.Where(ps...) - return _u -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (_u *ResourceUpdateOne) Select(field string, fields ...string) *ResourceUpdateOne { - _u.fields = append([]string{field}, fields...) - return _u -} - -// Save executes the query and returns the updated Resource entity. -func (_u *ResourceUpdateOne) Save(ctx context.Context) (*Resource, error) { - _u.defaults() - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *ResourceUpdateOne) SaveX(ctx context.Context) *Resource { - node, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (_u *ResourceUpdateOne) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *ResourceUpdateOne) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *ResourceUpdateOne) defaults() { - if _, ok := _u.mutation.UpdateTime(); !ok { - v := resource.UpdateDefaultUpdateTime() - _u.mutation.SetUpdateTime(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *ResourceUpdateOne) check() error { - if v, ok := _u.mutation.Name(); ok { - if err := resource.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} - } - } - if v, ok := _u.mutation.Keyword(); ok { - if err := resource.KeywordValidator(v); err != nil { - return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} - } - } - if v, ok := _u.mutation.GetType(); ok { - if err := resource.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} - } - } - if v, ok := _u.mutation.Path(); ok { - if err := resource.PathValidator(v); err != nil { - return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} - } - } - if v, ok := _u.mutation.Component(); ok { - if err := resource.ComponentValidator(v); err != nil { - return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} - } - } - if v, ok := _u.mutation.Icon(); ok { - if err := resource.IconValidator(v); err != nil { - return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} - } - } - if v, ok := _u.mutation.TreePath(); ok { - if err := resource.TreePathValidator(v); err != nil { - return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} - } - } - if v, ok := _u.mutation.Description(); ok { - if err := resource.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} - } - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *ResourceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ResourceUpdateOne { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(resource.Table, resource.Columns, sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64)) - id, ok := _u.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Resource.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := _u.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, resource.FieldID) - for _, f := range fields { - if !resource.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != resource.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.UpdateTime(); ok { - _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(resource.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Keyword(); ok { - _spec.SetField(resource.FieldKeyword, field.TypeString, value) - } - if value, ok := _u.mutation.GetType(); ok { - _spec.SetField(resource.FieldType, field.TypeString, value) - } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedStatus(); ok { - _spec.AddField(resource.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.Path(); ok { - _spec.SetField(resource.FieldPath, field.TypeString, value) - } - if value, ok := _u.mutation.Component(); ok { - _spec.SetField(resource.FieldComponent, field.TypeString, value) - } - if value, ok := _u.mutation.Icon(); ok { - _spec.SetField(resource.FieldIcon, field.TypeString, value) - } - if value, ok := _u.mutation.Sequence(); ok { - _spec.SetField(resource.FieldSequence, field.TypeInt, value) - } - if value, ok := _u.mutation.AddedSequence(); ok { - _spec.AddField(resource.FieldSequence, field.TypeInt, value) - } - if value, ok := _u.mutation.Visible(); ok { - _spec.SetField(resource.FieldVisible, field.TypeBool, value) - } - if value, ok := _u.mutation.Level(); ok { - _spec.SetField(resource.FieldLevel, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedLevel(); ok { - _spec.AddField(resource.FieldLevel, field.TypeInt8, value) - } - if value, ok := _u.mutation.TreePath(); ok { - _spec.SetField(resource.FieldTreePath, field.TypeString, value) - } - if value, ok := _u.mutation.Properties(); ok { - _spec.SetField(resource.FieldProperties, field.TypeJSON, value) - } - if _u.mutation.PropertiesCleared() { - _spec.ClearField(resource.FieldProperties, field.TypeJSON) - } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(resource.FieldDescription, field.TypeString, value) - } - if _u.mutation.ParentCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: resource.ParentTable, - Columns: []string{resource.ParentColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: resource.ParentTable, - Columns: []string{resource.ParentColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.ChildrenCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.PermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: resource.PermissionsTable, - Columns: resource.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: resource.PermissionsTable, - Columns: resource.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: resource.PermissionsTable, - Columns: resource.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - _node = &Resource{config: _u.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{resource.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - _u.mutation.done = true - return _node, nil -} - -// SetResource set the Resource -func (ru *ResourceUpdate) SetResource(input *Resource, fields ...string) *ResourceUpdate { - m := ru.mutation - if len(fields) == 0 { - fields = resource.OmitColumns(resource.FieldID) - } - _ = m.SetFields(input, fields...) - return ru -} - -// SetResourceWithZero set the Resource -func (ru *ResourceUpdate) SetResourceWithZero(input *Resource, fields ...string) *ResourceUpdate { - m := ru.mutation - if len(fields) == 0 { - fields = resource.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return ru -} - -// SetResource set the Resource -func (ruo *ResourceUpdateOne) SetResource(input *Resource, fields ...string) *ResourceUpdateOne { - m := ruo.mutation - if len(fields) == 0 { - fields = resource.OmitColumns(resource.FieldID) - } - _ = m.SetFields(input, fields...) - return ruo -} - -// SetResourceWithZero set the Resource -func (ruo *ResourceUpdateOne) SetResourceWithZero(input *Resource, fields ...string) *ResourceUpdateOne { - m := ruo.mutation - if len(fields) == 0 { - fields = resource.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return ruo -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -func (ruo *ResourceUpdateOne) Omit(fields ...string) *ResourceUpdateOne { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - ruo.fields = []string(nil) - for _, col := range resource.Columns { - if _, ok := omits[col]; !ok { - ruo.fields = append(ruo.fields, col) - } - } - return ruo -} diff --git a/internal/features/system/data/ent/role.go b/internal/features/system/data/ent/role.go deleted file mode 100644 index f4205e85..00000000 --- a/internal/features/system/data/ent/role.go +++ /dev/null @@ -1,258 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/role" - "strings" - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" -) - -// Role table -type Role struct { - config `json:"-"` - // ID of the ent. - // ID - ID int64 `json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime time.Time `json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime time.Time `json:"update_time,omitempty"` - // keyword of role (unique) - Keyword string `json:"keyword,omitempty"` - // Display name of role - Name string `json:"name,omitempty"` - // Details about role - Description string `json:"description,omitempty"` - // Role type: 1 - System role 2 - User role 3 - Department role - Type int8 `json:"type,omitempty"` - // Sequence for sorting - Sequence int `json:"sequence,omitempty"` - // status - Status int8 `json:"status,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the RoleQuery when eager-loading is set. - Edges RoleEdges `json:"edges"` - selectValues sql.SelectValues -} - -// RoleEdges holds the relations/edges for other nodes in the graph. -type RoleEdges struct { - // Users holds the value of the users edge. - Users []*User `json:"users,omitempty"` - // Permissions holds the value of the permissions edge. - Permissions []*Permission `json:"permissions,omitempty"` - // UserRoles holds the value of the user_roles edge. - UserRoles []*UserRole `json:"user_roles,omitempty"` - // RolePermissions holds the value of the role_permissions edge. - RolePermissions []*RolePermission `json:"role_permissions,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [4]bool -} - -// UsersOrErr returns the Users value or an error if the edge -// was not loaded in eager-loading. -func (e RoleEdges) UsersOrErr() ([]*User, error) { - if e.loadedTypes[0] { - return e.Users, nil - } - return nil, &NotLoadedError{edge: "users"} -} - -// PermissionsOrErr returns the Permissions value or an error if the edge -// was not loaded in eager-loading. -func (e RoleEdges) PermissionsOrErr() ([]*Permission, error) { - if e.loadedTypes[1] { - return e.Permissions, nil - } - return nil, &NotLoadedError{edge: "permissions"} -} - -// UserRolesOrErr returns the UserRoles value or an error if the edge -// was not loaded in eager-loading. -func (e RoleEdges) UserRolesOrErr() ([]*UserRole, error) { - if e.loadedTypes[2] { - return e.UserRoles, nil - } - return nil, &NotLoadedError{edge: "user_roles"} -} - -// RolePermissionsOrErr returns the RolePermissions value or an error if the edge -// was not loaded in eager-loading. -func (e RoleEdges) RolePermissionsOrErr() ([]*RolePermission, error) { - if e.loadedTypes[3] { - return e.RolePermissions, nil - } - return nil, &NotLoadedError{edge: "role_permissions"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*Role) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case role.FieldID, role.FieldType, role.FieldSequence, role.FieldStatus: - values[i] = new(sql.NullInt64) - case role.FieldKeyword, role.FieldName, role.FieldDescription: - values[i] = new(sql.NullString) - case role.FieldCreateTime, role.FieldUpdateTime: - values[i] = new(sql.NullTime) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the Role fields. -func (_m *Role) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case role.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - _m.ID = int64(value.Int64) - case role.FieldCreateTime: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field create_time", values[i]) - } else if value.Valid { - _m.CreateTime = value.Time - } - case role.FieldUpdateTime: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field update_time", values[i]) - } else if value.Valid { - _m.UpdateTime = value.Time - } - case role.FieldKeyword: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field keyword", values[i]) - } else if value.Valid { - _m.Keyword = value.String - } - case role.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - _m.Name = value.String - } - case role.FieldDescription: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field description", values[i]) - } else if value.Valid { - _m.Description = value.String - } - case role.FieldType: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field type", values[i]) - } else if value.Valid { - _m.Type = int8(value.Int64) - } - case role.FieldSequence: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field sequence", values[i]) - } else if value.Valid { - _m.Sequence = int(value.Int64) - } - case role.FieldStatus: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field status", values[i]) - } else if value.Valid { - _m.Status = int8(value.Int64) - } - default: - _m.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the Role. -// This includes values selected through modifiers, order, etc. -func (_m *Role) Value(name string) (ent.Value, error) { - return _m.selectValues.Get(name) -} - -// QueryUsers queries the "users" edge of the Role entity. -func (_m *Role) QueryUsers() *UserQuery { - return NewRoleClient(_m.config).QueryUsers(_m) -} - -// QueryPermissions queries the "permissions" edge of the Role entity. -func (_m *Role) QueryPermissions() *PermissionQuery { - return NewRoleClient(_m.config).QueryPermissions(_m) -} - -// QueryUserRoles queries the "user_roles" edge of the Role entity. -func (_m *Role) QueryUserRoles() *UserRoleQuery { - return NewRoleClient(_m.config).QueryUserRoles(_m) -} - -// QueryRolePermissions queries the "role_permissions" edge of the Role entity. -func (_m *Role) QueryRolePermissions() *RolePermissionQuery { - return NewRoleClient(_m.config).QueryRolePermissions(_m) -} - -// Update returns a builder for updating this Role. -// Note that you need to call Role.Unwrap() before calling this method if this Role -// was returned from a transaction, and the transaction was committed or rolled back. -func (_m *Role) Update() *RoleUpdateOne { - return NewRoleClient(_m.config).UpdateOne(_m) -} - -// Unwrap unwraps the Role entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (_m *Role) Unwrap() *Role { - _tx, ok := _m.config.driver.(*txDriver) - if !ok { - panic("ent: Role is not a transactional entity") - } - _m.config.driver = _tx.drv - return _m -} - -// String implements the fmt.Stringer. -func (_m *Role) String() string { - var builder strings.Builder - builder.WriteString("Role(") - builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - builder.WriteString("create_time=") - builder.WriteString(_m.CreateTime.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("update_time=") - builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("keyword=") - builder.WriteString(_m.Keyword) - builder.WriteString(", ") - builder.WriteString("name=") - builder.WriteString(_m.Name) - builder.WriteString(", ") - builder.WriteString("description=") - builder.WriteString(_m.Description) - builder.WriteString(", ") - builder.WriteString("type=") - builder.WriteString(fmt.Sprintf("%v", _m.Type)) - builder.WriteString(", ") - builder.WriteString("sequence=") - builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) - builder.WriteString(", ") - builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", _m.Status)) - builder.WriteByte(')') - return builder.String() -} - -// Roles is a parsable slice of Role. -type Roles []*Role diff --git a/internal/features/system/data/ent/role/role.go b/internal/features/system/data/ent/role/role.go deleted file mode 100644 index 4ee5d7ce..00000000 --- a/internal/features/system/data/ent/role/role.go +++ /dev/null @@ -1,318 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package role - -import ( - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the role type in the database. - Label = "role" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldKeyword holds the string denoting the keyword field in the database. - FieldKeyword = "keyword" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldType holds the string denoting the type field in the database. - FieldType = "type" - // FieldSequence holds the string denoting the sequence field in the database. - FieldSequence = "sequence" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" - // EdgeUsers holds the string denoting the users edge name in mutations. - EdgeUsers = "users" - // EdgePermissions holds the string denoting the permissions edge name in mutations. - EdgePermissions = "permissions" - // EdgeUserRoles holds the string denoting the user_roles edge name in mutations. - EdgeUserRoles = "user_roles" - // EdgeRolePermissions holds the string denoting the role_permissions edge name in mutations. - EdgeRolePermissions = "role_permissions" - // Table holds the table name of the role in the database. - Table = "sys_roles" - // UsersTable is the table that holds the users relation/edge. The primary key declared below. - UsersTable = "sys_user_roles" - // UsersInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UsersInverseTable = "sys_users" - // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. - PermissionsTable = "sys_role_permissions" - // PermissionsInverseTable is the table name for the Permission entity. - // It exists in this package in order to avoid circular dependency with the "permission" package. - PermissionsInverseTable = "sys_permissions" - // UserRolesTable is the table that holds the user_roles relation/edge. - UserRolesTable = "sys_user_roles" - // UserRolesInverseTable is the table name for the UserRole entity. - // It exists in this package in order to avoid circular dependency with the "userrole" package. - UserRolesInverseTable = "sys_user_roles" - // UserRolesColumn is the table column denoting the user_roles relation/edge. - UserRolesColumn = "role_id" - // RolePermissionsTable is the table that holds the role_permissions relation/edge. - RolePermissionsTable = "sys_role_permissions" - // RolePermissionsInverseTable is the table name for the RolePermission entity. - // It exists in this package in order to avoid circular dependency with the "rolepermission" package. - RolePermissionsInverseTable = "sys_role_permissions" - // RolePermissionsColumn is the table column denoting the role_permissions relation/edge. - RolePermissionsColumn = "role_id" -) - -// Columns holds all SQL columns for role fields. -var Columns = []string{ - FieldID, - FieldCreateTime, - FieldUpdateTime, - FieldKeyword, - FieldName, - FieldDescription, - FieldType, - FieldSequence, - FieldStatus, -} - -var ( - // UsersPrimaryKey and UsersColumn2 are the table columns denoting the - // primary key for the users relation (M2M). - UsersPrimaryKey = []string{"user_id", "role_id"} - // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the - // primary key for the permissions relation (M2M). - PermissionsPrimaryKey = []string{"role_id", "permission_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() time.Time - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() time.Time - // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. - UpdateDefaultUpdateTime func() time.Time - // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - KeywordValidator func(string) error - // DefaultName holds the default value on creation for the "name" field. - DefaultName string - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // DefaultDescription holds the default value on creation for the "description" field. - DefaultDescription string - // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - DescriptionValidator func(string) error - // DefaultType holds the default value on creation for the "type" field. - DefaultType int8 - // DefaultSequence holds the default value on creation for the "sequence" field. - DefaultSequence int - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 -) - -// OrderOption defines the ordering options for the Role queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByKeyword orders the results by the keyword field. -func ByKeyword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldKeyword, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() -} - -// ByType orders the results by the type field. -func ByType(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldType, opts...).ToFunc() -} - -// BySequence orders the results by the sequence field. -func BySequence(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSequence, opts...).ToFunc() -} - -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - -// ByUsersCount orders the results by users count. -func ByUsersCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...) - } -} - -// ByUsers orders the results by users terms. -func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByPermissionsCount orders the results by permissions count. -func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) - } -} - -// ByPermissions orders the results by permissions terms. -func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByUserRolesCount orders the results by user_roles count. -func ByUserRolesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUserRolesStep(), opts...) - } -} - -// ByUserRoles orders the results by user_roles terms. -func ByUserRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserRolesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByRolePermissionsCount orders the results by role_permissions count. -func ByRolePermissionsCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newRolePermissionsStep(), opts...) - } -} - -// ByRolePermissions orders the results by role_permissions terms. -func ByRolePermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRolePermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newUsersStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UsersInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), - ) -} -func newPermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), - ) -} -func newUserRolesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserRolesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), - ) -} -func newRolePermissionsStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RolePermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/features/system/data/ent/role/where.go b/internal/features/system/data/ent/role/where.go deleted file mode 100644 index e037afe8..00000000 --- a/internal/features/system/data/ent/role/where.go +++ /dev/null @@ -1,598 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package role - -import ( - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.Role { - return predicate.Role(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.Role { - return predicate.Role(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.Role { - return predicate.Role(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldID, id)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v time.Time) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v time.Time) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldUpdateTime, v)) -} - -// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. -func Keyword(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldKeyword, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldName, v)) -} - -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldDescription, v)) -} - -// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. -func Type(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldType, v)) -} - -// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. -func Sequence(v int) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldSequence, v)) -} - -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldStatus, v)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v time.Time) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v time.Time) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...time.Time) predicate.Role { - return predicate.Role(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...time.Time) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v time.Time) predicate.Role { - return predicate.Role(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v time.Time) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v time.Time) predicate.Role { - return predicate.Role(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v time.Time) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldCreateTime, v)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v time.Time) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v time.Time) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...time.Time) predicate.Role { - return predicate.Role(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...time.Time) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v time.Time) predicate.Role { - return predicate.Role(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v time.Time) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v time.Time) predicate.Role { - return predicate.Role(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v time.Time) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldUpdateTime, v)) -} - -// KeywordEQ applies the EQ predicate on the "keyword" field. -func KeywordEQ(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldKeyword, v)) -} - -// KeywordNEQ applies the NEQ predicate on the "keyword" field. -func KeywordNEQ(v string) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldKeyword, v)) -} - -// KeywordIn applies the In predicate on the "keyword" field. -func KeywordIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldIn(FieldKeyword, vs...)) -} - -// KeywordNotIn applies the NotIn predicate on the "keyword" field. -func KeywordNotIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldKeyword, vs...)) -} - -// KeywordGT applies the GT predicate on the "keyword" field. -func KeywordGT(v string) predicate.Role { - return predicate.Role(sql.FieldGT(FieldKeyword, v)) -} - -// KeywordGTE applies the GTE predicate on the "keyword" field. -func KeywordGTE(v string) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldKeyword, v)) -} - -// KeywordLT applies the LT predicate on the "keyword" field. -func KeywordLT(v string) predicate.Role { - return predicate.Role(sql.FieldLT(FieldKeyword, v)) -} - -// KeywordLTE applies the LTE predicate on the "keyword" field. -func KeywordLTE(v string) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldKeyword, v)) -} - -// KeywordContains applies the Contains predicate on the "keyword" field. -func KeywordContains(v string) predicate.Role { - return predicate.Role(sql.FieldContains(FieldKeyword, v)) -} - -// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. -func KeywordHasPrefix(v string) predicate.Role { - return predicate.Role(sql.FieldHasPrefix(FieldKeyword, v)) -} - -// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. -func KeywordHasSuffix(v string) predicate.Role { - return predicate.Role(sql.FieldHasSuffix(FieldKeyword, v)) -} - -// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. -func KeywordEqualFold(v string) predicate.Role { - return predicate.Role(sql.FieldEqualFold(FieldKeyword, v)) -} - -// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. -func KeywordContainsFold(v string) predicate.Role { - return predicate.Role(sql.FieldContainsFold(FieldKeyword, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Role { - return predicate.Role(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Role { - return predicate.Role(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Role { - return predicate.Role(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Role { - return predicate.Role(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Role { - return predicate.Role(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Role { - return predicate.Role(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Role { - return predicate.Role(sql.FieldContainsFold(FieldName, v)) -} - -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldDescription, v)) -} - -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldDescription, v)) -} - -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldIn(FieldDescription, vs...)) -} - -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldDescription, vs...)) -} - -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.Role { - return predicate.Role(sql.FieldGT(FieldDescription, v)) -} - -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldDescription, v)) -} - -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.Role { - return predicate.Role(sql.FieldLT(FieldDescription, v)) -} - -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldDescription, v)) -} - -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.Role { - return predicate.Role(sql.FieldContains(FieldDescription, v)) -} - -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.Role { - return predicate.Role(sql.FieldHasPrefix(FieldDescription, v)) -} - -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.Role { - return predicate.Role(sql.FieldHasSuffix(FieldDescription, v)) -} - -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.Role { - return predicate.Role(sql.FieldEqualFold(FieldDescription, v)) -} - -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.Role { - return predicate.Role(sql.FieldContainsFold(FieldDescription, v)) -} - -// TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldType, v)) -} - -// TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldType, v)) -} - -// TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldIn(FieldType, vs...)) -} - -// TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldType, vs...)) -} - -// TypeGT applies the GT predicate on the "type" field. -func TypeGT(v int8) predicate.Role { - return predicate.Role(sql.FieldGT(FieldType, v)) -} - -// TypeGTE applies the GTE predicate on the "type" field. -func TypeGTE(v int8) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldType, v)) -} - -// TypeLT applies the LT predicate on the "type" field. -func TypeLT(v int8) predicate.Role { - return predicate.Role(sql.FieldLT(FieldType, v)) -} - -// TypeLTE applies the LTE predicate on the "type" field. -func TypeLTE(v int8) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldType, v)) -} - -// SequenceEQ applies the EQ predicate on the "sequence" field. -func SequenceEQ(v int) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldSequence, v)) -} - -// SequenceNEQ applies the NEQ predicate on the "sequence" field. -func SequenceNEQ(v int) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldSequence, v)) -} - -// SequenceIn applies the In predicate on the "sequence" field. -func SequenceIn(vs ...int) predicate.Role { - return predicate.Role(sql.FieldIn(FieldSequence, vs...)) -} - -// SequenceNotIn applies the NotIn predicate on the "sequence" field. -func SequenceNotIn(vs ...int) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldSequence, vs...)) -} - -// SequenceGT applies the GT predicate on the "sequence" field. -func SequenceGT(v int) predicate.Role { - return predicate.Role(sql.FieldGT(FieldSequence, v)) -} - -// SequenceGTE applies the GTE predicate on the "sequence" field. -func SequenceGTE(v int) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldSequence, v)) -} - -// SequenceLT applies the LT predicate on the "sequence" field. -func SequenceLT(v int) predicate.Role { - return predicate.Role(sql.FieldLT(FieldSequence, v)) -} - -// SequenceLTE applies the LTE predicate on the "sequence" field. -func SequenceLTE(v int) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldSequence, v)) -} - -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldStatus, vs...)) -} - -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.Role { - return predicate.Role(sql.FieldGT(FieldStatus, v)) -} - -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldStatus, v)) -} - -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.Role { - return predicate.Role(sql.FieldLT(FieldStatus, v)) -} - -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldStatus, v)) -} - -// HasUsers applies the HasEdge predicate on the "users" edge. -func HasUsers() predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUsersWith applies the HasEdge predicate on the "users" edge with a given conditions (other predicates). -func HasUsersWith(preds ...predicate.User) predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := newUsersStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermissions applies the HasEdge predicate on the "permissions" edge. -func HasPermissions() predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). -func HasPermissionsWith(preds ...predicate.Permission) predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := newPermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasUserRoles applies the HasEdge predicate on the "user_roles" edge. -func HasUserRoles() predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserRolesWith applies the HasEdge predicate on the "user_roles" edge with a given conditions (other predicates). -func HasUserRolesWith(preds ...predicate.UserRole) predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := newUserRolesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasRolePermissions applies the HasEdge predicate on the "role_permissions" edge. -func HasRolePermissions() predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, RolePermissionsTable, RolePermissionsColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRolePermissionsWith applies the HasEdge predicate on the "role_permissions" edge with a given conditions (other predicates). -func HasRolePermissionsWith(preds ...predicate.RolePermission) predicate.Role { - return predicate.Role(func(s *sql.Selector) { - step := newRolePermissionsStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.Role) predicate.Role { - return predicate.Role(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.Role) predicate.Role { - return predicate.Role(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.Role) predicate.Role { - return predicate.Role(sql.NotPredicates(p)) -} diff --git a/internal/features/system/data/ent/role_create.go b/internal/features/system/data/ent/role_create.go deleted file mode 100644 index 9a6a9336..00000000 --- a/internal/features/system/data/ent/role_create.go +++ /dev/null @@ -1,540 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// RoleCreate is the builder for creating a Role entity. -type RoleCreate struct { - config - mutation *RoleMutation - hooks []Hook -} - -// SetCreateTime sets the "create_time" field. -func (_c *RoleCreate) SetCreateTime(v time.Time) *RoleCreate { - _c.mutation.SetCreateTime(v) - return _c -} - -// SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (_c *RoleCreate) SetNillableCreateTime(v *time.Time) *RoleCreate { - if v != nil { - _c.SetCreateTime(*v) - } - return _c -} - -// SetUpdateTime sets the "update_time" field. -func (_c *RoleCreate) SetUpdateTime(v time.Time) *RoleCreate { - _c.mutation.SetUpdateTime(v) - return _c -} - -// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (_c *RoleCreate) SetNillableUpdateTime(v *time.Time) *RoleCreate { - if v != nil { - _c.SetUpdateTime(*v) - } - return _c -} - -// SetKeyword sets the "keyword" field. -func (_c *RoleCreate) SetKeyword(v string) *RoleCreate { - _c.mutation.SetKeyword(v) - return _c -} - -// SetName sets the "name" field. -func (_c *RoleCreate) SetName(v string) *RoleCreate { - _c.mutation.SetName(v) - return _c -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_c *RoleCreate) SetNillableName(v *string) *RoleCreate { - if v != nil { - _c.SetName(*v) - } - return _c -} - -// SetDescription sets the "description" field. -func (_c *RoleCreate) SetDescription(v string) *RoleCreate { - _c.mutation.SetDescription(v) - return _c -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_c *RoleCreate) SetNillableDescription(v *string) *RoleCreate { - if v != nil { - _c.SetDescription(*v) - } - return _c -} - -// SetType sets the "type" field. -func (_c *RoleCreate) SetType(v int8) *RoleCreate { - _c.mutation.SetType(v) - return _c -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (_c *RoleCreate) SetNillableType(v *int8) *RoleCreate { - if v != nil { - _c.SetType(*v) - } - return _c -} - -// SetSequence sets the "sequence" field. -func (_c *RoleCreate) SetSequence(v int) *RoleCreate { - _c.mutation.SetSequence(v) - return _c -} - -// SetNillableSequence sets the "sequence" field if the given value is not nil. -func (_c *RoleCreate) SetNillableSequence(v *int) *RoleCreate { - if v != nil { - _c.SetSequence(*v) - } - return _c -} - -// SetStatus sets the "status" field. -func (_c *RoleCreate) SetStatus(v int8) *RoleCreate { - _c.mutation.SetStatus(v) - return _c -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *RoleCreate) SetNillableStatus(v *int8) *RoleCreate { - if v != nil { - _c.SetStatus(*v) - } - return _c -} - -// SetID sets the "id" field. -func (_c *RoleCreate) SetID(v int64) *RoleCreate { - _c.mutation.SetID(v) - return _c -} - -// AddUserIDs adds the "users" edge to the User entity by IDs. -func (_c *RoleCreate) AddUserIDs(ids ...int64) *RoleCreate { - _c.mutation.AddUserIDs(ids...) - return _c -} - -// AddUsers adds the "users" edges to the User entity. -func (_c *RoleCreate) AddUsers(v ...*User) *RoleCreate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddUserIDs(ids...) -} - -// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (_c *RoleCreate) AddPermissionIDs(ids ...int64) *RoleCreate { - _c.mutation.AddPermissionIDs(ids...) - return _c -} - -// AddPermissions adds the "permissions" edges to the Permission entity. -func (_c *RoleCreate) AddPermissions(v ...*Permission) *RoleCreate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddPermissionIDs(ids...) -} - -// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (_c *RoleCreate) AddUserRoleIDs(ids ...int) *RoleCreate { - _c.mutation.AddUserRoleIDs(ids...) - return _c -} - -// AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (_c *RoleCreate) AddUserRoles(v ...*UserRole) *RoleCreate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddUserRoleIDs(ids...) -} - -// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (_c *RoleCreate) AddRolePermissionIDs(ids ...int) *RoleCreate { - _c.mutation.AddRolePermissionIDs(ids...) - return _c -} - -// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (_c *RoleCreate) AddRolePermissions(v ...*RolePermission) *RoleCreate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddRolePermissionIDs(ids...) -} - -// Mutation returns the RoleMutation object of the builder. -func (_c *RoleCreate) Mutation() *RoleMutation { - return _c.mutation -} - -// Save creates the Role in the database. -func (_c *RoleCreate) Save(ctx context.Context) (*Role, error) { - _c.defaults() - return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (_c *RoleCreate) SaveX(ctx context.Context) *Role { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *RoleCreate) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *RoleCreate) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_c *RoleCreate) defaults() { - if _, ok := _c.mutation.CreateTime(); !ok { - v := role.DefaultCreateTime() - _c.mutation.SetCreateTime(v) - } - if _, ok := _c.mutation.UpdateTime(); !ok { - v := role.DefaultUpdateTime() - _c.mutation.SetUpdateTime(v) - } - if _, ok := _c.mutation.Name(); !ok { - v := role.DefaultName - _c.mutation.SetName(v) - } - if _, ok := _c.mutation.Description(); !ok { - v := role.DefaultDescription - _c.mutation.SetDescription(v) - } - if _, ok := _c.mutation.GetType(); !ok { - v := role.DefaultType - _c.mutation.SetType(v) - } - if _, ok := _c.mutation.Sequence(); !ok { - v := role.DefaultSequence - _c.mutation.SetSequence(v) - } - if _, ok := _c.mutation.Status(); !ok { - v := role.DefaultStatus - _c.mutation.SetStatus(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_c *RoleCreate) check() error { - if _, ok := _c.mutation.CreateTime(); !ok { - return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "Role.create_time"`)} - } - if _, ok := _c.mutation.UpdateTime(); !ok { - return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Role.update_time"`)} - } - if _, ok := _c.mutation.Keyword(); !ok { - return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Role.keyword"`)} - } - if v, ok := _c.mutation.Keyword(); ok { - if err := role.KeywordValidator(v); err != nil { - return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Role.keyword": %w`, err)} - } - } - if _, ok := _c.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Role.name"`)} - } - if v, ok := _c.mutation.Name(); ok { - if err := role.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Role.name": %w`, err)} - } - } - if _, ok := _c.mutation.Description(); !ok { - return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Role.description"`)} - } - if v, ok := _c.mutation.Description(); ok { - if err := role.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Role.description": %w`, err)} - } - } - if _, ok := _c.mutation.GetType(); !ok { - return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Role.type"`)} - } - if _, ok := _c.mutation.Sequence(); !ok { - return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "Role.sequence"`)} - } - if _, ok := _c.mutation.Status(); !ok { - return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Role.status"`)} - } - return nil -} - -func (_c *RoleCreate) sqlSave(ctx context.Context) (*Role, error) { - if err := _c.check(); err != nil { - return nil, err - } - _node, _spec := _c.createSpec() - if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != _node.ID { - id := _spec.ID.Value.(int64) - _node.ID = int64(id) - } - _c.mutation.id = &_node.ID - _c.mutation.done = true - return _node, nil -} - -func (_c *RoleCreate) createSpec() (*Role, *sqlgraph.CreateSpec) { - var ( - _node = &Role{config: _c.config} - _spec = sqlgraph.NewCreateSpec(role.Table, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) - ) - if id, ok := _c.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = id - } - if value, ok := _c.mutation.CreateTime(); ok { - _spec.SetField(role.FieldCreateTime, field.TypeTime, value) - _node.CreateTime = value - } - if value, ok := _c.mutation.UpdateTime(); ok { - _spec.SetField(role.FieldUpdateTime, field.TypeTime, value) - _node.UpdateTime = value - } - if value, ok := _c.mutation.Keyword(); ok { - _spec.SetField(role.FieldKeyword, field.TypeString, value) - _node.Keyword = value - } - if value, ok := _c.mutation.Name(); ok { - _spec.SetField(role.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := _c.mutation.Description(); ok { - _spec.SetField(role.FieldDescription, field.TypeString, value) - _node.Description = value - } - if value, ok := _c.mutation.GetType(); ok { - _spec.SetField(role.FieldType, field.TypeInt8, value) - _node.Type = value - } - if value, ok := _c.mutation.Sequence(); ok { - _spec.SetField(role.FieldSequence, field.TypeInt, value) - _node.Sequence = value - } - if value, ok := _c.mutation.Status(); ok { - _spec.SetField(role.FieldStatus, field.TypeInt8, value) - _node.Status = value - } - if nodes := _c.mutation.UsersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: role.UsersTable, - Columns: role.UsersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: role.PermissionsTable, - Columns: role.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.UserRolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.UserRolesTable, - Columns: []string{role.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.RolePermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.RolePermissionsTable, - Columns: []string{role.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// SetRole set the Role -func (_c *RoleCreate) SetRole(input *Role, fields ...string) *RoleCreate { - m := _c.mutation - if len(fields) == 0 { - fields = role.Columns - } - _ = m.SetFields(input, fields...) - return _c -} - -// SetRoleWithZero set the Role -func (_c *RoleCreate) SetRoleWithZero(input *Role, fields ...string) *RoleCreate { - m := _c.mutation - if len(fields) == 0 { - fields = role.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return _c -} - -// RoleCreateBulk is the builder for creating many Role entities in bulk. -type RoleCreateBulk struct { - config - err error - builders []*RoleCreate -} - -// Save creates the Role entities in the database. -func (_c *RoleCreateBulk) Save(ctx context.Context) ([]*Role, error) { - if _c.err != nil { - return nil, _c.err - } - specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*Role, len(_c.builders)) - mutators := make([]Mutator, len(_c.builders)) - for i := range _c.builders { - func(i int, root context.Context) { - builder := _c.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*RoleMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil && nodes[i].ID == 0 { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int64(id) - } - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (_c *RoleCreateBulk) SaveX(ctx context.Context) []*Role { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *RoleCreateBulk) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *RoleCreateBulk) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/role_delete.go b/internal/features/system/data/ent/role_delete.go deleted file mode 100644 index 81c933a9..00000000 --- a/internal/features/system/data/ent/role_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/role" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// RoleDelete is the builder for deleting a Role entity. -type RoleDelete struct { - config - hooks []Hook - mutation *RoleMutation -} - -// Where appends a list predicates to the RoleDelete builder. -func (_d *RoleDelete) Where(ps ...predicate.Role) *RoleDelete { - _d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (_d *RoleDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *RoleDelete) ExecX(ctx context.Context) int { - n, err := _d.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (_d *RoleDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(role.Table, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) - if ps := _d.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - _d.mutation.done = true - return affected, err -} - -// RoleDeleteOne is the builder for deleting a single Role entity. -type RoleDeleteOne struct { - _d *RoleDelete -} - -// Where appends a list predicates to the RoleDelete builder. -func (_d *RoleDeleteOne) Where(ps ...predicate.Role) *RoleDeleteOne { - _d._d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query. -func (_d *RoleDeleteOne) Exec(ctx context.Context) error { - n, err := _d._d.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{role.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *RoleDeleteOne) ExecX(ctx context.Context) { - if err := _d.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/role_query.go b/internal/features/system/data/ent/role_query.go deleted file mode 100644 index 4cfb77b6..00000000 --- a/internal/features/system/data/ent/role_query.go +++ /dev/null @@ -1,984 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// RoleQuery is the builder for querying Role entities. -type RoleQuery struct { - config - ctx *QueryContext - order []role.OrderOption - inters []Interceptor - predicates []predicate.Role - withUsers *UserQuery - withPermissions *PermissionQuery - withUserRoles *UserRoleQuery - withRolePermissions *RolePermissionQuery - modifiers []func(*sql.Selector) - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the RoleQuery builder. -func (_q *RoleQuery) Where(ps ...predicate.Role) *RoleQuery { - _q.predicates = append(_q.predicates, ps...) - return _q -} - -// Limit the number of records to be returned by this query. -func (_q *RoleQuery) Limit(limit int) *RoleQuery { - _q.ctx.Limit = &limit - return _q -} - -// Offset to start from. -func (_q *RoleQuery) Offset(offset int) *RoleQuery { - _q.ctx.Offset = &offset - return _q -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (_q *RoleQuery) Unique(unique bool) *RoleQuery { - _q.ctx.Unique = &unique - return _q -} - -// Order specifies how the records should be ordered. -func (_q *RoleQuery) Order(o ...role.OrderOption) *RoleQuery { - _q.order = append(_q.order, o...) - return _q -} - -// QueryUsers chains the current query on the "users" edge. -func (_q *RoleQuery) QueryUsers() *UserQuery { - query := (&UserClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(role.Table, role.FieldID, selector), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, role.UsersTable, role.UsersPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryPermissions chains the current query on the "permissions" edge. -func (_q *RoleQuery) QueryPermissions() *PermissionQuery { - query := (&PermissionClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(role.Table, role.FieldID, selector), - sqlgraph.To(permission.Table, permission.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, role.PermissionsTable, role.PermissionsPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryUserRoles chains the current query on the "user_roles" edge. -func (_q *RoleQuery) QueryUserRoles() *UserRoleQuery { - query := (&UserRoleClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(role.Table, role.FieldID, selector), - sqlgraph.To(userrole.Table, userrole.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, role.UserRolesTable, role.UserRolesColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryRolePermissions chains the current query on the "role_permissions" edge. -func (_q *RoleQuery) QueryRolePermissions() *RolePermissionQuery { - query := (&RolePermissionClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(role.Table, role.FieldID, selector), - sqlgraph.To(rolepermission.Table, rolepermission.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, role.RolePermissionsTable, role.RolePermissionsColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first Role entity from the query. -// Returns a *NotFoundError when no Role was found. -func (_q *RoleQuery) First(ctx context.Context) (*Role, error) { - nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{role.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (_q *RoleQuery) FirstX(ctx context.Context) *Role { - node, err := _q.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first Role ID from the query. -// Returns a *NotFoundError when no Role ID was found. -func (_q *RoleQuery) FirstID(ctx context.Context) (id int64, err error) { - var ids []int64 - if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{role.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (_q *RoleQuery) FirstIDX(ctx context.Context) int64 { - id, err := _q.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single Role entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one Role entity is found. -// Returns a *NotFoundError when no Role entities are found. -func (_q *RoleQuery) Only(ctx context.Context) (*Role, error) { - nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{role.Label} - default: - return nil, &NotSingularError{role.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (_q *RoleQuery) OnlyX(ctx context.Context) *Role { - node, err := _q.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only Role ID in the query. -// Returns a *NotSingularError when more than one Role ID is found. -// Returns a *NotFoundError when no entities are found. -func (_q *RoleQuery) OnlyID(ctx context.Context) (id int64, err error) { - var ids []int64 - if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{role.Label} - default: - err = &NotSingularError{role.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *RoleQuery) OnlyIDX(ctx context.Context) int64 { - id, err := _q.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Roles. -func (_q *RoleQuery) All(ctx context.Context) ([]*Role, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*Role, *RoleQuery]() - return withInterceptors[[]*Role](ctx, _q, qr, _q.inters) -} - -// AllX is like All, but panics if an error occurs. -func (_q *RoleQuery) AllX(ctx context.Context) []*Role { - nodes, err := _q.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of Role IDs. -func (_q *RoleQuery) IDs(ctx context.Context) (ids []int64, err error) { - if _q.ctx.Unique == nil && _q.path != nil { - _q.Unique(true) - } - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(role.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (_q *RoleQuery) IDsX(ctx context.Context) []int64 { - ids, err := _q.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (_q *RoleQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) - if err := _q.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, _q, querierCount[*RoleQuery](), _q.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (_q *RoleQuery) CountX(ctx context.Context) int { - count, err := _q.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (_q *RoleQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) - switch _, err := _q.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - -// ExistX is like Exist, but panics if an error occurs. -func (_q *RoleQuery) ExistX(ctx context.Context) bool { - exist, err := _q.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the RoleQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (_q *RoleQuery) Clone() *RoleQuery { - if _q == nil { - return nil - } - return &RoleQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]role.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.Role{}, _q.predicates...), - withUsers: _q.withUsers.Clone(), - withPermissions: _q.withPermissions.Clone(), - withUserRoles: _q.withUserRoles.Clone(), - withRolePermissions: _q.withRolePermissions.Clone(), - // clone intermediate query. - sql: _q.sql.Clone(), - path: _q.path, - modifiers: append([]func(*sql.Selector){}, _q.modifiers...), - } -} - -// WithUsers tells the query-builder to eager-load the nodes that are connected to -// the "users" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *RoleQuery) WithUsers(opts ...func(*UserQuery)) *RoleQuery { - query := (&UserClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withUsers = query - return _q -} - -// WithPermissions tells the query-builder to eager-load the nodes that are connected to -// the "permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *RoleQuery) WithPermissions(opts ...func(*PermissionQuery)) *RoleQuery { - query := (&PermissionClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withPermissions = query - return _q -} - -// WithUserRoles tells the query-builder to eager-load the nodes that are connected to -// the "user_roles" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *RoleQuery) WithUserRoles(opts ...func(*UserRoleQuery)) *RoleQuery { - query := (&UserRoleClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withUserRoles = query - return _q -} - -// WithRolePermissions tells the query-builder to eager-load the nodes that are connected to -// the "role_permissions" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *RoleQuery) WithRolePermissions(opts ...func(*RolePermissionQuery)) *RoleQuery { - query := (&RolePermissionClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withRolePermissions = query - return _q -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.Role.Query(). -// GroupBy(role.FieldCreateTime). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (_q *RoleQuery) GroupBy(field string, fields ...string) *RoleGroupBy { - _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &RoleGroupBy{build: _q} - grbuild.flds = &_q.ctx.Fields - grbuild.label = role.Label - grbuild.scan = grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// } -// -// client.Role.Query(). -// Select(role.FieldCreateTime). -// Scan(ctx, &v) -func (_q *RoleQuery) Select(fields ...string) *RoleSelect { - _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &RoleSelect{RoleQuery: _q} - sbuild.label = role.Label - sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a RoleSelect configured with the given aggregations. -func (_q *RoleQuery) Aggregate(fns ...AggregateFunc) *RoleSelect { - return _q.Select().Aggregate(fns...) -} - -func (_q *RoleQuery) prepareQuery(ctx context.Context) error { - for _, inter := range _q.inters { - if inter == nil { - return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") - } - if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, _q); err != nil { - return err - } - } - } - for _, f := range _q.ctx.Fields { - if !role.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if _q.path != nil { - prev, err := _q.path(ctx) - if err != nil { - return err - } - _q.sql = prev - } - return nil -} - -func (_q *RoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Role, error) { - var ( - nodes = []*Role{} - _spec = _q.querySpec() - loadedTypes = [4]bool{ - _q.withUsers != nil, - _q.withPermissions != nil, - _q.withUserRoles != nil, - _q.withRolePermissions != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*Role).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &Role{config: _q.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := _q.withUsers; query != nil { - if err := _q.loadUsers(ctx, query, nodes, - func(n *Role) { n.Edges.Users = []*User{} }, - func(n *Role, e *User) { n.Edges.Users = append(n.Edges.Users, e) }); err != nil { - return nil, err - } - } - if query := _q.withPermissions; query != nil { - if err := _q.loadPermissions(ctx, query, nodes, - func(n *Role) { n.Edges.Permissions = []*Permission{} }, - func(n *Role, e *Permission) { n.Edges.Permissions = append(n.Edges.Permissions, e) }); err != nil { - return nil, err - } - } - if query := _q.withUserRoles; query != nil { - if err := _q.loadUserRoles(ctx, query, nodes, - func(n *Role) { n.Edges.UserRoles = []*UserRole{} }, - func(n *Role, e *UserRole) { n.Edges.UserRoles = append(n.Edges.UserRoles, e) }); err != nil { - return nil, err - } - } - if query := _q.withRolePermissions; query != nil { - if err := _q.loadRolePermissions(ctx, query, nodes, - func(n *Role) { n.Edges.RolePermissions = []*RolePermission{} }, - func(n *Role, e *RolePermission) { n.Edges.RolePermissions = append(n.Edges.RolePermissions, e) }); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (_q *RoleQuery) loadUsers(ctx context.Context, query *UserQuery, nodes []*Role, init func(*Role), assign func(*Role, *User)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int64]*Role) - nids := make(map[int64]map[*Role]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(role.UsersTable) - s.Join(joinT).On(s.C(user.FieldID), joinT.C(role.UsersPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(role.UsersPrimaryKey[1]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(role.UsersPrimaryKey[1])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(sql.NullInt64)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := values[0].(*sql.NullInt64).Int64 - inValue := values[1].(*sql.NullInt64).Int64 - if nids[inValue] == nil { - nids[inValue] = map[*Role]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*User](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "users" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (_q *RoleQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*Role, init func(*Role), assign func(*Role, *Permission)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int64]*Role) - nids := make(map[int64]map[*Role]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(role.PermissionsTable) - s.Join(joinT).On(s.C(permission.FieldID), joinT.C(role.PermissionsPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(role.PermissionsPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(role.PermissionsPrimaryKey[0])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(sql.NullInt64)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := values[0].(*sql.NullInt64).Int64 - inValue := values[1].(*sql.NullInt64).Int64 - if nids[inValue] == nil { - nids[inValue] = map[*Role]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Permission](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "permissions" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (_q *RoleQuery) loadUserRoles(ctx context.Context, query *UserRoleQuery, nodes []*Role, init func(*Role), assign func(*Role, *UserRole)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int64]*Role) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(userrole.FieldRoleID) - } - query.Where(predicate.UserRole(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(role.UserRolesColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.RoleID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "role_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} -func (_q *RoleQuery) loadRolePermissions(ctx context.Context, query *RolePermissionQuery, nodes []*Role, init func(*Role), assign func(*Role, *RolePermission)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int64]*Role) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(rolepermission.FieldRoleID) - } - query.Where(predicate.RolePermission(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(role.RolePermissionsColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.RoleID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "role_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} - -func (_q *RoleQuery) sqlCount(ctx context.Context) (int, error) { - _spec := _q.querySpec() - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - _spec.Node.Columns = _q.ctx.Fields - if len(_q.ctx.Fields) > 0 { - _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique - } - return sqlgraph.CountNodes(ctx, _q.driver, _spec) -} - -func (_q *RoleQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) - _spec.From = _q.sql - if unique := _q.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if _q.path != nil { - _spec.Unique = true - } - if fields := _q.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, role.FieldID) - for i := range fields { - if fields[i] != role.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := _q.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := _q.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := _q.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := _q.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (_q *RoleQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(role.Table) - columns := _q.ctx.Fields - if len(columns) == 0 { - columns = role.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if _q.sql != nil { - selector = _q.sql - selector.Select(selector.Columns(columns...)...) - } - if _q.ctx.Unique != nil && *_q.ctx.Unique { - selector.Distinct() - } - for _, m := range _q.modifiers { - m(selector) - } - for _, p := range _q.predicates { - p(selector) - } - for _, p := range _q.order { - p(selector) - } - if offset := _q.ctx.Offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := _q.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// ForUpdate locks the selected rows against concurrent updates, and prevent them from being -// updated, deleted or "selected ... for update" by other sessions, until the transaction is -// either committed or rolled-back. -func (_q *RoleQuery) ForUpdate(opts ...sql.LockOption) *RoleQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForUpdate(opts...) - }) - return _q -} - -// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock -// on any rows that are read. Other sessions can read the rows, but cannot modify them -// until your transaction commits. -func (_q *RoleQuery) ForShare(opts ...sql.LockOption) *RoleQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForShare(opts...) - }) - return _q -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_q *RoleQuery) Modify(modifiers ...func(s *sql.Selector)) *RoleSelect { - _q.modifiers = append(_q.modifiers, modifiers...) - return _q.Select() -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// UpdateTime time.Time `json:"update_time,omitempty"` -// Keyword string `json:"keyword,omitempty"` -// Name string `json:"name,omitempty"` -// Description string `json:"description,omitempty"` -// Type int8 `json:"type,omitempty"` -// Sequence int `json:"sequence,omitempty"` -// Status int8 `json:"status,omitempty"` -// } -// -// client.Role.Query(). -// Omit( -// role.FieldCreateTime, -// role.FieldUpdateTime, -// role.FieldKeyword, -// role.FieldName, -// role.FieldDescription, -// role.FieldType, -// role.FieldSequence, -// role.FieldStatus, -// ). -// Scan(ctx, &v) -func (rq *RoleQuery) Omit(fields ...string) *RoleSelect { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - for _, col := range role.Columns { - if _, ok := omits[col]; !ok { - rq.ctx.Fields = append(rq.ctx.Fields, col) - } - } - - sbuild := &RoleSelect{RoleQuery: rq} - sbuild.label = role.Label - sbuild.flds, sbuild.scan = &rq.ctx.Fields, sbuild.Scan - return sbuild -} - -// RoleGroupBy is the group-by builder for Role entities. -type RoleGroupBy struct { - selector - build *RoleQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (_g *RoleGroupBy) Aggregate(fns ...AggregateFunc) *RoleGroupBy { - _g.fns = append(_g.fns, fns...) - return _g -} - -// Scan applies the selector query and scans the result into the given value. -func (_g *RoleGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) - if err := _g.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*RoleQuery, *RoleGroupBy](ctx, _g.build, _g, _g.build.inters, v) -} - -func (_g *RoleGroupBy) sqlScan(ctx context.Context, root *RoleQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(_g.fns)) - for _, fn := range _g.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) - for _, f := range *_g.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*_g.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// RoleSelect is the builder for selecting fields of Role entities. -type RoleSelect struct { - *RoleQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (_s *RoleSelect) Aggregate(fns ...AggregateFunc) *RoleSelect { - _s.fns = append(_s.fns, fns...) - return _s -} - -// Scan applies the selector query and scans the result into the given value. -func (_s *RoleSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) - if err := _s.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*RoleQuery, *RoleSelect](ctx, _s.RoleQuery, _s, _s.inters, v) -} - -func (_s *RoleSelect) sqlScan(ctx context.Context, root *RoleQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(_s.fns)) - for _, fn := range _s.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*_s.selector.flds); { - case n == 0 && len(aggregation) > 0: - selector.Select(aggregation...) - case n != 0 && len(aggregation) > 0: - selector.AppendSelect(aggregation...) - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _s.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_s *RoleSelect) Modify(modifiers ...func(s *sql.Selector)) *RoleSelect { - _s.modifiers = append(_s.modifiers, modifiers...) - return _s -} diff --git a/internal/features/system/data/ent/role_update.go b/internal/features/system/data/ent/role_update.go deleted file mode 100644 index c16827d1..00000000 --- a/internal/features/system/data/ent/role_update.go +++ /dev/null @@ -1,1246 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// RoleUpdate is the builder for updating Role entities. -type RoleUpdate struct { - config - hooks []Hook - mutation *RoleMutation - modifiers []func(*sql.UpdateBuilder) -} - -// Where appends a list predicates to the RoleUpdate builder. -func (_u *RoleUpdate) Where(ps ...predicate.Role) *RoleUpdate { - _u.mutation.Where(ps...) - return _u -} - -// SetUpdateTime sets the "update_time" field. -func (_u *RoleUpdate) SetUpdateTime(v time.Time) *RoleUpdate { - _u.mutation.SetUpdateTime(v) - return _u -} - -// SetKeyword sets the "keyword" field. -func (_u *RoleUpdate) SetKeyword(v string) *RoleUpdate { - _u.mutation.SetKeyword(v) - return _u -} - -// SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (_u *RoleUpdate) SetNillableKeyword(v *string) *RoleUpdate { - if v != nil { - _u.SetKeyword(*v) - } - return _u -} - -// SetName sets the "name" field. -func (_u *RoleUpdate) SetName(v string) *RoleUpdate { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *RoleUpdate) SetNillableName(v *string) *RoleUpdate { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetDescription sets the "description" field. -func (_u *RoleUpdate) SetDescription(v string) *RoleUpdate { - _u.mutation.SetDescription(v) - return _u -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *RoleUpdate) SetNillableDescription(v *string) *RoleUpdate { - if v != nil { - _u.SetDescription(*v) - } - return _u -} - -// SetType sets the "type" field. -func (_u *RoleUpdate) SetType(v int8) *RoleUpdate { - _u.mutation.ResetType() - _u.mutation.SetType(v) - return _u -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (_u *RoleUpdate) SetNillableType(v *int8) *RoleUpdate { - if v != nil { - _u.SetType(*v) - } - return _u -} - -// AddType adds value to the "type" field. -func (_u *RoleUpdate) AddType(v int8) *RoleUpdate { - _u.mutation.AddType(v) - return _u -} - -// SetSequence sets the "sequence" field. -func (_u *RoleUpdate) SetSequence(v int) *RoleUpdate { - _u.mutation.ResetSequence() - _u.mutation.SetSequence(v) - return _u -} - -// SetNillableSequence sets the "sequence" field if the given value is not nil. -func (_u *RoleUpdate) SetNillableSequence(v *int) *RoleUpdate { - if v != nil { - _u.SetSequence(*v) - } - return _u -} - -// AddSequence adds value to the "sequence" field. -func (_u *RoleUpdate) AddSequence(v int) *RoleUpdate { - _u.mutation.AddSequence(v) - return _u -} - -// SetStatus sets the "status" field. -func (_u *RoleUpdate) SetStatus(v int8) *RoleUpdate { - _u.mutation.ResetStatus() - _u.mutation.SetStatus(v) - return _u -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *RoleUpdate) SetNillableStatus(v *int8) *RoleUpdate { - if v != nil { - _u.SetStatus(*v) - } - return _u -} - -// AddStatus adds value to the "status" field. -func (_u *RoleUpdate) AddStatus(v int8) *RoleUpdate { - _u.mutation.AddStatus(v) - return _u -} - -// AddUserIDs adds the "users" edge to the User entity by IDs. -func (_u *RoleUpdate) AddUserIDs(ids ...int64) *RoleUpdate { - _u.mutation.AddUserIDs(ids...) - return _u -} - -// AddUsers adds the "users" edges to the User entity. -func (_u *RoleUpdate) AddUsers(v ...*User) *RoleUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddUserIDs(ids...) -} - -// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (_u *RoleUpdate) AddPermissionIDs(ids ...int64) *RoleUpdate { - _u.mutation.AddPermissionIDs(ids...) - return _u -} - -// AddPermissions adds the "permissions" edges to the Permission entity. -func (_u *RoleUpdate) AddPermissions(v ...*Permission) *RoleUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddPermissionIDs(ids...) -} - -// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (_u *RoleUpdate) AddUserRoleIDs(ids ...int) *RoleUpdate { - _u.mutation.AddUserRoleIDs(ids...) - return _u -} - -// AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (_u *RoleUpdate) AddUserRoles(v ...*UserRole) *RoleUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddUserRoleIDs(ids...) -} - -// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (_u *RoleUpdate) AddRolePermissionIDs(ids ...int) *RoleUpdate { - _u.mutation.AddRolePermissionIDs(ids...) - return _u -} - -// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (_u *RoleUpdate) AddRolePermissions(v ...*RolePermission) *RoleUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddRolePermissionIDs(ids...) -} - -// Mutation returns the RoleMutation object of the builder. -func (_u *RoleUpdate) Mutation() *RoleMutation { - return _u.mutation -} - -// ClearUsers clears all "users" edges to the User entity. -func (_u *RoleUpdate) ClearUsers() *RoleUpdate { - _u.mutation.ClearUsers() - return _u -} - -// RemoveUserIDs removes the "users" edge to User entities by IDs. -func (_u *RoleUpdate) RemoveUserIDs(ids ...int64) *RoleUpdate { - _u.mutation.RemoveUserIDs(ids...) - return _u -} - -// RemoveUsers removes "users" edges to User entities. -func (_u *RoleUpdate) RemoveUsers(v ...*User) *RoleUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveUserIDs(ids...) -} - -// ClearPermissions clears all "permissions" edges to the Permission entity. -func (_u *RoleUpdate) ClearPermissions() *RoleUpdate { - _u.mutation.ClearPermissions() - return _u -} - -// RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. -func (_u *RoleUpdate) RemovePermissionIDs(ids ...int64) *RoleUpdate { - _u.mutation.RemovePermissionIDs(ids...) - return _u -} - -// RemovePermissions removes "permissions" edges to Permission entities. -func (_u *RoleUpdate) RemovePermissions(v ...*Permission) *RoleUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemovePermissionIDs(ids...) -} - -// ClearUserRoles clears all "user_roles" edges to the UserRole entity. -func (_u *RoleUpdate) ClearUserRoles() *RoleUpdate { - _u.mutation.ClearUserRoles() - return _u -} - -// RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. -func (_u *RoleUpdate) RemoveUserRoleIDs(ids ...int) *RoleUpdate { - _u.mutation.RemoveUserRoleIDs(ids...) - return _u -} - -// RemoveUserRoles removes "user_roles" edges to UserRole entities. -func (_u *RoleUpdate) RemoveUserRoles(v ...*UserRole) *RoleUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveUserRoleIDs(ids...) -} - -// ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. -func (_u *RoleUpdate) ClearRolePermissions() *RoleUpdate { - _u.mutation.ClearRolePermissions() - return _u -} - -// RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. -func (_u *RoleUpdate) RemoveRolePermissionIDs(ids ...int) *RoleUpdate { - _u.mutation.RemoveRolePermissionIDs(ids...) - return _u -} - -// RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. -func (_u *RoleUpdate) RemoveRolePermissions(v ...*RolePermission) *RoleUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveRolePermissionIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (_u *RoleUpdate) Save(ctx context.Context) (int, error) { - _u.defaults() - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *RoleUpdate) SaveX(ctx context.Context) int { - affected, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (_u *RoleUpdate) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *RoleUpdate) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *RoleUpdate) defaults() { - if _, ok := _u.mutation.UpdateTime(); !ok { - v := role.UpdateDefaultUpdateTime() - _u.mutation.SetUpdateTime(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *RoleUpdate) check() error { - if v, ok := _u.mutation.Keyword(); ok { - if err := role.KeywordValidator(v); err != nil { - return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Role.keyword": %w`, err)} - } - } - if v, ok := _u.mutation.Name(); ok { - if err := role.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Role.name": %w`, err)} - } - } - if v, ok := _u.mutation.Description(); ok { - if err := role.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Role.description": %w`, err)} - } - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *RoleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoleUpdate { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *RoleUpdate) sqlSave(ctx context.Context) (_node int, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.UpdateTime(); ok { - _spec.SetField(role.FieldUpdateTime, field.TypeTime, value) - } - if value, ok := _u.mutation.Keyword(); ok { - _spec.SetField(role.FieldKeyword, field.TypeString, value) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(role.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(role.FieldDescription, field.TypeString, value) - } - if value, ok := _u.mutation.GetType(); ok { - _spec.SetField(role.FieldType, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedType(); ok { - _spec.AddField(role.FieldType, field.TypeInt8, value) - } - if value, ok := _u.mutation.Sequence(); ok { - _spec.SetField(role.FieldSequence, field.TypeInt, value) - } - if value, ok := _u.mutation.AddedSequence(); ok { - _spec.AddField(role.FieldSequence, field.TypeInt, value) - } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(role.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedStatus(); ok { - _spec.AddField(role.FieldStatus, field.TypeInt8, value) - } - if _u.mutation.UsersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: role.UsersTable, - Columns: role.UsersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedUsersIDs(); len(nodes) > 0 && !_u.mutation.UsersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: role.UsersTable, - Columns: role.UsersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.UsersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: role.UsersTable, - Columns: role.UsersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.PermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: role.PermissionsTable, - Columns: role.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: role.PermissionsTable, - Columns: role.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: role.PermissionsTable, - Columns: role.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.UserRolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.UserRolesTable, - Columns: []string{role.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.UserRolesTable, - Columns: []string{role.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.UserRolesTable, - Columns: []string{role.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.RolePermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.RolePermissionsTable, - Columns: []string{role.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.RolePermissionsTable, - Columns: []string{role.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.RolePermissionsTable, - Columns: []string{role.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{role.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - _u.mutation.done = true - return _node, nil -} - -// RoleUpdateOne is the builder for updating a single Role entity. -type RoleUpdateOne struct { - config - fields []string - hooks []Hook - mutation *RoleMutation - modifiers []func(*sql.UpdateBuilder) -} - -// SetUpdateTime sets the "update_time" field. -func (_u *RoleUpdateOne) SetUpdateTime(v time.Time) *RoleUpdateOne { - _u.mutation.SetUpdateTime(v) - return _u -} - -// SetKeyword sets the "keyword" field. -func (_u *RoleUpdateOne) SetKeyword(v string) *RoleUpdateOne { - _u.mutation.SetKeyword(v) - return _u -} - -// SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (_u *RoleUpdateOne) SetNillableKeyword(v *string) *RoleUpdateOne { - if v != nil { - _u.SetKeyword(*v) - } - return _u -} - -// SetName sets the "name" field. -func (_u *RoleUpdateOne) SetName(v string) *RoleUpdateOne { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *RoleUpdateOne) SetNillableName(v *string) *RoleUpdateOne { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetDescription sets the "description" field. -func (_u *RoleUpdateOne) SetDescription(v string) *RoleUpdateOne { - _u.mutation.SetDescription(v) - return _u -} - -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *RoleUpdateOne) SetNillableDescription(v *string) *RoleUpdateOne { - if v != nil { - _u.SetDescription(*v) - } - return _u -} - -// SetType sets the "type" field. -func (_u *RoleUpdateOne) SetType(v int8) *RoleUpdateOne { - _u.mutation.ResetType() - _u.mutation.SetType(v) - return _u -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (_u *RoleUpdateOne) SetNillableType(v *int8) *RoleUpdateOne { - if v != nil { - _u.SetType(*v) - } - return _u -} - -// AddType adds value to the "type" field. -func (_u *RoleUpdateOne) AddType(v int8) *RoleUpdateOne { - _u.mutation.AddType(v) - return _u -} - -// SetSequence sets the "sequence" field. -func (_u *RoleUpdateOne) SetSequence(v int) *RoleUpdateOne { - _u.mutation.ResetSequence() - _u.mutation.SetSequence(v) - return _u -} - -// SetNillableSequence sets the "sequence" field if the given value is not nil. -func (_u *RoleUpdateOne) SetNillableSequence(v *int) *RoleUpdateOne { - if v != nil { - _u.SetSequence(*v) - } - return _u -} - -// AddSequence adds value to the "sequence" field. -func (_u *RoleUpdateOne) AddSequence(v int) *RoleUpdateOne { - _u.mutation.AddSequence(v) - return _u -} - -// SetStatus sets the "status" field. -func (_u *RoleUpdateOne) SetStatus(v int8) *RoleUpdateOne { - _u.mutation.ResetStatus() - _u.mutation.SetStatus(v) - return _u -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *RoleUpdateOne) SetNillableStatus(v *int8) *RoleUpdateOne { - if v != nil { - _u.SetStatus(*v) - } - return _u -} - -// AddStatus adds value to the "status" field. -func (_u *RoleUpdateOne) AddStatus(v int8) *RoleUpdateOne { - _u.mutation.AddStatus(v) - return _u -} - -// AddUserIDs adds the "users" edge to the User entity by IDs. -func (_u *RoleUpdateOne) AddUserIDs(ids ...int64) *RoleUpdateOne { - _u.mutation.AddUserIDs(ids...) - return _u -} - -// AddUsers adds the "users" edges to the User entity. -func (_u *RoleUpdateOne) AddUsers(v ...*User) *RoleUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddUserIDs(ids...) -} - -// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. -func (_u *RoleUpdateOne) AddPermissionIDs(ids ...int64) *RoleUpdateOne { - _u.mutation.AddPermissionIDs(ids...) - return _u -} - -// AddPermissions adds the "permissions" edges to the Permission entity. -func (_u *RoleUpdateOne) AddPermissions(v ...*Permission) *RoleUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddPermissionIDs(ids...) -} - -// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (_u *RoleUpdateOne) AddUserRoleIDs(ids ...int) *RoleUpdateOne { - _u.mutation.AddUserRoleIDs(ids...) - return _u -} - -// AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (_u *RoleUpdateOne) AddUserRoles(v ...*UserRole) *RoleUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddUserRoleIDs(ids...) -} - -// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. -func (_u *RoleUpdateOne) AddRolePermissionIDs(ids ...int) *RoleUpdateOne { - _u.mutation.AddRolePermissionIDs(ids...) - return _u -} - -// AddRolePermissions adds the "role_permissions" edges to the RolePermission entity. -func (_u *RoleUpdateOne) AddRolePermissions(v ...*RolePermission) *RoleUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddRolePermissionIDs(ids...) -} - -// Mutation returns the RoleMutation object of the builder. -func (_u *RoleUpdateOne) Mutation() *RoleMutation { - return _u.mutation -} - -// ClearUsers clears all "users" edges to the User entity. -func (_u *RoleUpdateOne) ClearUsers() *RoleUpdateOne { - _u.mutation.ClearUsers() - return _u -} - -// RemoveUserIDs removes the "users" edge to User entities by IDs. -func (_u *RoleUpdateOne) RemoveUserIDs(ids ...int64) *RoleUpdateOne { - _u.mutation.RemoveUserIDs(ids...) - return _u -} - -// RemoveUsers removes "users" edges to User entities. -func (_u *RoleUpdateOne) RemoveUsers(v ...*User) *RoleUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveUserIDs(ids...) -} - -// ClearPermissions clears all "permissions" edges to the Permission entity. -func (_u *RoleUpdateOne) ClearPermissions() *RoleUpdateOne { - _u.mutation.ClearPermissions() - return _u -} - -// RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. -func (_u *RoleUpdateOne) RemovePermissionIDs(ids ...int64) *RoleUpdateOne { - _u.mutation.RemovePermissionIDs(ids...) - return _u -} - -// RemovePermissions removes "permissions" edges to Permission entities. -func (_u *RoleUpdateOne) RemovePermissions(v ...*Permission) *RoleUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemovePermissionIDs(ids...) -} - -// ClearUserRoles clears all "user_roles" edges to the UserRole entity. -func (_u *RoleUpdateOne) ClearUserRoles() *RoleUpdateOne { - _u.mutation.ClearUserRoles() - return _u -} - -// RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. -func (_u *RoleUpdateOne) RemoveUserRoleIDs(ids ...int) *RoleUpdateOne { - _u.mutation.RemoveUserRoleIDs(ids...) - return _u -} - -// RemoveUserRoles removes "user_roles" edges to UserRole entities. -func (_u *RoleUpdateOne) RemoveUserRoles(v ...*UserRole) *RoleUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveUserRoleIDs(ids...) -} - -// ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. -func (_u *RoleUpdateOne) ClearRolePermissions() *RoleUpdateOne { - _u.mutation.ClearRolePermissions() - return _u -} - -// RemoveRolePermissionIDs removes the "role_permissions" edge to RolePermission entities by IDs. -func (_u *RoleUpdateOne) RemoveRolePermissionIDs(ids ...int) *RoleUpdateOne { - _u.mutation.RemoveRolePermissionIDs(ids...) - return _u -} - -// RemoveRolePermissions removes "role_permissions" edges to RolePermission entities. -func (_u *RoleUpdateOne) RemoveRolePermissions(v ...*RolePermission) *RoleUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveRolePermissionIDs(ids...) -} - -// Where appends a list predicates to the RoleUpdate builder. -func (_u *RoleUpdateOne) Where(ps ...predicate.Role) *RoleUpdateOne { - _u.mutation.Where(ps...) - return _u -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (_u *RoleUpdateOne) Select(field string, fields ...string) *RoleUpdateOne { - _u.fields = append([]string{field}, fields...) - return _u -} - -// Save executes the query and returns the updated Role entity. -func (_u *RoleUpdateOne) Save(ctx context.Context) (*Role, error) { - _u.defaults() - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *RoleUpdateOne) SaveX(ctx context.Context) *Role { - node, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (_u *RoleUpdateOne) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *RoleUpdateOne) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *RoleUpdateOne) defaults() { - if _, ok := _u.mutation.UpdateTime(); !ok { - v := role.UpdateDefaultUpdateTime() - _u.mutation.SetUpdateTime(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *RoleUpdateOne) check() error { - if v, ok := _u.mutation.Keyword(); ok { - if err := role.KeywordValidator(v); err != nil { - return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Role.keyword": %w`, err)} - } - } - if v, ok := _u.mutation.Name(); ok { - if err := role.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Role.name": %w`, err)} - } - } - if v, ok := _u.mutation.Description(); ok { - if err := role.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Role.description": %w`, err)} - } - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *RoleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoleUpdateOne { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(role.Table, role.Columns, sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64)) - id, ok := _u.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Role.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := _u.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, role.FieldID) - for _, f := range fields { - if !role.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != role.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.UpdateTime(); ok { - _spec.SetField(role.FieldUpdateTime, field.TypeTime, value) - } - if value, ok := _u.mutation.Keyword(); ok { - _spec.SetField(role.FieldKeyword, field.TypeString, value) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(role.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(role.FieldDescription, field.TypeString, value) - } - if value, ok := _u.mutation.GetType(); ok { - _spec.SetField(role.FieldType, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedType(); ok { - _spec.AddField(role.FieldType, field.TypeInt8, value) - } - if value, ok := _u.mutation.Sequence(); ok { - _spec.SetField(role.FieldSequence, field.TypeInt, value) - } - if value, ok := _u.mutation.AddedSequence(); ok { - _spec.AddField(role.FieldSequence, field.TypeInt, value) - } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(role.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedStatus(); ok { - _spec.AddField(role.FieldStatus, field.TypeInt8, value) - } - if _u.mutation.UsersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: role.UsersTable, - Columns: role.UsersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedUsersIDs(); len(nodes) > 0 && !_u.mutation.UsersCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: role.UsersTable, - Columns: role.UsersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.UsersIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: true, - Table: role.UsersTable, - Columns: role.UsersPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.PermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: role.PermissionsTable, - Columns: role.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: role.PermissionsTable, - Columns: role.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: role.PermissionsTable, - Columns: role.PermissionsPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.UserRolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.UserRolesTable, - Columns: []string{role.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.UserRolesTable, - Columns: []string{role.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.UserRolesTable, - Columns: []string{role.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.RolePermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.RolePermissionsTable, - Columns: []string{role.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedRolePermissionsIDs(); len(nodes) > 0 && !_u.mutation.RolePermissionsCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.RolePermissionsTable, - Columns: []string{role.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RolePermissionsIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: role.RolePermissionsTable, - Columns: []string{role.RolePermissionsColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - _node = &Role{config: _u.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{role.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - _u.mutation.done = true - return _node, nil -} - -// SetRole set the Role -func (ru *RoleUpdate) SetRole(input *Role, fields ...string) *RoleUpdate { - m := ru.mutation - if len(fields) == 0 { - fields = role.OmitColumns(role.FieldID) - } - _ = m.SetFields(input, fields...) - return ru -} - -// SetRoleWithZero set the Role -func (ru *RoleUpdate) SetRoleWithZero(input *Role, fields ...string) *RoleUpdate { - m := ru.mutation - if len(fields) == 0 { - fields = role.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return ru -} - -// SetRole set the Role -func (ruo *RoleUpdateOne) SetRole(input *Role, fields ...string) *RoleUpdateOne { - m := ruo.mutation - if len(fields) == 0 { - fields = role.OmitColumns(role.FieldID) - } - _ = m.SetFields(input, fields...) - return ruo -} - -// SetRoleWithZero set the Role -func (ruo *RoleUpdateOne) SetRoleWithZero(input *Role, fields ...string) *RoleUpdateOne { - m := ruo.mutation - if len(fields) == 0 { - fields = role.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return ruo -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -func (ruo *RoleUpdateOne) Omit(fields ...string) *RoleUpdateOne { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - ruo.fields = []string(nil) - for _, col := range role.Columns { - if _, ok := omits[col]; !ok { - ruo.fields = append(ruo.fields, col) - } - } - return ruo -} diff --git a/internal/features/system/data/ent/rolepermission.go b/internal/features/system/data/ent/rolepermission.go deleted file mode 100644 index ba3116f2..00000000 --- a/internal/features/system/data/ent/rolepermission.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" -) - -// Role-Permission mapping table -type RolePermission struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // RoleID holds the value of the "role_id" field. - RoleID int64 `json:"role_id,omitempty"` - // PermissionID holds the value of the "permission_id" field. - PermissionID int64 `json:"permission_id,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the RolePermissionQuery when eager-loading is set. - Edges RolePermissionEdges `json:"edges"` - selectValues sql.SelectValues -} - -// RolePermissionEdges holds the relations/edges for other nodes in the graph. -type RolePermissionEdges struct { - // Role holds the value of the role edge. - Role *Role `json:"role,omitempty"` - // Permission holds the value of the permission edge. - Permission *Permission `json:"permission,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool -} - -// RoleOrErr returns the Role value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e RolePermissionEdges) RoleOrErr() (*Role, error) { - if e.Role != nil { - return e.Role, nil - } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: role.Label} - } - return nil, &NotLoadedError{edge: "role"} -} - -// PermissionOrErr returns the Permission value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e RolePermissionEdges) PermissionOrErr() (*Permission, error) { - if e.Permission != nil { - return e.Permission, nil - } else if e.loadedTypes[1] { - return nil, &NotFoundError{label: permission.Label} - } - return nil, &NotLoadedError{edge: "permission"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*RolePermission) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case rolepermission.FieldID, rolepermission.FieldRoleID, rolepermission.FieldPermissionID: - values[i] = new(sql.NullInt64) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the RolePermission fields. -func (_m *RolePermission) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case rolepermission.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - _m.ID = int(value.Int64) - case rolepermission.FieldRoleID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field role_id", values[i]) - } else if value.Valid { - _m.RoleID = value.Int64 - } - case rolepermission.FieldPermissionID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field permission_id", values[i]) - } else if value.Valid { - _m.PermissionID = value.Int64 - } - default: - _m.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the RolePermission. -// This includes values selected through modifiers, order, etc. -func (_m *RolePermission) Value(name string) (ent.Value, error) { - return _m.selectValues.Get(name) -} - -// QueryRole queries the "role" edge of the RolePermission entity. -func (_m *RolePermission) QueryRole() *RoleQuery { - return NewRolePermissionClient(_m.config).QueryRole(_m) -} - -// QueryPermission queries the "permission" edge of the RolePermission entity. -func (_m *RolePermission) QueryPermission() *PermissionQuery { - return NewRolePermissionClient(_m.config).QueryPermission(_m) -} - -// Update returns a builder for updating this RolePermission. -// Note that you need to call RolePermission.Unwrap() before calling this method if this RolePermission -// was returned from a transaction, and the transaction was committed or rolled back. -func (_m *RolePermission) Update() *RolePermissionUpdateOne { - return NewRolePermissionClient(_m.config).UpdateOne(_m) -} - -// Unwrap unwraps the RolePermission entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (_m *RolePermission) Unwrap() *RolePermission { - _tx, ok := _m.config.driver.(*txDriver) - if !ok { - panic("ent: RolePermission is not a transactional entity") - } - _m.config.driver = _tx.drv - return _m -} - -// String implements the fmt.Stringer. -func (_m *RolePermission) String() string { - var builder strings.Builder - builder.WriteString("RolePermission(") - builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - builder.WriteString("role_id=") - builder.WriteString(fmt.Sprintf("%v", _m.RoleID)) - builder.WriteString(", ") - builder.WriteString("permission_id=") - builder.WriteString(fmt.Sprintf("%v", _m.PermissionID)) - builder.WriteByte(')') - return builder.String() -} - -// RolePermissions is a parsable slice of RolePermission. -type RolePermissions []*RolePermission diff --git a/internal/features/system/data/ent/rolepermission/rolepermission.go b/internal/features/system/data/ent/rolepermission/rolepermission.go deleted file mode 100644 index 7923e112..00000000 --- a/internal/features/system/data/ent/rolepermission/rolepermission.go +++ /dev/null @@ -1,164 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package rolepermission - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the rolepermission type in the database. - Label = "role_permission" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldRoleID holds the string denoting the role_id field in the database. - FieldRoleID = "role_id" - // FieldPermissionID holds the string denoting the permission_id field in the database. - FieldPermissionID = "permission_id" - // EdgeRole holds the string denoting the role edge name in mutations. - EdgeRole = "role" - // EdgePermission holds the string denoting the permission edge name in mutations. - EdgePermission = "permission" - // Table holds the table name of the rolepermission in the database. - Table = "sys_role_permissions" - // RoleTable is the table that holds the role relation/edge. - RoleTable = "sys_role_permissions" - // RoleInverseTable is the table name for the Role entity. - // It exists in this package in order to avoid circular dependency with the "role" package. - RoleInverseTable = "sys_roles" - // RoleColumn is the table column denoting the role relation/edge. - RoleColumn = "role_id" - // PermissionTable is the table that holds the permission relation/edge. - PermissionTable = "sys_role_permissions" - // PermissionInverseTable is the table name for the Permission entity. - // It exists in this package in order to avoid circular dependency with the "permission" package. - PermissionInverseTable = "sys_permissions" - // PermissionColumn is the table column denoting the permission relation/edge. - PermissionColumn = "permission_id" -) - -// Columns holds all SQL columns for rolepermission fields. -var Columns = []string{ - FieldID, - FieldRoleID, - FieldPermissionID, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -// OrderOption defines the ordering options for the RolePermission queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByRoleID orders the results by the role_id field. -func ByRoleID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRoleID, opts...).ToFunc() -} - -// ByPermissionID orders the results by the permission_id field. -func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPermissionID, opts...).ToFunc() -} - -// ByRoleField orders the results by role field. -func ByRoleField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRoleStep(), sql.OrderByField(field, opts...)) - } -} - -// ByPermissionField orders the results by permission field. -func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) - } -} -func newRoleStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RoleInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), - ) -} -func newPermissionStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/features/system/data/ent/rolepermission/where.go b/internal/features/system/data/ent/rolepermission/where.go deleted file mode 100644 index 9e784297..00000000 --- a/internal/features/system/data/ent/rolepermission/where.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package rolepermission - -import ( - "origadmin/application/admin/internal/features/system/data/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.RolePermission { - return predicate.RolePermission(sql.FieldLTE(FieldID, id)) -} - -// RoleID applies equality check predicate on the "role_id" field. It's identical to RoleIDEQ. -func RoleID(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldRoleID, v)) -} - -// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. -func PermissionID(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldPermissionID, v)) -} - -// RoleIDEQ applies the EQ predicate on the "role_id" field. -func RoleIDEQ(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldRoleID, v)) -} - -// RoleIDNEQ applies the NEQ predicate on the "role_id" field. -func RoleIDNEQ(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNEQ(FieldRoleID, v)) -} - -// RoleIDIn applies the In predicate on the "role_id" field. -func RoleIDIn(vs ...int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldIn(FieldRoleID, vs...)) -} - -// RoleIDNotIn applies the NotIn predicate on the "role_id" field. -func RoleIDNotIn(vs ...int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNotIn(FieldRoleID, vs...)) -} - -// PermissionIDEQ applies the EQ predicate on the "permission_id" field. -func PermissionIDEQ(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldEQ(FieldPermissionID, v)) -} - -// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. -func PermissionIDNEQ(v int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNEQ(FieldPermissionID, v)) -} - -// PermissionIDIn applies the In predicate on the "permission_id" field. -func PermissionIDIn(vs ...int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldIn(FieldPermissionID, vs...)) -} - -// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. -func PermissionIDNotIn(vs ...int64) predicate.RolePermission { - return predicate.RolePermission(sql.FieldNotIn(FieldPermissionID, vs...)) -} - -// HasRole applies the HasEdge predicate on the "role" edge. -func HasRole() predicate.RolePermission { - return predicate.RolePermission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRoleWith applies the HasEdge predicate on the "role" edge with a given conditions (other predicates). -func HasRoleWith(preds ...predicate.Role) predicate.RolePermission { - return predicate.RolePermission(func(s *sql.Selector) { - step := newRoleStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasPermission applies the HasEdge predicate on the "permission" edge. -func HasPermission() predicate.RolePermission { - return predicate.RolePermission(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). -func HasPermissionWith(preds ...predicate.Permission) predicate.RolePermission { - return predicate.RolePermission(func(s *sql.Selector) { - step := newPermissionStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.RolePermission) predicate.RolePermission { - return predicate.RolePermission(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.RolePermission) predicate.RolePermission { - return predicate.RolePermission(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.RolePermission) predicate.RolePermission { - return predicate.RolePermission(sql.NotPredicates(p)) -} diff --git a/internal/features/system/data/ent/rolepermission_create.go b/internal/features/system/data/ent/rolepermission_create.go deleted file mode 100644 index 1f68ce2b..00000000 --- a/internal/features/system/data/ent/rolepermission_create.go +++ /dev/null @@ -1,260 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// RolePermissionCreate is the builder for creating a RolePermission entity. -type RolePermissionCreate struct { - config - mutation *RolePermissionMutation - hooks []Hook -} - -// SetRoleID sets the "role_id" field. -func (_c *RolePermissionCreate) SetRoleID(v int64) *RolePermissionCreate { - _c.mutation.SetRoleID(v) - return _c -} - -// SetPermissionID sets the "permission_id" field. -func (_c *RolePermissionCreate) SetPermissionID(v int64) *RolePermissionCreate { - _c.mutation.SetPermissionID(v) - return _c -} - -// SetRole sets the "role" edge to the Role entity. -func (_c *RolePermissionCreate) SetRole(v *Role) *RolePermissionCreate { - return _c.SetRoleID(v.ID) -} - -// SetPermission sets the "permission" edge to the Permission entity. -func (_c *RolePermissionCreate) SetPermission(v *Permission) *RolePermissionCreate { - return _c.SetPermissionID(v.ID) -} - -// Mutation returns the RolePermissionMutation object of the builder. -func (_c *RolePermissionCreate) Mutation() *RolePermissionMutation { - return _c.mutation -} - -// Save creates the RolePermission in the database. -func (_c *RolePermissionCreate) Save(ctx context.Context) (*RolePermission, error) { - return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (_c *RolePermissionCreate) SaveX(ctx context.Context) *RolePermission { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *RolePermissionCreate) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *RolePermissionCreate) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_c *RolePermissionCreate) check() error { - if _, ok := _c.mutation.RoleID(); !ok { - return &ValidationError{Name: "role_id", err: errors.New(`ent: missing required field "RolePermission.role_id"`)} - } - if _, ok := _c.mutation.PermissionID(); !ok { - return &ValidationError{Name: "permission_id", err: errors.New(`ent: missing required field "RolePermission.permission_id"`)} - } - if len(_c.mutation.RoleIDs()) == 0 { - return &ValidationError{Name: "role", err: errors.New(`ent: missing required edge "RolePermission.role"`)} - } - if len(_c.mutation.PermissionIDs()) == 0 { - return &ValidationError{Name: "permission", err: errors.New(`ent: missing required edge "RolePermission.permission"`)} - } - return nil -} - -func (_c *RolePermissionCreate) sqlSave(ctx context.Context) (*RolePermission, error) { - if err := _c.check(); err != nil { - return nil, err - } - _node, _spec := _c.createSpec() - if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - id := _spec.ID.Value.(int64) - _node.ID = int(id) - _c.mutation.id = &_node.ID - _c.mutation.done = true - return _node, nil -} - -func (_c *RolePermissionCreate) createSpec() (*RolePermission, *sqlgraph.CreateSpec) { - var ( - _node = &RolePermission{config: _c.config} - _spec = sqlgraph.NewCreateSpec(rolepermission.Table, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) - ) - if nodes := _c.mutation.RoleIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: rolepermission.RoleTable, - Columns: []string{rolepermission.RoleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.RoleID = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.PermissionIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: rolepermission.PermissionTable, - Columns: []string{rolepermission.PermissionColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.PermissionID = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// SetRolePermission set the RolePermission -func (_c *RolePermissionCreate) SetRolePermission(input *RolePermission, fields ...string) *RolePermissionCreate { - m := _c.mutation - if len(fields) == 0 { - fields = rolepermission.Columns - } - _ = m.SetFields(input, fields...) - return _c -} - -// SetRolePermissionWithZero set the RolePermission -func (_c *RolePermissionCreate) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionCreate { - m := _c.mutation - if len(fields) == 0 { - fields = rolepermission.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return _c -} - -// RolePermissionCreateBulk is the builder for creating many RolePermission entities in bulk. -type RolePermissionCreateBulk struct { - config - err error - builders []*RolePermissionCreate -} - -// Save creates the RolePermission entities in the database. -func (_c *RolePermissionCreateBulk) Save(ctx context.Context) ([]*RolePermission, error) { - if _c.err != nil { - return nil, _c.err - } - specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*RolePermission, len(_c.builders)) - mutators := make([]Mutator, len(_c.builders)) - for i := range _c.builders { - func(i int, root context.Context) { - builder := _c.builders[i] - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*RolePermissionMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (_c *RolePermissionCreateBulk) SaveX(ctx context.Context) []*RolePermission { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *RolePermissionCreateBulk) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *RolePermissionCreateBulk) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/rolepermission_delete.go b/internal/features/system/data/ent/rolepermission_delete.go deleted file mode 100644 index d2796477..00000000 --- a/internal/features/system/data/ent/rolepermission_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// RolePermissionDelete is the builder for deleting a RolePermission entity. -type RolePermissionDelete struct { - config - hooks []Hook - mutation *RolePermissionMutation -} - -// Where appends a list predicates to the RolePermissionDelete builder. -func (_d *RolePermissionDelete) Where(ps ...predicate.RolePermission) *RolePermissionDelete { - _d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (_d *RolePermissionDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *RolePermissionDelete) ExecX(ctx context.Context) int { - n, err := _d.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (_d *RolePermissionDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(rolepermission.Table, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) - if ps := _d.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - _d.mutation.done = true - return affected, err -} - -// RolePermissionDeleteOne is the builder for deleting a single RolePermission entity. -type RolePermissionDeleteOne struct { - _d *RolePermissionDelete -} - -// Where appends a list predicates to the RolePermissionDelete builder. -func (_d *RolePermissionDeleteOne) Where(ps ...predicate.RolePermission) *RolePermissionDeleteOne { - _d._d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query. -func (_d *RolePermissionDeleteOne) Exec(ctx context.Context) error { - n, err := _d._d.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{rolepermission.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *RolePermissionDeleteOne) ExecX(ctx context.Context) { - if err := _d.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/rolepermission_query.go b/internal/features/system/data/ent/rolepermission_query.go deleted file mode 100644 index 6b14ebeb..00000000 --- a/internal/features/system/data/ent/rolepermission_query.go +++ /dev/null @@ -1,763 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "math" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// RolePermissionQuery is the builder for querying RolePermission entities. -type RolePermissionQuery struct { - config - ctx *QueryContext - order []rolepermission.OrderOption - inters []Interceptor - predicates []predicate.RolePermission - withRole *RoleQuery - withPermission *PermissionQuery - modifiers []func(*sql.Selector) - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the RolePermissionQuery builder. -func (_q *RolePermissionQuery) Where(ps ...predicate.RolePermission) *RolePermissionQuery { - _q.predicates = append(_q.predicates, ps...) - return _q -} - -// Limit the number of records to be returned by this query. -func (_q *RolePermissionQuery) Limit(limit int) *RolePermissionQuery { - _q.ctx.Limit = &limit - return _q -} - -// Offset to start from. -func (_q *RolePermissionQuery) Offset(offset int) *RolePermissionQuery { - _q.ctx.Offset = &offset - return _q -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (_q *RolePermissionQuery) Unique(unique bool) *RolePermissionQuery { - _q.ctx.Unique = &unique - return _q -} - -// Order specifies how the records should be ordered. -func (_q *RolePermissionQuery) Order(o ...rolepermission.OrderOption) *RolePermissionQuery { - _q.order = append(_q.order, o...) - return _q -} - -// QueryRole chains the current query on the "role" edge. -func (_q *RolePermissionQuery) QueryRole() *RoleQuery { - query := (&RoleClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(rolepermission.Table, rolepermission.FieldID, selector), - sqlgraph.To(role.Table, role.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.RoleTable, rolepermission.RoleColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryPermission chains the current query on the "permission" edge. -func (_q *RolePermissionQuery) QueryPermission() *PermissionQuery { - query := (&PermissionClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(rolepermission.Table, rolepermission.FieldID, selector), - sqlgraph.To(permission.Table, permission.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, rolepermission.PermissionTable, rolepermission.PermissionColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first RolePermission entity from the query. -// Returns a *NotFoundError when no RolePermission was found. -func (_q *RolePermissionQuery) First(ctx context.Context) (*RolePermission, error) { - nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{rolepermission.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (_q *RolePermissionQuery) FirstX(ctx context.Context) *RolePermission { - node, err := _q.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first RolePermission ID from the query. -// Returns a *NotFoundError when no RolePermission ID was found. -func (_q *RolePermissionQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{rolepermission.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (_q *RolePermissionQuery) FirstIDX(ctx context.Context) int { - id, err := _q.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single RolePermission entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one RolePermission entity is found. -// Returns a *NotFoundError when no RolePermission entities are found. -func (_q *RolePermissionQuery) Only(ctx context.Context) (*RolePermission, error) { - nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{rolepermission.Label} - default: - return nil, &NotSingularError{rolepermission.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (_q *RolePermissionQuery) OnlyX(ctx context.Context) *RolePermission { - node, err := _q.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only RolePermission ID in the query. -// Returns a *NotSingularError when more than one RolePermission ID is found. -// Returns a *NotFoundError when no entities are found. -func (_q *RolePermissionQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{rolepermission.Label} - default: - err = &NotSingularError{rolepermission.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *RolePermissionQuery) OnlyIDX(ctx context.Context) int { - id, err := _q.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of RolePermissions. -func (_q *RolePermissionQuery) All(ctx context.Context) ([]*RolePermission, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*RolePermission, *RolePermissionQuery]() - return withInterceptors[[]*RolePermission](ctx, _q, qr, _q.inters) -} - -// AllX is like All, but panics if an error occurs. -func (_q *RolePermissionQuery) AllX(ctx context.Context) []*RolePermission { - nodes, err := _q.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of RolePermission IDs. -func (_q *RolePermissionQuery) IDs(ctx context.Context) (ids []int, err error) { - if _q.ctx.Unique == nil && _q.path != nil { - _q.Unique(true) - } - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(rolepermission.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (_q *RolePermissionQuery) IDsX(ctx context.Context) []int { - ids, err := _q.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (_q *RolePermissionQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) - if err := _q.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, _q, querierCount[*RolePermissionQuery](), _q.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (_q *RolePermissionQuery) CountX(ctx context.Context) int { - count, err := _q.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (_q *RolePermissionQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) - switch _, err := _q.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - -// ExistX is like Exist, but panics if an error occurs. -func (_q *RolePermissionQuery) ExistX(ctx context.Context) bool { - exist, err := _q.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the RolePermissionQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (_q *RolePermissionQuery) Clone() *RolePermissionQuery { - if _q == nil { - return nil - } - return &RolePermissionQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]rolepermission.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.RolePermission{}, _q.predicates...), - withRole: _q.withRole.Clone(), - withPermission: _q.withPermission.Clone(), - // clone intermediate query. - sql: _q.sql.Clone(), - path: _q.path, - modifiers: append([]func(*sql.Selector){}, _q.modifiers...), - } -} - -// WithRole tells the query-builder to eager-load the nodes that are connected to -// the "role" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *RolePermissionQuery) WithRole(opts ...func(*RoleQuery)) *RolePermissionQuery { - query := (&RoleClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withRole = query - return _q -} - -// WithPermission tells the query-builder to eager-load the nodes that are connected to -// the "permission" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *RolePermissionQuery) WithPermission(opts ...func(*PermissionQuery)) *RolePermissionQuery { - query := (&PermissionClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withPermission = query - return _q -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// RoleID int64 `json:"role_id,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.RolePermission.Query(). -// GroupBy(rolepermission.FieldRoleID). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (_q *RolePermissionQuery) GroupBy(field string, fields ...string) *RolePermissionGroupBy { - _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &RolePermissionGroupBy{build: _q} - grbuild.flds = &_q.ctx.Fields - grbuild.label = rolepermission.Label - grbuild.scan = grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// RoleID int64 `json:"role_id,omitempty"` -// } -// -// client.RolePermission.Query(). -// Select(rolepermission.FieldRoleID). -// Scan(ctx, &v) -func (_q *RolePermissionQuery) Select(fields ...string) *RolePermissionSelect { - _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &RolePermissionSelect{RolePermissionQuery: _q} - sbuild.label = rolepermission.Label - sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a RolePermissionSelect configured with the given aggregations. -func (_q *RolePermissionQuery) Aggregate(fns ...AggregateFunc) *RolePermissionSelect { - return _q.Select().Aggregate(fns...) -} - -func (_q *RolePermissionQuery) prepareQuery(ctx context.Context) error { - for _, inter := range _q.inters { - if inter == nil { - return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") - } - if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, _q); err != nil { - return err - } - } - } - for _, f := range _q.ctx.Fields { - if !rolepermission.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if _q.path != nil { - prev, err := _q.path(ctx) - if err != nil { - return err - } - _q.sql = prev - } - return nil -} - -func (_q *RolePermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*RolePermission, error) { - var ( - nodes = []*RolePermission{} - _spec = _q.querySpec() - loadedTypes = [2]bool{ - _q.withRole != nil, - _q.withPermission != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*RolePermission).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &RolePermission{config: _q.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := _q.withRole; query != nil { - if err := _q.loadRole(ctx, query, nodes, nil, - func(n *RolePermission, e *Role) { n.Edges.Role = e }); err != nil { - return nil, err - } - } - if query := _q.withPermission; query != nil { - if err := _q.loadPermission(ctx, query, nodes, nil, - func(n *RolePermission, e *Permission) { n.Edges.Permission = e }); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (_q *RolePermissionQuery) loadRole(ctx context.Context, query *RoleQuery, nodes []*RolePermission, init func(*RolePermission), assign func(*RolePermission, *Role)) error { - ids := make([]int64, 0, len(nodes)) - nodeids := make(map[int64][]*RolePermission) - for i := range nodes { - fk := nodes[i].RoleID - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(role.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "role_id" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} -func (_q *RolePermissionQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*RolePermission, init func(*RolePermission), assign func(*RolePermission, *Permission)) error { - ids := make([]int64, 0, len(nodes)) - nodeids := make(map[int64][]*RolePermission) - for i := range nodes { - fk := nodes[i].PermissionID - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(permission.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "permission_id" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} - -func (_q *RolePermissionQuery) sqlCount(ctx context.Context) (int, error) { - _spec := _q.querySpec() - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - _spec.Node.Columns = _q.ctx.Fields - if len(_q.ctx.Fields) > 0 { - _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique - } - return sqlgraph.CountNodes(ctx, _q.driver, _spec) -} - -func (_q *RolePermissionQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(rolepermission.Table, rolepermission.Columns, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) - _spec.From = _q.sql - if unique := _q.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if _q.path != nil { - _spec.Unique = true - } - if fields := _q.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, rolepermission.FieldID) - for i := range fields { - if fields[i] != rolepermission.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - if _q.withRole != nil { - _spec.Node.AddColumnOnce(rolepermission.FieldRoleID) - } - if _q.withPermission != nil { - _spec.Node.AddColumnOnce(rolepermission.FieldPermissionID) - } - } - if ps := _q.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := _q.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := _q.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := _q.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (_q *RolePermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(rolepermission.Table) - columns := _q.ctx.Fields - if len(columns) == 0 { - columns = rolepermission.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if _q.sql != nil { - selector = _q.sql - selector.Select(selector.Columns(columns...)...) - } - if _q.ctx.Unique != nil && *_q.ctx.Unique { - selector.Distinct() - } - for _, m := range _q.modifiers { - m(selector) - } - for _, p := range _q.predicates { - p(selector) - } - for _, p := range _q.order { - p(selector) - } - if offset := _q.ctx.Offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := _q.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// ForUpdate locks the selected rows against concurrent updates, and prevent them from being -// updated, deleted or "selected ... for update" by other sessions, until the transaction is -// either committed or rolled-back. -func (_q *RolePermissionQuery) ForUpdate(opts ...sql.LockOption) *RolePermissionQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForUpdate(opts...) - }) - return _q -} - -// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock -// on any rows that are read. Other sessions can read the rows, but cannot modify them -// until your transaction commits. -func (_q *RolePermissionQuery) ForShare(opts ...sql.LockOption) *RolePermissionQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForShare(opts...) - }) - return _q -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_q *RolePermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *RolePermissionSelect { - _q.modifiers = append(_q.modifiers, modifiers...) - return _q.Select() -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// Example: -// -// var v []struct { -// RoleID int64 `json:"role_id,omitempty"` -// PermissionID int64 `json:"permission_id,omitempty"` -// } -// -// client.RolePermission.Query(). -// Omit( -// rolepermission.FieldRoleID, -// rolepermission.FieldPermissionID, -// ). -// Scan(ctx, &v) -func (rpq *RolePermissionQuery) Omit(fields ...string) *RolePermissionSelect { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - for _, col := range rolepermission.Columns { - if _, ok := omits[col]; !ok { - rpq.ctx.Fields = append(rpq.ctx.Fields, col) - } - } - - sbuild := &RolePermissionSelect{RolePermissionQuery: rpq} - sbuild.label = rolepermission.Label - sbuild.flds, sbuild.scan = &rpq.ctx.Fields, sbuild.Scan - return sbuild -} - -// RolePermissionGroupBy is the group-by builder for RolePermission entities. -type RolePermissionGroupBy struct { - selector - build *RolePermissionQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (_g *RolePermissionGroupBy) Aggregate(fns ...AggregateFunc) *RolePermissionGroupBy { - _g.fns = append(_g.fns, fns...) - return _g -} - -// Scan applies the selector query and scans the result into the given value. -func (_g *RolePermissionGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) - if err := _g.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*RolePermissionQuery, *RolePermissionGroupBy](ctx, _g.build, _g, _g.build.inters, v) -} - -func (_g *RolePermissionGroupBy) sqlScan(ctx context.Context, root *RolePermissionQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(_g.fns)) - for _, fn := range _g.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) - for _, f := range *_g.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*_g.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// RolePermissionSelect is the builder for selecting fields of RolePermission entities. -type RolePermissionSelect struct { - *RolePermissionQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (_s *RolePermissionSelect) Aggregate(fns ...AggregateFunc) *RolePermissionSelect { - _s.fns = append(_s.fns, fns...) - return _s -} - -// Scan applies the selector query and scans the result into the given value. -func (_s *RolePermissionSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) - if err := _s.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*RolePermissionQuery, *RolePermissionSelect](ctx, _s.RolePermissionQuery, _s, _s.inters, v) -} - -func (_s *RolePermissionSelect) sqlScan(ctx context.Context, root *RolePermissionQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(_s.fns)) - for _, fn := range _s.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*_s.selector.flds); { - case n == 0 && len(aggregation) > 0: - selector.Select(aggregation...) - case n != 0 && len(aggregation) > 0: - selector.AppendSelect(aggregation...) - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _s.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_s *RolePermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *RolePermissionSelect { - _s.modifiers = append(_s.modifiers, modifiers...) - return _s -} diff --git a/internal/features/system/data/ent/rolepermission_update.go b/internal/features/system/data/ent/rolepermission_update.go deleted file mode 100644 index 822748e3..00000000 --- a/internal/features/system/data/ent/rolepermission_update.go +++ /dev/null @@ -1,493 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/rolepermission" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// RolePermissionUpdate is the builder for updating RolePermission entities. -type RolePermissionUpdate struct { - config - hooks []Hook - mutation *RolePermissionMutation - modifiers []func(*sql.UpdateBuilder) -} - -// Where appends a list predicates to the RolePermissionUpdate builder. -func (_u *RolePermissionUpdate) Where(ps ...predicate.RolePermission) *RolePermissionUpdate { - _u.mutation.Where(ps...) - return _u -} - -// SetRoleID sets the "role_id" field. -func (_u *RolePermissionUpdate) SetRoleID(v int64) *RolePermissionUpdate { - _u.mutation.SetRoleID(v) - return _u -} - -// SetNillableRoleID sets the "role_id" field if the given value is not nil. -func (_u *RolePermissionUpdate) SetNillableRoleID(v *int64) *RolePermissionUpdate { - if v != nil { - _u.SetRoleID(*v) - } - return _u -} - -// SetPermissionID sets the "permission_id" field. -func (_u *RolePermissionUpdate) SetPermissionID(v int64) *RolePermissionUpdate { - _u.mutation.SetPermissionID(v) - return _u -} - -// SetNillablePermissionID sets the "permission_id" field if the given value is not nil. -func (_u *RolePermissionUpdate) SetNillablePermissionID(v *int64) *RolePermissionUpdate { - if v != nil { - _u.SetPermissionID(*v) - } - return _u -} - -// SetRole sets the "role" edge to the Role entity. -func (_u *RolePermissionUpdate) SetRole(v *Role) *RolePermissionUpdate { - return _u.SetRoleID(v.ID) -} - -// SetPermission sets the "permission" edge to the Permission entity. -func (_u *RolePermissionUpdate) SetPermission(v *Permission) *RolePermissionUpdate { - return _u.SetPermissionID(v.ID) -} - -// Mutation returns the RolePermissionMutation object of the builder. -func (_u *RolePermissionUpdate) Mutation() *RolePermissionMutation { - return _u.mutation -} - -// ClearRole clears the "role" edge to the Role entity. -func (_u *RolePermissionUpdate) ClearRole() *RolePermissionUpdate { - _u.mutation.ClearRole() - return _u -} - -// ClearPermission clears the "permission" edge to the Permission entity. -func (_u *RolePermissionUpdate) ClearPermission() *RolePermissionUpdate { - _u.mutation.ClearPermission() - return _u -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (_u *RolePermissionUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *RolePermissionUpdate) SaveX(ctx context.Context) int { - affected, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (_u *RolePermissionUpdate) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *RolePermissionUpdate) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *RolePermissionUpdate) check() error { - if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "RolePermission.role"`) - } - if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "RolePermission.permission"`) - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *RolePermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RolePermissionUpdate { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *RolePermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(rolepermission.Table, rolepermission.Columns, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if _u.mutation.RoleCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: rolepermission.RoleTable, - Columns: []string{rolepermission.RoleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: rolepermission.RoleTable, - Columns: []string{rolepermission.RoleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.PermissionCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: rolepermission.PermissionTable, - Columns: []string{rolepermission.PermissionColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: rolepermission.PermissionTable, - Columns: []string{rolepermission.PermissionColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{rolepermission.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - _u.mutation.done = true - return _node, nil -} - -// RolePermissionUpdateOne is the builder for updating a single RolePermission entity. -type RolePermissionUpdateOne struct { - config - fields []string - hooks []Hook - mutation *RolePermissionMutation - modifiers []func(*sql.UpdateBuilder) -} - -// SetRoleID sets the "role_id" field. -func (_u *RolePermissionUpdateOne) SetRoleID(v int64) *RolePermissionUpdateOne { - _u.mutation.SetRoleID(v) - return _u -} - -// SetNillableRoleID sets the "role_id" field if the given value is not nil. -func (_u *RolePermissionUpdateOne) SetNillableRoleID(v *int64) *RolePermissionUpdateOne { - if v != nil { - _u.SetRoleID(*v) - } - return _u -} - -// SetPermissionID sets the "permission_id" field. -func (_u *RolePermissionUpdateOne) SetPermissionID(v int64) *RolePermissionUpdateOne { - _u.mutation.SetPermissionID(v) - return _u -} - -// SetNillablePermissionID sets the "permission_id" field if the given value is not nil. -func (_u *RolePermissionUpdateOne) SetNillablePermissionID(v *int64) *RolePermissionUpdateOne { - if v != nil { - _u.SetPermissionID(*v) - } - return _u -} - -// SetRole sets the "role" edge to the Role entity. -func (_u *RolePermissionUpdateOne) SetRole(v *Role) *RolePermissionUpdateOne { - return _u.SetRoleID(v.ID) -} - -// SetPermission sets the "permission" edge to the Permission entity. -func (_u *RolePermissionUpdateOne) SetPermission(v *Permission) *RolePermissionUpdateOne { - return _u.SetPermissionID(v.ID) -} - -// Mutation returns the RolePermissionMutation object of the builder. -func (_u *RolePermissionUpdateOne) Mutation() *RolePermissionMutation { - return _u.mutation -} - -// ClearRole clears the "role" edge to the Role entity. -func (_u *RolePermissionUpdateOne) ClearRole() *RolePermissionUpdateOne { - _u.mutation.ClearRole() - return _u -} - -// ClearPermission clears the "permission" edge to the Permission entity. -func (_u *RolePermissionUpdateOne) ClearPermission() *RolePermissionUpdateOne { - _u.mutation.ClearPermission() - return _u -} - -// Where appends a list predicates to the RolePermissionUpdate builder. -func (_u *RolePermissionUpdateOne) Where(ps ...predicate.RolePermission) *RolePermissionUpdateOne { - _u.mutation.Where(ps...) - return _u -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (_u *RolePermissionUpdateOne) Select(field string, fields ...string) *RolePermissionUpdateOne { - _u.fields = append([]string{field}, fields...) - return _u -} - -// Save executes the query and returns the updated RolePermission entity. -func (_u *RolePermissionUpdateOne) Save(ctx context.Context) (*RolePermission, error) { - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *RolePermissionUpdateOne) SaveX(ctx context.Context) *RolePermission { - node, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (_u *RolePermissionUpdateOne) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *RolePermissionUpdateOne) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *RolePermissionUpdateOne) check() error { - if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "RolePermission.role"`) - } - if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "RolePermission.permission"`) - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *RolePermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RolePermissionUpdateOne { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePermission, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(rolepermission.Table, rolepermission.Columns, sqlgraph.NewFieldSpec(rolepermission.FieldID, field.TypeInt)) - id, ok := _u.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RolePermission.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := _u.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, rolepermission.FieldID) - for _, f := range fields { - if !rolepermission.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != rolepermission.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if _u.mutation.RoleCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: rolepermission.RoleTable, - Columns: []string{rolepermission.RoleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: rolepermission.RoleTable, - Columns: []string{rolepermission.RoleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.PermissionCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: rolepermission.PermissionTable, - Columns: []string{rolepermission.PermissionColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: rolepermission.PermissionTable, - Columns: []string{rolepermission.PermissionColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - _node = &RolePermission{config: _u.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{rolepermission.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - _u.mutation.done = true - return _node, nil -} - -// SetRolePermission set the RolePermission -func (rpu *RolePermissionUpdate) SetRolePermission(input *RolePermission, fields ...string) *RolePermissionUpdate { - m := rpu.mutation - if len(fields) == 0 { - fields = rolepermission.OmitColumns(rolepermission.FieldID) - } - _ = m.SetFields(input, fields...) - return rpu -} - -// SetRolePermissionWithZero set the RolePermission -func (rpu *RolePermissionUpdate) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionUpdate { - m := rpu.mutation - if len(fields) == 0 { - fields = rolepermission.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return rpu -} - -// SetRolePermission set the RolePermission -func (rpuo *RolePermissionUpdateOne) SetRolePermission(input *RolePermission, fields ...string) *RolePermissionUpdateOne { - m := rpuo.mutation - if len(fields) == 0 { - fields = rolepermission.OmitColumns(rolepermission.FieldID) - } - _ = m.SetFields(input, fields...) - return rpuo -} - -// SetRolePermissionWithZero set the RolePermission -func (rpuo *RolePermissionUpdateOne) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionUpdateOne { - m := rpuo.mutation - if len(fields) == 0 { - fields = rolepermission.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return rpuo -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -func (rpuo *RolePermissionUpdateOne) Omit(fields ...string) *RolePermissionUpdateOne { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - rpuo.fields = []string(nil) - for _, col := range rolepermission.Columns { - if _, ok := omits[col]; !ok { - rpuo.fields = append(rpuo.fields, col) - } - } - return rpuo -} diff --git a/internal/features/system/data/ent/runtime.go b/internal/features/system/data/ent/runtime.go deleted file mode 100644 index e291b037..00000000 --- a/internal/features/system/data/ent/runtime.go +++ /dev/null @@ -1,262 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/data/ent/resource" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/schema" - "origadmin/application/admin/internal/features/system/data/ent/user" - "time" -) - -// The init function reads all schema descriptors with runtime code -// (default values, validators, hooks and policies) and stitches it -// to their package variables. -func init() { - permissionMixin := schema.Permission{}.Mixin() - permissionMixinFields0 := permissionMixin[0].Fields() - _ = permissionMixinFields0 - permissionFields := schema.Permission{}.Fields() - _ = permissionFields - // permissionDescCreateTime is the schema descriptor for create_time field. - permissionDescCreateTime := permissionMixinFields0[0].Descriptor() - // permission.DefaultCreateTime holds the default value on creation for the create_time field. - permission.DefaultCreateTime = permissionDescCreateTime.Default.(func() time.Time) - // permissionDescUpdateTime is the schema descriptor for update_time field. - permissionDescUpdateTime := permissionMixinFields0[1].Descriptor() - // permission.DefaultUpdateTime holds the default value on creation for the update_time field. - permission.DefaultUpdateTime = permissionDescUpdateTime.Default.(func() time.Time) - // permission.UpdateDefaultUpdateTime holds the default value on update for the update_time field. - permission.UpdateDefaultUpdateTime = permissionDescUpdateTime.UpdateDefault.(func() time.Time) - // permissionDescName is the schema descriptor for name field. - permissionDescName := permissionFields[1].Descriptor() - // permission.DefaultName holds the default value on creation for the name field. - permission.DefaultName = permissionDescName.Default.(string) - // permission.NameValidator is a validator for the "name" field. It is called by the builders before save. - permission.NameValidator = permissionDescName.Validators[0].(func(string) error) - // permissionDescKeyword is the schema descriptor for keyword field. - permissionDescKeyword := permissionFields[2].Descriptor() - // permission.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - permission.KeywordValidator = permissionDescKeyword.Validators[0].(func(string) error) - // permissionDescDescription is the schema descriptor for description field. - permissionDescDescription := permissionFields[3].Descriptor() - // permission.DefaultDescription holds the default value on creation for the description field. - permission.DefaultDescription = permissionDescDescription.Default.(string) - // permission.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - permission.DescriptionValidator = permissionDescDescription.Validators[0].(func(string) error) - // permissionDescDataScope is the schema descriptor for data_scope field. - permissionDescDataScope := permissionFields[4].Descriptor() - // permission.DefaultDataScope holds the default value on creation for the data_scope field. - permission.DefaultDataScope = permissionDescDataScope.Default.(string) - resourceMixin := schema.Resource{}.Mixin() - resourceMixinFields0 := resourceMixin[0].Fields() - _ = resourceMixinFields0 - resourceFields := schema.Resource{}.Fields() - _ = resourceFields - // resourceDescCreateTime is the schema descriptor for create_time field. - resourceDescCreateTime := resourceMixinFields0[0].Descriptor() - // resource.DefaultCreateTime holds the default value on creation for the create_time field. - resource.DefaultCreateTime = resourceDescCreateTime.Default.(func() time.Time) - // resourceDescUpdateTime is the schema descriptor for update_time field. - resourceDescUpdateTime := resourceMixinFields0[1].Descriptor() - // resource.DefaultUpdateTime holds the default value on creation for the update_time field. - resource.DefaultUpdateTime = resourceDescUpdateTime.Default.(func() time.Time) - // resource.UpdateDefaultUpdateTime holds the default value on update for the update_time field. - resource.UpdateDefaultUpdateTime = resourceDescUpdateTime.UpdateDefault.(func() time.Time) - // resourceDescName is the schema descriptor for name field. - resourceDescName := resourceFields[1].Descriptor() - // resource.DefaultName holds the default value on creation for the name field. - resource.DefaultName = resourceDescName.Default.(string) - // resource.NameValidator is a validator for the "name" field. It is called by the builders before save. - resource.NameValidator = resourceDescName.Validators[0].(func(string) error) - // resourceDescKeyword is the schema descriptor for keyword field. - resourceDescKeyword := resourceFields[2].Descriptor() - // resource.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - resource.KeywordValidator = resourceDescKeyword.Validators[0].(func(string) error) - // resourceDescType is the schema descriptor for type field. - resourceDescType := resourceFields[3].Descriptor() - // resource.DefaultType holds the default value on creation for the type field. - resource.DefaultType = resourceDescType.Default.(string) - // resource.TypeValidator is a validator for the "type" field. It is called by the builders before save. - resource.TypeValidator = resourceDescType.Validators[0].(func(string) error) - // resourceDescStatus is the schema descriptor for status field. - resourceDescStatus := resourceFields[4].Descriptor() - // resource.DefaultStatus holds the default value on creation for the status field. - resource.DefaultStatus = resourceDescStatus.Default.(int8) - // resourceDescPath is the schema descriptor for path field. - resourceDescPath := resourceFields[5].Descriptor() - // resource.DefaultPath holds the default value on creation for the path field. - resource.DefaultPath = resourceDescPath.Default.(string) - // resource.PathValidator is a validator for the "path" field. It is called by the builders before save. - resource.PathValidator = resourceDescPath.Validators[0].(func(string) error) - // resourceDescComponent is the schema descriptor for component field. - resourceDescComponent := resourceFields[6].Descriptor() - // resource.DefaultComponent holds the default value on creation for the component field. - resource.DefaultComponent = resourceDescComponent.Default.(string) - // resource.ComponentValidator is a validator for the "component" field. It is called by the builders before save. - resource.ComponentValidator = resourceDescComponent.Validators[0].(func(string) error) - // resourceDescIcon is the schema descriptor for icon field. - resourceDescIcon := resourceFields[7].Descriptor() - // resource.DefaultIcon holds the default value on creation for the icon field. - resource.DefaultIcon = resourceDescIcon.Default.(string) - // resource.IconValidator is a validator for the "icon" field. It is called by the builders before save. - resource.IconValidator = resourceDescIcon.Validators[0].(func(string) error) - // resourceDescSequence is the schema descriptor for sequence field. - resourceDescSequence := resourceFields[8].Descriptor() - // resource.DefaultSequence holds the default value on creation for the sequence field. - resource.DefaultSequence = resourceDescSequence.Default.(int) - // resourceDescVisible is the schema descriptor for visible field. - resourceDescVisible := resourceFields[9].Descriptor() - // resource.DefaultVisible holds the default value on creation for the visible field. - resource.DefaultVisible = resourceDescVisible.Default.(bool) - // resourceDescLevel is the schema descriptor for level field. - resourceDescLevel := resourceFields[10].Descriptor() - // resource.DefaultLevel holds the default value on creation for the level field. - resource.DefaultLevel = resourceDescLevel.Default.(int8) - // resourceDescTreePath is the schema descriptor for tree_path field. - resourceDescTreePath := resourceFields[11].Descriptor() - // resource.DefaultTreePath holds the default value on creation for the tree_path field. - resource.DefaultTreePath = resourceDescTreePath.Default.(string) - // resource.TreePathValidator is a validator for the "tree_path" field. It is called by the builders before save. - resource.TreePathValidator = resourceDescTreePath.Validators[0].(func(string) error) - // resourceDescDescription is the schema descriptor for description field. - resourceDescDescription := resourceFields[13].Descriptor() - // resource.DefaultDescription holds the default value on creation for the description field. - resource.DefaultDescription = resourceDescDescription.Default.(string) - // resource.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - resource.DescriptionValidator = resourceDescDescription.Validators[0].(func(string) error) - roleMixin := schema.Role{}.Mixin() - roleMixinFields0 := roleMixin[0].Fields() - _ = roleMixinFields0 - roleFields := schema.Role{}.Fields() - _ = roleFields - // roleDescCreateTime is the schema descriptor for create_time field. - roleDescCreateTime := roleMixinFields0[0].Descriptor() - // role.DefaultCreateTime holds the default value on creation for the create_time field. - role.DefaultCreateTime = roleDescCreateTime.Default.(func() time.Time) - // roleDescUpdateTime is the schema descriptor for update_time field. - roleDescUpdateTime := roleMixinFields0[1].Descriptor() - // role.DefaultUpdateTime holds the default value on creation for the update_time field. - role.DefaultUpdateTime = roleDescUpdateTime.Default.(func() time.Time) - // role.UpdateDefaultUpdateTime holds the default value on update for the update_time field. - role.UpdateDefaultUpdateTime = roleDescUpdateTime.UpdateDefault.(func() time.Time) - // roleDescKeyword is the schema descriptor for keyword field. - roleDescKeyword := roleFields[1].Descriptor() - // role.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - role.KeywordValidator = roleDescKeyword.Validators[0].(func(string) error) - // roleDescName is the schema descriptor for name field. - roleDescName := roleFields[2].Descriptor() - // role.DefaultName holds the default value on creation for the name field. - role.DefaultName = roleDescName.Default.(string) - // role.NameValidator is a validator for the "name" field. It is called by the builders before save. - role.NameValidator = roleDescName.Validators[0].(func(string) error) - // roleDescDescription is the schema descriptor for description field. - roleDescDescription := roleFields[3].Descriptor() - // role.DefaultDescription holds the default value on creation for the description field. - role.DefaultDescription = roleDescDescription.Default.(string) - // role.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - role.DescriptionValidator = roleDescDescription.Validators[0].(func(string) error) - // roleDescType is the schema descriptor for type field. - roleDescType := roleFields[4].Descriptor() - // role.DefaultType holds the default value on creation for the type field. - role.DefaultType = roleDescType.Default.(int8) - // roleDescSequence is the schema descriptor for sequence field. - roleDescSequence := roleFields[5].Descriptor() - // role.DefaultSequence holds the default value on creation for the sequence field. - role.DefaultSequence = roleDescSequence.Default.(int) - // roleDescStatus is the schema descriptor for status field. - roleDescStatus := roleFields[6].Descriptor() - // role.DefaultStatus holds the default value on creation for the status field. - role.DefaultStatus = roleDescStatus.Default.(int8) - userMixin := schema.User{}.Mixin() - userMixinFields0 := userMixin[0].Fields() - _ = userMixinFields0 - userFields := schema.User{}.Fields() - _ = userFields - // userDescCreateTime is the schema descriptor for create_time field. - userDescCreateTime := userMixinFields0[0].Descriptor() - // user.DefaultCreateTime holds the default value on creation for the create_time field. - user.DefaultCreateTime = userDescCreateTime.Default.(func() time.Time) - // userDescUpdateTime is the schema descriptor for update_time field. - userDescUpdateTime := userMixinFields0[1].Descriptor() - // user.DefaultUpdateTime holds the default value on creation for the update_time field. - user.DefaultUpdateTime = userDescUpdateTime.Default.(func() time.Time) - // user.UpdateDefaultUpdateTime holds the default value on update for the update_time field. - user.UpdateDefaultUpdateTime = userDescUpdateTime.UpdateDefault.(func() time.Time) - // userDescUUID is the schema descriptor for uuid field. - userDescUUID := userFields[1].Descriptor() - // user.UUIDValidator is a validator for the "uuid" field. It is called by the builders before save. - user.UUIDValidator = userDescUUID.Validators[0].(func(string) error) - // userDescAllowedIP is the schema descriptor for allowed_ip field. - userDescAllowedIP := userFields[2].Descriptor() - // user.DefaultAllowedIP holds the default value on creation for the allowed_ip field. - user.DefaultAllowedIP = userDescAllowedIP.Default.(string) - // userDescUsername is the schema descriptor for username field. - userDescUsername := userFields[3].Descriptor() - // user.UsernameValidator is a validator for the "username" field. It is called by the builders before save. - user.UsernameValidator = userDescUsername.Validators[0].(func(string) error) - // userDescNickname is the schema descriptor for nickname field. - userDescNickname := userFields[4].Descriptor() - // user.DefaultNickname holds the default value on creation for the nickname field. - user.DefaultNickname = userDescNickname.Default.(string) - // user.NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. - user.NicknameValidator = userDescNickname.Validators[0].(func(string) error) - // userDescAvatar is the schema descriptor for avatar field. - userDescAvatar := userFields[5].Descriptor() - // user.DefaultAvatar holds the default value on creation for the avatar field. - user.DefaultAvatar = userDescAvatar.Default.(string) - // user.AvatarValidator is a validator for the "avatar" field. It is called by the builders before save. - user.AvatarValidator = userDescAvatar.Validators[0].(func(string) error) - // userDescName is the schema descriptor for name field. - userDescName := userFields[6].Descriptor() - // user.DefaultName holds the default value on creation for the name field. - user.DefaultName = userDescName.Default.(string) - // user.NameValidator is a validator for the "name" field. It is called by the builders before save. - user.NameValidator = userDescName.Validators[0].(func(string) error) - // userDescPassword is the schema descriptor for password field. - userDescPassword := userFields[8].Descriptor() - // user.DefaultPassword holds the default value on creation for the password field. - user.DefaultPassword = userDescPassword.Default.(string) - // user.PasswordValidator is a validator for the "password" field. It is called by the builders before save. - user.PasswordValidator = userDescPassword.Validators[0].(func(string) error) - // userDescPhone is the schema descriptor for phone field. - userDescPhone := userFields[9].Descriptor() - // user.DefaultPhone holds the default value on creation for the phone field. - user.DefaultPhone = userDescPhone.Default.(string) - // user.PhoneValidator is a validator for the "phone" field. It is called by the builders before save. - user.PhoneValidator = userDescPhone.Validators[0].(func(string) error) - // userDescEmail is the schema descriptor for email field. - userDescEmail := userFields[10].Descriptor() - // user.DefaultEmail holds the default value on creation for the email field. - user.DefaultEmail = userDescEmail.Default.(string) - // user.EmailValidator is a validator for the "email" field. It is called by the builders before save. - user.EmailValidator = userDescEmail.Validators[0].(func(string) error) - // userDescDepartment is the schema descriptor for department field. - userDescDepartment := userFields[11].Descriptor() - // user.DefaultDepartment holds the default value on creation for the department field. - user.DefaultDepartment = userDescDepartment.Default.(string) - // user.DepartmentValidator is a validator for the "department" field. It is called by the builders before save. - user.DepartmentValidator = userDescDepartment.Validators[0].(func(string) error) - // userDescRemark is the schema descriptor for remark field. - userDescRemark := userFields[12].Descriptor() - // user.DefaultRemark holds the default value on creation for the remark field. - user.DefaultRemark = userDescRemark.Default.(string) - // user.RemarkValidator is a validator for the "remark" field. It is called by the builders before save. - user.RemarkValidator = userDescRemark.Validators[0].(func(string) error) - // userDescStatus is the schema descriptor for status field. - userDescStatus := userFields[13].Descriptor() - // user.DefaultStatus holds the default value on creation for the status field. - user.DefaultStatus = userDescStatus.Default.(int8) - // userDescIsSystem is the schema descriptor for is_system field. - userDescIsSystem := userFields[14].Descriptor() - // user.DefaultIsSystem holds the default value on creation for the is_system field. - user.DefaultIsSystem = userDescIsSystem.Default.(bool) - // userDescLastLoginIP is the schema descriptor for last_login_ip field. - userDescLastLoginIP := userFields[15].Descriptor() - // user.DefaultLastLoginIP holds the default value on creation for the last_login_ip field. - user.DefaultLastLoginIP = userDescLastLoginIP.Default.(string) - // user.LastLoginIPValidator is a validator for the "last_login_ip" field. It is called by the builders before save. - user.LastLoginIPValidator = userDescLastLoginIP.Validators[0].(func(string) error) -} diff --git a/internal/features/system/data/ent/runtime/runtime.go b/internal/features/system/data/ent/runtime/runtime.go deleted file mode 100644 index 6876c351..00000000 --- a/internal/features/system/data/ent/runtime/runtime.go +++ /dev/null @@ -1,10 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package runtime - -// The schema-stitching logic is generated in origadmin/application/admin/internal/features/system/data/ent/runtime.go - -const ( - Version = "v0.14.5" // Version of ent codegen. - Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen. -) diff --git a/internal/features/system/data/ent/schema/permission.go b/internal/features/system/data/ent/schema/permission.go deleted file mode 100644 index 0e27e5fd..00000000 --- a/internal/features/system/data/ent/schema/permission.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package schema implements the functions, types, and interfaces for the module. -package schema - -import ( - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/mixin" -) - -// Permission holds the schema definition for the Permission entity. -type Permission struct { - ent.Schema -} - -// DataScope 数据范围 -const ( - DataScopeSelf string = "self" // 仅本人数据 - DataScopeDept string = "dept" // 部门数据 - DataScopeRole string = "role" // 角色数据 - DataScopeAll string = "all" // 所有数据 -) - -func (Permission) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("sys_permissions"), - entsql.WithComments(true), - schema.Comment("Permission table"), - } -} - -// Fields of the Permission. -func (Permission) Fields() []ent.Field { - return []ent.Field{ - field.Int64("id"). - Comment("ID"). - Immutable(). - Unique(), - field.String("name").MaxLen(64).Default("").Comment("Name"), - field.String("keyword").MaxLen(64).Unique().Comment("Keyword"), - field.String("description").MaxLen(1024).Default("").Comment("Description"), - field.String("data_scope").Default(DataScopeSelf).Comment("Data scope"), - field.JSON("data_rules", map[string]string{}).Optional().Comment("Data rules"), - field.Enum("actions").Values("read", "write", "delete", "manage").Default("read").Comment("Actions"), - } -} - -// Mixin of the Permission. -func (Permission) Mixin() []ent.Mixin { - return []ent.Mixin{ - mixin.Time{}, - } -} - -// Edges of the Permission. -func (Permission) Edges() []ent.Edge { - return []ent.Edge{ - edge.From("roles", Role.Type). - Ref("permissions"). - Through("role_permissions", RolePermission.Type), - edge.To("resources", Resource.Type). - Through("permission_resources", PermissionResource.Type), - } -} diff --git a/internal/features/system/data/ent/schema/permissionresource.go b/internal/features/system/data/ent/schema/permissionresource.go deleted file mode 100644 index ce0cbbad..00000000 --- a/internal/features/system/data/ent/schema/permissionresource.go +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package schema implements the functions, types, and interfaces for the module. -package schema - -import ( - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" -) - -type PermissionResource struct { - ent.Schema -} - -func (PermissionResource) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("sys_permission_resources"), - entsql.WithComments(true), - schema.Comment("Permission-Resource mapping table"), - } -} - -func (PermissionResource) Fields() []ent.Field { - return []ent.Field{ - field.Int64("permission_id"), - field.Int64("resource_id"), - } -} - -func (PermissionResource) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("permission_id", "resource_id"). - Unique(), - } -} - -func (PermissionResource) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("permission", Permission.Type). - Field("permission_id"). - Unique(). - Required(), - edge.To("resource", Resource.Type). - Field("resource_id"). - Unique(). - Required(), - } -} diff --git a/internal/features/system/data/ent/schema/resource.go b/internal/features/system/data/ent/schema/resource.go deleted file mode 100644 index 7dab39d5..00000000 --- a/internal/features/system/data/ent/schema/resource.go +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package schema implements the functions, types, and interfaces for the module. -package schema - -import ( - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" - "entgo.io/ent/schema/mixin" -) - -const ( - ResourceStatusEnabled int8 = 1 // 启用 - ResourceStatusDisabled int8 = 2 // 禁用 -) -const ( - ResourceTypeUnknown = "U" // 未知 - ResourceTypeRoot = "ROOT" // 根目录 - ResourceTypeGroup = "G" // 分组 - ResourceTypeMenu = "M" // 目录 - ResourceTypePage = "P" // 页面 - ResourceTypeButton = "B" // 按钮 - ResourceTypeAPI = "A" // API接口 - ResourceTypeRedirect = "R" // 重定向 - -) - -// Resource holds the schema definition for the Resource domain. -type Resource struct { - ent.Schema -} - -func (Resource) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("sys_resources"), - entsql.WithComments(true), - schema.Comment("Resource table"), - } -} - -// Fields of the Resource. -func (Resource) Fields() []ent.Field { - return []ent.Field{ - field.Int64("id"). - Comment("ID"). - Immutable(). - Unique(), - field.String("name").MaxLen(128).Default("").Comment("Name"), - field.String("keyword").MaxLen(64).Unique().Comment("Keyword"), - field.String("type").MaxLen(2).Default(ResourceTypeMenu).Comment("Type"), - field.Int8("status").Default(ResourceStatusEnabled).Comment("Status"), - field.String("path").MaxLen(256).Default("").Comment("Path"), - field.String("component").MaxLen(128).Default("").Comment("Component"), - field.String("icon").MaxLen(64).Default("").Comment("Icon"), - field.Int("sequence").Default(0).Comment("Sequence"), - field.Bool("visible").Default(true).Comment("Visible"), - field.Int8("level").Default(0).Comment("Level"), - field.String("tree_path").MaxLen(256).Default("").Comment("Tree path"), - field.JSON("properties", map[string]string{}).Optional().Comment("Properties"), - field.String("description").MaxLen(1024).Default("").Comment("Description"), - field.Int64("parent_id").Optional().Comment("Parent ID"), - } -} - -// Mixin of the Resource. -func (Resource) Mixin() []ent.Mixin { - return []ent.Mixin{ - mixin.Time{}, - } -} - -// Indexes of the Resource. -func (Resource) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("parent_id"), - index.Fields("level"), - } -} - -// Edges of the Resource. -func (Resource) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("children", Resource.Type).From("parent").Field("parent_id").Unique(), - edge.From("permissions", Permission.Type). - Ref("resources"). - Through("permission_resources", PermissionResource.Type), - } -} diff --git a/internal/features/system/data/ent/schema/role.go b/internal/features/system/data/ent/schema/role.go deleted file mode 100644 index 26cf9d14..00000000 --- a/internal/features/system/data/ent/schema/role.go +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package schema implements the functions, types, and interfaces for the module. -package schema - -import ( - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" - "entgo.io/ent/schema/mixin" - - "origadmin/application/admin/internal/data/entity/ent/schema/types" -) - -// Role type constant -const ( - RoleTypeSystem int8 = 1 // System roles (e.g., Super Admin) - RoleTypeUser int8 = 2 // User roles (e.g., general user, operation, customer service) -) - -// Role holds the schema definition for the Role domain. -type Role struct { - ent.Schema -} - -func (Role) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("sys_roles"), - entsql.WithComments(true), - schema.Comment("Role table"), - } -} - -// Fields of the Role. -func (Role) Fields() []ent.Field { - return []ent.Field{ - field.Int64("id"). - Comment("ID"). - Immutable(). - Unique(), - field.String("keyword"). - MaxLen(32). - Unique(). - Comment("keyword of role (unique)"), - field.String("name"). - MaxLen(128). - Default(""). - Comment("Display name of role"), - field.String("description"). - MaxLen(1024). - Default(""). - Comment("Details about role"), - field.Int8("type"). - Default(RoleTypeUser). - Comment("Role type: 1 - System role 2 - User role 3 - Department role"), - field.Int("sequence"). - Default(0). - Comment("Sequence for sorting"), - field.Int8("status"). - Default(types.Active). - Comment("status"), - } -} - -// Mixin of the Role. -func (Role) Mixin() []ent.Mixin { - return []ent.Mixin{ - mixin.Time{}, - } -} - -// Indexes of the Role. -func (Role) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("keyword"), - index.Fields("name"), - index.Fields("sequence"), - index.Fields("status"), - } -} - -// Edges of the Role. -func (Role) Edges() []ent.Edge { - return []ent.Edge{ - edge.From("users", User.Type). - Ref("roles"). - Through("user_roles", UserRole.Type), - edge.To("permissions", Permission.Type). - StorageKey(edge.Columns("role_id", "permission_id")). - Through("role_permissions", RolePermission.Type), - } -} diff --git a/internal/features/system/data/ent/schema/rolepermission.go b/internal/features/system/data/ent/schema/rolepermission.go deleted file mode 100644 index 5b96f816..00000000 --- a/internal/features/system/data/ent/schema/rolepermission.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package schema implements the functions, types, and interfaces for the module. -package schema - -import ( - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" -) - -// RolePermission holds the schema definition for the RolePermission entity. -type RolePermission struct { - ent.Schema -} - -func (RolePermission) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("sys_role_permissions"), - entsql.WithComments(true), - schema.Comment("Role-Permission mapping table"), - } -} - -// Fields of the RolePermission. -func (RolePermission) Fields() []ent.Field { - return []ent.Field{ - field.Int64("role_id"), - field.Int64("permission_id"), - } -} - -// Indexes of the RolePermission. -func (RolePermission) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("role_id", "permission_id"). - Unique(), - } -} - -// Edges of the RolePermission. -func (RolePermission) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("role", Role.Type). - Field("role_id"). - Unique(). - Required(), - edge.To("permission", Permission.Type). - Field("permission_id"). - Unique(). - Required(), - } -} diff --git a/internal/features/system/data/ent/schema/user.go b/internal/features/system/data/ent/schema/user.go deleted file mode 100644 index 3008ff96..00000000 --- a/internal/features/system/data/ent/schema/user.go +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package schema implements the functions, types, and interfaces for the module. -package schema - -import ( - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" - "entgo.io/ent/schema/mixin" - - "origadmin/application/admin/internal/data/entity/ent/schema/types" -) - -const ( - UserStatusActive = types.Active - UserStatusFrozen = types.Frozen -) - -const ( - UserGenderMale = "male" - UserGenderFemale = "female" - UserGenderUnknown = "unknown" -) - -// User holds the schema definition for the User domain. -type User struct { - ent.Schema -} - -func (User) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("sys_users"), - entsql.WithComments(true), - schema.Comment("User table"), - } -} - -// Fields of the User. -func (User) Fields() []ent.Field { - return []ent.Field{ - field.Int64("id"). - Comment("ID"). - Immutable(). - Unique(), - field.String("uuid").MaxLen(36).Unique().Comment("UUID"), - field.String("allowed_ip").Default("0.0.0.0").Comment("Allowed IP"), - field.String("username").MaxLen(32).Unique().Comment("login username of user"), - field.String("nickname").MaxLen(64).Default("").Comment("Nickname display name of user"), - field.String("avatar").MaxLen(256).Default("").Comment("Avatar display avatar of user"), - field.String("name").MaxLen(64).Default("").Comment("Name of user"), - field.Enum("gender").Values(UserGenderMale, UserGenderFemale, UserGenderUnknown).Default(UserGenderUnknown).Comment("Gender of user"), - field.String("password").MaxLen(256).Default("").Sensitive().Comment("Encrypted password"), - field.String("phone").MaxLen(32).Default("").Comment("login phone number of user"), - field.String("email").MaxLen(64).Default("").Comment("login email of user"), - field.String("department").MaxLen(64).Default("").Comment("Department of user"), - field.String("remark").MaxLen(1024).Default("").Comment("Remark of user"), - field.Int8("status").Default(UserStatusActive).Comment("status"), - field.Bool("is_system").Default(false).Comment("Whether the system is built-in"), - field.String("last_login_ip").MaxLen(32).Default("").Comment("Last login IP"), - field.Time("last_login_time").Optional().Comment("Last login time"), - } -} - -// Mixin of the User. -func (User) Mixin() []ent.Mixin { - return []ent.Mixin{ - mixin.Time{}, - } -} - -// Indexes of the User. -func (User) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("username"), - index.Fields("phone"), - index.Fields("email"), - index.Fields("status"), - } -} - -// Edges of the User. -func (User) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("roles", Role.Type). - Through("user_roles", UserRole.Type), - } -} diff --git a/internal/features/system/data/ent/schema/userrole.go b/internal/features/system/data/ent/schema/userrole.go deleted file mode 100644 index aff01384..00000000 --- a/internal/features/system/data/ent/schema/userrole.go +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package schema implements the functions, types, and interfaces for the module. -package schema - -import ( - "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" -) - -// UserRole holds the schema definition for the UserRole domain. -type UserRole struct { - ent.Schema -} - -func (UserRole) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("sys_user_roles"), - entsql.WithComments(true), - schema.Comment("User-Role mapping table"), - } -} - -// Fields of the UserRole. -func (UserRole) Fields() []ent.Field { - return []ent.Field{ - field.Int64("user_id"), - field.Int64("role_id"), - } -} - -// Indexes of the UserRole. -func (UserRole) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("user_id", "role_id"). - Unique(), - } -} - -// Edges of the UserRole. -func (UserRole) Edges() []ent.Edge { - return []ent.Edge{ - edge.To("user", User.Type). - Field("user_id"). - Required(). - Unique(), - edge.To("role", Role.Type). - Field("role_id"). - Required(). - Unique(), - } -} diff --git a/internal/features/system/data/ent/template/crud.tpl b/internal/features/system/data/ent/template/crud.tpl deleted file mode 100644 index d119b8c5..00000000 --- a/internal/features/system/data/ent/template/crud.tpl +++ /dev/null @@ -1,40 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Graph */}} - -{{ define "crud" }} - {{- $pkg := base $.Config.Package -}} - {{- template "header" $ -}} - - {{/* Additional dependencies injected to config. */}} - {{ $deps := list }}{{ with $.Config.Annotations }}{{ $deps = $.Config.Annotations.Dependencies }}{{ end }} - - import ( - "log" - - "entgo.io/ent/dialect" - - {{- range $n := $.Nodes }} - {{ $n.PackageAlias }} "{{ $n.Config.Package }}/{{ $n.PackageDir }}" - {{- end }} - {{- range $dep := $deps }} - {{ $dep.Type.PkgName }} "{{ $dep.Type.PkgPath }}" - {{- end }} - "{{ $.Config.Package }}/migrate" - {{- range $import := $.Storage.Imports }} - "{{ $import }}" - {{- end -}} - {{- template "import/additional" $ }} - ) - - {{ range $n := $.Nodes }} - {{- /* Support adding create methods by global templates. */}} - {{- with $tmpls := matchTemplate "crud/helper/*" }} - {{- range $tmpl := $tmpls }} - {{ xtemplate $tmpl $n }} - {{- end }} - {{- end }} - {{ end }} - -{{ end }} - - diff --git a/internal/features/system/data/ent/template/crud_create.tpl b/internal/features/system/data/ent/template/crud_create.tpl deleted file mode 100644 index bfd1fa84..00000000 --- a/internal/features/system/data/ent/template/crud_create.tpl +++ /dev/null @@ -1,34 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Graph */}} - -{{ define "create/additional/crud" }} - - {{ $builder := .CreateName }} - {{ $receiver := .CreateReceiver }} - {{ $fields := .Fields }} - {{- $const := print .Package}} - {{- if .ID.UserDefined }} - {{ $fields = append $fields .ID }} - {{- end }} - - {{ print "// Set" .Name " set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{ $const }}.Columns - } - _ = m.SetFields(input, fields...) - return {{ $receiver }} - } - - {{ print "// Set" .Name "WithZero set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{ $const }}.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return {{ $receiver }} - } - -{{- end -}} diff --git a/internal/features/system/data/ent/template/crud_query.tpl b/internal/features/system/data/ent/template/crud_query.tpl deleted file mode 100644 index da033c1d..00000000 --- a/internal/features/system/data/ent/template/crud_query.tpl +++ /dev/null @@ -1,48 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Type */}} - -{{ define "query/additional/crud" }} - - {{ $pkg := .Package }} - {{ $fields := .Fields }} - {{ $builder := .QueryName }} - {{ $receiver := receiver $builder }} - {{ $selectBuilder := pascal .Name | printf "%sSelect" }} - - // Omit allows the unselect one or more fields/columns for the given query, - // instead of selecting all fields in the entity. - {{- with len $fields }} - // Example: - // - // var v []struct { - {{- range $f := $fields }} - // {{ $f.StructField }} {{ $f.Type }} `{{ $f.StructTag }}` - {{- end }} - // } - // - // client.{{ pascal $.Name }}.Query(). - // Omit( - {{- range $f := $fields }} - // {{ $pkg }}.{{ $f.Constant }}, - {{- end }} - // ). - // Scan(ctx, &v) - {{- end }} - func ({{ $receiver }} *{{ $builder }}) Omit(fields ...string) *{{ $selectBuilder }} { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - for _, col := range {{ $pkg }}.Columns { - if _, ok := omits[col]; !ok { - {{ $receiver }}.ctx.Fields = append({{ $receiver }}.ctx.Fields, col) - } - } - - sbuild := &{{ $selectBuilder }}{ {{ $builder }}: {{ $receiver }} } - sbuild.label = {{ $pkg }}.Label - sbuild.flds, sbuild.scan = &{{ $receiver }}.ctx.Fields, sbuild.Scan - return sbuild - } - -{{- end -}} diff --git a/internal/features/system/data/ent/template/crud_update.tpl b/internal/features/system/data/ent/template/crud_update.tpl deleted file mode 100644 index 17b34147..00000000 --- a/internal/features/system/data/ent/template/crud_update.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Graph */}} - -{{ define "update/additional/crud/update" }} - - {{ $builder := .UpdateName }} - {{ $receiver := receiver $builder }} - {{ $fields := .Fields }} - {{- if or (hasSuffix $builder "Update") (hasSuffix $builder "UpdateOne") }} - {{ $fields = .MutableFields }} - {{- end }} - - {{ print "// Set" .Name " set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { - {{- $const := print .Package}} - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{$const}}.OmitColumns({{$const}}.FieldID) - } - _ = m.SetFields(input, fields...) - return {{ $receiver }} - } - - {{ print "// Set" .Name "WithZero set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{ $const }}.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return {{ $receiver }} - } -{{- end -}} diff --git a/internal/features/system/data/ent/template/crud_update_one.tpl b/internal/features/system/data/ent/template/crud_update_one.tpl deleted file mode 100644 index e384a498..00000000 --- a/internal/features/system/data/ent/template/crud_update_one.tpl +++ /dev/null @@ -1,48 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Graph */}} - -{{ define "update/additional/crud_one" }} - {{ $builder := $.UpdateOneName }} - {{- if hasSuffix $builder "UpdateOne" }} - {{ $receiver := receiver $builder }} - {{ print "// Set" .Name " set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { - {{- $const := print .Package}} - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{$const}}.OmitColumns({{$const}}.FieldID) - } - _ = m.SetFields(input, fields...) - return {{ $receiver }} - } - - {{ print "// Set" .Name "WithZero set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{ $const }}.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return {{ $receiver }} - } - - {{ $onebuilder := $.UpdateOneName }} - {{ $receiver = receiver $onebuilder }} - // Omit allows the unselect one or more fields/columns for the given query, - // instead of selecting all fields in the entity. - func ({{ $receiver }} *{{ $onebuilder }}) Omit(fields ...string) *{{ $onebuilder }} { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - {{ $receiver }}.fields = []string(nil) - for _, col := range {{ .Package }}.Columns { - if _, ok := omits[col]; !ok { - {{ $receiver }}.fields = append({{ $receiver }}.fields, col) - } - } - return {{ $receiver }} - } - {{- end }} - -{{- end -}} diff --git a/internal/features/system/data/ent/template/database.tpl b/internal/features/system/data/ent/template/database.tpl deleted file mode 100644 index 05bbdd69..00000000 --- a/internal/features/system/data/ent/template/database.tpl +++ /dev/null @@ -1,126 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based *gen.Type type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Type */}} - - -{{ define "database" }} - {{ $pkg := base $.Config.Package -}} - {{ template "header" $ }} - - /* Additional dependencies injected to config. */ - {{ $deps := list }}{{ with $.Config.Annotations }}{{ $deps = $.Config.Annotations.Dependencies }}{{ end }} - - import ( - "context" - "fmt" - "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime/interfaces/storage/database" - ) - - // Database is the client that holds all ent builders. - type Database struct { - client *Client - } - - // NewDatabase creates a new database configured with the given options. - func NewDatabase(opts ...Option) *Database { - client := NewClient(opts...) - return &Database{client: client} - } - - // NewDatabase creates a new database configured with the given options. - func NewDatabaseWithClient(client *Client,opts ...Option) *Database { - if client == nil { - client = NewClient(opts...) - } - return &Database{client: client} - } - - func (db *Database) clientDriver(ctx context.Context) dialect.Driver { - tx := TxFromContext(ctx) - c := db.client - if tx != nil { - c = tx.Client() - } - return c.driver - } - - // Tx runs the given function f within a transaction. - func (db *Database) Tx(ctx context.Context, fn func(context.Context) error) error { - tx := TxFromContext(ctx) - if tx != nil { - return fn(ctx) - } - - return db.InTx(ctx, func (tx database.Tx) error { - txv, ok := tx.(*Tx) - if !ok { - return fmt.Errorf("ent: expected tx context") - } - return fn(NewTxContext(ctx, txv)) - }) - } - - // InTx runs the given function f within a transaction. - func (db *Database) InTx(ctx context.Context, fn func(tx database.Tx) error) error { - tx := TxFromContext(ctx) - if tx != nil { - return fn(tx) - } - tx, err := db.client.Tx(ctx) - if err != nil { - return fmt.Errorf("starting transaction: %w", err) - } - if err = fn(tx); err != nil { - if txerr := tx.Rollback(); txerr != nil { - return fmt.Errorf("rolling back transaction: %v (original error: %w)", txerr, err) - } - return err - } - if err := tx.Commit(); err != nil { - return fmt.Errorf("committing transaction: %w", err) - } - return nil - } - - // Client returns the client that holds all ent builders. - func (db *Database) Client(ctx context.Context) *Client { - tx := TxFromContext(ctx) - if tx != nil { - return tx.Client() - } - return db.client - } - - // Exec executes a query that doesn't return rows. For example, in SQL, INSERT or UPDATE. - func (db *Database) Exec(ctx context.Context, query string, args ...interface{}) (*sql.Result, error) { - var res sql.Result - err := db.clientDriver(ctx).Exec(ctx, query, args, &res) - if err != nil { - return nil, err - } - return &res, nil - } - - // Query executes a query that returns rows, typically a SELECT in SQL. - func (db *Database) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) { - var rows sql.Rows - err := db.clientDriver(ctx).Query(ctx, query, args, &rows) - if err != nil { - return nil, err - } - return &rows, nil - } - - {{ range $n := $.Nodes }} - {{ $client := print $n.Name "Client" }} - // {{ $n.Name }} is the client for interacting with the {{ $n.Name }} builders. - func (db *Database) {{ $n.Name }}(ctx context.Context) *{{ $client }} { - return db.Client(ctx).{{ $n.Name }} - } - {{ end }} - - func (db *Database) Migration(ctx context.Context,opts ...schema.MigrateOption) error { - return db.Client(ctx).Schema.Create(ctx, opts...) - } - -{{ end }} \ No newline at end of file diff --git a/internal/features/system/data/ent/template/mutation_fields.tpl b/internal/features/system/data/ent/template/mutation_fields.tpl deleted file mode 100644 index 3f9fd0e6..00000000 --- a/internal/features/system/data/ent/template/mutation_fields.tpl +++ /dev/null @@ -1,119 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Graph */}} - -{{ define "mutation_fields" }} - {{- $pkg := base $.Config.Package -}} - {{- template "header" $ -}} - - {{/* Additional dependencies injected to config. */}} - {{ $deps := list }}{{ with $.Config.Annotations }}{{ $deps = $.Config.Annotations.Dependencies }}{{ end }} - - import ( - "log" - - "entgo.io/ent/dialect" - - {{- range $n := $.Nodes }} - {{ $n.PackageAlias }} "{{ $n.Config.Package }}/{{ $n.PackageDir }}" - {{- end }} - {{- range $dep := $deps }} - {{ $dep.Type.PkgName }} "{{ $dep.Type.PkgPath }}" - {{- end }} - "{{ $.Config.Package }}/migrate" - {{- range $import := $.Storage.Imports }} - "{{ $import }}" - {{- end -}} - {{- template "import/additional" $ }} - ) - - {{ range $n := $.MutableNodes }} - {{ $fields := $n.Fields }} - {{- if .ID.UserDefined }} - {{ $fields = append $fields .ID }} - {{- end }} - {{ $mutation := $n.MutationName }} - // SetFields sets the values of the fields with the given names. It returns an - // error if the field is not defined in the schema, or if the type mismatched the - // field type. - func (m *{{ $mutation }}) SetFields(input *{{ .Name }}, fields ...string) error { - for i := range fields { - switch fields[i] { - {{- range $f := $fields }} - {{- $const := print $n.Package "." $f.Constant }} - {{- $setter := print "Set" $f.StructField }} - {{- $clear := print "Reset" $f.StructField }} - case {{ $const }}: - {{- if $f.Nillable}} - if input.{{ $f.StructField }} != nil { - m.{{ $setter }}(*input.{{ $f.StructField }}) - }else{ - m.{{ $clear }}() - } - {{- else if $f.IsBool}} - if input.{{ $f.StructField }} { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- else if $f.IsTime}} - if input.{{ $f.StructField }}.Unix() != 0 { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- else if $f.IsJSON}} - if len(input.{{ $f.StructField }}) > 0 { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- else if $f.IsString}} - // check {{$f.Type}} with {{$f.ScanType}} if it is empty - if input.{{ $f.StructField }} != "" { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- else if $f.Type.Numeric}} - // check {{$f.Type}} with {{$f.ScanType}} if it is zero - if input.{{ $f.StructField }} != 0 { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- else }} - var zero {{ $f.Type }} - // check {{$f.Type}} with {{$f.ScanType}} if it is empty - if input.{{ $f.StructField }} != zero { - m.{{ $setter }}(input.{{ $f.StructField }}) - } - {{- end}} - {{- end }} - default: - return fmt.Errorf("unknown {{ .Name }} field %s", fields[i]) - } - } - return nil - } - - // SetFieldsWithZero sets the values of the fields with the given names. It returns an - // error if the field is not defined in the schema, or if the type mismatched the - // field type. - func (m *{{ $mutation }}) SetFieldsWithZero(input *{{ .Name }}, fields ...string) error { - for i := range fields { - switch fields[i] { - {{- range $f := $fields }} - {{- $const := print $n.Package "." $f.Constant }} - {{- $setter := print "Set" $f.StructField }} - {{- $clear := print "Reset" $f.StructField }} - case {{ $const }}: - {{- if $f.Nillable}} - if input.{{ $f.StructField }}!= nil { - m.{{ $setter }}(*input.{{ $f.StructField }}) - }else{ - m.{{ $clear }}() - } - {{- else}} - m.{{ $setter }}(input.{{ $f.StructField }}) - {{- end}} - {{- end }} - default: - return fmt.Errorf("unknown {{ .Name }} field %s", fields[i]) - } - } - return nil - } - {{- end }} - -{{ end }} - diff --git a/internal/features/system/data/ent/template/type_meta_fields.tpl b/internal/features/system/data/ent/template/type_meta_fields.tpl deleted file mode 100644 index 5cd85559..00000000 --- a/internal/features/system/data/ent/template/type_meta_fields.tpl +++ /dev/null @@ -1,67 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Type*/}} - -{{ define "meta/additional/fields" }} - - // SelectColumns returns all selected fields. - func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields - } - - // OmitColumns returns all fields that are not in the list of fields. - func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns,fields, true) - } - - // OmitCustomColumns returns all fields that are not in the list of fields. - func OmitCustomColumns(src []string,fields ...string) []string { - if len(src) == 0 { - src= Columns - } - // Default removal FieldID - return omitColumns(src,fields, true) - } - - // OmitColumnsWithID returns all fields that are not in the list of fields. - func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns,fields, false) - } - - // OmitCustomColumns returns all fields that are not in the list of fields. - func OmitCustomColumnsWithID(src []string,fields ...string) []string { - if len(src) == 0 { - src= Columns - } - // Not remove FieldID - return omitColumns(src,fields, false) - } - - func omitColumns(src []string,fields []string,omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields - } - - func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false - } -{{ end }} diff --git a/internal/features/system/data/ent/template/type_meta_where.tpl b/internal/features/system/data/ent/template/type_meta_where.tpl deleted file mode 100644 index c0c8f095..00000000 --- a/internal/features/system/data/ent/template/type_meta_where.tpl +++ /dev/null @@ -1,16 +0,0 @@ -{{/* The line below tells Intellij/GoLand to enable the autocompletion based on the *gen.Graph type. */}} -{{/* gotype: entgo.io/ent/entc/gen.Type*/}} - -{{ define "where/additional/with" }} -{{/* {{- $type := $.Name }}*/}} -{{/* {{- range $edge := $.Edges }}*/}} -{{/* {{- if $edge.StructField }}*/}} -{{/* {{ $func := print "With" $edge.StructField }}*/}} -{{/* // With{{ $edge.StructField }} tells the query-builder to eager-load the nodes that are connected to*/}} -{{/* // the "{{ $edge.StructField }}" edge. The optional arguments are used to configure the query builder of the edge.*/}} -{{/* func {{$func}}(query *{{ $edge.StructField }}Query) {*/}} -{{/* query.{{$func}}()*/}} -{{/* }*/}} -{{/* {{- end }}*/}} -{{/* {{- end }}*/}} -{{ end }} \ No newline at end of file diff --git a/internal/features/system/data/ent/tx.go b/internal/features/system/data/ent/tx.go deleted file mode 100644 index f93d6ecc..00000000 --- a/internal/features/system/data/ent/tx.go +++ /dev/null @@ -1,228 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "sync" - - "entgo.io/ent/dialect" -) - -// Tx is a transactional client that is created by calling Client.Tx(). -type Tx struct { - config - // Permission is the client for interacting with the Permission builders. - Permission *PermissionClient - // PermissionResource is the client for interacting with the PermissionResource builders. - PermissionResource *PermissionResourceClient - // Resource is the client for interacting with the Resource builders. - Resource *ResourceClient - // Role is the client for interacting with the Role builders. - Role *RoleClient - // RolePermission is the client for interacting with the RolePermission builders. - RolePermission *RolePermissionClient - // User is the client for interacting with the User builders. - User *UserClient - // UserRole is the client for interacting with the UserRole builders. - UserRole *UserRoleClient - - // lazily loaded. - client *Client - clientOnce sync.Once - // ctx lives for the life of the transaction. It is - // the same context used by the underlying connection. - ctx context.Context -} - -type ( - // Committer is the interface that wraps the Commit method. - Committer interface { - Commit(context.Context, *Tx) error - } - - // The CommitFunc type is an adapter to allow the use of ordinary - // function as a Committer. If f is a function with the appropriate - // signature, CommitFunc(f) is a Committer that calls f. - CommitFunc func(context.Context, *Tx) error - - // CommitHook defines the "commit middleware". A function that gets a Committer - // and returns a Committer. For example: - // - // hook := func(next ent.Committer) ent.Committer { - // return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { - // // Do some stuff before. - // if err := next.Commit(ctx, tx); err != nil { - // return err - // } - // // Do some stuff after. - // return nil - // }) - // } - // - CommitHook func(Committer) Committer -) - -// Commit calls f(ctx, m). -func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { - return f(ctx, tx) -} - -// Commit commits the transaction. -func (tx *Tx) Commit() error { - txDriver := tx.config.driver.(*txDriver) - var fn Committer = CommitFunc(func(context.Context, *Tx) error { - return txDriver.tx.Commit() - }) - txDriver.mu.Lock() - hooks := append([]CommitHook(nil), txDriver.onCommit...) - txDriver.mu.Unlock() - for i := len(hooks) - 1; i >= 0; i-- { - fn = hooks[i](fn) - } - return fn.Commit(tx.ctx, tx) -} - -// OnCommit adds a hook to call on commit. -func (tx *Tx) OnCommit(f CommitHook) { - txDriver := tx.config.driver.(*txDriver) - txDriver.mu.Lock() - txDriver.onCommit = append(txDriver.onCommit, f) - txDriver.mu.Unlock() -} - -type ( - // Rollbacker is the interface that wraps the Rollback method. - Rollbacker interface { - Rollback(context.Context, *Tx) error - } - - // The RollbackFunc type is an adapter to allow the use of ordinary - // function as a Rollbacker. If f is a function with the appropriate - // signature, RollbackFunc(f) is a Rollbacker that calls f. - RollbackFunc func(context.Context, *Tx) error - - // RollbackHook defines the "rollback middleware". A function that gets a Rollbacker - // and returns a Rollbacker. For example: - // - // hook := func(next ent.Rollbacker) ent.Rollbacker { - // return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { - // // Do some stuff before. - // if err := next.Rollback(ctx, tx); err != nil { - // return err - // } - // // Do some stuff after. - // return nil - // }) - // } - // - RollbackHook func(Rollbacker) Rollbacker -) - -// Rollback calls f(ctx, m). -func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { - return f(ctx, tx) -} - -// Rollback rollbacks the transaction. -func (tx *Tx) Rollback() error { - txDriver := tx.config.driver.(*txDriver) - var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { - return txDriver.tx.Rollback() - }) - txDriver.mu.Lock() - hooks := append([]RollbackHook(nil), txDriver.onRollback...) - txDriver.mu.Unlock() - for i := len(hooks) - 1; i >= 0; i-- { - fn = hooks[i](fn) - } - return fn.Rollback(tx.ctx, tx) -} - -// OnRollback adds a hook to call on rollback. -func (tx *Tx) OnRollback(f RollbackHook) { - txDriver := tx.config.driver.(*txDriver) - txDriver.mu.Lock() - txDriver.onRollback = append(txDriver.onRollback, f) - txDriver.mu.Unlock() -} - -// Client returns a Client that binds to current transaction. -func (tx *Tx) Client() *Client { - tx.clientOnce.Do(func() { - tx.client = &Client{config: tx.config} - tx.client.init() - }) - return tx.client -} - -func (tx *Tx) init() { - tx.Permission = NewPermissionClient(tx.config) - tx.PermissionResource = NewPermissionResourceClient(tx.config) - tx.Resource = NewResourceClient(tx.config) - tx.Role = NewRoleClient(tx.config) - tx.RolePermission = NewRolePermissionClient(tx.config) - tx.User = NewUserClient(tx.config) - tx.UserRole = NewUserRoleClient(tx.config) -} - -// txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. -// The idea is to support transactions without adding any extra code to the builders. -// When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. -// Commit and Rollback are nop for the internal builders and the user must call one -// of them in order to commit or rollback the transaction. -// -// If a closed transaction is embedded in one of the generated entities, and the entity -// applies a query, for example: Permission.QueryXXX(), the query will be executed -// through the driver which created this transaction. -// -// Note that txDriver is not goroutine safe. -type txDriver struct { - // the driver we started the transaction from. - drv dialect.Driver - // tx is the underlying transaction. - tx dialect.Tx - // completion hooks. - mu sync.Mutex - onCommit []CommitHook - onRollback []RollbackHook -} - -// newTx creates a new transactional driver. -func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { - tx, err := drv.Tx(ctx) - if err != nil { - return nil, err - } - return &txDriver{tx: tx, drv: drv}, nil -} - -// Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls -// from the internal builders. Should be called only by the internal builders. -func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } - -// Dialect returns the dialect of the driver we started the transaction from. -func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } - -// Close is a nop close. -func (*txDriver) Close() error { return nil } - -// Commit is a nop commit for the internal builders. -// User must call `Tx.Commit` in order to commit the transaction. -func (*txDriver) Commit() error { return nil } - -// Rollback is a nop rollback for the internal builders. -// User must call `Tx.Rollback` in order to rollback the transaction. -func (*txDriver) Rollback() error { return nil } - -// Exec calls tx.Exec. -func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error { - return tx.tx.Exec(ctx, query, args, v) -} - -// Query calls tx.Query. -func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error { - return tx.tx.Query(ctx, query, args, v) -} - -var _ dialect.Driver = (*txDriver)(nil) diff --git a/internal/features/system/data/ent/user.go b/internal/features/system/data/ent/user.go deleted file mode 100644 index 20bac1cf..00000000 --- a/internal/features/system/data/ent/user.go +++ /dev/null @@ -1,337 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/user" - "strings" - "time" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" -) - -// User table -type User struct { - config `json:"-"` - // ID of the ent. - // ID - ID int64 `json:"id,omitempty"` - // CreateTime holds the value of the "create_time" field. - CreateTime time.Time `json:"create_time,omitempty"` - // UpdateTime holds the value of the "update_time" field. - UpdateTime time.Time `json:"update_time,omitempty"` - // UUID - UUID string `json:"uuid,omitempty"` - // Allowed IP - AllowedIP string `json:"allowed_ip,omitempty"` - // login username of user - Username string `json:"username,omitempty"` - // Nickname display name of user - Nickname string `json:"nickname,omitempty"` - // Avatar display avatar of user - Avatar string `json:"avatar,omitempty"` - // Name of user - Name string `json:"name,omitempty"` - // Gender of user - Gender user.Gender `json:"gender,omitempty"` - // Encrypted password - Password string `json:"-"` - // login phone number of user - Phone string `json:"phone,omitempty"` - // login email of user - Email string `json:"email,omitempty"` - // Department of user - Department string `json:"department,omitempty"` - // Remark of user - Remark string `json:"remark,omitempty"` - // status - Status int8 `json:"status,omitempty"` - // Whether the system is built-in - IsSystem bool `json:"is_system,omitempty"` - // Last login IP - LastLoginIP string `json:"last_login_ip,omitempty"` - // Last login time - LastLoginTime time.Time `json:"last_login_time,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the UserQuery when eager-loading is set. - Edges UserEdges `json:"edges"` - selectValues sql.SelectValues -} - -// UserEdges holds the relations/edges for other nodes in the graph. -type UserEdges struct { - // Roles holds the value of the roles edge. - Roles []*Role `json:"roles,omitempty"` - // UserRoles holds the value of the user_roles edge. - UserRoles []*UserRole `json:"user_roles,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool -} - -// RolesOrErr returns the Roles value or an error if the edge -// was not loaded in eager-loading. -func (e UserEdges) RolesOrErr() ([]*Role, error) { - if e.loadedTypes[0] { - return e.Roles, nil - } - return nil, &NotLoadedError{edge: "roles"} -} - -// UserRolesOrErr returns the UserRoles value or an error if the edge -// was not loaded in eager-loading. -func (e UserEdges) UserRolesOrErr() ([]*UserRole, error) { - if e.loadedTypes[1] { - return e.UserRoles, nil - } - return nil, &NotLoadedError{edge: "user_roles"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*User) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case user.FieldIsSystem: - values[i] = new(sql.NullBool) - case user.FieldID, user.FieldStatus: - values[i] = new(sql.NullInt64) - case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldPassword, user.FieldPhone, user.FieldEmail, user.FieldDepartment, user.FieldRemark, user.FieldLastLoginIP: - values[i] = new(sql.NullString) - case user.FieldCreateTime, user.FieldUpdateTime, user.FieldLastLoginTime: - values[i] = new(sql.NullTime) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the User fields. -func (_m *User) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case user.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - _m.ID = int64(value.Int64) - case user.FieldCreateTime: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field create_time", values[i]) - } else if value.Valid { - _m.CreateTime = value.Time - } - case user.FieldUpdateTime: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field update_time", values[i]) - } else if value.Valid { - _m.UpdateTime = value.Time - } - case user.FieldUUID: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field uuid", values[i]) - } else if value.Valid { - _m.UUID = value.String - } - case user.FieldAllowedIP: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field allowed_ip", values[i]) - } else if value.Valid { - _m.AllowedIP = value.String - } - case user.FieldUsername: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field username", values[i]) - } else if value.Valid { - _m.Username = value.String - } - case user.FieldNickname: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field nickname", values[i]) - } else if value.Valid { - _m.Nickname = value.String - } - case user.FieldAvatar: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field avatar", values[i]) - } else if value.Valid { - _m.Avatar = value.String - } - case user.FieldName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) - } else if value.Valid { - _m.Name = value.String - } - case user.FieldGender: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field gender", values[i]) - } else if value.Valid { - _m.Gender = user.Gender(value.String) - } - case user.FieldPassword: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field password", values[i]) - } else if value.Valid { - _m.Password = value.String - } - case user.FieldPhone: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field phone", values[i]) - } else if value.Valid { - _m.Phone = value.String - } - case user.FieldEmail: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field email", values[i]) - } else if value.Valid { - _m.Email = value.String - } - case user.FieldDepartment: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field department", values[i]) - } else if value.Valid { - _m.Department = value.String - } - case user.FieldRemark: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field remark", values[i]) - } else if value.Valid { - _m.Remark = value.String - } - case user.FieldStatus: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field status", values[i]) - } else if value.Valid { - _m.Status = int8(value.Int64) - } - case user.FieldIsSystem: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field is_system", values[i]) - } else if value.Valid { - _m.IsSystem = value.Bool - } - case user.FieldLastLoginIP: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field last_login_ip", values[i]) - } else if value.Valid { - _m.LastLoginIP = value.String - } - case user.FieldLastLoginTime: - if value, ok := values[i].(*sql.NullTime); !ok { - return fmt.Errorf("unexpected type %T for field last_login_time", values[i]) - } else if value.Valid { - _m.LastLoginTime = value.Time - } - default: - _m.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the User. -// This includes values selected through modifiers, order, etc. -func (_m *User) Value(name string) (ent.Value, error) { - return _m.selectValues.Get(name) -} - -// QueryRoles queries the "roles" edge of the User entity. -func (_m *User) QueryRoles() *RoleQuery { - return NewUserClient(_m.config).QueryRoles(_m) -} - -// QueryUserRoles queries the "user_roles" edge of the User entity. -func (_m *User) QueryUserRoles() *UserRoleQuery { - return NewUserClient(_m.config).QueryUserRoles(_m) -} - -// Update returns a builder for updating this User. -// Note that you need to call User.Unwrap() before calling this method if this User -// was returned from a transaction, and the transaction was committed or rolled back. -func (_m *User) Update() *UserUpdateOne { - return NewUserClient(_m.config).UpdateOne(_m) -} - -// Unwrap unwraps the User entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (_m *User) Unwrap() *User { - _tx, ok := _m.config.driver.(*txDriver) - if !ok { - panic("ent: User is not a transactional entity") - } - _m.config.driver = _tx.drv - return _m -} - -// String implements the fmt.Stringer. -func (_m *User) String() string { - var builder strings.Builder - builder.WriteString("User(") - builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - builder.WriteString("create_time=") - builder.WriteString(_m.CreateTime.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("update_time=") - builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("uuid=") - builder.WriteString(_m.UUID) - builder.WriteString(", ") - builder.WriteString("allowed_ip=") - builder.WriteString(_m.AllowedIP) - builder.WriteString(", ") - builder.WriteString("username=") - builder.WriteString(_m.Username) - builder.WriteString(", ") - builder.WriteString("nickname=") - builder.WriteString(_m.Nickname) - builder.WriteString(", ") - builder.WriteString("avatar=") - builder.WriteString(_m.Avatar) - builder.WriteString(", ") - builder.WriteString("name=") - builder.WriteString(_m.Name) - builder.WriteString(", ") - builder.WriteString("gender=") - builder.WriteString(fmt.Sprintf("%v", _m.Gender)) - builder.WriteString(", ") - builder.WriteString("password=") - builder.WriteString(", ") - builder.WriteString("phone=") - builder.WriteString(_m.Phone) - builder.WriteString(", ") - builder.WriteString("email=") - builder.WriteString(_m.Email) - builder.WriteString(", ") - builder.WriteString("department=") - builder.WriteString(_m.Department) - builder.WriteString(", ") - builder.WriteString("remark=") - builder.WriteString(_m.Remark) - builder.WriteString(", ") - builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", _m.Status)) - builder.WriteString(", ") - builder.WriteString("is_system=") - builder.WriteString(fmt.Sprintf("%v", _m.IsSystem)) - builder.WriteString(", ") - builder.WriteString("last_login_ip=") - builder.WriteString(_m.LastLoginIP) - builder.WriteString(", ") - builder.WriteString("last_login_time=") - builder.WriteString(_m.LastLoginTime.Format(time.ANSIC)) - builder.WriteByte(')') - return builder.String() -} - -// Users is a parsable slice of User. -type Users []*User diff --git a/internal/features/system/data/ent/user/user.go b/internal/features/system/data/ent/user/user.go deleted file mode 100644 index 2b17d732..00000000 --- a/internal/features/system/data/ent/user/user.go +++ /dev/null @@ -1,395 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package user - -import ( - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the user type in the database. - Label = "user" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldCreateTime holds the string denoting the create_time field in the database. - FieldCreateTime = "create_time" - // FieldUpdateTime holds the string denoting the update_time field in the database. - FieldUpdateTime = "update_time" - // FieldUUID holds the string denoting the uuid field in the database. - FieldUUID = "uuid" - // FieldAllowedIP holds the string denoting the allowed_ip field in the database. - FieldAllowedIP = "allowed_ip" - // FieldUsername holds the string denoting the username field in the database. - FieldUsername = "username" - // FieldNickname holds the string denoting the nickname field in the database. - FieldNickname = "nickname" - // FieldAvatar holds the string denoting the avatar field in the database. - FieldAvatar = "avatar" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" - // FieldGender holds the string denoting the gender field in the database. - FieldGender = "gender" - // FieldPassword holds the string denoting the password field in the database. - FieldPassword = "password" - // FieldPhone holds the string denoting the phone field in the database. - FieldPhone = "phone" - // FieldEmail holds the string denoting the email field in the database. - FieldEmail = "email" - // FieldDepartment holds the string denoting the department field in the database. - FieldDepartment = "department" - // FieldRemark holds the string denoting the remark field in the database. - FieldRemark = "remark" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" - // FieldIsSystem holds the string denoting the is_system field in the database. - FieldIsSystem = "is_system" - // FieldLastLoginIP holds the string denoting the last_login_ip field in the database. - FieldLastLoginIP = "last_login_ip" - // FieldLastLoginTime holds the string denoting the last_login_time field in the database. - FieldLastLoginTime = "last_login_time" - // EdgeRoles holds the string denoting the roles edge name in mutations. - EdgeRoles = "roles" - // EdgeUserRoles holds the string denoting the user_roles edge name in mutations. - EdgeUserRoles = "user_roles" - // Table holds the table name of the user in the database. - Table = "sys_users" - // RolesTable is the table that holds the roles relation/edge. The primary key declared below. - RolesTable = "sys_user_roles" - // RolesInverseTable is the table name for the Role entity. - // It exists in this package in order to avoid circular dependency with the "role" package. - RolesInverseTable = "sys_roles" - // UserRolesTable is the table that holds the user_roles relation/edge. - UserRolesTable = "sys_user_roles" - // UserRolesInverseTable is the table name for the UserRole entity. - // It exists in this package in order to avoid circular dependency with the "userrole" package. - UserRolesInverseTable = "sys_user_roles" - // UserRolesColumn is the table column denoting the user_roles relation/edge. - UserRolesColumn = "user_id" -) - -// Columns holds all SQL columns for user fields. -var Columns = []string{ - FieldID, - FieldCreateTime, - FieldUpdateTime, - FieldUUID, - FieldAllowedIP, - FieldUsername, - FieldNickname, - FieldAvatar, - FieldName, - FieldGender, - FieldPassword, - FieldPhone, - FieldEmail, - FieldDepartment, - FieldRemark, - FieldStatus, - FieldIsSystem, - FieldLastLoginIP, - FieldLastLoginTime, -} - -var ( - // RolesPrimaryKey and RolesColumn2 are the table columns denoting the - // primary key for the roles relation (M2M). - RolesPrimaryKey = []string{"user_id", "role_id"} -) - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -var ( - // DefaultCreateTime holds the default value on creation for the "create_time" field. - DefaultCreateTime func() time.Time - // DefaultUpdateTime holds the default value on creation for the "update_time" field. - DefaultUpdateTime func() time.Time - // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. - UpdateDefaultUpdateTime func() time.Time - // UUIDValidator is a validator for the "uuid" field. It is called by the builders before save. - UUIDValidator func(string) error - // DefaultAllowedIP holds the default value on creation for the "allowed_ip" field. - DefaultAllowedIP string - // UsernameValidator is a validator for the "username" field. It is called by the builders before save. - UsernameValidator func(string) error - // DefaultNickname holds the default value on creation for the "nickname" field. - DefaultNickname string - // NicknameValidator is a validator for the "nickname" field. It is called by the builders before save. - NicknameValidator func(string) error - // DefaultAvatar holds the default value on creation for the "avatar" field. - DefaultAvatar string - // AvatarValidator is a validator for the "avatar" field. It is called by the builders before save. - AvatarValidator func(string) error - // DefaultName holds the default value on creation for the "name" field. - DefaultName string - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error - // DefaultPassword holds the default value on creation for the "password" field. - DefaultPassword string - // PasswordValidator is a validator for the "password" field. It is called by the builders before save. - PasswordValidator func(string) error - // DefaultPhone holds the default value on creation for the "phone" field. - DefaultPhone string - // PhoneValidator is a validator for the "phone" field. It is called by the builders before save. - PhoneValidator func(string) error - // DefaultEmail holds the default value on creation for the "email" field. - DefaultEmail string - // EmailValidator is a validator for the "email" field. It is called by the builders before save. - EmailValidator func(string) error - // DefaultDepartment holds the default value on creation for the "department" field. - DefaultDepartment string - // DepartmentValidator is a validator for the "department" field. It is called by the builders before save. - DepartmentValidator func(string) error - // DefaultRemark holds the default value on creation for the "remark" field. - DefaultRemark string - // RemarkValidator is a validator for the "remark" field. It is called by the builders before save. - RemarkValidator func(string) error - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 - // DefaultIsSystem holds the default value on creation for the "is_system" field. - DefaultIsSystem bool - // DefaultLastLoginIP holds the default value on creation for the "last_login_ip" field. - DefaultLastLoginIP string - // LastLoginIPValidator is a validator for the "last_login_ip" field. It is called by the builders before save. - LastLoginIPValidator func(string) error -) - -// Gender defines the type for the "gender" enum field. -type Gender string - -// GenderUnknown is the default value of the Gender enum. -const DefaultGender = GenderUnknown - -// Gender values. -const ( - GenderMale Gender = "male" - GenderFemale Gender = "female" - GenderUnknown Gender = "unknown" -) - -func (ge Gender) String() string { - return string(ge) -} - -// GenderValidator is a validator for the "gender" field enum values. It is called by the builders before save. -func GenderValidator(ge Gender) error { - switch ge { - case GenderMale, GenderFemale, GenderUnknown: - return nil - default: - return fmt.Errorf("user: invalid enum value for gender field: %q", ge) - } -} - -// OrderOption defines the ordering options for the User queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByCreateTime orders the results by the create_time field. -func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldCreateTime, opts...).ToFunc() -} - -// ByUpdateTime orders the results by the update_time field. -func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() -} - -// ByUUID orders the results by the uuid field. -func ByUUID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUUID, opts...).ToFunc() -} - -// ByAllowedIP orders the results by the allowed_ip field. -func ByAllowedIP(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldAllowedIP, opts...).ToFunc() -} - -// ByUsername orders the results by the username field. -func ByUsername(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUsername, opts...).ToFunc() -} - -// ByNickname orders the results by the nickname field. -func ByNickname(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldNickname, opts...).ToFunc() -} - -// ByAvatar orders the results by the avatar field. -func ByAvatar(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldAvatar, opts...).ToFunc() -} - -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() -} - -// ByGender orders the results by the gender field. -func ByGender(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldGender, opts...).ToFunc() -} - -// ByPassword orders the results by the password field. -func ByPassword(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPassword, opts...).ToFunc() -} - -// ByPhone orders the results by the phone field. -func ByPhone(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPhone, opts...).ToFunc() -} - -// ByEmail orders the results by the email field. -func ByEmail(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldEmail, opts...).ToFunc() -} - -// ByDepartment orders the results by the department field. -func ByDepartment(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDepartment, opts...).ToFunc() -} - -// ByRemark orders the results by the remark field. -func ByRemark(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRemark, opts...).ToFunc() -} - -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - -// ByIsSystem orders the results by the is_system field. -func ByIsSystem(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldIsSystem, opts...).ToFunc() -} - -// ByLastLoginIP orders the results by the last_login_ip field. -func ByLastLoginIP(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldLastLoginIP, opts...).ToFunc() -} - -// ByLastLoginTime orders the results by the last_login_time field. -func ByLastLoginTime(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldLastLoginTime, opts...).ToFunc() -} - -// ByRolesCount orders the results by roles count. -func ByRolesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newRolesStep(), opts...) - } -} - -// ByRoles orders the results by roles terms. -func ByRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRolesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} - -// ByUserRolesCount orders the results by user_roles count. -func ByUserRolesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newUserRolesStep(), opts...) - } -} - -// ByUserRoles orders the results by user_roles terms. -func ByUserRoles(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserRolesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newRolesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RolesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...), - ) -} -func newUserRolesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserRolesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/features/system/data/ent/user/where.go b/internal/features/system/data/ent/user/where.go deleted file mode 100644 index 9b236388..00000000 --- a/internal/features/system/data/ent/user/where.go +++ /dev/null @@ -1,1182 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package user - -import ( - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int64) predicate.User { - return predicate.User(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int64) predicate.User { - return predicate.User(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int64) predicate.User { - return predicate.User(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int64) predicate.User { - return predicate.User(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int64) predicate.User { - return predicate.User(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int64) predicate.User { - return predicate.User(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int64) predicate.User { - return predicate.User(sql.FieldLTE(FieldID, id)) -} - -// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. -func CreateTime(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldCreateTime, v)) -} - -// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. -func UpdateTime(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UUID applies equality check predicate on the "uuid" field. It's identical to UUIDEQ. -func UUID(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldUUID, v)) -} - -// AllowedIP applies equality check predicate on the "allowed_ip" field. It's identical to AllowedIPEQ. -func AllowedIP(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldAllowedIP, v)) -} - -// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. -func Username(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldUsername, v)) -} - -// Nickname applies equality check predicate on the "nickname" field. It's identical to NicknameEQ. -func Nickname(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldNickname, v)) -} - -// Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ. -func Avatar(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldAvatar, v)) -} - -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldName, v)) -} - -// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ. -func Password(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldPassword, v)) -} - -// Phone applies equality check predicate on the "phone" field. It's identical to PhoneEQ. -func Phone(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldPhone, v)) -} - -// Email applies equality check predicate on the "email" field. It's identical to EmailEQ. -func Email(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldEmail, v)) -} - -// Department applies equality check predicate on the "department" field. It's identical to DepartmentEQ. -func Department(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldDepartment, v)) -} - -// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ. -func Remark(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldRemark, v)) -} - -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.User { - return predicate.User(sql.FieldEQ(FieldStatus, v)) -} - -// IsSystem applies equality check predicate on the "is_system" field. It's identical to IsSystemEQ. -func IsSystem(v bool) predicate.User { - return predicate.User(sql.FieldEQ(FieldIsSystem, v)) -} - -// LastLoginIP applies equality check predicate on the "last_login_ip" field. It's identical to LastLoginIPEQ. -func LastLoginIP(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldLastLoginIP, v)) -} - -// LastLoginTime applies equality check predicate on the "last_login_time" field. It's identical to LastLoginTimeEQ. -func LastLoginTime(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldLastLoginTime, v)) -} - -// CreateTimeEQ applies the EQ predicate on the "create_time" field. -func CreateTimeEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldCreateTime, v)) -} - -// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. -func CreateTimeNEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldNEQ(FieldCreateTime, v)) -} - -// CreateTimeIn applies the In predicate on the "create_time" field. -func CreateTimeIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldIn(FieldCreateTime, vs...)) -} - -// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. -func CreateTimeNotIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldNotIn(FieldCreateTime, vs...)) -} - -// CreateTimeGT applies the GT predicate on the "create_time" field. -func CreateTimeGT(v time.Time) predicate.User { - return predicate.User(sql.FieldGT(FieldCreateTime, v)) -} - -// CreateTimeGTE applies the GTE predicate on the "create_time" field. -func CreateTimeGTE(v time.Time) predicate.User { - return predicate.User(sql.FieldGTE(FieldCreateTime, v)) -} - -// CreateTimeLT applies the LT predicate on the "create_time" field. -func CreateTimeLT(v time.Time) predicate.User { - return predicate.User(sql.FieldLT(FieldCreateTime, v)) -} - -// CreateTimeLTE applies the LTE predicate on the "create_time" field. -func CreateTimeLTE(v time.Time) predicate.User { - return predicate.User(sql.FieldLTE(FieldCreateTime, v)) -} - -// UpdateTimeEQ applies the EQ predicate on the "update_time" field. -func UpdateTimeEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldUpdateTime, v)) -} - -// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. -func UpdateTimeNEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldNEQ(FieldUpdateTime, v)) -} - -// UpdateTimeIn applies the In predicate on the "update_time" field. -func UpdateTimeIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. -func UpdateTimeNotIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldNotIn(FieldUpdateTime, vs...)) -} - -// UpdateTimeGT applies the GT predicate on the "update_time" field. -func UpdateTimeGT(v time.Time) predicate.User { - return predicate.User(sql.FieldGT(FieldUpdateTime, v)) -} - -// UpdateTimeGTE applies the GTE predicate on the "update_time" field. -func UpdateTimeGTE(v time.Time) predicate.User { - return predicate.User(sql.FieldGTE(FieldUpdateTime, v)) -} - -// UpdateTimeLT applies the LT predicate on the "update_time" field. -func UpdateTimeLT(v time.Time) predicate.User { - return predicate.User(sql.FieldLT(FieldUpdateTime, v)) -} - -// UpdateTimeLTE applies the LTE predicate on the "update_time" field. -func UpdateTimeLTE(v time.Time) predicate.User { - return predicate.User(sql.FieldLTE(FieldUpdateTime, v)) -} - -// UUIDEQ applies the EQ predicate on the "uuid" field. -func UUIDEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldUUID, v)) -} - -// UUIDNEQ applies the NEQ predicate on the "uuid" field. -func UUIDNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldUUID, v)) -} - -// UUIDIn applies the In predicate on the "uuid" field. -func UUIDIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldUUID, vs...)) -} - -// UUIDNotIn applies the NotIn predicate on the "uuid" field. -func UUIDNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldUUID, vs...)) -} - -// UUIDGT applies the GT predicate on the "uuid" field. -func UUIDGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldUUID, v)) -} - -// UUIDGTE applies the GTE predicate on the "uuid" field. -func UUIDGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldUUID, v)) -} - -// UUIDLT applies the LT predicate on the "uuid" field. -func UUIDLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldUUID, v)) -} - -// UUIDLTE applies the LTE predicate on the "uuid" field. -func UUIDLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldUUID, v)) -} - -// UUIDContains applies the Contains predicate on the "uuid" field. -func UUIDContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldUUID, v)) -} - -// UUIDHasPrefix applies the HasPrefix predicate on the "uuid" field. -func UUIDHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldUUID, v)) -} - -// UUIDHasSuffix applies the HasSuffix predicate on the "uuid" field. -func UUIDHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldUUID, v)) -} - -// UUIDEqualFold applies the EqualFold predicate on the "uuid" field. -func UUIDEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldUUID, v)) -} - -// UUIDContainsFold applies the ContainsFold predicate on the "uuid" field. -func UUIDContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldUUID, v)) -} - -// AllowedIPEQ applies the EQ predicate on the "allowed_ip" field. -func AllowedIPEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldAllowedIP, v)) -} - -// AllowedIPNEQ applies the NEQ predicate on the "allowed_ip" field. -func AllowedIPNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldAllowedIP, v)) -} - -// AllowedIPIn applies the In predicate on the "allowed_ip" field. -func AllowedIPIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldAllowedIP, vs...)) -} - -// AllowedIPNotIn applies the NotIn predicate on the "allowed_ip" field. -func AllowedIPNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldAllowedIP, vs...)) -} - -// AllowedIPGT applies the GT predicate on the "allowed_ip" field. -func AllowedIPGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldAllowedIP, v)) -} - -// AllowedIPGTE applies the GTE predicate on the "allowed_ip" field. -func AllowedIPGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldAllowedIP, v)) -} - -// AllowedIPLT applies the LT predicate on the "allowed_ip" field. -func AllowedIPLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldAllowedIP, v)) -} - -// AllowedIPLTE applies the LTE predicate on the "allowed_ip" field. -func AllowedIPLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldAllowedIP, v)) -} - -// AllowedIPContains applies the Contains predicate on the "allowed_ip" field. -func AllowedIPContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldAllowedIP, v)) -} - -// AllowedIPHasPrefix applies the HasPrefix predicate on the "allowed_ip" field. -func AllowedIPHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldAllowedIP, v)) -} - -// AllowedIPHasSuffix applies the HasSuffix predicate on the "allowed_ip" field. -func AllowedIPHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldAllowedIP, v)) -} - -// AllowedIPEqualFold applies the EqualFold predicate on the "allowed_ip" field. -func AllowedIPEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldAllowedIP, v)) -} - -// AllowedIPContainsFold applies the ContainsFold predicate on the "allowed_ip" field. -func AllowedIPContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldAllowedIP, v)) -} - -// UsernameEQ applies the EQ predicate on the "username" field. -func UsernameEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldUsername, v)) -} - -// UsernameNEQ applies the NEQ predicate on the "username" field. -func UsernameNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldUsername, v)) -} - -// UsernameIn applies the In predicate on the "username" field. -func UsernameIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldUsername, vs...)) -} - -// UsernameNotIn applies the NotIn predicate on the "username" field. -func UsernameNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldUsername, vs...)) -} - -// UsernameGT applies the GT predicate on the "username" field. -func UsernameGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldUsername, v)) -} - -// UsernameGTE applies the GTE predicate on the "username" field. -func UsernameGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldUsername, v)) -} - -// UsernameLT applies the LT predicate on the "username" field. -func UsernameLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldUsername, v)) -} - -// UsernameLTE applies the LTE predicate on the "username" field. -func UsernameLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldUsername, v)) -} - -// UsernameContains applies the Contains predicate on the "username" field. -func UsernameContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldUsername, v)) -} - -// UsernameHasPrefix applies the HasPrefix predicate on the "username" field. -func UsernameHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldUsername, v)) -} - -// UsernameHasSuffix applies the HasSuffix predicate on the "username" field. -func UsernameHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldUsername, v)) -} - -// UsernameEqualFold applies the EqualFold predicate on the "username" field. -func UsernameEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldUsername, v)) -} - -// UsernameContainsFold applies the ContainsFold predicate on the "username" field. -func UsernameContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldUsername, v)) -} - -// NicknameEQ applies the EQ predicate on the "nickname" field. -func NicknameEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldNickname, v)) -} - -// NicknameNEQ applies the NEQ predicate on the "nickname" field. -func NicknameNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldNickname, v)) -} - -// NicknameIn applies the In predicate on the "nickname" field. -func NicknameIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldNickname, vs...)) -} - -// NicknameNotIn applies the NotIn predicate on the "nickname" field. -func NicknameNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldNickname, vs...)) -} - -// NicknameGT applies the GT predicate on the "nickname" field. -func NicknameGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldNickname, v)) -} - -// NicknameGTE applies the GTE predicate on the "nickname" field. -func NicknameGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldNickname, v)) -} - -// NicknameLT applies the LT predicate on the "nickname" field. -func NicknameLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldNickname, v)) -} - -// NicknameLTE applies the LTE predicate on the "nickname" field. -func NicknameLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldNickname, v)) -} - -// NicknameContains applies the Contains predicate on the "nickname" field. -func NicknameContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldNickname, v)) -} - -// NicknameHasPrefix applies the HasPrefix predicate on the "nickname" field. -func NicknameHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldNickname, v)) -} - -// NicknameHasSuffix applies the HasSuffix predicate on the "nickname" field. -func NicknameHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldNickname, v)) -} - -// NicknameEqualFold applies the EqualFold predicate on the "nickname" field. -func NicknameEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldNickname, v)) -} - -// NicknameContainsFold applies the ContainsFold predicate on the "nickname" field. -func NicknameContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldNickname, v)) -} - -// AvatarEQ applies the EQ predicate on the "avatar" field. -func AvatarEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldAvatar, v)) -} - -// AvatarNEQ applies the NEQ predicate on the "avatar" field. -func AvatarNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldAvatar, v)) -} - -// AvatarIn applies the In predicate on the "avatar" field. -func AvatarIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldAvatar, vs...)) -} - -// AvatarNotIn applies the NotIn predicate on the "avatar" field. -func AvatarNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldAvatar, vs...)) -} - -// AvatarGT applies the GT predicate on the "avatar" field. -func AvatarGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldAvatar, v)) -} - -// AvatarGTE applies the GTE predicate on the "avatar" field. -func AvatarGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldAvatar, v)) -} - -// AvatarLT applies the LT predicate on the "avatar" field. -func AvatarLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldAvatar, v)) -} - -// AvatarLTE applies the LTE predicate on the "avatar" field. -func AvatarLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldAvatar, v)) -} - -// AvatarContains applies the Contains predicate on the "avatar" field. -func AvatarContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldAvatar, v)) -} - -// AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field. -func AvatarHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldAvatar, v)) -} - -// AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field. -func AvatarHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldAvatar, v)) -} - -// AvatarEqualFold applies the EqualFold predicate on the "avatar" field. -func AvatarEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldAvatar, v)) -} - -// AvatarContainsFold applies the ContainsFold predicate on the "avatar" field. -func AvatarContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldAvatar, v)) -} - -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldName, v)) -} - -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldName, v)) -} - -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldName, vs...)) -} - -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldName, vs...)) -} - -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldName, v)) -} - -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldName, v)) -} - -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldName, v)) -} - -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldName, v)) -} - -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldName, v)) -} - -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldName, v)) -} - -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldName, v)) -} - -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldName, v)) -} - -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldName, v)) -} - -// GenderEQ applies the EQ predicate on the "gender" field. -func GenderEQ(v Gender) predicate.User { - return predicate.User(sql.FieldEQ(FieldGender, v)) -} - -// GenderNEQ applies the NEQ predicate on the "gender" field. -func GenderNEQ(v Gender) predicate.User { - return predicate.User(sql.FieldNEQ(FieldGender, v)) -} - -// GenderIn applies the In predicate on the "gender" field. -func GenderIn(vs ...Gender) predicate.User { - return predicate.User(sql.FieldIn(FieldGender, vs...)) -} - -// GenderNotIn applies the NotIn predicate on the "gender" field. -func GenderNotIn(vs ...Gender) predicate.User { - return predicate.User(sql.FieldNotIn(FieldGender, vs...)) -} - -// PasswordEQ applies the EQ predicate on the "password" field. -func PasswordEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldPassword, v)) -} - -// PasswordNEQ applies the NEQ predicate on the "password" field. -func PasswordNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldPassword, v)) -} - -// PasswordIn applies the In predicate on the "password" field. -func PasswordIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldPassword, vs...)) -} - -// PasswordNotIn applies the NotIn predicate on the "password" field. -func PasswordNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldPassword, vs...)) -} - -// PasswordGT applies the GT predicate on the "password" field. -func PasswordGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldPassword, v)) -} - -// PasswordGTE applies the GTE predicate on the "password" field. -func PasswordGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldPassword, v)) -} - -// PasswordLT applies the LT predicate on the "password" field. -func PasswordLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldPassword, v)) -} - -// PasswordLTE applies the LTE predicate on the "password" field. -func PasswordLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldPassword, v)) -} - -// PasswordContains applies the Contains predicate on the "password" field. -func PasswordContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldPassword, v)) -} - -// PasswordHasPrefix applies the HasPrefix predicate on the "password" field. -func PasswordHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldPassword, v)) -} - -// PasswordHasSuffix applies the HasSuffix predicate on the "password" field. -func PasswordHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldPassword, v)) -} - -// PasswordEqualFold applies the EqualFold predicate on the "password" field. -func PasswordEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldPassword, v)) -} - -// PasswordContainsFold applies the ContainsFold predicate on the "password" field. -func PasswordContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldPassword, v)) -} - -// PhoneEQ applies the EQ predicate on the "phone" field. -func PhoneEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldPhone, v)) -} - -// PhoneNEQ applies the NEQ predicate on the "phone" field. -func PhoneNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldPhone, v)) -} - -// PhoneIn applies the In predicate on the "phone" field. -func PhoneIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldPhone, vs...)) -} - -// PhoneNotIn applies the NotIn predicate on the "phone" field. -func PhoneNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldPhone, vs...)) -} - -// PhoneGT applies the GT predicate on the "phone" field. -func PhoneGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldPhone, v)) -} - -// PhoneGTE applies the GTE predicate on the "phone" field. -func PhoneGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldPhone, v)) -} - -// PhoneLT applies the LT predicate on the "phone" field. -func PhoneLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldPhone, v)) -} - -// PhoneLTE applies the LTE predicate on the "phone" field. -func PhoneLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldPhone, v)) -} - -// PhoneContains applies the Contains predicate on the "phone" field. -func PhoneContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldPhone, v)) -} - -// PhoneHasPrefix applies the HasPrefix predicate on the "phone" field. -func PhoneHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldPhone, v)) -} - -// PhoneHasSuffix applies the HasSuffix predicate on the "phone" field. -func PhoneHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldPhone, v)) -} - -// PhoneEqualFold applies the EqualFold predicate on the "phone" field. -func PhoneEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldPhone, v)) -} - -// PhoneContainsFold applies the ContainsFold predicate on the "phone" field. -func PhoneContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldPhone, v)) -} - -// EmailEQ applies the EQ predicate on the "email" field. -func EmailEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldEmail, v)) -} - -// EmailNEQ applies the NEQ predicate on the "email" field. -func EmailNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldEmail, v)) -} - -// EmailIn applies the In predicate on the "email" field. -func EmailIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldEmail, vs...)) -} - -// EmailNotIn applies the NotIn predicate on the "email" field. -func EmailNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldEmail, vs...)) -} - -// EmailGT applies the GT predicate on the "email" field. -func EmailGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldEmail, v)) -} - -// EmailGTE applies the GTE predicate on the "email" field. -func EmailGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldEmail, v)) -} - -// EmailLT applies the LT predicate on the "email" field. -func EmailLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldEmail, v)) -} - -// EmailLTE applies the LTE predicate on the "email" field. -func EmailLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldEmail, v)) -} - -// EmailContains applies the Contains predicate on the "email" field. -func EmailContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldEmail, v)) -} - -// EmailHasPrefix applies the HasPrefix predicate on the "email" field. -func EmailHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldEmail, v)) -} - -// EmailHasSuffix applies the HasSuffix predicate on the "email" field. -func EmailHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldEmail, v)) -} - -// EmailEqualFold applies the EqualFold predicate on the "email" field. -func EmailEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldEmail, v)) -} - -// EmailContainsFold applies the ContainsFold predicate on the "email" field. -func EmailContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldEmail, v)) -} - -// DepartmentEQ applies the EQ predicate on the "department" field. -func DepartmentEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldDepartment, v)) -} - -// DepartmentNEQ applies the NEQ predicate on the "department" field. -func DepartmentNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldDepartment, v)) -} - -// DepartmentIn applies the In predicate on the "department" field. -func DepartmentIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldDepartment, vs...)) -} - -// DepartmentNotIn applies the NotIn predicate on the "department" field. -func DepartmentNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldDepartment, vs...)) -} - -// DepartmentGT applies the GT predicate on the "department" field. -func DepartmentGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldDepartment, v)) -} - -// DepartmentGTE applies the GTE predicate on the "department" field. -func DepartmentGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldDepartment, v)) -} - -// DepartmentLT applies the LT predicate on the "department" field. -func DepartmentLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldDepartment, v)) -} - -// DepartmentLTE applies the LTE predicate on the "department" field. -func DepartmentLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldDepartment, v)) -} - -// DepartmentContains applies the Contains predicate on the "department" field. -func DepartmentContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldDepartment, v)) -} - -// DepartmentHasPrefix applies the HasPrefix predicate on the "department" field. -func DepartmentHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldDepartment, v)) -} - -// DepartmentHasSuffix applies the HasSuffix predicate on the "department" field. -func DepartmentHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldDepartment, v)) -} - -// DepartmentEqualFold applies the EqualFold predicate on the "department" field. -func DepartmentEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldDepartment, v)) -} - -// DepartmentContainsFold applies the ContainsFold predicate on the "department" field. -func DepartmentContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldDepartment, v)) -} - -// RemarkEQ applies the EQ predicate on the "remark" field. -func RemarkEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldRemark, v)) -} - -// RemarkNEQ applies the NEQ predicate on the "remark" field. -func RemarkNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldRemark, v)) -} - -// RemarkIn applies the In predicate on the "remark" field. -func RemarkIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldRemark, vs...)) -} - -// RemarkNotIn applies the NotIn predicate on the "remark" field. -func RemarkNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldRemark, vs...)) -} - -// RemarkGT applies the GT predicate on the "remark" field. -func RemarkGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldRemark, v)) -} - -// RemarkGTE applies the GTE predicate on the "remark" field. -func RemarkGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldRemark, v)) -} - -// RemarkLT applies the LT predicate on the "remark" field. -func RemarkLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldRemark, v)) -} - -// RemarkLTE applies the LTE predicate on the "remark" field. -func RemarkLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldRemark, v)) -} - -// RemarkContains applies the Contains predicate on the "remark" field. -func RemarkContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldRemark, v)) -} - -// RemarkHasPrefix applies the HasPrefix predicate on the "remark" field. -func RemarkHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldRemark, v)) -} - -// RemarkHasSuffix applies the HasSuffix predicate on the "remark" field. -func RemarkHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldRemark, v)) -} - -// RemarkEqualFold applies the EqualFold predicate on the "remark" field. -func RemarkEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldRemark, v)) -} - -// RemarkContainsFold applies the ContainsFold predicate on the "remark" field. -func RemarkContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldRemark, v)) -} - -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.User { - return predicate.User(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.User { - return predicate.User(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.User { - return predicate.User(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.User { - return predicate.User(sql.FieldNotIn(FieldStatus, vs...)) -} - -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.User { - return predicate.User(sql.FieldGT(FieldStatus, v)) -} - -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.User { - return predicate.User(sql.FieldGTE(FieldStatus, v)) -} - -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.User { - return predicate.User(sql.FieldLT(FieldStatus, v)) -} - -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.User { - return predicate.User(sql.FieldLTE(FieldStatus, v)) -} - -// IsSystemEQ applies the EQ predicate on the "is_system" field. -func IsSystemEQ(v bool) predicate.User { - return predicate.User(sql.FieldEQ(FieldIsSystem, v)) -} - -// IsSystemNEQ applies the NEQ predicate on the "is_system" field. -func IsSystemNEQ(v bool) predicate.User { - return predicate.User(sql.FieldNEQ(FieldIsSystem, v)) -} - -// LastLoginIPEQ applies the EQ predicate on the "last_login_ip" field. -func LastLoginIPEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldLastLoginIP, v)) -} - -// LastLoginIPNEQ applies the NEQ predicate on the "last_login_ip" field. -func LastLoginIPNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldLastLoginIP, v)) -} - -// LastLoginIPIn applies the In predicate on the "last_login_ip" field. -func LastLoginIPIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldLastLoginIP, vs...)) -} - -// LastLoginIPNotIn applies the NotIn predicate on the "last_login_ip" field. -func LastLoginIPNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldLastLoginIP, vs...)) -} - -// LastLoginIPGT applies the GT predicate on the "last_login_ip" field. -func LastLoginIPGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldLastLoginIP, v)) -} - -// LastLoginIPGTE applies the GTE predicate on the "last_login_ip" field. -func LastLoginIPGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldLastLoginIP, v)) -} - -// LastLoginIPLT applies the LT predicate on the "last_login_ip" field. -func LastLoginIPLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldLastLoginIP, v)) -} - -// LastLoginIPLTE applies the LTE predicate on the "last_login_ip" field. -func LastLoginIPLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldLastLoginIP, v)) -} - -// LastLoginIPContains applies the Contains predicate on the "last_login_ip" field. -func LastLoginIPContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldLastLoginIP, v)) -} - -// LastLoginIPHasPrefix applies the HasPrefix predicate on the "last_login_ip" field. -func LastLoginIPHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldLastLoginIP, v)) -} - -// LastLoginIPHasSuffix applies the HasSuffix predicate on the "last_login_ip" field. -func LastLoginIPHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldLastLoginIP, v)) -} - -// LastLoginIPEqualFold applies the EqualFold predicate on the "last_login_ip" field. -func LastLoginIPEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldLastLoginIP, v)) -} - -// LastLoginIPContainsFold applies the ContainsFold predicate on the "last_login_ip" field. -func LastLoginIPContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldLastLoginIP, v)) -} - -// LastLoginTimeEQ applies the EQ predicate on the "last_login_time" field. -func LastLoginTimeEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldEQ(FieldLastLoginTime, v)) -} - -// LastLoginTimeNEQ applies the NEQ predicate on the "last_login_time" field. -func LastLoginTimeNEQ(v time.Time) predicate.User { - return predicate.User(sql.FieldNEQ(FieldLastLoginTime, v)) -} - -// LastLoginTimeIn applies the In predicate on the "last_login_time" field. -func LastLoginTimeIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldIn(FieldLastLoginTime, vs...)) -} - -// LastLoginTimeNotIn applies the NotIn predicate on the "last_login_time" field. -func LastLoginTimeNotIn(vs ...time.Time) predicate.User { - return predicate.User(sql.FieldNotIn(FieldLastLoginTime, vs...)) -} - -// LastLoginTimeGT applies the GT predicate on the "last_login_time" field. -func LastLoginTimeGT(v time.Time) predicate.User { - return predicate.User(sql.FieldGT(FieldLastLoginTime, v)) -} - -// LastLoginTimeGTE applies the GTE predicate on the "last_login_time" field. -func LastLoginTimeGTE(v time.Time) predicate.User { - return predicate.User(sql.FieldGTE(FieldLastLoginTime, v)) -} - -// LastLoginTimeLT applies the LT predicate on the "last_login_time" field. -func LastLoginTimeLT(v time.Time) predicate.User { - return predicate.User(sql.FieldLT(FieldLastLoginTime, v)) -} - -// LastLoginTimeLTE applies the LTE predicate on the "last_login_time" field. -func LastLoginTimeLTE(v time.Time) predicate.User { - return predicate.User(sql.FieldLTE(FieldLastLoginTime, v)) -} - -// LastLoginTimeIsNil applies the IsNil predicate on the "last_login_time" field. -func LastLoginTimeIsNil() predicate.User { - return predicate.User(sql.FieldIsNull(FieldLastLoginTime)) -} - -// LastLoginTimeNotNil applies the NotNil predicate on the "last_login_time" field. -func LastLoginTimeNotNil() predicate.User { - return predicate.User(sql.FieldNotNull(FieldLastLoginTime)) -} - -// HasRoles applies the HasEdge predicate on the "roles" edge. -func HasRoles() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, RolesTable, RolesPrimaryKey...), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRolesWith applies the HasEdge predicate on the "roles" edge with a given conditions (other predicates). -func HasRolesWith(preds ...predicate.Role) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := newRolesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasUserRoles applies the HasEdge predicate on the "user_roles" edge. -func HasUserRoles() predicate.User { - return predicate.User(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, UserRolesTable, UserRolesColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserRolesWith applies the HasEdge predicate on the "user_roles" edge with a given conditions (other predicates). -func HasUserRolesWith(preds ...predicate.UserRole) predicate.User { - return predicate.User(func(s *sql.Selector) { - step := newUserRolesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.User) predicate.User { - return predicate.User(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.User) predicate.User { - return predicate.User(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.User) predicate.User { - return predicate.User(sql.NotPredicates(p)) -} diff --git a/internal/features/system/data/ent/user_create.go b/internal/features/system/data/ent/user_create.go deleted file mode 100644 index 8cf2c1cf..00000000 --- a/internal/features/system/data/ent/user_create.go +++ /dev/null @@ -1,752 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - "time" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// UserCreate is the builder for creating a User entity. -type UserCreate struct { - config - mutation *UserMutation - hooks []Hook -} - -// SetCreateTime sets the "create_time" field. -func (_c *UserCreate) SetCreateTime(v time.Time) *UserCreate { - _c.mutation.SetCreateTime(v) - return _c -} - -// SetNillableCreateTime sets the "create_time" field if the given value is not nil. -func (_c *UserCreate) SetNillableCreateTime(v *time.Time) *UserCreate { - if v != nil { - _c.SetCreateTime(*v) - } - return _c -} - -// SetUpdateTime sets the "update_time" field. -func (_c *UserCreate) SetUpdateTime(v time.Time) *UserCreate { - _c.mutation.SetUpdateTime(v) - return _c -} - -// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. -func (_c *UserCreate) SetNillableUpdateTime(v *time.Time) *UserCreate { - if v != nil { - _c.SetUpdateTime(*v) - } - return _c -} - -// SetUUID sets the "uuid" field. -func (_c *UserCreate) SetUUID(v string) *UserCreate { - _c.mutation.SetUUID(v) - return _c -} - -// SetAllowedIP sets the "allowed_ip" field. -func (_c *UserCreate) SetAllowedIP(v string) *UserCreate { - _c.mutation.SetAllowedIP(v) - return _c -} - -// SetNillableAllowedIP sets the "allowed_ip" field if the given value is not nil. -func (_c *UserCreate) SetNillableAllowedIP(v *string) *UserCreate { - if v != nil { - _c.SetAllowedIP(*v) - } - return _c -} - -// SetUsername sets the "username" field. -func (_c *UserCreate) SetUsername(v string) *UserCreate { - _c.mutation.SetUsername(v) - return _c -} - -// SetNickname sets the "nickname" field. -func (_c *UserCreate) SetNickname(v string) *UserCreate { - _c.mutation.SetNickname(v) - return _c -} - -// SetNillableNickname sets the "nickname" field if the given value is not nil. -func (_c *UserCreate) SetNillableNickname(v *string) *UserCreate { - if v != nil { - _c.SetNickname(*v) - } - return _c -} - -// SetAvatar sets the "avatar" field. -func (_c *UserCreate) SetAvatar(v string) *UserCreate { - _c.mutation.SetAvatar(v) - return _c -} - -// SetNillableAvatar sets the "avatar" field if the given value is not nil. -func (_c *UserCreate) SetNillableAvatar(v *string) *UserCreate { - if v != nil { - _c.SetAvatar(*v) - } - return _c -} - -// SetName sets the "name" field. -func (_c *UserCreate) SetName(v string) *UserCreate { - _c.mutation.SetName(v) - return _c -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_c *UserCreate) SetNillableName(v *string) *UserCreate { - if v != nil { - _c.SetName(*v) - } - return _c -} - -// SetGender sets the "gender" field. -func (_c *UserCreate) SetGender(v user.Gender) *UserCreate { - _c.mutation.SetGender(v) - return _c -} - -// SetNillableGender sets the "gender" field if the given value is not nil. -func (_c *UserCreate) SetNillableGender(v *user.Gender) *UserCreate { - if v != nil { - _c.SetGender(*v) - } - return _c -} - -// SetPassword sets the "password" field. -func (_c *UserCreate) SetPassword(v string) *UserCreate { - _c.mutation.SetPassword(v) - return _c -} - -// SetNillablePassword sets the "password" field if the given value is not nil. -func (_c *UserCreate) SetNillablePassword(v *string) *UserCreate { - if v != nil { - _c.SetPassword(*v) - } - return _c -} - -// SetPhone sets the "phone" field. -func (_c *UserCreate) SetPhone(v string) *UserCreate { - _c.mutation.SetPhone(v) - return _c -} - -// SetNillablePhone sets the "phone" field if the given value is not nil. -func (_c *UserCreate) SetNillablePhone(v *string) *UserCreate { - if v != nil { - _c.SetPhone(*v) - } - return _c -} - -// SetEmail sets the "email" field. -func (_c *UserCreate) SetEmail(v string) *UserCreate { - _c.mutation.SetEmail(v) - return _c -} - -// SetNillableEmail sets the "email" field if the given value is not nil. -func (_c *UserCreate) SetNillableEmail(v *string) *UserCreate { - if v != nil { - _c.SetEmail(*v) - } - return _c -} - -// SetDepartment sets the "department" field. -func (_c *UserCreate) SetDepartment(v string) *UserCreate { - _c.mutation.SetDepartment(v) - return _c -} - -// SetNillableDepartment sets the "department" field if the given value is not nil. -func (_c *UserCreate) SetNillableDepartment(v *string) *UserCreate { - if v != nil { - _c.SetDepartment(*v) - } - return _c -} - -// SetRemark sets the "remark" field. -func (_c *UserCreate) SetRemark(v string) *UserCreate { - _c.mutation.SetRemark(v) - return _c -} - -// SetNillableRemark sets the "remark" field if the given value is not nil. -func (_c *UserCreate) SetNillableRemark(v *string) *UserCreate { - if v != nil { - _c.SetRemark(*v) - } - return _c -} - -// SetStatus sets the "status" field. -func (_c *UserCreate) SetStatus(v int8) *UserCreate { - _c.mutation.SetStatus(v) - return _c -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *UserCreate) SetNillableStatus(v *int8) *UserCreate { - if v != nil { - _c.SetStatus(*v) - } - return _c -} - -// SetIsSystem sets the "is_system" field. -func (_c *UserCreate) SetIsSystem(v bool) *UserCreate { - _c.mutation.SetIsSystem(v) - return _c -} - -// SetNillableIsSystem sets the "is_system" field if the given value is not nil. -func (_c *UserCreate) SetNillableIsSystem(v *bool) *UserCreate { - if v != nil { - _c.SetIsSystem(*v) - } - return _c -} - -// SetLastLoginIP sets the "last_login_ip" field. -func (_c *UserCreate) SetLastLoginIP(v string) *UserCreate { - _c.mutation.SetLastLoginIP(v) - return _c -} - -// SetNillableLastLoginIP sets the "last_login_ip" field if the given value is not nil. -func (_c *UserCreate) SetNillableLastLoginIP(v *string) *UserCreate { - if v != nil { - _c.SetLastLoginIP(*v) - } - return _c -} - -// SetLastLoginTime sets the "last_login_time" field. -func (_c *UserCreate) SetLastLoginTime(v time.Time) *UserCreate { - _c.mutation.SetLastLoginTime(v) - return _c -} - -// SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. -func (_c *UserCreate) SetNillableLastLoginTime(v *time.Time) *UserCreate { - if v != nil { - _c.SetLastLoginTime(*v) - } - return _c -} - -// SetID sets the "id" field. -func (_c *UserCreate) SetID(v int64) *UserCreate { - _c.mutation.SetID(v) - return _c -} - -// AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (_c *UserCreate) AddRoleIDs(ids ...int64) *UserCreate { - _c.mutation.AddRoleIDs(ids...) - return _c -} - -// AddRoles adds the "roles" edges to the Role entity. -func (_c *UserCreate) AddRoles(v ...*Role) *UserCreate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddRoleIDs(ids...) -} - -// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (_c *UserCreate) AddUserRoleIDs(ids ...int) *UserCreate { - _c.mutation.AddUserRoleIDs(ids...) - return _c -} - -// AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (_c *UserCreate) AddUserRoles(v ...*UserRole) *UserCreate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddUserRoleIDs(ids...) -} - -// Mutation returns the UserMutation object of the builder. -func (_c *UserCreate) Mutation() *UserMutation { - return _c.mutation -} - -// Save creates the User in the database. -func (_c *UserCreate) Save(ctx context.Context) (*User, error) { - _c.defaults() - return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (_c *UserCreate) SaveX(ctx context.Context) *User { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *UserCreate) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *UserCreate) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_c *UserCreate) defaults() { - if _, ok := _c.mutation.CreateTime(); !ok { - v := user.DefaultCreateTime() - _c.mutation.SetCreateTime(v) - } - if _, ok := _c.mutation.UpdateTime(); !ok { - v := user.DefaultUpdateTime() - _c.mutation.SetUpdateTime(v) - } - if _, ok := _c.mutation.AllowedIP(); !ok { - v := user.DefaultAllowedIP - _c.mutation.SetAllowedIP(v) - } - if _, ok := _c.mutation.Nickname(); !ok { - v := user.DefaultNickname - _c.mutation.SetNickname(v) - } - if _, ok := _c.mutation.Avatar(); !ok { - v := user.DefaultAvatar - _c.mutation.SetAvatar(v) - } - if _, ok := _c.mutation.Name(); !ok { - v := user.DefaultName - _c.mutation.SetName(v) - } - if _, ok := _c.mutation.Gender(); !ok { - v := user.DefaultGender - _c.mutation.SetGender(v) - } - if _, ok := _c.mutation.Password(); !ok { - v := user.DefaultPassword - _c.mutation.SetPassword(v) - } - if _, ok := _c.mutation.Phone(); !ok { - v := user.DefaultPhone - _c.mutation.SetPhone(v) - } - if _, ok := _c.mutation.Email(); !ok { - v := user.DefaultEmail - _c.mutation.SetEmail(v) - } - if _, ok := _c.mutation.Department(); !ok { - v := user.DefaultDepartment - _c.mutation.SetDepartment(v) - } - if _, ok := _c.mutation.Remark(); !ok { - v := user.DefaultRemark - _c.mutation.SetRemark(v) - } - if _, ok := _c.mutation.Status(); !ok { - v := user.DefaultStatus - _c.mutation.SetStatus(v) - } - if _, ok := _c.mutation.IsSystem(); !ok { - v := user.DefaultIsSystem - _c.mutation.SetIsSystem(v) - } - if _, ok := _c.mutation.LastLoginIP(); !ok { - v := user.DefaultLastLoginIP - _c.mutation.SetLastLoginIP(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_c *UserCreate) check() error { - if _, ok := _c.mutation.CreateTime(); !ok { - return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "User.create_time"`)} - } - if _, ok := _c.mutation.UpdateTime(); !ok { - return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "User.update_time"`)} - } - if _, ok := _c.mutation.UUID(); !ok { - return &ValidationError{Name: "uuid", err: errors.New(`ent: missing required field "User.uuid"`)} - } - if v, ok := _c.mutation.UUID(); ok { - if err := user.UUIDValidator(v); err != nil { - return &ValidationError{Name: "uuid", err: fmt.Errorf(`ent: validator failed for field "User.uuid": %w`, err)} - } - } - if _, ok := _c.mutation.AllowedIP(); !ok { - return &ValidationError{Name: "allowed_ip", err: errors.New(`ent: missing required field "User.allowed_ip"`)} - } - if _, ok := _c.mutation.Username(); !ok { - return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)} - } - if v, ok := _c.mutation.Username(); ok { - if err := user.UsernameValidator(v); err != nil { - return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} - } - } - if _, ok := _c.mutation.Nickname(); !ok { - return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "User.nickname"`)} - } - if v, ok := _c.mutation.Nickname(); ok { - if err := user.NicknameValidator(v); err != nil { - return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} - } - } - if _, ok := _c.mutation.Avatar(); !ok { - return &ValidationError{Name: "avatar", err: errors.New(`ent: missing required field "User.avatar"`)} - } - if v, ok := _c.mutation.Avatar(); ok { - if err := user.AvatarValidator(v); err != nil { - return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} - } - } - if _, ok := _c.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "User.name"`)} - } - if v, ok := _c.mutation.Name(); ok { - if err := user.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} - } - } - if _, ok := _c.mutation.Gender(); !ok { - return &ValidationError{Name: "gender", err: errors.New(`ent: missing required field "User.gender"`)} - } - if v, ok := _c.mutation.Gender(); ok { - if err := user.GenderValidator(v); err != nil { - return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} - } - } - if _, ok := _c.mutation.Password(); !ok { - return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "User.password"`)} - } - if v, ok := _c.mutation.Password(); ok { - if err := user.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} - } - } - if _, ok := _c.mutation.Phone(); !ok { - return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "User.phone"`)} - } - if v, ok := _c.mutation.Phone(); ok { - if err := user.PhoneValidator(v); err != nil { - return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "User.phone": %w`, err)} - } - } - if _, ok := _c.mutation.Email(); !ok { - return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "User.email"`)} - } - if v, ok := _c.mutation.Email(); ok { - if err := user.EmailValidator(v); err != nil { - return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} - } - } - if _, ok := _c.mutation.Department(); !ok { - return &ValidationError{Name: "department", err: errors.New(`ent: missing required field "User.department"`)} - } - if v, ok := _c.mutation.Department(); ok { - if err := user.DepartmentValidator(v); err != nil { - return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} - } - } - if _, ok := _c.mutation.Remark(); !ok { - return &ValidationError{Name: "remark", err: errors.New(`ent: missing required field "User.remark"`)} - } - if v, ok := _c.mutation.Remark(); ok { - if err := user.RemarkValidator(v); err != nil { - return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "User.remark": %w`, err)} - } - } - if _, ok := _c.mutation.Status(); !ok { - return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "User.status"`)} - } - if _, ok := _c.mutation.IsSystem(); !ok { - return &ValidationError{Name: "is_system", err: errors.New(`ent: missing required field "User.is_system"`)} - } - if _, ok := _c.mutation.LastLoginIP(); !ok { - return &ValidationError{Name: "last_login_ip", err: errors.New(`ent: missing required field "User.last_login_ip"`)} - } - if v, ok := _c.mutation.LastLoginIP(); ok { - if err := user.LastLoginIPValidator(v); err != nil { - return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} - } - } - return nil -} - -func (_c *UserCreate) sqlSave(ctx context.Context) (*User, error) { - if err := _c.check(); err != nil { - return nil, err - } - _node, _spec := _c.createSpec() - if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - if _spec.ID.Value != _node.ID { - id := _spec.ID.Value.(int64) - _node.ID = int64(id) - } - _c.mutation.id = &_node.ID - _c.mutation.done = true - return _node, nil -} - -func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { - var ( - _node = &User{config: _c.config} - _spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) - ) - if id, ok := _c.mutation.ID(); ok { - _node.ID = id - _spec.ID.Value = id - } - if value, ok := _c.mutation.CreateTime(); ok { - _spec.SetField(user.FieldCreateTime, field.TypeTime, value) - _node.CreateTime = value - } - if value, ok := _c.mutation.UpdateTime(); ok { - _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) - _node.UpdateTime = value - } - if value, ok := _c.mutation.UUID(); ok { - _spec.SetField(user.FieldUUID, field.TypeString, value) - _node.UUID = value - } - if value, ok := _c.mutation.AllowedIP(); ok { - _spec.SetField(user.FieldAllowedIP, field.TypeString, value) - _node.AllowedIP = value - } - if value, ok := _c.mutation.Username(); ok { - _spec.SetField(user.FieldUsername, field.TypeString, value) - _node.Username = value - } - if value, ok := _c.mutation.Nickname(); ok { - _spec.SetField(user.FieldNickname, field.TypeString, value) - _node.Nickname = value - } - if value, ok := _c.mutation.Avatar(); ok { - _spec.SetField(user.FieldAvatar, field.TypeString, value) - _node.Avatar = value - } - if value, ok := _c.mutation.Name(); ok { - _spec.SetField(user.FieldName, field.TypeString, value) - _node.Name = value - } - if value, ok := _c.mutation.Gender(); ok { - _spec.SetField(user.FieldGender, field.TypeEnum, value) - _node.Gender = value - } - if value, ok := _c.mutation.Password(); ok { - _spec.SetField(user.FieldPassword, field.TypeString, value) - _node.Password = value - } - if value, ok := _c.mutation.Phone(); ok { - _spec.SetField(user.FieldPhone, field.TypeString, value) - _node.Phone = value - } - if value, ok := _c.mutation.Email(); ok { - _spec.SetField(user.FieldEmail, field.TypeString, value) - _node.Email = value - } - if value, ok := _c.mutation.Department(); ok { - _spec.SetField(user.FieldDepartment, field.TypeString, value) - _node.Department = value - } - if value, ok := _c.mutation.Remark(); ok { - _spec.SetField(user.FieldRemark, field.TypeString, value) - _node.Remark = value - } - if value, ok := _c.mutation.Status(); ok { - _spec.SetField(user.FieldStatus, field.TypeInt8, value) - _node.Status = value - } - if value, ok := _c.mutation.IsSystem(); ok { - _spec.SetField(user.FieldIsSystem, field.TypeBool, value) - _node.IsSystem = value - } - if value, ok := _c.mutation.LastLoginIP(); ok { - _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) - _node.LastLoginIP = value - } - if value, ok := _c.mutation.LastLoginTime(); ok { - _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) - _node.LastLoginTime = value - } - if nodes := _c.mutation.RolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: user.RolesTable, - Columns: user.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.UserRolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: user.UserRolesTable, - Columns: []string{user.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// SetUser set the User -func (_c *UserCreate) SetUser(input *User, fields ...string) *UserCreate { - m := _c.mutation - if len(fields) == 0 { - fields = user.Columns - } - _ = m.SetFields(input, fields...) - return _c -} - -// SetUserWithZero set the User -func (_c *UserCreate) SetUserWithZero(input *User, fields ...string) *UserCreate { - m := _c.mutation - if len(fields) == 0 { - fields = user.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return _c -} - -// UserCreateBulk is the builder for creating many User entities in bulk. -type UserCreateBulk struct { - config - err error - builders []*UserCreate -} - -// Save creates the User entities in the database. -func (_c *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { - if _c.err != nil { - return nil, _c.err - } - specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*User, len(_c.builders)) - mutators := make([]Mutator, len(_c.builders)) - for i := range _c.builders { - func(i int, root context.Context) { - builder := _c.builders[i] - builder.defaults() - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*UserMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil && nodes[i].ID == 0 { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int64(id) - } - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (_c *UserCreateBulk) SaveX(ctx context.Context) []*User { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *UserCreateBulk) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *UserCreateBulk) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/user_delete.go b/internal/features/system/data/ent/user_delete.go deleted file mode 100644 index 6a43fc0a..00000000 --- a/internal/features/system/data/ent/user_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/user" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// UserDelete is the builder for deleting a User entity. -type UserDelete struct { - config - hooks []Hook - mutation *UserMutation -} - -// Where appends a list predicates to the UserDelete builder. -func (_d *UserDelete) Where(ps ...predicate.User) *UserDelete { - _d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (_d *UserDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *UserDelete) ExecX(ctx context.Context) int { - n, err := _d.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (_d *UserDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) - if ps := _d.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - _d.mutation.done = true - return affected, err -} - -// UserDeleteOne is the builder for deleting a single User entity. -type UserDeleteOne struct { - _d *UserDelete -} - -// Where appends a list predicates to the UserDelete builder. -func (_d *UserDeleteOne) Where(ps ...predicate.User) *UserDeleteOne { - _d._d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query. -func (_d *UserDeleteOne) Exec(ctx context.Context) error { - n, err := _d._d.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{user.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *UserDeleteOne) ExecX(ctx context.Context) { - if err := _d.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/user_query.go b/internal/features/system/data/ent/user_query.go deleted file mode 100644 index 063e18e4..00000000 --- a/internal/features/system/data/ent/user_query.go +++ /dev/null @@ -1,825 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "database/sql/driver" - "fmt" - "math" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// UserQuery is the builder for querying User entities. -type UserQuery struct { - config - ctx *QueryContext - order []user.OrderOption - inters []Interceptor - predicates []predicate.User - withRoles *RoleQuery - withUserRoles *UserRoleQuery - modifiers []func(*sql.Selector) - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the UserQuery builder. -func (_q *UserQuery) Where(ps ...predicate.User) *UserQuery { - _q.predicates = append(_q.predicates, ps...) - return _q -} - -// Limit the number of records to be returned by this query. -func (_q *UserQuery) Limit(limit int) *UserQuery { - _q.ctx.Limit = &limit - return _q -} - -// Offset to start from. -func (_q *UserQuery) Offset(offset int) *UserQuery { - _q.ctx.Offset = &offset - return _q -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (_q *UserQuery) Unique(unique bool) *UserQuery { - _q.ctx.Unique = &unique - return _q -} - -// Order specifies how the records should be ordered. -func (_q *UserQuery) Order(o ...user.OrderOption) *UserQuery { - _q.order = append(_q.order, o...) - return _q -} - -// QueryRoles chains the current query on the "roles" edge. -func (_q *UserQuery) QueryRoles() *RoleQuery { - query := (&RoleClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, selector), - sqlgraph.To(role.Table, role.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, user.RolesTable, user.RolesPrimaryKey...), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryUserRoles chains the current query on the "user_roles" edge. -func (_q *UserQuery) QueryUserRoles() *UserRoleQuery { - query := (&UserRoleClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(user.Table, user.FieldID, selector), - sqlgraph.To(userrole.Table, userrole.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, user.UserRolesTable, user.UserRolesColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first User entity from the query. -// Returns a *NotFoundError when no User was found. -func (_q *UserQuery) First(ctx context.Context) (*User, error) { - nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{user.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (_q *UserQuery) FirstX(ctx context.Context) *User { - node, err := _q.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first User ID from the query. -// Returns a *NotFoundError when no User ID was found. -func (_q *UserQuery) FirstID(ctx context.Context) (id int64, err error) { - var ids []int64 - if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{user.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (_q *UserQuery) FirstIDX(ctx context.Context) int64 { - id, err := _q.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single User entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one User entity is found. -// Returns a *NotFoundError when no User entities are found. -func (_q *UserQuery) Only(ctx context.Context) (*User, error) { - nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{user.Label} - default: - return nil, &NotSingularError{user.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (_q *UserQuery) OnlyX(ctx context.Context) *User { - node, err := _q.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only User ID in the query. -// Returns a *NotSingularError when more than one User ID is found. -// Returns a *NotFoundError when no entities are found. -func (_q *UserQuery) OnlyID(ctx context.Context) (id int64, err error) { - var ids []int64 - if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{user.Label} - default: - err = &NotSingularError{user.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *UserQuery) OnlyIDX(ctx context.Context) int64 { - id, err := _q.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of Users. -func (_q *UserQuery) All(ctx context.Context) ([]*User, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*User, *UserQuery]() - return withInterceptors[[]*User](ctx, _q, qr, _q.inters) -} - -// AllX is like All, but panics if an error occurs. -func (_q *UserQuery) AllX(ctx context.Context) []*User { - nodes, err := _q.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of User IDs. -func (_q *UserQuery) IDs(ctx context.Context) (ids []int64, err error) { - if _q.ctx.Unique == nil && _q.path != nil { - _q.Unique(true) - } - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(user.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (_q *UserQuery) IDsX(ctx context.Context) []int64 { - ids, err := _q.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (_q *UserQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) - if err := _q.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, _q, querierCount[*UserQuery](), _q.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (_q *UserQuery) CountX(ctx context.Context) int { - count, err := _q.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (_q *UserQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) - switch _, err := _q.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - -// ExistX is like Exist, but panics if an error occurs. -func (_q *UserQuery) ExistX(ctx context.Context) bool { - exist, err := _q.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (_q *UserQuery) Clone() *UserQuery { - if _q == nil { - return nil - } - return &UserQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]user.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.User{}, _q.predicates...), - withRoles: _q.withRoles.Clone(), - withUserRoles: _q.withUserRoles.Clone(), - // clone intermediate query. - sql: _q.sql.Clone(), - path: _q.path, - modifiers: append([]func(*sql.Selector){}, _q.modifiers...), - } -} - -// WithRoles tells the query-builder to eager-load the nodes that are connected to -// the "roles" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *UserQuery) WithRoles(opts ...func(*RoleQuery)) *UserQuery { - query := (&RoleClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withRoles = query - return _q -} - -// WithUserRoles tells the query-builder to eager-load the nodes that are connected to -// the "user_roles" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *UserQuery) WithUserRoles(opts ...func(*UserRoleQuery)) *UserQuery { - query := (&UserRoleClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withUserRoles = query - return _q -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.User.Query(). -// GroupBy(user.FieldCreateTime). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (_q *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { - _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &UserGroupBy{build: _q} - grbuild.flds = &_q.ctx.Fields - grbuild.label = user.Label - grbuild.scan = grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// } -// -// client.User.Query(). -// Select(user.FieldCreateTime). -// Scan(ctx, &v) -func (_q *UserQuery) Select(fields ...string) *UserSelect { - _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &UserSelect{UserQuery: _q} - sbuild.label = user.Label - sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a UserSelect configured with the given aggregations. -func (_q *UserQuery) Aggregate(fns ...AggregateFunc) *UserSelect { - return _q.Select().Aggregate(fns...) -} - -func (_q *UserQuery) prepareQuery(ctx context.Context) error { - for _, inter := range _q.inters { - if inter == nil { - return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") - } - if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, _q); err != nil { - return err - } - } - } - for _, f := range _q.ctx.Fields { - if !user.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if _q.path != nil { - prev, err := _q.path(ctx) - if err != nil { - return err - } - _q.sql = prev - } - return nil -} - -func (_q *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) { - var ( - nodes = []*User{} - _spec = _q.querySpec() - loadedTypes = [2]bool{ - _q.withRoles != nil, - _q.withUserRoles != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*User).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &User{config: _q.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := _q.withRoles; query != nil { - if err := _q.loadRoles(ctx, query, nodes, - func(n *User) { n.Edges.Roles = []*Role{} }, - func(n *User, e *Role) { n.Edges.Roles = append(n.Edges.Roles, e) }); err != nil { - return nil, err - } - } - if query := _q.withUserRoles; query != nil { - if err := _q.loadUserRoles(ctx, query, nodes, - func(n *User) { n.Edges.UserRoles = []*UserRole{} }, - func(n *User, e *UserRole) { n.Edges.UserRoles = append(n.Edges.UserRoles, e) }); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (_q *UserQuery) loadRoles(ctx context.Context, query *RoleQuery, nodes []*User, init func(*User), assign func(*User, *Role)) error { - edgeIDs := make([]driver.Value, len(nodes)) - byID := make(map[int64]*User) - nids := make(map[int64]map[*User]struct{}) - for i, node := range nodes { - edgeIDs[i] = node.ID - byID[node.ID] = node - if init != nil { - init(node) - } - } - query.Where(func(s *sql.Selector) { - joinT := sql.Table(user.RolesTable) - s.Join(joinT).On(s.C(role.FieldID), joinT.C(user.RolesPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(user.RolesPrimaryKey[0]), edgeIDs...)) - columns := s.SelectedColumns() - s.Select(joinT.C(user.RolesPrimaryKey[0])) - s.AppendSelect(columns...) - s.SetDistinct(false) - }) - if err := query.prepareQuery(ctx); err != nil { - return err - } - qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { - return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err - } - return append([]any{new(sql.NullInt64)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := values[0].(*sql.NullInt64).Int64 - inValue := values[1].(*sql.NullInt64).Int64 - if nids[inValue] == nil { - nids[inValue] = map[*User]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) - } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } - }) - }) - neighbors, err := withInterceptors[[]*Role](ctx, query, qr, query.inters) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nids[n.ID] - if !ok { - return fmt.Errorf(`unexpected "roles" node returned %v`, n.ID) - } - for kn := range nodes { - assign(kn, n) - } - } - return nil -} -func (_q *UserQuery) loadUserRoles(ctx context.Context, query *UserRoleQuery, nodes []*User, init func(*User), assign func(*User, *UserRole)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int64]*User) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(userrole.FieldUserID) - } - query.Where(predicate.UserRole(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(user.UserRolesColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.UserID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "user_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} - -func (_q *UserQuery) sqlCount(ctx context.Context) (int, error) { - _spec := _q.querySpec() - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - _spec.Node.Columns = _q.ctx.Fields - if len(_q.ctx.Fields) > 0 { - _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique - } - return sqlgraph.CountNodes(ctx, _q.driver, _spec) -} - -func (_q *UserQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) - _spec.From = _q.sql - if unique := _q.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if _q.path != nil { - _spec.Unique = true - } - if fields := _q.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) - for i := range fields { - if fields[i] != user.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - } - if ps := _q.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := _q.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := _q.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := _q.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (_q *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(user.Table) - columns := _q.ctx.Fields - if len(columns) == 0 { - columns = user.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if _q.sql != nil { - selector = _q.sql - selector.Select(selector.Columns(columns...)...) - } - if _q.ctx.Unique != nil && *_q.ctx.Unique { - selector.Distinct() - } - for _, m := range _q.modifiers { - m(selector) - } - for _, p := range _q.predicates { - p(selector) - } - for _, p := range _q.order { - p(selector) - } - if offset := _q.ctx.Offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := _q.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// ForUpdate locks the selected rows against concurrent updates, and prevent them from being -// updated, deleted or "selected ... for update" by other sessions, until the transaction is -// either committed or rolled-back. -func (_q *UserQuery) ForUpdate(opts ...sql.LockOption) *UserQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForUpdate(opts...) - }) - return _q -} - -// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock -// on any rows that are read. Other sessions can read the rows, but cannot modify them -// until your transaction commits. -func (_q *UserQuery) ForShare(opts ...sql.LockOption) *UserQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForShare(opts...) - }) - return _q -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { - _q.modifiers = append(_q.modifiers, modifiers...) - return _q.Select() -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// Example: -// -// var v []struct { -// CreateTime time.Time `json:"create_time,omitempty"` -// UpdateTime time.Time `json:"update_time,omitempty"` -// UUID string `json:"uuid,omitempty"` -// AllowedIP string `json:"allowed_ip,omitempty"` -// Username string `json:"username,omitempty"` -// Nickname string `json:"nickname,omitempty"` -// Avatar string `json:"avatar,omitempty"` -// Name string `json:"name,omitempty"` -// Gender user.Gender `json:"gender,omitempty"` -// Password string `json:"password,omitempty"` -// Phone string `json:"phone,omitempty"` -// Email string `json:"email,omitempty"` -// Department string `json:"department,omitempty"` -// Remark string `json:"remark,omitempty"` -// Status int8 `json:"status,omitempty"` -// IsSystem bool `json:"is_system,omitempty"` -// LastLoginIP string `json:"last_login_ip,omitempty"` -// LastLoginTime time.Time `json:"last_login_time,omitempty"` -// } -// -// client.User.Query(). -// Omit( -// user.FieldCreateTime, -// user.FieldUpdateTime, -// user.FieldUUID, -// user.FieldAllowedIP, -// user.FieldUsername, -// user.FieldNickname, -// user.FieldAvatar, -// user.FieldName, -// user.FieldGender, -// user.FieldPassword, -// user.FieldPhone, -// user.FieldEmail, -// user.FieldDepartment, -// user.FieldRemark, -// user.FieldStatus, -// user.FieldIsSystem, -// user.FieldLastLoginIP, -// user.FieldLastLoginTime, -// ). -// Scan(ctx, &v) -func (uq *UserQuery) Omit(fields ...string) *UserSelect { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - for _, col := range user.Columns { - if _, ok := omits[col]; !ok { - uq.ctx.Fields = append(uq.ctx.Fields, col) - } - } - - sbuild := &UserSelect{UserQuery: uq} - sbuild.label = user.Label - sbuild.flds, sbuild.scan = &uq.ctx.Fields, sbuild.Scan - return sbuild -} - -// UserGroupBy is the group-by builder for User entities. -type UserGroupBy struct { - selector - build *UserQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (_g *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { - _g.fns = append(_g.fns, fns...) - return _g -} - -// Scan applies the selector query and scans the result into the given value. -func (_g *UserGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) - if err := _g.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*UserQuery, *UserGroupBy](ctx, _g.build, _g, _g.build.inters, v) -} - -func (_g *UserGroupBy) sqlScan(ctx context.Context, root *UserQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(_g.fns)) - for _, fn := range _g.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) - for _, f := range *_g.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*_g.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// UserSelect is the builder for selecting fields of User entities. -type UserSelect struct { - *UserQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (_s *UserSelect) Aggregate(fns ...AggregateFunc) *UserSelect { - _s.fns = append(_s.fns, fns...) - return _s -} - -// Scan applies the selector query and scans the result into the given value. -func (_s *UserSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) - if err := _s.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*UserQuery, *UserSelect](ctx, _s.UserQuery, _s, _s.inters, v) -} - -func (_s *UserSelect) sqlScan(ctx context.Context, root *UserQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(_s.fns)) - for _, fn := range _s.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*_s.selector.flds); { - case n == 0 && len(aggregation) > 0: - selector.Select(aggregation...) - case n != 0 && len(aggregation) > 0: - selector.AppendSelect(aggregation...) - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _s.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_s *UserSelect) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { - _s.modifiers = append(_s.modifiers, modifiers...) - return _s -} diff --git a/internal/features/system/data/ent/user_update.go b/internal/features/system/data/ent/user_update.go deleted file mode 100644 index d288b564..00000000 --- a/internal/features/system/data/ent/user_update.go +++ /dev/null @@ -1,1328 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - "time" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// UserUpdate is the builder for updating User entities. -type UserUpdate struct { - config - hooks []Hook - mutation *UserMutation - modifiers []func(*sql.UpdateBuilder) -} - -// Where appends a list predicates to the UserUpdate builder. -func (_u *UserUpdate) Where(ps ...predicate.User) *UserUpdate { - _u.mutation.Where(ps...) - return _u -} - -// SetUpdateTime sets the "update_time" field. -func (_u *UserUpdate) SetUpdateTime(v time.Time) *UserUpdate { - _u.mutation.SetUpdateTime(v) - return _u -} - -// SetUUID sets the "uuid" field. -func (_u *UserUpdate) SetUUID(v string) *UserUpdate { - _u.mutation.SetUUID(v) - return _u -} - -// SetNillableUUID sets the "uuid" field if the given value is not nil. -func (_u *UserUpdate) SetNillableUUID(v *string) *UserUpdate { - if v != nil { - _u.SetUUID(*v) - } - return _u -} - -// SetAllowedIP sets the "allowed_ip" field. -func (_u *UserUpdate) SetAllowedIP(v string) *UserUpdate { - _u.mutation.SetAllowedIP(v) - return _u -} - -// SetNillableAllowedIP sets the "allowed_ip" field if the given value is not nil. -func (_u *UserUpdate) SetNillableAllowedIP(v *string) *UserUpdate { - if v != nil { - _u.SetAllowedIP(*v) - } - return _u -} - -// SetUsername sets the "username" field. -func (_u *UserUpdate) SetUsername(v string) *UserUpdate { - _u.mutation.SetUsername(v) - return _u -} - -// SetNillableUsername sets the "username" field if the given value is not nil. -func (_u *UserUpdate) SetNillableUsername(v *string) *UserUpdate { - if v != nil { - _u.SetUsername(*v) - } - return _u -} - -// SetNickname sets the "nickname" field. -func (_u *UserUpdate) SetNickname(v string) *UserUpdate { - _u.mutation.SetNickname(v) - return _u -} - -// SetNillableNickname sets the "nickname" field if the given value is not nil. -func (_u *UserUpdate) SetNillableNickname(v *string) *UserUpdate { - if v != nil { - _u.SetNickname(*v) - } - return _u -} - -// SetAvatar sets the "avatar" field. -func (_u *UserUpdate) SetAvatar(v string) *UserUpdate { - _u.mutation.SetAvatar(v) - return _u -} - -// SetNillableAvatar sets the "avatar" field if the given value is not nil. -func (_u *UserUpdate) SetNillableAvatar(v *string) *UserUpdate { - if v != nil { - _u.SetAvatar(*v) - } - return _u -} - -// SetName sets the "name" field. -func (_u *UserUpdate) SetName(v string) *UserUpdate { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *UserUpdate) SetNillableName(v *string) *UserUpdate { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetGender sets the "gender" field. -func (_u *UserUpdate) SetGender(v user.Gender) *UserUpdate { - _u.mutation.SetGender(v) - return _u -} - -// SetNillableGender sets the "gender" field if the given value is not nil. -func (_u *UserUpdate) SetNillableGender(v *user.Gender) *UserUpdate { - if v != nil { - _u.SetGender(*v) - } - return _u -} - -// SetPassword sets the "password" field. -func (_u *UserUpdate) SetPassword(v string) *UserUpdate { - _u.mutation.SetPassword(v) - return _u -} - -// SetNillablePassword sets the "password" field if the given value is not nil. -func (_u *UserUpdate) SetNillablePassword(v *string) *UserUpdate { - if v != nil { - _u.SetPassword(*v) - } - return _u -} - -// SetPhone sets the "phone" field. -func (_u *UserUpdate) SetPhone(v string) *UserUpdate { - _u.mutation.SetPhone(v) - return _u -} - -// SetNillablePhone sets the "phone" field if the given value is not nil. -func (_u *UserUpdate) SetNillablePhone(v *string) *UserUpdate { - if v != nil { - _u.SetPhone(*v) - } - return _u -} - -// SetEmail sets the "email" field. -func (_u *UserUpdate) SetEmail(v string) *UserUpdate { - _u.mutation.SetEmail(v) - return _u -} - -// SetNillableEmail sets the "email" field if the given value is not nil. -func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate { - if v != nil { - _u.SetEmail(*v) - } - return _u -} - -// SetDepartment sets the "department" field. -func (_u *UserUpdate) SetDepartment(v string) *UserUpdate { - _u.mutation.SetDepartment(v) - return _u -} - -// SetNillableDepartment sets the "department" field if the given value is not nil. -func (_u *UserUpdate) SetNillableDepartment(v *string) *UserUpdate { - if v != nil { - _u.SetDepartment(*v) - } - return _u -} - -// SetRemark sets the "remark" field. -func (_u *UserUpdate) SetRemark(v string) *UserUpdate { - _u.mutation.SetRemark(v) - return _u -} - -// SetNillableRemark sets the "remark" field if the given value is not nil. -func (_u *UserUpdate) SetNillableRemark(v *string) *UserUpdate { - if v != nil { - _u.SetRemark(*v) - } - return _u -} - -// SetStatus sets the "status" field. -func (_u *UserUpdate) SetStatus(v int8) *UserUpdate { - _u.mutation.ResetStatus() - _u.mutation.SetStatus(v) - return _u -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *UserUpdate) SetNillableStatus(v *int8) *UserUpdate { - if v != nil { - _u.SetStatus(*v) - } - return _u -} - -// AddStatus adds value to the "status" field. -func (_u *UserUpdate) AddStatus(v int8) *UserUpdate { - _u.mutation.AddStatus(v) - return _u -} - -// SetIsSystem sets the "is_system" field. -func (_u *UserUpdate) SetIsSystem(v bool) *UserUpdate { - _u.mutation.SetIsSystem(v) - return _u -} - -// SetNillableIsSystem sets the "is_system" field if the given value is not nil. -func (_u *UserUpdate) SetNillableIsSystem(v *bool) *UserUpdate { - if v != nil { - _u.SetIsSystem(*v) - } - return _u -} - -// SetLastLoginIP sets the "last_login_ip" field. -func (_u *UserUpdate) SetLastLoginIP(v string) *UserUpdate { - _u.mutation.SetLastLoginIP(v) - return _u -} - -// SetNillableLastLoginIP sets the "last_login_ip" field if the given value is not nil. -func (_u *UserUpdate) SetNillableLastLoginIP(v *string) *UserUpdate { - if v != nil { - _u.SetLastLoginIP(*v) - } - return _u -} - -// SetLastLoginTime sets the "last_login_time" field. -func (_u *UserUpdate) SetLastLoginTime(v time.Time) *UserUpdate { - _u.mutation.SetLastLoginTime(v) - return _u -} - -// SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. -func (_u *UserUpdate) SetNillableLastLoginTime(v *time.Time) *UserUpdate { - if v != nil { - _u.SetLastLoginTime(*v) - } - return _u -} - -// ClearLastLoginTime clears the value of the "last_login_time" field. -func (_u *UserUpdate) ClearLastLoginTime() *UserUpdate { - _u.mutation.ClearLastLoginTime() - return _u -} - -// AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (_u *UserUpdate) AddRoleIDs(ids ...int64) *UserUpdate { - _u.mutation.AddRoleIDs(ids...) - return _u -} - -// AddRoles adds the "roles" edges to the Role entity. -func (_u *UserUpdate) AddRoles(v ...*Role) *UserUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddRoleIDs(ids...) -} - -// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (_u *UserUpdate) AddUserRoleIDs(ids ...int) *UserUpdate { - _u.mutation.AddUserRoleIDs(ids...) - return _u -} - -// AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (_u *UserUpdate) AddUserRoles(v ...*UserRole) *UserUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddUserRoleIDs(ids...) -} - -// Mutation returns the UserMutation object of the builder. -func (_u *UserUpdate) Mutation() *UserMutation { - return _u.mutation -} - -// ClearRoles clears all "roles" edges to the Role entity. -func (_u *UserUpdate) ClearRoles() *UserUpdate { - _u.mutation.ClearRoles() - return _u -} - -// RemoveRoleIDs removes the "roles" edge to Role entities by IDs. -func (_u *UserUpdate) RemoveRoleIDs(ids ...int64) *UserUpdate { - _u.mutation.RemoveRoleIDs(ids...) - return _u -} - -// RemoveRoles removes "roles" edges to Role entities. -func (_u *UserUpdate) RemoveRoles(v ...*Role) *UserUpdate { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveRoleIDs(ids...) -} - -// ClearUserRoles clears all "user_roles" edges to the UserRole entity. -func (_u *UserUpdate) ClearUserRoles() *UserUpdate { - _u.mutation.ClearUserRoles() - return _u -} - -// RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. -func (_u *UserUpdate) RemoveUserRoleIDs(ids ...int) *UserUpdate { - _u.mutation.RemoveUserRoleIDs(ids...) - return _u -} - -// RemoveUserRoles removes "user_roles" edges to UserRole entities. -func (_u *UserUpdate) RemoveUserRoles(v ...*UserRole) *UserUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveUserRoleIDs(ids...) -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (_u *UserUpdate) Save(ctx context.Context) (int, error) { - _u.defaults() - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *UserUpdate) SaveX(ctx context.Context) int { - affected, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (_u *UserUpdate) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *UserUpdate) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *UserUpdate) defaults() { - if _, ok := _u.mutation.UpdateTime(); !ok { - v := user.UpdateDefaultUpdateTime() - _u.mutation.SetUpdateTime(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *UserUpdate) check() error { - if v, ok := _u.mutation.UUID(); ok { - if err := user.UUIDValidator(v); err != nil { - return &ValidationError{Name: "uuid", err: fmt.Errorf(`ent: validator failed for field "User.uuid": %w`, err)} - } - } - if v, ok := _u.mutation.Username(); ok { - if err := user.UsernameValidator(v); err != nil { - return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} - } - } - if v, ok := _u.mutation.Nickname(); ok { - if err := user.NicknameValidator(v); err != nil { - return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} - } - } - if v, ok := _u.mutation.Avatar(); ok { - if err := user.AvatarValidator(v); err != nil { - return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} - } - } - if v, ok := _u.mutation.Name(); ok { - if err := user.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} - } - } - if v, ok := _u.mutation.Gender(); ok { - if err := user.GenderValidator(v); err != nil { - return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} - } - } - if v, ok := _u.mutation.Password(); ok { - if err := user.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} - } - } - if v, ok := _u.mutation.Phone(); ok { - if err := user.PhoneValidator(v); err != nil { - return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "User.phone": %w`, err)} - } - } - if v, ok := _u.mutation.Email(); ok { - if err := user.EmailValidator(v); err != nil { - return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} - } - } - if v, ok := _u.mutation.Department(); ok { - if err := user.DepartmentValidator(v); err != nil { - return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} - } - } - if v, ok := _u.mutation.Remark(); ok { - if err := user.RemarkValidator(v); err != nil { - return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "User.remark": %w`, err)} - } - } - if v, ok := _u.mutation.LastLoginIP(); ok { - if err := user.LastLoginIPValidator(v); err != nil { - return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} - } - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *UserUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdate { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.UpdateTime(); ok { - _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) - } - if value, ok := _u.mutation.UUID(); ok { - _spec.SetField(user.FieldUUID, field.TypeString, value) - } - if value, ok := _u.mutation.AllowedIP(); ok { - _spec.SetField(user.FieldAllowedIP, field.TypeString, value) - } - if value, ok := _u.mutation.Username(); ok { - _spec.SetField(user.FieldUsername, field.TypeString, value) - } - if value, ok := _u.mutation.Nickname(); ok { - _spec.SetField(user.FieldNickname, field.TypeString, value) - } - if value, ok := _u.mutation.Avatar(); ok { - _spec.SetField(user.FieldAvatar, field.TypeString, value) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(user.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Gender(); ok { - _spec.SetField(user.FieldGender, field.TypeEnum, value) - } - if value, ok := _u.mutation.Password(); ok { - _spec.SetField(user.FieldPassword, field.TypeString, value) - } - if value, ok := _u.mutation.Phone(); ok { - _spec.SetField(user.FieldPhone, field.TypeString, value) - } - if value, ok := _u.mutation.Email(); ok { - _spec.SetField(user.FieldEmail, field.TypeString, value) - } - if value, ok := _u.mutation.Department(); ok { - _spec.SetField(user.FieldDepartment, field.TypeString, value) - } - if value, ok := _u.mutation.Remark(); ok { - _spec.SetField(user.FieldRemark, field.TypeString, value) - } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(user.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedStatus(); ok { - _spec.AddField(user.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.IsSystem(); ok { - _spec.SetField(user.FieldIsSystem, field.TypeBool, value) - } - if value, ok := _u.mutation.LastLoginIP(); ok { - _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) - } - if value, ok := _u.mutation.LastLoginTime(); ok { - _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) - } - if _u.mutation.LastLoginTimeCleared() { - _spec.ClearField(user.FieldLastLoginTime, field.TypeTime) - } - if _u.mutation.RolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: user.RolesTable, - Columns: user.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: user.RolesTable, - Columns: user.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: user.RolesTable, - Columns: user.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.UserRolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: user.UserRolesTable, - Columns: []string{user.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: user.UserRolesTable, - Columns: []string{user.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: user.UserRolesTable, - Columns: []string{user.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{user.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - _u.mutation.done = true - return _node, nil -} - -// UserUpdateOne is the builder for updating a single User entity. -type UserUpdateOne struct { - config - fields []string - hooks []Hook - mutation *UserMutation - modifiers []func(*sql.UpdateBuilder) -} - -// SetUpdateTime sets the "update_time" field. -func (_u *UserUpdateOne) SetUpdateTime(v time.Time) *UserUpdateOne { - _u.mutation.SetUpdateTime(v) - return _u -} - -// SetUUID sets the "uuid" field. -func (_u *UserUpdateOne) SetUUID(v string) *UserUpdateOne { - _u.mutation.SetUUID(v) - return _u -} - -// SetNillableUUID sets the "uuid" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableUUID(v *string) *UserUpdateOne { - if v != nil { - _u.SetUUID(*v) - } - return _u -} - -// SetAllowedIP sets the "allowed_ip" field. -func (_u *UserUpdateOne) SetAllowedIP(v string) *UserUpdateOne { - _u.mutation.SetAllowedIP(v) - return _u -} - -// SetNillableAllowedIP sets the "allowed_ip" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableAllowedIP(v *string) *UserUpdateOne { - if v != nil { - _u.SetAllowedIP(*v) - } - return _u -} - -// SetUsername sets the "username" field. -func (_u *UserUpdateOne) SetUsername(v string) *UserUpdateOne { - _u.mutation.SetUsername(v) - return _u -} - -// SetNillableUsername sets the "username" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableUsername(v *string) *UserUpdateOne { - if v != nil { - _u.SetUsername(*v) - } - return _u -} - -// SetNickname sets the "nickname" field. -func (_u *UserUpdateOne) SetNickname(v string) *UserUpdateOne { - _u.mutation.SetNickname(v) - return _u -} - -// SetNillableNickname sets the "nickname" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableNickname(v *string) *UserUpdateOne { - if v != nil { - _u.SetNickname(*v) - } - return _u -} - -// SetAvatar sets the "avatar" field. -func (_u *UserUpdateOne) SetAvatar(v string) *UserUpdateOne { - _u.mutation.SetAvatar(v) - return _u -} - -// SetNillableAvatar sets the "avatar" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableAvatar(v *string) *UserUpdateOne { - if v != nil { - _u.SetAvatar(*v) - } - return _u -} - -// SetName sets the "name" field. -func (_u *UserUpdateOne) SetName(v string) *UserUpdateOne { - _u.mutation.SetName(v) - return _u -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableName(v *string) *UserUpdateOne { - if v != nil { - _u.SetName(*v) - } - return _u -} - -// SetGender sets the "gender" field. -func (_u *UserUpdateOne) SetGender(v user.Gender) *UserUpdateOne { - _u.mutation.SetGender(v) - return _u -} - -// SetNillableGender sets the "gender" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableGender(v *user.Gender) *UserUpdateOne { - if v != nil { - _u.SetGender(*v) - } - return _u -} - -// SetPassword sets the "password" field. -func (_u *UserUpdateOne) SetPassword(v string) *UserUpdateOne { - _u.mutation.SetPassword(v) - return _u -} - -// SetNillablePassword sets the "password" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillablePassword(v *string) *UserUpdateOne { - if v != nil { - _u.SetPassword(*v) - } - return _u -} - -// SetPhone sets the "phone" field. -func (_u *UserUpdateOne) SetPhone(v string) *UserUpdateOne { - _u.mutation.SetPhone(v) - return _u -} - -// SetNillablePhone sets the "phone" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillablePhone(v *string) *UserUpdateOne { - if v != nil { - _u.SetPhone(*v) - } - return _u -} - -// SetEmail sets the "email" field. -func (_u *UserUpdateOne) SetEmail(v string) *UserUpdateOne { - _u.mutation.SetEmail(v) - return _u -} - -// SetNillableEmail sets the "email" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne { - if v != nil { - _u.SetEmail(*v) - } - return _u -} - -// SetDepartment sets the "department" field. -func (_u *UserUpdateOne) SetDepartment(v string) *UserUpdateOne { - _u.mutation.SetDepartment(v) - return _u -} - -// SetNillableDepartment sets the "department" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableDepartment(v *string) *UserUpdateOne { - if v != nil { - _u.SetDepartment(*v) - } - return _u -} - -// SetRemark sets the "remark" field. -func (_u *UserUpdateOne) SetRemark(v string) *UserUpdateOne { - _u.mutation.SetRemark(v) - return _u -} - -// SetNillableRemark sets the "remark" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableRemark(v *string) *UserUpdateOne { - if v != nil { - _u.SetRemark(*v) - } - return _u -} - -// SetStatus sets the "status" field. -func (_u *UserUpdateOne) SetStatus(v int8) *UserUpdateOne { - _u.mutation.ResetStatus() - _u.mutation.SetStatus(v) - return _u -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableStatus(v *int8) *UserUpdateOne { - if v != nil { - _u.SetStatus(*v) - } - return _u -} - -// AddStatus adds value to the "status" field. -func (_u *UserUpdateOne) AddStatus(v int8) *UserUpdateOne { - _u.mutation.AddStatus(v) - return _u -} - -// SetIsSystem sets the "is_system" field. -func (_u *UserUpdateOne) SetIsSystem(v bool) *UserUpdateOne { - _u.mutation.SetIsSystem(v) - return _u -} - -// SetNillableIsSystem sets the "is_system" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableIsSystem(v *bool) *UserUpdateOne { - if v != nil { - _u.SetIsSystem(*v) - } - return _u -} - -// SetLastLoginIP sets the "last_login_ip" field. -func (_u *UserUpdateOne) SetLastLoginIP(v string) *UserUpdateOne { - _u.mutation.SetLastLoginIP(v) - return _u -} - -// SetNillableLastLoginIP sets the "last_login_ip" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableLastLoginIP(v *string) *UserUpdateOne { - if v != nil { - _u.SetLastLoginIP(*v) - } - return _u -} - -// SetLastLoginTime sets the "last_login_time" field. -func (_u *UserUpdateOne) SetLastLoginTime(v time.Time) *UserUpdateOne { - _u.mutation.SetLastLoginTime(v) - return _u -} - -// SetNillableLastLoginTime sets the "last_login_time" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableLastLoginTime(v *time.Time) *UserUpdateOne { - if v != nil { - _u.SetLastLoginTime(*v) - } - return _u -} - -// ClearLastLoginTime clears the value of the "last_login_time" field. -func (_u *UserUpdateOne) ClearLastLoginTime() *UserUpdateOne { - _u.mutation.ClearLastLoginTime() - return _u -} - -// AddRoleIDs adds the "roles" edge to the Role entity by IDs. -func (_u *UserUpdateOne) AddRoleIDs(ids ...int64) *UserUpdateOne { - _u.mutation.AddRoleIDs(ids...) - return _u -} - -// AddRoles adds the "roles" edges to the Role entity. -func (_u *UserUpdateOne) AddRoles(v ...*Role) *UserUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddRoleIDs(ids...) -} - -// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by IDs. -func (_u *UserUpdateOne) AddUserRoleIDs(ids ...int) *UserUpdateOne { - _u.mutation.AddUserRoleIDs(ids...) - return _u -} - -// AddUserRoles adds the "user_roles" edges to the UserRole entity. -func (_u *UserUpdateOne) AddUserRoles(v ...*UserRole) *UserUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddUserRoleIDs(ids...) -} - -// Mutation returns the UserMutation object of the builder. -func (_u *UserUpdateOne) Mutation() *UserMutation { - return _u.mutation -} - -// ClearRoles clears all "roles" edges to the Role entity. -func (_u *UserUpdateOne) ClearRoles() *UserUpdateOne { - _u.mutation.ClearRoles() - return _u -} - -// RemoveRoleIDs removes the "roles" edge to Role entities by IDs. -func (_u *UserUpdateOne) RemoveRoleIDs(ids ...int64) *UserUpdateOne { - _u.mutation.RemoveRoleIDs(ids...) - return _u -} - -// RemoveRoles removes "roles" edges to Role entities. -func (_u *UserUpdateOne) RemoveRoles(v ...*Role) *UserUpdateOne { - ids := make([]int64, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveRoleIDs(ids...) -} - -// ClearUserRoles clears all "user_roles" edges to the UserRole entity. -func (_u *UserUpdateOne) ClearUserRoles() *UserUpdateOne { - _u.mutation.ClearUserRoles() - return _u -} - -// RemoveUserRoleIDs removes the "user_roles" edge to UserRole entities by IDs. -func (_u *UserUpdateOne) RemoveUserRoleIDs(ids ...int) *UserUpdateOne { - _u.mutation.RemoveUserRoleIDs(ids...) - return _u -} - -// RemoveUserRoles removes "user_roles" edges to UserRole entities. -func (_u *UserUpdateOne) RemoveUserRoles(v ...*UserRole) *UserUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemoveUserRoleIDs(ids...) -} - -// Where appends a list predicates to the UserUpdate builder. -func (_u *UserUpdateOne) Where(ps ...predicate.User) *UserUpdateOne { - _u.mutation.Where(ps...) - return _u -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (_u *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { - _u.fields = append([]string{field}, fields...) - return _u -} - -// Save executes the query and returns the updated User entity. -func (_u *UserUpdateOne) Save(ctx context.Context) (*User, error) { - _u.defaults() - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *UserUpdateOne) SaveX(ctx context.Context) *User { - node, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (_u *UserUpdateOne) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *UserUpdateOne) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// defaults sets the default values of the builder before save. -func (_u *UserUpdateOne) defaults() { - if _, ok := _u.mutation.UpdateTime(); !ok { - v := user.UpdateDefaultUpdateTime() - _u.mutation.SetUpdateTime(v) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *UserUpdateOne) check() error { - if v, ok := _u.mutation.UUID(); ok { - if err := user.UUIDValidator(v); err != nil { - return &ValidationError{Name: "uuid", err: fmt.Errorf(`ent: validator failed for field "User.uuid": %w`, err)} - } - } - if v, ok := _u.mutation.Username(); ok { - if err := user.UsernameValidator(v); err != nil { - return &ValidationError{Name: "username", err: fmt.Errorf(`ent: validator failed for field "User.username": %w`, err)} - } - } - if v, ok := _u.mutation.Nickname(); ok { - if err := user.NicknameValidator(v); err != nil { - return &ValidationError{Name: "nickname", err: fmt.Errorf(`ent: validator failed for field "User.nickname": %w`, err)} - } - } - if v, ok := _u.mutation.Avatar(); ok { - if err := user.AvatarValidator(v); err != nil { - return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "User.avatar": %w`, err)} - } - } - if v, ok := _u.mutation.Name(); ok { - if err := user.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "User.name": %w`, err)} - } - } - if v, ok := _u.mutation.Gender(); ok { - if err := user.GenderValidator(v); err != nil { - return &ValidationError{Name: "gender", err: fmt.Errorf(`ent: validator failed for field "User.gender": %w`, err)} - } - } - if v, ok := _u.mutation.Password(); ok { - if err := user.PasswordValidator(v); err != nil { - return &ValidationError{Name: "password", err: fmt.Errorf(`ent: validator failed for field "User.password": %w`, err)} - } - } - if v, ok := _u.mutation.Phone(); ok { - if err := user.PhoneValidator(v); err != nil { - return &ValidationError{Name: "phone", err: fmt.Errorf(`ent: validator failed for field "User.phone": %w`, err)} - } - } - if v, ok := _u.mutation.Email(); ok { - if err := user.EmailValidator(v); err != nil { - return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} - } - } - if v, ok := _u.mutation.Department(); ok { - if err := user.DepartmentValidator(v); err != nil { - return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} - } - } - if v, ok := _u.mutation.Remark(); ok { - if err := user.RemarkValidator(v); err != nil { - return &ValidationError{Name: "remark", err: fmt.Errorf(`ent: validator failed for field "User.remark": %w`, err)} - } - } - if v, ok := _u.mutation.LastLoginIP(); ok { - if err := user.LastLoginIPValidator(v); err != nil { - return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} - } - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *UserUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserUpdateOne { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(user.Table, user.Columns, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64)) - id, ok := _u.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := _u.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) - for _, f := range fields { - if !user.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != user.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if value, ok := _u.mutation.UpdateTime(); ok { - _spec.SetField(user.FieldUpdateTime, field.TypeTime, value) - } - if value, ok := _u.mutation.UUID(); ok { - _spec.SetField(user.FieldUUID, field.TypeString, value) - } - if value, ok := _u.mutation.AllowedIP(); ok { - _spec.SetField(user.FieldAllowedIP, field.TypeString, value) - } - if value, ok := _u.mutation.Username(); ok { - _spec.SetField(user.FieldUsername, field.TypeString, value) - } - if value, ok := _u.mutation.Nickname(); ok { - _spec.SetField(user.FieldNickname, field.TypeString, value) - } - if value, ok := _u.mutation.Avatar(); ok { - _spec.SetField(user.FieldAvatar, field.TypeString, value) - } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(user.FieldName, field.TypeString, value) - } - if value, ok := _u.mutation.Gender(); ok { - _spec.SetField(user.FieldGender, field.TypeEnum, value) - } - if value, ok := _u.mutation.Password(); ok { - _spec.SetField(user.FieldPassword, field.TypeString, value) - } - if value, ok := _u.mutation.Phone(); ok { - _spec.SetField(user.FieldPhone, field.TypeString, value) - } - if value, ok := _u.mutation.Email(); ok { - _spec.SetField(user.FieldEmail, field.TypeString, value) - } - if value, ok := _u.mutation.Department(); ok { - _spec.SetField(user.FieldDepartment, field.TypeString, value) - } - if value, ok := _u.mutation.Remark(); ok { - _spec.SetField(user.FieldRemark, field.TypeString, value) - } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(user.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedStatus(); ok { - _spec.AddField(user.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.IsSystem(); ok { - _spec.SetField(user.FieldIsSystem, field.TypeBool, value) - } - if value, ok := _u.mutation.LastLoginIP(); ok { - _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) - } - if value, ok := _u.mutation.LastLoginTime(); ok { - _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) - } - if _u.mutation.LastLoginTimeCleared() { - _spec.ClearField(user.FieldLastLoginTime, field.TypeTime) - } - if _u.mutation.RolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: user.RolesTable, - Columns: user.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedRolesIDs(); len(nodes) > 0 && !_u.mutation.RolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: user.RolesTable, - Columns: user.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2M, - Inverse: false, - Table: user.RolesTable, - Columns: user.RolesPrimaryKey, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.UserRolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: user.UserRolesTable, - Columns: []string{user.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedUserRolesIDs(); len(nodes) > 0 && !_u.mutation.UserRolesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: user.UserRolesTable, - Columns: []string{user.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.UserRolesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: user.UserRolesTable, - Columns: []string{user.UserRolesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - _node = &User{config: _u.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{user.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - _u.mutation.done = true - return _node, nil -} - -// SetUser set the User -func (uu *UserUpdate) SetUser(input *User, fields ...string) *UserUpdate { - m := uu.mutation - if len(fields) == 0 { - fields = user.OmitColumns(user.FieldID) - } - _ = m.SetFields(input, fields...) - return uu -} - -// SetUserWithZero set the User -func (uu *UserUpdate) SetUserWithZero(input *User, fields ...string) *UserUpdate { - m := uu.mutation - if len(fields) == 0 { - fields = user.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return uu -} - -// SetUser set the User -func (uuo *UserUpdateOne) SetUser(input *User, fields ...string) *UserUpdateOne { - m := uuo.mutation - if len(fields) == 0 { - fields = user.OmitColumns(user.FieldID) - } - _ = m.SetFields(input, fields...) - return uuo -} - -// SetUserWithZero set the User -func (uuo *UserUpdateOne) SetUserWithZero(input *User, fields ...string) *UserUpdateOne { - m := uuo.mutation - if len(fields) == 0 { - fields = user.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return uuo -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -func (uuo *UserUpdateOne) Omit(fields ...string) *UserUpdateOne { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - uuo.fields = []string(nil) - for _, col := range user.Columns { - if _, ok := omits[col]; !ok { - uuo.fields = append(uuo.fields, col) - } - } - return uuo -} diff --git a/internal/features/system/data/ent/userrole.go b/internal/features/system/data/ent/userrole.go deleted file mode 100644 index 920ef7c3..00000000 --- a/internal/features/system/data/ent/userrole.go +++ /dev/null @@ -1,160 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - "strings" - - "entgo.io/ent" - "entgo.io/ent/dialect/sql" -) - -// User-Role mapping table -type UserRole struct { - config `json:"-"` - // ID of the ent. - ID int `json:"id,omitempty"` - // UserID holds the value of the "user_id" field. - UserID int64 `json:"user_id,omitempty"` - // RoleID holds the value of the "role_id" field. - RoleID int64 `json:"role_id,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the UserRoleQuery when eager-loading is set. - Edges UserRoleEdges `json:"edges"` - selectValues sql.SelectValues -} - -// UserRoleEdges holds the relations/edges for other nodes in the graph. -type UserRoleEdges struct { - // User holds the value of the user edge. - User *User `json:"user,omitempty"` - // Role holds the value of the role edge. - Role *Role `json:"role,omitempty"` - // loadedTypes holds the information for reporting if a - // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool -} - -// UserOrErr returns the User value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e UserRoleEdges) UserOrErr() (*User, error) { - if e.User != nil { - return e.User, nil - } else if e.loadedTypes[0] { - return nil, &NotFoundError{label: user.Label} - } - return nil, &NotLoadedError{edge: "user"} -} - -// RoleOrErr returns the Role value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e UserRoleEdges) RoleOrErr() (*Role, error) { - if e.Role != nil { - return e.Role, nil - } else if e.loadedTypes[1] { - return nil, &NotFoundError{label: role.Label} - } - return nil, &NotLoadedError{edge: "role"} -} - -// scanValues returns the types for scanning values from sql.Rows. -func (*UserRole) scanValues(columns []string) ([]any, error) { - values := make([]any, len(columns)) - for i := range columns { - switch columns[i] { - case userrole.FieldID, userrole.FieldUserID, userrole.FieldRoleID: - values[i] = new(sql.NullInt64) - default: - values[i] = new(sql.UnknownType) - } - } - return values, nil -} - -// assignValues assigns the values that were returned from sql.Rows (after scanning) -// to the UserRole fields. -func (_m *UserRole) assignValues(columns []string, values []any) error { - if m, n := len(values), len(columns); m < n { - return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) - } - for i := range columns { - switch columns[i] { - case userrole.FieldID: - value, ok := values[i].(*sql.NullInt64) - if !ok { - return fmt.Errorf("unexpected type %T for field id", value) - } - _m.ID = int(value.Int64) - case userrole.FieldUserID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field user_id", values[i]) - } else if value.Valid { - _m.UserID = value.Int64 - } - case userrole.FieldRoleID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field role_id", values[i]) - } else if value.Valid { - _m.RoleID = value.Int64 - } - default: - _m.selectValues.Set(columns[i], values[i]) - } - } - return nil -} - -// Value returns the ent.Value that was dynamically selected and assigned to the UserRole. -// This includes values selected through modifiers, order, etc. -func (_m *UserRole) Value(name string) (ent.Value, error) { - return _m.selectValues.Get(name) -} - -// QueryUser queries the "user" edge of the UserRole entity. -func (_m *UserRole) QueryUser() *UserQuery { - return NewUserRoleClient(_m.config).QueryUser(_m) -} - -// QueryRole queries the "role" edge of the UserRole entity. -func (_m *UserRole) QueryRole() *RoleQuery { - return NewUserRoleClient(_m.config).QueryRole(_m) -} - -// Update returns a builder for updating this UserRole. -// Note that you need to call UserRole.Unwrap() before calling this method if this UserRole -// was returned from a transaction, and the transaction was committed or rolled back. -func (_m *UserRole) Update() *UserRoleUpdateOne { - return NewUserRoleClient(_m.config).UpdateOne(_m) -} - -// Unwrap unwraps the UserRole entity that was returned from a transaction after it was closed, -// so that all future queries will be executed through the driver which created the transaction. -func (_m *UserRole) Unwrap() *UserRole { - _tx, ok := _m.config.driver.(*txDriver) - if !ok { - panic("ent: UserRole is not a transactional entity") - } - _m.config.driver = _tx.drv - return _m -} - -// String implements the fmt.Stringer. -func (_m *UserRole) String() string { - var builder strings.Builder - builder.WriteString("UserRole(") - builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) - builder.WriteString("user_id=") - builder.WriteString(fmt.Sprintf("%v", _m.UserID)) - builder.WriteString(", ") - builder.WriteString("role_id=") - builder.WriteString(fmt.Sprintf("%v", _m.RoleID)) - builder.WriteByte(')') - return builder.String() -} - -// UserRoles is a parsable slice of UserRole. -type UserRoles []*UserRole diff --git a/internal/features/system/data/ent/userrole/userrole.go b/internal/features/system/data/ent/userrole/userrole.go deleted file mode 100644 index 71028bfd..00000000 --- a/internal/features/system/data/ent/userrole/userrole.go +++ /dev/null @@ -1,164 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package userrole - -import ( - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -const ( - // Label holds the string label denoting the userrole type in the database. - Label = "user_role" - // FieldID holds the string denoting the id field in the database. - FieldID = "id" - // FieldUserID holds the string denoting the user_id field in the database. - FieldUserID = "user_id" - // FieldRoleID holds the string denoting the role_id field in the database. - FieldRoleID = "role_id" - // EdgeUser holds the string denoting the user edge name in mutations. - EdgeUser = "user" - // EdgeRole holds the string denoting the role edge name in mutations. - EdgeRole = "role" - // Table holds the table name of the userrole in the database. - Table = "sys_user_roles" - // UserTable is the table that holds the user relation/edge. - UserTable = "sys_user_roles" - // UserInverseTable is the table name for the User entity. - // It exists in this package in order to avoid circular dependency with the "user" package. - UserInverseTable = "sys_users" - // UserColumn is the table column denoting the user relation/edge. - UserColumn = "user_id" - // RoleTable is the table that holds the role relation/edge. - RoleTable = "sys_user_roles" - // RoleInverseTable is the table name for the Role entity. - // It exists in this package in order to avoid circular dependency with the "role" package. - RoleInverseTable = "sys_roles" - // RoleColumn is the table column denoting the role relation/edge. - RoleColumn = "role_id" -) - -// Columns holds all SQL columns for userrole fields. -var Columns = []string{ - FieldID, - FieldUserID, - FieldRoleID, -} - -// ValidColumn reports if the column name is valid (part of the table columns). -func ValidColumn(column string) bool { - for i := range Columns { - if column == Columns[i] { - return true - } - } - return false -} - -// OrderOption defines the ordering options for the UserRole queries. -type OrderOption func(*sql.Selector) - -// ByID orders the results by the id field. -func ByID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldID, opts...).ToFunc() -} - -// ByUserID orders the results by the user_id field. -func ByUserID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldUserID, opts...).ToFunc() -} - -// ByRoleID orders the results by the role_id field. -func ByRoleID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRoleID, opts...).ToFunc() -} - -// ByUserField orders the results by user field. -func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...)) - } -} - -// ByRoleField orders the results by role field. -func ByRoleField(field string, opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newRoleStep(), sql.OrderByField(field, opts...)) - } -} -func newUserStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(UserInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), - ) -} -func newRoleStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(RoleInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), - ) -} - -// SelectColumns returns all selected fields. -func SelectColumns(fields []string) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(fields)) - for _, field := range fields { - if field != FieldID { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -// OmitColumns returns all fields that are not in the list of fields. -func OmitColumns(fields ...string) []string { - // Default removal FieldID - return omitColumns(Columns, fields, true) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumns(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Default removal FieldID - return omitColumns(src, fields, true) -} - -// OmitColumnsWithID returns all fields that are not in the list of fields. -func OmitColumnsWithID(fields ...string) []string { - // Not remove FieldID - return omitColumns(Columns, fields, false) -} - -// OmitCustomColumns returns all fields that are not in the list of fields. -func OmitCustomColumnsWithID(src []string, fields ...string) []string { - if len(src) == 0 { - src = Columns - } - // Not remove FieldID - return omitColumns(src, fields, false) -} - -func omitColumns(src []string, fields []string, omitID bool) []string { - // Default removal FieldID - filteredFields := make([]string, 0, len(src)) - for _, field := range src { - if !(omitID && field == FieldID) && !contains(fields, field) { - filteredFields = append(filteredFields, field) - } - } - return filteredFields -} - -func contains(slice []string, item string) bool { - for _, s := range slice { - if s == item { - return true - } - } - return false -} diff --git a/internal/features/system/data/ent/userrole/where.go b/internal/features/system/data/ent/userrole/where.go deleted file mode 100644 index 53430300..00000000 --- a/internal/features/system/data/ent/userrole/where.go +++ /dev/null @@ -1,166 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package userrole - -import ( - "origadmin/application/admin/internal/features/system/data/ent/predicate" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" -) - -// ID filters vertices based on their ID field. -func ID(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldID, id)) -} - -// IDEQ applies the EQ predicate on the ID field. -func IDEQ(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldID, id)) -} - -// IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldNEQ(FieldID, id)) -} - -// IDIn applies the In predicate on the ID field. -func IDIn(ids ...int) predicate.UserRole { - return predicate.UserRole(sql.FieldIn(FieldID, ids...)) -} - -// IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...int) predicate.UserRole { - return predicate.UserRole(sql.FieldNotIn(FieldID, ids...)) -} - -// IDGT applies the GT predicate on the ID field. -func IDGT(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldGT(FieldID, id)) -} - -// IDGTE applies the GTE predicate on the ID field. -func IDGTE(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldGTE(FieldID, id)) -} - -// IDLT applies the LT predicate on the ID field. -func IDLT(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldLT(FieldID, id)) -} - -// IDLTE applies the LTE predicate on the ID field. -func IDLTE(id int) predicate.UserRole { - return predicate.UserRole(sql.FieldLTE(FieldID, id)) -} - -// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ. -func UserID(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldUserID, v)) -} - -// RoleID applies equality check predicate on the "role_id" field. It's identical to RoleIDEQ. -func RoleID(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldRoleID, v)) -} - -// UserIDEQ applies the EQ predicate on the "user_id" field. -func UserIDEQ(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldUserID, v)) -} - -// UserIDNEQ applies the NEQ predicate on the "user_id" field. -func UserIDNEQ(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldNEQ(FieldUserID, v)) -} - -// UserIDIn applies the In predicate on the "user_id" field. -func UserIDIn(vs ...int64) predicate.UserRole { - return predicate.UserRole(sql.FieldIn(FieldUserID, vs...)) -} - -// UserIDNotIn applies the NotIn predicate on the "user_id" field. -func UserIDNotIn(vs ...int64) predicate.UserRole { - return predicate.UserRole(sql.FieldNotIn(FieldUserID, vs...)) -} - -// RoleIDEQ applies the EQ predicate on the "role_id" field. -func RoleIDEQ(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldEQ(FieldRoleID, v)) -} - -// RoleIDNEQ applies the NEQ predicate on the "role_id" field. -func RoleIDNEQ(v int64) predicate.UserRole { - return predicate.UserRole(sql.FieldNEQ(FieldRoleID, v)) -} - -// RoleIDIn applies the In predicate on the "role_id" field. -func RoleIDIn(vs ...int64) predicate.UserRole { - return predicate.UserRole(sql.FieldIn(FieldRoleID, vs...)) -} - -// RoleIDNotIn applies the NotIn predicate on the "role_id" field. -func RoleIDNotIn(vs ...int64) predicate.UserRole { - return predicate.UserRole(sql.FieldNotIn(FieldRoleID, vs...)) -} - -// HasUser applies the HasEdge predicate on the "user" edge. -func HasUser() predicate.UserRole { - return predicate.UserRole(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates). -func HasUserWith(preds ...predicate.User) predicate.UserRole { - return predicate.UserRole(func(s *sql.Selector) { - step := newUserStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// HasRole applies the HasEdge predicate on the "role" edge. -func HasRole() predicate.UserRole { - return predicate.UserRole(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, RoleTable, RoleColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasRoleWith applies the HasEdge predicate on the "role" edge with a given conditions (other predicates). -func HasRoleWith(preds ...predicate.Role) predicate.UserRole { - return predicate.UserRole(func(s *sql.Selector) { - step := newRoleStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - -// And groups predicates with the AND operator between them. -func And(predicates ...predicate.UserRole) predicate.UserRole { - return predicate.UserRole(sql.AndPredicates(predicates...)) -} - -// Or groups predicates with the OR operator between them. -func Or(predicates ...predicate.UserRole) predicate.UserRole { - return predicate.UserRole(sql.OrPredicates(predicates...)) -} - -// Not applies the not operator on the given predicate. -func Not(p predicate.UserRole) predicate.UserRole { - return predicate.UserRole(sql.NotPredicates(p)) -} diff --git a/internal/features/system/data/ent/userrole_create.go b/internal/features/system/data/ent/userrole_create.go deleted file mode 100644 index 5fda64c2..00000000 --- a/internal/features/system/data/ent/userrole_create.go +++ /dev/null @@ -1,260 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// UserRoleCreate is the builder for creating a UserRole entity. -type UserRoleCreate struct { - config - mutation *UserRoleMutation - hooks []Hook -} - -// SetUserID sets the "user_id" field. -func (_c *UserRoleCreate) SetUserID(v int64) *UserRoleCreate { - _c.mutation.SetUserID(v) - return _c -} - -// SetRoleID sets the "role_id" field. -func (_c *UserRoleCreate) SetRoleID(v int64) *UserRoleCreate { - _c.mutation.SetRoleID(v) - return _c -} - -// SetUser sets the "user" edge to the User entity. -func (_c *UserRoleCreate) SetUser(v *User) *UserRoleCreate { - return _c.SetUserID(v.ID) -} - -// SetRole sets the "role" edge to the Role entity. -func (_c *UserRoleCreate) SetRole(v *Role) *UserRoleCreate { - return _c.SetRoleID(v.ID) -} - -// Mutation returns the UserRoleMutation object of the builder. -func (_c *UserRoleCreate) Mutation() *UserRoleMutation { - return _c.mutation -} - -// Save creates the UserRole in the database. -func (_c *UserRoleCreate) Save(ctx context.Context) (*UserRole, error) { - return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) -} - -// SaveX calls Save and panics if Save returns an error. -func (_c *UserRoleCreate) SaveX(ctx context.Context) *UserRole { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *UserRoleCreate) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *UserRoleCreate) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_c *UserRoleCreate) check() error { - if _, ok := _c.mutation.UserID(); !ok { - return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UserRole.user_id"`)} - } - if _, ok := _c.mutation.RoleID(); !ok { - return &ValidationError{Name: "role_id", err: errors.New(`ent: missing required field "UserRole.role_id"`)} - } - if len(_c.mutation.UserIDs()) == 0 { - return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UserRole.user"`)} - } - if len(_c.mutation.RoleIDs()) == 0 { - return &ValidationError{Name: "role", err: errors.New(`ent: missing required edge "UserRole.role"`)} - } - return nil -} - -func (_c *UserRoleCreate) sqlSave(ctx context.Context) (*UserRole, error) { - if err := _c.check(); err != nil { - return nil, err - } - _node, _spec := _c.createSpec() - if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - id := _spec.ID.Value.(int64) - _node.ID = int(id) - _c.mutation.id = &_node.ID - _c.mutation.done = true - return _node, nil -} - -func (_c *UserRoleCreate) createSpec() (*UserRole, *sqlgraph.CreateSpec) { - var ( - _node = &UserRole{config: _c.config} - _spec = sqlgraph.NewCreateSpec(userrole.Table, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) - ) - if nodes := _c.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: userrole.UserTable, - Columns: []string{userrole.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.UserID = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.RoleIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: userrole.RoleTable, - Columns: []string{userrole.RoleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _node.RoleID = nodes[0] - _spec.Edges = append(_spec.Edges, edge) - } - return _node, _spec -} - -// SetUserRole set the UserRole -func (_c *UserRoleCreate) SetUserRole(input *UserRole, fields ...string) *UserRoleCreate { - m := _c.mutation - if len(fields) == 0 { - fields = userrole.Columns - } - _ = m.SetFields(input, fields...) - return _c -} - -// SetUserRoleWithZero set the UserRole -func (_c *UserRoleCreate) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleCreate { - m := _c.mutation - if len(fields) == 0 { - fields = userrole.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return _c -} - -// UserRoleCreateBulk is the builder for creating many UserRole entities in bulk. -type UserRoleCreateBulk struct { - config - err error - builders []*UserRoleCreate -} - -// Save creates the UserRole entities in the database. -func (_c *UserRoleCreateBulk) Save(ctx context.Context) ([]*UserRole, error) { - if _c.err != nil { - return nil, _c.err - } - specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) - nodes := make([]*UserRole, len(_c.builders)) - mutators := make([]Mutator, len(_c.builders)) - for i := range _c.builders { - func(i int, root context.Context) { - builder := _c.builders[i] - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*UserRoleMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err := builder.check(); err != nil { - return nil, err - } - builder.mutation = mutation - var err error - nodes[i], specs[i] = builder.createSpec() - if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) - } else { - spec := &sqlgraph.BatchCreateSpec{Nodes: specs} - // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { - if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - } - } - if err != nil { - return nil, err - } - mutation.id = &nodes[i].ID - if specs[i].ID.Value != nil { - id := specs[i].ID.Value.(int64) - nodes[i].ID = int(id) - } - mutation.done = true - return nodes[i], nil - }) - for i := len(builder.hooks) - 1; i >= 0; i-- { - mut = builder.hooks[i](mut) - } - mutators[i] = mut - }(i, ctx) - } - if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { - return nil, err - } - } - return nodes, nil -} - -// SaveX is like Save, but panics if an error occurs. -func (_c *UserRoleCreateBulk) SaveX(ctx context.Context) []*UserRole { - v, err := _c.Save(ctx) - if err != nil { - panic(err) - } - return v -} - -// Exec executes the query. -func (_c *UserRoleCreateBulk) Exec(ctx context.Context) error { - _, err := _c.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_c *UserRoleCreateBulk) ExecX(ctx context.Context) { - if err := _c.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/userrole_delete.go b/internal/features/system/data/ent/userrole_delete.go deleted file mode 100644 index c81494d8..00000000 --- a/internal/features/system/data/ent/userrole_delete.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// UserRoleDelete is the builder for deleting a UserRole entity. -type UserRoleDelete struct { - config - hooks []Hook - mutation *UserRoleMutation -} - -// Where appends a list predicates to the UserRoleDelete builder. -func (_d *UserRoleDelete) Where(ps ...predicate.UserRole) *UserRoleDelete { - _d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query and returns how many vertices were deleted. -func (_d *UserRoleDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *UserRoleDelete) ExecX(ctx context.Context) int { - n, err := _d.Exec(ctx) - if err != nil { - panic(err) - } - return n -} - -func (_d *UserRoleDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(userrole.Table, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) - if ps := _d.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) - if err != nil && sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - _d.mutation.done = true - return affected, err -} - -// UserRoleDeleteOne is the builder for deleting a single UserRole entity. -type UserRoleDeleteOne struct { - _d *UserRoleDelete -} - -// Where appends a list predicates to the UserRoleDelete builder. -func (_d *UserRoleDeleteOne) Where(ps ...predicate.UserRole) *UserRoleDeleteOne { - _d._d.mutation.Where(ps...) - return _d -} - -// Exec executes the deletion query. -func (_d *UserRoleDeleteOne) Exec(ctx context.Context) error { - n, err := _d._d.Exec(ctx) - switch { - case err != nil: - return err - case n == 0: - return &NotFoundError{userrole.Label} - default: - return nil - } -} - -// ExecX is like Exec, but panics if an error occurs. -func (_d *UserRoleDeleteOne) ExecX(ctx context.Context) { - if err := _d.Exec(ctx); err != nil { - panic(err) - } -} diff --git a/internal/features/system/data/ent/userrole_query.go b/internal/features/system/data/ent/userrole_query.go deleted file mode 100644 index 15534ede..00000000 --- a/internal/features/system/data/ent/userrole_query.go +++ /dev/null @@ -1,763 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "fmt" - "math" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - - "entgo.io/ent" - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// UserRoleQuery is the builder for querying UserRole entities. -type UserRoleQuery struct { - config - ctx *QueryContext - order []userrole.OrderOption - inters []Interceptor - predicates []predicate.UserRole - withUser *UserQuery - withRole *RoleQuery - modifiers []func(*sql.Selector) - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) -} - -// Where adds a new predicate for the UserRoleQuery builder. -func (_q *UserRoleQuery) Where(ps ...predicate.UserRole) *UserRoleQuery { - _q.predicates = append(_q.predicates, ps...) - return _q -} - -// Limit the number of records to be returned by this query. -func (_q *UserRoleQuery) Limit(limit int) *UserRoleQuery { - _q.ctx.Limit = &limit - return _q -} - -// Offset to start from. -func (_q *UserRoleQuery) Offset(offset int) *UserRoleQuery { - _q.ctx.Offset = &offset - return _q -} - -// Unique configures the query builder to filter duplicate records on query. -// By default, unique is set to true, and can be disabled using this method. -func (_q *UserRoleQuery) Unique(unique bool) *UserRoleQuery { - _q.ctx.Unique = &unique - return _q -} - -// Order specifies how the records should be ordered. -func (_q *UserRoleQuery) Order(o ...userrole.OrderOption) *UserRoleQuery { - _q.order = append(_q.order, o...) - return _q -} - -// QueryUser chains the current query on the "user" edge. -func (_q *UserRoleQuery) QueryUser() *UserQuery { - query := (&UserClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(userrole.Table, userrole.FieldID, selector), - sqlgraph.To(user.Table, user.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, userrole.UserTable, userrole.UserColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryRole chains the current query on the "role" edge. -func (_q *UserRoleQuery) QueryRole() *RoleQuery { - query := (&RoleClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(userrole.Table, userrole.FieldID, selector), - sqlgraph.To(role.Table, role.FieldID), - sqlgraph.Edge(sqlgraph.M2O, false, userrole.RoleTable, userrole.RoleColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// First returns the first UserRole entity from the query. -// Returns a *NotFoundError when no UserRole was found. -func (_q *UserRoleQuery) First(ctx context.Context) (*UserRole, error) { - nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) - if err != nil { - return nil, err - } - if len(nodes) == 0 { - return nil, &NotFoundError{userrole.Label} - } - return nodes[0], nil -} - -// FirstX is like First, but panics if an error occurs. -func (_q *UserRoleQuery) FirstX(ctx context.Context) *UserRole { - node, err := _q.First(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return node -} - -// FirstID returns the first UserRole ID from the query. -// Returns a *NotFoundError when no UserRole ID was found. -func (_q *UserRoleQuery) FirstID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { - return - } - if len(ids) == 0 { - err = &NotFoundError{userrole.Label} - return - } - return ids[0], nil -} - -// FirstIDX is like FirstID, but panics if an error occurs. -func (_q *UserRoleQuery) FirstIDX(ctx context.Context) int { - id, err := _q.FirstID(ctx) - if err != nil && !IsNotFound(err) { - panic(err) - } - return id -} - -// Only returns a single UserRole entity found by the query, ensuring it only returns one. -// Returns a *NotSingularError when more than one UserRole entity is found. -// Returns a *NotFoundError when no UserRole entities are found. -func (_q *UserRoleQuery) Only(ctx context.Context) (*UserRole, error) { - nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) - if err != nil { - return nil, err - } - switch len(nodes) { - case 1: - return nodes[0], nil - case 0: - return nil, &NotFoundError{userrole.Label} - default: - return nil, &NotSingularError{userrole.Label} - } -} - -// OnlyX is like Only, but panics if an error occurs. -func (_q *UserRoleQuery) OnlyX(ctx context.Context) *UserRole { - node, err := _q.Only(ctx) - if err != nil { - panic(err) - } - return node -} - -// OnlyID is like Only, but returns the only UserRole ID in the query. -// Returns a *NotSingularError when more than one UserRole ID is found. -// Returns a *NotFoundError when no entities are found. -func (_q *UserRoleQuery) OnlyID(ctx context.Context) (id int, err error) { - var ids []int - if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { - return - } - switch len(ids) { - case 1: - id = ids[0] - case 0: - err = &NotFoundError{userrole.Label} - default: - err = &NotSingularError{userrole.Label} - } - return -} - -// OnlyIDX is like OnlyID, but panics if an error occurs. -func (_q *UserRoleQuery) OnlyIDX(ctx context.Context) int { - id, err := _q.OnlyID(ctx) - if err != nil { - panic(err) - } - return id -} - -// All executes the query and returns a list of UserRoles. -func (_q *UserRoleQuery) All(ctx context.Context) ([]*UserRole, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - qr := querierAll[[]*UserRole, *UserRoleQuery]() - return withInterceptors[[]*UserRole](ctx, _q, qr, _q.inters) -} - -// AllX is like All, but panics if an error occurs. -func (_q *UserRoleQuery) AllX(ctx context.Context) []*UserRole { - nodes, err := _q.All(ctx) - if err != nil { - panic(err) - } - return nodes -} - -// IDs executes the query and returns a list of UserRole IDs. -func (_q *UserRoleQuery) IDs(ctx context.Context) (ids []int, err error) { - if _q.ctx.Unique == nil && _q.path != nil { - _q.Unique(true) - } - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) - if err = _q.Select(userrole.FieldID).Scan(ctx, &ids); err != nil { - return nil, err - } - return ids, nil -} - -// IDsX is like IDs, but panics if an error occurs. -func (_q *UserRoleQuery) IDsX(ctx context.Context) []int { - ids, err := _q.IDs(ctx) - if err != nil { - panic(err) - } - return ids -} - -// Count returns the count of the given query. -func (_q *UserRoleQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) - if err := _q.prepareQuery(ctx); err != nil { - return 0, err - } - return withInterceptors[int](ctx, _q, querierCount[*UserRoleQuery](), _q.inters) -} - -// CountX is like Count, but panics if an error occurs. -func (_q *UserRoleQuery) CountX(ctx context.Context) int { - count, err := _q.Count(ctx) - if err != nil { - panic(err) - } - return count -} - -// Exist returns true if the query has elements in the graph. -func (_q *UserRoleQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) - switch _, err := _q.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - -// ExistX is like Exist, but panics if an error occurs. -func (_q *UserRoleQuery) ExistX(ctx context.Context) bool { - exist, err := _q.Exist(ctx) - if err != nil { - panic(err) - } - return exist -} - -// Clone returns a duplicate of the UserRoleQuery builder, including all associated steps. It can be -// used to prepare common query builders and use them differently after the clone is made. -func (_q *UserRoleQuery) Clone() *UserRoleQuery { - if _q == nil { - return nil - } - return &UserRoleQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]userrole.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.UserRole{}, _q.predicates...), - withUser: _q.withUser.Clone(), - withRole: _q.withRole.Clone(), - // clone intermediate query. - sql: _q.sql.Clone(), - path: _q.path, - modifiers: append([]func(*sql.Selector){}, _q.modifiers...), - } -} - -// WithUser tells the query-builder to eager-load the nodes that are connected to -// the "user" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *UserRoleQuery) WithUser(opts ...func(*UserQuery)) *UserRoleQuery { - query := (&UserClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withUser = query - return _q -} - -// WithRole tells the query-builder to eager-load the nodes that are connected to -// the "role" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *UserRoleQuery) WithRole(opts ...func(*RoleQuery)) *UserRoleQuery { - query := (&RoleClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withRole = query - return _q -} - -// GroupBy is used to group vertices by one or more fields/columns. -// It is often used with aggregate functions, like: count, max, mean, min, sum. -// -// Example: -// -// var v []struct { -// UserID int64 `json:"user_id,omitempty"` -// Count int `json:"count,omitempty"` -// } -// -// client.UserRole.Query(). -// GroupBy(userrole.FieldUserID). -// Aggregate(ent.Count()). -// Scan(ctx, &v) -func (_q *UserRoleQuery) GroupBy(field string, fields ...string) *UserRoleGroupBy { - _q.ctx.Fields = append([]string{field}, fields...) - grbuild := &UserRoleGroupBy{build: _q} - grbuild.flds = &_q.ctx.Fields - grbuild.label = userrole.Label - grbuild.scan = grbuild.Scan - return grbuild -} - -// Select allows the selection one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// -// Example: -// -// var v []struct { -// UserID int64 `json:"user_id,omitempty"` -// } -// -// client.UserRole.Query(). -// Select(userrole.FieldUserID). -// Scan(ctx, &v) -func (_q *UserRoleQuery) Select(fields ...string) *UserRoleSelect { - _q.ctx.Fields = append(_q.ctx.Fields, fields...) - sbuild := &UserRoleSelect{UserRoleQuery: _q} - sbuild.label = userrole.Label - sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan - return sbuild -} - -// Aggregate returns a UserRoleSelect configured with the given aggregations. -func (_q *UserRoleQuery) Aggregate(fns ...AggregateFunc) *UserRoleSelect { - return _q.Select().Aggregate(fns...) -} - -func (_q *UserRoleQuery) prepareQuery(ctx context.Context) error { - for _, inter := range _q.inters { - if inter == nil { - return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") - } - if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, _q); err != nil { - return err - } - } - } - for _, f := range _q.ctx.Fields { - if !userrole.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - } - if _q.path != nil { - prev, err := _q.path(ctx) - if err != nil { - return err - } - _q.sql = prev - } - return nil -} - -func (_q *UserRoleQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*UserRole, error) { - var ( - nodes = []*UserRole{} - _spec = _q.querySpec() - loadedTypes = [2]bool{ - _q.withUser != nil, - _q.withRole != nil, - } - ) - _spec.ScanValues = func(columns []string) ([]any, error) { - return (*UserRole).scanValues(nil, columns) - } - _spec.Assign = func(columns []string, values []any) error { - node := &UserRole{config: _q.config} - nodes = append(nodes, node) - node.Edges.loadedTypes = loadedTypes - return node.assignValues(columns, values) - } - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - for i := range hooks { - hooks[i](ctx, _spec) - } - if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { - return nil, err - } - if len(nodes) == 0 { - return nodes, nil - } - if query := _q.withUser; query != nil { - if err := _q.loadUser(ctx, query, nodes, nil, - func(n *UserRole, e *User) { n.Edges.User = e }); err != nil { - return nil, err - } - } - if query := _q.withRole; query != nil { - if err := _q.loadRole(ctx, query, nodes, nil, - func(n *UserRole, e *Role) { n.Edges.Role = e }); err != nil { - return nil, err - } - } - return nodes, nil -} - -func (_q *UserRoleQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*UserRole, init func(*UserRole), assign func(*UserRole, *User)) error { - ids := make([]int64, 0, len(nodes)) - nodeids := make(map[int64][]*UserRole) - for i := range nodes { - fk := nodes[i].UserID - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(user.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "user_id" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} -func (_q *UserRoleQuery) loadRole(ctx context.Context, query *RoleQuery, nodes []*UserRole, init func(*UserRole), assign func(*UserRole, *Role)) error { - ids := make([]int64, 0, len(nodes)) - nodeids := make(map[int64][]*UserRole) - for i := range nodes { - fk := nodes[i].RoleID - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(role.IDIn(ids...)) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - nodes, ok := nodeids[n.ID] - if !ok { - return fmt.Errorf(`unexpected foreign-key "role_id" returned %v`, n.ID) - } - for i := range nodes { - assign(nodes[i], n) - } - } - return nil -} - -func (_q *UserRoleQuery) sqlCount(ctx context.Context) (int, error) { - _spec := _q.querySpec() - if len(_q.modifiers) > 0 { - _spec.Modifiers = _q.modifiers - } - _spec.Node.Columns = _q.ctx.Fields - if len(_q.ctx.Fields) > 0 { - _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique - } - return sqlgraph.CountNodes(ctx, _q.driver, _spec) -} - -func (_q *UserRoleQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(userrole.Table, userrole.Columns, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) - _spec.From = _q.sql - if unique := _q.ctx.Unique; unique != nil { - _spec.Unique = *unique - } else if _q.path != nil { - _spec.Unique = true - } - if fields := _q.ctx.Fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, userrole.FieldID) - for i := range fields { - if fields[i] != userrole.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) - } - } - if _q.withUser != nil { - _spec.Node.AddColumnOnce(userrole.FieldUserID) - } - if _q.withRole != nil { - _spec.Node.AddColumnOnce(userrole.FieldRoleID) - } - } - if ps := _q.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if limit := _q.ctx.Limit; limit != nil { - _spec.Limit = *limit - } - if offset := _q.ctx.Offset; offset != nil { - _spec.Offset = *offset - } - if ps := _q.order; len(ps) > 0 { - _spec.Order = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - return _spec -} - -func (_q *UserRoleQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(_q.driver.Dialect()) - t1 := builder.Table(userrole.Table) - columns := _q.ctx.Fields - if len(columns) == 0 { - columns = userrole.Columns - } - selector := builder.Select(t1.Columns(columns...)...).From(t1) - if _q.sql != nil { - selector = _q.sql - selector.Select(selector.Columns(columns...)...) - } - if _q.ctx.Unique != nil && *_q.ctx.Unique { - selector.Distinct() - } - for _, m := range _q.modifiers { - m(selector) - } - for _, p := range _q.predicates { - p(selector) - } - for _, p := range _q.order { - p(selector) - } - if offset := _q.ctx.Offset; offset != nil { - // limit is mandatory for offset clause. We start - // with default value, and override it below if needed. - selector.Offset(*offset).Limit(math.MaxInt32) - } - if limit := _q.ctx.Limit; limit != nil { - selector.Limit(*limit) - } - return selector -} - -// ForUpdate locks the selected rows against concurrent updates, and prevent them from being -// updated, deleted or "selected ... for update" by other sessions, until the transaction is -// either committed or rolled-back. -func (_q *UserRoleQuery) ForUpdate(opts ...sql.LockOption) *UserRoleQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForUpdate(opts...) - }) - return _q -} - -// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock -// on any rows that are read. Other sessions can read the rows, but cannot modify them -// until your transaction commits. -func (_q *UserRoleQuery) ForShare(opts ...sql.LockOption) *UserRoleQuery { - if _q.driver.Dialect() == dialect.Postgres { - _q.Unique(false) - } - _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { - s.ForShare(opts...) - }) - return _q -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_q *UserRoleQuery) Modify(modifiers ...func(s *sql.Selector)) *UserRoleSelect { - _q.modifiers = append(_q.modifiers, modifiers...) - return _q.Select() -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -// Example: -// -// var v []struct { -// UserID int64 `json:"user_id,omitempty"` -// RoleID int64 `json:"role_id,omitempty"` -// } -// -// client.UserRole.Query(). -// Omit( -// userrole.FieldUserID, -// userrole.FieldRoleID, -// ). -// Scan(ctx, &v) -func (urq *UserRoleQuery) Omit(fields ...string) *UserRoleSelect { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - for _, col := range userrole.Columns { - if _, ok := omits[col]; !ok { - urq.ctx.Fields = append(urq.ctx.Fields, col) - } - } - - sbuild := &UserRoleSelect{UserRoleQuery: urq} - sbuild.label = userrole.Label - sbuild.flds, sbuild.scan = &urq.ctx.Fields, sbuild.Scan - return sbuild -} - -// UserRoleGroupBy is the group-by builder for UserRole entities. -type UserRoleGroupBy struct { - selector - build *UserRoleQuery -} - -// Aggregate adds the given aggregation functions to the group-by query. -func (_g *UserRoleGroupBy) Aggregate(fns ...AggregateFunc) *UserRoleGroupBy { - _g.fns = append(_g.fns, fns...) - return _g -} - -// Scan applies the selector query and scans the result into the given value. -func (_g *UserRoleGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) - if err := _g.build.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*UserRoleQuery, *UserRoleGroupBy](ctx, _g.build, _g, _g.build.inters, v) -} - -func (_g *UserRoleGroupBy) sqlScan(ctx context.Context, root *UserRoleQuery, v any) error { - selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(_g.fns)) - for _, fn := range _g.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) - for _, f := range *_g.flds { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - selector.GroupBy(selector.Columns(*_g.flds...)...) - if err := selector.Err(); err != nil { - return err - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// UserRoleSelect is the builder for selecting fields of UserRole entities. -type UserRoleSelect struct { - *UserRoleQuery - selector -} - -// Aggregate adds the given aggregation functions to the selector query. -func (_s *UserRoleSelect) Aggregate(fns ...AggregateFunc) *UserRoleSelect { - _s.fns = append(_s.fns, fns...) - return _s -} - -// Scan applies the selector query and scans the result into the given value. -func (_s *UserRoleSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) - if err := _s.prepareQuery(ctx); err != nil { - return err - } - return scanWithInterceptors[*UserRoleQuery, *UserRoleSelect](ctx, _s.UserRoleQuery, _s, _s.inters, v) -} - -func (_s *UserRoleSelect) sqlScan(ctx context.Context, root *UserRoleQuery, v any) error { - selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(_s.fns)) - for _, fn := range _s.fns { - aggregation = append(aggregation, fn(selector)) - } - switch n := len(*_s.selector.flds); { - case n == 0 && len(aggregation) > 0: - selector.Select(aggregation...) - case n != 0 && len(aggregation) > 0: - selector.AppendSelect(aggregation...) - } - rows := &sql.Rows{} - query, args := selector.Query() - if err := _s.driver.Query(ctx, query, args, rows); err != nil { - return err - } - defer rows.Close() - return sql.ScanSlice(rows, v) -} - -// Modify adds a query modifier for attaching custom logic to queries. -func (_s *UserRoleSelect) Modify(modifiers ...func(s *sql.Selector)) *UserRoleSelect { - _s.modifiers = append(_s.modifiers, modifiers...) - return _s -} diff --git a/internal/features/system/data/ent/userrole_update.go b/internal/features/system/data/ent/userrole_update.go deleted file mode 100644 index c8e54ad8..00000000 --- a/internal/features/system/data/ent/userrole_update.go +++ /dev/null @@ -1,493 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" - "errors" - "fmt" - "origadmin/application/admin/internal/features/system/data/ent/predicate" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/data/ent/userrole" - - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" - "entgo.io/ent/schema/field" -) - -// UserRoleUpdate is the builder for updating UserRole entities. -type UserRoleUpdate struct { - config - hooks []Hook - mutation *UserRoleMutation - modifiers []func(*sql.UpdateBuilder) -} - -// Where appends a list predicates to the UserRoleUpdate builder. -func (_u *UserRoleUpdate) Where(ps ...predicate.UserRole) *UserRoleUpdate { - _u.mutation.Where(ps...) - return _u -} - -// SetUserID sets the "user_id" field. -func (_u *UserRoleUpdate) SetUserID(v int64) *UserRoleUpdate { - _u.mutation.SetUserID(v) - return _u -} - -// SetNillableUserID sets the "user_id" field if the given value is not nil. -func (_u *UserRoleUpdate) SetNillableUserID(v *int64) *UserRoleUpdate { - if v != nil { - _u.SetUserID(*v) - } - return _u -} - -// SetRoleID sets the "role_id" field. -func (_u *UserRoleUpdate) SetRoleID(v int64) *UserRoleUpdate { - _u.mutation.SetRoleID(v) - return _u -} - -// SetNillableRoleID sets the "role_id" field if the given value is not nil. -func (_u *UserRoleUpdate) SetNillableRoleID(v *int64) *UserRoleUpdate { - if v != nil { - _u.SetRoleID(*v) - } - return _u -} - -// SetUser sets the "user" edge to the User entity. -func (_u *UserRoleUpdate) SetUser(v *User) *UserRoleUpdate { - return _u.SetUserID(v.ID) -} - -// SetRole sets the "role" edge to the Role entity. -func (_u *UserRoleUpdate) SetRole(v *Role) *UserRoleUpdate { - return _u.SetRoleID(v.ID) -} - -// Mutation returns the UserRoleMutation object of the builder. -func (_u *UserRoleUpdate) Mutation() *UserRoleMutation { - return _u.mutation -} - -// ClearUser clears the "user" edge to the User entity. -func (_u *UserRoleUpdate) ClearUser() *UserRoleUpdate { - _u.mutation.ClearUser() - return _u -} - -// ClearRole clears the "role" edge to the Role entity. -func (_u *UserRoleUpdate) ClearRole() *UserRoleUpdate { - _u.mutation.ClearRole() - return _u -} - -// Save executes the query and returns the number of nodes affected by the update operation. -func (_u *UserRoleUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *UserRoleUpdate) SaveX(ctx context.Context) int { - affected, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return affected -} - -// Exec executes the query. -func (_u *UserRoleUpdate) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *UserRoleUpdate) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *UserRoleUpdate) check() error { - if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "UserRole.user"`) - } - if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "UserRole.role"`) - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *UserRoleUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserRoleUpdate { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *UserRoleUpdate) sqlSave(ctx context.Context) (_node int, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(userrole.Table, userrole.Columns, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if _u.mutation.UserCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: userrole.UserTable, - Columns: []string{userrole.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: userrole.UserTable, - Columns: []string{userrole.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.RoleCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: userrole.RoleTable, - Columns: []string{userrole.RoleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: userrole.RoleTable, - Columns: []string{userrole.RoleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{userrole.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return 0, err - } - _u.mutation.done = true - return _node, nil -} - -// UserRoleUpdateOne is the builder for updating a single UserRole entity. -type UserRoleUpdateOne struct { - config - fields []string - hooks []Hook - mutation *UserRoleMutation - modifiers []func(*sql.UpdateBuilder) -} - -// SetUserID sets the "user_id" field. -func (_u *UserRoleUpdateOne) SetUserID(v int64) *UserRoleUpdateOne { - _u.mutation.SetUserID(v) - return _u -} - -// SetNillableUserID sets the "user_id" field if the given value is not nil. -func (_u *UserRoleUpdateOne) SetNillableUserID(v *int64) *UserRoleUpdateOne { - if v != nil { - _u.SetUserID(*v) - } - return _u -} - -// SetRoleID sets the "role_id" field. -func (_u *UserRoleUpdateOne) SetRoleID(v int64) *UserRoleUpdateOne { - _u.mutation.SetRoleID(v) - return _u -} - -// SetNillableRoleID sets the "role_id" field if the given value is not nil. -func (_u *UserRoleUpdateOne) SetNillableRoleID(v *int64) *UserRoleUpdateOne { - if v != nil { - _u.SetRoleID(*v) - } - return _u -} - -// SetUser sets the "user" edge to the User entity. -func (_u *UserRoleUpdateOne) SetUser(v *User) *UserRoleUpdateOne { - return _u.SetUserID(v.ID) -} - -// SetRole sets the "role" edge to the Role entity. -func (_u *UserRoleUpdateOne) SetRole(v *Role) *UserRoleUpdateOne { - return _u.SetRoleID(v.ID) -} - -// Mutation returns the UserRoleMutation object of the builder. -func (_u *UserRoleUpdateOne) Mutation() *UserRoleMutation { - return _u.mutation -} - -// ClearUser clears the "user" edge to the User entity. -func (_u *UserRoleUpdateOne) ClearUser() *UserRoleUpdateOne { - _u.mutation.ClearUser() - return _u -} - -// ClearRole clears the "role" edge to the Role entity. -func (_u *UserRoleUpdateOne) ClearRole() *UserRoleUpdateOne { - _u.mutation.ClearRole() - return _u -} - -// Where appends a list predicates to the UserRoleUpdate builder. -func (_u *UserRoleUpdateOne) Where(ps ...predicate.UserRole) *UserRoleUpdateOne { - _u.mutation.Where(ps...) - return _u -} - -// Select allows selecting one or more fields (columns) of the returned entity. -// The default is selecting all fields defined in the entity schema. -func (_u *UserRoleUpdateOne) Select(field string, fields ...string) *UserRoleUpdateOne { - _u.fields = append([]string{field}, fields...) - return _u -} - -// Save executes the query and returns the updated UserRole entity. -func (_u *UserRoleUpdateOne) Save(ctx context.Context) (*UserRole, error) { - return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) -} - -// SaveX is like Save, but panics if an error occurs. -func (_u *UserRoleUpdateOne) SaveX(ctx context.Context) *UserRole { - node, err := _u.Save(ctx) - if err != nil { - panic(err) - } - return node -} - -// Exec executes the query on the entity. -func (_u *UserRoleUpdateOne) Exec(ctx context.Context) error { - _, err := _u.Save(ctx) - return err -} - -// ExecX is like Exec, but panics if an error occurs. -func (_u *UserRoleUpdateOne) ExecX(ctx context.Context) { - if err := _u.Exec(ctx); err != nil { - panic(err) - } -} - -// check runs all checks and user-defined validators on the builder. -func (_u *UserRoleUpdateOne) check() error { - if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "UserRole.user"`) - } - if _u.mutation.RoleCleared() && len(_u.mutation.RoleIDs()) > 0 { - return errors.New(`ent: clearing a required unique edge "UserRole.role"`) - } - return nil -} - -// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. -func (_u *UserRoleUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *UserRoleUpdateOne { - _u.modifiers = append(_u.modifiers, modifiers...) - return _u -} - -func (_u *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, err error) { - if err := _u.check(); err != nil { - return _node, err - } - _spec := sqlgraph.NewUpdateSpec(userrole.Table, userrole.Columns, sqlgraph.NewFieldSpec(userrole.FieldID, field.TypeInt)) - id, ok := _u.mutation.ID() - if !ok { - return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UserRole.id" for update`)} - } - _spec.Node.ID.Value = id - if fields := _u.fields; len(fields) > 0 { - _spec.Node.Columns = make([]string, 0, len(fields)) - _spec.Node.Columns = append(_spec.Node.Columns, userrole.FieldID) - for _, f := range fields { - if !userrole.ValidColumn(f) { - return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} - } - if f != userrole.FieldID { - _spec.Node.Columns = append(_spec.Node.Columns, f) - } - } - } - if ps := _u.mutation.predicates; len(ps) > 0 { - _spec.Predicate = func(selector *sql.Selector) { - for i := range ps { - ps[i](selector) - } - } - } - if _u.mutation.UserCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: userrole.UserTable, - Columns: []string{userrole.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.UserIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: userrole.UserTable, - Columns: []string{userrole.UserColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.RoleCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: userrole.RoleTable, - Columns: []string{userrole.RoleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RoleIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: false, - Table: userrole.RoleTable, - Columns: []string{userrole.RoleColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(role.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - _spec.AddModifiers(_u.modifiers...) - _node = &UserRole{config: _u.config} - _spec.Assign = _node.assignValues - _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { - if _, ok := err.(*sqlgraph.NotFoundError); ok { - err = &NotFoundError{userrole.Label} - } else if sqlgraph.IsConstraintError(err) { - err = &ConstraintError{msg: err.Error(), wrap: err} - } - return nil, err - } - _u.mutation.done = true - return _node, nil -} - -// SetUserRole set the UserRole -func (uru *UserRoleUpdate) SetUserRole(input *UserRole, fields ...string) *UserRoleUpdate { - m := uru.mutation - if len(fields) == 0 { - fields = userrole.OmitColumns(userrole.FieldID) - } - _ = m.SetFields(input, fields...) - return uru -} - -// SetUserRoleWithZero set the UserRole -func (uru *UserRoleUpdate) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleUpdate { - m := uru.mutation - if len(fields) == 0 { - fields = userrole.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return uru -} - -// SetUserRole set the UserRole -func (uruo *UserRoleUpdateOne) SetUserRole(input *UserRole, fields ...string) *UserRoleUpdateOne { - m := uruo.mutation - if len(fields) == 0 { - fields = userrole.OmitColumns(userrole.FieldID) - } - _ = m.SetFields(input, fields...) - return uruo -} - -// SetUserRoleWithZero set the UserRole -func (uruo *UserRoleUpdateOne) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleUpdateOne { - m := uruo.mutation - if len(fields) == 0 { - fields = userrole.Columns - } - _ = m.SetFieldsWithZero(input, fields...) - return uruo -} - -// Omit allows the unselect one or more fields/columns for the given query, -// instead of selecting all fields in the entity. -func (uruo *UserRoleUpdateOne) Omit(fields ...string) *UserRoleUpdateOne { - omits := make(map[string]struct{}, len(fields)) - for i := range fields { - omits[fields[i]] = struct{}{} - } - uruo.fields = []string(nil) - for _, col := range userrole.Columns { - if _, ok := omits[col]; !ok { - uruo.fields = append(uruo.fields, col) - } - } - return uruo -} diff --git a/internal/features/system/data/permission.go b/internal/features/system/data/permission.go deleted file mode 100644 index f57794a4..00000000 --- a/internal/features/system/data/permission.go +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package data - -import ( - "context" - - "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/features/system/data/ent" - "origadmin/application/admin/internal/features/system/data/ent/permission" - "origadmin/application/admin/internal/features/system/dto" -) - -type permissionRepo struct { - db *ent.Client -} - -func (repo *permissionRepo) Get(ctx context.Context, id int64, options ...dto.PermissionQueryOption) (*types.Permission, error) { - result, err := repo.db.Permission.Get(ctx, (id)) - if err != nil { - return nil, err - } - return dto.ConvertPermissionToPermissionPB(result), nil -} - -func (repo *permissionRepo) Create(ctx context.Context, p *types.Permission, options ...dto.PermissionQueryOption) (*types.Permission, error) { - create := repo.db.Permission.Create(). - SetName(p.Name) - - if len(p.ResourceIds) > 0 { - create.AddResourceIDs(p.ResourceIds...) - } - - // ... set other fields - - saved, err := create.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertPermissionToPermissionPB(saved), nil -} - -func (repo *permissionRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Permission.DeleteOneID((id)).Exec(ctx) -} - -func (repo *permissionRepo) Update(ctx context.Context, p *types.Permission, options ...dto.PermissionQueryOption) (*types.Permission, error) { - update := repo.db.Permission.UpdateOneID((p.Id)) - - if len(p.ResourceIds) > 0 { - update.ClearResources().AddResourceIDs(p.ResourceIds...) - } - - // ... set other fields - - saved, err := update.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertPermissionToPermissionPB(saved), nil -} - -func (repo *permissionRepo) List(ctx context.Context, in *system.ListPermissionsRequest, options ...dto.PermissionQueryOption) ([]*types.Permission, int32, error) { - query := repo.db.Permission.Query() - - if len(in.DataScopes) > 0 { - query = query.Where(permission.DataScopeIn(in.DataScopes...)) - } - - if in.OnlyCount { - count, err := query.Count(ctx) - return nil, int32(count), err - } - - count, err := query.Clone().Count(ctx) - if err != nil { - return nil, 0, err - } - - //query = db.QueryPage(query, in) - - result, err := query.All(ctx) - return dto.ConvertPermissionsToPermissionsPB(result), int32(count), err -} - -// NewPermissionRepo . -func NewPermissionRepo(d *Data) (dto.PermissionRepo, error) { - return &permissionRepo{db: d.db}, nil -} diff --git a/internal/features/system/data/provider.go b/internal/features/system/data/provider.go deleted file mode 100644 index 436a1c2a..00000000 --- a/internal/features/system/data/provider.go +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package data implements the functions, types, and interfaces for the module. -package data - -import ( - "origadmin/application/admin/internal/features/system/dto" -) - -// Repositories is a collection of all repositories. -type Repositories struct { - ResourceRepo dto.ResourceRepo - RoleRepo dto.RoleRepo - UserRepo dto.UserRepo - PermissionRepo dto.PermissionRepo -} - -// NewRepositories creates a new Repositories instance. -func NewRepositories( - resourceRepo dto.ResourceRepo, - roleRepo dto.RoleRepo, - userRepo dto.UserRepo, - permissionRepo dto.PermissionRepo, -) (*Repositories, error) { - return &Repositories{ - ResourceRepo: resourceRepo, - RoleRepo: roleRepo, - UserRepo: userRepo, - PermissionRepo: permissionRepo, - }, nil -} diff --git a/internal/features/system/data/resource.go b/internal/features/system/data/resource.go deleted file mode 100644 index d8251264..00000000 --- a/internal/features/system/data/resource.go +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package data - -import ( - "context" - "strconv" - - "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/features/system/data/ent" - "origadmin/application/admin/internal/features/system/dto" -) - -type resourceRepo struct { - db *ent.Client - Delimiter string -} - -func (repo *resourceRepo) Get(ctx context.Context, id int64, options ...dto.ResourceQueryOption) (*types.Resource, error) { - result, err := repo.db.Resource.Get(ctx, (id)) - if err != nil { - return nil, err - } - return dto.ConvertResourceToResourcePB(result), nil -} - -func (repo *resourceRepo) Create(ctx context.Context, r *types.Resource, options ...dto.ResourceQueryOption) (*types.Resource, error) { - if r.ParentId > 0 { - parent, err := repo.db.Resource.Get(ctx, r.ParentId) - if err != nil { - return nil, err - } - r.TreePath = parent.TreePath + strconv.Itoa(int(parent.ID)) + repo.Delimiter - } - - create := repo.db.Resource.Create(). - SetName(r.Name). - SetParentID(r.ParentId). - SetTreePath(r.TreePath) - - if len(r.PermissionIds) > 0 { - create.AddPermissionIDs(r.PermissionIds...) - } - - // ... set other fields - - saved, err := create.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResourceToResourcePB(saved), nil -} - -func (repo *resourceRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Resource.DeleteOneID(id).Exec(ctx) -} - -func (repo *resourceRepo) Update(ctx context.Context, r *types.Resource, options ...dto.ResourceQueryOption) (*types.Resource, error) { - update := repo.db.Resource.UpdateOneID(r.Id) - - if len(r.PermissionIds) > 0 { - update.ClearPermissions().AddPermissionIDs(r.PermissionIds...) - } - - // ... set other fields - - saved, err := update.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResourceToResourcePB(saved), nil -} - -func (repo *resourceRepo) List(ctx context.Context, in *system.ListResourcesRequest, options ...dto.ResourceQueryOption) ([]*types.Resource, int32, error) { - query := repo.db.Resource.Query() - - if in.OnlyCount { - count, err := query.Count(ctx) - return nil, int32(count), err - } - - count, err := query.Clone().Count(ctx) - if err != nil { - return nil, 0, err - } - - //query = db.QueryPage(query, in) - - result, err := query.All(ctx) - return dto.ConvertResourcesToResourcesPB(result), int32(count), err -} - -// NewResourceRepo . -func NewResourceRepo(d *Data) (dto.ResourceRepo, error) { - return &resourceRepo{ - db: d.db, - Delimiter: "/", - }, nil -} diff --git a/internal/features/system/data/role.go b/internal/features/system/data/role.go deleted file mode 100644 index 41bee718..00000000 --- a/internal/features/system/data/role.go +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package data is the data access object -package data - -import ( - "context" - "errors" - - "github.com/origadmin/toolkits/crypto/rand" - - "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/features/system/data/ent" - "origadmin/application/admin/internal/features/system/data/ent/role" - "origadmin/application/admin/internal/features/system/dto" -) - -type roleRepo struct { - gen rand.Generator - db *ent.Client -} - -func (repo *roleRepo) Get(ctx context.Context, id int64, options ...dto.RoleQueryOption) (*types.Role, error) { - result, err := repo.db.Role.Get(ctx, (id)) - if err != nil { - return nil, err - } - return dto.ConvertRoleToRolePB(result), nil -} - -func (repo *roleRepo) Create(ctx context.Context, r *types.Role, options ...dto.RoleUpdateOption) (*types.Role, error) { - if r.Keyword == "" { - randString, err := repo.gen.RandString(12) - if err != nil { - randString = "" - } - r.Keyword = "system:role:" + randString - } - exist, err := repo.db.Role.Query().Where(role.KeywordEqualFold(r.Keyword)).Exist(ctx) - if err != nil || exist { - return nil, errors.New("role keyword already exists") - } - - create := repo.db.Role.Create(). - SetName(r.Name). - SetKeyword(r.Keyword) - - saved, err := create.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertRoleToRolePB(saved), nil -} - -func (repo *roleRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Role.DeleteOneID((id)).Exec(ctx) -} - -func (repo *roleRepo) Update(ctx context.Context, r *types.Role, options ...dto.RoleUpdateOption) (*types.Role, error) { - update := repo.db.Role.UpdateOneID((r.Id)) - if len(r.PermissionIds) > 0 { - update.ClearPermissions().AddPermissionIDs(r.PermissionIds...) - } - - // ... set other fields - - saved, err := update.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertRoleToRolePB(saved), nil -} - -func (repo *roleRepo) List(ctx context.Context, in *system.ListRolesRequest, options ...dto.RoleQueryOption) ([]*types.Role, int32, error) { - query := repo.db.Role.Query() - - //if in.Name != nil { - // query = query.Where(role.NameContains(*in.Name)) - //} - //if in.Status != nil { - // query = query.Where(role.StatusEQ(*in.Status)) - //} - - if in.OnlyCount { - count, err := query.Count(ctx) - return nil, int32(count), err - } - - count, err := query.Clone().Count(ctx) - if err != nil { - return nil, 0, err - } - - //query = db.QueryPage(query, in) - - result, err := query.All(ctx) - return dto.ConvertRolesToRolesPB(result), int32(count), err -} - -// NewRoleRepo . -func NewRoleRepo(d *Data) (dto.RoleRepo, error) { - return &roleRepo{ - gen: rand.NewGenerator(rand.KindDigit | rand.KindLowerCase), - db: d.db, - }, nil -} diff --git a/internal/features/system/data/user.go b/internal/features/system/data/user.go deleted file mode 100644 index 78392ba6..00000000 --- a/internal/features/system/data/user.go +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package data is the data access object -package data - -import ( - "context" - "errors" - - "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/features/system/data/ent" - "origadmin/application/admin/internal/features/system/data/ent/user" - "origadmin/application/admin/internal/features/system/dto" -) - -type userRepo struct { - db *ent.Client -} - -func (repo *userRepo) Get(ctx context.Context, id int64, options ...dto.UserQueryOption) (*types.User, error) { - result, err := repo.db.User.Get(ctx, id) - if err != nil { - return nil, err - } - return dto.ConvertUserToUserPB(result), nil -} - -func (repo *userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*types.User, error) { - result, err := repo.db.User.Query().Where(user.UsernameEQ(username)).Only(ctx) - if err != nil { - return nil, err - } - return dto.ConvertUserToUserPB(result), nil -} - -func (repo *userRepo) Create(ctx context.Context, u *types.User, options ...dto.UserMutationOption) (*types.User, error) { - exist, err := repo.db.User.Query().Where(user.UsernameEQ(u.Username)).Exist(ctx) - if err != nil || exist { - return nil, errors.New("user already exists") - } - - create := repo.db.User.Create(). - SetUsername(u.Username). - SetPassword(u.Password) - - // ... set other fields - - saved, err := create.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertUserToUserPB(saved), nil -} - -func (repo *userRepo) Delete(ctx context.Context, id int64) error { - return repo.db.User.DeleteOneID(id).Exec(ctx) -} - -func (repo *userRepo) Update(ctx context.Context, u *types.User, options ...dto.UserMutationOption) (*types.User, error) { - update := repo.db.User.UpdateOneID(u.Id) - - if len(u.RoleIds) > 0 { - update.ClearRoles().AddRoleIDs(u.RoleIds...) - } - - // ... set other fields - - saved, err := update.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertUserToUserPB(saved), nil -} - -func (repo *userRepo) List(ctx context.Context, in *system.ListUsersRequest, options ...dto.UserQueryOption) ([]*types.User, int32, error) { - query := repo.db.User.Query() - - if in.Title != "" { - query = query.Where(user.Or(user.UsernameContainsFold(in.Title), user.PhoneContainsFold(in.Title), user.EmailContainsFold(in.Title))) - } - //if in.Status != nil { - // query = query.Where(user.StatusEQ(int8(*in.Status))) - //} - - if in.OnlyCount { - count, err := query.Count(ctx) - return nil, int32(count), err - } - - count, err := query.Clone().Count(ctx) - if err != nil { - return nil, 0, err - } - - //query = db.QueryPage(query, in) - - result, err := query.All(ctx) - return dto.ConvertUsersToUsersPB(result), int32(count), err -} - -func (repo *userRepo) AddRoleIDs(ctx context.Context, id int64, roleIDs []int64, options ...dto.UserMutationOption) error { - return repo.db.User.UpdateOneID(id).AddRoleIDs(roleIDs...).Exec(ctx) -} - -func (repo *userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { - ids, err := repo.db.User.Query().Where(user.ID(id)).QueryRoles().IDs(ctx) - if err != nil { - return nil, err - } - var result []int64 - for _, i := range ids { - result = append(result, int64(i)) - } - return result, nil -} - -func (repo *userRepo) ListResourceByUserID(ctx context.Context, id int64, options ...dto.UserQueryOption) ([]*types.Resource, error) { - resources, err := repo.db.User.Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResourcesToResourcesPB(resources), nil -} - -func (repo *userRepo) UpdateUserStatus(ctx context.Context, id int64, status int32, options ...dto.UserQueryOption) error { - return repo.db.User.UpdateOneID(id).SetStatus(int8(status)).Exec(ctx) -} - -func (repo *userRepo) Current(ctx context.Context, id int64) (*types.User, error) { - return repo.Get(ctx, id) -} - -// NewUserRepo . -func NewUserRepo(d *Data) (dto.UserRepo, error) { - return &userRepo{db: d.db}, nil -} diff --git a/internal/features/system/dto/custom.gen.go b/internal/features/system/dto/custom.gen.go index 3af06d81..263fb2d7 100644 --- a/internal/features/system/dto/custom.gen.go +++ b/internal/features/system/dto/custom.gen.go @@ -2,21 +2,3 @@ // More info: https://github.com/origadmin/abgen package dto - -import ( - "origadmin/application/admin/internal/features/system/data/ent/user" -) - -// ConvertGenderToString is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertGenderToString(from user.Gender) string { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} - -// ConvertStringToGender is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertStringToGender(from string) user.Gender { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index 5b62b93c..c3d4357e 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -1,5 +1,9 @@ package dto +import ( + "origadmin/application/admin/internal/data/entity/ent/user" +) + //go:generate go run github.com/origadmin/abgen/cmd/abgen -debug go run ./cmd/abgen -debug . //go:abgen:package:path=origadmin/application/admin/internal/features/system/data/ent,alias=ent @@ -8,3 +12,17 @@ package dto //go:abgen:convert:direction="both" //go:abgen:convert:source:suffix="" //go:abgen:convert:target:suffix="PB" + +// ConvertGenderToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertGenderToString(from user.Gender) string { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertStringToGender is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToGender(from string) user.Gender { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} diff --git a/internal/features/system/service/service.go b/internal/features/system/service/service.go index 719befb9..144e553c 100644 --- a/internal/features/system/service/service.go +++ b/internal/features/system/service/service.go @@ -15,10 +15,10 @@ type SystemService struct { system.UnimplementedUserServiceServer system.UnimplementedPermissionServiceServer - resource *biz.ResourceUseCase - role *biz.RoleUseCase - user *biz.UserUseCase - permission *biz.PermissionUseCase + Resource *biz.ResourceUseCase + Role *biz.RoleUseCase + User *biz.UserUseCase + Permission *biz.PermissionUseCase } func New( @@ -28,9 +28,9 @@ func New( permission *biz.PermissionUseCase, ) *SystemService { return &SystemService{ - resource: resource, - role: role, - user: user, - permission: permission, + Resource: resource, + Role: role, + User: user, + Permission: permission, } } diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index cf14d354..6fae4cc0 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -1152,6 +1152,11 @@ paths: description: The only_count is the query parameter for set only to query the total number schema: type: boolean + - name: keyword + in: query + description: The keyword is the query parameter for set only to query the department by keyword + schema: + type: string responses: "200": description: OK @@ -1325,6 +1330,11 @@ paths: description: The only_count is the query parameter for set only to query the total number schema: type: boolean + - name: keyword + in: query + description: The keyword is the query parameter for set only to query the menu by keyword + schema: + type: string responses: "200": description: OK @@ -1500,6 +1510,11 @@ paths: type: array items: type: string + - name: keyword + in: query + description: The keyword is the query parameter for set only to query the permission by keyword + schema: + type: string responses: "200": description: OK @@ -1673,6 +1688,11 @@ paths: description: The only_count is the query parameter for set only to query the total number schema: type: boolean + - name: keyword + in: query + description: The keyword is the query parameter for set only to query the position by keyword + schema: + type: string responses: "200": description: OK @@ -1851,6 +1871,11 @@ paths: description: resource type schema: type: string + - name: keyword + in: query + description: The resource name keyword + schema: + type: string responses: "200": description: OK @@ -2024,6 +2049,11 @@ paths: description: The only_count is the query parameter for set only to query the total number schema: type: boolean + - name: keyword + in: query + description: The keyword is the query parameter for set only to query the role by keyword + schema: + type: string responses: "200": description: OK @@ -2197,7 +2227,7 @@ paths: description: The only_count is the query parameter for set only to query the total number schema: type: boolean - - name: title + - name: keyword in: query description: The title query parameter for set only to query the title schema: From cc31a71e2c492aca58a70feb60bc46c6eea413a4 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 24 Dec 2025 19:00:54 +0800 Subject: [PATCH 072/158] refactor(system): consolidate PageLimiter usage and optimize DAL methods with query options --- cmd/system/wire.go | 5 +- internal/features/auth/biz/auth.biz.go | 2 +- internal/features/auth/biz/biz.go | 2 +- internal/features/auth/biz/casbin.biz.go | 2 +- internal/features/auth/biz/login.biz.go | 2 +- internal/features/auth/biz/personal.biz.go | 2 +- internal/features/auth/dto/auth.go | 2 +- internal/features/datastore/biz/biz.go | 2 +- internal/features/datastore/biz/datastore.go | 2 +- internal/features/datastore/dto/menu.go | 6 +- internal/features/datastore/dto/permission.go | 6 +- internal/features/datastore/dto/resource.go | 6 +- internal/features/datastore/dto/role.go | 6 +- internal/features/datastore/dto/user.go | 6 +- internal/features/system/dal/permission.go | 57 +++++++++++----- internal/features/system/dal/resource.go | 54 +++++++++------ internal/features/system/dal/role.go | 60 ++++++++++------- internal/features/system/dal/user.go | 65 +++++++++++-------- internal/features/system/dto/dto.go | 10 +++ internal/features/system/dto/permission.go | 28 +++++--- internal/features/system/dto/resource.go | 25 +++++-- internal/features/system/dto/role.go | 29 ++++++--- internal/features/system/dto/user.go | 41 +++++++----- internal/helpers/captcha/captcha.go | 2 +- internal/helpers/db/db.go | 2 +- internal/helpers/repo/query.go | 17 +++++ 26 files changed, 284 insertions(+), 157 deletions(-) create mode 100644 internal/helpers/repo/query.go diff --git a/cmd/system/wire.go b/cmd/system/wire.go index a019ac3c..7fecd230 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -35,12 +35,13 @@ func provideLogger(app *runtime.App) log.Logger { return app.Logger() } +var infraProviderSet = wire.NewSet(provideLogger, provideHasher) + // wireApp init kratos application. func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { panic(wire.Build( // The injector function's parameter `app` is an implicit provider for *runtime.App. - provideLogger, - provideHasher, + infraProviderSet, wire.FieldsOf(new(*conf.Config), "Bootstrap"), wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), data.ProviderSet, diff --git a/internal/features/auth/biz/auth.biz.go b/internal/features/auth/biz/auth.biz.go index 2f84015e..d4ef9459 100644 --- a/internal/features/auth/biz/auth.biz.go +++ b/internal/features/auth/biz/auth.biz.go @@ -19,7 +19,7 @@ import ( // AuthServiceBiz is a Auth use case. type AuthServiceBiz struct { dao dto.AuthRepo - limiter pagination.PageLimiter + limiter repo.PageLimiter log *log.KHelper } diff --git a/internal/features/auth/biz/biz.go b/internal/features/auth/biz/biz.go index 9ba4b24a..e7428ffe 100644 --- a/internal/features/auth/biz/biz.go +++ b/internal/features/auth/biz/biz.go @@ -9,7 +9,7 @@ import ( ) var ( - defaultLimiter = pagination.DefaultLimiter() + defaultLimiter = repo.DefaultLimiter() ) type UpdateHooker interface { diff --git a/internal/features/auth/biz/casbin.biz.go b/internal/features/auth/biz/casbin.biz.go index 7a35d17a..f1eae8f1 100644 --- a/internal/features/auth/biz/casbin.biz.go +++ b/internal/features/auth/biz/casbin.biz.go @@ -23,7 +23,7 @@ import ( // CasbinSourceServiceBiz is a CasbinSource use case. type CasbinSourceServiceBiz struct { dao dto.CasbinSourceRepo - limiter pagination.PageLimiter + limiter repo.PageLimiter log *log.KHelper lastModified *atomic.Int64 } diff --git a/internal/features/auth/biz/login.biz.go b/internal/features/auth/biz/login.biz.go index 07e5aeb2..b4cd87fa 100644 --- a/internal/features/auth/biz/login.biz.go +++ b/internal/features/auth/biz/login.biz.go @@ -20,7 +20,7 @@ import ( // LoginServiceBiz is a Login use case. type LoginServiceBiz struct { dao dto.LoginRepo - limiter pagination.PageLimiter + limiter repo.PageLimiter log *log.KHelper } diff --git a/internal/features/auth/biz/personal.biz.go b/internal/features/auth/biz/personal.biz.go index 9528e4dd..ee13f13d 100644 --- a/internal/features/auth/biz/personal.biz.go +++ b/internal/features/auth/biz/personal.biz.go @@ -20,7 +20,7 @@ import ( // PersonalServiceBiz is a Personal use case. type PersonalServiceBiz struct { dao dto.PersonalRepo - limiter pagination.PageLimiter + limiter repo.PageLimiter log *log.KHelper } diff --git a/internal/features/auth/dto/auth.go b/internal/features/auth/dto/auth.go index cc77dca7..d7bc1c55 100644 --- a/internal/features/auth/dto/auth.go +++ b/internal/features/auth/dto/auth.go @@ -35,7 +35,7 @@ type AuthResourceQueryOption struct { Fields []string } -func (o AuthResourceQueryOption) FromListRequest(in *ListAuthResourcesRequest, limiter pagination.PageLimiter) error { +func (o AuthResourceQueryOption) FromListRequest(in *ListAuthResourcesRequest, limiter repo.PageLimiter) error { in.Current = limiter.Current(in.Current) in.PageSize = limiter.PerPage(in.PageSize) return nil diff --git a/internal/features/datastore/biz/biz.go b/internal/features/datastore/biz/biz.go index 7c11317b..faa0f4e6 100644 --- a/internal/features/datastore/biz/biz.go +++ b/internal/features/datastore/biz/biz.go @@ -16,7 +16,7 @@ var ( ) var ( - defaultLimiter = pagination.PageLimiter{} + defaultLimiter = repo.PageLimiter{} ) type UpdateHooker interface { diff --git a/internal/features/datastore/biz/datastore.go b/internal/features/datastore/biz/datastore.go index ebfbcae5..6555fb25 100644 --- a/internal/features/datastore/biz/datastore.go +++ b/internal/features/datastore/biz/datastore.go @@ -19,7 +19,7 @@ import ( // PermissionServiceBiz is a PermissionPB use case. type PermissionServiceBiz struct { dao dto.PermissionRepo - limiter pagination.PageLimiter + limiter repo.PageLimiter log *log.KHelper } diff --git a/internal/features/datastore/dto/menu.go b/internal/features/datastore/dto/menu.go index 3542e0b6..0598d713 100644 --- a/internal/features/datastore/dto/menu.go +++ b/internal/features/datastore/dto/menu.go @@ -40,17 +40,17 @@ type MenuQueryOption struct { Fields []string } -func (o MenuQueryOption) FromListRequest(in *ListMenusRequest, limiter pagination.PageLimiter) error { +func (o MenuQueryOption) FromListRequest(in *ListMenusRequest, limiter repo.PageLimiter) error { in.Current = limiter.Current(in.Current) in.PageSize = limiter.PerPage(in.PageSize) return nil } -func (o MenuQueryOption) FromGetRequest(in *pb.GetMenuRequest, limiter pagination.PageLimiter) error { +func (o MenuQueryOption) FromGetRequest(in *pb.GetMenuRequest, limiter repo.PageLimiter) error { return nil } -func (o MenuQueryOption) FromCreateRequest(in *pb.CreateMenuRequest, limiter pagination.PageLimiter) error { +func (o MenuQueryOption) FromCreateRequest(in *pb.CreateMenuRequest, limiter repo.PageLimiter) error { return nil } diff --git a/internal/features/datastore/dto/permission.go b/internal/features/datastore/dto/permission.go index 0c9a1e63..a2f33a92 100644 --- a/internal/features/datastore/dto/permission.go +++ b/internal/features/datastore/dto/permission.go @@ -49,17 +49,17 @@ type PermissionQueryOption struct { IncludeRoles bool } -func (o PermissionQueryOption) FromListRequest(in *ListPermissionsRequest, limiter pagination.PageLimiter) error { +func (o PermissionQueryOption) FromListRequest(in *ListPermissionsRequest, limiter repo.PageLimiter) error { in.Current = limiter.Current(in.Current) in.PageSize = limiter.PerPage(in.PageSize) return nil } -func (o PermissionQueryOption) FromGetRequest(in *pb.GetPermissionRequest, limiter pagination.PageLimiter) error { +func (o PermissionQueryOption) FromGetRequest(in *pb.GetPermissionRequest, limiter repo.PageLimiter) error { return nil } -func (o PermissionQueryOption) FromCreateRequest(in *pb.CreatePermissionRequest, limiter pagination.PageLimiter) error { +func (o PermissionQueryOption) FromCreateRequest(in *pb.CreatePermissionRequest, limiter repo.PageLimiter) error { return nil } diff --git a/internal/features/datastore/dto/resource.go b/internal/features/datastore/dto/resource.go index 7ee531b0..9c082d97 100644 --- a/internal/features/datastore/dto/resource.go +++ b/internal/features/datastore/dto/resource.go @@ -49,17 +49,17 @@ type ResourceQueryOption struct { Fields []string } -func (o ResourceQueryOption) FromListRequest(in *ListResourcesRequest, limiter pagination.PageLimiter) error { +func (o ResourceQueryOption) FromListRequest(in *ListResourcesRequest, limiter repo.PageLimiter) error { in.Current = limiter.Current(in.Current) in.PageSize = limiter.PerPage(in.PageSize) return nil } -func (o ResourceQueryOption) FromGetRequest(in *pb.GetResourceRequest, limiter pagination.PageLimiter) error { +func (o ResourceQueryOption) FromGetRequest(in *pb.GetResourceRequest, limiter repo.PageLimiter) error { return nil } -func (o ResourceQueryOption) FromCreateRequest(in *pb.CreateResourceRequest, limiter pagination.PageLimiter) error { +func (o ResourceQueryOption) FromCreateRequest(in *pb.CreateResourceRequest, limiter repo.PageLimiter) error { return nil } diff --git a/internal/features/datastore/dto/role.go b/internal/features/datastore/dto/role.go index 061a07c9..0c8de645 100644 --- a/internal/features/datastore/dto/role.go +++ b/internal/features/datastore/dto/role.go @@ -47,17 +47,17 @@ type RoleQueryOption struct { IncludePermissions bool } -func (o RoleQueryOption) FromListRequest(in *ListRolesRequest, limiter pagination.PageLimiter) error { +func (o RoleQueryOption) FromListRequest(in *ListRolesRequest, limiter repo.PageLimiter) error { in.Current = limiter.Current(in.Current) in.PageSize = limiter.PerPage(in.PageSize) return nil } -func (o RoleQueryOption) FromGetRequest(in *pb.GetRoleRequest, limiter pagination.PageLimiter) error { +func (o RoleQueryOption) FromGetRequest(in *pb.GetRoleRequest, limiter repo.PageLimiter) error { return nil } -func (o RoleQueryOption) FromCreateRequest(in *pb.CreateRoleRequest, limiter pagination.PageLimiter) error { +func (o RoleQueryOption) FromCreateRequest(in *pb.CreateRoleRequest, limiter repo.PageLimiter) error { return nil } diff --git a/internal/features/datastore/dto/user.go b/internal/features/datastore/dto/user.go index ed8e552f..d1d99300 100644 --- a/internal/features/datastore/dto/user.go +++ b/internal/features/datastore/dto/user.go @@ -72,17 +72,17 @@ type UserQueryOption struct { Fields []string } -func (o *UserQueryOption) FromListRequest(in *ListUsersRequest, limiter pagination.PageLimiter) error { +func (o *UserQueryOption) FromListRequest(in *ListUsersRequest, limiter repo.PageLimiter) error { in.Current = limiter.Current(in.Current) in.PageSize = limiter.PerPage(in.PageSize) return nil } -func (o *UserQueryOption) FromGetRequest(in *pb.GetUserRequest, limiter pagination.PageLimiter) error { +func (o *UserQueryOption) FromGetRequest(in *pb.GetUserRequest, limiter repo.PageLimiter) error { return nil } -func (o *UserMutationOption) FromCreateRequest(in *pb.CreateUserRequest, limiter pagination.PageLimiter) error { +func (o *UserMutationOption) FromCreateRequest(in *pb.CreateUserRequest, limiter repo.PageLimiter) error { o.RandomPasswd = in.RandomPassword return nil } diff --git a/internal/features/system/dal/permission.go b/internal/features/system/dal/permission.go index 0cacb279..6126be1f 100644 --- a/internal/features/system/dal/permission.go +++ b/internal/features/system/dal/permission.go @@ -23,21 +23,31 @@ func NewPermissionRepo(db *ent.Database) dto.PermissionRepo { return &permissionRepo{db: db} } -func (r *permissionRepo) Get(ctx context.Context, id int64, opts ...dto.PermissionQueryOption) (*types.Permission, error) { - result, err := r.db.Permission(ctx).Get(ctx, id) +func (r *permissionRepo) Get(ctx context.Context, id int64, opts ...*dto.PermissionQueryOptions) (*types.Permission, error) { + opt := &dto.PermissionQueryOptions{} + if len(opts) > 0 { + opt = opts[0] + } + + query := r.db.Permission(ctx).Query().Where(permission.ID(id)) + + if opt.WithResources { + query.WithResources() + } + if opt.WithRoles { + query.WithRoles() + } + + result, err := query.Only(ctx) if err != nil { return nil, err } return dto.ConvertPermissionToPermissionPB(result), nil } -func (r *permissionRepo) Create(ctx context.Context, p *types.Permission, opts ...dto.PermissionMutationOption) (*types.Permission, error) { - create := r.db.Permission(ctx).Create(). - SetName(p.Name) - - //if len(p.ResourceIds) > 0 { - // create.AddResourceIDs(p.ResourceIds...) - //} +func (r *permissionRepo) Create(ctx context.Context, p *types.Permission, opts ...*dto.PermissionCreateOptions) (*types.Permission, error) { + entPermission := dto.ConvertPermissionPBToPermission(p) + create := r.db.Permission(ctx).Create().SetPermission(entPermission) // ... set other fields @@ -52,14 +62,11 @@ func (r *permissionRepo) Delete(ctx context.Context, id int64) error { return r.db.Permission(ctx).DeleteOneID(id).Exec(ctx) } -func (r *permissionRepo) Update(ctx context.Context, p *types.Permission, opts ...dto.PermissionMutationOption) (*types.Permission, error) { - update := r.db.Permission(ctx).UpdateOneID(p.Id) +func (r *permissionRepo) Update(ctx context.Context, p *types.Permission, opts ...*dto.PermissionUpdateOptions) (*types.Permission, error) { + entPermission := dto.ConvertPermissionPBToPermission(p) + update := r.db.Permission(ctx).UpdateOneID(p.Id).SetPermission(entPermission) - //if len(p.ResourceIds) > 0 { - // update.ClearResources().AddResourceIDs(p.ResourceIds...) - //} - - // ... set other fields + // ... handle partial updates based on opts ... saved, err := update.Save(ctx) if err != nil { @@ -68,19 +75,33 @@ func (r *permissionRepo) Update(ctx context.Context, p *types.Permission, opts . return dto.ConvertPermissionToPermissionPB(saved), nil } -func (r *permissionRepo) List(ctx context.Context, in *system.ListPermissionsRequest, opts ...dto.PermissionQueryOption) ([]*types.Permission, int32, error) { +func (r *permissionRepo) List(ctx context.Context, in *system.ListPermissionsRequest, opts ...*dto.PermissionQueryOptions) ([]*types.Permission, int32, error) { + opt := &dto.PermissionQueryOptions{} + if len(opts) > 0 { + opt = opts[0] + } + query := r.db.Permission(ctx).Query() if len(in.DataScopes) > 0 { query = query.Where(permission.DataScopeIn(in.DataScopes...)) } + if opt.Page > 0 && opt.PageSize > 0 { + query.Offset((opt.Page - 1) * opt.PageSize).Limit(opt.PageSize) + } + count, err := query.Clone().Count(ctx) if err != nil { return nil, 0, err } - //query = db.QueryPage(query, in) + if opt.WithResources { + query.WithResources() + } + if opt.WithRoles { + query.WithRoles() + } result, err := query.All(ctx) return dto.ConvertPermissionsToPermissionsPB(result), int32(count), err diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index 5e69f4c3..fcb38040 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -11,6 +11,7 @@ import ( "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/features/system/dto" ) @@ -27,15 +28,26 @@ func NewResourceRepo(db *ent.Database) dto.ResourceRepo { } } -func (r *resourceRepo) Get(ctx context.Context, id int64, opts ...dto.ResourceQueryOption) (*types.Resource, error) { - result, err := r.db.Resource(ctx).Get(ctx, id) +func (r *resourceRepo) Get(ctx context.Context, id int64, opts ...*dto.ResourceQueryOptions) (*types.Resource, error) { + opt := &dto.ResourceQueryOptions{} + if len(opts) > 0 { + opt = opts[0] + } + + query := r.db.Resource(ctx).Query().Where(resource.ID(id)) + + if opt.WithPermissions { + query.WithPermissions() + } + + result, err := query.Only(ctx) if err != nil { return nil, err } return dto.ConvertResourceToResourcePB(result), nil } -func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ...dto.ResourceMutationOption) (*types.Resource, error) { +func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ...*dto.ResourceCreateOptions) (*types.Resource, error) { if res.ParentId > 0 { parent, err := r.db.Resource(ctx).Get(ctx, res.ParentId) if err != nil { @@ -44,14 +56,8 @@ func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ... res.TreePath = parent.TreePath + strconv.FormatInt(int64(parent.ID), 10) + r.Delimiter } - create := r.db.Resource(ctx).Create(). - SetName(res.Name). - SetParentID(res.ParentId). - SetTreePath(res.TreePath) - - //if len(res.PermissionIds) > 0 { - // create.AddPermissionIDs(res.PermissionIds...) - //} + entResource := dto.ConvertResourcePBToResource(res) + create := r.db.Resource(ctx).Create().SetResource(entResource) // ... set other fields @@ -66,14 +72,11 @@ func (r *resourceRepo) Delete(ctx context.Context, id int64) error { return r.db.Resource(ctx).DeleteOneID(id).Exec(ctx) } -func (r *resourceRepo) Update(ctx context.Context, res *types.Resource, opts ...dto.ResourceMutationOption) (*types.Resource, error) { - update := r.db.Resource(ctx).UpdateOneID(res.Id) +func (r *resourceRepo) Update(ctx context.Context, res *types.Resource, opts ...*dto.ResourceUpdateOptions) (*types.Resource, error) { + entResource := dto.ConvertResourcePBToResource(res) + update := r.db.Resource(ctx).UpdateOneID(res.Id).SetResource(entResource) - //if len(res.PermissionIds) > 0 { - // update.ClearPermissions().AddPermissionIDs(res.PermissionIds...) - //} - - // ... set other fields + // ... handle partial updates based on opts ... saved, err := update.Save(ctx) if err != nil { @@ -82,15 +85,26 @@ func (r *resourceRepo) Update(ctx context.Context, res *types.Resource, opts ... return dto.ConvertResourceToResourcePB(saved), nil } -func (r *resourceRepo) List(ctx context.Context, in *system.ListResourcesRequest, opts ...dto.ResourceQueryOption) ([]*types.Resource, int32, error) { +func (r *resourceRepo) List(ctx context.Context, in *system.ListResourcesRequest, opts ...*dto.ResourceQueryOptions) ([]*types.Resource, int32, error) { + opt := &dto.ResourceQueryOptions{} + if len(opts) > 0 { + opt = opts[0] + } + query := r.db.Resource(ctx).Query() + if opt.Page > 0 && opt.PageSize > 0 { + query.Offset((opt.Page - 1) * opt.PageSize).Limit(opt.PageSize) + } + count, err := query.Clone().Count(ctx) if err != nil { return nil, 0, err } - //query = db.QueryPage(query, in) + if opt.WithPermissions { + query.WithPermissions() + } result, err := query.All(ctx) return dto.ConvertResourcesToResourcesPB(result), int32(count), err diff --git a/internal/features/system/dal/role.go b/internal/features/system/dal/role.go index c5de3114..27654faa 100644 --- a/internal/features/system/dal/role.go +++ b/internal/features/system/dal/role.go @@ -22,23 +22,31 @@ type roleRepo struct { } // NewRoleRepo . -func NewRoleRepo(db *ent.Database) (dto.RoleRepo, error) { - generator, err := rand.NewGenerator(rand.KindDigit | rand.KindLowerCase) - if err != nil { - return nil, err - } - return &roleRepo{db: db, gen: generator}, nil +func NewRoleRepo(db *ent.Database) dto.RoleRepo { + generator := rand.NewGenerator(rand.KindDigit | rand.KindLowerCase) + return &roleRepo{db: db, gen: generator} } -func (r *roleRepo) Get(ctx context.Context, id int64, opts ...dto.RoleQueryOption) (*types.Role, error) { - result, err := r.db.Role(ctx).Get(ctx, id) +func (r *roleRepo) Get(ctx context.Context, id int64, opts ...*dto.RoleQueryOptions) (*types.Role, error) { + opt := &dto.RoleQueryOptions{} + if len(opts) > 0 { + opt = opts[0] + } + + query := r.db.Role(ctx).Query().Where(role.ID(id)) + + if opt.WithPermissions { + query.WithPermissions() + } + + result, err := query.Only(ctx) if err != nil { return nil, err } return dto.ConvertRoleToRolePB(result), nil } -func (r *roleRepo) Create(ctx context.Context, rl *types.Role, opts ...dto.RoleMutationOption) (*types.Role, error) { +func (r *roleRepo) Create(ctx context.Context, rl *types.Role, opts ...*dto.RoleCreateOptions) (*types.Role, error) { if rl.Keyword == "" { randString, err := r.gen.RandString(12) if err != nil { @@ -51,9 +59,8 @@ func (r *roleRepo) Create(ctx context.Context, rl *types.Role, opts ...dto.RoleM return nil, errors.New("role keyword already exists") } - create := r.db.Role(ctx).Create(). - SetName(rl.Name). - SetKeyword(rl.Keyword) + entRole := dto.ConvertRolePBToRole(rl) + create := r.db.Role(ctx).Create().SetRole(entRole) saved, err := create.Save(ctx) if err != nil { @@ -66,13 +73,10 @@ func (r *roleRepo) Delete(ctx context.Context, id int64) error { return r.db.Role(ctx).DeleteOneID(id).Exec(ctx) } -func (r *roleRepo) Update(ctx context.Context, rl *types.Role, opts ...dto.RoleMutationOption) (*types.Role, error) { - update := r.db.Role(ctx).UpdateOneID(rl.Id) - //if len(rl.PermissionIds) > 0 { - // update.ClearPermissions().AddPermissionIDs(rl.PermissionIds...) - //} - - // ... set other fields +func (r *roleRepo) Update(ctx context.Context, rl *types.Role, opts ...*dto.RoleUpdateOptions) (*types.Role, error) { + entRole := dto.ConvertRolePBToRole(rl) + update := r.db.Role(ctx).UpdateOneID(rl.Id).SetRole(entRole) + // ... handle partial updates based on opts ... saved, err := update.Save(ctx) if err != nil { @@ -81,22 +85,30 @@ func (r *roleRepo) Update(ctx context.Context, rl *types.Role, opts ...dto.RoleM return dto.ConvertRoleToRolePB(saved), nil } -func (r *roleRepo) List(ctx context.Context, in *system.ListRolesRequest, opts ...dto.RoleQueryOption) ([]*types.Role, int32, error) { +func (r *roleRepo) List(ctx context.Context, in *system.ListRolesRequest, opts ...*dto.RoleQueryOptions) ([]*types.Role, int32, error) { + opt := &dto.RoleQueryOptions{} + if len(opts) > 0 { + opt = opts[0] + } + query := r.db.Role(ctx).Query() if in.GetKeyword() != "" { query = query.Where(role.NameContainsFold(in.GetKeyword())) } - //if in.Status != nil { - // query = query.Where(role.StatusEQ(*in.Status)) - //} + + if opt.Page > 0 && opt.PageSize > 0 { + query.Offset((opt.Page - 1) * opt.PageSize).Limit(opt.PageSize) + } count, err := query.Clone().Count(ctx) if err != nil { return nil, 0, err } - //query = db.QueryPage(query, in) + if opt.WithPermissions { + query.WithPermissions() + } result, err := query.All(ctx) return dto.ConvertRolesToRolesPB(result), int32(count), err diff --git a/internal/features/system/dal/user.go b/internal/features/system/dal/user.go index 9d0f8fc6..7511dfc2 100644 --- a/internal/features/system/dal/user.go +++ b/internal/features/system/dal/user.go @@ -24,25 +24,33 @@ func NewUserRepo(db *ent.Database) dto.UserRepo { return &userRepo{db: db} } -func (r *userRepo) Get(ctx context.Context, id int64, opts ...dto.UserQueryOption) (*types.User, error) { - result, err := r.db.User(ctx).Get(ctx, id) +func (r *userRepo) Get(ctx context.Context, id int64, opts ...*dto.UserQueryOptions) (*types.User, error) { + opt := &dto.UserQueryOptions{} + if len(opts) > 0 { + opt = opts[0] + } + + query := r.db.User(ctx).Query().Where(user.ID(id)) + + if opt.WithRoles { + query.WithRoles() + } + + result, err := query.Only(ctx) if err != nil { return nil, err } return dto.ConvertUserToUserPB(result), nil } -func (r *userRepo) Create(ctx context.Context, u *types.User, opts ...dto.UserMutationOption) (*types.User, error) { +func (r *userRepo) Create(ctx context.Context, u *types.User, opts ...*dto.UserCreateOptions) (*types.User, error) { exist, err := r.db.User(ctx).Query().Where(user.UsernameEQ(u.Username)).Exist(ctx) if err != nil || exist { return nil, errors.New("user already exists") } - create := r.db.User(ctx).Create(). - SetUsername(u.Username). - SetPassword(u.Password) - - // ... set other fields + entUser := dto.ConvertUserPBToUser(u) + create := r.db.User(ctx).Create().SetUser(entUser) saved, err := create.Save(ctx) if err != nil { @@ -55,14 +63,11 @@ func (r *userRepo) Delete(ctx context.Context, id int64) error { return r.db.User(ctx).DeleteOneID(id).Exec(ctx) } -func (r *userRepo) Update(ctx context.Context, u *types.User, opts ...dto.UserMutationOption) (*types.User, error) { - update := r.db.User(ctx).UpdateOneID(u.Id) - - //if len(u.RoleIds) > 0 { - // update.ClearRoles().AddRoleIDs(u.RoleIds...) - //} +func (r *userRepo) Update(ctx context.Context, u *types.User, opts ...*dto.UserUpdateOptions) (*types.User, error) { + entUser := dto.ConvertUserPBToUser(u) + update := r.db.User(ctx).UpdateOneID(u.Id).SetUser(entUser) - // ... set other fields + // ... handle partial updates based on opts saved, err := update.Save(ctx) if err != nil { @@ -71,32 +76,40 @@ func (r *userRepo) Update(ctx context.Context, u *types.User, opts ...dto.UserMu return dto.ConvertUserToUserPB(saved), nil } -func (r *userRepo) List(ctx context.Context, in *system.ListUsersRequest, opts ...dto.UserQueryOption) ([]*types.User, int32, error) { +func (r *userRepo) List(ctx context.Context, in *system.ListUsersRequest, opts ...*dto.UserQueryOptions) ([]*types.User, int32, error) { + opt := &dto.UserQueryOptions{} + if len(opts) > 0 { + opt = opts[0] + } + query := r.db.User(ctx).Query() if in.GetKeyword() != "" { query = query.Where(user.Or(user.UsernameContainsFold(in.GetKeyword()), user.PhoneContainsFold(in.GetKeyword()), user.EmailContainsFold(in.GetKeyword()))) } - //if in.Status != nil { - // query = query.Where(user.StatusEQ(int8(*in.Status))) - //} + + if opt.Page > 0 && opt.PageSize > 0 { + query.Offset((opt.Page - 1) * opt.PageSize).Limit(opt.PageSize) + } count, err := query.Clone().Count(ctx) if err != nil { return nil, 0, err } - //query = db.QueryPage(query, in) + if opt.WithRoles { + query.WithRoles() + } result, err := query.All(ctx) return dto.ConvertUsersToUsersPB(result), int32(count), err } -func (r *userRepo) AddRoleIDs(ctx context.Context, id int64, roleIDs []int64, opts ...dto.UserMutationOption) error { +func (r *userRepo) AddRoleIDs(ctx context.Context, id int64, roleIDs []int64) error { return r.db.User(ctx).UpdateOneID(id).AddRoleIDs(roleIDs...).Exec(ctx) } -func (r *userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*types.User, error) { +func (r *userRepo) GetByUsername(ctx context.Context, username string) (*types.User, error) { result, err := r.db.User(ctx).Query().Where(user.UsernameEQ(username)).Only(ctx) if err != nil { return nil, err @@ -112,7 +125,7 @@ func (r *userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { return ids, nil } -func (r *userRepo) ListResourceByUserID(ctx context.Context, id int64, opts ...dto.UserQueryOption) ([]*types.Resource, error) { +func (r *userRepo) ListResourceByUserID(ctx context.Context, id int64) ([]*types.Resource, error) { resources, err := r.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) if err != nil { return nil, err @@ -120,10 +133,6 @@ func (r *userRepo) ListResourceByUserID(ctx context.Context, id int64, opts ...d return dto.ConvertResourcesToResourcesPB(resources), nil } -func (r *userRepo) UpdateUserStatus(ctx context.Context, id int64, status int32, opts ...dto.UserQueryOption) error { +func (r *userRepo) UpdateUserStatus(ctx context.Context, id int64, status int32) error { return r.db.User(ctx).UpdateOneID(id).SetStatus(int8(status)).Exec(ctx) } - -func (r *userRepo) Current(ctx context.Context, id int64) (*types.User, error) { - return r.Get(ctx, id) -} diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index c3d4357e..fc2af785 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -26,3 +26,13 @@ func ConvertStringToGender(from string) user.Gender { // TODO: Implement this custom conversion panic("stub! not implemented") } + +type Pagination struct { + Page int + PageSize int +} + +type QueryOption struct { + Pagination *Pagination + OrderBy []string +} diff --git a/internal/features/system/dto/permission.go b/internal/features/system/dto/permission.go index 0edfbfce..cd03ecab 100644 --- a/internal/features/system/dto/permission.go +++ b/internal/features/system/dto/permission.go @@ -7,22 +7,32 @@ package dto import ( "context" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/helpers/repo" ) // PermissionRepo is a Permission repository interface. type PermissionRepo interface { - Get(context.Context, int64, ...PermissionQueryOption) (*types.Permission, error) - Create(context.Context, *types.Permission, ...PermissionQueryOption) (*types.Permission, error) + Get(context.Context, int64, ...*PermissionQueryOptions) (*types.Permission, error) + List(context.Context, *system.ListPermissionsRequest, ...*PermissionQueryOptions) ([]*types.Permission, int32, error) + Create(context.Context, *types.Permission, ...*PermissionCreateOptions) (*types.Permission, error) + Update(context.Context, *types.Permission, ...*PermissionUpdateOptions) (*types.Permission, error) Delete(context.Context, int64) error - Update(context.Context, *types.Permission, ...PermissionQueryOption) (*types.Permission, error) - List(context.Context, *system.ListPermissionsRequest, ...PermissionQueryOption) ([]*types.Permission, int32, error) } -type PermissionQueryOption struct { - OrderFields []string - Fields []string - IncludeResources bool - IncludeRoles bool +// PermissionQueryOptions specifies options for listing permissions. +type PermissionQueryOptions struct { + repo.QueryOption + WithResources bool + WithRoles bool +} + +// PermissionCreateOptions specifies options for creating a permission. +type PermissionCreateOptions struct { +} + +// PermissionUpdateOptions specifies options for updating a permission. +type PermissionUpdateOptions struct { } diff --git a/internal/features/system/dto/resource.go b/internal/features/system/dto/resource.go index 5f5a604b..d26a2fc9 100644 --- a/internal/features/system/dto/resource.go +++ b/internal/features/system/dto/resource.go @@ -7,20 +7,31 @@ package dto import ( "context" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/helpers/repo" ) // ResourceRepo is a Resource repository interface. type ResourceRepo interface { - Get(context.Context, int64, ...ResourceQueryOption) (*types.Resource, error) - Create(context.Context, *types.Resource, ...ResourceQueryOption) (*types.Resource, error) + Get(context.Context, int64, ...*ResourceQueryOptions) (*types.Resource, error) + List(context.Context, *system.ListResourcesRequest, ...*ResourceQueryOptions) ([]*types.Resource, int32, error) + Create(context.Context, *types.Resource, ...*ResourceCreateOptions) (*types.Resource, error) + Update(context.Context, *types.Resource, ...*ResourceUpdateOptions) (*types.Resource, error) Delete(context.Context, int64) error - Update(context.Context, *types.Resource, ...ResourceQueryOption) (*types.Resource, error) - List(context.Context, *system.ListResourcesRequest, ...ResourceQueryOption) ([]*types.Resource, int32, error) } -type ResourceQueryOption struct { - OrderFields []string - Fields []string +// ResourceQueryOptions specifies options for listing resources. +type ResourceQueryOptions struct { + repo.QueryOption + WithPermissions bool +} + +// ResourceCreateOptions specifies options for creating a resource. +type ResourceCreateOptions struct { +} + +// ResourceUpdateOptions specifies options for updating a resource. +type ResourceUpdateOptions struct { } diff --git a/internal/features/system/dto/role.go b/internal/features/system/dto/role.go index f4e9edad..25173f07 100644 --- a/internal/features/system/dto/role.go +++ b/internal/features/system/dto/role.go @@ -7,24 +7,35 @@ package dto import ( "context" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/helpers/repo" ) // RoleRepo is a Role repository interface. type RoleRepo interface { - Get(context.Context, int64, ...RoleQueryOption) (*types.Role, error) - List(context.Context, *system.ListRolesRequest, ...RoleQueryOption) ([]*types.Role, int32, error) - Create(context.Context, *types.Role, ...RoleUpdateOption) (*types.Role, error) - Update(context.Context, *types.Role, ...RoleUpdateOption) (*types.Role, error) + Get(context.Context, int64, ...*RoleQueryOptions) (*types.Role, error) + List(context.Context, *system.ListRolesRequest, ...*RoleQueryOptions) ([]*types.Role, int32, error) + Create(context.Context, *types.Role, ...*RoleCreateOptions) (*types.Role, error) + Update(context.Context, *types.Role, ...*RoleUpdateOptions) (*types.Role, error) Delete(context.Context, int64) error + + // Business-specific methods + GetPermissions(context.Context, int64) ([]*types.Permission, error) + UpdatePermissions(context.Context, int64, []int64) error +} + +// RoleQueryOptions specifies options for listing roles. +type RoleQueryOptions struct { + repo.QueryOption + WithPermissions bool } -type RoleQueryOption struct { - IncludePermissions bool - OrderFields []string +// RoleCreateOptions specifies options for creating a role. +type RoleCreateOptions struct { } -type RoleUpdateOption struct { - Fields []string +// RoleUpdateOptions specifies options for updating a role. +type RoleUpdateOptions struct { } diff --git a/internal/features/system/dto/user.go b/internal/features/system/dto/user.go index 327edf5a..c5f442d6 100644 --- a/internal/features/system/dto/user.go +++ b/internal/features/system/dto/user.go @@ -7,31 +7,42 @@ package dto import ( "context" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/helpers/repo" ) // UserRepo is a User repository interface. type UserRepo interface { - Get(context.Context, int64, ...UserQueryOption) (*types.User, error) - Create(context.Context, *types.User, ...UserMutationOption) (*types.User, error) + Get(context.Context, int64, ...*UserQueryOptions) (*types.User, error) + List(context.Context, *system.ListUsersRequest, ...*UserQueryOptions) ([]*types.User, int32, error) + Create(context.Context, *types.User, ...*UserCreateOptions) (*types.User, error) + Update(context.Context, *types.User, ...*UserUpdateOptions) (*types.User, error) Delete(context.Context, int64) error - Update(context.Context, *types.User, ...UserMutationOption) (*types.User, error) - List(context.Context, *system.ListUsersRequest, ...UserQueryOption) ([]*types.User, int32, error) - AddRoleIDs(context.Context, int64, []int64, ...UserMutationOption) error - GetByUsername(context.Context, string, ...string) (*types.User, error) + + // Business-specific methods + AddRoleIDs(context.Context, int64, []int64) error + GetByUsername(context.Context, string) (*types.User, error) GetRoleIDs(context.Context, int64) ([]int64, error) - ListResourceByUserID(context.Context, int64, ...UserQueryOption) ([]*types.Resource, error) - Current(context.Context, int64) (*types.User, error) - UpdateUserStatus(ctx context.Context, id int64, status int32, options ...UserQueryOption) error + ListResourceByUserID(context.Context, int64) ([]*types.Resource, error) + UpdateUserStatus(ctx context.Context, id int64, status int32) error +} + +// UserQueryOptions specifies options for listing users. +type UserQueryOptions struct { + repo.QueryOption + WithRoles bool } -type UserMutationOption struct { - Fields []string +// UserCreateOptions specifies options for creating a user. +type UserCreateOptions struct { + // Example: Immediately load roles after creation + LoadRoles bool } -type UserQueryOption struct { - IncludeRoles bool - OrderFields []string - Fields []string +// UserUpdateOptions specifies options for updating a user. +type UserUpdateOptions struct { + // Example: For partial updates (PATCH) + UpdateFields []string } diff --git a/internal/helpers/captcha/captcha.go b/internal/helpers/captcha/captcha.go index 445200d8..39566fec 100644 --- a/internal/helpers/captcha/captcha.go +++ b/internal/helpers/captcha/captcha.go @@ -16,7 +16,7 @@ import ( ) var ( - ErrNotFound = errors.New(400, typespb.AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), http.StatusBadRequest, "captcha not found") + ErrNotFound = errors.New(http.StatusBadRequest, typespb.AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), "captcha not found") ) const ( diff --git a/internal/helpers/db/db.go b/internal/helpers/db/db.go index 790040e3..5e1a15f9 100644 --- a/internal/helpers/db/db.go +++ b/internal/helpers/db/db.go @@ -28,7 +28,7 @@ type FieldSelector[T any] interface { Omit(...string) T } -func Query[P Paginator[P]](query P, in pagination.PageRequest, paging bool) P { +func Query[P Paginator[P]](query P, in repo.PageRequest, paging bool) P { if !paging { return QueryNoPage(query, in) } diff --git a/internal/helpers/repo/query.go b/internal/helpers/repo/query.go new file mode 100644 index 00000000..ef820984 --- /dev/null +++ b/internal/helpers/repo/query.go @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package repo provides common query options for pagination. +package repo + +// QueryOption holds common query options like pagination and ordering. +// It is intended to be embedded in more specific query option structs. +type QueryOption struct { + Page int + PageSize int + OrderBy []string +} + +// IsOption is a marker method to ensure type safety. +func (o *QueryOption) IsOption() {} From 14201282ec62f6903e2c01be2c3f9263d8e5e83d Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 24 Dec 2025 20:12:01 +0800 Subject: [PATCH 073/158] refactor(proto): simplify user service endpoints and request structures by removing nested user object --- api/v1/proto/system/user.proto | 27 +- api/v1/proto/types/system.proto | 32 +- api/v1/services/system/user.pb.go | 153 +++--- api/v1/services/system/user.pb.gw.go | 98 ++-- api/v1/services/system/user.pb.validate.go | 123 ++--- api/v1/services/system/user_bridge.pb.go | 12 +- api/v1/services/system/user_http.pb.go | 24 +- api/v1/services/types/system.pb.go | 84 +-- api/v1/services/types/system.pb.validate.go | 6 - cmd/system/wire.go | 15 - cmd/system/wire_gen.go | 37 +- internal/conf/config.go | 7 +- .../auth/dal}/casbin-adapter.dal.go | 2 +- internal/features/system/biz/permission.go | 40 +- internal/features/system/biz/resource.go | 40 +- internal/features/system/biz/role.go | 40 +- internal/features/system/biz/user.go | 45 +- internal/features/system/dal/permission.go | 26 +- internal/features/system/dal/resource.go | 22 +- internal/features/system/dal/role.go | 26 +- internal/features/system/dal/user.go | 29 +- internal/features/system/dto/dto.gen.go | 494 +++++++++++++++++- internal/features/system/dto/dto.go | 12 +- internal/features/system/dto/permission.go | 32 +- internal/features/system/dto/resource.go | 31 +- internal/features/system/dto/role.go | 31 +- internal/features/system/dto/user.go | 31 +- .../features/system/service/permission.go | 18 +- internal/features/system/service/resource.go | 18 +- internal/features/system/service/role.go | 18 +- internal/features/system/service/user.go | 26 +- internal/helpers/repo/options.go | 64 +++ internal/helpers/repo/query.go | 17 - resources/docs/openapi/openapi.yaml | 274 +++++----- 34 files changed, 1166 insertions(+), 788 deletions(-) rename internal/{data => features/auth/dal}/casbin-adapter.dal.go (99%) create mode 100644 internal/helpers/repo/options.go delete mode 100644 internal/helpers/repo/query.go diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index 62d2b5c0..5f6577d0 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -39,21 +39,21 @@ service UserService { }; } rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse) { - option (google.api.http) = {delete: "/sys/users/{user.id}"}; + option (google.api.http) = {delete: "/sys/users/{id}"}; } // UpdateUserStatus Update the status of the user information rpc UpdateUserStatus(UpdateUserStatusRequest) returns (UpdateUserStatusResponse) { option (google.api.http) = { - put: "/sys/users/{user.id}/status" - body: "user" + put: "/sys/users/{id}/status" + body: "*" }; } // UpdateUserRoles update the user roles rpc UpdateUserRoles(UpdateUserRolesRequest) returns (UpdateUserRolesResponse) { option (google.api.http) = { - put: "/sys/users/{user.id}/roles" - body: "user" + put: "/sys/users/{id}/roles" + body: "*" }; } @@ -61,7 +61,7 @@ service UserService { rpc ResetUserPassword(ResetUserPasswordRequest) returns (ResetUserPasswordResponse) { option (google.api.http) = { post: "/sys/users/{id}/password/reset" - body: "data" + body: "password" }; } } @@ -76,14 +76,16 @@ message ListUserResourcesResponse { } message UpdateUserStatusRequest { - api.v1.services.types.User user = 1 [json_name = "user"]; + int64 id = 1; + int32 status = 2; + optional api.v1.services.types.User user = 3 [json_name = "user"]; } message UpdateUserStatusResponse {} message ResetUserPasswordRequest { - string id = 1 [json_name = "id"]; - google.protobuf.Any data = 2 [json_name = "data"]; + int64 id = 1; + string password = 2; } message ResetUserPasswordResponse {} @@ -167,9 +169,10 @@ message UpdateUserResponse { } message DeleteUserRequest { - // The resource id of the user to be deleted, for example: - // "shelves/shelf1/users/user2" - api.v1.services.types.User user = 1; + // The resource id of the user to be deleted. + int64 id = 1; + // The user object, for compatibility. + optional api.v1.services.types.User user = 2; } message DeleteUserResponse { diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index f7d3b3d3..d2d0fc75 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -142,38 +142,30 @@ message User { string name = 11 [json_name = "name"]; // user.field.gender string gender = 12 [json_name = "gender"]; - // user.field.password - // @Decrypted don't show this field in response - string password = 13 [json_name = "password"]; - // user.field.confirm_password - string confirm_password = 14 [json_name = "confirm_password"]; - // user.field.salt - // @Decrypted don't show this field in response - string salt = 15 [json_name = "salt"]; // user.field.phone - string phone = 16 [json_name = "phone"]; + string phone = 13 [json_name = "phone"]; // user.field.email - string email = 17 [json_name = "email"]; + string email = 14 [json_name = "email"]; // user.field.remark - string remark = 18 [json_name = "remark"]; + string remark = 15 [json_name = "remark"]; // user.field.token - string token = 19 [json_name = "token"]; + string token = 16 [json_name = "token"]; // user.field.status - int32 status = 20 [json_name = "status"]; + int32 status = 17 [json_name = "status"]; // user.field.last_login_ip - string last_login_ip = 21 [json_name = "last_login_ip"]; + string last_login_ip = 18 [json_name = "last_login_ip"]; // user.field.last_login_time - google.protobuf.Timestamp last_login_time = 22 [json_name = "last_login_time"]; + google.protobuf.Timestamp last_login_time = 19 [json_name = "last_login_time"]; // user.field.sanction_date - optional google.protobuf.Timestamp sanction_date = 23 [json_name = "sanction_date"]; + optional google.protobuf.Timestamp sanction_date = 20 [json_name = "sanction_date"]; // user.field.manager_id - int64 manager_id = 24 [json_name = "manager_id"]; + int64 manager_id = 21 [json_name = "manager_id"]; // user.field.manager - string manager = 25 [json_name = "manager"]; + string manager = 22 [json_name = "manager"]; // Roles holds the value of the roles edge. - repeated Role roles = 26 [json_name = "roles"]; + repeated Role roles = 23 [json_name = "roles"]; // Role Ids holds the value of the role_ids - repeated int64 role_ids = 27 [json_name = "role_ids"]; + repeated int64 role_ids = 24 [json_name = "role_ids"]; } // UserEdges holds the relations/edges for other nodes in the graph. diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go index a88e0619..144ded6c 100644 --- a/api/v1/services/system/user.pb.go +++ b/api/v1/services/system/user.pb.go @@ -123,7 +123,9 @@ func (x *ListUserResourcesResponse) GetResources() []*types.Resource { type UpdateUserStatusRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` + User *types.User `protobuf:"bytes,3,opt,name=user,proto3,oneof" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -158,6 +160,20 @@ func (*UpdateUserStatusRequest) Descriptor() ([]byte, []int) { return file_system_user_proto_rawDescGZIP(), []int{2} } +func (x *UpdateUserStatusRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateUserStatusRequest) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + func (x *UpdateUserStatusRequest) GetUser() *types.User { if x != nil { return x.User @@ -203,8 +219,8 @@ func (*UpdateUserStatusResponse) Descriptor() ([]byte, []int) { type ResetUserPasswordRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -239,18 +255,18 @@ func (*ResetUserPasswordRequest) Descriptor() ([]byte, []int) { return file_system_user_proto_rawDescGZIP(), []int{4} } -func (x *ResetUserPasswordRequest) GetId() string { +func (x *ResetUserPasswordRequest) GetId() int64 { if x != nil { return x.Id } - return "" + return 0 } -func (x *ResetUserPasswordRequest) GetData() *anypb.Any { +func (x *ResetUserPasswordRequest) GetPassword() string { if x != nil { - return x.Data + return x.Password } - return nil + return "" } type ResetUserPasswordResponse struct { @@ -822,9 +838,10 @@ func (x *UpdateUserResponse) GetUser() *types.User { type DeleteUserRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - // The resource id of the user to be deleted, for example: - // "shelves/shelf1/users/user2" - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // The resource id of the user to be deleted. + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + // The user object, for compatibility. + User *types.User `protobuf:"bytes,2,opt,name=user,proto3,oneof" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -859,6 +876,13 @@ func (*DeleteUserRequest) Descriptor() ([]byte, []int) { return file_system_user_proto_rawDescGZIP(), []int{14} } +func (x *DeleteUserRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + func (x *DeleteUserRequest) GetUser() *types.User { if x != nil { return x.User @@ -1023,13 +1047,16 @@ const file_system_user_proto_rawDesc = "" + "\x02id\x18\x01 \x01(\x03R\x02id\"p\n" + "\x19ListUserResourcesResponse\x12\x14\n" + "\x05total\x18\x01 \x01(\x05R\x05total\x12=\n" + - "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"J\n" + - "\x17UpdateUserStatusRequest\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\x1a\n" + - "\x18UpdateUserStatusResponse\"T\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"\x80\x01\n" + + "\x17UpdateUserStatusRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + + "\x06status\x18\x02 \x01(\x05R\x06status\x124\n" + + "\x04user\x18\x03 \x01(\v2\x1b.api.v1.services.types.UserH\x00R\x04user\x88\x01\x01B\a\n" + + "\x05_user\"\x1a\n" + + "\x18UpdateUserStatusResponse\"F\n" + "\x18ResetUserPasswordRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12(\n" + - "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1b\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" + + "\bpassword\x18\x02 \x01(\tR\bpassword\"\x1b\n" + "\x19ResetUserPasswordResponse\"\xcc\x01\n" + "\x10ListUsersRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + @@ -1070,9 +1097,11 @@ const file_system_user_proto_rawDesc = "" + "\tis_system\x18\x04 \x01(\bR\tis_system\x12(\n" + "\x0frandom_password\x18\x02 \x01(\bR\x0frandom_password\"E\n" + "\x12UpdateUserResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"D\n" + - "\x11DeleteUserRequest\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"B\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"b\n" + + "\x11DeleteUserRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x124\n" + + "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserH\x00R\x04user\x88\x01\x01B\a\n" + + "\x05_user\"B\n" + "\x12DeleteUserResponse\x12,\n" + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"u\n" + "\x16UpdateUserRolesRequest\x12\x0e\n" + @@ -1080,8 +1109,7 @@ const file_system_user_proto_rawDesc = "" + "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x1a\n" + "\brole_ids\x18\x03 \x03(\x03R\brole_ids\"J\n" + "\x17UpdateUserRolesResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\x8e\n" + - "\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\xfc\t\n" + "\vUserService\x12t\n" + "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + "/sys/users\x12\x9b\x01\n" + @@ -1091,12 +1119,12 @@ const file_system_user_proto_rawDesc = "" + "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a*.api.v1.services.system.CreateUserResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04user\"\n" + "/sys/users\x12\x87\x01\n" + "\n" + - "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04user\x1a\x14/sys/users/{user.id}\x12\x81\x01\n" + + "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04user\x1a\x14/sys/users/{user.id}\x12|\n" + "\n" + - "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x1c\x82\xd3\xe4\x93\x02\x16*\x14/sys/users/{user.id}\x12\xa0\x01\n" + - "\x10UpdateUserStatus\x12/.api.v1.services.system.UpdateUserStatusRequest\x1a0.api.v1.services.system.UpdateUserStatusResponse\")\x82\xd3\xe4\x93\x02#:\x04user\x1a\x1b/sys/users/{user.id}/status\x12\x9c\x01\n" + - "\x0fUpdateUserRoles\x12..api.v1.services.system.UpdateUserRolesRequest\x1a/.api.v1.services.system.UpdateUserRolesResponse\"(\x82\xd3\xe4\x93\x02\":\x04user\x1a\x1a/sys/users/{user.id}/roles\x12\xa6\x01\n" + - "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\",\x82\xd3\xe4\x93\x02&:\x04data\"\x1e/sys/users/{id}/password/resetB\xde\x01\n" + + "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/users/{id}\x12\x98\x01\n" + + "\x10UpdateUserStatus\x12/.api.v1.services.system.UpdateUserStatusRequest\x1a0.api.v1.services.system.UpdateUserStatusResponse\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x1a\x16/sys/users/{id}/status\x12\x94\x01\n" + + "\x0fUpdateUserRoles\x12..api.v1.services.system.UpdateUserRolesRequest\x1a/.api.v1.services.system.UpdateUserRolesResponse\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x1a\x15/sys/users/{id}/roles\x12\xaa\x01\n" + + "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\"0\x82\xd3\xe4\x93\x02*:\bpassword\"\x1e/sys/users/{id}/password/resetB\xde\x01\n" + "\x1acom.api.v1.services.systemB\tUserProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( @@ -1139,41 +1167,40 @@ var file_system_user_proto_goTypes = []any{ var file_system_user_proto_depIdxs = []int32{ 18, // 0: api.v1.services.system.ListUserResourcesResponse.resources:type_name -> api.v1.services.types.Resource 19, // 1: api.v1.services.system.UpdateUserStatusRequest.user:type_name -> api.v1.services.types.User - 20, // 2: api.v1.services.system.ResetUserPasswordRequest.data:type_name -> google.protobuf.Any - 19, // 3: api.v1.services.system.ListUsersResponse.users:type_name -> api.v1.services.types.User - 20, // 4: api.v1.services.system.ListUsersResponse.extra:type_name -> google.protobuf.Any - 19, // 5: api.v1.services.system.GetUserResponse.user:type_name -> api.v1.services.types.User - 19, // 6: api.v1.services.system.CreateUserRequest.user:type_name -> api.v1.services.types.User - 19, // 7: api.v1.services.system.CreateUserResponse.user:type_name -> api.v1.services.types.User - 19, // 8: api.v1.services.system.UpdateUserRequest.user:type_name -> api.v1.services.types.User - 19, // 9: api.v1.services.system.UpdateUserResponse.user:type_name -> api.v1.services.types.User - 19, // 10: api.v1.services.system.DeleteUserRequest.user:type_name -> api.v1.services.types.User - 21, // 11: api.v1.services.system.DeleteUserResponse.empty:type_name -> google.protobuf.Empty - 19, // 12: api.v1.services.system.UpdateUserRolesRequest.user:type_name -> api.v1.services.types.User - 19, // 13: api.v1.services.system.UpdateUserRolesResponse.user:type_name -> api.v1.services.types.User - 6, // 14: api.v1.services.system.UserService.ListUsers:input_type -> api.v1.services.system.ListUsersRequest - 0, // 15: api.v1.services.system.UserService.ListUserResources:input_type -> api.v1.services.system.ListUserResourcesRequest - 8, // 16: api.v1.services.system.UserService.GetUser:input_type -> api.v1.services.system.GetUserRequest - 10, // 17: api.v1.services.system.UserService.CreateUser:input_type -> api.v1.services.system.CreateUserRequest - 12, // 18: api.v1.services.system.UserService.UpdateUser:input_type -> api.v1.services.system.UpdateUserRequest - 14, // 19: api.v1.services.system.UserService.DeleteUser:input_type -> api.v1.services.system.DeleteUserRequest - 2, // 20: api.v1.services.system.UserService.UpdateUserStatus:input_type -> api.v1.services.system.UpdateUserStatusRequest - 16, // 21: api.v1.services.system.UserService.UpdateUserRoles:input_type -> api.v1.services.system.UpdateUserRolesRequest - 4, // 22: api.v1.services.system.UserService.ResetUserPassword:input_type -> api.v1.services.system.ResetUserPasswordRequest - 7, // 23: api.v1.services.system.UserService.ListUsers:output_type -> api.v1.services.system.ListUsersResponse - 1, // 24: api.v1.services.system.UserService.ListUserResources:output_type -> api.v1.services.system.ListUserResourcesResponse - 9, // 25: api.v1.services.system.UserService.GetUser:output_type -> api.v1.services.system.GetUserResponse - 11, // 26: api.v1.services.system.UserService.CreateUser:output_type -> api.v1.services.system.CreateUserResponse - 13, // 27: api.v1.services.system.UserService.UpdateUser:output_type -> api.v1.services.system.UpdateUserResponse - 15, // 28: api.v1.services.system.UserService.DeleteUser:output_type -> api.v1.services.system.DeleteUserResponse - 3, // 29: api.v1.services.system.UserService.UpdateUserStatus:output_type -> api.v1.services.system.UpdateUserStatusResponse - 17, // 30: api.v1.services.system.UserService.UpdateUserRoles:output_type -> api.v1.services.system.UpdateUserRolesResponse - 5, // 31: api.v1.services.system.UserService.ResetUserPassword:output_type -> api.v1.services.system.ResetUserPasswordResponse - 23, // [23:32] is the sub-list for method output_type - 14, // [14:23] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name + 19, // 2: api.v1.services.system.ListUsersResponse.users:type_name -> api.v1.services.types.User + 20, // 3: api.v1.services.system.ListUsersResponse.extra:type_name -> google.protobuf.Any + 19, // 4: api.v1.services.system.GetUserResponse.user:type_name -> api.v1.services.types.User + 19, // 5: api.v1.services.system.CreateUserRequest.user:type_name -> api.v1.services.types.User + 19, // 6: api.v1.services.system.CreateUserResponse.user:type_name -> api.v1.services.types.User + 19, // 7: api.v1.services.system.UpdateUserRequest.user:type_name -> api.v1.services.types.User + 19, // 8: api.v1.services.system.UpdateUserResponse.user:type_name -> api.v1.services.types.User + 19, // 9: api.v1.services.system.DeleteUserRequest.user:type_name -> api.v1.services.types.User + 21, // 10: api.v1.services.system.DeleteUserResponse.empty:type_name -> google.protobuf.Empty + 19, // 11: api.v1.services.system.UpdateUserRolesRequest.user:type_name -> api.v1.services.types.User + 19, // 12: api.v1.services.system.UpdateUserRolesResponse.user:type_name -> api.v1.services.types.User + 6, // 13: api.v1.services.system.UserService.ListUsers:input_type -> api.v1.services.system.ListUsersRequest + 0, // 14: api.v1.services.system.UserService.ListUserResources:input_type -> api.v1.services.system.ListUserResourcesRequest + 8, // 15: api.v1.services.system.UserService.GetUser:input_type -> api.v1.services.system.GetUserRequest + 10, // 16: api.v1.services.system.UserService.CreateUser:input_type -> api.v1.services.system.CreateUserRequest + 12, // 17: api.v1.services.system.UserService.UpdateUser:input_type -> api.v1.services.system.UpdateUserRequest + 14, // 18: api.v1.services.system.UserService.DeleteUser:input_type -> api.v1.services.system.DeleteUserRequest + 2, // 19: api.v1.services.system.UserService.UpdateUserStatus:input_type -> api.v1.services.system.UpdateUserStatusRequest + 16, // 20: api.v1.services.system.UserService.UpdateUserRoles:input_type -> api.v1.services.system.UpdateUserRolesRequest + 4, // 21: api.v1.services.system.UserService.ResetUserPassword:input_type -> api.v1.services.system.ResetUserPasswordRequest + 7, // 22: api.v1.services.system.UserService.ListUsers:output_type -> api.v1.services.system.ListUsersResponse + 1, // 23: api.v1.services.system.UserService.ListUserResources:output_type -> api.v1.services.system.ListUserResourcesResponse + 9, // 24: api.v1.services.system.UserService.GetUser:output_type -> api.v1.services.system.GetUserResponse + 11, // 25: api.v1.services.system.UserService.CreateUser:output_type -> api.v1.services.system.CreateUserResponse + 13, // 26: api.v1.services.system.UserService.UpdateUser:output_type -> api.v1.services.system.UpdateUserResponse + 15, // 27: api.v1.services.system.UserService.DeleteUser:output_type -> api.v1.services.system.DeleteUserResponse + 3, // 28: api.v1.services.system.UserService.UpdateUserStatus:output_type -> api.v1.services.system.UpdateUserStatusResponse + 17, // 29: api.v1.services.system.UserService.UpdateUserRoles:output_type -> api.v1.services.system.UpdateUserRolesResponse + 5, // 30: api.v1.services.system.UserService.ResetUserPassword:output_type -> api.v1.services.system.ResetUserPasswordResponse + 22, // [22:31] is the sub-list for method output_type + 13, // [13:22] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name } func init() { file_system_user_proto_init() } @@ -1181,7 +1208,9 @@ func file_system_user_proto_init() { if File_system_user_proto != nil { return } + file_system_user_proto_msgTypes[2].OneofWrappers = []any{} file_system_user_proto_msgTypes[7].OneofWrappers = []any{} + file_system_user_proto_msgTypes[14].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/api/v1/services/system/user.pb.gw.go b/api/v1/services/system/user.pb.gw.go index 6958ef75..f8be51a7 100644 --- a/api/v1/services/system/user.pb.gw.go +++ b/api/v1/services/system/user.pb.gw.go @@ -236,7 +236,7 @@ func local_request_UserService_UpdateUser_0(ctx context.Context, marshaler runti return msg, metadata, err } -var filter_UserService_DeleteUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} +var filter_UserService_DeleteUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} func request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( @@ -245,13 +245,13 @@ func request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Mar err error ) io.Copy(io.Discard, req.Body) - val, ok := pathParams["user.id"] + val, ok := pathParams["id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + protoReq.Id, err = runtime.Int64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) @@ -269,13 +269,13 @@ func local_request_UserService_DeleteUser_0(ctx context.Context, marshaler runti metadata runtime.ServerMetadata err error ) - val, ok := pathParams["user.id"] + val, ok := pathParams["id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + protoReq.Id, err = runtime.Int64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) @@ -293,16 +293,16 @@ func request_UserService_UpdateUserStatus_0(ctx context.Context, marshaler runti metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - val, ok := pathParams["user.id"] + val, ok := pathParams["id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + protoReq.Id, err = runtime.Int64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } msg, err := client.UpdateUserStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -314,45 +314,37 @@ func local_request_UserService_UpdateUserStatus_0(ctx context.Context, marshaler metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - val, ok := pathParams["user.id"] + val, ok := pathParams["id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + protoReq.Id, err = runtime.Int64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } msg, err := server.UpdateUserStatus(ctx, &protoReq) return msg, metadata, err } -var filter_UserService_UpdateUserRoles_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - func request_UserService_UpdateUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateUserRolesRequest metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - val, ok := pathParams["user.id"] + val, ok := pathParams["id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + protoReq.Id, err = runtime.Int64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUserRoles_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } msg, err := client.UpdateUserRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -364,22 +356,16 @@ func local_request_UserService_UpdateUserRoles_0(ctx context.Context, marshaler metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - val, ok := pathParams["user.id"] + val, ok := pathParams["id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + protoReq.Id, err = runtime.Int64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUserRoles_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } msg, err := server.UpdateUserRoles(ctx, &protoReq) return msg, metadata, err @@ -391,14 +377,14 @@ func request_UserService_ResetUserPassword_0(ctx context.Context, marshaler runt metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Password); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - protoReq.Id, err = runtime.String(val) + protoReq.Id, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -412,14 +398,14 @@ func local_request_UserService_ResetUserPassword_0(ctx context.Context, marshale metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Password); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["id"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } - protoReq.Id, err = runtime.String(val) + protoReq.Id, err = runtime.Int64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } @@ -539,7 +525,7 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/DeleteUser", runtime.WithHTTPPathPattern("/sys/users/{user.id}")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/DeleteUser", runtime.WithHTTPPathPattern("/sys/users/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -559,7 +545,7 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserStatus", runtime.WithHTTPPathPattern("/sys/users/{user.id}/status")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserStatus", runtime.WithHTTPPathPattern("/sys/users/{id}/status")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -579,7 +565,7 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserRoles", runtime.WithHTTPPathPattern("/sys/users/{user.id}/roles")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserRoles", runtime.WithHTTPPathPattern("/sys/users/{id}/roles")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -742,7 +728,7 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/DeleteUser", runtime.WithHTTPPathPattern("/sys/users/{user.id}")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/DeleteUser", runtime.WithHTTPPathPattern("/sys/users/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -759,7 +745,7 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserStatus", runtime.WithHTTPPathPattern("/sys/users/{user.id}/status")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserStatus", runtime.WithHTTPPathPattern("/sys/users/{id}/status")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -776,7 +762,7 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserRoles", runtime.WithHTTPPathPattern("/sys/users/{user.id}/roles")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.UserService/UpdateUserRoles", runtime.WithHTTPPathPattern("/sys/users/{id}/roles")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -815,9 +801,9 @@ var ( pattern_UserService_GetUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "users", "id"}, "")) pattern_UserService_CreateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "users"}, "")) pattern_UserService_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "users", "user.id"}, "")) - pattern_UserService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "users", "user.id"}, "")) - pattern_UserService_UpdateUserStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"sys", "users", "user.id", "status"}, "")) - pattern_UserService_UpdateUserRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"sys", "users", "user.id", "roles"}, "")) + pattern_UserService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "users", "id"}, "")) + pattern_UserService_UpdateUserStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"sys", "users", "id", "status"}, "")) + pattern_UserService_UpdateUserRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"sys", "users", "id", "roles"}, "")) pattern_UserService_ResetUserPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4}, []string{"sys", "users", "id", "password", "reset"}, "")) ) diff --git a/api/v1/services/system/user.pb.validate.go b/api/v1/services/system/user.pb.validate.go index 1dbd70f7..6f8b2eb0 100644 --- a/api/v1/services/system/user.pb.validate.go +++ b/api/v1/services/system/user.pb.validate.go @@ -299,33 +299,41 @@ func (m *UpdateUserStatusRequest) validate(all bool) error { var errors []error - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateUserStatusRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) + // no validation rules for Id + + // no validation rules for Status + + if m.User != nil { + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUserStatusRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUserStatusRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } } - case interface{ Validate() error }: + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - errors = append(errors, UpdateUserStatusRequestValidationError{ + return UpdateUserStatusRequestValidationError{ field: "User", reason: "embedded message failed validation", cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateUserStatusRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, + } } } + } if len(errors) > 0 { @@ -534,34 +542,7 @@ func (m *ResetUserPasswordRequest) validate(all bool) error { // no validation rules for Id - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResetUserPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResetUserPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResetUserPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for Password if len(errors) > 0 { return ResetUserPasswordRequestMultiError(errors) @@ -1829,33 +1810,39 @@ func (m *DeleteUserRequest) validate(all bool) error { var errors []error - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) + // no validation rules for Id + + if m.User != nil { + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteUserRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } } - case interface{ Validate() error }: + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - errors = append(errors, DeleteUserRequestValidationError{ + return DeleteUserRequestValidationError{ field: "User", reason: "embedded message failed validation", cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, + } } } + } if len(errors) > 0 { diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 85075ca1..2627437b 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -113,9 +113,9 @@ func RegisterUserServiceBridgeServer(s *http.Server, srv UserServiceHookedBridge r.GET("/sys/users/:id", _UserService_GetUser0_Bridge_Handler(srv)) r.POST("/sys/users", _UserService_CreateUser0_Bridge_Handler(srv)) r.PUT("/sys/users/:user.id", _UserService_UpdateUser0_Bridge_Handler(srv)) - r.DELETE("/sys/users/:user.id", _UserService_DeleteUser0_Bridge_Handler(srv)) - r.PUT("/sys/users/:user.id/status", _UserService_UpdateUserStatus0_Bridge_Handler(srv)) - r.PUT("/sys/users/:user.id/roles", _UserService_UpdateUserRoles0_Bridge_Handler(srv)) + r.DELETE("/sys/users/:id", _UserService_DeleteUser0_Bridge_Handler(srv)) + r.PUT("/sys/users/:id/status", _UserService_UpdateUserStatus0_Bridge_Handler(srv)) + r.PUT("/sys/users/:id/roles", _UserService_UpdateUserRoles0_Bridge_Handler(srv)) r.POST("/sys/users/:id/password/reset", _UserService_ResetUserPassword0_Bridge_Handler(srv)) } @@ -278,7 +278,7 @@ func _UserService_DeleteUser0_Bridge_Handler(srv UserServiceHookedBridger) func( func _UserService_UpdateUserStatus0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateUserStatusRequest - if err := ctx.Bind(&in.User); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -307,7 +307,7 @@ func _UserService_UpdateUserStatus0_Bridge_Handler(srv UserServiceHookedBridger) func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateUserRolesRequest - if err := ctx.Bind(&in.User); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -336,7 +336,7 @@ func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceHookedBridger) func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ResetUserPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { + if err := ctx.Bind(&in.Password); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/user_http.pb.go b/api/v1/services/system/user_http.pb.go index 4ab1e025..950d7350 100644 --- a/api/v1/services/system/user_http.pb.go +++ b/api/v1/services/system/user_http.pb.go @@ -51,9 +51,9 @@ func RegisterUserServiceHTTPServer(s *http.Server, srv UserServiceHTTPServer) { r.GET("/sys/users/{id}", _UserService_GetUser0_HTTP_Handler(srv)) r.POST("/sys/users", _UserService_CreateUser0_HTTP_Handler(srv)) r.PUT("/sys/users/{user.id}", _UserService_UpdateUser0_HTTP_Handler(srv)) - r.DELETE("/sys/users/{user.id}", _UserService_DeleteUser0_HTTP_Handler(srv)) - r.PUT("/sys/users/{user.id}/status", _UserService_UpdateUserStatus0_HTTP_Handler(srv)) - r.PUT("/sys/users/{user.id}/roles", _UserService_UpdateUserRoles0_HTTP_Handler(srv)) + r.DELETE("/sys/users/{id}", _UserService_DeleteUser0_HTTP_Handler(srv)) + r.PUT("/sys/users/{id}/status", _UserService_UpdateUserStatus0_HTTP_Handler(srv)) + r.PUT("/sys/users/{id}/roles", _UserService_UpdateUserRoles0_HTTP_Handler(srv)) r.POST("/sys/users/{id}/password/reset", _UserService_ResetUserPassword0_HTTP_Handler(srv)) } @@ -192,7 +192,7 @@ func _UserService_DeleteUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx h func _UserService_UpdateUserStatus0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateUserStatusRequest - if err := ctx.Bind(&in.User); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -217,7 +217,7 @@ func _UserService_UpdateUserStatus0_HTTP_Handler(srv UserServiceHTTPServer) func func _UserService_UpdateUserRoles0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateUserRolesRequest - if err := ctx.Bind(&in.User); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -242,7 +242,7 @@ func _UserService_UpdateUserRoles0_HTTP_Handler(srv UserServiceHTTPServer) func( func _UserService_ResetUserPassword0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in ResetUserPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { + if err := ctx.Bind(&in.Password); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -302,7 +302,7 @@ func (c *UserServiceHTTPClientImpl) CreateUser(ctx context.Context, in *CreateUs func (c *UserServiceHTTPClientImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...http.CallOption) (*DeleteUserResponse, error) { var out DeleteUserResponse - pattern := "/sys/users/{user.id}" + pattern := "/sys/users/{id}" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationUserServiceDeleteUser)) opts = append(opts, http.PathTemplate(pattern)) @@ -359,7 +359,7 @@ func (c *UserServiceHTTPClientImpl) ResetUserPassword(ctx context.Context, in *R path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationUserServiceResetUserPassword)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in.Password, &out, opts...) if err != nil { return nil, err } @@ -382,11 +382,11 @@ func (c *UserServiceHTTPClientImpl) UpdateUser(ctx context.Context, in *UpdateUs // UpdateUserRoles UpdateUserRoles update the user roles func (c *UserServiceHTTPClientImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest, opts ...http.CallOption) (*UpdateUserRolesResponse, error) { var out UpdateUserRolesResponse - pattern := "/sys/users/{user.id}/roles" + pattern := "/sys/users/{id}/roles" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationUserServiceUpdateUserRoles)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) + err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) if err != nil { return nil, err } @@ -396,11 +396,11 @@ func (c *UserServiceHTTPClientImpl) UpdateUserRoles(ctx context.Context, in *Upd // UpdateUserStatus UpdateUserStatus Update the status of the user information func (c *UserServiceHTTPClientImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest, opts ...http.CallOption) (*UpdateUserStatusResponse, error) { var out UpdateUserStatusResponse - pattern := "/sys/users/{user.id}/status" + pattern := "/sys/users/{id}/status" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationUserServiceUpdateUserStatus)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) + err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index 36899fd2..82f5b117 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -595,38 +595,30 @@ type User struct { Name string `protobuf:"bytes,11,opt,name=name,proto3" json:"name,omitempty"` // user.field.gender Gender string `protobuf:"bytes,12,opt,name=gender,proto3" json:"gender,omitempty"` - // user.field.password - // @Decrypted don't show this field in response - Password string `protobuf:"bytes,13,opt,name=password,proto3" json:"password,omitempty"` - // user.field.confirm_password - ConfirmPassword string `protobuf:"bytes,14,opt,name=confirm_password,proto3" json:"confirm_password,omitempty"` - // user.field.salt - // @Decrypted don't show this field in response - Salt string `protobuf:"bytes,15,opt,name=salt,proto3" json:"salt,omitempty"` // user.field.phone - Phone string `protobuf:"bytes,16,opt,name=phone,proto3" json:"phone,omitempty"` + Phone string `protobuf:"bytes,13,opt,name=phone,proto3" json:"phone,omitempty"` // user.field.email - Email string `protobuf:"bytes,17,opt,name=email,proto3" json:"email,omitempty"` + Email string `protobuf:"bytes,14,opt,name=email,proto3" json:"email,omitempty"` // user.field.remark - Remark string `protobuf:"bytes,18,opt,name=remark,proto3" json:"remark,omitempty"` + Remark string `protobuf:"bytes,15,opt,name=remark,proto3" json:"remark,omitempty"` // user.field.token - Token string `protobuf:"bytes,19,opt,name=token,proto3" json:"token,omitempty"` + Token string `protobuf:"bytes,16,opt,name=token,proto3" json:"token,omitempty"` // user.field.status - Status int32 `protobuf:"varint,20,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` // user.field.last_login_ip - LastLoginIp string `protobuf:"bytes,21,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` + LastLoginIp string `protobuf:"bytes,18,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` // user.field.last_login_time - LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` + LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,19,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` // user.field.sanction_date - SanctionDate *timestamppb.Timestamp `protobuf:"bytes,23,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` + SanctionDate *timestamppb.Timestamp `protobuf:"bytes,20,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` // user.field.manager_id - ManagerId int64 `protobuf:"varint,24,opt,name=manager_id,proto3" json:"manager_id,omitempty"` + ManagerId int64 `protobuf:"varint,21,opt,name=manager_id,proto3" json:"manager_id,omitempty"` // user.field.manager - Manager string `protobuf:"bytes,25,opt,name=manager,proto3" json:"manager,omitempty"` + Manager string `protobuf:"bytes,22,opt,name=manager,proto3" json:"manager,omitempty"` // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,26,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*Role `protobuf:"bytes,23,rep,name=roles,proto3" json:"roles,omitempty"` // Role Ids holds the value of the role_ids - RoleIds []int64 `protobuf:"varint,27,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` + RoleIds []int64 `protobuf:"varint,24,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -745,27 +737,6 @@ func (x *User) GetGender() string { return "" } -func (x *User) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -func (x *User) GetConfirmPassword() string { - if x != nil { - return x.ConfirmPassword - } - return "" -} - -func (x *User) GetSalt() string { - if x != nil { - return x.Salt - } - return "" -} - func (x *User) GetPhone() string { if x != nil { return x.Phone @@ -2834,7 +2805,7 @@ const file_types_system_proto_rawDesc = "" + "role_menus\x12?\n" + "\n" + "user_roles\x18\x04 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + - "user_roles\"\xaa\a\n" + + "user_roles\"\xce\x06\n" + "\x04User\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + @@ -2850,24 +2821,21 @@ const file_types_system_proto_rawDesc = "" + "\x06avatar\x18\n" + " \x01(\tR\x06avatar\x12\x12\n" + "\x04name\x18\v \x01(\tR\x04name\x12\x16\n" + - "\x06gender\x18\f \x01(\tR\x06gender\x12\x1a\n" + - "\bpassword\x18\r \x01(\tR\bpassword\x12*\n" + - "\x10confirm_password\x18\x0e \x01(\tR\x10confirm_password\x12\x12\n" + - "\x04salt\x18\x0f \x01(\tR\x04salt\x12\x14\n" + - "\x05phone\x18\x10 \x01(\tR\x05phone\x12\x14\n" + - "\x05email\x18\x11 \x01(\tR\x05email\x12\x16\n" + - "\x06remark\x18\x12 \x01(\tR\x06remark\x12\x14\n" + - "\x05token\x18\x13 \x01(\tR\x05token\x12\x16\n" + - "\x06status\x18\x14 \x01(\x05R\x06status\x12$\n" + - "\rlast_login_ip\x18\x15 \x01(\tR\rlast_login_ip\x12D\n" + - "\x0flast_login_time\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12E\n" + - "\rsanction_date\x18\x17 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x12\x1e\n" + + "\x06gender\x18\f \x01(\tR\x06gender\x12\x14\n" + + "\x05phone\x18\r \x01(\tR\x05phone\x12\x14\n" + + "\x05email\x18\x0e \x01(\tR\x05email\x12\x16\n" + + "\x06remark\x18\x0f \x01(\tR\x06remark\x12\x14\n" + + "\x05token\x18\x10 \x01(\tR\x05token\x12\x16\n" + + "\x06status\x18\x11 \x01(\x05R\x06status\x12$\n" + + "\rlast_login_ip\x18\x12 \x01(\tR\rlast_login_ip\x12D\n" + + "\x0flast_login_time\x18\x13 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12E\n" + + "\rsanction_date\x18\x14 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x12\x1e\n" + "\n" + - "manager_id\x18\x18 \x01(\x03R\n" + + "manager_id\x18\x15 \x01(\x03R\n" + "manager_id\x12\x18\n" + - "\amanager\x18\x19 \x01(\tR\amanager\x121\n" + - "\x05roles\x18\x1a \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + - "\brole_ids\x18\x1b \x03(\x03R\brole_idsB\x10\n" + + "\amanager\x18\x16 \x01(\tR\amanager\x121\n" + + "\x05roles\x18\x17 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + + "\brole_ids\x18\x18 \x03(\x03R\brole_idsB\x10\n" + "\x0e_sanction_date\"\x7f\n" + "\tUserEdges\x121\n" + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12?\n" + diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index f9a8dc81..6e0eb1da 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -1254,12 +1254,6 @@ func (m *User) validate(all bool) error { // no validation rules for Gender - // no validation rules for Password - - // no validation rules for ConfirmPassword - - // no validation rules for Salt - // no validation rules for Phone // no validation rules for Email diff --git a/cmd/system/wire.go b/cmd/system/wire.go index 7fecd230..43165940 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -12,10 +12,6 @@ import ( "github.com/go-kratos/kratos/v2" "github.com/google/wire" "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" - "github.com/origadmin/toolkits/crypto/hash/types" "origadmin/application/admin/internal/conf" confpb "origadmin/application/admin/internal/conf/pb" @@ -26,17 +22,6 @@ import ( "origadmin/application/admin/internal/features/system/service" ) -func provideHasher() (hash.Crypto, error) { - // Using a default cost for bcrypt. In a real application, this might come from config. - return hash.NewCrypto(types.BCRYPT, bcrypt.WithCost(bcrypt.DefaultCost)) -} - -func provideLogger(app *runtime.App) log.Logger { - return app.Logger() -} - -var infraProviderSet = wire.NewSet(provideLogger, provideHasher) - // wireApp init kratos application. func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { panic(wire.Build( diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index 3d191ef4..89f32380 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -33,39 +33,20 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err if err != nil { return nil, nil, err } - resourceRepo := dal.NewResourceRepo(dataData) - resourceUseCase, err := biz.NewResourceUseCase(resourceRepo) - if err != nil { - cleanup() - return nil, nil, err - } - roleRepo, err := dal.NewRoleRepo(dataData) - if err != nil { - cleanup() - return nil, nil, err - } - roleUseCase, err := biz.NewRoleUseCase(roleRepo) - if err != nil { - cleanup() - return nil, nil, err - } - userRepo := dal.NewUserRepo(dataData) + database := data.ProvideDatabase(dataData) + resourceRepo := dal.NewResourceRepo(database) + resourceUseCase := biz.NewResourceUseCase(resourceRepo) + roleRepo := dal.NewRoleRepo(database) + roleUseCase := biz.NewRoleUseCase(roleRepo) + userRepo := dal.NewUserRepo(database) crypto, err := provideHasher() if err != nil { cleanup() return nil, nil, err } - userUseCase, err := biz.NewUserUseCase(userRepo, crypto) - if err != nil { - cleanup() - return nil, nil, err - } - permissionRepo := dal.NewPermissionRepo(dataData) - permissionUseCase, err := biz.NewPermissionUseCase(permissionRepo) - if err != nil { - cleanup() - return nil, nil, err - } + userUseCase := biz.NewUserUseCase(userRepo, crypto) + permissionRepo := dal.NewPermissionRepo(database) + permissionUseCase := biz.NewPermissionUseCase(permissionRepo) systemService := service.New(resourceUseCase, roleUseCase, userUseCase, permissionUseCase) v := provideLogger(app) v2, err := server.NewServers(servers, systemService, v) diff --git a/internal/conf/config.go b/internal/conf/config.go index 223d230c..dff431f1 100644 --- a/internal/conf/config.go +++ b/internal/conf/config.go @@ -7,6 +7,7 @@ import ( loggerv1 "github.com/origadmin/runtime/api/gen/go/config/logger/v1" middlewarev1 "github.com/origadmin/runtime/api/gen/go/config/middleware/v1" transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" + "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/interfaces" confpb "origadmin/application/admin/internal/conf/pb" ) @@ -76,8 +77,6 @@ StructuredConfig, error) { return c, nil } -func New() Bootstrap.ConfigTransformer { - return &Config{ - Bootstrap: new(confpb.Bootstrap), - } +func New() bootstrap.ConfigTransformer { + return &Config{} } diff --git a/internal/data/casbin-adapter.dal.go b/internal/features/auth/dal/casbin-adapter.dal.go similarity index 99% rename from internal/data/casbin-adapter.dal.go rename to internal/features/auth/dal/casbin-adapter.dal.go index 7da9ed2a..5d2474fc 100644 --- a/internal/data/casbin-adapter.dal.go +++ b/internal/features/auth/dal/casbin-adapter.dal.go @@ -2,7 +2,7 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -package data +package dal import ( "context" diff --git a/internal/features/system/biz/permission.go b/internal/features/system/biz/permission.go index e6d6b477..a91c7c73 100644 --- a/internal/features/system/biz/permission.go +++ b/internal/features/system/biz/permission.go @@ -18,46 +18,28 @@ type PermissionUseCase struct { repo dto.PermissionRepo } +// NewPermissionUseCase new a Permission use case. +func NewPermissionUseCase(repo dto.PermissionRepo) *PermissionUseCase { + return &PermissionUseCase{repo: repo} +} + func (uc *PermissionUseCase) ListPermissions(ctx context.Context, in *system.ListPermissionsRequest) ([]*types.Permission, int32, error) { - result, total, err := uc.repo.List(ctx, in) - if err != nil { - return nil, 0, err - } - return result, total, nil + queryOpt := dto.ListPermissionsRequestToQueryOption(in) + return uc.repo.List(ctx, queryOpt) } func (uc *PermissionUseCase) GetPermission(ctx context.Context, id int64) (*types.Permission, error) { - result, err := uc.repo.Get(ctx, id) - if err != nil { - return nil, err - } - return result, nil + return uc.repo.Get(ctx, id) } func (uc *PermissionUseCase) CreatePermission(ctx context.Context, in *types.Permission) (*types.Permission, error) { - result, err := uc.repo.Create(ctx, in) - if err != nil { - return nil, err - } - return result, nil + return uc.repo.Create(ctx, in) } func (uc *PermissionUseCase) UpdatePermission(ctx context.Context, in *types.Permission) (*types.Permission, error) { - result, err := uc.repo.Update(ctx, in) - if err != nil { - return nil, err - } - return result, nil + return uc.repo.Update(ctx, in) } func (uc *PermissionUseCase) DeletePermission(ctx context.Context, id int64) error { - if err := uc.repo.Delete(ctx, id); err != nil { - return err - } - return nil -} - -// NewPermissionUseCase new a Permission use case. -func NewPermissionUseCase(repo dto.PermissionRepo) (*PermissionUseCase, error) { - return &PermissionUseCase{repo: repo}, nil + return uc.repo.Delete(ctx, id) } diff --git a/internal/features/system/biz/resource.go b/internal/features/system/biz/resource.go index f8c2bb96..c3f07827 100644 --- a/internal/features/system/biz/resource.go +++ b/internal/features/system/biz/resource.go @@ -18,46 +18,28 @@ type ResourceUseCase struct { repo dto.ResourceRepo } +// NewResourceUseCase new a Resource use case. +func NewResourceUseCase(repo dto.ResourceRepo) *ResourceUseCase { + return &ResourceUseCase{repo: repo} +} + func (uc *ResourceUseCase) ListResources(ctx context.Context, in *system.ListResourcesRequest) ([]*types.Resource, int32, error) { - result, total, err := uc.repo.List(ctx, in) - if err != nil { - return nil, 0, err - } - return result, total, nil + queryOpt := dto.ListResourcesRequestToQueryOption(in) + return uc.repo.List(ctx, queryOpt) } func (uc *ResourceUseCase) GetResource(ctx context.Context, id int64) (*types.Resource, error) { - result, err := uc.repo.Get(ctx, id) - if err != nil { - return nil, err - } - return result, nil + return uc.repo.Get(ctx, id) } func (uc *ResourceUseCase) CreateResource(ctx context.Context, in *types.Resource) (*types.Resource, error) { - result, err := uc.repo.Create(ctx, in) - if err != nil { - return nil, err - } - return result, nil + return uc.repo.Create(ctx, in) } func (uc *ResourceUseCase) UpdateResource(ctx context.Context, in *types.Resource) (*types.Resource, error) { - result, err := uc.repo.Update(ctx, in) - if err != nil { - return nil, err - } - return result, nil + return uc.repo.Update(ctx, in) } func (uc *ResourceUseCase) DeleteResource(ctx context.Context, id int64) error { - if err := uc.repo.Delete(ctx, id); err != nil { - return err - } - return nil -} - -// NewResourceUseCase new a Resource use case. -func NewResourceUseCase(repo dto.ResourceRepo) (*ResourceUseCase, error) { - return &ResourceUseCase{repo: repo}, nil + return uc.repo.Delete(ctx, id) } diff --git a/internal/features/system/biz/role.go b/internal/features/system/biz/role.go index 913a73b2..fb5618d9 100644 --- a/internal/features/system/biz/role.go +++ b/internal/features/system/biz/role.go @@ -18,46 +18,32 @@ type RoleUseCase struct { repo dto.RoleRepo } +// NewRoleUseCase new a Role use case. +func NewRoleUseCase(repo dto.RoleRepo) *RoleUseCase { + return &RoleUseCase{repo: repo} +} + func (uc *RoleUseCase) ListRoles(ctx context.Context, in *system.ListRolesRequest) ([]*types.Role, int32, error) { - result, total, err := uc.repo.List(ctx, in) - if err != nil { - return nil, 0, err - } - return result, total, nil + queryOpt := dto.ListRolesRequestToQueryOption(in) + return uc.repo.List(ctx, queryOpt) } func (uc *RoleUseCase) GetRole(ctx context.Context, id int64) (*types.Role, error) { - result, err := uc.repo.Get(ctx, id) - if err != nil { - return nil, err - } - return result, nil + return uc.repo.Get(ctx, id) } func (uc *RoleUseCase) CreateRole(ctx context.Context, in *types.Role) (*types.Role, error) { - result, err := uc.repo.Create(ctx, in) - if err != nil { - return nil, err - } - return result, nil + return uc.repo.Create(ctx, in) } func (uc *RoleUseCase) UpdateRole(ctx context.Context, in *types.Role) (*types.Role, error) { - result, err := uc.repo.Update(ctx, in) - if err != nil { - return nil, err - } - return result, nil + return uc.repo.Update(ctx, in) } func (uc *RoleUseCase) DeleteRole(ctx context.Context, id int64) error { - if err := uc.repo.Delete(ctx, id); err != nil { - return err - } - return nil + return uc.repo.Delete(ctx, id) } -// NewRoleUseCase new a Role use case. -func NewRoleUseCase(repo dto.RoleRepo) (*RoleUseCase, error) { - return &RoleUseCase{repo: repo}, nil +func (uc *RoleUseCase) UpdateRolePermissions(ctx context.Context, id int64, permissionIDs []int64) error { + return uc.repo.UpdatePermissions(ctx, id, permissionIDs) } diff --git a/internal/features/system/biz/user.go b/internal/features/system/biz/user.go index b7b9612b..c5499845 100644 --- a/internal/features/system/biz/user.go +++ b/internal/features/system/biz/user.go @@ -21,22 +21,21 @@ type UserUseCase struct { hasher hash.Crypto } +// NewUserUseCase new a User use case. +func NewUserUseCase(repo dto.UserRepo, hasher hash.Crypto) *UserUseCase { + return &UserUseCase{repo: repo, hasher: hasher} +} + func (uc *UserUseCase) ListUserResources(ctx context.Context, id int64) ([]*types.Resource, error) { - // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer - // and added to the interface. For now, we'll return an error. - return nil, fmt.Errorf("ListUserResources not implemented") + return uc.repo.ListResourceByUserID(ctx, id) } func (uc *UserUseCase) UpdateUserRoles(ctx context.Context, id int64, roleIDs []int64) error { - // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer - // and added to the interface. For now, we'll return an error. - return fmt.Errorf("UpdateUserRoles not implemented") + return uc.repo.AddRoleIDs(ctx, id, roleIDs) } func (uc *UserUseCase) UpdateUserStatus(ctx context.Context, id int64, status int32) error { - // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer - // and added to the interface. For now, we'll return an error. - return fmt.Errorf("UpdateUserStatus not implemented") + return uc.repo.UpdateUserStatus(ctx, id, status) } func (uc *UserUseCase) ResetUserPassword(ctx context.Context, id int64, password string) error { @@ -45,15 +44,12 @@ func (uc *UserUseCase) ResetUserPassword(ctx context.Context, id int64, password } func (uc *UserUseCase) ListUsers(ctx context.Context, in *system.ListUsersRequest) ([]*types.User, int32, error) { - // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer - // and added to the interface. For now, we'll return an error. - return nil, 0, fmt.Errorf("ListUsers not implemented") + queryOpt := dto.ListUsersRequestToQueryOption(in) + return uc.repo.List(ctx, queryOpt) } func (uc *UserUseCase) GetUser(ctx context.Context, id int64) (*types.User, error) { - // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer - // and added to the interface. For now, we'll return an error. - return nil, fmt.Errorf("GetUser not implemented") + return uc.repo.Get(ctx, id) } func (uc *UserUseCase) CreateUser(ctx context.Context, in *types.User, password string) (*types.User, error) { @@ -61,28 +57,15 @@ func (uc *UserUseCase) CreateUser(ctx context.Context, in *types.User, password if err != nil { return nil, err } - in.Password = hashedPassword - fmt.Println("Create new user username:", in.Username, "password:", password) - // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer - // and added to the interface. For now, we'll return an error. - return nil, fmt.Errorf("CreateUser not implemented") + return uc.repo.Create(ctx, in, hashedPassword) } func (uc *UserUseCase) UpdateUser(ctx context.Context, in *types.User) (*types.User, error) { - // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer - // and added to the interface. For now, we'll return an error. - return nil, fmt.Errorf("UpdateUser not implemented") + return uc.repo.Update(ctx, in) } func (uc *UserUseCase) DeleteUser(ctx context.Context, id int64) error { - // This method is not in the biz.UserRepo interface, so it needs to be implemented in the data layer - // and added to the interface. For now, we'll return an error. - return fmt.Errorf("DeleteUser not implemented") -} - -// NewUserUseCase new a User use case. -func NewUserUseCase(repo dto.UserRepo, hasher hash.Crypto) (*UserUseCase, error) { - return &UserUseCase{repo: repo, hasher: hasher}, nil + return uc.repo.Delete(ctx, id) } diff --git a/internal/features/system/dal/permission.go b/internal/features/system/dal/permission.go index 6126be1f..cfec7b0b 100644 --- a/internal/features/system/dal/permission.go +++ b/internal/features/system/dal/permission.go @@ -7,11 +7,11 @@ package dal import ( "context" - "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/repo" ) type permissionRepo struct { @@ -23,12 +23,8 @@ func NewPermissionRepo(db *ent.Database) dto.PermissionRepo { return &permissionRepo{db: db} } -func (r *permissionRepo) Get(ctx context.Context, id int64, opts ...*dto.PermissionQueryOptions) (*types.Permission, error) { - opt := &dto.PermissionQueryOptions{} - if len(opts) > 0 { - opt = opts[0] - } - +func (r *permissionRepo) Get(ctx context.Context, id int64, opts ...*dto.PermissionQueryOption) (*types.Permission, error) { + opt := repo.GetFirstOption(opts...) query := r.db.Permission(ctx).Query().Where(permission.ID(id)) if opt.WithResources { @@ -45,7 +41,7 @@ func (r *permissionRepo) Get(ctx context.Context, id int64, opts ...*dto.Permiss return dto.ConvertPermissionToPermissionPB(result), nil } -func (r *permissionRepo) Create(ctx context.Context, p *types.Permission, opts ...*dto.PermissionCreateOptions) (*types.Permission, error) { +func (r *permissionRepo) Create(ctx context.Context, p *types.Permission, opts ...*dto.PermissionCreateOption) (*types.Permission, error) { entPermission := dto.ConvertPermissionPBToPermission(p) create := r.db.Permission(ctx).Create().SetPermission(entPermission) @@ -62,7 +58,7 @@ func (r *permissionRepo) Delete(ctx context.Context, id int64) error { return r.db.Permission(ctx).DeleteOneID(id).Exec(ctx) } -func (r *permissionRepo) Update(ctx context.Context, p *types.Permission, opts ...*dto.PermissionUpdateOptions) (*types.Permission, error) { +func (r *permissionRepo) Update(ctx context.Context, p *types.Permission, opts ...*dto.PermissionUpdateOption) (*types.Permission, error) { entPermission := dto.ConvertPermissionPBToPermission(p) update := r.db.Permission(ctx).UpdateOneID(p.Id).SetPermission(entPermission) @@ -75,16 +71,12 @@ func (r *permissionRepo) Update(ctx context.Context, p *types.Permission, opts . return dto.ConvertPermissionToPermissionPB(saved), nil } -func (r *permissionRepo) List(ctx context.Context, in *system.ListPermissionsRequest, opts ...*dto.PermissionQueryOptions) ([]*types.Permission, int32, error) { - opt := &dto.PermissionQueryOptions{} - if len(opts) > 0 { - opt = opts[0] - } - +func (r *permissionRepo) List(ctx context.Context, opts ...*dto.PermissionQueryOption) ([]*types.Permission, int32, error) { + opt := repo.GetFirstOption(opts...) query := r.db.Permission(ctx).Query() - if len(in.DataScopes) > 0 { - query = query.Where(permission.DataScopeIn(in.DataScopes...)) + if len(opt.DataScopes) > 0 { + query.Where(permission.DataScopeIn(opt.DataScopes...)) } if opt.Page > 0 && opt.PageSize > 0 { diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index fcb38040..6316daf1 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -8,11 +8,11 @@ import ( "context" "strconv" - "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/repo" ) type resourceRepo struct { @@ -28,12 +28,8 @@ func NewResourceRepo(db *ent.Database) dto.ResourceRepo { } } -func (r *resourceRepo) Get(ctx context.Context, id int64, opts ...*dto.ResourceQueryOptions) (*types.Resource, error) { - opt := &dto.ResourceQueryOptions{} - if len(opts) > 0 { - opt = opts[0] - } - +func (r *resourceRepo) Get(ctx context.Context, id int64, opts ...*dto.ResourceQueryOption) (*types.Resource, error) { + opt := repo.GetFirstOption(opts...) query := r.db.Resource(ctx).Query().Where(resource.ID(id)) if opt.WithPermissions { @@ -47,7 +43,7 @@ func (r *resourceRepo) Get(ctx context.Context, id int64, opts ...*dto.ResourceQ return dto.ConvertResourceToResourcePB(result), nil } -func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ...*dto.ResourceCreateOptions) (*types.Resource, error) { +func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ...*dto.ResourceCreateOption) (*types.Resource, error) { if res.ParentId > 0 { parent, err := r.db.Resource(ctx).Get(ctx, res.ParentId) if err != nil { @@ -72,7 +68,7 @@ func (r *resourceRepo) Delete(ctx context.Context, id int64) error { return r.db.Resource(ctx).DeleteOneID(id).Exec(ctx) } -func (r *resourceRepo) Update(ctx context.Context, res *types.Resource, opts ...*dto.ResourceUpdateOptions) (*types.Resource, error) { +func (r *resourceRepo) Update(ctx context.Context, res *types.Resource, opts ...*dto.ResourceUpdateOption) (*types.Resource, error) { entResource := dto.ConvertResourcePBToResource(res) update := r.db.Resource(ctx).UpdateOneID(res.Id).SetResource(entResource) @@ -85,12 +81,8 @@ func (r *resourceRepo) Update(ctx context.Context, res *types.Resource, opts ... return dto.ConvertResourceToResourcePB(saved), nil } -func (r *resourceRepo) List(ctx context.Context, in *system.ListResourcesRequest, opts ...*dto.ResourceQueryOptions) ([]*types.Resource, int32, error) { - opt := &dto.ResourceQueryOptions{} - if len(opts) > 0 { - opt = opts[0] - } - +func (r *resourceRepo) List(ctx context.Context, opts ...*dto.ResourceQueryOption) ([]*types.Resource, int32, error) { + opt := repo.GetFirstOption(opts...) query := r.db.Resource(ctx).Query() if opt.Page > 0 && opt.PageSize > 0 { diff --git a/internal/features/system/dal/role.go b/internal/features/system/dal/role.go index 27654faa..763dc205 100644 --- a/internal/features/system/dal/role.go +++ b/internal/features/system/dal/role.go @@ -9,11 +9,11 @@ import ( "errors" "github.com/origadmin/toolkits/crypto/rand" - "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/role" "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/repo" ) type roleRepo struct { @@ -27,12 +27,8 @@ func NewRoleRepo(db *ent.Database) dto.RoleRepo { return &roleRepo{db: db, gen: generator} } -func (r *roleRepo) Get(ctx context.Context, id int64, opts ...*dto.RoleQueryOptions) (*types.Role, error) { - opt := &dto.RoleQueryOptions{} - if len(opts) > 0 { - opt = opts[0] - } - +func (r *roleRepo) Get(ctx context.Context, id int64, opts ...*dto.RoleQueryOption) (*types.Role, error) { + opt := repo.GetFirstOption(opts...) query := r.db.Role(ctx).Query().Where(role.ID(id)) if opt.WithPermissions { @@ -46,7 +42,7 @@ func (r *roleRepo) Get(ctx context.Context, id int64, opts ...*dto.RoleQueryOpti return dto.ConvertRoleToRolePB(result), nil } -func (r *roleRepo) Create(ctx context.Context, rl *types.Role, opts ...*dto.RoleCreateOptions) (*types.Role, error) { +func (r *roleRepo) Create(ctx context.Context, rl *types.Role, opts ...*dto.RoleCreateOption) (*types.Role, error) { if rl.Keyword == "" { randString, err := r.gen.RandString(12) if err != nil { @@ -73,7 +69,7 @@ func (r *roleRepo) Delete(ctx context.Context, id int64) error { return r.db.Role(ctx).DeleteOneID(id).Exec(ctx) } -func (r *roleRepo) Update(ctx context.Context, rl *types.Role, opts ...*dto.RoleUpdateOptions) (*types.Role, error) { +func (r *roleRepo) Update(ctx context.Context, rl *types.Role, opts ...*dto.RoleUpdateOption) (*types.Role, error) { entRole := dto.ConvertRolePBToRole(rl) update := r.db.Role(ctx).UpdateOneID(rl.Id).SetRole(entRole) // ... handle partial updates based on opts ... @@ -85,16 +81,12 @@ func (r *roleRepo) Update(ctx context.Context, rl *types.Role, opts ...*dto.Role return dto.ConvertRoleToRolePB(saved), nil } -func (r *roleRepo) List(ctx context.Context, in *system.ListRolesRequest, opts ...*dto.RoleQueryOptions) ([]*types.Role, int32, error) { - opt := &dto.RoleQueryOptions{} - if len(opts) > 0 { - opt = opts[0] - } - +func (r *roleRepo) List(ctx context.Context, opts ...*dto.RoleQueryOption) ([]*types.Role, int32, error) { + opt := repo.GetFirstOption(opts...) query := r.db.Role(ctx).Query() - if in.GetKeyword() != "" { - query = query.Where(role.NameContainsFold(in.GetKeyword())) + if opt.Keyword != "" { + query.Where(role.NameContainsFold(opt.Keyword)) } if opt.Page > 0 && opt.PageSize > 0 { diff --git a/internal/features/system/dal/user.go b/internal/features/system/dal/user.go index 7511dfc2..60aa9cd7 100644 --- a/internal/features/system/dal/user.go +++ b/internal/features/system/dal/user.go @@ -8,11 +8,11 @@ import ( "context" "errors" - "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/repo" ) type userRepo struct { @@ -24,12 +24,8 @@ func NewUserRepo(db *ent.Database) dto.UserRepo { return &userRepo{db: db} } -func (r *userRepo) Get(ctx context.Context, id int64, opts ...*dto.UserQueryOptions) (*types.User, error) { - opt := &dto.UserQueryOptions{} - if len(opts) > 0 { - opt = opts[0] - } - +func (r *userRepo) Get(ctx context.Context, id int64, opts ...*dto.UserQueryOption) (*types.User, error) { + opt := repo.GetFirstOption(opts...) query := r.db.User(ctx).Query().Where(user.ID(id)) if opt.WithRoles { @@ -43,13 +39,16 @@ func (r *userRepo) Get(ctx context.Context, id int64, opts ...*dto.UserQueryOpti return dto.ConvertUserToUserPB(result), nil } -func (r *userRepo) Create(ctx context.Context, u *types.User, opts ...*dto.UserCreateOptions) (*types.User, error) { +func (r *userRepo) Create(ctx context.Context, u *types.User, password string, opts ...*dto.UserCreateOption) (*types.User, error) { exist, err := r.db.User(ctx).Query().Where(user.UsernameEQ(u.Username)).Exist(ctx) if err != nil || exist { return nil, errors.New("user already exists") } entUser := dto.ConvertUserPBToUser(u) + if password != "" { + entUser.EncryptedPassword = password + } create := r.db.User(ctx).Create().SetUser(entUser) saved, err := create.Save(ctx) @@ -63,7 +62,7 @@ func (r *userRepo) Delete(ctx context.Context, id int64) error { return r.db.User(ctx).DeleteOneID(id).Exec(ctx) } -func (r *userRepo) Update(ctx context.Context, u *types.User, opts ...*dto.UserUpdateOptions) (*types.User, error) { +func (r *userRepo) Update(ctx context.Context, u *types.User, opts ...*dto.UserUpdateOption) (*types.User, error) { entUser := dto.ConvertUserPBToUser(u) update := r.db.User(ctx).UpdateOneID(u.Id).SetUser(entUser) @@ -76,16 +75,12 @@ func (r *userRepo) Update(ctx context.Context, u *types.User, opts ...*dto.UserU return dto.ConvertUserToUserPB(saved), nil } -func (r *userRepo) List(ctx context.Context, in *system.ListUsersRequest, opts ...*dto.UserQueryOptions) ([]*types.User, int32, error) { - opt := &dto.UserQueryOptions{} - if len(opts) > 0 { - opt = opts[0] - } - +func (r *userRepo) List(ctx context.Context, opts ...*dto.UserQueryOption) ([]*types.User, int32, error) { + opt := repo.GetFirstOption(opts...) query := r.db.User(ctx).Query() - if in.GetKeyword() != "" { - query = query.Where(user.Or(user.UsernameContainsFold(in.GetKeyword()), user.PhoneContainsFold(in.GetKeyword()), user.EmailContainsFold(in.GetKeyword()))) + if opt.Keyword != "" { + query.Where(user.Or(user.UsernameContainsFold(opt.Keyword), user.PhoneContainsFold(opt.Keyword), user.EmailContainsFold(opt.Keyword))) } if opt.Page > 0 && opt.PageSize > 0 { diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index 4a87db9f..9f2fb69b 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -8,7 +8,7 @@ package dto import ( "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/features/system/data/ent" + "origadmin/application/admin/internal/data/entity/ent" "time" "google.golang.org/protobuf/types/known/timestamppb" @@ -16,6 +16,12 @@ import ( // Local type aliases for external types. type ( + Department = ent.Department + DepartmentEdges = ent.DepartmentEdges + DepartmentEdgesPB = types.DepartmentEdges + DepartmentPB = types.Department + Departments = []*ent.Department + DepartmentsPB = []*types.Department MenuPB = types.Menu MenusPB = []*types.Menu Permission = ent.Permission @@ -30,9 +36,17 @@ type ( PermissionResourcesPB = []*types.PermissionResource Permissions = []*ent.Permission PermissionsPB = []*types.Permission + Position = ent.Position + PositionEdges = ent.PositionEdges + PositionEdgesPB = types.PositionEdges PositionPB = types.Position + PositionPermission = ent.PositionPermission + PositionPermissionEdges = ent.PositionPermissionEdges + PositionPermissionEdgesPB = types.PositionPermissionEdges PositionPermissionPB = types.PositionPermission + PositionPermissions = []*ent.PositionPermission PositionPermissionsPB = []*types.PositionPermission + Positions = []*ent.Position PositionsPB = []*types.Position Resource = ent.Resource ResourceEdges = ent.ResourceEdges @@ -55,9 +69,21 @@ type ( Roles = []*ent.Role RolesPB = []*types.Role User = ent.User + UserDepartment = ent.UserDepartment + UserDepartmentEdges = ent.UserDepartmentEdges + UserDepartmentEdgesPB = types.UserDepartmentEdges + UserDepartmentPB = types.UserDepartment + UserDepartments = []*ent.UserDepartment + UserDepartmentsPB = []*types.UserDepartment UserEdges = ent.UserEdges UserEdgesPB = types.UserEdges UserPB = types.User + UserPosition = ent.UserPosition + UserPositionEdges = ent.UserPositionEdges + UserPositionEdgesPB = types.UserPositionEdges + UserPositionPB = types.UserPosition + UserPositions = []*ent.UserPosition + UserPositionsPB = []*types.UserPosition UserRole = ent.UserRole UserRoleEdges = ent.UserRoleEdges UserRoleEdgesPB = types.UserRoleEdges @@ -68,6 +94,108 @@ type ( UsersPB = []*types.User ) +// ConvertDepartmentEdgesPBToDepartmentEdges converts DepartmentEdgesPB to DepartmentEdges. +func ConvertDepartmentEdgesPBToDepartmentEdges(from *DepartmentEdgesPB) *DepartmentEdges { + if from == nil { + return nil + } + + to := &DepartmentEdges{ + Users: ConvertUsersPBToUsers(from.Users), + Positions: ConvertPositionsPBToPositions(from.Positions), + Parent: ConvertDepartmentPBToDepartment(from.Parent), + Children: ConvertDepartmentsPBToDepartments(from.Children), + UserDepartments: ConvertUserDepartmentsPBToUserDepartments(from.UserDepartments), + } + return to +} + +// ConvertDepartmentEdgesToDepartmentEdgesPB converts DepartmentEdges to DepartmentEdgesPB. +func ConvertDepartmentEdgesToDepartmentEdgesPB(from *DepartmentEdges) *DepartmentEdgesPB { + if from == nil { + return nil + } + + to := &DepartmentEdgesPB{ + Users: ConvertUsersToUsersPB(from.Users), + Positions: ConvertPositionsToPositionsPB(from.Positions), + Children: ConvertDepartmentsToDepartmentsPB(from.Children), + Parent: ConvertDepartmentToDepartmentPB(from.Parent), + UserDepartments: ConvertUserDepartmentsToUserDepartmentsPB(from.UserDepartments), + } + return to +} + +// ConvertDepartmentPBToDepartment converts DepartmentPB to Department. +func ConvertDepartmentPBToDepartment(from *DepartmentPB) *Department { + if from == nil { + return nil + } + + to := &Department{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + TreePath: from.TreePath, + Sequence: int(from.Sequence), + Status: int8(from.Status), + Level: int(from.Level), + Description: from.Description, + ParentID: from.ParentId, + } + return to +} + +// ConvertDepartmentToDepartmentPB converts Department to DepartmentPB. +func ConvertDepartmentToDepartmentPB(from *Department) *DepartmentPB { + if from == nil { + return nil + } + + to := &DepartmentPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + TreePath: from.TreePath, + Sequence: int32(from.Sequence), + Status: int32(from.Status), + Level: int32(from.Level), + Description: from.Description, + ParentId: from.ParentID, + Children: ConvertDepartmentsToDepartmentsPB(from.Edges.Children), + Parent: ConvertDepartmentToDepartmentPB(from.Edges.Parent), + } + return to +} + +// ConvertDepartmentsPBToDepartments converts a slice of *DepartmentPB to a slice of *Department. +func ConvertDepartmentsPBToDepartments(froms DepartmentsPB) Departments { + if froms == nil { + return nil + } + tos := make(Departments, len(froms)) + for i, f := range froms { + tos[i] = ConvertDepartmentPBToDepartment(f) + } + return tos +} + +// ConvertDepartmentsToDepartmentsPB converts a slice of *Department to a slice of *DepartmentPB. +func ConvertDepartmentsToDepartmentsPB(froms Departments) DepartmentsPB { + if froms == nil { + return nil + } + tos := make(DepartmentsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertDepartmentToDepartmentPB(f) + } + return tos +} + // ConvertPermissionEdgesPBToPermissionEdges converts PermissionEdgesPB to PermissionEdges. func ConvertPermissionEdgesPBToPermissionEdges(from *PermissionEdgesPB) *PermissionEdges { if from == nil { @@ -76,8 +204,10 @@ func ConvertPermissionEdgesPBToPermissionEdges(from *PermissionEdgesPB) *Permiss to := &PermissionEdges{ Roles: ConvertRolesPBToRoles(from.Roles), + Positions: ConvertPositionsPBToPositions(from.Positions), Resources: ConvertResourcesPBToResources(from.Resources), RolePermissions: ConvertRolePermissionsPBToRolePermissions(from.RolePermissions), + PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), PermissionResources: ConvertPermissionResourcesPBToPermissionResources(from.PermissionResources), } return to @@ -92,8 +222,10 @@ func ConvertPermissionEdgesToPermissionEdgesPB(from *PermissionEdges) *Permissio to := &PermissionEdgesPB{ Roles: ConvertRolesToRolesPB(from.Roles), Resources: ConvertResourcesToResourcesPB(from.Resources), + Positions: ConvertPositionsToPositionsPB(from.Positions), RolePermissions: ConvertRolePermissionsToRolePermissionsPB(from.RolePermissions), PermissionResources: ConvertPermissionResourcesToPermissionResourcesPB(from.PermissionResources), + PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), } return to } @@ -215,6 +347,18 @@ func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { return to } +// ConvertPermissionsPBToPermissions converts a slice of *PermissionPB to a slice of *Permission. +func ConvertPermissionsPBToPermissions(froms PermissionsPB) Permissions { + if froms == nil { + return nil + } + tos := make(Permissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionPBToPermission(f) + } + return tos +} + // ConvertPermissionsToPermissionsPB converts a slice of *Permission to a slice of *PermissionPB. func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { if froms == nil { @@ -227,6 +371,176 @@ func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { return tos } +// ConvertPositionEdgesPBToPositionEdges converts PositionEdgesPB to PositionEdges. +func ConvertPositionEdgesPBToPositionEdges(from *PositionEdgesPB) *PositionEdges { + if from == nil { + return nil + } + + to := &PositionEdges{ + Department: ConvertDepartmentPBToDepartment(from.Department), + Users: ConvertUsersPBToUsers(from.Users), + Permissions: ConvertPermissionsPBToPermissions(from.Permissions), + UserPositions: ConvertUserPositionsPBToUserPositions(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), + } + return to +} + +// ConvertPositionEdgesToPositionEdgesPB converts PositionEdges to PositionEdgesPB. +func ConvertPositionEdgesToPositionEdgesPB(from *PositionEdges) *PositionEdgesPB { + if from == nil { + return nil + } + + to := &PositionEdgesPB{ + Department: ConvertDepartmentToDepartmentPB(from.Department), + Users: ConvertUsersToUsersPB(from.Users), + Permissions: ConvertPermissionsToPermissionsPB(from.Permissions), + UserPositions: ConvertUserPositionsToUserPositionsPB(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), + } + return to +} + +// ConvertPositionPBToPosition converts PositionPB to Position. +func ConvertPositionPBToPosition(from *PositionPB) *Position { + if from == nil { + return nil + } + + to := &Position{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DepartmentID: from.DepartmentId, + } + return to +} + +// ConvertPositionPermissionEdgesPBToPositionPermissionEdges converts PositionPermissionEdgesPB to PositionPermissionEdges. +func ConvertPositionPermissionEdgesPBToPositionPermissionEdges(from *PositionPermissionEdgesPB) *PositionPermissionEdges { + if from == nil { + return nil + } + + to := &PositionPermissionEdges{ + Position: ConvertPositionPBToPosition(from.Position), + Permission: ConvertPermissionPBToPermission(from.Permission), + } + return to +} + +// ConvertPositionPermissionEdgesToPositionPermissionEdgesPB converts PositionPermissionEdges to PositionPermissionEdgesPB. +func ConvertPositionPermissionEdgesToPositionPermissionEdgesPB(from *PositionPermissionEdges) *PositionPermissionEdgesPB { + if from == nil { + return nil + } + + to := &PositionPermissionEdgesPB{ + Position: ConvertPositionToPositionPB(from.Position), + Permission: ConvertPermissionToPermissionPB(from.Permission), + } + return to +} + +// ConvertPositionPermissionPBToPositionPermission converts PositionPermissionPB to PositionPermission. +func ConvertPositionPermissionPBToPositionPermission(from *PositionPermissionPB) *PositionPermission { + if from == nil { + return nil + } + + to := &PositionPermission{ + ID: int(from.Id), + PositionID: from.PositionId, + PermissionID: from.PermissionId, + } + return to +} + +// ConvertPositionPermissionToPositionPermissionPB converts PositionPermission to PositionPermissionPB. +func ConvertPositionPermissionToPositionPermissionPB(from *PositionPermission) *PositionPermissionPB { + if from == nil { + return nil + } + + to := &PositionPermissionPB{ + Id: int64(from.ID), + PositionId: from.PositionID, + PermissionId: from.PermissionID, + } + return to +} + +// ConvertPositionPermissionsPBToPositionPermissions converts a slice of *PositionPermissionPB to a slice of *PositionPermission. +func ConvertPositionPermissionsPBToPositionPermissions(froms PositionPermissionsPB) PositionPermissions { + if froms == nil { + return nil + } + tos := make(PositionPermissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionPBToPositionPermission(f) + } + return tos +} + +// ConvertPositionPermissionsToPositionPermissionsPB converts a slice of *PositionPermission to a slice of *PositionPermissionPB. +func ConvertPositionPermissionsToPositionPermissionsPB(froms PositionPermissions) PositionPermissionsPB { + if froms == nil { + return nil + } + tos := make(PositionPermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionToPositionPermissionPB(f) + } + return tos +} + +// ConvertPositionToPositionPB converts Position to PositionPB. +func ConvertPositionToPositionPB(from *Position) *PositionPB { + if from == nil { + return nil + } + + to := &PositionPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DepartmentId: from.DepartmentID, + } + return to +} + +// ConvertPositionsPBToPositions converts a slice of *PositionPB to a slice of *Position. +func ConvertPositionsPBToPositions(froms PositionsPB) Positions { + if froms == nil { + return nil + } + tos := make(Positions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPBToPosition(f) + } + return tos +} + +// ConvertPositionsToPositionsPB converts a slice of *Position to a slice of *PositionPB. +func ConvertPositionsToPositionsPB(froms Positions) PositionsPB { + if froms == nil { + return nil + } + tos := make(PositionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionToPositionPB(f) + } + return tos +} + // ConvertResourceEdgesPBToResourceEdges converts ResourceEdgesPB to ResourceEdges. func ConvertResourceEdgesPBToResourceEdges(from *ResourceEdgesPB) *ResourceEdges { if from == nil { @@ -259,9 +573,12 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { UpdateTime: ConvertTimestampToTime(from.UpdateTime), Name: from.Name, Keyword: from.Keyword, + I18nKey: from.I18NKey, Type: from.Type, Status: int8(from.Status), Path: from.Path, + Operation: from.Operation, + Method: from.Method, Component: from.Component, Icon: from.Icon, Sequence: int(from.Sequence), @@ -286,9 +603,12 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Name: from.Name, Keyword: from.Keyword, + I18NKey: from.I18nKey, Type: from.Type, Status: int32(from.Status), Path: from.Path, + Operation: from.Operation, + Method: from.Method, Component: from.Component, Icon: from.Icon, Sequence: int32(from.Sequence), @@ -498,6 +818,86 @@ func ConvertRolesToRolesPB(froms Roles) RolesPB { return tos } +// ConvertUserDepartmentEdgesPBToUserDepartmentEdges converts UserDepartmentEdgesPB to UserDepartmentEdges. +func ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from *UserDepartmentEdgesPB) *UserDepartmentEdges { + if from == nil { + return nil + } + + to := &UserDepartmentEdges{ + User: ConvertUserPBToUser(from.User), + Department: ConvertDepartmentPBToDepartment(from.Department), + } + return to +} + +// ConvertUserDepartmentEdgesToUserDepartmentEdgesPB converts UserDepartmentEdges to UserDepartmentEdgesPB. +func ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(from *UserDepartmentEdges) *UserDepartmentEdgesPB { + if from == nil { + return nil + } + + to := &UserDepartmentEdgesPB{ + User: ConvertUserToUserPB(from.User), + Department: ConvertDepartmentToDepartmentPB(from.Department), + } + return to +} + +// ConvertUserDepartmentPBToUserDepartment converts UserDepartmentPB to UserDepartment. +func ConvertUserDepartmentPBToUserDepartment(from *UserDepartmentPB) *UserDepartment { + if from == nil { + return nil + } + + to := &UserDepartment{ + ID: int(from.Id), + UserID: from.UserId, + DepartmentID: from.DepartmentId, + Edges: *ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from.Edges), + } + return to +} + +// ConvertUserDepartmentToUserDepartmentPB converts UserDepartment to UserDepartmentPB. +func ConvertUserDepartmentToUserDepartmentPB(from *UserDepartment) *UserDepartmentPB { + if from == nil { + return nil + } + + to := &UserDepartmentPB{ + Id: int64(from.ID), + UserId: from.UserID, + DepartmentId: from.DepartmentID, + Edges: ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(&from.Edges), + } + return to +} + +// ConvertUserDepartmentsPBToUserDepartments converts a slice of *UserDepartmentPB to a slice of *UserDepartment. +func ConvertUserDepartmentsPBToUserDepartments(froms UserDepartmentsPB) UserDepartments { + if froms == nil { + return nil + } + tos := make(UserDepartments, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserDepartmentPBToUserDepartment(f) + } + return tos +} + +// ConvertUserDepartmentsToUserDepartmentsPB converts a slice of *UserDepartment to a slice of *UserDepartmentPB. +func ConvertUserDepartmentsToUserDepartmentsPB(froms UserDepartments) UserDepartmentsPB { + if froms == nil { + return nil + } + tos := make(UserDepartmentsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserDepartmentToUserDepartmentPB(f) + } + return tos +} + // ConvertUserEdgesPBToUserEdges converts UserEdgesPB to UserEdges. func ConvertUserEdgesPBToUserEdges(from *UserEdgesPB) *UserEdges { if from == nil { @@ -532,6 +932,8 @@ func ConvertUserPBToUser(from *UserPB) *User { to := &User{ ID: from.Id, + CreateAuthor: from.CreateAuthor, + UpdateAuthor: from.UpdateAuthor, CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), UUID: from.Uuid, @@ -541,17 +943,98 @@ func ConvertUserPBToUser(from *UserPB) *User { Avatar: from.Avatar, Name: from.Name, Gender: ConvertStringToGender(from.Gender), - Password: from.Password, Phone: from.Phone, Email: from.Email, Remark: from.Remark, + Token: from.Token, Status: int8(from.Status), LastLoginIP: from.LastLoginIp, LastLoginTime: ConvertTimestampToTime(from.LastLoginTime), + SanctionDate: ConvertTimestampToTime(from.SanctionDate), + ManagerID: from.ManagerId, + Manager: from.Manager, } return to } +// ConvertUserPositionEdgesPBToUserPositionEdges converts UserPositionEdgesPB to UserPositionEdges. +func ConvertUserPositionEdgesPBToUserPositionEdges(from *UserPositionEdgesPB) *UserPositionEdges { + if from == nil { + return nil + } + + to := &UserPositionEdges{ + User: ConvertUserPBToUser(from.User), + Position: ConvertPositionPBToPosition(from.Position), + } + return to +} + +// ConvertUserPositionEdgesToUserPositionEdgesPB converts UserPositionEdges to UserPositionEdgesPB. +func ConvertUserPositionEdgesToUserPositionEdgesPB(from *UserPositionEdges) *UserPositionEdgesPB { + if from == nil { + return nil + } + + to := &UserPositionEdgesPB{ + User: ConvertUserToUserPB(from.User), + Position: ConvertPositionToPositionPB(from.Position), + } + return to +} + +// ConvertUserPositionPBToUserPosition converts UserPositionPB to UserPosition. +func ConvertUserPositionPBToUserPosition(from *UserPositionPB) *UserPosition { + if from == nil { + return nil + } + + to := &UserPosition{ + ID: int(from.Id), + UserID: from.UserId, + PositionID: from.PositionId, + } + return to +} + +// ConvertUserPositionToUserPositionPB converts UserPosition to UserPositionPB. +func ConvertUserPositionToUserPositionPB(from *UserPosition) *UserPositionPB { + if from == nil { + return nil + } + + to := &UserPositionPB{ + Id: int64(from.ID), + UserId: from.UserID, + PositionId: from.PositionID, + } + return to +} + +// ConvertUserPositionsPBToUserPositions converts a slice of *UserPositionPB to a slice of *UserPosition. +func ConvertUserPositionsPBToUserPositions(froms UserPositionsPB) UserPositions { + if froms == nil { + return nil + } + tos := make(UserPositions, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionPBToUserPosition(f) + } + return tos +} + +// ConvertUserPositionsToUserPositionsPB converts a slice of *UserPosition to a slice of *UserPositionPB. +func ConvertUserPositionsToUserPositionsPB(froms UserPositions) UserPositionsPB { + if froms == nil { + return nil + } + tos := make(UserPositionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionToUserPositionPB(f) + } + return tos +} + // ConvertUserRoleEdgesPBToUserRoleEdges converts UserRoleEdgesPB to UserRoleEdges. func ConvertUserRoleEdgesPBToUserRoleEdges(from *UserRoleEdgesPB) *UserRoleEdges { if from == nil { @@ -640,6 +1123,8 @@ func ConvertUserToUserPB(from *User) *UserPB { to := &UserPB{ Id: from.ID, + CreateAuthor: from.CreateAuthor, + UpdateAuthor: from.UpdateAuthor, CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Uuid: from.UUID, @@ -649,13 +1134,16 @@ func ConvertUserToUserPB(from *User) *UserPB { Avatar: from.Avatar, Name: from.Name, Gender: ConvertGenderToString(from.Gender), - Password: from.Password, Phone: from.Phone, Email: from.Email, Remark: from.Remark, + Token: from.Token, Status: int32(from.Status), LastLoginIp: from.LastLoginIP, LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), + SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), + ManagerId: from.ManagerID, + Manager: from.Manager, Roles: ConvertRolesToRolesPB(from.Edges.Roles), } return to diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index fc2af785..240cfe09 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -6,7 +6,7 @@ import ( //go:generate go run github.com/origadmin/abgen/cmd/abgen -debug go run ./cmd/abgen -debug . -//go:abgen:package:path=origadmin/application/admin/internal/features/system/data/ent,alias=ent +//go:abgen:package:path=origadmin/application/admin/internal/data/entity/ent,alias=ent //go:abgen:package:path=origadmin/application/admin/api/v1/services/types,alias=types //go:abgen:pair:packages="ent,types" //go:abgen:convert:direction="both" @@ -26,13 +26,3 @@ func ConvertStringToGender(from string) user.Gender { // TODO: Implement this custom conversion panic("stub! not implemented") } - -type Pagination struct { - Page int - PageSize int -} - -type QueryOption struct { - Pagination *Pagination - OrderBy []string -} diff --git a/internal/features/system/dto/permission.go b/internal/features/system/dto/permission.go index cd03ecab..72256cc2 100644 --- a/internal/features/system/dto/permission.go +++ b/internal/features/system/dto/permission.go @@ -15,24 +15,36 @@ import ( // PermissionRepo is a Permission repository interface. type PermissionRepo interface { - Get(context.Context, int64, ...*PermissionQueryOptions) (*types.Permission, error) - List(context.Context, *system.ListPermissionsRequest, ...*PermissionQueryOptions) ([]*types.Permission, int32, error) - Create(context.Context, *types.Permission, ...*PermissionCreateOptions) (*types.Permission, error) - Update(context.Context, *types.Permission, ...*PermissionUpdateOptions) (*types.Permission, error) + Get(context.Context, int64, ...*PermissionQueryOption) (*types.Permission, error) + List(context.Context, ...*PermissionQueryOption) ([]*types.Permission, int32, error) + Create(context.Context, *types.Permission, ...*PermissionCreateOption) (*types.Permission, error) + Update(context.Context, *types.Permission, ...*PermissionUpdateOption) (*types.Permission, error) Delete(context.Context, int64) error } -// PermissionQueryOptions specifies options for listing permissions. -type PermissionQueryOptions struct { +// PermissionQueryOption specifies options for querying permissions. +type PermissionQueryOption struct { repo.QueryOption + DataScopes []string WithResources bool WithRoles bool } -// PermissionCreateOptions specifies options for creating a permission. -type PermissionCreateOptions struct { +// PermissionCreateOption specifies options for creating a permission. +type PermissionCreateOption struct { } -// PermissionUpdateOptions specifies options for updating a permission. -type PermissionUpdateOptions struct { +// PermissionUpdateOption specifies options for updating a permission. +type PermissionUpdateOption struct { +} + +// ListPermissionsRequestToQueryOption converts an API request to a query option object. +func ListPermissionsRequestToQueryOption(req *system.ListPermissionsRequest) *PermissionQueryOption { + if req == nil { + return &PermissionQueryOption{} + } + return &PermissionQueryOption{ + QueryOption: repo.OptionFromRequest(req), + DataScopes: req.GetDataScopes(), + } } diff --git a/internal/features/system/dto/resource.go b/internal/features/system/dto/resource.go index d26a2fc9..40009cb9 100644 --- a/internal/features/system/dto/resource.go +++ b/internal/features/system/dto/resource.go @@ -15,23 +15,34 @@ import ( // ResourceRepo is a Resource repository interface. type ResourceRepo interface { - Get(context.Context, int64, ...*ResourceQueryOptions) (*types.Resource, error) - List(context.Context, *system.ListResourcesRequest, ...*ResourceQueryOptions) ([]*types.Resource, int32, error) - Create(context.Context, *types.Resource, ...*ResourceCreateOptions) (*types.Resource, error) - Update(context.Context, *types.Resource, ...*ResourceUpdateOptions) (*types.Resource, error) + Get(context.Context, int64, ...*ResourceQueryOption) (*types.Resource, error) + List(context.Context, ...*ResourceQueryOption) ([]*types.Resource, int32, error) + Create(context.Context, *types.Resource, ...*ResourceCreateOption) (*types.Resource, error) + Update(context.Context, *types.Resource, ...*ResourceUpdateOption) (*types.Resource, error) Delete(context.Context, int64) error } -// ResourceQueryOptions specifies options for listing resources. -type ResourceQueryOptions struct { +// ResourceQueryOption specifies options for querying resources. +type ResourceQueryOption struct { repo.QueryOption WithPermissions bool } -// ResourceCreateOptions specifies options for creating a resource. -type ResourceCreateOptions struct { +// ResourceCreateOption specifies options for creating a resource. +type ResourceCreateOption struct { } -// ResourceUpdateOptions specifies options for updating a resource. -type ResourceUpdateOptions struct { +// ResourceUpdateOption specifies options for updating a resource. +type ResourceUpdateOption struct { +} + +// ListResourcesRequestToQueryOption converts an API request to a query option object. +func ListResourcesRequestToQueryOption(req *system.ListResourcesRequest) *ResourceQueryOption { + if req == nil { + return &ResourceQueryOption{} + } + return &ResourceQueryOption{ + QueryOption: repo.OptionFromRequest(req), + // WithPermissions: req.GetWithPermissions(), // Assuming this field exists + } } diff --git a/internal/features/system/dto/role.go b/internal/features/system/dto/role.go index 25173f07..8c618e5b 100644 --- a/internal/features/system/dto/role.go +++ b/internal/features/system/dto/role.go @@ -15,10 +15,10 @@ import ( // RoleRepo is a Role repository interface. type RoleRepo interface { - Get(context.Context, int64, ...*RoleQueryOptions) (*types.Role, error) - List(context.Context, *system.ListRolesRequest, ...*RoleQueryOptions) ([]*types.Role, int32, error) - Create(context.Context, *types.Role, ...*RoleCreateOptions) (*types.Role, error) - Update(context.Context, *types.Role, ...*RoleUpdateOptions) (*types.Role, error) + Get(context.Context, int64, ...*RoleQueryOption) (*types.Role, error) + List(context.Context, ...*RoleQueryOption) ([]*types.Role, int32, error) + Create(context.Context, *types.Role, ...*RoleCreateOption) (*types.Role, error) + Update(context.Context, *types.Role, ...*RoleUpdateOption) (*types.Role, error) Delete(context.Context, int64) error // Business-specific methods @@ -26,16 +26,27 @@ type RoleRepo interface { UpdatePermissions(context.Context, int64, []int64) error } -// RoleQueryOptions specifies options for listing roles. -type RoleQueryOptions struct { +// RoleQueryOption specifies options for querying roles. +type RoleQueryOption struct { repo.QueryOption WithPermissions bool } -// RoleCreateOptions specifies options for creating a role. -type RoleCreateOptions struct { +// RoleCreateOption specifies options for creating a role. +type RoleCreateOption struct { } -// RoleUpdateOptions specifies options for updating a role. -type RoleUpdateOptions struct { +// RoleUpdateOption specifies options for updating a role. +type RoleUpdateOption struct { +} + +// ListRolesRequestToQueryOption converts an API request to a query option object. +func ListRolesRequestToQueryOption(req *system.ListRolesRequest) *RoleQueryOption { + if req == nil { + return &RoleQueryOption{} + } + return &RoleQueryOption{ + QueryOption: repo.OptionFromRequest(req), + // WithPermissions: req.GetWithPermissions(), // Assuming this field exists + } } diff --git a/internal/features/system/dto/user.go b/internal/features/system/dto/user.go index c5f442d6..18a10a48 100644 --- a/internal/features/system/dto/user.go +++ b/internal/features/system/dto/user.go @@ -15,10 +15,10 @@ import ( // UserRepo is a User repository interface. type UserRepo interface { - Get(context.Context, int64, ...*UserQueryOptions) (*types.User, error) - List(context.Context, *system.ListUsersRequest, ...*UserQueryOptions) ([]*types.User, int32, error) - Create(context.Context, *types.User, ...*UserCreateOptions) (*types.User, error) - Update(context.Context, *types.User, ...*UserUpdateOptions) (*types.User, error) + Get(context.Context, int64, ...*UserQueryOption) (*types.User, error) + List(context.Context, ...*UserQueryOption) ([]*types.User, int32, error) + Create(context.Context, *types.User, string, ...*UserCreateOption) (*types.User, error) + Update(context.Context, *types.User, ...*UserUpdateOption) (*types.User, error) Delete(context.Context, int64) error // Business-specific methods @@ -29,20 +29,31 @@ type UserRepo interface { UpdateUserStatus(ctx context.Context, id int64, status int32) error } -// UserQueryOptions specifies options for listing users. -type UserQueryOptions struct { +// UserQueryOption specifies options for querying users. +type UserQueryOption struct { repo.QueryOption WithRoles bool } -// UserCreateOptions specifies options for creating a user. -type UserCreateOptions struct { +// UserCreateOption specifies options for creating a user. +type UserCreateOption struct { // Example: Immediately load roles after creation LoadRoles bool } -// UserUpdateOptions specifies options for updating a user. -type UserUpdateOptions struct { +// UserUpdateOption specifies options for updating a user. +type UserUpdateOption struct { // Example: For partial updates (PATCH) UpdateFields []string } + +// ListUsersRequestToQueryOption converts an API request to a query option object. +func ListUsersRequestToQueryOption(req *system.ListUsersRequest) *UserQueryOption { + if req == nil { + return &UserQueryOption{} + } + return &UserQueryOption{ + QueryOption: repo.OptionFromRequest(req), + // WithRoles: req.GetWithRoles(), // Assuming this field exists in the request + } +} diff --git a/internal/features/system/service/permission.go b/internal/features/system/service/permission.go index 103fa29b..39dda44b 100644 --- a/internal/features/system/service/permission.go +++ b/internal/features/system/service/permission.go @@ -8,11 +8,11 @@ import ( "context" "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/api/v1/services/types" ) func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPermissionsRequest) (*system.ListPermissionsResponse, error) { - permissions, total, err := s.permission.ListPermissions(ctx, req) + permissions, total, err := s.Permission.ListPermissions(ctx, req) if err != nil { return nil, err } @@ -22,20 +22,20 @@ func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPer }, nil } -func (s *SystemService) GetPermission(ctx context.Context, req *system.GetPermissionRequest) (*dto.PermissionPB, error) { - return s.permission.GetPermission(ctx, req.Id) +func (s *SystemService) GetPermission(ctx context.Context, req *system.GetPermissionRequest) (*types.Permission, error) { + return s.Permission.GetPermission(ctx, req.Id) } -func (s *SystemService) CreatePermission(ctx context.Context, req *system.CreatePermissionRequest) (*dto.PermissionPB, error) { - return s.permission.CreatePermission(ctx, req.Permission) +func (s *SystemService) CreatePermission(ctx context.Context, req *system.CreatePermissionRequest) (*types.Permission, error) { + return s.Permission.CreatePermission(ctx, req.Permission) } -func (s *SystemService) UpdatePermission(ctx context.Context, req *system.UpdatePermissionRequest) (*dto.PermissionPB, error) { - return s.permission.UpdatePermission(ctx, req.Permission) +func (s *SystemService) UpdatePermission(ctx context.Context, req *system.UpdatePermissionRequest) (*types.Permission, error) { + return s.Permission.UpdatePermission(ctx, req.Permission) } func (s *SystemService) DeletePermission(ctx context.Context, req *system.DeletePermissionRequest) (*system.DeletePermissionResponse, error) { - err := s.permission.DeletePermission(ctx, req.Id) + err := s.Permission.DeletePermission(ctx, req.Id) if err != nil { return nil, err } diff --git a/internal/features/system/service/resource.go b/internal/features/system/service/resource.go index dea4d7d0..1505b205 100644 --- a/internal/features/system/service/resource.go +++ b/internal/features/system/service/resource.go @@ -8,11 +8,11 @@ import ( "context" "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/api/v1/services/types" ) func (s *SystemService) ListResources(ctx context.Context, req *system.ListResourcesRequest) (*system.ListResourcesResponse, error) { - resources, total, err := s.resource.ListResources(ctx, req) + resources, total, err := s.Resource.ListResources(ctx, req) if err != nil { return nil, err } @@ -22,20 +22,20 @@ func (s *SystemService) ListResources(ctx context.Context, req *system.ListResou }, nil } -func (s *SystemService) GetResource(ctx context.Context, req *system.GetResourceRequest) (*dto.ResourcePB, error) { - return s.resource.GetResource(ctx, req.Id) +func (s *SystemService) GetResource(ctx context.Context, req *system.GetResourceRequest) (*types.Resource, error) { + return s.Resource.GetResource(ctx, req.Id) } -func (s *SystemService) CreateResource(ctx context.Context, req *system.CreateResourceRequest) (*dto.ResourcePB, error) { - return s.resource.CreateResource(ctx, req.Resource) +func (s *SystemService) CreateResource(ctx context.Context, req *system.CreateResourceRequest) (*types.Resource, error) { + return s.Resource.CreateResource(ctx, req.Resource) } -func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateResourceRequest) (*dto.ResourcePB, error) { - return s.resource.UpdateResource(ctx, req.Resource) +func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateResourceRequest) (*types.Resource, error) { + return s.Resource.UpdateResource(ctx, req.Resource) } func (s *SystemService) DeleteResource(ctx context.Context, req *system.DeleteResourceRequest) (*system.DeleteResourceResponse, error) { - err := s.resource.DeleteResource(ctx, req.Id) + err := s.Resource.DeleteResource(ctx, req.Id) if err != nil { return nil, err } diff --git a/internal/features/system/service/role.go b/internal/features/system/service/role.go index 4a1917c8..c3f96fc7 100644 --- a/internal/features/system/service/role.go +++ b/internal/features/system/service/role.go @@ -8,11 +8,11 @@ import ( "context" "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/api/v1/services/types" ) func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequest) (*system.ListRolesResponse, error) { - roles, total, err := s.role.ListRoles(ctx, req) + roles, total, err := s.Role.ListRoles(ctx, req) if err != nil { return nil, err } @@ -22,17 +22,17 @@ func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequ Total: total, }, nil } -func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*dto.RolePB, error) { - return s.role.GetRole(ctx, req.Id) +func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*types.Role, error) { + return s.Role.GetRole(ctx, req.Id) } -func (s *SystemService) CreateRole(ctx context.Context, req *system.CreateRoleRequest) (*dto.RolePB, error) { - return s.role.CreateRole(ctx, req.Role) +func (s *SystemService) CreateRole(ctx context.Context, req *system.CreateRoleRequest) (*types.Role, error) { + return s.Role.CreateRole(ctx, req.Role) } -func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRequest) (*dto.RolePB, error) { - return s.role.UpdateRole(ctx, req.Role) +func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRequest) (*types.Role, error) { + return s.Role.UpdateRole(ctx, req.Role) } func (s *SystemService) DeleteRole(ctx context.Context, req *system.DeleteRoleRequest) (*system.DeleteRoleResponse, error) { - err := s.role.DeleteRole(ctx, req.Id) + err := s.Role.DeleteRole(ctx, req.Id) if err != nil { return nil, err } diff --git a/internal/features/system/service/user.go b/internal/features/system/service/user.go index 4cfdcaac..626e6edb 100644 --- a/internal/features/system/service/user.go +++ b/internal/features/system/service/user.go @@ -8,11 +8,11 @@ import ( "context" "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/api/v1/services/types" ) func (s *SystemService) ListUserResources(ctx context.Context, req *system.ListUserResourcesRequest) (*system.ListUserResourcesResponse, error) { - resources, err := s.user.ListUserResources(ctx, req.Id) + resources, err := s.User.ListUserResources(ctx, req.GetId()) if err != nil { return nil, err } @@ -22,7 +22,7 @@ func (s *SystemService) ListUserResources(ctx context.Context, req *system.ListU } func (s *SystemService) UpdateUserRoles(ctx context.Context, req *system.UpdateUserRolesRequest) (*system.UpdateUserRolesResponse, error) { - err := s.user.UpdateUserRoles(ctx, req.Id, req.RoleIds) + err := s.User.UpdateUserRoles(ctx, req.GetId(), req.GetRoleIds()) if err != nil { return nil, err } @@ -30,7 +30,7 @@ func (s *SystemService) UpdateUserRoles(ctx context.Context, req *system.UpdateU } func (s *SystemService) UpdateUserStatus(ctx context.Context, req *system.UpdateUserStatusRequest) (*system.UpdateUserStatusResponse, error) { - err := s.user.UpdateUserStatus(ctx, req.Id, req.Status) + err := s.User.UpdateUserStatus(ctx, req.GetId(), req.GetStatus()) if err != nil { return nil, err } @@ -38,7 +38,7 @@ func (s *SystemService) UpdateUserStatus(ctx context.Context, req *system.Update } func (s *SystemService) ResetUserPassword(ctx context.Context, req *system.ResetUserPasswordRequest) (*system.ResetUserPasswordResponse, error) { - err := s.user.ResetUserPassword(ctx, req.Id, req.Password) + err := s.User.ResetUserPassword(ctx, req.GetId(), req.GetPassword()) if err != nil { return nil, err } @@ -46,7 +46,7 @@ func (s *SystemService) ResetUserPassword(ctx context.Context, req *system.Reset } func (s *SystemService) ListUsers(ctx context.Context, req *system.ListUsersRequest) (*system.ListUsersResponse, error) { - users, total, err := s.user.ListUsers(ctx, req) + users, total, err := s.User.ListUsers(ctx, req) if err != nil { return nil, err } @@ -56,20 +56,20 @@ func (s *SystemService) ListUsers(ctx context.Context, req *system.ListUsersRequ }, nil } -func (s *SystemService) GetUser(ctx context.Context, req *system.GetUserRequest) (*dto.UserPB, error) { - return s.user.GetUser(ctx, req.Id) +func (s *SystemService) GetUser(ctx context.Context, req *system.GetUserRequest) (*types.User, error) { + return s.User.GetUser(ctx, req.GetId()) } -func (s *SystemService) CreateUser(ctx context.Context, req *system.CreateUserRequest) (*dto.UserPB, error) { - return s.user.CreateUser(ctx, req.User, req.Password) +func (s *SystemService) CreateUser(ctx context.Context, req *system.CreateUserRequest) (*types.User, error) { + return s.User.CreateUser(ctx, req.GetUser(), req.GetPassword()) } -func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRequest) (*dto.UserPB, error) { - return s.user.UpdateUser(ctx, req.User) +func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRequest) (*types.User, error) { + return s.User.UpdateUser(ctx, req.GetUser()) } func (s *SystemService) DeleteUser(ctx context.Context, req *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { - err := s.user.DeleteUser(ctx, req.GetUser().GetId()) + err := s.User.DeleteUser(ctx, req.GetId()) if err != nil { return nil, err } diff --git a/internal/helpers/repo/options.go b/internal/helpers/repo/options.go new file mode 100644 index 00000000..d75371b8 --- /dev/null +++ b/internal/helpers/repo/options.go @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package repo provides common helpers for repository implementations, +// focusing on abstracting common query patterns like pagination. +package repo + +// PaginatingRequest defines the contract for any request that supports pagination. +type PaginatingRequest interface { + GetPage() int32 + GetPageSize() int32 +} + +// CountingRequest defines the contract for any request that supports "count-only" mode. +type CountingRequest interface { + GetOnlyCount() bool +} + +// KeywordRequest defines the contract for any request that supports keyword-based search. +type KeywordRequest interface { + GetKeyword() string +} + +// QueryOption holds common query options like pagination and ordering. +// It is intended to be embedded in more specific query option structs. +type QueryOption struct { + Page int + PageSize int + OnlyCount bool + Keyword string + OrderBy []string +} + +// OptionFromRequest creates a QueryOption with common details +// extracted from any request that satisfies the PaginatingRequest, +// CountingRequest, or KeywordRequest interfaces. +func OptionFromRequest(req interface{}) QueryOption { + opt := QueryOption{} + + if r, ok := req.(PaginatingRequest); ok { + opt.Page = int(r.GetPage()) + opt.PageSize = int(r.GetPageSize()) + } + + if r, ok := req.(CountingRequest); ok { + opt.OnlyCount = r.GetOnlyCount() + } + + if r, ok := req.(KeywordRequest); ok { + opt.Keyword = r.GetKeyword() + } + + return opt +} + +// GetFirstOption safely retrieves the first option from a slice of option pointers. +// If the slice is empty or the first element is nil, it returns a new, non-nil instance of the option type. +func GetFirstOption[T any](opts ...*T) *T { + if len(opts) > 0 && opts[0] != nil { + return opts[0] + } + return new(T) +} diff --git a/internal/helpers/repo/query.go b/internal/helpers/repo/query.go deleted file mode 100644 index ef820984..00000000 --- a/internal/helpers/repo/query.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package repo provides common query options for pagination. -package repo - -// QueryOption holds common query options like pagination and ordering. -// It is intended to be embedded in more specific query option structs. -type QueryOption struct { - Page int - PageSize int - OrderBy []string -} - -// IsOption is a marker method to ensure type safety. -func (o *QueryOption) IsOption() {} diff --git a/resources/docs/openapi/openapi.yaml b/resources/docs/openapi/openapi.yaml index 6fae4cc0..592e1034 100644 --- a/resources/docs/openapi/openapi.yaml +++ b/resources/docs/openapi/openapi.yaml @@ -2321,113 +2321,14 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/users/{id}/password/reset: - post: - tags: - - UserService - description: ResetUserPassword reset the user s password - operationId: UserService_ResetUserPassword - parameters: - - name: id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.protobuf.Any' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.ResetUserPasswordResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /sys/users/{id}/resources: - get: - tags: - - UserService - operationId: UserService_ListUserResources - parameters: - - name: id - in: path - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.ListUserResourcesResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /sys/users/{user.id}: - put: - tags: - - UserService - operationId: UserService_UpdateUser - parameters: - - name: user.id - in: path - required: true - schema: - type: string - - name: user_id - in: query - description: The user id to use for this user. - schema: - type: string - - name: is_system - in: query - description: The user is_system to use for this user. - schema: - type: boolean - - name: random_password - in: query - description: The random_password is the query parameter for set only to generate a random password - schema: - type: boolean - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.types.User' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.UpdateUserResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' delete: tags: - UserService operationId: UserService_DeleteUser parameters: - - name: user.id + - name: id in: path + description: The resource id of the user to be deleted. required: true schema: type: string @@ -2495,25 +2396,6 @@ paths: description: user.field.gender schema: type: string - - name: user.password - in: query - description: |- - user.field.password - @Decrypted don't show this field in response - schema: - type: string - - name: user.confirm_password - in: query - description: user.field.confirm_password - schema: - type: string - - name: user.salt - in: query - description: |- - user.field.salt - @Decrypted don't show this field in response - schema: - type: string - name: user.phone in: query description: user.field.phone @@ -2587,33 +2469,78 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/users/{user.id}/roles: - put: + /sys/users/{id}/password/reset: + post: tags: - UserService - description: UpdateUserRoles update the user roles - operationId: UserService_UpdateUserRoles + description: ResetUserPassword reset the user s password + operationId: UserService_ResetUserPassword parameters: - - name: user.id + - name: id in: path required: true schema: type: string + requestBody: + content: + application/json: + schema: + type: string + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.ResetUserPasswordResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /sys/users/{id}/resources: + get: + tags: + - UserService + operationId: UserService_ListUserResources + parameters: - name: id - in: query + in: path + required: true schema: type: string - - name: role_ids - in: query + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.ListUserResourcesResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /sys/users/{id}/roles: + put: + tags: + - UserService + description: UpdateUserRoles update the user roles + operationId: UserService_UpdateUserRoles + parameters: + - name: id + in: path + required: true schema: - type: array - items: - type: string + type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.User' + $ref: '#/components/schemas/api.v1.services.system.UpdateUserRolesRequest' required: true responses: "200": @@ -2628,18 +2555,63 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/users/{user.id}/status: + /sys/users/{id}/status: put: tags: - UserService description: UpdateUserStatus Update the status of the user information operationId: UserService_UpdateUserStatus + parameters: + - name: id + in: path + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.UpdateUserStatusRequest' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.UpdateUserStatusResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /sys/users/{user.id}: + put: + tags: + - UserService + operationId: UserService_UpdateUser parameters: - name: user.id in: path required: true schema: type: string + - name: user_id + in: query + description: The user id to use for this user. + schema: + type: string + - name: is_system + in: query + description: The user is_system to use for this user. + schema: + type: boolean + - name: random_password + in: query + description: The random_password is the query parameter for set only to generate a random password + schema: + type: boolean requestBody: content: application/json: @@ -2652,7 +2624,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.UpdateUserStatusResponse' + $ref: '#/components/schemas/api.v1.services.system.UpdateUserResponse' default: description: Default error response content: @@ -3568,11 +3540,32 @@ components: properties: user: $ref: '#/components/schemas/api.v1.services.types.User' + api.v1.services.system.UpdateUserRolesRequest: + type: object + properties: + id: + type: string + user: + $ref: '#/components/schemas/api.v1.services.types.User' + role_ids: + type: array + items: + type: string api.v1.services.system.UpdateUserRolesResponse: type: object properties: user: $ref: '#/components/schemas/api.v1.services.types.User' + api.v1.services.system.UpdateUserStatusRequest: + type: object + properties: + id: + type: string + status: + type: integer + format: int32 + user: + $ref: '#/components/schemas/api.v1.services.types.User' api.v1.services.system.UpdateUserStatusResponse: type: object properties: {} @@ -4010,19 +4003,6 @@ components: gender: type: string description: user.field.gender - password: - type: string - description: |- - user.field.password - @Decrypted don't show this field in response - confirm_password: - type: string - description: user.field.confirm_password - salt: - type: string - description: |- - user.field.salt - @Decrypted don't show this field in response phone: type: string description: user.field.phone From 99a03406602948fb65b03f669511aaae8c898a61 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 24 Dec 2025 21:13:13 +0800 Subject: [PATCH 074/158] feat(system): refactor service responses and add bcrypt hasher provider --- cmd/system/wire.go | 10 ++++++- internal/features/system/server/server.go | 16 +++++------ .../features/system/service/permission.go | 27 +++++++++++++------ internal/features/system/service/resource.go | 27 +++++++++++++------ internal/features/system/service/role.go | 27 +++++++++++++------ internal/features/system/service/user.go | 25 ++++++++++++----- resources/.env.system | 4 +++ .../{configs => bak}/admin/bootstrap.toml | 0 resources/{configs => bak}/admin/clients.toml | 0 .../{configs => bak}/admin/discovery.toml | 0 resources/{configs => bak}/admin/logger.toml | 0 .../{configs => bak}/admin/middleware.toml | 0 .../{configs => bak}/admin/security.toml | 0 resources/{configs => bak}/admin/storage.toml | 0 resources/{configs => bak}/auth/service.toml | 0 .../{configs => bak}/common/bootstrap.toml | 0 .../{configs => bak}/common/discovery.toml | 0 resources/{configs => bak}/common/logger.toml | 0 .../{configs => bak}/common/middleware.toml | 0 .../{configs => bak}/common/security.toml | 0 .../{configs => bak}/common/storage.toml | 0 .../{configs => bak}/system/service.toml | 0 resources/configs/bootstrap.yaml | 16 +++++++++++ resources/configs/databases.yaml | 6 +++++ resources/configs/logger.yaml | 4 +++ resources/configs/server.yaml | 10 +++++++ 26 files changed, 132 insertions(+), 40 deletions(-) create mode 100644 resources/.env.system rename resources/{configs => bak}/admin/bootstrap.toml (100%) rename resources/{configs => bak}/admin/clients.toml (100%) rename resources/{configs => bak}/admin/discovery.toml (100%) rename resources/{configs => bak}/admin/logger.toml (100%) rename resources/{configs => bak}/admin/middleware.toml (100%) rename resources/{configs => bak}/admin/security.toml (100%) rename resources/{configs => bak}/admin/storage.toml (100%) rename resources/{configs => bak}/auth/service.toml (100%) rename resources/{configs => bak}/common/bootstrap.toml (100%) rename resources/{configs => bak}/common/discovery.toml (100%) rename resources/{configs => bak}/common/logger.toml (100%) rename resources/{configs => bak}/common/middleware.toml (100%) rename resources/{configs => bak}/common/security.toml (100%) rename resources/{configs => bak}/common/storage.toml (100%) rename resources/{configs => bak}/system/service.toml (100%) create mode 100644 resources/configs/bootstrap.yaml create mode 100644 resources/configs/databases.yaml create mode 100644 resources/configs/logger.yaml create mode 100644 resources/configs/server.yaml diff --git a/cmd/system/wire.go b/cmd/system/wire.go index 43165940..e3646026 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -12,6 +12,9 @@ import ( "github.com/go-kratos/kratos/v2" "github.com/google/wire" "github.com/origadmin/runtime" + "github.com/origadmin/toolkits/crypto/hash" + "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" + "github.com/origadmin/toolkits/crypto/hash/types" "origadmin/application/admin/internal/conf" confpb "origadmin/application/admin/internal/conf/pb" @@ -22,11 +25,16 @@ import ( "origadmin/application/admin/internal/features/system/service" ) +func provideHasher() (hash.Crypto, error) { + // Using a default cost for bcrypt. In a real application, this might come from config. + return hash.NewCrypto(types.BCRYPT, bcrypt.WithCost(bcrypt.DefaultCost)) +} + // wireApp init kratos application. func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { panic(wire.Build( // The injector function's parameter `app` is an implicit provider for *runtime.App. - infraProviderSet, + provideHasher, wire.FieldsOf(new(*conf.Config), "Bootstrap"), wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), data.ProviderSet, diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index eb602af5..c8df0f6c 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -68,10 +68,10 @@ func NewHTTPServer(cfg *httpv1.Server, svc *service.SystemService, logger log.Lo srv := http.NewServer(opts...) // Register HTTP handlers - systemv1.RegisterUserServiceHTTPServer(srv, svc.User) - systemv1.RegisterRoleServiceHTTPServer(srv, svc.Role) - systemv1.RegisterPermissionServiceHTTPServer(srv, svc.Permission) - systemv1.RegisterResourceServiceHTTPServer(srv, svc.Resource) + systemv1.RegisterUserServiceHTTPServer(srv, svc) + systemv1.RegisterRoleServiceHTTPServer(srv, svc) + systemv1.RegisterPermissionServiceHTTPServer(srv, svc) + systemv1.RegisterResourceServiceHTTPServer(srv, svc) return srv, nil } @@ -92,10 +92,10 @@ func NewGRPCServer(cfg *grpcv1.Server, svc *service.SystemService, logger log.Lo srv := grpc.NewServer(opts...) // Register gRPC handlers - systemv1.RegisterUserServiceServer(srv, svc.User) - systemv1.RegisterRoleServiceServer(srv, svc.Role) - systemv1.RegisterPermissionServiceServer(srv, svc.Permission) - systemv1.RegisterResourceServiceServer(srv, svc.Resource) + systemv1.RegisterUserServiceServer(srv, svc) + systemv1.RegisterRoleServiceServer(srv, svc) + systemv1.RegisterPermissionServiceServer(srv, svc) + systemv1.RegisterResourceServiceServer(srv, svc) return srv, nil } diff --git a/internal/features/system/service/permission.go b/internal/features/system/service/permission.go index 39dda44b..b961f93b 100644 --- a/internal/features/system/service/permission.go +++ b/internal/features/system/service/permission.go @@ -8,7 +8,6 @@ import ( "context" "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/api/v1/services/types" ) func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPermissionsRequest) (*system.ListPermissionsResponse, error) { @@ -22,20 +21,32 @@ func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPer }, nil } -func (s *SystemService) GetPermission(ctx context.Context, req *system.GetPermissionRequest) (*types.Permission, error) { - return s.Permission.GetPermission(ctx, req.Id) +func (s *SystemService) GetPermission(ctx context.Context, req *system.GetPermissionRequest) (*system.GetPermissionResponse, error) { + permission, err := s.Permission.GetPermission(ctx, req.GetId()) + if err != nil { + return nil, err + } + return &system.GetPermissionResponse{Permission: permission}, nil } -func (s *SystemService) CreatePermission(ctx context.Context, req *system.CreatePermissionRequest) (*types.Permission, error) { - return s.Permission.CreatePermission(ctx, req.Permission) +func (s *SystemService) CreatePermission(ctx context.Context, req *system.CreatePermissionRequest) (*system.CreatePermissionResponse, error) { + permission, err := s.Permission.CreatePermission(ctx, req.GetPermission()) + if err != nil { + return nil, err + } + return &system.CreatePermissionResponse{Permission: permission}, nil } -func (s *SystemService) UpdatePermission(ctx context.Context, req *system.UpdatePermissionRequest) (*types.Permission, error) { - return s.Permission.UpdatePermission(ctx, req.Permission) +func (s *SystemService) UpdatePermission(ctx context.Context, req *system.UpdatePermissionRequest) (*system.UpdatePermissionResponse, error) { + permission, err := s.Permission.UpdatePermission(ctx, req.GetPermission()) + if err != nil { + return nil, err + } + return &system.UpdatePermissionResponse{Permission: permission}, nil } func (s *SystemService) DeletePermission(ctx context.Context, req *system.DeletePermissionRequest) (*system.DeletePermissionResponse, error) { - err := s.Permission.DeletePermission(ctx, req.Id) + err := s.Permission.DeletePermission(ctx, req.GetId()) if err != nil { return nil, err } diff --git a/internal/features/system/service/resource.go b/internal/features/system/service/resource.go index 1505b205..32e4f84d 100644 --- a/internal/features/system/service/resource.go +++ b/internal/features/system/service/resource.go @@ -8,7 +8,6 @@ import ( "context" "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/api/v1/services/types" ) func (s *SystemService) ListResources(ctx context.Context, req *system.ListResourcesRequest) (*system.ListResourcesResponse, error) { @@ -22,20 +21,32 @@ func (s *SystemService) ListResources(ctx context.Context, req *system.ListResou }, nil } -func (s *SystemService) GetResource(ctx context.Context, req *system.GetResourceRequest) (*types.Resource, error) { - return s.Resource.GetResource(ctx, req.Id) +func (s *SystemService) GetResource(ctx context.Context, req *system.GetResourceRequest) (*system.GetResourceResponse, error) { + resource, err := s.Resource.GetResource(ctx, req.GetId()) + if err != nil { + return nil, err + } + return &system.GetResourceResponse{Resource: resource}, nil } -func (s *SystemService) CreateResource(ctx context.Context, req *system.CreateResourceRequest) (*types.Resource, error) { - return s.Resource.CreateResource(ctx, req.Resource) +func (s *SystemService) CreateResource(ctx context.Context, req *system.CreateResourceRequest) (*system.CreateResourceResponse, error) { + resource, err := s.Resource.CreateResource(ctx, req.GetResource()) + if err != nil { + return nil, err + } + return &system.CreateResourceResponse{Resource: resource}, nil } -func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateResourceRequest) (*types.Resource, error) { - return s.Resource.UpdateResource(ctx, req.Resource) +func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateResourceRequest) (*system.UpdateResourceResponse, error) { + resource, err := s.Resource.UpdateResource(ctx, req.GetResource()) + if err != nil { + return nil, err + } + return &system.UpdateResourceResponse{Resource: resource}, nil } func (s *SystemService) DeleteResource(ctx context.Context, req *system.DeleteResourceRequest) (*system.DeleteResourceResponse, error) { - err := s.Resource.DeleteResource(ctx, req.Id) + err := s.Resource.DeleteResource(ctx, req.GetId()) if err != nil { return nil, err } diff --git a/internal/features/system/service/role.go b/internal/features/system/service/role.go index c3f96fc7..2a6cf703 100644 --- a/internal/features/system/service/role.go +++ b/internal/features/system/service/role.go @@ -8,7 +8,6 @@ import ( "context" "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/api/v1/services/types" ) func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequest) (*system.ListRolesResponse, error) { @@ -22,17 +21,29 @@ func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequ Total: total, }, nil } -func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*types.Role, error) { - return s.Role.GetRole(ctx, req.Id) +func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*system.GetRoleResponse, error) { + role, err := s.Role.GetRole(ctx, req.GetId()) + if err != nil { + return nil, err + } + return &system.GetRoleResponse{Role: role}, nil } -func (s *SystemService) CreateRole(ctx context.Context, req *system.CreateRoleRequest) (*types.Role, error) { - return s.Role.CreateRole(ctx, req.Role) +func (s *SystemService) CreateRole(ctx context.Context, req *system.CreateRoleRequest) (*system.CreateRoleResponse, error) { + role, err := s.Role.CreateRole(ctx, req.GetRole()) + if err != nil { + return nil, err + } + return &system.CreateRoleResponse{Role: role}, nil } -func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRequest) (*types.Role, error) { - return s.Role.UpdateRole(ctx, req.Role) +func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRequest) (*system.UpdateRoleResponse, error) { + role, err := s.Role.UpdateRole(ctx, req.GetRole()) + if err != nil { + return nil, err + } + return &system.UpdateRoleResponse{Role: role}, nil } func (s *SystemService) DeleteRole(ctx context.Context, req *system.DeleteRoleRequest) (*system.DeleteRoleResponse, error) { - err := s.Role.DeleteRole(ctx, req.Id) + err := s.Role.DeleteRole(ctx, req.GetId()) if err != nil { return nil, err } diff --git a/internal/features/system/service/user.go b/internal/features/system/service/user.go index 626e6edb..9f7811c0 100644 --- a/internal/features/system/service/user.go +++ b/internal/features/system/service/user.go @@ -8,7 +8,6 @@ import ( "context" "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/api/v1/services/types" ) func (s *SystemService) ListUserResources(ctx context.Context, req *system.ListUserResourcesRequest) (*system.ListUserResourcesResponse, error) { @@ -56,16 +55,28 @@ func (s *SystemService) ListUsers(ctx context.Context, req *system.ListUsersRequ }, nil } -func (s *SystemService) GetUser(ctx context.Context, req *system.GetUserRequest) (*types.User, error) { - return s.User.GetUser(ctx, req.GetId()) +func (s *SystemService) GetUser(ctx context.Context, req *system.GetUserRequest) (*system.GetUserResponse, error) { + user, err := s.User.GetUser(ctx, req.GetId()) + if err != nil { + return nil, err + } + return &system.GetUserResponse{User: user}, nil } -func (s *SystemService) CreateUser(ctx context.Context, req *system.CreateUserRequest) (*types.User, error) { - return s.User.CreateUser(ctx, req.GetUser(), req.GetPassword()) +func (s *SystemService) CreateUser(ctx context.Context, req *system.CreateUserRequest) (*system.CreateUserResponse, error) { + user, err := s.User.CreateUser(ctx, req.GetUser(), req.GetPassword()) + if err != nil { + return nil, err + } + return &system.CreateUserResponse{User: user}, nil } -func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRequest) (*types.User, error) { - return s.User.UpdateUser(ctx, req.GetUser()) +func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRequest) (*system.UpdateUserResponse, error) { + user, err := s.User.UpdateUser(ctx, req.GetUser()) + if err != nil { + return nil, err + } + return &system.UpdateUserResponse{User: user}, nil } func (s *SystemService) DeleteUser(ctx context.Context, req *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { diff --git a/resources/.env.system b/resources/.env.system new file mode 100644 index 00000000..b5cab5f1 --- /dev/null +++ b/resources/.env.system @@ -0,0 +1,4 @@ +# .env.system +# You can define environment-specific variables here. +# For example: +# DB_USER=admin diff --git a/resources/configs/admin/bootstrap.toml b/resources/bak/admin/bootstrap.toml similarity index 100% rename from resources/configs/admin/bootstrap.toml rename to resources/bak/admin/bootstrap.toml diff --git a/resources/configs/admin/clients.toml b/resources/bak/admin/clients.toml similarity index 100% rename from resources/configs/admin/clients.toml rename to resources/bak/admin/clients.toml diff --git a/resources/configs/admin/discovery.toml b/resources/bak/admin/discovery.toml similarity index 100% rename from resources/configs/admin/discovery.toml rename to resources/bak/admin/discovery.toml diff --git a/resources/configs/admin/logger.toml b/resources/bak/admin/logger.toml similarity index 100% rename from resources/configs/admin/logger.toml rename to resources/bak/admin/logger.toml diff --git a/resources/configs/admin/middleware.toml b/resources/bak/admin/middleware.toml similarity index 100% rename from resources/configs/admin/middleware.toml rename to resources/bak/admin/middleware.toml diff --git a/resources/configs/admin/security.toml b/resources/bak/admin/security.toml similarity index 100% rename from resources/configs/admin/security.toml rename to resources/bak/admin/security.toml diff --git a/resources/configs/admin/storage.toml b/resources/bak/admin/storage.toml similarity index 100% rename from resources/configs/admin/storage.toml rename to resources/bak/admin/storage.toml diff --git a/resources/configs/auth/service.toml b/resources/bak/auth/service.toml similarity index 100% rename from resources/configs/auth/service.toml rename to resources/bak/auth/service.toml diff --git a/resources/configs/common/bootstrap.toml b/resources/bak/common/bootstrap.toml similarity index 100% rename from resources/configs/common/bootstrap.toml rename to resources/bak/common/bootstrap.toml diff --git a/resources/configs/common/discovery.toml b/resources/bak/common/discovery.toml similarity index 100% rename from resources/configs/common/discovery.toml rename to resources/bak/common/discovery.toml diff --git a/resources/configs/common/logger.toml b/resources/bak/common/logger.toml similarity index 100% rename from resources/configs/common/logger.toml rename to resources/bak/common/logger.toml diff --git a/resources/configs/common/middleware.toml b/resources/bak/common/middleware.toml similarity index 100% rename from resources/configs/common/middleware.toml rename to resources/bak/common/middleware.toml diff --git a/resources/configs/common/security.toml b/resources/bak/common/security.toml similarity index 100% rename from resources/configs/common/security.toml rename to resources/bak/common/security.toml diff --git a/resources/configs/common/storage.toml b/resources/bak/common/storage.toml similarity index 100% rename from resources/configs/common/storage.toml rename to resources/bak/common/storage.toml diff --git a/resources/configs/system/service.toml b/resources/bak/system/service.toml similarity index 100% rename from resources/configs/system/service.toml rename to resources/bak/system/service.toml diff --git a/resources/configs/bootstrap.yaml b/resources/configs/bootstrap.yaml new file mode 100644 index 00000000..1d6509b2 --- /dev/null +++ b/resources/configs/bootstrap.yaml @@ -0,0 +1,16 @@ +# This is the main bootstrap file for the system service. +# It defines a series of configuration sources to be loaded sequentially. +# Paths inside are relative to this bootstrap.yaml file. +sources: + # File sources are loaded first to provide default values. + - file: + path: server.yaml + type: file + - file: + path: databases.yaml + type: file + - file: + path: logger.yaml + type: file + # Environment variables can be loaded last to override file settings. + - type: env diff --git a/resources/configs/databases.yaml b/resources/configs/databases.yaml new file mode 100644 index 00000000..028b8292 --- /dev/null +++ b/resources/configs/databases.yaml @@ -0,0 +1,6 @@ +# databases.yaml +data: + database: + default: + driver: sqlite3 + source: file:data.db?cache=shared&_fk=1 diff --git a/resources/configs/logger.yaml b/resources/configs/logger.yaml new file mode 100644 index 00000000..27be245f --- /dev/null +++ b/resources/configs/logger.yaml @@ -0,0 +1,4 @@ +# logger.yaml +logger: + level: debug + format: console # or json diff --git a/resources/configs/server.yaml b/resources/configs/server.yaml new file mode 100644 index 00000000..6cc15c0f --- /dev/null +++ b/resources/configs/server.yaml @@ -0,0 +1,10 @@ +# server.yaml +servers: + - protocol: http + http: + addr: 0.0.0.0:8000 + timeout: 1s + - protocol: grpc + grpc: + addr: 0.0.0.0:9000 + timeout: 1s From fa20bbf4b21a72419fd7409dae39de953f5c8dac Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 24 Dec 2025 23:40:10 +0800 Subject: [PATCH 075/158] refactor(config): update config structure and logging, move openapi docs to api-docs --- Makefile | 2 +- buf.gen.yaml | 2 +- cmd/system/main.go | 1 - go.mod | 18 ++++++------- go.sum | 12 +++++++++ internal/conf/config.go | 6 ++++- internal/features/system/server/server.go | 5 +++- .../{docs => api-docs}/openapi/openapi.yaml | 0 resources/configs/bootstrap.yaml | 2 +- resources/configs/databases.yaml | 9 ++++--- resources/configs/logger.yaml | 4 ++- resources/configs/server.yaml | 27 +++++++++++++------ 12 files changed, 60 insertions(+), 28 deletions(-) rename resources/{docs => api-docs}/openapi/openapi.yaml (100%) diff --git a/Makefile b/Makefile index 44a7a4ff..90393f2e 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ THIRD_PARTY_PATH=third_party PROTO_INTERNAL_PATH=internal PROTO_TOOLKITS_PATH=toolkits PROTO_API_PATH=api -OPENAPI_DOCS_PATH=resources/docs/openapi +OPENAPI_DOCS_PATH=resources/api-docs/openapi ifeq ($(GOHOSTOS), windows) #the `find.exe` is different from `find` in bash/shell. diff --git a/buf.gen.yaml b/buf.gen.yaml index f9036627..841e8ee8 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -14,7 +14,7 @@ managed: plugins: # comment with error: duplicate generated file name "openapi.yaml". Generation will continue without error here and drop the second occurrence of this file, but please raise an issue with the maintainer of the plugin. - local: protoc-gen-openapi - out: resources/docs/openapi + out: resources/api-docs/openapi opt: - naming=proto # Naming convention. Using "proto" passes the name directly from the proto file. The default value is json # - depth=2 # Recursion depth of the loop message. The default value is 2 diff --git a/cmd/system/main.go b/cmd/system/main.go index daf8ee71..2e48a6ba 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -70,7 +70,6 @@ func main() { if !ok { log.Fatalf("failed to get bootstrap config") } - // wireApp now takes the runtime instance and builds the kratos app. app, cleanupApp, err := wireApp(rt, bootstrapConfig) if err != nil { diff --git a/go.mod b/go.mod index 716a0199..c59e95bb 100644 --- a/go.mod +++ b/go.mod @@ -12,16 +12,16 @@ replace github.com/origadmin/contrib v1.1.0 => ../../contrib require ( entgo.io/ent v0.14.5 - github.com/casbin/casbin/v2 v2.134.0 - github.com/envoyproxy/protoc-gen-validate v1.2.1 - github.com/go-kratos/kratos/v2 v2.9.1 + github.com/casbin/casbin/v2 v2.135.0 + github.com/envoyproxy/protoc-gen-validate v1.3.0 + github.com/go-kratos/kratos/v2 v2.9.2 github.com/goexts/generic v0.14.0 github.com/golang-jwt/jwt/v5 v5.3.0 // indirect github.com/google/gnostic v0.7.1 // indirect github.com/google/uuid v1.6.0 github.com/google/wire v0.7.0 github.com/gorilla/handlers v1.5.2 - github.com/mattn/go-sqlite3 v1.14.28 // indirect + github.com/mattn/go-sqlite3 v1.14.32 // indirect github.com/mojocn/base64Captcha v1.3.8 github.com/origadmin/contrib v1.1.0 github.com/origadmin/entslog/v3 v3.1.0 @@ -29,7 +29,7 @@ require ( github.com/origadmin/slog-kratos v1.0.5 // indirect github.com/origadmin/toolkits v1.2.0 github.com/origadmin/toolkits/codec v1.2.0 - github.com/origadmin/toolkits/crypto v1.2.0 + github.com/origadmin/toolkits/crypto v1.2.0 github.com/origadmin/toolkits/errors v1.2.0 github.com/sony/sonyflake v1.3.0 github.com/sqlite3ent/sqlite3 v1.40.0 @@ -95,9 +95,9 @@ require ( github.com/felixge/httpsnoop v1.0.4 // indirect github.com/go-chi/chi/v5 v5.2.3 // indirect github.com/go-kratos/aegis v0.2.0 // indirect - github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251106012513-9262193e351a // indirect - github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251106012513-9262193e351a // indirect - github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251106012513-9262193e351a // indirect + github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251201062103-6f0b3015b803 // indirect + github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251201062103-6f0b3015b803 // indirect + github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251201062103-6f0b3015b803 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect @@ -193,7 +193,7 @@ require ( golang.org/x/text v0.31.0 // indirect golang.org/x/tools v0.39.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 // indirect - google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect + google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 5cf9ea1b..63afdede 100644 --- a/go.sum +++ b/go.sum @@ -76,6 +76,8 @@ github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFos github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= github.com/casbin/casbin/v2 v2.134.0 h1:wyO3hZb487GzlGVAI2hUoHQT0ehFD+9B5P+HVG9BVTM= github.com/casbin/casbin/v2 v2.134.0/go.mod h1:FmcfntdXLTcYXv/hxgNntcRPqAbwOG9xsism0yXT+18= +github.com/casbin/casbin/v2 v2.135.0 h1:6BLkMQiGotYyS5yYeWgW19vxqugUlvHFkFiLnLR/bxk= +github.com/casbin/casbin/v2 v2.135.0/go.mod h1:FmcfntdXLTcYXv/hxgNntcRPqAbwOG9xsism0yXT+18= github.com/casbin/govaluate v1.3.0 h1:VA0eSY0M2lA86dYd5kPPuNZMUD9QkWnOCnavGrw9myc= github.com/casbin/govaluate v1.3.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= @@ -121,6 +123,8 @@ github.com/envoyproxy/go-control-plane v0.13.5-0.20251024222203-75eaa193e329 h1: github.com/envoyproxy/go-control-plane/envoy v1.35.0 h1:ixjkELDE+ru6idPxcHLj8LBVc2bFP7iBytj353BoHUo= github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8= github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU= +github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg5VPuZ0uONDT6eb4= +github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -133,12 +137,17 @@ github.com/go-kratos/aegis v0.2.0 h1:dObzCDWn3XVjUkgxyBp6ZeWtx/do0DPZ7LY3yNSJLUQ github.com/go-kratos/aegis v0.2.0/go.mod h1:v0R2m73WgEEYB3XYu6aE2WcMwsZkJ/Rzuf5eVccm7bI= github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251106012513-9262193e351a h1:hXTsD6lWaAU7UQchbmafi9WLTyBMjoLttEnVpWMiGJA= github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:tr3LJLUypg8Js3bClD6s7p2eWLTIitvq9Paf7FAK3R4= +github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:tr3LJLUypg8Js3bClD6s7p2eWLTIitvq9Paf7FAK3R4= github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251106012513-9262193e351a h1:3nyCH1sGH9sSWnnVDpvxywg8r+Esr1lObU6wTzW3ups= github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= +github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251106012513-9262193e351a h1:lyM6XpKxtzwcII0cvVk8QsGyJvu9xMJT8yoW6fwIbT4= github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= +github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= github.com/go-kratos/kratos/v2 v2.9.1 h1:EGif6/S/aK/RCR5clIbyhioTNyoSrii3FC118jG40Z0= github.com/go-kratos/kratos/v2 v2.9.1/go.mod h1:a1MQLjMhIh7R0kcJS9SzJYR43BRI7EPzzN0J1Ksu2bA= +github.com/go-kratos/kratos/v2 v2.9.2 h1:px8GJQBeLpquDKQWQ9zohEWiLA8n4D/pv7aH3asvUvo= +github.com/go-kratos/kratos/v2 v2.9.2/go.mod h1:Jc7jaeYd4RAPjetun2C+oFAOO7HNMHTT/Z4LxpuEDJM= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -242,6 +251,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= +github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= @@ -518,6 +529,7 @@ google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM= google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1/go.mod h1:5KF+wpkbTSbGcR9zteSqZV6fqFOWBl4Yde8En8MryZA= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0/go.mod h1:QLvsjh0OIR0TYBeiu2bkWGTJBUNQ64st52iWj/yA93I= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/conf/config.go b/internal/conf/config.go index dff431f1..55a95d78 100644 --- a/internal/conf/config.go +++ b/internal/conf/config.go @@ -72,8 +72,12 @@ func (c *Config) DecodedConfig() any { return &c.Bootstrap } -func (c *Config) Transform(config interfaces.Config, config2 interfaces.StructuredConfig) (interfaces. +func (c *Config) Transform(config interfaces.Config, sc interfaces.StructuredConfig) (interfaces. StructuredConfig, error) { + err := config.Decode("", &c.Bootstrap) + if err != nil { + return nil, err + } return c, nil } diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index c8df0f6c..a11af48f 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -6,6 +6,7 @@ package server import ( "errors" + stdhttp "net/http" "github.com/go-kratos/kratos/v2/transport" "github.com/go-kratos/kratos/v2/transport/grpc" @@ -72,7 +73,9 @@ func NewHTTPServer(cfg *httpv1.Server, svc *service.SystemService, logger log.Lo systemv1.RegisterRoleServiceHTTPServer(srv, svc) systemv1.RegisterPermissionServiceHTTPServer(srv, svc) systemv1.RegisterResourceServiceHTTPServer(srv, svc) - + srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { + log.Infof("HTTP %s %s", method, path) + }) return srv, nil } diff --git a/resources/docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml similarity index 100% rename from resources/docs/openapi/openapi.yaml rename to resources/api-docs/openapi/openapi.yaml diff --git a/resources/configs/bootstrap.yaml b/resources/configs/bootstrap.yaml index 1d6509b2..c8680bee 100644 --- a/resources/configs/bootstrap.yaml +++ b/resources/configs/bootstrap.yaml @@ -12,5 +12,5 @@ sources: - file: path: logger.yaml type: file - # Environment variables can be loaded last to override file settings. + # Environment variables are loaded last to override file settings. - type: env diff --git a/resources/configs/databases.yaml b/resources/configs/databases.yaml index 028b8292..0d6182af 100644 --- a/resources/configs/databases.yaml +++ b/resources/configs/databases.yaml @@ -1,6 +1,7 @@ # databases.yaml data: - database: - default: - driver: sqlite3 - source: file:data.db?cache=shared&_fk=1 + databases: + configs: + - dialect: sqlite3 + name: default + source: file:./data.db?cache=shared&mode=memory&_fk=1 diff --git a/resources/configs/logger.yaml b/resources/configs/logger.yaml index 27be245f..89dcb027 100644 --- a/resources/configs/logger.yaml +++ b/resources/configs/logger.yaml @@ -1,4 +1,6 @@ # logger.yaml logger: + caller: true + format: text level: debug - format: console # or json + output: stdout diff --git a/resources/configs/server.yaml b/resources/configs/server.yaml index 6cc15c0f..80930df1 100644 --- a/resources/configs/server.yaml +++ b/resources/configs/server.yaml @@ -1,10 +1,21 @@ # server.yaml servers: - - protocol: http - http: - addr: 0.0.0.0:8000 - timeout: 1s - - protocol: grpc - grpc: - addr: 0.0.0.0:9000 - timeout: 1s + configs: + - grpc: + # Reads the port from the GRPC_PORT environment variable; defaults to 9090 if not present. + addr: 0.0.0.0:${GRPC_PORT:9090} + middlewares: + - recovery + - logger + network: tcp + name: grpc_server + protocol: grpc + - http: + # Reads the port from the HTTP_PORT environment variable; defaults to 8080 if not present. + addr: 0.0.0.0:${HTTP_PORT:8080} + middlewares: + - recovery + - logger + network: tcp + name: http_server + protocol: http From fa2719724290c814268fe7a8acaef3ae142adaf8 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 02:48:35 +0800 Subject: [PATCH 076/158] refactor(rbac): update API endpoints and request body structures for RBAC services --- api/http/api/v1/sys/rbac.http | 340 ++++++++---------- api/http/api/v1/sys/rbac.service.http | 179 +++++++++ api/v1/proto/system/department.proto | 2 +- api/v1/proto/system/menu.proto | 2 +- api/v1/proto/system/permission.proto | 2 +- api/v1/proto/system/position.proto | 2 +- api/v1/proto/system/resource.proto | 2 +- api/v1/proto/system/role.proto | 2 +- api/v1/proto/system/user.proto | 2 +- api/v1/services/system/department.pb.go | 7 +- api/v1/services/system/department.pb.gw.go | 18 +- .../services/system/department_bridge.pb.go | 2 +- api/v1/services/system/department_http.pb.go | 4 +- api/v1/services/system/menu.pb.go | 6 +- api/v1/services/system/menu.pb.gw.go | 18 +- api/v1/services/system/menu_bridge.pb.go | 2 +- api/v1/services/system/menu_http.pb.go | 4 +- api/v1/services/system/permission.pb.go | 7 +- api/v1/services/system/permission.pb.gw.go | 18 +- .../services/system/permission_bridge.pb.go | 2 +- api/v1/services/system/permission_http.pb.go | 4 +- api/v1/services/system/position.pb.go | 6 +- api/v1/services/system/position.pb.gw.go | 18 +- api/v1/services/system/position_bridge.pb.go | 2 +- api/v1/services/system/position_http.pb.go | 4 +- api/v1/services/system/resource.pb.go | 6 +- api/v1/services/system/resource.pb.gw.go | 18 +- api/v1/services/system/resource_bridge.pb.go | 2 +- api/v1/services/system/resource_http.pb.go | 4 +- api/v1/services/system/role.pb.go | 6 +- api/v1/services/system/role.pb.gw.go | 18 +- api/v1/services/system/role_bridge.pb.go | 2 +- api/v1/services/system/role_http.pb.go | 4 +- api/v1/services/system/user.pb.go | 6 +- api/v1/services/system/user.pb.gw.go | 18 +- api/v1/services/system/user_bridge.pb.go | 2 +- api/v1/services/system/user_http.pb.go | 4 +- cmd/system/main.go | 1 + internal/features/system/dal/user.go | 7 + internal/features/system/dto/dto.go | 16 +- .../features/system/service/permission.go | 2 + internal/features/system/service/resource.go | 2 + internal/features/system/service/role.go | 6 +- internal/features/system/service/user.go | 6 +- resources/api-docs/openapi/openapi.yaml | 216 ++++++----- 45 files changed, 539 insertions(+), 462 deletions(-) create mode 100644 api/http/api/v1/sys/rbac.service.http diff --git a/api/http/api/v1/sys/rbac.http b/api/http/api/v1/sys/rbac.http index 279f8391..94285934 100644 --- a/api/http/api/v1/sys/rbac.http +++ b/api/http/api/v1/sys/rbac.http @@ -1,223 +1,179 @@ @token = eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzYyNzEyMDEsImlzcyI6ImxvY2FsaG9zdCIsInN1YiI6ImFkbWluIn0.3x9WnK9OZQUFdYYBAwVwqtNrMK3VRZJjBgQXRnQLNd8K4m0WwfTyAiA1TfwlUyh8t95WXfl99AkXJEJUWAQppg -@host = http://127.0.0.1:25100 +@host = http://127.0.0.1:8080 -### GET request to example server -GET {{host}}/api/v1/sys/resources - ?generated-in=GoLand +### +# RBAC - Resources +### + +# @name ListResources +# List all resources with pagination +GET {{host}}/api/v1/sys/resources?page=1&page_size=10 +Authorization: Bearer {{token}} + +### + +# @name CreateResource +# Create a new resource +POST {{host}}/api/v1/sys/resources +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "resource": { + "name": "New Resource", + "type": "api", + "path": "/api/v1/new/resource" + } +} + +### +# RBAC - Roles +### + +# @name ListRoles +# List all roles with pagination +GET {{host}}/api/v1/sys/roles?page=1&page_size=10 Authorization: Bearer {{token}} ### -### Create role resource +# @name CreateRole +# Create a new role POST {{host}}/api/v1/sys/roles Authorization: Bearer {{token}} Content-Type: application/json { - "keyword": "", - "name": "admin", - "description": "管理员", - "sequence": 8, - "status": 1 + "role": { + "keyword": "new_role", + "name": "New Role", + "description": "A newly created role", + "sequence": 10, + "status": 1 + } } +### +# RBAC - Users +### + +# @name ListUsers +# List all users with pagination +GET {{host}}/api/v1/sys/users?page=1&page_size=10 +Authorization: Bearer {{token}} + ### -#[ -#{ -# "id": "1", -# "create_time": "2023-07-20T12:00:00Z", -# "update_time": "2023-07-20T12:00:00Z", -# "username": "user1", -# "name": "User One", -# "avatar": "avatar1.jpg", -# "password": "password1", -# "salt": "salt1", -# "phone": "1234567890", -# "email": "user1@example.com", -# "remark": "Remark for User One", -# "status": "active", -# "edges": {} -# }, -# { -# "id": "2", -# "create_time": "2023-07-20T13:00:00Z", -# "update_time": "2023-07-20T13:00:00Z", -# "username": "user2", -# "name": "User Two", -# "avatar": "avatar2.jpg", -# "password": "password2", -# "salt": "salt2", -# "phone": "0987654321", -# "email": "user2@example.com", -# "remark": "Remark for User Two", -# "status": "inactive", -# "edges": {} -# }, -# { -# "id": "3", -# "create_time": "2023-07-20T14:00:00Z", -# "update_time": "2023-07-20T14:00:00Z", -# "username": "user3", -# "name": "User Three", -# "avatar": "avatar3.jpg", -# "password": "password3", -# "salt": "salt3", -# "phone": "1111111111", -# "email": "user3@example.com", -# "remark": "Remark for User Three", -# "status": "active", -# "edges": {} -# }, -# { -# "id": "4", -# "create_time": "2023-07-20T15:00:00Z", -# "update_time": "2023-07-20T15:00:00Z", -# "username": "user4", -# "name": "User Four", -# "avatar": "avatar4.jpg", -# "password": "password4", -# "salt": "salt4", -# "phone": "2222222222", -# "email": "user4@example.com", -# "remark": "Remark for User Four", -# "status": "inactive", -# "edges": {} -# }, -# { -# "id": "5", -# "create_time": "2023-07-20T16:00:00Z", -# "update_time": "2023-07-20T16:00:00Z", -# "username": "user5", -# "name": "User Five", -# "avatar": "avatar5.jpg", -# "password": "password5", -# "salt": "salt5", -# "phone": "3333333333", -# "email": "user5@example.com", -# "remark": "Remark for User Five", -# "status": "active", -# "edges": {} -# }, -# { -# "id": "6", -# "create_time": "2023-07-20T17:00:00Z", -# "update_time": "2023-07-20T17:00:00Z", -# "username": "user6", -# "name": "User Six", -# "avatar": "avatar6.jpg", -# "password": "password6", -# "salt": "salt6", -# "phone": "4444444444", -# "email": "user6@example.com", -# "remark": "Remark for User Six", -# "status": "inactive", -# "edges": {} -# }, -# { -# "id": "7", -# "create_time": "2023-07-20T18:00:00Z", -# "update_time": "2023-07-20T18:00:00Z", -# "username": "user7", -# "name": "User Seven", -# "avatar": "avatar7.jpg", -# "password": "password7", -# "salt": "salt7", -# "phone": "5555555555", -# "email": "user7@example.com", -# "remark": "Remark for User Seven", -# "status": "active", -# "edges": {} -# }, -# { -# "id": "8", -# "create_time": "2023-07-20T19:00:00Z", -# "update_time": "2023-07-20T19:00:00Z", -# "username": "user8", -# "name": "User Eight", -# "avatar": "avatar8.jpg", -# "password": "password8", -# "salt": "salt8", -# "phone": "6666666666", -# "email": "user8@example.com", -# "remark": "Remark for User Eight", -# "status": "inactive", -# "edges": {} -# }, -# { -# "id": "9", -# "create_time": "2023-07-20T20:00:00Z", -# "update_time": "2023-07-20T20:00:00Z", -# "username": "user9", -# "name": "User Nine", -# "avatar": "avatar9.jpg", -# "password": "password9", -# "salt": "salt9", -# "phone": "7777777777", -# "email": "user9@example.com", -# "remark": "Remark for User Nine", -# "status": "active", -# "edges": {} -# }, -# { -# "id": "10", -# "create_time": "2023-07-20T21:00:00Z", -# "update_time": "2023-07-20T21:00:00Z", -# "username": "user10", -# "name": "User Ten", -# "avatar": "avatar10.jpg", -# "password": "password10", -#"salt": "salt10", -#"phone": "8888888888", -#"email": "user10@example.com", -#"remark": "Remark for User Ten", -#"status": "inactive", -#"edges": {} -#} -#] -### Create user resource +# @name CreateUser +# Create a new user POST {{host}}/api/v1/sys/users Authorization: Bearer {{token}} Content-Type: application/json { - "id": "1", - "create_time": "2023-07-20T12:00:00Z", - "update_time": "2023-07-20T12:00:00Z", - "username": "user5", - "name": "User One", - "avatar": "avatar1.jpg", - "password": "password1", - "salt": "salt1", - "phone": "1234567890", - "email": "user1@example.com", - "remark": "Remark for User One", - "status": 1, - "edges": {} + "user": { + "username": "testuser1", + "name": "Test User 1", + "nickname": "tester", + "email": "testuser1@example.com", + "status": 1 + }, + "password": "password123" +} + +### + +# @name CreateUserWithRandomPassword +# Create a new user with a random password +POST {{host}}/api/v1/sys/users +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "user": { + "username": "testuser2", + "name": "Test User 2", + "nickname": "tester2", + "email": "testuser2@example.com", + "status": 1 + }, + "random_password": true +} + +### +# RBAC - Permissions +### + +# @name ListPermissions +# List all permissions with pagination +GET {{host}}/api/v1/sys/permissions?page=1&page_size=10 +Authorization: Bearer {{token}} + +### + +# @name CreatePermission +# Create a new permission +POST {{host}}/api/v1/sys/permissions +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "permission": { + "name": "Read Articles", + "keyword": "article:read" + } } +### +# RBAC - Departments +### + +# @name CreateDepartment +# Create a new department +POST {{host}}/api/v1/sys/departments +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "department": { + "name": "Engineering", + "status": 1 + } +} +### +# RBAC - Menus ### -### Create user resource with random password -POST {{host}}/api/v1/sys/users?random_password=true +# @name CreateMenu +# Create a new menu +POST {{host}}/api/v1/sys/menus Authorization: Bearer {{token}} Content-Type: application/json { - "id": "1", - "create_time": "2023-07-20T12:00:00Z", - "update_time": "2023-07-20T12:00:00Z", - "username": "user6", - "name": "User One", - "avatar": "avatar1.jpg", - "password": "password1", - "salt": "salt1", - "phone": "1234567890", - "email": "user1@example.com", - "remark": "Remark for User One", - "status": 1, - "edges": {} + "menu": { + "name": "Dashboard", + "path": "/dashboard", + "component": "Layout" + } } -### \ No newline at end of file +### +# RBAC - Positions +### + +# @name CreatePosition +# Create a new position +POST {{host}}/api/v1/sys/positions +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "position": { + "name": "Software Engineer", + "keyword": "swe" + } +} + +### diff --git a/api/http/api/v1/sys/rbac.service.http b/api/http/api/v1/sys/rbac.service.http new file mode 100644 index 00000000..33e07e3a --- /dev/null +++ b/api/http/api/v1/sys/rbac.service.http @@ -0,0 +1,179 @@ +@token = eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzYyNzEyMDEsImlzcyI6ImxvY2FsaG9zdCIsInN1YiI6ImFkbWluIn0.3x9WnK9OZQUFdYYBAwVwqtNrMK3VRZJjBgQXRnQLNd8K4m0WwfTyAiA1TfwlUyh8t95WXfl99AkXJEJUWAQppg +@host = http://127.0.0.1:8080 + +### +# RBAC - Resources (Direct Service Test) +### + +# @name ListResources +# List all resources with pagination +GET {{host}}/sys/resources?page=1&page_size=10 +Authorization: Bearer {{token}} + +### + +# @name CreateResource +# Create a new resource +POST {{host}}/sys/resources +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "resource": { + "name": "New Resource", + "type": "api", + "path": "/api/v1/new/resource" + } +} + +### +# RBAC - Roles (Direct Service Test) +### + +# @name ListRoles +# List all roles with pagination +GET {{host}}/sys/roles?page=1&page_size=10 +Authorization: Bearer {{token}} + +### + +# @name CreateRole +# Create a new role +POST {{host}}/sys/roles +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "role": { + "keyword": "new_role", + "name": "New Role", + "description": "A newly created role", + "sequence": 10, + "status": 1 + } +} + +### +# RBAC - Users (Direct Service Test) +### + +# @name ListUsers +# List all users with pagination +GET {{host}}/sys/users?page=1&page_size=10 +Authorization: Bearer {{token}} + +### + +# @name CreateUser +# Create a new user +POST {{host}}/sys/users +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "user": { + "username": "testuser1", + "name": "Test User 1", + "nickname": "tester", + "email": "testuser1@example.com", + "status": 1 + }, + "password": "password123" +} + +### + +# @name CreateUserWithRandomPassword +# Create a new user with a random password +POST {{host}}/sys/users +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "user": { + "username": "testuser2", + "name": "Test User 2", + "nickname": "tester2", + "email": "testuser2@example.com", + "status": 1 + }, + "random_password": true +} + +### +# RBAC - Permissions (Direct Service Test) +### + +# @name ListPermissions +# List all permissions with pagination +GET {{host}}/sys/permissions?page=1&page_size=10 +Authorization: Bearer {{token}} + +### + +# @name CreatePermission +# Create a new permission +POST {{host}}/sys/permissions +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "permission": { + "name": "Read Articles", + "keyword": "article:read" + } +} + +### +# RBAC - Departments (Direct Service Test) +### + +# @name CreateDepartment +# Create a new department +POST {{host}}/sys/departments +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "department": { + "name": "Engineering", + "status": 1 + } +} + +### +# RBAC - Menus (Direct Service Test) +### + +# @name CreateMenu +# Create a new menu +POST {{host}}/sys/menus +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "menu": { + "name": "Dashboard", + "path": "/dashboard", + "component": "Layout" + } +} + +### +# RBAC - Positions (Direct Service Test) +### + +# @name CreatePosition +# Create a new position +POST {{host}}/sys/positions +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "position": { + "name": "Software Engineer", + "keyword": "swe" + } +} + +### diff --git a/api/v1/proto/system/department.proto b/api/v1/proto/system/department.proto index 18afbf30..4b88dff8 100644 --- a/api/v1/proto/system/department.proto +++ b/api/v1/proto/system/department.proto @@ -24,7 +24,7 @@ service DepartmentService { rpc CreateDepartment(CreateDepartmentRequest) returns (CreateDepartmentResponse) { option (google.api.http) = { post: "/sys/departments" - body: "department" + body: "*" }; } rpc UpdateDepartment(UpdateDepartmentRequest) returns (UpdateDepartmentResponse) { diff --git a/api/v1/proto/system/menu.proto b/api/v1/proto/system/menu.proto index c038d35e..f3c4212c 100644 --- a/api/v1/proto/system/menu.proto +++ b/api/v1/proto/system/menu.proto @@ -24,7 +24,7 @@ service MenuService { rpc CreateMenu(CreateMenuRequest) returns (CreateMenuResponse) { option (google.api.http) = { post: "/sys/menus" - body: "menu" + body: "*" }; } rpc UpdateMenu(UpdateMenuRequest) returns (UpdateMenuResponse) { diff --git a/api/v1/proto/system/permission.proto b/api/v1/proto/system/permission.proto index 3b9e2b98..177ff247 100644 --- a/api/v1/proto/system/permission.proto +++ b/api/v1/proto/system/permission.proto @@ -24,7 +24,7 @@ service PermissionService { rpc CreatePermission(CreatePermissionRequest) returns (CreatePermissionResponse) { option (google.api.http) = { post: "/sys/permissions" - body: "permission" + body: "*" }; } rpc UpdatePermission(UpdatePermissionRequest) returns (UpdatePermissionResponse) { diff --git a/api/v1/proto/system/position.proto b/api/v1/proto/system/position.proto index 05fbccc0..018d2af6 100644 --- a/api/v1/proto/system/position.proto +++ b/api/v1/proto/system/position.proto @@ -24,7 +24,7 @@ service PositionService { rpc CreatePosition(CreatePositionRequest) returns (CreatePositionResponse) { option (google.api.http) = { post: "/sys/positions" - body: "position" + body: "*" }; } rpc UpdatePosition(UpdatePositionRequest) returns (UpdatePositionResponse) { diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index 2bea3a3f..eba7c0ba 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -24,7 +24,7 @@ service ResourceService { rpc CreateResource(CreateResourceRequest) returns (CreateResourceResponse) { option (google.api.http) = { post: "/sys/resources" - body: "resource" + body: "*" }; } rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) { diff --git a/api/v1/proto/system/role.proto b/api/v1/proto/system/role.proto index d4dac31c..ad492580 100644 --- a/api/v1/proto/system/role.proto +++ b/api/v1/proto/system/role.proto @@ -24,7 +24,7 @@ service RoleService { rpc CreateRole(CreateRoleRequest) returns (CreateRoleResponse) { option (google.api.http) = { post: "/sys/roles" - body: "role" + body: "*" }; } rpc UpdateRole(UpdateRoleRequest) returns (UpdateRoleResponse) { diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index 5f6577d0..431cdece 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -29,7 +29,7 @@ service UserService { rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) { option (google.api.http) = { post: "/sys/users" - body: "user" + body: "*" }; } rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse) { diff --git a/api/v1/services/system/department.pb.go b/api/v1/services/system/department.pb.go index 7df2a2f1..090fd229 100644 --- a/api/v1/services/system/department.pb.go +++ b/api/v1/services/system/department.pb.go @@ -655,12 +655,11 @@ const file_system_department_proto_rawDesc = "" + "\x17DeleteDepartmentRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + "\x18DeleteDepartmentResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x93\x06\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x8a\x06\n" + "\x11DepartmentService\x12\x8c\x01\n" + "\x0fListDepartments\x12..api.v1.services.system.ListDepartmentsRequest\x1a/.api.v1.services.system.ListDepartmentsResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/departments\x12\x8b\x01\n" + - "\rGetDepartment\x12,.api.v1.services.system.GetDepartmentRequest\x1a-.api.v1.services.system.GetDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/departments/{id}\x12\x9b\x01\n" + - "\x10CreateDepartment\x12/.api.v1.services.system.CreateDepartmentRequest\x1a0.api.v1.services.system.CreateDepartmentResponse\"$\x82\xd3\xe4\x93\x02\x1e:\n" + - "department\"\x10/sys/departments\x12\xab\x01\n" + + "\rGetDepartment\x12,.api.v1.services.system.GetDepartmentRequest\x1a-.api.v1.services.system.GetDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/departments/{id}\x12\x92\x01\n" + + "\x10CreateDepartment\x12/.api.v1.services.system.CreateDepartmentRequest\x1a0.api.v1.services.system.CreateDepartmentResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/sys/departments\x12\xab\x01\n" + "\x10UpdateDepartment\x12/.api.v1.services.system.UpdateDepartmentRequest\x1a0.api.v1.services.system.UpdateDepartmentResponse\"4\x82\xd3\xe4\x93\x02.:\n" + "department\x1a /sys/departments/{department.id}\x12\x94\x01\n" + "\x10DeleteDepartment\x12/.api.v1.services.system.DeleteDepartmentRequest\x1a0.api.v1.services.system.DeleteDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/departments/{id}B\xe4\x01\n" + diff --git a/api/v1/services/system/department.pb.gw.go b/api/v1/services/system/department.pb.gw.go index 6a34e28f..97ea84fd 100644 --- a/api/v1/services/system/department.pb.gw.go +++ b/api/v1/services/system/department.pb.gw.go @@ -105,20 +105,12 @@ func local_request_DepartmentService_GetDepartment_0(ctx context.Context, marsha return msg, metadata, err } -var filter_DepartmentService_CreateDepartment_0 = &utilities.DoubleArray{Encoding: map[string]int{"department": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - func request_DepartmentService_CreateDepartment_0(ctx context.Context, marshaler runtime.Marshaler, client DepartmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq CreateDepartmentRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Department); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_CreateDepartment_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CreateDepartment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -130,13 +122,7 @@ func local_request_DepartmentService_CreateDepartment_0(ctx context.Context, mar protoReq CreateDepartmentRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Department); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DepartmentService_CreateDepartment_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateDepartment(ctx, &protoReq) diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go index 65ca7403..03833d7c 100644 --- a/api/v1/services/system/department_bridge.pb.go +++ b/api/v1/services/system/department_bridge.pb.go @@ -136,7 +136,7 @@ func _DepartmentService_GetDepartment0_Bridge_Handler(srv DepartmentServiceHooke func _DepartmentService_CreateDepartment0_Bridge_Handler(srv DepartmentServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateDepartmentRequest - if err := ctx.Bind(&in.Department); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/department_http.pb.go b/api/v1/services/system/department_http.pb.go index 1420bdf9..7bfe47d1 100644 --- a/api/v1/services/system/department_http.pb.go +++ b/api/v1/services/system/department_http.pb.go @@ -86,7 +86,7 @@ func _DepartmentService_GetDepartment0_HTTP_Handler(srv DepartmentServiceHTTPSer func _DepartmentService_CreateDepartment0_HTTP_Handler(srv DepartmentServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateDepartmentRequest - if err := ctx.Bind(&in.Department); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -174,7 +174,7 @@ func (c *DepartmentServiceHTTPClientImpl) CreateDepartment(ctx context.Context, path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationDepartmentServiceCreateDepartment)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Department, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/system/menu.pb.go b/api/v1/services/system/menu.pb.go index d423a9cb..e194fe21 100644 --- a/api/v1/services/system/menu.pb.go +++ b/api/v1/services/system/menu.pb.go @@ -647,13 +647,13 @@ const file_system_menu_proto_rawDesc = "" + "\x11DeleteMenuRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + "\x12DeleteMenuResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xff\x04\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xfc\x04\n" + "\vMenuService\x12t\n" + "\tListMenus\x12(.api.v1.services.system.ListMenusRequest\x1a).api.v1.services.system.ListMenusResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + "/sys/menus\x12s\n" + - "\aGetMenu\x12&.api.v1.services.system.GetMenuRequest\x1a'.api.v1.services.system.GetMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/menus/{id}\x12}\n" + + "\aGetMenu\x12&.api.v1.services.system.GetMenuRequest\x1a'.api.v1.services.system.GetMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/menus/{id}\x12z\n" + "\n" + - "CreateMenu\x12).api.v1.services.system.CreateMenuRequest\x1a*.api.v1.services.system.CreateMenuResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04menu\"\n" + + "CreateMenu\x12).api.v1.services.system.CreateMenuRequest\x1a*.api.v1.services.system.CreateMenuResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + "/sys/menus\x12\x87\x01\n" + "\n" + "UpdateMenu\x12).api.v1.services.system.UpdateMenuRequest\x1a*.api.v1.services.system.UpdateMenuResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04menu\x1a\x14/sys/menus/{menu.id}\x12|\n" + diff --git a/api/v1/services/system/menu.pb.gw.go b/api/v1/services/system/menu.pb.gw.go index 507b36f2..e3fd0ee7 100644 --- a/api/v1/services/system/menu.pb.gw.go +++ b/api/v1/services/system/menu.pb.gw.go @@ -105,20 +105,12 @@ func local_request_MenuService_GetMenu_0(ctx context.Context, marshaler runtime. return msg, metadata, err } -var filter_MenuService_CreateMenu_0 = &utilities.DoubleArray{Encoding: map[string]int{"menu": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - func request_MenuService_CreateMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq CreateMenuRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_CreateMenu_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CreateMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -130,13 +122,7 @@ func local_request_MenuService_CreateMenu_0(ctx context.Context, marshaler runti protoReq CreateMenuRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_CreateMenu_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateMenu(ctx, &protoReq) diff --git a/api/v1/services/system/menu_bridge.pb.go b/api/v1/services/system/menu_bridge.pb.go index 03afbf8b..196e0b18 100644 --- a/api/v1/services/system/menu_bridge.pb.go +++ b/api/v1/services/system/menu_bridge.pb.go @@ -136,7 +136,7 @@ func _MenuService_GetMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx func _MenuService_CreateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateMenuRequest - if err := ctx.Bind(&in.Menu); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/menu_http.pb.go b/api/v1/services/system/menu_http.pb.go index ff62da43..45b4440d 100644 --- a/api/v1/services/system/menu_http.pb.go +++ b/api/v1/services/system/menu_http.pb.go @@ -86,7 +86,7 @@ func _MenuService_GetMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http func _MenuService_CreateMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateMenuRequest - if err := ctx.Bind(&in.Menu); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -174,7 +174,7 @@ func (c *MenuServiceHTTPClientImpl) CreateMenu(ctx context.Context, in *CreateMe path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationMenuServiceCreateMenu)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Menu, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/system/permission.pb.go b/api/v1/services/system/permission.pb.go index beca8545..d3511f86 100644 --- a/api/v1/services/system/permission.pb.go +++ b/api/v1/services/system/permission.pb.go @@ -665,12 +665,11 @@ const file_system_permission_proto_rawDesc = "" + "\x17DeletePermissionRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + "\x18DeletePermissionResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x93\x06\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x8a\x06\n" + "\x11PermissionService\x12\x8c\x01\n" + "\x0fListPermissions\x12..api.v1.services.system.ListPermissionsRequest\x1a/.api.v1.services.system.ListPermissionsResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/permissions\x12\x8b\x01\n" + - "\rGetPermission\x12,.api.v1.services.system.GetPermissionRequest\x1a-.api.v1.services.system.GetPermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/permissions/{id}\x12\x9b\x01\n" + - "\x10CreatePermission\x12/.api.v1.services.system.CreatePermissionRequest\x1a0.api.v1.services.system.CreatePermissionResponse\"$\x82\xd3\xe4\x93\x02\x1e:\n" + - "permission\"\x10/sys/permissions\x12\xab\x01\n" + + "\rGetPermission\x12,.api.v1.services.system.GetPermissionRequest\x1a-.api.v1.services.system.GetPermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/permissions/{id}\x12\x92\x01\n" + + "\x10CreatePermission\x12/.api.v1.services.system.CreatePermissionRequest\x1a0.api.v1.services.system.CreatePermissionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/sys/permissions\x12\xab\x01\n" + "\x10UpdatePermission\x12/.api.v1.services.system.UpdatePermissionRequest\x1a0.api.v1.services.system.UpdatePermissionResponse\"4\x82\xd3\xe4\x93\x02.:\n" + "permission\x1a /sys/permissions/{permission.id}\x12\x94\x01\n" + "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xe4\x01\n" + diff --git a/api/v1/services/system/permission.pb.gw.go b/api/v1/services/system/permission.pb.gw.go index 77dfdf2c..4a5053f0 100644 --- a/api/v1/services/system/permission.pb.gw.go +++ b/api/v1/services/system/permission.pb.gw.go @@ -105,20 +105,12 @@ func local_request_PermissionService_GetPermission_0(ctx context.Context, marsha return msg, metadata, err } -var filter_PermissionService_CreatePermission_0 = &utilities.DoubleArray{Encoding: map[string]int{"permission": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - func request_PermissionService_CreatePermission_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq CreatePermissionRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_CreatePermission_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CreatePermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -130,13 +122,7 @@ func local_request_PermissionService_CreatePermission_0(ctx context.Context, mar protoReq CreatePermissionRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_CreatePermission_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreatePermission(ctx, &protoReq) diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go index 9648b59b..188a6d8b 100644 --- a/api/v1/services/system/permission_bridge.pb.go +++ b/api/v1/services/system/permission_bridge.pb.go @@ -136,7 +136,7 @@ func _PermissionService_GetPermission0_Bridge_Handler(srv PermissionServiceHooke func _PermissionService_CreatePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreatePermissionRequest - if err := ctx.Bind(&in.Permission); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/permission_http.pb.go b/api/v1/services/system/permission_http.pb.go index 51616cbb..971bc1da 100644 --- a/api/v1/services/system/permission_http.pb.go +++ b/api/v1/services/system/permission_http.pb.go @@ -86,7 +86,7 @@ func _PermissionService_GetPermission0_HTTP_Handler(srv PermissionServiceHTTPSer func _PermissionService_CreatePermission0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreatePermissionRequest - if err := ctx.Bind(&in.Permission); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -174,7 +174,7 @@ func (c *PermissionServiceHTTPClientImpl) CreatePermission(ctx context.Context, path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationPermissionServiceCreatePermission)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Permission, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/system/position.pb.go b/api/v1/services/system/position.pb.go index ffbfbc02..859ed4ff 100644 --- a/api/v1/services/system/position.pb.go +++ b/api/v1/services/system/position.pb.go @@ -644,11 +644,11 @@ const file_system_position_proto_rawDesc = "" + "\x15DeletePositionRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + "\x16DeletePositionResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xe3\x05\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xdc\x05\n" + "\x0fPositionService\x12\x84\x01\n" + "\rListPositions\x12,.api.v1.services.system.ListPositionsRequest\x1a-.api.v1.services.system.ListPositionsResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/positions\x12\x83\x01\n" + - "\vGetPosition\x12*.api.v1.services.system.GetPositionRequest\x1a+.api.v1.services.system.GetPositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/positions/{id}\x12\x91\x01\n" + - "\x0eCreatePosition\x12-.api.v1.services.system.CreatePositionRequest\x1a..api.v1.services.system.CreatePositionResponse\" \x82\xd3\xe4\x93\x02\x1a:\bposition\"\x0e/sys/positions\x12\x9f\x01\n" + + "\vGetPosition\x12*.api.v1.services.system.GetPositionRequest\x1a+.api.v1.services.system.GetPositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/positions/{id}\x12\x8a\x01\n" + + "\x0eCreatePosition\x12-.api.v1.services.system.CreatePositionRequest\x1a..api.v1.services.system.CreatePositionResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/sys/positions\x12\x9f\x01\n" + "\x0eUpdatePosition\x12-.api.v1.services.system.UpdatePositionRequest\x1a..api.v1.services.system.UpdatePositionResponse\".\x82\xd3\xe4\x93\x02(:\bposition\x1a\x1c/sys/positions/{position.id}\x12\x8c\x01\n" + "\x0eDeletePosition\x12-.api.v1.services.system.DeletePositionRequest\x1a..api.v1.services.system.DeletePositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/positions/{id}B\xe2\x01\n" + "\x1acom.api.v1.services.systemB\rPositionProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" diff --git a/api/v1/services/system/position.pb.gw.go b/api/v1/services/system/position.pb.gw.go index 1d7fcf6b..d6e88372 100644 --- a/api/v1/services/system/position.pb.gw.go +++ b/api/v1/services/system/position.pb.gw.go @@ -105,20 +105,12 @@ func local_request_PositionService_GetPosition_0(ctx context.Context, marshaler return msg, metadata, err } -var filter_PositionService_CreatePosition_0 = &utilities.DoubleArray{Encoding: map[string]int{"position": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - func request_PositionService_CreatePosition_0(ctx context.Context, marshaler runtime.Marshaler, client PositionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq CreatePositionRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Position); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_CreatePosition_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CreatePosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -130,13 +122,7 @@ func local_request_PositionService_CreatePosition_0(ctx context.Context, marshal protoReq CreatePositionRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Position); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PositionService_CreatePosition_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreatePosition(ctx, &protoReq) diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go index 037f1db0..c518fd36 100644 --- a/api/v1/services/system/position_bridge.pb.go +++ b/api/v1/services/system/position_bridge.pb.go @@ -136,7 +136,7 @@ func _PositionService_GetPosition0_Bridge_Handler(srv PositionServiceHookedBridg func _PositionService_CreatePosition0_Bridge_Handler(srv PositionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreatePositionRequest - if err := ctx.Bind(&in.Position); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/position_http.pb.go b/api/v1/services/system/position_http.pb.go index 6ded04a3..fbc276ab 100644 --- a/api/v1/services/system/position_http.pb.go +++ b/api/v1/services/system/position_http.pb.go @@ -86,7 +86,7 @@ func _PositionService_GetPosition0_HTTP_Handler(srv PositionServiceHTTPServer) f func _PositionService_CreatePosition0_HTTP_Handler(srv PositionServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreatePositionRequest - if err := ctx.Bind(&in.Position); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -174,7 +174,7 @@ func (c *PositionServiceHTTPClientImpl) CreatePosition(ctx context.Context, in * path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationPositionServiceCreatePosition)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Position, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go index be71731b..3d5416e6 100644 --- a/api/v1/services/system/resource.pb.go +++ b/api/v1/services/system/resource.pb.go @@ -666,11 +666,11 @@ const file_system_resource_proto_rawDesc = "" + "\x15DeleteResourceRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + "\x16DeleteResourceResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xe3\x05\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xdc\x05\n" + "\x0fResourceService\x12\x84\x01\n" + "\rListResources\x12,.api.v1.services.system.ListResourcesRequest\x1a-.api.v1.services.system.ListResourcesResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/resources\x12\x83\x01\n" + - "\vGetResource\x12*.api.v1.services.system.GetResourceRequest\x1a+.api.v1.services.system.GetResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/resources/{id}\x12\x91\x01\n" + - "\x0eCreateResource\x12-.api.v1.services.system.CreateResourceRequest\x1a..api.v1.services.system.CreateResourceResponse\" \x82\xd3\xe4\x93\x02\x1a:\bresource\"\x0e/sys/resources\x12\x9f\x01\n" + + "\vGetResource\x12*.api.v1.services.system.GetResourceRequest\x1a+.api.v1.services.system.GetResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/resources/{id}\x12\x8a\x01\n" + + "\x0eCreateResource\x12-.api.v1.services.system.CreateResourceRequest\x1a..api.v1.services.system.CreateResourceResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/sys/resources\x12\x9f\x01\n" + "\x0eUpdateResource\x12-.api.v1.services.system.UpdateResourceRequest\x1a..api.v1.services.system.UpdateResourceResponse\".\x82\xd3\xe4\x93\x02(:\bresource\x1a\x1c/sys/resources/{resource.id}\x12\x8c\x01\n" + "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xe2\x01\n" + "\x1acom.api.v1.services.systemB\rResourceProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" diff --git a/api/v1/services/system/resource.pb.gw.go b/api/v1/services/system/resource.pb.gw.go index 36912fc0..1fb9643b 100644 --- a/api/v1/services/system/resource.pb.gw.go +++ b/api/v1/services/system/resource.pb.gw.go @@ -105,20 +105,12 @@ func local_request_ResourceService_GetResource_0(ctx context.Context, marshaler return msg, metadata, err } -var filter_ResourceService_CreateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{"resource": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - func request_ResourceService_CreateResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq CreateResourceRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_CreateResource_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CreateResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -130,13 +122,7 @@ func local_request_ResourceService_CreateResource_0(ctx context.Context, marshal protoReq CreateResourceRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_CreateResource_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateResource(ctx, &protoReq) diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go index 4b19f3e1..3cb6e419 100644 --- a/api/v1/services/system/resource_bridge.pb.go +++ b/api/v1/services/system/resource_bridge.pb.go @@ -136,7 +136,7 @@ func _ResourceService_GetResource0_Bridge_Handler(srv ResourceServiceHookedBridg func _ResourceService_CreateResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateResourceRequest - if err := ctx.Bind(&in.Resource); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/resource_http.pb.go b/api/v1/services/system/resource_http.pb.go index 05816b6c..f3e3a47f 100644 --- a/api/v1/services/system/resource_http.pb.go +++ b/api/v1/services/system/resource_http.pb.go @@ -86,7 +86,7 @@ func _ResourceService_GetResource0_HTTP_Handler(srv ResourceServiceHTTPServer) f func _ResourceService_CreateResource0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateResourceRequest - if err := ctx.Bind(&in.Resource); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -174,7 +174,7 @@ func (c *ResourceServiceHTTPClientImpl) CreateResource(ctx context.Context, in * path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationResourceServiceCreateResource)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Resource, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/system/role.pb.go b/api/v1/services/system/role.pb.go index 9c5c692d..2be3e16f 100644 --- a/api/v1/services/system/role.pb.go +++ b/api/v1/services/system/role.pb.go @@ -645,13 +645,13 @@ const file_system_role_proto_rawDesc = "" + "\x11DeleteRoleRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + "\x12DeleteRoleResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xff\x04\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xfc\x04\n" + "\vRoleService\x12t\n" + "\tListRoles\x12(.api.v1.services.system.ListRolesRequest\x1a).api.v1.services.system.ListRolesResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + "/sys/roles\x12s\n" + - "\aGetRole\x12&.api.v1.services.system.GetRoleRequest\x1a'.api.v1.services.system.GetRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/roles/{id}\x12}\n" + + "\aGetRole\x12&.api.v1.services.system.GetRoleRequest\x1a'.api.v1.services.system.GetRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/roles/{id}\x12z\n" + "\n" + - "CreateRole\x12).api.v1.services.system.CreateRoleRequest\x1a*.api.v1.services.system.CreateRoleResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04role\"\n" + + "CreateRole\x12).api.v1.services.system.CreateRoleRequest\x1a*.api.v1.services.system.CreateRoleResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + "/sys/roles\x12\x87\x01\n" + "\n" + "UpdateRole\x12).api.v1.services.system.UpdateRoleRequest\x1a*.api.v1.services.system.UpdateRoleResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04role\x1a\x14/sys/roles/{role.id}\x12|\n" + diff --git a/api/v1/services/system/role.pb.gw.go b/api/v1/services/system/role.pb.gw.go index 7f3f6e9a..de552e88 100644 --- a/api/v1/services/system/role.pb.gw.go +++ b/api/v1/services/system/role.pb.gw.go @@ -105,20 +105,12 @@ func local_request_RoleService_GetRole_0(ctx context.Context, marshaler runtime. return msg, metadata, err } -var filter_RoleService_CreateRole_0 = &utilities.DoubleArray{Encoding: map[string]int{"role": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - func request_RoleService_CreateRole_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq CreateRoleRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_CreateRole_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CreateRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -130,13 +122,7 @@ func local_request_RoleService_CreateRole_0(ctx context.Context, marshaler runti protoReq CreateRoleRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_CreateRole_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateRole(ctx, &protoReq) diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go index bb313daf..c16497d5 100644 --- a/api/v1/services/system/role_bridge.pb.go +++ b/api/v1/services/system/role_bridge.pb.go @@ -136,7 +136,7 @@ func _RoleService_GetRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx func _RoleService_CreateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateRoleRequest - if err := ctx.Bind(&in.Role); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/role_http.pb.go b/api/v1/services/system/role_http.pb.go index 4b10fbf7..4c486700 100644 --- a/api/v1/services/system/role_http.pb.go +++ b/api/v1/services/system/role_http.pb.go @@ -86,7 +86,7 @@ func _RoleService_GetRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http func _RoleService_CreateRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateRoleRequest - if err := ctx.Bind(&in.Role); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -174,7 +174,7 @@ func (c *RoleServiceHTTPClientImpl) CreateRole(ctx context.Context, in *CreateRo path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationRoleServiceCreateRole)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Role, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go index 144ded6c..3481153d 100644 --- a/api/v1/services/system/user.pb.go +++ b/api/v1/services/system/user.pb.go @@ -1109,14 +1109,14 @@ const file_system_user_proto_rawDesc = "" + "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x1a\n" + "\brole_ids\x18\x03 \x03(\x03R\brole_ids\"J\n" + "\x17UpdateUserRolesResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\xfc\t\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\xf9\t\n" + "\vUserService\x12t\n" + "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + "/sys/users\x12\x9b\x01\n" + "\x11ListUserResources\x120.api.v1.services.system.ListUserResourcesRequest\x1a1.api.v1.services.system.ListUserResourcesResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/sys/users/{id}/resources\x12s\n" + - "\aGetUser\x12&.api.v1.services.system.GetUserRequest\x1a'.api.v1.services.system.GetUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/users/{id}\x12}\n" + + "\aGetUser\x12&.api.v1.services.system.GetUserRequest\x1a'.api.v1.services.system.GetUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/users/{id}\x12z\n" + "\n" + - "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a*.api.v1.services.system.CreateUserResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x04user\"\n" + + "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a*.api.v1.services.system.CreateUserResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + "/sys/users\x12\x87\x01\n" + "\n" + "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04user\x1a\x14/sys/users/{user.id}\x12|\n" + diff --git a/api/v1/services/system/user.pb.gw.go b/api/v1/services/system/user.pb.gw.go index f8be51a7..b9fec933 100644 --- a/api/v1/services/system/user.pb.gw.go +++ b/api/v1/services/system/user.pb.gw.go @@ -142,20 +142,12 @@ func local_request_UserService_GetUser_0(ctx context.Context, marshaler runtime. return msg, metadata, err } -var filter_UserService_CreateUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - func request_UserService_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq CreateUserRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_CreateUser_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.CreateUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -167,13 +159,7 @@ func local_request_UserService_CreateUser_0(ctx context.Context, marshaler runti protoReq CreateUserRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_CreateUser_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.CreateUser(ctx, &protoReq) diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 2627437b..37aeae0f 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -197,7 +197,7 @@ func _UserService_GetUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx func _UserService_CreateUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateUserRequest - if err := ctx.Bind(&in.User); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/user_http.pb.go b/api/v1/services/system/user_http.pb.go index 950d7350..68749962 100644 --- a/api/v1/services/system/user_http.pb.go +++ b/api/v1/services/system/user_http.pb.go @@ -123,7 +123,7 @@ func _UserService_GetUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http func _UserService_CreateUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in CreateUserRequest - if err := ctx.Bind(&in.User); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -293,7 +293,7 @@ func (c *UserServiceHTTPClientImpl) CreateUser(ctx context.Context, in *CreateUs path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationUserServiceCreateUser)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.User, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/cmd/system/main.go b/cmd/system/main.go index 2e48a6ba..f28b20c5 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -18,6 +18,7 @@ import ( runtimebootstrap "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" "origadmin/application/admin/internal/conf" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" confhelper "origadmin/application/admin/internal/helpers/conf" ) diff --git a/internal/features/system/dal/user.go b/internal/features/system/dal/user.go index 60aa9cd7..894a57af 100644 --- a/internal/features/system/dal/user.go +++ b/internal/features/system/dal/user.go @@ -8,6 +8,8 @@ import ( "context" "errors" + "github.com/google/uuid" + "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/user" @@ -46,6 +48,11 @@ func (r *userRepo) Create(ctx context.Context, u *types.User, password string, o } entUser := dto.ConvertUserPBToUser(u) + uuid, err := uuid.NewRandom() + if err != nil { + return nil, err + } + entUser.UUID = uuid.String() if password != "" { entUser.EncryptedPassword = password } diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index 240cfe09..8ab9efd6 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -16,13 +16,21 @@ import ( // ConvertGenderToString is a custom conversion function stub. // Please implement this function to complete the conversion. func ConvertGenderToString(from user.Gender) string { - // TODO: Implement this custom conversion - panic("stub! not implemented") + switch from { + case user.GenderFemale: + return "female" + default: + return "male" + } } // ConvertStringToGender is a custom conversion function stub. // Please implement this function to complete the conversion. func ConvertStringToGender(from string) user.Gender { - // TODO: Implement this custom conversion - panic("stub! not implemented") + switch from { + case "female": + return user.GenderFemale + default: + return user.GenderMale + } } diff --git a/internal/features/system/service/permission.go b/internal/features/system/service/permission.go index b961f93b..8f8e6e48 100644 --- a/internal/features/system/service/permission.go +++ b/internal/features/system/service/permission.go @@ -18,6 +18,8 @@ func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPer return &system.ListPermissionsResponse{ Permissions: permissions, Total: total, + Page: req.GetPage(), + PageSize: req.GetPageSize(), }, nil } diff --git a/internal/features/system/service/resource.go b/internal/features/system/service/resource.go index 32e4f84d..8a8a5bf3 100644 --- a/internal/features/system/service/resource.go +++ b/internal/features/system/service/resource.go @@ -18,6 +18,8 @@ func (s *SystemService) ListResources(ctx context.Context, req *system.ListResou return &system.ListResourcesResponse{ Resources: resources, Total: total, + Page: req.GetPage(), + PageSize: req.GetPageSize(), }, nil } diff --git a/internal/features/system/service/role.go b/internal/features/system/service/role.go index 2a6cf703..367c00d6 100644 --- a/internal/features/system/service/role.go +++ b/internal/features/system/service/role.go @@ -17,8 +17,10 @@ func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequ } return &system.ListRolesResponse{ - Roles: roles, - Total: total, + Roles: roles, + Total: total, + Page: req.GetPage(), + PageSize: req.GetPageSize(), }, nil } func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*system.GetRoleResponse, error) { diff --git a/internal/features/system/service/user.go b/internal/features/system/service/user.go index 9f7811c0..43687fe0 100644 --- a/internal/features/system/service/user.go +++ b/internal/features/system/service/user.go @@ -50,8 +50,10 @@ func (s *SystemService) ListUsers(ctx context.Context, req *system.ListUsersRequ return nil, err } return &system.ListUsersResponse{ - Users: users, - Total: total, + Users: users, + Total: total, + Page: req.GetPage(), + PageSize: req.GetPageSize(), }, nil } diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 592e1034..627e7248 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -1174,22 +1174,11 @@ paths: tags: - DepartmentService operationId: DepartmentService_CreateDepartment - parameters: - - name: parent - in: query - description: The parent resource id where the department is to be created. - schema: - type: string - - name: department_id - in: query - description: The department id to use for this department. - schema: - type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Department' + $ref: '#/components/schemas/api.v1.services.system.CreateDepartmentRequest' required: true responses: "200": @@ -1352,22 +1341,11 @@ paths: tags: - MenuService operationId: MenuService_CreateMenu - parameters: - - name: parent - in: query - description: The parent resource id where the menu is to be created. - schema: - type: string - - name: menu_id - in: query - description: The menu id to use for this menu. - schema: - type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Menu' + $ref: '#/components/schemas/api.v1.services.system.CreateMenuRequest' required: true responses: "200": @@ -1532,22 +1510,11 @@ paths: tags: - PermissionService operationId: PermissionService_CreatePermission - parameters: - - name: parent - in: query - description: The parent resource id where the permission is to be created. - schema: - type: string - - name: permission_id - in: query - description: The permission id to use for this permission. - schema: - type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Permission' + $ref: '#/components/schemas/api.v1.services.system.CreatePermissionRequest' required: true responses: "200": @@ -1710,22 +1677,11 @@ paths: tags: - PositionService operationId: PositionService_CreatePosition - parameters: - - name: parent - in: query - description: The parent resource id where the position is to be created. - schema: - type: string - - name: position_id - in: query - description: The position id to use for this position. - schema: - type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Position' + $ref: '#/components/schemas/api.v1.services.system.CreatePositionRequest' required: true responses: "200": @@ -1893,22 +1849,11 @@ paths: tags: - ResourceService operationId: ResourceService_CreateResource - parameters: - - name: parent - in: query - description: The parent resource id where the resource is to be created. - schema: - type: string - - name: resource_id - in: query - description: The resource id to use for this resource. - schema: - type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Resource' + $ref: '#/components/schemas/api.v1.services.system.CreateResourceRequest' required: true responses: "200": @@ -2071,22 +2016,11 @@ paths: tags: - RoleService operationId: RoleService_CreateRole - parameters: - - name: parent - in: query - description: The parent resource id where the role is to be created. - schema: - type: string - - name: role_id - in: query - description: The role id to use for this role. - schema: - type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Role' + $ref: '#/components/schemas/api.v1.services.system.CreateRoleRequest' required: true responses: "200": @@ -2249,37 +2183,11 @@ paths: tags: - UserService operationId: UserService_CreateUser - parameters: - - name: parent - in: query - description: The parent resource id where the user is to be created. - schema: - type: string - - name: password - in: query - description: The password to use for this user. - schema: - type: string - - name: user_id - in: query - description: The user id to use for this user. - schema: - type: string - - name: is_system - in: query - description: The user is_system to use for this user. - schema: - type: boolean - - name: random_password - in: query - description: The random_password is the query parameter for set only to generate a random password - schema: - type: boolean requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.User' + $ref: '#/components/schemas/api.v1.services.system.CreateUserRequest' required: true responses: "200": @@ -3170,38 +3078,148 @@ components: api.v1.services.message.UpdatePersonalSettingResponse: type: object properties: {} + api.v1.services.system.CreateDepartmentRequest: + type: object + properties: + parent: + type: string + description: The parent resource id where the department is to be created. + department_id: + type: string + description: The department id to use for this department. + department: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.Department' + description: |- + The department resource to create. + The field id should match the Noun in the method id. api.v1.services.system.CreateDepartmentResponse: type: object properties: department: $ref: '#/components/schemas/api.v1.services.types.Department' + api.v1.services.system.CreateMenuRequest: + type: object + properties: + parent: + type: string + description: The parent resource id where the menu is to be created. + menu_id: + type: string + description: The menu id to use for this menu. + menu: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.Menu' + description: |- + The menu resource to create. + The field id should match the Noun in the method id. + description: CreateMenuRequest is the request for the MenuService.CreateMenu method. api.v1.services.system.CreateMenuResponse: type: object properties: menu: $ref: '#/components/schemas/api.v1.services.types.Menu' description: CreateMenuResponse is the response for the MenuService.CreateMenu method. + api.v1.services.system.CreatePermissionRequest: + type: object + properties: + parent: + type: string + description: The parent resource id where the permission is to be created. + permission_id: + type: string + description: The permission id to use for this permission. + permission: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.Permission' + description: |- + The permission resource to create. + The field id should match the Noun in the method id. api.v1.services.system.CreatePermissionResponse: type: object properties: permission: $ref: '#/components/schemas/api.v1.services.types.Permission' + api.v1.services.system.CreatePositionRequest: + type: object + properties: + parent: + type: string + description: The parent resource id where the position is to be created. + position_id: + type: string + description: The position id to use for this position. + position: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.Position' + description: The position object to create. api.v1.services.system.CreatePositionResponse: type: object properties: position: $ref: '#/components/schemas/api.v1.services.types.Position' + api.v1.services.system.CreateResourceRequest: + type: object + properties: + parent: + type: string + description: The parent resource id where the resource is to be created. + resource_id: + type: string + description: The resource id to use for this resource. + resource: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.Resource' + description: The resource object to create. + description: CreateResourceRequest is the request for the ResourceService.CreateResource method. api.v1.services.system.CreateResourceResponse: type: object properties: resource: $ref: '#/components/schemas/api.v1.services.types.Resource' description: CreateResourceResponse is the response for the ResourceService.CreateResource method. + api.v1.services.system.CreateRoleRequest: + type: object + properties: + parent: + type: string + description: The parent resource id where the role is to be created. + role_id: + type: string + description: The role id to use for this role. + role: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.Role' + description: |- + The role resource to create. + The field id should match the Noun in the method id. api.v1.services.system.CreateRoleResponse: type: object properties: role: $ref: '#/components/schemas/api.v1.services.types.Role' + api.v1.services.system.CreateUserRequest: + type: object + properties: + parent: + type: string + description: The parent resource id where the user is to be created. + user: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.User' + description: The user resource to be created. + password: + type: string + description: The password to use for this user. + user_id: + type: string + description: The user id to use for this user. + is_system: + type: boolean + description: The user is_system to use for this user. + random_password: + type: boolean + description: The random_password is the query parameter for set only to generate a random password api.v1.services.system.CreateUserResponse: type: object properties: From 7a1745c65bd3aef04569ccea6173eb6c7272a6af Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 03:18:03 +0800 Subject: [PATCH 077/158] refactor(auth): remove default host option from AuthService proto definition --- api/v1/proto/auth/auth.proto | 1 - 1 file changed, 1 deletion(-) diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index 43b5db3d..9391e0af 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -14,7 +14,6 @@ option java_package = "com.origadmin.api.v1.services.auth"; option objc_class_prefix = "APIServiceAuthAuth"; service AuthService { - option (google.api.default_host) = "api.foo.com"; // ListAuthResources returns a list of Auths. rpc ListAuthResources(ListAuthResourcesRequest) returns (ListAuthResourcesResponse) { option (google.api.http) = {get: "/auth/resources"}; From 2eb611621f047fc5730e4fb0cbff75f0ee75be18 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 05:06:19 +0800 Subject: [PATCH 078/158] feat(system): replace Menu with View entity and refactor Resource schema to align with data model --- api/v1/proto/system/menu.proto | 132 +-------------- api/v1/proto/system/resource.proto | 80 ++++----- api/v1/proto/system/view.proto | 109 +++++++++++++ internal/data/entity/ent/generate.go | 2 +- internal/data/entity/ent/schema/department.go | 2 +- internal/data/entity/ent/schema/resource.go | 153 ++++-------------- internal/data/entity/ent/schema/softdelete.go | 4 +- internal/data/entity/ent/schema/user.go | 4 +- internal/data/entity/ent/schema/view.go | 69 ++++++++ internal/helpers/ent/mixin/field.go | 36 ++--- internal/helpers/ent/mixin/mixin.go | 147 ++++++++++++----- .../helpers/ent/mixin/mixin_generic_id.go | 45 ++++++ internal/helpers/ent/mixin/mixin_id.go | 2 +- internal/helpers/ent/mixin/mixin_uuid.go | 2 +- tools.go | 3 +- 15 files changed, 422 insertions(+), 368 deletions(-) create mode 100644 api/v1/proto/system/view.proto create mode 100644 internal/data/entity/ent/schema/view.go create mode 100644 internal/helpers/ent/mixin/mixin_generic_id.go diff --git a/api/v1/proto/system/menu.proto b/api/v1/proto/system/menu.proto index f3c4212c..3f7f1142 100644 --- a/api/v1/proto/system/menu.proto +++ b/api/v1/proto/system/menu.proto @@ -1,130 +1,2 @@ -syntax = "proto3"; - -package api.v1.services.system; - -import "google/api/annotations.proto"; -import "google/protobuf/any.proto"; -import "google/protobuf/empty.proto"; -import "types/system.proto"; - -option go_package = "origadmin/application/admin/api/v1/services/system;system"; -option java_multiple_files = true; -option java_outer_classname = "APIServiceSystemMenuProto"; -option java_package = "com.origadmin.api.v1.services.system"; -option objc_class_prefix = "APIServiceSystemMenu"; - -// The menu service definition. -service MenuService { - rpc ListMenus(ListMenusRequest) returns (ListMenusResponse) { - option (google.api.http) = {get: "/sys/menus"}; - } - rpc GetMenu(GetMenuRequest) returns (GetMenuResponse) { - option (google.api.http) = {get: "/sys/menus/{id}"}; - } - rpc CreateMenu(CreateMenuRequest) returns (CreateMenuResponse) { - option (google.api.http) = { - post: "/sys/menus" - body: "*" - }; - } - rpc UpdateMenu(UpdateMenuRequest) returns (UpdateMenuResponse) { - option (google.api.http) = { - put: "/sys/menus/{menu.id}" - body: "menu" - }; - } - rpc DeleteMenu(DeleteMenuRequest) returns (DeleteMenuResponse) { - option (google.api.http) = {delete: "/sys/menus/{id}"}; - } -} - -// ListMenusRequest is the request for the MenuService.ListMenus method. -message ListMenusRequest { - // The parent resource id, for example, "shelves/shelf1". - int64 id = 1 [json_name = "id"]; - // The page number. - int32 page = 2 [json_name = "page"]; - // The maximum number of items to return. - int32 page_size = 3 [json_name = "page_size"]; - // The next_page_token value returned from a previous List request, if any. - string page_token = 4 [json_name = "page_token"]; - // The no_paging is used to disable pagination. - bool no_paging = 5 [json_name = "no_paging"]; - // The only_count is the query parameter for set only to query the total number - bool only_count = 6 [json_name = "only_count"]; - // The keyword is the query parameter for set only to query the menu by keyword - string keyword = 7 [json_name = "keyword"]; -} - -// ListMenusResponse is the response for the MenuService.ListMenus method. -message ListMenusResponse { - // The total number of items in the list. - int32 total = 1 [json_name = "total"]; - // The paging menus - repeated api.v1.services.types.Menu menus = 2 [json_name = "menus"]; - // The page number. - int32 page = 3 [json_name = "page"]; - // The maximum number of items to return. - int32 page_size = 4 [json_name = "page_size"]; - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - string next_page_token = 5 [json_name = "next_page_token"]; - // Additional information about this response. - // content to be added without destroying the page data format - optional google.protobuf.Any extra = 6 [json_name = "extra"]; -} - -// GetMenuRequest is the request for the MenuService.GetMenu method. -message GetMenuRequest { - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/menus/menu2" - int64 id = 1; -} - -// GetMenuResponse is the response for the MenuService.GetMenu method. -message GetMenuResponse { - // The field id should match the Noun in the method id. - api.v1.services.types.Menu menu = 1; -} - -// CreateMenuRequest is the request for the MenuService.CreateMenu method. -message CreateMenuRequest { - // The parent resource id where the menu is to be created. - string parent = 1; - - // The menu id to use for this menu. - string menu_id = 3; - - // The menu resource to create. - // The field id should match the Noun in the method id. - api.v1.services.types.Menu menu = 2; -} - -// CreateMenuResponse is the response for the MenuService.CreateMenu method. -message CreateMenuResponse { - api.v1.services.types.Menu menu = 1; -} - -// UpdateMenuRequest is the request for the MenuService.UpdateMenu method. -message UpdateMenuRequest { - // The menu resource which replaces the resource on the server. - api.v1.services.types.Menu menu = 1; -} - -// UpdateMenuResponse is the response for the MenuService.UpdateMenu method. -message UpdateMenuResponse { - api.v1.services.types.Menu menu = 1; -} - -// DeleteMenuRequest is the request for the MenuService.DeleteMenu method. -message DeleteMenuRequest { - // The resource id of the menu to be deleted, for example: - // "shelves/shelf1/menus/menu2" - int64 id = 1; -} - -// DeleteMenuResponse is the response for the MenuService.DeleteMenu method. -message DeleteMenuResponse { - // or Menu menu = 1; or google.protobuf.Empty empty = 1; - google.protobuf.Empty empty = 1; -} +// This file is intentionally left empty and is pending deletion. +// The 'Menu' concept has been fully replaced by the more generic 'View' entity. diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index eba7c0ba..d005cb6c 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -14,118 +14,100 @@ option java_package = "com.origadmin.api.v1.services.system"; option objc_class_prefix = "APIServiceSystemResource"; // The resource service definition. +// A Resource represents a backend asset that requires access control, such as an HTTP API or a gRPC method. +// The definition of the Resource message in types/system.proto should be updated to include fields +// like service_name, path, method, operation, policy, version_id, last_sync_version_id, and sync_status +// as specified in 09_Data_Model_Schema.md. service ResourceService { + // Lists all backend resources. rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) { option (google.api.http) = {get: "/sys/resources"}; } + // Gets a single backend resource. rpc GetResource(GetResourceRequest) returns (GetResourceResponse) { option (google.api.http) = {get: "/sys/resources/{id}"}; } + // Creates a new backend resource. rpc CreateResource(CreateResourceRequest) returns (CreateResourceResponse) { option (google.api.http) = { post: "/sys/resources" body: "*" }; } + // Updates a backend resource. rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) { option (google.api.http) = { put: "/sys/resources/{resource.id}" body: "resource" }; } + // Deletes a backend resource. rpc DeleteResource(DeleteResourceRequest) returns (DeleteResourceResponse) { option (google.api.http) = {delete: "/sys/resources/{id}"}; } } -// ListResourcesRequest is the request for the ResourceService.ListResources method. +// Request message for ResourceService.ListResources. message ListResourcesRequest { - // The parent resource id, for example, "shelves/shelf1". int64 id = 1 [json_name = "id"]; - // The page number. int32 page = 2 [json_name = "page"]; - // The maximum number of items to return. int32 page_size = 3 [json_name = "page_size"]; - // The next_page_token value returned from a previous List request, if any. string page_token = 4 [json_name = "page_token"]; - // The no_paging is used to disable pagination. bool no_paging = 5 [json_name = "no_paging"]; - // The only_count is the query parameter for set only to query the total number bool only_count = 6 [json_name = "only_count"]; - // resource type - string type = 7 [json_name = "type"]; - // The resource name keyword - string keyword = 8 [json_name = "keyword"]; + string keyword = 7 [json_name = "keyword"]; + string service_name = 8 [json_name = "service_name"]; + string sync_status = 9 [json_name = "sync_status"]; } -// ListResourcesResponse is the response for the ResourceService.ListResources method. +// Response message for ResourceService.ListResources. message ListResourcesResponse { - // The total number of items in the list. int32 total = 1 [json_name = "total"]; - // The paging resources repeated api.v1.services.types.Resource resources = 2 [json_name = "resources"]; - // The page number. int32 page = 3 [json_name = "page"]; - // The maximum number of items to return. int32 page_size = 4 [json_name = "page_size"]; - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. string next_page_token = 5 [json_name = "next_page_token"]; - // Additional information about this response. - // content to be added without destroying the page data format optional google.protobuf.Any extra = 6 [json_name = "extra"]; } -// GetResourceRequest is the request for the ResourceService.GetResource method. +// Request message for ResourceService.GetResource. message GetResourceRequest { - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/resources/resource2" - int64 id = 1 [json_name = "id"]; + int64 id = 1; } -// GetResourceResponse is the response for the ResourceService.GetResource method. +// Response message for ResourceService.GetResource. message GetResourceResponse { - // The field id should match the Noun in the method id. - api.v1.services.types.Resource resource = 1 [json_name = "resource"]; + api.v1.services.types.Resource resource = 1; } -// CreateResourceRequest is the request for the ResourceService.CreateResource method. +// Request message for ResourceService.CreateResource. message CreateResourceRequest { - // The parent resource id where the resource is to be created. - string parent = 1 [json_name = "parent"]; - // The resource id to use for this resource. - string resource_id = 2 [json_name = "resource_id"]; - // The resource object to create. - api.v1.services.types.Resource resource = 3 [json_name = "resource"]; + string parent = 1; + string resource_id = 2; + api.v1.services.types.Resource resource = 3; } -// CreateResourceResponse is the response for the ResourceService.CreateResource method. +// Response message for ResourceService.CreateResource. message CreateResourceResponse { - api.v1.services.types.Resource resource = 1 [json_name = "resource"]; + api.v1.services.types.Resource resource = 1; } -// UpdateResourceRequest is the request for the ResourceService.UpdateResource method. +// Request message for ResourceService.UpdateResource. message UpdateResourceRequest { - // The id of the resource object to update. - int64 id = 1 [json_name = "id"]; - // The resource object which replaces the resource on the server. - api.v1.services.types.Resource resource = 2 [json_name = "resource"]; + api.v1.services.types.Resource resource = 1; } -// UpdateResourceResponse is the response for the ResourceService.UpdateResource method. +// Response message for ResourceService.UpdateResource. message UpdateResourceResponse { - api.v1.services.types.Resource resource = 1 [json_name = "resource"]; + api.v1.services.types.Resource resource = 1; } -// DeleteResourceRequest is the request for the ResourceService.DeleteResource method. +// Request message for ResourceService.DeleteResource. message DeleteResourceRequest { - // The resource id of the resource to be deleted, for example: - // "shelves/shelf1/resources/resource2" - int64 id = 1 [json_name = "id"]; + int64 id = 1; } -// DeleteResourceResponse is the response for the ResourceService.DeleteResource method. +// Response message for ResourceService.DeleteResource. message DeleteResourceResponse { - // or Resource resource = 1; or google.protobuf.Empty empty = 1; google.protobuf.Empty empty = 1; } diff --git a/api/v1/proto/system/view.proto b/api/v1/proto/system/view.proto new file mode 100644 index 00000000..32cc2692 --- /dev/null +++ b/api/v1/proto/system/view.proto @@ -0,0 +1,109 @@ +syntax = "proto3"; + +package api.v1.services.system; + +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/empty.proto"; +import "types/system.proto"; + +option go_package = "origadmin/application/admin/api/v1/services/system;system"; +option java_multiple_files = true; +option java_outer_classname = "APIServiceSystemViewProto"; +option java_package = "com.origadmin.api.v1.services.system"; +option objc_class_prefix = "APIServiceSystemView"; + +// The view service definition. +// A View represents a UI element that can be controlled by permissions, such as a menu, button, or page. +service ViewService { + // Lists all view elements. + rpc ListViews(ListViewsRequest) returns (ListViewsResponse) { + option (google.api.http) = {get: "/sys/views"}; + } + // Gets a single view element. + rpc GetView(GetViewRequest) returns (GetViewResponse) { + option (google.api.http) = {get: "/sys/views/{id}"}; + } + // Creates a new view element. + rpc CreateView(CreateViewRequest) returns (CreateViewResponse) { + option (google.api.http) = { + post: "/sys/views" + body: "*" + }; + } + // Updates a view element. + rpc UpdateView(UpdateViewRequest) returns (UpdateViewResponse) { + option (google.api.http) = { + put: "/sys/views/{view.id}" + body: "view" + }; + } + // Deletes a view element. + rpc DeleteView(DeleteViewRequest) returns (DeleteViewResponse) { + option (google.api.http) = {delete: "/sys/views/{id}"}; + } +} + +// Request message for ViewService.ListViews. +message ListViewsRequest { + int64 id = 1 [json_name = "id"]; + int32 page = 2 [json_name = "page"]; + int32 page_size = 3 [json_name = "page_size"]; + string page_token = 4 [json_name = "page_token"]; + bool no_paging = 5 [json_name = "no_paging"]; + bool only_count = 6 [json_name = "only_count"]; + string keyword = 7 [json_name = "keyword"]; + string scope = 8 [json_name = "scope"]; +} + +// Response message for ViewService.ListViews. +message ListViewsResponse { + int32 total = 1 [json_name = "total"]; + repeated api.v1.services.types.View views = 2 [json_name = "views"]; + int32 page = 3 [json_name = "page"]; + int32 page_size = 4 [json_name = "page_size"]; + string next_page_token = 5 [json_name = "next_page_token"]; + optional google.protobuf.Any extra = 6 [json_name = "extra"]; +} + +// Request message for ViewService.GetView. +message GetViewRequest { + int64 id = 1; +} + +// Response message for ViewService.GetView. +message GetViewResponse { + api.v1.services.types.View view = 1; +} + +// Request message for ViewService.CreateView. +message CreateViewRequest { + string parent = 1; + string view_id = 2; + api.v1.services.types.View view = 3; +} + +// Response message for ViewService.CreateView. +message CreateViewResponse { + api.v1.services.types.View view = 1; +} + +// Request message for ViewService.UpdateView. +message UpdateViewRequest { + api.v1.services.types.View view = 1; +} + +// Response message for ViewService.UpdateView. +message UpdateViewResponse { + api.v1.services.types.View view = 1; +} + +// Request message for ViewService.DeleteView. +message DeleteViewRequest { + int64 id = 1; +} + +// Response message for ViewService.DeleteView. +message DeleteViewResponse { + google.protobuf.Empty empty = 1; +} diff --git a/internal/data/entity/ent/generate.go b/internal/data/entity/ent/generate.go index 30225e2e..a46b7e6d 100644 --- a/internal/data/entity/ent/generate.go +++ b/internal/data/entity/ent/generate.go @@ -5,4 +5,4 @@ // Package ent is the data access object for SYS. package ent -//go:generate ent generate --template ./template --feature intercept --feature schema/snapshot --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema +//go:generate go run entgo.io/ent/cmd/ent generate --template ./template --feature intercept --feature schema/snapshot --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema diff --git a/internal/data/entity/ent/schema/department.go b/internal/data/entity/ent/schema/department.go index a50a6c3b..5b389d16 100644 --- a/internal/data/entity/ent/schema/department.go +++ b/internal/data/entity/ent/schema/department.go @@ -51,7 +51,7 @@ func (Department) Fields() []ent.Field { MaxLen(1024). Default(""). Comment(i18n.Text("entity.department.field.description")), - mixin.OP("parent_id", "department.field.parent_id"), + mixin.OptionalFK("parent_id", "department.field.parent_id"), } } diff --git a/internal/data/entity/ent/schema/resource.go b/internal/data/entity/ent/schema/resource.go index fa02298a..7390d31a 100644 --- a/internal/data/entity/ent/schema/resource.go +++ b/internal/data/entity/ent/schema/resource.go @@ -1,39 +1,14 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package schema implements the functions, types, and interfaces for the module. package schema import ( "entgo.io/ent" - "entgo.io/ent/dialect/entsql" - "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" - "origadmin/application/admin/internal/helpers/ent/mixin" "origadmin/application/admin/internal/helpers/i18n" ) -const ( - ResourceStatusEnabled int8 = 1 // 启用 - ResourceStatusDisabled int8 = 2 // 禁用 -) -const ( - ResourceTypeUnknown = "U" // 未知 - ResourceTypeRoot = "ROOT" // 根目录 - ResourceTypeGroup = "G" // 分组 - ResourceTypeMenu = "M" // 目录 - ResourceTypePage = "P" // 页面 - ResourceTypeButton = "B" // 按钮 - ResourceTypeAPI = "A" // API接口 - ResourceTypeRedirect = "R" // 重定向 - -) - -// Resource holds the schema definition for the Resource domain. +// Resource holds the schema definition for the Resource entity. type Resource struct { ent.Schema } @@ -41,108 +16,50 @@ type Resource struct { // Fields of the Resource. func (Resource) Fields() []ent.Field { return []ent.Field{ - field.String("name"). - MaxLen(128). - Default(""). - Comment(i18n.Text("entity.resource.field.name")), + field.String("service_name"). + Comment(i18n.Text("resource.service_name.comment")), field.String("keyword"). - MaxLen(64). + Comment(i18n.Text("resource.keyword.comment")). Unique(). - Comment(i18n.Text("entity.resource.field.keyword")), - field.String("i18n_key"). - MaxLen(128). - Default(""). - Comment(i18n.Text("entity.resource.field.i18n_key")), - field.String("type"). - MaxLen(2). - Default(ResourceTypeMenu). - Comment(i18n.Text("entity.resource.field.type")), - field.Int8("status"). - Default(ResourceStatusEnabled). - Comment(i18n.Text("entity.resource.field.status")), - // fields that are unique to api resources + NotEmpty(), field.String("path"). - MaxLen(256). - Default(""). - Comment(i18n.Text("entity.resource.field.path")), - // fields that are unique to grpc resources - field.String("operation"). - MaxLen(128). - Default(""). - Comment(i18n.Text("entity.resource.field.operation")), + Comment(i18n.Text("resource.path.comment")). + Optional(), field.String("method"). - MaxLen(16). - Default(""). - Comment(i18n.Text("entity.resource.field.method")), - // fields specific to ui resources - field.String("component"). - MaxLen(128). - Default(""). - Comment(i18n.Text("entity.resource.field.component")), - // fields specific to ui resources - field.String("icon"). - MaxLen(64). - Default(""). - Comment(i18n.Text("entity.resource.field.icon")), - // menu sort field - field.Int("sequence"). - Default(0). - Comment(i18n.Text("entity.resource.field.sequence")), - // menu specific fields - field.Bool("visible"). - Default(true). - Comment(i18n.Text("entity.resource.field.visible")), - field.Int8("level"). - Default(0). - Comment(i18n.Text("entity.resource.field.level")), - field.String("tree_path"). - MaxLen(256). - Default(""). - Comment(i18n.Text("entity.resource.field.tree_path")), - // extended properties - field.JSON("properties", map[string]string{}). - Optional(). - Comment(i18n.Text("entity.resource.field.properties")), - field.String("description"). - MaxLen(1024). - Default(""). - Comment(i18n.Text("entity.resource.field.description")), - mixin.OP("parent_id", "resource.field.parent_id"), - } -} - -// Mixin of the Resource. -func (Resource) Mixin() []ent.Mixin { - return mixin.ModelMixin -} - -// Indexes of the Resource. -func (Resource) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("parent_id"), - index.Fields("level"), - } -} - -// Annotations of the Menu. -func (Resource) Annotations() []schema.Annotation { - return []schema.Annotation{ - entsql.Table("sys_resources"), - entsql.WithComments(true), - schema.Comment(i18n.Text("entity.resource.table.comment")), + Comment(i18n.Text("resource.method.comment")). + Optional(), + field.String("operation"). + Comment(i18n.Text("resource.operation.comment")). + Optional(), + field.String("policy"). + Comment(i18n.Text("resource.policy.comment")). + Default(""), + field.String("version_id"). + Comment(i18n.Text("resource.version_id.comment")). + Default(""), + field.String("last_sync_version_id"). + Comment(i18n.Text("resource.last_sync_version_id.comment")). + Default(""), + field.String("sync_status"). + Comment(i18n.Text("resource.sync_status.comment")). + Default("Synced"), + field.Enum("status"). + Comment(i18n.Text("resource.status.comment")). + Values("enabled", "disabled"). + Default("enabled"), } } // Edges of the Resource. func (Resource) Edges() []ent.Edge { return []ent.Edge{ - edge.To("children", Resource.Type), - edge.From("parent", Resource.Type). - Ref("children"). - Field("parent_id"). - Unique(), + edge.To("views", View.Type), edge.From("permissions", Permission.Type). - Ref("resources"). - Through("permission_resources", PermissionResource.Type), + Ref("resources"), } } + +// Mixin of the Resource. +func (Resource) Mixin() []ent.Mixin { + return mixin.ModelMixin +} diff --git a/internal/data/entity/ent/schema/softdelete.go b/internal/data/entity/ent/schema/softdelete.go index 602008bf..60e286a6 100644 --- a/internal/data/entity/ent/schema/softdelete.go +++ b/internal/data/entity/ent/schema/softdelete.go @@ -20,7 +20,7 @@ import ( // SoftDelete is schema to include control and time fields. type SoftDelete struct { - mixin.DeleteSchema + mixin.DeleteMixin } //Interceptors of the SoftDeleteMixin. @@ -65,6 +65,6 @@ func (s SoftDelete) Hooks() []ent.Hook { // P adds a storage-level predicate to the queries and mutations. func (s SoftDelete) P(w interface{ WhereP(...func(*sql.Selector)) }) { w.WhereP( - sql.FieldIsNull(s.DeleteSchema.Fields()[0].Descriptor().Name), + sql.FieldIsNull(s.DeleteMixin.Fields()[0].Descriptor().Name), ) } diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 76b660f0..904b63df 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -104,8 +104,8 @@ func (User) Fields() []ent.Field { Comment(i18n.Text("entity.user.field.last_login_ip")), mixin.Time("last_login_time", i18n.Text("entity.user.field.last_login_time")), mixin.Time("login_time", i18n.Text("entity.user.field.login_time")), - mixin.TimeOP("sanction_date", i18n.Text("entity.user.field.sanction_date")), - mixin.OP("manager_id", i18n.Text("entity.user.field.manager_id")), // 管理员ID + mixin.TimeOptional("sanction_date", i18n.Text("entity.user.field.sanction_date")), + mixin.OptionalFK("manager_id", i18n.Text("entity.user.field.manager_id")), // 管理员ID field.String("manager"). Default(""). Comment(i18n.Text("entity.user.field.manager")), // 管理员 diff --git a/internal/data/entity/ent/schema/view.go b/internal/data/entity/ent/schema/view.go new file mode 100644 index 00000000..f2153bb0 --- /dev/null +++ b/internal/data/entity/ent/schema/view.go @@ -0,0 +1,69 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/field" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" +) + +// View holds the schema definition for the View entity. +type View struct { + ent.Schema +} + +// Fields of the View. +func (View) Fields() []ent.Field { + return []ent.Field{ + // Use OptionalFK for an optional foreign key, as designed in the mixin package. + mixin.OptionalFK("parent_id", i18n.Text("view.parent_id.comment")), + field.String("keyword"). + Comment(i18n.Text("view.keyword.comment")). + Unique(). + NotEmpty(), + field.String("scope"). + Comment(i18n.Text("view.scope.comment")). + Default("default"), + field.String("name"). + Comment(i18n.Text("view.name.comment")), + field.String("type"). + Comment(i18n.Text("view.type.comment")). + MaxLen(1). + Default("U"), + field.String("component"). + Comment(i18n.Text("view.component.comment")). + Optional(), + field.String("path"). + Comment(i18n.Text("view.path.comment")). + Optional(), + field.String("icon"). + Comment(i18n.Text("view.icon.comment")). + Optional(), + field.Bool("visible"). + Comment(i18n.Text("view.visible.comment")). + Default(true), + field.Int("sequence"). + Comment(i18n.Text("view.sequence.comment")). + Default(0), + } +} + +// Edges of the View. +func (View) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("children", View.Type). + From("parent"). + Field("parent_id"). + Unique(), + edge.From("resources", Resource.Type). + Ref("views"), + edge.From("permissions", Permission.Type). + Ref("views"), + } +} + +// Mixin of the View. +func (View) Mixin() []ent.Mixin { + return mixin.ModelMixin +} diff --git a/internal/helpers/ent/mixin/field.go b/internal/helpers/ent/mixin/field.go index d48cd186..210049ef 100644 --- a/internal/helpers/ent/mixin/field.go +++ b/internal/helpers/ent/mixin/field.go @@ -17,39 +17,39 @@ import ( // ZeroTime represents the zero value for time.Time. var ZeroTime = time.Time{} -var _id = ID{} +var innerID = ID{} func Comment(key string) IDGenerator { - return _id.Comment(key) + return innerID.Comment(key) } func I18nComment(key string) IDGenerator { - return _id.Comment(i18n.Text(key)) + return innerID.Comment(i18n.Text(key)) } func PK(name string, comment ...string) ent.Field { if len(comment) == 0 { - return _id.PK(name) + return innerID.PK(name) } - return _id.Comment(comment[0]).PK(name) + return innerID.Comment(comment[0]).PK(name) } func FK(name string, comment ...string) ent.Field { if len(comment) == 0 { - return _id.FK(name) + return innerID.FK(name) } - return _id.Comment(comment[0]).FK(name) + return innerID.Comment(comment[0]).FK(name) } -func OP(name string, comment ...string) ent.Field { +func OptionalFK(name string, comment ...string) ent.Field { if len(comment) == 0 { - return _id.OP(name) + return innerID.OptionalFK(name) } - return _id.Comment(comment[0]).OP(name) + return innerID.Comment(comment[0]).OptionalFK(name) } -// TimeOP returns a time field with a default value of ZeroTime and a custom schema type for MySQL. -func TimeOP(name string, comment ...string) ent.Field { +// TimeOptional returns a time field with a default value of ZeroTime and a custom schema type for MySQL. +func TimeOptional(name string, comment ...string) ent.Field { if len(comment) == 0 { return field.Time(name). Optional(). @@ -97,10 +97,10 @@ func FieldFK(name string) ent.Field { return ID{}.FK(name) } -// FieldOP returns an optional string field with a maximum length of 36 characters. -func FieldOP(name string) ent.Field { +// FieldOptional returns an optional string field with a maximum length of 36 characters. +func FieldOptional(name string) ent.Field { // Create an optional string field with the given name and maximum length. - return ID{}.OP(name) + return ID{}.OptionalFK(name) } func FieldUUIDPK(name string, comment ...string) ent.Field { @@ -119,12 +119,12 @@ func FieldUUIDFK(name string, comment ...string) ent.Field { return UUID{}.Comment(comment[0]).FK(name) } -func FieldUUIDOP(name string, comment ...string) ent.Field { +func FieldUUIDOptional(name string, comment ...string) ent.Field { if len(comment) == 0 { - return UUID{}.OP(name) + return UUID{}.OptionalFK(name) } // Create an optional string field with the given name and maximum length. - return UUID{}.Comment(comment[0]).OP(name) + return UUID{}.Comment(comment[0]).OptionalFK(name) } // FieldTime returns a time field with a default value of ZeroTime and a custom schema type for MySQL. diff --git a/internal/helpers/ent/mixin/mixin.go b/internal/helpers/ent/mixin/mixin.go index cc46849a..cc681e68 100644 --- a/internal/helpers/ent/mixin/mixin.go +++ b/internal/helpers/ent/mixin/mixin.go @@ -19,25 +19,42 @@ import ( type IDGenerator interface { Comment(key string) IDGenerator - OP(name string) ent.Field + OptionalFK(name string) ent.Field FK(name string) ent.Field PK(name string) ent.Field } // Audit schema to include control and time fields. -type Audit struct { +type auditMixin struct { mixin.Schema + CreateField string + UpdateField string +} + +func DefaultAudit() ent.Mixin { + return auditMixin{ + CreateField: "create_author", + UpdateField: "update_author", + } +} + +// Audit returns a new audit mixin with configurable field names. +func Audit(createField, updateField string) ent.Mixin { + return auditMixin{ + CreateField: createField, + UpdateField: updateField, + } } // Fields of the mixin. -func (Audit) Fields() []ent.Field { - auditCreate := _id - auditCreate.Key = "create_author" +func (m auditMixin) Fields() []ent.Field { + auditCreate := innerID + auditCreate.Key = m.CreateField auditCreate.CommentKey = i18n.Text("create_author.field.comment") auditCreate.UseDefault = true auditCreate.Optional = true - auditUpdate := _id - auditUpdate.Key = "update_author" + auditUpdate := innerID + auditUpdate.Key = m.UpdateField auditUpdate.CommentKey = i18n.Text("update_author.field.comment") auditUpdate.UseDefault = true auditUpdate.Optional = true @@ -48,10 +65,10 @@ func (Audit) Fields() []ent.Field { } // Indexes of the mixin. -func (Audit) Indexes() []ent.Index { +func (m auditMixin) Indexes() []ent.Index { return []ent.Index{ - index.Fields("create_author"), - index.Fields("update_author"), + index.Fields(m.CreateField), + index.Fields(m.UpdateField), } } @@ -62,7 +79,7 @@ type ManagerSchema struct { // Fields of the Model. func (ManagerSchema) Fields() []ent.Field { - manager := _id + manager := innerID manager.Key = "manager_id" manager.CommentKey = i18n.Text("manager_id.field.comment") manager.Optional = true @@ -82,36 +99,65 @@ func (ManagerSchema) Indexes() []ent.Index { } } -// CreateUpdateSchema schema to include control and time fields. -type CreateUpdateSchema struct { +// createUpdateMixin schema to include control and time fields. +type createUpdateMixin struct { mixin.Schema + UpdateField string + CreateField string +} + +func DefaultCreateUpdateMixin() ent.Mixin { + return createUpdateMixin{ + UpdateField: "update_time", + CreateField: "create_time", + } +} + +func CreateUpdateMixin(updateField, createField string) ent.Mixin { + return createUpdateMixin{ + UpdateField: updateField, + CreateField: createField, + } } // Fields of the mixin. -func (CreateUpdateSchema) Fields() []ent.Field { +func (m createUpdateMixin) Fields() []ent.Field { return append( - CreateSchema{}.Fields(), - UpdateSchema{}.Fields()..., + CreateMixin(m.CreateField).Fields(), + UpdateMixin(m.UpdateField).Fields()..., ) } // Indexes of the mixin. -func (CreateUpdateSchema) Indexes() []ent.Index { +func (m createUpdateMixin) Indexes() []ent.Index { return append( - CreateSchema{}.Indexes(), - UpdateSchema{}.Indexes()..., + CreateMixin(m.CreateField).Indexes(), + UpdateMixin(m.UpdateField).Indexes()..., ) } -// CreateSchema schema to include control and time fields. -type CreateSchema struct { +// createMixin schema to include control and time fields. +type createMixin struct { mixin.Schema + CreateField string +} + +func DefaultCreateMixin() ent.Mixin { + return createMixin{ + CreateField: "create_time", + } +} + +func CreateMixin(fieldName string) ent.Mixin { + return createMixin{ + CreateField: fieldName, + } } // Fields of the mixin. -func (CreateSchema) Fields() []ent.Field { +func (m createMixin) Fields() []ent.Field { return []ent.Field{ - field.Time("create_time"). + field.Time(m.CreateField). Comment(i18n.Text("create_time.field.comment")). Default(time.Now). Immutable(), @@ -119,21 +165,33 @@ func (CreateSchema) Fields() []ent.Field { } // Indexes of the mixin. -func (CreateSchema) Indexes() []ent.Index { +func (m createMixin) Indexes() []ent.Index { return []ent.Index{ - index.Fields("create_time"), + index.Fields(m.CreateField), } } -// UpdateSchema schema to include control and time fields. -type UpdateSchema struct { +// updateMixin schema to include control and time fields. +type updateMixin struct { mixin.Schema + UpdateField string +} + +func DefaultUpdateMixin() ent.Mixin { + return updateMixin{ + UpdateField: "update_time", + } +} +func UpdateMixin(fieldName string) ent.Mixin { + return updateMixin{ + UpdateField: fieldName, + } } // Fields of the mixin. -func (UpdateSchema) Fields() []ent.Field { +func (m updateMixin) Fields() []ent.Field { return []ent.Field{ - field.Time("update_time"). + field.Time(m.UpdateField). Comment(i18n.Text("update_time.field.comment")). Default(time.Now). UpdateDefault(time.Now), @@ -141,21 +199,22 @@ func (UpdateSchema) Fields() []ent.Field { } // Indexes of the mixin. -func (UpdateSchema) Indexes() []ent.Index { +func (m updateMixin) Indexes() []ent.Index { return []ent.Index{ - index.Fields("update_time"), + index.Fields(m.UpdateField), } } -// DeleteSchema schema to include control and time fields. -type DeleteSchema struct { +// DeleteMixin schema to include control and time fields. +type DeleteMixin struct { mixin.Schema + DeleteField string } // Fields of the Model. -func (DeleteSchema) Fields() []ent.Field { +func (m DeleteMixin) Fields() []ent.Field { return []ent.Field{ - field.Time("delete_time"). + field.Time(m.DeleteField). Comment(i18n.Text("delete_time.field.comment")). Optional(). Nillable(), @@ -163,23 +222,23 @@ func (DeleteSchema) Fields() []ent.Field { } // Indexes of the mixin. -func (DeleteSchema) Indexes() []ent.Index { +func (m DeleteMixin) Indexes() []ent.Index { return []ent.Index{ - index.Fields("delete_time"), + index.Fields(m.DeleteField), } } var ( ModelMixin = []ent.Mixin{ - _id, - CreateSchema{}, - UpdateSchema{}, + innerID, + DefaultCreateMixin(), + DefaultUpdateMixin(), } AuditModelMixin = []ent.Mixin{ - _id, - Audit{}, - CreateSchema{}, - UpdateSchema{}, + innerID, + DefaultAudit(), + DefaultCreateMixin(), + DefaultUpdateMixin(), } ) diff --git a/internal/helpers/ent/mixin/mixin_generic_id.go b/internal/helpers/ent/mixin/mixin_generic_id.go new file mode 100644 index 00000000..0923067f --- /dev/null +++ b/internal/helpers/ent/mixin/mixin_generic_id.go @@ -0,0 +1,45 @@ +package mixin + +import ( + "entgo.io/ent" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/mixin" + "golang.org/x/exp/constraints" // for Integer +) + +type IDType interface { + constraints.Integer | string +} + +type GenericID[T IDType] struct { + mixin.Schema + Key string + CommentKey string + Optional bool + Positive bool + Unique bool + Immutable bool + UseDefault bool + DefaultFunc func() int64 + UseCustomIDGenerator bool +} + +func (g GenericID[T]) Fields() []ent.Field { + var pkField ent.Field + var t T + + switch any(t).(type) { + case int64, int, int32: + pkField = field.Int64("id") + case string: + pkField = field.String("id") + } + return []ent.Field{pkField} +} + +// ... 实现其他泛型方法 FK, OptionalFK 等 + +// 在 field.go 中可以这样使用 +// var innerID = GenericID[int64]{} // 使用int64 +// or +// var innerID = GenericID[string]{} // 使用string diff --git a/internal/helpers/ent/mixin/mixin_id.go b/internal/helpers/ent/mixin/mixin_id.go index 0cc9e162..a3a60f98 100644 --- a/internal/helpers/ent/mixin/mixin_id.go +++ b/internal/helpers/ent/mixin/mixin_id.go @@ -88,7 +88,7 @@ func (obj ID) PK(name string) ent.Field { return obj.ToField() } -func (obj ID) OP(name string) ent.Field { +func (obj ID) OptionalFK(name string) ent.Field { obj.Key = name obj.Positive = true obj.Optional = true diff --git a/internal/helpers/ent/mixin/mixin_uuid.go b/internal/helpers/ent/mixin/mixin_uuid.go index 32927d22..1a70ef08 100644 --- a/internal/helpers/ent/mixin/mixin_uuid.go +++ b/internal/helpers/ent/mixin/mixin_uuid.go @@ -86,7 +86,7 @@ func (obj UUID) PK(name string) ent.Field { return obj.ToField() } -func (obj UUID) OP(name string) ent.Field { +func (obj UUID) OptionalFK(name string) ent.Field { obj.Key = name obj.Optional = true if obj.CommentKey == "" { diff --git a/tools.go b/tools.go index 3c04584c..92db8ef2 100644 --- a/tools.go +++ b/tools.go @@ -3,6 +3,7 @@ package tools import ( + _ "entgo.io/ent/cmd/ent" _ "github.com/bufbuild/buf/cmd/buf" _ "github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking" _ "github.com/bufbuild/buf/cmd/protoc-gen-buf-lint" @@ -13,4 +14,4 @@ import ( _ "github.com/google/wire/cmd/wire" _ "google.golang.org/grpc/cmd/protoc-gen-go-grpc" _ "google.golang.org/protobuf/cmd/protoc-gen-go" -) \ No newline at end of file +) From 303eb6b90bedfe3b18e04831e1e1a3dfb1bf9825 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 05:11:06 +0800 Subject: [PATCH 079/158] feat(ent): add View entity support with hook and intercept functions --- internal/data/entity/ent/client.go | 271 +- internal/data/entity/ent/database.go | 5 + internal/data/entity/ent/ent.go | 2 + internal/data/entity/ent/hook/hook.go | 12 + .../data/entity/ent/intercept/intercept.go | 30 + internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 184 +- internal/data/entity/ent/mutation.go | 9825 +++++++++-------- internal/data/entity/ent/mutation_fields.go | 237 +- internal/data/entity/ent/permission.go | 24 +- .../data/entity/ent/permission/permission.go | 33 +- internal/data/entity/ent/permission/where.go | 23 + internal/data/entity/ent/permission_create.go | 32 + internal/data/entity/ent/permission_query.go | 107 +- internal/data/entity/ent/permission_update.go | 163 + .../permissionresource/permissionresource.go | 2 +- .../data/entity/ent/predicate/predicate.go | 3 + internal/data/entity/ent/resource.go | 254 +- internal/data/entity/ent/resource/resource.go | 306 +- internal/data/entity/ent/resource/where.go | 922 +- internal/data/entity/ent/resource_create.go | 481 +- internal/data/entity/ent/resource_query.go | 314 +- internal/data/entity/ent/resource_update.go | 1020 +- internal/data/entity/ent/runtime/runtime.go | 148 +- internal/data/entity/ent/schema/permission.go | 2 + internal/data/entity/ent/tx.go | 3 + internal/helpers/ent/mixin/mixin.go | 5 +- 27 files changed, 7208 insertions(+), 7202 deletions(-) diff --git a/internal/data/entity/ent/client.go b/internal/data/entity/ent/client.go index 2883d92d..74ff704b 100644 --- a/internal/data/entity/ent/client.go +++ b/internal/data/entity/ent/client.go @@ -25,6 +25,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userdepartment" "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/view" "entgo.io/ent" "entgo.io/ent/dialect" @@ -65,6 +66,8 @@ type Client struct { UserPosition *UserPositionClient // UserRole is the client for interacting with the UserRole builders. UserRole *UserRoleClient + // View is the client for interacting with the View builders. + View *ViewClient } // NewClient creates a new client configured with the given options. @@ -90,6 +93,7 @@ func (c *Client) init() { c.UserDepartment = NewUserDepartmentClient(c.config) c.UserPosition = NewUserPositionClient(c.config) c.UserRole = NewUserRoleClient(c.config) + c.View = NewViewClient(c.config) } type ( @@ -196,6 +200,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { UserDepartment: NewUserDepartmentClient(cfg), UserPosition: NewUserPositionClient(cfg), UserRole: NewUserRoleClient(cfg), + View: NewViewClient(cfg), }, nil } @@ -229,6 +234,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) UserDepartment: NewUserDepartmentClient(cfg), UserPosition: NewUserPositionClient(cfg), UserRole: NewUserRoleClient(cfg), + View: NewViewClient(cfg), }, nil } @@ -260,7 +266,7 @@ func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.CasbinRule, c.Department, c.Notification, c.Permission, c.PermissionResource, c.Position, c.PositionPermission, c.Resource, c.Role, c.RolePermission, c.User, - c.UserDepartment, c.UserPosition, c.UserRole, + c.UserDepartment, c.UserPosition, c.UserRole, c.View, } { n.Use(hooks...) } @@ -272,7 +278,7 @@ func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.CasbinRule, c.Department, c.Notification, c.Permission, c.PermissionResource, c.Position, c.PositionPermission, c.Resource, c.Role, c.RolePermission, c.User, - c.UserDepartment, c.UserPosition, c.UserRole, + c.UserDepartment, c.UserPosition, c.UserRole, c.View, } { n.Intercept(interceptors...) } @@ -309,6 +315,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.UserPosition.mutate(ctx, m) case *UserRoleMutation: return c.UserRole.mutate(ctx, m) + case *ViewMutation: + return c.View.mutate(ctx, m) default: return nil, fmt.Errorf("ent: unknown mutation type %T", m) } @@ -949,6 +957,22 @@ func (c *PermissionClient) QueryResources(_m *Permission) *ResourceQuery { return query } +// QueryViews queries the views edge of a Permission. +func (c *PermissionClient) QueryViews(_m *Permission) *ViewQuery { + query := (&ViewClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, id), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, permission.ViewsTable, permission.ViewsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryRolePermissions queries the role_permissions edge of a Permission. func (c *PermissionClient) QueryRolePermissions(_m *Permission) *RolePermissionQuery { query := (&RolePermissionClient{config: c.config}).Query() @@ -1673,31 +1697,15 @@ func (c *ResourceClient) GetX(ctx context.Context, id int64) *Resource { return obj } -// QueryChildren queries the children edge of a Resource. -func (c *ResourceClient) QueryChildren(_m *Resource) *ResourceQuery { - query := (&ResourceClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, id), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, resource.ChildrenTable, resource.ChildrenColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - -// QueryParent queries the parent edge of a Resource. -func (c *ResourceClient) QueryParent(_m *Resource) *ResourceQuery { - query := (&ResourceClient{config: c.config}).Query() +// QueryViews queries the views edge of a Resource. +func (c *ResourceClient) QueryViews(_m *Resource) *ViewQuery { + query := (&ViewClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(resource.Table, resource.FieldID, id), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, resource.ParentTable, resource.ParentColumn), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, resource.ViewsTable, resource.ViewsPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -1721,22 +1729,6 @@ func (c *ResourceClient) QueryPermissions(_m *Resource) *PermissionQuery { return query } -// QueryPermissionResources queries the permission_resources edge of a Resource. -func (c *ResourceClient) QueryPermissionResources(_m *Resource) *PermissionResourceQuery { - query := (&PermissionResourceClient{config: c.config}).Query() - query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := _m.ID - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, id), - sqlgraph.To(permissionresource.Table, permissionresource.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, resource.PermissionResourcesTable, resource.PermissionResourcesColumn), - ) - fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) - return fromV, nil - } - return query -} - // Hooks returns the client hooks. func (c *ResourceClient) Hooks() []Hook { return c.hooks.Resource @@ -2850,16 +2842,213 @@ func (c *UserRoleClient) mutate(ctx context.Context, m *UserRoleMutation) (Value } } +// ViewClient is a client for the View schema. +type ViewClient struct { + config +} + +// NewViewClient returns a client for the View from the given config. +func NewViewClient(c config) *ViewClient { + return &ViewClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `view.Hooks(f(g(h())))`. +func (c *ViewClient) Use(hooks ...Hook) { + c.hooks.View = append(c.hooks.View, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `view.Intercept(f(g(h())))`. +func (c *ViewClient) Intercept(interceptors ...Interceptor) { + c.inters.View = append(c.inters.View, interceptors...) +} + +// Create returns a builder for creating a View entity. +func (c *ViewClient) Create() *ViewCreate { + mutation := newViewMutation(c.config, OpCreate) + return &ViewCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of View entities. +func (c *ViewClient) CreateBulk(builders ...*ViewCreate) *ViewCreateBulk { + return &ViewCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ViewClient) MapCreateBulk(slice any, setFunc func(*ViewCreate, int)) *ViewCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ViewCreateBulk{err: fmt.Errorf("calling to ViewClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ViewCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ViewCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for View. +func (c *ViewClient) Update() *ViewUpdate { + mutation := newViewMutation(c.config, OpUpdate) + return &ViewUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ViewClient) UpdateOne(_m *View) *ViewUpdateOne { + mutation := newViewMutation(c.config, OpUpdateOne, withView(_m)) + return &ViewUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ViewClient) UpdateOneID(id int64) *ViewUpdateOne { + mutation := newViewMutation(c.config, OpUpdateOne, withViewID(id)) + return &ViewUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for View. +func (c *ViewClient) Delete() *ViewDelete { + mutation := newViewMutation(c.config, OpDelete) + return &ViewDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ViewClient) DeleteOne(_m *View) *ViewDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ViewClient) DeleteOneID(id int64) *ViewDeleteOne { + builder := c.Delete().Where(view.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ViewDeleteOne{builder} +} + +// Query returns a query builder for View. +func (c *ViewClient) Query() *ViewQuery { + return &ViewQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeView}, + inters: c.Interceptors(), + } +} + +// Get returns a View entity by its id. +func (c *ViewClient) Get(ctx context.Context, id int64) (*View, error) { + return c.Query().Where(view.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ViewClient) GetX(ctx context.Context, id int64) *View { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryParent queries the parent edge of a View. +func (c *ViewClient) QueryParent(_m *View) *ViewQuery { + query := (&ViewClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, id), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, view.ParentTable, view.ParentColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryChildren queries the children edge of a View. +func (c *ViewClient) QueryChildren(_m *View) *ViewQuery { + query := (&ViewClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, id), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, view.ChildrenTable, view.ChildrenColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryResources queries the resources edge of a View. +func (c *ViewClient) QueryResources(_m *View) *ResourceQuery { + query := (&ResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, id), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, view.ResourcesTable, view.ResourcesPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryPermissions queries the permissions edge of a View. +func (c *ViewClient) QueryPermissions(_m *View) *PermissionQuery { + query := (&PermissionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, id), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, view.PermissionsTable, view.PermissionsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ViewClient) Hooks() []Hook { + return c.hooks.View +} + +// Interceptors returns the client interceptors. +func (c *ViewClient) Interceptors() []Interceptor { + return c.inters.View +} + +func (c *ViewClient) mutate(ctx context.Context, m *ViewMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ViewCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ViewUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ViewUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ViewDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown View mutation op: %q", m.Op()) + } +} + // hooks and interceptors per client, for fast access. type ( hooks struct { CasbinRule, Department, Notification, Permission, PermissionResource, Position, PositionPermission, Resource, Role, RolePermission, User, UserDepartment, - UserPosition, UserRole []ent.Hook + UserPosition, UserRole, View []ent.Hook } inters struct { CasbinRule, Department, Notification, Permission, PermissionResource, Position, PositionPermission, Resource, Role, RolePermission, User, UserDepartment, - UserPosition, UserRole []ent.Interceptor + UserPosition, UserRole, View []ent.Interceptor } ) diff --git a/internal/data/entity/ent/database.go b/internal/data/entity/ent/database.go index a21918bc..301afd74 100644 --- a/internal/data/entity/ent/database.go +++ b/internal/data/entity/ent/database.go @@ -179,6 +179,11 @@ func (db *Database) UserRole(ctx context.Context) *UserRoleClient { return db.Client(ctx).UserRole } +// View is the client for interacting with the View builders. +func (db *Database) View(ctx context.Context) *ViewClient { + return db.Client(ctx).View +} + func (db *Database) Migration(ctx context.Context, opts ...schema.MigrateOption) error { return db.Client(ctx).Schema.Create(ctx, opts...) } diff --git a/internal/data/entity/ent/ent.go b/internal/data/entity/ent/ent.go index ed679869..8a40552a 100644 --- a/internal/data/entity/ent/ent.go +++ b/internal/data/entity/ent/ent.go @@ -20,6 +20,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userdepartment" "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/view" "reflect" "sync" @@ -100,6 +101,7 @@ func checkColumn(t, c string) error { userdepartment.Table: userdepartment.ValidColumn, userposition.Table: userposition.ValidColumn, userrole.Table: userrole.ValidColumn, + view.Table: view.ValidColumn, }) }) return columnCheck(t, c) diff --git a/internal/data/entity/ent/hook/hook.go b/internal/data/entity/ent/hook/hook.go index 122bef9d..46cf2869 100644 --- a/internal/data/entity/ent/hook/hook.go +++ b/internal/data/entity/ent/hook/hook.go @@ -176,6 +176,18 @@ func (f UserRoleFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, er return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserRoleMutation", m) } +// The ViewFunc type is an adapter to allow the use of ordinary +// function as View mutator. +type ViewFunc func(context.Context, *ent.ViewMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ViewFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ViewMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ViewMutation", m) +} + // Condition is a hook condition function. type Condition func(context.Context, ent.Mutation) bool diff --git a/internal/data/entity/ent/intercept/intercept.go b/internal/data/entity/ent/intercept/intercept.go index fb629178..b17fc3b2 100644 --- a/internal/data/entity/ent/intercept/intercept.go +++ b/internal/data/entity/ent/intercept/intercept.go @@ -22,6 +22,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userdepartment" "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/view" "entgo.io/ent/dialect/sql" ) @@ -460,6 +461,33 @@ func (f TraverseUserRole) Traverse(ctx context.Context, q ent.Query) error { return fmt.Errorf("unexpected query type %T. expect *ent.UserRoleQuery", q) } +// The ViewFunc type is an adapter to allow the use of ordinary function as a Querier. +type ViewFunc func(context.Context, *ent.ViewQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ViewFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ViewQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ViewQuery", q) +} + +// The TraverseView type is an adapter to allow the use of ordinary function as Traverser. +type TraverseView func(context.Context, *ent.ViewQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseView) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseView) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ViewQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ViewQuery", q) +} + // NewQuery returns the generic Query interface for the given typed query. func NewQuery(q ent.Query) (Query, error) { switch q := q.(type) { @@ -491,6 +519,8 @@ func NewQuery(q ent.Query) (Query, error) { return &query[*ent.UserPositionQuery, predicate.UserPosition, userposition.OrderOption]{typ: ent.TypeUserPosition, tq: q}, nil case *ent.UserRoleQuery: return &query[*ent.UserRoleQuery, predicate.UserRole, userrole.OrderOption]{typ: ent.TypeUserRole, tq: q}, nil + case *ent.ViewQuery: + return &query[*ent.ViewQuery, predicate.View, view.OrderOption]{typ: ent.TypeView, tq: q}, nil default: return nil, fmt.Errorf("unknown query type %T", q) } diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index 61db98b6..5764ac3c 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"children\",\"type\":\"Resource\"},{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref_name\":\"children\",\"unique\":true,\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"i18n_key\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n_key\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":2,\"default\":true,\"default_value\":\"M\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":16,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.component\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.icon\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.visible\"},{\"name\":\"level\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.level\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"properties\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"resource.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"parent_id\"]},{\"fields\":[\"level\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"delete_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\"}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\"},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"delete_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"ref_name\":\"views\",\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"views\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1,\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index efbb21fa..3c876454 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -179,9 +179,9 @@ var ( OnDelete: schema.NoAction, }, { - Symbol: "sys_permission_resources_sys_resources_resource", + Symbol: "sys_permission_resources_resources_resource", Columns: []*schema.Column{SysPermissionResourcesColumns[2]}, - RefColumns: []*schema.Column{SysResourcesColumns[0]}, + RefColumns: []*schema.Column{ResourcesColumns[0]}, OnDelete: schema.NoAction, }, }, @@ -274,63 +274,37 @@ var ( }, }, } - // SysResourcesColumns holds the columns for the "sys_resources" table. - SysResourcesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, - {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, - {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "name", Type: field.TypeString, Size: 128, Comment: "entity.resource.field.name", Default: ""}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 64, Comment: "entity.resource.field.keyword"}, - {Name: "i18n_key", Type: field.TypeString, Size: 128, Comment: "entity.resource.field.i18n_key", Default: ""}, - {Name: "type", Type: field.TypeString, Size: 2, Comment: "entity.resource.field.type", Default: "M"}, - {Name: "status", Type: field.TypeInt8, Comment: "entity.resource.field.status", Default: 1}, - {Name: "path", Type: field.TypeString, Size: 256, Comment: "entity.resource.field.path", Default: ""}, - {Name: "operation", Type: field.TypeString, Size: 128, Comment: "entity.resource.field.operation", Default: ""}, - {Name: "method", Type: field.TypeString, Size: 16, Comment: "entity.resource.field.method", Default: ""}, - {Name: "component", Type: field.TypeString, Size: 128, Comment: "entity.resource.field.component", Default: ""}, - {Name: "icon", Type: field.TypeString, Size: 64, Comment: "entity.resource.field.icon", Default: ""}, - {Name: "sequence", Type: field.TypeInt, Comment: "entity.resource.field.sequence", Default: 0}, - {Name: "visible", Type: field.TypeBool, Comment: "entity.resource.field.visible", Default: true}, - {Name: "level", Type: field.TypeInt8, Comment: "entity.resource.field.level", Default: 0}, - {Name: "tree_path", Type: field.TypeString, Size: 256, Comment: "entity.resource.field.tree_path", Default: ""}, - {Name: "properties", Type: field.TypeJSON, Nullable: true, Comment: "entity.resource.field.properties"}, - {Name: "description", Type: field.TypeString, Size: 1024, Comment: "entity.resource.field.description", Default: ""}, - {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "resource.field.parent_id"}, - } - // SysResourcesTable holds the schema information for the "sys_resources" table. - SysResourcesTable = &schema.Table{ - Name: "sys_resources", - Comment: "entity.resource.table.comment", - Columns: SysResourcesColumns, - PrimaryKey: []*schema.Column{SysResourcesColumns[0]}, - ForeignKeys: []*schema.ForeignKey{ - { - Symbol: "sys_resources_sys_resources_children", - Columns: []*schema.Column{SysResourcesColumns[19]}, - RefColumns: []*schema.Column{SysResourcesColumns[0]}, - OnDelete: schema.SetNull, - }, - }, + // ResourcesColumns holds the columns for the "resources" table. + ResourcesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, + {Name: "service_name", Type: field.TypeString}, + {Name: "keyword", Type: field.TypeString, Unique: true}, + {Name: "path", Type: field.TypeString, Nullable: true}, + {Name: "method", Type: field.TypeString, Nullable: true}, + {Name: "operation", Type: field.TypeString, Nullable: true}, + {Name: "policy", Type: field.TypeString, Default: ""}, + {Name: "version_id", Type: field.TypeString, Default: ""}, + {Name: "last_sync_version_id", Type: field.TypeString, Default: ""}, + {Name: "sync_status", Type: field.TypeString, Default: "Synced"}, + {Name: "status", Type: field.TypeEnum, Enums: []string{"enabled", "disabled"}, Default: "enabled"}, + } + // ResourcesTable holds the schema information for the "resources" table. + ResourcesTable = &schema.Table{ + Name: "resources", + Columns: ResourcesColumns, + PrimaryKey: []*schema.Column{ResourcesColumns[0]}, Indexes: []*schema.Index{ { Name: "resource_create_time", Unique: false, - Columns: []*schema.Column{SysResourcesColumns[1]}, + Columns: []*schema.Column{ResourcesColumns[1]}, }, { Name: "resource_update_time", Unique: false, - Columns: []*schema.Column{SysResourcesColumns[2]}, - }, - { - Name: "resource_parent_id", - Unique: false, - Columns: []*schema.Column{SysResourcesColumns[19]}, - }, - { - Name: "resource_level", - Unique: false, - Columns: []*schema.Column{SysResourcesColumns[15]}, + Columns: []*schema.Column{ResourcesColumns[2]}, }, }, } @@ -646,6 +620,98 @@ var ( }, }, } + // ViewsColumns holds the columns for the "views" table. + ViewsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64}, + {Name: "create_time", Type: field.TypeTime}, + {Name: "update_time", Type: field.TypeTime}, + {Name: "keyword", Type: field.TypeString, Unique: true}, + {Name: "scope", Type: field.TypeString, Default: "default"}, + {Name: "name", Type: field.TypeString}, + {Name: "type", Type: field.TypeString, Size: 1, Default: "U"}, + {Name: "component", Type: field.TypeString, Nullable: true}, + {Name: "path", Type: field.TypeString, Nullable: true}, + {Name: "icon", Type: field.TypeString, Nullable: true}, + {Name: "visible", Type: field.TypeBool, Default: true}, + {Name: "sequence", Type: field.TypeInt, Default: 0}, + {Name: "parent_id", Type: field.TypeInt64, Nullable: true}, + } + // ViewsTable holds the schema information for the "views" table. + ViewsTable = &schema.Table{ + Name: "views", + Columns: ViewsColumns, + PrimaryKey: []*schema.Column{ViewsColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "views_views_children", + Columns: []*schema.Column{ViewsColumns[12]}, + RefColumns: []*schema.Column{ViewsColumns[0]}, + OnDelete: schema.SetNull, + }, + }, + Indexes: []*schema.Index{ + { + Name: "view_create_time", + Unique: false, + Columns: []*schema.Column{ViewsColumns[1]}, + }, + { + Name: "view_update_time", + Unique: false, + Columns: []*schema.Column{ViewsColumns[2]}, + }, + }, + } + // PermissionViewsColumns holds the columns for the "permission_views" table. + PermissionViewsColumns = []*schema.Column{ + {Name: "permission_id", Type: field.TypeInt64}, + {Name: "view_id", Type: field.TypeInt64}, + } + // PermissionViewsTable holds the schema information for the "permission_views" table. + PermissionViewsTable = &schema.Table{ + Name: "permission_views", + Columns: PermissionViewsColumns, + PrimaryKey: []*schema.Column{PermissionViewsColumns[0], PermissionViewsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "permission_views_permission_id", + Columns: []*schema.Column{PermissionViewsColumns[0]}, + RefColumns: []*schema.Column{SysPermissionsColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "permission_views_view_id", + Columns: []*schema.Column{PermissionViewsColumns[1]}, + RefColumns: []*schema.Column{ViewsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } + // ResourceViewsColumns holds the columns for the "resource_views" table. + ResourceViewsColumns = []*schema.Column{ + {Name: "resource_id", Type: field.TypeInt64}, + {Name: "view_id", Type: field.TypeInt64}, + } + // ResourceViewsTable holds the schema information for the "resource_views" table. + ResourceViewsTable = &schema.Table{ + Name: "resource_views", + Columns: ResourceViewsColumns, + PrimaryKey: []*schema.Column{ResourceViewsColumns[0], ResourceViewsColumns[1]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "resource_views_resource_id", + Columns: []*schema.Column{ResourceViewsColumns[0]}, + RefColumns: []*schema.Column{ResourcesColumns[0]}, + OnDelete: schema.Cascade, + }, + { + Symbol: "resource_views_view_id", + Columns: []*schema.Column{ResourceViewsColumns[1]}, + RefColumns: []*schema.Column{ViewsColumns[0]}, + OnDelete: schema.Cascade, + }, + }, + } // Tables holds all the tables in the schema. Tables = []*schema.Table{ CasbinRulesTable, @@ -655,13 +721,16 @@ var ( SysPermissionResourcesTable, SysPositionsTable, SysPositionPermissionsTable, - SysResourcesTable, + ResourcesTable, SysRolesTable, SysRolePermissionsTable, SysUsersTable, SysUserDepartmentsTable, SysUserPositionsTable, SysUserRolesTable, + ViewsTable, + PermissionViewsTable, + ResourceViewsTable, } ) @@ -677,7 +746,7 @@ func init() { Table: "sys_permissions", } SysPermissionResourcesTable.ForeignKeys[0].RefTable = SysPermissionsTable - SysPermissionResourcesTable.ForeignKeys[1].RefTable = SysResourcesTable + SysPermissionResourcesTable.ForeignKeys[1].RefTable = ResourcesTable SysPermissionResourcesTable.Annotation = &entsql.Annotation{ Table: "sys_permission_resources", } @@ -690,10 +759,6 @@ func init() { SysPositionPermissionsTable.Annotation = &entsql.Annotation{ Table: "sys_position_permissions", } - SysResourcesTable.ForeignKeys[0].RefTable = SysResourcesTable - SysResourcesTable.Annotation = &entsql.Annotation{ - Table: "sys_resources", - } SysRolesTable.Annotation = &entsql.Annotation{ Table: "sys_roles", } @@ -720,4 +785,9 @@ func init() { SysUserRolesTable.Annotation = &entsql.Annotation{ Table: "sys_user_roles", } + ViewsTable.ForeignKeys[0].RefTable = ViewsTable + PermissionViewsTable.ForeignKeys[0].RefTable = SysPermissionsTable + PermissionViewsTable.ForeignKeys[1].RefTable = ViewsTable + ResourceViewsTable.ForeignKeys[0].RefTable = ResourcesTable + ResourceViewsTable.ForeignKeys[1].RefTable = ViewsTable } diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index d60b40d2..01505b9e 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -21,6 +21,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userdepartment" "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/view" "sync" "time" @@ -51,6 +52,7 @@ const ( TypeUserDepartment = "UserDepartment" TypeUserPosition = "UserPosition" TypeUserRole = "UserRole" + TypeView = "View" ) // CasbinRuleMutation represents an operation that mutates the CasbinRule nodes in the graph. @@ -2945,6 +2947,9 @@ type PermissionMutation struct { resources map[int64]struct{} removedresources map[int64]struct{} clearedresources bool + views map[int64]struct{} + removedviews map[int64]struct{} + clearedviews bool role_permissions map[int]struct{} removedrole_permissions map[int]struct{} clearedrole_permissions bool @@ -3526,6 +3531,60 @@ func (m *PermissionMutation) ResetResources() { m.removedresources = nil } +// AddViewIDs adds the "views" edge to the View entity by ids. +func (m *PermissionMutation) AddViewIDs(ids ...int64) { + if m.views == nil { + m.views = make(map[int64]struct{}) + } + for i := range ids { + m.views[ids[i]] = struct{}{} + } +} + +// ClearViews clears the "views" edge to the View entity. +func (m *PermissionMutation) ClearViews() { + m.clearedviews = true +} + +// ViewsCleared reports if the "views" edge to the View entity was cleared. +func (m *PermissionMutation) ViewsCleared() bool { + return m.clearedviews +} + +// RemoveViewIDs removes the "views" edge to the View entity by IDs. +func (m *PermissionMutation) RemoveViewIDs(ids ...int64) { + if m.removedviews == nil { + m.removedviews = make(map[int64]struct{}) + } + for i := range ids { + delete(m.views, ids[i]) + m.removedviews[ids[i]] = struct{}{} + } +} + +// RemovedViews returns the removed IDs of the "views" edge to the View entity. +func (m *PermissionMutation) RemovedViewsIDs() (ids []int64) { + for id := range m.removedviews { + ids = append(ids, id) + } + return +} + +// ViewsIDs returns the "views" edge IDs in the mutation. +func (m *PermissionMutation) ViewsIDs() (ids []int64) { + for id := range m.views { + ids = append(ids, id) + } + return +} + +// ResetViews resets all changes to the "views" edge. +func (m *PermissionMutation) ResetViews() { + m.views = nil + m.clearedviews = false + m.removedviews = nil +} + // AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by ids. func (m *PermissionMutation) AddRolePermissionIDs(ids ...int) { if m.role_permissions == nil { @@ -3949,7 +4008,7 @@ func (m *PermissionMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *PermissionMutation) AddedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 7) if m.roles != nil { edges = append(edges, permission.EdgeRoles) } @@ -3959,6 +4018,9 @@ func (m *PermissionMutation) AddedEdges() []string { if m.resources != nil { edges = append(edges, permission.EdgeResources) } + if m.views != nil { + edges = append(edges, permission.EdgeViews) + } if m.role_permissions != nil { edges = append(edges, permission.EdgeRolePermissions) } @@ -3993,6 +4055,12 @@ func (m *PermissionMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case permission.EdgeViews: + ids := make([]ent.Value, 0, len(m.views)) + for id := range m.views { + ids = append(ids, id) + } + return ids case permission.EdgeRolePermissions: ids := make([]ent.Value, 0, len(m.role_permissions)) for id := range m.role_permissions { @@ -4017,7 +4085,7 @@ func (m *PermissionMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *PermissionMutation) RemovedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 7) if m.removedroles != nil { edges = append(edges, permission.EdgeRoles) } @@ -4027,6 +4095,9 @@ func (m *PermissionMutation) RemovedEdges() []string { if m.removedresources != nil { edges = append(edges, permission.EdgeResources) } + if m.removedviews != nil { + edges = append(edges, permission.EdgeViews) + } if m.removedrole_permissions != nil { edges = append(edges, permission.EdgeRolePermissions) } @@ -4061,6 +4132,12 @@ func (m *PermissionMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case permission.EdgeViews: + ids := make([]ent.Value, 0, len(m.removedviews)) + for id := range m.removedviews { + ids = append(ids, id) + } + return ids case permission.EdgeRolePermissions: ids := make([]ent.Value, 0, len(m.removedrole_permissions)) for id := range m.removedrole_permissions { @@ -4085,7 +4162,7 @@ func (m *PermissionMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *PermissionMutation) ClearedEdges() []string { - edges := make([]string, 0, 6) + edges := make([]string, 0, 7) if m.clearedroles { edges = append(edges, permission.EdgeRoles) } @@ -4095,6 +4172,9 @@ func (m *PermissionMutation) ClearedEdges() []string { if m.clearedresources { edges = append(edges, permission.EdgeResources) } + if m.clearedviews { + edges = append(edges, permission.EdgeViews) + } if m.clearedrole_permissions { edges = append(edges, permission.EdgeRolePermissions) } @@ -4117,6 +4197,8 @@ func (m *PermissionMutation) EdgeCleared(name string) bool { return m.clearedpositions case permission.EdgeResources: return m.clearedresources + case permission.EdgeViews: + return m.clearedviews case permission.EdgeRolePermissions: return m.clearedrole_permissions case permission.EdgePositionPermissions: @@ -4148,6 +4230,9 @@ func (m *PermissionMutation) ResetEdge(name string) error { case permission.EdgeResources: m.ResetResources() return nil + case permission.EdgeViews: + m.ResetViews() + return nil case permission.EdgeRolePermissions: m.ResetRolePermissions() return nil @@ -6123,45 +6208,31 @@ func (m *PositionPermissionMutation) ResetEdge(name string) error { // ResourceMutation represents an operation that mutates the Resource nodes in the graph. type ResourceMutation struct { config - op Op - typ string - id *int64 - create_time *time.Time - update_time *time.Time - name *string - keyword *string - i18n_key *string - _type *string - status *int8 - addstatus *int8 - _path *string - operation *string - method *string - component *string - icon *string - sequence *int - addsequence *int - visible *bool - level *int8 - addlevel *int8 - tree_path *string - properties *map[string]string - description *string - clearedFields map[string]struct{} - children map[int64]struct{} - removedchildren map[int64]struct{} - clearedchildren bool - parent *int64 - clearedparent bool - permissions map[int64]struct{} - removedpermissions map[int64]struct{} - clearedpermissions bool - permission_resources map[int]struct{} - removedpermission_resources map[int]struct{} - clearedpermission_resources bool - done bool - oldValue func(context.Context) (*Resource, error) - predicates []predicate.Resource + op Op + typ string + id *int64 + create_time *time.Time + update_time *time.Time + service_name *string + keyword *string + _path *string + method *string + operation *string + policy *string + version_id *string + last_sync_version_id *string + sync_status *string + status *resource.Status + clearedFields map[string]struct{} + views map[int64]struct{} + removedviews map[int64]struct{} + clearedviews bool + permissions map[int64]struct{} + removedpermissions map[int64]struct{} + clearedpermissions bool + done bool + oldValue func(context.Context) (*Resource, error) + predicates []predicate.Resource } var _ ent.Mutation = (*ResourceMutation)(nil) @@ -6340,40 +6411,40 @@ func (m *ResourceMutation) ResetUpdateTime() { m.update_time = nil } -// SetName sets the "name" field. -func (m *ResourceMutation) SetName(s string) { - m.name = &s +// SetServiceName sets the "service_name" field. +func (m *ResourceMutation) SetServiceName(s string) { + m.service_name = &s } -// Name returns the value of the "name" field in the mutation. -func (m *ResourceMutation) Name() (r string, exists bool) { - v := m.name +// ServiceName returns the value of the "service_name" field in the mutation. +func (m *ResourceMutation) ServiceName() (r string, exists bool) { + v := m.service_name if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the Resource entity. +// OldServiceName returns the old "service_name" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldName(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldServiceName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") + return v, errors.New("OldServiceName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") + return v, errors.New("OldServiceName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) + return v, fmt.Errorf("querying old value for OldServiceName: %w", err) } - return oldValue.Name, nil + return oldValue.ServiceName, nil } -// ResetName resets all changes to the "name" field. -func (m *ResourceMutation) ResetName() { - m.name = nil +// ResetServiceName resets all changes to the "service_name" field. +func (m *ResourceMutation) ResetServiceName() { + m.service_name = nil } // SetKeyword sets the "keyword" field. @@ -6412,2178 +6483,2293 @@ func (m *ResourceMutation) ResetKeyword() { m.keyword = nil } -// SetI18nKey sets the "i18n_key" field. -func (m *ResourceMutation) SetI18nKey(s string) { - m.i18n_key = &s +// SetPath sets the "path" field. +func (m *ResourceMutation) SetPath(s string) { + m._path = &s } -// I18nKey returns the value of the "i18n_key" field in the mutation. -func (m *ResourceMutation) I18nKey() (r string, exists bool) { - v := m.i18n_key +// Path returns the value of the "path" field in the mutation. +func (m *ResourceMutation) Path() (r string, exists bool) { + v := m._path if v == nil { return } return *v, true } -// OldI18nKey returns the old "i18n_key" field's value of the Resource entity. +// OldPath returns the old "path" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldI18nKey(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldPath(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldI18nKey is only allowed on UpdateOne operations") + return v, errors.New("OldPath is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldI18nKey requires an ID field in the mutation") + return v, errors.New("OldPath requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldI18nKey: %w", err) + return v, fmt.Errorf("querying old value for OldPath: %w", err) } - return oldValue.I18nKey, nil + return oldValue.Path, nil } -// ResetI18nKey resets all changes to the "i18n_key" field. -func (m *ResourceMutation) ResetI18nKey() { - m.i18n_key = nil +// ClearPath clears the value of the "path" field. +func (m *ResourceMutation) ClearPath() { + m._path = nil + m.clearedFields[resource.FieldPath] = struct{}{} } -// SetType sets the "type" field. -func (m *ResourceMutation) SetType(s string) { - m._type = &s +// PathCleared returns if the "path" field was cleared in this mutation. +func (m *ResourceMutation) PathCleared() bool { + _, ok := m.clearedFields[resource.FieldPath] + return ok } -// GetType returns the value of the "type" field in the mutation. -func (m *ResourceMutation) GetType() (r string, exists bool) { - v := m._type +// ResetPath resets all changes to the "path" field. +func (m *ResourceMutation) ResetPath() { + m._path = nil + delete(m.clearedFields, resource.FieldPath) +} + +// SetMethod sets the "method" field. +func (m *ResourceMutation) SetMethod(s string) { + m.method = &s +} + +// Method returns the value of the "method" field in the mutation. +func (m *ResourceMutation) Method() (r string, exists bool) { + v := m.method if v == nil { return } return *v, true } -// OldType returns the old "type" field's value of the Resource entity. +// OldMethod returns the old "method" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldType(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldMethod(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") + return v, errors.New("OldMethod is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") + return v, errors.New("OldMethod requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) + return v, fmt.Errorf("querying old value for OldMethod: %w", err) } - return oldValue.Type, nil + return oldValue.Method, nil } -// ResetType resets all changes to the "type" field. -func (m *ResourceMutation) ResetType() { - m._type = nil +// ClearMethod clears the value of the "method" field. +func (m *ResourceMutation) ClearMethod() { + m.method = nil + m.clearedFields[resource.FieldMethod] = struct{}{} } -// SetStatus sets the "status" field. -func (m *ResourceMutation) SetStatus(i int8) { - m.status = &i - m.addstatus = nil +// MethodCleared returns if the "method" field was cleared in this mutation. +func (m *ResourceMutation) MethodCleared() bool { + _, ok := m.clearedFields[resource.FieldMethod] + return ok } -// Status returns the value of the "status" field in the mutation. -func (m *ResourceMutation) Status() (r int8, exists bool) { - v := m.status +// ResetMethod resets all changes to the "method" field. +func (m *ResourceMutation) ResetMethod() { + m.method = nil + delete(m.clearedFields, resource.FieldMethod) +} + +// SetOperation sets the "operation" field. +func (m *ResourceMutation) SetOperation(s string) { + m.operation = &s +} + +// Operation returns the value of the "operation" field in the mutation. +func (m *ResourceMutation) Operation() (r string, exists bool) { + v := m.operation if v == nil { return } return *v, true } -// OldStatus returns the old "status" field's value of the Resource entity. +// OldOperation returns the old "operation" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldStatus(ctx context.Context) (v int8, err error) { +func (m *ResourceMutation) OldOperation(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") + return v, errors.New("OldOperation is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") + return v, errors.New("OldOperation requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) + return v, fmt.Errorf("querying old value for OldOperation: %w", err) } - return oldValue.Status, nil + return oldValue.Operation, nil } -// AddStatus adds i to the "status" field. -func (m *ResourceMutation) AddStatus(i int8) { - if m.addstatus != nil { - *m.addstatus += i - } else { - m.addstatus = &i - } +// ClearOperation clears the value of the "operation" field. +func (m *ResourceMutation) ClearOperation() { + m.operation = nil + m.clearedFields[resource.FieldOperation] = struct{}{} } -// AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *ResourceMutation) AddedStatus() (r int8, exists bool) { - v := m.addstatus - if v == nil { - return - } - return *v, true +// OperationCleared returns if the "operation" field was cleared in this mutation. +func (m *ResourceMutation) OperationCleared() bool { + _, ok := m.clearedFields[resource.FieldOperation] + return ok } -// ResetStatus resets all changes to the "status" field. -func (m *ResourceMutation) ResetStatus() { - m.status = nil - m.addstatus = nil +// ResetOperation resets all changes to the "operation" field. +func (m *ResourceMutation) ResetOperation() { + m.operation = nil + delete(m.clearedFields, resource.FieldOperation) } -// SetPath sets the "path" field. -func (m *ResourceMutation) SetPath(s string) { - m._path = &s +// SetPolicy sets the "policy" field. +func (m *ResourceMutation) SetPolicy(s string) { + m.policy = &s } -// Path returns the value of the "path" field in the mutation. -func (m *ResourceMutation) Path() (r string, exists bool) { - v := m._path +// Policy returns the value of the "policy" field in the mutation. +func (m *ResourceMutation) Policy() (r string, exists bool) { + v := m.policy if v == nil { return } return *v, true } -// OldPath returns the old "path" field's value of the Resource entity. +// OldPolicy returns the old "policy" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldPath(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldPolicy(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPath is only allowed on UpdateOne operations") + return v, errors.New("OldPolicy is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPath requires an ID field in the mutation") + return v, errors.New("OldPolicy requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPath: %w", err) + return v, fmt.Errorf("querying old value for OldPolicy: %w", err) } - return oldValue.Path, nil + return oldValue.Policy, nil } -// ResetPath resets all changes to the "path" field. -func (m *ResourceMutation) ResetPath() { - m._path = nil +// ResetPolicy resets all changes to the "policy" field. +func (m *ResourceMutation) ResetPolicy() { + m.policy = nil } -// SetOperation sets the "operation" field. -func (m *ResourceMutation) SetOperation(s string) { - m.operation = &s +// SetVersionID sets the "version_id" field. +func (m *ResourceMutation) SetVersionID(s string) { + m.version_id = &s } -// Operation returns the value of the "operation" field in the mutation. -func (m *ResourceMutation) Operation() (r string, exists bool) { - v := m.operation +// VersionID returns the value of the "version_id" field in the mutation. +func (m *ResourceMutation) VersionID() (r string, exists bool) { + v := m.version_id if v == nil { return } return *v, true } -// OldOperation returns the old "operation" field's value of the Resource entity. +// OldVersionID returns the old "version_id" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldOperation(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldVersionID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldOperation is only allowed on UpdateOne operations") + return v, errors.New("OldVersionID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldOperation requires an ID field in the mutation") + return v, errors.New("OldVersionID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldOperation: %w", err) + return v, fmt.Errorf("querying old value for OldVersionID: %w", err) } - return oldValue.Operation, nil + return oldValue.VersionID, nil } -// ResetOperation resets all changes to the "operation" field. -func (m *ResourceMutation) ResetOperation() { - m.operation = nil +// ResetVersionID resets all changes to the "version_id" field. +func (m *ResourceMutation) ResetVersionID() { + m.version_id = nil } -// SetMethod sets the "method" field. -func (m *ResourceMutation) SetMethod(s string) { - m.method = &s +// SetLastSyncVersionID sets the "last_sync_version_id" field. +func (m *ResourceMutation) SetLastSyncVersionID(s string) { + m.last_sync_version_id = &s } -// Method returns the value of the "method" field in the mutation. -func (m *ResourceMutation) Method() (r string, exists bool) { - v := m.method +// LastSyncVersionID returns the value of the "last_sync_version_id" field in the mutation. +func (m *ResourceMutation) LastSyncVersionID() (r string, exists bool) { + v := m.last_sync_version_id if v == nil { return } return *v, true } -// OldMethod returns the old "method" field's value of the Resource entity. +// OldLastSyncVersionID returns the old "last_sync_version_id" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldMethod(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldLastSyncVersionID(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldMethod is only allowed on UpdateOne operations") + return v, errors.New("OldLastSyncVersionID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldMethod requires an ID field in the mutation") + return v, errors.New("OldLastSyncVersionID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldMethod: %w", err) + return v, fmt.Errorf("querying old value for OldLastSyncVersionID: %w", err) } - return oldValue.Method, nil + return oldValue.LastSyncVersionID, nil } -// ResetMethod resets all changes to the "method" field. -func (m *ResourceMutation) ResetMethod() { - m.method = nil +// ResetLastSyncVersionID resets all changes to the "last_sync_version_id" field. +func (m *ResourceMutation) ResetLastSyncVersionID() { + m.last_sync_version_id = nil } -// SetComponent sets the "component" field. -func (m *ResourceMutation) SetComponent(s string) { - m.component = &s +// SetSyncStatus sets the "sync_status" field. +func (m *ResourceMutation) SetSyncStatus(s string) { + m.sync_status = &s } -// Component returns the value of the "component" field in the mutation. -func (m *ResourceMutation) Component() (r string, exists bool) { - v := m.component +// SyncStatus returns the value of the "sync_status" field in the mutation. +func (m *ResourceMutation) SyncStatus() (r string, exists bool) { + v := m.sync_status if v == nil { return } return *v, true } -// OldComponent returns the old "component" field's value of the Resource entity. +// OldSyncStatus returns the old "sync_status" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldComponent(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldSyncStatus(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldComponent is only allowed on UpdateOne operations") + return v, errors.New("OldSyncStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldComponent requires an ID field in the mutation") + return v, errors.New("OldSyncStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldComponent: %w", err) + return v, fmt.Errorf("querying old value for OldSyncStatus: %w", err) } - return oldValue.Component, nil + return oldValue.SyncStatus, nil } -// ResetComponent resets all changes to the "component" field. -func (m *ResourceMutation) ResetComponent() { - m.component = nil +// ResetSyncStatus resets all changes to the "sync_status" field. +func (m *ResourceMutation) ResetSyncStatus() { + m.sync_status = nil } -// SetIcon sets the "icon" field. -func (m *ResourceMutation) SetIcon(s string) { - m.icon = &s +// SetStatus sets the "status" field. +func (m *ResourceMutation) SetStatus(r resource.Status) { + m.status = &r } -// Icon returns the value of the "icon" field in the mutation. -func (m *ResourceMutation) Icon() (r string, exists bool) { - v := m.icon +// Status returns the value of the "status" field in the mutation. +func (m *ResourceMutation) Status() (r resource.Status, exists bool) { + v := m.status if v == nil { return } return *v, true } -// OldIcon returns the old "icon" field's value of the Resource entity. +// OldStatus returns the old "status" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldIcon(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldStatus(ctx context.Context) (v resource.Status, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIcon is only allowed on UpdateOne operations") + return v, errors.New("OldStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIcon requires an ID field in the mutation") + return v, errors.New("OldStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldIcon: %w", err) + return v, fmt.Errorf("querying old value for OldStatus: %w", err) } - return oldValue.Icon, nil + return oldValue.Status, nil } -// ResetIcon resets all changes to the "icon" field. -func (m *ResourceMutation) ResetIcon() { - m.icon = nil +// ResetStatus resets all changes to the "status" field. +func (m *ResourceMutation) ResetStatus() { + m.status = nil } -// SetSequence sets the "sequence" field. -func (m *ResourceMutation) SetSequence(i int) { - m.sequence = &i - m.addsequence = nil +// AddViewIDs adds the "views" edge to the View entity by ids. +func (m *ResourceMutation) AddViewIDs(ids ...int64) { + if m.views == nil { + m.views = make(map[int64]struct{}) + } + for i := range ids { + m.views[ids[i]] = struct{}{} + } } -// Sequence returns the value of the "sequence" field in the mutation. -func (m *ResourceMutation) Sequence() (r int, exists bool) { - v := m.sequence - if v == nil { - return - } - return *v, true +// ClearViews clears the "views" edge to the View entity. +func (m *ResourceMutation) ClearViews() { + m.clearedviews = true } -// OldSequence returns the old "sequence" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldSequence(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSequence is only allowed on UpdateOne operations") +// ViewsCleared reports if the "views" edge to the View entity was cleared. +func (m *ResourceMutation) ViewsCleared() bool { + return m.clearedviews +} + +// RemoveViewIDs removes the "views" edge to the View entity by IDs. +func (m *ResourceMutation) RemoveViewIDs(ids ...int64) { + if m.removedviews == nil { + m.removedviews = make(map[int64]struct{}) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSequence requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSequence: %w", err) + for i := range ids { + delete(m.views, ids[i]) + m.removedviews[ids[i]] = struct{}{} } - return oldValue.Sequence, nil } -// AddSequence adds i to the "sequence" field. -func (m *ResourceMutation) AddSequence(i int) { - if m.addsequence != nil { - *m.addsequence += i - } else { - m.addsequence = &i +// RemovedViews returns the removed IDs of the "views" edge to the View entity. +func (m *ResourceMutation) RemovedViewsIDs() (ids []int64) { + for id := range m.removedviews { + ids = append(ids, id) } + return } -// AddedSequence returns the value that was added to the "sequence" field in this mutation. -func (m *ResourceMutation) AddedSequence() (r int, exists bool) { - v := m.addsequence - if v == nil { - return +// ViewsIDs returns the "views" edge IDs in the mutation. +func (m *ResourceMutation) ViewsIDs() (ids []int64) { + for id := range m.views { + ids = append(ids, id) } - return *v, true -} - -// ResetSequence resets all changes to the "sequence" field. -func (m *ResourceMutation) ResetSequence() { - m.sequence = nil - m.addsequence = nil -} - -// SetVisible sets the "visible" field. -func (m *ResourceMutation) SetVisible(b bool) { - m.visible = &b + return } -// Visible returns the value of the "visible" field in the mutation. -func (m *ResourceMutation) Visible() (r bool, exists bool) { - v := m.visible - if v == nil { - return - } - return *v, true +// ResetViews resets all changes to the "views" edge. +func (m *ResourceMutation) ResetViews() { + m.views = nil + m.clearedviews = false + m.removedviews = nil } -// OldVisible returns the old "visible" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldVisible(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldVisible is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldVisible requires an ID field in the mutation") +// AddPermissionIDs adds the "permissions" edge to the Permission entity by ids. +func (m *ResourceMutation) AddPermissionIDs(ids ...int64) { + if m.permissions == nil { + m.permissions = make(map[int64]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldVisible: %w", err) + for i := range ids { + m.permissions[ids[i]] = struct{}{} } - return oldValue.Visible, nil -} - -// ResetVisible resets all changes to the "visible" field. -func (m *ResourceMutation) ResetVisible() { - m.visible = nil } -// SetLevel sets the "level" field. -func (m *ResourceMutation) SetLevel(i int8) { - m.level = &i - m.addlevel = nil +// ClearPermissions clears the "permissions" edge to the Permission entity. +func (m *ResourceMutation) ClearPermissions() { + m.clearedpermissions = true } -// Level returns the value of the "level" field in the mutation. -func (m *ResourceMutation) Level() (r int8, exists bool) { - v := m.level - if v == nil { - return - } - return *v, true +// PermissionsCleared reports if the "permissions" edge to the Permission entity was cleared. +func (m *ResourceMutation) PermissionsCleared() bool { + return m.clearedpermissions } -// OldLevel returns the old "level" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldLevel(ctx context.Context) (v int8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLevel is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLevel requires an ID field in the mutation") +// RemovePermissionIDs removes the "permissions" edge to the Permission entity by IDs. +func (m *ResourceMutation) RemovePermissionIDs(ids ...int64) { + if m.removedpermissions == nil { + m.removedpermissions = make(map[int64]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLevel: %w", err) + for i := range ids { + delete(m.permissions, ids[i]) + m.removedpermissions[ids[i]] = struct{}{} } - return oldValue.Level, nil } -// AddLevel adds i to the "level" field. -func (m *ResourceMutation) AddLevel(i int8) { - if m.addlevel != nil { - *m.addlevel += i - } else { - m.addlevel = &i +// RemovedPermissions returns the removed IDs of the "permissions" edge to the Permission entity. +func (m *ResourceMutation) RemovedPermissionsIDs() (ids []int64) { + for id := range m.removedpermissions { + ids = append(ids, id) } + return } -// AddedLevel returns the value that was added to the "level" field in this mutation. -func (m *ResourceMutation) AddedLevel() (r int8, exists bool) { - v := m.addlevel - if v == nil { - return +// PermissionsIDs returns the "permissions" edge IDs in the mutation. +func (m *ResourceMutation) PermissionsIDs() (ids []int64) { + for id := range m.permissions { + ids = append(ids, id) } - return *v, true + return } -// ResetLevel resets all changes to the "level" field. -func (m *ResourceMutation) ResetLevel() { - m.level = nil - m.addlevel = nil +// ResetPermissions resets all changes to the "permissions" edge. +func (m *ResourceMutation) ResetPermissions() { + m.permissions = nil + m.clearedpermissions = false + m.removedpermissions = nil } -// SetTreePath sets the "tree_path" field. -func (m *ResourceMutation) SetTreePath(s string) { - m.tree_path = &s +// Where appends a list predicates to the ResourceMutation builder. +func (m *ResourceMutation) Where(ps ...predicate.Resource) { + m.predicates = append(m.predicates, ps...) } -// TreePath returns the value of the "tree_path" field in the mutation. -func (m *ResourceMutation) TreePath() (r string, exists bool) { - v := m.tree_path - if v == nil { - return +// WhereP appends storage-level predicates to the ResourceMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ResourceMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Resource, len(ps)) + for i := range ps { + p[i] = ps[i] } - return *v, true + m.Where(p...) } -// OldTreePath returns the old "tree_path" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldTreePath(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTreePath is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTreePath requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTreePath: %w", err) - } - return oldValue.TreePath, nil +// Op returns the operation name. +func (m *ResourceMutation) Op() Op { + return m.op } -// ResetTreePath resets all changes to the "tree_path" field. -func (m *ResourceMutation) ResetTreePath() { - m.tree_path = nil +// SetOp allows setting the mutation operation. +func (m *ResourceMutation) SetOp(op Op) { + m.op = op } -// SetProperties sets the "properties" field. -func (m *ResourceMutation) SetProperties(value map[string]string) { - m.properties = &value +// Type returns the node type of this mutation (Resource). +func (m *ResourceMutation) Type() string { + return m.typ } -// Properties returns the value of the "properties" field in the mutation. -func (m *ResourceMutation) Properties() (r map[string]string, exists bool) { - v := m.properties - if v == nil { - return +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ResourceMutation) Fields() []string { + fields := make([]string, 0, 12) + if m.create_time != nil { + fields = append(fields, resource.FieldCreateTime) } - return *v, true -} - -// OldProperties returns the old "properties" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldProperties(ctx context.Context) (v map[string]string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldProperties is only allowed on UpdateOne operations") + if m.update_time != nil { + fields = append(fields, resource.FieldUpdateTime) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldProperties requires an ID field in the mutation") + if m.service_name != nil { + fields = append(fields, resource.FieldServiceName) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldProperties: %w", err) + if m.keyword != nil { + fields = append(fields, resource.FieldKeyword) } - return oldValue.Properties, nil -} - -// ClearProperties clears the value of the "properties" field. -func (m *ResourceMutation) ClearProperties() { - m.properties = nil - m.clearedFields[resource.FieldProperties] = struct{}{} -} - -// PropertiesCleared returns if the "properties" field was cleared in this mutation. -func (m *ResourceMutation) PropertiesCleared() bool { - _, ok := m.clearedFields[resource.FieldProperties] - return ok -} - -// ResetProperties resets all changes to the "properties" field. -func (m *ResourceMutation) ResetProperties() { - m.properties = nil - delete(m.clearedFields, resource.FieldProperties) -} - -// SetDescription sets the "description" field. -func (m *ResourceMutation) SetDescription(s string) { - m.description = &s -} - -// Description returns the value of the "description" field in the mutation. -func (m *ResourceMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return + if m._path != nil { + fields = append(fields, resource.FieldPath) } - return *v, true -} - -// OldDescription returns the old "description" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") + if m.method != nil { + fields = append(fields, resource.FieldMethod) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + if m.operation != nil { + fields = append(fields, resource.FieldOperation) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + if m.policy != nil { + fields = append(fields, resource.FieldPolicy) } - return oldValue.Description, nil -} - -// ResetDescription resets all changes to the "description" field. -func (m *ResourceMutation) ResetDescription() { - m.description = nil -} - -// SetParentID sets the "parent_id" field. -func (m *ResourceMutation) SetParentID(i int64) { - m.parent = &i -} - -// ParentID returns the value of the "parent_id" field in the mutation. -func (m *ResourceMutation) ParentID() (r int64, exists bool) { - v := m.parent - if v == nil { - return + if m.version_id != nil { + fields = append(fields, resource.FieldVersionID) } - return *v, true -} - -// OldParentID returns the old "parent_id" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldParentID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldParentID is only allowed on UpdateOne operations") + if m.last_sync_version_id != nil { + fields = append(fields, resource.FieldLastSyncVersionID) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldParentID requires an ID field in the mutation") + if m.sync_status != nil { + fields = append(fields, resource.FieldSyncStatus) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldParentID: %w", err) + if m.status != nil { + fields = append(fields, resource.FieldStatus) } - return oldValue.ParentID, nil -} - -// ClearParentID clears the value of the "parent_id" field. -func (m *ResourceMutation) ClearParentID() { - m.parent = nil - m.clearedFields[resource.FieldParentID] = struct{}{} -} - -// ParentIDCleared returns if the "parent_id" field was cleared in this mutation. -func (m *ResourceMutation) ParentIDCleared() bool { - _, ok := m.clearedFields[resource.FieldParentID] - return ok + return fields } -// ResetParentID resets all changes to the "parent_id" field. -func (m *ResourceMutation) ResetParentID() { - m.parent = nil - delete(m.clearedFields, resource.FieldParentID) -} - -// AddChildIDs adds the "children" edge to the Resource entity by ids. -func (m *ResourceMutation) AddChildIDs(ids ...int64) { - if m.children == nil { - m.children = make(map[int64]struct{}) - } - for i := range ids { - m.children[ids[i]] = struct{}{} +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ResourceMutation) Field(name string) (ent.Value, bool) { + switch name { + case resource.FieldCreateTime: + return m.CreateTime() + case resource.FieldUpdateTime: + return m.UpdateTime() + case resource.FieldServiceName: + return m.ServiceName() + case resource.FieldKeyword: + return m.Keyword() + case resource.FieldPath: + return m.Path() + case resource.FieldMethod: + return m.Method() + case resource.FieldOperation: + return m.Operation() + case resource.FieldPolicy: + return m.Policy() + case resource.FieldVersionID: + return m.VersionID() + case resource.FieldLastSyncVersionID: + return m.LastSyncVersionID() + case resource.FieldSyncStatus: + return m.SyncStatus() + case resource.FieldStatus: + return m.Status() } + return nil, false } -// ClearChildren clears the "children" edge to the Resource entity. -func (m *ResourceMutation) ClearChildren() { - m.clearedchildren = true -} - -// ChildrenCleared reports if the "children" edge to the Resource entity was cleared. -func (m *ResourceMutation) ChildrenCleared() bool { - return m.clearedchildren +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ResourceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case resource.FieldCreateTime: + return m.OldCreateTime(ctx) + case resource.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case resource.FieldServiceName: + return m.OldServiceName(ctx) + case resource.FieldKeyword: + return m.OldKeyword(ctx) + case resource.FieldPath: + return m.OldPath(ctx) + case resource.FieldMethod: + return m.OldMethod(ctx) + case resource.FieldOperation: + return m.OldOperation(ctx) + case resource.FieldPolicy: + return m.OldPolicy(ctx) + case resource.FieldVersionID: + return m.OldVersionID(ctx) + case resource.FieldLastSyncVersionID: + return m.OldLastSyncVersionID(ctx) + case resource.FieldSyncStatus: + return m.OldSyncStatus(ctx) + case resource.FieldStatus: + return m.OldStatus(ctx) + } + return nil, fmt.Errorf("unknown Resource field %s", name) } -// RemoveChildIDs removes the "children" edge to the Resource entity by IDs. -func (m *ResourceMutation) RemoveChildIDs(ids ...int64) { - if m.removedchildren == nil { - m.removedchildren = make(map[int64]struct{}) - } - for i := range ids { - delete(m.children, ids[i]) - m.removedchildren[ids[i]] = struct{}{} +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ResourceMutation) SetField(name string, value ent.Value) error { + switch name { + case resource.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case resource.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case resource.FieldServiceName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServiceName(v) + return nil + case resource.FieldKeyword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKeyword(v) + return nil + case resource.FieldPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPath(v) + return nil + case resource.FieldMethod: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMethod(v) + return nil + case resource.FieldOperation: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOperation(v) + return nil + case resource.FieldPolicy: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPolicy(v) + return nil + case resource.FieldVersionID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVersionID(v) + return nil + case resource.FieldLastSyncVersionID: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLastSyncVersionID(v) + return nil + case resource.FieldSyncStatus: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSyncStatus(v) + return nil + case resource.FieldStatus: + v, ok := value.(resource.Status) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil } + return fmt.Errorf("unknown Resource field %s", name) } -// RemovedChildren returns the removed IDs of the "children" edge to the Resource entity. -func (m *ResourceMutation) RemovedChildrenIDs() (ids []int64) { - for id := range m.removedchildren { - ids = append(ids, id) - } - return +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ResourceMutation) AddedFields() []string { + return nil } -// ChildrenIDs returns the "children" edge IDs in the mutation. -func (m *ResourceMutation) ChildrenIDs() (ids []int64) { - for id := range m.children { - ids = append(ids, id) - } - return +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ResourceMutation) AddedField(name string) (ent.Value, bool) { + return nil, false } -// ResetChildren resets all changes to the "children" edge. -func (m *ResourceMutation) ResetChildren() { - m.children = nil - m.clearedchildren = false - m.removedchildren = nil +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ResourceMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Resource numeric field %s", name) } -// ClearParent clears the "parent" edge to the Resource entity. -func (m *ResourceMutation) ClearParent() { - m.clearedparent = true - m.clearedFields[resource.FieldParentID] = struct{}{} +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ResourceMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(resource.FieldPath) { + fields = append(fields, resource.FieldPath) + } + if m.FieldCleared(resource.FieldMethod) { + fields = append(fields, resource.FieldMethod) + } + if m.FieldCleared(resource.FieldOperation) { + fields = append(fields, resource.FieldOperation) + } + return fields } -// ParentCleared reports if the "parent" edge to the Resource entity was cleared. -func (m *ResourceMutation) ParentCleared() bool { - return m.ParentIDCleared() || m.clearedparent +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ResourceMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok } -// ParentIDs returns the "parent" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// ParentID instead. It exists only for internal usage by the builders. -func (m *ResourceMutation) ParentIDs() (ids []int64) { - if id := m.parent; id != nil { - ids = append(ids, *id) +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ResourceMutation) ClearField(name string) error { + switch name { + case resource.FieldPath: + m.ClearPath() + return nil + case resource.FieldMethod: + m.ClearMethod() + return nil + case resource.FieldOperation: + m.ClearOperation() + return nil } - return + return fmt.Errorf("unknown Resource nullable field %s", name) } -// ResetParent resets all changes to the "parent" edge. -func (m *ResourceMutation) ResetParent() { - m.parent = nil - m.clearedparent = false +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ResourceMutation) ResetField(name string) error { + switch name { + case resource.FieldCreateTime: + m.ResetCreateTime() + return nil + case resource.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case resource.FieldServiceName: + m.ResetServiceName() + return nil + case resource.FieldKeyword: + m.ResetKeyword() + return nil + case resource.FieldPath: + m.ResetPath() + return nil + case resource.FieldMethod: + m.ResetMethod() + return nil + case resource.FieldOperation: + m.ResetOperation() + return nil + case resource.FieldPolicy: + m.ResetPolicy() + return nil + case resource.FieldVersionID: + m.ResetVersionID() + return nil + case resource.FieldLastSyncVersionID: + m.ResetLastSyncVersionID() + return nil + case resource.FieldSyncStatus: + m.ResetSyncStatus() + return nil + case resource.FieldStatus: + m.ResetStatus() + return nil + } + return fmt.Errorf("unknown Resource field %s", name) } -// AddPermissionIDs adds the "permissions" edge to the Permission entity by ids. -func (m *ResourceMutation) AddPermissionIDs(ids ...int64) { - if m.permissions == nil { - m.permissions = make(map[int64]struct{}) +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ResourceMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.views != nil { + edges = append(edges, resource.EdgeViews) } - for i := range ids { - m.permissions[ids[i]] = struct{}{} + if m.permissions != nil { + edges = append(edges, resource.EdgePermissions) } + return edges } -// ClearPermissions clears the "permissions" edge to the Permission entity. -func (m *ResourceMutation) ClearPermissions() { - m.clearedpermissions = true -} - -// PermissionsCleared reports if the "permissions" edge to the Permission entity was cleared. -func (m *ResourceMutation) PermissionsCleared() bool { - return m.clearedpermissions -} +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ResourceMutation) AddedIDs(name string) []ent.Value { + switch name { + case resource.EdgeViews: + ids := make([]ent.Value, 0, len(m.views)) + for id := range m.views { + ids = append(ids, id) + } + return ids + case resource.EdgePermissions: + ids := make([]ent.Value, 0, len(m.permissions)) + for id := range m.permissions { + ids = append(ids, id) + } + return ids + } + return nil +} -// RemovePermissionIDs removes the "permissions" edge to the Permission entity by IDs. -func (m *ResourceMutation) RemovePermissionIDs(ids ...int64) { - if m.removedpermissions == nil { - m.removedpermissions = make(map[int64]struct{}) +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ResourceMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + if m.removedviews != nil { + edges = append(edges, resource.EdgeViews) } - for i := range ids { - delete(m.permissions, ids[i]) - m.removedpermissions[ids[i]] = struct{}{} + if m.removedpermissions != nil { + edges = append(edges, resource.EdgePermissions) } + return edges } -// RemovedPermissions returns the removed IDs of the "permissions" edge to the Permission entity. -func (m *ResourceMutation) RemovedPermissionsIDs() (ids []int64) { - for id := range m.removedpermissions { - ids = append(ids, id) +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ResourceMutation) RemovedIDs(name string) []ent.Value { + switch name { + case resource.EdgeViews: + ids := make([]ent.Value, 0, len(m.removedviews)) + for id := range m.removedviews { + ids = append(ids, id) + } + return ids + case resource.EdgePermissions: + ids := make([]ent.Value, 0, len(m.removedpermissions)) + for id := range m.removedpermissions { + ids = append(ids, id) + } + return ids } - return + return nil } -// PermissionsIDs returns the "permissions" edge IDs in the mutation. -func (m *ResourceMutation) PermissionsIDs() (ids []int64) { - for id := range m.permissions { - ids = append(ids, id) +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ResourceMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedviews { + edges = append(edges, resource.EdgeViews) } - return + if m.clearedpermissions { + edges = append(edges, resource.EdgePermissions) + } + return edges } -// ResetPermissions resets all changes to the "permissions" edge. -func (m *ResourceMutation) ResetPermissions() { - m.permissions = nil - m.clearedpermissions = false - m.removedpermissions = nil +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ResourceMutation) EdgeCleared(name string) bool { + switch name { + case resource.EdgeViews: + return m.clearedviews + case resource.EdgePermissions: + return m.clearedpermissions + } + return false } -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by ids. -func (m *ResourceMutation) AddPermissionResourceIDs(ids ...int) { - if m.permission_resources == nil { - m.permission_resources = make(map[int]struct{}) - } - for i := range ids { - m.permission_resources[ids[i]] = struct{}{} +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ResourceMutation) ClearEdge(name string) error { + switch name { } + return fmt.Errorf("unknown Resource unique edge %s", name) } -// ClearPermissionResources clears the "permission_resources" edge to the PermissionResource entity. -func (m *ResourceMutation) ClearPermissionResources() { - m.clearedpermission_resources = true +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ResourceMutation) ResetEdge(name string) error { + switch name { + case resource.EdgeViews: + m.ResetViews() + return nil + case resource.EdgePermissions: + m.ResetPermissions() + return nil + } + return fmt.Errorf("unknown Resource edge %s", name) } -// PermissionResourcesCleared reports if the "permission_resources" edge to the PermissionResource entity was cleared. -func (m *ResourceMutation) PermissionResourcesCleared() bool { - return m.clearedpermission_resources +// RoleMutation represents an operation that mutates the Role nodes in the graph. +type RoleMutation struct { + config + op Op + typ string + id *int64 + create_time *time.Time + update_time *time.Time + keyword *string + name *string + description *string + _type *int8 + add_type *int8 + sequence *int + addsequence *int + status *int8 + addstatus *int8 + clearedFields map[string]struct{} + users map[int64]struct{} + removedusers map[int64]struct{} + clearedusers bool + permissions map[int64]struct{} + removedpermissions map[int64]struct{} + clearedpermissions bool + user_roles map[int]struct{} + removeduser_roles map[int]struct{} + cleareduser_roles bool + role_permissions map[int]struct{} + removedrole_permissions map[int]struct{} + clearedrole_permissions bool + done bool + oldValue func(context.Context) (*Role, error) + predicates []predicate.Role } -// RemovePermissionResourceIDs removes the "permission_resources" edge to the PermissionResource entity by IDs. -func (m *ResourceMutation) RemovePermissionResourceIDs(ids ...int) { - if m.removedpermission_resources == nil { - m.removedpermission_resources = make(map[int]struct{}) +var _ ent.Mutation = (*RoleMutation)(nil) + +// roleOption allows management of the mutation configuration using functional options. +type roleOption func(*RoleMutation) + +// newRoleMutation creates new mutation for the Role entity. +func newRoleMutation(c config, op Op, opts ...roleOption) *RoleMutation { + m := &RoleMutation{ + config: c, + op: op, + typ: TypeRole, + clearedFields: make(map[string]struct{}), } - for i := range ids { - delete(m.permission_resources, ids[i]) - m.removedpermission_resources[ids[i]] = struct{}{} + for _, opt := range opts { + opt(m) } + return m } -// RemovedPermissionResources returns the removed IDs of the "permission_resources" edge to the PermissionResource entity. -func (m *ResourceMutation) RemovedPermissionResourcesIDs() (ids []int) { - for id := range m.removedpermission_resources { - ids = append(ids, id) +// withRoleID sets the ID field of the mutation. +func withRoleID(id int64) roleOption { + return func(m *RoleMutation) { + var ( + err error + once sync.Once + value *Role + ) + m.oldValue = func(ctx context.Context) (*Role, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Role.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } - return } -// PermissionResourcesIDs returns the "permission_resources" edge IDs in the mutation. -func (m *ResourceMutation) PermissionResourcesIDs() (ids []int) { - for id := range m.permission_resources { - ids = append(ids, id) +// withRole sets the old Role of the mutation. +func withRole(node *Role) roleOption { + return func(m *RoleMutation) { + m.oldValue = func(context.Context) (*Role, error) { + return node, nil + } + m.id = &node.ID } - return } -// ResetPermissionResources resets all changes to the "permission_resources" edge. -func (m *ResourceMutation) ResetPermissionResources() { - m.permission_resources = nil - m.clearedpermission_resources = false - m.removedpermission_resources = nil +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m RoleMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// Where appends a list predicates to the ResourceMutation builder. -func (m *ResourceMutation) Where(ps ...predicate.Resource) { - m.predicates = append(m.predicates, ps...) +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m RoleMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil } -// WhereP appends storage-level predicates to the ResourceMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *ResourceMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Resource, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Role entities. +func (m *RoleMutation) SetID(id int64) { + m.id = &id } -// Op returns the operation name. -func (m *ResourceMutation) Op() Op { - return m.op +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *RoleMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true } -// SetOp allows setting the mutation operation. -func (m *ResourceMutation) SetOp(op Op) { - m.op = op +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *RoleMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Role.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } } -// Type returns the node type of this mutation (Resource). -func (m *ResourceMutation) Type() string { - return m.typ +// SetCreateTime sets the "create_time" field. +func (m *RoleMutation) SetCreateTime(t time.Time) { + m.create_time = &t } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *ResourceMutation) Fields() []string { - fields := make([]string, 0, 19) - if m.create_time != nil { - fields = append(fields, resource.FieldCreateTime) +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *RoleMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return } - if m.update_time != nil { - fields = append(fields, resource.FieldUpdateTime) + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") } - if m.name != nil { - fields = append(fields, resource.FieldName) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") } - if m.keyword != nil { - fields = append(fields, resource.FieldKeyword) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) } - if m.i18n_key != nil { - fields = append(fields, resource.FieldI18nKey) + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *RoleMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *RoleMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *RoleMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return } - if m._type != nil { - fields = append(fields, resource.FieldType) + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") } - if m.status != nil { - fields = append(fields, resource.FieldStatus) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") } - if m._path != nil { - fields = append(fields, resource.FieldPath) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) } - if m.operation != nil { - fields = append(fields, resource.FieldOperation) + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *RoleMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetKeyword sets the "keyword" field. +func (m *RoleMutation) SetKeyword(s string) { + m.keyword = &s +} + +// Keyword returns the value of the "keyword" field in the mutation. +func (m *RoleMutation) Keyword() (r string, exists bool) { + v := m.keyword + if v == nil { + return } - if m.method != nil { - fields = append(fields, resource.FieldMethod) + return *v, true +} + +// OldKeyword returns the old "keyword" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldKeyword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKeyword is only allowed on UpdateOne operations") } - if m.component != nil { - fields = append(fields, resource.FieldComponent) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKeyword requires an ID field in the mutation") } - if m.icon != nil { - fields = append(fields, resource.FieldIcon) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKeyword: %w", err) } - if m.sequence != nil { - fields = append(fields, resource.FieldSequence) + return oldValue.Keyword, nil +} + +// ResetKeyword resets all changes to the "keyword" field. +func (m *RoleMutation) ResetKeyword() { + m.keyword = nil +} + +// SetName sets the "name" field. +func (m *RoleMutation) SetName(s string) { + m.name = &s +} + +// Name returns the value of the "name" field in the mutation. +func (m *RoleMutation) Name() (r string, exists bool) { + v := m.name + if v == nil { + return } - if m.visible != nil { - fields = append(fields, resource.FieldVisible) + return *v, true +} + +// OldName returns the old "name" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldName is only allowed on UpdateOne operations") } - if m.level != nil { - fields = append(fields, resource.FieldLevel) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldName requires an ID field in the mutation") } - if m.tree_path != nil { - fields = append(fields, resource.FieldTreePath) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldName: %w", err) } - if m.properties != nil { - fields = append(fields, resource.FieldProperties) + return oldValue.Name, nil +} + +// ResetName resets all changes to the "name" field. +func (m *RoleMutation) ResetName() { + m.name = nil +} + +// SetDescription sets the "description" field. +func (m *RoleMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *RoleMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return } - if m.description != nil { - fields = append(fields, resource.FieldDescription) + return *v, true +} + +// OldDescription returns the old "description" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") } - if m.parent != nil { - fields = append(fields, resource.FieldParentID) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") } - return fields + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *ResourceMutation) Field(name string) (ent.Value, bool) { - switch name { - case resource.FieldCreateTime: - return m.CreateTime() - case resource.FieldUpdateTime: - return m.UpdateTime() - case resource.FieldName: - return m.Name() - case resource.FieldKeyword: - return m.Keyword() - case resource.FieldI18nKey: - return m.I18nKey() - case resource.FieldType: - return m.GetType() - case resource.FieldStatus: - return m.Status() - case resource.FieldPath: - return m.Path() - case resource.FieldOperation: - return m.Operation() - case resource.FieldMethod: - return m.Method() - case resource.FieldComponent: - return m.Component() - case resource.FieldIcon: - return m.Icon() - case resource.FieldSequence: - return m.Sequence() - case resource.FieldVisible: - return m.Visible() - case resource.FieldLevel: - return m.Level() - case resource.FieldTreePath: - return m.TreePath() - case resource.FieldProperties: - return m.Properties() - case resource.FieldDescription: - return m.Description() - case resource.FieldParentID: - return m.ParentID() - } - return nil, false +// ResetDescription resets all changes to the "description" field. +func (m *RoleMutation) ResetDescription() { + m.description = nil } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *ResourceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case resource.FieldCreateTime: - return m.OldCreateTime(ctx) - case resource.FieldUpdateTime: - return m.OldUpdateTime(ctx) - case resource.FieldName: - return m.OldName(ctx) - case resource.FieldKeyword: - return m.OldKeyword(ctx) - case resource.FieldI18nKey: - return m.OldI18nKey(ctx) - case resource.FieldType: - return m.OldType(ctx) - case resource.FieldStatus: - return m.OldStatus(ctx) - case resource.FieldPath: - return m.OldPath(ctx) - case resource.FieldOperation: - return m.OldOperation(ctx) - case resource.FieldMethod: - return m.OldMethod(ctx) - case resource.FieldComponent: - return m.OldComponent(ctx) - case resource.FieldIcon: - return m.OldIcon(ctx) - case resource.FieldSequence: - return m.OldSequence(ctx) - case resource.FieldVisible: - return m.OldVisible(ctx) - case resource.FieldLevel: - return m.OldLevel(ctx) - case resource.FieldTreePath: - return m.OldTreePath(ctx) - case resource.FieldProperties: - return m.OldProperties(ctx) - case resource.FieldDescription: - return m.OldDescription(ctx) - case resource.FieldParentID: - return m.OldParentID(ctx) +// SetType sets the "type" field. +func (m *RoleMutation) SetType(i int8) { + m._type = &i + m.add_type = nil +} + +// GetType returns the value of the "type" field in the mutation. +func (m *RoleMutation) GetType() (r int8, exists bool) { + v := m._type + if v == nil { + return } - return nil, fmt.Errorf("unknown Resource field %s", name) + return *v, true } -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *ResourceMutation) SetField(name string, value ent.Value) error { - switch name { - case resource.FieldCreateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreateTime(v) - return nil - case resource.FieldUpdateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdateTime(v) - return nil - case resource.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case resource.FieldKeyword: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKeyword(v) - return nil - case resource.FieldI18nKey: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetI18nKey(v) - return nil - case resource.FieldType: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case resource.FieldStatus: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetStatus(v) - return nil - case resource.FieldPath: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPath(v) - return nil - case resource.FieldOperation: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetOperation(v) - return nil - case resource.FieldMethod: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetMethod(v) - return nil - case resource.FieldComponent: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetComponent(v) - return nil - case resource.FieldIcon: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetIcon(v) - return nil - case resource.FieldSequence: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetSequence(v) - return nil - case resource.FieldVisible: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetVisible(v) - return nil - case resource.FieldLevel: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetLevel(v) - return nil - case resource.FieldTreePath: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetTreePath(v) - return nil - case resource.FieldProperties: - v, ok := value.(map[string]string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetProperties(v) - return nil - case resource.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case resource.FieldParentID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetParentID(v) - return nil - } - return fmt.Errorf("unknown Resource field %s", name) -} - -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *ResourceMutation) AddedFields() []string { - var fields []string - if m.addstatus != nil { - fields = append(fields, resource.FieldStatus) +// OldType returns the old "type" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldType(ctx context.Context) (v int8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") } - if m.addsequence != nil { - fields = append(fields, resource.FieldSequence) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") } - if m.addlevel != nil { - fields = append(fields, resource.FieldLevel) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) } - return fields + return oldValue.Type, nil } -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *ResourceMutation) AddedField(name string) (ent.Value, bool) { - switch name { - case resource.FieldStatus: - return m.AddedStatus() - case resource.FieldSequence: - return m.AddedSequence() - case resource.FieldLevel: - return m.AddedLevel() +// AddType adds i to the "type" field. +func (m *RoleMutation) AddType(i int8) { + if m.add_type != nil { + *m.add_type += i + } else { + m.add_type = &i } - return nil, false } -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *ResourceMutation) AddField(name string, value ent.Value) error { - switch name { - case resource.FieldStatus: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddStatus(v) - return nil - case resource.FieldSequence: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSequence(v) - return nil - case resource.FieldLevel: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddLevel(v) - return nil +// AddedType returns the value that was added to the "type" field in this mutation. +func (m *RoleMutation) AddedType() (r int8, exists bool) { + v := m.add_type + if v == nil { + return } - return fmt.Errorf("unknown Resource numeric field %s", name) + return *v, true } -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *ResourceMutation) ClearedFields() []string { - var fields []string - if m.FieldCleared(resource.FieldProperties) { - fields = append(fields, resource.FieldProperties) - } - if m.FieldCleared(resource.FieldParentID) { - fields = append(fields, resource.FieldParentID) +// ResetType resets all changes to the "type" field. +func (m *RoleMutation) ResetType() { + m._type = nil + m.add_type = nil +} + +// SetSequence sets the "sequence" field. +func (m *RoleMutation) SetSequence(i int) { + m.sequence = &i + m.addsequence = nil +} + +// Sequence returns the value of the "sequence" field in the mutation. +func (m *RoleMutation) Sequence() (r int, exists bool) { + v := m.sequence + if v == nil { + return } - return fields + return *v, true } -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *ResourceMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok +// OldSequence returns the old "sequence" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldSequence(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSequence is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSequence requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSequence: %w", err) + } + return oldValue.Sequence, nil } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *ResourceMutation) ClearField(name string) error { - switch name { - case resource.FieldProperties: - m.ClearProperties() - return nil - case resource.FieldParentID: - m.ClearParentID() - return nil +// AddSequence adds i to the "sequence" field. +func (m *RoleMutation) AddSequence(i int) { + if m.addsequence != nil { + *m.addsequence += i + } else { + m.addsequence = &i } - return fmt.Errorf("unknown Resource nullable field %s", name) } -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *ResourceMutation) ResetField(name string) error { - switch name { - case resource.FieldCreateTime: - m.ResetCreateTime() - return nil - case resource.FieldUpdateTime: - m.ResetUpdateTime() - return nil - case resource.FieldName: - m.ResetName() - return nil - case resource.FieldKeyword: - m.ResetKeyword() - return nil - case resource.FieldI18nKey: - m.ResetI18nKey() - return nil - case resource.FieldType: - m.ResetType() - return nil - case resource.FieldStatus: - m.ResetStatus() - return nil - case resource.FieldPath: - m.ResetPath() - return nil - case resource.FieldOperation: - m.ResetOperation() - return nil - case resource.FieldMethod: - m.ResetMethod() - return nil - case resource.FieldComponent: - m.ResetComponent() - return nil - case resource.FieldIcon: - m.ResetIcon() - return nil - case resource.FieldSequence: - m.ResetSequence() - return nil - case resource.FieldVisible: - m.ResetVisible() - return nil - case resource.FieldLevel: - m.ResetLevel() - return nil - case resource.FieldTreePath: - m.ResetTreePath() - return nil - case resource.FieldProperties: - m.ResetProperties() - return nil - case resource.FieldDescription: - m.ResetDescription() - return nil - case resource.FieldParentID: - m.ResetParentID() - return nil +// AddedSequence returns the value that was added to the "sequence" field in this mutation. +func (m *RoleMutation) AddedSequence() (r int, exists bool) { + v := m.addsequence + if v == nil { + return } - return fmt.Errorf("unknown Resource field %s", name) + return *v, true } -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *ResourceMutation) AddedEdges() []string { - edges := make([]string, 0, 4) - if m.children != nil { - edges = append(edges, resource.EdgeChildren) +// ResetSequence resets all changes to the "sequence" field. +func (m *RoleMutation) ResetSequence() { + m.sequence = nil + m.addsequence = nil +} + +// SetStatus sets the "status" field. +func (m *RoleMutation) SetStatus(i int8) { + m.status = &i + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *RoleMutation) Status() (r int8, exists bool) { + v := m.status + if v == nil { + return } - if m.parent != nil { - edges = append(edges, resource.EdgeParent) + return *v, true +} + +// OldStatus returns the old "status" field's value of the Role entity. +// If the Role object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RoleMutation) OldStatus(ctx context.Context) (v int8, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") } - if m.permissions != nil { - edges = append(edges, resource.EdgePermissions) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") } - if m.permission_resources != nil { - edges = append(edges, resource.EdgePermissionResources) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) } - return edges + return oldValue.Status, nil } -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *ResourceMutation) AddedIDs(name string) []ent.Value { - switch name { - case resource.EdgeChildren: - ids := make([]ent.Value, 0, len(m.children)) - for id := range m.children { - ids = append(ids, id) - } - return ids - case resource.EdgeParent: - if id := m.parent; id != nil { - return []ent.Value{*id} - } - case resource.EdgePermissions: - ids := make([]ent.Value, 0, len(m.permissions)) - for id := range m.permissions { - ids = append(ids, id) - } - return ids - case resource.EdgePermissionResources: - ids := make([]ent.Value, 0, len(m.permission_resources)) - for id := range m.permission_resources { - ids = append(ids, id) - } - return ids +// AddStatus adds i to the "status" field. +func (m *RoleMutation) AddStatus(i int8) { + if m.addstatus != nil { + *m.addstatus += i + } else { + m.addstatus = &i } - return nil } -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *ResourceMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - if m.removedchildren != nil { - edges = append(edges, resource.EdgeChildren) - } - if m.removedpermissions != nil { - edges = append(edges, resource.EdgePermissions) - } - if m.removedpermission_resources != nil { - edges = append(edges, resource.EdgePermissionResources) +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *RoleMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus + if v == nil { + return } - return edges + return *v, true } -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *ResourceMutation) RemovedIDs(name string) []ent.Value { - switch name { - case resource.EdgeChildren: - ids := make([]ent.Value, 0, len(m.removedchildren)) - for id := range m.removedchildren { - ids = append(ids, id) - } - return ids - case resource.EdgePermissions: - ids := make([]ent.Value, 0, len(m.removedpermissions)) - for id := range m.removedpermissions { - ids = append(ids, id) - } - return ids - case resource.EdgePermissionResources: - ids := make([]ent.Value, 0, len(m.removedpermission_resources)) - for id := range m.removedpermission_resources { - ids = append(ids, id) - } - return ids - } - return nil +// ResetStatus resets all changes to the "status" field. +func (m *RoleMutation) ResetStatus() { + m.status = nil + m.addstatus = nil } -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *ResourceMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) - if m.clearedchildren { - edges = append(edges, resource.EdgeChildren) +// AddUserIDs adds the "users" edge to the User entity by ids. +func (m *RoleMutation) AddUserIDs(ids ...int64) { + if m.users == nil { + m.users = make(map[int64]struct{}) } - if m.clearedparent { - edges = append(edges, resource.EdgeParent) + for i := range ids { + m.users[ids[i]] = struct{}{} } - if m.clearedpermissions { - edges = append(edges, resource.EdgePermissions) +} + +// ClearUsers clears the "users" edge to the User entity. +func (m *RoleMutation) ClearUsers() { + m.clearedusers = true +} + +// UsersCleared reports if the "users" edge to the User entity was cleared. +func (m *RoleMutation) UsersCleared() bool { + return m.clearedusers +} + +// RemoveUserIDs removes the "users" edge to the User entity by IDs. +func (m *RoleMutation) RemoveUserIDs(ids ...int64) { + if m.removedusers == nil { + m.removedusers = make(map[int64]struct{}) } - if m.clearedpermission_resources { - edges = append(edges, resource.EdgePermissionResources) + for i := range ids { + delete(m.users, ids[i]) + m.removedusers[ids[i]] = struct{}{} } - return edges } -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *ResourceMutation) EdgeCleared(name string) bool { - switch name { - case resource.EdgeChildren: - return m.clearedchildren - case resource.EdgeParent: - return m.clearedparent - case resource.EdgePermissions: - return m.clearedpermissions - case resource.EdgePermissionResources: - return m.clearedpermission_resources +// RemovedUsers returns the removed IDs of the "users" edge to the User entity. +func (m *RoleMutation) RemovedUsersIDs() (ids []int64) { + for id := range m.removedusers { + ids = append(ids, id) } - return false + return } -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *ResourceMutation) ClearEdge(name string) error { - switch name { - case resource.EdgeParent: - m.ClearParent() - return nil +// UsersIDs returns the "users" edge IDs in the mutation. +func (m *RoleMutation) UsersIDs() (ids []int64) { + for id := range m.users { + ids = append(ids, id) } - return fmt.Errorf("unknown Resource unique edge %s", name) + return } -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *ResourceMutation) ResetEdge(name string) error { - switch name { - case resource.EdgeChildren: - m.ResetChildren() - return nil - case resource.EdgeParent: - m.ResetParent() - return nil - case resource.EdgePermissions: - m.ResetPermissions() - return nil - case resource.EdgePermissionResources: - m.ResetPermissionResources() - return nil +// ResetUsers resets all changes to the "users" edge. +func (m *RoleMutation) ResetUsers() { + m.users = nil + m.clearedusers = false + m.removedusers = nil +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by ids. +func (m *RoleMutation) AddPermissionIDs(ids ...int64) { + if m.permissions == nil { + m.permissions = make(map[int64]struct{}) + } + for i := range ids { + m.permissions[ids[i]] = struct{}{} } - return fmt.Errorf("unknown Resource edge %s", name) } -// RoleMutation represents an operation that mutates the Role nodes in the graph. -type RoleMutation struct { - config - op Op - typ string - id *int64 - create_time *time.Time - update_time *time.Time - keyword *string - name *string - description *string - _type *int8 - add_type *int8 - sequence *int - addsequence *int - status *int8 - addstatus *int8 - clearedFields map[string]struct{} - users map[int64]struct{} - removedusers map[int64]struct{} - clearedusers bool - permissions map[int64]struct{} - removedpermissions map[int64]struct{} - clearedpermissions bool - user_roles map[int]struct{} - removeduser_roles map[int]struct{} - cleareduser_roles bool - role_permissions map[int]struct{} - removedrole_permissions map[int]struct{} - clearedrole_permissions bool - done bool - oldValue func(context.Context) (*Role, error) - predicates []predicate.Role +// ClearPermissions clears the "permissions" edge to the Permission entity. +func (m *RoleMutation) ClearPermissions() { + m.clearedpermissions = true } -var _ ent.Mutation = (*RoleMutation)(nil) - -// roleOption allows management of the mutation configuration using functional options. -type roleOption func(*RoleMutation) +// PermissionsCleared reports if the "permissions" edge to the Permission entity was cleared. +func (m *RoleMutation) PermissionsCleared() bool { + return m.clearedpermissions +} -// newRoleMutation creates new mutation for the Role entity. -func newRoleMutation(c config, op Op, opts ...roleOption) *RoleMutation { - m := &RoleMutation{ - config: c, - op: op, - typ: TypeRole, - clearedFields: make(map[string]struct{}), +// RemovePermissionIDs removes the "permissions" edge to the Permission entity by IDs. +func (m *RoleMutation) RemovePermissionIDs(ids ...int64) { + if m.removedpermissions == nil { + m.removedpermissions = make(map[int64]struct{}) } - for _, opt := range opts { - opt(m) + for i := range ids { + delete(m.permissions, ids[i]) + m.removedpermissions[ids[i]] = struct{}{} } - return m } -// withRoleID sets the ID field of the mutation. -func withRoleID(id int64) roleOption { - return func(m *RoleMutation) { - var ( - err error - once sync.Once - value *Role - ) - m.oldValue = func(ctx context.Context) (*Role, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().Role.Get(ctx, id) - } - }) - return value, err - } - m.id = &id +// RemovedPermissions returns the removed IDs of the "permissions" edge to the Permission entity. +func (m *RoleMutation) RemovedPermissionsIDs() (ids []int64) { + for id := range m.removedpermissions { + ids = append(ids, id) } + return } -// withRole sets the old Role of the mutation. -func withRole(node *Role) roleOption { - return func(m *RoleMutation) { - m.oldValue = func(context.Context) (*Role, error) { - return node, nil - } - m.id = &node.ID +// PermissionsIDs returns the "permissions" edge IDs in the mutation. +func (m *RoleMutation) PermissionsIDs() (ids []int64) { + for id := range m.permissions { + ids = append(ids, id) } + return } -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m RoleMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client +// ResetPermissions resets all changes to the "permissions" edge. +func (m *RoleMutation) ResetPermissions() { + m.permissions = nil + m.clearedpermissions = false + m.removedpermissions = nil } -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m RoleMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") +// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by ids. +func (m *RoleMutation) AddUserRoleIDs(ids ...int) { + if m.user_roles == nil { + m.user_roles = make(map[int]struct{}) + } + for i := range ids { + m.user_roles[ids[i]] = struct{}{} } - tx := &Tx{config: m.config} - tx.init() - return tx, nil } -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of Role entities. -func (m *RoleMutation) SetID(id int64) { - m.id = &id +// ClearUserRoles clears the "user_roles" edge to the UserRole entity. +func (m *RoleMutation) ClearUserRoles() { + m.cleareduser_roles = true } -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *RoleMutation) ID() (id int64, exists bool) { - if m.id == nil { - return - } - return *m.id, true +// UserRolesCleared reports if the "user_roles" edge to the UserRole entity was cleared. +func (m *RoleMutation) UserRolesCleared() bool { + return m.cleareduser_roles } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *RoleMutation) IDs(ctx context.Context) ([]int64, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int64{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().Role.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) +// RemoveUserRoleIDs removes the "user_roles" edge to the UserRole entity by IDs. +func (m *RoleMutation) RemoveUserRoleIDs(ids ...int) { + if m.removeduser_roles == nil { + m.removeduser_roles = make(map[int]struct{}) + } + for i := range ids { + delete(m.user_roles, ids[i]) + m.removeduser_roles[ids[i]] = struct{}{} } } -// SetCreateTime sets the "create_time" field. -func (m *RoleMutation) SetCreateTime(t time.Time) { - m.create_time = &t +// RemovedUserRoles returns the removed IDs of the "user_roles" edge to the UserRole entity. +func (m *RoleMutation) RemovedUserRolesIDs() (ids []int) { + for id := range m.removeduser_roles { + ids = append(ids, id) + } + return } -// CreateTime returns the value of the "create_time" field in the mutation. -func (m *RoleMutation) CreateTime() (r time.Time, exists bool) { - v := m.create_time - if v == nil { - return +// UserRolesIDs returns the "user_roles" edge IDs in the mutation. +func (m *RoleMutation) UserRolesIDs() (ids []int) { + for id := range m.user_roles { + ids = append(ids, id) } - return *v, true + return } -// OldCreateTime returns the old "create_time" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreateTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) - } - return oldValue.CreateTime, nil +// ResetUserRoles resets all changes to the "user_roles" edge. +func (m *RoleMutation) ResetUserRoles() { + m.user_roles = nil + m.cleareduser_roles = false + m.removeduser_roles = nil } -// ResetCreateTime resets all changes to the "create_time" field. -func (m *RoleMutation) ResetCreateTime() { - m.create_time = nil +// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by ids. +func (m *RoleMutation) AddRolePermissionIDs(ids ...int) { + if m.role_permissions == nil { + m.role_permissions = make(map[int]struct{}) + } + for i := range ids { + m.role_permissions[ids[i]] = struct{}{} + } } -// SetUpdateTime sets the "update_time" field. -func (m *RoleMutation) SetUpdateTime(t time.Time) { - m.update_time = &t +// ClearRolePermissions clears the "role_permissions" edge to the RolePermission entity. +func (m *RoleMutation) ClearRolePermissions() { + m.clearedrole_permissions = true } -// UpdateTime returns the value of the "update_time" field in the mutation. -func (m *RoleMutation) UpdateTime() (r time.Time, exists bool) { - v := m.update_time - if v == nil { - return - } - return *v, true +// RolePermissionsCleared reports if the "role_permissions" edge to the RolePermission entity was cleared. +func (m *RoleMutation) RolePermissionsCleared() bool { + return m.clearedrole_permissions } -// OldUpdateTime returns the old "update_time" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateTime requires an ID field in the mutation") +// RemoveRolePermissionIDs removes the "role_permissions" edge to the RolePermission entity by IDs. +func (m *RoleMutation) RemoveRolePermissionIDs(ids ...int) { + if m.removedrole_permissions == nil { + m.removedrole_permissions = make(map[int]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + for i := range ids { + delete(m.role_permissions, ids[i]) + m.removedrole_permissions[ids[i]] = struct{}{} } - return oldValue.UpdateTime, nil } -// ResetUpdateTime resets all changes to the "update_time" field. -func (m *RoleMutation) ResetUpdateTime() { - m.update_time = nil +// RemovedRolePermissions returns the removed IDs of the "role_permissions" edge to the RolePermission entity. +func (m *RoleMutation) RemovedRolePermissionsIDs() (ids []int) { + for id := range m.removedrole_permissions { + ids = append(ids, id) + } + return } -// SetKeyword sets the "keyword" field. -func (m *RoleMutation) SetKeyword(s string) { - m.keyword = &s -} - -// Keyword returns the value of the "keyword" field in the mutation. -func (m *RoleMutation) Keyword() (r string, exists bool) { - v := m.keyword - if v == nil { - return - } - return *v, true -} - -// OldKeyword returns the old "keyword" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldKeyword(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKeyword is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKeyword requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldKeyword: %w", err) +// RolePermissionsIDs returns the "role_permissions" edge IDs in the mutation. +func (m *RoleMutation) RolePermissionsIDs() (ids []int) { + for id := range m.role_permissions { + ids = append(ids, id) } - return oldValue.Keyword, nil -} - -// ResetKeyword resets all changes to the "keyword" field. -func (m *RoleMutation) ResetKeyword() { - m.keyword = nil + return } -// SetName sets the "name" field. -func (m *RoleMutation) SetName(s string) { - m.name = &s +// ResetRolePermissions resets all changes to the "role_permissions" edge. +func (m *RoleMutation) ResetRolePermissions() { + m.role_permissions = nil + m.clearedrole_permissions = false + m.removedrole_permissions = nil } -// Name returns the value of the "name" field in the mutation. -func (m *RoleMutation) Name() (r string, exists bool) { - v := m.name - if v == nil { - return - } - return *v, true +// Where appends a list predicates to the RoleMutation builder. +func (m *RoleMutation) Where(ps ...predicate.Role) { + m.predicates = append(m.predicates, ps...) } -// OldName returns the old "name" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) +// WhereP appends storage-level predicates to the RoleMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *RoleMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Role, len(ps)) + for i := range ps { + p[i] = ps[i] } - return oldValue.Name, nil + m.Where(p...) } -// ResetName resets all changes to the "name" field. -func (m *RoleMutation) ResetName() { - m.name = nil +// Op returns the operation name. +func (m *RoleMutation) Op() Op { + return m.op } -// SetDescription sets the "description" field. -func (m *RoleMutation) SetDescription(s string) { - m.description = &s +// SetOp allows setting the mutation operation. +func (m *RoleMutation) SetOp(op Op) { + m.op = op } -// Description returns the value of the "description" field in the mutation. -func (m *RoleMutation) Description() (r string, exists bool) { - v := m.description - if v == nil { - return - } - return *v, true +// Type returns the node type of this mutation (Role). +func (m *RoleMutation) Type() string { + return m.typ } -// OldDescription returns the old "description" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldDescription(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDescription is only allowed on UpdateOne operations") +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *RoleMutation) Fields() []string { + fields := make([]string, 0, 8) + if m.create_time != nil { + fields = append(fields, role.FieldCreateTime) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDescription requires an ID field in the mutation") + if m.update_time != nil { + fields = append(fields, role.FieldUpdateTime) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldDescription: %w", err) + if m.keyword != nil { + fields = append(fields, role.FieldKeyword) } - return oldValue.Description, nil -} - -// ResetDescription resets all changes to the "description" field. -func (m *RoleMutation) ResetDescription() { - m.description = nil -} - -// SetType sets the "type" field. -func (m *RoleMutation) SetType(i int8) { - m._type = &i - m.add_type = nil -} - -// GetType returns the value of the "type" field in the mutation. -func (m *RoleMutation) GetType() (r int8, exists bool) { - v := m._type - if v == nil { - return + if m.name != nil { + fields = append(fields, role.FieldName) } - return *v, true -} - -// OldType returns the old "type" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldType(ctx context.Context) (v int8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldType is only allowed on UpdateOne operations") + if m.description != nil { + fields = append(fields, role.FieldDescription) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldType requires an ID field in the mutation") + if m._type != nil { + fields = append(fields, role.FieldType) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldType: %w", err) + if m.sequence != nil { + fields = append(fields, role.FieldSequence) } - return oldValue.Type, nil -} - -// AddType adds i to the "type" field. -func (m *RoleMutation) AddType(i int8) { - if m.add_type != nil { - *m.add_type += i - } else { - m.add_type = &i + if m.status != nil { + fields = append(fields, role.FieldStatus) } + return fields } -// AddedType returns the value that was added to the "type" field in this mutation. -func (m *RoleMutation) AddedType() (r int8, exists bool) { - v := m.add_type - if v == nil { - return +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *RoleMutation) Field(name string) (ent.Value, bool) { + switch name { + case role.FieldCreateTime: + return m.CreateTime() + case role.FieldUpdateTime: + return m.UpdateTime() + case role.FieldKeyword: + return m.Keyword() + case role.FieldName: + return m.Name() + case role.FieldDescription: + return m.Description() + case role.FieldType: + return m.GetType() + case role.FieldSequence: + return m.Sequence() + case role.FieldStatus: + return m.Status() } - return *v, true -} - -// ResetType resets all changes to the "type" field. -func (m *RoleMutation) ResetType() { - m._type = nil - m.add_type = nil -} - -// SetSequence sets the "sequence" field. -func (m *RoleMutation) SetSequence(i int) { - m.sequence = &i - m.addsequence = nil + return nil, false } -// Sequence returns the value of the "sequence" field in the mutation. -func (m *RoleMutation) Sequence() (r int, exists bool) { - v := m.sequence - if v == nil { - return +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *RoleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case role.FieldCreateTime: + return m.OldCreateTime(ctx) + case role.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case role.FieldKeyword: + return m.OldKeyword(ctx) + case role.FieldName: + return m.OldName(ctx) + case role.FieldDescription: + return m.OldDescription(ctx) + case role.FieldType: + return m.OldType(ctx) + case role.FieldSequence: + return m.OldSequence(ctx) + case role.FieldStatus: + return m.OldStatus(ctx) } - return *v, true + return nil, fmt.Errorf("unknown Role field %s", name) } -// OldSequence returns the old "sequence" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldSequence(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSequence is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSequence requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSequence: %w", err) - } - return oldValue.Sequence, nil +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *RoleMutation) SetField(name string, value ent.Value) error { + switch name { + case role.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case role.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case role.FieldKeyword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKeyword(v) + return nil + case role.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case role.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case role.FieldType: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case role.FieldSequence: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSequence(v) + return nil + case role.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + } + return fmt.Errorf("unknown Role field %s", name) } -// AddSequence adds i to the "sequence" field. -func (m *RoleMutation) AddSequence(i int) { +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *RoleMutation) AddedFields() []string { + var fields []string + if m.add_type != nil { + fields = append(fields, role.FieldType) + } if m.addsequence != nil { - *m.addsequence += i - } else { - m.addsequence = &i + fields = append(fields, role.FieldSequence) + } + if m.addstatus != nil { + fields = append(fields, role.FieldStatus) } + return fields } -// AddedSequence returns the value that was added to the "sequence" field in this mutation. -func (m *RoleMutation) AddedSequence() (r int, exists bool) { - v := m.addsequence - if v == nil { - return +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *RoleMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case role.FieldType: + return m.AddedType() + case role.FieldSequence: + return m.AddedSequence() + case role.FieldStatus: + return m.AddedStatus() } - return *v, true + return nil, false } -// ResetSequence resets all changes to the "sequence" field. -func (m *RoleMutation) ResetSequence() { - m.sequence = nil - m.addsequence = nil +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *RoleMutation) AddField(name string, value ent.Value) error { + switch name { + case role.FieldType: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddType(v) + return nil + case role.FieldSequence: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSequence(v) + return nil + case role.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + } + return fmt.Errorf("unknown Role numeric field %s", name) } -// SetStatus sets the "status" field. -func (m *RoleMutation) SetStatus(i int8) { - m.status = &i - m.addstatus = nil +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *RoleMutation) ClearedFields() []string { + return nil } -// Status returns the value of the "status" field in the mutation. -func (m *RoleMutation) Status() (r int8, exists bool) { - v := m.status - if v == nil { - return - } - return *v, true +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *RoleMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok } -// OldStatus returns the old "status" field's value of the Role entity. -// If the Role object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldStatus(ctx context.Context) (v int8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) - } - return oldValue.Status, nil +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *RoleMutation) ClearField(name string) error { + return fmt.Errorf("unknown Role nullable field %s", name) } -// AddStatus adds i to the "status" field. -func (m *RoleMutation) AddStatus(i int8) { - if m.addstatus != nil { - *m.addstatus += i - } else { - m.addstatus = &i +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *RoleMutation) ResetField(name string) error { + switch name { + case role.FieldCreateTime: + m.ResetCreateTime() + return nil + case role.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case role.FieldKeyword: + m.ResetKeyword() + return nil + case role.FieldName: + m.ResetName() + return nil + case role.FieldDescription: + m.ResetDescription() + return nil + case role.FieldType: + m.ResetType() + return nil + case role.FieldSequence: + m.ResetSequence() + return nil + case role.FieldStatus: + m.ResetStatus() + return nil } + return fmt.Errorf("unknown Role field %s", name) } -// AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *RoleMutation) AddedStatus() (r int8, exists bool) { - v := m.addstatus - if v == nil { - return +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *RoleMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.users != nil { + edges = append(edges, role.EdgeUsers) } - return *v, true -} - -// ResetStatus resets all changes to the "status" field. -func (m *RoleMutation) ResetStatus() { - m.status = nil - m.addstatus = nil -} - -// AddUserIDs adds the "users" edge to the User entity by ids. -func (m *RoleMutation) AddUserIDs(ids ...int64) { - if m.users == nil { - m.users = make(map[int64]struct{}) + if m.permissions != nil { + edges = append(edges, role.EdgePermissions) } - for i := range ids { - m.users[ids[i]] = struct{}{} + if m.user_roles != nil { + edges = append(edges, role.EdgeUserRoles) } + if m.role_permissions != nil { + edges = append(edges, role.EdgeRolePermissions) + } + return edges } -// ClearUsers clears the "users" edge to the User entity. -func (m *RoleMutation) ClearUsers() { - m.clearedusers = true -} - -// UsersCleared reports if the "users" edge to the User entity was cleared. -func (m *RoleMutation) UsersCleared() bool { - return m.clearedusers -} - -// RemoveUserIDs removes the "users" edge to the User entity by IDs. -func (m *RoleMutation) RemoveUserIDs(ids ...int64) { - if m.removedusers == nil { - m.removedusers = make(map[int64]struct{}) - } - for i := range ids { - delete(m.users, ids[i]) - m.removedusers[ids[i]] = struct{}{} +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *RoleMutation) AddedIDs(name string) []ent.Value { + switch name { + case role.EdgeUsers: + ids := make([]ent.Value, 0, len(m.users)) + for id := range m.users { + ids = append(ids, id) + } + return ids + case role.EdgePermissions: + ids := make([]ent.Value, 0, len(m.permissions)) + for id := range m.permissions { + ids = append(ids, id) + } + return ids + case role.EdgeUserRoles: + ids := make([]ent.Value, 0, len(m.user_roles)) + for id := range m.user_roles { + ids = append(ids, id) + } + return ids + case role.EdgeRolePermissions: + ids := make([]ent.Value, 0, len(m.role_permissions)) + for id := range m.role_permissions { + ids = append(ids, id) + } + return ids } + return nil } -// RemovedUsers returns the removed IDs of the "users" edge to the User entity. -func (m *RoleMutation) RemovedUsersIDs() (ids []int64) { - for id := range m.removedusers { - ids = append(ids, id) +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *RoleMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedusers != nil { + edges = append(edges, role.EdgeUsers) } - return -} - -// UsersIDs returns the "users" edge IDs in the mutation. -func (m *RoleMutation) UsersIDs() (ids []int64) { - for id := range m.users { - ids = append(ids, id) + if m.removedpermissions != nil { + edges = append(edges, role.EdgePermissions) } - return -} - -// ResetUsers resets all changes to the "users" edge. -func (m *RoleMutation) ResetUsers() { - m.users = nil - m.clearedusers = false - m.removedusers = nil -} - -// AddPermissionIDs adds the "permissions" edge to the Permission entity by ids. -func (m *RoleMutation) AddPermissionIDs(ids ...int64) { - if m.permissions == nil { - m.permissions = make(map[int64]struct{}) + if m.removeduser_roles != nil { + edges = append(edges, role.EdgeUserRoles) } - for i := range ids { - m.permissions[ids[i]] = struct{}{} + if m.removedrole_permissions != nil { + edges = append(edges, role.EdgeRolePermissions) } + return edges } -// ClearPermissions clears the "permissions" edge to the Permission entity. -func (m *RoleMutation) ClearPermissions() { - m.clearedpermissions = true -} - -// PermissionsCleared reports if the "permissions" edge to the Permission entity was cleared. -func (m *RoleMutation) PermissionsCleared() bool { - return m.clearedpermissions +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *RoleMutation) RemovedIDs(name string) []ent.Value { + switch name { + case role.EdgeUsers: + ids := make([]ent.Value, 0, len(m.removedusers)) + for id := range m.removedusers { + ids = append(ids, id) + } + return ids + case role.EdgePermissions: + ids := make([]ent.Value, 0, len(m.removedpermissions)) + for id := range m.removedpermissions { + ids = append(ids, id) + } + return ids + case role.EdgeUserRoles: + ids := make([]ent.Value, 0, len(m.removeduser_roles)) + for id := range m.removeduser_roles { + ids = append(ids, id) + } + return ids + case role.EdgeRolePermissions: + ids := make([]ent.Value, 0, len(m.removedrole_permissions)) + for id := range m.removedrole_permissions { + ids = append(ids, id) + } + return ids + } + return nil } -// RemovePermissionIDs removes the "permissions" edge to the Permission entity by IDs. -func (m *RoleMutation) RemovePermissionIDs(ids ...int64) { - if m.removedpermissions == nil { - m.removedpermissions = make(map[int64]struct{}) +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *RoleMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedusers { + edges = append(edges, role.EdgeUsers) } - for i := range ids { - delete(m.permissions, ids[i]) - m.removedpermissions[ids[i]] = struct{}{} + if m.clearedpermissions { + edges = append(edges, role.EdgePermissions) } -} - -// RemovedPermissions returns the removed IDs of the "permissions" edge to the Permission entity. -func (m *RoleMutation) RemovedPermissionsIDs() (ids []int64) { - for id := range m.removedpermissions { - ids = append(ids, id) + if m.cleareduser_roles { + edges = append(edges, role.EdgeUserRoles) } - return + if m.clearedrole_permissions { + edges = append(edges, role.EdgeRolePermissions) + } + return edges } -// PermissionsIDs returns the "permissions" edge IDs in the mutation. -func (m *RoleMutation) PermissionsIDs() (ids []int64) { - for id := range m.permissions { - ids = append(ids, id) +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *RoleMutation) EdgeCleared(name string) bool { + switch name { + case role.EdgeUsers: + return m.clearedusers + case role.EdgePermissions: + return m.clearedpermissions + case role.EdgeUserRoles: + return m.cleareduser_roles + case role.EdgeRolePermissions: + return m.clearedrole_permissions } - return + return false } -// ResetPermissions resets all changes to the "permissions" edge. -func (m *RoleMutation) ResetPermissions() { - m.permissions = nil - m.clearedpermissions = false - m.removedpermissions = nil +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *RoleMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown Role unique edge %s", name) } -// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by ids. -func (m *RoleMutation) AddUserRoleIDs(ids ...int) { - if m.user_roles == nil { - m.user_roles = make(map[int]struct{}) - } - for i := range ids { - m.user_roles[ids[i]] = struct{}{} +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *RoleMutation) ResetEdge(name string) error { + switch name { + case role.EdgeUsers: + m.ResetUsers() + return nil + case role.EdgePermissions: + m.ResetPermissions() + return nil + case role.EdgeUserRoles: + m.ResetUserRoles() + return nil + case role.EdgeRolePermissions: + m.ResetRolePermissions() + return nil } + return fmt.Errorf("unknown Role edge %s", name) } -// ClearUserRoles clears the "user_roles" edge to the UserRole entity. -func (m *RoleMutation) ClearUserRoles() { - m.cleareduser_roles = true +// RolePermissionMutation represents an operation that mutates the RolePermission nodes in the graph. +type RolePermissionMutation struct { + config + op Op + typ string + id *int + clearedFields map[string]struct{} + role *int64 + clearedrole bool + permission *int64 + clearedpermission bool + done bool + oldValue func(context.Context) (*RolePermission, error) + predicates []predicate.RolePermission } -// UserRolesCleared reports if the "user_roles" edge to the UserRole entity was cleared. -func (m *RoleMutation) UserRolesCleared() bool { - return m.cleareduser_roles -} +var _ ent.Mutation = (*RolePermissionMutation)(nil) -// RemoveUserRoleIDs removes the "user_roles" edge to the UserRole entity by IDs. -func (m *RoleMutation) RemoveUserRoleIDs(ids ...int) { - if m.removeduser_roles == nil { - m.removeduser_roles = make(map[int]struct{}) +// rolepermissionOption allows management of the mutation configuration using functional options. +type rolepermissionOption func(*RolePermissionMutation) + +// newRolePermissionMutation creates new mutation for the RolePermission entity. +func newRolePermissionMutation(c config, op Op, opts ...rolepermissionOption) *RolePermissionMutation { + m := &RolePermissionMutation{ + config: c, + op: op, + typ: TypeRolePermission, + clearedFields: make(map[string]struct{}), } - for i := range ids { - delete(m.user_roles, ids[i]) - m.removeduser_roles[ids[i]] = struct{}{} + for _, opt := range opts { + opt(m) } + return m } -// RemovedUserRoles returns the removed IDs of the "user_roles" edge to the UserRole entity. -func (m *RoleMutation) RemovedUserRolesIDs() (ids []int) { - for id := range m.removeduser_roles { - ids = append(ids, id) +// withRolePermissionID sets the ID field of the mutation. +func withRolePermissionID(id int) rolepermissionOption { + return func(m *RolePermissionMutation) { + var ( + err error + once sync.Once + value *RolePermission + ) + m.oldValue = func(ctx context.Context) (*RolePermission, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().RolePermission.Get(ctx, id) + } + }) + return value, err + } + m.id = &id } - return } -// UserRolesIDs returns the "user_roles" edge IDs in the mutation. -func (m *RoleMutation) UserRolesIDs() (ids []int) { - for id := range m.user_roles { - ids = append(ids, id) +// withRolePermission sets the old RolePermission of the mutation. +func withRolePermission(node *RolePermission) rolepermissionOption { + return func(m *RolePermissionMutation) { + m.oldValue = func(context.Context) (*RolePermission, error) { + return node, nil + } + m.id = &node.ID } - return } -// ResetUserRoles resets all changes to the "user_roles" edge. -func (m *RoleMutation) ResetUserRoles() { - m.user_roles = nil - m.cleareduser_roles = false - m.removeduser_roles = nil +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m RolePermissionMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client } -// AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by ids. -func (m *RoleMutation) AddRolePermissionIDs(ids ...int) { - if m.role_permissions == nil { - m.role_permissions = make(map[int]struct{}) +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m RolePermissionMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") } - for i := range ids { - m.role_permissions[ids[i]] = struct{}{} + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *RolePermissionMutation) ID() (id int, exists bool) { + if m.id == nil { + return } + return *m.id, true } -// ClearRolePermissions clears the "role_permissions" edge to the RolePermission entity. -func (m *RoleMutation) ClearRolePermissions() { - m.clearedrole_permissions = true +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *RolePermissionMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().RolePermission.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } } -// RolePermissionsCleared reports if the "role_permissions" edge to the RolePermission entity was cleared. -func (m *RoleMutation) RolePermissionsCleared() bool { - return m.clearedrole_permissions +// SetRoleID sets the "role_id" field. +func (m *RolePermissionMutation) SetRoleID(i int64) { + m.role = &i } -// RemoveRolePermissionIDs removes the "role_permissions" edge to the RolePermission entity by IDs. -func (m *RoleMutation) RemoveRolePermissionIDs(ids ...int) { - if m.removedrole_permissions == nil { - m.removedrole_permissions = make(map[int]struct{}) +// RoleID returns the value of the "role_id" field in the mutation. +func (m *RolePermissionMutation) RoleID() (r int64, exists bool) { + v := m.role + if v == nil { + return } - for i := range ids { - delete(m.role_permissions, ids[i]) - m.removedrole_permissions[ids[i]] = struct{}{} + return *v, true +} + +// OldRoleID returns the old "role_id" field's value of the RolePermission entity. +// If the RolePermission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RolePermissionMutation) OldRoleID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRoleID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRoleID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRoleID: %w", err) + } + return oldValue.RoleID, nil +} + +// ResetRoleID resets all changes to the "role_id" field. +func (m *RolePermissionMutation) ResetRoleID() { + m.role = nil +} + +// SetPermissionID sets the "permission_id" field. +func (m *RolePermissionMutation) SetPermissionID(i int64) { + m.permission = &i +} + +// PermissionID returns the value of the "permission_id" field in the mutation. +func (m *RolePermissionMutation) PermissionID() (r int64, exists bool) { + v := m.permission + if v == nil { + return } + return *v, true } -// RemovedRolePermissions returns the removed IDs of the "role_permissions" edge to the RolePermission entity. -func (m *RoleMutation) RemovedRolePermissionsIDs() (ids []int) { - for id := range m.removedrole_permissions { - ids = append(ids, id) +// OldPermissionID returns the old "permission_id" field's value of the RolePermission entity. +// If the RolePermission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *RolePermissionMutation) OldPermissionID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPermissionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPermissionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPermissionID: %w", err) + } + return oldValue.PermissionID, nil +} + +// ResetPermissionID resets all changes to the "permission_id" field. +func (m *RolePermissionMutation) ResetPermissionID() { + m.permission = nil +} + +// ClearRole clears the "role" edge to the Role entity. +func (m *RolePermissionMutation) ClearRole() { + m.clearedrole = true + m.clearedFields[rolepermission.FieldRoleID] = struct{}{} +} + +// RoleCleared reports if the "role" edge to the Role entity was cleared. +func (m *RolePermissionMutation) RoleCleared() bool { + return m.clearedrole +} + +// RoleIDs returns the "role" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// RoleID instead. It exists only for internal usage by the builders. +func (m *RolePermissionMutation) RoleIDs() (ids []int64) { + if id := m.role; id != nil { + ids = append(ids, *id) } return } -// RolePermissionsIDs returns the "role_permissions" edge IDs in the mutation. -func (m *RoleMutation) RolePermissionsIDs() (ids []int) { - for id := range m.role_permissions { - ids = append(ids, id) +// ResetRole resets all changes to the "role" edge. +func (m *RolePermissionMutation) ResetRole() { + m.role = nil + m.clearedrole = false +} + +// ClearPermission clears the "permission" edge to the Permission entity. +func (m *RolePermissionMutation) ClearPermission() { + m.clearedpermission = true + m.clearedFields[rolepermission.FieldPermissionID] = struct{}{} +} + +// PermissionCleared reports if the "permission" edge to the Permission entity was cleared. +func (m *RolePermissionMutation) PermissionCleared() bool { + return m.clearedpermission +} + +// PermissionIDs returns the "permission" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PermissionID instead. It exists only for internal usage by the builders. +func (m *RolePermissionMutation) PermissionIDs() (ids []int64) { + if id := m.permission; id != nil { + ids = append(ids, *id) } return } -// ResetRolePermissions resets all changes to the "role_permissions" edge. -func (m *RoleMutation) ResetRolePermissions() { - m.role_permissions = nil - m.clearedrole_permissions = false - m.removedrole_permissions = nil +// ResetPermission resets all changes to the "permission" edge. +func (m *RolePermissionMutation) ResetPermission() { + m.permission = nil + m.clearedpermission = false } -// Where appends a list predicates to the RoleMutation builder. -func (m *RoleMutation) Where(ps ...predicate.Role) { +// Where appends a list predicates to the RolePermissionMutation builder. +func (m *RolePermissionMutation) Where(ps ...predicate.RolePermission) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the RoleMutation builder. Using this method, +// WhereP appends storage-level predicates to the RolePermissionMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *RoleMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.Role, len(ps)) +func (m *RolePermissionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.RolePermission, len(ps)) for i := range ps { p[i] = ps[i] } @@ -8591,48 +8777,30 @@ func (m *RoleMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *RoleMutation) Op() Op { +func (m *RolePermissionMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *RoleMutation) SetOp(op Op) { +func (m *RolePermissionMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (Role). -func (m *RoleMutation) Type() string { +// Type returns the node type of this mutation (RolePermission). +func (m *RolePermissionMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *RoleMutation) Fields() []string { - fields := make([]string, 0, 8) - if m.create_time != nil { - fields = append(fields, role.FieldCreateTime) - } - if m.update_time != nil { - fields = append(fields, role.FieldUpdateTime) - } - if m.keyword != nil { - fields = append(fields, role.FieldKeyword) - } - if m.name != nil { - fields = append(fields, role.FieldName) - } - if m.description != nil { - fields = append(fields, role.FieldDescription) - } - if m._type != nil { - fields = append(fields, role.FieldType) - } - if m.sequence != nil { - fields = append(fields, role.FieldSequence) +func (m *RolePermissionMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.role != nil { + fields = append(fields, rolepermission.FieldRoleID) } - if m.status != nil { - fields = append(fields, role.FieldStatus) + if m.permission != nil { + fields = append(fields, rolepermission.FieldPermissionID) } return fields } @@ -8640,24 +8808,12 @@ func (m *RoleMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *RoleMutation) Field(name string) (ent.Value, bool) { +func (m *RolePermissionMutation) Field(name string) (ent.Value, bool) { switch name { - case role.FieldCreateTime: - return m.CreateTime() - case role.FieldUpdateTime: - return m.UpdateTime() - case role.FieldKeyword: - return m.Keyword() - case role.FieldName: - return m.Name() - case role.FieldDescription: - return m.Description() - case role.FieldType: - return m.GetType() - case role.FieldSequence: - return m.Sequence() - case role.FieldStatus: - return m.Status() + case rolepermission.FieldRoleID: + return m.RoleID() + case rolepermission.FieldPermissionID: + return m.PermissionID() } return nil, false } @@ -8665,120 +8821,51 @@ func (m *RoleMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *RoleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *RolePermissionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case role.FieldCreateTime: - return m.OldCreateTime(ctx) - case role.FieldUpdateTime: - return m.OldUpdateTime(ctx) - case role.FieldKeyword: - return m.OldKeyword(ctx) - case role.FieldName: - return m.OldName(ctx) - case role.FieldDescription: - return m.OldDescription(ctx) - case role.FieldType: - return m.OldType(ctx) - case role.FieldSequence: - return m.OldSequence(ctx) - case role.FieldStatus: - return m.OldStatus(ctx) + case rolepermission.FieldRoleID: + return m.OldRoleID(ctx) + case rolepermission.FieldPermissionID: + return m.OldPermissionID(ctx) } - return nil, fmt.Errorf("unknown Role field %s", name) + return nil, fmt.Errorf("unknown RolePermission field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *RoleMutation) SetField(name string, value ent.Value) error { +func (m *RolePermissionMutation) SetField(name string, value ent.Value) error { switch name { - case role.FieldCreateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetCreateTime(v) - return nil - case role.FieldUpdateTime: - v, ok := value.(time.Time) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUpdateTime(v) - return nil - case role.FieldKeyword: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetKeyword(v) - return nil - case role.FieldName: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetName(v) - return nil - case role.FieldDescription: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetDescription(v) - return nil - case role.FieldType: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetType(v) - return nil - case role.FieldSequence: - v, ok := value.(int) + case rolepermission.FieldRoleID: + v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetSequence(v) + m.SetRoleID(v) return nil - case role.FieldStatus: - v, ok := value.(int8) + case rolepermission.FieldPermissionID: + v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetStatus(v) + m.SetPermissionID(v) return nil } - return fmt.Errorf("unknown Role field %s", name) + return fmt.Errorf("unknown RolePermission field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *RoleMutation) AddedFields() []string { +func (m *RolePermissionMutation) AddedFields() []string { var fields []string - if m.add_type != nil { - fields = append(fields, role.FieldType) - } - if m.addsequence != nil { - fields = append(fields, role.FieldSequence) - } - if m.addstatus != nil { - fields = append(fields, role.FieldStatus) - } return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *RoleMutation) AddedField(name string) (ent.Value, bool) { +func (m *RolePermissionMutation) AddedField(name string) (ent.Value, bool) { switch name { - case role.FieldType: - return m.AddedType() - case role.FieldSequence: - return m.AddedSequence() - case role.FieldStatus: - return m.AddedStatus() } return nil, false } @@ -8786,273 +8873,209 @@ func (m *RoleMutation) AddedField(name string) (ent.Value, bool) { // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *RoleMutation) AddField(name string, value ent.Value) error { +func (m *RolePermissionMutation) AddField(name string, value ent.Value) error { switch name { - case role.FieldType: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddType(v) - return nil - case role.FieldSequence: - v, ok := value.(int) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddSequence(v) - return nil - case role.FieldStatus: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddStatus(v) - return nil } - return fmt.Errorf("unknown Role numeric field %s", name) + return fmt.Errorf("unknown RolePermission numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *RoleMutation) ClearedFields() []string { +func (m *RolePermissionMutation) ClearedFields() []string { return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *RoleMutation) FieldCleared(name string) bool { +func (m *RolePermissionMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *RoleMutation) ClearField(name string) error { - return fmt.Errorf("unknown Role nullable field %s", name) +func (m *RolePermissionMutation) ClearField(name string) error { + return fmt.Errorf("unknown RolePermission nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *RoleMutation) ResetField(name string) error { +func (m *RolePermissionMutation) ResetField(name string) error { switch name { - case role.FieldCreateTime: - m.ResetCreateTime() - return nil - case role.FieldUpdateTime: - m.ResetUpdateTime() - return nil - case role.FieldKeyword: - m.ResetKeyword() - return nil - case role.FieldName: - m.ResetName() - return nil - case role.FieldDescription: - m.ResetDescription() - return nil - case role.FieldType: - m.ResetType() - return nil - case role.FieldSequence: - m.ResetSequence() + case rolepermission.FieldRoleID: + m.ResetRoleID() return nil - case role.FieldStatus: - m.ResetStatus() + case rolepermission.FieldPermissionID: + m.ResetPermissionID() return nil } - return fmt.Errorf("unknown Role field %s", name) + return fmt.Errorf("unknown RolePermission field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *RoleMutation) AddedEdges() []string { - edges := make([]string, 0, 4) - if m.users != nil { - edges = append(edges, role.EdgeUsers) - } - if m.permissions != nil { - edges = append(edges, role.EdgePermissions) - } - if m.user_roles != nil { - edges = append(edges, role.EdgeUserRoles) +func (m *RolePermissionMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.role != nil { + edges = append(edges, rolepermission.EdgeRole) } - if m.role_permissions != nil { - edges = append(edges, role.EdgeRolePermissions) + if m.permission != nil { + edges = append(edges, rolepermission.EdgePermission) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *RoleMutation) AddedIDs(name string) []ent.Value { +func (m *RolePermissionMutation) AddedIDs(name string) []ent.Value { switch name { - case role.EdgeUsers: - ids := make([]ent.Value, 0, len(m.users)) - for id := range m.users { - ids = append(ids, id) - } - return ids - case role.EdgePermissions: - ids := make([]ent.Value, 0, len(m.permissions)) - for id := range m.permissions { - ids = append(ids, id) - } - return ids - case role.EdgeUserRoles: - ids := make([]ent.Value, 0, len(m.user_roles)) - for id := range m.user_roles { - ids = append(ids, id) + case rolepermission.EdgeRole: + if id := m.role; id != nil { + return []ent.Value{*id} } - return ids - case role.EdgeRolePermissions: - ids := make([]ent.Value, 0, len(m.role_permissions)) - for id := range m.role_permissions { - ids = append(ids, id) + case rolepermission.EdgePermission: + if id := m.permission; id != nil { + return []ent.Value{*id} } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *RoleMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) - if m.removedusers != nil { - edges = append(edges, role.EdgeUsers) - } - if m.removedpermissions != nil { - edges = append(edges, role.EdgePermissions) - } - if m.removeduser_roles != nil { - edges = append(edges, role.EdgeUserRoles) - } - if m.removedrole_permissions != nil { - edges = append(edges, role.EdgeRolePermissions) - } +func (m *RolePermissionMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *RoleMutation) RemovedIDs(name string) []ent.Value { +func (m *RolePermissionMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *RolePermissionMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedrole { + edges = append(edges, rolepermission.EdgeRole) + } + if m.clearedpermission { + edges = append(edges, rolepermission.EdgePermission) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *RolePermissionMutation) EdgeCleared(name string) bool { switch name { - case role.EdgeUsers: - ids := make([]ent.Value, 0, len(m.removedusers)) - for id := range m.removedusers { - ids = append(ids, id) - } - return ids - case role.EdgePermissions: - ids := make([]ent.Value, 0, len(m.removedpermissions)) - for id := range m.removedpermissions { - ids = append(ids, id) - } - return ids - case role.EdgeUserRoles: - ids := make([]ent.Value, 0, len(m.removeduser_roles)) - for id := range m.removeduser_roles { - ids = append(ids, id) - } - return ids - case role.EdgeRolePermissions: - ids := make([]ent.Value, 0, len(m.removedrole_permissions)) - for id := range m.removedrole_permissions { - ids = append(ids, id) - } - return ids - } - return nil -} - -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *RoleMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) - if m.clearedusers { - edges = append(edges, role.EdgeUsers) - } - if m.clearedpermissions { - edges = append(edges, role.EdgePermissions) - } - if m.cleareduser_roles { - edges = append(edges, role.EdgeUserRoles) - } - if m.clearedrole_permissions { - edges = append(edges, role.EdgeRolePermissions) - } - return edges -} - -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *RoleMutation) EdgeCleared(name string) bool { - switch name { - case role.EdgeUsers: - return m.clearedusers - case role.EdgePermissions: - return m.clearedpermissions - case role.EdgeUserRoles: - return m.cleareduser_roles - case role.EdgeRolePermissions: - return m.clearedrole_permissions + case rolepermission.EdgeRole: + return m.clearedrole + case rolepermission.EdgePermission: + return m.clearedpermission } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *RoleMutation) ClearEdge(name string) error { +func (m *RolePermissionMutation) ClearEdge(name string) error { switch name { + case rolepermission.EdgeRole: + m.ClearRole() + return nil + case rolepermission.EdgePermission: + m.ClearPermission() + return nil } - return fmt.Errorf("unknown Role unique edge %s", name) + return fmt.Errorf("unknown RolePermission unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *RoleMutation) ResetEdge(name string) error { +func (m *RolePermissionMutation) ResetEdge(name string) error { switch name { - case role.EdgeUsers: - m.ResetUsers() - return nil - case role.EdgePermissions: - m.ResetPermissions() - return nil - case role.EdgeUserRoles: - m.ResetUserRoles() + case rolepermission.EdgeRole: + m.ResetRole() return nil - case role.EdgeRolePermissions: - m.ResetRolePermissions() + case rolepermission.EdgePermission: + m.ResetPermission() return nil } - return fmt.Errorf("unknown Role edge %s", name) + return fmt.Errorf("unknown RolePermission edge %s", name) } -// RolePermissionMutation represents an operation that mutates the RolePermission nodes in the graph. -type RolePermissionMutation struct { +// UserMutation represents an operation that mutates the User nodes in the graph. +type UserMutation struct { config - op Op - typ string - id *int - clearedFields map[string]struct{} - role *int64 - clearedrole bool - permission *int64 - clearedpermission bool - done bool - oldValue func(context.Context) (*RolePermission, error) - predicates []predicate.RolePermission + op Op + typ string + id *int64 + create_author *int64 + addcreate_author *int64 + update_author *int64 + addupdate_author *int64 + create_time *time.Time + update_time *time.Time + delete_time *time.Time + uuid *string + allowed_ip *string + username *string + nickname *string + avatar *string + name *string + gender *user.Gender + encrypted_password *string + salt *string + phone *string + email *string + department *string + remark *string + token *string + status *int8 + addstatus *int8 + is_system *bool + last_login_ip *string + last_login_time *time.Time + login_time *time.Time + sanction_date *time.Time + manager_id *int64 + addmanager_id *int64 + manager *string + clearedFields map[string]struct{} + roles map[int64]struct{} + removedroles map[int64]struct{} + clearedroles bool + positions map[int64]struct{} + removedpositions map[int64]struct{} + clearedpositions bool + departments map[int64]struct{} + removeddepartments map[int64]struct{} + cleareddepartments bool + user_roles map[int]struct{} + removeduser_roles map[int]struct{} + cleareduser_roles bool + user_positions map[int]struct{} + removeduser_positions map[int]struct{} + cleareduser_positions bool + user_departments map[int]struct{} + removeduser_departments map[int]struct{} + cleareduser_departments bool + done bool + oldValue func(context.Context) (*User, error) + predicates []predicate.User } -var _ ent.Mutation = (*RolePermissionMutation)(nil) +var _ ent.Mutation = (*UserMutation)(nil) -// rolepermissionOption allows management of the mutation configuration using functional options. -type rolepermissionOption func(*RolePermissionMutation) +// userOption allows management of the mutation configuration using functional options. +type userOption func(*UserMutation) -// newRolePermissionMutation creates new mutation for the RolePermission entity. -func newRolePermissionMutation(c config, op Op, opts ...rolepermissionOption) *RolePermissionMutation { - m := &RolePermissionMutation{ +// newUserMutation creates new mutation for the User entity. +func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { + m := &UserMutation{ config: c, op: op, - typ: TypeRolePermission, + typ: TypeUser, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -9061,20 +9084,20 @@ func newRolePermissionMutation(c config, op Op, opts ...rolepermissionOption) *R return m } -// withRolePermissionID sets the ID field of the mutation. -func withRolePermissionID(id int) rolepermissionOption { - return func(m *RolePermissionMutation) { +// withUserID sets the ID field of the mutation. +func withUserID(id int64) userOption { + return func(m *UserMutation) { var ( err error once sync.Once - value *RolePermission + value *User ) - m.oldValue = func(ctx context.Context) (*RolePermission, error) { + m.oldValue = func(ctx context.Context) (*User, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().RolePermission.Get(ctx, id) + value, err = m.Client().User.Get(ctx, id) } }) return value, err @@ -9083,10 +9106,10 @@ func withRolePermissionID(id int) rolepermissionOption { } } -// withRolePermission sets the old RolePermission of the mutation. -func withRolePermission(node *RolePermission) rolepermissionOption { - return func(m *RolePermissionMutation) { - m.oldValue = func(context.Context) (*RolePermission, error) { +// withUser sets the old User of the mutation. +func withUser(node *User) userOption { + return func(m *UserMutation) { + m.oldValue = func(context.Context) (*User, error) { return node, nil } m.id = &node.ID @@ -9095,7 +9118,7 @@ func withRolePermission(node *RolePermission) rolepermissionOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m RolePermissionMutation) Client() *Client { +func (m UserMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -9103,7 +9126,7 @@ func (m RolePermissionMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m RolePermissionMutation) Tx() (*Tx, error) { +func (m UserMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -9112,9 +9135,15 @@ func (m RolePermissionMutation) Tx() (*Tx, error) { return tx, nil } +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of User entities. +func (m *UserMutation) SetID(id int64) { + m.id = &id +} + // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *RolePermissionMutation) ID() (id int, exists bool) { +func (m *UserMutation) ID() (id int64, exists bool) { if m.id == nil { return } @@ -9125,2060 +9154,1526 @@ func (m *RolePermissionMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *RolePermissionMutation) IDs(ctx context.Context) ([]int, error) { +func (m *UserMutation) IDs(ctx context.Context) ([]int64, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []int{id}, nil + return []int64{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().RolePermission.Query().Where(m.predicates...).IDs(ctx) + return m.Client().User.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } -// SetRoleID sets the "role_id" field. -func (m *RolePermissionMutation) SetRoleID(i int64) { - m.role = &i +// SetCreateAuthor sets the "create_author" field. +func (m *UserMutation) SetCreateAuthor(i int64) { + m.create_author = &i + m.addcreate_author = nil } -// RoleID returns the value of the "role_id" field in the mutation. -func (m *RolePermissionMutation) RoleID() (r int64, exists bool) { - v := m.role +// CreateAuthor returns the value of the "create_author" field in the mutation. +func (m *UserMutation) CreateAuthor() (r int64, exists bool) { + v := m.create_author if v == nil { return } return *v, true } -// OldRoleID returns the old "role_id" field's value of the RolePermission entity. -// If the RolePermission object wasn't provided to the builder, the object is fetched from the database. +// OldCreateAuthor returns the old "create_author" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RolePermissionMutation) OldRoleID(ctx context.Context) (v int64, err error) { +func (m *UserMutation) OldCreateAuthor(ctx context.Context) (v int64, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRoleID is only allowed on UpdateOne operations") + return v, errors.New("OldCreateAuthor is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRoleID requires an ID field in the mutation") + return v, errors.New("OldCreateAuthor requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldRoleID: %w", err) + return v, fmt.Errorf("querying old value for OldCreateAuthor: %w", err) } - return oldValue.RoleID, nil -} - -// ResetRoleID resets all changes to the "role_id" field. -func (m *RolePermissionMutation) ResetRoleID() { - m.role = nil + return oldValue.CreateAuthor, nil } -// SetPermissionID sets the "permission_id" field. -func (m *RolePermissionMutation) SetPermissionID(i int64) { - m.permission = &i +// AddCreateAuthor adds i to the "create_author" field. +func (m *UserMutation) AddCreateAuthor(i int64) { + if m.addcreate_author != nil { + *m.addcreate_author += i + } else { + m.addcreate_author = &i + } } -// PermissionID returns the value of the "permission_id" field in the mutation. -func (m *RolePermissionMutation) PermissionID() (r int64, exists bool) { - v := m.permission +// AddedCreateAuthor returns the value that was added to the "create_author" field in this mutation. +func (m *UserMutation) AddedCreateAuthor() (r int64, exists bool) { + v := m.addcreate_author if v == nil { return } return *v, true } -// OldPermissionID returns the old "permission_id" field's value of the RolePermission entity. -// If the RolePermission object wasn't provided to the builder, the object is fetched from the database. +// ClearCreateAuthor clears the value of the "create_author" field. +func (m *UserMutation) ClearCreateAuthor() { + m.create_author = nil + m.addcreate_author = nil + m.clearedFields[user.FieldCreateAuthor] = struct{}{} +} + +// CreateAuthorCleared returns if the "create_author" field was cleared in this mutation. +func (m *UserMutation) CreateAuthorCleared() bool { + _, ok := m.clearedFields[user.FieldCreateAuthor] + return ok +} + +// ResetCreateAuthor resets all changes to the "create_author" field. +func (m *UserMutation) ResetCreateAuthor() { + m.create_author = nil + m.addcreate_author = nil + delete(m.clearedFields, user.FieldCreateAuthor) +} + +// SetUpdateAuthor sets the "update_author" field. +func (m *UserMutation) SetUpdateAuthor(i int64) { + m.update_author = &i + m.addupdate_author = nil +} + +// UpdateAuthor returns the value of the "update_author" field in the mutation. +func (m *UserMutation) UpdateAuthor() (r int64, exists bool) { + v := m.update_author + if v == nil { + return + } + return *v, true +} + +// OldUpdateAuthor returns the old "update_author" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RolePermissionMutation) OldPermissionID(ctx context.Context) (v int64, err error) { +func (m *UserMutation) OldUpdateAuthor(ctx context.Context) (v int64, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPermissionID is only allowed on UpdateOne operations") + return v, errors.New("OldUpdateAuthor is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPermissionID requires an ID field in the mutation") + return v, errors.New("OldUpdateAuthor requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPermissionID: %w", err) + return v, fmt.Errorf("querying old value for OldUpdateAuthor: %w", err) } - return oldValue.PermissionID, nil + return oldValue.UpdateAuthor, nil } -// ResetPermissionID resets all changes to the "permission_id" field. -func (m *RolePermissionMutation) ResetPermissionID() { - m.permission = nil +// AddUpdateAuthor adds i to the "update_author" field. +func (m *UserMutation) AddUpdateAuthor(i int64) { + if m.addupdate_author != nil { + *m.addupdate_author += i + } else { + m.addupdate_author = &i + } } -// ClearRole clears the "role" edge to the Role entity. -func (m *RolePermissionMutation) ClearRole() { - m.clearedrole = true - m.clearedFields[rolepermission.FieldRoleID] = struct{}{} +// AddedUpdateAuthor returns the value that was added to the "update_author" field in this mutation. +func (m *UserMutation) AddedUpdateAuthor() (r int64, exists bool) { + v := m.addupdate_author + if v == nil { + return + } + return *v, true } -// RoleCleared reports if the "role" edge to the Role entity was cleared. -func (m *RolePermissionMutation) RoleCleared() bool { - return m.clearedrole +// ClearUpdateAuthor clears the value of the "update_author" field. +func (m *UserMutation) ClearUpdateAuthor() { + m.update_author = nil + m.addupdate_author = nil + m.clearedFields[user.FieldUpdateAuthor] = struct{}{} } -// RoleIDs returns the "role" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// RoleID instead. It exists only for internal usage by the builders. -func (m *RolePermissionMutation) RoleIDs() (ids []int64) { - if id := m.role; id != nil { - ids = append(ids, *id) - } - return +// UpdateAuthorCleared returns if the "update_author" field was cleared in this mutation. +func (m *UserMutation) UpdateAuthorCleared() bool { + _, ok := m.clearedFields[user.FieldUpdateAuthor] + return ok } -// ResetRole resets all changes to the "role" edge. -func (m *RolePermissionMutation) ResetRole() { - m.role = nil - m.clearedrole = false +// ResetUpdateAuthor resets all changes to the "update_author" field. +func (m *UserMutation) ResetUpdateAuthor() { + m.update_author = nil + m.addupdate_author = nil + delete(m.clearedFields, user.FieldUpdateAuthor) } -// ClearPermission clears the "permission" edge to the Permission entity. -func (m *RolePermissionMutation) ClearPermission() { - m.clearedpermission = true - m.clearedFields[rolepermission.FieldPermissionID] = struct{}{} +// SetCreateTime sets the "create_time" field. +func (m *UserMutation) SetCreateTime(t time.Time) { + m.create_time = &t } -// PermissionCleared reports if the "permission" edge to the Permission entity was cleared. -func (m *RolePermissionMutation) PermissionCleared() bool { - return m.clearedpermission +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *UserMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true } -// PermissionIDs returns the "permission" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// PermissionID instead. It exists only for internal usage by the builders. -func (m *RolePermissionMutation) PermissionIDs() (ids []int64) { - if id := m.permission; id != nil { - ids = append(ids, *id) +// OldCreateTime returns the old "create_time" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") } - return + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil } -// ResetPermission resets all changes to the "permission" edge. -func (m *RolePermissionMutation) ResetPermission() { - m.permission = nil - m.clearedpermission = false +// ResetCreateTime resets all changes to the "create_time" field. +func (m *UserMutation) ResetCreateTime() { + m.create_time = nil } -// Where appends a list predicates to the RolePermissionMutation builder. -func (m *RolePermissionMutation) Where(ps ...predicate.RolePermission) { - m.predicates = append(m.predicates, ps...) +// SetUpdateTime sets the "update_time" field. +func (m *UserMutation) SetUpdateTime(t time.Time) { + m.update_time = &t } -// WhereP appends storage-level predicates to the RolePermissionMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *RolePermissionMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.RolePermission, len(ps)) - for i := range ps { - p[i] = ps[i] +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *UserMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return } - m.Where(p...) + return *v, true } -// Op returns the operation name. -func (m *RolePermissionMutation) Op() Op { - return m.op +// OldUpdateTime returns the old "update_time" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil } -// SetOp allows setting the mutation operation. -func (m *RolePermissionMutation) SetOp(op Op) { - m.op = op +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *UserMutation) ResetUpdateTime() { + m.update_time = nil } -// Type returns the node type of this mutation (RolePermission). -func (m *RolePermissionMutation) Type() string { - return m.typ +// SetDeleteTime sets the "delete_time" field. +func (m *UserMutation) SetDeleteTime(t time.Time) { + m.delete_time = &t } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *RolePermissionMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.role != nil { - fields = append(fields, rolepermission.FieldRoleID) - } - if m.permission != nil { - fields = append(fields, rolepermission.FieldPermissionID) +// DeleteTime returns the value of the "delete_time" field in the mutation. +func (m *UserMutation) DeleteTime() (r time.Time, exists bool) { + v := m.delete_time + if v == nil { + return } - return fields + return *v, true } -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *RolePermissionMutation) Field(name string) (ent.Value, bool) { - switch name { - case rolepermission.FieldRoleID: - return m.RoleID() - case rolepermission.FieldPermissionID: - return m.PermissionID() +// OldDeleteTime returns the old "delete_time" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldDeleteTime(ctx context.Context) (v *time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDeleteTime is only allowed on UpdateOne operations") } - return nil, false + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDeleteTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDeleteTime: %w", err) + } + return oldValue.DeleteTime, nil } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *RolePermissionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case rolepermission.FieldRoleID: - return m.OldRoleID(ctx) - case rolepermission.FieldPermissionID: - return m.OldPermissionID(ctx) - } - return nil, fmt.Errorf("unknown RolePermission field %s", name) +// ClearDeleteTime clears the value of the "delete_time" field. +func (m *UserMutation) ClearDeleteTime() { + m.delete_time = nil + m.clearedFields[user.FieldDeleteTime] = struct{}{} } -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *RolePermissionMutation) SetField(name string, value ent.Value) error { - switch name { - case rolepermission.FieldRoleID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRoleID(v) - return nil - case rolepermission.FieldPermissionID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPermissionID(v) - return nil - } - return fmt.Errorf("unknown RolePermission field %s", name) +// DeleteTimeCleared returns if the "delete_time" field was cleared in this mutation. +func (m *UserMutation) DeleteTimeCleared() bool { + _, ok := m.clearedFields[user.FieldDeleteTime] + return ok } -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *RolePermissionMutation) AddedFields() []string { - var fields []string - return fields +// ResetDeleteTime resets all changes to the "delete_time" field. +func (m *UserMutation) ResetDeleteTime() { + m.delete_time = nil + delete(m.clearedFields, user.FieldDeleteTime) } -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *RolePermissionMutation) AddedField(name string) (ent.Value, bool) { - switch name { - } - return nil, false +// SetUUID sets the "uuid" field. +func (m *UserMutation) SetUUID(s string) { + m.uuid = &s } -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *RolePermissionMutation) AddField(name string, value ent.Value) error { - switch name { +// UUID returns the value of the "uuid" field in the mutation. +func (m *UserMutation) UUID() (r string, exists bool) { + v := m.uuid + if v == nil { + return } - return fmt.Errorf("unknown RolePermission numeric field %s", name) + return *v, true } -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *RolePermissionMutation) ClearedFields() []string { - return nil +// OldUUID returns the old "uuid" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUUID(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUUID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUUID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUUID: %w", err) + } + return oldValue.UUID, nil } -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *RolePermissionMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok +// ResetUUID resets all changes to the "uuid" field. +func (m *UserMutation) ResetUUID() { + m.uuid = nil } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *RolePermissionMutation) ClearField(name string) error { - return fmt.Errorf("unknown RolePermission nullable field %s", name) +// SetAllowedIP sets the "allowed_ip" field. +func (m *UserMutation) SetAllowedIP(s string) { + m.allowed_ip = &s } -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *RolePermissionMutation) ResetField(name string) error { - switch name { - case rolepermission.FieldRoleID: - m.ResetRoleID() - return nil - case rolepermission.FieldPermissionID: - m.ResetPermissionID() - return nil +// AllowedIP returns the value of the "allowed_ip" field in the mutation. +func (m *UserMutation) AllowedIP() (r string, exists bool) { + v := m.allowed_ip + if v == nil { + return } - return fmt.Errorf("unknown RolePermission field %s", name) + return *v, true } -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *RolePermissionMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.role != nil { - edges = append(edges, rolepermission.EdgeRole) +// OldAllowedIP returns the old "allowed_ip" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldAllowedIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAllowedIP is only allowed on UpdateOne operations") } - if m.permission != nil { - edges = append(edges, rolepermission.EdgePermission) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAllowedIP requires an ID field in the mutation") } - return edges + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAllowedIP: %w", err) + } + return oldValue.AllowedIP, nil } -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *RolePermissionMutation) AddedIDs(name string) []ent.Value { - switch name { - case rolepermission.EdgeRole: - if id := m.role; id != nil { - return []ent.Value{*id} - } - case rolepermission.EdgePermission: - if id := m.permission; id != nil { - return []ent.Value{*id} - } - } - return nil +// ResetAllowedIP resets all changes to the "allowed_ip" field. +func (m *UserMutation) ResetAllowedIP() { + m.allowed_ip = nil } -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *RolePermissionMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - return edges +// SetUsername sets the "username" field. +func (m *UserMutation) SetUsername(s string) { + m.username = &s } -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *RolePermissionMutation) RemovedIDs(name string) []ent.Value { - return nil +// Username returns the value of the "username" field in the mutation. +func (m *UserMutation) Username() (r string, exists bool) { + v := m.username + if v == nil { + return + } + return *v, true } -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *RolePermissionMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.clearedrole { - edges = append(edges, rolepermission.EdgeRole) +// OldUsername returns the old "username" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUsername is only allowed on UpdateOne operations") } - if m.clearedpermission { - edges = append(edges, rolepermission.EdgePermission) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUsername requires an ID field in the mutation") } - return edges + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUsername: %w", err) + } + return oldValue.Username, nil } -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *RolePermissionMutation) EdgeCleared(name string) bool { - switch name { - case rolepermission.EdgeRole: - return m.clearedrole - case rolepermission.EdgePermission: - return m.clearedpermission - } - return false +// ResetUsername resets all changes to the "username" field. +func (m *UserMutation) ResetUsername() { + m.username = nil } -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *RolePermissionMutation) ClearEdge(name string) error { - switch name { - case rolepermission.EdgeRole: - m.ClearRole() - return nil - case rolepermission.EdgePermission: - m.ClearPermission() - return nil +// SetNickname sets the "nickname" field. +func (m *UserMutation) SetNickname(s string) { + m.nickname = &s +} + +// Nickname returns the value of the "nickname" field in the mutation. +func (m *UserMutation) Nickname() (r string, exists bool) { + v := m.nickname + if v == nil { + return } - return fmt.Errorf("unknown RolePermission unique edge %s", name) + return *v, true } -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *RolePermissionMutation) ResetEdge(name string) error { - switch name { - case rolepermission.EdgeRole: - m.ResetRole() - return nil - case rolepermission.EdgePermission: - m.ResetPermission() - return nil +// OldNickname returns the old "nickname" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldNickname(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldNickname is only allowed on UpdateOne operations") } - return fmt.Errorf("unknown RolePermission edge %s", name) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldNickname requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldNickname: %w", err) + } + return oldValue.Nickname, nil } -// UserMutation represents an operation that mutates the User nodes in the graph. -type UserMutation struct { - config - op Op - typ string - id *int64 - create_author *int64 - addcreate_author *int64 - update_author *int64 - addupdate_author *int64 - create_time *time.Time - update_time *time.Time - delete_time *time.Time - uuid *string - allowed_ip *string - username *string - nickname *string - avatar *string - name *string - gender *user.Gender - encrypted_password *string - salt *string - phone *string - email *string - department *string - remark *string - token *string - status *int8 - addstatus *int8 - is_system *bool - last_login_ip *string - last_login_time *time.Time - login_time *time.Time - sanction_date *time.Time - manager_id *int64 - addmanager_id *int64 - manager *string - clearedFields map[string]struct{} - roles map[int64]struct{} - removedroles map[int64]struct{} - clearedroles bool - positions map[int64]struct{} - removedpositions map[int64]struct{} - clearedpositions bool - departments map[int64]struct{} - removeddepartments map[int64]struct{} - cleareddepartments bool - user_roles map[int]struct{} - removeduser_roles map[int]struct{} - cleareduser_roles bool - user_positions map[int]struct{} - removeduser_positions map[int]struct{} - cleareduser_positions bool - user_departments map[int]struct{} - removeduser_departments map[int]struct{} - cleareduser_departments bool - done bool - oldValue func(context.Context) (*User, error) - predicates []predicate.User +// ResetNickname resets all changes to the "nickname" field. +func (m *UserMutation) ResetNickname() { + m.nickname = nil } -var _ ent.Mutation = (*UserMutation)(nil) - -// userOption allows management of the mutation configuration using functional options. -type userOption func(*UserMutation) - -// newUserMutation creates new mutation for the User entity. -func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { - m := &UserMutation{ - config: c, - op: op, - typ: TypeUser, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) - } - return m +// SetAvatar sets the "avatar" field. +func (m *UserMutation) SetAvatar(s string) { + m.avatar = &s } -// withUserID sets the ID field of the mutation. -func withUserID(id int64) userOption { - return func(m *UserMutation) { - var ( - err error - once sync.Once - value *User - ) - m.oldValue = func(ctx context.Context) (*User, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().User.Get(ctx, id) - } - }) - return value, err - } - m.id = &id +// Avatar returns the value of the "avatar" field in the mutation. +func (m *UserMutation) Avatar() (r string, exists bool) { + v := m.avatar + if v == nil { + return } + return *v, true } -// withUser sets the old User of the mutation. -func withUser(node *User) userOption { - return func(m *UserMutation) { - m.oldValue = func(context.Context) (*User, error) { - return node, nil - } - m.id = &node.ID +// OldAvatar returns the old "avatar" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldAvatar(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAvatar is only allowed on UpdateOne operations") } -} - -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m UserMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client -} - -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m UserMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAvatar requires an ID field in the mutation") } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// SetID sets the value of the id field. Note that this -// operation is only accepted on creation of User entities. -func (m *UserMutation) SetID(id int64) { - m.id = &id -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *UserMutation) ID() (id int64, exists bool) { - if m.id == nil { - return + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAvatar: %w", err) } - return *m.id, true + return oldValue.Avatar, nil } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *UserMutation) IDs(ctx context.Context) ([]int64, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int64{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().User.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) - } +// ResetAvatar resets all changes to the "avatar" field. +func (m *UserMutation) ResetAvatar() { + m.avatar = nil } -// SetCreateAuthor sets the "create_author" field. -func (m *UserMutation) SetCreateAuthor(i int64) { - m.create_author = &i - m.addcreate_author = nil +// SetName sets the "name" field. +func (m *UserMutation) SetName(s string) { + m.name = &s } -// CreateAuthor returns the value of the "create_author" field in the mutation. -func (m *UserMutation) CreateAuthor() (r int64, exists bool) { - v := m.create_author +// Name returns the value of the "name" field in the mutation. +func (m *UserMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldCreateAuthor returns the old "create_author" field's value of the User entity. +// OldName returns the old "name" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldCreateAuthor(ctx context.Context) (v int64, err error) { +func (m *UserMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreateAuthor is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreateAuthor requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreateAuthor: %w", err) - } - return oldValue.CreateAuthor, nil -} - -// AddCreateAuthor adds i to the "create_author" field. -func (m *UserMutation) AddCreateAuthor(i int64) { - if m.addcreate_author != nil { - *m.addcreate_author += i - } else { - m.addcreate_author = &i - } -} - -// AddedCreateAuthor returns the value that was added to the "create_author" field in this mutation. -func (m *UserMutation) AddedCreateAuthor() (r int64, exists bool) { - v := m.addcreate_author - if v == nil { - return + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return *v, true -} - -// ClearCreateAuthor clears the value of the "create_author" field. -func (m *UserMutation) ClearCreateAuthor() { - m.create_author = nil - m.addcreate_author = nil - m.clearedFields[user.FieldCreateAuthor] = struct{}{} -} - -// CreateAuthorCleared returns if the "create_author" field was cleared in this mutation. -func (m *UserMutation) CreateAuthorCleared() bool { - _, ok := m.clearedFields[user.FieldCreateAuthor] - return ok + return oldValue.Name, nil } -// ResetCreateAuthor resets all changes to the "create_author" field. -func (m *UserMutation) ResetCreateAuthor() { - m.create_author = nil - m.addcreate_author = nil - delete(m.clearedFields, user.FieldCreateAuthor) +// ResetName resets all changes to the "name" field. +func (m *UserMutation) ResetName() { + m.name = nil } -// SetUpdateAuthor sets the "update_author" field. -func (m *UserMutation) SetUpdateAuthor(i int64) { - m.update_author = &i - m.addupdate_author = nil +// SetGender sets the "gender" field. +func (m *UserMutation) SetGender(u user.Gender) { + m.gender = &u } -// UpdateAuthor returns the value of the "update_author" field in the mutation. -func (m *UserMutation) UpdateAuthor() (r int64, exists bool) { - v := m.update_author +// Gender returns the value of the "gender" field in the mutation. +func (m *UserMutation) Gender() (r user.Gender, exists bool) { + v := m.gender if v == nil { return } return *v, true } -// OldUpdateAuthor returns the old "update_author" field's value of the User entity. +// OldGender returns the old "gender" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUpdateAuthor(ctx context.Context) (v int64, err error) { +func (m *UserMutation) OldGender(ctx context.Context) (v user.Gender, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateAuthor is only allowed on UpdateOne operations") + return v, errors.New("OldGender is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateAuthor requires an ID field in the mutation") + return v, errors.New("OldGender requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateAuthor: %w", err) + return v, fmt.Errorf("querying old value for OldGender: %w", err) } - return oldValue.UpdateAuthor, nil + return oldValue.Gender, nil } -// AddUpdateAuthor adds i to the "update_author" field. -func (m *UserMutation) AddUpdateAuthor(i int64) { - if m.addupdate_author != nil { - *m.addupdate_author += i - } else { - m.addupdate_author = &i - } -} - -// AddedUpdateAuthor returns the value that was added to the "update_author" field in this mutation. -func (m *UserMutation) AddedUpdateAuthor() (r int64, exists bool) { - v := m.addupdate_author - if v == nil { - return - } - return *v, true -} - -// ClearUpdateAuthor clears the value of the "update_author" field. -func (m *UserMutation) ClearUpdateAuthor() { - m.update_author = nil - m.addupdate_author = nil - m.clearedFields[user.FieldUpdateAuthor] = struct{}{} -} - -// UpdateAuthorCleared returns if the "update_author" field was cleared in this mutation. -func (m *UserMutation) UpdateAuthorCleared() bool { - _, ok := m.clearedFields[user.FieldUpdateAuthor] - return ok -} - -// ResetUpdateAuthor resets all changes to the "update_author" field. -func (m *UserMutation) ResetUpdateAuthor() { - m.update_author = nil - m.addupdate_author = nil - delete(m.clearedFields, user.FieldUpdateAuthor) +// ResetGender resets all changes to the "gender" field. +func (m *UserMutation) ResetGender() { + m.gender = nil } -// SetCreateTime sets the "create_time" field. -func (m *UserMutation) SetCreateTime(t time.Time) { - m.create_time = &t +// SetEncryptedPassword sets the "encrypted_password" field. +func (m *UserMutation) SetEncryptedPassword(s string) { + m.encrypted_password = &s } -// CreateTime returns the value of the "create_time" field in the mutation. -func (m *UserMutation) CreateTime() (r time.Time, exists bool) { - v := m.create_time +// EncryptedPassword returns the value of the "encrypted_password" field in the mutation. +func (m *UserMutation) EncryptedPassword() (r string, exists bool) { + v := m.encrypted_password if v == nil { return } return *v, true } -// OldCreateTime returns the old "create_time" field's value of the User entity. +// OldEncryptedPassword returns the old "encrypted_password" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { +func (m *UserMutation) OldEncryptedPassword(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + return v, errors.New("OldEncryptedPassword is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCreateTime requires an ID field in the mutation") + return v, errors.New("OldEncryptedPassword requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + return v, fmt.Errorf("querying old value for OldEncryptedPassword: %w", err) } - return oldValue.CreateTime, nil + return oldValue.EncryptedPassword, nil } -// ResetCreateTime resets all changes to the "create_time" field. -func (m *UserMutation) ResetCreateTime() { - m.create_time = nil +// ResetEncryptedPassword resets all changes to the "encrypted_password" field. +func (m *UserMutation) ResetEncryptedPassword() { + m.encrypted_password = nil } -// SetUpdateTime sets the "update_time" field. -func (m *UserMutation) SetUpdateTime(t time.Time) { - m.update_time = &t +// SetSalt sets the "salt" field. +func (m *UserMutation) SetSalt(s string) { + m.salt = &s } -// UpdateTime returns the value of the "update_time" field in the mutation. -func (m *UserMutation) UpdateTime() (r time.Time, exists bool) { - v := m.update_time +// Salt returns the value of the "salt" field in the mutation. +func (m *UserMutation) Salt() (r string, exists bool) { + v := m.salt if v == nil { return } return *v, true } -// OldUpdateTime returns the old "update_time" field's value of the User entity. +// OldSalt returns the old "salt" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { +func (m *UserMutation) OldSalt(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + return v, errors.New("OldSalt is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUpdateTime requires an ID field in the mutation") + return v, errors.New("OldSalt requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + return v, fmt.Errorf("querying old value for OldSalt: %w", err) } - return oldValue.UpdateTime, nil + return oldValue.Salt, nil } -// ResetUpdateTime resets all changes to the "update_time" field. -func (m *UserMutation) ResetUpdateTime() { - m.update_time = nil +// ResetSalt resets all changes to the "salt" field. +func (m *UserMutation) ResetSalt() { + m.salt = nil } -// SetDeleteTime sets the "delete_time" field. -func (m *UserMutation) SetDeleteTime(t time.Time) { - m.delete_time = &t +// SetPhone sets the "phone" field. +func (m *UserMutation) SetPhone(s string) { + m.phone = &s } -// DeleteTime returns the value of the "delete_time" field in the mutation. -func (m *UserMutation) DeleteTime() (r time.Time, exists bool) { - v := m.delete_time +// Phone returns the value of the "phone" field in the mutation. +func (m *UserMutation) Phone() (r string, exists bool) { + v := m.phone if v == nil { return } return *v, true } -// OldDeleteTime returns the old "delete_time" field's value of the User entity. +// OldPhone returns the old "phone" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldDeleteTime(ctx context.Context) (v *time.Time, err error) { +func (m *UserMutation) OldPhone(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDeleteTime is only allowed on UpdateOne operations") + return v, errors.New("OldPhone is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDeleteTime requires an ID field in the mutation") + return v, errors.New("OldPhone requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDeleteTime: %w", err) + return v, fmt.Errorf("querying old value for OldPhone: %w", err) } - return oldValue.DeleteTime, nil -} - -// ClearDeleteTime clears the value of the "delete_time" field. -func (m *UserMutation) ClearDeleteTime() { - m.delete_time = nil - m.clearedFields[user.FieldDeleteTime] = struct{}{} -} - -// DeleteTimeCleared returns if the "delete_time" field was cleared in this mutation. -func (m *UserMutation) DeleteTimeCleared() bool { - _, ok := m.clearedFields[user.FieldDeleteTime] - return ok + return oldValue.Phone, nil } -// ResetDeleteTime resets all changes to the "delete_time" field. -func (m *UserMutation) ResetDeleteTime() { - m.delete_time = nil - delete(m.clearedFields, user.FieldDeleteTime) +// ResetPhone resets all changes to the "phone" field. +func (m *UserMutation) ResetPhone() { + m.phone = nil } -// SetUUID sets the "uuid" field. -func (m *UserMutation) SetUUID(s string) { - m.uuid = &s +// SetEmail sets the "email" field. +func (m *UserMutation) SetEmail(s string) { + m.email = &s } -// UUID returns the value of the "uuid" field in the mutation. -func (m *UserMutation) UUID() (r string, exists bool) { - v := m.uuid +// Email returns the value of the "email" field in the mutation. +func (m *UserMutation) Email() (r string, exists bool) { + v := m.email if v == nil { return } return *v, true } -// OldUUID returns the old "uuid" field's value of the User entity. +// OldEmail returns the old "email" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUUID(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUUID is only allowed on UpdateOne operations") + return v, errors.New("OldEmail is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUUID requires an ID field in the mutation") + return v, errors.New("OldEmail requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUUID: %w", err) + return v, fmt.Errorf("querying old value for OldEmail: %w", err) } - return oldValue.UUID, nil + return oldValue.Email, nil } -// ResetUUID resets all changes to the "uuid" field. -func (m *UserMutation) ResetUUID() { - m.uuid = nil +// ResetEmail resets all changes to the "email" field. +func (m *UserMutation) ResetEmail() { + m.email = nil } -// SetAllowedIP sets the "allowed_ip" field. -func (m *UserMutation) SetAllowedIP(s string) { - m.allowed_ip = &s +// SetDepartment sets the "department" field. +func (m *UserMutation) SetDepartment(s string) { + m.department = &s } -// AllowedIP returns the value of the "allowed_ip" field in the mutation. -func (m *UserMutation) AllowedIP() (r string, exists bool) { - v := m.allowed_ip +// Department returns the value of the "department" field in the mutation. +func (m *UserMutation) Department() (r string, exists bool) { + v := m.department if v == nil { return } return *v, true } -// OldAllowedIP returns the old "allowed_ip" field's value of the User entity. +// OldDepartment returns the old "department" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldAllowedIP(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldDepartment(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAllowedIP is only allowed on UpdateOne operations") + return v, errors.New("OldDepartment is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAllowedIP requires an ID field in the mutation") + return v, errors.New("OldDepartment requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAllowedIP: %w", err) + return v, fmt.Errorf("querying old value for OldDepartment: %w", err) } - return oldValue.AllowedIP, nil + return oldValue.Department, nil } -// ResetAllowedIP resets all changes to the "allowed_ip" field. -func (m *UserMutation) ResetAllowedIP() { - m.allowed_ip = nil +// ResetDepartment resets all changes to the "department" field. +func (m *UserMutation) ResetDepartment() { + m.department = nil } -// SetUsername sets the "username" field. -func (m *UserMutation) SetUsername(s string) { - m.username = &s +// SetRemark sets the "remark" field. +func (m *UserMutation) SetRemark(s string) { + m.remark = &s } -// Username returns the value of the "username" field in the mutation. -func (m *UserMutation) Username() (r string, exists bool) { - v := m.username +// Remark returns the value of the "remark" field in the mutation. +func (m *UserMutation) Remark() (r string, exists bool) { + v := m.remark if v == nil { return } return *v, true } -// OldUsername returns the old "username" field's value of the User entity. +// OldRemark returns the old "remark" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldRemark(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUsername is only allowed on UpdateOne operations") + return v, errors.New("OldRemark is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUsername requires an ID field in the mutation") + return v, errors.New("OldRemark requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUsername: %w", err) + return v, fmt.Errorf("querying old value for OldRemark: %w", err) } - return oldValue.Username, nil + return oldValue.Remark, nil } -// ResetUsername resets all changes to the "username" field. -func (m *UserMutation) ResetUsername() { - m.username = nil +// ResetRemark resets all changes to the "remark" field. +func (m *UserMutation) ResetRemark() { + m.remark = nil } -// SetNickname sets the "nickname" field. -func (m *UserMutation) SetNickname(s string) { - m.nickname = &s +// SetToken sets the "token" field. +func (m *UserMutation) SetToken(s string) { + m.token = &s } -// Nickname returns the value of the "nickname" field in the mutation. -func (m *UserMutation) Nickname() (r string, exists bool) { - v := m.nickname +// Token returns the value of the "token" field in the mutation. +func (m *UserMutation) Token() (r string, exists bool) { + v := m.token if v == nil { return } return *v, true } -// OldNickname returns the old "nickname" field's value of the User entity. +// OldToken returns the old "token" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldNickname(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldToken(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNickname is only allowed on UpdateOne operations") + return v, errors.New("OldToken is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNickname requires an ID field in the mutation") + return v, errors.New("OldToken requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldNickname: %w", err) + return v, fmt.Errorf("querying old value for OldToken: %w", err) } - return oldValue.Nickname, nil + return oldValue.Token, nil } -// ResetNickname resets all changes to the "nickname" field. -func (m *UserMutation) ResetNickname() { - m.nickname = nil +// ResetToken resets all changes to the "token" field. +func (m *UserMutation) ResetToken() { + m.token = nil } -// SetAvatar sets the "avatar" field. -func (m *UserMutation) SetAvatar(s string) { - m.avatar = &s +// SetStatus sets the "status" field. +func (m *UserMutation) SetStatus(i int8) { + m.status = &i + m.addstatus = nil } -// Avatar returns the value of the "avatar" field in the mutation. -func (m *UserMutation) Avatar() (r string, exists bool) { - v := m.avatar +// Status returns the value of the "status" field in the mutation. +func (m *UserMutation) Status() (r int8, exists bool) { + v := m.status if v == nil { return } return *v, true } -// OldAvatar returns the old "avatar" field's value of the User entity. +// OldStatus returns the old "status" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldAvatar(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldStatus(ctx context.Context) (v int8, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldAvatar is only allowed on UpdateOne operations") + return v, errors.New("OldStatus is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldAvatar requires an ID field in the mutation") + return v, errors.New("OldStatus requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldAvatar: %w", err) + return v, fmt.Errorf("querying old value for OldStatus: %w", err) } - return oldValue.Avatar, nil -} - -// ResetAvatar resets all changes to the "avatar" field. -func (m *UserMutation) ResetAvatar() { - m.avatar = nil + return oldValue.Status, nil } -// SetName sets the "name" field. -func (m *UserMutation) SetName(s string) { - m.name = &s +// AddStatus adds i to the "status" field. +func (m *UserMutation) AddStatus(i int8) { + if m.addstatus != nil { + *m.addstatus += i + } else { + m.addstatus = &i + } } -// Name returns the value of the "name" field in the mutation. -func (m *UserMutation) Name() (r string, exists bool) { - v := m.name +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *UserMutation) AddedStatus() (r int8, exists bool) { + v := m.addstatus if v == nil { return } return *v, true } -// OldName returns the old "name" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldName(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldName is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldName requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldName: %w", err) - } - return oldValue.Name, nil -} - -// ResetName resets all changes to the "name" field. -func (m *UserMutation) ResetName() { - m.name = nil +// ResetStatus resets all changes to the "status" field. +func (m *UserMutation) ResetStatus() { + m.status = nil + m.addstatus = nil } -// SetGender sets the "gender" field. -func (m *UserMutation) SetGender(u user.Gender) { - m.gender = &u +// SetIsSystem sets the "is_system" field. +func (m *UserMutation) SetIsSystem(b bool) { + m.is_system = &b } -// Gender returns the value of the "gender" field in the mutation. -func (m *UserMutation) Gender() (r user.Gender, exists bool) { - v := m.gender +// IsSystem returns the value of the "is_system" field in the mutation. +func (m *UserMutation) IsSystem() (r bool, exists bool) { + v := m.is_system if v == nil { return } return *v, true } -// OldGender returns the old "gender" field's value of the User entity. +// OldIsSystem returns the old "is_system" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldGender(ctx context.Context) (v user.Gender, err error) { +func (m *UserMutation) OldIsSystem(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldGender is only allowed on UpdateOne operations") + return v, errors.New("OldIsSystem is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldGender requires an ID field in the mutation") + return v, errors.New("OldIsSystem requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldGender: %w", err) + return v, fmt.Errorf("querying old value for OldIsSystem: %w", err) } - return oldValue.Gender, nil + return oldValue.IsSystem, nil } -// ResetGender resets all changes to the "gender" field. -func (m *UserMutation) ResetGender() { - m.gender = nil +// ResetIsSystem resets all changes to the "is_system" field. +func (m *UserMutation) ResetIsSystem() { + m.is_system = nil } -// SetEncryptedPassword sets the "encrypted_password" field. -func (m *UserMutation) SetEncryptedPassword(s string) { - m.encrypted_password = &s +// SetLastLoginIP sets the "last_login_ip" field. +func (m *UserMutation) SetLastLoginIP(s string) { + m.last_login_ip = &s } -// EncryptedPassword returns the value of the "encrypted_password" field in the mutation. -func (m *UserMutation) EncryptedPassword() (r string, exists bool) { - v := m.encrypted_password +// LastLoginIP returns the value of the "last_login_ip" field in the mutation. +func (m *UserMutation) LastLoginIP() (r string, exists bool) { + v := m.last_login_ip if v == nil { return } return *v, true } -// OldEncryptedPassword returns the old "encrypted_password" field's value of the User entity. +// OldLastLoginIP returns the old "last_login_ip" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldEncryptedPassword(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldLastLoginIP(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEncryptedPassword is only allowed on UpdateOne operations") + return v, errors.New("OldLastLoginIP is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEncryptedPassword requires an ID field in the mutation") + return v, errors.New("OldLastLoginIP requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEncryptedPassword: %w", err) + return v, fmt.Errorf("querying old value for OldLastLoginIP: %w", err) } - return oldValue.EncryptedPassword, nil + return oldValue.LastLoginIP, nil } -// ResetEncryptedPassword resets all changes to the "encrypted_password" field. -func (m *UserMutation) ResetEncryptedPassword() { - m.encrypted_password = nil +// ResetLastLoginIP resets all changes to the "last_login_ip" field. +func (m *UserMutation) ResetLastLoginIP() { + m.last_login_ip = nil } -// SetSalt sets the "salt" field. -func (m *UserMutation) SetSalt(s string) { - m.salt = &s +// SetLastLoginTime sets the "last_login_time" field. +func (m *UserMutation) SetLastLoginTime(t time.Time) { + m.last_login_time = &t } -// Salt returns the value of the "salt" field in the mutation. -func (m *UserMutation) Salt() (r string, exists bool) { - v := m.salt +// LastLoginTime returns the value of the "last_login_time" field in the mutation. +func (m *UserMutation) LastLoginTime() (r time.Time, exists bool) { + v := m.last_login_time if v == nil { return } return *v, true } -// OldSalt returns the old "salt" field's value of the User entity. +// OldLastLoginTime returns the old "last_login_time" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldSalt(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldLastLoginTime(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSalt is only allowed on UpdateOne operations") + return v, errors.New("OldLastLoginTime is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSalt requires an ID field in the mutation") + return v, errors.New("OldLastLoginTime requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldSalt: %w", err) + return v, fmt.Errorf("querying old value for OldLastLoginTime: %w", err) } - return oldValue.Salt, nil + return oldValue.LastLoginTime, nil } -// ResetSalt resets all changes to the "salt" field. -func (m *UserMutation) ResetSalt() { - m.salt = nil +// ResetLastLoginTime resets all changes to the "last_login_time" field. +func (m *UserMutation) ResetLastLoginTime() { + m.last_login_time = nil } -// SetPhone sets the "phone" field. -func (m *UserMutation) SetPhone(s string) { - m.phone = &s +// SetLoginTime sets the "login_time" field. +func (m *UserMutation) SetLoginTime(t time.Time) { + m.login_time = &t } -// Phone returns the value of the "phone" field in the mutation. -func (m *UserMutation) Phone() (r string, exists bool) { - v := m.phone +// LoginTime returns the value of the "login_time" field in the mutation. +func (m *UserMutation) LoginTime() (r time.Time, exists bool) { + v := m.login_time if v == nil { return } return *v, true } -// OldPhone returns the old "phone" field's value of the User entity. +// OldLoginTime returns the old "login_time" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldPhone(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldLoginTime(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPhone is only allowed on UpdateOne operations") + return v, errors.New("OldLoginTime is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPhone requires an ID field in the mutation") + return v, errors.New("OldLoginTime requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPhone: %w", err) + return v, fmt.Errorf("querying old value for OldLoginTime: %w", err) } - return oldValue.Phone, nil + return oldValue.LoginTime, nil } -// ResetPhone resets all changes to the "phone" field. -func (m *UserMutation) ResetPhone() { - m.phone = nil +// ResetLoginTime resets all changes to the "login_time" field. +func (m *UserMutation) ResetLoginTime() { + m.login_time = nil } -// SetEmail sets the "email" field. -func (m *UserMutation) SetEmail(s string) { - m.email = &s +// SetSanctionDate sets the "sanction_date" field. +func (m *UserMutation) SetSanctionDate(t time.Time) { + m.sanction_date = &t } -// Email returns the value of the "email" field in the mutation. -func (m *UserMutation) Email() (r string, exists bool) { - v := m.email +// SanctionDate returns the value of the "sanction_date" field in the mutation. +func (m *UserMutation) SanctionDate() (r time.Time, exists bool) { + v := m.sanction_date if v == nil { return } return *v, true } -// OldEmail returns the old "email" field's value of the User entity. +// OldSanctionDate returns the old "sanction_date" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldEmail(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldSanctionDate(ctx context.Context) (v time.Time, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldEmail is only allowed on UpdateOne operations") + return v, errors.New("OldSanctionDate is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldEmail requires an ID field in the mutation") + return v, errors.New("OldSanctionDate requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldEmail: %w", err) + return v, fmt.Errorf("querying old value for OldSanctionDate: %w", err) } - return oldValue.Email, nil + return oldValue.SanctionDate, nil } -// ResetEmail resets all changes to the "email" field. -func (m *UserMutation) ResetEmail() { - m.email = nil +// ClearSanctionDate clears the value of the "sanction_date" field. +func (m *UserMutation) ClearSanctionDate() { + m.sanction_date = nil + m.clearedFields[user.FieldSanctionDate] = struct{}{} } -// SetDepartment sets the "department" field. -func (m *UserMutation) SetDepartment(s string) { - m.department = &s +// SanctionDateCleared returns if the "sanction_date" field was cleared in this mutation. +func (m *UserMutation) SanctionDateCleared() bool { + _, ok := m.clearedFields[user.FieldSanctionDate] + return ok } -// Department returns the value of the "department" field in the mutation. -func (m *UserMutation) Department() (r string, exists bool) { - v := m.department +// ResetSanctionDate resets all changes to the "sanction_date" field. +func (m *UserMutation) ResetSanctionDate() { + m.sanction_date = nil + delete(m.clearedFields, user.FieldSanctionDate) +} + +// SetManagerID sets the "manager_id" field. +func (m *UserMutation) SetManagerID(i int64) { + m.manager_id = &i + m.addmanager_id = nil +} + +// ManagerID returns the value of the "manager_id" field in the mutation. +func (m *UserMutation) ManagerID() (r int64, exists bool) { + v := m.manager_id if v == nil { return } return *v, true } -// OldDepartment returns the old "department" field's value of the User entity. +// OldManagerID returns the old "manager_id" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldDepartment(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldManagerID(ctx context.Context) (v int64, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDepartment is only allowed on UpdateOne operations") + return v, errors.New("OldManagerID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDepartment requires an ID field in the mutation") + return v, errors.New("OldManagerID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDepartment: %w", err) + return v, fmt.Errorf("querying old value for OldManagerID: %w", err) } - return oldValue.Department, nil -} - -// ResetDepartment resets all changes to the "department" field. -func (m *UserMutation) ResetDepartment() { - m.department = nil + return oldValue.ManagerID, nil } -// SetRemark sets the "remark" field. -func (m *UserMutation) SetRemark(s string) { - m.remark = &s +// AddManagerID adds i to the "manager_id" field. +func (m *UserMutation) AddManagerID(i int64) { + if m.addmanager_id != nil { + *m.addmanager_id += i + } else { + m.addmanager_id = &i + } } -// Remark returns the value of the "remark" field in the mutation. -func (m *UserMutation) Remark() (r string, exists bool) { - v := m.remark +// AddedManagerID returns the value that was added to the "manager_id" field in this mutation. +func (m *UserMutation) AddedManagerID() (r int64, exists bool) { + v := m.addmanager_id if v == nil { return } return *v, true } -// OldRemark returns the old "remark" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldRemark(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRemark is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRemark requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRemark: %w", err) - } - return oldValue.Remark, nil +// ClearManagerID clears the value of the "manager_id" field. +func (m *UserMutation) ClearManagerID() { + m.manager_id = nil + m.addmanager_id = nil + m.clearedFields[user.FieldManagerID] = struct{}{} } -// ResetRemark resets all changes to the "remark" field. -func (m *UserMutation) ResetRemark() { - m.remark = nil +// ManagerIDCleared returns if the "manager_id" field was cleared in this mutation. +func (m *UserMutation) ManagerIDCleared() bool { + _, ok := m.clearedFields[user.FieldManagerID] + return ok } -// SetToken sets the "token" field. -func (m *UserMutation) SetToken(s string) { - m.token = &s +// ResetManagerID resets all changes to the "manager_id" field. +func (m *UserMutation) ResetManagerID() { + m.manager_id = nil + m.addmanager_id = nil + delete(m.clearedFields, user.FieldManagerID) } -// Token returns the value of the "token" field in the mutation. -func (m *UserMutation) Token() (r string, exists bool) { - v := m.token +// SetManager sets the "manager" field. +func (m *UserMutation) SetManager(s string) { + m.manager = &s +} + +// Manager returns the value of the "manager" field in the mutation. +func (m *UserMutation) Manager() (r string, exists bool) { + v := m.manager if v == nil { return } return *v, true } -// OldToken returns the old "token" field's value of the User entity. +// OldManager returns the old "manager" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldToken(ctx context.Context) (v string, err error) { +func (m *UserMutation) OldManager(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldToken is only allowed on UpdateOne operations") + return v, errors.New("OldManager is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldToken requires an ID field in the mutation") + return v, errors.New("OldManager requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldToken: %w", err) + return v, fmt.Errorf("querying old value for OldManager: %w", err) } - return oldValue.Token, nil -} - -// ResetToken resets all changes to the "token" field. -func (m *UserMutation) ResetToken() { - m.token = nil + return oldValue.Manager, nil } -// SetStatus sets the "status" field. -func (m *UserMutation) SetStatus(i int8) { - m.status = &i - m.addstatus = nil +// ResetManager resets all changes to the "manager" field. +func (m *UserMutation) ResetManager() { + m.manager = nil } -// Status returns the value of the "status" field in the mutation. -func (m *UserMutation) Status() (r int8, exists bool) { - v := m.status - if v == nil { - return +// AddRoleIDs adds the "roles" edge to the Role entity by ids. +func (m *UserMutation) AddRoleIDs(ids ...int64) { + if m.roles == nil { + m.roles = make(map[int64]struct{}) + } + for i := range ids { + m.roles[ids[i]] = struct{}{} } - return *v, true } -// OldStatus returns the old "status" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldStatus(ctx context.Context) (v int8, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) - } - return oldValue.Status, nil +// ClearRoles clears the "roles" edge to the Role entity. +func (m *UserMutation) ClearRoles() { + m.clearedroles = true } -// AddStatus adds i to the "status" field. -func (m *UserMutation) AddStatus(i int8) { - if m.addstatus != nil { - *m.addstatus += i - } else { - m.addstatus = &i - } +// RolesCleared reports if the "roles" edge to the Role entity was cleared. +func (m *UserMutation) RolesCleared() bool { + return m.clearedroles } -// AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *UserMutation) AddedStatus() (r int8, exists bool) { - v := m.addstatus - if v == nil { - return +// RemoveRoleIDs removes the "roles" edge to the Role entity by IDs. +func (m *UserMutation) RemoveRoleIDs(ids ...int64) { + if m.removedroles == nil { + m.removedroles = make(map[int64]struct{}) + } + for i := range ids { + delete(m.roles, ids[i]) + m.removedroles[ids[i]] = struct{}{} } - return *v, true } -// ResetStatus resets all changes to the "status" field. -func (m *UserMutation) ResetStatus() { - m.status = nil - m.addstatus = nil +// RemovedRoles returns the removed IDs of the "roles" edge to the Role entity. +func (m *UserMutation) RemovedRolesIDs() (ids []int64) { + for id := range m.removedroles { + ids = append(ids, id) + } + return } -// SetIsSystem sets the "is_system" field. -func (m *UserMutation) SetIsSystem(b bool) { - m.is_system = &b +// RolesIDs returns the "roles" edge IDs in the mutation. +func (m *UserMutation) RolesIDs() (ids []int64) { + for id := range m.roles { + ids = append(ids, id) + } + return } -// IsSystem returns the value of the "is_system" field in the mutation. -func (m *UserMutation) IsSystem() (r bool, exists bool) { - v := m.is_system - if v == nil { - return - } - return *v, true +// ResetRoles resets all changes to the "roles" edge. +func (m *UserMutation) ResetRoles() { + m.roles = nil + m.clearedroles = false + m.removedroles = nil } -// OldIsSystem returns the old "is_system" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldIsSystem(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsSystem is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsSystem requires an ID field in the mutation") +// AddPositionIDs adds the "positions" edge to the Position entity by ids. +func (m *UserMutation) AddPositionIDs(ids ...int64) { + if m.positions == nil { + m.positions = make(map[int64]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldIsSystem: %w", err) + for i := range ids { + m.positions[ids[i]] = struct{}{} } - return oldValue.IsSystem, nil } -// ResetIsSystem resets all changes to the "is_system" field. -func (m *UserMutation) ResetIsSystem() { - m.is_system = nil +// ClearPositions clears the "positions" edge to the Position entity. +func (m *UserMutation) ClearPositions() { + m.clearedpositions = true } -// SetLastLoginIP sets the "last_login_ip" field. -func (m *UserMutation) SetLastLoginIP(s string) { - m.last_login_ip = &s +// PositionsCleared reports if the "positions" edge to the Position entity was cleared. +func (m *UserMutation) PositionsCleared() bool { + return m.clearedpositions } -// LastLoginIP returns the value of the "last_login_ip" field in the mutation. -func (m *UserMutation) LastLoginIP() (r string, exists bool) { - v := m.last_login_ip - if v == nil { - return +// RemovePositionIDs removes the "positions" edge to the Position entity by IDs. +func (m *UserMutation) RemovePositionIDs(ids ...int64) { + if m.removedpositions == nil { + m.removedpositions = make(map[int64]struct{}) + } + for i := range ids { + delete(m.positions, ids[i]) + m.removedpositions[ids[i]] = struct{}{} } - return *v, true } -// OldLastLoginIP returns the old "last_login_ip" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldLastLoginIP(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastLoginIP is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastLoginIP requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLastLoginIP: %w", err) +// RemovedPositions returns the removed IDs of the "positions" edge to the Position entity. +func (m *UserMutation) RemovedPositionsIDs() (ids []int64) { + for id := range m.removedpositions { + ids = append(ids, id) } - return oldValue.LastLoginIP, nil + return } -// ResetLastLoginIP resets all changes to the "last_login_ip" field. -func (m *UserMutation) ResetLastLoginIP() { - m.last_login_ip = nil +// PositionsIDs returns the "positions" edge IDs in the mutation. +func (m *UserMutation) PositionsIDs() (ids []int64) { + for id := range m.positions { + ids = append(ids, id) + } + return } -// SetLastLoginTime sets the "last_login_time" field. -func (m *UserMutation) SetLastLoginTime(t time.Time) { - m.last_login_time = &t +// ResetPositions resets all changes to the "positions" edge. +func (m *UserMutation) ResetPositions() { + m.positions = nil + m.clearedpositions = false + m.removedpositions = nil } -// LastLoginTime returns the value of the "last_login_time" field in the mutation. -func (m *UserMutation) LastLoginTime() (r time.Time, exists bool) { - v := m.last_login_time - if v == nil { - return +// AddDepartmentIDs adds the "departments" edge to the Department entity by ids. +func (m *UserMutation) AddDepartmentIDs(ids ...int64) { + if m.departments == nil { + m.departments = make(map[int64]struct{}) + } + for i := range ids { + m.departments[ids[i]] = struct{}{} } - return *v, true } -// OldLastLoginTime returns the old "last_login_time" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldLastLoginTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLastLoginTime is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLastLoginTime requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLastLoginTime: %w", err) - } - return oldValue.LastLoginTime, nil +// ClearDepartments clears the "departments" edge to the Department entity. +func (m *UserMutation) ClearDepartments() { + m.cleareddepartments = true } -// ResetLastLoginTime resets all changes to the "last_login_time" field. -func (m *UserMutation) ResetLastLoginTime() { - m.last_login_time = nil +// DepartmentsCleared reports if the "departments" edge to the Department entity was cleared. +func (m *UserMutation) DepartmentsCleared() bool { + return m.cleareddepartments } -// SetLoginTime sets the "login_time" field. -func (m *UserMutation) SetLoginTime(t time.Time) { - m.login_time = &t +// RemoveDepartmentIDs removes the "departments" edge to the Department entity by IDs. +func (m *UserMutation) RemoveDepartmentIDs(ids ...int64) { + if m.removeddepartments == nil { + m.removeddepartments = make(map[int64]struct{}) + } + for i := range ids { + delete(m.departments, ids[i]) + m.removeddepartments[ids[i]] = struct{}{} + } } -// LoginTime returns the value of the "login_time" field in the mutation. -func (m *UserMutation) LoginTime() (r time.Time, exists bool) { - v := m.login_time - if v == nil { - return +// RemovedDepartments returns the removed IDs of the "departments" edge to the Department entity. +func (m *UserMutation) RemovedDepartmentsIDs() (ids []int64) { + for id := range m.removeddepartments { + ids = append(ids, id) } - return *v, true + return } -// OldLoginTime returns the old "login_time" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldLoginTime(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldLoginTime is only allowed on UpdateOne operations") +// DepartmentsIDs returns the "departments" edge IDs in the mutation. +func (m *UserMutation) DepartmentsIDs() (ids []int64) { + for id := range m.departments { + ids = append(ids, id) } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldLoginTime requires an ID field in the mutation") + return +} + +// ResetDepartments resets all changes to the "departments" edge. +func (m *UserMutation) ResetDepartments() { + m.departments = nil + m.cleareddepartments = false + m.removeddepartments = nil +} + +// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by ids. +func (m *UserMutation) AddUserRoleIDs(ids ...int) { + if m.user_roles == nil { + m.user_roles = make(map[int]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldLoginTime: %w", err) + for i := range ids { + m.user_roles[ids[i]] = struct{}{} } - return oldValue.LoginTime, nil } -// ResetLoginTime resets all changes to the "login_time" field. -func (m *UserMutation) ResetLoginTime() { - m.login_time = nil +// ClearUserRoles clears the "user_roles" edge to the UserRole entity. +func (m *UserMutation) ClearUserRoles() { + m.cleareduser_roles = true } -// SetSanctionDate sets the "sanction_date" field. -func (m *UserMutation) SetSanctionDate(t time.Time) { - m.sanction_date = &t +// UserRolesCleared reports if the "user_roles" edge to the UserRole entity was cleared. +func (m *UserMutation) UserRolesCleared() bool { + return m.cleareduser_roles } -// SanctionDate returns the value of the "sanction_date" field in the mutation. -func (m *UserMutation) SanctionDate() (r time.Time, exists bool) { - v := m.sanction_date - if v == nil { - return +// RemoveUserRoleIDs removes the "user_roles" edge to the UserRole entity by IDs. +func (m *UserMutation) RemoveUserRoleIDs(ids ...int) { + if m.removeduser_roles == nil { + m.removeduser_roles = make(map[int]struct{}) + } + for i := range ids { + delete(m.user_roles, ids[i]) + m.removeduser_roles[ids[i]] = struct{}{} } - return *v, true } -// OldSanctionDate returns the old "sanction_date" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldSanctionDate(ctx context.Context) (v time.Time, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldSanctionDate is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldSanctionDate requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldSanctionDate: %w", err) +// RemovedUserRoles returns the removed IDs of the "user_roles" edge to the UserRole entity. +func (m *UserMutation) RemovedUserRolesIDs() (ids []int) { + for id := range m.removeduser_roles { + ids = append(ids, id) } - return oldValue.SanctionDate, nil + return } -// ClearSanctionDate clears the value of the "sanction_date" field. -func (m *UserMutation) ClearSanctionDate() { - m.sanction_date = nil - m.clearedFields[user.FieldSanctionDate] = struct{}{} +// UserRolesIDs returns the "user_roles" edge IDs in the mutation. +func (m *UserMutation) UserRolesIDs() (ids []int) { + for id := range m.user_roles { + ids = append(ids, id) + } + return } -// SanctionDateCleared returns if the "sanction_date" field was cleared in this mutation. -func (m *UserMutation) SanctionDateCleared() bool { - _, ok := m.clearedFields[user.FieldSanctionDate] - return ok +// ResetUserRoles resets all changes to the "user_roles" edge. +func (m *UserMutation) ResetUserRoles() { + m.user_roles = nil + m.cleareduser_roles = false + m.removeduser_roles = nil } -// ResetSanctionDate resets all changes to the "sanction_date" field. -func (m *UserMutation) ResetSanctionDate() { - m.sanction_date = nil - delete(m.clearedFields, user.FieldSanctionDate) +// AddUserPositionIDs adds the "user_positions" edge to the UserPosition entity by ids. +func (m *UserMutation) AddUserPositionIDs(ids ...int) { + if m.user_positions == nil { + m.user_positions = make(map[int]struct{}) + } + for i := range ids { + m.user_positions[ids[i]] = struct{}{} + } } -// SetManagerID sets the "manager_id" field. -func (m *UserMutation) SetManagerID(i int64) { - m.manager_id = &i - m.addmanager_id = nil +// ClearUserPositions clears the "user_positions" edge to the UserPosition entity. +func (m *UserMutation) ClearUserPositions() { + m.cleareduser_positions = true } -// ManagerID returns the value of the "manager_id" field in the mutation. -func (m *UserMutation) ManagerID() (r int64, exists bool) { - v := m.manager_id - if v == nil { - return - } - return *v, true +// UserPositionsCleared reports if the "user_positions" edge to the UserPosition entity was cleared. +func (m *UserMutation) UserPositionsCleared() bool { + return m.cleareduser_positions } -// OldManagerID returns the old "manager_id" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldManagerID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManagerID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManagerID requires an ID field in the mutation") +// RemoveUserPositionIDs removes the "user_positions" edge to the UserPosition entity by IDs. +func (m *UserMutation) RemoveUserPositionIDs(ids ...int) { + if m.removeduser_positions == nil { + m.removeduser_positions = make(map[int]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldManagerID: %w", err) + for i := range ids { + delete(m.user_positions, ids[i]) + m.removeduser_positions[ids[i]] = struct{}{} } - return oldValue.ManagerID, nil } -// AddManagerID adds i to the "manager_id" field. -func (m *UserMutation) AddManagerID(i int64) { - if m.addmanager_id != nil { - *m.addmanager_id += i - } else { - m.addmanager_id = &i +// RemovedUserPositions returns the removed IDs of the "user_positions" edge to the UserPosition entity. +func (m *UserMutation) RemovedUserPositionsIDs() (ids []int) { + for id := range m.removeduser_positions { + ids = append(ids, id) } + return } -// AddedManagerID returns the value that was added to the "manager_id" field in this mutation. -func (m *UserMutation) AddedManagerID() (r int64, exists bool) { - v := m.addmanager_id - if v == nil { - return +// UserPositionsIDs returns the "user_positions" edge IDs in the mutation. +func (m *UserMutation) UserPositionsIDs() (ids []int) { + for id := range m.user_positions { + ids = append(ids, id) } - return *v, true + return } -// ClearManagerID clears the value of the "manager_id" field. -func (m *UserMutation) ClearManagerID() { - m.manager_id = nil - m.addmanager_id = nil - m.clearedFields[user.FieldManagerID] = struct{}{} +// ResetUserPositions resets all changes to the "user_positions" edge. +func (m *UserMutation) ResetUserPositions() { + m.user_positions = nil + m.cleareduser_positions = false + m.removeduser_positions = nil } -// ManagerIDCleared returns if the "manager_id" field was cleared in this mutation. -func (m *UserMutation) ManagerIDCleared() bool { - _, ok := m.clearedFields[user.FieldManagerID] - return ok +// AddUserDepartmentIDs adds the "user_departments" edge to the UserDepartment entity by ids. +func (m *UserMutation) AddUserDepartmentIDs(ids ...int) { + if m.user_departments == nil { + m.user_departments = make(map[int]struct{}) + } + for i := range ids { + m.user_departments[ids[i]] = struct{}{} + } } -// ResetManagerID resets all changes to the "manager_id" field. -func (m *UserMutation) ResetManagerID() { - m.manager_id = nil - m.addmanager_id = nil - delete(m.clearedFields, user.FieldManagerID) -} - -// SetManager sets the "manager" field. -func (m *UserMutation) SetManager(s string) { - m.manager = &s -} - -// Manager returns the value of the "manager" field in the mutation. -func (m *UserMutation) Manager() (r string, exists bool) { - v := m.manager - if v == nil { - return - } - return *v, true -} - -// OldManager returns the old "manager" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldManager(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManager is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManager requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldManager: %w", err) - } - return oldValue.Manager, nil -} - -// ResetManager resets all changes to the "manager" field. -func (m *UserMutation) ResetManager() { - m.manager = nil -} - -// AddRoleIDs adds the "roles" edge to the Role entity by ids. -func (m *UserMutation) AddRoleIDs(ids ...int64) { - if m.roles == nil { - m.roles = make(map[int64]struct{}) - } - for i := range ids { - m.roles[ids[i]] = struct{}{} - } -} - -// ClearRoles clears the "roles" edge to the Role entity. -func (m *UserMutation) ClearRoles() { - m.clearedroles = true +// ClearUserDepartments clears the "user_departments" edge to the UserDepartment entity. +func (m *UserMutation) ClearUserDepartments() { + m.cleareduser_departments = true } -// RolesCleared reports if the "roles" edge to the Role entity was cleared. -func (m *UserMutation) RolesCleared() bool { - return m.clearedroles +// UserDepartmentsCleared reports if the "user_departments" edge to the UserDepartment entity was cleared. +func (m *UserMutation) UserDepartmentsCleared() bool { + return m.cleareduser_departments } -// RemoveRoleIDs removes the "roles" edge to the Role entity by IDs. -func (m *UserMutation) RemoveRoleIDs(ids ...int64) { - if m.removedroles == nil { - m.removedroles = make(map[int64]struct{}) +// RemoveUserDepartmentIDs removes the "user_departments" edge to the UserDepartment entity by IDs. +func (m *UserMutation) RemoveUserDepartmentIDs(ids ...int) { + if m.removeduser_departments == nil { + m.removeduser_departments = make(map[int]struct{}) } for i := range ids { - delete(m.roles, ids[i]) - m.removedroles[ids[i]] = struct{}{} + delete(m.user_departments, ids[i]) + m.removeduser_departments[ids[i]] = struct{}{} } } -// RemovedRoles returns the removed IDs of the "roles" edge to the Role entity. -func (m *UserMutation) RemovedRolesIDs() (ids []int64) { - for id := range m.removedroles { +// RemovedUserDepartments returns the removed IDs of the "user_departments" edge to the UserDepartment entity. +func (m *UserMutation) RemovedUserDepartmentsIDs() (ids []int) { + for id := range m.removeduser_departments { ids = append(ids, id) } return } -// RolesIDs returns the "roles" edge IDs in the mutation. -func (m *UserMutation) RolesIDs() (ids []int64) { - for id := range m.roles { +// UserDepartmentsIDs returns the "user_departments" edge IDs in the mutation. +func (m *UserMutation) UserDepartmentsIDs() (ids []int) { + for id := range m.user_departments { ids = append(ids, id) } return } -// ResetRoles resets all changes to the "roles" edge. -func (m *UserMutation) ResetRoles() { - m.roles = nil - m.clearedroles = false - m.removedroles = nil -} - -// AddPositionIDs adds the "positions" edge to the Position entity by ids. -func (m *UserMutation) AddPositionIDs(ids ...int64) { - if m.positions == nil { - m.positions = make(map[int64]struct{}) - } - for i := range ids { - m.positions[ids[i]] = struct{}{} - } -} - -// ClearPositions clears the "positions" edge to the Position entity. -func (m *UserMutation) ClearPositions() { - m.clearedpositions = true +// ResetUserDepartments resets all changes to the "user_departments" edge. +func (m *UserMutation) ResetUserDepartments() { + m.user_departments = nil + m.cleareduser_departments = false + m.removeduser_departments = nil } -// PositionsCleared reports if the "positions" edge to the Position entity was cleared. -func (m *UserMutation) PositionsCleared() bool { - return m.clearedpositions +// Where appends a list predicates to the UserMutation builder. +func (m *UserMutation) Where(ps ...predicate.User) { + m.predicates = append(m.predicates, ps...) } -// RemovePositionIDs removes the "positions" edge to the Position entity by IDs. -func (m *UserMutation) RemovePositionIDs(ids ...int64) { - if m.removedpositions == nil { - m.removedpositions = make(map[int64]struct{}) - } - for i := range ids { - delete(m.positions, ids[i]) - m.removedpositions[ids[i]] = struct{}{} +// WhereP appends storage-level predicates to the UserMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.User, len(ps)) + for i := range ps { + p[i] = ps[i] } + m.Where(p...) } -// RemovedPositions returns the removed IDs of the "positions" edge to the Position entity. -func (m *UserMutation) RemovedPositionsIDs() (ids []int64) { - for id := range m.removedpositions { - ids = append(ids, id) - } - return +// Op returns the operation name. +func (m *UserMutation) Op() Op { + return m.op } -// PositionsIDs returns the "positions" edge IDs in the mutation. -func (m *UserMutation) PositionsIDs() (ids []int64) { - for id := range m.positions { - ids = append(ids, id) - } - return +// SetOp allows setting the mutation operation. +func (m *UserMutation) SetOp(op Op) { + m.op = op } -// ResetPositions resets all changes to the "positions" edge. -func (m *UserMutation) ResetPositions() { - m.positions = nil - m.clearedpositions = false - m.removedpositions = nil +// Type returns the node type of this mutation (User). +func (m *UserMutation) Type() string { + return m.typ } -// AddDepartmentIDs adds the "departments" edge to the Department entity by ids. -func (m *UserMutation) AddDepartmentIDs(ids ...int64) { - if m.departments == nil { - m.departments = make(map[int64]struct{}) +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UserMutation) Fields() []string { + fields := make([]string, 0, 27) + if m.create_author != nil { + fields = append(fields, user.FieldCreateAuthor) } - for i := range ids { - m.departments[ids[i]] = struct{}{} + if m.update_author != nil { + fields = append(fields, user.FieldUpdateAuthor) } -} - -// ClearDepartments clears the "departments" edge to the Department entity. -func (m *UserMutation) ClearDepartments() { - m.cleareddepartments = true -} - -// DepartmentsCleared reports if the "departments" edge to the Department entity was cleared. -func (m *UserMutation) DepartmentsCleared() bool { - return m.cleareddepartments -} - -// RemoveDepartmentIDs removes the "departments" edge to the Department entity by IDs. -func (m *UserMutation) RemoveDepartmentIDs(ids ...int64) { - if m.removeddepartments == nil { - m.removeddepartments = make(map[int64]struct{}) + if m.create_time != nil { + fields = append(fields, user.FieldCreateTime) } - for i := range ids { - delete(m.departments, ids[i]) - m.removeddepartments[ids[i]] = struct{}{} + if m.update_time != nil { + fields = append(fields, user.FieldUpdateTime) } -} - -// RemovedDepartments returns the removed IDs of the "departments" edge to the Department entity. -func (m *UserMutation) RemovedDepartmentsIDs() (ids []int64) { - for id := range m.removeddepartments { - ids = append(ids, id) + if m.delete_time != nil { + fields = append(fields, user.FieldDeleteTime) } - return -} - -// DepartmentsIDs returns the "departments" edge IDs in the mutation. -func (m *UserMutation) DepartmentsIDs() (ids []int64) { - for id := range m.departments { - ids = append(ids, id) + if m.uuid != nil { + fields = append(fields, user.FieldUUID) } - return -} - -// ResetDepartments resets all changes to the "departments" edge. -func (m *UserMutation) ResetDepartments() { - m.departments = nil - m.cleareddepartments = false - m.removeddepartments = nil -} - -// AddUserRoleIDs adds the "user_roles" edge to the UserRole entity by ids. -func (m *UserMutation) AddUserRoleIDs(ids ...int) { - if m.user_roles == nil { - m.user_roles = make(map[int]struct{}) + if m.allowed_ip != nil { + fields = append(fields, user.FieldAllowedIP) } - for i := range ids { - m.user_roles[ids[i]] = struct{}{} + if m.username != nil { + fields = append(fields, user.FieldUsername) } -} - -// ClearUserRoles clears the "user_roles" edge to the UserRole entity. -func (m *UserMutation) ClearUserRoles() { - m.cleareduser_roles = true -} - -// UserRolesCleared reports if the "user_roles" edge to the UserRole entity was cleared. -func (m *UserMutation) UserRolesCleared() bool { - return m.cleareduser_roles -} - -// RemoveUserRoleIDs removes the "user_roles" edge to the UserRole entity by IDs. -func (m *UserMutation) RemoveUserRoleIDs(ids ...int) { - if m.removeduser_roles == nil { - m.removeduser_roles = make(map[int]struct{}) - } - for i := range ids { - delete(m.user_roles, ids[i]) - m.removeduser_roles[ids[i]] = struct{}{} - } -} - -// RemovedUserRoles returns the removed IDs of the "user_roles" edge to the UserRole entity. -func (m *UserMutation) RemovedUserRolesIDs() (ids []int) { - for id := range m.removeduser_roles { - ids = append(ids, id) - } - return -} - -// UserRolesIDs returns the "user_roles" edge IDs in the mutation. -func (m *UserMutation) UserRolesIDs() (ids []int) { - for id := range m.user_roles { - ids = append(ids, id) - } - return -} - -// ResetUserRoles resets all changes to the "user_roles" edge. -func (m *UserMutation) ResetUserRoles() { - m.user_roles = nil - m.cleareduser_roles = false - m.removeduser_roles = nil -} - -// AddUserPositionIDs adds the "user_positions" edge to the UserPosition entity by ids. -func (m *UserMutation) AddUserPositionIDs(ids ...int) { - if m.user_positions == nil { - m.user_positions = make(map[int]struct{}) - } - for i := range ids { - m.user_positions[ids[i]] = struct{}{} - } -} - -// ClearUserPositions clears the "user_positions" edge to the UserPosition entity. -func (m *UserMutation) ClearUserPositions() { - m.cleareduser_positions = true -} - -// UserPositionsCleared reports if the "user_positions" edge to the UserPosition entity was cleared. -func (m *UserMutation) UserPositionsCleared() bool { - return m.cleareduser_positions -} - -// RemoveUserPositionIDs removes the "user_positions" edge to the UserPosition entity by IDs. -func (m *UserMutation) RemoveUserPositionIDs(ids ...int) { - if m.removeduser_positions == nil { - m.removeduser_positions = make(map[int]struct{}) - } - for i := range ids { - delete(m.user_positions, ids[i]) - m.removeduser_positions[ids[i]] = struct{}{} - } -} - -// RemovedUserPositions returns the removed IDs of the "user_positions" edge to the UserPosition entity. -func (m *UserMutation) RemovedUserPositionsIDs() (ids []int) { - for id := range m.removeduser_positions { - ids = append(ids, id) - } - return -} - -// UserPositionsIDs returns the "user_positions" edge IDs in the mutation. -func (m *UserMutation) UserPositionsIDs() (ids []int) { - for id := range m.user_positions { - ids = append(ids, id) - } - return -} - -// ResetUserPositions resets all changes to the "user_positions" edge. -func (m *UserMutation) ResetUserPositions() { - m.user_positions = nil - m.cleareduser_positions = false - m.removeduser_positions = nil -} - -// AddUserDepartmentIDs adds the "user_departments" edge to the UserDepartment entity by ids. -func (m *UserMutation) AddUserDepartmentIDs(ids ...int) { - if m.user_departments == nil { - m.user_departments = make(map[int]struct{}) - } - for i := range ids { - m.user_departments[ids[i]] = struct{}{} - } -} - -// ClearUserDepartments clears the "user_departments" edge to the UserDepartment entity. -func (m *UserMutation) ClearUserDepartments() { - m.cleareduser_departments = true -} - -// UserDepartmentsCleared reports if the "user_departments" edge to the UserDepartment entity was cleared. -func (m *UserMutation) UserDepartmentsCleared() bool { - return m.cleareduser_departments -} - -// RemoveUserDepartmentIDs removes the "user_departments" edge to the UserDepartment entity by IDs. -func (m *UserMutation) RemoveUserDepartmentIDs(ids ...int) { - if m.removeduser_departments == nil { - m.removeduser_departments = make(map[int]struct{}) - } - for i := range ids { - delete(m.user_departments, ids[i]) - m.removeduser_departments[ids[i]] = struct{}{} - } -} - -// RemovedUserDepartments returns the removed IDs of the "user_departments" edge to the UserDepartment entity. -func (m *UserMutation) RemovedUserDepartmentsIDs() (ids []int) { - for id := range m.removeduser_departments { - ids = append(ids, id) - } - return -} - -// UserDepartmentsIDs returns the "user_departments" edge IDs in the mutation. -func (m *UserMutation) UserDepartmentsIDs() (ids []int) { - for id := range m.user_departments { - ids = append(ids, id) - } - return -} - -// ResetUserDepartments resets all changes to the "user_departments" edge. -func (m *UserMutation) ResetUserDepartments() { - m.user_departments = nil - m.cleareduser_departments = false - m.removeduser_departments = nil -} - -// Where appends a list predicates to the UserMutation builder. -func (m *UserMutation) Where(ps ...predicate.User) { - m.predicates = append(m.predicates, ps...) -} - -// WhereP appends storage-level predicates to the UserMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *UserMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.User, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) -} - -// Op returns the operation name. -func (m *UserMutation) Op() Op { - return m.op -} - -// SetOp allows setting the mutation operation. -func (m *UserMutation) SetOp(op Op) { - m.op = op -} - -// Type returns the node type of this mutation (User). -func (m *UserMutation) Type() string { - return m.typ -} - -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 27) - if m.create_author != nil { - fields = append(fields, user.FieldCreateAuthor) - } - if m.update_author != nil { - fields = append(fields, user.FieldUpdateAuthor) - } - if m.create_time != nil { - fields = append(fields, user.FieldCreateTime) - } - if m.update_time != nil { - fields = append(fields, user.FieldUpdateTime) - } - if m.delete_time != nil { - fields = append(fields, user.FieldDeleteTime) - } - if m.uuid != nil { - fields = append(fields, user.FieldUUID) - } - if m.allowed_ip != nil { - fields = append(fields, user.FieldAllowedIP) - } - if m.username != nil { - fields = append(fields, user.FieldUsername) - } - if m.nickname != nil { - fields = append(fields, user.FieldNickname) + if m.nickname != nil { + fields = append(fields, user.FieldNickname) } if m.avatar != nil { fields = append(fields, user.FieldAvatar) @@ -11558,464 +11053,1430 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { m.SetManager(v) return nil } - return fmt.Errorf("unknown User field %s", name) + return fmt.Errorf("unknown User field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserMutation) AddedFields() []string { + var fields []string + if m.addcreate_author != nil { + fields = append(fields, user.FieldCreateAuthor) + } + if m.addupdate_author != nil { + fields = append(fields, user.FieldUpdateAuthor) + } + if m.addstatus != nil { + fields = append(fields, user.FieldStatus) + } + if m.addmanager_id != nil { + fields = append(fields, user.FieldManagerID) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UserMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case user.FieldCreateAuthor: + return m.AddedCreateAuthor() + case user.FieldUpdateAuthor: + return m.AddedUpdateAuthor() + case user.FieldStatus: + return m.AddedStatus() + case user.FieldManagerID: + return m.AddedManagerID() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) AddField(name string, value ent.Value) error { + switch name { + case user.FieldCreateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCreateAuthor(v) + return nil + case user.FieldUpdateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUpdateAuthor(v) + return nil + case user.FieldStatus: + v, ok := value.(int8) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil + case user.FieldManagerID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddManagerID(v) + return nil + } + return fmt.Errorf("unknown User numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(user.FieldCreateAuthor) { + fields = append(fields, user.FieldCreateAuthor) + } + if m.FieldCleared(user.FieldUpdateAuthor) { + fields = append(fields, user.FieldUpdateAuthor) + } + if m.FieldCleared(user.FieldDeleteTime) { + fields = append(fields, user.FieldDeleteTime) + } + if m.FieldCleared(user.FieldSanctionDate) { + fields = append(fields, user.FieldSanctionDate) + } + if m.FieldCleared(user.FieldManagerID) { + fields = append(fields, user.FieldManagerID) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UserMutation) ClearField(name string) error { + switch name { + case user.FieldCreateAuthor: + m.ClearCreateAuthor() + return nil + case user.FieldUpdateAuthor: + m.ClearUpdateAuthor() + return nil + case user.FieldDeleteTime: + m.ClearDeleteTime() + return nil + case user.FieldSanctionDate: + m.ClearSanctionDate() + return nil + case user.FieldManagerID: + m.ClearManagerID() + return nil + } + return fmt.Errorf("unknown User nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *UserMutation) ResetField(name string) error { + switch name { + case user.FieldCreateAuthor: + m.ResetCreateAuthor() + return nil + case user.FieldUpdateAuthor: + m.ResetUpdateAuthor() + return nil + case user.FieldCreateTime: + m.ResetCreateTime() + return nil + case user.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case user.FieldDeleteTime: + m.ResetDeleteTime() + return nil + case user.FieldUUID: + m.ResetUUID() + return nil + case user.FieldAllowedIP: + m.ResetAllowedIP() + return nil + case user.FieldUsername: + m.ResetUsername() + return nil + case user.FieldNickname: + m.ResetNickname() + return nil + case user.FieldAvatar: + m.ResetAvatar() + return nil + case user.FieldName: + m.ResetName() + return nil + case user.FieldGender: + m.ResetGender() + return nil + case user.FieldEncryptedPassword: + m.ResetEncryptedPassword() + return nil + case user.FieldSalt: + m.ResetSalt() + return nil + case user.FieldPhone: + m.ResetPhone() + return nil + case user.FieldEmail: + m.ResetEmail() + return nil + case user.FieldDepartment: + m.ResetDepartment() + return nil + case user.FieldRemark: + m.ResetRemark() + return nil + case user.FieldToken: + m.ResetToken() + return nil + case user.FieldStatus: + m.ResetStatus() + return nil + case user.FieldIsSystem: + m.ResetIsSystem() + return nil + case user.FieldLastLoginIP: + m.ResetLastLoginIP() + return nil + case user.FieldLastLoginTime: + m.ResetLastLoginTime() + return nil + case user.FieldLoginTime: + m.ResetLoginTime() + return nil + case user.FieldSanctionDate: + m.ResetSanctionDate() + return nil + case user.FieldManagerID: + m.ResetManagerID() + return nil + case user.FieldManager: + m.ResetManager() + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserMutation) AddedEdges() []string { + edges := make([]string, 0, 6) + if m.roles != nil { + edges = append(edges, user.EdgeRoles) + } + if m.positions != nil { + edges = append(edges, user.EdgePositions) + } + if m.departments != nil { + edges = append(edges, user.EdgeDepartments) + } + if m.user_roles != nil { + edges = append(edges, user.EdgeUserRoles) + } + if m.user_positions != nil { + edges = append(edges, user.EdgeUserPositions) + } + if m.user_departments != nil { + edges = append(edges, user.EdgeUserDepartments) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserMutation) AddedIDs(name string) []ent.Value { + switch name { + case user.EdgeRoles: + ids := make([]ent.Value, 0, len(m.roles)) + for id := range m.roles { + ids = append(ids, id) + } + return ids + case user.EdgePositions: + ids := make([]ent.Value, 0, len(m.positions)) + for id := range m.positions { + ids = append(ids, id) + } + return ids + case user.EdgeDepartments: + ids := make([]ent.Value, 0, len(m.departments)) + for id := range m.departments { + ids = append(ids, id) + } + return ids + case user.EdgeUserRoles: + ids := make([]ent.Value, 0, len(m.user_roles)) + for id := range m.user_roles { + ids = append(ids, id) + } + return ids + case user.EdgeUserPositions: + ids := make([]ent.Value, 0, len(m.user_positions)) + for id := range m.user_positions { + ids = append(ids, id) + } + return ids + case user.EdgeUserDepartments: + ids := make([]ent.Value, 0, len(m.user_departments)) + for id := range m.user_departments { + ids = append(ids, id) + } + return ids + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserMutation) RemovedEdges() []string { + edges := make([]string, 0, 6) + if m.removedroles != nil { + edges = append(edges, user.EdgeRoles) + } + if m.removedpositions != nil { + edges = append(edges, user.EdgePositions) + } + if m.removeddepartments != nil { + edges = append(edges, user.EdgeDepartments) + } + if m.removeduser_roles != nil { + edges = append(edges, user.EdgeUserRoles) + } + if m.removeduser_positions != nil { + edges = append(edges, user.EdgeUserPositions) + } + if m.removeduser_departments != nil { + edges = append(edges, user.EdgeUserDepartments) + } + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserMutation) RemovedIDs(name string) []ent.Value { + switch name { + case user.EdgeRoles: + ids := make([]ent.Value, 0, len(m.removedroles)) + for id := range m.removedroles { + ids = append(ids, id) + } + return ids + case user.EdgePositions: + ids := make([]ent.Value, 0, len(m.removedpositions)) + for id := range m.removedpositions { + ids = append(ids, id) + } + return ids + case user.EdgeDepartments: + ids := make([]ent.Value, 0, len(m.removeddepartments)) + for id := range m.removeddepartments { + ids = append(ids, id) + } + return ids + case user.EdgeUserRoles: + ids := make([]ent.Value, 0, len(m.removeduser_roles)) + for id := range m.removeduser_roles { + ids = append(ids, id) + } + return ids + case user.EdgeUserPositions: + ids := make([]ent.Value, 0, len(m.removeduser_positions)) + for id := range m.removeduser_positions { + ids = append(ids, id) + } + return ids + case user.EdgeUserDepartments: + ids := make([]ent.Value, 0, len(m.removeduser_departments)) + for id := range m.removeduser_departments { + ids = append(ids, id) + } + return ids + } + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserMutation) ClearedEdges() []string { + edges := make([]string, 0, 6) + if m.clearedroles { + edges = append(edges, user.EdgeRoles) + } + if m.clearedpositions { + edges = append(edges, user.EdgePositions) + } + if m.cleareddepartments { + edges = append(edges, user.EdgeDepartments) + } + if m.cleareduser_roles { + edges = append(edges, user.EdgeUserRoles) + } + if m.cleareduser_positions { + edges = append(edges, user.EdgeUserPositions) + } + if m.cleareduser_departments { + edges = append(edges, user.EdgeUserDepartments) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserMutation) EdgeCleared(name string) bool { + switch name { + case user.EdgeRoles: + return m.clearedroles + case user.EdgePositions: + return m.clearedpositions + case user.EdgeDepartments: + return m.cleareddepartments + case user.EdgeUserRoles: + return m.cleareduser_roles + case user.EdgeUserPositions: + return m.cleareduser_positions + case user.EdgeUserDepartments: + return m.cleareduser_departments + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserMutation) ClearEdge(name string) error { + switch name { + } + return fmt.Errorf("unknown User unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *UserMutation) ResetEdge(name string) error { + switch name { + case user.EdgeRoles: + m.ResetRoles() + return nil + case user.EdgePositions: + m.ResetPositions() + return nil + case user.EdgeDepartments: + m.ResetDepartments() + return nil + case user.EdgeUserRoles: + m.ResetUserRoles() + return nil + case user.EdgeUserPositions: + m.ResetUserPositions() + return nil + case user.EdgeUserDepartments: + m.ResetUserDepartments() + return nil + } + return fmt.Errorf("unknown User edge %s", name) +} + +// UserDepartmentMutation represents an operation that mutates the UserDepartment nodes in the graph. +type UserDepartmentMutation struct { + config + op Op + typ string + id *int + clearedFields map[string]struct{} + user *int64 + cleareduser bool + department *int64 + cleareddepartment bool + done bool + oldValue func(context.Context) (*UserDepartment, error) + predicates []predicate.UserDepartment +} + +var _ ent.Mutation = (*UserDepartmentMutation)(nil) + +// userdepartmentOption allows management of the mutation configuration using functional options. +type userdepartmentOption func(*UserDepartmentMutation) + +// newUserDepartmentMutation creates new mutation for the UserDepartment entity. +func newUserDepartmentMutation(c config, op Op, opts ...userdepartmentOption) *UserDepartmentMutation { + m := &UserDepartmentMutation{ + config: c, + op: op, + typ: TypeUserDepartment, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserDepartmentID sets the ID field of the mutation. +func withUserDepartmentID(id int) userdepartmentOption { + return func(m *UserDepartmentMutation) { + var ( + err error + once sync.Once + value *UserDepartment + ) + m.oldValue = func(ctx context.Context) (*UserDepartment, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().UserDepartment.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUserDepartment sets the old UserDepartment of the mutation. +func withUserDepartment(node *UserDepartment) userdepartmentOption { + return func(m *UserDepartmentMutation) { + m.oldValue = func(context.Context) (*UserDepartment, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m UserDepartmentMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m UserDepartmentMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *UserDepartmentMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *UserDepartmentMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().UserDepartment.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetUserID sets the "user_id" field. +func (m *UserDepartmentMutation) SetUserID(i int64) { + m.user = &i +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *UserDepartmentMutation) UserID() (r int64, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the UserDepartment entity. +// If the UserDepartment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserDepartmentMutation) OldUserID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *UserDepartmentMutation) ResetUserID() { + m.user = nil +} + +// SetDepartmentID sets the "department_id" field. +func (m *UserDepartmentMutation) SetDepartmentID(i int64) { + m.department = &i +} + +// DepartmentID returns the value of the "department_id" field in the mutation. +func (m *UserDepartmentMutation) DepartmentID() (r int64, exists bool) { + v := m.department + if v == nil { + return + } + return *v, true +} + +// OldDepartmentID returns the old "department_id" field's value of the UserDepartment entity. +// If the UserDepartment object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserDepartmentMutation) OldDepartmentID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDepartmentID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDepartmentID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDepartmentID: %w", err) + } + return oldValue.DepartmentID, nil +} + +// ResetDepartmentID resets all changes to the "department_id" field. +func (m *UserDepartmentMutation) ResetDepartmentID() { + m.department = nil +} + +// ClearUser clears the "user" edge to the User entity. +func (m *UserDepartmentMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[userdepartment.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *UserDepartmentMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *UserDepartmentMutation) UserIDs() (ids []int64) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *UserDepartmentMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// ClearDepartment clears the "department" edge to the Department entity. +func (m *UserDepartmentMutation) ClearDepartment() { + m.cleareddepartment = true + m.clearedFields[userdepartment.FieldDepartmentID] = struct{}{} +} + +// DepartmentCleared reports if the "department" edge to the Department entity was cleared. +func (m *UserDepartmentMutation) DepartmentCleared() bool { + return m.cleareddepartment +} + +// DepartmentIDs returns the "department" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// DepartmentID instead. It exists only for internal usage by the builders. +func (m *UserDepartmentMutation) DepartmentIDs() (ids []int64) { + if id := m.department; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetDepartment resets all changes to the "department" edge. +func (m *UserDepartmentMutation) ResetDepartment() { + m.department = nil + m.cleareddepartment = false +} + +// Where appends a list predicates to the UserDepartmentMutation builder. +func (m *UserDepartmentMutation) Where(ps ...predicate.UserDepartment) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserDepartmentMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserDepartmentMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserDepartment, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserDepartmentMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserDepartmentMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (UserDepartment). +func (m *UserDepartmentMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UserDepartmentMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.user != nil { + fields = append(fields, userdepartment.FieldUserID) + } + if m.department != nil { + fields = append(fields, userdepartment.FieldDepartmentID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UserDepartmentMutation) Field(name string) (ent.Value, bool) { + switch name { + case userdepartment.FieldUserID: + return m.UserID() + case userdepartment.FieldDepartmentID: + return m.DepartmentID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *UserDepartmentMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case userdepartment.FieldUserID: + return m.OldUserID(ctx) + case userdepartment.FieldDepartmentID: + return m.OldDepartmentID(ctx) + } + return nil, fmt.Errorf("unknown UserDepartment field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserDepartmentMutation) SetField(name string, value ent.Value) error { + switch name { + case userdepartment.FieldUserID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserID(v) + return nil + case userdepartment.FieldDepartmentID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDepartmentID(v) + return nil + } + return fmt.Errorf("unknown UserDepartment field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserDepartmentMutation) AddedFields() []string { + var fields []string + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UserDepartmentMutation) AddedField(name string) (ent.Value, bool) { + switch name { + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserDepartmentMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown UserDepartment numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserDepartmentMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserDepartmentMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UserDepartmentMutation) ClearField(name string) error { + return fmt.Errorf("unknown UserDepartment nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *UserDepartmentMutation) ResetField(name string) error { + switch name { + case userdepartment.FieldUserID: + m.ResetUserID() + return nil + case userdepartment.FieldDepartmentID: + m.ResetDepartmentID() + return nil + } + return fmt.Errorf("unknown UserDepartment field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserDepartmentMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.user != nil { + edges = append(edges, userdepartment.EdgeUser) + } + if m.department != nil { + edges = append(edges, userdepartment.EdgeDepartment) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserDepartmentMutation) AddedIDs(name string) []ent.Value { + switch name { + case userdepartment.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} + } + case userdepartment.EdgeDepartment: + if id := m.department; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserDepartmentMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserDepartmentMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserDepartmentMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.cleareduser { + edges = append(edges, userdepartment.EdgeUser) + } + if m.cleareddepartment { + edges = append(edges, userdepartment.EdgeDepartment) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserDepartmentMutation) EdgeCleared(name string) bool { + switch name { + case userdepartment.EdgeUser: + return m.cleareduser + case userdepartment.EdgeDepartment: + return m.cleareddepartment + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserDepartmentMutation) ClearEdge(name string) error { + switch name { + case userdepartment.EdgeUser: + m.ClearUser() + return nil + case userdepartment.EdgeDepartment: + m.ClearDepartment() + return nil + } + return fmt.Errorf("unknown UserDepartment unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *UserDepartmentMutation) ResetEdge(name string) error { + switch name { + case userdepartment.EdgeUser: + m.ResetUser() + return nil + case userdepartment.EdgeDepartment: + m.ResetDepartment() + return nil + } + return fmt.Errorf("unknown UserDepartment edge %s", name) +} + +// UserPositionMutation represents an operation that mutates the UserPosition nodes in the graph. +type UserPositionMutation struct { + config + op Op + typ string + id *int + clearedFields map[string]struct{} + user *int64 + cleareduser bool + position *int64 + clearedposition bool + done bool + oldValue func(context.Context) (*UserPosition, error) + predicates []predicate.UserPosition +} + +var _ ent.Mutation = (*UserPositionMutation)(nil) + +// userpositionOption allows management of the mutation configuration using functional options. +type userpositionOption func(*UserPositionMutation) + +// newUserPositionMutation creates new mutation for the UserPosition entity. +func newUserPositionMutation(c config, op Op, opts ...userpositionOption) *UserPositionMutation { + m := &UserPositionMutation{ + config: c, + op: op, + typ: TypeUserPosition, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserPositionID sets the ID field of the mutation. +func withUserPositionID(id int) userpositionOption { + return func(m *UserPositionMutation) { + var ( + err error + once sync.Once + value *UserPosition + ) + m.oldValue = func(ctx context.Context) (*UserPosition, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().UserPosition.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUserPosition sets the old UserPosition of the mutation. +func withUserPosition(node *UserPosition) userpositionOption { + return func(m *UserPositionMutation) { + m.oldValue = func(context.Context) (*UserPosition, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m UserPositionMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m UserPositionMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *UserPositionMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *UserPositionMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().UserPosition.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetUserID sets the "user_id" field. +func (m *UserPositionMutation) SetUserID(i int64) { + m.user = &i +} + +// UserID returns the value of the "user_id" field in the mutation. +func (m *UserPositionMutation) UserID() (r int64, exists bool) { + v := m.user + if v == nil { + return + } + return *v, true +} + +// OldUserID returns the old "user_id" field's value of the UserPosition entity. +// If the UserPosition object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserPositionMutation) OldUserID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserID: %w", err) + } + return oldValue.UserID, nil +} + +// ResetUserID resets all changes to the "user_id" field. +func (m *UserPositionMutation) ResetUserID() { + m.user = nil +} + +// SetPositionID sets the "position_id" field. +func (m *UserPositionMutation) SetPositionID(i int64) { + m.position = &i +} + +// PositionID returns the value of the "position_id" field in the mutation. +func (m *UserPositionMutation) PositionID() (r int64, exists bool) { + v := m.position + if v == nil { + return + } + return *v, true } -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *UserMutation) AddedFields() []string { - var fields []string - if m.addcreate_author != nil { - fields = append(fields, user.FieldCreateAuthor) +// OldPositionID returns the old "position_id" field's value of the UserPosition entity. +// If the UserPosition object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserPositionMutation) OldPositionID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPositionID is only allowed on UpdateOne operations") } - if m.addupdate_author != nil { - fields = append(fields, user.FieldUpdateAuthor) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPositionID requires an ID field in the mutation") } - if m.addstatus != nil { - fields = append(fields, user.FieldStatus) + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPositionID: %w", err) } - if m.addmanager_id != nil { - fields = append(fields, user.FieldManagerID) + return oldValue.PositionID, nil +} + +// ResetPositionID resets all changes to the "position_id" field. +func (m *UserPositionMutation) ResetPositionID() { + m.position = nil +} + +// ClearUser clears the "user" edge to the User entity. +func (m *UserPositionMutation) ClearUser() { + m.cleareduser = true + m.clearedFields[userposition.FieldUserID] = struct{}{} +} + +// UserCleared reports if the "user" edge to the User entity was cleared. +func (m *UserPositionMutation) UserCleared() bool { + return m.cleareduser +} + +// UserIDs returns the "user" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// UserID instead. It exists only for internal usage by the builders. +func (m *UserPositionMutation) UserIDs() (ids []int64) { + if id := m.user; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetUser resets all changes to the "user" edge. +func (m *UserPositionMutation) ResetUser() { + m.user = nil + m.cleareduser = false +} + +// ClearPosition clears the "position" edge to the Position entity. +func (m *UserPositionMutation) ClearPosition() { + m.clearedposition = true + m.clearedFields[userposition.FieldPositionID] = struct{}{} +} + +// PositionCleared reports if the "position" edge to the Position entity was cleared. +func (m *UserPositionMutation) PositionCleared() bool { + return m.clearedposition +} + +// PositionIDs returns the "position" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PositionID instead. It exists only for internal usage by the builders. +func (m *UserPositionMutation) PositionIDs() (ids []int64) { + if id := m.position; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetPosition resets all changes to the "position" edge. +func (m *UserPositionMutation) ResetPosition() { + m.position = nil + m.clearedposition = false +} + +// Where appends a list predicates to the UserPositionMutation builder. +func (m *UserPositionMutation) Where(ps ...predicate.UserPosition) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the UserPositionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *UserPositionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserPosition, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *UserPositionMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *UserPositionMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (UserPosition). +func (m *UserPositionMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UserPositionMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.user != nil { + fields = append(fields, userposition.FieldUserID) + } + if m.position != nil { + fields = append(fields, userposition.FieldPositionID) } return fields } -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *UserMutation) AddedField(name string) (ent.Value, bool) { +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UserPositionMutation) Field(name string) (ent.Value, bool) { switch name { - case user.FieldCreateAuthor: - return m.AddedCreateAuthor() - case user.FieldUpdateAuthor: - return m.AddedUpdateAuthor() - case user.FieldStatus: - return m.AddedStatus() - case user.FieldManagerID: - return m.AddedManagerID() + case userposition.FieldUserID: + return m.UserID() + case userposition.FieldPositionID: + return m.PositionID() } return nil, false } -// AddField adds the value to the field with the given name. It returns an error if +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *UserPositionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case userposition.FieldUserID: + return m.OldUserID(ctx) + case userposition.FieldPositionID: + return m.OldPositionID(ctx) + } + return nil, fmt.Errorf("unknown UserPosition field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *UserMutation) AddField(name string, value ent.Value) error { +func (m *UserPositionMutation) SetField(name string, value ent.Value) error { switch name { - case user.FieldCreateAuthor: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddCreateAuthor(v) - return nil - case user.FieldUpdateAuthor: + case userposition.FieldUserID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddUpdateAuthor(v) - return nil - case user.FieldStatus: - v, ok := value.(int8) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddStatus(v) + m.SetUserID(v) return nil - case user.FieldManagerID: + case userposition.FieldPositionID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddManagerID(v) + m.SetPositionID(v) return nil } - return fmt.Errorf("unknown User numeric field %s", name) + return fmt.Errorf("unknown UserPosition field %s", name) } -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *UserMutation) ClearedFields() []string { +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserPositionMutation) AddedFields() []string { var fields []string - if m.FieldCleared(user.FieldCreateAuthor) { - fields = append(fields, user.FieldCreateAuthor) - } - if m.FieldCleared(user.FieldUpdateAuthor) { - fields = append(fields, user.FieldUpdateAuthor) - } - if m.FieldCleared(user.FieldDeleteTime) { - fields = append(fields, user.FieldDeleteTime) - } - if m.FieldCleared(user.FieldSanctionDate) { - fields = append(fields, user.FieldSanctionDate) - } - if m.FieldCleared(user.FieldManagerID) { - fields = append(fields, user.FieldManagerID) - } return fields } -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *UserMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] - return ok +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UserPositionMutation) AddedField(name string) (ent.Value, bool) { + switch name { + } + return nil, false } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *UserMutation) ClearField(name string) error { +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserPositionMutation) AddField(name string, value ent.Value) error { switch name { - case user.FieldCreateAuthor: - m.ClearCreateAuthor() - return nil - case user.FieldUpdateAuthor: - m.ClearUpdateAuthor() - return nil - case user.FieldDeleteTime: - m.ClearDeleteTime() - return nil - case user.FieldSanctionDate: - m.ClearSanctionDate() - return nil - case user.FieldManagerID: - m.ClearManagerID() - return nil } - return fmt.Errorf("unknown User nullable field %s", name) + return fmt.Errorf("unknown UserPosition numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserPositionMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserPositionMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UserPositionMutation) ClearField(name string) error { + return fmt.Errorf("unknown UserPosition nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *UserMutation) ResetField(name string) error { +func (m *UserPositionMutation) ResetField(name string) error { switch name { - case user.FieldCreateAuthor: - m.ResetCreateAuthor() - return nil - case user.FieldUpdateAuthor: - m.ResetUpdateAuthor() - return nil - case user.FieldCreateTime: - m.ResetCreateTime() - return nil - case user.FieldUpdateTime: - m.ResetUpdateTime() - return nil - case user.FieldDeleteTime: - m.ResetDeleteTime() - return nil - case user.FieldUUID: - m.ResetUUID() - return nil - case user.FieldAllowedIP: - m.ResetAllowedIP() - return nil - case user.FieldUsername: - m.ResetUsername() - return nil - case user.FieldNickname: - m.ResetNickname() - return nil - case user.FieldAvatar: - m.ResetAvatar() - return nil - case user.FieldName: - m.ResetName() - return nil - case user.FieldGender: - m.ResetGender() - return nil - case user.FieldEncryptedPassword: - m.ResetEncryptedPassword() - return nil - case user.FieldSalt: - m.ResetSalt() - return nil - case user.FieldPhone: - m.ResetPhone() - return nil - case user.FieldEmail: - m.ResetEmail() - return nil - case user.FieldDepartment: - m.ResetDepartment() - return nil - case user.FieldRemark: - m.ResetRemark() - return nil - case user.FieldToken: - m.ResetToken() - return nil - case user.FieldStatus: - m.ResetStatus() - return nil - case user.FieldIsSystem: - m.ResetIsSystem() - return nil - case user.FieldLastLoginIP: - m.ResetLastLoginIP() - return nil - case user.FieldLastLoginTime: - m.ResetLastLoginTime() - return nil - case user.FieldLoginTime: - m.ResetLoginTime() - return nil - case user.FieldSanctionDate: - m.ResetSanctionDate() - return nil - case user.FieldManagerID: - m.ResetManagerID() + case userposition.FieldUserID: + m.ResetUserID() return nil - case user.FieldManager: - m.ResetManager() + case userposition.FieldPositionID: + m.ResetPositionID() return nil } - return fmt.Errorf("unknown User field %s", name) + return fmt.Errorf("unknown UserPosition field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *UserMutation) AddedEdges() []string { - edges := make([]string, 0, 6) - if m.roles != nil { - edges = append(edges, user.EdgeRoles) - } - if m.positions != nil { - edges = append(edges, user.EdgePositions) - } - if m.departments != nil { - edges = append(edges, user.EdgeDepartments) - } - if m.user_roles != nil { - edges = append(edges, user.EdgeUserRoles) - } - if m.user_positions != nil { - edges = append(edges, user.EdgeUserPositions) +func (m *UserPositionMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.user != nil { + edges = append(edges, userposition.EdgeUser) } - if m.user_departments != nil { - edges = append(edges, user.EdgeUserDepartments) + if m.position != nil { + edges = append(edges, userposition.EdgePosition) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *UserMutation) AddedIDs(name string) []ent.Value { +func (m *UserPositionMutation) AddedIDs(name string) []ent.Value { switch name { - case user.EdgeRoles: - ids := make([]ent.Value, 0, len(m.roles)) - for id := range m.roles { - ids = append(ids, id) - } - return ids - case user.EdgePositions: - ids := make([]ent.Value, 0, len(m.positions)) - for id := range m.positions { - ids = append(ids, id) - } - return ids - case user.EdgeDepartments: - ids := make([]ent.Value, 0, len(m.departments)) - for id := range m.departments { - ids = append(ids, id) - } - return ids - case user.EdgeUserRoles: - ids := make([]ent.Value, 0, len(m.user_roles)) - for id := range m.user_roles { - ids = append(ids, id) - } - return ids - case user.EdgeUserPositions: - ids := make([]ent.Value, 0, len(m.user_positions)) - for id := range m.user_positions { - ids = append(ids, id) + case userposition.EdgeUser: + if id := m.user; id != nil { + return []ent.Value{*id} } - return ids - case user.EdgeUserDepartments: - ids := make([]ent.Value, 0, len(m.user_departments)) - for id := range m.user_departments { - ids = append(ids, id) + case userposition.EdgePosition: + if id := m.position; id != nil { + return []ent.Value{*id} } - return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *UserMutation) RemovedEdges() []string { - edges := make([]string, 0, 6) - if m.removedroles != nil { - edges = append(edges, user.EdgeRoles) - } - if m.removedpositions != nil { - edges = append(edges, user.EdgePositions) - } - if m.removeddepartments != nil { - edges = append(edges, user.EdgeDepartments) - } - if m.removeduser_roles != nil { - edges = append(edges, user.EdgeUserRoles) - } - if m.removeduser_positions != nil { - edges = append(edges, user.EdgeUserPositions) - } - if m.removeduser_departments != nil { - edges = append(edges, user.EdgeUserDepartments) - } +func (m *UserPositionMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *UserMutation) RemovedIDs(name string) []ent.Value { - switch name { - case user.EdgeRoles: - ids := make([]ent.Value, 0, len(m.removedroles)) - for id := range m.removedroles { - ids = append(ids, id) - } - return ids - case user.EdgePositions: - ids := make([]ent.Value, 0, len(m.removedpositions)) - for id := range m.removedpositions { - ids = append(ids, id) - } - return ids - case user.EdgeDepartments: - ids := make([]ent.Value, 0, len(m.removeddepartments)) - for id := range m.removeddepartments { - ids = append(ids, id) - } - return ids - case user.EdgeUserRoles: - ids := make([]ent.Value, 0, len(m.removeduser_roles)) - for id := range m.removeduser_roles { - ids = append(ids, id) - } - return ids - case user.EdgeUserPositions: - ids := make([]ent.Value, 0, len(m.removeduser_positions)) - for id := range m.removeduser_positions { - ids = append(ids, id) - } - return ids - case user.EdgeUserDepartments: - ids := make([]ent.Value, 0, len(m.removeduser_departments)) - for id := range m.removeduser_departments { - ids = append(ids, id) - } - return ids - } +func (m *UserPositionMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *UserMutation) ClearedEdges() []string { - edges := make([]string, 0, 6) - if m.clearedroles { - edges = append(edges, user.EdgeRoles) - } - if m.clearedpositions { - edges = append(edges, user.EdgePositions) - } - if m.cleareddepartments { - edges = append(edges, user.EdgeDepartments) - } - if m.cleareduser_roles { - edges = append(edges, user.EdgeUserRoles) - } - if m.cleareduser_positions { - edges = append(edges, user.EdgeUserPositions) - } - if m.cleareduser_departments { - edges = append(edges, user.EdgeUserDepartments) +func (m *UserPositionMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.cleareduser { + edges = append(edges, userposition.EdgeUser) + } + if m.clearedposition { + edges = append(edges, userposition.EdgePosition) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *UserMutation) EdgeCleared(name string) bool { +func (m *UserPositionMutation) EdgeCleared(name string) bool { switch name { - case user.EdgeRoles: - return m.clearedroles - case user.EdgePositions: - return m.clearedpositions - case user.EdgeDepartments: - return m.cleareddepartments - case user.EdgeUserRoles: - return m.cleareduser_roles - case user.EdgeUserPositions: - return m.cleareduser_positions - case user.EdgeUserDepartments: - return m.cleareduser_departments + case userposition.EdgeUser: + return m.cleareduser + case userposition.EdgePosition: + return m.clearedposition } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *UserMutation) ClearEdge(name string) error { +func (m *UserPositionMutation) ClearEdge(name string) error { switch name { + case userposition.EdgeUser: + m.ClearUser() + return nil + case userposition.EdgePosition: + m.ClearPosition() + return nil } - return fmt.Errorf("unknown User unique edge %s", name) + return fmt.Errorf("unknown UserPosition unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *UserMutation) ResetEdge(name string) error { +func (m *UserPositionMutation) ResetEdge(name string) error { switch name { - case user.EdgeRoles: - m.ResetRoles() - return nil - case user.EdgePositions: - m.ResetPositions() - return nil - case user.EdgeDepartments: - m.ResetDepartments() - return nil - case user.EdgeUserRoles: - m.ResetUserRoles() - return nil - case user.EdgeUserPositions: - m.ResetUserPositions() + case userposition.EdgeUser: + m.ResetUser() return nil - case user.EdgeUserDepartments: - m.ResetUserDepartments() + case userposition.EdgePosition: + m.ResetPosition() return nil } - return fmt.Errorf("unknown User edge %s", name) + return fmt.Errorf("unknown UserPosition edge %s", name) } -// UserDepartmentMutation represents an operation that mutates the UserDepartment nodes in the graph. -type UserDepartmentMutation struct { +// UserRoleMutation represents an operation that mutates the UserRole nodes in the graph. +type UserRoleMutation struct { config - op Op - typ string - id *int - clearedFields map[string]struct{} - user *int64 - cleareduser bool - department *int64 - cleareddepartment bool - done bool - oldValue func(context.Context) (*UserDepartment, error) - predicates []predicate.UserDepartment + op Op + typ string + id *int + clearedFields map[string]struct{} + user *int64 + cleareduser bool + role *int64 + clearedrole bool + done bool + oldValue func(context.Context) (*UserRole, error) + predicates []predicate.UserRole } -var _ ent.Mutation = (*UserDepartmentMutation)(nil) +var _ ent.Mutation = (*UserRoleMutation)(nil) -// userdepartmentOption allows management of the mutation configuration using functional options. -type userdepartmentOption func(*UserDepartmentMutation) +// userroleOption allows management of the mutation configuration using functional options. +type userroleOption func(*UserRoleMutation) -// newUserDepartmentMutation creates new mutation for the UserDepartment entity. -func newUserDepartmentMutation(c config, op Op, opts ...userdepartmentOption) *UserDepartmentMutation { - m := &UserDepartmentMutation{ +// newUserRoleMutation creates new mutation for the UserRole entity. +func newUserRoleMutation(c config, op Op, opts ...userroleOption) *UserRoleMutation { + m := &UserRoleMutation{ config: c, op: op, - typ: TypeUserDepartment, + typ: TypeUserRole, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -12024,20 +12485,20 @@ func newUserDepartmentMutation(c config, op Op, opts ...userdepartmentOption) *U return m } -// withUserDepartmentID sets the ID field of the mutation. -func withUserDepartmentID(id int) userdepartmentOption { - return func(m *UserDepartmentMutation) { +// withUserRoleID sets the ID field of the mutation. +func withUserRoleID(id int) userroleOption { + return func(m *UserRoleMutation) { var ( err error once sync.Once - value *UserDepartment + value *UserRole ) - m.oldValue = func(ctx context.Context) (*UserDepartment, error) { + m.oldValue = func(ctx context.Context) (*UserRole, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().UserDepartment.Get(ctx, id) + value, err = m.Client().UserRole.Get(ctx, id) } }) return value, err @@ -12046,10 +12507,10 @@ func withUserDepartmentID(id int) userdepartmentOption { } } -// withUserDepartment sets the old UserDepartment of the mutation. -func withUserDepartment(node *UserDepartment) userdepartmentOption { - return func(m *UserDepartmentMutation) { - m.oldValue = func(context.Context) (*UserDepartment, error) { +// withUserRole sets the old UserRole of the mutation. +func withUserRole(node *UserRole) userroleOption { + return func(m *UserRoleMutation) { + m.oldValue = func(context.Context) (*UserRole, error) { return node, nil } m.id = &node.ID @@ -12058,7 +12519,7 @@ func withUserDepartment(node *UserDepartment) userdepartmentOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m UserDepartmentMutation) Client() *Client { +func (m UserRoleMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -12066,7 +12527,7 @@ func (m UserDepartmentMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m UserDepartmentMutation) Tx() (*Tx, error) { +func (m UserRoleMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -12077,7 +12538,7 @@ func (m UserDepartmentMutation) Tx() (*Tx, error) { // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *UserDepartmentMutation) ID() (id int, exists bool) { +func (m *UserRoleMutation) ID() (id int, exists bool) { if m.id == nil { return } @@ -12088,7 +12549,7 @@ func (m *UserDepartmentMutation) ID() (id int, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *UserDepartmentMutation) IDs(ctx context.Context) ([]int, error) { +func (m *UserRoleMutation) IDs(ctx context.Context) ([]int, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() @@ -12097,19 +12558,19 @@ func (m *UserDepartmentMutation) IDs(ctx context.Context) ([]int, error) { } fallthrough case m.op.Is(OpUpdate | OpDelete): - return m.Client().UserDepartment.Query().Where(m.predicates...).IDs(ctx) + return m.Client().UserRole.Query().Where(m.predicates...).IDs(ctx) default: return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) } } // SetUserID sets the "user_id" field. -func (m *UserDepartmentMutation) SetUserID(i int64) { +func (m *UserRoleMutation) SetUserID(i int64) { m.user = &i } // UserID returns the value of the "user_id" field in the mutation. -func (m *UserDepartmentMutation) UserID() (r int64, exists bool) { +func (m *UserRoleMutation) UserID() (r int64, exists bool) { v := m.user if v == nil { return @@ -12117,10 +12578,10 @@ func (m *UserDepartmentMutation) UserID() (r int64, exists bool) { return *v, true } -// OldUserID returns the old "user_id" field's value of the UserDepartment entity. -// If the UserDepartment object wasn't provided to the builder, the object is fetched from the database. +// OldUserID returns the old "user_id" field's value of the UserRole entity. +// If the UserRole object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserDepartmentMutation) OldUserID(ctx context.Context) (v int64, err error) { +func (m *UserRoleMutation) OldUserID(ctx context.Context) (v int64, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldUserID is only allowed on UpdateOne operations") } @@ -12135,61 +12596,61 @@ func (m *UserDepartmentMutation) OldUserID(ctx context.Context) (v int64, err er } // ResetUserID resets all changes to the "user_id" field. -func (m *UserDepartmentMutation) ResetUserID() { +func (m *UserRoleMutation) ResetUserID() { m.user = nil } -// SetDepartmentID sets the "department_id" field. -func (m *UserDepartmentMutation) SetDepartmentID(i int64) { - m.department = &i +// SetRoleID sets the "role_id" field. +func (m *UserRoleMutation) SetRoleID(i int64) { + m.role = &i } -// DepartmentID returns the value of the "department_id" field in the mutation. -func (m *UserDepartmentMutation) DepartmentID() (r int64, exists bool) { - v := m.department +// RoleID returns the value of the "role_id" field in the mutation. +func (m *UserRoleMutation) RoleID() (r int64, exists bool) { + v := m.role if v == nil { return } return *v, true } -// OldDepartmentID returns the old "department_id" field's value of the UserDepartment entity. -// If the UserDepartment object wasn't provided to the builder, the object is fetched from the database. +// OldRoleID returns the old "role_id" field's value of the UserRole entity. +// If the UserRole object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserDepartmentMutation) OldDepartmentID(ctx context.Context) (v int64, err error) { +func (m *UserRoleMutation) OldRoleID(ctx context.Context) (v int64, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldDepartmentID is only allowed on UpdateOne operations") + return v, errors.New("OldRoleID is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldDepartmentID requires an ID field in the mutation") + return v, errors.New("OldRoleID requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldDepartmentID: %w", err) + return v, fmt.Errorf("querying old value for OldRoleID: %w", err) } - return oldValue.DepartmentID, nil + return oldValue.RoleID, nil } -// ResetDepartmentID resets all changes to the "department_id" field. -func (m *UserDepartmentMutation) ResetDepartmentID() { - m.department = nil +// ResetRoleID resets all changes to the "role_id" field. +func (m *UserRoleMutation) ResetRoleID() { + m.role = nil } // ClearUser clears the "user" edge to the User entity. -func (m *UserDepartmentMutation) ClearUser() { +func (m *UserRoleMutation) ClearUser() { m.cleareduser = true - m.clearedFields[userdepartment.FieldUserID] = struct{}{} + m.clearedFields[userrole.FieldUserID] = struct{}{} } // UserCleared reports if the "user" edge to the User entity was cleared. -func (m *UserDepartmentMutation) UserCleared() bool { +func (m *UserRoleMutation) UserCleared() bool { return m.cleareduser } // UserIDs returns the "user" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use // UserID instead. It exists only for internal usage by the builders. -func (m *UserDepartmentMutation) UserIDs() (ids []int64) { +func (m *UserRoleMutation) UserIDs() (ids []int64) { if id := m.user; id != nil { ids = append(ids, *id) } @@ -12197,47 +12658,47 @@ func (m *UserDepartmentMutation) UserIDs() (ids []int64) { } // ResetUser resets all changes to the "user" edge. -func (m *UserDepartmentMutation) ResetUser() { +func (m *UserRoleMutation) ResetUser() { m.user = nil m.cleareduser = false } -// ClearDepartment clears the "department" edge to the Department entity. -func (m *UserDepartmentMutation) ClearDepartment() { - m.cleareddepartment = true - m.clearedFields[userdepartment.FieldDepartmentID] = struct{}{} +// ClearRole clears the "role" edge to the Role entity. +func (m *UserRoleMutation) ClearRole() { + m.clearedrole = true + m.clearedFields[userrole.FieldRoleID] = struct{}{} } -// DepartmentCleared reports if the "department" edge to the Department entity was cleared. -func (m *UserDepartmentMutation) DepartmentCleared() bool { - return m.cleareddepartment +// RoleCleared reports if the "role" edge to the Role entity was cleared. +func (m *UserRoleMutation) RoleCleared() bool { + return m.clearedrole } -// DepartmentIDs returns the "department" edge IDs in the mutation. +// RoleIDs returns the "role" edge IDs in the mutation. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// DepartmentID instead. It exists only for internal usage by the builders. -func (m *UserDepartmentMutation) DepartmentIDs() (ids []int64) { - if id := m.department; id != nil { +// RoleID instead. It exists only for internal usage by the builders. +func (m *UserRoleMutation) RoleIDs() (ids []int64) { + if id := m.role; id != nil { ids = append(ids, *id) } return } -// ResetDepartment resets all changes to the "department" edge. -func (m *UserDepartmentMutation) ResetDepartment() { - m.department = nil - m.cleareddepartment = false +// ResetRole resets all changes to the "role" edge. +func (m *UserRoleMutation) ResetRole() { + m.role = nil + m.clearedrole = false } -// Where appends a list predicates to the UserDepartmentMutation builder. -func (m *UserDepartmentMutation) Where(ps ...predicate.UserDepartment) { +// Where appends a list predicates to the UserRoleMutation builder. +func (m *UserRoleMutation) Where(ps ...predicate.UserRole) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the UserDepartmentMutation builder. Using this method, +// WhereP appends storage-level predicates to the UserRoleMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *UserDepartmentMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.UserDepartment, len(ps)) +func (m *UserRoleMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.UserRole, len(ps)) for i := range ps { p[i] = ps[i] } @@ -12245,30 +12706,30 @@ func (m *UserDepartmentMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *UserDepartmentMutation) Op() Op { +func (m *UserRoleMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *UserDepartmentMutation) SetOp(op Op) { +func (m *UserRoleMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (UserDepartment). -func (m *UserDepartmentMutation) Type() string { +// Type returns the node type of this mutation (UserRole). +func (m *UserRoleMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *UserDepartmentMutation) Fields() []string { +func (m *UserRoleMutation) Fields() []string { fields := make([]string, 0, 2) if m.user != nil { - fields = append(fields, userdepartment.FieldUserID) + fields = append(fields, userrole.FieldUserID) } - if m.department != nil { - fields = append(fields, userdepartment.FieldDepartmentID) + if m.role != nil { + fields = append(fields, userrole.FieldRoleID) } return fields } @@ -12276,12 +12737,12 @@ func (m *UserDepartmentMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *UserDepartmentMutation) Field(name string) (ent.Value, bool) { +func (m *UserRoleMutation) Field(name string) (ent.Value, bool) { switch name { - case userdepartment.FieldUserID: + case userrole.FieldUserID: return m.UserID() - case userdepartment.FieldDepartmentID: - return m.DepartmentID() + case userrole.FieldRoleID: + return m.RoleID() } return nil, false } @@ -12289,42 +12750,42 @@ func (m *UserDepartmentMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *UserDepartmentMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *UserRoleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case userdepartment.FieldUserID: + case userrole.FieldUserID: return m.OldUserID(ctx) - case userdepartment.FieldDepartmentID: - return m.OldDepartmentID(ctx) + case userrole.FieldRoleID: + return m.OldRoleID(ctx) } - return nil, fmt.Errorf("unknown UserDepartment field %s", name) + return nil, fmt.Errorf("unknown UserRole field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *UserDepartmentMutation) SetField(name string, value ent.Value) error { +func (m *UserRoleMutation) SetField(name string, value ent.Value) error { switch name { - case userdepartment.FieldUserID: + case userrole.FieldUserID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetUserID(v) return nil - case userdepartment.FieldDepartmentID: + case userrole.FieldRoleID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetDepartmentID(v) + m.SetRoleID(v) return nil } - return fmt.Errorf("unknown UserDepartment field %s", name) + return fmt.Errorf("unknown UserRole field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *UserDepartmentMutation) AddedFields() []string { +func (m *UserRoleMutation) AddedFields() []string { var fields []string return fields } @@ -12332,7 +12793,7 @@ func (m *UserDepartmentMutation) AddedFields() []string { // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *UserDepartmentMutation) AddedField(name string) (ent.Value, bool) { +func (m *UserRoleMutation) AddedField(name string) (ent.Value, bool) { switch name { } return nil, false @@ -12341,67 +12802,67 @@ func (m *UserDepartmentMutation) AddedField(name string) (ent.Value, bool) { // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *UserDepartmentMutation) AddField(name string, value ent.Value) error { +func (m *UserRoleMutation) AddField(name string, value ent.Value) error { switch name { } - return fmt.Errorf("unknown UserDepartment numeric field %s", name) + return fmt.Errorf("unknown UserRole numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *UserDepartmentMutation) ClearedFields() []string { +func (m *UserRoleMutation) ClearedFields() []string { return nil } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *UserDepartmentMutation) FieldCleared(name string) bool { +func (m *UserRoleMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *UserDepartmentMutation) ClearField(name string) error { - return fmt.Errorf("unknown UserDepartment nullable field %s", name) +func (m *UserRoleMutation) ClearField(name string) error { + return fmt.Errorf("unknown UserRole nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *UserDepartmentMutation) ResetField(name string) error { +func (m *UserRoleMutation) ResetField(name string) error { switch name { - case userdepartment.FieldUserID: + case userrole.FieldUserID: m.ResetUserID() return nil - case userdepartment.FieldDepartmentID: - m.ResetDepartmentID() + case userrole.FieldRoleID: + m.ResetRoleID() return nil } - return fmt.Errorf("unknown UserDepartment field %s", name) + return fmt.Errorf("unknown UserRole field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *UserDepartmentMutation) AddedEdges() []string { +func (m *UserRoleMutation) AddedEdges() []string { edges := make([]string, 0, 2) if m.user != nil { - edges = append(edges, userdepartment.EdgeUser) + edges = append(edges, userrole.EdgeUser) } - if m.department != nil { - edges = append(edges, userdepartment.EdgeDepartment) + if m.role != nil { + edges = append(edges, userrole.EdgeRole) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *UserDepartmentMutation) AddedIDs(name string) []ent.Value { +func (m *UserRoleMutation) AddedIDs(name string) []ent.Value { switch name { - case userdepartment.EdgeUser: + case userrole.EdgeUser: if id := m.user; id != nil { return []ent.Value{*id} } - case userdepartment.EdgeDepartment: - if id := m.department; id != nil { + case userrole.EdgeRole: + if id := m.role; id != nil { return []ent.Value{*id} } } @@ -12409,96 +12870,115 @@ func (m *UserDepartmentMutation) AddedIDs(name string) []ent.Value { } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *UserDepartmentMutation) RemovedEdges() []string { +func (m *UserRoleMutation) RemovedEdges() []string { edges := make([]string, 0, 2) return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *UserDepartmentMutation) RemovedIDs(name string) []ent.Value { +func (m *UserRoleMutation) RemovedIDs(name string) []ent.Value { return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *UserDepartmentMutation) ClearedEdges() []string { +func (m *UserRoleMutation) ClearedEdges() []string { edges := make([]string, 0, 2) if m.cleareduser { - edges = append(edges, userdepartment.EdgeUser) + edges = append(edges, userrole.EdgeUser) } - if m.cleareddepartment { - edges = append(edges, userdepartment.EdgeDepartment) + if m.clearedrole { + edges = append(edges, userrole.EdgeRole) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *UserDepartmentMutation) EdgeCleared(name string) bool { +func (m *UserRoleMutation) EdgeCleared(name string) bool { switch name { - case userdepartment.EdgeUser: + case userrole.EdgeUser: return m.cleareduser - case userdepartment.EdgeDepartment: - return m.cleareddepartment + case userrole.EdgeRole: + return m.clearedrole } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *UserDepartmentMutation) ClearEdge(name string) error { +func (m *UserRoleMutation) ClearEdge(name string) error { switch name { - case userdepartment.EdgeUser: + case userrole.EdgeUser: m.ClearUser() return nil - case userdepartment.EdgeDepartment: - m.ClearDepartment() + case userrole.EdgeRole: + m.ClearRole() return nil } - return fmt.Errorf("unknown UserDepartment unique edge %s", name) + return fmt.Errorf("unknown UserRole unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *UserDepartmentMutation) ResetEdge(name string) error { +func (m *UserRoleMutation) ResetEdge(name string) error { switch name { - case userdepartment.EdgeUser: + case userrole.EdgeUser: m.ResetUser() return nil - case userdepartment.EdgeDepartment: - m.ResetDepartment() + case userrole.EdgeRole: + m.ResetRole() return nil } - return fmt.Errorf("unknown UserDepartment edge %s", name) + return fmt.Errorf("unknown UserRole edge %s", name) } -// UserPositionMutation represents an operation that mutates the UserPosition nodes in the graph. -type UserPositionMutation struct { +// ViewMutation represents an operation that mutates the View nodes in the graph. +type ViewMutation struct { config - op Op - typ string - id *int - clearedFields map[string]struct{} - user *int64 - cleareduser bool - position *int64 - clearedposition bool - done bool - oldValue func(context.Context) (*UserPosition, error) - predicates []predicate.UserPosition -} - -var _ ent.Mutation = (*UserPositionMutation)(nil) - -// userpositionOption allows management of the mutation configuration using functional options. -type userpositionOption func(*UserPositionMutation) - -// newUserPositionMutation creates new mutation for the UserPosition entity. -func newUserPositionMutation(c config, op Op, opts ...userpositionOption) *UserPositionMutation { - m := &UserPositionMutation{ + op Op + typ string + id *int64 + create_time *time.Time + update_time *time.Time + keyword *string + scope *string + name *string + _type *string + component *string + _path *string + icon *string + visible *bool + sequence *int + addsequence *int + clearedFields map[string]struct{} + parent *int64 + clearedparent bool + children map[int64]struct{} + removedchildren map[int64]struct{} + clearedchildren bool + resources map[int64]struct{} + removedresources map[int64]struct{} + clearedresources bool + permissions map[int64]struct{} + removedpermissions map[int64]struct{} + clearedpermissions bool + done bool + oldValue func(context.Context) (*View, error) + predicates []predicate.View +} + +var _ ent.Mutation = (*ViewMutation)(nil) + +// viewOption allows management of the mutation configuration using functional options. +type viewOption func(*ViewMutation) + +// newViewMutation creates new mutation for the View entity. +func newViewMutation(c config, op Op, opts ...viewOption) *ViewMutation { + m := &ViewMutation{ config: c, op: op, - typ: TypeUserPosition, + typ: TypeView, clearedFields: make(map[string]struct{}), } for _, opt := range opts { @@ -12507,20 +12987,20 @@ func newUserPositionMutation(c config, op Op, opts ...userpositionOption) *UserP return m } -// withUserPositionID sets the ID field of the mutation. -func withUserPositionID(id int) userpositionOption { - return func(m *UserPositionMutation) { +// withViewID sets the ID field of the mutation. +func withViewID(id int64) viewOption { + return func(m *ViewMutation) { var ( err error once sync.Once - value *UserPosition + value *View ) - m.oldValue = func(ctx context.Context) (*UserPosition, error) { + m.oldValue = func(ctx context.Context) (*View, error) { once.Do(func() { if m.done { err = errors.New("querying old values post mutation is not allowed") } else { - value, err = m.Client().UserPosition.Get(ctx, id) + value, err = m.Client().View.Get(ctx, id) } }) return value, err @@ -12529,10 +13009,10 @@ func withUserPositionID(id int) userpositionOption { } } -// withUserPosition sets the old UserPosition of the mutation. -func withUserPosition(node *UserPosition) userpositionOption { - return func(m *UserPositionMutation) { - m.oldValue = func(context.Context) (*UserPosition, error) { +// withView sets the old View of the mutation. +func withView(node *View) viewOption { + return func(m *ViewMutation) { + m.oldValue = func(context.Context) (*View, error) { return node, nil } m.id = &node.ID @@ -12541,7 +13021,7 @@ func withUserPosition(node *UserPosition) userpositionOption { // Client returns a new `ent.Client` from the mutation. If the mutation was // executed in a transaction (ent.Tx), a transactional client is returned. -func (m UserPositionMutation) Client() *Client { +func (m ViewMutation) Client() *Client { client := &Client{config: m.config} client.init() return client @@ -12549,7 +13029,7 @@ func (m UserPositionMutation) Client() *Client { // Tx returns an `ent.Tx` for mutations that were executed in transactions; // it returns an error otherwise. -func (m UserPositionMutation) Tx() (*Tx, error) { +func (m ViewMutation) Tx() (*Tx, error) { if _, ok := m.driver.(*txDriver); !ok { return nil, errors.New("ent: mutation is not running in a transaction") } @@ -12558,652 +13038,742 @@ func (m UserPositionMutation) Tx() (*Tx, error) { return tx, nil } -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *UserPositionMutation) ID() (id int, exists bool) { - if m.id == nil { +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of View entities. +func (m *ViewMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ViewMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ViewMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().View.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateTime sets the "create_time" field. +func (m *ViewMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *ViewMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *ViewMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *ViewMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *ViewMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *ViewMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetParentID sets the "parent_id" field. +func (m *ViewMutation) SetParentID(i int64) { + m.parent = &i +} + +// ParentID returns the value of the "parent_id" field in the mutation. +func (m *ViewMutation) ParentID() (r int64, exists bool) { + v := m.parent + if v == nil { + return + } + return *v, true +} + +// OldParentID returns the old "parent_id" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldParentID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldParentID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldParentID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldParentID: %w", err) + } + return oldValue.ParentID, nil +} + +// ClearParentID clears the value of the "parent_id" field. +func (m *ViewMutation) ClearParentID() { + m.parent = nil + m.clearedFields[view.FieldParentID] = struct{}{} +} + +// ParentIDCleared returns if the "parent_id" field was cleared in this mutation. +func (m *ViewMutation) ParentIDCleared() bool { + _, ok := m.clearedFields[view.FieldParentID] + return ok +} + +// ResetParentID resets all changes to the "parent_id" field. +func (m *ViewMutation) ResetParentID() { + m.parent = nil + delete(m.clearedFields, view.FieldParentID) +} + +// SetKeyword sets the "keyword" field. +func (m *ViewMutation) SetKeyword(s string) { + m.keyword = &s +} + +// Keyword returns the value of the "keyword" field in the mutation. +func (m *ViewMutation) Keyword() (r string, exists bool) { + v := m.keyword + if v == nil { return } - return *m.id, true + return *v, true } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *UserPositionMutation) IDs(ctx context.Context) ([]int, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().UserPosition.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) +// OldKeyword returns the old "keyword" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldKeyword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldKeyword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldKeyword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldKeyword: %w", err) } + return oldValue.Keyword, nil } -// SetUserID sets the "user_id" field. -func (m *UserPositionMutation) SetUserID(i int64) { - m.user = &i +// ResetKeyword resets all changes to the "keyword" field. +func (m *ViewMutation) ResetKeyword() { + m.keyword = nil } -// UserID returns the value of the "user_id" field in the mutation. -func (m *UserPositionMutation) UserID() (r int64, exists bool) { - v := m.user +// SetScope sets the "scope" field. +func (m *ViewMutation) SetScope(s string) { + m.scope = &s +} + +// Scope returns the value of the "scope" field in the mutation. +func (m *ViewMutation) Scope() (r string, exists bool) { + v := m.scope if v == nil { return } return *v, true } -// OldUserID returns the old "user_id" field's value of the UserPosition entity. -// If the UserPosition object wasn't provided to the builder, the object is fetched from the database. +// OldScope returns the old "scope" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserPositionMutation) OldUserID(ctx context.Context) (v int64, err error) { +func (m *ViewMutation) OldScope(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") + return v, errors.New("OldScope is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") + return v, errors.New("OldScope requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + return v, fmt.Errorf("querying old value for OldScope: %w", err) } - return oldValue.UserID, nil + return oldValue.Scope, nil } -// ResetUserID resets all changes to the "user_id" field. -func (m *UserPositionMutation) ResetUserID() { - m.user = nil +// ResetScope resets all changes to the "scope" field. +func (m *ViewMutation) ResetScope() { + m.scope = nil } -// SetPositionID sets the "position_id" field. -func (m *UserPositionMutation) SetPositionID(i int64) { - m.position = &i +// SetName sets the "name" field. +func (m *ViewMutation) SetName(s string) { + m.name = &s } -// PositionID returns the value of the "position_id" field in the mutation. -func (m *UserPositionMutation) PositionID() (r int64, exists bool) { - v := m.position +// Name returns the value of the "name" field in the mutation. +func (m *ViewMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldPositionID returns the old "position_id" field's value of the UserPosition entity. -// If the UserPosition object wasn't provided to the builder, the object is fetched from the database. +// OldName returns the old "name" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserPositionMutation) OldPositionID(ctx context.Context) (v int64, err error) { +func (m *ViewMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPositionID is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPositionID requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPositionID: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.PositionID, nil -} - -// ResetPositionID resets all changes to the "position_id" field. -func (m *UserPositionMutation) ResetPositionID() { - m.position = nil + return oldValue.Name, nil } -// ClearUser clears the "user" edge to the User entity. -func (m *UserPositionMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[userposition.FieldUserID] = struct{}{} +// ResetName resets all changes to the "name" field. +func (m *ViewMutation) ResetName() { + m.name = nil } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *UserPositionMutation) UserCleared() bool { - return m.cleareduser +// SetType sets the "type" field. +func (m *ViewMutation) SetType(s string) { + m._type = &s } -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *UserPositionMutation) UserIDs() (ids []int64) { - if id := m.user; id != nil { - ids = append(ids, *id) +// GetType returns the value of the "type" field in the mutation. +func (m *ViewMutation) GetType() (r string, exists bool) { + v := m._type + if v == nil { + return } - return + return *v, true } -// ResetUser resets all changes to the "user" edge. -func (m *UserPositionMutation) ResetUser() { - m.user = nil - m.cleareduser = false +// OldType returns the old "type" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil } -// ClearPosition clears the "position" edge to the Position entity. -func (m *UserPositionMutation) ClearPosition() { - m.clearedposition = true - m.clearedFields[userposition.FieldPositionID] = struct{}{} +// ResetType resets all changes to the "type" field. +func (m *ViewMutation) ResetType() { + m._type = nil } -// PositionCleared reports if the "position" edge to the Position entity was cleared. -func (m *UserPositionMutation) PositionCleared() bool { - return m.clearedposition +// SetComponent sets the "component" field. +func (m *ViewMutation) SetComponent(s string) { + m.component = &s } -// PositionIDs returns the "position" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// PositionID instead. It exists only for internal usage by the builders. -func (m *UserPositionMutation) PositionIDs() (ids []int64) { - if id := m.position; id != nil { - ids = append(ids, *id) +// Component returns the value of the "component" field in the mutation. +func (m *ViewMutation) Component() (r string, exists bool) { + v := m.component + if v == nil { + return } - return + return *v, true } -// ResetPosition resets all changes to the "position" edge. -func (m *UserPositionMutation) ResetPosition() { - m.position = nil - m.clearedposition = false +// OldComponent returns the old "component" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldComponent(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldComponent is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldComponent requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldComponent: %w", err) + } + return oldValue.Component, nil } -// Where appends a list predicates to the UserPositionMutation builder. -func (m *UserPositionMutation) Where(ps ...predicate.UserPosition) { - m.predicates = append(m.predicates, ps...) +// ClearComponent clears the value of the "component" field. +func (m *ViewMutation) ClearComponent() { + m.component = nil + m.clearedFields[view.FieldComponent] = struct{}{} } -// WhereP appends storage-level predicates to the UserPositionMutation builder. Using this method, -// users can use type-assertion to append predicates that do not depend on any generated package. -func (m *UserPositionMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.UserPosition, len(ps)) - for i := range ps { - p[i] = ps[i] - } - m.Where(p...) +// ComponentCleared returns if the "component" field was cleared in this mutation. +func (m *ViewMutation) ComponentCleared() bool { + _, ok := m.clearedFields[view.FieldComponent] + return ok } -// Op returns the operation name. -func (m *UserPositionMutation) Op() Op { - return m.op +// ResetComponent resets all changes to the "component" field. +func (m *ViewMutation) ResetComponent() { + m.component = nil + delete(m.clearedFields, view.FieldComponent) } -// SetOp allows setting the mutation operation. -func (m *UserPositionMutation) SetOp(op Op) { - m.op = op +// SetPath sets the "path" field. +func (m *ViewMutation) SetPath(s string) { + m._path = &s } -// Type returns the node type of this mutation (UserPosition). -func (m *UserPositionMutation) Type() string { - return m.typ +// Path returns the value of the "path" field in the mutation. +func (m *ViewMutation) Path() (r string, exists bool) { + v := m._path + if v == nil { + return + } + return *v, true } -// Fields returns all fields that were changed during this mutation. Note that in -// order to get all numeric fields that were incremented/decremented, call -// AddedFields(). -func (m *UserPositionMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.user != nil { - fields = append(fields, userposition.FieldUserID) +// OldPath returns the old "path" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldPath(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPath is only allowed on UpdateOne operations") } - if m.position != nil { - fields = append(fields, userposition.FieldPositionID) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPath requires an ID field in the mutation") } - return fields -} - -// Field returns the value of a field with the given name. The second boolean -// return value indicates that this field was not set, or was not defined in the -// schema. -func (m *UserPositionMutation) Field(name string) (ent.Value, bool) { - switch name { - case userposition.FieldUserID: - return m.UserID() - case userposition.FieldPositionID: - return m.PositionID() + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPath: %w", err) } - return nil, false + return oldValue.Path, nil } -// OldField returns the old value of the field from the database. An error is -// returned if the mutation operation is not UpdateOne, or the query to the -// database failed. -func (m *UserPositionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { - switch name { - case userposition.FieldUserID: - return m.OldUserID(ctx) - case userposition.FieldPositionID: - return m.OldPositionID(ctx) - } - return nil, fmt.Errorf("unknown UserPosition field %s", name) +// ClearPath clears the value of the "path" field. +func (m *ViewMutation) ClearPath() { + m._path = nil + m.clearedFields[view.FieldPath] = struct{}{} } -// SetField sets the value of a field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *UserPositionMutation) SetField(name string, value ent.Value) error { - switch name { - case userposition.FieldUserID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetUserID(v) - return nil - case userposition.FieldPositionID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetPositionID(v) - return nil - } - return fmt.Errorf("unknown UserPosition field %s", name) +// PathCleared returns if the "path" field was cleared in this mutation. +func (m *ViewMutation) PathCleared() bool { + _, ok := m.clearedFields[view.FieldPath] + return ok } -// AddedFields returns all numeric fields that were incremented/decremented during -// this mutation. -func (m *UserPositionMutation) AddedFields() []string { - var fields []string - return fields +// ResetPath resets all changes to the "path" field. +func (m *ViewMutation) ResetPath() { + m._path = nil + delete(m.clearedFields, view.FieldPath) } -// AddedField returns the numeric value that was incremented/decremented on a field -// with the given name. The second boolean return value indicates that this field -// was not set, or was not defined in the schema. -func (m *UserPositionMutation) AddedField(name string) (ent.Value, bool) { - switch name { +// SetIcon sets the "icon" field. +func (m *ViewMutation) SetIcon(s string) { + m.icon = &s +} + +// Icon returns the value of the "icon" field in the mutation. +func (m *ViewMutation) Icon() (r string, exists bool) { + v := m.icon + if v == nil { + return } - return nil, false + return *v, true } -// AddField adds the value to the field with the given name. It returns an error if -// the field is not defined in the schema, or if the type mismatched the field -// type. -func (m *UserPositionMutation) AddField(name string, value ent.Value) error { - switch name { +// OldIcon returns the old "icon" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldIcon(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIcon is only allowed on UpdateOne operations") } - return fmt.Errorf("unknown UserPosition numeric field %s", name) + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIcon requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIcon: %w", err) + } + return oldValue.Icon, nil } -// ClearedFields returns all nullable fields that were cleared during this -// mutation. -func (m *UserPositionMutation) ClearedFields() []string { - return nil +// ClearIcon clears the value of the "icon" field. +func (m *ViewMutation) ClearIcon() { + m.icon = nil + m.clearedFields[view.FieldIcon] = struct{}{} } -// FieldCleared returns a boolean indicating if a field with the given name was -// cleared in this mutation. -func (m *UserPositionMutation) FieldCleared(name string) bool { - _, ok := m.clearedFields[name] +// IconCleared returns if the "icon" field was cleared in this mutation. +func (m *ViewMutation) IconCleared() bool { + _, ok := m.clearedFields[view.FieldIcon] return ok } -// ClearField clears the value of the field with the given name. It returns an -// error if the field is not defined in the schema. -func (m *UserPositionMutation) ClearField(name string) error { - return fmt.Errorf("unknown UserPosition nullable field %s", name) +// ResetIcon resets all changes to the "icon" field. +func (m *ViewMutation) ResetIcon() { + m.icon = nil + delete(m.clearedFields, view.FieldIcon) } -// ResetField resets all changes in the mutation for the field with the given name. -// It returns an error if the field is not defined in the schema. -func (m *UserPositionMutation) ResetField(name string) error { - switch name { - case userposition.FieldUserID: - m.ResetUserID() - return nil - case userposition.FieldPositionID: - m.ResetPositionID() - return nil - } - return fmt.Errorf("unknown UserPosition field %s", name) +// SetVisible sets the "visible" field. +func (m *ViewMutation) SetVisible(b bool) { + m.visible = &b } -// AddedEdges returns all edge names that were set/added in this mutation. -func (m *UserPositionMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.user != nil { - edges = append(edges, userposition.EdgeUser) - } - if m.position != nil { - edges = append(edges, userposition.EdgePosition) +// Visible returns the value of the "visible" field in the mutation. +func (m *ViewMutation) Visible() (r bool, exists bool) { + v := m.visible + if v == nil { + return } - return edges + return *v, true } -// AddedIDs returns all IDs (to other nodes) that were added for the given edge -// name in this mutation. -func (m *UserPositionMutation) AddedIDs(name string) []ent.Value { - switch name { - case userposition.EdgeUser: - if id := m.user; id != nil { - return []ent.Value{*id} - } - case userposition.EdgePosition: - if id := m.position; id != nil { - return []ent.Value{*id} - } +// OldVisible returns the old "visible" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldVisible(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldVisible is only allowed on UpdateOne operations") } - return nil + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldVisible requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldVisible: %w", err) + } + return oldValue.Visible, nil } -// RemovedEdges returns all edge names that were removed in this mutation. -func (m *UserPositionMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) - return edges +// ResetVisible resets all changes to the "visible" field. +func (m *ViewMutation) ResetVisible() { + m.visible = nil } -// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with -// the given name in this mutation. -func (m *UserPositionMutation) RemovedIDs(name string) []ent.Value { - return nil +// SetSequence sets the "sequence" field. +func (m *ViewMutation) SetSequence(i int) { + m.sequence = &i + m.addsequence = nil } -// ClearedEdges returns all edge names that were cleared in this mutation. -func (m *UserPositionMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.cleareduser { - edges = append(edges, userposition.EdgeUser) - } - if m.clearedposition { - edges = append(edges, userposition.EdgePosition) +// Sequence returns the value of the "sequence" field in the mutation. +func (m *ViewMutation) Sequence() (r int, exists bool) { + v := m.sequence + if v == nil { + return } - return edges + return *v, true } -// EdgeCleared returns a boolean which indicates if the edge with the given name -// was cleared in this mutation. -func (m *UserPositionMutation) EdgeCleared(name string) bool { - switch name { - case userposition.EdgeUser: - return m.cleareduser - case userposition.EdgePosition: - return m.clearedposition +// OldSequence returns the old "sequence" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldSequence(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSequence is only allowed on UpdateOne operations") } - return false + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSequence requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSequence: %w", err) + } + return oldValue.Sequence, nil } -// ClearEdge clears the value of the edge with the given name. It returns an error -// if that edge is not defined in the schema. -func (m *UserPositionMutation) ClearEdge(name string) error { - switch name { - case userposition.EdgeUser: - m.ClearUser() - return nil - case userposition.EdgePosition: - m.ClearPosition() - return nil +// AddSequence adds i to the "sequence" field. +func (m *ViewMutation) AddSequence(i int) { + if m.addsequence != nil { + *m.addsequence += i + } else { + m.addsequence = &i } - return fmt.Errorf("unknown UserPosition unique edge %s", name) } -// ResetEdge resets all changes to the edge with the given name in this mutation. -// It returns an error if the edge is not defined in the schema. -func (m *UserPositionMutation) ResetEdge(name string) error { - switch name { - case userposition.EdgeUser: - m.ResetUser() - return nil - case userposition.EdgePosition: - m.ResetPosition() - return nil +// AddedSequence returns the value that was added to the "sequence" field in this mutation. +func (m *ViewMutation) AddedSequence() (r int, exists bool) { + v := m.addsequence + if v == nil { + return } - return fmt.Errorf("unknown UserPosition edge %s", name) + return *v, true } -// UserRoleMutation represents an operation that mutates the UserRole nodes in the graph. -type UserRoleMutation struct { - config - op Op - typ string - id *int - clearedFields map[string]struct{} - user *int64 - cleareduser bool - role *int64 - clearedrole bool - done bool - oldValue func(context.Context) (*UserRole, error) - predicates []predicate.UserRole +// ResetSequence resets all changes to the "sequence" field. +func (m *ViewMutation) ResetSequence() { + m.sequence = nil + m.addsequence = nil } -var _ ent.Mutation = (*UserRoleMutation)(nil) +// ClearParent clears the "parent" edge to the View entity. +func (m *ViewMutation) ClearParent() { + m.clearedparent = true + m.clearedFields[view.FieldParentID] = struct{}{} +} -// userroleOption allows management of the mutation configuration using functional options. -type userroleOption func(*UserRoleMutation) +// ParentCleared reports if the "parent" edge to the View entity was cleared. +func (m *ViewMutation) ParentCleared() bool { + return m.ParentIDCleared() || m.clearedparent +} -// newUserRoleMutation creates new mutation for the UserRole entity. -func newUserRoleMutation(c config, op Op, opts ...userroleOption) *UserRoleMutation { - m := &UserRoleMutation{ - config: c, - op: op, - typ: TypeUserRole, - clearedFields: make(map[string]struct{}), - } - for _, opt := range opts { - opt(m) +// ParentIDs returns the "parent" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ParentID instead. It exists only for internal usage by the builders. +func (m *ViewMutation) ParentIDs() (ids []int64) { + if id := m.parent; id != nil { + ids = append(ids, *id) } - return m + return } -// withUserRoleID sets the ID field of the mutation. -func withUserRoleID(id int) userroleOption { - return func(m *UserRoleMutation) { - var ( - err error - once sync.Once - value *UserRole - ) - m.oldValue = func(ctx context.Context) (*UserRole, error) { - once.Do(func() { - if m.done { - err = errors.New("querying old values post mutation is not allowed") - } else { - value, err = m.Client().UserRole.Get(ctx, id) - } - }) - return value, err - } - m.id = &id +// ResetParent resets all changes to the "parent" edge. +func (m *ViewMutation) ResetParent() { + m.parent = nil + m.clearedparent = false +} + +// AddChildIDs adds the "children" edge to the View entity by ids. +func (m *ViewMutation) AddChildIDs(ids ...int64) { + if m.children == nil { + m.children = make(map[int64]struct{}) + } + for i := range ids { + m.children[ids[i]] = struct{}{} } } -// withUserRole sets the old UserRole of the mutation. -func withUserRole(node *UserRole) userroleOption { - return func(m *UserRoleMutation) { - m.oldValue = func(context.Context) (*UserRole, error) { - return node, nil - } - m.id = &node.ID - } +// ClearChildren clears the "children" edge to the View entity. +func (m *ViewMutation) ClearChildren() { + m.clearedchildren = true } -// Client returns a new `ent.Client` from the mutation. If the mutation was -// executed in a transaction (ent.Tx), a transactional client is returned. -func (m UserRoleMutation) Client() *Client { - client := &Client{config: m.config} - client.init() - return client +// ChildrenCleared reports if the "children" edge to the View entity was cleared. +func (m *ViewMutation) ChildrenCleared() bool { + return m.clearedchildren } -// Tx returns an `ent.Tx` for mutations that were executed in transactions; -// it returns an error otherwise. -func (m UserRoleMutation) Tx() (*Tx, error) { - if _, ok := m.driver.(*txDriver); !ok { - return nil, errors.New("ent: mutation is not running in a transaction") +// RemoveChildIDs removes the "children" edge to the View entity by IDs. +func (m *ViewMutation) RemoveChildIDs(ids ...int64) { + if m.removedchildren == nil { + m.removedchildren = make(map[int64]struct{}) } - tx := &Tx{config: m.config} - tx.init() - return tx, nil -} - -// ID returns the ID value in the mutation. Note that the ID is only available -// if it was provided to the builder or after it was returned from the database. -func (m *UserRoleMutation) ID() (id int, exists bool) { - if m.id == nil { - return + for i := range ids { + delete(m.children, ids[i]) + m.removedchildren[ids[i]] = struct{}{} } - return *m.id, true } -// IDs queries the database and returns the entity ids that match the mutation's predicate. -// That means, if the mutation is applied within a transaction with an isolation level such -// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated -// or updated by the mutation. -func (m *UserRoleMutation) IDs(ctx context.Context) ([]int, error) { - switch { - case m.op.Is(OpUpdateOne | OpDeleteOne): - id, exists := m.ID() - if exists { - return []int{id}, nil - } - fallthrough - case m.op.Is(OpUpdate | OpDelete): - return m.Client().UserRole.Query().Where(m.predicates...).IDs(ctx) - default: - return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) +// RemovedChildren returns the removed IDs of the "children" edge to the View entity. +func (m *ViewMutation) RemovedChildrenIDs() (ids []int64) { + for id := range m.removedchildren { + ids = append(ids, id) } + return } -// SetUserID sets the "user_id" field. -func (m *UserRoleMutation) SetUserID(i int64) { - m.user = &i +// ChildrenIDs returns the "children" edge IDs in the mutation. +func (m *ViewMutation) ChildrenIDs() (ids []int64) { + for id := range m.children { + ids = append(ids, id) + } + return } -// UserID returns the value of the "user_id" field in the mutation. -func (m *UserRoleMutation) UserID() (r int64, exists bool) { - v := m.user - if v == nil { - return - } - return *v, true +// ResetChildren resets all changes to the "children" edge. +func (m *ViewMutation) ResetChildren() { + m.children = nil + m.clearedchildren = false + m.removedchildren = nil } -// OldUserID returns the old "user_id" field's value of the UserRole entity. -// If the UserRole object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserRoleMutation) OldUserID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldUserID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldUserID requires an ID field in the mutation") +// AddResourceIDs adds the "resources" edge to the Resource entity by ids. +func (m *ViewMutation) AddResourceIDs(ids ...int64) { + if m.resources == nil { + m.resources = make(map[int64]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldUserID: %w", err) + for i := range ids { + m.resources[ids[i]] = struct{}{} } - return oldValue.UserID, nil } -// ResetUserID resets all changes to the "user_id" field. -func (m *UserRoleMutation) ResetUserID() { - m.user = nil +// ClearResources clears the "resources" edge to the Resource entity. +func (m *ViewMutation) ClearResources() { + m.clearedresources = true } -// SetRoleID sets the "role_id" field. -func (m *UserRoleMutation) SetRoleID(i int64) { - m.role = &i +// ResourcesCleared reports if the "resources" edge to the Resource entity was cleared. +func (m *ViewMutation) ResourcesCleared() bool { + return m.clearedresources } -// RoleID returns the value of the "role_id" field in the mutation. -func (m *UserRoleMutation) RoleID() (r int64, exists bool) { - v := m.role - if v == nil { - return +// RemoveResourceIDs removes the "resources" edge to the Resource entity by IDs. +func (m *ViewMutation) RemoveResourceIDs(ids ...int64) { + if m.removedresources == nil { + m.removedresources = make(map[int64]struct{}) + } + for i := range ids { + delete(m.resources, ids[i]) + m.removedresources[ids[i]] = struct{}{} } - return *v, true } -// OldRoleID returns the old "role_id" field's value of the UserRole entity. -// If the UserRole object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserRoleMutation) OldRoleID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRoleID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRoleID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRoleID: %w", err) +// RemovedResources returns the removed IDs of the "resources" edge to the Resource entity. +func (m *ViewMutation) RemovedResourcesIDs() (ids []int64) { + for id := range m.removedresources { + ids = append(ids, id) } - return oldValue.RoleID, nil + return } -// ResetRoleID resets all changes to the "role_id" field. -func (m *UserRoleMutation) ResetRoleID() { - m.role = nil +// ResourcesIDs returns the "resources" edge IDs in the mutation. +func (m *ViewMutation) ResourcesIDs() (ids []int64) { + for id := range m.resources { + ids = append(ids, id) + } + return } -// ClearUser clears the "user" edge to the User entity. -func (m *UserRoleMutation) ClearUser() { - m.cleareduser = true - m.clearedFields[userrole.FieldUserID] = struct{}{} +// ResetResources resets all changes to the "resources" edge. +func (m *ViewMutation) ResetResources() { + m.resources = nil + m.clearedresources = false + m.removedresources = nil } -// UserCleared reports if the "user" edge to the User entity was cleared. -func (m *UserRoleMutation) UserCleared() bool { - return m.cleareduser +// AddPermissionIDs adds the "permissions" edge to the Permission entity by ids. +func (m *ViewMutation) AddPermissionIDs(ids ...int64) { + if m.permissions == nil { + m.permissions = make(map[int64]struct{}) + } + for i := range ids { + m.permissions[ids[i]] = struct{}{} + } } -// UserIDs returns the "user" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// UserID instead. It exists only for internal usage by the builders. -func (m *UserRoleMutation) UserIDs() (ids []int64) { - if id := m.user; id != nil { - ids = append(ids, *id) - } - return +// ClearPermissions clears the "permissions" edge to the Permission entity. +func (m *ViewMutation) ClearPermissions() { + m.clearedpermissions = true } -// ResetUser resets all changes to the "user" edge. -func (m *UserRoleMutation) ResetUser() { - m.user = nil - m.cleareduser = false +// PermissionsCleared reports if the "permissions" edge to the Permission entity was cleared. +func (m *ViewMutation) PermissionsCleared() bool { + return m.clearedpermissions } -// ClearRole clears the "role" edge to the Role entity. -func (m *UserRoleMutation) ClearRole() { - m.clearedrole = true - m.clearedFields[userrole.FieldRoleID] = struct{}{} +// RemovePermissionIDs removes the "permissions" edge to the Permission entity by IDs. +func (m *ViewMutation) RemovePermissionIDs(ids ...int64) { + if m.removedpermissions == nil { + m.removedpermissions = make(map[int64]struct{}) + } + for i := range ids { + delete(m.permissions, ids[i]) + m.removedpermissions[ids[i]] = struct{}{} + } } -// RoleCleared reports if the "role" edge to the Role entity was cleared. -func (m *UserRoleMutation) RoleCleared() bool { - return m.clearedrole +// RemovedPermissions returns the removed IDs of the "permissions" edge to the Permission entity. +func (m *ViewMutation) RemovedPermissionsIDs() (ids []int64) { + for id := range m.removedpermissions { + ids = append(ids, id) + } + return } -// RoleIDs returns the "role" edge IDs in the mutation. -// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use -// RoleID instead. It exists only for internal usage by the builders. -func (m *UserRoleMutation) RoleIDs() (ids []int64) { - if id := m.role; id != nil { - ids = append(ids, *id) +// PermissionsIDs returns the "permissions" edge IDs in the mutation. +func (m *ViewMutation) PermissionsIDs() (ids []int64) { + for id := range m.permissions { + ids = append(ids, id) } return } -// ResetRole resets all changes to the "role" edge. -func (m *UserRoleMutation) ResetRole() { - m.role = nil - m.clearedrole = false +// ResetPermissions resets all changes to the "permissions" edge. +func (m *ViewMutation) ResetPermissions() { + m.permissions = nil + m.clearedpermissions = false + m.removedpermissions = nil } -// Where appends a list predicates to the UserRoleMutation builder. -func (m *UserRoleMutation) Where(ps ...predicate.UserRole) { +// Where appends a list predicates to the ViewMutation builder. +func (m *ViewMutation) Where(ps ...predicate.View) { m.predicates = append(m.predicates, ps...) } -// WhereP appends storage-level predicates to the UserRoleMutation builder. Using this method, +// WhereP appends storage-level predicates to the ViewMutation builder. Using this method, // users can use type-assertion to append predicates that do not depend on any generated package. -func (m *UserRoleMutation) WhereP(ps ...func(*sql.Selector)) { - p := make([]predicate.UserRole, len(ps)) +func (m *ViewMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.View, len(ps)) for i := range ps { p[i] = ps[i] } @@ -13211,30 +13781,60 @@ func (m *UserRoleMutation) WhereP(ps ...func(*sql.Selector)) { } // Op returns the operation name. -func (m *UserRoleMutation) Op() Op { +func (m *ViewMutation) Op() Op { return m.op } // SetOp allows setting the mutation operation. -func (m *UserRoleMutation) SetOp(op Op) { +func (m *ViewMutation) SetOp(op Op) { m.op = op } -// Type returns the node type of this mutation (UserRole). -func (m *UserRoleMutation) Type() string { +// Type returns the node type of this mutation (View). +func (m *ViewMutation) Type() string { return m.typ } // Fields returns all fields that were changed during this mutation. Note that in // order to get all numeric fields that were incremented/decremented, call // AddedFields(). -func (m *UserRoleMutation) Fields() []string { - fields := make([]string, 0, 2) - if m.user != nil { - fields = append(fields, userrole.FieldUserID) +func (m *ViewMutation) Fields() []string { + fields := make([]string, 0, 12) + if m.create_time != nil { + fields = append(fields, view.FieldCreateTime) } - if m.role != nil { - fields = append(fields, userrole.FieldRoleID) + if m.update_time != nil { + fields = append(fields, view.FieldUpdateTime) + } + if m.parent != nil { + fields = append(fields, view.FieldParentID) + } + if m.keyword != nil { + fields = append(fields, view.FieldKeyword) + } + if m.scope != nil { + fields = append(fields, view.FieldScope) + } + if m.name != nil { + fields = append(fields, view.FieldName) + } + if m._type != nil { + fields = append(fields, view.FieldType) + } + if m.component != nil { + fields = append(fields, view.FieldComponent) + } + if m._path != nil { + fields = append(fields, view.FieldPath) + } + if m.icon != nil { + fields = append(fields, view.FieldIcon) + } + if m.visible != nil { + fields = append(fields, view.FieldVisible) + } + if m.sequence != nil { + fields = append(fields, view.FieldSequence) } return fields } @@ -13242,12 +13842,32 @@ func (m *UserRoleMutation) Fields() []string { // Field returns the value of a field with the given name. The second boolean // return value indicates that this field was not set, or was not defined in the // schema. -func (m *UserRoleMutation) Field(name string) (ent.Value, bool) { +func (m *ViewMutation) Field(name string) (ent.Value, bool) { switch name { - case userrole.FieldUserID: - return m.UserID() - case userrole.FieldRoleID: - return m.RoleID() + case view.FieldCreateTime: + return m.CreateTime() + case view.FieldUpdateTime: + return m.UpdateTime() + case view.FieldParentID: + return m.ParentID() + case view.FieldKeyword: + return m.Keyword() + case view.FieldScope: + return m.Scope() + case view.FieldName: + return m.Name() + case view.FieldType: + return m.GetType() + case view.FieldComponent: + return m.Component() + case view.FieldPath: + return m.Path() + case view.FieldIcon: + return m.Icon() + case view.FieldVisible: + return m.Visible() + case view.FieldSequence: + return m.Sequence() } return nil, false } @@ -13255,51 +13875,146 @@ func (m *UserRoleMutation) Field(name string) (ent.Value, bool) { // OldField returns the old value of the field from the database. An error is // returned if the mutation operation is not UpdateOne, or the query to the // database failed. -func (m *UserRoleMutation) OldField(ctx context.Context, name string) (ent.Value, error) { +func (m *ViewMutation) OldField(ctx context.Context, name string) (ent.Value, error) { switch name { - case userrole.FieldUserID: - return m.OldUserID(ctx) - case userrole.FieldRoleID: - return m.OldRoleID(ctx) + case view.FieldCreateTime: + return m.OldCreateTime(ctx) + case view.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case view.FieldParentID: + return m.OldParentID(ctx) + case view.FieldKeyword: + return m.OldKeyword(ctx) + case view.FieldScope: + return m.OldScope(ctx) + case view.FieldName: + return m.OldName(ctx) + case view.FieldType: + return m.OldType(ctx) + case view.FieldComponent: + return m.OldComponent(ctx) + case view.FieldPath: + return m.OldPath(ctx) + case view.FieldIcon: + return m.OldIcon(ctx) + case view.FieldVisible: + return m.OldVisible(ctx) + case view.FieldSequence: + return m.OldSequence(ctx) } - return nil, fmt.Errorf("unknown UserRole field %s", name) + return nil, fmt.Errorf("unknown View field %s", name) } // SetField sets the value of a field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *UserRoleMutation) SetField(name string, value ent.Value) error { +func (m *ViewMutation) SetField(name string, value ent.Value) error { switch name { - case userrole.FieldUserID: - v, ok := value.(int64) + case view.FieldCreateTime: + v, ok := value.(time.Time) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetUserID(v) + m.SetCreateTime(v) return nil - case userrole.FieldRoleID: + case view.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case view.FieldParentID: v, ok := value.(int64) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRoleID(v) + m.SetParentID(v) + return nil + case view.FieldKeyword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetKeyword(v) + return nil + case view.FieldScope: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetScope(v) + return nil + case view.FieldName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetName(v) + return nil + case view.FieldType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case view.FieldComponent: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetComponent(v) + return nil + case view.FieldPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPath(v) + return nil + case view.FieldIcon: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIcon(v) + return nil + case view.FieldVisible: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetVisible(v) + return nil + case view.FieldSequence: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSequence(v) return nil } - return fmt.Errorf("unknown UserRole field %s", name) + return fmt.Errorf("unknown View field %s", name) } // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. -func (m *UserRoleMutation) AddedFields() []string { +func (m *ViewMutation) AddedFields() []string { var fields []string + if m.addsequence != nil { + fields = append(fields, view.FieldSequence) + } return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. -func (m *UserRoleMutation) AddedField(name string) (ent.Value, bool) { +func (m *ViewMutation) AddedField(name string) (ent.Value, bool) { switch name { + case view.FieldSequence: + return m.AddedSequence() } return nil, false } @@ -13307,133 +14022,259 @@ func (m *UserRoleMutation) AddedField(name string) (ent.Value, bool) { // AddField adds the value to the field with the given name. It returns an error if // the field is not defined in the schema, or if the type mismatched the field // type. -func (m *UserRoleMutation) AddField(name string, value ent.Value) error { +func (m *ViewMutation) AddField(name string, value ent.Value) error { switch name { + case view.FieldSequence: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSequence(v) + return nil } - return fmt.Errorf("unknown UserRole numeric field %s", name) + return fmt.Errorf("unknown View numeric field %s", name) } // ClearedFields returns all nullable fields that were cleared during this // mutation. -func (m *UserRoleMutation) ClearedFields() []string { - return nil +func (m *ViewMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(view.FieldParentID) { + fields = append(fields, view.FieldParentID) + } + if m.FieldCleared(view.FieldComponent) { + fields = append(fields, view.FieldComponent) + } + if m.FieldCleared(view.FieldPath) { + fields = append(fields, view.FieldPath) + } + if m.FieldCleared(view.FieldIcon) { + fields = append(fields, view.FieldIcon) + } + return fields } // FieldCleared returns a boolean indicating if a field with the given name was // cleared in this mutation. -func (m *UserRoleMutation) FieldCleared(name string) bool { +func (m *ViewMutation) FieldCleared(name string) bool { _, ok := m.clearedFields[name] return ok } // ClearField clears the value of the field with the given name. It returns an // error if the field is not defined in the schema. -func (m *UserRoleMutation) ClearField(name string) error { - return fmt.Errorf("unknown UserRole nullable field %s", name) +func (m *ViewMutation) ClearField(name string) error { + switch name { + case view.FieldParentID: + m.ClearParentID() + return nil + case view.FieldComponent: + m.ClearComponent() + return nil + case view.FieldPath: + m.ClearPath() + return nil + case view.FieldIcon: + m.ClearIcon() + return nil + } + return fmt.Errorf("unknown View nullable field %s", name) } // ResetField resets all changes in the mutation for the field with the given name. // It returns an error if the field is not defined in the schema. -func (m *UserRoleMutation) ResetField(name string) error { +func (m *ViewMutation) ResetField(name string) error { switch name { - case userrole.FieldUserID: - m.ResetUserID() + case view.FieldCreateTime: + m.ResetCreateTime() return nil - case userrole.FieldRoleID: - m.ResetRoleID() + case view.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case view.FieldParentID: + m.ResetParentID() + return nil + case view.FieldKeyword: + m.ResetKeyword() + return nil + case view.FieldScope: + m.ResetScope() + return nil + case view.FieldName: + m.ResetName() + return nil + case view.FieldType: + m.ResetType() + return nil + case view.FieldComponent: + m.ResetComponent() + return nil + case view.FieldPath: + m.ResetPath() + return nil + case view.FieldIcon: + m.ResetIcon() + return nil + case view.FieldVisible: + m.ResetVisible() + return nil + case view.FieldSequence: + m.ResetSequence() return nil } - return fmt.Errorf("unknown UserRole field %s", name) + return fmt.Errorf("unknown View field %s", name) } // AddedEdges returns all edge names that were set/added in this mutation. -func (m *UserRoleMutation) AddedEdges() []string { - edges := make([]string, 0, 2) - if m.user != nil { - edges = append(edges, userrole.EdgeUser) +func (m *ViewMutation) AddedEdges() []string { + edges := make([]string, 0, 4) + if m.parent != nil { + edges = append(edges, view.EdgeParent) } - if m.role != nil { - edges = append(edges, userrole.EdgeRole) + if m.children != nil { + edges = append(edges, view.EdgeChildren) + } + if m.resources != nil { + edges = append(edges, view.EdgeResources) + } + if m.permissions != nil { + edges = append(edges, view.EdgePermissions) } return edges } // AddedIDs returns all IDs (to other nodes) that were added for the given edge // name in this mutation. -func (m *UserRoleMutation) AddedIDs(name string) []ent.Value { +func (m *ViewMutation) AddedIDs(name string) []ent.Value { switch name { - case userrole.EdgeUser: - if id := m.user; id != nil { + case view.EdgeParent: + if id := m.parent; id != nil { return []ent.Value{*id} } - case userrole.EdgeRole: - if id := m.role; id != nil { - return []ent.Value{*id} + case view.EdgeChildren: + ids := make([]ent.Value, 0, len(m.children)) + for id := range m.children { + ids = append(ids, id) } + return ids + case view.EdgeResources: + ids := make([]ent.Value, 0, len(m.resources)) + for id := range m.resources { + ids = append(ids, id) + } + return ids + case view.EdgePermissions: + ids := make([]ent.Value, 0, len(m.permissions)) + for id := range m.permissions { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. -func (m *UserRoleMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) +func (m *ViewMutation) RemovedEdges() []string { + edges := make([]string, 0, 4) + if m.removedchildren != nil { + edges = append(edges, view.EdgeChildren) + } + if m.removedresources != nil { + edges = append(edges, view.EdgeResources) + } + if m.removedpermissions != nil { + edges = append(edges, view.EdgePermissions) + } return edges } // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with // the given name in this mutation. -func (m *UserRoleMutation) RemovedIDs(name string) []ent.Value { +func (m *ViewMutation) RemovedIDs(name string) []ent.Value { + switch name { + case view.EdgeChildren: + ids := make([]ent.Value, 0, len(m.removedchildren)) + for id := range m.removedchildren { + ids = append(ids, id) + } + return ids + case view.EdgeResources: + ids := make([]ent.Value, 0, len(m.removedresources)) + for id := range m.removedresources { + ids = append(ids, id) + } + return ids + case view.EdgePermissions: + ids := make([]ent.Value, 0, len(m.removedpermissions)) + for id := range m.removedpermissions { + ids = append(ids, id) + } + return ids + } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. -func (m *UserRoleMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) - if m.cleareduser { - edges = append(edges, userrole.EdgeUser) +func (m *ViewMutation) ClearedEdges() []string { + edges := make([]string, 0, 4) + if m.clearedparent { + edges = append(edges, view.EdgeParent) } - if m.clearedrole { - edges = append(edges, userrole.EdgeRole) + if m.clearedchildren { + edges = append(edges, view.EdgeChildren) + } + if m.clearedresources { + edges = append(edges, view.EdgeResources) + } + if m.clearedpermissions { + edges = append(edges, view.EdgePermissions) } return edges } // EdgeCleared returns a boolean which indicates if the edge with the given name // was cleared in this mutation. -func (m *UserRoleMutation) EdgeCleared(name string) bool { +func (m *ViewMutation) EdgeCleared(name string) bool { switch name { - case userrole.EdgeUser: - return m.cleareduser - case userrole.EdgeRole: - return m.clearedrole + case view.EdgeParent: + return m.clearedparent + case view.EdgeChildren: + return m.clearedchildren + case view.EdgeResources: + return m.clearedresources + case view.EdgePermissions: + return m.clearedpermissions } return false } // ClearEdge clears the value of the edge with the given name. It returns an error // if that edge is not defined in the schema. -func (m *UserRoleMutation) ClearEdge(name string) error { +func (m *ViewMutation) ClearEdge(name string) error { switch name { - case userrole.EdgeUser: - m.ClearUser() - return nil - case userrole.EdgeRole: - m.ClearRole() + case view.EdgeParent: + m.ClearParent() return nil } - return fmt.Errorf("unknown UserRole unique edge %s", name) + return fmt.Errorf("unknown View unique edge %s", name) } // ResetEdge resets all changes to the edge with the given name in this mutation. // It returns an error if the edge is not defined in the schema. -func (m *UserRoleMutation) ResetEdge(name string) error { +func (m *ViewMutation) ResetEdge(name string) error { switch name { - case userrole.EdgeUser: - m.ResetUser() + case view.EdgeParent: + m.ResetParent() return nil - case userrole.EdgeRole: - m.ResetRole() + case view.EdgeChildren: + m.ResetChildren() + return nil + case view.EdgeResources: + m.ResetResources() + return nil + case view.EdgePermissions: + m.ResetPermissions() return nil } - return fmt.Errorf("unknown UserRole edge %s", name) + return fmt.Errorf("unknown View edge %s", name) } diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index 80a753a6..36a28581 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -18,6 +18,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userdepartment" "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/view" ) // SetFields sets the values of the fields with the given names. It returns an @@ -537,88 +538,56 @@ func (m *ResourceMutation) SetFields(input *Resource, fields ...string) error { if input.UpdateTime.Unix() != 0 { m.SetUpdateTime(input.UpdateTime) } - case resource.FieldName: + case resource.FieldServiceName: // check string with sql.NullString if it is empty - if input.Name != "" { - m.SetName(input.Name) + if input.ServiceName != "" { + m.SetServiceName(input.ServiceName) } case resource.FieldKeyword: // check string with sql.NullString if it is empty if input.Keyword != "" { m.SetKeyword(input.Keyword) } - case resource.FieldI18nKey: - // check string with sql.NullString if it is empty - if input.I18nKey != "" { - m.SetI18nKey(input.I18nKey) - } - case resource.FieldType: - // check string with sql.NullString if it is empty - if input.Type != "" { - m.SetType(input.Type) - } - case resource.FieldStatus: - // check int8 with sql.NullInt64 if it is zero - if input.Status != 0 { - m.SetStatus(input.Status) - } case resource.FieldPath: // check string with sql.NullString if it is empty if input.Path != "" { m.SetPath(input.Path) } - case resource.FieldOperation: - // check string with sql.NullString if it is empty - if input.Operation != "" { - m.SetOperation(input.Operation) - } case resource.FieldMethod: // check string with sql.NullString if it is empty if input.Method != "" { m.SetMethod(input.Method) } - case resource.FieldComponent: + case resource.FieldOperation: // check string with sql.NullString if it is empty - if input.Component != "" { - m.SetComponent(input.Component) + if input.Operation != "" { + m.SetOperation(input.Operation) } - case resource.FieldIcon: + case resource.FieldPolicy: // check string with sql.NullString if it is empty - if input.Icon != "" { - m.SetIcon(input.Icon) - } - case resource.FieldSequence: - // check int with sql.NullInt64 if it is zero - if input.Sequence != 0 { - m.SetSequence(input.Sequence) + if input.Policy != "" { + m.SetPolicy(input.Policy) } - case resource.FieldVisible: - if input.Visible { - m.SetVisible(input.Visible) - } - case resource.FieldLevel: - // check int8 with sql.NullInt64 if it is zero - if input.Level != 0 { - m.SetLevel(input.Level) - } - case resource.FieldTreePath: + case resource.FieldVersionID: // check string with sql.NullString if it is empty - if input.TreePath != "" { - m.SetTreePath(input.TreePath) + if input.VersionID != "" { + m.SetVersionID(input.VersionID) } - case resource.FieldProperties: - if len(input.Properties) > 0 { - m.SetProperties(input.Properties) + case resource.FieldLastSyncVersionID: + // check string with sql.NullString if it is empty + if input.LastSyncVersionID != "" { + m.SetLastSyncVersionID(input.LastSyncVersionID) } - case resource.FieldDescription: + case resource.FieldSyncStatus: // check string with sql.NullString if it is empty - if input.Description != "" { - m.SetDescription(input.Description) + if input.SyncStatus != "" { + m.SetSyncStatus(input.SyncStatus) } - case resource.FieldParentID: - // check int64 with sql.NullInt64 if it is zero - if input.ParentID != 0 { - m.SetParentID(input.ParentID) + case resource.FieldStatus: + var zero resource.Status + // check resource.Status with sql.NullString if it is empty + if input.Status != zero { + m.SetStatus(input.Status) } case resource.FieldID: // check int64 with sql.NullInt64 if it is zero @@ -642,40 +611,26 @@ func (m *ResourceMutation) SetFieldsWithZero(input *Resource, fields ...string) m.SetCreateTime(input.CreateTime) case resource.FieldUpdateTime: m.SetUpdateTime(input.UpdateTime) - case resource.FieldName: - m.SetName(input.Name) + case resource.FieldServiceName: + m.SetServiceName(input.ServiceName) case resource.FieldKeyword: m.SetKeyword(input.Keyword) - case resource.FieldI18nKey: - m.SetI18nKey(input.I18nKey) - case resource.FieldType: - m.SetType(input.Type) - case resource.FieldStatus: - m.SetStatus(input.Status) case resource.FieldPath: m.SetPath(input.Path) - case resource.FieldOperation: - m.SetOperation(input.Operation) case resource.FieldMethod: m.SetMethod(input.Method) - case resource.FieldComponent: - m.SetComponent(input.Component) - case resource.FieldIcon: - m.SetIcon(input.Icon) - case resource.FieldSequence: - m.SetSequence(input.Sequence) - case resource.FieldVisible: - m.SetVisible(input.Visible) - case resource.FieldLevel: - m.SetLevel(input.Level) - case resource.FieldTreePath: - m.SetTreePath(input.TreePath) - case resource.FieldProperties: - m.SetProperties(input.Properties) - case resource.FieldDescription: - m.SetDescription(input.Description) - case resource.FieldParentID: - m.SetParentID(input.ParentID) + case resource.FieldOperation: + m.SetOperation(input.Operation) + case resource.FieldPolicy: + m.SetPolicy(input.Policy) + case resource.FieldVersionID: + m.SetVersionID(input.VersionID) + case resource.FieldLastSyncVersionID: + m.SetLastSyncVersionID(input.LastSyncVersionID) + case resource.FieldSyncStatus: + m.SetSyncStatus(input.SyncStatus) + case resource.FieldStatus: + m.SetStatus(input.Status) case resource.FieldID: m.SetID(input.ID) default: @@ -1153,3 +1108,117 @@ func (m *UserRoleMutation) SetFieldsWithZero(input *UserRole, fields ...string) } return nil } + +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *ViewMutation) SetFields(input *View, fields ...string) error { + for i := range fields { + switch fields[i] { + case view.FieldCreateTime: + if input.CreateTime.Unix() != 0 { + m.SetCreateTime(input.CreateTime) + } + case view.FieldUpdateTime: + if input.UpdateTime.Unix() != 0 { + m.SetUpdateTime(input.UpdateTime) + } + case view.FieldParentID: + // check int64 with sql.NullInt64 if it is zero + if input.ParentID != 0 { + m.SetParentID(input.ParentID) + } + case view.FieldKeyword: + // check string with sql.NullString if it is empty + if input.Keyword != "" { + m.SetKeyword(input.Keyword) + } + case view.FieldScope: + // check string with sql.NullString if it is empty + if input.Scope != "" { + m.SetScope(input.Scope) + } + case view.FieldName: + // check string with sql.NullString if it is empty + if input.Name != "" { + m.SetName(input.Name) + } + case view.FieldType: + // check string with sql.NullString if it is empty + if input.Type != "" { + m.SetType(input.Type) + } + case view.FieldComponent: + // check string with sql.NullString if it is empty + if input.Component != "" { + m.SetComponent(input.Component) + } + case view.FieldPath: + // check string with sql.NullString if it is empty + if input.Path != "" { + m.SetPath(input.Path) + } + case view.FieldIcon: + // check string with sql.NullString if it is empty + if input.Icon != "" { + m.SetIcon(input.Icon) + } + case view.FieldVisible: + if input.Visible { + m.SetVisible(input.Visible) + } + case view.FieldSequence: + // check int with sql.NullInt64 if it is zero + if input.Sequence != 0 { + m.SetSequence(input.Sequence) + } + case view.FieldID: + // check int64 with sql.NullInt64 if it is zero + if input.ID != 0 { + m.SetID(input.ID) + } + default: + return fmt.Errorf("unknown View field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *ViewMutation) SetFieldsWithZero(input *View, fields ...string) error { + for i := range fields { + switch fields[i] { + case view.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case view.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case view.FieldParentID: + m.SetParentID(input.ParentID) + case view.FieldKeyword: + m.SetKeyword(input.Keyword) + case view.FieldScope: + m.SetScope(input.Scope) + case view.FieldName: + m.SetName(input.Name) + case view.FieldType: + m.SetType(input.Type) + case view.FieldComponent: + m.SetComponent(input.Component) + case view.FieldPath: + m.SetPath(input.Path) + case view.FieldIcon: + m.SetIcon(input.Icon) + case view.FieldVisible: + m.SetVisible(input.Visible) + case view.FieldSequence: + m.SetSequence(input.Sequence) + case view.FieldID: + m.SetID(input.ID) + default: + return fmt.Errorf("unknown View field %s", fields[i]) + } + } + return nil +} diff --git a/internal/data/entity/ent/permission.go b/internal/data/entity/ent/permission.go index 6b0784e9..199011c1 100644 --- a/internal/data/entity/ent/permission.go +++ b/internal/data/entity/ent/permission.go @@ -49,6 +49,8 @@ type PermissionEdges struct { Positions []*Position `json:"positions,omitempty"` // Resources holds the value of the resources edge. Resources []*Resource `json:"resources,omitempty"` + // Views holds the value of the views edge. + Views []*View `json:"views,omitempty"` // RolePermissions holds the value of the role_permissions edge. RolePermissions []*RolePermission `json:"role_permissions,omitempty"` // PositionPermissions holds the value of the position_permissions edge. @@ -57,7 +59,7 @@ type PermissionEdges struct { PermissionResources []*PermissionResource `json:"permission_resources,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [6]bool + loadedTypes [7]bool } // RolesOrErr returns the Roles value or an error if the edge @@ -87,10 +89,19 @@ func (e PermissionEdges) ResourcesOrErr() ([]*Resource, error) { return nil, &NotLoadedError{edge: "resources"} } +// ViewsOrErr returns the Views value or an error if the edge +// was not loaded in eager-loading. +func (e PermissionEdges) ViewsOrErr() ([]*View, error) { + if e.loadedTypes[3] { + return e.Views, nil + } + return nil, &NotLoadedError{edge: "views"} +} + // RolePermissionsOrErr returns the RolePermissions value or an error if the edge // was not loaded in eager-loading. func (e PermissionEdges) RolePermissionsOrErr() ([]*RolePermission, error) { - if e.loadedTypes[3] { + if e.loadedTypes[4] { return e.RolePermissions, nil } return nil, &NotLoadedError{edge: "role_permissions"} @@ -99,7 +110,7 @@ func (e PermissionEdges) RolePermissionsOrErr() ([]*RolePermission, error) { // PositionPermissionsOrErr returns the PositionPermissions value or an error if the edge // was not loaded in eager-loading. func (e PermissionEdges) PositionPermissionsOrErr() ([]*PositionPermission, error) { - if e.loadedTypes[4] { + if e.loadedTypes[5] { return e.PositionPermissions, nil } return nil, &NotLoadedError{edge: "position_permissions"} @@ -108,7 +119,7 @@ func (e PermissionEdges) PositionPermissionsOrErr() ([]*PositionPermission, erro // PermissionResourcesOrErr returns the PermissionResources value or an error if the edge // was not loaded in eager-loading. func (e PermissionEdges) PermissionResourcesOrErr() ([]*PermissionResource, error) { - if e.loadedTypes[5] { + if e.loadedTypes[6] { return e.PermissionResources, nil } return nil, &NotLoadedError{edge: "permission_resources"} @@ -226,6 +237,11 @@ func (_m *Permission) QueryResources() *ResourceQuery { return NewPermissionClient(_m.config).QueryResources(_m) } +// QueryViews queries the "views" edge of the Permission entity. +func (_m *Permission) QueryViews() *ViewQuery { + return NewPermissionClient(_m.config).QueryViews(_m) +} + // QueryRolePermissions queries the "role_permissions" edge of the Permission entity. func (_m *Permission) QueryRolePermissions() *RolePermissionQuery { return NewPermissionClient(_m.config).QueryRolePermissions(_m) diff --git a/internal/data/entity/ent/permission/permission.go b/internal/data/entity/ent/permission/permission.go index 45cd170f..84632cc0 100644 --- a/internal/data/entity/ent/permission/permission.go +++ b/internal/data/entity/ent/permission/permission.go @@ -37,6 +37,8 @@ const ( EdgePositions = "positions" // EdgeResources holds the string denoting the resources edge name in mutations. EdgeResources = "resources" + // EdgeViews holds the string denoting the views edge name in mutations. + EdgeViews = "views" // EdgeRolePermissions holds the string denoting the role_permissions edge name in mutations. EdgeRolePermissions = "role_permissions" // EdgePositionPermissions holds the string denoting the position_permissions edge name in mutations. @@ -59,7 +61,12 @@ const ( ResourcesTable = "sys_permission_resources" // ResourcesInverseTable is the table name for the Resource entity. // It exists in this package in order to avoid circular dependency with the "resource" package. - ResourcesInverseTable = "sys_resources" + ResourcesInverseTable = "resources" + // ViewsTable is the table that holds the views relation/edge. The primary key declared below. + ViewsTable = "permission_views" + // ViewsInverseTable is the table name for the View entity. + // It exists in this package in order to avoid circular dependency with the "view" package. + ViewsInverseTable = "views" // RolePermissionsTable is the table that holds the role_permissions relation/edge. RolePermissionsTable = "sys_role_permissions" // RolePermissionsInverseTable is the table name for the RolePermission entity. @@ -106,6 +113,9 @@ var ( // ResourcesPrimaryKey and ResourcesColumn2 are the table columns denoting the // primary key for the resources relation (M2M). ResourcesPrimaryKey = []string{"permission_id", "resource_id"} + // ViewsPrimaryKey and ViewsColumn2 are the table columns denoting the + // primary key for the views relation (M2M). + ViewsPrimaryKey = []string{"permission_id", "view_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -256,6 +266,20 @@ func ByResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { } } +// ByViewsCount orders the results by views count. +func ByViewsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newViewsStep(), opts...) + } +} + +// ByViews orders the results by views terms. +func ByViews(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newViewsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + // ByRolePermissionsCount orders the results by role_permissions count. func ByRolePermissionsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { @@ -318,6 +342,13 @@ func newResourcesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), ) } +func newViewsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ViewsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ViewsTable, ViewsPrimaryKey...), + ) +} func newRolePermissionsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/internal/data/entity/ent/permission/where.go b/internal/data/entity/ent/permission/where.go index 9b6ec847..73790eb2 100644 --- a/internal/data/entity/ent/permission/where.go +++ b/internal/data/entity/ent/permission/where.go @@ -524,6 +524,29 @@ func HasResourcesWith(preds ...predicate.Resource) predicate.Permission { }) } +// HasViews applies the HasEdge predicate on the "views" edge. +func HasViews() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ViewsTable, ViewsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasViewsWith applies the HasEdge predicate on the "views" edge with a given conditions (other predicates). +func HasViewsWith(preds ...predicate.View) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newViewsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // HasRolePermissions applies the HasEdge predicate on the "role_permissions" edge. func HasRolePermissions() predicate.Permission { return predicate.Permission(func(s *sql.Selector) { diff --git a/internal/data/entity/ent/permission_create.go b/internal/data/entity/ent/permission_create.go index f13dabca..7a9d7608 100644 --- a/internal/data/entity/ent/permission_create.go +++ b/internal/data/entity/ent/permission_create.go @@ -13,6 +13,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/role" "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/view" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -181,6 +182,21 @@ func (_c *PermissionCreate) AddResources(v ...*Resource) *PermissionCreate { return _c.AddResourceIDs(ids...) } +// AddViewIDs adds the "views" edge to the View entity by IDs. +func (_c *PermissionCreate) AddViewIDs(ids ...int64) *PermissionCreate { + _c.mutation.AddViewIDs(ids...) + return _c +} + +// AddViews adds the "views" edges to the View entity. +func (_c *PermissionCreate) AddViews(v ...*View) *PermissionCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddViewIDs(ids...) +} + // AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. func (_c *PermissionCreate) AddRolePermissionIDs(ids ...int) *PermissionCreate { _c.mutation.AddRolePermissionIDs(ids...) @@ -451,6 +467,22 @@ func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := _c.mutation.ViewsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ViewsTable, + Columns: permission.ViewsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } if nodes := _c.mutation.RolePermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/internal/data/entity/ent/permission_query.go b/internal/data/entity/ent/permission_query.go index 7bc8ba03..c7b684c0 100644 --- a/internal/data/entity/ent/permission_query.go +++ b/internal/data/entity/ent/permission_query.go @@ -15,6 +15,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/role" "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/view" "entgo.io/ent" "entgo.io/ent/dialect" @@ -33,6 +34,7 @@ type PermissionQuery struct { withRoles *RoleQuery withPositions *PositionQuery withResources *ResourceQuery + withViews *ViewQuery withRolePermissions *RolePermissionQuery withPositionPermissions *PositionPermissionQuery withPermissionResources *PermissionResourceQuery @@ -139,6 +141,28 @@ func (_q *PermissionQuery) QueryResources() *ResourceQuery { return query } +// QueryViews chains the current query on the "views" edge. +func (_q *PermissionQuery) QueryViews() *ViewQuery { + query := (&ViewClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, selector), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, permission.ViewsTable, permission.ViewsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryRolePermissions chains the current query on the "role_permissions" edge. func (_q *PermissionQuery) QueryRolePermissions() *RolePermissionQuery { query := (&RolePermissionClient{config: _q.config}).Query() @@ -400,6 +424,7 @@ func (_q *PermissionQuery) Clone() *PermissionQuery { withRoles: _q.withRoles.Clone(), withPositions: _q.withPositions.Clone(), withResources: _q.withResources.Clone(), + withViews: _q.withViews.Clone(), withRolePermissions: _q.withRolePermissions.Clone(), withPositionPermissions: _q.withPositionPermissions.Clone(), withPermissionResources: _q.withPermissionResources.Clone(), @@ -443,6 +468,17 @@ func (_q *PermissionQuery) WithResources(opts ...func(*ResourceQuery)) *Permissi return _q } +// WithViews tells the query-builder to eager-load the nodes that are connected to +// the "views" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PermissionQuery) WithViews(opts ...func(*ViewQuery)) *PermissionQuery { + query := (&ViewClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withViews = query + return _q +} + // WithRolePermissions tells the query-builder to eager-load the nodes that are connected to // the "role_permissions" edge. The optional arguments are used to configure the query builder of the edge. func (_q *PermissionQuery) WithRolePermissions(opts ...func(*RolePermissionQuery)) *PermissionQuery { @@ -554,10 +590,11 @@ func (_q *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*P var ( nodes = []*Permission{} _spec = _q.querySpec() - loadedTypes = [6]bool{ + loadedTypes = [7]bool{ _q.withRoles != nil, _q.withPositions != nil, _q.withResources != nil, + _q.withViews != nil, _q.withRolePermissions != nil, _q.withPositionPermissions != nil, _q.withPermissionResources != nil, @@ -605,6 +642,13 @@ func (_q *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*P return nil, err } } + if query := _q.withViews; query != nil { + if err := _q.loadViews(ctx, query, nodes, + func(n *Permission) { n.Edges.Views = []*View{} }, + func(n *Permission, e *View) { n.Edges.Views = append(n.Edges.Views, e) }); err != nil { + return nil, err + } + } if query := _q.withRolePermissions; query != nil { if err := _q.loadRolePermissions(ctx, query, nodes, func(n *Permission) { n.Edges.RolePermissions = []*RolePermission{} }, @@ -816,6 +860,67 @@ func (_q *PermissionQuery) loadResources(ctx context.Context, query *ResourceQue } return nil } +func (_q *PermissionQuery) loadViews(ctx context.Context, query *ViewQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *View)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int64]*Permission) + nids := make(map[int64]map[*Permission]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(permission.ViewsTable) + s.Join(joinT).On(s.C(view.FieldID), joinT.C(permission.ViewsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(permission.ViewsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(permission.ViewsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullInt64).Int64 + inValue := values[1].(*sql.NullInt64).Int64 + if nids[inValue] == nil { + nids[inValue] = map[*Permission]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*View](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "views" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} func (_q *PermissionQuery) loadRolePermissions(ctx context.Context, query *RolePermissionQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *RolePermission)) error { fks := make([]driver.Value, 0, len(nodes)) nodeids := make(map[int64]*Permission) diff --git a/internal/data/entity/ent/permission_update.go b/internal/data/entity/ent/permission_update.go index 546e9e70..fad1606b 100644 --- a/internal/data/entity/ent/permission_update.go +++ b/internal/data/entity/ent/permission_update.go @@ -14,6 +14,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/role" "origadmin/application/admin/internal/data/entity/ent/rolepermission" + "origadmin/application/admin/internal/data/entity/ent/view" "time" "entgo.io/ent/dialect/sql" @@ -168,6 +169,21 @@ func (_u *PermissionUpdate) AddResources(v ...*Resource) *PermissionUpdate { return _u.AddResourceIDs(ids...) } +// AddViewIDs adds the "views" edge to the View entity by IDs. +func (_u *PermissionUpdate) AddViewIDs(ids ...int64) *PermissionUpdate { + _u.mutation.AddViewIDs(ids...) + return _u +} + +// AddViews adds the "views" edges to the View entity. +func (_u *PermissionUpdate) AddViews(v ...*View) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddViewIDs(ids...) +} + // AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. func (_u *PermissionUpdate) AddRolePermissionIDs(ids ...int) *PermissionUpdate { _u.mutation.AddRolePermissionIDs(ids...) @@ -281,6 +297,27 @@ func (_u *PermissionUpdate) RemoveResources(v ...*Resource) *PermissionUpdate { return _u.RemoveResourceIDs(ids...) } +// ClearViews clears all "views" edges to the View entity. +func (_u *PermissionUpdate) ClearViews() *PermissionUpdate { + _u.mutation.ClearViews() + return _u +} + +// RemoveViewIDs removes the "views" edge to View entities by IDs. +func (_u *PermissionUpdate) RemoveViewIDs(ids ...int64) *PermissionUpdate { + _u.mutation.RemoveViewIDs(ids...) + return _u +} + +// RemoveViews removes "views" edges to View entities. +func (_u *PermissionUpdate) RemoveViews(v ...*View) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveViewIDs(ids...) +} + // ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. func (_u *PermissionUpdate) ClearRolePermissions() *PermissionUpdate { _u.mutation.ClearRolePermissions() @@ -582,6 +619,51 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.ViewsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ViewsTable, + Columns: permission.ViewsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedViewsIDs(); len(nodes) > 0 && !_u.mutation.ViewsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ViewsTable, + Columns: permission.ViewsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ViewsTable, + Columns: permission.ViewsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if _u.mutation.RolePermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -872,6 +954,21 @@ func (_u *PermissionUpdateOne) AddResources(v ...*Resource) *PermissionUpdateOne return _u.AddResourceIDs(ids...) } +// AddViewIDs adds the "views" edge to the View entity by IDs. +func (_u *PermissionUpdateOne) AddViewIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.AddViewIDs(ids...) + return _u +} + +// AddViews adds the "views" edges to the View entity. +func (_u *PermissionUpdateOne) AddViews(v ...*View) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddViewIDs(ids...) +} + // AddRolePermissionIDs adds the "role_permissions" edge to the RolePermission entity by IDs. func (_u *PermissionUpdateOne) AddRolePermissionIDs(ids ...int) *PermissionUpdateOne { _u.mutation.AddRolePermissionIDs(ids...) @@ -985,6 +1082,27 @@ func (_u *PermissionUpdateOne) RemoveResources(v ...*Resource) *PermissionUpdate return _u.RemoveResourceIDs(ids...) } +// ClearViews clears all "views" edges to the View entity. +func (_u *PermissionUpdateOne) ClearViews() *PermissionUpdateOne { + _u.mutation.ClearViews() + return _u +} + +// RemoveViewIDs removes the "views" edge to View entities by IDs. +func (_u *PermissionUpdateOne) RemoveViewIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.RemoveViewIDs(ids...) + return _u +} + +// RemoveViews removes "views" edges to View entities. +func (_u *PermissionUpdateOne) RemoveViews(v ...*View) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveViewIDs(ids...) +} + // ClearRolePermissions clears all "role_permissions" edges to the RolePermission entity. func (_u *PermissionUpdateOne) ClearRolePermissions() *PermissionUpdateOne { _u.mutation.ClearRolePermissions() @@ -1316,6 +1434,51 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.ViewsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ViewsTable, + Columns: permission.ViewsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedViewsIDs(); len(nodes) > 0 && !_u.mutation.ViewsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ViewsTable, + Columns: permission.ViewsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: false, + Table: permission.ViewsTable, + Columns: permission.ViewsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } if _u.mutation.RolePermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, diff --git a/internal/data/entity/ent/permissionresource/permissionresource.go b/internal/data/entity/ent/permissionresource/permissionresource.go index 22d0c165..087c01db 100644 --- a/internal/data/entity/ent/permissionresource/permissionresource.go +++ b/internal/data/entity/ent/permissionresource/permissionresource.go @@ -33,7 +33,7 @@ const ( ResourceTable = "sys_permission_resources" // ResourceInverseTable is the table name for the Resource entity. // It exists in this package in order to avoid circular dependency with the "resource" package. - ResourceInverseTable = "sys_resources" + ResourceInverseTable = "resources" // ResourceColumn is the table column denoting the resource relation/edge. ResourceColumn = "resource_id" ) diff --git a/internal/data/entity/ent/predicate/predicate.go b/internal/data/entity/ent/predicate/predicate.go index acf692b3..88e73f21 100644 --- a/internal/data/entity/ent/predicate/predicate.go +++ b/internal/data/entity/ent/predicate/predicate.go @@ -47,3 +47,6 @@ type UserPosition func(*sql.Selector) // UserRole is the predicate function for userrole builders. type UserRole func(*sql.Selector) + +// View is the predicate function for view builders. +type View func(*sql.Selector) diff --git a/internal/data/entity/ent/resource.go b/internal/data/entity/ent/resource.go index 37f78e8c..761211c8 100644 --- a/internal/data/entity/ent/resource.go +++ b/internal/data/entity/ent/resource.go @@ -3,7 +3,6 @@ package ent import ( - "encoding/json" "fmt" "origadmin/application/admin/internal/data/entity/ent/resource" "strings" @@ -13,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql" ) -// entity.resource.table.comment +// Resource is the model entity for the Resource schema. type Resource struct { config `json:"-"` // ID of the ent. @@ -23,40 +22,26 @@ type Resource struct { CreateTime time.Time `json:"create_time,omitempty"` // update_time.field.comment UpdateTime time.Time `json:"update_time,omitempty"` - // entity.resource.field.name - Name string `json:"name,omitempty"` - // entity.resource.field.keyword + // resource.service_name.comment + ServiceName string `json:"service_name,omitempty"` + // resource.keyword.comment Keyword string `json:"keyword,omitempty"` - // entity.resource.field.i18n_key - I18nKey string `json:"i18n_key,omitempty"` - // entity.resource.field.type - Type string `json:"type,omitempty"` - // entity.resource.field.status - Status int8 `json:"status,omitempty"` - // entity.resource.field.path + // resource.path.comment Path string `json:"path,omitempty"` - // entity.resource.field.operation - Operation string `json:"operation,omitempty"` - // entity.resource.field.method + // resource.method.comment Method string `json:"method,omitempty"` - // entity.resource.field.component - Component string `json:"component,omitempty"` - // entity.resource.field.icon - Icon string `json:"icon,omitempty"` - // entity.resource.field.sequence - Sequence int `json:"sequence,omitempty"` - // entity.resource.field.visible - Visible bool `json:"visible,omitempty"` - // entity.resource.field.level - Level int8 `json:"level,omitempty"` - // entity.resource.field.tree_path - TreePath string `json:"tree_path,omitempty"` - // entity.resource.field.properties - Properties map[string]string `json:"properties,omitempty"` - // entity.resource.field.description - Description string `json:"description,omitempty"` - // resource.field.parent_id - ParentID int64 `json:"parent_id,omitempty"` + // resource.operation.comment + Operation string `json:"operation,omitempty"` + // resource.policy.comment + Policy string `json:"policy,omitempty"` + // resource.version_id.comment + VersionID string `json:"version_id,omitempty"` + // resource.last_sync_version_id.comment + LastSyncVersionID string `json:"last_sync_version_id,omitempty"` + // resource.sync_status.comment + SyncStatus string `json:"sync_status,omitempty"` + // resource.status.comment + Status resource.Status `json:"status,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ResourceQuery when eager-loading is set. Edges ResourceEdges `json:"edges"` @@ -65,69 +50,41 @@ type Resource struct { // ResourceEdges holds the relations/edges for other nodes in the graph. type ResourceEdges struct { - // Children holds the value of the children edge. - Children []*Resource `json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Resource `json:"parent,omitempty"` + // Views holds the value of the views edge. + Views []*View `json:"views,omitempty"` // Permissions holds the value of the permissions edge. Permissions []*Permission `json:"permissions,omitempty"` - // PermissionResources holds the value of the permission_resources edge. - PermissionResources []*PermissionResource `json:"permission_resources,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [4]bool + loadedTypes [2]bool } -// ChildrenOrErr returns the Children value or an error if the edge +// ViewsOrErr returns the Views value or an error if the edge // was not loaded in eager-loading. -func (e ResourceEdges) ChildrenOrErr() ([]*Resource, error) { +func (e ResourceEdges) ViewsOrErr() ([]*View, error) { if e.loadedTypes[0] { - return e.Children, nil - } - return nil, &NotLoadedError{edge: "children"} -} - -// ParentOrErr returns the Parent value or an error if the edge -// was not loaded in eager-loading, or loaded but was not found. -func (e ResourceEdges) ParentOrErr() (*Resource, error) { - if e.Parent != nil { - return e.Parent, nil - } else if e.loadedTypes[1] { - return nil, &NotFoundError{label: resource.Label} + return e.Views, nil } - return nil, &NotLoadedError{edge: "parent"} + return nil, &NotLoadedError{edge: "views"} } // PermissionsOrErr returns the Permissions value or an error if the edge // was not loaded in eager-loading. func (e ResourceEdges) PermissionsOrErr() ([]*Permission, error) { - if e.loadedTypes[2] { + if e.loadedTypes[1] { return e.Permissions, nil } return nil, &NotLoadedError{edge: "permissions"} } -// PermissionResourcesOrErr returns the PermissionResources value or an error if the edge -// was not loaded in eager-loading. -func (e ResourceEdges) PermissionResourcesOrErr() ([]*PermissionResource, error) { - if e.loadedTypes[3] { - return e.PermissionResources, nil - } - return nil, &NotLoadedError{edge: "permission_resources"} -} - // scanValues returns the types for scanning values from sql.Rows. func (*Resource) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case resource.FieldProperties: - values[i] = new([]byte) - case resource.FieldVisible: - values[i] = new(sql.NullBool) - case resource.FieldID, resource.FieldStatus, resource.FieldSequence, resource.FieldLevel, resource.FieldParentID: + case resource.FieldID: values[i] = new(sql.NullInt64) - case resource.FieldName, resource.FieldKeyword, resource.FieldI18nKey, resource.FieldType, resource.FieldPath, resource.FieldOperation, resource.FieldMethod, resource.FieldComponent, resource.FieldIcon, resource.FieldTreePath, resource.FieldDescription: + case resource.FieldServiceName, resource.FieldKeyword, resource.FieldPath, resource.FieldMethod, resource.FieldOperation, resource.FieldPolicy, resource.FieldVersionID, resource.FieldLastSyncVersionID, resource.FieldSyncStatus, resource.FieldStatus: values[i] = new(sql.NullString) case resource.FieldCreateTime, resource.FieldUpdateTime: values[i] = new(sql.NullTime) @@ -164,11 +121,11 @@ func (_m *Resource) assignValues(columns []string, values []any) error { } else if value.Valid { _m.UpdateTime = value.Time } - case resource.FieldName: + case resource.FieldServiceName: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field name", values[i]) + return fmt.Errorf("unexpected type %T for field service_name", values[i]) } else if value.Valid { - _m.Name = value.String + _m.ServiceName = value.String } case resource.FieldKeyword: if value, ok := values[i].(*sql.NullString); !ok { @@ -176,97 +133,53 @@ func (_m *Resource) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Keyword = value.String } - case resource.FieldI18nKey: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field i18n_key", values[i]) - } else if value.Valid { - _m.I18nKey = value.String - } - case resource.FieldType: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field type", values[i]) - } else if value.Valid { - _m.Type = value.String - } - case resource.FieldStatus: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field status", values[i]) - } else if value.Valid { - _m.Status = int8(value.Int64) - } case resource.FieldPath: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field path", values[i]) } else if value.Valid { _m.Path = value.String } - case resource.FieldOperation: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field operation", values[i]) - } else if value.Valid { - _m.Operation = value.String - } case resource.FieldMethod: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field method", values[i]) } else if value.Valid { _m.Method = value.String } - case resource.FieldComponent: + case resource.FieldOperation: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field component", values[i]) + return fmt.Errorf("unexpected type %T for field operation", values[i]) } else if value.Valid { - _m.Component = value.String + _m.Operation = value.String } - case resource.FieldIcon: + case resource.FieldPolicy: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field icon", values[i]) + return fmt.Errorf("unexpected type %T for field policy", values[i]) } else if value.Valid { - _m.Icon = value.String + _m.Policy = value.String } - case resource.FieldSequence: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field sequence", values[i]) - } else if value.Valid { - _m.Sequence = int(value.Int64) - } - case resource.FieldVisible: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field visible", values[i]) - } else if value.Valid { - _m.Visible = value.Bool - } - case resource.FieldLevel: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field level", values[i]) + case resource.FieldVersionID: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field version_id", values[i]) } else if value.Valid { - _m.Level = int8(value.Int64) + _m.VersionID = value.String } - case resource.FieldTreePath: + case resource.FieldLastSyncVersionID: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field tree_path", values[i]) + return fmt.Errorf("unexpected type %T for field last_sync_version_id", values[i]) } else if value.Valid { - _m.TreePath = value.String - } - case resource.FieldProperties: - if value, ok := values[i].(*[]byte); !ok { - return fmt.Errorf("unexpected type %T for field properties", values[i]) - } else if value != nil && len(*value) > 0 { - if err := json.Unmarshal(*value, &_m.Properties); err != nil { - return fmt.Errorf("unmarshal field properties: %w", err) - } + _m.LastSyncVersionID = value.String } - case resource.FieldDescription: + case resource.FieldSyncStatus: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field description", values[i]) + return fmt.Errorf("unexpected type %T for field sync_status", values[i]) } else if value.Valid { - _m.Description = value.String + _m.SyncStatus = value.String } - case resource.FieldParentID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field parent_id", values[i]) + case resource.FieldStatus: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - _m.ParentID = value.Int64 + _m.Status = resource.Status(value.String) } default: _m.selectValues.Set(columns[i], values[i]) @@ -281,14 +194,9 @@ func (_m *Resource) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } -// QueryChildren queries the "children" edge of the Resource entity. -func (_m *Resource) QueryChildren() *ResourceQuery { - return NewResourceClient(_m.config).QueryChildren(_m) -} - -// QueryParent queries the "parent" edge of the Resource entity. -func (_m *Resource) QueryParent() *ResourceQuery { - return NewResourceClient(_m.config).QueryParent(_m) +// QueryViews queries the "views" edge of the Resource entity. +func (_m *Resource) QueryViews() *ViewQuery { + return NewResourceClient(_m.config).QueryViews(_m) } // QueryPermissions queries the "permissions" edge of the Resource entity. @@ -296,11 +204,6 @@ func (_m *Resource) QueryPermissions() *PermissionQuery { return NewResourceClient(_m.config).QueryPermissions(_m) } -// QueryPermissionResources queries the "permission_resources" edge of the Resource entity. -func (_m *Resource) QueryPermissionResources() *PermissionResourceQuery { - return NewResourceClient(_m.config).QueryPermissionResources(_m) -} - // Update returns a builder for updating this Resource. // Note that you need to call Resource.Unwrap() before calling this method if this Resource // was returned from a transaction, and the transaction was committed or rolled back. @@ -330,56 +233,35 @@ func (_m *Resource) String() string { builder.WriteString("update_time=") builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) builder.WriteString(", ") - builder.WriteString("name=") - builder.WriteString(_m.Name) + builder.WriteString("service_name=") + builder.WriteString(_m.ServiceName) builder.WriteString(", ") builder.WriteString("keyword=") builder.WriteString(_m.Keyword) builder.WriteString(", ") - builder.WriteString("i18n_key=") - builder.WriteString(_m.I18nKey) - builder.WriteString(", ") - builder.WriteString("type=") - builder.WriteString(_m.Type) - builder.WriteString(", ") - builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", _m.Status)) - builder.WriteString(", ") builder.WriteString("path=") builder.WriteString(_m.Path) builder.WriteString(", ") - builder.WriteString("operation=") - builder.WriteString(_m.Operation) - builder.WriteString(", ") builder.WriteString("method=") builder.WriteString(_m.Method) builder.WriteString(", ") - builder.WriteString("component=") - builder.WriteString(_m.Component) - builder.WriteString(", ") - builder.WriteString("icon=") - builder.WriteString(_m.Icon) - builder.WriteString(", ") - builder.WriteString("sequence=") - builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) - builder.WriteString(", ") - builder.WriteString("visible=") - builder.WriteString(fmt.Sprintf("%v", _m.Visible)) + builder.WriteString("operation=") + builder.WriteString(_m.Operation) builder.WriteString(", ") - builder.WriteString("level=") - builder.WriteString(fmt.Sprintf("%v", _m.Level)) + builder.WriteString("policy=") + builder.WriteString(_m.Policy) builder.WriteString(", ") - builder.WriteString("tree_path=") - builder.WriteString(_m.TreePath) + builder.WriteString("version_id=") + builder.WriteString(_m.VersionID) builder.WriteString(", ") - builder.WriteString("properties=") - builder.WriteString(fmt.Sprintf("%v", _m.Properties)) + builder.WriteString("last_sync_version_id=") + builder.WriteString(_m.LastSyncVersionID) builder.WriteString(", ") - builder.WriteString("description=") - builder.WriteString(_m.Description) + builder.WriteString("sync_status=") + builder.WriteString(_m.SyncStatus) builder.WriteString(", ") - builder.WriteString("parent_id=") - builder.WriteString(fmt.Sprintf("%v", _m.ParentID)) + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/resource/resource.go b/internal/data/entity/ent/resource/resource.go index 9dc8240a..b5ca2263 100644 --- a/internal/data/entity/ent/resource/resource.go +++ b/internal/data/entity/ent/resource/resource.go @@ -3,6 +3,7 @@ package resource import ( + "fmt" "time" "entgo.io/ent/dialect/sql" @@ -18,70 +19,42 @@ const ( FieldCreateTime = "create_time" // FieldUpdateTime holds the string denoting the update_time field in the database. FieldUpdateTime = "update_time" - // FieldName holds the string denoting the name field in the database. - FieldName = "name" + // FieldServiceName holds the string denoting the service_name field in the database. + FieldServiceName = "service_name" // FieldKeyword holds the string denoting the keyword field in the database. FieldKeyword = "keyword" - // FieldI18nKey holds the string denoting the i18n_key field in the database. - FieldI18nKey = "i18n_key" - // FieldType holds the string denoting the type field in the database. - FieldType = "type" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" // FieldPath holds the string denoting the path field in the database. FieldPath = "path" - // FieldOperation holds the string denoting the operation field in the database. - FieldOperation = "operation" // FieldMethod holds the string denoting the method field in the database. FieldMethod = "method" - // FieldComponent holds the string denoting the component field in the database. - FieldComponent = "component" - // FieldIcon holds the string denoting the icon field in the database. - FieldIcon = "icon" - // FieldSequence holds the string denoting the sequence field in the database. - FieldSequence = "sequence" - // FieldVisible holds the string denoting the visible field in the database. - FieldVisible = "visible" - // FieldLevel holds the string denoting the level field in the database. - FieldLevel = "level" - // FieldTreePath holds the string denoting the tree_path field in the database. - FieldTreePath = "tree_path" - // FieldProperties holds the string denoting the properties field in the database. - FieldProperties = "properties" - // FieldDescription holds the string denoting the description field in the database. - FieldDescription = "description" - // FieldParentID holds the string denoting the parent_id field in the database. - FieldParentID = "parent_id" - // EdgeChildren holds the string denoting the children edge name in mutations. - EdgeChildren = "children" - // EdgeParent holds the string denoting the parent edge name in mutations. - EdgeParent = "parent" + // FieldOperation holds the string denoting the operation field in the database. + FieldOperation = "operation" + // FieldPolicy holds the string denoting the policy field in the database. + FieldPolicy = "policy" + // FieldVersionID holds the string denoting the version_id field in the database. + FieldVersionID = "version_id" + // FieldLastSyncVersionID holds the string denoting the last_sync_version_id field in the database. + FieldLastSyncVersionID = "last_sync_version_id" + // FieldSyncStatus holds the string denoting the sync_status field in the database. + FieldSyncStatus = "sync_status" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // EdgeViews holds the string denoting the views edge name in mutations. + EdgeViews = "views" // EdgePermissions holds the string denoting the permissions edge name in mutations. EdgePermissions = "permissions" - // EdgePermissionResources holds the string denoting the permission_resources edge name in mutations. - EdgePermissionResources = "permission_resources" // Table holds the table name of the resource in the database. - Table = "sys_resources" - // ChildrenTable is the table that holds the children relation/edge. - ChildrenTable = "sys_resources" - // ChildrenColumn is the table column denoting the children relation/edge. - ChildrenColumn = "parent_id" - // ParentTable is the table that holds the parent relation/edge. - ParentTable = "sys_resources" - // ParentColumn is the table column denoting the parent relation/edge. - ParentColumn = "parent_id" + Table = "resources" + // ViewsTable is the table that holds the views relation/edge. The primary key declared below. + ViewsTable = "resource_views" + // ViewsInverseTable is the table name for the View entity. + // It exists in this package in order to avoid circular dependency with the "view" package. + ViewsInverseTable = "views" // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. PermissionsTable = "sys_permission_resources" // PermissionsInverseTable is the table name for the Permission entity. // It exists in this package in order to avoid circular dependency with the "permission" package. PermissionsInverseTable = "sys_permissions" - // PermissionResourcesTable is the table that holds the permission_resources relation/edge. - PermissionResourcesTable = "sys_permission_resources" - // PermissionResourcesInverseTable is the table name for the PermissionResource entity. - // It exists in this package in order to avoid circular dependency with the "permissionresource" package. - PermissionResourcesInverseTable = "sys_permission_resources" - // PermissionResourcesColumn is the table column denoting the permission_resources relation/edge. - PermissionResourcesColumn = "resource_id" ) // Columns holds all SQL columns for resource fields. @@ -89,26 +62,22 @@ var Columns = []string{ FieldID, FieldCreateTime, FieldUpdateTime, - FieldName, + FieldServiceName, FieldKeyword, - FieldI18nKey, - FieldType, - FieldStatus, FieldPath, - FieldOperation, FieldMethod, - FieldComponent, - FieldIcon, - FieldSequence, - FieldVisible, - FieldLevel, - FieldTreePath, - FieldProperties, - FieldDescription, - FieldParentID, + FieldOperation, + FieldPolicy, + FieldVersionID, + FieldLastSyncVersionID, + FieldSyncStatus, + FieldStatus, } var ( + // ViewsPrimaryKey and ViewsColumn2 are the table columns denoting the + // primary key for the views relation (M2M). + ViewsPrimaryKey = []string{"resource_id", "view_id"} // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the // primary key for the permissions relation (M2M). PermissionsPrimaryKey = []string{"permission_id", "resource_id"} @@ -131,64 +100,48 @@ var ( DefaultUpdateTime func() time.Time // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. UpdateDefaultUpdateTime func() time.Time - // DefaultName holds the default value on creation for the "name" field. - DefaultName string - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. KeywordValidator func(string) error - // DefaultI18nKey holds the default value on creation for the "i18n_key" field. - DefaultI18nKey string - // I18nKeyValidator is a validator for the "i18n_key" field. It is called by the builders before save. - I18nKeyValidator func(string) error - // DefaultType holds the default value on creation for the "type" field. - DefaultType string - // TypeValidator is a validator for the "type" field. It is called by the builders before save. - TypeValidator func(string) error - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 - // DefaultPath holds the default value on creation for the "path" field. - DefaultPath string - // PathValidator is a validator for the "path" field. It is called by the builders before save. - PathValidator func(string) error - // DefaultOperation holds the default value on creation for the "operation" field. - DefaultOperation string - // OperationValidator is a validator for the "operation" field. It is called by the builders before save. - OperationValidator func(string) error - // DefaultMethod holds the default value on creation for the "method" field. - DefaultMethod string - // MethodValidator is a validator for the "method" field. It is called by the builders before save. - MethodValidator func(string) error - // DefaultComponent holds the default value on creation for the "component" field. - DefaultComponent string - // ComponentValidator is a validator for the "component" field. It is called by the builders before save. - ComponentValidator func(string) error - // DefaultIcon holds the default value on creation for the "icon" field. - DefaultIcon string - // IconValidator is a validator for the "icon" field. It is called by the builders before save. - IconValidator func(string) error - // DefaultSequence holds the default value on creation for the "sequence" field. - DefaultSequence int - // DefaultVisible holds the default value on creation for the "visible" field. - DefaultVisible bool - // DefaultLevel holds the default value on creation for the "level" field. - DefaultLevel int8 - // DefaultTreePath holds the default value on creation for the "tree_path" field. - DefaultTreePath string - // TreePathValidator is a validator for the "tree_path" field. It is called by the builders before save. - TreePathValidator func(string) error - // DefaultDescription holds the default value on creation for the "description" field. - DefaultDescription string - // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - DescriptionValidator func(string) error - // ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. - ParentIDValidator func(int64) error + // DefaultPolicy holds the default value on creation for the "policy" field. + DefaultPolicy string + // DefaultVersionID holds the default value on creation for the "version_id" field. + DefaultVersionID string + // DefaultLastSyncVersionID holds the default value on creation for the "last_sync_version_id" field. + DefaultLastSyncVersionID string + // DefaultSyncStatus holds the default value on creation for the "sync_status" field. + DefaultSyncStatus string // DefaultID holds the default value on creation for the "id" field. DefaultID func() int64 // IDValidator is a validator for the "id" field. It is called by the builders before save. IDValidator func(int64) error ) +// Status defines the type for the "status" enum field. +type Status string + +// StatusEnabled is the default value of the Status enum. +const DefaultStatus = StatusEnabled + +// Status values. +const ( + StatusEnabled Status = "enabled" + StatusDisabled Status = "disabled" +) + +func (s Status) String() string { + return string(s) +} + +// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. +func StatusValidator(s Status) error { + switch s { + case StatusEnabled, StatusDisabled: + return nil + default: + return fmt.Errorf("resource: invalid enum value for status field: %q", s) + } +} + // OrderOption defines the ordering options for the Resource queries. type OrderOption func(*sql.Selector) @@ -207,9 +160,9 @@ func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() } -// ByName orders the results by the name field. -func ByName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldName, opts...).ToFunc() +// ByServiceName orders the results by the service_name field. +func ByServiceName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldServiceName, opts...).ToFunc() } // ByKeyword orders the results by the keyword field. @@ -217,94 +170,57 @@ func ByKeyword(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldKeyword, opts...).ToFunc() } -// ByI18nKey orders the results by the i18n_key field. -func ByI18nKey(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldI18nKey, opts...).ToFunc() -} - -// ByType orders the results by the type field. -func ByType(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldType, opts...).ToFunc() -} - -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() -} - // ByPath orders the results by the path field. func ByPath(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPath, opts...).ToFunc() } -// ByOperation orders the results by the operation field. -func ByOperation(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldOperation, opts...).ToFunc() -} - // ByMethod orders the results by the method field. func ByMethod(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldMethod, opts...).ToFunc() } -// ByComponent orders the results by the component field. -func ByComponent(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldComponent, opts...).ToFunc() -} - -// ByIcon orders the results by the icon field. -func ByIcon(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldIcon, opts...).ToFunc() -} - -// BySequence orders the results by the sequence field. -func BySequence(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldSequence, opts...).ToFunc() -} - -// ByVisible orders the results by the visible field. -func ByVisible(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldVisible, opts...).ToFunc() +// ByOperation orders the results by the operation field. +func ByOperation(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldOperation, opts...).ToFunc() } -// ByLevel orders the results by the level field. -func ByLevel(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldLevel, opts...).ToFunc() +// ByPolicy orders the results by the policy field. +func ByPolicy(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPolicy, opts...).ToFunc() } -// ByTreePath orders the results by the tree_path field. -func ByTreePath(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTreePath, opts...).ToFunc() +// ByVersionID orders the results by the version_id field. +func ByVersionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVersionID, opts...).ToFunc() } -// ByDescription orders the results by the description field. -func ByDescription(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldDescription, opts...).ToFunc() +// ByLastSyncVersionID orders the results by the last_sync_version_id field. +func ByLastSyncVersionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLastSyncVersionID, opts...).ToFunc() } -// ByParentID orders the results by the parent_id field. -func ByParentID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldParentID, opts...).ToFunc() +// BySyncStatus orders the results by the sync_status field. +func BySyncStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSyncStatus, opts...).ToFunc() } -// ByChildrenCount orders the results by children count. -func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) - } +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() } -// ByChildren orders the results by children terms. -func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { +// ByViewsCount orders the results by views count. +func ByViewsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) + sqlgraph.OrderByNeighborsCount(s, newViewsStep(), opts...) } } -// ByParentField orders the results by parent field. -func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { +// ByViews orders the results by views terms. +func ByViews(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) + sqlgraph.OrderByNeighborTerms(s, newViewsStep(), append([]sql.OrderTerm{term}, terms...)...) } } @@ -321,32 +237,11 @@ func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) } } - -// ByPermissionResourcesCount orders the results by permission_resources count. -func ByPermissionResourcesCount(opts ...sql.OrderTermOption) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborsCount(s, newPermissionResourcesStep(), opts...) - } -} - -// ByPermissionResources orders the results by permission_resources terms. -func ByPermissionResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { - return func(s *sql.Selector) { - sqlgraph.OrderByNeighborTerms(s, newPermissionResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) - } -} -func newChildrenStep() *sqlgraph.Step { +func newViewsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), - ) -} -func newParentStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + sqlgraph.To(ViewsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, ViewsTable, ViewsPrimaryKey...), ) } func newPermissionsStep() *sqlgraph.Step { @@ -356,13 +251,6 @@ func newPermissionsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), ) } -func newPermissionResourcesStep() *sqlgraph.Step { - return sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.To(PermissionResourcesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), - ) -} // SelectColumns returns all selected fields. func SelectColumns(fields []string) []string { diff --git a/internal/data/entity/ent/resource/where.go b/internal/data/entity/ent/resource/where.go index 6040258b..62303acc 100644 --- a/internal/data/entity/ent/resource/where.go +++ b/internal/data/entity/ent/resource/where.go @@ -65,9 +65,9 @@ func UpdateTime(v time.Time) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldUpdateTime, v)) } -// Name applies equality check predicate on the "name" field. It's identical to NameEQ. -func Name(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldName, v)) +// ServiceName applies equality check predicate on the "service_name" field. It's identical to ServiceNameEQ. +func ServiceName(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldServiceName, v)) } // Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. @@ -75,74 +75,34 @@ func Keyword(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) } -// I18nKey applies equality check predicate on the "i18n_key" field. It's identical to I18nKeyEQ. -func I18nKey(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldI18nKey, v)) -} - -// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. -func Type(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldType, v)) -} - -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldStatus, v)) -} - // Path applies equality check predicate on the "path" field. It's identical to PathEQ. func Path(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldPath, v)) } -// Operation applies equality check predicate on the "operation" field. It's identical to OperationEQ. -func Operation(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldOperation, v)) -} - // Method applies equality check predicate on the "method" field. It's identical to MethodEQ. func Method(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldMethod, v)) } -// Component applies equality check predicate on the "component" field. It's identical to ComponentEQ. -func Component(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldComponent, v)) -} - -// Icon applies equality check predicate on the "icon" field. It's identical to IconEQ. -func Icon(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldIcon, v)) -} - -// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. -func Sequence(v int) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldSequence, v)) -} - -// Visible applies equality check predicate on the "visible" field. It's identical to VisibleEQ. -func Visible(v bool) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldVisible, v)) -} - -// Level applies equality check predicate on the "level" field. It's identical to LevelEQ. -func Level(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldLevel, v)) +// Operation applies equality check predicate on the "operation" field. It's identical to OperationEQ. +func Operation(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldOperation, v)) } -// TreePath applies equality check predicate on the "tree_path" field. It's identical to TreePathEQ. -func TreePath(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) +// VersionID applies equality check predicate on the "version_id" field. It's identical to VersionIDEQ. +func VersionID(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldVersionID, v)) } -// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. -func Description(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldDescription, v)) +// LastSyncVersionID applies equality check predicate on the "last_sync_version_id" field. It's identical to LastSyncVersionIDEQ. +func LastSyncVersionID(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldLastSyncVersionID, v)) } -// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ. -func ParentID(v int64) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldParentID, v)) +// SyncStatus applies equality check predicate on the "sync_status" field. It's identical to SyncStatusEQ. +func SyncStatus(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldSyncStatus, v)) } // CreateTimeEQ applies the EQ predicate on the "create_time" field. @@ -225,69 +185,69 @@ func UpdateTimeLTE(v time.Time) predicate.Resource { return predicate.Resource(sql.FieldLTE(FieldUpdateTime, v)) } -// NameEQ applies the EQ predicate on the "name" field. -func NameEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldName, v)) +// ServiceNameEQ applies the EQ predicate on the "service_name" field. +func ServiceNameEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldServiceName, v)) } -// NameNEQ applies the NEQ predicate on the "name" field. -func NameNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldName, v)) +// ServiceNameNEQ applies the NEQ predicate on the "service_name" field. +func ServiceNameNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldServiceName, v)) } -// NameIn applies the In predicate on the "name" field. -func NameIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldName, vs...)) +// ServiceNameIn applies the In predicate on the "service_name" field. +func ServiceNameIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldServiceName, vs...)) } -// NameNotIn applies the NotIn predicate on the "name" field. -func NameNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldName, vs...)) +// ServiceNameNotIn applies the NotIn predicate on the "service_name" field. +func ServiceNameNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldServiceName, vs...)) } -// NameGT applies the GT predicate on the "name" field. -func NameGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldName, v)) +// ServiceNameGT applies the GT predicate on the "service_name" field. +func ServiceNameGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldServiceName, v)) } -// NameGTE applies the GTE predicate on the "name" field. -func NameGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldName, v)) +// ServiceNameGTE applies the GTE predicate on the "service_name" field. +func ServiceNameGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldServiceName, v)) } -// NameLT applies the LT predicate on the "name" field. -func NameLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldName, v)) +// ServiceNameLT applies the LT predicate on the "service_name" field. +func ServiceNameLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldServiceName, v)) } -// NameLTE applies the LTE predicate on the "name" field. -func NameLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldName, v)) +// ServiceNameLTE applies the LTE predicate on the "service_name" field. +func ServiceNameLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldServiceName, v)) } -// NameContains applies the Contains predicate on the "name" field. -func NameContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldName, v)) +// ServiceNameContains applies the Contains predicate on the "service_name" field. +func ServiceNameContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldServiceName, v)) } -// NameHasPrefix applies the HasPrefix predicate on the "name" field. -func NameHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldName, v)) +// ServiceNameHasPrefix applies the HasPrefix predicate on the "service_name" field. +func ServiceNameHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldServiceName, v)) } -// NameHasSuffix applies the HasSuffix predicate on the "name" field. -func NameHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldName, v)) +// ServiceNameHasSuffix applies the HasSuffix predicate on the "service_name" field. +func ServiceNameHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldServiceName, v)) } -// NameEqualFold applies the EqualFold predicate on the "name" field. -func NameEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldName, v)) +// ServiceNameEqualFold applies the EqualFold predicate on the "service_name" field. +func ServiceNameEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldServiceName, v)) } -// NameContainsFold applies the ContainsFold predicate on the "name" field. -func NameContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldName, v)) +// ServiceNameContainsFold applies the ContainsFold predicate on the "service_name" field. +func ServiceNameContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldServiceName, v)) } // KeywordEQ applies the EQ predicate on the "keyword" field. @@ -355,176 +315,6 @@ func KeywordContainsFold(v string) predicate.Resource { return predicate.Resource(sql.FieldContainsFold(FieldKeyword, v)) } -// I18nKeyEQ applies the EQ predicate on the "i18n_key" field. -func I18nKeyEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldI18nKey, v)) -} - -// I18nKeyNEQ applies the NEQ predicate on the "i18n_key" field. -func I18nKeyNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldI18nKey, v)) -} - -// I18nKeyIn applies the In predicate on the "i18n_key" field. -func I18nKeyIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldI18nKey, vs...)) -} - -// I18nKeyNotIn applies the NotIn predicate on the "i18n_key" field. -func I18nKeyNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldI18nKey, vs...)) -} - -// I18nKeyGT applies the GT predicate on the "i18n_key" field. -func I18nKeyGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldI18nKey, v)) -} - -// I18nKeyGTE applies the GTE predicate on the "i18n_key" field. -func I18nKeyGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldI18nKey, v)) -} - -// I18nKeyLT applies the LT predicate on the "i18n_key" field. -func I18nKeyLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldI18nKey, v)) -} - -// I18nKeyLTE applies the LTE predicate on the "i18n_key" field. -func I18nKeyLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldI18nKey, v)) -} - -// I18nKeyContains applies the Contains predicate on the "i18n_key" field. -func I18nKeyContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldI18nKey, v)) -} - -// I18nKeyHasPrefix applies the HasPrefix predicate on the "i18n_key" field. -func I18nKeyHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldI18nKey, v)) -} - -// I18nKeyHasSuffix applies the HasSuffix predicate on the "i18n_key" field. -func I18nKeyHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldI18nKey, v)) -} - -// I18nKeyEqualFold applies the EqualFold predicate on the "i18n_key" field. -func I18nKeyEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldI18nKey, v)) -} - -// I18nKeyContainsFold applies the ContainsFold predicate on the "i18n_key" field. -func I18nKeyContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldI18nKey, v)) -} - -// TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldType, v)) -} - -// TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldType, v)) -} - -// TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldType, vs...)) -} - -// TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldType, vs...)) -} - -// TypeGT applies the GT predicate on the "type" field. -func TypeGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldType, v)) -} - -// TypeGTE applies the GTE predicate on the "type" field. -func TypeGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldType, v)) -} - -// TypeLT applies the LT predicate on the "type" field. -func TypeLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldType, v)) -} - -// TypeLTE applies the LTE predicate on the "type" field. -func TypeLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldType, v)) -} - -// TypeContains applies the Contains predicate on the "type" field. -func TypeContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldType, v)) -} - -// TypeHasPrefix applies the HasPrefix predicate on the "type" field. -func TypeHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldType, v)) -} - -// TypeHasSuffix applies the HasSuffix predicate on the "type" field. -func TypeHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldType, v)) -} - -// TypeEqualFold applies the EqualFold predicate on the "type" field. -func TypeEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldType, v)) -} - -// TypeContainsFold applies the ContainsFold predicate on the "type" field. -func TypeContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldType, v)) -} - -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldStatus, v)) -} - -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldStatus, v)) -} - -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldStatus, vs...)) -} - -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldStatus, vs...)) -} - -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldStatus, v)) -} - -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldStatus, v)) -} - -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldStatus, v)) -} - -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldStatus, v)) -} - // PathEQ applies the EQ predicate on the "path" field. func PathEQ(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldPath, v)) @@ -580,6 +370,16 @@ func PathHasSuffix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasSuffix(FieldPath, v)) } +// PathIsNil applies the IsNil predicate on the "path" field. +func PathIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldPath)) +} + +// PathNotNil applies the NotNil predicate on the "path" field. +func PathNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldPath)) +} + // PathEqualFold applies the EqualFold predicate on the "path" field. func PathEqualFold(v string) predicate.Resource { return predicate.Resource(sql.FieldEqualFold(FieldPath, v)) @@ -590,71 +390,6 @@ func PathContainsFold(v string) predicate.Resource { return predicate.Resource(sql.FieldContainsFold(FieldPath, v)) } -// OperationEQ applies the EQ predicate on the "operation" field. -func OperationEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldOperation, v)) -} - -// OperationNEQ applies the NEQ predicate on the "operation" field. -func OperationNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldOperation, v)) -} - -// OperationIn applies the In predicate on the "operation" field. -func OperationIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldOperation, vs...)) -} - -// OperationNotIn applies the NotIn predicate on the "operation" field. -func OperationNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldOperation, vs...)) -} - -// OperationGT applies the GT predicate on the "operation" field. -func OperationGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldOperation, v)) -} - -// OperationGTE applies the GTE predicate on the "operation" field. -func OperationGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldOperation, v)) -} - -// OperationLT applies the LT predicate on the "operation" field. -func OperationLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldOperation, v)) -} - -// OperationLTE applies the LTE predicate on the "operation" field. -func OperationLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldOperation, v)) -} - -// OperationContains applies the Contains predicate on the "operation" field. -func OperationContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldOperation, v)) -} - -// OperationHasPrefix applies the HasPrefix predicate on the "operation" field. -func OperationHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldOperation, v)) -} - -// OperationHasSuffix applies the HasSuffix predicate on the "operation" field. -func OperationHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldOperation, v)) -} - -// OperationEqualFold applies the EqualFold predicate on the "operation" field. -func OperationEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldOperation, v)) -} - -// OperationContainsFold applies the ContainsFold predicate on the "operation" field. -func OperationContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldOperation, v)) -} - // MethodEQ applies the EQ predicate on the "method" field. func MethodEQ(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldMethod, v)) @@ -710,6 +445,16 @@ func MethodHasSuffix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasSuffix(FieldMethod, v)) } +// MethodIsNil applies the IsNil predicate on the "method" field. +func MethodIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldMethod)) +} + +// MethodNotNil applies the NotNil predicate on the "method" field. +func MethodNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldMethod)) +} + // MethodEqualFold applies the EqualFold predicate on the "method" field. func MethodEqualFold(v string) predicate.Resource { return predicate.Resource(sql.FieldEqualFold(FieldMethod, v)) @@ -720,434 +465,376 @@ func MethodContainsFold(v string) predicate.Resource { return predicate.Resource(sql.FieldContainsFold(FieldMethod, v)) } -// ComponentEQ applies the EQ predicate on the "component" field. -func ComponentEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldComponent, v)) -} - -// ComponentNEQ applies the NEQ predicate on the "component" field. -func ComponentNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldComponent, v)) -} - -// ComponentIn applies the In predicate on the "component" field. -func ComponentIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldComponent, vs...)) -} - -// ComponentNotIn applies the NotIn predicate on the "component" field. -func ComponentNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldComponent, vs...)) -} - -// ComponentGT applies the GT predicate on the "component" field. -func ComponentGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldComponent, v)) -} - -// ComponentGTE applies the GTE predicate on the "component" field. -func ComponentGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldComponent, v)) -} - -// ComponentLT applies the LT predicate on the "component" field. -func ComponentLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldComponent, v)) -} - -// ComponentLTE applies the LTE predicate on the "component" field. -func ComponentLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldComponent, v)) -} - -// ComponentContains applies the Contains predicate on the "component" field. -func ComponentContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldComponent, v)) -} - -// ComponentHasPrefix applies the HasPrefix predicate on the "component" field. -func ComponentHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldComponent, v)) +// OperationEQ applies the EQ predicate on the "operation" field. +func OperationEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldOperation, v)) } -// ComponentHasSuffix applies the HasSuffix predicate on the "component" field. -func ComponentHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldComponent, v)) +// OperationNEQ applies the NEQ predicate on the "operation" field. +func OperationNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldOperation, v)) } -// ComponentEqualFold applies the EqualFold predicate on the "component" field. -func ComponentEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldComponent, v)) +// OperationIn applies the In predicate on the "operation" field. +func OperationIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldOperation, vs...)) } -// ComponentContainsFold applies the ContainsFold predicate on the "component" field. -func ComponentContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldComponent, v)) +// OperationNotIn applies the NotIn predicate on the "operation" field. +func OperationNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldOperation, vs...)) } -// IconEQ applies the EQ predicate on the "icon" field. -func IconEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldIcon, v)) +// OperationGT applies the GT predicate on the "operation" field. +func OperationGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldOperation, v)) } -// IconNEQ applies the NEQ predicate on the "icon" field. -func IconNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldIcon, v)) +// OperationGTE applies the GTE predicate on the "operation" field. +func OperationGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldOperation, v)) } -// IconIn applies the In predicate on the "icon" field. -func IconIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldIcon, vs...)) +// OperationLT applies the LT predicate on the "operation" field. +func OperationLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldOperation, v)) } -// IconNotIn applies the NotIn predicate on the "icon" field. -func IconNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldIcon, vs...)) +// OperationLTE applies the LTE predicate on the "operation" field. +func OperationLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldOperation, v)) } -// IconGT applies the GT predicate on the "icon" field. -func IconGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldIcon, v)) +// OperationContains applies the Contains predicate on the "operation" field. +func OperationContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldOperation, v)) } -// IconGTE applies the GTE predicate on the "icon" field. -func IconGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldIcon, v)) +// OperationHasPrefix applies the HasPrefix predicate on the "operation" field. +func OperationHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldOperation, v)) } -// IconLT applies the LT predicate on the "icon" field. -func IconLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldIcon, v)) +// OperationHasSuffix applies the HasSuffix predicate on the "operation" field. +func OperationHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldOperation, v)) } -// IconLTE applies the LTE predicate on the "icon" field. -func IconLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldIcon, v)) +// OperationIsNil applies the IsNil predicate on the "operation" field. +func OperationIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldOperation)) } -// IconContains applies the Contains predicate on the "icon" field. -func IconContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldIcon, v)) +// OperationNotNil applies the NotNil predicate on the "operation" field. +func OperationNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldOperation)) } -// IconHasPrefix applies the HasPrefix predicate on the "icon" field. -func IconHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldIcon, v)) +// OperationEqualFold applies the EqualFold predicate on the "operation" field. +func OperationEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldOperation, v)) } -// IconHasSuffix applies the HasSuffix predicate on the "icon" field. -func IconHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldIcon, v)) +// OperationContainsFold applies the ContainsFold predicate on the "operation" field. +func OperationContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldOperation, v)) } -// IconEqualFold applies the EqualFold predicate on the "icon" field. -func IconEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldIcon, v)) +// PolicyEQ applies the EQ predicate on the "policy" field. +func PolicyEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldPolicy, v)) } -// IconContainsFold applies the ContainsFold predicate on the "icon" field. -func IconContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldIcon, v)) +// PolicyNEQ applies the NEQ predicate on the "policy" field. +func PolicyNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldPolicy, v)) } -// SequenceEQ applies the EQ predicate on the "sequence" field. -func SequenceEQ(v int) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldSequence, v)) +// PolicyIn applies the In predicate on the "policy" field. +func PolicyIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldPolicy, vs...)) } -// SequenceNEQ applies the NEQ predicate on the "sequence" field. -func SequenceNEQ(v int) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldSequence, v)) +// PolicyNotIn applies the NotIn predicate on the "policy" field. +func PolicyNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldPolicy, vs...)) } -// SequenceIn applies the In predicate on the "sequence" field. -func SequenceIn(vs ...int) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldSequence, vs...)) +// PolicyGT applies the GT predicate on the "policy" field. +func PolicyGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldPolicy, v)) } -// SequenceNotIn applies the NotIn predicate on the "sequence" field. -func SequenceNotIn(vs ...int) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldSequence, vs...)) +// PolicyGTE applies the GTE predicate on the "policy" field. +func PolicyGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldPolicy, v)) } -// SequenceGT applies the GT predicate on the "sequence" field. -func SequenceGT(v int) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldSequence, v)) +// PolicyLT applies the LT predicate on the "policy" field. +func PolicyLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldPolicy, v)) } -// SequenceGTE applies the GTE predicate on the "sequence" field. -func SequenceGTE(v int) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldSequence, v)) +// PolicyLTE applies the LTE predicate on the "policy" field. +func PolicyLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldPolicy, v)) } -// SequenceLT applies the LT predicate on the "sequence" field. -func SequenceLT(v int) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldSequence, v)) +// PolicyContains applies the Contains predicate on the "policy" field. +func PolicyContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldPolicy, v)) } -// SequenceLTE applies the LTE predicate on the "sequence" field. -func SequenceLTE(v int) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldSequence, v)) +// PolicyHasPrefix applies the HasPrefix predicate on the "policy" field. +func PolicyHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldPolicy, v)) } -// VisibleEQ applies the EQ predicate on the "visible" field. -func VisibleEQ(v bool) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldVisible, v)) +// PolicyHasSuffix applies the HasSuffix predicate on the "policy" field. +func PolicyHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldPolicy, v)) } -// VisibleNEQ applies the NEQ predicate on the "visible" field. -func VisibleNEQ(v bool) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldVisible, v)) +// PolicyEqualFold applies the EqualFold predicate on the "policy" field. +func PolicyEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldPolicy, v)) } -// LevelEQ applies the EQ predicate on the "level" field. -func LevelEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldLevel, v)) +// PolicyContainsFold applies the ContainsFold predicate on the "policy" field. +func PolicyContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldPolicy, v)) } -// LevelNEQ applies the NEQ predicate on the "level" field. -func LevelNEQ(v int8) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldLevel, v)) +// VersionIDEQ applies the EQ predicate on the "version_id" field. +func VersionIDEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldVersionID, v)) } -// LevelIn applies the In predicate on the "level" field. -func LevelIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldLevel, vs...)) +// VersionIDNEQ applies the NEQ predicate on the "version_id" field. +func VersionIDNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldVersionID, v)) } -// LevelNotIn applies the NotIn predicate on the "level" field. -func LevelNotIn(vs ...int8) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldLevel, vs...)) +// VersionIDIn applies the In predicate on the "version_id" field. +func VersionIDIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldVersionID, vs...)) } -// LevelGT applies the GT predicate on the "level" field. -func LevelGT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldLevel, v)) +// VersionIDNotIn applies the NotIn predicate on the "version_id" field. +func VersionIDNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldVersionID, vs...)) } -// LevelGTE applies the GTE predicate on the "level" field. -func LevelGTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldLevel, v)) +// VersionIDGT applies the GT predicate on the "version_id" field. +func VersionIDGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldVersionID, v)) } -// LevelLT applies the LT predicate on the "level" field. -func LevelLT(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldLevel, v)) +// VersionIDGTE applies the GTE predicate on the "version_id" field. +func VersionIDGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldVersionID, v)) } -// LevelLTE applies the LTE predicate on the "level" field. -func LevelLTE(v int8) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldLevel, v)) +// VersionIDLT applies the LT predicate on the "version_id" field. +func VersionIDLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldVersionID, v)) } -// TreePathEQ applies the EQ predicate on the "tree_path" field. -func TreePathEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) +// VersionIDLTE applies the LTE predicate on the "version_id" field. +func VersionIDLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldVersionID, v)) } -// TreePathNEQ applies the NEQ predicate on the "tree_path" field. -func TreePathNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldTreePath, v)) +// VersionIDContains applies the Contains predicate on the "version_id" field. +func VersionIDContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldVersionID, v)) } -// TreePathIn applies the In predicate on the "tree_path" field. -func TreePathIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldTreePath, vs...)) +// VersionIDHasPrefix applies the HasPrefix predicate on the "version_id" field. +func VersionIDHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldVersionID, v)) } -// TreePathNotIn applies the NotIn predicate on the "tree_path" field. -func TreePathNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldTreePath, vs...)) +// VersionIDHasSuffix applies the HasSuffix predicate on the "version_id" field. +func VersionIDHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldVersionID, v)) } -// TreePathGT applies the GT predicate on the "tree_path" field. -func TreePathGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldTreePath, v)) +// VersionIDEqualFold applies the EqualFold predicate on the "version_id" field. +func VersionIDEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldVersionID, v)) } -// TreePathGTE applies the GTE predicate on the "tree_path" field. -func TreePathGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldTreePath, v)) +// VersionIDContainsFold applies the ContainsFold predicate on the "version_id" field. +func VersionIDContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldVersionID, v)) } -// TreePathLT applies the LT predicate on the "tree_path" field. -func TreePathLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldTreePath, v)) +// LastSyncVersionIDEQ applies the EQ predicate on the "last_sync_version_id" field. +func LastSyncVersionIDEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldLastSyncVersionID, v)) } -// TreePathLTE applies the LTE predicate on the "tree_path" field. -func TreePathLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldTreePath, v)) +// LastSyncVersionIDNEQ applies the NEQ predicate on the "last_sync_version_id" field. +func LastSyncVersionIDNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldLastSyncVersionID, v)) } -// TreePathContains applies the Contains predicate on the "tree_path" field. -func TreePathContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldTreePath, v)) +// LastSyncVersionIDIn applies the In predicate on the "last_sync_version_id" field. +func LastSyncVersionIDIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldLastSyncVersionID, vs...)) } -// TreePathHasPrefix applies the HasPrefix predicate on the "tree_path" field. -func TreePathHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldTreePath, v)) +// LastSyncVersionIDNotIn applies the NotIn predicate on the "last_sync_version_id" field. +func LastSyncVersionIDNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldLastSyncVersionID, vs...)) } -// TreePathHasSuffix applies the HasSuffix predicate on the "tree_path" field. -func TreePathHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldTreePath, v)) +// LastSyncVersionIDGT applies the GT predicate on the "last_sync_version_id" field. +func LastSyncVersionIDGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldLastSyncVersionID, v)) } -// TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. -func TreePathEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldTreePath, v)) +// LastSyncVersionIDGTE applies the GTE predicate on the "last_sync_version_id" field. +func LastSyncVersionIDGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldLastSyncVersionID, v)) } -// TreePathContainsFold applies the ContainsFold predicate on the "tree_path" field. -func TreePathContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldTreePath, v)) +// LastSyncVersionIDLT applies the LT predicate on the "last_sync_version_id" field. +func LastSyncVersionIDLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldLastSyncVersionID, v)) } -// PropertiesIsNil applies the IsNil predicate on the "properties" field. -func PropertiesIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldProperties)) +// LastSyncVersionIDLTE applies the LTE predicate on the "last_sync_version_id" field. +func LastSyncVersionIDLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldLastSyncVersionID, v)) } -// PropertiesNotNil applies the NotNil predicate on the "properties" field. -func PropertiesNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldProperties)) +// LastSyncVersionIDContains applies the Contains predicate on the "last_sync_version_id" field. +func LastSyncVersionIDContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldLastSyncVersionID, v)) } -// DescriptionEQ applies the EQ predicate on the "description" field. -func DescriptionEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldDescription, v)) +// LastSyncVersionIDHasPrefix applies the HasPrefix predicate on the "last_sync_version_id" field. +func LastSyncVersionIDHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldLastSyncVersionID, v)) } -// DescriptionNEQ applies the NEQ predicate on the "description" field. -func DescriptionNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldDescription, v)) +// LastSyncVersionIDHasSuffix applies the HasSuffix predicate on the "last_sync_version_id" field. +func LastSyncVersionIDHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldLastSyncVersionID, v)) } -// DescriptionIn applies the In predicate on the "description" field. -func DescriptionIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldDescription, vs...)) +// LastSyncVersionIDEqualFold applies the EqualFold predicate on the "last_sync_version_id" field. +func LastSyncVersionIDEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldLastSyncVersionID, v)) } -// DescriptionNotIn applies the NotIn predicate on the "description" field. -func DescriptionNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldDescription, vs...)) +// LastSyncVersionIDContainsFold applies the ContainsFold predicate on the "last_sync_version_id" field. +func LastSyncVersionIDContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldLastSyncVersionID, v)) } -// DescriptionGT applies the GT predicate on the "description" field. -func DescriptionGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldDescription, v)) +// SyncStatusEQ applies the EQ predicate on the "sync_status" field. +func SyncStatusEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldSyncStatus, v)) } -// DescriptionGTE applies the GTE predicate on the "description" field. -func DescriptionGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldDescription, v)) +// SyncStatusNEQ applies the NEQ predicate on the "sync_status" field. +func SyncStatusNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldSyncStatus, v)) } -// DescriptionLT applies the LT predicate on the "description" field. -func DescriptionLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldDescription, v)) +// SyncStatusIn applies the In predicate on the "sync_status" field. +func SyncStatusIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldSyncStatus, vs...)) } -// DescriptionLTE applies the LTE predicate on the "description" field. -func DescriptionLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldDescription, v)) +// SyncStatusNotIn applies the NotIn predicate on the "sync_status" field. +func SyncStatusNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldSyncStatus, vs...)) } -// DescriptionContains applies the Contains predicate on the "description" field. -func DescriptionContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldDescription, v)) +// SyncStatusGT applies the GT predicate on the "sync_status" field. +func SyncStatusGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldSyncStatus, v)) } -// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. -func DescriptionHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldDescription, v)) +// SyncStatusGTE applies the GTE predicate on the "sync_status" field. +func SyncStatusGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldSyncStatus, v)) } -// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. -func DescriptionHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldDescription, v)) +// SyncStatusLT applies the LT predicate on the "sync_status" field. +func SyncStatusLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldSyncStatus, v)) } -// DescriptionEqualFold applies the EqualFold predicate on the "description" field. -func DescriptionEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldDescription, v)) +// SyncStatusLTE applies the LTE predicate on the "sync_status" field. +func SyncStatusLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldSyncStatus, v)) } -// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. -func DescriptionContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldDescription, v)) +// SyncStatusContains applies the Contains predicate on the "sync_status" field. +func SyncStatusContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldSyncStatus, v)) } -// ParentIDEQ applies the EQ predicate on the "parent_id" field. -func ParentIDEQ(v int64) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldParentID, v)) +// SyncStatusHasPrefix applies the HasPrefix predicate on the "sync_status" field. +func SyncStatusHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldSyncStatus, v)) } -// ParentIDNEQ applies the NEQ predicate on the "parent_id" field. -func ParentIDNEQ(v int64) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldParentID, v)) +// SyncStatusHasSuffix applies the HasSuffix predicate on the "sync_status" field. +func SyncStatusHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldSyncStatus, v)) } -// ParentIDIn applies the In predicate on the "parent_id" field. -func ParentIDIn(vs ...int64) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldParentID, vs...)) +// SyncStatusEqualFold applies the EqualFold predicate on the "sync_status" field. +func SyncStatusEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldSyncStatus, v)) } -// ParentIDNotIn applies the NotIn predicate on the "parent_id" field. -func ParentIDNotIn(vs ...int64) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldParentID, vs...)) +// SyncStatusContainsFold applies the ContainsFold predicate on the "sync_status" field. +func SyncStatusContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldSyncStatus, v)) } -// ParentIDIsNil applies the IsNil predicate on the "parent_id" field. -func ParentIDIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldParentID)) +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v Status) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldStatus, v)) } -// ParentIDNotNil applies the NotNil predicate on the "parent_id" field. -func ParentIDNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldParentID)) +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v Status) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldStatus, v)) } -// HasChildren applies the HasEdge predicate on the "children" edge. -func HasChildren() predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...Status) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldStatus, vs...)) } -// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates). -func HasChildrenWith(preds ...predicate.Resource) predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := newChildrenStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...Status) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldStatus, vs...)) } -// HasParent applies the HasEdge predicate on the "parent" edge. -func HasParent() predicate.Resource { +// HasViews applies the HasEdge predicate on the "views" edge. +func HasViews() predicate.Resource { return predicate.Resource(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + sqlgraph.Edge(sqlgraph.M2M, false, ViewsTable, ViewsPrimaryKey...), ) sqlgraph.HasNeighbors(s, step) }) } -// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). -func HasParentWith(preds ...predicate.Resource) predicate.Resource { +// HasViewsWith applies the HasEdge predicate on the "views" edge with a given conditions (other predicates). +func HasViewsWith(preds ...predicate.View) predicate.Resource { return predicate.Resource(func(s *sql.Selector) { - step := newParentStep() + step := newViewsStep() sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { for _, p := range preds { p(s) @@ -1179,29 +866,6 @@ func HasPermissionsWith(preds ...predicate.Permission) predicate.Resource { }) } -// HasPermissionResources applies the HasEdge predicate on the "permission_resources" edge. -func HasPermissionResources() predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := sqlgraph.NewStep( - sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), - ) - sqlgraph.HasNeighbors(s, step) - }) -} - -// HasPermissionResourcesWith applies the HasEdge predicate on the "permission_resources" edge with a given conditions (other predicates). -func HasPermissionResourcesWith(preds ...predicate.PermissionResource) predicate.Resource { - return predicate.Resource(func(s *sql.Selector) { - step := newPermissionResourcesStep() - sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { - for _, p := range preds { - p(s) - } - }) - }) -} - // And groups predicates with the AND operator between them. func And(predicates ...predicate.Resource) predicate.Resource { return predicate.Resource(sql.AndPredicates(predicates...)) diff --git a/internal/data/entity/ent/resource_create.go b/internal/data/entity/ent/resource_create.go index 203a26fd..f427f632 100644 --- a/internal/data/entity/ent/resource_create.go +++ b/internal/data/entity/ent/resource_create.go @@ -7,8 +7,8 @@ import ( "errors" "fmt" "origadmin/application/admin/internal/data/entity/ent/permission" - "origadmin/application/admin/internal/data/entity/ent/permissionresource" "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/view" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -50,17 +50,9 @@ func (_c *ResourceCreate) SetNillableUpdateTime(v *time.Time) *ResourceCreate { return _c } -// SetName sets the "name" field. -func (_c *ResourceCreate) SetName(v string) *ResourceCreate { - _c.mutation.SetName(v) - return _c -} - -// SetNillableName sets the "name" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableName(v *string) *ResourceCreate { - if v != nil { - _c.SetName(*v) - } +// SetServiceName sets the "service_name" field. +func (_c *ResourceCreate) SetServiceName(v string) *ResourceCreate { + _c.mutation.SetServiceName(v) return _c } @@ -70,48 +62,6 @@ func (_c *ResourceCreate) SetKeyword(v string) *ResourceCreate { return _c } -// SetI18nKey sets the "i18n_key" field. -func (_c *ResourceCreate) SetI18nKey(v string) *ResourceCreate { - _c.mutation.SetI18nKey(v) - return _c -} - -// SetNillableI18nKey sets the "i18n_key" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableI18nKey(v *string) *ResourceCreate { - if v != nil { - _c.SetI18nKey(*v) - } - return _c -} - -// SetType sets the "type" field. -func (_c *ResourceCreate) SetType(v string) *ResourceCreate { - _c.mutation.SetType(v) - return _c -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableType(v *string) *ResourceCreate { - if v != nil { - _c.SetType(*v) - } - return _c -} - -// SetStatus sets the "status" field. -func (_c *ResourceCreate) SetStatus(v int8) *ResourceCreate { - _c.mutation.SetStatus(v) - return _c -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableStatus(v *int8) *ResourceCreate { - if v != nil { - _c.SetStatus(*v) - } - return _c -} - // SetPath sets the "path" field. func (_c *ResourceCreate) SetPath(v string) *ResourceCreate { _c.mutation.SetPath(v) @@ -126,20 +76,6 @@ func (_c *ResourceCreate) SetNillablePath(v *string) *ResourceCreate { return _c } -// SetOperation sets the "operation" field. -func (_c *ResourceCreate) SetOperation(v string) *ResourceCreate { - _c.mutation.SetOperation(v) - return _c -} - -// SetNillableOperation sets the "operation" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableOperation(v *string) *ResourceCreate { - if v != nil { - _c.SetOperation(*v) - } - return _c -} - // SetMethod sets the "method" field. func (_c *ResourceCreate) SetMethod(v string) *ResourceCreate { _c.mutation.SetMethod(v) @@ -154,120 +90,86 @@ func (_c *ResourceCreate) SetNillableMethod(v *string) *ResourceCreate { return _c } -// SetComponent sets the "component" field. -func (_c *ResourceCreate) SetComponent(v string) *ResourceCreate { - _c.mutation.SetComponent(v) - return _c -} - -// SetNillableComponent sets the "component" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableComponent(v *string) *ResourceCreate { - if v != nil { - _c.SetComponent(*v) - } - return _c -} - -// SetIcon sets the "icon" field. -func (_c *ResourceCreate) SetIcon(v string) *ResourceCreate { - _c.mutation.SetIcon(v) - return _c -} - -// SetNillableIcon sets the "icon" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableIcon(v *string) *ResourceCreate { - if v != nil { - _c.SetIcon(*v) - } - return _c -} - -// SetSequence sets the "sequence" field. -func (_c *ResourceCreate) SetSequence(v int) *ResourceCreate { - _c.mutation.SetSequence(v) +// SetOperation sets the "operation" field. +func (_c *ResourceCreate) SetOperation(v string) *ResourceCreate { + _c.mutation.SetOperation(v) return _c } -// SetNillableSequence sets the "sequence" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableSequence(v *int) *ResourceCreate { +// SetNillableOperation sets the "operation" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableOperation(v *string) *ResourceCreate { if v != nil { - _c.SetSequence(*v) + _c.SetOperation(*v) } return _c } -// SetVisible sets the "visible" field. -func (_c *ResourceCreate) SetVisible(v bool) *ResourceCreate { - _c.mutation.SetVisible(v) +// SetPolicy sets the "policy" field. +func (_c *ResourceCreate) SetPolicy(v string) *ResourceCreate { + _c.mutation.SetPolicy(v) return _c } -// SetNillableVisible sets the "visible" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableVisible(v *bool) *ResourceCreate { +// SetNillablePolicy sets the "policy" field if the given value is not nil. +func (_c *ResourceCreate) SetNillablePolicy(v *string) *ResourceCreate { if v != nil { - _c.SetVisible(*v) + _c.SetPolicy(*v) } return _c } -// SetLevel sets the "level" field. -func (_c *ResourceCreate) SetLevel(v int8) *ResourceCreate { - _c.mutation.SetLevel(v) +// SetVersionID sets the "version_id" field. +func (_c *ResourceCreate) SetVersionID(v string) *ResourceCreate { + _c.mutation.SetVersionID(v) return _c } -// SetNillableLevel sets the "level" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableLevel(v *int8) *ResourceCreate { +// SetNillableVersionID sets the "version_id" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableVersionID(v *string) *ResourceCreate { if v != nil { - _c.SetLevel(*v) + _c.SetVersionID(*v) } return _c } -// SetTreePath sets the "tree_path" field. -func (_c *ResourceCreate) SetTreePath(v string) *ResourceCreate { - _c.mutation.SetTreePath(v) +// SetLastSyncVersionID sets the "last_sync_version_id" field. +func (_c *ResourceCreate) SetLastSyncVersionID(v string) *ResourceCreate { + _c.mutation.SetLastSyncVersionID(v) return _c } -// SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableTreePath(v *string) *ResourceCreate { +// SetNillableLastSyncVersionID sets the "last_sync_version_id" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableLastSyncVersionID(v *string) *ResourceCreate { if v != nil { - _c.SetTreePath(*v) + _c.SetLastSyncVersionID(*v) } return _c } -// SetProperties sets the "properties" field. -func (_c *ResourceCreate) SetProperties(v map[string]string) *ResourceCreate { - _c.mutation.SetProperties(v) - return _c -} - -// SetDescription sets the "description" field. -func (_c *ResourceCreate) SetDescription(v string) *ResourceCreate { - _c.mutation.SetDescription(v) +// SetSyncStatus sets the "sync_status" field. +func (_c *ResourceCreate) SetSyncStatus(v string) *ResourceCreate { + _c.mutation.SetSyncStatus(v) return _c } -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableDescription(v *string) *ResourceCreate { +// SetNillableSyncStatus sets the "sync_status" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableSyncStatus(v *string) *ResourceCreate { if v != nil { - _c.SetDescription(*v) + _c.SetSyncStatus(*v) } return _c } -// SetParentID sets the "parent_id" field. -func (_c *ResourceCreate) SetParentID(v int64) *ResourceCreate { - _c.mutation.SetParentID(v) +// SetStatus sets the "status" field. +func (_c *ResourceCreate) SetStatus(v resource.Status) *ResourceCreate { + _c.mutation.SetStatus(v) return _c } -// SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableParentID(v *int64) *ResourceCreate { +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableStatus(v *resource.Status) *ResourceCreate { if v != nil { - _c.SetParentID(*v) + _c.SetStatus(*v) } return _c } @@ -286,24 +188,19 @@ func (_c *ResourceCreate) SetNillableID(v *int64) *ResourceCreate { return _c } -// AddChildIDs adds the "children" edge to the Resource entity by IDs. -func (_c *ResourceCreate) AddChildIDs(ids ...int64) *ResourceCreate { - _c.mutation.AddChildIDs(ids...) +// AddViewIDs adds the "views" edge to the View entity by IDs. +func (_c *ResourceCreate) AddViewIDs(ids ...int64) *ResourceCreate { + _c.mutation.AddViewIDs(ids...) return _c } -// AddChildren adds the "children" edges to the Resource entity. -func (_c *ResourceCreate) AddChildren(v ...*Resource) *ResourceCreate { +// AddViews adds the "views" edges to the View entity. +func (_c *ResourceCreate) AddViews(v ...*View) *ResourceCreate { ids := make([]int64, len(v)) for i := range v { ids[i] = v[i].ID } - return _c.AddChildIDs(ids...) -} - -// SetParent sets the "parent" edge to the Resource entity. -func (_c *ResourceCreate) SetParent(v *Resource) *ResourceCreate { - return _c.SetParentID(v.ID) + return _c.AddViewIDs(ids...) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. @@ -321,21 +218,6 @@ func (_c *ResourceCreate) AddPermissions(v ...*Permission) *ResourceCreate { return _c.AddPermissionIDs(ids...) } -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (_c *ResourceCreate) AddPermissionResourceIDs(ids ...int) *ResourceCreate { - _c.mutation.AddPermissionResourceIDs(ids...) - return _c -} - -// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (_c *ResourceCreate) AddPermissionResources(v ...*PermissionResource) *ResourceCreate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _c.AddPermissionResourceIDs(ids...) -} - // Mutation returns the ResourceMutation object of the builder. func (_c *ResourceCreate) Mutation() *ResourceMutation { return _c.mutation @@ -379,62 +261,26 @@ func (_c *ResourceCreate) defaults() { v := resource.DefaultUpdateTime() _c.mutation.SetUpdateTime(v) } - if _, ok := _c.mutation.Name(); !ok { - v := resource.DefaultName - _c.mutation.SetName(v) + if _, ok := _c.mutation.Policy(); !ok { + v := resource.DefaultPolicy + _c.mutation.SetPolicy(v) + } + if _, ok := _c.mutation.VersionID(); !ok { + v := resource.DefaultVersionID + _c.mutation.SetVersionID(v) } - if _, ok := _c.mutation.I18nKey(); !ok { - v := resource.DefaultI18nKey - _c.mutation.SetI18nKey(v) + if _, ok := _c.mutation.LastSyncVersionID(); !ok { + v := resource.DefaultLastSyncVersionID + _c.mutation.SetLastSyncVersionID(v) } - if _, ok := _c.mutation.GetType(); !ok { - v := resource.DefaultType - _c.mutation.SetType(v) + if _, ok := _c.mutation.SyncStatus(); !ok { + v := resource.DefaultSyncStatus + _c.mutation.SetSyncStatus(v) } if _, ok := _c.mutation.Status(); !ok { v := resource.DefaultStatus _c.mutation.SetStatus(v) } - if _, ok := _c.mutation.Path(); !ok { - v := resource.DefaultPath - _c.mutation.SetPath(v) - } - if _, ok := _c.mutation.Operation(); !ok { - v := resource.DefaultOperation - _c.mutation.SetOperation(v) - } - if _, ok := _c.mutation.Method(); !ok { - v := resource.DefaultMethod - _c.mutation.SetMethod(v) - } - if _, ok := _c.mutation.Component(); !ok { - v := resource.DefaultComponent - _c.mutation.SetComponent(v) - } - if _, ok := _c.mutation.Icon(); !ok { - v := resource.DefaultIcon - _c.mutation.SetIcon(v) - } - if _, ok := _c.mutation.Sequence(); !ok { - v := resource.DefaultSequence - _c.mutation.SetSequence(v) - } - if _, ok := _c.mutation.Visible(); !ok { - v := resource.DefaultVisible - _c.mutation.SetVisible(v) - } - if _, ok := _c.mutation.Level(); !ok { - v := resource.DefaultLevel - _c.mutation.SetLevel(v) - } - if _, ok := _c.mutation.TreePath(); !ok { - v := resource.DefaultTreePath - _c.mutation.SetTreePath(v) - } - if _, ok := _c.mutation.Description(); !ok { - v := resource.DefaultDescription - _c.mutation.SetDescription(v) - } if _, ok := _c.mutation.ID(); !ok { v := resource.DefaultID() _c.mutation.SetID(v) @@ -449,13 +295,8 @@ func (_c *ResourceCreate) check() error { if _, ok := _c.mutation.UpdateTime(); !ok { return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Resource.update_time"`)} } - if _, ok := _c.mutation.Name(); !ok { - return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Resource.name"`)} - } - if v, ok := _c.mutation.Name(); ok { - if err := resource.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} - } + if _, ok := _c.mutation.ServiceName(); !ok { + return &ValidationError{Name: "service_name", err: errors.New(`ent: missing required field "Resource.service_name"`)} } if _, ok := _c.mutation.Keyword(); !ok { return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Resource.keyword"`)} @@ -465,93 +306,24 @@ func (_c *ResourceCreate) check() error { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} } } - if _, ok := _c.mutation.I18nKey(); !ok { - return &ValidationError{Name: "i18n_key", err: errors.New(`ent: missing required field "Resource.i18n_key"`)} + if _, ok := _c.mutation.Policy(); !ok { + return &ValidationError{Name: "policy", err: errors.New(`ent: missing required field "Resource.policy"`)} } - if v, ok := _c.mutation.I18nKey(); ok { - if err := resource.I18nKeyValidator(v); err != nil { - return &ValidationError{Name: "i18n_key", err: fmt.Errorf(`ent: validator failed for field "Resource.i18n_key": %w`, err)} - } + if _, ok := _c.mutation.VersionID(); !ok { + return &ValidationError{Name: "version_id", err: errors.New(`ent: missing required field "Resource.version_id"`)} } - if _, ok := _c.mutation.GetType(); !ok { - return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Resource.type"`)} + if _, ok := _c.mutation.LastSyncVersionID(); !ok { + return &ValidationError{Name: "last_sync_version_id", err: errors.New(`ent: missing required field "Resource.last_sync_version_id"`)} } - if v, ok := _c.mutation.GetType(); ok { - if err := resource.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} - } + if _, ok := _c.mutation.SyncStatus(); !ok { + return &ValidationError{Name: "sync_status", err: errors.New(`ent: missing required field "Resource.sync_status"`)} } if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Resource.status"`)} } - if _, ok := _c.mutation.Path(); !ok { - return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "Resource.path"`)} - } - if v, ok := _c.mutation.Path(); ok { - if err := resource.PathValidator(v); err != nil { - return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} - } - } - if _, ok := _c.mutation.Operation(); !ok { - return &ValidationError{Name: "operation", err: errors.New(`ent: missing required field "Resource.operation"`)} - } - if v, ok := _c.mutation.Operation(); ok { - if err := resource.OperationValidator(v); err != nil { - return &ValidationError{Name: "operation", err: fmt.Errorf(`ent: validator failed for field "Resource.operation": %w`, err)} - } - } - if _, ok := _c.mutation.Method(); !ok { - return &ValidationError{Name: "method", err: errors.New(`ent: missing required field "Resource.method"`)} - } - if v, ok := _c.mutation.Method(); ok { - if err := resource.MethodValidator(v); err != nil { - return &ValidationError{Name: "method", err: fmt.Errorf(`ent: validator failed for field "Resource.method": %w`, err)} - } - } - if _, ok := _c.mutation.Component(); !ok { - return &ValidationError{Name: "component", err: errors.New(`ent: missing required field "Resource.component"`)} - } - if v, ok := _c.mutation.Component(); ok { - if err := resource.ComponentValidator(v); err != nil { - return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} - } - } - if _, ok := _c.mutation.Icon(); !ok { - return &ValidationError{Name: "icon", err: errors.New(`ent: missing required field "Resource.icon"`)} - } - if v, ok := _c.mutation.Icon(); ok { - if err := resource.IconValidator(v); err != nil { - return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} - } - } - if _, ok := _c.mutation.Sequence(); !ok { - return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "Resource.sequence"`)} - } - if _, ok := _c.mutation.Visible(); !ok { - return &ValidationError{Name: "visible", err: errors.New(`ent: missing required field "Resource.visible"`)} - } - if _, ok := _c.mutation.Level(); !ok { - return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "Resource.level"`)} - } - if _, ok := _c.mutation.TreePath(); !ok { - return &ValidationError{Name: "tree_path", err: errors.New(`ent: missing required field "Resource.tree_path"`)} - } - if v, ok := _c.mutation.TreePath(); ok { - if err := resource.TreePathValidator(v); err != nil { - return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} - } - } - if _, ok := _c.mutation.Description(); !ok { - return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Resource.description"`)} - } - if v, ok := _c.mutation.Description(); ok { - if err := resource.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} - } - } - if v, ok := _c.mutation.ParentID(); ok { - if err := resource.ParentIDValidator(v); err != nil { - return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Resource.parent_id": %w`, err)} + if v, ok := _c.mutation.Status(); ok { + if err := resource.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Resource.status": %w`, err)} } } if v, ok := _c.mutation.ID(); ok { @@ -599,101 +371,60 @@ func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) _node.UpdateTime = value } - if value, ok := _c.mutation.Name(); ok { - _spec.SetField(resource.FieldName, field.TypeString, value) - _node.Name = value + if value, ok := _c.mutation.ServiceName(); ok { + _spec.SetField(resource.FieldServiceName, field.TypeString, value) + _node.ServiceName = value } if value, ok := _c.mutation.Keyword(); ok { _spec.SetField(resource.FieldKeyword, field.TypeString, value) _node.Keyword = value } - if value, ok := _c.mutation.I18nKey(); ok { - _spec.SetField(resource.FieldI18nKey, field.TypeString, value) - _node.I18nKey = value - } - if value, ok := _c.mutation.GetType(); ok { - _spec.SetField(resource.FieldType, field.TypeString, value) - _node.Type = value - } - if value, ok := _c.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeInt8, value) - _node.Status = value - } if value, ok := _c.mutation.Path(); ok { _spec.SetField(resource.FieldPath, field.TypeString, value) _node.Path = value } - if value, ok := _c.mutation.Operation(); ok { - _spec.SetField(resource.FieldOperation, field.TypeString, value) - _node.Operation = value - } if value, ok := _c.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) _node.Method = value } - if value, ok := _c.mutation.Component(); ok { - _spec.SetField(resource.FieldComponent, field.TypeString, value) - _node.Component = value - } - if value, ok := _c.mutation.Icon(); ok { - _spec.SetField(resource.FieldIcon, field.TypeString, value) - _node.Icon = value - } - if value, ok := _c.mutation.Sequence(); ok { - _spec.SetField(resource.FieldSequence, field.TypeInt, value) - _node.Sequence = value + if value, ok := _c.mutation.Operation(); ok { + _spec.SetField(resource.FieldOperation, field.TypeString, value) + _node.Operation = value } - if value, ok := _c.mutation.Visible(); ok { - _spec.SetField(resource.FieldVisible, field.TypeBool, value) - _node.Visible = value + if value, ok := _c.mutation.Policy(); ok { + _spec.SetField(resource.FieldPolicy, field.TypeString, value) + _node.Policy = value } - if value, ok := _c.mutation.Level(); ok { - _spec.SetField(resource.FieldLevel, field.TypeInt8, value) - _node.Level = value + if value, ok := _c.mutation.VersionID(); ok { + _spec.SetField(resource.FieldVersionID, field.TypeString, value) + _node.VersionID = value } - if value, ok := _c.mutation.TreePath(); ok { - _spec.SetField(resource.FieldTreePath, field.TypeString, value) - _node.TreePath = value + if value, ok := _c.mutation.LastSyncVersionID(); ok { + _spec.SetField(resource.FieldLastSyncVersionID, field.TypeString, value) + _node.LastSyncVersionID = value } - if value, ok := _c.mutation.Properties(); ok { - _spec.SetField(resource.FieldProperties, field.TypeJSON, value) - _node.Properties = value + if value, ok := _c.mutation.SyncStatus(); ok { + _spec.SetField(resource.FieldSyncStatus, field.TypeString, value) + _node.SyncStatus = value } - if value, ok := _c.mutation.Description(); ok { - _spec.SetField(resource.FieldDescription, field.TypeString, value) - _node.Description = value + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(resource.FieldStatus, field.TypeEnum, value) + _node.Status = value } - if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 { + if nodes := _c.mutation.ViewsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, + Rel: sqlgraph.M2M, Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: true, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } - if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: resource.ParentTable, - Columns: []string{resource.ParentColumn}, + Table: resource.ViewsTable, + Columns: resource.ViewsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } - _node.ParentID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { @@ -712,22 +443,6 @@ func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := _c.mutation.PermissionResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges = append(_spec.Edges, edge) - } return _node, _spec } diff --git a/internal/data/entity/ent/resource_query.go b/internal/data/entity/ent/resource_query.go index b03e9e39..99d6894c 100644 --- a/internal/data/entity/ent/resource_query.go +++ b/internal/data/entity/ent/resource_query.go @@ -8,9 +8,9 @@ import ( "fmt" "math" "origadmin/application/admin/internal/data/entity/ent/permission" - "origadmin/application/admin/internal/data/entity/ent/permissionresource" "origadmin/application/admin/internal/data/entity/ent/predicate" "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/view" "entgo.io/ent" "entgo.io/ent/dialect" @@ -22,15 +22,13 @@ import ( // ResourceQuery is the builder for querying Resource entities. type ResourceQuery struct { config - ctx *QueryContext - order []resource.OrderOption - inters []Interceptor - predicates []predicate.Resource - withChildren *ResourceQuery - withParent *ResourceQuery - withPermissions *PermissionQuery - withPermissionResources *PermissionResourceQuery - modifiers []func(*sql.Selector) + ctx *QueryContext + order []resource.OrderOption + inters []Interceptor + predicates []predicate.Resource + withViews *ViewQuery + withPermissions *PermissionQuery + modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -67,9 +65,9 @@ func (_q *ResourceQuery) Order(o ...resource.OrderOption) *ResourceQuery { return _q } -// QueryChildren chains the current query on the "children" edge. -func (_q *ResourceQuery) QueryChildren() *ResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() +// QueryViews chains the current query on the "views" edge. +func (_q *ResourceQuery) QueryViews() *ViewQuery { + query := (&ViewClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := _q.prepareQuery(ctx); err != nil { return nil, err @@ -80,30 +78,8 @@ func (_q *ResourceQuery) QueryChildren() *ResourceQuery { } step := sqlgraph.NewStep( sqlgraph.From(resource.Table, resource.FieldID, selector), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.O2M, false, resource.ChildrenTable, resource.ChildrenColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - -// QueryParent chains the current query on the "parent" edge. -func (_q *ResourceQuery) QueryParent() *ResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, selector), - sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.M2O, true, resource.ParentTable, resource.ParentColumn), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.M2M, false, resource.ViewsTable, resource.ViewsPrimaryKey...), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -133,28 +109,6 @@ func (_q *ResourceQuery) QueryPermissions() *PermissionQuery { return query } -// QueryPermissionResources chains the current query on the "permission_resources" edge. -func (_q *ResourceQuery) QueryPermissionResources() *PermissionResourceQuery { - query := (&PermissionResourceClient{config: _q.config}).Query() - query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := _q.prepareQuery(ctx); err != nil { - return nil, err - } - selector := _q.sqlQuery(ctx) - if err := selector.Err(); err != nil { - return nil, err - } - step := sqlgraph.NewStep( - sqlgraph.From(resource.Table, resource.FieldID, selector), - sqlgraph.To(permissionresource.Table, permissionresource.FieldID), - sqlgraph.Edge(sqlgraph.O2M, true, resource.PermissionResourcesTable, resource.PermissionResourcesColumn), - ) - fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) - return fromU, nil - } - return query -} - // First returns the first Resource entity from the query. // Returns a *NotFoundError when no Resource was found. func (_q *ResourceQuery) First(ctx context.Context) (*Resource, error) { @@ -342,15 +296,13 @@ func (_q *ResourceQuery) Clone() *ResourceQuery { return nil } return &ResourceQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]resource.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.Resource{}, _q.predicates...), - withChildren: _q.withChildren.Clone(), - withParent: _q.withParent.Clone(), - withPermissions: _q.withPermissions.Clone(), - withPermissionResources: _q.withPermissionResources.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]resource.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Resource{}, _q.predicates...), + withViews: _q.withViews.Clone(), + withPermissions: _q.withPermissions.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, @@ -358,25 +310,14 @@ func (_q *ResourceQuery) Clone() *ResourceQuery { } } -// WithChildren tells the query-builder to eager-load the nodes that are connected to -// the "children" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *ResourceQuery) WithChildren(opts ...func(*ResourceQuery)) *ResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withChildren = query - return _q -} - -// WithParent tells the query-builder to eager-load the nodes that are connected to -// the "parent" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *ResourceQuery) WithParent(opts ...func(*ResourceQuery)) *ResourceQuery { - query := (&ResourceClient{config: _q.config}).Query() +// WithViews tells the query-builder to eager-load the nodes that are connected to +// the "views" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ResourceQuery) WithViews(opts ...func(*ViewQuery)) *ResourceQuery { + query := (&ViewClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - _q.withParent = query + _q.withViews = query return _q } @@ -391,17 +332,6 @@ func (_q *ResourceQuery) WithPermissions(opts ...func(*PermissionQuery)) *Resour return _q } -// WithPermissionResources tells the query-builder to eager-load the nodes that are connected to -// the "permission_resources" edge. The optional arguments are used to configure the query builder of the edge. -func (_q *ResourceQuery) WithPermissionResources(opts ...func(*PermissionResourceQuery)) *ResourceQuery { - query := (&PermissionResourceClient{config: _q.config}).Query() - for _, opt := range opts { - opt(query) - } - _q.withPermissionResources = query - return _q -} - // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -480,11 +410,9 @@ func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Res var ( nodes = []*Resource{} _spec = _q.querySpec() - loadedTypes = [4]bool{ - _q.withChildren != nil, - _q.withParent != nil, + loadedTypes = [2]bool{ + _q.withViews != nil, _q.withPermissions != nil, - _q.withPermissionResources != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -508,16 +436,10 @@ func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Res if len(nodes) == 0 { return nodes, nil } - if query := _q.withChildren; query != nil { - if err := _q.loadChildren(ctx, query, nodes, - func(n *Resource) { n.Edges.Children = []*Resource{} }, - func(n *Resource, e *Resource) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil { - return nil, err - } - } - if query := _q.withParent; query != nil { - if err := _q.loadParent(ctx, query, nodes, nil, - func(n *Resource, e *Resource) { n.Edges.Parent = e }); err != nil { + if query := _q.withViews; query != nil { + if err := _q.loadViews(ctx, query, nodes, + func(n *Resource) { n.Edges.Views = []*View{} }, + func(n *Resource, e *View) { n.Edges.Views = append(n.Edges.Views, e) }); err != nil { return nil, err } } @@ -528,73 +450,66 @@ func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Res return nil, err } } - if query := _q.withPermissionResources; query != nil { - if err := _q.loadPermissionResources(ctx, query, nodes, - func(n *Resource) { n.Edges.PermissionResources = []*PermissionResource{} }, - func(n *Resource, e *PermissionResource) { - n.Edges.PermissionResources = append(n.Edges.PermissionResources, e) - }); err != nil { - return nil, err - } - } return nodes, nil } -func (_q *ResourceQuery) loadChildren(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int64]*Resource) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] +func (_q *ResourceQuery) loadViews(ctx context.Context, query *ViewQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *View)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int64]*Resource) + nids := make(map[int64]map[*Resource]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node if init != nil { - init(nodes[i]) + init(node) } } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(resource.FieldParentID) - } - query.Where(predicate.Resource(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(resource.ChildrenColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { + query.Where(func(s *sql.Selector) { + joinT := sql.Table(resource.ViewsTable) + s.Join(joinT).On(s.C(view.FieldID), joinT.C(resource.ViewsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(resource.ViewsPrimaryKey[0]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(resource.ViewsPrimaryKey[0])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { return err } - for _, n := range neighbors { - fk := n.ParentID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "parent_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} -func (_q *ResourceQuery) loadParent(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { - ids := make([]int64, 0, len(nodes)) - nodeids := make(map[int64][]*Resource) - for i := range nodes { - fk := nodes[i].ParentID - if _, ok := nodeids[fk]; !ok { - ids = append(ids, fk) - } - nodeids[fk] = append(nodeids[fk], nodes[i]) - } - if len(ids) == 0 { - return nil - } - query.Where(resource.IDIn(ids...)) - neighbors, err := query.All(ctx) + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullInt64).Int64 + inValue := values[1].(*sql.NullInt64).Int64 + if nids[inValue] == nil { + nids[inValue] = map[*Resource]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*View](ctx, query, qr, query.inters) if err != nil { return err } for _, n := range neighbors { - nodes, ok := nodeids[n.ID] + nodes, ok := nids[n.ID] if !ok { - return fmt.Errorf(`unexpected foreign-key "parent_id" returned %v`, n.ID) + return fmt.Errorf(`unexpected "views" node returned %v`, n.ID) } - for i := range nodes { - assign(nodes[i], n) + for kn := range nodes { + assign(kn, n) } } return nil @@ -660,36 +575,6 @@ func (_q *ResourceQuery) loadPermissions(ctx context.Context, query *PermissionQ } return nil } -func (_q *ResourceQuery) loadPermissionResources(ctx context.Context, query *PermissionResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *PermissionResource)) error { - fks := make([]driver.Value, 0, len(nodes)) - nodeids := make(map[int64]*Resource) - for i := range nodes { - fks = append(fks, nodes[i].ID) - nodeids[nodes[i].ID] = nodes[i] - if init != nil { - init(nodes[i]) - } - } - if len(query.ctx.Fields) > 0 { - query.ctx.AppendFieldOnce(permissionresource.FieldResourceID) - } - query.Where(predicate.PermissionResource(func(s *sql.Selector) { - s.Where(sql.InValues(s.C(resource.PermissionResourcesColumn), fks...)) - })) - neighbors, err := query.All(ctx) - if err != nil { - return err - } - for _, n := range neighbors { - fk := n.ResourceID - node, ok := nodeids[fk] - if !ok { - return fmt.Errorf(`unexpected referenced foreign-key "resource_id" returned %v for node %v`, fk, n.ID) - } - assign(node, n) - } - return nil -} func (_q *ResourceQuery) sqlCount(ctx context.Context) (int, error) { _spec := _q.querySpec() @@ -719,9 +604,6 @@ func (_q *ResourceQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if _q.withParent != nil { - _spec.Node.AddColumnOnce(resource.FieldParentID) - } } if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { @@ -820,46 +702,32 @@ func (_q *ResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *ResourceSel // var v []struct { // CreateTime time.Time `json:"create_time,omitempty"` // UpdateTime time.Time `json:"update_time,omitempty"` -// Name string `json:"name,omitempty"` +// ServiceName string `json:"service_name,omitempty"` // Keyword string `json:"keyword,omitempty"` -// I18nKey string `json:"i18n_key,omitempty"` -// Type string `json:"type,omitempty"` -// Status int8 `json:"status,omitempty"` // Path string `json:"path,omitempty"` -// Operation string `json:"operation,omitempty"` // Method string `json:"method,omitempty"` -// Component string `json:"component,omitempty"` -// Icon string `json:"icon,omitempty"` -// Sequence int `json:"sequence,omitempty"` -// Visible bool `json:"visible,omitempty"` -// Level int8 `json:"level,omitempty"` -// TreePath string `json:"tree_path,omitempty"` -// Properties map[string]string `json:"properties,omitempty"` -// Description string `json:"description,omitempty"` -// ParentID int64 `json:"parent_id,omitempty"` +// Operation string `json:"operation,omitempty"` +// Policy string `json:"policy,omitempty"` +// VersionID string `json:"version_id,omitempty"` +// LastSyncVersionID string `json:"last_sync_version_id,omitempty"` +// SyncStatus string `json:"sync_status,omitempty"` +// Status resource.Status `json:"status,omitempty"` // } // // client.Resource.Query(). // Omit( // resource.FieldCreateTime, // resource.FieldUpdateTime, -// resource.FieldName, +// resource.FieldServiceName, // resource.FieldKeyword, -// resource.FieldI18nKey, -// resource.FieldType, -// resource.FieldStatus, // resource.FieldPath, -// resource.FieldOperation, // resource.FieldMethod, -// resource.FieldComponent, -// resource.FieldIcon, -// resource.FieldSequence, -// resource.FieldVisible, -// resource.FieldLevel, -// resource.FieldTreePath, -// resource.FieldProperties, -// resource.FieldDescription, -// resource.FieldParentID, +// resource.FieldOperation, +// resource.FieldPolicy, +// resource.FieldVersionID, +// resource.FieldLastSyncVersionID, +// resource.FieldSyncStatus, +// resource.FieldStatus, // ). // Scan(ctx, &v) func (rq *ResourceQuery) Omit(fields ...string) *ResourceSelect { diff --git a/internal/data/entity/ent/resource_update.go b/internal/data/entity/ent/resource_update.go index e70739d9..b36462fc 100644 --- a/internal/data/entity/ent/resource_update.go +++ b/internal/data/entity/ent/resource_update.go @@ -7,9 +7,9 @@ import ( "errors" "fmt" "origadmin/application/admin/internal/data/entity/ent/permission" - "origadmin/application/admin/internal/data/entity/ent/permissionresource" "origadmin/application/admin/internal/data/entity/ent/predicate" "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/view" "time" "entgo.io/ent/dialect/sql" @@ -37,16 +37,16 @@ func (_u *ResourceUpdate) SetUpdateTime(v time.Time) *ResourceUpdate { return _u } -// SetName sets the "name" field. -func (_u *ResourceUpdate) SetName(v string) *ResourceUpdate { - _u.mutation.SetName(v) +// SetServiceName sets the "service_name" field. +func (_u *ResourceUpdate) SetServiceName(v string) *ResourceUpdate { + _u.mutation.SetServiceName(v) return _u } -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableName(v *string) *ResourceUpdate { +// SetNillableServiceName sets the "service_name" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableServiceName(v *string) *ResourceUpdate { if v != nil { - _u.SetName(*v) + _u.SetServiceName(*v) } return _u } @@ -65,55 +65,6 @@ func (_u *ResourceUpdate) SetNillableKeyword(v *string) *ResourceUpdate { return _u } -// SetI18nKey sets the "i18n_key" field. -func (_u *ResourceUpdate) SetI18nKey(v string) *ResourceUpdate { - _u.mutation.SetI18nKey(v) - return _u -} - -// SetNillableI18nKey sets the "i18n_key" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableI18nKey(v *string) *ResourceUpdate { - if v != nil { - _u.SetI18nKey(*v) - } - return _u -} - -// SetType sets the "type" field. -func (_u *ResourceUpdate) SetType(v string) *ResourceUpdate { - _u.mutation.SetType(v) - return _u -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableType(v *string) *ResourceUpdate { - if v != nil { - _u.SetType(*v) - } - return _u -} - -// SetStatus sets the "status" field. -func (_u *ResourceUpdate) SetStatus(v int8) *ResourceUpdate { - _u.mutation.ResetStatus() - _u.mutation.SetStatus(v) - return _u -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableStatus(v *int8) *ResourceUpdate { - if v != nil { - _u.SetStatus(*v) - } - return _u -} - -// AddStatus adds value to the "status" field. -func (_u *ResourceUpdate) AddStatus(v int8) *ResourceUpdate { - _u.mutation.AddStatus(v) - return _u -} - // SetPath sets the "path" field. func (_u *ResourceUpdate) SetPath(v string) *ResourceUpdate { _u.mutation.SetPath(v) @@ -128,17 +79,9 @@ func (_u *ResourceUpdate) SetNillablePath(v *string) *ResourceUpdate { return _u } -// SetOperation sets the "operation" field. -func (_u *ResourceUpdate) SetOperation(v string) *ResourceUpdate { - _u.mutation.SetOperation(v) - return _u -} - -// SetNillableOperation sets the "operation" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableOperation(v *string) *ResourceUpdate { - if v != nil { - _u.SetOperation(*v) - } +// ClearPath clears the value of the "path" field. +func (_u *ResourceUpdate) ClearPath() *ResourceUpdate { + _u.mutation.ClearPath() return _u } @@ -156,168 +99,115 @@ func (_u *ResourceUpdate) SetNillableMethod(v *string) *ResourceUpdate { return _u } -// SetComponent sets the "component" field. -func (_u *ResourceUpdate) SetComponent(v string) *ResourceUpdate { - _u.mutation.SetComponent(v) - return _u -} - -// SetNillableComponent sets the "component" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableComponent(v *string) *ResourceUpdate { - if v != nil { - _u.SetComponent(*v) - } - return _u -} - -// SetIcon sets the "icon" field. -func (_u *ResourceUpdate) SetIcon(v string) *ResourceUpdate { - _u.mutation.SetIcon(v) - return _u -} - -// SetNillableIcon sets the "icon" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableIcon(v *string) *ResourceUpdate { - if v != nil { - _u.SetIcon(*v) - } +// ClearMethod clears the value of the "method" field. +func (_u *ResourceUpdate) ClearMethod() *ResourceUpdate { + _u.mutation.ClearMethod() return _u } -// SetSequence sets the "sequence" field. -func (_u *ResourceUpdate) SetSequence(v int) *ResourceUpdate { - _u.mutation.ResetSequence() - _u.mutation.SetSequence(v) +// SetOperation sets the "operation" field. +func (_u *ResourceUpdate) SetOperation(v string) *ResourceUpdate { + _u.mutation.SetOperation(v) return _u } -// SetNillableSequence sets the "sequence" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableSequence(v *int) *ResourceUpdate { +// SetNillableOperation sets the "operation" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableOperation(v *string) *ResourceUpdate { if v != nil { - _u.SetSequence(*v) + _u.SetOperation(*v) } return _u } -// AddSequence adds value to the "sequence" field. -func (_u *ResourceUpdate) AddSequence(v int) *ResourceUpdate { - _u.mutation.AddSequence(v) +// ClearOperation clears the value of the "operation" field. +func (_u *ResourceUpdate) ClearOperation() *ResourceUpdate { + _u.mutation.ClearOperation() return _u } -// SetVisible sets the "visible" field. -func (_u *ResourceUpdate) SetVisible(v bool) *ResourceUpdate { - _u.mutation.SetVisible(v) +// SetPolicy sets the "policy" field. +func (_u *ResourceUpdate) SetPolicy(v string) *ResourceUpdate { + _u.mutation.SetPolicy(v) return _u } -// SetNillableVisible sets the "visible" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableVisible(v *bool) *ResourceUpdate { +// SetNillablePolicy sets the "policy" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillablePolicy(v *string) *ResourceUpdate { if v != nil { - _u.SetVisible(*v) + _u.SetPolicy(*v) } return _u } -// SetLevel sets the "level" field. -func (_u *ResourceUpdate) SetLevel(v int8) *ResourceUpdate { - _u.mutation.ResetLevel() - _u.mutation.SetLevel(v) +// SetVersionID sets the "version_id" field. +func (_u *ResourceUpdate) SetVersionID(v string) *ResourceUpdate { + _u.mutation.SetVersionID(v) return _u } -// SetNillableLevel sets the "level" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableLevel(v *int8) *ResourceUpdate { +// SetNillableVersionID sets the "version_id" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableVersionID(v *string) *ResourceUpdate { if v != nil { - _u.SetLevel(*v) + _u.SetVersionID(*v) } return _u } -// AddLevel adds value to the "level" field. -func (_u *ResourceUpdate) AddLevel(v int8) *ResourceUpdate { - _u.mutation.AddLevel(v) - return _u -} - -// SetTreePath sets the "tree_path" field. -func (_u *ResourceUpdate) SetTreePath(v string) *ResourceUpdate { - _u.mutation.SetTreePath(v) +// SetLastSyncVersionID sets the "last_sync_version_id" field. +func (_u *ResourceUpdate) SetLastSyncVersionID(v string) *ResourceUpdate { + _u.mutation.SetLastSyncVersionID(v) return _u } -// SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableTreePath(v *string) *ResourceUpdate { +// SetNillableLastSyncVersionID sets the "last_sync_version_id" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableLastSyncVersionID(v *string) *ResourceUpdate { if v != nil { - _u.SetTreePath(*v) + _u.SetLastSyncVersionID(*v) } return _u } -// SetProperties sets the "properties" field. -func (_u *ResourceUpdate) SetProperties(v map[string]string) *ResourceUpdate { - _u.mutation.SetProperties(v) - return _u -} - -// ClearProperties clears the value of the "properties" field. -func (_u *ResourceUpdate) ClearProperties() *ResourceUpdate { - _u.mutation.ClearProperties() - return _u -} - -// SetDescription sets the "description" field. -func (_u *ResourceUpdate) SetDescription(v string) *ResourceUpdate { - _u.mutation.SetDescription(v) +// SetSyncStatus sets the "sync_status" field. +func (_u *ResourceUpdate) SetSyncStatus(v string) *ResourceUpdate { + _u.mutation.SetSyncStatus(v) return _u } -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableDescription(v *string) *ResourceUpdate { +// SetNillableSyncStatus sets the "sync_status" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableSyncStatus(v *string) *ResourceUpdate { if v != nil { - _u.SetDescription(*v) + _u.SetSyncStatus(*v) } return _u } -// SetParentID sets the "parent_id" field. -func (_u *ResourceUpdate) SetParentID(v int64) *ResourceUpdate { - _u.mutation.SetParentID(v) +// SetStatus sets the "status" field. +func (_u *ResourceUpdate) SetStatus(v resource.Status) *ResourceUpdate { + _u.mutation.SetStatus(v) return _u } -// SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableParentID(v *int64) *ResourceUpdate { +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableStatus(v *resource.Status) *ResourceUpdate { if v != nil { - _u.SetParentID(*v) + _u.SetStatus(*v) } return _u } -// ClearParentID clears the value of the "parent_id" field. -func (_u *ResourceUpdate) ClearParentID() *ResourceUpdate { - _u.mutation.ClearParentID() - return _u -} - -// AddChildIDs adds the "children" edge to the Resource entity by IDs. -func (_u *ResourceUpdate) AddChildIDs(ids ...int64) *ResourceUpdate { - _u.mutation.AddChildIDs(ids...) +// AddViewIDs adds the "views" edge to the View entity by IDs. +func (_u *ResourceUpdate) AddViewIDs(ids ...int64) *ResourceUpdate { + _u.mutation.AddViewIDs(ids...) return _u } -// AddChildren adds the "children" edges to the Resource entity. -func (_u *ResourceUpdate) AddChildren(v ...*Resource) *ResourceUpdate { +// AddViews adds the "views" edges to the View entity. +func (_u *ResourceUpdate) AddViews(v ...*View) *ResourceUpdate { ids := make([]int64, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddChildIDs(ids...) -} - -// SetParent sets the "parent" edge to the Resource entity. -func (_u *ResourceUpdate) SetParent(v *Resource) *ResourceUpdate { - return _u.SetParentID(v.ID) + return _u.AddViewIDs(ids...) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. @@ -335,51 +225,30 @@ func (_u *ResourceUpdate) AddPermissions(v ...*Permission) *ResourceUpdate { return _u.AddPermissionIDs(ids...) } -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (_u *ResourceUpdate) AddPermissionResourceIDs(ids ...int) *ResourceUpdate { - _u.mutation.AddPermissionResourceIDs(ids...) - return _u -} - -// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (_u *ResourceUpdate) AddPermissionResources(v ...*PermissionResource) *ResourceUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddPermissionResourceIDs(ids...) -} - // Mutation returns the ResourceMutation object of the builder. func (_u *ResourceUpdate) Mutation() *ResourceMutation { return _u.mutation } -// ClearChildren clears all "children" edges to the Resource entity. -func (_u *ResourceUpdate) ClearChildren() *ResourceUpdate { - _u.mutation.ClearChildren() +// ClearViews clears all "views" edges to the View entity. +func (_u *ResourceUpdate) ClearViews() *ResourceUpdate { + _u.mutation.ClearViews() return _u } -// RemoveChildIDs removes the "children" edge to Resource entities by IDs. -func (_u *ResourceUpdate) RemoveChildIDs(ids ...int64) *ResourceUpdate { - _u.mutation.RemoveChildIDs(ids...) +// RemoveViewIDs removes the "views" edge to View entities by IDs. +func (_u *ResourceUpdate) RemoveViewIDs(ids ...int64) *ResourceUpdate { + _u.mutation.RemoveViewIDs(ids...) return _u } -// RemoveChildren removes "children" edges to Resource entities. -func (_u *ResourceUpdate) RemoveChildren(v ...*Resource) *ResourceUpdate { +// RemoveViews removes "views" edges to View entities. +func (_u *ResourceUpdate) RemoveViews(v ...*View) *ResourceUpdate { ids := make([]int64, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveChildIDs(ids...) -} - -// ClearParent clears the "parent" edge to the Resource entity. -func (_u *ResourceUpdate) ClearParent() *ResourceUpdate { - _u.mutation.ClearParent() - return _u + return _u.RemoveViewIDs(ids...) } // ClearPermissions clears all "permissions" edges to the Permission entity. @@ -403,27 +272,6 @@ func (_u *ResourceUpdate) RemovePermissions(v ...*Permission) *ResourceUpdate { return _u.RemovePermissionIDs(ids...) } -// ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. -func (_u *ResourceUpdate) ClearPermissionResources() *ResourceUpdate { - _u.mutation.ClearPermissionResources() - return _u -} - -// RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. -func (_u *ResourceUpdate) RemovePermissionResourceIDs(ids ...int) *ResourceUpdate { - _u.mutation.RemovePermissionResourceIDs(ids...) - return _u -} - -// RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. -func (_u *ResourceUpdate) RemovePermissionResources(v ...*PermissionResource) *ResourceUpdate { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemovePermissionResourceIDs(ids...) -} - // Save executes the query and returns the number of nodes affected by the update operation. func (_u *ResourceUpdate) Save(ctx context.Context) (int, error) { _u.defaults() @@ -462,64 +310,14 @@ func (_u *ResourceUpdate) defaults() { // check runs all checks and user-defined validators on the builder. func (_u *ResourceUpdate) check() error { - if v, ok := _u.mutation.Name(); ok { - if err := resource.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} - } - } if v, ok := _u.mutation.Keyword(); ok { if err := resource.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} } } - if v, ok := _u.mutation.I18nKey(); ok { - if err := resource.I18nKeyValidator(v); err != nil { - return &ValidationError{Name: "i18n_key", err: fmt.Errorf(`ent: validator failed for field "Resource.i18n_key": %w`, err)} - } - } - if v, ok := _u.mutation.GetType(); ok { - if err := resource.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} - } - } - if v, ok := _u.mutation.Path(); ok { - if err := resource.PathValidator(v); err != nil { - return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} - } - } - if v, ok := _u.mutation.Operation(); ok { - if err := resource.OperationValidator(v); err != nil { - return &ValidationError{Name: "operation", err: fmt.Errorf(`ent: validator failed for field "Resource.operation": %w`, err)} - } - } - if v, ok := _u.mutation.Method(); ok { - if err := resource.MethodValidator(v); err != nil { - return &ValidationError{Name: "method", err: fmt.Errorf(`ent: validator failed for field "Resource.method": %w`, err)} - } - } - if v, ok := _u.mutation.Component(); ok { - if err := resource.ComponentValidator(v); err != nil { - return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} - } - } - if v, ok := _u.mutation.Icon(); ok { - if err := resource.IconValidator(v); err != nil { - return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} - } - } - if v, ok := _u.mutation.TreePath(); ok { - if err := resource.TreePathValidator(v); err != nil { - return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} - } - } - if v, ok := _u.mutation.Description(); ok { - if err := resource.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} - } - } - if v, ok := _u.mutation.ParentID(); ok { - if err := resource.ParentIDValidator(v); err != nil { - return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Resource.parent_id": %w`, err)} + if v, ok := _u.mutation.Status(); ok { + if err := resource.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Resource.status": %w`, err)} } } return nil @@ -546,88 +344,67 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(resource.FieldName, field.TypeString, value) + if value, ok := _u.mutation.ServiceName(); ok { + _spec.SetField(resource.FieldServiceName, field.TypeString, value) } if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(resource.FieldKeyword, field.TypeString, value) } - if value, ok := _u.mutation.I18nKey(); ok { - _spec.SetField(resource.FieldI18nKey, field.TypeString, value) - } - if value, ok := _u.mutation.GetType(); ok { - _spec.SetField(resource.FieldType, field.TypeString, value) - } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedStatus(); ok { - _spec.AddField(resource.FieldStatus, field.TypeInt8, value) - } if value, ok := _u.mutation.Path(); ok { _spec.SetField(resource.FieldPath, field.TypeString, value) } - if value, ok := _u.mutation.Operation(); ok { - _spec.SetField(resource.FieldOperation, field.TypeString, value) + if _u.mutation.PathCleared() { + _spec.ClearField(resource.FieldPath, field.TypeString) } if value, ok := _u.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) } - if value, ok := _u.mutation.Component(); ok { - _spec.SetField(resource.FieldComponent, field.TypeString, value) - } - if value, ok := _u.mutation.Icon(); ok { - _spec.SetField(resource.FieldIcon, field.TypeString, value) - } - if value, ok := _u.mutation.Sequence(); ok { - _spec.SetField(resource.FieldSequence, field.TypeInt, value) + if _u.mutation.MethodCleared() { + _spec.ClearField(resource.FieldMethod, field.TypeString) } - if value, ok := _u.mutation.AddedSequence(); ok { - _spec.AddField(resource.FieldSequence, field.TypeInt, value) - } - if value, ok := _u.mutation.Visible(); ok { - _spec.SetField(resource.FieldVisible, field.TypeBool, value) + if value, ok := _u.mutation.Operation(); ok { + _spec.SetField(resource.FieldOperation, field.TypeString, value) } - if value, ok := _u.mutation.Level(); ok { - _spec.SetField(resource.FieldLevel, field.TypeInt8, value) + if _u.mutation.OperationCleared() { + _spec.ClearField(resource.FieldOperation, field.TypeString) } - if value, ok := _u.mutation.AddedLevel(); ok { - _spec.AddField(resource.FieldLevel, field.TypeInt8, value) + if value, ok := _u.mutation.Policy(); ok { + _spec.SetField(resource.FieldPolicy, field.TypeString, value) } - if value, ok := _u.mutation.TreePath(); ok { - _spec.SetField(resource.FieldTreePath, field.TypeString, value) + if value, ok := _u.mutation.VersionID(); ok { + _spec.SetField(resource.FieldVersionID, field.TypeString, value) } - if value, ok := _u.mutation.Properties(); ok { - _spec.SetField(resource.FieldProperties, field.TypeJSON, value) + if value, ok := _u.mutation.LastSyncVersionID(); ok { + _spec.SetField(resource.FieldLastSyncVersionID, field.TypeString, value) } - if _u.mutation.PropertiesCleared() { - _spec.ClearField(resource.FieldProperties, field.TypeJSON) + if value, ok := _u.mutation.SyncStatus(); ok { + _spec.SetField(resource.FieldSyncStatus, field.TypeString, value) } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(resource.FieldDescription, field.TypeString, value) + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(resource.FieldStatus, field.TypeEnum, value) } - if _u.mutation.ChildrenCleared() { + if _u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, + Rel: sqlgraph.M2M, Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: true, + Table: resource.ViewsTable, + Columns: resource.ViewsPrimaryKey, + Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + if nodes := _u.mutation.RemovedViewsIDs(); len(nodes) > 0 && !_u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, + Rel: sqlgraph.M2M, Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: true, + Table: resource.ViewsTable, + Columns: resource.ViewsPrimaryKey, + Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } for _, k := range nodes { @@ -635,44 +412,15 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ViewsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, + Rel: sqlgraph.M2M, Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: true, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.ParentCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: resource.ParentTable, - Columns: []string{resource.ParentColumn}, + Table: resource.ViewsTable, + Columns: resource.ViewsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: resource.ParentTable, - Columns: []string{resource.ParentColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } for _, k := range nodes { @@ -725,51 +473,6 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } _spec.AddModifiers(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -798,16 +501,16 @@ func (_u *ResourceUpdateOne) SetUpdateTime(v time.Time) *ResourceUpdateOne { return _u } -// SetName sets the "name" field. -func (_u *ResourceUpdateOne) SetName(v string) *ResourceUpdateOne { - _u.mutation.SetName(v) +// SetServiceName sets the "service_name" field. +func (_u *ResourceUpdateOne) SetServiceName(v string) *ResourceUpdateOne { + _u.mutation.SetServiceName(v) return _u } -// SetNillableName sets the "name" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableName(v *string) *ResourceUpdateOne { +// SetNillableServiceName sets the "service_name" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableServiceName(v *string) *ResourceUpdateOne { if v != nil { - _u.SetName(*v) + _u.SetServiceName(*v) } return _u } @@ -826,55 +529,6 @@ func (_u *ResourceUpdateOne) SetNillableKeyword(v *string) *ResourceUpdateOne { return _u } -// SetI18nKey sets the "i18n_key" field. -func (_u *ResourceUpdateOne) SetI18nKey(v string) *ResourceUpdateOne { - _u.mutation.SetI18nKey(v) - return _u -} - -// SetNillableI18nKey sets the "i18n_key" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableI18nKey(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetI18nKey(*v) - } - return _u -} - -// SetType sets the "type" field. -func (_u *ResourceUpdateOne) SetType(v string) *ResourceUpdateOne { - _u.mutation.SetType(v) - return _u -} - -// SetNillableType sets the "type" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableType(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetType(*v) - } - return _u -} - -// SetStatus sets the "status" field. -func (_u *ResourceUpdateOne) SetStatus(v int8) *ResourceUpdateOne { - _u.mutation.ResetStatus() - _u.mutation.SetStatus(v) - return _u -} - -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableStatus(v *int8) *ResourceUpdateOne { - if v != nil { - _u.SetStatus(*v) - } - return _u -} - -// AddStatus adds value to the "status" field. -func (_u *ResourceUpdateOne) AddStatus(v int8) *ResourceUpdateOne { - _u.mutation.AddStatus(v) - return _u -} - // SetPath sets the "path" field. func (_u *ResourceUpdateOne) SetPath(v string) *ResourceUpdateOne { _u.mutation.SetPath(v) @@ -889,17 +543,9 @@ func (_u *ResourceUpdateOne) SetNillablePath(v *string) *ResourceUpdateOne { return _u } -// SetOperation sets the "operation" field. -func (_u *ResourceUpdateOne) SetOperation(v string) *ResourceUpdateOne { - _u.mutation.SetOperation(v) - return _u -} - -// SetNillableOperation sets the "operation" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableOperation(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetOperation(*v) - } +// ClearPath clears the value of the "path" field. +func (_u *ResourceUpdateOne) ClearPath() *ResourceUpdateOne { + _u.mutation.ClearPath() return _u } @@ -917,168 +563,115 @@ func (_u *ResourceUpdateOne) SetNillableMethod(v *string) *ResourceUpdateOne { return _u } -// SetComponent sets the "component" field. -func (_u *ResourceUpdateOne) SetComponent(v string) *ResourceUpdateOne { - _u.mutation.SetComponent(v) - return _u -} - -// SetNillableComponent sets the "component" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableComponent(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetComponent(*v) - } - return _u -} - -// SetIcon sets the "icon" field. -func (_u *ResourceUpdateOne) SetIcon(v string) *ResourceUpdateOne { - _u.mutation.SetIcon(v) - return _u -} - -// SetNillableIcon sets the "icon" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableIcon(v *string) *ResourceUpdateOne { - if v != nil { - _u.SetIcon(*v) - } +// ClearMethod clears the value of the "method" field. +func (_u *ResourceUpdateOne) ClearMethod() *ResourceUpdateOne { + _u.mutation.ClearMethod() return _u } -// SetSequence sets the "sequence" field. -func (_u *ResourceUpdateOne) SetSequence(v int) *ResourceUpdateOne { - _u.mutation.ResetSequence() - _u.mutation.SetSequence(v) +// SetOperation sets the "operation" field. +func (_u *ResourceUpdateOne) SetOperation(v string) *ResourceUpdateOne { + _u.mutation.SetOperation(v) return _u } -// SetNillableSequence sets the "sequence" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableSequence(v *int) *ResourceUpdateOne { +// SetNillableOperation sets the "operation" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableOperation(v *string) *ResourceUpdateOne { if v != nil { - _u.SetSequence(*v) + _u.SetOperation(*v) } return _u } -// AddSequence adds value to the "sequence" field. -func (_u *ResourceUpdateOne) AddSequence(v int) *ResourceUpdateOne { - _u.mutation.AddSequence(v) +// ClearOperation clears the value of the "operation" field. +func (_u *ResourceUpdateOne) ClearOperation() *ResourceUpdateOne { + _u.mutation.ClearOperation() return _u } -// SetVisible sets the "visible" field. -func (_u *ResourceUpdateOne) SetVisible(v bool) *ResourceUpdateOne { - _u.mutation.SetVisible(v) +// SetPolicy sets the "policy" field. +func (_u *ResourceUpdateOne) SetPolicy(v string) *ResourceUpdateOne { + _u.mutation.SetPolicy(v) return _u } -// SetNillableVisible sets the "visible" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableVisible(v *bool) *ResourceUpdateOne { +// SetNillablePolicy sets the "policy" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillablePolicy(v *string) *ResourceUpdateOne { if v != nil { - _u.SetVisible(*v) + _u.SetPolicy(*v) } return _u } -// SetLevel sets the "level" field. -func (_u *ResourceUpdateOne) SetLevel(v int8) *ResourceUpdateOne { - _u.mutation.ResetLevel() - _u.mutation.SetLevel(v) +// SetVersionID sets the "version_id" field. +func (_u *ResourceUpdateOne) SetVersionID(v string) *ResourceUpdateOne { + _u.mutation.SetVersionID(v) return _u } -// SetNillableLevel sets the "level" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableLevel(v *int8) *ResourceUpdateOne { +// SetNillableVersionID sets the "version_id" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableVersionID(v *string) *ResourceUpdateOne { if v != nil { - _u.SetLevel(*v) + _u.SetVersionID(*v) } return _u } -// AddLevel adds value to the "level" field. -func (_u *ResourceUpdateOne) AddLevel(v int8) *ResourceUpdateOne { - _u.mutation.AddLevel(v) - return _u -} - -// SetTreePath sets the "tree_path" field. -func (_u *ResourceUpdateOne) SetTreePath(v string) *ResourceUpdateOne { - _u.mutation.SetTreePath(v) +// SetLastSyncVersionID sets the "last_sync_version_id" field. +func (_u *ResourceUpdateOne) SetLastSyncVersionID(v string) *ResourceUpdateOne { + _u.mutation.SetLastSyncVersionID(v) return _u } -// SetNillableTreePath sets the "tree_path" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableTreePath(v *string) *ResourceUpdateOne { +// SetNillableLastSyncVersionID sets the "last_sync_version_id" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableLastSyncVersionID(v *string) *ResourceUpdateOne { if v != nil { - _u.SetTreePath(*v) + _u.SetLastSyncVersionID(*v) } return _u } -// SetProperties sets the "properties" field. -func (_u *ResourceUpdateOne) SetProperties(v map[string]string) *ResourceUpdateOne { - _u.mutation.SetProperties(v) - return _u -} - -// ClearProperties clears the value of the "properties" field. -func (_u *ResourceUpdateOne) ClearProperties() *ResourceUpdateOne { - _u.mutation.ClearProperties() - return _u -} - -// SetDescription sets the "description" field. -func (_u *ResourceUpdateOne) SetDescription(v string) *ResourceUpdateOne { - _u.mutation.SetDescription(v) +// SetSyncStatus sets the "sync_status" field. +func (_u *ResourceUpdateOne) SetSyncStatus(v string) *ResourceUpdateOne { + _u.mutation.SetSyncStatus(v) return _u } -// SetNillableDescription sets the "description" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableDescription(v *string) *ResourceUpdateOne { +// SetNillableSyncStatus sets the "sync_status" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableSyncStatus(v *string) *ResourceUpdateOne { if v != nil { - _u.SetDescription(*v) + _u.SetSyncStatus(*v) } return _u } -// SetParentID sets the "parent_id" field. -func (_u *ResourceUpdateOne) SetParentID(v int64) *ResourceUpdateOne { - _u.mutation.SetParentID(v) +// SetStatus sets the "status" field. +func (_u *ResourceUpdateOne) SetStatus(v resource.Status) *ResourceUpdateOne { + _u.mutation.SetStatus(v) return _u } -// SetNillableParentID sets the "parent_id" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableParentID(v *int64) *ResourceUpdateOne { +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableStatus(v *resource.Status) *ResourceUpdateOne { if v != nil { - _u.SetParentID(*v) + _u.SetStatus(*v) } return _u } -// ClearParentID clears the value of the "parent_id" field. -func (_u *ResourceUpdateOne) ClearParentID() *ResourceUpdateOne { - _u.mutation.ClearParentID() - return _u -} - -// AddChildIDs adds the "children" edge to the Resource entity by IDs. -func (_u *ResourceUpdateOne) AddChildIDs(ids ...int64) *ResourceUpdateOne { - _u.mutation.AddChildIDs(ids...) +// AddViewIDs adds the "views" edge to the View entity by IDs. +func (_u *ResourceUpdateOne) AddViewIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.AddViewIDs(ids...) return _u } -// AddChildren adds the "children" edges to the Resource entity. -func (_u *ResourceUpdateOne) AddChildren(v ...*Resource) *ResourceUpdateOne { +// AddViews adds the "views" edges to the View entity. +func (_u *ResourceUpdateOne) AddViews(v ...*View) *ResourceUpdateOne { ids := make([]int64, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.AddChildIDs(ids...) -} - -// SetParent sets the "parent" edge to the Resource entity. -func (_u *ResourceUpdateOne) SetParent(v *Resource) *ResourceUpdateOne { - return _u.SetParentID(v.ID) + return _u.AddViewIDs(ids...) } // AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. @@ -1096,51 +689,30 @@ func (_u *ResourceUpdateOne) AddPermissions(v ...*Permission) *ResourceUpdateOne return _u.AddPermissionIDs(ids...) } -// AddPermissionResourceIDs adds the "permission_resources" edge to the PermissionResource entity by IDs. -func (_u *ResourceUpdateOne) AddPermissionResourceIDs(ids ...int) *ResourceUpdateOne { - _u.mutation.AddPermissionResourceIDs(ids...) - return _u -} - -// AddPermissionResources adds the "permission_resources" edges to the PermissionResource entity. -func (_u *ResourceUpdateOne) AddPermissionResources(v ...*PermissionResource) *ResourceUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.AddPermissionResourceIDs(ids...) -} - // Mutation returns the ResourceMutation object of the builder. func (_u *ResourceUpdateOne) Mutation() *ResourceMutation { return _u.mutation } -// ClearChildren clears all "children" edges to the Resource entity. -func (_u *ResourceUpdateOne) ClearChildren() *ResourceUpdateOne { - _u.mutation.ClearChildren() +// ClearViews clears all "views" edges to the View entity. +func (_u *ResourceUpdateOne) ClearViews() *ResourceUpdateOne { + _u.mutation.ClearViews() return _u } -// RemoveChildIDs removes the "children" edge to Resource entities by IDs. -func (_u *ResourceUpdateOne) RemoveChildIDs(ids ...int64) *ResourceUpdateOne { - _u.mutation.RemoveChildIDs(ids...) +// RemoveViewIDs removes the "views" edge to View entities by IDs. +func (_u *ResourceUpdateOne) RemoveViewIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.RemoveViewIDs(ids...) return _u } -// RemoveChildren removes "children" edges to Resource entities. -func (_u *ResourceUpdateOne) RemoveChildren(v ...*Resource) *ResourceUpdateOne { +// RemoveViews removes "views" edges to View entities. +func (_u *ResourceUpdateOne) RemoveViews(v ...*View) *ResourceUpdateOne { ids := make([]int64, len(v)) for i := range v { ids[i] = v[i].ID } - return _u.RemoveChildIDs(ids...) -} - -// ClearParent clears the "parent" edge to the Resource entity. -func (_u *ResourceUpdateOne) ClearParent() *ResourceUpdateOne { - _u.mutation.ClearParent() - return _u + return _u.RemoveViewIDs(ids...) } // ClearPermissions clears all "permissions" edges to the Permission entity. @@ -1164,27 +736,6 @@ func (_u *ResourceUpdateOne) RemovePermissions(v ...*Permission) *ResourceUpdate return _u.RemovePermissionIDs(ids...) } -// ClearPermissionResources clears all "permission_resources" edges to the PermissionResource entity. -func (_u *ResourceUpdateOne) ClearPermissionResources() *ResourceUpdateOne { - _u.mutation.ClearPermissionResources() - return _u -} - -// RemovePermissionResourceIDs removes the "permission_resources" edge to PermissionResource entities by IDs. -func (_u *ResourceUpdateOne) RemovePermissionResourceIDs(ids ...int) *ResourceUpdateOne { - _u.mutation.RemovePermissionResourceIDs(ids...) - return _u -} - -// RemovePermissionResources removes "permission_resources" edges to PermissionResource entities. -func (_u *ResourceUpdateOne) RemovePermissionResources(v ...*PermissionResource) *ResourceUpdateOne { - ids := make([]int, len(v)) - for i := range v { - ids[i] = v[i].ID - } - return _u.RemovePermissionResourceIDs(ids...) -} - // Where appends a list predicates to the ResourceUpdate builder. func (_u *ResourceUpdateOne) Where(ps ...predicate.Resource) *ResourceUpdateOne { _u.mutation.Where(ps...) @@ -1236,64 +787,14 @@ func (_u *ResourceUpdateOne) defaults() { // check runs all checks and user-defined validators on the builder. func (_u *ResourceUpdateOne) check() error { - if v, ok := _u.mutation.Name(); ok { - if err := resource.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Resource.name": %w`, err)} - } - } if v, ok := _u.mutation.Keyword(); ok { if err := resource.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} } } - if v, ok := _u.mutation.I18nKey(); ok { - if err := resource.I18nKeyValidator(v); err != nil { - return &ValidationError{Name: "i18n_key", err: fmt.Errorf(`ent: validator failed for field "Resource.i18n_key": %w`, err)} - } - } - if v, ok := _u.mutation.GetType(); ok { - if err := resource.TypeValidator(v); err != nil { - return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "Resource.type": %w`, err)} - } - } - if v, ok := _u.mutation.Path(); ok { - if err := resource.PathValidator(v); err != nil { - return &ValidationError{Name: "path", err: fmt.Errorf(`ent: validator failed for field "Resource.path": %w`, err)} - } - } - if v, ok := _u.mutation.Operation(); ok { - if err := resource.OperationValidator(v); err != nil { - return &ValidationError{Name: "operation", err: fmt.Errorf(`ent: validator failed for field "Resource.operation": %w`, err)} - } - } - if v, ok := _u.mutation.Method(); ok { - if err := resource.MethodValidator(v); err != nil { - return &ValidationError{Name: "method", err: fmt.Errorf(`ent: validator failed for field "Resource.method": %w`, err)} - } - } - if v, ok := _u.mutation.Component(); ok { - if err := resource.ComponentValidator(v); err != nil { - return &ValidationError{Name: "component", err: fmt.Errorf(`ent: validator failed for field "Resource.component": %w`, err)} - } - } - if v, ok := _u.mutation.Icon(); ok { - if err := resource.IconValidator(v); err != nil { - return &ValidationError{Name: "icon", err: fmt.Errorf(`ent: validator failed for field "Resource.icon": %w`, err)} - } - } - if v, ok := _u.mutation.TreePath(); ok { - if err := resource.TreePathValidator(v); err != nil { - return &ValidationError{Name: "tree_path", err: fmt.Errorf(`ent: validator failed for field "Resource.tree_path": %w`, err)} - } - } - if v, ok := _u.mutation.Description(); ok { - if err := resource.DescriptionValidator(v); err != nil { - return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Resource.description": %w`, err)} - } - } - if v, ok := _u.mutation.ParentID(); ok { - if err := resource.ParentIDValidator(v); err != nil { - return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Resource.parent_id": %w`, err)} + if v, ok := _u.mutation.Status(); ok { + if err := resource.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Resource.status": %w`, err)} } } return nil @@ -1337,88 +838,67 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) } - if value, ok := _u.mutation.Name(); ok { - _spec.SetField(resource.FieldName, field.TypeString, value) + if value, ok := _u.mutation.ServiceName(); ok { + _spec.SetField(resource.FieldServiceName, field.TypeString, value) } if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(resource.FieldKeyword, field.TypeString, value) } - if value, ok := _u.mutation.I18nKey(); ok { - _spec.SetField(resource.FieldI18nKey, field.TypeString, value) - } - if value, ok := _u.mutation.GetType(); ok { - _spec.SetField(resource.FieldType, field.TypeString, value) - } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeInt8, value) - } - if value, ok := _u.mutation.AddedStatus(); ok { - _spec.AddField(resource.FieldStatus, field.TypeInt8, value) - } if value, ok := _u.mutation.Path(); ok { _spec.SetField(resource.FieldPath, field.TypeString, value) } - if value, ok := _u.mutation.Operation(); ok { - _spec.SetField(resource.FieldOperation, field.TypeString, value) + if _u.mutation.PathCleared() { + _spec.ClearField(resource.FieldPath, field.TypeString) } if value, ok := _u.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) } - if value, ok := _u.mutation.Component(); ok { - _spec.SetField(resource.FieldComponent, field.TypeString, value) - } - if value, ok := _u.mutation.Icon(); ok { - _spec.SetField(resource.FieldIcon, field.TypeString, value) - } - if value, ok := _u.mutation.Sequence(); ok { - _spec.SetField(resource.FieldSequence, field.TypeInt, value) + if _u.mutation.MethodCleared() { + _spec.ClearField(resource.FieldMethod, field.TypeString) } - if value, ok := _u.mutation.AddedSequence(); ok { - _spec.AddField(resource.FieldSequence, field.TypeInt, value) - } - if value, ok := _u.mutation.Visible(); ok { - _spec.SetField(resource.FieldVisible, field.TypeBool, value) + if value, ok := _u.mutation.Operation(); ok { + _spec.SetField(resource.FieldOperation, field.TypeString, value) } - if value, ok := _u.mutation.Level(); ok { - _spec.SetField(resource.FieldLevel, field.TypeInt8, value) + if _u.mutation.OperationCleared() { + _spec.ClearField(resource.FieldOperation, field.TypeString) } - if value, ok := _u.mutation.AddedLevel(); ok { - _spec.AddField(resource.FieldLevel, field.TypeInt8, value) + if value, ok := _u.mutation.Policy(); ok { + _spec.SetField(resource.FieldPolicy, field.TypeString, value) } - if value, ok := _u.mutation.TreePath(); ok { - _spec.SetField(resource.FieldTreePath, field.TypeString, value) + if value, ok := _u.mutation.VersionID(); ok { + _spec.SetField(resource.FieldVersionID, field.TypeString, value) } - if value, ok := _u.mutation.Properties(); ok { - _spec.SetField(resource.FieldProperties, field.TypeJSON, value) + if value, ok := _u.mutation.LastSyncVersionID(); ok { + _spec.SetField(resource.FieldLastSyncVersionID, field.TypeString, value) } - if _u.mutation.PropertiesCleared() { - _spec.ClearField(resource.FieldProperties, field.TypeJSON) + if value, ok := _u.mutation.SyncStatus(); ok { + _spec.SetField(resource.FieldSyncStatus, field.TypeString, value) } - if value, ok := _u.mutation.Description(); ok { - _spec.SetField(resource.FieldDescription, field.TypeString, value) + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(resource.FieldStatus, field.TypeEnum, value) } - if _u.mutation.ChildrenCleared() { + if _u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, + Rel: sqlgraph.M2M, Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: true, + Table: resource.ViewsTable, + Columns: resource.ViewsPrimaryKey, + Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + if nodes := _u.mutation.RemovedViewsIDs(); len(nodes) > 0 && !_u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, + Rel: sqlgraph.M2M, Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: true, + Table: resource.ViewsTable, + Columns: resource.ViewsPrimaryKey, + Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } for _, k := range nodes { @@ -1426,44 +906,15 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + if nodes := _u.mutation.ViewsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, + Rel: sqlgraph.M2M, Inverse: false, - Table: resource.ChildrenTable, - Columns: []string{resource.ChildrenColumn}, - Bidi: true, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } - if _u.mutation.ParentCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: resource.ParentTable, - Columns: []string{resource.ParentColumn}, + Table: resource.ViewsTable, + Columns: resource.ViewsPrimaryKey, Bidi: false, Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.M2O, - Inverse: true, - Table: resource.ParentTable, - Columns: []string{resource.ParentColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } for _, k := range nodes { @@ -1516,51 +967,6 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if _u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.RemovedPermissionResourcesIDs(); len(nodes) > 0 && !_u.mutation.PermissionResourcesCleared() { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Clear = append(_spec.Edges.Clear, edge) - } - if nodes := _u.mutation.PermissionResourcesIDs(); len(nodes) > 0 { - edge := &sqlgraph.EdgeSpec{ - Rel: sqlgraph.O2M, - Inverse: true, - Table: resource.PermissionResourcesTable, - Columns: []string{resource.PermissionResourcesColumn}, - Bidi: false, - Target: &sqlgraph.EdgeTarget{ - IDSpec: sqlgraph.NewFieldSpec(permissionresource.FieldID, field.TypeInt), - }, - } - for _, k := range nodes { - edge.Target.Nodes = append(edge.Target.Nodes, k) - } - _spec.Edges.Add = append(_spec.Edges.Add, edge) - } _spec.AddModifiers(_u.modifiers...) _node = &Resource{config: _u.config} _spec.Assign = _node.assignValues diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index 3dd6911a..81846663 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -18,6 +18,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userdepartment" "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" + "origadmin/application/admin/internal/data/entity/ent/view" "time" ) @@ -292,90 +293,26 @@ func init() { resource.DefaultUpdateTime = resourceDescUpdateTime.Default.(func() time.Time) // resource.UpdateDefaultUpdateTime holds the default value on update for the update_time field. resource.UpdateDefaultUpdateTime = resourceDescUpdateTime.UpdateDefault.(func() time.Time) - // resourceDescName is the schema descriptor for name field. - resourceDescName := resourceFields[0].Descriptor() - // resource.DefaultName holds the default value on creation for the name field. - resource.DefaultName = resourceDescName.Default.(string) - // resource.NameValidator is a validator for the "name" field. It is called by the builders before save. - resource.NameValidator = resourceDescName.Validators[0].(func(string) error) // resourceDescKeyword is the schema descriptor for keyword field. resourceDescKeyword := resourceFields[1].Descriptor() // resource.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. resource.KeywordValidator = resourceDescKeyword.Validators[0].(func(string) error) - // resourceDescI18nKey is the schema descriptor for i18n_key field. - resourceDescI18nKey := resourceFields[2].Descriptor() - // resource.DefaultI18nKey holds the default value on creation for the i18n_key field. - resource.DefaultI18nKey = resourceDescI18nKey.Default.(string) - // resource.I18nKeyValidator is a validator for the "i18n_key" field. It is called by the builders before save. - resource.I18nKeyValidator = resourceDescI18nKey.Validators[0].(func(string) error) - // resourceDescType is the schema descriptor for type field. - resourceDescType := resourceFields[3].Descriptor() - // resource.DefaultType holds the default value on creation for the type field. - resource.DefaultType = resourceDescType.Default.(string) - // resource.TypeValidator is a validator for the "type" field. It is called by the builders before save. - resource.TypeValidator = resourceDescType.Validators[0].(func(string) error) - // resourceDescStatus is the schema descriptor for status field. - resourceDescStatus := resourceFields[4].Descriptor() - // resource.DefaultStatus holds the default value on creation for the status field. - resource.DefaultStatus = resourceDescStatus.Default.(int8) - // resourceDescPath is the schema descriptor for path field. - resourceDescPath := resourceFields[5].Descriptor() - // resource.DefaultPath holds the default value on creation for the path field. - resource.DefaultPath = resourceDescPath.Default.(string) - // resource.PathValidator is a validator for the "path" field. It is called by the builders before save. - resource.PathValidator = resourceDescPath.Validators[0].(func(string) error) - // resourceDescOperation is the schema descriptor for operation field. - resourceDescOperation := resourceFields[6].Descriptor() - // resource.DefaultOperation holds the default value on creation for the operation field. - resource.DefaultOperation = resourceDescOperation.Default.(string) - // resource.OperationValidator is a validator for the "operation" field. It is called by the builders before save. - resource.OperationValidator = resourceDescOperation.Validators[0].(func(string) error) - // resourceDescMethod is the schema descriptor for method field. - resourceDescMethod := resourceFields[7].Descriptor() - // resource.DefaultMethod holds the default value on creation for the method field. - resource.DefaultMethod = resourceDescMethod.Default.(string) - // resource.MethodValidator is a validator for the "method" field. It is called by the builders before save. - resource.MethodValidator = resourceDescMethod.Validators[0].(func(string) error) - // resourceDescComponent is the schema descriptor for component field. - resourceDescComponent := resourceFields[8].Descriptor() - // resource.DefaultComponent holds the default value on creation for the component field. - resource.DefaultComponent = resourceDescComponent.Default.(string) - // resource.ComponentValidator is a validator for the "component" field. It is called by the builders before save. - resource.ComponentValidator = resourceDescComponent.Validators[0].(func(string) error) - // resourceDescIcon is the schema descriptor for icon field. - resourceDescIcon := resourceFields[9].Descriptor() - // resource.DefaultIcon holds the default value on creation for the icon field. - resource.DefaultIcon = resourceDescIcon.Default.(string) - // resource.IconValidator is a validator for the "icon" field. It is called by the builders before save. - resource.IconValidator = resourceDescIcon.Validators[0].(func(string) error) - // resourceDescSequence is the schema descriptor for sequence field. - resourceDescSequence := resourceFields[10].Descriptor() - // resource.DefaultSequence holds the default value on creation for the sequence field. - resource.DefaultSequence = resourceDescSequence.Default.(int) - // resourceDescVisible is the schema descriptor for visible field. - resourceDescVisible := resourceFields[11].Descriptor() - // resource.DefaultVisible holds the default value on creation for the visible field. - resource.DefaultVisible = resourceDescVisible.Default.(bool) - // resourceDescLevel is the schema descriptor for level field. - resourceDescLevel := resourceFields[12].Descriptor() - // resource.DefaultLevel holds the default value on creation for the level field. - resource.DefaultLevel = resourceDescLevel.Default.(int8) - // resourceDescTreePath is the schema descriptor for tree_path field. - resourceDescTreePath := resourceFields[13].Descriptor() - // resource.DefaultTreePath holds the default value on creation for the tree_path field. - resource.DefaultTreePath = resourceDescTreePath.Default.(string) - // resource.TreePathValidator is a validator for the "tree_path" field. It is called by the builders before save. - resource.TreePathValidator = resourceDescTreePath.Validators[0].(func(string) error) - // resourceDescDescription is the schema descriptor for description field. - resourceDescDescription := resourceFields[15].Descriptor() - // resource.DefaultDescription holds the default value on creation for the description field. - resource.DefaultDescription = resourceDescDescription.Default.(string) - // resource.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. - resource.DescriptionValidator = resourceDescDescription.Validators[0].(func(string) error) - // resourceDescParentID is the schema descriptor for parent_id field. - resourceDescParentID := resourceFields[16].Descriptor() - // resource.ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. - resource.ParentIDValidator = resourceDescParentID.Validators[0].(func(int64) error) + // resourceDescPolicy is the schema descriptor for policy field. + resourceDescPolicy := resourceFields[5].Descriptor() + // resource.DefaultPolicy holds the default value on creation for the policy field. + resource.DefaultPolicy = resourceDescPolicy.Default.(string) + // resourceDescVersionID is the schema descriptor for version_id field. + resourceDescVersionID := resourceFields[6].Descriptor() + // resource.DefaultVersionID holds the default value on creation for the version_id field. + resource.DefaultVersionID = resourceDescVersionID.Default.(string) + // resourceDescLastSyncVersionID is the schema descriptor for last_sync_version_id field. + resourceDescLastSyncVersionID := resourceFields[7].Descriptor() + // resource.DefaultLastSyncVersionID holds the default value on creation for the last_sync_version_id field. + resource.DefaultLastSyncVersionID = resourceDescLastSyncVersionID.Default.(string) + // resourceDescSyncStatus is the schema descriptor for sync_status field. + resourceDescSyncStatus := resourceFields[8].Descriptor() + // resource.DefaultSyncStatus holds the default value on creation for the sync_status field. + resource.DefaultSyncStatus = resourceDescSyncStatus.Default.(string) // resourceDescID is the schema descriptor for id field. resourceDescID := resourceMixinFields0[0].Descriptor() // resource.DefaultID holds the default value on creation for the id field. @@ -618,6 +555,57 @@ func init() { userroleDescRoleID := userroleFields[1].Descriptor() // userrole.RoleIDValidator is a validator for the "role_id" field. It is called by the builders before save. userrole.RoleIDValidator = userroleDescRoleID.Validators[0].(func(int64) error) + viewMixin := schema.View{}.Mixin() + viewMixinFields0 := viewMixin[0].Fields() + _ = viewMixinFields0 + viewMixinFields1 := viewMixin[1].Fields() + _ = viewMixinFields1 + viewMixinFields2 := viewMixin[2].Fields() + _ = viewMixinFields2 + viewFields := schema.View{}.Fields() + _ = viewFields + // viewDescCreateTime is the schema descriptor for create_time field. + viewDescCreateTime := viewMixinFields1[0].Descriptor() + // view.DefaultCreateTime holds the default value on creation for the create_time field. + view.DefaultCreateTime = viewDescCreateTime.Default.(func() time.Time) + // viewDescUpdateTime is the schema descriptor for update_time field. + viewDescUpdateTime := viewMixinFields2[0].Descriptor() + // view.DefaultUpdateTime holds the default value on creation for the update_time field. + view.DefaultUpdateTime = viewDescUpdateTime.Default.(func() time.Time) + // view.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + view.UpdateDefaultUpdateTime = viewDescUpdateTime.UpdateDefault.(func() time.Time) + // viewDescParentID is the schema descriptor for parent_id field. + viewDescParentID := viewFields[0].Descriptor() + // view.ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. + view.ParentIDValidator = viewDescParentID.Validators[0].(func(int64) error) + // viewDescKeyword is the schema descriptor for keyword field. + viewDescKeyword := viewFields[1].Descriptor() + // view.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + view.KeywordValidator = viewDescKeyword.Validators[0].(func(string) error) + // viewDescScope is the schema descriptor for scope field. + viewDescScope := viewFields[2].Descriptor() + // view.DefaultScope holds the default value on creation for the scope field. + view.DefaultScope = viewDescScope.Default.(string) + // viewDescType is the schema descriptor for type field. + viewDescType := viewFields[4].Descriptor() + // view.DefaultType holds the default value on creation for the type field. + view.DefaultType = viewDescType.Default.(string) + // view.TypeValidator is a validator for the "type" field. It is called by the builders before save. + view.TypeValidator = viewDescType.Validators[0].(func(string) error) + // viewDescVisible is the schema descriptor for visible field. + viewDescVisible := viewFields[8].Descriptor() + // view.DefaultVisible holds the default value on creation for the visible field. + view.DefaultVisible = viewDescVisible.Default.(bool) + // viewDescSequence is the schema descriptor for sequence field. + viewDescSequence := viewFields[9].Descriptor() + // view.DefaultSequence holds the default value on creation for the sequence field. + view.DefaultSequence = viewDescSequence.Default.(int) + // viewDescID is the schema descriptor for id field. + viewDescID := viewMixinFields0[0].Descriptor() + // view.DefaultID holds the default value on creation for the id field. + view.DefaultID = viewDescID.Default.(func() int64) + // view.IDValidator is a validator for the "id" field. It is called by the builders before save. + view.IDValidator = viewDescID.Validators[0].(func(int64) error) } const ( diff --git a/internal/data/entity/ent/schema/permission.go b/internal/data/entity/ent/schema/permission.go index 267cf6f5..e3a0a751 100644 --- a/internal/data/entity/ent/schema/permission.go +++ b/internal/data/entity/ent/schema/permission.go @@ -88,5 +88,7 @@ func (Permission) Edges() []ent.Edge { Through("position_permissions", PositionPermission.Type), edge.To("resources", Resource.Type). Through("permission_resources", PermissionResource.Type), + // Add the inverse edge to View, resolving the generation error. + edge.To("views", View.Type), } } diff --git a/internal/data/entity/ent/tx.go b/internal/data/entity/ent/tx.go index e496ec72..46881260 100644 --- a/internal/data/entity/ent/tx.go +++ b/internal/data/entity/ent/tx.go @@ -40,6 +40,8 @@ type Tx struct { UserPosition *UserPositionClient // UserRole is the client for interacting with the UserRole builders. UserRole *UserRoleClient + // View is the client for interacting with the View builders. + View *ViewClient // lazily loaded. client *Client @@ -185,6 +187,7 @@ func (tx *Tx) init() { tx.UserDepartment = NewUserDepartmentClient(tx.config) tx.UserPosition = NewUserPositionClient(tx.config) tx.UserRole = NewUserRoleClient(tx.config) + tx.View = NewViewClient(tx.config) } // txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. diff --git a/internal/helpers/ent/mixin/mixin.go b/internal/helpers/ent/mixin/mixin.go index cc681e68..1c5a1ab9 100644 --- a/internal/helpers/ent/mixin/mixin.go +++ b/internal/helpers/ent/mixin/mixin.go @@ -208,13 +208,12 @@ func (m updateMixin) Indexes() []ent.Index { // DeleteMixin schema to include control and time fields. type DeleteMixin struct { mixin.Schema - DeleteField string } // Fields of the Model. func (m DeleteMixin) Fields() []ent.Field { return []ent.Field{ - field.Time(m.DeleteField). + field.Time("delete_time"). Comment(i18n.Text("delete_time.field.comment")). Optional(). Nillable(), @@ -224,7 +223,7 @@ func (m DeleteMixin) Fields() []ent.Field { // Indexes of the mixin. func (m DeleteMixin) Indexes() []ent.Index { return []ent.Index{ - index.Fields(m.DeleteField), + index.Fields("delete_time"), } } From 22ff43fced26ac9b207ada31c4d2b9578a2f2efb Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 05:23:13 +0800 Subject: [PATCH 080/158] chore(schema): update ent internal schema definition with latest entity configurations --- internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 7 +- internal/data/entity/ent/schema/softdelete.go | 70 - internal/data/entity/ent/schema/user.go | 2 +- internal/data/entity/ent/user.go | 2 +- internal/data/entity/ent/view.go | 306 ++++ internal/data/entity/ent/view/view.go | 339 +++++ internal/data/entity/ent/view/where.go | 868 +++++++++++ internal/data/entity/ent/view_create.go | 602 ++++++++ internal/data/entity/ent/view_delete.go | 88 ++ internal/data/entity/ent/view_query.go | 991 +++++++++++++ internal/data/entity/ent/view_update.go | 1318 +++++++++++++++++ internal/helpers/ent/mixin/soft_delete.go | 103 ++ 13 files changed, 4619 insertions(+), 79 deletions(-) delete mode 100644 internal/data/entity/ent/schema/softdelete.go create mode 100644 internal/data/entity/ent/view.go create mode 100644 internal/data/entity/ent/view/view.go create mode 100644 internal/data/entity/ent/view/where.go create mode 100644 internal/data/entity/ent/view_create.go create mode 100644 internal/data/entity/ent/view_delete.go create mode 100644 internal/data/entity/ent/view_query.go create mode 100644 internal/data/entity/ent/view_update.go create mode 100644 internal/helpers/ent/mixin/soft_delete.go diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index 5764ac3c..65b98eec 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\"}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\"},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"delete_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"ref_name\":\"views\",\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"views\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1,\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\"}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\"},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"ref_name\":\"views\",\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"views\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1,\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index 3c876454..b920d30b 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -410,7 +410,7 @@ var ( {Name: "update_author", Type: field.TypeInt64, Nullable: true, Comment: "update_author.field.comment", Default: 0}, {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "delete_time", Type: field.TypeTime, Nullable: true, Comment: "delete_time.field.comment"}, + {Name: "delete_time", Type: field.TypeTime, Nullable: true, Comment: "Time of soft-delete"}, {Name: "uuid", Type: field.TypeString, Size: 36, Comment: "entity.user.field.uuid"}, {Name: "allowed_ip", Type: field.TypeString, Comment: "entity.user.field.allowed_ip", Default: "0.0.0.0"}, {Name: "username", Type: field.TypeString, Unique: true, Size: 32, Comment: "entity.user.field.username"}, @@ -461,11 +461,6 @@ var ( Unique: false, Columns: []*schema.Column{SysUsersColumns[4]}, }, - { - Name: "user_delete_time", - Unique: false, - Columns: []*schema.Column{SysUsersColumns[5]}, - }, { Name: "user_username", Unique: false, diff --git a/internal/data/entity/ent/schema/softdelete.go b/internal/data/entity/ent/schema/softdelete.go deleted file mode 100644 index 60e286a6..00000000 --- a/internal/data/entity/ent/schema/softdelete.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package schema implements the functions, types, and interfaces for the module. -package schema - -import ( - "context" - "fmt" - "time" - - "entgo.io/ent/dialect/sql" - - "origadmin/application/admin/internal/helpers/ent/mixin" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/hook" - "origadmin/application/admin/internal/data/entity/ent/intercept" -) - -// SoftDelete is schema to include control and time fields. -type SoftDelete struct { - mixin.DeleteMixin -} - -//Interceptors of the SoftDeleteMixin. -func (s SoftDelete) Interceptors() []ent.Interceptor { - return []ent.Interceptor{ - intercept.TraverseFunc(func(ctx context.Context, q intercept.Query) error { - // Skip soft-delete, means include soft-deleted entities. - if mixin.IsSkipSoftDelete(ctx) { - return nil - } - s.P(q) - return nil - }), - } -} - -func (s SoftDelete) Hooks() []ent.Hook { - return []ent.Hook{ - hook.On(func(next ent.Mutator) ent.Mutator { - return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { - // Skip soft-delete, means delete the entity permanently. - if mixin.IsSkipSoftDelete(ctx) { - return next.Mutate(ctx, m) - } - mx, ok := m.(interface { - SetOp(ent.Op) - SetDeleteTime(time.Time) - }) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - mx.SetOp(ent.OpUpdate) - mx.SetDeleteTime(time.Now()) - return next.Mutate(ctx, m) - }) - }, - ent.OpDelete|ent.OpDeleteOne, - ), - } -} - -// P adds a storage-level predicate to the queries and mutations. -func (s SoftDelete) P(w interface{ WhereP(...func(*sql.Selector)) }) { - w.WhereP( - sql.FieldIsNull(s.DeleteMixin.Fields()[0].Descriptor().Name), - ) -} diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 904b63df..81d8875b 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -114,7 +114,7 @@ func (User) Fields() []ent.Field { // Mixin of the User. func (User) Mixin() []ent.Mixin { - return append(mixin.AuditModelMixin, SoftDelete{}) + return append(mixin.AuditModelMixin, mixin.SoftDeleteMixin{}) } // Indexes of the User. diff --git a/internal/data/entity/ent/user.go b/internal/data/entity/ent/user.go index 28cf0feb..f9f64e1a 100644 --- a/internal/data/entity/ent/user.go +++ b/internal/data/entity/ent/user.go @@ -26,7 +26,7 @@ type User struct { CreateTime time.Time `json:"create_time,omitempty"` // update_time.field.comment UpdateTime time.Time `json:"update_time,omitempty"` - // delete_time.field.comment + // Time of soft-delete DeleteTime *time.Time `json:"delete_time,omitempty"` // entity.user.field.uuid UUID string `json:"uuid,omitempty"` diff --git a/internal/data/entity/ent/view.go b/internal/data/entity/ent/view.go new file mode 100644 index 00000000..2873e2be --- /dev/null +++ b/internal/data/entity/ent/view.go @@ -0,0 +1,306 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "origadmin/application/admin/internal/data/entity/ent/view" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// View is the model entity for the View schema. +type View struct { + config `json:"-"` + // ID of the ent. + // field.primary_key.comment + ID int64 `json:"id,omitempty"` + // create_time.field.comment + CreateTime time.Time `json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime time.Time `json:"update_time,omitempty"` + // view.parent_id.comment + ParentID int64 `json:"parent_id,omitempty"` + // view.keyword.comment + Keyword string `json:"keyword,omitempty"` + // view.scope.comment + Scope string `json:"scope,omitempty"` + // view.name.comment + Name string `json:"name,omitempty"` + // view.type.comment + Type string `json:"type,omitempty"` + // view.component.comment + Component string `json:"component,omitempty"` + // view.path.comment + Path string `json:"path,omitempty"` + // view.icon.comment + Icon string `json:"icon,omitempty"` + // view.visible.comment + Visible bool `json:"visible,omitempty"` + // view.sequence.comment + Sequence int `json:"sequence,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ViewQuery when eager-loading is set. + Edges ViewEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ViewEdges holds the relations/edges for other nodes in the graph. +type ViewEdges struct { + // Parent holds the value of the parent edge. + Parent *View `json:"parent,omitempty"` + // Children holds the value of the children edge. + Children []*View `json:"children,omitempty"` + // Resources holds the value of the resources edge. + Resources []*Resource `json:"resources,omitempty"` + // Permissions holds the value of the permissions edge. + Permissions []*Permission `json:"permissions,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [4]bool +} + +// ParentOrErr returns the Parent value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ViewEdges) ParentOrErr() (*View, error) { + if e.Parent != nil { + return e.Parent, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: view.Label} + } + return nil, &NotLoadedError{edge: "parent"} +} + +// ChildrenOrErr returns the Children value or an error if the edge +// was not loaded in eager-loading. +func (e ViewEdges) ChildrenOrErr() ([]*View, error) { + if e.loadedTypes[1] { + return e.Children, nil + } + return nil, &NotLoadedError{edge: "children"} +} + +// ResourcesOrErr returns the Resources value or an error if the edge +// was not loaded in eager-loading. +func (e ViewEdges) ResourcesOrErr() ([]*Resource, error) { + if e.loadedTypes[2] { + return e.Resources, nil + } + return nil, &NotLoadedError{edge: "resources"} +} + +// PermissionsOrErr returns the Permissions value or an error if the edge +// was not loaded in eager-loading. +func (e ViewEdges) PermissionsOrErr() ([]*Permission, error) { + if e.loadedTypes[3] { + return e.Permissions, nil + } + return nil, &NotLoadedError{edge: "permissions"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*View) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case view.FieldVisible: + values[i] = new(sql.NullBool) + case view.FieldID, view.FieldParentID, view.FieldSequence: + values[i] = new(sql.NullInt64) + case view.FieldKeyword, view.FieldScope, view.FieldName, view.FieldType, view.FieldComponent, view.FieldPath, view.FieldIcon: + values[i] = new(sql.NullString) + case view.FieldCreateTime, view.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the View fields. +func (_m *View) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case view.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case view.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = value.Time + } + case view.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = value.Time + } + case view.FieldParentID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field parent_id", values[i]) + } else if value.Valid { + _m.ParentID = value.Int64 + } + case view.FieldKeyword: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field keyword", values[i]) + } else if value.Valid { + _m.Keyword = value.String + } + case view.FieldScope: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field scope", values[i]) + } else if value.Valid { + _m.Scope = value.String + } + case view.FieldName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field name", values[i]) + } else if value.Valid { + _m.Name = value.String + } + case view.FieldType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + _m.Type = value.String + } + case view.FieldComponent: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field component", values[i]) + } else if value.Valid { + _m.Component = value.String + } + case view.FieldPath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field path", values[i]) + } else if value.Valid { + _m.Path = value.String + } + case view.FieldIcon: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field icon", values[i]) + } else if value.Valid { + _m.Icon = value.String + } + case view.FieldVisible: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field visible", values[i]) + } else if value.Valid { + _m.Visible = value.Bool + } + case view.FieldSequence: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sequence", values[i]) + } else if value.Valid { + _m.Sequence = int(value.Int64) + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the View. +// This includes values selected through modifiers, order, etc. +func (_m *View) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryParent queries the "parent" edge of the View entity. +func (_m *View) QueryParent() *ViewQuery { + return NewViewClient(_m.config).QueryParent(_m) +} + +// QueryChildren queries the "children" edge of the View entity. +func (_m *View) QueryChildren() *ViewQuery { + return NewViewClient(_m.config).QueryChildren(_m) +} + +// QueryResources queries the "resources" edge of the View entity. +func (_m *View) QueryResources() *ResourceQuery { + return NewViewClient(_m.config).QueryResources(_m) +} + +// QueryPermissions queries the "permissions" edge of the View entity. +func (_m *View) QueryPermissions() *PermissionQuery { + return NewViewClient(_m.config).QueryPermissions(_m) +} + +// Update returns a builder for updating this View. +// Note that you need to call View.Unwrap() before calling this method if this View +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *View) Update() *ViewUpdateOne { + return NewViewClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the View entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *View) Unwrap() *View { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: View is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *View) String() string { + var builder strings.Builder + builder.WriteString("View(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("create_time=") + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("parent_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ParentID)) + builder.WriteString(", ") + builder.WriteString("keyword=") + builder.WriteString(_m.Keyword) + builder.WriteString(", ") + builder.WriteString("scope=") + builder.WriteString(_m.Scope) + builder.WriteString(", ") + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(_m.Type) + builder.WriteString(", ") + builder.WriteString("component=") + builder.WriteString(_m.Component) + builder.WriteString(", ") + builder.WriteString("path=") + builder.WriteString(_m.Path) + builder.WriteString(", ") + builder.WriteString("icon=") + builder.WriteString(_m.Icon) + builder.WriteString(", ") + builder.WriteString("visible=") + builder.WriteString(fmt.Sprintf("%v", _m.Visible)) + builder.WriteString(", ") + builder.WriteString("sequence=") + builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) + builder.WriteByte(')') + return builder.String() +} + +// Views is a parsable slice of View. +type Views []*View diff --git a/internal/data/entity/ent/view/view.go b/internal/data/entity/ent/view/view.go new file mode 100644 index 00000000..46a54b58 --- /dev/null +++ b/internal/data/entity/ent/view/view.go @@ -0,0 +1,339 @@ +// Code generated by ent, DO NOT EDIT. + +package view + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the view type in the database. + Label = "view" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldParentID holds the string denoting the parent_id field in the database. + FieldParentID = "parent_id" + // FieldKeyword holds the string denoting the keyword field in the database. + FieldKeyword = "keyword" + // FieldScope holds the string denoting the scope field in the database. + FieldScope = "scope" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldComponent holds the string denoting the component field in the database. + FieldComponent = "component" + // FieldPath holds the string denoting the path field in the database. + FieldPath = "path" + // FieldIcon holds the string denoting the icon field in the database. + FieldIcon = "icon" + // FieldVisible holds the string denoting the visible field in the database. + FieldVisible = "visible" + // FieldSequence holds the string denoting the sequence field in the database. + FieldSequence = "sequence" + // EdgeParent holds the string denoting the parent edge name in mutations. + EdgeParent = "parent" + // EdgeChildren holds the string denoting the children edge name in mutations. + EdgeChildren = "children" + // EdgeResources holds the string denoting the resources edge name in mutations. + EdgeResources = "resources" + // EdgePermissions holds the string denoting the permissions edge name in mutations. + EdgePermissions = "permissions" + // Table holds the table name of the view in the database. + Table = "views" + // ParentTable is the table that holds the parent relation/edge. + ParentTable = "views" + // ParentColumn is the table column denoting the parent relation/edge. + ParentColumn = "parent_id" + // ChildrenTable is the table that holds the children relation/edge. + ChildrenTable = "views" + // ChildrenColumn is the table column denoting the children relation/edge. + ChildrenColumn = "parent_id" + // ResourcesTable is the table that holds the resources relation/edge. The primary key declared below. + ResourcesTable = "resource_views" + // ResourcesInverseTable is the table name for the Resource entity. + // It exists in this package in order to avoid circular dependency with the "resource" package. + ResourcesInverseTable = "resources" + // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. + PermissionsTable = "permission_views" + // PermissionsInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionsInverseTable = "sys_permissions" +) + +// Columns holds all SQL columns for view fields. +var Columns = []string{ + FieldID, + FieldCreateTime, + FieldUpdateTime, + FieldParentID, + FieldKeyword, + FieldScope, + FieldName, + FieldType, + FieldComponent, + FieldPath, + FieldIcon, + FieldVisible, + FieldSequence, +} + +var ( + // ResourcesPrimaryKey and ResourcesColumn2 are the table columns denoting the + // primary key for the resources relation (M2M). + ResourcesPrimaryKey = []string{"resource_id", "view_id"} + // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the + // primary key for the permissions relation (M2M). + PermissionsPrimaryKey = []string{"permission_id", "view_id"} +) + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. + ParentIDValidator func(int64) error + // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. + KeywordValidator func(string) error + // DefaultScope holds the default value on creation for the "scope" field. + DefaultScope string + // DefaultType holds the default value on creation for the "type" field. + DefaultType string + // TypeValidator is a validator for the "type" field. It is called by the builders before save. + TypeValidator func(string) error + // DefaultVisible holds the default value on creation for the "visible" field. + DefaultVisible bool + // DefaultSequence holds the default value on creation for the "sequence" field. + DefaultSequence int + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int64) error +) + +// OrderOption defines the ordering options for the View queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByParentID orders the results by the parent_id field. +func ByParentID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldParentID, opts...).ToFunc() +} + +// ByKeyword orders the results by the keyword field. +func ByKeyword(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldKeyword, opts...).ToFunc() +} + +// ByScope orders the results by the scope field. +func ByScope(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldScope, opts...).ToFunc() +} + +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// ByComponent orders the results by the component field. +func ByComponent(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldComponent, opts...).ToFunc() +} + +// ByPath orders the results by the path field. +func ByPath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPath, opts...).ToFunc() +} + +// ByIcon orders the results by the icon field. +func ByIcon(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIcon, opts...).ToFunc() +} + +// ByVisible orders the results by the visible field. +func ByVisible(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldVisible, opts...).ToFunc() +} + +// BySequence orders the results by the sequence field. +func BySequence(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSequence, opts...).ToFunc() +} + +// ByParentField orders the results by parent field. +func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) + } +} + +// ByChildrenCount orders the results by children count. +func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) + } +} + +// ByChildren orders the results by children terms. +func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByResourcesCount orders the results by resources count. +func ByResourcesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newResourcesStep(), opts...) + } +} + +// ByResources orders the results by resources terms. +func ByResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByPermissionsCount orders the results by permissions count. +func ByPermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newPermissionsStep(), opts...) + } +} + +// ByPermissions orders the results by permissions terms. +func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} +func newParentStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) +} +func newChildrenStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) +} +func newResourcesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ResourcesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ResourcesTable, ResourcesPrimaryKey...), + ) +} +func newPermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/view/where.go b/internal/data/entity/ent/view/where.go new file mode 100644 index 00000000..3044ff8f --- /dev/null +++ b/internal/data/entity/ent/view/where.go @@ -0,0 +1,868 @@ +// Code generated by ent, DO NOT EDIT. + +package view + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.View { + return predicate.View(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.View { + return predicate.View(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.View { + return predicate.View(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.View { + return predicate.View(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.View { + return predicate.View(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.View { + return predicate.View(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.View { + return predicate.View(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.View { + return predicate.View(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.View { + return predicate.View(sql.FieldLTE(FieldID, id)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.View { + return predicate.View(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.View { + return predicate.View(sql.FieldEQ(FieldUpdateTime, v)) +} + +// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ. +func ParentID(v int64) predicate.View { + return predicate.View(sql.FieldEQ(FieldParentID, v)) +} + +// Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. +func Keyword(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldKeyword, v)) +} + +// Scope applies equality check predicate on the "scope" field. It's identical to ScopeEQ. +func Scope(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldScope, v)) +} + +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldName, v)) +} + +// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. +func Type(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldType, v)) +} + +// Component applies equality check predicate on the "component" field. It's identical to ComponentEQ. +func Component(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldComponent, v)) +} + +// Path applies equality check predicate on the "path" field. It's identical to PathEQ. +func Path(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldPath, v)) +} + +// Icon applies equality check predicate on the "icon" field. It's identical to IconEQ. +func Icon(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldIcon, v)) +} + +// Visible applies equality check predicate on the "visible" field. It's identical to VisibleEQ. +func Visible(v bool) predicate.View { + return predicate.View(sql.FieldEQ(FieldVisible, v)) +} + +// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. +func Sequence(v int) predicate.View { + return predicate.View(sql.FieldEQ(FieldSequence, v)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.View { + return predicate.View(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.View { + return predicate.View(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.View { + return predicate.View(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.View { + return predicate.View(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.View { + return predicate.View(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.View { + return predicate.View(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.View { + return predicate.View(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.View { + return predicate.View(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.View { + return predicate.View(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.View { + return predicate.View(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.View { + return predicate.View(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.View { + return predicate.View(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.View { + return predicate.View(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.View { + return predicate.View(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.View { + return predicate.View(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.View { + return predicate.View(sql.FieldLTE(FieldUpdateTime, v)) +} + +// ParentIDEQ applies the EQ predicate on the "parent_id" field. +func ParentIDEQ(v int64) predicate.View { + return predicate.View(sql.FieldEQ(FieldParentID, v)) +} + +// ParentIDNEQ applies the NEQ predicate on the "parent_id" field. +func ParentIDNEQ(v int64) predicate.View { + return predicate.View(sql.FieldNEQ(FieldParentID, v)) +} + +// ParentIDIn applies the In predicate on the "parent_id" field. +func ParentIDIn(vs ...int64) predicate.View { + return predicate.View(sql.FieldIn(FieldParentID, vs...)) +} + +// ParentIDNotIn applies the NotIn predicate on the "parent_id" field. +func ParentIDNotIn(vs ...int64) predicate.View { + return predicate.View(sql.FieldNotIn(FieldParentID, vs...)) +} + +// ParentIDIsNil applies the IsNil predicate on the "parent_id" field. +func ParentIDIsNil() predicate.View { + return predicate.View(sql.FieldIsNull(FieldParentID)) +} + +// ParentIDNotNil applies the NotNil predicate on the "parent_id" field. +func ParentIDNotNil() predicate.View { + return predicate.View(sql.FieldNotNull(FieldParentID)) +} + +// KeywordEQ applies the EQ predicate on the "keyword" field. +func KeywordEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldKeyword, v)) +} + +// KeywordNEQ applies the NEQ predicate on the "keyword" field. +func KeywordNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldKeyword, v)) +} + +// KeywordIn applies the In predicate on the "keyword" field. +func KeywordIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldKeyword, vs...)) +} + +// KeywordNotIn applies the NotIn predicate on the "keyword" field. +func KeywordNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldKeyword, vs...)) +} + +// KeywordGT applies the GT predicate on the "keyword" field. +func KeywordGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldKeyword, v)) +} + +// KeywordGTE applies the GTE predicate on the "keyword" field. +func KeywordGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldKeyword, v)) +} + +// KeywordLT applies the LT predicate on the "keyword" field. +func KeywordLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldKeyword, v)) +} + +// KeywordLTE applies the LTE predicate on the "keyword" field. +func KeywordLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldKeyword, v)) +} + +// KeywordContains applies the Contains predicate on the "keyword" field. +func KeywordContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldKeyword, v)) +} + +// KeywordHasPrefix applies the HasPrefix predicate on the "keyword" field. +func KeywordHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldKeyword, v)) +} + +// KeywordHasSuffix applies the HasSuffix predicate on the "keyword" field. +func KeywordHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldKeyword, v)) +} + +// KeywordEqualFold applies the EqualFold predicate on the "keyword" field. +func KeywordEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldKeyword, v)) +} + +// KeywordContainsFold applies the ContainsFold predicate on the "keyword" field. +func KeywordContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldKeyword, v)) +} + +// ScopeEQ applies the EQ predicate on the "scope" field. +func ScopeEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldScope, v)) +} + +// ScopeNEQ applies the NEQ predicate on the "scope" field. +func ScopeNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldScope, v)) +} + +// ScopeIn applies the In predicate on the "scope" field. +func ScopeIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldScope, vs...)) +} + +// ScopeNotIn applies the NotIn predicate on the "scope" field. +func ScopeNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldScope, vs...)) +} + +// ScopeGT applies the GT predicate on the "scope" field. +func ScopeGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldScope, v)) +} + +// ScopeGTE applies the GTE predicate on the "scope" field. +func ScopeGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldScope, v)) +} + +// ScopeLT applies the LT predicate on the "scope" field. +func ScopeLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldScope, v)) +} + +// ScopeLTE applies the LTE predicate on the "scope" field. +func ScopeLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldScope, v)) +} + +// ScopeContains applies the Contains predicate on the "scope" field. +func ScopeContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldScope, v)) +} + +// ScopeHasPrefix applies the HasPrefix predicate on the "scope" field. +func ScopeHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldScope, v)) +} + +// ScopeHasSuffix applies the HasSuffix predicate on the "scope" field. +func ScopeHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldScope, v)) +} + +// ScopeEqualFold applies the EqualFold predicate on the "scope" field. +func ScopeEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldScope, v)) +} + +// ScopeContainsFold applies the ContainsFold predicate on the "scope" field. +func ScopeContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldScope, v)) +} + +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldName, v)) +} + +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldName, v)) +} + +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldName, vs...)) +} + +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldName, vs...)) +} + +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldName, v)) +} + +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldName, v)) +} + +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldName, v)) +} + +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldName, v)) +} + +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldName, v)) +} + +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldName, v)) +} + +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldName, v)) +} + +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldName, v)) +} + +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldName, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldType, vs...)) +} + +// TypeGT applies the GT predicate on the "type" field. +func TypeGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldType, v)) +} + +// TypeGTE applies the GTE predicate on the "type" field. +func TypeGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldType, v)) +} + +// TypeLT applies the LT predicate on the "type" field. +func TypeLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldType, v)) +} + +// TypeLTE applies the LTE predicate on the "type" field. +func TypeLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldType, v)) +} + +// TypeContains applies the Contains predicate on the "type" field. +func TypeContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldType, v)) +} + +// TypeHasPrefix applies the HasPrefix predicate on the "type" field. +func TypeHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldType, v)) +} + +// TypeHasSuffix applies the HasSuffix predicate on the "type" field. +func TypeHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldType, v)) +} + +// TypeEqualFold applies the EqualFold predicate on the "type" field. +func TypeEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldType, v)) +} + +// TypeContainsFold applies the ContainsFold predicate on the "type" field. +func TypeContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldType, v)) +} + +// ComponentEQ applies the EQ predicate on the "component" field. +func ComponentEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldComponent, v)) +} + +// ComponentNEQ applies the NEQ predicate on the "component" field. +func ComponentNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldComponent, v)) +} + +// ComponentIn applies the In predicate on the "component" field. +func ComponentIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldComponent, vs...)) +} + +// ComponentNotIn applies the NotIn predicate on the "component" field. +func ComponentNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldComponent, vs...)) +} + +// ComponentGT applies the GT predicate on the "component" field. +func ComponentGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldComponent, v)) +} + +// ComponentGTE applies the GTE predicate on the "component" field. +func ComponentGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldComponent, v)) +} + +// ComponentLT applies the LT predicate on the "component" field. +func ComponentLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldComponent, v)) +} + +// ComponentLTE applies the LTE predicate on the "component" field. +func ComponentLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldComponent, v)) +} + +// ComponentContains applies the Contains predicate on the "component" field. +func ComponentContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldComponent, v)) +} + +// ComponentHasPrefix applies the HasPrefix predicate on the "component" field. +func ComponentHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldComponent, v)) +} + +// ComponentHasSuffix applies the HasSuffix predicate on the "component" field. +func ComponentHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldComponent, v)) +} + +// ComponentIsNil applies the IsNil predicate on the "component" field. +func ComponentIsNil() predicate.View { + return predicate.View(sql.FieldIsNull(FieldComponent)) +} + +// ComponentNotNil applies the NotNil predicate on the "component" field. +func ComponentNotNil() predicate.View { + return predicate.View(sql.FieldNotNull(FieldComponent)) +} + +// ComponentEqualFold applies the EqualFold predicate on the "component" field. +func ComponentEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldComponent, v)) +} + +// ComponentContainsFold applies the ContainsFold predicate on the "component" field. +func ComponentContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldComponent, v)) +} + +// PathEQ applies the EQ predicate on the "path" field. +func PathEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldPath, v)) +} + +// PathNEQ applies the NEQ predicate on the "path" field. +func PathNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldPath, v)) +} + +// PathIn applies the In predicate on the "path" field. +func PathIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldPath, vs...)) +} + +// PathNotIn applies the NotIn predicate on the "path" field. +func PathNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldPath, vs...)) +} + +// PathGT applies the GT predicate on the "path" field. +func PathGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldPath, v)) +} + +// PathGTE applies the GTE predicate on the "path" field. +func PathGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldPath, v)) +} + +// PathLT applies the LT predicate on the "path" field. +func PathLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldPath, v)) +} + +// PathLTE applies the LTE predicate on the "path" field. +func PathLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldPath, v)) +} + +// PathContains applies the Contains predicate on the "path" field. +func PathContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldPath, v)) +} + +// PathHasPrefix applies the HasPrefix predicate on the "path" field. +func PathHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldPath, v)) +} + +// PathHasSuffix applies the HasSuffix predicate on the "path" field. +func PathHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldPath, v)) +} + +// PathIsNil applies the IsNil predicate on the "path" field. +func PathIsNil() predicate.View { + return predicate.View(sql.FieldIsNull(FieldPath)) +} + +// PathNotNil applies the NotNil predicate on the "path" field. +func PathNotNil() predicate.View { + return predicate.View(sql.FieldNotNull(FieldPath)) +} + +// PathEqualFold applies the EqualFold predicate on the "path" field. +func PathEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldPath, v)) +} + +// PathContainsFold applies the ContainsFold predicate on the "path" field. +func PathContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldPath, v)) +} + +// IconEQ applies the EQ predicate on the "icon" field. +func IconEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldIcon, v)) +} + +// IconNEQ applies the NEQ predicate on the "icon" field. +func IconNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldIcon, v)) +} + +// IconIn applies the In predicate on the "icon" field. +func IconIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldIcon, vs...)) +} + +// IconNotIn applies the NotIn predicate on the "icon" field. +func IconNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldIcon, vs...)) +} + +// IconGT applies the GT predicate on the "icon" field. +func IconGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldIcon, v)) +} + +// IconGTE applies the GTE predicate on the "icon" field. +func IconGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldIcon, v)) +} + +// IconLT applies the LT predicate on the "icon" field. +func IconLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldIcon, v)) +} + +// IconLTE applies the LTE predicate on the "icon" field. +func IconLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldIcon, v)) +} + +// IconContains applies the Contains predicate on the "icon" field. +func IconContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldIcon, v)) +} + +// IconHasPrefix applies the HasPrefix predicate on the "icon" field. +func IconHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldIcon, v)) +} + +// IconHasSuffix applies the HasSuffix predicate on the "icon" field. +func IconHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldIcon, v)) +} + +// IconIsNil applies the IsNil predicate on the "icon" field. +func IconIsNil() predicate.View { + return predicate.View(sql.FieldIsNull(FieldIcon)) +} + +// IconNotNil applies the NotNil predicate on the "icon" field. +func IconNotNil() predicate.View { + return predicate.View(sql.FieldNotNull(FieldIcon)) +} + +// IconEqualFold applies the EqualFold predicate on the "icon" field. +func IconEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldIcon, v)) +} + +// IconContainsFold applies the ContainsFold predicate on the "icon" field. +func IconContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldIcon, v)) +} + +// VisibleEQ applies the EQ predicate on the "visible" field. +func VisibleEQ(v bool) predicate.View { + return predicate.View(sql.FieldEQ(FieldVisible, v)) +} + +// VisibleNEQ applies the NEQ predicate on the "visible" field. +func VisibleNEQ(v bool) predicate.View { + return predicate.View(sql.FieldNEQ(FieldVisible, v)) +} + +// SequenceEQ applies the EQ predicate on the "sequence" field. +func SequenceEQ(v int) predicate.View { + return predicate.View(sql.FieldEQ(FieldSequence, v)) +} + +// SequenceNEQ applies the NEQ predicate on the "sequence" field. +func SequenceNEQ(v int) predicate.View { + return predicate.View(sql.FieldNEQ(FieldSequence, v)) +} + +// SequenceIn applies the In predicate on the "sequence" field. +func SequenceIn(vs ...int) predicate.View { + return predicate.View(sql.FieldIn(FieldSequence, vs...)) +} + +// SequenceNotIn applies the NotIn predicate on the "sequence" field. +func SequenceNotIn(vs ...int) predicate.View { + return predicate.View(sql.FieldNotIn(FieldSequence, vs...)) +} + +// SequenceGT applies the GT predicate on the "sequence" field. +func SequenceGT(v int) predicate.View { + return predicate.View(sql.FieldGT(FieldSequence, v)) +} + +// SequenceGTE applies the GTE predicate on the "sequence" field. +func SequenceGTE(v int) predicate.View { + return predicate.View(sql.FieldGTE(FieldSequence, v)) +} + +// SequenceLT applies the LT predicate on the "sequence" field. +func SequenceLT(v int) predicate.View { + return predicate.View(sql.FieldLT(FieldSequence, v)) +} + +// SequenceLTE applies the LTE predicate on the "sequence" field. +func SequenceLTE(v int) predicate.View { + return predicate.View(sql.FieldLTE(FieldSequence, v)) +} + +// HasParent applies the HasEdge predicate on the "parent" edge. +func HasParent() predicate.View { + return predicate.View(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). +func HasParentWith(preds ...predicate.View) predicate.View { + return predicate.View(func(s *sql.Selector) { + step := newParentStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasChildren applies the HasEdge predicate on the "children" edge. +func HasChildren() predicate.View { + return predicate.View(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates). +func HasChildrenWith(preds ...predicate.View) predicate.View { + return predicate.View(func(s *sql.Selector) { + step := newChildrenStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasResources applies the HasEdge predicate on the "resources" edge. +func HasResources() predicate.View { + return predicate.View(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, ResourcesTable, ResourcesPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasResourcesWith applies the HasEdge predicate on the "resources" edge with a given conditions (other predicates). +func HasResourcesWith(preds ...predicate.Resource) predicate.View { + return predicate.View(func(s *sql.Selector) { + step := newResourcesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermissions applies the HasEdge predicate on the "permissions" edge. +func HasPermissions() predicate.View { + return predicate.View(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionsWith applies the HasEdge predicate on the "permissions" edge with a given conditions (other predicates). +func HasPermissionsWith(preds ...predicate.Permission) predicate.View { + return predicate.View(func(s *sql.Selector) { + step := newPermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.View) predicate.View { + return predicate.View(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.View) predicate.View { + return predicate.View(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.View) predicate.View { + return predicate.View(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/view_create.go b/internal/data/entity/ent/view_create.go new file mode 100644 index 00000000..3ff20c65 --- /dev/null +++ b/internal/data/entity/ent/view_create.go @@ -0,0 +1,602 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/view" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewCreate is the builder for creating a View entity. +type ViewCreate struct { + config + mutation *ViewMutation + hooks []Hook +} + +// SetCreateTime sets the "create_time" field. +func (_c *ViewCreate) SetCreateTime(v time.Time) *ViewCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *ViewCreate) SetNillableCreateTime(v *time.Time) *ViewCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *ViewCreate) SetUpdateTime(v time.Time) *ViewCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *ViewCreate) SetNillableUpdateTime(v *time.Time) *ViewCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetParentID sets the "parent_id" field. +func (_c *ViewCreate) SetParentID(v int64) *ViewCreate { + _c.mutation.SetParentID(v) + return _c +} + +// SetNillableParentID sets the "parent_id" field if the given value is not nil. +func (_c *ViewCreate) SetNillableParentID(v *int64) *ViewCreate { + if v != nil { + _c.SetParentID(*v) + } + return _c +} + +// SetKeyword sets the "keyword" field. +func (_c *ViewCreate) SetKeyword(v string) *ViewCreate { + _c.mutation.SetKeyword(v) + return _c +} + +// SetScope sets the "scope" field. +func (_c *ViewCreate) SetScope(v string) *ViewCreate { + _c.mutation.SetScope(v) + return _c +} + +// SetNillableScope sets the "scope" field if the given value is not nil. +func (_c *ViewCreate) SetNillableScope(v *string) *ViewCreate { + if v != nil { + _c.SetScope(*v) + } + return _c +} + +// SetName sets the "name" field. +func (_c *ViewCreate) SetName(v string) *ViewCreate { + _c.mutation.SetName(v) + return _c +} + +// SetType sets the "type" field. +func (_c *ViewCreate) SetType(v string) *ViewCreate { + _c.mutation.SetType(v) + return _c +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_c *ViewCreate) SetNillableType(v *string) *ViewCreate { + if v != nil { + _c.SetType(*v) + } + return _c +} + +// SetComponent sets the "component" field. +func (_c *ViewCreate) SetComponent(v string) *ViewCreate { + _c.mutation.SetComponent(v) + return _c +} + +// SetNillableComponent sets the "component" field if the given value is not nil. +func (_c *ViewCreate) SetNillableComponent(v *string) *ViewCreate { + if v != nil { + _c.SetComponent(*v) + } + return _c +} + +// SetPath sets the "path" field. +func (_c *ViewCreate) SetPath(v string) *ViewCreate { + _c.mutation.SetPath(v) + return _c +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (_c *ViewCreate) SetNillablePath(v *string) *ViewCreate { + if v != nil { + _c.SetPath(*v) + } + return _c +} + +// SetIcon sets the "icon" field. +func (_c *ViewCreate) SetIcon(v string) *ViewCreate { + _c.mutation.SetIcon(v) + return _c +} + +// SetNillableIcon sets the "icon" field if the given value is not nil. +func (_c *ViewCreate) SetNillableIcon(v *string) *ViewCreate { + if v != nil { + _c.SetIcon(*v) + } + return _c +} + +// SetVisible sets the "visible" field. +func (_c *ViewCreate) SetVisible(v bool) *ViewCreate { + _c.mutation.SetVisible(v) + return _c +} + +// SetNillableVisible sets the "visible" field if the given value is not nil. +func (_c *ViewCreate) SetNillableVisible(v *bool) *ViewCreate { + if v != nil { + _c.SetVisible(*v) + } + return _c +} + +// SetSequence sets the "sequence" field. +func (_c *ViewCreate) SetSequence(v int) *ViewCreate { + _c.mutation.SetSequence(v) + return _c +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_c *ViewCreate) SetNillableSequence(v *int) *ViewCreate { + if v != nil { + _c.SetSequence(*v) + } + return _c +} + +// SetID sets the "id" field. +func (_c *ViewCreate) SetID(v int64) *ViewCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *ViewCreate) SetNillableID(v *int64) *ViewCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetParent sets the "parent" edge to the View entity. +func (_c *ViewCreate) SetParent(v *View) *ViewCreate { + return _c.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the View entity by IDs. +func (_c *ViewCreate) AddChildIDs(ids ...int64) *ViewCreate { + _c.mutation.AddChildIDs(ids...) + return _c +} + +// AddChildren adds the "children" edges to the View entity. +func (_c *ViewCreate) AddChildren(v ...*View) *ViewCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddChildIDs(ids...) +} + +// AddResourceIDs adds the "resources" edge to the Resource entity by IDs. +func (_c *ViewCreate) AddResourceIDs(ids ...int64) *ViewCreate { + _c.mutation.AddResourceIDs(ids...) + return _c +} + +// AddResources adds the "resources" edges to the Resource entity. +func (_c *ViewCreate) AddResources(v ...*Resource) *ViewCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddResourceIDs(ids...) +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. +func (_c *ViewCreate) AddPermissionIDs(ids ...int64) *ViewCreate { + _c.mutation.AddPermissionIDs(ids...) + return _c +} + +// AddPermissions adds the "permissions" edges to the Permission entity. +func (_c *ViewCreate) AddPermissions(v ...*Permission) *ViewCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddPermissionIDs(ids...) +} + +// Mutation returns the ViewMutation object of the builder. +func (_c *ViewCreate) Mutation() *ViewMutation { + return _c.mutation +} + +// Save creates the View in the database. +func (_c *ViewCreate) Save(ctx context.Context) (*View, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *ViewCreate) SaveX(ctx context.Context) *View { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ViewCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ViewCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *ViewCreate) defaults() { + if _, ok := _c.mutation.CreateTime(); !ok { + v := view.DefaultCreateTime() + _c.mutation.SetCreateTime(v) + } + if _, ok := _c.mutation.UpdateTime(); !ok { + v := view.DefaultUpdateTime() + _c.mutation.SetUpdateTime(v) + } + if _, ok := _c.mutation.Scope(); !ok { + v := view.DefaultScope + _c.mutation.SetScope(v) + } + if _, ok := _c.mutation.GetType(); !ok { + v := view.DefaultType + _c.mutation.SetType(v) + } + if _, ok := _c.mutation.Visible(); !ok { + v := view.DefaultVisible + _c.mutation.SetVisible(v) + } + if _, ok := _c.mutation.Sequence(); !ok { + v := view.DefaultSequence + _c.mutation.SetSequence(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := view.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *ViewCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "View.create_time"`)} + } + if _, ok := _c.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "View.update_time"`)} + } + if v, ok := _c.mutation.ParentID(); ok { + if err := view.ParentIDValidator(v); err != nil { + return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "View.parent_id": %w`, err)} + } + } + if _, ok := _c.mutation.Keyword(); !ok { + return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "View.keyword"`)} + } + if v, ok := _c.mutation.Keyword(); ok { + if err := view.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "View.keyword": %w`, err)} + } + } + if _, ok := _c.mutation.Scope(); !ok { + return &ValidationError{Name: "scope", err: errors.New(`ent: missing required field "View.scope"`)} + } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "View.name"`)} + } + if _, ok := _c.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "View.type"`)} + } + if v, ok := _c.mutation.GetType(); ok { + if err := view.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "View.type": %w`, err)} + } + } + if _, ok := _c.mutation.Visible(); !ok { + return &ValidationError{Name: "visible", err: errors.New(`ent: missing required field "View.visible"`)} + } + if _, ok := _c.mutation.Sequence(); !ok { + return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "View.sequence"`)} + } + if v, ok := _c.mutation.ID(); ok { + if err := view.IDValidator(v); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "View.id": %w`, err)} + } + } + return nil +} + +func (_c *ViewCreate) sqlSave(ctx context.Context) (*View, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *ViewCreate) createSpec() (*View, *sqlgraph.CreateSpec) { + var ( + _node = &View{config: _c.config} + _spec = sqlgraph.NewCreateSpec(view.Table, sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(view.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(view.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if value, ok := _c.mutation.Keyword(); ok { + _spec.SetField(view.FieldKeyword, field.TypeString, value) + _node.Keyword = value + } + if value, ok := _c.mutation.Scope(); ok { + _spec.SetField(view.FieldScope, field.TypeString, value) + _node.Scope = value + } + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(view.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.GetType(); ok { + _spec.SetField(view.FieldType, field.TypeString, value) + _node.Type = value + } + if value, ok := _c.mutation.Component(); ok { + _spec.SetField(view.FieldComponent, field.TypeString, value) + _node.Component = value + } + if value, ok := _c.mutation.Path(); ok { + _spec.SetField(view.FieldPath, field.TypeString, value) + _node.Path = value + } + if value, ok := _c.mutation.Icon(); ok { + _spec.SetField(view.FieldIcon, field.TypeString, value) + _node.Icon = value + } + if value, ok := _c.mutation.Visible(); ok { + _spec.SetField(view.FieldVisible, field.TypeBool, value) + _node.Visible = value + } + if value, ok := _c.mutation.Sequence(); ok { + _spec.SetField(view.FieldSequence, field.TypeInt, value) + _node.Sequence = value + } + if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: view.ParentTable, + Columns: []string{view.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ParentID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: view.ChildrenTable, + Columns: []string{view.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.ResourcesTable, + Columns: view.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.PermissionsTable, + Columns: view.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SetView set the View +func (_c *ViewCreate) SetView(input *View, fields ...string) *ViewCreate { + m := _c.mutation + if len(fields) == 0 { + fields = view.Columns + } + _ = m.SetFields(input, fields...) + return _c +} + +// SetViewWithZero set the View +func (_c *ViewCreate) SetViewWithZero(input *View, fields ...string) *ViewCreate { + m := _c.mutation + if len(fields) == 0 { + fields = view.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return _c +} + +// ViewCreateBulk is the builder for creating many View entities in bulk. +type ViewCreateBulk struct { + config + err error + builders []*ViewCreate +} + +// Save creates the View entities in the database. +func (_c *ViewCreateBulk) Save(ctx context.Context) ([]*View, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*View, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ViewMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *ViewCreateBulk) SaveX(ctx context.Context) []*View { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ViewCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ViewCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/data/entity/ent/view_delete.go b/internal/data/entity/ent/view_delete.go new file mode 100644 index 00000000..b1111a01 --- /dev/null +++ b/internal/data/entity/ent/view_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/view" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewDelete is the builder for deleting a View entity. +type ViewDelete struct { + config + hooks []Hook + mutation *ViewMutation +} + +// Where appends a list predicates to the ViewDelete builder. +func (_d *ViewDelete) Where(ps ...predicate.View) *ViewDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *ViewDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ViewDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *ViewDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(view.Table, sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// ViewDeleteOne is the builder for deleting a single View entity. +type ViewDeleteOne struct { + _d *ViewDelete +} + +// Where appends a list predicates to the ViewDelete builder. +func (_d *ViewDeleteOne) Where(ps ...predicate.View) *ViewDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *ViewDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{view.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ViewDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/data/entity/ent/view_query.go b/internal/data/entity/ent/view_query.go new file mode 100644 index 00000000..f24d6d64 --- /dev/null +++ b/internal/data/entity/ent/view_query.go @@ -0,0 +1,991 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "database/sql/driver" + "fmt" + "math" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/view" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewQuery is the builder for querying View entities. +type ViewQuery struct { + config + ctx *QueryContext + order []view.OrderOption + inters []Interceptor + predicates []predicate.View + withParent *ViewQuery + withChildren *ViewQuery + withResources *ResourceQuery + withPermissions *PermissionQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ViewQuery builder. +func (_q *ViewQuery) Where(ps ...predicate.View) *ViewQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *ViewQuery) Limit(limit int) *ViewQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *ViewQuery) Offset(offset int) *ViewQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *ViewQuery) Unique(unique bool) *ViewQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *ViewQuery) Order(o ...view.OrderOption) *ViewQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryParent chains the current query on the "parent" edge. +func (_q *ViewQuery) QueryParent() *ViewQuery { + query := (&ViewClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, selector), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, view.ParentTable, view.ParentColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryChildren chains the current query on the "children" edge. +func (_q *ViewQuery) QueryChildren() *ViewQuery { + query := (&ViewClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, selector), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, view.ChildrenTable, view.ChildrenColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryResources chains the current query on the "resources" edge. +func (_q *ViewQuery) QueryResources() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, selector), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, view.ResourcesTable, view.ResourcesPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryPermissions chains the current query on the "permissions" edge. +func (_q *ViewQuery) QueryPermissions() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, selector), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2M, true, view.PermissionsTable, view.PermissionsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first View entity from the query. +// Returns a *NotFoundError when no View was found. +func (_q *ViewQuery) First(ctx context.Context) (*View, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{view.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *ViewQuery) FirstX(ctx context.Context) *View { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first View ID from the query. +// Returns a *NotFoundError when no View ID was found. +func (_q *ViewQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{view.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *ViewQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single View entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one View entity is found. +// Returns a *NotFoundError when no View entities are found. +func (_q *ViewQuery) Only(ctx context.Context) (*View, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{view.Label} + default: + return nil, &NotSingularError{view.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *ViewQuery) OnlyX(ctx context.Context) *View { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only View ID in the query. +// Returns a *NotSingularError when more than one View ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *ViewQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{view.Label} + default: + err = &NotSingularError{view.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *ViewQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Views. +func (_q *ViewQuery) All(ctx context.Context) ([]*View, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*View, *ViewQuery]() + return withInterceptors[[]*View](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *ViewQuery) AllX(ctx context.Context) []*View { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of View IDs. +func (_q *ViewQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(view.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *ViewQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *ViewQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*ViewQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *ViewQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *ViewQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *ViewQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ViewQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *ViewQuery) Clone() *ViewQuery { + if _q == nil { + return nil + } + return &ViewQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]view.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.View{}, _q.predicates...), + withParent: _q.withParent.Clone(), + withChildren: _q.withChildren.Clone(), + withResources: _q.withResources.Clone(), + withPermissions: _q.withPermissions.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithParent tells the query-builder to eager-load the nodes that are connected to +// the "parent" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ViewQuery) WithParent(opts ...func(*ViewQuery)) *ViewQuery { + query := (&ViewClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withParent = query + return _q +} + +// WithChildren tells the query-builder to eager-load the nodes that are connected to +// the "children" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ViewQuery) WithChildren(opts ...func(*ViewQuery)) *ViewQuery { + query := (&ViewClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withChildren = query + return _q +} + +// WithResources tells the query-builder to eager-load the nodes that are connected to +// the "resources" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ViewQuery) WithResources(opts ...func(*ResourceQuery)) *ViewQuery { + query := (&ResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withResources = query + return _q +} + +// WithPermissions tells the query-builder to eager-load the nodes that are connected to +// the "permissions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ViewQuery) WithPermissions(opts ...func(*PermissionQuery)) *ViewQuery { + query := (&PermissionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withPermissions = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.View.Query(). +// GroupBy(view.FieldCreateTime). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *ViewQuery) GroupBy(field string, fields ...string) *ViewGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &ViewGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = view.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// } +// +// client.View.Query(). +// Select(view.FieldCreateTime). +// Scan(ctx, &v) +func (_q *ViewQuery) Select(fields ...string) *ViewSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &ViewSelect{ViewQuery: _q} + sbuild.label = view.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ViewSelect configured with the given aggregations. +func (_q *ViewQuery) Aggregate(fns ...AggregateFunc) *ViewSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *ViewQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !view.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *ViewQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*View, error) { + var ( + nodes = []*View{} + _spec = _q.querySpec() + loadedTypes = [4]bool{ + _q.withParent != nil, + _q.withChildren != nil, + _q.withResources != nil, + _q.withPermissions != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*View).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &View{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withParent; query != nil { + if err := _q.loadParent(ctx, query, nodes, nil, + func(n *View, e *View) { n.Edges.Parent = e }); err != nil { + return nil, err + } + } + if query := _q.withChildren; query != nil { + if err := _q.loadChildren(ctx, query, nodes, + func(n *View) { n.Edges.Children = []*View{} }, + func(n *View, e *View) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil { + return nil, err + } + } + if query := _q.withResources; query != nil { + if err := _q.loadResources(ctx, query, nodes, + func(n *View) { n.Edges.Resources = []*Resource{} }, + func(n *View, e *Resource) { n.Edges.Resources = append(n.Edges.Resources, e) }); err != nil { + return nil, err + } + } + if query := _q.withPermissions; query != nil { + if err := _q.loadPermissions(ctx, query, nodes, + func(n *View) { n.Edges.Permissions = []*Permission{} }, + func(n *View, e *Permission) { n.Edges.Permissions = append(n.Edges.Permissions, e) }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *ViewQuery) loadParent(ctx context.Context, query *ViewQuery, nodes []*View, init func(*View), assign func(*View, *View)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*View) + for i := range nodes { + fk := nodes[i].ParentID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(view.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "parent_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *ViewQuery) loadChildren(ctx context.Context, query *ViewQuery, nodes []*View, init func(*View), assign func(*View, *View)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*View) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(view.FieldParentID) + } + query.Where(predicate.View(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(view.ChildrenColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ParentID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "parent_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *ViewQuery) loadResources(ctx context.Context, query *ResourceQuery, nodes []*View, init func(*View), assign func(*View, *Resource)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int64]*View) + nids := make(map[int64]map[*View]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(view.ResourcesTable) + s.Join(joinT).On(s.C(resource.FieldID), joinT.C(view.ResourcesPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(view.ResourcesPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(view.ResourcesPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullInt64).Int64 + inValue := values[1].(*sql.NullInt64).Int64 + if nids[inValue] == nil { + nids[inValue] = map[*View]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Resource](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "resources" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} +func (_q *ViewQuery) loadPermissions(ctx context.Context, query *PermissionQuery, nodes []*View, init func(*View), assign func(*View, *Permission)) error { + edgeIDs := make([]driver.Value, len(nodes)) + byID := make(map[int64]*View) + nids := make(map[int64]map[*View]struct{}) + for i, node := range nodes { + edgeIDs[i] = node.ID + byID[node.ID] = node + if init != nil { + init(node) + } + } + query.Where(func(s *sql.Selector) { + joinT := sql.Table(view.PermissionsTable) + s.Join(joinT).On(s.C(permission.FieldID), joinT.C(view.PermissionsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(view.PermissionsPrimaryKey[1]), edgeIDs...)) + columns := s.SelectedColumns() + s.Select(joinT.C(view.PermissionsPrimaryKey[1])) + s.AppendSelect(columns...) + s.SetDistinct(false) + }) + if err := query.prepareQuery(ctx); err != nil { + return err + } + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil + } + spec.Assign = func(columns []string, values []any) error { + outValue := values[0].(*sql.NullInt64).Int64 + inValue := values[1].(*sql.NullInt64).Int64 + if nids[inValue] == nil { + nids[inValue] = map[*View]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil + } + }) + }) + neighbors, err := withInterceptors[[]*Permission](ctx, query, qr, query.inters) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nids[n.ID] + if !ok { + return fmt.Errorf(`unexpected "permissions" node returned %v`, n.ID) + } + for kn := range nodes { + assign(kn, n) + } + } + return nil +} + +func (_q *ViewQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *ViewQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(view.Table, view.Columns, sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, view.FieldID) + for i := range fields { + if fields[i] != view.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withParent != nil { + _spec.Node.AddColumnOnce(view.FieldParentID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *ViewQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(view.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = view.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *ViewQuery) ForUpdate(opts ...sql.LockOption) *ViewQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *ViewQuery) ForShare(opts ...sql.LockOption) *ViewQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *ViewQuery) Modify(modifiers ...func(s *sql.Selector)) *ViewSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// CreateTime time.Time `json:"create_time,omitempty"` +// UpdateTime time.Time `json:"update_time,omitempty"` +// ParentID int64 `json:"parent_id,omitempty"` +// Keyword string `json:"keyword,omitempty"` +// Scope string `json:"scope,omitempty"` +// Name string `json:"name,omitempty"` +// Type string `json:"type,omitempty"` +// Component string `json:"component,omitempty"` +// Path string `json:"path,omitempty"` +// Icon string `json:"icon,omitempty"` +// Visible bool `json:"visible,omitempty"` +// Sequence int `json:"sequence,omitempty"` +// } +// +// client.View.Query(). +// Omit( +// view.FieldCreateTime, +// view.FieldUpdateTime, +// view.FieldParentID, +// view.FieldKeyword, +// view.FieldScope, +// view.FieldName, +// view.FieldType, +// view.FieldComponent, +// view.FieldPath, +// view.FieldIcon, +// view.FieldVisible, +// view.FieldSequence, +// ). +// Scan(ctx, &v) +func (vq *ViewQuery) Omit(fields ...string) *ViewSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range view.Columns { + if _, ok := omits[col]; !ok { + vq.ctx.Fields = append(vq.ctx.Fields, col) + } + } + + sbuild := &ViewSelect{ViewQuery: vq} + sbuild.label = view.Label + sbuild.flds, sbuild.scan = &vq.ctx.Fields, sbuild.Scan + return sbuild +} + +// ViewGroupBy is the group-by builder for View entities. +type ViewGroupBy struct { + selector + build *ViewQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *ViewGroupBy) Aggregate(fns ...AggregateFunc) *ViewGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *ViewGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ViewQuery, *ViewGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *ViewGroupBy) sqlScan(ctx context.Context, root *ViewQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ViewSelect is the builder for selecting fields of View entities. +type ViewSelect struct { + *ViewQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *ViewSelect) Aggregate(fns ...AggregateFunc) *ViewSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *ViewSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ViewQuery, *ViewSelect](ctx, _s.ViewQuery, _s, _s.inters, v) +} + +func (_s *ViewSelect) sqlScan(ctx context.Context, root *ViewQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *ViewSelect) Modify(modifiers ...func(s *sql.Selector)) *ViewSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/internal/data/entity/ent/view_update.go b/internal/data/entity/ent/view_update.go new file mode 100644 index 00000000..61d87429 --- /dev/null +++ b/internal/data/entity/ent/view_update.go @@ -0,0 +1,1318 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/view" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewUpdate is the builder for updating View entities. +type ViewUpdate struct { + config + hooks []Hook + mutation *ViewMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ViewUpdate builder. +func (_u *ViewUpdate) Where(ps ...predicate.View) *ViewUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *ViewUpdate) SetUpdateTime(v time.Time) *ViewUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetParentID sets the "parent_id" field. +func (_u *ViewUpdate) SetParentID(v int64) *ViewUpdate { + _u.mutation.SetParentID(v) + return _u +} + +// SetNillableParentID sets the "parent_id" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableParentID(v *int64) *ViewUpdate { + if v != nil { + _u.SetParentID(*v) + } + return _u +} + +// ClearParentID clears the value of the "parent_id" field. +func (_u *ViewUpdate) ClearParentID() *ViewUpdate { + _u.mutation.ClearParentID() + return _u +} + +// SetKeyword sets the "keyword" field. +func (_u *ViewUpdate) SetKeyword(v string) *ViewUpdate { + _u.mutation.SetKeyword(v) + return _u +} + +// SetNillableKeyword sets the "keyword" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableKeyword(v *string) *ViewUpdate { + if v != nil { + _u.SetKeyword(*v) + } + return _u +} + +// SetScope sets the "scope" field. +func (_u *ViewUpdate) SetScope(v string) *ViewUpdate { + _u.mutation.SetScope(v) + return _u +} + +// SetNillableScope sets the "scope" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableScope(v *string) *ViewUpdate { + if v != nil { + _u.SetScope(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *ViewUpdate) SetName(v string) *ViewUpdate { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableName(v *string) *ViewUpdate { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetType sets the "type" field. +func (_u *ViewUpdate) SetType(v string) *ViewUpdate { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableType(v *string) *ViewUpdate { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetComponent sets the "component" field. +func (_u *ViewUpdate) SetComponent(v string) *ViewUpdate { + _u.mutation.SetComponent(v) + return _u +} + +// SetNillableComponent sets the "component" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableComponent(v *string) *ViewUpdate { + if v != nil { + _u.SetComponent(*v) + } + return _u +} + +// ClearComponent clears the value of the "component" field. +func (_u *ViewUpdate) ClearComponent() *ViewUpdate { + _u.mutation.ClearComponent() + return _u +} + +// SetPath sets the "path" field. +func (_u *ViewUpdate) SetPath(v string) *ViewUpdate { + _u.mutation.SetPath(v) + return _u +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (_u *ViewUpdate) SetNillablePath(v *string) *ViewUpdate { + if v != nil { + _u.SetPath(*v) + } + return _u +} + +// ClearPath clears the value of the "path" field. +func (_u *ViewUpdate) ClearPath() *ViewUpdate { + _u.mutation.ClearPath() + return _u +} + +// SetIcon sets the "icon" field. +func (_u *ViewUpdate) SetIcon(v string) *ViewUpdate { + _u.mutation.SetIcon(v) + return _u +} + +// SetNillableIcon sets the "icon" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableIcon(v *string) *ViewUpdate { + if v != nil { + _u.SetIcon(*v) + } + return _u +} + +// ClearIcon clears the value of the "icon" field. +func (_u *ViewUpdate) ClearIcon() *ViewUpdate { + _u.mutation.ClearIcon() + return _u +} + +// SetVisible sets the "visible" field. +func (_u *ViewUpdate) SetVisible(v bool) *ViewUpdate { + _u.mutation.SetVisible(v) + return _u +} + +// SetNillableVisible sets the "visible" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableVisible(v *bool) *ViewUpdate { + if v != nil { + _u.SetVisible(*v) + } + return _u +} + +// SetSequence sets the "sequence" field. +func (_u *ViewUpdate) SetSequence(v int) *ViewUpdate { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableSequence(v *int) *ViewUpdate { + if v != nil { + _u.SetSequence(*v) + } + return _u +} + +// AddSequence adds value to the "sequence" field. +func (_u *ViewUpdate) AddSequence(v int) *ViewUpdate { + _u.mutation.AddSequence(v) + return _u +} + +// SetParent sets the "parent" edge to the View entity. +func (_u *ViewUpdate) SetParent(v *View) *ViewUpdate { + return _u.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the View entity by IDs. +func (_u *ViewUpdate) AddChildIDs(ids ...int64) *ViewUpdate { + _u.mutation.AddChildIDs(ids...) + return _u +} + +// AddChildren adds the "children" edges to the View entity. +func (_u *ViewUpdate) AddChildren(v ...*View) *ViewUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChildIDs(ids...) +} + +// AddResourceIDs adds the "resources" edge to the Resource entity by IDs. +func (_u *ViewUpdate) AddResourceIDs(ids ...int64) *ViewUpdate { + _u.mutation.AddResourceIDs(ids...) + return _u +} + +// AddResources adds the "resources" edges to the Resource entity. +func (_u *ViewUpdate) AddResources(v ...*Resource) *ViewUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddResourceIDs(ids...) +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. +func (_u *ViewUpdate) AddPermissionIDs(ids ...int64) *ViewUpdate { + _u.mutation.AddPermissionIDs(ids...) + return _u +} + +// AddPermissions adds the "permissions" edges to the Permission entity. +func (_u *ViewUpdate) AddPermissions(v ...*Permission) *ViewUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPermissionIDs(ids...) +} + +// Mutation returns the ViewMutation object of the builder. +func (_u *ViewUpdate) Mutation() *ViewMutation { + return _u.mutation +} + +// ClearParent clears the "parent" edge to the View entity. +func (_u *ViewUpdate) ClearParent() *ViewUpdate { + _u.mutation.ClearParent() + return _u +} + +// ClearChildren clears all "children" edges to the View entity. +func (_u *ViewUpdate) ClearChildren() *ViewUpdate { + _u.mutation.ClearChildren() + return _u +} + +// RemoveChildIDs removes the "children" edge to View entities by IDs. +func (_u *ViewUpdate) RemoveChildIDs(ids ...int64) *ViewUpdate { + _u.mutation.RemoveChildIDs(ids...) + return _u +} + +// RemoveChildren removes "children" edges to View entities. +func (_u *ViewUpdate) RemoveChildren(v ...*View) *ViewUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChildIDs(ids...) +} + +// ClearResources clears all "resources" edges to the Resource entity. +func (_u *ViewUpdate) ClearResources() *ViewUpdate { + _u.mutation.ClearResources() + return _u +} + +// RemoveResourceIDs removes the "resources" edge to Resource entities by IDs. +func (_u *ViewUpdate) RemoveResourceIDs(ids ...int64) *ViewUpdate { + _u.mutation.RemoveResourceIDs(ids...) + return _u +} + +// RemoveResources removes "resources" edges to Resource entities. +func (_u *ViewUpdate) RemoveResources(v ...*Resource) *ViewUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveResourceIDs(ids...) +} + +// ClearPermissions clears all "permissions" edges to the Permission entity. +func (_u *ViewUpdate) ClearPermissions() *ViewUpdate { + _u.mutation.ClearPermissions() + return _u +} + +// RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. +func (_u *ViewUpdate) RemovePermissionIDs(ids ...int64) *ViewUpdate { + _u.mutation.RemovePermissionIDs(ids...) + return _u +} + +// RemovePermissions removes "permissions" edges to Permission entities. +func (_u *ViewUpdate) RemovePermissions(v ...*Permission) *ViewUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePermissionIDs(ids...) +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *ViewUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ViewUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *ViewUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ViewUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ViewUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := view.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ViewUpdate) check() error { + if v, ok := _u.mutation.ParentID(); ok { + if err := view.ParentIDValidator(v); err != nil { + return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "View.parent_id": %w`, err)} + } + } + if v, ok := _u.mutation.Keyword(); ok { + if err := view.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "View.keyword": %w`, err)} + } + } + if v, ok := _u.mutation.GetType(); ok { + if err := view.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "View.type": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ViewUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ViewUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(view.Table, view.Columns, sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(view.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.Keyword(); ok { + _spec.SetField(view.FieldKeyword, field.TypeString, value) + } + if value, ok := _u.mutation.Scope(); ok { + _spec.SetField(view.FieldScope, field.TypeString, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(view.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(view.FieldType, field.TypeString, value) + } + if value, ok := _u.mutation.Component(); ok { + _spec.SetField(view.FieldComponent, field.TypeString, value) + } + if _u.mutation.ComponentCleared() { + _spec.ClearField(view.FieldComponent, field.TypeString) + } + if value, ok := _u.mutation.Path(); ok { + _spec.SetField(view.FieldPath, field.TypeString, value) + } + if _u.mutation.PathCleared() { + _spec.ClearField(view.FieldPath, field.TypeString) + } + if value, ok := _u.mutation.Icon(); ok { + _spec.SetField(view.FieldIcon, field.TypeString, value) + } + if _u.mutation.IconCleared() { + _spec.ClearField(view.FieldIcon, field.TypeString) + } + if value, ok := _u.mutation.Visible(); ok { + _spec.SetField(view.FieldVisible, field.TypeBool, value) + } + if value, ok := _u.mutation.Sequence(); ok { + _spec.SetField(view.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSequence(); ok { + _spec.AddField(view.FieldSequence, field.TypeInt, value) + } + if _u.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: view.ParentTable, + Columns: []string{view.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: view.ParentTable, + Columns: []string{view.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: view.ChildrenTable, + Columns: []string{view.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: view.ChildrenTable, + Columns: []string{view.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: view.ChildrenTable, + Columns: []string{view.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.ResourcesTable, + Columns: view.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !_u.mutation.ResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.ResourcesTable, + Columns: view.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.ResourcesTable, + Columns: view.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.PermissionsTable, + Columns: view.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.PermissionsTable, + Columns: view.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.PermissionsTable, + Columns: view.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{view.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// ViewUpdateOne is the builder for updating a single View entity. +type ViewUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ViewMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdateTime sets the "update_time" field. +func (_u *ViewUpdateOne) SetUpdateTime(v time.Time) *ViewUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetParentID sets the "parent_id" field. +func (_u *ViewUpdateOne) SetParentID(v int64) *ViewUpdateOne { + _u.mutation.SetParentID(v) + return _u +} + +// SetNillableParentID sets the "parent_id" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableParentID(v *int64) *ViewUpdateOne { + if v != nil { + _u.SetParentID(*v) + } + return _u +} + +// ClearParentID clears the value of the "parent_id" field. +func (_u *ViewUpdateOne) ClearParentID() *ViewUpdateOne { + _u.mutation.ClearParentID() + return _u +} + +// SetKeyword sets the "keyword" field. +func (_u *ViewUpdateOne) SetKeyword(v string) *ViewUpdateOne { + _u.mutation.SetKeyword(v) + return _u +} + +// SetNillableKeyword sets the "keyword" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableKeyword(v *string) *ViewUpdateOne { + if v != nil { + _u.SetKeyword(*v) + } + return _u +} + +// SetScope sets the "scope" field. +func (_u *ViewUpdateOne) SetScope(v string) *ViewUpdateOne { + _u.mutation.SetScope(v) + return _u +} + +// SetNillableScope sets the "scope" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableScope(v *string) *ViewUpdateOne { + if v != nil { + _u.SetScope(*v) + } + return _u +} + +// SetName sets the "name" field. +func (_u *ViewUpdateOne) SetName(v string) *ViewUpdateOne { + _u.mutation.SetName(v) + return _u +} + +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableName(v *string) *ViewUpdateOne { + if v != nil { + _u.SetName(*v) + } + return _u +} + +// SetType sets the "type" field. +func (_u *ViewUpdateOne) SetType(v string) *ViewUpdateOne { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableType(v *string) *ViewUpdateOne { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// SetComponent sets the "component" field. +func (_u *ViewUpdateOne) SetComponent(v string) *ViewUpdateOne { + _u.mutation.SetComponent(v) + return _u +} + +// SetNillableComponent sets the "component" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableComponent(v *string) *ViewUpdateOne { + if v != nil { + _u.SetComponent(*v) + } + return _u +} + +// ClearComponent clears the value of the "component" field. +func (_u *ViewUpdateOne) ClearComponent() *ViewUpdateOne { + _u.mutation.ClearComponent() + return _u +} + +// SetPath sets the "path" field. +func (_u *ViewUpdateOne) SetPath(v string) *ViewUpdateOne { + _u.mutation.SetPath(v) + return _u +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillablePath(v *string) *ViewUpdateOne { + if v != nil { + _u.SetPath(*v) + } + return _u +} + +// ClearPath clears the value of the "path" field. +func (_u *ViewUpdateOne) ClearPath() *ViewUpdateOne { + _u.mutation.ClearPath() + return _u +} + +// SetIcon sets the "icon" field. +func (_u *ViewUpdateOne) SetIcon(v string) *ViewUpdateOne { + _u.mutation.SetIcon(v) + return _u +} + +// SetNillableIcon sets the "icon" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableIcon(v *string) *ViewUpdateOne { + if v != nil { + _u.SetIcon(*v) + } + return _u +} + +// ClearIcon clears the value of the "icon" field. +func (_u *ViewUpdateOne) ClearIcon() *ViewUpdateOne { + _u.mutation.ClearIcon() + return _u +} + +// SetVisible sets the "visible" field. +func (_u *ViewUpdateOne) SetVisible(v bool) *ViewUpdateOne { + _u.mutation.SetVisible(v) + return _u +} + +// SetNillableVisible sets the "visible" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableVisible(v *bool) *ViewUpdateOne { + if v != nil { + _u.SetVisible(*v) + } + return _u +} + +// SetSequence sets the "sequence" field. +func (_u *ViewUpdateOne) SetSequence(v int) *ViewUpdateOne { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableSequence(v *int) *ViewUpdateOne { + if v != nil { + _u.SetSequence(*v) + } + return _u +} + +// AddSequence adds value to the "sequence" field. +func (_u *ViewUpdateOne) AddSequence(v int) *ViewUpdateOne { + _u.mutation.AddSequence(v) + return _u +} + +// SetParent sets the "parent" edge to the View entity. +func (_u *ViewUpdateOne) SetParent(v *View) *ViewUpdateOne { + return _u.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the View entity by IDs. +func (_u *ViewUpdateOne) AddChildIDs(ids ...int64) *ViewUpdateOne { + _u.mutation.AddChildIDs(ids...) + return _u +} + +// AddChildren adds the "children" edges to the View entity. +func (_u *ViewUpdateOne) AddChildren(v ...*View) *ViewUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChildIDs(ids...) +} + +// AddResourceIDs adds the "resources" edge to the Resource entity by IDs. +func (_u *ViewUpdateOne) AddResourceIDs(ids ...int64) *ViewUpdateOne { + _u.mutation.AddResourceIDs(ids...) + return _u +} + +// AddResources adds the "resources" edges to the Resource entity. +func (_u *ViewUpdateOne) AddResources(v ...*Resource) *ViewUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddResourceIDs(ids...) +} + +// AddPermissionIDs adds the "permissions" edge to the Permission entity by IDs. +func (_u *ViewUpdateOne) AddPermissionIDs(ids ...int64) *ViewUpdateOne { + _u.mutation.AddPermissionIDs(ids...) + return _u +} + +// AddPermissions adds the "permissions" edges to the Permission entity. +func (_u *ViewUpdateOne) AddPermissions(v ...*Permission) *ViewUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddPermissionIDs(ids...) +} + +// Mutation returns the ViewMutation object of the builder. +func (_u *ViewUpdateOne) Mutation() *ViewMutation { + return _u.mutation +} + +// ClearParent clears the "parent" edge to the View entity. +func (_u *ViewUpdateOne) ClearParent() *ViewUpdateOne { + _u.mutation.ClearParent() + return _u +} + +// ClearChildren clears all "children" edges to the View entity. +func (_u *ViewUpdateOne) ClearChildren() *ViewUpdateOne { + _u.mutation.ClearChildren() + return _u +} + +// RemoveChildIDs removes the "children" edge to View entities by IDs. +func (_u *ViewUpdateOne) RemoveChildIDs(ids ...int64) *ViewUpdateOne { + _u.mutation.RemoveChildIDs(ids...) + return _u +} + +// RemoveChildren removes "children" edges to View entities. +func (_u *ViewUpdateOne) RemoveChildren(v ...*View) *ViewUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChildIDs(ids...) +} + +// ClearResources clears all "resources" edges to the Resource entity. +func (_u *ViewUpdateOne) ClearResources() *ViewUpdateOne { + _u.mutation.ClearResources() + return _u +} + +// RemoveResourceIDs removes the "resources" edge to Resource entities by IDs. +func (_u *ViewUpdateOne) RemoveResourceIDs(ids ...int64) *ViewUpdateOne { + _u.mutation.RemoveResourceIDs(ids...) + return _u +} + +// RemoveResources removes "resources" edges to Resource entities. +func (_u *ViewUpdateOne) RemoveResources(v ...*Resource) *ViewUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveResourceIDs(ids...) +} + +// ClearPermissions clears all "permissions" edges to the Permission entity. +func (_u *ViewUpdateOne) ClearPermissions() *ViewUpdateOne { + _u.mutation.ClearPermissions() + return _u +} + +// RemovePermissionIDs removes the "permissions" edge to Permission entities by IDs. +func (_u *ViewUpdateOne) RemovePermissionIDs(ids ...int64) *ViewUpdateOne { + _u.mutation.RemovePermissionIDs(ids...) + return _u +} + +// RemovePermissions removes "permissions" edges to Permission entities. +func (_u *ViewUpdateOne) RemovePermissions(v ...*Permission) *ViewUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemovePermissionIDs(ids...) +} + +// Where appends a list predicates to the ViewUpdate builder. +func (_u *ViewUpdateOne) Where(ps ...predicate.View) *ViewUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *ViewUpdateOne) Select(field string, fields ...string) *ViewUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated View entity. +func (_u *ViewUpdateOne) Save(ctx context.Context) (*View, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ViewUpdateOne) SaveX(ctx context.Context) *View { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *ViewUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ViewUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ViewUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := view.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ViewUpdateOne) check() error { + if v, ok := _u.mutation.ParentID(); ok { + if err := view.ParentIDValidator(v); err != nil { + return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "View.parent_id": %w`, err)} + } + } + if v, ok := _u.mutation.Keyword(); ok { + if err := view.KeywordValidator(v); err != nil { + return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "View.keyword": %w`, err)} + } + } + if v, ok := _u.mutation.GetType(); ok { + if err := view.TypeValidator(v); err != nil { + return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "View.type": %w`, err)} + } + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ViewUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ViewUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(view.Table, view.Columns, sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "View.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, view.FieldID) + for _, f := range fields { + if !view.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != view.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(view.FieldUpdateTime, field.TypeTime, value) + } + if value, ok := _u.mutation.Keyword(); ok { + _spec.SetField(view.FieldKeyword, field.TypeString, value) + } + if value, ok := _u.mutation.Scope(); ok { + _spec.SetField(view.FieldScope, field.TypeString, value) + } + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(view.FieldName, field.TypeString, value) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(view.FieldType, field.TypeString, value) + } + if value, ok := _u.mutation.Component(); ok { + _spec.SetField(view.FieldComponent, field.TypeString, value) + } + if _u.mutation.ComponentCleared() { + _spec.ClearField(view.FieldComponent, field.TypeString) + } + if value, ok := _u.mutation.Path(); ok { + _spec.SetField(view.FieldPath, field.TypeString, value) + } + if _u.mutation.PathCleared() { + _spec.ClearField(view.FieldPath, field.TypeString) + } + if value, ok := _u.mutation.Icon(); ok { + _spec.SetField(view.FieldIcon, field.TypeString, value) + } + if _u.mutation.IconCleared() { + _spec.ClearField(view.FieldIcon, field.TypeString) + } + if value, ok := _u.mutation.Visible(); ok { + _spec.SetField(view.FieldVisible, field.TypeBool, value) + } + if value, ok := _u.mutation.Sequence(); ok { + _spec.SetField(view.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSequence(); ok { + _spec.AddField(view.FieldSequence, field.TypeInt, value) + } + if _u.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: view.ParentTable, + Columns: []string{view.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: view.ParentTable, + Columns: []string{view.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: view.ChildrenTable, + Columns: []string{view.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: view.ChildrenTable, + Columns: []string{view.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: view.ChildrenTable, + Columns: []string{view.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.ResourcesTable, + Columns: view.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !_u.mutation.ResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.ResourcesTable, + Columns: view.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.ResourcesTable, + Columns: view.ResourcesPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.PermissionsTable, + Columns: view.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.PermissionsTable, + Columns: view.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2M, + Inverse: true, + Table: view.PermissionsTable, + Columns: view.PermissionsPrimaryKey, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &View{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{view.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} + +// SetView set the View +func (vu *ViewUpdate) SetView(input *View, fields ...string) *ViewUpdate { + m := vu.mutation + if len(fields) == 0 { + fields = view.OmitColumns(view.FieldID) + } + _ = m.SetFields(input, fields...) + return vu +} + +// SetViewWithZero set the View +func (vu *ViewUpdate) SetViewWithZero(input *View, fields ...string) *ViewUpdate { + m := vu.mutation + if len(fields) == 0 { + fields = view.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return vu +} + +// SetView set the View +func (vuo *ViewUpdateOne) SetView(input *View, fields ...string) *ViewUpdateOne { + m := vuo.mutation + if len(fields) == 0 { + fields = view.OmitColumns(view.FieldID) + } + _ = m.SetFields(input, fields...) + return vuo +} + +// SetViewWithZero set the View +func (vuo *ViewUpdateOne) SetViewWithZero(input *View, fields ...string) *ViewUpdateOne { + m := vuo.mutation + if len(fields) == 0 { + fields = view.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return vuo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (vuo *ViewUpdateOne) Omit(fields ...string) *ViewUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + vuo.fields = []string(nil) + for _, col := range view.Columns { + if _, ok := omits[col]; !ok { + vuo.fields = append(vuo.fields, col) + } + } + return vuo +} diff --git a/internal/helpers/ent/mixin/soft_delete.go b/internal/helpers/ent/mixin/soft_delete.go new file mode 100644 index 00000000..ff6ebaf4 --- /dev/null +++ b/internal/helpers/ent/mixin/soft_delete.go @@ -0,0 +1,103 @@ +package mixin + +import ( + "context" + "errors" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/schema/field" + "entgo.io/ent/schema/mixin" +) + +// SoftDeleteMixin implements the soft-delete pattern for a schema. +type SoftDeleteMixin struct { + mixin.Schema +} + +// Fields of the SoftDeleteMixin. +func (SoftDeleteMixin) Fields() []ent.Field { + return []ent.Field{ + field.Time("delete_time"). + Comment("Time of soft-delete"). + Optional(). + Nillable(), + } +} + +// Hooks of the SoftDeleteMixin. +func (SoftDeleteMixin) Hooks() []ent.Hook { + return []ent.Hook{ + softDeleteHook(), + } +} + +// Interceptors of the SoftDeleteMixin. +func (SoftDeleteMixin) Interceptors() []ent.Interceptor { + return []ent.Interceptor{ + softDeleteInterceptor(), + } +} + +// softDeleteHook intercepts DELETE operations and converts them to UPDATEs. +func softDeleteHook() ent.Hook { + // Define an interface for mutations that support soft-delete. + // This relies on structural typing and code generation. + type softDeleter interface { + SetOp(ent.Op) + SetDeleteTime(time.Time) + } + + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + // Skip if not a DELETE operation or if soft-delete is skipped. + if !m.Op().Is(ent.OpDelete|ent.OpDeleteOne) || IsSkipSoftDelete(ctx) { + return next.Mutate(ctx, m) + } + + // Check if the mutation implements the softDeleter interface. + mx, ok := m.(softDeleter) + if !ok { + return nil, errors.New("ent: mutation does not support soft-delete") + } + + // Change the operation to UPDATE and set the delete_time. + mx.SetOp(ent.OpUpdate) + mx.SetDeleteTime(time.Now()) + + // Proceed with the mutation, which is now an update. + return next.Mutate(ctx, m) + }) + } +} + +// softDeleteInterceptor filters out soft-deleted records from queries. +func softDeleteInterceptor() ent.Interceptor { + // Define an interface for queries that support WhereP. + type queryWither interface { + WhereP(...func(*sql.Selector)) + } + + return ent.InterceptFunc(func(next ent.Querier) ent.Querier { + return ent.QuerierFunc(func(ctx context.Context, query ent.Query) (ent.Value, error) { + // Skip if soft-delete is skipped for this query. + if IsSkipSoftDelete(ctx) { + return next.Query(ctx, query) + } + + // Check if the query supports the WhereP method. + q, ok := query.(queryWither) + if !ok { + return next.Query(ctx, query) + } + + // Add the WHERE clause to filter out soft-deleted records. + q.WhereP(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C("delete_time"))) + }) + + return next.Query(ctx, query) + }) + }) +} From f0815737551c0b5e45e1546bfbdb0f5230b38d3f Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 05:26:43 +0800 Subject: [PATCH 081/158] feat(dto): refactor resource conversion and add status conversion stubs --- internal/features/system/dto/custom.gen.go | 18 +++++++++ internal/features/system/dto/dto.gen.go | 47 ++++++---------------- internal/features/system/dto/dto.go | 2 +- 3 files changed, 32 insertions(+), 35 deletions(-) diff --git a/internal/features/system/dto/custom.gen.go b/internal/features/system/dto/custom.gen.go index 263fb2d7..afd154bd 100644 --- a/internal/features/system/dto/custom.gen.go +++ b/internal/features/system/dto/custom.gen.go @@ -2,3 +2,21 @@ // More info: https://github.com/origadmin/abgen package dto + +import ( + "origadmin/application/admin/internal/data/entity/ent/resource" +) + +// ConvertInt32ToStatus is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertInt32ToStatus(from int32) resource.Status { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertStatusToInt32 is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStatusToInt32(from resource.Status) int32 { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index 9f2fb69b..4c75ada8 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -2,7 +2,7 @@ // Code generated by abgen. DO NOT EDIT. // versions: v0.0.1 -// source: D:\workspace\project\golang\origadmin\framework\projects\backend\internal\features\system\dto +// source: . package dto @@ -92,6 +92,9 @@ type ( UserRolesPB = []*types.UserRole Users = []*ent.User UsersPB = []*types.User + View = ent.View + ViewEdges = ent.ViewEdges + Views = []*ent.View ) // ConvertDepartmentEdgesPBToDepartmentEdges converts DepartmentEdgesPB to DepartmentEdges. @@ -568,25 +571,14 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { } to := &Resource{ - ID: from.Id, - CreateTime: ConvertTimestampToTime(from.CreateTime), - UpdateTime: ConvertTimestampToTime(from.UpdateTime), - Name: from.Name, - Keyword: from.Keyword, - I18nKey: from.I18NKey, - Type: from.Type, - Status: int8(from.Status), - Path: from.Path, - Operation: from.Operation, - Method: from.Method, - Component: from.Component, - Icon: from.Icon, - Sequence: int(from.Sequence), - Visible: from.Visible, - TreePath: from.TreePath, - Properties: from.Properties, - Description: from.Description, - ParentID: from.ParentId, + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Path: from.Path, + Method: from.Method, + Operation: from.Operation, + Status: ConvertInt32ToStatus(from.Status), } return to } @@ -601,24 +593,11 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { Id: from.ID, CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), - Name: from.Name, Keyword: from.Keyword, - I18NKey: from.I18nKey, - Type: from.Type, - Status: int32(from.Status), + Status: ConvertStatusToInt32(from.Status), Path: from.Path, Operation: from.Operation, Method: from.Method, - Component: from.Component, - Icon: from.Icon, - Sequence: int32(from.Sequence), - Visible: from.Visible, - TreePath: from.TreePath, - Properties: from.Properties, - Description: from.Description, - ParentId: from.ParentID, - Children: ConvertResourcesToResourcesPB(from.Edges.Children), - Parent: ConvertResourceToResourcePB(from.Edges.Parent), Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), } return to diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index 8ab9efd6..90117e48 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -4,7 +4,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/user" ) -//go:generate go run github.com/origadmin/abgen/cmd/abgen -debug go run ./cmd/abgen -debug . +//go:generate abgen -debug . //go:abgen:package:path=origadmin/application/admin/internal/data/entity/ent,alias=ent //go:abgen:package:path=origadmin/application/admin/api/v1/services/types,alias=types From 03aad06040770de6d15aee2d839427168cb5a098 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 05:31:44 +0800 Subject: [PATCH 082/158] refactor(system): replace Menu entity with View entity and remove deprecated menu.proto --- api/v1/proto/system/menu.proto | 2 - api/v1/proto/types/system.proto | 58 +- api/v1/services/auth/auth.pb.go | 4 +- api/v1/services/system/menu.pb.go | 741 --------- api/v1/services/system/menu.pb.gw.go | 459 ------ api/v1/services/system/menu.pb.validate.go | 1321 ----------------- api/v1/services/system/menu_bridge.pb.go | 392 ----- api/v1/services/system/menu_grpc.pb.go | 277 ---- api/v1/services/system/menu_http.pb.go | 234 --- api/v1/services/system/resource.pb.go | 154 +- api/v1/services/system/resource.pb.gw.go | 14 - .../services/system/resource.pb.validate.go | 8 +- api/v1/services/system/resource_bridge.pb.go | 5 + api/v1/services/system/resource_grpc.pb.go | 18 + api/v1/services/system/resource_http.pb.go | 15 + api/v1/services/types/system.pb.go | 290 ++-- api/v1/services/types/system.pb.validate.go | 356 ++--- internal/features/system/biz/provider.go | 1 + internal/features/system/dal/provider.go | 2 +- internal/features/system/service/service.go | 4 + resources/api-docs/openapi/openapi.yaml | 722 +++++---- 21 files changed, 805 insertions(+), 4272 deletions(-) delete mode 100644 api/v1/proto/system/menu.proto delete mode 100644 api/v1/services/system/menu.pb.go delete mode 100644 api/v1/services/system/menu.pb.gw.go delete mode 100644 api/v1/services/system/menu.pb.validate.go delete mode 100644 api/v1/services/system/menu_bridge.pb.go delete mode 100644 api/v1/services/system/menu_grpc.pb.go delete mode 100644 api/v1/services/system/menu_http.pb.go diff --git a/api/v1/proto/system/menu.proto b/api/v1/proto/system/menu.proto deleted file mode 100644 index 3f7f1142..00000000 --- a/api/v1/proto/system/menu.proto +++ /dev/null @@ -1,2 +0,0 @@ -// This file is intentionally left empty and is pending deletion. -// The 'Menu' concept has been fully replaced by the more generic 'View' entity. diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index d2d0fc75..edc0ca6a 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -10,8 +10,8 @@ option java_outer_classname = "APIServiceTypeSystemProto"; option java_package = "com.origadmin.api.v1.services.types"; option objc_class_prefix = "APIServiceType"; -// Menu is the model entity for the Menu schema. -message Menu { +// View is the model entity for the View schema. +message View { // ID of the ent. int64 id = 1 [json_name = "id"]; // CreateTime holds the value of the "create_time" field. @@ -43,27 +43,27 @@ message Menu { // ParentPath holds the value of the "parent_path" field. string parent_path = 15 [json_name = "parent_path"]; // Children holds the value of the children edge. - repeated Menu children = 21 [json_name = "children"]; + repeated View children = 21 [json_name = "children"]; // Parent holds the value of the parent edge. - Menu parent = 22 [json_name = "parent"]; + View parent = 22 [json_name = "parent"]; // Resources holds the value of the resources edge. repeated Resource resources = 23 [json_name = "resources"]; // Roles holds the value of the roles edge. repeated Role roles = 24 [json_name = "roles"]; } -// MenuEdges holds the relations/edges for other nodes in the graph. -message MenuEdges { +// ViewEdges holds the relations/edges for other nodes in the graph. +message ViewEdges { // Children holds the value of the children edge. - repeated Menu children = 1 [json_name = "children"]; + repeated View children = 1 [json_name = "children"]; // Parent holds the value of the parent edge. - Menu parent = 2 [json_name = "parent"]; + View parent = 2 [json_name = "parent"]; // Resources holds the value of the resources edge. repeated Resource resources = 3 [json_name = "resources"]; // Roles holds the value of the roles edge. repeated Role roles = 4 [json_name = "roles"]; - // RoleMenu holds the value of the role_menu edge. - repeated RoleMenu role_menus = 5 [json_name = "role_menus"]; + // RoleView holds the value of the role_view edge. + repeated RoleView role_views = 5 [json_name = "role_views"]; } // Role is the model entity for the Role schema. @@ -89,8 +89,8 @@ message Role { int32 status = 9 [json_name = "status"]; // role.field.is_types bool is_types = 10 [json_name = "is_types"]; - // Menus holds the value of the menus edge. - repeated Menu menus = 21 [json_name = "menus"]; + // Views holds the value of the views edge. + repeated View views = 21 [json_name = "views"]; // Users holds the value of the users edge. repeated User users = 22 [json_name = "users"]; // Resources holds the value of the resources edge. @@ -105,12 +105,12 @@ message Role { // RoleEdges holds the relations/edges for other nodes in the graph. message RoleEdges { - // Menus holds the value of the menus edge. - repeated Menu menus = 1 [json_name = "menus"]; + // Views holds the value of the views edge. + repeated View views = 1 [json_name = "views"]; // Users holds the value of the users edge. repeated User users = 2 [json_name = "users"]; - // RoleMenu holds the value of the role_menu edge. - repeated RoleMenu role_menus = 3 [json_name = "role_menus"]; + // RoleView holds the value of the role_view edge. + repeated RoleView role_views = 3 [json_name = "role_views"]; // UserRole holds the value of the user_role edge. repeated UserRole user_roles = 4 [json_name = "user_roles"]; } @@ -204,8 +204,8 @@ message UserRoleEdges { Role role = 2 [json_name = "role"]; } -// RoleMenu is the model entity for the RoleMenu schema. -message RoleMenu { +// RoleView is the model entity for the RoleView schema. +message RoleView { // ID of the ent. int64 id = 1 [json_name = "id"]; // CreateTime holds the value of the "create_time" field. @@ -214,20 +214,20 @@ message RoleMenu { google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; // RoleID holds the value of the "role_id" field. int64 role_id = 4 [json_name = "role_id"]; - // MenuID holds the value of the "menu_id" field. - int64 menu_id = 5 [json_name = "menu_id"]; + // ViewID holds the value of the "view_id" field. + int64 view_id = 5 [json_name = "view_id"]; // Role holds the value of the role edge. Role role = 21 [json_name = "role"]; - // Menu holds the value of the menu edge. - Menu menu = 22 [json_name = "menu"]; + // View holds the value of the view edge. + View view = 22 [json_name = "view"]; } -// RoleMenuEdges holds the relations/edges for other nodes in the graph. -message RoleMenuEdges { +// RoleViewEdges holds the relations/edges for other nodes in the graph. +message RoleViewEdges { // Role holds the value of the role edge. Role role = 1 [json_name = "role"]; - // Menu holds the value of the menu edge. - Menu menu = 2 [json_name = "menu"]; + // View holds the value of the view edge. + View view = 2 [json_name = "view"]; } // Resource is the model entity for the Resource schema. @@ -283,8 +283,8 @@ message Resource { // ResourceEdges holds the relations/edges for other nodes in the graph. message ResourceEdges { - // Menu holds the value of the menu edge. - Menu menu = 1 [json_name = "menu"]; + // View holds the value of the view edge. + View view = 1 [json_name = "view"]; } // department.table.comment @@ -300,7 +300,7 @@ message Department { string keyword = 4 [json_name = "keyword"]; // department.field.name string name = 5 [json_name = "name"]; - // menu.field.tree_path + // department.field.tree_path string tree_path = 6 [json_name = "tree_path"]; // department.field.sequence int32 sequence = 7 [json_name = "sequence"]; diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index e5c2c744..83329dbe 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -864,7 +864,7 @@ const file_auth_auth_proto_rawDesc = "" + "\x06method\x18\x04 \x01(\tR\x06method\x12\x1c\n" + "\toperation\x18\x05 \x01(\tR\toperation\"2\n" + "\x14AuthenticateResponse\x12\x1a\n" + - "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xbb\x06\n" + + "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xab\x06\n" + "\vAuthService\x12\x8d\x01\n" + "\x11ListAuthResources\x12..api.v1.services.auth.ListAuthResourcesRequest\x1a/.api.v1.services.auth.ListAuthResourcesResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/auth/resources\x12}\n" + "\vCreateToken\x12(.api.v1.services.auth.CreateTokenRequest\x1a).api.v1.services.auth.CreateTokenResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x04data\"\v/auth/token\x12\x80\x01\n" + @@ -872,7 +872,7 @@ const file_auth_auth_proto_rawDesc = "" + "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x04data\"\r/auth/destroy\x12\x87\x01\n" + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\" \x82\xd3\xe4\x93\x02\x1a:\x04data\"\x12/auth/authenticate\x12{\n" + "\n" + - "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x04data\"\f/auth/logout\x1a\x0e\xcaA\vapi.foo.comB\xd0\x01\n" + + "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x04data\"\f/auth/logoutB\xd0\x01\n" + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( diff --git a/api/v1/services/system/menu.pb.go b/api/v1/services/system/menu.pb.go deleted file mode 100644 index e194fe21..00000000 --- a/api/v1/services/system/menu.pb.go +++ /dev/null @@ -1,741 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: system/menu.proto - -package system - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// ListMenusRequest is the request for the MenuService.ListMenus method. -type ListMenusRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The page number. - Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - // The keyword is the query parameter for set only to query the menu by keyword - Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListMenusRequest) Reset() { - *x = ListMenusRequest{} - mi := &file_system_menu_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListMenusRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListMenusRequest) ProtoMessage() {} - -func (x *ListMenusRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[0] - 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 ListMenusRequest.ProtoReflect.Descriptor instead. -func (*ListMenusRequest) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{0} -} - -func (x *ListMenusRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListMenusRequest) GetPage() int32 { - if x != nil { - return x.Page - } - return 0 -} - -func (x *ListMenusRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListMenusRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListMenusRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListMenusRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -func (x *ListMenusRequest) GetKeyword() string { - if x != nil { - return x.Keyword - } - return "" -} - -// ListMenusResponse is the response for the MenuService.ListMenus method. -type ListMenusResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` - // The paging menus - Menus []*types.Menu `protobuf:"bytes,2,rep,name=menus,proto3" json:"menus,omitempty"` - // The page number. - Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the page data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListMenusResponse) Reset() { - *x = ListMenusResponse{} - mi := &file_system_menu_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListMenusResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListMenusResponse) ProtoMessage() {} - -func (x *ListMenusResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[1] - 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 ListMenusResponse.ProtoReflect.Descriptor instead. -func (*ListMenusResponse) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{1} -} - -func (x *ListMenusResponse) GetTotal() int32 { - if x != nil { - return x.Total - } - return 0 -} - -func (x *ListMenusResponse) GetMenus() []*types.Menu { - if x != nil { - return x.Menus - } - return nil -} - -func (x *ListMenusResponse) GetPage() int32 { - if x != nil { - return x.Page - } - return 0 -} - -func (x *ListMenusResponse) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListMenusResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -func (x *ListMenusResponse) GetExtra() *anypb.Any { - if x != nil { - return x.Extra - } - return nil -} - -// GetMenuRequest is the request for the MenuService.GetMenu method. -type GetMenuRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/menus/menu2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetMenuRequest) Reset() { - *x = GetMenuRequest{} - mi := &file_system_menu_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetMenuRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetMenuRequest) ProtoMessage() {} - -func (x *GetMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[2] - 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 GetMenuRequest.ProtoReflect.Descriptor instead. -func (*GetMenuRequest) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{2} -} - -func (x *GetMenuRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -// GetMenuResponse is the response for the MenuService.GetMenu method. -type GetMenuResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field id should match the Noun in the method id. - Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetMenuResponse) Reset() { - *x = GetMenuResponse{} - mi := &file_system_menu_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetMenuResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetMenuResponse) ProtoMessage() {} - -func (x *GetMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[3] - 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 GetMenuResponse.ProtoReflect.Descriptor instead. -func (*GetMenuResponse) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{3} -} - -func (x *GetMenuResponse) GetMenu() *types.Menu { - if x != nil { - return x.Menu - } - return nil -} - -// CreateMenuRequest is the request for the MenuService.CreateMenu method. -type CreateMenuRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id where the menu is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The menu id to use for this menu. - MenuId string `protobuf:"bytes,3,opt,name=menu_id,json=menuId,proto3" json:"menu_id,omitempty"` - // The menu resource to create. - // The field id should match the Noun in the method id. - Menu *types.Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateMenuRequest) Reset() { - *x = CreateMenuRequest{} - mi := &file_system_menu_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateMenuRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateMenuRequest) ProtoMessage() {} - -func (x *CreateMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[4] - 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 CreateMenuRequest.ProtoReflect.Descriptor instead. -func (*CreateMenuRequest) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{4} -} - -func (x *CreateMenuRequest) GetParent() string { - if x != nil { - return x.Parent - } - return "" -} - -func (x *CreateMenuRequest) GetMenuId() string { - if x != nil { - return x.MenuId - } - return "" -} - -func (x *CreateMenuRequest) GetMenu() *types.Menu { - if x != nil { - return x.Menu - } - return nil -} - -// CreateMenuResponse is the response for the MenuService.CreateMenu method. -type CreateMenuResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateMenuResponse) Reset() { - *x = CreateMenuResponse{} - mi := &file_system_menu_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateMenuResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateMenuResponse) ProtoMessage() {} - -func (x *CreateMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[5] - 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 CreateMenuResponse.ProtoReflect.Descriptor instead. -func (*CreateMenuResponse) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{5} -} - -func (x *CreateMenuResponse) GetMenu() *types.Menu { - if x != nil { - return x.Menu - } - return nil -} - -// UpdateMenuRequest is the request for the MenuService.UpdateMenu method. -type UpdateMenuRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The menu resource which replaces the resource on the server. - Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateMenuRequest) Reset() { - *x = UpdateMenuRequest{} - mi := &file_system_menu_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateMenuRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateMenuRequest) ProtoMessage() {} - -func (x *UpdateMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_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 UpdateMenuRequest.ProtoReflect.Descriptor instead. -func (*UpdateMenuRequest) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdateMenuRequest) GetMenu() *types.Menu { - if x != nil { - return x.Menu - } - return nil -} - -// UpdateMenuResponse is the response for the MenuService.UpdateMenu method. -type UpdateMenuResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Menu *types.Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdateMenuResponse) Reset() { - *x = UpdateMenuResponse{} - mi := &file_system_menu_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdateMenuResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdateMenuResponse) ProtoMessage() {} - -func (x *UpdateMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdateMenuResponse.ProtoReflect.Descriptor instead. -func (*UpdateMenuResponse) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{7} -} - -func (x *UpdateMenuResponse) GetMenu() *types.Menu { - if x != nil { - return x.Menu - } - return nil -} - -// DeleteMenuRequest is the request for the MenuService.DeleteMenu method. -type DeleteMenuRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The resource id of the menu to be deleted, for example: - // "shelves/shelf1/menus/menu2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteMenuRequest) Reset() { - *x = DeleteMenuRequest{} - mi := &file_system_menu_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteMenuRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteMenuRequest) ProtoMessage() {} - -func (x *DeleteMenuRequest) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[8] - 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 DeleteMenuRequest.ProtoReflect.Descriptor instead. -func (*DeleteMenuRequest) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{8} -} - -func (x *DeleteMenuRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -// DeleteMenuResponse is the response for the MenuService.DeleteMenu method. -type DeleteMenuResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // or Menu menu = 1; or google.protobuf.Empty empty = 1; - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DeleteMenuResponse) Reset() { - *x = DeleteMenuResponse{} - mi := &file_system_menu_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DeleteMenuResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteMenuResponse) ProtoMessage() {} - -func (x *DeleteMenuResponse) ProtoReflect() protoreflect.Message { - mi := &file_system_menu_proto_msgTypes[9] - 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 DeleteMenuResponse.ProtoReflect.Descriptor instead. -func (*DeleteMenuResponse) Descriptor() ([]byte, []int) { - return file_system_menu_proto_rawDescGZIP(), []int{9} -} - -func (x *DeleteMenuResponse) GetEmpty() *emptypb.Empty { - if x != nil { - return x.Empty - } - return nil -} - -var File_system_menu_proto protoreflect.FileDescriptor - -const file_system_menu_proto_rawDesc = "" + - "\n" + - "\x11system/menu.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xcc\x01\n" + - "\x10ListMenusRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + - "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\x12\x18\n" + - "\akeyword\x18\a \x01(\tR\akeyword\"\xf3\x01\n" + - "\x11ListMenusResponse\x12\x14\n" + - "\x05total\x18\x01 \x01(\x05R\x05total\x121\n" + - "\x05menus\x18\x02 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x12\x12\n" + - "\x04page\x18\x03 \x01(\x05R\x04page\x12\x1c\n" + - "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + - "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + - "\x06_extra\" \n" + - "\x0eGetMenuRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + - "\x0fGetMenuResponse\x12/\n" + - "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"u\n" + - "\x11CreateMenuRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x17\n" + - "\amenu_id\x18\x03 \x01(\tR\x06menuId\x12/\n" + - "\x04menu\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"E\n" + - "\x12CreateMenuResponse\x12/\n" + - "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"D\n" + - "\x11UpdateMenuRequest\x12/\n" + - "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"E\n" + - "\x12UpdateMenuResponse\x12/\n" + - "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"#\n" + - "\x11DeleteMenuRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + - "\x12DeleteMenuResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xfc\x04\n" + - "\vMenuService\x12t\n" + - "\tListMenus\x12(.api.v1.services.system.ListMenusRequest\x1a).api.v1.services.system.ListMenusResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + - "/sys/menus\x12s\n" + - "\aGetMenu\x12&.api.v1.services.system.GetMenuRequest\x1a'.api.v1.services.system.GetMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/menus/{id}\x12z\n" + - "\n" + - "CreateMenu\x12).api.v1.services.system.CreateMenuRequest\x1a*.api.v1.services.system.CreateMenuResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + - "/sys/menus\x12\x87\x01\n" + - "\n" + - "UpdateMenu\x12).api.v1.services.system.UpdateMenuRequest\x1a*.api.v1.services.system.UpdateMenuResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04menu\x1a\x14/sys/menus/{menu.id}\x12|\n" + - "\n" + - "DeleteMenu\x12).api.v1.services.system.DeleteMenuRequest\x1a*.api.v1.services.system.DeleteMenuResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/menus/{id}B\xde\x01\n" + - "\x1acom.api.v1.services.systemB\tMenuProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" - -var ( - file_system_menu_proto_rawDescOnce sync.Once - file_system_menu_proto_rawDescData []byte -) - -func file_system_menu_proto_rawDescGZIP() []byte { - file_system_menu_proto_rawDescOnce.Do(func() { - file_system_menu_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_menu_proto_rawDesc), len(file_system_menu_proto_rawDesc))) - }) - return file_system_menu_proto_rawDescData -} - -var file_system_menu_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_system_menu_proto_goTypes = []any{ - (*ListMenusRequest)(nil), // 0: api.v1.services.system.ListMenusRequest - (*ListMenusResponse)(nil), // 1: api.v1.services.system.ListMenusResponse - (*GetMenuRequest)(nil), // 2: api.v1.services.system.GetMenuRequest - (*GetMenuResponse)(nil), // 3: api.v1.services.system.GetMenuResponse - (*CreateMenuRequest)(nil), // 4: api.v1.services.system.CreateMenuRequest - (*CreateMenuResponse)(nil), // 5: api.v1.services.system.CreateMenuResponse - (*UpdateMenuRequest)(nil), // 6: api.v1.services.system.UpdateMenuRequest - (*UpdateMenuResponse)(nil), // 7: api.v1.services.system.UpdateMenuResponse - (*DeleteMenuRequest)(nil), // 8: api.v1.services.system.DeleteMenuRequest - (*DeleteMenuResponse)(nil), // 9: api.v1.services.system.DeleteMenuResponse - (*types.Menu)(nil), // 10: api.v1.services.types.Menu - (*anypb.Any)(nil), // 11: google.protobuf.Any - (*emptypb.Empty)(nil), // 12: google.protobuf.Empty -} -var file_system_menu_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.system.ListMenusResponse.menus:type_name -> api.v1.services.types.Menu - 11, // 1: api.v1.services.system.ListMenusResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.system.GetMenuResponse.menu:type_name -> api.v1.services.types.Menu - 10, // 3: api.v1.services.system.CreateMenuRequest.menu:type_name -> api.v1.services.types.Menu - 10, // 4: api.v1.services.system.CreateMenuResponse.menu:type_name -> api.v1.services.types.Menu - 10, // 5: api.v1.services.system.UpdateMenuRequest.menu:type_name -> api.v1.services.types.Menu - 10, // 6: api.v1.services.system.UpdateMenuResponse.menu:type_name -> api.v1.services.types.Menu - 12, // 7: api.v1.services.system.DeleteMenuResponse.empty:type_name -> google.protobuf.Empty - 0, // 8: api.v1.services.system.MenuService.ListMenus:input_type -> api.v1.services.system.ListMenusRequest - 2, // 9: api.v1.services.system.MenuService.GetMenu:input_type -> api.v1.services.system.GetMenuRequest - 4, // 10: api.v1.services.system.MenuService.CreateMenu:input_type -> api.v1.services.system.CreateMenuRequest - 6, // 11: api.v1.services.system.MenuService.UpdateMenu:input_type -> api.v1.services.system.UpdateMenuRequest - 8, // 12: api.v1.services.system.MenuService.DeleteMenu:input_type -> api.v1.services.system.DeleteMenuRequest - 1, // 13: api.v1.services.system.MenuService.ListMenus:output_type -> api.v1.services.system.ListMenusResponse - 3, // 14: api.v1.services.system.MenuService.GetMenu:output_type -> api.v1.services.system.GetMenuResponse - 5, // 15: api.v1.services.system.MenuService.CreateMenu:output_type -> api.v1.services.system.CreateMenuResponse - 7, // 16: api.v1.services.system.MenuService.UpdateMenu:output_type -> api.v1.services.system.UpdateMenuResponse - 9, // 17: api.v1.services.system.MenuService.DeleteMenu:output_type -> api.v1.services.system.DeleteMenuResponse - 13, // [13:18] is the sub-list for method output_type - 8, // [8:13] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name -} - -func init() { file_system_menu_proto_init() } -func file_system_menu_proto_init() { - if File_system_menu_proto != nil { - return - } - file_system_menu_proto_msgTypes[1].OneofWrappers = []any{} - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_menu_proto_rawDesc), len(file_system_menu_proto_rawDesc)), - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_system_menu_proto_goTypes, - DependencyIndexes: file_system_menu_proto_depIdxs, - MessageInfos: file_system_menu_proto_msgTypes, - }.Build() - File_system_menu_proto = out.File - file_system_menu_proto_goTypes = nil - file_system_menu_proto_depIdxs = nil -} diff --git a/api/v1/services/system/menu.pb.gw.go b/api/v1/services/system/menu.pb.gw.go deleted file mode 100644 index e3fd0ee7..00000000 --- a/api/v1/services/system/menu.pb.gw.go +++ /dev/null @@ -1,459 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: system/menu.proto - -/* -Package system is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package system - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_MenuService_ListMenus_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_MenuService_ListMenus_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListMenusRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_ListMenus_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListMenus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_MenuService_ListMenus_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListMenusRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MenuService_ListMenus_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListMenus(ctx, &protoReq) - return msg, metadata, err -} - -func request_MenuService_GetMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetMenuRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_MenuService_GetMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetMenuRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetMenu(ctx, &protoReq) - return msg, metadata, err -} - -func request_MenuService_CreateMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateMenuRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreateMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_MenuService_CreateMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CreateMenuRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreateMenu(ctx, &protoReq) - return msg, metadata, err -} - -func request_MenuService_UpdateMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateMenuRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["menu.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "menu.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "menu.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "menu.id", err) - } - msg, err := client.UpdateMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_MenuService_UpdateMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdateMenuRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Menu); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["menu.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "menu.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "menu.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "menu.id", err) - } - msg, err := server.UpdateMenu(ctx, &protoReq) - return msg, metadata, err -} - -func request_MenuService_DeleteMenu_0(ctx context.Context, marshaler runtime.Marshaler, client MenuServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteMenuRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.DeleteMenu(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_MenuService_DeleteMenu_0(ctx context.Context, marshaler runtime.Marshaler, server MenuServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq DeleteMenuRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.DeleteMenu(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterMenuServiceHandlerServer registers the http handlers for service MenuService to "mux". -// UnaryRPC :call MenuServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMenuServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterMenuServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MenuServiceServer) error { - mux.Handle(http.MethodGet, pattern_MenuService_ListMenus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/ListMenus", runtime.WithHTTPPathPattern("/sys/menus")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_MenuService_ListMenus_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_ListMenus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_MenuService_GetMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/GetMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_MenuService_GetMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_GetMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_MenuService_CreateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/CreateMenu", runtime.WithHTTPPathPattern("/sys/menus")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_MenuService_CreateMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_CreateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_MenuService_UpdateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/UpdateMenu", runtime.WithHTTPPathPattern("/sys/menus/{menu.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_MenuService_UpdateMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_UpdateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_MenuService_DeleteMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.MenuService/DeleteMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_MenuService_DeleteMenu_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_DeleteMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterMenuServiceHandlerFromEndpoint is same as RegisterMenuServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMenuServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterMenuServiceHandler(ctx, mux, conn) -} - -// RegisterMenuServiceHandler registers the http handlers for service MenuService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterMenuServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMenuServiceHandlerClient(ctx, mux, NewMenuServiceClient(conn)) -} - -// RegisterMenuServiceHandlerClient registers the http handlers for service MenuService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MenuServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MenuServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MenuServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterMenuServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MenuServiceClient) error { - mux.Handle(http.MethodGet, pattern_MenuService_ListMenus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/ListMenus", runtime.WithHTTPPathPattern("/sys/menus")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_MenuService_ListMenus_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_ListMenus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_MenuService_GetMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/GetMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_MenuService_GetMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_GetMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_MenuService_CreateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/CreateMenu", runtime.WithHTTPPathPattern("/sys/menus")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_MenuService_CreateMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_CreateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_MenuService_UpdateMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/UpdateMenu", runtime.WithHTTPPathPattern("/sys/menus/{menu.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_MenuService_UpdateMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_UpdateMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_MenuService_DeleteMenu_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.MenuService/DeleteMenu", runtime.WithHTTPPathPattern("/sys/menus/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_MenuService_DeleteMenu_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_MenuService_DeleteMenu_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_MenuService_ListMenus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "menus"}, "")) - pattern_MenuService_GetMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "menus", "id"}, "")) - pattern_MenuService_CreateMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "menus"}, "")) - pattern_MenuService_UpdateMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "menus", "menu.id"}, "")) - pattern_MenuService_DeleteMenu_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "menus", "id"}, "")) -) - -var ( - forward_MenuService_ListMenus_0 = runtime.ForwardResponseMessage - forward_MenuService_GetMenu_0 = runtime.ForwardResponseMessage - forward_MenuService_CreateMenu_0 = runtime.ForwardResponseMessage - forward_MenuService_UpdateMenu_0 = runtime.ForwardResponseMessage - forward_MenuService_DeleteMenu_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/system/menu.pb.validate.go b/api/v1/services/system/menu.pb.validate.go deleted file mode 100644 index 45670aa2..00000000 --- a/api/v1/services/system/menu.pb.validate.go +++ /dev/null @@ -1,1321 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: system/menu.proto - -package system - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on ListMenusRequest 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 *ListMenusRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListMenusRequest 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 -// ListMenusRequestMultiError, or nil if none found. -func (m *ListMenusRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListMenusRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Page - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - // no validation rules for Keyword - - if len(errors) > 0 { - return ListMenusRequestMultiError(errors) - } - - return nil -} - -// ListMenusRequestMultiError is an error wrapping multiple validation errors -// returned by ListMenusRequest.ValidateAll() if the designated constraints -// aren't met. -type ListMenusRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListMenusRequestMultiError) 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 ListMenusRequestMultiError) AllErrors() []error { return m } - -// ListMenusRequestValidationError is the validation error returned by -// ListMenusRequest.Validate if the designated constraints aren't met. -type ListMenusRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListMenusRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListMenusRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListMenusRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListMenusRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListMenusRequestValidationError) ErrorName() string { return "ListMenusRequestValidationError" } - -// Error satisfies the builtin error interface -func (e ListMenusRequestValidationError) 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 %sListMenusRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListMenusRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListMenusRequestValidationError{} - -// Validate checks the field values on ListMenusResponse 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 *ListMenusResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListMenusResponse 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 -// ListMenusResponseMultiError, or nil if none found. -func (m *ListMenusResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListMenusResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Total - - for idx, item := range m.GetMenus() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListMenusResponseValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListMenusResponseValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListMenusResponseValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for Page - - // no validation rules for PageSize - - // no validation rules for NextPageToken - - if m.Extra != nil { - - if all { - switch v := interface{}(m.GetExtra()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListMenusResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListMenusResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListMenusResponseValidationError{ - field: "Extra", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListMenusResponseMultiError(errors) - } - - return nil -} - -// ListMenusResponseMultiError is an error wrapping multiple validation errors -// returned by ListMenusResponse.ValidateAll() if the designated constraints -// aren't met. -type ListMenusResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListMenusResponseMultiError) 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 ListMenusResponseMultiError) AllErrors() []error { return m } - -// ListMenusResponseValidationError is the validation error returned by -// ListMenusResponse.Validate if the designated constraints aren't met. -type ListMenusResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListMenusResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListMenusResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListMenusResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListMenusResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListMenusResponseValidationError) ErrorName() string { - return "ListMenusResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListMenusResponseValidationError) 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 %sListMenusResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListMenusResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListMenusResponseValidationError{} - -// Validate checks the field values on GetMenuRequest 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 *GetMenuRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetMenuRequest 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 GetMenuRequestMultiError, -// or nil if none found. -func (m *GetMenuRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetMenuRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return GetMenuRequestMultiError(errors) - } - - return nil -} - -// GetMenuRequestMultiError is an error wrapping multiple validation errors -// returned by GetMenuRequest.ValidateAll() if the designated constraints -// aren't met. -type GetMenuRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetMenuRequestMultiError) 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 GetMenuRequestMultiError) AllErrors() []error { return m } - -// GetMenuRequestValidationError is the validation error returned by -// GetMenuRequest.Validate if the designated constraints aren't met. -type GetMenuRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetMenuRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetMenuRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetMenuRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetMenuRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetMenuRequestValidationError) ErrorName() string { return "GetMenuRequestValidationError" } - -// Error satisfies the builtin error interface -func (e GetMenuRequestValidationError) 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 %sGetMenuRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetMenuRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetMenuRequestValidationError{} - -// Validate checks the field values on GetMenuResponse 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 *GetMenuResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetMenuResponse 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 -// GetMenuResponseMultiError, or nil if none found. -func (m *GetMenuResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetMenuResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetMenuResponseMultiError(errors) - } - - return nil -} - -// GetMenuResponseMultiError is an error wrapping multiple validation errors -// returned by GetMenuResponse.ValidateAll() if the designated constraints -// aren't met. -type GetMenuResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetMenuResponseMultiError) 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 GetMenuResponseMultiError) AllErrors() []error { return m } - -// GetMenuResponseValidationError is the validation error returned by -// GetMenuResponse.Validate if the designated constraints aren't met. -type GetMenuResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetMenuResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetMenuResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetMenuResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetMenuResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetMenuResponseValidationError) ErrorName() string { return "GetMenuResponseValidationError" } - -// Error satisfies the builtin error interface -func (e GetMenuResponseValidationError) 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 %sGetMenuResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetMenuResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetMenuResponseValidationError{} - -// Validate checks the field values on CreateMenuRequest 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 *CreateMenuRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateMenuRequest 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 -// CreateMenuRequestMultiError, or nil if none found. -func (m *CreateMenuRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateMenuRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Parent - - // no validation rules for MenuId - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateMenuRequestMultiError(errors) - } - - return nil -} - -// CreateMenuRequestMultiError is an error wrapping multiple validation errors -// returned by CreateMenuRequest.ValidateAll() if the designated constraints -// aren't met. -type CreateMenuRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateMenuRequestMultiError) 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 CreateMenuRequestMultiError) AllErrors() []error { return m } - -// CreateMenuRequestValidationError is the validation error returned by -// CreateMenuRequest.Validate if the designated constraints aren't met. -type CreateMenuRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateMenuRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateMenuRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateMenuRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateMenuRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateMenuRequestValidationError) ErrorName() string { - return "CreateMenuRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateMenuRequestValidationError) 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 %sCreateMenuRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateMenuRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateMenuRequestValidationError{} - -// Validate checks the field values on CreateMenuResponse 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 *CreateMenuResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateMenuResponse 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 -// CreateMenuResponseMultiError, or nil if none found. -func (m *CreateMenuResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateMenuResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CreateMenuResponseMultiError(errors) - } - - return nil -} - -// CreateMenuResponseMultiError is an error wrapping multiple validation errors -// returned by CreateMenuResponse.ValidateAll() if the designated constraints -// aren't met. -type CreateMenuResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateMenuResponseMultiError) 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 CreateMenuResponseMultiError) AllErrors() []error { return m } - -// CreateMenuResponseValidationError is the validation error returned by -// CreateMenuResponse.Validate if the designated constraints aren't met. -type CreateMenuResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateMenuResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateMenuResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateMenuResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateMenuResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateMenuResponseValidationError) ErrorName() string { - return "CreateMenuResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateMenuResponseValidationError) 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 %sCreateMenuResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateMenuResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateMenuResponseValidationError{} - -// Validate checks the field values on UpdateMenuRequest 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 *UpdateMenuRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateMenuRequest 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 -// UpdateMenuRequestMultiError, or nil if none found. -func (m *UpdateMenuRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateMenuRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateMenuRequestValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateMenuRequestMultiError(errors) - } - - return nil -} - -// UpdateMenuRequestMultiError is an error wrapping multiple validation errors -// returned by UpdateMenuRequest.ValidateAll() if the designated constraints -// aren't met. -type UpdateMenuRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateMenuRequestMultiError) 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 UpdateMenuRequestMultiError) AllErrors() []error { return m } - -// UpdateMenuRequestValidationError is the validation error returned by -// UpdateMenuRequest.Validate if the designated constraints aren't met. -type UpdateMenuRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateMenuRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateMenuRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateMenuRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateMenuRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateMenuRequestValidationError) ErrorName() string { - return "UpdateMenuRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateMenuRequestValidationError) 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 %sUpdateMenuRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateMenuRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateMenuRequestValidationError{} - -// Validate checks the field values on UpdateMenuResponse 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 *UpdateMenuResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdateMenuResponse 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 -// UpdateMenuResponseMultiError, or nil if none found. -func (m *UpdateMenuResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdateMenuResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetMenu()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateMenuResponseValidationError{ - field: "Menu", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdateMenuResponseMultiError(errors) - } - - return nil -} - -// UpdateMenuResponseMultiError is an error wrapping multiple validation errors -// returned by UpdateMenuResponse.ValidateAll() if the designated constraints -// aren't met. -type UpdateMenuResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdateMenuResponseMultiError) 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 UpdateMenuResponseMultiError) AllErrors() []error { return m } - -// UpdateMenuResponseValidationError is the validation error returned by -// UpdateMenuResponse.Validate if the designated constraints aren't met. -type UpdateMenuResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdateMenuResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdateMenuResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdateMenuResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdateMenuResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdateMenuResponseValidationError) ErrorName() string { - return "UpdateMenuResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdateMenuResponseValidationError) 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 %sUpdateMenuResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdateMenuResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdateMenuResponseValidationError{} - -// Validate checks the field values on DeleteMenuRequest 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 *DeleteMenuRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteMenuRequest 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 -// DeleteMenuRequestMultiError, or nil if none found. -func (m *DeleteMenuRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteMenuRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if len(errors) > 0 { - return DeleteMenuRequestMultiError(errors) - } - - return nil -} - -// DeleteMenuRequestMultiError is an error wrapping multiple validation errors -// returned by DeleteMenuRequest.ValidateAll() if the designated constraints -// aren't met. -type DeleteMenuRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteMenuRequestMultiError) 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 DeleteMenuRequestMultiError) AllErrors() []error { return m } - -// DeleteMenuRequestValidationError is the validation error returned by -// DeleteMenuRequest.Validate if the designated constraints aren't met. -type DeleteMenuRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteMenuRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteMenuRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteMenuRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteMenuRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteMenuRequestValidationError) ErrorName() string { - return "DeleteMenuRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteMenuRequestValidationError) 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 %sDeleteMenuRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteMenuRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteMenuRequestValidationError{} - -// Validate checks the field values on DeleteMenuResponse 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 *DeleteMenuResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DeleteMenuResponse 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 -// DeleteMenuResponseMultiError, or nil if none found. -func (m *DeleteMenuResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *DeleteMenuResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteMenuResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteMenuResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteMenuResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return DeleteMenuResponseMultiError(errors) - } - - return nil -} - -// DeleteMenuResponseMultiError is an error wrapping multiple validation errors -// returned by DeleteMenuResponse.ValidateAll() if the designated constraints -// aren't met. -type DeleteMenuResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DeleteMenuResponseMultiError) 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 DeleteMenuResponseMultiError) AllErrors() []error { return m } - -// DeleteMenuResponseValidationError is the validation error returned by -// DeleteMenuResponse.Validate if the designated constraints aren't met. -type DeleteMenuResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DeleteMenuResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DeleteMenuResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DeleteMenuResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DeleteMenuResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DeleteMenuResponseValidationError) ErrorName() string { - return "DeleteMenuResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e DeleteMenuResponseValidationError) 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 %sDeleteMenuResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DeleteMenuResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DeleteMenuResponseValidationError{} diff --git a/api/v1/services/system/menu_bridge.pb.go b/api/v1/services/system/menu_bridge.pb.go deleted file mode 100644 index 196e0b18..00000000 --- a/api/v1/services/system/menu_bridge.pb.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: system/menu.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const MenuServiceCreateMenuBridgeOperation = "/api.v1.services.system.MenuService/CreateMenu" -const MenuServiceDeleteMenuBridgeOperation = "/api.v1.services.system.MenuService/DeleteMenu" -const MenuServiceGetMenuBridgeOperation = "/api.v1.services.system.MenuService/GetMenu" -const MenuServiceListMenusBridgeOperation = "/api.v1.services.system.MenuService/ListMenus" -const MenuServiceUpdateMenuBridgeOperation = "/api.v1.services.system.MenuService/UpdateMenu" - -type MenuServiceBridgeServer interface { - CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) - DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) - GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) - ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) - UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) -} - -type MenuServiceHooker interface { - MenuServiceCreateMenuHooker - MenuServiceDeleteMenuHooker - MenuServiceGetMenuHooker - MenuServiceListMenusHooker - MenuServiceUpdateMenuHooker -} - -type MenuServiceHookedBridger interface { - MenuServiceHooker - MenuServiceBridgeServer -} -type MenuServiceCreateMenuHooker interface { - PrepareCreateMenu(http.Context, *CreateMenuRequest) (context.Context, error) - CompleteCreateMenu(http.Context, *CreateMenuRequest, *CreateMenuResponse) error -} -type MenuServiceDeleteMenuHooker interface { - PrepareDeleteMenu(http.Context, *DeleteMenuRequest) (context.Context, error) - CompleteDeleteMenu(http.Context, *DeleteMenuRequest, *DeleteMenuResponse) error -} -type MenuServiceGetMenuHooker interface { - PrepareGetMenu(http.Context, *GetMenuRequest) (context.Context, error) - CompleteGetMenu(http.Context, *GetMenuRequest, *GetMenuResponse) error -} -type MenuServiceListMenusHooker interface { - PrepareListMenus(http.Context, *ListMenusRequest) (context.Context, error) - CompleteListMenus(http.Context, *ListMenusRequest, *ListMenusResponse) error -} -type MenuServiceUpdateMenuHooker interface { - PrepareUpdateMenu(http.Context, *UpdateMenuRequest) (context.Context, error) - CompleteUpdateMenu(http.Context, *UpdateMenuRequest, *UpdateMenuResponse) error -} - -func RegisterMenuServiceBridgeServer(s *http.Server, srv MenuServiceHookedBridger) { - r := s.Route("/") - r.GET("/sys/menus", _MenuService_ListMenus0_Bridge_Handler(srv)) - r.GET("/sys/menus/:id", _MenuService_GetMenu0_Bridge_Handler(srv)) - r.POST("/sys/menus", _MenuService_CreateMenu0_Bridge_Handler(srv)) - r.PUT("/sys/menus/:menu.id", _MenuService_UpdateMenu0_Bridge_Handler(srv)) - r.DELETE("/sys/menus/:id", _MenuService_DeleteMenu0_Bridge_Handler(srv)) -} - -func _MenuService_ListMenus0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListMenusRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceListMenus) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListMenus(ctx, req.(*ListMenusRequest)) - }) - - newctx, err := srv.PrepareListMenus(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListMenus(ctx, &in, out.(*ListMenusResponse)) - } -} - -func _MenuService_GetMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetMenuRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceGetMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetMenu(ctx, req.(*GetMenuRequest)) - }) - - newctx, err := srv.PrepareGetMenu(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetMenu(ctx, &in, out.(*GetMenuResponse)) - } -} - -func _MenuService_CreateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateMenuRequest - if err := ctx.Bind(&in); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceCreateMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateMenu(ctx, req.(*CreateMenuRequest)) - }) - - newctx, err := srv.PrepareCreateMenu(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreateMenu(ctx, &in, out.(*CreateMenuResponse)) - } -} - -func _MenuService_UpdateMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateMenuRequest - if err := ctx.Bind(&in.Menu); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceUpdateMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateMenu(ctx, req.(*UpdateMenuRequest)) - }) - - newctx, err := srv.PrepareUpdateMenu(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateMenu(ctx, &in, out.(*UpdateMenuResponse)) - } -} - -func _MenuService_DeleteMenu0_Bridge_Handler(srv MenuServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteMenuRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceDeleteMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteMenu(ctx, req.(*DeleteMenuRequest)) - }) - - newctx, err := srv.PrepareDeleteMenu(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeleteMenu(ctx, &in, out.(*DeleteMenuResponse)) - } -} - -// UnimplementedMenuServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedMenuServiceHooked struct{} - -func (UnimplementedMenuServiceHooked) PrepareCreateMenu(ctx http.Context, in *CreateMenuRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedMenuServiceHooked) CompleteCreateMenu(ctx http.Context, in *CreateMenuRequest, out *CreateMenuResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedMenuServiceHooked) PrepareDeleteMenu(ctx http.Context, in *DeleteMenuRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedMenuServiceHooked) CompleteDeleteMenu(ctx http.Context, in *DeleteMenuRequest, out *DeleteMenuResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedMenuServiceHooked) PrepareGetMenu(ctx http.Context, in *GetMenuRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedMenuServiceHooked) CompleteGetMenu(ctx http.Context, in *GetMenuRequest, out *GetMenuResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedMenuServiceHooked) PrepareListMenus(ctx http.Context, in *ListMenusRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedMenuServiceHooked) CompleteListMenus(ctx http.Context, in *ListMenusRequest, out *ListMenusResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedMenuServiceHooked) PrepareUpdateMenu(ctx http.Context, in *UpdateMenuRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedMenuServiceHooked) CompleteUpdateMenu(ctx http.Context, in *UpdateMenuRequest, out *UpdateMenuResponse) error { - return ctx.Result(200, out) -} - -func WithMenuServiceHook(h MenuServiceHooker) func(MenuServiceBridgeServer) MenuServiceHookedBridger { - return func(srv MenuServiceBridgeServer) MenuServiceHookedBridger { - return MenuServiceHookedBridge{MenuServiceBridgeServer: srv, MenuServiceHooker: h} - } -} - -// MenuServiceHookedBridge is a bridge between the HTTP and gRPC implementations of MenuService. -// It implements the HTTP and gRPC implementations of MenuService. -// It forwards requests and responses between the two implementations. -type MenuServiceHookedBridge struct { - MenuServiceBridgeServer - MenuServiceHooker -} - -type MenuServiceHTTPBridgeImpl struct { - client MenuServiceHTTPClient -} - -func NewMenuServiceHTTPBridge(client *http.Client) MenuServiceHTTPServer { - return &MenuServiceHTTPBridgeImpl{client: NewMenuServiceHTTPClient(client)} -} - -func (c *MenuServiceHTTPBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { - return c.client.CreateMenu(ctx, in) -} - -func (c *MenuServiceHTTPBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { - return c.client.DeleteMenu(ctx, in) -} - -func (c *MenuServiceHTTPBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { - return c.client.GetMenu(ctx, in) -} - -func (c *MenuServiceHTTPBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { - return c.client.ListMenus(ctx, in) -} - -func (c *MenuServiceHTTPBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { - return c.client.UpdateMenu(ctx, in) -} - -type MenuServiceBridgeImpl struct { - client MenuServiceClient -} - -func NewMenuServiceBridge(client grpc.ClientConnInterface) MenuServiceServer { - return &MenuServiceBridgeImpl{client: NewMenuServiceClient(client)} -} - -func (c *MenuServiceBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { - return c.client.CreateMenu(ctx, in) -} - -func (c *MenuServiceBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { - return c.client.DeleteMenu(ctx, in) -} - -func (c *MenuServiceBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { - return c.client.GetMenu(ctx, in) -} - -func (c *MenuServiceBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { - return c.client.ListMenus(ctx, in) -} - -func (c *MenuServiceBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { - return c.client.UpdateMenu(ctx, in) -} - -func (c *MenuServiceBridgeImpl) mustEmbedUnimplementedMenuServiceServer() {} - -type MenuServiceGRPC2HTTPBridgeImpl struct { - client MenuServiceClient -} - -func NewMenuServiceGRPC2HTTP(client grpc.ClientConnInterface) MenuServiceHTTPServer { - return &MenuServiceGRPC2HTTPBridgeImpl{client: NewMenuServiceClient(client)} -} - -func (c *MenuServiceGRPC2HTTPBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { - return c.client.CreateMenu(ctx, in) -} - -func (c *MenuServiceGRPC2HTTPBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { - return c.client.DeleteMenu(ctx, in) -} - -func (c *MenuServiceGRPC2HTTPBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { - return c.client.GetMenu(ctx, in) -} - -func (c *MenuServiceGRPC2HTTPBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { - return c.client.ListMenus(ctx, in) -} - -func (c *MenuServiceGRPC2HTTPBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { - return c.client.UpdateMenu(ctx, in) -} - -type MenuServiceHTTP2GRPCBridgeImpl struct { - client MenuServiceHTTPClient -} - -func NewMenuServiceHTTP2GRPC(client *http.Client) MenuServiceServer { - return &MenuServiceHTTP2GRPCBridgeImpl{client: NewMenuServiceHTTPClient(client)} -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest) (*CreateMenuResponse, error) { - return c.client.CreateMenu(ctx, in) -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest) (*DeleteMenuResponse, error) { - return c.client.DeleteMenu(ctx, in) -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) GetMenu(ctx context.Context, in *GetMenuRequest) (*GetMenuResponse, error) { - return c.client.GetMenu(ctx, in) -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) ListMenus(ctx context.Context, in *ListMenusRequest) (*ListMenusResponse, error) { - return c.client.ListMenus(ctx, in) -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest) (*UpdateMenuResponse, error) { - return c.client.UpdateMenu(ctx, in) -} - -func (c *MenuServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedMenuServiceServer() {} diff --git a/api/v1/services/system/menu_grpc.pb.go b/api/v1/services/system/menu_grpc.pb.go deleted file mode 100644 index 69f1f159..00000000 --- a/api/v1/services/system/menu_grpc.pb.go +++ /dev/null @@ -1,277 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: system/menu.proto - -package system - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - MenuService_ListMenus_FullMethodName = "/api.v1.services.system.MenuService/ListMenus" - MenuService_GetMenu_FullMethodName = "/api.v1.services.system.MenuService/GetMenu" - MenuService_CreateMenu_FullMethodName = "/api.v1.services.system.MenuService/CreateMenu" - MenuService_UpdateMenu_FullMethodName = "/api.v1.services.system.MenuService/UpdateMenu" - MenuService_DeleteMenu_FullMethodName = "/api.v1.services.system.MenuService/DeleteMenu" -) - -// MenuServiceClient is the client API for MenuService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The menu service definition. -type MenuServiceClient interface { - ListMenus(ctx context.Context, in *ListMenusRequest, opts ...grpc.CallOption) (*ListMenusResponse, error) - GetMenu(ctx context.Context, in *GetMenuRequest, opts ...grpc.CallOption) (*GetMenuResponse, error) - CreateMenu(ctx context.Context, in *CreateMenuRequest, opts ...grpc.CallOption) (*CreateMenuResponse, error) - UpdateMenu(ctx context.Context, in *UpdateMenuRequest, opts ...grpc.CallOption) (*UpdateMenuResponse, error) - DeleteMenu(ctx context.Context, in *DeleteMenuRequest, opts ...grpc.CallOption) (*DeleteMenuResponse, error) -} - -type menuServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewMenuServiceClient(cc grpc.ClientConnInterface) MenuServiceClient { - return &menuServiceClient{cc} -} - -func (c *menuServiceClient) ListMenus(ctx context.Context, in *ListMenusRequest, opts ...grpc.CallOption) (*ListMenusResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListMenusResponse) - err := c.cc.Invoke(ctx, MenuService_ListMenus_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *menuServiceClient) GetMenu(ctx context.Context, in *GetMenuRequest, opts ...grpc.CallOption) (*GetMenuResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetMenuResponse) - err := c.cc.Invoke(ctx, MenuService_GetMenu_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *menuServiceClient) CreateMenu(ctx context.Context, in *CreateMenuRequest, opts ...grpc.CallOption) (*CreateMenuResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateMenuResponse) - err := c.cc.Invoke(ctx, MenuService_CreateMenu_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *menuServiceClient) UpdateMenu(ctx context.Context, in *UpdateMenuRequest, opts ...grpc.CallOption) (*UpdateMenuResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateMenuResponse) - err := c.cc.Invoke(ctx, MenuService_UpdateMenu_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *menuServiceClient) DeleteMenu(ctx context.Context, in *DeleteMenuRequest, opts ...grpc.CallOption) (*DeleteMenuResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DeleteMenuResponse) - err := c.cc.Invoke(ctx, MenuService_DeleteMenu_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MenuServiceServer is the server API for MenuService service. -// All implementations must embed UnimplementedMenuServiceServer -// for forward compatibility. -// -// The menu service definition. -type MenuServiceServer interface { - ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) - GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) - CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) - UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) - DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) - mustEmbedUnimplementedMenuServiceServer() -} - -// UnimplementedMenuServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedMenuServiceServer struct{} - -func (UnimplementedMenuServiceServer) ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListMenus not implemented") -} -func (UnimplementedMenuServiceServer) GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetMenu not implemented") -} -func (UnimplementedMenuServiceServer) CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateMenu not implemented") -} -func (UnimplementedMenuServiceServer) UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateMenu not implemented") -} -func (UnimplementedMenuServiceServer) DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteMenu not implemented") -} -func (UnimplementedMenuServiceServer) mustEmbedUnimplementedMenuServiceServer() {} -func (UnimplementedMenuServiceServer) testEmbeddedByValue() {} - -// UnsafeMenuServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to MenuServiceServer will -// result in compilation errors. -type UnsafeMenuServiceServer interface { - mustEmbedUnimplementedMenuServiceServer() -} - -func RegisterMenuServiceServer(s grpc.ServiceRegistrar, srv MenuServiceServer) { - // If the following call pancis, it indicates UnimplementedMenuServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&MenuService_ServiceDesc, srv) -} - -func _MenuService_ListMenus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListMenusRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MenuServiceServer).ListMenus(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MenuService_ListMenus_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).ListMenus(ctx, req.(*ListMenusRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MenuService_GetMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetMenuRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MenuServiceServer).GetMenu(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MenuService_GetMenu_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).GetMenu(ctx, req.(*GetMenuRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MenuService_CreateMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateMenuRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MenuServiceServer).CreateMenu(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MenuService_CreateMenu_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).CreateMenu(ctx, req.(*CreateMenuRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MenuService_UpdateMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateMenuRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MenuServiceServer).UpdateMenu(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MenuService_UpdateMenu_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).UpdateMenu(ctx, req.(*UpdateMenuRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _MenuService_DeleteMenu_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteMenuRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MenuServiceServer).DeleteMenu(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: MenuService_DeleteMenu_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MenuServiceServer).DeleteMenu(ctx, req.(*DeleteMenuRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// MenuService_ServiceDesc is the grpc.ServiceDesc for MenuService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var MenuService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.system.MenuService", - HandlerType: (*MenuServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "ListMenus", - Handler: _MenuService_ListMenus_Handler, - }, - { - MethodName: "GetMenu", - Handler: _MenuService_GetMenu_Handler, - }, - { - MethodName: "CreateMenu", - Handler: _MenuService_CreateMenu_Handler, - }, - { - MethodName: "UpdateMenu", - Handler: _MenuService_UpdateMenu_Handler, - }, - { - MethodName: "DeleteMenu", - Handler: _MenuService_DeleteMenu_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "system/menu.proto", -} diff --git a/api/v1/services/system/menu_http.pb.go b/api/v1/services/system/menu_http.pb.go deleted file mode 100644 index 45b4440d..00000000 --- a/api/v1/services/system/menu_http.pb.go +++ /dev/null @@ -1,234 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: system/menu.proto - -package system - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationMenuServiceCreateMenu = "/api.v1.services.system.MenuService/CreateMenu" -const OperationMenuServiceDeleteMenu = "/api.v1.services.system.MenuService/DeleteMenu" -const OperationMenuServiceGetMenu = "/api.v1.services.system.MenuService/GetMenu" -const OperationMenuServiceListMenus = "/api.v1.services.system.MenuService/ListMenus" -const OperationMenuServiceUpdateMenu = "/api.v1.services.system.MenuService/UpdateMenu" - -type MenuServiceHTTPServer interface { - CreateMenu(context.Context, *CreateMenuRequest) (*CreateMenuResponse, error) - DeleteMenu(context.Context, *DeleteMenuRequest) (*DeleteMenuResponse, error) - GetMenu(context.Context, *GetMenuRequest) (*GetMenuResponse, error) - ListMenus(context.Context, *ListMenusRequest) (*ListMenusResponse, error) - UpdateMenu(context.Context, *UpdateMenuRequest) (*UpdateMenuResponse, error) -} - -func RegisterMenuServiceHTTPServer(s *http.Server, srv MenuServiceHTTPServer) { - r := s.Route("/") - r.GET("/sys/menus", _MenuService_ListMenus0_HTTP_Handler(srv)) - r.GET("/sys/menus/{id}", _MenuService_GetMenu0_HTTP_Handler(srv)) - r.POST("/sys/menus", _MenuService_CreateMenu0_HTTP_Handler(srv)) - r.PUT("/sys/menus/{menu.id}", _MenuService_UpdateMenu0_HTTP_Handler(srv)) - r.DELETE("/sys/menus/{id}", _MenuService_DeleteMenu0_HTTP_Handler(srv)) -} - -func _MenuService_ListMenus0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListMenusRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceListMenus) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListMenus(ctx, req.(*ListMenusRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListMenusResponse) - return ctx.Result(200, reply) - } -} - -func _MenuService_GetMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetMenuRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceGetMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetMenu(ctx, req.(*GetMenuRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetMenuResponse) - return ctx.Result(200, reply) - } -} - -func _MenuService_CreateMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CreateMenuRequest - if err := ctx.Bind(&in); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceCreateMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateMenu(ctx, req.(*CreateMenuRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CreateMenuResponse) - return ctx.Result(200, reply) - } -} - -func _MenuService_UpdateMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdateMenuRequest - if err := ctx.Bind(&in.Menu); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceUpdateMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateMenu(ctx, req.(*UpdateMenuRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdateMenuResponse) - return ctx.Result(200, reply) - } -} - -func _MenuService_DeleteMenu0_HTTP_Handler(srv MenuServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in DeleteMenuRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationMenuServiceDeleteMenu) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteMenu(ctx, req.(*DeleteMenuRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*DeleteMenuResponse) - return ctx.Result(200, reply) - } -} - -type MenuServiceHTTPClient interface { - CreateMenu(ctx context.Context, req *CreateMenuRequest, opts ...http.CallOption) (rsp *CreateMenuResponse, err error) - DeleteMenu(ctx context.Context, req *DeleteMenuRequest, opts ...http.CallOption) (rsp *DeleteMenuResponse, err error) - GetMenu(ctx context.Context, req *GetMenuRequest, opts ...http.CallOption) (rsp *GetMenuResponse, err error) - ListMenus(ctx context.Context, req *ListMenusRequest, opts ...http.CallOption) (rsp *ListMenusResponse, err error) - UpdateMenu(ctx context.Context, req *UpdateMenuRequest, opts ...http.CallOption) (rsp *UpdateMenuResponse, err error) -} - -type MenuServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewMenuServiceHTTPClient(client *http.Client) MenuServiceHTTPClient { - return &MenuServiceHTTPClientImpl{client} -} - -func (c *MenuServiceHTTPClientImpl) CreateMenu(ctx context.Context, in *CreateMenuRequest, opts ...http.CallOption) (*CreateMenuResponse, error) { - var out CreateMenuResponse - pattern := "/sys/menus" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationMenuServiceCreateMenu)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *MenuServiceHTTPClientImpl) DeleteMenu(ctx context.Context, in *DeleteMenuRequest, opts ...http.CallOption) (*DeleteMenuResponse, error) { - var out DeleteMenuResponse - pattern := "/sys/menus/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationMenuServiceDeleteMenu)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *MenuServiceHTTPClientImpl) GetMenu(ctx context.Context, in *GetMenuRequest, opts ...http.CallOption) (*GetMenuResponse, error) { - var out GetMenuResponse - pattern := "/sys/menus/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationMenuServiceGetMenu)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *MenuServiceHTTPClientImpl) ListMenus(ctx context.Context, in *ListMenusRequest, opts ...http.CallOption) (*ListMenusResponse, error) { - var out ListMenusResponse - pattern := "/sys/menus" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationMenuServiceListMenus)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *MenuServiceHTTPClientImpl) UpdateMenu(ctx context.Context, in *UpdateMenuRequest, opts ...http.CallOption) (*UpdateMenuResponse, error) { - var out UpdateMenuResponse - pattern := "/sys/menus/{menu.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationMenuServiceUpdateMenu)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Menu, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go index 3d5416e6..581196ea 100644 --- a/api/v1/services/system/resource.pb.go +++ b/api/v1/services/system/resource.pb.go @@ -25,25 +25,18 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// ListResourcesRequest is the request for the ResourceService.ListResources method. +// Request message for ResourceService.ListResources. type ListResourcesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The page number. - Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - // resource type - Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` - // The resource name keyword - Keyword string `protobuf:"bytes,8,opt,name=keyword,proto3" json:"keyword,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` + ServiceName string `protobuf:"bytes,8,opt,name=service_name,proto3" json:"service_name,omitempty"` + SyncStatus string `protobuf:"bytes,9,opt,name=sync_status,proto3" json:"sync_status,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -120,37 +113,36 @@ func (x *ListResourcesRequest) GetOnlyCount() bool { return false } -func (x *ListResourcesRequest) GetType() string { +func (x *ListResourcesRequest) GetKeyword() string { if x != nil { - return x.Type + return x.Keyword } return "" } -func (x *ListResourcesRequest) GetKeyword() string { +func (x *ListResourcesRequest) GetServiceName() string { if x != nil { - return x.Keyword + return x.ServiceName } return "" } -// ListResourcesResponse is the response for the ResourceService.ListResources method. +func (x *ListResourcesRequest) GetSyncStatus() string { + if x != nil { + return x.SyncStatus + } + return "" +} + +// Response message for ResourceService.ListResources. type ListResourcesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` - // The paging resources - Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` - // The page number. - Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - // Additional information about this response. - // content to be added without destroying the page data format - Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` + Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` + Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -227,12 +219,10 @@ func (x *ListResourcesResponse) GetExtra() *anypb.Any { return nil } -// GetResourceRequest is the request for the ResourceService.GetResource method. +// Request message for ResourceService.GetResource. type GetResourceRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field will contain id of the resource requested, for example: - // "shelves/shelf1/resources/resource2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -274,11 +264,10 @@ func (x *GetResourceRequest) GetId() int64 { return 0 } -// GetResourceResponse is the response for the ResourceService.GetResource method. +// Response message for ResourceService.GetResource. type GetResourceResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The field id should match the Noun in the method id. - Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -320,15 +309,12 @@ func (x *GetResourceResponse) GetResource() *types.Resource { return nil } -// CreateResourceRequest is the request for the ResourceService.CreateResource method. +// Request message for ResourceService.CreateResource. type CreateResourceRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id where the resource is to be created. - Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` - // The resource id to use for this resource. - ResourceId string `protobuf:"bytes,2,opt,name=resource_id,proto3" json:"resource_id,omitempty"` - // The resource object to create. - Resource *types.Resource `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + ResourceId string `protobuf:"bytes,2,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"` + Resource *types.Resource `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -384,7 +370,7 @@ func (x *CreateResourceRequest) GetResource() *types.Resource { return nil } -// CreateResourceResponse is the response for the ResourceService.CreateResource method. +// Response message for ResourceService.CreateResource. type CreateResourceResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` @@ -429,13 +415,10 @@ func (x *CreateResourceResponse) GetResource() *types.Resource { return nil } -// UpdateResourceRequest is the request for the ResourceService.UpdateResource method. +// Request message for ResourceService.UpdateResource. type UpdateResourceRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The id of the resource object to update. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The resource object which replaces the resource on the server. - Resource *types.Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -470,13 +453,6 @@ func (*UpdateResourceRequest) Descriptor() ([]byte, []int) { return file_system_resource_proto_rawDescGZIP(), []int{6} } -func (x *UpdateResourceRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - func (x *UpdateResourceRequest) GetResource() *types.Resource { if x != nil { return x.Resource @@ -484,7 +460,7 @@ func (x *UpdateResourceRequest) GetResource() *types.Resource { return nil } -// UpdateResourceResponse is the response for the ResourceService.UpdateResource method. +// Response message for ResourceService.UpdateResource. type UpdateResourceResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Resource *types.Resource `protobuf:"bytes,1,opt,name=resource,proto3" json:"resource,omitempty"` @@ -529,12 +505,10 @@ func (x *UpdateResourceResponse) GetResource() *types.Resource { return nil } -// DeleteResourceRequest is the request for the ResourceService.DeleteResource method. +// Request message for ResourceService.DeleteResource. type DeleteResourceRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The resource id of the resource to be deleted, for example: - // "shelves/shelf1/resources/resource2" - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -576,11 +550,10 @@ func (x *DeleteResourceRequest) GetId() int64 { return 0 } -// DeleteResourceResponse is the response for the ResourceService.DeleteResource method. +// Response message for ResourceService.DeleteResource. type DeleteResourceResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // or Resource resource = 1; or google.protobuf.Empty empty = 1; - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -626,7 +599,7 @@ var File_system_resource_proto protoreflect.FileDescriptor const file_system_resource_proto_rawDesc = "" + "\n" + - "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xe4\x01\n" + + "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\x96\x02\n" + "\x14ListResourcesRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + @@ -637,9 +610,10 @@ const file_system_resource_proto_rawDesc = "" + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + "\n" + "only_count\x18\x06 \x01(\bR\n" + - "only_count\x12\x12\n" + - "\x04type\x18\a \x01(\tR\x04type\x12\x18\n" + - "\akeyword\x18\b \x01(\tR\akeyword\"\x83\x02\n" + + "only_count\x12\x18\n" + + "\akeyword\x18\a \x01(\tR\akeyword\x12\"\n" + + "\fservice_name\x18\b \x01(\tR\fservice_name\x12 \n" + + "\vsync_status\x18\t \x01(\tR\vsync_status\"\x83\x02\n" + "\x15ListResourcesResponse\x12\x14\n" + "\x05total\x18\x01 \x01(\x05R\x05total\x12=\n" + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x12\n" + @@ -651,16 +625,16 @@ const file_system_resource_proto_rawDesc = "" + "\x12GetResourceRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"R\n" + "\x13GetResourceResponse\x12;\n" + - "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"\x8e\x01\n" + + "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"\x8d\x01\n" + "\x15CreateResourceRequest\x12\x16\n" + - "\x06parent\x18\x01 \x01(\tR\x06parent\x12 \n" + - "\vresource_id\x18\x02 \x01(\tR\vresource_id\x12;\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x1f\n" + + "\vresource_id\x18\x02 \x01(\tR\n" + + "resourceId\x12;\n" + "\bresource\x18\x03 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"U\n" + "\x16CreateResourceResponse\x12;\n" + - "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"d\n" + - "\x15UpdateResourceRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12;\n" + - "\bresource\x18\x02 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"U\n" + + "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"T\n" + + "\x15UpdateResourceRequest\x12;\n" + + "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"U\n" + "\x16UpdateResourceResponse\x12;\n" + "\bresource\x18\x01 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresource\"'\n" + "\x15DeleteResourceRequest\x12\x0e\n" + diff --git a/api/v1/services/system/resource.pb.gw.go b/api/v1/services/system/resource.pb.gw.go index 1fb9643b..f57e17f2 100644 --- a/api/v1/services/system/resource.pb.gw.go +++ b/api/v1/services/system/resource.pb.gw.go @@ -129,8 +129,6 @@ func local_request_ResourceService_CreateResource_0(ctx context.Context, marshal return msg, metadata, err } -var filter_ResourceService_UpdateResource_0 = &utilities.DoubleArray{Encoding: map[string]int{"resource": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - func request_ResourceService_UpdateResource_0(ctx context.Context, marshaler runtime.Marshaler, client ResourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateResourceRequest @@ -148,12 +146,6 @@ func request_ResourceService_UpdateResource_0(ctx context.Context, marshaler run if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource.id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_UpdateResource_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } msg, err := client.UpdateResource(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -175,12 +167,6 @@ func local_request_ResourceService_UpdateResource_0(ctx context.Context, marshal if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "resource.id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ResourceService_UpdateResource_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } msg, err := server.UpdateResource(ctx, &protoReq) return msg, metadata, err } diff --git a/api/v1/services/system/resource.pb.validate.go b/api/v1/services/system/resource.pb.validate.go index daec38f1..004aec33 100644 --- a/api/v1/services/system/resource.pb.validate.go +++ b/api/v1/services/system/resource.pb.validate.go @@ -69,10 +69,12 @@ func (m *ListResourcesRequest) validate(all bool) error { // no validation rules for OnlyCount - // no validation rules for Type - // no validation rules for Keyword + // no validation rules for ServiceName + + // no validation rules for SyncStatus + if len(errors) > 0 { return ListResourcesRequestMultiError(errors) } @@ -853,8 +855,6 @@ func (m *UpdateResourceRequest) validate(all bool) error { var errors []error - // no validation rules for Id - if all { switch v := interface{}(m.GetResource()).(type) { case interface{ ValidateAll() error }: diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go index 3cb6e419..c75a81a6 100644 --- a/api/v1/services/system/resource_bridge.pb.go +++ b/api/v1/services/system/resource_bridge.pb.go @@ -35,10 +35,15 @@ const ResourceServiceListResourcesBridgeOperation = "/api.v1.services.system.Res const ResourceServiceUpdateResourceBridgeOperation = "/api.v1.services.system.ResourceService/UpdateResource" type ResourceServiceBridgeServer interface { + // Creates a new backend resource. CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) + // Deletes a backend resource. DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) + // Gets a single backend resource. GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) + // Lists all backend resources. ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) + // Updates a backend resource. UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) } diff --git a/api/v1/services/system/resource_grpc.pb.go b/api/v1/services/system/resource_grpc.pb.go index e730965e..e73964a7 100644 --- a/api/v1/services/system/resource_grpc.pb.go +++ b/api/v1/services/system/resource_grpc.pb.go @@ -31,11 +31,20 @@ const ( // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // The resource service definition. +// A Resource represents a backend asset that requires access control, such as an HTTP API or a gRPC method. +// The definition of the Resource message in types/system.proto should be updated to include fields +// like service_name, path, method, operation, policy, version_id, last_sync_version_id, and sync_status +// as specified in 09_Data_Model_Schema.md. type ResourceServiceClient interface { + // Lists all backend resources. ListResources(ctx context.Context, in *ListResourcesRequest, opts ...grpc.CallOption) (*ListResourcesResponse, error) + // Gets a single backend resource. GetResource(ctx context.Context, in *GetResourceRequest, opts ...grpc.CallOption) (*GetResourceResponse, error) + // Creates a new backend resource. CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...grpc.CallOption) (*CreateResourceResponse, error) + // Updates a backend resource. UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...grpc.CallOption) (*UpdateResourceResponse, error) + // Deletes a backend resource. DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...grpc.CallOption) (*DeleteResourceResponse, error) } @@ -102,11 +111,20 @@ func (c *resourceServiceClient) DeleteResource(ctx context.Context, in *DeleteRe // for forward compatibility. // // The resource service definition. +// A Resource represents a backend asset that requires access control, such as an HTTP API or a gRPC method. +// The definition of the Resource message in types/system.proto should be updated to include fields +// like service_name, path, method, operation, policy, version_id, last_sync_version_id, and sync_status +// as specified in 09_Data_Model_Schema.md. type ResourceServiceServer interface { + // Lists all backend resources. ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) + // Gets a single backend resource. GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) + // Creates a new backend resource. CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) + // Updates a backend resource. UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) + // Deletes a backend resource. DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) mustEmbedUnimplementedResourceServiceServer() } diff --git a/api/v1/services/system/resource_http.pb.go b/api/v1/services/system/resource_http.pb.go index f3e3a47f..9ab206b5 100644 --- a/api/v1/services/system/resource_http.pb.go +++ b/api/v1/services/system/resource_http.pb.go @@ -26,10 +26,15 @@ const OperationResourceServiceListResources = "/api.v1.services.system.ResourceS const OperationResourceServiceUpdateResource = "/api.v1.services.system.ResourceService/UpdateResource" type ResourceServiceHTTPServer interface { + // CreateResource Creates a new backend resource. CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) + // DeleteResource Deletes a backend resource. DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) + // GetResource Gets a single backend resource. GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) + // ListResources Lists all backend resources. ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) + // UpdateResource Updates a backend resource. UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) } @@ -153,10 +158,15 @@ func _ResourceService_DeleteResource0_HTTP_Handler(srv ResourceServiceHTTPServer } type ResourceServiceHTTPClient interface { + // CreateResource Creates a new backend resource. CreateResource(ctx context.Context, req *CreateResourceRequest, opts ...http.CallOption) (rsp *CreateResourceResponse, err error) + // DeleteResource Deletes a backend resource. DeleteResource(ctx context.Context, req *DeleteResourceRequest, opts ...http.CallOption) (rsp *DeleteResourceResponse, err error) + // GetResource Gets a single backend resource. GetResource(ctx context.Context, req *GetResourceRequest, opts ...http.CallOption) (rsp *GetResourceResponse, err error) + // ListResources Lists all backend resources. ListResources(ctx context.Context, req *ListResourcesRequest, opts ...http.CallOption) (rsp *ListResourcesResponse, err error) + // UpdateResource Updates a backend resource. UpdateResource(ctx context.Context, req *UpdateResourceRequest, opts ...http.CallOption) (rsp *UpdateResourceResponse, err error) } @@ -168,6 +178,7 @@ func NewResourceServiceHTTPClient(client *http.Client) ResourceServiceHTTPClient return &ResourceServiceHTTPClientImpl{client} } +// CreateResource Creates a new backend resource. func (c *ResourceServiceHTTPClientImpl) CreateResource(ctx context.Context, in *CreateResourceRequest, opts ...http.CallOption) (*CreateResourceResponse, error) { var out CreateResourceResponse pattern := "/sys/resources" @@ -181,6 +192,7 @@ func (c *ResourceServiceHTTPClientImpl) CreateResource(ctx context.Context, in * return &out, nil } +// DeleteResource Deletes a backend resource. func (c *ResourceServiceHTTPClientImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest, opts ...http.CallOption) (*DeleteResourceResponse, error) { var out DeleteResourceResponse pattern := "/sys/resources/{id}" @@ -194,6 +206,7 @@ func (c *ResourceServiceHTTPClientImpl) DeleteResource(ctx context.Context, in * return &out, nil } +// GetResource Gets a single backend resource. func (c *ResourceServiceHTTPClientImpl) GetResource(ctx context.Context, in *GetResourceRequest, opts ...http.CallOption) (*GetResourceResponse, error) { var out GetResourceResponse pattern := "/sys/resources/{id}" @@ -207,6 +220,7 @@ func (c *ResourceServiceHTTPClientImpl) GetResource(ctx context.Context, in *Get return &out, nil } +// ListResources Lists all backend resources. func (c *ResourceServiceHTTPClientImpl) ListResources(ctx context.Context, in *ListResourcesRequest, opts ...http.CallOption) (*ListResourcesResponse, error) { var out ListResourcesResponse pattern := "/sys/resources" @@ -220,6 +234,7 @@ func (c *ResourceServiceHTTPClientImpl) ListResources(ctx context.Context, in *L return &out, nil } +// UpdateResource Updates a backend resource. func (c *ResourceServiceHTTPClientImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest, opts ...http.CallOption) (*UpdateResourceResponse, error) { var out UpdateResourceResponse pattern := "/sys/resources/{resource.id}" diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index 82f5b117..bc692ebb 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -22,8 +22,8 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// Menu is the model entity for the Menu schema. -type Menu struct { +// View is the model entity for the View schema. +type View struct { state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -56,9 +56,9 @@ type Menu struct { // ParentPath holds the value of the "parent_path" field. ParentPath string `protobuf:"bytes,15,opt,name=parent_path,proto3" json:"parent_path,omitempty"` // Children holds the value of the children edge. - Children []*Menu `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` + Children []*View `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. - Parent *Menu `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` + Parent *View `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` // Resources holds the value of the resources edge. Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` // Roles holds the value of the roles edge. @@ -67,20 +67,20 @@ type Menu struct { sizeCache protoimpl.SizeCache } -func (x *Menu) Reset() { - *x = Menu{} +func (x *View) Reset() { + *x = View{} mi := &file_types_system_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *Menu) String() string { +func (x *View) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Menu) ProtoMessage() {} +func (*View) ProtoMessage() {} -func (x *Menu) ProtoReflect() protoreflect.Message { +func (x *View) ProtoReflect() protoreflect.Message { mi := &file_types_system_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -92,175 +92,175 @@ func (x *Menu) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Menu.ProtoReflect.Descriptor instead. -func (*Menu) Descriptor() ([]byte, []int) { +// Deprecated: Use View.ProtoReflect.Descriptor instead. +func (*View) Descriptor() ([]byte, []int) { return file_types_system_proto_rawDescGZIP(), []int{0} } -func (x *Menu) GetId() int64 { +func (x *View) GetId() int64 { if x != nil { return x.Id } return 0 } -func (x *Menu) GetCreateTime() *timestamppb.Timestamp { +func (x *View) GetCreateTime() *timestamppb.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *Menu) GetUpdateTime() *timestamppb.Timestamp { +func (x *View) GetUpdateTime() *timestamppb.Timestamp { if x != nil { return x.UpdateTime } return nil } -func (x *Menu) GetKeyword() string { +func (x *View) GetKeyword() string { if x != nil { return x.Keyword } return "" } -func (x *Menu) GetName() string { +func (x *View) GetName() string { if x != nil { return x.Name } return "" } -func (x *Menu) GetI18NKey() string { +func (x *View) GetI18NKey() string { if x != nil { return x.I18NKey } return "" } -func (x *Menu) GetDescription() string { +func (x *View) GetDescription() string { if x != nil { return x.Description } return "" } -func (x *Menu) GetSequence() int32 { +func (x *View) GetSequence() int32 { if x != nil { return x.Sequence } return 0 } -func (x *Menu) GetType() string { +func (x *View) GetType() string { if x != nil { return x.Type } return "" } -func (x *Menu) GetIcon() string { +func (x *View) GetIcon() string { if x != nil { return x.Icon } return "" } -func (x *Menu) GetPath() string { +func (x *View) GetPath() string { if x != nil { return x.Path } return "" } -func (x *Menu) GetProperties() string { +func (x *View) GetProperties() string { if x != nil { return x.Properties } return "" } -func (x *Menu) GetStatus() int32 { +func (x *View) GetStatus() int32 { if x != nil { return x.Status } return 0 } -func (x *Menu) GetParentId() int64 { +func (x *View) GetParentId() int64 { if x != nil { return x.ParentId } return 0 } -func (x *Menu) GetParentPath() string { +func (x *View) GetParentPath() string { if x != nil { return x.ParentPath } return "" } -func (x *Menu) GetChildren() []*Menu { +func (x *View) GetChildren() []*View { if x != nil { return x.Children } return nil } -func (x *Menu) GetParent() *Menu { +func (x *View) GetParent() *View { if x != nil { return x.Parent } return nil } -func (x *Menu) GetResources() []*Resource { +func (x *View) GetResources() []*Resource { if x != nil { return x.Resources } return nil } -func (x *Menu) GetRoles() []*Role { +func (x *View) GetRoles() []*Role { if x != nil { return x.Roles } return nil } -// MenuEdges holds the relations/edges for other nodes in the graph. -type MenuEdges struct { +// ViewEdges holds the relations/edges for other nodes in the graph. +type ViewEdges struct { state protoimpl.MessageState `protogen:"open.v1"` // Children holds the value of the children edge. - Children []*Menu `protobuf:"bytes,1,rep,name=children,proto3" json:"children,omitempty"` + Children []*View `protobuf:"bytes,1,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. - Parent *Menu `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` + Parent *View `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` // Resources holds the value of the resources edge. Resources []*Resource `protobuf:"bytes,3,rep,name=resources,proto3" json:"resources,omitempty"` // Roles holds the value of the roles edge. Roles []*Role `protobuf:"bytes,4,rep,name=roles,proto3" json:"roles,omitempty"` - // RoleMenu holds the value of the role_menu edge. - RoleMenus []*RoleMenu `protobuf:"bytes,5,rep,name=role_menus,proto3" json:"role_menus,omitempty"` + // RoleView holds the value of the role_view edge. + RoleViews []*RoleView `protobuf:"bytes,5,rep,name=role_views,proto3" json:"role_views,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *MenuEdges) Reset() { - *x = MenuEdges{} +func (x *ViewEdges) Reset() { + *x = ViewEdges{} mi := &file_types_system_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *MenuEdges) String() string { +func (x *ViewEdges) String() string { return protoimpl.X.MessageStringOf(x) } -func (*MenuEdges) ProtoMessage() {} +func (*ViewEdges) ProtoMessage() {} -func (x *MenuEdges) ProtoReflect() protoreflect.Message { +func (x *ViewEdges) ProtoReflect() protoreflect.Message { mi := &file_types_system_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -272,42 +272,42 @@ func (x *MenuEdges) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use MenuEdges.ProtoReflect.Descriptor instead. -func (*MenuEdges) Descriptor() ([]byte, []int) { +// Deprecated: Use ViewEdges.ProtoReflect.Descriptor instead. +func (*ViewEdges) Descriptor() ([]byte, []int) { return file_types_system_proto_rawDescGZIP(), []int{1} } -func (x *MenuEdges) GetChildren() []*Menu { +func (x *ViewEdges) GetChildren() []*View { if x != nil { return x.Children } return nil } -func (x *MenuEdges) GetParent() *Menu { +func (x *ViewEdges) GetParent() *View { if x != nil { return x.Parent } return nil } -func (x *MenuEdges) GetResources() []*Resource { +func (x *ViewEdges) GetResources() []*Resource { if x != nil { return x.Resources } return nil } -func (x *MenuEdges) GetRoles() []*Role { +func (x *ViewEdges) GetRoles() []*Role { if x != nil { return x.Roles } return nil } -func (x *MenuEdges) GetRoleMenus() []*RoleMenu { +func (x *ViewEdges) GetRoleViews() []*RoleView { if x != nil { - return x.RoleMenus + return x.RoleViews } return nil } @@ -336,8 +336,8 @@ type Role struct { Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"` // role.field.is_types IsTypes bool `protobuf:"varint,10,opt,name=is_types,proto3" json:"is_types,omitempty"` - // Menus holds the value of the menus edge. - Menus []*Menu `protobuf:"bytes,21,rep,name=menus,proto3" json:"menus,omitempty"` + // Views holds the value of the views edge. + Views []*View `protobuf:"bytes,21,rep,name=views,proto3" json:"views,omitempty"` // Users holds the value of the users edge. Users []*User `protobuf:"bytes,22,rep,name=users,proto3" json:"users,omitempty"` // Resources holds the value of the resources edge. @@ -452,9 +452,9 @@ func (x *Role) GetIsTypes() bool { return false } -func (x *Role) GetMenus() []*Menu { +func (x *Role) GetViews() []*View { if x != nil { - return x.Menus + return x.Views } return nil } @@ -497,12 +497,12 @@ func (x *Role) GetPermissionIds() []int64 { // RoleEdges holds the relations/edges for other nodes in the graph. type RoleEdges struct { state protoimpl.MessageState `protogen:"open.v1"` - // Menus holds the value of the menus edge. - Menus []*Menu `protobuf:"bytes,1,rep,name=menus,proto3" json:"menus,omitempty"` + // Views holds the value of the views edge. + Views []*View `protobuf:"bytes,1,rep,name=views,proto3" json:"views,omitempty"` // Users holds the value of the users edge. Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` - // RoleMenu holds the value of the role_menu edge. - RoleMenus []*RoleMenu `protobuf:"bytes,3,rep,name=role_menus,proto3" json:"role_menus,omitempty"` + // RoleView holds the value of the role_view edge. + RoleViews []*RoleView `protobuf:"bytes,3,rep,name=role_views,proto3" json:"role_views,omitempty"` // UserRole holds the value of the user_role edge. UserRoles []*UserRole `protobuf:"bytes,4,rep,name=user_roles,proto3" json:"user_roles,omitempty"` unknownFields protoimpl.UnknownFields @@ -539,9 +539,9 @@ func (*RoleEdges) Descriptor() ([]byte, []int) { return file_types_system_proto_rawDescGZIP(), []int{3} } -func (x *RoleEdges) GetMenus() []*Menu { +func (x *RoleEdges) GetViews() []*View { if x != nil { - return x.Menus + return x.Views } return nil } @@ -553,9 +553,9 @@ func (x *RoleEdges) GetUsers() []*User { return nil } -func (x *RoleEdges) GetRoleMenus() []*RoleMenu { +func (x *RoleEdges) GetRoleViews() []*RoleView { if x != nil { - return x.RoleMenus + return x.RoleViews } return nil } @@ -1040,8 +1040,8 @@ func (x *UserRoleEdges) GetRole() *Role { return nil } -// RoleMenu is the model entity for the RoleMenu schema. -type RoleMenu struct { +// RoleView is the model entity for the RoleView schema. +type RoleView struct { state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -1051,30 +1051,30 @@ type RoleMenu struct { UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` // RoleID holds the value of the "role_id" field. RoleId int64 `protobuf:"varint,4,opt,name=role_id,proto3" json:"role_id,omitempty"` - // MenuID holds the value of the "menu_id" field. - MenuId int64 `protobuf:"varint,5,opt,name=menu_id,proto3" json:"menu_id,omitempty"` + // ViewID holds the value of the "view_id" field. + ViewId int64 `protobuf:"varint,5,opt,name=view_id,proto3" json:"view_id,omitempty"` // Role holds the value of the role edge. Role *Role `protobuf:"bytes,21,opt,name=role,proto3" json:"role,omitempty"` - // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,22,opt,name=menu,proto3" json:"menu,omitempty"` + // View holds the value of the view edge. + View *View `protobuf:"bytes,22,opt,name=view,proto3" json:"view,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *RoleMenu) Reset() { - *x = RoleMenu{} +func (x *RoleView) Reset() { + *x = RoleView{} mi := &file_types_system_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *RoleMenu) String() string { +func (x *RoleView) String() string { return protoimpl.X.MessageStringOf(x) } -func (*RoleMenu) ProtoMessage() {} +func (*RoleView) ProtoMessage() {} -func (x *RoleMenu) ProtoReflect() protoreflect.Message { +func (x *RoleView) ProtoReflect() protoreflect.Message { mi := &file_types_system_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1086,85 +1086,85 @@ func (x *RoleMenu) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use RoleMenu.ProtoReflect.Descriptor instead. -func (*RoleMenu) Descriptor() ([]byte, []int) { +// Deprecated: Use RoleView.ProtoReflect.Descriptor instead. +func (*RoleView) Descriptor() ([]byte, []int) { return file_types_system_proto_rawDescGZIP(), []int{8} } -func (x *RoleMenu) GetId() int64 { +func (x *RoleView) GetId() int64 { if x != nil { return x.Id } return 0 } -func (x *RoleMenu) GetCreateTime() *timestamppb.Timestamp { +func (x *RoleView) GetCreateTime() *timestamppb.Timestamp { if x != nil { return x.CreateTime } return nil } -func (x *RoleMenu) GetUpdateTime() *timestamppb.Timestamp { +func (x *RoleView) GetUpdateTime() *timestamppb.Timestamp { if x != nil { return x.UpdateTime } return nil } -func (x *RoleMenu) GetRoleId() int64 { +func (x *RoleView) GetRoleId() int64 { if x != nil { return x.RoleId } return 0 } -func (x *RoleMenu) GetMenuId() int64 { +func (x *RoleView) GetViewId() int64 { if x != nil { - return x.MenuId + return x.ViewId } return 0 } -func (x *RoleMenu) GetRole() *Role { +func (x *RoleView) GetRole() *Role { if x != nil { return x.Role } return nil } -func (x *RoleMenu) GetMenu() *Menu { +func (x *RoleView) GetView() *View { if x != nil { - return x.Menu + return x.View } return nil } -// RoleMenuEdges holds the relations/edges for other nodes in the graph. -type RoleMenuEdges struct { +// RoleViewEdges holds the relations/edges for other nodes in the graph. +type RoleViewEdges struct { state protoimpl.MessageState `protogen:"open.v1"` // Role holds the value of the role edge. Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,2,opt,name=menu,proto3" json:"menu,omitempty"` + // View holds the value of the view edge. + View *View `protobuf:"bytes,2,opt,name=view,proto3" json:"view,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *RoleMenuEdges) Reset() { - *x = RoleMenuEdges{} +func (x *RoleViewEdges) Reset() { + *x = RoleViewEdges{} mi := &file_types_system_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *RoleMenuEdges) String() string { +func (x *RoleViewEdges) String() string { return protoimpl.X.MessageStringOf(x) } -func (*RoleMenuEdges) ProtoMessage() {} +func (*RoleViewEdges) ProtoMessage() {} -func (x *RoleMenuEdges) ProtoReflect() protoreflect.Message { +func (x *RoleViewEdges) ProtoReflect() protoreflect.Message { mi := &file_types_system_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -1176,21 +1176,21 @@ func (x *RoleMenuEdges) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use RoleMenuEdges.ProtoReflect.Descriptor instead. -func (*RoleMenuEdges) Descriptor() ([]byte, []int) { +// Deprecated: Use RoleViewEdges.ProtoReflect.Descriptor instead. +func (*RoleViewEdges) Descriptor() ([]byte, []int) { return file_types_system_proto_rawDescGZIP(), []int{9} } -func (x *RoleMenuEdges) GetRole() *Role { +func (x *RoleViewEdges) GetRole() *Role { if x != nil { return x.Role } return nil } -func (x *RoleMenuEdges) GetMenu() *Menu { +func (x *RoleViewEdges) GetView() *View { if x != nil { - return x.Menu + return x.View } return nil } @@ -1443,8 +1443,8 @@ func (x *Resource) GetPermissions() []*Permission { // ResourceEdges holds the relations/edges for other nodes in the graph. type ResourceEdges struct { state protoimpl.MessageState `protogen:"open.v1"` - // Menu holds the value of the menu edge. - Menu *Menu `protobuf:"bytes,1,opt,name=menu,proto3" json:"menu,omitempty"` + // View holds the value of the view edge. + View *View `protobuf:"bytes,1,opt,name=view,proto3" json:"view,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1479,9 +1479,9 @@ func (*ResourceEdges) Descriptor() ([]byte, []int) { return file_types_system_proto_rawDescGZIP(), []int{11} } -func (x *ResourceEdges) GetMenu() *Menu { +func (x *ResourceEdges) GetView() *View { if x != nil { - return x.Menu + return x.View } return nil } @@ -1500,7 +1500,7 @@ type Department struct { Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` // department.field.name Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - // menu.field.tree_path + // department.field.tree_path TreePath string `protobuf:"bytes,6,opt,name=tree_path,proto3" json:"tree_path,omitempty"` // department.field.sequence Sequence int32 `protobuf:"varint,7,opt,name=sequence,proto3" json:"sequence,omitempty"` @@ -2748,7 +2748,7 @@ var File_types_system_proto protoreflect.FileDescriptor const file_types_system_proto_rawDesc = "" + "\n" + "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xae\x05\n" + - "\x04Menu\x12\x0e\n" + + "\x04View\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + @@ -2767,18 +2767,18 @@ const file_types_system_proto_rawDesc = "" + "\x06status\x18\r \x01(\x05R\x06status\x12\x1c\n" + "\tparent_id\x18\x0e \x01(\x03R\tparent_id\x12 \n" + "\vparent_path\x18\x0f \x01(\tR\vparent_path\x127\n" + - "\bchildren\x18\x15 \x03(\v2\x1b.api.v1.services.types.MenuR\bchildren\x123\n" + - "\x06parent\x18\x16 \x01(\v2\x1b.api.v1.services.types.MenuR\x06parent\x12=\n" + + "\bchildren\x18\x15 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + + "\x06parent\x18\x16 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + "\x05roles\x18\x18 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xac\x02\n" + - "\tMenuEdges\x127\n" + - "\bchildren\x18\x01 \x03(\v2\x1b.api.v1.services.types.MenuR\bchildren\x123\n" + - "\x06parent\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x06parent\x12=\n" + + "\tViewEdges\x127\n" + + "\bchildren\x18\x01 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + + "\x06parent\x18\x02 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + "\tresources\x18\x03 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + "\x05roles\x18\x04 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12?\n" + "\n" + - "role_menus\x18\x05 \x03(\v2\x1f.api.v1.services.types.RoleMenuR\n" + - "role_menus\"\xfc\x04\n" + + "role_views\x18\x05 \x03(\v2\x1f.api.v1.services.types.RoleViewR\n" + + "role_views\"\xfc\x04\n" + "\x04Role\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + @@ -2791,18 +2791,18 @@ const file_types_system_proto_rawDesc = "" + "\x06status\x18\t \x01(\x05R\x06status\x12\x1a\n" + "\bis_types\x18\n" + " \x01(\bR\bis_types\x121\n" + - "\x05menus\x18\x15 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x121\n" + + "\x05views\x18\x15 \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x121\n" + "\x05users\x18\x16 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\"\n" + "\fresource_ids\x18\x18 \x03(\x03R\fresource_ids\x12C\n" + "\vpermissions\x18\x19 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12&\n" + "\x0epermission_ids\x18\x1a \x03(\x03R\x0epermission_ids\"\xf3\x01\n" + "\tRoleEdges\x121\n" + - "\x05menus\x18\x01 \x03(\v2\x1b.api.v1.services.types.MenuR\x05menus\x121\n" + + "\x05views\x18\x01 \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x121\n" + "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12?\n" + "\n" + - "role_menus\x18\x03 \x03(\v2\x1f.api.v1.services.types.RoleMenuR\n" + - "role_menus\x12?\n" + + "role_views\x18\x03 \x03(\v2\x1f.api.v1.services.types.RoleViewR\n" + + "role_views\x12?\n" + "\n" + "user_roles\x18\x04 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + "user_roles\"\xce\x06\n" + @@ -2854,17 +2854,17 @@ const file_types_system_proto_rawDesc = "" + "\rUserRoleEdges\x12/\n" + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\xac\x02\n" + - "\bRoleMenu\x12\x0e\n" + + "\bRoleView\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + "\arole_id\x18\x04 \x01(\x03R\arole_id\x12\x18\n" + - "\amenu_id\x18\x05 \x01(\x03R\amenu_id\x12/\n" + + "\aview_id\x18\x05 \x01(\x03R\aview_id\x12/\n" + "\x04role\x18\x15 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + - "\x04menu\x18\x16 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"q\n" + - "\rRoleMenuEdges\x12/\n" + + "\x04view\x18\x16 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"q\n" + + "\rRoleViewEdges\x12/\n" + "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + - "\x04menu\x18\x02 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"\x8f\a\n" + + "\x04view\x18\x02 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\x8f\a\n" + "\bResource\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + @@ -2896,7 +2896,7 @@ const file_types_system_proto_rawDesc = "" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"@\n" + "\rResourceEdges\x12/\n" + - "\x04menu\x18\x01 \x01(\v2\x1b.api.v1.services.types.MenuR\x04menu\"\xe8\x03\n" + + "\x04view\x18\x01 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\xe8\x03\n" + "\n" + "Department\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + @@ -3023,16 +3023,16 @@ func file_types_system_proto_rawDescGZIP() []byte { var file_types_system_proto_msgTypes = make([]protoimpl.MessageInfo, 30) var file_types_system_proto_goTypes = []any{ - (*Menu)(nil), // 0: api.v1.services.types.Menu - (*MenuEdges)(nil), // 1: api.v1.services.types.MenuEdges + (*View)(nil), // 0: api.v1.services.types.View + (*ViewEdges)(nil), // 1: api.v1.services.types.ViewEdges (*Role)(nil), // 2: api.v1.services.types.Role (*RoleEdges)(nil), // 3: api.v1.services.types.RoleEdges (*User)(nil), // 4: api.v1.services.types.User (*UserEdges)(nil), // 5: api.v1.services.types.UserEdges (*UserRole)(nil), // 6: api.v1.services.types.UserRole (*UserRoleEdges)(nil), // 7: api.v1.services.types.UserRoleEdges - (*RoleMenu)(nil), // 8: api.v1.services.types.RoleMenu - (*RoleMenuEdges)(nil), // 9: api.v1.services.types.RoleMenuEdges + (*RoleView)(nil), // 8: api.v1.services.types.RoleView + (*RoleViewEdges)(nil), // 9: api.v1.services.types.RoleViewEdges (*Resource)(nil), // 10: api.v1.services.types.Resource (*ResourceEdges)(nil), // 11: api.v1.services.types.ResourceEdges (*Department)(nil), // 12: api.v1.services.types.Department @@ -3056,26 +3056,26 @@ var file_types_system_proto_goTypes = []any{ (*timestamppb.Timestamp)(nil), // 30: google.protobuf.Timestamp } var file_types_system_proto_depIdxs = []int32{ - 30, // 0: api.v1.services.types.Menu.create_time:type_name -> google.protobuf.Timestamp - 30, // 1: api.v1.services.types.Menu.update_time:type_name -> google.protobuf.Timestamp - 0, // 2: api.v1.services.types.Menu.children:type_name -> api.v1.services.types.Menu - 0, // 3: api.v1.services.types.Menu.parent:type_name -> api.v1.services.types.Menu - 10, // 4: api.v1.services.types.Menu.resources:type_name -> api.v1.services.types.Resource - 2, // 5: api.v1.services.types.Menu.roles:type_name -> api.v1.services.types.Role - 0, // 6: api.v1.services.types.MenuEdges.children:type_name -> api.v1.services.types.Menu - 0, // 7: api.v1.services.types.MenuEdges.parent:type_name -> api.v1.services.types.Menu - 10, // 8: api.v1.services.types.MenuEdges.resources:type_name -> api.v1.services.types.Resource - 2, // 9: api.v1.services.types.MenuEdges.roles:type_name -> api.v1.services.types.Role - 8, // 10: api.v1.services.types.MenuEdges.role_menus:type_name -> api.v1.services.types.RoleMenu + 30, // 0: api.v1.services.types.View.create_time:type_name -> google.protobuf.Timestamp + 30, // 1: api.v1.services.types.View.update_time:type_name -> google.protobuf.Timestamp + 0, // 2: api.v1.services.types.View.children:type_name -> api.v1.services.types.View + 0, // 3: api.v1.services.types.View.parent:type_name -> api.v1.services.types.View + 10, // 4: api.v1.services.types.View.resources:type_name -> api.v1.services.types.Resource + 2, // 5: api.v1.services.types.View.roles:type_name -> api.v1.services.types.Role + 0, // 6: api.v1.services.types.ViewEdges.children:type_name -> api.v1.services.types.View + 0, // 7: api.v1.services.types.ViewEdges.parent:type_name -> api.v1.services.types.View + 10, // 8: api.v1.services.types.ViewEdges.resources:type_name -> api.v1.services.types.Resource + 2, // 9: api.v1.services.types.ViewEdges.roles:type_name -> api.v1.services.types.Role + 8, // 10: api.v1.services.types.ViewEdges.role_views:type_name -> api.v1.services.types.RoleView 30, // 11: api.v1.services.types.Role.create_time:type_name -> google.protobuf.Timestamp 30, // 12: api.v1.services.types.Role.update_time:type_name -> google.protobuf.Timestamp - 0, // 13: api.v1.services.types.Role.menus:type_name -> api.v1.services.types.Menu + 0, // 13: api.v1.services.types.Role.views:type_name -> api.v1.services.types.View 4, // 14: api.v1.services.types.Role.users:type_name -> api.v1.services.types.User 10, // 15: api.v1.services.types.Role.resources:type_name -> api.v1.services.types.Resource 18, // 16: api.v1.services.types.Role.permissions:type_name -> api.v1.services.types.Permission - 0, // 17: api.v1.services.types.RoleEdges.menus:type_name -> api.v1.services.types.Menu + 0, // 17: api.v1.services.types.RoleEdges.views:type_name -> api.v1.services.types.View 4, // 18: api.v1.services.types.RoleEdges.users:type_name -> api.v1.services.types.User - 8, // 19: api.v1.services.types.RoleEdges.role_menus:type_name -> api.v1.services.types.RoleMenu + 8, // 19: api.v1.services.types.RoleEdges.role_views:type_name -> api.v1.services.types.RoleView 6, // 20: api.v1.services.types.RoleEdges.user_roles:type_name -> api.v1.services.types.UserRole 30, // 21: api.v1.services.types.User.create_time:type_name -> google.protobuf.Timestamp 30, // 22: api.v1.services.types.User.update_time:type_name -> google.protobuf.Timestamp @@ -3090,19 +3090,19 @@ var file_types_system_proto_depIdxs = []int32{ 2, // 31: api.v1.services.types.UserRole.role:type_name -> api.v1.services.types.Role 4, // 32: api.v1.services.types.UserRoleEdges.user:type_name -> api.v1.services.types.User 2, // 33: api.v1.services.types.UserRoleEdges.role:type_name -> api.v1.services.types.Role - 30, // 34: api.v1.services.types.RoleMenu.create_time:type_name -> google.protobuf.Timestamp - 30, // 35: api.v1.services.types.RoleMenu.update_time:type_name -> google.protobuf.Timestamp - 2, // 36: api.v1.services.types.RoleMenu.role:type_name -> api.v1.services.types.Role - 0, // 37: api.v1.services.types.RoleMenu.menu:type_name -> api.v1.services.types.Menu - 2, // 38: api.v1.services.types.RoleMenuEdges.role:type_name -> api.v1.services.types.Role - 0, // 39: api.v1.services.types.RoleMenuEdges.menu:type_name -> api.v1.services.types.Menu + 30, // 34: api.v1.services.types.RoleView.create_time:type_name -> google.protobuf.Timestamp + 30, // 35: api.v1.services.types.RoleView.update_time:type_name -> google.protobuf.Timestamp + 2, // 36: api.v1.services.types.RoleView.role:type_name -> api.v1.services.types.Role + 0, // 37: api.v1.services.types.RoleView.view:type_name -> api.v1.services.types.View + 2, // 38: api.v1.services.types.RoleViewEdges.role:type_name -> api.v1.services.types.Role + 0, // 39: api.v1.services.types.RoleViewEdges.view:type_name -> api.v1.services.types.View 30, // 40: api.v1.services.types.Resource.create_time:type_name -> google.protobuf.Timestamp 30, // 41: api.v1.services.types.Resource.update_time:type_name -> google.protobuf.Timestamp 28, // 42: api.v1.services.types.Resource.properties:type_name -> api.v1.services.types.Resource.PropertiesEntry 10, // 43: api.v1.services.types.Resource.children:type_name -> api.v1.services.types.Resource 10, // 44: api.v1.services.types.Resource.parent:type_name -> api.v1.services.types.Resource 18, // 45: api.v1.services.types.Resource.permissions:type_name -> api.v1.services.types.Permission - 0, // 46: api.v1.services.types.ResourceEdges.menu:type_name -> api.v1.services.types.Menu + 0, // 46: api.v1.services.types.ResourceEdges.view:type_name -> api.v1.services.types.View 30, // 47: api.v1.services.types.Department.create_time:type_name -> google.protobuf.Timestamp 30, // 48: api.v1.services.types.Department.update_time:type_name -> google.protobuf.Timestamp 12, // 49: api.v1.services.types.Department.children:type_name -> api.v1.services.types.Department diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index 6e0eb1da..50ecbfce 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -35,21 +35,21 @@ var ( _ = sort.Sort ) -// Validate checks the field values on Menu with the rules defined in the proto +// Validate checks the field values on View 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 *Menu) Validate() error { +func (m *View) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on Menu with the rules defined in the +// ValidateAll checks the field values on View 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 MenuMultiError, or nil if none found. -func (m *Menu) ValidateAll() error { +// a list of violation errors wrapped in ViewMultiError, or nil if none found. +func (m *View) ValidateAll() error { return m.validate(true) } -func (m *Menu) validate(all bool) error { +func (m *View) validate(all bool) error { if m == nil { return nil } @@ -62,7 +62,7 @@ func (m *Menu) validate(all bool) error { switch v := interface{}(m.GetCreateTime()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: "CreateTime", reason: "embedded message failed validation", cause: err, @@ -70,7 +70,7 @@ func (m *Menu) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: "CreateTime", reason: "embedded message failed validation", cause: err, @@ -79,7 +79,7 @@ func (m *Menu) validate(all bool) error { } } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuValidationError{ + return ViewValidationError{ field: "CreateTime", reason: "embedded message failed validation", cause: err, @@ -91,7 +91,7 @@ func (m *Menu) validate(all bool) error { switch v := interface{}(m.GetUpdateTime()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: "UpdateTime", reason: "embedded message failed validation", cause: err, @@ -99,7 +99,7 @@ func (m *Menu) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: "UpdateTime", reason: "embedded message failed validation", cause: err, @@ -108,7 +108,7 @@ func (m *Menu) validate(all bool) error { } } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuValidationError{ + return ViewValidationError{ field: "UpdateTime", reason: "embedded message failed validation", cause: err, @@ -147,7 +147,7 @@ func (m *Menu) validate(all bool) error { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: fmt.Sprintf("Children[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -155,7 +155,7 @@ func (m *Menu) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: fmt.Sprintf("Children[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -164,7 +164,7 @@ func (m *Menu) validate(all bool) error { } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuValidationError{ + return ViewValidationError{ field: fmt.Sprintf("Children[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -178,7 +178,7 @@ func (m *Menu) validate(all bool) error { switch v := interface{}(m.GetParent()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: "Parent", reason: "embedded message failed validation", cause: err, @@ -186,7 +186,7 @@ func (m *Menu) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: "Parent", reason: "embedded message failed validation", cause: err, @@ -195,7 +195,7 @@ func (m *Menu) validate(all bool) error { } } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuValidationError{ + return ViewValidationError{ field: "Parent", reason: "embedded message failed validation", cause: err, @@ -210,7 +210,7 @@ func (m *Menu) validate(all bool) error { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: fmt.Sprintf("Resources[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -218,7 +218,7 @@ func (m *Menu) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: fmt.Sprintf("Resources[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -227,7 +227,7 @@ func (m *Menu) validate(all bool) error { } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuValidationError{ + return ViewValidationError{ field: fmt.Sprintf("Resources[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -244,7 +244,7 @@ func (m *Menu) validate(all bool) error { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: fmt.Sprintf("Roles[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -252,7 +252,7 @@ func (m *Menu) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuValidationError{ + errors = append(errors, ViewValidationError{ field: fmt.Sprintf("Roles[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -261,7 +261,7 @@ func (m *Menu) validate(all bool) error { } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuValidationError{ + return ViewValidationError{ field: fmt.Sprintf("Roles[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -272,18 +272,18 @@ func (m *Menu) validate(all bool) error { } if len(errors) > 0 { - return MenuMultiError(errors) + return ViewMultiError(errors) } return nil } -// MenuMultiError is an error wrapping multiple validation errors returned by -// Menu.ValidateAll() if the designated constraints aren't met. -type MenuMultiError []error +// ViewMultiError is an error wrapping multiple validation errors returned by +// View.ValidateAll() if the designated constraints aren't met. +type ViewMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m MenuMultiError) Error() string { +func (m ViewMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -292,11 +292,11 @@ func (m MenuMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m MenuMultiError) AllErrors() []error { return m } +func (m ViewMultiError) AllErrors() []error { return m } -// MenuValidationError is the validation error returned by Menu.Validate if the +// ViewValidationError is the validation error returned by View.Validate if the // designated constraints aren't met. -type MenuValidationError struct { +type ViewValidationError struct { field string reason string cause error @@ -304,22 +304,22 @@ type MenuValidationError struct { } // Field function returns field value. -func (e MenuValidationError) Field() string { return e.field } +func (e ViewValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e MenuValidationError) Reason() string { return e.reason } +func (e ViewValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e MenuValidationError) Cause() error { return e.cause } +func (e ViewValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e MenuValidationError) Key() bool { return e.key } +func (e ViewValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e MenuValidationError) ErrorName() string { return "MenuValidationError" } +func (e ViewValidationError) ErrorName() string { return "ViewValidationError" } // Error satisfies the builtin error interface -func (e MenuValidationError) Error() string { +func (e ViewValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -331,14 +331,14 @@ func (e MenuValidationError) Error() string { } return fmt.Sprintf( - "invalid %sMenu.%s: %s%s", + "invalid %sView.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = MenuValidationError{} +var _ error = ViewValidationError{} var _ interface { Field() string @@ -346,24 +346,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = MenuValidationError{} +} = ViewValidationError{} -// Validate checks the field values on MenuEdges with the rules defined in the +// Validate checks the field values on ViewEdges 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 *MenuEdges) Validate() error { +func (m *ViewEdges) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on MenuEdges with the rules defined in +// ValidateAll checks the field values on ViewEdges 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 MenuEdgesMultiError, or nil +// result is a list of violation errors wrapped in ViewEdgesMultiError, or nil // if none found. -func (m *MenuEdges) ValidateAll() error { +func (m *ViewEdges) ValidateAll() error { return m.validate(true) } -func (m *MenuEdges) validate(all bool) error { +func (m *ViewEdges) validate(all bool) error { if m == nil { return nil } @@ -377,7 +377,7 @@ func (m *MenuEdges) validate(all bool) error { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ + errors = append(errors, ViewEdgesValidationError{ field: fmt.Sprintf("Children[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -385,7 +385,7 @@ func (m *MenuEdges) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ + errors = append(errors, ViewEdgesValidationError{ field: fmt.Sprintf("Children[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -394,7 +394,7 @@ func (m *MenuEdges) validate(all bool) error { } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ + return ViewEdgesValidationError{ field: fmt.Sprintf("Children[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -408,7 +408,7 @@ func (m *MenuEdges) validate(all bool) error { switch v := interface{}(m.GetParent()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ + errors = append(errors, ViewEdgesValidationError{ field: "Parent", reason: "embedded message failed validation", cause: err, @@ -416,7 +416,7 @@ func (m *MenuEdges) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ + errors = append(errors, ViewEdgesValidationError{ field: "Parent", reason: "embedded message failed validation", cause: err, @@ -425,7 +425,7 @@ func (m *MenuEdges) validate(all bool) error { } } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ + return ViewEdgesValidationError{ field: "Parent", reason: "embedded message failed validation", cause: err, @@ -440,7 +440,7 @@ func (m *MenuEdges) validate(all bool) error { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ + errors = append(errors, ViewEdgesValidationError{ field: fmt.Sprintf("Resources[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -448,7 +448,7 @@ func (m *MenuEdges) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ + errors = append(errors, ViewEdgesValidationError{ field: fmt.Sprintf("Resources[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -457,7 +457,7 @@ func (m *MenuEdges) validate(all bool) error { } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ + return ViewEdgesValidationError{ field: fmt.Sprintf("Resources[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -474,7 +474,7 @@ func (m *MenuEdges) validate(all bool) error { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ + errors = append(errors, ViewEdgesValidationError{ field: fmt.Sprintf("Roles[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -482,7 +482,7 @@ func (m *MenuEdges) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ + errors = append(errors, ViewEdgesValidationError{ field: fmt.Sprintf("Roles[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -491,7 +491,7 @@ func (m *MenuEdges) validate(all bool) error { } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ + return ViewEdgesValidationError{ field: fmt.Sprintf("Roles[%v]", idx), reason: "embedded message failed validation", cause: err, @@ -501,23 +501,23 @@ func (m *MenuEdges) validate(all bool) error { } - for idx, item := range m.GetRoleMenus() { + for idx, item := range m.GetRoleViews() { _, _ = idx, item if all { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), + errors = append(errors, ViewEdgesValidationError{ + field: fmt.Sprintf("RoleViews[%v]", idx), reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, MenuEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), + errors = append(errors, ViewEdgesValidationError{ + field: fmt.Sprintf("RoleViews[%v]", idx), reason: "embedded message failed validation", cause: err, }) @@ -525,8 +525,8 @@ func (m *MenuEdges) validate(all bool) error { } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return MenuEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), + return ViewEdgesValidationError{ + field: fmt.Sprintf("RoleViews[%v]", idx), reason: "embedded message failed validation", cause: err, } @@ -536,18 +536,18 @@ func (m *MenuEdges) validate(all bool) error { } if len(errors) > 0 { - return MenuEdgesMultiError(errors) + return ViewEdgesMultiError(errors) } return nil } -// MenuEdgesMultiError is an error wrapping multiple validation errors returned -// by MenuEdges.ValidateAll() if the designated constraints aren't met. -type MenuEdgesMultiError []error +// ViewEdgesMultiError is an error wrapping multiple validation errors returned +// by ViewEdges.ValidateAll() if the designated constraints aren't met. +type ViewEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m MenuEdgesMultiError) Error() string { +func (m ViewEdgesMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -556,11 +556,11 @@ func (m MenuEdgesMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m MenuEdgesMultiError) AllErrors() []error { return m } +func (m ViewEdgesMultiError) AllErrors() []error { return m } -// MenuEdgesValidationError is the validation error returned by -// MenuEdges.Validate if the designated constraints aren't met. -type MenuEdgesValidationError struct { +// ViewEdgesValidationError is the validation error returned by +// ViewEdges.Validate if the designated constraints aren't met. +type ViewEdgesValidationError struct { field string reason string cause error @@ -568,22 +568,22 @@ type MenuEdgesValidationError struct { } // Field function returns field value. -func (e MenuEdgesValidationError) Field() string { return e.field } +func (e ViewEdgesValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e MenuEdgesValidationError) Reason() string { return e.reason } +func (e ViewEdgesValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e MenuEdgesValidationError) Cause() error { return e.cause } +func (e ViewEdgesValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e MenuEdgesValidationError) Key() bool { return e.key } +func (e ViewEdgesValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e MenuEdgesValidationError) ErrorName() string { return "MenuEdgesValidationError" } +func (e ViewEdgesValidationError) ErrorName() string { return "ViewEdgesValidationError" } // Error satisfies the builtin error interface -func (e MenuEdgesValidationError) Error() string { +func (e ViewEdgesValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -595,14 +595,14 @@ func (e MenuEdgesValidationError) Error() string { } return fmt.Sprintf( - "invalid %sMenuEdges.%s: %s%s", + "invalid %sViewEdges.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = MenuEdgesValidationError{} +var _ error = ViewEdgesValidationError{} var _ interface { Field() string @@ -610,7 +610,7 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = MenuEdgesValidationError{} +} = ViewEdgesValidationError{} // Validate checks the field values on Role with the rules defined in the proto // definition for this message. If any rules are violated, the first error @@ -707,7 +707,7 @@ func (m *Role) validate(all bool) error { // no validation rules for IsTypes - for idx, item := range m.GetMenus() { + for idx, item := range m.GetViews() { _, _ = idx, item if all { @@ -715,7 +715,7 @@ func (m *Role) validate(all bool) error { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), + field: fmt.Sprintf("Views[%v]", idx), reason: "embedded message failed validation", cause: err, }) @@ -723,7 +723,7 @@ func (m *Role) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, RoleValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), + field: fmt.Sprintf("Views[%v]", idx), reason: "embedded message failed validation", cause: err, }) @@ -732,7 +732,7 @@ func (m *Role) validate(all bool) error { } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoleValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), + field: fmt.Sprintf("Views[%v]", idx), reason: "embedded message failed validation", cause: err, } @@ -942,7 +942,7 @@ func (m *RoleEdges) validate(all bool) error { var errors []error - for idx, item := range m.GetMenus() { + for idx, item := range m.GetViews() { _, _ = idx, item if all { @@ -950,7 +950,7 @@ func (m *RoleEdges) validate(all bool) error { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), + field: fmt.Sprintf("Views[%v]", idx), reason: "embedded message failed validation", cause: err, }) @@ -958,7 +958,7 @@ func (m *RoleEdges) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), + field: fmt.Sprintf("Views[%v]", idx), reason: "embedded message failed validation", cause: err, }) @@ -967,7 +967,7 @@ func (m *RoleEdges) validate(all bool) error { } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoleEdgesValidationError{ - field: fmt.Sprintf("Menus[%v]", idx), + field: fmt.Sprintf("Views[%v]", idx), reason: "embedded message failed validation", cause: err, } @@ -1010,7 +1010,7 @@ func (m *RoleEdges) validate(all bool) error { } - for idx, item := range m.GetRoleMenus() { + for idx, item := range m.GetRoleViews() { _, _ = idx, item if all { @@ -1018,7 +1018,7 @@ func (m *RoleEdges) validate(all bool) error { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), + field: fmt.Sprintf("RoleViews[%v]", idx), reason: "embedded message failed validation", cause: err, }) @@ -1026,7 +1026,7 @@ func (m *RoleEdges) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), + field: fmt.Sprintf("RoleViews[%v]", idx), reason: "embedded message failed validation", cause: err, }) @@ -1035,7 +1035,7 @@ func (m *RoleEdges) validate(all bool) error { } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoleEdgesValidationError{ - field: fmt.Sprintf("RoleMenus[%v]", idx), + field: fmt.Sprintf("RoleViews[%v]", idx), reason: "embedded message failed validation", cause: err, } @@ -1991,22 +1991,22 @@ var _ interface { ErrorName() string } = UserRoleEdgesValidationError{} -// Validate checks the field values on RoleMenu with the rules defined in the +// Validate checks the field values on RoleView 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 *RoleMenu) Validate() error { +func (m *RoleView) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on RoleMenu with the rules defined in +// ValidateAll checks the field values on RoleView 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 RoleMenuMultiError, or nil +// result is a list of violation errors wrapped in RoleViewMultiError, or nil // if none found. -func (m *RoleMenu) ValidateAll() error { +func (m *RoleView) ValidateAll() error { return m.validate(true) } -func (m *RoleMenu) validate(all bool) error { +func (m *RoleView) validate(all bool) error { if m == nil { return nil } @@ -2019,7 +2019,7 @@ func (m *RoleMenu) validate(all bool) error { switch v := interface{}(m.GetCreateTime()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ + errors = append(errors, RoleViewValidationError{ field: "CreateTime", reason: "embedded message failed validation", cause: err, @@ -2027,7 +2027,7 @@ func (m *RoleMenu) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ + errors = append(errors, RoleViewValidationError{ field: "CreateTime", reason: "embedded message failed validation", cause: err, @@ -2036,7 +2036,7 @@ func (m *RoleMenu) validate(all bool) error { } } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return RoleMenuValidationError{ + return RoleViewValidationError{ field: "CreateTime", reason: "embedded message failed validation", cause: err, @@ -2048,7 +2048,7 @@ func (m *RoleMenu) validate(all bool) error { switch v := interface{}(m.GetUpdateTime()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ + errors = append(errors, RoleViewValidationError{ field: "UpdateTime", reason: "embedded message failed validation", cause: err, @@ -2056,7 +2056,7 @@ func (m *RoleMenu) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ + errors = append(errors, RoleViewValidationError{ field: "UpdateTime", reason: "embedded message failed validation", cause: err, @@ -2065,7 +2065,7 @@ func (m *RoleMenu) validate(all bool) error { } } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return RoleMenuValidationError{ + return RoleViewValidationError{ field: "UpdateTime", reason: "embedded message failed validation", cause: err, @@ -2075,13 +2075,13 @@ func (m *RoleMenu) validate(all bool) error { // no validation rules for RoleId - // no validation rules for MenuId + // no validation rules for ViewId if all { switch v := interface{}(m.GetRole()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ + errors = append(errors, RoleViewValidationError{ field: "Role", reason: "embedded message failed validation", cause: err, @@ -2089,7 +2089,7 @@ func (m *RoleMenu) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ + errors = append(errors, RoleViewValidationError{ field: "Role", reason: "embedded message failed validation", cause: err, @@ -2098,7 +2098,7 @@ func (m *RoleMenu) validate(all bool) error { } } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return RoleMenuValidationError{ + return RoleViewValidationError{ field: "Role", reason: "embedded message failed validation", cause: err, @@ -2107,28 +2107,28 @@ func (m *RoleMenu) validate(all bool) error { } if all { - switch v := interface{}(m.GetMenu()).(type) { + switch v := interface{}(m.GetView()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "Menu", + errors = append(errors, RoleViewValidationError{ + field: "View", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuValidationError{ - field: "Menu", + errors = append(errors, RoleViewValidationError{ + field: "View", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetView()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return RoleMenuValidationError{ - field: "Menu", + return RoleViewValidationError{ + field: "View", reason: "embedded message failed validation", cause: err, } @@ -2136,18 +2136,18 @@ func (m *RoleMenu) validate(all bool) error { } if len(errors) > 0 { - return RoleMenuMultiError(errors) + return RoleViewMultiError(errors) } return nil } -// RoleMenuMultiError is an error wrapping multiple validation errors returned -// by RoleMenu.ValidateAll() if the designated constraints aren't met. -type RoleMenuMultiError []error +// RoleViewMultiError is an error wrapping multiple validation errors returned +// by RoleView.ValidateAll() if the designated constraints aren't met. +type RoleViewMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m RoleMenuMultiError) Error() string { +func (m RoleViewMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -2156,11 +2156,11 @@ func (m RoleMenuMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m RoleMenuMultiError) AllErrors() []error { return m } +func (m RoleViewMultiError) AllErrors() []error { return m } -// RoleMenuValidationError is the validation error returned by -// RoleMenu.Validate if the designated constraints aren't met. -type RoleMenuValidationError struct { +// RoleViewValidationError is the validation error returned by +// RoleView.Validate if the designated constraints aren't met. +type RoleViewValidationError struct { field string reason string cause error @@ -2168,22 +2168,22 @@ type RoleMenuValidationError struct { } // Field function returns field value. -func (e RoleMenuValidationError) Field() string { return e.field } +func (e RoleViewValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e RoleMenuValidationError) Reason() string { return e.reason } +func (e RoleViewValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e RoleMenuValidationError) Cause() error { return e.cause } +func (e RoleViewValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e RoleMenuValidationError) Key() bool { return e.key } +func (e RoleViewValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e RoleMenuValidationError) ErrorName() string { return "RoleMenuValidationError" } +func (e RoleViewValidationError) ErrorName() string { return "RoleViewValidationError" } // Error satisfies the builtin error interface -func (e RoleMenuValidationError) Error() string { +func (e RoleViewValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -2195,14 +2195,14 @@ func (e RoleMenuValidationError) Error() string { } return fmt.Sprintf( - "invalid %sRoleMenu.%s: %s%s", + "invalid %sRoleView.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = RoleMenuValidationError{} +var _ error = RoleViewValidationError{} var _ interface { Field() string @@ -2210,24 +2210,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = RoleMenuValidationError{} +} = RoleViewValidationError{} -// Validate checks the field values on RoleMenuEdges with the rules defined in +// Validate checks the field values on RoleViewEdges 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 *RoleMenuEdges) Validate() error { +func (m *RoleViewEdges) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on RoleMenuEdges with the rules defined +// ValidateAll checks the field values on RoleViewEdges 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 RoleMenuEdgesMultiError, or +// result is a list of violation errors wrapped in RoleViewEdgesMultiError, or // nil if none found. -func (m *RoleMenuEdges) ValidateAll() error { +func (m *RoleViewEdges) ValidateAll() error { return m.validate(true) } -func (m *RoleMenuEdges) validate(all bool) error { +func (m *RoleViewEdges) validate(all bool) error { if m == nil { return nil } @@ -2238,7 +2238,7 @@ func (m *RoleMenuEdges) validate(all bool) error { switch v := interface{}(m.GetRole()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ + errors = append(errors, RoleViewEdgesValidationError{ field: "Role", reason: "embedded message failed validation", cause: err, @@ -2246,7 +2246,7 @@ func (m *RoleMenuEdges) validate(all bool) error { } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ + errors = append(errors, RoleViewEdgesValidationError{ field: "Role", reason: "embedded message failed validation", cause: err, @@ -2255,7 +2255,7 @@ func (m *RoleMenuEdges) validate(all bool) error { } } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return RoleMenuEdgesValidationError{ + return RoleViewEdgesValidationError{ field: "Role", reason: "embedded message failed validation", cause: err, @@ -2264,28 +2264,28 @@ func (m *RoleMenuEdges) validate(all bool) error { } if all { - switch v := interface{}(m.GetMenu()).(type) { + switch v := interface{}(m.GetView()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ - field: "Menu", + errors = append(errors, RoleViewEdgesValidationError{ + field: "View", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, RoleMenuEdgesValidationError{ - field: "Menu", + errors = append(errors, RoleViewEdgesValidationError{ + field: "View", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetView()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return RoleMenuEdgesValidationError{ - field: "Menu", + return RoleViewEdgesValidationError{ + field: "View", reason: "embedded message failed validation", cause: err, } @@ -2293,19 +2293,19 @@ func (m *RoleMenuEdges) validate(all bool) error { } if len(errors) > 0 { - return RoleMenuEdgesMultiError(errors) + return RoleViewEdgesMultiError(errors) } return nil } -// RoleMenuEdgesMultiError is an error wrapping multiple validation errors -// returned by RoleMenuEdges.ValidateAll() if the designated constraints +// RoleViewEdgesMultiError is an error wrapping multiple validation errors +// returned by RoleViewEdges.ValidateAll() if the designated constraints // aren't met. -type RoleMenuEdgesMultiError []error +type RoleViewEdgesMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m RoleMenuEdgesMultiError) Error() string { +func (m RoleViewEdgesMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -2314,11 +2314,11 @@ func (m RoleMenuEdgesMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m RoleMenuEdgesMultiError) AllErrors() []error { return m } +func (m RoleViewEdgesMultiError) AllErrors() []error { return m } -// RoleMenuEdgesValidationError is the validation error returned by -// RoleMenuEdges.Validate if the designated constraints aren't met. -type RoleMenuEdgesValidationError struct { +// RoleViewEdgesValidationError is the validation error returned by +// RoleViewEdges.Validate if the designated constraints aren't met. +type RoleViewEdgesValidationError struct { field string reason string cause error @@ -2326,22 +2326,22 @@ type RoleMenuEdgesValidationError struct { } // Field function returns field value. -func (e RoleMenuEdgesValidationError) Field() string { return e.field } +func (e RoleViewEdgesValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e RoleMenuEdgesValidationError) Reason() string { return e.reason } +func (e RoleViewEdgesValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e RoleMenuEdgesValidationError) Cause() error { return e.cause } +func (e RoleViewEdgesValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e RoleMenuEdgesValidationError) Key() bool { return e.key } +func (e RoleViewEdgesValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e RoleMenuEdgesValidationError) ErrorName() string { return "RoleMenuEdgesValidationError" } +func (e RoleViewEdgesValidationError) ErrorName() string { return "RoleViewEdgesValidationError" } // Error satisfies the builtin error interface -func (e RoleMenuEdgesValidationError) Error() string { +func (e RoleViewEdgesValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -2353,14 +2353,14 @@ func (e RoleMenuEdgesValidationError) Error() string { } return fmt.Sprintf( - "invalid %sRoleMenuEdges.%s: %s%s", + "invalid %sRoleViewEdges.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = RoleMenuEdgesValidationError{} +var _ error = RoleViewEdgesValidationError{} var _ interface { Field() string @@ -2368,7 +2368,7 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = RoleMenuEdgesValidationError{} +} = RoleViewEdgesValidationError{} // Validate checks the field values on Resource with the rules defined in the // proto definition for this message. If any rules are violated, the first @@ -2681,11 +2681,11 @@ func (m *ResourceEdges) validate(all bool) error { var errors []error if all { - switch v := interface{}(m.GetMenu()).(type) { + switch v := interface{}(m.GetView()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, ResourceEdgesValidationError{ - field: "Menu", + field: "View", reason: "embedded message failed validation", cause: err, }) @@ -2693,16 +2693,16 @@ func (m *ResourceEdges) validate(all bool) error { case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, ResourceEdgesValidationError{ - field: "Menu", + field: "View", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetMenu()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetView()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ResourceEdgesValidationError{ - field: "Menu", + field: "View", reason: "embedded message failed validation", cause: err, } diff --git a/internal/features/system/biz/provider.go b/internal/features/system/biz/provider.go index 2a6b5654..6921be73 100644 --- a/internal/features/system/biz/provider.go +++ b/internal/features/system/biz/provider.go @@ -15,4 +15,5 @@ var ProviderSet = wire.NewSet( NewRoleUseCase, NewUserUseCase, NewPermissionUseCase, + NewViewUseCase, ) diff --git a/internal/features/system/dal/provider.go b/internal/features/system/dal/provider.go index fffb44e8..a99772e7 100644 --- a/internal/features/system/dal/provider.go +++ b/internal/features/system/dal/provider.go @@ -7,4 +7,4 @@ package dal import "github.com/google/wire" // ProviderSet is dal providers. -var ProviderSet = wire.NewSet(NewUserRepo, NewRoleRepo, NewPermissionRepo, NewResourceRepo) +var ProviderSet = wire.NewSet(NewUserRepo, NewRoleRepo, NewPermissionRepo, NewResourceRepo, NewViewRepo) diff --git a/internal/features/system/service/service.go b/internal/features/system/service/service.go index 144e553c..28a26a62 100644 --- a/internal/features/system/service/service.go +++ b/internal/features/system/service/service.go @@ -14,11 +14,13 @@ type SystemService struct { system.UnimplementedRoleServiceServer system.UnimplementedUserServiceServer system.UnimplementedPermissionServiceServer + system.UnimplementedViewServiceServer Resource *biz.ResourceUseCase Role *biz.RoleUseCase User *biz.UserUseCase Permission *biz.PermissionUseCase + View *biz.ViewUseCase } func New( @@ -26,11 +28,13 @@ func New( role *biz.RoleUseCase, user *biz.UserUseCase, permission *biz.PermissionUseCase, + view *biz.ViewUseCase, ) *SystemService { return &SystemService{ Resource: resource, Role: role, User: user, Permission: permission, + View: view, } } diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 627e7248..3afd2c42 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -14,7 +14,8 @@ info: url: https://origadmin/application/admin/blob/master/LICENSE version: Version from annotation servers: - - url: https://api.foo.com + - url: http://localhost:10080 + - url: https://localhost:10080 paths: /auth/authenticate: post: @@ -1281,168 +1282,6 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/menus: - get: - tags: - - MenuService - operationId: MenuService_ListMenus - parameters: - - name: id - in: query - description: The parent resource id, for example, "shelves/shelf1". - schema: - type: string - - name: page - in: query - description: The page number. - schema: - type: integer - format: int32 - - name: page_size - in: query - description: The maximum number of items to return. - schema: - type: integer - format: int32 - - name: page_token - in: query - description: The next_page_token value returned from a previous List request, if any. - schema: - type: string - - name: no_paging - in: query - description: The no_paging is used to disable pagination. - schema: - type: boolean - - name: only_count - in: query - description: The only_count is the query parameter for set only to query the total number - schema: - type: boolean - - name: keyword - in: query - description: The keyword is the query parameter for set only to query the menu by keyword - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.ListMenusResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - post: - tags: - - MenuService - operationId: MenuService_CreateMenu - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.CreateMenuRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.CreateMenuResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /sys/menus/{id}: - get: - tags: - - MenuService - operationId: MenuService_GetMenu - parameters: - - name: id - in: path - description: |- - The field will contain id of the resource requested, for example: - "shelves/shelf1/menus/menu2" - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.GetMenuResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - delete: - tags: - - MenuService - operationId: MenuService_DeleteMenu - parameters: - - name: id - in: path - description: |- - The resource id of the menu to be deleted, for example: - "shelves/shelf1/menus/menu2" - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.DeleteMenuResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /sys/menus/{menu.id}: - put: - tags: - - MenuService - operationId: MenuService_UpdateMenu - parameters: - - name: menu.id - in: path - required: true - schema: - type: string - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.types.Menu' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.UpdateMenuResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' /sys/permissions: get: tags: @@ -1788,48 +1627,45 @@ paths: get: tags: - ResourceService + description: Lists all backend resources. operationId: ResourceService_ListResources parameters: - name: id in: query - description: The parent resource id, for example, "shelves/shelf1". schema: type: string - name: page in: query - description: The page number. schema: type: integer format: int32 - name: page_size in: query - description: The maximum number of items to return. schema: type: integer format: int32 - name: page_token in: query - description: The next_page_token value returned from a previous List request, if any. schema: type: string - name: no_paging in: query - description: The no_paging is used to disable pagination. schema: type: boolean - name: only_count in: query - description: The only_count is the query parameter for set only to query the total number schema: type: boolean - - name: type + - name: keyword in: query - description: resource type schema: type: string - - name: keyword + - name: service_name + in: query + schema: + type: string + - name: sync_status in: query - description: The resource name keyword schema: type: string responses: @@ -1848,6 +1684,7 @@ paths: post: tags: - ResourceService + description: Creates a new backend resource. operationId: ResourceService_CreateResource requestBody: content: @@ -1872,13 +1709,11 @@ paths: get: tags: - ResourceService + description: Gets a single backend resource. operationId: ResourceService_GetResource parameters: - name: id in: path - description: |- - The field will contain id of the resource requested, for example: - "shelves/shelf1/resources/resource2" required: true schema: type: string @@ -1898,13 +1733,11 @@ paths: delete: tags: - ResourceService + description: Deletes a backend resource. operationId: ResourceService_DeleteResource parameters: - name: id in: path - description: |- - The resource id of the resource to be deleted, for example: - "shelves/shelf1/resources/resource2" required: true schema: type: string @@ -1925,6 +1758,7 @@ paths: put: tags: - ResourceService + description: Updates a backend resource. operationId: ResourceService_UpdateResource parameters: - name: resource.id @@ -1932,11 +1766,6 @@ paths: required: true schema: type: string - - name: id - in: query - description: The id of the resource object to update. - schema: - type: string requestBody: content: application/json: @@ -2487,44 +2316,202 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.UpdateUserStatusResponse' + $ref: '#/components/schemas/api.v1.services.system.UpdateUserStatusResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /sys/users/{user.id}: + put: + tags: + - UserService + operationId: UserService_UpdateUser + parameters: + - name: user.id + in: path + required: true + schema: + type: string + - name: user_id + in: query + description: The user id to use for this user. + schema: + type: string + - name: is_system + in: query + description: The user is_system to use for this user. + schema: + type: boolean + - name: random_password + in: query + description: The random_password is the query parameter for set only to generate a random password + schema: + type: boolean + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.types.User' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.UpdateUserResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /sys/views: + get: + tags: + - ViewService + description: Lists all view elements. + operationId: ViewService_ListViews + parameters: + - name: id + in: query + schema: + type: string + - name: page + in: query + schema: + type: integer + format: int32 + - name: page_size + in: query + schema: + type: integer + format: int32 + - name: page_token + in: query + schema: + type: string + - name: no_paging + in: query + schema: + type: boolean + - name: only_count + in: query + schema: + type: boolean + - name: keyword + in: query + schema: + type: string + - name: scope + in: query + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.ListViewsResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + post: + tags: + - ViewService + description: Creates a new view element. + operationId: ViewService_CreateView + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.CreateViewRequest' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.CreateViewResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /sys/views/{id}: + get: + tags: + - ViewService + description: Gets a single view element. + operationId: ViewService_GetView + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.GetViewResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + delete: + tags: + - ViewService + description: Deletes a view element. + operationId: ViewService_DeleteView + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.system.DeleteViewResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /sys/users/{user.id}: + /sys/views/{view.id}: put: tags: - - UserService - operationId: UserService_UpdateUser + - ViewService + description: Updates a view element. + operationId: ViewService_UpdateView parameters: - - name: user.id + - name: view.id in: path required: true schema: type: string - - name: user_id - in: query - description: The user id to use for this user. - schema: - type: string - - name: is_system - in: query - description: The user is_system to use for this user. - schema: - type: boolean - - name: random_password - in: query - description: The random_password is the query parameter for set only to generate a random password - schema: - type: boolean requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.User' + $ref: '#/components/schemas/api.v1.services.types.View' required: true responses: "200": @@ -2532,7 +2519,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.system.UpdateUserResponse' + $ref: '#/components/schemas/api.v1.services.system.UpdateViewResponse' default: description: Default error response content: @@ -3098,28 +3085,6 @@ components: properties: department: $ref: '#/components/schemas/api.v1.services.types.Department' - api.v1.services.system.CreateMenuRequest: - type: object - properties: - parent: - type: string - description: The parent resource id where the menu is to be created. - menu_id: - type: string - description: The menu id to use for this menu. - menu: - allOf: - - $ref: '#/components/schemas/api.v1.services.types.Menu' - description: |- - The menu resource to create. - The field id should match the Noun in the method id. - description: CreateMenuRequest is the request for the MenuService.CreateMenu method. - api.v1.services.system.CreateMenuResponse: - type: object - properties: - menu: - $ref: '#/components/schemas/api.v1.services.types.Menu' - description: CreateMenuResponse is the response for the MenuService.CreateMenu method. api.v1.services.system.CreatePermissionRequest: type: object properties: @@ -3163,21 +3128,17 @@ components: properties: parent: type: string - description: The parent resource id where the resource is to be created. resource_id: type: string - description: The resource id to use for this resource. resource: - allOf: - - $ref: '#/components/schemas/api.v1.services.types.Resource' - description: The resource object to create. - description: CreateResourceRequest is the request for the ResourceService.CreateResource method. + $ref: '#/components/schemas/api.v1.services.types.Resource' + description: Request message for ResourceService.CreateResource. api.v1.services.system.CreateResourceResponse: type: object properties: resource: $ref: '#/components/schemas/api.v1.services.types.Resource' - description: CreateResourceResponse is the response for the ResourceService.CreateResource method. + description: Response message for ResourceService.CreateResource. api.v1.services.system.CreateRoleRequest: type: object properties: @@ -3225,13 +3186,25 @@ components: properties: user: $ref: '#/components/schemas/api.v1.services.types.User' - api.v1.services.system.DeleteDepartmentResponse: + api.v1.services.system.CreateViewRequest: type: object - properties: {} - api.v1.services.system.DeleteMenuResponse: + properties: + parent: + type: string + view_id: + type: string + view: + $ref: '#/components/schemas/api.v1.services.types.View' + description: Request message for ViewService.CreateView. + api.v1.services.system.CreateViewResponse: + type: object + properties: + view: + $ref: '#/components/schemas/api.v1.services.types.View' + description: Response message for ViewService.CreateView. + api.v1.services.system.DeleteDepartmentResponse: type: object properties: {} - description: DeleteMenuResponse is the response for the MenuService.DeleteMenu method. api.v1.services.system.DeletePermissionResponse: type: object properties: {} @@ -3241,26 +3214,22 @@ components: api.v1.services.system.DeleteResourceResponse: type: object properties: {} - description: DeleteResourceResponse is the response for the ResourceService.DeleteResource method. + description: Response message for ResourceService.DeleteResource. api.v1.services.system.DeleteRoleResponse: type: object properties: {} api.v1.services.system.DeleteUserResponse: type: object properties: {} + api.v1.services.system.DeleteViewResponse: + type: object + properties: {} + description: Response message for ViewService.DeleteView. api.v1.services.system.GetDepartmentResponse: type: object properties: department: $ref: '#/components/schemas/api.v1.services.types.Department' - api.v1.services.system.GetMenuResponse: - type: object - properties: - menu: - allOf: - - $ref: '#/components/schemas/api.v1.services.types.Menu' - description: The field id should match the Noun in the method id. - description: GetMenuResponse is the response for the MenuService.GetMenu method. api.v1.services.system.GetPermissionResponse: type: object properties: @@ -3275,10 +3244,8 @@ components: type: object properties: resource: - allOf: - - $ref: '#/components/schemas/api.v1.services.types.Resource' - description: The field id should match the Noun in the method id. - description: GetResourceResponse is the response for the ResourceService.GetResource method. + $ref: '#/components/schemas/api.v1.services.types.Resource' + description: Response message for ResourceService.GetResource. api.v1.services.system.GetRoleResponse: type: object properties: @@ -3289,6 +3256,12 @@ components: properties: user: $ref: '#/components/schemas/api.v1.services.types.User' + api.v1.services.system.GetViewResponse: + type: object + properties: + view: + $ref: '#/components/schemas/api.v1.services.types.View' + description: Response message for ViewService.GetView. api.v1.services.system.ListDepartmentsResponse: type: object properties: @@ -3320,38 +3293,6 @@ components: description: |- Additional information about this response. content to be added without destroying the page data format - api.v1.services.system.ListMenusResponse: - type: object - properties: - total: - type: integer - description: The total number of items in the list. - format: int32 - menus: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Menu' - description: The paging menus - page: - type: integer - description: The page number. - format: int32 - page_size: - type: integer - description: The maximum number of items to return. - format: int32 - next_page_token: - type: string - description: |- - Token to retrieve the next page of results, or empty if there are no - more results in the list. - extra: - allOf: - - $ref: '#/components/schemas/google.protobuf.Any' - description: |- - Additional information about this response. - content to be added without destroying the page data format - description: ListMenusResponse is the response for the MenuService.ListMenus method. api.v1.services.system.ListPermissionsResponse: type: object properties: @@ -3419,33 +3360,22 @@ components: properties: total: type: integer - description: The total number of items in the list. format: int32 resources: type: array items: $ref: '#/components/schemas/api.v1.services.types.Resource' - description: The paging resources page: type: integer - description: The page number. format: int32 page_size: type: integer - description: The maximum number of items to return. format: int32 next_page_token: type: string - description: |- - Token to retrieve the next page of results, or empty if there are no - more results in the list. extra: - allOf: - - $ref: '#/components/schemas/google.protobuf.Any' - description: |- - Additional information about this response. - content to be added without destroying the page data format - description: ListResourcesResponse is the response for the ResourceService.ListResources method. + $ref: '#/components/schemas/google.protobuf.Any' + description: Response message for ResourceService.ListResources. api.v1.services.system.ListRolesResponse: type: object properties: @@ -3518,6 +3448,27 @@ components: description: |- Additional information about this response. content to be added without destroying the page data format + api.v1.services.system.ListViewsResponse: + type: object + properties: + total: + type: integer + format: int32 + views: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.View' + page: + type: integer + format: int32 + page_size: + type: integer + format: int32 + next_page_token: + type: string + extra: + $ref: '#/components/schemas/google.protobuf.Any' + description: Response message for ViewService.ListViews. api.v1.services.system.ResetUserPasswordResponse: type: object properties: {} @@ -3526,12 +3477,6 @@ components: properties: department: $ref: '#/components/schemas/api.v1.services.types.Department' - api.v1.services.system.UpdateMenuResponse: - type: object - properties: - menu: - $ref: '#/components/schemas/api.v1.services.types.Menu' - description: UpdateMenuResponse is the response for the MenuService.UpdateMenu method. api.v1.services.system.UpdatePermissionResponse: type: object properties: @@ -3547,7 +3492,7 @@ components: properties: resource: $ref: '#/components/schemas/api.v1.services.types.Resource' - description: UpdateResourceResponse is the response for the ResourceService.UpdateResource method. + description: Response message for ResourceService.UpdateResource. api.v1.services.system.UpdateRoleResponse: type: object properties: @@ -3587,6 +3532,12 @@ components: api.v1.services.system.UpdateUserStatusResponse: type: object properties: {} + api.v1.services.system.UpdateViewResponse: + type: object + properties: + view: + $ref: '#/components/schemas/api.v1.services.types.View' + description: Response message for ViewService.UpdateView. api.v1.services.types.DataObject: type: object properties: @@ -3645,7 +3596,7 @@ components: description: department.field.name tree_path: type: string - description: menu.field.tree_path + description: department.field.tree_path sequence: type: integer description: department.field.sequence @@ -3674,78 +3625,6 @@ components: - $ref: '#/components/schemas/api.v1.services.types.Department' description: Parent holds the value of the parent edge. description: department.table.comment - api.v1.services.types.Menu: - type: object - properties: - id: - type: string - description: ID of the ent. - create_time: - type: string - description: CreateTime holds the value of the "create_time" field. - format: date-time - update_time: - type: string - description: UpdateTime holds the value of the "update_time" field. - format: date-time - keyword: - type: string - description: Code holds the value of the "keyword" field. - name: - type: string - description: Name holds the value of the "name" field. - i18n_key: - type: string - description: I18nKey holds the value - description: - type: string - description: Description holds the value of the "description" field. - sequence: - type: integer - description: Sequence holds the value of the "sequence" field. - format: int32 - type: - type: string - description: Type holds the value of the "type" field. - icon: - type: string - description: Icon holds the value of the "icon" field. - path: - type: string - description: Path holds the value of the "path" field. - properties: - type: string - description: Properties holds the value of the "properties" field. - status: - type: integer - description: Status holds the value of the "status" field. - format: int32 - parent_id: - type: string - description: ParentID holds the value of the "parent_id" field. - parent_path: - type: string - description: ParentPath holds the value of the "parent_path" field. - children: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Menu' - description: Children holds the value of the children edge. - parent: - allOf: - - $ref: '#/components/schemas/api.v1.services.types.Menu' - description: Parent holds the value of the parent edge. - resources: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Resource' - description: Resources holds the value of the resources edge. - roles: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Role' - description: Roles holds the value of the roles edge. - description: Menu is the model entity for the Menu schema. api.v1.services.types.Permission: type: object properties: @@ -3947,11 +3826,11 @@ components: is_types: type: boolean description: role.field.is_types - menus: + views: type: array items: - $ref: '#/components/schemas/api.v1.services.types.Menu' - description: Menus holds the value of the menus edge. + $ref: '#/components/schemas/api.v1.services.types.View' + description: Views holds the value of the views edge. users: type: array items: @@ -4065,6 +3944,78 @@ components: type: string description: Role Ids holds the value of the role_ids description: User is the model entity for the User schema. + api.v1.services.types.View: + type: object + properties: + id: + type: string + description: ID of the ent. + create_time: + type: string + description: CreateTime holds the value of the "create_time" field. + format: date-time + update_time: + type: string + description: UpdateTime holds the value of the "update_time" field. + format: date-time + keyword: + type: string + description: Code holds the value of the "keyword" field. + name: + type: string + description: Name holds the value of the "name" field. + i18n_key: + type: string + description: I18nKey holds the value + description: + type: string + description: Description holds the value of the "description" field. + sequence: + type: integer + description: Sequence holds the value of the "sequence" field. + format: int32 + type: + type: string + description: Type holds the value of the "type" field. + icon: + type: string + description: Icon holds the value of the "icon" field. + path: + type: string + description: Path holds the value of the "path" field. + properties: + type: string + description: Properties holds the value of the "properties" field. + status: + type: integer + description: Status holds the value of the "status" field. + format: int32 + parent_id: + type: string + description: ParentID holds the value of the "parent_id" field. + parent_path: + type: string + description: ParentPath holds the value of the "parent_path" field. + children: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.View' + description: Children holds the value of the children edge. + parent: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.View' + description: Parent holds the value of the parent edge. + resources: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.Resource' + description: Resources holds the value of the resources edge. + roles: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.Role' + description: Roles holds the value of the roles edge. + description: View is the model entity for the View schema. api.v1.services.upload.CreateUploadResponse: type: object properties: @@ -4175,8 +4126,6 @@ tags: description: The login service definition. - name: LoginService description: The login service definition. - - name: MenuService - description: The menu service definition. - name: PermissionService description: The login service definition. - name: PersonalService @@ -4186,10 +4135,17 @@ tags: - name: PositionService description: The login service definition. - name: ResourceService - description: The resource service definition. + description: |- + The resource service definition. + A Resource represents a backend asset that requires access control, such as an HTTP API or a gRPC method. + The definition of the Resource message in types/system.proto should be updated to include fields + like service_name, path, method, operation, policy, version_id, last_sync_version_id, and sync_status + as specified in 09_Data_Model_Schema.md. - name: RoleService description: The login service definition. - name: UploadService description: The data service definition. - name: UserService description: The login service definition. + - name: ViewService + description: "The view service definition.\r\n A View represents a UI element that can be controlled by permissions, such as a menu, button, or page." From a80a3a41bf50b2fff1a1920cf9971cce3ad4d0e0 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 14:05:13 +0800 Subject: [PATCH 083/158] refactor(schema): move enums to dedicated package and update schema types usage --- .../data/entity/ent/schema/audit/service.go | 25 ---- .../data/entity/ent/schema/notification.go | 7 +- internal/data/entity/ent/schema/role.go | 26 ++-- .../data/entity/ent/schema/rolepermission.go | 4 +- .../data/entity/ent/schema/types/constants.go | 17 --- .../data/entity/ent/schema/types/structs.go | 24 ---- internal/data/entity/ent/schema/user.go | 32 ++--- internal/data/entity/ent/schema/view.go | 18 ++- internal/data/enums/status.go | 27 ++++ internal/data/enums/view.go | 25 ++++ internal/features/system/biz/view.go | 49 ++++++++ internal/features/system/dal/view.go | 118 ++++++++++++++++++ internal/features/system/dto/permission.go | 57 ++------- internal/features/system/dto/resource.go | 1 - internal/features/system/dto/role.go | 1 - internal/features/system/dto/user.go | 1 - internal/features/system/dto/view.go | 3 + 17 files changed, 279 insertions(+), 156 deletions(-) delete mode 100644 internal/data/entity/ent/schema/audit/service.go delete mode 100644 internal/data/entity/ent/schema/types/constants.go delete mode 100644 internal/data/entity/ent/schema/types/structs.go create mode 100644 internal/data/enums/status.go create mode 100644 internal/data/enums/view.go create mode 100644 internal/features/system/biz/view.go create mode 100644 internal/features/system/dal/view.go create mode 100644 internal/features/system/dto/view.go diff --git a/internal/data/entity/ent/schema/audit/service.go b/internal/data/entity/ent/schema/audit/service.go deleted file mode 100644 index 34092154..00000000 --- a/internal/data/entity/ent/schema/audit/service.go +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package audit implements the functions, types, and interfaces for the module. -package audit - -import ( - "context" -) - -type Service interface { - Log(ctx context.Context, action string, entity interface{}) -} - -type service struct { -} - -func (s service) Log(ctx context.Context, action string, entity interface{}) { - //log.Info("audit", "action", action, "entity", entity) -} - -func NewService() Service { - return &service{} -} diff --git a/internal/data/entity/ent/schema/notification.go b/internal/data/entity/ent/schema/notification.go index 02372872..7d2d8819 100644 --- a/internal/data/entity/ent/schema/notification.go +++ b/internal/data/entity/ent/schema/notification.go @@ -11,9 +11,9 @@ import ( "entgo.io/ent/schema" "entgo.io/ent/schema/field" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/helpers/ent/mixin" "origadmin/application/admin/internal/helpers/i18n" - "origadmin/application/admin/internal/data/entity/ent/schema/types" ) // Notification holds the schema definition for the Notification entity. @@ -31,9 +31,10 @@ func (Notification) Fields() []ent.Field { Default(""). Comment(i18n.Text("entity.notification.field.content")), field.Int8("status"). - Default(types.Unknown). + GoType(enums.Status(0)). // Tell entc to generate the Go type as enums.Status + Default(int8(enums.StatusUnknown)). // Provide the underlying type (int8) to the builder method Comment(i18n.Text("entity.notification.field.status")), - mixin.FK("category_id", "entity.notification.field.category_id"), + mixin.FK("category_id", i18n.Text("entity.notification.field.category_id")), } } diff --git a/internal/data/entity/ent/schema/role.go b/internal/data/entity/ent/schema/role.go index a56cadde..9d468300 100644 --- a/internal/data/entity/ent/schema/role.go +++ b/internal/data/entity/ent/schema/role.go @@ -13,15 +13,9 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/helpers/ent/mixin" "origadmin/application/admin/internal/helpers/i18n" - "origadmin/application/admin/internal/data/entity/ent/schema/types" -) - -// Role type constant -const ( - RoleTypeSystem int8 = 1 // System roles (e.g., Super Admin) - RoleTypeUser int8 = 2 // User roles (e.g., general user, operation, customer service) ) // Role holds the schema definition for the Role domain. @@ -35,24 +29,26 @@ func (Role) Fields() []ent.Field { field.String("keyword"). MaxLen(32). Unique(). - Comment("entity.role.field.keyword"), // keyword of role (unique) + Comment(i18n.Text("entity.role.field.keyword")), // keyword of role (unique) field.String("name"). MaxLen(128). Default(""). - Comment("entity.role.field.name"), // Display name of role + Comment(i18n.Text("entity.role.field.name")), // Display name of role field.String("description"). MaxLen(1024). Default(""). - Comment("entity.role.field.description"), // Details about role + Comment(i18n.Text("entity.role.field.description")), // Details about role field.Int8("type"). - Default(RoleTypeUser). - Comment("entity.role.field.type"), //("Role type: 1 - System role 2 - User role 3 - Department role"), + GoType(enums.RoleType(0)). + Default(int8(enums.RoleTypeUser)). + Comment(i18n.Text("entity.role.field.type")), // Role type: 1 - System role 2 - User role field.Int("sequence"). Default(0). - Comment("entity.role.field.sequence"), // Sequence for sorting + Comment(i18n.Text("entity.role.field.sequence")), // Sequence for sorting field.Int8("status"). - Default(types.Active). - Comment("entity.role.field.status"), + GoType(enums.Status(0)). + Default(int8(enums.StatusActive)). + Comment(i18n.Text("entity.role.field.status")), } } diff --git a/internal/data/entity/ent/schema/rolepermission.go b/internal/data/entity/ent/schema/rolepermission.go index f1d5a44d..bd5661fd 100644 --- a/internal/data/entity/ent/schema/rolepermission.go +++ b/internal/data/entity/ent/schema/rolepermission.go @@ -31,9 +31,7 @@ func (RolePermission) Fields() []ent.Field { // Mixin of the RolePermission. func (RolePermission) Mixin() []ent.Mixin { - return []ent.Mixin{ - //mixin.ID{}, - } + return []ent.Mixin{} } // Indexes of the RolePermission. diff --git a/internal/data/entity/ent/schema/types/constants.go b/internal/data/entity/ent/schema/types/constants.go deleted file mode 100644 index 501e16dc..00000000 --- a/internal/data/entity/ent/schema/types/constants.go +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package types implements the functions, types, and interfaces for the module. -package types - -const ( - Invalid = 0 - Enabled = 1 - Disabled = 2 - - Unknown = Invalid - Active = Enabled - Inactive = Disabled - Frozen = Disabled -) diff --git a/internal/data/entity/ent/schema/types/structs.go b/internal/data/entity/ent/schema/types/structs.go deleted file mode 100644 index 438b1ee2..00000000 --- a/internal/data/entity/ent/schema/types/structs.go +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package types implements the functions, types, and interfaces for the module. -package types - -import ( - "time" -) - -type PermissionCondition struct { - Field string `json:"field"` - Operator string `json:"operator"` - Value string `json:"value"` -} - -type PermissionAccessControl struct { - Actions []string `json:"actions"` - Conditions map[string]string `json:"conditions"` - ValidFrom *time.Time `json:"valid_from"` - ValidUntil *time.Time `json:"valid_until"` - Attributes map[string]any `json:"attributes"` -} diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 81d8875b..00659acc 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -13,22 +13,11 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + "origadmin/application/admin/internal/data/entity/ent/hook" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/helpers/ent/mixin" "origadmin/application/admin/internal/helpers/i18n" - "origadmin/application/admin/internal/data/entity/ent/hook" - "origadmin/application/admin/internal/data/entity/ent/schema/audit" - "origadmin/application/admin/internal/data/entity/ent/schema/types" -) - -const ( - UserStatusActive = types.Active - UserStatusFrozen = types.Frozen -) - -const ( - UserGenderMale = "male" - UserGenderFemale = "female" - UserGenderUnknown = "unknown" + "origadmin/application/admin/internal/services/audit" ) // User holds the schema definition for the User domain. @@ -60,8 +49,12 @@ func (User) Fields() []ent.Field { Default(""). Comment(i18n.Text("entity.user.field.nickname")), // Name of user field.Enum("gender"). - Values(UserGenderMale, UserGenderFemale, UserGenderUnknown). - Default(UserGenderUnknown). + Values( + string(enums.GenderMale), + string(enums.GenderFemale), + string(enums.GenderUnknown), + ). + Default(string(enums.GenderUnknown)). Comment(i18n.Text("entity.user.field.gender")), // Gender of user field.String("encrypted_password"). MaxLen(256). @@ -93,7 +86,8 @@ func (User) Fields() []ent.Field { Default(""). Comment(i18n.Text("entity.user.field.token")), // Token for login field.Int8("status"). - Default(UserStatusActive). + GoType(enums.Status(0)). + Default(int8(enums.StatusActive)). Comment(i18n.Text("entity.user.field.status")), field.Bool("is_system"). Default(false). @@ -105,10 +99,10 @@ func (User) Fields() []ent.Field { mixin.Time("last_login_time", i18n.Text("entity.user.field.last_login_time")), mixin.Time("login_time", i18n.Text("entity.user.field.login_time")), mixin.TimeOptional("sanction_date", i18n.Text("entity.user.field.sanction_date")), - mixin.OptionalFK("manager_id", i18n.Text("entity.user.field.manager_id")), // 管理员ID + mixin.OptionalFK("manager_id", i18n.Text("entity.user.field.manager_id")), field.String("manager"). Default(""). - Comment(i18n.Text("entity.user.field.manager")), // 管理员 + Comment(i18n.Text("entity.user.field.manager")), } } diff --git a/internal/data/entity/ent/schema/view.go b/internal/data/entity/ent/schema/view.go index f2153bb0..5d9b6bb0 100644 --- a/internal/data/entity/ent/schema/view.go +++ b/internal/data/entity/ent/schema/view.go @@ -4,6 +4,8 @@ import ( "entgo.io/ent" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/helpers/ent/mixin" "origadmin/application/admin/internal/helpers/i18n" ) @@ -27,10 +29,20 @@ func (View) Fields() []ent.Field { Default("default"), field.String("name"). Comment(i18n.Text("view.name.comment")), - field.String("type"). + field.Enum("type"). Comment(i18n.Text("view.type.comment")). - MaxLen(1). - Default("U"), + Values( + string(enums.ViewTypeRoot), + string(enums.ViewTypeGroup), + string(enums.ViewTypeMenu), + string(enums.ViewTypeLink), + string(enums.ViewTypePage), + string(enums.ViewTypeButton), + string(enums.ViewTypeElement), + string(enums.ViewTypeRedirect), + string(enums.ViewTypeUnknown), + ). + Default(string(enums.ViewTypeUnknown)), field.String("component"). Comment(i18n.Text("view.component.comment")). Optional(), diff --git a/internal/data/enums/status.go b/internal/data/enums/status.go new file mode 100644 index 00000000..e98b1b9b --- /dev/null +++ b/internal/data/enums/status.go @@ -0,0 +1,27 @@ +package enums + +// Status defines a general-purpose status for various entities. +type Status int8 + +const ( + StatusInvalid Status = 0 + StatusEnabled Status = 1 + StatusDisabled Status = 2 + + StatusUnknown = StatusInvalid + StatusActive = StatusEnabled + StatusInactive = StatusDisabled + StatusFrozen = StatusDisabled +) + +// String returns the string representation of the status. +func (s Status) String() string { + switch s { + case StatusEnabled: + return "enabled" + case StatusDisabled: + return "disabled" + default: + return "unknown" + } +} diff --git a/internal/data/enums/view.go b/internal/data/enums/view.go new file mode 100644 index 00000000..9214f22d --- /dev/null +++ b/internal/data/enums/view.go @@ -0,0 +1,25 @@ +package enums + +// ViewType defines the nature and behavior of a View entity. +type ViewType string + +const ( + // ViewTypeRoot (T) is a virtual root node, used as a mount point for view trees in different scopes. It is not displayed. + ViewTypeRoot ViewType = "T" + // ViewTypeGroup (G) is a pure visual grouping in a menu. It is not clickable and has no link. + ViewTypeGroup ViewType = "G" + // ViewTypeMenu (M) is a core navigation item, typically with a link that navigates to a PAGE. + ViewTypeMenu ViewType = "M" + // ViewTypeLink (L) is an external link that opens in a new tab. + ViewTypeLink ViewType = "L" + // ViewTypePage (P) is the final destination of navigation, a container for content. + ViewTypePage ViewType = "P" + // ViewTypeButton (B) is an action trigger displayed on a page. + ViewTypeButton ViewType = "B" + // ViewTypeElement (E) is a generic UI element like a tab or a table column that requires permission control. + ViewTypeElement ViewType = "E" + // ViewTypeRedirect (R) is a route that performs a redirect. + ViewTypeRedirect ViewType = "R" + // ViewTypeUnknown (U) is an unknown or undefined type. + ViewTypeUnknown ViewType = "U" +) diff --git a/internal/features/system/biz/view.go b/internal/features/system/biz/view.go new file mode 100644 index 00000000..0ae0093f --- /dev/null +++ b/internal/features/system/biz/view.go @@ -0,0 +1,49 @@ +package biz + +import ( + "context" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/system/dto" +) + +// ViewUseCase is a View use case. +type ViewUseCase struct { + repo dto.ViewRepo +} + +// NewViewUseCase new a View use case. +func NewViewUseCase(repo dto.ViewRepo) *ViewUseCase { + return &ViewUseCase{repo: repo} +} + +// ListViews retrieves a list of views. +func (uc *ViewUseCase) ListViews(ctx context.Context, in *system.ListViewsRequest) ([]*types.View, int32, error) { + queryOpt := &dto.ViewQueryOption{ + Keyword: in.GetKeyword(), + Scope: in.GetScope(), + } + queryOpt.SetPaging(in.GetPage(), in.GetPageSize(), in.GetNoPaging()) + + return uc.repo.List(ctx, queryOpt) +} + +// GetView retrieves a single view by its ID. +func (uc *ViewUseCase) GetView(ctx context.Context, id int64) (*types.View, error) { + return uc.repo.Get(ctx, id) +} + +// CreateView creates a new view. +func (uc *ViewUseCase) CreateView(ctx context.Context, in *types.View) (*types.View, error) { + return uc.repo.Create(ctx, in) +} + +// UpdateView updates an existing view. +func (uc *ViewUseCase) UpdateView(ctx context.Context, in *types.View) (*types.View, error) { + return uc.repo.Update(ctx, in) +} + +// DeleteView deletes a view by its ID. +func (uc *ViewUseCase) DeleteView(ctx context.Context, id int64) error { + return uc.repo.Delete(ctx, id) +} diff --git a/internal/features/system/dal/view.go b/internal/features/system/dal/view.go new file mode 100644 index 00000000..e81f64a0 --- /dev/null +++ b/internal/features/system/dal/view.go @@ -0,0 +1,118 @@ +package dal + +import ( + "context" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/repo" +) + +type viewRepo struct { + db *ent.Database +} + +// NewViewRepo creates a new view repository. +func NewViewRepo(db *ent.Database) dto.ViewRepo { + return &viewRepo{db: db} +} + +// Get retrieves a single view by its ID. +func (r *viewRepo) Get(ctx context.Context, id int64) (*types.View, error) { + result, err := r.db.View(ctx).Query().Where(view.ID(id)).Only(ctx) + if err != nil { + return nil, err + } + return dto.ConvertViewToViewPB(result), nil +} + +// List retrieves a list of views based on query options. +func (r *viewRepo) List(ctx context.Context, opts ...*dto.ViewQueryOption) ([]*types.View, int32, error) { + opt := repo.GetFirstOption(opts...) + query := r.db.View(ctx).Query() + + // Apply filters + if opt.Keyword != "" { + query.Where(view.Or( + view.NameContains(opt.Keyword), + view.KeywordContains(opt.Keyword), + )) + } + if opt.Scope != "" { + query.Where(view.ScopeEQ(opt.Scope)) + } + + // Get the total count before applying pagination. + count, err := query.Clone().Count(ctx) + if err != nil { + return nil, 0, err + } + + // Apply pagination + if opt.Page > 0 && opt.PageSize > 0 { + query.Offset((opt.Page - 1) * opt.PageSize).Limit(opt.PageSize) + } + + result, err := query.All(ctx) + if err != nil { + return nil, 0, err + } + + return dto.ConvertViewsToViewsPB(result), int32(count), nil +} + +// Create creates a new view. +func (r *viewRepo) Create(ctx context.Context, in *types.View, opts ...*dto.ViewCreateOption) (*types.View, error) { + create := r.db.View(ctx).Create(). + SetKeyword(in.Keyword). + SetName(in.Name). + SetScope(in.Scope). + SetType(in.Type). + SetNillableComponent(&in.Component). + SetNillablePath(&in.Path). + SetNillableIcon(&in.Icon). + SetVisible(in.Visible). + SetSequence(int(in.Sequence)) + + if in.ParentId > 0 { + create.SetParentID(in.ParentId) + } + + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertViewToViewPB(saved), nil +} + +// Update updates an existing view. +func (r *viewRepo) Update(ctx context.Context, in *types.View, opts ...*dto.ViewUpdateOption) (*types.View, error) { + update := r.db.View(ctx).UpdateOneID(in.Id). + SetKeyword(in.Keyword). + SetName(in.Name). + SetScope(in.Scope). + SetType(in.Type). + SetNillableComponent(&in.Component). + SetNillablePath(&in.Path). + SetNillableIcon(&in.Icon). + SetVisible(in.Visible). + SetSequence(int(in.Sequence)) + + if in.ParentId > 0 { + update.SetParentID(in.ParentId) + } else { + update.ClearParent() + } + + saved, err := update.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertViewToViewPB(saved), nil +} + +// Delete deletes a view by its ID (soft delete). +func (r *viewRepo) Delete(ctx context.Context, id int64) error { + return r.db.View(ctx).DeleteOneID(id).Exec(ctx) +} diff --git a/internal/features/system/dto/permission.go b/internal/features/system/dto/permission.go index 72256cc2..c1e34d1b 100644 --- a/internal/features/system/dto/permission.go +++ b/internal/features/system/dto/permission.go @@ -1,50 +1,19 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the system module. package dto -import ( - "context" - - "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/helpers/repo" -) - -// PermissionRepo is a Permission repository interface. -type PermissionRepo interface { - Get(context.Context, int64, ...*PermissionQueryOption) (*types.Permission, error) - List(context.Context, ...*PermissionQueryOption) ([]*types.Permission, int32, error) - Create(context.Context, *types.Permission, ...*PermissionCreateOption) (*types.Permission, error) - Update(context.Context, *types.Permission, ...*PermissionUpdateOption) (*types.Permission, error) - Delete(context.Context, int64) error -} - -// PermissionQueryOption specifies options for querying permissions. -type PermissionQueryOption struct { - repo.QueryOption - DataScopes []string - WithResources bool - WithRoles bool -} - -// PermissionCreateOption specifies options for creating a permission. -type PermissionCreateOption struct { -} +import "time" -// PermissionUpdateOption specifies options for updating a permission. -type PermissionUpdateOption struct { +// PermissionCondition represents a single condition for a permission. +type PermissionCondition struct { + Field string `json:"field"` + Operator string `json:"operator"` + Value string `json:"value"` } -// ListPermissionsRequestToQueryOption converts an API request to a query option object. -func ListPermissionsRequestToQueryOption(req *system.ListPermissionsRequest) *PermissionQueryOption { - if req == nil { - return &PermissionQueryOption{} - } - return &PermissionQueryOption{ - QueryOption: repo.OptionFromRequest(req), - DataScopes: req.GetDataScopes(), - } +// PermissionAccessControl defines the access control rules for a permission. +type PermissionAccessControl struct { + Actions []string `json:"actions"` + Conditions map[string]string `json:"conditions"` + ValidFrom *time.Time `json:"valid_from"` + ValidUntil *time.Time `json:"valid_until"` + Attributes map[string]any `json:"attributes"` } diff --git a/internal/features/system/dto/resource.go b/internal/features/system/dto/resource.go index 40009cb9..59a7e687 100644 --- a/internal/features/system/dto/resource.go +++ b/internal/features/system/dto/resource.go @@ -43,6 +43,5 @@ func ListResourcesRequestToQueryOption(req *system.ListResourcesRequest) *Resour } return &ResourceQueryOption{ QueryOption: repo.OptionFromRequest(req), - // WithPermissions: req.GetWithPermissions(), // Assuming this field exists } } diff --git a/internal/features/system/dto/role.go b/internal/features/system/dto/role.go index 8c618e5b..d48dabc5 100644 --- a/internal/features/system/dto/role.go +++ b/internal/features/system/dto/role.go @@ -47,6 +47,5 @@ func ListRolesRequestToQueryOption(req *system.ListRolesRequest) *RoleQueryOptio } return &RoleQueryOption{ QueryOption: repo.OptionFromRequest(req), - // WithPermissions: req.GetWithPermissions(), // Assuming this field exists } } diff --git a/internal/features/system/dto/user.go b/internal/features/system/dto/user.go index 18a10a48..6ba5c2f0 100644 --- a/internal/features/system/dto/user.go +++ b/internal/features/system/dto/user.go @@ -54,6 +54,5 @@ func ListUsersRequestToQueryOption(req *system.ListUsersRequest) *UserQueryOptio } return &UserQueryOption{ QueryOption: repo.OptionFromRequest(req), - // WithRoles: req.GetWithRoles(), // Assuming this field exists in the request } } diff --git a/internal/features/system/dto/view.go b/internal/features/system/dto/view.go new file mode 100644 index 00000000..dc315908 --- /dev/null +++ b/internal/features/system/dto/view.go @@ -0,0 +1,3 @@ +// This file is intentionally left empty and is pending deletion. +// The definitions within this file have been moved to the 'internal/data/enums' package +// to correct a layering violation. From 22f1d4e2a5a01362413f296c32380688884e450d Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 15:20:11 +0800 Subject: [PATCH 084/158] refactor(audit): remove user audit hooks and related dependencies --- internal/data/data.go | 1 - internal/data/entity/ent/schema/hooks.go | 39 --------- internal/data/entity/ent/schema/user.go | 11 +-- internal/features/system/dto/dto.gen.go | 106 ++++++++++++++++++++++- 4 files changed, 103 insertions(+), 54 deletions(-) delete mode 100644 internal/data/entity/ent/schema/hooks.go diff --git a/internal/data/data.go b/internal/data/data.go index 5a7858ac..1b138282 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -79,6 +79,5 @@ func NewData(rt *runtime.App, conf *conf.Config) (*Data, func(), error) { } } } - return d, cleanup, nil } diff --git a/internal/data/entity/ent/schema/hooks.go b/internal/data/entity/ent/schema/hooks.go deleted file mode 100644 index 2390e97a..00000000 --- a/internal/data/entity/ent/schema/hooks.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package schema implements the functions, types, and interfaces for the module. -package schema - -import ( - "context" - "fmt" - "strings" - - "entgo.io/ent" - - "origadmin/application/admin/internal/data/entity/ent/schema/audit" -) - -func UserAuditHook(service audit.Service) ent.Hook { - return func(mutator ent.Mutator) ent.Mutator { - return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { - value, err := mutator.Mutate(ctx, m) - if err != nil { - return nil, err - } - - go func() { - defer func() { - if r := recover(); r != nil { - //log.Error("audit panic recovered", r) - } - }() - action := strings.ToUpper(strings.TrimPrefix(fmt.Sprintf("%T", m), "*ent.")) - service.Log(context.Background(), action, value) - }() - - return value, nil - }) - } -} diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 00659acc..84dcf90d 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -13,11 +13,9 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" - "origadmin/application/admin/internal/data/entity/ent/hook" "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/helpers/ent/mixin" "origadmin/application/admin/internal/helpers/i18n" - "origadmin/application/admin/internal/services/audit" ) // User holds the schema definition for the User domain. @@ -150,12 +148,5 @@ func (User) Edges() []ent.Edge { } func (User) Hooks() []ent.Hook { - auditService := audit.NewService() - // todo audit service: inject audit service - if auditService == nil { - return nil - } - return []ent.Hook{ - hook.On(UserAuditHook(auditService), ent.OpCreate|ent.OpUpdate|ent.OpDelete), - } + return []ent.Hook{} } diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index 4c75ada8..373e003e 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -22,8 +22,6 @@ type ( DepartmentPB = types.Department Departments = []*ent.Department DepartmentsPB = []*types.Department - MenuPB = types.Menu - MenusPB = []*types.Menu Permission = ent.Permission PermissionEdges = ent.PermissionEdges PermissionEdgesPB = types.PermissionEdges @@ -57,8 +55,6 @@ type ( Role = ent.Role RoleEdges = ent.RoleEdges RoleEdgesPB = types.RoleEdges - RoleMenuPB = types.RoleMenu - RoleMenusPB = []*types.RoleMenu RolePB = types.Role RolePermission = ent.RolePermission RolePermissionEdges = ent.RolePermissionEdges @@ -66,6 +62,8 @@ type ( RolePermissionPB = types.RolePermission RolePermissions = []*ent.RolePermission RolePermissionsPB = []*types.RolePermission + RoleViewPB = types.RoleView + RoleViewsPB = []*types.RoleView Roles = []*ent.Role RolesPB = []*types.Role User = ent.User @@ -94,7 +92,10 @@ type ( UsersPB = []*types.User View = ent.View ViewEdges = ent.ViewEdges + ViewEdgesPB = types.ViewEdges + ViewPB = types.View Views = []*ent.View + ViewsPB = []*types.View ) // ConvertDepartmentEdgesPBToDepartmentEdges converts DepartmentEdgesPB to DepartmentEdges. @@ -1152,6 +1153,103 @@ func ConvertUsersToUsersPB(froms Users) UsersPB { return tos } +// ConvertViewEdgesPBToViewEdges converts ViewEdgesPB to ViewEdges. +func ConvertViewEdgesPBToViewEdges(from *ViewEdgesPB) *ViewEdges { + if from == nil { + return nil + } + + to := &ViewEdges{ + Parent: ConvertViewPBToView(from.Parent), + Children: ConvertViewsPBToViews(from.Children), + Resources: ConvertResourcesPBToResources(from.Resources), + } + return to +} + +// ConvertViewEdgesToViewEdgesPB converts ViewEdges to ViewEdgesPB. +func ConvertViewEdgesToViewEdgesPB(from *ViewEdges) *ViewEdgesPB { + if from == nil { + return nil + } + + to := &ViewEdgesPB{ + Children: ConvertViewsToViewsPB(from.Children), + Parent: ConvertViewToViewPB(from.Parent), + Resources: ConvertResourcesToResourcesPB(from.Resources), + } + return to +} + +// ConvertViewPBToView converts ViewPB to View. +func ConvertViewPBToView(from *ViewPB) *View { + if from == nil { + return nil + } + + to := &View{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + ParentID: from.ParentId, + Keyword: from.Keyword, + Name: from.Name, + Type: from.Type, + Path: from.Path, + Icon: from.Icon, + Sequence: int(from.Sequence), + } + return to +} + +// ConvertViewToViewPB converts View to ViewPB. +func ConvertViewToViewPB(from *View) *ViewPB { + if from == nil { + return nil + } + + to := &ViewPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Sequence: int32(from.Sequence), + Type: from.Type, + Icon: from.Icon, + Path: from.Path, + ParentId: from.ParentID, + Children: ConvertViewsToViewsPB(from.Edges.Children), + Parent: ConvertViewToViewPB(from.Edges.Parent), + Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), + } + return to +} + +// ConvertViewsPBToViews converts a slice of *ViewPB to a slice of *View. +func ConvertViewsPBToViews(froms ViewsPB) Views { + if froms == nil { + return nil + } + tos := make(Views, len(froms)) + for i, f := range froms { + tos[i] = ConvertViewPBToView(f) + } + return tos +} + +// ConvertViewsToViewsPB converts a slice of *View to a slice of *ViewPB. +func ConvertViewsToViewsPB(froms Views) ViewsPB { + if froms == nil { + return nil + } + tos := make(ViewsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertViewToViewPB(f) + } + return tos +} + // --- Helper Functions --- func ConvertTimeToTimestamp(t time.Time) *timestamppb.Timestamp { From b8a6386c49b2aead7ba8a1be63c4686b49be0b10 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 15:29:29 +0800 Subject: [PATCH 085/158] feat(ent): add ViewPermission and ViewResource hook and intercept adapters --- internal/data/entity/ent/client.go | 428 +++- internal/data/entity/ent/database.go | 10 + internal/data/entity/ent/ent.go | 4 + internal/data/entity/ent/hook/hook.go | 24 + .../data/entity/ent/intercept/intercept.go | 60 + internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 206 +- internal/data/entity/ent/mutation.go | 2207 ++++++++++++++++- internal/data/entity/ent/mutation_fields.go | 161 +- internal/data/entity/ent/notification.go | 5 +- .../entity/ent/notification/notification.go | 3 +- .../data/entity/ent/notification/where.go | 52 +- .../data/entity/ent/notification_create.go | 5 +- .../data/entity/ent/notification_query.go | 2 +- .../data/entity/ent/notification_update.go | 13 +- internal/data/entity/ent/permission.go | 18 +- .../data/entity/ent/permission/permission.go | 36 +- internal/data/entity/ent/permission/where.go | 25 +- internal/data/entity/ent/permission_create.go | 41 +- internal/data/entity/ent/permission_query.go | 84 +- internal/data/entity/ent/permission_update.go | 217 +- .../data/entity/ent/predicate/predicate.go | 6 + internal/data/entity/ent/resource.go | 18 +- internal/data/entity/ent/resource/resource.go | 36 +- internal/data/entity/ent/resource/where.go | 25 +- internal/data/entity/ent/resource_create.go | 41 +- internal/data/entity/ent/resource_query.go | 112 +- internal/data/entity/ent/resource_update.go | 217 +- internal/data/entity/ent/role.go | 9 +- internal/data/entity/ent/role/role.go | 5 +- internal/data/entity/ent/role/where.go | 103 +- internal/data/entity/ent/role_create.go | 9 +- internal/data/entity/ent/role_query.go | 4 +- internal/data/entity/ent/role_update.go | 25 +- internal/data/entity/ent/runtime/runtime.go | 105 +- internal/data/entity/ent/schema/department.go | 9 - .../data/entity/ent/schema/notification.go | 4 +- internal/data/entity/ent/schema/permission.go | 5 +- .../entity/ent/schema/positionpermission.go | 2 - internal/data/entity/ent/schema/resource.go | 4 +- .../data/entity/ent/schema/rolepermission.go | 2 - .../data/entity/ent/schema/userdepartment.go | 2 - .../data/entity/ent/schema/userposition.go | 2 - internal/data/entity/ent/schema/userrole.go | 4 +- internal/data/entity/ent/schema/view.go | 8 +- .../data/entity/ent/schema/viewpermission.go | 61 + .../data/entity/ent/schema/viewresource.go | 62 + internal/data/entity/ent/tx.go | 6 + internal/data/entity/ent/user.go | 5 +- internal/data/entity/ent/user/user.go | 5 +- internal/data/entity/ent/user/where.go | 52 +- internal/data/entity/ent/user_create.go | 5 +- internal/data/entity/ent/user_query.go | 2 +- internal/data/entity/ent/user_update.go | 13 +- internal/data/entity/ent/userrole.go | 2 +- internal/data/entity/ent/view.go | 40 +- internal/data/entity/ent/view/view.go | 110 +- internal/data/entity/ent/view/where.go | 108 +- internal/data/entity/ent/view_create.go | 88 +- internal/data/entity/ent/view_query.go | 204 +- internal/data/entity/ent/view_update.go | 446 +++- 61 files changed, 5009 insertions(+), 560 deletions(-) create mode 100644 internal/data/entity/ent/schema/viewpermission.go create mode 100644 internal/data/entity/ent/schema/viewresource.go diff --git a/internal/data/entity/ent/client.go b/internal/data/entity/ent/client.go index 74ff704b..2d35c06e 100644 --- a/internal/data/entity/ent/client.go +++ b/internal/data/entity/ent/client.go @@ -26,6 +26,8 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/entity/ent/viewresource" "entgo.io/ent" "entgo.io/ent/dialect" @@ -68,6 +70,10 @@ type Client struct { UserRole *UserRoleClient // View is the client for interacting with the View builders. View *ViewClient + // ViewPermission is the client for interacting with the ViewPermission builders. + ViewPermission *ViewPermissionClient + // ViewResource is the client for interacting with the ViewResource builders. + ViewResource *ViewResourceClient } // NewClient creates a new client configured with the given options. @@ -94,6 +100,8 @@ func (c *Client) init() { c.UserPosition = NewUserPositionClient(c.config) c.UserRole = NewUserRoleClient(c.config) c.View = NewViewClient(c.config) + c.ViewPermission = NewViewPermissionClient(c.config) + c.ViewResource = NewViewResourceClient(c.config) } type ( @@ -201,6 +209,8 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) { UserPosition: NewUserPositionClient(cfg), UserRole: NewUserRoleClient(cfg), View: NewViewClient(cfg), + ViewPermission: NewViewPermissionClient(cfg), + ViewResource: NewViewResourceClient(cfg), }, nil } @@ -235,6 +245,8 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) UserPosition: NewUserPositionClient(cfg), UserRole: NewUserRoleClient(cfg), View: NewViewClient(cfg), + ViewPermission: NewViewPermissionClient(cfg), + ViewResource: NewViewResourceClient(cfg), }, nil } @@ -266,7 +278,8 @@ func (c *Client) Use(hooks ...Hook) { for _, n := range []interface{ Use(...Hook) }{ c.CasbinRule, c.Department, c.Notification, c.Permission, c.PermissionResource, c.Position, c.PositionPermission, c.Resource, c.Role, c.RolePermission, c.User, - c.UserDepartment, c.UserPosition, c.UserRole, c.View, + c.UserDepartment, c.UserPosition, c.UserRole, c.View, c.ViewPermission, + c.ViewResource, } { n.Use(hooks...) } @@ -278,7 +291,8 @@ func (c *Client) Intercept(interceptors ...Interceptor) { for _, n := range []interface{ Intercept(...Interceptor) }{ c.CasbinRule, c.Department, c.Notification, c.Permission, c.PermissionResource, c.Position, c.PositionPermission, c.Resource, c.Role, c.RolePermission, c.User, - c.UserDepartment, c.UserPosition, c.UserRole, c.View, + c.UserDepartment, c.UserPosition, c.UserRole, c.View, c.ViewPermission, + c.ViewResource, } { n.Intercept(interceptors...) } @@ -317,6 +331,10 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { return c.UserRole.mutate(ctx, m) case *ViewMutation: return c.View.mutate(ctx, m) + case *ViewPermissionMutation: + return c.ViewPermission.mutate(ctx, m) + case *ViewResourceMutation: + return c.ViewResource.mutate(ctx, m) default: return nil, fmt.Errorf("ent: unknown mutation type %T", m) } @@ -965,7 +983,7 @@ func (c *PermissionClient) QueryViews(_m *Permission) *ViewQuery { step := sqlgraph.NewStep( sqlgraph.From(permission.Table, permission.FieldID, id), sqlgraph.To(view.Table, view.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, permission.ViewsTable, permission.ViewsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, permission.ViewsTable, permission.ViewsPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -1021,6 +1039,22 @@ func (c *PermissionClient) QueryPermissionResources(_m *Permission) *PermissionR return query } +// QueryViewPermissions queries the view_permissions edge of a Permission. +func (c *PermissionClient) QueryViewPermissions(_m *Permission) *ViewPermissionQuery { + query := (&ViewPermissionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, id), + sqlgraph.To(viewpermission.Table, viewpermission.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, permission.ViewPermissionsTable, permission.ViewPermissionsColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *PermissionClient) Hooks() []Hook { return c.hooks.Permission @@ -1705,7 +1739,7 @@ func (c *ResourceClient) QueryViews(_m *Resource) *ViewQuery { step := sqlgraph.NewStep( sqlgraph.From(resource.Table, resource.FieldID, id), sqlgraph.To(view.Table, view.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, resource.ViewsTable, resource.ViewsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, resource.ViewsTable, resource.ViewsPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -1729,6 +1763,22 @@ func (c *ResourceClient) QueryPermissions(_m *Resource) *PermissionQuery { return query } +// QueryViewResources queries the view_resources edge of a Resource. +func (c *ResourceClient) QueryViewResources(_m *Resource) *ViewResourceQuery { + query := (&ViewResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, id), + sqlgraph.To(viewresource.Table, viewresource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, resource.ViewResourcesTable, resource.ViewResourcesColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + // Hooks returns the client hooks. func (c *ResourceClient) Hooks() []Hook { return c.hooks.Resource @@ -2990,7 +3040,7 @@ func (c *ViewClient) QueryResources(_m *View) *ResourceQuery { step := sqlgraph.NewStep( sqlgraph.From(view.Table, view.FieldID, id), sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, view.ResourcesTable, view.ResourcesPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, false, view.ResourcesTable, view.ResourcesPrimaryKey...), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -3006,7 +3056,39 @@ func (c *ViewClient) QueryPermissions(_m *View) *PermissionQuery { step := sqlgraph.NewStep( sqlgraph.From(view.Table, view.FieldID, id), sqlgraph.To(permission.Table, permission.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, view.PermissionsTable, view.PermissionsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, false, view.PermissionsTable, view.PermissionsPrimaryKey...), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryViewResources queries the view_resources edge of a View. +func (c *ViewClient) QueryViewResources(_m *View) *ViewResourceQuery { + query := (&ViewResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, id), + sqlgraph.To(viewresource.Table, viewresource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, view.ViewResourcesTable, view.ViewResourcesColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryViewPermissions queries the view_permissions edge of a View. +func (c *ViewClient) QueryViewPermissions(_m *View) *ViewPermissionQuery { + query := (&ViewPermissionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, id), + sqlgraph.To(viewpermission.Table, viewpermission.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, view.ViewPermissionsTable, view.ViewPermissionsColumn), ) fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil @@ -3039,16 +3121,346 @@ func (c *ViewClient) mutate(ctx context.Context, m *ViewMutation) (Value, error) } } +// ViewPermissionClient is a client for the ViewPermission schema. +type ViewPermissionClient struct { + config +} + +// NewViewPermissionClient returns a client for the ViewPermission from the given config. +func NewViewPermissionClient(c config) *ViewPermissionClient { + return &ViewPermissionClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `viewpermission.Hooks(f(g(h())))`. +func (c *ViewPermissionClient) Use(hooks ...Hook) { + c.hooks.ViewPermission = append(c.hooks.ViewPermission, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `viewpermission.Intercept(f(g(h())))`. +func (c *ViewPermissionClient) Intercept(interceptors ...Interceptor) { + c.inters.ViewPermission = append(c.inters.ViewPermission, interceptors...) +} + +// Create returns a builder for creating a ViewPermission entity. +func (c *ViewPermissionClient) Create() *ViewPermissionCreate { + mutation := newViewPermissionMutation(c.config, OpCreate) + return &ViewPermissionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ViewPermission entities. +func (c *ViewPermissionClient) CreateBulk(builders ...*ViewPermissionCreate) *ViewPermissionCreateBulk { + return &ViewPermissionCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ViewPermissionClient) MapCreateBulk(slice any, setFunc func(*ViewPermissionCreate, int)) *ViewPermissionCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ViewPermissionCreateBulk{err: fmt.Errorf("calling to ViewPermissionClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ViewPermissionCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ViewPermissionCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ViewPermission. +func (c *ViewPermissionClient) Update() *ViewPermissionUpdate { + mutation := newViewPermissionMutation(c.config, OpUpdate) + return &ViewPermissionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ViewPermissionClient) UpdateOne(_m *ViewPermission) *ViewPermissionUpdateOne { + mutation := newViewPermissionMutation(c.config, OpUpdateOne, withViewPermission(_m)) + return &ViewPermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ViewPermissionClient) UpdateOneID(id int64) *ViewPermissionUpdateOne { + mutation := newViewPermissionMutation(c.config, OpUpdateOne, withViewPermissionID(id)) + return &ViewPermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ViewPermission. +func (c *ViewPermissionClient) Delete() *ViewPermissionDelete { + mutation := newViewPermissionMutation(c.config, OpDelete) + return &ViewPermissionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ViewPermissionClient) DeleteOne(_m *ViewPermission) *ViewPermissionDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ViewPermissionClient) DeleteOneID(id int64) *ViewPermissionDeleteOne { + builder := c.Delete().Where(viewpermission.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ViewPermissionDeleteOne{builder} +} + +// Query returns a query builder for ViewPermission. +func (c *ViewPermissionClient) Query() *ViewPermissionQuery { + return &ViewPermissionQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeViewPermission}, + inters: c.Interceptors(), + } +} + +// Get returns a ViewPermission entity by its id. +func (c *ViewPermissionClient) Get(ctx context.Context, id int64) (*ViewPermission, error) { + return c.Query().Where(viewpermission.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ViewPermissionClient) GetX(ctx context.Context, id int64) *ViewPermission { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryView queries the view edge of a ViewPermission. +func (c *ViewPermissionClient) QueryView(_m *ViewPermission) *ViewQuery { + query := (&ViewClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(viewpermission.Table, viewpermission.FieldID, id), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, viewpermission.ViewTable, viewpermission.ViewColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryPermission queries the permission edge of a ViewPermission. +func (c *ViewPermissionClient) QueryPermission(_m *ViewPermission) *PermissionQuery { + query := (&PermissionClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(viewpermission.Table, viewpermission.FieldID, id), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, viewpermission.PermissionTable, viewpermission.PermissionColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ViewPermissionClient) Hooks() []Hook { + return c.hooks.ViewPermission +} + +// Interceptors returns the client interceptors. +func (c *ViewPermissionClient) Interceptors() []Interceptor { + return c.inters.ViewPermission +} + +func (c *ViewPermissionClient) mutate(ctx context.Context, m *ViewPermissionMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ViewPermissionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ViewPermissionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ViewPermissionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ViewPermissionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ViewPermission mutation op: %q", m.Op()) + } +} + +// ViewResourceClient is a client for the ViewResource schema. +type ViewResourceClient struct { + config +} + +// NewViewResourceClient returns a client for the ViewResource from the given config. +func NewViewResourceClient(c config) *ViewResourceClient { + return &ViewResourceClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `viewresource.Hooks(f(g(h())))`. +func (c *ViewResourceClient) Use(hooks ...Hook) { + c.hooks.ViewResource = append(c.hooks.ViewResource, hooks...) +} + +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `viewresource.Intercept(f(g(h())))`. +func (c *ViewResourceClient) Intercept(interceptors ...Interceptor) { + c.inters.ViewResource = append(c.inters.ViewResource, interceptors...) +} + +// Create returns a builder for creating a ViewResource entity. +func (c *ViewResourceClient) Create() *ViewResourceCreate { + mutation := newViewResourceMutation(c.config, OpCreate) + return &ViewResourceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of ViewResource entities. +func (c *ViewResourceClient) CreateBulk(builders ...*ViewResourceCreate) *ViewResourceCreateBulk { + return &ViewResourceCreateBulk{config: c.config, builders: builders} +} + +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *ViewResourceClient) MapCreateBulk(slice any, setFunc func(*ViewResourceCreate, int)) *ViewResourceCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &ViewResourceCreateBulk{err: fmt.Errorf("calling to ViewResourceClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*ViewResourceCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &ViewResourceCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for ViewResource. +func (c *ViewResourceClient) Update() *ViewResourceUpdate { + mutation := newViewResourceMutation(c.config, OpUpdate) + return &ViewResourceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ViewResourceClient) UpdateOne(_m *ViewResource) *ViewResourceUpdateOne { + mutation := newViewResourceMutation(c.config, OpUpdateOne, withViewResource(_m)) + return &ViewResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ViewResourceClient) UpdateOneID(id int64) *ViewResourceUpdateOne { + mutation := newViewResourceMutation(c.config, OpUpdateOne, withViewResourceID(id)) + return &ViewResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for ViewResource. +func (c *ViewResourceClient) Delete() *ViewResourceDelete { + mutation := newViewResourceMutation(c.config, OpDelete) + return &ViewResourceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ViewResourceClient) DeleteOne(_m *ViewResource) *ViewResourceDeleteOne { + return c.DeleteOneID(_m.ID) +} + +// DeleteOneID returns a builder for deleting the given entity by its id. +func (c *ViewResourceClient) DeleteOneID(id int64) *ViewResourceDeleteOne { + builder := c.Delete().Where(viewresource.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ViewResourceDeleteOne{builder} +} + +// Query returns a query builder for ViewResource. +func (c *ViewResourceClient) Query() *ViewResourceQuery { + return &ViewResourceQuery{ + config: c.config, + ctx: &QueryContext{Type: TypeViewResource}, + inters: c.Interceptors(), + } +} + +// Get returns a ViewResource entity by its id. +func (c *ViewResourceClient) Get(ctx context.Context, id int64) (*ViewResource, error) { + return c.Query().Where(viewresource.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ViewResourceClient) GetX(ctx context.Context, id int64) *ViewResource { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// QueryView queries the view edge of a ViewResource. +func (c *ViewResourceClient) QueryView(_m *ViewResource) *ViewQuery { + query := (&ViewClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(viewresource.Table, viewresource.FieldID, id), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, viewresource.ViewTable, viewresource.ViewColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryResource queries the resource edge of a ViewResource. +func (c *ViewResourceClient) QueryResource(_m *ViewResource) *ResourceQuery { + query := (&ResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(viewresource.Table, viewresource.FieldID, id), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, viewresource.ResourceTable, viewresource.ResourceColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// Hooks returns the client hooks. +func (c *ViewResourceClient) Hooks() []Hook { + return c.hooks.ViewResource +} + +// Interceptors returns the client interceptors. +func (c *ViewResourceClient) Interceptors() []Interceptor { + return c.inters.ViewResource +} + +func (c *ViewResourceClient) mutate(ctx context.Context, m *ViewResourceMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&ViewResourceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&ViewResourceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&ViewResourceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&ViewResourceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown ViewResource mutation op: %q", m.Op()) + } +} + // hooks and interceptors per client, for fast access. type ( hooks struct { CasbinRule, Department, Notification, Permission, PermissionResource, Position, PositionPermission, Resource, Role, RolePermission, User, UserDepartment, - UserPosition, UserRole, View []ent.Hook + UserPosition, UserRole, View, ViewPermission, ViewResource []ent.Hook } inters struct { CasbinRule, Department, Notification, Permission, PermissionResource, Position, PositionPermission, Resource, Role, RolePermission, User, UserDepartment, - UserPosition, UserRole, View []ent.Interceptor + UserPosition, UserRole, View, ViewPermission, ViewResource []ent.Interceptor } ) diff --git a/internal/data/entity/ent/database.go b/internal/data/entity/ent/database.go index 301afd74..7e48f769 100644 --- a/internal/data/entity/ent/database.go +++ b/internal/data/entity/ent/database.go @@ -184,6 +184,16 @@ func (db *Database) View(ctx context.Context) *ViewClient { return db.Client(ctx).View } +// ViewPermission is the client for interacting with the ViewPermission builders. +func (db *Database) ViewPermission(ctx context.Context) *ViewPermissionClient { + return db.Client(ctx).ViewPermission +} + +// ViewResource is the client for interacting with the ViewResource builders. +func (db *Database) ViewResource(ctx context.Context) *ViewResourceClient { + return db.Client(ctx).ViewResource +} + func (db *Database) Migration(ctx context.Context, opts ...schema.MigrateOption) error { return db.Client(ctx).Schema.Create(ctx, opts...) } diff --git a/internal/data/entity/ent/ent.go b/internal/data/entity/ent/ent.go index 8a40552a..0a0471cf 100644 --- a/internal/data/entity/ent/ent.go +++ b/internal/data/entity/ent/ent.go @@ -21,6 +21,8 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/entity/ent/viewresource" "reflect" "sync" @@ -102,6 +104,8 @@ func checkColumn(t, c string) error { userposition.Table: userposition.ValidColumn, userrole.Table: userrole.ValidColumn, view.Table: view.ValidColumn, + viewpermission.Table: viewpermission.ValidColumn, + viewresource.Table: viewresource.ValidColumn, }) }) return columnCheck(t, c) diff --git a/internal/data/entity/ent/hook/hook.go b/internal/data/entity/ent/hook/hook.go index 46cf2869..38e072e4 100644 --- a/internal/data/entity/ent/hook/hook.go +++ b/internal/data/entity/ent/hook/hook.go @@ -188,6 +188,30 @@ func (f ViewFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ViewMutation", m) } +// The ViewPermissionFunc type is an adapter to allow the use of ordinary +// function as ViewPermission mutator. +type ViewPermissionFunc func(context.Context, *ent.ViewPermissionMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ViewPermissionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ViewPermissionMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ViewPermissionMutation", m) +} + +// The ViewResourceFunc type is an adapter to allow the use of ordinary +// function as ViewResource mutator. +type ViewResourceFunc func(context.Context, *ent.ViewResourceMutation) (ent.Value, error) + +// Mutate calls f(ctx, m). +func (f ViewResourceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { + if mv, ok := m.(*ent.ViewResourceMutation); ok { + return f(ctx, mv) + } + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ViewResourceMutation", m) +} + // Condition is a hook condition function. type Condition func(context.Context, ent.Mutation) bool diff --git a/internal/data/entity/ent/intercept/intercept.go b/internal/data/entity/ent/intercept/intercept.go index b17fc3b2..8c62d3d7 100644 --- a/internal/data/entity/ent/intercept/intercept.go +++ b/internal/data/entity/ent/intercept/intercept.go @@ -23,6 +23,8 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/entity/ent/viewresource" "entgo.io/ent/dialect/sql" ) @@ -488,6 +490,60 @@ func (f TraverseView) Traverse(ctx context.Context, q ent.Query) error { return fmt.Errorf("unexpected query type %T. expect *ent.ViewQuery", q) } +// The ViewPermissionFunc type is an adapter to allow the use of ordinary function as a Querier. +type ViewPermissionFunc func(context.Context, *ent.ViewPermissionQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ViewPermissionFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ViewPermissionQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ViewPermissionQuery", q) +} + +// The TraverseViewPermission type is an adapter to allow the use of ordinary function as Traverser. +type TraverseViewPermission func(context.Context, *ent.ViewPermissionQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseViewPermission) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseViewPermission) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ViewPermissionQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ViewPermissionQuery", q) +} + +// The ViewResourceFunc type is an adapter to allow the use of ordinary function as a Querier. +type ViewResourceFunc func(context.Context, *ent.ViewResourceQuery) (ent.Value, error) + +// Query calls f(ctx, q). +func (f ViewResourceFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) { + if q, ok := q.(*ent.ViewResourceQuery); ok { + return f(ctx, q) + } + return nil, fmt.Errorf("unexpected query type %T. expect *ent.ViewResourceQuery", q) +} + +// The TraverseViewResource type is an adapter to allow the use of ordinary function as Traverser. +type TraverseViewResource func(context.Context, *ent.ViewResourceQuery) error + +// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline. +func (f TraverseViewResource) Intercept(next ent.Querier) ent.Querier { + return next +} + +// Traverse calls f(ctx, q). +func (f TraverseViewResource) Traverse(ctx context.Context, q ent.Query) error { + if q, ok := q.(*ent.ViewResourceQuery); ok { + return f(ctx, q) + } + return fmt.Errorf("unexpected query type %T. expect *ent.ViewResourceQuery", q) +} + // NewQuery returns the generic Query interface for the given typed query. func NewQuery(q ent.Query) (Query, error) { switch q := q.(type) { @@ -521,6 +577,10 @@ func NewQuery(q ent.Query) (Query, error) { return &query[*ent.UserRoleQuery, predicate.UserRole, userrole.OrderOption]{typ: ent.TypeUserRole, tq: q}, nil case *ent.ViewQuery: return &query[*ent.ViewQuery, predicate.View, view.OrderOption]{typ: ent.TypeView, tq: q}, nil + case *ent.ViewPermissionQuery: + return &query[*ent.ViewPermissionQuery, predicate.ViewPermission, viewpermission.OrderOption]{typ: ent.TypeViewPermission, tq: q}, nil + case *ent.ViewResourceQuery: + return &query[*ent.ViewResourceQuery, predicate.ViewResource, viewresource.OrderOption]{typ: ent.TypeViewResource, tq: q}, nil default: return nil, fmt.Errorf("unknown query type %T", q) } diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index 65b98eec..47ef9a77 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\"}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"fields\":[\"permission_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\"},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"role_id\"]},{\"fields\":[\"permission_id\"]},{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"department_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"position_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"fields\":[\"user_id\"]},{\"fields\":[\"role_id\"]},{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.(1).(2).(3)\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"ref_name\":\"views\",\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"views\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1,\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index b920d30b..1ced4cfe 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -257,16 +257,6 @@ var ( }, }, Indexes: []*schema.Index{ - { - Name: "positionpermission_permission_id", - Unique: false, - Columns: []*schema.Column{SysPositionPermissionsColumns[2]}, - }, - { - Name: "positionpermission_position_id", - Unique: false, - Columns: []*schema.Column{SysPositionPermissionsColumns[1]}, - }, { Name: "positionpermission_position_id_permission_id", Unique: true, @@ -386,16 +376,6 @@ var ( }, }, Indexes: []*schema.Index{ - { - Name: "rolepermission_role_id", - Unique: false, - Columns: []*schema.Column{SysRolePermissionsColumns[1]}, - }, - { - Name: "rolepermission_permission_id", - Unique: false, - Columns: []*schema.Column{SysRolePermissionsColumns[2]}, - }, { Name: "rolepermission_role_id_permission_id", Unique: true, @@ -510,16 +490,6 @@ var ( }, }, Indexes: []*schema.Index{ - { - Name: "userdepartment_user_id", - Unique: false, - Columns: []*schema.Column{SysUserDepartmentsColumns[1]}, - }, - { - Name: "userdepartment_department_id", - Unique: false, - Columns: []*schema.Column{SysUserDepartmentsColumns[2]}, - }, { Name: "userdepartment_user_id_department_id", Unique: true, @@ -554,16 +524,6 @@ var ( }, }, Indexes: []*schema.Index{ - { - Name: "userposition_user_id", - Unique: false, - Columns: []*schema.Column{SysUserPositionsColumns[1]}, - }, - { - Name: "userposition_position_id", - Unique: false, - Columns: []*schema.Column{SysUserPositionsColumns[2]}, - }, { Name: "userposition_user_id_position_id", Unique: true, @@ -580,7 +540,7 @@ var ( // SysUserRolesTable holds the schema information for the "sys_user_roles" table. SysUserRolesTable = &schema.Table{ Name: "sys_user_roles", - Comment: "entity.(1).(2).(3)", + Comment: "entity.user_role.table.comment", Columns: SysUserRolesColumns, PrimaryKey: []*schema.Column{SysUserRolesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ @@ -598,16 +558,6 @@ var ( }, }, Indexes: []*schema.Index{ - { - Name: "userrole_user_id", - Unique: false, - Columns: []*schema.Column{SysUserRolesColumns[1]}, - }, - { - Name: "userrole_role_id", - Unique: false, - Columns: []*schema.Column{SysUserRolesColumns[2]}, - }, { Name: "userrole_user_id_role_id", Unique: true, @@ -623,7 +573,7 @@ var ( {Name: "keyword", Type: field.TypeString, Unique: true}, {Name: "scope", Type: field.TypeString, Default: "default"}, {Name: "name", Type: field.TypeString}, - {Name: "type", Type: field.TypeString, Size: 1, Default: "U"}, + {Name: "type", Type: field.TypeEnum, Enums: []string{"T", "G", "M", "L", "P", "B", "E", "R", "U"}, Default: "U"}, {Name: "component", Type: field.TypeString, Nullable: true}, {Name: "path", Type: field.TypeString, Nullable: true}, {Name: "icon", Type: field.TypeString, Nullable: true}, @@ -657,53 +607,119 @@ var ( }, }, } - // PermissionViewsColumns holds the columns for the "permission_views" table. - PermissionViewsColumns = []*schema.Column{ - {Name: "permission_id", Type: field.TypeInt64}, - {Name: "view_id", Type: field.TypeInt64}, - } - // PermissionViewsTable holds the schema information for the "permission_views" table. - PermissionViewsTable = &schema.Table{ - Name: "permission_views", - Columns: PermissionViewsColumns, - PrimaryKey: []*schema.Column{PermissionViewsColumns[0], PermissionViewsColumns[1]}, + // SysViewPermissionsColumns holds the columns for the "sys_view_permissions" table. + SysViewPermissionsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, + {Name: "create_author", Type: field.TypeInt64, Nullable: true, Comment: "create_author.field.comment", Default: 0}, + {Name: "update_author", Type: field.TypeInt64, Nullable: true, Comment: "update_author.field.comment", Default: 0}, + {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, + {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, + {Name: "view_id", Type: field.TypeInt64, Comment: "view_permission.view_id.comment"}, + {Name: "permission_id", Type: field.TypeInt64, Comment: "view_permission.permission_id.comment"}, + } + // SysViewPermissionsTable holds the schema information for the "sys_view_permissions" table. + SysViewPermissionsTable = &schema.Table{ + Name: "sys_view_permissions", + Comment: "entity.view_permission.table.comment", + Columns: SysViewPermissionsColumns, + PrimaryKey: []*schema.Column{SysViewPermissionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "permission_views_permission_id", - Columns: []*schema.Column{PermissionViewsColumns[0]}, + Symbol: "sys_view_permissions_views_view", + Columns: []*schema.Column{SysViewPermissionsColumns[5]}, + RefColumns: []*schema.Column{ViewsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "sys_view_permissions_sys_permissions_permission", + Columns: []*schema.Column{SysViewPermissionsColumns[6]}, RefColumns: []*schema.Column{SysPermissionsColumns[0]}, - OnDelete: schema.Cascade, + OnDelete: schema.NoAction, + }, + }, + Indexes: []*schema.Index{ + { + Name: "viewpermission_create_author", + Unique: false, + Columns: []*schema.Column{SysViewPermissionsColumns[1]}, }, { - Symbol: "permission_views_view_id", - Columns: []*schema.Column{PermissionViewsColumns[1]}, - RefColumns: []*schema.Column{ViewsColumns[0]}, - OnDelete: schema.Cascade, + Name: "viewpermission_update_author", + Unique: false, + Columns: []*schema.Column{SysViewPermissionsColumns[2]}, + }, + { + Name: "viewpermission_create_time", + Unique: false, + Columns: []*schema.Column{SysViewPermissionsColumns[3]}, + }, + { + Name: "viewpermission_update_time", + Unique: false, + Columns: []*schema.Column{SysViewPermissionsColumns[4]}, + }, + { + Name: "viewpermission_view_id_permission_id", + Unique: true, + Columns: []*schema.Column{SysViewPermissionsColumns[5], SysViewPermissionsColumns[6]}, }, }, } - // ResourceViewsColumns holds the columns for the "resource_views" table. - ResourceViewsColumns = []*schema.Column{ - {Name: "resource_id", Type: field.TypeInt64}, - {Name: "view_id", Type: field.TypeInt64}, - } - // ResourceViewsTable holds the schema information for the "resource_views" table. - ResourceViewsTable = &schema.Table{ - Name: "resource_views", - Columns: ResourceViewsColumns, - PrimaryKey: []*schema.Column{ResourceViewsColumns[0], ResourceViewsColumns[1]}, + // SysViewResourcesColumns holds the columns for the "sys_view_resources" table. + SysViewResourcesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, + {Name: "create_author", Type: field.TypeInt64, Nullable: true, Comment: "create_author.field.comment", Default: 0}, + {Name: "update_author", Type: field.TypeInt64, Nullable: true, Comment: "update_author.field.comment", Default: 0}, + {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, + {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, + {Name: "view_id", Type: field.TypeInt64, Comment: "view_resource.view_id.comment"}, + {Name: "resource_id", Type: field.TypeInt64, Comment: "view_resource.resource_id.comment"}, + } + // SysViewResourcesTable holds the schema information for the "sys_view_resources" table. + SysViewResourcesTable = &schema.Table{ + Name: "sys_view_resources", + Comment: "entity.view_resource.table.comment", + Columns: SysViewResourcesColumns, + PrimaryKey: []*schema.Column{SysViewResourcesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "resource_views_resource_id", - Columns: []*schema.Column{ResourceViewsColumns[0]}, + Symbol: "sys_view_resources_views_view", + Columns: []*schema.Column{SysViewResourcesColumns[5]}, + RefColumns: []*schema.Column{ViewsColumns[0]}, + OnDelete: schema.NoAction, + }, + { + Symbol: "sys_view_resources_resources_resource", + Columns: []*schema.Column{SysViewResourcesColumns[6]}, RefColumns: []*schema.Column{ResourcesColumns[0]}, - OnDelete: schema.Cascade, + OnDelete: schema.NoAction, }, + }, + Indexes: []*schema.Index{ { - Symbol: "resource_views_view_id", - Columns: []*schema.Column{ResourceViewsColumns[1]}, - RefColumns: []*schema.Column{ViewsColumns[0]}, - OnDelete: schema.Cascade, + Name: "viewresource_create_author", + Unique: false, + Columns: []*schema.Column{SysViewResourcesColumns[1]}, + }, + { + Name: "viewresource_update_author", + Unique: false, + Columns: []*schema.Column{SysViewResourcesColumns[2]}, + }, + { + Name: "viewresource_create_time", + Unique: false, + Columns: []*schema.Column{SysViewResourcesColumns[3]}, + }, + { + Name: "viewresource_update_time", + Unique: false, + Columns: []*schema.Column{SysViewResourcesColumns[4]}, + }, + { + Name: "viewresource_view_id_resource_id", + Unique: true, + Columns: []*schema.Column{SysViewResourcesColumns[5], SysViewResourcesColumns[6]}, }, }, } @@ -724,8 +740,8 @@ var ( SysUserPositionsTable, SysUserRolesTable, ViewsTable, - PermissionViewsTable, - ResourceViewsTable, + SysViewPermissionsTable, + SysViewResourcesTable, } ) @@ -781,8 +797,14 @@ func init() { Table: "sys_user_roles", } ViewsTable.ForeignKeys[0].RefTable = ViewsTable - PermissionViewsTable.ForeignKeys[0].RefTable = SysPermissionsTable - PermissionViewsTable.ForeignKeys[1].RefTable = ViewsTable - ResourceViewsTable.ForeignKeys[0].RefTable = ResourcesTable - ResourceViewsTable.ForeignKeys[1].RefTable = ViewsTable + SysViewPermissionsTable.ForeignKeys[0].RefTable = ViewsTable + SysViewPermissionsTable.ForeignKeys[1].RefTable = SysPermissionsTable + SysViewPermissionsTable.Annotation = &entsql.Annotation{ + Table: "sys_view_permissions", + } + SysViewResourcesTable.ForeignKeys[0].RefTable = ViewsTable + SysViewResourcesTable.ForeignKeys[1].RefTable = ResourcesTable + SysViewResourcesTable.Annotation = &entsql.Annotation{ + Table: "sys_view_resources", + } } diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index 01505b9e..1f4209f1 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -22,6 +22,9 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/entity/ent/viewresource" + "origadmin/application/admin/internal/data/enums" "sync" "time" @@ -53,6 +56,8 @@ const ( TypeUserPosition = "UserPosition" TypeUserRole = "UserRole" TypeView = "View" + TypeViewPermission = "ViewPermission" + TypeViewResource = "ViewResource" ) // CasbinRuleMutation represents an operation that mutates the CasbinRule nodes in the graph. @@ -2049,8 +2054,8 @@ type NotificationMutation struct { update_time *time.Time subject *string content *string - status *int8 - addstatus *int8 + status *enums.Status + addstatus *enums.Status category_id *int64 addcategory_id *int64 clearedFields map[string]struct{} @@ -2448,13 +2453,13 @@ func (m *NotificationMutation) ResetContent() { } // SetStatus sets the "status" field. -func (m *NotificationMutation) SetStatus(i int8) { - m.status = &i +func (m *NotificationMutation) SetStatus(e enums.Status) { + m.status = &e m.addstatus = nil } // Status returns the value of the "status" field in the mutation. -func (m *NotificationMutation) Status() (r int8, exists bool) { +func (m *NotificationMutation) Status() (r enums.Status, exists bool) { v := m.status if v == nil { return @@ -2465,7 +2470,7 @@ func (m *NotificationMutation) Status() (r int8, exists bool) { // OldStatus returns the old "status" field's value of the Notification entity. // If the Notification object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NotificationMutation) OldStatus(ctx context.Context) (v int8, err error) { +func (m *NotificationMutation) OldStatus(ctx context.Context) (v enums.Status, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStatus is only allowed on UpdateOne operations") } @@ -2479,17 +2484,17 @@ func (m *NotificationMutation) OldStatus(ctx context.Context) (v int8, err error return oldValue.Status, nil } -// AddStatus adds i to the "status" field. -func (m *NotificationMutation) AddStatus(i int8) { +// AddStatus adds e to the "status" field. +func (m *NotificationMutation) AddStatus(e enums.Status) { if m.addstatus != nil { - *m.addstatus += i + *m.addstatus += e } else { - m.addstatus = &i + m.addstatus = &e } } // AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *NotificationMutation) AddedStatus() (r int8, exists bool) { +func (m *NotificationMutation) AddedStatus() (r enums.Status, exists bool) { v := m.addstatus if v == nil { return @@ -2719,7 +2724,7 @@ func (m *NotificationMutation) SetField(name string, value ent.Value) error { m.SetContent(v) return nil case notification.FieldStatus: - v, ok := value.(int8) + v, ok := value.(enums.Status) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -2792,7 +2797,7 @@ func (m *NotificationMutation) AddField(name string, value ent.Value) error { m.AddUpdateAuthor(v) return nil case notification.FieldStatus: - v, ok := value.(int8) + v, ok := value.(enums.Status) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -2959,6 +2964,9 @@ type PermissionMutation struct { permission_resources map[int]struct{} removedpermission_resources map[int]struct{} clearedpermission_resources bool + view_permissions map[int64]struct{} + removedview_permissions map[int64]struct{} + clearedview_permissions bool done bool oldValue func(context.Context) (*Permission, error) predicates []predicate.Permission @@ -3747,6 +3755,60 @@ func (m *PermissionMutation) ResetPermissionResources() { m.removedpermission_resources = nil } +// AddViewPermissionIDs adds the "view_permissions" edge to the ViewPermission entity by ids. +func (m *PermissionMutation) AddViewPermissionIDs(ids ...int64) { + if m.view_permissions == nil { + m.view_permissions = make(map[int64]struct{}) + } + for i := range ids { + m.view_permissions[ids[i]] = struct{}{} + } +} + +// ClearViewPermissions clears the "view_permissions" edge to the ViewPermission entity. +func (m *PermissionMutation) ClearViewPermissions() { + m.clearedview_permissions = true +} + +// ViewPermissionsCleared reports if the "view_permissions" edge to the ViewPermission entity was cleared. +func (m *PermissionMutation) ViewPermissionsCleared() bool { + return m.clearedview_permissions +} + +// RemoveViewPermissionIDs removes the "view_permissions" edge to the ViewPermission entity by IDs. +func (m *PermissionMutation) RemoveViewPermissionIDs(ids ...int64) { + if m.removedview_permissions == nil { + m.removedview_permissions = make(map[int64]struct{}) + } + for i := range ids { + delete(m.view_permissions, ids[i]) + m.removedview_permissions[ids[i]] = struct{}{} + } +} + +// RemovedViewPermissions returns the removed IDs of the "view_permissions" edge to the ViewPermission entity. +func (m *PermissionMutation) RemovedViewPermissionsIDs() (ids []int64) { + for id := range m.removedview_permissions { + ids = append(ids, id) + } + return +} + +// ViewPermissionsIDs returns the "view_permissions" edge IDs in the mutation. +func (m *PermissionMutation) ViewPermissionsIDs() (ids []int64) { + for id := range m.view_permissions { + ids = append(ids, id) + } + return +} + +// ResetViewPermissions resets all changes to the "view_permissions" edge. +func (m *PermissionMutation) ResetViewPermissions() { + m.view_permissions = nil + m.clearedview_permissions = false + m.removedview_permissions = nil +} + // Where appends a list predicates to the PermissionMutation builder. func (m *PermissionMutation) Where(ps ...predicate.Permission) { m.predicates = append(m.predicates, ps...) @@ -4008,7 +4070,7 @@ func (m *PermissionMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *PermissionMutation) AddedEdges() []string { - edges := make([]string, 0, 7) + edges := make([]string, 0, 8) if m.roles != nil { edges = append(edges, permission.EdgeRoles) } @@ -4030,6 +4092,9 @@ func (m *PermissionMutation) AddedEdges() []string { if m.permission_resources != nil { edges = append(edges, permission.EdgePermissionResources) } + if m.view_permissions != nil { + edges = append(edges, permission.EdgeViewPermissions) + } return edges } @@ -4079,13 +4144,19 @@ func (m *PermissionMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case permission.EdgeViewPermissions: + ids := make([]ent.Value, 0, len(m.view_permissions)) + for id := range m.view_permissions { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *PermissionMutation) RemovedEdges() []string { - edges := make([]string, 0, 7) + edges := make([]string, 0, 8) if m.removedroles != nil { edges = append(edges, permission.EdgeRoles) } @@ -4107,6 +4178,9 @@ func (m *PermissionMutation) RemovedEdges() []string { if m.removedpermission_resources != nil { edges = append(edges, permission.EdgePermissionResources) } + if m.removedview_permissions != nil { + edges = append(edges, permission.EdgeViewPermissions) + } return edges } @@ -4156,13 +4230,19 @@ func (m *PermissionMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case permission.EdgeViewPermissions: + ids := make([]ent.Value, 0, len(m.removedview_permissions)) + for id := range m.removedview_permissions { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *PermissionMutation) ClearedEdges() []string { - edges := make([]string, 0, 7) + edges := make([]string, 0, 8) if m.clearedroles { edges = append(edges, permission.EdgeRoles) } @@ -4184,6 +4264,9 @@ func (m *PermissionMutation) ClearedEdges() []string { if m.clearedpermission_resources { edges = append(edges, permission.EdgePermissionResources) } + if m.clearedview_permissions { + edges = append(edges, permission.EdgeViewPermissions) + } return edges } @@ -4205,6 +4288,8 @@ func (m *PermissionMutation) EdgeCleared(name string) bool { return m.clearedposition_permissions case permission.EdgePermissionResources: return m.clearedpermission_resources + case permission.EdgeViewPermissions: + return m.clearedview_permissions } return false } @@ -4242,6 +4327,9 @@ func (m *PermissionMutation) ResetEdge(name string) error { case permission.EdgePermissionResources: m.ResetPermissionResources() return nil + case permission.EdgeViewPermissions: + m.ResetViewPermissions() + return nil } return fmt.Errorf("unknown Permission edge %s", name) } @@ -6208,31 +6296,34 @@ func (m *PositionPermissionMutation) ResetEdge(name string) error { // ResourceMutation represents an operation that mutates the Resource nodes in the graph. type ResourceMutation struct { config - op Op - typ string - id *int64 - create_time *time.Time - update_time *time.Time - service_name *string - keyword *string - _path *string - method *string - operation *string - policy *string - version_id *string - last_sync_version_id *string - sync_status *string - status *resource.Status - clearedFields map[string]struct{} - views map[int64]struct{} - removedviews map[int64]struct{} - clearedviews bool - permissions map[int64]struct{} - removedpermissions map[int64]struct{} - clearedpermissions bool - done bool - oldValue func(context.Context) (*Resource, error) - predicates []predicate.Resource + op Op + typ string + id *int64 + create_time *time.Time + update_time *time.Time + service_name *string + keyword *string + _path *string + method *string + operation *string + policy *string + version_id *string + last_sync_version_id *string + sync_status *string + status *resource.Status + clearedFields map[string]struct{} + views map[int64]struct{} + removedviews map[int64]struct{} + clearedviews bool + permissions map[int64]struct{} + removedpermissions map[int64]struct{} + clearedpermissions bool + view_resources map[int64]struct{} + removedview_resources map[int64]struct{} + clearedview_resources bool + done bool + oldValue func(context.Context) (*Resource, error) + predicates []predicate.Resource } var _ ent.Mutation = (*ResourceMutation)(nil) @@ -6918,6 +7009,60 @@ func (m *ResourceMutation) ResetPermissions() { m.removedpermissions = nil } +// AddViewResourceIDs adds the "view_resources" edge to the ViewResource entity by ids. +func (m *ResourceMutation) AddViewResourceIDs(ids ...int64) { + if m.view_resources == nil { + m.view_resources = make(map[int64]struct{}) + } + for i := range ids { + m.view_resources[ids[i]] = struct{}{} + } +} + +// ClearViewResources clears the "view_resources" edge to the ViewResource entity. +func (m *ResourceMutation) ClearViewResources() { + m.clearedview_resources = true +} + +// ViewResourcesCleared reports if the "view_resources" edge to the ViewResource entity was cleared. +func (m *ResourceMutation) ViewResourcesCleared() bool { + return m.clearedview_resources +} + +// RemoveViewResourceIDs removes the "view_resources" edge to the ViewResource entity by IDs. +func (m *ResourceMutation) RemoveViewResourceIDs(ids ...int64) { + if m.removedview_resources == nil { + m.removedview_resources = make(map[int64]struct{}) + } + for i := range ids { + delete(m.view_resources, ids[i]) + m.removedview_resources[ids[i]] = struct{}{} + } +} + +// RemovedViewResources returns the removed IDs of the "view_resources" edge to the ViewResource entity. +func (m *ResourceMutation) RemovedViewResourcesIDs() (ids []int64) { + for id := range m.removedview_resources { + ids = append(ids, id) + } + return +} + +// ViewResourcesIDs returns the "view_resources" edge IDs in the mutation. +func (m *ResourceMutation) ViewResourcesIDs() (ids []int64) { + for id := range m.view_resources { + ids = append(ids, id) + } + return +} + +// ResetViewResources resets all changes to the "view_resources" edge. +func (m *ResourceMutation) ResetViewResources() { + m.view_resources = nil + m.clearedview_resources = false + m.removedview_resources = nil +} + // Where appends a list predicates to the ResourceMutation builder. func (m *ResourceMutation) Where(ps ...predicate.Resource) { m.predicates = append(m.predicates, ps...) @@ -7259,13 +7404,16 @@ func (m *ResourceMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *ResourceMutation) AddedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.views != nil { edges = append(edges, resource.EdgeViews) } if m.permissions != nil { edges = append(edges, resource.EdgePermissions) } + if m.view_resources != nil { + edges = append(edges, resource.EdgeViewResources) + } return edges } @@ -7285,19 +7433,28 @@ func (m *ResourceMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case resource.EdgeViewResources: + ids := make([]ent.Value, 0, len(m.view_resources)) + for id := range m.view_resources { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *ResourceMutation) RemovedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.removedviews != nil { edges = append(edges, resource.EdgeViews) } if m.removedpermissions != nil { edges = append(edges, resource.EdgePermissions) } + if m.removedview_resources != nil { + edges = append(edges, resource.EdgeViewResources) + } return edges } @@ -7317,19 +7474,28 @@ func (m *ResourceMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case resource.EdgeViewResources: + ids := make([]ent.Value, 0, len(m.removedview_resources)) + for id := range m.removedview_resources { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *ResourceMutation) ClearedEdges() []string { - edges := make([]string, 0, 2) + edges := make([]string, 0, 3) if m.clearedviews { edges = append(edges, resource.EdgeViews) } if m.clearedpermissions { edges = append(edges, resource.EdgePermissions) } + if m.clearedview_resources { + edges = append(edges, resource.EdgeViewResources) + } return edges } @@ -7341,6 +7507,8 @@ func (m *ResourceMutation) EdgeCleared(name string) bool { return m.clearedviews case resource.EdgePermissions: return m.clearedpermissions + case resource.EdgeViewResources: + return m.clearedview_resources } return false } @@ -7363,6 +7531,9 @@ func (m *ResourceMutation) ResetEdge(name string) error { case resource.EdgePermissions: m.ResetPermissions() return nil + case resource.EdgeViewResources: + m.ResetViewResources() + return nil } return fmt.Errorf("unknown Resource edge %s", name) } @@ -7378,12 +7549,12 @@ type RoleMutation struct { keyword *string name *string description *string - _type *int8 - add_type *int8 + _type *enums.RoleType + add_type *enums.RoleType sequence *int addsequence *int - status *int8 - addstatus *int8 + status *enums.Status + addstatus *enums.Status clearedFields map[string]struct{} users map[int64]struct{} removedusers map[int64]struct{} @@ -7687,13 +7858,13 @@ func (m *RoleMutation) ResetDescription() { } // SetType sets the "type" field. -func (m *RoleMutation) SetType(i int8) { - m._type = &i +func (m *RoleMutation) SetType(et enums.RoleType) { + m._type = &et m.add_type = nil } // GetType returns the value of the "type" field in the mutation. -func (m *RoleMutation) GetType() (r int8, exists bool) { +func (m *RoleMutation) GetType() (r enums.RoleType, exists bool) { v := m._type if v == nil { return @@ -7704,7 +7875,7 @@ func (m *RoleMutation) GetType() (r int8, exists bool) { // OldType returns the old "type" field's value of the Role entity. // If the Role object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldType(ctx context.Context) (v int8, err error) { +func (m *RoleMutation) OldType(ctx context.Context) (v enums.RoleType, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldType is only allowed on UpdateOne operations") } @@ -7718,17 +7889,17 @@ func (m *RoleMutation) OldType(ctx context.Context) (v int8, err error) { return oldValue.Type, nil } -// AddType adds i to the "type" field. -func (m *RoleMutation) AddType(i int8) { +// AddType adds et to the "type" field. +func (m *RoleMutation) AddType(et enums.RoleType) { if m.add_type != nil { - *m.add_type += i + *m.add_type += et } else { - m.add_type = &i + m.add_type = &et } } // AddedType returns the value that was added to the "type" field in this mutation. -func (m *RoleMutation) AddedType() (r int8, exists bool) { +func (m *RoleMutation) AddedType() (r enums.RoleType, exists bool) { v := m.add_type if v == nil { return @@ -7799,13 +7970,13 @@ func (m *RoleMutation) ResetSequence() { } // SetStatus sets the "status" field. -func (m *RoleMutation) SetStatus(i int8) { - m.status = &i +func (m *RoleMutation) SetStatus(e enums.Status) { + m.status = &e m.addstatus = nil } // Status returns the value of the "status" field in the mutation. -func (m *RoleMutation) Status() (r int8, exists bool) { +func (m *RoleMutation) Status() (r enums.Status, exists bool) { v := m.status if v == nil { return @@ -7816,7 +7987,7 @@ func (m *RoleMutation) Status() (r int8, exists bool) { // OldStatus returns the old "status" field's value of the Role entity. // If the Role object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *RoleMutation) OldStatus(ctx context.Context) (v int8, err error) { +func (m *RoleMutation) OldStatus(ctx context.Context) (v enums.Status, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStatus is only allowed on UpdateOne operations") } @@ -7830,17 +8001,17 @@ func (m *RoleMutation) OldStatus(ctx context.Context) (v int8, err error) { return oldValue.Status, nil } -// AddStatus adds i to the "status" field. -func (m *RoleMutation) AddStatus(i int8) { +// AddStatus adds e to the "status" field. +func (m *RoleMutation) AddStatus(e enums.Status) { if m.addstatus != nil { - *m.addstatus += i + *m.addstatus += e } else { - m.addstatus = &i + m.addstatus = &e } } // AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *RoleMutation) AddedStatus() (r int8, exists bool) { +func (m *RoleMutation) AddedStatus() (r enums.Status, exists bool) { v := m.addstatus if v == nil { return @@ -8223,7 +8394,7 @@ func (m *RoleMutation) SetField(name string, value ent.Value) error { m.SetDescription(v) return nil case role.FieldType: - v, ok := value.(int8) + v, ok := value.(enums.RoleType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -8237,7 +8408,7 @@ func (m *RoleMutation) SetField(name string, value ent.Value) error { m.SetSequence(v) return nil case role.FieldStatus: - v, ok := value.(int8) + v, ok := value.(enums.Status) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -8284,7 +8455,7 @@ func (m *RoleMutation) AddedField(name string) (ent.Value, bool) { func (m *RoleMutation) AddField(name string, value ent.Value) error { switch name { case role.FieldType: - v, ok := value.(int8) + v, ok := value.(enums.RoleType) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -8298,7 +8469,7 @@ func (m *RoleMutation) AddField(name string, value ent.Value) error { m.AddSequence(v) return nil case role.FieldStatus: - v, ok := value.(int8) + v, ok := value.(enums.Status) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -9031,8 +9202,8 @@ type UserMutation struct { department *string remark *string token *string - status *int8 - addstatus *int8 + status *enums.Status + addstatus *enums.Status is_system *bool last_login_ip *string last_login_time *time.Time @@ -9935,13 +10106,13 @@ func (m *UserMutation) ResetToken() { } // SetStatus sets the "status" field. -func (m *UserMutation) SetStatus(i int8) { - m.status = &i +func (m *UserMutation) SetStatus(e enums.Status) { + m.status = &e m.addstatus = nil } // Status returns the value of the "status" field in the mutation. -func (m *UserMutation) Status() (r int8, exists bool) { +func (m *UserMutation) Status() (r enums.Status, exists bool) { v := m.status if v == nil { return @@ -9952,7 +10123,7 @@ func (m *UserMutation) Status() (r int8, exists bool) { // OldStatus returns the old "status" field's value of the User entity. // If the User object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldStatus(ctx context.Context) (v int8, err error) { +func (m *UserMutation) OldStatus(ctx context.Context) (v enums.Status, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStatus is only allowed on UpdateOne operations") } @@ -9966,17 +10137,17 @@ func (m *UserMutation) OldStatus(ctx context.Context) (v int8, err error) { return oldValue.Status, nil } -// AddStatus adds i to the "status" field. -func (m *UserMutation) AddStatus(i int8) { +// AddStatus adds e to the "status" field. +func (m *UserMutation) AddStatus(e enums.Status) { if m.addstatus != nil { - *m.addstatus += i + *m.addstatus += e } else { - m.addstatus = &i + m.addstatus = &e } } // AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *UserMutation) AddedStatus() (r int8, exists bool) { +func (m *UserMutation) AddedStatus() (r enums.Status, exists bool) { v := m.addstatus if v == nil { return @@ -10997,7 +11168,7 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { m.SetToken(v) return nil case user.FieldStatus: - v, ok := value.(int8) + v, ok := value.(enums.Status) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -11112,7 +11283,7 @@ func (m *UserMutation) AddField(name string, value ent.Value) error { m.AddUpdateAuthor(v) return nil case user.FieldStatus: - v, ok := value.(int8) + v, ok := value.(enums.Status) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -12936,36 +13107,42 @@ func (m *UserRoleMutation) ResetEdge(name string) error { // ViewMutation represents an operation that mutates the View nodes in the graph. type ViewMutation struct { config - op Op - typ string - id *int64 - create_time *time.Time - update_time *time.Time - keyword *string - scope *string - name *string - _type *string - component *string - _path *string - icon *string - visible *bool - sequence *int - addsequence *int - clearedFields map[string]struct{} - parent *int64 - clearedparent bool - children map[int64]struct{} - removedchildren map[int64]struct{} - clearedchildren bool - resources map[int64]struct{} - removedresources map[int64]struct{} - clearedresources bool - permissions map[int64]struct{} - removedpermissions map[int64]struct{} - clearedpermissions bool - done bool - oldValue func(context.Context) (*View, error) - predicates []predicate.View + op Op + typ string + id *int64 + create_time *time.Time + update_time *time.Time + keyword *string + scope *string + name *string + _type *view.Type + component *string + _path *string + icon *string + visible *bool + sequence *int + addsequence *int + clearedFields map[string]struct{} + parent *int64 + clearedparent bool + children map[int64]struct{} + removedchildren map[int64]struct{} + clearedchildren bool + resources map[int64]struct{} + removedresources map[int64]struct{} + clearedresources bool + permissions map[int64]struct{} + removedpermissions map[int64]struct{} + clearedpermissions bool + view_resources map[int64]struct{} + removedview_resources map[int64]struct{} + clearedview_resources bool + view_permissions map[int64]struct{} + removedview_permissions map[int64]struct{} + clearedview_permissions bool + done bool + oldValue func(context.Context) (*View, error) + predicates []predicate.View } var _ ent.Mutation = (*ViewMutation)(nil) @@ -13302,12 +13479,12 @@ func (m *ViewMutation) ResetName() { } // SetType sets the "type" field. -func (m *ViewMutation) SetType(s string) { - m._type = &s +func (m *ViewMutation) SetType(v view.Type) { + m._type = &v } // GetType returns the value of the "type" field in the mutation. -func (m *ViewMutation) GetType() (r string, exists bool) { +func (m *ViewMutation) GetType() (r view.Type, exists bool) { v := m._type if v == nil { return @@ -13318,7 +13495,7 @@ func (m *ViewMutation) GetType() (r string, exists bool) { // OldType returns the old "type" field's value of the View entity. // If the View object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ViewMutation) OldType(ctx context.Context) (v string, err error) { +func (m *ViewMutation) OldType(ctx context.Context) (v view.Type, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldType is only allowed on UpdateOne operations") } @@ -13765,6 +13942,114 @@ func (m *ViewMutation) ResetPermissions() { m.removedpermissions = nil } +// AddViewResourceIDs adds the "view_resources" edge to the ViewResource entity by ids. +func (m *ViewMutation) AddViewResourceIDs(ids ...int64) { + if m.view_resources == nil { + m.view_resources = make(map[int64]struct{}) + } + for i := range ids { + m.view_resources[ids[i]] = struct{}{} + } +} + +// ClearViewResources clears the "view_resources" edge to the ViewResource entity. +func (m *ViewMutation) ClearViewResources() { + m.clearedview_resources = true +} + +// ViewResourcesCleared reports if the "view_resources" edge to the ViewResource entity was cleared. +func (m *ViewMutation) ViewResourcesCleared() bool { + return m.clearedview_resources +} + +// RemoveViewResourceIDs removes the "view_resources" edge to the ViewResource entity by IDs. +func (m *ViewMutation) RemoveViewResourceIDs(ids ...int64) { + if m.removedview_resources == nil { + m.removedview_resources = make(map[int64]struct{}) + } + for i := range ids { + delete(m.view_resources, ids[i]) + m.removedview_resources[ids[i]] = struct{}{} + } +} + +// RemovedViewResources returns the removed IDs of the "view_resources" edge to the ViewResource entity. +func (m *ViewMutation) RemovedViewResourcesIDs() (ids []int64) { + for id := range m.removedview_resources { + ids = append(ids, id) + } + return +} + +// ViewResourcesIDs returns the "view_resources" edge IDs in the mutation. +func (m *ViewMutation) ViewResourcesIDs() (ids []int64) { + for id := range m.view_resources { + ids = append(ids, id) + } + return +} + +// ResetViewResources resets all changes to the "view_resources" edge. +func (m *ViewMutation) ResetViewResources() { + m.view_resources = nil + m.clearedview_resources = false + m.removedview_resources = nil +} + +// AddViewPermissionIDs adds the "view_permissions" edge to the ViewPermission entity by ids. +func (m *ViewMutation) AddViewPermissionIDs(ids ...int64) { + if m.view_permissions == nil { + m.view_permissions = make(map[int64]struct{}) + } + for i := range ids { + m.view_permissions[ids[i]] = struct{}{} + } +} + +// ClearViewPermissions clears the "view_permissions" edge to the ViewPermission entity. +func (m *ViewMutation) ClearViewPermissions() { + m.clearedview_permissions = true +} + +// ViewPermissionsCleared reports if the "view_permissions" edge to the ViewPermission entity was cleared. +func (m *ViewMutation) ViewPermissionsCleared() bool { + return m.clearedview_permissions +} + +// RemoveViewPermissionIDs removes the "view_permissions" edge to the ViewPermission entity by IDs. +func (m *ViewMutation) RemoveViewPermissionIDs(ids ...int64) { + if m.removedview_permissions == nil { + m.removedview_permissions = make(map[int64]struct{}) + } + for i := range ids { + delete(m.view_permissions, ids[i]) + m.removedview_permissions[ids[i]] = struct{}{} + } +} + +// RemovedViewPermissions returns the removed IDs of the "view_permissions" edge to the ViewPermission entity. +func (m *ViewMutation) RemovedViewPermissionsIDs() (ids []int64) { + for id := range m.removedview_permissions { + ids = append(ids, id) + } + return +} + +// ViewPermissionsIDs returns the "view_permissions" edge IDs in the mutation. +func (m *ViewMutation) ViewPermissionsIDs() (ids []int64) { + for id := range m.view_permissions { + ids = append(ids, id) + } + return +} + +// ResetViewPermissions resets all changes to the "view_permissions" edge. +func (m *ViewMutation) ResetViewPermissions() { + m.view_permissions = nil + m.clearedview_permissions = false + m.removedview_permissions = nil +} + // Where appends a list predicates to the ViewMutation builder. func (m *ViewMutation) Where(ps ...predicate.View) { m.predicates = append(m.predicates, ps...) @@ -13953,7 +14238,7 @@ func (m *ViewMutation) SetField(name string, value ent.Value) error { m.SetName(v) return nil case view.FieldType: - v, ok := value.(string) + v, ok := value.(view.Type) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -14127,7 +14412,7 @@ func (m *ViewMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *ViewMutation) AddedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 6) if m.parent != nil { edges = append(edges, view.EdgeParent) } @@ -14140,6 +14425,12 @@ func (m *ViewMutation) AddedEdges() []string { if m.permissions != nil { edges = append(edges, view.EdgePermissions) } + if m.view_resources != nil { + edges = append(edges, view.EdgeViewResources) + } + if m.view_permissions != nil { + edges = append(edges, view.EdgeViewPermissions) + } return edges } @@ -14169,13 +14460,25 @@ func (m *ViewMutation) AddedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case view.EdgeViewResources: + ids := make([]ent.Value, 0, len(m.view_resources)) + for id := range m.view_resources { + ids = append(ids, id) + } + return ids + case view.EdgeViewPermissions: + ids := make([]ent.Value, 0, len(m.view_permissions)) + for id := range m.view_permissions { + ids = append(ids, id) + } + return ids } return nil } // RemovedEdges returns all edge names that were removed in this mutation. func (m *ViewMutation) RemovedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 6) if m.removedchildren != nil { edges = append(edges, view.EdgeChildren) } @@ -14185,6 +14488,12 @@ func (m *ViewMutation) RemovedEdges() []string { if m.removedpermissions != nil { edges = append(edges, view.EdgePermissions) } + if m.removedview_resources != nil { + edges = append(edges, view.EdgeViewResources) + } + if m.removedview_permissions != nil { + edges = append(edges, view.EdgeViewPermissions) + } return edges } @@ -14210,13 +14519,25 @@ func (m *ViewMutation) RemovedIDs(name string) []ent.Value { ids = append(ids, id) } return ids + case view.EdgeViewResources: + ids := make([]ent.Value, 0, len(m.removedview_resources)) + for id := range m.removedview_resources { + ids = append(ids, id) + } + return ids + case view.EdgeViewPermissions: + ids := make([]ent.Value, 0, len(m.removedview_permissions)) + for id := range m.removedview_permissions { + ids = append(ids, id) + } + return ids } return nil } // ClearedEdges returns all edge names that were cleared in this mutation. func (m *ViewMutation) ClearedEdges() []string { - edges := make([]string, 0, 4) + edges := make([]string, 0, 6) if m.clearedparent { edges = append(edges, view.EdgeParent) } @@ -14229,6 +14550,12 @@ func (m *ViewMutation) ClearedEdges() []string { if m.clearedpermissions { edges = append(edges, view.EdgePermissions) } + if m.clearedview_resources { + edges = append(edges, view.EdgeViewResources) + } + if m.clearedview_permissions { + edges = append(edges, view.EdgeViewPermissions) + } return edges } @@ -14244,6 +14571,10 @@ func (m *ViewMutation) EdgeCleared(name string) bool { return m.clearedresources case view.EdgePermissions: return m.clearedpermissions + case view.EdgeViewResources: + return m.clearedview_resources + case view.EdgeViewPermissions: + return m.clearedview_permissions } return false } @@ -14275,6 +14606,1640 @@ func (m *ViewMutation) ResetEdge(name string) error { case view.EdgePermissions: m.ResetPermissions() return nil + case view.EdgeViewResources: + m.ResetViewResources() + return nil + case view.EdgeViewPermissions: + m.ResetViewPermissions() + return nil } return fmt.Errorf("unknown View edge %s", name) } + +// ViewPermissionMutation represents an operation that mutates the ViewPermission nodes in the graph. +type ViewPermissionMutation struct { + config + op Op + typ string + id *int64 + create_author *int64 + addcreate_author *int64 + update_author *int64 + addupdate_author *int64 + create_time *time.Time + update_time *time.Time + clearedFields map[string]struct{} + view *int64 + clearedview bool + permission *int64 + clearedpermission bool + done bool + oldValue func(context.Context) (*ViewPermission, error) + predicates []predicate.ViewPermission +} + +var _ ent.Mutation = (*ViewPermissionMutation)(nil) + +// viewpermissionOption allows management of the mutation configuration using functional options. +type viewpermissionOption func(*ViewPermissionMutation) + +// newViewPermissionMutation creates new mutation for the ViewPermission entity. +func newViewPermissionMutation(c config, op Op, opts ...viewpermissionOption) *ViewPermissionMutation { + m := &ViewPermissionMutation{ + config: c, + op: op, + typ: TypeViewPermission, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withViewPermissionID sets the ID field of the mutation. +func withViewPermissionID(id int64) viewpermissionOption { + return func(m *ViewPermissionMutation) { + var ( + err error + once sync.Once + value *ViewPermission + ) + m.oldValue = func(ctx context.Context) (*ViewPermission, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ViewPermission.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withViewPermission sets the old ViewPermission of the mutation. +func withViewPermission(node *ViewPermission) viewpermissionOption { + return func(m *ViewPermissionMutation) { + m.oldValue = func(context.Context) (*ViewPermission, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ViewPermissionMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ViewPermissionMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of ViewPermission entities. +func (m *ViewPermissionMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ViewPermissionMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ViewPermissionMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().ViewPermission.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateAuthor sets the "create_author" field. +func (m *ViewPermissionMutation) SetCreateAuthor(i int64) { + m.create_author = &i + m.addcreate_author = nil +} + +// CreateAuthor returns the value of the "create_author" field in the mutation. +func (m *ViewPermissionMutation) CreateAuthor() (r int64, exists bool) { + v := m.create_author + if v == nil { + return + } + return *v, true +} + +// OldCreateAuthor returns the old "create_author" field's value of the ViewPermission entity. +// If the ViewPermission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewPermissionMutation) OldCreateAuthor(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateAuthor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateAuthor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateAuthor: %w", err) + } + return oldValue.CreateAuthor, nil +} + +// AddCreateAuthor adds i to the "create_author" field. +func (m *ViewPermissionMutation) AddCreateAuthor(i int64) { + if m.addcreate_author != nil { + *m.addcreate_author += i + } else { + m.addcreate_author = &i + } +} + +// AddedCreateAuthor returns the value that was added to the "create_author" field in this mutation. +func (m *ViewPermissionMutation) AddedCreateAuthor() (r int64, exists bool) { + v := m.addcreate_author + if v == nil { + return + } + return *v, true +} + +// ClearCreateAuthor clears the value of the "create_author" field. +func (m *ViewPermissionMutation) ClearCreateAuthor() { + m.create_author = nil + m.addcreate_author = nil + m.clearedFields[viewpermission.FieldCreateAuthor] = struct{}{} +} + +// CreateAuthorCleared returns if the "create_author" field was cleared in this mutation. +func (m *ViewPermissionMutation) CreateAuthorCleared() bool { + _, ok := m.clearedFields[viewpermission.FieldCreateAuthor] + return ok +} + +// ResetCreateAuthor resets all changes to the "create_author" field. +func (m *ViewPermissionMutation) ResetCreateAuthor() { + m.create_author = nil + m.addcreate_author = nil + delete(m.clearedFields, viewpermission.FieldCreateAuthor) +} + +// SetUpdateAuthor sets the "update_author" field. +func (m *ViewPermissionMutation) SetUpdateAuthor(i int64) { + m.update_author = &i + m.addupdate_author = nil +} + +// UpdateAuthor returns the value of the "update_author" field in the mutation. +func (m *ViewPermissionMutation) UpdateAuthor() (r int64, exists bool) { + v := m.update_author + if v == nil { + return + } + return *v, true +} + +// OldUpdateAuthor returns the old "update_author" field's value of the ViewPermission entity. +// If the ViewPermission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewPermissionMutation) OldUpdateAuthor(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateAuthor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateAuthor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateAuthor: %w", err) + } + return oldValue.UpdateAuthor, nil +} + +// AddUpdateAuthor adds i to the "update_author" field. +func (m *ViewPermissionMutation) AddUpdateAuthor(i int64) { + if m.addupdate_author != nil { + *m.addupdate_author += i + } else { + m.addupdate_author = &i + } +} + +// AddedUpdateAuthor returns the value that was added to the "update_author" field in this mutation. +func (m *ViewPermissionMutation) AddedUpdateAuthor() (r int64, exists bool) { + v := m.addupdate_author + if v == nil { + return + } + return *v, true +} + +// ClearUpdateAuthor clears the value of the "update_author" field. +func (m *ViewPermissionMutation) ClearUpdateAuthor() { + m.update_author = nil + m.addupdate_author = nil + m.clearedFields[viewpermission.FieldUpdateAuthor] = struct{}{} +} + +// UpdateAuthorCleared returns if the "update_author" field was cleared in this mutation. +func (m *ViewPermissionMutation) UpdateAuthorCleared() bool { + _, ok := m.clearedFields[viewpermission.FieldUpdateAuthor] + return ok +} + +// ResetUpdateAuthor resets all changes to the "update_author" field. +func (m *ViewPermissionMutation) ResetUpdateAuthor() { + m.update_author = nil + m.addupdate_author = nil + delete(m.clearedFields, viewpermission.FieldUpdateAuthor) +} + +// SetCreateTime sets the "create_time" field. +func (m *ViewPermissionMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *ViewPermissionMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the ViewPermission entity. +// If the ViewPermission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewPermissionMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *ViewPermissionMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *ViewPermissionMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *ViewPermissionMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the ViewPermission entity. +// If the ViewPermission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewPermissionMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *ViewPermissionMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetViewID sets the "view_id" field. +func (m *ViewPermissionMutation) SetViewID(i int64) { + m.view = &i +} + +// ViewID returns the value of the "view_id" field in the mutation. +func (m *ViewPermissionMutation) ViewID() (r int64, exists bool) { + v := m.view + if v == nil { + return + } + return *v, true +} + +// OldViewID returns the old "view_id" field's value of the ViewPermission entity. +// If the ViewPermission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewPermissionMutation) OldViewID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldViewID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldViewID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldViewID: %w", err) + } + return oldValue.ViewID, nil +} + +// ResetViewID resets all changes to the "view_id" field. +func (m *ViewPermissionMutation) ResetViewID() { + m.view = nil +} + +// SetPermissionID sets the "permission_id" field. +func (m *ViewPermissionMutation) SetPermissionID(i int64) { + m.permission = &i +} + +// PermissionID returns the value of the "permission_id" field in the mutation. +func (m *ViewPermissionMutation) PermissionID() (r int64, exists bool) { + v := m.permission + if v == nil { + return + } + return *v, true +} + +// OldPermissionID returns the old "permission_id" field's value of the ViewPermission entity. +// If the ViewPermission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewPermissionMutation) OldPermissionID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPermissionID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPermissionID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPermissionID: %w", err) + } + return oldValue.PermissionID, nil +} + +// ResetPermissionID resets all changes to the "permission_id" field. +func (m *ViewPermissionMutation) ResetPermissionID() { + m.permission = nil +} + +// ClearView clears the "view" edge to the View entity. +func (m *ViewPermissionMutation) ClearView() { + m.clearedview = true + m.clearedFields[viewpermission.FieldViewID] = struct{}{} +} + +// ViewCleared reports if the "view" edge to the View entity was cleared. +func (m *ViewPermissionMutation) ViewCleared() bool { + return m.clearedview +} + +// ViewIDs returns the "view" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ViewID instead. It exists only for internal usage by the builders. +func (m *ViewPermissionMutation) ViewIDs() (ids []int64) { + if id := m.view; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetView resets all changes to the "view" edge. +func (m *ViewPermissionMutation) ResetView() { + m.view = nil + m.clearedview = false +} + +// ClearPermission clears the "permission" edge to the Permission entity. +func (m *ViewPermissionMutation) ClearPermission() { + m.clearedpermission = true + m.clearedFields[viewpermission.FieldPermissionID] = struct{}{} +} + +// PermissionCleared reports if the "permission" edge to the Permission entity was cleared. +func (m *ViewPermissionMutation) PermissionCleared() bool { + return m.clearedpermission +} + +// PermissionIDs returns the "permission" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// PermissionID instead. It exists only for internal usage by the builders. +func (m *ViewPermissionMutation) PermissionIDs() (ids []int64) { + if id := m.permission; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetPermission resets all changes to the "permission" edge. +func (m *ViewPermissionMutation) ResetPermission() { + m.permission = nil + m.clearedpermission = false +} + +// Where appends a list predicates to the ViewPermissionMutation builder. +func (m *ViewPermissionMutation) Where(ps ...predicate.ViewPermission) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ViewPermissionMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ViewPermissionMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ViewPermission, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ViewPermissionMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ViewPermissionMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ViewPermission). +func (m *ViewPermissionMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ViewPermissionMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.create_author != nil { + fields = append(fields, viewpermission.FieldCreateAuthor) + } + if m.update_author != nil { + fields = append(fields, viewpermission.FieldUpdateAuthor) + } + if m.create_time != nil { + fields = append(fields, viewpermission.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, viewpermission.FieldUpdateTime) + } + if m.view != nil { + fields = append(fields, viewpermission.FieldViewID) + } + if m.permission != nil { + fields = append(fields, viewpermission.FieldPermissionID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ViewPermissionMutation) Field(name string) (ent.Value, bool) { + switch name { + case viewpermission.FieldCreateAuthor: + return m.CreateAuthor() + case viewpermission.FieldUpdateAuthor: + return m.UpdateAuthor() + case viewpermission.FieldCreateTime: + return m.CreateTime() + case viewpermission.FieldUpdateTime: + return m.UpdateTime() + case viewpermission.FieldViewID: + return m.ViewID() + case viewpermission.FieldPermissionID: + return m.PermissionID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ViewPermissionMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case viewpermission.FieldCreateAuthor: + return m.OldCreateAuthor(ctx) + case viewpermission.FieldUpdateAuthor: + return m.OldUpdateAuthor(ctx) + case viewpermission.FieldCreateTime: + return m.OldCreateTime(ctx) + case viewpermission.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case viewpermission.FieldViewID: + return m.OldViewID(ctx) + case viewpermission.FieldPermissionID: + return m.OldPermissionID(ctx) + } + return nil, fmt.Errorf("unknown ViewPermission field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ViewPermissionMutation) SetField(name string, value ent.Value) error { + switch name { + case viewpermission.FieldCreateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateAuthor(v) + return nil + case viewpermission.FieldUpdateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateAuthor(v) + return nil + case viewpermission.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case viewpermission.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case viewpermission.FieldViewID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetViewID(v) + return nil + case viewpermission.FieldPermissionID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPermissionID(v) + return nil + } + return fmt.Errorf("unknown ViewPermission field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ViewPermissionMutation) AddedFields() []string { + var fields []string + if m.addcreate_author != nil { + fields = append(fields, viewpermission.FieldCreateAuthor) + } + if m.addupdate_author != nil { + fields = append(fields, viewpermission.FieldUpdateAuthor) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ViewPermissionMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case viewpermission.FieldCreateAuthor: + return m.AddedCreateAuthor() + case viewpermission.FieldUpdateAuthor: + return m.AddedUpdateAuthor() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ViewPermissionMutation) AddField(name string, value ent.Value) error { + switch name { + case viewpermission.FieldCreateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCreateAuthor(v) + return nil + case viewpermission.FieldUpdateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUpdateAuthor(v) + return nil + } + return fmt.Errorf("unknown ViewPermission numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ViewPermissionMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(viewpermission.FieldCreateAuthor) { + fields = append(fields, viewpermission.FieldCreateAuthor) + } + if m.FieldCleared(viewpermission.FieldUpdateAuthor) { + fields = append(fields, viewpermission.FieldUpdateAuthor) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ViewPermissionMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ViewPermissionMutation) ClearField(name string) error { + switch name { + case viewpermission.FieldCreateAuthor: + m.ClearCreateAuthor() + return nil + case viewpermission.FieldUpdateAuthor: + m.ClearUpdateAuthor() + return nil + } + return fmt.Errorf("unknown ViewPermission nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ViewPermissionMutation) ResetField(name string) error { + switch name { + case viewpermission.FieldCreateAuthor: + m.ResetCreateAuthor() + return nil + case viewpermission.FieldUpdateAuthor: + m.ResetUpdateAuthor() + return nil + case viewpermission.FieldCreateTime: + m.ResetCreateTime() + return nil + case viewpermission.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case viewpermission.FieldViewID: + m.ResetViewID() + return nil + case viewpermission.FieldPermissionID: + m.ResetPermissionID() + return nil + } + return fmt.Errorf("unknown ViewPermission field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ViewPermissionMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.view != nil { + edges = append(edges, viewpermission.EdgeView) + } + if m.permission != nil { + edges = append(edges, viewpermission.EdgePermission) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ViewPermissionMutation) AddedIDs(name string) []ent.Value { + switch name { + case viewpermission.EdgeView: + if id := m.view; id != nil { + return []ent.Value{*id} + } + case viewpermission.EdgePermission: + if id := m.permission; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ViewPermissionMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ViewPermissionMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ViewPermissionMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedview { + edges = append(edges, viewpermission.EdgeView) + } + if m.clearedpermission { + edges = append(edges, viewpermission.EdgePermission) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ViewPermissionMutation) EdgeCleared(name string) bool { + switch name { + case viewpermission.EdgeView: + return m.clearedview + case viewpermission.EdgePermission: + return m.clearedpermission + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ViewPermissionMutation) ClearEdge(name string) error { + switch name { + case viewpermission.EdgeView: + m.ClearView() + return nil + case viewpermission.EdgePermission: + m.ClearPermission() + return nil + } + return fmt.Errorf("unknown ViewPermission unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ViewPermissionMutation) ResetEdge(name string) error { + switch name { + case viewpermission.EdgeView: + m.ResetView() + return nil + case viewpermission.EdgePermission: + m.ResetPermission() + return nil + } + return fmt.Errorf("unknown ViewPermission edge %s", name) +} + +// ViewResourceMutation represents an operation that mutates the ViewResource nodes in the graph. +type ViewResourceMutation struct { + config + op Op + typ string + id *int64 + create_author *int64 + addcreate_author *int64 + update_author *int64 + addupdate_author *int64 + create_time *time.Time + update_time *time.Time + clearedFields map[string]struct{} + view *int64 + clearedview bool + resource *int64 + clearedresource bool + done bool + oldValue func(context.Context) (*ViewResource, error) + predicates []predicate.ViewResource +} + +var _ ent.Mutation = (*ViewResourceMutation)(nil) + +// viewresourceOption allows management of the mutation configuration using functional options. +type viewresourceOption func(*ViewResourceMutation) + +// newViewResourceMutation creates new mutation for the ViewResource entity. +func newViewResourceMutation(c config, op Op, opts ...viewresourceOption) *ViewResourceMutation { + m := &ViewResourceMutation{ + config: c, + op: op, + typ: TypeViewResource, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withViewResourceID sets the ID field of the mutation. +func withViewResourceID(id int64) viewresourceOption { + return func(m *ViewResourceMutation) { + var ( + err error + once sync.Once + value *ViewResource + ) + m.oldValue = func(ctx context.Context) (*ViewResource, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().ViewResource.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withViewResource sets the old ViewResource of the mutation. +func withViewResource(node *ViewResource) viewresourceOption { + return func(m *ViewResourceMutation) { + m.oldValue = func(context.Context) (*ViewResource, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ViewResourceMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ViewResourceMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of ViewResource entities. +func (m *ViewResourceMutation) SetID(id int64) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ViewResourceMutation) ID() (id int64, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ViewResourceMutation) IDs(ctx context.Context) ([]int64, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int64{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().ViewResource.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetCreateAuthor sets the "create_author" field. +func (m *ViewResourceMutation) SetCreateAuthor(i int64) { + m.create_author = &i + m.addcreate_author = nil +} + +// CreateAuthor returns the value of the "create_author" field in the mutation. +func (m *ViewResourceMutation) CreateAuthor() (r int64, exists bool) { + v := m.create_author + if v == nil { + return + } + return *v, true +} + +// OldCreateAuthor returns the old "create_author" field's value of the ViewResource entity. +// If the ViewResource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewResourceMutation) OldCreateAuthor(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateAuthor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateAuthor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateAuthor: %w", err) + } + return oldValue.CreateAuthor, nil +} + +// AddCreateAuthor adds i to the "create_author" field. +func (m *ViewResourceMutation) AddCreateAuthor(i int64) { + if m.addcreate_author != nil { + *m.addcreate_author += i + } else { + m.addcreate_author = &i + } +} + +// AddedCreateAuthor returns the value that was added to the "create_author" field in this mutation. +func (m *ViewResourceMutation) AddedCreateAuthor() (r int64, exists bool) { + v := m.addcreate_author + if v == nil { + return + } + return *v, true +} + +// ClearCreateAuthor clears the value of the "create_author" field. +func (m *ViewResourceMutation) ClearCreateAuthor() { + m.create_author = nil + m.addcreate_author = nil + m.clearedFields[viewresource.FieldCreateAuthor] = struct{}{} +} + +// CreateAuthorCleared returns if the "create_author" field was cleared in this mutation. +func (m *ViewResourceMutation) CreateAuthorCleared() bool { + _, ok := m.clearedFields[viewresource.FieldCreateAuthor] + return ok +} + +// ResetCreateAuthor resets all changes to the "create_author" field. +func (m *ViewResourceMutation) ResetCreateAuthor() { + m.create_author = nil + m.addcreate_author = nil + delete(m.clearedFields, viewresource.FieldCreateAuthor) +} + +// SetUpdateAuthor sets the "update_author" field. +func (m *ViewResourceMutation) SetUpdateAuthor(i int64) { + m.update_author = &i + m.addupdate_author = nil +} + +// UpdateAuthor returns the value of the "update_author" field in the mutation. +func (m *ViewResourceMutation) UpdateAuthor() (r int64, exists bool) { + v := m.update_author + if v == nil { + return + } + return *v, true +} + +// OldUpdateAuthor returns the old "update_author" field's value of the ViewResource entity. +// If the ViewResource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewResourceMutation) OldUpdateAuthor(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateAuthor is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateAuthor requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateAuthor: %w", err) + } + return oldValue.UpdateAuthor, nil +} + +// AddUpdateAuthor adds i to the "update_author" field. +func (m *ViewResourceMutation) AddUpdateAuthor(i int64) { + if m.addupdate_author != nil { + *m.addupdate_author += i + } else { + m.addupdate_author = &i + } +} + +// AddedUpdateAuthor returns the value that was added to the "update_author" field in this mutation. +func (m *ViewResourceMutation) AddedUpdateAuthor() (r int64, exists bool) { + v := m.addupdate_author + if v == nil { + return + } + return *v, true +} + +// ClearUpdateAuthor clears the value of the "update_author" field. +func (m *ViewResourceMutation) ClearUpdateAuthor() { + m.update_author = nil + m.addupdate_author = nil + m.clearedFields[viewresource.FieldUpdateAuthor] = struct{}{} +} + +// UpdateAuthorCleared returns if the "update_author" field was cleared in this mutation. +func (m *ViewResourceMutation) UpdateAuthorCleared() bool { + _, ok := m.clearedFields[viewresource.FieldUpdateAuthor] + return ok +} + +// ResetUpdateAuthor resets all changes to the "update_author" field. +func (m *ViewResourceMutation) ResetUpdateAuthor() { + m.update_author = nil + m.addupdate_author = nil + delete(m.clearedFields, viewresource.FieldUpdateAuthor) +} + +// SetCreateTime sets the "create_time" field. +func (m *ViewResourceMutation) SetCreateTime(t time.Time) { + m.create_time = &t +} + +// CreateTime returns the value of the "create_time" field in the mutation. +func (m *ViewResourceMutation) CreateTime() (r time.Time, exists bool) { + v := m.create_time + if v == nil { + return + } + return *v, true +} + +// OldCreateTime returns the old "create_time" field's value of the ViewResource entity. +// If the ViewResource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewResourceMutation) OldCreateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreateTime: %w", err) + } + return oldValue.CreateTime, nil +} + +// ResetCreateTime resets all changes to the "create_time" field. +func (m *ViewResourceMutation) ResetCreateTime() { + m.create_time = nil +} + +// SetUpdateTime sets the "update_time" field. +func (m *ViewResourceMutation) SetUpdateTime(t time.Time) { + m.update_time = &t +} + +// UpdateTime returns the value of the "update_time" field in the mutation. +func (m *ViewResourceMutation) UpdateTime() (r time.Time, exists bool) { + v := m.update_time + if v == nil { + return + } + return *v, true +} + +// OldUpdateTime returns the old "update_time" field's value of the ViewResource entity. +// If the ViewResource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewResourceMutation) OldUpdateTime(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUpdateTime requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err) + } + return oldValue.UpdateTime, nil +} + +// ResetUpdateTime resets all changes to the "update_time" field. +func (m *ViewResourceMutation) ResetUpdateTime() { + m.update_time = nil +} + +// SetViewID sets the "view_id" field. +func (m *ViewResourceMutation) SetViewID(i int64) { + m.view = &i +} + +// ViewID returns the value of the "view_id" field in the mutation. +func (m *ViewResourceMutation) ViewID() (r int64, exists bool) { + v := m.view + if v == nil { + return + } + return *v, true +} + +// OldViewID returns the old "view_id" field's value of the ViewResource entity. +// If the ViewResource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewResourceMutation) OldViewID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldViewID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldViewID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldViewID: %w", err) + } + return oldValue.ViewID, nil +} + +// ResetViewID resets all changes to the "view_id" field. +func (m *ViewResourceMutation) ResetViewID() { + m.view = nil +} + +// SetResourceID sets the "resource_id" field. +func (m *ViewResourceMutation) SetResourceID(i int64) { + m.resource = &i +} + +// ResourceID returns the value of the "resource_id" field in the mutation. +func (m *ViewResourceMutation) ResourceID() (r int64, exists bool) { + v := m.resource + if v == nil { + return + } + return *v, true +} + +// OldResourceID returns the old "resource_id" field's value of the ViewResource entity. +// If the ViewResource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewResourceMutation) OldResourceID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldResourceID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldResourceID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldResourceID: %w", err) + } + return oldValue.ResourceID, nil +} + +// ResetResourceID resets all changes to the "resource_id" field. +func (m *ViewResourceMutation) ResetResourceID() { + m.resource = nil +} + +// ClearView clears the "view" edge to the View entity. +func (m *ViewResourceMutation) ClearView() { + m.clearedview = true + m.clearedFields[viewresource.FieldViewID] = struct{}{} +} + +// ViewCleared reports if the "view" edge to the View entity was cleared. +func (m *ViewResourceMutation) ViewCleared() bool { + return m.clearedview +} + +// ViewIDs returns the "view" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ViewID instead. It exists only for internal usage by the builders. +func (m *ViewResourceMutation) ViewIDs() (ids []int64) { + if id := m.view; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetView resets all changes to the "view" edge. +func (m *ViewResourceMutation) ResetView() { + m.view = nil + m.clearedview = false +} + +// ClearResource clears the "resource" edge to the Resource entity. +func (m *ViewResourceMutation) ClearResource() { + m.clearedresource = true + m.clearedFields[viewresource.FieldResourceID] = struct{}{} +} + +// ResourceCleared reports if the "resource" edge to the Resource entity was cleared. +func (m *ViewResourceMutation) ResourceCleared() bool { + return m.clearedresource +} + +// ResourceIDs returns the "resource" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ResourceID instead. It exists only for internal usage by the builders. +func (m *ViewResourceMutation) ResourceIDs() (ids []int64) { + if id := m.resource; id != nil { + ids = append(ids, *id) + } + return +} + +// ResetResource resets all changes to the "resource" edge. +func (m *ViewResourceMutation) ResetResource() { + m.resource = nil + m.clearedresource = false +} + +// Where appends a list predicates to the ViewResourceMutation builder. +func (m *ViewResourceMutation) Where(ps ...predicate.ViewResource) { + m.predicates = append(m.predicates, ps...) +} + +// WhereP appends storage-level predicates to the ViewResourceMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *ViewResourceMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.ViewResource, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + +// Op returns the operation name. +func (m *ViewResourceMutation) Op() Op { + return m.op +} + +// SetOp allows setting the mutation operation. +func (m *ViewResourceMutation) SetOp(op Op) { + m.op = op +} + +// Type returns the node type of this mutation (ViewResource). +func (m *ViewResourceMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ViewResourceMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.create_author != nil { + fields = append(fields, viewresource.FieldCreateAuthor) + } + if m.update_author != nil { + fields = append(fields, viewresource.FieldUpdateAuthor) + } + if m.create_time != nil { + fields = append(fields, viewresource.FieldCreateTime) + } + if m.update_time != nil { + fields = append(fields, viewresource.FieldUpdateTime) + } + if m.view != nil { + fields = append(fields, viewresource.FieldViewID) + } + if m.resource != nil { + fields = append(fields, viewresource.FieldResourceID) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ViewResourceMutation) Field(name string) (ent.Value, bool) { + switch name { + case viewresource.FieldCreateAuthor: + return m.CreateAuthor() + case viewresource.FieldUpdateAuthor: + return m.UpdateAuthor() + case viewresource.FieldCreateTime: + return m.CreateTime() + case viewresource.FieldUpdateTime: + return m.UpdateTime() + case viewresource.FieldViewID: + return m.ViewID() + case viewresource.FieldResourceID: + return m.ResourceID() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ViewResourceMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case viewresource.FieldCreateAuthor: + return m.OldCreateAuthor(ctx) + case viewresource.FieldUpdateAuthor: + return m.OldUpdateAuthor(ctx) + case viewresource.FieldCreateTime: + return m.OldCreateTime(ctx) + case viewresource.FieldUpdateTime: + return m.OldUpdateTime(ctx) + case viewresource.FieldViewID: + return m.OldViewID(ctx) + case viewresource.FieldResourceID: + return m.OldResourceID(ctx) + } + return nil, fmt.Errorf("unknown ViewResource field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ViewResourceMutation) SetField(name string, value ent.Value) error { + switch name { + case viewresource.FieldCreateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateAuthor(v) + return nil + case viewresource.FieldUpdateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateAuthor(v) + return nil + case viewresource.FieldCreateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreateTime(v) + return nil + case viewresource.FieldUpdateTime: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUpdateTime(v) + return nil + case viewresource.FieldViewID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetViewID(v) + return nil + case viewresource.FieldResourceID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetResourceID(v) + return nil + } + return fmt.Errorf("unknown ViewResource field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ViewResourceMutation) AddedFields() []string { + var fields []string + if m.addcreate_author != nil { + fields = append(fields, viewresource.FieldCreateAuthor) + } + if m.addupdate_author != nil { + fields = append(fields, viewresource.FieldUpdateAuthor) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ViewResourceMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case viewresource.FieldCreateAuthor: + return m.AddedCreateAuthor() + case viewresource.FieldUpdateAuthor: + return m.AddedUpdateAuthor() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ViewResourceMutation) AddField(name string, value ent.Value) error { + switch name { + case viewresource.FieldCreateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddCreateAuthor(v) + return nil + case viewresource.FieldUpdateAuthor: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddUpdateAuthor(v) + return nil + } + return fmt.Errorf("unknown ViewResource numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ViewResourceMutation) ClearedFields() []string { + var fields []string + if m.FieldCleared(viewresource.FieldCreateAuthor) { + fields = append(fields, viewresource.FieldCreateAuthor) + } + if m.FieldCleared(viewresource.FieldUpdateAuthor) { + fields = append(fields, viewresource.FieldUpdateAuthor) + } + return fields +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ViewResourceMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ViewResourceMutation) ClearField(name string) error { + switch name { + case viewresource.FieldCreateAuthor: + m.ClearCreateAuthor() + return nil + case viewresource.FieldUpdateAuthor: + m.ClearUpdateAuthor() + return nil + } + return fmt.Errorf("unknown ViewResource nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ViewResourceMutation) ResetField(name string) error { + switch name { + case viewresource.FieldCreateAuthor: + m.ResetCreateAuthor() + return nil + case viewresource.FieldUpdateAuthor: + m.ResetUpdateAuthor() + return nil + case viewresource.FieldCreateTime: + m.ResetCreateTime() + return nil + case viewresource.FieldUpdateTime: + m.ResetUpdateTime() + return nil + case viewresource.FieldViewID: + m.ResetViewID() + return nil + case viewresource.FieldResourceID: + m.ResetResourceID() + return nil + } + return fmt.Errorf("unknown ViewResource field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ViewResourceMutation) AddedEdges() []string { + edges := make([]string, 0, 2) + if m.view != nil { + edges = append(edges, viewresource.EdgeView) + } + if m.resource != nil { + edges = append(edges, viewresource.EdgeResource) + } + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ViewResourceMutation) AddedIDs(name string) []ent.Value { + switch name { + case viewresource.EdgeView: + if id := m.view; id != nil { + return []ent.Value{*id} + } + case viewresource.EdgeResource: + if id := m.resource; id != nil { + return []ent.Value{*id} + } + } + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ViewResourceMutation) RemovedEdges() []string { + edges := make([]string, 0, 2) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ViewResourceMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ViewResourceMutation) ClearedEdges() []string { + edges := make([]string, 0, 2) + if m.clearedview { + edges = append(edges, viewresource.EdgeView) + } + if m.clearedresource { + edges = append(edges, viewresource.EdgeResource) + } + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ViewResourceMutation) EdgeCleared(name string) bool { + switch name { + case viewresource.EdgeView: + return m.clearedview + case viewresource.EdgeResource: + return m.clearedresource + } + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ViewResourceMutation) ClearEdge(name string) error { + switch name { + case viewresource.EdgeView: + m.ClearView() + return nil + case viewresource.EdgeResource: + m.ClearResource() + return nil + } + return fmt.Errorf("unknown ViewResource unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ViewResourceMutation) ResetEdge(name string) error { + switch name { + case viewresource.EdgeView: + m.ResetView() + return nil + case viewresource.EdgeResource: + m.ResetResource() + return nil + } + return fmt.Errorf("unknown ViewResource edge %s", name) +} diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index 36a28581..38627ae0 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -19,6 +19,8 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/entity/ent/viewresource" ) // SetFields sets the values of the fields with the given names. It returns an @@ -232,7 +234,7 @@ func (m *NotificationMutation) SetFields(input *Notification, fields ...string) m.SetContent(input.Content) } case notification.FieldStatus: - // check int8 with sql.NullInt64 if it is zero + // check enums.Status with sql.NullInt64 if it is zero if input.Status != 0 { m.SetStatus(input.Status) } @@ -670,7 +672,7 @@ func (m *RoleMutation) SetFields(input *Role, fields ...string) error { m.SetDescription(input.Description) } case role.FieldType: - // check int8 with sql.NullInt64 if it is zero + // check enums.RoleType with sql.NullInt64 if it is zero if input.Type != 0 { m.SetType(input.Type) } @@ -680,7 +682,7 @@ func (m *RoleMutation) SetFields(input *Role, fields ...string) error { m.SetSequence(input.Sequence) } case role.FieldStatus: - // check int8 with sql.NullInt64 if it is zero + // check enums.Status with sql.NullInt64 if it is zero if input.Status != 0 { m.SetStatus(input.Status) } @@ -869,7 +871,7 @@ func (m *UserMutation) SetFields(input *User, fields ...string) error { m.SetToken(input.Token) } case user.FieldStatus: - // check int8 with sql.NullInt64 if it is zero + // check enums.Status with sql.NullInt64 if it is zero if input.Status != 0 { m.SetStatus(input.Status) } @@ -1144,8 +1146,9 @@ func (m *ViewMutation) SetFields(input *View, fields ...string) error { m.SetName(input.Name) } case view.FieldType: - // check string with sql.NullString if it is empty - if input.Type != "" { + var zero view.Type + // check view.Type with sql.NullString if it is empty + if input.Type != zero { m.SetType(input.Type) } case view.FieldComponent: @@ -1222,3 +1225,149 @@ func (m *ViewMutation) SetFieldsWithZero(input *View, fields ...string) error { } return nil } + +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *ViewPermissionMutation) SetFields(input *ViewPermission, fields ...string) error { + for i := range fields { + switch fields[i] { + case viewpermission.FieldCreateAuthor: + // check int64 with sql.NullInt64 if it is zero + if input.CreateAuthor != 0 { + m.SetCreateAuthor(input.CreateAuthor) + } + case viewpermission.FieldUpdateAuthor: + // check int64 with sql.NullInt64 if it is zero + if input.UpdateAuthor != 0 { + m.SetUpdateAuthor(input.UpdateAuthor) + } + case viewpermission.FieldCreateTime: + if input.CreateTime.Unix() != 0 { + m.SetCreateTime(input.CreateTime) + } + case viewpermission.FieldUpdateTime: + if input.UpdateTime.Unix() != 0 { + m.SetUpdateTime(input.UpdateTime) + } + case viewpermission.FieldViewID: + // check int64 with sql.NullInt64 if it is zero + if input.ViewID != 0 { + m.SetViewID(input.ViewID) + } + case viewpermission.FieldPermissionID: + // check int64 with sql.NullInt64 if it is zero + if input.PermissionID != 0 { + m.SetPermissionID(input.PermissionID) + } + case viewpermission.FieldID: + // check int64 with sql.NullInt64 if it is zero + if input.ID != 0 { + m.SetID(input.ID) + } + default: + return fmt.Errorf("unknown ViewPermission field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *ViewPermissionMutation) SetFieldsWithZero(input *ViewPermission, fields ...string) error { + for i := range fields { + switch fields[i] { + case viewpermission.FieldCreateAuthor: + m.SetCreateAuthor(input.CreateAuthor) + case viewpermission.FieldUpdateAuthor: + m.SetUpdateAuthor(input.UpdateAuthor) + case viewpermission.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case viewpermission.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case viewpermission.FieldViewID: + m.SetViewID(input.ViewID) + case viewpermission.FieldPermissionID: + m.SetPermissionID(input.PermissionID) + case viewpermission.FieldID: + m.SetID(input.ID) + default: + return fmt.Errorf("unknown ViewPermission field %s", fields[i]) + } + } + return nil +} + +// SetFields sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *ViewResourceMutation) SetFields(input *ViewResource, fields ...string) error { + for i := range fields { + switch fields[i] { + case viewresource.FieldCreateAuthor: + // check int64 with sql.NullInt64 if it is zero + if input.CreateAuthor != 0 { + m.SetCreateAuthor(input.CreateAuthor) + } + case viewresource.FieldUpdateAuthor: + // check int64 with sql.NullInt64 if it is zero + if input.UpdateAuthor != 0 { + m.SetUpdateAuthor(input.UpdateAuthor) + } + case viewresource.FieldCreateTime: + if input.CreateTime.Unix() != 0 { + m.SetCreateTime(input.CreateTime) + } + case viewresource.FieldUpdateTime: + if input.UpdateTime.Unix() != 0 { + m.SetUpdateTime(input.UpdateTime) + } + case viewresource.FieldViewID: + // check int64 with sql.NullInt64 if it is zero + if input.ViewID != 0 { + m.SetViewID(input.ViewID) + } + case viewresource.FieldResourceID: + // check int64 with sql.NullInt64 if it is zero + if input.ResourceID != 0 { + m.SetResourceID(input.ResourceID) + } + case viewresource.FieldID: + // check int64 with sql.NullInt64 if it is zero + if input.ID != 0 { + m.SetID(input.ID) + } + default: + return fmt.Errorf("unknown ViewResource field %s", fields[i]) + } + } + return nil +} + +// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *ViewResourceMutation) SetFieldsWithZero(input *ViewResource, fields ...string) error { + for i := range fields { + switch fields[i] { + case viewresource.FieldCreateAuthor: + m.SetCreateAuthor(input.CreateAuthor) + case viewresource.FieldUpdateAuthor: + m.SetUpdateAuthor(input.UpdateAuthor) + case viewresource.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case viewresource.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case viewresource.FieldViewID: + m.SetViewID(input.ViewID) + case viewresource.FieldResourceID: + m.SetResourceID(input.ResourceID) + case viewresource.FieldID: + m.SetID(input.ID) + default: + return fmt.Errorf("unknown ViewResource field %s", fields[i]) + } + } + return nil +} diff --git a/internal/data/entity/ent/notification.go b/internal/data/entity/ent/notification.go index 3ba29436..65b8b4df 100644 --- a/internal/data/entity/ent/notification.go +++ b/internal/data/entity/ent/notification.go @@ -5,6 +5,7 @@ package ent import ( "fmt" "origadmin/application/admin/internal/data/entity/ent/notification" + "origadmin/application/admin/internal/data/enums" "strings" "time" @@ -31,7 +32,7 @@ type Notification struct { // entity.notification.field.content Content string `json:"content,omitempty"` // entity.notification.field.status - Status int8 `json:"status,omitempty"` + Status enums.Status `json:"status,omitempty"` // entity.notification.field.category_id CategoryID int64 `json:"category_id,omitempty"` selectValues sql.SelectValues @@ -109,7 +110,7 @@ func (_m *Notification) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - _m.Status = int8(value.Int64) + _m.Status = enums.Status(value.Int64) } case notification.FieldCategoryID: if value, ok := values[i].(*sql.NullInt64); !ok { diff --git a/internal/data/entity/ent/notification/notification.go b/internal/data/entity/ent/notification/notification.go index 54c36347..49cadcb9 100644 --- a/internal/data/entity/ent/notification/notification.go +++ b/internal/data/entity/ent/notification/notification.go @@ -3,6 +3,7 @@ package notification import ( + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -72,7 +73,7 @@ var ( // DefaultContent holds the default value on creation for the "content" field. DefaultContent string // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 + DefaultStatus enums.Status // CategoryIDValidator is a validator for the "category_id" field. It is called by the builders before save. CategoryIDValidator func(int64) error // DefaultID holds the default value on creation for the "id" field. diff --git a/internal/data/entity/ent/notification/where.go b/internal/data/entity/ent/notification/where.go index 11f751f2..75391462 100644 --- a/internal/data/entity/ent/notification/where.go +++ b/internal/data/entity/ent/notification/where.go @@ -4,6 +4,7 @@ package notification import ( "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -85,8 +86,9 @@ func Content(v string) predicate.Notification { } // Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.Notification { - return predicate.Notification(sql.FieldEQ(FieldStatus, v)) +func Status(v enums.Status) predicate.Notification { + vc := int8(v) + return predicate.Notification(sql.FieldEQ(FieldStatus, vc)) } // CategoryID applies equality check predicate on the "category_id" field. It's identical to CategoryIDEQ. @@ -405,43 +407,57 @@ func ContentContainsFold(v string) predicate.Notification { } // StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.Notification { - return predicate.Notification(sql.FieldEQ(FieldStatus, v)) +func StatusEQ(v enums.Status) predicate.Notification { + vc := int8(v) + return predicate.Notification(sql.FieldEQ(FieldStatus, vc)) } // StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.Notification { - return predicate.Notification(sql.FieldNEQ(FieldStatus, v)) +func StatusNEQ(v enums.Status) predicate.Notification { + vc := int8(v) + return predicate.Notification(sql.FieldNEQ(FieldStatus, vc)) } // StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.Notification { - return predicate.Notification(sql.FieldIn(FieldStatus, vs...)) +func StatusIn(vs ...enums.Status) predicate.Notification { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Notification(sql.FieldIn(FieldStatus, v...)) } // StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.Notification { - return predicate.Notification(sql.FieldNotIn(FieldStatus, vs...)) +func StatusNotIn(vs ...enums.Status) predicate.Notification { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Notification(sql.FieldNotIn(FieldStatus, v...)) } // StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.Notification { - return predicate.Notification(sql.FieldGT(FieldStatus, v)) +func StatusGT(v enums.Status) predicate.Notification { + vc := int8(v) + return predicate.Notification(sql.FieldGT(FieldStatus, vc)) } // StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.Notification { - return predicate.Notification(sql.FieldGTE(FieldStatus, v)) +func StatusGTE(v enums.Status) predicate.Notification { + vc := int8(v) + return predicate.Notification(sql.FieldGTE(FieldStatus, vc)) } // StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.Notification { - return predicate.Notification(sql.FieldLT(FieldStatus, v)) +func StatusLT(v enums.Status) predicate.Notification { + vc := int8(v) + return predicate.Notification(sql.FieldLT(FieldStatus, vc)) } // StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.Notification { - return predicate.Notification(sql.FieldLTE(FieldStatus, v)) +func StatusLTE(v enums.Status) predicate.Notification { + vc := int8(v) + return predicate.Notification(sql.FieldLTE(FieldStatus, vc)) } // CategoryIDEQ applies the EQ predicate on the "category_id" field. diff --git a/internal/data/entity/ent/notification_create.go b/internal/data/entity/ent/notification_create.go index 1f5dc888..211d92a9 100644 --- a/internal/data/entity/ent/notification_create.go +++ b/internal/data/entity/ent/notification_create.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "origadmin/application/admin/internal/data/entity/ent/notification" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -105,13 +106,13 @@ func (_c *NotificationCreate) SetNillableContent(v *string) *NotificationCreate } // SetStatus sets the "status" field. -func (_c *NotificationCreate) SetStatus(v int8) *NotificationCreate { +func (_c *NotificationCreate) SetStatus(v enums.Status) *NotificationCreate { _c.mutation.SetStatus(v) return _c } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *NotificationCreate) SetNillableStatus(v *int8) *NotificationCreate { +func (_c *NotificationCreate) SetNillableStatus(v *enums.Status) *NotificationCreate { if v != nil { _c.SetStatus(*v) } diff --git a/internal/data/entity/ent/notification_query.go b/internal/data/entity/ent/notification_query.go index 019f2615..ad950cd2 100644 --- a/internal/data/entity/ent/notification_query.go +++ b/internal/data/entity/ent/notification_query.go @@ -491,7 +491,7 @@ func (_q *NotificationQuery) Modify(modifiers ...func(s *sql.Selector)) *Notific // UpdateTime time.Time `json:"update_time,omitempty"` // Subject string `json:"subject,omitempty"` // Content string `json:"content,omitempty"` -// Status int8 `json:"status,omitempty"` +// Status enums.Status `json:"status,omitempty"` // CategoryID int64 `json:"category_id,omitempty"` // } // diff --git a/internal/data/entity/ent/notification_update.go b/internal/data/entity/ent/notification_update.go index 6d245c9b..675ce5ec 100644 --- a/internal/data/entity/ent/notification_update.go +++ b/internal/data/entity/ent/notification_update.go @@ -8,6 +8,7 @@ import ( "fmt" "origadmin/application/admin/internal/data/entity/ent/notification" "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -118,14 +119,14 @@ func (_u *NotificationUpdate) SetNillableContent(v *string) *NotificationUpdate } // SetStatus sets the "status" field. -func (_u *NotificationUpdate) SetStatus(v int8) *NotificationUpdate { +func (_u *NotificationUpdate) SetStatus(v enums.Status) *NotificationUpdate { _u.mutation.ResetStatus() _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *NotificationUpdate) SetNillableStatus(v *int8) *NotificationUpdate { +func (_u *NotificationUpdate) SetNillableStatus(v *enums.Status) *NotificationUpdate { if v != nil { _u.SetStatus(*v) } @@ -133,7 +134,7 @@ func (_u *NotificationUpdate) SetNillableStatus(v *int8) *NotificationUpdate { } // AddStatus adds value to the "status" field. -func (_u *NotificationUpdate) AddStatus(v int8) *NotificationUpdate { +func (_u *NotificationUpdate) AddStatus(v enums.Status) *NotificationUpdate { _u.mutation.AddStatus(v) return _u } @@ -378,14 +379,14 @@ func (_u *NotificationUpdateOne) SetNillableContent(v *string) *NotificationUpda } // SetStatus sets the "status" field. -func (_u *NotificationUpdateOne) SetStatus(v int8) *NotificationUpdateOne { +func (_u *NotificationUpdateOne) SetStatus(v enums.Status) *NotificationUpdateOne { _u.mutation.ResetStatus() _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *NotificationUpdateOne) SetNillableStatus(v *int8) *NotificationUpdateOne { +func (_u *NotificationUpdateOne) SetNillableStatus(v *enums.Status) *NotificationUpdateOne { if v != nil { _u.SetStatus(*v) } @@ -393,7 +394,7 @@ func (_u *NotificationUpdateOne) SetNillableStatus(v *int8) *NotificationUpdateO } // AddStatus adds value to the "status" field. -func (_u *NotificationUpdateOne) AddStatus(v int8) *NotificationUpdateOne { +func (_u *NotificationUpdateOne) AddStatus(v enums.Status) *NotificationUpdateOne { _u.mutation.AddStatus(v) return _u } diff --git a/internal/data/entity/ent/permission.go b/internal/data/entity/ent/permission.go index 199011c1..86ccdd64 100644 --- a/internal/data/entity/ent/permission.go +++ b/internal/data/entity/ent/permission.go @@ -57,9 +57,11 @@ type PermissionEdges struct { PositionPermissions []*PositionPermission `json:"position_permissions,omitempty"` // PermissionResources holds the value of the permission_resources edge. PermissionResources []*PermissionResource `json:"permission_resources,omitempty"` + // ViewPermissions holds the value of the view_permissions edge. + ViewPermissions []*ViewPermission `json:"view_permissions,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [7]bool + loadedTypes [8]bool } // RolesOrErr returns the Roles value or an error if the edge @@ -125,6 +127,15 @@ func (e PermissionEdges) PermissionResourcesOrErr() ([]*PermissionResource, erro return nil, &NotLoadedError{edge: "permission_resources"} } +// ViewPermissionsOrErr returns the ViewPermissions value or an error if the edge +// was not loaded in eager-loading. +func (e PermissionEdges) ViewPermissionsOrErr() ([]*ViewPermission, error) { + if e.loadedTypes[7] { + return e.ViewPermissions, nil + } + return nil, &NotLoadedError{edge: "view_permissions"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Permission) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -257,6 +268,11 @@ func (_m *Permission) QueryPermissionResources() *PermissionResourceQuery { return NewPermissionClient(_m.config).QueryPermissionResources(_m) } +// QueryViewPermissions queries the "view_permissions" edge of the Permission entity. +func (_m *Permission) QueryViewPermissions() *ViewPermissionQuery { + return NewPermissionClient(_m.config).QueryViewPermissions(_m) +} + // Update returns a builder for updating this Permission. // Note that you need to call Permission.Unwrap() before calling this method if this Permission // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/internal/data/entity/ent/permission/permission.go b/internal/data/entity/ent/permission/permission.go index 84632cc0..cac2d900 100644 --- a/internal/data/entity/ent/permission/permission.go +++ b/internal/data/entity/ent/permission/permission.go @@ -45,6 +45,8 @@ const ( EdgePositionPermissions = "position_permissions" // EdgePermissionResources holds the string denoting the permission_resources edge name in mutations. EdgePermissionResources = "permission_resources" + // EdgeViewPermissions holds the string denoting the view_permissions edge name in mutations. + EdgeViewPermissions = "view_permissions" // Table holds the table name of the permission in the database. Table = "sys_permissions" // RolesTable is the table that holds the roles relation/edge. The primary key declared below. @@ -63,7 +65,7 @@ const ( // It exists in this package in order to avoid circular dependency with the "resource" package. ResourcesInverseTable = "resources" // ViewsTable is the table that holds the views relation/edge. The primary key declared below. - ViewsTable = "permission_views" + ViewsTable = "sys_view_permissions" // ViewsInverseTable is the table name for the View entity. // It exists in this package in order to avoid circular dependency with the "view" package. ViewsInverseTable = "views" @@ -88,6 +90,13 @@ const ( PermissionResourcesInverseTable = "sys_permission_resources" // PermissionResourcesColumn is the table column denoting the permission_resources relation/edge. PermissionResourcesColumn = "permission_id" + // ViewPermissionsTable is the table that holds the view_permissions relation/edge. + ViewPermissionsTable = "sys_view_permissions" + // ViewPermissionsInverseTable is the table name for the ViewPermission entity. + // It exists in this package in order to avoid circular dependency with the "viewpermission" package. + ViewPermissionsInverseTable = "sys_view_permissions" + // ViewPermissionsColumn is the table column denoting the view_permissions relation/edge. + ViewPermissionsColumn = "permission_id" ) // Columns holds all SQL columns for permission fields. @@ -115,7 +124,7 @@ var ( ResourcesPrimaryKey = []string{"permission_id", "resource_id"} // ViewsPrimaryKey and ViewsColumn2 are the table columns denoting the // primary key for the views relation (M2M). - ViewsPrimaryKey = []string{"permission_id", "view_id"} + ViewsPrimaryKey = []string{"view_id", "permission_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -321,6 +330,20 @@ func ByPermissionResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOpti sqlgraph.OrderByNeighborTerms(s, newPermissionResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByViewPermissionsCount orders the results by view_permissions count. +func ByViewPermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newViewPermissionsStep(), opts...) + } +} + +// ByViewPermissions orders the results by view_permissions terms. +func ByViewPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newViewPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newRolesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -346,7 +369,7 @@ func newViewsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(ViewsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, ViewsTable, ViewsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, ViewsTable, ViewsPrimaryKey...), ) } func newRolePermissionsStep() *sqlgraph.Step { @@ -370,6 +393,13 @@ func newPermissionResourcesStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.O2M, true, PermissionResourcesTable, PermissionResourcesColumn), ) } +func newViewPermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ViewPermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ViewPermissionsTable, ViewPermissionsColumn), + ) +} // SelectColumns returns all selected fields. func SelectColumns(fields []string) []string { diff --git a/internal/data/entity/ent/permission/where.go b/internal/data/entity/ent/permission/where.go index 73790eb2..aed383e5 100644 --- a/internal/data/entity/ent/permission/where.go +++ b/internal/data/entity/ent/permission/where.go @@ -529,7 +529,7 @@ func HasViews() predicate.Permission { return predicate.Permission(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, ViewsTable, ViewsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, ViewsTable, ViewsPrimaryKey...), ) sqlgraph.HasNeighbors(s, step) }) @@ -616,6 +616,29 @@ func HasPermissionResourcesWith(preds ...predicate.PermissionResource) predicate }) } +// HasViewPermissions applies the HasEdge predicate on the "view_permissions" edge. +func HasViewPermissions() predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ViewPermissionsTable, ViewPermissionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasViewPermissionsWith applies the HasEdge predicate on the "view_permissions" edge with a given conditions (other predicates). +func HasViewPermissionsWith(preds ...predicate.ViewPermission) predicate.Permission { + return predicate.Permission(func(s *sql.Selector) { + step := newViewPermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Permission) predicate.Permission { return predicate.Permission(sql.AndPredicates(predicates...)) diff --git a/internal/data/entity/ent/permission_create.go b/internal/data/entity/ent/permission_create.go index 7a9d7608..4d2da4ab 100644 --- a/internal/data/entity/ent/permission_create.go +++ b/internal/data/entity/ent/permission_create.go @@ -14,6 +14,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/role" "origadmin/application/admin/internal/data/entity/ent/rolepermission" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -242,6 +243,21 @@ func (_c *PermissionCreate) AddPermissionResources(v ...*PermissionResource) *Pe return _c.AddPermissionResourceIDs(ids...) } +// AddViewPermissionIDs adds the "view_permissions" edge to the ViewPermission entity by IDs. +func (_c *PermissionCreate) AddViewPermissionIDs(ids ...int64) *PermissionCreate { + _c.mutation.AddViewPermissionIDs(ids...) + return _c +} + +// AddViewPermissions adds the "view_permissions" edges to the ViewPermission entity. +func (_c *PermissionCreate) AddViewPermissions(v ...*ViewPermission) *PermissionCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddViewPermissionIDs(ids...) +} + // Mutation returns the PermissionMutation object of the builder. func (_c *PermissionCreate) Mutation() *PermissionMutation { return _c.mutation @@ -470,7 +486,7 @@ func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { if nodes := _c.mutation.ViewsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: permission.ViewsTable, Columns: permission.ViewsPrimaryKey, Bidi: false, @@ -481,6 +497,13 @@ func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewPermissionCreate{config: _c.config, mutation: newViewPermissionMutation(_c.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.RolePermissionsIDs(); len(nodes) > 0 { @@ -531,6 +554,22 @@ func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := _c.mutation.ViewPermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.ViewPermissionsTable, + Columns: []string{permission.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/internal/data/entity/ent/permission_query.go b/internal/data/entity/ent/permission_query.go index c7b684c0..98bc1802 100644 --- a/internal/data/entity/ent/permission_query.go +++ b/internal/data/entity/ent/permission_query.go @@ -16,6 +16,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/role" "origadmin/application/admin/internal/data/entity/ent/rolepermission" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" "entgo.io/ent" "entgo.io/ent/dialect" @@ -38,6 +39,7 @@ type PermissionQuery struct { withRolePermissions *RolePermissionQuery withPositionPermissions *PositionPermissionQuery withPermissionResources *PermissionResourceQuery + withViewPermissions *ViewPermissionQuery modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector @@ -155,7 +157,7 @@ func (_q *PermissionQuery) QueryViews() *ViewQuery { step := sqlgraph.NewStep( sqlgraph.From(permission.Table, permission.FieldID, selector), sqlgraph.To(view.Table, view.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, permission.ViewsTable, permission.ViewsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, permission.ViewsTable, permission.ViewsPrimaryKey...), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -229,6 +231,28 @@ func (_q *PermissionQuery) QueryPermissionResources() *PermissionResourceQuery { return query } +// QueryViewPermissions chains the current query on the "view_permissions" edge. +func (_q *PermissionQuery) QueryViewPermissions() *ViewPermissionQuery { + query := (&ViewPermissionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(permission.Table, permission.FieldID, selector), + sqlgraph.To(viewpermission.Table, viewpermission.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, permission.ViewPermissionsTable, permission.ViewPermissionsColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Permission entity from the query. // Returns a *NotFoundError when no Permission was found. func (_q *PermissionQuery) First(ctx context.Context) (*Permission, error) { @@ -428,6 +452,7 @@ func (_q *PermissionQuery) Clone() *PermissionQuery { withRolePermissions: _q.withRolePermissions.Clone(), withPositionPermissions: _q.withPositionPermissions.Clone(), withPermissionResources: _q.withPermissionResources.Clone(), + withViewPermissions: _q.withViewPermissions.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, @@ -512,6 +537,17 @@ func (_q *PermissionQuery) WithPermissionResources(opts ...func(*PermissionResou return _q } +// WithViewPermissions tells the query-builder to eager-load the nodes that are connected to +// the "view_permissions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *PermissionQuery) WithViewPermissions(opts ...func(*ViewPermissionQuery)) *PermissionQuery { + query := (&ViewPermissionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withViewPermissions = query + return _q +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -590,7 +626,7 @@ func (_q *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*P var ( nodes = []*Permission{} _spec = _q.querySpec() - loadedTypes = [7]bool{ + loadedTypes = [8]bool{ _q.withRoles != nil, _q.withPositions != nil, _q.withResources != nil, @@ -598,6 +634,7 @@ func (_q *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*P _q.withRolePermissions != nil, _q.withPositionPermissions != nil, _q.withPermissionResources != nil, + _q.withViewPermissions != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -674,6 +711,13 @@ func (_q *PermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*P return nil, err } } + if query := _q.withViewPermissions; query != nil { + if err := _q.loadViewPermissions(ctx, query, nodes, + func(n *Permission) { n.Edges.ViewPermissions = []*ViewPermission{} }, + func(n *Permission, e *ViewPermission) { n.Edges.ViewPermissions = append(n.Edges.ViewPermissions, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -873,10 +917,10 @@ func (_q *PermissionQuery) loadViews(ctx context.Context, query *ViewQuery, node } query.Where(func(s *sql.Selector) { joinT := sql.Table(permission.ViewsTable) - s.Join(joinT).On(s.C(view.FieldID), joinT.C(permission.ViewsPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(permission.ViewsPrimaryKey[0]), edgeIDs...)) + s.Join(joinT).On(s.C(view.FieldID), joinT.C(permission.ViewsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(permission.ViewsPrimaryKey[1]), edgeIDs...)) columns := s.SelectedColumns() - s.Select(joinT.C(permission.ViewsPrimaryKey[0])) + s.Select(joinT.C(permission.ViewsPrimaryKey[1])) s.AppendSelect(columns...) s.SetDistinct(false) }) @@ -1011,6 +1055,36 @@ func (_q *PermissionQuery) loadPermissionResources(ctx context.Context, query *P } return nil } +func (_q *PermissionQuery) loadViewPermissions(ctx context.Context, query *ViewPermissionQuery, nodes []*Permission, init func(*Permission), assign func(*Permission, *ViewPermission)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*Permission) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(viewpermission.FieldPermissionID) + } + query.Where(predicate.ViewPermission(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(permission.ViewPermissionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.PermissionID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "permission_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (_q *PermissionQuery) sqlCount(ctx context.Context) (int, error) { _spec := _q.querySpec() diff --git a/internal/data/entity/ent/permission_update.go b/internal/data/entity/ent/permission_update.go index fad1606b..3bce2351 100644 --- a/internal/data/entity/ent/permission_update.go +++ b/internal/data/entity/ent/permission_update.go @@ -15,6 +15,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/role" "origadmin/application/admin/internal/data/entity/ent/rolepermission" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" "time" "entgo.io/ent/dialect/sql" @@ -229,6 +230,21 @@ func (_u *PermissionUpdate) AddPermissionResources(v ...*PermissionResource) *Pe return _u.AddPermissionResourceIDs(ids...) } +// AddViewPermissionIDs adds the "view_permissions" edge to the ViewPermission entity by IDs. +func (_u *PermissionUpdate) AddViewPermissionIDs(ids ...int64) *PermissionUpdate { + _u.mutation.AddViewPermissionIDs(ids...) + return _u +} + +// AddViewPermissions adds the "view_permissions" edges to the ViewPermission entity. +func (_u *PermissionUpdate) AddViewPermissions(v ...*ViewPermission) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddViewPermissionIDs(ids...) +} + // Mutation returns the PermissionMutation object of the builder. func (_u *PermissionUpdate) Mutation() *PermissionMutation { return _u.mutation @@ -381,6 +397,27 @@ func (_u *PermissionUpdate) RemovePermissionResources(v ...*PermissionResource) return _u.RemovePermissionResourceIDs(ids...) } +// ClearViewPermissions clears all "view_permissions" edges to the ViewPermission entity. +func (_u *PermissionUpdate) ClearViewPermissions() *PermissionUpdate { + _u.mutation.ClearViewPermissions() + return _u +} + +// RemoveViewPermissionIDs removes the "view_permissions" edge to ViewPermission entities by IDs. +func (_u *PermissionUpdate) RemoveViewPermissionIDs(ids ...int64) *PermissionUpdate { + _u.mutation.RemoveViewPermissionIDs(ids...) + return _u +} + +// RemoveViewPermissions removes "view_permissions" edges to ViewPermission entities. +func (_u *PermissionUpdate) RemoveViewPermissions(v ...*ViewPermission) *PermissionUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveViewPermissionIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (_u *PermissionUpdate) Save(ctx context.Context) (int, error) { _u.defaults() @@ -622,7 +659,7 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) if _u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: permission.ViewsTable, Columns: permission.ViewsPrimaryKey, Bidi: false, @@ -630,12 +667,19 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedViewsIDs(); len(nodes) > 0 && !_u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: permission.ViewsTable, Columns: permission.ViewsPrimaryKey, Bidi: false, @@ -646,12 +690,19 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ViewsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: permission.ViewsTable, Columns: permission.ViewsPrimaryKey, Bidi: false, @@ -662,6 +713,13 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.RolePermissionsCleared() { @@ -799,6 +857,51 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.ViewPermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.ViewPermissionsTable, + Columns: []string{permission.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedViewPermissionsIDs(); len(nodes) > 0 && !_u.mutation.ViewPermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.ViewPermissionsTable, + Columns: []string{permission.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewPermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.ViewPermissionsTable, + Columns: []string{permission.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -1014,6 +1117,21 @@ func (_u *PermissionUpdateOne) AddPermissionResources(v ...*PermissionResource) return _u.AddPermissionResourceIDs(ids...) } +// AddViewPermissionIDs adds the "view_permissions" edge to the ViewPermission entity by IDs. +func (_u *PermissionUpdateOne) AddViewPermissionIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.AddViewPermissionIDs(ids...) + return _u +} + +// AddViewPermissions adds the "view_permissions" edges to the ViewPermission entity. +func (_u *PermissionUpdateOne) AddViewPermissions(v ...*ViewPermission) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddViewPermissionIDs(ids...) +} + // Mutation returns the PermissionMutation object of the builder. func (_u *PermissionUpdateOne) Mutation() *PermissionMutation { return _u.mutation @@ -1166,6 +1284,27 @@ func (_u *PermissionUpdateOne) RemovePermissionResources(v ...*PermissionResourc return _u.RemovePermissionResourceIDs(ids...) } +// ClearViewPermissions clears all "view_permissions" edges to the ViewPermission entity. +func (_u *PermissionUpdateOne) ClearViewPermissions() *PermissionUpdateOne { + _u.mutation.ClearViewPermissions() + return _u +} + +// RemoveViewPermissionIDs removes the "view_permissions" edge to ViewPermission entities by IDs. +func (_u *PermissionUpdateOne) RemoveViewPermissionIDs(ids ...int64) *PermissionUpdateOne { + _u.mutation.RemoveViewPermissionIDs(ids...) + return _u +} + +// RemoveViewPermissions removes "view_permissions" edges to ViewPermission entities. +func (_u *PermissionUpdateOne) RemoveViewPermissions(v ...*ViewPermission) *PermissionUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveViewPermissionIDs(ids...) +} + // Where appends a list predicates to the PermissionUpdate builder. func (_u *PermissionUpdateOne) Where(ps ...predicate.Permission) *PermissionUpdateOne { _u.mutation.Where(ps...) @@ -1437,7 +1576,7 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, if _u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: permission.ViewsTable, Columns: permission.ViewsPrimaryKey, Bidi: false, @@ -1445,12 +1584,19 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedViewsIDs(); len(nodes) > 0 && !_u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: permission.ViewsTable, Columns: permission.ViewsPrimaryKey, Bidi: false, @@ -1461,12 +1607,19 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ViewsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: permission.ViewsTable, Columns: permission.ViewsPrimaryKey, Bidi: false, @@ -1477,6 +1630,13 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.RolePermissionsCleared() { @@ -1614,6 +1774,51 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.ViewPermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.ViewPermissionsTable, + Columns: []string{permission.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedViewPermissionsIDs(); len(nodes) > 0 && !_u.mutation.ViewPermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.ViewPermissionsTable, + Columns: []string{permission.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewPermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: permission.ViewPermissionsTable, + Columns: []string{permission.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(_u.modifiers...) _node = &Permission{config: _u.config} _spec.Assign = _node.assignValues diff --git a/internal/data/entity/ent/predicate/predicate.go b/internal/data/entity/ent/predicate/predicate.go index 88e73f21..6e5fde87 100644 --- a/internal/data/entity/ent/predicate/predicate.go +++ b/internal/data/entity/ent/predicate/predicate.go @@ -50,3 +50,9 @@ type UserRole func(*sql.Selector) // View is the predicate function for view builders. type View func(*sql.Selector) + +// ViewPermission is the predicate function for viewpermission builders. +type ViewPermission func(*sql.Selector) + +// ViewResource is the predicate function for viewresource builders. +type ViewResource func(*sql.Selector) diff --git a/internal/data/entity/ent/resource.go b/internal/data/entity/ent/resource.go index 761211c8..42753cbe 100644 --- a/internal/data/entity/ent/resource.go +++ b/internal/data/entity/ent/resource.go @@ -54,9 +54,11 @@ type ResourceEdges struct { Views []*View `json:"views,omitempty"` // Permissions holds the value of the permissions edge. Permissions []*Permission `json:"permissions,omitempty"` + // ViewResources holds the value of the view_resources edge. + ViewResources []*ViewResource `json:"view_resources,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [2]bool + loadedTypes [3]bool } // ViewsOrErr returns the Views value or an error if the edge @@ -77,6 +79,15 @@ func (e ResourceEdges) PermissionsOrErr() ([]*Permission, error) { return nil, &NotLoadedError{edge: "permissions"} } +// ViewResourcesOrErr returns the ViewResources value or an error if the edge +// was not loaded in eager-loading. +func (e ResourceEdges) ViewResourcesOrErr() ([]*ViewResource, error) { + if e.loadedTypes[2] { + return e.ViewResources, nil + } + return nil, &NotLoadedError{edge: "view_resources"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*Resource) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -204,6 +215,11 @@ func (_m *Resource) QueryPermissions() *PermissionQuery { return NewResourceClient(_m.config).QueryPermissions(_m) } +// QueryViewResources queries the "view_resources" edge of the Resource entity. +func (_m *Resource) QueryViewResources() *ViewResourceQuery { + return NewResourceClient(_m.config).QueryViewResources(_m) +} + // Update returns a builder for updating this Resource. // Note that you need to call Resource.Unwrap() before calling this method if this Resource // was returned from a transaction, and the transaction was committed or rolled back. diff --git a/internal/data/entity/ent/resource/resource.go b/internal/data/entity/ent/resource/resource.go index b5ca2263..bba448b6 100644 --- a/internal/data/entity/ent/resource/resource.go +++ b/internal/data/entity/ent/resource/resource.go @@ -43,10 +43,12 @@ const ( EdgeViews = "views" // EdgePermissions holds the string denoting the permissions edge name in mutations. EdgePermissions = "permissions" + // EdgeViewResources holds the string denoting the view_resources edge name in mutations. + EdgeViewResources = "view_resources" // Table holds the table name of the resource in the database. Table = "resources" // ViewsTable is the table that holds the views relation/edge. The primary key declared below. - ViewsTable = "resource_views" + ViewsTable = "sys_view_resources" // ViewsInverseTable is the table name for the View entity. // It exists in this package in order to avoid circular dependency with the "view" package. ViewsInverseTable = "views" @@ -55,6 +57,13 @@ const ( // PermissionsInverseTable is the table name for the Permission entity. // It exists in this package in order to avoid circular dependency with the "permission" package. PermissionsInverseTable = "sys_permissions" + // ViewResourcesTable is the table that holds the view_resources relation/edge. + ViewResourcesTable = "sys_view_resources" + // ViewResourcesInverseTable is the table name for the ViewResource entity. + // It exists in this package in order to avoid circular dependency with the "viewresource" package. + ViewResourcesInverseTable = "sys_view_resources" + // ViewResourcesColumn is the table column denoting the view_resources relation/edge. + ViewResourcesColumn = "resource_id" ) // Columns holds all SQL columns for resource fields. @@ -77,7 +86,7 @@ var Columns = []string{ var ( // ViewsPrimaryKey and ViewsColumn2 are the table columns denoting the // primary key for the views relation (M2M). - ViewsPrimaryKey = []string{"resource_id", "view_id"} + ViewsPrimaryKey = []string{"view_id", "resource_id"} // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the // primary key for the permissions relation (M2M). PermissionsPrimaryKey = []string{"permission_id", "resource_id"} @@ -237,11 +246,25 @@ func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByViewResourcesCount orders the results by view_resources count. +func ByViewResourcesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newViewResourcesStep(), opts...) + } +} + +// ByViewResources orders the results by view_resources terms. +func ByViewResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newViewResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newViewsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(ViewsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, ViewsTable, ViewsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, ViewsTable, ViewsPrimaryKey...), ) } func newPermissionsStep() *sqlgraph.Step { @@ -251,6 +274,13 @@ func newPermissionsStep() *sqlgraph.Step { sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), ) } +func newViewResourcesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ViewResourcesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ViewResourcesTable, ViewResourcesColumn), + ) +} // SelectColumns returns all selected fields. func SelectColumns(fields []string) []string { diff --git a/internal/data/entity/ent/resource/where.go b/internal/data/entity/ent/resource/where.go index 62303acc..a83f7158 100644 --- a/internal/data/entity/ent/resource/where.go +++ b/internal/data/entity/ent/resource/where.go @@ -825,7 +825,7 @@ func HasViews() predicate.Resource { return predicate.Resource(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, ViewsTable, ViewsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, ViewsTable, ViewsPrimaryKey...), ) sqlgraph.HasNeighbors(s, step) }) @@ -866,6 +866,29 @@ func HasPermissionsWith(preds ...predicate.Permission) predicate.Resource { }) } +// HasViewResources applies the HasEdge predicate on the "view_resources" edge. +func HasViewResources() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ViewResourcesTable, ViewResourcesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasViewResourcesWith applies the HasEdge predicate on the "view_resources" edge with a given conditions (other predicates). +func HasViewResourcesWith(preds ...predicate.ViewResource) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newViewResourcesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.Resource) predicate.Resource { return predicate.Resource(sql.AndPredicates(predicates...)) diff --git a/internal/data/entity/ent/resource_create.go b/internal/data/entity/ent/resource_create.go index f427f632..8778d88a 100644 --- a/internal/data/entity/ent/resource_create.go +++ b/internal/data/entity/ent/resource_create.go @@ -9,6 +9,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewresource" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -218,6 +219,21 @@ func (_c *ResourceCreate) AddPermissions(v ...*Permission) *ResourceCreate { return _c.AddPermissionIDs(ids...) } +// AddViewResourceIDs adds the "view_resources" edge to the ViewResource entity by IDs. +func (_c *ResourceCreate) AddViewResourceIDs(ids ...int64) *ResourceCreate { + _c.mutation.AddViewResourceIDs(ids...) + return _c +} + +// AddViewResources adds the "view_resources" edges to the ViewResource entity. +func (_c *ResourceCreate) AddViewResources(v ...*ViewResource) *ResourceCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddViewResourceIDs(ids...) +} + // Mutation returns the ResourceMutation object of the builder. func (_c *ResourceCreate) Mutation() *ResourceMutation { return _c.mutation @@ -414,7 +430,7 @@ func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { if nodes := _c.mutation.ViewsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: resource.ViewsTable, Columns: resource.ViewsPrimaryKey, Bidi: false, @@ -425,6 +441,13 @@ func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewResourceCreate{config: _c.config, mutation: newViewResourceMutation(_c.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { @@ -443,6 +466,22 @@ func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } + if nodes := _c.mutation.ViewResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.ViewResourcesTable, + Columns: []string{resource.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } return _node, _spec } diff --git a/internal/data/entity/ent/resource_query.go b/internal/data/entity/ent/resource_query.go index 99d6894c..18e9be90 100644 --- a/internal/data/entity/ent/resource_query.go +++ b/internal/data/entity/ent/resource_query.go @@ -11,6 +11,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/predicate" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewresource" "entgo.io/ent" "entgo.io/ent/dialect" @@ -22,13 +23,14 @@ import ( // ResourceQuery is the builder for querying Resource entities. type ResourceQuery struct { config - ctx *QueryContext - order []resource.OrderOption - inters []Interceptor - predicates []predicate.Resource - withViews *ViewQuery - withPermissions *PermissionQuery - modifiers []func(*sql.Selector) + ctx *QueryContext + order []resource.OrderOption + inters []Interceptor + predicates []predicate.Resource + withViews *ViewQuery + withPermissions *PermissionQuery + withViewResources *ViewResourceQuery + modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -79,7 +81,7 @@ func (_q *ResourceQuery) QueryViews() *ViewQuery { step := sqlgraph.NewStep( sqlgraph.From(resource.Table, resource.FieldID, selector), sqlgraph.To(view.Table, view.FieldID), - sqlgraph.Edge(sqlgraph.M2M, false, resource.ViewsTable, resource.ViewsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, true, resource.ViewsTable, resource.ViewsPrimaryKey...), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -109,6 +111,28 @@ func (_q *ResourceQuery) QueryPermissions() *PermissionQuery { return query } +// QueryViewResources chains the current query on the "view_resources" edge. +func (_q *ResourceQuery) QueryViewResources() *ViewResourceQuery { + query := (&ViewResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, selector), + sqlgraph.To(viewresource.Table, viewresource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, resource.ViewResourcesTable, resource.ViewResourcesColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + // First returns the first Resource entity from the query. // Returns a *NotFoundError when no Resource was found. func (_q *ResourceQuery) First(ctx context.Context) (*Resource, error) { @@ -296,13 +320,14 @@ func (_q *ResourceQuery) Clone() *ResourceQuery { return nil } return &ResourceQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]resource.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.Resource{}, _q.predicates...), - withViews: _q.withViews.Clone(), - withPermissions: _q.withPermissions.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]resource.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Resource{}, _q.predicates...), + withViews: _q.withViews.Clone(), + withPermissions: _q.withPermissions.Clone(), + withViewResources: _q.withViewResources.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, @@ -332,6 +357,17 @@ func (_q *ResourceQuery) WithPermissions(opts ...func(*PermissionQuery)) *Resour return _q } +// WithViewResources tells the query-builder to eager-load the nodes that are connected to +// the "view_resources" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ResourceQuery) WithViewResources(opts ...func(*ViewResourceQuery)) *ResourceQuery { + query := (&ViewResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withViewResources = query + return _q +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -410,9 +446,10 @@ func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Res var ( nodes = []*Resource{} _spec = _q.querySpec() - loadedTypes = [2]bool{ + loadedTypes = [3]bool{ _q.withViews != nil, _q.withPermissions != nil, + _q.withViewResources != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -450,6 +487,13 @@ func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Res return nil, err } } + if query := _q.withViewResources; query != nil { + if err := _q.loadViewResources(ctx, query, nodes, + func(n *Resource) { n.Edges.ViewResources = []*ViewResource{} }, + func(n *Resource, e *ViewResource) { n.Edges.ViewResources = append(n.Edges.ViewResources, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -466,10 +510,10 @@ func (_q *ResourceQuery) loadViews(ctx context.Context, query *ViewQuery, nodes } query.Where(func(s *sql.Selector) { joinT := sql.Table(resource.ViewsTable) - s.Join(joinT).On(s.C(view.FieldID), joinT.C(resource.ViewsPrimaryKey[1])) - s.Where(sql.InValues(joinT.C(resource.ViewsPrimaryKey[0]), edgeIDs...)) + s.Join(joinT).On(s.C(view.FieldID), joinT.C(resource.ViewsPrimaryKey[0])) + s.Where(sql.InValues(joinT.C(resource.ViewsPrimaryKey[1]), edgeIDs...)) columns := s.SelectedColumns() - s.Select(joinT.C(resource.ViewsPrimaryKey[0])) + s.Select(joinT.C(resource.ViewsPrimaryKey[1])) s.AppendSelect(columns...) s.SetDistinct(false) }) @@ -575,6 +619,36 @@ func (_q *ResourceQuery) loadPermissions(ctx context.Context, query *PermissionQ } return nil } +func (_q *ResourceQuery) loadViewResources(ctx context.Context, query *ViewResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *ViewResource)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*Resource) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(viewresource.FieldResourceID) + } + query.Where(predicate.ViewResource(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(resource.ViewResourcesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ResourceID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "resource_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (_q *ResourceQuery) sqlCount(ctx context.Context) (int, error) { _spec := _q.querySpec() diff --git a/internal/data/entity/ent/resource_update.go b/internal/data/entity/ent/resource_update.go index b36462fc..c8a7bb81 100644 --- a/internal/data/entity/ent/resource_update.go +++ b/internal/data/entity/ent/resource_update.go @@ -10,6 +10,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/predicate" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewresource" "time" "entgo.io/ent/dialect/sql" @@ -225,6 +226,21 @@ func (_u *ResourceUpdate) AddPermissions(v ...*Permission) *ResourceUpdate { return _u.AddPermissionIDs(ids...) } +// AddViewResourceIDs adds the "view_resources" edge to the ViewResource entity by IDs. +func (_u *ResourceUpdate) AddViewResourceIDs(ids ...int64) *ResourceUpdate { + _u.mutation.AddViewResourceIDs(ids...) + return _u +} + +// AddViewResources adds the "view_resources" edges to the ViewResource entity. +func (_u *ResourceUpdate) AddViewResources(v ...*ViewResource) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddViewResourceIDs(ids...) +} + // Mutation returns the ResourceMutation object of the builder. func (_u *ResourceUpdate) Mutation() *ResourceMutation { return _u.mutation @@ -272,6 +288,27 @@ func (_u *ResourceUpdate) RemovePermissions(v ...*Permission) *ResourceUpdate { return _u.RemovePermissionIDs(ids...) } +// ClearViewResources clears all "view_resources" edges to the ViewResource entity. +func (_u *ResourceUpdate) ClearViewResources() *ResourceUpdate { + _u.mutation.ClearViewResources() + return _u +} + +// RemoveViewResourceIDs removes the "view_resources" edge to ViewResource entities by IDs. +func (_u *ResourceUpdate) RemoveViewResourceIDs(ids ...int64) *ResourceUpdate { + _u.mutation.RemoveViewResourceIDs(ids...) + return _u +} + +// RemoveViewResources removes "view_resources" edges to ViewResource entities. +func (_u *ResourceUpdate) RemoveViewResources(v ...*ViewResource) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveViewResourceIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (_u *ResourceUpdate) Save(ctx context.Context) (int, error) { _u.defaults() @@ -386,7 +423,7 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { if _u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: resource.ViewsTable, Columns: resource.ViewsPrimaryKey, Bidi: false, @@ -394,12 +431,19 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedViewsIDs(); len(nodes) > 0 && !_u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: resource.ViewsTable, Columns: resource.ViewsPrimaryKey, Bidi: false, @@ -410,12 +454,19 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ViewsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: resource.ViewsTable, Columns: resource.ViewsPrimaryKey, Bidi: false, @@ -426,6 +477,13 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.PermissionsCleared() { @@ -473,6 +531,51 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.ViewResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.ViewResourcesTable, + Columns: []string{resource.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedViewResourcesIDs(); len(nodes) > 0 && !_u.mutation.ViewResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.ViewResourcesTable, + Columns: []string{resource.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.ViewResourcesTable, + Columns: []string{resource.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(_u.modifiers...) if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { @@ -689,6 +792,21 @@ func (_u *ResourceUpdateOne) AddPermissions(v ...*Permission) *ResourceUpdateOne return _u.AddPermissionIDs(ids...) } +// AddViewResourceIDs adds the "view_resources" edge to the ViewResource entity by IDs. +func (_u *ResourceUpdateOne) AddViewResourceIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.AddViewResourceIDs(ids...) + return _u +} + +// AddViewResources adds the "view_resources" edges to the ViewResource entity. +func (_u *ResourceUpdateOne) AddViewResources(v ...*ViewResource) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddViewResourceIDs(ids...) +} + // Mutation returns the ResourceMutation object of the builder. func (_u *ResourceUpdateOne) Mutation() *ResourceMutation { return _u.mutation @@ -736,6 +854,27 @@ func (_u *ResourceUpdateOne) RemovePermissions(v ...*Permission) *ResourceUpdate return _u.RemovePermissionIDs(ids...) } +// ClearViewResources clears all "view_resources" edges to the ViewResource entity. +func (_u *ResourceUpdateOne) ClearViewResources() *ResourceUpdateOne { + _u.mutation.ClearViewResources() + return _u +} + +// RemoveViewResourceIDs removes the "view_resources" edge to ViewResource entities by IDs. +func (_u *ResourceUpdateOne) RemoveViewResourceIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.RemoveViewResourceIDs(ids...) + return _u +} + +// RemoveViewResources removes "view_resources" edges to ViewResource entities. +func (_u *ResourceUpdateOne) RemoveViewResources(v ...*ViewResource) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveViewResourceIDs(ids...) +} + // Where appends a list predicates to the ResourceUpdate builder. func (_u *ResourceUpdateOne) Where(ps ...predicate.Resource) *ResourceUpdateOne { _u.mutation.Where(ps...) @@ -880,7 +1019,7 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err if _u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: resource.ViewsTable, Columns: resource.ViewsPrimaryKey, Bidi: false, @@ -888,12 +1027,19 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), }, } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedViewsIDs(); len(nodes) > 0 && !_u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: resource.ViewsTable, Columns: resource.ViewsPrimaryKey, Bidi: false, @@ -904,12 +1050,19 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ViewsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: false, + Inverse: true, Table: resource.ViewsTable, Columns: resource.ViewsPrimaryKey, Bidi: false, @@ -920,6 +1073,13 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.PermissionsCleared() { @@ -967,6 +1127,51 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } + if _u.mutation.ViewResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.ViewResourcesTable, + Columns: []string{resource.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedViewResourcesIDs(); len(nodes) > 0 && !_u.mutation.ViewResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.ViewResourcesTable, + Columns: []string{resource.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: resource.ViewResourcesTable, + Columns: []string{resource.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } _spec.AddModifiers(_u.modifiers...) _node = &Resource{config: _u.config} _spec.Assign = _node.assignValues diff --git a/internal/data/entity/ent/role.go b/internal/data/entity/ent/role.go index 039ff361..c1de1b7d 100644 --- a/internal/data/entity/ent/role.go +++ b/internal/data/entity/ent/role.go @@ -5,6 +5,7 @@ package ent import ( "fmt" "origadmin/application/admin/internal/data/entity/ent/role" + "origadmin/application/admin/internal/data/enums" "strings" "time" @@ -29,11 +30,11 @@ type Role struct { // entity.role.field.description Description string `json:"description,omitempty"` // entity.role.field.type - Type int8 `json:"type,omitempty"` + Type enums.RoleType `json:"type,omitempty"` // entity.role.field.sequence Sequence int `json:"sequence,omitempty"` // entity.role.field.status - Status int8 `json:"status,omitempty"` + Status enums.Status `json:"status,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the RoleQuery when eager-loading is set. Edges RoleEdges `json:"edges"` @@ -157,7 +158,7 @@ func (_m *Role) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) } else if value.Valid { - _m.Type = int8(value.Int64) + _m.Type = enums.RoleType(value.Int64) } case role.FieldSequence: if value, ok := values[i].(*sql.NullInt64); !ok { @@ -169,7 +170,7 @@ func (_m *Role) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - _m.Status = int8(value.Int64) + _m.Status = enums.Status(value.Int64) } default: _m.selectValues.Set(columns[i], values[i]) diff --git a/internal/data/entity/ent/role/role.go b/internal/data/entity/ent/role/role.go index a09ff5e5..6e751022 100644 --- a/internal/data/entity/ent/role/role.go +++ b/internal/data/entity/ent/role/role.go @@ -3,6 +3,7 @@ package role import ( + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -116,11 +117,11 @@ var ( // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. DescriptionValidator func(string) error // DefaultType holds the default value on creation for the "type" field. - DefaultType int8 + DefaultType enums.RoleType // DefaultSequence holds the default value on creation for the "sequence" field. DefaultSequence int // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 + DefaultStatus enums.Status // DefaultID holds the default value on creation for the "id" field. DefaultID func() int64 // IDValidator is a validator for the "id" field. It is called by the builders before save. diff --git a/internal/data/entity/ent/role/where.go b/internal/data/entity/ent/role/where.go index d308036e..bb3e3ae9 100644 --- a/internal/data/entity/ent/role/where.go +++ b/internal/data/entity/ent/role/where.go @@ -4,6 +4,7 @@ package role import ( "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -81,8 +82,9 @@ func Description(v string) predicate.Role { } // Type applies equality check predicate on the "type" field. It's identical to TypeEQ. -func Type(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldType, v)) +func Type(v enums.RoleType) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldEQ(FieldType, vc)) } // Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. @@ -91,8 +93,9 @@ func Sequence(v int) predicate.Role { } // Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldStatus, v)) +func Status(v enums.Status) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldEQ(FieldStatus, vc)) } // CreateTimeEQ applies the EQ predicate on the "create_time" field. @@ -371,43 +374,57 @@ func DescriptionContainsFold(v string) predicate.Role { } // TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldType, v)) +func TypeEQ(v enums.RoleType) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldEQ(FieldType, vc)) } // TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldType, v)) +func TypeNEQ(v enums.RoleType) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldNEQ(FieldType, vc)) } // TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldIn(FieldType, vs...)) +func TypeIn(vs ...enums.RoleType) predicate.Role { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Role(sql.FieldIn(FieldType, v...)) } // TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldType, vs...)) +func TypeNotIn(vs ...enums.RoleType) predicate.Role { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Role(sql.FieldNotIn(FieldType, v...)) } // TypeGT applies the GT predicate on the "type" field. -func TypeGT(v int8) predicate.Role { - return predicate.Role(sql.FieldGT(FieldType, v)) +func TypeGT(v enums.RoleType) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldGT(FieldType, vc)) } // TypeGTE applies the GTE predicate on the "type" field. -func TypeGTE(v int8) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldType, v)) +func TypeGTE(v enums.RoleType) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldGTE(FieldType, vc)) } // TypeLT applies the LT predicate on the "type" field. -func TypeLT(v int8) predicate.Role { - return predicate.Role(sql.FieldLT(FieldType, v)) +func TypeLT(v enums.RoleType) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldLT(FieldType, vc)) } // TypeLTE applies the LTE predicate on the "type" field. -func TypeLTE(v int8) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldType, v)) +func TypeLTE(v enums.RoleType) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldLTE(FieldType, vc)) } // SequenceEQ applies the EQ predicate on the "sequence" field. @@ -451,43 +468,57 @@ func SequenceLTE(v int) predicate.Role { } // StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldEQ(FieldStatus, v)) +func StatusEQ(v enums.Status) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldEQ(FieldStatus, vc)) } // StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.Role { - return predicate.Role(sql.FieldNEQ(FieldStatus, v)) +func StatusNEQ(v enums.Status) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldNEQ(FieldStatus, vc)) } // StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldIn(FieldStatus, vs...)) +func StatusIn(vs ...enums.Status) predicate.Role { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Role(sql.FieldIn(FieldStatus, v...)) } // StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.Role { - return predicate.Role(sql.FieldNotIn(FieldStatus, vs...)) +func StatusNotIn(vs ...enums.Status) predicate.Role { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Role(sql.FieldNotIn(FieldStatus, v...)) } // StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.Role { - return predicate.Role(sql.FieldGT(FieldStatus, v)) +func StatusGT(v enums.Status) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldGT(FieldStatus, vc)) } // StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.Role { - return predicate.Role(sql.FieldGTE(FieldStatus, v)) +func StatusGTE(v enums.Status) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldGTE(FieldStatus, vc)) } // StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.Role { - return predicate.Role(sql.FieldLT(FieldStatus, v)) +func StatusLT(v enums.Status) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldLT(FieldStatus, vc)) } // StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.Role { - return predicate.Role(sql.FieldLTE(FieldStatus, v)) +func StatusLTE(v enums.Status) predicate.Role { + vc := int8(v) + return predicate.Role(sql.FieldLTE(FieldStatus, vc)) } // HasUsers applies the HasEdge predicate on the "users" edge. diff --git a/internal/data/entity/ent/role_create.go b/internal/data/entity/ent/role_create.go index 149e169e..60d7b17b 100644 --- a/internal/data/entity/ent/role_create.go +++ b/internal/data/entity/ent/role_create.go @@ -11,6 +11,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/rolepermission" "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/data/entity/ent/userrole" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -87,13 +88,13 @@ func (_c *RoleCreate) SetNillableDescription(v *string) *RoleCreate { } // SetType sets the "type" field. -func (_c *RoleCreate) SetType(v int8) *RoleCreate { +func (_c *RoleCreate) SetType(v enums.RoleType) *RoleCreate { _c.mutation.SetType(v) return _c } // SetNillableType sets the "type" field if the given value is not nil. -func (_c *RoleCreate) SetNillableType(v *int8) *RoleCreate { +func (_c *RoleCreate) SetNillableType(v *enums.RoleType) *RoleCreate { if v != nil { _c.SetType(*v) } @@ -115,13 +116,13 @@ func (_c *RoleCreate) SetNillableSequence(v *int) *RoleCreate { } // SetStatus sets the "status" field. -func (_c *RoleCreate) SetStatus(v int8) *RoleCreate { +func (_c *RoleCreate) SetStatus(v enums.Status) *RoleCreate { _c.mutation.SetStatus(v) return _c } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *RoleCreate) SetNillableStatus(v *int8) *RoleCreate { +func (_c *RoleCreate) SetNillableStatus(v *enums.Status) *RoleCreate { if v != nil { _c.SetStatus(*v) } diff --git a/internal/data/entity/ent/role_query.go b/internal/data/entity/ent/role_query.go index ca912788..b46d5514 100644 --- a/internal/data/entity/ent/role_query.go +++ b/internal/data/entity/ent/role_query.go @@ -853,9 +853,9 @@ func (_q *RoleQuery) Modify(modifiers ...func(s *sql.Selector)) *RoleSelect { // Keyword string `json:"keyword,omitempty"` // Name string `json:"name,omitempty"` // Description string `json:"description,omitempty"` -// Type int8 `json:"type,omitempty"` +// Type enums.RoleType `json:"type,omitempty"` // Sequence int `json:"sequence,omitempty"` -// Status int8 `json:"status,omitempty"` +// Status enums.Status `json:"status,omitempty"` // } // // client.Role.Query(). diff --git a/internal/data/entity/ent/role_update.go b/internal/data/entity/ent/role_update.go index 97f5b12d..89b2c0e5 100644 --- a/internal/data/entity/ent/role_update.go +++ b/internal/data/entity/ent/role_update.go @@ -12,6 +12,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/rolepermission" "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/data/entity/ent/userrole" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -82,14 +83,14 @@ func (_u *RoleUpdate) SetNillableDescription(v *string) *RoleUpdate { } // SetType sets the "type" field. -func (_u *RoleUpdate) SetType(v int8) *RoleUpdate { +func (_u *RoleUpdate) SetType(v enums.RoleType) *RoleUpdate { _u.mutation.ResetType() _u.mutation.SetType(v) return _u } // SetNillableType sets the "type" field if the given value is not nil. -func (_u *RoleUpdate) SetNillableType(v *int8) *RoleUpdate { +func (_u *RoleUpdate) SetNillableType(v *enums.RoleType) *RoleUpdate { if v != nil { _u.SetType(*v) } @@ -97,7 +98,7 @@ func (_u *RoleUpdate) SetNillableType(v *int8) *RoleUpdate { } // AddType adds value to the "type" field. -func (_u *RoleUpdate) AddType(v int8) *RoleUpdate { +func (_u *RoleUpdate) AddType(v enums.RoleType) *RoleUpdate { _u.mutation.AddType(v) return _u } @@ -124,14 +125,14 @@ func (_u *RoleUpdate) AddSequence(v int) *RoleUpdate { } // SetStatus sets the "status" field. -func (_u *RoleUpdate) SetStatus(v int8) *RoleUpdate { +func (_u *RoleUpdate) SetStatus(v enums.Status) *RoleUpdate { _u.mutation.ResetStatus() _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *RoleUpdate) SetNillableStatus(v *int8) *RoleUpdate { +func (_u *RoleUpdate) SetNillableStatus(v *enums.Status) *RoleUpdate { if v != nil { _u.SetStatus(*v) } @@ -139,7 +140,7 @@ func (_u *RoleUpdate) SetNillableStatus(v *int8) *RoleUpdate { } // AddStatus adds value to the "status" field. -func (_u *RoleUpdate) AddStatus(v int8) *RoleUpdate { +func (_u *RoleUpdate) AddStatus(v enums.Status) *RoleUpdate { _u.mutation.AddStatus(v) return _u } @@ -648,14 +649,14 @@ func (_u *RoleUpdateOne) SetNillableDescription(v *string) *RoleUpdateOne { } // SetType sets the "type" field. -func (_u *RoleUpdateOne) SetType(v int8) *RoleUpdateOne { +func (_u *RoleUpdateOne) SetType(v enums.RoleType) *RoleUpdateOne { _u.mutation.ResetType() _u.mutation.SetType(v) return _u } // SetNillableType sets the "type" field if the given value is not nil. -func (_u *RoleUpdateOne) SetNillableType(v *int8) *RoleUpdateOne { +func (_u *RoleUpdateOne) SetNillableType(v *enums.RoleType) *RoleUpdateOne { if v != nil { _u.SetType(*v) } @@ -663,7 +664,7 @@ func (_u *RoleUpdateOne) SetNillableType(v *int8) *RoleUpdateOne { } // AddType adds value to the "type" field. -func (_u *RoleUpdateOne) AddType(v int8) *RoleUpdateOne { +func (_u *RoleUpdateOne) AddType(v enums.RoleType) *RoleUpdateOne { _u.mutation.AddType(v) return _u } @@ -690,14 +691,14 @@ func (_u *RoleUpdateOne) AddSequence(v int) *RoleUpdateOne { } // SetStatus sets the "status" field. -func (_u *RoleUpdateOne) SetStatus(v int8) *RoleUpdateOne { +func (_u *RoleUpdateOne) SetStatus(v enums.Status) *RoleUpdateOne { _u.mutation.ResetStatus() _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *RoleUpdateOne) SetNillableStatus(v *int8) *RoleUpdateOne { +func (_u *RoleUpdateOne) SetNillableStatus(v *enums.Status) *RoleUpdateOne { if v != nil { _u.SetStatus(*v) } @@ -705,7 +706,7 @@ func (_u *RoleUpdateOne) SetNillableStatus(v *int8) *RoleUpdateOne { } // AddStatus adds value to the "status" field. -func (_u *RoleUpdateOne) AddStatus(v int8) *RoleUpdateOne { +func (_u *RoleUpdateOne) AddStatus(v enums.Status) *RoleUpdateOne { _u.mutation.AddStatus(v) return _u } diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index 81846663..afc47ab7 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -19,6 +19,9 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/entity/ent/viewresource" + "origadmin/application/admin/internal/data/enums" "time" ) @@ -155,7 +158,7 @@ func init() { // notificationDescStatus is the schema descriptor for status field. notificationDescStatus := notificationFields[2].Descriptor() // notification.DefaultStatus holds the default value on creation for the status field. - notification.DefaultStatus = notificationDescStatus.Default.(int8) + notification.DefaultStatus = enums.Status(notificationDescStatus.Default.(int8)) // notificationDescCategoryID is the schema descriptor for category_id field. notificationDescCategoryID := notificationFields[3].Descriptor() // notification.CategoryIDValidator is a validator for the "category_id" field. It is called by the builders before save. @@ -357,7 +360,7 @@ func init() { // roleDescType is the schema descriptor for type field. roleDescType := roleFields[3].Descriptor() // role.DefaultType holds the default value on creation for the type field. - role.DefaultType = roleDescType.Default.(int8) + role.DefaultType = enums.RoleType(roleDescType.Default.(int8)) // roleDescSequence is the schema descriptor for sequence field. roleDescSequence := roleFields[4].Descriptor() // role.DefaultSequence holds the default value on creation for the sequence field. @@ -365,7 +368,7 @@ func init() { // roleDescStatus is the schema descriptor for status field. roleDescStatus := roleFields[5].Descriptor() // role.DefaultStatus holds the default value on creation for the status field. - role.DefaultStatus = roleDescStatus.Default.(int8) + role.DefaultStatus = enums.Status(roleDescStatus.Default.(int8)) // roleDescID is the schema descriptor for id field. roleDescID := roleMixinFields0[0].Descriptor() // role.DefaultID holds the default value on creation for the id field. @@ -384,9 +387,7 @@ func init() { rolepermission.PermissionIDValidator = rolepermissionDescPermissionID.Validators[0].(func(int64) error) userMixin := schema.User{}.Mixin() userMixinHooks4 := userMixin[4].Hooks() - userHooks := schema.User{}.Hooks() user.Hooks[0] = userMixinHooks4[0] - user.Hooks[1] = userHooks[0] userMixinInters4 := userMixin[4].Interceptors() user.Interceptors[0] = userMixinInters4[0] userMixinFields0 := userMixin[0].Fields() @@ -492,7 +493,7 @@ func init() { // userDescStatus is the schema descriptor for status field. userDescStatus := userFields[14].Descriptor() // user.DefaultStatus holds the default value on creation for the status field. - user.DefaultStatus = userDescStatus.Default.(int8) + user.DefaultStatus = enums.Status(userDescStatus.Default.(int8)) // userDescIsSystem is the schema descriptor for is_system field. userDescIsSystem := userFields[15].Descriptor() // user.DefaultIsSystem holds the default value on creation for the is_system field. @@ -586,12 +587,6 @@ func init() { viewDescScope := viewFields[2].Descriptor() // view.DefaultScope holds the default value on creation for the scope field. view.DefaultScope = viewDescScope.Default.(string) - // viewDescType is the schema descriptor for type field. - viewDescType := viewFields[4].Descriptor() - // view.DefaultType holds the default value on creation for the type field. - view.DefaultType = viewDescType.Default.(string) - // view.TypeValidator is a validator for the "type" field. It is called by the builders before save. - view.TypeValidator = viewDescType.Validators[0].(func(string) error) // viewDescVisible is the schema descriptor for visible field. viewDescVisible := viewFields[8].Descriptor() // view.DefaultVisible holds the default value on creation for the visible field. @@ -606,6 +601,92 @@ func init() { view.DefaultID = viewDescID.Default.(func() int64) // view.IDValidator is a validator for the "id" field. It is called by the builders before save. view.IDValidator = viewDescID.Validators[0].(func(int64) error) + viewpermissionMixin := schema.ViewPermission{}.Mixin() + viewpermissionMixinFields0 := viewpermissionMixin[0].Fields() + _ = viewpermissionMixinFields0 + viewpermissionMixinFields1 := viewpermissionMixin[1].Fields() + _ = viewpermissionMixinFields1 + viewpermissionMixinFields2 := viewpermissionMixin[2].Fields() + _ = viewpermissionMixinFields2 + viewpermissionMixinFields3 := viewpermissionMixin[3].Fields() + _ = viewpermissionMixinFields3 + viewpermissionFields := schema.ViewPermission{}.Fields() + _ = viewpermissionFields + // viewpermissionDescCreateAuthor is the schema descriptor for create_author field. + viewpermissionDescCreateAuthor := viewpermissionMixinFields1[0].Descriptor() + // viewpermission.DefaultCreateAuthor holds the default value on creation for the create_author field. + viewpermission.DefaultCreateAuthor = viewpermissionDescCreateAuthor.Default.(int64) + // viewpermissionDescUpdateAuthor is the schema descriptor for update_author field. + viewpermissionDescUpdateAuthor := viewpermissionMixinFields1[1].Descriptor() + // viewpermission.DefaultUpdateAuthor holds the default value on creation for the update_author field. + viewpermission.DefaultUpdateAuthor = viewpermissionDescUpdateAuthor.Default.(int64) + // viewpermissionDescCreateTime is the schema descriptor for create_time field. + viewpermissionDescCreateTime := viewpermissionMixinFields2[0].Descriptor() + // viewpermission.DefaultCreateTime holds the default value on creation for the create_time field. + viewpermission.DefaultCreateTime = viewpermissionDescCreateTime.Default.(func() time.Time) + // viewpermissionDescUpdateTime is the schema descriptor for update_time field. + viewpermissionDescUpdateTime := viewpermissionMixinFields3[0].Descriptor() + // viewpermission.DefaultUpdateTime holds the default value on creation for the update_time field. + viewpermission.DefaultUpdateTime = viewpermissionDescUpdateTime.Default.(func() time.Time) + // viewpermission.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + viewpermission.UpdateDefaultUpdateTime = viewpermissionDescUpdateTime.UpdateDefault.(func() time.Time) + // viewpermissionDescViewID is the schema descriptor for view_id field. + viewpermissionDescViewID := viewpermissionFields[0].Descriptor() + // viewpermission.ViewIDValidator is a validator for the "view_id" field. It is called by the builders before save. + viewpermission.ViewIDValidator = viewpermissionDescViewID.Validators[0].(func(int64) error) + // viewpermissionDescPermissionID is the schema descriptor for permission_id field. + viewpermissionDescPermissionID := viewpermissionFields[1].Descriptor() + // viewpermission.PermissionIDValidator is a validator for the "permission_id" field. It is called by the builders before save. + viewpermission.PermissionIDValidator = viewpermissionDescPermissionID.Validators[0].(func(int64) error) + // viewpermissionDescID is the schema descriptor for id field. + viewpermissionDescID := viewpermissionMixinFields0[0].Descriptor() + // viewpermission.DefaultID holds the default value on creation for the id field. + viewpermission.DefaultID = viewpermissionDescID.Default.(func() int64) + // viewpermission.IDValidator is a validator for the "id" field. It is called by the builders before save. + viewpermission.IDValidator = viewpermissionDescID.Validators[0].(func(int64) error) + viewresourceMixin := schema.ViewResource{}.Mixin() + viewresourceMixinFields0 := viewresourceMixin[0].Fields() + _ = viewresourceMixinFields0 + viewresourceMixinFields1 := viewresourceMixin[1].Fields() + _ = viewresourceMixinFields1 + viewresourceMixinFields2 := viewresourceMixin[2].Fields() + _ = viewresourceMixinFields2 + viewresourceMixinFields3 := viewresourceMixin[3].Fields() + _ = viewresourceMixinFields3 + viewresourceFields := schema.ViewResource{}.Fields() + _ = viewresourceFields + // viewresourceDescCreateAuthor is the schema descriptor for create_author field. + viewresourceDescCreateAuthor := viewresourceMixinFields1[0].Descriptor() + // viewresource.DefaultCreateAuthor holds the default value on creation for the create_author field. + viewresource.DefaultCreateAuthor = viewresourceDescCreateAuthor.Default.(int64) + // viewresourceDescUpdateAuthor is the schema descriptor for update_author field. + viewresourceDescUpdateAuthor := viewresourceMixinFields1[1].Descriptor() + // viewresource.DefaultUpdateAuthor holds the default value on creation for the update_author field. + viewresource.DefaultUpdateAuthor = viewresourceDescUpdateAuthor.Default.(int64) + // viewresourceDescCreateTime is the schema descriptor for create_time field. + viewresourceDescCreateTime := viewresourceMixinFields2[0].Descriptor() + // viewresource.DefaultCreateTime holds the default value on creation for the create_time field. + viewresource.DefaultCreateTime = viewresourceDescCreateTime.Default.(func() time.Time) + // viewresourceDescUpdateTime is the schema descriptor for update_time field. + viewresourceDescUpdateTime := viewresourceMixinFields3[0].Descriptor() + // viewresource.DefaultUpdateTime holds the default value on creation for the update_time field. + viewresource.DefaultUpdateTime = viewresourceDescUpdateTime.Default.(func() time.Time) + // viewresource.UpdateDefaultUpdateTime holds the default value on update for the update_time field. + viewresource.UpdateDefaultUpdateTime = viewresourceDescUpdateTime.UpdateDefault.(func() time.Time) + // viewresourceDescViewID is the schema descriptor for view_id field. + viewresourceDescViewID := viewresourceFields[0].Descriptor() + // viewresource.ViewIDValidator is a validator for the "view_id" field. It is called by the builders before save. + viewresource.ViewIDValidator = viewresourceDescViewID.Validators[0].(func(int64) error) + // viewresourceDescResourceID is the schema descriptor for resource_id field. + viewresourceDescResourceID := viewresourceFields[1].Descriptor() + // viewresource.ResourceIDValidator is a validator for the "resource_id" field. It is called by the builders before save. + viewresource.ResourceIDValidator = viewresourceDescResourceID.Validators[0].(func(int64) error) + // viewresourceDescID is the schema descriptor for id field. + viewresourceDescID := viewresourceMixinFields0[0].Descriptor() + // viewresource.DefaultID holds the default value on creation for the id field. + viewresource.DefaultID = viewresourceDescID.Default.(func() int64) + // viewresource.IDValidator is a validator for the "id" field. It is called by the builders before save. + viewresource.IDValidator = viewresourceDescID.Validators[0].(func(int64) error) } const ( diff --git a/internal/data/entity/ent/schema/department.go b/internal/data/entity/ent/schema/department.go index 5b389d16..5a7a8cb7 100644 --- a/internal/data/entity/ent/schema/department.go +++ b/internal/data/entity/ent/schema/department.go @@ -33,8 +33,6 @@ func (Department) Fields() []ent.Field { MaxLen(64). Default(""). Comment(i18n.Text("entity.department.field.name")), - // use materialized path model to store the tree structure - // Parent path of the menu item field.String("tree_path"). MaxLen(256). Default(""). @@ -74,8 +72,6 @@ func (Department) Indexes() []ent.Index { func (Department) Annotations() []schema.Annotation { return []schema.Annotation{ entsql.Table("sys_departments"), - // Adding this annotation to the schema enables - // comments for the table and all its fields. entsql.WithComments(true), schema.Comment(i18n.Text("entity.department.table.comment")), } @@ -90,10 +86,5 @@ func (Department) Edges() []ent.Edge { edge.To("positions", Position.Type), edge.To("children", Department.Type). From("parent").Unique().Field("parent_id"), - //edge.To("children", Department.Type), - //edge.From("parent", Department.Type). - // Ref("children"). - // Field("parent_id"). - // Unique(), } } diff --git a/internal/data/entity/ent/schema/notification.go b/internal/data/entity/ent/schema/notification.go index 7d2d8819..f58f720e 100644 --- a/internal/data/entity/ent/schema/notification.go +++ b/internal/data/entity/ent/schema/notification.go @@ -31,8 +31,8 @@ func (Notification) Fields() []ent.Field { Default(""). Comment(i18n.Text("entity.notification.field.content")), field.Int8("status"). - GoType(enums.Status(0)). // Tell entc to generate the Go type as enums.Status - Default(int8(enums.StatusUnknown)). // Provide the underlying type (int8) to the builder method + GoType(enums.Status(0)). + Default(int8(enums.StatusUnknown)). Comment(i18n.Text("entity.notification.field.status")), mixin.FK("category_id", i18n.Text("entity.notification.field.category_id")), } diff --git a/internal/data/entity/ent/schema/permission.go b/internal/data/entity/ent/schema/permission.go index e3a0a751..555caaaf 100644 --- a/internal/data/entity/ent/schema/permission.go +++ b/internal/data/entity/ent/schema/permission.go @@ -88,7 +88,8 @@ func (Permission) Edges() []ent.Edge { Through("position_permissions", PositionPermission.Type), edge.To("resources", Resource.Type). Through("permission_resources", PermissionResource.Type), - // Add the inverse edge to View, resolving the generation error. - edge.To("views", View.Type), + edge.From("views", View.Type). + Ref("permissions"). + Through("view_permissions", ViewPermission.Type), } } diff --git a/internal/data/entity/ent/schema/positionpermission.go b/internal/data/entity/ent/schema/positionpermission.go index a56bc514..18afc02a 100644 --- a/internal/data/entity/ent/schema/positionpermission.go +++ b/internal/data/entity/ent/schema/positionpermission.go @@ -39,8 +39,6 @@ func (PositionPermission) Mixin() []ent.Mixin { // Indexes of the PositionPermission. func (PositionPermission) Indexes() []ent.Index { return []ent.Index{ - index.Fields("permission_id"), // From Permission.ID - index.Fields("position_id"), // From Position.ID index.Fields("position_id", "permission_id"). Unique(), } diff --git a/internal/data/entity/ent/schema/resource.go b/internal/data/entity/ent/schema/resource.go index 7390d31a..c9c728ce 100644 --- a/internal/data/entity/ent/schema/resource.go +++ b/internal/data/entity/ent/schema/resource.go @@ -53,7 +53,9 @@ func (Resource) Fields() []ent.Field { // Edges of the Resource. func (Resource) Edges() []ent.Edge { return []ent.Edge{ - edge.To("views", View.Type), + edge.From("views", View.Type). + Ref("resources"). + Through("view_resources", ViewResource.Type), edge.From("permissions", Permission.Type). Ref("resources"), } diff --git a/internal/data/entity/ent/schema/rolepermission.go b/internal/data/entity/ent/schema/rolepermission.go index bd5661fd..0ecd0627 100644 --- a/internal/data/entity/ent/schema/rolepermission.go +++ b/internal/data/entity/ent/schema/rolepermission.go @@ -37,8 +37,6 @@ func (RolePermission) Mixin() []ent.Mixin { // Indexes of the RolePermission. func (RolePermission) Indexes() []ent.Index { return []ent.Index{ - index.Fields("role_id"), // From Role.ID - index.Fields("permission_id"), // From Permission.ID index.Fields("role_id", "permission_id"). Unique(), } diff --git a/internal/data/entity/ent/schema/userdepartment.go b/internal/data/entity/ent/schema/userdepartment.go index d3b275d9..74f06e58 100644 --- a/internal/data/entity/ent/schema/userdepartment.go +++ b/internal/data/entity/ent/schema/userdepartment.go @@ -39,8 +39,6 @@ func (UserDepartment) Mixin() []ent.Mixin { // Indexes of the UserDepartment. func (UserDepartment) Indexes() []ent.Index { return []ent.Index{ - index.Fields("user_id"), - index.Fields("department_id"), index.Fields("user_id", "department_id"). Unique(), } diff --git a/internal/data/entity/ent/schema/userposition.go b/internal/data/entity/ent/schema/userposition.go index 23caac7d..2be93136 100644 --- a/internal/data/entity/ent/schema/userposition.go +++ b/internal/data/entity/ent/schema/userposition.go @@ -39,8 +39,6 @@ func (UserPosition) Mixin() []ent.Mixin { // Indexes of the UserPosition. func (UserPosition) Indexes() []ent.Index { return []ent.Index{ - index.Fields("user_id"), // From User.ID - index.Fields("position_id"), // From Position.ID index.Fields("user_id", "position_id"). Unique(), } diff --git a/internal/data/entity/ent/schema/userrole.go b/internal/data/entity/ent/schema/userrole.go index ce456616..a27ed678 100644 --- a/internal/data/entity/ent/schema/userrole.go +++ b/internal/data/entity/ent/schema/userrole.go @@ -39,8 +39,6 @@ func (UserRole) Mixin() []ent.Mixin { // Indexes of the UserRole. func (UserRole) Indexes() []ent.Index { return []ent.Index{ - index.Fields("user_id"), // From User.ID - index.Fields("role_id"), // From Role.ID index.Fields("user_id", "role_id"). Unique(), } @@ -51,7 +49,7 @@ func (UserRole) Annotations() []schema.Annotation { return []schema.Annotation{ entsql.Table("sys_user_roles"), entsql.WithComments(true), - schema.Comment(i18n.Text("entity.(1).(2).(3)")), + schema.Comment(i18n.Text("entity.user_role.table.comment")), } } diff --git a/internal/data/entity/ent/schema/view.go b/internal/data/entity/ent/schema/view.go index 5d9b6bb0..bc09124e 100644 --- a/internal/data/entity/ent/schema/view.go +++ b/internal/data/entity/ent/schema/view.go @@ -68,10 +68,10 @@ func (View) Edges() []ent.Edge { From("parent"). Field("parent_id"). Unique(), - edge.From("resources", Resource.Type). - Ref("views"), - edge.From("permissions", Permission.Type). - Ref("views"), + edge.To("resources", Resource.Type). + Through("view_resources", ViewResource.Type), + edge.To("permissions", Permission.Type). + Through("view_permissions", ViewPermission.Type), } } diff --git a/internal/data/entity/ent/schema/viewpermission.go b/internal/data/entity/ent/schema/viewpermission.go new file mode 100644 index 00000000..5038d77f --- /dev/null +++ b/internal/data/entity/ent/schema/viewpermission.go @@ -0,0 +1,61 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/index" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" +) + +// ViewPermission holds the schema definition for the ViewPermission entity. +// It's a through-table for the M-N relationship between View and Permission. +type ViewPermission struct { + ent.Schema +} + +// Fields of the ViewPermission. +func (ViewPermission) Fields() []ent.Field { + return []ent.Field{ + mixin.FK("view_id", i18n.Text("view_permission.view_id.comment")), + mixin.FK("permission_id", i18n.Text("view_permission.permission_id.comment")), + } +} + +// Edges of the ViewPermission. +func (ViewPermission) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("view", View.Type). + Field("view_id"). + Unique(). + Required(), + edge.To("permission", Permission.Type). + Field("permission_id"). + Unique(). + Required(), + } +} + +// Indexes of the ViewPermission. +func (ViewPermission) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("view_id", "permission_id"). + Unique(), + } +} + +// Annotations of the ViewPermission. +func (ViewPermission) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_view_permissions"), + entsql.WithComments(true), + schema.Comment(i18n.Text("entity.view_permission.table.comment")), + } +} + +// Mixin of the ViewPermission. +func (ViewPermission) Mixin() []ent.Mixin { + return mixin.AuditModelMixin +} diff --git a/internal/data/entity/ent/schema/viewresource.go b/internal/data/entity/ent/schema/viewresource.go new file mode 100644 index 00000000..43b1d568 --- /dev/null +++ b/internal/data/entity/ent/schema/viewresource.go @@ -0,0 +1,62 @@ +package schema + +import ( + "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" + "entgo.io/ent/schema/edge" + "entgo.io/ent/schema/index" + "origadmin/application/admin/internal/helpers/ent/mixin" + "origadmin/application/admin/internal/helpers/i18n" +) + +// ViewResource holds the schema definition for the ViewResource entity. +// It's a through-table for the M-N relationship between View and Resource. +type ViewResource struct { + ent.Schema +} + +// Fields of the ViewResource. +func (ViewResource) Fields() []ent.Field { + return []ent.Field{ + mixin.FK("view_id", i18n.Text("view_resource.view_id.comment")), + mixin.FK("resource_id", i18n.Text("view_resource.resource_id.comment")), + } +} + +// Edges of the ViewResource. +func (ViewResource) Edges() []ent.Edge { + return []ent.Edge{ + edge.To("view", View.Type). + Field("view_id"). + Unique(). + Required(), + edge.To("resource", Resource.Type). + Field("resource_id"). + Unique(). + Required(), + } +} + +// Indexes of the ViewResource. +func (ViewResource) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("view_id", "resource_id"). + Unique(), + } +} + +// Annotations of the ViewResource. +func (ViewResource) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_view_resources"), + entsql.WithComments(true), + schema.Comment(i18n.Text("entity.view_resource.table.comment")), + } +} + +// Mixin of the ViewResource. +func (ViewResource) Mixin() []ent.Mixin { + // Using AuditModelMixin to automatically get id, create/update times, and created_by/updated_by fields. + return mixin.AuditModelMixin +} diff --git a/internal/data/entity/ent/tx.go b/internal/data/entity/ent/tx.go index 46881260..51983852 100644 --- a/internal/data/entity/ent/tx.go +++ b/internal/data/entity/ent/tx.go @@ -42,6 +42,10 @@ type Tx struct { UserRole *UserRoleClient // View is the client for interacting with the View builders. View *ViewClient + // ViewPermission is the client for interacting with the ViewPermission builders. + ViewPermission *ViewPermissionClient + // ViewResource is the client for interacting with the ViewResource builders. + ViewResource *ViewResourceClient // lazily loaded. client *Client @@ -188,6 +192,8 @@ func (tx *Tx) init() { tx.UserPosition = NewUserPositionClient(tx.config) tx.UserRole = NewUserRoleClient(tx.config) tx.View = NewViewClient(tx.config) + tx.ViewPermission = NewViewPermissionClient(tx.config) + tx.ViewResource = NewViewResourceClient(tx.config) } // txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. diff --git a/internal/data/entity/ent/user.go b/internal/data/entity/ent/user.go index f9f64e1a..63f898e9 100644 --- a/internal/data/entity/ent/user.go +++ b/internal/data/entity/ent/user.go @@ -5,6 +5,7 @@ package ent import ( "fmt" "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/enums" "strings" "time" @@ -59,7 +60,7 @@ type User struct { // entity.user.field.token Token string `json:"token,omitempty"` // entity.user.field.status - Status int8 `json:"status,omitempty"` + Status enums.Status `json:"status,omitempty"` // entity.user.field.is_system IsSystem bool `json:"is_system,omitempty"` // entity.user.field.last_login_ip @@ -306,7 +307,7 @@ func (_m *User) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - _m.Status = int8(value.Int64) + _m.Status = enums.Status(value.Int64) } case user.FieldIsSystem: if value, ok := values[i].(*sql.NullBool); !ok { diff --git a/internal/data/entity/ent/user/user.go b/internal/data/entity/ent/user/user.go index abbf2a13..e8e9d1de 100644 --- a/internal/data/entity/ent/user/user.go +++ b/internal/data/entity/ent/user/user.go @@ -4,6 +4,7 @@ package user import ( "fmt" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent" @@ -186,7 +187,7 @@ func ValidColumn(column string) bool { // // import _ "origadmin/application/admin/internal/data/entity/ent/runtime" var ( - Hooks [2]ent.Hook + Hooks [1]ent.Hook Interceptors [1]ent.Interceptor // DefaultCreateAuthor holds the default value on creation for the "create_author" field. DefaultCreateAuthor int64 @@ -245,7 +246,7 @@ var ( // TokenValidator is a validator for the "token" field. It is called by the builders before save. TokenValidator func(string) error // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus int8 + DefaultStatus enums.Status // DefaultIsSystem holds the default value on creation for the "is_system" field. DefaultIsSystem bool // DefaultLastLoginIP holds the default value on creation for the "last_login_ip" field. diff --git a/internal/data/entity/ent/user/where.go b/internal/data/entity/ent/user/where.go index 4e88c5ed..76205250 100644 --- a/internal/data/entity/ent/user/where.go +++ b/internal/data/entity/ent/user/where.go @@ -4,6 +4,7 @@ package user import ( "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -146,8 +147,9 @@ func Token(v string) predicate.User { } // Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v int8) predicate.User { - return predicate.User(sql.FieldEQ(FieldStatus, v)) +func Status(v enums.Status) predicate.User { + vc := int8(v) + return predicate.User(sql.FieldEQ(FieldStatus, vc)) } // IsSystem applies equality check predicate on the "is_system" field. It's identical to IsSystemEQ. @@ -1281,43 +1283,57 @@ func TokenContainsFold(v string) predicate.User { } // StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v int8) predicate.User { - return predicate.User(sql.FieldEQ(FieldStatus, v)) +func StatusEQ(v enums.Status) predicate.User { + vc := int8(v) + return predicate.User(sql.FieldEQ(FieldStatus, vc)) } // StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v int8) predicate.User { - return predicate.User(sql.FieldNEQ(FieldStatus, v)) +func StatusNEQ(v enums.Status) predicate.User { + vc := int8(v) + return predicate.User(sql.FieldNEQ(FieldStatus, vc)) } // StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...int8) predicate.User { - return predicate.User(sql.FieldIn(FieldStatus, vs...)) +func StatusIn(vs ...enums.Status) predicate.User { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.User(sql.FieldIn(FieldStatus, v...)) } // StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...int8) predicate.User { - return predicate.User(sql.FieldNotIn(FieldStatus, vs...)) +func StatusNotIn(vs ...enums.Status) predicate.User { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.User(sql.FieldNotIn(FieldStatus, v...)) } // StatusGT applies the GT predicate on the "status" field. -func StatusGT(v int8) predicate.User { - return predicate.User(sql.FieldGT(FieldStatus, v)) +func StatusGT(v enums.Status) predicate.User { + vc := int8(v) + return predicate.User(sql.FieldGT(FieldStatus, vc)) } // StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v int8) predicate.User { - return predicate.User(sql.FieldGTE(FieldStatus, v)) +func StatusGTE(v enums.Status) predicate.User { + vc := int8(v) + return predicate.User(sql.FieldGTE(FieldStatus, vc)) } // StatusLT applies the LT predicate on the "status" field. -func StatusLT(v int8) predicate.User { - return predicate.User(sql.FieldLT(FieldStatus, v)) +func StatusLT(v enums.Status) predicate.User { + vc := int8(v) + return predicate.User(sql.FieldLT(FieldStatus, vc)) } // StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v int8) predicate.User { - return predicate.User(sql.FieldLTE(FieldStatus, v)) +func StatusLTE(v enums.Status) predicate.User { + vc := int8(v) + return predicate.User(sql.FieldLTE(FieldStatus, vc)) } // IsSystemEQ applies the EQ predicate on the "is_system" field. diff --git a/internal/data/entity/ent/user_create.go b/internal/data/entity/ent/user_create.go index 1a0c0ba6..1db06155 100644 --- a/internal/data/entity/ent/user_create.go +++ b/internal/data/entity/ent/user_create.go @@ -13,6 +13,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userdepartment" "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -277,13 +278,13 @@ func (_c *UserCreate) SetNillableToken(v *string) *UserCreate { } // SetStatus sets the "status" field. -func (_c *UserCreate) SetStatus(v int8) *UserCreate { +func (_c *UserCreate) SetStatus(v enums.Status) *UserCreate { _c.mutation.SetStatus(v) return _c } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *UserCreate) SetNillableStatus(v *int8) *UserCreate { +func (_c *UserCreate) SetNillableStatus(v *enums.Status) *UserCreate { if v != nil { _c.SetStatus(*v) } diff --git a/internal/data/entity/ent/user_query.go b/internal/data/entity/ent/user_query.go index 4449f304..454395df 100644 --- a/internal/data/entity/ent/user_query.go +++ b/internal/data/entity/ent/user_query.go @@ -1046,7 +1046,7 @@ func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // Department string `json:"department,omitempty"` // Remark string `json:"remark,omitempty"` // Token string `json:"token,omitempty"` -// Status int8 `json:"status,omitempty"` +// Status enums.Status `json:"status,omitempty"` // IsSystem bool `json:"is_system,omitempty"` // LastLoginIP string `json:"last_login_ip,omitempty"` // LastLoginTime time.Time `json:"last_login_time,omitempty"` diff --git a/internal/data/entity/ent/user_update.go b/internal/data/entity/ent/user_update.go index 6d93a4cf..198aa0a4 100644 --- a/internal/data/entity/ent/user_update.go +++ b/internal/data/entity/ent/user_update.go @@ -14,6 +14,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/userdepartment" "origadmin/application/admin/internal/data/entity/ent/userposition" "origadmin/application/admin/internal/data/entity/ent/userrole" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -312,14 +313,14 @@ func (_u *UserUpdate) SetNillableToken(v *string) *UserUpdate { } // SetStatus sets the "status" field. -func (_u *UserUpdate) SetStatus(v int8) *UserUpdate { +func (_u *UserUpdate) SetStatus(v enums.Status) *UserUpdate { _u.mutation.ResetStatus() _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *UserUpdate) SetNillableStatus(v *int8) *UserUpdate { +func (_u *UserUpdate) SetNillableStatus(v *enums.Status) *UserUpdate { if v != nil { _u.SetStatus(*v) } @@ -327,7 +328,7 @@ func (_u *UserUpdate) SetNillableStatus(v *int8) *UserUpdate { } // AddStatus adds value to the "status" field. -func (_u *UserUpdate) AddStatus(v int8) *UserUpdate { +func (_u *UserUpdate) AddStatus(v enums.Status) *UserUpdate { _u.mutation.AddStatus(v) return _u } @@ -1484,14 +1485,14 @@ func (_u *UserUpdateOne) SetNillableToken(v *string) *UserUpdateOne { } // SetStatus sets the "status" field. -func (_u *UserUpdateOne) SetStatus(v int8) *UserUpdateOne { +func (_u *UserUpdateOne) SetStatus(v enums.Status) *UserUpdateOne { _u.mutation.ResetStatus() _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableStatus(v *int8) *UserUpdateOne { +func (_u *UserUpdateOne) SetNillableStatus(v *enums.Status) *UserUpdateOne { if v != nil { _u.SetStatus(*v) } @@ -1499,7 +1500,7 @@ func (_u *UserUpdateOne) SetNillableStatus(v *int8) *UserUpdateOne { } // AddStatus adds value to the "status" field. -func (_u *UserUpdateOne) AddStatus(v int8) *UserUpdateOne { +func (_u *UserUpdateOne) AddStatus(v enums.Status) *UserUpdateOne { _u.mutation.AddStatus(v) return _u } diff --git a/internal/data/entity/ent/userrole.go b/internal/data/entity/ent/userrole.go index 33f53be4..a8fe45d0 100644 --- a/internal/data/entity/ent/userrole.go +++ b/internal/data/entity/ent/userrole.go @@ -13,7 +13,7 @@ import ( "entgo.io/ent/dialect/sql" ) -// entity.(1).(2).(3) +// entity.user_role.table.comment type UserRole struct { config `json:"-"` // ID of the ent. diff --git a/internal/data/entity/ent/view.go b/internal/data/entity/ent/view.go index 2873e2be..7dbcde3a 100644 --- a/internal/data/entity/ent/view.go +++ b/internal/data/entity/ent/view.go @@ -31,7 +31,7 @@ type View struct { // view.name.comment Name string `json:"name,omitempty"` // view.type.comment - Type string `json:"type,omitempty"` + Type view.Type `json:"type,omitempty"` // view.component.comment Component string `json:"component,omitempty"` // view.path.comment @@ -58,9 +58,13 @@ type ViewEdges struct { Resources []*Resource `json:"resources,omitempty"` // Permissions holds the value of the permissions edge. Permissions []*Permission `json:"permissions,omitempty"` + // ViewResources holds the value of the view_resources edge. + ViewResources []*ViewResource `json:"view_resources,omitempty"` + // ViewPermissions holds the value of the view_permissions edge. + ViewPermissions []*ViewPermission `json:"view_permissions,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [4]bool + loadedTypes [6]bool } // ParentOrErr returns the Parent value or an error if the edge @@ -101,6 +105,24 @@ func (e ViewEdges) PermissionsOrErr() ([]*Permission, error) { return nil, &NotLoadedError{edge: "permissions"} } +// ViewResourcesOrErr returns the ViewResources value or an error if the edge +// was not loaded in eager-loading. +func (e ViewEdges) ViewResourcesOrErr() ([]*ViewResource, error) { + if e.loadedTypes[4] { + return e.ViewResources, nil + } + return nil, &NotLoadedError{edge: "view_resources"} +} + +// ViewPermissionsOrErr returns the ViewPermissions value or an error if the edge +// was not loaded in eager-loading. +func (e ViewEdges) ViewPermissionsOrErr() ([]*ViewPermission, error) { + if e.loadedTypes[5] { + return e.ViewPermissions, nil + } + return nil, &NotLoadedError{edge: "view_permissions"} +} + // scanValues returns the types for scanning values from sql.Rows. func (*View) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) @@ -175,7 +197,7 @@ func (_m *View) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) } else if value.Valid { - _m.Type = value.String + _m.Type = view.Type(value.String) } case view.FieldComponent: if value, ok := values[i].(*sql.NullString); !ok { @@ -240,6 +262,16 @@ func (_m *View) QueryPermissions() *PermissionQuery { return NewViewClient(_m.config).QueryPermissions(_m) } +// QueryViewResources queries the "view_resources" edge of the View entity. +func (_m *View) QueryViewResources() *ViewResourceQuery { + return NewViewClient(_m.config).QueryViewResources(_m) +} + +// QueryViewPermissions queries the "view_permissions" edge of the View entity. +func (_m *View) QueryViewPermissions() *ViewPermissionQuery { + return NewViewClient(_m.config).QueryViewPermissions(_m) +} + // Update returns a builder for updating this View. // Note that you need to call View.Unwrap() before calling this method if this View // was returned from a transaction, and the transaction was committed or rolled back. @@ -282,7 +314,7 @@ func (_m *View) String() string { builder.WriteString(_m.Name) builder.WriteString(", ") builder.WriteString("type=") - builder.WriteString(_m.Type) + builder.WriteString(fmt.Sprintf("%v", _m.Type)) builder.WriteString(", ") builder.WriteString("component=") builder.WriteString(_m.Component) diff --git a/internal/data/entity/ent/view/view.go b/internal/data/entity/ent/view/view.go index 46a54b58..9193428a 100644 --- a/internal/data/entity/ent/view/view.go +++ b/internal/data/entity/ent/view/view.go @@ -3,6 +3,7 @@ package view import ( + "fmt" "time" "entgo.io/ent/dialect/sql" @@ -46,6 +47,10 @@ const ( EdgeResources = "resources" // EdgePermissions holds the string denoting the permissions edge name in mutations. EdgePermissions = "permissions" + // EdgeViewResources holds the string denoting the view_resources edge name in mutations. + EdgeViewResources = "view_resources" + // EdgeViewPermissions holds the string denoting the view_permissions edge name in mutations. + EdgeViewPermissions = "view_permissions" // Table holds the table name of the view in the database. Table = "views" // ParentTable is the table that holds the parent relation/edge. @@ -57,15 +62,29 @@ const ( // ChildrenColumn is the table column denoting the children relation/edge. ChildrenColumn = "parent_id" // ResourcesTable is the table that holds the resources relation/edge. The primary key declared below. - ResourcesTable = "resource_views" + ResourcesTable = "sys_view_resources" // ResourcesInverseTable is the table name for the Resource entity. // It exists in this package in order to avoid circular dependency with the "resource" package. ResourcesInverseTable = "resources" // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. - PermissionsTable = "permission_views" + PermissionsTable = "sys_view_permissions" // PermissionsInverseTable is the table name for the Permission entity. // It exists in this package in order to avoid circular dependency with the "permission" package. PermissionsInverseTable = "sys_permissions" + // ViewResourcesTable is the table that holds the view_resources relation/edge. + ViewResourcesTable = "sys_view_resources" + // ViewResourcesInverseTable is the table name for the ViewResource entity. + // It exists in this package in order to avoid circular dependency with the "viewresource" package. + ViewResourcesInverseTable = "sys_view_resources" + // ViewResourcesColumn is the table column denoting the view_resources relation/edge. + ViewResourcesColumn = "view_id" + // ViewPermissionsTable is the table that holds the view_permissions relation/edge. + ViewPermissionsTable = "sys_view_permissions" + // ViewPermissionsInverseTable is the table name for the ViewPermission entity. + // It exists in this package in order to avoid circular dependency with the "viewpermission" package. + ViewPermissionsInverseTable = "sys_view_permissions" + // ViewPermissionsColumn is the table column denoting the view_permissions relation/edge. + ViewPermissionsColumn = "view_id" ) // Columns holds all SQL columns for view fields. @@ -88,10 +107,10 @@ var Columns = []string{ var ( // ResourcesPrimaryKey and ResourcesColumn2 are the table columns denoting the // primary key for the resources relation (M2M). - ResourcesPrimaryKey = []string{"resource_id", "view_id"} + ResourcesPrimaryKey = []string{"view_id", "resource_id"} // PermissionsPrimaryKey and PermissionsColumn2 are the table columns denoting the // primary key for the permissions relation (M2M). - PermissionsPrimaryKey = []string{"permission_id", "view_id"} + PermissionsPrimaryKey = []string{"view_id", "permission_id"} ) // ValidColumn reports if the column name is valid (part of the table columns). @@ -117,10 +136,6 @@ var ( KeywordValidator func(string) error // DefaultScope holds the default value on creation for the "scope" field. DefaultScope string - // DefaultType holds the default value on creation for the "type" field. - DefaultType string - // TypeValidator is a validator for the "type" field. It is called by the builders before save. - TypeValidator func(string) error // DefaultVisible holds the default value on creation for the "visible" field. DefaultVisible bool // DefaultSequence holds the default value on creation for the "sequence" field. @@ -131,6 +146,39 @@ var ( IDValidator func(int64) error ) +// Type defines the type for the "type" enum field. +type Type string + +// TypeU is the default value of the Type enum. +const DefaultType = TypeU + +// Type values. +const ( + TypeT Type = "T" + TypeG Type = "G" + TypeM Type = "M" + TypeL Type = "L" + TypeP Type = "P" + TypeB Type = "B" + TypeE Type = "E" + TypeR Type = "R" + TypeU Type = "U" +) + +func (_type Type) String() string { + return string(_type) +} + +// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save. +func TypeValidator(_type Type) error { + switch _type { + case TypeT, TypeG, TypeM, TypeL, TypeP, TypeB, TypeE, TypeR, TypeU: + return nil + default: + return fmt.Errorf("view: invalid enum value for type field: %q", _type) + } +} + // OrderOption defines the ordering options for the View queries. type OrderOption func(*sql.Selector) @@ -247,6 +295,34 @@ func ByPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) } } + +// ByViewResourcesCount orders the results by view_resources count. +func ByViewResourcesCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newViewResourcesStep(), opts...) + } +} + +// ByViewResources orders the results by view_resources terms. +func ByViewResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newViewResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} + +// ByViewPermissionsCount orders the results by view_permissions count. +func ByViewPermissionsCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newViewPermissionsStep(), opts...) + } +} + +// ByViewPermissions orders the results by view_permissions terms. +func ByViewPermissions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newViewPermissionsStep(), append([]sql.OrderTerm{term}, terms...)...) + } +} func newParentStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), @@ -265,14 +341,28 @@ func newResourcesStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(ResourcesInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, ResourcesTable, ResourcesPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), ) } func newPermissionsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(PermissionsInverseTable, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), + ) +} +func newViewResourcesStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ViewResourcesInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ViewResourcesTable, ViewResourcesColumn), + ) +} +func newViewPermissionsStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ViewPermissionsInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ViewPermissionsTable, ViewPermissionsColumn), ) } diff --git a/internal/data/entity/ent/view/where.go b/internal/data/entity/ent/view/where.go index 3044ff8f..b8920f35 100644 --- a/internal/data/entity/ent/view/where.go +++ b/internal/data/entity/ent/view/where.go @@ -85,11 +85,6 @@ func Name(v string) predicate.View { return predicate.View(sql.FieldEQ(FieldName, v)) } -// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. -func Type(v string) predicate.View { - return predicate.View(sql.FieldEQ(FieldType, v)) -} - // Component applies equality check predicate on the "component" field. It's identical to ComponentEQ. func Component(v string) predicate.View { return predicate.View(sql.FieldEQ(FieldComponent, v)) @@ -421,70 +416,25 @@ func NameContainsFold(v string) predicate.View { } // TypeEQ applies the EQ predicate on the "type" field. -func TypeEQ(v string) predicate.View { +func TypeEQ(v Type) predicate.View { return predicate.View(sql.FieldEQ(FieldType, v)) } // TypeNEQ applies the NEQ predicate on the "type" field. -func TypeNEQ(v string) predicate.View { +func TypeNEQ(v Type) predicate.View { return predicate.View(sql.FieldNEQ(FieldType, v)) } // TypeIn applies the In predicate on the "type" field. -func TypeIn(vs ...string) predicate.View { +func TypeIn(vs ...Type) predicate.View { return predicate.View(sql.FieldIn(FieldType, vs...)) } // TypeNotIn applies the NotIn predicate on the "type" field. -func TypeNotIn(vs ...string) predicate.View { +func TypeNotIn(vs ...Type) predicate.View { return predicate.View(sql.FieldNotIn(FieldType, vs...)) } -// TypeGT applies the GT predicate on the "type" field. -func TypeGT(v string) predicate.View { - return predicate.View(sql.FieldGT(FieldType, v)) -} - -// TypeGTE applies the GTE predicate on the "type" field. -func TypeGTE(v string) predicate.View { - return predicate.View(sql.FieldGTE(FieldType, v)) -} - -// TypeLT applies the LT predicate on the "type" field. -func TypeLT(v string) predicate.View { - return predicate.View(sql.FieldLT(FieldType, v)) -} - -// TypeLTE applies the LTE predicate on the "type" field. -func TypeLTE(v string) predicate.View { - return predicate.View(sql.FieldLTE(FieldType, v)) -} - -// TypeContains applies the Contains predicate on the "type" field. -func TypeContains(v string) predicate.View { - return predicate.View(sql.FieldContains(FieldType, v)) -} - -// TypeHasPrefix applies the HasPrefix predicate on the "type" field. -func TypeHasPrefix(v string) predicate.View { - return predicate.View(sql.FieldHasPrefix(FieldType, v)) -} - -// TypeHasSuffix applies the HasSuffix predicate on the "type" field. -func TypeHasSuffix(v string) predicate.View { - return predicate.View(sql.FieldHasSuffix(FieldType, v)) -} - -// TypeEqualFold applies the EqualFold predicate on the "type" field. -func TypeEqualFold(v string) predicate.View { - return predicate.View(sql.FieldEqualFold(FieldType, v)) -} - -// TypeContainsFold applies the ContainsFold predicate on the "type" field. -func TypeContainsFold(v string) predicate.View { - return predicate.View(sql.FieldContainsFold(FieldType, v)) -} - // ComponentEQ applies the EQ predicate on the "component" field. func ComponentEQ(v string) predicate.View { return predicate.View(sql.FieldEQ(FieldComponent, v)) @@ -811,7 +761,7 @@ func HasResources() predicate.View { return predicate.View(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, ResourcesTable, ResourcesPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, false, ResourcesTable, ResourcesPrimaryKey...), ) sqlgraph.HasNeighbors(s, step) }) @@ -834,7 +784,7 @@ func HasPermissions() predicate.View { return predicate.View(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, PermissionsTable, PermissionsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, false, PermissionsTable, PermissionsPrimaryKey...), ) sqlgraph.HasNeighbors(s, step) }) @@ -852,6 +802,52 @@ func HasPermissionsWith(preds ...predicate.Permission) predicate.View { }) } +// HasViewResources applies the HasEdge predicate on the "view_resources" edge. +func HasViewResources() predicate.View { + return predicate.View(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ViewResourcesTable, ViewResourcesColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasViewResourcesWith applies the HasEdge predicate on the "view_resources" edge with a given conditions (other predicates). +func HasViewResourcesWith(preds ...predicate.ViewResource) predicate.View { + return predicate.View(func(s *sql.Selector) { + step := newViewResourcesStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasViewPermissions applies the HasEdge predicate on the "view_permissions" edge. +func HasViewPermissions() predicate.View { + return predicate.View(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, ViewPermissionsTable, ViewPermissionsColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasViewPermissionsWith applies the HasEdge predicate on the "view_permissions" edge with a given conditions (other predicates). +func HasViewPermissionsWith(preds ...predicate.ViewPermission) predicate.View { + return predicate.View(func(s *sql.Selector) { + step := newViewPermissionsStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + // And groups predicates with the AND operator between them. func And(predicates ...predicate.View) predicate.View { return predicate.View(sql.AndPredicates(predicates...)) diff --git a/internal/data/entity/ent/view_create.go b/internal/data/entity/ent/view_create.go index 3ff20c65..13458730 100644 --- a/internal/data/entity/ent/view_create.go +++ b/internal/data/entity/ent/view_create.go @@ -9,6 +9,8 @@ import ( "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/entity/ent/viewresource" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -91,13 +93,13 @@ func (_c *ViewCreate) SetName(v string) *ViewCreate { } // SetType sets the "type" field. -func (_c *ViewCreate) SetType(v string) *ViewCreate { +func (_c *ViewCreate) SetType(v view.Type) *ViewCreate { _c.mutation.SetType(v) return _c } // SetNillableType sets the "type" field if the given value is not nil. -func (_c *ViewCreate) SetNillableType(v *string) *ViewCreate { +func (_c *ViewCreate) SetNillableType(v *view.Type) *ViewCreate { if v != nil { _c.SetType(*v) } @@ -238,6 +240,36 @@ func (_c *ViewCreate) AddPermissions(v ...*Permission) *ViewCreate { return _c.AddPermissionIDs(ids...) } +// AddViewResourceIDs adds the "view_resources" edge to the ViewResource entity by IDs. +func (_c *ViewCreate) AddViewResourceIDs(ids ...int64) *ViewCreate { + _c.mutation.AddViewResourceIDs(ids...) + return _c +} + +// AddViewResources adds the "view_resources" edges to the ViewResource entity. +func (_c *ViewCreate) AddViewResources(v ...*ViewResource) *ViewCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddViewResourceIDs(ids...) +} + +// AddViewPermissionIDs adds the "view_permissions" edge to the ViewPermission entity by IDs. +func (_c *ViewCreate) AddViewPermissionIDs(ids ...int64) *ViewCreate { + _c.mutation.AddViewPermissionIDs(ids...) + return _c +} + +// AddViewPermissions adds the "view_permissions" edges to the ViewPermission entity. +func (_c *ViewCreate) AddViewPermissions(v ...*ViewPermission) *ViewCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddViewPermissionIDs(ids...) +} + // Mutation returns the ViewMutation object of the builder. func (_c *ViewCreate) Mutation() *ViewMutation { return _c.mutation @@ -402,7 +434,7 @@ func (_c *ViewCreate) createSpec() (*View, *sqlgraph.CreateSpec) { _node.Name = value } if value, ok := _c.mutation.GetType(); ok { - _spec.SetField(view.FieldType, field.TypeString, value) + _spec.SetField(view.FieldType, field.TypeEnum, value) _node.Type = value } if value, ok := _c.mutation.Component(); ok { @@ -461,7 +493,7 @@ func (_c *ViewCreate) createSpec() (*View, *sqlgraph.CreateSpec) { if nodes := _c.mutation.ResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.ResourcesTable, Columns: view.ResourcesPrimaryKey, Bidi: false, @@ -472,12 +504,19 @@ func (_c *ViewCreate) createSpec() (*View, *sqlgraph.CreateSpec) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewResourceCreate{config: _c.config, mutation: newViewResourceMutation(_c.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.PermissionsTable, Columns: view.PermissionsPrimaryKey, Bidi: false, @@ -488,6 +527,45 @@ func (_c *ViewCreate) createSpec() (*View, *sqlgraph.CreateSpec) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewPermissionCreate{config: _c.config, mutation: newViewPermissionMutation(_c.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ViewResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewResourcesTable, + Columns: []string{view.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ViewPermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewPermissionsTable, + Columns: []string{view.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } _spec.Edges = append(_spec.Edges, edge) } return _node, _spec diff --git a/internal/data/entity/ent/view_query.go b/internal/data/entity/ent/view_query.go index f24d6d64..fe151ebf 100644 --- a/internal/data/entity/ent/view_query.go +++ b/internal/data/entity/ent/view_query.go @@ -11,6 +11,8 @@ import ( "origadmin/application/admin/internal/data/entity/ent/predicate" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/entity/ent/viewresource" "entgo.io/ent" "entgo.io/ent/dialect" @@ -22,15 +24,17 @@ import ( // ViewQuery is the builder for querying View entities. type ViewQuery struct { config - ctx *QueryContext - order []view.OrderOption - inters []Interceptor - predicates []predicate.View - withParent *ViewQuery - withChildren *ViewQuery - withResources *ResourceQuery - withPermissions *PermissionQuery - modifiers []func(*sql.Selector) + ctx *QueryContext + order []view.OrderOption + inters []Interceptor + predicates []predicate.View + withParent *ViewQuery + withChildren *ViewQuery + withResources *ResourceQuery + withPermissions *PermissionQuery + withViewResources *ViewResourceQuery + withViewPermissions *ViewPermissionQuery + modifiers []func(*sql.Selector) // intermediate query (i.e. traversal path). sql *sql.Selector path func(context.Context) (*sql.Selector, error) @@ -125,7 +129,7 @@ func (_q *ViewQuery) QueryResources() *ResourceQuery { step := sqlgraph.NewStep( sqlgraph.From(view.Table, view.FieldID, selector), sqlgraph.To(resource.Table, resource.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, view.ResourcesTable, view.ResourcesPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, false, view.ResourcesTable, view.ResourcesPrimaryKey...), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -147,7 +151,51 @@ func (_q *ViewQuery) QueryPermissions() *PermissionQuery { step := sqlgraph.NewStep( sqlgraph.From(view.Table, view.FieldID, selector), sqlgraph.To(permission.Table, permission.FieldID), - sqlgraph.Edge(sqlgraph.M2M, true, view.PermissionsTable, view.PermissionsPrimaryKey...), + sqlgraph.Edge(sqlgraph.M2M, false, view.PermissionsTable, view.PermissionsPrimaryKey...), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryViewResources chains the current query on the "view_resources" edge. +func (_q *ViewQuery) QueryViewResources() *ViewResourceQuery { + query := (&ViewResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, selector), + sqlgraph.To(viewresource.Table, viewresource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, view.ViewResourcesTable, view.ViewResourcesColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryViewPermissions chains the current query on the "view_permissions" edge. +func (_q *ViewQuery) QueryViewPermissions() *ViewPermissionQuery { + query := (&ViewPermissionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(view.Table, view.FieldID, selector), + sqlgraph.To(viewpermission.Table, viewpermission.FieldID), + sqlgraph.Edge(sqlgraph.O2M, true, view.ViewPermissionsTable, view.ViewPermissionsColumn), ) fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil @@ -342,15 +390,17 @@ func (_q *ViewQuery) Clone() *ViewQuery { return nil } return &ViewQuery{ - config: _q.config, - ctx: _q.ctx.Clone(), - order: append([]view.OrderOption{}, _q.order...), - inters: append([]Interceptor{}, _q.inters...), - predicates: append([]predicate.View{}, _q.predicates...), - withParent: _q.withParent.Clone(), - withChildren: _q.withChildren.Clone(), - withResources: _q.withResources.Clone(), - withPermissions: _q.withPermissions.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]view.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.View{}, _q.predicates...), + withParent: _q.withParent.Clone(), + withChildren: _q.withChildren.Clone(), + withResources: _q.withResources.Clone(), + withPermissions: _q.withPermissions.Clone(), + withViewResources: _q.withViewResources.Clone(), + withViewPermissions: _q.withViewPermissions.Clone(), // clone intermediate query. sql: _q.sql.Clone(), path: _q.path, @@ -402,6 +452,28 @@ func (_q *ViewQuery) WithPermissions(opts ...func(*PermissionQuery)) *ViewQuery return _q } +// WithViewResources tells the query-builder to eager-load the nodes that are connected to +// the "view_resources" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ViewQuery) WithViewResources(opts ...func(*ViewResourceQuery)) *ViewQuery { + query := (&ViewResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withViewResources = query + return _q +} + +// WithViewPermissions tells the query-builder to eager-load the nodes that are connected to +// the "view_permissions" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ViewQuery) WithViewPermissions(opts ...func(*ViewPermissionQuery)) *ViewQuery { + query := (&ViewPermissionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withViewPermissions = query + return _q +} + // GroupBy is used to group vertices by one or more fields/columns. // It is often used with aggregate functions, like: count, max, mean, min, sum. // @@ -480,11 +552,13 @@ func (_q *ViewQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*View, e var ( nodes = []*View{} _spec = _q.querySpec() - loadedTypes = [4]bool{ + loadedTypes = [6]bool{ _q.withParent != nil, _q.withChildren != nil, _q.withResources != nil, _q.withPermissions != nil, + _q.withViewResources != nil, + _q.withViewPermissions != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { @@ -535,6 +609,20 @@ func (_q *ViewQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*View, e return nil, err } } + if query := _q.withViewResources; query != nil { + if err := _q.loadViewResources(ctx, query, nodes, + func(n *View) { n.Edges.ViewResources = []*ViewResource{} }, + func(n *View, e *ViewResource) { n.Edges.ViewResources = append(n.Edges.ViewResources, e) }); err != nil { + return nil, err + } + } + if query := _q.withViewPermissions; query != nil { + if err := _q.loadViewPermissions(ctx, query, nodes, + func(n *View) { n.Edges.ViewPermissions = []*ViewPermission{} }, + func(n *View, e *ViewPermission) { n.Edges.ViewPermissions = append(n.Edges.ViewPermissions, e) }); err != nil { + return nil, err + } + } return nodes, nil } @@ -610,10 +698,10 @@ func (_q *ViewQuery) loadResources(ctx context.Context, query *ResourceQuery, no } query.Where(func(s *sql.Selector) { joinT := sql.Table(view.ResourcesTable) - s.Join(joinT).On(s.C(resource.FieldID), joinT.C(view.ResourcesPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(view.ResourcesPrimaryKey[1]), edgeIDs...)) + s.Join(joinT).On(s.C(resource.FieldID), joinT.C(view.ResourcesPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(view.ResourcesPrimaryKey[0]), edgeIDs...)) columns := s.SelectedColumns() - s.Select(joinT.C(view.ResourcesPrimaryKey[1])) + s.Select(joinT.C(view.ResourcesPrimaryKey[0])) s.AppendSelect(columns...) s.SetDistinct(false) }) @@ -671,10 +759,10 @@ func (_q *ViewQuery) loadPermissions(ctx context.Context, query *PermissionQuery } query.Where(func(s *sql.Selector) { joinT := sql.Table(view.PermissionsTable) - s.Join(joinT).On(s.C(permission.FieldID), joinT.C(view.PermissionsPrimaryKey[0])) - s.Where(sql.InValues(joinT.C(view.PermissionsPrimaryKey[1]), edgeIDs...)) + s.Join(joinT).On(s.C(permission.FieldID), joinT.C(view.PermissionsPrimaryKey[1])) + s.Where(sql.InValues(joinT.C(view.PermissionsPrimaryKey[0]), edgeIDs...)) columns := s.SelectedColumns() - s.Select(joinT.C(view.PermissionsPrimaryKey[1])) + s.Select(joinT.C(view.PermissionsPrimaryKey[0])) s.AppendSelect(columns...) s.SetDistinct(false) }) @@ -719,6 +807,66 @@ func (_q *ViewQuery) loadPermissions(ctx context.Context, query *PermissionQuery } return nil } +func (_q *ViewQuery) loadViewResources(ctx context.Context, query *ViewResourceQuery, nodes []*View, init func(*View), assign func(*View, *ViewResource)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*View) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(viewresource.FieldViewID) + } + query.Where(predicate.ViewResource(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(view.ViewResourcesColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ViewID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "view_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} +func (_q *ViewQuery) loadViewPermissions(ctx context.Context, query *ViewPermissionQuery, nodes []*View, init func(*View), assign func(*View, *ViewPermission)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*View) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(viewpermission.FieldViewID) + } + query.Where(predicate.ViewPermission(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(view.ViewPermissionsColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ViewID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "view_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (_q *ViewQuery) sqlCount(ctx context.Context) (int, error) { _spec := _q.querySpec() @@ -853,7 +1001,7 @@ func (_q *ViewQuery) Modify(modifiers ...func(s *sql.Selector)) *ViewSelect { // Keyword string `json:"keyword,omitempty"` // Scope string `json:"scope,omitempty"` // Name string `json:"name,omitempty"` -// Type string `json:"type,omitempty"` +// Type view.Type `json:"type,omitempty"` // Component string `json:"component,omitempty"` // Path string `json:"path,omitempty"` // Icon string `json:"icon,omitempty"` diff --git a/internal/data/entity/ent/view_update.go b/internal/data/entity/ent/view_update.go index 61d87429..be5592f5 100644 --- a/internal/data/entity/ent/view_update.go +++ b/internal/data/entity/ent/view_update.go @@ -10,6 +10,8 @@ import ( "origadmin/application/admin/internal/data/entity/ent/predicate" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/entity/ent/viewresource" "time" "entgo.io/ent/dialect/sql" @@ -100,13 +102,13 @@ func (_u *ViewUpdate) SetNillableName(v *string) *ViewUpdate { } // SetType sets the "type" field. -func (_u *ViewUpdate) SetType(v string) *ViewUpdate { +func (_u *ViewUpdate) SetType(v view.Type) *ViewUpdate { _u.mutation.SetType(v) return _u } // SetNillableType sets the "type" field if the given value is not nil. -func (_u *ViewUpdate) SetNillableType(v *string) *ViewUpdate { +func (_u *ViewUpdate) SetNillableType(v *view.Type) *ViewUpdate { if v != nil { _u.SetType(*v) } @@ -258,6 +260,36 @@ func (_u *ViewUpdate) AddPermissions(v ...*Permission) *ViewUpdate { return _u.AddPermissionIDs(ids...) } +// AddViewResourceIDs adds the "view_resources" edge to the ViewResource entity by IDs. +func (_u *ViewUpdate) AddViewResourceIDs(ids ...int64) *ViewUpdate { + _u.mutation.AddViewResourceIDs(ids...) + return _u +} + +// AddViewResources adds the "view_resources" edges to the ViewResource entity. +func (_u *ViewUpdate) AddViewResources(v ...*ViewResource) *ViewUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddViewResourceIDs(ids...) +} + +// AddViewPermissionIDs adds the "view_permissions" edge to the ViewPermission entity by IDs. +func (_u *ViewUpdate) AddViewPermissionIDs(ids ...int64) *ViewUpdate { + _u.mutation.AddViewPermissionIDs(ids...) + return _u +} + +// AddViewPermissions adds the "view_permissions" edges to the ViewPermission entity. +func (_u *ViewUpdate) AddViewPermissions(v ...*ViewPermission) *ViewUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddViewPermissionIDs(ids...) +} + // Mutation returns the ViewMutation object of the builder. func (_u *ViewUpdate) Mutation() *ViewMutation { return _u.mutation @@ -332,6 +364,48 @@ func (_u *ViewUpdate) RemovePermissions(v ...*Permission) *ViewUpdate { return _u.RemovePermissionIDs(ids...) } +// ClearViewResources clears all "view_resources" edges to the ViewResource entity. +func (_u *ViewUpdate) ClearViewResources() *ViewUpdate { + _u.mutation.ClearViewResources() + return _u +} + +// RemoveViewResourceIDs removes the "view_resources" edge to ViewResource entities by IDs. +func (_u *ViewUpdate) RemoveViewResourceIDs(ids ...int64) *ViewUpdate { + _u.mutation.RemoveViewResourceIDs(ids...) + return _u +} + +// RemoveViewResources removes "view_resources" edges to ViewResource entities. +func (_u *ViewUpdate) RemoveViewResources(v ...*ViewResource) *ViewUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveViewResourceIDs(ids...) +} + +// ClearViewPermissions clears all "view_permissions" edges to the ViewPermission entity. +func (_u *ViewUpdate) ClearViewPermissions() *ViewUpdate { + _u.mutation.ClearViewPermissions() + return _u +} + +// RemoveViewPermissionIDs removes the "view_permissions" edge to ViewPermission entities by IDs. +func (_u *ViewUpdate) RemoveViewPermissionIDs(ids ...int64) *ViewUpdate { + _u.mutation.RemoveViewPermissionIDs(ids...) + return _u +} + +// RemoveViewPermissions removes "view_permissions" edges to ViewPermission entities. +func (_u *ViewUpdate) RemoveViewPermissions(v ...*ViewPermission) *ViewUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveViewPermissionIDs(ids...) +} + // Save executes the query and returns the number of nodes affected by the update operation. func (_u *ViewUpdate) Save(ctx context.Context) (int, error) { _u.defaults() @@ -419,7 +493,7 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec.SetField(view.FieldName, field.TypeString, value) } if value, ok := _u.mutation.GetType(); ok { - _spec.SetField(view.FieldType, field.TypeString, value) + _spec.SetField(view.FieldType, field.TypeEnum, value) } if value, ok := _u.mutation.Component(); ok { _spec.SetField(view.FieldComponent, field.TypeString, value) @@ -525,7 +599,7 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { if _u.mutation.ResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.ResourcesTable, Columns: view.ResourcesPrimaryKey, Bidi: false, @@ -533,12 +607,19 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), }, } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !_u.mutation.ResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.ResourcesTable, Columns: view.ResourcesPrimaryKey, Bidi: false, @@ -549,12 +630,19 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.ResourcesTable, Columns: view.ResourcesPrimaryKey, Bidi: false, @@ -565,12 +653,19 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.PermissionsTable, Columns: view.PermissionsPrimaryKey, Bidi: false, @@ -578,12 +673,19 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), }, } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.PermissionsTable, Columns: view.PermissionsPrimaryKey, Bidi: false, @@ -594,12 +696,19 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.PermissionsTable, Columns: view.PermissionsPrimaryKey, Bidi: false, @@ -610,6 +719,103 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ViewResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewResourcesTable, + Columns: []string{view.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedViewResourcesIDs(); len(nodes) > 0 && !_u.mutation.ViewResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewResourcesTable, + Columns: []string{view.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewResourcesTable, + Columns: []string{view.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ViewPermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewPermissionsTable, + Columns: []string{view.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedViewPermissionsIDs(); len(nodes) > 0 && !_u.mutation.ViewPermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewPermissionsTable, + Columns: []string{view.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewPermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewPermissionsTable, + Columns: []string{view.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _spec.AddModifiers(_u.modifiers...) @@ -703,13 +909,13 @@ func (_u *ViewUpdateOne) SetNillableName(v *string) *ViewUpdateOne { } // SetType sets the "type" field. -func (_u *ViewUpdateOne) SetType(v string) *ViewUpdateOne { +func (_u *ViewUpdateOne) SetType(v view.Type) *ViewUpdateOne { _u.mutation.SetType(v) return _u } // SetNillableType sets the "type" field if the given value is not nil. -func (_u *ViewUpdateOne) SetNillableType(v *string) *ViewUpdateOne { +func (_u *ViewUpdateOne) SetNillableType(v *view.Type) *ViewUpdateOne { if v != nil { _u.SetType(*v) } @@ -861,6 +1067,36 @@ func (_u *ViewUpdateOne) AddPermissions(v ...*Permission) *ViewUpdateOne { return _u.AddPermissionIDs(ids...) } +// AddViewResourceIDs adds the "view_resources" edge to the ViewResource entity by IDs. +func (_u *ViewUpdateOne) AddViewResourceIDs(ids ...int64) *ViewUpdateOne { + _u.mutation.AddViewResourceIDs(ids...) + return _u +} + +// AddViewResources adds the "view_resources" edges to the ViewResource entity. +func (_u *ViewUpdateOne) AddViewResources(v ...*ViewResource) *ViewUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddViewResourceIDs(ids...) +} + +// AddViewPermissionIDs adds the "view_permissions" edge to the ViewPermission entity by IDs. +func (_u *ViewUpdateOne) AddViewPermissionIDs(ids ...int64) *ViewUpdateOne { + _u.mutation.AddViewPermissionIDs(ids...) + return _u +} + +// AddViewPermissions adds the "view_permissions" edges to the ViewPermission entity. +func (_u *ViewUpdateOne) AddViewPermissions(v ...*ViewPermission) *ViewUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddViewPermissionIDs(ids...) +} + // Mutation returns the ViewMutation object of the builder. func (_u *ViewUpdateOne) Mutation() *ViewMutation { return _u.mutation @@ -935,6 +1171,48 @@ func (_u *ViewUpdateOne) RemovePermissions(v ...*Permission) *ViewUpdateOne { return _u.RemovePermissionIDs(ids...) } +// ClearViewResources clears all "view_resources" edges to the ViewResource entity. +func (_u *ViewUpdateOne) ClearViewResources() *ViewUpdateOne { + _u.mutation.ClearViewResources() + return _u +} + +// RemoveViewResourceIDs removes the "view_resources" edge to ViewResource entities by IDs. +func (_u *ViewUpdateOne) RemoveViewResourceIDs(ids ...int64) *ViewUpdateOne { + _u.mutation.RemoveViewResourceIDs(ids...) + return _u +} + +// RemoveViewResources removes "view_resources" edges to ViewResource entities. +func (_u *ViewUpdateOne) RemoveViewResources(v ...*ViewResource) *ViewUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveViewResourceIDs(ids...) +} + +// ClearViewPermissions clears all "view_permissions" edges to the ViewPermission entity. +func (_u *ViewUpdateOne) ClearViewPermissions() *ViewUpdateOne { + _u.mutation.ClearViewPermissions() + return _u +} + +// RemoveViewPermissionIDs removes the "view_permissions" edge to ViewPermission entities by IDs. +func (_u *ViewUpdateOne) RemoveViewPermissionIDs(ids ...int64) *ViewUpdateOne { + _u.mutation.RemoveViewPermissionIDs(ids...) + return _u +} + +// RemoveViewPermissions removes "view_permissions" edges to ViewPermission entities. +func (_u *ViewUpdateOne) RemoveViewPermissions(v ...*ViewPermission) *ViewUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveViewPermissionIDs(ids...) +} + // Where appends a list predicates to the ViewUpdate builder. func (_u *ViewUpdateOne) Where(ps ...predicate.View) *ViewUpdateOne { _u.mutation.Where(ps...) @@ -1052,7 +1330,7 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { _spec.SetField(view.FieldName, field.TypeString, value) } if value, ok := _u.mutation.GetType(); ok { - _spec.SetField(view.FieldType, field.TypeString, value) + _spec.SetField(view.FieldType, field.TypeEnum, value) } if value, ok := _u.mutation.Component(); ok { _spec.SetField(view.FieldComponent, field.TypeString, value) @@ -1158,7 +1436,7 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { if _u.mutation.ResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.ResourcesTable, Columns: view.ResourcesPrimaryKey, Bidi: false, @@ -1166,12 +1444,19 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), }, } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedResourcesIDs(); len(nodes) > 0 && !_u.mutation.ResourcesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.ResourcesTable, Columns: view.ResourcesPrimaryKey, Bidi: false, @@ -1182,12 +1467,19 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.ResourcesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.ResourcesTable, Columns: view.ResourcesPrimaryKey, Bidi: false, @@ -1198,12 +1490,19 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.PermissionsTable, Columns: view.PermissionsPrimaryKey, Bidi: false, @@ -1211,12 +1510,19 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), }, } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.RemovedPermissionsIDs(); len(nodes) > 0 && !_u.mutation.PermissionsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.PermissionsTable, Columns: view.PermissionsPrimaryKey, Bidi: false, @@ -1227,12 +1533,19 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } if nodes := _u.mutation.PermissionsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, - Inverse: true, + Inverse: false, Table: view.PermissionsTable, Columns: view.PermissionsPrimaryKey, Bidi: false, @@ -1243,6 +1556,103 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } + createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} + createE.defaults() + _, specE := createE.createSpec() + edge.Target.Fields = specE.Fields + if specE.ID.Value != nil { + edge.Target.Fields = append(edge.Target.Fields, specE.ID) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ViewResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewResourcesTable, + Columns: []string{view.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedViewResourcesIDs(); len(nodes) > 0 && !_u.mutation.ViewResourcesCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewResourcesTable, + Columns: []string{view.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewResourcesIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewResourcesTable, + Columns: []string{view.ViewResourcesColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ViewPermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewPermissionsTable, + Columns: []string{view.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedViewPermissionsIDs(); len(nodes) > 0 && !_u.mutation.ViewPermissionsCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewPermissionsTable, + Columns: []string{view.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewPermissionsIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: true, + Table: view.ViewPermissionsTable, + Columns: []string{view.ViewPermissionsColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } _spec.Edges.Add = append(_spec.Edges.Add, edge) } _spec.AddModifiers(_u.modifiers...) From dacc5e7b0863ac5248f087e37b55b99fa78feb96 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 16:01:52 +0800 Subject: [PATCH 086/158] feat(i18n): refactor i18n package with embedded locale files and new manager pattern --- internal/helpers/db/db.go | 16 +- internal/helpers/errors/config.go | 23 --- internal/helpers/errors/errors.go | 70 -------- internal/helpers/errors/start.go | 27 --- internal/helpers/i18n/i18n.go | 204 ++++++++--------------- internal/helpers/i18n/i18n_test.go | 6 +- internal/helpers/i18n/locales/en_US.json | 89 ++++++++++ internal/helpers/i18n/locales/zh_CN.json | 3 + 8 files changed, 173 insertions(+), 265 deletions(-) delete mode 100644 internal/helpers/errors/config.go delete mode 100644 internal/helpers/errors/errors.go delete mode 100644 internal/helpers/errors/start.go create mode 100644 internal/helpers/i18n/locales/en_US.json create mode 100644 internal/helpers/i18n/locales/zh_CN.json diff --git a/internal/helpers/db/db.go b/internal/helpers/db/db.go index 5e1a15f9..f83608ba 100644 --- a/internal/helpers/db/db.go +++ b/internal/helpers/db/db.go @@ -11,7 +11,7 @@ import ( "entgo.io/ent/dialect/sql" - "origadmin/application/admin/internal/helpers/pagination" + "origadmin/application/admin/internal/helpers/repo" ) type Paginator[T any] interface { @@ -28,20 +28,14 @@ type FieldSelector[T any] interface { Omit(...string) T } -func Query[P Paginator[P]](query P, in repo.PageRequest, paging bool) P { +func Query[P Paginator[P]](query P, in repo.PaginatingRequest, paging bool) P { if !paging { return QueryNoPage(query, in) } return QueryPage(query, in) } -type PageRequest interface { - GetPageSize() int32 - GetPageToken() string - GetCurrent() int32 -} - -func QueryNoPage[P Paginator[P]](query P, in PageRequest) P { +func QueryNoPage[P Paginator[P]](query P, in repo.PaginatingRequest) P { pageSize := in.GetPageSize() if pageSize > 0 { query = query.Limit(int(pageSize)) @@ -57,7 +51,7 @@ func handleTokenPagination[P Paginator[P]](query P, token string) P { return query } -func QueryPage[P Paginator[P]](query P, in PageRequest) P { +func QueryPage[P Paginator[P]](query P, in repo.PaginatingRequest) P { pageSize := in.GetPageSize() if pageSize > 0 { query = query.Limit(int(pageSize)) @@ -66,7 +60,7 @@ func QueryPage[P Paginator[P]](query P, in PageRequest) P { if token != "" { return handleTokenPagination(query, token) } - current := in.GetCurrent() + current := in.GetPage() if current > 0 { return query.Offset(int((current - 1) * pageSize)) } diff --git a/internal/helpers/errors/config.go b/internal/helpers/errors/config.go deleted file mode 100644 index a820451f..00000000 --- a/internal/helpers/errors/config.go +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package errors - -import ( - "fmt" -) - -type configErr struct { - name string - message string - error -} - -func (c configErr) Error() string { - return fmt.Sprintf("file %s: %s,error:%v", c.name, c.message, c.error) -} - -func ConfigError(err error, name string, message string) error { - return configErr{name: name, message: message, error: err} -} diff --git a/internal/helpers/errors/errors.go b/internal/helpers/errors/errors.go deleted file mode 100644 index 666ef760..00000000 --- a/internal/helpers/errors/errors.go +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package errors - -import ( - "net/http" - - "github.com/go-kratos/kratos/v2/errors" - transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/origadmin/toolkits/errors/httperr" -) - -type Error = httperr.Error - -func ErrorEncoder(w http.ResponseWriter, r *http.Request, err error) { - var reply Error - if !errors.As(err, &reply) { - se := errors.FromError(err) - reply.ID = se.Message - reply.Code = se.Code - reply.Detail = se.Reason - - } - - codec, _ := transhttp.CodecForRequest(r, "Accept") - body, err := codec.Marshal(reply) - if err != nil { - w.WriteHeader(http.StatusInternalServerError) - return - } - w.Header().Set("Content-Type", contentType(codec.Name())) - w.WriteHeader(http.StatusOK) - w.Write(body) -} - -func ResponseEncoder(w http.ResponseWriter, r *http.Request, v interface{}) error { - //reply := NewResponse() - //reply.Code = 200 - //reply.Data = v - //reply.Message = "success" - //reply.Reason = "success" - //reply.Ts = time.Now().Format(pkgTime.MilliTimeLayout) - reply := v - - codec, _ := transhttp.CodecForRequest(r, "Accept") - data, err := codec.Marshal(reply) - if err != nil { - return err - } - - w.Header().Set("Content-Type", contentType(codec.Name())) - w.WriteHeader(http.StatusOK) - w.Write(data) - return nil -} - -func contentType(name string) string { - return "application/" + name -} - -func New() []transhttp.ServerOption { - var opts []transhttp.ServerOption - // Error decoder - opts = append(opts, transhttp.ErrorEncoder(ErrorEncoder)) - // Returns the parameter decoder - opts = append(opts, transhttp.ResponseEncoder(ResponseEncoder)) - return opts -} diff --git a/internal/helpers/errors/start.go b/internal/helpers/errors/start.go deleted file mode 100644 index 9301a060..00000000 --- a/internal/helpers/errors/start.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package errors - -import ( - "fmt" -) - -type startError struct { - name string - message string - err error -} - -func (r startError) Error() string { - return fmt.Sprintf("[%s] %s: %s", r.name, r.message, r.err) -} - -func StartError(name string, message string, err error) error { - return &startError{ - name: name, - message: message, - err: err, - } -} diff --git a/internal/helpers/i18n/i18n.go b/internal/helpers/i18n/i18n.go index da1845e8..a4373921 100644 --- a/internal/helpers/i18n/i18n.go +++ b/internal/helpers/i18n/i18n.go @@ -1,148 +1,90 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package i18n implements the functions, types, and interfaces for the module. package i18n -const ( - // DefaultLanguage defines the default language for the system - DefaultLanguage = "en_US" +import ( + "embed" + "encoding/json" + "io/fs" + "path" + "strings" + "sync" ) -var locale = "en_US" - -// KeyTextMap defines all internationalized key-value pairs used in the system -var KeyTextMap = map[string]map[string]string{ - "zh_CN": { - "entity.test": "测试", - // 权限相关 - "entity.permission.system.user.manage": "系统用户管理权限", - "entity.permission.dept.staff.transfer": "部门人员调动权限", - "entity.permission.resource.api.access": "API访问权限", - - "entity.department.name": "部门名称", - "entity.department.keyword": "部门编码", - - // 菜单相关 - "entity.menu.system.user": "系统用户管理", - "entity.menu.system.role": "系统角色管理", - "entity.menu.dept.manage": "部门管理", - - // 按钮相关 - "entity.button.add": "添加", - "entity.button.edit": "编辑", - "entity.button.delete": "删除", - - // 通用字段 - "entity.field.name": "名称", - "entity.field.description": "描述", - "entity.field.status": "状态", - "entity.field.created_at": "创建时间", - "entity.field.updated_at": "更新时间", - }, - "en_US": { - "entity.test": "test", - // Permissions - "entity.permission.system.user.manage": "System User Management Permission", - "entity.permission.dept.staff.transfer": "Department Staff Transfer Permission", - "entity.permission.resource.api.access": "API Access Permission", +//go:embed locales/*.json +var localesFS embed.FS - // Menus - "entity.menu.system.user": "System Users", - "entity.menu.system.role": "System Roles", - "entity.menu.dept.manage": "Department Management", - - // Buttons - "entity.button.add": "Add", - "entity.button.edit": "Edit", - "entity.button.delete": "Delete", - - // Common Fields - "entity.field.name": "Name", - "entity.field.description": "Description", - "entity.field.status": "Status", - "entity.field.created_at": "Created At", - "entity.field.updated_at": "Updated At", +const ( + // DefaultLang defines the language used for build-time tasks and as a fallback. + DefaultLang = "en" +) - // Department - "entity.department.id": "Primary key of Department", - "entity.department.department_id": "Foreign key of Department", - "entity.department.keyword": "Keyword of Department", - "entity.department.name": "Display name of Department", - "entity.department.description": "Details about Department", - "entity.department.sequence": "Sequence for sorting", - "entity.department.status": "Status of the department", - "entity.department.inherit_roles": "Whether to inherit roles from the parent department", - "entity.department.ancestors": "Ancestor list (format: ,1,2,3,)", - "entity.department.parent_id": "Parent department ID", - "entity.department.level": "Department level", +var ( + globalManager *Manager + once sync.Once +) - // Menu - "entity.menu.id": "Primary key of the menu item", - "entity.menu.menu_id": "Foreign key of the menu item", - "entity.menu.keyword": "Unique keyword for the menu item", - "entity.menu.name": "Display name of the menu item", - "entity.menu.description": "Description of the menu item", - "entity.menu.type": "Type of the menu item (e.g., page, link)", - "entity.menu.icon": "Icon for the menu item", - "entity.menu.path": "Path associated with the menu item", - "entity.menu.status": "Status of the menu item (e.g., activated, deactivated)", - "entity.menu.parent_path": "Parent path of the menu item", - "entity.menu.sequence": "Sequence for sorting the menu item", - "entity.menu.properties": "Additional properties of the menu item", - "entity.menu.parent_id": "Parent ID of the menu item", - }, +// Manager handles loading and retrieving translations. +type Manager struct { + translations map[string]map[string]string // map[lang]map[key]value } -// LocaleText Obtain the corresponding translated text based on the key and language -func LocaleText(locale string, key string) string { - // If you cannot find the specified language, - // Chinese is used by default - if translations, ok := KeyTextMap[locale]; ok { - if text, exists := translations[key]; exists { - //fmt.Println("locale.", locale, "key.", key, "text.", text) - return text +// initManager loads all locale files from the embedded filesystem. +func initManager() { + once.Do(func() { + m := &Manager{ + translations: make(map[string]map[string]string), } - } - // If the specified language cannot be found and - // the language is the default language, - // the key itself is returned - if locale == DefaultLanguage { - //fmt.Println("locale.", locale, "key.", key, "text.", "default") - return key - } - if translations, ok := KeyTextMap[DefaultLanguage]; ok { - if text, exists := translations[key]; exists { - //fmt.Println("locale.", "default", "key.", key, "text.", text) - return text + + files, err := fs.ReadDir(localesFS, "locales") + if err != nil { + // A broken build should stop the process. + panic("i18n: failed to read embedded locales directory: " + err.Error()) } - } - return key + + for _, file := range files { + if file.IsDir() || path.Ext(file.Name()) != ".json" { + continue + } + + lang := strings.TrimSuffix(file.Name(), ".json") + content, err := fs.ReadFile(localesFS, path.Join("locales", file.Name())) + if err != nil { + panic("i18n: failed to read locale file " + file.Name() + ": " + err.Error()) + } + + var translationsForLang map[string]string + if err := json.Unmarshal(content, &translationsForLang); err != nil { + panic("i18n: failed to parse locale file " + file.Name() + ": " + err.Error()) + } + m.translations[lang] = translationsForLang + } + globalManager = m + }) } +// Text returns the translation for the given key in the **default language**. +// This function is 100% backward compatible and is used for build-time tasks +// like `go generate` and as the default for runtime usage. +// IT MUST NOT BE RENAMED OR HAVE ITS SIGNATURE CHANGED. func Text(key string) string { - return LocaleText(locale, key) + initManager() + if defaultTranslations, ok := globalManager.translations[DefaultLang]; ok { + if val, ok := defaultTranslations[key]; ok { + return val + } + } + return key // Fallback to the key itself. } -// Docs -// // 权限相关 -// permission.system.user.manage // 系统用户管理权限 -// permission.dept.staff.transfer // 部门人员调动权限 -// permission.resource.api.access // API访问权限 - -// // 菜单相关 -// menu.system.user // 系统用户菜单 -// menu.system.role // 系统角色菜单 -// menu.dept.manage // 部门管理菜单 - -// // 按钮相关 -// button.add // 添加按钮 -// button.edit // 编辑按钮 -// button.delete // 删除按钮 - -// Locale 获取当前系统语言设置 -func Locale() string { - //i18n.PreferredLocale(i18n.Locales, "zh_CN", "en_US") - return locale +// TextFor returns the translation for a given key in a specific language. +// This is the new function to be used at RUNTIME for multi-language support. +func TextFor(lang, key string) string { + initManager() + // Try to get the translation for the requested language. + if langTranslations, ok := globalManager.translations[lang]; ok { + if val, ok := langTranslations[key]; ok { + return val + } + } + // Fallback to the default language. + return Text(key) } diff --git a/internal/helpers/i18n/i18n_test.go b/internal/helpers/i18n/i18n_test.go index 1c6d6007..1afae3ab 100644 --- a/internal/helpers/i18n/i18n_test.go +++ b/internal/helpers/i18n/i18n_test.go @@ -26,7 +26,7 @@ func TestLocaleText(t *testing.T) { locale: "en_US", key: "test", }, - want: "test", + want: "en_US test", }, { name: "test2", @@ -34,12 +34,12 @@ func TestLocaleText(t *testing.T) { locale: "zh_CN", key: "test", }, - want: "测试", + want: "中文测试", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := LocaleText(tt.args.locale, tt.args.key); got != tt.want { + if got := TextFor(tt.args.locale, tt.args.key); got != tt.want { t.Errorf("LocaleText() = %v, want %v", got, tt.want) } }) diff --git a/internal/helpers/i18n/locales/en_US.json b/internal/helpers/i18n/locales/en_US.json new file mode 100644 index 00000000..c95768f5 --- /dev/null +++ b/internal/helpers/i18n/locales/en_US.json @@ -0,0 +1,89 @@ +{ + "test": "en_US test", + "entity.user.field.uuid": "The unique identifier of the user (UUID).", + "entity.user.field.allowed_ip": "Allowed IP addresses for the user, separated by commas. '0.0.0.0' means no limit.", + "entity.user.field.username": "The login username of the user.", + "entity.user.field.nickname": "The display name or nickname of the user.", + "entity.user.field.avatar": "The URL of the user's avatar image.", + "entity.user.field.name": "The real name of the user.", + "entity.user.field.gender": "The gender of the user (male, female, unknown).", + "entity.user.field.encrypted_password": "The encrypted password hash of the user.", + "entity.user.field.salt": "The salt used for password hashing (deprecated).", + "entity.user.field.phone": "The phone number of the user.", + "entity.user.field.email": "The email address of the user.", + "entity.user.field.department": "The department the user belongs to.", + "entity.user.field.remark": "Additional remarks or notes about the user.", + "entity.user.field.token": "The authentication token for the user.", + "entity.user.field.status": "The status of the user account (e.g., active, inactive).", + "entity.user.field.is_system": "Indicates if the user is a system-level user (cannot be deleted).", + "entity.user.field.last_login_ip": "The IP address of the last login.", + "entity.user.field.last_login_time": "The time of the last login.", + "entity.user.field.login_time": "The time of the current login.", + "entity.user.field.sanction_date": "The date until which the user is sanctioned.", + "entity.user.field.manager_id": "The ID of the user's manager.", + "entity.user.field.manager": "The name of the user's manager.", + "entity.user.table.comment": "Stores user account information.", + + "entity.role.field.keyword": "Unique keyword for the role (e.g., 'admin').", + "entity.role.field.name": "Display name of the role.", + "entity.role.field.description": "Detailed description of the role's purpose.", + "entity.role.field.type": "The type of the role (e.g., system-defined, user-defined).", + "entity.role.field.sequence": "The sorting order of the role.", + "entity.role.field.status": "The status of the role (e.g., enabled, disabled).", + "entity.role.table.comment": "Stores role definitions and their properties.", + + "entity.permission.field.name": "Display name of the permission.", + "entity.permission.field.keyword": "Unique keyword for the permission (e.g., 'user:create').", + "entity.permission.field.description": "Detailed description of what the permission allows.", + "entity.permission.field.data_scope": "The data scope this permission applies to (e.g., self, dept, all).", + "entity.permission.field.data_rules": "JSON-defined rules for data scoping.", + "entity.permission.field.actions": "The actions allowed by this permission (e.g., read, write).", + "entity.permission.table.comment": "Stores permission definitions.", + + "entity.notification.field.subject": "The subject or title of the notification.", + "entity.notification.field.content": "The main content of the notification.", + "entity.notification.field.status": "The status of the notification (e.g., unread, read).", + "entity.notification.field.category_id": "The ID of the category this notification belongs to.", + "entity.notification.table.comment": "Stores user notifications.", + + "view.parent_id.comment": "The ID of the parent view, used for building a tree structure.", + "view.keyword.comment": "Global unique keyword for the view element.", + "view.scope.comment": "The scope where the view is used (e.g., 'default' for sidebar).", + "view.name.comment": "The display name of the view element.", + "view.type.comment": "The type of the view element (e.g., Menu, Button, Page).", + "view.component.comment": "The frontend component path for rendering.", + "view.path.comment": "The routing path associated with the view.", + "view.icon.comment": "The icon used for the view element.", + "view.visible.comment": "Indicates if the view is visible in the UI.", + "view.sequence.comment": "The sorting order of the view element.", + + "resource.service_name.comment": "The name of the microservice this resource belongs to.", + "resource.keyword.comment": "Global unique keyword to associate with a View.", + "resource.path.comment": "The HTTP API path template.", + "resource.method.comment": "The HTTP method for the API.", + "resource.operation.comment": "The gRPC full method name.", + "resource.policy.comment": "The raw policy string from the proto annotation.", + "resource.version_id.comment": "A hash representing the version of this policy definition.", + "resource.last_sync_version_id.comment": "The version ID of the last successful sync.", + "resource.sync_status.comment": "Sync status with the code definition (e.g., Synced, Modified).", + "resource.status.comment": "The status of the resource (e.g., enabled, disabled).", + + "view_resource.view_id.comment": "The ID of the associated view.", + "view_resource.resource_id.comment": "The ID of the associated resource.", + "entity.view_resource.table.comment": "Through-table for the many-to-many relationship between views and resources.", + + "view_permission.view_id.comment": "The ID of the associated view.", + "view_permission.permission_id.comment": "The ID of the associated permission.", + "entity.view_permission.table.comment": "Through-table for the many-to-many relationship between views and permissions.", + + "field.primary_key.comment": "The primary key of the table.", + "field.foreign_key.comment": "A foreign key to another table.", + "field.optional_key.comment": "An optional foreign key to another table.", + "create_author.field.comment": "The ID of the user who created this record.", + "update_author.field.comment": "The ID of the user who last updated this record.", + "manager_id.field.comment": "The ID of the manager.", + "manager_name.field.comment": "The name of the manager.", + "create_time.field.comment": "The creation time of the record.", + "update_time.field.comment": "The last update time of the record.", + "delete_time.field.comment": "The deletion time of the record (for soft delete)." +} diff --git a/internal/helpers/i18n/locales/zh_CN.json b/internal/helpers/i18n/locales/zh_CN.json new file mode 100644 index 00000000..6c35b688 --- /dev/null +++ b/internal/helpers/i18n/locales/zh_CN.json @@ -0,0 +1,3 @@ +{ + "test": "中文测试" +} From 363f1d5b4d359a3e22df3da2566213933d62a152 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 17:05:24 +0800 Subject: [PATCH 087/158] feat(ent): add ViewPermission and ViewResource ent schemas for view-permission and view-resource relations --- internal/data/entity/ent/viewpermission.go | 208 +++++ .../ent/viewpermission/viewpermission.go | 219 +++++ .../data/entity/ent/viewpermission/where.go | 367 +++++++++ .../data/entity/ent/viewpermission_create.go | 400 +++++++++ .../data/entity/ent/viewpermission_delete.go | 88 ++ .../data/entity/ent/viewpermission_query.go | 771 ++++++++++++++++++ .../data/entity/ent/viewpermission_update.go | 694 ++++++++++++++++ internal/data/entity/ent/viewresource.go | 208 +++++ .../entity/ent/viewresource/viewresource.go | 219 +++++ .../data/entity/ent/viewresource/where.go | 367 +++++++++ .../data/entity/ent/viewresource_create.go | 400 +++++++++ .../data/entity/ent/viewresource_delete.go | 88 ++ .../data/entity/ent/viewresource_query.go | 771 ++++++++++++++++++ .../data/entity/ent/viewresource_update.go | 694 ++++++++++++++++ internal/data/enums/role.go | 23 + internal/data/enums/user.go | 15 + internal/features/system/dal/user.go | 1 - internal/features/system/dto/dto.go | 1 + internal/features/system/dto/resource_type.go | 65 -- internal/features/system/dto/view_type.go | 74 ++ internal/helpers/db/coalesce.go | 25 + internal/helpers/db/db.go | 101 +-- internal/helpers/db/pagination.go | 91 +++ internal/helpers/db/sorting.go | 42 + internal/helpers/repo/options.go | 15 +- 25 files changed, 5781 insertions(+), 166 deletions(-) create mode 100644 internal/data/entity/ent/viewpermission.go create mode 100644 internal/data/entity/ent/viewpermission/viewpermission.go create mode 100644 internal/data/entity/ent/viewpermission/where.go create mode 100644 internal/data/entity/ent/viewpermission_create.go create mode 100644 internal/data/entity/ent/viewpermission_delete.go create mode 100644 internal/data/entity/ent/viewpermission_query.go create mode 100644 internal/data/entity/ent/viewpermission_update.go create mode 100644 internal/data/entity/ent/viewresource.go create mode 100644 internal/data/entity/ent/viewresource/viewresource.go create mode 100644 internal/data/entity/ent/viewresource/where.go create mode 100644 internal/data/entity/ent/viewresource_create.go create mode 100644 internal/data/entity/ent/viewresource_delete.go create mode 100644 internal/data/entity/ent/viewresource_query.go create mode 100644 internal/data/entity/ent/viewresource_update.go create mode 100644 internal/data/enums/role.go create mode 100644 internal/data/enums/user.go delete mode 100644 internal/features/system/dto/resource_type.go create mode 100644 internal/features/system/dto/view_type.go create mode 100644 internal/helpers/db/coalesce.go create mode 100644 internal/helpers/db/pagination.go create mode 100644 internal/helpers/db/sorting.go diff --git a/internal/data/entity/ent/viewpermission.go b/internal/data/entity/ent/viewpermission.go new file mode 100644 index 00000000..726bfc22 --- /dev/null +++ b/internal/data/entity/ent/viewpermission.go @@ -0,0 +1,208 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// entity.view_permission.table.comment +type ViewPermission struct { + config `json:"-"` + // ID of the ent. + // field.primary_key.comment + ID int64 `json:"id,omitempty"` + // create_author.field.comment + CreateAuthor int64 `json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `json:"update_author,omitempty"` + // create_time.field.comment + CreateTime time.Time `json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime time.Time `json:"update_time,omitempty"` + // view_permission.view_id.comment + ViewID int64 `json:"view_id,omitempty"` + // view_permission.permission_id.comment + PermissionID int64 `json:"permission_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ViewPermissionQuery when eager-loading is set. + Edges ViewPermissionEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ViewPermissionEdges holds the relations/edges for other nodes in the graph. +type ViewPermissionEdges struct { + // View holds the value of the view edge. + View *View `json:"view,omitempty"` + // Permission holds the value of the permission edge. + Permission *Permission `json:"permission,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// ViewOrErr returns the View value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ViewPermissionEdges) ViewOrErr() (*View, error) { + if e.View != nil { + return e.View, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: view.Label} + } + return nil, &NotLoadedError{edge: "view"} +} + +// PermissionOrErr returns the Permission value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ViewPermissionEdges) PermissionOrErr() (*Permission, error) { + if e.Permission != nil { + return e.Permission, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: permission.Label} + } + return nil, &NotLoadedError{edge: "permission"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ViewPermission) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case viewpermission.FieldID, viewpermission.FieldCreateAuthor, viewpermission.FieldUpdateAuthor, viewpermission.FieldViewID, viewpermission.FieldPermissionID: + values[i] = new(sql.NullInt64) + case viewpermission.FieldCreateTime, viewpermission.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ViewPermission fields. +func (_m *ViewPermission) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case viewpermission.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case viewpermission.FieldCreateAuthor: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field create_author", values[i]) + } else if value.Valid { + _m.CreateAuthor = value.Int64 + } + case viewpermission.FieldUpdateAuthor: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field update_author", values[i]) + } else if value.Valid { + _m.UpdateAuthor = value.Int64 + } + case viewpermission.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = value.Time + } + case viewpermission.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = value.Time + } + case viewpermission.FieldViewID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field view_id", values[i]) + } else if value.Valid { + _m.ViewID = value.Int64 + } + case viewpermission.FieldPermissionID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field permission_id", values[i]) + } else if value.Valid { + _m.PermissionID = value.Int64 + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ViewPermission. +// This includes values selected through modifiers, order, etc. +func (_m *ViewPermission) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryView queries the "view" edge of the ViewPermission entity. +func (_m *ViewPermission) QueryView() *ViewQuery { + return NewViewPermissionClient(_m.config).QueryView(_m) +} + +// QueryPermission queries the "permission" edge of the ViewPermission entity. +func (_m *ViewPermission) QueryPermission() *PermissionQuery { + return NewViewPermissionClient(_m.config).QueryPermission(_m) +} + +// Update returns a builder for updating this ViewPermission. +// Note that you need to call ViewPermission.Unwrap() before calling this method if this ViewPermission +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *ViewPermission) Update() *ViewPermissionUpdateOne { + return NewViewPermissionClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the ViewPermission entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *ViewPermission) Unwrap() *ViewPermission { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: ViewPermission is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *ViewPermission) String() string { + var builder strings.Builder + builder.WriteString("ViewPermission(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("create_author=") + builder.WriteString(fmt.Sprintf("%v", _m.CreateAuthor)) + builder.WriteString(", ") + builder.WriteString("update_author=") + builder.WriteString(fmt.Sprintf("%v", _m.UpdateAuthor)) + builder.WriteString(", ") + builder.WriteString("create_time=") + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("view_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ViewID)) + builder.WriteString(", ") + builder.WriteString("permission_id=") + builder.WriteString(fmt.Sprintf("%v", _m.PermissionID)) + builder.WriteByte(')') + return builder.String() +} + +// ViewPermissions is a parsable slice of ViewPermission. +type ViewPermissions []*ViewPermission diff --git a/internal/data/entity/ent/viewpermission/viewpermission.go b/internal/data/entity/ent/viewpermission/viewpermission.go new file mode 100644 index 00000000..2f016813 --- /dev/null +++ b/internal/data/entity/ent/viewpermission/viewpermission.go @@ -0,0 +1,219 @@ +// Code generated by ent, DO NOT EDIT. + +package viewpermission + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the viewpermission type in the database. + Label = "view_permission" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateAuthor holds the string denoting the create_author field in the database. + FieldCreateAuthor = "create_author" + // FieldUpdateAuthor holds the string denoting the update_author field in the database. + FieldUpdateAuthor = "update_author" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldViewID holds the string denoting the view_id field in the database. + FieldViewID = "view_id" + // FieldPermissionID holds the string denoting the permission_id field in the database. + FieldPermissionID = "permission_id" + // EdgeView holds the string denoting the view edge name in mutations. + EdgeView = "view" + // EdgePermission holds the string denoting the permission edge name in mutations. + EdgePermission = "permission" + // Table holds the table name of the viewpermission in the database. + Table = "sys_view_permissions" + // ViewTable is the table that holds the view relation/edge. + ViewTable = "sys_view_permissions" + // ViewInverseTable is the table name for the View entity. + // It exists in this package in order to avoid circular dependency with the "view" package. + ViewInverseTable = "views" + // ViewColumn is the table column denoting the view relation/edge. + ViewColumn = "view_id" + // PermissionTable is the table that holds the permission relation/edge. + PermissionTable = "sys_view_permissions" + // PermissionInverseTable is the table name for the Permission entity. + // It exists in this package in order to avoid circular dependency with the "permission" package. + PermissionInverseTable = "sys_permissions" + // PermissionColumn is the table column denoting the permission relation/edge. + PermissionColumn = "permission_id" +) + +// Columns holds all SQL columns for viewpermission fields. +var Columns = []string{ + FieldID, + FieldCreateAuthor, + FieldUpdateAuthor, + FieldCreateTime, + FieldUpdateTime, + FieldViewID, + FieldPermissionID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateAuthor holds the default value on creation for the "create_author" field. + DefaultCreateAuthor int64 + // DefaultUpdateAuthor holds the default value on creation for the "update_author" field. + DefaultUpdateAuthor int64 + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // ViewIDValidator is a validator for the "view_id" field. It is called by the builders before save. + ViewIDValidator func(int64) error + // PermissionIDValidator is a validator for the "permission_id" field. It is called by the builders before save. + PermissionIDValidator func(int64) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int64) error +) + +// OrderOption defines the ordering options for the ViewPermission queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateAuthor orders the results by the create_author field. +func ByCreateAuthor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateAuthor, opts...).ToFunc() +} + +// ByUpdateAuthor orders the results by the update_author field. +func ByUpdateAuthor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateAuthor, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByViewID orders the results by the view_id field. +func ByViewID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldViewID, opts...).ToFunc() +} + +// ByPermissionID orders the results by the permission_id field. +func ByPermissionID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPermissionID, opts...).ToFunc() +} + +// ByViewField orders the results by view field. +func ByViewField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newViewStep(), sql.OrderByField(field, opts...)) + } +} + +// ByPermissionField orders the results by permission field. +func ByPermissionField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newPermissionStep(), sql.OrderByField(field, opts...)) + } +} +func newViewStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ViewInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ViewTable, ViewColumn), + ) +} +func newPermissionStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(PermissionInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/viewpermission/where.go b/internal/data/entity/ent/viewpermission/where.go new file mode 100644 index 00000000..c04be1bd --- /dev/null +++ b/internal/data/entity/ent/viewpermission/where.go @@ -0,0 +1,367 @@ +// Code generated by ent, DO NOT EDIT. + +package viewpermission + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldLTE(FieldID, id)) +} + +// CreateAuthor applies equality check predicate on the "create_author" field. It's identical to CreateAuthorEQ. +func CreateAuthor(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldCreateAuthor, v)) +} + +// UpdateAuthor applies equality check predicate on the "update_author" field. It's identical to UpdateAuthorEQ. +func UpdateAuthor(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldUpdateAuthor, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldUpdateTime, v)) +} + +// ViewID applies equality check predicate on the "view_id" field. It's identical to ViewIDEQ. +func ViewID(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldViewID, v)) +} + +// PermissionID applies equality check predicate on the "permission_id" field. It's identical to PermissionIDEQ. +func PermissionID(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldPermissionID, v)) +} + +// CreateAuthorEQ applies the EQ predicate on the "create_author" field. +func CreateAuthorEQ(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldCreateAuthor, v)) +} + +// CreateAuthorNEQ applies the NEQ predicate on the "create_author" field. +func CreateAuthorNEQ(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNEQ(FieldCreateAuthor, v)) +} + +// CreateAuthorIn applies the In predicate on the "create_author" field. +func CreateAuthorIn(vs ...int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldIn(FieldCreateAuthor, vs...)) +} + +// CreateAuthorNotIn applies the NotIn predicate on the "create_author" field. +func CreateAuthorNotIn(vs ...int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNotIn(FieldCreateAuthor, vs...)) +} + +// CreateAuthorGT applies the GT predicate on the "create_author" field. +func CreateAuthorGT(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldGT(FieldCreateAuthor, v)) +} + +// CreateAuthorGTE applies the GTE predicate on the "create_author" field. +func CreateAuthorGTE(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldGTE(FieldCreateAuthor, v)) +} + +// CreateAuthorLT applies the LT predicate on the "create_author" field. +func CreateAuthorLT(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldLT(FieldCreateAuthor, v)) +} + +// CreateAuthorLTE applies the LTE predicate on the "create_author" field. +func CreateAuthorLTE(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldLTE(FieldCreateAuthor, v)) +} + +// CreateAuthorIsNil applies the IsNil predicate on the "create_author" field. +func CreateAuthorIsNil() predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldIsNull(FieldCreateAuthor)) +} + +// CreateAuthorNotNil applies the NotNil predicate on the "create_author" field. +func CreateAuthorNotNil() predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNotNull(FieldCreateAuthor)) +} + +// UpdateAuthorEQ applies the EQ predicate on the "update_author" field. +func UpdateAuthorEQ(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldUpdateAuthor, v)) +} + +// UpdateAuthorNEQ applies the NEQ predicate on the "update_author" field. +func UpdateAuthorNEQ(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNEQ(FieldUpdateAuthor, v)) +} + +// UpdateAuthorIn applies the In predicate on the "update_author" field. +func UpdateAuthorIn(vs ...int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldIn(FieldUpdateAuthor, vs...)) +} + +// UpdateAuthorNotIn applies the NotIn predicate on the "update_author" field. +func UpdateAuthorNotIn(vs ...int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNotIn(FieldUpdateAuthor, vs...)) +} + +// UpdateAuthorGT applies the GT predicate on the "update_author" field. +func UpdateAuthorGT(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldGT(FieldUpdateAuthor, v)) +} + +// UpdateAuthorGTE applies the GTE predicate on the "update_author" field. +func UpdateAuthorGTE(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldGTE(FieldUpdateAuthor, v)) +} + +// UpdateAuthorLT applies the LT predicate on the "update_author" field. +func UpdateAuthorLT(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldLT(FieldUpdateAuthor, v)) +} + +// UpdateAuthorLTE applies the LTE predicate on the "update_author" field. +func UpdateAuthorLTE(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldLTE(FieldUpdateAuthor, v)) +} + +// UpdateAuthorIsNil applies the IsNil predicate on the "update_author" field. +func UpdateAuthorIsNil() predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldIsNull(FieldUpdateAuthor)) +} + +// UpdateAuthorNotNil applies the NotNil predicate on the "update_author" field. +func UpdateAuthorNotNil() predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNotNull(FieldUpdateAuthor)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldLTE(FieldUpdateTime, v)) +} + +// ViewIDEQ applies the EQ predicate on the "view_id" field. +func ViewIDEQ(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldViewID, v)) +} + +// ViewIDNEQ applies the NEQ predicate on the "view_id" field. +func ViewIDNEQ(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNEQ(FieldViewID, v)) +} + +// ViewIDIn applies the In predicate on the "view_id" field. +func ViewIDIn(vs ...int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldIn(FieldViewID, vs...)) +} + +// ViewIDNotIn applies the NotIn predicate on the "view_id" field. +func ViewIDNotIn(vs ...int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNotIn(FieldViewID, vs...)) +} + +// PermissionIDEQ applies the EQ predicate on the "permission_id" field. +func PermissionIDEQ(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldEQ(FieldPermissionID, v)) +} + +// PermissionIDNEQ applies the NEQ predicate on the "permission_id" field. +func PermissionIDNEQ(v int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNEQ(FieldPermissionID, v)) +} + +// PermissionIDIn applies the In predicate on the "permission_id" field. +func PermissionIDIn(vs ...int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldIn(FieldPermissionID, vs...)) +} + +// PermissionIDNotIn applies the NotIn predicate on the "permission_id" field. +func PermissionIDNotIn(vs ...int64) predicate.ViewPermission { + return predicate.ViewPermission(sql.FieldNotIn(FieldPermissionID, vs...)) +} + +// HasView applies the HasEdge predicate on the "view" edge. +func HasView() predicate.ViewPermission { + return predicate.ViewPermission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ViewTable, ViewColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasViewWith applies the HasEdge predicate on the "view" edge with a given conditions (other predicates). +func HasViewWith(preds ...predicate.View) predicate.ViewPermission { + return predicate.ViewPermission(func(s *sql.Selector) { + step := newViewStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasPermission applies the HasEdge predicate on the "permission" edge. +func HasPermission() predicate.ViewPermission { + return predicate.ViewPermission(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, PermissionTable, PermissionColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasPermissionWith applies the HasEdge predicate on the "permission" edge with a given conditions (other predicates). +func HasPermissionWith(preds ...predicate.Permission) predicate.ViewPermission { + return predicate.ViewPermission(func(s *sql.Selector) { + step := newPermissionStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ViewPermission) predicate.ViewPermission { + return predicate.ViewPermission(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ViewPermission) predicate.ViewPermission { + return predicate.ViewPermission(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ViewPermission) predicate.ViewPermission { + return predicate.ViewPermission(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/viewpermission_create.go b/internal/data/entity/ent/viewpermission_create.go new file mode 100644 index 00000000..7e107b0e --- /dev/null +++ b/internal/data/entity/ent/viewpermission_create.go @@ -0,0 +1,400 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewPermissionCreate is the builder for creating a ViewPermission entity. +type ViewPermissionCreate struct { + config + mutation *ViewPermissionMutation + hooks []Hook +} + +// SetCreateAuthor sets the "create_author" field. +func (_c *ViewPermissionCreate) SetCreateAuthor(v int64) *ViewPermissionCreate { + _c.mutation.SetCreateAuthor(v) + return _c +} + +// SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. +func (_c *ViewPermissionCreate) SetNillableCreateAuthor(v *int64) *ViewPermissionCreate { + if v != nil { + _c.SetCreateAuthor(*v) + } + return _c +} + +// SetUpdateAuthor sets the "update_author" field. +func (_c *ViewPermissionCreate) SetUpdateAuthor(v int64) *ViewPermissionCreate { + _c.mutation.SetUpdateAuthor(v) + return _c +} + +// SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. +func (_c *ViewPermissionCreate) SetNillableUpdateAuthor(v *int64) *ViewPermissionCreate { + if v != nil { + _c.SetUpdateAuthor(*v) + } + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *ViewPermissionCreate) SetCreateTime(v time.Time) *ViewPermissionCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *ViewPermissionCreate) SetNillableCreateTime(v *time.Time) *ViewPermissionCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *ViewPermissionCreate) SetUpdateTime(v time.Time) *ViewPermissionCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *ViewPermissionCreate) SetNillableUpdateTime(v *time.Time) *ViewPermissionCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetViewID sets the "view_id" field. +func (_c *ViewPermissionCreate) SetViewID(v int64) *ViewPermissionCreate { + _c.mutation.SetViewID(v) + return _c +} + +// SetPermissionID sets the "permission_id" field. +func (_c *ViewPermissionCreate) SetPermissionID(v int64) *ViewPermissionCreate { + _c.mutation.SetPermissionID(v) + return _c +} + +// SetID sets the "id" field. +func (_c *ViewPermissionCreate) SetID(v int64) *ViewPermissionCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *ViewPermissionCreate) SetNillableID(v *int64) *ViewPermissionCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetView sets the "view" edge to the View entity. +func (_c *ViewPermissionCreate) SetView(v *View) *ViewPermissionCreate { + return _c.SetViewID(v.ID) +} + +// SetPermission sets the "permission" edge to the Permission entity. +func (_c *ViewPermissionCreate) SetPermission(v *Permission) *ViewPermissionCreate { + return _c.SetPermissionID(v.ID) +} + +// Mutation returns the ViewPermissionMutation object of the builder. +func (_c *ViewPermissionCreate) Mutation() *ViewPermissionMutation { + return _c.mutation +} + +// Save creates the ViewPermission in the database. +func (_c *ViewPermissionCreate) Save(ctx context.Context) (*ViewPermission, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *ViewPermissionCreate) SaveX(ctx context.Context) *ViewPermission { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ViewPermissionCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ViewPermissionCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *ViewPermissionCreate) defaults() { + if _, ok := _c.mutation.CreateAuthor(); !ok { + v := viewpermission.DefaultCreateAuthor + _c.mutation.SetCreateAuthor(v) + } + if _, ok := _c.mutation.UpdateAuthor(); !ok { + v := viewpermission.DefaultUpdateAuthor + _c.mutation.SetUpdateAuthor(v) + } + if _, ok := _c.mutation.CreateTime(); !ok { + v := viewpermission.DefaultCreateTime() + _c.mutation.SetCreateTime(v) + } + if _, ok := _c.mutation.UpdateTime(); !ok { + v := viewpermission.DefaultUpdateTime() + _c.mutation.SetUpdateTime(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := viewpermission.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *ViewPermissionCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "ViewPermission.create_time"`)} + } + if _, ok := _c.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "ViewPermission.update_time"`)} + } + if _, ok := _c.mutation.ViewID(); !ok { + return &ValidationError{Name: "view_id", err: errors.New(`ent: missing required field "ViewPermission.view_id"`)} + } + if v, ok := _c.mutation.ViewID(); ok { + if err := viewpermission.ViewIDValidator(v); err != nil { + return &ValidationError{Name: "view_id", err: fmt.Errorf(`ent: validator failed for field "ViewPermission.view_id": %w`, err)} + } + } + if _, ok := _c.mutation.PermissionID(); !ok { + return &ValidationError{Name: "permission_id", err: errors.New(`ent: missing required field "ViewPermission.permission_id"`)} + } + if v, ok := _c.mutation.PermissionID(); ok { + if err := viewpermission.PermissionIDValidator(v); err != nil { + return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "ViewPermission.permission_id": %w`, err)} + } + } + if v, ok := _c.mutation.ID(); ok { + if err := viewpermission.IDValidator(v); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "ViewPermission.id": %w`, err)} + } + } + if len(_c.mutation.ViewIDs()) == 0 { + return &ValidationError{Name: "view", err: errors.New(`ent: missing required edge "ViewPermission.view"`)} + } + if len(_c.mutation.PermissionIDs()) == 0 { + return &ValidationError{Name: "permission", err: errors.New(`ent: missing required edge "ViewPermission.permission"`)} + } + return nil +} + +func (_c *ViewPermissionCreate) sqlSave(ctx context.Context) (*ViewPermission, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *ViewPermissionCreate) createSpec() (*ViewPermission, *sqlgraph.CreateSpec) { + var ( + _node = &ViewPermission{config: _c.config} + _spec = sqlgraph.NewCreateSpec(viewpermission.Table, sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreateAuthor(); ok { + _spec.SetField(viewpermission.FieldCreateAuthor, field.TypeInt64, value) + _node.CreateAuthor = value + } + if value, ok := _c.mutation.UpdateAuthor(); ok { + _spec.SetField(viewpermission.FieldUpdateAuthor, field.TypeInt64, value) + _node.UpdateAuthor = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(viewpermission.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(viewpermission.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if nodes := _c.mutation.ViewIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewpermission.ViewTable, + Columns: []string{viewpermission.ViewColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ViewID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.PermissionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewpermission.PermissionTable, + Columns: []string{viewpermission.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.PermissionID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SetViewPermission set the ViewPermission +func (_c *ViewPermissionCreate) SetViewPermission(input *ViewPermission, fields ...string) *ViewPermissionCreate { + m := _c.mutation + if len(fields) == 0 { + fields = viewpermission.Columns + } + _ = m.SetFields(input, fields...) + return _c +} + +// SetViewPermissionWithZero set the ViewPermission +func (_c *ViewPermissionCreate) SetViewPermissionWithZero(input *ViewPermission, fields ...string) *ViewPermissionCreate { + m := _c.mutation + if len(fields) == 0 { + fields = viewpermission.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return _c +} + +// ViewPermissionCreateBulk is the builder for creating many ViewPermission entities in bulk. +type ViewPermissionCreateBulk struct { + config + err error + builders []*ViewPermissionCreate +} + +// Save creates the ViewPermission entities in the database. +func (_c *ViewPermissionCreateBulk) Save(ctx context.Context) ([]*ViewPermission, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*ViewPermission, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ViewPermissionMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *ViewPermissionCreateBulk) SaveX(ctx context.Context) []*ViewPermission { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ViewPermissionCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ViewPermissionCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/data/entity/ent/viewpermission_delete.go b/internal/data/entity/ent/viewpermission_delete.go new file mode 100644 index 00000000..cafe1b2e --- /dev/null +++ b/internal/data/entity/ent/viewpermission_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewPermissionDelete is the builder for deleting a ViewPermission entity. +type ViewPermissionDelete struct { + config + hooks []Hook + mutation *ViewPermissionMutation +} + +// Where appends a list predicates to the ViewPermissionDelete builder. +func (_d *ViewPermissionDelete) Where(ps ...predicate.ViewPermission) *ViewPermissionDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *ViewPermissionDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ViewPermissionDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *ViewPermissionDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(viewpermission.Table, sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// ViewPermissionDeleteOne is the builder for deleting a single ViewPermission entity. +type ViewPermissionDeleteOne struct { + _d *ViewPermissionDelete +} + +// Where appends a list predicates to the ViewPermissionDelete builder. +func (_d *ViewPermissionDeleteOne) Where(ps ...predicate.ViewPermission) *ViewPermissionDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *ViewPermissionDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{viewpermission.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ViewPermissionDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/data/entity/ent/viewpermission_query.go b/internal/data/entity/ent/viewpermission_query.go new file mode 100644 index 00000000..24658ce3 --- /dev/null +++ b/internal/data/entity/ent/viewpermission_query.go @@ -0,0 +1,771 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewPermissionQuery is the builder for querying ViewPermission entities. +type ViewPermissionQuery struct { + config + ctx *QueryContext + order []viewpermission.OrderOption + inters []Interceptor + predicates []predicate.ViewPermission + withView *ViewQuery + withPermission *PermissionQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ViewPermissionQuery builder. +func (_q *ViewPermissionQuery) Where(ps ...predicate.ViewPermission) *ViewPermissionQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *ViewPermissionQuery) Limit(limit int) *ViewPermissionQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *ViewPermissionQuery) Offset(offset int) *ViewPermissionQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *ViewPermissionQuery) Unique(unique bool) *ViewPermissionQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *ViewPermissionQuery) Order(o ...viewpermission.OrderOption) *ViewPermissionQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryView chains the current query on the "view" edge. +func (_q *ViewPermissionQuery) QueryView() *ViewQuery { + query := (&ViewClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(viewpermission.Table, viewpermission.FieldID, selector), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, viewpermission.ViewTable, viewpermission.ViewColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryPermission chains the current query on the "permission" edge. +func (_q *ViewPermissionQuery) QueryPermission() *PermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(viewpermission.Table, viewpermission.FieldID, selector), + sqlgraph.To(permission.Table, permission.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, viewpermission.PermissionTable, viewpermission.PermissionColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ViewPermission entity from the query. +// Returns a *NotFoundError when no ViewPermission was found. +func (_q *ViewPermissionQuery) First(ctx context.Context) (*ViewPermission, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{viewpermission.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *ViewPermissionQuery) FirstX(ctx context.Context) *ViewPermission { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ViewPermission ID from the query. +// Returns a *NotFoundError when no ViewPermission ID was found. +func (_q *ViewPermissionQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{viewpermission.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *ViewPermissionQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ViewPermission entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ViewPermission entity is found. +// Returns a *NotFoundError when no ViewPermission entities are found. +func (_q *ViewPermissionQuery) Only(ctx context.Context) (*ViewPermission, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{viewpermission.Label} + default: + return nil, &NotSingularError{viewpermission.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *ViewPermissionQuery) OnlyX(ctx context.Context) *ViewPermission { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ViewPermission ID in the query. +// Returns a *NotSingularError when more than one ViewPermission ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *ViewPermissionQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{viewpermission.Label} + default: + err = &NotSingularError{viewpermission.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *ViewPermissionQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ViewPermissions. +func (_q *ViewPermissionQuery) All(ctx context.Context) ([]*ViewPermission, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ViewPermission, *ViewPermissionQuery]() + return withInterceptors[[]*ViewPermission](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *ViewPermissionQuery) AllX(ctx context.Context) []*ViewPermission { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ViewPermission IDs. +func (_q *ViewPermissionQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(viewpermission.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *ViewPermissionQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *ViewPermissionQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*ViewPermissionQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *ViewPermissionQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *ViewPermissionQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *ViewPermissionQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ViewPermissionQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *ViewPermissionQuery) Clone() *ViewPermissionQuery { + if _q == nil { + return nil + } + return &ViewPermissionQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]viewpermission.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.ViewPermission{}, _q.predicates...), + withView: _q.withView.Clone(), + withPermission: _q.withPermission.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithView tells the query-builder to eager-load the nodes that are connected to +// the "view" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ViewPermissionQuery) WithView(opts ...func(*ViewQuery)) *ViewPermissionQuery { + query := (&ViewClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withView = query + return _q +} + +// WithPermission tells the query-builder to eager-load the nodes that are connected to +// the "permission" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ViewPermissionQuery) WithPermission(opts ...func(*PermissionQuery)) *ViewPermissionQuery { + query := (&PermissionClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withPermission = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreateAuthor int64 `json:"create_author,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ViewPermission.Query(). +// GroupBy(viewpermission.FieldCreateAuthor). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *ViewPermissionQuery) GroupBy(field string, fields ...string) *ViewPermissionGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &ViewPermissionGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = viewpermission.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreateAuthor int64 `json:"create_author,omitempty"` +// } +// +// client.ViewPermission.Query(). +// Select(viewpermission.FieldCreateAuthor). +// Scan(ctx, &v) +func (_q *ViewPermissionQuery) Select(fields ...string) *ViewPermissionSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &ViewPermissionSelect{ViewPermissionQuery: _q} + sbuild.label = viewpermission.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ViewPermissionSelect configured with the given aggregations. +func (_q *ViewPermissionQuery) Aggregate(fns ...AggregateFunc) *ViewPermissionSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *ViewPermissionQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !viewpermission.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *ViewPermissionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ViewPermission, error) { + var ( + nodes = []*ViewPermission{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withView != nil, + _q.withPermission != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ViewPermission).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ViewPermission{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withView; query != nil { + if err := _q.loadView(ctx, query, nodes, nil, + func(n *ViewPermission, e *View) { n.Edges.View = e }); err != nil { + return nil, err + } + } + if query := _q.withPermission; query != nil { + if err := _q.loadPermission(ctx, query, nodes, nil, + func(n *ViewPermission, e *Permission) { n.Edges.Permission = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *ViewPermissionQuery) loadView(ctx context.Context, query *ViewQuery, nodes []*ViewPermission, init func(*ViewPermission), assign func(*ViewPermission, *View)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*ViewPermission) + for i := range nodes { + fk := nodes[i].ViewID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(view.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "view_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *ViewPermissionQuery) loadPermission(ctx context.Context, query *PermissionQuery, nodes []*ViewPermission, init func(*ViewPermission), assign func(*ViewPermission, *Permission)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*ViewPermission) + for i := range nodes { + fk := nodes[i].PermissionID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(permission.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "permission_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *ViewPermissionQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *ViewPermissionQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(viewpermission.Table, viewpermission.Columns, sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, viewpermission.FieldID) + for i := range fields { + if fields[i] != viewpermission.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withView != nil { + _spec.Node.AddColumnOnce(viewpermission.FieldViewID) + } + if _q.withPermission != nil { + _spec.Node.AddColumnOnce(viewpermission.FieldPermissionID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *ViewPermissionQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(viewpermission.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = viewpermission.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *ViewPermissionQuery) ForUpdate(opts ...sql.LockOption) *ViewPermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *ViewPermissionQuery) ForShare(opts ...sql.LockOption) *ViewPermissionQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *ViewPermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *ViewPermissionSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// CreateAuthor int64 `json:"create_author,omitempty"` +// UpdateAuthor int64 `json:"update_author,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` +// UpdateTime time.Time `json:"update_time,omitempty"` +// ViewID int64 `json:"view_id,omitempty"` +// PermissionID int64 `json:"permission_id,omitempty"` +// } +// +// client.ViewPermission.Query(). +// Omit( +// viewpermission.FieldCreateAuthor, +// viewpermission.FieldUpdateAuthor, +// viewpermission.FieldCreateTime, +// viewpermission.FieldUpdateTime, +// viewpermission.FieldViewID, +// viewpermission.FieldPermissionID, +// ). +// Scan(ctx, &v) +func (vpq *ViewPermissionQuery) Omit(fields ...string) *ViewPermissionSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range viewpermission.Columns { + if _, ok := omits[col]; !ok { + vpq.ctx.Fields = append(vpq.ctx.Fields, col) + } + } + + sbuild := &ViewPermissionSelect{ViewPermissionQuery: vpq} + sbuild.label = viewpermission.Label + sbuild.flds, sbuild.scan = &vpq.ctx.Fields, sbuild.Scan + return sbuild +} + +// ViewPermissionGroupBy is the group-by builder for ViewPermission entities. +type ViewPermissionGroupBy struct { + selector + build *ViewPermissionQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *ViewPermissionGroupBy) Aggregate(fns ...AggregateFunc) *ViewPermissionGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *ViewPermissionGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ViewPermissionQuery, *ViewPermissionGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *ViewPermissionGroupBy) sqlScan(ctx context.Context, root *ViewPermissionQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ViewPermissionSelect is the builder for selecting fields of ViewPermission entities. +type ViewPermissionSelect struct { + *ViewPermissionQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *ViewPermissionSelect) Aggregate(fns ...AggregateFunc) *ViewPermissionSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *ViewPermissionSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ViewPermissionQuery, *ViewPermissionSelect](ctx, _s.ViewPermissionQuery, _s, _s.inters, v) +} + +func (_s *ViewPermissionSelect) sqlScan(ctx context.Context, root *ViewPermissionQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *ViewPermissionSelect) Modify(modifiers ...func(s *sql.Selector)) *ViewPermissionSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/internal/data/entity/ent/viewpermission_update.go b/internal/data/entity/ent/viewpermission_update.go new file mode 100644 index 00000000..fd003244 --- /dev/null +++ b/internal/data/entity/ent/viewpermission_update.go @@ -0,0 +1,694 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewPermissionUpdate is the builder for updating ViewPermission entities. +type ViewPermissionUpdate struct { + config + hooks []Hook + mutation *ViewPermissionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ViewPermissionUpdate builder. +func (_u *ViewPermissionUpdate) Where(ps ...predicate.ViewPermission) *ViewPermissionUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetCreateAuthor sets the "create_author" field. +func (_u *ViewPermissionUpdate) SetCreateAuthor(v int64) *ViewPermissionUpdate { + _u.mutation.ResetCreateAuthor() + _u.mutation.SetCreateAuthor(v) + return _u +} + +// SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. +func (_u *ViewPermissionUpdate) SetNillableCreateAuthor(v *int64) *ViewPermissionUpdate { + if v != nil { + _u.SetCreateAuthor(*v) + } + return _u +} + +// AddCreateAuthor adds value to the "create_author" field. +func (_u *ViewPermissionUpdate) AddCreateAuthor(v int64) *ViewPermissionUpdate { + _u.mutation.AddCreateAuthor(v) + return _u +} + +// ClearCreateAuthor clears the value of the "create_author" field. +func (_u *ViewPermissionUpdate) ClearCreateAuthor() *ViewPermissionUpdate { + _u.mutation.ClearCreateAuthor() + return _u +} + +// SetUpdateAuthor sets the "update_author" field. +func (_u *ViewPermissionUpdate) SetUpdateAuthor(v int64) *ViewPermissionUpdate { + _u.mutation.ResetUpdateAuthor() + _u.mutation.SetUpdateAuthor(v) + return _u +} + +// SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. +func (_u *ViewPermissionUpdate) SetNillableUpdateAuthor(v *int64) *ViewPermissionUpdate { + if v != nil { + _u.SetUpdateAuthor(*v) + } + return _u +} + +// AddUpdateAuthor adds value to the "update_author" field. +func (_u *ViewPermissionUpdate) AddUpdateAuthor(v int64) *ViewPermissionUpdate { + _u.mutation.AddUpdateAuthor(v) + return _u +} + +// ClearUpdateAuthor clears the value of the "update_author" field. +func (_u *ViewPermissionUpdate) ClearUpdateAuthor() *ViewPermissionUpdate { + _u.mutation.ClearUpdateAuthor() + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *ViewPermissionUpdate) SetUpdateTime(v time.Time) *ViewPermissionUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetViewID sets the "view_id" field. +func (_u *ViewPermissionUpdate) SetViewID(v int64) *ViewPermissionUpdate { + _u.mutation.SetViewID(v) + return _u +} + +// SetNillableViewID sets the "view_id" field if the given value is not nil. +func (_u *ViewPermissionUpdate) SetNillableViewID(v *int64) *ViewPermissionUpdate { + if v != nil { + _u.SetViewID(*v) + } + return _u +} + +// SetPermissionID sets the "permission_id" field. +func (_u *ViewPermissionUpdate) SetPermissionID(v int64) *ViewPermissionUpdate { + _u.mutation.SetPermissionID(v) + return _u +} + +// SetNillablePermissionID sets the "permission_id" field if the given value is not nil. +func (_u *ViewPermissionUpdate) SetNillablePermissionID(v *int64) *ViewPermissionUpdate { + if v != nil { + _u.SetPermissionID(*v) + } + return _u +} + +// SetView sets the "view" edge to the View entity. +func (_u *ViewPermissionUpdate) SetView(v *View) *ViewPermissionUpdate { + return _u.SetViewID(v.ID) +} + +// SetPermission sets the "permission" edge to the Permission entity. +func (_u *ViewPermissionUpdate) SetPermission(v *Permission) *ViewPermissionUpdate { + return _u.SetPermissionID(v.ID) +} + +// Mutation returns the ViewPermissionMutation object of the builder. +func (_u *ViewPermissionUpdate) Mutation() *ViewPermissionMutation { + return _u.mutation +} + +// ClearView clears the "view" edge to the View entity. +func (_u *ViewPermissionUpdate) ClearView() *ViewPermissionUpdate { + _u.mutation.ClearView() + return _u +} + +// ClearPermission clears the "permission" edge to the Permission entity. +func (_u *ViewPermissionUpdate) ClearPermission() *ViewPermissionUpdate { + _u.mutation.ClearPermission() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *ViewPermissionUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ViewPermissionUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *ViewPermissionUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ViewPermissionUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ViewPermissionUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := viewpermission.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ViewPermissionUpdate) check() error { + if v, ok := _u.mutation.ViewID(); ok { + if err := viewpermission.ViewIDValidator(v); err != nil { + return &ValidationError{Name: "view_id", err: fmt.Errorf(`ent: validator failed for field "ViewPermission.view_id": %w`, err)} + } + } + if v, ok := _u.mutation.PermissionID(); ok { + if err := viewpermission.PermissionIDValidator(v); err != nil { + return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "ViewPermission.permission_id": %w`, err)} + } + } + if _u.mutation.ViewCleared() && len(_u.mutation.ViewIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ViewPermission.view"`) + } + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ViewPermission.permission"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ViewPermissionUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ViewPermissionUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ViewPermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(viewpermission.Table, viewpermission.Columns, sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.CreateAuthor(); ok { + _spec.SetField(viewpermission.FieldCreateAuthor, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedCreateAuthor(); ok { + _spec.AddField(viewpermission.FieldCreateAuthor, field.TypeInt64, value) + } + if _u.mutation.CreateAuthorCleared() { + _spec.ClearField(viewpermission.FieldCreateAuthor, field.TypeInt64) + } + if value, ok := _u.mutation.UpdateAuthor(); ok { + _spec.SetField(viewpermission.FieldUpdateAuthor, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedUpdateAuthor(); ok { + _spec.AddField(viewpermission.FieldUpdateAuthor, field.TypeInt64, value) + } + if _u.mutation.UpdateAuthorCleared() { + _spec.ClearField(viewpermission.FieldUpdateAuthor, field.TypeInt64) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(viewpermission.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.ViewCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewpermission.ViewTable, + Columns: []string{viewpermission.ViewColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewpermission.ViewTable, + Columns: []string{viewpermission.ViewColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewpermission.PermissionTable, + Columns: []string{viewpermission.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewpermission.PermissionTable, + Columns: []string{viewpermission.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{viewpermission.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// ViewPermissionUpdateOne is the builder for updating a single ViewPermission entity. +type ViewPermissionUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ViewPermissionMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetCreateAuthor sets the "create_author" field. +func (_u *ViewPermissionUpdateOne) SetCreateAuthor(v int64) *ViewPermissionUpdateOne { + _u.mutation.ResetCreateAuthor() + _u.mutation.SetCreateAuthor(v) + return _u +} + +// SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. +func (_u *ViewPermissionUpdateOne) SetNillableCreateAuthor(v *int64) *ViewPermissionUpdateOne { + if v != nil { + _u.SetCreateAuthor(*v) + } + return _u +} + +// AddCreateAuthor adds value to the "create_author" field. +func (_u *ViewPermissionUpdateOne) AddCreateAuthor(v int64) *ViewPermissionUpdateOne { + _u.mutation.AddCreateAuthor(v) + return _u +} + +// ClearCreateAuthor clears the value of the "create_author" field. +func (_u *ViewPermissionUpdateOne) ClearCreateAuthor() *ViewPermissionUpdateOne { + _u.mutation.ClearCreateAuthor() + return _u +} + +// SetUpdateAuthor sets the "update_author" field. +func (_u *ViewPermissionUpdateOne) SetUpdateAuthor(v int64) *ViewPermissionUpdateOne { + _u.mutation.ResetUpdateAuthor() + _u.mutation.SetUpdateAuthor(v) + return _u +} + +// SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. +func (_u *ViewPermissionUpdateOne) SetNillableUpdateAuthor(v *int64) *ViewPermissionUpdateOne { + if v != nil { + _u.SetUpdateAuthor(*v) + } + return _u +} + +// AddUpdateAuthor adds value to the "update_author" field. +func (_u *ViewPermissionUpdateOne) AddUpdateAuthor(v int64) *ViewPermissionUpdateOne { + _u.mutation.AddUpdateAuthor(v) + return _u +} + +// ClearUpdateAuthor clears the value of the "update_author" field. +func (_u *ViewPermissionUpdateOne) ClearUpdateAuthor() *ViewPermissionUpdateOne { + _u.mutation.ClearUpdateAuthor() + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *ViewPermissionUpdateOne) SetUpdateTime(v time.Time) *ViewPermissionUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetViewID sets the "view_id" field. +func (_u *ViewPermissionUpdateOne) SetViewID(v int64) *ViewPermissionUpdateOne { + _u.mutation.SetViewID(v) + return _u +} + +// SetNillableViewID sets the "view_id" field if the given value is not nil. +func (_u *ViewPermissionUpdateOne) SetNillableViewID(v *int64) *ViewPermissionUpdateOne { + if v != nil { + _u.SetViewID(*v) + } + return _u +} + +// SetPermissionID sets the "permission_id" field. +func (_u *ViewPermissionUpdateOne) SetPermissionID(v int64) *ViewPermissionUpdateOne { + _u.mutation.SetPermissionID(v) + return _u +} + +// SetNillablePermissionID sets the "permission_id" field if the given value is not nil. +func (_u *ViewPermissionUpdateOne) SetNillablePermissionID(v *int64) *ViewPermissionUpdateOne { + if v != nil { + _u.SetPermissionID(*v) + } + return _u +} + +// SetView sets the "view" edge to the View entity. +func (_u *ViewPermissionUpdateOne) SetView(v *View) *ViewPermissionUpdateOne { + return _u.SetViewID(v.ID) +} + +// SetPermission sets the "permission" edge to the Permission entity. +func (_u *ViewPermissionUpdateOne) SetPermission(v *Permission) *ViewPermissionUpdateOne { + return _u.SetPermissionID(v.ID) +} + +// Mutation returns the ViewPermissionMutation object of the builder. +func (_u *ViewPermissionUpdateOne) Mutation() *ViewPermissionMutation { + return _u.mutation +} + +// ClearView clears the "view" edge to the View entity. +func (_u *ViewPermissionUpdateOne) ClearView() *ViewPermissionUpdateOne { + _u.mutation.ClearView() + return _u +} + +// ClearPermission clears the "permission" edge to the Permission entity. +func (_u *ViewPermissionUpdateOne) ClearPermission() *ViewPermissionUpdateOne { + _u.mutation.ClearPermission() + return _u +} + +// Where appends a list predicates to the ViewPermissionUpdate builder. +func (_u *ViewPermissionUpdateOne) Where(ps ...predicate.ViewPermission) *ViewPermissionUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *ViewPermissionUpdateOne) Select(field string, fields ...string) *ViewPermissionUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated ViewPermission entity. +func (_u *ViewPermissionUpdateOne) Save(ctx context.Context) (*ViewPermission, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ViewPermissionUpdateOne) SaveX(ctx context.Context) *ViewPermission { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *ViewPermissionUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ViewPermissionUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ViewPermissionUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := viewpermission.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ViewPermissionUpdateOne) check() error { + if v, ok := _u.mutation.ViewID(); ok { + if err := viewpermission.ViewIDValidator(v); err != nil { + return &ValidationError{Name: "view_id", err: fmt.Errorf(`ent: validator failed for field "ViewPermission.view_id": %w`, err)} + } + } + if v, ok := _u.mutation.PermissionID(); ok { + if err := viewpermission.PermissionIDValidator(v); err != nil { + return &ValidationError{Name: "permission_id", err: fmt.Errorf(`ent: validator failed for field "ViewPermission.permission_id": %w`, err)} + } + } + if _u.mutation.ViewCleared() && len(_u.mutation.ViewIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ViewPermission.view"`) + } + if _u.mutation.PermissionCleared() && len(_u.mutation.PermissionIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ViewPermission.permission"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ViewPermissionUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ViewPermissionUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ViewPermissionUpdateOne) sqlSave(ctx context.Context) (_node *ViewPermission, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(viewpermission.Table, viewpermission.Columns, sqlgraph.NewFieldSpec(viewpermission.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ViewPermission.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, viewpermission.FieldID) + for _, f := range fields { + if !viewpermission.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != viewpermission.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.CreateAuthor(); ok { + _spec.SetField(viewpermission.FieldCreateAuthor, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedCreateAuthor(); ok { + _spec.AddField(viewpermission.FieldCreateAuthor, field.TypeInt64, value) + } + if _u.mutation.CreateAuthorCleared() { + _spec.ClearField(viewpermission.FieldCreateAuthor, field.TypeInt64) + } + if value, ok := _u.mutation.UpdateAuthor(); ok { + _spec.SetField(viewpermission.FieldUpdateAuthor, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedUpdateAuthor(); ok { + _spec.AddField(viewpermission.FieldUpdateAuthor, field.TypeInt64, value) + } + if _u.mutation.UpdateAuthorCleared() { + _spec.ClearField(viewpermission.FieldUpdateAuthor, field.TypeInt64) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(viewpermission.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.ViewCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewpermission.ViewTable, + Columns: []string{viewpermission.ViewColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewpermission.ViewTable, + Columns: []string{viewpermission.ViewColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.PermissionCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewpermission.PermissionTable, + Columns: []string{viewpermission.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.PermissionIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewpermission.PermissionTable, + Columns: []string{viewpermission.PermissionColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(permission.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &ViewPermission{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{viewpermission.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} + +// SetViewPermission set the ViewPermission +func (vpu *ViewPermissionUpdate) SetViewPermission(input *ViewPermission, fields ...string) *ViewPermissionUpdate { + m := vpu.mutation + if len(fields) == 0 { + fields = viewpermission.OmitColumns(viewpermission.FieldID) + } + _ = m.SetFields(input, fields...) + return vpu +} + +// SetViewPermissionWithZero set the ViewPermission +func (vpu *ViewPermissionUpdate) SetViewPermissionWithZero(input *ViewPermission, fields ...string) *ViewPermissionUpdate { + m := vpu.mutation + if len(fields) == 0 { + fields = viewpermission.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return vpu +} + +// SetViewPermission set the ViewPermission +func (vpuo *ViewPermissionUpdateOne) SetViewPermission(input *ViewPermission, fields ...string) *ViewPermissionUpdateOne { + m := vpuo.mutation + if len(fields) == 0 { + fields = viewpermission.OmitColumns(viewpermission.FieldID) + } + _ = m.SetFields(input, fields...) + return vpuo +} + +// SetViewPermissionWithZero set the ViewPermission +func (vpuo *ViewPermissionUpdateOne) SetViewPermissionWithZero(input *ViewPermission, fields ...string) *ViewPermissionUpdateOne { + m := vpuo.mutation + if len(fields) == 0 { + fields = viewpermission.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return vpuo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (vpuo *ViewPermissionUpdateOne) Omit(fields ...string) *ViewPermissionUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + vpuo.fields = []string(nil) + for _, col := range viewpermission.Columns { + if _, ok := omits[col]; !ok { + vpuo.fields = append(vpuo.fields, col) + } + } + return vpuo +} diff --git a/internal/data/entity/ent/viewresource.go b/internal/data/entity/ent/viewresource.go new file mode 100644 index 00000000..d0841cb1 --- /dev/null +++ b/internal/data/entity/ent/viewresource.go @@ -0,0 +1,208 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewresource" + "strings" + "time" + + "entgo.io/ent" + "entgo.io/ent/dialect/sql" +) + +// entity.view_resource.table.comment +type ViewResource struct { + config `json:"-"` + // ID of the ent. + // field.primary_key.comment + ID int64 `json:"id,omitempty"` + // create_author.field.comment + CreateAuthor int64 `json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `json:"update_author,omitempty"` + // create_time.field.comment + CreateTime time.Time `json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime time.Time `json:"update_time,omitempty"` + // view_resource.view_id.comment + ViewID int64 `json:"view_id,omitempty"` + // view_resource.resource_id.comment + ResourceID int64 `json:"resource_id,omitempty"` + // Edges holds the relations/edges for other nodes in the graph. + // The values are being populated by the ViewResourceQuery when eager-loading is set. + Edges ViewResourceEdges `json:"edges"` + selectValues sql.SelectValues +} + +// ViewResourceEdges holds the relations/edges for other nodes in the graph. +type ViewResourceEdges struct { + // View holds the value of the view edge. + View *View `json:"view,omitempty"` + // Resource holds the value of the resource edge. + Resource *Resource `json:"resource,omitempty"` + // loadedTypes holds the information for reporting if a + // type was loaded (or requested) in eager-loading or not. + loadedTypes [2]bool +} + +// ViewOrErr returns the View value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ViewResourceEdges) ViewOrErr() (*View, error) { + if e.View != nil { + return e.View, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: view.Label} + } + return nil, &NotLoadedError{edge: "view"} +} + +// ResourceOrErr returns the Resource value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ViewResourceEdges) ResourceOrErr() (*Resource, error) { + if e.Resource != nil { + return e.Resource, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: resource.Label} + } + return nil, &NotLoadedError{edge: "resource"} +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*ViewResource) scanValues(columns []string) ([]any, error) { + values := make([]any, len(columns)) + for i := range columns { + switch columns[i] { + case viewresource.FieldID, viewresource.FieldCreateAuthor, viewresource.FieldUpdateAuthor, viewresource.FieldViewID, viewresource.FieldResourceID: + values[i] = new(sql.NullInt64) + case viewresource.FieldCreateTime, viewresource.FieldUpdateTime: + values[i] = new(sql.NullTime) + default: + values[i] = new(sql.UnknownType) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the ViewResource fields. +func (_m *ViewResource) assignValues(columns []string, values []any) error { + if m, n := len(values), len(columns); m < n { + return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) + } + for i := range columns { + switch columns[i] { + case viewresource.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + _m.ID = int64(value.Int64) + case viewresource.FieldCreateAuthor: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field create_author", values[i]) + } else if value.Valid { + _m.CreateAuthor = value.Int64 + } + case viewresource.FieldUpdateAuthor: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field update_author", values[i]) + } else if value.Valid { + _m.UpdateAuthor = value.Int64 + } + case viewresource.FieldCreateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field create_time", values[i]) + } else if value.Valid { + _m.CreateTime = value.Time + } + case viewresource.FieldUpdateTime: + if value, ok := values[i].(*sql.NullTime); !ok { + return fmt.Errorf("unexpected type %T for field update_time", values[i]) + } else if value.Valid { + _m.UpdateTime = value.Time + } + case viewresource.FieldViewID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field view_id", values[i]) + } else if value.Valid { + _m.ViewID = value.Int64 + } + case viewresource.FieldResourceID: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field resource_id", values[i]) + } else if value.Valid { + _m.ResourceID = value.Int64 + } + default: + _m.selectValues.Set(columns[i], values[i]) + } + } + return nil +} + +// Value returns the ent.Value that was dynamically selected and assigned to the ViewResource. +// This includes values selected through modifiers, order, etc. +func (_m *ViewResource) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) +} + +// QueryView queries the "view" edge of the ViewResource entity. +func (_m *ViewResource) QueryView() *ViewQuery { + return NewViewResourceClient(_m.config).QueryView(_m) +} + +// QueryResource queries the "resource" edge of the ViewResource entity. +func (_m *ViewResource) QueryResource() *ResourceQuery { + return NewViewResourceClient(_m.config).QueryResource(_m) +} + +// Update returns a builder for updating this ViewResource. +// Note that you need to call ViewResource.Unwrap() before calling this method if this ViewResource +// was returned from a transaction, and the transaction was committed or rolled back. +func (_m *ViewResource) Update() *ViewResourceUpdateOne { + return NewViewResourceClient(_m.config).UpdateOne(_m) +} + +// Unwrap unwraps the ViewResource entity that was returned from a transaction after it was closed, +// so that all future queries will be executed through the driver which created the transaction. +func (_m *ViewResource) Unwrap() *ViewResource { + _tx, ok := _m.config.driver.(*txDriver) + if !ok { + panic("ent: ViewResource is not a transactional entity") + } + _m.config.driver = _tx.drv + return _m +} + +// String implements the fmt.Stringer. +func (_m *ViewResource) String() string { + var builder strings.Builder + builder.WriteString("ViewResource(") + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) + builder.WriteString("create_author=") + builder.WriteString(fmt.Sprintf("%v", _m.CreateAuthor)) + builder.WriteString(", ") + builder.WriteString("update_author=") + builder.WriteString(fmt.Sprintf("%v", _m.UpdateAuthor)) + builder.WriteString(", ") + builder.WriteString("create_time=") + builder.WriteString(_m.CreateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("update_time=") + builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) + builder.WriteString(", ") + builder.WriteString("view_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ViewID)) + builder.WriteString(", ") + builder.WriteString("resource_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ResourceID)) + builder.WriteByte(')') + return builder.String() +} + +// ViewResources is a parsable slice of ViewResource. +type ViewResources []*ViewResource diff --git a/internal/data/entity/ent/viewresource/viewresource.go b/internal/data/entity/ent/viewresource/viewresource.go new file mode 100644 index 00000000..c95d09a7 --- /dev/null +++ b/internal/data/entity/ent/viewresource/viewresource.go @@ -0,0 +1,219 @@ +// Code generated by ent, DO NOT EDIT. + +package viewresource + +import ( + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +const ( + // Label holds the string label denoting the viewresource type in the database. + Label = "view_resource" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldCreateAuthor holds the string denoting the create_author field in the database. + FieldCreateAuthor = "create_author" + // FieldUpdateAuthor holds the string denoting the update_author field in the database. + FieldUpdateAuthor = "update_author" + // FieldCreateTime holds the string denoting the create_time field in the database. + FieldCreateTime = "create_time" + // FieldUpdateTime holds the string denoting the update_time field in the database. + FieldUpdateTime = "update_time" + // FieldViewID holds the string denoting the view_id field in the database. + FieldViewID = "view_id" + // FieldResourceID holds the string denoting the resource_id field in the database. + FieldResourceID = "resource_id" + // EdgeView holds the string denoting the view edge name in mutations. + EdgeView = "view" + // EdgeResource holds the string denoting the resource edge name in mutations. + EdgeResource = "resource" + // Table holds the table name of the viewresource in the database. + Table = "sys_view_resources" + // ViewTable is the table that holds the view relation/edge. + ViewTable = "sys_view_resources" + // ViewInverseTable is the table name for the View entity. + // It exists in this package in order to avoid circular dependency with the "view" package. + ViewInverseTable = "views" + // ViewColumn is the table column denoting the view relation/edge. + ViewColumn = "view_id" + // ResourceTable is the table that holds the resource relation/edge. + ResourceTable = "sys_view_resources" + // ResourceInverseTable is the table name for the Resource entity. + // It exists in this package in order to avoid circular dependency with the "resource" package. + ResourceInverseTable = "resources" + // ResourceColumn is the table column denoting the resource relation/edge. + ResourceColumn = "resource_id" +) + +// Columns holds all SQL columns for viewresource fields. +var Columns = []string{ + FieldID, + FieldCreateAuthor, + FieldUpdateAuthor, + FieldCreateTime, + FieldUpdateTime, + FieldViewID, + FieldResourceID, +} + +// ValidColumn reports if the column name is valid (part of the table columns). +func ValidColumn(column string) bool { + for i := range Columns { + if column == Columns[i] { + return true + } + } + return false +} + +var ( + // DefaultCreateAuthor holds the default value on creation for the "create_author" field. + DefaultCreateAuthor int64 + // DefaultUpdateAuthor holds the default value on creation for the "update_author" field. + DefaultUpdateAuthor int64 + // DefaultCreateTime holds the default value on creation for the "create_time" field. + DefaultCreateTime func() time.Time + // DefaultUpdateTime holds the default value on creation for the "update_time" field. + DefaultUpdateTime func() time.Time + // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. + UpdateDefaultUpdateTime func() time.Time + // ViewIDValidator is a validator for the "view_id" field. It is called by the builders before save. + ViewIDValidator func(int64) error + // ResourceIDValidator is a validator for the "resource_id" field. It is called by the builders before save. + ResourceIDValidator func(int64) error + // DefaultID holds the default value on creation for the "id" field. + DefaultID func() int64 + // IDValidator is a validator for the "id" field. It is called by the builders before save. + IDValidator func(int64) error +) + +// OrderOption defines the ordering options for the ViewResource queries. +type OrderOption func(*sql.Selector) + +// ByID orders the results by the id field. +func ByID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldID, opts...).ToFunc() +} + +// ByCreateAuthor orders the results by the create_author field. +func ByCreateAuthor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateAuthor, opts...).ToFunc() +} + +// ByUpdateAuthor orders the results by the update_author field. +func ByUpdateAuthor(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateAuthor, opts...).ToFunc() +} + +// ByCreateTime orders the results by the create_time field. +func ByCreateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldCreateTime, opts...).ToFunc() +} + +// ByUpdateTime orders the results by the update_time field. +func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() +} + +// ByViewID orders the results by the view_id field. +func ByViewID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldViewID, opts...).ToFunc() +} + +// ByResourceID orders the results by the resource_id field. +func ByResourceID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldResourceID, opts...).ToFunc() +} + +// ByViewField orders the results by view field. +func ByViewField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newViewStep(), sql.OrderByField(field, opts...)) + } +} + +// ByResourceField orders the results by resource field. +func ByResourceField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newResourceStep(), sql.OrderByField(field, opts...)) + } +} +func newViewStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ViewInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ViewTable, ViewColumn), + ) +} +func newResourceStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(ResourceInverseTable, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ResourceTable, ResourceColumn), + ) +} + +// SelectColumns returns all selected fields. +func SelectColumns(fields []string) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(fields)) + for _, field := range fields { + if field != FieldID { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +// OmitColumns returns all fields that are not in the list of fields. +func OmitColumns(fields ...string) []string { + // Default removal FieldID + return omitColumns(Columns, fields, true) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumns(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Default removal FieldID + return omitColumns(src, fields, true) +} + +// OmitColumnsWithID returns all fields that are not in the list of fields. +func OmitColumnsWithID(fields ...string) []string { + // Not remove FieldID + return omitColumns(Columns, fields, false) +} + +// OmitCustomColumns returns all fields that are not in the list of fields. +func OmitCustomColumnsWithID(src []string, fields ...string) []string { + if len(src) == 0 { + src = Columns + } + // Not remove FieldID + return omitColumns(src, fields, false) +} + +func omitColumns(src []string, fields []string, omitID bool) []string { + // Default removal FieldID + filteredFields := make([]string, 0, len(src)) + for _, field := range src { + if !(omitID && field == FieldID) && !contains(fields, field) { + filteredFields = append(filteredFields, field) + } + } + return filteredFields +} + +func contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} diff --git a/internal/data/entity/ent/viewresource/where.go b/internal/data/entity/ent/viewresource/where.go new file mode 100644 index 00000000..7cb9839e --- /dev/null +++ b/internal/data/entity/ent/viewresource/where.go @@ -0,0 +1,367 @@ +// Code generated by ent, DO NOT EDIT. + +package viewresource + +import ( + "origadmin/application/admin/internal/data/entity/ent/predicate" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" +) + +// ID filters vertices based on their ID field. +func ID(id int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldID, id)) +} + +// IDEQ applies the EQ predicate on the ID field. +func IDEQ(id int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldID, id)) +} + +// IDNEQ applies the NEQ predicate on the ID field. +func IDNEQ(id int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNEQ(FieldID, id)) +} + +// IDIn applies the In predicate on the ID field. +func IDIn(ids ...int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldIn(FieldID, ids...)) +} + +// IDNotIn applies the NotIn predicate on the ID field. +func IDNotIn(ids ...int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNotIn(FieldID, ids...)) +} + +// IDGT applies the GT predicate on the ID field. +func IDGT(id int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldGT(FieldID, id)) +} + +// IDGTE applies the GTE predicate on the ID field. +func IDGTE(id int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldGTE(FieldID, id)) +} + +// IDLT applies the LT predicate on the ID field. +func IDLT(id int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldLT(FieldID, id)) +} + +// IDLTE applies the LTE predicate on the ID field. +func IDLTE(id int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldLTE(FieldID, id)) +} + +// CreateAuthor applies equality check predicate on the "create_author" field. It's identical to CreateAuthorEQ. +func CreateAuthor(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldCreateAuthor, v)) +} + +// UpdateAuthor applies equality check predicate on the "update_author" field. It's identical to UpdateAuthorEQ. +func UpdateAuthor(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldUpdateAuthor, v)) +} + +// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ. +func CreateTime(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldCreateTime, v)) +} + +// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ. +func UpdateTime(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldUpdateTime, v)) +} + +// ViewID applies equality check predicate on the "view_id" field. It's identical to ViewIDEQ. +func ViewID(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldViewID, v)) +} + +// ResourceID applies equality check predicate on the "resource_id" field. It's identical to ResourceIDEQ. +func ResourceID(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldResourceID, v)) +} + +// CreateAuthorEQ applies the EQ predicate on the "create_author" field. +func CreateAuthorEQ(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldCreateAuthor, v)) +} + +// CreateAuthorNEQ applies the NEQ predicate on the "create_author" field. +func CreateAuthorNEQ(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNEQ(FieldCreateAuthor, v)) +} + +// CreateAuthorIn applies the In predicate on the "create_author" field. +func CreateAuthorIn(vs ...int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldIn(FieldCreateAuthor, vs...)) +} + +// CreateAuthorNotIn applies the NotIn predicate on the "create_author" field. +func CreateAuthorNotIn(vs ...int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNotIn(FieldCreateAuthor, vs...)) +} + +// CreateAuthorGT applies the GT predicate on the "create_author" field. +func CreateAuthorGT(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldGT(FieldCreateAuthor, v)) +} + +// CreateAuthorGTE applies the GTE predicate on the "create_author" field. +func CreateAuthorGTE(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldGTE(FieldCreateAuthor, v)) +} + +// CreateAuthorLT applies the LT predicate on the "create_author" field. +func CreateAuthorLT(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldLT(FieldCreateAuthor, v)) +} + +// CreateAuthorLTE applies the LTE predicate on the "create_author" field. +func CreateAuthorLTE(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldLTE(FieldCreateAuthor, v)) +} + +// CreateAuthorIsNil applies the IsNil predicate on the "create_author" field. +func CreateAuthorIsNil() predicate.ViewResource { + return predicate.ViewResource(sql.FieldIsNull(FieldCreateAuthor)) +} + +// CreateAuthorNotNil applies the NotNil predicate on the "create_author" field. +func CreateAuthorNotNil() predicate.ViewResource { + return predicate.ViewResource(sql.FieldNotNull(FieldCreateAuthor)) +} + +// UpdateAuthorEQ applies the EQ predicate on the "update_author" field. +func UpdateAuthorEQ(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldUpdateAuthor, v)) +} + +// UpdateAuthorNEQ applies the NEQ predicate on the "update_author" field. +func UpdateAuthorNEQ(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNEQ(FieldUpdateAuthor, v)) +} + +// UpdateAuthorIn applies the In predicate on the "update_author" field. +func UpdateAuthorIn(vs ...int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldIn(FieldUpdateAuthor, vs...)) +} + +// UpdateAuthorNotIn applies the NotIn predicate on the "update_author" field. +func UpdateAuthorNotIn(vs ...int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNotIn(FieldUpdateAuthor, vs...)) +} + +// UpdateAuthorGT applies the GT predicate on the "update_author" field. +func UpdateAuthorGT(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldGT(FieldUpdateAuthor, v)) +} + +// UpdateAuthorGTE applies the GTE predicate on the "update_author" field. +func UpdateAuthorGTE(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldGTE(FieldUpdateAuthor, v)) +} + +// UpdateAuthorLT applies the LT predicate on the "update_author" field. +func UpdateAuthorLT(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldLT(FieldUpdateAuthor, v)) +} + +// UpdateAuthorLTE applies the LTE predicate on the "update_author" field. +func UpdateAuthorLTE(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldLTE(FieldUpdateAuthor, v)) +} + +// UpdateAuthorIsNil applies the IsNil predicate on the "update_author" field. +func UpdateAuthorIsNil() predicate.ViewResource { + return predicate.ViewResource(sql.FieldIsNull(FieldUpdateAuthor)) +} + +// UpdateAuthorNotNil applies the NotNil predicate on the "update_author" field. +func UpdateAuthorNotNil() predicate.ViewResource { + return predicate.ViewResource(sql.FieldNotNull(FieldUpdateAuthor)) +} + +// CreateTimeEQ applies the EQ predicate on the "create_time" field. +func CreateTimeEQ(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldCreateTime, v)) +} + +// CreateTimeNEQ applies the NEQ predicate on the "create_time" field. +func CreateTimeNEQ(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNEQ(FieldCreateTime, v)) +} + +// CreateTimeIn applies the In predicate on the "create_time" field. +func CreateTimeIn(vs ...time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldIn(FieldCreateTime, vs...)) +} + +// CreateTimeNotIn applies the NotIn predicate on the "create_time" field. +func CreateTimeNotIn(vs ...time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNotIn(FieldCreateTime, vs...)) +} + +// CreateTimeGT applies the GT predicate on the "create_time" field. +func CreateTimeGT(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldGT(FieldCreateTime, v)) +} + +// CreateTimeGTE applies the GTE predicate on the "create_time" field. +func CreateTimeGTE(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldGTE(FieldCreateTime, v)) +} + +// CreateTimeLT applies the LT predicate on the "create_time" field. +func CreateTimeLT(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldLT(FieldCreateTime, v)) +} + +// CreateTimeLTE applies the LTE predicate on the "create_time" field. +func CreateTimeLTE(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldLTE(FieldCreateTime, v)) +} + +// UpdateTimeEQ applies the EQ predicate on the "update_time" field. +func UpdateTimeEQ(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldUpdateTime, v)) +} + +// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field. +func UpdateTimeNEQ(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNEQ(FieldUpdateTime, v)) +} + +// UpdateTimeIn applies the In predicate on the "update_time" field. +func UpdateTimeIn(vs ...time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field. +func UpdateTimeNotIn(vs ...time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNotIn(FieldUpdateTime, vs...)) +} + +// UpdateTimeGT applies the GT predicate on the "update_time" field. +func UpdateTimeGT(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldGT(FieldUpdateTime, v)) +} + +// UpdateTimeGTE applies the GTE predicate on the "update_time" field. +func UpdateTimeGTE(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldGTE(FieldUpdateTime, v)) +} + +// UpdateTimeLT applies the LT predicate on the "update_time" field. +func UpdateTimeLT(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldLT(FieldUpdateTime, v)) +} + +// UpdateTimeLTE applies the LTE predicate on the "update_time" field. +func UpdateTimeLTE(v time.Time) predicate.ViewResource { + return predicate.ViewResource(sql.FieldLTE(FieldUpdateTime, v)) +} + +// ViewIDEQ applies the EQ predicate on the "view_id" field. +func ViewIDEQ(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldViewID, v)) +} + +// ViewIDNEQ applies the NEQ predicate on the "view_id" field. +func ViewIDNEQ(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNEQ(FieldViewID, v)) +} + +// ViewIDIn applies the In predicate on the "view_id" field. +func ViewIDIn(vs ...int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldIn(FieldViewID, vs...)) +} + +// ViewIDNotIn applies the NotIn predicate on the "view_id" field. +func ViewIDNotIn(vs ...int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNotIn(FieldViewID, vs...)) +} + +// ResourceIDEQ applies the EQ predicate on the "resource_id" field. +func ResourceIDEQ(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldEQ(FieldResourceID, v)) +} + +// ResourceIDNEQ applies the NEQ predicate on the "resource_id" field. +func ResourceIDNEQ(v int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNEQ(FieldResourceID, v)) +} + +// ResourceIDIn applies the In predicate on the "resource_id" field. +func ResourceIDIn(vs ...int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldIn(FieldResourceID, vs...)) +} + +// ResourceIDNotIn applies the NotIn predicate on the "resource_id" field. +func ResourceIDNotIn(vs ...int64) predicate.ViewResource { + return predicate.ViewResource(sql.FieldNotIn(FieldResourceID, vs...)) +} + +// HasView applies the HasEdge predicate on the "view" edge. +func HasView() predicate.ViewResource { + return predicate.ViewResource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ViewTable, ViewColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasViewWith applies the HasEdge predicate on the "view" edge with a given conditions (other predicates). +func HasViewWith(preds ...predicate.View) predicate.ViewResource { + return predicate.ViewResource(func(s *sql.Selector) { + step := newViewStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasResource applies the HasEdge predicate on the "resource" edge. +func HasResource() predicate.ViewResource { + return predicate.ViewResource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, ResourceTable, ResourceColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasResourceWith applies the HasEdge predicate on the "resource" edge with a given conditions (other predicates). +func HasResourceWith(preds ...predicate.Resource) predicate.ViewResource { + return predicate.ViewResource(func(s *sql.Selector) { + step := newResourceStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.ViewResource) predicate.ViewResource { + return predicate.ViewResource(sql.AndPredicates(predicates...)) +} + +// Or groups predicates with the OR operator between them. +func Or(predicates ...predicate.ViewResource) predicate.ViewResource { + return predicate.ViewResource(sql.OrPredicates(predicates...)) +} + +// Not applies the not operator on the given predicate. +func Not(p predicate.ViewResource) predicate.ViewResource { + return predicate.ViewResource(sql.NotPredicates(p)) +} diff --git a/internal/data/entity/ent/viewresource_create.go b/internal/data/entity/ent/viewresource_create.go new file mode 100644 index 00000000..eca55428 --- /dev/null +++ b/internal/data/entity/ent/viewresource_create.go @@ -0,0 +1,400 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewresource" + "time" + + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewResourceCreate is the builder for creating a ViewResource entity. +type ViewResourceCreate struct { + config + mutation *ViewResourceMutation + hooks []Hook +} + +// SetCreateAuthor sets the "create_author" field. +func (_c *ViewResourceCreate) SetCreateAuthor(v int64) *ViewResourceCreate { + _c.mutation.SetCreateAuthor(v) + return _c +} + +// SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. +func (_c *ViewResourceCreate) SetNillableCreateAuthor(v *int64) *ViewResourceCreate { + if v != nil { + _c.SetCreateAuthor(*v) + } + return _c +} + +// SetUpdateAuthor sets the "update_author" field. +func (_c *ViewResourceCreate) SetUpdateAuthor(v int64) *ViewResourceCreate { + _c.mutation.SetUpdateAuthor(v) + return _c +} + +// SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. +func (_c *ViewResourceCreate) SetNillableUpdateAuthor(v *int64) *ViewResourceCreate { + if v != nil { + _c.SetUpdateAuthor(*v) + } + return _c +} + +// SetCreateTime sets the "create_time" field. +func (_c *ViewResourceCreate) SetCreateTime(v time.Time) *ViewResourceCreate { + _c.mutation.SetCreateTime(v) + return _c +} + +// SetNillableCreateTime sets the "create_time" field if the given value is not nil. +func (_c *ViewResourceCreate) SetNillableCreateTime(v *time.Time) *ViewResourceCreate { + if v != nil { + _c.SetCreateTime(*v) + } + return _c +} + +// SetUpdateTime sets the "update_time" field. +func (_c *ViewResourceCreate) SetUpdateTime(v time.Time) *ViewResourceCreate { + _c.mutation.SetUpdateTime(v) + return _c +} + +// SetNillableUpdateTime sets the "update_time" field if the given value is not nil. +func (_c *ViewResourceCreate) SetNillableUpdateTime(v *time.Time) *ViewResourceCreate { + if v != nil { + _c.SetUpdateTime(*v) + } + return _c +} + +// SetViewID sets the "view_id" field. +func (_c *ViewResourceCreate) SetViewID(v int64) *ViewResourceCreate { + _c.mutation.SetViewID(v) + return _c +} + +// SetResourceID sets the "resource_id" field. +func (_c *ViewResourceCreate) SetResourceID(v int64) *ViewResourceCreate { + _c.mutation.SetResourceID(v) + return _c +} + +// SetID sets the "id" field. +func (_c *ViewResourceCreate) SetID(v int64) *ViewResourceCreate { + _c.mutation.SetID(v) + return _c +} + +// SetNillableID sets the "id" field if the given value is not nil. +func (_c *ViewResourceCreate) SetNillableID(v *int64) *ViewResourceCreate { + if v != nil { + _c.SetID(*v) + } + return _c +} + +// SetView sets the "view" edge to the View entity. +func (_c *ViewResourceCreate) SetView(v *View) *ViewResourceCreate { + return _c.SetViewID(v.ID) +} + +// SetResource sets the "resource" edge to the Resource entity. +func (_c *ViewResourceCreate) SetResource(v *Resource) *ViewResourceCreate { + return _c.SetResourceID(v.ID) +} + +// Mutation returns the ViewResourceMutation object of the builder. +func (_c *ViewResourceCreate) Mutation() *ViewResourceMutation { + return _c.mutation +} + +// Save creates the ViewResource in the database. +func (_c *ViewResourceCreate) Save(ctx context.Context) (*ViewResource, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) +} + +// SaveX calls Save and panics if Save returns an error. +func (_c *ViewResourceCreate) SaveX(ctx context.Context) *ViewResource { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ViewResourceCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ViewResourceCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_c *ViewResourceCreate) defaults() { + if _, ok := _c.mutation.CreateAuthor(); !ok { + v := viewresource.DefaultCreateAuthor + _c.mutation.SetCreateAuthor(v) + } + if _, ok := _c.mutation.UpdateAuthor(); !ok { + v := viewresource.DefaultUpdateAuthor + _c.mutation.SetUpdateAuthor(v) + } + if _, ok := _c.mutation.CreateTime(); !ok { + v := viewresource.DefaultCreateTime() + _c.mutation.SetCreateTime(v) + } + if _, ok := _c.mutation.UpdateTime(); !ok { + v := viewresource.DefaultUpdateTime() + _c.mutation.SetUpdateTime(v) + } + if _, ok := _c.mutation.ID(); !ok { + v := viewresource.DefaultID() + _c.mutation.SetID(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_c *ViewResourceCreate) check() error { + if _, ok := _c.mutation.CreateTime(); !ok { + return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "ViewResource.create_time"`)} + } + if _, ok := _c.mutation.UpdateTime(); !ok { + return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "ViewResource.update_time"`)} + } + if _, ok := _c.mutation.ViewID(); !ok { + return &ValidationError{Name: "view_id", err: errors.New(`ent: missing required field "ViewResource.view_id"`)} + } + if v, ok := _c.mutation.ViewID(); ok { + if err := viewresource.ViewIDValidator(v); err != nil { + return &ValidationError{Name: "view_id", err: fmt.Errorf(`ent: validator failed for field "ViewResource.view_id": %w`, err)} + } + } + if _, ok := _c.mutation.ResourceID(); !ok { + return &ValidationError{Name: "resource_id", err: errors.New(`ent: missing required field "ViewResource.resource_id"`)} + } + if v, ok := _c.mutation.ResourceID(); ok { + if err := viewresource.ResourceIDValidator(v); err != nil { + return &ValidationError{Name: "resource_id", err: fmt.Errorf(`ent: validator failed for field "ViewResource.resource_id": %w`, err)} + } + } + if v, ok := _c.mutation.ID(); ok { + if err := viewresource.IDValidator(v); err != nil { + return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "ViewResource.id": %w`, err)} + } + } + if len(_c.mutation.ViewIDs()) == 0 { + return &ValidationError{Name: "view", err: errors.New(`ent: missing required edge "ViewResource.view"`)} + } + if len(_c.mutation.ResourceIDs()) == 0 { + return &ValidationError{Name: "resource", err: errors.New(`ent: missing required edge "ViewResource.resource"`)} + } + return nil +} + +func (_c *ViewResourceCreate) sqlSave(ctx context.Context) (*ViewResource, error) { + if err := _c.check(); err != nil { + return nil, err + } + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int64(id) + } + _c.mutation.id = &_node.ID + _c.mutation.done = true + return _node, nil +} + +func (_c *ViewResourceCreate) createSpec() (*ViewResource, *sqlgraph.CreateSpec) { + var ( + _node = &ViewResource{config: _c.config} + _spec = sqlgraph.NewCreateSpec(viewresource.Table, sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64)) + ) + if id, ok := _c.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := _c.mutation.CreateAuthor(); ok { + _spec.SetField(viewresource.FieldCreateAuthor, field.TypeInt64, value) + _node.CreateAuthor = value + } + if value, ok := _c.mutation.UpdateAuthor(); ok { + _spec.SetField(viewresource.FieldUpdateAuthor, field.TypeInt64, value) + _node.UpdateAuthor = value + } + if value, ok := _c.mutation.CreateTime(); ok { + _spec.SetField(viewresource.FieldCreateTime, field.TypeTime, value) + _node.CreateTime = value + } + if value, ok := _c.mutation.UpdateTime(); ok { + _spec.SetField(viewresource.FieldUpdateTime, field.TypeTime, value) + _node.UpdateTime = value + } + if nodes := _c.mutation.ViewIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewresource.ViewTable, + Columns: []string{viewresource.ViewColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ViewID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ResourceIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewresource.ResourceTable, + Columns: []string{viewresource.ResourceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ResourceID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + return _node, _spec +} + +// SetViewResource set the ViewResource +func (_c *ViewResourceCreate) SetViewResource(input *ViewResource, fields ...string) *ViewResourceCreate { + m := _c.mutation + if len(fields) == 0 { + fields = viewresource.Columns + } + _ = m.SetFields(input, fields...) + return _c +} + +// SetViewResourceWithZero set the ViewResource +func (_c *ViewResourceCreate) SetViewResourceWithZero(input *ViewResource, fields ...string) *ViewResourceCreate { + m := _c.mutation + if len(fields) == 0 { + fields = viewresource.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return _c +} + +// ViewResourceCreateBulk is the builder for creating many ViewResource entities in bulk. +type ViewResourceCreateBulk struct { + config + err error + builders []*ViewResourceCreate +} + +// Save creates the ViewResource entities in the database. +func (_c *ViewResourceCreateBulk) Save(ctx context.Context) ([]*ViewResource, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*ViewResource, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { + func(i int, root context.Context) { + builder := _c.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*ViewResourceMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err := builder.check(); err != nil { + return nil, err + } + builder.mutation = mutation + var err error + nodes[i], specs[i] = builder.createSpec() + if i < len(mutators)-1 { + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) + } else { + spec := &sqlgraph.BatchCreateSpec{Nodes: specs} + // Invoke the actual operation on the latest mutation in the chain. + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { + if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + } + } + if err != nil { + return nil, err + } + mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int64(id) + } + mutation.done = true + return nodes[i], nil + }) + for i := len(builder.hooks) - 1; i >= 0; i-- { + mut = builder.hooks[i](mut) + } + mutators[i] = mut + }(i, ctx) + } + if len(mutators) > 0 { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (_c *ViewResourceCreateBulk) SaveX(ctx context.Context) []*ViewResource { + v, err := _c.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (_c *ViewResourceCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_c *ViewResourceCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/data/entity/ent/viewresource_delete.go b/internal/data/entity/ent/viewresource_delete.go new file mode 100644 index 00000000..79126f51 --- /dev/null +++ b/internal/data/entity/ent/viewresource_delete.go @@ -0,0 +1,88 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/viewresource" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewResourceDelete is the builder for deleting a ViewResource entity. +type ViewResourceDelete struct { + config + hooks []Hook + mutation *ViewResourceMutation +} + +// Where appends a list predicates to the ViewResourceDelete builder. +func (_d *ViewResourceDelete) Where(ps ...predicate.ViewResource) *ViewResourceDelete { + _d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (_d *ViewResourceDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ViewResourceDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (_d *ViewResourceDelete) sqlExec(ctx context.Context) (int, error) { + _spec := sqlgraph.NewDeleteSpec(viewresource.Table, sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64)) + if ps := _d.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + _d.mutation.done = true + return affected, err +} + +// ViewResourceDeleteOne is the builder for deleting a single ViewResource entity. +type ViewResourceDeleteOne struct { + _d *ViewResourceDelete +} + +// Where appends a list predicates to the ViewResourceDelete builder. +func (_d *ViewResourceDeleteOne) Where(ps ...predicate.ViewResource) *ViewResourceDeleteOne { + _d._d.mutation.Where(ps...) + return _d +} + +// Exec executes the deletion query. +func (_d *ViewResourceDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{viewresource.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (_d *ViewResourceDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/internal/data/entity/ent/viewresource_query.go b/internal/data/entity/ent/viewresource_query.go new file mode 100644 index 00000000..a76bcfd5 --- /dev/null +++ b/internal/data/entity/ent/viewresource_query.go @@ -0,0 +1,771 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "math" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewresource" + + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewResourceQuery is the builder for querying ViewResource entities. +type ViewResourceQuery struct { + config + ctx *QueryContext + order []viewresource.OrderOption + inters []Interceptor + predicates []predicate.ViewResource + withView *ViewQuery + withResource *ResourceQuery + modifiers []func(*sql.Selector) + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the ViewResourceQuery builder. +func (_q *ViewResourceQuery) Where(ps ...predicate.ViewResource) *ViewResourceQuery { + _q.predicates = append(_q.predicates, ps...) + return _q +} + +// Limit the number of records to be returned by this query. +func (_q *ViewResourceQuery) Limit(limit int) *ViewResourceQuery { + _q.ctx.Limit = &limit + return _q +} + +// Offset to start from. +func (_q *ViewResourceQuery) Offset(offset int) *ViewResourceQuery { + _q.ctx.Offset = &offset + return _q +} + +// Unique configures the query builder to filter duplicate records on query. +// By default, unique is set to true, and can be disabled using this method. +func (_q *ViewResourceQuery) Unique(unique bool) *ViewResourceQuery { + _q.ctx.Unique = &unique + return _q +} + +// Order specifies how the records should be ordered. +func (_q *ViewResourceQuery) Order(o ...viewresource.OrderOption) *ViewResourceQuery { + _q.order = append(_q.order, o...) + return _q +} + +// QueryView chains the current query on the "view" edge. +func (_q *ViewResourceQuery) QueryView() *ViewQuery { + query := (&ViewClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(viewresource.Table, viewresource.FieldID, selector), + sqlgraph.To(view.Table, view.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, viewresource.ViewTable, viewresource.ViewColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryResource chains the current query on the "resource" edge. +func (_q *ViewResourceQuery) QueryResource() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(viewresource.Table, viewresource.FieldID, selector), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2O, false, viewresource.ResourceTable, viewresource.ResourceColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// First returns the first ViewResource entity from the query. +// Returns a *NotFoundError when no ViewResource was found. +func (_q *ViewResourceQuery) First(ctx context.Context) (*ViewResource, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{viewresource.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (_q *ViewResourceQuery) FirstX(ctx context.Context) *ViewResource { + node, err := _q.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first ViewResource ID from the query. +// Returns a *NotFoundError when no ViewResource ID was found. +func (_q *ViewResourceQuery) FirstID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{viewresource.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (_q *ViewResourceQuery) FirstIDX(ctx context.Context) int64 { + id, err := _q.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single ViewResource entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one ViewResource entity is found. +// Returns a *NotFoundError when no ViewResource entities are found. +func (_q *ViewResourceQuery) Only(ctx context.Context) (*ViewResource, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{viewresource.Label} + default: + return nil, &NotSingularError{viewresource.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (_q *ViewResourceQuery) OnlyX(ctx context.Context) *ViewResource { + node, err := _q.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only ViewResource ID in the query. +// Returns a *NotSingularError when more than one ViewResource ID is found. +// Returns a *NotFoundError when no entities are found. +func (_q *ViewResourceQuery) OnlyID(ctx context.Context) (id int64, err error) { + var ids []int64 + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{viewresource.Label} + default: + err = &NotSingularError{viewresource.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (_q *ViewResourceQuery) OnlyIDX(ctx context.Context) int64 { + id, err := _q.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of ViewResources. +func (_q *ViewResourceQuery) All(ctx context.Context) ([]*ViewResource, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + qr := querierAll[[]*ViewResource, *ViewResourceQuery]() + return withInterceptors[[]*ViewResource](ctx, _q, qr, _q.inters) +} + +// AllX is like All, but panics if an error occurs. +func (_q *ViewResourceQuery) AllX(ctx context.Context) []*ViewResource { + nodes, err := _q.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of ViewResource IDs. +func (_q *ViewResourceQuery) IDs(ctx context.Context) (ids []int64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) + } + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(viewresource.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (_q *ViewResourceQuery) IDsX(ctx context.Context) []int64 { + ids, err := _q.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (_q *ViewResourceQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { + return 0, err + } + return withInterceptors[int](ctx, _q, querierCount[*ViewResourceQuery](), _q.inters) +} + +// CountX is like Count, but panics if an error occurs. +func (_q *ViewResourceQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (_q *ViewResourceQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil + } +} + +// ExistX is like Exist, but panics if an error occurs. +func (_q *ViewResourceQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the ViewResourceQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (_q *ViewResourceQuery) Clone() *ViewResourceQuery { + if _q == nil { + return nil + } + return &ViewResourceQuery{ + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]viewresource.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.ViewResource{}, _q.predicates...), + withView: _q.withView.Clone(), + withResource: _q.withResource.Clone(), + // clone intermediate query. + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), + } +} + +// WithView tells the query-builder to eager-load the nodes that are connected to +// the "view" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ViewResourceQuery) WithView(opts ...func(*ViewQuery)) *ViewResourceQuery { + query := (&ViewClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withView = query + return _q +} + +// WithResource tells the query-builder to eager-load the nodes that are connected to +// the "resource" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ViewResourceQuery) WithResource(opts ...func(*ResourceQuery)) *ViewResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withResource = query + return _q +} + +// GroupBy is used to group vertices by one or more fields/columns. +// It is often used with aggregate functions, like: count, max, mean, min, sum. +// +// Example: +// +// var v []struct { +// CreateAuthor int64 `json:"create_author,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.ViewResource.Query(). +// GroupBy(viewresource.FieldCreateAuthor). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +func (_q *ViewResourceQuery) GroupBy(field string, fields ...string) *ViewResourceGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &ViewResourceGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields + grbuild.label = viewresource.Label + grbuild.scan = grbuild.Scan + return grbuild +} + +// Select allows the selection one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// +// Example: +// +// var v []struct { +// CreateAuthor int64 `json:"create_author,omitempty"` +// } +// +// client.ViewResource.Query(). +// Select(viewresource.FieldCreateAuthor). +// Scan(ctx, &v) +func (_q *ViewResourceQuery) Select(fields ...string) *ViewResourceSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &ViewResourceSelect{ViewResourceQuery: _q} + sbuild.label = viewresource.Label + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan + return sbuild +} + +// Aggregate returns a ViewResourceSelect configured with the given aggregations. +func (_q *ViewResourceQuery) Aggregate(fns ...AggregateFunc) *ViewResourceSelect { + return _q.Select().Aggregate(fns...) +} + +func (_q *ViewResourceQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { + if inter == nil { + return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") + } + if trv, ok := inter.(Traverser); ok { + if err := trv.Traverse(ctx, _q); err != nil { + return err + } + } + } + for _, f := range _q.ctx.Fields { + if !viewresource.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if _q.path != nil { + prev, err := _q.path(ctx) + if err != nil { + return err + } + _q.sql = prev + } + return nil +} + +func (_q *ViewResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*ViewResource, error) { + var ( + nodes = []*ViewResource{} + _spec = _q.querySpec() + loadedTypes = [2]bool{ + _q.withView != nil, + _q.withResource != nil, + } + ) + _spec.ScanValues = func(columns []string) ([]any, error) { + return (*ViewResource).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []any) error { + node := &ViewResource{config: _q.config} + nodes = append(nodes, node) + node.Edges.loadedTypes = loadedTypes + return node.assignValues(columns, values) + } + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + if query := _q.withView; query != nil { + if err := _q.loadView(ctx, query, nodes, nil, + func(n *ViewResource, e *View) { n.Edges.View = e }); err != nil { + return nil, err + } + } + if query := _q.withResource; query != nil { + if err := _q.loadResource(ctx, query, nodes, nil, + func(n *ViewResource, e *Resource) { n.Edges.Resource = e }); err != nil { + return nil, err + } + } + return nodes, nil +} + +func (_q *ViewResourceQuery) loadView(ctx context.Context, query *ViewQuery, nodes []*ViewResource, init func(*ViewResource), assign func(*ViewResource, *View)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*ViewResource) + for i := range nodes { + fk := nodes[i].ViewID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(view.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "view_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *ViewResourceQuery) loadResource(ctx context.Context, query *ResourceQuery, nodes []*ViewResource, init func(*ViewResource), assign func(*ViewResource, *Resource)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*ViewResource) + for i := range nodes { + fk := nodes[i].ResourceID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(resource.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "resource_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} + +func (_q *ViewResourceQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers + } + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique + } + return sqlgraph.CountNodes(ctx, _q.driver, _spec) +} + +func (_q *ViewResourceQuery) querySpec() *sqlgraph.QuerySpec { + _spec := sqlgraph.NewQuerySpec(viewresource.Table, viewresource.Columns, sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64)) + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { + _spec.Unique = *unique + } else if _q.path != nil { + _spec.Unique = true + } + if fields := _q.ctx.Fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, viewresource.FieldID) + for i := range fields { + if fields[i] != viewresource.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + if _q.withView != nil { + _spec.Node.AddColumnOnce(viewresource.FieldViewID) + } + if _q.withResource != nil { + _spec.Node.AddColumnOnce(viewresource.FieldResourceID) + } + } + if ps := _q.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := _q.ctx.Limit; limit != nil { + _spec.Limit = *limit + } + if offset := _q.ctx.Offset; offset != nil { + _spec.Offset = *offset + } + if ps := _q.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (_q *ViewResourceQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) + t1 := builder.Table(viewresource.Table) + columns := _q.ctx.Fields + if len(columns) == 0 { + columns = viewresource.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if _q.sql != nil { + selector = _q.sql + selector.Select(selector.Columns(columns...)...) + } + if _q.ctx.Unique != nil && *_q.ctx.Unique { + selector.Distinct() + } + for _, m := range _q.modifiers { + m(selector) + } + for _, p := range _q.predicates { + p(selector) + } + for _, p := range _q.order { + p(selector) + } + if offset := _q.ctx.Offset; offset != nil { + // limit is mandatory for offset clause. We start + // with default value, and override it below if needed. + selector.Offset(*offset).Limit(math.MaxInt32) + } + if limit := _q.ctx.Limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// ForUpdate locks the selected rows against concurrent updates, and prevent them from being +// updated, deleted or "selected ... for update" by other sessions, until the transaction is +// either committed or rolled-back. +func (_q *ViewResourceQuery) ForUpdate(opts ...sql.LockOption) *ViewResourceQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForUpdate(opts...) + }) + return _q +} + +// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock +// on any rows that are read. Other sessions can read the rows, but cannot modify them +// until your transaction commits. +func (_q *ViewResourceQuery) ForShare(opts ...sql.LockOption) *ViewResourceQuery { + if _q.driver.Dialect() == dialect.Postgres { + _q.Unique(false) + } + _q.modifiers = append(_q.modifiers, func(s *sql.Selector) { + s.ForShare(opts...) + }) + return _q +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_q *ViewResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *ViewResourceSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +// Example: +// +// var v []struct { +// CreateAuthor int64 `json:"create_author,omitempty"` +// UpdateAuthor int64 `json:"update_author,omitempty"` +// CreateTime time.Time `json:"create_time,omitempty"` +// UpdateTime time.Time `json:"update_time,omitempty"` +// ViewID int64 `json:"view_id,omitempty"` +// ResourceID int64 `json:"resource_id,omitempty"` +// } +// +// client.ViewResource.Query(). +// Omit( +// viewresource.FieldCreateAuthor, +// viewresource.FieldUpdateAuthor, +// viewresource.FieldCreateTime, +// viewresource.FieldUpdateTime, +// viewresource.FieldViewID, +// viewresource.FieldResourceID, +// ). +// Scan(ctx, &v) +func (vrq *ViewResourceQuery) Omit(fields ...string) *ViewResourceSelect { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + for _, col := range viewresource.Columns { + if _, ok := omits[col]; !ok { + vrq.ctx.Fields = append(vrq.ctx.Fields, col) + } + } + + sbuild := &ViewResourceSelect{ViewResourceQuery: vrq} + sbuild.label = viewresource.Label + sbuild.flds, sbuild.scan = &vrq.ctx.Fields, sbuild.Scan + return sbuild +} + +// ViewResourceGroupBy is the group-by builder for ViewResource entities. +type ViewResourceGroupBy struct { + selector + build *ViewResourceQuery +} + +// Aggregate adds the given aggregation functions to the group-by query. +func (_g *ViewResourceGroupBy) Aggregate(fns ...AggregateFunc) *ViewResourceGroupBy { + _g.fns = append(_g.fns, fns...) + return _g +} + +// Scan applies the selector query and scans the result into the given value. +func (_g *ViewResourceGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ViewResourceQuery, *ViewResourceGroupBy](ctx, _g.build, _g, _g.build.inters, v) +} + +func (_g *ViewResourceGroupBy) sqlScan(ctx context.Context, root *ViewResourceQuery, v any) error { + selector := root.sqlQuery(ctx).Select() + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { + aggregation = append(aggregation, fn(selector)) + } + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*_g.flds...)...) + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// ViewResourceSelect is the builder for selecting fields of ViewResource entities. +type ViewResourceSelect struct { + *ViewResourceQuery + selector +} + +// Aggregate adds the given aggregation functions to the selector query. +func (_s *ViewResourceSelect) Aggregate(fns ...AggregateFunc) *ViewResourceSelect { + _s.fns = append(_s.fns, fns...) + return _s +} + +// Scan applies the selector query and scans the result into the given value. +func (_s *ViewResourceSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { + return err + } + return scanWithInterceptors[*ViewResourceQuery, *ViewResourceSelect](ctx, _s.ViewResourceQuery, _s, _s.inters, v) +} + +func (_s *ViewResourceSelect) sqlScan(ctx context.Context, root *ViewResourceQuery, v any) error { + selector := root.sqlQuery(ctx) + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { + aggregation = append(aggregation, fn(selector)) + } + switch n := len(*_s.selector.flds); { + case n == 0 && len(aggregation) > 0: + selector.Select(aggregation...) + case n != 0 && len(aggregation) > 0: + selector.AppendSelect(aggregation...) + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := _s.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +// Modify adds a query modifier for attaching custom logic to queries. +func (_s *ViewResourceSelect) Modify(modifiers ...func(s *sql.Selector)) *ViewResourceSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s +} diff --git a/internal/data/entity/ent/viewresource_update.go b/internal/data/entity/ent/viewresource_update.go new file mode 100644 index 00000000..8ebe66a3 --- /dev/null +++ b/internal/data/entity/ent/viewresource_update.go @@ -0,0 +1,694 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/entity/ent/viewresource" + "time" + + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/schema/field" +) + +// ViewResourceUpdate is the builder for updating ViewResource entities. +type ViewResourceUpdate struct { + config + hooks []Hook + mutation *ViewResourceMutation + modifiers []func(*sql.UpdateBuilder) +} + +// Where appends a list predicates to the ViewResourceUpdate builder. +func (_u *ViewResourceUpdate) Where(ps ...predicate.ViewResource) *ViewResourceUpdate { + _u.mutation.Where(ps...) + return _u +} + +// SetCreateAuthor sets the "create_author" field. +func (_u *ViewResourceUpdate) SetCreateAuthor(v int64) *ViewResourceUpdate { + _u.mutation.ResetCreateAuthor() + _u.mutation.SetCreateAuthor(v) + return _u +} + +// SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. +func (_u *ViewResourceUpdate) SetNillableCreateAuthor(v *int64) *ViewResourceUpdate { + if v != nil { + _u.SetCreateAuthor(*v) + } + return _u +} + +// AddCreateAuthor adds value to the "create_author" field. +func (_u *ViewResourceUpdate) AddCreateAuthor(v int64) *ViewResourceUpdate { + _u.mutation.AddCreateAuthor(v) + return _u +} + +// ClearCreateAuthor clears the value of the "create_author" field. +func (_u *ViewResourceUpdate) ClearCreateAuthor() *ViewResourceUpdate { + _u.mutation.ClearCreateAuthor() + return _u +} + +// SetUpdateAuthor sets the "update_author" field. +func (_u *ViewResourceUpdate) SetUpdateAuthor(v int64) *ViewResourceUpdate { + _u.mutation.ResetUpdateAuthor() + _u.mutation.SetUpdateAuthor(v) + return _u +} + +// SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. +func (_u *ViewResourceUpdate) SetNillableUpdateAuthor(v *int64) *ViewResourceUpdate { + if v != nil { + _u.SetUpdateAuthor(*v) + } + return _u +} + +// AddUpdateAuthor adds value to the "update_author" field. +func (_u *ViewResourceUpdate) AddUpdateAuthor(v int64) *ViewResourceUpdate { + _u.mutation.AddUpdateAuthor(v) + return _u +} + +// ClearUpdateAuthor clears the value of the "update_author" field. +func (_u *ViewResourceUpdate) ClearUpdateAuthor() *ViewResourceUpdate { + _u.mutation.ClearUpdateAuthor() + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *ViewResourceUpdate) SetUpdateTime(v time.Time) *ViewResourceUpdate { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetViewID sets the "view_id" field. +func (_u *ViewResourceUpdate) SetViewID(v int64) *ViewResourceUpdate { + _u.mutation.SetViewID(v) + return _u +} + +// SetNillableViewID sets the "view_id" field if the given value is not nil. +func (_u *ViewResourceUpdate) SetNillableViewID(v *int64) *ViewResourceUpdate { + if v != nil { + _u.SetViewID(*v) + } + return _u +} + +// SetResourceID sets the "resource_id" field. +func (_u *ViewResourceUpdate) SetResourceID(v int64) *ViewResourceUpdate { + _u.mutation.SetResourceID(v) + return _u +} + +// SetNillableResourceID sets the "resource_id" field if the given value is not nil. +func (_u *ViewResourceUpdate) SetNillableResourceID(v *int64) *ViewResourceUpdate { + if v != nil { + _u.SetResourceID(*v) + } + return _u +} + +// SetView sets the "view" edge to the View entity. +func (_u *ViewResourceUpdate) SetView(v *View) *ViewResourceUpdate { + return _u.SetViewID(v.ID) +} + +// SetResource sets the "resource" edge to the Resource entity. +func (_u *ViewResourceUpdate) SetResource(v *Resource) *ViewResourceUpdate { + return _u.SetResourceID(v.ID) +} + +// Mutation returns the ViewResourceMutation object of the builder. +func (_u *ViewResourceUpdate) Mutation() *ViewResourceMutation { + return _u.mutation +} + +// ClearView clears the "view" edge to the View entity. +func (_u *ViewResourceUpdate) ClearView() *ViewResourceUpdate { + _u.mutation.ClearView() + return _u +} + +// ClearResource clears the "resource" edge to the Resource entity. +func (_u *ViewResourceUpdate) ClearResource() *ViewResourceUpdate { + _u.mutation.ClearResource() + return _u +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (_u *ViewResourceUpdate) Save(ctx context.Context) (int, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ViewResourceUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (_u *ViewResourceUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ViewResourceUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ViewResourceUpdate) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := viewresource.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ViewResourceUpdate) check() error { + if v, ok := _u.mutation.ViewID(); ok { + if err := viewresource.ViewIDValidator(v); err != nil { + return &ValidationError{Name: "view_id", err: fmt.Errorf(`ent: validator failed for field "ViewResource.view_id": %w`, err)} + } + } + if v, ok := _u.mutation.ResourceID(); ok { + if err := viewresource.ResourceIDValidator(v); err != nil { + return &ValidationError{Name: "resource_id", err: fmt.Errorf(`ent: validator failed for field "ViewResource.resource_id": %w`, err)} + } + } + if _u.mutation.ViewCleared() && len(_u.mutation.ViewIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ViewResource.view"`) + } + if _u.mutation.ResourceCleared() && len(_u.mutation.ResourceIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ViewResource.resource"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ViewResourceUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ViewResourceUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ViewResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(viewresource.Table, viewresource.Columns, sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64)) + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.CreateAuthor(); ok { + _spec.SetField(viewresource.FieldCreateAuthor, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedCreateAuthor(); ok { + _spec.AddField(viewresource.FieldCreateAuthor, field.TypeInt64, value) + } + if _u.mutation.CreateAuthorCleared() { + _spec.ClearField(viewresource.FieldCreateAuthor, field.TypeInt64) + } + if value, ok := _u.mutation.UpdateAuthor(); ok { + _spec.SetField(viewresource.FieldUpdateAuthor, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedUpdateAuthor(); ok { + _spec.AddField(viewresource.FieldUpdateAuthor, field.TypeInt64, value) + } + if _u.mutation.UpdateAuthorCleared() { + _spec.ClearField(viewresource.FieldUpdateAuthor, field.TypeInt64) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(viewresource.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.ViewCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewresource.ViewTable, + Columns: []string{viewresource.ViewColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewresource.ViewTable, + Columns: []string{viewresource.ViewColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ResourceCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewresource.ResourceTable, + Columns: []string{viewresource.ResourceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ResourceIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewresource.ResourceTable, + Columns: []string{viewresource.ResourceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{viewresource.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + _u.mutation.done = true + return _node, nil +} + +// ViewResourceUpdateOne is the builder for updating a single ViewResource entity. +type ViewResourceUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ViewResourceMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetCreateAuthor sets the "create_author" field. +func (_u *ViewResourceUpdateOne) SetCreateAuthor(v int64) *ViewResourceUpdateOne { + _u.mutation.ResetCreateAuthor() + _u.mutation.SetCreateAuthor(v) + return _u +} + +// SetNillableCreateAuthor sets the "create_author" field if the given value is not nil. +func (_u *ViewResourceUpdateOne) SetNillableCreateAuthor(v *int64) *ViewResourceUpdateOne { + if v != nil { + _u.SetCreateAuthor(*v) + } + return _u +} + +// AddCreateAuthor adds value to the "create_author" field. +func (_u *ViewResourceUpdateOne) AddCreateAuthor(v int64) *ViewResourceUpdateOne { + _u.mutation.AddCreateAuthor(v) + return _u +} + +// ClearCreateAuthor clears the value of the "create_author" field. +func (_u *ViewResourceUpdateOne) ClearCreateAuthor() *ViewResourceUpdateOne { + _u.mutation.ClearCreateAuthor() + return _u +} + +// SetUpdateAuthor sets the "update_author" field. +func (_u *ViewResourceUpdateOne) SetUpdateAuthor(v int64) *ViewResourceUpdateOne { + _u.mutation.ResetUpdateAuthor() + _u.mutation.SetUpdateAuthor(v) + return _u +} + +// SetNillableUpdateAuthor sets the "update_author" field if the given value is not nil. +func (_u *ViewResourceUpdateOne) SetNillableUpdateAuthor(v *int64) *ViewResourceUpdateOne { + if v != nil { + _u.SetUpdateAuthor(*v) + } + return _u +} + +// AddUpdateAuthor adds value to the "update_author" field. +func (_u *ViewResourceUpdateOne) AddUpdateAuthor(v int64) *ViewResourceUpdateOne { + _u.mutation.AddUpdateAuthor(v) + return _u +} + +// ClearUpdateAuthor clears the value of the "update_author" field. +func (_u *ViewResourceUpdateOne) ClearUpdateAuthor() *ViewResourceUpdateOne { + _u.mutation.ClearUpdateAuthor() + return _u +} + +// SetUpdateTime sets the "update_time" field. +func (_u *ViewResourceUpdateOne) SetUpdateTime(v time.Time) *ViewResourceUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetViewID sets the "view_id" field. +func (_u *ViewResourceUpdateOne) SetViewID(v int64) *ViewResourceUpdateOne { + _u.mutation.SetViewID(v) + return _u +} + +// SetNillableViewID sets the "view_id" field if the given value is not nil. +func (_u *ViewResourceUpdateOne) SetNillableViewID(v *int64) *ViewResourceUpdateOne { + if v != nil { + _u.SetViewID(*v) + } + return _u +} + +// SetResourceID sets the "resource_id" field. +func (_u *ViewResourceUpdateOne) SetResourceID(v int64) *ViewResourceUpdateOne { + _u.mutation.SetResourceID(v) + return _u +} + +// SetNillableResourceID sets the "resource_id" field if the given value is not nil. +func (_u *ViewResourceUpdateOne) SetNillableResourceID(v *int64) *ViewResourceUpdateOne { + if v != nil { + _u.SetResourceID(*v) + } + return _u +} + +// SetView sets the "view" edge to the View entity. +func (_u *ViewResourceUpdateOne) SetView(v *View) *ViewResourceUpdateOne { + return _u.SetViewID(v.ID) +} + +// SetResource sets the "resource" edge to the Resource entity. +func (_u *ViewResourceUpdateOne) SetResource(v *Resource) *ViewResourceUpdateOne { + return _u.SetResourceID(v.ID) +} + +// Mutation returns the ViewResourceMutation object of the builder. +func (_u *ViewResourceUpdateOne) Mutation() *ViewResourceMutation { + return _u.mutation +} + +// ClearView clears the "view" edge to the View entity. +func (_u *ViewResourceUpdateOne) ClearView() *ViewResourceUpdateOne { + _u.mutation.ClearView() + return _u +} + +// ClearResource clears the "resource" edge to the Resource entity. +func (_u *ViewResourceUpdateOne) ClearResource() *ViewResourceUpdateOne { + _u.mutation.ClearResource() + return _u +} + +// Where appends a list predicates to the ViewResourceUpdate builder. +func (_u *ViewResourceUpdateOne) Where(ps ...predicate.ViewResource) *ViewResourceUpdateOne { + _u.mutation.Where(ps...) + return _u +} + +// Select allows selecting one or more fields (columns) of the returned entity. +// The default is selecting all fields defined in the entity schema. +func (_u *ViewResourceUpdateOne) Select(field string, fields ...string) *ViewResourceUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u +} + +// Save executes the query and returns the updated ViewResource entity. +func (_u *ViewResourceUpdateOne) Save(ctx context.Context) (*ViewResource, error) { + _u.defaults() + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) +} + +// SaveX is like Save, but panics if an error occurs. +func (_u *ViewResourceUpdateOne) SaveX(ctx context.Context) *ViewResource { + node, err := _u.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (_u *ViewResourceUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (_u *ViewResourceUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (_u *ViewResourceUpdateOne) defaults() { + if _, ok := _u.mutation.UpdateTime(); !ok { + v := viewresource.UpdateDefaultUpdateTime() + _u.mutation.SetUpdateTime(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (_u *ViewResourceUpdateOne) check() error { + if v, ok := _u.mutation.ViewID(); ok { + if err := viewresource.ViewIDValidator(v); err != nil { + return &ValidationError{Name: "view_id", err: fmt.Errorf(`ent: validator failed for field "ViewResource.view_id": %w`, err)} + } + } + if v, ok := _u.mutation.ResourceID(); ok { + if err := viewresource.ResourceIDValidator(v); err != nil { + return &ValidationError{Name: "resource_id", err: fmt.Errorf(`ent: validator failed for field "ViewResource.resource_id": %w`, err)} + } + } + if _u.mutation.ViewCleared() && len(_u.mutation.ViewIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ViewResource.view"`) + } + if _u.mutation.ResourceCleared() && len(_u.mutation.ResourceIDs()) > 0 { + return errors.New(`ent: clearing a required unique edge "ViewResource.resource"`) + } + return nil +} + +// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. +func (_u *ViewResourceUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *ViewResourceUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u +} + +func (_u *ViewResourceUpdateOne) sqlSave(ctx context.Context) (_node *ViewResource, err error) { + if err := _u.check(); err != nil { + return _node, err + } + _spec := sqlgraph.NewUpdateSpec(viewresource.Table, viewresource.Columns, sqlgraph.NewFieldSpec(viewresource.FieldID, field.TypeInt64)) + id, ok := _u.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "ViewResource.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := _u.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, viewresource.FieldID) + for _, f := range fields { + if !viewresource.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != viewresource.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := _u.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := _u.mutation.CreateAuthor(); ok { + _spec.SetField(viewresource.FieldCreateAuthor, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedCreateAuthor(); ok { + _spec.AddField(viewresource.FieldCreateAuthor, field.TypeInt64, value) + } + if _u.mutation.CreateAuthorCleared() { + _spec.ClearField(viewresource.FieldCreateAuthor, field.TypeInt64) + } + if value, ok := _u.mutation.UpdateAuthor(); ok { + _spec.SetField(viewresource.FieldUpdateAuthor, field.TypeInt64, value) + } + if value, ok := _u.mutation.AddedUpdateAuthor(); ok { + _spec.AddField(viewresource.FieldUpdateAuthor, field.TypeInt64, value) + } + if _u.mutation.UpdateAuthorCleared() { + _spec.ClearField(viewresource.FieldUpdateAuthor, field.TypeInt64) + } + if value, ok := _u.mutation.UpdateTime(); ok { + _spec.SetField(viewresource.FieldUpdateTime, field.TypeTime, value) + } + if _u.mutation.ViewCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewresource.ViewTable, + Columns: []string{viewresource.ViewColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ViewIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewresource.ViewTable, + Columns: []string{viewresource.ViewColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(view.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ResourceCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewresource.ResourceTable, + Columns: []string{viewresource.ResourceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ResourceIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: false, + Table: viewresource.ResourceTable, + Columns: []string{viewresource.ResourceColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + _spec.AddModifiers(_u.modifiers...) + _node = &ViewResource{config: _u.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{viewresource.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + _u.mutation.done = true + return _node, nil +} + +// SetViewResource set the ViewResource +func (vru *ViewResourceUpdate) SetViewResource(input *ViewResource, fields ...string) *ViewResourceUpdate { + m := vru.mutation + if len(fields) == 0 { + fields = viewresource.OmitColumns(viewresource.FieldID) + } + _ = m.SetFields(input, fields...) + return vru +} + +// SetViewResourceWithZero set the ViewResource +func (vru *ViewResourceUpdate) SetViewResourceWithZero(input *ViewResource, fields ...string) *ViewResourceUpdate { + m := vru.mutation + if len(fields) == 0 { + fields = viewresource.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return vru +} + +// SetViewResource set the ViewResource +func (vruo *ViewResourceUpdateOne) SetViewResource(input *ViewResource, fields ...string) *ViewResourceUpdateOne { + m := vruo.mutation + if len(fields) == 0 { + fields = viewresource.OmitColumns(viewresource.FieldID) + } + _ = m.SetFields(input, fields...) + return vruo +} + +// SetViewResourceWithZero set the ViewResource +func (vruo *ViewResourceUpdateOne) SetViewResourceWithZero(input *ViewResource, fields ...string) *ViewResourceUpdateOne { + m := vruo.mutation + if len(fields) == 0 { + fields = viewresource.Columns + } + _ = m.SetFieldsWithZero(input, fields...) + return vruo +} + +// Omit allows the unselect one or more fields/columns for the given query, +// instead of selecting all fields in the entity. +func (vruo *ViewResourceUpdateOne) Omit(fields ...string) *ViewResourceUpdateOne { + omits := make(map[string]struct{}, len(fields)) + for i := range fields { + omits[fields[i]] = struct{}{} + } + vruo.fields = []string(nil) + for _, col := range viewresource.Columns { + if _, ok := omits[col]; !ok { + vruo.fields = append(vruo.fields, col) + } + } + return vruo +} diff --git a/internal/data/enums/role.go b/internal/data/enums/role.go new file mode 100644 index 00000000..5b1d1763 --- /dev/null +++ b/internal/data/enums/role.go @@ -0,0 +1,23 @@ +package enums + +// RoleType defines the type of a role. +type RoleType int8 + +const ( + // RoleTypeSystem indicates a system-level role (e.g., Super Admin) that cannot be deleted. + RoleTypeSystem RoleType = 1 + // RoleTypeUser indicates a user-defined role (e.g., general user, operator). + RoleTypeUser RoleType = 2 +) + +// String returns the string representation of the role type. +func (rt RoleType) String() string { + switch rt { + case RoleTypeSystem: + return "system" + case RoleTypeUser: + return "user" + default: + return "unknown" + } +} diff --git a/internal/data/enums/user.go b/internal/data/enums/user.go new file mode 100644 index 00000000..0c9cf23d --- /dev/null +++ b/internal/data/enums/user.go @@ -0,0 +1,15 @@ +package enums + +// Gender defines the gender of a user. +type Gender string + +const ( + GenderMale Gender = "male" + GenderFemale Gender = "female" + GenderUnknown Gender = "unknown" +) + +// String returns the string representation of the gender. +func (g Gender) String() string { + return string(g) +} diff --git a/internal/features/system/dal/user.go b/internal/features/system/dal/user.go index 894a57af..5de322a4 100644 --- a/internal/features/system/dal/user.go +++ b/internal/features/system/dal/user.go @@ -57,7 +57,6 @@ func (r *userRepo) Create(ctx context.Context, u *types.User, password string, o entUser.EncryptedPassword = password } create := r.db.User(ctx).Create().SetUser(entUser) - saved, err := create.Save(ctx) if err != nil { return nil, err diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index 90117e48..efb34242 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -2,6 +2,7 @@ package dto import ( "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/enums" ) //go:generate abgen -debug . diff --git a/internal/features/system/dto/resource_type.go b/internal/features/system/dto/resource_type.go deleted file mode 100644 index f3b265fa..00000000 --- a/internal/features/system/dto/resource_type.go +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto implements the functions, types, and interfaces for the module. -package dto - -import ( - "origadmin/application/admin/internal/data/entity/ent/schema" -) - -const ( - ResourceTypeRoot = schema.ResourceTypeRoot - ResourceTypeGroup = schema.ResourceTypeGroup - ResourceTypeMenu = schema.ResourceTypeMenu - ResourceTypePage = schema.ResourceTypePage - ResourceTypeButton = schema.ResourceTypeButton - ResourceTypeAPI = schema.ResourceTypeAPI - ResourceTypeRedirect = schema.ResourceTypeRedirect - ResourceTypeUnknown = schema.ResourceTypeUnknown -) - -// ResourceTypeName returns the name of the resource type -func ResourceTypeName(str string) string { - switch str { - case ResourceTypeMenu: - return "Menu" - case ResourceTypePage: - return "Page" - case ResourceTypeButton: - return "Button" - case ResourceTypeAPI: - return "API" - case ResourceTypeRedirect: - return "Redirect" - case ResourceTypeRoot: - return "ROOT" - case ResourceTypeGroup: - return "Group" - default: - return "Unknown" - } -} - -// ResourceTypeCode returns the code of the resource type -func ResourceTypeCode(s string) string { - switch s { - case "Menu": - return ResourceTypeMenu - case "Page": - return ResourceTypePage - case "Button": - return ResourceTypeButton - case "API": - return ResourceTypeAPI - case "Redirect": - return ResourceTypeRedirect - case "ROOT": - return ResourceTypeRoot - case "Group": - return ResourceTypeGroup - default: - return ResourceTypeUnknown - } -} diff --git a/internal/features/system/dto/view_type.go b/internal/features/system/dto/view_type.go new file mode 100644 index 00000000..37bb79ee --- /dev/null +++ b/internal/features/system/dto/view_type.go @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto implements the functions, types, and interfaces for the module. +package dto + +import ( + "strings" + + "origadmin/application/admin/internal/data/entity/ent/view" +) + +const ( + ViewTypeRoot = view.TypeT + ViewTypeGroup = view.TypeG + ViewTypeMenu = view.TypeM + ViewTypeLink = view.TypeL + ViewTypePage = view.TypeP + ViewTypeButton = view.TypeB + ViewTypeElement = view.TypeE + ViewTypeRedirect = view.TypeR + ViewTypeUnknown = view.TypeU +) + +type ViewType = view.Type + +// ViewTypeName returns the name of the resource type +func ViewTypeName(str ViewType) string { + switch str { + case ViewTypeMenu: + return "Menu" + case ViewTypePage: + return "Page" + case ViewTypeButton: + return "Button" + case ViewTypeElement: + return "Element" + case ViewTypeRedirect: + return "Redirect" + case ViewTypeRoot: + return "Root" + case ViewTypeGroup: + return "Group" + case ViewTypeLink: + return "Link" + default: + return "Unknown" + } +} + +// ViewTypeCode returns the code of the resource type +func ViewTypeCode(s string) ViewType { + switch strings.ToLower(s) { + case "menu": + return ViewTypeMenu + case "page": + return ViewTypePage + case "button": + return ViewTypeButton + case "redirect": + return ViewTypeRedirect + case "root": + return ViewTypeRoot + case "group": + return ViewTypeGroup + case "link": + return ViewTypeLink + case "element": + return ViewTypeElement + default: + return ViewTypeUnknown + } +} diff --git a/internal/helpers/db/coalesce.go b/internal/helpers/db/coalesce.go new file mode 100644 index 00000000..9919d857 --- /dev/null +++ b/internal/helpers/db/coalesce.go @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package db provides common helpers for database operations, +// currently focusing on query construction for Ent. +package db + +import ( + "entgo.io/ent/dialect/sql" +) + +// CoalesceMax returns the max value of the given field. +func CoalesceMax(field string) func(selector *sql.Selector) string { + return func(selector *sql.Selector) string { + fn := sql.Func{} + fn.Append(func(builder *sql.Builder) { + builder.WriteString("COALESCE") + builder.Wrap(func(b *sql.Builder) { + b.Ident(sql.Max(selector.C(field))).Comma().WriteByte('0') + }) + }) + return fn.String() + } +} diff --git a/internal/helpers/db/db.go b/internal/helpers/db/db.go index f83608ba..77af7151 100644 --- a/internal/helpers/db/db.go +++ b/internal/helpers/db/db.go @@ -2,102 +2,9 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package db implements the functions, types, and interfaces for the module. +// Package db provides common helpers for database operations, +// currently focusing on query construction for Ent. package db -import ( - "context" - "strings" - - "entgo.io/ent/dialect/sql" - - "origadmin/application/admin/internal/helpers/repo" -) - -type Paginator[T any] interface { - Limit(int) T - Offset(int) T -} - -type QueryCounter[T any] interface { - Count(ctx context.Context) (int, error) -} - -type FieldSelector[T any] interface { - Select(...string) T - Omit(...string) T -} - -func Query[P Paginator[P]](query P, in repo.PaginatingRequest, paging bool) P { - if !paging { - return QueryNoPage(query, in) - } - return QueryPage(query, in) -} - -func QueryNoPage[P Paginator[P]](query P, in repo.PaginatingRequest) P { - pageSize := in.GetPageSize() - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - return query -} - -func handleTokenPagination[P Paginator[P]](query P, token string) P { - // TODO: Implement cursor pagination logic - // Example pseudocode: - // decodedToken := decodeToken(token) - // query = query.Where(...).Order(...).Limit(...) - return query -} - -func QueryPage[P Paginator[P]](query P, in repo.PaginatingRequest) P { - pageSize := in.GetPageSize() - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - token := in.GetPageToken() - if token != "" { - return handleTokenPagination(query, token) - } - current := in.GetPage() - if current > 0 { - return query.Offset(int((current - 1) * pageSize)) - } - - return query -} - -func PageCount[Q QueryCounter[Q]](ctx context.Context, query Q) (int32, error) { - count, err := query.Count(ctx) - if err != nil { - return 0, err - } - return int32(count), nil -} - -type Order interface { - ~func(*sql.Selector) -} - -func OrderBy[T Order](fields []string, orders ...T) []T { - for _, field := range fields { - parts := strings.Split(field, ",") - fieldName := parts[0] - var orderOpt sql.OrderTermOption - - if len(parts) > 1 { - switch strings.ToLower(parts[1]) { - case "desc": - orderOpt = sql.OrderDesc() - default: - orderOpt = sql.OrderAsc() - } - } else { - orderOpt = sql.OrderAsc() - } - - orders = append(orders, sql.OrderByField(fieldName, orderOpt).ToFunc()) - } - return orders -} +// This file is intentionally left blank after refactoring. +// Common interfaces or future helpers can be added here. diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go new file mode 100644 index 00000000..dcf5f1d9 --- /dev/null +++ b/internal/helpers/db/pagination.go @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package db + +import ( + "context" + "encoding/base64" + "encoding/json" + + "entgo.io/ent/dialect/sql" + + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/helpers/repo" +) + +// Cursor represents the data encoded in a pagination token. +type Cursor struct { + ID int64 `json:"id"` +} + +// EncodeCursor creates a base64-encoded token from a cursor. +func EncodeCursor(c *Cursor) (string, error) { + data, err := json.Marshal(c) + if err != nil { + return "", err + } + return base64.StdEncoding.EncodeToString(data), nil +} + +// DecodeCursor parses a base64-encoded token into a Cursor struct. +func DecodeCursor(token string) (*Cursor, error) { + data, err := base64.StdEncoding.DecodeString(token) + if err != nil { + return nil, err + } + var c Cursor + if err := json.Unmarshal(data, &c); err != nil { + return nil, err + } + return &c, nil +} + +type OrderFunc = func(*sql.Selector) + +type WherePredicate interface { + ~func(*sql.Selector) +} + +// paginateable defines the minimal interface for a query builder to support pagination. +// All Ent query builders satisfy this interface. +type paginateable[T any] interface { + Limit(int) T + Offset(int) T + Order(...OrderFunc) T +} + +// counter defines an interface for queries that can count their results. +type counter[T any] interface { + Count(ctx context.Context) (int, error) +} + +// Pagination applies pagination logic to a query builder. +// It is the caller's responsibility to apply the correct WHERE clause for cursor-based pagination *before* calling this function. +func Pagination[P paginateable[P]](query P, opt *repo.QueryOption, idField string) P { + // Apply the limit first, as it's common to both pagination types. + if opt.PageSize > 0 { + query = query.Limit(opt.PageSize) + } + + if opt.PageToken != "" { + // If a token is used, the WHERE clause is assumed to be already applied by the caller. + // We just need to enforce the correct ordering for the cursor to work. + query = query.Order(ent.Asc(idField)) + } else if opt.Page > 0 { + // For offset-based pagination, apply the offset. + query = query.Offset((opt.Page - 1) * opt.PageSize) + } + + return query +} + +// PageCount executes a count query and returns the total number of records. +func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { + count, err := query.Count(ctx) + if err != nil { + return 0, err + } + return int32(count), nil +} diff --git a/internal/helpers/db/sorting.go b/internal/helpers/db/sorting.go new file mode 100644 index 00000000..32a0654e --- /dev/null +++ b/internal/helpers/db/sorting.go @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package db + +import ( + "entgo.io/ent/dialect/sql" + "strings" +) + +// Order is an interface constraint for Ent order functions. +type Order interface { + ~func(*sql.Selector) +} + +// OrderBy dynamically builds a list of order functions from a slice of strings. +// Each string can be in the format "field_name" (for ascending) or "field_name,desc" (for descending). +// This function is designed to be perfectly compatible with Ent's `Order()` method. +func OrderBy[T Order](fields []string, orders ...T) []T { + for _, field := range fields { + parts := strings.Split(field, ",") + fieldName := parts[0] + var orderOpt sql.OrderTermOption + + if len(parts) > 1 { + switch strings.ToLower(parts[1]) { + case "desc": + orderOpt = sql.OrderDesc() + default: + orderOpt = sql.OrderAsc() + } + } else { + orderOpt = sql.OrderAsc() + } + + // This conversion is specific to Ent's sql.OrderFunc and is intentionally kept + // to maintain compatibility. + orders = append(orders, sql.OrderByField(fieldName, orderOpt).ToFunc()) + } + return orders +} diff --git a/internal/helpers/repo/options.go b/internal/helpers/repo/options.go index d75371b8..40f23980 100644 --- a/internal/helpers/repo/options.go +++ b/internal/helpers/repo/options.go @@ -6,12 +6,17 @@ // focusing on abstracting common query patterns like pagination. package repo -// PaginatingRequest defines the contract for any request that supports pagination. +// PaginatingRequest defines the contract for any request that supports offset-based pagination. type PaginatingRequest interface { GetPage() int32 GetPageSize() int32 } +// TokenPaginatingRequest defines the contract for any request that supports token-based pagination. +type TokenPaginatingRequest interface { + GetPageToken() string +} + // CountingRequest defines the contract for any request that supports "count-only" mode. type CountingRequest interface { GetOnlyCount() bool @@ -27,14 +32,14 @@ type KeywordRequest interface { type QueryOption struct { Page int PageSize int + PageToken string // Added for cursor pagination OnlyCount bool Keyword string OrderBy []string } // OptionFromRequest creates a QueryOption with common details -// extracted from any request that satisfies the PaginatingRequest, -// CountingRequest, or KeywordRequest interfaces. +// extracted from any request that satisfies the supported interfaces. func OptionFromRequest(req interface{}) QueryOption { opt := QueryOption{} @@ -43,6 +48,10 @@ func OptionFromRequest(req interface{}) QueryOption { opt.PageSize = int(r.GetPageSize()) } + if r, ok := req.(TokenPaginatingRequest); ok { + opt.PageToken = r.GetPageToken() + } + if r, ok := req.(CountingRequest); ok { opt.OnlyCount = r.GetOnlyCount() } From 3b31a344a458b19280506bb64bba0c67f527aeef Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 17:57:33 +0800 Subject: [PATCH 088/158] feat(db): refactor pagination and sorting with improved cursor handling and unified pagination logic --- internal/helpers/db/pagination.go | 78 +++++++++++++++---------------- internal/helpers/db/sorting.go | 8 ++-- internal/helpers/repo/options.go | 22 ++++++++- 3 files changed, 64 insertions(+), 44 deletions(-) diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go index dcf5f1d9..ec21ba5c 100644 --- a/internal/helpers/db/pagination.go +++ b/internal/helpers/db/pagination.go @@ -5,83 +5,83 @@ package db import ( + "bytes" "context" "encoding/base64" - "encoding/json" + "encoding/gob" + "fmt" "entgo.io/ent/dialect/sql" - "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/helpers/repo" ) -// Cursor represents the data encoded in a pagination token. -type Cursor struct { - ID int64 `json:"id"` -} +// Cursor, EncodeCursor, DecodeCursor, OrderFunc, and counter remain the same as the user's correct version. -// EncodeCursor creates a base64-encoded token from a cursor. -func EncodeCursor(c *Cursor) (string, error) { - data, err := json.Marshal(c) - if err != nil { - return "", err +type Cursor map[string]interface{} + +func EncodeCursor(c Cursor) (string, error) { + var buf bytes.Buffer + encoder := gob.NewEncoder(&buf) + if err := encoder.Encode(c); err != nil { + return "", fmt.Errorf("gob encode cursor: %w", err) } - return base64.StdEncoding.EncodeToString(data), nil + return base64.StdEncoding.EncodeToString(buf.Bytes()), nil } -// DecodeCursor parses a base64-encoded token into a Cursor struct. -func DecodeCursor(token string) (*Cursor, error) { +func DecodeCursor(token string) (Cursor, error) { data, err := base64.StdEncoding.DecodeString(token) if err != nil { - return nil, err + return nil, fmt.Errorf("base64 decode token: %w", err) } var c Cursor - if err := json.Unmarshal(data, &c); err != nil { - return nil, err + decoder := gob.NewDecoder(bytes.NewReader(data)) + if err := decoder.Decode(&c); err != nil { + return nil, fmt.Errorf("gob decode cursor: %w", err) } - return &c, nil + return c, nil } type OrderFunc = func(*sql.Selector) -type WherePredicate interface { - ~func(*sql.Selector) -} - -// paginateable defines the minimal interface for a query builder to support pagination. -// All Ent query builders satisfy this interface. type paginateable[T any] interface { Limit(int) T Offset(int) T Order(...OrderFunc) T } -// counter defines an interface for queries that can count their results. type counter[T any] interface { Count(ctx context.Context) (int, error) } -// Pagination applies pagination logic to a query builder. -// It is the caller's responsibility to apply the correct WHERE clause for cursor-based pagination *before* calling this function. -func Pagination[P paginateable[P]](query P, opt *repo.QueryOption, idField string) P { - // Apply the limit first, as it's common to both pagination types. - if opt.PageSize > 0 { - query = query.Limit(opt.PageSize) +// Paginate is the single, unified function for applying all pagination logic. +// It correctly handles NoPaging with a hard limit, and standard pagination with default/max sizes. +// It is the caller's responsibility to apply WHERE and ORDER clauses. +func Paginate[P paginateable[P]](query P, opt *repo.QueryOption) P { + // 1. Handle NoPaging case with a hard security limit. + if opt.NoPaging { + return query.Limit(repo.HardLimit) + } + + // 2. Determine the final page size for standard pagination. + pageSize := opt.PageSize + if pageSize <= 0 { + pageSize = repo.DefaultPageSize + } + if pageSize > repo.MaxPageSize { + pageSize = repo.MaxPageSize } + query = query.Limit(pageSize) - if opt.PageToken != "" { - // If a token is used, the WHERE clause is assumed to be already applied by the caller. - // We just need to enforce the correct ordering for the cursor to work. - query = query.Order(ent.Asc(idField)) - } else if opt.Page > 0 { - // For offset-based pagination, apply the offset. - query = query.Offset((opt.Page - 1) * opt.PageSize) + // 3. Apply offset only if it's not a token-based pagination request. + if opt.PageToken == "" && opt.Page > 0 { + query = query.Offset((opt.Page - 1) * pageSize) } return query } -// PageCount executes a count query and returns the total number of records. +// PageCount remains the same. func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { count, err := query.Count(ctx) if err != nil { diff --git a/internal/helpers/db/sorting.go b/internal/helpers/db/sorting.go index 32a0654e..31c8f087 100644 --- a/internal/helpers/db/sorting.go +++ b/internal/helpers/db/sorting.go @@ -9,15 +9,15 @@ import ( "strings" ) -// Order is an interface constraint for Ent order functions. -type Order interface { +// order is an interface constraint for Ent order functions. +type order interface { ~func(*sql.Selector) } // OrderBy dynamically builds a list of order functions from a slice of strings. // Each string can be in the format "field_name" (for ascending) or "field_name,desc" (for descending). -// This function is designed to be perfectly compatible with Ent's `Order()` method. -func OrderBy[T Order](fields []string, orders ...T) []T { +// This function is designed to be perfectly compatible with Ent's `order()` method. +func OrderBy[T order](fields []string, orders ...T) []T { for _, field := range fields { parts := strings.Split(field, ",") fieldName := parts[0] diff --git a/internal/helpers/repo/options.go b/internal/helpers/repo/options.go index 40f23980..24299f5c 100644 --- a/internal/helpers/repo/options.go +++ b/internal/helpers/repo/options.go @@ -6,6 +6,16 @@ // focusing on abstracting common query patterns like pagination. package repo +const ( + // DefaultPageSize is the page size used when the client does not specify one. + DefaultPageSize = 10 + // MaxPageSize is the maximum page size allowed for normal pagination. + MaxPageSize = 100 + // HardLimit is the absolute maximum number of records that can be returned in a single query, + // typically used when NoPaging is requested. + HardLimit = 1000 +) + // PaginatingRequest defines the contract for any request that supports offset-based pagination. type PaginatingRequest interface { GetPage() int32 @@ -17,6 +27,11 @@ type TokenPaginatingRequest interface { GetPageToken() string } +// NoPagingRequest defines the contract for any request that can disable pagination. +type NoPagingRequest interface { + GetNoPaging() bool +} + // CountingRequest defines the contract for any request that supports "count-only" mode. type CountingRequest interface { GetOnlyCount() bool @@ -32,7 +47,8 @@ type KeywordRequest interface { type QueryOption struct { Page int PageSize int - PageToken string // Added for cursor pagination + PageToken string + NoPaging bool OnlyCount bool Keyword string OrderBy []string @@ -52,6 +68,10 @@ func OptionFromRequest(req interface{}) QueryOption { opt.PageToken = r.GetPageToken() } + if r, ok := req.(NoPagingRequest); ok { + opt.NoPaging = r.GetNoPaging() + } + if r, ok := req.(CountingRequest); ok { opt.OnlyCount = r.GetOnlyCount() } From 02b66737b402612a4aab929f1dc36eeb5afe08d1 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 18:13:48 +0800 Subject: [PATCH 089/158] feat(db): add token-based pagination support and refactor pagination logic --- internal/helpers/db/pagination.go | 55 +++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go index ec21ba5c..0295f0cb 100644 --- a/internal/helpers/db/pagination.go +++ b/internal/helpers/db/pagination.go @@ -54,13 +54,22 @@ type counter[T any] interface { Count(ctx context.Context) (int, error) } -// Paginate is the single, unified function for applying all pagination logic. -// It correctly handles NoPaging with a hard limit, and standard pagination with default/max sizes. -// It is the caller's responsibility to apply WHERE and ORDER clauses. -func Paginate[P paginateable[P]](query P, opt *repo.QueryOption) P { - // 1. Handle NoPaging case with a hard security limit. +type queryable interface { + ~func(*sql.Selector) +} + +type Where[T queryable] interface { + Limit(int) Where[T] + Offset(int) Where[T] + Order(...OrderFunc) Where[T] + Where(...T) Where[T] +} + +type cursorCallback[T queryable] func(cursor Cursor) T + +func applyPageSize(opt *repo.QueryOption) int { if opt.NoPaging { - return query.Limit(repo.HardLimit) + return repo.HardLimit } // 2. Determine the final page size for standard pagination. @@ -71,8 +80,21 @@ func Paginate[P paginateable[P]](query P, opt *repo.QueryOption) P { if pageSize > repo.MaxPageSize { pageSize = repo.MaxPageSize } + return pageSize +} + +// Paginate is the single, unified function for applying all pagination logic. +// It correctly handles NoPaging with a hard limit, and standard pagination with default/max sizes. +// It is the caller's responsibility to apply WHERE and ORDER clauses. +func Paginate[P paginateable[P]](query P, opt *repo.QueryOption) P { + // 1. Handle NoPaging case with a hard security limit. + pageSize := applyPageSize(opt) query = query.Limit(pageSize) + if opt.NoPaging { + return query + } + // 3. Apply offset only if it's not a token-based pagination request. if opt.PageToken == "" && opt.Page > 0 { query = query.Offset((opt.Page - 1) * pageSize) @@ -81,6 +103,27 @@ func Paginate[P paginateable[P]](query P, opt *repo.QueryOption) P { return query } +func Token[T queryable](query Where[T], opt *repo.QueryOption, callback cursorCallback[T]) (Where[T], error) { + // 1. Handle NoPaging case with a hard security limit. + pageSize := applyPageSize(opt) + query = query.Limit(pageSize) + + if opt.NoPaging { + return query, nil + } + + // 3. Apply cursor-based pagination if a token is provided. + if opt.PageToken != "" { + cursor, err := DecodeCursor(opt.PageToken) + if err != nil { + return query, fmt.Errorf("decode cursor: %w", err) + } + query = query.Where(callback(cursor)) + } + + return query, nil +} + // PageCount remains the same. func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { count, err := query.Count(ctx) From 654b1561f46c2c15ed549fffba6f0bae38c68ce6 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 19:38:40 +0800 Subject: [PATCH 090/158] feat(system): extend View proto definition with new fields and refactor view repository methods --- api/v1/proto/types/system.proto | 36 ++++--- api/v1/services/types/system.pb.go | 94 +++++++++++------ api/v1/services/types/system.pb.validate.go | 6 ++ internal/features/system/dal/view.go | 69 ++++-------- internal/features/system/dto/custom.gen.go | 18 ---- internal/features/system/dto/dto.gen.go | 17 ++- internal/features/system/dto/dto.go | 14 ++- internal/features/system/dto/permission.go | 34 +++++- internal/features/system/dto/view.go | 36 ++++++- internal/features/system/server/server.go | 1 + internal/helpers/db/db.go | 8 ++ internal/helpers/db/pagination.go | 110 ++++++++++++-------- internal/helpers/db/sorting.go | 10 +- resources/api-docs/openapi/openapi.yaml | 11 +- 14 files changed, 289 insertions(+), 175 deletions(-) diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index edc0ca6a..554ddce0 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -22,34 +22,40 @@ message View { string keyword = 4 [json_name = "keyword"]; // Name holds the value of the "name" field. string name = 5 [json_name = "name"]; - // I18nKey holds the value - string i18n_key = 6 [json_name = "i18n_key"]; + // Scope holds the value of the "scope" field. + string scope = 6 [json_name = "scope"]; + // I18nKey holds the value of the "i18n_key" field. + string i18n_key = 7 [json_name = "i18n_key"]; // Description holds the value of the "description" field. - string description = 7 [json_name = "description"]; + string description = 8 [json_name = "description"]; // Sequence holds the value of the "sequence" field. - int32 sequence = 8 [json_name = "sequence"]; + int32 sequence = 9 [json_name = "sequence"]; // Type holds the value of the "type" field. - string type = 9 [json_name = "type"]; + string type = 10 [json_name = "type"]; + // Comment holds the value of the "comment" field. + string comment = 11 [json_name = "comment"]; // Icon holds the value of the "icon" field. - string icon = 10 [json_name = "icon"]; + string icon = 12 [json_name = "icon"]; + // Visible holds the value of the "visible" field. + bool visible = 13 [json_name = "visible"]; // Path holds the value of the "path" field. - string path = 11 [json_name = "path"]; + string path = 14 [json_name = "path"]; // Properties holds the value of the "properties" field. - string properties = 12 [json_name = "properties"]; + string properties = 15 [json_name = "properties"]; // Status holds the value of the "status" field. - int32 status = 13 [json_name = "status"]; + int32 status = 16 [json_name = "status"]; // ParentID holds the value of the "parent_id" field. - int64 parent_id = 14 [json_name = "parent_id"]; + int64 parent_id = 17 [json_name = "parent_id"]; // ParentPath holds the value of the "parent_path" field. - string parent_path = 15 [json_name = "parent_path"]; + string parent_path = 18 [json_name = "parent_path"]; // Children holds the value of the children edge. - repeated View children = 21 [json_name = "children"]; + repeated View children = 19 [json_name = "children"]; // Parent holds the value of the parent edge. - View parent = 22 [json_name = "parent"]; + View parent = 20 [json_name = "parent"]; // Resources holds the value of the resources edge. - repeated Resource resources = 23 [json_name = "resources"]; + repeated Resource resources = 21 [json_name = "resources"]; // Roles holds the value of the roles edge. - repeated Role roles = 24 [json_name = "roles"]; + repeated Role roles = 22 [json_name = "roles"]; } // ViewEdges holds the relations/edges for other nodes in the graph. diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index bc692ebb..c193970d 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -35,34 +35,40 @@ type View struct { Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` // Name holds the value of the "name" field. Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - // I18nKey holds the value - I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` + // Scope holds the value of the "scope" field. + Scope string `protobuf:"bytes,6,opt,name=scope,proto3" json:"scope,omitempty"` + // I18nKey holds the value of the "i18n_key" field. + I18NKey string `protobuf:"bytes,7,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` // Description holds the value of the "description" field. - Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,8,opt,name=description,proto3" json:"description,omitempty"` // Sequence holds the value of the "sequence" field. - Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` + Sequence int32 `protobuf:"varint,9,opt,name=sequence,proto3" json:"sequence,omitempty"` // Type holds the value of the "type" field. - Type string `protobuf:"bytes,9,opt,name=type,proto3" json:"type,omitempty"` + Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` + // Comment holds the value of the "comment" field. + Comment string `protobuf:"bytes,11,opt,name=comment,proto3" json:"comment,omitempty"` // Icon holds the value of the "icon" field. - Icon string `protobuf:"bytes,10,opt,name=icon,proto3" json:"icon,omitempty"` + Icon string `protobuf:"bytes,12,opt,name=icon,proto3" json:"icon,omitempty"` + // Visible holds the value of the "visible" field. + Visible bool `protobuf:"varint,13,opt,name=visible,proto3" json:"visible,omitempty"` // Path holds the value of the "path" field. - Path string `protobuf:"bytes,11,opt,name=path,proto3" json:"path,omitempty"` + Path string `protobuf:"bytes,14,opt,name=path,proto3" json:"path,omitempty"` // Properties holds the value of the "properties" field. - Properties string `protobuf:"bytes,12,opt,name=properties,proto3" json:"properties,omitempty"` + Properties string `protobuf:"bytes,15,opt,name=properties,proto3" json:"properties,omitempty"` // Status holds the value of the "status" field. - Status int32 `protobuf:"varint,13,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,16,opt,name=status,proto3" json:"status,omitempty"` // ParentID holds the value of the "parent_id" field. - ParentId int64 `protobuf:"varint,14,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + ParentId int64 `protobuf:"varint,17,opt,name=parent_id,proto3" json:"parent_id,omitempty"` // ParentPath holds the value of the "parent_path" field. - ParentPath string `protobuf:"bytes,15,opt,name=parent_path,proto3" json:"parent_path,omitempty"` + ParentPath string `protobuf:"bytes,18,opt,name=parent_path,proto3" json:"parent_path,omitempty"` // Children holds the value of the children edge. - Children []*View `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` + Children []*View `protobuf:"bytes,19,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. - Parent *View `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` + Parent *View `protobuf:"bytes,20,opt,name=parent,proto3" json:"parent,omitempty"` // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*Resource `protobuf:"bytes,21,rep,name=resources,proto3" json:"resources,omitempty"` // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*Role `protobuf:"bytes,22,rep,name=roles,proto3" json:"roles,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -132,6 +138,13 @@ func (x *View) GetName() string { return "" } +func (x *View) GetScope() string { + if x != nil { + return x.Scope + } + return "" +} + func (x *View) GetI18NKey() string { if x != nil { return x.I18NKey @@ -160,6 +173,13 @@ func (x *View) GetType() string { return "" } +func (x *View) GetComment() string { + if x != nil { + return x.Comment + } + return "" +} + func (x *View) GetIcon() string { if x != nil { return x.Icon @@ -167,6 +187,13 @@ func (x *View) GetIcon() string { return "" } +func (x *View) GetVisible() bool { + if x != nil { + return x.Visible + } + return false +} + func (x *View) GetPath() string { if x != nil { return x.Path @@ -2747,30 +2774,33 @@ var File_types_system_proto protoreflect.FileDescriptor const file_types_system_proto_rawDesc = "" + "\n" + - "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xae\x05\n" + + "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xf8\x05\n" + "\x04View\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\x05 \x01(\tR\x04name\x12\x1a\n" + - "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12 \n" + - "\vdescription\x18\a \x01(\tR\vdescription\x12\x1a\n" + - "\bsequence\x18\b \x01(\x05R\bsequence\x12\x12\n" + - "\x04type\x18\t \x01(\tR\x04type\x12\x12\n" + - "\x04icon\x18\n" + - " \x01(\tR\x04icon\x12\x12\n" + - "\x04path\x18\v \x01(\tR\x04path\x12\x1e\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12\x14\n" + + "\x05scope\x18\x06 \x01(\tR\x05scope\x12\x1a\n" + + "\bi18n_key\x18\a \x01(\tR\bi18n_key\x12 \n" + + "\vdescription\x18\b \x01(\tR\vdescription\x12\x1a\n" + + "\bsequence\x18\t \x01(\x05R\bsequence\x12\x12\n" + + "\x04type\x18\n" + + " \x01(\tR\x04type\x12\x18\n" + + "\acomment\x18\v \x01(\tR\acomment\x12\x12\n" + + "\x04icon\x18\f \x01(\tR\x04icon\x12\x18\n" + + "\avisible\x18\r \x01(\bR\avisible\x12\x12\n" + + "\x04path\x18\x0e \x01(\tR\x04path\x12\x1e\n" + "\n" + - "properties\x18\f \x01(\tR\n" + + "properties\x18\x0f \x01(\tR\n" + "properties\x12\x16\n" + - "\x06status\x18\r \x01(\x05R\x06status\x12\x1c\n" + - "\tparent_id\x18\x0e \x01(\x03R\tparent_id\x12 \n" + - "\vparent_path\x18\x0f \x01(\tR\vparent_path\x127\n" + - "\bchildren\x18\x15 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + - "\x06parent\x18\x16 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + - "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + - "\x05roles\x18\x18 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xac\x02\n" + + "\x06status\x18\x10 \x01(\x05R\x06status\x12\x1c\n" + + "\tparent_id\x18\x11 \x01(\x03R\tparent_id\x12 \n" + + "\vparent_path\x18\x12 \x01(\tR\vparent_path\x127\n" + + "\bchildren\x18\x13 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + + "\x06parent\x18\x14 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + + "\tresources\x18\x15 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + + "\x05roles\x18\x16 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xac\x02\n" + "\tViewEdges\x127\n" + "\bchildren\x18\x01 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + "\x06parent\x18\x02 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index 50ecbfce..910f454d 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -120,6 +120,8 @@ func (m *View) validate(all bool) error { // no validation rules for Name + // no validation rules for Scope + // no validation rules for I18NKey // no validation rules for Description @@ -128,8 +130,12 @@ func (m *View) validate(all bool) error { // no validation rules for Type + // no validation rules for Comment + // no validation rules for Icon + // no validation rules for Visible + // no validation rules for Path // no validation rules for Properties diff --git a/internal/features/system/dal/view.go b/internal/features/system/dal/view.go index e81f64a0..72f549ab 100644 --- a/internal/features/system/dal/view.go +++ b/internal/features/system/dal/view.go @@ -1,11 +1,17 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + package dal import ( "context" + "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/view" "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/db" "origadmin/application/admin/internal/helpers/repo" ) @@ -19,11 +25,12 @@ func NewViewRepo(db *ent.Database) dto.ViewRepo { } // Get retrieves a single view by its ID. -func (r *viewRepo) Get(ctx context.Context, id int64) (*types.View, error) { +func (r *viewRepo) Get(ctx context.Context, id int64, opts ...*dto.ViewQueryOption) (*types.View, error) { result, err := r.db.View(ctx).Query().Where(view.ID(id)).Only(ctx) if err != nil { return nil, err } + // Calling the converter, assuming it's generated in the dto package. return dto.ConvertViewToViewPB(result), nil } @@ -43,76 +50,44 @@ func (r *viewRepo) List(ctx context.Context, opts ...*dto.ViewQueryOption) ([]*t query.Where(view.ScopeEQ(opt.Scope)) } - // Get the total count before applying pagination. - count, err := query.Clone().Count(ctx) - if err != nil { - return nil, 0, err - } - - // Apply pagination - if opt.Page > 0 && opt.PageSize > 0 { - query.Offset((opt.Page - 1) * opt.PageSize).Limit(opt.PageSize) - } - - result, err := query.All(ctx) + result, count, err := db.Query(ctx, query, &opt.QueryOption) if err != nil { return nil, 0, err } - return dto.ConvertViewsToViewsPB(result), int32(count), nil + // Calling the converter, assuming it's generated in the dto package. + return dto.ConvertViewsToViewsPB(result), count, nil } // Create creates a new view. func (r *viewRepo) Create(ctx context.Context, in *types.View, opts ...*dto.ViewCreateOption) (*types.View, error) { - create := r.db.View(ctx).Create(). - SetKeyword(in.Keyword). - SetName(in.Name). - SetScope(in.Scope). - SetType(in.Type). - SetNillableComponent(&in.Component). - SetNillablePath(&in.Path). - SetNillableIcon(&in.Icon). - SetVisible(in.Visible). - SetSequence(int(in.Sequence)) - - if in.ParentId > 0 { - create.SetParentID(in.ParentId) - } - + // Calling the converter, assuming it's generated in the dto package. + entView := dto.ConvertViewPBToView(in) + // Assuming a `SetView` method exists, following the `SetUser` pattern. + create := r.db.View(ctx).Create().SetView(entView) saved, err := create.Save(ctx) if err != nil { return nil, err } + // Calling the converter, assuming it's generated in the dto package. return dto.ConvertViewToViewPB(saved), nil } // Update updates an existing view. func (r *viewRepo) Update(ctx context.Context, in *types.View, opts ...*dto.ViewUpdateOption) (*types.View, error) { - update := r.db.View(ctx).UpdateOneID(in.Id). - SetKeyword(in.Keyword). - SetName(in.Name). - SetScope(in.Scope). - SetType(in.Type). - SetNillableComponent(&in.Component). - SetNillablePath(&in.Path). - SetNillableIcon(&in.Icon). - SetVisible(in.Visible). - SetSequence(int(in.Sequence)) - - if in.ParentId > 0 { - update.SetParentID(in.ParentId) - } else { - update.ClearParent() - } - + // Calling the converter, assuming it's generated in the dto package. + entView := dto.ConvertViewPBToView(in) + // Assuming a `SetView` method exists, following the `SetUser` pattern. + update := r.db.View(ctx).UpdateOneID(in.Id).SetView(entView) saved, err := update.Save(ctx) if err != nil { return nil, err } + // Calling the converter, assuming it's generated in the dto package. return dto.ConvertViewToViewPB(saved), nil } -// Delete deletes a view by its ID (soft delete). +// Delete deletes a view by its ID. func (r *viewRepo) Delete(ctx context.Context, id int64) error { return r.db.View(ctx).DeleteOneID(id).Exec(ctx) } diff --git a/internal/features/system/dto/custom.gen.go b/internal/features/system/dto/custom.gen.go index afd154bd..263fb2d7 100644 --- a/internal/features/system/dto/custom.gen.go +++ b/internal/features/system/dto/custom.gen.go @@ -2,21 +2,3 @@ // More info: https://github.com/origadmin/abgen package dto - -import ( - "origadmin/application/admin/internal/data/entity/ent/resource" -) - -// ConvertInt32ToStatus is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertInt32ToStatus(from int32) resource.Status { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} - -// ConvertStatusToInt32 is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertStatusToInt32(from resource.Status) int32 { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index 373e003e..235c373e 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -9,6 +9,7 @@ package dto import ( "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/enums" "time" "google.golang.org/protobuf/types/known/timestamppb" @@ -94,6 +95,12 @@ type ( ViewEdges = ent.ViewEdges ViewEdgesPB = types.ViewEdges ViewPB = types.View + ViewPermission = ent.ViewPermission + ViewPermissionEdges = ent.ViewPermissionEdges + ViewPermissions = []*ent.ViewPermission + ViewResource = ent.ViewResource + ViewResourceEdges = ent.ViewResourceEdges + ViewResources = []*ent.ViewResource Views = []*ent.View ViewsPB = []*types.View ) @@ -667,9 +674,9 @@ func ConvertRolePBToRole(from *RolePB) *Role { Keyword: from.Keyword, Name: from.Name, Description: from.Description, - Type: int8(from.Type), + Type: enums.RoleType(from.Type), Sequence: int(from.Sequence), - Status: int8(from.Status), + Status: enums.Status(from.Status), } return to } @@ -927,7 +934,7 @@ func ConvertUserPBToUser(from *UserPB) *User { Email: from.Email, Remark: from.Remark, Token: from.Token, - Status: int8(from.Status), + Status: enums.Status(from.Status), LastLoginIP: from.LastLoginIp, LastLoginTime: ConvertTimestampToTime(from.LastLoginTime), SanctionDate: ConvertTimestampToTime(from.SanctionDate), @@ -1194,7 +1201,7 @@ func ConvertViewPBToView(from *ViewPB) *View { ParentID: from.ParentId, Keyword: from.Keyword, Name: from.Name, - Type: from.Type, + Type: ConvertStringToType(from.Type), Path: from.Path, Icon: from.Icon, Sequence: int(from.Sequence), @@ -1215,7 +1222,7 @@ func ConvertViewToViewPB(from *View) *ViewPB { Keyword: from.Keyword, Name: from.Name, Sequence: int32(from.Sequence), - Type: from.Type, + Type: ConvertTypeToString(from.Type), Icon: from.Icon, Path: from.Path, ParentId: from.ParentID, diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index efb34242..ccb21221 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -2,7 +2,7 @@ package dto import ( "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/data/enums" + "origadmin/application/admin/internal/data/entity/ent/view" ) //go:generate abgen -debug . @@ -35,3 +35,15 @@ func ConvertStringToGender(from string) user.Gender { return user.GenderMale } } + +// ConvertStringToType is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToType(from string) view.Type { + return ViewTypeCode(from) +} + +// ConvertTypeToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertTypeToString(from view.Type) string { + return ViewTypeName(from) +} diff --git a/internal/features/system/dto/permission.go b/internal/features/system/dto/permission.go index c1e34d1b..908bb34c 100644 --- a/internal/features/system/dto/permission.go +++ b/internal/features/system/dto/permission.go @@ -1,6 +1,38 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto is the data transfer object package for the system module. package dto -import "time" +import ( + "context" + "time" + + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/helpers/repo" +) + +// PermissionRepo is a Permission repository interface. +type PermissionRepo interface { + Get(ctx context.Context, id int64, opts ...*PermissionQueryOption) (*types.Permission, error) + List(ctx context.Context, opts ...*PermissionQueryOption) ([]*types.Permission, int32, error) + Create(ctx context.Context, in *types.Permission, opts ...*PermissionCreateOption) (*types.Permission, error) + Update(ctx context.Context, in *types.Permission, opts ...*PermissionUpdateOption) (*types.Permission, error) + Delete(ctx context.Context, id int64) error +} + +// PermissionQueryOption specifies options for querying permissions. +type PermissionQueryOption struct { + repo.QueryOption + DataScopes []string +} + +// PermissionCreateOption specifies options for creating a permission. +type PermissionCreateOption struct{} + +// PermissionUpdateOption specifies options for updating a permission. +type PermissionUpdateOption struct{} // PermissionCondition represents a single condition for a permission. type PermissionCondition struct { diff --git a/internal/features/system/dto/view.go b/internal/features/system/dto/view.go index dc315908..2c06ee15 100644 --- a/internal/features/system/dto/view.go +++ b/internal/features/system/dto/view.go @@ -1,3 +1,33 @@ -// This file is intentionally left empty and is pending deletion. -// The definitions within this file have been moved to the 'internal/data/enums' package -// to correct a layering violation. +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto is the data transfer object package for the system module. +package dto + +import ( + "context" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/helpers/repo" +) + +// ViewRepo is a View repository interface. +type ViewRepo interface { + Get(ctx context.Context, id int64, opts ...*ViewQueryOption) (*types.View, error) + List(ctx context.Context, opts ...*ViewQueryOption) ([]*types.View, int32, error) + Create(ctx context.Context, in *types.View, opts ...*ViewCreateOption) (*types.View, error) + Update(ctx context.Context, in *types.View, opts ...*ViewUpdateOption) (*types.View, error) + Delete(ctx context.Context, id int64) error +} + +// ViewQueryOption specifies options for querying views. +type ViewQueryOption struct { + repo.QueryOption + Scope string +} + +// ViewCreateOption specifies options for creating a view. +type ViewCreateOption struct{} + +// ViewUpdateOption specifies options for updating a view. +type ViewUpdateOption struct{} diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index a11af48f..3120b629 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -39,6 +39,7 @@ func NewServers(cfg *transportv1.Servers, svc *service.SystemService, logger log if err != nil { return nil, err } + srv.Server transportServers = append(transportServers, srv) case "grpc": srv, err := NewGRPCServer(serverCfg.GetGrpc(), svc, logger) diff --git a/internal/helpers/db/db.go b/internal/helpers/db/db.go index 77af7151..0b2608e6 100644 --- a/internal/helpers/db/db.go +++ b/internal/helpers/db/db.go @@ -6,5 +6,13 @@ // currently focusing on query construction for Ent. package db +import ( + "entgo.io/ent/dialect/sql" +) + // This file is intentionally left blank after refactoring. // Common interfaces or future helpers can be added here. + +type selectable interface { + ~func(*sql.Selector) +} diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go index 0295f0cb..bf14faa6 100644 --- a/internal/helpers/db/pagination.go +++ b/internal/helpers/db/pagination.go @@ -2,6 +2,9 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ +// Package db provides common, generic helpers for database operations. +// Its scope is strictly limited to functionalities that are truly generic +// and do not depend on schema-specific types like predicates. package db import ( @@ -11,19 +14,14 @@ import ( "encoding/gob" "fmt" - "entgo.io/ent/dialect/sql" - "origadmin/application/admin/internal/helpers/repo" ) -// Cursor, EncodeCursor, DecodeCursor, OrderFunc, and counter remain the same as the user's correct version. - type Cursor map[string]interface{} func EncodeCursor(c Cursor) (string, error) { var buf bytes.Buffer - encoder := gob.NewEncoder(&buf) - if err := encoder.Encode(c); err != nil { + if err := gob.NewEncoder(&buf).Encode(c); err != nil { return "", fmt.Errorf("gob encode cursor: %w", err) } return base64.StdEncoding.EncodeToString(buf.Bytes()), nil @@ -35,44 +33,56 @@ func DecodeCursor(token string) (Cursor, error) { return nil, fmt.Errorf("base64 decode token: %w", err) } var c Cursor - decoder := gob.NewDecoder(bytes.NewReader(data)) - if err := decoder.Decode(&c); err != nil { + if err := gob.NewDecoder(bytes.NewReader(data)).Decode(&c); err != nil { return nil, fmt.Errorf("gob decode cursor: %w", err) } return c, nil } -type OrderFunc = func(*sql.Selector) - -type paginateable[T any] interface { +// paginateable is the minimal, correct interface for applying Limit and Offset. +// It does not include `Where` or `Order` as they are not generically solvable. +type paginateable[T any, W selectable, O selectable, R any] interface { + counter[T] + cloneable[T] + whereFilterable[T, W] + orderable[T, O] + queryable[R] Limit(int) T Offset(int) T - Order(...OrderFunc) T } -type counter[T any] interface { - Count(ctx context.Context) (int, error) +type orderable[T any, O selectable] interface { + Order(...O) T } -type queryable interface { - ~func(*sql.Selector) +type whereFilterable[T any, W selectable] interface { + Where(...W) T } -type Where[T queryable] interface { - Limit(int) Where[T] - Offset(int) Where[T] - Order(...OrderFunc) Where[T] - Where(...T) Where[T] +type cloneable[T any] interface { + Clone() T +} + +// counter defines an interface for queries that can count their results. +type counter[T any] interface { + cloneable[T] + Count(ctx context.Context) (int, error) } -type cursorCallback[T queryable] func(cursor Cursor) T +type queryable[T any] interface { + All(ctx context.Context) ([]T, error) + Only(ctx context.Context) (T, error) +} func applyPageSize(opt *repo.QueryOption) int { + if opt == nil { + return repo.DefaultPageSize + } + if opt.NoPaging { return repo.HardLimit } - // 2. Determine the final page size for standard pagination. pageSize := opt.PageSize if pageSize <= 0 { pageSize = repo.DefaultPageSize @@ -83,11 +93,15 @@ func applyPageSize(opt *repo.QueryOption) int { return pageSize } -// Paginate is the single, unified function for applying all pagination logic. -// It correctly handles NoPaging with a hard limit, and standard pagination with default/max sizes. -// It is the caller's responsibility to apply WHERE and ORDER clauses. -func Paginate[P paginateable[P]](query P, opt *repo.QueryOption) P { +type cursorCallback[T selectable] func(cursor Cursor) T + +// Paginate is the single, unified function for applying pagination logic. +// It ONLY handles Limit and Offset based on the provided options. +// All WHERE and ORDER clauses are the responsibility of the caller in the DAL layer. +func Paginate[R any, W selectable, O selectable, P paginateable[P, W, O, R]](query P, opt *repo.QueryOption, + callbacks ...cursorCallback[W]) P { // 1. Handle NoPaging case with a hard security limit. + // 2. Determine the final page size for standard pagination. pageSize := applyPageSize(opt) query = query.Limit(pageSize) @@ -99,36 +113,42 @@ func Paginate[P paginateable[P]](query P, opt *repo.QueryOption) P { if opt.PageToken == "" && opt.Page > 0 { query = query.Offset((opt.Page - 1) * pageSize) } - - return query -} - -func Token[T queryable](query Where[T], opt *repo.QueryOption, callback cursorCallback[T]) (Where[T], error) { - // 1. Handle NoPaging case with a hard security limit. - pageSize := applyPageSize(opt) - query = query.Limit(pageSize) - - if opt.NoPaging { - return query, nil - } - - // 3. Apply cursor-based pagination if a token is provided. + // 4. Apply cursor-based pagination if a token is provided. if opt.PageToken != "" { cursor, err := DecodeCursor(opt.PageToken) if err != nil { - return query, fmt.Errorf("decode cursor: %w", err) + return query + } + for _, cb := range callbacks { + query = query.Where(cb(cursor)) } - query = query.Where(callback(cursor)) } - return query, nil + return query } // PageCount remains the same. func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { - count, err := query.Count(ctx) + count, err := query.Clone().Count(ctx) if err != nil { return 0, err } return int32(count), nil } + +func Query[R any, W selectable, O selectable, P paginateable[P, W, O, R]](ctx context.Context, query P, + o *repo.QueryOption, callbacks ...cursorCallback[W]) ([]R, int32, error) { + if o.OnlyCount { + count, err := PageCount(ctx, query) + if err != nil { + return nil, 0, err + } + return nil, count, nil + } + query = Paginate(query, o, callbacks...) + result, err := query.All(ctx) + if err != nil { + return nil, 0, err + } + return result, 0, nil +} diff --git a/internal/helpers/db/sorting.go b/internal/helpers/db/sorting.go index 31c8f087..8f104b83 100644 --- a/internal/helpers/db/sorting.go +++ b/internal/helpers/db/sorting.go @@ -5,19 +5,15 @@ package db import ( - "entgo.io/ent/dialect/sql" "strings" -) -// order is an interface constraint for Ent order functions. -type order interface { - ~func(*sql.Selector) -} + "entgo.io/ent/dialect/sql" +) // OrderBy dynamically builds a list of order functions from a slice of strings. // Each string can be in the format "field_name" (for ascending) or "field_name,desc" (for descending). // This function is designed to be perfectly compatible with Ent's `order()` method. -func OrderBy[T order](fields []string, orders ...T) []T { +func OrderBy[T selectable](fields []string, orders ...T) []T { for _, field := range fields { parts := strings.Split(field, ",") fieldName := parts[0] diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 3afd2c42..11808267 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -3964,9 +3964,12 @@ components: name: type: string description: Name holds the value of the "name" field. + scope: + type: string + description: Scope holds the value of the "scope" field. i18n_key: type: string - description: I18nKey holds the value + description: I18nKey holds the value of the "i18n_key" field. description: type: string description: Description holds the value of the "description" field. @@ -3977,9 +3980,15 @@ components: type: type: string description: Type holds the value of the "type" field. + comment: + type: string + description: Comment holds the value of the "comment" field. icon: type: string description: Icon holds the value of the "icon" field. + visible: + type: boolean + description: Visible holds the value of the "visible" field. path: type: string description: Path holds the value of the "path" field. From c70ac5a166c5430c87166e898f057d9b394ed2bd Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 19:41:06 +0800 Subject: [PATCH 091/158] refactor(db): restructure Cursor type and rename whereFilterable to filterable in pagination --- internal/helpers/db/pagination.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go index bf14faa6..9f801612 100644 --- a/internal/helpers/db/pagination.go +++ b/internal/helpers/db/pagination.go @@ -17,7 +17,11 @@ import ( "origadmin/application/admin/internal/helpers/repo" ) -type Cursor map[string]interface{} +type Cursor struct { + ID int64 `json:"id"` + Field string `json:"field"` + Desc bool `json:"desc"` +} func EncodeCursor(c Cursor) (string, error) { var buf bytes.Buffer @@ -28,13 +32,14 @@ func EncodeCursor(c Cursor) (string, error) { } func DecodeCursor(token string) (Cursor, error) { + var c Cursor data, err := base64.StdEncoding.DecodeString(token) if err != nil { - return nil, fmt.Errorf("base64 decode token: %w", err) + return c, fmt.Errorf("base64 decode token: %w", err) } - var c Cursor + if err := gob.NewDecoder(bytes.NewReader(data)).Decode(&c); err != nil { - return nil, fmt.Errorf("gob decode cursor: %w", err) + return c, fmt.Errorf("gob decode cursor: %w", err) } return c, nil } @@ -44,7 +49,7 @@ func DecodeCursor(token string) (Cursor, error) { type paginateable[T any, W selectable, O selectable, R any] interface { counter[T] cloneable[T] - whereFilterable[T, W] + filterable[T, W] orderable[T, O] queryable[R] Limit(int) T @@ -55,7 +60,7 @@ type orderable[T any, O selectable] interface { Order(...O) T } -type whereFilterable[T any, W selectable] interface { +type filterable[T any, W selectable] interface { Where(...W) T } From 3fb0789ff09f50384f0d905c0f8974506ce4affb Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 19:48:17 +0800 Subject: [PATCH 092/158] feat(db): optimize pagination query with count control and error handling --- internal/helpers/db/pagination.go | 33 +++++++++++++++++++++++++------ internal/helpers/repo/options.go | 1 + 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go index 9f801612..2401c62a 100644 --- a/internal/helpers/db/pagination.go +++ b/internal/helpers/db/pagination.go @@ -13,6 +13,7 @@ import ( "encoding/base64" "encoding/gob" "fmt" + "time" "origadmin/application/admin/internal/helpers/repo" ) @@ -44,8 +45,7 @@ func DecodeCursor(token string) (Cursor, error) { return c, nil } -// paginateable is the minimal, correct interface for applying Limit and Offset. -// It does not include `Where` or `Order` as they are not generically solvable. +// paginateable defines an interface for queries that can be paginated. type paginateable[T any, W selectable, O selectable, R any] interface { counter[T] cloneable[T] @@ -143,17 +143,38 @@ func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { func Query[R any, W selectable, O selectable, P paginateable[P, W, O, R]](ctx context.Context, query P, o *repo.QueryOption, callbacks ...cursorCallback[W]) ([]R, int32, error) { + + // 记录查询开始时间用于监控 + start := time.Now() + defer func() { + // 这里可以添加监控代码,记录查询耗时 + _ = time.Since(start) + }() + + // 只有在需要时才执行count查询 + var count int32 + var err error + if o.OnlyCount { - count, err := PageCount(ctx, query) + count, err = PageCount(ctx, query) if err != nil { - return nil, 0, err + return nil, 0, fmt.Errorf("count query failed: %w", err) } return nil, count, nil } + + // 如果明确需要总数或者不是cursor分页,才执行count查询 + if o.IncludeCount || o.PageToken == "" { + count, err = PageCount(ctx, query) + if err != nil { + return nil, 0, fmt.Errorf("count query failed: %w", err) + } + } + query = Paginate(query, o, callbacks...) result, err := query.All(ctx) if err != nil { - return nil, 0, err + return nil, 0, fmt.Errorf("data query failed: %w", err) } - return result, 0, nil + return result, count, nil } diff --git a/internal/helpers/repo/options.go b/internal/helpers/repo/options.go index 24299f5c..c2d9470a 100644 --- a/internal/helpers/repo/options.go +++ b/internal/helpers/repo/options.go @@ -50,6 +50,7 @@ type QueryOption struct { PageToken string NoPaging bool OnlyCount bool + IncludeCount bool Keyword string OrderBy []string } From 394c4771583b0993113cc7c8ee00cd8cdbeb058e Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 19:58:00 +0800 Subject: [PATCH 093/158] refactor(db): optimize pagination logic and remove unused fields --- internal/helpers/db/pagination.go | 41 ++++++++++++++----------------- internal/helpers/repo/options.go | 1 - 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go index 2401c62a..d5a07f8b 100644 --- a/internal/helpers/db/pagination.go +++ b/internal/helpers/db/pagination.go @@ -13,7 +13,6 @@ import ( "encoding/base64" "encoding/gob" "fmt" - "time" "origadmin/application/admin/internal/helpers/repo" ) @@ -132,7 +131,7 @@ func Paginate[R any, W selectable, O selectable, P paginateable[P, W, O, R]](que return query } -// PageCount remains the same. +// PageCount 执行count查询并返回结果 func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { count, err := query.Clone().Count(ctx) if err != nil { @@ -143,38 +142,34 @@ func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { func Query[R any, W selectable, O selectable, P paginateable[P, W, O, R]](ctx context.Context, query P, o *repo.QueryOption, callbacks ...cursorCallback[W]) ([]R, int32, error) { - - // 记录查询开始时间用于监控 - start := time.Now() - defer func() { - // 这里可以添加监控代码,记录查询耗时 - _ = time.Since(start) - }() - - // 只有在需要时才执行count查询 - var count int32 - var err error - - if o.OnlyCount { - count, err = PageCount(ctx, query) + + // 如果只需要计数,直接执行count查询 + if o != nil && o.OnlyCount { + count, err := PageCount(ctx, query) if err != nil { return nil, 0, fmt.Errorf("count query failed: %w", err) } return nil, count, nil } - - // 如果明确需要总数或者不是cursor分页,才执行count查询 - if o.IncludeCount || o.PageToken == "" { - count, err = PageCount(ctx, query) - if err != nil { - return nil, 0, fmt.Errorf("count query failed: %w", err) + + // 先克隆原始查询用于count查询(必须在分页之前) + var count int32 + var countErr error + + // 只有在非cursor分页时才执行count查询 + if o == nil || o.PageToken == "" { + count, countErr = PageCount(ctx, query) + if countErr != nil { + return nil, 0, fmt.Errorf("count query failed: %w", countErr) } } - + + // 对原始查询应用分页 query = Paginate(query, o, callbacks...) result, err := query.All(ctx) if err != nil { return nil, 0, fmt.Errorf("data query failed: %w", err) } + return result, count, nil } diff --git a/internal/helpers/repo/options.go b/internal/helpers/repo/options.go index c2d9470a..24299f5c 100644 --- a/internal/helpers/repo/options.go +++ b/internal/helpers/repo/options.go @@ -50,7 +50,6 @@ type QueryOption struct { PageToken string NoPaging bool OnlyCount bool - IncludeCount bool Keyword string OrderBy []string } From 0fde394982210b3852c1e323a73a4bd6ba985b54 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 21:17:57 +0800 Subject: [PATCH 094/158] feat(db): refactor pagination logic with query option normalization and page boundary validation --- internal/helpers/db/pagination.go | 78 +++++++++++++++++++++++++------ internal/helpers/db/sorting.go | 10 ++++ 2 files changed, 73 insertions(+), 15 deletions(-) diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go index d5a07f8b..9b7351d7 100644 --- a/internal/helpers/db/pagination.go +++ b/internal/helpers/db/pagination.go @@ -78,7 +78,39 @@ type queryable[T any] interface { Only(ctx context.Context) (T, error) } +// normalizeQueryOption 统一处理QueryOption的初始化和验证 +func normalizeQueryOption(opt *repo.QueryOption) *repo.QueryOption { + if opt == nil { + return &repo.QueryOption{ + Page: 1, + PageSize: repo.DefaultPageSize, + } + } + + // 规范化页码 + if opt.Page <= 0 { + opt.Page = 1 + } + + // 规范化页大小 + if opt.NoPaging { + if opt.PageSize <= 0 || opt.PageSize > repo.HardLimit { + opt.PageSize = repo.HardLimit + } + } else { + if opt.PageSize <= 0 { + opt.PageSize = repo.DefaultPageSize + } + if opt.PageSize > repo.MaxPageSize { + opt.PageSize = repo.MaxPageSize + } + } + + return opt +} + func applyPageSize(opt *repo.QueryOption) int { + // 注意:这个函数现在只处理页大小,页码验证在normalizeQueryOption中处理 if opt == nil { return repo.DefaultPageSize } @@ -87,14 +119,7 @@ func applyPageSize(opt *repo.QueryOption) int { return repo.HardLimit } - pageSize := opt.PageSize - if pageSize <= 0 { - pageSize = repo.DefaultPageSize - } - if pageSize > repo.MaxPageSize { - pageSize = repo.MaxPageSize - } - return pageSize + return opt.PageSize } type cursorCallback[T selectable] func(cursor Cursor) T @@ -102,8 +127,13 @@ type cursorCallback[T selectable] func(cursor Cursor) T // Paginate is the single, unified function for applying pagination logic. // It ONLY handles Limit and Offset based on the provided options. // All WHERE and ORDER clauses are the responsibility of the caller in the DAL layer. +// Note: Page boundary validation is handled in the Query function. func Paginate[R any, W selectable, O selectable, P paginateable[P, W, O, R]](query P, opt *repo.QueryOption, callbacks ...cursorCallback[W]) P { + if opt == nil { + return query.Limit(repo.DefaultPageSize) + } + // 1. Handle NoPaging case with a hard security limit. // 2. Determine the final page size for standard pagination. pageSize := applyPageSize(opt) @@ -114,17 +144,20 @@ func Paginate[R any, W selectable, O selectable, P paginateable[P, W, O, R]](que } // 3. Apply offset only if it's not a token-based pagination request. - if opt.PageToken == "" && opt.Page > 0 { + if opt.PageToken == "" { query = query.Offset((opt.Page - 1) * pageSize) } + // 4. Apply cursor-based pagination if a token is provided. if opt.PageToken != "" { cursor, err := DecodeCursor(opt.PageToken) if err != nil { - return query - } - for _, cb := range callbacks { - query = query.Where(cb(cursor)) + query = query.Limit(0) + } else { + query.Order(OrderByField[O](cursor.Field, cursor.Desc)) + for _, cb := range callbacks { + query = query.Where(cb(cursor)) + } } } @@ -143,8 +176,11 @@ func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { func Query[R any, W selectable, O selectable, P paginateable[P, W, O, R]](ctx context.Context, query P, o *repo.QueryOption, callbacks ...cursorCallback[W]) ([]R, int32, error) { + // 统一初始化和验证选项 + o = normalizeQueryOption(o) + // 如果只需要计数,直接执行count查询 - if o != nil && o.OnlyCount { + if o.OnlyCount { count, err := PageCount(ctx, query) if err != nil { return nil, 0, fmt.Errorf("count query failed: %w", err) @@ -157,11 +193,23 @@ func Query[R any, W selectable, O selectable, P paginateable[P, W, O, R]](ctx co var countErr error // 只有在非cursor分页时才执行count查询 - if o == nil || o.PageToken == "" { + if o.PageToken == "" { count, countErr = PageCount(ctx, query) if countErr != nil { return nil, 0, fmt.Errorf("count query failed: %w", countErr) } + + // 检查请求的页码是否超出总页数 + if count > 0 && o.PageSize > 0 { + totalPages := (count + int32(o.PageSize) - 1) / int32(o.PageSize) // 向上取整 + if o.Page > int(totalPages) { + // 页码超出范围,返回空结果 + return []R{}, count, nil + } + } else if count == 0 { + // 没有数据,返回空结果 + return []R{}, count, nil + } } // 对原始查询应用分页 diff --git a/internal/helpers/db/sorting.go b/internal/helpers/db/sorting.go index 8f104b83..d2b7263a 100644 --- a/internal/helpers/db/sorting.go +++ b/internal/helpers/db/sorting.go @@ -36,3 +36,13 @@ func OrderBy[T selectable](fields []string, orders ...T) []T { } return orders } + +func OrderByField[T selectable](fieldName string, desc bool) T { + var orderOpt sql.OrderTermOption + if desc { + orderOpt = sql.OrderDesc() + } else { + orderOpt = sql.OrderAsc() + } + return sql.OrderByField(fieldName, orderOpt).ToFunc() +} From 9b753f727d6703d553821fcf87dbcbe0d44341fd Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 21:30:41 +0800 Subject: [PATCH 095/158] refactor(db): translate pagination comments to English and improve code clarity --- internal/helpers/db/pagination.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go index 9b7351d7..08a6edba 100644 --- a/internal/helpers/db/pagination.go +++ b/internal/helpers/db/pagination.go @@ -78,7 +78,7 @@ type queryable[T any] interface { Only(ctx context.Context) (T, error) } -// normalizeQueryOption 统一处理QueryOption的初始化和验证 +// normalizeQueryOption handles unified initialization and validation of QueryOption func normalizeQueryOption(opt *repo.QueryOption) *repo.QueryOption { if opt == nil { return &repo.QueryOption{ @@ -87,12 +87,12 @@ func normalizeQueryOption(opt *repo.QueryOption) *repo.QueryOption { } } - // 规范化页码 + // Normalize page number if opt.Page <= 0 { opt.Page = 1 } - // 规范化页大小 + // Normalize page size if opt.NoPaging { if opt.PageSize <= 0 || opt.PageSize > repo.HardLimit { opt.PageSize = repo.HardLimit @@ -110,7 +110,7 @@ func normalizeQueryOption(opt *repo.QueryOption) *repo.QueryOption { } func applyPageSize(opt *repo.QueryOption) int { - // 注意:这个函数现在只处理页大小,页码验证在normalizeQueryOption中处理 + // Note: This function now only handles page size, page validation is handled in normalizeQueryOption if opt == nil { return repo.DefaultPageSize } @@ -164,7 +164,7 @@ func Paginate[R any, W selectable, O selectable, P paginateable[P, W, O, R]](que return query } -// PageCount 执行count查询并返回结果 +// PageCount executes count query and returns the result func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { count, err := query.Clone().Count(ctx) if err != nil { @@ -176,10 +176,10 @@ func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { func Query[R any, W selectable, O selectable, P paginateable[P, W, O, R]](ctx context.Context, query P, o *repo.QueryOption, callbacks ...cursorCallback[W]) ([]R, int32, error) { - // 统一初始化和验证选项 + // Unified initialization and validation of options o = normalizeQueryOption(o) - // 如果只需要计数,直接执行count查询 + // If only count is needed, execute count query directly if o.OnlyCount { count, err := PageCount(ctx, query) if err != nil { @@ -188,31 +188,31 @@ func Query[R any, W selectable, O selectable, P paginateable[P, W, O, R]](ctx co return nil, count, nil } - // 先克隆原始查询用于count查询(必须在分页之前) + // Clone original query for count query (must be before pagination) var count int32 var countErr error - // 只有在非cursor分页时才执行count查询 + // Execute count query only for non-cursor pagination if o.PageToken == "" { count, countErr = PageCount(ctx, query) if countErr != nil { return nil, 0, fmt.Errorf("count query failed: %w", countErr) } - // 检查请求的页码是否超出总页数 + // Check if requested page exceeds total pages if count > 0 && o.PageSize > 0 { - totalPages := (count + int32(o.PageSize) - 1) / int32(o.PageSize) // 向上取整 + totalPages := (count + int32(o.PageSize) - 1) / int32(o.PageSize) // round up if o.Page > int(totalPages) { - // 页码超出范围,返回空结果 + // Page number out of range, return empty result return []R{}, count, nil } } else if count == 0 { - // 没有数据,返回空结果 + // No data, return empty result return []R{}, count, nil } } - // 对原始查询应用分页 + // Apply pagination to original query query = Paginate(query, o, callbacks...) result, err := query.All(ctx) if err != nil { From 9f6a377b6d9e22b559ee7fc9d281380a804742b7 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 22:33:25 +0800 Subject: [PATCH 096/158] refactor(db): rename pagination interfaces and optimize query execution --- internal/helpers/db/pagination.go | 87 ++++++++++++++++++------------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go index 08a6edba..8d8e7a3e 100644 --- a/internal/helpers/db/pagination.go +++ b/internal/helpers/db/pagination.go @@ -44,36 +44,41 @@ func DecodeCursor(token string) (Cursor, error) { return c, nil } -// paginateable defines an interface for queries that can be paginated. -type paginateable[T any, W selectable, O selectable, R any] interface { - counter[T] - cloneable[T] - filterable[T, W] - orderable[T, O] - queryable[R] +// Pageable defines the interface for queries that can be paginated. +// It aggregates capabilities for counting, cloning, filtering, ordering, and fetching results. +type Pageable[T any, W any, O any, R any] interface { + Counter[T] + Cloner[T] + Filterer[T, W] + Orderer[T, O] + Fetcher[R] Limit(int) T Offset(int) T } -type orderable[T any, O selectable] interface { +// Orderer defines the interface for queries that can be ordered. +type Orderer[T any, O any] interface { Order(...O) T } -type filterable[T any, W selectable] interface { +// Filterer defines the interface for queries that can be filtered. +type Filterer[T any, W any] interface { Where(...W) T } -type cloneable[T any] interface { +// Cloner defines the interface for objects that can clone themselves. +type Cloner[T any] interface { Clone() T } -// counter defines an interface for queries that can count their results. -type counter[T any] interface { - cloneable[T] +// Counter defines the interface for queries that can count their results. +type Counter[T any] interface { + Cloner[T] Count(ctx context.Context) (int, error) } -type queryable[T any] interface { +// Fetcher defines the interface for queries that can execute and fetch results. +type Fetcher[T any] interface { All(ctx context.Context) ([]T, error) Only(ctx context.Context) (T, error) } @@ -122,13 +127,13 @@ func applyPageSize(opt *repo.QueryOption) int { return opt.PageSize } -type cursorCallback[T selectable] func(cursor Cursor) T +type cursorCallback[T any] func(cursor Cursor) T // Paginate is the single, unified function for applying pagination logic. // It ONLY handles Limit and Offset based on the provided options. // All WHERE and ORDER clauses are the responsibility of the caller in the DAL layer. -// Note: Page boundary validation is handled in the Query function. -func Paginate[R any, W selectable, O selectable, P paginateable[P, W, O, R]](query P, opt *repo.QueryOption, +// Note: Page boundary validation is handled in the Find function. +func Paginate[R any, W any, O any, P Pageable[P, W, O, R]](query P, opt *repo.QueryOption, callbacks ...cursorCallback[W]) P { if opt == nil { return query.Limit(repo.DefaultPageSize) @@ -164,8 +169,9 @@ func Paginate[R any, W selectable, O selectable, P paginateable[P, W, O, R]](que return query } -// PageCount executes count query and returns the result -func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { +// CountTotal executes the count query and returns the total number of records. +// It clones the query to avoid side effects on the original query builder. +func CountTotal[Q Counter[Q]](ctx context.Context, query Q) (int32, error) { count, err := query.Clone().Count(ctx) if err != nil { return 0, err @@ -173,47 +179,56 @@ func PageCount[Q counter[Q]](ctx context.Context, query Q) (int32, error) { return int32(count), nil } -func Query[R any, W selectable, O selectable, P paginateable[P, W, O, R]](ctx context.Context, query P, +// Find executes the query with pagination options and returns the results and total count. +// It handles both offset-based and cursor-based pagination. +// For offset-based pagination, it performs an optimization to skip the data query +// if the total count is 0 or the requested page is out of range. +func Find[R any, W any, O any, P Pageable[P, W, O, R]](ctx context.Context, query P, o *repo.QueryOption, callbacks ...cursorCallback[W]) ([]R, int32, error) { // Unified initialization and validation of options o = normalizeQueryOption(o) - // If only count is needed, execute count query directly + // Optimization: If only count is needed, execute count query directly if o.OnlyCount { - count, err := PageCount(ctx, query) + count, err := CountTotal(ctx, query) if err != nil { return nil, 0, fmt.Errorf("count query failed: %w", err) } return nil, count, nil } - // Clone original query for count query (must be before pagination) var count int32 - var countErr error + var err error - // Execute count query only for non-cursor pagination + // Execute count query only for non-cursor pagination (Offset-based) if o.PageToken == "" { - count, countErr = PageCount(ctx, query) - if countErr != nil { - return nil, 0, fmt.Errorf("count query failed: %w", countErr) + count, err = CountTotal(ctx, query) + if err != nil { + return nil, 0, fmt.Errorf("count query failed: %w", err) } - // Check if requested page exceeds total pages - if count > 0 && o.PageSize > 0 { - totalPages := (count + int32(o.PageSize) - 1) / int32(o.PageSize) // round up - if o.Page > int(totalPages) { + // Optimization: Early exit if no data found + if count == 0 { + return []R{}, 0, nil + } + + // Optimization: Early exit if requested page exceeds total pages + // Note: o.PageSize is guaranteed to be > 0 by normalizeQueryOption (unless NoPaging is true, where Page is 1) + if o.PageSize > 0 { + // Calculate total pages: ceil(count / pageSize) + totalPages := (int(count) + o.PageSize - 1) / o.PageSize + if o.Page > totalPages { // Page number out of range, return empty result return []R{}, count, nil } - } else if count == 0 { - // No data, return empty result - return []R{}, count, nil } } - // Apply pagination to original query + // Apply pagination logic (Limit, Offset, Cursor) to the query query = Paginate(query, o, callbacks...) + + // Execute the data query result, err := query.All(ctx) if err != nil { return nil, 0, fmt.Errorf("data query failed: %w", err) From 608cb60396618f280fa61b3e179d4b9679986542 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 25 Dec 2025 22:38:14 +0800 Subject: [PATCH 097/158] refactor(system): replace Query with Find method in view data access layer --- internal/features/system/dal/view.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/features/system/dal/view.go b/internal/features/system/dal/view.go index 72f549ab..a4557b39 100644 --- a/internal/features/system/dal/view.go +++ b/internal/features/system/dal/view.go @@ -50,7 +50,7 @@ func (r *viewRepo) List(ctx context.Context, opts ...*dto.ViewQueryOption) ([]*t query.Where(view.ScopeEQ(opt.Scope)) } - result, count, err := db.Query(ctx, query, &opt.QueryOption) + result, count, err := db.Find(ctx, query, &opt.QueryOption) if err != nil { return nil, 0, err } From 1387387306b7aa0814fdf7f37339b09fdfdf341e Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 26 Dec 2025 01:27:19 +0800 Subject: [PATCH 098/158] feat(ent): refactor mutation methods to clarify zero value handling with SetFields and SetFieldsSkipZero --- internal/data/entity/ent/casbinrule_update.go | 20 +- internal/data/entity/ent/department_update.go | 20 +- internal/data/entity/ent/mutation_fields.go | 742 +++++++++--------- .../data/entity/ent/notification_update.go | 20 +- internal/data/entity/ent/permission_update.go | 20 +- .../entity/ent/permissionresource_update.go | 20 +- internal/data/entity/ent/position_update.go | 20 +- .../entity/ent/positionpermission_update.go | 20 +- internal/data/entity/ent/resource_update.go | 20 +- internal/data/entity/ent/role_update.go | 20 +- .../data/entity/ent/rolepermission_update.go | 20 +- .../data/entity/ent/template/crud_update.tpl | 37 +- .../entity/ent/template/crud_update_one.tpl | 15 +- .../entity/ent/template/mutation_fields.tpl | 65 +- internal/data/entity/ent/user_update.go | 20 +- .../data/entity/ent/userdepartment_update.go | 20 +- .../data/entity/ent/userposition_update.go | 20 +- internal/data/entity/ent/userrole_update.go | 20 +- internal/data/entity/ent/view_update.go | 20 +- .../data/entity/ent/viewpermission_update.go | 20 +- .../data/entity/ent/viewresource_update.go | 20 +- internal/features/system/dal/view.go | 84 +- internal/features/system/dto/view.go | 7 +- internal/helpers/repo/options.go | 12 + 24 files changed, 690 insertions(+), 612 deletions(-) diff --git a/internal/data/entity/ent/casbinrule_update.go b/internal/data/entity/ent/casbinrule_update.go index fdb871d1..422502d1 100644 --- a/internal/data/entity/ent/casbinrule_update.go +++ b/internal/data/entity/ent/casbinrule_update.go @@ -428,7 +428,7 @@ func (_u *CasbinRuleUpdateOne) sqlSave(ctx context.Context) (_node *CasbinRule, return _node, nil } -// SetCasbinRule set the CasbinRule +// SetCasbinRule set the CasbinRule. This method includes zero values in the update. func (cru *CasbinRuleUpdate) SetCasbinRule(input *CasbinRule, fields ...string) *CasbinRuleUpdate { m := cru.mutation if len(fields) == 0 { @@ -438,17 +438,17 @@ func (cru *CasbinRuleUpdate) SetCasbinRule(input *CasbinRule, fields ...string) return cru } -// SetCasbinRuleWithZero set the CasbinRule -func (cru *CasbinRuleUpdate) SetCasbinRuleWithZero(input *CasbinRule, fields ...string) *CasbinRuleUpdate { +// SetCasbinRuleSkipZero set the CasbinRule, skipping zero values. +func (cru *CasbinRuleUpdate) SetCasbinRuleSkipZero(input *CasbinRule, fields ...string) *CasbinRuleUpdate { m := cru.mutation if len(fields) == 0 { - fields = casbinrule.Columns + fields = casbinrule.OmitColumns(casbinrule.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return cru } -// SetCasbinRule set the CasbinRule +// SetCasbinRule set the CasbinRule. This method includes zero values in the update. func (cruo *CasbinRuleUpdateOne) SetCasbinRule(input *CasbinRule, fields ...string) *CasbinRuleUpdateOne { m := cruo.mutation if len(fields) == 0 { @@ -458,13 +458,13 @@ func (cruo *CasbinRuleUpdateOne) SetCasbinRule(input *CasbinRule, fields ...stri return cruo } -// SetCasbinRuleWithZero set the CasbinRule -func (cruo *CasbinRuleUpdateOne) SetCasbinRuleWithZero(input *CasbinRule, fields ...string) *CasbinRuleUpdateOne { +// SetCasbinRuleSkipZero set the CasbinRule, skipping zero values. +func (cruo *CasbinRuleUpdateOne) SetCasbinRuleSkipZero(input *CasbinRule, fields ...string) *CasbinRuleUpdateOne { m := cruo.mutation if len(fields) == 0 { - fields = casbinrule.Columns + fields = casbinrule.OmitColumns(casbinrule.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return cruo } diff --git a/internal/data/entity/ent/department_update.go b/internal/data/entity/ent/department_update.go index c3aec8cd..de2fb0f7 100644 --- a/internal/data/entity/ent/department_update.go +++ b/internal/data/entity/ent/department_update.go @@ -1362,7 +1362,7 @@ func (_u *DepartmentUpdateOne) sqlSave(ctx context.Context) (_node *Department, return _node, nil } -// SetDepartment set the Department +// SetDepartment set the Department. This method includes zero values in the update. func (du *DepartmentUpdate) SetDepartment(input *Department, fields ...string) *DepartmentUpdate { m := du.mutation if len(fields) == 0 { @@ -1372,17 +1372,17 @@ func (du *DepartmentUpdate) SetDepartment(input *Department, fields ...string) * return du } -// SetDepartmentWithZero set the Department -func (du *DepartmentUpdate) SetDepartmentWithZero(input *Department, fields ...string) *DepartmentUpdate { +// SetDepartmentSkipZero set the Department, skipping zero values. +func (du *DepartmentUpdate) SetDepartmentSkipZero(input *Department, fields ...string) *DepartmentUpdate { m := du.mutation if len(fields) == 0 { - fields = department.Columns + fields = department.OmitColumns(department.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return du } -// SetDepartment set the Department +// SetDepartment set the Department. This method includes zero values in the update. func (duo *DepartmentUpdateOne) SetDepartment(input *Department, fields ...string) *DepartmentUpdateOne { m := duo.mutation if len(fields) == 0 { @@ -1392,13 +1392,13 @@ func (duo *DepartmentUpdateOne) SetDepartment(input *Department, fields ...strin return duo } -// SetDepartmentWithZero set the Department -func (duo *DepartmentUpdateOne) SetDepartmentWithZero(input *Department, fields ...string) *DepartmentUpdateOne { +// SetDepartmentSkipZero set the Department, skipping zero values. +func (duo *DepartmentUpdateOne) SetDepartmentSkipZero(input *Department, fields ...string) *DepartmentUpdateOne { m := duo.mutation if len(fields) == 0 { - fields = department.Columns + fields = department.OmitColumns(department.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return duo } diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index 38627ae0..c7f568fd 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -25,8 +25,35 @@ import ( // SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. +// field type. This method includes zero values in the update. func (m *CasbinRuleMutation) SetFields(input *CasbinRule, fields ...string) error { + for i := range fields { + switch fields[i] { + case casbinrule.FieldPtype: + m.SetPtype(input.Ptype) + case casbinrule.FieldV0: + m.SetV0(input.V0) + case casbinrule.FieldV1: + m.SetV1(input.V1) + case casbinrule.FieldV2: + m.SetV2(input.V2) + case casbinrule.FieldV3: + m.SetV3(input.V3) + case casbinrule.FieldV4: + m.SetV4(input.V4) + case casbinrule.FieldV5: + m.SetV5(input.V5) + default: + return fmt.Errorf("unknown CasbinRule field %s", fields[i]) + } + } + return nil +} + +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the +// field type. +func (m *CasbinRuleMutation) SetFieldsSkipZero(input *CasbinRule, fields ...string) error { for i := range fields { switch fields[i] { case casbinrule.FieldPtype: @@ -71,37 +98,45 @@ func (m *CasbinRuleMutation) SetFields(input *CasbinRule, fields ...string) erro return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *CasbinRuleMutation) SetFieldsWithZero(input *CasbinRule, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *DepartmentMutation) SetFields(input *Department, fields ...string) error { for i := range fields { switch fields[i] { - case casbinrule.FieldPtype: - m.SetPtype(input.Ptype) - case casbinrule.FieldV0: - m.SetV0(input.V0) - case casbinrule.FieldV1: - m.SetV1(input.V1) - case casbinrule.FieldV2: - m.SetV2(input.V2) - case casbinrule.FieldV3: - m.SetV3(input.V3) - case casbinrule.FieldV4: - m.SetV4(input.V4) - case casbinrule.FieldV5: - m.SetV5(input.V5) + case department.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case department.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case department.FieldKeyword: + m.SetKeyword(input.Keyword) + case department.FieldName: + m.SetName(input.Name) + case department.FieldTreePath: + m.SetTreePath(input.TreePath) + case department.FieldSequence: + m.SetSequence(input.Sequence) + case department.FieldStatus: + m.SetStatus(input.Status) + case department.FieldLevel: + m.SetLevel(input.Level) + case department.FieldDescription: + m.SetDescription(input.Description) + case department.FieldParentID: + m.SetParentID(input.ParentID) + case department.FieldID: + m.SetID(input.ID) default: - return fmt.Errorf("unknown CasbinRule field %s", fields[i]) + return fmt.Errorf("unknown Department field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *DepartmentMutation) SetFields(input *Department, fields ...string) error { +func (m *DepartmentMutation) SetFieldsSkipZero(input *Department, fields ...string) error { for i := range fields { switch fields[i] { case department.FieldCreateTime: @@ -164,45 +199,41 @@ func (m *DepartmentMutation) SetFields(input *Department, fields ...string) erro return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *DepartmentMutation) SetFieldsWithZero(input *Department, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *NotificationMutation) SetFields(input *Notification, fields ...string) error { for i := range fields { switch fields[i] { - case department.FieldCreateTime: + case notification.FieldCreateAuthor: + m.SetCreateAuthor(input.CreateAuthor) + case notification.FieldUpdateAuthor: + m.SetUpdateAuthor(input.UpdateAuthor) + case notification.FieldCreateTime: m.SetCreateTime(input.CreateTime) - case department.FieldUpdateTime: + case notification.FieldUpdateTime: m.SetUpdateTime(input.UpdateTime) - case department.FieldKeyword: - m.SetKeyword(input.Keyword) - case department.FieldName: - m.SetName(input.Name) - case department.FieldTreePath: - m.SetTreePath(input.TreePath) - case department.FieldSequence: - m.SetSequence(input.Sequence) - case department.FieldStatus: + case notification.FieldSubject: + m.SetSubject(input.Subject) + case notification.FieldContent: + m.SetContent(input.Content) + case notification.FieldStatus: m.SetStatus(input.Status) - case department.FieldLevel: - m.SetLevel(input.Level) - case department.FieldDescription: - m.SetDescription(input.Description) - case department.FieldParentID: - m.SetParentID(input.ParentID) - case department.FieldID: + case notification.FieldCategoryID: + m.SetCategoryID(input.CategoryID) + case notification.FieldID: m.SetID(input.ID) default: - return fmt.Errorf("unknown Department field %s", fields[i]) + return fmt.Errorf("unknown Notification field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *NotificationMutation) SetFields(input *Notification, fields ...string) error { +func (m *NotificationMutation) SetFieldsSkipZero(input *Notification, fields ...string) error { for i := range fields { switch fields[i] { case notification.FieldCreateAuthor: @@ -255,41 +286,41 @@ func (m *NotificationMutation) SetFields(input *Notification, fields ...string) return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *NotificationMutation) SetFieldsWithZero(input *Notification, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *PermissionMutation) SetFields(input *Permission, fields ...string) error { for i := range fields { switch fields[i] { - case notification.FieldCreateAuthor: - m.SetCreateAuthor(input.CreateAuthor) - case notification.FieldUpdateAuthor: - m.SetUpdateAuthor(input.UpdateAuthor) - case notification.FieldCreateTime: + case permission.FieldCreateTime: m.SetCreateTime(input.CreateTime) - case notification.FieldUpdateTime: + case permission.FieldUpdateTime: m.SetUpdateTime(input.UpdateTime) - case notification.FieldSubject: - m.SetSubject(input.Subject) - case notification.FieldContent: - m.SetContent(input.Content) - case notification.FieldStatus: - m.SetStatus(input.Status) - case notification.FieldCategoryID: - m.SetCategoryID(input.CategoryID) - case notification.FieldID: + case permission.FieldName: + m.SetName(input.Name) + case permission.FieldKeyword: + m.SetKeyword(input.Keyword) + case permission.FieldDescription: + m.SetDescription(input.Description) + case permission.FieldDataScope: + m.SetDataScope(input.DataScope) + case permission.FieldDataRules: + m.SetDataRules(input.DataRules) + case permission.FieldActions: + m.SetActions(input.Actions) + case permission.FieldID: m.SetID(input.ID) default: - return fmt.Errorf("unknown Notification field %s", fields[i]) + return fmt.Errorf("unknown Permission field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *PermissionMutation) SetFields(input *Permission, fields ...string) error { +func (m *PermissionMutation) SetFieldsSkipZero(input *Permission, fields ...string) error { for i := range fields { switch fields[i] { case permission.FieldCreateTime: @@ -342,41 +373,27 @@ func (m *PermissionMutation) SetFields(input *Permission, fields ...string) erro return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *PermissionMutation) SetFieldsWithZero(input *Permission, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *PermissionResourceMutation) SetFields(input *PermissionResource, fields ...string) error { for i := range fields { switch fields[i] { - case permission.FieldCreateTime: - m.SetCreateTime(input.CreateTime) - case permission.FieldUpdateTime: - m.SetUpdateTime(input.UpdateTime) - case permission.FieldName: - m.SetName(input.Name) - case permission.FieldKeyword: - m.SetKeyword(input.Keyword) - case permission.FieldDescription: - m.SetDescription(input.Description) - case permission.FieldDataScope: - m.SetDataScope(input.DataScope) - case permission.FieldDataRules: - m.SetDataRules(input.DataRules) - case permission.FieldActions: - m.SetActions(input.Actions) - case permission.FieldID: - m.SetID(input.ID) + case permissionresource.FieldPermissionID: + m.SetPermissionID(input.PermissionID) + case permissionresource.FieldResourceID: + m.SetResourceID(input.ResourceID) default: - return fmt.Errorf("unknown Permission field %s", fields[i]) + return fmt.Errorf("unknown PermissionResource field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *PermissionResourceMutation) SetFields(input *PermissionResource, fields ...string) error { +func (m *PermissionResourceMutation) SetFieldsSkipZero(input *PermissionResource, fields ...string) error { for i := range fields { switch fields[i] { case permissionresource.FieldPermissionID: @@ -396,27 +413,37 @@ func (m *PermissionResourceMutation) SetFields(input *PermissionResource, fields return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *PermissionResourceMutation) SetFieldsWithZero(input *PermissionResource, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *PositionMutation) SetFields(input *Position, fields ...string) error { for i := range fields { switch fields[i] { - case permissionresource.FieldPermissionID: - m.SetPermissionID(input.PermissionID) - case permissionresource.FieldResourceID: - m.SetResourceID(input.ResourceID) + case position.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case position.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case position.FieldName: + m.SetName(input.Name) + case position.FieldKeyword: + m.SetKeyword(input.Keyword) + case position.FieldDescription: + m.SetDescription(input.Description) + case position.FieldDepartmentID: + m.SetDepartmentID(input.DepartmentID) + case position.FieldID: + m.SetID(input.ID) default: - return fmt.Errorf("unknown PermissionResource field %s", fields[i]) + return fmt.Errorf("unknown Position field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *PositionMutation) SetFields(input *Position, fields ...string) error { +func (m *PositionMutation) SetFieldsSkipZero(input *Position, fields ...string) error { for i := range fields { switch fields[i] { case position.FieldCreateTime: @@ -459,37 +486,27 @@ func (m *PositionMutation) SetFields(input *Position, fields ...string) error { return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *PositionMutation) SetFieldsWithZero(input *Position, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *PositionPermissionMutation) SetFields(input *PositionPermission, fields ...string) error { for i := range fields { switch fields[i] { - case position.FieldCreateTime: - m.SetCreateTime(input.CreateTime) - case position.FieldUpdateTime: - m.SetUpdateTime(input.UpdateTime) - case position.FieldName: - m.SetName(input.Name) - case position.FieldKeyword: - m.SetKeyword(input.Keyword) - case position.FieldDescription: - m.SetDescription(input.Description) - case position.FieldDepartmentID: - m.SetDepartmentID(input.DepartmentID) - case position.FieldID: - m.SetID(input.ID) + case positionpermission.FieldPositionID: + m.SetPositionID(input.PositionID) + case positionpermission.FieldPermissionID: + m.SetPermissionID(input.PermissionID) default: - return fmt.Errorf("unknown Position field %s", fields[i]) + return fmt.Errorf("unknown PositionPermission field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *PositionPermissionMutation) SetFields(input *PositionPermission, fields ...string) error { +func (m *PositionPermissionMutation) SetFieldsSkipZero(input *PositionPermission, fields ...string) error { for i := range fields { switch fields[i] { case positionpermission.FieldPositionID: @@ -509,27 +526,49 @@ func (m *PositionPermissionMutation) SetFields(input *PositionPermission, fields return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *PositionPermissionMutation) SetFieldsWithZero(input *PositionPermission, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *ResourceMutation) SetFields(input *Resource, fields ...string) error { for i := range fields { switch fields[i] { - case positionpermission.FieldPositionID: - m.SetPositionID(input.PositionID) - case positionpermission.FieldPermissionID: - m.SetPermissionID(input.PermissionID) + case resource.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case resource.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case resource.FieldServiceName: + m.SetServiceName(input.ServiceName) + case resource.FieldKeyword: + m.SetKeyword(input.Keyword) + case resource.FieldPath: + m.SetPath(input.Path) + case resource.FieldMethod: + m.SetMethod(input.Method) + case resource.FieldOperation: + m.SetOperation(input.Operation) + case resource.FieldPolicy: + m.SetPolicy(input.Policy) + case resource.FieldVersionID: + m.SetVersionID(input.VersionID) + case resource.FieldLastSyncVersionID: + m.SetLastSyncVersionID(input.LastSyncVersionID) + case resource.FieldSyncStatus: + m.SetSyncStatus(input.SyncStatus) + case resource.FieldStatus: + m.SetStatus(input.Status) + case resource.FieldID: + m.SetID(input.ID) default: - return fmt.Errorf("unknown PositionPermission field %s", fields[i]) + return fmt.Errorf("unknown Resource field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *ResourceMutation) SetFields(input *Resource, fields ...string) error { +func (m *ResourceMutation) SetFieldsSkipZero(input *Resource, fields ...string) error { for i := range fields { switch fields[i] { case resource.FieldCreateTime: @@ -603,49 +642,41 @@ func (m *ResourceMutation) SetFields(input *Resource, fields ...string) error { return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *ResourceMutation) SetFieldsWithZero(input *Resource, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *RoleMutation) SetFields(input *Role, fields ...string) error { for i := range fields { switch fields[i] { - case resource.FieldCreateTime: + case role.FieldCreateTime: m.SetCreateTime(input.CreateTime) - case resource.FieldUpdateTime: + case role.FieldUpdateTime: m.SetUpdateTime(input.UpdateTime) - case resource.FieldServiceName: - m.SetServiceName(input.ServiceName) - case resource.FieldKeyword: + case role.FieldKeyword: m.SetKeyword(input.Keyword) - case resource.FieldPath: - m.SetPath(input.Path) - case resource.FieldMethod: - m.SetMethod(input.Method) - case resource.FieldOperation: - m.SetOperation(input.Operation) - case resource.FieldPolicy: - m.SetPolicy(input.Policy) - case resource.FieldVersionID: - m.SetVersionID(input.VersionID) - case resource.FieldLastSyncVersionID: - m.SetLastSyncVersionID(input.LastSyncVersionID) - case resource.FieldSyncStatus: - m.SetSyncStatus(input.SyncStatus) - case resource.FieldStatus: + case role.FieldName: + m.SetName(input.Name) + case role.FieldDescription: + m.SetDescription(input.Description) + case role.FieldType: + m.SetType(input.Type) + case role.FieldSequence: + m.SetSequence(input.Sequence) + case role.FieldStatus: m.SetStatus(input.Status) - case resource.FieldID: + case role.FieldID: m.SetID(input.ID) default: - return fmt.Errorf("unknown Resource field %s", fields[i]) + return fmt.Errorf("unknown Role field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *RoleMutation) SetFields(input *Role, fields ...string) error { +func (m *RoleMutation) SetFieldsSkipZero(input *Role, fields ...string) error { for i := range fields { switch fields[i] { case role.FieldCreateTime: @@ -698,41 +729,27 @@ func (m *RoleMutation) SetFields(input *Role, fields ...string) error { return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *RoleMutation) SetFieldsWithZero(input *Role, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *RolePermissionMutation) SetFields(input *RolePermission, fields ...string) error { for i := range fields { switch fields[i] { - case role.FieldCreateTime: - m.SetCreateTime(input.CreateTime) - case role.FieldUpdateTime: - m.SetUpdateTime(input.UpdateTime) - case role.FieldKeyword: - m.SetKeyword(input.Keyword) - case role.FieldName: - m.SetName(input.Name) - case role.FieldDescription: - m.SetDescription(input.Description) - case role.FieldType: - m.SetType(input.Type) - case role.FieldSequence: - m.SetSequence(input.Sequence) - case role.FieldStatus: - m.SetStatus(input.Status) - case role.FieldID: - m.SetID(input.ID) + case rolepermission.FieldRoleID: + m.SetRoleID(input.RoleID) + case rolepermission.FieldPermissionID: + m.SetPermissionID(input.PermissionID) default: - return fmt.Errorf("unknown Role field %s", fields[i]) + return fmt.Errorf("unknown RolePermission field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *RolePermissionMutation) SetFields(input *RolePermission, fields ...string) error { +func (m *RolePermissionMutation) SetFieldsSkipZero(input *RolePermission, fields ...string) error { for i := range fields { switch fields[i] { case rolepermission.FieldRoleID: @@ -752,27 +769,83 @@ func (m *RolePermissionMutation) SetFields(input *RolePermission, fields ...stri return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *RolePermissionMutation) SetFieldsWithZero(input *RolePermission, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *UserMutation) SetFields(input *User, fields ...string) error { for i := range fields { switch fields[i] { - case rolepermission.FieldRoleID: - m.SetRoleID(input.RoleID) - case rolepermission.FieldPermissionID: - m.SetPermissionID(input.PermissionID) + case user.FieldCreateAuthor: + m.SetCreateAuthor(input.CreateAuthor) + case user.FieldUpdateAuthor: + m.SetUpdateAuthor(input.UpdateAuthor) + case user.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case user.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case user.FieldDeleteTime: + if input.DeleteTime != nil { + m.SetDeleteTime(*input.DeleteTime) + } else { + m.ResetDeleteTime() + } + case user.FieldUUID: + m.SetUUID(input.UUID) + case user.FieldAllowedIP: + m.SetAllowedIP(input.AllowedIP) + case user.FieldUsername: + m.SetUsername(input.Username) + case user.FieldNickname: + m.SetNickname(input.Nickname) + case user.FieldAvatar: + m.SetAvatar(input.Avatar) + case user.FieldName: + m.SetName(input.Name) + case user.FieldGender: + m.SetGender(input.Gender) + case user.FieldEncryptedPassword: + m.SetEncryptedPassword(input.EncryptedPassword) + case user.FieldSalt: + m.SetSalt(input.Salt) + case user.FieldPhone: + m.SetPhone(input.Phone) + case user.FieldEmail: + m.SetEmail(input.Email) + case user.FieldDepartment: + m.SetDepartment(input.Department) + case user.FieldRemark: + m.SetRemark(input.Remark) + case user.FieldToken: + m.SetToken(input.Token) + case user.FieldStatus: + m.SetStatus(input.Status) + case user.FieldIsSystem: + m.SetIsSystem(input.IsSystem) + case user.FieldLastLoginIP: + m.SetLastLoginIP(input.LastLoginIP) + case user.FieldLastLoginTime: + m.SetLastLoginTime(input.LastLoginTime) + case user.FieldLoginTime: + m.SetLoginTime(input.LoginTime) + case user.FieldSanctionDate: + m.SetSanctionDate(input.SanctionDate) + case user.FieldManagerID: + m.SetManagerID(input.ManagerID) + case user.FieldManager: + m.SetManager(input.Manager) + case user.FieldID: + m.SetID(input.ID) default: - return fmt.Errorf("unknown RolePermission field %s", fields[i]) + return fmt.Errorf("unknown User field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *UserMutation) SetFields(input *User, fields ...string) error { +func (m *UserMutation) SetFieldsSkipZero(input *User, fields ...string) error { for i := range fields { switch fields[i] { case user.FieldCreateAuthor: @@ -918,83 +991,27 @@ func (m *UserMutation) SetFields(input *User, fields ...string) error { return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *UserMutation) SetFieldsWithZero(input *User, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *UserDepartmentMutation) SetFields(input *UserDepartment, fields ...string) error { for i := range fields { switch fields[i] { - case user.FieldCreateAuthor: - m.SetCreateAuthor(input.CreateAuthor) - case user.FieldUpdateAuthor: - m.SetUpdateAuthor(input.UpdateAuthor) - case user.FieldCreateTime: - m.SetCreateTime(input.CreateTime) - case user.FieldUpdateTime: - m.SetUpdateTime(input.UpdateTime) - case user.FieldDeleteTime: - if input.DeleteTime != nil { - m.SetDeleteTime(*input.DeleteTime) - } else { - m.ResetDeleteTime() - } - case user.FieldUUID: - m.SetUUID(input.UUID) - case user.FieldAllowedIP: - m.SetAllowedIP(input.AllowedIP) - case user.FieldUsername: - m.SetUsername(input.Username) - case user.FieldNickname: - m.SetNickname(input.Nickname) - case user.FieldAvatar: - m.SetAvatar(input.Avatar) - case user.FieldName: - m.SetName(input.Name) - case user.FieldGender: - m.SetGender(input.Gender) - case user.FieldEncryptedPassword: - m.SetEncryptedPassword(input.EncryptedPassword) - case user.FieldSalt: - m.SetSalt(input.Salt) - case user.FieldPhone: - m.SetPhone(input.Phone) - case user.FieldEmail: - m.SetEmail(input.Email) - case user.FieldDepartment: - m.SetDepartment(input.Department) - case user.FieldRemark: - m.SetRemark(input.Remark) - case user.FieldToken: - m.SetToken(input.Token) - case user.FieldStatus: - m.SetStatus(input.Status) - case user.FieldIsSystem: - m.SetIsSystem(input.IsSystem) - case user.FieldLastLoginIP: - m.SetLastLoginIP(input.LastLoginIP) - case user.FieldLastLoginTime: - m.SetLastLoginTime(input.LastLoginTime) - case user.FieldLoginTime: - m.SetLoginTime(input.LoginTime) - case user.FieldSanctionDate: - m.SetSanctionDate(input.SanctionDate) - case user.FieldManagerID: - m.SetManagerID(input.ManagerID) - case user.FieldManager: - m.SetManager(input.Manager) - case user.FieldID: - m.SetID(input.ID) + case userdepartment.FieldUserID: + m.SetUserID(input.UserID) + case userdepartment.FieldDepartmentID: + m.SetDepartmentID(input.DepartmentID) default: - return fmt.Errorf("unknown User field %s", fields[i]) + return fmt.Errorf("unknown UserDepartment field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *UserDepartmentMutation) SetFields(input *UserDepartment, fields ...string) error { +func (m *UserDepartmentMutation) SetFieldsSkipZero(input *UserDepartment, fields ...string) error { for i := range fields { switch fields[i] { case userdepartment.FieldUserID: @@ -1014,27 +1031,27 @@ func (m *UserDepartmentMutation) SetFields(input *UserDepartment, fields ...stri return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *UserDepartmentMutation) SetFieldsWithZero(input *UserDepartment, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *UserPositionMutation) SetFields(input *UserPosition, fields ...string) error { for i := range fields { switch fields[i] { - case userdepartment.FieldUserID: + case userposition.FieldUserID: m.SetUserID(input.UserID) - case userdepartment.FieldDepartmentID: - m.SetDepartmentID(input.DepartmentID) + case userposition.FieldPositionID: + m.SetPositionID(input.PositionID) default: - return fmt.Errorf("unknown UserDepartment field %s", fields[i]) + return fmt.Errorf("unknown UserPosition field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *UserPositionMutation) SetFields(input *UserPosition, fields ...string) error { +func (m *UserPositionMutation) SetFieldsSkipZero(input *UserPosition, fields ...string) error { for i := range fields { switch fields[i] { case userposition.FieldUserID: @@ -1054,27 +1071,27 @@ func (m *UserPositionMutation) SetFields(input *UserPosition, fields ...string) return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *UserPositionMutation) SetFieldsWithZero(input *UserPosition, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *UserRoleMutation) SetFields(input *UserRole, fields ...string) error { for i := range fields { switch fields[i] { - case userposition.FieldUserID: + case userrole.FieldUserID: m.SetUserID(input.UserID) - case userposition.FieldPositionID: - m.SetPositionID(input.PositionID) + case userrole.FieldRoleID: + m.SetRoleID(input.RoleID) default: - return fmt.Errorf("unknown UserPosition field %s", fields[i]) + return fmt.Errorf("unknown UserRole field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *UserRoleMutation) SetFields(input *UserRole, fields ...string) error { +func (m *UserRoleMutation) SetFieldsSkipZero(input *UserRole, fields ...string) error { for i := range fields { switch fields[i] { case userrole.FieldUserID: @@ -1094,27 +1111,49 @@ func (m *UserRoleMutation) SetFields(input *UserRole, fields ...string) error { return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *UserRoleMutation) SetFieldsWithZero(input *UserRole, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *ViewMutation) SetFields(input *View, fields ...string) error { for i := range fields { switch fields[i] { - case userrole.FieldUserID: - m.SetUserID(input.UserID) - case userrole.FieldRoleID: - m.SetRoleID(input.RoleID) + case view.FieldCreateTime: + m.SetCreateTime(input.CreateTime) + case view.FieldUpdateTime: + m.SetUpdateTime(input.UpdateTime) + case view.FieldParentID: + m.SetParentID(input.ParentID) + case view.FieldKeyword: + m.SetKeyword(input.Keyword) + case view.FieldScope: + m.SetScope(input.Scope) + case view.FieldName: + m.SetName(input.Name) + case view.FieldType: + m.SetType(input.Type) + case view.FieldComponent: + m.SetComponent(input.Component) + case view.FieldPath: + m.SetPath(input.Path) + case view.FieldIcon: + m.SetIcon(input.Icon) + case view.FieldVisible: + m.SetVisible(input.Visible) + case view.FieldSequence: + m.SetSequence(input.Sequence) + case view.FieldID: + m.SetID(input.ID) default: - return fmt.Errorf("unknown UserRole field %s", fields[i]) + return fmt.Errorf("unknown View field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *ViewMutation) SetFields(input *View, fields ...string) error { +func (m *ViewMutation) SetFieldsSkipZero(input *View, fields ...string) error { for i := range fields { switch fields[i] { case view.FieldCreateTime: @@ -1187,49 +1226,37 @@ func (m *ViewMutation) SetFields(input *View, fields ...string) error { return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *ViewMutation) SetFieldsWithZero(input *View, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *ViewPermissionMutation) SetFields(input *ViewPermission, fields ...string) error { for i := range fields { switch fields[i] { - case view.FieldCreateTime: + case viewpermission.FieldCreateAuthor: + m.SetCreateAuthor(input.CreateAuthor) + case viewpermission.FieldUpdateAuthor: + m.SetUpdateAuthor(input.UpdateAuthor) + case viewpermission.FieldCreateTime: m.SetCreateTime(input.CreateTime) - case view.FieldUpdateTime: + case viewpermission.FieldUpdateTime: m.SetUpdateTime(input.UpdateTime) - case view.FieldParentID: - m.SetParentID(input.ParentID) - case view.FieldKeyword: - m.SetKeyword(input.Keyword) - case view.FieldScope: - m.SetScope(input.Scope) - case view.FieldName: - m.SetName(input.Name) - case view.FieldType: - m.SetType(input.Type) - case view.FieldComponent: - m.SetComponent(input.Component) - case view.FieldPath: - m.SetPath(input.Path) - case view.FieldIcon: - m.SetIcon(input.Icon) - case view.FieldVisible: - m.SetVisible(input.Visible) - case view.FieldSequence: - m.SetSequence(input.Sequence) - case view.FieldID: + case viewpermission.FieldViewID: + m.SetViewID(input.ViewID) + case viewpermission.FieldPermissionID: + m.SetPermissionID(input.PermissionID) + case viewpermission.FieldID: m.SetID(input.ID) default: - return fmt.Errorf("unknown View field %s", fields[i]) + return fmt.Errorf("unknown ViewPermission field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *ViewPermissionMutation) SetFields(input *ViewPermission, fields ...string) error { +func (m *ViewPermissionMutation) SetFieldsSkipZero(input *ViewPermission, fields ...string) error { for i := range fields { switch fields[i] { case viewpermission.FieldCreateAuthor: @@ -1272,37 +1299,37 @@ func (m *ViewPermissionMutation) SetFields(input *ViewPermission, fields ...stri return nil } -// SetFieldsWithZero sets the values of the fields with the given names. It returns an +// SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *ViewPermissionMutation) SetFieldsWithZero(input *ViewPermission, fields ...string) error { +// field type. This method includes zero values in the update. +func (m *ViewResourceMutation) SetFields(input *ViewResource, fields ...string) error { for i := range fields { switch fields[i] { - case viewpermission.FieldCreateAuthor: + case viewresource.FieldCreateAuthor: m.SetCreateAuthor(input.CreateAuthor) - case viewpermission.FieldUpdateAuthor: + case viewresource.FieldUpdateAuthor: m.SetUpdateAuthor(input.UpdateAuthor) - case viewpermission.FieldCreateTime: + case viewresource.FieldCreateTime: m.SetCreateTime(input.CreateTime) - case viewpermission.FieldUpdateTime: + case viewresource.FieldUpdateTime: m.SetUpdateTime(input.UpdateTime) - case viewpermission.FieldViewID: + case viewresource.FieldViewID: m.SetViewID(input.ViewID) - case viewpermission.FieldPermissionID: - m.SetPermissionID(input.PermissionID) - case viewpermission.FieldID: + case viewresource.FieldResourceID: + m.SetResourceID(input.ResourceID) + case viewresource.FieldID: m.SetID(input.ID) default: - return fmt.Errorf("unknown ViewPermission field %s", fields[i]) + return fmt.Errorf("unknown ViewResource field %s", fields[i]) } } return nil } -// SetFields sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the +// SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. +// It returns an error if the field is not defined in the schema, or if the type mismatched the // field type. -func (m *ViewResourceMutation) SetFields(input *ViewResource, fields ...string) error { +func (m *ViewResourceMutation) SetFieldsSkipZero(input *ViewResource, fields ...string) error { for i := range fields { switch fields[i] { case viewresource.FieldCreateAuthor: @@ -1344,30 +1371,3 @@ func (m *ViewResourceMutation) SetFields(input *ViewResource, fields ...string) } return nil } - -// SetFieldsWithZero sets the values of the fields with the given names. It returns an -// error if the field is not defined in the schema, or if the type mismatched the -// field type. -func (m *ViewResourceMutation) SetFieldsWithZero(input *ViewResource, fields ...string) error { - for i := range fields { - switch fields[i] { - case viewresource.FieldCreateAuthor: - m.SetCreateAuthor(input.CreateAuthor) - case viewresource.FieldUpdateAuthor: - m.SetUpdateAuthor(input.UpdateAuthor) - case viewresource.FieldCreateTime: - m.SetCreateTime(input.CreateTime) - case viewresource.FieldUpdateTime: - m.SetUpdateTime(input.UpdateTime) - case viewresource.FieldViewID: - m.SetViewID(input.ViewID) - case viewresource.FieldResourceID: - m.SetResourceID(input.ResourceID) - case viewresource.FieldID: - m.SetID(input.ID) - default: - return fmt.Errorf("unknown ViewResource field %s", fields[i]) - } - } - return nil -} diff --git a/internal/data/entity/ent/notification_update.go b/internal/data/entity/ent/notification_update.go index 675ce5ec..8aa2e61a 100644 --- a/internal/data/entity/ent/notification_update.go +++ b/internal/data/entity/ent/notification_update.go @@ -574,7 +574,7 @@ func (_u *NotificationUpdateOne) sqlSave(ctx context.Context) (_node *Notificati return _node, nil } -// SetNotification set the Notification +// SetNotification set the Notification. This method includes zero values in the update. func (nu *NotificationUpdate) SetNotification(input *Notification, fields ...string) *NotificationUpdate { m := nu.mutation if len(fields) == 0 { @@ -584,17 +584,17 @@ func (nu *NotificationUpdate) SetNotification(input *Notification, fields ...str return nu } -// SetNotificationWithZero set the Notification -func (nu *NotificationUpdate) SetNotificationWithZero(input *Notification, fields ...string) *NotificationUpdate { +// SetNotificationSkipZero set the Notification, skipping zero values. +func (nu *NotificationUpdate) SetNotificationSkipZero(input *Notification, fields ...string) *NotificationUpdate { m := nu.mutation if len(fields) == 0 { - fields = notification.Columns + fields = notification.OmitColumns(notification.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return nu } -// SetNotification set the Notification +// SetNotification set the Notification. This method includes zero values in the update. func (nuo *NotificationUpdateOne) SetNotification(input *Notification, fields ...string) *NotificationUpdateOne { m := nuo.mutation if len(fields) == 0 { @@ -604,13 +604,13 @@ func (nuo *NotificationUpdateOne) SetNotification(input *Notification, fields .. return nuo } -// SetNotificationWithZero set the Notification -func (nuo *NotificationUpdateOne) SetNotificationWithZero(input *Notification, fields ...string) *NotificationUpdateOne { +// SetNotificationSkipZero set the Notification, skipping zero values. +func (nuo *NotificationUpdateOne) SetNotificationSkipZero(input *Notification, fields ...string) *NotificationUpdateOne { m := nuo.mutation if len(fields) == 0 { - fields = notification.Columns + fields = notification.OmitColumns(notification.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return nuo } diff --git a/internal/data/entity/ent/permission_update.go b/internal/data/entity/ent/permission_update.go index 3bce2351..b072b659 100644 --- a/internal/data/entity/ent/permission_update.go +++ b/internal/data/entity/ent/permission_update.go @@ -1835,7 +1835,7 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, return _node, nil } -// SetPermission set the Permission +// SetPermission set the Permission. This method includes zero values in the update. func (pu *PermissionUpdate) SetPermission(input *Permission, fields ...string) *PermissionUpdate { m := pu.mutation if len(fields) == 0 { @@ -1845,17 +1845,17 @@ func (pu *PermissionUpdate) SetPermission(input *Permission, fields ...string) * return pu } -// SetPermissionWithZero set the Permission -func (pu *PermissionUpdate) SetPermissionWithZero(input *Permission, fields ...string) *PermissionUpdate { +// SetPermissionSkipZero set the Permission, skipping zero values. +func (pu *PermissionUpdate) SetPermissionSkipZero(input *Permission, fields ...string) *PermissionUpdate { m := pu.mutation if len(fields) == 0 { - fields = permission.Columns + fields = permission.OmitColumns(permission.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return pu } -// SetPermission set the Permission +// SetPermission set the Permission. This method includes zero values in the update. func (puo *PermissionUpdateOne) SetPermission(input *Permission, fields ...string) *PermissionUpdateOne { m := puo.mutation if len(fields) == 0 { @@ -1865,13 +1865,13 @@ func (puo *PermissionUpdateOne) SetPermission(input *Permission, fields ...strin return puo } -// SetPermissionWithZero set the Permission -func (puo *PermissionUpdateOne) SetPermissionWithZero(input *Permission, fields ...string) *PermissionUpdateOne { +// SetPermissionSkipZero set the Permission, skipping zero values. +func (puo *PermissionUpdateOne) SetPermissionSkipZero(input *Permission, fields ...string) *PermissionUpdateOne { m := puo.mutation if len(fields) == 0 { - fields = permission.Columns + fields = permission.OmitColumns(permission.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return puo } diff --git a/internal/data/entity/ent/permissionresource_update.go b/internal/data/entity/ent/permissionresource_update.go index e8059d4e..ce6bc631 100644 --- a/internal/data/entity/ent/permissionresource_update.go +++ b/internal/data/entity/ent/permissionresource_update.go @@ -456,7 +456,7 @@ func (_u *PermissionResourceUpdateOne) sqlSave(ctx context.Context) (_node *Perm return _node, nil } -// SetPermissionResource set the PermissionResource +// SetPermissionResource set the PermissionResource. This method includes zero values in the update. func (pru *PermissionResourceUpdate) SetPermissionResource(input *PermissionResource, fields ...string) *PermissionResourceUpdate { m := pru.mutation if len(fields) == 0 { @@ -466,17 +466,17 @@ func (pru *PermissionResourceUpdate) SetPermissionResource(input *PermissionReso return pru } -// SetPermissionResourceWithZero set the PermissionResource -func (pru *PermissionResourceUpdate) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceUpdate { +// SetPermissionResourceSkipZero set the PermissionResource, skipping zero values. +func (pru *PermissionResourceUpdate) SetPermissionResourceSkipZero(input *PermissionResource, fields ...string) *PermissionResourceUpdate { m := pru.mutation if len(fields) == 0 { - fields = permissionresource.Columns + fields = permissionresource.OmitColumns(permissionresource.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return pru } -// SetPermissionResource set the PermissionResource +// SetPermissionResource set the PermissionResource. This method includes zero values in the update. func (pruo *PermissionResourceUpdateOne) SetPermissionResource(input *PermissionResource, fields ...string) *PermissionResourceUpdateOne { m := pruo.mutation if len(fields) == 0 { @@ -486,13 +486,13 @@ func (pruo *PermissionResourceUpdateOne) SetPermissionResource(input *Permission return pruo } -// SetPermissionResourceWithZero set the PermissionResource -func (pruo *PermissionResourceUpdateOne) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceUpdateOne { +// SetPermissionResourceSkipZero set the PermissionResource, skipping zero values. +func (pruo *PermissionResourceUpdateOne) SetPermissionResourceSkipZero(input *PermissionResource, fields ...string) *PermissionResourceUpdateOne { m := pruo.mutation if len(fields) == 0 { - fields = permissionresource.Columns + fields = permissionresource.OmitColumns(permissionresource.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return pruo } diff --git a/internal/data/entity/ent/position_update.go b/internal/data/entity/ent/position_update.go index 8a7765d6..4c2bd79e 100644 --- a/internal/data/entity/ent/position_update.go +++ b/internal/data/entity/ent/position_update.go @@ -1152,7 +1152,7 @@ func (_u *PositionUpdateOne) sqlSave(ctx context.Context) (_node *Position, err return _node, nil } -// SetPosition set the Position +// SetPosition set the Position. This method includes zero values in the update. func (pu *PositionUpdate) SetPosition(input *Position, fields ...string) *PositionUpdate { m := pu.mutation if len(fields) == 0 { @@ -1162,17 +1162,17 @@ func (pu *PositionUpdate) SetPosition(input *Position, fields ...string) *Positi return pu } -// SetPositionWithZero set the Position -func (pu *PositionUpdate) SetPositionWithZero(input *Position, fields ...string) *PositionUpdate { +// SetPositionSkipZero set the Position, skipping zero values. +func (pu *PositionUpdate) SetPositionSkipZero(input *Position, fields ...string) *PositionUpdate { m := pu.mutation if len(fields) == 0 { - fields = position.Columns + fields = position.OmitColumns(position.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return pu } -// SetPosition set the Position +// SetPosition set the Position. This method includes zero values in the update. func (puo *PositionUpdateOne) SetPosition(input *Position, fields ...string) *PositionUpdateOne { m := puo.mutation if len(fields) == 0 { @@ -1182,13 +1182,13 @@ func (puo *PositionUpdateOne) SetPosition(input *Position, fields ...string) *Po return puo } -// SetPositionWithZero set the Position -func (puo *PositionUpdateOne) SetPositionWithZero(input *Position, fields ...string) *PositionUpdateOne { +// SetPositionSkipZero set the Position, skipping zero values. +func (puo *PositionUpdateOne) SetPositionSkipZero(input *Position, fields ...string) *PositionUpdateOne { m := puo.mutation if len(fields) == 0 { - fields = position.Columns + fields = position.OmitColumns(position.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return puo } diff --git a/internal/data/entity/ent/positionpermission_update.go b/internal/data/entity/ent/positionpermission_update.go index ba2b4c35..ab64f96c 100644 --- a/internal/data/entity/ent/positionpermission_update.go +++ b/internal/data/entity/ent/positionpermission_update.go @@ -456,7 +456,7 @@ func (_u *PositionPermissionUpdateOne) sqlSave(ctx context.Context) (_node *Posi return _node, nil } -// SetPositionPermission set the PositionPermission +// SetPositionPermission set the PositionPermission. This method includes zero values in the update. func (ppu *PositionPermissionUpdate) SetPositionPermission(input *PositionPermission, fields ...string) *PositionPermissionUpdate { m := ppu.mutation if len(fields) == 0 { @@ -466,17 +466,17 @@ func (ppu *PositionPermissionUpdate) SetPositionPermission(input *PositionPermis return ppu } -// SetPositionPermissionWithZero set the PositionPermission -func (ppu *PositionPermissionUpdate) SetPositionPermissionWithZero(input *PositionPermission, fields ...string) *PositionPermissionUpdate { +// SetPositionPermissionSkipZero set the PositionPermission, skipping zero values. +func (ppu *PositionPermissionUpdate) SetPositionPermissionSkipZero(input *PositionPermission, fields ...string) *PositionPermissionUpdate { m := ppu.mutation if len(fields) == 0 { - fields = positionpermission.Columns + fields = positionpermission.OmitColumns(positionpermission.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return ppu } -// SetPositionPermission set the PositionPermission +// SetPositionPermission set the PositionPermission. This method includes zero values in the update. func (ppuo *PositionPermissionUpdateOne) SetPositionPermission(input *PositionPermission, fields ...string) *PositionPermissionUpdateOne { m := ppuo.mutation if len(fields) == 0 { @@ -486,13 +486,13 @@ func (ppuo *PositionPermissionUpdateOne) SetPositionPermission(input *PositionPe return ppuo } -// SetPositionPermissionWithZero set the PositionPermission -func (ppuo *PositionPermissionUpdateOne) SetPositionPermissionWithZero(input *PositionPermission, fields ...string) *PositionPermissionUpdateOne { +// SetPositionPermissionSkipZero set the PositionPermission, skipping zero values. +func (ppuo *PositionPermissionUpdateOne) SetPositionPermissionSkipZero(input *PositionPermission, fields ...string) *PositionPermissionUpdateOne { m := ppuo.mutation if len(fields) == 0 { - fields = positionpermission.Columns + fields = positionpermission.OmitColumns(positionpermission.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return ppuo } diff --git a/internal/data/entity/ent/resource_update.go b/internal/data/entity/ent/resource_update.go index c8a7bb81..11eb9bac 100644 --- a/internal/data/entity/ent/resource_update.go +++ b/internal/data/entity/ent/resource_update.go @@ -1188,7 +1188,7 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err return _node, nil } -// SetResource set the Resource +// SetResource set the Resource. This method includes zero values in the update. func (ru *ResourceUpdate) SetResource(input *Resource, fields ...string) *ResourceUpdate { m := ru.mutation if len(fields) == 0 { @@ -1198,17 +1198,17 @@ func (ru *ResourceUpdate) SetResource(input *Resource, fields ...string) *Resour return ru } -// SetResourceWithZero set the Resource -func (ru *ResourceUpdate) SetResourceWithZero(input *Resource, fields ...string) *ResourceUpdate { +// SetResourceSkipZero set the Resource, skipping zero values. +func (ru *ResourceUpdate) SetResourceSkipZero(input *Resource, fields ...string) *ResourceUpdate { m := ru.mutation if len(fields) == 0 { - fields = resource.Columns + fields = resource.OmitColumns(resource.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return ru } -// SetResource set the Resource +// SetResource set the Resource. This method includes zero values in the update. func (ruo *ResourceUpdateOne) SetResource(input *Resource, fields ...string) *ResourceUpdateOne { m := ruo.mutation if len(fields) == 0 { @@ -1218,13 +1218,13 @@ func (ruo *ResourceUpdateOne) SetResource(input *Resource, fields ...string) *Re return ruo } -// SetResourceWithZero set the Resource -func (ruo *ResourceUpdateOne) SetResourceWithZero(input *Resource, fields ...string) *ResourceUpdateOne { +// SetResourceSkipZero set the Resource, skipping zero values. +func (ruo *ResourceUpdateOne) SetResourceSkipZero(input *Resource, fields ...string) *ResourceUpdateOne { m := ruo.mutation if len(fields) == 0 { - fields = resource.Columns + fields = resource.OmitColumns(resource.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return ruo } diff --git a/internal/data/entity/ent/role_update.go b/internal/data/entity/ent/role_update.go index 89b2c0e5..099f2a41 100644 --- a/internal/data/entity/ent/role_update.go +++ b/internal/data/entity/ent/role_update.go @@ -1190,7 +1190,7 @@ func (_u *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) { return _node, nil } -// SetRole set the Role +// SetRole set the Role. This method includes zero values in the update. func (ru *RoleUpdate) SetRole(input *Role, fields ...string) *RoleUpdate { m := ru.mutation if len(fields) == 0 { @@ -1200,17 +1200,17 @@ func (ru *RoleUpdate) SetRole(input *Role, fields ...string) *RoleUpdate { return ru } -// SetRoleWithZero set the Role -func (ru *RoleUpdate) SetRoleWithZero(input *Role, fields ...string) *RoleUpdate { +// SetRoleSkipZero set the Role, skipping zero values. +func (ru *RoleUpdate) SetRoleSkipZero(input *Role, fields ...string) *RoleUpdate { m := ru.mutation if len(fields) == 0 { - fields = role.Columns + fields = role.OmitColumns(role.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return ru } -// SetRole set the Role +// SetRole set the Role. This method includes zero values in the update. func (ruo *RoleUpdateOne) SetRole(input *Role, fields ...string) *RoleUpdateOne { m := ruo.mutation if len(fields) == 0 { @@ -1220,13 +1220,13 @@ func (ruo *RoleUpdateOne) SetRole(input *Role, fields ...string) *RoleUpdateOne return ruo } -// SetRoleWithZero set the Role -func (ruo *RoleUpdateOne) SetRoleWithZero(input *Role, fields ...string) *RoleUpdateOne { +// SetRoleSkipZero set the Role, skipping zero values. +func (ruo *RoleUpdateOne) SetRoleSkipZero(input *Role, fields ...string) *RoleUpdateOne { m := ruo.mutation if len(fields) == 0 { - fields = role.Columns + fields = role.OmitColumns(role.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return ruo } diff --git a/internal/data/entity/ent/rolepermission_update.go b/internal/data/entity/ent/rolepermission_update.go index bd214577..0b42c631 100644 --- a/internal/data/entity/ent/rolepermission_update.go +++ b/internal/data/entity/ent/rolepermission_update.go @@ -456,7 +456,7 @@ func (_u *RolePermissionUpdateOne) sqlSave(ctx context.Context) (_node *RolePerm return _node, nil } -// SetRolePermission set the RolePermission +// SetRolePermission set the RolePermission. This method includes zero values in the update. func (rpu *RolePermissionUpdate) SetRolePermission(input *RolePermission, fields ...string) *RolePermissionUpdate { m := rpu.mutation if len(fields) == 0 { @@ -466,17 +466,17 @@ func (rpu *RolePermissionUpdate) SetRolePermission(input *RolePermission, fields return rpu } -// SetRolePermissionWithZero set the RolePermission -func (rpu *RolePermissionUpdate) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionUpdate { +// SetRolePermissionSkipZero set the RolePermission, skipping zero values. +func (rpu *RolePermissionUpdate) SetRolePermissionSkipZero(input *RolePermission, fields ...string) *RolePermissionUpdate { m := rpu.mutation if len(fields) == 0 { - fields = rolepermission.Columns + fields = rolepermission.OmitColumns(rolepermission.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return rpu } -// SetRolePermission set the RolePermission +// SetRolePermission set the RolePermission. This method includes zero values in the update. func (rpuo *RolePermissionUpdateOne) SetRolePermission(input *RolePermission, fields ...string) *RolePermissionUpdateOne { m := rpuo.mutation if len(fields) == 0 { @@ -486,13 +486,13 @@ func (rpuo *RolePermissionUpdateOne) SetRolePermission(input *RolePermission, fi return rpuo } -// SetRolePermissionWithZero set the RolePermission -func (rpuo *RolePermissionUpdateOne) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionUpdateOne { +// SetRolePermissionSkipZero set the RolePermission, skipping zero values. +func (rpuo *RolePermissionUpdateOne) SetRolePermissionSkipZero(input *RolePermission, fields ...string) *RolePermissionUpdateOne { m := rpuo.mutation if len(fields) == 0 { - fields = rolepermission.Columns + fields = rolepermission.OmitColumns(rolepermission.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return rpuo } diff --git a/internal/data/entity/ent/template/crud_update.tpl b/internal/data/entity/ent/template/crud_update.tpl index 17b34147..a35a9df6 100644 --- a/internal/data/entity/ent/template/crud_update.tpl +++ b/internal/data/entity/ent/template/crud_update.tpl @@ -10,24 +10,25 @@ {{ $fields = .MutableFields }} {{- end }} - {{ print "// Set" .Name " set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { - {{- $const := print .Package}} - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{$const}}.OmitColumns({{$const}}.FieldID) - } - _ = m.SetFields(input, fields...) - return {{ $receiver }} - } - - {{ print "// Set" .Name "WithZero set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { - m := {{ $receiver }}.mutation - if len(fields) == 0 { - fields = {{ $const }}.Columns + {{ print "// Set" .Name " set the " .Name ". This method includes zero values in the update." }} + func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { + {{- $const := print .Package}} + m := {{ $receiver }}.mutation + if len(fields) == 0 { + fields = {{$const}}.OmitColumns({{$const}}.FieldID) + } + _ = m.SetFields(input, fields...) + return {{ $receiver }} } - _ = m.SetFieldsWithZero(input, fields...) - return {{ $receiver }} + + {{ print "// Set" .Name "SkipZero set the " .Name ", skipping zero values." }} + func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}SkipZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { + {{- $const := print .Package}} + m := {{ $receiver }}.mutation + if len(fields) == 0 { + fields = {{$const}}.OmitColumns({{$const}}.FieldID) + } + _ = m.SetFieldsSkipZero(input, fields...) + return {{ $receiver }} } {{- end -}} diff --git a/internal/data/entity/ent/template/crud_update_one.tpl b/internal/data/entity/ent/template/crud_update_one.tpl index e384a498..99be76e7 100644 --- a/internal/data/entity/ent/template/crud_update_one.tpl +++ b/internal/data/entity/ent/template/crud_update_one.tpl @@ -5,24 +5,25 @@ {{ $builder := $.UpdateOneName }} {{- if hasSuffix $builder "UpdateOne" }} {{ $receiver := receiver $builder }} - {{ print "// Set" .Name " set the " .Name }} + {{ $const := print .Package}} + + {{ print "// Set" .Name " set the " .Name ". This method includes zero values in the update." }} func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}(input *{{ .Name }}, fields ...string) *{{ $builder }} { - {{- $const := print .Package}} m := {{ $receiver }}.mutation if len(fields) == 0 { - fields = {{$const}}.OmitColumns({{$const}}.FieldID) + fields = {{$const}}.OmitColumns({{$const}}.FieldID) } _ = m.SetFields(input, fields...) return {{ $receiver }} } - {{ print "// Set" .Name "WithZero set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { + {{ print "// Set" .Name "SkipZero set the " .Name ", skipping zero values." }} + func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}SkipZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { m := {{ $receiver }}.mutation if len(fields) == 0 { - fields = {{ $const }}.Columns + fields = {{$const}}.OmitColumns({{$const}}.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return {{ $receiver }} } diff --git a/internal/data/entity/ent/template/mutation_fields.tpl b/internal/data/entity/ent/template/mutation_fields.tpl index 3f9fd0e6..bc50cf2d 100644 --- a/internal/data/entity/ent/template/mutation_fields.tpl +++ b/internal/data/entity/ent/template/mutation_fields.tpl @@ -9,9 +9,7 @@ {{ $deps := list }}{{ with $.Config.Annotations }}{{ $deps = $.Config.Annotations.Dependencies }}{{ end }} import ( - "log" - - "entgo.io/ent/dialect" + "fmt" {{- range $n := $.Nodes }} {{ $n.PackageAlias }} "{{ $n.Config.Package }}/{{ $n.PackageDir }}" @@ -19,7 +17,6 @@ {{- range $dep := $deps }} {{ $dep.Type.PkgName }} "{{ $dep.Type.PkgPath }}" {{- end }} - "{{ $.Config.Package }}/migrate" {{- range $import := $.Storage.Imports }} "{{ $import }}" {{- end -}} @@ -32,12 +29,41 @@ {{ $fields = append $fields .ID }} {{- end }} {{ $mutation := $n.MutationName }} + // SetFields sets the values of the fields with the given names. It returns an // error if the field is not defined in the schema, or if the type mismatched the - // field type. + // field type. This method includes zero values in the update. func (m *{{ $mutation }}) SetFields(input *{{ .Name }}, fields ...string) error { for i := range fields { switch fields[i] { + {{- range $f := $fields }} + {{- $const := print $n.Package "." $f.Constant }} + {{- $setter := print "Set" $f.StructField }} + {{- $clear := print "Reset" $f.StructField }} + case {{ $const }}: + {{- if $f.Nillable}} + if input.{{ $f.StructField }}!= nil { + m.{{ $setter }}(*input.{{ $f.StructField }}) + }else{ + m.{{ $clear }}() + } + {{- else}} + m.{{ $setter }}(input.{{ $f.StructField }}) + {{- end}} + {{- end }} + default: + return fmt.Errorf("unknown {{ .Name }} field %s", fields[i]) + } + } + return nil + } + + // SetFieldsSkipZero sets the values of the fields with the given names, skipping zero values. + // It returns an error if the field is not defined in the schema, or if the type mismatched the + // field type. + func (m *{{ $mutation }}) SetFieldsSkipZero(input *{{ .Name }}, fields ...string) error { + for i := range fields { + switch fields[i] { {{- range $f := $fields }} {{- $const := print $n.Package "." $f.Constant }} {{- $setter := print "Set" $f.StructField }} @@ -78,34 +104,6 @@ m.{{ $setter }}(input.{{ $f.StructField }}) } {{- end}} - {{- end }} - default: - return fmt.Errorf("unknown {{ .Name }} field %s", fields[i]) - } - } - return nil - } - - // SetFieldsWithZero sets the values of the fields with the given names. It returns an - // error if the field is not defined in the schema, or if the type mismatched the - // field type. - func (m *{{ $mutation }}) SetFieldsWithZero(input *{{ .Name }}, fields ...string) error { - for i := range fields { - switch fields[i] { - {{- range $f := $fields }} - {{- $const := print $n.Package "." $f.Constant }} - {{- $setter := print "Set" $f.StructField }} - {{- $clear := print "Reset" $f.StructField }} - case {{ $const }}: - {{- if $f.Nillable}} - if input.{{ $f.StructField }}!= nil { - m.{{ $setter }}(*input.{{ $f.StructField }}) - }else{ - m.{{ $clear }}() - } - {{- else}} - m.{{ $setter }}(input.{{ $f.StructField }}) - {{- end}} {{- end }} default: return fmt.Errorf("unknown {{ .Name }} field %s", fields[i]) @@ -116,4 +114,3 @@ {{- end }} {{ end }} - diff --git a/internal/data/entity/ent/user_update.go b/internal/data/entity/ent/user_update.go index 198aa0a4..e0e45095 100644 --- a/internal/data/entity/ent/user_update.go +++ b/internal/data/entity/ent/user_update.go @@ -2404,7 +2404,7 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { return _node, nil } -// SetUser set the User +// SetUser set the User. This method includes zero values in the update. func (uu *UserUpdate) SetUser(input *User, fields ...string) *UserUpdate { m := uu.mutation if len(fields) == 0 { @@ -2414,17 +2414,17 @@ func (uu *UserUpdate) SetUser(input *User, fields ...string) *UserUpdate { return uu } -// SetUserWithZero set the User -func (uu *UserUpdate) SetUserWithZero(input *User, fields ...string) *UserUpdate { +// SetUserSkipZero set the User, skipping zero values. +func (uu *UserUpdate) SetUserSkipZero(input *User, fields ...string) *UserUpdate { m := uu.mutation if len(fields) == 0 { - fields = user.Columns + fields = user.OmitColumns(user.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return uu } -// SetUser set the User +// SetUser set the User. This method includes zero values in the update. func (uuo *UserUpdateOne) SetUser(input *User, fields ...string) *UserUpdateOne { m := uuo.mutation if len(fields) == 0 { @@ -2434,13 +2434,13 @@ func (uuo *UserUpdateOne) SetUser(input *User, fields ...string) *UserUpdateOne return uuo } -// SetUserWithZero set the User -func (uuo *UserUpdateOne) SetUserWithZero(input *User, fields ...string) *UserUpdateOne { +// SetUserSkipZero set the User, skipping zero values. +func (uuo *UserUpdateOne) SetUserSkipZero(input *User, fields ...string) *UserUpdateOne { m := uuo.mutation if len(fields) == 0 { - fields = user.Columns + fields = user.OmitColumns(user.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return uuo } diff --git a/internal/data/entity/ent/userdepartment_update.go b/internal/data/entity/ent/userdepartment_update.go index aba0bbcd..8348fd7e 100644 --- a/internal/data/entity/ent/userdepartment_update.go +++ b/internal/data/entity/ent/userdepartment_update.go @@ -456,7 +456,7 @@ func (_u *UserDepartmentUpdateOne) sqlSave(ctx context.Context) (_node *UserDepa return _node, nil } -// SetUserDepartment set the UserDepartment +// SetUserDepartment set the UserDepartment. This method includes zero values in the update. func (udu *UserDepartmentUpdate) SetUserDepartment(input *UserDepartment, fields ...string) *UserDepartmentUpdate { m := udu.mutation if len(fields) == 0 { @@ -466,17 +466,17 @@ func (udu *UserDepartmentUpdate) SetUserDepartment(input *UserDepartment, fields return udu } -// SetUserDepartmentWithZero set the UserDepartment -func (udu *UserDepartmentUpdate) SetUserDepartmentWithZero(input *UserDepartment, fields ...string) *UserDepartmentUpdate { +// SetUserDepartmentSkipZero set the UserDepartment, skipping zero values. +func (udu *UserDepartmentUpdate) SetUserDepartmentSkipZero(input *UserDepartment, fields ...string) *UserDepartmentUpdate { m := udu.mutation if len(fields) == 0 { - fields = userdepartment.Columns + fields = userdepartment.OmitColumns(userdepartment.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return udu } -// SetUserDepartment set the UserDepartment +// SetUserDepartment set the UserDepartment. This method includes zero values in the update. func (uduo *UserDepartmentUpdateOne) SetUserDepartment(input *UserDepartment, fields ...string) *UserDepartmentUpdateOne { m := uduo.mutation if len(fields) == 0 { @@ -486,13 +486,13 @@ func (uduo *UserDepartmentUpdateOne) SetUserDepartment(input *UserDepartment, fi return uduo } -// SetUserDepartmentWithZero set the UserDepartment -func (uduo *UserDepartmentUpdateOne) SetUserDepartmentWithZero(input *UserDepartment, fields ...string) *UserDepartmentUpdateOne { +// SetUserDepartmentSkipZero set the UserDepartment, skipping zero values. +func (uduo *UserDepartmentUpdateOne) SetUserDepartmentSkipZero(input *UserDepartment, fields ...string) *UserDepartmentUpdateOne { m := uduo.mutation if len(fields) == 0 { - fields = userdepartment.Columns + fields = userdepartment.OmitColumns(userdepartment.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return uduo } diff --git a/internal/data/entity/ent/userposition_update.go b/internal/data/entity/ent/userposition_update.go index d3cf097c..fc2265f8 100644 --- a/internal/data/entity/ent/userposition_update.go +++ b/internal/data/entity/ent/userposition_update.go @@ -456,7 +456,7 @@ func (_u *UserPositionUpdateOne) sqlSave(ctx context.Context) (_node *UserPositi return _node, nil } -// SetUserPosition set the UserPosition +// SetUserPosition set the UserPosition. This method includes zero values in the update. func (upu *UserPositionUpdate) SetUserPosition(input *UserPosition, fields ...string) *UserPositionUpdate { m := upu.mutation if len(fields) == 0 { @@ -466,17 +466,17 @@ func (upu *UserPositionUpdate) SetUserPosition(input *UserPosition, fields ...st return upu } -// SetUserPositionWithZero set the UserPosition -func (upu *UserPositionUpdate) SetUserPositionWithZero(input *UserPosition, fields ...string) *UserPositionUpdate { +// SetUserPositionSkipZero set the UserPosition, skipping zero values. +func (upu *UserPositionUpdate) SetUserPositionSkipZero(input *UserPosition, fields ...string) *UserPositionUpdate { m := upu.mutation if len(fields) == 0 { - fields = userposition.Columns + fields = userposition.OmitColumns(userposition.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return upu } -// SetUserPosition set the UserPosition +// SetUserPosition set the UserPosition. This method includes zero values in the update. func (upuo *UserPositionUpdateOne) SetUserPosition(input *UserPosition, fields ...string) *UserPositionUpdateOne { m := upuo.mutation if len(fields) == 0 { @@ -486,13 +486,13 @@ func (upuo *UserPositionUpdateOne) SetUserPosition(input *UserPosition, fields . return upuo } -// SetUserPositionWithZero set the UserPosition -func (upuo *UserPositionUpdateOne) SetUserPositionWithZero(input *UserPosition, fields ...string) *UserPositionUpdateOne { +// SetUserPositionSkipZero set the UserPosition, skipping zero values. +func (upuo *UserPositionUpdateOne) SetUserPositionSkipZero(input *UserPosition, fields ...string) *UserPositionUpdateOne { m := upuo.mutation if len(fields) == 0 { - fields = userposition.Columns + fields = userposition.OmitColumns(userposition.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return upuo } diff --git a/internal/data/entity/ent/userrole_update.go b/internal/data/entity/ent/userrole_update.go index 90c3a5a9..2ff40053 100644 --- a/internal/data/entity/ent/userrole_update.go +++ b/internal/data/entity/ent/userrole_update.go @@ -456,7 +456,7 @@ func (_u *UserRoleUpdateOne) sqlSave(ctx context.Context) (_node *UserRole, err return _node, nil } -// SetUserRole set the UserRole +// SetUserRole set the UserRole. This method includes zero values in the update. func (uru *UserRoleUpdate) SetUserRole(input *UserRole, fields ...string) *UserRoleUpdate { m := uru.mutation if len(fields) == 0 { @@ -466,17 +466,17 @@ func (uru *UserRoleUpdate) SetUserRole(input *UserRole, fields ...string) *UserR return uru } -// SetUserRoleWithZero set the UserRole -func (uru *UserRoleUpdate) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleUpdate { +// SetUserRoleSkipZero set the UserRole, skipping zero values. +func (uru *UserRoleUpdate) SetUserRoleSkipZero(input *UserRole, fields ...string) *UserRoleUpdate { m := uru.mutation if len(fields) == 0 { - fields = userrole.Columns + fields = userrole.OmitColumns(userrole.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return uru } -// SetUserRole set the UserRole +// SetUserRole set the UserRole. This method includes zero values in the update. func (uruo *UserRoleUpdateOne) SetUserRole(input *UserRole, fields ...string) *UserRoleUpdateOne { m := uruo.mutation if len(fields) == 0 { @@ -486,13 +486,13 @@ func (uruo *UserRoleUpdateOne) SetUserRole(input *UserRole, fields ...string) *U return uruo } -// SetUserRoleWithZero set the UserRole -func (uruo *UserRoleUpdateOne) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleUpdateOne { +// SetUserRoleSkipZero set the UserRole, skipping zero values. +func (uruo *UserRoleUpdateOne) SetUserRoleSkipZero(input *UserRole, fields ...string) *UserRoleUpdateOne { m := uruo.mutation if len(fields) == 0 { - fields = userrole.Columns + fields = userrole.OmitColumns(userrole.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return uruo } diff --git a/internal/data/entity/ent/view_update.go b/internal/data/entity/ent/view_update.go index be5592f5..6af5d955 100644 --- a/internal/data/entity/ent/view_update.go +++ b/internal/data/entity/ent/view_update.go @@ -1671,7 +1671,7 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { return _node, nil } -// SetView set the View +// SetView set the View. This method includes zero values in the update. func (vu *ViewUpdate) SetView(input *View, fields ...string) *ViewUpdate { m := vu.mutation if len(fields) == 0 { @@ -1681,17 +1681,17 @@ func (vu *ViewUpdate) SetView(input *View, fields ...string) *ViewUpdate { return vu } -// SetViewWithZero set the View -func (vu *ViewUpdate) SetViewWithZero(input *View, fields ...string) *ViewUpdate { +// SetViewSkipZero set the View, skipping zero values. +func (vu *ViewUpdate) SetViewSkipZero(input *View, fields ...string) *ViewUpdate { m := vu.mutation if len(fields) == 0 { - fields = view.Columns + fields = view.OmitColumns(view.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return vu } -// SetView set the View +// SetView set the View. This method includes zero values in the update. func (vuo *ViewUpdateOne) SetView(input *View, fields ...string) *ViewUpdateOne { m := vuo.mutation if len(fields) == 0 { @@ -1701,13 +1701,13 @@ func (vuo *ViewUpdateOne) SetView(input *View, fields ...string) *ViewUpdateOne return vuo } -// SetViewWithZero set the View -func (vuo *ViewUpdateOne) SetViewWithZero(input *View, fields ...string) *ViewUpdateOne { +// SetViewSkipZero set the View, skipping zero values. +func (vuo *ViewUpdateOne) SetViewSkipZero(input *View, fields ...string) *ViewUpdateOne { m := vuo.mutation if len(fields) == 0 { - fields = view.Columns + fields = view.OmitColumns(view.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return vuo } diff --git a/internal/data/entity/ent/viewpermission_update.go b/internal/data/entity/ent/viewpermission_update.go index fd003244..17899ba7 100644 --- a/internal/data/entity/ent/viewpermission_update.go +++ b/internal/data/entity/ent/viewpermission_update.go @@ -637,7 +637,7 @@ func (_u *ViewPermissionUpdateOne) sqlSave(ctx context.Context) (_node *ViewPerm return _node, nil } -// SetViewPermission set the ViewPermission +// SetViewPermission set the ViewPermission. This method includes zero values in the update. func (vpu *ViewPermissionUpdate) SetViewPermission(input *ViewPermission, fields ...string) *ViewPermissionUpdate { m := vpu.mutation if len(fields) == 0 { @@ -647,17 +647,17 @@ func (vpu *ViewPermissionUpdate) SetViewPermission(input *ViewPermission, fields return vpu } -// SetViewPermissionWithZero set the ViewPermission -func (vpu *ViewPermissionUpdate) SetViewPermissionWithZero(input *ViewPermission, fields ...string) *ViewPermissionUpdate { +// SetViewPermissionSkipZero set the ViewPermission, skipping zero values. +func (vpu *ViewPermissionUpdate) SetViewPermissionSkipZero(input *ViewPermission, fields ...string) *ViewPermissionUpdate { m := vpu.mutation if len(fields) == 0 { - fields = viewpermission.Columns + fields = viewpermission.OmitColumns(viewpermission.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return vpu } -// SetViewPermission set the ViewPermission +// SetViewPermission set the ViewPermission. This method includes zero values in the update. func (vpuo *ViewPermissionUpdateOne) SetViewPermission(input *ViewPermission, fields ...string) *ViewPermissionUpdateOne { m := vpuo.mutation if len(fields) == 0 { @@ -667,13 +667,13 @@ func (vpuo *ViewPermissionUpdateOne) SetViewPermission(input *ViewPermission, fi return vpuo } -// SetViewPermissionWithZero set the ViewPermission -func (vpuo *ViewPermissionUpdateOne) SetViewPermissionWithZero(input *ViewPermission, fields ...string) *ViewPermissionUpdateOne { +// SetViewPermissionSkipZero set the ViewPermission, skipping zero values. +func (vpuo *ViewPermissionUpdateOne) SetViewPermissionSkipZero(input *ViewPermission, fields ...string) *ViewPermissionUpdateOne { m := vpuo.mutation if len(fields) == 0 { - fields = viewpermission.Columns + fields = viewpermission.OmitColumns(viewpermission.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return vpuo } diff --git a/internal/data/entity/ent/viewresource_update.go b/internal/data/entity/ent/viewresource_update.go index 8ebe66a3..70589dac 100644 --- a/internal/data/entity/ent/viewresource_update.go +++ b/internal/data/entity/ent/viewresource_update.go @@ -637,7 +637,7 @@ func (_u *ViewResourceUpdateOne) sqlSave(ctx context.Context) (_node *ViewResour return _node, nil } -// SetViewResource set the ViewResource +// SetViewResource set the ViewResource. This method includes zero values in the update. func (vru *ViewResourceUpdate) SetViewResource(input *ViewResource, fields ...string) *ViewResourceUpdate { m := vru.mutation if len(fields) == 0 { @@ -647,17 +647,17 @@ func (vru *ViewResourceUpdate) SetViewResource(input *ViewResource, fields ...st return vru } -// SetViewResourceWithZero set the ViewResource -func (vru *ViewResourceUpdate) SetViewResourceWithZero(input *ViewResource, fields ...string) *ViewResourceUpdate { +// SetViewResourceSkipZero set the ViewResource, skipping zero values. +func (vru *ViewResourceUpdate) SetViewResourceSkipZero(input *ViewResource, fields ...string) *ViewResourceUpdate { m := vru.mutation if len(fields) == 0 { - fields = viewresource.Columns + fields = viewresource.OmitColumns(viewresource.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return vru } -// SetViewResource set the ViewResource +// SetViewResource set the ViewResource. This method includes zero values in the update. func (vruo *ViewResourceUpdateOne) SetViewResource(input *ViewResource, fields ...string) *ViewResourceUpdateOne { m := vruo.mutation if len(fields) == 0 { @@ -667,13 +667,13 @@ func (vruo *ViewResourceUpdateOne) SetViewResource(input *ViewResource, fields . return vruo } -// SetViewResourceWithZero set the ViewResource -func (vruo *ViewResourceUpdateOne) SetViewResourceWithZero(input *ViewResource, fields ...string) *ViewResourceUpdateOne { +// SetViewResourceSkipZero set the ViewResource, skipping zero values. +func (vruo *ViewResourceUpdateOne) SetViewResourceSkipZero(input *ViewResource, fields ...string) *ViewResourceUpdateOne { m := vruo.mutation if len(fields) == 0 { - fields = viewresource.Columns + fields = viewresource.OmitColumns(viewresource.FieldID) } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return vruo } diff --git a/internal/features/system/dal/view.go b/internal/features/system/dal/view.go index a4557b39..6e836907 100644 --- a/internal/features/system/dal/view.go +++ b/internal/features/system/dal/view.go @@ -7,6 +7,9 @@ package dal import ( "context" + "entgo.io/ent/dialect/sql" + "google.golang.org/protobuf/types/known/fieldmaskpb" + "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/view" @@ -26,11 +29,15 @@ func NewViewRepo(db *ent.Database) dto.ViewRepo { // Get retrieves a single view by its ID. func (r *viewRepo) Get(ctx context.Context, id int64, opts ...*dto.ViewQueryOption) (*types.View, error) { - result, err := r.db.View(ctx).Query().Where(view.ID(id)).Only(ctx) + opt := repo.GetFirstOption(opts...) + query := r.db.View(ctx).Query().Where(view.ID(id)) + + query = viewQueryOptions(query, opt) + + result, err := query.Only(ctx) if err != nil { return nil, err } - // Calling the converter, assuming it's generated in the dto package. return dto.ConvertViewToViewPB(result), nil } @@ -50,40 +57,52 @@ func (r *viewRepo) List(ctx context.Context, opts ...*dto.ViewQueryOption) ([]*t query.Where(view.ScopeEQ(opt.Scope)) } + query = viewQueryOptions(query, opt) + result, count, err := db.Find(ctx, query, &opt.QueryOption) if err != nil { return nil, 0, err } - // Calling the converter, assuming it's generated in the dto package. return dto.ConvertViewsToViewsPB(result), count, nil } // Create creates a new view. func (r *viewRepo) Create(ctx context.Context, in *types.View, opts ...*dto.ViewCreateOption) (*types.View, error) { - // Calling the converter, assuming it's generated in the dto package. entView := dto.ConvertViewPBToView(in) - // Assuming a `SetView` method exists, following the `SetUser` pattern. create := r.db.View(ctx).Create().SetView(entView) saved, err := create.Save(ctx) if err != nil { return nil, err } - // Calling the converter, assuming it's generated in the dto package. return dto.ConvertViewToViewPB(saved), nil } -// Update updates an existing view. +// Update updates an existing view. It supports partial updates via FieldMask. func (r *viewRepo) Update(ctx context.Context, in *types.View, opts ...*dto.ViewUpdateOption) (*types.View, error) { - // Calling the converter, assuming it's generated in the dto package. + opt := repo.GetFirstOption(opts...) entView := dto.ConvertViewPBToView(in) - // Assuming a `SetView` method exists, following the `SetUser` pattern. - update := r.db.View(ctx).UpdateOneID(in.Id).SetView(entView) + update := r.db.View(ctx).UpdateOneID(in.Id) + + // The default behavior of SetView now includes zero values. + if opt.UpdateMask == nil || !opt.UpdateMask.IsValid(in) { + update.SetView(entView) // Use the new default SetView + } else { + var updateCols []string + for _, path := range opt.UpdateMask.GetPaths() { + if view.ValidColumn(path) { + updateCols = append(updateCols, path) + } + } + if len(updateCols) > 0 { + update.SetView(entView, updateCols...) // Use the new default SetView + } + } + saved, err := update.Save(ctx) if err != nil { return nil, err } - // Calling the converter, assuming it's generated in the dto package. return dto.ConvertViewToViewPB(saved), nil } @@ -91,3 +110,46 @@ func (r *viewRepo) Update(ctx context.Context, in *types.View, opts ...*dto.View func (r *viewRepo) Delete(ctx context.Context, id int64) error { return r.db.View(ctx).DeleteOneID(id).Exec(ctx) } + +// viewQueryOptions applies common query options to the ViewQuery. +func viewQueryOptions(query *ent.ViewQuery, option *dto.ViewQueryOption) *ent.ViewQuery { + if option == nil { + return query + } + + // Handle FieldMask for field selection + if option.ReadMask != nil { + // Ensure the mask is valid before using it + option.ReadMask.Normalize() + if option.ReadMask.IsValid(new(types.View)) { + var selectCols []string + for _, path := range option.ReadMask.GetPaths() { + // Directly validate against the ent schema definition. + if view.ValidColumn(path) { + selectCols = append(selectCols, path) + } + } + // Only apply select if valid columns were found + if len(selectCols) > 0 { + // Always include the ID for entity hydration + selectCols = append(selectCols, view.FieldID) + query.Select(selectCols...) + } + } + } + + // Handle OrderBy + if len(option.OrderBy) > 0 { + query.Order(viewOrderBy(option.OrderBy)...) + } + return query +} + +func viewOrderBy(fields []string, opts ...sql.OrderTermOption) []view.OrderOption { + var orders []view.OrderOption + for _, field := range fields { + // Here you might also want a map for sorting fields if they differ from DB columns + orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) + } + return orders +} diff --git a/internal/features/system/dto/view.go b/internal/features/system/dto/view.go index 2c06ee15..83066cd9 100644 --- a/internal/features/system/dto/view.go +++ b/internal/features/system/dto/view.go @@ -7,6 +7,9 @@ package dto import ( "context" + + "google.golang.org/protobuf/types/known/fieldmaskpb" + "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/helpers/repo" ) @@ -30,4 +33,6 @@ type ViewQueryOption struct { type ViewCreateOption struct{} // ViewUpdateOption specifies options for updating a view. -type ViewUpdateOption struct{} +type ViewUpdateOption struct { + UpdateMask *fieldmaskpb.FieldMask +} diff --git a/internal/helpers/repo/options.go b/internal/helpers/repo/options.go index 24299f5c..b3a36125 100644 --- a/internal/helpers/repo/options.go +++ b/internal/helpers/repo/options.go @@ -6,6 +6,10 @@ // focusing on abstracting common query patterns like pagination. package repo +import ( + "google.golang.org/protobuf/types/known/fieldmaskpb" +) + const ( // DefaultPageSize is the page size used when the client does not specify one. DefaultPageSize = 10 @@ -52,6 +56,7 @@ type QueryOption struct { OnlyCount bool Keyword string OrderBy []string + ReadMask *fieldmaskpb.FieldMask // Use FieldMask for field selection } // OptionFromRequest creates a QueryOption with common details @@ -80,6 +85,13 @@ func OptionFromRequest(req interface{}) QueryOption { opt.Keyword = r.GetKeyword() } + // This is a generic helper. The ReadMask should be populated from the specific + // request type in the service layer, as the field name (`read_mask`) can vary. + // Example in service layer: + // if r, ok := req.(interface{ GetReadMask() *fieldmaskpb.FieldMask }); ok { + // opt.ReadMask = r.GetReadMask() + // } + return opt } From aa1303659dad0f4e0e42855b739ea97221418b82 Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 26 Dec 2025 02:15:44 +0800 Subject: [PATCH 099/158] refactor(system): consolidate view repository logic and move common db helpers to shared package --- internal/features/system/dal/view.go | 89 +++++++++------------------- internal/features/system/dto/view.go | 2 +- internal/helpers/db/db.go | 38 +++++++++++- internal/helpers/repo/options.go | 16 ++++- 4 files changed, 77 insertions(+), 68 deletions(-) diff --git a/internal/features/system/dal/view.go b/internal/features/system/dal/view.go index 6e836907..2a64c91e 100644 --- a/internal/features/system/dal/view.go +++ b/internal/features/system/dal/view.go @@ -7,9 +7,6 @@ package dal import ( "context" - "entgo.io/ent/dialect/sql" - "google.golang.org/protobuf/types/known/fieldmaskpb" - "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/view" @@ -23,8 +20,8 @@ type viewRepo struct { } // NewViewRepo creates a new view repository. -func NewViewRepo(db *ent.Database) dto.ViewRepo { - return &viewRepo{db: db} +func NewViewRepo(database *ent.Database) dto.ViewRepo { + return &viewRepo{db: database} } // Get retrieves a single view by its ID. @@ -32,7 +29,12 @@ func (r *viewRepo) Get(ctx context.Context, id int64, opts ...*dto.ViewQueryOpti opt := repo.GetFirstOption(opts...) query := r.db.View(ctx).Query().Where(view.ID(id)) - query = viewQueryOptions(query, opt) + if opt.ReadMask != nil { + selectCols := db.SelectFields(opt.ReadMask, view.ValidColumn, new(types.View)) + if len(selectCols) > 0 { + query.Select(selectCols...) + } + } result, err := query.Only(ctx) if err != nil { @@ -57,7 +59,19 @@ func (r *viewRepo) List(ctx context.Context, opts ...*dto.ViewQueryOption) ([]*t query.Where(view.ScopeEQ(opt.Scope)) } - query = viewQueryOptions(query, opt) + if opt.ReadMask != nil { + selectCols := db.SelectFields(opt.ReadMask, view.ValidColumn, new(types.View)) + if len(selectCols) > 0 { + query.Select(selectCols...) + } + } + + if opt.OrderBy != nil { + orders := db.OrderBy[view.OrderOption](opt.OrderBy) + if len(orders) > 0 { + query.Order(orders...) + } + } result, count, err := db.Find(ctx, query, &opt.QueryOption) if err != nil { @@ -70,6 +84,7 @@ func (r *viewRepo) List(ctx context.Context, opts ...*dto.ViewQueryOption) ([]*t // Create creates a new view. func (r *viewRepo) Create(ctx context.Context, in *types.View, opts ...*dto.ViewCreateOption) (*types.View, error) { entView := dto.ConvertViewPBToView(in) + // After template modification, SetView is now the method that includes zero values. create := r.db.View(ctx).Create().SetView(entView) saved, err := create.Save(ctx) if err != nil { @@ -84,19 +99,12 @@ func (r *viewRepo) Update(ctx context.Context, in *types.View, opts ...*dto.View entView := dto.ConvertViewPBToView(in) update := r.db.View(ctx).UpdateOneID(in.Id) - // The default behavior of SetView now includes zero values. - if opt.UpdateMask == nil || !opt.UpdateMask.IsValid(in) { - update.SetView(entView) // Use the new default SetView + // After template modification, SetView is now the method that includes zero values. + updateCols := db.UpdateFields(opt.UpdateMask, view.ValidColumn, in) + if len(updateCols) > 0 { + update.SetView(entView, updateCols...) } else { - var updateCols []string - for _, path := range opt.UpdateMask.GetPaths() { - if view.ValidColumn(path) { - updateCols = append(updateCols, path) - } - } - if len(updateCols) > 0 { - update.SetView(entView, updateCols...) // Use the new default SetView - } + update.SetView(entView) } saved, err := update.Save(ctx) @@ -110,46 +118,3 @@ func (r *viewRepo) Update(ctx context.Context, in *types.View, opts ...*dto.View func (r *viewRepo) Delete(ctx context.Context, id int64) error { return r.db.View(ctx).DeleteOneID(id).Exec(ctx) } - -// viewQueryOptions applies common query options to the ViewQuery. -func viewQueryOptions(query *ent.ViewQuery, option *dto.ViewQueryOption) *ent.ViewQuery { - if option == nil { - return query - } - - // Handle FieldMask for field selection - if option.ReadMask != nil { - // Ensure the mask is valid before using it - option.ReadMask.Normalize() - if option.ReadMask.IsValid(new(types.View)) { - var selectCols []string - for _, path := range option.ReadMask.GetPaths() { - // Directly validate against the ent schema definition. - if view.ValidColumn(path) { - selectCols = append(selectCols, path) - } - } - // Only apply select if valid columns were found - if len(selectCols) > 0 { - // Always include the ID for entity hydration - selectCols = append(selectCols, view.FieldID) - query.Select(selectCols...) - } - } - } - - // Handle OrderBy - if len(option.OrderBy) > 0 { - query.Order(viewOrderBy(option.OrderBy)...) - } - return query -} - -func viewOrderBy(fields []string, opts ...sql.OrderTermOption) []view.OrderOption { - var orders []view.OrderOption - for _, field := range fields { - // Here you might also want a map for sorting fields if they differ from DB columns - orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) - } - return orders -} diff --git a/internal/features/system/dto/view.go b/internal/features/system/dto/view.go index 83066cd9..bfb7a610 100644 --- a/internal/features/system/dto/view.go +++ b/internal/features/system/dto/view.go @@ -34,5 +34,5 @@ type ViewCreateOption struct{} // ViewUpdateOption specifies options for updating a view. type ViewUpdateOption struct { - UpdateMask *fieldmaskpb.FieldMask + repo.UpdateOption } diff --git a/internal/helpers/db/db.go b/internal/helpers/db/db.go index 0b2608e6..2dcfded6 100644 --- a/internal/helpers/db/db.go +++ b/internal/helpers/db/db.go @@ -8,11 +8,43 @@ package db import ( "entgo.io/ent/dialect/sql" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/fieldmaskpb" ) -// This file is intentionally left blank after refactoring. -// Common interfaces or future helpers can be added here. - +// selectable is a generic constraint for types that can be used as order functions in Ent. +// It's an alias for any type whose underlying type is func(*sql.Selector). type selectable interface { ~func(*sql.Selector) } + +// ColumnValidator is a function type for validating if a string is a valid column name for an entity. +type ColumnValidator func(string) bool + +func SelectFields(mask *fieldmaskpb.FieldMask, validator ColumnValidator, messageType proto.Message) []string { + var selectCols []string + if mask != nil { + mask.Normalize() + if mask.IsValid(messageType) { + for _, path := range mask.GetPaths() { + if validator(path) { + selectCols = append(selectCols, path) + } + } + } + } + return selectCols +} + +func UpdateFields(mask *fieldmaskpb.FieldMask, validator ColumnValidator, messageType proto.Message) []string { + var updateCols []string + if mask == nil || !mask.IsValid(messageType) { + return updateCols + } + for _, path := range mask.GetPaths() { + if validator(path) { + updateCols = append(updateCols, path) + } + } + return updateCols +} diff --git a/internal/helpers/repo/options.go b/internal/helpers/repo/options.go index b3a36125..866f705a 100644 --- a/internal/helpers/repo/options.go +++ b/internal/helpers/repo/options.go @@ -59,9 +59,9 @@ type QueryOption struct { ReadMask *fieldmaskpb.FieldMask // Use FieldMask for field selection } -// OptionFromRequest creates a QueryOption with common details +// QueryOptionFromRequest creates a QueryOption with common details // extracted from any request that satisfies the supported interfaces. -func OptionFromRequest(req interface{}) QueryOption { +func QueryOptionFromRequest(req interface{}) QueryOption { opt := QueryOption{} if r, ok := req.(PaginatingRequest); ok { @@ -95,6 +95,18 @@ func OptionFromRequest(req interface{}) QueryOption { return opt } +type UpdateOption struct { + UpdateMask *fieldmaskpb.FieldMask +} + +func UpdateOptionFromRequest(req interface{}) UpdateOption { + opt := UpdateOption{} + if r, ok := req.(interface{ GetUpdateMask() *fieldmaskpb.FieldMask }); ok { + opt.UpdateMask = r.GetUpdateMask() + } + return opt +} + // GetFirstOption safely retrieves the first option from a slice of option pointers. // If the slice is empty or the first element is nil, it returns a new, non-nil instance of the option type. func GetFirstOption[T any](opts ...*T) *T { From 2e6e776578394eeb7e5ca4c916a57100b5a4be58 Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 26 Dec 2025 02:48:31 +0800 Subject: [PATCH 100/158] feat(db): implement field mask support for selective query and update operations --- internal/features/system/dal/permission.go | 55 +++++++++++------ internal/features/system/dal/resource.go | 53 ++++++++++++----- internal/features/system/dal/role.go | 50 ++++++++++++---- internal/features/system/dal/user.go | 58 ++++++++++++------ internal/features/system/dal/view.go | 6 +- internal/features/system/dto/permission.go | 30 +++++++++- internal/features/system/dto/resource.go | 13 +++- internal/features/system/dto/role.go | 13 +++- internal/features/system/dto/user.go | 15 ++++- internal/features/system/dto/view.go | 24 +++++++- internal/features/system/server/server.go | 1 - internal/features/system/service/view.go | 56 ++++++++++++++++++ internal/helpers/db/db.go | 69 ++++++++++++++-------- internal/helpers/db/pagination.go | 10 +++- internal/helpers/db/sorting.go | 4 +- 15 files changed, 352 insertions(+), 105 deletions(-) create mode 100644 internal/features/system/service/view.go diff --git a/internal/features/system/dal/permission.go b/internal/features/system/dal/permission.go index cfec7b0b..fb59b7c4 100644 --- a/internal/features/system/dal/permission.go +++ b/internal/features/system/dal/permission.go @@ -11,6 +11,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/permission" "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/db" "origadmin/application/admin/internal/helpers/repo" ) @@ -19,8 +20,8 @@ type permissionRepo struct { } // NewPermissionRepo . -func NewPermissionRepo(db *ent.Database) dto.PermissionRepo { - return &permissionRepo{db: db} +func NewPermissionRepo(database *ent.Database) dto.PermissionRepo { + return &permissionRepo{db: database} } func (r *permissionRepo) Get(ctx context.Context, id int64, opts ...*dto.PermissionQueryOption) (*types.Permission, error) { @@ -34,6 +35,13 @@ func (r *permissionRepo) Get(ctx context.Context, id int64, opts ...*dto.Permiss query.WithRoles() } + if opt.ReadMask != nil { + selectCols := db.SelectFields(opt.ReadMask, permission.ValidColumn, permission.FieldID, new(types.Permission)) + if len(selectCols) > 0 { + query.Select(selectCols...) + } + } + result, err := query.Only(ctx) if err != nil { return nil, err @@ -45,8 +53,6 @@ func (r *permissionRepo) Create(ctx context.Context, p *types.Permission, opts . entPermission := dto.ConvertPermissionPBToPermission(p) create := r.db.Permission(ctx).Create().SetPermission(entPermission) - // ... set other fields - saved, err := create.Save(ctx) if err != nil { return nil, err @@ -59,10 +65,16 @@ func (r *permissionRepo) Delete(ctx context.Context, id int64) error { } func (r *permissionRepo) Update(ctx context.Context, p *types.Permission, opts ...*dto.PermissionUpdateOption) (*types.Permission, error) { + opt := repo.GetFirstOption(opts...) entPermission := dto.ConvertPermissionPBToPermission(p) - update := r.db.Permission(ctx).UpdateOneID(p.Id).SetPermission(entPermission) + update := r.db.Permission(ctx).UpdateOneID(p.Id) - // ... handle partial updates based on opts ... + updateCols := db.UpdateFields(opt.UpdateMask, permission.ValidColumn, p) + if len(updateCols) > 0 { + update.SetPermission(entPermission, updateCols...) + } else { + update.SetPermission(entPermission) + } saved, err := update.Save(ctx) if err != nil { @@ -79,15 +91,6 @@ func (r *permissionRepo) List(ctx context.Context, opts ...*dto.PermissionQueryO query.Where(permission.DataScopeIn(opt.DataScopes...)) } - if opt.Page > 0 && opt.PageSize > 0 { - query.Offset((opt.Page - 1) * opt.PageSize).Limit(opt.PageSize) - } - - count, err := query.Clone().Count(ctx) - if err != nil { - return nil, 0, err - } - if opt.WithResources { query.WithResources() } @@ -95,6 +98,24 @@ func (r *permissionRepo) List(ctx context.Context, opts ...*dto.PermissionQueryO query.WithRoles() } - result, err := query.All(ctx) - return dto.ConvertPermissionsToPermissionsPB(result), int32(count), err + if opt.ReadMask != nil { + selectCols := db.SelectFields(opt.ReadMask, permission.ValidColumn, permission.FieldID, new(types.Permission)) + if len(selectCols) > 0 { + query.Select(selectCols...) + } + } + + if opt.OrderBy != nil { + orders := db.OrderBy[permission.OrderOption](opt.OrderBy) + if len(orders) > 0 { + query.Order(orders...) + } + } + + result, count, err := db.Find(ctx, query, &opt.QueryOption) + if err != nil { + return nil, 0, err + } + + return dto.ConvertPermissionsToPermissionsPB(result), count, err } diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index 6316daf1..27ee36bc 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -12,6 +12,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/db" "origadmin/application/admin/internal/helpers/repo" ) @@ -21,9 +22,9 @@ type resourceRepo struct { } // NewResourceRepo . -func NewResourceRepo(db *ent.Database) dto.ResourceRepo { +func NewResourceRepo(database *ent.Database) dto.ResourceRepo { return &resourceRepo{ - db: db, + db: database, Delimiter: "/", } } @@ -36,6 +37,13 @@ func (r *resourceRepo) Get(ctx context.Context, id int64, opts ...*dto.ResourceQ query.WithPermissions() } + if opt.ReadMask != nil { + selectCols := db.SelectFields(opt.ReadMask, resource.ValidColumn, resource.FieldID, new(types.Resource)) + if len(selectCols) > 0 { + query.Select(selectCols...) + } + } + result, err := query.Only(ctx) if err != nil { return nil, err @@ -49,14 +57,12 @@ func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ... if err != nil { return nil, err } - res.TreePath = parent.TreePath + strconv.FormatInt(int64(parent.ID), 10) + r.Delimiter + res.TreePath = parent.TreePath + strconv.FormatInt(parent.ID, 10) + r.Delimiter } entResource := dto.ConvertResourcePBToResource(res) create := r.db.Resource(ctx).Create().SetResource(entResource) - // ... set other fields - saved, err := create.Save(ctx) if err != nil { return nil, err @@ -69,10 +75,16 @@ func (r *resourceRepo) Delete(ctx context.Context, id int64) error { } func (r *resourceRepo) Update(ctx context.Context, res *types.Resource, opts ...*dto.ResourceUpdateOption) (*types.Resource, error) { + opt := repo.GetFirstOption(opts...) entResource := dto.ConvertResourcePBToResource(res) - update := r.db.Resource(ctx).UpdateOneID(res.Id).SetResource(entResource) + update := r.db.Resource(ctx).UpdateOneID(res.Id) - // ... handle partial updates based on opts ... + updateCols := db.UpdateFields(opt.UpdateMask, resource.ValidColumn, res) + if len(updateCols) > 0 { + update.SetResource(entResource, updateCols...) + } else { + update.SetResource(entResource) + } saved, err := update.Save(ctx) if err != nil { @@ -85,19 +97,28 @@ func (r *resourceRepo) List(ctx context.Context, opts ...*dto.ResourceQueryOptio opt := repo.GetFirstOption(opts...) query := r.db.Resource(ctx).Query() - if opt.Page > 0 && opt.PageSize > 0 { - query.Offset((opt.Page - 1) * opt.PageSize).Limit(opt.PageSize) + if opt.WithPermissions { + query.WithPermissions() } - count, err := query.Clone().Count(ctx) - if err != nil { - return nil, 0, err + if opt.ReadMask != nil { + selectCols := db.SelectFields(opt.ReadMask, resource.ValidColumn, resource.FieldID, new(types.Resource)) + if len(selectCols) > 0 { + query.Select(selectCols...) + } } - if opt.WithPermissions { - query.WithPermissions() + if opt.OrderBy != nil { + orders := db.OrderBy[resource.OrderOption](opt.OrderBy) + if len(orders) > 0 { + query.Order(orders...) + } + } + + result, count, err := db.Find(ctx, query, &opt.QueryOption) + if err != nil { + return nil, 0, err } - result, err := query.All(ctx) - return dto.ConvertResourcesToResourcesPB(result), int32(count), err + return dto.ConvertResourcesToResourcesPB(result), count, err } diff --git a/internal/features/system/dal/role.go b/internal/features/system/dal/role.go index 763dc205..867918d1 100644 --- a/internal/features/system/dal/role.go +++ b/internal/features/system/dal/role.go @@ -13,6 +13,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/role" "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/db" "origadmin/application/admin/internal/helpers/repo" ) @@ -22,9 +23,9 @@ type roleRepo struct { } // NewRoleRepo . -func NewRoleRepo(db *ent.Database) dto.RoleRepo { +func NewRoleRepo(database *ent.Database) dto.RoleRepo { generator := rand.NewGenerator(rand.KindDigit | rand.KindLowerCase) - return &roleRepo{db: db, gen: generator} + return &roleRepo{db: database, gen: generator} } func (r *roleRepo) Get(ctx context.Context, id int64, opts ...*dto.RoleQueryOption) (*types.Role, error) { @@ -35,6 +36,13 @@ func (r *roleRepo) Get(ctx context.Context, id int64, opts ...*dto.RoleQueryOpti query.WithPermissions() } + if opt.ReadMask != nil { + selectCols := db.SelectFields(opt.ReadMask, role.ValidColumn, role.FieldID, new(types.Role)) + if len(selectCols) > 0 { + query.Select(selectCols...) + } + } + result, err := query.Only(ctx) if err != nil { return nil, err @@ -70,9 +78,16 @@ func (r *roleRepo) Delete(ctx context.Context, id int64) error { } func (r *roleRepo) Update(ctx context.Context, rl *types.Role, opts ...*dto.RoleUpdateOption) (*types.Role, error) { + opt := repo.GetFirstOption(opts...) entRole := dto.ConvertRolePBToRole(rl) - update := r.db.Role(ctx).UpdateOneID(rl.Id).SetRole(entRole) - // ... handle partial updates based on opts ... + update := r.db.Role(ctx).UpdateOneID(rl.Id) + + updateCols := db.UpdateFields(opt.UpdateMask, role.ValidColumn, rl) + if len(updateCols) > 0 { + update.SetRole(entRole, updateCols...) + } else { + update.SetRole(entRole) + } saved, err := update.Save(ctx) if err != nil { @@ -89,21 +104,30 @@ func (r *roleRepo) List(ctx context.Context, opts ...*dto.RoleQueryOption) ([]*t query.Where(role.NameContainsFold(opt.Keyword)) } - if opt.Page > 0 && opt.PageSize > 0 { - query.Offset((opt.Page - 1) * opt.PageSize).Limit(opt.PageSize) + if opt.WithPermissions { + query.WithPermissions() } - count, err := query.Clone().Count(ctx) - if err != nil { - return nil, 0, err + if opt.ReadMask != nil { + selectCols := db.SelectFields(opt.ReadMask, role.ValidColumn, role.FieldID, new(types.Role)) + if len(selectCols) > 0 { + query.Select(selectCols...) + } } - if opt.WithPermissions { - query.WithPermissions() + if opt.OrderBy != nil { + orders := db.OrderBy[role.OrderOption](opt.OrderBy) + if len(orders) > 0 { + query.Order(orders...) + } + } + + result, count, err := db.Find(ctx, query, &opt.QueryOption) + if err != nil { + return nil, 0, err } - result, err := query.All(ctx) - return dto.ConvertRolesToRolesPB(result), int32(count), err + return dto.ConvertRolesToRolesPB(result), count, err } func (r *roleRepo) GetPermissions(ctx context.Context, id int64) ([]*types.Permission, error) { diff --git a/internal/features/system/dal/user.go b/internal/features/system/dal/user.go index 5de322a4..7f086c36 100644 --- a/internal/features/system/dal/user.go +++ b/internal/features/system/dal/user.go @@ -13,7 +13,9 @@ import ( "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/features/system/dto" + "origadmin/application/admin/internal/helpers/db" "origadmin/application/admin/internal/helpers/repo" ) @@ -22,8 +24,8 @@ type userRepo struct { } // NewUserRepo . -func NewUserRepo(db *ent.Database) dto.UserRepo { - return &userRepo{db: db} +func NewUserRepo(database *ent.Database) dto.UserRepo { + return &userRepo{db: database} } func (r *userRepo) Get(ctx context.Context, id int64, opts ...*dto.UserQueryOption) (*types.User, error) { @@ -34,6 +36,13 @@ func (r *userRepo) Get(ctx context.Context, id int64, opts ...*dto.UserQueryOpti query.WithRoles() } + if opt.ReadMask != nil { + selectCols := db.SelectFields(opt.ReadMask, user.ValidColumn, user.FieldID, new(types.User)) + if len(selectCols) > 0 { + query.Select(selectCols...) + } + } + result, err := query.Only(ctx) if err != nil { return nil, err @@ -48,11 +57,11 @@ func (r *userRepo) Create(ctx context.Context, u *types.User, password string, o } entUser := dto.ConvertUserPBToUser(u) - uuid, err := uuid.NewRandom() + uid, err := uuid.NewRandom() if err != nil { return nil, err } - entUser.UUID = uuid.String() + entUser.UUID = uid.String() if password != "" { entUser.EncryptedPassword = password } @@ -69,10 +78,16 @@ func (r *userRepo) Delete(ctx context.Context, id int64) error { } func (r *userRepo) Update(ctx context.Context, u *types.User, opts ...*dto.UserUpdateOption) (*types.User, error) { + opt := repo.GetFirstOption(opts...) entUser := dto.ConvertUserPBToUser(u) - update := r.db.User(ctx).UpdateOneID(u.Id).SetUser(entUser) + update := r.db.User(ctx).UpdateOneID(u.Id) - // ... handle partial updates based on opts + updateCols := db.UpdateFields(opt.UpdateMask, user.ValidColumn, u) + if len(updateCols) > 0 { + update.SetUser(entUser, updateCols...) + } else { + update.SetUser(entUser) + } saved, err := update.Save(ctx) if err != nil { @@ -89,21 +104,30 @@ func (r *userRepo) List(ctx context.Context, opts ...*dto.UserQueryOption) ([]*t query.Where(user.Or(user.UsernameContainsFold(opt.Keyword), user.PhoneContainsFold(opt.Keyword), user.EmailContainsFold(opt.Keyword))) } - if opt.Page > 0 && opt.PageSize > 0 { - query.Offset((opt.Page - 1) * opt.PageSize).Limit(opt.PageSize) + if opt.WithRoles { + query.WithRoles() } - count, err := query.Clone().Count(ctx) - if err != nil { - return nil, 0, err + if opt.ReadMask != nil { + selectCols := db.SelectFields(opt.ReadMask, user.ValidColumn, user.FieldID, new(types.User)) + if len(selectCols) > 0 { + query.Select(selectCols...) + } } - if opt.WithRoles { - query.WithRoles() + if opt.OrderBy != nil { + orders := db.OrderBy[user.OrderOption](opt.OrderBy) + if len(orders) > 0 { + query.Order(orders...) + } + } + + result, count, err := db.Find(ctx, query, &opt.QueryOption) + if err != nil { + return nil, 0, err } - result, err := query.All(ctx) - return dto.ConvertUsersToUsersPB(result), int32(count), err + return dto.ConvertUsersToUsersPB(result), count, err } func (r *userRepo) AddRoleIDs(ctx context.Context, id int64, roleIDs []int64) error { @@ -134,6 +158,6 @@ func (r *userRepo) ListResourceByUserID(ctx context.Context, id int64) ([]*types return dto.ConvertResourcesToResourcesPB(resources), nil } -func (r *userRepo) UpdateUserStatus(ctx context.Context, id int64, status int32) error { - return r.db.User(ctx).UpdateOneID(id).SetStatus(int8(status)).Exec(ctx) +func (r *userRepo) UpdateUserStatus(ctx context.Context, id int64, status int8) error { + return r.db.User(ctx).UpdateOneID(id).SetStatus(enums.Status(status)).Exec(ctx) } diff --git a/internal/features/system/dal/view.go b/internal/features/system/dal/view.go index 2a64c91e..254f26dd 100644 --- a/internal/features/system/dal/view.go +++ b/internal/features/system/dal/view.go @@ -30,7 +30,7 @@ func (r *viewRepo) Get(ctx context.Context, id int64, opts ...*dto.ViewQueryOpti query := r.db.View(ctx).Query().Where(view.ID(id)) if opt.ReadMask != nil { - selectCols := db.SelectFields(opt.ReadMask, view.ValidColumn, new(types.View)) + selectCols := db.SelectFields(opt.ReadMask, view.ValidColumn, view.FieldID, new(types.View)) if len(selectCols) > 0 { query.Select(selectCols...) } @@ -60,7 +60,7 @@ func (r *viewRepo) List(ctx context.Context, opts ...*dto.ViewQueryOption) ([]*t } if opt.ReadMask != nil { - selectCols := db.SelectFields(opt.ReadMask, view.ValidColumn, new(types.View)) + selectCols := db.SelectFields(opt.ReadMask, view.ValidColumn, view.FieldID, new(types.View)) if len(selectCols) > 0 { query.Select(selectCols...) } @@ -102,6 +102,8 @@ func (r *viewRepo) Update(ctx context.Context, in *types.View, opts ...*dto.View // After template modification, SetView is now the method that includes zero values. updateCols := db.UpdateFields(opt.UpdateMask, view.ValidColumn, in) if len(updateCols) > 0 { + // The primary key should never be in the update list. + // UpdateFields already ensures this. update.SetView(entView, updateCols...) } else { update.SetView(entView) diff --git a/internal/features/system/dto/permission.go b/internal/features/system/dto/permission.go index 908bb34c..e6fe1ceb 100644 --- a/internal/features/system/dto/permission.go +++ b/internal/features/system/dto/permission.go @@ -9,6 +9,7 @@ import ( "context" "time" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/helpers/repo" ) @@ -25,14 +26,18 @@ type PermissionRepo interface { // PermissionQueryOption specifies options for querying permissions. type PermissionQueryOption struct { repo.QueryOption - DataScopes []string + DataScopes []string + WithResources bool + WithRoles bool } // PermissionCreateOption specifies options for creating a permission. type PermissionCreateOption struct{} // PermissionUpdateOption specifies options for updating a permission. -type PermissionUpdateOption struct{} +type PermissionUpdateOption struct { + repo.UpdateOption +} // PermissionCondition represents a single condition for a permission. type PermissionCondition struct { @@ -49,3 +54,24 @@ type PermissionAccessControl struct { ValidUntil *time.Time `json:"valid_until"` Attributes map[string]any `json:"attributes"` } + +// ListPermissionsRequestToQueryOption converts an API request to a query option object. +func ListPermissionsRequestToQueryOption(req *system.ListPermissionsRequest) *PermissionQueryOption { + if req == nil { + return &PermissionQueryOption{} + } + return &PermissionQueryOption{ + QueryOption: repo.QueryOptionFromRequest(req), + DataScopes: req.GetDataScopes(), + } +} + +// UpdatePermissionRequestToUpdateOption converts an API request to an update option object. +func UpdatePermissionRequestToUpdateOption(req *system.UpdatePermissionRequest) *PermissionUpdateOption { + if req == nil { + return &PermissionUpdateOption{} + } + return &PermissionUpdateOption{ + UpdateOption: repo.UpdateOptionFromRequest(req), + } +} diff --git a/internal/features/system/dto/resource.go b/internal/features/system/dto/resource.go index 59a7e687..7a9d5053 100644 --- a/internal/features/system/dto/resource.go +++ b/internal/features/system/dto/resource.go @@ -34,6 +34,7 @@ type ResourceCreateOption struct { // ResourceUpdateOption specifies options for updating a resource. type ResourceUpdateOption struct { + repo.UpdateOption } // ListResourcesRequestToQueryOption converts an API request to a query option object. @@ -42,6 +43,16 @@ func ListResourcesRequestToQueryOption(req *system.ListResourcesRequest) *Resour return &ResourceQueryOption{} } return &ResourceQueryOption{ - QueryOption: repo.OptionFromRequest(req), + QueryOption: repo.QueryOptionFromRequest(req), + } +} + +// UpdateResourceRequestToUpdateOption converts an API request to an update option object. +func UpdateResourceRequestToUpdateOption(req *system.UpdateResourceRequest) *ResourceUpdateOption { + if req == nil { + return &ResourceUpdateOption{} + } + return &ResourceUpdateOption{ + UpdateOption: repo.UpdateOptionFromRequest(req), } } diff --git a/internal/features/system/dto/role.go b/internal/features/system/dto/role.go index d48dabc5..57ff8617 100644 --- a/internal/features/system/dto/role.go +++ b/internal/features/system/dto/role.go @@ -38,6 +38,7 @@ type RoleCreateOption struct { // RoleUpdateOption specifies options for updating a role. type RoleUpdateOption struct { + repo.UpdateOption } // ListRolesRequestToQueryOption converts an API request to a query option object. @@ -46,6 +47,16 @@ func ListRolesRequestToQueryOption(req *system.ListRolesRequest) *RoleQueryOptio return &RoleQueryOption{} } return &RoleQueryOption{ - QueryOption: repo.OptionFromRequest(req), + QueryOption: repo.QueryOptionFromRequest(req), + } +} + +// UpdateRoleRequestToUpdateOption converts an API request to an update option object. +func UpdateRoleRequestToUpdateOption(req *system.UpdateRoleRequest) *RoleUpdateOption { + if req == nil { + return &RoleUpdateOption{} + } + return &RoleUpdateOption{ + UpdateOption: repo.UpdateOptionFromRequest(req), } } diff --git a/internal/features/system/dto/user.go b/internal/features/system/dto/user.go index 6ba5c2f0..97d55e7b 100644 --- a/internal/features/system/dto/user.go +++ b/internal/features/system/dto/user.go @@ -43,8 +43,7 @@ type UserCreateOption struct { // UserUpdateOption specifies options for updating a user. type UserUpdateOption struct { - // Example: For partial updates (PATCH) - UpdateFields []string + repo.UpdateOption } // ListUsersRequestToQueryOption converts an API request to a query option object. @@ -53,6 +52,16 @@ func ListUsersRequestToQueryOption(req *system.ListUsersRequest) *UserQueryOptio return &UserQueryOption{} } return &UserQueryOption{ - QueryOption: repo.OptionFromRequest(req), + QueryOption: repo.QueryOptionFromRequest(req), + } +} + +// UpdateUserRequestToUpdateOption converts an API request to an update option object. +func UpdateUserRequestToUpdateOption(req *system.UpdateUserRequest) *UserUpdateOption { + if req == nil { + return &UserUpdateOption{} + } + return &UserUpdateOption{ + UpdateOption: repo.UpdateOptionFromRequest(req), } } diff --git a/internal/features/system/dto/view.go b/internal/features/system/dto/view.go index bfb7a610..580e9bf7 100644 --- a/internal/features/system/dto/view.go +++ b/internal/features/system/dto/view.go @@ -8,8 +8,7 @@ package dto import ( "context" - "google.golang.org/protobuf/types/known/fieldmaskpb" - + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/helpers/repo" ) @@ -36,3 +35,24 @@ type ViewCreateOption struct{} type ViewUpdateOption struct { repo.UpdateOption } + +// ListViewsRequestToQueryOption converts an API request to a query option object. +func ListViewsRequestToQueryOption(req *system.ListViewsRequest) *ViewQueryOption { + if req == nil { + return &ViewQueryOption{} + } + return &ViewQueryOption{ + QueryOption: repo.QueryOptionFromRequest(req), + Scope: req.GetScope(), + } +} + +// UpdateViewRequestToUpdateOption converts an API request to an update option object. +func UpdateViewRequestToUpdateOption(req *system.UpdateViewRequest) *ViewUpdateOption { + if req == nil { + return &ViewUpdateOption{} + } + return &ViewUpdateOption{ + UpdateOption: repo.UpdateOptionFromRequest(req), + } +} diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index 3120b629..a11af48f 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -39,7 +39,6 @@ func NewServers(cfg *transportv1.Servers, svc *service.SystemService, logger log if err != nil { return nil, err } - srv.Server transportServers = append(transportServers, srv) case "grpc": srv, err := NewGRPCServer(serverCfg.GetGrpc(), svc, logger) diff --git a/internal/features/system/service/view.go b/internal/features/system/service/view.go new file mode 100644 index 00000000..0599e562 --- /dev/null +++ b/internal/features/system/service/view.go @@ -0,0 +1,56 @@ +package service + +import ( + "context" + "origadmin/application/admin/api/v1/services/system" +) + +// ListViews handles the RPC for listing views. +func (s *SystemService) ListViews(ctx context.Context, req *system.ListViewsRequest) (*system.ListViewsResponse, error) { + views, total, err := s.View.ListViews(ctx, req) + if err != nil { + return nil, err + } + return &system.ListViewsResponse{ + Views: views, + Total: total, + Page: req.GetPage(), + PageSize: req.GetPageSize(), + }, nil +} + +// GetView handles the RPC for getting a single view. +func (s *SystemService) GetView(ctx context.Context, req *system.GetViewRequest) (*system.GetViewResponse, error) { + view, err := s.View.GetView(ctx, req.GetId()) + if err != nil { + return nil, err + } + return &system.GetViewResponse{View: view}, nil +} + +// CreateView handles the RPC for creating a new view. +func (s *SystemService) CreateView(ctx context.Context, req *system.CreateViewRequest) (*system.CreateViewResponse, error) { + view, err := s.View.CreateView(ctx, req.GetView()) + if err != nil { + return nil, err + } + return &system.CreateViewResponse{View: view}, nil +} + +// UpdateView handles the RPC for updating an existing view. +func (s *SystemService) UpdateView(ctx context.Context, req *system.UpdateViewRequest) (*system.UpdateViewResponse, error) { + view, err := s.View.UpdateView(ctx, req.GetView()) + if err != nil { + return nil, err + } + return &system.UpdateViewResponse{View: view}, nil +} + +// DeleteView handles the RPC for deleting a view. +func (s *SystemService) DeleteView(ctx context.Context, req *system.DeleteViewRequest) (*system.DeleteViewResponse, error) { + err := s.View.DeleteView(ctx, req.GetId()) + if err != nil { + return nil, err + } + return &system.DeleteViewResponse{}, nil +} diff --git a/internal/helpers/db/db.go b/internal/helpers/db/db.go index 2dcfded6..3d46673d 100644 --- a/internal/helpers/db/db.go +++ b/internal/helpers/db/db.go @@ -7,44 +7,61 @@ package db import ( - "entgo.io/ent/dialect/sql" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/fieldmaskpb" ) -// selectable is a generic constraint for types that can be used as order functions in Ent. -// It's an alias for any type whose underlying type is func(*sql.Selector). -type selectable interface { - ~func(*sql.Selector) -} - // ColumnValidator is a function type for validating if a string is a valid column name for an entity. type ColumnValidator func(string) bool -func SelectFields(mask *fieldmaskpb.FieldMask, validator ColumnValidator, messageType proto.Message) []string { - var selectCols []string - if mask != nil { - mask.Normalize() - if mask.IsValid(messageType) { - for _, path := range mask.GetPaths() { - if validator(path) { - selectCols = append(selectCols, path) - } +// processMask is an unexported helper that contains the common logic for processing a FieldMask. +// It normalizes, validates, and filters the paths in the mask, returning a slice of valid column names. +func processMask(mask *fieldmaskpb.FieldMask, validator ColumnValidator, messageType proto.Message) []string { + if mask == nil { + return nil + } + // Normalize must be called before IsValid. + mask.Normalize() + if !mask.IsValid(messageType) { + return nil + } + + var cols []string + for _, path := range mask.GetPaths() { + if validator(path) { + cols = append(cols, path) + } + } + return cols +} + +// SelectFields parses a ReadMask and returns a slice of column names for selection. +// CRITICAL: It automatically adds the primary key (idField) to the selection if other fields are selected, +// which is essential for ent to hydrate the model correctly. +func SelectFields(mask *fieldmaskpb.FieldMask, validator ColumnValidator, idField string, messageType proto.Message) []string { + selectCols := processMask(mask, validator, messageType) + + // If any columns are selected, always ensure the ID field is also selected. + if len(selectCols) > 0 { + hasID := false + for _, col := range selectCols { + if col == idField { + hasID = true + break } } + if !hasID { + selectCols = append(selectCols, idField) + } } + return selectCols } +// UpdateFields parses an UpdateMask and returns a slice of column names for a partial update. +// It will NOT add the ID field. func UpdateFields(mask *fieldmaskpb.FieldMask, validator ColumnValidator, messageType proto.Message) []string { - var updateCols []string - if mask == nil || !mask.IsValid(messageType) { - return updateCols - } - for _, path := range mask.GetPaths() { - if validator(path) { - updateCols = append(updateCols, path) - } - } - return updateCols + // The primary key should never be included in an update operation. + // processMask already ensures this by simply validating columns, and we don't add the idField here. + return processMask(mask, validator, messageType) } diff --git a/internal/helpers/db/pagination.go b/internal/helpers/db/pagination.go index 8d8e7a3e..ac755349 100644 --- a/internal/helpers/db/pagination.go +++ b/internal/helpers/db/pagination.go @@ -14,6 +14,8 @@ import ( "encoding/gob" "fmt" + "entgo.io/ent/dialect/sql" + "origadmin/application/admin/internal/helpers/repo" ) @@ -56,6 +58,10 @@ type Pageable[T any, W any, O any, R any] interface { Offset(int) T } +type Selector interface { + ~func(*sql.Selector) +} + // Orderer defines the interface for queries that can be ordered. type Orderer[T any, O any] interface { Order(...O) T @@ -133,7 +139,7 @@ type cursorCallback[T any] func(cursor Cursor) T // It ONLY handles Limit and Offset based on the provided options. // All WHERE and ORDER clauses are the responsibility of the caller in the DAL layer. // Note: Page boundary validation is handled in the Find function. -func Paginate[R any, W any, O any, P Pageable[P, W, O, R]](query P, opt *repo.QueryOption, +func Paginate[R any, W any, O Selector, P Pageable[P, W, O, R]](query P, opt *repo.QueryOption, callbacks ...cursorCallback[W]) P { if opt == nil { return query.Limit(repo.DefaultPageSize) @@ -183,7 +189,7 @@ func CountTotal[Q Counter[Q]](ctx context.Context, query Q) (int32, error) { // It handles both offset-based and cursor-based pagination. // For offset-based pagination, it performs an optimization to skip the data query // if the total count is 0 or the requested page is out of range. -func Find[R any, W any, O any, P Pageable[P, W, O, R]](ctx context.Context, query P, +func Find[R any, W any, O Selector, P Pageable[P, W, O, R]](ctx context.Context, query P, o *repo.QueryOption, callbacks ...cursorCallback[W]) ([]R, int32, error) { // Unified initialization and validation of options diff --git a/internal/helpers/db/sorting.go b/internal/helpers/db/sorting.go index d2b7263a..aab44c2f 100644 --- a/internal/helpers/db/sorting.go +++ b/internal/helpers/db/sorting.go @@ -13,7 +13,7 @@ import ( // OrderBy dynamically builds a list of order functions from a slice of strings. // Each string can be in the format "field_name" (for ascending) or "field_name,desc" (for descending). // This function is designed to be perfectly compatible with Ent's `order()` method. -func OrderBy[T selectable](fields []string, orders ...T) []T { +func OrderBy[T Selector](fields []string, orders ...T) []T { for _, field := range fields { parts := strings.Split(field, ",") fieldName := parts[0] @@ -37,7 +37,7 @@ func OrderBy[T selectable](fields []string, orders ...T) []T { return orders } -func OrderByField[T selectable](fieldName string, desc bool) T { +func OrderByField[T Selector](fieldName string, desc bool) T { var orderOpt sql.OrderTermOption if desc { orderOpt = sql.OrderDesc() From d31623ddf634a0a0b6c9957926895caab4a7f7af Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 26 Dec 2025 03:09:31 +0800 Subject: [PATCH 101/158] feat(system): add tree_path field to View proto and regenerate related files --- api/v1/proto/types/system.proto | 18 ++-- api/v1/services/types/system.pb.go | 46 ++++++---- api/v1/services/types/system.pb.validate.go | 2 + cmd/system/wire.go | 12 +-- cmd/system/wire_gen.go | 5 +- internal/data/entity/ent/casbinrule_create.go | 4 +- internal/data/entity/ent/department_create.go | 4 +- internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 88 +++++++++++-------- internal/data/entity/ent/mutation.go | 75 +++++++++++++++- internal/data/entity/ent/mutation_fields.go | 7 ++ .../data/entity/ent/notification_create.go | 4 +- .../data/entity/ent/permission/permission.go | 2 +- internal/data/entity/ent/permission_create.go | 4 +- .../entity/ent/permissionresource_create.go | 4 +- internal/data/entity/ent/position_create.go | 4 +- .../entity/ent/positionpermission_create.go | 4 +- internal/data/entity/ent/resource/resource.go | 2 +- internal/data/entity/ent/resource_create.go | 4 +- internal/data/entity/ent/role_create.go | 4 +- .../data/entity/ent/rolepermission_create.go | 4 +- internal/data/entity/ent/runtime/runtime.go | 32 ++++++- internal/data/entity/ent/schema/department.go | 2 +- internal/data/entity/ent/schema/permission.go | 2 +- internal/data/entity/ent/schema/position.go | 2 +- internal/data/entity/ent/schema/resource.go | 1 + internal/data/entity/ent/schema/role.go | 2 +- internal/data/entity/ent/schema/view.go | 24 +++++ .../data/entity/ent/template/crud_create.tpl | 4 +- internal/data/entity/ent/user_create.go | 4 +- .../data/entity/ent/userdepartment_create.go | 4 +- .../data/entity/ent/userposition_create.go | 4 +- internal/data/entity/ent/userrole_create.go | 4 +- internal/data/entity/ent/view.go | 15 +++- internal/data/entity/ent/view/view.go | 14 ++- internal/data/entity/ent/view/where.go | 80 +++++++++++++++++ internal/data/entity/ent/view_create.go | 22 ++++- internal/data/entity/ent/view_query.go | 2 + internal/data/entity/ent/view_update.go | 52 +++++++++++ .../ent/viewpermission/viewpermission.go | 2 +- .../data/entity/ent/viewpermission_create.go | 4 +- .../entity/ent/viewresource/viewresource.go | 2 +- .../data/entity/ent/viewresource_create.go | 4 +- internal/features/system/biz/user.go | 2 +- internal/features/system/biz/view.go | 7 +- internal/features/system/dal/resource.go | 9 -- internal/features/system/dal/view.go | 22 +++-- internal/features/system/dto/custom.gen.go | 18 ++++ internal/features/system/dto/dto.gen.go | 6 ++ internal/features/system/dto/user.go | 2 +- internal/features/system/dto/view.go | 4 +- internal/features/system/server/server.go | 2 + internal/features/system/service/user.go | 2 +- resources/api-docs/openapi/openapi.yaml | 3 + 54 files changed, 504 insertions(+), 154 deletions(-) diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index 554ddce0..07c05ef9 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -40,22 +40,24 @@ message View { bool visible = 13 [json_name = "visible"]; // Path holds the value of the "path" field. string path = 14 [json_name = "path"]; + // TreePath holds the value of the "tree_path" field. + string tree_path = 15 [json_name = "tree_path"]; // Properties holds the value of the "properties" field. - string properties = 15 [json_name = "properties"]; + string properties = 16 [json_name = "properties"]; // Status holds the value of the "status" field. - int32 status = 16 [json_name = "status"]; + int32 status = 17 [json_name = "status"]; // ParentID holds the value of the "parent_id" field. - int64 parent_id = 17 [json_name = "parent_id"]; + int64 parent_id = 18 [json_name = "parent_id"]; // ParentPath holds the value of the "parent_path" field. - string parent_path = 18 [json_name = "parent_path"]; + string parent_path = 19 [json_name = "parent_path"]; // Children holds the value of the children edge. - repeated View children = 19 [json_name = "children"]; + repeated View children = 20 [json_name = "children"]; // Parent holds the value of the parent edge. - View parent = 20 [json_name = "parent"]; + View parent = 21 [json_name = "parent"]; // Resources holds the value of the resources edge. - repeated Resource resources = 21 [json_name = "resources"]; + repeated Resource resources = 22 [json_name = "resources"]; // Roles holds the value of the roles edge. - repeated Role roles = 22 [json_name = "roles"]; + repeated Role roles = 23 [json_name = "roles"]; } // ViewEdges holds the relations/edges for other nodes in the graph. diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index c193970d..42e51674 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -53,22 +53,24 @@ type View struct { Visible bool `protobuf:"varint,13,opt,name=visible,proto3" json:"visible,omitempty"` // Path holds the value of the "path" field. Path string `protobuf:"bytes,14,opt,name=path,proto3" json:"path,omitempty"` + // TreePath holds the value of the "tree_path" field. + TreePath string `protobuf:"bytes,15,opt,name=tree_path,proto3" json:"tree_path,omitempty"` // Properties holds the value of the "properties" field. - Properties string `protobuf:"bytes,15,opt,name=properties,proto3" json:"properties,omitempty"` + Properties string `protobuf:"bytes,16,opt,name=properties,proto3" json:"properties,omitempty"` // Status holds the value of the "status" field. - Status int32 `protobuf:"varint,16,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` // ParentID holds the value of the "parent_id" field. - ParentId int64 `protobuf:"varint,17,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + ParentId int64 `protobuf:"varint,18,opt,name=parent_id,proto3" json:"parent_id,omitempty"` // ParentPath holds the value of the "parent_path" field. - ParentPath string `protobuf:"bytes,18,opt,name=parent_path,proto3" json:"parent_path,omitempty"` + ParentPath string `protobuf:"bytes,19,opt,name=parent_path,proto3" json:"parent_path,omitempty"` // Children holds the value of the children edge. - Children []*View `protobuf:"bytes,19,rep,name=children,proto3" json:"children,omitempty"` + Children []*View `protobuf:"bytes,20,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. - Parent *View `protobuf:"bytes,20,opt,name=parent,proto3" json:"parent,omitempty"` + Parent *View `protobuf:"bytes,21,opt,name=parent,proto3" json:"parent,omitempty"` // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,21,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*Resource `protobuf:"bytes,22,rep,name=resources,proto3" json:"resources,omitempty"` // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,22,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*Role `protobuf:"bytes,23,rep,name=roles,proto3" json:"roles,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -201,6 +203,13 @@ func (x *View) GetPath() string { return "" } +func (x *View) GetTreePath() string { + if x != nil { + return x.TreePath + } + return "" +} + func (x *View) GetProperties() string { if x != nil { return x.Properties @@ -2774,7 +2783,7 @@ var File_types_system_proto protoreflect.FileDescriptor const file_types_system_proto_rawDesc = "" + "\n" + - "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xf8\x05\n" + + "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x96\x06\n" + "\x04View\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + @@ -2790,17 +2799,18 @@ const file_types_system_proto_rawDesc = "" + "\acomment\x18\v \x01(\tR\acomment\x12\x12\n" + "\x04icon\x18\f \x01(\tR\x04icon\x12\x18\n" + "\avisible\x18\r \x01(\bR\avisible\x12\x12\n" + - "\x04path\x18\x0e \x01(\tR\x04path\x12\x1e\n" + + "\x04path\x18\x0e \x01(\tR\x04path\x12\x1c\n" + + "\ttree_path\x18\x0f \x01(\tR\ttree_path\x12\x1e\n" + "\n" + - "properties\x18\x0f \x01(\tR\n" + + "properties\x18\x10 \x01(\tR\n" + "properties\x12\x16\n" + - "\x06status\x18\x10 \x01(\x05R\x06status\x12\x1c\n" + - "\tparent_id\x18\x11 \x01(\x03R\tparent_id\x12 \n" + - "\vparent_path\x18\x12 \x01(\tR\vparent_path\x127\n" + - "\bchildren\x18\x13 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + - "\x06parent\x18\x14 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + - "\tresources\x18\x15 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + - "\x05roles\x18\x16 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xac\x02\n" + + "\x06status\x18\x11 \x01(\x05R\x06status\x12\x1c\n" + + "\tparent_id\x18\x12 \x01(\x03R\tparent_id\x12 \n" + + "\vparent_path\x18\x13 \x01(\tR\vparent_path\x127\n" + + "\bchildren\x18\x14 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + + "\x06parent\x18\x15 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + + "\tresources\x18\x16 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + + "\x05roles\x18\x17 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xac\x02\n" + "\tViewEdges\x127\n" + "\bchildren\x18\x01 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + "\x06parent\x18\x02 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index 910f454d..957c6afa 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -138,6 +138,8 @@ func (m *View) validate(all bool) error { // no validation rules for Path + // no validation rules for TreePath + // no validation rules for Properties // no validation rules for Status diff --git a/cmd/system/wire.go b/cmd/system/wire.go index e3646026..f499d873 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -11,11 +11,8 @@ package main import ( "github.com/go-kratos/kratos/v2" "github.com/google/wire" - "github.com/origadmin/runtime" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" - "github.com/origadmin/toolkits/crypto/hash/types" + "github.com/origadmin/runtime" "origadmin/application/admin/internal/conf" confpb "origadmin/application/admin/internal/conf/pb" "origadmin/application/admin/internal/data" @@ -25,16 +22,11 @@ import ( "origadmin/application/admin/internal/features/system/service" ) -func provideHasher() (hash.Crypto, error) { - // Using a default cost for bcrypt. In a real application, this might come from config. - return hash.NewCrypto(types.BCRYPT, bcrypt.WithCost(bcrypt.DefaultCost)) -} - // wireApp init kratos application. func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { panic(wire.Build( // The injector function's parameter `app` is an implicit provider for *runtime.App. - provideHasher, + infraProviderSet, wire.FieldsOf(new(*conf.Config), "Bootstrap"), wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), data.ProviderSet, diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index 89f32380..38d59135 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -21,6 +21,7 @@ import ( _ "github.com/origadmin/contrib/config/consul" _ "github.com/origadmin/contrib/registry/consul" _ "github.com/sqlite3ent/sqlite3" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" ) // Injectors from wire.go: @@ -47,7 +48,9 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err userUseCase := biz.NewUserUseCase(userRepo, crypto) permissionRepo := dal.NewPermissionRepo(database) permissionUseCase := biz.NewPermissionUseCase(permissionRepo) - systemService := service.New(resourceUseCase, roleUseCase, userUseCase, permissionUseCase) + viewRepo := dal.NewViewRepo(database) + viewUseCase := biz.NewViewUseCase(viewRepo) + systemService := service.New(resourceUseCase, roleUseCase, userUseCase, permissionUseCase, viewUseCase) v := provideLogger(app) v2, err := server.NewServers(servers, systemService, v) if err != nil { diff --git a/internal/data/entity/ent/casbinrule_create.go b/internal/data/entity/ent/casbinrule_create.go index 28a449da..79e1e76e 100644 --- a/internal/data/entity/ent/casbinrule_create.go +++ b/internal/data/entity/ent/casbinrule_create.go @@ -273,12 +273,12 @@ func (_c *CasbinRuleCreate) SetCasbinRule(input *CasbinRule, fields ...string) * } // SetCasbinRuleWithZero set the CasbinRule -func (_c *CasbinRuleCreate) SetCasbinRuleWithZero(input *CasbinRule, fields ...string) *CasbinRuleCreate { +func (_c *CasbinRuleCreate) SetCasbinRuleSkipZero(input *CasbinRule, fields ...string) *CasbinRuleCreate { m := _c.mutation if len(fields) == 0 { fields = casbinrule.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/department_create.go b/internal/data/entity/ent/department_create.go index 1bc73169..44f88cc6 100644 --- a/internal/data/entity/ent/department_create.go +++ b/internal/data/entity/ent/department_create.go @@ -517,12 +517,12 @@ func (_c *DepartmentCreate) SetDepartment(input *Department, fields ...string) * } // SetDepartmentWithZero set the Department -func (_c *DepartmentCreate) SetDepartmentWithZero(input *Department, fields ...string) *DepartmentCreate { +func (_c *DepartmentCreate) SetDepartmentSkipZero(input *Department, fields ...string) *DepartmentCreate { m := _c.mutation if len(fields) == 0 { fields = department.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index 47ef9a77..c1771702 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index 1ced4cfe..c3237f6b 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -31,7 +31,7 @@ var ( {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 64, Comment: "entity.department.field.keyword"}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.department.field.keyword"}, {Name: "name", Type: field.TypeString, Size: 64, Comment: "entity.department.field.name", Default: ""}, {Name: "tree_path", Type: field.TypeString, Size: 256, Comment: "entity.menu.field.tree_path", Default: ""}, {Name: "sequence", Type: field.TypeInt, Comment: "entity.department.field.sequence"}, @@ -134,7 +134,7 @@ var ( {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, {Name: "name", Type: field.TypeString, Size: 64, Comment: "entity.permission.field.name", Default: ""}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 64, Comment: "entity.permission.field.keyword"}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.permission.field.keyword"}, {Name: "description", Type: field.TypeString, Size: 1024, Comment: "entity.permission.field.description", Default: ""}, {Name: "data_scope", Type: field.TypeString, Comment: "entity.permission.field.data_scope", Default: "self"}, {Name: "data_rules", Type: field.TypeJSON, Nullable: true, Comment: "entity.permission.field.data_rules"}, @@ -199,7 +199,7 @@ var ( {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, {Name: "name", Type: field.TypeString, Unique: true, Size: 64, Comment: "entity.position.field.name"}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 64, Comment: "entity.position.field.keyword"}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.position.field.keyword"}, {Name: "description", Type: field.TypeString, Size: 1024, Comment: "entity.position.field.description", Default: ""}, {Name: "department_id", Type: field.TypeInt64, Comment: "entity.department.field.department_id"}, } @@ -270,7 +270,7 @@ var ( {Name: "create_time", Type: field.TypeTime}, {Name: "update_time", Type: field.TypeTime}, {Name: "service_name", Type: field.TypeString}, - {Name: "keyword", Type: field.TypeString, Unique: true}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255}, {Name: "path", Type: field.TypeString, Nullable: true}, {Name: "method", Type: field.TypeString, Nullable: true}, {Name: "operation", Type: field.TypeString, Nullable: true}, @@ -303,7 +303,7 @@ var ( {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 32, Comment: "entity.role.field.keyword"}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.role.field.keyword"}, {Name: "name", Type: field.TypeString, Size: 128, Comment: "entity.role.field.name", Default: ""}, {Name: "description", Type: field.TypeString, Size: 1024, Comment: "entity.role.field.description", Default: ""}, {Name: "type", Type: field.TypeInt8, Comment: "entity.role.field.type", Default: 2}, @@ -565,32 +565,34 @@ var ( }, }, } - // ViewsColumns holds the columns for the "views" table. - ViewsColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt64}, - {Name: "create_time", Type: field.TypeTime}, - {Name: "update_time", Type: field.TypeTime}, - {Name: "keyword", Type: field.TypeString, Unique: true}, - {Name: "scope", Type: field.TypeString, Default: "default"}, - {Name: "name", Type: field.TypeString}, - {Name: "type", Type: field.TypeEnum, Enums: []string{"T", "G", "M", "L", "P", "B", "E", "R", "U"}, Default: "U"}, - {Name: "component", Type: field.TypeString, Nullable: true}, - {Name: "path", Type: field.TypeString, Nullable: true}, - {Name: "icon", Type: field.TypeString, Nullable: true}, - {Name: "visible", Type: field.TypeBool, Default: true}, - {Name: "sequence", Type: field.TypeInt, Default: 0}, - {Name: "parent_id", Type: field.TypeInt64, Nullable: true}, - } - // ViewsTable holds the schema information for the "views" table. - ViewsTable = &schema.Table{ - Name: "views", - Columns: ViewsColumns, - PrimaryKey: []*schema.Column{ViewsColumns[0]}, + // SysViewsColumns holds the columns for the "sys_views" table. + SysViewsColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, + {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, + {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "view.keyword.comment"}, + {Name: "scope", Type: field.TypeString, Comment: "view.scope.comment", Default: "default"}, + {Name: "name", Type: field.TypeString, Comment: "view.name.comment"}, + {Name: "type", Type: field.TypeEnum, Comment: "view.type.comment", Enums: []string{"T", "G", "M", "L", "P", "B", "E", "R", "U"}, Default: "U"}, + {Name: "component", Type: field.TypeString, Nullable: true, Comment: "view.component.comment"}, + {Name: "path", Type: field.TypeString, Nullable: true, Comment: "view.path.comment"}, + {Name: "icon", Type: field.TypeString, Nullable: true, Comment: "view.icon.comment"}, + {Name: "visible", Type: field.TypeBool, Comment: "view.visible.comment", Default: true}, + {Name: "sequence", Type: field.TypeInt, Comment: "view.sequence.comment", Default: 0}, + {Name: "tree_path", Type: field.TypeString, Nullable: true, Comment: "view.tree_path.comment"}, + {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "view.parent_id.comment"}, + } + // SysViewsTable holds the schema information for the "sys_views" table. + SysViewsTable = &schema.Table{ + Name: "sys_views", + Comment: "entity.view.table.comment", + Columns: SysViewsColumns, + PrimaryKey: []*schema.Column{SysViewsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "views_views_children", - Columns: []*schema.Column{ViewsColumns[12]}, - RefColumns: []*schema.Column{ViewsColumns[0]}, + Symbol: "sys_views_sys_views_children", + Columns: []*schema.Column{SysViewsColumns[13]}, + RefColumns: []*schema.Column{SysViewsColumns[0]}, OnDelete: schema.SetNull, }, }, @@ -598,12 +600,17 @@ var ( { Name: "view_create_time", Unique: false, - Columns: []*schema.Column{ViewsColumns[1]}, + Columns: []*schema.Column{SysViewsColumns[1]}, }, { Name: "view_update_time", Unique: false, - Columns: []*schema.Column{ViewsColumns[2]}, + Columns: []*schema.Column{SysViewsColumns[2]}, + }, + { + Name: "view_keyword_scope", + Unique: true, + Columns: []*schema.Column{SysViewsColumns[3], SysViewsColumns[4]}, }, }, } @@ -625,9 +632,9 @@ var ( PrimaryKey: []*schema.Column{SysViewPermissionsColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "sys_view_permissions_views_view", + Symbol: "sys_view_permissions_sys_views_view", Columns: []*schema.Column{SysViewPermissionsColumns[5]}, - RefColumns: []*schema.Column{ViewsColumns[0]}, + RefColumns: []*schema.Column{SysViewsColumns[0]}, OnDelete: schema.NoAction, }, { @@ -683,9 +690,9 @@ var ( PrimaryKey: []*schema.Column{SysViewResourcesColumns[0]}, ForeignKeys: []*schema.ForeignKey{ { - Symbol: "sys_view_resources_views_view", + Symbol: "sys_view_resources_sys_views_view", Columns: []*schema.Column{SysViewResourcesColumns[5]}, - RefColumns: []*schema.Column{ViewsColumns[0]}, + RefColumns: []*schema.Column{SysViewsColumns[0]}, OnDelete: schema.NoAction, }, { @@ -739,7 +746,7 @@ var ( SysUserDepartmentsTable, SysUserPositionsTable, SysUserRolesTable, - ViewsTable, + SysViewsTable, SysViewPermissionsTable, SysViewResourcesTable, } @@ -796,13 +803,16 @@ func init() { SysUserRolesTable.Annotation = &entsql.Annotation{ Table: "sys_user_roles", } - ViewsTable.ForeignKeys[0].RefTable = ViewsTable - SysViewPermissionsTable.ForeignKeys[0].RefTable = ViewsTable + SysViewsTable.ForeignKeys[0].RefTable = SysViewsTable + SysViewsTable.Annotation = &entsql.Annotation{ + Table: "sys_views", + } + SysViewPermissionsTable.ForeignKeys[0].RefTable = SysViewsTable SysViewPermissionsTable.ForeignKeys[1].RefTable = SysPermissionsTable SysViewPermissionsTable.Annotation = &entsql.Annotation{ Table: "sys_view_permissions", } - SysViewResourcesTable.ForeignKeys[0].RefTable = ViewsTable + SysViewResourcesTable.ForeignKeys[0].RefTable = SysViewsTable SysViewResourcesTable.ForeignKeys[1].RefTable = ResourcesTable SysViewResourcesTable.Annotation = &entsql.Annotation{ Table: "sys_view_resources", diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index 1f4209f1..a586ab54 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -13122,6 +13122,7 @@ type ViewMutation struct { visible *bool sequence *int addsequence *int + tree_path *string clearedFields map[string]struct{} parent *int64 clearedparent bool @@ -13753,6 +13754,55 @@ func (m *ViewMutation) ResetSequence() { m.addsequence = nil } +// SetTreePath sets the "tree_path" field. +func (m *ViewMutation) SetTreePath(s string) { + m.tree_path = &s +} + +// TreePath returns the value of the "tree_path" field in the mutation. +func (m *ViewMutation) TreePath() (r string, exists bool) { + v := m.tree_path + if v == nil { + return + } + return *v, true +} + +// OldTreePath returns the old "tree_path" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldTreePath(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTreePath is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTreePath requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTreePath: %w", err) + } + return oldValue.TreePath, nil +} + +// ClearTreePath clears the value of the "tree_path" field. +func (m *ViewMutation) ClearTreePath() { + m.tree_path = nil + m.clearedFields[view.FieldTreePath] = struct{}{} +} + +// TreePathCleared returns if the "tree_path" field was cleared in this mutation. +func (m *ViewMutation) TreePathCleared() bool { + _, ok := m.clearedFields[view.FieldTreePath] + return ok +} + +// ResetTreePath resets all changes to the "tree_path" field. +func (m *ViewMutation) ResetTreePath() { + m.tree_path = nil + delete(m.clearedFields, view.FieldTreePath) +} + // ClearParent clears the "parent" edge to the View entity. func (m *ViewMutation) ClearParent() { m.clearedparent = true @@ -14084,7 +14134,7 @@ func (m *ViewMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *ViewMutation) Fields() []string { - fields := make([]string, 0, 12) + fields := make([]string, 0, 13) if m.create_time != nil { fields = append(fields, view.FieldCreateTime) } @@ -14121,6 +14171,9 @@ func (m *ViewMutation) Fields() []string { if m.sequence != nil { fields = append(fields, view.FieldSequence) } + if m.tree_path != nil { + fields = append(fields, view.FieldTreePath) + } return fields } @@ -14153,6 +14206,8 @@ func (m *ViewMutation) Field(name string) (ent.Value, bool) { return m.Visible() case view.FieldSequence: return m.Sequence() + case view.FieldTreePath: + return m.TreePath() } return nil, false } @@ -14186,6 +14241,8 @@ func (m *ViewMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldVisible(ctx) case view.FieldSequence: return m.OldSequence(ctx) + case view.FieldTreePath: + return m.OldTreePath(ctx) } return nil, fmt.Errorf("unknown View field %s", name) } @@ -14279,6 +14336,13 @@ func (m *ViewMutation) SetField(name string, value ent.Value) error { } m.SetSequence(v) return nil + case view.FieldTreePath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTreePath(v) + return nil } return fmt.Errorf("unknown View field %s", name) } @@ -14336,6 +14400,9 @@ func (m *ViewMutation) ClearedFields() []string { if m.FieldCleared(view.FieldIcon) { fields = append(fields, view.FieldIcon) } + if m.FieldCleared(view.FieldTreePath) { + fields = append(fields, view.FieldTreePath) + } return fields } @@ -14362,6 +14429,9 @@ func (m *ViewMutation) ClearField(name string) error { case view.FieldIcon: m.ClearIcon() return nil + case view.FieldTreePath: + m.ClearTreePath() + return nil } return fmt.Errorf("unknown View nullable field %s", name) } @@ -14406,6 +14476,9 @@ func (m *ViewMutation) ResetField(name string) error { case view.FieldSequence: m.ResetSequence() return nil + case view.FieldTreePath: + m.ResetTreePath() + return nil } return fmt.Errorf("unknown View field %s", name) } diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index c7f568fd..23ae1ba2 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -1141,6 +1141,8 @@ func (m *ViewMutation) SetFields(input *View, fields ...string) error { m.SetVisible(input.Visible) case view.FieldSequence: m.SetSequence(input.Sequence) + case view.FieldTreePath: + m.SetTreePath(input.TreePath) case view.FieldID: m.SetID(input.ID) default: @@ -1214,6 +1216,11 @@ func (m *ViewMutation) SetFieldsSkipZero(input *View, fields ...string) error { if input.Sequence != 0 { m.SetSequence(input.Sequence) } + case view.FieldTreePath: + // check string with sql.NullString if it is empty + if input.TreePath != "" { + m.SetTreePath(input.TreePath) + } case view.FieldID: // check int64 with sql.NullInt64 if it is zero if input.ID != 0 { diff --git a/internal/data/entity/ent/notification_create.go b/internal/data/entity/ent/notification_create.go index 211d92a9..44c06cb4 100644 --- a/internal/data/entity/ent/notification_create.go +++ b/internal/data/entity/ent/notification_create.go @@ -316,12 +316,12 @@ func (_c *NotificationCreate) SetNotification(input *Notification, fields ...str } // SetNotificationWithZero set the Notification -func (_c *NotificationCreate) SetNotificationWithZero(input *Notification, fields ...string) *NotificationCreate { +func (_c *NotificationCreate) SetNotificationSkipZero(input *Notification, fields ...string) *NotificationCreate { m := _c.mutation if len(fields) == 0 { fields = notification.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/permission/permission.go b/internal/data/entity/ent/permission/permission.go index cac2d900..bf300029 100644 --- a/internal/data/entity/ent/permission/permission.go +++ b/internal/data/entity/ent/permission/permission.go @@ -68,7 +68,7 @@ const ( ViewsTable = "sys_view_permissions" // ViewsInverseTable is the table name for the View entity. // It exists in this package in order to avoid circular dependency with the "view" package. - ViewsInverseTable = "views" + ViewsInverseTable = "sys_views" // RolePermissionsTable is the table that holds the role_permissions relation/edge. RolePermissionsTable = "sys_role_permissions" // RolePermissionsInverseTable is the table name for the RolePermission entity. diff --git a/internal/data/entity/ent/permission_create.go b/internal/data/entity/ent/permission_create.go index 4d2da4ab..f4ee265f 100644 --- a/internal/data/entity/ent/permission_create.go +++ b/internal/data/entity/ent/permission_create.go @@ -584,12 +584,12 @@ func (_c *PermissionCreate) SetPermission(input *Permission, fields ...string) * } // SetPermissionWithZero set the Permission -func (_c *PermissionCreate) SetPermissionWithZero(input *Permission, fields ...string) *PermissionCreate { +func (_c *PermissionCreate) SetPermissionSkipZero(input *Permission, fields ...string) *PermissionCreate { m := _c.mutation if len(fields) == 0 { fields = permission.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/permissionresource_create.go b/internal/data/entity/ent/permissionresource_create.go index 6cde80eb..865cec00 100644 --- a/internal/data/entity/ent/permissionresource_create.go +++ b/internal/data/entity/ent/permissionresource_create.go @@ -173,12 +173,12 @@ func (_c *PermissionResourceCreate) SetPermissionResource(input *PermissionResou } // SetPermissionResourceWithZero set the PermissionResource -func (_c *PermissionResourceCreate) SetPermissionResourceWithZero(input *PermissionResource, fields ...string) *PermissionResourceCreate { +func (_c *PermissionResourceCreate) SetPermissionResourceSkipZero(input *PermissionResource, fields ...string) *PermissionResourceCreate { m := _c.mutation if len(fields) == 0 { fields = permissionresource.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/position_create.go b/internal/data/entity/ent/position_create.go index 109e68c7..965fd7ee 100644 --- a/internal/data/entity/ent/position_create.go +++ b/internal/data/entity/ent/position_create.go @@ -412,12 +412,12 @@ func (_c *PositionCreate) SetPosition(input *Position, fields ...string) *Positi } // SetPositionWithZero set the Position -func (_c *PositionCreate) SetPositionWithZero(input *Position, fields ...string) *PositionCreate { +func (_c *PositionCreate) SetPositionSkipZero(input *Position, fields ...string) *PositionCreate { m := _c.mutation if len(fields) == 0 { fields = position.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/positionpermission_create.go b/internal/data/entity/ent/positionpermission_create.go index 96ea8b88..bcb02501 100644 --- a/internal/data/entity/ent/positionpermission_create.go +++ b/internal/data/entity/ent/positionpermission_create.go @@ -173,12 +173,12 @@ func (_c *PositionPermissionCreate) SetPositionPermission(input *PositionPermiss } // SetPositionPermissionWithZero set the PositionPermission -func (_c *PositionPermissionCreate) SetPositionPermissionWithZero(input *PositionPermission, fields ...string) *PositionPermissionCreate { +func (_c *PositionPermissionCreate) SetPositionPermissionSkipZero(input *PositionPermission, fields ...string) *PositionPermissionCreate { m := _c.mutation if len(fields) == 0 { fields = positionpermission.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/resource/resource.go b/internal/data/entity/ent/resource/resource.go index bba448b6..695bdaf2 100644 --- a/internal/data/entity/ent/resource/resource.go +++ b/internal/data/entity/ent/resource/resource.go @@ -51,7 +51,7 @@ const ( ViewsTable = "sys_view_resources" // ViewsInverseTable is the table name for the View entity. // It exists in this package in order to avoid circular dependency with the "view" package. - ViewsInverseTable = "views" + ViewsInverseTable = "sys_views" // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. PermissionsTable = "sys_permission_resources" // PermissionsInverseTable is the table name for the Permission entity. diff --git a/internal/data/entity/ent/resource_create.go b/internal/data/entity/ent/resource_create.go index 8778d88a..9fa0a673 100644 --- a/internal/data/entity/ent/resource_create.go +++ b/internal/data/entity/ent/resource_create.go @@ -496,12 +496,12 @@ func (_c *ResourceCreate) SetResource(input *Resource, fields ...string) *Resour } // SetResourceWithZero set the Resource -func (_c *ResourceCreate) SetResourceWithZero(input *Resource, fields ...string) *ResourceCreate { +func (_c *ResourceCreate) SetResourceSkipZero(input *Resource, fields ...string) *ResourceCreate { m := _c.mutation if len(fields) == 0 { fields = resource.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/role_create.go b/internal/data/entity/ent/role_create.go index 60d7b17b..3032f526 100644 --- a/internal/data/entity/ent/role_create.go +++ b/internal/data/entity/ent/role_create.go @@ -460,12 +460,12 @@ func (_c *RoleCreate) SetRole(input *Role, fields ...string) *RoleCreate { } // SetRoleWithZero set the Role -func (_c *RoleCreate) SetRoleWithZero(input *Role, fields ...string) *RoleCreate { +func (_c *RoleCreate) SetRoleSkipZero(input *Role, fields ...string) *RoleCreate { m := _c.mutation if len(fields) == 0 { fields = role.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/rolepermission_create.go b/internal/data/entity/ent/rolepermission_create.go index e87bca97..89bc1f2e 100644 --- a/internal/data/entity/ent/rolepermission_create.go +++ b/internal/data/entity/ent/rolepermission_create.go @@ -173,12 +173,12 @@ func (_c *RolePermissionCreate) SetRolePermission(input *RolePermission, fields } // SetRolePermissionWithZero set the RolePermission -func (_c *RolePermissionCreate) SetRolePermissionWithZero(input *RolePermission, fields ...string) *RolePermissionCreate { +func (_c *RolePermissionCreate) SetRolePermissionSkipZero(input *RolePermission, fields ...string) *RolePermissionCreate { m := _c.mutation if len(fields) == 0 { fields = rolepermission.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index afc47ab7..3f255cd4 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -299,7 +299,21 @@ func init() { // resourceDescKeyword is the schema descriptor for keyword field. resourceDescKeyword := resourceFields[1].Descriptor() // resource.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - resource.KeywordValidator = resourceDescKeyword.Validators[0].(func(string) error) + resource.KeywordValidator = func() func(string) error { + validators := resourceDescKeyword.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(keyword string) error { + for _, fn := range fns { + if err := fn(keyword); err != nil { + return err + } + } + return nil + } + }() // resourceDescPolicy is the schema descriptor for policy field. resourceDescPolicy := resourceFields[5].Descriptor() // resource.DefaultPolicy holds the default value on creation for the policy field. @@ -582,7 +596,21 @@ func init() { // viewDescKeyword is the schema descriptor for keyword field. viewDescKeyword := viewFields[1].Descriptor() // view.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. - view.KeywordValidator = viewDescKeyword.Validators[0].(func(string) error) + view.KeywordValidator = func() func(string) error { + validators := viewDescKeyword.Validators + fns := [...]func(string) error{ + validators[0].(func(string) error), + validators[1].(func(string) error), + } + return func(keyword string) error { + for _, fn := range fns { + if err := fn(keyword); err != nil { + return err + } + } + return nil + } + }() // viewDescScope is the schema descriptor for scope field. viewDescScope := viewFields[2].Descriptor() // view.DefaultScope holds the default value on creation for the scope field. diff --git a/internal/data/entity/ent/schema/department.go b/internal/data/entity/ent/schema/department.go index 5a7a8cb7..588d1405 100644 --- a/internal/data/entity/ent/schema/department.go +++ b/internal/data/entity/ent/schema/department.go @@ -26,7 +26,7 @@ type Department struct { func (Department) Fields() []ent.Field { return []ent.Field{ field.String("keyword"). - MaxLen(64). + MaxLen(255). Unique(). Comment(i18n.Text("entity.department.field.keyword")), field.String("name"). diff --git a/internal/data/entity/ent/schema/permission.go b/internal/data/entity/ent/schema/permission.go index 555caaaf..eeb048b0 100644 --- a/internal/data/entity/ent/schema/permission.go +++ b/internal/data/entity/ent/schema/permission.go @@ -37,7 +37,7 @@ func (Permission) Fields() []ent.Field { Default(""). Comment(i18n.Text("entity.permission.field.name")), field.String("keyword"). - MaxLen(64). + MaxLen(255). Unique(). Comment(i18n.Text("entity.permission.field.keyword")), field.String("description"). diff --git a/internal/data/entity/ent/schema/position.go b/internal/data/entity/ent/schema/position.go index e2d2c5b8..2528b4e8 100644 --- a/internal/data/entity/ent/schema/position.go +++ b/internal/data/entity/ent/schema/position.go @@ -29,7 +29,7 @@ func (Position) Fields() []ent.Field { Unique(). Comment(i18n.Text("entity.position.field.name")), field.String("keyword"). - MaxLen(64). + MaxLen(255). Unique(). Comment(i18n.Text("entity.position.field.keyword")), field.String("description"). diff --git a/internal/data/entity/ent/schema/resource.go b/internal/data/entity/ent/schema/resource.go index c9c728ce..baf5d16b 100644 --- a/internal/data/entity/ent/schema/resource.go +++ b/internal/data/entity/ent/schema/resource.go @@ -19,6 +19,7 @@ func (Resource) Fields() []ent.Field { field.String("service_name"). Comment(i18n.Text("resource.service_name.comment")), field.String("keyword"). + MaxLen(255). Comment(i18n.Text("resource.keyword.comment")). Unique(). NotEmpty(), diff --git a/internal/data/entity/ent/schema/role.go b/internal/data/entity/ent/schema/role.go index 9d468300..88605c42 100644 --- a/internal/data/entity/ent/schema/role.go +++ b/internal/data/entity/ent/schema/role.go @@ -27,7 +27,7 @@ type Role struct { func (Role) Fields() []ent.Field { return []ent.Field{ field.String("keyword"). - MaxLen(32). + MaxLen(255). Unique(). Comment(i18n.Text("entity.role.field.keyword")), // keyword of role (unique) field.String("name"). diff --git a/internal/data/entity/ent/schema/view.go b/internal/data/entity/ent/schema/view.go index bc09124e..d2fee841 100644 --- a/internal/data/entity/ent/schema/view.go +++ b/internal/data/entity/ent/schema/view.go @@ -2,8 +2,11 @@ package schema import ( "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + "entgo.io/ent/schema/index" "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/helpers/ent/mixin" @@ -21,6 +24,7 @@ func (View) Fields() []ent.Field { // Use OptionalFK for an optional foreign key, as designed in the mixin package. mixin.OptionalFK("parent_id", i18n.Text("view.parent_id.comment")), field.String("keyword"). + MaxLen(255). Comment(i18n.Text("view.keyword.comment")). Unique(). NotEmpty(), @@ -58,6 +62,9 @@ func (View) Fields() []ent.Field { field.Int("sequence"). Comment(i18n.Text("view.sequence.comment")). Default(0), + field.String("tree_path"). + Comment(i18n.Text("view.tree_path.comment")). + Optional(), } } @@ -79,3 +86,20 @@ func (View) Edges() []ent.Edge { func (View) Mixin() []ent.Mixin { return mixin.ModelMixin } + +// Indexes of the View. +func (View) Indexes() []ent.Index { + return []ent.Index{ + index.Fields("keyword", "scope"). + Unique(), + } +} + +// Annotations of the View. +func (View) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_views"), + entsql.WithComments(true), + schema.Comment(i18n.Text("entity.view.table.comment")), + } +} diff --git a/internal/data/entity/ent/template/crud_create.tpl b/internal/data/entity/ent/template/crud_create.tpl index bfd1fa84..21c3efa1 100644 --- a/internal/data/entity/ent/template/crud_create.tpl +++ b/internal/data/entity/ent/template/crud_create.tpl @@ -22,12 +22,12 @@ } {{ print "// Set" .Name "WithZero set the " .Name }} - func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}WithZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { + func ({{ $receiver }} *{{ $builder }}) Set{{ .Name }}SkipZero(input *{{ .Name }}, fields ...string) *{{ $builder }} { m := {{ $receiver }}.mutation if len(fields) == 0 { fields = {{ $const }}.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return {{ $receiver }} } diff --git a/internal/data/entity/ent/user_create.go b/internal/data/entity/ent/user_create.go index 1db06155..2fa688b3 100644 --- a/internal/data/entity/ent/user_create.go +++ b/internal/data/entity/ent/user_create.go @@ -1038,12 +1038,12 @@ func (_c *UserCreate) SetUser(input *User, fields ...string) *UserCreate { } // SetUserWithZero set the User -func (_c *UserCreate) SetUserWithZero(input *User, fields ...string) *UserCreate { +func (_c *UserCreate) SetUserSkipZero(input *User, fields ...string) *UserCreate { m := _c.mutation if len(fields) == 0 { fields = user.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/userdepartment_create.go b/internal/data/entity/ent/userdepartment_create.go index bf89873c..29321929 100644 --- a/internal/data/entity/ent/userdepartment_create.go +++ b/internal/data/entity/ent/userdepartment_create.go @@ -173,12 +173,12 @@ func (_c *UserDepartmentCreate) SetUserDepartment(input *UserDepartment, fields } // SetUserDepartmentWithZero set the UserDepartment -func (_c *UserDepartmentCreate) SetUserDepartmentWithZero(input *UserDepartment, fields ...string) *UserDepartmentCreate { +func (_c *UserDepartmentCreate) SetUserDepartmentSkipZero(input *UserDepartment, fields ...string) *UserDepartmentCreate { m := _c.mutation if len(fields) == 0 { fields = userdepartment.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/userposition_create.go b/internal/data/entity/ent/userposition_create.go index 8649f0aa..b3a611fb 100644 --- a/internal/data/entity/ent/userposition_create.go +++ b/internal/data/entity/ent/userposition_create.go @@ -173,12 +173,12 @@ func (_c *UserPositionCreate) SetUserPosition(input *UserPosition, fields ...str } // SetUserPositionWithZero set the UserPosition -func (_c *UserPositionCreate) SetUserPositionWithZero(input *UserPosition, fields ...string) *UserPositionCreate { +func (_c *UserPositionCreate) SetUserPositionSkipZero(input *UserPosition, fields ...string) *UserPositionCreate { m := _c.mutation if len(fields) == 0 { fields = userposition.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/userrole_create.go b/internal/data/entity/ent/userrole_create.go index f98b7a1b..ff0c88d4 100644 --- a/internal/data/entity/ent/userrole_create.go +++ b/internal/data/entity/ent/userrole_create.go @@ -173,12 +173,12 @@ func (_c *UserRoleCreate) SetUserRole(input *UserRole, fields ...string) *UserRo } // SetUserRoleWithZero set the UserRole -func (_c *UserRoleCreate) SetUserRoleWithZero(input *UserRole, fields ...string) *UserRoleCreate { +func (_c *UserRoleCreate) SetUserRoleSkipZero(input *UserRole, fields ...string) *UserRoleCreate { m := _c.mutation if len(fields) == 0 { fields = userrole.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/view.go b/internal/data/entity/ent/view.go index 7dbcde3a..4db5f830 100644 --- a/internal/data/entity/ent/view.go +++ b/internal/data/entity/ent/view.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql" ) -// View is the model entity for the View schema. +// entity.view.table.comment type View struct { config `json:"-"` // ID of the ent. @@ -42,6 +42,8 @@ type View struct { Visible bool `json:"visible,omitempty"` // view.sequence.comment Sequence int `json:"sequence,omitempty"` + // view.tree_path.comment + TreePath string `json:"tree_path,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ViewQuery when eager-loading is set. Edges ViewEdges `json:"edges"` @@ -132,7 +134,7 @@ func (*View) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case view.FieldID, view.FieldParentID, view.FieldSequence: values[i] = new(sql.NullInt64) - case view.FieldKeyword, view.FieldScope, view.FieldName, view.FieldType, view.FieldComponent, view.FieldPath, view.FieldIcon: + case view.FieldKeyword, view.FieldScope, view.FieldName, view.FieldType, view.FieldComponent, view.FieldPath, view.FieldIcon, view.FieldTreePath: values[i] = new(sql.NullString) case view.FieldCreateTime, view.FieldUpdateTime: values[i] = new(sql.NullTime) @@ -229,6 +231,12 @@ func (_m *View) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Sequence = int(value.Int64) } + case view.FieldTreePath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field tree_path", values[i]) + } else if value.Valid { + _m.TreePath = value.String + } default: _m.selectValues.Set(columns[i], values[i]) } @@ -330,6 +338,9 @@ func (_m *View) String() string { builder.WriteString(", ") builder.WriteString("sequence=") builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) + builder.WriteString(", ") + builder.WriteString("tree_path=") + builder.WriteString(_m.TreePath) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/view/view.go b/internal/data/entity/ent/view/view.go index 9193428a..94ece1d6 100644 --- a/internal/data/entity/ent/view/view.go +++ b/internal/data/entity/ent/view/view.go @@ -39,6 +39,8 @@ const ( FieldVisible = "visible" // FieldSequence holds the string denoting the sequence field in the database. FieldSequence = "sequence" + // FieldTreePath holds the string denoting the tree_path field in the database. + FieldTreePath = "tree_path" // EdgeParent holds the string denoting the parent edge name in mutations. EdgeParent = "parent" // EdgeChildren holds the string denoting the children edge name in mutations. @@ -52,13 +54,13 @@ const ( // EdgeViewPermissions holds the string denoting the view_permissions edge name in mutations. EdgeViewPermissions = "view_permissions" // Table holds the table name of the view in the database. - Table = "views" + Table = "sys_views" // ParentTable is the table that holds the parent relation/edge. - ParentTable = "views" + ParentTable = "sys_views" // ParentColumn is the table column denoting the parent relation/edge. ParentColumn = "parent_id" // ChildrenTable is the table that holds the children relation/edge. - ChildrenTable = "views" + ChildrenTable = "sys_views" // ChildrenColumn is the table column denoting the children relation/edge. ChildrenColumn = "parent_id" // ResourcesTable is the table that holds the resources relation/edge. The primary key declared below. @@ -102,6 +104,7 @@ var Columns = []string{ FieldIcon, FieldVisible, FieldSequence, + FieldTreePath, } var ( @@ -247,6 +250,11 @@ func BySequence(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSequence, opts...).ToFunc() } +// ByTreePath orders the results by the tree_path field. +func ByTreePath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTreePath, opts...).ToFunc() +} + // ByParentField orders the results by parent field. func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/internal/data/entity/ent/view/where.go b/internal/data/entity/ent/view/where.go index b8920f35..b43c68df 100644 --- a/internal/data/entity/ent/view/where.go +++ b/internal/data/entity/ent/view/where.go @@ -110,6 +110,11 @@ func Sequence(v int) predicate.View { return predicate.View(sql.FieldEQ(FieldSequence, v)) } +// TreePath applies equality check predicate on the "tree_path" field. It's identical to TreePathEQ. +func TreePath(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldTreePath, v)) +} + // CreateTimeEQ applies the EQ predicate on the "create_time" field. func CreateTimeEQ(v time.Time) predicate.View { return predicate.View(sql.FieldEQ(FieldCreateTime, v)) @@ -710,6 +715,81 @@ func SequenceLTE(v int) predicate.View { return predicate.View(sql.FieldLTE(FieldSequence, v)) } +// TreePathEQ applies the EQ predicate on the "tree_path" field. +func TreePathEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldTreePath, v)) +} + +// TreePathNEQ applies the NEQ predicate on the "tree_path" field. +func TreePathNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldTreePath, v)) +} + +// TreePathIn applies the In predicate on the "tree_path" field. +func TreePathIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldTreePath, vs...)) +} + +// TreePathNotIn applies the NotIn predicate on the "tree_path" field. +func TreePathNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldTreePath, vs...)) +} + +// TreePathGT applies the GT predicate on the "tree_path" field. +func TreePathGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldTreePath, v)) +} + +// TreePathGTE applies the GTE predicate on the "tree_path" field. +func TreePathGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldTreePath, v)) +} + +// TreePathLT applies the LT predicate on the "tree_path" field. +func TreePathLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldTreePath, v)) +} + +// TreePathLTE applies the LTE predicate on the "tree_path" field. +func TreePathLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldTreePath, v)) +} + +// TreePathContains applies the Contains predicate on the "tree_path" field. +func TreePathContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldTreePath, v)) +} + +// TreePathHasPrefix applies the HasPrefix predicate on the "tree_path" field. +func TreePathHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldTreePath, v)) +} + +// TreePathHasSuffix applies the HasSuffix predicate on the "tree_path" field. +func TreePathHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldTreePath, v)) +} + +// TreePathIsNil applies the IsNil predicate on the "tree_path" field. +func TreePathIsNil() predicate.View { + return predicate.View(sql.FieldIsNull(FieldTreePath)) +} + +// TreePathNotNil applies the NotNil predicate on the "tree_path" field. +func TreePathNotNil() predicate.View { + return predicate.View(sql.FieldNotNull(FieldTreePath)) +} + +// TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. +func TreePathEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldTreePath, v)) +} + +// TreePathContainsFold applies the ContainsFold predicate on the "tree_path" field. +func TreePathContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldTreePath, v)) +} + // HasParent applies the HasEdge predicate on the "parent" edge. func HasParent() predicate.View { return predicate.View(func(s *sql.Selector) { diff --git a/internal/data/entity/ent/view_create.go b/internal/data/entity/ent/view_create.go index 13458730..4c37f679 100644 --- a/internal/data/entity/ent/view_create.go +++ b/internal/data/entity/ent/view_create.go @@ -176,6 +176,20 @@ func (_c *ViewCreate) SetNillableSequence(v *int) *ViewCreate { return _c } +// SetTreePath sets the "tree_path" field. +func (_c *ViewCreate) SetTreePath(v string) *ViewCreate { + _c.mutation.SetTreePath(v) + return _c +} + +// SetNillableTreePath sets the "tree_path" field if the given value is not nil. +func (_c *ViewCreate) SetNillableTreePath(v *string) *ViewCreate { + if v != nil { + _c.SetTreePath(*v) + } + return _c +} + // SetID sets the "id" field. func (_c *ViewCreate) SetID(v int64) *ViewCreate { _c.mutation.SetID(v) @@ -457,6 +471,10 @@ func (_c *ViewCreate) createSpec() (*View, *sqlgraph.CreateSpec) { _spec.SetField(view.FieldSequence, field.TypeInt, value) _node.Sequence = value } + if value, ok := _c.mutation.TreePath(); ok { + _spec.SetField(view.FieldTreePath, field.TypeString, value) + _node.TreePath = value + } if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -582,12 +600,12 @@ func (_c *ViewCreate) SetView(input *View, fields ...string) *ViewCreate { } // SetViewWithZero set the View -func (_c *ViewCreate) SetViewWithZero(input *View, fields ...string) *ViewCreate { +func (_c *ViewCreate) SetViewSkipZero(input *View, fields ...string) *ViewCreate { m := _c.mutation if len(fields) == 0 { fields = view.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/view_query.go b/internal/data/entity/ent/view_query.go index fe151ebf..20e5e9ad 100644 --- a/internal/data/entity/ent/view_query.go +++ b/internal/data/entity/ent/view_query.go @@ -1007,6 +1007,7 @@ func (_q *ViewQuery) Modify(modifiers ...func(s *sql.Selector)) *ViewSelect { // Icon string `json:"icon,omitempty"` // Visible bool `json:"visible,omitempty"` // Sequence int `json:"sequence,omitempty"` +// TreePath string `json:"tree_path,omitempty"` // } // // client.View.Query(). @@ -1023,6 +1024,7 @@ func (_q *ViewQuery) Modify(modifiers ...func(s *sql.Selector)) *ViewSelect { // view.FieldIcon, // view.FieldVisible, // view.FieldSequence, +// view.FieldTreePath, // ). // Scan(ctx, &v) func (vq *ViewQuery) Omit(fields ...string) *ViewSelect { diff --git a/internal/data/entity/ent/view_update.go b/internal/data/entity/ent/view_update.go index 6af5d955..482f75fc 100644 --- a/internal/data/entity/ent/view_update.go +++ b/internal/data/entity/ent/view_update.go @@ -210,6 +210,26 @@ func (_u *ViewUpdate) AddSequence(v int) *ViewUpdate { return _u } +// SetTreePath sets the "tree_path" field. +func (_u *ViewUpdate) SetTreePath(v string) *ViewUpdate { + _u.mutation.SetTreePath(v) + return _u +} + +// SetNillableTreePath sets the "tree_path" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableTreePath(v *string) *ViewUpdate { + if v != nil { + _u.SetTreePath(*v) + } + return _u +} + +// ClearTreePath clears the value of the "tree_path" field. +func (_u *ViewUpdate) ClearTreePath() *ViewUpdate { + _u.mutation.ClearTreePath() + return _u +} + // SetParent sets the "parent" edge to the View entity. func (_u *ViewUpdate) SetParent(v *View) *ViewUpdate { return _u.SetParentID(v.ID) @@ -522,6 +542,12 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.AddedSequence(); ok { _spec.AddField(view.FieldSequence, field.TypeInt, value) } + if value, ok := _u.mutation.TreePath(); ok { + _spec.SetField(view.FieldTreePath, field.TypeString, value) + } + if _u.mutation.TreePathCleared() { + _spec.ClearField(view.FieldTreePath, field.TypeString) + } if _u.mutation.ParentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -1017,6 +1043,26 @@ func (_u *ViewUpdateOne) AddSequence(v int) *ViewUpdateOne { return _u } +// SetTreePath sets the "tree_path" field. +func (_u *ViewUpdateOne) SetTreePath(v string) *ViewUpdateOne { + _u.mutation.SetTreePath(v) + return _u +} + +// SetNillableTreePath sets the "tree_path" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableTreePath(v *string) *ViewUpdateOne { + if v != nil { + _u.SetTreePath(*v) + } + return _u +} + +// ClearTreePath clears the value of the "tree_path" field. +func (_u *ViewUpdateOne) ClearTreePath() *ViewUpdateOne { + _u.mutation.ClearTreePath() + return _u +} + // SetParent sets the "parent" edge to the View entity. func (_u *ViewUpdateOne) SetParent(v *View) *ViewUpdateOne { return _u.SetParentID(v.ID) @@ -1359,6 +1405,12 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { if value, ok := _u.mutation.AddedSequence(); ok { _spec.AddField(view.FieldSequence, field.TypeInt, value) } + if value, ok := _u.mutation.TreePath(); ok { + _spec.SetField(view.FieldTreePath, field.TypeString, value) + } + if _u.mutation.TreePathCleared() { + _spec.ClearField(view.FieldTreePath, field.TypeString) + } if _u.mutation.ParentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/internal/data/entity/ent/viewpermission/viewpermission.go b/internal/data/entity/ent/viewpermission/viewpermission.go index 2f016813..aca30d06 100644 --- a/internal/data/entity/ent/viewpermission/viewpermission.go +++ b/internal/data/entity/ent/viewpermission/viewpermission.go @@ -36,7 +36,7 @@ const ( ViewTable = "sys_view_permissions" // ViewInverseTable is the table name for the View entity. // It exists in this package in order to avoid circular dependency with the "view" package. - ViewInverseTable = "views" + ViewInverseTable = "sys_views" // ViewColumn is the table column denoting the view relation/edge. ViewColumn = "view_id" // PermissionTable is the table that holds the permission relation/edge. diff --git a/internal/data/entity/ent/viewpermission_create.go b/internal/data/entity/ent/viewpermission_create.go index 7e107b0e..ca189207 100644 --- a/internal/data/entity/ent/viewpermission_create.go +++ b/internal/data/entity/ent/viewpermission_create.go @@ -302,12 +302,12 @@ func (_c *ViewPermissionCreate) SetViewPermission(input *ViewPermission, fields } // SetViewPermissionWithZero set the ViewPermission -func (_c *ViewPermissionCreate) SetViewPermissionWithZero(input *ViewPermission, fields ...string) *ViewPermissionCreate { +func (_c *ViewPermissionCreate) SetViewPermissionSkipZero(input *ViewPermission, fields ...string) *ViewPermissionCreate { m := _c.mutation if len(fields) == 0 { fields = viewpermission.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/data/entity/ent/viewresource/viewresource.go b/internal/data/entity/ent/viewresource/viewresource.go index c95d09a7..c2f8dfe0 100644 --- a/internal/data/entity/ent/viewresource/viewresource.go +++ b/internal/data/entity/ent/viewresource/viewresource.go @@ -36,7 +36,7 @@ const ( ViewTable = "sys_view_resources" // ViewInverseTable is the table name for the View entity. // It exists in this package in order to avoid circular dependency with the "view" package. - ViewInverseTable = "views" + ViewInverseTable = "sys_views" // ViewColumn is the table column denoting the view relation/edge. ViewColumn = "view_id" // ResourceTable is the table that holds the resource relation/edge. diff --git a/internal/data/entity/ent/viewresource_create.go b/internal/data/entity/ent/viewresource_create.go index eca55428..6dd0af92 100644 --- a/internal/data/entity/ent/viewresource_create.go +++ b/internal/data/entity/ent/viewresource_create.go @@ -302,12 +302,12 @@ func (_c *ViewResourceCreate) SetViewResource(input *ViewResource, fields ...str } // SetViewResourceWithZero set the ViewResource -func (_c *ViewResourceCreate) SetViewResourceWithZero(input *ViewResource, fields ...string) *ViewResourceCreate { +func (_c *ViewResourceCreate) SetViewResourceSkipZero(input *ViewResource, fields ...string) *ViewResourceCreate { m := _c.mutation if len(fields) == 0 { fields = viewresource.Columns } - _ = m.SetFieldsWithZero(input, fields...) + _ = m.SetFieldsSkipZero(input, fields...) return _c } diff --git a/internal/features/system/biz/user.go b/internal/features/system/biz/user.go index c5499845..8064deec 100644 --- a/internal/features/system/biz/user.go +++ b/internal/features/system/biz/user.go @@ -34,7 +34,7 @@ func (uc *UserUseCase) UpdateUserRoles(ctx context.Context, id int64, roleIDs [] return uc.repo.AddRoleIDs(ctx, id, roleIDs) } -func (uc *UserUseCase) UpdateUserStatus(ctx context.Context, id int64, status int32) error { +func (uc *UserUseCase) UpdateUserStatus(ctx context.Context, id int64, status int8) error { return uc.repo.UpdateUserStatus(ctx, id, status) } diff --git a/internal/features/system/biz/view.go b/internal/features/system/biz/view.go index 0ae0093f..175953d0 100644 --- a/internal/features/system/biz/view.go +++ b/internal/features/system/biz/view.go @@ -19,12 +19,7 @@ func NewViewUseCase(repo dto.ViewRepo) *ViewUseCase { // ListViews retrieves a list of views. func (uc *ViewUseCase) ListViews(ctx context.Context, in *system.ListViewsRequest) ([]*types.View, int32, error) { - queryOpt := &dto.ViewQueryOption{ - Keyword: in.GetKeyword(), - Scope: in.GetScope(), - } - queryOpt.SetPaging(in.GetPage(), in.GetPageSize(), in.GetNoPaging()) - + queryOpt := dto.ListViewsRequestToQueryOption(in) return uc.repo.List(ctx, queryOpt) } diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index 27ee36bc..74242472 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -6,7 +6,6 @@ package dal import ( "context" - "strconv" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" @@ -52,14 +51,6 @@ func (r *resourceRepo) Get(ctx context.Context, id int64, opts ...*dto.ResourceQ } func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ...*dto.ResourceCreateOption) (*types.Resource, error) { - if res.ParentId > 0 { - parent, err := r.db.Resource(ctx).Get(ctx, res.ParentId) - if err != nil { - return nil, err - } - res.TreePath = parent.TreePath + strconv.FormatInt(parent.ID, 10) + r.Delimiter - } - entResource := dto.ConvertResourcePBToResource(res) create := r.db.Resource(ctx).Create().SetResource(entResource) diff --git a/internal/features/system/dal/view.go b/internal/features/system/dal/view.go index 254f26dd..5ef0867c 100644 --- a/internal/features/system/dal/view.go +++ b/internal/features/system/dal/view.go @@ -6,6 +6,7 @@ package dal import ( "context" + "strconv" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" @@ -16,12 +17,16 @@ import ( ) type viewRepo struct { - db *ent.Database + db *ent.Database + Delimiter string } // NewViewRepo creates a new view repository. func NewViewRepo(database *ent.Database) dto.ViewRepo { - return &viewRepo{db: database} + return &viewRepo{ + db: database, + Delimiter: "/", + } } // Get retrieves a single view by its ID. @@ -83,8 +88,16 @@ func (r *viewRepo) List(ctx context.Context, opts ...*dto.ViewQueryOption) ([]*t // Create creates a new view. func (r *viewRepo) Create(ctx context.Context, in *types.View, opts ...*dto.ViewCreateOption) (*types.View, error) { + // Calculate TreePath before converting to ent object + if in.ParentId > 0 { + parent, err := r.db.View(ctx).Get(ctx, in.ParentId) + if err != nil { + return nil, err + } + in.TreePath = parent.TreePath + strconv.FormatInt(parent.ID, 10) + r.Delimiter + } + entView := dto.ConvertViewPBToView(in) - // After template modification, SetView is now the method that includes zero values. create := r.db.View(ctx).Create().SetView(entView) saved, err := create.Save(ctx) if err != nil { @@ -99,11 +112,8 @@ func (r *viewRepo) Update(ctx context.Context, in *types.View, opts ...*dto.View entView := dto.ConvertViewPBToView(in) update := r.db.View(ctx).UpdateOneID(in.Id) - // After template modification, SetView is now the method that includes zero values. updateCols := db.UpdateFields(opt.UpdateMask, view.ValidColumn, in) if len(updateCols) > 0 { - // The primary key should never be in the update list. - // UpdateFields already ensures this. update.SetView(entView, updateCols...) } else { update.SetView(entView) diff --git a/internal/features/system/dto/custom.gen.go b/internal/features/system/dto/custom.gen.go index 263fb2d7..afd154bd 100644 --- a/internal/features/system/dto/custom.gen.go +++ b/internal/features/system/dto/custom.gen.go @@ -2,3 +2,21 @@ // More info: https://github.com/origadmin/abgen package dto + +import ( + "origadmin/application/admin/internal/data/entity/ent/resource" +) + +// ConvertInt32ToStatus is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertInt32ToStatus(from int32) resource.Status { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertStatusToInt32 is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStatusToInt32(from resource.Status) int32 { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index 235c373e..144fda3d 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -1200,11 +1200,14 @@ func ConvertViewPBToView(from *ViewPB) *View { UpdateTime: ConvertTimestampToTime(from.UpdateTime), ParentID: from.ParentId, Keyword: from.Keyword, + Scope: from.Scope, Name: from.Name, Type: ConvertStringToType(from.Type), Path: from.Path, Icon: from.Icon, + Visible: from.Visible, Sequence: int(from.Sequence), + TreePath: from.TreePath, } return to } @@ -1221,10 +1224,13 @@ func ConvertViewToViewPB(from *View) *ViewPB { UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Keyword: from.Keyword, Name: from.Name, + Scope: from.Scope, Sequence: int32(from.Sequence), Type: ConvertTypeToString(from.Type), Icon: from.Icon, + Visible: from.Visible, Path: from.Path, + TreePath: from.TreePath, ParentId: from.ParentID, Children: ConvertViewsToViewsPB(from.Edges.Children), Parent: ConvertViewToViewPB(from.Edges.Parent), diff --git a/internal/features/system/dto/user.go b/internal/features/system/dto/user.go index 97d55e7b..75a1e172 100644 --- a/internal/features/system/dto/user.go +++ b/internal/features/system/dto/user.go @@ -26,7 +26,7 @@ type UserRepo interface { GetByUsername(context.Context, string) (*types.User, error) GetRoleIDs(context.Context, int64) ([]int64, error) ListResourceByUserID(context.Context, int64) ([]*types.Resource, error) - UpdateUserStatus(ctx context.Context, id int64, status int32) error + UpdateUserStatus(ctx context.Context, id int64, status int8) error } // UserQueryOption specifies options for querying users. diff --git a/internal/features/system/dto/view.go b/internal/features/system/dto/view.go index 580e9bf7..58de8c16 100644 --- a/internal/features/system/dto/view.go +++ b/internal/features/system/dto/view.go @@ -25,7 +25,8 @@ type ViewRepo interface { // ViewQueryOption specifies options for querying views. type ViewQueryOption struct { repo.QueryOption - Scope string + Scope string + Keyword string } // ViewCreateOption specifies options for creating a view. @@ -44,6 +45,7 @@ func ListViewsRequestToQueryOption(req *system.ListViewsRequest) *ViewQueryOptio return &ViewQueryOption{ QueryOption: repo.QueryOptionFromRequest(req), Scope: req.GetScope(), + Keyword: req.GetKeyword(), } } diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index a11af48f..6cfb136d 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -73,6 +73,7 @@ func NewHTTPServer(cfg *httpv1.Server, svc *service.SystemService, logger log.Lo systemv1.RegisterRoleServiceHTTPServer(srv, svc) systemv1.RegisterPermissionServiceHTTPServer(srv, svc) systemv1.RegisterResourceServiceHTTPServer(srv, svc) + systemv1.RegisterViewServiceHTTPServer(srv, svc) srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { log.Infof("HTTP %s %s", method, path) }) @@ -99,6 +100,7 @@ func NewGRPCServer(cfg *grpcv1.Server, svc *service.SystemService, logger log.Lo systemv1.RegisterRoleServiceServer(srv, svc) systemv1.RegisterPermissionServiceServer(srv, svc) systemv1.RegisterResourceServiceServer(srv, svc) + systemv1.RegisterViewServiceServer(srv, svc) return srv, nil } diff --git a/internal/features/system/service/user.go b/internal/features/system/service/user.go index 43687fe0..2ef617cc 100644 --- a/internal/features/system/service/user.go +++ b/internal/features/system/service/user.go @@ -29,7 +29,7 @@ func (s *SystemService) UpdateUserRoles(ctx context.Context, req *system.UpdateU } func (s *SystemService) UpdateUserStatus(ctx context.Context, req *system.UpdateUserStatusRequest) (*system.UpdateUserStatusResponse, error) { - err := s.User.UpdateUserStatus(ctx, req.GetId(), req.GetStatus()) + err := s.User.UpdateUserStatus(ctx, req.GetId(), int8(req.GetStatus())) if err != nil { return nil, err } diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 11808267..de48380c 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -3992,6 +3992,9 @@ components: path: type: string description: Path holds the value of the "path" field. + tree_path: + type: string + description: TreePath holds the value of the "tree_path" field. properties: type: string description: Properties holds the value of the "properties" field. From b1d2b534a9837a6f5ff143c56a5bca15bd7852eb Mon Sep 17 00:00:00 2001 From: godcong Date: Fri, 26 Dec 2025 04:42:03 +0800 Subject: [PATCH 102/158] feat(rbac): add view CRUD endpoints and fix proto field comments --- api/http/api/v1/sys/rbac.service.http | 65 +++++++++++++++++++ api/v1/proto/system/department.proto | 2 +- api/v1/proto/system/permission.proto | 2 +- api/v1/proto/system/position.proto | 2 +- api/v1/proto/system/role.proto | 2 +- api/v1/proto/system/user.proto | 2 +- .../data/entity/ent/department/department.go | 2 - internal/data/entity/ent/department_create.go | 5 -- internal/data/entity/ent/department_update.go | 10 --- internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/runtime/runtime.go | 12 ---- internal/data/entity/ent/user/user.go | 2 - internal/data/entity/ent/user_create.go | 5 -- internal/data/entity/ent/user_update.go | 10 --- internal/data/entity/ent/view/view.go | 2 - internal/data/entity/ent/view_create.go | 5 -- internal/data/entity/ent/view_update.go | 10 --- internal/features/system/biz/permission.go | 1 + internal/features/system/biz/resource.go | 6 ++ internal/features/system/biz/role.go | 6 ++ internal/features/system/biz/user.go | 6 ++ internal/features/system/biz/view.go | 11 ++++ internal/features/system/dal/permission.go | 6 +- internal/features/system/dal/resource.go | 6 +- internal/features/system/dal/role.go | 6 +- internal/features/system/dal/user.go | 6 +- internal/features/system/dal/view.go | 10 ++- internal/features/system/dto/custom.gen.go | 18 ----- internal/features/system/dto/dto.go | 28 ++++++++ .../features/system/service/permission.go | 11 ++++ internal/features/system/service/resource.go | 11 ++++ internal/features/system/service/role.go | 11 ++++ internal/features/system/service/user.go | 23 +++++++ internal/features/system/service/view.go | 12 ++++ internal/helpers/ent/mixin/mixin_id.go | 2 +- 35 files changed, 222 insertions(+), 98 deletions(-) diff --git a/api/http/api/v1/sys/rbac.service.http b/api/http/api/v1/sys/rbac.service.http index 33e07e3a..272bbf17 100644 --- a/api/http/api/v1/sys/rbac.service.http +++ b/api/http/api/v1/sys/rbac.service.http @@ -1,5 +1,7 @@ @token = eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzYyNzEyMDEsImlzcyI6ImxvY2FsaG9zdCIsInN1YiI6ImFkbWluIn0.3x9WnK9OZQUFdYYBAwVwqtNrMK3VRZJjBgQXRnQLNd8K4m0WwfTyAiA1TfwlUyh8t95WXfl99AkXJEJUWAQppg @host = http://127.0.0.1:8080 +# Default ID for the view. This will be overwritten by the CreateView request. +@viewId = 1 ### # RBAC - Resources (Direct Service Test) @@ -177,3 +179,66 @@ Content-Type: application/json } ### +# RBAC - Views (Service Test) +# +# IMPORTANT: You must run "CreateView" first to set the {{viewId}} variable. +### + +# @name CreateView +# STEP 1: Create a new view and capture its ID +POST {{host}}/sys/views +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "view": { + "keyword": "dashboard_view_test_keyword", + "name": "dashboard_view_test", + "title": "Dashboard View Test", + "path": "/dashboard_test", + "component": "pages/DashboardTest", + "scope": "system" + } +} + +> {% + // This script runs after the request and saves the new ID to the 'viewId' variable + client.global.set("viewId", response.body.id); +%} + +### + +# @name ListView +# List all views, with filtering +GET {{host}}/sys/views?scope=system&keyword=dashboard +Authorization: Bearer {{token}} + +### + +# @name GetView +# STEP 2: Get the view created in STEP 1 +GET {{host}}/sys/views/{{viewId}} +Authorization: Bearer {{token}} + +### + +# @name UpdateView +# STEP 3: Update the view created in STEP 1 +PUT {{host}}/sys/views/{{viewId}} +Authorization: Bearer {{token}} +Content-Type: application/json + +{ + "view": { + "title": "System Dashboard View (Updated)" + } +} + +### + +# @name DeleteView +# STEP 4: Delete the view created in STEP 1 +DELETE {{host}}/sys/views/{{viewId}} +Authorization: Bearer {{token}} + +### diff --git a/api/v1/proto/system/department.proto b/api/v1/proto/system/department.proto index 4b88dff8..650574c9 100644 --- a/api/v1/proto/system/department.proto +++ b/api/v1/proto/system/department.proto @@ -58,7 +58,7 @@ message ListDepartmentsRequest { message ListDepartmentsResponse { // The total number of items in the list. int32 total = 1 [json_name = "total"]; - // The paging menus + // The paging departments repeated api.v1.services.types.Department departments = 2 [json_name = "departments"]; // The page number. int32 page = 3 [json_name = "page"]; diff --git a/api/v1/proto/system/permission.proto b/api/v1/proto/system/permission.proto index 177ff247..666c3ed7 100644 --- a/api/v1/proto/system/permission.proto +++ b/api/v1/proto/system/permission.proto @@ -60,7 +60,7 @@ message ListPermissionsRequest { message ListPermissionsResponse { // The total number of items in the list. int32 total = 1 [json_name = "total"]; - // The paging menus + // The paging permissions repeated api.v1.services.types.Permission permissions = 2 [json_name = "permissions"]; // The page number. int32 page = 3 [json_name = "page"]; diff --git a/api/v1/proto/system/position.proto b/api/v1/proto/system/position.proto index 018d2af6..2c7edb6b 100644 --- a/api/v1/proto/system/position.proto +++ b/api/v1/proto/system/position.proto @@ -58,7 +58,7 @@ message ListPositionsRequest { message ListPositionsResponse { // The total number of items in the list. int32 total = 1 [json_name = "total"]; - // The paging menus + // The paging positions repeated api.v1.services.types.Position positions = 2 [json_name = "positions"]; // The page number. int32 page = 3 [json_name = "page"]; diff --git a/api/v1/proto/system/role.proto b/api/v1/proto/system/role.proto index ad492580..a94aaeb3 100644 --- a/api/v1/proto/system/role.proto +++ b/api/v1/proto/system/role.proto @@ -58,7 +58,7 @@ message ListRolesRequest { message ListRolesResponse { // The total number of items in the list. int32 total = 1 [json_name = "total"]; - // The paging menus + // The paging roles repeated api.v1.services.types.Role roles = 2 [json_name = "roles"]; // The page number. int32 page = 3 [json_name = "page"]; diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index 431cdece..295a66f9 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -110,7 +110,7 @@ message ListUsersRequest { message ListUsersResponse { // The total number of items in the list. int32 total = 1 [json_name = "total"]; - // The paging menus + // The paging users repeated api.v1.services.types.User users = 2 [json_name = "users"]; // The page number. int32 page = 3 [json_name = "page"]; diff --git a/internal/data/entity/ent/department/department.go b/internal/data/entity/ent/department/department.go index ea3a35e2..c6ef00ae 100644 --- a/internal/data/entity/ent/department/department.go +++ b/internal/data/entity/ent/department/department.go @@ -131,8 +131,6 @@ var ( DefaultDescription string // DescriptionValidator is a validator for the "description" field. It is called by the builders before save. DescriptionValidator func(string) error - // ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. - ParentIDValidator func(int64) error // DefaultID holds the default value on creation for the "id" field. DefaultID func() int64 // IDValidator is a validator for the "id" field. It is called by the builders before save. diff --git a/internal/data/entity/ent/department_create.go b/internal/data/entity/ent/department_create.go index 44f88cc6..8e351cf9 100644 --- a/internal/data/entity/ent/department_create.go +++ b/internal/data/entity/ent/department_create.go @@ -344,11 +344,6 @@ func (_c *DepartmentCreate) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Department.description": %w`, err)} } } - if v, ok := _c.mutation.ParentID(); ok { - if err := department.ParentIDValidator(v); err != nil { - return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Department.parent_id": %w`, err)} - } - } if v, ok := _c.mutation.ID(); ok { if err := department.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Department.id": %w`, err)} diff --git a/internal/data/entity/ent/department_update.go b/internal/data/entity/ent/department_update.go index de2fb0f7..fcaed3e8 100644 --- a/internal/data/entity/ent/department_update.go +++ b/internal/data/entity/ent/department_update.go @@ -395,11 +395,6 @@ func (_u *DepartmentUpdate) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Department.description": %w`, err)} } } - if v, ok := _u.mutation.ParentID(); ok { - if err := department.ParentIDValidator(v); err != nil { - return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Department.parent_id": %w`, err)} - } - } return nil } @@ -1061,11 +1056,6 @@ func (_u *DepartmentUpdateOne) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Department.description": %w`, err)} } } - if v, ok := _u.mutation.ParentID(); ok { - if err := department.ParentIDValidator(v); err != nil { - return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "Department.parent_id": %w`, err)} - } - } return nil } diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index c1771702..7175fa98 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index 3f255cd4..e38e4a7b 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -108,10 +108,6 @@ func init() { department.DefaultDescription = departmentDescDescription.Default.(string) // department.DescriptionValidator is a validator for the "description" field. It is called by the builders before save. department.DescriptionValidator = departmentDescDescription.Validators[0].(func(string) error) - // departmentDescParentID is the schema descriptor for parent_id field. - departmentDescParentID := departmentFields[7].Descriptor() - // department.ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. - department.ParentIDValidator = departmentDescParentID.Validators[0].(func(int64) error) // departmentDescID is the schema descriptor for id field. departmentDescID := departmentMixinFields0[0].Descriptor() // department.DefaultID holds the default value on creation for the id field. @@ -526,10 +522,6 @@ func init() { userDescLoginTime := userFields[18].Descriptor() // user.DefaultLoginTime holds the default value on creation for the login_time field. user.DefaultLoginTime = userDescLoginTime.Default.(func() time.Time) - // userDescManagerID is the schema descriptor for manager_id field. - userDescManagerID := userFields[20].Descriptor() - // user.ManagerIDValidator is a validator for the "manager_id" field. It is called by the builders before save. - user.ManagerIDValidator = userDescManagerID.Validators[0].(func(int64) error) // userDescManager is the schema descriptor for manager field. userDescManager := userFields[21].Descriptor() // user.DefaultManager holds the default value on creation for the manager field. @@ -589,10 +581,6 @@ func init() { view.DefaultUpdateTime = viewDescUpdateTime.Default.(func() time.Time) // view.UpdateDefaultUpdateTime holds the default value on update for the update_time field. view.UpdateDefaultUpdateTime = viewDescUpdateTime.UpdateDefault.(func() time.Time) - // viewDescParentID is the schema descriptor for parent_id field. - viewDescParentID := viewFields[0].Descriptor() - // view.ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. - view.ParentIDValidator = viewDescParentID.Validators[0].(func(int64) error) // viewDescKeyword is the schema descriptor for keyword field. viewDescKeyword := viewFields[1].Descriptor() // view.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. diff --git a/internal/data/entity/ent/user/user.go b/internal/data/entity/ent/user/user.go index e8e9d1de..0b354301 100644 --- a/internal/data/entity/ent/user/user.go +++ b/internal/data/entity/ent/user/user.go @@ -257,8 +257,6 @@ var ( DefaultLastLoginTime func() time.Time // DefaultLoginTime holds the default value on creation for the "login_time" field. DefaultLoginTime func() time.Time - // ManagerIDValidator is a validator for the "manager_id" field. It is called by the builders before save. - ManagerIDValidator func(int64) error // DefaultManager holds the default value on creation for the "manager" field. DefaultManager string // DefaultID holds the default value on creation for the "id" field. diff --git a/internal/data/entity/ent/user_create.go b/internal/data/entity/ent/user_create.go index 2fa688b3..fc4c26e9 100644 --- a/internal/data/entity/ent/user_create.go +++ b/internal/data/entity/ent/user_create.go @@ -775,11 +775,6 @@ func (_c *UserCreate) check() error { if _, ok := _c.mutation.LoginTime(); !ok { return &ValidationError{Name: "login_time", err: errors.New(`ent: missing required field "User.login_time"`)} } - if v, ok := _c.mutation.ManagerID(); ok { - if err := user.ManagerIDValidator(v); err != nil { - return &ValidationError{Name: "manager_id", err: fmt.Errorf(`ent: validator failed for field "User.manager_id": %w`, err)} - } - } if _, ok := _c.mutation.Manager(); !ok { return &ValidationError{Name: "manager", err: errors.New(`ent: missing required field "User.manager"`)} } diff --git a/internal/data/entity/ent/user_update.go b/internal/data/entity/ent/user_update.go index e0e45095..e1bb33bd 100644 --- a/internal/data/entity/ent/user_update.go +++ b/internal/data/entity/ent/user_update.go @@ -785,11 +785,6 @@ func (_u *UserUpdate) check() error { return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} } } - if v, ok := _u.mutation.ManagerID(); ok { - if err := user.ManagerIDValidator(v); err != nil { - return &ValidationError{Name: "manager_id", err: fmt.Errorf(`ent: validator failed for field "User.manager_id": %w`, err)} - } - } return nil } @@ -1970,11 +1965,6 @@ func (_u *UserUpdateOne) check() error { return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} } } - if v, ok := _u.mutation.ManagerID(); ok { - if err := user.ManagerIDValidator(v); err != nil { - return &ValidationError{Name: "manager_id", err: fmt.Errorf(`ent: validator failed for field "User.manager_id": %w`, err)} - } - } return nil } diff --git a/internal/data/entity/ent/view/view.go b/internal/data/entity/ent/view/view.go index 94ece1d6..becfd145 100644 --- a/internal/data/entity/ent/view/view.go +++ b/internal/data/entity/ent/view/view.go @@ -133,8 +133,6 @@ var ( DefaultUpdateTime func() time.Time // UpdateDefaultUpdateTime holds the default value on update for the "update_time" field. UpdateDefaultUpdateTime func() time.Time - // ParentIDValidator is a validator for the "parent_id" field. It is called by the builders before save. - ParentIDValidator func(int64) error // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. KeywordValidator func(string) error // DefaultScope holds the default value on creation for the "scope" field. diff --git a/internal/data/entity/ent/view_create.go b/internal/data/entity/ent/view_create.go index 4c37f679..b9e34252 100644 --- a/internal/data/entity/ent/view_create.go +++ b/internal/data/entity/ent/view_create.go @@ -357,11 +357,6 @@ func (_c *ViewCreate) check() error { if _, ok := _c.mutation.UpdateTime(); !ok { return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "View.update_time"`)} } - if v, ok := _c.mutation.ParentID(); ok { - if err := view.ParentIDValidator(v); err != nil { - return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "View.parent_id": %w`, err)} - } - } if _, ok := _c.mutation.Keyword(); !ok { return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "View.keyword"`)} } diff --git a/internal/data/entity/ent/view_update.go b/internal/data/entity/ent/view_update.go index 482f75fc..9902cfcc 100644 --- a/internal/data/entity/ent/view_update.go +++ b/internal/data/entity/ent/view_update.go @@ -464,11 +464,6 @@ func (_u *ViewUpdate) defaults() { // check runs all checks and user-defined validators on the builder. func (_u *ViewUpdate) check() error { - if v, ok := _u.mutation.ParentID(); ok { - if err := view.ParentIDValidator(v); err != nil { - return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "View.parent_id": %w`, err)} - } - } if v, ok := _u.mutation.Keyword(); ok { if err := view.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "View.keyword": %w`, err)} @@ -1310,11 +1305,6 @@ func (_u *ViewUpdateOne) defaults() { // check runs all checks and user-defined validators on the builder. func (_u *ViewUpdateOne) check() error { - if v, ok := _u.mutation.ParentID(); ok { - if err := view.ParentIDValidator(v); err != nil { - return &ValidationError{Name: "parent_id", err: fmt.Errorf(`ent: validator failed for field "View.parent_id": %w`, err)} - } - } if v, ok := _u.mutation.Keyword(); ok { if err := view.KeywordValidator(v); err != nil { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "View.keyword": %w`, err)} diff --git a/internal/features/system/biz/permission.go b/internal/features/system/biz/permission.go index a91c7c73..a6f7a40f 100644 --- a/internal/features/system/biz/permission.go +++ b/internal/features/system/biz/permission.go @@ -10,6 +10,7 @@ import ( "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/features/system/dto" ) diff --git a/internal/features/system/biz/resource.go b/internal/features/system/biz/resource.go index c3f07827..da9a2555 100644 --- a/internal/features/system/biz/resource.go +++ b/internal/features/system/biz/resource.go @@ -10,6 +10,7 @@ import ( "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/features/system/dto" ) @@ -33,6 +34,11 @@ func (uc *ResourceUseCase) GetResource(ctx context.Context, id int64) (*types.Re } func (uc *ResourceUseCase) CreateResource(ctx context.Context, in *types.Resource) (*types.Resource, error) { + // Set business-defined default values. + if in.Status == 0 { + in.Status = int32(enums.StatusEnabled) + } + return uc.repo.Create(ctx, in) } diff --git a/internal/features/system/biz/role.go b/internal/features/system/biz/role.go index fb5618d9..d2c437bb 100644 --- a/internal/features/system/biz/role.go +++ b/internal/features/system/biz/role.go @@ -10,6 +10,7 @@ import ( "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/features/system/dto" ) @@ -33,6 +34,11 @@ func (uc *RoleUseCase) GetRole(ctx context.Context, id int64) (*types.Role, erro } func (uc *RoleUseCase) CreateRole(ctx context.Context, in *types.Role) (*types.Role, error) { + // Set business-defined default values. + if in.Status == 0 { + in.Status = int32(enums.StatusEnabled) + } + return uc.repo.Create(ctx, in) } diff --git a/internal/features/system/biz/user.go b/internal/features/system/biz/user.go index 8064deec..f0de4568 100644 --- a/internal/features/system/biz/user.go +++ b/internal/features/system/biz/user.go @@ -12,6 +12,7 @@ import ( "github.com/origadmin/toolkits/crypto/hash" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/features/system/dto" ) @@ -53,6 +54,11 @@ func (uc *UserUseCase) GetUser(ctx context.Context, id int64) (*types.User, erro } func (uc *UserUseCase) CreateUser(ctx context.Context, in *types.User, password string) (*types.User, error) { + // Set business-defined default values. + if in.Status == 0 { + in.Status = int32(enums.StatusEnabled) + } + hashedPassword, err := uc.hasher.Hash(password) if err != nil { return nil, err diff --git a/internal/features/system/biz/view.go b/internal/features/system/biz/view.go index 175953d0..7c906f5e 100644 --- a/internal/features/system/biz/view.go +++ b/internal/features/system/biz/view.go @@ -2,8 +2,10 @@ package biz import ( "context" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/features/system/dto" ) @@ -30,6 +32,15 @@ func (uc *ViewUseCase) GetView(ctx context.Context, id int64) (*types.View, erro // CreateView creates a new view. func (uc *ViewUseCase) CreateView(ctx context.Context, in *types.View) (*types.View, error) { + // Set business-defined default values before passing to the data layer. + // This is the correct layer to ensure the business object is valid. + if in.Type == "" || in.Type == dto.ViewTypeUnknown.String() { + in.Type = dto.ViewTypePage.String() + } + if in.Status == 0 { + in.Status = int32(enums.StatusEnabled) + } + return uc.repo.Create(ctx, in) } diff --git a/internal/features/system/dal/permission.go b/internal/features/system/dal/permission.go index fb59b7c4..4e2be1d5 100644 --- a/internal/features/system/dal/permission.go +++ b/internal/features/system/dal/permission.go @@ -51,7 +51,7 @@ func (r *permissionRepo) Get(ctx context.Context, id int64, opts ...*dto.Permiss func (r *permissionRepo) Create(ctx context.Context, p *types.Permission, opts ...*dto.PermissionCreateOption) (*types.Permission, error) { entPermission := dto.ConvertPermissionPBToPermission(p) - create := r.db.Permission(ctx).Create().SetPermission(entPermission) + create := r.db.Permission(ctx).Create().SetPermissionSkipZero(entPermission) saved, err := create.Save(ctx) if err != nil { @@ -71,9 +71,11 @@ func (r *permissionRepo) Update(ctx context.Context, p *types.Permission, opts . updateCols := db.UpdateFields(opt.UpdateMask, permission.ValidColumn, p) if len(updateCols) > 0 { + // If a field mask is present, update only the specified fields, including zero values. update.SetPermission(entPermission, updateCols...) } else { - update.SetPermission(entPermission) + // If no field mask, skip zero values to prevent accidental clearing of fields. + update.SetPermissionSkipZero(entPermission) } saved, err := update.Save(ctx) diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index 74242472..d5bcd77e 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -52,7 +52,7 @@ func (r *resourceRepo) Get(ctx context.Context, id int64, opts ...*dto.ResourceQ func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ...*dto.ResourceCreateOption) (*types.Resource, error) { entResource := dto.ConvertResourcePBToResource(res) - create := r.db.Resource(ctx).Create().SetResource(entResource) + create := r.db.Resource(ctx).Create().SetResourceSkipZero(entResource) saved, err := create.Save(ctx) if err != nil { @@ -72,9 +72,11 @@ func (r *resourceRepo) Update(ctx context.Context, res *types.Resource, opts ... updateCols := db.UpdateFields(opt.UpdateMask, resource.ValidColumn, res) if len(updateCols) > 0 { + // If a field mask is present, update only the specified fields, including zero values. update.SetResource(entResource, updateCols...) } else { - update.SetResource(entResource) + // If no field mask, skip zero values to prevent accidental clearing of fields. + update.SetResourceSkipZero(entResource) } saved, err := update.Save(ctx) diff --git a/internal/features/system/dal/role.go b/internal/features/system/dal/role.go index 867918d1..8d180640 100644 --- a/internal/features/system/dal/role.go +++ b/internal/features/system/dal/role.go @@ -64,7 +64,7 @@ func (r *roleRepo) Create(ctx context.Context, rl *types.Role, opts ...*dto.Role } entRole := dto.ConvertRolePBToRole(rl) - create := r.db.Role(ctx).Create().SetRole(entRole) + create := r.db.Role(ctx).Create().SetRoleSkipZero(entRole) saved, err := create.Save(ctx) if err != nil { @@ -84,9 +84,11 @@ func (r *roleRepo) Update(ctx context.Context, rl *types.Role, opts ...*dto.Role updateCols := db.UpdateFields(opt.UpdateMask, role.ValidColumn, rl) if len(updateCols) > 0 { + // If a field mask is present, update only the specified fields, including zero values. update.SetRole(entRole, updateCols...) } else { - update.SetRole(entRole) + // If no field mask, skip zero values to prevent accidental clearing of fields. + update.SetRoleSkipZero(entRole) } saved, err := update.Save(ctx) diff --git a/internal/features/system/dal/user.go b/internal/features/system/dal/user.go index 7f086c36..2d309d5d 100644 --- a/internal/features/system/dal/user.go +++ b/internal/features/system/dal/user.go @@ -65,7 +65,7 @@ func (r *userRepo) Create(ctx context.Context, u *types.User, password string, o if password != "" { entUser.EncryptedPassword = password } - create := r.db.User(ctx).Create().SetUser(entUser) + create := r.db.User(ctx).Create().SetUserSkipZero(entUser) saved, err := create.Save(ctx) if err != nil { return nil, err @@ -84,9 +84,11 @@ func (r *userRepo) Update(ctx context.Context, u *types.User, opts ...*dto.UserU updateCols := db.UpdateFields(opt.UpdateMask, user.ValidColumn, u) if len(updateCols) > 0 { + // If a field mask is present, update only the specified fields, including zero values. update.SetUser(entUser, updateCols...) } else { - update.SetUser(entUser) + // If no field mask, skip zero values to prevent accidental clearing of fields. + update.SetUserSkipZero(entUser) } saved, err := update.Save(ctx) diff --git a/internal/features/system/dal/view.go b/internal/features/system/dal/view.go index 5ef0867c..136b7a4a 100644 --- a/internal/features/system/dal/view.go +++ b/internal/features/system/dal/view.go @@ -6,6 +6,7 @@ package dal import ( "context" + "errors" "strconv" "origadmin/application/admin/api/v1/services/types" @@ -88,6 +89,9 @@ func (r *viewRepo) List(ctx context.Context, opts ...*dto.ViewQueryOption) ([]*t // Create creates a new view. func (r *viewRepo) Create(ctx context.Context, in *types.View, opts ...*dto.ViewCreateOption) (*types.View, error) { + if in == nil { + return nil, errors.New("input view data cannot be nil") + } // Calculate TreePath before converting to ent object if in.ParentId > 0 { parent, err := r.db.View(ctx).Get(ctx, in.ParentId) @@ -98,7 +102,7 @@ func (r *viewRepo) Create(ctx context.Context, in *types.View, opts ...*dto.View } entView := dto.ConvertViewPBToView(in) - create := r.db.View(ctx).Create().SetView(entView) + create := r.db.View(ctx).Create().SetViewSkipZero(entView) saved, err := create.Save(ctx) if err != nil { return nil, err @@ -114,9 +118,11 @@ func (r *viewRepo) Update(ctx context.Context, in *types.View, opts ...*dto.View updateCols := db.UpdateFields(opt.UpdateMask, view.ValidColumn, in) if len(updateCols) > 0 { + // If a field mask is present, update only the specified fields, including zero values. update.SetView(entView, updateCols...) } else { - update.SetView(entView) + // If no field mask, skip zero values to prevent accidental clearing of fields. + update.SetViewSkipZero(entView) } saved, err := update.Save(ctx) diff --git a/internal/features/system/dto/custom.gen.go b/internal/features/system/dto/custom.gen.go index afd154bd..263fb2d7 100644 --- a/internal/features/system/dto/custom.gen.go +++ b/internal/features/system/dto/custom.gen.go @@ -2,21 +2,3 @@ // More info: https://github.com/origadmin/abgen package dto - -import ( - "origadmin/application/admin/internal/data/entity/ent/resource" -) - -// ConvertInt32ToStatus is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertInt32ToStatus(from int32) resource.Status { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} - -// ConvertStatusToInt32 is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertStatusToInt32(from resource.Status) int32 { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index ccb21221..0df28c0d 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -1,6 +1,7 @@ package dto import ( + "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/data/entity/ent/view" ) @@ -14,6 +15,11 @@ import ( //go:abgen:convert:source:suffix="" //go:abgen:convert:target:suffix="PB" +const ( + StatusEnabled = 1 + StatusDisabled = 0 +) + // ConvertGenderToString is a custom conversion function stub. // Please implement this function to complete the conversion. func ConvertGenderToString(from user.Gender) string { @@ -47,3 +53,25 @@ func ConvertStringToType(from string) view.Type { func ConvertTypeToString(from view.Type) string { return ViewTypeName(from) } + +// ConvertInt32ToStatus is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertInt32ToStatus(from int32) resource.Status { + switch from { + case 1: + return resource.StatusEnabled + default: + return resource.StatusDisabled + } +} + +// ConvertStatusToInt32 is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStatusToInt32(from resource.Status) int32 { + switch from { + case resource.StatusEnabled: + return 1 + default: + return 0 + } +} diff --git a/internal/features/system/service/permission.go b/internal/features/system/service/permission.go index 8f8e6e48..cb7f5f46 100644 --- a/internal/features/system/service/permission.go +++ b/internal/features/system/service/permission.go @@ -7,7 +7,9 @@ package service import ( "context" + "github.com/origadmin/runtime/errors" "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data/entity/ent" ) func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPermissionsRequest) (*system.ListPermissionsResponse, error) { @@ -26,6 +28,9 @@ func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPer func (s *SystemService) GetPermission(ctx context.Context, req *system.GetPermissionRequest) (*system.GetPermissionResponse, error) { permission, err := s.Permission.GetPermission(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("PERMISSION_NOT_FOUND", "Permission not found") + } return nil, err } return &system.GetPermissionResponse{Permission: permission}, nil @@ -42,6 +47,9 @@ func (s *SystemService) CreatePermission(ctx context.Context, req *system.Create func (s *SystemService) UpdatePermission(ctx context.Context, req *system.UpdatePermissionRequest) (*system.UpdatePermissionResponse, error) { permission, err := s.Permission.UpdatePermission(ctx, req.GetPermission()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("PERMISSION_NOT_FOUND", "Permission not found") + } return nil, err } return &system.UpdatePermissionResponse{Permission: permission}, nil @@ -50,6 +58,9 @@ func (s *SystemService) UpdatePermission(ctx context.Context, req *system.Update func (s *SystemService) DeletePermission(ctx context.Context, req *system.DeletePermissionRequest) (*system.DeletePermissionResponse, error) { err := s.Permission.DeletePermission(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("PERMISSION_NOT_FOUND", "Permission not found") + } return nil, err } return &system.DeletePermissionResponse{}, nil diff --git a/internal/features/system/service/resource.go b/internal/features/system/service/resource.go index 8a8a5bf3..0ae59dc0 100644 --- a/internal/features/system/service/resource.go +++ b/internal/features/system/service/resource.go @@ -7,7 +7,9 @@ package service import ( "context" + "github.com/origadmin/runtime/errors" "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data/entity/ent" ) func (s *SystemService) ListResources(ctx context.Context, req *system.ListResourcesRequest) (*system.ListResourcesResponse, error) { @@ -26,6 +28,9 @@ func (s *SystemService) ListResources(ctx context.Context, req *system.ListResou func (s *SystemService) GetResource(ctx context.Context, req *system.GetResourceRequest) (*system.GetResourceResponse, error) { resource, err := s.Resource.GetResource(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("RESOURCE_NOT_FOUND", "Resource not found") + } return nil, err } return &system.GetResourceResponse{Resource: resource}, nil @@ -42,6 +47,9 @@ func (s *SystemService) CreateResource(ctx context.Context, req *system.CreateRe func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateResourceRequest) (*system.UpdateResourceResponse, error) { resource, err := s.Resource.UpdateResource(ctx, req.GetResource()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("RESOURCE_NOT_FOUND", "Resource not found") + } return nil, err } return &system.UpdateResourceResponse{Resource: resource}, nil @@ -50,6 +58,9 @@ func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateRe func (s *SystemService) DeleteResource(ctx context.Context, req *system.DeleteResourceRequest) (*system.DeleteResourceResponse, error) { err := s.Resource.DeleteResource(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("RESOURCE_NOT_FOUND", "Resource not found") + } return nil, err } return &system.DeleteResourceResponse{}, nil diff --git a/internal/features/system/service/role.go b/internal/features/system/service/role.go index 367c00d6..f4dd6e5c 100644 --- a/internal/features/system/service/role.go +++ b/internal/features/system/service/role.go @@ -7,7 +7,9 @@ package service import ( "context" + "github.com/origadmin/runtime/errors" "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data/entity/ent" ) func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequest) (*system.ListRolesResponse, error) { @@ -26,6 +28,9 @@ func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequ func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*system.GetRoleResponse, error) { role, err := s.Role.GetRole(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("ROLE_NOT_FOUND", "Role not found") + } return nil, err } return &system.GetRoleResponse{Role: role}, nil @@ -40,6 +45,9 @@ func (s *SystemService) CreateRole(ctx context.Context, req *system.CreateRoleRe func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRequest) (*system.UpdateRoleResponse, error) { role, err := s.Role.UpdateRole(ctx, req.GetRole()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("ROLE_NOT_FOUND", "Role not found") + } return nil, err } return &system.UpdateRoleResponse{Role: role}, nil @@ -47,6 +55,9 @@ func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRe func (s *SystemService) DeleteRole(ctx context.Context, req *system.DeleteRoleRequest) (*system.DeleteRoleResponse, error) { err := s.Role.DeleteRole(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("ROLE_NOT_FOUND", "Role not found") + } return nil, err } return &system.DeleteRoleResponse{}, nil diff --git a/internal/features/system/service/user.go b/internal/features/system/service/user.go index 2ef617cc..fc6521fd 100644 --- a/internal/features/system/service/user.go +++ b/internal/features/system/service/user.go @@ -7,12 +7,17 @@ package service import ( "context" + "github.com/origadmin/runtime/errors" "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data/entity/ent" ) func (s *SystemService) ListUserResources(ctx context.Context, req *system.ListUserResourcesRequest) (*system.ListUserResourcesResponse, error) { resources, err := s.User.ListUserResources(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("USER_NOT_FOUND", "User not found") + } return nil, err } return &system.ListUserResourcesResponse{ @@ -23,6 +28,9 @@ func (s *SystemService) ListUserResources(ctx context.Context, req *system.ListU func (s *SystemService) UpdateUserRoles(ctx context.Context, req *system.UpdateUserRolesRequest) (*system.UpdateUserRolesResponse, error) { err := s.User.UpdateUserRoles(ctx, req.GetId(), req.GetRoleIds()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("USER_NOT_FOUND", "User not found") + } return nil, err } return &system.UpdateUserRolesResponse{}, nil @@ -31,6 +39,9 @@ func (s *SystemService) UpdateUserRoles(ctx context.Context, req *system.UpdateU func (s *SystemService) UpdateUserStatus(ctx context.Context, req *system.UpdateUserStatusRequest) (*system.UpdateUserStatusResponse, error) { err := s.User.UpdateUserStatus(ctx, req.GetId(), int8(req.GetStatus())) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("USER_NOT_FOUND", "User not found") + } return nil, err } return &system.UpdateUserStatusResponse{}, nil @@ -39,6 +50,9 @@ func (s *SystemService) UpdateUserStatus(ctx context.Context, req *system.Update func (s *SystemService) ResetUserPassword(ctx context.Context, req *system.ResetUserPasswordRequest) (*system.ResetUserPasswordResponse, error) { err := s.User.ResetUserPassword(ctx, req.GetId(), req.GetPassword()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("USER_NOT_FOUND", "User not found") + } return nil, err } return &system.ResetUserPasswordResponse{}, nil @@ -60,6 +74,9 @@ func (s *SystemService) ListUsers(ctx context.Context, req *system.ListUsersRequ func (s *SystemService) GetUser(ctx context.Context, req *system.GetUserRequest) (*system.GetUserResponse, error) { user, err := s.User.GetUser(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("USER_NOT_FOUND", "User not found") + } return nil, err } return &system.GetUserResponse{User: user}, nil @@ -76,6 +93,9 @@ func (s *SystemService) CreateUser(ctx context.Context, req *system.CreateUserRe func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRequest) (*system.UpdateUserResponse, error) { user, err := s.User.UpdateUser(ctx, req.GetUser()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("USER_NOT_FOUND", "User not found") + } return nil, err } return &system.UpdateUserResponse{User: user}, nil @@ -84,6 +104,9 @@ func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRe func (s *SystemService) DeleteUser(ctx context.Context, req *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { err := s.User.DeleteUser(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("USER_NOT_FOUND", "User not found") + } return nil, err } return &system.DeleteUserResponse{}, nil diff --git a/internal/features/system/service/view.go b/internal/features/system/service/view.go index 0599e562..d199431c 100644 --- a/internal/features/system/service/view.go +++ b/internal/features/system/service/view.go @@ -2,7 +2,10 @@ package service import ( "context" + + "github.com/origadmin/runtime/errors" "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/data/entity/ent" ) // ListViews handles the RPC for listing views. @@ -23,6 +26,9 @@ func (s *SystemService) ListViews(ctx context.Context, req *system.ListViewsRequ func (s *SystemService) GetView(ctx context.Context, req *system.GetViewRequest) (*system.GetViewResponse, error) { view, err := s.View.GetView(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("VIEW_NOT_FOUND", "View not found") + } return nil, err } return &system.GetViewResponse{View: view}, nil @@ -41,6 +47,9 @@ func (s *SystemService) CreateView(ctx context.Context, req *system.CreateViewRe func (s *SystemService) UpdateView(ctx context.Context, req *system.UpdateViewRequest) (*system.UpdateViewResponse, error) { view, err := s.View.UpdateView(ctx, req.GetView()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("VIEW_NOT_FOUND", "View not found") + } return nil, err } return &system.UpdateViewResponse{View: view}, nil @@ -50,6 +59,9 @@ func (s *SystemService) UpdateView(ctx context.Context, req *system.UpdateViewRe func (s *SystemService) DeleteView(ctx context.Context, req *system.DeleteViewRequest) (*system.DeleteViewResponse, error) { err := s.View.DeleteView(ctx, req.GetId()) if err != nil { + if ent.IsNotFound(err) { + return nil, errors.NotFound("VIEW_NOT_FOUND", "View not found") + } return nil, err } return &system.DeleteViewResponse{}, nil diff --git a/internal/helpers/ent/mixin/mixin_id.go b/internal/helpers/ent/mixin/mixin_id.go index a3a60f98..16f6bb13 100644 --- a/internal/helpers/ent/mixin/mixin_id.go +++ b/internal/helpers/ent/mixin/mixin_id.go @@ -90,7 +90,7 @@ func (obj ID) PK(name string) ent.Field { func (obj ID) OptionalFK(name string) ent.Field { obj.Key = name - obj.Positive = true + // obj.Positive = true // This was the error. An optional FK can be 0. obj.Optional = true if obj.CommentKey == "" { obj.CommentKey = "field.optional_key.comment" From 84672e5ccc012f201fd2b74970b885218e5992b6 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 30 Dec 2025 02:58:58 +0800 Subject: [PATCH 103/158] feat(auth): refactor auth proto definitions and consolidate services into unified Auth service --- api/v1/proto/auth/auth.proto | 164 +- api/v1/proto/auth/casbin.proto | 6 +- api/v1/proto/auth/login.proto | 212 -- api/v1/proto/auth/me.proto | 83 + api/v1/proto/auth/personal.proto | 150 - api/v1/services/auth/auth.pb.go | 834 ++--- api/v1/services/auth/auth.pb.gw.go | 292 +- api/v1/services/auth/auth.pb.validate.go | 1307 ++------ api/v1/services/auth/auth_bridge.pb.go | 397 +-- api/v1/services/auth/auth_grpc.pb.go | 255 +- api/v1/services/auth/auth_http.pb.go | 244 +- api/v1/services/auth/casbin.pb.go | 10 +- api/v1/services/auth/casbin.pb.gw.go | 18 +- api/v1/services/auth/casbin_bridge.pb.go | 6 +- api/v1/services/auth/casbin_http.pb.go | 12 +- api/v1/services/auth/login.pb.go | 1461 --------- api/v1/services/auth/login.pb.gw.go | 631 ---- api/v1/services/auth/login.pb.validate.go | 2930 ------------------ api/v1/services/auth/login_bridge.pb.go | 554 ---- api/v1/services/auth/login_grpc.pb.go | 391 --- api/v1/services/auth/login_http.pb.go | 339 -- api/v1/services/auth/me.pb.go | 422 +++ api/v1/services/auth/me.pb.gw.go | 391 +++ api/v1/services/auth/me.pb.validate.go | 851 +++++ api/v1/services/auth/me_bridge.pb.go | 390 +++ api/v1/services/auth/me_grpc.pb.go | 289 ++ api/v1/services/auth/me_http.pb.go | 242 ++ api/v1/services/auth/personal.pb.go | 1074 ------- api/v1/services/auth/personal.pb.gw.go | 594 ---- api/v1/services/auth/personal.pb.validate.go | 2390 -------------- api/v1/services/auth/personal_bridge.pb.go | 565 ---- api/v1/services/auth/personal_grpc.pb.go | 407 --- api/v1/services/auth/personal_http.pb.go | 366 --- api/v1/services/system/department.pb.go | 2 +- api/v1/services/system/permission.pb.go | 2 +- api/v1/services/system/position.pb.go | 2 +- api/v1/services/system/role.pb.go | 2 +- api/v1/services/system/user.pb.go | 2 +- internal/features/system/biz/permission.go | 2 +- internal/features/system/biz/provider.go | 1 + internal/features/system/biz/resource.go | 3 +- internal/features/system/biz/role.go | 3 +- internal/features/system/biz/user.go | 3 +- internal/features/system/biz/view.go | 9 +- internal/features/system/server/server.go | 2 + internal/features/system/service/service.go | 4 + resources/api-docs/openapi/openapi.yaml | 867 +----- 47 files changed, 4007 insertions(+), 15174 deletions(-) delete mode 100644 api/v1/proto/auth/login.proto create mode 100644 api/v1/proto/auth/me.proto delete mode 100644 api/v1/proto/auth/personal.proto delete mode 100644 api/v1/services/auth/login.pb.go delete mode 100644 api/v1/services/auth/login.pb.gw.go delete mode 100644 api/v1/services/auth/login.pb.validate.go delete mode 100644 api/v1/services/auth/login_bridge.pb.go delete mode 100644 api/v1/services/auth/login_grpc.pb.go delete mode 100644 api/v1/services/auth/login_http.pb.go create mode 100644 api/v1/services/auth/me.pb.go create mode 100644 api/v1/services/auth/me.pb.gw.go create mode 100644 api/v1/services/auth/me.pb.validate.go create mode 100644 api/v1/services/auth/me_bridge.pb.go create mode 100644 api/v1/services/auth/me_grpc.pb.go create mode 100644 api/v1/services/auth/me_http.pb.go delete mode 100644 api/v1/services/auth/personal.pb.go delete mode 100644 api/v1/services/auth/personal.pb.gw.go delete mode 100644 api/v1/services/auth/personal.pb.validate.go delete mode 100644 api/v1/services/auth/personal_bridge.pb.go delete mode 100644 api/v1/services/auth/personal_grpc.pb.go delete mode 100644 api/v1/services/auth/personal_http.pb.go diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index 9391e0af..dbd53da4 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -3,137 +3,131 @@ syntax = "proto3"; package api.v1.services.auth; import "google/api/annotations.proto"; -import "google/api/client.proto"; import "google/protobuf/empty.proto"; -import "types/system.proto"; option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; -option java_outer_classname = "APIServiceAuthAuthProto"; option java_package = "com.origadmin.api.v1.services.auth"; -option objc_class_prefix = "APIServiceAuthAuth"; +option java_outer_classname = "APIServiceAuthProto"; -service AuthService { - // ListAuthResources returns a list of Auths. - rpc ListAuthResources(ListAuthResourcesRequest) returns (ListAuthResourcesResponse) { - option (google.api.http) = {get: "/auth/resources"}; - } +// Service Auth provides APIs for the authentication lifecycle. +service Auth { + // --- Authentication --- - // CreateToken generates a new JWT token for the given user. - rpc CreateToken(CreateTokenRequest) returns (CreateTokenResponse) { + // Login authenticates a user and returns a token pair. + rpc Login(LoginRequest) returns (LoginResponse) { option (google.api.http) = { - post: "/auth/token" - body: "data" + post: "/api/v1/auth/login" + body: "*" }; } - // ValidateToken verifies the validity of a JWT token. - rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse) { - option (google.api.http) = {get: "/auth/validate"}; + // Register creates a new user account. + rpc Register(RegisterRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/api/v1/auth/register" + body: "*" + }; } - // DestroyToken invalidates a JWT token. - rpc DestroyToken(DestroyTokenRequest) returns (DestroyTokenResponse) { + // Logout invalidates the user's session. + rpc Logout(LogoutRequest) returns (google.protobuf.Empty) { option (google.api.http) = { - post: "/auth/destroy" - body: "data" + post: "/api/v1/auth/logout" + body: "*" }; } - // Authenticate authenticates a user. - rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse) { + // RefreshToken provides a new access token. + rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse) { option (google.api.http) = { - post: "/auth/authenticate" - body: "data" + post: "/api/v1/auth/token" + body: "*" }; } - // AuthLogout logs out a user. - rpc AuthLogout(AuthLogoutRequest) returns (AuthLogoutResponse) { + // --- Captcha --- + + // GetCaptcha generates a new captcha. + rpc GetCaptcha(GetCaptchaRequest) returns (GetCaptchaResponse) { option (google.api.http) = { - post: "/auth/logout" - body: "data" + get: "/api/v1/captcha" }; } -} -message AuthLogoutRequest { - message Data { - string token = 1 [json_name = "token"]; - } - Data data = 1 [json_name = "data"]; -} + // --- Internal --- -message AuthLogoutResponse { - google.protobuf.Empty empty = 1; + // Authenticate is for internal use by the gateway to verify user access via gRPC. + // It does not have an HTTP binding. + rpc Authenticate(AuthenticateRequest) returns (AuthenticateResponse); } -message ListAuthResourcesRequest { - // The maximum number of Auths to return. - int32 page_size = 1 [json_name = "page_size"]; - // The next_page_token value returned from a previous List request, if any. - string page_token = 2 [json_name = "page_token"]; - // The current page number. - int32 current = 3 [json_name = "current"]; - // The no_paging is used to disable pagination. - bool no_paging = 4 [json_name = "no_paging"]; +// --- Message Definitions --- + +// The request message for the Login RPC. +message LoginRequest { + string username = 1; + string password = 2; + string captcha_id = 3; + string captcha_code = 4; } -message ListAuthResourcesResponse { - // The list of Auths. - repeated api.v1.services.types.Resource resources = 1 [json_name = "resources"]; - // The total number of Auths in the result set. - int32 total_size = 2 [json_name = "total_size"]; +// The response message for the Login RPC. +message LoginResponse { + string access_token = 1; + string refresh_token = 2; + string token_type = 3; + int64 expires_in = 4; } -// CreateTokenRequest contains the information needed to create a token. -message CreateTokenRequest { - message Data { - string user_id = 1 [json_name = "user_id"]; - repeated string scopes = 2 [json_name = "scopes"]; - } - Data data = 1 [json_name = "data"]; +// The request message for the Register RPC. +message RegisterRequest { + string username = 1; + string password = 2; + string email = 3; + string captcha_id = 4; + string captcha_code = 5; } -// CreateTokenResponse contains the generated token. -message CreateTokenResponse { - string token = 1 [json_name = "token"]; +// The request message for the Logout RPC. +message LogoutRequest { + string refresh_token = 1; } -// VerifyTokenRequest contains the token to be verified. -message ValidateTokenRequest { - string token = 1 [json_name = "token"]; +// The request message for the RefreshToken RPC. +message RefreshTokenRequest { + string refresh_token = 1; } -// VerifyTokenResponse contains the result of the verification. -message ValidateTokenResponse { - bool is_valid = 1 [json_name = "is_valid"]; - map claims = 2 [json_name = "claims"]; +// The response message for the RefreshToken RPC. +message RefreshTokenResponse { + string access_token = 1; + string token_type = 2; + int64 expires_in = 3; } -// DestroyTokenRequest contains the token to be invalidated. -message DestroyTokenRequest { - message Data { - string token = 1 [json_name = "token"]; - } - Data data = 1 [json_name = "data"]; +// The request message for the GetCaptcha RPC. +message GetCaptchaRequest { + // If true, forces reloading of the captcha. + bool reload = 1; } -// DestroyTokenResponse contains the result of the invalidation. -message DestroyTokenResponse { - google.protobuf.Empty empty = 1; +// The response message for the GetCaptcha RPC. +message GetCaptchaResponse { + string captcha_id = 1; + // Base64 encoded image data. + string captcha_image = 2; } +// The request message for the Authenticate RPC. message AuthenticateRequest { - message Data { - string token = 1 [json_name = "token"]; - string path = 3 [json_name = "path"]; - string method = 4 [json_name = "method"]; - string operation = 5 [json_name = "operation"]; - } - Data data = 1 [json_name = "data"]; + string token = 1; + string path = 2; + string method = 3; } +// The response message for the Authenticate RPC. message AuthenticateResponse { - bool is_valid = 1 [json_name = "is_valid"]; + bool authorized = 1; + string user_id = 2; } diff --git a/api/v1/proto/auth/casbin.proto b/api/v1/proto/auth/casbin.proto index 4ca298f6..3c9f3a77 100644 --- a/api/v1/proto/auth/casbin.proto +++ b/api/v1/proto/auth/casbin.proto @@ -14,19 +14,19 @@ option objc_class_prefix = "APIServiceAuthCasbin"; service CasbinSourceService { rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) { option (google.api.http) = { - get: "/casbin/policies" + get: "/api/v1/casbin/policies" response_body: "*" }; } rpc ListGroupings(ListGroupingsRequest) returns (ListGroupingsResponse) { option (google.api.http) = { - get: "/casbin/groupings" + get: "/api/v1/casbin/groupings" response_body: "*" }; } rpc WatchUpdate(WatchUpdateRequest) returns (WatchUpdateResponse) { option (google.api.http) = { - get: "/casbin/watch" + get: "/api/v1/casbin/watch" response_body: "*" }; } diff --git a/api/v1/proto/auth/login.proto b/api/v1/proto/auth/login.proto deleted file mode 100644 index d21a5be2..00000000 --- a/api/v1/proto/auth/login.proto +++ /dev/null @@ -1,212 +0,0 @@ -syntax = "proto3"; - -package api.v1.services.auth; - -import "google/api/annotations.proto"; -import "google/protobuf/any.proto"; -import "security/v1/credential.proto"; -import "validate/validate.proto"; - -option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; -option java_multiple_files = true; -option java_outer_classname = "APIV1ServicesAuthLoginProto"; -option java_package = "com.origadmin.api.v1.services.auth"; -option objc_class_prefix = "APIServiceAuthLogin"; - -// The login service definition. -service LoginService { - rpc Captcha(CaptchaRequest) returns (CaptchaResponse) { - option (google.api.http) = { - get: "/captcha" - response_body: "*" - }; - } - rpc CaptchaId(CaptchaIdRequest) returns (CaptchaIdResponse) { - option (google.api.http) = {get: "/captcha/id"}; - } - rpc CaptchaImage(CaptchaImageRequest) returns (CaptchaImageResponse) { - option (google.api.http) = { - get: "/captcha/image" - response_body: "*" - }; - } - rpc CaptchaAudio(CaptchaAudioRequest) returns (CaptchaAudioResponse) { - option (google.api.http) = { - get: "/captcha/audio" - response_body: "*" - }; - } - rpc Login(LoginRequest) returns (LoginResponse) { - option (google.api.http) = { - post: "/login" - body: "data" - }; - } - rpc Logout(LogoutRequest) returns (LogoutResponse) { - option (google.api.http) = { - post: "/logout" - body: "data" - }; - } - rpc Register(RegisterRequest) returns (RegisterResponse) { - option (google.api.http) = { - post: "/register" - body: "data" - }; - } - rpc TokenRefresh(TokenRefreshRequest) returns (TokenRefreshResponse) { - option (google.api.http) = { - post: "/token/refresh" - body: "data" - }; - } -} - -message TokenRefreshRequest { - message Data { - string refresh_token = 1 [ - json_name = "refresh_token", - (validate.rules).string = {min_len: 1} - ]; - } - Data data = 2 [json_name = "data"]; -} - -message TokenRefreshResponse { - contrib.api.security.v1.TokenCredential token = 1; -} - -message LoginRequest { - message Data { - string username = 1 [ - json_name = "username", - (validate.rules).string = {min_len: 1} - ]; - string password = 2 [ - json_name = "password", - (validate.rules).string = {min_len: 1} - ]; - string captcha_id = 3 [ - json_name = "captcha_id", - (validate.rules).string = {min_len: 1} - ]; - string captcha_code = 4 [ - json_name = "captcha_code", - (validate.rules).string = {min_len: 1} - ]; - } - Data data = 2 [json_name = "data"]; -} - -message LoginResponse { - contrib.api.security.v1.TokenCredential token = 1; -} - -message CurrentUserRequestQuery { - int64 user_id = 1 [json_name = "user_id"]; -} - -message CurrentUserRequest { - CurrentUserRequestQuery data = 1 [json_name = "data"]; -} - -message CurrentUserResponse { - bool success = 1; - google.protobuf.Any data = 2 [json_name = "data"]; -} - -message CaptchaIdRequest { - // The timestamp of the request prevent caching of the same result - string ts = 1 [json_name = "ts"]; - bool reload = 2 [json_name = "reload"]; -} - -message CaptchaIdResponse { - string data = 1; -} - -// The request message containing the user's name. -message CaptchaImageRequest { - string id = 1 [json_name = "id"]; - string reload = 2 [json_name = "reload"]; - google.protobuf.Any data = 3 [json_name = "data"]; -} - -message CaptchaData { - string captcha_id = 1; - string captcha_img = 2; -} - -// The response message containing the greetings -message CaptchaImageResponse { - map headers = 1; - bytes image = 2 [json_name = "image"]; -} - -// The request message containing the user's name. -message CaptchaAudioRequest { - string id = 1 [json_name = "id"]; - string reload = 2 [json_name = "reload"]; - google.protobuf.Any data = 3 [json_name = "data"]; -} - -// The response message containing the greetings -message CaptchaAudioResponse { - map headers = 1 [json_name = "headers"]; - bytes audio = 2 [json_name = "audio"]; -} - -message CaptchaRequest { - // The id of the captcha - string id = 1 [json_name = "id"]; - // The type of the captcha - string type = 2 [json_name = "type"]; - // The reload is used to reload the captcha - bool reload = 3 [json_name = "reload"]; - // The timestamp of the request prevent caching of the same result - string ts = 4 [json_name = "ts"]; -} - -message CaptchaResponse { - string id = 1 [json_name = "id"]; - string type = 2 [json_name = "type"]; - string data = 3 [json_name = "data"]; -} - -message RegisterRequest { - message Data { - string username = 1 [ - json_name = "username", - (validate.rules).string = {min_len: 1} - ]; - string password = 2 [ - json_name = "password", - (validate.rules).string = {min_len: 1} - ]; - string captcha_id = 3 [ - json_name = "captcha_id", - (validate.rules).string = {min_len: 1} - ]; - string captcha_code = 4 [ - json_name = "captcha_code", - (validate.rules).string = {min_len: 1} - ]; - } - Data data = 2 [json_name = "data"]; -} - -message RegisterResponse { - bool success = 1; - message Data { - string redirect = 1; - } - Data data = 2 [json_name = "data"]; -} - -message LogoutRequest { - google.protobuf.Any data = 2 [json_name = "data"]; -} - -message LogoutResponse { - bool success = 1; -} diff --git a/api/v1/proto/auth/me.proto b/api/v1/proto/auth/me.proto new file mode 100644 index 00000000..ba538be4 --- /dev/null +++ b/api/v1/proto/auth/me.proto @@ -0,0 +1,83 @@ +syntax = "proto3"; + +package api.v1.services.auth; + +import "google/api/annotations.proto"; +import "google/protobuf/empty.proto"; +import "types/system.proto"; + +option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; +option java_multiple_files = true; +option java_package = "com.origadmin.api.v1.services.auth"; +option java_outer_classname = "APIServiceMeProto"; + +// Service Me provides APIs for the currently authenticated user to manage their own profile and data. +service Me { + // GetProfile retrieves the profile of the currently authenticated user. + rpc GetProfile(GetProfileRequest) returns (api.v1.services.types.User) { + option (google.api.http) = { + get: "/api/v1/me/profile" + }; + } + + // UpdateProfile updates the profile of the currently authenticated user. + rpc UpdateProfile(UpdateProfileRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + put: "/api/v1/me/profile" + body: "*" + }; + } + + // UpdatePassword changes the password for the currently authenticated user. + rpc UpdatePassword(UpdatePasswordRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + put: "/api/v1/me/password" + body: "*" + }; + } + + // GetUserResources retrieves the menu/resource list for the current user. + rpc GetUserResources(GetUserResourcesRequest) returns (GetUserResourcesResponse) { + option (google.api.http) = { + get: "/api/v1/me/resources" + }; + } + + // GetUserRoles retrieves the role list for the current user. + rpc GetUserRoles(GetUserRolesRequest) returns (GetUserRolesResponse) { + option (google.api.http) = { + get: "/api/v1/me/roles" + }; + } +} + +// The request message for the GetProfile RPC. +message GetProfileRequest {} + +// The request message for the UpdateProfile RPC. +message UpdateProfileRequest { + // The fields to update. + api.v1.services.types.User user = 1; +} + +// The request message for the UpdatePassword RPC. +message UpdatePasswordRequest { + string old_password = 1; + string new_password = 2; +} + +// The request message for the GetUserResources RPC. +message GetUserResourcesRequest {} + +// The response message for the GetUserResources RPC. +message GetUserResourcesResponse { + repeated api.v1.services.types.Resource resources = 1; +} + +// The request message for the GetUserRoles RPC. +message GetUserRolesRequest {} + +// The response message for the GetUserRoles RPC. +message GetUserRolesResponse { + repeated api.v1.services.types.Role roles = 1; +} diff --git a/api/v1/proto/auth/personal.proto b/api/v1/proto/auth/personal.proto deleted file mode 100644 index c02c4c3c..00000000 --- a/api/v1/proto/auth/personal.proto +++ /dev/null @@ -1,150 +0,0 @@ -syntax = "proto3"; - -package api.v1.services.auth; - -import "google/api/annotations.proto"; -import "google/protobuf/any.proto"; -import "types/system.proto"; -import "validate/validate.proto"; - -option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; -option java_multiple_files = true; -option java_outer_classname = "APIV1ServicesAuthPersonalProto"; -option java_package = "com.origadmin.api.v1.services.auth"; - -// PersonalService Personal user service -service PersonalService { - // GetPersonalProfile Update the personal user information - rpc GetPersonalProfile(GetPersonalProfileRequest) returns (GetPersonalProfileResponse) { - option (google.api.http) = {get: "/auth/personal/profile"}; - } - // ListPersonalResources List the personal user's menu - rpc ListPersonalResources(ListPersonalResourcesRequest) returns (ListPersonalResourcesResponse) { - option (google.api.http) = {get: "/auth/personal/resources"}; - } - // ListPersonalResources List the personal user's menu - rpc ListPersonalRoles(ListPersonalRolesRequest) returns (ListPersonalRolesResponse) { - option (google.api.http) = {get: "/auth/personal/roles"}; - } - // PersonalLogout Personal user logs out - rpc PersonalLogout(PersonalLogoutRequest) returns (PersonalLogoutResponse) { - option (google.api.http) = { - post: "/auth/personal/logout" - body: "data" - }; - } - // RefreshPersonalToken Refresh the personal user's token - rpc RefreshPersonalToken(RefreshPersonalTokenRequest) returns (RefreshPersonalTokenResponse) { - option (google.api.http) = { - post: "/auth/personal/token/refresh" - body: "data" - }; - } - // UpdatePersonalProfilePassword The user changes the password - rpc UpdatePersonalPassword(UpdatePersonalPasswordRequest) returns (UpdatePersonalPasswordResponse) { - option (google.api.http) = { - put: "/auth/personal/password" - body: "data" - }; - } - // UpdatePersonalProfile Update the personal user information - rpc UpdatePersonalProfile(UpdatePersonalProfileRequest) returns (UpdatePersonalProfileResponse) { - option (google.api.http) = { - put: "/auth/personal/profile" - body: "data" - }; - } - // UpdatePersonalSetting User settings are saved - rpc UpdatePersonalSetting(UpdatePersonalSettingRequest) returns (UpdatePersonalSettingResponse) { - option (google.api.http) = { - put: "/auth/personal/setting" - body: "data" - }; - } -} - -message UpdatePersonalSettingRequest { - google.protobuf.Any data = 1 [json_name = "data"]; -} - -message UpdatePersonalSettingResponse {} - -message UpdatePersonalRoleRequest { - api.v1.services.types.Role role = 1 [json_name = "role"]; -} - -message UpdatePersonalRoleResponse {} - -message ListPersonalResourcesRequest { - // The parent resource id, for example, "shelves/shelf1". - int64 id = 1 [json_name = "id"]; - // The current page number. - int32 current = 2 [json_name = "current"]; - // The maximum number of items to return. - int32 page_size = 3 [json_name = "page_size"]; - // The next_page_token value returned from a previous List request, if any. - string page_token = 4 [json_name = "page_token"]; - // The no_paging is used to disable pagination. - bool no_paging = 5 [json_name = "no_paging"]; - // The only_count is the query parameter for set only to query the total number - bool only_count = 6 [json_name = "only_count"]; -} - -message ListPersonalResourcesResponse { - // The total number of items in the list. - int64 total_size = 1 [json_name = "total"]; - // list of resources - repeated api.v1.services.types.Resource resources = 2 [json_name = "resources"]; - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - string next_page_token = 5 [json_name = "next_page_token"]; -} - -message UpdatePersonalPasswordRequest { - google.protobuf.Any data = 1 [json_name = "data"]; -} - -message UpdatePersonalPasswordResponse {} - -message PersonalPasswordRestRequest { - int64 id = 1 [ - json_name = "id", - (validate.rules).int64 = {gt: 0} - ]; -} - -message PersonalPasswordRestResponse {} - -message UpdatePersonalProfileRequest { - google.protobuf.Any data = 1 [json_name = "data"]; -} - -message UpdatePersonalProfileResponse {} - -message PersonalLogoutRequest { - google.protobuf.Any data = 2 [json_name = "data"]; -} - -message PersonalLogoutResponse { - bool success = 1; -} - -message ListPersonalRolesRequest {} - -message ListPersonalRolesResponse { - repeated api.v1.services.types.Role roles = 1; -} - -message GetPersonalProfileRequest {} - -message GetPersonalProfileResponse { - api.v1.services.types.User user = 1 [json_name = "user"]; -} - -message RefreshPersonalTokenRequest { - google.protobuf.Any data = 1 [json_name = "data"]; -} - -message RefreshPersonalTokenResponse { - string token = 1 [json_name = "token"]; -} diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index 83329dbe..40b6d4ec 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -11,7 +11,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" unsafe "unsafe" @@ -24,27 +23,31 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type AuthLogoutRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *AuthLogoutRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +// The request message for the Login RPC. +type LoginRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` + CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,json=captchaCode,proto3" json:"captcha_code,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *AuthLogoutRequest) Reset() { - *x = AuthLogoutRequest{} +func (x *LoginRequest) Reset() { + *x = LoginRequest{} mi := &file_auth_auth_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *AuthLogoutRequest) String() string { +func (x *LoginRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AuthLogoutRequest) ProtoMessage() {} +func (*LoginRequest) ProtoMessage() {} -func (x *AuthLogoutRequest) ProtoReflect() protoreflect.Message { +func (x *LoginRequest) ProtoReflect() protoreflect.Message { mi := &file_auth_auth_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -56,91 +59,65 @@ func (x *AuthLogoutRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AuthLogoutRequest.ProtoReflect.Descriptor instead. -func (*AuthLogoutRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. +func (*LoginRequest) Descriptor() ([]byte, []int) { return file_auth_auth_proto_rawDescGZIP(), []int{0} } -func (x *AuthLogoutRequest) GetData() *AuthLogoutRequest_Data { +func (x *LoginRequest) GetUsername() string { if x != nil { - return x.Data + return x.Username } - return nil -} - -type AuthLogoutResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AuthLogoutResponse) Reset() { - *x = AuthLogoutResponse{} - mi := &file_auth_auth_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AuthLogoutResponse) String() string { - return protoimpl.X.MessageStringOf(x) + return "" } -func (*AuthLogoutResponse) ProtoMessage() {} - -func (x *AuthLogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[1] +func (x *LoginRequest) GetPassword() string { if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms + return x.Password } - return mi.MessageOf(x) + return "" } -// Deprecated: Use AuthLogoutResponse.ProtoReflect.Descriptor instead. -func (*AuthLogoutResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{1} +func (x *LoginRequest) GetCaptchaId() string { + if x != nil { + return x.CaptchaId + } + return "" } -func (x *AuthLogoutResponse) GetEmpty() *emptypb.Empty { +func (x *LoginRequest) GetCaptchaCode() string { if x != nil { - return x.Empty + return x.CaptchaCode } - return nil + return "" } -type ListAuthResourcesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The maximum number of Auths to return. - PageSize int32 `protobuf:"varint,1,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,2,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,3,opt,name=current,proto3" json:"current,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,4,opt,name=no_paging,proto3" json:"no_paging,omitempty"` +// The response message for the Login RPC. +type LoginResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` + TokenType string `protobuf:"bytes,3,opt,name=token_type,json=tokenType,proto3" json:"token_type,omitempty"` + ExpiresIn int64 `protobuf:"varint,4,opt,name=expires_in,json=expiresIn,proto3" json:"expires_in,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *ListAuthResourcesRequest) Reset() { - *x = ListAuthResourcesRequest{} - mi := &file_auth_auth_proto_msgTypes[2] +func (x *LoginResponse) Reset() { + *x = LoginResponse{} + mi := &file_auth_auth_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *ListAuthResourcesRequest) String() string { +func (x *LoginResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ListAuthResourcesRequest) ProtoMessage() {} +func (*LoginResponse) ProtoMessage() {} -func (x *ListAuthResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[2] +func (x *LoginResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -151,64 +128,66 @@ func (x *ListAuthResourcesRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ListAuthResourcesRequest.ProtoReflect.Descriptor instead. -func (*ListAuthResourcesRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{2} +// Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. +func (*LoginResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{1} } -func (x *ListAuthResourcesRequest) GetPageSize() int32 { +func (x *LoginResponse) GetAccessToken() string { if x != nil { - return x.PageSize + return x.AccessToken } - return 0 + return "" } -func (x *ListAuthResourcesRequest) GetPageToken() string { +func (x *LoginResponse) GetRefreshToken() string { if x != nil { - return x.PageToken + return x.RefreshToken } return "" } -func (x *ListAuthResourcesRequest) GetCurrent() int32 { +func (x *LoginResponse) GetTokenType() string { if x != nil { - return x.Current + return x.TokenType } - return 0 + return "" } -func (x *ListAuthResourcesRequest) GetNoPaging() bool { +func (x *LoginResponse) GetExpiresIn() int64 { if x != nil { - return x.NoPaging + return x.ExpiresIn } - return false + return 0 } -type ListAuthResourcesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The list of Auths. - Resources []*types.Resource `protobuf:"bytes,1,rep,name=resources,proto3" json:"resources,omitempty"` - // The total number of Auths in the result set. - TotalSize int32 `protobuf:"varint,2,opt,name=total_size,proto3" json:"total_size,omitempty"` +// The request message for the Register RPC. +type RegisterRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` + CaptchaId string `protobuf:"bytes,4,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` + CaptchaCode string `protobuf:"bytes,5,opt,name=captcha_code,json=captchaCode,proto3" json:"captcha_code,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *ListAuthResourcesResponse) Reset() { - *x = ListAuthResourcesResponse{} - mi := &file_auth_auth_proto_msgTypes[3] +func (x *RegisterRequest) Reset() { + *x = RegisterRequest{} + mi := &file_auth_auth_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *ListAuthResourcesResponse) String() string { +func (x *RegisterRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ListAuthResourcesResponse) ProtoMessage() {} +func (*RegisterRequest) ProtoMessage() {} -func (x *ListAuthResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[3] +func (x *RegisterRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -219,93 +198,69 @@ func (x *ListAuthResourcesResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ListAuthResourcesResponse.ProtoReflect.Descriptor instead. -func (*ListAuthResourcesResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{3} +// Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. +func (*RegisterRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{2} } -func (x *ListAuthResourcesResponse) GetResources() []*types.Resource { +func (x *RegisterRequest) GetUsername() string { if x != nil { - return x.Resources + return x.Username } - return nil + return "" } -func (x *ListAuthResourcesResponse) GetTotalSize() int32 { +func (x *RegisterRequest) GetPassword() string { if x != nil { - return x.TotalSize + return x.Password } - return 0 -} - -// CreateTokenRequest contains the information needed to create a token. -type CreateTokenRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *CreateTokenRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateTokenRequest) Reset() { - *x = CreateTokenRequest{} - mi := &file_auth_auth_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateTokenRequest) String() string { - return protoimpl.X.MessageStringOf(x) + return "" } -func (*CreateTokenRequest) ProtoMessage() {} - -func (x *CreateTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[4] +func (x *RegisterRequest) GetEmail() string { if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms + return x.Email } - return mi.MessageOf(x) + return "" } -// Deprecated: Use CreateTokenRequest.ProtoReflect.Descriptor instead. -func (*CreateTokenRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{4} +func (x *RegisterRequest) GetCaptchaId() string { + if x != nil { + return x.CaptchaId + } + return "" } -func (x *CreateTokenRequest) GetData() *CreateTokenRequest_Data { +func (x *RegisterRequest) GetCaptchaCode() string { if x != nil { - return x.Data + return x.CaptchaCode } - return nil + return "" } -// CreateTokenResponse contains the generated token. -type CreateTokenResponse struct { +// The request message for the Logout RPC. +type LogoutRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *CreateTokenResponse) Reset() { - *x = CreateTokenResponse{} - mi := &file_auth_auth_proto_msgTypes[5] +func (x *LogoutRequest) Reset() { + *x = LogoutRequest{} + mi := &file_auth_auth_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *CreateTokenResponse) String() string { +func (x *LogoutRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CreateTokenResponse) ProtoMessage() {} +func (*LogoutRequest) ProtoMessage() {} -func (x *CreateTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[5] +func (x *LogoutRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -316,41 +271,41 @@ func (x *CreateTokenResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CreateTokenResponse.ProtoReflect.Descriptor instead. -func (*CreateTokenResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{5} +// Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. +func (*LogoutRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{3} } -func (x *CreateTokenResponse) GetToken() string { +func (x *LogoutRequest) GetRefreshToken() string { if x != nil { - return x.Token + return x.RefreshToken } return "" } -// VerifyTokenRequest contains the token to be verified. -type ValidateTokenRequest struct { +// The request message for the RefreshToken RPC. +type RefreshTokenRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *ValidateTokenRequest) Reset() { - *x = ValidateTokenRequest{} - mi := &file_auth_auth_proto_msgTypes[6] +func (x *RefreshTokenRequest) Reset() { + *x = RefreshTokenRequest{} + mi := &file_auth_auth_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *ValidateTokenRequest) String() string { +func (x *RefreshTokenRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ValidateTokenRequest) ProtoMessage() {} +func (*RefreshTokenRequest) ProtoMessage() {} -func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[6] +func (x *RefreshTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -361,42 +316,43 @@ func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ValidateTokenRequest.ProtoReflect.Descriptor instead. -func (*ValidateTokenRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{6} +// Deprecated: Use RefreshTokenRequest.ProtoReflect.Descriptor instead. +func (*RefreshTokenRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{4} } -func (x *ValidateTokenRequest) GetToken() string { +func (x *RefreshTokenRequest) GetRefreshToken() string { if x != nil { - return x.Token + return x.RefreshToken } return "" } -// VerifyTokenResponse contains the result of the verification. -type ValidateTokenResponse struct { +// The response message for the RefreshToken RPC. +type RefreshTokenResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - IsValid bool `protobuf:"varint,1,opt,name=is_valid,proto3" json:"is_valid,omitempty"` - Claims map[string]string `protobuf:"bytes,2,rep,name=claims,proto3" json:"claims,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + TokenType string `protobuf:"bytes,2,opt,name=token_type,json=tokenType,proto3" json:"token_type,omitempty"` + ExpiresIn int64 `protobuf:"varint,3,opt,name=expires_in,json=expiresIn,proto3" json:"expires_in,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *ValidateTokenResponse) Reset() { - *x = ValidateTokenResponse{} - mi := &file_auth_auth_proto_msgTypes[7] +func (x *RefreshTokenResponse) Reset() { + *x = RefreshTokenResponse{} + mi := &file_auth_auth_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *ValidateTokenResponse) String() string { +func (x *RefreshTokenResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*ValidateTokenResponse) ProtoMessage() {} +func (*RefreshTokenResponse) ProtoMessage() {} -func (x *ValidateTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[7] +func (x *RefreshTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -407,93 +363,56 @@ func (x *ValidateTokenResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use ValidateTokenResponse.ProtoReflect.Descriptor instead. -func (*ValidateTokenResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{7} -} - -func (x *ValidateTokenResponse) GetIsValid() bool { - if x != nil { - return x.IsValid - } - return false +// Deprecated: Use RefreshTokenResponse.ProtoReflect.Descriptor instead. +func (*RefreshTokenResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{5} } -func (x *ValidateTokenResponse) GetClaims() map[string]string { +func (x *RefreshTokenResponse) GetAccessToken() string { if x != nil { - return x.Claims + return x.AccessToken } - return nil -} - -// DestroyTokenRequest contains the token to be invalidated. -type DestroyTokenRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *DestroyTokenRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DestroyTokenRequest) Reset() { - *x = DestroyTokenRequest{} - mi := &file_auth_auth_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DestroyTokenRequest) String() string { - return protoimpl.X.MessageStringOf(x) + return "" } -func (*DestroyTokenRequest) ProtoMessage() {} - -func (x *DestroyTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[8] +func (x *RefreshTokenResponse) GetTokenType() string { if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms + return x.TokenType } - return mi.MessageOf(x) -} - -// Deprecated: Use DestroyTokenRequest.ProtoReflect.Descriptor instead. -func (*DestroyTokenRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{8} + return "" } -func (x *DestroyTokenRequest) GetData() *DestroyTokenRequest_Data { +func (x *RefreshTokenResponse) GetExpiresIn() int64 { if x != nil { - return x.Data + return x.ExpiresIn } - return nil + return 0 } -// DestroyTokenResponse contains the result of the invalidation. -type DestroyTokenResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` +// The request message for the GetCaptcha RPC. +type GetCaptchaRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // If true, forces reloading of the captcha. + Reload bool `protobuf:"varint,1,opt,name=reload,proto3" json:"reload,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *DestroyTokenResponse) Reset() { - *x = DestroyTokenResponse{} - mi := &file_auth_auth_proto_msgTypes[9] +func (x *GetCaptchaRequest) Reset() { + *x = GetCaptchaRequest{} + mi := &file_auth_auth_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *DestroyTokenResponse) String() string { +func (x *GetCaptchaRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DestroyTokenResponse) ProtoMessage() {} +func (*GetCaptchaRequest) ProtoMessage() {} -func (x *DestroyTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[9] +func (x *GetCaptchaRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -504,40 +423,43 @@ func (x *DestroyTokenResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DestroyTokenResponse.ProtoReflect.Descriptor instead. -func (*DestroyTokenResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{9} +// Deprecated: Use GetCaptchaRequest.ProtoReflect.Descriptor instead. +func (*GetCaptchaRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{6} } -func (x *DestroyTokenResponse) GetEmpty() *emptypb.Empty { +func (x *GetCaptchaRequest) GetReload() bool { if x != nil { - return x.Empty + return x.Reload } - return nil + return false } -type AuthenticateRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *AuthenticateRequest_Data `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +// The response message for the GetCaptcha RPC. +type GetCaptchaResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` + // Base64 encoded image data. + CaptchaImage string `protobuf:"bytes,2,opt,name=captcha_image,json=captchaImage,proto3" json:"captcha_image,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *AuthenticateRequest) Reset() { - *x = AuthenticateRequest{} - mi := &file_auth_auth_proto_msgTypes[10] +func (x *GetCaptchaResponse) Reset() { + *x = GetCaptchaResponse{} + mi := &file_auth_auth_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *AuthenticateRequest) String() string { +func (x *GetCaptchaResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AuthenticateRequest) ProtoMessage() {} +func (*GetCaptchaResponse) ProtoMessage() {} -func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[10] +func (x *GetCaptchaResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -548,84 +470,50 @@ func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AuthenticateRequest.ProtoReflect.Descriptor instead. -func (*AuthenticateRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{10} -} - -func (x *AuthenticateRequest) GetData() *AuthenticateRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -type AuthenticateResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - IsValid bool `protobuf:"varint,1,opt,name=is_valid,proto3" json:"is_valid,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *AuthenticateResponse) Reset() { - *x = AuthenticateResponse{} - mi := &file_auth_auth_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *AuthenticateResponse) String() string { - return protoimpl.X.MessageStringOf(x) +// Deprecated: Use GetCaptchaResponse.ProtoReflect.Descriptor instead. +func (*GetCaptchaResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{7} } -func (*AuthenticateResponse) ProtoMessage() {} - -func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[11] +func (x *GetCaptchaResponse) GetCaptchaId() string { if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms + return x.CaptchaId } - return mi.MessageOf(x) -} - -// Deprecated: Use AuthenticateResponse.ProtoReflect.Descriptor instead. -func (*AuthenticateResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{11} + return "" } -func (x *AuthenticateResponse) GetIsValid() bool { +func (x *GetCaptchaResponse) GetCaptchaImage() string { if x != nil { - return x.IsValid + return x.CaptchaImage } - return false + return "" } -type AuthLogoutRequest_Data struct { +// The request message for the Authenticate RPC. +type AuthenticateRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` + Method string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *AuthLogoutRequest_Data) Reset() { - *x = AuthLogoutRequest_Data{} - mi := &file_auth_auth_proto_msgTypes[12] +func (x *AuthenticateRequest) Reset() { + *x = AuthenticateRequest{} + mi := &file_auth_auth_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *AuthLogoutRequest_Data) String() string { +func (x *AuthenticateRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AuthLogoutRequest_Data) ProtoMessage() {} +func (*AuthenticateRequest) ProtoMessage() {} -func (x *AuthLogoutRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[12] +func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -636,139 +524,56 @@ func (x *AuthLogoutRequest_Data) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AuthLogoutRequest_Data.ProtoReflect.Descriptor instead. -func (*AuthLogoutRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{0, 0} +// Deprecated: Use AuthenticateRequest.ProtoReflect.Descriptor instead. +func (*AuthenticateRequest) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{8} } -func (x *AuthLogoutRequest_Data) GetToken() string { +func (x *AuthenticateRequest) GetToken() string { if x != nil { return x.Token } return "" } -type CreateTokenRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId string `protobuf:"bytes,1,opt,name=user_id,proto3" json:"user_id,omitempty"` - Scopes []string `protobuf:"bytes,2,rep,name=scopes,proto3" json:"scopes,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CreateTokenRequest_Data) Reset() { - *x = CreateTokenRequest_Data{} - mi := &file_auth_auth_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CreateTokenRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CreateTokenRequest_Data) ProtoMessage() {} - -func (x *CreateTokenRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[13] - 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 CreateTokenRequest_Data.ProtoReflect.Descriptor instead. -func (*CreateTokenRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{4, 0} -} - -func (x *CreateTokenRequest_Data) GetUserId() string { +func (x *AuthenticateRequest) GetPath() string { if x != nil { - return x.UserId + return x.Path } return "" } -func (x *CreateTokenRequest_Data) GetScopes() []string { - if x != nil { - return x.Scopes - } - return nil -} - -type DestroyTokenRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DestroyTokenRequest_Data) Reset() { - *x = DestroyTokenRequest_Data{} - mi := &file_auth_auth_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DestroyTokenRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DestroyTokenRequest_Data) ProtoMessage() {} - -func (x *DestroyTokenRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[15] - 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 DestroyTokenRequest_Data.ProtoReflect.Descriptor instead. -func (*DestroyTokenRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{8, 0} -} - -func (x *DestroyTokenRequest_Data) GetToken() string { +func (x *AuthenticateRequest) GetMethod() string { if x != nil { - return x.Token + return x.Method } return "" } -type AuthenticateRequest_Data struct { +// The response message for the Authenticate RPC. +type AuthenticateResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"` - Method string `protobuf:"bytes,4,opt,name=method,proto3" json:"method,omitempty"` - Operation string `protobuf:"bytes,5,opt,name=operation,proto3" json:"operation,omitempty"` + Authorized bool `protobuf:"varint,1,opt,name=authorized,proto3" json:"authorized,omitempty"` + UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *AuthenticateRequest_Data) Reset() { - *x = AuthenticateRequest_Data{} - mi := &file_auth_auth_proto_msgTypes[16] +func (x *AuthenticateResponse) Reset() { + *x = AuthenticateResponse{} + mi := &file_auth_auth_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *AuthenticateRequest_Data) String() string { +func (x *AuthenticateResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AuthenticateRequest_Data) ProtoMessage() {} +func (*AuthenticateResponse) ProtoMessage() {} -func (x *AuthenticateRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[16] +func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -779,35 +584,21 @@ func (x *AuthenticateRequest_Data) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AuthenticateRequest_Data.ProtoReflect.Descriptor instead. -func (*AuthenticateRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{10, 0} -} - -func (x *AuthenticateRequest_Data) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -func (x *AuthenticateRequest_Data) GetPath() string { - if x != nil { - return x.Path - } - return "" +// Deprecated: Use AuthenticateResponse.ProtoReflect.Descriptor instead. +func (*AuthenticateResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{9} } -func (x *AuthenticateRequest_Data) GetMethod() string { +func (x *AuthenticateResponse) GetAuthorized() bool { if x != nil { - return x.Method + return x.Authorized } - return "" + return false } -func (x *AuthenticateRequest_Data) GetOperation() string { +func (x *AuthenticateResponse) GetUserId() string { if x != nil { - return x.Operation + return x.UserId } return "" } @@ -816,63 +607,60 @@ var File_auth_auth_proto protoreflect.FileDescriptor const file_auth_auth_proto_rawDesc = "" + "\n" + - "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"s\n" + - "\x11AuthLogoutRequest\x12@\n" + - "\x04data\x18\x01 \x01(\v2,.api.v1.services.auth.AuthLogoutRequest.DataR\x04data\x1a\x1c\n" + - "\x04Data\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\"B\n" + - "\x12AuthLogoutResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"\x90\x01\n" + - "\x18ListAuthResourcesRequest\x12\x1c\n" + - "\tpage_size\x18\x01 \x01(\x05R\tpage_size\x12\x1e\n" + + "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x88\x01\n" + + "\fLoginRequest\x12\x1a\n" + + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x1d\n" + + "\n" + + "captcha_id\x18\x03 \x01(\tR\tcaptchaId\x12!\n" + + "\fcaptcha_code\x18\x04 \x01(\tR\vcaptchaCode\"\x95\x01\n" + + "\rLoginResponse\x12!\n" + + "\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12#\n" + + "\rrefresh_token\x18\x02 \x01(\tR\frefreshToken\x12\x1d\n" + + "\n" + + "token_type\x18\x03 \x01(\tR\ttokenType\x12\x1d\n" + "\n" + - "page_token\x18\x02 \x01(\tR\n" + - "page_token\x12\x18\n" + - "\acurrent\x18\x03 \x01(\x05R\acurrent\x12\x1c\n" + - "\tno_paging\x18\x04 \x01(\bR\tno_paging\"z\n" + - "\x19ListAuthResourcesResponse\x12=\n" + - "\tresources\x18\x01 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x1e\n" + + "expires_in\x18\x04 \x01(\x03R\texpiresIn\"\xa1\x01\n" + + "\x0fRegisterRequest\x12\x1a\n" + + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x14\n" + + "\x05email\x18\x03 \x01(\tR\x05email\x12\x1d\n" + "\n" + - "total_size\x18\x02 \x01(\x05R\n" + - "total_size\"\x91\x01\n" + - "\x12CreateTokenRequest\x12A\n" + - "\x04data\x18\x01 \x01(\v2-.api.v1.services.auth.CreateTokenRequest.DataR\x04data\x1a8\n" + - "\x04Data\x12\x18\n" + - "\auser_id\x18\x01 \x01(\tR\auser_id\x12\x16\n" + - "\x06scopes\x18\x02 \x03(\tR\x06scopes\"+\n" + - "\x13CreateTokenResponse\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\",\n" + - "\x14ValidateTokenRequest\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\"\xbf\x01\n" + - "\x15ValidateTokenResponse\x12\x1a\n" + - "\bis_valid\x18\x01 \x01(\bR\bis_valid\x12O\n" + - "\x06claims\x18\x02 \x03(\v27.api.v1.services.auth.ValidateTokenResponse.ClaimsEntryR\x06claims\x1a9\n" + - "\vClaimsEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"w\n" + - "\x13DestroyTokenRequest\x12B\n" + - "\x04data\x18\x01 \x01(\v2..api.v1.services.auth.DestroyTokenRequest.DataR\x04data\x1a\x1c\n" + - "\x04Data\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token\"D\n" + - "\x14DestroyTokenResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"\xc1\x01\n" + - "\x13AuthenticateRequest\x12B\n" + - "\x04data\x18\x01 \x01(\v2..api.v1.services.auth.AuthenticateRequest.DataR\x04data\x1af\n" + - "\x04Data\x12\x14\n" + + "captcha_id\x18\x04 \x01(\tR\tcaptchaId\x12!\n" + + "\fcaptcha_code\x18\x05 \x01(\tR\vcaptchaCode\"4\n" + + "\rLogoutRequest\x12#\n" + + "\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\":\n" + + "\x13RefreshTokenRequest\x12#\n" + + "\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\"w\n" + + "\x14RefreshTokenResponse\x12!\n" + + "\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12\x1d\n" + + "\n" + + "token_type\x18\x02 \x01(\tR\ttokenType\x12\x1d\n" + + "\n" + + "expires_in\x18\x03 \x01(\x03R\texpiresIn\"+\n" + + "\x11GetCaptchaRequest\x12\x16\n" + + "\x06reload\x18\x01 \x01(\bR\x06reload\"X\n" + + "\x12GetCaptchaResponse\x12\x1d\n" + + "\n" + + "captcha_id\x18\x01 \x01(\tR\tcaptchaId\x12#\n" + + "\rcaptcha_image\x18\x02 \x01(\tR\fcaptchaImage\"W\n" + + "\x13AuthenticateRequest\x12\x14\n" + "\x05token\x18\x01 \x01(\tR\x05token\x12\x12\n" + - "\x04path\x18\x03 \x01(\tR\x04path\x12\x16\n" + - "\x06method\x18\x04 \x01(\tR\x06method\x12\x1c\n" + - "\toperation\x18\x05 \x01(\tR\toperation\"2\n" + - "\x14AuthenticateResponse\x12\x1a\n" + - "\bis_valid\x18\x01 \x01(\bR\bis_valid2\xab\x06\n" + - "\vAuthService\x12\x8d\x01\n" + - "\x11ListAuthResources\x12..api.v1.services.auth.ListAuthResourcesRequest\x1a/.api.v1.services.auth.ListAuthResourcesResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/auth/resources\x12}\n" + - "\vCreateToken\x12(.api.v1.services.auth.CreateTokenRequest\x1a).api.v1.services.auth.CreateTokenResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x04data\"\v/auth/token\x12\x80\x01\n" + - "\rValidateToken\x12*.api.v1.services.auth.ValidateTokenRequest\x1a+.api.v1.services.auth.ValidateTokenResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/auth/validate\x12\x82\x01\n" + - "\fDestroyToken\x12).api.v1.services.auth.DestroyTokenRequest\x1a*.api.v1.services.auth.DestroyTokenResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x04data\"\r/auth/destroy\x12\x87\x01\n" + - "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponse\" \x82\xd3\xe4\x93\x02\x1a:\x04data\"\x12/auth/authenticate\x12{\n" + + "\x04path\x18\x02 \x01(\tR\x04path\x12\x16\n" + + "\x06method\x18\x03 \x01(\tR\x06method\"O\n" + + "\x14AuthenticateResponse\x12\x1e\n" + + "\n" + + "authorized\x18\x01 \x01(\bR\n" + + "authorized\x12\x17\n" + + "\auser_id\x18\x02 \x01(\tR\x06userId2\xb3\x05\n" + + "\x04Auth\x12o\n" + + "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v1/auth/login\x12k\n" + + "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a\x16.google.protobuf.Empty\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/v1/auth/register\x12e\n" + + "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a\x16.google.protobuf.Empty\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/api/v1/auth/logout\x12\x84\x01\n" + + "\fRefreshToken\x12).api.v1.services.auth.RefreshTokenRequest\x1a*.api.v1.services.auth.RefreshTokenResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v1/auth/token\x12x\n" + "\n" + - "AuthLogout\x12'.api.v1.services.auth.AuthLogoutRequest\x1a(.api.v1.services.auth.AuthLogoutResponse\"\x1a\x82\xd3\xe4\x93\x02\x14:\x04data\"\f/auth/logoutB\xd0\x01\n" + + "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/api/v1/captcha\x12e\n" + + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponseB\xd0\x01\n" + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( @@ -887,54 +675,38 @@ func file_auth_auth_proto_rawDescGZIP() []byte { return file_auth_auth_proto_rawDescData } -var file_auth_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_auth_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_auth_auth_proto_goTypes = []any{ - (*AuthLogoutRequest)(nil), // 0: api.v1.services.auth.AuthLogoutRequest - (*AuthLogoutResponse)(nil), // 1: api.v1.services.auth.AuthLogoutResponse - (*ListAuthResourcesRequest)(nil), // 2: api.v1.services.auth.ListAuthResourcesRequest - (*ListAuthResourcesResponse)(nil), // 3: api.v1.services.auth.ListAuthResourcesResponse - (*CreateTokenRequest)(nil), // 4: api.v1.services.auth.CreateTokenRequest - (*CreateTokenResponse)(nil), // 5: api.v1.services.auth.CreateTokenResponse - (*ValidateTokenRequest)(nil), // 6: api.v1.services.auth.ValidateTokenRequest - (*ValidateTokenResponse)(nil), // 7: api.v1.services.auth.ValidateTokenResponse - (*DestroyTokenRequest)(nil), // 8: api.v1.services.auth.DestroyTokenRequest - (*DestroyTokenResponse)(nil), // 9: api.v1.services.auth.DestroyTokenResponse - (*AuthenticateRequest)(nil), // 10: api.v1.services.auth.AuthenticateRequest - (*AuthenticateResponse)(nil), // 11: api.v1.services.auth.AuthenticateResponse - (*AuthLogoutRequest_Data)(nil), // 12: api.v1.services.auth.AuthLogoutRequest.Data - (*CreateTokenRequest_Data)(nil), // 13: api.v1.services.auth.CreateTokenRequest.Data - nil, // 14: api.v1.services.auth.ValidateTokenResponse.ClaimsEntry - (*DestroyTokenRequest_Data)(nil), // 15: api.v1.services.auth.DestroyTokenRequest.Data - (*AuthenticateRequest_Data)(nil), // 16: api.v1.services.auth.AuthenticateRequest.Data - (*emptypb.Empty)(nil), // 17: google.protobuf.Empty - (*types.Resource)(nil), // 18: api.v1.services.types.Resource + (*LoginRequest)(nil), // 0: api.v1.services.auth.LoginRequest + (*LoginResponse)(nil), // 1: api.v1.services.auth.LoginResponse + (*RegisterRequest)(nil), // 2: api.v1.services.auth.RegisterRequest + (*LogoutRequest)(nil), // 3: api.v1.services.auth.LogoutRequest + (*RefreshTokenRequest)(nil), // 4: api.v1.services.auth.RefreshTokenRequest + (*RefreshTokenResponse)(nil), // 5: api.v1.services.auth.RefreshTokenResponse + (*GetCaptchaRequest)(nil), // 6: api.v1.services.auth.GetCaptchaRequest + (*GetCaptchaResponse)(nil), // 7: api.v1.services.auth.GetCaptchaResponse + (*AuthenticateRequest)(nil), // 8: api.v1.services.auth.AuthenticateRequest + (*AuthenticateResponse)(nil), // 9: api.v1.services.auth.AuthenticateResponse + (*emptypb.Empty)(nil), // 10: google.protobuf.Empty } var file_auth_auth_proto_depIdxs = []int32{ - 12, // 0: api.v1.services.auth.AuthLogoutRequest.data:type_name -> api.v1.services.auth.AuthLogoutRequest.Data - 17, // 1: api.v1.services.auth.AuthLogoutResponse.empty:type_name -> google.protobuf.Empty - 18, // 2: api.v1.services.auth.ListAuthResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 13, // 3: api.v1.services.auth.CreateTokenRequest.data:type_name -> api.v1.services.auth.CreateTokenRequest.Data - 14, // 4: api.v1.services.auth.ValidateTokenResponse.claims:type_name -> api.v1.services.auth.ValidateTokenResponse.ClaimsEntry - 15, // 5: api.v1.services.auth.DestroyTokenRequest.data:type_name -> api.v1.services.auth.DestroyTokenRequest.Data - 17, // 6: api.v1.services.auth.DestroyTokenResponse.empty:type_name -> google.protobuf.Empty - 16, // 7: api.v1.services.auth.AuthenticateRequest.data:type_name -> api.v1.services.auth.AuthenticateRequest.Data - 2, // 8: api.v1.services.auth.AuthService.ListAuthResources:input_type -> api.v1.services.auth.ListAuthResourcesRequest - 4, // 9: api.v1.services.auth.AuthService.CreateToken:input_type -> api.v1.services.auth.CreateTokenRequest - 6, // 10: api.v1.services.auth.AuthService.ValidateToken:input_type -> api.v1.services.auth.ValidateTokenRequest - 8, // 11: api.v1.services.auth.AuthService.DestroyToken:input_type -> api.v1.services.auth.DestroyTokenRequest - 10, // 12: api.v1.services.auth.AuthService.Authenticate:input_type -> api.v1.services.auth.AuthenticateRequest - 0, // 13: api.v1.services.auth.AuthService.AuthLogout:input_type -> api.v1.services.auth.AuthLogoutRequest - 3, // 14: api.v1.services.auth.AuthService.ListAuthResources:output_type -> api.v1.services.auth.ListAuthResourcesResponse - 5, // 15: api.v1.services.auth.AuthService.CreateToken:output_type -> api.v1.services.auth.CreateTokenResponse - 7, // 16: api.v1.services.auth.AuthService.ValidateToken:output_type -> api.v1.services.auth.ValidateTokenResponse - 9, // 17: api.v1.services.auth.AuthService.DestroyToken:output_type -> api.v1.services.auth.DestroyTokenResponse - 11, // 18: api.v1.services.auth.AuthService.Authenticate:output_type -> api.v1.services.auth.AuthenticateResponse - 1, // 19: api.v1.services.auth.AuthService.AuthLogout:output_type -> api.v1.services.auth.AuthLogoutResponse - 14, // [14:20] is the sub-list for method output_type - 8, // [8:14] 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 + 0, // 0: api.v1.services.auth.Auth.Login:input_type -> api.v1.services.auth.LoginRequest + 2, // 1: api.v1.services.auth.Auth.Register:input_type -> api.v1.services.auth.RegisterRequest + 3, // 2: api.v1.services.auth.Auth.Logout:input_type -> api.v1.services.auth.LogoutRequest + 4, // 3: api.v1.services.auth.Auth.RefreshToken:input_type -> api.v1.services.auth.RefreshTokenRequest + 6, // 4: api.v1.services.auth.Auth.GetCaptcha:input_type -> api.v1.services.auth.GetCaptchaRequest + 8, // 5: api.v1.services.auth.Auth.Authenticate:input_type -> api.v1.services.auth.AuthenticateRequest + 1, // 6: api.v1.services.auth.Auth.Login:output_type -> api.v1.services.auth.LoginResponse + 10, // 7: api.v1.services.auth.Auth.Register:output_type -> google.protobuf.Empty + 10, // 8: api.v1.services.auth.Auth.Logout:output_type -> google.protobuf.Empty + 5, // 9: api.v1.services.auth.Auth.RefreshToken:output_type -> api.v1.services.auth.RefreshTokenResponse + 7, // 10: api.v1.services.auth.Auth.GetCaptcha:output_type -> api.v1.services.auth.GetCaptchaResponse + 9, // 11: api.v1.services.auth.Auth.Authenticate:output_type -> api.v1.services.auth.AuthenticateResponse + 6, // [6:12] is the sub-list for method output_type + 0, // [0:6] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name } func init() { file_auth_auth_proto_init() } @@ -948,7 +720,7 @@ func file_auth_auth_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_auth_proto_rawDesc), len(file_auth_auth_proto_rawDesc)), NumEnums: 0, - NumMessages: 17, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, diff --git a/api/v1/services/auth/auth.pb.gw.go b/api/v1/services/auth/auth.pb.gw.go index 40545037..cc30ddbd 100644 --- a/api/v1/services/auth/auth.pb.gw.go +++ b/api/v1/services/auth/auth.pb.gw.go @@ -35,301 +35,248 @@ var ( _ = metadata.Join ) -var filter_AuthService_ListAuthResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_AuthService_ListAuthResources_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Auth_Login_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq ListAuthResourcesRequest + protoReq LoginRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ListAuthResources_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.ListAuthResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_AuthService_ListAuthResources_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Auth_Login_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq ListAuthResourcesRequest + protoReq LoginRequest metadata runtime.ServerMetadata ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ListAuthResources_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.ListAuthResources(ctx, &protoReq) + msg, err := server.Login(ctx, &protoReq) return msg, metadata, err } -func request_AuthService_CreateToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Auth_Register_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq CreateTokenRequest + protoReq RegisterRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.CreateToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Register(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_AuthService_CreateToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Auth_Register_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq CreateTokenRequest + protoReq RegisterRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.CreateToken(ctx, &protoReq) + msg, err := server.Register(ctx, &protoReq) return msg, metadata, err } -var filter_AuthService_ValidateToken_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_AuthService_ValidateToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Auth_Logout_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq ValidateTokenRequest + protoReq LogoutRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ValidateToken_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.ValidateToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Logout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_AuthService_ValidateToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Auth_Logout_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq ValidateTokenRequest + protoReq LogoutRequest metadata runtime.ServerMetadata ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_ValidateToken_0); err != nil { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.ValidateToken(ctx, &protoReq) + msg, err := server.Logout(ctx, &protoReq) return msg, metadata, err } -func request_AuthService_DestroyToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Auth_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq DestroyTokenRequest + protoReq RefreshTokenRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.DestroyToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.RefreshToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_AuthService_DestroyToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Auth_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq DestroyTokenRequest + protoReq RefreshTokenRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.DestroyToken(ctx, &protoReq) + msg, err := server.RefreshToken(ctx, &protoReq) return msg, metadata, err } -func request_AuthService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +var filter_Auth_GetCaptcha_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_Auth_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq AuthenticateRequest + protoReq GetCaptchaRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.Authenticate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_AuthService_Authenticate_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq AuthenticateRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Auth_GetCaptcha_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.Authenticate(ctx, &protoReq) + msg, err := client.GetCaptcha(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func request_AuthService_AuthLogout_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Auth_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq AuthLogoutRequest + protoReq GetCaptchaRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.AuthLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_AuthService_AuthLogout_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq AuthLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Auth_GetCaptcha_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.AuthLogout(ctx, &protoReq) + msg, err := server.GetCaptcha(ctx, &protoReq) return msg, metadata, err } -// RegisterAuthServiceHandlerServer registers the http handlers for service AuthService to "mux". -// UnaryRPC :call AuthServiceServer directly. +// RegisterAuthHandlerServer registers the http handlers for service Auth to "mux". +// UnaryRPC :call AuthServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthServiceHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServiceServer) error { - mux.Handle(http.MethodGet, pattern_AuthService_ListAuthResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/auth/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_AuthService_ListAuthResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_ListAuthResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_AuthService_CreateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { +func RegisterAuthHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServer) error { + mux.Handle(http.MethodPost, pattern_Auth_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/auth/token")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Auth/Login", runtime.WithHTTPPathPattern("/api/v1/auth/login")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_AuthService_CreateToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Auth_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_CreateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Auth_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_AuthService_ValidateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Auth_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/auth/validate")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Auth/Register", runtime.WithHTTPPathPattern("/api/v1/auth/register")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_AuthService_ValidateToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Auth_Register_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_ValidateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Auth_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_AuthService_DestroyToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Auth_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/auth/destroy")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Auth/Logout", runtime.WithHTTPPathPattern("/api/v1/auth/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_AuthService_DestroyToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Auth_Logout_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_DestroyToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Auth_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_AuthService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Auth_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/auth/authenticate")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Auth/RefreshToken", runtime.WithHTTPPathPattern("/api/v1/auth/token")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_AuthService_Authenticate_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Auth_RefreshToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_Authenticate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Auth_RefreshToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_AuthService_AuthLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_Auth_GetCaptcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/auth/logout")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Auth/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_AuthService_AuthLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Auth_GetCaptcha_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_AuthLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Auth_GetCaptcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } -// RegisterAuthServiceHandlerFromEndpoint is same as RegisterAuthServiceHandler but +// RegisterAuthHandlerFromEndpoint is same as RegisterAuthHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterAuthServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { +func RegisterAuthHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err @@ -348,140 +295,121 @@ func RegisterAuthServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.Se } }() }() - return RegisterAuthServiceHandler(ctx, mux, conn) + return RegisterAuthHandler(ctx, mux, conn) } -// RegisterAuthServiceHandler registers the http handlers for service AuthService to "mux". +// RegisterAuthHandler registers the http handlers for service Auth to "mux". // The handlers forward requests to the grpc endpoint over "conn". -func RegisterAuthServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterAuthServiceHandlerClient(ctx, mux, NewAuthServiceClient(conn)) +func RegisterAuthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterAuthHandlerClient(ctx, mux, NewAuthClient(conn)) } -// RegisterAuthServiceHandlerClient registers the http handlers for service AuthService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AuthServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AuthServiceClient" +// RegisterAuthHandlerClient registers the http handlers for service Auth +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AuthClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AuthClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "AuthServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthServiceClient) error { - mux.Handle(http.MethodGet, pattern_AuthService_ListAuthResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ListAuthResources", runtime.WithHTTPPathPattern("/auth/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_AuthService_ListAuthResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_AuthService_ListAuthResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_AuthService_CreateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { +// "AuthClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterAuthHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthClient) error { + mux.Handle(http.MethodPost, pattern_Auth_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/CreateToken", runtime.WithHTTPPathPattern("/auth/token")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Auth/Login", runtime.WithHTTPPathPattern("/api/v1/auth/login")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_AuthService_CreateToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Auth_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_CreateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Auth_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_AuthService_ValidateToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Auth_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/ValidateToken", runtime.WithHTTPPathPattern("/auth/validate")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Auth/Register", runtime.WithHTTPPathPattern("/api/v1/auth/register")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_AuthService_ValidateToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Auth_Register_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_ValidateToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Auth_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_AuthService_DestroyToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Auth_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/DestroyToken", runtime.WithHTTPPathPattern("/auth/destroy")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Auth/Logout", runtime.WithHTTPPathPattern("/api/v1/auth/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_AuthService_DestroyToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Auth_Logout_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_DestroyToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Auth_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_AuthService_Authenticate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_Auth_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Authenticate", runtime.WithHTTPPathPattern("/auth/authenticate")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Auth/RefreshToken", runtime.WithHTTPPathPattern("/api/v1/auth/token")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_AuthService_Authenticate_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Auth_RefreshToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_Authenticate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Auth_RefreshToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_AuthService_AuthLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_Auth_GetCaptcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/AuthLogout", runtime.WithHTTPPathPattern("/auth/logout")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Auth/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_AuthService_AuthLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Auth_GetCaptcha_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_AuthLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Auth_GetCaptcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( - pattern_AuthService_ListAuthResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "resources"}, "")) - pattern_AuthService_CreateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "token"}, "")) - pattern_AuthService_ValidateToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "validate"}, "")) - pattern_AuthService_DestroyToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "destroy"}, "")) - pattern_AuthService_Authenticate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "authenticate"}, "")) - pattern_AuthService_AuthLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "logout"}, "")) + pattern_Auth_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "login"}, "")) + pattern_Auth_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "register"}, "")) + pattern_Auth_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "logout"}, "")) + pattern_Auth_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "token"}, "")) + pattern_Auth_GetCaptcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "captcha"}, "")) ) var ( - forward_AuthService_ListAuthResources_0 = runtime.ForwardResponseMessage - forward_AuthService_CreateToken_0 = runtime.ForwardResponseMessage - forward_AuthService_ValidateToken_0 = runtime.ForwardResponseMessage - forward_AuthService_DestroyToken_0 = runtime.ForwardResponseMessage - forward_AuthService_Authenticate_0 = runtime.ForwardResponseMessage - forward_AuthService_AuthLogout_0 = runtime.ForwardResponseMessage + forward_Auth_Login_0 = runtime.ForwardResponseMessage + forward_Auth_Register_0 = runtime.ForwardResponseMessage + forward_Auth_Logout_0 = runtime.ForwardResponseMessage + forward_Auth_RefreshToken_0 = runtime.ForwardResponseMessage + forward_Auth_GetCaptcha_0 = runtime.ForwardResponseMessage ) diff --git a/api/v1/services/auth/auth.pb.validate.go b/api/v1/services/auth/auth.pb.validate.go index 3cc97d16..8e45ad1a 100644 --- a/api/v1/services/auth/auth.pb.validate.go +++ b/api/v1/services/auth/auth.pb.validate.go @@ -35,202 +35,49 @@ var ( _ = sort.Sort ) -// Validate checks the field values on AuthLogoutRequest 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 *AuthLogoutRequest) Validate() error { +// 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. +func (m *LoginRequest) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on AuthLogoutRequest 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 -// AuthLogoutRequestMultiError, or nil if none found. -func (m *AuthLogoutRequest) ValidateAll() error { +// ValidateAll checks the field values on LoginRequest 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 LoginRequestMultiError, or +// nil if none found. +func (m *LoginRequest) ValidateAll() error { return m.validate(true) } -func (m *AuthLogoutRequest) validate(all bool) error { +func (m *LoginRequest) validate(all bool) error { if m == nil { return nil } var errors []error - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, AuthLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, AuthLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return AuthLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return AuthLogoutRequestMultiError(errors) - } - - return nil -} - -// AuthLogoutRequestMultiError is an error wrapping multiple validation errors -// returned by AuthLogoutRequest.ValidateAll() if the designated constraints -// aren't met. -type AuthLogoutRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m AuthLogoutRequestMultiError) 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 AuthLogoutRequestMultiError) AllErrors() []error { return m } - -// AuthLogoutRequestValidationError is the validation error returned by -// AuthLogoutRequest.Validate if the designated constraints aren't met. -type AuthLogoutRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e AuthLogoutRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e AuthLogoutRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e AuthLogoutRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e AuthLogoutRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e AuthLogoutRequestValidationError) ErrorName() string { - return "AuthLogoutRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e AuthLogoutRequestValidationError) 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 %sAuthLogoutRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = AuthLogoutRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = AuthLogoutRequestValidationError{} - -// Validate checks the field values on AuthLogoutResponse 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 *AuthLogoutResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on AuthLogoutResponse 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 -// AuthLogoutResponseMultiError, or nil if none found. -func (m *AuthLogoutResponse) ValidateAll() error { - return m.validate(true) -} + // no validation rules for Username -func (m *AuthLogoutResponse) validate(all bool) error { - if m == nil { - return nil - } + // no validation rules for Password - var errors []error + // no validation rules for CaptchaId - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, AuthLogoutResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, AuthLogoutResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return AuthLogoutResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for CaptchaCode if len(errors) > 0 { - return AuthLogoutResponseMultiError(errors) + return LoginRequestMultiError(errors) } return nil } -// AuthLogoutResponseMultiError is an error wrapping multiple validation errors -// returned by AuthLogoutResponse.ValidateAll() if the designated constraints -// aren't met. -type AuthLogoutResponseMultiError []error +// LoginRequestMultiError is an error wrapping multiple validation errors +// returned by LoginRequest.ValidateAll() if the designated constraints aren't met. +type LoginRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m AuthLogoutResponseMultiError) Error() string { +func (m LoginRequestMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -239,11 +86,11 @@ func (m AuthLogoutResponseMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m AuthLogoutResponseMultiError) AllErrors() []error { return m } +func (m LoginRequestMultiError) AllErrors() []error { return m } -// AuthLogoutResponseValidationError is the validation error returned by -// AuthLogoutResponse.Validate if the designated constraints aren't met. -type AuthLogoutResponseValidationError struct { +// LoginRequestValidationError is the validation error returned by +// LoginRequest.Validate if the designated constraints aren't met. +type LoginRequestValidationError struct { field string reason string cause error @@ -251,24 +98,22 @@ type AuthLogoutResponseValidationError struct { } // Field function returns field value. -func (e AuthLogoutResponseValidationError) Field() string { return e.field } +func (e LoginRequestValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e AuthLogoutResponseValidationError) Reason() string { return e.reason } +func (e LoginRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e AuthLogoutResponseValidationError) Cause() error { return e.cause } +func (e LoginRequestValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e AuthLogoutResponseValidationError) Key() bool { return e.key } +func (e LoginRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e AuthLogoutResponseValidationError) ErrorName() string { - return "AuthLogoutResponseValidationError" -} +func (e LoginRequestValidationError) ErrorName() string { return "LoginRequestValidationError" } // Error satisfies the builtin error interface -func (e AuthLogoutResponseValidationError) Error() string { +func (e LoginRequestValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -280,14 +125,14 @@ func (e AuthLogoutResponseValidationError) Error() string { } return fmt.Sprintf( - "invalid %sAuthLogoutResponse.%s: %s%s", + "invalid %sLoginRequest.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = AuthLogoutResponseValidationError{} +var _ error = LoginRequestValidationError{} var _ interface { Field() string @@ -295,52 +140,52 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = AuthLogoutResponseValidationError{} +} = LoginRequestValidationError{} -// Validate checks the field values on ListAuthResourcesRequest 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 *ListAuthResourcesRequest) Validate() error { +// Validate checks the field values on LoginResponse 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 *LoginResponse) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on ListAuthResourcesRequest 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 -// ListAuthResourcesRequestMultiError, or nil if none found. -func (m *ListAuthResourcesRequest) ValidateAll() error { +// ValidateAll checks the field values on LoginResponse 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 LoginResponseMultiError, or +// nil if none found. +func (m *LoginResponse) ValidateAll() error { return m.validate(true) } -func (m *ListAuthResourcesRequest) validate(all bool) error { +func (m *LoginResponse) validate(all bool) error { if m == nil { return nil } var errors []error - // no validation rules for PageSize + // no validation rules for AccessToken - // no validation rules for PageToken + // no validation rules for RefreshToken - // no validation rules for Current + // no validation rules for TokenType - // no validation rules for NoPaging + // no validation rules for ExpiresIn if len(errors) > 0 { - return ListAuthResourcesRequestMultiError(errors) + return LoginResponseMultiError(errors) } return nil } -// ListAuthResourcesRequestMultiError is an error wrapping multiple validation -// errors returned by ListAuthResourcesRequest.ValidateAll() if the designated -// constraints aren't met. -type ListAuthResourcesRequestMultiError []error +// LoginResponseMultiError is an error wrapping multiple validation errors +// returned by LoginResponse.ValidateAll() if the designated constraints +// aren't met. +type LoginResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m ListAuthResourcesRequestMultiError) Error() string { +func (m LoginResponseMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -349,11 +194,11 @@ func (m ListAuthResourcesRequestMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m ListAuthResourcesRequestMultiError) AllErrors() []error { return m } +func (m LoginResponseMultiError) AllErrors() []error { return m } -// ListAuthResourcesRequestValidationError is the validation error returned by -// ListAuthResourcesRequest.Validate if the designated constraints aren't met. -type ListAuthResourcesRequestValidationError struct { +// LoginResponseValidationError is the validation error returned by +// LoginResponse.Validate if the designated constraints aren't met. +type LoginResponseValidationError struct { field string reason string cause error @@ -361,24 +206,22 @@ type ListAuthResourcesRequestValidationError struct { } // Field function returns field value. -func (e ListAuthResourcesRequestValidationError) Field() string { return e.field } +func (e LoginResponseValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e ListAuthResourcesRequestValidationError) Reason() string { return e.reason } +func (e LoginResponseValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e ListAuthResourcesRequestValidationError) Cause() error { return e.cause } +func (e LoginResponseValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e ListAuthResourcesRequestValidationError) Key() bool { return e.key } +func (e LoginResponseValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e ListAuthResourcesRequestValidationError) ErrorName() string { - return "ListAuthResourcesRequestValidationError" -} +func (e LoginResponseValidationError) ErrorName() string { return "LoginResponseValidationError" } // Error satisfies the builtin error interface -func (e ListAuthResourcesRequestValidationError) Error() string { +func (e LoginResponseValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -390,14 +233,14 @@ func (e ListAuthResourcesRequestValidationError) Error() string { } return fmt.Sprintf( - "invalid %sListAuthResourcesRequest.%s: %s%s", + "invalid %sLoginResponse.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = ListAuthResourcesRequestValidationError{} +var _ error = LoginResponseValidationError{} var _ interface { Field() string @@ -405,211 +248,54 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = ListAuthResourcesRequestValidationError{} +} = LoginResponseValidationError{} -// Validate checks the field values on ListAuthResourcesResponse 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 *ListAuthResourcesResponse) Validate() error { +// Validate checks the field values on RegisterRequest 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 *RegisterRequest) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on ListAuthResourcesResponse with the -// rules defined in the proto definition for this message. If any rules are +// ValidateAll checks the field values on RegisterRequest 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 -// ListAuthResourcesResponseMultiError, or nil if none found. -func (m *ListAuthResourcesResponse) ValidateAll() error { +// RegisterRequestMultiError, or nil if none found. +func (m *RegisterRequest) ValidateAll() error { return m.validate(true) } -func (m *ListAuthResourcesResponse) validate(all bool) error { +func (m *RegisterRequest) validate(all bool) error { if m == nil { return nil } var errors []error - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListAuthResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListAuthResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListAuthResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for TotalSize - - if len(errors) > 0 { - return ListAuthResourcesResponseMultiError(errors) - } - - return nil -} - -// ListAuthResourcesResponseMultiError is an error wrapping multiple validation -// errors returned by ListAuthResourcesResponse.ValidateAll() if the -// designated constraints aren't met. -type ListAuthResourcesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListAuthResourcesResponseMultiError) 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 ListAuthResourcesResponseMultiError) AllErrors() []error { return m } - -// ListAuthResourcesResponseValidationError is the validation error returned by -// ListAuthResourcesResponse.Validate if the designated constraints aren't met. -type ListAuthResourcesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListAuthResourcesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListAuthResourcesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListAuthResourcesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListAuthResourcesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListAuthResourcesResponseValidationError) ErrorName() string { - return "ListAuthResourcesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListAuthResourcesResponseValidationError) 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 %sListAuthResourcesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListAuthResourcesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListAuthResourcesResponseValidationError{} - -// Validate checks the field values on CreateTokenRequest 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 *CreateTokenRequest) Validate() error { - return m.validate(false) -} + // no validation rules for Username -// ValidateAll checks the field values on CreateTokenRequest 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 -// CreateTokenRequestMultiError, or nil if none found. -func (m *CreateTokenRequest) ValidateAll() error { - return m.validate(true) -} + // no validation rules for Password -func (m *CreateTokenRequest) validate(all bool) error { - if m == nil { - return nil - } + // no validation rules for Email - var errors []error + // no validation rules for CaptchaId - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CreateTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CreateTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CreateTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for CaptchaCode if len(errors) > 0 { - return CreateTokenRequestMultiError(errors) + return RegisterRequestMultiError(errors) } return nil } -// CreateTokenRequestMultiError is an error wrapping multiple validation errors -// returned by CreateTokenRequest.ValidateAll() if the designated constraints +// RegisterRequestMultiError is an error wrapping multiple validation errors +// returned by RegisterRequest.ValidateAll() if the designated constraints // aren't met. -type CreateTokenRequestMultiError []error +type RegisterRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m CreateTokenRequestMultiError) Error() string { +func (m RegisterRequestMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -618,11 +304,11 @@ func (m CreateTokenRequestMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m CreateTokenRequestMultiError) AllErrors() []error { return m } +func (m RegisterRequestMultiError) AllErrors() []error { return m } -// CreateTokenRequestValidationError is the validation error returned by -// CreateTokenRequest.Validate if the designated constraints aren't met. -type CreateTokenRequestValidationError struct { +// RegisterRequestValidationError is the validation error returned by +// RegisterRequest.Validate if the designated constraints aren't met. +type RegisterRequestValidationError struct { field string reason string cause error @@ -630,24 +316,22 @@ type CreateTokenRequestValidationError struct { } // Field function returns field value. -func (e CreateTokenRequestValidationError) Field() string { return e.field } +func (e RegisterRequestValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e CreateTokenRequestValidationError) Reason() string { return e.reason } +func (e RegisterRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e CreateTokenRequestValidationError) Cause() error { return e.cause } +func (e RegisterRequestValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e CreateTokenRequestValidationError) Key() bool { return e.key } +func (e RegisterRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e CreateTokenRequestValidationError) ErrorName() string { - return "CreateTokenRequestValidationError" -} +func (e RegisterRequestValidationError) ErrorName() string { return "RegisterRequestValidationError" } // Error satisfies the builtin error interface -func (e CreateTokenRequestValidationError) Error() string { +func (e RegisterRequestValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -659,14 +343,14 @@ func (e CreateTokenRequestValidationError) Error() string { } return fmt.Sprintf( - "invalid %sCreateTokenRequest.%s: %s%s", + "invalid %sRegisterRequest.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = CreateTokenRequestValidationError{} +var _ error = RegisterRequestValidationError{} var _ interface { Field() string @@ -674,46 +358,46 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = CreateTokenRequestValidationError{} +} = RegisterRequestValidationError{} -// Validate checks the field values on CreateTokenResponse 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 *CreateTokenResponse) Validate() error { +// Validate checks the field values on LogoutRequest 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 *LogoutRequest) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on CreateTokenResponse 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 -// CreateTokenResponseMultiError, or nil if none found. -func (m *CreateTokenResponse) ValidateAll() error { +// ValidateAll checks the field values on LogoutRequest 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 LogoutRequestMultiError, or +// nil if none found. +func (m *LogoutRequest) ValidateAll() error { return m.validate(true) } -func (m *CreateTokenResponse) validate(all bool) error { +func (m *LogoutRequest) validate(all bool) error { if m == nil { return nil } var errors []error - // no validation rules for Token + // no validation rules for RefreshToken if len(errors) > 0 { - return CreateTokenResponseMultiError(errors) + return LogoutRequestMultiError(errors) } return nil } -// CreateTokenResponseMultiError is an error wrapping multiple validation -// errors returned by CreateTokenResponse.ValidateAll() if the designated -// constraints aren't met. -type CreateTokenResponseMultiError []error +// LogoutRequestMultiError is an error wrapping multiple validation errors +// returned by LogoutRequest.ValidateAll() if the designated constraints +// aren't met. +type LogoutRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m CreateTokenResponseMultiError) Error() string { +func (m LogoutRequestMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -722,11 +406,11 @@ func (m CreateTokenResponseMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m CreateTokenResponseMultiError) AllErrors() []error { return m } +func (m LogoutRequestMultiError) AllErrors() []error { return m } -// CreateTokenResponseValidationError is the validation error returned by -// CreateTokenResponse.Validate if the designated constraints aren't met. -type CreateTokenResponseValidationError struct { +// LogoutRequestValidationError is the validation error returned by +// LogoutRequest.Validate if the designated constraints aren't met. +type LogoutRequestValidationError struct { field string reason string cause error @@ -734,24 +418,22 @@ type CreateTokenResponseValidationError struct { } // Field function returns field value. -func (e CreateTokenResponseValidationError) Field() string { return e.field } +func (e LogoutRequestValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e CreateTokenResponseValidationError) Reason() string { return e.reason } +func (e LogoutRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e CreateTokenResponseValidationError) Cause() error { return e.cause } +func (e LogoutRequestValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e CreateTokenResponseValidationError) Key() bool { return e.key } +func (e LogoutRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e CreateTokenResponseValidationError) ErrorName() string { - return "CreateTokenResponseValidationError" -} +func (e LogoutRequestValidationError) ErrorName() string { return "LogoutRequestValidationError" } // Error satisfies the builtin error interface -func (e CreateTokenResponseValidationError) Error() string { +func (e LogoutRequestValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -763,14 +445,14 @@ func (e CreateTokenResponseValidationError) Error() string { } return fmt.Sprintf( - "invalid %sCreateTokenResponse.%s: %s%s", + "invalid %sLogoutRequest.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = CreateTokenResponseValidationError{} +var _ error = LogoutRequestValidationError{} var _ interface { Field() string @@ -778,46 +460,46 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = CreateTokenResponseValidationError{} +} = LogoutRequestValidationError{} -// Validate checks the field values on ValidateTokenRequest with the rules +// Validate checks the field values on RefreshTokenRequest 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 *ValidateTokenRequest) Validate() error { +func (m *RefreshTokenRequest) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on ValidateTokenRequest with the rules +// ValidateAll checks the field values on RefreshTokenRequest 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 -// ValidateTokenRequestMultiError, or nil if none found. -func (m *ValidateTokenRequest) ValidateAll() error { +// RefreshTokenRequestMultiError, or nil if none found. +func (m *RefreshTokenRequest) ValidateAll() error { return m.validate(true) } -func (m *ValidateTokenRequest) validate(all bool) error { +func (m *RefreshTokenRequest) validate(all bool) error { if m == nil { return nil } var errors []error - // no validation rules for Token + // no validation rules for RefreshToken if len(errors) > 0 { - return ValidateTokenRequestMultiError(errors) + return RefreshTokenRequestMultiError(errors) } return nil } -// ValidateTokenRequestMultiError is an error wrapping multiple validation -// errors returned by ValidateTokenRequest.ValidateAll() if the designated +// RefreshTokenRequestMultiError is an error wrapping multiple validation +// errors returned by RefreshTokenRequest.ValidateAll() if the designated // constraints aren't met. -type ValidateTokenRequestMultiError []error +type RefreshTokenRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m ValidateTokenRequestMultiError) Error() string { +func (m RefreshTokenRequestMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -826,11 +508,11 @@ func (m ValidateTokenRequestMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m ValidateTokenRequestMultiError) AllErrors() []error { return m } +func (m RefreshTokenRequestMultiError) AllErrors() []error { return m } -// ValidateTokenRequestValidationError is the validation error returned by -// ValidateTokenRequest.Validate if the designated constraints aren't met. -type ValidateTokenRequestValidationError struct { +// RefreshTokenRequestValidationError is the validation error returned by +// RefreshTokenRequest.Validate if the designated constraints aren't met. +type RefreshTokenRequestValidationError struct { field string reason string cause error @@ -838,24 +520,24 @@ type ValidateTokenRequestValidationError struct { } // Field function returns field value. -func (e ValidateTokenRequestValidationError) Field() string { return e.field } +func (e RefreshTokenRequestValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e ValidateTokenRequestValidationError) Reason() string { return e.reason } +func (e RefreshTokenRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e ValidateTokenRequestValidationError) Cause() error { return e.cause } +func (e RefreshTokenRequestValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e ValidateTokenRequestValidationError) Key() bool { return e.key } +func (e RefreshTokenRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e ValidateTokenRequestValidationError) ErrorName() string { - return "ValidateTokenRequestValidationError" +func (e RefreshTokenRequestValidationError) ErrorName() string { + return "RefreshTokenRequestValidationError" } // Error satisfies the builtin error interface -func (e ValidateTokenRequestValidationError) Error() string { +func (e RefreshTokenRequestValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -867,14 +549,14 @@ func (e ValidateTokenRequestValidationError) Error() string { } return fmt.Sprintf( - "invalid %sValidateTokenRequest.%s: %s%s", + "invalid %sRefreshTokenRequest.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = ValidateTokenRequestValidationError{} +var _ error = RefreshTokenRequestValidationError{} var _ interface { Field() string @@ -882,48 +564,50 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = ValidateTokenRequestValidationError{} +} = RefreshTokenRequestValidationError{} -// Validate checks the field values on ValidateTokenResponse with the rules +// Validate checks the field values on RefreshTokenResponse 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 *ValidateTokenResponse) Validate() error { +func (m *RefreshTokenResponse) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on ValidateTokenResponse with the rules +// ValidateAll checks the field values on RefreshTokenResponse 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 -// ValidateTokenResponseMultiError, or nil if none found. -func (m *ValidateTokenResponse) ValidateAll() error { +// RefreshTokenResponseMultiError, or nil if none found. +func (m *RefreshTokenResponse) ValidateAll() error { return m.validate(true) } -func (m *ValidateTokenResponse) validate(all bool) error { +func (m *RefreshTokenResponse) validate(all bool) error { if m == nil { return nil } var errors []error - // no validation rules for IsValid + // no validation rules for AccessToken - // no validation rules for Claims + // no validation rules for TokenType + + // no validation rules for ExpiresIn if len(errors) > 0 { - return ValidateTokenResponseMultiError(errors) + return RefreshTokenResponseMultiError(errors) } return nil } -// ValidateTokenResponseMultiError is an error wrapping multiple validation -// errors returned by ValidateTokenResponse.ValidateAll() if the designated +// RefreshTokenResponseMultiError is an error wrapping multiple validation +// errors returned by RefreshTokenResponse.ValidateAll() if the designated // constraints aren't met. -type ValidateTokenResponseMultiError []error +type RefreshTokenResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m ValidateTokenResponseMultiError) Error() string { +func (m RefreshTokenResponseMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -932,11 +616,11 @@ func (m ValidateTokenResponseMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m ValidateTokenResponseMultiError) AllErrors() []error { return m } +func (m RefreshTokenResponseMultiError) AllErrors() []error { return m } -// ValidateTokenResponseValidationError is the validation error returned by -// ValidateTokenResponse.Validate if the designated constraints aren't met. -type ValidateTokenResponseValidationError struct { +// RefreshTokenResponseValidationError is the validation error returned by +// RefreshTokenResponse.Validate if the designated constraints aren't met. +type RefreshTokenResponseValidationError struct { field string reason string cause error @@ -944,24 +628,24 @@ type ValidateTokenResponseValidationError struct { } // Field function returns field value. -func (e ValidateTokenResponseValidationError) Field() string { return e.field } +func (e RefreshTokenResponseValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e ValidateTokenResponseValidationError) Reason() string { return e.reason } +func (e RefreshTokenResponseValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e ValidateTokenResponseValidationError) Cause() error { return e.cause } +func (e RefreshTokenResponseValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e ValidateTokenResponseValidationError) Key() bool { return e.key } +func (e RefreshTokenResponseValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e ValidateTokenResponseValidationError) ErrorName() string { - return "ValidateTokenResponseValidationError" +func (e RefreshTokenResponseValidationError) ErrorName() string { + return "RefreshTokenResponseValidationError" } // Error satisfies the builtin error interface -func (e ValidateTokenResponseValidationError) Error() string { +func (e RefreshTokenResponseValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -973,14 +657,14 @@ func (e ValidateTokenResponseValidationError) Error() string { } return fmt.Sprintf( - "invalid %sValidateTokenResponse.%s: %s%s", + "invalid %sRefreshTokenResponse.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = ValidateTokenResponseValidationError{} +var _ error = RefreshTokenResponseValidationError{} var _ interface { Field() string @@ -988,73 +672,46 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = ValidateTokenResponseValidationError{} +} = RefreshTokenResponseValidationError{} -// Validate checks the field values on DestroyTokenRequest 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 *DestroyTokenRequest) Validate() error { +// Validate checks the field values on GetCaptchaRequest 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 *GetCaptchaRequest) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on DestroyTokenRequest with the rules +// ValidateAll checks the field values on GetCaptchaRequest 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 -// DestroyTokenRequestMultiError, or nil if none found. -func (m *DestroyTokenRequest) ValidateAll() error { +// GetCaptchaRequestMultiError, or nil if none found. +func (m *GetCaptchaRequest) ValidateAll() error { return m.validate(true) } -func (m *DestroyTokenRequest) validate(all bool) error { +func (m *GetCaptchaRequest) validate(all bool) error { if m == nil { return nil } var errors []error - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DestroyTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DestroyTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DestroyTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for Reload if len(errors) > 0 { - return DestroyTokenRequestMultiError(errors) + return GetCaptchaRequestMultiError(errors) } return nil } -// DestroyTokenRequestMultiError is an error wrapping multiple validation -// errors returned by DestroyTokenRequest.ValidateAll() if the designated -// constraints aren't met. -type DestroyTokenRequestMultiError []error +// GetCaptchaRequestMultiError is an error wrapping multiple validation errors +// returned by GetCaptchaRequest.ValidateAll() if the designated constraints +// aren't met. +type GetCaptchaRequestMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m DestroyTokenRequestMultiError) Error() string { +func (m GetCaptchaRequestMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -1063,11 +720,11 @@ func (m DestroyTokenRequestMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m DestroyTokenRequestMultiError) AllErrors() []error { return m } +func (m GetCaptchaRequestMultiError) AllErrors() []error { return m } -// DestroyTokenRequestValidationError is the validation error returned by -// DestroyTokenRequest.Validate if the designated constraints aren't met. -type DestroyTokenRequestValidationError struct { +// GetCaptchaRequestValidationError is the validation error returned by +// GetCaptchaRequest.Validate if the designated constraints aren't met. +type GetCaptchaRequestValidationError struct { field string reason string cause error @@ -1075,24 +732,24 @@ type DestroyTokenRequestValidationError struct { } // Field function returns field value. -func (e DestroyTokenRequestValidationError) Field() string { return e.field } +func (e GetCaptchaRequestValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e DestroyTokenRequestValidationError) Reason() string { return e.reason } +func (e GetCaptchaRequestValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e DestroyTokenRequestValidationError) Cause() error { return e.cause } +func (e GetCaptchaRequestValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e DestroyTokenRequestValidationError) Key() bool { return e.key } +func (e GetCaptchaRequestValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e DestroyTokenRequestValidationError) ErrorName() string { - return "DestroyTokenRequestValidationError" +func (e GetCaptchaRequestValidationError) ErrorName() string { + return "GetCaptchaRequestValidationError" } // Error satisfies the builtin error interface -func (e DestroyTokenRequestValidationError) Error() string { +func (e GetCaptchaRequestValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -1104,14 +761,14 @@ func (e DestroyTokenRequestValidationError) Error() string { } return fmt.Sprintf( - "invalid %sDestroyTokenRequest.%s: %s%s", + "invalid %sGetCaptchaRequest.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = DestroyTokenRequestValidationError{} +var _ error = GetCaptchaRequestValidationError{} var _ interface { Field() string @@ -1119,73 +776,48 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = DestroyTokenRequestValidationError{} +} = GetCaptchaRequestValidationError{} -// Validate checks the field values on DestroyTokenResponse with the rules +// Validate checks the field values on GetCaptchaResponse 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 *DestroyTokenResponse) Validate() error { +func (m *GetCaptchaResponse) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on DestroyTokenResponse with the rules +// ValidateAll checks the field values on GetCaptchaResponse 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 -// DestroyTokenResponseMultiError, or nil if none found. -func (m *DestroyTokenResponse) ValidateAll() error { +// GetCaptchaResponseMultiError, or nil if none found. +func (m *GetCaptchaResponse) ValidateAll() error { return m.validate(true) } -func (m *DestroyTokenResponse) validate(all bool) error { +func (m *GetCaptchaResponse) validate(all bool) error { if m == nil { return nil } var errors []error - if all { - switch v := interface{}(m.GetEmpty()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DestroyTokenResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DestroyTokenResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DestroyTokenResponseValidationError{ - field: "Empty", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for CaptchaId + + // no validation rules for CaptchaImage if len(errors) > 0 { - return DestroyTokenResponseMultiError(errors) + return GetCaptchaResponseMultiError(errors) } return nil } -// DestroyTokenResponseMultiError is an error wrapping multiple validation -// errors returned by DestroyTokenResponse.ValidateAll() if the designated -// constraints aren't met. -type DestroyTokenResponseMultiError []error +// GetCaptchaResponseMultiError is an error wrapping multiple validation errors +// returned by GetCaptchaResponse.ValidateAll() if the designated constraints +// aren't met. +type GetCaptchaResponseMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m DestroyTokenResponseMultiError) Error() string { +func (m GetCaptchaResponseMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -1194,11 +826,11 @@ func (m DestroyTokenResponseMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m DestroyTokenResponseMultiError) AllErrors() []error { return m } +func (m GetCaptchaResponseMultiError) AllErrors() []error { return m } -// DestroyTokenResponseValidationError is the validation error returned by -// DestroyTokenResponse.Validate if the designated constraints aren't met. -type DestroyTokenResponseValidationError struct { +// GetCaptchaResponseValidationError is the validation error returned by +// GetCaptchaResponse.Validate if the designated constraints aren't met. +type GetCaptchaResponseValidationError struct { field string reason string cause error @@ -1206,24 +838,24 @@ type DestroyTokenResponseValidationError struct { } // Field function returns field value. -func (e DestroyTokenResponseValidationError) Field() string { return e.field } +func (e GetCaptchaResponseValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e DestroyTokenResponseValidationError) Reason() string { return e.reason } +func (e GetCaptchaResponseValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e DestroyTokenResponseValidationError) Cause() error { return e.cause } +func (e GetCaptchaResponseValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e DestroyTokenResponseValidationError) Key() bool { return e.key } +func (e GetCaptchaResponseValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e DestroyTokenResponseValidationError) ErrorName() string { - return "DestroyTokenResponseValidationError" +func (e GetCaptchaResponseValidationError) ErrorName() string { + return "GetCaptchaResponseValidationError" } // Error satisfies the builtin error interface -func (e DestroyTokenResponseValidationError) Error() string { +func (e GetCaptchaResponseValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -1235,14 +867,14 @@ func (e DestroyTokenResponseValidationError) Error() string { } return fmt.Sprintf( - "invalid %sDestroyTokenResponse.%s: %s%s", + "invalid %sGetCaptchaResponse.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = DestroyTokenResponseValidationError{} +var _ error = GetCaptchaResponseValidationError{} var _ interface { Field() string @@ -1250,7 +882,7 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = DestroyTokenResponseValidationError{} +} = GetCaptchaResponseValidationError{} // Validate checks the field values on AuthenticateRequest with the rules // defined in the proto definition for this message. If any rules are @@ -1274,34 +906,11 @@ func (m *AuthenticateRequest) validate(all bool) error { var errors []error - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, AuthenticateRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, AuthenticateRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return AuthenticateRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for Token + + // no validation rules for Path + + // no validation rules for Method if len(errors) > 0 { return AuthenticateRequestMultiError(errors) @@ -1405,7 +1014,9 @@ func (m *AuthenticateResponse) validate(all bool) error { var errors []error - // no validation rules for IsValid + // no validation rules for Authorized + + // no validation rules for UserId if len(errors) > 0 { return AuthenticateResponseMultiError(errors) @@ -1486,425 +1097,3 @@ var _ interface { Cause() error ErrorName() string } = AuthenticateResponseValidationError{} - -// Validate checks the field values on AuthLogoutRequest_Data 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 *AuthLogoutRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on AuthLogoutRequest_Data 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 -// AuthLogoutRequest_DataMultiError, or nil if none found. -func (m *AuthLogoutRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *AuthLogoutRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - if len(errors) > 0 { - return AuthLogoutRequest_DataMultiError(errors) - } - - return nil -} - -// AuthLogoutRequest_DataMultiError is an error wrapping multiple validation -// errors returned by AuthLogoutRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type AuthLogoutRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m AuthLogoutRequest_DataMultiError) 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 AuthLogoutRequest_DataMultiError) AllErrors() []error { return m } - -// AuthLogoutRequest_DataValidationError is the validation error returned by -// AuthLogoutRequest_Data.Validate if the designated constraints aren't met. -type AuthLogoutRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e AuthLogoutRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e AuthLogoutRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e AuthLogoutRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e AuthLogoutRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e AuthLogoutRequest_DataValidationError) ErrorName() string { - return "AuthLogoutRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e AuthLogoutRequest_DataValidationError) 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 %sAuthLogoutRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = AuthLogoutRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = AuthLogoutRequest_DataValidationError{} - -// Validate checks the field values on CreateTokenRequest_Data 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 *CreateTokenRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CreateTokenRequest_Data 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 -// CreateTokenRequest_DataMultiError, or nil if none found. -func (m *CreateTokenRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *CreateTokenRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for UserId - - if len(errors) > 0 { - return CreateTokenRequest_DataMultiError(errors) - } - - return nil -} - -// CreateTokenRequest_DataMultiError is an error wrapping multiple validation -// errors returned by CreateTokenRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type CreateTokenRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CreateTokenRequest_DataMultiError) 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 CreateTokenRequest_DataMultiError) AllErrors() []error { return m } - -// CreateTokenRequest_DataValidationError is the validation error returned by -// CreateTokenRequest_Data.Validate if the designated constraints aren't met. -type CreateTokenRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CreateTokenRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CreateTokenRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CreateTokenRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CreateTokenRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CreateTokenRequest_DataValidationError) ErrorName() string { - return "CreateTokenRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e CreateTokenRequest_DataValidationError) 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 %sCreateTokenRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CreateTokenRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CreateTokenRequest_DataValidationError{} - -// Validate checks the field values on DestroyTokenRequest_Data 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 *DestroyTokenRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on DestroyTokenRequest_Data 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 -// DestroyTokenRequest_DataMultiError, or nil if none found. -func (m *DestroyTokenRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *DestroyTokenRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - if len(errors) > 0 { - return DestroyTokenRequest_DataMultiError(errors) - } - - return nil -} - -// DestroyTokenRequest_DataMultiError is an error wrapping multiple validation -// errors returned by DestroyTokenRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type DestroyTokenRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m DestroyTokenRequest_DataMultiError) 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 DestroyTokenRequest_DataMultiError) AllErrors() []error { return m } - -// DestroyTokenRequest_DataValidationError is the validation error returned by -// DestroyTokenRequest_Data.Validate if the designated constraints aren't met. -type DestroyTokenRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e DestroyTokenRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e DestroyTokenRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e DestroyTokenRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e DestroyTokenRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e DestroyTokenRequest_DataValidationError) ErrorName() string { - return "DestroyTokenRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e DestroyTokenRequest_DataValidationError) 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 %sDestroyTokenRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = DestroyTokenRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = DestroyTokenRequest_DataValidationError{} - -// Validate checks the field values on AuthenticateRequest_Data 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 *AuthenticateRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on AuthenticateRequest_Data 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 -// AuthenticateRequest_DataMultiError, or nil if none found. -func (m *AuthenticateRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *AuthenticateRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - // no validation rules for Path - - // no validation rules for Method - - // no validation rules for Operation - - if len(errors) > 0 { - return AuthenticateRequest_DataMultiError(errors) - } - - return nil -} - -// AuthenticateRequest_DataMultiError is an error wrapping multiple validation -// errors returned by AuthenticateRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type AuthenticateRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m AuthenticateRequest_DataMultiError) 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 AuthenticateRequest_DataMultiError) AllErrors() []error { return m } - -// AuthenticateRequest_DataValidationError is the validation error returned by -// AuthenticateRequest_Data.Validate if the designated constraints aren't met. -type AuthenticateRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e AuthenticateRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e AuthenticateRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e AuthenticateRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e AuthenticateRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e AuthenticateRequest_DataValidationError) ErrorName() string { - return "AuthenticateRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e AuthenticateRequest_DataValidationError) 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 %sAuthenticateRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = AuthenticateRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = AuthenticateRequest_DataValidationError{} diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index e2e5322b..b475b4a8 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -12,6 +12,7 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" io "io" ) @@ -28,114 +29,82 @@ var ( _ = codes.Unimplemented ) -const AuthServiceAuthLogoutBridgeOperation = "/api.v1.services.auth.AuthService/AuthLogout" -const AuthServiceAuthenticateBridgeOperation = "/api.v1.services.auth.AuthService/Authenticate" -const AuthServiceCreateTokenBridgeOperation = "/api.v1.services.auth.AuthService/CreateToken" -const AuthServiceDestroyTokenBridgeOperation = "/api.v1.services.auth.AuthService/DestroyToken" -const AuthServiceListAuthResourcesBridgeOperation = "/api.v1.services.auth.AuthService/ListAuthResources" -const AuthServiceValidateTokenBridgeOperation = "/api.v1.services.auth.AuthService/ValidateToken" - -type AuthServiceBridgeServer interface { - // AuthLogout logs out a user. - AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) - // Authenticate authenticates a user. - Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) - // CreateToken generates a new JWT token for the given user. - CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) - // DestroyToken invalidates a JWT token. - DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) - // ListAuthResources returns a list of Auths. - ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) - // ValidateToken verifies the validity of a JWT token. - ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) -} - -type AuthServiceHooker interface { - AuthServiceAuthLogoutHooker - AuthServiceAuthenticateHooker - AuthServiceCreateTokenHooker - AuthServiceDestroyTokenHooker - AuthServiceListAuthResourcesHooker - AuthServiceValidateTokenHooker -} - -type AuthServiceHookedBridger interface { - AuthServiceHooker - AuthServiceBridgeServer -} -type AuthServiceAuthLogoutHooker interface { - PrepareAuthLogout(http.Context, *AuthLogoutRequest) (context.Context, error) - CompleteAuthLogout(http.Context, *AuthLogoutRequest, *AuthLogoutResponse) error -} -type AuthServiceAuthenticateHooker interface { - PrepareAuthenticate(http.Context, *AuthenticateRequest) (context.Context, error) - CompleteAuthenticate(http.Context, *AuthenticateRequest, *AuthenticateResponse) error -} -type AuthServiceCreateTokenHooker interface { - PrepareCreateToken(http.Context, *CreateTokenRequest) (context.Context, error) - CompleteCreateToken(http.Context, *CreateTokenRequest, *CreateTokenResponse) error -} -type AuthServiceDestroyTokenHooker interface { - PrepareDestroyToken(http.Context, *DestroyTokenRequest) (context.Context, error) - CompleteDestroyToken(http.Context, *DestroyTokenRequest, *DestroyTokenResponse) error -} -type AuthServiceListAuthResourcesHooker interface { - PrepareListAuthResources(http.Context, *ListAuthResourcesRequest) (context.Context, error) - CompleteListAuthResources(http.Context, *ListAuthResourcesRequest, *ListAuthResourcesResponse) error -} -type AuthServiceValidateTokenHooker interface { - PrepareValidateToken(http.Context, *ValidateTokenRequest) (context.Context, error) - CompleteValidateToken(http.Context, *ValidateTokenRequest, *ValidateTokenResponse) error -} - -func RegisterAuthServiceBridgeServer(s *http.Server, srv AuthServiceHookedBridger) { - r := s.Route("/") - r.GET("/auth/resources", _AuthService_ListAuthResources0_Bridge_Handler(srv)) - r.POST("/auth/token", _AuthService_CreateToken0_Bridge_Handler(srv)) - r.GET("/auth/validate", _AuthService_ValidateToken0_Bridge_Handler(srv)) - r.POST("/auth/destroy", _AuthService_DestroyToken0_Bridge_Handler(srv)) - r.POST("/auth/authenticate", _AuthService_Authenticate0_Bridge_Handler(srv)) - r.POST("/auth/logout", _AuthService_AuthLogout0_Bridge_Handler(srv)) +const AuthGetCaptchaBridgeOperation = "/api.v1.services.auth.Auth/GetCaptcha" +const AuthLoginBridgeOperation = "/api.v1.services.auth.Auth/Login" +const AuthLogoutBridgeOperation = "/api.v1.services.auth.Auth/Logout" +const AuthRefreshTokenBridgeOperation = "/api.v1.services.auth.Auth/RefreshToken" +const AuthRegisterBridgeOperation = "/api.v1.services.auth.Auth/Register" + +type AuthBridgeServer interface { + // GetCaptcha generates a new captcha. + GetCaptcha(context.Context, *GetCaptchaRequest) (*GetCaptchaResponse, error) + // Login authenticates a user and returns a token pair. + Login(context.Context, *LoginRequest) (*LoginResponse, error) + // Logout invalidates the user's session. + Logout(context.Context, *LogoutRequest) (*emptypb.Empty, error) + // RefreshToken provides a new access token. + RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) + // Register creates a new user account. + Register(context.Context, *RegisterRequest) (*emptypb.Empty, error) } -func _AuthService_ListAuthResources0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListAuthResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceListAuthResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) - }) +type AuthHooker interface { + AuthGetCaptchaHooker + AuthLoginHooker + AuthLogoutHooker + AuthRefreshTokenHooker + AuthRegisterHooker +} - newctx, err := srv.PrepareListAuthResources(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListAuthResources(ctx, &in, out.(*ListAuthResourcesResponse)) - } +type AuthHookedBridger interface { + AuthHooker + AuthBridgeServer +} +type AuthGetCaptchaHooker interface { + PrepareGetCaptcha(http.Context, *GetCaptchaRequest) (context.Context, error) + CompleteGetCaptcha(http.Context, *GetCaptchaRequest, *GetCaptchaResponse) error +} +type AuthLoginHooker interface { + PrepareLogin(http.Context, *LoginRequest) (context.Context, error) + CompleteLogin(http.Context, *LoginRequest, *LoginResponse) error +} +type AuthLogoutHooker interface { + PrepareLogout(http.Context, *LogoutRequest) (context.Context, error) + CompleteLogout(http.Context, *LogoutRequest, *emptypb.Empty) error +} +type AuthRefreshTokenHooker interface { + PrepareRefreshToken(http.Context, *RefreshTokenRequest) (context.Context, error) + CompleteRefreshToken(http.Context, *RefreshTokenRequest, *RefreshTokenResponse) error +} +type AuthRegisterHooker interface { + PrepareRegister(http.Context, *RegisterRequest) (context.Context, error) + CompleteRegister(http.Context, *RegisterRequest, *emptypb.Empty) error } -func _AuthService_CreateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { +func RegisterAuthBridgeServer(s *http.Server, srv AuthHookedBridger) { + r := s.Route("/") + r.POST("/api/v1/auth/login", _Auth_Login0_Bridge_Handler(srv)) + r.POST("/api/v1/auth/register", _Auth_Register0_Bridge_Handler(srv)) + r.POST("/api/v1/auth/logout", _Auth_Logout0_Bridge_Handler(srv)) + r.POST("/api/v1/auth/token", _Auth_RefreshToken0_Bridge_Handler(srv)) + r.GET("/api/v1/captcha", _Auth_GetCaptcha0_Bridge_Handler(srv)) +} + +func _Auth_Login0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { - var in CreateTokenRequest - if err := ctx.Bind(&in.Data); err != nil { + var in LoginRequest + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthServiceCreateToken) + http.SetOperation(ctx, OperationAuthLogin) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateToken(ctx, req.(*CreateTokenRequest)) + return srv.Login(ctx, req.(*LoginRequest)) }) - newctx, err := srv.PrepareCreateToken(ctx, &in) + newctx, err := srv.PrepareLogin(ctx, &in) if err != nil { return err } @@ -143,22 +112,25 @@ func _AuthService_CreateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func if err != nil { return err } - return srv.CompleteCreateToken(ctx, &in, out.(*CreateTokenResponse)) + return srv.CompleteLogin(ctx, &in, out.(*LoginResponse)) } } -func _AuthService_ValidateToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { +func _Auth_Register0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { - var in ValidateTokenRequest + var in RegisterRequest + if err := ctx.Bind(&in); err != nil { + return err + } if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthServiceValidateToken) + http.SetOperation(ctx, OperationAuthRegister) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ValidateToken(ctx, req.(*ValidateTokenRequest)) + return srv.Register(ctx, req.(*RegisterRequest)) }) - newctx, err := srv.PrepareValidateToken(ctx, &in) + newctx, err := srv.PrepareRegister(ctx, &in) if err != nil { return err } @@ -166,25 +138,25 @@ func _AuthService_ValidateToken0_Bridge_Handler(srv AuthServiceHookedBridger) fu if err != nil { return err } - return srv.CompleteValidateToken(ctx, &in, out.(*ValidateTokenResponse)) + return srv.CompleteRegister(ctx, &in, out.(*emptypb.Empty)) } } -func _AuthService_DestroyToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { +func _Auth_Logout0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { - var in DestroyTokenRequest - if err := ctx.Bind(&in.Data); err != nil { + var in LogoutRequest + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthServiceDestroyToken) + http.SetOperation(ctx, OperationAuthLogout) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DestroyToken(ctx, req.(*DestroyTokenRequest)) + return srv.Logout(ctx, req.(*LogoutRequest)) }) - newctx, err := srv.PrepareDestroyToken(ctx, &in) + newctx, err := srv.PrepareLogout(ctx, &in) if err != nil { return err } @@ -192,25 +164,25 @@ func _AuthService_DestroyToken0_Bridge_Handler(srv AuthServiceHookedBridger) fun if err != nil { return err } - return srv.CompleteDestroyToken(ctx, &in, out.(*DestroyTokenResponse)) + return srv.CompleteLogout(ctx, &in, out.(*emptypb.Empty)) } } -func _AuthService_Authenticate0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { +func _Auth_RefreshToken0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { - var in AuthenticateRequest - if err := ctx.Bind(&in.Data); err != nil { + var in RefreshTokenRequest + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthServiceAuthenticate) + http.SetOperation(ctx, OperationAuthRefreshToken) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Authenticate(ctx, req.(*AuthenticateRequest)) + return srv.RefreshToken(ctx, req.(*RefreshTokenRequest)) }) - newctx, err := srv.PrepareAuthenticate(ctx, &in) + newctx, err := srv.PrepareRefreshToken(ctx, &in) if err != nil { return err } @@ -218,25 +190,22 @@ func _AuthService_Authenticate0_Bridge_Handler(srv AuthServiceHookedBridger) fun if err != nil { return err } - return srv.CompleteAuthenticate(ctx, &in, out.(*AuthenticateResponse)) + return srv.CompleteRefreshToken(ctx, &in, out.(*RefreshTokenResponse)) } } -func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { +func _Auth_GetCaptcha0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { - var in AuthLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } + var in GetCaptchaRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthServiceAuthLogout) + http.SetOperation(ctx, OperationAuthGetCaptcha) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.AuthLogout(ctx, req.(*AuthLogoutRequest)) + return srv.GetCaptcha(ctx, req.(*GetCaptchaRequest)) }) - newctx, err := srv.PrepareAuthLogout(ctx, &in) + newctx, err := srv.PrepareGetCaptcha(ctx, &in) if err != nil { return err } @@ -244,207 +213,183 @@ func _AuthService_AuthLogout0_Bridge_Handler(srv AuthServiceHookedBridger) func( if err != nil { return err } - return srv.CompleteAuthLogout(ctx, &in, out.(*AuthLogoutResponse)) + return srv.CompleteGetCaptcha(ctx, &in, out.(*GetCaptchaResponse)) } } -// UnimplementedAuthServiceHooked must be embedded to have +// UnimplementedAuthHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedAuthServiceHooked struct{} +type UnimplementedAuthHooked struct{} -func (UnimplementedAuthServiceHooked) PrepareAuthLogout(ctx http.Context, in *AuthLogoutRequest) (context.Context, error) { +func (UnimplementedAuthHooked) PrepareGetCaptcha(ctx http.Context, in *GetCaptchaRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) CompleteAuthLogout(ctx http.Context, in *AuthLogoutRequest, out *AuthLogoutResponse) error { +func (UnimplementedAuthHooked) CompleteGetCaptcha(ctx http.Context, in *GetCaptchaRequest, out *GetCaptchaResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceHooked) PrepareAuthenticate(ctx http.Context, in *AuthenticateRequest) (context.Context, error) { +func (UnimplementedAuthHooked) PrepareLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) CompleteAuthenticate(ctx http.Context, in *AuthenticateRequest, out *AuthenticateResponse) error { +func (UnimplementedAuthHooked) CompleteLogin(ctx http.Context, in *LoginRequest, out *LoginResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceHooked) PrepareCreateToken(ctx http.Context, in *CreateTokenRequest) (context.Context, error) { +func (UnimplementedAuthHooked) PrepareLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) CompleteCreateToken(ctx http.Context, in *CreateTokenRequest, out *CreateTokenResponse) error { +func (UnimplementedAuthHooked) CompleteLogout(ctx http.Context, in *LogoutRequest, out *emptypb.Empty) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceHooked) PrepareDestroyToken(ctx http.Context, in *DestroyTokenRequest) (context.Context, error) { +func (UnimplementedAuthHooked) PrepareRefreshToken(ctx http.Context, in *RefreshTokenRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) CompleteDestroyToken(ctx http.Context, in *DestroyTokenRequest, out *DestroyTokenResponse) error { +func (UnimplementedAuthHooked) CompleteRefreshToken(ctx http.Context, in *RefreshTokenRequest, out *RefreshTokenResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceHooked) PrepareListAuthResources(ctx http.Context, in *ListAuthResourcesRequest) (context.Context, error) { +func (UnimplementedAuthHooked) PrepareRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthServiceHooked) CompleteListAuthResources(ctx http.Context, in *ListAuthResourcesRequest, out *ListAuthResourcesResponse) error { +func (UnimplementedAuthHooked) CompleteRegister(ctx http.Context, in *RegisterRequest, out *emptypb.Empty) error { return ctx.Result(200, out) } -func (UnimplementedAuthServiceHooked) PrepareValidateToken(ctx http.Context, in *ValidateTokenRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedAuthServiceHooked) CompleteValidateToken(ctx http.Context, in *ValidateTokenRequest, out *ValidateTokenResponse) error { - return ctx.Result(200, out) -} - -func WithAuthServiceHook(h AuthServiceHooker) func(AuthServiceBridgeServer) AuthServiceHookedBridger { - return func(srv AuthServiceBridgeServer) AuthServiceHookedBridger { - return AuthServiceHookedBridge{AuthServiceBridgeServer: srv, AuthServiceHooker: h} +func WithAuthHook(h AuthHooker) func(AuthBridgeServer) AuthHookedBridger { + return func(srv AuthBridgeServer) AuthHookedBridger { + return AuthHookedBridge{AuthBridgeServer: srv, AuthHooker: h} } } -// AuthServiceHookedBridge is a bridge between the HTTP and gRPC implementations of AuthService. -// It implements the HTTP and gRPC implementations of AuthService. +// AuthHookedBridge is a bridge between the HTTP and gRPC implementations of Auth. +// It implements the HTTP and gRPC implementations of Auth. // It forwards requests and responses between the two implementations. -type AuthServiceHookedBridge struct { - AuthServiceBridgeServer - AuthServiceHooker -} - -type AuthServiceHTTPBridgeImpl struct { - client AuthServiceHTTPClient -} - -func NewAuthServiceHTTPBridge(client *http.Client) AuthServiceHTTPServer { - return &AuthServiceHTTPBridgeImpl{client: NewAuthServiceHTTPClient(client)} +type AuthHookedBridge struct { + AuthBridgeServer + AuthHooker } -func (c *AuthServiceHTTPBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { - return c.client.AuthLogout(ctx, in) +type AuthHTTPBridgeImpl struct { + client AuthHTTPClient } -func (c *AuthServiceHTTPBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { - return c.client.Authenticate(ctx, in) +func NewAuthHTTPBridge(client *http.Client) AuthHTTPServer { + return &AuthHTTPBridgeImpl{client: NewAuthHTTPClient(client)} } -func (c *AuthServiceHTTPBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { - return c.client.CreateToken(ctx, in) +func (c *AuthHTTPBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) } -func (c *AuthServiceHTTPBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { - return c.client.DestroyToken(ctx, in) +func (c *AuthHTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) } -func (c *AuthServiceHTTPBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { - return c.client.ListAuthResources(ctx, in) +func (c *AuthHTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*emptypb.Empty, error) { + return c.client.Logout(ctx, in) } -func (c *AuthServiceHTTPBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { - return c.client.ValidateToken(ctx, in) +func (c *AuthHTTPBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { + return c.client.RefreshToken(ctx, in) } -type AuthServiceBridgeImpl struct { - client AuthServiceClient +func (c *AuthHTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*emptypb.Empty, error) { + return c.client.Register(ctx, in) } -func NewAuthServiceBridge(client grpc.ClientConnInterface) AuthServiceServer { - return &AuthServiceBridgeImpl{client: NewAuthServiceClient(client)} +type AuthBridgeImpl struct { + client AuthClient } -func (c *AuthServiceBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { - return c.client.AuthLogout(ctx, in) +func NewAuthBridge(client grpc.ClientConnInterface) AuthServer { + return &AuthBridgeImpl{client: NewAuthClient(client)} } -func (c *AuthServiceBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { - return c.client.Authenticate(ctx, in) +func (c *AuthBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) } -func (c *AuthServiceBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { - return c.client.CreateToken(ctx, in) +func (c *AuthBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) } -func (c *AuthServiceBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { - return c.client.DestroyToken(ctx, in) +func (c *AuthBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*emptypb.Empty, error) { + return c.client.Logout(ctx, in) } -func (c *AuthServiceBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { - return c.client.ListAuthResources(ctx, in) +func (c *AuthBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { + return c.client.RefreshToken(ctx, in) } -func (c *AuthServiceBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { - return c.client.ValidateToken(ctx, in) +func (c *AuthBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*emptypb.Empty, error) { + return c.client.Register(ctx, in) } -func (c *AuthServiceBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} - -type AuthServiceGRPC2HTTPBridgeImpl struct { - client AuthServiceClient -} - -func NewAuthServiceGRPC2HTTP(client grpc.ClientConnInterface) AuthServiceHTTPServer { - return &AuthServiceGRPC2HTTPBridgeImpl{client: NewAuthServiceClient(client)} -} +func (c *AuthBridgeImpl) mustEmbedUnimplementedAuthServer() {} -func (c *AuthServiceGRPC2HTTPBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { - return c.client.AuthLogout(ctx, in) +type AuthGRPC2HTTPBridgeImpl struct { + client AuthClient } -func (c *AuthServiceGRPC2HTTPBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { - return c.client.Authenticate(ctx, in) +func NewAuthGRPC2HTTP(client grpc.ClientConnInterface) AuthHTTPServer { + return &AuthGRPC2HTTPBridgeImpl{client: NewAuthClient(client)} } -func (c *AuthServiceGRPC2HTTPBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { - return c.client.CreateToken(ctx, in) +func (c *AuthGRPC2HTTPBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) } -func (c *AuthServiceGRPC2HTTPBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { - return c.client.DestroyToken(ctx, in) +func (c *AuthGRPC2HTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) } -func (c *AuthServiceGRPC2HTTPBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { - return c.client.ListAuthResources(ctx, in) +func (c *AuthGRPC2HTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*emptypb.Empty, error) { + return c.client.Logout(ctx, in) } -func (c *AuthServiceGRPC2HTTPBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { - return c.client.ValidateToken(ctx, in) +func (c *AuthGRPC2HTTPBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { + return c.client.RefreshToken(ctx, in) } -type AuthServiceHTTP2GRPCBridgeImpl struct { - client AuthServiceHTTPClient +func (c *AuthGRPC2HTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*emptypb.Empty, error) { + return c.client.Register(ctx, in) } -func NewAuthServiceHTTP2GRPC(client *http.Client) AuthServiceServer { - return &AuthServiceHTTP2GRPCBridgeImpl{client: NewAuthServiceHTTPClient(client)} +type AuthHTTP2GRPCBridgeImpl struct { + client AuthHTTPClient } -func (c *AuthServiceHTTP2GRPCBridgeImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest) (*AuthLogoutResponse, error) { - return c.client.AuthLogout(ctx, in) +func NewAuthHTTP2GRPC(client *http.Client) AuthServer { + return &AuthHTTP2GRPCBridgeImpl{client: NewAuthHTTPClient(client)} } -func (c *AuthServiceHTTP2GRPCBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { - return c.client.Authenticate(ctx, in) +func (c *AuthHTTP2GRPCBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) } -func (c *AuthServiceHTTP2GRPCBridgeImpl) CreateToken(ctx context.Context, in *CreateTokenRequest) (*CreateTokenResponse, error) { - return c.client.CreateToken(ctx, in) +func (c *AuthHTTP2GRPCBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) } -func (c *AuthServiceHTTP2GRPCBridgeImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest) (*DestroyTokenResponse, error) { - return c.client.DestroyToken(ctx, in) +func (c *AuthHTTP2GRPCBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*emptypb.Empty, error) { + return c.client.Logout(ctx, in) } -func (c *AuthServiceHTTP2GRPCBridgeImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { - return c.client.ListAuthResources(ctx, in) +func (c *AuthHTTP2GRPCBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { + return c.client.RefreshToken(ctx, in) } -func (c *AuthServiceHTTP2GRPCBridgeImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest) (*ValidateTokenResponse, error) { - return c.client.ValidateToken(ctx, in) +func (c *AuthHTTP2GRPCBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*emptypb.Empty, error) { + return c.client.Register(ctx, in) } -func (c *AuthServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} +func (c *AuthHTTP2GRPCBridgeImpl) mustEmbedUnimplementedAuthServer() {} diff --git a/api/v1/services/auth/auth_grpc.pb.go b/api/v1/services/auth/auth_grpc.pb.go index fcac5f0b..bbd6fba9 100644 --- a/api/v1/services/auth/auth_grpc.pb.go +++ b/api/v1/services/auth/auth_grpc.pb.go @@ -11,6 +11,7 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -19,303 +20,309 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - AuthService_ListAuthResources_FullMethodName = "/api.v1.services.auth.AuthService/ListAuthResources" - AuthService_CreateToken_FullMethodName = "/api.v1.services.auth.AuthService/CreateToken" - AuthService_ValidateToken_FullMethodName = "/api.v1.services.auth.AuthService/ValidateToken" - AuthService_DestroyToken_FullMethodName = "/api.v1.services.auth.AuthService/DestroyToken" - AuthService_Authenticate_FullMethodName = "/api.v1.services.auth.AuthService/Authenticate" - AuthService_AuthLogout_FullMethodName = "/api.v1.services.auth.AuthService/AuthLogout" + Auth_Login_FullMethodName = "/api.v1.services.auth.Auth/Login" + Auth_Register_FullMethodName = "/api.v1.services.auth.Auth/Register" + Auth_Logout_FullMethodName = "/api.v1.services.auth.Auth/Logout" + Auth_RefreshToken_FullMethodName = "/api.v1.services.auth.Auth/RefreshToken" + Auth_GetCaptcha_FullMethodName = "/api.v1.services.auth.Auth/GetCaptcha" + Auth_Authenticate_FullMethodName = "/api.v1.services.auth.Auth/Authenticate" ) -// AuthServiceClient is the client API for AuthService service. +// AuthClient is the client API for Auth service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type AuthServiceClient interface { - // ListAuthResources returns a list of Auths. - ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...grpc.CallOption) (*ListAuthResourcesResponse, error) - // CreateToken generates a new JWT token for the given user. - CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...grpc.CallOption) (*CreateTokenResponse, error) - // ValidateToken verifies the validity of a JWT token. - ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*ValidateTokenResponse, error) - // DestroyToken invalidates a JWT token. - DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...grpc.CallOption) (*DestroyTokenResponse, error) - // Authenticate authenticates a user. +// +// Service Auth provides APIs for the authentication lifecycle. +type AuthClient interface { + // Login authenticates a user and returns a token pair. + Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) + // Register creates a new user account. + Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + // Logout invalidates the user's session. + Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + // RefreshToken provides a new access token. + RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error) + // GetCaptcha generates a new captcha. + GetCaptcha(ctx context.Context, in *GetCaptchaRequest, opts ...grpc.CallOption) (*GetCaptchaResponse, error) + // Authenticate is for internal use by the gateway to verify user access via gRPC. + // It does not have an HTTP binding. Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) - // AuthLogout logs out a user. - AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...grpc.CallOption) (*AuthLogoutResponse, error) } -type authServiceClient struct { +type authClient struct { cc grpc.ClientConnInterface } -func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { - return &authServiceClient{cc} +func NewAuthClient(cc grpc.ClientConnInterface) AuthClient { + return &authClient{cc} } -func (c *authServiceClient) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...grpc.CallOption) (*ListAuthResourcesResponse, error) { +func (c *authClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListAuthResourcesResponse) - err := c.cc.Invoke(ctx, AuthService_ListAuthResources_FullMethodName, in, out, cOpts...) + out := new(LoginResponse) + err := c.cc.Invoke(ctx, Auth_Login_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authServiceClient) CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...grpc.CallOption) (*CreateTokenResponse, error) { +func (c *authClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CreateTokenResponse) - err := c.cc.Invoke(ctx, AuthService_CreateToken_FullMethodName, in, out, cOpts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Auth_Register_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authServiceClient) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*ValidateTokenResponse, error) { +func (c *authClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ValidateTokenResponse) - err := c.cc.Invoke(ctx, AuthService_ValidateToken_FullMethodName, in, out, cOpts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Auth_Logout_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authServiceClient) DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...grpc.CallOption) (*DestroyTokenResponse, error) { +func (c *authClient) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(DestroyTokenResponse) - err := c.cc.Invoke(ctx, AuthService_DestroyToken_FullMethodName, in, out, cOpts...) + out := new(RefreshTokenResponse) + err := c.cc.Invoke(ctx, Auth_RefreshToken_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authServiceClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) { +func (c *authClient) GetCaptcha(ctx context.Context, in *GetCaptchaRequest, opts ...grpc.CallOption) (*GetCaptchaResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(AuthenticateResponse) - err := c.cc.Invoke(ctx, AuthService_Authenticate_FullMethodName, in, out, cOpts...) + out := new(GetCaptchaResponse) + err := c.cc.Invoke(ctx, Auth_GetCaptcha_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authServiceClient) AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...grpc.CallOption) (*AuthLogoutResponse, error) { +func (c *authClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(AuthLogoutResponse) - err := c.cc.Invoke(ctx, AuthService_AuthLogout_FullMethodName, in, out, cOpts...) + out := new(AuthenticateResponse) + err := c.cc.Invoke(ctx, Auth_Authenticate_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -// AuthServiceServer is the server API for AuthService service. -// All implementations must embed UnimplementedAuthServiceServer +// AuthServer is the server API for Auth service. +// All implementations must embed UnimplementedAuthServer // for forward compatibility. -type AuthServiceServer interface { - // ListAuthResources returns a list of Auths. - ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) - // CreateToken generates a new JWT token for the given user. - CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) - // ValidateToken verifies the validity of a JWT token. - ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) - // DestroyToken invalidates a JWT token. - DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) - // Authenticate authenticates a user. +// +// Service Auth provides APIs for the authentication lifecycle. +type AuthServer interface { + // Login authenticates a user and returns a token pair. + Login(context.Context, *LoginRequest) (*LoginResponse, error) + // Register creates a new user account. + Register(context.Context, *RegisterRequest) (*emptypb.Empty, error) + // Logout invalidates the user's session. + Logout(context.Context, *LogoutRequest) (*emptypb.Empty, error) + // RefreshToken provides a new access token. + RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) + // GetCaptcha generates a new captcha. + GetCaptcha(context.Context, *GetCaptchaRequest) (*GetCaptchaResponse, error) + // Authenticate is for internal use by the gateway to verify user access via gRPC. + // It does not have an HTTP binding. Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) - // AuthLogout logs out a user. - AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) - mustEmbedUnimplementedAuthServiceServer() + mustEmbedUnimplementedAuthServer() } -// UnimplementedAuthServiceServer must be embedded to have +// UnimplementedAuthServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedAuthServiceServer struct{} +type UnimplementedAuthServer struct{} -func (UnimplementedAuthServiceServer) ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListAuthResources not implemented") +func (UnimplementedAuthServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") } -func (UnimplementedAuthServiceServer) CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateToken not implemented") +func (UnimplementedAuthServer) Register(context.Context, *RegisterRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") } -func (UnimplementedAuthServiceServer) ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ValidateToken not implemented") +func (UnimplementedAuthServer) Logout(context.Context, *LogoutRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented") } -func (UnimplementedAuthServiceServer) DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DestroyToken not implemented") +func (UnimplementedAuthServer) RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RefreshToken not implemented") } -func (UnimplementedAuthServiceServer) Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") +func (UnimplementedAuthServer) GetCaptcha(context.Context, *GetCaptchaRequest) (*GetCaptchaResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCaptcha not implemented") } -func (UnimplementedAuthServiceServer) AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AuthLogout not implemented") +func (UnimplementedAuthServer) Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") } -func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} -func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} +func (UnimplementedAuthServer) mustEmbedUnimplementedAuthServer() {} +func (UnimplementedAuthServer) testEmbeddedByValue() {} -// UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to AuthServiceServer will +// UnsafeAuthServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AuthServer will // result in compilation errors. -type UnsafeAuthServiceServer interface { - mustEmbedUnimplementedAuthServiceServer() +type UnsafeAuthServer interface { + mustEmbedUnimplementedAuthServer() } -func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { - // If the following call pancis, it indicates UnimplementedAuthServiceServer was +func RegisterAuthServer(s grpc.ServiceRegistrar, srv AuthServer) { + // If the following call pancis, it indicates UnimplementedAuthServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&AuthService_ServiceDesc, srv) + s.RegisterService(&Auth_ServiceDesc, srv) } -func _AuthService_ListAuthResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListAuthResourcesRequest) +func _Auth_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LoginRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServiceServer).ListAuthResources(ctx, in) + return srv.(AuthServer).Login(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: AuthService_ListAuthResources_FullMethodName, + FullMethod: Auth_Login_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) + return srv.(AuthServer).Login(ctx, req.(*LoginRequest)) } return interceptor(ctx, in, info, handler) } -func _AuthService_CreateToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateTokenRequest) +func _Auth_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RegisterRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServiceServer).CreateToken(ctx, in) + return srv.(AuthServer).Register(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: AuthService_CreateToken_FullMethodName, + FullMethod: Auth_Register_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).CreateToken(ctx, req.(*CreateTokenRequest)) + return srv.(AuthServer).Register(ctx, req.(*RegisterRequest)) } return interceptor(ctx, in, info, handler) } -func _AuthService_ValidateToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ValidateTokenRequest) +func _Auth_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LogoutRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServiceServer).ValidateToken(ctx, in) + return srv.(AuthServer).Logout(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: AuthService_ValidateToken_FullMethodName, + FullMethod: Auth_Logout_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).ValidateToken(ctx, req.(*ValidateTokenRequest)) + return srv.(AuthServer).Logout(ctx, req.(*LogoutRequest)) } return interceptor(ctx, in, info, handler) } -func _AuthService_DestroyToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DestroyTokenRequest) +func _Auth_RefreshToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RefreshTokenRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServiceServer).DestroyToken(ctx, in) + return srv.(AuthServer).RefreshToken(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: AuthService_DestroyToken_FullMethodName, + FullMethod: Auth_RefreshToken_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).DestroyToken(ctx, req.(*DestroyTokenRequest)) + return srv.(AuthServer).RefreshToken(ctx, req.(*RefreshTokenRequest)) } return interceptor(ctx, in, info, handler) } -func _AuthService_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AuthenticateRequest) +func _Auth_GetCaptcha_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCaptchaRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServiceServer).Authenticate(ctx, in) + return srv.(AuthServer).GetCaptcha(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: AuthService_Authenticate_FullMethodName, + FullMethod: Auth_GetCaptcha_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).Authenticate(ctx, req.(*AuthenticateRequest)) + return srv.(AuthServer).GetCaptcha(ctx, req.(*GetCaptchaRequest)) } return interceptor(ctx, in, info, handler) } -func _AuthService_AuthLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(AuthLogoutRequest) +func _Auth_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AuthenticateRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServiceServer).AuthLogout(ctx, in) + return srv.(AuthServer).Authenticate(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: AuthService_AuthLogout_FullMethodName, + FullMethod: Auth_Authenticate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).AuthLogout(ctx, req.(*AuthLogoutRequest)) + return srv.(AuthServer).Authenticate(ctx, req.(*AuthenticateRequest)) } return interceptor(ctx, in, info, handler) } -// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service. +// Auth_ServiceDesc is the grpc.ServiceDesc for Auth service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var AuthService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.auth.AuthService", - HandlerType: (*AuthServiceServer)(nil), +var Auth_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.auth.Auth", + HandlerType: (*AuthServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "ListAuthResources", - Handler: _AuthService_ListAuthResources_Handler, + MethodName: "Login", + Handler: _Auth_Login_Handler, }, { - MethodName: "CreateToken", - Handler: _AuthService_CreateToken_Handler, + MethodName: "Register", + Handler: _Auth_Register_Handler, }, { - MethodName: "ValidateToken", - Handler: _AuthService_ValidateToken_Handler, + MethodName: "Logout", + Handler: _Auth_Logout_Handler, }, { - MethodName: "DestroyToken", - Handler: _AuthService_DestroyToken_Handler, + MethodName: "RefreshToken", + Handler: _Auth_RefreshToken_Handler, }, { - MethodName: "Authenticate", - Handler: _AuthService_Authenticate_Handler, + MethodName: "GetCaptcha", + Handler: _Auth_GetCaptcha_Handler, }, { - MethodName: "AuthLogout", - Handler: _AuthService_AuthLogout_Handler, + MethodName: "Authenticate", + Handler: _Auth_Authenticate_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go index cd009a40..c32e8a71 100644 --- a/api/v1/services/auth/auth_http.pb.go +++ b/api/v1/services/auth/auth_http.pb.go @@ -10,6 +10,7 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" binding "github.com/go-kratos/kratos/v2/transport/http/binding" + emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -19,265 +20,226 @@ var _ = binding.EncodeURL const _ = http.SupportPackageIsVersion1 -const OperationAuthServiceAuthLogout = "/api.v1.services.auth.AuthService/AuthLogout" -const OperationAuthServiceAuthenticate = "/api.v1.services.auth.AuthService/Authenticate" -const OperationAuthServiceCreateToken = "/api.v1.services.auth.AuthService/CreateToken" -const OperationAuthServiceDestroyToken = "/api.v1.services.auth.AuthService/DestroyToken" -const OperationAuthServiceListAuthResources = "/api.v1.services.auth.AuthService/ListAuthResources" -const OperationAuthServiceValidateToken = "/api.v1.services.auth.AuthService/ValidateToken" - -type AuthServiceHTTPServer interface { - // AuthLogout AuthLogout logs out a user. - AuthLogout(context.Context, *AuthLogoutRequest) (*AuthLogoutResponse, error) - // Authenticate Authenticate authenticates a user. - Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) - // CreateToken CreateToken generates a new JWT token for the given user. - CreateToken(context.Context, *CreateTokenRequest) (*CreateTokenResponse, error) - // DestroyToken DestroyToken invalidates a JWT token. - DestroyToken(context.Context, *DestroyTokenRequest) (*DestroyTokenResponse, error) - // ListAuthResources ListAuthResources returns a list of Auths. - ListAuthResources(context.Context, *ListAuthResourcesRequest) (*ListAuthResourcesResponse, error) - // ValidateToken ValidateToken verifies the validity of a JWT token. - ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) -} - -func RegisterAuthServiceHTTPServer(s *http.Server, srv AuthServiceHTTPServer) { +const OperationAuthGetCaptcha = "/api.v1.services.auth.Auth/GetCaptcha" +const OperationAuthLogin = "/api.v1.services.auth.Auth/Login" +const OperationAuthLogout = "/api.v1.services.auth.Auth/Logout" +const OperationAuthRefreshToken = "/api.v1.services.auth.Auth/RefreshToken" +const OperationAuthRegister = "/api.v1.services.auth.Auth/Register" + +type AuthHTTPServer interface { + // GetCaptcha GetCaptcha generates a new captcha. + GetCaptcha(context.Context, *GetCaptchaRequest) (*GetCaptchaResponse, error) + // Login Login authenticates a user and returns a token pair. + Login(context.Context, *LoginRequest) (*LoginResponse, error) + // Logout Logout invalidates the user's session. + Logout(context.Context, *LogoutRequest) (*emptypb.Empty, error) + // RefreshToken RefreshToken provides a new access token. + RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) + // Register Register creates a new user account. + Register(context.Context, *RegisterRequest) (*emptypb.Empty, error) +} + +func RegisterAuthHTTPServer(s *http.Server, srv AuthHTTPServer) { r := s.Route("/") - r.GET("/auth/resources", _AuthService_ListAuthResources0_HTTP_Handler(srv)) - r.POST("/auth/token", _AuthService_CreateToken0_HTTP_Handler(srv)) - r.GET("/auth/validate", _AuthService_ValidateToken0_HTTP_Handler(srv)) - r.POST("/auth/destroy", _AuthService_DestroyToken0_HTTP_Handler(srv)) - r.POST("/auth/authenticate", _AuthService_Authenticate0_HTTP_Handler(srv)) - r.POST("/auth/logout", _AuthService_AuthLogout0_HTTP_Handler(srv)) -} - -func _AuthService_ListAuthResources0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListAuthResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationAuthServiceListAuthResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListAuthResources(ctx, req.(*ListAuthResourcesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListAuthResourcesResponse) - return ctx.Result(200, reply) - } + r.POST("/api/v1/auth/login", _Auth_Login0_HTTP_Handler(srv)) + r.POST("/api/v1/auth/register", _Auth_Register0_HTTP_Handler(srv)) + r.POST("/api/v1/auth/logout", _Auth_Logout0_HTTP_Handler(srv)) + r.POST("/api/v1/auth/token", _Auth_RefreshToken0_HTTP_Handler(srv)) + r.GET("/api/v1/captcha", _Auth_GetCaptcha0_HTTP_Handler(srv)) } -func _AuthService_CreateToken0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { +func _Auth_Login0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { - var in CreateTokenRequest - if err := ctx.Bind(&in.Data); err != nil { + var in LoginRequest + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthServiceCreateToken) + http.SetOperation(ctx, OperationAuthLogin) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateToken(ctx, req.(*CreateTokenRequest)) + return srv.Login(ctx, req.(*LoginRequest)) }) out, err := h(ctx, &in) if err != nil { return err } - reply := out.(*CreateTokenResponse) + reply := out.(*LoginResponse) return ctx.Result(200, reply) } } -func _AuthService_ValidateToken0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { +func _Auth_Register0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { - var in ValidateTokenRequest + var in RegisterRequest + if err := ctx.Bind(&in); err != nil { + return err + } if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthServiceValidateToken) + http.SetOperation(ctx, OperationAuthRegister) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ValidateToken(ctx, req.(*ValidateTokenRequest)) + return srv.Register(ctx, req.(*RegisterRequest)) }) out, err := h(ctx, &in) if err != nil { return err } - reply := out.(*ValidateTokenResponse) + reply := out.(*emptypb.Empty) return ctx.Result(200, reply) } } -func _AuthService_DestroyToken0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { +func _Auth_Logout0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { - var in DestroyTokenRequest - if err := ctx.Bind(&in.Data); err != nil { + var in LogoutRequest + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthServiceDestroyToken) + http.SetOperation(ctx, OperationAuthLogout) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DestroyToken(ctx, req.(*DestroyTokenRequest)) + return srv.Logout(ctx, req.(*LogoutRequest)) }) out, err := h(ctx, &in) if err != nil { return err } - reply := out.(*DestroyTokenResponse) + reply := out.(*emptypb.Empty) return ctx.Result(200, reply) } } -func _AuthService_Authenticate0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { +func _Auth_RefreshToken0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { - var in AuthenticateRequest - if err := ctx.Bind(&in.Data); err != nil { + var in RefreshTokenRequest + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthServiceAuthenticate) + http.SetOperation(ctx, OperationAuthRefreshToken) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Authenticate(ctx, req.(*AuthenticateRequest)) + return srv.RefreshToken(ctx, req.(*RefreshTokenRequest)) }) out, err := h(ctx, &in) if err != nil { return err } - reply := out.(*AuthenticateResponse) + reply := out.(*RefreshTokenResponse) return ctx.Result(200, reply) } } -func _AuthService_AuthLogout0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { +func _Auth_GetCaptcha0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { - var in AuthLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } + var in GetCaptchaRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthServiceAuthLogout) + http.SetOperation(ctx, OperationAuthGetCaptcha) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.AuthLogout(ctx, req.(*AuthLogoutRequest)) + return srv.GetCaptcha(ctx, req.(*GetCaptchaRequest)) }) out, err := h(ctx, &in) if err != nil { return err } - reply := out.(*AuthLogoutResponse) + reply := out.(*GetCaptchaResponse) return ctx.Result(200, reply) } } -type AuthServiceHTTPClient interface { - // AuthLogout AuthLogout logs out a user. - AuthLogout(ctx context.Context, req *AuthLogoutRequest, opts ...http.CallOption) (rsp *AuthLogoutResponse, err error) - // Authenticate Authenticate authenticates a user. - Authenticate(ctx context.Context, req *AuthenticateRequest, opts ...http.CallOption) (rsp *AuthenticateResponse, err error) - // CreateToken CreateToken generates a new JWT token for the given user. - CreateToken(ctx context.Context, req *CreateTokenRequest, opts ...http.CallOption) (rsp *CreateTokenResponse, err error) - // DestroyToken DestroyToken invalidates a JWT token. - DestroyToken(ctx context.Context, req *DestroyTokenRequest, opts ...http.CallOption) (rsp *DestroyTokenResponse, err error) - // ListAuthResources ListAuthResources returns a list of Auths. - ListAuthResources(ctx context.Context, req *ListAuthResourcesRequest, opts ...http.CallOption) (rsp *ListAuthResourcesResponse, err error) - // ValidateToken ValidateToken verifies the validity of a JWT token. - ValidateToken(ctx context.Context, req *ValidateTokenRequest, opts ...http.CallOption) (rsp *ValidateTokenResponse, err error) +type AuthHTTPClient interface { + // GetCaptcha GetCaptcha generates a new captcha. + GetCaptcha(ctx context.Context, req *GetCaptchaRequest, opts ...http.CallOption) (rsp *GetCaptchaResponse, err error) + // Login Login authenticates a user and returns a token pair. + Login(ctx context.Context, req *LoginRequest, opts ...http.CallOption) (rsp *LoginResponse, err error) + // Logout Logout invalidates the user's session. + Logout(ctx context.Context, req *LogoutRequest, opts ...http.CallOption) (rsp *emptypb.Empty, err error) + // RefreshToken RefreshToken provides a new access token. + RefreshToken(ctx context.Context, req *RefreshTokenRequest, opts ...http.CallOption) (rsp *RefreshTokenResponse, err error) + // Register Register creates a new user account. + Register(ctx context.Context, req *RegisterRequest, opts ...http.CallOption) (rsp *emptypb.Empty, err error) } -type AuthServiceHTTPClientImpl struct { +type AuthHTTPClientImpl struct { cc *http.Client } -func NewAuthServiceHTTPClient(client *http.Client) AuthServiceHTTPClient { - return &AuthServiceHTTPClientImpl{client} +func NewAuthHTTPClient(client *http.Client) AuthHTTPClient { + return &AuthHTTPClientImpl{client} } -// AuthLogout AuthLogout logs out a user. -func (c *AuthServiceHTTPClientImpl) AuthLogout(ctx context.Context, in *AuthLogoutRequest, opts ...http.CallOption) (*AuthLogoutResponse, error) { - var out AuthLogoutResponse - pattern := "/auth/logout" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthServiceAuthLogout)) +// GetCaptcha GetCaptcha generates a new captcha. +func (c *AuthHTTPClientImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest, opts ...http.CallOption) (*GetCaptchaResponse, error) { + var out GetCaptchaResponse + pattern := "/api/v1/captcha" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationAuthGetCaptcha)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) if err != nil { return nil, err } return &out, nil } -// Authenticate Authenticate authenticates a user. -func (c *AuthServiceHTTPClientImpl) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...http.CallOption) (*AuthenticateResponse, error) { - var out AuthenticateResponse - pattern := "/auth/authenticate" +// Login Login authenticates a user and returns a token pair. +func (c *AuthHTTPClientImpl) Login(ctx context.Context, in *LoginRequest, opts ...http.CallOption) (*LoginResponse, error) { + var out LoginResponse + pattern := "/api/v1/auth/login" path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthServiceAuthenticate)) + opts = append(opts, http.Operation(OperationAuthLogin)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } return &out, nil } -// CreateToken CreateToken generates a new JWT token for the given user. -func (c *AuthServiceHTTPClientImpl) CreateToken(ctx context.Context, in *CreateTokenRequest, opts ...http.CallOption) (*CreateTokenResponse, error) { - var out CreateTokenResponse - pattern := "/auth/token" +// Logout Logout invalidates the user's session. +func (c *AuthHTTPClientImpl) Logout(ctx context.Context, in *LogoutRequest, opts ...http.CallOption) (*emptypb.Empty, error) { + var out emptypb.Empty + pattern := "/api/v1/auth/logout" path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthServiceCreateToken)) + opts = append(opts, http.Operation(OperationAuthLogout)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } return &out, nil } -// DestroyToken DestroyToken invalidates a JWT token. -func (c *AuthServiceHTTPClientImpl) DestroyToken(ctx context.Context, in *DestroyTokenRequest, opts ...http.CallOption) (*DestroyTokenResponse, error) { - var out DestroyTokenResponse - pattern := "/auth/destroy" +// RefreshToken RefreshToken provides a new access token. +func (c *AuthHTTPClientImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...http.CallOption) (*RefreshTokenResponse, error) { + var out RefreshTokenResponse + pattern := "/api/v1/auth/token" path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthServiceDestroyToken)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ListAuthResources ListAuthResources returns a list of Auths. -func (c *AuthServiceHTTPClientImpl) ListAuthResources(ctx context.Context, in *ListAuthResourcesRequest, opts ...http.CallOption) (*ListAuthResourcesResponse, error) { - var out ListAuthResourcesResponse - pattern := "/auth/resources" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationAuthServiceListAuthResources)) + opts = append(opts, http.Operation(OperationAuthRefreshToken)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } return &out, nil } -// ValidateToken ValidateToken verifies the validity of a JWT token. -func (c *AuthServiceHTTPClientImpl) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...http.CallOption) (*ValidateTokenResponse, error) { - var out ValidateTokenResponse - pattern := "/auth/validate" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationAuthServiceValidateToken)) +// Register Register creates a new user account. +func (c *AuthHTTPClientImpl) Register(ctx context.Context, in *RegisterRequest, opts ...http.CallOption) (*emptypb.Empty, error) { + var out emptypb.Empty + pattern := "/api/v1/auth/register" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationAuthRegister)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/auth/casbin.pb.go b/api/v1/services/auth/casbin.pb.go index 09c72623..2205cf9c 100644 --- a/api/v1/services/auth/casbin.pb.go +++ b/api/v1/services/auth/casbin.pb.go @@ -536,11 +536,11 @@ const file_auth_casbin_proto_rawDesc = "" + "\x12WatchUpdateRequest\x12$\n" + "\rlast_modified\x18\x01 \x01(\x03R\rlast_modified\";\n" + "\x13WatchUpdateResponse\x12$\n" + - "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\x89\x04\n" + - "\x13CasbinSourceService\x12\x82\x01\n" + - "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x86\x01\n" + - "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12|\n" + - "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12f\n" + + "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\x9f\x04\n" + + "\x13CasbinSourceService\x12\x89\x01\n" + + "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\"\x82\xd3\xe4\x93\x02\x1cb\x01*\x12\x17/api/v1/casbin/policies\x12\x8d\x01\n" + + "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"#\x82\xd3\xe4\x93\x02\x1db\x01*\x12\x18/api/v1/casbin/groupings\x12\x83\x01\n" + + "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x1f\x82\xd3\xe4\x93\x02\x19b\x01*\x12\x14/api/v1/casbin/watch\x12f\n" + "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xd2\x01\n" + "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" diff --git a/api/v1/services/auth/casbin.pb.gw.go b/api/v1/services/auth/casbin.pb.gw.go index b20ef61b..dee31a0f 100644 --- a/api/v1/services/auth/casbin.pb.gw.go +++ b/api/v1/services/auth/casbin.pb.gw.go @@ -118,7 +118,7 @@ func RegisterCasbinSourceServiceHandlerServer(ctx context.Context, mux *runtime. var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/api/v1/casbin/policies")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -138,7 +138,7 @@ func RegisterCasbinSourceServiceHandlerServer(ctx context.Context, mux *runtime. var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/api/v1/casbin/groupings")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -158,7 +158,7 @@ func RegisterCasbinSourceServiceHandlerServer(ctx context.Context, mux *runtime. var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/api/v1/casbin/watch")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -216,7 +216,7 @@ func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime. ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/api/v1/casbin/policies")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -233,7 +233,7 @@ func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime. ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/api/v1/casbin/groupings")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -250,7 +250,7 @@ func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime. ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/api/v1/casbin/watch")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -267,9 +267,9 @@ func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime. } var ( - pattern_CasbinSourceService_ListPolicies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "policies"}, "")) - pattern_CasbinSourceService_ListGroupings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "groupings"}, "")) - pattern_CasbinSourceService_WatchUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "watch"}, "")) + pattern_CasbinSourceService_ListPolicies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "policies"}, "")) + pattern_CasbinSourceService_ListGroupings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "groupings"}, "")) + pattern_CasbinSourceService_WatchUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "watch"}, "")) ) var ( diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index 9e7e573b..c72ee06b 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -63,9 +63,9 @@ type CasbinSourceServiceWatchUpdateHooker interface { func RegisterCasbinSourceServiceBridgeServer(s *http.Server, srv CasbinSourceServiceHookedBridger) { r := s.Route("/") - r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_Bridge_Handler(srv)) - r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_Bridge_Handler(srv)) - r.GET("/casbin/watch", _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv)) + r.GET("/api/v1/casbin/policies", _CasbinSourceService_ListPolicies0_Bridge_Handler(srv)) + r.GET("/api/v1/casbin/groupings", _CasbinSourceService_ListGroupings0_Bridge_Handler(srv)) + r.GET("/api/v1/casbin/watch", _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv)) } func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { diff --git a/api/v1/services/auth/casbin_http.pb.go b/api/v1/services/auth/casbin_http.pb.go index e66f87ae..94487ae0 100644 --- a/api/v1/services/auth/casbin_http.pb.go +++ b/api/v1/services/auth/casbin_http.pb.go @@ -31,9 +31,9 @@ type CasbinSourceServiceHTTPServer interface { func RegisterCasbinSourceServiceHTTPServer(s *http.Server, srv CasbinSourceServiceHTTPServer) { r := s.Route("/") - r.GET("/casbin/policies", _CasbinSourceService_ListPolicies0_HTTP_Handler(srv)) - r.GET("/casbin/groupings", _CasbinSourceService_ListGroupings0_HTTP_Handler(srv)) - r.GET("/casbin/watch", _CasbinSourceService_WatchUpdate0_HTTP_Handler(srv)) + r.GET("/api/v1/casbin/policies", _CasbinSourceService_ListPolicies0_HTTP_Handler(srv)) + r.GET("/api/v1/casbin/groupings", _CasbinSourceService_ListGroupings0_HTTP_Handler(srv)) + r.GET("/api/v1/casbin/watch", _CasbinSourceService_WatchUpdate0_HTTP_Handler(srv)) } func _CasbinSourceService_ListPolicies0_HTTP_Handler(srv CasbinSourceServiceHTTPServer) func(ctx http.Context) error { @@ -109,7 +109,7 @@ func NewCasbinSourceServiceHTTPClient(client *http.Client) CasbinSourceServiceHT func (c *CasbinSourceServiceHTTPClientImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...http.CallOption) (*ListGroupingsResponse, error) { var out ListGroupingsResponse - pattern := "/casbin/groupings" + pattern := "/api/v1/casbin/groupings" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationCasbinSourceServiceListGroupings)) opts = append(opts, http.PathTemplate(pattern)) @@ -122,7 +122,7 @@ func (c *CasbinSourceServiceHTTPClientImpl) ListGroupings(ctx context.Context, i func (c *CasbinSourceServiceHTTPClientImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...http.CallOption) (*ListPoliciesResponse, error) { var out ListPoliciesResponse - pattern := "/casbin/policies" + pattern := "/api/v1/casbin/policies" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationCasbinSourceServiceListPolicies)) opts = append(opts, http.PathTemplate(pattern)) @@ -135,7 +135,7 @@ func (c *CasbinSourceServiceHTTPClientImpl) ListPolicies(ctx context.Context, in func (c *CasbinSourceServiceHTTPClientImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...http.CallOption) (*WatchUpdateResponse, error) { var out WatchUpdateResponse - pattern := "/casbin/watch" + pattern := "/api/v1/casbin/watch" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationCasbinSourceServiceWatchUpdate)) opts = append(opts, http.PathTemplate(pattern)) diff --git a/api/v1/services/auth/login.pb.go b/api/v1/services/auth/login.pb.go deleted file mode 100644 index 4ca709a3..00000000 --- a/api/v1/services/auth/login.pb.go +++ /dev/null @@ -1,1461 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: auth/login.proto - -package auth - -import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" - v1 "github.com/origadmin/contrib/api/gen/go/security/v1" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type TokenRefreshRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *TokenRefreshRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *TokenRefreshRequest) Reset() { - *x = TokenRefreshRequest{} - mi := &file_auth_login_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *TokenRefreshRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TokenRefreshRequest) ProtoMessage() {} - -func (x *TokenRefreshRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[0] - 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 TokenRefreshRequest.ProtoReflect.Descriptor instead. -func (*TokenRefreshRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{0} -} - -func (x *TokenRefreshRequest) GetData() *TokenRefreshRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -type TokenRefreshResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token *v1.TokenCredential `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *TokenRefreshResponse) Reset() { - *x = TokenRefreshResponse{} - mi := &file_auth_login_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *TokenRefreshResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TokenRefreshResponse) ProtoMessage() {} - -func (x *TokenRefreshResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[1] - 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 TokenRefreshResponse.ProtoReflect.Descriptor instead. -func (*TokenRefreshResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{1} -} - -func (x *TokenRefreshResponse) GetToken() *v1.TokenCredential { - if x != nil { - return x.Token - } - return nil -} - -type LoginRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *LoginRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LoginRequest) Reset() { - *x = LoginRequest{} - mi := &file_auth_login_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LoginRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoginRequest) ProtoMessage() {} - -func (x *LoginRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[2] - 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 LoginRequest.ProtoReflect.Descriptor instead. -func (*LoginRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{2} -} - -func (x *LoginRequest) GetData() *LoginRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -type LoginResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token *v1.TokenCredential `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LoginResponse) Reset() { - *x = LoginResponse{} - mi := &file_auth_login_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LoginResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoginResponse) ProtoMessage() {} - -func (x *LoginResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[3] - 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 LoginResponse.ProtoReflect.Descriptor instead. -func (*LoginResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{3} -} - -func (x *LoginResponse) GetToken() *v1.TokenCredential { - if x != nil { - return x.Token - } - return nil -} - -type CurrentUserRequestQuery struct { - state protoimpl.MessageState `protogen:"open.v1"` - UserId int64 `protobuf:"varint,1,opt,name=user_id,proto3" json:"user_id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CurrentUserRequestQuery) Reset() { - *x = CurrentUserRequestQuery{} - mi := &file_auth_login_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CurrentUserRequestQuery) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CurrentUserRequestQuery) ProtoMessage() {} - -func (x *CurrentUserRequestQuery) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[4] - 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 CurrentUserRequestQuery.ProtoReflect.Descriptor instead. -func (*CurrentUserRequestQuery) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{4} -} - -func (x *CurrentUserRequestQuery) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -type CurrentUserRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *CurrentUserRequestQuery `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CurrentUserRequest) Reset() { - *x = CurrentUserRequest{} - mi := &file_auth_login_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CurrentUserRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CurrentUserRequest) ProtoMessage() {} - -func (x *CurrentUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[5] - 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 CurrentUserRequest.ProtoReflect.Descriptor instead. -func (*CurrentUserRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{5} -} - -func (x *CurrentUserRequest) GetData() *CurrentUserRequestQuery { - if x != nil { - return x.Data - } - return nil -} - -type CurrentUserResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CurrentUserResponse) Reset() { - *x = CurrentUserResponse{} - mi := &file_auth_login_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CurrentUserResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CurrentUserResponse) ProtoMessage() {} - -func (x *CurrentUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_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 CurrentUserResponse.ProtoReflect.Descriptor instead. -func (*CurrentUserResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{6} -} - -func (x *CurrentUserResponse) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -func (x *CurrentUserResponse) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type CaptchaIdRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The timestamp of the request prevent caching of the same result - Ts string `protobuf:"bytes,1,opt,name=ts,proto3" json:"ts,omitempty"` - Reload bool `protobuf:"varint,2,opt,name=reload,proto3" json:"reload,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaIdRequest) Reset() { - *x = CaptchaIdRequest{} - mi := &file_auth_login_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaIdRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaIdRequest) ProtoMessage() {} - -func (x *CaptchaIdRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use CaptchaIdRequest.ProtoReflect.Descriptor instead. -func (*CaptchaIdRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{7} -} - -func (x *CaptchaIdRequest) GetTs() string { - if x != nil { - return x.Ts - } - return "" -} - -func (x *CaptchaIdRequest) GetReload() bool { - if x != nil { - return x.Reload - } - return false -} - -type CaptchaIdResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data string `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaIdResponse) Reset() { - *x = CaptchaIdResponse{} - mi := &file_auth_login_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaIdResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaIdResponse) ProtoMessage() {} - -func (x *CaptchaIdResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[8] - 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 CaptchaIdResponse.ProtoReflect.Descriptor instead. -func (*CaptchaIdResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{8} -} - -func (x *CaptchaIdResponse) GetData() string { - if x != nil { - return x.Data - } - return "" -} - -// The request message containing the user's name. -type CaptchaImageRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Reload string `protobuf:"bytes,2,opt,name=reload,proto3" json:"reload,omitempty"` - Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaImageRequest) Reset() { - *x = CaptchaImageRequest{} - mi := &file_auth_login_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaImageRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaImageRequest) ProtoMessage() {} - -func (x *CaptchaImageRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[9] - 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 CaptchaImageRequest.ProtoReflect.Descriptor instead. -func (*CaptchaImageRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{9} -} - -func (x *CaptchaImageRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CaptchaImageRequest) GetReload() string { - if x != nil { - return x.Reload - } - return "" -} - -func (x *CaptchaImageRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type CaptchaData struct { - state protoimpl.MessageState `protogen:"open.v1"` - CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` - CaptchaImg string `protobuf:"bytes,2,opt,name=captcha_img,json=captchaImg,proto3" json:"captcha_img,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaData) Reset() { - *x = CaptchaData{} - mi := &file_auth_login_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaData) ProtoMessage() {} - -func (x *CaptchaData) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[10] - 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 CaptchaData.ProtoReflect.Descriptor instead. -func (*CaptchaData) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{10} -} - -func (x *CaptchaData) GetCaptchaId() string { - if x != nil { - return x.CaptchaId - } - return "" -} - -func (x *CaptchaData) GetCaptchaImg() string { - if x != nil { - return x.CaptchaImg - } - return "" -} - -// The response message containing the greetings -type CaptchaImageResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - Image []byte `protobuf:"bytes,2,opt,name=image,proto3" json:"image,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaImageResponse) Reset() { - *x = CaptchaImageResponse{} - mi := &file_auth_login_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaImageResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaImageResponse) ProtoMessage() {} - -func (x *CaptchaImageResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[11] - 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 CaptchaImageResponse.ProtoReflect.Descriptor instead. -func (*CaptchaImageResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{11} -} - -func (x *CaptchaImageResponse) GetHeaders() map[string]string { - if x != nil { - return x.Headers - } - return nil -} - -func (x *CaptchaImageResponse) GetImage() []byte { - if x != nil { - return x.Image - } - return nil -} - -// The request message containing the user's name. -type CaptchaAudioRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Reload string `protobuf:"bytes,2,opt,name=reload,proto3" json:"reload,omitempty"` - Data *anypb.Any `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaAudioRequest) Reset() { - *x = CaptchaAudioRequest{} - mi := &file_auth_login_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaAudioRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaAudioRequest) ProtoMessage() {} - -func (x *CaptchaAudioRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[12] - 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 CaptchaAudioRequest.ProtoReflect.Descriptor instead. -func (*CaptchaAudioRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{12} -} - -func (x *CaptchaAudioRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CaptchaAudioRequest) GetReload() string { - if x != nil { - return x.Reload - } - return "" -} - -func (x *CaptchaAudioRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -// The response message containing the greetings -type CaptchaAudioResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Headers map[string]string `protobuf:"bytes,1,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` - Audio []byte `protobuf:"bytes,2,opt,name=audio,proto3" json:"audio,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaAudioResponse) Reset() { - *x = CaptchaAudioResponse{} - mi := &file_auth_login_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaAudioResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaAudioResponse) ProtoMessage() {} - -func (x *CaptchaAudioResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[13] - 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 CaptchaAudioResponse.ProtoReflect.Descriptor instead. -func (*CaptchaAudioResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{13} -} - -func (x *CaptchaAudioResponse) GetHeaders() map[string]string { - if x != nil { - return x.Headers - } - return nil -} - -func (x *CaptchaAudioResponse) GetAudio() []byte { - if x != nil { - return x.Audio - } - return nil -} - -type CaptchaRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The id of the captcha - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // The type of the captcha - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - // The reload is used to reload the captcha - Reload bool `protobuf:"varint,3,opt,name=reload,proto3" json:"reload,omitempty"` - // The timestamp of the request prevent caching of the same result - Ts string `protobuf:"bytes,4,opt,name=ts,proto3" json:"ts,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaRequest) Reset() { - *x = CaptchaRequest{} - mi := &file_auth_login_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaRequest) ProtoMessage() {} - -func (x *CaptchaRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[14] - 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 CaptchaRequest.ProtoReflect.Descriptor instead. -func (*CaptchaRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{14} -} - -func (x *CaptchaRequest) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CaptchaRequest) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *CaptchaRequest) GetReload() bool { - if x != nil { - return x.Reload - } - return false -} - -func (x *CaptchaRequest) GetTs() string { - if x != nil { - return x.Ts - } - return "" -} - -type CaptchaResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` - Data string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *CaptchaResponse) Reset() { - *x = CaptchaResponse{} - mi := &file_auth_login_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *CaptchaResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*CaptchaResponse) ProtoMessage() {} - -func (x *CaptchaResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[15] - 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 CaptchaResponse.ProtoReflect.Descriptor instead. -func (*CaptchaResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{15} -} - -func (x *CaptchaResponse) GetId() string { - if x != nil { - return x.Id - } - return "" -} - -func (x *CaptchaResponse) GetType() string { - if x != nil { - return x.Type - } - return "" -} - -func (x *CaptchaResponse) GetData() string { - if x != nil { - return x.Data - } - return "" -} - -type RegisterRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *RegisterRequest_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RegisterRequest) Reset() { - *x = RegisterRequest{} - mi := &file_auth_login_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RegisterRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterRequest) ProtoMessage() {} - -func (x *RegisterRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[16] - 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 RegisterRequest.ProtoReflect.Descriptor instead. -func (*RegisterRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{16} -} - -func (x *RegisterRequest) GetData() *RegisterRequest_Data { - if x != nil { - return x.Data - } - return nil -} - -type RegisterResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Data *RegisterResponse_Data `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RegisterResponse) Reset() { - *x = RegisterResponse{} - mi := &file_auth_login_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RegisterResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterResponse) ProtoMessage() {} - -func (x *RegisterResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[17] - 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 RegisterResponse.ProtoReflect.Descriptor instead. -func (*RegisterResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{17} -} - -func (x *RegisterResponse) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -func (x *RegisterResponse) GetData() *RegisterResponse_Data { - if x != nil { - return x.Data - } - return nil -} - -type LogoutRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LogoutRequest) Reset() { - *x = LogoutRequest{} - mi := &file_auth_login_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LogoutRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LogoutRequest) ProtoMessage() {} - -func (x *LogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[18] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. -func (*LogoutRequest) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{18} -} - -func (x *LogoutRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type LogoutResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LogoutResponse) Reset() { - *x = LogoutResponse{} - mi := &file_auth_login_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LogoutResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LogoutResponse) ProtoMessage() {} - -func (x *LogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead. -func (*LogoutResponse) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{19} -} - -func (x *LogoutResponse) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -type TokenRefreshRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *TokenRefreshRequest_Data) Reset() { - *x = TokenRefreshRequest_Data{} - mi := &file_auth_login_proto_msgTypes[20] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *TokenRefreshRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*TokenRefreshRequest_Data) ProtoMessage() {} - -func (x *TokenRefreshRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[20] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use TokenRefreshRequest_Data.ProtoReflect.Descriptor instead. -func (*TokenRefreshRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{0, 0} -} - -func (x *TokenRefreshRequest_Data) GetRefreshToken() string { - if x != nil { - return x.RefreshToken - } - return "" -} - -type LoginRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` - CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` - CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *LoginRequest_Data) Reset() { - *x = LoginRequest_Data{} - mi := &file_auth_login_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *LoginRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*LoginRequest_Data) ProtoMessage() {} - -func (x *LoginRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[21] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use LoginRequest_Data.ProtoReflect.Descriptor instead. -func (*LoginRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{2, 0} -} - -func (x *LoginRequest_Data) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *LoginRequest_Data) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -func (x *LoginRequest_Data) GetCaptchaId() string { - if x != nil { - return x.CaptchaId - } - return "" -} - -func (x *LoginRequest_Data) GetCaptchaCode() string { - if x != nil { - return x.CaptchaCode - } - return "" -} - -type RegisterRequest_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` - CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` - CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RegisterRequest_Data) Reset() { - *x = RegisterRequest_Data{} - mi := &file_auth_login_proto_msgTypes[24] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RegisterRequest_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterRequest_Data) ProtoMessage() {} - -func (x *RegisterRequest_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_proto_msgTypes[24] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RegisterRequest_Data.ProtoReflect.Descriptor instead. -func (*RegisterRequest_Data) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{16, 0} -} - -func (x *RegisterRequest_Data) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *RegisterRequest_Data) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -func (x *RegisterRequest_Data) GetCaptchaId() string { - if x != nil { - return x.CaptchaId - } - return "" -} - -func (x *RegisterRequest_Data) GetCaptchaCode() string { - if x != nil { - return x.CaptchaCode - } - return "" -} - -type RegisterResponse_Data struct { - state protoimpl.MessageState `protogen:"open.v1"` - Redirect string `protobuf:"bytes,1,opt,name=redirect,proto3" json:"redirect,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RegisterResponse_Data) Reset() { - *x = RegisterResponse_Data{} - mi := &file_auth_login_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RegisterResponse_Data) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RegisterResponse_Data) ProtoMessage() {} - -func (x *RegisterResponse_Data) ProtoReflect() protoreflect.Message { - mi := &file_auth_login_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 RegisterResponse_Data.ProtoReflect.Descriptor instead. -func (*RegisterResponse_Data) Descriptor() ([]byte, []int) { - return file_auth_login_proto_rawDescGZIP(), []int{17, 0} -} - -func (x *RegisterResponse_Data) GetRedirect() string { - if x != nil { - return x.Redirect - } - return "" -} - -var File_auth_login_proto protoreflect.FileDescriptor - -const file_auth_login_proto_rawDesc = "" + - "\n" + - "\x10auth/login.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1csecurity/v1/credential.proto\x1a\x17validate/validate.proto\"\x90\x01\n" + - "\x13TokenRefreshRequest\x12B\n" + - "\x04data\x18\x02 \x01(\v2..api.v1.services.auth.TokenRefreshRequest.DataR\x04data\x1a5\n" + - "\x04Data\x12-\n" + - "\rrefresh_token\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\rrefresh_token\"V\n" + - "\x14TokenRefreshResponse\x12>\n" + - "\x05token\x18\x01 \x01(\v2(.contrib.api.security.v1.TokenCredentialR\x05token\"\xf4\x01\n" + - "\fLoginRequest\x12;\n" + - "\x04data\x18\x02 \x01(\v2'.api.v1.services.auth.LoginRequest.DataR\x04data\x1a\xa6\x01\n" + - "\x04Data\x12#\n" + - "\busername\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12#\n" + - "\bpassword\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\bpassword\x12'\n" + - "\n" + - "captcha_id\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\n" + - "captcha_id\x12+\n" + - "\fcaptcha_code\x18\x04 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\fcaptcha_code\"O\n" + - "\rLoginResponse\x12>\n" + - "\x05token\x18\x01 \x01(\v2(.contrib.api.security.v1.TokenCredentialR\x05token\"3\n" + - "\x17CurrentUserRequestQuery\x12\x18\n" + - "\auser_id\x18\x01 \x01(\x03R\auser_id\"W\n" + - "\x12CurrentUserRequest\x12A\n" + - "\x04data\x18\x01 \x01(\v2-.api.v1.services.auth.CurrentUserRequestQueryR\x04data\"Y\n" + - "\x13CurrentUserResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\x12(\n" + - "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\":\n" + - "\x10CaptchaIdRequest\x12\x0e\n" + - "\x02ts\x18\x01 \x01(\tR\x02ts\x12\x16\n" + - "\x06reload\x18\x02 \x01(\bR\x06reload\"'\n" + - "\x11CaptchaIdResponse\x12\x12\n" + - "\x04data\x18\x01 \x01(\tR\x04data\"g\n" + - "\x13CaptchaImageRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" + - "\x06reload\x18\x02 \x01(\tR\x06reload\x12(\n" + - "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\"M\n" + - "\vCaptchaData\x12\x1d\n" + - "\n" + - "captcha_id\x18\x01 \x01(\tR\tcaptchaId\x12\x1f\n" + - "\vcaptcha_img\x18\x02 \x01(\tR\n" + - "captchaImg\"\xbb\x01\n" + - "\x14CaptchaImageResponse\x12Q\n" + - "\aheaders\x18\x01 \x03(\v27.api.v1.services.auth.CaptchaImageResponse.HeadersEntryR\aheaders\x12\x14\n" + - "\x05image\x18\x02 \x01(\fR\x05image\x1a:\n" + - "\fHeadersEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"g\n" + - "\x13CaptchaAudioRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" + - "\x06reload\x18\x02 \x01(\tR\x06reload\x12(\n" + - "\x04data\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\xbb\x01\n" + - "\x14CaptchaAudioResponse\x12Q\n" + - "\aheaders\x18\x01 \x03(\v27.api.v1.services.auth.CaptchaAudioResponse.HeadersEntryR\aheaders\x12\x14\n" + - "\x05audio\x18\x02 \x01(\fR\x05audio\x1a:\n" + - "\fHeadersEntry\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\\\n" + - "\x0eCaptchaRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + - "\x04type\x18\x02 \x01(\tR\x04type\x12\x16\n" + - "\x06reload\x18\x03 \x01(\bR\x06reload\x12\x0e\n" + - "\x02ts\x18\x04 \x01(\tR\x02ts\"I\n" + - "\x0fCaptchaResponse\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + - "\x04type\x18\x02 \x01(\tR\x04type\x12\x12\n" + - "\x04data\x18\x03 \x01(\tR\x04data\"\xfa\x01\n" + - "\x0fRegisterRequest\x12>\n" + - "\x04data\x18\x02 \x01(\v2*.api.v1.services.auth.RegisterRequest.DataR\x04data\x1a\xa6\x01\n" + - "\x04Data\x12#\n" + - "\busername\x18\x01 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12#\n" + - "\bpassword\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\bpassword\x12'\n" + - "\n" + - "captcha_id\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\n" + - "captcha_id\x12+\n" + - "\fcaptcha_code\x18\x04 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\fcaptcha_code\"\x91\x01\n" + - "\x10RegisterResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\x12?\n" + - "\x04data\x18\x02 \x01(\v2+.api.v1.services.auth.RegisterResponse.DataR\x04data\x1a\"\n" + - "\x04Data\x12\x1a\n" + - "\bredirect\x18\x01 \x01(\tR\bredirect\"9\n" + - "\rLogoutRequest\x12(\n" + - "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"*\n" + - "\x0eLogoutResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess2\xc2\a\n" + - "\fLoginService\x12k\n" + - "\aCaptcha\x12$.api.v1.services.auth.CaptchaRequest\x1a%.api.v1.services.auth.CaptchaResponse\"\x13\x82\xd3\xe4\x93\x02\rb\x01*\x12\b/captcha\x12q\n" + - "\tCaptchaId\x12&.api.v1.services.auth.CaptchaIdRequest\x1a'.api.v1.services.auth.CaptchaIdResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/captcha/id\x12\x80\x01\n" + - "\fCaptchaImage\x12).api.v1.services.auth.CaptchaImageRequest\x1a*.api.v1.services.auth.CaptchaImageResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/image\x12\x80\x01\n" + - "\fCaptchaAudio\x12).api.v1.services.auth.CaptchaAudioRequest\x1a*.api.v1.services.auth.CaptchaAudioResponse\"\x19\x82\xd3\xe4\x93\x02\x13b\x01*\x12\x0e/captcha/audio\x12f\n" + - "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x14\x82\xd3\xe4\x93\x02\x0e:\x04data\"\x06/login\x12j\n" + - "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/logout\x12r\n" + - "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a&.api.v1.services.auth.RegisterResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x04data\"\t/register\x12\x83\x01\n" + - "\fTokenRefresh\x12).api.v1.services.auth.TokenRefreshRequest\x1a*.api.v1.services.auth.TokenRefreshResponse\"\x1c\x82\xd3\xe4\x93\x02\x16:\x04data\"\x0e/token/refreshB\xd1\x01\n" + - "\x18com.api.v1.services.authB\n" + - "LoginProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" - -var ( - file_auth_login_proto_rawDescOnce sync.Once - file_auth_login_proto_rawDescData []byte -) - -func file_auth_login_proto_rawDescGZIP() []byte { - file_auth_login_proto_rawDescOnce.Do(func() { - file_auth_login_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_login_proto_rawDesc), len(file_auth_login_proto_rawDesc))) - }) - return file_auth_login_proto_rawDescData -} - -var file_auth_login_proto_msgTypes = make([]protoimpl.MessageInfo, 26) -var file_auth_login_proto_goTypes = []any{ - (*TokenRefreshRequest)(nil), // 0: api.v1.services.auth.TokenRefreshRequest - (*TokenRefreshResponse)(nil), // 1: api.v1.services.auth.TokenRefreshResponse - (*LoginRequest)(nil), // 2: api.v1.services.auth.LoginRequest - (*LoginResponse)(nil), // 3: api.v1.services.auth.LoginResponse - (*CurrentUserRequestQuery)(nil), // 4: api.v1.services.auth.CurrentUserRequestQuery - (*CurrentUserRequest)(nil), // 5: api.v1.services.auth.CurrentUserRequest - (*CurrentUserResponse)(nil), // 6: api.v1.services.auth.CurrentUserResponse - (*CaptchaIdRequest)(nil), // 7: api.v1.services.auth.CaptchaIdRequest - (*CaptchaIdResponse)(nil), // 8: api.v1.services.auth.CaptchaIdResponse - (*CaptchaImageRequest)(nil), // 9: api.v1.services.auth.CaptchaImageRequest - (*CaptchaData)(nil), // 10: api.v1.services.auth.CaptchaData - (*CaptchaImageResponse)(nil), // 11: api.v1.services.auth.CaptchaImageResponse - (*CaptchaAudioRequest)(nil), // 12: api.v1.services.auth.CaptchaAudioRequest - (*CaptchaAudioResponse)(nil), // 13: api.v1.services.auth.CaptchaAudioResponse - (*CaptchaRequest)(nil), // 14: api.v1.services.auth.CaptchaRequest - (*CaptchaResponse)(nil), // 15: api.v1.services.auth.CaptchaResponse - (*RegisterRequest)(nil), // 16: api.v1.services.auth.RegisterRequest - (*RegisterResponse)(nil), // 17: api.v1.services.auth.RegisterResponse - (*LogoutRequest)(nil), // 18: api.v1.services.auth.LogoutRequest - (*LogoutResponse)(nil), // 19: api.v1.services.auth.LogoutResponse - (*TokenRefreshRequest_Data)(nil), // 20: api.v1.services.auth.TokenRefreshRequest.Data - (*LoginRequest_Data)(nil), // 21: api.v1.services.auth.LoginRequest.Data - nil, // 22: api.v1.services.auth.CaptchaImageResponse.HeadersEntry - nil, // 23: api.v1.services.auth.CaptchaAudioResponse.HeadersEntry - (*RegisterRequest_Data)(nil), // 24: api.v1.services.auth.RegisterRequest.Data - (*RegisterResponse_Data)(nil), // 25: api.v1.services.auth.RegisterResponse.Data - (*v1.TokenCredential)(nil), // 26: contrib.api.security.v1.TokenCredential - (*anypb.Any)(nil), // 27: google.protobuf.Any -} -var file_auth_login_proto_depIdxs = []int32{ - 20, // 0: api.v1.services.auth.TokenRefreshRequest.data:type_name -> api.v1.services.auth.TokenRefreshRequest.Data - 26, // 1: api.v1.services.auth.TokenRefreshResponse.token:type_name -> contrib.api.security.v1.TokenCredential - 21, // 2: api.v1.services.auth.LoginRequest.data:type_name -> api.v1.services.auth.LoginRequest.Data - 26, // 3: api.v1.services.auth.LoginResponse.token:type_name -> contrib.api.security.v1.TokenCredential - 4, // 4: api.v1.services.auth.CurrentUserRequest.data:type_name -> api.v1.services.auth.CurrentUserRequestQuery - 27, // 5: api.v1.services.auth.CurrentUserResponse.data:type_name -> google.protobuf.Any - 27, // 6: api.v1.services.auth.CaptchaImageRequest.data:type_name -> google.protobuf.Any - 22, // 7: api.v1.services.auth.CaptchaImageResponse.headers:type_name -> api.v1.services.auth.CaptchaImageResponse.HeadersEntry - 27, // 8: api.v1.services.auth.CaptchaAudioRequest.data:type_name -> google.protobuf.Any - 23, // 9: api.v1.services.auth.CaptchaAudioResponse.headers:type_name -> api.v1.services.auth.CaptchaAudioResponse.HeadersEntry - 24, // 10: api.v1.services.auth.RegisterRequest.data:type_name -> api.v1.services.auth.RegisterRequest.Data - 25, // 11: api.v1.services.auth.RegisterResponse.data:type_name -> api.v1.services.auth.RegisterResponse.Data - 27, // 12: api.v1.services.auth.LogoutRequest.data:type_name -> google.protobuf.Any - 14, // 13: api.v1.services.auth.LoginService.Captcha:input_type -> api.v1.services.auth.CaptchaRequest - 7, // 14: api.v1.services.auth.LoginService.CaptchaId:input_type -> api.v1.services.auth.CaptchaIdRequest - 9, // 15: api.v1.services.auth.LoginService.CaptchaImage:input_type -> api.v1.services.auth.CaptchaImageRequest - 12, // 16: api.v1.services.auth.LoginService.CaptchaAudio:input_type -> api.v1.services.auth.CaptchaAudioRequest - 2, // 17: api.v1.services.auth.LoginService.Login:input_type -> api.v1.services.auth.LoginRequest - 18, // 18: api.v1.services.auth.LoginService.Logout:input_type -> api.v1.services.auth.LogoutRequest - 16, // 19: api.v1.services.auth.LoginService.Register:input_type -> api.v1.services.auth.RegisterRequest - 0, // 20: api.v1.services.auth.LoginService.TokenRefresh:input_type -> api.v1.services.auth.TokenRefreshRequest - 15, // 21: api.v1.services.auth.LoginService.Captcha:output_type -> api.v1.services.auth.CaptchaResponse - 8, // 22: api.v1.services.auth.LoginService.CaptchaId:output_type -> api.v1.services.auth.CaptchaIdResponse - 11, // 23: api.v1.services.auth.LoginService.CaptchaImage:output_type -> api.v1.services.auth.CaptchaImageResponse - 13, // 24: api.v1.services.auth.LoginService.CaptchaAudio:output_type -> api.v1.services.auth.CaptchaAudioResponse - 3, // 25: api.v1.services.auth.LoginService.Login:output_type -> api.v1.services.auth.LoginResponse - 19, // 26: api.v1.services.auth.LoginService.Logout:output_type -> api.v1.services.auth.LogoutResponse - 17, // 27: api.v1.services.auth.LoginService.Register:output_type -> api.v1.services.auth.RegisterResponse - 1, // 28: api.v1.services.auth.LoginService.TokenRefresh:output_type -> api.v1.services.auth.TokenRefreshResponse - 21, // [21:29] is the sub-list for method output_type - 13, // [13:21] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name -} - -func init() { file_auth_login_proto_init() } -func file_auth_login_proto_init() { - if File_auth_login_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_login_proto_rawDesc), len(file_auth_login_proto_rawDesc)), - NumEnums: 0, - NumMessages: 26, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_auth_login_proto_goTypes, - DependencyIndexes: file_auth_login_proto_depIdxs, - MessageInfos: file_auth_login_proto_msgTypes, - }.Build() - File_auth_login_proto = out.File - file_auth_login_proto_goTypes = nil - file_auth_login_proto_depIdxs = nil -} diff --git a/api/v1/services/auth/login.pb.gw.go b/api/v1/services/auth/login.pb.gw.go deleted file mode 100644 index 6c520321..00000000 --- a/api/v1/services/auth/login.pb.gw.go +++ /dev/null @@ -1,631 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: auth/login.proto - -/* -Package auth is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package auth - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -var filter_LoginService_Captcha_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_LoginService_Captcha_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_Captcha_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Captcha(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_Captcha_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_Captcha_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Captcha(ctx, &protoReq) - return msg, metadata, err -} - -var filter_LoginService_CaptchaId_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_LoginService_CaptchaId_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaIdRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaId_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CaptchaId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_CaptchaId_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaIdRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaId_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CaptchaId(ctx, &protoReq) - return msg, metadata, err -} - -var filter_LoginService_CaptchaImage_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_LoginService_CaptchaImage_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaImageRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaImage_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CaptchaImage(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_CaptchaImage_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaImageRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaImage_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CaptchaImage(ctx, &protoReq) - return msg, metadata, err -} - -var filter_LoginService_CaptchaAudio_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_LoginService_CaptchaAudio_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaAudioRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaAudio_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CaptchaAudio(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_CaptchaAudio_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq CaptchaAudioRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_LoginService_CaptchaAudio_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CaptchaAudio(ctx, &protoReq) - return msg, metadata, err -} - -func request_LoginService_Login_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq LoginRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_Login_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq LoginRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Login(ctx, &protoReq) - return msg, metadata, err -} - -func request_LoginService_Logout_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq LogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Logout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_Logout_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq LogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Logout(ctx, &protoReq) - return msg, metadata, err -} - -func request_LoginService_Register_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RegisterRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Register(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_Register_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RegisterRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Register(ctx, &protoReq) - return msg, metadata, err -} - -func request_LoginService_TokenRefresh_0(ctx context.Context, marshaler runtime.Marshaler, client LoginServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq TokenRefreshRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.TokenRefresh(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_LoginService_TokenRefresh_0(ctx context.Context, marshaler runtime.Marshaler, server LoginServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq TokenRefreshRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.TokenRefresh(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterLoginServiceHandlerServer registers the http handlers for service LoginService to "mux". -// UnaryRPC :call LoginServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterLoginServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterLoginServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server LoginServiceServer) error { - mux.Handle(http.MethodGet, pattern_LoginService_Captcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Captcha", runtime.WithHTTPPathPattern("/captcha")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_Captcha_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Captcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaId", runtime.WithHTTPPathPattern("/captcha/id")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_CaptchaId_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaId_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaImage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaImage", runtime.WithHTTPPathPattern("/captcha/image")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_CaptchaImage_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaImage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaAudio_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaAudio", runtime.WithHTTPPathPattern("/captcha/audio")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_CaptchaAudio_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaAudio_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Login", runtime.WithHTTPPathPattern("/login")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Logout", runtime.WithHTTPPathPattern("/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_Logout_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Register", runtime.WithHTTPPathPattern("/register")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_Register_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_TokenRefresh_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.LoginService/TokenRefresh", runtime.WithHTTPPathPattern("/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_LoginService_TokenRefresh_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_TokenRefresh_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterLoginServiceHandlerFromEndpoint is same as RegisterLoginServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterLoginServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterLoginServiceHandler(ctx, mux, conn) -} - -// RegisterLoginServiceHandler registers the http handlers for service LoginService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterLoginServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterLoginServiceHandlerClient(ctx, mux, NewLoginServiceClient(conn)) -} - -// RegisterLoginServiceHandlerClient registers the http handlers for service LoginService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "LoginServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "LoginServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "LoginServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterLoginServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client LoginServiceClient) error { - mux.Handle(http.MethodGet, pattern_LoginService_Captcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Captcha", runtime.WithHTTPPathPattern("/captcha")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_Captcha_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Captcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaId", runtime.WithHTTPPathPattern("/captcha/id")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_CaptchaId_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaId_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaImage_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaImage", runtime.WithHTTPPathPattern("/captcha/image")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_CaptchaImage_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaImage_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_LoginService_CaptchaAudio_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/CaptchaAudio", runtime.WithHTTPPathPattern("/captcha/audio")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_CaptchaAudio_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_CaptchaAudio_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Login", runtime.WithHTTPPathPattern("/login")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Logout", runtime.WithHTTPPathPattern("/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_Logout_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/Register", runtime.WithHTTPPathPattern("/register")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_Register_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_LoginService_TokenRefresh_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.LoginService/TokenRefresh", runtime.WithHTTPPathPattern("/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_LoginService_TokenRefresh_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_LoginService_TokenRefresh_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_LoginService_Captcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"captcha"}, "")) - pattern_LoginService_CaptchaId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"captcha", "id"}, "")) - pattern_LoginService_CaptchaImage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"captcha", "image"}, "")) - pattern_LoginService_CaptchaAudio_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"captcha", "audio"}, "")) - pattern_LoginService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"login"}, "")) - pattern_LoginService_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"logout"}, "")) - pattern_LoginService_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"register"}, "")) - pattern_LoginService_TokenRefresh_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"token", "refresh"}, "")) -) - -var ( - forward_LoginService_Captcha_0 = runtime.ForwardResponseMessage - forward_LoginService_CaptchaId_0 = runtime.ForwardResponseMessage - forward_LoginService_CaptchaImage_0 = runtime.ForwardResponseMessage - forward_LoginService_CaptchaAudio_0 = runtime.ForwardResponseMessage - forward_LoginService_Login_0 = runtime.ForwardResponseMessage - forward_LoginService_Logout_0 = runtime.ForwardResponseMessage - forward_LoginService_Register_0 = runtime.ForwardResponseMessage - forward_LoginService_TokenRefresh_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/auth/login.pb.validate.go b/api/v1/services/auth/login.pb.validate.go deleted file mode 100644 index 45969891..00000000 --- a/api/v1/services/auth/login.pb.validate.go +++ /dev/null @@ -1,2930 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: auth/login.proto - -package auth - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on TokenRefreshRequest 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 *TokenRefreshRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on TokenRefreshRequest 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 -// TokenRefreshRequestMultiError, or nil if none found. -func (m *TokenRefreshRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *TokenRefreshRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, TokenRefreshRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, TokenRefreshRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return TokenRefreshRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return TokenRefreshRequestMultiError(errors) - } - - return nil -} - -// TokenRefreshRequestMultiError is an error wrapping multiple validation -// errors returned by TokenRefreshRequest.ValidateAll() if the designated -// constraints aren't met. -type TokenRefreshRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m TokenRefreshRequestMultiError) 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 TokenRefreshRequestMultiError) AllErrors() []error { return m } - -// TokenRefreshRequestValidationError is the validation error returned by -// TokenRefreshRequest.Validate if the designated constraints aren't met. -type TokenRefreshRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e TokenRefreshRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e TokenRefreshRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e TokenRefreshRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e TokenRefreshRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e TokenRefreshRequestValidationError) ErrorName() string { - return "TokenRefreshRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e TokenRefreshRequestValidationError) 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 %sTokenRefreshRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = TokenRefreshRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = TokenRefreshRequestValidationError{} - -// Validate checks the field values on TokenRefreshResponse 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 *TokenRefreshResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on TokenRefreshResponse 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 -// TokenRefreshResponseMultiError, or nil if none found. -func (m *TokenRefreshResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *TokenRefreshResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetToken()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, TokenRefreshResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, TokenRefreshResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetToken()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return TokenRefreshResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return TokenRefreshResponseMultiError(errors) - } - - return nil -} - -// TokenRefreshResponseMultiError is an error wrapping multiple validation -// errors returned by TokenRefreshResponse.ValidateAll() if the designated -// constraints aren't met. -type TokenRefreshResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m TokenRefreshResponseMultiError) 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 TokenRefreshResponseMultiError) AllErrors() []error { return m } - -// TokenRefreshResponseValidationError is the validation error returned by -// TokenRefreshResponse.Validate if the designated constraints aren't met. -type TokenRefreshResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e TokenRefreshResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e TokenRefreshResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e TokenRefreshResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e TokenRefreshResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e TokenRefreshResponseValidationError) ErrorName() string { - return "TokenRefreshResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e TokenRefreshResponseValidationError) 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 %sTokenRefreshResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = TokenRefreshResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = TokenRefreshResponseValidationError{} - -// 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. -func (m *LoginRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LoginRequest 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 LoginRequestMultiError, or -// nil if none found. -func (m *LoginRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *LoginRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LoginRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LoginRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LoginRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return LoginRequestMultiError(errors) - } - - return nil -} - -// LoginRequestMultiError is an error wrapping multiple validation errors -// returned by LoginRequest.ValidateAll() if the designated constraints aren't met. -type LoginRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LoginRequestMultiError) 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 LoginRequestMultiError) AllErrors() []error { return m } - -// LoginRequestValidationError is the validation error returned by -// LoginRequest.Validate if the designated constraints aren't met. -type LoginRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LoginRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LoginRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LoginRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LoginRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LoginRequestValidationError) ErrorName() string { return "LoginRequestValidationError" } - -// Error satisfies the builtin error interface -func (e LoginRequestValidationError) 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 %sLoginRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LoginRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LoginRequestValidationError{} - -// Validate checks the field values on LoginResponse 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 *LoginResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LoginResponse 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 LoginResponseMultiError, or -// nil if none found. -func (m *LoginResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *LoginResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetToken()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LoginResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LoginResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetToken()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LoginResponseValidationError{ - field: "Token", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return LoginResponseMultiError(errors) - } - - return nil -} - -// LoginResponseMultiError is an error wrapping multiple validation errors -// returned by LoginResponse.ValidateAll() if the designated constraints -// aren't met. -type LoginResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LoginResponseMultiError) 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 LoginResponseMultiError) AllErrors() []error { return m } - -// LoginResponseValidationError is the validation error returned by -// LoginResponse.Validate if the designated constraints aren't met. -type LoginResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LoginResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LoginResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LoginResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LoginResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LoginResponseValidationError) ErrorName() string { return "LoginResponseValidationError" } - -// Error satisfies the builtin error interface -func (e LoginResponseValidationError) 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 %sLoginResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LoginResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LoginResponseValidationError{} - -// Validate checks the field values on CurrentUserRequestQuery 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 *CurrentUserRequestQuery) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CurrentUserRequestQuery 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 -// CurrentUserRequestQueryMultiError, or nil if none found. -func (m *CurrentUserRequestQuery) ValidateAll() error { - return m.validate(true) -} - -func (m *CurrentUserRequestQuery) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for UserId - - if len(errors) > 0 { - return CurrentUserRequestQueryMultiError(errors) - } - - return nil -} - -// CurrentUserRequestQueryMultiError is an error wrapping multiple validation -// errors returned by CurrentUserRequestQuery.ValidateAll() if the designated -// constraints aren't met. -type CurrentUserRequestQueryMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CurrentUserRequestQueryMultiError) 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 CurrentUserRequestQueryMultiError) AllErrors() []error { return m } - -// CurrentUserRequestQueryValidationError is the validation error returned by -// CurrentUserRequestQuery.Validate if the designated constraints aren't met. -type CurrentUserRequestQueryValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CurrentUserRequestQueryValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CurrentUserRequestQueryValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CurrentUserRequestQueryValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CurrentUserRequestQueryValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CurrentUserRequestQueryValidationError) ErrorName() string { - return "CurrentUserRequestQueryValidationError" -} - -// Error satisfies the builtin error interface -func (e CurrentUserRequestQueryValidationError) 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 %sCurrentUserRequestQuery.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CurrentUserRequestQueryValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CurrentUserRequestQueryValidationError{} - -// Validate checks the field values on CurrentUserRequest 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 *CurrentUserRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CurrentUserRequest 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 -// CurrentUserRequestMultiError, or nil if none found. -func (m *CurrentUserRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CurrentUserRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CurrentUserRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CurrentUserRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CurrentUserRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CurrentUserRequestMultiError(errors) - } - - return nil -} - -// CurrentUserRequestMultiError is an error wrapping multiple validation errors -// returned by CurrentUserRequest.ValidateAll() if the designated constraints -// aren't met. -type CurrentUserRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CurrentUserRequestMultiError) 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 CurrentUserRequestMultiError) AllErrors() []error { return m } - -// CurrentUserRequestValidationError is the validation error returned by -// CurrentUserRequest.Validate if the designated constraints aren't met. -type CurrentUserRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CurrentUserRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CurrentUserRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CurrentUserRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CurrentUserRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CurrentUserRequestValidationError) ErrorName() string { - return "CurrentUserRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CurrentUserRequestValidationError) 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 %sCurrentUserRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CurrentUserRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CurrentUserRequestValidationError{} - -// Validate checks the field values on CurrentUserResponse 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 *CurrentUserResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CurrentUserResponse 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 -// CurrentUserResponseMultiError, or nil if none found. -func (m *CurrentUserResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CurrentUserResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Success - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CurrentUserResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CurrentUserResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CurrentUserResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CurrentUserResponseMultiError(errors) - } - - return nil -} - -// CurrentUserResponseMultiError is an error wrapping multiple validation -// errors returned by CurrentUserResponse.ValidateAll() if the designated -// constraints aren't met. -type CurrentUserResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CurrentUserResponseMultiError) 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 CurrentUserResponseMultiError) AllErrors() []error { return m } - -// CurrentUserResponseValidationError is the validation error returned by -// CurrentUserResponse.Validate if the designated constraints aren't met. -type CurrentUserResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CurrentUserResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CurrentUserResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CurrentUserResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CurrentUserResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CurrentUserResponseValidationError) ErrorName() string { - return "CurrentUserResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CurrentUserResponseValidationError) 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 %sCurrentUserResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CurrentUserResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CurrentUserResponseValidationError{} - -// Validate checks the field values on CaptchaIdRequest 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 *CaptchaIdRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaIdRequest 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 -// CaptchaIdRequestMultiError, or nil if none found. -func (m *CaptchaIdRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaIdRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Ts - - // no validation rules for Reload - - if len(errors) > 0 { - return CaptchaIdRequestMultiError(errors) - } - - return nil -} - -// CaptchaIdRequestMultiError is an error wrapping multiple validation errors -// returned by CaptchaIdRequest.ValidateAll() if the designated constraints -// aren't met. -type CaptchaIdRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaIdRequestMultiError) 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 CaptchaIdRequestMultiError) AllErrors() []error { return m } - -// CaptchaIdRequestValidationError is the validation error returned by -// CaptchaIdRequest.Validate if the designated constraints aren't met. -type CaptchaIdRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaIdRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaIdRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaIdRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaIdRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaIdRequestValidationError) ErrorName() string { return "CaptchaIdRequestValidationError" } - -// Error satisfies the builtin error interface -func (e CaptchaIdRequestValidationError) 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 %sCaptchaIdRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaIdRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaIdRequestValidationError{} - -// Validate checks the field values on CaptchaIdResponse 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 *CaptchaIdResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaIdResponse 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 -// CaptchaIdResponseMultiError, or nil if none found. -func (m *CaptchaIdResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaIdResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Data - - if len(errors) > 0 { - return CaptchaIdResponseMultiError(errors) - } - - return nil -} - -// CaptchaIdResponseMultiError is an error wrapping multiple validation errors -// returned by CaptchaIdResponse.ValidateAll() if the designated constraints -// aren't met. -type CaptchaIdResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaIdResponseMultiError) 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 CaptchaIdResponseMultiError) AllErrors() []error { return m } - -// CaptchaIdResponseValidationError is the validation error returned by -// CaptchaIdResponse.Validate if the designated constraints aren't met. -type CaptchaIdResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaIdResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaIdResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaIdResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaIdResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaIdResponseValidationError) ErrorName() string { - return "CaptchaIdResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CaptchaIdResponseValidationError) 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 %sCaptchaIdResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaIdResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaIdResponseValidationError{} - -// Validate checks the field values on CaptchaImageRequest 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 *CaptchaImageRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaImageRequest 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 -// CaptchaImageRequestMultiError, or nil if none found. -func (m *CaptchaImageRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaImageRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Reload - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CaptchaImageRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CaptchaImageRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CaptchaImageRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CaptchaImageRequestMultiError(errors) - } - - return nil -} - -// CaptchaImageRequestMultiError is an error wrapping multiple validation -// errors returned by CaptchaImageRequest.ValidateAll() if the designated -// constraints aren't met. -type CaptchaImageRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaImageRequestMultiError) 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 CaptchaImageRequestMultiError) AllErrors() []error { return m } - -// CaptchaImageRequestValidationError is the validation error returned by -// CaptchaImageRequest.Validate if the designated constraints aren't met. -type CaptchaImageRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaImageRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaImageRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaImageRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaImageRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaImageRequestValidationError) ErrorName() string { - return "CaptchaImageRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CaptchaImageRequestValidationError) 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 %sCaptchaImageRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaImageRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaImageRequestValidationError{} - -// Validate checks the field values on CaptchaData 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 *CaptchaData) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaData 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 CaptchaDataMultiError, or -// nil if none found. -func (m *CaptchaData) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaData) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for CaptchaId - - // no validation rules for CaptchaImg - - if len(errors) > 0 { - return CaptchaDataMultiError(errors) - } - - return nil -} - -// CaptchaDataMultiError is an error wrapping multiple validation errors -// returned by CaptchaData.ValidateAll() if the designated constraints aren't met. -type CaptchaDataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaDataMultiError) 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 CaptchaDataMultiError) AllErrors() []error { return m } - -// CaptchaDataValidationError is the validation error returned by -// CaptchaData.Validate if the designated constraints aren't met. -type CaptchaDataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaDataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaDataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaDataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaDataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaDataValidationError) ErrorName() string { return "CaptchaDataValidationError" } - -// Error satisfies the builtin error interface -func (e CaptchaDataValidationError) 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 %sCaptchaData.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaDataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaDataValidationError{} - -// Validate checks the field values on CaptchaImageResponse 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 *CaptchaImageResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaImageResponse 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 -// CaptchaImageResponseMultiError, or nil if none found. -func (m *CaptchaImageResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaImageResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Headers - - // no validation rules for Image - - if len(errors) > 0 { - return CaptchaImageResponseMultiError(errors) - } - - return nil -} - -// CaptchaImageResponseMultiError is an error wrapping multiple validation -// errors returned by CaptchaImageResponse.ValidateAll() if the designated -// constraints aren't met. -type CaptchaImageResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaImageResponseMultiError) 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 CaptchaImageResponseMultiError) AllErrors() []error { return m } - -// CaptchaImageResponseValidationError is the validation error returned by -// CaptchaImageResponse.Validate if the designated constraints aren't met. -type CaptchaImageResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaImageResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaImageResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaImageResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaImageResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaImageResponseValidationError) ErrorName() string { - return "CaptchaImageResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CaptchaImageResponseValidationError) 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 %sCaptchaImageResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaImageResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaImageResponseValidationError{} - -// Validate checks the field values on CaptchaAudioRequest 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 *CaptchaAudioRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaAudioRequest 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 -// CaptchaAudioRequestMultiError, or nil if none found. -func (m *CaptchaAudioRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaAudioRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Reload - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CaptchaAudioRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CaptchaAudioRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CaptchaAudioRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return CaptchaAudioRequestMultiError(errors) - } - - return nil -} - -// CaptchaAudioRequestMultiError is an error wrapping multiple validation -// errors returned by CaptchaAudioRequest.ValidateAll() if the designated -// constraints aren't met. -type CaptchaAudioRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaAudioRequestMultiError) 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 CaptchaAudioRequestMultiError) AllErrors() []error { return m } - -// CaptchaAudioRequestValidationError is the validation error returned by -// CaptchaAudioRequest.Validate if the designated constraints aren't met. -type CaptchaAudioRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaAudioRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaAudioRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaAudioRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaAudioRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaAudioRequestValidationError) ErrorName() string { - return "CaptchaAudioRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e CaptchaAudioRequestValidationError) 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 %sCaptchaAudioRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaAudioRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaAudioRequestValidationError{} - -// Validate checks the field values on CaptchaAudioResponse 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 *CaptchaAudioResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaAudioResponse 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 -// CaptchaAudioResponseMultiError, or nil if none found. -func (m *CaptchaAudioResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaAudioResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Headers - - // no validation rules for Audio - - if len(errors) > 0 { - return CaptchaAudioResponseMultiError(errors) - } - - return nil -} - -// CaptchaAudioResponseMultiError is an error wrapping multiple validation -// errors returned by CaptchaAudioResponse.ValidateAll() if the designated -// constraints aren't met. -type CaptchaAudioResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaAudioResponseMultiError) 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 CaptchaAudioResponseMultiError) AllErrors() []error { return m } - -// CaptchaAudioResponseValidationError is the validation error returned by -// CaptchaAudioResponse.Validate if the designated constraints aren't met. -type CaptchaAudioResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaAudioResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaAudioResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaAudioResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaAudioResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaAudioResponseValidationError) ErrorName() string { - return "CaptchaAudioResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e CaptchaAudioResponseValidationError) 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 %sCaptchaAudioResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaAudioResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaAudioResponseValidationError{} - -// Validate checks the field values on CaptchaRequest 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 *CaptchaRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaRequest 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 CaptchaRequestMultiError, -// or nil if none found. -func (m *CaptchaRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Type - - // no validation rules for Reload - - // no validation rules for Ts - - if len(errors) > 0 { - return CaptchaRequestMultiError(errors) - } - - return nil -} - -// CaptchaRequestMultiError is an error wrapping multiple validation errors -// returned by CaptchaRequest.ValidateAll() if the designated constraints -// aren't met. -type CaptchaRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaRequestMultiError) 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 CaptchaRequestMultiError) AllErrors() []error { return m } - -// CaptchaRequestValidationError is the validation error returned by -// CaptchaRequest.Validate if the designated constraints aren't met. -type CaptchaRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaRequestValidationError) ErrorName() string { return "CaptchaRequestValidationError" } - -// Error satisfies the builtin error interface -func (e CaptchaRequestValidationError) 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 %sCaptchaRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaRequestValidationError{} - -// Validate checks the field values on CaptchaResponse 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 *CaptchaResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on CaptchaResponse 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 -// CaptchaResponseMultiError, or nil if none found. -func (m *CaptchaResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *CaptchaResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Type - - // no validation rules for Data - - if len(errors) > 0 { - return CaptchaResponseMultiError(errors) - } - - return nil -} - -// CaptchaResponseMultiError is an error wrapping multiple validation errors -// returned by CaptchaResponse.ValidateAll() if the designated constraints -// aren't met. -type CaptchaResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m CaptchaResponseMultiError) 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 CaptchaResponseMultiError) AllErrors() []error { return m } - -// CaptchaResponseValidationError is the validation error returned by -// CaptchaResponse.Validate if the designated constraints aren't met. -type CaptchaResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e CaptchaResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e CaptchaResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e CaptchaResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e CaptchaResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e CaptchaResponseValidationError) ErrorName() string { return "CaptchaResponseValidationError" } - -// Error satisfies the builtin error interface -func (e CaptchaResponseValidationError) 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 %sCaptchaResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = CaptchaResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = CaptchaResponseValidationError{} - -// Validate checks the field values on RegisterRequest 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 *RegisterRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RegisterRequest 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 -// RegisterRequestMultiError, or nil if none found. -func (m *RegisterRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *RegisterRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RegisterRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RegisterRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RegisterRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RegisterRequestMultiError(errors) - } - - return nil -} - -// RegisterRequestMultiError is an error wrapping multiple validation errors -// returned by RegisterRequest.ValidateAll() if the designated constraints -// aren't met. -type RegisterRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RegisterRequestMultiError) 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 RegisterRequestMultiError) AllErrors() []error { return m } - -// RegisterRequestValidationError is the validation error returned by -// RegisterRequest.Validate if the designated constraints aren't met. -type RegisterRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RegisterRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RegisterRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RegisterRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RegisterRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RegisterRequestValidationError) ErrorName() string { return "RegisterRequestValidationError" } - -// Error satisfies the builtin error interface -func (e RegisterRequestValidationError) 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 %sRegisterRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RegisterRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RegisterRequestValidationError{} - -// Validate checks the field values on RegisterResponse 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 *RegisterResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RegisterResponse 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 -// RegisterResponseMultiError, or nil if none found. -func (m *RegisterResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *RegisterResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Success - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RegisterResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RegisterResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RegisterResponseValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RegisterResponseMultiError(errors) - } - - return nil -} - -// RegisterResponseMultiError is an error wrapping multiple validation errors -// returned by RegisterResponse.ValidateAll() if the designated constraints -// aren't met. -type RegisterResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RegisterResponseMultiError) 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 RegisterResponseMultiError) AllErrors() []error { return m } - -// RegisterResponseValidationError is the validation error returned by -// RegisterResponse.Validate if the designated constraints aren't met. -type RegisterResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RegisterResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RegisterResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RegisterResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RegisterResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RegisterResponseValidationError) ErrorName() string { return "RegisterResponseValidationError" } - -// Error satisfies the builtin error interface -func (e RegisterResponseValidationError) 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 %sRegisterResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RegisterResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RegisterResponseValidationError{} - -// Validate checks the field values on LogoutRequest 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 *LogoutRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LogoutRequest 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 LogoutRequestMultiError, or -// nil if none found. -func (m *LogoutRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *LogoutRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, LogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, LogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return LogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return LogoutRequestMultiError(errors) - } - - return nil -} - -// LogoutRequestMultiError is an error wrapping multiple validation errors -// returned by LogoutRequest.ValidateAll() if the designated constraints -// aren't met. -type LogoutRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LogoutRequestMultiError) 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 LogoutRequestMultiError) AllErrors() []error { return m } - -// LogoutRequestValidationError is the validation error returned by -// LogoutRequest.Validate if the designated constraints aren't met. -type LogoutRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LogoutRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LogoutRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LogoutRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LogoutRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LogoutRequestValidationError) ErrorName() string { return "LogoutRequestValidationError" } - -// Error satisfies the builtin error interface -func (e LogoutRequestValidationError) 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 %sLogoutRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LogoutRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LogoutRequestValidationError{} - -// Validate checks the field values on LogoutResponse 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 *LogoutResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LogoutResponse 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 LogoutResponseMultiError, -// or nil if none found. -func (m *LogoutResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *LogoutResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Success - - if len(errors) > 0 { - return LogoutResponseMultiError(errors) - } - - return nil -} - -// LogoutResponseMultiError is an error wrapping multiple validation errors -// returned by LogoutResponse.ValidateAll() if the designated constraints -// aren't met. -type LogoutResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LogoutResponseMultiError) 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 LogoutResponseMultiError) AllErrors() []error { return m } - -// LogoutResponseValidationError is the validation error returned by -// LogoutResponse.Validate if the designated constraints aren't met. -type LogoutResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LogoutResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LogoutResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LogoutResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LogoutResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LogoutResponseValidationError) ErrorName() string { return "LogoutResponseValidationError" } - -// Error satisfies the builtin error interface -func (e LogoutResponseValidationError) 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 %sLogoutResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LogoutResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LogoutResponseValidationError{} - -// Validate checks the field values on TokenRefreshRequest_Data 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 *TokenRefreshRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on TokenRefreshRequest_Data 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 -// TokenRefreshRequest_DataMultiError, or nil if none found. -func (m *TokenRefreshRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *TokenRefreshRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetRefreshToken()) < 1 { - err := TokenRefreshRequest_DataValidationError{ - field: "RefreshToken", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return TokenRefreshRequest_DataMultiError(errors) - } - - return nil -} - -// TokenRefreshRequest_DataMultiError is an error wrapping multiple validation -// errors returned by TokenRefreshRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type TokenRefreshRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m TokenRefreshRequest_DataMultiError) 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 TokenRefreshRequest_DataMultiError) AllErrors() []error { return m } - -// TokenRefreshRequest_DataValidationError is the validation error returned by -// TokenRefreshRequest_Data.Validate if the designated constraints aren't met. -type TokenRefreshRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e TokenRefreshRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e TokenRefreshRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e TokenRefreshRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e TokenRefreshRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e TokenRefreshRequest_DataValidationError) ErrorName() string { - return "TokenRefreshRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e TokenRefreshRequest_DataValidationError) 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 %sTokenRefreshRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = TokenRefreshRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = TokenRefreshRequest_DataValidationError{} - -// Validate checks the field values on LoginRequest_Data 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 *LoginRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on LoginRequest_Data 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 -// LoginRequest_DataMultiError, or nil if none found. -func (m *LoginRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *LoginRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetUsername()) < 1 { - err := LoginRequest_DataValidationError{ - field: "Username", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetPassword()) < 1 { - err := LoginRequest_DataValidationError{ - field: "Password", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetCaptchaId()) < 1 { - err := LoginRequest_DataValidationError{ - field: "CaptchaId", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetCaptchaCode()) < 1 { - err := LoginRequest_DataValidationError{ - field: "CaptchaCode", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return LoginRequest_DataMultiError(errors) - } - - return nil -} - -// LoginRequest_DataMultiError is an error wrapping multiple validation errors -// returned by LoginRequest_Data.ValidateAll() if the designated constraints -// aren't met. -type LoginRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m LoginRequest_DataMultiError) 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 LoginRequest_DataMultiError) AllErrors() []error { return m } - -// LoginRequest_DataValidationError is the validation error returned by -// LoginRequest_Data.Validate if the designated constraints aren't met. -type LoginRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e LoginRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e LoginRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e LoginRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e LoginRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e LoginRequest_DataValidationError) ErrorName() string { - return "LoginRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e LoginRequest_DataValidationError) 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 %sLoginRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = LoginRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = LoginRequest_DataValidationError{} - -// Validate checks the field values on RegisterRequest_Data 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 *RegisterRequest_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RegisterRequest_Data 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 -// RegisterRequest_DataMultiError, or nil if none found. -func (m *RegisterRequest_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *RegisterRequest_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if utf8.RuneCountInString(m.GetUsername()) < 1 { - err := RegisterRequest_DataValidationError{ - field: "Username", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetPassword()) < 1 { - err := RegisterRequest_DataValidationError{ - field: "Password", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetCaptchaId()) < 1 { - err := RegisterRequest_DataValidationError{ - field: "CaptchaId", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if utf8.RuneCountInString(m.GetCaptchaCode()) < 1 { - err := RegisterRequest_DataValidationError{ - field: "CaptchaCode", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return RegisterRequest_DataMultiError(errors) - } - - return nil -} - -// RegisterRequest_DataMultiError is an error wrapping multiple validation -// errors returned by RegisterRequest_Data.ValidateAll() if the designated -// constraints aren't met. -type RegisterRequest_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RegisterRequest_DataMultiError) 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 RegisterRequest_DataMultiError) AllErrors() []error { return m } - -// RegisterRequest_DataValidationError is the validation error returned by -// RegisterRequest_Data.Validate if the designated constraints aren't met. -type RegisterRequest_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RegisterRequest_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RegisterRequest_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RegisterRequest_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RegisterRequest_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RegisterRequest_DataValidationError) ErrorName() string { - return "RegisterRequest_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e RegisterRequest_DataValidationError) 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 %sRegisterRequest_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RegisterRequest_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RegisterRequest_DataValidationError{} - -// Validate checks the field values on RegisterResponse_Data 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 *RegisterResponse_Data) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RegisterResponse_Data 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 -// RegisterResponse_DataMultiError, or nil if none found. -func (m *RegisterResponse_Data) ValidateAll() error { - return m.validate(true) -} - -func (m *RegisterResponse_Data) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Redirect - - if len(errors) > 0 { - return RegisterResponse_DataMultiError(errors) - } - - return nil -} - -// RegisterResponse_DataMultiError is an error wrapping multiple validation -// errors returned by RegisterResponse_Data.ValidateAll() if the designated -// constraints aren't met. -type RegisterResponse_DataMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RegisterResponse_DataMultiError) 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 RegisterResponse_DataMultiError) AllErrors() []error { return m } - -// RegisterResponse_DataValidationError is the validation error returned by -// RegisterResponse_Data.Validate if the designated constraints aren't met. -type RegisterResponse_DataValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RegisterResponse_DataValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RegisterResponse_DataValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RegisterResponse_DataValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RegisterResponse_DataValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RegisterResponse_DataValidationError) ErrorName() string { - return "RegisterResponse_DataValidationError" -} - -// Error satisfies the builtin error interface -func (e RegisterResponse_DataValidationError) 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 %sRegisterResponse_Data.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RegisterResponse_DataValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RegisterResponse_DataValidationError{} diff --git a/api/v1/services/auth/login_bridge.pb.go b/api/v1/services/auth/login_bridge.pb.go deleted file mode 100644 index de674202..00000000 --- a/api/v1/services/auth/login_bridge.pb.go +++ /dev/null @@ -1,554 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: auth/login.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const LoginServiceCaptchaBridgeOperation = "/api.v1.services.auth.LoginService/Captcha" -const LoginServiceCaptchaAudioBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaAudio" -const LoginServiceCaptchaIdBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaId" -const LoginServiceCaptchaImageBridgeOperation = "/api.v1.services.auth.LoginService/CaptchaImage" -const LoginServiceLoginBridgeOperation = "/api.v1.services.auth.LoginService/Login" -const LoginServiceLogoutBridgeOperation = "/api.v1.services.auth.LoginService/Logout" -const LoginServiceRegisterBridgeOperation = "/api.v1.services.auth.LoginService/Register" -const LoginServiceTokenRefreshBridgeOperation = "/api.v1.services.auth.LoginService/TokenRefresh" - -type LoginServiceBridgeServer interface { - Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) - CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) - CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) - CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) - Login(context.Context, *LoginRequest) (*LoginResponse, error) - Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) - Register(context.Context, *RegisterRequest) (*RegisterResponse, error) - TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) -} - -type LoginServiceHooker interface { - LoginServiceCaptchaHooker - LoginServiceCaptchaAudioHooker - LoginServiceCaptchaIdHooker - LoginServiceCaptchaImageHooker - LoginServiceLoginHooker - LoginServiceLogoutHooker - LoginServiceRegisterHooker - LoginServiceTokenRefreshHooker -} - -type LoginServiceHookedBridger interface { - LoginServiceHooker - LoginServiceBridgeServer -} -type LoginServiceCaptchaHooker interface { - PrepareCaptcha(http.Context, *CaptchaRequest) (context.Context, error) - CompleteCaptcha(http.Context, *CaptchaRequest, *CaptchaResponse) error -} -type LoginServiceCaptchaAudioHooker interface { - PrepareCaptchaAudio(http.Context, *CaptchaAudioRequest) (context.Context, error) - CompleteCaptchaAudio(http.Context, *CaptchaAudioRequest, *CaptchaAudioResponse) error -} -type LoginServiceCaptchaIdHooker interface { - PrepareCaptchaId(http.Context, *CaptchaIdRequest) (context.Context, error) - CompleteCaptchaId(http.Context, *CaptchaIdRequest, *CaptchaIdResponse) error -} -type LoginServiceCaptchaImageHooker interface { - PrepareCaptchaImage(http.Context, *CaptchaImageRequest) (context.Context, error) - CompleteCaptchaImage(http.Context, *CaptchaImageRequest, *CaptchaImageResponse) error -} -type LoginServiceLoginHooker interface { - PrepareLogin(http.Context, *LoginRequest) (context.Context, error) - CompleteLogin(http.Context, *LoginRequest, *LoginResponse) error -} -type LoginServiceLogoutHooker interface { - PrepareLogout(http.Context, *LogoutRequest) (context.Context, error) - CompleteLogout(http.Context, *LogoutRequest, *LogoutResponse) error -} -type LoginServiceRegisterHooker interface { - PrepareRegister(http.Context, *RegisterRequest) (context.Context, error) - CompleteRegister(http.Context, *RegisterRequest, *RegisterResponse) error -} -type LoginServiceTokenRefreshHooker interface { - PrepareTokenRefresh(http.Context, *TokenRefreshRequest) (context.Context, error) - CompleteTokenRefresh(http.Context, *TokenRefreshRequest, *TokenRefreshResponse) error -} - -func RegisterLoginServiceBridgeServer(s *http.Server, srv LoginServiceHookedBridger) { - r := s.Route("/") - r.GET("/captcha", _LoginService_Captcha0_Bridge_Handler(srv)) - r.GET("/captcha/id", _LoginService_CaptchaId0_Bridge_Handler(srv)) - r.GET("/captcha/image", _LoginService_CaptchaImage0_Bridge_Handler(srv)) - r.GET("/captcha/audio", _LoginService_CaptchaAudio0_Bridge_Handler(srv)) - r.POST("/login", _LoginService_Login0_Bridge_Handler(srv)) - r.POST("/logout", _LoginService_Logout0_Bridge_Handler(srv)) - r.POST("/register", _LoginService_Register0_Bridge_Handler(srv)) - r.POST("/token/refresh", _LoginService_TokenRefresh0_Bridge_Handler(srv)) -} - -func _LoginService_Captcha0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptcha) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Captcha(ctx, req.(*CaptchaRequest)) - }) - - newctx, err := srv.PrepareCaptcha(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCaptcha(ctx, &in, out.(*CaptchaResponse)) - } -} - -func _LoginService_CaptchaId0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaIdRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaId) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaId(ctx, req.(*CaptchaIdRequest)) - }) - - newctx, err := srv.PrepareCaptchaId(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCaptchaId(ctx, &in, out.(*CaptchaIdResponse)) - } -} - -func _LoginService_CaptchaImage0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaImageRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaImage) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaImage(ctx, req.(*CaptchaImageRequest)) - }) - - newctx, err := srv.PrepareCaptchaImage(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCaptchaImage(ctx, &in, out.(*CaptchaImageResponse)) - } -} - -func _LoginService_CaptchaAudio0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaAudioRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaAudio) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) - }) - - newctx, err := srv.PrepareCaptchaAudio(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCaptchaAudio(ctx, &in, out.(*CaptchaAudioResponse)) - } -} - -func _LoginService_Login0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in LoginRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceLogin) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Login(ctx, req.(*LoginRequest)) - }) - - newctx, err := srv.PrepareLogin(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteLogin(ctx, &in, out.(*LoginResponse)) - } -} - -func _LoginService_Logout0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in LogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Logout(ctx, req.(*LogoutRequest)) - }) - - newctx, err := srv.PrepareLogout(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteLogout(ctx, &in, out.(*LogoutResponse)) - } -} - -func _LoginService_Register0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RegisterRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceRegister) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Register(ctx, req.(*RegisterRequest)) - }) - - newctx, err := srv.PrepareRegister(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteRegister(ctx, &in, out.(*RegisterResponse)) - } -} - -func _LoginService_TokenRefresh0_Bridge_Handler(srv LoginServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in TokenRefreshRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceTokenRefresh) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.TokenRefresh(ctx, req.(*TokenRefreshRequest)) - }) - - newctx, err := srv.PrepareTokenRefresh(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteTokenRefresh(ctx, &in, out.(*TokenRefreshResponse)) - } -} - -// UnimplementedLoginServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedLoginServiceHooked struct{} - -func (UnimplementedLoginServiceHooked) PrepareCaptcha(ctx http.Context, in *CaptchaRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteCaptcha(ctx http.Context, in *CaptchaRequest, out *CaptchaResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteCaptchaAudio(ctx http.Context, in *CaptchaAudioRequest, out *CaptchaAudioResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareCaptchaId(ctx http.Context, in *CaptchaIdRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteCaptchaId(ctx http.Context, in *CaptchaIdRequest, out *CaptchaIdResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareCaptchaImage(ctx http.Context, in *CaptchaImageRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteCaptchaImage(ctx http.Context, in *CaptchaImageRequest, out *CaptchaImageResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteLogin(ctx http.Context, in *LoginRequest, out *LoginResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteLogout(ctx http.Context, in *LogoutRequest, out *LogoutResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteRegister(ctx http.Context, in *RegisterRequest, out *RegisterResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedLoginServiceHooked) PrepareTokenRefresh(ctx http.Context, in *TokenRefreshRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedLoginServiceHooked) CompleteTokenRefresh(ctx http.Context, in *TokenRefreshRequest, out *TokenRefreshResponse) error { - return ctx.Result(200, out) -} - -func WithLoginServiceHook(h LoginServiceHooker) func(LoginServiceBridgeServer) LoginServiceHookedBridger { - return func(srv LoginServiceBridgeServer) LoginServiceHookedBridger { - return LoginServiceHookedBridge{LoginServiceBridgeServer: srv, LoginServiceHooker: h} - } -} - -// LoginServiceHookedBridge is a bridge between the HTTP and gRPC implementations of LoginService. -// It implements the HTTP and gRPC implementations of LoginService. -// It forwards requests and responses between the two implementations. -type LoginServiceHookedBridge struct { - LoginServiceBridgeServer - LoginServiceHooker -} - -type LoginServiceHTTPBridgeImpl struct { - client LoginServiceHTTPClient -} - -func NewLoginServiceHTTPBridge(client *http.Client) LoginServiceHTTPServer { - return &LoginServiceHTTPBridgeImpl{client: NewLoginServiceHTTPClient(client)} -} - -func (c *LoginServiceHTTPBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { - return c.client.Captcha(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { - return c.client.CaptchaAudio(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { - return c.client.CaptchaId(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { - return c.client.CaptchaImage(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { - return c.client.Logout(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { - return c.client.Register(ctx, in) -} - -func (c *LoginServiceHTTPBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { - return c.client.TokenRefresh(ctx, in) -} - -type LoginServiceBridgeImpl struct { - client LoginServiceClient -} - -func NewLoginServiceBridge(client grpc.ClientConnInterface) LoginServiceServer { - return &LoginServiceBridgeImpl{client: NewLoginServiceClient(client)} -} - -func (c *LoginServiceBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { - return c.client.Captcha(ctx, in) -} - -func (c *LoginServiceBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { - return c.client.CaptchaAudio(ctx, in) -} - -func (c *LoginServiceBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { - return c.client.CaptchaId(ctx, in) -} - -func (c *LoginServiceBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { - return c.client.CaptchaImage(ctx, in) -} - -func (c *LoginServiceBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *LoginServiceBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { - return c.client.Logout(ctx, in) -} - -func (c *LoginServiceBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { - return c.client.Register(ctx, in) -} - -func (c *LoginServiceBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { - return c.client.TokenRefresh(ctx, in) -} - -func (c *LoginServiceBridgeImpl) mustEmbedUnimplementedLoginServiceServer() {} - -type LoginServiceGRPC2HTTPBridgeImpl struct { - client LoginServiceClient -} - -func NewLoginServiceGRPC2HTTP(client grpc.ClientConnInterface) LoginServiceHTTPServer { - return &LoginServiceGRPC2HTTPBridgeImpl{client: NewLoginServiceClient(client)} -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { - return c.client.Captcha(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { - return c.client.CaptchaAudio(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { - return c.client.CaptchaId(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { - return c.client.CaptchaImage(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { - return c.client.Logout(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { - return c.client.Register(ctx, in) -} - -func (c *LoginServiceGRPC2HTTPBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { - return c.client.TokenRefresh(ctx, in) -} - -type LoginServiceHTTP2GRPCBridgeImpl struct { - client LoginServiceHTTPClient -} - -func NewLoginServiceHTTP2GRPC(client *http.Client) LoginServiceServer { - return &LoginServiceHTTP2GRPCBridgeImpl{client: NewLoginServiceHTTPClient(client)} -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) { - return c.client.Captcha(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { - return c.client.CaptchaAudio(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest) (*CaptchaIdResponse, error) { - return c.client.CaptchaId(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest) (*CaptchaImageResponse, error) { - return c.client.CaptchaImage(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { - return c.client.Logout(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { - return c.client.Register(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) { - return c.client.TokenRefresh(ctx, in) -} - -func (c *LoginServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedLoginServiceServer() {} diff --git a/api/v1/services/auth/login_grpc.pb.go b/api/v1/services/auth/login_grpc.pb.go deleted file mode 100644 index dbb951a2..00000000 --- a/api/v1/services/auth/login_grpc.pb.go +++ /dev/null @@ -1,391 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: auth/login.proto - -package auth - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - LoginService_Captcha_FullMethodName = "/api.v1.services.auth.LoginService/Captcha" - LoginService_CaptchaId_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaId" - LoginService_CaptchaImage_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaImage" - LoginService_CaptchaAudio_FullMethodName = "/api.v1.services.auth.LoginService/CaptchaAudio" - LoginService_Login_FullMethodName = "/api.v1.services.auth.LoginService/Login" - LoginService_Logout_FullMethodName = "/api.v1.services.auth.LoginService/Logout" - LoginService_Register_FullMethodName = "/api.v1.services.auth.LoginService/Register" - LoginService_TokenRefresh_FullMethodName = "/api.v1.services.auth.LoginService/TokenRefresh" -) - -// LoginServiceClient is the client API for LoginService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// The login service definition. -type LoginServiceClient interface { - Captcha(ctx context.Context, in *CaptchaRequest, opts ...grpc.CallOption) (*CaptchaResponse, error) - CaptchaId(ctx context.Context, in *CaptchaIdRequest, opts ...grpc.CallOption) (*CaptchaIdResponse, error) - CaptchaImage(ctx context.Context, in *CaptchaImageRequest, opts ...grpc.CallOption) (*CaptchaImageResponse, error) - CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest, opts ...grpc.CallOption) (*CaptchaAudioResponse, error) - Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) - Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) - Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) - TokenRefresh(ctx context.Context, in *TokenRefreshRequest, opts ...grpc.CallOption) (*TokenRefreshResponse, error) -} - -type loginServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewLoginServiceClient(cc grpc.ClientConnInterface) LoginServiceClient { - return &loginServiceClient{cc} -} - -func (c *loginServiceClient) Captcha(ctx context.Context, in *CaptchaRequest, opts ...grpc.CallOption) (*CaptchaResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CaptchaResponse) - err := c.cc.Invoke(ctx, LoginService_Captcha_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) CaptchaId(ctx context.Context, in *CaptchaIdRequest, opts ...grpc.CallOption) (*CaptchaIdResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CaptchaIdResponse) - err := c.cc.Invoke(ctx, LoginService_CaptchaId_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) CaptchaImage(ctx context.Context, in *CaptchaImageRequest, opts ...grpc.CallOption) (*CaptchaImageResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CaptchaImageResponse) - err := c.cc.Invoke(ctx, LoginService_CaptchaImage_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest, opts ...grpc.CallOption) (*CaptchaAudioResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(CaptchaAudioResponse) - err := c.cc.Invoke(ctx, LoginService_CaptchaAudio_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(LoginResponse) - err := c.cc.Invoke(ctx, LoginService_Login_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(LogoutResponse) - err := c.cc.Invoke(ctx, LoginService_Logout_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(RegisterResponse) - err := c.cc.Invoke(ctx, LoginService_Register_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *loginServiceClient) TokenRefresh(ctx context.Context, in *TokenRefreshRequest, opts ...grpc.CallOption) (*TokenRefreshResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(TokenRefreshResponse) - err := c.cc.Invoke(ctx, LoginService_TokenRefresh_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// LoginServiceServer is the server API for LoginService service. -// All implementations must embed UnimplementedLoginServiceServer -// for forward compatibility. -// -// The login service definition. -type LoginServiceServer interface { - Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) - CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) - CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) - CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) - Login(context.Context, *LoginRequest) (*LoginResponse, error) - Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) - Register(context.Context, *RegisterRequest) (*RegisterResponse, error) - TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) - mustEmbedUnimplementedLoginServiceServer() -} - -// UnimplementedLoginServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedLoginServiceServer struct{} - -func (UnimplementedLoginServiceServer) Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Captcha not implemented") -} -func (UnimplementedLoginServiceServer) CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CaptchaId not implemented") -} -func (UnimplementedLoginServiceServer) CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CaptchaImage not implemented") -} -func (UnimplementedLoginServiceServer) CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CaptchaAudio not implemented") -} -func (UnimplementedLoginServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") -} -func (UnimplementedLoginServiceServer) Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented") -} -func (UnimplementedLoginServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") -} -func (UnimplementedLoginServiceServer) TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method TokenRefresh not implemented") -} -func (UnimplementedLoginServiceServer) mustEmbedUnimplementedLoginServiceServer() {} -func (UnimplementedLoginServiceServer) testEmbeddedByValue() {} - -// UnsafeLoginServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to LoginServiceServer will -// result in compilation errors. -type UnsafeLoginServiceServer interface { - mustEmbedUnimplementedLoginServiceServer() -} - -func RegisterLoginServiceServer(s grpc.ServiceRegistrar, srv LoginServiceServer) { - // If the following call pancis, it indicates UnimplementedLoginServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&LoginService_ServiceDesc, srv) -} - -func _LoginService_Captcha_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CaptchaRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).Captcha(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_Captcha_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).Captcha(ctx, req.(*CaptchaRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_CaptchaId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CaptchaIdRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).CaptchaId(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_CaptchaId_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).CaptchaId(ctx, req.(*CaptchaIdRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_CaptchaImage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CaptchaImageRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).CaptchaImage(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_CaptchaImage_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).CaptchaImage(ctx, req.(*CaptchaImageRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_CaptchaAudio_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CaptchaAudioRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).CaptchaAudio(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_CaptchaAudio_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LoginRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).Login(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_Login_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).Login(ctx, req.(*LoginRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(LogoutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).Logout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_Logout_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).Logout(ctx, req.(*LogoutRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RegisterRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).Register(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_Register_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).Register(ctx, req.(*RegisterRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _LoginService_TokenRefresh_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TokenRefreshRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(LoginServiceServer).TokenRefresh(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: LoginService_TokenRefresh_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(LoginServiceServer).TokenRefresh(ctx, req.(*TokenRefreshRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// LoginService_ServiceDesc is the grpc.ServiceDesc for LoginService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var LoginService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.auth.LoginService", - HandlerType: (*LoginServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Captcha", - Handler: _LoginService_Captcha_Handler, - }, - { - MethodName: "CaptchaId", - Handler: _LoginService_CaptchaId_Handler, - }, - { - MethodName: "CaptchaImage", - Handler: _LoginService_CaptchaImage_Handler, - }, - { - MethodName: "CaptchaAudio", - Handler: _LoginService_CaptchaAudio_Handler, - }, - { - MethodName: "Login", - Handler: _LoginService_Login_Handler, - }, - { - MethodName: "Logout", - Handler: _LoginService_Logout_Handler, - }, - { - MethodName: "Register", - Handler: _LoginService_Register_Handler, - }, - { - MethodName: "TokenRefresh", - Handler: _LoginService_TokenRefresh_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "auth/login.proto", -} diff --git a/api/v1/services/auth/login_http.pb.go b/api/v1/services/auth/login_http.pb.go deleted file mode 100644 index cd24ca67..00000000 --- a/api/v1/services/auth/login_http.pb.go +++ /dev/null @@ -1,339 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: auth/login.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationLoginServiceCaptcha = "/api.v1.services.auth.LoginService/Captcha" -const OperationLoginServiceCaptchaAudio = "/api.v1.services.auth.LoginService/CaptchaAudio" -const OperationLoginServiceCaptchaId = "/api.v1.services.auth.LoginService/CaptchaId" -const OperationLoginServiceCaptchaImage = "/api.v1.services.auth.LoginService/CaptchaImage" -const OperationLoginServiceLogin = "/api.v1.services.auth.LoginService/Login" -const OperationLoginServiceLogout = "/api.v1.services.auth.LoginService/Logout" -const OperationLoginServiceRegister = "/api.v1.services.auth.LoginService/Register" -const OperationLoginServiceTokenRefresh = "/api.v1.services.auth.LoginService/TokenRefresh" - -type LoginServiceHTTPServer interface { - Captcha(context.Context, *CaptchaRequest) (*CaptchaResponse, error) - CaptchaAudio(context.Context, *CaptchaAudioRequest) (*CaptchaAudioResponse, error) - CaptchaId(context.Context, *CaptchaIdRequest) (*CaptchaIdResponse, error) - CaptchaImage(context.Context, *CaptchaImageRequest) (*CaptchaImageResponse, error) - Login(context.Context, *LoginRequest) (*LoginResponse, error) - Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) - Register(context.Context, *RegisterRequest) (*RegisterResponse, error) - TokenRefresh(context.Context, *TokenRefreshRequest) (*TokenRefreshResponse, error) -} - -func RegisterLoginServiceHTTPServer(s *http.Server, srv LoginServiceHTTPServer) { - r := s.Route("/") - r.GET("/captcha", _LoginService_Captcha0_HTTP_Handler(srv)) - r.GET("/captcha/id", _LoginService_CaptchaId0_HTTP_Handler(srv)) - r.GET("/captcha/image", _LoginService_CaptchaImage0_HTTP_Handler(srv)) - r.GET("/captcha/audio", _LoginService_CaptchaAudio0_HTTP_Handler(srv)) - r.POST("/login", _LoginService_Login0_HTTP_Handler(srv)) - r.POST("/logout", _LoginService_Logout0_HTTP_Handler(srv)) - r.POST("/register", _LoginService_Register0_HTTP_Handler(srv)) - r.POST("/token/refresh", _LoginService_TokenRefresh0_HTTP_Handler(srv)) -} - -func _LoginService_Captcha0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptcha) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Captcha(ctx, req.(*CaptchaRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_CaptchaId0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaIdRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaId) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaId(ctx, req.(*CaptchaIdRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaIdResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_CaptchaImage0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaImageRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaImage) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaImage(ctx, req.(*CaptchaImageRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaImageResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_CaptchaAudio0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in CaptchaAudioRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceCaptchaAudio) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CaptchaAudio(ctx, req.(*CaptchaAudioRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*CaptchaAudioResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_Login0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in LoginRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceLogin) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Login(ctx, req.(*LoginRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*LoginResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_Logout0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in LogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Logout(ctx, req.(*LogoutRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*LogoutResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_Register0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RegisterRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceRegister) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Register(ctx, req.(*RegisterRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*RegisterResponse) - return ctx.Result(200, reply) - } -} - -func _LoginService_TokenRefresh0_HTTP_Handler(srv LoginServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in TokenRefreshRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationLoginServiceTokenRefresh) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.TokenRefresh(ctx, req.(*TokenRefreshRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*TokenRefreshResponse) - return ctx.Result(200, reply) - } -} - -type LoginServiceHTTPClient interface { - Captcha(ctx context.Context, req *CaptchaRequest, opts ...http.CallOption) (rsp *CaptchaResponse, err error) - CaptchaAudio(ctx context.Context, req *CaptchaAudioRequest, opts ...http.CallOption) (rsp *CaptchaAudioResponse, err error) - CaptchaId(ctx context.Context, req *CaptchaIdRequest, opts ...http.CallOption) (rsp *CaptchaIdResponse, err error) - CaptchaImage(ctx context.Context, req *CaptchaImageRequest, opts ...http.CallOption) (rsp *CaptchaImageResponse, err error) - Login(ctx context.Context, req *LoginRequest, opts ...http.CallOption) (rsp *LoginResponse, err error) - Logout(ctx context.Context, req *LogoutRequest, opts ...http.CallOption) (rsp *LogoutResponse, err error) - Register(ctx context.Context, req *RegisterRequest, opts ...http.CallOption) (rsp *RegisterResponse, err error) - TokenRefresh(ctx context.Context, req *TokenRefreshRequest, opts ...http.CallOption) (rsp *TokenRefreshResponse, err error) -} - -type LoginServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewLoginServiceHTTPClient(client *http.Client) LoginServiceHTTPClient { - return &LoginServiceHTTPClientImpl{client} -} - -func (c *LoginServiceHTTPClientImpl) Captcha(ctx context.Context, in *CaptchaRequest, opts ...http.CallOption) (*CaptchaResponse, error) { - var out CaptchaResponse - pattern := "/captcha" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationLoginServiceCaptcha)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) CaptchaAudio(ctx context.Context, in *CaptchaAudioRequest, opts ...http.CallOption) (*CaptchaAudioResponse, error) { - var out CaptchaAudioResponse - pattern := "/captcha/audio" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationLoginServiceCaptchaAudio)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) CaptchaId(ctx context.Context, in *CaptchaIdRequest, opts ...http.CallOption) (*CaptchaIdResponse, error) { - var out CaptchaIdResponse - pattern := "/captcha/id" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationLoginServiceCaptchaId)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) CaptchaImage(ctx context.Context, in *CaptchaImageRequest, opts ...http.CallOption) (*CaptchaImageResponse, error) { - var out CaptchaImageResponse - pattern := "/captcha/image" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationLoginServiceCaptchaImage)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) Login(ctx context.Context, in *LoginRequest, opts ...http.CallOption) (*LoginResponse, error) { - var out LoginResponse - pattern := "/login" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationLoginServiceLogin)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) Logout(ctx context.Context, in *LogoutRequest, opts ...http.CallOption) (*LogoutResponse, error) { - var out LogoutResponse - pattern := "/logout" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationLoginServiceLogout)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) Register(ctx context.Context, in *RegisterRequest, opts ...http.CallOption) (*RegisterResponse, error) { - var out RegisterResponse - pattern := "/register" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationLoginServiceRegister)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *LoginServiceHTTPClientImpl) TokenRefresh(ctx context.Context, in *TokenRefreshRequest, opts ...http.CallOption) (*TokenRefreshResponse, error) { - var out TokenRefreshResponse - pattern := "/token/refresh" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationLoginServiceTokenRefresh)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/auth/me.pb.go b/api/v1/services/auth/me.pb.go new file mode 100644 index 00000000..2da67f34 --- /dev/null +++ b/api/v1/services/auth/me.pb.go @@ -0,0 +1,422 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: auth/me.proto + +package auth + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// The request message for the GetProfile RPC. +type GetProfileRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetProfileRequest) Reset() { + *x = GetProfileRequest{} + mi := &file_auth_me_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProfileRequest) ProtoMessage() {} + +func (x *GetProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_me_proto_msgTypes[0] + 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 GetProfileRequest.ProtoReflect.Descriptor instead. +func (*GetProfileRequest) Descriptor() ([]byte, []int) { + return file_auth_me_proto_rawDescGZIP(), []int{0} +} + +// The request message for the UpdateProfile RPC. +type UpdateProfileRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The fields to update. + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateProfileRequest) Reset() { + *x = UpdateProfileRequest{} + mi := &file_auth_me_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateProfileRequest) ProtoMessage() {} + +func (x *UpdateProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_me_proto_msgTypes[1] + 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 UpdateProfileRequest.ProtoReflect.Descriptor instead. +func (*UpdateProfileRequest) Descriptor() ([]byte, []int) { + return file_auth_me_proto_rawDescGZIP(), []int{1} +} + +func (x *UpdateProfileRequest) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + +// The request message for the UpdatePassword RPC. +type UpdatePasswordRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + OldPassword string `protobuf:"bytes,1,opt,name=old_password,json=oldPassword,proto3" json:"old_password,omitempty"` + NewPassword string `protobuf:"bytes,2,opt,name=new_password,json=newPassword,proto3" json:"new_password,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePasswordRequest) Reset() { + *x = UpdatePasswordRequest{} + mi := &file_auth_me_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePasswordRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePasswordRequest) ProtoMessage() {} + +func (x *UpdatePasswordRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_me_proto_msgTypes[2] + 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 UpdatePasswordRequest.ProtoReflect.Descriptor instead. +func (*UpdatePasswordRequest) Descriptor() ([]byte, []int) { + return file_auth_me_proto_rawDescGZIP(), []int{2} +} + +func (x *UpdatePasswordRequest) GetOldPassword() string { + if x != nil { + return x.OldPassword + } + return "" +} + +func (x *UpdatePasswordRequest) GetNewPassword() string { + if x != nil { + return x.NewPassword + } + return "" +} + +// The request message for the GetUserResources RPC. +type GetUserResourcesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserResourcesRequest) Reset() { + *x = GetUserResourcesRequest{} + mi := &file_auth_me_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserResourcesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserResourcesRequest) ProtoMessage() {} + +func (x *GetUserResourcesRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_me_proto_msgTypes[3] + 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 GetUserResourcesRequest.ProtoReflect.Descriptor instead. +func (*GetUserResourcesRequest) Descriptor() ([]byte, []int) { + return file_auth_me_proto_rawDescGZIP(), []int{3} +} + +// The response message for the GetUserResources RPC. +type GetUserResourcesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Resources []*types.Resource `protobuf:"bytes,1,rep,name=resources,proto3" json:"resources,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserResourcesResponse) Reset() { + *x = GetUserResourcesResponse{} + mi := &file_auth_me_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserResourcesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserResourcesResponse) ProtoMessage() {} + +func (x *GetUserResourcesResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_me_proto_msgTypes[4] + 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 GetUserResourcesResponse.ProtoReflect.Descriptor instead. +func (*GetUserResourcesResponse) Descriptor() ([]byte, []int) { + return file_auth_me_proto_rawDescGZIP(), []int{4} +} + +func (x *GetUserResourcesResponse) GetResources() []*types.Resource { + if x != nil { + return x.Resources + } + return nil +} + +// The request message for the GetUserRoles RPC. +type GetUserRolesRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserRolesRequest) Reset() { + *x = GetUserRolesRequest{} + mi := &file_auth_me_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserRolesRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserRolesRequest) ProtoMessage() {} + +func (x *GetUserRolesRequest) ProtoReflect() protoreflect.Message { + mi := &file_auth_me_proto_msgTypes[5] + 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 GetUserRolesRequest.ProtoReflect.Descriptor instead. +func (*GetUserRolesRequest) Descriptor() ([]byte, []int) { + return file_auth_me_proto_rawDescGZIP(), []int{5} +} + +// The response message for the GetUserRoles RPC. +type GetUserRolesResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Roles []*types.Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetUserRolesResponse) Reset() { + *x = GetUserRolesResponse{} + mi := &file_auth_me_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetUserRolesResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserRolesResponse) ProtoMessage() {} + +func (x *GetUserRolesResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_me_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 GetUserRolesResponse.ProtoReflect.Descriptor instead. +func (*GetUserRolesResponse) Descriptor() ([]byte, []int) { + return file_auth_me_proto_rawDescGZIP(), []int{6} +} + +func (x *GetUserRolesResponse) GetRoles() []*types.Role { + if x != nil { + return x.Roles + } + return nil +} + +var File_auth_me_proto protoreflect.FileDescriptor + +const file_auth_me_proto_rawDesc = "" + + "\n" + + "\rauth/me.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\x13\n" + + "\x11GetProfileRequest\"G\n" + + "\x14UpdateProfileRequest\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"]\n" + + "\x15UpdatePasswordRequest\x12!\n" + + "\fold_password\x18\x01 \x01(\tR\voldPassword\x12!\n" + + "\fnew_password\x18\x02 \x01(\tR\vnewPassword\"\x19\n" + + "\x17GetUserResourcesRequest\"Y\n" + + "\x18GetUserResourcesResponse\x12=\n" + + "\tresources\x18\x01 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"\x15\n" + + "\x13GetUserRolesRequest\"I\n" + + "\x14GetUserRolesResponse\x121\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles2\xf2\x04\n" + + "\x02Me\x12n\n" + + "\n" + + "GetProfile\x12'.api.v1.services.auth.GetProfileRequest\x1a\x1b.api.v1.services.types.User\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/api/v1/me/profile\x12r\n" + + "\rUpdateProfile\x12*.api.v1.services.auth.UpdateProfileRequest\x1a\x16.google.protobuf.Empty\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\x1a\x12/api/v1/me/profile\x12u\n" + + "\x0eUpdatePassword\x12+.api.v1.services.auth.UpdatePasswordRequest\x1a\x16.google.protobuf.Empty\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\x1a\x13/api/v1/me/password\x12\x8f\x01\n" + + "\x10GetUserResources\x12-.api.v1.services.auth.GetUserResourcesRequest\x1a..api.v1.services.auth.GetUserResourcesResponse\"\x1c\x82\xd3\xe4\x93\x02\x16\x12\x14/api/v1/me/resources\x12\x7f\n" + + "\fGetUserRoles\x12).api.v1.services.auth.GetUserRolesRequest\x1a*.api.v1.services.auth.GetUserRolesResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/api/v1/me/rolesB\xce\x01\n" + + "\x18com.api.v1.services.authB\aMeProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + +var ( + file_auth_me_proto_rawDescOnce sync.Once + file_auth_me_proto_rawDescData []byte +) + +func file_auth_me_proto_rawDescGZIP() []byte { + file_auth_me_proto_rawDescOnce.Do(func() { + file_auth_me_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_me_proto_rawDesc), len(file_auth_me_proto_rawDesc))) + }) + return file_auth_me_proto_rawDescData +} + +var file_auth_me_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_auth_me_proto_goTypes = []any{ + (*GetProfileRequest)(nil), // 0: api.v1.services.auth.GetProfileRequest + (*UpdateProfileRequest)(nil), // 1: api.v1.services.auth.UpdateProfileRequest + (*UpdatePasswordRequest)(nil), // 2: api.v1.services.auth.UpdatePasswordRequest + (*GetUserResourcesRequest)(nil), // 3: api.v1.services.auth.GetUserResourcesRequest + (*GetUserResourcesResponse)(nil), // 4: api.v1.services.auth.GetUserResourcesResponse + (*GetUserRolesRequest)(nil), // 5: api.v1.services.auth.GetUserRolesRequest + (*GetUserRolesResponse)(nil), // 6: api.v1.services.auth.GetUserRolesResponse + (*types.User)(nil), // 7: api.v1.services.types.User + (*types.Resource)(nil), // 8: api.v1.services.types.Resource + (*types.Role)(nil), // 9: api.v1.services.types.Role + (*emptypb.Empty)(nil), // 10: google.protobuf.Empty +} +var file_auth_me_proto_depIdxs = []int32{ + 7, // 0: api.v1.services.auth.UpdateProfileRequest.user:type_name -> api.v1.services.types.User + 8, // 1: api.v1.services.auth.GetUserResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 9, // 2: api.v1.services.auth.GetUserRolesResponse.roles:type_name -> api.v1.services.types.Role + 0, // 3: api.v1.services.auth.Me.GetProfile:input_type -> api.v1.services.auth.GetProfileRequest + 1, // 4: api.v1.services.auth.Me.UpdateProfile:input_type -> api.v1.services.auth.UpdateProfileRequest + 2, // 5: api.v1.services.auth.Me.UpdatePassword:input_type -> api.v1.services.auth.UpdatePasswordRequest + 3, // 6: api.v1.services.auth.Me.GetUserResources:input_type -> api.v1.services.auth.GetUserResourcesRequest + 5, // 7: api.v1.services.auth.Me.GetUserRoles:input_type -> api.v1.services.auth.GetUserRolesRequest + 7, // 8: api.v1.services.auth.Me.GetProfile:output_type -> api.v1.services.types.User + 10, // 9: api.v1.services.auth.Me.UpdateProfile:output_type -> google.protobuf.Empty + 10, // 10: api.v1.services.auth.Me.UpdatePassword:output_type -> google.protobuf.Empty + 4, // 11: api.v1.services.auth.Me.GetUserResources:output_type -> api.v1.services.auth.GetUserResourcesResponse + 6, // 12: api.v1.services.auth.Me.GetUserRoles:output_type -> api.v1.services.auth.GetUserRolesResponse + 8, // [8:13] is the sub-list for method output_type + 3, // [3:8] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_auth_me_proto_init() } +func file_auth_me_proto_init() { + if File_auth_me_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_me_proto_rawDesc), len(file_auth_me_proto_rawDesc)), + NumEnums: 0, + NumMessages: 7, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_auth_me_proto_goTypes, + DependencyIndexes: file_auth_me_proto_depIdxs, + MessageInfos: file_auth_me_proto_msgTypes, + }.Build() + File_auth_me_proto = out.File + file_auth_me_proto_goTypes = nil + file_auth_me_proto_depIdxs = nil +} diff --git a/api/v1/services/auth/me.pb.gw.go b/api/v1/services/auth/me.pb.gw.go new file mode 100644 index 00000000..7538d5d9 --- /dev/null +++ b/api/v1/services/auth/me.pb.gw.go @@ -0,0 +1,391 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: auth/me.proto + +/* +Package auth is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package auth + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +func request_Me_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, client MeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetProfileRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.GetProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Me_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, server MeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetProfileRequest + metadata runtime.ServerMetadata + ) + msg, err := server.GetProfile(ctx, &protoReq) + return msg, metadata, err +} + +func request_Me_UpdateProfile_0(ctx context.Context, marshaler runtime.Marshaler, client MeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateProfileRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Me_UpdateProfile_0(ctx context.Context, marshaler runtime.Marshaler, server MeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateProfileRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateProfile(ctx, &protoReq) + return msg, metadata, err +} + +func request_Me_UpdatePassword_0(ctx context.Context, marshaler runtime.Marshaler, client MeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePasswordRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdatePassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Me_UpdatePassword_0(ctx context.Context, marshaler runtime.Marshaler, server MeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdatePasswordRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdatePassword(ctx, &protoReq) + return msg, metadata, err +} + +func request_Me_GetUserResources_0(ctx context.Context, marshaler runtime.Marshaler, client MeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetUserResourcesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.GetUserResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Me_GetUserResources_0(ctx context.Context, marshaler runtime.Marshaler, server MeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetUserResourcesRequest + metadata runtime.ServerMetadata + ) + msg, err := server.GetUserResources(ctx, &protoReq) + return msg, metadata, err +} + +func request_Me_GetUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, client MeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetUserRolesRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.GetUserRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_Me_GetUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, server MeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetUserRolesRequest + metadata runtime.ServerMetadata + ) + msg, err := server.GetUserRoles(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterMeHandlerServer registers the http handlers for service Me to "mux". +// UnaryRPC :call MeServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMeHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterMeHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MeServer) error { + mux.Handle(http.MethodGet, pattern_Me_GetProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Me/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Me_GetProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Me_GetProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_Me_UpdateProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Me/UpdateProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Me_UpdateProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Me_UpdateProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_Me_UpdatePassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Me/UpdatePassword", runtime.WithHTTPPathPattern("/api/v1/me/password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Me_UpdatePassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Me_UpdatePassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_Me_GetUserResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Me/GetUserResources", runtime.WithHTTPPathPattern("/api/v1/me/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Me_GetUserResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Me_GetUserResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_Me_GetUserRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Me/GetUserRoles", runtime.WithHTTPPathPattern("/api/v1/me/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Me_GetUserRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Me_GetUserRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterMeHandlerFromEndpoint is same as RegisterMeHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterMeHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterMeHandler(ctx, mux, conn) +} + +// RegisterMeHandler registers the http handlers for service Me to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterMeHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterMeHandlerClient(ctx, mux, NewMeClient(conn)) +} + +// RegisterMeHandlerClient registers the http handlers for service Me +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MeClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MeClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "MeClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterMeHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MeClient) error { + mux.Handle(http.MethodGet, pattern_Me_GetProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Me/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Me_GetProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Me_GetProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_Me_UpdateProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Me/UpdateProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Me_UpdateProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Me_UpdateProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_Me_UpdatePassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Me/UpdatePassword", runtime.WithHTTPPathPattern("/api/v1/me/password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Me_UpdatePassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Me_UpdatePassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_Me_GetUserResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Me/GetUserResources", runtime.WithHTTPPathPattern("/api/v1/me/resources")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Me_GetUserResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Me_GetUserResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_Me_GetUserRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Me/GetUserRoles", runtime.WithHTTPPathPattern("/api/v1/me/roles")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Me_GetUserRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_Me_GetUserRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_Me_GetProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "profile"}, "")) + pattern_Me_UpdateProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "profile"}, "")) + pattern_Me_UpdatePassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "password"}, "")) + pattern_Me_GetUserResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "resources"}, "")) + pattern_Me_GetUserRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "roles"}, "")) +) + +var ( + forward_Me_GetProfile_0 = runtime.ForwardResponseMessage + forward_Me_UpdateProfile_0 = runtime.ForwardResponseMessage + forward_Me_UpdatePassword_0 = runtime.ForwardResponseMessage + forward_Me_GetUserResources_0 = runtime.ForwardResponseMessage + forward_Me_GetUserRoles_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/auth/me.pb.validate.go b/api/v1/services/auth/me.pb.validate.go new file mode 100644 index 00000000..dbb4e73a --- /dev/null +++ b/api/v1/services/auth/me.pb.validate.go @@ -0,0 +1,851 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: auth/me.proto + +package auth + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on GetProfileRequest 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 *GetProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetProfileRequest 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 +// GetProfileRequestMultiError, or nil if none found. +func (m *GetProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetProfileRequestMultiError(errors) + } + + return nil +} + +// GetProfileRequestMultiError is an error wrapping multiple validation errors +// returned by GetProfileRequest.ValidateAll() if the designated constraints +// aren't met. +type GetProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetProfileRequestMultiError) 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 GetProfileRequestMultiError) AllErrors() []error { return m } + +// GetProfileRequestValidationError is the validation error returned by +// GetProfileRequest.Validate if the designated constraints aren't met. +type GetProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetProfileRequestValidationError) ErrorName() string { + return "GetProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetProfileRequestValidationError) 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 %sGetProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetProfileRequestValidationError{} + +// Validate checks the field values on UpdateProfileRequest 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 *UpdateProfileRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateProfileRequest 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 +// UpdateProfileRequestMultiError, or nil if none found. +func (m *UpdateProfileRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateProfileRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateProfileRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateProfileRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateProfileRequestValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateProfileRequestMultiError(errors) + } + + return nil +} + +// UpdateProfileRequestMultiError is an error wrapping multiple validation +// errors returned by UpdateProfileRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdateProfileRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateProfileRequestMultiError) 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 UpdateProfileRequestMultiError) AllErrors() []error { return m } + +// UpdateProfileRequestValidationError is the validation error returned by +// UpdateProfileRequest.Validate if the designated constraints aren't met. +type UpdateProfileRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateProfileRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateProfileRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateProfileRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateProfileRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateProfileRequestValidationError) ErrorName() string { + return "UpdateProfileRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateProfileRequestValidationError) 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 %sUpdateProfileRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateProfileRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateProfileRequestValidationError{} + +// Validate checks the field values on UpdatePasswordRequest 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 *UpdatePasswordRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePasswordRequest 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 +// UpdatePasswordRequestMultiError, or nil if none found. +func (m *UpdatePasswordRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePasswordRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for OldPassword + + // no validation rules for NewPassword + + if len(errors) > 0 { + return UpdatePasswordRequestMultiError(errors) + } + + return nil +} + +// UpdatePasswordRequestMultiError is an error wrapping multiple validation +// errors returned by UpdatePasswordRequest.ValidateAll() if the designated +// constraints aren't met. +type UpdatePasswordRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePasswordRequestMultiError) 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 UpdatePasswordRequestMultiError) AllErrors() []error { return m } + +// UpdatePasswordRequestValidationError is the validation error returned by +// UpdatePasswordRequest.Validate if the designated constraints aren't met. +type UpdatePasswordRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePasswordRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePasswordRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePasswordRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePasswordRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePasswordRequestValidationError) ErrorName() string { + return "UpdatePasswordRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePasswordRequestValidationError) 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 %sUpdatePasswordRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePasswordRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePasswordRequestValidationError{} + +// Validate checks the field values on GetUserResourcesRequest 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 *GetUserResourcesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserResourcesRequest 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 +// GetUserResourcesRequestMultiError, or nil if none found. +func (m *GetUserResourcesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserResourcesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetUserResourcesRequestMultiError(errors) + } + + return nil +} + +// GetUserResourcesRequestMultiError is an error wrapping multiple validation +// errors returned by GetUserResourcesRequest.ValidateAll() if the designated +// constraints aren't met. +type GetUserResourcesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserResourcesRequestMultiError) 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 GetUserResourcesRequestMultiError) AllErrors() []error { return m } + +// GetUserResourcesRequestValidationError is the validation error returned by +// GetUserResourcesRequest.Validate if the designated constraints aren't met. +type GetUserResourcesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserResourcesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserResourcesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserResourcesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserResourcesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserResourcesRequestValidationError) ErrorName() string { + return "GetUserResourcesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUserResourcesRequestValidationError) 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 %sGetUserResourcesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserResourcesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserResourcesRequestValidationError{} + +// Validate checks the field values on GetUserResourcesResponse 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 *GetUserResourcesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserResourcesResponse 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 +// GetUserResourcesResponseMultiError, or nil if none found. +func (m *GetUserResourcesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserResourcesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetUserResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetUserResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetUserResourcesResponseValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetUserResourcesResponseMultiError(errors) + } + + return nil +} + +// GetUserResourcesResponseMultiError is an error wrapping multiple validation +// errors returned by GetUserResourcesResponse.ValidateAll() if the designated +// constraints aren't met. +type GetUserResourcesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserResourcesResponseMultiError) 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 GetUserResourcesResponseMultiError) AllErrors() []error { return m } + +// GetUserResourcesResponseValidationError is the validation error returned by +// GetUserResourcesResponse.Validate if the designated constraints aren't met. +type GetUserResourcesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserResourcesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserResourcesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserResourcesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserResourcesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserResourcesResponseValidationError) ErrorName() string { + return "GetUserResourcesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUserResourcesResponseValidationError) 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 %sGetUserResourcesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserResourcesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserResourcesResponseValidationError{} + +// Validate checks the field values on GetUserRolesRequest 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 *GetUserRolesRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserRolesRequest 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 +// GetUserRolesRequestMultiError, or nil if none found. +func (m *GetUserRolesRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserRolesRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return GetUserRolesRequestMultiError(errors) + } + + return nil +} + +// GetUserRolesRequestMultiError is an error wrapping multiple validation +// errors returned by GetUserRolesRequest.ValidateAll() if the designated +// constraints aren't met. +type GetUserRolesRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserRolesRequestMultiError) 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 GetUserRolesRequestMultiError) AllErrors() []error { return m } + +// GetUserRolesRequestValidationError is the validation error returned by +// GetUserRolesRequest.Validate if the designated constraints aren't met. +type GetUserRolesRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserRolesRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserRolesRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserRolesRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserRolesRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserRolesRequestValidationError) ErrorName() string { + return "GetUserRolesRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUserRolesRequestValidationError) 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 %sGetUserRolesRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserRolesRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserRolesRequestValidationError{} + +// Validate checks the field values on GetUserRolesResponse 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 *GetUserRolesResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetUserRolesResponse 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 +// GetUserRolesResponseMultiError, or nil if none found. +func (m *GetUserRolesResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetUserRolesResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + for idx, item := range m.GetRoles() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetUserRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetUserRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetUserRolesResponseValidationError{ + field: fmt.Sprintf("Roles[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return GetUserRolesResponseMultiError(errors) + } + + return nil +} + +// GetUserRolesResponseMultiError is an error wrapping multiple validation +// errors returned by GetUserRolesResponse.ValidateAll() if the designated +// constraints aren't met. +type GetUserRolesResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetUserRolesResponseMultiError) 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 GetUserRolesResponseMultiError) AllErrors() []error { return m } + +// GetUserRolesResponseValidationError is the validation error returned by +// GetUserRolesResponse.Validate if the designated constraints aren't met. +type GetUserRolesResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetUserRolesResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetUserRolesResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetUserRolesResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetUserRolesResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetUserRolesResponseValidationError) ErrorName() string { + return "GetUserRolesResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetUserRolesResponseValidationError) 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 %sGetUserRolesResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetUserRolesResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetUserRolesResponseValidationError{} diff --git a/api/v1/services/auth/me_bridge.pb.go b/api/v1/services/auth/me_bridge.pb.go new file mode 100644 index 00000000..4cc72515 --- /dev/null +++ b/api/v1/services/auth/me_bridge.pb.go @@ -0,0 +1,390 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: auth/me.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" + io "io" + types "origadmin/application/admin/api/v1/services/types" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const MeGetProfileBridgeOperation = "/api.v1.services.auth.Me/GetProfile" +const MeGetUserResourcesBridgeOperation = "/api.v1.services.auth.Me/GetUserResources" +const MeGetUserRolesBridgeOperation = "/api.v1.services.auth.Me/GetUserRoles" +const MeUpdatePasswordBridgeOperation = "/api.v1.services.auth.Me/UpdatePassword" +const MeUpdateProfileBridgeOperation = "/api.v1.services.auth.Me/UpdateProfile" + +type MeBridgeServer interface { + // GetProfile retrieves the profile of the currently authenticated user. + GetProfile(context.Context, *GetProfileRequest) (*types.User, error) + // GetUserResources retrieves the menu/resource list for the current user. + GetUserResources(context.Context, *GetUserResourcesRequest) (*GetUserResourcesResponse, error) + // GetUserRoles retrieves the role list for the current user. + GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error) + // UpdatePassword changes the password for the currently authenticated user. + UpdatePassword(context.Context, *UpdatePasswordRequest) (*emptypb.Empty, error) + // UpdateProfile updates the profile of the currently authenticated user. + UpdateProfile(context.Context, *UpdateProfileRequest) (*emptypb.Empty, error) +} + +type MeHooker interface { + MeGetProfileHooker + MeGetUserResourcesHooker + MeGetUserRolesHooker + MeUpdatePasswordHooker + MeUpdateProfileHooker +} + +type MeHookedBridger interface { + MeHooker + MeBridgeServer +} +type MeGetProfileHooker interface { + PrepareGetProfile(http.Context, *GetProfileRequest) (context.Context, error) + CompleteGetProfile(http.Context, *GetProfileRequest, *types.User) error +} +type MeGetUserResourcesHooker interface { + PrepareGetUserResources(http.Context, *GetUserResourcesRequest) (context.Context, error) + CompleteGetUserResources(http.Context, *GetUserResourcesRequest, *GetUserResourcesResponse) error +} +type MeGetUserRolesHooker interface { + PrepareGetUserRoles(http.Context, *GetUserRolesRequest) (context.Context, error) + CompleteGetUserRoles(http.Context, *GetUserRolesRequest, *GetUserRolesResponse) error +} +type MeUpdatePasswordHooker interface { + PrepareUpdatePassword(http.Context, *UpdatePasswordRequest) (context.Context, error) + CompleteUpdatePassword(http.Context, *UpdatePasswordRequest, *emptypb.Empty) error +} +type MeUpdateProfileHooker interface { + PrepareUpdateProfile(http.Context, *UpdateProfileRequest) (context.Context, error) + CompleteUpdateProfile(http.Context, *UpdateProfileRequest, *emptypb.Empty) error +} + +func RegisterMeBridgeServer(s *http.Server, srv MeHookedBridger) { + r := s.Route("/") + r.GET("/api/v1/me/profile", _Me_GetProfile0_Bridge_Handler(srv)) + r.PUT("/api/v1/me/profile", _Me_UpdateProfile0_Bridge_Handler(srv)) + r.PUT("/api/v1/me/password", _Me_UpdatePassword0_Bridge_Handler(srv)) + r.GET("/api/v1/me/resources", _Me_GetUserResources0_Bridge_Handler(srv)) + r.GET("/api/v1/me/roles", _Me_GetUserRoles0_Bridge_Handler(srv)) +} + +func _Me_GetProfile0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMeGetProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetProfile(ctx, req.(*GetProfileRequest)) + }) + + newctx, err := srv.PrepareGetProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetProfile(ctx, &in, out.(*types.User)) + } +} + +func _Me_UpdateProfile0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateProfileRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMeUpdateProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateProfile(ctx, req.(*UpdateProfileRequest)) + }) + + newctx, err := srv.PrepareUpdateProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateProfile(ctx, &in, out.(*emptypb.Empty)) + } +} + +func _Me_UpdatePassword0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePasswordRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMeUpdatePassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePassword(ctx, req.(*UpdatePasswordRequest)) + }) + + newctx, err := srv.PrepareUpdatePassword(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdatePassword(ctx, &in, out.(*emptypb.Empty)) + } +} + +func _Me_GetUserResources0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUserResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMeGetUserResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUserResources(ctx, req.(*GetUserResourcesRequest)) + }) + + newctx, err := srv.PrepareGetUserResources(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetUserResources(ctx, &in, out.(*GetUserResourcesResponse)) + } +} + +func _Me_GetUserRoles0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUserRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMeGetUserRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUserRoles(ctx, req.(*GetUserRolesRequest)) + }) + + newctx, err := srv.PrepareGetUserRoles(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetUserRoles(ctx, &in, out.(*GetUserRolesResponse)) + } +} + +// UnimplementedMeHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMeHooked struct{} + +func (UnimplementedMeHooked) PrepareGetProfile(ctx http.Context, in *GetProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMeHooked) CompleteGetProfile(ctx http.Context, in *GetProfileRequest, out *types.User) error { + return ctx.Result(200, out) +} + +func (UnimplementedMeHooked) PrepareGetUserResources(ctx http.Context, in *GetUserResourcesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMeHooked) CompleteGetUserResources(ctx http.Context, in *GetUserResourcesRequest, out *GetUserResourcesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedMeHooked) PrepareGetUserRoles(ctx http.Context, in *GetUserRolesRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMeHooked) CompleteGetUserRoles(ctx http.Context, in *GetUserRolesRequest, out *GetUserRolesResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedMeHooked) PrepareUpdatePassword(ctx http.Context, in *UpdatePasswordRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMeHooked) CompleteUpdatePassword(ctx http.Context, in *UpdatePasswordRequest, out *emptypb.Empty) error { + return ctx.Result(200, out) +} + +func (UnimplementedMeHooked) PrepareUpdateProfile(ctx http.Context, in *UpdateProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedMeHooked) CompleteUpdateProfile(ctx http.Context, in *UpdateProfileRequest, out *emptypb.Empty) error { + return ctx.Result(200, out) +} + +func WithMeHook(h MeHooker) func(MeBridgeServer) MeHookedBridger { + return func(srv MeBridgeServer) MeHookedBridger { + return MeHookedBridge{MeBridgeServer: srv, MeHooker: h} + } +} + +// MeHookedBridge is a bridge between the HTTP and gRPC implementations of Me. +// It implements the HTTP and gRPC implementations of Me. +// It forwards requests and responses between the two implementations. +type MeHookedBridge struct { + MeBridgeServer + MeHooker +} + +type MeHTTPBridgeImpl struct { + client MeHTTPClient +} + +func NewMeHTTPBridge(client *http.Client) MeHTTPServer { + return &MeHTTPBridgeImpl{client: NewMeHTTPClient(client)} +} + +func (c *MeHTTPBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*types.User, error) { + return c.client.GetProfile(ctx, in) +} + +func (c *MeHTTPBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { + return c.client.GetUserResources(ctx, in) +} + +func (c *MeHTTPBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { + return c.client.GetUserRoles(ctx, in) +} + +func (c *MeHTTPBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*emptypb.Empty, error) { + return c.client.UpdatePassword(ctx, in) +} + +func (c *MeHTTPBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*emptypb.Empty, error) { + return c.client.UpdateProfile(ctx, in) +} + +type MeBridgeImpl struct { + client MeClient +} + +func NewMeBridge(client grpc.ClientConnInterface) MeServer { + return &MeBridgeImpl{client: NewMeClient(client)} +} + +func (c *MeBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*types.User, error) { + return c.client.GetProfile(ctx, in) +} + +func (c *MeBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { + return c.client.GetUserResources(ctx, in) +} + +func (c *MeBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { + return c.client.GetUserRoles(ctx, in) +} + +func (c *MeBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*emptypb.Empty, error) { + return c.client.UpdatePassword(ctx, in) +} + +func (c *MeBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*emptypb.Empty, error) { + return c.client.UpdateProfile(ctx, in) +} + +func (c *MeBridgeImpl) mustEmbedUnimplementedMeServer() {} + +type MeGRPC2HTTPBridgeImpl struct { + client MeClient +} + +func NewMeGRPC2HTTP(client grpc.ClientConnInterface) MeHTTPServer { + return &MeGRPC2HTTPBridgeImpl{client: NewMeClient(client)} +} + +func (c *MeGRPC2HTTPBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*types.User, error) { + return c.client.GetProfile(ctx, in) +} + +func (c *MeGRPC2HTTPBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { + return c.client.GetUserResources(ctx, in) +} + +func (c *MeGRPC2HTTPBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { + return c.client.GetUserRoles(ctx, in) +} + +func (c *MeGRPC2HTTPBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*emptypb.Empty, error) { + return c.client.UpdatePassword(ctx, in) +} + +func (c *MeGRPC2HTTPBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*emptypb.Empty, error) { + return c.client.UpdateProfile(ctx, in) +} + +type MeHTTP2GRPCBridgeImpl struct { + client MeHTTPClient +} + +func NewMeHTTP2GRPC(client *http.Client) MeServer { + return &MeHTTP2GRPCBridgeImpl{client: NewMeHTTPClient(client)} +} + +func (c *MeHTTP2GRPCBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*types.User, error) { + return c.client.GetProfile(ctx, in) +} + +func (c *MeHTTP2GRPCBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { + return c.client.GetUserResources(ctx, in) +} + +func (c *MeHTTP2GRPCBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { + return c.client.GetUserRoles(ctx, in) +} + +func (c *MeHTTP2GRPCBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*emptypb.Empty, error) { + return c.client.UpdatePassword(ctx, in) +} + +func (c *MeHTTP2GRPCBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*emptypb.Empty, error) { + return c.client.UpdateProfile(ctx, in) +} + +func (c *MeHTTP2GRPCBridgeImpl) mustEmbedUnimplementedMeServer() {} diff --git a/api/v1/services/auth/me_grpc.pb.go b/api/v1/services/auth/me_grpc.pb.go new file mode 100644 index 00000000..923edec7 --- /dev/null +++ b/api/v1/services/auth/me_grpc.pb.go @@ -0,0 +1,289 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: auth/me.proto + +package auth + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Me_GetProfile_FullMethodName = "/api.v1.services.auth.Me/GetProfile" + Me_UpdateProfile_FullMethodName = "/api.v1.services.auth.Me/UpdateProfile" + Me_UpdatePassword_FullMethodName = "/api.v1.services.auth.Me/UpdatePassword" + Me_GetUserResources_FullMethodName = "/api.v1.services.auth.Me/GetUserResources" + Me_GetUserRoles_FullMethodName = "/api.v1.services.auth.Me/GetUserRoles" +) + +// MeClient is the client API for Me service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Service Me provides APIs for the currently authenticated user to manage their own profile and data. +type MeClient interface { + // GetProfile retrieves the profile of the currently authenticated user. + GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*types.User, error) + // UpdateProfile updates the profile of the currently authenticated user. + UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + // UpdatePassword changes the password for the currently authenticated user. + UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + // GetUserResources retrieves the menu/resource list for the current user. + GetUserResources(ctx context.Context, in *GetUserResourcesRequest, opts ...grpc.CallOption) (*GetUserResourcesResponse, error) + // GetUserRoles retrieves the role list for the current user. + GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...grpc.CallOption) (*GetUserRolesResponse, error) +} + +type meClient struct { + cc grpc.ClientConnInterface +} + +func NewMeClient(cc grpc.ClientConnInterface) MeClient { + return &meClient{cc} +} + +func (c *meClient) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*types.User, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(types.User) + err := c.cc.Invoke(ctx, Me_GetProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *meClient) UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Me_UpdateProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *meClient) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Me_UpdatePassword_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *meClient) GetUserResources(ctx context.Context, in *GetUserResourcesRequest, opts ...grpc.CallOption) (*GetUserResourcesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetUserResourcesResponse) + err := c.cc.Invoke(ctx, Me_GetUserResources_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *meClient) GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...grpc.CallOption) (*GetUserRolesResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetUserRolesResponse) + err := c.cc.Invoke(ctx, Me_GetUserRoles_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MeServer is the server API for Me service. +// All implementations must embed UnimplementedMeServer +// for forward compatibility. +// +// Service Me provides APIs for the currently authenticated user to manage their own profile and data. +type MeServer interface { + // GetProfile retrieves the profile of the currently authenticated user. + GetProfile(context.Context, *GetProfileRequest) (*types.User, error) + // UpdateProfile updates the profile of the currently authenticated user. + UpdateProfile(context.Context, *UpdateProfileRequest) (*emptypb.Empty, error) + // UpdatePassword changes the password for the currently authenticated user. + UpdatePassword(context.Context, *UpdatePasswordRequest) (*emptypb.Empty, error) + // GetUserResources retrieves the menu/resource list for the current user. + GetUserResources(context.Context, *GetUserResourcesRequest) (*GetUserResourcesResponse, error) + // GetUserRoles retrieves the role list for the current user. + GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error) + mustEmbedUnimplementedMeServer() +} + +// UnimplementedMeServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedMeServer struct{} + +func (UnimplementedMeServer) GetProfile(context.Context, *GetProfileRequest) (*types.User, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProfile not implemented") +} +func (UnimplementedMeServer) UpdateProfile(context.Context, *UpdateProfileRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateProfile not implemented") +} +func (UnimplementedMeServer) UpdatePassword(context.Context, *UpdatePasswordRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdatePassword not implemented") +} +func (UnimplementedMeServer) GetUserResources(context.Context, *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUserResources not implemented") +} +func (UnimplementedMeServer) GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUserRoles not implemented") +} +func (UnimplementedMeServer) mustEmbedUnimplementedMeServer() {} +func (UnimplementedMeServer) testEmbeddedByValue() {} + +// UnsafeMeServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MeServer will +// result in compilation errors. +type UnsafeMeServer interface { + mustEmbedUnimplementedMeServer() +} + +func RegisterMeServer(s grpc.ServiceRegistrar, srv MeServer) { + // If the following call pancis, it indicates UnimplementedMeServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&Me_ServiceDesc, srv) +} + +func _Me_GetProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MeServer).GetProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Me_GetProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MeServer).GetProfile(ctx, req.(*GetProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Me_UpdateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MeServer).UpdateProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Me_UpdateProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MeServer).UpdateProfile(ctx, req.(*UpdateProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Me_UpdatePassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdatePasswordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MeServer).UpdatePassword(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Me_UpdatePassword_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MeServer).UpdatePassword(ctx, req.(*UpdatePasswordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Me_GetUserResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserResourcesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MeServer).GetUserResources(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Me_GetUserResources_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MeServer).GetUserResources(ctx, req.(*GetUserResourcesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Me_GetUserRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserRolesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MeServer).GetUserRoles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Me_GetUserRoles_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MeServer).GetUserRoles(ctx, req.(*GetUserRolesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Me_ServiceDesc is the grpc.ServiceDesc for Me service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Me_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.auth.Me", + HandlerType: (*MeServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetProfile", + Handler: _Me_GetProfile_Handler, + }, + { + MethodName: "UpdateProfile", + Handler: _Me_UpdateProfile_Handler, + }, + { + MethodName: "UpdatePassword", + Handler: _Me_UpdatePassword_Handler, + }, + { + MethodName: "GetUserResources", + Handler: _Me_GetUserResources_Handler, + }, + { + MethodName: "GetUserRoles", + Handler: _Me_GetUserRoles_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "auth/me.proto", +} diff --git a/api/v1/services/auth/me_http.pb.go b/api/v1/services/auth/me_http.pb.go new file mode 100644 index 00000000..60fe09ad --- /dev/null +++ b/api/v1/services/auth/me_http.pb.go @@ -0,0 +1,242 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: auth/me.proto + +package auth + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationMeGetProfile = "/api.v1.services.auth.Me/GetProfile" +const OperationMeGetUserResources = "/api.v1.services.auth.Me/GetUserResources" +const OperationMeGetUserRoles = "/api.v1.services.auth.Me/GetUserRoles" +const OperationMeUpdatePassword = "/api.v1.services.auth.Me/UpdatePassword" +const OperationMeUpdateProfile = "/api.v1.services.auth.Me/UpdateProfile" + +type MeHTTPServer interface { + // GetProfile GetProfile retrieves the profile of the currently authenticated user. + GetProfile(context.Context, *GetProfileRequest) (*types.User, error) + // GetUserResources GetUserResources retrieves the menu/resource list for the current user. + GetUserResources(context.Context, *GetUserResourcesRequest) (*GetUserResourcesResponse, error) + // GetUserRoles GetUserRoles retrieves the role list for the current user. + GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error) + // UpdatePassword UpdatePassword changes the password for the currently authenticated user. + UpdatePassword(context.Context, *UpdatePasswordRequest) (*emptypb.Empty, error) + // UpdateProfile UpdateProfile updates the profile of the currently authenticated user. + UpdateProfile(context.Context, *UpdateProfileRequest) (*emptypb.Empty, error) +} + +func RegisterMeHTTPServer(s *http.Server, srv MeHTTPServer) { + r := s.Route("/") + r.GET("/api/v1/me/profile", _Me_GetProfile0_HTTP_Handler(srv)) + r.PUT("/api/v1/me/profile", _Me_UpdateProfile0_HTTP_Handler(srv)) + r.PUT("/api/v1/me/password", _Me_UpdatePassword0_HTTP_Handler(srv)) + r.GET("/api/v1/me/resources", _Me_GetUserResources0_HTTP_Handler(srv)) + r.GET("/api/v1/me/roles", _Me_GetUserRoles0_HTTP_Handler(srv)) +} + +func _Me_GetProfile0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMeGetProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetProfile(ctx, req.(*GetProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*types.User) + return ctx.Result(200, reply) + } +} + +func _Me_UpdateProfile0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateProfileRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMeUpdateProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateProfile(ctx, req.(*UpdateProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*emptypb.Empty) + return ctx.Result(200, reply) + } +} + +func _Me_UpdatePassword0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdatePasswordRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMeUpdatePassword) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdatePassword(ctx, req.(*UpdatePasswordRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*emptypb.Empty) + return ctx.Result(200, reply) + } +} + +func _Me_GetUserResources0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUserResourcesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMeGetUserResources) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUserResources(ctx, req.(*GetUserResourcesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetUserResourcesResponse) + return ctx.Result(200, reply) + } +} + +func _Me_GetUserRoles0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetUserRolesRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationMeGetUserRoles) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUserRoles(ctx, req.(*GetUserRolesRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetUserRolesResponse) + return ctx.Result(200, reply) + } +} + +type MeHTTPClient interface { + // GetProfile GetProfile retrieves the profile of the currently authenticated user. + GetProfile(ctx context.Context, req *GetProfileRequest, opts ...http.CallOption) (rsp *types.User, err error) + // GetUserResources GetUserResources retrieves the menu/resource list for the current user. + GetUserResources(ctx context.Context, req *GetUserResourcesRequest, opts ...http.CallOption) (rsp *GetUserResourcesResponse, err error) + // GetUserRoles GetUserRoles retrieves the role list for the current user. + GetUserRoles(ctx context.Context, req *GetUserRolesRequest, opts ...http.CallOption) (rsp *GetUserRolesResponse, err error) + // UpdatePassword UpdatePassword changes the password for the currently authenticated user. + UpdatePassword(ctx context.Context, req *UpdatePasswordRequest, opts ...http.CallOption) (rsp *emptypb.Empty, err error) + // UpdateProfile UpdateProfile updates the profile of the currently authenticated user. + UpdateProfile(ctx context.Context, req *UpdateProfileRequest, opts ...http.CallOption) (rsp *emptypb.Empty, err error) +} + +type MeHTTPClientImpl struct { + cc *http.Client +} + +func NewMeHTTPClient(client *http.Client) MeHTTPClient { + return &MeHTTPClientImpl{client} +} + +// GetProfile GetProfile retrieves the profile of the currently authenticated user. +func (c *MeHTTPClientImpl) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...http.CallOption) (*types.User, error) { + var out types.User + pattern := "/api/v1/me/profile" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationMeGetProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// GetUserResources GetUserResources retrieves the menu/resource list for the current user. +func (c *MeHTTPClientImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest, opts ...http.CallOption) (*GetUserResourcesResponse, error) { + var out GetUserResourcesResponse + pattern := "/api/v1/me/resources" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationMeGetUserResources)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// GetUserRoles GetUserRoles retrieves the role list for the current user. +func (c *MeHTTPClientImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...http.CallOption) (*GetUserRolesResponse, error) { + var out GetUserRolesResponse + pattern := "/api/v1/me/roles" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationMeGetUserRoles)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdatePassword UpdatePassword changes the password for the currently authenticated user. +func (c *MeHTTPClientImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...http.CallOption) (*emptypb.Empty, error) { + var out emptypb.Empty + pattern := "/api/v1/me/password" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationMeUpdatePassword)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdateProfile UpdateProfile updates the profile of the currently authenticated user. +func (c *MeHTTPClientImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...http.CallOption) (*emptypb.Empty, error) { + var out emptypb.Empty + pattern := "/api/v1/me/profile" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationMeUpdateProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/auth/personal.pb.go b/api/v1/services/auth/personal.pb.go deleted file mode 100644 index 5d73ceaf..00000000 --- a/api/v1/services/auth/personal.pb.go +++ /dev/null @@ -1,1074 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: auth/personal.proto - -package auth - -import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - anypb "google.golang.org/protobuf/types/known/anypb" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - sync "sync" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type UpdatePersonalSettingRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalSettingRequest) Reset() { - *x = UpdatePersonalSettingRequest{} - mi := &file_auth_personal_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalSettingRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalSettingRequest) ProtoMessage() {} - -func (x *UpdatePersonalSettingRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[0] - 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 UpdatePersonalSettingRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalSettingRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{0} -} - -func (x *UpdatePersonalSettingRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalSettingResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalSettingResponse) Reset() { - *x = UpdatePersonalSettingResponse{} - mi := &file_auth_personal_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalSettingResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalSettingResponse) ProtoMessage() {} - -func (x *UpdatePersonalSettingResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[1] - 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 UpdatePersonalSettingResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalSettingResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{1} -} - -type UpdatePersonalRoleRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Role *types.Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalRoleRequest) Reset() { - *x = UpdatePersonalRoleRequest{} - mi := &file_auth_personal_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalRoleRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalRoleRequest) ProtoMessage() {} - -func (x *UpdatePersonalRoleRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[2] - 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 UpdatePersonalRoleRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalRoleRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{2} -} - -func (x *UpdatePersonalRoleRequest) GetRole() *types.Role { - if x != nil { - return x.Role - } - return nil -} - -type UpdatePersonalRoleResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalRoleResponse) Reset() { - *x = UpdatePersonalRoleResponse{} - mi := &file_auth_personal_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalRoleResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalRoleResponse) ProtoMessage() {} - -func (x *UpdatePersonalRoleResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[3] - 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 UpdatePersonalRoleResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalRoleResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{3} -} - -type ListPersonalResourcesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The parent resource id, for example, "shelves/shelf1". - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The current page number. - Current int32 `protobuf:"varint,2,opt,name=current,proto3" json:"current,omitempty"` - // The maximum number of items to return. - PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` - // The next_page_token value returned from a previous List request, if any. - PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` - // The no_paging is used to disable pagination. - NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` - // The only_count is the query parameter for set only to query the total number - OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalResourcesRequest) Reset() { - *x = ListPersonalResourcesRequest{} - mi := &file_auth_personal_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalResourcesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalResourcesRequest) ProtoMessage() {} - -func (x *ListPersonalResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[4] - 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 ListPersonalResourcesRequest.ProtoReflect.Descriptor instead. -func (*ListPersonalResourcesRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{4} -} - -func (x *ListPersonalResourcesRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetCurrent() int32 { - if x != nil { - return x.Current - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetPageSize() int32 { - if x != nil { - return x.PageSize - } - return 0 -} - -func (x *ListPersonalResourcesRequest) GetPageToken() string { - if x != nil { - return x.PageToken - } - return "" -} - -func (x *ListPersonalResourcesRequest) GetNoPaging() bool { - if x != nil { - return x.NoPaging - } - return false -} - -func (x *ListPersonalResourcesRequest) GetOnlyCount() bool { - if x != nil { - return x.OnlyCount - } - return false -} - -type ListPersonalResourcesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The total number of items in the list. - TotalSize int64 `protobuf:"varint,1,opt,name=total_size,json=total,proto3" json:"total_size,omitempty"` - // list of resources - Resources []*types.Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` - // Token to retrieve the next page of results, or empty if there are no - // more results in the list. - NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalResourcesResponse) Reset() { - *x = ListPersonalResourcesResponse{} - mi := &file_auth_personal_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalResourcesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalResourcesResponse) ProtoMessage() {} - -func (x *ListPersonalResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[5] - 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 ListPersonalResourcesResponse.ProtoReflect.Descriptor instead. -func (*ListPersonalResourcesResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{5} -} - -func (x *ListPersonalResourcesResponse) GetTotalSize() int64 { - if x != nil { - return x.TotalSize - } - return 0 -} - -func (x *ListPersonalResourcesResponse) GetResources() []*types.Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *ListPersonalResourcesResponse) GetNextPageToken() string { - if x != nil { - return x.NextPageToken - } - return "" -} - -type UpdatePersonalPasswordRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalPasswordRequest) Reset() { - *x = UpdatePersonalPasswordRequest{} - mi := &file_auth_personal_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalPasswordRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalPasswordRequest) ProtoMessage() {} - -func (x *UpdatePersonalPasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_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 UpdatePersonalPasswordRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalPasswordRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{6} -} - -func (x *UpdatePersonalPasswordRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalPasswordResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalPasswordResponse) Reset() { - *x = UpdatePersonalPasswordResponse{} - mi := &file_auth_personal_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalPasswordResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalPasswordResponse) ProtoMessage() {} - -func (x *UpdatePersonalPasswordResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UpdatePersonalPasswordResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalPasswordResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{7} -} - -type PersonalPasswordRestRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalPasswordRestRequest) Reset() { - *x = PersonalPasswordRestRequest{} - mi := &file_auth_personal_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalPasswordRestRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalPasswordRestRequest) ProtoMessage() {} - -func (x *PersonalPasswordRestRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[8] - 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 PersonalPasswordRestRequest.ProtoReflect.Descriptor instead. -func (*PersonalPasswordRestRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{8} -} - -func (x *PersonalPasswordRestRequest) GetId() int64 { - if x != nil { - return x.Id - } - return 0 -} - -type PersonalPasswordRestResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalPasswordRestResponse) Reset() { - *x = PersonalPasswordRestResponse{} - mi := &file_auth_personal_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalPasswordRestResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalPasswordRestResponse) ProtoMessage() {} - -func (x *PersonalPasswordRestResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[9] - 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 PersonalPasswordRestResponse.ProtoReflect.Descriptor instead. -func (*PersonalPasswordRestResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{9} -} - -type UpdatePersonalProfileRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalProfileRequest) Reset() { - *x = UpdatePersonalProfileRequest{} - mi := &file_auth_personal_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalProfileRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalProfileRequest) ProtoMessage() {} - -func (x *UpdatePersonalProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[10] - 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 UpdatePersonalProfileRequest.ProtoReflect.Descriptor instead. -func (*UpdatePersonalProfileRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{10} -} - -func (x *UpdatePersonalProfileRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type UpdatePersonalProfileResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UpdatePersonalProfileResponse) Reset() { - *x = UpdatePersonalProfileResponse{} - mi := &file_auth_personal_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UpdatePersonalProfileResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UpdatePersonalProfileResponse) ProtoMessage() {} - -func (x *UpdatePersonalProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[11] - 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 UpdatePersonalProfileResponse.ProtoReflect.Descriptor instead. -func (*UpdatePersonalProfileResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{11} -} - -type PersonalLogoutRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalLogoutRequest) Reset() { - *x = PersonalLogoutRequest{} - mi := &file_auth_personal_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalLogoutRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalLogoutRequest) ProtoMessage() {} - -func (x *PersonalLogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[12] - 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 PersonalLogoutRequest.ProtoReflect.Descriptor instead. -func (*PersonalLogoutRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{12} -} - -func (x *PersonalLogoutRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type PersonalLogoutResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PersonalLogoutResponse) Reset() { - *x = PersonalLogoutResponse{} - mi := &file_auth_personal_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PersonalLogoutResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PersonalLogoutResponse) ProtoMessage() {} - -func (x *PersonalLogoutResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[13] - 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 PersonalLogoutResponse.ProtoReflect.Descriptor instead. -func (*PersonalLogoutResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{13} -} - -func (x *PersonalLogoutResponse) GetSuccess() bool { - if x != nil { - return x.Success - } - return false -} - -type ListPersonalRolesRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalRolesRequest) Reset() { - *x = ListPersonalRolesRequest{} - mi := &file_auth_personal_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalRolesRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalRolesRequest) ProtoMessage() {} - -func (x *ListPersonalRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[14] - 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 ListPersonalRolesRequest.ProtoReflect.Descriptor instead. -func (*ListPersonalRolesRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{14} -} - -type ListPersonalRolesResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Roles []*types.Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ListPersonalRolesResponse) Reset() { - *x = ListPersonalRolesResponse{} - mi := &file_auth_personal_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ListPersonalRolesResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ListPersonalRolesResponse) ProtoMessage() {} - -func (x *ListPersonalRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[15] - 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 ListPersonalRolesResponse.ProtoReflect.Descriptor instead. -func (*ListPersonalRolesResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{15} -} - -func (x *ListPersonalRolesResponse) GetRoles() []*types.Role { - if x != nil { - return x.Roles - } - return nil -} - -type GetPersonalProfileRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPersonalProfileRequest) Reset() { - *x = GetPersonalProfileRequest{} - mi := &file_auth_personal_proto_msgTypes[16] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPersonalProfileRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPersonalProfileRequest) ProtoMessage() {} - -func (x *GetPersonalProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[16] - 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 GetPersonalProfileRequest.ProtoReflect.Descriptor instead. -func (*GetPersonalProfileRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{16} -} - -type GetPersonalProfileResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *GetPersonalProfileResponse) Reset() { - *x = GetPersonalProfileResponse{} - mi := &file_auth_personal_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *GetPersonalProfileResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetPersonalProfileResponse) ProtoMessage() {} - -func (x *GetPersonalProfileResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[17] - 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 GetPersonalProfileResponse.ProtoReflect.Descriptor instead. -func (*GetPersonalProfileResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{17} -} - -func (x *GetPersonalProfileResponse) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - -type RefreshPersonalTokenRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - Data *anypb.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RefreshPersonalTokenRequest) Reset() { - *x = RefreshPersonalTokenRequest{} - mi := &file_auth_personal_proto_msgTypes[18] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RefreshPersonalTokenRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RefreshPersonalTokenRequest) ProtoMessage() {} - -func (x *RefreshPersonalTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[18] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RefreshPersonalTokenRequest.ProtoReflect.Descriptor instead. -func (*RefreshPersonalTokenRequest) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{18} -} - -func (x *RefreshPersonalTokenRequest) GetData() *anypb.Any { - if x != nil { - return x.Data - } - return nil -} - -type RefreshPersonalTokenResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RefreshPersonalTokenResponse) Reset() { - *x = RefreshPersonalTokenResponse{} - mi := &file_auth_personal_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RefreshPersonalTokenResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RefreshPersonalTokenResponse) ProtoMessage() {} - -func (x *RefreshPersonalTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_personal_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RefreshPersonalTokenResponse.ProtoReflect.Descriptor instead. -func (*RefreshPersonalTokenResponse) Descriptor() ([]byte, []int) { - return file_auth_personal_proto_rawDescGZIP(), []int{19} -} - -func (x *RefreshPersonalTokenResponse) GetToken() string { - if x != nil { - return x.Token - } - return "" -} - -var File_auth_personal_proto protoreflect.FileDescriptor - -const file_auth_personal_proto_rawDesc = "" + - "\n" + - "\x13auth/personal.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x12types/system.proto\x1a\x17validate/validate.proto\"H\n" + - "\x1cUpdatePersonalSettingRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + - "\x1dUpdatePersonalSettingResponse\"L\n" + - "\x19UpdatePersonalRoleRequest\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\x1c\n" + - "\x1aUpdatePersonalRoleResponse\"\xc4\x01\n" + - "\x1cListPersonalResourcesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + - "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + - "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + - "\n" + - "page_token\x18\x04 \x01(\tR\n" + - "page_token\x12\x1c\n" + - "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + - "\n" + - "only_count\x18\x06 \x01(\bR\n" + - "only_count\"\xa3\x01\n" + - "\x1dListPersonalResourcesResponse\x12\x19\n" + - "\n" + - "total_size\x18\x01 \x01(\x03R\x05total\x12=\n" + - "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12(\n" + - "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\"I\n" + - "\x1dUpdatePersonalPasswordRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\" \n" + - "\x1eUpdatePersonalPasswordResponse\"6\n" + - "\x1bPersonalPasswordRestRequest\x12\x17\n" + - "\x02id\x18\x01 \x01(\x03B\a\xfaB\x04\"\x02 \x00R\x02id\"\x1e\n" + - "\x1cPersonalPasswordRestResponse\"H\n" + - "\x1cUpdatePersonalProfileRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"\x1f\n" + - "\x1dUpdatePersonalProfileResponse\"A\n" + - "\x15PersonalLogoutRequest\x12(\n" + - "\x04data\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x04data\"2\n" + - "\x16PersonalLogoutResponse\x12\x18\n" + - "\asuccess\x18\x01 \x01(\bR\asuccess\"\x1a\n" + - "\x18ListPersonalRolesRequest\"N\n" + - "\x19ListPersonalRolesResponse\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x1b\n" + - "\x19GetPersonalProfileRequest\"M\n" + - "\x1aGetPersonalProfileResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + - "\x1bRefreshPersonalTokenRequest\x12(\n" + - "\x04data\x18\x01 \x01(\v2\x14.google.protobuf.AnyR\x04data\"4\n" + - "\x1cRefreshPersonalTokenResponse\x12\x14\n" + - "\x05token\x18\x01 \x01(\tR\x05token2\xa3\n" + - "\n" + - "\x0fPersonalService\x12\x97\x01\n" + - "\x12GetPersonalProfile\x12/.api.v1.services.auth.GetPersonalProfileRequest\x1a0.api.v1.services.auth.GetPersonalProfileResponse\"\x1e\x82\xd3\xe4\x93\x02\x18\x12\x16/auth/personal/profile\x12\xa2\x01\n" + - "\x15ListPersonalResources\x122.api.v1.services.auth.ListPersonalResourcesRequest\x1a3.api.v1.services.auth.ListPersonalResourcesResponse\" \x82\xd3\xe4\x93\x02\x1a\x12\x18/auth/personal/resources\x12\x92\x01\n" + - "\x11ListPersonalRoles\x12..api.v1.services.auth.ListPersonalRolesRequest\x1a/.api.v1.services.auth.ListPersonalRolesResponse\"\x1c\x82\xd3\xe4\x93\x02\x16\x12\x14/auth/personal/roles\x12\x90\x01\n" + - "\x0ePersonalLogout\x12+.api.v1.services.auth.PersonalLogoutRequest\x1a,.api.v1.services.auth.PersonalLogoutResponse\"#\x82\xd3\xe4\x93\x02\x1d:\x04data\"\x15/auth/personal/logout\x12\xa9\x01\n" + - "\x14RefreshPersonalToken\x121.api.v1.services.auth.RefreshPersonalTokenRequest\x1a2.api.v1.services.auth.RefreshPersonalTokenResponse\"*\x82\xd3\xe4\x93\x02$:\x04data\"\x1c/auth/personal/token/refresh\x12\xaa\x01\n" + - "\x16UpdatePersonalPassword\x123.api.v1.services.auth.UpdatePersonalPasswordRequest\x1a4.api.v1.services.auth.UpdatePersonalPasswordResponse\"%\x82\xd3\xe4\x93\x02\x1f:\x04data\x1a\x17/auth/personal/password\x12\xa6\x01\n" + - "\x15UpdatePersonalProfile\x122.api.v1.services.auth.UpdatePersonalProfileRequest\x1a3.api.v1.services.auth.UpdatePersonalProfileResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/profile\x12\xa6\x01\n" + - "\x15UpdatePersonalSetting\x122.api.v1.services.auth.UpdatePersonalSettingRequest\x1a3.api.v1.services.auth.UpdatePersonalSettingResponse\"$\x82\xd3\xe4\x93\x02\x1e:\x04data\x1a\x16/auth/personal/settingB\xd4\x01\n" + - "\x18com.api.v1.services.authB\rPersonalProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" - -var ( - file_auth_personal_proto_rawDescOnce sync.Once - file_auth_personal_proto_rawDescData []byte -) - -func file_auth_personal_proto_rawDescGZIP() []byte { - file_auth_personal_proto_rawDescOnce.Do(func() { - file_auth_personal_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_personal_proto_rawDesc), len(file_auth_personal_proto_rawDesc))) - }) - return file_auth_personal_proto_rawDescData -} - -var file_auth_personal_proto_msgTypes = make([]protoimpl.MessageInfo, 20) -var file_auth_personal_proto_goTypes = []any{ - (*UpdatePersonalSettingRequest)(nil), // 0: api.v1.services.auth.UpdatePersonalSettingRequest - (*UpdatePersonalSettingResponse)(nil), // 1: api.v1.services.auth.UpdatePersonalSettingResponse - (*UpdatePersonalRoleRequest)(nil), // 2: api.v1.services.auth.UpdatePersonalRoleRequest - (*UpdatePersonalRoleResponse)(nil), // 3: api.v1.services.auth.UpdatePersonalRoleResponse - (*ListPersonalResourcesRequest)(nil), // 4: api.v1.services.auth.ListPersonalResourcesRequest - (*ListPersonalResourcesResponse)(nil), // 5: api.v1.services.auth.ListPersonalResourcesResponse - (*UpdatePersonalPasswordRequest)(nil), // 6: api.v1.services.auth.UpdatePersonalPasswordRequest - (*UpdatePersonalPasswordResponse)(nil), // 7: api.v1.services.auth.UpdatePersonalPasswordResponse - (*PersonalPasswordRestRequest)(nil), // 8: api.v1.services.auth.PersonalPasswordRestRequest - (*PersonalPasswordRestResponse)(nil), // 9: api.v1.services.auth.PersonalPasswordRestResponse - (*UpdatePersonalProfileRequest)(nil), // 10: api.v1.services.auth.UpdatePersonalProfileRequest - (*UpdatePersonalProfileResponse)(nil), // 11: api.v1.services.auth.UpdatePersonalProfileResponse - (*PersonalLogoutRequest)(nil), // 12: api.v1.services.auth.PersonalLogoutRequest - (*PersonalLogoutResponse)(nil), // 13: api.v1.services.auth.PersonalLogoutResponse - (*ListPersonalRolesRequest)(nil), // 14: api.v1.services.auth.ListPersonalRolesRequest - (*ListPersonalRolesResponse)(nil), // 15: api.v1.services.auth.ListPersonalRolesResponse - (*GetPersonalProfileRequest)(nil), // 16: api.v1.services.auth.GetPersonalProfileRequest - (*GetPersonalProfileResponse)(nil), // 17: api.v1.services.auth.GetPersonalProfileResponse - (*RefreshPersonalTokenRequest)(nil), // 18: api.v1.services.auth.RefreshPersonalTokenRequest - (*RefreshPersonalTokenResponse)(nil), // 19: api.v1.services.auth.RefreshPersonalTokenResponse - (*anypb.Any)(nil), // 20: google.protobuf.Any - (*types.Role)(nil), // 21: api.v1.services.types.Role - (*types.Resource)(nil), // 22: api.v1.services.types.Resource - (*types.User)(nil), // 23: api.v1.services.types.User -} -var file_auth_personal_proto_depIdxs = []int32{ - 20, // 0: api.v1.services.auth.UpdatePersonalSettingRequest.data:type_name -> google.protobuf.Any - 21, // 1: api.v1.services.auth.UpdatePersonalRoleRequest.role:type_name -> api.v1.services.types.Role - 22, // 2: api.v1.services.auth.ListPersonalResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 20, // 3: api.v1.services.auth.UpdatePersonalPasswordRequest.data:type_name -> google.protobuf.Any - 20, // 4: api.v1.services.auth.UpdatePersonalProfileRequest.data:type_name -> google.protobuf.Any - 20, // 5: api.v1.services.auth.PersonalLogoutRequest.data:type_name -> google.protobuf.Any - 21, // 6: api.v1.services.auth.ListPersonalRolesResponse.roles:type_name -> api.v1.services.types.Role - 23, // 7: api.v1.services.auth.GetPersonalProfileResponse.user:type_name -> api.v1.services.types.User - 20, // 8: api.v1.services.auth.RefreshPersonalTokenRequest.data:type_name -> google.protobuf.Any - 16, // 9: api.v1.services.auth.PersonalService.GetPersonalProfile:input_type -> api.v1.services.auth.GetPersonalProfileRequest - 4, // 10: api.v1.services.auth.PersonalService.ListPersonalResources:input_type -> api.v1.services.auth.ListPersonalResourcesRequest - 14, // 11: api.v1.services.auth.PersonalService.ListPersonalRoles:input_type -> api.v1.services.auth.ListPersonalRolesRequest - 12, // 12: api.v1.services.auth.PersonalService.PersonalLogout:input_type -> api.v1.services.auth.PersonalLogoutRequest - 18, // 13: api.v1.services.auth.PersonalService.RefreshPersonalToken:input_type -> api.v1.services.auth.RefreshPersonalTokenRequest - 6, // 14: api.v1.services.auth.PersonalService.UpdatePersonalPassword:input_type -> api.v1.services.auth.UpdatePersonalPasswordRequest - 10, // 15: api.v1.services.auth.PersonalService.UpdatePersonalProfile:input_type -> api.v1.services.auth.UpdatePersonalProfileRequest - 0, // 16: api.v1.services.auth.PersonalService.UpdatePersonalSetting:input_type -> api.v1.services.auth.UpdatePersonalSettingRequest - 17, // 17: api.v1.services.auth.PersonalService.GetPersonalProfile:output_type -> api.v1.services.auth.GetPersonalProfileResponse - 5, // 18: api.v1.services.auth.PersonalService.ListPersonalResources:output_type -> api.v1.services.auth.ListPersonalResourcesResponse - 15, // 19: api.v1.services.auth.PersonalService.ListPersonalRoles:output_type -> api.v1.services.auth.ListPersonalRolesResponse - 13, // 20: api.v1.services.auth.PersonalService.PersonalLogout:output_type -> api.v1.services.auth.PersonalLogoutResponse - 19, // 21: api.v1.services.auth.PersonalService.RefreshPersonalToken:output_type -> api.v1.services.auth.RefreshPersonalTokenResponse - 7, // 22: api.v1.services.auth.PersonalService.UpdatePersonalPassword:output_type -> api.v1.services.auth.UpdatePersonalPasswordResponse - 11, // 23: api.v1.services.auth.PersonalService.UpdatePersonalProfile:output_type -> api.v1.services.auth.UpdatePersonalProfileResponse - 1, // 24: api.v1.services.auth.PersonalService.UpdatePersonalSetting:output_type -> api.v1.services.auth.UpdatePersonalSettingResponse - 17, // [17:25] is the sub-list for method output_type - 9, // [9:17] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name -} - -func init() { file_auth_personal_proto_init() } -func file_auth_personal_proto_init() { - if File_auth_personal_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_personal_proto_rawDesc), len(file_auth_personal_proto_rawDesc)), - NumEnums: 0, - NumMessages: 20, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_auth_personal_proto_goTypes, - DependencyIndexes: file_auth_personal_proto_depIdxs, - MessageInfos: file_auth_personal_proto_msgTypes, - }.Build() - File_auth_personal_proto = out.File - file_auth_personal_proto_goTypes = nil - file_auth_personal_proto_depIdxs = nil -} diff --git a/api/v1/services/auth/personal.pb.gw.go b/api/v1/services/auth/personal.pb.gw.go deleted file mode 100644 index fb8ce2cc..00000000 --- a/api/v1/services/auth/personal.pb.gw.go +++ /dev/null @@ -1,594 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: auth/personal.proto - -/* -Package auth is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package auth - -import ( - "context" - "errors" - "io" - "net/http" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -func request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPersonalProfileRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.GetPersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_GetPersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq GetPersonalProfileRequest - metadata runtime.ServerMetadata - ) - msg, err := server.GetPersonalProfile(ctx, &protoReq) - return msg, metadata, err -} - -var filter_PersonalService_ListPersonalResources_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalResourcesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListPersonalResources(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_ListPersonalResources_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalResourcesRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PersonalService_ListPersonalResources_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListPersonalResources(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalRolesRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.ListPersonalRoles(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_ListPersonalRoles_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq ListPersonalRolesRequest - metadata runtime.ServerMetadata - ) - msg, err := server.ListPersonalRoles(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq PersonalLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.PersonalLogout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_PersonalLogout_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq PersonalLogoutRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.PersonalLogout(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RefreshPersonalTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.RefreshPersonalToken(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_RefreshPersonalToken_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq RefreshPersonalTokenRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.RefreshPersonalToken(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalPasswordRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalPassword_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalPasswordRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalPassword(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalProfileRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalProfile_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalProfileRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalProfile(ctx, &protoReq) - return msg, metadata, err -} - -func request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, client PersonalServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalSettingRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdatePersonalSetting(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_PersonalService_UpdatePersonalSetting_0(ctx context.Context, marshaler runtime.Marshaler, server PersonalServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq UpdatePersonalSettingRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Data); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdatePersonalSetting(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterPersonalServiceHandlerServer registers the http handlers for service PersonalService to "mux". -// UnaryRPC :call PersonalServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPersonalServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterPersonalServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PersonalServiceServer) error { - mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/auth/personal/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/auth/personal/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/auth/personal/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/auth/personal/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/auth/personal/password")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/auth/personal/setting")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterPersonalServiceHandlerFromEndpoint is same as RegisterPersonalServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterPersonalServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterPersonalServiceHandler(ctx, mux, conn) -} - -// RegisterPersonalServiceHandler registers the http handlers for service PersonalService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterPersonalServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterPersonalServiceHandlerClient(ctx, mux, NewPersonalServiceClient(conn)) -} - -// RegisterPersonalServiceHandlerClient registers the http handlers for service PersonalService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PersonalServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PersonalServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "PersonalServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterPersonalServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PersonalServiceClient) error { - mux.Handle(http.MethodGet, pattern_PersonalService_GetPersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/GetPersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_GetPersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_GetPersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalResources", runtime.WithHTTPPathPattern("/auth/personal/resources")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_ListPersonalResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_PersonalService_ListPersonalRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/ListPersonalRoles", runtime.WithHTTPPathPattern("/auth/personal/roles")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_ListPersonalRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_ListPersonalRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_PersonalLogout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/PersonalLogout", runtime.WithHTTPPathPattern("/auth/personal/logout")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_PersonalLogout_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_PersonalLogout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_PersonalService_RefreshPersonalToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/RefreshPersonalToken", runtime.WithHTTPPathPattern("/auth/personal/token/refresh")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_RefreshPersonalToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_RefreshPersonalToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalPassword", runtime.WithHTTPPathPattern("/auth/personal/password")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalProfile", runtime.WithHTTPPathPattern("/auth/personal/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_PersonalService_UpdatePersonalSetting_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.PersonalService/UpdatePersonalSetting", runtime.WithHTTPPathPattern("/auth/personal/setting")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_PersonalService_UpdatePersonalSetting_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_PersonalService_UpdatePersonalSetting_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_PersonalService_GetPersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "profile"}, "")) - pattern_PersonalService_ListPersonalResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "resources"}, "")) - pattern_PersonalService_ListPersonalRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "roles"}, "")) - pattern_PersonalService_PersonalLogout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "logout"}, "")) - pattern_PersonalService_RefreshPersonalToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"auth", "personal", "token", "refresh"}, "")) - pattern_PersonalService_UpdatePersonalPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "password"}, "")) - pattern_PersonalService_UpdatePersonalProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "profile"}, "")) - pattern_PersonalService_UpdatePersonalSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"auth", "personal", "setting"}, "")) -) - -var ( - forward_PersonalService_GetPersonalProfile_0 = runtime.ForwardResponseMessage - forward_PersonalService_ListPersonalResources_0 = runtime.ForwardResponseMessage - forward_PersonalService_ListPersonalRoles_0 = runtime.ForwardResponseMessage - forward_PersonalService_PersonalLogout_0 = runtime.ForwardResponseMessage - forward_PersonalService_RefreshPersonalToken_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalPassword_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalProfile_0 = runtime.ForwardResponseMessage - forward_PersonalService_UpdatePersonalSetting_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/auth/personal.pb.validate.go b/api/v1/services/auth/personal.pb.validate.go deleted file mode 100644 index 92933952..00000000 --- a/api/v1/services/auth/personal.pb.validate.go +++ /dev/null @@ -1,2390 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: auth/personal.proto - -package auth - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) - -// Validate checks the field values on UpdatePersonalSettingRequest 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 *UpdatePersonalSettingRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalSettingRequest 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 -// UpdatePersonalSettingRequestMultiError, or nil if none found. -func (m *UpdatePersonalSettingRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalSettingRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalSettingRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalSettingRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalSettingRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalSettingRequest.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalSettingRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalSettingRequestMultiError) 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 UpdatePersonalSettingRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalSettingRequestValidationError is the validation error returned -// by UpdatePersonalSettingRequest.Validate if the designated constraints -// aren't met. -type UpdatePersonalSettingRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalSettingRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalSettingRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalSettingRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalSettingRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalSettingRequestValidationError) ErrorName() string { - return "UpdatePersonalSettingRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalSettingRequestValidationError) 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 %sUpdatePersonalSettingRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalSettingRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalSettingRequestValidationError{} - -// Validate checks the field values on UpdatePersonalSettingResponse 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 *UpdatePersonalSettingResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalSettingResponse 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 -// UpdatePersonalSettingResponseMultiError, or nil if none found. -func (m *UpdatePersonalSettingResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalSettingResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalSettingResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalSettingResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalSettingResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalSettingResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalSettingResponseMultiError) 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 UpdatePersonalSettingResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalSettingResponseValidationError is the validation error -// returned by UpdatePersonalSettingResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalSettingResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalSettingResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalSettingResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalSettingResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalSettingResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalSettingResponseValidationError) ErrorName() string { - return "UpdatePersonalSettingResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalSettingResponseValidationError) 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 %sUpdatePersonalSettingResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalSettingResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalSettingResponseValidationError{} - -// Validate checks the field values on UpdatePersonalRoleRequest 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 *UpdatePersonalRoleRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalRoleRequest 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 -// UpdatePersonalRoleRequestMultiError, or nil if none found. -func (m *UpdatePersonalRoleRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalRoleRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalRoleRequestValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalRoleRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalRoleRequestMultiError is an error wrapping multiple validation -// errors returned by UpdatePersonalRoleRequest.ValidateAll() if the -// designated constraints aren't met. -type UpdatePersonalRoleRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalRoleRequestMultiError) 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 UpdatePersonalRoleRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalRoleRequestValidationError is the validation error returned by -// UpdatePersonalRoleRequest.Validate if the designated constraints aren't met. -type UpdatePersonalRoleRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalRoleRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalRoleRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalRoleRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalRoleRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalRoleRequestValidationError) ErrorName() string { - return "UpdatePersonalRoleRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalRoleRequestValidationError) 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 %sUpdatePersonalRoleRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalRoleRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalRoleRequestValidationError{} - -// Validate checks the field values on UpdatePersonalRoleResponse 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 *UpdatePersonalRoleResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalRoleResponse 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 -// UpdatePersonalRoleResponseMultiError, or nil if none found. -func (m *UpdatePersonalRoleResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalRoleResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalRoleResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalRoleResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalRoleResponse.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalRoleResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalRoleResponseMultiError) 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 UpdatePersonalRoleResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalRoleResponseValidationError is the validation error returned -// by UpdatePersonalRoleResponse.Validate if the designated constraints aren't met. -type UpdatePersonalRoleResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalRoleResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalRoleResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalRoleResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalRoleResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalRoleResponseValidationError) ErrorName() string { - return "UpdatePersonalRoleResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalRoleResponseValidationError) 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 %sUpdatePersonalRoleResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalRoleResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalRoleResponseValidationError{} - -// Validate checks the field values on ListPersonalResourcesRequest 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 *ListPersonalResourcesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalResourcesRequest 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 -// ListPersonalResourcesRequestMultiError, or nil if none found. -func (m *ListPersonalResourcesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalResourcesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for Current - - // no validation rules for PageSize - - // no validation rules for PageToken - - // no validation rules for NoPaging - - // no validation rules for OnlyCount - - if len(errors) > 0 { - return ListPersonalResourcesRequestMultiError(errors) - } - - return nil -} - -// ListPersonalResourcesRequestMultiError is an error wrapping multiple -// validation errors returned by ListPersonalResourcesRequest.ValidateAll() if -// the designated constraints aren't met. -type ListPersonalResourcesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalResourcesRequestMultiError) 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 ListPersonalResourcesRequestMultiError) AllErrors() []error { return m } - -// ListPersonalResourcesRequestValidationError is the validation error returned -// by ListPersonalResourcesRequest.Validate if the designated constraints -// aren't met. -type ListPersonalResourcesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalResourcesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalResourcesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalResourcesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalResourcesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalResourcesRequestValidationError) ErrorName() string { - return "ListPersonalResourcesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalResourcesRequestValidationError) 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 %sListPersonalResourcesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalResourcesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalResourcesRequestValidationError{} - -// Validate checks the field values on ListPersonalResourcesResponse 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 *ListPersonalResourcesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalResourcesResponse 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 -// ListPersonalResourcesResponseMultiError, or nil if none found. -func (m *ListPersonalResourcesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalResourcesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for TotalSize - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPersonalResourcesResponseValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - // no validation rules for NextPageToken - - if len(errors) > 0 { - return ListPersonalResourcesResponseMultiError(errors) - } - - return nil -} - -// ListPersonalResourcesResponseMultiError is an error wrapping multiple -// validation errors returned by ListPersonalResourcesResponse.ValidateAll() -// if the designated constraints aren't met. -type ListPersonalResourcesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalResourcesResponseMultiError) 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 ListPersonalResourcesResponseMultiError) AllErrors() []error { return m } - -// ListPersonalResourcesResponseValidationError is the validation error -// returned by ListPersonalResourcesResponse.Validate if the designated -// constraints aren't met. -type ListPersonalResourcesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalResourcesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalResourcesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalResourcesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalResourcesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalResourcesResponseValidationError) ErrorName() string { - return "ListPersonalResourcesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalResourcesResponseValidationError) 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 %sListPersonalResourcesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalResourcesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalResourcesResponseValidationError{} - -// Validate checks the field values on UpdatePersonalPasswordRequest 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 *UpdatePersonalPasswordRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalPasswordRequest 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 -// UpdatePersonalPasswordRequestMultiError, or nil if none found. -func (m *UpdatePersonalPasswordRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalPasswordRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalPasswordRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalPasswordRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalPasswordRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalPasswordRequest.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalPasswordRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalPasswordRequestMultiError) 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 UpdatePersonalPasswordRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalPasswordRequestValidationError is the validation error -// returned by UpdatePersonalPasswordRequest.Validate if the designated -// constraints aren't met. -type UpdatePersonalPasswordRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalPasswordRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalPasswordRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalPasswordRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalPasswordRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalPasswordRequestValidationError) ErrorName() string { - return "UpdatePersonalPasswordRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalPasswordRequestValidationError) 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 %sUpdatePersonalPasswordRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalPasswordRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalPasswordRequestValidationError{} - -// Validate checks the field values on UpdatePersonalPasswordResponse 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 *UpdatePersonalPasswordResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalPasswordResponse 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 -// UpdatePersonalPasswordResponseMultiError, or nil if none found. -func (m *UpdatePersonalPasswordResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalPasswordResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalPasswordResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalPasswordResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalPasswordResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalPasswordResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalPasswordResponseMultiError) 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 UpdatePersonalPasswordResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalPasswordResponseValidationError is the validation error -// returned by UpdatePersonalPasswordResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalPasswordResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalPasswordResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalPasswordResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalPasswordResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalPasswordResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalPasswordResponseValidationError) ErrorName() string { - return "UpdatePersonalPasswordResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalPasswordResponseValidationError) 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 %sUpdatePersonalPasswordResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalPasswordResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalPasswordResponseValidationError{} - -// Validate checks the field values on PersonalPasswordRestRequest 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 *PersonalPasswordRestRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalPasswordRestRequest 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 -// PersonalPasswordRestRequestMultiError, or nil if none found. -func (m *PersonalPasswordRestRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalPasswordRestRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if m.GetId() <= 0 { - err := PersonalPasswordRestRequestValidationError{ - field: "Id", - reason: "value must be greater than 0", - } - if !all { - return err - } - errors = append(errors, err) - } - - if len(errors) > 0 { - return PersonalPasswordRestRequestMultiError(errors) - } - - return nil -} - -// PersonalPasswordRestRequestMultiError is an error wrapping multiple -// validation errors returned by PersonalPasswordRestRequest.ValidateAll() if -// the designated constraints aren't met. -type PersonalPasswordRestRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalPasswordRestRequestMultiError) 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 PersonalPasswordRestRequestMultiError) AllErrors() []error { return m } - -// PersonalPasswordRestRequestValidationError is the validation error returned -// by PersonalPasswordRestRequest.Validate if the designated constraints -// aren't met. -type PersonalPasswordRestRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalPasswordRestRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalPasswordRestRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalPasswordRestRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalPasswordRestRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalPasswordRestRequestValidationError) ErrorName() string { - return "PersonalPasswordRestRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalPasswordRestRequestValidationError) 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 %sPersonalPasswordRestRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalPasswordRestRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalPasswordRestRequestValidationError{} - -// Validate checks the field values on PersonalPasswordRestResponse 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 *PersonalPasswordRestResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalPasswordRestResponse 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 -// PersonalPasswordRestResponseMultiError, or nil if none found. -func (m *PersonalPasswordRestResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalPasswordRestResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return PersonalPasswordRestResponseMultiError(errors) - } - - return nil -} - -// PersonalPasswordRestResponseMultiError is an error wrapping multiple -// validation errors returned by PersonalPasswordRestResponse.ValidateAll() if -// the designated constraints aren't met. -type PersonalPasswordRestResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalPasswordRestResponseMultiError) 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 PersonalPasswordRestResponseMultiError) AllErrors() []error { return m } - -// PersonalPasswordRestResponseValidationError is the validation error returned -// by PersonalPasswordRestResponse.Validate if the designated constraints -// aren't met. -type PersonalPasswordRestResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalPasswordRestResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalPasswordRestResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalPasswordRestResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalPasswordRestResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalPasswordRestResponseValidationError) ErrorName() string { - return "PersonalPasswordRestResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalPasswordRestResponseValidationError) 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 %sPersonalPasswordRestResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalPasswordRestResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalPasswordRestResponseValidationError{} - -// Validate checks the field values on UpdatePersonalProfileRequest 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 *UpdatePersonalProfileRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalProfileRequest 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 -// UpdatePersonalProfileRequestMultiError, or nil if none found. -func (m *UpdatePersonalProfileRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalProfileRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdatePersonalProfileRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UpdatePersonalProfileRequestMultiError(errors) - } - - return nil -} - -// UpdatePersonalProfileRequestMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalProfileRequest.ValidateAll() if -// the designated constraints aren't met. -type UpdatePersonalProfileRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalProfileRequestMultiError) 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 UpdatePersonalProfileRequestMultiError) AllErrors() []error { return m } - -// UpdatePersonalProfileRequestValidationError is the validation error returned -// by UpdatePersonalProfileRequest.Validate if the designated constraints -// aren't met. -type UpdatePersonalProfileRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalProfileRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalProfileRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalProfileRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalProfileRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalProfileRequestValidationError) ErrorName() string { - return "UpdatePersonalProfileRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalProfileRequestValidationError) 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 %sUpdatePersonalProfileRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalProfileRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalProfileRequestValidationError{} - -// Validate checks the field values on UpdatePersonalProfileResponse 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 *UpdatePersonalProfileResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UpdatePersonalProfileResponse 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 -// UpdatePersonalProfileResponseMultiError, or nil if none found. -func (m *UpdatePersonalProfileResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *UpdatePersonalProfileResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return UpdatePersonalProfileResponseMultiError(errors) - } - - return nil -} - -// UpdatePersonalProfileResponseMultiError is an error wrapping multiple -// validation errors returned by UpdatePersonalProfileResponse.ValidateAll() -// if the designated constraints aren't met. -type UpdatePersonalProfileResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UpdatePersonalProfileResponseMultiError) 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 UpdatePersonalProfileResponseMultiError) AllErrors() []error { return m } - -// UpdatePersonalProfileResponseValidationError is the validation error -// returned by UpdatePersonalProfileResponse.Validate if the designated -// constraints aren't met. -type UpdatePersonalProfileResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UpdatePersonalProfileResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UpdatePersonalProfileResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UpdatePersonalProfileResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UpdatePersonalProfileResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UpdatePersonalProfileResponseValidationError) ErrorName() string { - return "UpdatePersonalProfileResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e UpdatePersonalProfileResponseValidationError) 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 %sUpdatePersonalProfileResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UpdatePersonalProfileResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UpdatePersonalProfileResponseValidationError{} - -// Validate checks the field values on PersonalLogoutRequest 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 *PersonalLogoutRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalLogoutRequest 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 -// PersonalLogoutRequestMultiError, or nil if none found. -func (m *PersonalLogoutRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalLogoutRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PersonalLogoutRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return PersonalLogoutRequestMultiError(errors) - } - - return nil -} - -// PersonalLogoutRequestMultiError is an error wrapping multiple validation -// errors returned by PersonalLogoutRequest.ValidateAll() if the designated -// constraints aren't met. -type PersonalLogoutRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalLogoutRequestMultiError) 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 PersonalLogoutRequestMultiError) AllErrors() []error { return m } - -// PersonalLogoutRequestValidationError is the validation error returned by -// PersonalLogoutRequest.Validate if the designated constraints aren't met. -type PersonalLogoutRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalLogoutRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalLogoutRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalLogoutRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalLogoutRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalLogoutRequestValidationError) ErrorName() string { - return "PersonalLogoutRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalLogoutRequestValidationError) 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 %sPersonalLogoutRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalLogoutRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalLogoutRequestValidationError{} - -// Validate checks the field values on PersonalLogoutResponse 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 *PersonalLogoutResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PersonalLogoutResponse 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 -// PersonalLogoutResponseMultiError, or nil if none found. -func (m *PersonalLogoutResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *PersonalLogoutResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Success - - if len(errors) > 0 { - return PersonalLogoutResponseMultiError(errors) - } - - return nil -} - -// PersonalLogoutResponseMultiError is an error wrapping multiple validation -// errors returned by PersonalLogoutResponse.ValidateAll() if the designated -// constraints aren't met. -type PersonalLogoutResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PersonalLogoutResponseMultiError) 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 PersonalLogoutResponseMultiError) AllErrors() []error { return m } - -// PersonalLogoutResponseValidationError is the validation error returned by -// PersonalLogoutResponse.Validate if the designated constraints aren't met. -type PersonalLogoutResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PersonalLogoutResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PersonalLogoutResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PersonalLogoutResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PersonalLogoutResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PersonalLogoutResponseValidationError) ErrorName() string { - return "PersonalLogoutResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e PersonalLogoutResponseValidationError) 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 %sPersonalLogoutResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PersonalLogoutResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PersonalLogoutResponseValidationError{} - -// Validate checks the field values on ListPersonalRolesRequest 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 *ListPersonalRolesRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalRolesRequest 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 -// ListPersonalRolesRequestMultiError, or nil if none found. -func (m *ListPersonalRolesRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalRolesRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return ListPersonalRolesRequestMultiError(errors) - } - - return nil -} - -// ListPersonalRolesRequestMultiError is an error wrapping multiple validation -// errors returned by ListPersonalRolesRequest.ValidateAll() if the designated -// constraints aren't met. -type ListPersonalRolesRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalRolesRequestMultiError) 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 ListPersonalRolesRequestMultiError) AllErrors() []error { return m } - -// ListPersonalRolesRequestValidationError is the validation error returned by -// ListPersonalRolesRequest.Validate if the designated constraints aren't met. -type ListPersonalRolesRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalRolesRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalRolesRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalRolesRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalRolesRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalRolesRequestValidationError) ErrorName() string { - return "ListPersonalRolesRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalRolesRequestValidationError) 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 %sListPersonalRolesRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalRolesRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalRolesRequestValidationError{} - -// Validate checks the field values on ListPersonalRolesResponse 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 *ListPersonalRolesResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ListPersonalRolesResponse 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 -// ListPersonalRolesResponseMultiError, or nil if none found. -func (m *ListPersonalRolesResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *ListPersonalRolesResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ListPersonalRolesResponseValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ListPersonalRolesResponseMultiError(errors) - } - - return nil -} - -// ListPersonalRolesResponseMultiError is an error wrapping multiple validation -// errors returned by ListPersonalRolesResponse.ValidateAll() if the -// designated constraints aren't met. -type ListPersonalRolesResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ListPersonalRolesResponseMultiError) 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 ListPersonalRolesResponseMultiError) AllErrors() []error { return m } - -// ListPersonalRolesResponseValidationError is the validation error returned by -// ListPersonalRolesResponse.Validate if the designated constraints aren't met. -type ListPersonalRolesResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ListPersonalRolesResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ListPersonalRolesResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ListPersonalRolesResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ListPersonalRolesResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ListPersonalRolesResponseValidationError) ErrorName() string { - return "ListPersonalRolesResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e ListPersonalRolesResponseValidationError) 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 %sListPersonalRolesResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ListPersonalRolesResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ListPersonalRolesResponseValidationError{} - -// Validate checks the field values on GetPersonalProfileRequest 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 *GetPersonalProfileRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPersonalProfileRequest 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 -// GetPersonalProfileRequestMultiError, or nil if none found. -func (m *GetPersonalProfileRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPersonalProfileRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if len(errors) > 0 { - return GetPersonalProfileRequestMultiError(errors) - } - - return nil -} - -// GetPersonalProfileRequestMultiError is an error wrapping multiple validation -// errors returned by GetPersonalProfileRequest.ValidateAll() if the -// designated constraints aren't met. -type GetPersonalProfileRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPersonalProfileRequestMultiError) 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 GetPersonalProfileRequestMultiError) AllErrors() []error { return m } - -// GetPersonalProfileRequestValidationError is the validation error returned by -// GetPersonalProfileRequest.Validate if the designated constraints aren't met. -type GetPersonalProfileRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPersonalProfileRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPersonalProfileRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPersonalProfileRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPersonalProfileRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPersonalProfileRequestValidationError) ErrorName() string { - return "GetPersonalProfileRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPersonalProfileRequestValidationError) 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 %sGetPersonalProfileRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPersonalProfileRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPersonalProfileRequestValidationError{} - -// Validate checks the field values on GetPersonalProfileResponse 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 *GetPersonalProfileResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on GetPersonalProfileResponse 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 -// GetPersonalProfileResponseMultiError, or nil if none found. -func (m *GetPersonalProfileResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *GetPersonalProfileResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return GetPersonalProfileResponseValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return GetPersonalProfileResponseMultiError(errors) - } - - return nil -} - -// GetPersonalProfileResponseMultiError is an error wrapping multiple -// validation errors returned by GetPersonalProfileResponse.ValidateAll() if -// the designated constraints aren't met. -type GetPersonalProfileResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m GetPersonalProfileResponseMultiError) 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 GetPersonalProfileResponseMultiError) AllErrors() []error { return m } - -// GetPersonalProfileResponseValidationError is the validation error returned -// by GetPersonalProfileResponse.Validate if the designated constraints aren't met. -type GetPersonalProfileResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e GetPersonalProfileResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e GetPersonalProfileResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e GetPersonalProfileResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e GetPersonalProfileResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e GetPersonalProfileResponseValidationError) ErrorName() string { - return "GetPersonalProfileResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e GetPersonalProfileResponseValidationError) 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 %sGetPersonalProfileResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = GetPersonalProfileResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = GetPersonalProfileResponseValidationError{} - -// Validate checks the field values on RefreshPersonalTokenRequest 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 *RefreshPersonalTokenRequest) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RefreshPersonalTokenRequest 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 -// RefreshPersonalTokenRequestMultiError, or nil if none found. -func (m *RefreshPersonalTokenRequest) ValidateAll() error { - return m.validate(true) -} - -func (m *RefreshPersonalTokenRequest) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetData()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetData()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RefreshPersonalTokenRequestValidationError{ - field: "Data", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RefreshPersonalTokenRequestMultiError(errors) - } - - return nil -} - -// RefreshPersonalTokenRequestMultiError is an error wrapping multiple -// validation errors returned by RefreshPersonalTokenRequest.ValidateAll() if -// the designated constraints aren't met. -type RefreshPersonalTokenRequestMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RefreshPersonalTokenRequestMultiError) 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 RefreshPersonalTokenRequestMultiError) AllErrors() []error { return m } - -// RefreshPersonalTokenRequestValidationError is the validation error returned -// by RefreshPersonalTokenRequest.Validate if the designated constraints -// aren't met. -type RefreshPersonalTokenRequestValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RefreshPersonalTokenRequestValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RefreshPersonalTokenRequestValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RefreshPersonalTokenRequestValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RefreshPersonalTokenRequestValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RefreshPersonalTokenRequestValidationError) ErrorName() string { - return "RefreshPersonalTokenRequestValidationError" -} - -// Error satisfies the builtin error interface -func (e RefreshPersonalTokenRequestValidationError) 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 %sRefreshPersonalTokenRequest.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RefreshPersonalTokenRequestValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RefreshPersonalTokenRequestValidationError{} - -// Validate checks the field values on RefreshPersonalTokenResponse 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 *RefreshPersonalTokenResponse) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on RefreshPersonalTokenResponse 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 -// RefreshPersonalTokenResponseMultiError, or nil if none found. -func (m *RefreshPersonalTokenResponse) ValidateAll() error { - return m.validate(true) -} - -func (m *RefreshPersonalTokenResponse) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Token - - if len(errors) > 0 { - return RefreshPersonalTokenResponseMultiError(errors) - } - - return nil -} - -// RefreshPersonalTokenResponseMultiError is an error wrapping multiple -// validation errors returned by RefreshPersonalTokenResponse.ValidateAll() if -// the designated constraints aren't met. -type RefreshPersonalTokenResponseMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RefreshPersonalTokenResponseMultiError) 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 RefreshPersonalTokenResponseMultiError) AllErrors() []error { return m } - -// RefreshPersonalTokenResponseValidationError is the validation error returned -// by RefreshPersonalTokenResponse.Validate if the designated constraints -// aren't met. -type RefreshPersonalTokenResponseValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RefreshPersonalTokenResponseValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RefreshPersonalTokenResponseValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RefreshPersonalTokenResponseValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RefreshPersonalTokenResponseValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RefreshPersonalTokenResponseValidationError) ErrorName() string { - return "RefreshPersonalTokenResponseValidationError" -} - -// Error satisfies the builtin error interface -func (e RefreshPersonalTokenResponseValidationError) 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 %sRefreshPersonalTokenResponse.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RefreshPersonalTokenResponseValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RefreshPersonalTokenResponseValidationError{} diff --git a/api/v1/services/auth/personal_bridge.pb.go b/api/v1/services/auth/personal_bridge.pb.go deleted file mode 100644 index 25b430e6..00000000 --- a/api/v1/services/auth/personal_bridge.pb.go +++ /dev/null @@ -1,565 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: auth/personal.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const PersonalServiceGetPersonalProfileBridgeOperation = "/api.v1.services.auth.PersonalService/GetPersonalProfile" -const PersonalServiceListPersonalResourcesBridgeOperation = "/api.v1.services.auth.PersonalService/ListPersonalResources" -const PersonalServiceListPersonalRolesBridgeOperation = "/api.v1.services.auth.PersonalService/ListPersonalRoles" -const PersonalServicePersonalLogoutBridgeOperation = "/api.v1.services.auth.PersonalService/PersonalLogout" -const PersonalServiceRefreshPersonalTokenBridgeOperation = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" -const PersonalServiceUpdatePersonalPasswordBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" -const PersonalServiceUpdatePersonalProfileBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" -const PersonalServiceUpdatePersonalSettingBridgeOperation = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" - -type PersonalServiceBridgeServer interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) -} - -type PersonalServiceHooker interface { - PersonalServiceGetPersonalProfileHooker - PersonalServiceListPersonalResourcesHooker - PersonalServiceListPersonalRolesHooker - PersonalServicePersonalLogoutHooker - PersonalServiceRefreshPersonalTokenHooker - PersonalServiceUpdatePersonalPasswordHooker - PersonalServiceUpdatePersonalProfileHooker - PersonalServiceUpdatePersonalSettingHooker -} - -type PersonalServiceHookedBridger interface { - PersonalServiceHooker - PersonalServiceBridgeServer -} -type PersonalServiceGetPersonalProfileHooker interface { - PrepareGetPersonalProfile(http.Context, *GetPersonalProfileRequest) (context.Context, error) - CompleteGetPersonalProfile(http.Context, *GetPersonalProfileRequest, *GetPersonalProfileResponse) error -} -type PersonalServiceListPersonalResourcesHooker interface { - PrepareListPersonalResources(http.Context, *ListPersonalResourcesRequest) (context.Context, error) - CompleteListPersonalResources(http.Context, *ListPersonalResourcesRequest, *ListPersonalResourcesResponse) error -} -type PersonalServiceListPersonalRolesHooker interface { - PrepareListPersonalRoles(http.Context, *ListPersonalRolesRequest) (context.Context, error) - CompleteListPersonalRoles(http.Context, *ListPersonalRolesRequest, *ListPersonalRolesResponse) error -} -type PersonalServicePersonalLogoutHooker interface { - PreparePersonalLogout(http.Context, *PersonalLogoutRequest) (context.Context, error) - CompletePersonalLogout(http.Context, *PersonalLogoutRequest, *PersonalLogoutResponse) error -} -type PersonalServiceRefreshPersonalTokenHooker interface { - PrepareRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest) (context.Context, error) - CompleteRefreshPersonalToken(http.Context, *RefreshPersonalTokenRequest, *RefreshPersonalTokenResponse) error -} -type PersonalServiceUpdatePersonalPasswordHooker interface { - PrepareUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest) (context.Context, error) - CompleteUpdatePersonalPassword(http.Context, *UpdatePersonalPasswordRequest, *UpdatePersonalPasswordResponse) error -} -type PersonalServiceUpdatePersonalProfileHooker interface { - PrepareUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest) (context.Context, error) - CompleteUpdatePersonalProfile(http.Context, *UpdatePersonalProfileRequest, *UpdatePersonalProfileResponse) error -} -type PersonalServiceUpdatePersonalSettingHooker interface { - PrepareUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest) (context.Context, error) - CompleteUpdatePersonalSetting(http.Context, *UpdatePersonalSettingRequest, *UpdatePersonalSettingResponse) error -} - -func RegisterPersonalServiceBridgeServer(s *http.Server, srv PersonalServiceHookedBridger) { - r := s.Route("/") - r.GET("/auth/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) - r.GET("/auth/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) - r.GET("/auth/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) - r.POST("/auth/personal/logout", _PersonalService_PersonalLogout0_Bridge_Handler(srv)) - r.POST("/auth/personal/token/refresh", _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv)) - r.PUT("/auth/personal/password", _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv)) - r.PUT("/auth/personal/profile", _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv)) - r.PUT("/auth/personal/setting", _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv)) -} - -func _PersonalService_GetPersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPersonalProfileRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - }) - - newctx, err := srv.PrepareGetPersonalProfile(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetPersonalProfile(ctx, &in, out.(*GetPersonalProfileResponse)) - } -} - -func _PersonalService_ListPersonalResources0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - }) - - newctx, err := srv.PrepareListPersonalResources(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPersonalResources(ctx, &in, out.(*ListPersonalResourcesResponse)) - } -} - -func _PersonalService_ListPersonalRoles0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalRolesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - }) - - newctx, err := srv.PrepareListPersonalRoles(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListPersonalRoles(ctx, &in, out.(*ListPersonalRolesResponse)) - } -} - -func _PersonalService_PersonalLogout0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in PersonalLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServicePersonalLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - }) - - newctx, err := srv.PreparePersonalLogout(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompletePersonalLogout(ctx, &in, out.(*PersonalLogoutResponse)) - } -} - -func _PersonalService_RefreshPersonalToken0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RefreshPersonalTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - }) - - newctx, err := srv.PrepareRefreshPersonalToken(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteRefreshPersonalToken(ctx, &in, out.(*RefreshPersonalTokenResponse)) - } -} - -func _PersonalService_UpdatePersonalPassword0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalPassword(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalPassword(ctx, &in, out.(*UpdatePersonalPasswordResponse)) - } -} - -func _PersonalService_UpdatePersonalProfile0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalProfileRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalProfile(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalProfile(ctx, &in, out.(*UpdatePersonalProfileResponse)) - } -} - -func _PersonalService_UpdatePersonalSetting0_Bridge_Handler(srv PersonalServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalSettingRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - }) - - newctx, err := srv.PrepareUpdatePersonalSetting(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdatePersonalSetting(ctx, &in, out.(*UpdatePersonalSettingResponse)) - } -} - -// UnimplementedPersonalServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPersonalServiceHooked struct{} - -func (UnimplementedPersonalServiceHooked) PrepareGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteGetPersonalProfile(ctx http.Context, in *GetPersonalProfileRequest, out *GetPersonalProfileResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteListPersonalResources(ctx http.Context, in *ListPersonalResourcesRequest, out *ListPersonalResourcesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteListPersonalRoles(ctx http.Context, in *ListPersonalRolesRequest, out *ListPersonalRolesResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PreparePersonalLogout(ctx http.Context, in *PersonalLogoutRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompletePersonalLogout(ctx http.Context, in *PersonalLogoutRequest, out *PersonalLogoutResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteRefreshPersonalToken(ctx http.Context, in *RefreshPersonalTokenRequest, out *RefreshPersonalTokenResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalPassword(ctx http.Context, in *UpdatePersonalPasswordRequest, out *UpdatePersonalPasswordResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalProfile(ctx http.Context, in *UpdatePersonalProfileRequest, out *UpdatePersonalProfileResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedPersonalServiceHooked) PrepareUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedPersonalServiceHooked) CompleteUpdatePersonalSetting(ctx http.Context, in *UpdatePersonalSettingRequest, out *UpdatePersonalSettingResponse) error { - return ctx.Result(200, out) -} - -func WithPersonalServiceHook(h PersonalServiceHooker) func(PersonalServiceBridgeServer) PersonalServiceHookedBridger { - return func(srv PersonalServiceBridgeServer) PersonalServiceHookedBridger { - return PersonalServiceHookedBridge{PersonalServiceBridgeServer: srv, PersonalServiceHooker: h} - } -} - -// PersonalServiceHookedBridge is a bridge between the HTTP and gRPC implementations of PersonalService. -// It implements the HTTP and gRPC implementations of PersonalService. -// It forwards requests and responses between the two implementations. -type PersonalServiceHookedBridge struct { - PersonalServiceBridgeServer - PersonalServiceHooker -} - -type PersonalServiceHTTPBridgeImpl struct { - client PersonalServiceHTTPClient -} - -func NewPersonalServiceHTTPBridge(client *http.Client) PersonalServiceHTTPServer { - return &PersonalServiceHTTPBridgeImpl{client: NewPersonalServiceHTTPClient(client)} -} - -func (c *PersonalServiceHTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -type PersonalServiceBridgeImpl struct { - client PersonalServiceClient -} - -func NewPersonalServiceBridge(client grpc.ClientConnInterface) PersonalServiceServer { - return &PersonalServiceBridgeImpl{client: NewPersonalServiceClient(client)} -} - -func (c *PersonalServiceBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -func (c *PersonalServiceBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} - -type PersonalServiceGRPC2HTTPBridgeImpl struct { - client PersonalServiceClient -} - -func NewPersonalServiceGRPC2HTTP(client grpc.ClientConnInterface) PersonalServiceHTTPServer { - return &PersonalServiceGRPC2HTTPBridgeImpl{client: NewPersonalServiceClient(client)} -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceGRPC2HTTPBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -type PersonalServiceHTTP2GRPCBridgeImpl struct { - client PersonalServiceHTTPClient -} - -func NewPersonalServiceHTTP2GRPC(client *http.Client) PersonalServiceServer { - return &PersonalServiceHTTP2GRPCBridgeImpl{client: NewPersonalServiceHTTPClient(client)} -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return c.client.GetPersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return c.client.ListPersonalResources(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return c.client.ListPersonalRoles(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return c.client.PersonalLogout(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return c.client.RefreshPersonalToken(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return c.client.UpdatePersonalPassword(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return c.client.UpdatePersonalProfile(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return c.client.UpdatePersonalSetting(ctx, in) -} - -func (c *PersonalServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPersonalServiceServer() {} diff --git a/api/v1/services/auth/personal_grpc.pb.go b/api/v1/services/auth/personal_grpc.pb.go deleted file mode 100644 index 6f4d95e8..00000000 --- a/api/v1/services/auth/personal_grpc.pb.go +++ /dev/null @@ -1,407 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: auth/personal.proto - -package auth - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - PersonalService_GetPersonalProfile_FullMethodName = "/api.v1.services.auth.PersonalService/GetPersonalProfile" - PersonalService_ListPersonalResources_FullMethodName = "/api.v1.services.auth.PersonalService/ListPersonalResources" - PersonalService_ListPersonalRoles_FullMethodName = "/api.v1.services.auth.PersonalService/ListPersonalRoles" - PersonalService_PersonalLogout_FullMethodName = "/api.v1.services.auth.PersonalService/PersonalLogout" - PersonalService_RefreshPersonalToken_FullMethodName = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" - PersonalService_UpdatePersonalPassword_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" - PersonalService_UpdatePersonalProfile_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" - PersonalService_UpdatePersonalSetting_FullMethodName = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" -) - -// PersonalServiceClient is the client API for PersonalService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// PersonalService Personal user service -type PersonalServiceClient interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) -} - -type personalServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewPersonalServiceClient(cc grpc.ClientConnInterface) PersonalServiceClient { - return &personalServiceClient{cc} -} - -func (c *personalServiceClient) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...grpc.CallOption) (*GetPersonalProfileResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetPersonalProfileResponse) - err := c.cc.Invoke(ctx, PersonalService_GetPersonalProfile_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...grpc.CallOption) (*ListPersonalResourcesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPersonalResourcesResponse) - err := c.cc.Invoke(ctx, PersonalService_ListPersonalResources_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...grpc.CallOption) (*ListPersonalRolesResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ListPersonalRolesResponse) - err := c.cc.Invoke(ctx, PersonalService_ListPersonalRoles_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...grpc.CallOption) (*PersonalLogoutResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(PersonalLogoutResponse) - err := c.cc.Invoke(ctx, PersonalService_PersonalLogout_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...grpc.CallOption) (*RefreshPersonalTokenResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(RefreshPersonalTokenResponse) - err := c.cc.Invoke(ctx, PersonalService_RefreshPersonalToken_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...grpc.CallOption) (*UpdatePersonalPasswordResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalPasswordResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalPassword_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...grpc.CallOption) (*UpdatePersonalProfileResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalProfileResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalProfile_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *personalServiceClient) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...grpc.CallOption) (*UpdatePersonalSettingResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdatePersonalSettingResponse) - err := c.cc.Invoke(ctx, PersonalService_UpdatePersonalSetting_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// PersonalServiceServer is the server API for PersonalService service. -// All implementations must embed UnimplementedPersonalServiceServer -// for forward compatibility. -// -// PersonalService Personal user service -type PersonalServiceServer interface { - // GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) - mustEmbedUnimplementedPersonalServiceServer() -} - -// UnimplementedPersonalServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedPersonalServiceServer struct{} - -func (UnimplementedPersonalServiceServer) GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetPersonalProfile not implemented") -} -func (UnimplementedPersonalServiceServer) ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPersonalResources not implemented") -} -func (UnimplementedPersonalServiceServer) ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListPersonalRoles not implemented") -} -func (UnimplementedPersonalServiceServer) PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method PersonalLogout not implemented") -} -func (UnimplementedPersonalServiceServer) RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RefreshPersonalToken not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalPassword not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalProfile not implemented") -} -func (UnimplementedPersonalServiceServer) UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdatePersonalSetting not implemented") -} -func (UnimplementedPersonalServiceServer) mustEmbedUnimplementedPersonalServiceServer() {} -func (UnimplementedPersonalServiceServer) testEmbeddedByValue() {} - -// UnsafePersonalServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to PersonalServiceServer will -// result in compilation errors. -type UnsafePersonalServiceServer interface { - mustEmbedUnimplementedPersonalServiceServer() -} - -func RegisterPersonalServiceServer(s grpc.ServiceRegistrar, srv PersonalServiceServer) { - // If the following call pancis, it indicates UnimplementedPersonalServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&PersonalService_ServiceDesc, srv) -} - -func _PersonalService_GetPersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetPersonalProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).GetPersonalProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_GetPersonalProfile_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_ListPersonalResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPersonalResourcesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).ListPersonalResources(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_ListPersonalResources_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_ListPersonalRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ListPersonalRolesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).ListPersonalRoles(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_ListPersonalRoles_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_PersonalLogout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PersonalLogoutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).PersonalLogout(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_PersonalLogout_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_RefreshPersonalToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RefreshPersonalTokenRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_RefreshPersonalToken_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalPasswordRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalPassword_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalProfile_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _PersonalService_UpdatePersonalSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdatePersonalSettingRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: PersonalService_UpdatePersonalSetting_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PersonalServiceServer).UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// PersonalService_ServiceDesc is the grpc.ServiceDesc for PersonalService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var PersonalService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.auth.PersonalService", - HandlerType: (*PersonalServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "GetPersonalProfile", - Handler: _PersonalService_GetPersonalProfile_Handler, - }, - { - MethodName: "ListPersonalResources", - Handler: _PersonalService_ListPersonalResources_Handler, - }, - { - MethodName: "ListPersonalRoles", - Handler: _PersonalService_ListPersonalRoles_Handler, - }, - { - MethodName: "PersonalLogout", - Handler: _PersonalService_PersonalLogout_Handler, - }, - { - MethodName: "RefreshPersonalToken", - Handler: _PersonalService_RefreshPersonalToken_Handler, - }, - { - MethodName: "UpdatePersonalPassword", - Handler: _PersonalService_UpdatePersonalPassword_Handler, - }, - { - MethodName: "UpdatePersonalProfile", - Handler: _PersonalService_UpdatePersonalProfile_Handler, - }, - { - MethodName: "UpdatePersonalSetting", - Handler: _PersonalService_UpdatePersonalSetting_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "auth/personal.proto", -} diff --git a/api/v1/services/auth/personal_http.pb.go b/api/v1/services/auth/personal_http.pb.go deleted file mode 100644 index 1d00a291..00000000 --- a/api/v1/services/auth/personal_http.pb.go +++ /dev/null @@ -1,366 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: auth/personal.proto - -package auth - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationPersonalServiceGetPersonalProfile = "/api.v1.services.auth.PersonalService/GetPersonalProfile" -const OperationPersonalServiceListPersonalResources = "/api.v1.services.auth.PersonalService/ListPersonalResources" -const OperationPersonalServiceListPersonalRoles = "/api.v1.services.auth.PersonalService/ListPersonalRoles" -const OperationPersonalServicePersonalLogout = "/api.v1.services.auth.PersonalService/PersonalLogout" -const OperationPersonalServiceRefreshPersonalToken = "/api.v1.services.auth.PersonalService/RefreshPersonalToken" -const OperationPersonalServiceUpdatePersonalPassword = "/api.v1.services.auth.PersonalService/UpdatePersonalPassword" -const OperationPersonalServiceUpdatePersonalProfile = "/api.v1.services.auth.PersonalService/UpdatePersonalProfile" -const OperationPersonalServiceUpdatePersonalSetting = "/api.v1.services.auth.PersonalService/UpdatePersonalSetting" - -type PersonalServiceHTTPServer interface { - // GetPersonalProfile GetPersonalProfile Update the personal user information - GetPersonalProfile(context.Context, *GetPersonalProfileRequest) (*GetPersonalProfileResponse, error) - // ListPersonalResources ListPersonalResources List the personal user's menu - ListPersonalResources(context.Context, *ListPersonalResourcesRequest) (*ListPersonalResourcesResponse, error) - // ListPersonalRoles ListPersonalResources List the personal user's menu - ListPersonalRoles(context.Context, *ListPersonalRolesRequest) (*ListPersonalRolesResponse, error) - // PersonalLogout PersonalLogout Personal user logs out - PersonalLogout(context.Context, *PersonalLogoutRequest) (*PersonalLogoutResponse, error) - // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(context.Context, *RefreshPersonalTokenRequest) (*RefreshPersonalTokenResponse, error) - // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(context.Context, *UpdatePersonalPasswordRequest) (*UpdatePersonalPasswordResponse, error) - // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(context.Context, *UpdatePersonalProfileRequest) (*UpdatePersonalProfileResponse, error) - // UpdatePersonalSetting UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(context.Context, *UpdatePersonalSettingRequest) (*UpdatePersonalSettingResponse, error) -} - -func RegisterPersonalServiceHTTPServer(s *http.Server, srv PersonalServiceHTTPServer) { - r := s.Route("/") - r.GET("/auth/personal/profile", _PersonalService_GetPersonalProfile0_HTTP_Handler(srv)) - r.GET("/auth/personal/resources", _PersonalService_ListPersonalResources0_HTTP_Handler(srv)) - r.GET("/auth/personal/roles", _PersonalService_ListPersonalRoles0_HTTP_Handler(srv)) - r.POST("/auth/personal/logout", _PersonalService_PersonalLogout0_HTTP_Handler(srv)) - r.POST("/auth/personal/token/refresh", _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv)) - r.PUT("/auth/personal/password", _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv)) - r.PUT("/auth/personal/profile", _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv)) - r.PUT("/auth/personal/setting", _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv)) -} - -func _PersonalService_GetPersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in GetPersonalProfileRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceGetPersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetPersonalProfile(ctx, req.(*GetPersonalProfileRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*GetPersonalProfileResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_ListPersonalResources0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalResourcesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalResources) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalResources(ctx, req.(*ListPersonalResourcesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPersonalResourcesResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_ListPersonalRoles0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in ListPersonalRolesRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceListPersonalRoles) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListPersonalRoles(ctx, req.(*ListPersonalRolesRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*ListPersonalRolesResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_PersonalLogout0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in PersonalLogoutRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServicePersonalLogout) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.PersonalLogout(ctx, req.(*PersonalLogoutRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*PersonalLogoutResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_RefreshPersonalToken0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in RefreshPersonalTokenRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceRefreshPersonalToken) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.RefreshPersonalToken(ctx, req.(*RefreshPersonalTokenRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*RefreshPersonalTokenResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalPassword0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalPasswordRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalPassword) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalPassword(ctx, req.(*UpdatePersonalPasswordRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalPasswordResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalProfile0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalProfileRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalProfile(ctx, req.(*UpdatePersonalProfileRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalProfileResponse) - return ctx.Result(200, reply) - } -} - -func _PersonalService_UpdatePersonalSetting0_HTTP_Handler(srv PersonalServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in UpdatePersonalSettingRequest - if err := ctx.Bind(&in.Data); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationPersonalServiceUpdatePersonalSetting) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdatePersonalSetting(ctx, req.(*UpdatePersonalSettingRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*UpdatePersonalSettingResponse) - return ctx.Result(200, reply) - } -} - -type PersonalServiceHTTPClient interface { - // GetPersonalProfile GetPersonalProfile Update the personal user information - GetPersonalProfile(ctx context.Context, req *GetPersonalProfileRequest, opts ...http.CallOption) (rsp *GetPersonalProfileResponse, err error) - // ListPersonalResources ListPersonalResources List the personal user's menu - ListPersonalResources(ctx context.Context, req *ListPersonalResourcesRequest, opts ...http.CallOption) (rsp *ListPersonalResourcesResponse, err error) - // ListPersonalRoles ListPersonalResources List the personal user's menu - ListPersonalRoles(ctx context.Context, req *ListPersonalRolesRequest, opts ...http.CallOption) (rsp *ListPersonalRolesResponse, err error) - // PersonalLogout PersonalLogout Personal user logs out - PersonalLogout(ctx context.Context, req *PersonalLogoutRequest, opts ...http.CallOption) (rsp *PersonalLogoutResponse, err error) - // RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token - RefreshPersonalToken(ctx context.Context, req *RefreshPersonalTokenRequest, opts ...http.CallOption) (rsp *RefreshPersonalTokenResponse, err error) - // UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password - UpdatePersonalPassword(ctx context.Context, req *UpdatePersonalPasswordRequest, opts ...http.CallOption) (rsp *UpdatePersonalPasswordResponse, err error) - // UpdatePersonalProfile UpdatePersonalProfile Update the personal user information - UpdatePersonalProfile(ctx context.Context, req *UpdatePersonalProfileRequest, opts ...http.CallOption) (rsp *UpdatePersonalProfileResponse, err error) - // UpdatePersonalSetting UpdatePersonalSetting User settings are saved - UpdatePersonalSetting(ctx context.Context, req *UpdatePersonalSettingRequest, opts ...http.CallOption) (rsp *UpdatePersonalSettingResponse, err error) -} - -type PersonalServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewPersonalServiceHTTPClient(client *http.Client) PersonalServiceHTTPClient { - return &PersonalServiceHTTPClientImpl{client} -} - -// GetPersonalProfile GetPersonalProfile Update the personal user information -func (c *PersonalServiceHTTPClientImpl) GetPersonalProfile(ctx context.Context, in *GetPersonalProfileRequest, opts ...http.CallOption) (*GetPersonalProfileResponse, error) { - var out GetPersonalProfileResponse - pattern := "/auth/personal/profile" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceGetPersonalProfile)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ListPersonalResources ListPersonalResources List the personal user's menu -func (c *PersonalServiceHTTPClientImpl) ListPersonalResources(ctx context.Context, in *ListPersonalResourcesRequest, opts ...http.CallOption) (*ListPersonalResourcesResponse, error) { - var out ListPersonalResourcesResponse - pattern := "/auth/personal/resources" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceListPersonalResources)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ListPersonalRoles ListPersonalResources List the personal user's menu -func (c *PersonalServiceHTTPClientImpl) ListPersonalRoles(ctx context.Context, in *ListPersonalRolesRequest, opts ...http.CallOption) (*ListPersonalRolesResponse, error) { - var out ListPersonalRolesResponse - pattern := "/auth/personal/roles" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationPersonalServiceListPersonalRoles)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// PersonalLogout PersonalLogout Personal user logs out -func (c *PersonalServiceHTTPClientImpl) PersonalLogout(ctx context.Context, in *PersonalLogoutRequest, opts ...http.CallOption) (*PersonalLogoutResponse, error) { - var out PersonalLogoutResponse - pattern := "/auth/personal/logout" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServicePersonalLogout)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// RefreshPersonalToken RefreshPersonalToken Refresh the personal user's token -func (c *PersonalServiceHTTPClientImpl) RefreshPersonalToken(ctx context.Context, in *RefreshPersonalTokenRequest, opts ...http.CallOption) (*RefreshPersonalTokenResponse, error) { - var out RefreshPersonalTokenResponse - pattern := "/auth/personal/token/refresh" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceRefreshPersonalToken)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdatePersonalPassword UpdatePersonalProfilePassword The user changes the password -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalPassword(ctx context.Context, in *UpdatePersonalPasswordRequest, opts ...http.CallOption) (*UpdatePersonalPasswordResponse, error) { - var out UpdatePersonalPasswordResponse - pattern := "/auth/personal/password" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalPassword)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdatePersonalProfile UpdatePersonalProfile Update the personal user information -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalProfile(ctx context.Context, in *UpdatePersonalProfileRequest, opts ...http.CallOption) (*UpdatePersonalProfileResponse, error) { - var out UpdatePersonalProfileResponse - pattern := "/auth/personal/profile" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalProfile)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// UpdatePersonalSetting UpdatePersonalSetting User settings are saved -func (c *PersonalServiceHTTPClientImpl) UpdatePersonalSetting(ctx context.Context, in *UpdatePersonalSettingRequest, opts ...http.CallOption) (*UpdatePersonalSettingResponse, error) { - var out UpdatePersonalSettingResponse - pattern := "/auth/personal/setting" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationPersonalServiceUpdatePersonalSetting)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Data, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/api/v1/services/system/department.pb.go b/api/v1/services/system/department.pb.go index 090fd229..ba47090b 100644 --- a/api/v1/services/system/department.pb.go +++ b/api/v1/services/system/department.pb.go @@ -128,7 +128,7 @@ type ListDepartmentsResponse struct { state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` - // The paging menus + // The paging departments Departments []*types.Department `protobuf:"bytes,2,rep,name=departments,proto3" json:"departments,omitempty"` // The page number. Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` diff --git a/api/v1/services/system/permission.pb.go b/api/v1/services/system/permission.pb.go index d3511f86..7dd4d018 100644 --- a/api/v1/services/system/permission.pb.go +++ b/api/v1/services/system/permission.pb.go @@ -137,7 +137,7 @@ type ListPermissionsResponse struct { state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` - // The paging menus + // The paging permissions Permissions []*types.Permission `protobuf:"bytes,2,rep,name=permissions,proto3" json:"permissions,omitempty"` // The page number. Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` diff --git a/api/v1/services/system/position.pb.go b/api/v1/services/system/position.pb.go index 859ed4ff..27055225 100644 --- a/api/v1/services/system/position.pb.go +++ b/api/v1/services/system/position.pb.go @@ -128,7 +128,7 @@ type ListPositionsResponse struct { state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` - // The paging menus + // The paging positions Positions []*types.Position `protobuf:"bytes,2,rep,name=positions,proto3" json:"positions,omitempty"` // The page number. Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` diff --git a/api/v1/services/system/role.pb.go b/api/v1/services/system/role.pb.go index 2be3e16f..60714fc4 100644 --- a/api/v1/services/system/role.pb.go +++ b/api/v1/services/system/role.pb.go @@ -128,7 +128,7 @@ type ListRolesResponse struct { state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` - // The paging menus + // The paging roles Roles []*types.Role `protobuf:"bytes,2,rep,name=roles,proto3" json:"roles,omitempty"` // The page number. Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go index 3481153d..8afef874 100644 --- a/api/v1/services/system/user.pb.go +++ b/api/v1/services/system/user.pb.go @@ -408,7 +408,7 @@ type ListUsersResponse struct { state protoimpl.MessageState `protogen:"open.v1"` // The total number of items in the list. Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` - // The paging menus + // The paging users Users []*types.User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` // The page number. Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` diff --git a/internal/features/system/biz/permission.go b/internal/features/system/biz/permission.go index a6f7a40f..31235cfe 100644 --- a/internal/features/system/biz/permission.go +++ b/internal/features/system/biz/permission.go @@ -10,7 +10,6 @@ import ( "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/features/system/dto" ) @@ -34,6 +33,7 @@ func (uc *PermissionUseCase) GetPermission(ctx context.Context, id int64) (*type } func (uc *PermissionUseCase) CreatePermission(ctx context.Context, in *types.Permission) (*types.Permission, error) { + // Permission does not have a status field, so no default value is needed here. return uc.repo.Create(ctx, in) } diff --git a/internal/features/system/biz/provider.go b/internal/features/system/biz/provider.go index 6921be73..f5f7482f 100644 --- a/internal/features/system/biz/provider.go +++ b/internal/features/system/biz/provider.go @@ -16,4 +16,5 @@ var ProviderSet = wire.NewSet( NewUserUseCase, NewPermissionUseCase, NewViewUseCase, + NewPersonalUseCase, ) diff --git a/internal/features/system/biz/resource.go b/internal/features/system/biz/resource.go index da9a2555..63688de0 100644 --- a/internal/features/system/biz/resource.go +++ b/internal/features/system/biz/resource.go @@ -33,8 +33,9 @@ func (uc *ResourceUseCase) GetResource(ctx context.Context, id int64) (*types.Re return uc.repo.Get(ctx, id) } +// CreateResource creates a new resource, ensuring essential fields have valid default values. func (uc *ResourceUseCase) CreateResource(ctx context.Context, in *types.Resource) (*types.Resource, error) { - // Set business-defined default values. + // The backend must always enforce data integrity, regardless of frontend behavior. if in.Status == 0 { in.Status = int32(enums.StatusEnabled) } diff --git a/internal/features/system/biz/role.go b/internal/features/system/biz/role.go index d2c437bb..968895bd 100644 --- a/internal/features/system/biz/role.go +++ b/internal/features/system/biz/role.go @@ -33,8 +33,9 @@ func (uc *RoleUseCase) GetRole(ctx context.Context, id int64) (*types.Role, erro return uc.repo.Get(ctx, id) } +// CreateRole creates a new role, ensuring essential fields have valid default values. func (uc *RoleUseCase) CreateRole(ctx context.Context, in *types.Role) (*types.Role, error) { - // Set business-defined default values. + // The backend must always enforce data integrity, regardless of frontend behavior. if in.Status == 0 { in.Status = int32(enums.StatusEnabled) } diff --git a/internal/features/system/biz/user.go b/internal/features/system/biz/user.go index f0de4568..1bf4b561 100644 --- a/internal/features/system/biz/user.go +++ b/internal/features/system/biz/user.go @@ -53,8 +53,9 @@ func (uc *UserUseCase) GetUser(ctx context.Context, id int64) (*types.User, erro return uc.repo.Get(ctx, id) } +// CreateUser creates a new user, ensuring essential fields have valid default values. func (uc *UserUseCase) CreateUser(ctx context.Context, in *types.User, password string) (*types.User, error) { - // Set business-defined default values. + // The backend must always enforce data integrity, regardless of frontend behavior. if in.Status == 0 { in.Status = int32(enums.StatusEnabled) } diff --git a/internal/features/system/biz/view.go b/internal/features/system/biz/view.go index 7c906f5e..82a8b4a6 100644 --- a/internal/features/system/biz/view.go +++ b/internal/features/system/biz/view.go @@ -30,12 +30,11 @@ func (uc *ViewUseCase) GetView(ctx context.Context, id int64) (*types.View, erro return uc.repo.Get(ctx, id) } -// CreateView creates a new view. +// CreateView creates a new view, ensuring essential fields have valid default values. func (uc *ViewUseCase) CreateView(ctx context.Context, in *types.View) (*types.View, error) { - // Set business-defined default values before passing to the data layer. - // This is the correct layer to ensure the business object is valid. - if in.Type == "" || in.Type == dto.ViewTypeUnknown.String() { - in.Type = dto.ViewTypePage.String() + // The backend must always enforce data integrity, regardless of frontend behavior. + if in.Type == "" || in.Type == enums.ViewTypeUnknown.String() { + in.Type = enums.ViewTypePage.String() } if in.Status == 0 { in.Status = int32(enums.StatusEnabled) diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index 6cfb136d..16315495 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -74,6 +74,7 @@ func NewHTTPServer(cfg *httpv1.Server, svc *service.SystemService, logger log.Lo systemv1.RegisterPermissionServiceHTTPServer(srv, svc) systemv1.RegisterResourceServiceHTTPServer(srv, svc) systemv1.RegisterViewServiceHTTPServer(srv, svc) + systemv1.RegisterPersonalServiceHTTPServer(srv, svc) srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { log.Infof("HTTP %s %s", method, path) }) @@ -101,6 +102,7 @@ func NewGRPCServer(cfg *grpcv1.Server, svc *service.SystemService, logger log.Lo systemv1.RegisterPermissionServiceServer(srv, svc) systemv1.RegisterResourceServiceServer(srv, svc) systemv1.RegisterViewServiceServer(srv, svc) + systemv1.RegisterPersonalServiceServer(srv, svc) return srv, nil } diff --git a/internal/features/system/service/service.go b/internal/features/system/service/service.go index 28a26a62..d8320e66 100644 --- a/internal/features/system/service/service.go +++ b/internal/features/system/service/service.go @@ -15,12 +15,14 @@ type SystemService struct { system.UnimplementedUserServiceServer system.UnimplementedPermissionServiceServer system.UnimplementedViewServiceServer + system.UnimplementedPersonalServiceServer Resource *biz.ResourceUseCase Role *biz.RoleUseCase User *biz.UserUseCase Permission *biz.PermissionUseCase View *biz.ViewUseCase + Personal *biz.PersonalUseCase } func New( @@ -29,6 +31,7 @@ func New( user *biz.UserUseCase, permission *biz.PermissionUseCase, view *biz.ViewUseCase, + personal *biz.PersonalUseCase, ) *SystemService { return &SystemService{ Resource: resource, @@ -36,5 +39,6 @@ func New( User: user, Permission: permission, View: view, + Personal: personal, } } diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index de48380c..6385a94d 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -17,17 +17,17 @@ servers: - url: http://localhost:10080 - url: https://localhost:10080 paths: - /auth/authenticate: + /api/v1/auth/login: post: tags: - - AuthService - description: Authenticate authenticates a user. - operationId: AuthService_Authenticate + - Auth + description: Login authenticates a user and returns a token pair. + operationId: Auth_Login requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.AuthenticateRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.LoginRequest' required: true responses: "200": @@ -35,74 +35,68 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.AuthenticateResponse' + $ref: '#/components/schemas/api.v1.services.auth.LoginResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /auth/destroy: + /api/v1/auth/logout: post: tags: - - AuthService - description: DestroyToken invalidates a JWT token. - operationId: AuthService_DestroyToken + - Auth + description: Logout invalidates the user's session. + operationId: Auth_Logout requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.DestroyTokenRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.LogoutRequest' required: true responses: "200": description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.DestroyTokenResponse' + content: {} default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /auth/logout: + /api/v1/auth/register: post: tags: - - AuthService - description: AuthLogout logs out a user. - operationId: AuthService_AuthLogout + - Auth + description: Register creates a new user account. + operationId: Auth_Register requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.AuthLogoutRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.RegisterRequest' required: true responses: "200": description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.AuthLogoutResponse' + content: {} default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /auth/personal/logout: + /api/v1/auth/token: post: tags: - - PersonalService - description: PersonalLogout Personal user logs out - operationId: PersonalService_PersonalLogout + - Auth + description: RefreshToken provides a new access token. + operationId: Auth_RefreshToken requestBody: content: application/json: schema: - $ref: '#/components/schemas/google.protobuf.Any' + $ref: '#/components/schemas/api.v1.services.auth.RefreshTokenRequest' required: true responses: "200": @@ -110,118 +104,23 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.PersonalLogoutResponse' + $ref: '#/components/schemas/api.v1.services.auth.RefreshTokenResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /auth/personal/password: - put: - tags: - - PersonalService - description: UpdatePersonalProfilePassword The user changes the password - operationId: PersonalService_UpdatePersonalPassword - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.protobuf.Any' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.UpdatePersonalPasswordResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /auth/personal/profile: + /api/v1/captcha: get: tags: - - PersonalService - description: GetPersonalProfile Update the personal user information - operationId: PersonalService_GetPersonalProfile - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.GetPersonalProfileResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - put: - tags: - - PersonalService - description: UpdatePersonalProfile Update the personal user information - operationId: PersonalService_UpdatePersonalProfile - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.protobuf.Any' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.UpdatePersonalProfileResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /auth/personal/resources: - get: - tags: - - PersonalService - description: ListPersonalResources List the personal user's menu - operationId: PersonalService_ListPersonalResources + - Auth + description: GetCaptcha generates a new captcha. + operationId: Auth_GetCaptcha parameters: - - name: id - in: query - description: The parent resource id, for example, "shelves/shelf1". - schema: - type: string - - name: current - in: query - description: The current page number. - schema: - type: integer - format: int32 - - name: page_size - in: query - description: The maximum number of items to return. - schema: - type: integer - format: int32 - - name: page_token - in: query - description: The next_page_token value returned from a previous List request, if any. - schema: - type: string - - name: no_paging - in: query - description: The no_paging is used to disable pagination. - schema: - type: boolean - - name: only_count + - name: reload in: query - description: The only_count is the query parameter for set only to query the total number + description: If true, forces reloading of the captcha. schema: type: boolean responses: @@ -230,425 +129,166 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.ListPersonalResourcesResponse' + $ref: '#/components/schemas/api.v1.services.auth.GetCaptchaResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /auth/personal/roles: + /api/v1/casbin/groupings: get: tags: - - PersonalService - description: ListPersonalResources List the personal user's menu - operationId: PersonalService_ListPersonalRoles - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.ListPersonalRolesResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /auth/personal/setting: - put: - tags: - - PersonalService - description: UpdatePersonalSetting User settings are saved - operationId: PersonalService_UpdatePersonalSetting - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.protobuf.Any' - required: true + - CasbinSourceService + operationId: CasbinSourceService_ListGroupings responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.UpdatePersonalSettingResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListGroupingsResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /auth/personal/token/refresh: - post: + /api/v1/casbin/policies: + get: tags: - - PersonalService - description: RefreshPersonalToken Refresh the personal user's token - operationId: PersonalService_RefreshPersonalToken - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.protobuf.Any' - required: true + - CasbinSourceService + operationId: CasbinSourceService_ListPolicies responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.RefreshPersonalTokenResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListPoliciesResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /auth/resources: + /api/v1/casbin/watch: get: tags: - - AuthService - description: ListAuthResources returns a list of Auths. - operationId: AuthService_ListAuthResources + - CasbinSourceService + operationId: CasbinSourceService_WatchUpdate parameters: - - name: page_size - in: query - description: The maximum number of Auths to return. - schema: - type: integer - format: int32 - - name: page_token + - name: last_modified in: query - description: The next_page_token value returned from a previous List request, if any. schema: type: string - - name: current - in: query - description: The current page number. - schema: - type: integer - format: int32 - - name: no_paging - in: query - description: The no_paging is used to disable pagination. - schema: - type: boolean responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.ListAuthResourcesResponse' + $ref: '#/components/schemas/api.v1.services.auth.WatchUpdateResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /auth/token: - post: + /api/v1/me/password: + put: tags: - - AuthService - description: CreateToken generates a new JWT token for the given user. - operationId: AuthService_CreateToken + - Me + description: UpdatePassword changes the password for the currently authenticated user. + operationId: Me_UpdatePassword requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.CreateTokenRequest_Data' + $ref: '#/components/schemas/api.v1.services.auth.UpdatePasswordRequest' required: true responses: "200": description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.CreateTokenResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /auth/validate: - get: - tags: - - AuthService - description: ValidateToken verifies the validity of a JWT token. - operationId: AuthService_ValidateToken - parameters: - - name: token - in: query - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.ValidateTokenResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /captcha: - get: - tags: - - LoginService - operationId: LoginService_Captcha - parameters: - - name: id - in: query - description: The id of the captcha - schema: - type: string - - name: type - in: query - description: The type of the captcha - schema: - type: string - - name: reload - in: query - description: The reload is used to reload the captcha - schema: - type: boolean - - name: ts - in: query - description: The timestamp of the request prevent caching of the same result - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.CaptchaResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /captcha/audio: - get: - tags: - - LoginService - operationId: LoginService_CaptchaAudio - parameters: - - name: id - in: query - schema: - type: string - - name: reload - in: query - schema: - type: string - - name: data.type_url - in: query - description: |- - A URL/resource name that uniquely identifies the type of the serialized - protocol buffer message. This string must contain at least - one "/" character. The last segment of the URL's path must represent - the fully qualified name of the type (as in - `path/google.protobuf.Duration`). The name should be in a canonical form - (e.g., leading "." is not accepted). - - In practice, teams usually precompile into the binary all types that they - expect it to use in the context of Any. However, for URLs which use the - scheme `http`, `https`, or no scheme, one can optionally set up a type - server that maps type URLs to message definitions as follows: - - * If no scheme is provided, `https` is assumed. - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the official - protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. As of May 2023, there are no widely used type server - implementations and no plans to implement one. - - Schemes other than `http`, `https` (or the empty scheme) might be - used with implementation specific semantics. - schema: - type: string - - name: data.value - in: query - description: Must be a valid serialized protocol buffer of the above specified type. - schema: - type: string - format: bytes - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.CaptchaAudioResponse' + content: {} default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /captcha/id: + /api/v1/me/profile: get: tags: - - LoginService - operationId: LoginService_CaptchaId - parameters: - - name: ts - in: query - description: The timestamp of the request prevent caching of the same result - schema: - type: string - - name: reload - in: query - schema: - type: boolean + - Me + description: GetProfile retrieves the profile of the currently authenticated user. + operationId: Me_GetProfile responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.CaptchaIdResponse' + $ref: '#/components/schemas/api.v1.services.types.User' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /captcha/image: - get: - tags: - - LoginService - operationId: LoginService_CaptchaImage - parameters: - - name: id - in: query - schema: - type: string - - name: reload - in: query - schema: - type: string - - name: data.type_url - in: query - description: |- - A URL/resource name that uniquely identifies the type of the serialized - protocol buffer message. This string must contain at least - one "/" character. The last segment of the URL's path must represent - the fully qualified name of the type (as in - `path/google.protobuf.Duration`). The name should be in a canonical form - (e.g., leading "." is not accepted). - - In practice, teams usually precompile into the binary all types that they - expect it to use in the context of Any. However, for URLs which use the - scheme `http`, `https`, or no scheme, one can optionally set up a type - server that maps type URLs to message definitions as follows: - - * If no scheme is provided, `https` is assumed. - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the official - protobuf release, and it is not used for type URLs beginning with - type.googleapis.com. As of May 2023, there are no widely used type server - implementations and no plans to implement one. - - Schemes other than `http`, `https` (or the empty scheme) might be - used with implementation specific semantics. - schema: - type: string - - name: data.value - in: query - description: Must be a valid serialized protocol buffer of the above specified type. - schema: - type: string - format: bytes - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.CaptchaImageResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /casbin/groupings: - get: - tags: - - CasbinSourceService - operationId: CasbinSourceService_ListGroupings + put: + tags: + - Me + description: UpdateProfile updates the profile of the currently authenticated user. + operationId: Me_UpdateProfile + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.UpdateProfileRequest' + required: true responses: "200": description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.ListGroupingsResponse' + content: {} default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /casbin/policies: + /api/v1/me/resources: get: tags: - - CasbinSourceService - operationId: CasbinSourceService_ListPolicies + - Me + description: GetUserResources retrieves the menu/resource list for the current user. + operationId: Me_GetUserResources responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.ListPoliciesResponse' + $ref: '#/components/schemas/api.v1.services.auth.GetUserResourcesResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /casbin/watch: + /api/v1/me/roles: get: tags: - - CasbinSourceService - operationId: CasbinSourceService_WatchUpdate - parameters: - - name: last_modified - in: query - schema: - type: string + - Me + description: GetUserRoles retrieves the role list for the current user. + operationId: Me_GetUserRoles responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.WatchUpdateResponse' + $ref: '#/components/schemas/api.v1.services.auth.GetUserRolesResponse' default: description: Default error response content: @@ -829,54 +469,6 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /login: - post: - tags: - - LoginService - operationId: LoginService_Login - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.LoginRequest_Data' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.LoginResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /logout: - post: - tags: - - LoginService - operationId: LoginService_Logout - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/google.protobuf.Any' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.LogoutResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' /message/personal/logout: post: tags: @@ -1091,30 +683,6 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /register: - post: - tags: - - LoginService - operationId: LoginService_Register - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.RegisterRequest_Data' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' /sys/departments: get: tags: @@ -2526,30 +2094,6 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /token/refresh: - post: - tags: - - LoginService - operationId: LoginService_TokenRefresh - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.TokenRefreshRequest_Data' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.TokenRefreshResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' /upload: get: tags: @@ -2726,95 +2270,31 @@ paths: $ref: '#/components/schemas/google.rpc.Status' components: schemas: - api.v1.services.auth.AuthLogoutRequest_Data: - type: object - properties: - token: - type: string - api.v1.services.auth.AuthLogoutResponse: - type: object - properties: {} - api.v1.services.auth.AuthenticateRequest_Data: - type: object - properties: - token: - type: string - path: - type: string - method: - type: string - operation: - type: string - api.v1.services.auth.AuthenticateResponse: - type: object - properties: - is_valid: - type: boolean - api.v1.services.auth.CaptchaAudioResponse: - type: object - properties: - headers: - type: object - additionalProperties: - type: string - audio: - type: string - format: bytes - description: The response message containing the greetings - api.v1.services.auth.CaptchaIdResponse: - type: object - properties: - data: - type: string - api.v1.services.auth.CaptchaImageResponse: - type: object - properties: - headers: - type: object - additionalProperties: - type: string - image: - type: string - format: bytes - description: The response message containing the greetings - api.v1.services.auth.CaptchaResponse: + api.v1.services.auth.GetCaptchaResponse: type: object properties: - id: - type: string - type: + captcha_id: type: string - data: + captcha_image: type: string - api.v1.services.auth.CreateTokenRequest_Data: + description: Base64 encoded image data. + description: The response message for the GetCaptcha RPC. + api.v1.services.auth.GetUserResourcesResponse: type: object properties: - user_id: - type: string - scopes: + resources: type: array items: - type: string - api.v1.services.auth.CreateTokenResponse: - type: object - properties: - token: - type: string - description: CreateTokenResponse contains the generated token. - api.v1.services.auth.DestroyTokenRequest_Data: - type: object - properties: - token: - type: string - api.v1.services.auth.DestroyTokenResponse: - type: object - properties: {} - description: DestroyTokenResponse contains the result of the invalidation. - api.v1.services.auth.GetPersonalProfileResponse: + $ref: '#/components/schemas/api.v1.services.types.Resource' + description: The response message for the GetUserResources RPC. + api.v1.services.auth.GetUserRolesResponse: type: object properties: - user: - $ref: '#/components/schemas/api.v1.services.types.User' + roles: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.Role' + description: The response message for the GetUserRoles RPC. api.v1.services.auth.GroupingRule: type: object properties: @@ -2824,18 +2304,6 @@ components: type: array items: type: string - api.v1.services.auth.ListAuthResourcesResponse: - type: object - properties: - resources: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Resource' - description: The list of Auths. - total_size: - type: integer - description: The total number of Auths in the result set. - format: int32 api.v1.services.auth.ListGroupingsResponse: type: object properties: @@ -2843,27 +2311,6 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.auth.GroupingRule' - api.v1.services.auth.ListPersonalResourcesResponse: - type: object - properties: - total_size: - type: string - description: The total number of items in the list. - resources: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Resource' - description: list of resources - next_page_token: - type: string - description: "Token to retrieve the next page of results, or empty if there are no\r\n more results in the list." - api.v1.services.auth.ListPersonalRolesResponse: - type: object - properties: - roles: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Role' api.v1.services.auth.ListPoliciesResponse: type: object properties: @@ -2871,7 +2318,7 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.auth.PolicyRule' - api.v1.services.auth.LoginRequest_Data: + api.v1.services.auth.LoginRequest: type: object properties: username: @@ -2882,21 +2329,25 @@ components: type: string captcha_code: type: string + description: The request message for the Login RPC. api.v1.services.auth.LoginResponse: type: object properties: - token: - $ref: '#/components/schemas/contrib.api.security.v1.TokenCredential' - api.v1.services.auth.LogoutResponse: - type: object - properties: - success: - type: boolean - api.v1.services.auth.PersonalLogoutResponse: + access_token: + type: string + refresh_token: + type: string + token_type: + type: string + expires_in: + type: string + description: The response message for the Login RPC. + api.v1.services.auth.LogoutRequest: type: object properties: - success: - type: boolean + refresh_token: + type: string + description: The request message for the Logout RPC. api.v1.services.auth.PolicyRule: type: object properties: @@ -2906,63 +2357,52 @@ components: type: array items: type: string - api.v1.services.auth.RefreshPersonalTokenResponse: + api.v1.services.auth.RefreshTokenRequest: type: object properties: - token: + refresh_token: + type: string + description: The request message for the RefreshToken RPC. + api.v1.services.auth.RefreshTokenResponse: + type: object + properties: + access_token: + type: string + token_type: + type: string + expires_in: type: string - api.v1.services.auth.RegisterRequest_Data: + description: The response message for the RefreshToken RPC. + api.v1.services.auth.RegisterRequest: type: object properties: username: type: string password: type: string + email: + type: string captcha_id: type: string captcha_code: type: string - api.v1.services.auth.RegisterResponse: - type: object - properties: - success: - type: boolean - data: - $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse_Data' - api.v1.services.auth.RegisterResponse_Data: + description: The request message for the Register RPC. + api.v1.services.auth.UpdatePasswordRequest: type: object properties: - redirect: + old_password: type: string - api.v1.services.auth.TokenRefreshRequest_Data: - type: object - properties: - refresh_token: + new_password: type: string - api.v1.services.auth.TokenRefreshResponse: - type: object - properties: - token: - $ref: '#/components/schemas/contrib.api.security.v1.TokenCredential' - api.v1.services.auth.UpdatePersonalPasswordResponse: - type: object - properties: {} - api.v1.services.auth.UpdatePersonalProfileResponse: - type: object - properties: {} - api.v1.services.auth.UpdatePersonalSettingResponse: - type: object - properties: {} - api.v1.services.auth.ValidateTokenResponse: + description: The request message for the UpdatePassword RPC. + api.v1.services.auth.UpdateProfileRequest: type: object properties: - is_valid: - type: boolean - claims: - type: object - additionalProperties: - type: string - description: VerifyTokenResponse contains the result of the verification. + user: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.User' + description: The fields to update. + description: The request message for the UpdateProfile RPC. api.v1.services.auth.WatchUpdateResponse: type: object properties: @@ -3273,7 +2713,7 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.types.Department' - description: The paging menus + description: The paging departments page: type: integer description: The page number. @@ -3304,7 +2744,7 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.types.Permission' - description: The paging menus + description: The paging permissions page: type: integer description: The page number. @@ -3335,7 +2775,7 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.types.Position' - description: The paging menus + description: The paging positions page: type: integer description: The page number. @@ -3387,7 +2827,7 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.types.Role' - description: The paging menus + description: The paging roles page: type: integer description: The page number. @@ -3428,7 +2868,7 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.types.User' - description: The paging menus + description: The paging users page: type: integer description: The page number. @@ -4080,22 +3520,6 @@ components: data: $ref: '#/components/schemas/api.v1.services.types.DataObject' description: UpdateUploadResponse is the response for the UploadService.UpdateUpload method. - contrib.api.security.v1.TokenCredential: - type: object - properties: - access_token: - type: string - description: The access token used for authentication. - refresh_token: - type: string - description: The refresh token used to obtain a new access token. - expires_in: - type: string - description: The remaining lifetime of the access token in seconds. - token_type: - type: string - description: The type of the token, typically 'Bearer'. - description: "TokenCredential holds the credentials for token-based authentication flows\r\n like OAuth2 and JWT.\r\n\r\n IMPORTANT: This message represents the full set of tokens typically returned\r\n from a token issuance endpoint (e.g., /login). It is designed for use in\r\n CredentialResponse." google.protobuf.Any: type: object properties: @@ -4129,21 +3553,20 @@ components: name: Authorization in: header tags: - - name: AuthService + - name: Auth + description: Service Auth provides APIs for the authentication lifecycle. - name: CasbinSourceService description: The Casbin source service definition. - name: DatastoreService description: The data service definition. - name: DepartmentService description: The login service definition. - - name: LoginService - description: The login service definition. + - name: Me + description: Service Me provides APIs for the currently authenticated user to manage their own profile and data. - name: PermissionService description: The login service definition. - name: PersonalService description: PersonalService Personal user service - - name: PersonalService - description: PersonalService Personal user service - name: PositionService description: The login service definition. - name: ResourceService From b81a22fcc80050709e6673f477facbc6688a896d Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 30 Dec 2025 05:15:18 +0800 Subject: [PATCH 104/158] refactor(auth): restructure auth service with wire dependency injection and simplified biz logic --- cmd/auth/main.go | 109 +- cmd/auth/provider.go | 18 + cmd/auth/wire.go | 44 +- internal/features/auth/biz/auth.biz.go | 62 - internal/features/auth/biz/auth.go | 42 + internal/features/auth/biz/login.biz.go | 75 - internal/features/auth/biz/me.go | 25 + internal/features/auth/biz/personal.biz.go | 63 - internal/features/auth/biz/provider.go | 16 +- internal/features/auth/dal/auth.dal.go | 195 --- internal/features/auth/dal/auth.go | 38 + internal/features/auth/dal/me.go | 33 + internal/features/auth/dal/personal.dal.go | 156 -- internal/features/auth/dal/provider.go | 20 +- internal/features/auth/dal/user.dal.go | 222 --- internal/features/auth/dto/auth.go | 45 +- internal/features/auth/dto/casbin.go | 3 - internal/features/auth/dto/custom.gen.go | 52 + internal/features/auth/dto/dto.gen.go | 1279 +++++++++++++++++ internal/features/auth/dto/dto.go | 1020 +------------ internal/features/auth/dto/login.go | 109 -- internal/features/auth/dto/me.go | 11 + internal/features/auth/dto/personal.go | 20 - internal/features/auth/server/gins.go | 67 - internal/features/auth/server/grpc.go | 27 - internal/features/auth/server/http.go | 27 - internal/features/auth/server/server.go | 216 ++- internal/features/auth/service/auth.bridge.go | 186 --- internal/features/auth/service/auth.go | 67 + internal/features/auth/service/auth.grpc.go | 30 - internal/features/auth/service/auth.http.go | 39 - .../features/auth/service/casbin.bridge.go | 209 --- internal/features/auth/service/casbin.go | 122 +- internal/features/auth/service/casbin.grpc.go | 55 - internal/features/auth/service/casbin.http.go | 44 - .../features/auth/service/login.bridge.go | 269 ---- internal/features/auth/service/login.grpc.go | 64 - internal/features/auth/service/login.http.go | 63 - internal/features/auth/service/me.go | 49 + .../features/auth/service/personal.bridge.go | 140 -- .../features/auth/service/personal.grpc.go | 71 - .../features/auth/service/personal.http.go | 63 - internal/features/auth/service/provider.go | 36 +- internal/features/auth/service/service.go | 111 -- 44 files changed, 1813 insertions(+), 3799 deletions(-) create mode 100644 cmd/auth/provider.go delete mode 100644 internal/features/auth/biz/auth.biz.go create mode 100644 internal/features/auth/biz/auth.go delete mode 100644 internal/features/auth/biz/login.biz.go create mode 100644 internal/features/auth/biz/me.go delete mode 100644 internal/features/auth/biz/personal.biz.go delete mode 100644 internal/features/auth/dal/auth.dal.go create mode 100644 internal/features/auth/dal/auth.go create mode 100644 internal/features/auth/dal/me.go delete mode 100644 internal/features/auth/dal/personal.dal.go delete mode 100644 internal/features/auth/dal/user.dal.go create mode 100644 internal/features/auth/dto/custom.gen.go create mode 100644 internal/features/auth/dto/dto.gen.go delete mode 100644 internal/features/auth/dto/login.go create mode 100644 internal/features/auth/dto/me.go delete mode 100644 internal/features/auth/dto/personal.go delete mode 100644 internal/features/auth/server/gins.go delete mode 100644 internal/features/auth/server/grpc.go delete mode 100644 internal/features/auth/server/http.go delete mode 100644 internal/features/auth/service/auth.bridge.go create mode 100644 internal/features/auth/service/auth.go delete mode 100644 internal/features/auth/service/auth.grpc.go delete mode 100644 internal/features/auth/service/auth.http.go delete mode 100644 internal/features/auth/service/casbin.bridge.go delete mode 100644 internal/features/auth/service/casbin.grpc.go delete mode 100644 internal/features/auth/service/casbin.http.go delete mode 100644 internal/features/auth/service/login.bridge.go delete mode 100644 internal/features/auth/service/login.grpc.go delete mode 100644 internal/features/auth/service/login.http.go create mode 100644 internal/features/auth/service/me.go delete mode 100644 internal/features/auth/service/personal.bridge.go delete mode 100644 internal/features/auth/service/personal.grpc.go delete mode 100644 internal/features/auth/service/personal.http.go delete mode 100644 internal/features/auth/service/service.go diff --git a/cmd/auth/main.go b/cmd/auth/main.go index cc13d593..13807875 100644 --- a/cmd/auth/main.go +++ b/cmd/auth/main.go @@ -1,84 +1,81 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - package main import ( - "context" "flag" - "log/slog" "github.com/go-kratos/kratos/v2" - "github.com/go-kratos/kratos/v2/encoding" "github.com/go-kratos/kratos/v2/transport" + "github.com/joho/godotenv" + _ "github.com/sqlite3ent/sqlite3" // Import for sqlite3 driver + + _ "github.com/origadmin/contrib/config/consul" + _ "github.com/origadmin/contrib/registry/consul" "github.com/origadmin/runtime" - "github.com/origadmin/runtime/bootstrap" + runtimebootstrap "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/codec/toml" - - _ "origadmin/application/admin/contrib/consul/config" - _ "origadmin/application/admin/contrib/consul/registry" - _ "origadmin/application/admin/contrib/database/drivers" + "origadmin/application/admin/internal/conf" _ "origadmin/application/admin/internal/data/entity/ent/runtime" - "origadmin/application/admin/internal/loader" + confhelper "origadmin/application/admin/internal/helpers/conf" ) -// go build -ldflags "-X main.Version=vx.y.z -X main.Name=origadmin.service.auth.v1" var ( - // Name is the Name of the compiled software. + // Name is the name of the compiled software. Name = "origadmin.service.auth.v1" - // Version is the Version of the compiled software. + // Version is the version of the compiled software. Version = "v1.0.0" - // boot are the bootstrap boot. - flags = bootstrap.New() - // debug mode - debug = false - // configPath is the config path, default is config.toml - configPath = "" + + // flagconf is the config flag. + flagconf string ) func init() { - encoding.RegisterCodec(toml.Codec) - flags.SetServiceInfo(Name, Version) - flag.BoolVar(&debug, "debug", false, "set environment, eg: -debug") - flag.StringVar(&configPath, "c", "config.toml", "config path, eg: -c config.toml") + // The config path should be the directory containing configuration files. + // The default is empty, so we can detect if the user has provided it. + flag.StringVar(&flagconf, "conf", "", "config path, eg: -conf bootstrap.yaml") +} + +func NewApp(app *runtime.App, servers []transport.Server) *kratos.App { + return app.NewApp(servers) } func main() { + // Load .env file for local development from resources directory. + // It's safe to ignore the error, as the file may not exist in production. + _ = godotenv.Load("resources/.env.auth") + flag.Parse() - // the release mode, work dir sets to empty, use config path as work dir - if debug { - flags.SetEnv("debug") - flags.SetConfigPath("resources/configs/auth_config.toml") - flags.SetWorkDir(".") - slog.SetLogLoggerLevel(slog.LevelDebug) + confPath := confhelper.FindConfPath(flagconf) + if confPath == "" { + log.Fatalf("Could not find configuration file. Searched -conf flag, executable path, and development path.") } - //r, err := runtime.Load(flags) - //if err != nil { - // return - //} - //l := r.Logger( - // "ts", log.DefaultTimestamp, - // "caller", log.DefaultCaller, - // "service.id", flags.ServiceID(), - // "service.name", flags.ServiceName(), - // "service.version", flags.Version(), - // "trace.id", tracing.TraceID(), - // "span.id", tracing.SpanID(), - //) - //log.SetLogger(l) - ll := log.NewHelper(log.GetLogger()) - ll.Infof("bootstrap flags: %+v", flags) - if err := loader.Bootstrap(context.Background(), flags, buildInjectors); err != nil { - ll.Infof("failed to bootstrap: %s", err.Error()) - return + // Log the config path for debugging + log.Infof("Loading configuration from: %s\n", confPath) + + // NewFromBootstrap handles config loading, logging, and container setup. + rt := runtime.New(Name, Version) + err := rt.Load(confPath, runtimebootstrap.WithConfigTransformer(conf.New())) + if err != nil { + log.Fatalf("failed to create runtime: %v", err) } -} + defer rt.Config().Close() + log.Infof("Starting %s %s (ID: %s)\n", rt.AppInfo().Name(), rt.AppInfo().Version(), rt.AppInfo().ID()) + + // Get bootstrap config + bootstrapConfig, ok := rt.StructuredConfig().(*conf.Config) + if !ok { + log.Fatalf("failed to get bootstrap config") + } + // wireApp now takes the runtime instance and builds the kratos app. + app, cleanupApp, err := wireApp(rt, bootstrapConfig) + if err != nil { + log.Fatalf("failed to wire app: %v", err) + } + defer cleanupApp() -// NewApp new app with runtime and injector -func NewApp(r runtime.Runtime, servers []transport.Server) *kratos.App { - return r.CreateApp(servers...) + // Run the application + if err := app.Run(); err != nil { + log.Fatalf("app run failed: %v", err) + } } diff --git a/cmd/auth/provider.go b/cmd/auth/provider.go new file mode 100644 index 00000000..2d7b5b45 --- /dev/null +++ b/cmd/auth/provider.go @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package main + +import ( + "github.com/google/wire" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/log" +) + +func provideLogger(app *runtime.App) log.Logger { + return app.Logger() +} + +// infraProviderSet provides basic infrastructure dependencies. +var infraProviderSet = wire.NewSet(provideLogger) diff --git a/cmd/auth/wire.go b/cmd/auth/wire.go index a9addaa2..6d6e5165 100644 --- a/cmd/auth/wire.go +++ b/cmd/auth/wire.go @@ -1,40 +1,36 @@ //go:build wireinject // +build wireinject -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// The build tag makes sure the stub is not built in the final build. package main import ( "github.com/go-kratos/kratos/v2" "github.com/google/wire" - "github.com/origadmin/runtime" - "origadmin/application/admin/internal/configs" + "github.com/origadmin/runtime" + "origadmin/application/admin/internal/conf" + confpb "origadmin/application/admin/internal/conf/pb" "origadmin/application/admin/internal/data" - authbiz "origadmin/application/admin/internal/features/auth/biz" // Corrected import path - authdal "origadmin/application/admin/internal/features/auth/dal" // Corrected import path - authserver "origadmin/application/admin/internal/features/auth/server" // Corrected import path - authservice "origadmin/application/admin/internal/features/auth/service" // Corrected import path + "origadmin/application/admin/internal/features/auth/biz" + "origadmin/application/admin/internal/features/auth/dal" + "origadmin/application/admin/internal/features/auth/server" + "origadmin/application/admin/internal/features/auth/service" + "origadmin/application/admin/internal/pkg/token" ) -// buildInjectors init kratos application. -func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { +// wireApp init kratos application. +func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { panic(wire.Build( - //loader.ProviderSet, - data.ProviderSet, - //authdal.ProviderSet, - //basisbiz.ProviderSet, - //basisservice.ProviderSet, - //basisserver.ProviderSet, - authdal.ProviderSet, - authbiz.ProviderSet, - authservice.ProviderSet, - authserver.ProviderSet, - /* add your providers here */ + // The injector function's parameter `app` is an implicit provider for *runtime.App. + infraProviderSet, + wire.FieldsOf(new(*conf.Config), "Bootstrap"), + wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), + data.ProviderSet, // This was the missing piece + dal.ProviderSet, + biz.ProviderSet, + token.ProviderSet, + service.ProviderSet, + server.ProviderSet, NewApp, )) } diff --git a/internal/features/auth/biz/auth.biz.go b/internal/features/auth/biz/auth.biz.go deleted file mode 100644 index d4ef9459..00000000 --- a/internal/features/auth/biz/auth.biz.go +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the auth module of OrigAdmin. -package biz - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/mods/auth/dto" -) - -// AuthServiceBiz is a Auth use case. -type AuthServiceBiz struct { - dao dto.AuthRepo - limiter repo.PageLimiter - log *log.KHelper -} - -func (biz AuthServiceBiz) AuthLogout(ctx context.Context, in *pb.AuthLogoutRequest) (*pb.AuthLogoutResponse, error) { - return biz.dao.AuthLogout(ctx, in) -} - -func (biz AuthServiceBiz) CreateToken(ctx context.Context, in *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error) { - return biz.dao.CreateToken(ctx, in) -} - -func (biz AuthServiceBiz) ValidateToken(ctx context.Context, in *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) { - return biz.dao.ValidateToken(ctx, in) -} - -func (biz AuthServiceBiz) DestroyToken(ctx context.Context, in *pb.DestroyTokenRequest) (*pb.DestroyTokenResponse, error) { - return biz.dao.DestroyToken(ctx, in) -} - -func (biz AuthServiceBiz) Authenticate(ctx context.Context, in *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) { - return biz.dao.Authenticate(ctx, in) -} - -func (biz AuthServiceBiz) ListAuthResources(ctx context.Context, in *pb.ListAuthResourcesRequest) (*pb.ListAuthResourcesResponse, error) { - var option dto.AuthResourceQueryOption - if err := option.FromListRequest(in, biz.limiter); err != nil { - return nil, err - } - biz.log.Info("ListAuths") - result, total, err := biz.dao.ListAuthResources(ctx, in, option) - if err != nil { - return nil, err - } - return dto.ToListAuthResourcesResponse(result, in, total) -} - -// NewAuthServiceBiz new Auth use case. -func NewAuthServiceBiz(r runtime.Runtime, repo dto.AuthRepo) *AuthServiceBiz { - return &AuthServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.WithLogger("module", "biz/auth"))} -} diff --git a/internal/features/auth/biz/auth.go b/internal/features/auth/biz/auth.go new file mode 100644 index 00000000..2bf4406f --- /dev/null +++ b/internal/features/auth/biz/auth.go @@ -0,0 +1,42 @@ +package biz + +import ( + "context" + "errors" + + "github.com/go-kratos/kratos/v2/log" + "golang.org/x/crypto/bcrypt" + + "origadmin/application/admin/internal/features/auth/dto" +) + +// AuthUseCase is a authentication use case. +type AuthUseCase struct { + repo dto.AuthRepo + log *log.Helper +} + +// NewAuthUseCase new a authentication use case. +func NewAuthUseCase(repo dto.AuthRepo, logger log.Logger) *AuthUseCase { + return &AuthUseCase{ + repo: repo, + log: log.NewHelper(logger), + } +} + +// VerifyUser verifies the user's credentials and returns the user ID if successful. +func (uc *AuthUseCase) VerifyUser(ctx context.Context, username, password string) (int64, error) { + user, err := uc.repo.GetUserByUsername(ctx, username) + if err != nil { + return 0, err + } + + // Compare the provided password with the stored hash. + err = bcrypt.CompareHashAndPassword([]byte(user.EncryptedPassword), []byte(password)) + if err != nil { + // If the passwords don't match, return a generic error. + return 0, errors.New("invalid username or password") + } + + return user.ID, nil +} diff --git a/internal/features/auth/biz/login.biz.go b/internal/features/auth/biz/login.biz.go deleted file mode 100644 index b4cd87fa..00000000 --- a/internal/features/auth/biz/login.biz.go +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the auth module of OrigAdmin. -package biz - -import ( - "context" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/mods/auth/dto" -) - -// LoginServiceBiz is a Login use case. -type LoginServiceBiz struct { - dao dto.LoginRepo - limiter repo.PageLimiter - log *log.KHelper -} - -func (biz LoginServiceBiz) CaptchaId(ctx context.Context, in *pb.CaptchaIdRequest) (*pb.CaptchaIdResponse, error) { - log.Info("CaptchaId") - return biz.dao.CaptchaID(ctx, in) -} - -func (biz LoginServiceBiz) Register(ctx context.Context, in *pb.RegisterRequest) (*pb.RegisterResponse, error) { - log.Info("Register") - return biz.dao.Register(ctx, in) -} - -func (biz LoginServiceBiz) Captcha(ctx context.Context, in *pb.CaptchaRequest) (*pb.CaptchaResponse, error) { - log.Info("Captcha") - return biz.dao.Captcha(ctx, in) -} - -func (biz LoginServiceBiz) CaptchaImage(ctx context.Context, in *dto.CaptchaImageRequest) (*dto.CaptchaImageResponse, error) { - log.Info("CaptchaImage") - return biz.dao.CaptchaImage(ctx, in.Id, in.Reload == "1" || in.Reload == "true") -} - -func (biz LoginServiceBiz) CaptchaAudio(ctx context.Context, in *pb.CaptchaAudioRequest) (*pb.CaptchaAudioResponse, error) { - log.Info("CaptchaAudio") - return biz.dao.CaptchaAudio(ctx, in.Id, in.Reload == "1" || in.Reload == "true") -} - -func (biz LoginServiceBiz) Login(ctx context.Context, in *dto.LoginRequest) (*dto.LoginResponse, error) { - log.Info("Login") - return biz.dao.Login(ctx, in) -} - -func (biz LoginServiceBiz) Logout(ctx context.Context, in *dto.LogoutRequest) (*dto.LogoutResponse, error) { - log.Info("Logout") - return biz.dao.Logout(ctx, in) -} - -func (biz LoginServiceBiz) CurrentUser(ctx context.Context, in *dto.CurrentUserRequest) (*dto.CurrentUserResponse, error) { - log.Info("CurrentUser") - return biz.dao.CurrentUser(ctx, in) -} - -func (biz LoginServiceBiz) TokenRefresh(ctx context.Context, in *pb.TokenRefreshRequest) (*pb.TokenRefreshResponse, error) { - log.Info("TokenRefresh") - return biz.dao.TokenRefresh(ctx, in) -} - -// NewLoginServiceBiz new a Login use case. -func NewLoginServiceBiz(r runtime.Runtime, repo dto.LoginRepo) *LoginServiceBiz { - return &LoginServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.WithLogger("module", "biz/login"))} -} diff --git a/internal/features/auth/biz/me.go b/internal/features/auth/biz/me.go new file mode 100644 index 00000000..4d9fff1b --- /dev/null +++ b/internal/features/auth/biz/me.go @@ -0,0 +1,25 @@ +package biz + +import ( + "context" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/auth/dto" + + "github.com/go-kratos/kratos/v2/log" +) + +// MeUseCase is a user profile use case. +type MeUseCase struct { + repo dto.MeRepo + log *log.Helper +} + +// NewMeUseCase new a user profile use case. +func NewMeUseCase(repo dto.MeRepo, logger log.Logger) *MeUseCase { + return &MeUseCase{repo: repo, log: log.NewHelper(logger)} +} + +// GetProfile gets the user profile. +func (uc *MeUseCase) GetProfile(ctx context.Context, userID int64) (*types.User, error) { + return uc.repo.GetProfile(ctx, userID) +} diff --git a/internal/features/auth/biz/personal.biz.go b/internal/features/auth/biz/personal.biz.go deleted file mode 100644 index ee13f13d..00000000 --- a/internal/features/auth/biz/personal.biz.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the auth module of OrigAdmin. -package biz - -import ( - "context" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/mods/auth/dto" -) - -// PersonalServiceBiz is a Personal use case. -type PersonalServiceBiz struct { - dao dto.PersonalRepo - limiter repo.PageLimiter - log *log.KHelper -} - -func (biz PersonalServiceBiz) ListPersonalResources(ctx context.Context, in *pb.ListPersonalResourcesRequest) (*pb.ListPersonalResourcesResponse, error) { - return biz.dao.ListPersonalResources(ctx, in) -} - -func (biz PersonalServiceBiz) RefreshPersonalToken(ctx context.Context, in *pb.RefreshPersonalTokenRequest) (*pb.RefreshPersonalTokenResponse, error) { - //return biz.dao.RefreshPersonalToken(ctx, in) - return &pb.RefreshPersonalTokenResponse{}, nil -} - -func (biz PersonalServiceBiz) GetPersonalProfile(ctx context.Context, in *pb.GetPersonalProfileRequest) (*pb.GetPersonalProfileResponse, error) { - return biz.dao.GetPersonalProfile(ctx, in) -} - -func (biz PersonalServiceBiz) ListPersonalRoles(ctx context.Context, in *pb.ListPersonalRolesRequest) (*pb.ListPersonalRolesResponse, error) { - return biz.dao.ListPersonalRoles(ctx, in) -} - -func (biz PersonalServiceBiz) PersonalLogout(ctx context.Context, in *pb.PersonalLogoutRequest) (*pb.PersonalLogoutResponse, error) { - return &pb.PersonalLogoutResponse{}, nil -} - -func (biz PersonalServiceBiz) UpdatePersonalPassword(ctx context.Context, in *pb.UpdatePersonalPasswordRequest) (*pb.UpdatePersonalPasswordResponse, error) { - return biz.dao.UpdatePersonalPassword(ctx, in) -} - -func (biz PersonalServiceBiz) UpdatePersonalProfile(ctx context.Context, in *pb.UpdatePersonalProfileRequest) (*pb.UpdatePersonalProfileResponse, error) { - return biz.dao.UpdatePersonalProfile(ctx, in) -} - -func (biz PersonalServiceBiz) UpdatePersonalSetting(ctx context.Context, in *pb.UpdatePersonalSettingRequest) (*pb.UpdatePersonalSettingResponse, error) { - return &pb.UpdatePersonalSettingResponse{}, nil -} - -// NewPersonalServiceBiz new a Personal use case. -func NewPersonalServiceBiz(r runtime.Runtime, repo dto.PersonalRepo) *PersonalServiceBiz { - return &PersonalServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} -} diff --git a/internal/features/auth/biz/provider.go b/internal/features/auth/biz/provider.go index 82359c2a..57be91be 100644 --- a/internal/features/auth/biz/provider.go +++ b/internal/features/auth/biz/provider.go @@ -1,18 +1,6 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz implements the functions, types, and interfaces for the module. package biz -import ( - "github.com/google/wire" -) +import "github.com/google/wire" // ProviderSet is biz providers. -var ProviderSet = wire.NewSet( - NewAuthServiceBiz, - NewLoginServiceBiz, - NewPersonalServiceBiz, - NewCasbinSourceServiceBiz, -) +var ProviderSet = wire.NewSet(NewAuthUseCase, NewMeUseCase) diff --git a/internal/features/auth/dal/auth.dal.go b/internal/features/auth/dal/auth.dal.go deleted file mode 100644 index 7169bbaa..00000000 --- a/internal/features/auth/dal/auth.dal.go +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "context" - "errors" - "sync" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/interfaces/security" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/helpers/db" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/resource" - _ "origadmin/application/admin/internal/data/entity/ent/runtime" - "origadmin/application/admin/internal/features/auth/dto" // Corrected import path -) - -type authRepo struct { - DB *data.Data - BufPool *sync.Pool - Tokenizer security.Tokenizer - Authorizer security.Authorizer -} - -func (repo authRepo) AuthLogout(ctx context.Context, request *pb.AuthLogoutRequest) (*pb.AuthLogoutResponse, error) { - //TODO implement me - panic("implement me") -} - -func (repo authRepo) CreateToken(ctx context.Context, request *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error) { - claims := security.ClaimsFromContext(ctx) - token, err := repo.Tokenizer.CreateToken(ctx, claims) - if err != nil { - return nil, err - } - return &pb.CreateTokenResponse{ - Token: token, - }, nil -} - -func (repo authRepo) ValidateToken(ctx context.Context, request *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) { - valid, err := repo.Tokenizer.Validate(ctx, request.Token) - if err != nil { - return nil, err - } - return &pb.ValidateTokenResponse{ - IsValid: valid, - }, nil -} - -func (repo authRepo) DestroyToken(ctx context.Context, request *pb.DestroyTokenRequest) (*pb.DestroyTokenResponse, error) { - //err := repo.Tokenizer.DestroyToken(ctx, request.Token) - //if err != nil { - // return nil, err - //} - return &pb.DestroyTokenResponse{}, nil -} - -func (repo authRepo) Authenticate(ctx context.Context, request *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) { - claims, err := repo.Tokenizer.ParseClaims(ctx, request.GetData().GetToken()) - if err != nil { - return nil, err - } - authorized, err := repo.Authorizer.Authorized( - ctx, - fromClaims(claims, "", ""), - request.GetData().GetMethod(), - request.GetData().GetPath()) - if err != nil { - return nil, err - } - return &pb.AuthenticateResponse{ - IsValid: authorized, - //Claims: fromClaims(claims), - }, nil -} - -func (repo authRepo) ListAuthResources(ctx context.Context, in *dto.ListAuthResourcesRequest, options ...dto.AuthResourceQueryOption) ([]*dto.ResourcePB, int32, error) { - var option dto.AuthResourceQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.DB.Resource(ctx).Query() - return authResourcePageQuery(ctx, query, in, option) -} - -func fromClaims(claims security.Claims, method, path string) security.Policy { - return &security.RegisteredPolicy{ - Subject: claims.GetSubject(), - Object: path, - Action: method, - Domain: claims.GetIssuer(), - Roles: nil, - Permissions: nil, - } -} - -// NewAuthRepo . -func NewAuthRepo(r runtime.Runtime, db *data.Data) dto.AuthRepo { - return &authRepo{ - DB: db, - BufPool: BufPool(), - } -} - -func authResourcePageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.ListAuthResourcesRequest, option dto.AuthResourceQueryOption) ([]*dto.ResourcePB, int32, error) { - query = authResourceQueryPage(query, in) - query = authResourceQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - result, err := query.All(ctx) - return dto.ConvertResources2PB(result), int32(count), err -} - -func authResourceQueryPage(query *ent.ResourceQuery, in *pb.ListAuthResourcesRequest) *ent.ResourceQuery { - if in.NoPaging { - pageSize := in.PageSize - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - return query - } - - pageSize := in.PageSize - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - current := in.Current - if current > 0 { - query = query.Offset(int((current - 1) * pageSize)) - } - return query -} - -func authResourceQueryOptions(query *ent.ResourceQuery, option dto.AuthResourceQueryOption) *ent.ResourceQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).(*ent.ResourceQuery) - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).(*ent.ResourceQuery) - } - if len(option.OrderFields) > 0 { - query = query.Order(resourceOrderBy(option.OrderFields)...) - } - return query -} - -type refreshTokenizer struct { - tokenizer security.Tokenizer -} - -func (r refreshTokenizer) CreateClaims(ctx context.Context, s string) (security.Claims, error) { - return r.tokenizer.CreateClaims(ctx, s) -} - -func (r refreshTokenizer) CreateToken(ctx context.Context, claims security.Claims) (string, error) { - return r.tokenizer.CreateToken(ctx, claims) -} - -func (r refreshTokenizer) ParseClaims(ctx context.Context, s string) (security.Claims, error) { - return r.tokenizer.ParseClaims(ctx, s) -} - -func (r refreshTokenizer) Validate(ctx context.Context, s string) (bool, error) { - return r.tokenizer.Validate(ctx, s) -} - -func (r refreshTokenizer) CreateRefreshClaims(ctx context.Context, s string) (security.Claims, error) { - return nil, errors.New("not implemented") -} - -func resourceOrderBy(orders []string) []resource.OrderOption { - return db.OrderBy[resource.OrderOption](orders) -} - -//func resourceQueryOptions(query *ent.ResourceQuery, option dto.ResourceQueryOption) *ent.ResourceQuery { -// if len(option.SelectFields) > 0 { -// query = query.Select(option.SelectFields...).ResourceQuery -// } -// if len(option.OmitFields) > 0 { -// query = query.Omit(option.OmitFields...).ResourceQuery -// } -// if len(option.OrderFields) > 0 { -// query = query.Order(resourceOrderBy(option.OrderFields)...) -// } -// return query -//} diff --git a/internal/features/auth/dal/auth.go b/internal/features/auth/dal/auth.go new file mode 100644 index 00000000..6d466ed2 --- /dev/null +++ b/internal/features/auth/dal/auth.go @@ -0,0 +1,38 @@ +package dal + +import ( + "context" + + "github.com/go-kratos/kratos/v2/log" + + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/features/auth/dto" +) + +type authRepo struct { + db *ent.Database + log *log.Helper +} + +// NewAuthRepo . +func NewAuthRepo(database *ent.Database, logger log.Logger) dto.AuthRepo { + return &authRepo{ + db: database, + log: log.NewHelper(logger), + } +} + +// GetUserByUsername retrieves a user by their username. +func (r *authRepo) GetUserByUsername(ctx context.Context, username string) (*dto.User, error) { + u, err := r.db.User(ctx).Query().Where(user.UsernameEQ(username)).Only(ctx) + if err != nil { + return nil, err + } + + return &dto.User{ + ID: u.ID, + Username: u.Username, + EncryptedPassword: u.EncryptedPassword, + }, nil +} diff --git a/internal/features/auth/dal/me.go b/internal/features/auth/dal/me.go new file mode 100644 index 00000000..ded7fcc2 --- /dev/null +++ b/internal/features/auth/dal/me.go @@ -0,0 +1,33 @@ +package dal + +import ( + "context" + + "github.com/go-kratos/kratos/v2/log" + + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/features/auth/dto" +) + +type meRepo struct { + db *ent.Database + log *log.Helper +} + +// NewMeRepo . +func NewMeRepo(database *ent.Database, logger log.Logger) dto.MeRepo { + return &meRepo{ + db: database, + log: log.NewHelper(logger), + } +} + +func (r *meRepo) GetProfile(ctx context.Context, userID int64) (*types.User, error) { + u, err := r.db.User(ctx).Query().Where(user.ID(userID)).Only(ctx) + if err != nil { + return nil, err + } + return dto.ConvertUserToUserPB(u), nil +} diff --git a/internal/features/auth/dal/personal.dal.go b/internal/features/auth/dal/personal.dal.go deleted file mode 100644 index 1af72a9e..00000000 --- a/internal/features/auth/dal/personal.dal.go +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "context" - - "github.com/go-kratos/kratos/v2/transport" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/auth" - typespb "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/helpers/securityx" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/mods/auth/dto" -) - -type personalRepo struct { - db *data.Data -} - -func (repo personalRepo) GetPersonalProfile(ctx context.Context, in *pb.GetPersonalProfileRequest) (*pb.GetPersonalProfileResponse, error) { - userid := securityx.GetUserID(ctx) - if userid == "" { - return nil, dto.ErrUserNotFound - } - if userid == "admin" { - return &pb.GetPersonalProfileResponse{ - User: &typespb.User{ - Id: 0, - Uuid: "admin", - Username: "admin", - Email: "admin", - Phone: "admin", - Avatar: "https://raw.githubusercontent.com/OrigAdmin/OrigAdmin/master/origadmin.png", - Nickname: "admin", - Status: 1, - }, - }, nil - } - userObj, err := repo.db.User(ctx).Query().Where(user.UUID(userid)).First(ctx) - if err != nil { - return nil, dto.ErrUserNotFound - } - return &pb.GetPersonalProfileResponse{ - User: dto.ConvertUser2PB(userObj), - }, nil -} - -func (repo personalRepo) ListPersonalRoles(ctx context.Context, in *pb.ListPersonalRolesRequest) (*pb.ListPersonalRolesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (repo personalRepo) UpdatePersonalPassword(ctx context.Context, in *pb.UpdatePersonalPasswordRequest) (*pb.UpdatePersonalPasswordResponse, error) { - //TODO implement me - panic("implement me") -} - -func (repo personalRepo) UpdatePersonalProfile(ctx context.Context, in *pb.UpdatePersonalProfileRequest) (*pb.UpdatePersonalProfileResponse, error) { - //TODO implement me - panic("implement me") -} - -func (repo personalRepo) ListPersonalResources(ctx context.Context, in *pb.ListPersonalResourcesRequest) (*pb.ListPersonalResourcesResponse, error) { - tr, ok := transport.FromServerContext(ctx) - log.Infof("tr: %+v", tr.RequestHeader()) - log.Infof("ok: %+v", ok) - uid := securityx.GetUserID(ctx) - log.Infof("uid: %+v", uid) - resourceQuery := repo.db.Resource(ctx).Query() - if uid != "admin" { - resourceQuery = repo.db.User(ctx).Query().Where(user.ID(in.Id)).QueryRoles().QueryPermissions().QueryResources() - } - resources, err := resourceQuery.Where(resource.StatusEQ(dto.ResourceStatusEnabled)).All(ctx) - if err != nil { - return nil, err - } - return &pb.ListPersonalResourcesResponse{ - TotalSize: int64(len(resources)), - Resources: dto.ConvertResources2PB(resources), - }, nil -} - -//func (repo personalRepo) ListResources(ctx context.Context, in *dto.ListResourcesRequest, options ...dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { -// var option dto.ResourceQueryOption -// if len(options) > 0 { -// option = options[0] -// } -// query := repo.db.Resource(ctx).Query() -// return personalPageQuery(ctx, query, in, option) -//} - -// NewPersonalRepo . -func NewPersonalRepo(r runtime.Runtime, db *data.Data) dto.PersonalRepo { - return &personalRepo{ - db: db, - } -} - -//func personalPageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.ListResourcesRequest, option dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { -// query = personalQueryOptions(query, option) -// count, err := query.Count(ctx) -// if err != nil { -// return nil, 0, err -// } -// query = personalQueryPage(query, in) -// result, err := query.All(ctx) -// return dto.ConvertResources2PB(result), int32(count), err -//} -// -//func personalQueryPage(query *ent.ResourceQuery, in *pb.ListResourcesRequest) *ent.ResourceQuery { -// if in.NoPaging { -// pageSize := in.PageSize -// if pageSize > 0 { -// query = query.Limit(int(pageSize)) -// } -// return query -// } -// -// pageSize := in.PageSize -// if pageSize > 0 { -// query = query.Limit(int(pageSize)) -// } -// current := in.Current -// if current > 0 { -// query = query.Offset(int((current - 1) * pageSize)) -// } -// return query -//} - -//func personalQueryOptions(query *ent.ResourceQuery, option dto.ResourceQueryOption) *ent.ResourceQuery { -// if len(option.SelectFields) > 0 { -// query = query.Select(option.SelectFields...).ResourceQuery -// } -// if len(option.OmitFields) > 0 { -// query = query.Omit(option.OmitFields...).ResourceQuery -// } -// if len(option.OrderFields) > 0 { -// query = query.Order(personalOrderBy(option.OrderFields)...) -// } -// return query -//} - -//func personalOrderBy(fields []string, opts ...sql.OrderTermOption) []resource.OrderOption { -// var orders []resource.OrderOption -// for _, field := range fields { -// orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) -// } -// return orders -//} diff --git a/internal/features/auth/dal/provider.go b/internal/features/auth/dal/provider.go index 70d8ceda..1178287d 100644 --- a/internal/features/auth/dal/provider.go +++ b/internal/features/auth/dal/provider.go @@ -1,20 +1,6 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dal implements the functions, types, and interfaces for the module. package dal -import ( - "github.com/google/wire" -) +import "github.com/google/wire" -// ProviderSet is data providers. -var ProviderSet = wire.NewSet( - //NewData, - NewAuthRepo, - NewLoginRepo, - NewCasbinSourceRepo, - NewPersonalRepo, - RefreshTokenizer, -) +// ProviderSet is dal providers. +var ProviderSet = wire.NewSet(NewAuthRepo, NewMeRepo) diff --git a/internal/features/auth/dal/user.dal.go b/internal/features/auth/dal/user.dal.go deleted file mode 100644 index a7487141..00000000 --- a/internal/features/auth/dal/user.dal.go +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dal is the data access object -package dal - -import ( - "errors" - "time" - - "github.com/origadmin/runtime/context" - - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/features/auth/dto" // Corrected import path -) - -type userRepo struct { - db *data.Data -} - -//func (repo userRepo) AddRoleIDs(ctx context.Context, i int64, int64s []int64, option ...dto.UserMutationOption) error { -// //TODO implement me -// panic("implement me") -//} -// -//func (repo userRepo) UpdateUserStatus(ctx context.Context, id int64, status int8, options ...dto.UserQueryOption) error { -// err := repo.db.User(ctx).UpdateOneID(id).SetStatus(status).Exec(ctx) -// if err != nil { -// return err -// } -// return nil -//} -// -//func (repo userRepo) Current(ctx context.Context, id int64) (*dto.UserPB, error) { -// return repo.Get(ctx, id) -//} -// -//func (repo userRepo) ListResourceByUserID(ctx context.Context, id int64, -// option ...dto.UserQueryOption) ([]*dto.ResourcePB, error) { -// resources, err := repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) -// if err != nil { -// return nil, err -// } -// return dto.ConvertResources2PB(resources), nil -//} - -//func (repo userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*dto.UserNode, error) { -// query := repo.db.User(ctx).Query().Where(user.UsernameEQ(username)) -// var option dto.UserQueryOption -// if len(fields) > 0 { -// option.SelectFields = fields -// } -// query = userQueryOptions(query, option) -// result, err := query.First(ctx) -// if err != nil { -// return nil, err -// } -// return &dto.UserNode{ -// UserPB: *dto.ConvertUser2PB(result), -// EncryptedPassword: result.EncryptedPassword, -// }, nil -//} - -//func (repo userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { -// return repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().IDs(ctx) -//} -// -//func (repo userRepo) Get(ctx context.Context, id int64, options ...dto.UserQueryOption) (*dto.UserPB, error) { -// var option dto.UserQueryOption -// if len(options) > 0 { -// option = options[0] -// } -// query := repo.db.User(ctx).Query().Where(user.ID(id)) -// query = userQueryOptions(query, option) -// result, err := query.First(ctx) -// if err != nil { -// return nil, err -// } -// return dto.ConvertUser2PB(result), nil -//} - -func (repo userRepo) Create(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { - var option dto.UserMutationOption - if len(options) > 0 { - option = options[0] - } - - var err error - exist, err := repo.db.User(ctx).Query().Where(user.UsernameEQ(userPB.Username)).Exist(ctx) - if err != nil || exist { - return nil, errors.New("user already exists") - } - obj := dto.ConvertUserPB2Object(userPB) - obj.CreateTime = time.Now() - obj.UpdateTime = time.Now() - err = repo.db.Tx(ctx, func(ctx context.Context) error { - create := repo.db.User(ctx).Create() - create.SetUser(obj, option.Fields...) - saved, err := create.Save(ctx) - if err != nil { - return err - } - userPB = dto.ConvertUser2PB(saved) - return nil - }) - if err != nil { - return nil, err - } - return userPB, nil -} - -func (repo userRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Tx(ctx, func(ctx context.Context) error { - return repo.db.User(ctx).DeleteOneID(id).Exec(ctx) - }) -} - -func (repo userRepo) Update(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { - obj := dto.ConvertUserPB2Object(userPB) - obj.UpdateTime = time.Now() - err := repo.db.Tx(ctx, func(ctx context.Context) error { - update := repo.db.User(ctx).UpdateOneID(userPB.Id) - if len(userPB.Roles) > 0 { - update.ClearRoles() - update.AddRoles(dto.ConvertRolesPB2Object(userPB.Roles)...) - } else { - update.ClearRoles() - } - if len(userPB.RoleIds) > 0 { - update.ClearRoles() - update.AddRoleIDs(userPB.RoleIds...) - } else { - update.ClearRoles() - } - update.SetUser(obj, user.SelectColumns([]string{ - user.FieldNickname, - user.FieldUsername, - user.FieldPhone, - user.FieldEmail, - user.FieldUpdateTime})...) - saved, err := update.Save(ctx) - if err != nil { - return err - } - userPB = dto.ConvertUser2PB(saved) - return nil - }) - if err != nil { - return nil, err - } - return userPB, nil -} - -//func (repo userRepo) List(ctx context.Context, in *pb.ListUsersRequest, options ...dto.UserQueryOption) ([]*dto.UserPB, int32, error) { -// var option dto.UserQueryOption -// if len(options) > 0 { -// option = options[0] -// } -// -// query := repo.db.User(ctx).Query() -// if option.IncludeRoles { -// query = query.WithRoles() -// } -// if in.Title != "" { -// query = query.Where(user.Or(user.UsernameContainsFold(in.Title), user.PhoneContainsFold(in.Title), user.EmailContainsFold(in.Title))) -// } -// -// if v := option.Status; v > 0 { -// query = query.Where(user.StatusEQ(v)) -// } -// -// return userPageQuery(ctx, query, in, option) -//} -// -//// NewUserRepo . -//func NewUserRepo(r runtime.Runtime, db *data.Data) dto.UserRepo { -// return &userRepo{ -// db: db, -// } -//} -// -//func userPageQuery(ctx context.Context, query *ent.UserQuery, in *pb.ListUsersRequest, option dto.UserQueryOption) ([]*dto.UserPB, int32, error) { -// if in.OnlyCount { -// count, err := query.Count(ctx) -// if err != nil { -// return nil, 0, err -// } -// return nil, int32(count), nil -// } -// -// query = userQueryOptions(query, option) -// count, err := query.Count(ctx) -// if err != nil { -// return nil, 0, err -// } -// query = db.PaginationQuery(query, in, !in.NoPaging) -// result, err := query.All(ctx) -// return dto.ConvertUsers(result), int32(count), err -//} -// -//func userQueryOptions(query *ent.UserQuery, option dto.UserQueryOption) *ent.UserQuery { -// if len(option.SelectFields) > 0 { -// query = query.Select(option.SelectFields...).UserQuery -// } -// if len(option.OmitFields) > 0 { -// query = query.Omit(option.OmitFields...).UserQuery -// } -// if len(option.OrderFields) > 0 { -// query = query.Order(userOrderBy(option.OrderFields)...) -// } -// return query -//} -// -//func userOrderBy(fields []string, opts ...sql.OrderTermOption) []user.OrderOption { -// var orders []user.OrderOption -// for _, field := range fields { -// orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) -// } -// return orders -//} diff --git a/internal/features/auth/dto/auth.go b/internal/features/auth/dto/auth.go index d7bc1c55..2d7bdba3 100644 --- a/internal/features/auth/dto/auth.go +++ b/internal/features/auth/dto/auth.go @@ -1,50 +1,11 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the auth module. package dto import ( "context" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/auth" ) -type ( - ListAuthResourcesRequest = pb.ListAuthResourcesRequest - ListAuthResourcesResponse = pb.ListAuthResourcesResponse -) - -// AuthRepo is a Auth repository interface. +// AuthRepo defines the data access methods for authentication. type AuthRepo interface { - ListAuthResources(context.Context, *ListAuthResourcesRequest, ...AuthResourceQueryOption) ([]*ResourcePB, int32, error) - CreateToken(context.Context, *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error) - ValidateToken(context.Context, *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) - DestroyToken(context.Context, *pb.DestroyTokenRequest) (*pb.DestroyTokenResponse, error) - Authenticate(context.Context, *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) - AuthLogout(context.Context, *pb.AuthLogoutRequest) (*pb.AuthLogoutResponse, error) -} - -type AuthResourceQueryOption struct { - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string -} - -func (o AuthResourceQueryOption) FromListRequest(in *ListAuthResourcesRequest, limiter repo.PageLimiter) error { - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func ToListAuthResourcesResponse(result []*ResourcePB, in *ListAuthResourcesRequest, total int32, args ...any) (*ListAuthResourcesResponse, error) { - response := &ListAuthResourcesResponse{ - Resources: result, - TotalSize: total, - } - return response, nil + // GetUserByUsername retrieves a user by their username. + GetUserByUsername(ctx context.Context, username string) (*User, error) } diff --git a/internal/features/auth/dto/casbin.go b/internal/features/auth/dto/casbin.go index 16be5b21..357c03b1 100644 --- a/internal/features/auth/dto/casbin.go +++ b/internal/features/auth/dto/casbin.go @@ -16,12 +16,9 @@ type ( ListPoliciesResponse = pb.ListPoliciesResponse ListGroupingsRequest = pb.ListGroupingsRequest ListGroupingsResponse = pb.ListGroupingsResponse - //WatchUpdateRequest = pb.WatchUpdateRequest - //WatchUpdateResponse = pb.WatchUpdateResponse ) type CasbinSourceRepo interface { ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) - //WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) } diff --git a/internal/features/auth/dto/custom.gen.go b/internal/features/auth/dto/custom.gen.go new file mode 100644 index 00000000..5435a449 --- /dev/null +++ b/internal/features/auth/dto/custom.gen.go @@ -0,0 +1,52 @@ +// This file is generated by abgen, but you can edit it. +// More info: https://github.com/origadmin/abgen + +package dto + +import ( + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/view" +) + +// ConvertGenderToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertGenderToString(from user.Gender) string { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertInt32ToStatus is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertInt32ToStatus(from int32) resource.Status { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertStatusToInt32 is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStatusToInt32(from resource.Status) int32 { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertStringToGender is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToGender(from string) user.Gender { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertStringToType is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToType(from string) view.Type { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertTypeToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertTypeToString(from view.Type) string { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} diff --git a/internal/features/auth/dto/dto.gen.go b/internal/features/auth/dto/dto.gen.go new file mode 100644 index 00000000..144fda3d --- /dev/null +++ b/internal/features/auth/dto/dto.gen.go @@ -0,0 +1,1279 @@ +//go:build !abgen_source + +// Code generated by abgen. DO NOT EDIT. +// versions: v0.0.1 +// source: . + +package dto + +import ( + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/enums" + "time" + + "google.golang.org/protobuf/types/known/timestamppb" +) + +// Local type aliases for external types. +type ( + Department = ent.Department + DepartmentEdges = ent.DepartmentEdges + DepartmentEdgesPB = types.DepartmentEdges + DepartmentPB = types.Department + Departments = []*ent.Department + DepartmentsPB = []*types.Department + Permission = ent.Permission + PermissionEdges = ent.PermissionEdges + PermissionEdgesPB = types.PermissionEdges + PermissionPB = types.Permission + PermissionResource = ent.PermissionResource + PermissionResourceEdges = ent.PermissionResourceEdges + PermissionResourceEdgesPB = types.PermissionResourceEdges + PermissionResourcePB = types.PermissionResource + PermissionResources = []*ent.PermissionResource + PermissionResourcesPB = []*types.PermissionResource + Permissions = []*ent.Permission + PermissionsPB = []*types.Permission + Position = ent.Position + PositionEdges = ent.PositionEdges + PositionEdgesPB = types.PositionEdges + PositionPB = types.Position + PositionPermission = ent.PositionPermission + PositionPermissionEdges = ent.PositionPermissionEdges + PositionPermissionEdgesPB = types.PositionPermissionEdges + PositionPermissionPB = types.PositionPermission + PositionPermissions = []*ent.PositionPermission + PositionPermissionsPB = []*types.PositionPermission + Positions = []*ent.Position + PositionsPB = []*types.Position + Resource = ent.Resource + ResourceEdges = ent.ResourceEdges + ResourceEdgesPB = types.ResourceEdges + ResourcePB = types.Resource + Resources = []*ent.Resource + ResourcesPB = []*types.Resource + Role = ent.Role + RoleEdges = ent.RoleEdges + RoleEdgesPB = types.RoleEdges + RolePB = types.Role + RolePermission = ent.RolePermission + RolePermissionEdges = ent.RolePermissionEdges + RolePermissionEdgesPB = types.RolePermissionEdges + RolePermissionPB = types.RolePermission + RolePermissions = []*ent.RolePermission + RolePermissionsPB = []*types.RolePermission + RoleViewPB = types.RoleView + RoleViewsPB = []*types.RoleView + Roles = []*ent.Role + RolesPB = []*types.Role + User = ent.User + UserDepartment = ent.UserDepartment + UserDepartmentEdges = ent.UserDepartmentEdges + UserDepartmentEdgesPB = types.UserDepartmentEdges + UserDepartmentPB = types.UserDepartment + UserDepartments = []*ent.UserDepartment + UserDepartmentsPB = []*types.UserDepartment + UserEdges = ent.UserEdges + UserEdgesPB = types.UserEdges + UserPB = types.User + UserPosition = ent.UserPosition + UserPositionEdges = ent.UserPositionEdges + UserPositionEdgesPB = types.UserPositionEdges + UserPositionPB = types.UserPosition + UserPositions = []*ent.UserPosition + UserPositionsPB = []*types.UserPosition + UserRole = ent.UserRole + UserRoleEdges = ent.UserRoleEdges + UserRoleEdgesPB = types.UserRoleEdges + UserRolePB = types.UserRole + UserRoles = []*ent.UserRole + UserRolesPB = []*types.UserRole + Users = []*ent.User + UsersPB = []*types.User + View = ent.View + ViewEdges = ent.ViewEdges + ViewEdgesPB = types.ViewEdges + ViewPB = types.View + ViewPermission = ent.ViewPermission + ViewPermissionEdges = ent.ViewPermissionEdges + ViewPermissions = []*ent.ViewPermission + ViewResource = ent.ViewResource + ViewResourceEdges = ent.ViewResourceEdges + ViewResources = []*ent.ViewResource + Views = []*ent.View + ViewsPB = []*types.View +) + +// ConvertDepartmentEdgesPBToDepartmentEdges converts DepartmentEdgesPB to DepartmentEdges. +func ConvertDepartmentEdgesPBToDepartmentEdges(from *DepartmentEdgesPB) *DepartmentEdges { + if from == nil { + return nil + } + + to := &DepartmentEdges{ + Users: ConvertUsersPBToUsers(from.Users), + Positions: ConvertPositionsPBToPositions(from.Positions), + Parent: ConvertDepartmentPBToDepartment(from.Parent), + Children: ConvertDepartmentsPBToDepartments(from.Children), + UserDepartments: ConvertUserDepartmentsPBToUserDepartments(from.UserDepartments), + } + return to +} + +// ConvertDepartmentEdgesToDepartmentEdgesPB converts DepartmentEdges to DepartmentEdgesPB. +func ConvertDepartmentEdgesToDepartmentEdgesPB(from *DepartmentEdges) *DepartmentEdgesPB { + if from == nil { + return nil + } + + to := &DepartmentEdgesPB{ + Users: ConvertUsersToUsersPB(from.Users), + Positions: ConvertPositionsToPositionsPB(from.Positions), + Children: ConvertDepartmentsToDepartmentsPB(from.Children), + Parent: ConvertDepartmentToDepartmentPB(from.Parent), + UserDepartments: ConvertUserDepartmentsToUserDepartmentsPB(from.UserDepartments), + } + return to +} + +// ConvertDepartmentPBToDepartment converts DepartmentPB to Department. +func ConvertDepartmentPBToDepartment(from *DepartmentPB) *Department { + if from == nil { + return nil + } + + to := &Department{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + TreePath: from.TreePath, + Sequence: int(from.Sequence), + Status: int8(from.Status), + Level: int(from.Level), + Description: from.Description, + ParentID: from.ParentId, + } + return to +} + +// ConvertDepartmentToDepartmentPB converts Department to DepartmentPB. +func ConvertDepartmentToDepartmentPB(from *Department) *DepartmentPB { + if from == nil { + return nil + } + + to := &DepartmentPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + TreePath: from.TreePath, + Sequence: int32(from.Sequence), + Status: int32(from.Status), + Level: int32(from.Level), + Description: from.Description, + ParentId: from.ParentID, + Children: ConvertDepartmentsToDepartmentsPB(from.Edges.Children), + Parent: ConvertDepartmentToDepartmentPB(from.Edges.Parent), + } + return to +} + +// ConvertDepartmentsPBToDepartments converts a slice of *DepartmentPB to a slice of *Department. +func ConvertDepartmentsPBToDepartments(froms DepartmentsPB) Departments { + if froms == nil { + return nil + } + tos := make(Departments, len(froms)) + for i, f := range froms { + tos[i] = ConvertDepartmentPBToDepartment(f) + } + return tos +} + +// ConvertDepartmentsToDepartmentsPB converts a slice of *Department to a slice of *DepartmentPB. +func ConvertDepartmentsToDepartmentsPB(froms Departments) DepartmentsPB { + if froms == nil { + return nil + } + tos := make(DepartmentsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertDepartmentToDepartmentPB(f) + } + return tos +} + +// ConvertPermissionEdgesPBToPermissionEdges converts PermissionEdgesPB to PermissionEdges. +func ConvertPermissionEdgesPBToPermissionEdges(from *PermissionEdgesPB) *PermissionEdges { + if from == nil { + return nil + } + + to := &PermissionEdges{ + Roles: ConvertRolesPBToRoles(from.Roles), + Positions: ConvertPositionsPBToPositions(from.Positions), + Resources: ConvertResourcesPBToResources(from.Resources), + RolePermissions: ConvertRolePermissionsPBToRolePermissions(from.RolePermissions), + PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), + PermissionResources: ConvertPermissionResourcesPBToPermissionResources(from.PermissionResources), + } + return to +} + +// ConvertPermissionEdgesToPermissionEdgesPB converts PermissionEdges to PermissionEdgesPB. +func ConvertPermissionEdgesToPermissionEdgesPB(from *PermissionEdges) *PermissionEdgesPB { + if from == nil { + return nil + } + + to := &PermissionEdgesPB{ + Roles: ConvertRolesToRolesPB(from.Roles), + Resources: ConvertResourcesToResourcesPB(from.Resources), + Positions: ConvertPositionsToPositionsPB(from.Positions), + RolePermissions: ConvertRolePermissionsToRolePermissionsPB(from.RolePermissions), + PermissionResources: ConvertPermissionResourcesToPermissionResourcesPB(from.PermissionResources), + PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), + } + return to +} + +// ConvertPermissionPBToPermission converts PermissionPB to Permission. +func ConvertPermissionPBToPermission(from *PermissionPB) *Permission { + if from == nil { + return nil + } + + to := &Permission{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DataScope: from.DataScope, + DataRules: from.DataRules, + } + return to +} + +// ConvertPermissionResourceEdgesPBToPermissionResourceEdges converts PermissionResourceEdgesPB to PermissionResourceEdges. +func ConvertPermissionResourceEdgesPBToPermissionResourceEdges(from *PermissionResourceEdgesPB) *PermissionResourceEdges { + if from == nil { + return nil + } + + to := &PermissionResourceEdges{ + Permission: ConvertPermissionPBToPermission(from.Permission), + Resource: ConvertResourcePBToResource(from.Resource), + } + return to +} + +// ConvertPermissionResourceEdgesToPermissionResourceEdgesPB converts PermissionResourceEdges to PermissionResourceEdgesPB. +func ConvertPermissionResourceEdgesToPermissionResourceEdgesPB(from *PermissionResourceEdges) *PermissionResourceEdgesPB { + if from == nil { + return nil + } + + to := &PermissionResourceEdgesPB{ + Permission: ConvertPermissionToPermissionPB(from.Permission), + Resource: ConvertResourceToResourcePB(from.Resource), + } + return to +} + +// ConvertPermissionResourcePBToPermissionResource converts PermissionResourcePB to PermissionResource. +func ConvertPermissionResourcePBToPermissionResource(from *PermissionResourcePB) *PermissionResource { + if from == nil { + return nil + } + + to := &PermissionResource{ + ID: int(from.Id), + PermissionID: from.PermissionId, + ResourceID: from.ResourceId, + } + return to +} + +// ConvertPermissionResourceToPermissionResourcePB converts PermissionResource to PermissionResourcePB. +func ConvertPermissionResourceToPermissionResourcePB(from *PermissionResource) *PermissionResourcePB { + if from == nil { + return nil + } + + to := &PermissionResourcePB{ + Id: int64(from.ID), + PermissionId: from.PermissionID, + ResourceId: from.ResourceID, + } + return to +} + +// ConvertPermissionResourcesPBToPermissionResources converts a slice of *PermissionResourcePB to a slice of *PermissionResource. +func ConvertPermissionResourcesPBToPermissionResources(froms PermissionResourcesPB) PermissionResources { + if froms == nil { + return nil + } + tos := make(PermissionResources, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionResourcePBToPermissionResource(f) + } + return tos +} + +// ConvertPermissionResourcesToPermissionResourcesPB converts a slice of *PermissionResource to a slice of *PermissionResourcePB. +func ConvertPermissionResourcesToPermissionResourcesPB(froms PermissionResources) PermissionResourcesPB { + if froms == nil { + return nil + } + tos := make(PermissionResourcesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionResourceToPermissionResourcePB(f) + } + return tos +} + +// ConvertPermissionToPermissionPB converts Permission to PermissionPB. +func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { + if from == nil { + return nil + } + + to := &PermissionPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DataScope: from.DataScope, + DataRules: from.DataRules, + Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), + } + return to +} + +// ConvertPermissionsPBToPermissions converts a slice of *PermissionPB to a slice of *Permission. +func ConvertPermissionsPBToPermissions(froms PermissionsPB) Permissions { + if froms == nil { + return nil + } + tos := make(Permissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionPBToPermission(f) + } + return tos +} + +// ConvertPermissionsToPermissionsPB converts a slice of *Permission to a slice of *PermissionPB. +func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { + if froms == nil { + return nil + } + tos := make(PermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionToPermissionPB(f) + } + return tos +} + +// ConvertPositionEdgesPBToPositionEdges converts PositionEdgesPB to PositionEdges. +func ConvertPositionEdgesPBToPositionEdges(from *PositionEdgesPB) *PositionEdges { + if from == nil { + return nil + } + + to := &PositionEdges{ + Department: ConvertDepartmentPBToDepartment(from.Department), + Users: ConvertUsersPBToUsers(from.Users), + Permissions: ConvertPermissionsPBToPermissions(from.Permissions), + UserPositions: ConvertUserPositionsPBToUserPositions(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), + } + return to +} + +// ConvertPositionEdgesToPositionEdgesPB converts PositionEdges to PositionEdgesPB. +func ConvertPositionEdgesToPositionEdgesPB(from *PositionEdges) *PositionEdgesPB { + if from == nil { + return nil + } + + to := &PositionEdgesPB{ + Department: ConvertDepartmentToDepartmentPB(from.Department), + Users: ConvertUsersToUsersPB(from.Users), + Permissions: ConvertPermissionsToPermissionsPB(from.Permissions), + UserPositions: ConvertUserPositionsToUserPositionsPB(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), + } + return to +} + +// ConvertPositionPBToPosition converts PositionPB to Position. +func ConvertPositionPBToPosition(from *PositionPB) *Position { + if from == nil { + return nil + } + + to := &Position{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DepartmentID: from.DepartmentId, + } + return to +} + +// ConvertPositionPermissionEdgesPBToPositionPermissionEdges converts PositionPermissionEdgesPB to PositionPermissionEdges. +func ConvertPositionPermissionEdgesPBToPositionPermissionEdges(from *PositionPermissionEdgesPB) *PositionPermissionEdges { + if from == nil { + return nil + } + + to := &PositionPermissionEdges{ + Position: ConvertPositionPBToPosition(from.Position), + Permission: ConvertPermissionPBToPermission(from.Permission), + } + return to +} + +// ConvertPositionPermissionEdgesToPositionPermissionEdgesPB converts PositionPermissionEdges to PositionPermissionEdgesPB. +func ConvertPositionPermissionEdgesToPositionPermissionEdgesPB(from *PositionPermissionEdges) *PositionPermissionEdgesPB { + if from == nil { + return nil + } + + to := &PositionPermissionEdgesPB{ + Position: ConvertPositionToPositionPB(from.Position), + Permission: ConvertPermissionToPermissionPB(from.Permission), + } + return to +} + +// ConvertPositionPermissionPBToPositionPermission converts PositionPermissionPB to PositionPermission. +func ConvertPositionPermissionPBToPositionPermission(from *PositionPermissionPB) *PositionPermission { + if from == nil { + return nil + } + + to := &PositionPermission{ + ID: int(from.Id), + PositionID: from.PositionId, + PermissionID: from.PermissionId, + } + return to +} + +// ConvertPositionPermissionToPositionPermissionPB converts PositionPermission to PositionPermissionPB. +func ConvertPositionPermissionToPositionPermissionPB(from *PositionPermission) *PositionPermissionPB { + if from == nil { + return nil + } + + to := &PositionPermissionPB{ + Id: int64(from.ID), + PositionId: from.PositionID, + PermissionId: from.PermissionID, + } + return to +} + +// ConvertPositionPermissionsPBToPositionPermissions converts a slice of *PositionPermissionPB to a slice of *PositionPermission. +func ConvertPositionPermissionsPBToPositionPermissions(froms PositionPermissionsPB) PositionPermissions { + if froms == nil { + return nil + } + tos := make(PositionPermissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionPBToPositionPermission(f) + } + return tos +} + +// ConvertPositionPermissionsToPositionPermissionsPB converts a slice of *PositionPermission to a slice of *PositionPermissionPB. +func ConvertPositionPermissionsToPositionPermissionsPB(froms PositionPermissions) PositionPermissionsPB { + if froms == nil { + return nil + } + tos := make(PositionPermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionToPositionPermissionPB(f) + } + return tos +} + +// ConvertPositionToPositionPB converts Position to PositionPB. +func ConvertPositionToPositionPB(from *Position) *PositionPB { + if from == nil { + return nil + } + + to := &PositionPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DepartmentId: from.DepartmentID, + } + return to +} + +// ConvertPositionsPBToPositions converts a slice of *PositionPB to a slice of *Position. +func ConvertPositionsPBToPositions(froms PositionsPB) Positions { + if froms == nil { + return nil + } + tos := make(Positions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPBToPosition(f) + } + return tos +} + +// ConvertPositionsToPositionsPB converts a slice of *Position to a slice of *PositionPB. +func ConvertPositionsToPositionsPB(froms Positions) PositionsPB { + if froms == nil { + return nil + } + tos := make(PositionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionToPositionPB(f) + } + return tos +} + +// ConvertResourceEdgesPBToResourceEdges converts ResourceEdgesPB to ResourceEdges. +func ConvertResourceEdgesPBToResourceEdges(from *ResourceEdgesPB) *ResourceEdges { + if from == nil { + return nil + } + + to := &ResourceEdges{} + return to +} + +// ConvertResourceEdgesToResourceEdgesPB converts ResourceEdges to ResourceEdgesPB. +func ConvertResourceEdgesToResourceEdgesPB(from *ResourceEdges) *ResourceEdgesPB { + if from == nil { + return nil + } + + to := &ResourceEdgesPB{} + return to +} + +// ConvertResourcePBToResource converts ResourcePB to Resource. +func ConvertResourcePBToResource(from *ResourcePB) *Resource { + if from == nil { + return nil + } + + to := &Resource{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Path: from.Path, + Method: from.Method, + Operation: from.Operation, + Status: ConvertInt32ToStatus(from.Status), + } + return to +} + +// ConvertResourceToResourcePB converts Resource to ResourcePB. +func ConvertResourceToResourcePB(from *Resource) *ResourcePB { + if from == nil { + return nil + } + + to := &ResourcePB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Status: ConvertStatusToInt32(from.Status), + Path: from.Path, + Operation: from.Operation, + Method: from.Method, + Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), + } + return to +} + +// ConvertResourcesPBToResources converts a slice of *ResourcePB to a slice of *Resource. +func ConvertResourcesPBToResources(froms ResourcesPB) Resources { + if froms == nil { + return nil + } + tos := make(Resources, len(froms)) + for i, f := range froms { + tos[i] = ConvertResourcePBToResource(f) + } + return tos +} + +// ConvertResourcesToResourcesPB converts a slice of *Resource to a slice of *ResourcePB. +func ConvertResourcesToResourcesPB(froms Resources) ResourcesPB { + if froms == nil { + return nil + } + tos := make(ResourcesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertResourceToResourcePB(f) + } + return tos +} + +// ConvertRoleEdgesPBToRoleEdges converts RoleEdgesPB to RoleEdges. +func ConvertRoleEdgesPBToRoleEdges(from *RoleEdgesPB) *RoleEdges { + if from == nil { + return nil + } + + to := &RoleEdges{ + Users: ConvertUsersPBToUsers(from.Users), + UserRoles: ConvertUserRolesPBToUserRoles(from.UserRoles), + } + return to +} + +// ConvertRoleEdgesToRoleEdgesPB converts RoleEdges to RoleEdgesPB. +func ConvertRoleEdgesToRoleEdgesPB(from *RoleEdges) *RoleEdgesPB { + if from == nil { + return nil + } + + to := &RoleEdgesPB{ + Users: ConvertUsersToUsersPB(from.Users), + UserRoles: ConvertUserRolesToUserRolesPB(from.UserRoles), + } + return to +} + +// ConvertRolePBToRole converts RolePB to Role. +func ConvertRolePBToRole(from *RolePB) *Role { + if from == nil { + return nil + } + + to := &Role{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Description: from.Description, + Type: enums.RoleType(from.Type), + Sequence: int(from.Sequence), + Status: enums.Status(from.Status), + } + return to +} + +// ConvertRolePermissionEdgesPBToRolePermissionEdges converts RolePermissionEdgesPB to RolePermissionEdges. +func ConvertRolePermissionEdgesPBToRolePermissionEdges(from *RolePermissionEdgesPB) *RolePermissionEdges { + if from == nil { + return nil + } + + to := &RolePermissionEdges{ + Role: ConvertRolePBToRole(from.Role), + Permission: ConvertPermissionPBToPermission(from.Permission), + } + return to +} + +// ConvertRolePermissionEdgesToRolePermissionEdgesPB converts RolePermissionEdges to RolePermissionEdgesPB. +func ConvertRolePermissionEdgesToRolePermissionEdgesPB(from *RolePermissionEdges) *RolePermissionEdgesPB { + if from == nil { + return nil + } + + to := &RolePermissionEdgesPB{ + Role: ConvertRoleToRolePB(from.Role), + Permission: ConvertPermissionToPermissionPB(from.Permission), + } + return to +} + +// ConvertRolePermissionPBToRolePermission converts RolePermissionPB to RolePermission. +func ConvertRolePermissionPBToRolePermission(from *RolePermissionPB) *RolePermission { + if from == nil { + return nil + } + + to := &RolePermission{ + ID: int(from.Id), + RoleID: from.RoleId, + PermissionID: from.PermissionId, + } + return to +} + +// ConvertRolePermissionToRolePermissionPB converts RolePermission to RolePermissionPB. +func ConvertRolePermissionToRolePermissionPB(from *RolePermission) *RolePermissionPB { + if from == nil { + return nil + } + + to := &RolePermissionPB{ + Id: int64(from.ID), + RoleId: from.RoleID, + PermissionId: from.PermissionID, + } + return to +} + +// ConvertRolePermissionsPBToRolePermissions converts a slice of *RolePermissionPB to a slice of *RolePermission. +func ConvertRolePermissionsPBToRolePermissions(froms RolePermissionsPB) RolePermissions { + if froms == nil { + return nil + } + tos := make(RolePermissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertRolePermissionPBToRolePermission(f) + } + return tos +} + +// ConvertRolePermissionsToRolePermissionsPB converts a slice of *RolePermission to a slice of *RolePermissionPB. +func ConvertRolePermissionsToRolePermissionsPB(froms RolePermissions) RolePermissionsPB { + if froms == nil { + return nil + } + tos := make(RolePermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertRolePermissionToRolePermissionPB(f) + } + return tos +} + +// ConvertRoleToRolePB converts Role to RolePB. +func ConvertRoleToRolePB(from *Role) *RolePB { + if from == nil { + return nil + } + + to := &RolePB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Description: from.Description, + Type: int32(from.Type), + Sequence: int32(from.Sequence), + Status: int32(from.Status), + Users: ConvertUsersToUsersPB(from.Edges.Users), + Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), + } + return to +} + +// ConvertRolesPBToRoles converts a slice of *RolePB to a slice of *Role. +func ConvertRolesPBToRoles(froms RolesPB) Roles { + if froms == nil { + return nil + } + tos := make(Roles, len(froms)) + for i, f := range froms { + tos[i] = ConvertRolePBToRole(f) + } + return tos +} + +// ConvertRolesToRolesPB converts a slice of *Role to a slice of *RolePB. +func ConvertRolesToRolesPB(froms Roles) RolesPB { + if froms == nil { + return nil + } + tos := make(RolesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertRoleToRolePB(f) + } + return tos +} + +// ConvertUserDepartmentEdgesPBToUserDepartmentEdges converts UserDepartmentEdgesPB to UserDepartmentEdges. +func ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from *UserDepartmentEdgesPB) *UserDepartmentEdges { + if from == nil { + return nil + } + + to := &UserDepartmentEdges{ + User: ConvertUserPBToUser(from.User), + Department: ConvertDepartmentPBToDepartment(from.Department), + } + return to +} + +// ConvertUserDepartmentEdgesToUserDepartmentEdgesPB converts UserDepartmentEdges to UserDepartmentEdgesPB. +func ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(from *UserDepartmentEdges) *UserDepartmentEdgesPB { + if from == nil { + return nil + } + + to := &UserDepartmentEdgesPB{ + User: ConvertUserToUserPB(from.User), + Department: ConvertDepartmentToDepartmentPB(from.Department), + } + return to +} + +// ConvertUserDepartmentPBToUserDepartment converts UserDepartmentPB to UserDepartment. +func ConvertUserDepartmentPBToUserDepartment(from *UserDepartmentPB) *UserDepartment { + if from == nil { + return nil + } + + to := &UserDepartment{ + ID: int(from.Id), + UserID: from.UserId, + DepartmentID: from.DepartmentId, + Edges: *ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from.Edges), + } + return to +} + +// ConvertUserDepartmentToUserDepartmentPB converts UserDepartment to UserDepartmentPB. +func ConvertUserDepartmentToUserDepartmentPB(from *UserDepartment) *UserDepartmentPB { + if from == nil { + return nil + } + + to := &UserDepartmentPB{ + Id: int64(from.ID), + UserId: from.UserID, + DepartmentId: from.DepartmentID, + Edges: ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(&from.Edges), + } + return to +} + +// ConvertUserDepartmentsPBToUserDepartments converts a slice of *UserDepartmentPB to a slice of *UserDepartment. +func ConvertUserDepartmentsPBToUserDepartments(froms UserDepartmentsPB) UserDepartments { + if froms == nil { + return nil + } + tos := make(UserDepartments, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserDepartmentPBToUserDepartment(f) + } + return tos +} + +// ConvertUserDepartmentsToUserDepartmentsPB converts a slice of *UserDepartment to a slice of *UserDepartmentPB. +func ConvertUserDepartmentsToUserDepartmentsPB(froms UserDepartments) UserDepartmentsPB { + if froms == nil { + return nil + } + tos := make(UserDepartmentsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserDepartmentToUserDepartmentPB(f) + } + return tos +} + +// ConvertUserEdgesPBToUserEdges converts UserEdgesPB to UserEdges. +func ConvertUserEdgesPBToUserEdges(from *UserEdgesPB) *UserEdges { + if from == nil { + return nil + } + + to := &UserEdges{ + Roles: ConvertRolesPBToRoles(from.Roles), + UserRoles: ConvertUserRolesPBToUserRoles(from.UserRoles), + } + return to +} + +// ConvertUserEdgesToUserEdgesPB converts UserEdges to UserEdgesPB. +func ConvertUserEdgesToUserEdgesPB(from *UserEdges) *UserEdgesPB { + if from == nil { + return nil + } + + to := &UserEdgesPB{ + Roles: ConvertRolesToRolesPB(from.Roles), + UserRoles: ConvertUserRolesToUserRolesPB(from.UserRoles), + } + return to +} + +// ConvertUserPBToUser converts UserPB to User. +func ConvertUserPBToUser(from *UserPB) *User { + if from == nil { + return nil + } + + to := &User{ + ID: from.Id, + CreateAuthor: from.CreateAuthor, + UpdateAuthor: from.UpdateAuthor, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + UUID: from.Uuid, + AllowedIP: from.AllowedIp, + Username: from.Username, + Nickname: from.Nickname, + Avatar: from.Avatar, + Name: from.Name, + Gender: ConvertStringToGender(from.Gender), + Phone: from.Phone, + Email: from.Email, + Remark: from.Remark, + Token: from.Token, + Status: enums.Status(from.Status), + LastLoginIP: from.LastLoginIp, + LastLoginTime: ConvertTimestampToTime(from.LastLoginTime), + SanctionDate: ConvertTimestampToTime(from.SanctionDate), + ManagerID: from.ManagerId, + Manager: from.Manager, + } + return to +} + +// ConvertUserPositionEdgesPBToUserPositionEdges converts UserPositionEdgesPB to UserPositionEdges. +func ConvertUserPositionEdgesPBToUserPositionEdges(from *UserPositionEdgesPB) *UserPositionEdges { + if from == nil { + return nil + } + + to := &UserPositionEdges{ + User: ConvertUserPBToUser(from.User), + Position: ConvertPositionPBToPosition(from.Position), + } + return to +} + +// ConvertUserPositionEdgesToUserPositionEdgesPB converts UserPositionEdges to UserPositionEdgesPB. +func ConvertUserPositionEdgesToUserPositionEdgesPB(from *UserPositionEdges) *UserPositionEdgesPB { + if from == nil { + return nil + } + + to := &UserPositionEdgesPB{ + User: ConvertUserToUserPB(from.User), + Position: ConvertPositionToPositionPB(from.Position), + } + return to +} + +// ConvertUserPositionPBToUserPosition converts UserPositionPB to UserPosition. +func ConvertUserPositionPBToUserPosition(from *UserPositionPB) *UserPosition { + if from == nil { + return nil + } + + to := &UserPosition{ + ID: int(from.Id), + UserID: from.UserId, + PositionID: from.PositionId, + } + return to +} + +// ConvertUserPositionToUserPositionPB converts UserPosition to UserPositionPB. +func ConvertUserPositionToUserPositionPB(from *UserPosition) *UserPositionPB { + if from == nil { + return nil + } + + to := &UserPositionPB{ + Id: int64(from.ID), + UserId: from.UserID, + PositionId: from.PositionID, + } + return to +} + +// ConvertUserPositionsPBToUserPositions converts a slice of *UserPositionPB to a slice of *UserPosition. +func ConvertUserPositionsPBToUserPositions(froms UserPositionsPB) UserPositions { + if froms == nil { + return nil + } + tos := make(UserPositions, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionPBToUserPosition(f) + } + return tos +} + +// ConvertUserPositionsToUserPositionsPB converts a slice of *UserPosition to a slice of *UserPositionPB. +func ConvertUserPositionsToUserPositionsPB(froms UserPositions) UserPositionsPB { + if froms == nil { + return nil + } + tos := make(UserPositionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionToUserPositionPB(f) + } + return tos +} + +// ConvertUserRoleEdgesPBToUserRoleEdges converts UserRoleEdgesPB to UserRoleEdges. +func ConvertUserRoleEdgesPBToUserRoleEdges(from *UserRoleEdgesPB) *UserRoleEdges { + if from == nil { + return nil + } + + to := &UserRoleEdges{ + User: ConvertUserPBToUser(from.User), + Role: ConvertRolePBToRole(from.Role), + } + return to +} + +// ConvertUserRoleEdgesToUserRoleEdgesPB converts UserRoleEdges to UserRoleEdgesPB. +func ConvertUserRoleEdgesToUserRoleEdgesPB(from *UserRoleEdges) *UserRoleEdgesPB { + if from == nil { + return nil + } + + to := &UserRoleEdgesPB{ + User: ConvertUserToUserPB(from.User), + Role: ConvertRoleToRolePB(from.Role), + } + return to +} + +// ConvertUserRolePBToUserRole converts UserRolePB to UserRole. +func ConvertUserRolePBToUserRole(from *UserRolePB) *UserRole { + if from == nil { + return nil + } + + to := &UserRole{ + ID: int(from.Id), + UserID: from.UserId, + RoleID: from.RoleId, + } + return to +} + +// ConvertUserRoleToUserRolePB converts UserRole to UserRolePB. +func ConvertUserRoleToUserRolePB(from *UserRole) *UserRolePB { + if from == nil { + return nil + } + + to := &UserRolePB{ + Id: int64(from.ID), + UserId: from.UserID, + RoleId: from.RoleID, + User: ConvertUserToUserPB(from.Edges.User), + Role: ConvertRoleToRolePB(from.Edges.Role), + } + return to +} + +// ConvertUserRolesPBToUserRoles converts a slice of *UserRolePB to a slice of *UserRole. +func ConvertUserRolesPBToUserRoles(froms UserRolesPB) UserRoles { + if froms == nil { + return nil + } + tos := make(UserRoles, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserRolePBToUserRole(f) + } + return tos +} + +// ConvertUserRolesToUserRolesPB converts a slice of *UserRole to a slice of *UserRolePB. +func ConvertUserRolesToUserRolesPB(froms UserRoles) UserRolesPB { + if froms == nil { + return nil + } + tos := make(UserRolesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserRoleToUserRolePB(f) + } + return tos +} + +// ConvertUserToUserPB converts User to UserPB. +func ConvertUserToUserPB(from *User) *UserPB { + if from == nil { + return nil + } + + to := &UserPB{ + Id: from.ID, + CreateAuthor: from.CreateAuthor, + UpdateAuthor: from.UpdateAuthor, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Uuid: from.UUID, + AllowedIp: from.AllowedIP, + Username: from.Username, + Nickname: from.Nickname, + Avatar: from.Avatar, + Name: from.Name, + Gender: ConvertGenderToString(from.Gender), + Phone: from.Phone, + Email: from.Email, + Remark: from.Remark, + Token: from.Token, + Status: int32(from.Status), + LastLoginIp: from.LastLoginIP, + LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), + SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), + ManagerId: from.ManagerID, + Manager: from.Manager, + Roles: ConvertRolesToRolesPB(from.Edges.Roles), + } + return to +} + +// ConvertUsersPBToUsers converts a slice of *UserPB to a slice of *User. +func ConvertUsersPBToUsers(froms UsersPB) Users { + if froms == nil { + return nil + } + tos := make(Users, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPBToUser(f) + } + return tos +} + +// ConvertUsersToUsersPB converts a slice of *User to a slice of *UserPB. +func ConvertUsersToUsersPB(froms Users) UsersPB { + if froms == nil { + return nil + } + tos := make(UsersPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserToUserPB(f) + } + return tos +} + +// ConvertViewEdgesPBToViewEdges converts ViewEdgesPB to ViewEdges. +func ConvertViewEdgesPBToViewEdges(from *ViewEdgesPB) *ViewEdges { + if from == nil { + return nil + } + + to := &ViewEdges{ + Parent: ConvertViewPBToView(from.Parent), + Children: ConvertViewsPBToViews(from.Children), + Resources: ConvertResourcesPBToResources(from.Resources), + } + return to +} + +// ConvertViewEdgesToViewEdgesPB converts ViewEdges to ViewEdgesPB. +func ConvertViewEdgesToViewEdgesPB(from *ViewEdges) *ViewEdgesPB { + if from == nil { + return nil + } + + to := &ViewEdgesPB{ + Children: ConvertViewsToViewsPB(from.Children), + Parent: ConvertViewToViewPB(from.Parent), + Resources: ConvertResourcesToResourcesPB(from.Resources), + } + return to +} + +// ConvertViewPBToView converts ViewPB to View. +func ConvertViewPBToView(from *ViewPB) *View { + if from == nil { + return nil + } + + to := &View{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + ParentID: from.ParentId, + Keyword: from.Keyword, + Scope: from.Scope, + Name: from.Name, + Type: ConvertStringToType(from.Type), + Path: from.Path, + Icon: from.Icon, + Visible: from.Visible, + Sequence: int(from.Sequence), + TreePath: from.TreePath, + } + return to +} + +// ConvertViewToViewPB converts View to ViewPB. +func ConvertViewToViewPB(from *View) *ViewPB { + if from == nil { + return nil + } + + to := &ViewPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Scope: from.Scope, + Sequence: int32(from.Sequence), + Type: ConvertTypeToString(from.Type), + Icon: from.Icon, + Visible: from.Visible, + Path: from.Path, + TreePath: from.TreePath, + ParentId: from.ParentID, + Children: ConvertViewsToViewsPB(from.Edges.Children), + Parent: ConvertViewToViewPB(from.Edges.Parent), + Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), + } + return to +} + +// ConvertViewsPBToViews converts a slice of *ViewPB to a slice of *View. +func ConvertViewsPBToViews(froms ViewsPB) Views { + if froms == nil { + return nil + } + tos := make(Views, len(froms)) + for i, f := range froms { + tos[i] = ConvertViewPBToView(f) + } + return tos +} + +// ConvertViewsToViewsPB converts a slice of *View to a slice of *ViewPB. +func ConvertViewsToViewsPB(froms Views) ViewsPB { + if froms == nil { + return nil + } + tos := make(ViewsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertViewToViewPB(f) + } + return tos +} + +// --- Helper Functions --- + +func ConvertTimeToTimestamp(t time.Time) *timestamppb.Timestamp { + if t.IsZero() { + return nil + } + return timestamppb.New(t) +} +func ConvertTimestampToTime(ts *timestamppb.Timestamp) time.Time { + if ts == nil { + return time.Time{} + } + return ts.AsTime() +} diff --git a/internal/features/auth/dto/dto.go b/internal/features/auth/dto/dto.go index 26898cd2..f1bd0eae 100644 --- a/internal/features/auth/dto/dto.go +++ b/internal/features/auth/dto/dto.go @@ -5,1015 +5,11 @@ // Package dto is the data transfer object package for the auth module. package dto -import ( - "net/http" - - "github.com/origadmin/runtime/errors" // Changed from httperr - "google.golang.org/protobuf/types/known/timestamppb" - - typespb "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/schema/types" - "origadmin/application/admin/internal/data/entity/ent/user" -) - -const ( - UserStatusActive = types.Active - UserStatusFrozen = types.Frozen -) - -const ( - ResourceStatusEnabled = types.Enabled - ResourceStatusDisabled = types.Disabled -) - -type ( - // User 用户类型 - // @Convert( - // target = "UserPB", - // direction = "both", - // ignoreFields = ["password", "salt"] - // ) - User = ent.User - // UserPB - // @Convert( - // target="User", - // direction="both" - // ) - UserPB = typespb.User -) - -var ( - // ErrUserNotFound is user not found. - ErrUserNotFound = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") - ErrInvalidCaptchaID = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") - ErrInvalidPassword = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") - ErrInvalidUsername = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") - ErrCaptchaIDNotFound = errors.New("http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") -) - -// ConvertUser2PB user.table.comment -func ConvertUser2PB(goModel *User) (pbModel *UserPB) { - pbModel = &UserPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.CreateAuthor = int64(goModel.CreateAuthor) - pbModel.UpdateAuthor = int64(goModel.UpdateAuthor) - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Uuid = goModel.UUID - pbModel.AllowedIp = goModel.AllowedIP - pbModel.Username = goModel.Username - pbModel.Nickname = goModel.Nickname - pbModel.Avatar = goModel.Avatar - pbModel.Name = goModel.Name - pbModel.Gender = ConvertGender2PB(goModel.Gender) - //pbModel.Password = goModel.EncryptedPassword - //pbModel.Salt = goModel.Salt - pbModel.Phone = goModel.Phone - pbModel.Email = goModel.Email - pbModel.Remark = goModel.Remark - pbModel.Token = goModel.Token - pbModel.Status = int32(goModel.Status) - pbModel.LastLoginIp = goModel.LastLoginIP - pbModel.LastLoginTime = timestamppb.New(goModel.LastLoginTime) - pbModel.SanctionDate = timestamppb.New(goModel.SanctionDate) - pbModel.ManagerId = int64(goModel.ManagerID) - pbModel.Manager = goModel.Manager - //pbModel.Roles = ConvertRoles(goModel.Edges.Roles) - for _, role := range goModel.Edges.Roles { - pbModel.RoleIds = append(pbModel.RoleIds, role.ID) - } - pbModel.Roles = ConvertRoles2PB(goModel.Edges.Roles) - return pbModel -} - -func ConvertGender2PB(gender user.Gender) string { - return gender.String() -} - -// ConvertUserPB2Object user.table.comment -func ConvertUserPB2Object(pbModel *UserPB) (goModel *User) { - goModel = &User{} - if pbModel == nil { - return goModel - } - - goModel.ID = int64(pbModel.Id) - goModel.CreateAuthor = int64(pbModel.CreateAuthor) - goModel.UpdateAuthor = int64(pbModel.UpdateAuthor) - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.UUID = pbModel.Uuid - goModel.AllowedIP = pbModel.AllowedIp - goModel.Username = pbModel.Username - goModel.Nickname = pbModel.Nickname - goModel.Avatar = pbModel.Avatar - goModel.Name = pbModel.Name - goModel.Gender = user.Gender(pbModel.Gender) - //goModel.Password = pbModel.Password - //goModel.Salt = pbModel.Salt - goModel.Phone = pbModel.Phone - goModel.Email = pbModel.Email - goModel.Remark = pbModel.Remark - goModel.Token = pbModel.Token - goModel.Status = int8(pbModel.Status) - goModel.LastLoginIP = pbModel.LastLoginIp - goModel.LastLoginTime = pbModel.LastLoginTime.AsTime() - goModel.SanctionDate = pbModel.SanctionDate.AsTime() - goModel.ManagerID = pbModel.ManagerId - goModel.Manager = pbModel.Manager - return goModel -} - -type ( - Resource = ent.Resource - ResourcePB = typespb.Resource -) - -func ConvertResource2PB(goModel *Resource) (pbModel *ResourcePB) { - pbModel = &ResourcePB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = goModel.ID - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Name = goModel.Name - pbModel.Keyword = goModel.Keyword - pbModel.I18NKey = goModel.I18nKey - pbModel.Type = goModel.Type - pbModel.Status = int32(goModel.Status) - pbModel.Path = goModel.Path - pbModel.Operation = goModel.Operation - pbModel.Method = goModel.Method - pbModel.Component = goModel.Component - pbModel.Icon = goModel.Icon - pbModel.Sequence = int32(goModel.Sequence) - pbModel.Visible = goModel.Visible - pbModel.TreePath = goModel.TreePath - pbModel.Properties = goModel.Properties - pbModel.Description = goModel.Description - pbModel.ParentId = int64(goModel.ParentID) - return pbModel -} - -func ConvertResourcePB2Object(pbModel *ResourcePB) (goModel *Resource) { - goModel = &Resource{} - if pbModel == nil { - return goModel - } - - goModel.ID = pbModel.Id - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Name = pbModel.Name - goModel.Keyword = pbModel.Keyword - goModel.I18nKey = pbModel.I18NKey - goModel.Type = pbModel.Type - goModel.Status = int8(pbModel.Status) - goModel.Path = pbModel.Path - goModel.Operation = pbModel.Operation - goModel.Method = pbModel.Method - goModel.Component = pbModel.Component - goModel.Icon = pbModel.Icon - goModel.Sequence = int(pbModel.Sequence) - goModel.Visible = pbModel.Visible - goModel.TreePath = pbModel.TreePath - goModel.Properties = pbModel.Properties - goModel.Description = pbModel.Description - goModel.ParentID = pbModel.ParentId - return goModel -} - -type ( - Role = ent.Role - RolePB = typespb.Role -) - -// ConvertRole2PB role.table.comment -func ConvertRole2PB(goModel *Role) (pbModel *RolePB) { - pbModel = &RolePB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = goModel.ID - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Keyword = goModel.Keyword - pbModel.Name = goModel.Name - pbModel.Description = goModel.Description - pbModel.Type = int32(goModel.Type) - pbModel.Sequence = int32(goModel.Sequence) - pbModel.Status = int32(goModel.Status) - for _, permission := range goModel.Edges.Permissions { - pbModel.PermissionIds = append(pbModel.PermissionIds, int64(permission.ID)) - } - pbModel.Permissions = ConvertPermissions2PB(goModel.Edges.Permissions) - //pbModel.IsSystem = goModel.IsSystem - return pbModel -} - -// ConvertRolePB2Object role.table.comment -func ConvertRolePB2Object(pbModel *RolePB) (goModel *Role) { - goModel = &Role{} - if pbModel == nil { - return goModel - } - - goModel.ID = pbModel.Id - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Keyword = pbModel.Keyword - goModel.Name = pbModel.Name - goModel.Description = pbModel.Description - goModel.Type = int8(pbModel.Type) - goModel.Sequence = int(pbModel.Sequence) - goModel.Status = int8(pbModel.Status) - - //goModel.IsSystem = pbModel.IsSystem - return goModel -} - -type ( - Department = ent.Department - DepartmentPB = typespb.Department -) - -// ConvertDepartment2PB department.table.comment -func ConvertDepartment2PB(goModel *Department) (pbModel *DepartmentPB) { - pbModel = &DepartmentPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = goModel.ID - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Keyword = goModel.Keyword - pbModel.Name = goModel.Name - pbModel.Description = goModel.Description - pbModel.Sequence = int32(goModel.Sequence) - pbModel.Status = int32(goModel.Status) - pbModel.Level = int32(goModel.Level) - pbModel.ParentId = goModel.ParentID - return pbModel -} - -// ConvertDepartmentPB2Object department.table.comment -func ConvertDepartmentPB2Object(pbModel *DepartmentPB) (goModel *Department) { - goModel = &Department{} - if pbModel == nil { - return goModel - } - - goModel.ID = pbModel.Id - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Keyword = pbModel.Keyword - goModel.Name = pbModel.Name - goModel.TreePath = pbModel.TreePath - goModel.Description = pbModel.Description - goModel.Sequence = int(pbModel.Sequence) - goModel.Status = int8(pbModel.Status) - goModel.Level = int(pbModel.Level) - goModel.ParentID = pbModel.ParentId - return goModel -} - -type ( - Departments = []*ent.Department - DepartmentsPB = []*typespb.Department -) - -// ConvertDepartments2PB Children holds the value of the children edge. -func ConvertDepartments2PB(gosModel Departments) (pbsModel DepartmentsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertDepartment2PB(model)) - } - return pbsModel -} - -// ConvertDepartmentsPB2Object Children holds the value of the children edge. -func ConvertDepartmentsPB2Object(pbsModel DepartmentsPB) (gosModel Departments) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertDepartmentPB2Object(model)) - } - return gosModel -} - -type ( - UserDepartments = []*ent.UserDepartment - UserDepartmentsPB = []*typespb.UserDepartment -) - -// ConvertUserDepartments2PB UserDepartments holds the value of the user_departments edge. -func ConvertUserDepartments2PB(gosModel UserDepartments) (pbsModel UserDepartmentsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertUserDepartment2PB(model)) - } - return pbsModel -} - -// ConvertUserDepartmentsPB2Object UserDepartments holds the value of the user_departments edge. -func ConvertUserDepartmentsPB2Object(pbsModel UserDepartmentsPB) (gosModel UserDepartments) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertUserDepartmentPB2Object(model)) - } - return gosModel -} - -type ( - DepartmentEdges = ent.DepartmentEdges - DepartmentEdgesPB = typespb.DepartmentEdges -) - -// ConvertDepartmentEdges2PB DepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertDepartmentEdges2PB(goModel *DepartmentEdges) (pbModel *DepartmentEdgesPB) { - pbModel = &DepartmentEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Users = ConvertUsers2PB(goModel.Users) - pbModel.Positions = ConvertPositions2PB(goModel.Positions) - pbModel.Children = ConvertDepartments2PB(goModel.Children) - pbModel.Parent = ConvertDepartment2PB(goModel.Parent) - pbModel.UserDepartments = ConvertUserDepartments2PB(goModel.UserDepartments) - return pbModel -} - -// ConvertDepartmentEdgesPB2Object DepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertDepartmentEdgesPB2Object(pbModel *DepartmentEdgesPB) (goModel *DepartmentEdges) { - goModel = &DepartmentEdges{} - if pbModel == nil { - return goModel - } - - goModel.Users = ConvertUsersPB2Object(pbModel.Users) - goModel.Positions = ConvertPositionsPB2Object(pbModel.Positions) - goModel.Children = ConvertDepartmentsPB2Object(pbModel.Children) - goModel.Parent = ConvertDepartmentPB2Object(pbModel.Parent) - goModel.UserDepartments = ConvertUserDepartmentsPB2Object(pbModel.UserDepartments) - return goModel -} - -type ( - UserDepartment = ent.UserDepartment - UserDepartmentPB = typespb.UserDepartment -) - -// ConvertUserDepartment2PB user_department.table.comment -func ConvertUserDepartment2PB(goModel *UserDepartment) (pbModel *UserDepartmentPB) { - pbModel = &UserDepartmentPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.UserId = int64(goModel.UserID) - pbModel.DepartmentId = int64(goModel.DepartmentID) - return pbModel -} - -// ConvertUserDepartmentPB2Object user_department.table.comment -func ConvertUserDepartmentPB2Object(pbModel *UserDepartmentPB) (goModel *UserDepartment) { - goModel = &UserDepartment{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.UserID = int64(pbModel.UserId) - goModel.DepartmentID = int64(pbModel.DepartmentId) - return goModel -} - -type ( - UserDepartmentEdges = ent.UserDepartmentEdges - UserDepartmentEdgesPB = typespb.UserDepartmentEdges -) - -// ConvertUserDepartmentEdges2PB UserDepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertUserDepartmentEdges2PB(goModel *UserDepartmentEdges) (pbModel *UserDepartmentEdgesPB) { - pbModel = &UserDepartmentEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.User = ConvertUser2PB(goModel.User) - pbModel.Department = ConvertDepartment2PB(goModel.Department) - return pbModel -} - -// ConvertUserDepartmentEdgesPB2Object UserDepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertUserDepartmentEdgesPB2Object(pbModel *UserDepartmentEdgesPB) (goModel *UserDepartmentEdges) { - goModel = &UserDepartmentEdges{} - if pbModel == nil { - return goModel - } - - goModel.User = ConvertUserPB2Object(pbModel.User) - goModel.Department = ConvertDepartmentPB2Object(pbModel.Department) - return goModel -} - -type ( - Position = ent.Position - PositionPB = typespb.Position -) - -// ConvertPosition2PB position.table.comment -func ConvertPosition2PB(goModel *Position) (pbModel *PositionPB) { - pbModel = &PositionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Name = goModel.Name - pbModel.Description = goModel.Description - pbModel.DepartmentId = int64(goModel.DepartmentID) - return pbModel -} - -// ConvertPositionPB2Object position.table.comment -func ConvertPositionPB2Object(pbModel *PositionPB) (goModel *Position) { - goModel = &Position{} - if pbModel == nil { - return goModel - } - - goModel.ID = int64(pbModel.Id) - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Name = pbModel.Name - goModel.Description = pbModel.Description - goModel.DepartmentID = int64(pbModel.DepartmentId) - return goModel -} - -type ( - Users = []*ent.User - UsersPB = []*typespb.User -) - -// ConvertUsers2PB Users holds the value of the users edge. -func ConvertUsers2PB(gosModel Users) (pbsModel UsersPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertUser2PB(model)) - } - return pbsModel -} - -// ConvertUsersPB2Object Users holds the value of the users edge. -func ConvertUsersPB2Object(pbsModel UsersPB) (gosModel Users) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertUserPB2Object(model)) - } - return gosModel -} - -type ( - Permissions = []*ent.Permission - PermissionsPB = []*typespb.Permission -) - -// ConvertPermissions2PB Permissions holds the value of the permissions edge. -func ConvertPermissions2PB(gosModel Permissions) (pbsModel PermissionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPermission2PB(model)) - } - return pbsModel -} - -// ConvertPermissionsPB2Object Permissions holds the value of the permissions edge. -func ConvertPermissionsPB2Object(pbsModel PermissionsPB) (gosModel Permissions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPermissionPB2Object(model)) - } - return gosModel -} - -type ( - UserPositions = []*ent.UserPosition - UserPositionsPB = []*typespb.UserPosition -) - -// ConvertUserPositions2PB UserPositions holds the value of the user_positions edge. -func ConvertUserPositions2PB(gosModel UserPositions) (pbsModel UserPositionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertUserPosition2PB(model)) - } - return pbsModel -} - -// ConvertUserPositionsPB2Object UserPositions holds the value of the user_positions edge. -func ConvertUserPositionsPB2Object(pbsModel UserPositionsPB) (gosModel UserPositions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertUserPositionPB2Object(model)) - } - return gosModel -} - -type ( - PositionEdges = ent.PositionEdges - PositionEdgesPB = typespb.PositionEdges -) - -// ConvertPositionEdges2PB PositionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionEdges2PB(goModel *PositionEdges) (pbModel *PositionEdgesPB) { - pbModel = &PositionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Department = ConvertDepartment2PB(goModel.Department) - pbModel.Users = ConvertUsers2PB(goModel.Users) - pbModel.Permissions = ConvertPermissions2PB(goModel.Permissions) - pbModel.UserPositions = ConvertUserPositions2PB(goModel.UserPositions) - pbModel.PositionPermissions = ConvertPositionPermissions2PB(goModel.PositionPermissions) - return pbModel -} - -// ConvertPositionEdgesPB2Object PositionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionEdgesPB2Object(pbModel *PositionEdgesPB) (goModel *PositionEdges) { - goModel = &PositionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Department = ConvertDepartmentPB2Object(pbModel.Department) - goModel.Users = ConvertUsersPB2Object(pbModel.Users) - goModel.Permissions = ConvertPermissionsPB2Object(pbModel.Permissions) - goModel.UserPositions = ConvertUserPositionsPB2Object(pbModel.UserPositions) - goModel.PositionPermissions = ConvertPositionPermissionsPB2Object(pbModel.PositionPermissions) - return goModel -} - -// ConvertDataRules2PB permission.field.data_rules -func ConvertDataRules2PB(gosModel map[string]string) map[string]string { - return gosModel -} - -// ConvertDataRulesPB2Object permission.field.data_rules -func ConvertDataRulesPB2Object(pbsModel map[string]string) map[string]string { - return pbsModel -} - -type ( - Permission = ent.Permission - PermissionPB = typespb.Permission -) - -// ConvertPermission2PB permission.table.comment -func ConvertPermission2PB(goModel *Permission) (pbModel *PermissionPB) { - pbModel = &PermissionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Name = goModel.Name - pbModel.Keyword = goModel.Keyword - pbModel.Description = goModel.Description - pbModel.DataScope = goModel.DataScope - pbModel.DataRules = ConvertDataRules2PB(goModel.DataRules) - for _, resource := range goModel.Edges.Resources { - pbModel.ResourceIds = append(pbModel.ResourceIds, resource.ID) - } - pbModel.Resources = ConvertResources2PB(goModel.Edges.Resources) - return pbModel -} - -// ConvertPermissionPB2Object permission.table.comment -func ConvertPermissionPB2Object(pbModel *PermissionPB) (goModel *Permission) { - goModel = &Permission{} - if pbModel == nil { - return goModel - } - - goModel.ID = int64(pbModel.Id) - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Name = pbModel.Name - goModel.Keyword = pbModel.Keyword - goModel.Description = pbModel.Description - goModel.DataScope = pbModel.DataScope - goModel.DataRules = ConvertDataRulesPB2Object(pbModel.DataRules) - return goModel -} - -type ( - Roles = []*ent.Role - RolesPB = []*typespb.Role -) - -// ConvertRoles2PB Roles holds the value of the roles edge. -func ConvertRoles2PB(gosModel Roles) (pbsModel RolesPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertRole2PB(model)) - } - return pbsModel -} - -// ConvertRolesPB2Object Roles holds the value of the roles edge. -func ConvertRolesPB2Object(pbsModel RolesPB) (gosModel Roles) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertRolePB2Object(model)) - } - return gosModel -} - -type ( - Resources = []*ent.Resource - ResourcesPB = []*typespb.Resource -) - -// ConvertResources2PB Resources holds the value of the resources edge. -func ConvertResources2PB(gosModel Resources) (pbsModel ResourcesPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertResource2PB(model)) - } - return pbsModel -} - -// ConvertResourcesPB2Object Resources holds the value of the resources edge. -func ConvertResourcesPB2Object(pbsModel ResourcesPB) (gosModel Resources) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertResourcePB2Object(model)) - } - return gosModel -} - -type ( - Positions = []*ent.Position - PositionsPB = []*typespb.Position -) - -// ConvertPositions2PB Positions holds the value of the positions edge. -func ConvertPositions2PB(gosModel Positions) (pbsModel PositionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPosition2PB(model)) - } - return pbsModel -} - -// ConvertPositionsPB2Object Positions holds the value of the positions edge. -func ConvertPositionsPB2Object(pbsModel PositionsPB) (gosModel Positions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPositionPB2Object(model)) - } - return gosModel -} - -type ( - RolePermissions = []*ent.RolePermission - RolePermissionsPB = []*typespb.RolePermission -) - -// ConvertRolePermissions2PB RolePermissions holds the value of the role_permissions edge. -func ConvertRolePermissions2PB(gosModel RolePermissions) (pbsModel RolePermissionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertRolePermission2PB(model)) - } - return pbsModel -} - -// ConvertRolePermissionsPB2Object RolePermissions holds the value of the role_permissions edge. -func ConvertRolePermissionsPB2Object(pbsModel RolePermissionsPB) (gosModel RolePermissions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertRolePermissionPB2Object(model)) - } - return gosModel -} - -type ( - PermissionResources = []*ent.PermissionResource - PermissionResourcesPB = []*typespb.PermissionResource -) - -// ConvertPermissionResources2PB PermissionResources holds the value of the permission_resources edge. -func ConvertPermissionResources2PB(gosModel PermissionResources) (pbsModel PermissionResourcesPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPermissionResource2PB(model)) - } - return pbsModel -} - -// ConvertPermissionResourcesPB2Object PermissionResources holds the value of the permission_resources edge. -func ConvertPermissionResourcesPB2Object(pbsModel PermissionResourcesPB) (gosModel PermissionResources) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPermissionResourcePB2Object(model)) - } - return gosModel -} - -type ( - PositionPermissions = []*ent.PositionPermission - PositionPermissionsPB = []*typespb.PositionPermission -) - -// ConvertPositionPermissions2PB PositionPermissions holds the value of the position_permissions edge. -func ConvertPositionPermissions2PB(gosModel PositionPermissions) (pbsModel PositionPermissionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPositionPermission2PB(model)) - } - return pbsModel -} - -// ConvertPositionPermissionsPB2Object PositionPermissions holds the value of the position_permissions edge. -func ConvertPositionPermissionsPB2Object(pbsModel PositionPermissionsPB) (gosModel PositionPermissions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPositionPermissionPB2Object(model)) - } - return gosModel -} - -type ( - PermissionEdges = ent.PermissionEdges - PermissionEdgesPB = typespb.PermissionEdges -) - -// ConvertPermissionEdges2PB PermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionEdges2PB(goModel *PermissionEdges) (pbModel *PermissionEdgesPB) { - pbModel = &PermissionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Roles = ConvertRoles2PB(goModel.Roles) - pbModel.Resources = ConvertResources2PB(goModel.Resources) - pbModel.Positions = ConvertPositions2PB(goModel.Positions) - pbModel.RolePermissions = ConvertRolePermissions2PB(goModel.RolePermissions) - pbModel.PermissionResources = ConvertPermissionResources2PB(goModel.PermissionResources) - pbModel.PositionPermissions = ConvertPositionPermissions2PB(goModel.PositionPermissions) - return pbModel -} - -// ConvertPermissionEdgesPB2Object PermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionEdgesPB2Object(pbModel *PermissionEdgesPB) (goModel *PermissionEdges) { - goModel = &PermissionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Roles = ConvertRolesPB2Object(pbModel.Roles) - goModel.Resources = ConvertResourcesPB2Object(pbModel.Resources) - goModel.Positions = ConvertPositionsPB2Object(pbModel.Positions) - goModel.RolePermissions = ConvertRolePermissionsPB2Object(pbModel.RolePermissions) - goModel.PermissionResources = ConvertPermissionResourcesPB2Object(pbModel.PermissionResources) - goModel.PositionPermissions = ConvertPositionPermissionsPB2Object(pbModel.PositionPermissions) - return goModel -} - -type ( - UserPosition = ent.UserPosition - UserPositionPB = typespb.UserPosition -) - -// ConvertUserPosition2PB user_position.table.comment -func ConvertUserPosition2PB(goModel *UserPosition) (pbModel *UserPositionPB) { - pbModel = &UserPositionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.UserId = int64(goModel.UserID) - pbModel.PositionId = int64(goModel.PositionID) - return pbModel -} - -// ConvertUserPositionPB2Object user_position.table.comment -func ConvertUserPositionPB2Object(pbModel *UserPositionPB) (goModel *UserPosition) { - goModel = &UserPosition{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.UserID = int64(pbModel.UserId) - goModel.PositionID = int64(pbModel.PositionId) - return goModel -} - -type ( - UserPositionEdges = ent.UserPositionEdges - UserPositionEdgesPB = typespb.UserPositionEdges -) - -// ConvertUserPositionEdges2PB UserPositionEdges holds the relations/edges for other nodes in the graph. -func ConvertUserPositionEdges2PB(goModel *UserPositionEdges) (pbModel *UserPositionEdgesPB) { - pbModel = &UserPositionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.User = ConvertUser2PB(goModel.User) - pbModel.Position = ConvertPosition2PB(goModel.Position) - return pbModel -} - -// ConvertUserPositionEdgesPB2Object UserPositionEdges holds the relations/edges for other nodes in the graph. -func ConvertUserPositionEdgesPB2Object(pbModel *UserPositionEdgesPB) (goModel *UserPositionEdges) { - goModel = &UserPositionEdges{} - if pbModel == nil { - return goModel - } - - goModel.User = ConvertUserPB2Object(pbModel.User) - goModel.Position = ConvertPositionPB2Object(pbModel.Position) - return goModel -} - -type ( - PositionPermission = ent.PositionPermission - PositionPermissionPB = typespb.PositionPermission -) - -// ConvertPositionPermission2PB position_permission.table.comment -func ConvertPositionPermission2PB(goModel *PositionPermission) (pbModel *PositionPermissionPB) { - pbModel = &PositionPermissionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.PositionId = int64(goModel.PositionID) - pbModel.PermissionId = int64(goModel.PermissionID) - return pbModel -} - -// ConvertPositionPermissionPB2Object position_permission.table.comment -func ConvertPositionPermissionPB2Object(pbModel *PositionPermissionPB) (goModel *PositionPermission) { - goModel = &PositionPermission{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.PositionID = int64(pbModel.PositionId) - goModel.PermissionID = int64(pbModel.PermissionId) - return goModel -} - -type ( - PositionPermissionEdges = ent.PositionPermissionEdges - PositionPermissionEdgesPB = typespb.PositionPermissionEdges -) - -// ConvertPositionPermissionEdges2PB PositionPermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionPermissionEdges2PB(goModel *PositionPermissionEdges) (pbModel *PositionPermissionEdgesPB) { - pbModel = &PositionPermissionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Position = ConvertPosition2PB(goModel.Position) - pbModel.Permission = ConvertPermission2PB(goModel.Permission) - return pbModel -} - -// ConvertPositionPermissionEdgesPB2Object PositionPermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionPermissionEdgesPB2Object(pbModel *PositionPermissionEdgesPB) (goModel *PositionPermissionEdges) { - goModel = &PositionPermissionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Position = ConvertPositionPB2Object(pbModel.Position) - goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) - return goModel -} - -type ( - RolePermission = ent.RolePermission - RolePermissionPB = typespb.RolePermission -) - -// ConvertRolePermission2PB role_permission.table.comment -func ConvertRolePermission2PB(goModel *RolePermission) (pbModel *RolePermissionPB) { - pbModel = &RolePermissionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.RoleId = int64(goModel.RoleID) - pbModel.PermissionId = int64(goModel.PermissionID) - return pbModel -} - -// ConvertRolePermissionPB2Object role_permission.table.comment -func ConvertRolePermissionPB2Object(pbModel *RolePermissionPB) (goModel *RolePermission) { - goModel = &RolePermission{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.RoleID = int64(pbModel.RoleId) - goModel.PermissionID = int64(pbModel.PermissionId) - return goModel -} - -type ( - RolePermissionEdges = ent.RolePermissionEdges - RolePermissionEdgesPB = typespb.RolePermissionEdges -) - -// ConvertRolePermissionEdges2PB RolePermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertRolePermissionEdges2PB(goModel *RolePermissionEdges) (pbModel *RolePermissionEdgesPB) { - pbModel = &RolePermissionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Role = ConvertRole2PB(goModel.Role) - pbModel.Permission = ConvertPermission2PB(goModel.Permission) - return pbModel -} - -// ConvertRolePermissionEdgesPB2Object RolePermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertRolePermissionEdgesPB2Object(pbModel *RolePermissionEdgesPB) (goModel *RolePermissionEdges) { - goModel = &RolePermissionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Role = ConvertRolePB2Object(pbModel.Role) - goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) - return goModel -} - -type ( - PermissionResource = ent.PermissionResource - PermissionResourcePB = typespb.PermissionResource -) - -// ConvertPermissionResource2PB permission_resource.table.comment -func ConvertPermissionResource2PB(goModel *PermissionResource) (pbModel *PermissionResourcePB) { - pbModel = &PermissionResourcePB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.PermissionId = int64(goModel.PermissionID) - pbModel.ResourceId = int64(goModel.ResourceID) - //pbModel.Actions = goModel.Actions - return pbModel -} - -// ConvertPermissionResourcePB2Object permission_resource.table.comment -func ConvertPermissionResourcePB2Object(pbModel *PermissionResourcePB) (goModel *PermissionResource) { - goModel = &PermissionResource{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.PermissionID = int64(pbModel.PermissionId) - goModel.ResourceID = int64(pbModel.ResourceId) - //goModel.Actions = pbModel.Actions - return goModel -} - -type ( - PermissionResourceEdges = ent.PermissionResourceEdges - PermissionResourceEdgesPB = typespb.PermissionResourceEdges -) - -// ConvertPermissionResourceEdges2PB PermissionResourceEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionResourceEdges2PB(goModel *PermissionResourceEdges) (pbModel *PermissionResourceEdgesPB) { - pbModel = &PermissionResourceEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Permission = ConvertPermission2PB(goModel.Permission) - pbModel.Resource = ConvertResource2PB(goModel.Resource) - return pbModel -} - -// ConvertPermissionResourceEdgesPB2Object PermissionResourceEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionResourceEdgesPB2Object(pbModel *PermissionResourceEdgesPB) (goModel *PermissionResourceEdges) { - goModel = &PermissionResourceEdges{} - if pbModel == nil { - return goModel - } - - goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) - goModel.Resource = ConvertResourcePB2Object(pbModel.Resource) - return goModel -} +//go:generate abgen -debug . + +//go:abgen:package:path=origadmin/application/admin/internal/data/entity/ent,alias=ent +//go:abgen:package:path=origadmin/application/admin/api/v1/services/types,alias=types +//go:abgen:pair:packages="ent,types" +//go:abgen:convert:direction="both" +//go:abgen:convert:source:suffix="" +//go:abgen:convert:target:suffix="PB" diff --git a/internal/features/auth/dto/login.go b/internal/features/auth/dto/login.go deleted file mode 100644 index 8c667c22..00000000 --- a/internal/features/auth/dto/login.go +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the auth module. -package dto - -import ( - "context" - - "github.com/google/uuid" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/rand" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/helpers/id" -) - -type ( - CaptchaIDRequest = pb.CaptchaIdRequest - CaptchaIDResponse = pb.CaptchaIdResponse - CaptchaImageRequest = pb.CaptchaImageRequest - CaptchaImageResponse = pb.CaptchaImageResponse - CaptchaAudioRequest = pb.CaptchaAudioRequest - CaptchaAudioResponse = pb.CaptchaAudioResponse - CaptchaRequest = pb.CaptchaRequest - CaptchaResponse = pb.CaptchaResponse - CaptchaData = pb.CaptchaData - LoginRequest = pb.LoginRequest - LoginResponse = pb.LoginResponse - LogoutRequest = pb.LogoutRequest - LogoutResponse = pb.LogoutResponse - TokenRefreshRequest = pb.TokenRefreshRequest - TokenRefreshResponse = pb.TokenRefreshResponse - RegisterRequest = pb.RegisterRequest - RegisterResponse = pb.RegisterResponse - CurrentUserRequest = pb.CurrentUserRequest - CurrentUserResponse = pb.CurrentUserResponse -) - -type LoginRepo interface { - CaptchaID(ctx context.Context, in *CaptchaIDRequest) (*CaptchaIDResponse, error) - CaptchaImage(ctx context.Context, id string, reload bool) (*CaptchaImageResponse, error) - CaptchaAudio(ctx context.Context, id string, reload bool) (*CaptchaAudioResponse, error) - Captcha(ctx context.Context, in *CaptchaRequest) (*CaptchaResponse, error) - CurrentUser(ctx context.Context, in *CurrentUserRequest) (*CurrentUserResponse, error) - Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) - Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) - Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) - TokenRefresh(ctx context.Context, in *TokenRefreshRequest) (*TokenRefreshResponse, error) -} - -type UserMutationOption struct { - RandomPasswd bool - NoPasswd bool - Fields []string -} - -type UserQueryOption struct { - IncludeRoles bool - IsSystem bool - NoPasswd bool - RandomPasswd bool - Status int8 `form:"status" json:"status,omitempty"` - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string -} - -// MakeCreateUser functions are used to create new users -func MakeCreateUser(user *UserPB, username, password string, option UserMutationOption) (*UserPB, string, error) { - log.Debugf("Creating user with options: %+v", option) - if !option.NoPasswd { - log.Debugf("NoPasswd is false, checking for RandomPasswd") - if option.RandomPasswd && (user.Email != "" || user.Phone != "") { - log.Debugf("RandomPasswd is true and user has email or phone, generating random password") - password = rand.GenerateRandom(8) - log.Debugf("Generated random password: %s", password) - } else { - log.Debugf("RandomPasswd is false or user has no email or phone") - } - } else { - log.Debugf("NoPasswd is true, setting password to empty string") - password = "" - } - var err error - if password != "" { - log.Debugf("Password is not empty, generating salt") - //user.Salt = rand.GenerateSalt() - //log.Debugf("Generated salt: %s", user.Salt) - user.Password, err = hash.Generate(password) - if err != nil { - log.Errorf("Error generating password hash: %v", err) - return nil, "", err - } - log.Debugf("Generated password hash: %s", user.Password) - } - registerID := id.Gen() - user.Id = registerID - user.Uuid = uuid.Must(uuid.NewRandom()).String() - user.Username = username - user.Name = "user_" + random.RandString(8) - user.Status = 1 - return user, password, nil -} - -var random = rand.NewRand(rand.KindDigit | rand.KindLowerCase | rand.KindUpperCase) diff --git a/internal/features/auth/dto/me.go b/internal/features/auth/dto/me.go new file mode 100644 index 00000000..74e03547 --- /dev/null +++ b/internal/features/auth/dto/me.go @@ -0,0 +1,11 @@ +package dto + +import ( + "context" + "origadmin/application/admin/api/v1/services/types" +) + +// MeRepo defines the data access methods for user profile. +type MeRepo interface { + GetProfile(ctx context.Context, userID int64) (*types.User, error) +} diff --git a/internal/features/auth/dto/personal.go b/internal/features/auth/dto/personal.go deleted file mode 100644 index c2ea4660..00000000 --- a/internal/features/auth/dto/personal.go +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the auth module. -package dto - -import ( - "context" - - pb "origadmin/application/admin/api/v1/services/auth" -) - -type PersonalRepo interface { - GetPersonalProfile(ctx context.Context, in *pb.GetPersonalProfileRequest) (*pb.GetPersonalProfileResponse, error) - ListPersonalRoles(ctx context.Context, in *pb.ListPersonalRolesRequest) (*pb.ListPersonalRolesResponse, error) - UpdatePersonalPassword(ctx context.Context, in *pb.UpdatePersonalPasswordRequest) (*pb.UpdatePersonalPasswordResponse, error) - UpdatePersonalProfile(ctx context.Context, in *pb.UpdatePersonalProfileRequest) (*pb.UpdatePersonalProfileResponse, error) - ListPersonalResources(ctx context.Context, in *pb.ListPersonalResourcesRequest) (*pb.ListPersonalResourcesResponse, error) -} diff --git a/internal/features/auth/server/gins.go b/internal/features/auth/server/gins.go deleted file mode 100644 index 26373997..00000000 --- a/internal/features/auth/server/gins.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "net/url" - - "github.com/origadmin/contrib/transport/gins" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/service" - "github.com/origadmin/toolkits/env" - "github.com/origadmin/toolkits/net" - - "origadmin/application/admin/internal/configs" -) - -// NewGINSServer new a gin server. -func NewGINSServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.ServerOption) *gins.Server { - ms := middleware.NewServer(bootstrap.GetMiddleware()) - //option := settings.ApplyOrZero(ss...) - var opts = []gins.ServerOption{ - gins.Middleware(ms...), - } - //serviceConfig := bootstrap.GetService() - //cfg := serviceConfig.GetGins() - //if cfg == nil { - // return nil - //} - // - //if cfg.Network != "" { - // opts = append(opts, gins.Network(cfg.Network)) - //} - //if cfg.Addr != "" { - // opts = append(opts, gins.Address(cfg.Addr)) - //} - //if cfg.Timeout != nil { - // opts = append(opts, gins.Timeout(cfg.Timeout.AsDuration())) - //} - - //middlewares, err := bootstrap.LoadMiddlewares(bootstrap.GetServiceName(), bootstrap, l) - //if err == nil && len(middlewares) > 0 { - // opts = append(opts, http.Middleware(middlewares...)) - //} - - if l != nil { - opts = append(opts, gins.WithLogger(log.With(l, "module", "gins"))) - } - log.Infof("GetHostName: %s", env.Var(runtime.DefaultEnvPrefix, "host")) - hostVar := env.Var(runtime.DefaultEnvPrefix, "host") - hostIP := env.GetEnv(env.Var(runtime.DefaultEnvPrefix, "host_ip")) - if hostIP == "" { - log.Debugf("HostIP is empty, replacing with HostAddr: %s", hostVar) - hostIP = net.HostAddr(net.WithEnvVar(hostVar)) - log.Debugf("HostIP after replacement: %s", hostIP) - } - - var endpoint string - log.Debugf("GINS.Endpoint: %v", endpoint) - ep, _ := url.Parse(endpoint) - opts = append(opts, gins.Endpoint(ep)) - srv := gins.NewServer(opts...) - return srv -} diff --git a/internal/features/auth/server/grpc.go b/internal/features/auth/server/grpc.go deleted file mode 100644 index 43cb5ac0..00000000 --- a/internal/features/auth/server/grpc.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/service" - - "origadmin/application/admin/internal/configs" -) - -// NewGRPCServer new a gRPC server. -func NewGRPCServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.GRPCServer { - services := bootstrap.GetServer().GetServices() - for _, serviceConfig := range services { - if serviceConfig.GetType() == "grpc" { - grpcServer, err := r.Builder().NewGRPCServer(serviceConfig) - if err != nil { - return nil - } - return grpcServer - } - } - return nil -} diff --git a/internal/features/auth/server/http.go b/internal/features/auth/server/http.go deleted file mode 100644 index f1be2682..00000000 --- a/internal/features/auth/server/http.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/service" - - "origadmin/application/admin/internal/configs" -) - -// NewHTTPServer new an HTTP server. -func NewHTTPServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.HTTPServer { - services := bootstrap.GetServer().GetServices() - for _, serviceConfig := range services { - if serviceConfig.GetType() == "http" { - httpServer, err := r.Builder().NewHTTPServer(serviceConfig) - if err != nil { - return nil - } - return httpServer - } - } - return nil -} diff --git a/internal/features/auth/server/server.go b/internal/features/auth/server/server.go index f755e544..8b15c830 100644 --- a/internal/features/auth/server/server.go +++ b/internal/features/auth/server/server.go @@ -1,153 +1,117 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - package server import ( - "github.com/go-kratos/kratos/v2/metadata" + "errors" + stdhttp "net/http" + "github.com/go-kratos/kratos/v2/transport" + "github.com/go-kratos/kratos/v2/transport/grpc" + "github.com/go-kratos/kratos/v2/transport/http" "github.com/google/wire" - "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/service" - servicegrpc "github.com/origadmin/runtime/service/grpc" - servicehttp "github.com/origadmin/runtime/service/http" - "github.com/origadmin/toolkits/errors" - "origadmin/application/admin/internal/configs" - authservice "origadmin/application/admin/internal/features/auth/service" // Corrected import path -) + "github.com/origadmin/runtime/log" + authv1 "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/features/auth/service" -const ( - // ServiceName is service name. - ServiceName = "auth" + grpcv1 "github.com/origadmin/runtime/api/gen/go/config/transport/grpc/v1" + httpv1 "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1" + transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" ) -var ( - // ProviderSet is server providers. - ProviderSet = wire.NewSet( - NewAuthClient, - NewAuthServer, - ) -) +// ProviderSet is server providers. +var ProviderSet = wire.NewSet(NewServers) -func init() { - runtime.RegisterService(ServiceName, service.DefaultServiceFactory) -} - -func NewAuthServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc authservice.AuthServerRegistrar) []transport. -Server { - var servers []transport.Server - serverConfig := bootstrap.GetServer() - if serverConfig == nil { - return servers +// NewServers creates and configures the auth service servers (gRPC, HTTP). +func NewServers( + cfg *transportv1.Servers, + authSvc *service.AuthService, + meSvc *service.MeService, + casbinSvc *service.CasbinSourceService, + logger log.Logger, +) ([]transport.Server, error) { + if cfg == nil { + return nil, errors.New("servers config is nil") } - ll := log.NewHelper(r.WithLogger("module", "auth/server")) - middlewares := middleware.NewServer(bootstrap.GetServer().GetMiddleware()) - services := bootstrap.GetServer().GetServices() - coreinfo := bootstrap.GetServer().GetCore() - for _, serviceConfig := range services { - ll.Infow("msg", "service init", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) - var option service.ServerOption - switch serviceConfig.GetType() { - case "grpc": - options := []servicegrpc.Option{ - servicegrpc.WithMiddlewares(middlewares...), - servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), - } - option = service.WithGRPC(options...) - //grpcServer, err := r.Builder().NewGRPCServer(serviceConfig, options...) - //if err != nil { - // continue - //} - //ll.Infow("msg", "grpc server init", "name", coreinfo.GetName(), "version", - // coreinfo.GetVersion()) - //svc.Register(r.Context(), grpcServer) - //servers = append(servers, grpcServer) + var transportServers []transport.Server + for _, serverCfg := range cfg.GetConfigs() { + switch serverCfg.GetProtocol() { case "http": - options := []servicehttp.Option{ - servicehttp.WithMiddlewares(middlewares...), - servicehttp.WithPrefix(runtime.DefaultEnvPrefix), + srv, err := NewHTTPServer(serverCfg.GetHttp(), authSvc, meSvc, casbinSvc, logger) + if err != nil { + return nil, err } - option = service.WithHTTP(options...) - //httpServer, err := r.Builder().NewHTTPServer(serviceConfig, options...) - //if err != nil { - // continue - //} - //ll.Infow("msg", "http server init", "name", coreinfo.GetName(), "version", - // coreinfo.GetVersion()) - //svc.Register(r.Context(), httpServer) - //servers = append(servers, httpServer) + transportServers = append(transportServers, srv) + case "grpc": + srv, err := NewGRPCServer(serverCfg.GetGrpc(), authSvc, meSvc, casbinSvc, logger) + if err != nil { + return nil, err + } + transportServers = append(transportServers, srv) default: - ll.Warnw("msg", "service type not support", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) - continue - } - httpServer, err := r.Builder().NewServer("auth", serviceConfig, option) - if err != nil { - continue + return nil, errors.New("protocol is not supported: " + serverCfg.GetProtocol()) } - ll.Infow("msg", "auth server init", "name", coreinfo.GetName(), "version", - coreinfo.GetVersion()) - svc.Register(r.Context(), httpServer) - servers = append(servers, httpServer) } - return servers + return transportServers, nil } -func NewAuthClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service.GRPCClient, error) { - discovery := bootstrap.GetDiscovery() - if discovery == nil { - return nil, errors.New("no discovery") +// NewHTTPServer new an HTTP server. +func NewHTTPServer( + cfg *httpv1.Server, + authSvc *service.AuthService, + meSvc *service.MeService, + casbinSvc *service.CasbinSourceService, + logger log.Logger, +) (*http.Server, error) { + if cfg == nil { + return nil, errors.New("http config is nil") } - serviceConfig := &configv1.Service{ - Name: ServiceName, - Selector: &configv1.Service_Selector{ - Version: "v1.0.0", - Builder: "bbr", - }, + + var opts []http.ServerOption + if cfg.GetAddr() != "" { + opts = append(opts, http.Address(cfg.GetAddr())) } - helper := log.NewHelper(r.Logger()) - helper.Infof("service name: %s", discovery.ServiceName) - discover, err := runtime.NewDiscovery(discovery) - if err != nil { - return nil, errors.Wrap(err, "create discovery") + if cfg.GetTimeout() != nil { + opts = append(opts, http.Timeout(cfg.GetTimeout().AsDuration())) } - var ms []middleware.KMiddleware - options := []servicegrpc.Option{ - servicegrpc.WithDiscovery(discovery.ServiceName, discover), + srv := http.NewServer(opts...) + + // Register HTTP handlers + authv1.RegisterAuthHTTPServer(srv, authSvc) + authv1.RegisterMeHTTPServer(srv, meSvc) + authv1.RegisterCasbinSourceServiceHTTPServer(srv, casbinSvc) + + srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { + log.Infof("HTTP %s %s", method, path) + }) + return srv, nil +} + +// NewGRPCServer new a gRPC server. +func NewGRPCServer( + cfg *grpcv1.Server, + authSvc *service.AuthService, + meSvc *service.MeService, + casbinSvc *service.CasbinSourceService, + logger log.Logger, +) (*grpc.Server, error) { + if cfg == nil { + return nil, errors.New("grpc config is nil") } - ms = append(ms, middleware.NewClient(bootstrap.GetMiddleware())...) - ms = append(ms, MiddlewareServer()) - if len(ms) > 0 { - options = append(options, servicegrpc.WithMiddlewares(ms...)) + + var opts []grpc.ServerOption + if cfg.GetAddr() != "" { + opts = append(opts, grpc.Address(cfg.GetAddr())) } - client, err := runtime.NewGRPCServiceClient(context.Background(), serviceConfig, options...) - if err != nil { - return nil, errors.Wrap(err, "create menu grpc client") + if cfg.GetTimeout() != nil { + opts = append(opts, grpc.Timeout(cfg.GetTimeout().AsDuration())) } - return client, nil -} + srv := grpc.NewServer(opts...) -func MiddlewareServer() middleware.KMiddleware { - return func(handler middleware.KHandler) middleware.KHandler { - return func(ctx context.Context, req interface{}) (reply interface{}, err error) { - if md, ok := metadata.FromClientContext(ctx); ok { - log.Debugf("MiddlewareServer: found client context metadata: %+v", md) - } else { - log.Debugf("MiddlewareServer: no client context metadata found") - } - if md, ok := metadata.FromServerContext(ctx); ok { - log.Debugf("MiddlewareServer: found server context metadata: %+v", md) - } else { - log.Debugf("MiddlewareServer: no server context metadata found") - } - reply, err = handler(ctx, req) - return - } - } + // Register gRPC handlers + authv1.RegisterAuthServer(srv, authSvc) + authv1.RegisterMeServer(srv, meSvc) + authv1.RegisterCasbinSourceServiceServer(srv, casbinSvc) + + return srv, nil } diff --git a/internal/features/auth/service/auth.bridge.go b/internal/features/auth/service/auth.bridge.go deleted file mode 100644 index 5a43582a..00000000 --- a/internal/features/auth/service/auth.bridge.go +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - context2 "context" - "net/http" - - transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/auth" - typespb "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/helpers/resp" -) - -var ( - ErrorInvalidToken = typespb.ErrorSystemErrorReasonInvalidToken("invalid token") -) - -// AuthServiceHookedBridge is a menu service. -type AuthServiceHookedBridge struct { - pb.UnimplementedAuthServiceHooked - log *log.KHelper -} - -func (s AuthServiceHookedBridge) PrepareAuthLogout(ctx transhttp.Context, request *pb.AuthLogoutRequest) (context2.Context, error) { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceHookedBridge) CompleteAuthLogout(ctx transhttp.Context, request *pb.AuthLogoutRequest, response *pb.AuthLogoutResponse) error { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceHookedBridge) CompleteAuthenticate(ctx transhttp.Context, request *pb.AuthenticateRequest, response *pb.AuthenticateResponse) error { - if !response.IsValid { - return ErrorInvalidToken - } - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: true, - }) -} - -func (s AuthServiceHookedBridge) PrepareCreateToken(ctx transhttp.Context, request *pb.CreateTokenRequest) (context2.Context, error) { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceHookedBridge) CompleteCreateToken(ctx transhttp.Context, request *pb.CreateTokenRequest, response *pb.CreateTokenResponse) error { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceHookedBridge) PrepareDestroyToken(ctx transhttp.Context, request *pb.DestroyTokenRequest) (context2.Context, error) { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceHookedBridge) CompleteDestroyToken(ctx transhttp.Context, request *pb.DestroyTokenRequest, response *pb.DestroyTokenResponse) error { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceHookedBridge) PrepareListAuthResources(ctx transhttp.Context, request *pb.ListAuthResourcesRequest) (context2.Context, error) { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceHookedBridge) CompleteListAuthResources(ctx transhttp.Context, request *pb.ListAuthResourcesRequest, response *pb.ListAuthResourcesResponse) error { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceHookedBridge) PrepareValidateToken(ctx transhttp.Context, request *pb.ValidateTokenRequest) (context2.Context, error) { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceHookedBridge) CompleteValidateToken(ctx transhttp.Context, request *pb.ValidateTokenRequest, response *pb.ValidateTokenResponse) error { - //TODO implement me - panic("implement me") -} - -func (s AuthServiceHookedBridge) AuthLogout(ctx context.Context, request *pb.AuthLogoutRequest) (*pb.AuthLogoutResponse, error) { - //TODO implement me - panic("implement me") -} - -//func (s AuthServiceHookedBridge) Authenticate(ctx context.Context, request *pb.AuthenticateRequest) (*pb.AuthenticateResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Authenticate(ctx, request) -// if err != nil { -// return nil, err -// } -// if !response.IsValid { -// return nil, ErrorInvalidToken -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Result{ -// Success: true, -// }) -// return nil, nil -//} -// -//func (s AuthServiceHookedBridge) CreateToken(ctx context.Context, request *pb.CreateTokenRequest) (*pb.CreateTokenResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.CreateToken(ctx, request) -// if err != nil { -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Result{ -// Success: true, -// Data: response, -// }) -// return nil, nil -//} -// -//func (s AuthServiceHookedBridge) DestroyToken(ctx context.Context, request *pb.DestroyTokenRequest) (*pb.DestroyTokenResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.DestroyToken(ctx, request) -// if err != nil { -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Result{ -// Success: true, -// Data: response, -// }) -// return nil, nil -//} -// -//func (s AuthServiceHookedBridge) ValidateToken(ctx context.Context, request *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.ValidateToken(ctx, request) -// if err != nil { -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Result{ -// Success: true, -// Data: response, -// }) -// return nil, nil -//} -// -//func (s AuthServiceHookedBridge) ListAuthResources(ctx context.Context, request *pb.ListAuthResourcesRequest) (*pb.ListAuthResourcesResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.ListAuthResources(ctx, request) -// if err != nil { -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Page{ -// Success: true, -// Total: response.TotalSize, -// Data: resp.Proto2AnyPBArray(response.Resources...), -// }) -// return nil, nil -//} - -func NewAuthServiceHookedBridge(r runtime.Runtime, client pb.AuthServiceServer) pb.AuthServiceHookedBridger { - return pb.WithAuthServiceHook(&AuthServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/auth")), - })(client) -} - -// NewAuthServiceBridge new a menu service. -func NewAuthServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.AuthServiceServer { - return pb.NewAuthServiceBridge(client) -} - -func NewAuthServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.AuthServiceServer { - if v, ok := clients["auth"]; ok { - return NewAuthServiceBridge(r, v) - } else { - return pb.UnimplementedAuthServiceServer{} - } -} - -// NewAuthServiceHTTPBridge new a menu service. -func NewAuthServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.AuthServiceHTTPServer { - return pb.NewAuthServiceHTTPBridge(client) -} diff --git a/internal/features/auth/service/auth.go b/internal/features/auth/service/auth.go new file mode 100644 index 00000000..8b786353 --- /dev/null +++ b/internal/features/auth/service/auth.go @@ -0,0 +1,67 @@ +package service + +import ( + "context" + + "google.golang.org/protobuf/types/known/emptypb" + + v1 "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/features/auth/biz" + "origadmin/application/admin/internal/pkg/token" +) + +// AuthService is a service for authentication. +type AuthService struct { + v1.UnimplementedAuthServer + uc *biz.AuthUseCase + tm token.Manager +} + +// NewAuthService creates a new authentication service. +func NewAuthService(uc *biz.AuthUseCase, tm token.Manager) *AuthService { + return &AuthService{uc: uc, tm: tm} +} + +// Login authenticates a user and returns a token pair. +func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.LoginResponse, error) { + userID, err := s.uc.VerifyUser(ctx, req.Username, req.Password) + if err != nil { + return nil, err + } + + accessToken, refreshToken, err := s.tm.Generate(ctx, userID) + if err != nil { + return nil, err + } + + return &v1.LoginResponse{ + AccessToken: accessToken, + RefreshToken: refreshToken, + TokenType: "Bearer", + }, nil +} + +// Register creates a new user account. +func (s *AuthService) Register(ctx context.Context, req *v1.RegisterRequest) (*emptypb.Empty, error) { + return &emptypb.Empty{}, nil +} + +// Logout invalidates the user's session. +func (s *AuthService) Logout(ctx context.Context, req *v1.LogoutRequest) (*emptypb.Empty, error) { + return &emptypb.Empty{}, nil +} + +// RefreshToken provides a new access token. +func (s *AuthService) RefreshToken(ctx context.Context, req *v1.RefreshTokenRequest) (*v1.RefreshTokenResponse, error) { + return &v1.RefreshTokenResponse{}, nil +} + +// GetCaptcha generates a new captcha. +func (s *AuthService) GetCaptcha(ctx context.Context, req *v1.GetCaptchaRequest) (*v1.GetCaptchaResponse, error) { + return &v1.GetCaptchaResponse{}, nil +} + +// Authenticate is for internal use by the gateway to verify user access via gRPC. +func (s *AuthService) Authenticate(ctx context.Context, req *v1.AuthenticateRequest) (*v1.AuthenticateResponse, error) { + return &v1.AuthenticateResponse{}, nil +} diff --git a/internal/features/auth/service/auth.grpc.go b/internal/features/auth/service/auth.grpc.go deleted file mode 100644 index 1eaedb28..00000000 --- a/internal/features/auth/service/auth.grpc.go +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime/context" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/features/auth/biz" // Corrected import path -) - -// AuthServiceServer is a menu service. -type AuthServiceServer struct { - pb.UnimplementedAuthServiceServer - - client *biz.AuthServiceBiz -} - -func (s AuthServiceServer) ListAuthResources(ctx context.Context, request *pb.ListAuthResourcesRequest) (*pb.ListAuthResourcesResponse, error) { - return s.client.ListAuthResources(ctx, request) -} - -// NewAuthServiceServerPB new a menu service. -func NewAuthServiceServerPB(client *biz.AuthServiceBiz) pb.AuthServiceServer { - return &AuthServiceServer{client: client} -} - -var _ pb.AuthServiceServer = (*AuthServiceServer)(nil) diff --git a/internal/features/auth/service/auth.http.go b/internal/features/auth/service/auth.http.go deleted file mode 100644 index 85619501..00000000 --- a/internal/features/auth/service/auth.http.go +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime/context" - - pb "origadmin/application/admin/api/v1/services/auth" -) - -// AuthServiceHTTPServer is a menu service. -type AuthServiceHTTPServer struct { - pb.UnimplementedAuthServiceServer - - client pb.AuthServiceHTTPClient -} - -func (s AuthServiceHTTPServer) ListAuthResources(ctx context.Context, request *pb.ListAuthResourcesRequest) (*pb.ListAuthResourcesResponse, error) { - return s.client.ListAuthResources(ctx, request) -} - -//func (m AuthServiceHTTPServer) mustEmbedUnimplementedAuthServiceHTTPServer() { -// //TODO implement me -// panic("implement me") -//} - -// NewAuthServiceHTTPServer new a menu service. -func NewAuthServiceHTTPServer(client pb.AuthServiceHTTPClient) *AuthServiceHTTPServer { - return &AuthServiceHTTPServer{client: client} -} - -// NewAuthServiceHTTPServerPB new a menu service. -func NewAuthServiceHTTPServerPB(client pb.AuthServiceHTTPClient) pb.AuthServiceHTTPServer { - return &AuthServiceHTTPServer{client: client} -} - -var _ pb.AuthServiceServer = (*AuthServiceHTTPServer)(nil) diff --git a/internal/features/auth/service/casbin.bridge.go b/internal/features/auth/service/casbin.bridge.go deleted file mode 100644 index 70bc4b93..00000000 --- a/internal/features/auth/service/casbin.bridge.go +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - - "github.com/go-kratos/kratos/v2/transport/http" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/auth" -) - -// CasbinServiceHookedBridge is a Casbin service. -type CasbinServiceHookedBridge struct { - pb.UnimplementedCasbinSourceServiceHooked - log *log.KHelper -} - -func (c CasbinServiceHookedBridge) CompleteListGroupings(context http.Context, request *pb.ListGroupingsRequest, response *pb.ListGroupingsResponse) error { - //TODO implement me - panic("implement me") -} - -func (c CasbinServiceHookedBridge) PrepareListPolicies(context http.Context, request *pb.ListPoliciesRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (c CasbinServiceHookedBridge) CompleteListPolicies(context http.Context, request *pb.ListPoliciesRequest, response *pb.ListPoliciesResponse) error { - //TODO implement me - panic("implement me") -} - -func (c CasbinServiceHookedBridge) PrepareWatchUpdate(context http.Context, request *pb.WatchUpdateRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (c CasbinServiceHookedBridge) CompleteWatchUpdate(context http.Context, request *pb.WatchUpdateRequest, response *pb.WatchUpdateResponse) error { - //TODO implement me - panic("implement me") -} - -//func (s CasbinServiceHookedBridge) PersonalLogout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Logout(ctx, request) -// if err != nil { -// log.Errorf("Logout error: %v", err) -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Data{ -// Success: true, -// Data: resp.Proto2Any(response), -// }) -// return nil, nil -//} -// -//func (s CasbinServiceHookedBridge) Register(ctx context.Context, request *pb.RegisterRequest) (*pb.RegisterResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Register(ctx, request) -// if err != nil { -// log.Errorf("Register error: %v", err) -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Data{ -// Success: true, -// Data: resp.Proto2Any(response), -// }) -// return nil, nil -//} -// -//func (s CasbinServiceHookedBridge) Captcha(ctx context.Context, request *pb.CaptchaRequest) (*pb.CaptchaResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Captcha(ctx, request) -// if err != nil { -// log.Errorf("Captcha error: %v", err) -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Data{ -// Success: true, -// Data: resp.Proto2Any(response), -// }) -// return nil, nil -//} -// -//func (s CasbinServiceHookedBridge) CaptchaId(ctx context.Context, request *pb.CaptchaIdRequest) (*pb.CaptchaIdResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// log.Debugf("CaptchaId: Request:%+v", request) -// response, err := s.client.CaptchaId(ctx, request) -// log.Debugf("CaptchaId: Response:%+v, Error:%+v", response, err) -// if err != nil { -// log.Errorf("CaptchaImage error: %v", err) -// return nil, err -// } -// -// s.JSON(httpCtx, http.StatusOK, &resp.StringResult{ -// Success: true, -// Data: response.Data, -// }) -// return nil, nil -//} -// -//func (s CasbinServiceHookedBridge) CaptchaAudio(ctx context.Context, request *pb.CaptchaAudioRequest) (*pb.CaptchaAudioResponse, error) { -// _, err := s.client.CaptchaAudio(ctx, request) -// if err != nil { -// log.Errorf("Logout error: %v", err) -// return nil, err -// } -// return nil, nil -//} -//func (s CasbinServiceHookedBridge) CaptchaImage(ctx context.Context, request *pb.CaptchaImageRequest) (*pb.CaptchaImageResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// log.Debugf("CaptchaImage: Request:%+v", request) -// response, err := s.client.CaptchaImage(ctx, request) -// log.Debugf("CaptchaImage: Response:%+v, Error:%+v", response, err) -// if err != nil { -// log.Errorf("CaptchaImage error: %v", err) -// return nil, err -// } -// log.Debugf("CaptchaImage: Setting headers: %+v", response.Headers) -// for k, v := range response.Headers { -// httpCtx.Response().Header().Set(k, v) -// } -// log.Debugf("CaptchaImage: Writing response headers") -// httpCtx.Response().WriteHeader(http.StatusOK) -// log.Debugf("CaptchaImage: Writing response image") -// if _, err := httpCtx.Response().Write(response.Image); err != nil { -// log.Errorf("CaptchaImage error writing response: %v", err) -// return nil, err -// } -// //log.Debugf("CaptchaImage: Flushing response writer") -// //context.Response().Flush() -// log.Debugf("CaptchaImage: Completed successfully") -// return nil, nil -//} -// -//func (s CasbinServiceHookedBridge) TokenRefresh(ctx context.Context, request *pb.TokenRefreshRequest) (*pb.TokenRefreshResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.TokenRefresh(ctx, request) -// if err != nil { -// log.Errorf("Refresh error: %v", err) -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Data{ -// Success: true, -// Data: resp.Proto2Any(resp.FromToken(response.Token)), -// }) -// return nil, nil -//} -// -//func (s CasbinServiceHookedBridge) Casbin(ctx context.Context, request *pb.CasbinRequest) (*pb.CasbinResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Casbin(ctx, request) -// if err != nil { -// log.Errorf("Casbin error: %v", err) -// return nil, err -// } -// token := resp.FromToken(response.Token) -// log.Debugf("Casbin: Token:%+v", token) -// s.JSON(httpCtx, http.StatusOK, &resp.Result{ -// Success: true, -// Data: token, -// }) -// return nil, nil -//} -// -//func (s CasbinServiceHookedBridge) Logout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Logout(ctx, request) -// if err != nil { -// log.Errorf("Logout error: %v", err) -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Data{ -// Success: true, -// Data: resp.Proto2Any(response), -// }) -// return nil, nil -//} - -func NewCasbinServiceHookedBridge(r runtime.Runtime, client pb.CasbinSourceServiceHTTPServer) pb. -CasbinSourceServiceHookedBridger { - return pb.WithCasbinSourceServiceHook(&CasbinServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/auth")), - })(client) -} - -// NewCasbinServiceBridge new a menu service. -func NewCasbinServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.CasbinSourceServiceServer { - return pb.NewCasbinSourceServiceBridge(client) -} - -func NewCasbinServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.CasbinSourceServiceServer { - if v, ok := clients["auth"]; ok { - return NewCasbinServiceBridge(r, v) - } else { - return pb.UnimplementedCasbinSourceServiceServer{} - } -} - -// NewCasbinServiceHTTPBridge new a menu service. -func NewCasbinServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.CasbinSourceServiceHTTPServer { - return pb.NewCasbinSourceServiceHTTPBridge(client) -} diff --git a/internal/features/auth/service/casbin.go b/internal/features/auth/service/casbin.go index 4125045d..4163b8c0 100644 --- a/internal/features/auth/service/casbin.go +++ b/internal/features/auth/service/casbin.go @@ -1,121 +1,37 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - package service import ( "context" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - "google.golang.org/grpc" - "google.golang.org/grpc/status" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/contrib/security/authz/casbin" - "origadmin/application/admin/internal/features/auth/biz" // Corrected import path + v1 "origadmin/application/admin/api/v1/services/auth" ) -// CasbinSourceBiz is a Casbin rule source service. -type CasbinSourceBiz struct { - client *biz.CasbinSourceServiceBiz - log *log.KHelper -} - -func (c CasbinSourceBiz) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { - return c.client.ListPolicies(ctx, in) -} - -func (c CasbinSourceBiz) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, in) -} - -func (c CasbinSourceBiz) WatchUpdate(ctx context.Context, in *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { - return c.client.WatchUpdate(ctx, in) -} - -func (c CasbinSourceBiz) StreamRules(ctx context.Context, in *pb.StreamRulesRequest) (grpc.ServerStreamingClient[pb.StreamRulesResponse], error) { - stream := biz.NewCasbinRuleStream(ctx, c.client) - go func() { - err := stream.Start(in) - if err != nil { - c.log.Error("stream error", "error", err) - } - }() - return stream, nil -} - -func NewCasbinSourceBiz(r runtime.Runtime, client *biz.CasbinSourceServiceBiz) casbin.RuleSource { - return &CasbinSourceBiz{ - client: client, - log: log.NewHelper(r.WithLogger("module", "service/casbin")), - } -} - -// CasbinSourceClient is a Casbin rule source service. -type CasbinSourceClient struct { - client pb.CasbinSourceServiceClient - log *log.KHelper -} - -func (c CasbinSourceClient) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { - return c.client.ListPolicies(ctx, in) -} - -func (c CasbinSourceClient) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, in) -} - -func (c CasbinSourceClient) WatchUpdate(ctx context.Context, in *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { - return c.client.WatchUpdate(ctx, in) -} - -func (c CasbinSourceClient) StreamRules(ctx context.Context, in *pb.StreamRulesRequest) (grpc.ServerStreamingClient[pb.StreamRulesResponse], error) { - return c.client.StreamRules(ctx, in) -} - -// NewCasbinSourceClient new a menu service. -func NewCasbinSourceClient(r runtime.Runtime, clients map[string]*service.GRPCClient) casbin.RuleSource { - ll := log.NewHelper(r.WithLogger("module", "service/casbin")) - client, ok := clients["auth"] - c := NewUnimplementedCasbinSource(r) - if ok { - c = pb.NewCasbinSourceServiceClient(client) - } - return &CasbinSourceClient{ - client: c, - log: ll, - } -} - -func NewUnimplementedCasbinSource(r runtime.Runtime) pb.CasbinSourceServiceClient { - return UnimplementedCasbinSource{ - log: log.NewHelper(r.WithLogger("module", "service/casbin")), - } +// CasbinSourceService is a service for Casbin. +type CasbinSourceService struct { + v1.UnimplementedCasbinSourceServiceServer } -type UnimplementedCasbinSource struct { - log *log.KHelper +// NewCasbinSourceService creates a new Casbin source service. +func NewCasbinSourceService() *CasbinSourceService { + return &CasbinSourceService{} } -func (u UnimplementedCasbinSource) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest, opts ...grpc.CallOption) (*pb.ListPoliciesResponse, error) { - u.log.Error("ListPolicies not implemented") - return &pb.ListPoliciesResponse{}, nil +// ListPolicies returns a list of policies. +func (s *CasbinSourceService) ListPolicies(ctx context.Context, req *v1.ListPoliciesRequest) (*v1.ListPoliciesResponse, error) { + return &v1.ListPoliciesResponse{}, nil } -func (u UnimplementedCasbinSource) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest, opts ...grpc.CallOption) (*pb.ListGroupingsResponse, error) { - u.log.Error("ListGroupings not implemented") - return &pb.ListGroupingsResponse{}, nil +// ListGroupings returns a list of groupings. +func (s *CasbinSourceService) ListGroupings(ctx context.Context, req *v1.ListGroupingsRequest) (*v1.ListGroupingsResponse, error) { + return &v1.ListGroupingsResponse{}, nil } -func (u UnimplementedCasbinSource) WatchUpdate(ctx context.Context, in *pb.WatchUpdateRequest, opts ...grpc.CallOption) (*pb.WatchUpdateResponse, error) { - u.log.Error("WatchUpdate not implemented") - return &pb.WatchUpdateResponse{}, nil +// WatchUpdate returns a watch update. +func (s *CasbinSourceService) WatchUpdate(ctx context.Context, req *v1.WatchUpdateRequest) (*v1.WatchUpdateResponse, error) { + return &v1.WatchUpdateResponse{}, nil } -func (u UnimplementedCasbinSource) StreamRules(ctx context.Context, in *pb.StreamRulesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[pb.StreamRulesResponse], error) { - u.log.Error("StreamRules not implemented") - return nil, status.Error(400, "not implemented") +// StreamRules returns a stream of rules. +func (s *CasbinSourceService) StreamRules(req *v1.StreamRulesRequest, stream v1.CasbinSourceService_StreamRulesServer) error { + return nil } diff --git a/internal/features/auth/service/casbin.grpc.go b/internal/features/auth/service/casbin.grpc.go deleted file mode 100644 index 5fc556e4..00000000 --- a/internal/features/auth/service/casbin.grpc.go +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package service implements the functions, types, and interfaces for the moduls.enforcer. -package service - -import ( - "context" - - "github.com/origadmin/runtime/service" - "google.golang.org/grpc" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/features/auth/biz" // Corrected import path -) - -type CasbinSourceServiceServer struct { - pb.UnimplementedCasbinSourceServiceServer - client *biz.CasbinSourceServiceBiz -} - -func (c *CasbinSourceServiceServer) WatchUpdate(ctx context.Context, request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { - return c.client.WatchUpdate(ctx, request) -} - -func (c *CasbinSourceServiceServer) mustEmbedUnimplementedCasbinSourceServiceServer() { - -} - -func (c *CasbinSourceServiceServer) ListPolicies(ctx context.Context, - request *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { - return c.client.ListPolicies(ctx, request) -} - -func (c *CasbinSourceServiceServer) ListGroupings(ctx context.Context, - request *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, request) -} - -func (c *CasbinSourceServiceServer) StreamRules(request *pb.StreamRulesRequest, - stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { - return c.client.StreamRules(request, stream) -} - -// NewCasbinSourceServiceServerPB new a menu service. -func NewCasbinSourceServiceServerPB(client *biz.CasbinSourceServiceBiz) pb.CasbinSourceServiceServer { - return &CasbinSourceServiceServer{client: client} -} - -func NewCasbinSourceServiceClient(client *service.GRPCClient) pb.CasbinSourceServiceClient { - return pb.NewCasbinSourceServiceClient(client) -} - -var _ pb.CasbinSourceServiceServer = (*CasbinSourceServiceServer)(nil) diff --git a/internal/features/auth/service/casbin.http.go b/internal/features/auth/service/casbin.http.go deleted file mode 100644 index aa8eccb1..00000000 --- a/internal/features/auth/service/casbin.http.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime/context" - - pb "origadmin/application/admin/api/v1/services/auth" -) - -// CasbinSourceServiceHTTPServer is a login service. -type CasbinSourceServiceHTTPServer struct { - pb.UnimplementedCasbinSourceServiceServer - client pb.CasbinSourceServiceHTTPClient -} - -func (c CasbinSourceServiceHTTPServer) ListGroupings(ctx context.Context, request *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { - //TODO implement me - panic("implement me") -} - -func (c CasbinSourceServiceHTTPServer) ListPolicies(ctx context.Context, request *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (c CasbinSourceServiceHTTPServer) WatchUpdate(ctx context.Context, request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { - //TODO implement me - panic("implement me") -} - -// NewCasbinServiceHTTPServer new a login service. -func NewCasbinServiceHTTPServer(client pb.CasbinSourceServiceHTTPClient) *CasbinSourceServiceHTTPServer { - return &CasbinSourceServiceHTTPServer{client: client} -} - -// NewCasbinSourceServiceHTTPServerPB new a login service. -func NewCasbinSourceServiceHTTPServerPB(client pb.CasbinSourceServiceHTTPClient) pb.CasbinSourceServiceHTTPServer { - return &CasbinSourceServiceHTTPServer{client: client} -} - -var _ pb.CasbinSourceServiceHTTPServer = (*CasbinSourceServiceHTTPServer)(nil) diff --git a/internal/features/auth/service/login.bridge.go b/internal/features/auth/service/login.bridge.go deleted file mode 100644 index 4318dd02..00000000 --- a/internal/features/auth/service/login.bridge.go +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - "net/http" - - transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - "google.golang.org/protobuf/encoding/protojson" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/helpers/resp" -) - -// LoginServiceHookedBridge is a Login service. -type LoginServiceHookedBridge struct { - pb.UnimplementedLoginServiceHooked - log *log.KHelper -} - -func (s LoginServiceHookedBridge) CompleteCaptcha(ctx transhttp.Context, request *pb.CaptchaRequest, response *pb.CaptchaResponse) error { - marshal, err := protojson.Marshal(response) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: true, - Data: marshal, - }) -} - -func (s LoginServiceHookedBridge) CompleteCaptchaAudio(ctx transhttp.Context, request *pb.CaptchaAudioRequest, response *pb.CaptchaAudioResponse) error { - return ctx.JSON(http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) -} - -func (s LoginServiceHookedBridge) CompleteCaptchaId(ctx transhttp.Context, request *pb.CaptchaIdRequest, response *pb.CaptchaIdResponse) error { - return ctx.JSON(http.StatusOK, &resp.Data{ - Success: true, - Data: resp.Proto2Any(response), - }) -} - -func (s LoginServiceHookedBridge) CompleteCaptchaImage(ctx transhttp.Context, request *pb.CaptchaImageRequest, response *pb.CaptchaImageResponse) error { - s.log.Debugf("CaptchaImage: Setting headers: %+v", response.Headers) - for k, v := range response.Headers { - ctx.Response().Header().Set(k, v) - } - s.log.Debugf("CaptchaImage: Writing response headers") - ctx.Response().WriteHeader(http.StatusOK) - s.log.Debugf("CaptchaImage: Writing response image") - if _, err := ctx.Response().Write(response.Image); err != nil { - log.Errorf("CaptchaImage error writing response: %v", err) - return err - } - s.log.Debugf("CaptchaImage: Completed successfully") - return nil -} - -func (s LoginServiceHookedBridge) CompleteLogin(ctx transhttp.Context, request *pb.LoginRequest, response *pb.LoginResponse) error { - marshal, err := protojson.Marshal(resp.FromToken(response.Token)) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: true, - Data: marshal, - }) -} - -func (s LoginServiceHookedBridge) PrepareLogout(ctx transhttp.Context, request *pb.LogoutRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (s LoginServiceHookedBridge) CompleteLogout(ctx transhttp.Context, request *pb.LogoutRequest, response *pb.LogoutResponse) error { - //TODO implement me - panic("implement me") -} - -func (s LoginServiceHookedBridge) PrepareRegister(ctx transhttp.Context, request *pb.RegisterRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (s LoginServiceHookedBridge) CompleteRegister(ctx transhttp.Context, request *pb.RegisterRequest, response *pb.RegisterResponse) error { - //TODO implement me - panic("implement me") -} - -func (s LoginServiceHookedBridge) CompleteTokenRefresh(ctx transhttp.Context, request *pb.TokenRefreshRequest, response *pb.TokenRefreshResponse) error { - marshal, err := protojson.Marshal(resp.FromToken(response.Token)) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: true, - Data: marshal, - }) -} - -//func (s LoginServiceHookedBridge) PersonalLogout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Logout(ctx, request) -// if err != nil { -// log.Errorf("Logout error: %v", err) -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Data{ -// Success: true, -// Data: resp.Proto2Any(response), -// }) -// return nil, nil -//} -// -//func (s LoginServiceHookedBridge) Register(ctx context.Context, request *pb.RegisterRequest) (*pb.RegisterResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Register(ctx, request) -// if err != nil { -// log.Errorf("Register error: %v", err) -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Data{ -// Success: true, -// Data: resp.Proto2Any(response), -// }) -// return nil, nil -//} -// -//func (s LoginServiceHookedBridge) Captcha(ctx context.Context, request *pb.CaptchaRequest) (*pb.CaptchaResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Captcha(ctx, request) -// if err != nil { -// log.Errorf("Captcha error: %v", err) -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Data{ -// Success: true, -// Data: resp.Proto2Any(response), -// }) -// return nil, nil -//} -// -//func (s LoginServiceHookedBridge) CaptchaId(ctx context.Context, request *pb.CaptchaIdRequest) (*pb.CaptchaIdResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// log.Debugf("CaptchaId: Request:%+v", request) -// response, err := s.client.CaptchaId(ctx, request) -// log.Debugf("CaptchaId: Response:%+v, Error:%+v", response, err) -// if err != nil { -// log.Errorf("CaptchaImage error: %v", err) -// return nil, err -// } -// -// s.JSON(httpCtx, http.StatusOK, &resp.StringResult{ -// Success: true, -// Data: response.Data, -// }) -// return nil, nil -//} -// -//func (s LoginServiceHookedBridge) CaptchaAudio(ctx context.Context, request *pb.CaptchaAudioRequest) (*pb.CaptchaAudioResponse, error) { -// _, err := s.client.CaptchaAudio(ctx, request) -// if err != nil { -// log.Errorf("Logout error: %v", err) -// return nil, err -// } -// return nil, nil -//} -//func (s LoginServiceHookedBridge) CaptchaImage(ctx context.Context, request *pb.CaptchaImageRequest) (*pb.CaptchaImageResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// log.Debugf("CaptchaImage: Request:%+v", request) -// response, err := s.client.CaptchaImage(ctx, request) -// log.Debugf("CaptchaImage: Response:%+v, Error:%+v", response, err) -// if err != nil { -// log.Errorf("CaptchaImage error: %v", err) -// return nil, err -// } -// log.Debugf("CaptchaImage: Setting headers: %+v", response.Headers) -// for k, v := range response.Headers { -// httpCtx.Response().Header().Set(k, v) -// } -// log.Debugf("CaptchaImage: Writing response headers") -// httpCtx.Response().WriteHeader(http.StatusOK) -// log.Debugf("CaptchaImage: Writing response image") -// if _, err := httpCtx.Response().Write(response.Image); err != nil { -// log.Errorf("CaptchaImage error writing response: %v", err) -// return nil, err -// } -// //log.Debugf("CaptchaImage: Flushing response writer") -// //context.Response().Flush() -// log.Debugf("CaptchaImage: Completed successfully") -// return nil, nil -//} -// -//func (s LoginServiceHookedBridge) TokenRefresh(ctx context.Context, request *pb.TokenRefreshRequest) (*pb.TokenRefreshResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.TokenRefresh(ctx, request) -// if err != nil { -// log.Errorf("Refresh error: %v", err) -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Data{ -// Success: true, -// Data: resp.Proto2Any(resp.FromToken(response.Token)), -// }) -// return nil, nil -//} -// -//func (s LoginServiceHookedBridge) Login(ctx context.Context, request *pb.LoginRequest) (*pb.LoginResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Login(ctx, request) -// if err != nil { -// log.Errorf("Login error: %v", err) -// return nil, err -// } -// token := resp.FromToken(response.Token) -// log.Debugf("Login: Token:%+v", token) -// s.JSON(httpCtx, http.StatusOK, &resp.Result{ -// Success: true, -// Data: token, -// }) -// return nil, nil -//} -// -//func (s LoginServiceHookedBridge) Logout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { -// httpCtx := agent.FromHTTPContext(ctx) -// response, err := s.client.Logout(ctx, request) -// if err != nil { -// log.Errorf("Logout error: %v", err) -// return nil, err -// } -// s.JSON(httpCtx, http.StatusOK, &resp.Data{ -// Success: true, -// Data: resp.Proto2Any(response), -// }) -// return nil, nil -//} - -func NewLoginServiceHookedBridge(r runtime.Runtime, client pb.LoginServiceHTTPServer) pb.LoginServiceHookedBridger { - return pb.WithLoginServiceHook(&LoginServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/auth")), - })(client) -} - -// NewLoginServiceBridge new a menu service. -func NewLoginServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.LoginServiceServer { - return pb.NewLoginServiceBridge(client) -} - -func NewLoginServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.LoginServiceServer { - if v, ok := clients["auth"]; ok { - return NewLoginServiceBridge(r, v) - } else { - return pb.UnimplementedLoginServiceServer{} - } -} - -// NewLoginServiceHTTPBridge new a menu service. -func NewLoginServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.LoginServiceHTTPServer { - return pb.NewLoginServiceHTTPBridge(client) -} diff --git a/internal/features/auth/service/login.grpc.go b/internal/features/auth/service/login.grpc.go deleted file mode 100644 index dede06d2..00000000 --- a/internal/features/auth/service/login.grpc.go +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "golang.org/x/net/context" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/features/auth/biz" // Corrected import path -) - -// LoginServiceServer is a login service. -type LoginServiceServer struct { - pb.UnimplementedLoginServiceServer - - client *biz.LoginServiceBiz -} - -func (obj LoginServiceServer) Logout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { - return obj.client.Logout(ctx, request) -} - -func (obj LoginServiceServer) TokenRefresh(ctx context.Context, request *pb.TokenRefreshRequest) (*pb.TokenRefreshResponse, error) { - return obj.client.TokenRefresh(ctx, request) -} - -func (obj LoginServiceServer) Register(ctx context.Context, request *pb.RegisterRequest) (*pb.RegisterResponse, error) { - return obj.client.Register(ctx, request) -} - -func (obj LoginServiceServer) Captcha(ctx context.Context, request *pb.CaptchaRequest) (*pb.CaptchaResponse, error) { - return obj.client.Captcha(ctx, request) -} - -func (obj LoginServiceServer) CaptchaId(ctx context.Context, request *pb.CaptchaIdRequest) (*pb.CaptchaIdResponse, error) { - return obj.client.CaptchaId(ctx, request) -} - -func (obj LoginServiceServer) CaptchaImage(ctx context.Context, request *pb.CaptchaImageRequest) (*pb.CaptchaImageResponse, error) { - return obj.client.CaptchaImage(ctx, request) -} - -func (obj LoginServiceServer) Login(ctx context.Context, request *pb.LoginRequest) (*pb.LoginResponse, error) { - return obj.client.Login(ctx, request) -} - -//func (l LoginServiceServer) mustEmbedUnimplementedLoginServiceServer() { -// //TODO implement me -// panic("implement me") -//} - -// NewLoginServiceServer new a login service. -func NewLoginServiceServer(client *biz.LoginServiceBiz) *LoginServiceServer { - return &LoginServiceServer{client: client} -} - -// NewLoginServiceServerPB new a login service. -func NewLoginServiceServerPB(client *biz.LoginServiceBiz) pb.LoginServiceServer { - return &LoginServiceServer{client: client} -} - -var _ pb.LoginServiceServer = (*LoginServiceServer)(nil) diff --git a/internal/features/auth/service/login.http.go b/internal/features/auth/service/login.http.go deleted file mode 100644 index f8c53803..00000000 --- a/internal/features/auth/service/login.http.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - - pb "origadmin/application/admin/api/v1/services/auth" -) - -// LoginServiceHTTPServer is a login service. -type LoginServiceHTTPServer struct { - pb.UnimplementedLoginServiceServer - - client pb.LoginServiceHTTPClient -} - -func (obj LoginServiceHTTPServer) Logout(ctx context.Context, request *pb.LogoutRequest) (*pb.LogoutResponse, error) { - return obj.client.Logout(ctx, request) -} - -func (obj LoginServiceHTTPServer) TokenRefresh(ctx context.Context, request *pb.TokenRefreshRequest) (*pb.TokenRefreshResponse, error) { - return obj.client.TokenRefresh(ctx, request) -} - -func (obj LoginServiceHTTPServer) Register(ctx context.Context, request *pb.RegisterRequest) (*pb.RegisterResponse, error) { - return obj.client.Register(ctx, request) -} - -func (obj LoginServiceHTTPServer) Captcha(ctx context.Context, request *pb.CaptchaRequest) (*pb.CaptchaResponse, error) { - return obj.client.Captcha(ctx, request) -} - -func (obj LoginServiceHTTPServer) CaptchaId(ctx context.Context, request *pb.CaptchaIdRequest) (*pb.CaptchaIdResponse, error) { - return obj.client.CaptchaId(ctx, request) -} - -func (obj LoginServiceHTTPServer) CaptchaImage(ctx context.Context, request *pb.CaptchaImageRequest) (*pb.CaptchaImageResponse, error) { - return obj.client.CaptchaImage(ctx, request) -} - -func (obj LoginServiceHTTPServer) Login(ctx context.Context, request *pb.LoginRequest) (*pb.LoginResponse, error) { - return obj.client.Login(ctx, request) -} - -//func (l LoginServiceHTTPServer) mustEmbedUnimplementedLoginServiceHTTPServer() { -// //TODO implement me -// panic("implement me") -//} - -// NewLoginServiceHTTPServer new a login service. -func NewLoginServiceHTTPServer(client pb.LoginServiceHTTPClient) *LoginServiceHTTPServer { - return &LoginServiceHTTPServer{client: client} -} - -// NewLoginServiceHTTPServerPB new a login service. -func NewLoginServiceHTTPServerPB(client pb.LoginServiceHTTPClient) pb.LoginServiceHTTPServer { - return &LoginServiceHTTPServer{client: client} -} - -var _ pb.LoginServiceHTTPServer = (*LoginServiceHTTPServer)(nil) diff --git a/internal/features/auth/service/me.go b/internal/features/auth/service/me.go new file mode 100644 index 00000000..42d153ed --- /dev/null +++ b/internal/features/auth/service/me.go @@ -0,0 +1,49 @@ +package service + +import ( + "context" + + "google.golang.org/protobuf/types/known/emptypb" + + v1 "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/features/auth/biz" +) + +// MeService is a service for the currently authenticated user. +type MeService struct { + v1.UnimplementedMeServer + uc *biz.MeUseCase +} + +// NewMeService creates a new Me service. +func NewMeService(uc *biz.MeUseCase) *MeService { + return &MeService{uc: uc} +} + +// GetProfile retrieves the profile of the currently authenticated user. +func (s *MeService) GetProfile(ctx context.Context, req *v1.GetProfileRequest) (*types.User, error) { + // TODO: Get userID from context + userID := int64(1) // Placeholder + return s.uc.GetProfile(ctx, userID) +} + +// UpdateProfile updates the profile of the currently authenticated user. +func (s *MeService) UpdateProfile(ctx context.Context, req *v1.UpdateProfileRequest) (*emptypb.Empty, error) { + return &emptypb.Empty{}, nil +} + +// UpdatePassword changes the password for the currently authenticated user. +func (s *MeService) UpdatePassword(ctx context.Context, req *v1.UpdatePasswordRequest) (*emptypb.Empty, error) { + return &emptypb.Empty{}, nil +} + +// GetUserResources retrieves the menu/resource list for the current user. +func (s *MeService) GetUserResources(ctx context.Context, req *v1.GetUserResourcesRequest) (*v1.GetUserResourcesResponse, error) { + return &v1.GetUserResourcesResponse{}, nil +} + +// GetUserRoles retrieves the role list for the current user. +func (s *MeService) GetUserRoles(ctx context.Context, req *v1.GetUserRolesRequest) (*v1.GetUserRolesResponse, error) { + return &v1.GetUserRolesResponse{}, nil +} diff --git a/internal/features/auth/service/personal.bridge.go b/internal/features/auth/service/personal.bridge.go deleted file mode 100644 index 21fbd257..00000000 --- a/internal/features/auth/service/personal.bridge.go +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - "net/http" - - transhttp "github.com/go-kratos/kratos/v2/transport/http" - "github.com/goexts/generic/cmp" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/helpers/resp" -) - -// PersonalServiceHookedBridge is a menu service. -type PersonalServiceHookedBridge struct { - pb.UnimplementedPersonalServiceHooked - client pb.PersonalServiceHTTPServer - log *log.KHelper -} - -//func (p PersonalServiceHookedBridge) PrepareListPersonalResources(ctx transhttp.Context, request *pb.ListPersonalResourcesRequest) (context.Context, error) { -// //TODO implement me -// panic("implement me") -//} - -func (p PersonalServiceHookedBridge) CompleteListPersonalResources(ctx transhttp.Context, request *pb.ListPersonalResourcesRequest, response *pb.ListPersonalResourcesResponse) error { - marshal, err := resp.Proto2JSON(response.Resources...) - if err != nil { - return err - } - return ctx.JSON(http.StatusOK, &resp.Result{ - Success: true, - Data: marshal, - Total: int32(response.TotalSize), - NextPageToken: cmp.If(response.NextPageToken != "", &response.NextPageToken, nil), - }) -} - -func (p PersonalServiceHookedBridge) PrepareGetPersonalProfile(ctx transhttp.Context, request *pb.GetPersonalProfileRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) CompleteGetPersonalProfile(ctx transhttp.Context, request *pb.GetPersonalProfileRequest, response *pb.GetPersonalProfileResponse) error { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) PrepareListPersonalRoles(ctx transhttp.Context, request *pb.ListPersonalRolesRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) CompleteListPersonalRoles(ctx transhttp.Context, request *pb.ListPersonalRolesRequest, response *pb.ListPersonalRolesResponse) error { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) PreparePersonalLogout(ctx transhttp.Context, request *pb.PersonalLogoutRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) CompletePersonalLogout(ctx transhttp.Context, request *pb.PersonalLogoutRequest, response *pb.PersonalLogoutResponse) error { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) PrepareRefreshPersonalToken(ctx transhttp.Context, request *pb.RefreshPersonalTokenRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) CompleteRefreshPersonalToken(ctx transhttp.Context, request *pb.RefreshPersonalTokenRequest, response *pb.RefreshPersonalTokenResponse) error { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) PrepareUpdatePersonalPassword(ctx transhttp.Context, request *pb.UpdatePersonalPasswordRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) CompleteUpdatePersonalPassword(ctx transhttp.Context, request *pb.UpdatePersonalPasswordRequest, response *pb.UpdatePersonalPasswordResponse) error { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) PrepareUpdatePersonalProfile(ctx transhttp.Context, request *pb.UpdatePersonalProfileRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) CompleteUpdatePersonalProfile(ctx transhttp.Context, request *pb.UpdatePersonalProfileRequest, response *pb.UpdatePersonalProfileResponse) error { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) PrepareUpdatePersonalSetting(ctx transhttp.Context, request *pb.UpdatePersonalSettingRequest) (context.Context, error) { - //TODO implement me - panic("implement me") -} - -func (p PersonalServiceHookedBridge) CompleteUpdatePersonalSetting(ctx transhttp.Context, request *pb.UpdatePersonalSettingRequest, response *pb.UpdatePersonalSettingResponse) error { - //TODO implement me - panic("implement me") -} - -func NewPersonalServiceHookedBridge(r runtime.Runtime, client pb.PersonalServiceHTTPServer) pb.PersonalServiceHookedBridger { - return pb.WithPersonalServiceHook(&PersonalServiceHookedBridge{ - log: log.NewHelper(r.WithLogger("module", "service/auth")), - })(client) -} - -// NewPersonalServiceBridge new a menu service. -func NewPersonalServiceBridge(r runtime.Runtime, client *service.GRPCClient) pb.PersonalServiceServer { - return pb.NewPersonalServiceBridge(client) -} - -func NewPersonalServiceBridgeClient(r runtime.Runtime, clients map[string]*service.GRPCClient) pb.PersonalServiceServer { - if c, ok := clients["auth"]; ok { - return pb.NewPersonalServiceBridge(c) - } else { - return pb.UnimplementedPersonalServiceServer{} - } -} - -// NewPersonalServiceHTTPBridge new a menu service. -func NewPersonalServiceHTTPBridge(r runtime.Runtime, client *service.HTTPClient) pb.PersonalServiceHTTPServer { - return pb.NewPersonalServiceHTTPBridge(client) -} - -var _ pb.PersonalServiceHooker = (*PersonalServiceHookedBridge)(nil) diff --git a/internal/features/auth/service/personal.grpc.go b/internal/features/auth/service/personal.grpc.go deleted file mode 100644 index a9b9acd6..00000000 --- a/internal/features/auth/service/personal.grpc.go +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/features/auth/biz" // Corrected import path -) - -// PersonalServiceServer is a login service. -type PersonalServiceServer struct { - pb.UnimplementedPersonalServiceServer - - client *biz.PersonalServiceBiz - log *log.KHelper -} - -func (s PersonalServiceServer) GetPersonalProfile(ctx context.Context, request *pb.GetPersonalProfileRequest) (*pb.GetPersonalProfileResponse, error) { - return s.client.GetPersonalProfile(ctx, request) -} -func (s PersonalServiceServer) PersonalLogout(ctx context.Context, request *pb.PersonalLogoutRequest) (*pb.PersonalLogoutResponse, error) { - return s.client.PersonalLogout(ctx, request) -} - -func (s PersonalServiceServer) UpdatePersonalPassword(ctx context.Context, request *pb.UpdatePersonalPasswordRequest) (*pb.UpdatePersonalPasswordResponse, error) { - return s.client.UpdatePersonalPassword(ctx, request) -} - -func (s PersonalServiceServer) UpdatePersonalProfile(ctx context.Context, request *pb.UpdatePersonalProfileRequest) (*pb.UpdatePersonalProfileResponse, error) { - return s.client.UpdatePersonalProfile(ctx, request) -} - -func (s PersonalServiceServer) ListPersonalResources(ctx context.Context, request *pb.ListPersonalResourcesRequest) (*pb.ListPersonalResourcesResponse, error) { - return s.client.ListPersonalResources(ctx, request) -} - -func (s PersonalServiceServer) ListPersonalRoles(ctx context.Context, request *pb.ListPersonalRolesRequest) (*pb.ListPersonalRolesResponse, error) { - return s.client.ListPersonalRoles(ctx, request) -} - -func (s PersonalServiceServer) UpdatePersonalSetting(ctx context.Context, request *pb.UpdatePersonalSettingRequest) (*pb.UpdatePersonalSettingResponse, error) { - return s.client.UpdatePersonalSetting(ctx, request) -} - -//func (l PersonalServiceServer) mustEmbedUnimplementedPersonalServiceServer() { -// //TODO implement me -// panic("implement me") -//} - -// NewPersonalServiceServer new a login service. -func NewPersonalServiceServer(r runtime.Runtime, client *biz.PersonalServiceBiz) *PersonalServiceServer { - return &PersonalServiceServer{ - log: log.NewHelper(r.WithLogger( - "module", "service/personal", - )), - client: client, - } -} - -// NewPersonalServiceServerPB new a login service. -func NewPersonalServiceServerPB(r runtime.Runtime, client *biz.PersonalServiceBiz) pb.PersonalServiceServer { - return NewPersonalServiceServer(r, client) -} - -var _ pb.PersonalServiceServer = (*PersonalServiceServer)(nil) diff --git a/internal/features/auth/service/personal.http.go b/internal/features/auth/service/personal.http.go deleted file mode 100644 index 7f4ebba7..00000000 --- a/internal/features/auth/service/personal.http.go +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - - pb "origadmin/application/admin/api/v1/services/auth" -) - -// PersonalServiceHTTPServer is a login service. -type PersonalServiceHTTPServer struct { - pb.UnimplementedPersonalServiceServer - - client pb.PersonalServiceHTTPClient -} - -func (s PersonalServiceHTTPServer) GetPersonalProfile(ctx context.Context, request *pb.GetPersonalProfileRequest) (*pb.GetPersonalProfileResponse, error) { - return s.client.GetPersonalProfile(ctx, request) -} - -func (s PersonalServiceHTTPServer) PersonalLogout(ctx context.Context, request *pb.PersonalLogoutRequest) (*pb.PersonalLogoutResponse, error) { - return s.client.PersonalLogout(ctx, request) -} - -func (s PersonalServiceHTTPServer) UpdatePersonalPassword(ctx context.Context, request *pb.UpdatePersonalPasswordRequest) (*pb.UpdatePersonalPasswordResponse, error) { - return s.client.UpdatePersonalPassword(ctx, request) -} - -func (s PersonalServiceHTTPServer) UpdatePersonalProfile(ctx context.Context, request *pb.UpdatePersonalProfileRequest) (*pb.UpdatePersonalProfileResponse, error) { - return s.client.UpdatePersonalProfile(ctx, request) -} - -func (s PersonalServiceHTTPServer) ListPersonalResources(ctx context.Context, request *pb.ListPersonalResourcesRequest) (*pb.ListPersonalResourcesResponse, error) { - return s.client.ListPersonalResources(ctx, request) -} - -func (s PersonalServiceHTTPServer) ListPersonalRoles(ctx context.Context, request *pb.ListPersonalRolesRequest) (*pb.ListPersonalRolesResponse, error) { - return s.client.ListPersonalRoles(ctx, request) -} - -func (s PersonalServiceHTTPServer) UpdatePersonalSetting(ctx context.Context, request *pb.UpdatePersonalSettingRequest) (*pb.UpdatePersonalSettingResponse, error) { - return s.client.UpdatePersonalSetting(ctx, request) -} - -//func (l PersonalServiceHTTPServer) mustEmbedUnimplementedPersonalServiceServer() { -// //TODO implement me -// panic("implement me") -//} - -// NewPersonalServiceHTTPServer new a login service. -func NewPersonalServiceHTTPServer(client pb.PersonalServiceHTTPClient) *PersonalServiceHTTPServer { - return &PersonalServiceHTTPServer{client: client} -} - -// NewPersonalServiceHTTPServerPB new a login service. -func NewPersonalServiceHTTPServerPB(client pb.PersonalServiceHTTPClient) pb.PersonalServiceHTTPServer { - return &PersonalServiceHTTPServer{client: client} -} - -var _ pb.PersonalServiceServer = (*PersonalServiceHTTPServer)(nil) diff --git a/internal/features/auth/service/provider.go b/internal/features/auth/service/provider.go index 6b2a4dad..ed67c455 100644 --- a/internal/features/auth/service/provider.go +++ b/internal/features/auth/service/provider.go @@ -10,38 +10,4 @@ import ( ) // ProviderSet is service providers. -var ProviderSet = wire.NewSet( - NewRegisterServer, - NewAuthServiceServerPB, - NewAuthServiceHTTPServerPB, - NewCasbinSourceServiceServerPB, - NewCasbinSourceServiceHTTPServerPB, - NewLoginServiceServerPB, - NewLoginServiceHTTPServerPB, - NewPersonalServiceServerPB, - NewPersonalServiceHTTPServerPB, - NewCasbinSourceBiz, -) - -// LocalProviderSet is service providers. -var LocalProviderSet = wire.NewSet( - NewRegisterBridgeServer, - NewAuthServiceServerPB, - NewAuthServiceHTTPServerPB, - NewCasbinSourceServiceServerPB, - NewCasbinSourceServiceHTTPServerPB, - NewLoginServiceServerPB, - NewLoginServiceHTTPServerPB, - NewPersonalServiceServerPB, - NewPersonalServiceHTTPServerPB, - NewCasbinSourceBiz, -) - -var RemoteProviderSet = wire.NewSet( - NewRegisterBridgeServer, - NewAuthServiceBridgeClient, - NewCasbinServiceBridgeClient, - NewLoginServiceBridgeClient, - NewPersonalServiceBridgeClient, - NewCasbinSourceClient, -) +var ProviderSet = wire.NewSet(NewAuthService, NewMeService, NewCasbinSourceService) diff --git a/internal/features/auth/service/service.go b/internal/features/auth/service/service.go deleted file mode 100644 index 9bcfac99..00000000 --- a/internal/features/auth/service/service.go +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package service - -import ( - "context" - - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/service" - - pb "origadmin/application/admin/api/v1/services/auth" -) - -type AuthServerRegistrar service.ServerRegistrar - -type RegisterServer struct { - Auth pb.AuthServiceServer - Casbin pb.CasbinSourceServiceServer - Login pb.LoginServiceServer - Personal pb.PersonalServiceServer -} - -func (s RegisterServer) Register(ctx context.Context, svc any) { - switch v := svc.(type) { - case *service.GRPCServer: - s.RegisterGRPC(ctx, v) - case *service.HTTPServer: - s.RegisterHTTP(ctx, v) - } -} - -func (s RegisterServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { - log.Info("grpc server auth init") - pb.RegisterAuthServiceServer(server, s.Auth) - pb.RegisterCasbinSourceServiceServer(server, s.Casbin) - pb.RegisterLoginServiceServer(server, s.Login) - pb.RegisterPersonalServiceServer(server, s.Personal) -} - -func (s RegisterServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { - log.Info("http server auth init") - pb.RegisterAuthServiceHTTPServer(server, s.Auth) - pb.RegisterCasbinSourceServiceHTTPServer(server, s.Casbin) - pb.RegisterLoginServiceHTTPServer(server, s.Login) - pb.RegisterPersonalServiceHTTPServer(server, s.Personal) -} - -func NewRegisterServer( - Auth pb.AuthServiceServer, - Casbin pb.CasbinSourceServiceServer, - Login pb.LoginServiceServer, - Personal pb.PersonalServiceServer, -) AuthServerRegistrar { - return &RegisterServer{ - Auth: Auth, - Casbin: Casbin, - Login: Login, - Personal: Personal, - } -} - -type RegisterBridgeServer struct { - Auth pb.AuthServiceHookedBridger - Casbin pb.CasbinSourceServiceHookedBridger - Login pb.LoginServiceHookedBridger - Personal pb.PersonalServiceHookedBridger -} - -func (s RegisterBridgeServer) Register(ctx context.Context, svc any) { - switch v := svc.(type) { - case *service.GRPCServer: - s.RegisterGRPC(ctx, v) - case *service.HTTPServer: - s.RegisterHTTP(ctx, v) - } -} - -func (s RegisterBridgeServer) RegisterHTTP(ctx context.Context, server *service.HTTPServer) { - log.Info("http server auth init") - pb.RegisterAuthServiceBridgeServer(server, s.Auth) - pb.RegisterCasbinSourceServiceBridgeServer(server, s.Casbin) - pb.RegisterLoginServiceBridgeServer(server, s.Login) - pb.RegisterPersonalServiceBridgeServer(server, s.Personal) -} - -func (s RegisterBridgeServer) RegisterGRPC(ctx context.Context, server *service.GRPCServer) { - log.Info("http server system init") - //pb.RegisterResourceServiceBridgeServer(server, s.Resource) - //pb.RegisterRoleServiceBridgeServer(server, s.Role) - //pb.RegisterUserServiceBridgeServer(server, s.User) - //pb.RegisterPermissionServiceBridgeServer(server, s.Permission) -} - -func NewRegisterBridgeServer(r runtime.Runtime, - Auth pb.AuthServiceServer, - Casbin pb.CasbinSourceServiceServer, - Login pb.LoginServiceServer, - Personal pb.PersonalServiceServer, -) AuthServerRegistrar { - return &RegisterBridgeServer{ - Auth: NewAuthServiceHookedBridge(r, Auth), - Casbin: NewCasbinServiceHookedBridge(r, Casbin), - Login: NewLoginServiceHookedBridge(r, Login), - Personal: NewPersonalServiceHookedBridge(r, Personal), - } -} - -var _ service.ServerRegistrar = (*RegisterServer)(nil) From e35a51d86bd2993ac9b07c406f6dadf3f5f77c52 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 30 Dec 2025 05:34:51 +0800 Subject: [PATCH 105/158] feat(auth): refactor authentication to use JWT authenticator and remove legacy login implementation --- cmd/auth/provider.go | 40 ++- internal/features/auth/dal/login.dal.go | 436 ------------------------ internal/features/auth/service/auth.go | 31 +- 3 files changed, 58 insertions(+), 449 deletions(-) delete mode 100644 internal/features/auth/dal/login.dal.go diff --git a/cmd/auth/provider.go b/cmd/auth/provider.go index 2d7b5b45..0dc4c5e2 100644 --- a/cmd/auth/provider.go +++ b/cmd/auth/provider.go @@ -5,14 +5,48 @@ package main import ( + "errors" + "fmt" + + "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" + "github.com/origadmin/contrib/security/authn" + "github.com/origadmin/contrib/security/authn/jwt" "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/conf" + + authnv1 "github.comcom/origadmin/contrib/api/gen/go/security/authn/v1" + middlewarev1 "github.com/origadmin/runtime/api/gen/go/config/middleware/v1" ) +// provideAuthenticator creates a new JWT authenticator from the application configuration. +func provideAuthenticator(c *conf.Config, logger log.Logger) (authn.Authenticator, error) { + m, err := c.DecodeMiddlewares() + if err != nil { + return nil, fmt.Errorf("failed to decode middlewares config: %w", err) + } + + var jwtMiddleware *middlewarev1.Middleware + for _, mw := range m.GetConfigs() { + if mw.GetType() == "jwt" { + jwtMiddleware = mw + break + } + } + + if jwtMiddleware == nil || jwtMiddleware.GetJwt() == nil { + return nil, errors.New("JWT middleware configuration not found in bootstrap config") + } + + authnConfig := &authnv1.Authenticator{ + Jwt: jwtMiddleware.GetJwt(), + } + + return jwt.NewAuthenticator(authnConfig, log.NewOption(logger)) +} + func provideLogger(app *runtime.App) log.Logger { return app.Logger() } -// infraProviderSet provides basic infrastructure dependencies. -var infraProviderSet = wire.NewSet(provideLogger) +var infraProviderSet = wire.NewSet(provideLogger, provideAuthenticator) diff --git a/internal/features/auth/dal/login.dal.go b/internal/features/auth/dal/login.dal.go deleted file mode 100644 index 585d7403..00000000 --- a/internal/features/auth/dal/login.dal.go +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "bytes" - "fmt" - "sync" - - kerr "github.com/go-kratos/kratos/v2/errors" - - jwtv1 "github.com/origadmin/contrib/api/gen/go/security/authn/jwt/v1" - securityv1 "github.com/origadmin/contrib/api/gen/go/security/v1" - "github.com/origadmin/contrib/security" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/errors" // Changed from httperr - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/rand" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/features/auth/dto" // Corrected import path - authdto "origadmin/application/admin/internal/features/auth/dto" // Corrected import path - "origadmin/application/admin/internal/helpers/captcha" - "origadmin/application/admin/internal/helpers/resp" -) - -type loginRepo struct { - *data.LoginData - *data.Data - captcha *captcha.Captcha - bufpool *sync.Pool -} - -func (repo loginRepo) TokenRefresh(ctx context.Context, in *dto.TokenRefreshRequest) (*dto.TokenRefreshResponse, error) { - log.Debugf("Token refresh request received with data: %+v", in.GetData()) - return repo.refreshToken(ctx, in.GetData().GetRefreshToken()) -} - -func (repo loginRepo) CreateUser(ctx context.Context, userPB *dto.UserPB) (int, error) { - panic("implement me") -} - -func (repo loginRepo) Register(ctx context.Context, in *dto.RegisterRequest) (*dto.RegisterResponse, error) { - log.Debugf("Register request received with data: %+v", in.GetData()) - data := in.GetData() - var err error - createUser := new(dto.UserPB) - createUser, _, err = dto.MakeCreateUser(createUser, data.GetUsername(), data.GetPassword(), dto.UserMutationOption{}) - if err != nil { - return nil, err - } - if _, err := repo.CreateUser(ctx, createUser); err != nil { - return nil, err - } - - return &dto.RegisterResponse{ - Success: true, - Data: &auth.RegisterResponse_Data{ - Redirect: "", - }, - }, nil -} - -func (repo loginRepo) GetUserByUsername(ctx context.Context, username string, fields ...string) (*dto.User, error) { - panic("implement me") -} - -func (repo loginRepo) Login(ctx context.Context, in *dto.LoginRequest) (*dto.LoginResponse, error) { - log.Debugf("Login request received with data: %+v", in.GetData()) - data := in.GetData() - - // verify captcha - log.Debugf("Verifying captcha with id %s and code %s", data.CaptchaId, data.CaptchaCode) - if !repo.captcha.Store.Verify(data.CaptchaId, data.CaptchaCode, true) { - log.Warnf("Invalid captcha id %s or code %s", data.CaptchaId, data.CaptchaCode) - return nil, dto.ErrInvalidCaptchaID - } - - if root := repo.rootUser(); root.GetEnabled() { - log.Debugf("Root userData is enabled, checking if username matches") - // login by root - username := root.Username - if data.Username == username { - log.Debugf("Username matches, checking password") - if err := hash.Verify(root.Password, data.Password); err != nil { - log.Warnf("Invalid password for root userData") - return nil, dto.ErrInvalidPassword - } - - userID := root.Id - ctx = context.NewID(ctx, root.Id) - log.Infof("Login by root successful, userData ID: %s", userID) - return repo.genToken(ctx, userID) - } - } - - // get user info - log.Debugf("Getting userData info for username %s", data.Username) - userData, err := repo.GetUserByUsername(ctx, data.Username, user.FieldID, user.FieldEncryptedPassword, user.FieldStatus) - if err != nil { - log.Errorf("Error getting userData info: %v", err) - return nil, err - } - switch { - case userData == nil: - log.Warnf("User not found with username %s", data.Username) - return nil, dto.ErrInvalidUsername - case userData.Status != authdto.UserStatusActive: - log.Warnf("User %s is not activated", data.Username) - return nil, errors.New(400, "unknown", "User status is not activated, please contact the administrator") // Corrected errors.New usage - default: - log.Debugf("User found with ID %d and status %d", userData.ID, userData.Status) - } - - // check password - log.Debugf("Comparing password for userData %s", data.Username) - if err := hash.Verify(userData.EncryptedPassword, data.Password); err != nil { - log.Warnf("Invalid password for userData %s", data.Username) - return nil, dto.ErrInvalidPassword - } - - userUUID := userData.UUID - username := userData.Username - ctx = context.NewID(ctx, userUUID) - - // set userData cache with role ids - log.Debugf("Getting role IDs for userData %s", username) - roleIDs, err := repo.GetUserRoleIDs(ctx, userData.ID) - if err != nil { - log.Errorf("Error getting role IDs: %v", err) - return nil, kerr.Newf(404, "UNKNOWN", "failed to get userData role ids: %v", err) - } - - log.Infof("User %s logged in successfully with role ids: %v", username, roleIDs) - // generate token - log.Debugf("Generating token for userData %s", username) - return repo.genToken(ctx, userUUID) -} -func (repo loginRepo) CaptchaAudio(ctx context.Context, id string, reload bool) (*dto.CaptchaAudioResponse, error) { - var err error - log.Debugf("Generating captcha audio with id %s and reload %v", id, reload) - if reload && !repo.captcha.Reload(captcha.TypeAudio, id) { - log.Warnf("Captcha id %s not found during reload, regenerating", id) - id, err = repo.getCaptchaID() - if err != nil { - return nil, err - } - } - content := repo.captcha.Store.Get(id, false) - item, err := repo.captcha.DriverAudio.Driver.DrawCaptcha(content) - if err != nil { - return nil, err - } - buf := repo.getBuf() - _, err = item.WriteTo(buf) - if err != nil { - return nil, err - } - response := new(dto.CaptchaAudioResponse) - response.Headers = map[string]string{ - "Cache-Control": "no-cache, no-store, must-revalidate", - "Pragma": "no-cache", - "Expires": "0", - "Content-Type": captcha.MimeTypeAudio, - } - response.Audio = buf.Bytes() - return response, nil -} - -func (repo loginRepo) CaptchaImage(ctx context.Context, id string, reload bool) (*dto.CaptchaImageResponse, error) { - log.Debugf("Generating captcha image with id %s and reload %v", id, reload) - var err error - if reload && !repo.captcha.Reload(captcha.TypeDigit, id) { - log.Warnf("Captcha id %s not found during reload, regenerating", id) - id, err = repo.getCaptchaID() - if err != nil { - return nil, err - } - } - content := repo.captcha.Store.Get(id, false) - item, err := repo.captcha.DriverDigit.Driver.DrawCaptcha(content) - if err != nil { - return nil, err - } - buf := repo.getBuf() - _, err = item.WriteTo(buf) - if err != nil { - return nil, err - } - log.Debugf("Captcha image generated successfully") - response := new(dto.CaptchaImageResponse) - response.Headers = map[string]string{ - "Cache-Control": "no-cache, no-store, must-revalidate", - "Pragma": "no-cache", - "Expires": "0", - "Content-Type": captcha.MimeTypeImage, - } - response.Image = buf.Bytes() - log.Debugf("Returning captcha image response with headers: %+v", response.Headers) - return response, nil -} - -func (repo loginRepo) CurrentUser(ctx context.Context, in *dto.CurrentUserRequest) (*dto.CurrentUserResponse, error) { - current, err := repo.User(ctx).Get(ctx, in.GetData().GetUserId()) - if err != nil { - return nil, err - } - return &dto.CurrentUserResponse{ - Data: resp.Any(current), - }, nil -} - -func (repo loginRepo) Logout(ctx context.Context, in *dto.LogoutRequest) (*dto.LogoutResponse, error) { - return &dto.LogoutResponse{}, nil -} - -func (repo loginRepo) CaptchaID(ctx context.Context, in *dto.CaptchaIDRequest) (*dto.CaptchaIDResponse, error) { - id, err := repo.getCaptchaID() - if err != nil { - return nil, err - } - return &dto.CaptchaIDResponse{ - Data: id, - }, nil -} - -func (repo loginRepo) Captcha(ctx context.Context, in *dto.CaptchaRequest) (*dto.CaptchaResponse, error) { - var err error - var id = in.Id - if id == "" { - id, err = repo.getCaptchaID() - if err != nil { - return nil, err - } - } - driver, err := repo.getCaptchaDriver(in.Type) - if err != nil { - return nil, err - } - if in.Reload && in.Id != "" && !repo.captcha.Reload(in.Type, in.Id) { - log.Warnf("Captcha id %s not found during reload, regenerating id", id) - id, err = repo.getCaptchaID() - if err != nil { - return nil, err - } - } - data, err := repo.getCaptchaData(driver, id) - if err != nil { - return nil, err - } - return &dto.CaptchaResponse{ - Id: id, - Type: in.Type, - Data: data, - }, nil -} - -func (repo loginRepo) getCaptchaID() (string, error) { - id, _, answ, err := repo.captcha.DriverDigit.Generate() - if err != nil { - return "", err - } - log.Debugf("Generated captcha with id %s and answer %s", id, answ) - return id, nil -} - -func (repo loginRepo) FreeBuf(buf *bytes.Buffer) { - repo.putBuf(buf) -} - -func (repo loginRepo) getBuf() *bytes.Buffer { - return repo.bufpool.Get().(*bytes.Buffer) -} - -func (repo loginRepo) putBuf(buf *bytes.Buffer) { - buf.Reset() - repo.bufpool.Put(buf) -} - -func (repo loginRepo) refreshToken(ctx context.Context, token string) (*dto.TokenRefreshResponse, error) { - claims, err := repo.Tokenizer.ParseClaims(ctx, token) - if err != nil { - return nil, err - } - genToken, err := repo.genToken(ctx, claims.GetSubject()) - if err != nil { - return nil, err - } - return &dto.TokenRefreshResponse{ - Token: genToken.Token, - }, nil -} - -func (repo loginRepo) genToken(ctx context.Context, id string) (*dto.LoginResponse, error) { - claims, err := repo.Tokenizer.CreateClaims(ctx, id) - if err != nil { - return nil, err - } - token, err := repo.Tokenizer.CreateToken(ctx, claims) - if err != nil { - return nil, err - } - refreshClaims, err := repo.Tokenizer.CreateRefreshClaims(ctx, id) - if err != nil { - return nil, err - } - refreshToken, err := repo.Tokenizer.CreateToken(ctx, refreshClaims) - if err != nil { - return nil, err - } - return &dto.LoginResponse{ - Token: &jwtv1.Token{ - UserId: id, - AccessToken: token, - RefreshToken: refreshToken, - ExpirationTime: claims.GetExpiration(), - }, - }, nil -} - -func fromSecurityClaims(claims security.Claims) *securityv1.Claims { - return &securityv1.Claims{ - Sub: claims.GetSubject(), - Iss: claims.GetIssuer(), - Aud: claims.GetAudience(), - Exp: claims.GetExpiration(), - Nbf: claims.GetNotBefore(), - Iat: claims.GetIssuedAt(), - Jti: claims.GetID(), - Scopes: claims.GetScopes(), - } -} - -func (repo loginRepo) rootUser() *configs.RootUser { - return repo.LoginData.RootUser -} - -func (repo loginRepo) getCaptchaDriver(typ string) (captcha.Driver, error) { - var driver captcha.Driver - switch typ { - case captcha.TypeAudio: - driver = repo.captcha.DriverAudio.Driver - default: - driver = repo.captcha.DriverDigit.Driver - } - log.Debugf("Captcha audio generated successfully") - return driver, nil -} - -func (repo loginRepo) getCaptchaData(driver captcha.Driver, id string) (string, error) { - content := repo.captcha.Store.Get(id, false) - item, err := driver.DrawCaptcha(content) - if err != nil { - return "", err - } - return item.EncodeB64string(), nil -} - -func (repo loginRepo) getCaptchaAudio(id string) (string, error) { - log.Debugf("Writing captcha audio to buffer with id %s", id) - content := repo.captcha.Store.Get(id, false) - item, err := repo.captcha.DriverAudio.Driver.DrawCaptcha(content) - if err != nil { - return "", err - } - log.Debugf("Captcha audio generated successfully") - return item.EncodeB64string(), nil -} - -func (repo loginRepo) getCaptchaImage(id string) (string, error) { - log.Debugf("Writing captcha image to buffer with id %s", id) - content := repo.captcha.Store.Get(id, false) - item, err := repo.captcha.DriverDigit.Driver.DrawCaptcha(content) - if err != nil { - return "", err - } - log.Debugf("Captcha image generated successfully") - return item.EncodeB64string(), nil -} - -func (repo loginRepo) GetUserRoleIDs(ctx context.Context, id int64) ([]string, error) { - panic("implement me") -} - -func NewCaptcha(cfg *configs.Captcha) *captcha.Captcha { - return captcha.NewCaptcha(&captcha.Config{ - DriverDigit: &captcha.DriverDigit{ - Height: int(cfg.Height), - Width: int(cfg.Width), - Length: int(cfg.Length), - MaxSkew: 0.7, - DotCount: 120, - }, - }) -} - -// NewLoginRepo . -func NewLoginRepo(dd *data.Data, ld *data.LoginData) dto.LoginRepo { - var err error - cfg := ld.RootUser - // todo: generate random password for root user if not exists - if cfg.RandomPassword { - passwd := rand.GenerateRandom(12) - cfg.Password, err = hash.Generate(passwd) - if err == nil { - fmt.Println("Root user password:", passwd) - } else { - log.Errorf("Error generating password: %v", err) - cfg.RandomPassword = false - } - } - if cfg.Id == "" { - cfg.Id = cfg.Username - } - //authenticator, err := jwt.NewAuthenticator(&configv1.Security{}) - //if err != nil { - // panic(err) - //} - return &loginRepo{ - Data: dd, - bufpool: BufPool(), - LoginData: ld, - captcha: NewCaptcha(ld.Captcha), - } -} - -func BufPool() *sync.Pool { - return &sync.Pool{ - New: func() interface{} { - return &bytes.Buffer{} - }, - } -} diff --git a/internal/features/auth/service/auth.go b/internal/features/auth/service/auth.go index 8b786353..ff9f71e7 100644 --- a/internal/features/auth/service/auth.go +++ b/internal/features/auth/service/auth.go @@ -2,24 +2,27 @@ package service import ( "context" + "fmt" "google.golang.org/protobuf/types/known/emptypb" + securityv1 "github.com/origadmin/contrib/api/gen/go/security/v1" + "github.com/origadmin/contrib/security/authn/jwt" + securityPrincipal "github.com/origadmin/contrib/security/principal" v1 "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/features/auth/biz" - "origadmin/application/admin/internal/pkg/token" ) // AuthService is a service for authentication. type AuthService struct { v1.UnimplementedAuthServer - uc *biz.AuthUseCase - tm token.Manager + uc *biz.AuthUseCase + authn *jwt.Authenticator } // NewAuthService creates a new authentication service. -func NewAuthService(uc *biz.AuthUseCase, tm token.Manager) *AuthService { - return &AuthService{uc: uc, tm: tm} +func NewAuthService(uc *biz.AuthUseCase, authn *jwt.Authenticator) *AuthService { + return &AuthService{uc: uc, authn: authn} } // Login authenticates a user and returns a token pair. @@ -29,15 +32,23 @@ func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.Logi return nil, err } - accessToken, refreshToken, err := s.tm.Generate(ctx, userID) + // Create a principal for the user. + p := securityPrincipal.New(fmt.Sprint(userID)) + + // Create a credential (which contains the token). + credResp, err := s.authn.CreateCredential(ctx, p) if err != nil { return nil, err } - + token := credResp.Response().GetPayload().GetToken() + if token == nil { + return nil, securityv1.ErrorTokenInvalid("token is missing") + } return &v1.LoginResponse{ - AccessToken: accessToken, - RefreshToken: refreshToken, - TokenType: "Bearer", + AccessToken: token.GetAccessToken(), + RefreshToken: token.GetRefreshToken(), + TokenType: token.GetTokenType(), + ExpiresIn: token.GetExpiresIn(), }, nil } From d99aa9da9ca4846f7eaa3a808486344fedc9a19a Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 30 Dec 2025 05:45:38 +0800 Subject: [PATCH 106/158] feat(auth): refactor authentication system with credential creator, hasher and captcha support --- cmd/auth/provider.go | 25 +++++++++++++---- internal/data/data.go | 28 +++++++++++++++---- internal/features/auth/biz/auth.go | 19 ++++++------- internal/features/auth/biz/provider.go | 2 +- internal/features/auth/dal/provider.go | 2 +- internal/features/auth/dto/captcha.go | 9 +++++++ internal/features/auth/service/auth.go | 37 +++++++++++++++++--------- 7 files changed, 88 insertions(+), 34 deletions(-) create mode 100644 internal/features/auth/dto/captcha.go diff --git a/cmd/auth/provider.go b/cmd/auth/provider.go index 0dc4c5e2..91fe1017 100644 --- a/cmd/auth/provider.go +++ b/cmd/auth/provider.go @@ -10,17 +10,23 @@ import ( "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" - "github.com/origadmin/contrib/security/authn" "github.com/origadmin/contrib/security/authn/jwt" + "github.com/origadmin/contrib/security/credential" "github.com/origadmin/runtime" + "github.com/origadmin/toolkits/crypto/hash" + "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" + hash_types "github.com/origadmin/toolkits/crypto/hash/types" "origadmin/application/admin/internal/conf" + confpb "origadmin/application/admin/internal/conf/pb" - authnv1 "github.comcom/origadmin/contrib/api/gen/go/security/authn/v1" + authnv1 "github.com/origadmin/contrib/api/gen/go/security/authn/v1" middlewarev1 "github.com/origadmin/runtime/api/gen/go/config/middleware/v1" ) -// provideAuthenticator creates a new JWT authenticator from the application configuration. -func provideAuthenticator(c *conf.Config, logger log.Logger) (authn.Authenticator, error) { +// provideCredentialCreator creates a credential creator from the application configuration. +// It finds the JWT middleware config and uses it to initialize a jwt.Authenticator, +// which implements the credential.Creator interface. +func provideCredentialCreator(c *conf.Config, logger log.Logger) (credential.Creator, error) { m, err := c.DecodeMiddlewares() if err != nil { return nil, fmt.Errorf("failed to decode middlewares config: %w", err) @@ -42,11 +48,20 @@ func provideAuthenticator(c *conf.Config, logger log.Logger) (authn.Authenticato Jwt: jwtMiddleware.GetJwt(), } + // jwt.NewAuthenticator returns a *jwt.Authenticator which implements credential.Creator return jwt.NewAuthenticator(authnConfig, log.NewOption(logger)) } +func provideCaptchaConfig(c *conf.Config) (*confpb.Captcha, error) { + return c.GetCaptcha() +} + +func provideHasher() (hash.Crypto, error) { + return hash.NewCrypto(hash_types.BCRYPT, bcrypt.WithCost(bcrypt.DefaultCost)) +} + func provideLogger(app *runtime.App) log.Logger { return app.Logger() } -var infraProviderSet = wire.NewSet(provideLogger, provideAuthenticator) +var infraProviderSet = wire.NewSet(provideLogger, provideCredentialCreator, provideCaptchaConfig, provideHasher) diff --git a/internal/data/data.go b/internal/data/data.go index 1b138282..5d90251e 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -10,6 +10,7 @@ import ( entsql "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/schema" + "github.com/go-redis/redis/v8" "github.com/google/wire" "github.com/origadmin/runtime" @@ -20,13 +21,12 @@ import ( ) // ProviderSet is data providers. -var ProviderSet = wire.NewSet(NewData, ProvideDatabase) +var ProviderSet = wire.NewSet(NewData, ProvideDatabase, ProvideCache) // Data encapsulates the core data access components. -// It holds the ent.Database object for database operations and can be extended -// to hold other components like cache clients. type Data struct { DB *ent.Database + RDB *redis.Client log *log.Helper } @@ -35,7 +35,12 @@ func ProvideDatabase(d *Data) *ent.Database { return d.DB } -// NewData creates a new Data instance, which encapsulates the core database object. +// ProvideCache extracts and provides the *redis.Client from the *Data object. +func ProvideCache(d *Data) *redis.Client { + return d.RDB +} + +// NewData creates a new Data instance, which encapsulates the core database and cache objects. func NewData(rt *runtime.App, conf *conf.Config) (*Data, func(), error) { logHelper := log.NewHelper(rt.Logger()) @@ -44,11 +49,11 @@ func NewData(rt *runtime.App, conf *conf.Config) (*Data, func(), error) { return nil, nil, err } + // --- Database --- db, err := provider.DefaultDatabase() if err != nil { return nil, nil, err } - activeDB := entsql.OpenDB(db.Dialect(), db.DB()) database := ent.NewDatabase(ent.Driver(activeDB)) @@ -61,8 +66,16 @@ func NewData(rt *runtime.App, conf *conf.Config) (*Data, func(), error) { logHelper.Fatalf("failed creating schema resources: %v", err) } + // --- Cache --- + cache, err := provider.DefaultCache() + if err != nil { + return nil, nil, err + } + rdb := cache.Redis() + d := &Data{ DB: database, + RDB: rdb, log: logHelper, } @@ -78,6 +91,11 @@ func NewData(rt *runtime.App, conf *conf.Config) (*Data, func(), error) { logHelper.Errorf("failed to close database: %v", err) } } + if d.RDB != nil { + if err := d.RDB.Close(); err != nil { + logHelper.Errorf("failed to close redis client: %v", err) + } + } } return d, cleanup, nil } diff --git a/internal/features/auth/biz/auth.go b/internal/features/auth/biz/auth.go index 2bf4406f..fdcbde57 100644 --- a/internal/features/auth/biz/auth.go +++ b/internal/features/auth/biz/auth.go @@ -5,22 +5,24 @@ import ( "errors" "github.com/go-kratos/kratos/v2/log" - "golang.org/x/crypto/bcrypt" + "github.com/origadmin/toolkits/crypto/hash" "origadmin/application/admin/internal/features/auth/dto" ) // AuthUseCase is a authentication use case. type AuthUseCase struct { - repo dto.AuthRepo - log *log.Helper + repo dto.AuthRepo + hasher hash.Crypto + log *log.Helper } // NewAuthUseCase new a authentication use case. -func NewAuthUseCase(repo dto.AuthRepo, logger log.Logger) *AuthUseCase { +func NewAuthUseCase(repo dto.AuthRepo, hasher hash.Crypto, logger log.Logger) *AuthUseCase { return &AuthUseCase{ - repo: repo, - log: log.NewHelper(logger), + repo: repo, + hasher: hasher, + log: log.NewHelper(logger), } } @@ -32,9 +34,8 @@ func (uc *AuthUseCase) VerifyUser(ctx context.Context, username, password string } // Compare the provided password with the stored hash. - err = bcrypt.CompareHashAndPassword([]byte(user.EncryptedPassword), []byte(password)) - if err != nil { - // If the passwords don't match, return a generic error. + ok, err := uc.hasher.Compare(user.EncryptedPassword, password) + if err != nil || !ok { return 0, errors.New("invalid username or password") } diff --git a/internal/features/auth/biz/provider.go b/internal/features/auth/biz/provider.go index 57be91be..79062b67 100644 --- a/internal/features/auth/biz/provider.go +++ b/internal/features/auth/biz/provider.go @@ -3,4 +3,4 @@ package biz import "github.com/google/wire" // ProviderSet is biz providers. -var ProviderSet = wire.NewSet(NewAuthUseCase, NewMeUseCase) +var ProviderSet = wire.NewSet(NewAuthUseCase, NewMeUseCase, NewCaptchaUseCase) diff --git a/internal/features/auth/dal/provider.go b/internal/features/auth/dal/provider.go index 1178287d..d7835cd4 100644 --- a/internal/features/auth/dal/provider.go +++ b/internal/features/auth/dal/provider.go @@ -3,4 +3,4 @@ package dal import "github.com/google/wire" // ProviderSet is dal providers. -var ProviderSet = wire.NewSet(NewAuthRepo, NewMeRepo) +var ProviderSet = wire.NewSet(NewAuthRepo, NewMeRepo, NewCaptchaRepo) diff --git a/internal/features/auth/dto/captcha.go b/internal/features/auth/dto/captcha.go new file mode 100644 index 00000000..4cd89ac7 --- /dev/null +++ b/internal/features/auth/dto/captcha.go @@ -0,0 +1,9 @@ +package dto + +import "github.com/mojocn/base64Captcha" + +// CaptchaRepo defines the data access methods for captcha. +// It embeds the base64Captcha.Store interface. +type CaptchaRepo interface { + base64Captcha.Store +} diff --git a/internal/features/auth/service/auth.go b/internal/features/auth/service/auth.go index ff9f71e7..68fc441e 100644 --- a/internal/features/auth/service/auth.go +++ b/internal/features/auth/service/auth.go @@ -6,23 +6,24 @@ import ( "google.golang.org/protobuf/types/known/emptypb" + v1 "origadmin/application/admin/api/v1/services/auth" securityv1 "github.com/origadmin/contrib/api/gen/go/security/v1" - "github.com/origadmin/contrib/security/authn/jwt" + "github.com/origadmin/contrib/security/credential" securityPrincipal "github.com/origadmin/contrib/security/principal" - v1 "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/features/auth/biz" ) // AuthService is a service for authentication. type AuthService struct { v1.UnimplementedAuthServer - uc *biz.AuthUseCase - authn *jwt.Authenticator + uc *biz.AuthUseCase + captchaUC *biz.CaptchaUseCase + creator credential.Creator } // NewAuthService creates a new authentication service. -func NewAuthService(uc *biz.AuthUseCase, authn *jwt.Authenticator) *AuthService { - return &AuthService{uc: uc, authn: authn} +func NewAuthService(uc *biz.AuthUseCase, captchaUC *biz.CaptchaUseCase, creator credential.Creator) *AuthService { + return &AuthService{uc: uc, captchaUC: captchaUC, creator: creator} } // Login authenticates a user and returns a token pair. @@ -36,14 +37,16 @@ func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.Logi p := securityPrincipal.New(fmt.Sprint(userID)) // Create a credential (which contains the token). - credResp, err := s.authn.CreateCredential(ctx, p) + credResp, err := s.creator.CreateCredential(ctx, p) if err != nil { return nil, err } - token := credResp.Response().GetPayload().GetToken() + + token := credResp.Payload().GetToken() if token == nil { return nil, securityv1.ErrorTokenInvalid("token is missing") } + return &v1.LoginResponse{ AccessToken: token.GetAccessToken(), RefreshToken: token.GetRefreshToken(), @@ -52,6 +55,18 @@ func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.Logi }, nil } +// GetCaptcha generates a new captcha. +func (s *AuthService) GetCaptcha(ctx context.Context, req *v1.GetCaptchaRequest) (*v1.GetCaptchaResponse, error) { + id, b64s, err := s.captchaUC.GenerateCaptcha(ctx) + if err != nil { + return nil, err + } + return &v1.GetCaptchaResponse{ + CaptchaId: id, + CaptchaImage: b64s, + }, nil +} + // Register creates a new user account. func (s *AuthService) Register(ctx context.Context, req *v1.RegisterRequest) (*emptypb.Empty, error) { return &emptypb.Empty{}, nil @@ -67,12 +82,8 @@ func (s *AuthService) RefreshToken(ctx context.Context, req *v1.RefreshTokenRequ return &v1.RefreshTokenResponse{}, nil } -// GetCaptcha generates a new captcha. -func (s *AuthService) GetCaptcha(ctx context.Context, req *v1.GetCaptchaRequest) (*v1.GetCaptchaResponse, error) { - return &v1.GetCaptchaResponse{}, nil -} - // Authenticate is for internal use by the gateway to verify user access via gRPC. func (s *AuthService) Authenticate(ctx context.Context, req *v1.AuthenticateRequest) (*v1.AuthenticateResponse, error) { + // This should be implemented using an authn.Authenticator, which can be a separate dependency. return &v1.AuthenticateResponse{}, nil } From 14c55a60e55f6e3254c749b0542eb749a2e34631 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 30 Dec 2025 20:35:29 +0800 Subject: [PATCH 107/158] refactor(proto): rename services and add response messages for auth endpoints --- Makefile | 6 +- api/v1/proto/auth/auth.proto | 15 ++- api/v1/proto/auth/me.proto | 22 +++- api/v1/proto/datastore/datastore.proto | 1 - api/v1/proto/datastore/upload.proto | 7 +- api/v1/proto/types/message.proto | 2 - cmd/auth/provider.go | 67 ----------- cmd/auth/wire.go | 14 ++- cmd/auth/wire_gen.go | 81 ++++++++----- cmd/system/provider.go | 25 ---- cmd/system/wire.go | 9 +- cmd/system/wire_gen.go | 12 +- go.mod | 83 ++++++++----- go.sum | 126 ++++++++++++++++++++ internal/conf/pb/captcha.pb.go | 50 ++++---- internal/conf/pb/captcha.pb.validate.go | 33 +---- internal/conf/pb/captcha.proto | 9 +- internal/conf/pb/conf.pb.go | 63 ++++++---- internal/conf/pb/conf.pb.validate.go | 29 +++++ internal/conf/pb/conf.proto | 10 +- internal/data/data.go | 79 +++++------- internal/features/auth/biz/biz.go | 2 +- internal/features/auth/biz/captcha.go | 40 +++++++ internal/features/auth/biz/casbin.biz.go | 4 +- internal/features/auth/biz/provider.go | 2 +- internal/features/auth/dal/captcha.go | 74 ++++++++++++ internal/features/auth/dal/dal.go | 7 +- internal/features/auth/service/auth.go | 21 ++-- internal/features/auth/service/provider.go | 9 +- internal/features/system/biz/provider.go | 1 - internal/features/system/dal/role.go | 4 +- internal/features/system/server/server.go | 2 - internal/features/system/service/service.go | 4 - internal/helpers/captcha/cache.go | 63 ++++++++++ internal/helpers/captcha/captcha.go | 33 +---- internal/helpers/providers/providers.go | 102 ++++++++++++++++ test/token_test.go | 26 ++-- 37 files changed, 739 insertions(+), 398 deletions(-) delete mode 100644 cmd/auth/provider.go delete mode 100644 cmd/system/provider.go create mode 100644 internal/features/auth/biz/captcha.go create mode 100644 internal/features/auth/dal/captcha.go create mode 100644 internal/helpers/captcha/cache.go create mode 100644 internal/helpers/providers/providers.go diff --git a/Makefile b/Makefile index 90393f2e..088cc8c0 100644 --- a/Makefile +++ b/Makefile @@ -155,11 +155,11 @@ gen: buf build buf generate - @echo "Generating Protobuf code for helpers/resp/data/v1..." - @protoc -I. -I./third_party --go_out=paths=source_relative:. ./helpers/resp/data/v1/*.proto + @#echo "Generating Protobuf code for helpers/resp/data/v1..." + @#protoc -I. -I./third_party --go_out=paths=source_relative:. ./helpers/resp/data/v1/*.proto @echo "Generating Protobuf code for conf/pb..." - @protoc -I. -I./third_party --go_out=paths=source_relative:./internal --validate_out=paths=source_relative,lang=go:./internal ./internal/conf/pb/*.proto + @protoc -I. -I./third_party --go_out=paths=source_relative:. --validate_out=paths=source_relative,lang=go:. ./internal/conf/pb/*.proto go generate ./internal/data/entity/ent/generate.go go generate ./cmd/system diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index dbd53da4..36f1560d 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -3,15 +3,14 @@ syntax = "proto3"; package api.v1.services.auth; import "google/api/annotations.proto"; -import "google/protobuf/empty.proto"; option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; option java_package = "com.origadmin.api.v1.services.auth"; option java_outer_classname = "APIServiceAuthProto"; -// Service Auth provides APIs for the authentication lifecycle. -service Auth { +// Service AuthService provides APIs for the authentication lifecycle. +service AuthService { // --- Authentication --- // Login authenticates a user and returns a token pair. @@ -23,7 +22,7 @@ service Auth { } // Register creates a new user account. - rpc Register(RegisterRequest) returns (google.protobuf.Empty) { + rpc Register(RegisterRequest) returns (RegisterResponse) { option (google.api.http) = { post: "/api/v1/auth/register" body: "*" @@ -31,7 +30,7 @@ service Auth { } // Logout invalidates the user's session. - rpc Logout(LogoutRequest) returns (google.protobuf.Empty) { + rpc Logout(LogoutRequest) returns (LogoutResponse) { option (google.api.http) = { post: "/api/v1/auth/logout" body: "*" @@ -89,11 +88,17 @@ message RegisterRequest { string captcha_code = 5; } +// The response message for the Register RPC. +message RegisterResponse {} + // The request message for the Logout RPC. message LogoutRequest { string refresh_token = 1; } +// The response message for the Logout RPC. +message LogoutResponse {} + // The request message for the RefreshToken RPC. message RefreshTokenRequest { string refresh_token = 1; diff --git a/api/v1/proto/auth/me.proto b/api/v1/proto/auth/me.proto index ba538be4..dc4dff9b 100644 --- a/api/v1/proto/auth/me.proto +++ b/api/v1/proto/auth/me.proto @@ -3,7 +3,6 @@ syntax = "proto3"; package api.v1.services.auth; import "google/api/annotations.proto"; -import "google/protobuf/empty.proto"; import "types/system.proto"; option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; @@ -11,17 +10,17 @@ option java_multiple_files = true; option java_package = "com.origadmin.api.v1.services.auth"; option java_outer_classname = "APIServiceMeProto"; -// Service Me provides APIs for the currently authenticated user to manage their own profile and data. -service Me { +// Service MeService provides APIs for the currently authenticated user to manage their own profile and data. +service MeService { // GetProfile retrieves the profile of the currently authenticated user. - rpc GetProfile(GetProfileRequest) returns (api.v1.services.types.User) { + rpc GetProfile(GetProfileRequest) returns (GetProfileResponse) { option (google.api.http) = { get: "/api/v1/me/profile" }; } // UpdateProfile updates the profile of the currently authenticated user. - rpc UpdateProfile(UpdateProfileRequest) returns (google.protobuf.Empty) { + rpc UpdateProfile(UpdateProfileRequest) returns (UpdateProfileResponse) { option (google.api.http) = { put: "/api/v1/me/profile" body: "*" @@ -29,7 +28,7 @@ service Me { } // UpdatePassword changes the password for the currently authenticated user. - rpc UpdatePassword(UpdatePasswordRequest) returns (google.protobuf.Empty) { + rpc UpdatePassword(UpdatePasswordRequest) returns (UpdatePasswordResponse) { option (google.api.http) = { put: "/api/v1/me/password" body: "*" @@ -54,18 +53,29 @@ service Me { // The request message for the GetProfile RPC. message GetProfileRequest {} +// The response message for the GetProfile RPC. +message GetProfileResponse { + api.v1.services.types.User user = 1; +} + // The request message for the UpdateProfile RPC. message UpdateProfileRequest { // The fields to update. api.v1.services.types.User user = 1; } +// The response message for the UpdateProfile RPC. +message UpdateProfileResponse {} + // The request message for the UpdatePassword RPC. message UpdatePasswordRequest { string old_password = 1; string new_password = 2; } +// The response message for the UpdatePassword RPC. +message UpdatePasswordResponse {} + // The request message for the GetUserResources RPC. message GetUserResourcesRequest {} diff --git a/api/v1/proto/datastore/datastore.proto b/api/v1/proto/datastore/datastore.proto index 01ae6faf..d79676a1 100644 --- a/api/v1/proto/datastore/datastore.proto +++ b/api/v1/proto/datastore/datastore.proto @@ -6,7 +6,6 @@ import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/datastore.proto"; -import "validate/validate.proto"; option go_package = "origadmin/application/admin/api/v1/services/datastore;datastore"; option java_multiple_files = true; diff --git a/api/v1/proto/datastore/upload.proto b/api/v1/proto/datastore/upload.proto index 3f37a2d5..38e649e3 100644 --- a/api/v1/proto/datastore/upload.proto +++ b/api/v1/proto/datastore/upload.proto @@ -1,17 +1,16 @@ syntax = "proto3"; -package api.v1.services.upload; +package api.v1.services.datastore; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/datastore.proto"; -import "validate/validate.proto"; -option go_package = "origadmin/application/admin/api/v1/services/upload;upload"; +option go_package = "origadmin/application/admin/api/v1/services/datastore;datastore"; option java_multiple_files = true; option java_outer_classname = "APIV1ServicesUploadProto"; -option java_package = "com.origadmin.api.v1.services.upload"; +option java_package = "com.origadmin.api.v1.services.datastore"; // The data service definition. service UploadService { diff --git a/api/v1/proto/types/message.proto b/api/v1/proto/types/message.proto index f784d7e3..af30dd2c 100644 --- a/api/v1/proto/types/message.proto +++ b/api/v1/proto/types/message.proto @@ -2,8 +2,6 @@ syntax = "proto3"; package api.v1.services.types; -import "google/protobuf/timestamp.proto"; - option go_package = "origadmin/application/admin/api/v1/services/types;types"; option java_multiple_files = true; option java_outer_classname = "APIServiceTypeMessageProto"; diff --git a/cmd/auth/provider.go b/cmd/auth/provider.go deleted file mode 100644 index 91fe1017..00000000 --- a/cmd/auth/provider.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package main - -import ( - "errors" - "fmt" - - "github.com/go-kratos/kratos/v2/log" - "github.com/google/wire" - "github.com/origadmin/contrib/security/authn/jwt" - "github.com/origadmin/contrib/security/credential" - "github.com/origadmin/runtime" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" - hash_types "github.com/origadmin/toolkits/crypto/hash/types" - "origadmin/application/admin/internal/conf" - confpb "origadmin/application/admin/internal/conf/pb" - - authnv1 "github.com/origadmin/contrib/api/gen/go/security/authn/v1" - middlewarev1 "github.com/origadmin/runtime/api/gen/go/config/middleware/v1" -) - -// provideCredentialCreator creates a credential creator from the application configuration. -// It finds the JWT middleware config and uses it to initialize a jwt.Authenticator, -// which implements the credential.Creator interface. -func provideCredentialCreator(c *conf.Config, logger log.Logger) (credential.Creator, error) { - m, err := c.DecodeMiddlewares() - if err != nil { - return nil, fmt.Errorf("failed to decode middlewares config: %w", err) - } - - var jwtMiddleware *middlewarev1.Middleware - for _, mw := range m.GetConfigs() { - if mw.GetType() == "jwt" { - jwtMiddleware = mw - break - } - } - - if jwtMiddleware == nil || jwtMiddleware.GetJwt() == nil { - return nil, errors.New("JWT middleware configuration not found in bootstrap config") - } - - authnConfig := &authnv1.Authenticator{ - Jwt: jwtMiddleware.GetJwt(), - } - - // jwt.NewAuthenticator returns a *jwt.Authenticator which implements credential.Creator - return jwt.NewAuthenticator(authnConfig, log.NewOption(logger)) -} - -func provideCaptchaConfig(c *conf.Config) (*confpb.Captcha, error) { - return c.GetCaptcha() -} - -func provideHasher() (hash.Crypto, error) { - return hash.NewCrypto(hash_types.BCRYPT, bcrypt.WithCost(bcrypt.DefaultCost)) -} - -func provideLogger(app *runtime.App) log.Logger { - return app.Logger() -} - -var infraProviderSet = wire.NewSet(provideLogger, provideCredentialCreator, provideCaptchaConfig, provideHasher) diff --git a/cmd/auth/wire.go b/cmd/auth/wire.go index 6d6e5165..11557439 100644 --- a/cmd/auth/wire.go +++ b/cmd/auth/wire.go @@ -15,20 +15,24 @@ import ( "origadmin/application/admin/internal/features/auth/dal" "origadmin/application/admin/internal/features/auth/server" "origadmin/application/admin/internal/features/auth/service" - "origadmin/application/admin/internal/pkg/token" + "origadmin/application/admin/internal/helpers/providers" ) // wireApp init kratos application. func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { panic(wire.Build( - // The injector function's parameter `app` is an implicit provider for *runtime.App. - infraProviderSet, + // Shared infrastructure providers + providers.ProviderSet, + + // Instructions for wire to extract nested configs wire.FieldsOf(new(*conf.Config), "Bootstrap"), wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), - data.ProviderSet, // This was the missing piece + wire.FieldsOf(new(*confpb.Bootstrap), "Captcha"), + + // Service-specific providers + data.ProviderSet, dal.ProviderSet, biz.ProviderSet, - token.ProviderSet, service.ProviderSet, server.ProviderSet, NewApp, diff --git a/cmd/auth/wire_gen.go b/cmd/auth/wire_gen.go index 33a6d386..e4c11582 100644 --- a/cmd/auth/wire_gen.go +++ b/cmd/auth/wire_gen.go @@ -9,56 +9,77 @@ package main import ( "github.com/go-kratos/kratos/v2" "github.com/origadmin/runtime" - "origadmin/application/admin/internal/configs" + "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/features/auth/biz" // Corrected import path - "origadmin/application/admin/internal/features/auth/dal" // Corrected import path - "origadmin/application/admin/internal/features/auth/server" // Corrected import path - "origadmin/application/admin/internal/features/auth/service" // Corrected import path + "origadmin/application/admin/internal/features/auth/biz" + "origadmin/application/admin/internal/features/auth/dal" + "origadmin/application/admin/internal/features/auth/server" + "origadmin/application/admin/internal/features/auth/service" + "origadmin/application/admin/internal/helpers/providers" ) import ( - _ "origadmin/application/admin/contrib/consul/config" - _ "origadmin/application/admin/contrib/consul/registry" - _ "origadmin/application/admin/contrib/database" + _ "github.com/origadmin/contrib/config/consul" + _ "github.com/origadmin/contrib/registry/consul" + _ "github.com/sqlite3ent/sqlite3" _ "origadmin/application/admin/internal/data/entity/ent/runtime" ) // Injectors from wire.go: -// buildInjectors init kratos application. -func buildInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { - dataData, cleanup, err := data.NewData(r, bootstrap) +// wireApp init kratos application. +func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { + confpbBootstrap := &bootstrap.Bootstrap + servers := confpbBootstrap.Servers + provider, err := data.NewStorageProvider(app) if err != nil { return nil, nil, err } - authRepo := dal.NewAuthRepo(r, dataData) - authServiceBiz := biz.NewAuthServiceBiz(r, authRepo) - authServiceServer := service.NewAuthServiceServerPB(authServiceBiz) - casbinSourceRepo, err := dal.NewCasbinSourceRepo(dataData) + v := providers.ProvideLogger(app) + database, cleanup, err := data.ProvideDatabase(provider, v) + if err != nil { + return nil, nil, err + } + authRepo := dal.NewAuthRepo(database, v) + crypto, err := providers.ProvideHasher() + if err != nil { + cleanup() + return nil, nil, err + } + authUseCase := biz.NewAuthUseCase(authRepo, crypto, v) + cacheProvider, err := providers.ProvideCache(app) + if err != nil { + cleanup() + return nil, nil, err + } + captcha := confpbBootstrap.Captcha + captchaCaptcha, err := providers.ProvideCaptcha(cacheProvider, captcha) + if err != nil { + cleanup() + return nil, nil, err + } + options, err := providers.ProvideAuthenticatorOptions(bootstrap) + if err != nil { + cleanup() + return nil, nil, err + } + creator, err := providers.ProvideCredentialCreator(options, v) if err != nil { cleanup() return nil, nil, err } - casbinSourceServiceBiz := biz.NewCasbinSourceServiceBiz(r, casbinSourceRepo) - casbinSourceServiceServer := service.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) - tokenizer, err := data.NewTokenizer(bootstrap) + authService := service.NewAuthService(authUseCase, captchaCaptcha, creator) + meRepo := dal.NewMeRepo(database, v) + meUseCase := biz.NewMeUseCase(meRepo, v) + meService := service.NewMeService(meUseCase) + casbinSourceService := service.NewCasbinSourceService() + v2, err := server.NewServers(servers, authService, meService, casbinSourceService, v) if err != nil { cleanup() return nil, nil, err } - refreshTokenizer := dal.RefreshTokenizer(tokenizer) - loginData := data.NewLoginData(bootstrap, refreshTokenizer) - loginRepo := dal.NewLoginRepo(dataData, loginData) - loginServiceBiz := biz.NewLoginServiceBiz(r, loginRepo) - loginServiceServer := service.NewLoginServiceServerPB(loginServiceBiz) - personalRepo := dal.NewPersonalRepo(r, dataData) - personalServiceBiz := biz.NewPersonalServiceBiz(r, personalRepo) - personalServiceServer := service.NewPersonalServiceServerPB(r, personalServiceBiz) - authServerRegistrar := service.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) - v := server.NewAuthServer(r, bootstrap, authServerRegistrar) - app := NewApp(r, v) - return app, func() { + kratosApp := NewApp(app, v2) + return kratosApp, func() { cleanup() }, nil } diff --git a/cmd/system/provider.go b/cmd/system/provider.go deleted file mode 100644 index 154d9aac..00000000 --- a/cmd/system/provider.go +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package main - -import ( - "github.com/google/wire" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" - "github.com/origadmin/toolkits/crypto/hash/types" -) - -func provideHasher() (hash.Crypto, error) { - // Using a default cost for bcrypt. In a real application, this might come from config. - return hash.NewCrypto(types.BCRYPT, bcrypt.WithCost(bcrypt.DefaultCost)) -} - -func provideLogger(app *runtime.App) log.Logger { - return app.Logger() -} - -var infraProviderSet = wire.NewSet(provideLogger, provideHasher) diff --git a/cmd/system/wire.go b/cmd/system/wire.go index f499d873..73c8ec5f 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -20,15 +20,20 @@ import ( "origadmin/application/admin/internal/features/system/dal" "origadmin/application/admin/internal/features/system/server" "origadmin/application/admin/internal/features/system/service" + "origadmin/application/admin/internal/helpers/providers" ) // wireApp init kratos application. func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { panic(wire.Build( - // The injector function's parameter `app` is an implicit provider for *runtime.App. - infraProviderSet, + // Shared infrastructure providers + providers.ProviderSet, + + // Instructions for wire to extract nested configs wire.FieldsOf(new(*conf.Config), "Bootstrap"), wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), + + // Service-specific providers data.ProviderSet, dal.ProviderSet, biz.ProviderSet, diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index 38d59135..d830a2d5 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -15,6 +15,7 @@ import ( "origadmin/application/admin/internal/features/system/dal" "origadmin/application/admin/internal/features/system/server" "origadmin/application/admin/internal/features/system/service" + "origadmin/application/admin/internal/helpers/providers" ) import ( @@ -30,17 +31,21 @@ import ( func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { confpbBootstrap := &bootstrap.Bootstrap servers := confpbBootstrap.Servers - dataData, cleanup, err := data.NewData(app, bootstrap) + provider, err := data.NewStorageProvider(app) + if err != nil { + return nil, nil, err + } + v := providers.ProvideLogger(app) + database, cleanup, err := data.ProvideDatabase(provider, v) if err != nil { return nil, nil, err } - database := data.ProvideDatabase(dataData) resourceRepo := dal.NewResourceRepo(database) resourceUseCase := biz.NewResourceUseCase(resourceRepo) roleRepo := dal.NewRoleRepo(database) roleUseCase := biz.NewRoleUseCase(roleRepo) userRepo := dal.NewUserRepo(database) - crypto, err := provideHasher() + crypto, err := providers.ProvideHasher() if err != nil { cleanup() return nil, nil, err @@ -51,7 +56,6 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err viewRepo := dal.NewViewRepo(database) viewUseCase := biz.NewViewUseCase(viewRepo) systemService := service.New(resourceUseCase, roleUseCase, userUseCase, permissionUseCase, viewUseCase) - v := provideLogger(app) v2, err := server.NewServers(servers, systemService, v) if err != nil { cleanup() diff --git a/go.mod b/go.mod index c59e95bb..1e10cf5b 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/casbin/casbin/v2 v2.135.0 github.com/envoyproxy/protoc-gen-validate v1.3.0 github.com/go-kratos/kratos/v2 v2.9.2 + github.com/go-redis/redis/v8 v8.11.5 github.com/goexts/generic v0.14.0 github.com/golang-jwt/jwt/v5 v5.3.0 // indirect github.com/google/gnostic v0.7.1 // indirect @@ -24,8 +25,8 @@ require ( github.com/mattn/go-sqlite3 v1.14.32 // indirect github.com/mojocn/base64Captcha v1.3.8 github.com/origadmin/contrib v1.1.0 - github.com/origadmin/entslog/v3 v3.1.0 - github.com/origadmin/runtime v0.2.13 + github.com/origadmin/entslog/v3 v3.1.1 + github.com/origadmin/runtime v0.2.14 github.com/origadmin/slog-kratos v1.0.5 // indirect github.com/origadmin/toolkits v1.2.0 github.com/origadmin/toolkits/codec v1.2.0 @@ -34,21 +35,21 @@ require ( github.com/sony/sonyflake v1.3.0 github.com/sqlite3ent/sqlite3 v1.40.0 golang.org/x/net v0.47.0 - google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b // indirect google.golang.org/grpc v1.77.0 - google.golang.org/protobuf v1.36.10 + google.golang.org/protobuf v1.36.11 ) require github.com/joho/godotenv v1.5.1 require ( ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 // indirect - buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.10-20250718181942-e35f9b667443.1 // indirect - buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.10-20250109164928-1da0de137947.1 // indirect - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 // indirect - buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251027152159-f1066ce064ca.2 // indirect - buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.10-20251027152159-f1066ce064ca.1 // indirect - buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.10-20241007202033-cf42259fcbfc.1 // indirect + buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.11-20250718181942-e35f9b667443.1 // indirect + buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.11-20250109164928-1da0de137947.1 // indirect + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1 // indirect + buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251202164234-62b14f0b533c.2 // indirect + buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.11-20251202164234-62b14f0b533c.1 // indirect + buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.11-20241007202033-cf42259fcbfc.1 // indirect buf.build/go/app v0.2.0 // indirect buf.build/go/bufplugin v0.9.0 // indirect buf.build/go/bufprivateusage v0.1.0 // indirect @@ -57,7 +58,7 @@ require ( buf.build/go/protoyaml v0.6.0 // indirect buf.build/go/spdx v0.2.0 // indirect buf.build/go/standard v0.1.0 // indirect - cel.dev/expr v0.25.0 // indirect + cel.dev/expr v0.25.1 // indirect connectrpc.com/connect v1.19.1 // indirect connectrpc.com/otelconnect v0.8.0 // indirect dario.cat/mergo v1.0.2 // indirect @@ -68,22 +69,38 @@ require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect + github.com/atotto/clipboard v0.1.4 // indirect + github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect github.com/bufbuild/buf v1.61.0 // indirect github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8 // indirect github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1 // indirect - github.com/bytedance/sonic v1.14.1 // indirect - github.com/bytedance/sonic/loader v0.3.0 // indirect + github.com/bytedance/gopkg v0.1.3 // indirect + github.com/bytedance/sonic v1.14.2 // indirect + github.com/bytedance/sonic/loader v0.4.0 // indirect github.com/casbin/govaluate v1.3.0 // indirect + github.com/catppuccin/go v0.3.0 // indirect + github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 // indirect + github.com/charmbracelet/bubbletea v1.3.10 // indirect + github.com/charmbracelet/colorprofile v0.3.3 // indirect + github.com/charmbracelet/huh v0.8.0 // indirect + github.com/charmbracelet/lipgloss v1.1.0 // indirect + github.com/charmbracelet/x/ansi v0.11.3 // indirect + github.com/charmbracelet/x/cellbuf v0.0.14 // indirect + github.com/charmbracelet/x/exp/strings v0.0.0-20251215102626-e0db08df7383 // indirect + github.com/charmbracelet/x/term v0.2.2 // indirect github.com/cli/browser v1.3.0 // indirect + github.com/clipperhouse/displaywidth v0.6.2 // indirect + github.com/clipperhouse/stringish v0.1.1 // indirect + github.com/clipperhouse/uax29/v2 v2.3.0 // indirect github.com/cloudwego/base64x v0.1.6 // indirect github.com/containerd/errdefs v1.0.0 // indirect github.com/containerd/errdefs/pkg v0.3.0 // indirect - github.com/containerd/stargz-snapshotter/estargz v0.18.0 // indirect + github.com/containerd/stargz-snapshotter/estargz v0.18.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/distribution/reference v0.6.0 // indirect - github.com/docker/cli v28.5.1+incompatible // indirect + github.com/docker/cli v29.0.4+incompatible // indirect github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker v28.5.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.9.4 // indirect @@ -91,13 +108,15 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/emicklei/proto v1.14.2 // indirect + github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/go-chi/chi/v5 v5.2.3 // indirect github.com/go-kratos/aegis v0.2.0 // indirect - github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251201062103-6f0b3015b803 // indirect - github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251201062103-6f0b3015b803 // indirect - github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251201062103-6f0b3015b803 // indirect + github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251217105121-fb8e43efb207 // indirect + github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251217105121-fb8e43efb207 // indirect + github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251217105121-fb8e43efb207 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect @@ -108,9 +127,9 @@ require ( github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/mock v1.7.0-rc.1 // indirect github.com/google/cel-go v0.26.1 // indirect - github.com/google/gnostic-models v0.7.0 // indirect + github.com/google/gnostic-models v0.7.1 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/go-containerregistry v0.20.6 // indirect + github.com/google/go-containerregistry v0.20.7 // indirect github.com/google/subcommands v1.2.0 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -121,28 +140,35 @@ require ( github.com/jdx/go-netrc v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/klauspost/compress v1.18.1 // indirect + github.com/klauspost/compress v1.18.2 // indirect github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/klauspost/pgzip v1.2.6 // indirect github.com/lmittmann/tint v1.1.2 // indirect + github.com/lucasb-eyer/go-colorful v1.3.0 // indirect github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 // indirect github.com/lyft/protoc-gen-star/v2 v2.0.4 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-localereader v0.0.1 // indirect + github.com/mattn/go-runewidth v0.0.19 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/term v0.5.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/morikuni/aec v1.0.0 // indirect - github.com/ncruces/go-strftime v0.1.9 // indirect + github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect + github.com/muesli/cancelreader v0.2.2 // indirect + github.com/muesli/termenv v0.16.0 // indirect + github.com/ncruces/go-strftime v0.1.10 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect github.com/origadmin/toolkits/slogx v1.1.0 // indirect - github.com/petermattis/goid v0.0.0-20250904145737-900bdf8bb490 // indirect + github.com/petermattis/goid v0.0.0-20251121121749-a11dd1a45f9a // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect @@ -158,15 +184,16 @@ require ( github.com/shoenig/go-m1cpu v0.1.7 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/afero v1.15.0 // indirect - github.com/spf13/cobra v1.10.1 // indirect + github.com/spf13/cobra v1.10.2 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/stoewer/go-strcase v1.3.1 // indirect github.com/tetratelabs/wazero v1.9.0 // indirect github.com/tidwall/btree v1.8.1 // indirect - github.com/tklauser/go-sysconf v0.3.15 // indirect - github.com/tklauser/numcpus v0.10.0 // indirect + github.com/tklauser/go-sysconf v0.3.16 // indirect + github.com/tklauser/numcpus v0.11.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/vbatts/tar-split v0.12.2 // indirect + github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect github.com/zclconf/go-cty v1.16.2 // indirect github.com/zclconf/go-cty-yaml v1.1.0 // indirect @@ -192,7 +219,7 @@ require ( golang.org/x/term v0.37.0 // indirect golang.org/x/text v0.31.0 // indirect golang.org/x/tools v0.39.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect @@ -200,6 +227,6 @@ require ( modernc.org/libc v1.66.10 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.11.0 // indirect - modernc.org/sqlite v1.40.0 // indirect + modernc.org/sqlite v1.40.1 // indirect pluginrpc.com/pluginrpc v0.5.0 // indirect ) diff --git a/go.sum b/go.sum index 63afdede..de2ecbd9 100644 --- a/go.sum +++ b/go.sum @@ -2,16 +2,28 @@ ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 h1:E0wvcUXTkgyN4wy4LGtNzMNG ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.10-20250718181942-e35f9b667443.1 h1:FzJGrb8r7vir+P3zJ5Ebey8p54LYTYtQsrM/U35YO9Q= buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.10-20250718181942-e35f9b667443.1/go.mod h1:E6HwqUm4Ag7bXtg/tX7jHWO7CgpknbmeACgDax0icV0= +buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.11-20250718181942-e35f9b667443.1 h1:zQ9C3e6FtwSZUFuKAQfpIKGFk5ZuRoGt5g35Bix55sI= +buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.11-20250718181942-e35f9b667443.1/go.mod h1:1Znr6gmYBhbxWUPRrrVnSLXQsz8bvFVw1HHJq2bI3VQ= buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.10-20250109164928-1da0de137947.1 h1:9hkMnVoImDlY7rTlAWIWXdkGUKOjf3YlyZeSbYT29uA= buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.10-20250109164928-1da0de137947.1/go.mod h1:/AouMCAeQ+kB7+RRFpdUlZe3503p18VoUNcU2AFqZXM= +buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.11-20250109164928-1da0de137947.1 h1:HwzzCRS4ZrEm1++rzSDxHnO0DOjiT1b8I/24e8a4exY= +buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.11-20250109164928-1da0de137947.1/go.mod h1:8PRKXhgNes29Tjrnv8KdZzg3I1QceOkzibW1QK7EXv0= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 h1:31on4W/yPcV4nZHL4+UCiCvLPsMqe/vJcNg8Rci0scc= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1/go.mod h1:fUl8CEN/6ZAMk6bP8ahBJPUJw7rbp+j4x+wCcYi2IG4= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1 h1:j9yeqTWEFrtimt8Nng2MIeRrpoCvQzM9/g25XTvqUGg= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM= buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251027152159-f1066ce064ca.2 h1:Dbh4Edwy5qHlz1/boPAQ7T5Q7ZDMgEuQlEbXa94+JEo= buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251027152159-f1066ce064ca.2/go.mod h1:SqqTA3aiYVDkpDINxgbxDT6QBjkVjdqUXtbiz6DiWIg= +buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251202164234-62b14f0b533c.2 h1:eQ6XRVUaYYZFOZvBsyrOYLWbw6464s5dVnHscxa0b8w= +buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251202164234-62b14f0b533c.2/go.mod h1:omxVRch3jEPMINnUipLsuRWoEhND6LPXELKBG7xzyDw= buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.10-20251027152159-f1066ce064ca.1 h1:5tUFlRgcC+N2JJtjwlwyb2J4bBk/bJYLXk50zlewtzk= buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.10-20251027152159-f1066ce064ca.1/go.mod h1:AaYXXeRvnOc151wEuupAmn58Mh9bccKce2kk3QKMIrQ= +buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.11-20251202164234-62b14f0b533c.1 h1:PdfIJUbUVKdajMVYuMdvr2Wvo+wmzGnlPEYA4bhFaWI= +buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.11-20251202164234-62b14f0b533c.1/go.mod h1:1JJi9jvOqRxSMa+JxiZSm57doB+db/1WYCIa2lHfc40= buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.10-20241007202033-cf42259fcbfc.1 h1:CzM0kZcoaIr8+R4i8QVorUNRM/CqMr87i3j+w2pdpCc= buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.10-20241007202033-cf42259fcbfc.1/go.mod h1:bG+Fa7tcA+4pW0JdOh4h7iKjleyZIKhfVzVS10qfrnk= +buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.11-20241007202033-cf42259fcbfc.1 h1:iGPvEJltOXUMANWf0zajcRcbiOXLD90ZwPUFvbcuv6Q= +buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.11-20241007202033-cf42259fcbfc.1/go.mod h1:nWVKKRA29zdt4uvkjka3i/y4mkrswyWwiu0TbdX0zts= buf.build/go/app v0.2.0 h1:NYaH13A+RzPb7M5vO8uZYZ2maBZI5+MS9A9tQm66fy8= buf.build/go/app v0.2.0/go.mod h1:0XVOYemubVbxNXVY0DnsVgWeGkcbbAvjDa1fmhBC+Wo= buf.build/go/bufplugin v0.9.0 h1:ktZJNP3If7ldcWVqh46XKeiYJVPxHQxCfjzVQDzZ/lo= @@ -30,6 +42,8 @@ buf.build/go/standard v0.1.0 h1:g98T9IyvAl0vS3Pq8iVk6Cvj2ZiFvoUJRtfyGa0120U= buf.build/go/standard v0.1.0/go.mod h1:PiqpHz/7ZFq+kqvYhc/SK3lxFIB9N/aiH2CFC2JHIQg= cel.dev/expr v0.25.0 h1:qbCFvDJJthxLvf3TqeF9Ys7pjjWrO7LMzfYhpJUc30g= cel.dev/expr v0.25.0/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= +cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4= +cel.dev/expr v0.25.1/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= connectrpc.com/connect v1.19.1 h1:R5M57z05+90EfEvCY1b7hBxDVOUl45PrtXtAV2fOC14= connectrpc.com/connect v1.19.1/go.mod h1:tN20fjdGlewnSFeZxLKb0xwIZ6ozc3OQs2hTXy4du9w= connectrpc.com/otelconnect v0.8.0 h1:a4qrN4H8aEE2jAoCxheZYYfEjXMgVPyL9OzPQLBEFXU= @@ -55,6 +69,10 @@ github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYW github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= +github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= +github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= +github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= +github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= @@ -67,23 +85,56 @@ github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8 h1:l4PKzJ github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8/go.mod h1:HKN246DRQwavs64sr2xYmSL+RFOFxmLti+WGCZ2jh9U= github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1 h1:V1xulAoqLqVg44rY97xOR+mQpD2N+GzhMHVwJ030WEU= github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1/go.mod h1:c5D8gWRIZ2HLWO3gXYTtUfw/hbJyD8xikv2ooPxnklQ= +github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M= +github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= github.com/bytedance/sonic v1.13.3 h1:MS8gmaH16Gtirygw7jV91pDCN33NyMrPbN7qiYhEsF0= github.com/bytedance/sonic v1.13.3/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= github.com/bytedance/sonic v1.14.1/go.mod h1:gi6uhQLMbTdeP0muCnrjHLeCUPyb70ujhnNlhOylAFc= +github.com/bytedance/sonic v1.14.2 h1:k1twIoe97C1DtYUo+fZQy865IuHia4PR5RPiuGPPIIE= +github.com/bytedance/sonic v1.14.2/go.mod h1:T80iDELeHiHKSc0C9tubFygiuXoGzrkjKzX2quAx980= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY= github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= +github.com/bytedance/sonic/loader v0.4.0 h1:olZ7lEqcxtZygCK9EKYKADnpQoYkRQxaeY2NYzevs+o= +github.com/bytedance/sonic/loader v0.4.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo= github.com/casbin/casbin/v2 v2.134.0 h1:wyO3hZb487GzlGVAI2hUoHQT0ehFD+9B5P+HVG9BVTM= github.com/casbin/casbin/v2 v2.134.0/go.mod h1:FmcfntdXLTcYXv/hxgNntcRPqAbwOG9xsism0yXT+18= github.com/casbin/casbin/v2 v2.135.0 h1:6BLkMQiGotYyS5yYeWgW19vxqugUlvHFkFiLnLR/bxk= github.com/casbin/casbin/v2 v2.135.0/go.mod h1:FmcfntdXLTcYXv/hxgNntcRPqAbwOG9xsism0yXT+18= github.com/casbin/govaluate v1.3.0 h1:VA0eSY0M2lA86dYd5kPPuNZMUD9QkWnOCnavGrw9myc= github.com/casbin/govaluate v1.3.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= +github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY= +github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= +github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws= +github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7/go.mod h1:ISC1gtLcVilLOf23wvTfoQuYbW2q0JevFxPfUzZ9Ybw= +github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= +github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= +github.com/charmbracelet/colorprofile v0.3.3 h1:DjJzJtLP6/NZ8p7Cgjno0CKGr7wwRJGxWUwh2IyhfAI= +github.com/charmbracelet/colorprofile v0.3.3/go.mod h1:nB1FugsAbzq284eJcjfah2nhdSLppN2NqvfotkfRYP4= +github.com/charmbracelet/huh v0.8.0 h1:Xz/Pm2h64cXQZn/Jvele4J3r7DDiqFCNIVteYukxDvY= +github.com/charmbracelet/huh v0.8.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4= +github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= +github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30= +github.com/charmbracelet/x/ansi v0.11.3 h1:6DcVaqWI82BBVM/atTyq6yBoRLZFBsnoDoX9GCu2YOI= +github.com/charmbracelet/x/ansi v0.11.3/go.mod h1:yI7Zslym9tCJcedxz5+WBq+eUGMJT0bM06Fqy1/Y4dI= +github.com/charmbracelet/x/cellbuf v0.0.14 h1:iUEMryGyFTelKW3THW4+FfPgi4fkmKnnaLOXuc+/Kj4= +github.com/charmbracelet/x/cellbuf v0.0.14/go.mod h1:P447lJl49ywBbil/KjCk2HexGh4tEY9LH0/1QrZZ9rA= +github.com/charmbracelet/x/exp/strings v0.0.0-20251215102626-e0db08df7383 h1:EW707oHc6fWA5o8kvGjt/kta6DUd4VZ/3fGuH8L4REE= +github.com/charmbracelet/x/exp/strings v0.0.0-20251215102626-e0db08df7383/go.mod h1:/ehtMPNh9K4odGFkqYJKpIYyePhdp1hLBRvyY4bWkH8= +github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk= +github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI= github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk= +github.com/clipperhouse/displaywidth v0.6.2 h1:ZDpTkFfpHOKte4RG5O/BOyf3ysnvFswpyYrV7z2uAKo= +github.com/clipperhouse/displaywidth v0.6.2/go.mod h1:R+kHuzaYWFkTm7xoMmK1lFydbci4X2CicfbGstSGg0o= +github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= +github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= +github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4= +github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M= github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU= github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f h1:Y8xYupdHxryycyPlc9Y+bSQAYZnetRJ70VMVKm5CKI0= @@ -93,6 +144,8 @@ github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151X github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= github.com/containerd/stargz-snapshotter/estargz v0.18.0 h1:Ny5yptQgEXSkDFKvlKJGTvf1YJ+4xD8V+hXqoRG0n74= github.com/containerd/stargz-snapshotter/estargz v0.18.0/go.mod h1:7hfU1BO2KB3axZl0dRQCdnHrIWw7TRDdK6L44Rdeuo0= +github.com/containerd/stargz-snapshotter/estargz v0.18.1 h1:cy2/lpgBXDA3cDKSyEfNOFMA/c10O1axL69EU7iirO8= +github.com/containerd/stargz-snapshotter/estargz v0.18.1/go.mod h1:ALIEqa7B6oVDsrF37GkGN20SuvG/pIMm7FwP7ZmRb0Q= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= @@ -105,6 +158,8 @@ github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5Qvfr github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/docker/cli v28.5.1+incompatible h1:ESutzBALAD6qyCLqbQSEf1a/U8Ybms5agw59yGVc+yY= github.com/docker/cli v28.5.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v29.0.4+incompatible h1:mffN/hPqaI39vx/4QiSkdldHeM0rP1ZZBIXRUOPI5+I= +github.com/docker/cli v29.0.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v28.5.2+incompatible h1:DBX0Y0zAjZbSrm1uzOkdr1onVghKaftjlSWt4AFexzM= @@ -125,6 +180,8 @@ github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfU github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU= github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg5VPuZ0uONDT6eb4= github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA= +github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= +github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -138,12 +195,18 @@ github.com/go-kratos/aegis v0.2.0/go.mod h1:v0R2m73WgEEYB3XYu6aE2WcMwsZkJ/Rzuf5e github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251106012513-9262193e351a h1:hXTsD6lWaAU7UQchbmafi9WLTyBMjoLttEnVpWMiGJA= github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:tr3LJLUypg8Js3bClD6s7p2eWLTIitvq9Paf7FAK3R4= github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:tr3LJLUypg8Js3bClD6s7p2eWLTIitvq9Paf7FAK3R4= +github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251217105121-fb8e43efb207 h1:9/jBnQSuRMIdLTfeoM0IWXF1cGFKVjKb7fTDOEoD4H8= +github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251217105121-fb8e43efb207/go.mod h1:S0grzHPbqVD8ilueT7yd0k32/ZSbY64y7zdovhGNzyg= github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251106012513-9262193e351a h1:3nyCH1sGH9sSWnnVDpvxywg8r+Esr1lObU6wTzW3ups= github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= +github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251217105121-fb8e43efb207 h1:admtUgwA6qCvdh1A5Ke0r+1s1aEO8wrLWj07/5uqXxM= +github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251217105121-fb8e43efb207/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251106012513-9262193e351a h1:lyM6XpKxtzwcII0cvVk8QsGyJvu9xMJT8yoW6fwIbT4= github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= +github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251217105121-fb8e43efb207 h1:SlUVCwGBsK/ITX9HkWSGNhbA0Ud9t56r0m9qhy+pip0= +github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251217105121-fb8e43efb207/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= github.com/go-kratos/kratos/v2 v2.9.1 h1:EGif6/S/aK/RCR5clIbyhioTNyoSrii3FC118jG40Z0= github.com/go-kratos/kratos/v2 v2.9.1/go.mod h1:a1MQLjMhIh7R0kcJS9SzJYR43BRI7EPzzN0J1Ksu2bA= github.com/go-kratos/kratos/v2 v2.9.2 h1:px8GJQBeLpquDKQWQ9zohEWiLA8n4D/pv7aH3asvUvo= @@ -185,12 +248,16 @@ github.com/google/gnostic v0.7.1 h1:t5Kc7j/8kYr8t2u11rykRrPPovlEMG4+xdc/SpekATs= github.com/google/gnostic v0.7.1/go.mod h1:KSw6sxnxEBFM8jLPfJd46xZP+yQcfE8XkiqfZx5zR28= github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= +github.com/google/gnostic-models v0.7.1 h1:SisTfuFKJSKM5CPZkffwi6coztzzeYUhc3v4yxLWH8c= +github.com/google/gnostic-models v0.7.1/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/go-containerregistry v0.20.6 h1:cvWX87UxxLgaH76b4hIvya6Dzz9qHB31qAwjAohdSTU= github.com/google/go-containerregistry v0.20.6/go.mod h1:T0x8MuoAoKX/873bkeSfLD2FAkwCDf9/HZgsFJ02E2Y= +github.com/google/go-containerregistry v0.20.7 h1:24VGNpS0IwrOZ2ms2P1QE3Xa5X9p4phx0aUgzYzHW6I= +github.com/google/go-containerregistry v0.20.7/go.mod h1:Lx5LCZQjLH1QBaMPeGwsME9biPeo1lPx6lbGj/UmzgM= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= @@ -226,9 +293,12 @@ github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNU github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= +github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk= +github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= +github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU= github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= @@ -239,6 +309,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lmittmann/tint v1.1.2 h1:2CQzrL6rslrsyjqLDwD11bZ5OpLBPU+g3G/r5LSfS8w= github.com/lmittmann/tint v1.1.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= +github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag= +github.com/lucasb-eyer/go-colorful v1.3.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 h1:PwQumkgq4/acIiZhtifTV5OUqqiP82UAl0h87xj/l9k= github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/lyft/protoc-gen-star/v2 v2.0.4 h1:JDlNKttNIRd68AAIychs0AqEpO8/I/WYi01OQ7Raw6Q= @@ -249,6 +321,10 @@ github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stg github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= +github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= +github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= +github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= @@ -260,6 +336,8 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= +github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= @@ -275,8 +353,16 @@ github.com/mojocn/base64Captcha v1.3.8 h1:rrN9BhCwXKS8ht1e21kvR3iTaMgf4qPC9sRoV5 github.com/mojocn/base64Captcha v1.3.8/go.mod h1:QFZy927L8HVP3+VV5z2b1EAEiv1KxVJKZbAucVgLUy4= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= +github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= +github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= +github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= +github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= +github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/ncruces/go-strftime v0.1.10 h1:UYG9J7oU9Z0i5ohqzg9kicKcV4hc5YzEgZowOGjP4us= +github.com/ncruces/go-strftime v0.1.10/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= @@ -285,11 +371,16 @@ github.com/origadmin/contrib v1.1.0 h1:5ZMuxPas9+WIDNDlG+99Y5JHGwQRq2rZ4TjJXM5/O github.com/origadmin/contrib v1.1.0/go.mod h1:lqSKEAQHNRf96zWG3XvZZv96oFUeMBstLAWBGP7VIus= github.com/origadmin/entslog/v3 v3.1.0 h1:1SPjs2CWytl08obWW2wAk8UTiwoc0ak/doWdQHN64Rk= github.com/origadmin/entslog/v3 v3.1.0/go.mod h1:cIFyIZprNlJ69T18DnXBpylvO2CWvEGPhW1r2Sm/51s= +github.com/origadmin/entslog/v3 v3.1.1 h1:xuNst8prXxqa51marfhWwEAJJd1ZiYNEEBqflifL19o= +github.com/origadmin/entslog/v3 v3.1.1/go.mod h1:mmxKcgx7YflNUwaVAmkq0ajK/SqyaETPsLM1l1ty3lY= github.com/origadmin/runtime v0.2.3 h1:1DEiXawwftHOOWwHM5ScSSOk8CuMRyfvAQDAUUvGhDs= github.com/origadmin/runtime v0.2.3/go.mod h1:rgOxokXjWXXbzzHr2ICXW3KNsQ8KNGFqjMcpGo54aOM= github.com/origadmin/runtime v0.2.13/go.mod h1:P4X8gBcPhGpH778JV/VVlj7xi4iX1WYDfir3lJOoTwg= +github.com/origadmin/runtime v0.2.14 h1:4D0udgzQumSsbr2XW0Ozuv4jma7vWvY+blqaiEp8xtc= +github.com/origadmin/runtime v0.2.14/go.mod h1:HIzn3AGmC/OybEmANsXZFTo/xPSRTVnyE+89mm8PMCE= github.com/origadmin/slog-kratos v1.0.4 h1:1et3TBy61Uwf5N1ZbEBFhMqCjgxqfRXmz2w0Q1dujG0= github.com/origadmin/slog-kratos v1.0.4/go.mod h1:WUdhcWLyN0i8TbdemqE2Y/muoj0GaZ86OcdpumAWHPo= +github.com/origadmin/slog-kratos v1.0.5 h1:yDLxVaN8A8MMmIny3xy65uT1wLKl3S9tVZVijn+1Vhc= github.com/origadmin/slog-kratos v1.0.5/go.mod h1:zuOf6B1cMjPwwMJ2or2sPbzNAdx/fMn/6MekdG30Xh4= github.com/origadmin/toolkits v0.3.16 h1:R/Ws2S2W64ZScSkBz4QQ8HPXWpuH/ac+z1z0iHPyG0M= github.com/origadmin/toolkits v0.3.16/go.mod h1:l0H6drsQuWNiSDagDwI2jvLqxlNGtF1LI++fPrz5KAg= @@ -297,18 +388,24 @@ github.com/origadmin/toolkits v1.2.0 h1:7L/hgf0WC/q7yIJH9V0uENrxkAN0oU3D2EobfqKO github.com/origadmin/toolkits v1.2.0/go.mod h1:ylurxc+wCcSK3FyT7a6bnGfR2l4tu11b128X+dh1fbw= github.com/origadmin/toolkits/codec v0.3.16 h1:fRyWCMwyXz032I1ZHpsRuG/8YfWRS4YlfqYNdjeziMw= github.com/origadmin/toolkits/codec v0.3.16/go.mod h1:XqlOlTxdD3lLDPmC82cZEVoiD4/r4QA3umKKRVrgGu4= +github.com/origadmin/toolkits/codec v1.2.0 h1:Tnnxc2Bcf9wTcMiV/4h89CxGTz+v6EN6+ZBbYdyCLD8= github.com/origadmin/toolkits/codec v1.2.0/go.mod h1:NgbdOtowlFY79/CXZzRhes1tRHTBr3XZX+VBWL7yUpw= github.com/origadmin/toolkits/crypto v0.3.15 h1:OHgIXLvB2jCvKH55YVdSyTjcOAwB05FmvCQLKn2BoMQ= github.com/origadmin/toolkits/crypto v0.3.15/go.mod h1:ozRQi1rYHAIL/NSw0hJEWITEkZlSZ7wA9pCQKpqFv2s= +github.com/origadmin/toolkits/crypto v1.2.0 h1:SajjJuDHf/KT0AEvvW/Z2HnPW07vnyCvIlgD4lfykeA= github.com/origadmin/toolkits/crypto v1.2.0/go.mod h1:PlR7+Dh88bVl8z+wKjAcxVBHxl3fllwfhLGOvzAO9nQ= github.com/origadmin/toolkits/errors v1.1.0 h1:Vh5ic7kU6e01koOuGpu3c6etbSZ7gEfesXQMpOsO2D8= github.com/origadmin/toolkits/errors v1.1.0/go.mod h1:YCPShNuAmn0ns0JB43iKbVdWcPA8XCTiFG+7UA2+tJw= +github.com/origadmin/toolkits/errors v1.2.0 h1:dQzGVa9QtlptaQ3ljXz6+dbMwHMBORPdiyAF5xxErlk= github.com/origadmin/toolkits/errors v1.2.0/go.mod h1:YCPShNuAmn0ns0JB43iKbVdWcPA8XCTiFG+7UA2+tJw= github.com/origadmin/toolkits/slogx v0.3.16 h1:+sJAKM2t/3ZyT6qi+Q1CwnzXO/ObXJlKTfPA6RdJno0= github.com/origadmin/toolkits/slogx v0.3.16/go.mod h1:6ODf/5T3M7XBc0aKHHkMgOLawkASDzaPCj99JzabYME= +github.com/origadmin/toolkits/slogx v1.1.0 h1:UEqIMxMwUiWZe4/g/0aIVA/i7FMKqh4kSj0J+PRPJi8= github.com/origadmin/toolkits/slogx v1.1.0/go.mod h1:rpyegD2CZypR+ctlpVz4q3KROwb3xc6mUKQQZ9ow+qI= github.com/petermattis/goid v0.0.0-20250904145737-900bdf8bb490 h1:QTvNkZ5ylY0PGgA+Lih+GdboMLY/G9SEGLMEGVjTVA4= github.com/petermattis/goid v0.0.0-20250904145737-900bdf8bb490/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/petermattis/goid v0.0.0-20251121121749-a11dd1a45f9a h1:VweslR2akb/ARhXfqSfRbj1vpWwYXf3eeAUyw/ndms0= +github.com/petermattis/goid v0.0.0-20251121121749-a11dd1a45f9a/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= @@ -330,6 +427,7 @@ github.com/rodaine/protogofakeit v0.1.1 h1:ZKouljuRM3A+TArppfBqnH8tGZHOwM/pjvtXe github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0= @@ -349,6 +447,8 @@ github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -359,12 +459,15 @@ github.com/stoewer/go-strcase v1.3.1/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8w github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I= github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM= @@ -372,12 +475,18 @@ github.com/tidwall/btree v1.8.1 h1:27ehoXvm5AG/g+1VxLS1SD3vRhp/H7LuEfwNvddEdmA= github.com/tidwall/btree v1.8.1/go.mod h1:jBbTdUWhSZClZWoDg54VnvV7/54modSOzDN7VXftj1A= github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= +github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA= +github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI= github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= +github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw= +github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/vbatts/tar-split v0.12.2 h1:w/Y6tjxpeiFMR47yzZPlPj/FcPLpXbTUi/9H7d3CPa4= github.com/vbatts/tar-split v0.12.2/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVOpnNdfTMFA= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= +github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= @@ -416,6 +525,7 @@ go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/arch v0.18.0 h1:WN9poc33zL4AzGxqf8VtpKUnGvMi8O9lhNyBMF/85qc= golang.org/x/arch v0.18.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= +golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI= golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -438,6 +548,7 @@ golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= +golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -451,6 +562,7 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -461,6 +573,7 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -470,6 +583,7 @@ golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -483,6 +597,7 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -506,6 +621,7 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -516,6 +632,7 @@ golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= +golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -523,15 +640,22 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls= google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto= +google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b h1:uA40e2M6fYRBf0+8uN5mLlqUtV192iiksiICIBkYJ1E= +google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:Xa7le7qx2vmqB/SzWUBa7KdMjpdpAHlh5QCSnjessQk= google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 h1:Wgl1rcDNThT+Zn47YyCXOXyX/COgMTIdhJ717F0l4xk= google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b h1:Mv8VFug0MP9e5vUxfBcE3vUkV6CImK3cMNMIDFjmzxU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ= google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM= google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1/go.mod h1:5KF+wpkbTSbGcR9zteSqZV6fqFOWBl4Yde8En8MryZA= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0 h1:6Al3kEFFP9VJhRz3DID6quisgPnTeZVr4lep9kkxdPA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0/go.mod h1:QLvsjh0OIR0TYBeiu2bkWGTJBUNQ64st52iWj/yA93I= google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= +google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -560,6 +684,8 @@ modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= modernc.org/sqlite v1.40.0 h1:bNWEDlYhNPAUdUdBzjAvn8icAs/2gaKlj4vM+tQ6KdQ= modernc.org/sqlite v1.40.0/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE= +modernc.org/sqlite v1.40.1 h1:VfuXcxcUWWKRBuP8+BR9L7VnmusMgBNNnBYGEe9w/iY= +modernc.org/sqlite v1.40.1/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE= modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= diff --git a/internal/conf/pb/captcha.pb.go b/internal/conf/pb/captcha.pb.go index 931f4ec7..d6a003ec 100644 --- a/internal/conf/pb/captcha.pb.go +++ b/internal/conf/pb/captcha.pb.go @@ -7,7 +7,6 @@ package confpb import ( - v1 "github.com/origadmin/runtime/api/gen/go/config/data/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -27,8 +26,9 @@ type Captcha struct { Length int32 `protobuf:"varint,1,opt,name=length,proto3" json:"length,omitempty"` Width int32 `protobuf:"varint,2,opt,name=width,proto3" json:"width,omitempty"` Height int32 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` - CacheName string `protobuf:"bytes,4,opt,name=cache_name,proto3" json:"cache_name,omitempty"` - Caches *v1.Caches `protobuf:"bytes,5,opt,name=caches,proto3" json:"caches,omitempty"` + Maxskew float32 `protobuf:"fixed32,4,opt,name=maxskew,proto3" json:"maxskew,omitempty"` + DotCount int32 `protobuf:"varint,5,opt,name=dot_count,proto3" json:"dot_count,omitempty"` + CacheName string `protobuf:"bytes,6,opt,name=cache_name,proto3" json:"cache_name,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -84,33 +84,41 @@ func (x *Captcha) GetHeight() int32 { return 0 } -func (x *Captcha) GetCacheName() string { +func (x *Captcha) GetMaxskew() float32 { if x != nil { - return x.CacheName + return x.Maxskew } - return "" + return 0 +} + +func (x *Captcha) GetDotCount() int32 { + if x != nil { + return x.DotCount + } + return 0 } -func (x *Captcha) GetCaches() *v1.Caches { +func (x *Captcha) GetCacheName() string { if x != nil { - return x.Caches + return x.CacheName } - return nil + return "" } var File_internal_conf_pb_captcha_proto protoreflect.FileDescriptor const file_internal_conf_pb_captcha_proto_rawDesc = "" + "\n" + - "\x1einternal/conf/pb/captcha.proto\x12\aconf.pb\x1a\x19config/data/v1/data.proto\"\xab\x01\n" + + "\x1einternal/conf/pb/captcha.proto\x12\aconf.pb\"\xa7\x01\n" + "\aCaptcha\x12\x16\n" + "\x06length\x18\x01 \x01(\x05R\x06length\x12\x14\n" + "\x05width\x18\x02 \x01(\x05R\x05width\x12\x16\n" + - "\x06height\x18\x03 \x01(\x05R\x06height\x12\x1e\n" + + "\x06height\x18\x03 \x01(\x05R\x06height\x12\x18\n" + + "\amaxskew\x18\x04 \x01(\x02R\amaxskew\x12\x1c\n" + + "\tdot_count\x18\x05 \x01(\x05R\tdot_count\x12\x1e\n" + "\n" + - "cache_name\x18\x04 \x01(\tR\n" + - "cache_name\x12:\n" + - "\x06caches\x18\x05 \x01(\v2\".runtime.api.config.data.v1.CachesR\x06cachesB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" + "cache_name\x18\x06 \x01(\tR\n" + + "cache_nameB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" var ( file_internal_conf_pb_captcha_proto_rawDescOnce sync.Once @@ -126,16 +134,14 @@ func file_internal_conf_pb_captcha_proto_rawDescGZIP() []byte { var file_internal_conf_pb_captcha_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_internal_conf_pb_captcha_proto_goTypes = []any{ - (*Captcha)(nil), // 0: conf.pb.Captcha - (*v1.Caches)(nil), // 1: runtime.api.config.data.v1.Caches + (*Captcha)(nil), // 0: conf.pb.Captcha } var file_internal_conf_pb_captcha_proto_depIdxs = []int32{ - 1, // 0: conf.pb.Captcha.caches:type_name -> runtime.api.config.data.v1.Caches - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name } func init() { file_internal_conf_pb_captcha_proto_init() } diff --git a/internal/conf/pb/captcha.pb.validate.go b/internal/conf/pb/captcha.pb.validate.go index df99a14e..83233bc9 100644 --- a/internal/conf/pb/captcha.pb.validate.go +++ b/internal/conf/pb/captcha.pb.validate.go @@ -62,36 +62,11 @@ func (m *Captcha) validate(all bool) error { // no validation rules for Height - // no validation rules for CacheName + // no validation rules for Maxskew - if all { - switch v := interface{}(m.GetCaches()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, CaptchaValidationError{ - field: "Caches", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, CaptchaValidationError{ - field: "Caches", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCaches()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return CaptchaValidationError{ - field: "Caches", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for DotCount + + // no validation rules for CacheName if len(errors) > 0 { return CaptchaMultiError(errors) diff --git a/internal/conf/pb/captcha.proto b/internal/conf/pb/captcha.proto index 27bc81e1..22100c6b 100644 --- a/internal/conf/pb/captcha.proto +++ b/internal/conf/pb/captcha.proto @@ -2,18 +2,17 @@ syntax = "proto3"; package conf.pb; -import "config/data/v1/data.proto"; - option go_package = "origadmin/application/admin/internal/conf/pb;confpb"; message Captcha { int32 length = 1 [json_name = "length"]; int32 width = 2 [json_name = "width"]; int32 height = 3 [json_name = "height"]; + float maxskew = 4 [json_name = "maxskew"]; + int32 dot_count = 5 [json_name = "dot_count"]; + string cache_name = 6 [json_name = "cache_name"]; - string cache_name = 4 [json_name = "cache_name"]; - - runtime.api.config.data.v1.Caches caches = 5 [json_name = "caches"]; + // runtime.api.config.data.v1.Caches caches = 5 [json_name = "caches"]; // 注释原有Redis配置(应由公共配置管理) // message Redis { // string addr = 1 [json_name = "addr"]; diff --git a/internal/conf/pb/conf.pb.go b/internal/conf/pb/conf.pb.go index 42ae72e6..21247da2 100644 --- a/internal/conf/pb/conf.pb.go +++ b/internal/conf/pb/conf.pb.go @@ -7,6 +7,7 @@ package confpb import ( + v15 "github.com/origadmin/contrib/api/gen/go/security/v1" v11 "github.com/origadmin/runtime/api/gen/go/config/data/v1" v12 "github.com/origadmin/runtime/api/gen/go/config/discovery/v1" v13 "github.com/origadmin/runtime/api/gen/go/config/logger/v1" @@ -43,12 +44,14 @@ type Bootstrap struct { Logger *v13.Logger `protobuf:"bytes,6,opt,name=logger,proto3" json:"logger,omitempty"` // Middleware configuration for request processing. Middlewares *v14.Middlewares `protobuf:"bytes,7,opt,name=middlewares,proto3" json:"middlewares,omitempty"` + // Security configuration for authentication and authorization. + Security *v15.Security `protobuf:"bytes,8,opt,name=security,proto3" json:"security,omitempty"` // Captcha feature specific configuration. - Captcha *Captcha `protobuf:"bytes,8,opt,name=captcha,proto3" json:"captcha,omitempty"` + Captcha *Captcha `protobuf:"bytes,9,opt,name=captcha,proto3" json:"captcha,omitempty"` // RootUser feature specific configuration for initial user setup. - RootUser *RootUser `protobuf:"bytes,9,opt,name=root_user,json=rootUser,proto3" json:"root_user,omitempty"` + RootUser *RootUser `protobuf:"bytes,10,opt,name=root_user,json=rootUser,proto3" json:"root_user,omitempty"` // Default discovery service name. - DefaultDiscovery string `protobuf:"bytes,10,opt,name=default_discovery,json=defaultDiscovery,proto3" json:"default_discovery,omitempty"` + DefaultDiscovery string `protobuf:"bytes,11,opt,name=default_discovery,json=defaultDiscovery,proto3" json:"default_discovery,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -132,6 +135,13 @@ func (x *Bootstrap) GetMiddlewares() *v14.Middlewares { return nil } +func (x *Bootstrap) GetSecurity() *v15.Security { + if x != nil { + return x.Security + } + return nil +} + func (x *Bootstrap) GetCaptcha() *Captcha { if x != nil { return x.Captcha @@ -203,7 +213,7 @@ var File_internal_conf_pb_conf_proto protoreflect.FileDescriptor const file_internal_conf_pb_conf_proto_rawDesc = "" + "\n" + - "\x1binternal/conf/pb/conf.proto\x12\aconf.pb\x1a\x19config/data/v1/data.proto\x1a#config/discovery/v1/discovery.proto\x1a\x1dconfig/logger/v1/logger.proto\x1a%config/middleware/v1/middleware.proto\x1a#config/transport/v1/transport.proto\x1a\x1einternal/conf/pb/captcha.proto\x1a\x1binternal/conf/pb/root.proto\"\xf3\x04\n" + + "\x1binternal/conf/pb/conf.proto\x12\aconf.pb\x1a\x19config/data/v1/data.proto\x1a#config/discovery/v1/discovery.proto\x1a\x1dconfig/logger/v1/logger.proto\x1a%config/middleware/v1/middleware.proto\x1a#config/transport/v1/transport.proto\x1a\x1asecurity/v1/security.proto\x1a\x1einternal/conf/pb/captcha.proto\x1a\x1binternal/conf/pb/root.proto\"\xb2\x05\n" + "\tBootstrap\x12B\n" + "\aservers\x18\x01 \x01(\v2(.runtime.api.config.transport.v1.ServersR\aservers\x12B\n" + "\aclients\x18\x02 \x01(\v2(.runtime.api.config.transport.v1.ClientsR\aclients\x12@\n" + @@ -211,11 +221,12 @@ const file_internal_conf_pb_conf_proto_rawDesc = "" + "\x04data\x18\x04 \x01(\v2 .runtime.api.config.data.v1.DataR\x04data\x12N\n" + "\vdiscoveries\x18\x05 \x01(\v2,.runtime.api.config.discovery.v1.DiscoveriesR\vdiscoveries\x12<\n" + "\x06logger\x18\x06 \x01(\v2$.runtime.api.config.logger.v1.LoggerR\x06logger\x12O\n" + - "\vmiddlewares\x18\a \x01(\v2-.runtime.api.config.middleware.v1.MiddlewaresR\vmiddlewares\x12*\n" + - "\acaptcha\x18\b \x01(\v2\x10.conf.pb.CaptchaR\acaptcha\x12.\n" + - "\troot_user\x18\t \x01(\v2\x11.conf.pb.RootUserR\brootUser\x12+\n" + - "\x11default_discovery\x18\n" + - " \x01(\tR\x10defaultDiscovery\"*\n" + + "\vmiddlewares\x18\a \x01(\v2-.runtime.api.config.middleware.v1.MiddlewaresR\vmiddlewares\x12=\n" + + "\bsecurity\x18\b \x01(\v2!.contrib.api.security.v1.SecurityR\bsecurity\x12*\n" + + "\acaptcha\x18\t \x01(\v2\x10.conf.pb.CaptchaR\acaptcha\x12.\n" + + "\troot_user\x18\n" + + " \x01(\v2\x11.conf.pb.RootUserR\brootUser\x12+\n" + + "\x11default_discovery\x18\v \x01(\tR\x10defaultDiscovery\"*\n" + "\x0eSelectorGlobal\x12\x18\n" + "\abuilder\x18\x01 \x01(\tR\abuilderB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" @@ -241,24 +252,26 @@ var file_internal_conf_pb_conf_proto_goTypes = []any{ (*v12.Discoveries)(nil), // 5: runtime.api.config.discovery.v1.Discoveries (*v13.Logger)(nil), // 6: runtime.api.config.logger.v1.Logger (*v14.Middlewares)(nil), // 7: runtime.api.config.middleware.v1.Middlewares - (*Captcha)(nil), // 8: conf.pb.Captcha - (*RootUser)(nil), // 9: conf.pb.RootUser + (*v15.Security)(nil), // 8: contrib.api.security.v1.Security + (*Captcha)(nil), // 9: conf.pb.Captcha + (*RootUser)(nil), // 10: conf.pb.RootUser } var file_internal_conf_pb_conf_proto_depIdxs = []int32{ - 2, // 0: conf.pb.Bootstrap.servers:type_name -> runtime.api.config.transport.v1.Servers - 3, // 1: conf.pb.Bootstrap.clients:type_name -> runtime.api.config.transport.v1.Clients - 1, // 2: conf.pb.Bootstrap.selector_global:type_name -> conf.pb.SelectorGlobal - 4, // 3: conf.pb.Bootstrap.data:type_name -> runtime.api.config.data.v1.Data - 5, // 4: conf.pb.Bootstrap.discoveries:type_name -> runtime.api.config.discovery.v1.Discoveries - 6, // 5: conf.pb.Bootstrap.logger:type_name -> runtime.api.config.logger.v1.Logger - 7, // 6: conf.pb.Bootstrap.middlewares:type_name -> runtime.api.config.middleware.v1.Middlewares - 8, // 7: conf.pb.Bootstrap.captcha:type_name -> conf.pb.Captcha - 9, // 8: conf.pb.Bootstrap.root_user:type_name -> conf.pb.RootUser - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 2, // 0: conf.pb.Bootstrap.servers:type_name -> runtime.api.config.transport.v1.Servers + 3, // 1: conf.pb.Bootstrap.clients:type_name -> runtime.api.config.transport.v1.Clients + 1, // 2: conf.pb.Bootstrap.selector_global:type_name -> conf.pb.SelectorGlobal + 4, // 3: conf.pb.Bootstrap.data:type_name -> runtime.api.config.data.v1.Data + 5, // 4: conf.pb.Bootstrap.discoveries:type_name -> runtime.api.config.discovery.v1.Discoveries + 6, // 5: conf.pb.Bootstrap.logger:type_name -> runtime.api.config.logger.v1.Logger + 7, // 6: conf.pb.Bootstrap.middlewares:type_name -> runtime.api.config.middleware.v1.Middlewares + 8, // 7: conf.pb.Bootstrap.security:type_name -> contrib.api.security.v1.Security + 9, // 8: conf.pb.Bootstrap.captcha:type_name -> conf.pb.Captcha + 10, // 9: conf.pb.Bootstrap.root_user:type_name -> conf.pb.RootUser + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_internal_conf_pb_conf_proto_init() } diff --git a/internal/conf/pb/conf.pb.validate.go b/internal/conf/pb/conf.pb.validate.go index 79a6dd58..ee7b51ee 100644 --- a/internal/conf/pb/conf.pb.validate.go +++ b/internal/conf/pb/conf.pb.validate.go @@ -260,6 +260,35 @@ func (m *Bootstrap) validate(all bool) error { } } + if all { + switch v := interface{}(m.GetSecurity()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Security", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, BootstrapValidationError{ + field: "Security", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetSecurity()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return BootstrapValidationError{ + field: "Security", + reason: "embedded message failed validation", + cause: err, + } + } + } + if all { switch v := interface{}(m.GetCaptcha()).(type) { case interface{ ValidateAll() error }: diff --git a/internal/conf/pb/conf.proto b/internal/conf/pb/conf.proto index fc33e5e7..4c9f1966 100644 --- a/internal/conf/pb/conf.proto +++ b/internal/conf/pb/conf.proto @@ -7,6 +7,7 @@ import "config/discovery/v1/discovery.proto"; import "config/logger/v1/logger.proto"; import "config/middleware/v1/middleware.proto"; import "config/transport/v1/transport.proto"; +import "security/v1/security.proto"; import "internal/conf/pb/captcha.proto"; import "internal/conf/pb/root.proto"; @@ -35,14 +36,17 @@ message Bootstrap { // Middleware configuration for request processing. runtime.api.config.middleware.v1.Middlewares middlewares = 7; + // Security configuration for authentication and authorization. + contrib.api.security.v1.Security security = 8; + // Captcha feature specific configuration. - conf.pb.Captcha captcha = 8; + conf.pb.Captcha captcha = 9; // RootUser feature specific configuration for initial user setup. - conf.pb.RootUser root_user = 9; + conf.pb.RootUser root_user = 10; // Default discovery service name. - string default_discovery = 10; + string default_discovery = 11; } // SelectorGlobal defines the global selector/load-balancing strategy. diff --git a/internal/data/data.go b/internal/data/data.go index 5d90251e..013267de 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -10,53 +10,55 @@ import ( entsql "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/schema" - "github.com/go-redis/redis/v8" "github.com/google/wire" "github.com/origadmin/runtime" "github.com/origadmin/runtime/data/storage" "github.com/origadmin/runtime/log" - "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/data/entity/ent" ) // ProviderSet is data providers. -var ProviderSet = wire.NewSet(NewData, ProvideDatabase, ProvideCache) +var ProviderSet = wire.NewSet(NewData, ProvideDatabase, NewStorageProvider) // Data encapsulates the core data access components. type Data struct { DB *ent.Database - RDB *redis.Client log *log.Helper } // ProvideDatabase extracts and provides the *ent.Database from the *Data object. -func ProvideDatabase(d *Data) *ent.Database { - return d.DB -} - -// ProvideCache extracts and provides the *redis.Client from the *Data object. -func ProvideCache(d *Data) *redis.Client { - return d.RDB -} - -// NewData creates a new Data instance, which encapsulates the core database and cache objects. -func NewData(rt *runtime.App, conf *conf.Config) (*Data, func(), error) { - logHelper := log.NewHelper(rt.Logger()) - - provider, err := storage.New(rt.StructuredConfig()) +func ProvideDatabase(pv storage.Provider, logger log.Logger) (*ent.Database, func(), error) { + logHelper := log.NewHelper(logger) + db, err := pv.DefaultDatabase() if err != nil { return nil, nil, err } - // --- Database --- - db, err := provider.DefaultDatabase() - if err != nil { - return nil, nil, err - } activeDB := entsql.OpenDB(db.Dialect(), db.DB()) database := ent.NewDatabase(ent.Driver(activeDB)) + return database, func() { + if database != nil { + if err := database.Client(context.Background()).Close(); err != nil { + logHelper.Errorf("failed to close ent client: %v", err) + } + } + if activeDB != nil { + if err := activeDB.Close(); err != nil { + logHelper.Errorf("failed to close database: %v", err) + } + } + }, nil +} + +// NewStorageProvider creates a new storage provider from the application's structured config. +func NewStorageProvider(rt *runtime.App) (storage.Provider, error) { + return storage.New(rt.StructuredConfig()) +} +// NewData creates a new Data instance, which encapsulates the core database object. +func NewData(database *ent.Database, logger log.Logger) (*Data, error) { + logHelper := log.NewHelper(logger) // Run the auto migration tool. if err := database.Migration(context.Background(), schema.WithDropIndex(true), @@ -65,37 +67,10 @@ func NewData(rt *runtime.App, conf *conf.Config) (*Data, func(), error) { ); err != nil { logHelper.Fatalf("failed creating schema resources: %v", err) } - - // --- Cache --- - cache, err := provider.DefaultCache() - if err != nil { - return nil, nil, err - } - rdb := cache.Redis() - + ent.Debug() d := &Data{ DB: database, - RDB: rdb, log: logHelper, } - - cleanup := func() { - logHelper.Info("closing the data resources") - if d.DB != nil { - if err := d.DB.Client(context.Background()).Close(); err != nil { - logHelper.Errorf("failed to close ent client: %v", err) - } - } - if activeDB != nil { - if err := activeDB.Close(); err != nil { - logHelper.Errorf("failed to close database: %v", err) - } - } - if d.RDB != nil { - if err := d.RDB.Close(); err != nil { - logHelper.Errorf("failed to close redis client: %v", err) - } - } - } - return d, cleanup, nil + return d, nil } diff --git a/internal/features/auth/biz/biz.go b/internal/features/auth/biz/biz.go index e7428ffe..3efdc257 100644 --- a/internal/features/auth/biz/biz.go +++ b/internal/features/auth/biz/biz.go @@ -5,7 +5,7 @@ package biz import ( - "origadmin/application/admin/internal/helpers/pagination" + "origadmin/application/admin/internal/helpers/repo" ) var ( diff --git a/internal/features/auth/biz/captcha.go b/internal/features/auth/biz/captcha.go new file mode 100644 index 00000000..715569bd --- /dev/null +++ b/internal/features/auth/biz/captcha.go @@ -0,0 +1,40 @@ +package biz + +import ( + "context" + + "github.com/go-kratos/kratos/v2/log" + "github.com/mojocn/base64Captcha" + + confpb "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/features/auth/dto" +) + +// CaptchaUseCase is a captcha use case. +type CaptchaUseCase struct { + repo dto.CaptchaRepo + config *confpb.Captcha + log *log.Helper +} + +// NewCaptchaUseCase new a captcha use case. +func NewCaptchaUseCase(repo dto.CaptchaRepo, c *confpb.Captcha, logger log.Logger) *CaptchaUseCase { + return &CaptchaUseCase{ + repo: repo, + config: c, + log: log.NewHelper(logger), + } +} + +// GenerateCaptcha generates a new captcha. +func (uc *CaptchaUseCase) GenerateCaptcha(ctx context.Context) (id, b64s string, err error) { + driver := base64Captcha.NewDriverDigit( + int(uc.config.GetHeight()), + int(uc.config.GetWidth()), + int(uc.config.GetLength()), + uc.config.GetMaxskew(), + uc.config.GetDotcount(), + ) + c := base64Captcha.NewCaptcha(driver, uc.repo) + return c.Generate() +} diff --git a/internal/features/auth/biz/casbin.biz.go b/internal/features/auth/biz/casbin.biz.go index f1eae8f1..1b7a626c 100644 --- a/internal/features/auth/biz/casbin.biz.go +++ b/internal/features/auth/biz/casbin.biz.go @@ -14,10 +14,10 @@ import ( "github.com/origadmin/runtime/log" "google.golang.org/grpc" - "origadmin/application/admin/internal/helpers/pagination" + "origadmin/application/admin/internal/helpers/repo" pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/mods/auth/dto" + "origadmin/application/admin/internal/features/auth/dto" ) // CasbinSourceServiceBiz is a CasbinSource use case. diff --git a/internal/features/auth/biz/provider.go b/internal/features/auth/biz/provider.go index 79062b67..44db5db3 100644 --- a/internal/features/auth/biz/provider.go +++ b/internal/features/auth/biz/provider.go @@ -3,4 +3,4 @@ package biz import "github.com/google/wire" // ProviderSet is biz providers. -var ProviderSet = wire.NewSet(NewAuthUseCase, NewMeUseCase, NewCaptchaUseCase) +var ProviderSet = wire.NewSet(NewAuthUseCase, NewMeUseCase, NewCaptchaUseCase, NewCasbinSourceServiceBiz) diff --git a/internal/features/auth/dal/captcha.go b/internal/features/auth/dal/captcha.go new file mode 100644 index 00000000..925dde9b --- /dev/null +++ b/internal/features/auth/dal/captcha.go @@ -0,0 +1,74 @@ +package dal + +import ( + "context" + "fmt" + "time" + + "github.com/go-kratos/kratos/v2/log" + "github.com/go-redis/redis/v8" + "github.com/mojocn/base64Captcha" + "github.com/origadmin/runtime/data/storage" + + confpb "origadmin/application/admin/internal/conf/pb" +) + +const ( + captchaPrefix = "captcha:" +) + +type captchaRepo struct { + rdb *redis.Client + log *log.Helper +} + +// NewCaptchaRepo creates a new captcha repository that implements the base64Captcha.Store interface. +func NewCaptchaRepo(provider storage.Provider, cfg *confpb.Captcha, logger log.Logger) (base64Captcha.Store, error) { + cacheName := cfg.GetCacheName() + if cacheName == "" { + return nil, fmt.Errorf("captcha cache_name is not configured") + } + + cache, err := provider.Cache(cacheName) + if err != nil { + return nil, fmt.Errorf("failed to get cache '%s': %w", cacheName, err) + } + + rdb := cache.Redis() + if rdb == nil { + return nil, fmt.Errorf("the cache '%s' is not a Redis client", cacheName) + } + + return &captchaRepo{ + rdb: rdb, + log: log.NewHelper(logger), + }, nil +} + +// Set stores the captcha value. +func (r *captchaRepo) Set(id string, value string) error { + return r.rdb.Set(context.Background(), captchaPrefix+id, value, time.Minute*5).Err() +} + +// Get retrieves the captcha value. +func (r *captchaRepo) Get(id string, clear bool) string { + ctx := context.Background() + key := captchaPrefix + id + val, err := r.rdb.Get(ctx, key).Result() + if err != nil { + r.log.Errorf("failed to get captcha from redis: %v", err) + return "" + } + if clear { + if err := r.rdb.Del(ctx, key).Err(); err != nil { + r.log.Errorf("failed to delete captcha from redis: %v", err) + } + } + return val +} + +// Verify verifies the captcha value. +func (r *captchaRepo) Verify(id, answer string, clear bool) bool { + val := r.Get(id, clear) + return val == answer +} diff --git a/internal/features/auth/dal/dal.go b/internal/features/auth/dal/dal.go index 89700737..8de368ba 100644 --- a/internal/features/auth/dal/dal.go +++ b/internal/features/auth/dal/dal.go @@ -12,12 +12,9 @@ import ( "entgo.io/ent/dialect" "github.com/google/uuid" "github.com/origadmin/entslog/v3" - "github.com/origadmin/runtime/interfaces/security" "github.com/origadmin/runtime/log" "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/rand" - - "origadmin/application/admin/helpers/id" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/features/auth/dto" // Corrected import path ) @@ -32,7 +29,7 @@ type Data struct { const FKSuffix = "_fk=1" -var random = rand.NewRand(rand.KindDigit | rand.KindLowerCase | rand.KindUpperCase) +var random = rand.NewGenerator(rand.KindDigit | rand.KindLowerCase | rand.KindUpperCase) func FixSource(source string) string { // Check if the source already contains the FK parameter @@ -527,7 +524,7 @@ func MakeCreateUser(user *dto.UserPB, username, password string, option dto.User user.Id = registerID user.Uuid = uuid.Must(uuid.NewRandom()).String() user.Username = username - user.Name = "user_" + random.RandString(8) + user.Name = "user_" + random.String(8) user.Status = 1 return user, password, nil } diff --git a/internal/features/auth/service/auth.go b/internal/features/auth/service/auth.go index 68fc441e..521be19d 100644 --- a/internal/features/auth/service/auth.go +++ b/internal/features/auth/service/auth.go @@ -11,23 +11,29 @@ import ( "github.com/origadmin/contrib/security/credential" securityPrincipal "github.com/origadmin/contrib/security/principal" "origadmin/application/admin/internal/features/auth/biz" + "origadmin/application/admin/internal/helpers/captcha" ) // AuthService is a service for authentication. type AuthService struct { v1.UnimplementedAuthServer - uc *biz.AuthUseCase - captchaUC *biz.CaptchaUseCase - creator credential.Creator + uc *biz.AuthUseCase + captcha *captcha.Captcha + creator credential.Creator } // NewAuthService creates a new authentication service. -func NewAuthService(uc *biz.AuthUseCase, captchaUC *biz.CaptchaUseCase, creator credential.Creator) *AuthService { - return &AuthService{uc: uc, captchaUC: captchaUC, creator: creator} +func NewAuthService(uc *biz.AuthUseCase, captcha *captcha.Captcha, creator credential.Creator) *AuthService { + return &AuthService{uc: uc, captcha: captcha, creator: creator} } // Login authenticates a user and returns a token pair. func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.LoginResponse, error) { + // Verify captcha + if !s.captcha.Verify(req.GetCaptchaId(), req.GetCaptchaCode(), true) { + return nil, v1.ErrorCaptchaInvalid("invalid captcha") + } + userID, err := s.uc.VerifyUser(ctx, req.Username, req.Password) if err != nil { return nil, err @@ -42,7 +48,7 @@ func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.Logi return nil, err } - token := credResp.Payload().GetToken() + token := credResp.Response().GetPayload().GetToken() if token == nil { return nil, securityv1.ErrorTokenInvalid("token is missing") } @@ -57,7 +63,7 @@ func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.Logi // GetCaptcha generates a new captcha. func (s *AuthService) GetCaptcha(ctx context.Context, req *v1.GetCaptchaRequest) (*v1.GetCaptchaResponse, error) { - id, b64s, err := s.captchaUC.GenerateCaptcha(ctx) + _, id, b64s, err := s.captcha.GenerateDigit() if err != nil { return nil, err } @@ -84,6 +90,5 @@ func (s *AuthService) RefreshToken(ctx context.Context, req *v1.RefreshTokenRequ // Authenticate is for internal use by the gateway to verify user access via gRPC. func (s *AuthService) Authenticate(ctx context.Context, req *v1.AuthenticateRequest) (*v1.AuthenticateResponse, error) { - // This should be implemented using an authn.Authenticator, which can be a separate dependency. return &v1.AuthenticateResponse{}, nil } diff --git a/internal/features/auth/service/provider.go b/internal/features/auth/service/provider.go index ed67c455..feaa45fe 100644 --- a/internal/features/auth/service/provider.go +++ b/internal/features/auth/service/provider.go @@ -1,13 +1,6 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package service implements the functions, types, and interfaces for the module. package service -import ( - "github.com/google/wire" -) +import "github.com/google/wire" // ProviderSet is service providers. var ProviderSet = wire.NewSet(NewAuthService, NewMeService, NewCasbinSourceService) diff --git a/internal/features/system/biz/provider.go b/internal/features/system/biz/provider.go index f5f7482f..6921be73 100644 --- a/internal/features/system/biz/provider.go +++ b/internal/features/system/biz/provider.go @@ -16,5 +16,4 @@ var ProviderSet = wire.NewSet( NewUserUseCase, NewPermissionUseCase, NewViewUseCase, - NewPersonalUseCase, ) diff --git a/internal/features/system/dal/role.go b/internal/features/system/dal/role.go index 8d180640..28600dc3 100644 --- a/internal/features/system/dal/role.go +++ b/internal/features/system/dal/role.go @@ -19,7 +19,7 @@ import ( type roleRepo struct { db *ent.Database - gen rand.Generator + gen rand.Rand } // NewRoleRepo . @@ -52,7 +52,7 @@ func (r *roleRepo) Get(ctx context.Context, id int64, opts ...*dto.RoleQueryOpti func (r *roleRepo) Create(ctx context.Context, rl *types.Role, opts ...*dto.RoleCreateOption) (*types.Role, error) { if rl.Keyword == "" { - randString, err := r.gen.RandString(12) + randString, err := r.gen.String(12) if err != nil { randString = "" } diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index 16315495..6cfb136d 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -74,7 +74,6 @@ func NewHTTPServer(cfg *httpv1.Server, svc *service.SystemService, logger log.Lo systemv1.RegisterPermissionServiceHTTPServer(srv, svc) systemv1.RegisterResourceServiceHTTPServer(srv, svc) systemv1.RegisterViewServiceHTTPServer(srv, svc) - systemv1.RegisterPersonalServiceHTTPServer(srv, svc) srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { log.Infof("HTTP %s %s", method, path) }) @@ -102,7 +101,6 @@ func NewGRPCServer(cfg *grpcv1.Server, svc *service.SystemService, logger log.Lo systemv1.RegisterPermissionServiceServer(srv, svc) systemv1.RegisterResourceServiceServer(srv, svc) systemv1.RegisterViewServiceServer(srv, svc) - systemv1.RegisterPersonalServiceServer(srv, svc) return srv, nil } diff --git a/internal/features/system/service/service.go b/internal/features/system/service/service.go index d8320e66..28a26a62 100644 --- a/internal/features/system/service/service.go +++ b/internal/features/system/service/service.go @@ -15,14 +15,12 @@ type SystemService struct { system.UnimplementedUserServiceServer system.UnimplementedPermissionServiceServer system.UnimplementedViewServiceServer - system.UnimplementedPersonalServiceServer Resource *biz.ResourceUseCase Role *biz.RoleUseCase User *biz.UserUseCase Permission *biz.PermissionUseCase View *biz.ViewUseCase - Personal *biz.PersonalUseCase } func New( @@ -31,7 +29,6 @@ func New( user *biz.UserUseCase, permission *biz.PermissionUseCase, view *biz.ViewUseCase, - personal *biz.PersonalUseCase, ) *SystemService { return &SystemService{ Resource: resource, @@ -39,6 +36,5 @@ func New( User: user, Permission: permission, View: view, - Personal: personal, } } diff --git a/internal/helpers/captcha/cache.go b/internal/helpers/captcha/cache.go new file mode 100644 index 00000000..c2d08c95 --- /dev/null +++ b/internal/helpers/captcha/cache.go @@ -0,0 +1,63 @@ +// Package captcha implements the functions, types, and interfaces for the module. +package captcha + +import ( + "context" + "time" + + "github.com/mojocn/base64Captcha" + "github.com/origadmin/runtime/log" + + storageiface "github.com/origadmin/runtime/interfaces/storage" +) + +const ( + // captchaPrefix is the prefix for captcha keys in the cache. + captchaPrefix = "captcha:" + // defaultExpiration is the default expiration time for captcha keys. + defaultExpiration = 5 * time.Minute +) + +type store struct { + ctx context.Context + cache storageiface.Cache +} + +// NewStore creates a new captcha store backed by the provided storage.Cache. +// It holds a background context for cache operations. +func NewStore(cache storageiface.Cache) base64Captcha.Store { + return &store{ + ctx: context.Background(), + cache: cache, + } +} + +// Set stores the captcha value with a default expiration. +func (s *store) Set(id string, value string) error { + key := captchaPrefix + id + // The cache's Set method expects a string value. + return s.cache.Set(s.ctx, key, value, defaultExpiration) +} + +// Get retrieves the captcha value. +func (s *store) Get(id string, clear bool) string { + key := captchaPrefix + id + // The cache's Get method returns a string value. + val, err := s.cache.Get(s.ctx, key) + if err != nil { + log.Errorf("failed to get captcha from cache: %v", err) + return "" + } + if clear { + if err := s.cache.Delete(s.ctx, key); err != nil { + log.Errorf("failed to delete captcha from cache: %v", err) + } + } + return val +} + +// Verify verifies the captcha value. +func (s *store) Verify(id, answer string, clear bool) bool { + val := s.Get(id, clear) + return val == answer +} diff --git a/internal/helpers/captcha/captcha.go b/internal/helpers/captcha/captcha.go index 39566fec..7a239618 100644 --- a/internal/helpers/captcha/captcha.go +++ b/internal/helpers/captcha/captcha.go @@ -71,18 +71,9 @@ func NewCaptcha(config *Config) *Captcha { if config.DriverAudio == nil { config.DriverAudio = base64Captcha.DefaultDriverAudio } - //if config.DriverString == nil { - // config.DriverString = base64Captcha.DefaultDriverString - //} if config.DriverDigit == nil { config.DriverDigit = base64Captcha.DefaultDriverDigit } - if config.DriverChinese == nil { - //config.DriverChinese = base64Captcha.NewDriverChinese() - } - if config.DriverMath == nil { - //config.DriverMath = base64Captcha.NewDriverMath() - } return &Captcha{ DriverAudio: base64Captcha.NewCaptcha(config.DriverAudio, config.Store), DriverDigit: base64Captcha.NewCaptcha(config.DriverDigit, config.Store), @@ -106,30 +97,8 @@ func (c *Captcha) GenerateChinese() (string, string, string, error) { return c.DriverChinese.Generate() } -func (c *Captcha) ServerHTTP(w http.ResponseWriter, r *http.Request) { - -} +func (c *Captcha) ServerHTTP(w http.ResponseWriter, r *http.Request) {} func (c *Captcha) Verify(id, answer string, clear bool) bool { return c.Store.Verify(id, answer, clear) } - -func (c *Captcha) Reload(typ string, id string) bool { - if typ == TypeAudio { - return c.reload(c.DriverAudio.Driver, id) - } - return c.reload(c.DriverDigit.Driver, id) -} - -func (c *Captcha) reload(d base64Captcha.Driver, id string) bool { - old := c.Store.Get(id, false) - if old == "" { - return false - } - _, _, old = d.GenerateIdQuestionAnswer() - err := c.Store.Set(id, old) - if err != nil { - return false - } - return true -} diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go new file mode 100644 index 00000000..f6a8f3e1 --- /dev/null +++ b/internal/helpers/providers/providers.go @@ -0,0 +1,102 @@ +package providers + +import ( + "errors" + + "github.com/go-kratos/kratos/v2/log" + "github.com/google/wire" + + authnv1 "github.com/origadmin/contrib/api/gen/go/security/authn/v1" + "github.com/origadmin/contrib/security/authn/jwt" + "github.com/origadmin/contrib/security/credential" + "github.com/origadmin/runtime" + "github.com/origadmin/runtime/container" + "github.com/origadmin/toolkits/crypto/hash" + "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" + "github.com/origadmin/toolkits/crypto/hash/types" + "origadmin/application/admin/internal/conf" + confpb "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/helpers/captcha" +) + +// ProvideAuthenticatorOptions creates the JWT options from the application configuration. +func ProvideAuthenticatorOptions(c *conf.Config) (*jwt.Options, error) { + securityConfig := c.GetBootstrap().GetSecurity() + if securityConfig == nil { + return nil, errors.New("security configuration not found in bootstrap config") + } + authnConfig := securityConfig.GetAuthn() + if authnConfig == nil { + return nil, errors.New("authn configuration not found in security config") + } + configs := authnConfig.GetConfigs() + + var jwtConfig *authnv1.Authenticator + for _, mw := range configs { + if mw.GetType() == "jwt" { + jwtConfig = mw + break + } + } + if jwtConfig == nil || jwtConfig.GetJwt() == nil { + return nil, errors.New("JWT authenticator configuration not found in bootstrap config") + } + return jwt.NewOptions(jwtConfig) +} + +// ProvideCredentialCreator creates the JWT authenticator instance. +// It returns a credential.Creator interface, which is implemented by *jwt.Authenticator. +func ProvideCredentialCreator(opts *jwt.Options, logger log.Logger) (credential.Creator, error) { + return jwt.New(opts, logger) +} + +// ProvideAuthenticator creates the JWT authenticator instance. +// It returns a *jwt.Authenticator, which is needed by the AuthService. +func ProvideAuthenticator(opts *jwt.Options, logger log.Logger) (*jwt.Authenticator, error) { + return jwt.New(opts, logger) +} + +func ProvideCache(r *runtime.App) (container.CacheProvider, error) { + cacheProvider, err := r.CacheProvider() + if err != nil { + return nil, err + } + return cacheProvider, nil +} + +func ProvideCaptcha(p container.CacheProvider, cfg *confpb.Captcha) (*captcha.Captcha, error) { + cache, err := p.Cache(cfg.CacheName) + if err != nil { + return nil, err + } + + c := &captcha.Config{ + Store: captcha.NewStore(cache), + DriverDigit: &captcha.DriverDigit{ + Height: int(cfg.GetHeight()), + Width: int(cfg.GetWidth()), + Length: int(cfg.GetLength()), + MaxSkew: float64(cfg.GetMaxskew()), + DotCount: int(cfg.GetDotCount()), + }, + } + return captcha.NewCaptcha(c), nil +} + +func ProvideHasher() (hash.Crypto, error) { + return hash.NewCrypto(types.BCRYPT, bcrypt.WithCost(bcrypt.DefaultCost)) +} + +func ProvideLogger(app *runtime.App) log.Logger { + return app.Logger() +} + +var ProviderSet = wire.NewSet( + ProvideLogger, + ProvideCache, + ProvideAuthenticatorOptions, + ProvideCredentialCreator, + ProvideAuthenticator, + ProvideCaptcha, + ProvideHasher, +) diff --git a/test/token_test.go b/test/token_test.go index 44767ee3..40151e51 100644 --- a/test/token_test.go +++ b/test/token_test.go @@ -10,20 +10,23 @@ import ( "testing" "github.com/go-kratos/kratos/v2/encoding" - "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/interfaces/security" + + "github.com/origadmin/runtime" + sourcev1 "github.com/origadmin/runtime/api/gen/go/config/source/v1" + "github.com/origadmin/runtime/bootstrap" "github.com/origadmin/toolkits/codec/toml" - pb "origadmin/application/admin/api/v1/services/auth" _ "origadmin/application/admin/contrib/consul/config" _ "origadmin/application/admin/contrib/consul/registry" _ "origadmin/application/admin/contrib/database" "origadmin/application/admin/contrib/security/authz/casbin" "origadmin/application/admin/helpers/securityx" - "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/loader" - "origadmin/application/admin/internal/features/auth/dal" // Corrected import path + + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/features/auth/dal" // Corrected import path "origadmin/application/admin/internal/features/auth/service" // Corrected import path ) @@ -47,17 +50,12 @@ func init() { } func TestGenerateToken(t *testing.T) { - sourceConfig := &configv1.SourceConfig{ - Types: []string{"file"}, - File: &configv1.SourceConfig_File{ - Path: "..\\resources\\configs\\config_test.toml", - }, - } - bootstrap, err := loader.LoadBootstrap(sourceConfig) + + r := runtime.New("test", "v0.0.1") + err := r.Load("", bootstrap.WithDirectly()) if err != nil { - t.Fatalf("failed to load bootstrap: %v", err) + return } - r := runtime.Global() dataData, cleanup, err := data.NewData(r, bootstrap) if err != nil { return From c6e01b7319deee073b2163eb747ffec43018f685 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 30 Dec 2025 21:57:39 +0800 Subject: [PATCH 108/158] feat(auth): add RegisterResponse and LogoutResponse messages and rename Auth to AuthService --- api/v1/services/auth/auth.pb.go | 180 +++++++--- api/v1/services/auth/auth.pb.gw.go | 156 ++++---- api/v1/services/auth/auth.pb.validate.go | 200 +++++++++++ api/v1/services/auth/auth_bridge.pb.go | 264 +++++++------- api/v1/services/auth/auth_grpc.pb.go | 173 +++++---- api/v1/services/auth/auth_http.pb.go | 89 +++-- api/v1/services/auth/casbin_bridge.pb.go | 55 +-- api/v1/services/auth/me.pb.go | 241 ++++++++++--- api/v1/services/auth/me.pb.gw.go | 150 ++++---- api/v1/services/auth/me.pb.validate.go | 335 ++++++++++++++++++ api/v1/services/auth/me_bridge.pb.go | 252 +++++++------ api/v1/services/auth/me_grpc.pb.go | 162 +++++---- api/v1/services/auth/me_http.pb.go | 98 +++-- api/v1/services/datastore/datastore.pb.go | 3 +- .../services/datastore/datastore_bridge.pb.go | 122 +++---- api/v1/services/datastore/upload.pb.go | 77 ++-- api/v1/services/datastore/upload.pb.gw.go | 24 +- .../services/datastore/upload.pb.validate.go | 2 +- api/v1/services/datastore/upload_bridge.pb.go | 128 +++---- api/v1/services/datastore/upload_grpc.pb.go | 14 +- api/v1/services/datastore/upload_http.pb.go | 12 +- .../services/system/department_bridge.pb.go | 122 +++---- .../services/system/permission_bridge.pb.go | 122 +++---- api/v1/services/system/position_bridge.pb.go | 122 +++---- api/v1/services/system/resource_bridge.pb.go | 128 +++---- api/v1/services/system/role_bridge.pb.go | 122 +++---- api/v1/services/system/user_bridge.pb.go | 220 ++++++------ api/v1/services/types/message.pb.go | 3 +- resources/api-docs/openapi/openapi.yaml | 206 ++++++----- 29 files changed, 2283 insertions(+), 1499 deletions(-) diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index 40b6d4ec..ff86e900 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -10,7 +10,6 @@ import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" unsafe "unsafe" @@ -238,6 +237,43 @@ func (x *RegisterRequest) GetCaptchaCode() string { return "" } +// The response message for the Register RPC. +type RegisterResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RegisterResponse) Reset() { + *x = RegisterResponse{} + mi := &file_auth_auth_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RegisterResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RegisterResponse) ProtoMessage() {} + +func (x *RegisterResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[3] + 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 RegisterResponse.ProtoReflect.Descriptor instead. +func (*RegisterResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{3} +} + // The request message for the Logout RPC. type LogoutRequest struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -248,7 +284,7 @@ type LogoutRequest struct { func (x *LogoutRequest) Reset() { *x = LogoutRequest{} - mi := &file_auth_auth_proto_msgTypes[3] + mi := &file_auth_auth_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -260,7 +296,7 @@ func (x *LogoutRequest) String() string { func (*LogoutRequest) ProtoMessage() {} func (x *LogoutRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[3] + mi := &file_auth_auth_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -273,7 +309,7 @@ func (x *LogoutRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead. func (*LogoutRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{3} + return file_auth_auth_proto_rawDescGZIP(), []int{4} } func (x *LogoutRequest) GetRefreshToken() string { @@ -283,6 +319,43 @@ func (x *LogoutRequest) GetRefreshToken() string { return "" } +// The response message for the Logout RPC. +type LogoutResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LogoutResponse) Reset() { + *x = LogoutResponse{} + mi := &file_auth_auth_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LogoutResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LogoutResponse) ProtoMessage() {} + +func (x *LogoutResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_auth_proto_msgTypes[5] + 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 LogoutResponse.ProtoReflect.Descriptor instead. +func (*LogoutResponse) Descriptor() ([]byte, []int) { + return file_auth_auth_proto_rawDescGZIP(), []int{5} +} + // The request message for the RefreshToken RPC. type RefreshTokenRequest struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -293,7 +366,7 @@ type RefreshTokenRequest struct { func (x *RefreshTokenRequest) Reset() { *x = RefreshTokenRequest{} - mi := &file_auth_auth_proto_msgTypes[4] + mi := &file_auth_auth_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -305,7 +378,7 @@ func (x *RefreshTokenRequest) String() string { func (*RefreshTokenRequest) ProtoMessage() {} func (x *RefreshTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[4] + mi := &file_auth_auth_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -318,7 +391,7 @@ func (x *RefreshTokenRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RefreshTokenRequest.ProtoReflect.Descriptor instead. func (*RefreshTokenRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{4} + return file_auth_auth_proto_rawDescGZIP(), []int{6} } func (x *RefreshTokenRequest) GetRefreshToken() string { @@ -340,7 +413,7 @@ type RefreshTokenResponse struct { func (x *RefreshTokenResponse) Reset() { *x = RefreshTokenResponse{} - mi := &file_auth_auth_proto_msgTypes[5] + mi := &file_auth_auth_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -352,7 +425,7 @@ func (x *RefreshTokenResponse) String() string { func (*RefreshTokenResponse) ProtoMessage() {} func (x *RefreshTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[5] + mi := &file_auth_auth_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -365,7 +438,7 @@ func (x *RefreshTokenResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RefreshTokenResponse.ProtoReflect.Descriptor instead. func (*RefreshTokenResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{5} + return file_auth_auth_proto_rawDescGZIP(), []int{7} } func (x *RefreshTokenResponse) GetAccessToken() string { @@ -400,7 +473,7 @@ type GetCaptchaRequest struct { func (x *GetCaptchaRequest) Reset() { *x = GetCaptchaRequest{} - mi := &file_auth_auth_proto_msgTypes[6] + mi := &file_auth_auth_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -412,7 +485,7 @@ func (x *GetCaptchaRequest) String() string { func (*GetCaptchaRequest) ProtoMessage() {} func (x *GetCaptchaRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[6] + mi := &file_auth_auth_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -425,7 +498,7 @@ func (x *GetCaptchaRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetCaptchaRequest.ProtoReflect.Descriptor instead. func (*GetCaptchaRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{6} + return file_auth_auth_proto_rawDescGZIP(), []int{8} } func (x *GetCaptchaRequest) GetReload() bool { @@ -447,7 +520,7 @@ type GetCaptchaResponse struct { func (x *GetCaptchaResponse) Reset() { *x = GetCaptchaResponse{} - mi := &file_auth_auth_proto_msgTypes[7] + mi := &file_auth_auth_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -459,7 +532,7 @@ func (x *GetCaptchaResponse) String() string { func (*GetCaptchaResponse) ProtoMessage() {} func (x *GetCaptchaResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[7] + mi := &file_auth_auth_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -472,7 +545,7 @@ func (x *GetCaptchaResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetCaptchaResponse.ProtoReflect.Descriptor instead. func (*GetCaptchaResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{7} + return file_auth_auth_proto_rawDescGZIP(), []int{9} } func (x *GetCaptchaResponse) GetCaptchaId() string { @@ -501,7 +574,7 @@ type AuthenticateRequest struct { func (x *AuthenticateRequest) Reset() { *x = AuthenticateRequest{} - mi := &file_auth_auth_proto_msgTypes[8] + mi := &file_auth_auth_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -513,7 +586,7 @@ func (x *AuthenticateRequest) String() string { func (*AuthenticateRequest) ProtoMessage() {} func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[8] + mi := &file_auth_auth_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -526,7 +599,7 @@ func (x *AuthenticateRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthenticateRequest.ProtoReflect.Descriptor instead. func (*AuthenticateRequest) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{8} + return file_auth_auth_proto_rawDescGZIP(), []int{10} } func (x *AuthenticateRequest) GetToken() string { @@ -561,7 +634,7 @@ type AuthenticateResponse struct { func (x *AuthenticateResponse) Reset() { *x = AuthenticateResponse{} - mi := &file_auth_auth_proto_msgTypes[9] + mi := &file_auth_auth_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -573,7 +646,7 @@ func (x *AuthenticateResponse) String() string { func (*AuthenticateResponse) ProtoMessage() {} func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_auth_proto_msgTypes[9] + mi := &file_auth_auth_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -586,7 +659,7 @@ func (x *AuthenticateResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthenticateResponse.ProtoReflect.Descriptor instead. func (*AuthenticateResponse) Descriptor() ([]byte, []int) { - return file_auth_auth_proto_rawDescGZIP(), []int{9} + return file_auth_auth_proto_rawDescGZIP(), []int{11} } func (x *AuthenticateResponse) GetAuthorized() bool { @@ -607,7 +680,7 @@ var File_auth_auth_proto protoreflect.FileDescriptor const file_auth_auth_proto_rawDesc = "" + "\n" + - "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x88\x01\n" + + "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\"\x88\x01\n" + "\fLoginRequest\x12\x1a\n" + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x1d\n" + @@ -627,9 +700,11 @@ const file_auth_auth_proto_rawDesc = "" + "\x05email\x18\x03 \x01(\tR\x05email\x12\x1d\n" + "\n" + "captcha_id\x18\x04 \x01(\tR\tcaptchaId\x12!\n" + - "\fcaptcha_code\x18\x05 \x01(\tR\vcaptchaCode\"4\n" + + "\fcaptcha_code\x18\x05 \x01(\tR\vcaptchaCode\"\x12\n" + + "\x10RegisterResponse\"4\n" + "\rLogoutRequest\x12#\n" + - "\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\":\n" + + "\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\"\x10\n" + + "\x0eLogoutResponse\":\n" + "\x13RefreshTokenRequest\x12#\n" + "\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\"w\n" + "\x14RefreshTokenResponse\x12!\n" + @@ -652,11 +727,11 @@ const file_auth_auth_proto_rawDesc = "" + "\n" + "authorized\x18\x01 \x01(\bR\n" + "authorized\x12\x17\n" + - "\auser_id\x18\x02 \x01(\tR\x06userId2\xb3\x05\n" + - "\x04Auth\x12o\n" + - "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v1/auth/login\x12k\n" + - "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a\x16.google.protobuf.Empty\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/v1/auth/register\x12e\n" + - "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a\x16.google.protobuf.Empty\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/api/v1/auth/logout\x12\x84\x01\n" + + "\auser_id\x18\x02 \x01(\tR\x06userId2\xd8\x05\n" + + "\vAuthService\x12o\n" + + "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v1/auth/login\x12{\n" + + "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a&.api.v1.services.auth.RegisterResponse\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/v1/auth/register\x12s\n" + + "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/api/v1/auth/logout\x12\x84\x01\n" + "\fRefreshToken\x12).api.v1.services.auth.RefreshTokenRequest\x1a*.api.v1.services.auth.RefreshTokenResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v1/auth/token\x12x\n" + "\n" + "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/api/v1/captcha\x12e\n" + @@ -675,33 +750,34 @@ func file_auth_auth_proto_rawDescGZIP() []byte { return file_auth_auth_proto_rawDescData } -var file_auth_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_auth_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_auth_auth_proto_goTypes = []any{ (*LoginRequest)(nil), // 0: api.v1.services.auth.LoginRequest (*LoginResponse)(nil), // 1: api.v1.services.auth.LoginResponse (*RegisterRequest)(nil), // 2: api.v1.services.auth.RegisterRequest - (*LogoutRequest)(nil), // 3: api.v1.services.auth.LogoutRequest - (*RefreshTokenRequest)(nil), // 4: api.v1.services.auth.RefreshTokenRequest - (*RefreshTokenResponse)(nil), // 5: api.v1.services.auth.RefreshTokenResponse - (*GetCaptchaRequest)(nil), // 6: api.v1.services.auth.GetCaptchaRequest - (*GetCaptchaResponse)(nil), // 7: api.v1.services.auth.GetCaptchaResponse - (*AuthenticateRequest)(nil), // 8: api.v1.services.auth.AuthenticateRequest - (*AuthenticateResponse)(nil), // 9: api.v1.services.auth.AuthenticateResponse - (*emptypb.Empty)(nil), // 10: google.protobuf.Empty + (*RegisterResponse)(nil), // 3: api.v1.services.auth.RegisterResponse + (*LogoutRequest)(nil), // 4: api.v1.services.auth.LogoutRequest + (*LogoutResponse)(nil), // 5: api.v1.services.auth.LogoutResponse + (*RefreshTokenRequest)(nil), // 6: api.v1.services.auth.RefreshTokenRequest + (*RefreshTokenResponse)(nil), // 7: api.v1.services.auth.RefreshTokenResponse + (*GetCaptchaRequest)(nil), // 8: api.v1.services.auth.GetCaptchaRequest + (*GetCaptchaResponse)(nil), // 9: api.v1.services.auth.GetCaptchaResponse + (*AuthenticateRequest)(nil), // 10: api.v1.services.auth.AuthenticateRequest + (*AuthenticateResponse)(nil), // 11: api.v1.services.auth.AuthenticateResponse } var file_auth_auth_proto_depIdxs = []int32{ - 0, // 0: api.v1.services.auth.Auth.Login:input_type -> api.v1.services.auth.LoginRequest - 2, // 1: api.v1.services.auth.Auth.Register:input_type -> api.v1.services.auth.RegisterRequest - 3, // 2: api.v1.services.auth.Auth.Logout:input_type -> api.v1.services.auth.LogoutRequest - 4, // 3: api.v1.services.auth.Auth.RefreshToken:input_type -> api.v1.services.auth.RefreshTokenRequest - 6, // 4: api.v1.services.auth.Auth.GetCaptcha:input_type -> api.v1.services.auth.GetCaptchaRequest - 8, // 5: api.v1.services.auth.Auth.Authenticate:input_type -> api.v1.services.auth.AuthenticateRequest - 1, // 6: api.v1.services.auth.Auth.Login:output_type -> api.v1.services.auth.LoginResponse - 10, // 7: api.v1.services.auth.Auth.Register:output_type -> google.protobuf.Empty - 10, // 8: api.v1.services.auth.Auth.Logout:output_type -> google.protobuf.Empty - 5, // 9: api.v1.services.auth.Auth.RefreshToken:output_type -> api.v1.services.auth.RefreshTokenResponse - 7, // 10: api.v1.services.auth.Auth.GetCaptcha:output_type -> api.v1.services.auth.GetCaptchaResponse - 9, // 11: api.v1.services.auth.Auth.Authenticate:output_type -> api.v1.services.auth.AuthenticateResponse + 0, // 0: api.v1.services.auth.AuthService.Login:input_type -> api.v1.services.auth.LoginRequest + 2, // 1: api.v1.services.auth.AuthService.Register:input_type -> api.v1.services.auth.RegisterRequest + 4, // 2: api.v1.services.auth.AuthService.Logout:input_type -> api.v1.services.auth.LogoutRequest + 6, // 3: api.v1.services.auth.AuthService.RefreshToken:input_type -> api.v1.services.auth.RefreshTokenRequest + 8, // 4: api.v1.services.auth.AuthService.GetCaptcha:input_type -> api.v1.services.auth.GetCaptchaRequest + 10, // 5: api.v1.services.auth.AuthService.Authenticate:input_type -> api.v1.services.auth.AuthenticateRequest + 1, // 6: api.v1.services.auth.AuthService.Login:output_type -> api.v1.services.auth.LoginResponse + 3, // 7: api.v1.services.auth.AuthService.Register:output_type -> api.v1.services.auth.RegisterResponse + 5, // 8: api.v1.services.auth.AuthService.Logout:output_type -> api.v1.services.auth.LogoutResponse + 7, // 9: api.v1.services.auth.AuthService.RefreshToken:output_type -> api.v1.services.auth.RefreshTokenResponse + 9, // 10: api.v1.services.auth.AuthService.GetCaptcha:output_type -> api.v1.services.auth.GetCaptchaResponse + 11, // 11: api.v1.services.auth.AuthService.Authenticate:output_type -> api.v1.services.auth.AuthenticateResponse 6, // [6:12] is the sub-list for method output_type 0, // [0:6] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -720,7 +796,7 @@ func file_auth_auth_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_auth_proto_rawDesc), len(file_auth_auth_proto_rawDesc)), NumEnums: 0, - NumMessages: 10, + NumMessages: 12, NumExtensions: 0, NumServices: 1, }, diff --git a/api/v1/services/auth/auth.pb.gw.go b/api/v1/services/auth/auth.pb.gw.go index cc30ddbd..c5716b4e 100644 --- a/api/v1/services/auth/auth.pb.gw.go +++ b/api/v1/services/auth/auth.pb.gw.go @@ -35,7 +35,7 @@ var ( _ = metadata.Join ) -func request_Auth_Login_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_AuthService_Login_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq LoginRequest metadata runtime.ServerMetadata @@ -47,7 +47,7 @@ func request_Auth_Login_0(ctx context.Context, marshaler runtime.Marshaler, clie return msg, metadata, err } -func local_request_Auth_Login_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_AuthService_Login_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq LoginRequest metadata runtime.ServerMetadata @@ -59,7 +59,7 @@ func local_request_Auth_Login_0(ctx context.Context, marshaler runtime.Marshaler return msg, metadata, err } -func request_Auth_Register_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_AuthService_Register_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq RegisterRequest metadata runtime.ServerMetadata @@ -71,7 +71,7 @@ func request_Auth_Register_0(ctx context.Context, marshaler runtime.Marshaler, c return msg, metadata, err } -func local_request_Auth_Register_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_AuthService_Register_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq RegisterRequest metadata runtime.ServerMetadata @@ -83,7 +83,7 @@ func local_request_Auth_Register_0(ctx context.Context, marshaler runtime.Marsha return msg, metadata, err } -func request_Auth_Logout_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_AuthService_Logout_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq LogoutRequest metadata runtime.ServerMetadata @@ -95,7 +95,7 @@ func request_Auth_Logout_0(ctx context.Context, marshaler runtime.Marshaler, cli return msg, metadata, err } -func local_request_Auth_Logout_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_AuthService_Logout_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq LogoutRequest metadata runtime.ServerMetadata @@ -107,7 +107,7 @@ func local_request_Auth_Logout_0(ctx context.Context, marshaler runtime.Marshale return msg, metadata, err } -func request_Auth_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_AuthService_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq RefreshTokenRequest metadata runtime.ServerMetadata @@ -119,7 +119,7 @@ func request_Auth_RefreshToken_0(ctx context.Context, marshaler runtime.Marshale return msg, metadata, err } -func local_request_Auth_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_AuthService_RefreshToken_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq RefreshTokenRequest metadata runtime.ServerMetadata @@ -131,9 +131,9 @@ func local_request_Auth_RefreshToken_0(ctx context.Context, marshaler runtime.Ma return msg, metadata, err } -var filter_Auth_GetCaptcha_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +var filter_AuthService_GetCaptcha_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -func request_Auth_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_AuthService_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetCaptchaRequest metadata runtime.ServerMetadata @@ -142,14 +142,14 @@ func request_Auth_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Auth_GetCaptcha_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_GetCaptcha_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.GetCaptcha(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Auth_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_AuthService_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetCaptchaRequest metadata runtime.ServerMetadata @@ -157,126 +157,126 @@ func local_request_Auth_GetCaptcha_0(ctx context.Context, marshaler runtime.Mars if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Auth_GetCaptcha_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_GetCaptcha_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.GetCaptcha(ctx, &protoReq) return msg, metadata, err } -// RegisterAuthHandlerServer registers the http handlers for service Auth to "mux". -// UnaryRPC :call AuthServer directly. +// RegisterAuthServiceHandlerServer registers the http handlers for service AuthService to "mux". +// UnaryRPC :call AuthServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterAuthHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServer) error { - mux.Handle(http.MethodPost, pattern_Auth_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { +func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServiceServer) error { + mux.Handle(http.MethodPost, pattern_AuthService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Auth/Login", runtime.WithHTTPPathPattern("/api/v1/auth/login")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Login", runtime.WithHTTPPathPattern("/api/v1/auth/login")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Auth_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_AuthService_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Auth_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_Auth_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_AuthService_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Auth/Register", runtime.WithHTTPPathPattern("/api/v1/auth/register")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Register", runtime.WithHTTPPathPattern("/api/v1/auth/register")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Auth_Register_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_AuthService_Register_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Auth_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_Auth_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_AuthService_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Auth/Logout", runtime.WithHTTPPathPattern("/api/v1/auth/logout")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Logout", runtime.WithHTTPPathPattern("/api/v1/auth/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Auth_Logout_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_AuthService_Logout_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Auth_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_Auth_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_AuthService_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Auth/RefreshToken", runtime.WithHTTPPathPattern("/api/v1/auth/token")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/api/v1/auth/token")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Auth_RefreshToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_AuthService_RefreshToken_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Auth_RefreshToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_RefreshToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_Auth_GetCaptcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_AuthService_GetCaptcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Auth/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Auth_GetCaptcha_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_AuthService_GetCaptcha_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Auth_GetCaptcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_GetCaptcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } -// RegisterAuthHandlerFromEndpoint is same as RegisterAuthHandler but +// RegisterAuthServiceHandlerFromEndpoint is same as RegisterAuthServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterAuthHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { +func RegisterAuthServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err @@ -295,121 +295,121 @@ func RegisterAuthHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, } }() }() - return RegisterAuthHandler(ctx, mux, conn) + return RegisterAuthServiceHandler(ctx, mux, conn) } -// RegisterAuthHandler registers the http handlers for service Auth to "mux". +// RegisterAuthServiceHandler registers the http handlers for service AuthService to "mux". // The handlers forward requests to the grpc endpoint over "conn". -func RegisterAuthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterAuthHandlerClient(ctx, mux, NewAuthClient(conn)) +func RegisterAuthServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterAuthServiceHandlerClient(ctx, mux, NewAuthServiceClient(conn)) } -// RegisterAuthHandlerClient registers the http handlers for service Auth -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AuthClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AuthClient" +// RegisterAuthServiceHandlerClient registers the http handlers for service AuthService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AuthServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AuthServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "AuthClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterAuthHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthClient) error { - mux.Handle(http.MethodPost, pattern_Auth_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { +// "AuthServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthServiceClient) error { + mux.Handle(http.MethodPost, pattern_AuthService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Auth/Login", runtime.WithHTTPPathPattern("/api/v1/auth/login")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Login", runtime.WithHTTPPathPattern("/api/v1/auth/login")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Auth_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_AuthService_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Auth_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_Auth_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_AuthService_Register_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Auth/Register", runtime.WithHTTPPathPattern("/api/v1/auth/register")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Register", runtime.WithHTTPPathPattern("/api/v1/auth/register")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Auth_Register_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_AuthService_Register_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Auth_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_Register_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_Auth_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_AuthService_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Auth/Logout", runtime.WithHTTPPathPattern("/api/v1/auth/logout")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Logout", runtime.WithHTTPPathPattern("/api/v1/auth/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Auth_Logout_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_AuthService_Logout_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Auth_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_Auth_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_AuthService_RefreshToken_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Auth/RefreshToken", runtime.WithHTTPPathPattern("/api/v1/auth/token")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/api/v1/auth/token")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Auth_RefreshToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_AuthService_RefreshToken_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Auth_RefreshToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_RefreshToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_Auth_GetCaptcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_AuthService_GetCaptcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Auth/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Auth_GetCaptcha_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_AuthService_GetCaptcha_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Auth_GetCaptcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_GetCaptcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( - pattern_Auth_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "login"}, "")) - pattern_Auth_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "register"}, "")) - pattern_Auth_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "logout"}, "")) - pattern_Auth_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "token"}, "")) - pattern_Auth_GetCaptcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "captcha"}, "")) + pattern_AuthService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "login"}, "")) + pattern_AuthService_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "register"}, "")) + pattern_AuthService_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "logout"}, "")) + pattern_AuthService_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "token"}, "")) + pattern_AuthService_GetCaptcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "captcha"}, "")) ) var ( - forward_Auth_Login_0 = runtime.ForwardResponseMessage - forward_Auth_Register_0 = runtime.ForwardResponseMessage - forward_Auth_Logout_0 = runtime.ForwardResponseMessage - forward_Auth_RefreshToken_0 = runtime.ForwardResponseMessage - forward_Auth_GetCaptcha_0 = runtime.ForwardResponseMessage + forward_AuthService_Login_0 = runtime.ForwardResponseMessage + forward_AuthService_Register_0 = runtime.ForwardResponseMessage + forward_AuthService_Logout_0 = runtime.ForwardResponseMessage + forward_AuthService_RefreshToken_0 = runtime.ForwardResponseMessage + forward_AuthService_GetCaptcha_0 = runtime.ForwardResponseMessage ) diff --git a/api/v1/services/auth/auth.pb.validate.go b/api/v1/services/auth/auth.pb.validate.go index 8e45ad1a..96525455 100644 --- a/api/v1/services/auth/auth.pb.validate.go +++ b/api/v1/services/auth/auth.pb.validate.go @@ -360,6 +360,106 @@ var _ interface { ErrorName() string } = RegisterRequestValidationError{} +// Validate checks the field values on RegisterResponse 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 *RegisterResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on RegisterResponse 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 +// RegisterResponseMultiError, or nil if none found. +func (m *RegisterResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *RegisterResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return RegisterResponseMultiError(errors) + } + + return nil +} + +// RegisterResponseMultiError is an error wrapping multiple validation errors +// returned by RegisterResponse.ValidateAll() if the designated constraints +// aren't met. +type RegisterResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m RegisterResponseMultiError) 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 RegisterResponseMultiError) AllErrors() []error { return m } + +// RegisterResponseValidationError is the validation error returned by +// RegisterResponse.Validate if the designated constraints aren't met. +type RegisterResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e RegisterResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e RegisterResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e RegisterResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e RegisterResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e RegisterResponseValidationError) ErrorName() string { return "RegisterResponseValidationError" } + +// Error satisfies the builtin error interface +func (e RegisterResponseValidationError) 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 %sRegisterResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = RegisterResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = RegisterResponseValidationError{} + // Validate checks the field values on LogoutRequest 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. @@ -462,6 +562,106 @@ var _ interface { ErrorName() string } = LogoutRequestValidationError{} +// Validate checks the field values on LogoutResponse 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 *LogoutResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on LogoutResponse 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 LogoutResponseMultiError, +// or nil if none found. +func (m *LogoutResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *LogoutResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return LogoutResponseMultiError(errors) + } + + return nil +} + +// LogoutResponseMultiError is an error wrapping multiple validation errors +// returned by LogoutResponse.ValidateAll() if the designated constraints +// aren't met. +type LogoutResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m LogoutResponseMultiError) 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 LogoutResponseMultiError) AllErrors() []error { return m } + +// LogoutResponseValidationError is the validation error returned by +// LogoutResponse.Validate if the designated constraints aren't met. +type LogoutResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e LogoutResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e LogoutResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e LogoutResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e LogoutResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e LogoutResponseValidationError) ErrorName() string { return "LogoutResponseValidationError" } + +// Error satisfies the builtin error interface +func (e LogoutResponseValidationError) 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 %sLogoutResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = LogoutResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = LogoutResponseValidationError{} + // Validate checks the field values on RefreshTokenRequest 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/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index b475b4a8..918de030 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -12,7 +12,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - emptypb "google.golang.org/protobuf/types/known/emptypb" io "io" ) @@ -29,68 +28,77 @@ var ( _ = codes.Unimplemented ) -const AuthGetCaptchaBridgeOperation = "/api.v1.services.auth.Auth/GetCaptcha" -const AuthLoginBridgeOperation = "/api.v1.services.auth.Auth/Login" -const AuthLogoutBridgeOperation = "/api.v1.services.auth.Auth/Logout" -const AuthRefreshTokenBridgeOperation = "/api.v1.services.auth.Auth/RefreshToken" -const AuthRegisterBridgeOperation = "/api.v1.services.auth.Auth/Register" +const AuthServiceLoginBridgeOperation = "/api.v1.services.auth.AuthService/Login" +const AuthServiceRegisterBridgeOperation = "/api.v1.services.auth.AuthService/Register" +const AuthServiceLogoutBridgeOperation = "/api.v1.services.auth.AuthService/Logout" +const AuthServiceRefreshTokenBridgeOperation = "/api.v1.services.auth.AuthService/RefreshToken" +const AuthServiceGetCaptchaBridgeOperation = "/api.v1.services.auth.AuthService/GetCaptcha" +const AuthServiceAuthenticateBridgeOperation = "/api.v1.services.auth.AuthService/Authenticate" -type AuthBridgeServer interface { - // GetCaptcha generates a new captcha. - GetCaptcha(context.Context, *GetCaptchaRequest) (*GetCaptchaResponse, error) +type AuthServiceBridgeServer interface { // Login authenticates a user and returns a token pair. Login(context.Context, *LoginRequest) (*LoginResponse, error) + // Register creates a new user account. + Register(context.Context, *RegisterRequest) (*RegisterResponse, error) // Logout invalidates the user's session. - Logout(context.Context, *LogoutRequest) (*emptypb.Empty, error) + Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) // RefreshToken provides a new access token. RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) - // Register creates a new user account. - Register(context.Context, *RegisterRequest) (*emptypb.Empty, error) + // GetCaptcha generates a new captcha. + GetCaptcha(context.Context, *GetCaptchaRequest) (*GetCaptchaResponse, error) + // Authenticate is for internal use by the gateway to verify user access via gRPC. + // It does not have an HTTP binding. + Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) } -type AuthHooker interface { - AuthGetCaptchaHooker - AuthLoginHooker - AuthLogoutHooker - AuthRefreshTokenHooker - AuthRegisterHooker +type AuthServiceHooker interface { + AuthServiceLoginHooker + AuthServiceRegisterHooker + AuthServiceLogoutHooker + AuthServiceRefreshTokenHooker + AuthServiceGetCaptchaHooker + AuthServiceAuthenticateHooker } -type AuthHookedBridger interface { - AuthHooker - AuthBridgeServer +type AuthServiceHookedBridger interface { + AuthServiceHooker + AuthServiceBridgeServer } -type AuthGetCaptchaHooker interface { - PrepareGetCaptcha(http.Context, *GetCaptchaRequest) (context.Context, error) - CompleteGetCaptcha(http.Context, *GetCaptchaRequest, *GetCaptchaResponse) error -} -type AuthLoginHooker interface { +type AuthServiceLoginHooker interface { PrepareLogin(http.Context, *LoginRequest) (context.Context, error) CompleteLogin(http.Context, *LoginRequest, *LoginResponse) error } -type AuthLogoutHooker interface { +type AuthServiceRegisterHooker interface { + PrepareRegister(http.Context, *RegisterRequest) (context.Context, error) + CompleteRegister(http.Context, *RegisterRequest, *RegisterResponse) error +} +type AuthServiceLogoutHooker interface { PrepareLogout(http.Context, *LogoutRequest) (context.Context, error) - CompleteLogout(http.Context, *LogoutRequest, *emptypb.Empty) error + CompleteLogout(http.Context, *LogoutRequest, *LogoutResponse) error } -type AuthRefreshTokenHooker interface { +type AuthServiceRefreshTokenHooker interface { PrepareRefreshToken(http.Context, *RefreshTokenRequest) (context.Context, error) CompleteRefreshToken(http.Context, *RefreshTokenRequest, *RefreshTokenResponse) error } -type AuthRegisterHooker interface { - PrepareRegister(http.Context, *RegisterRequest) (context.Context, error) - CompleteRegister(http.Context, *RegisterRequest, *emptypb.Empty) error +type AuthServiceGetCaptchaHooker interface { + PrepareGetCaptcha(http.Context, *GetCaptchaRequest) (context.Context, error) + CompleteGetCaptcha(http.Context, *GetCaptchaRequest, *GetCaptchaResponse) error +} +type AuthServiceAuthenticateHooker interface { + PrepareAuthenticate(http.Context, *AuthenticateRequest) (context.Context, error) + CompleteAuthenticate(http.Context, *AuthenticateRequest, *AuthenticateResponse) error } -func RegisterAuthBridgeServer(s *http.Server, srv AuthHookedBridger) { +func RegisterAuthServiceBridgeServer(s *http.Server, srv AuthServiceHookedBridger) { r := s.Route("/") - r.POST("/api/v1/auth/login", _Auth_Login0_Bridge_Handler(srv)) - r.POST("/api/v1/auth/register", _Auth_Register0_Bridge_Handler(srv)) - r.POST("/api/v1/auth/logout", _Auth_Logout0_Bridge_Handler(srv)) - r.POST("/api/v1/auth/token", _Auth_RefreshToken0_Bridge_Handler(srv)) - r.GET("/api/v1/captcha", _Auth_GetCaptcha0_Bridge_Handler(srv)) + r.POST("/api/v1/auth/login", _AuthService_Login0_Bridge_Handler(srv)) + r.POST("/api/v1/auth/register", _AuthService_Register0_Bridge_Handler(srv)) + r.POST("/api/v1/auth/logout", _AuthService_Logout0_Bridge_Handler(srv)) + r.POST("/api/v1/auth/token", _AuthService_RefreshToken0_Bridge_Handler(srv)) + r.GET("/api/v1/captcha", _AuthService_GetCaptcha0_Bridge_Handler(srv)) } -func _Auth_Login0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) error { +func _AuthService_Login0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in LoginRequest if err := ctx.Bind(&in); err != nil { @@ -99,7 +107,7 @@ func _Auth_Login0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) e if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthLogin) + http.SetOperation(ctx, OperationAuthServiceLogin) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Login(ctx, req.(*LoginRequest)) }) @@ -116,7 +124,7 @@ func _Auth_Login0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) e } } -func _Auth_Register0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) error { +func _AuthService_Register0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in RegisterRequest if err := ctx.Bind(&in); err != nil { @@ -125,7 +133,7 @@ func _Auth_Register0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthRegister) + http.SetOperation(ctx, OperationAuthServiceRegister) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Register(ctx, req.(*RegisterRequest)) }) @@ -138,11 +146,11 @@ func _Auth_Register0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context if err != nil { return err } - return srv.CompleteRegister(ctx, &in, out.(*emptypb.Empty)) + return srv.CompleteRegister(ctx, &in, out.(*RegisterResponse)) } } -func _Auth_Logout0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) error { +func _AuthService_Logout0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in LogoutRequest if err := ctx.Bind(&in); err != nil { @@ -151,7 +159,7 @@ func _Auth_Logout0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthLogout) + http.SetOperation(ctx, OperationAuthServiceLogout) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Logout(ctx, req.(*LogoutRequest)) }) @@ -164,11 +172,11 @@ func _Auth_Logout0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) if err != nil { return err } - return srv.CompleteLogout(ctx, &in, out.(*emptypb.Empty)) + return srv.CompleteLogout(ctx, &in, out.(*LogoutResponse)) } } -func _Auth_RefreshToken0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) error { +func _AuthService_RefreshToken0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in RefreshTokenRequest if err := ctx.Bind(&in); err != nil { @@ -177,7 +185,7 @@ func _Auth_RefreshToken0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Con if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthRefreshToken) + http.SetOperation(ctx, OperationAuthServiceRefreshToken) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.RefreshToken(ctx, req.(*RefreshTokenRequest)) }) @@ -194,13 +202,13 @@ func _Auth_RefreshToken0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Con } } -func _Auth_GetCaptcha0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Context) error { +func _AuthService_GetCaptcha0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetCaptchaRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthGetCaptcha) + http.SetOperation(ctx, OperationAuthServiceGetCaptcha) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.GetCaptcha(ctx, req.(*GetCaptchaRequest)) }) @@ -217,179 +225,195 @@ func _Auth_GetCaptcha0_Bridge_Handler(srv AuthHookedBridger) func(ctx http.Conte } } -// UnimplementedAuthHooked must be embedded to have +// UnimplementedAuthServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedAuthHooked struct{} +type UnimplementedAuthServiceHooked struct{} + +func (UnimplementedAuthServiceHooked) PrepareLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedAuthServiceHooked) CompleteLogin(ctx http.Context, in *LoginRequest, out *LoginResponse) error { + return ctx.Result(200, out) +} -func (UnimplementedAuthHooked) PrepareGetCaptcha(ctx http.Context, in *GetCaptchaRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthHooked) CompleteGetCaptcha(ctx http.Context, in *GetCaptchaRequest, out *GetCaptchaResponse) error { +func (UnimplementedAuthServiceHooked) CompleteRegister(ctx http.Context, in *RegisterRequest, out *RegisterResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthHooked) PrepareLogin(ctx http.Context, in *LoginRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthHooked) CompleteLogin(ctx http.Context, in *LoginRequest, out *LoginResponse) error { +func (UnimplementedAuthServiceHooked) CompleteLogout(ctx http.Context, in *LogoutRequest, out *LogoutResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthHooked) PrepareLogout(ctx http.Context, in *LogoutRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareRefreshToken(ctx http.Context, in *RefreshTokenRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthHooked) CompleteLogout(ctx http.Context, in *LogoutRequest, out *emptypb.Empty) error { +func (UnimplementedAuthServiceHooked) CompleteRefreshToken(ctx http.Context, in *RefreshTokenRequest, out *RefreshTokenResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthHooked) PrepareRefreshToken(ctx http.Context, in *RefreshTokenRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareGetCaptcha(ctx http.Context, in *GetCaptchaRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthHooked) CompleteRefreshToken(ctx http.Context, in *RefreshTokenRequest, out *RefreshTokenResponse) error { +func (UnimplementedAuthServiceHooked) CompleteGetCaptcha(ctx http.Context, in *GetCaptchaRequest, out *GetCaptchaResponse) error { return ctx.Result(200, out) } -func (UnimplementedAuthHooked) PrepareRegister(ctx http.Context, in *RegisterRequest) (context.Context, error) { +func (UnimplementedAuthServiceHooked) PrepareAuthenticate(ctx http.Context, in *AuthenticateRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedAuthHooked) CompleteRegister(ctx http.Context, in *RegisterRequest, out *emptypb.Empty) error { +func (UnimplementedAuthServiceHooked) CompleteAuthenticate(ctx http.Context, in *AuthenticateRequest, out *AuthenticateResponse) error { return ctx.Result(200, out) } -func WithAuthHook(h AuthHooker) func(AuthBridgeServer) AuthHookedBridger { - return func(srv AuthBridgeServer) AuthHookedBridger { - return AuthHookedBridge{AuthBridgeServer: srv, AuthHooker: h} +func WithAuthServiceHook(h AuthServiceHooker) func(AuthServiceBridgeServer) AuthServiceHookedBridger { + return func(srv AuthServiceBridgeServer) AuthServiceHookedBridger { + return AuthServiceHookedBridge{AuthServiceBridgeServer: srv, AuthServiceHooker: h} } } -// AuthHookedBridge is a bridge between the HTTP and gRPC implementations of Auth. -// It implements the HTTP and gRPC implementations of Auth. +// AuthServiceHookedBridge is a bridge between the HTTP and gRPC implementations of AuthService. +// It implements the HTTP and gRPC implementations of AuthService. // It forwards requests and responses between the two implementations. -type AuthHookedBridge struct { - AuthBridgeServer - AuthHooker +type AuthServiceHookedBridge struct { + AuthServiceBridgeServer + AuthServiceHooker } -type AuthHTTPBridgeImpl struct { - client AuthHTTPClient +type AuthServiceHTTPBridgeImpl struct { + client AuthServiceHTTPClient } -func NewAuthHTTPBridge(client *http.Client) AuthHTTPServer { - return &AuthHTTPBridgeImpl{client: NewAuthHTTPClient(client)} +func NewAuthServiceHTTPBridge(client *http.Client) AuthServiceHTTPServer { + return &AuthServiceHTTPBridgeImpl{client: NewAuthServiceHTTPClient(client)} } -func (c *AuthHTTPBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { - return c.client.GetCaptcha(ctx, in) +func (c *AuthServiceHTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) } -func (c *AuthHTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) +func (c *AuthServiceHTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) } -func (c *AuthHTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*emptypb.Empty, error) { +func (c *AuthServiceHTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { return c.client.Logout(ctx, in) } -func (c *AuthHTTPBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { +func (c *AuthServiceHTTPBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { return c.client.RefreshToken(ctx, in) } -func (c *AuthHTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*emptypb.Empty, error) { - return c.client.Register(ctx, in) +func (c *AuthServiceHTTPBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) } -type AuthBridgeImpl struct { - client AuthClient +type AuthServiceBridgeImpl struct { + client AuthServiceClient } -func NewAuthBridge(client grpc.ClientConnInterface) AuthServer { - return &AuthBridgeImpl{client: NewAuthClient(client)} +func NewAuthServiceBridge(client grpc.ClientConnInterface) AuthServiceServer { + return &AuthServiceBridgeImpl{client: NewAuthServiceClient(client)} } -func (c *AuthBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { - return c.client.GetCaptcha(ctx, in) +func (c *AuthServiceBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) } -func (c *AuthBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) +func (c *AuthServiceBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) } -func (c *AuthBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*emptypb.Empty, error) { +func (c *AuthServiceBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { return c.client.Logout(ctx, in) } -func (c *AuthBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { +func (c *AuthServiceBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { return c.client.RefreshToken(ctx, in) } -func (c *AuthBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*emptypb.Empty, error) { - return c.client.Register(ctx, in) +func (c *AuthServiceBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) } -func (c *AuthBridgeImpl) mustEmbedUnimplementedAuthServer() {} - -type AuthGRPC2HTTPBridgeImpl struct { - client AuthClient +func (c *AuthServiceBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") } -func NewAuthGRPC2HTTP(client grpc.ClientConnInterface) AuthHTTPServer { - return &AuthGRPC2HTTPBridgeImpl{client: NewAuthClient(client)} +func (c *AuthServiceBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} + +type AuthServiceGRPC2HTTPBridgeImpl struct { + client AuthServiceClient } -func (c *AuthGRPC2HTTPBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { - return c.client.GetCaptcha(ctx, in) +func NewAuthServiceGRPC2HTTP(client grpc.ClientConnInterface) AuthServiceHTTPServer { + return &AuthServiceGRPC2HTTPBridgeImpl{client: NewAuthServiceClient(client)} } -func (c *AuthGRPC2HTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { +func (c *AuthServiceGRPC2HTTPBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { return c.client.Login(ctx, in) } -func (c *AuthGRPC2HTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*emptypb.Empty, error) { +func (c *AuthServiceGRPC2HTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) +} + +func (c *AuthServiceGRPC2HTTPBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { return c.client.Logout(ctx, in) } -func (c *AuthGRPC2HTTPBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { +func (c *AuthServiceGRPC2HTTPBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { return c.client.RefreshToken(ctx, in) } -func (c *AuthGRPC2HTTPBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*emptypb.Empty, error) { - return c.client.Register(ctx, in) +func (c *AuthServiceGRPC2HTTPBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) } -type AuthHTTP2GRPCBridgeImpl struct { - client AuthHTTPClient +type AuthServiceHTTP2GRPCBridgeImpl struct { + client AuthServiceHTTPClient } -func NewAuthHTTP2GRPC(client *http.Client) AuthServer { - return &AuthHTTP2GRPCBridgeImpl{client: NewAuthHTTPClient(client)} +func NewAuthServiceHTTP2GRPC(client *http.Client) AuthServiceServer { + return &AuthServiceHTTP2GRPCBridgeImpl{client: NewAuthServiceHTTPClient(client)} } -func (c *AuthHTTP2GRPCBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { - return c.client.GetCaptcha(ctx, in) +func (c *AuthServiceHTTP2GRPCBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { + return c.client.Login(ctx, in) } -func (c *AuthHTTP2GRPCBridgeImpl) Login(ctx context.Context, in *LoginRequest) (*LoginResponse, error) { - return c.client.Login(ctx, in) +func (c *AuthServiceHTTP2GRPCBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*RegisterResponse, error) { + return c.client.Register(ctx, in) } -func (c *AuthHTTP2GRPCBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*emptypb.Empty, error) { +func (c *AuthServiceHTTP2GRPCBridgeImpl) Logout(ctx context.Context, in *LogoutRequest) (*LogoutResponse, error) { return c.client.Logout(ctx, in) } -func (c *AuthHTTP2GRPCBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { +func (c *AuthServiceHTTP2GRPCBridgeImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest) (*RefreshTokenResponse, error) { return c.client.RefreshToken(ctx, in) } -func (c *AuthHTTP2GRPCBridgeImpl) Register(ctx context.Context, in *RegisterRequest) (*emptypb.Empty, error) { - return c.client.Register(ctx, in) +func (c *AuthServiceHTTP2GRPCBridgeImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest) (*GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) +} + +func (c *AuthServiceHTTP2GRPCBridgeImpl) Authenticate(ctx context.Context, in *AuthenticateRequest) (*AuthenticateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") } -func (c *AuthHTTP2GRPCBridgeImpl) mustEmbedUnimplementedAuthServer() {} +func (c *AuthServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedAuthServiceServer() {} diff --git a/api/v1/services/auth/auth_grpc.pb.go b/api/v1/services/auth/auth_grpc.pb.go index bbd6fba9..3976aad5 100644 --- a/api/v1/services/auth/auth_grpc.pb.go +++ b/api/v1/services/auth/auth_grpc.pb.go @@ -11,7 +11,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -20,26 +19,26 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - Auth_Login_FullMethodName = "/api.v1.services.auth.Auth/Login" - Auth_Register_FullMethodName = "/api.v1.services.auth.Auth/Register" - Auth_Logout_FullMethodName = "/api.v1.services.auth.Auth/Logout" - Auth_RefreshToken_FullMethodName = "/api.v1.services.auth.Auth/RefreshToken" - Auth_GetCaptcha_FullMethodName = "/api.v1.services.auth.Auth/GetCaptcha" - Auth_Authenticate_FullMethodName = "/api.v1.services.auth.Auth/Authenticate" + AuthService_Login_FullMethodName = "/api.v1.services.auth.AuthService/Login" + AuthService_Register_FullMethodName = "/api.v1.services.auth.AuthService/Register" + AuthService_Logout_FullMethodName = "/api.v1.services.auth.AuthService/Logout" + AuthService_RefreshToken_FullMethodName = "/api.v1.services.auth.AuthService/RefreshToken" + AuthService_GetCaptcha_FullMethodName = "/api.v1.services.auth.AuthService/GetCaptcha" + AuthService_Authenticate_FullMethodName = "/api.v1.services.auth.AuthService/Authenticate" ) -// AuthClient is the client API for Auth service. +// AuthServiceClient is the client API for AuthService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // -// Service Auth provides APIs for the authentication lifecycle. -type AuthClient interface { +// Service AuthService provides APIs for the authentication lifecycle. +type AuthServiceClient interface { // Login authenticates a user and returns a token pair. Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) // Register creates a new user account. - Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) // Logout invalidates the user's session. - Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) // RefreshToken provides a new access token. RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error) // GetCaptcha generates a new captcha. @@ -49,86 +48,86 @@ type AuthClient interface { Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) } -type authClient struct { +type authServiceClient struct { cc grpc.ClientConnInterface } -func NewAuthClient(cc grpc.ClientConnInterface) AuthClient { - return &authClient{cc} +func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { + return &authServiceClient{cc} } -func (c *authClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { +func (c *authServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(LoginResponse) - err := c.cc.Invoke(ctx, Auth_Login_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, AuthService_Login_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { +func (c *authServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, Auth_Register_FullMethodName, in, out, cOpts...) + out := new(RegisterResponse) + err := c.cc.Invoke(ctx, AuthService_Register_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { +func (c *authServiceClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, Auth_Logout_FullMethodName, in, out, cOpts...) + out := new(LogoutResponse) + err := c.cc.Invoke(ctx, AuthService_Logout_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authClient) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error) { +func (c *authServiceClient) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(RefreshTokenResponse) - err := c.cc.Invoke(ctx, Auth_RefreshToken_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, AuthService_RefreshToken_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authClient) GetCaptcha(ctx context.Context, in *GetCaptchaRequest, opts ...grpc.CallOption) (*GetCaptchaResponse, error) { +func (c *authServiceClient) GetCaptcha(ctx context.Context, in *GetCaptchaRequest, opts ...grpc.CallOption) (*GetCaptchaResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetCaptchaResponse) - err := c.cc.Invoke(ctx, Auth_GetCaptcha_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, AuthService_GetCaptcha_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) { +func (c *authServiceClient) Authenticate(ctx context.Context, in *AuthenticateRequest, opts ...grpc.CallOption) (*AuthenticateResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AuthenticateResponse) - err := c.cc.Invoke(ctx, Auth_Authenticate_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, AuthService_Authenticate_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -// AuthServer is the server API for Auth service. -// All implementations must embed UnimplementedAuthServer +// AuthServiceServer is the server API for AuthService service. +// All implementations must embed UnimplementedAuthServiceServer // for forward compatibility. // -// Service Auth provides APIs for the authentication lifecycle. -type AuthServer interface { +// Service AuthService provides APIs for the authentication lifecycle. +type AuthServiceServer interface { // Login authenticates a user and returns a token pair. Login(context.Context, *LoginRequest) (*LoginResponse, error) // Register creates a new user account. - Register(context.Context, *RegisterRequest) (*emptypb.Empty, error) + Register(context.Context, *RegisterRequest) (*RegisterResponse, error) // Logout invalidates the user's session. - Logout(context.Context, *LogoutRequest) (*emptypb.Empty, error) + Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) // RefreshToken provides a new access token. RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) // GetCaptcha generates a new captcha. @@ -136,193 +135,193 @@ type AuthServer interface { // Authenticate is for internal use by the gateway to verify user access via gRPC. // It does not have an HTTP binding. Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) - mustEmbedUnimplementedAuthServer() + mustEmbedUnimplementedAuthServiceServer() } -// UnimplementedAuthServer must be embedded to have +// UnimplementedAuthServiceServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedAuthServer struct{} +type UnimplementedAuthServiceServer struct{} -func (UnimplementedAuthServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { +func (UnimplementedAuthServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") } -func (UnimplementedAuthServer) Register(context.Context, *RegisterRequest) (*emptypb.Empty, error) { +func (UnimplementedAuthServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") } -func (UnimplementedAuthServer) Logout(context.Context, *LogoutRequest) (*emptypb.Empty, error) { +func (UnimplementedAuthServiceServer) Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented") } -func (UnimplementedAuthServer) RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) { +func (UnimplementedAuthServiceServer) RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RefreshToken not implemented") } -func (UnimplementedAuthServer) GetCaptcha(context.Context, *GetCaptchaRequest) (*GetCaptchaResponse, error) { +func (UnimplementedAuthServiceServer) GetCaptcha(context.Context, *GetCaptchaRequest) (*GetCaptchaResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetCaptcha not implemented") } -func (UnimplementedAuthServer) Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) { +func (UnimplementedAuthServiceServer) Authenticate(context.Context, *AuthenticateRequest) (*AuthenticateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Authenticate not implemented") } -func (UnimplementedAuthServer) mustEmbedUnimplementedAuthServer() {} -func (UnimplementedAuthServer) testEmbeddedByValue() {} +func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} +func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} -// UnsafeAuthServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to AuthServer will +// UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AuthServiceServer will // result in compilation errors. -type UnsafeAuthServer interface { - mustEmbedUnimplementedAuthServer() +type UnsafeAuthServiceServer interface { + mustEmbedUnimplementedAuthServiceServer() } -func RegisterAuthServer(s grpc.ServiceRegistrar, srv AuthServer) { - // If the following call pancis, it indicates UnimplementedAuthServer was +func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { + // If the following call pancis, it indicates UnimplementedAuthServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&Auth_ServiceDesc, srv) + s.RegisterService(&AuthService_ServiceDesc, srv) } -func _Auth_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _AuthService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(LoginRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServer).Login(ctx, in) + return srv.(AuthServiceServer).Login(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Auth_Login_FullMethodName, + FullMethod: AuthService_Login_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServer).Login(ctx, req.(*LoginRequest)) + return srv.(AuthServiceServer).Login(ctx, req.(*LoginRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _AuthService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RegisterRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServer).Register(ctx, in) + return srv.(AuthServiceServer).Register(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Auth_Register_FullMethodName, + FullMethod: AuthService_Register_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServer).Register(ctx, req.(*RegisterRequest)) + return srv.(AuthServiceServer).Register(ctx, req.(*RegisterRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _AuthService_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(LogoutRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServer).Logout(ctx, in) + return srv.(AuthServiceServer).Logout(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Auth_Logout_FullMethodName, + FullMethod: AuthService_Logout_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServer).Logout(ctx, req.(*LogoutRequest)) + return srv.(AuthServiceServer).Logout(ctx, req.(*LogoutRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_RefreshToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _AuthService_RefreshToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(RefreshTokenRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServer).RefreshToken(ctx, in) + return srv.(AuthServiceServer).RefreshToken(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Auth_RefreshToken_FullMethodName, + FullMethod: AuthService_RefreshToken_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServer).RefreshToken(ctx, req.(*RefreshTokenRequest)) + return srv.(AuthServiceServer).RefreshToken(ctx, req.(*RefreshTokenRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_GetCaptcha_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _AuthService_GetCaptcha_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetCaptchaRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServer).GetCaptcha(ctx, in) + return srv.(AuthServiceServer).GetCaptcha(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Auth_GetCaptcha_FullMethodName, + FullMethod: AuthService_GetCaptcha_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServer).GetCaptcha(ctx, req.(*GetCaptchaRequest)) + return srv.(AuthServiceServer).GetCaptcha(ctx, req.(*GetCaptchaRequest)) } return interceptor(ctx, in, info, handler) } -func _Auth_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _AuthService_Authenticate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(AuthenticateRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServer).Authenticate(ctx, in) + return srv.(AuthServiceServer).Authenticate(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Auth_Authenticate_FullMethodName, + FullMethod: AuthService_Authenticate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServer).Authenticate(ctx, req.(*AuthenticateRequest)) + return srv.(AuthServiceServer).Authenticate(ctx, req.(*AuthenticateRequest)) } return interceptor(ctx, in, info, handler) } -// Auth_ServiceDesc is the grpc.ServiceDesc for Auth service. +// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var Auth_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.auth.Auth", - HandlerType: (*AuthServer)(nil), +var AuthService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.auth.AuthService", + HandlerType: (*AuthServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Login", - Handler: _Auth_Login_Handler, + Handler: _AuthService_Login_Handler, }, { MethodName: "Register", - Handler: _Auth_Register_Handler, + Handler: _AuthService_Register_Handler, }, { MethodName: "Logout", - Handler: _Auth_Logout_Handler, + Handler: _AuthService_Logout_Handler, }, { MethodName: "RefreshToken", - Handler: _Auth_RefreshToken_Handler, + Handler: _AuthService_RefreshToken_Handler, }, { MethodName: "GetCaptcha", - Handler: _Auth_GetCaptcha_Handler, + Handler: _AuthService_GetCaptcha_Handler, }, { MethodName: "Authenticate", - Handler: _Auth_Authenticate_Handler, + Handler: _AuthService_Authenticate_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go index c32e8a71..2e61a5f3 100644 --- a/api/v1/services/auth/auth_http.pb.go +++ b/api/v1/services/auth/auth_http.pb.go @@ -10,7 +10,6 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" binding "github.com/go-kratos/kratos/v2/transport/http/binding" - emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -20,35 +19,35 @@ var _ = binding.EncodeURL const _ = http.SupportPackageIsVersion1 -const OperationAuthGetCaptcha = "/api.v1.services.auth.Auth/GetCaptcha" -const OperationAuthLogin = "/api.v1.services.auth.Auth/Login" -const OperationAuthLogout = "/api.v1.services.auth.Auth/Logout" -const OperationAuthRefreshToken = "/api.v1.services.auth.Auth/RefreshToken" -const OperationAuthRegister = "/api.v1.services.auth.Auth/Register" +const OperationAuthServiceGetCaptcha = "/api.v1.services.auth.AuthService/GetCaptcha" +const OperationAuthServiceLogin = "/api.v1.services.auth.AuthService/Login" +const OperationAuthServiceLogout = "/api.v1.services.auth.AuthService/Logout" +const OperationAuthServiceRefreshToken = "/api.v1.services.auth.AuthService/RefreshToken" +const OperationAuthServiceRegister = "/api.v1.services.auth.AuthService/Register" -type AuthHTTPServer interface { +type AuthServiceHTTPServer interface { // GetCaptcha GetCaptcha generates a new captcha. GetCaptcha(context.Context, *GetCaptchaRequest) (*GetCaptchaResponse, error) // Login Login authenticates a user and returns a token pair. Login(context.Context, *LoginRequest) (*LoginResponse, error) // Logout Logout invalidates the user's session. - Logout(context.Context, *LogoutRequest) (*emptypb.Empty, error) + Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) // RefreshToken RefreshToken provides a new access token. RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) // Register Register creates a new user account. - Register(context.Context, *RegisterRequest) (*emptypb.Empty, error) + Register(context.Context, *RegisterRequest) (*RegisterResponse, error) } -func RegisterAuthHTTPServer(s *http.Server, srv AuthHTTPServer) { +func RegisterAuthServiceHTTPServer(s *http.Server, srv AuthServiceHTTPServer) { r := s.Route("/") - r.POST("/api/v1/auth/login", _Auth_Login0_HTTP_Handler(srv)) - r.POST("/api/v1/auth/register", _Auth_Register0_HTTP_Handler(srv)) - r.POST("/api/v1/auth/logout", _Auth_Logout0_HTTP_Handler(srv)) - r.POST("/api/v1/auth/token", _Auth_RefreshToken0_HTTP_Handler(srv)) - r.GET("/api/v1/captcha", _Auth_GetCaptcha0_HTTP_Handler(srv)) + r.POST("/api/v1/auth/login", _AuthService_Login0_HTTP_Handler(srv)) + r.POST("/api/v1/auth/register", _AuthService_Register0_HTTP_Handler(srv)) + r.POST("/api/v1/auth/logout", _AuthService_Logout0_HTTP_Handler(srv)) + r.POST("/api/v1/auth/token", _AuthService_RefreshToken0_HTTP_Handler(srv)) + r.GET("/api/v1/captcha", _AuthService_GetCaptcha0_HTTP_Handler(srv)) } -func _Auth_Login0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error { +func _AuthService_Login0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in LoginRequest if err := ctx.Bind(&in); err != nil { @@ -57,7 +56,7 @@ func _Auth_Login0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthLogin) + http.SetOperation(ctx, OperationAuthServiceLogin) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Login(ctx, req.(*LoginRequest)) }) @@ -70,7 +69,7 @@ func _Auth_Login0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error } } -func _Auth_Register0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error { +func _AuthService_Register0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in RegisterRequest if err := ctx.Bind(&in); err != nil { @@ -79,7 +78,7 @@ func _Auth_Register0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) err if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthRegister) + http.SetOperation(ctx, OperationAuthServiceRegister) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Register(ctx, req.(*RegisterRequest)) }) @@ -87,12 +86,12 @@ func _Auth_Register0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) err if err != nil { return err } - reply := out.(*emptypb.Empty) + reply := out.(*RegisterResponse) return ctx.Result(200, reply) } } -func _Auth_Logout0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error { +func _AuthService_Logout0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in LogoutRequest if err := ctx.Bind(&in); err != nil { @@ -101,7 +100,7 @@ func _Auth_Logout0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthLogout) + http.SetOperation(ctx, OperationAuthServiceLogout) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.Logout(ctx, req.(*LogoutRequest)) }) @@ -109,12 +108,12 @@ func _Auth_Logout0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error if err != nil { return err } - reply := out.(*emptypb.Empty) + reply := out.(*LogoutResponse) return ctx.Result(200, reply) } } -func _Auth_RefreshToken0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error { +func _AuthService_RefreshToken0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in RefreshTokenRequest if err := ctx.Bind(&in); err != nil { @@ -123,7 +122,7 @@ func _Auth_RefreshToken0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthRefreshToken) + http.SetOperation(ctx, OperationAuthServiceRefreshToken) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.RefreshToken(ctx, req.(*RefreshTokenRequest)) }) @@ -136,13 +135,13 @@ func _Auth_RefreshToken0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) } } -func _Auth_GetCaptcha0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) error { +func _AuthService_GetCaptcha0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetCaptchaRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationAuthGetCaptcha) + http.SetOperation(ctx, OperationAuthServiceGetCaptcha) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.GetCaptcha(ctx, req.(*GetCaptchaRequest)) }) @@ -155,33 +154,33 @@ func _Auth_GetCaptcha0_HTTP_Handler(srv AuthHTTPServer) func(ctx http.Context) e } } -type AuthHTTPClient interface { +type AuthServiceHTTPClient interface { // GetCaptcha GetCaptcha generates a new captcha. GetCaptcha(ctx context.Context, req *GetCaptchaRequest, opts ...http.CallOption) (rsp *GetCaptchaResponse, err error) // Login Login authenticates a user and returns a token pair. Login(ctx context.Context, req *LoginRequest, opts ...http.CallOption) (rsp *LoginResponse, err error) // Logout Logout invalidates the user's session. - Logout(ctx context.Context, req *LogoutRequest, opts ...http.CallOption) (rsp *emptypb.Empty, err error) + Logout(ctx context.Context, req *LogoutRequest, opts ...http.CallOption) (rsp *LogoutResponse, err error) // RefreshToken RefreshToken provides a new access token. RefreshToken(ctx context.Context, req *RefreshTokenRequest, opts ...http.CallOption) (rsp *RefreshTokenResponse, err error) // Register Register creates a new user account. - Register(ctx context.Context, req *RegisterRequest, opts ...http.CallOption) (rsp *emptypb.Empty, err error) + Register(ctx context.Context, req *RegisterRequest, opts ...http.CallOption) (rsp *RegisterResponse, err error) } -type AuthHTTPClientImpl struct { +type AuthServiceHTTPClientImpl struct { cc *http.Client } -func NewAuthHTTPClient(client *http.Client) AuthHTTPClient { - return &AuthHTTPClientImpl{client} +func NewAuthServiceHTTPClient(client *http.Client) AuthServiceHTTPClient { + return &AuthServiceHTTPClientImpl{client} } // GetCaptcha GetCaptcha generates a new captcha. -func (c *AuthHTTPClientImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest, opts ...http.CallOption) (*GetCaptchaResponse, error) { +func (c *AuthServiceHTTPClientImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest, opts ...http.CallOption) (*GetCaptchaResponse, error) { var out GetCaptchaResponse pattern := "/api/v1/captcha" path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationAuthGetCaptcha)) + opts = append(opts, http.Operation(OperationAuthServiceGetCaptcha)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) if err != nil { @@ -191,11 +190,11 @@ func (c *AuthHTTPClientImpl) GetCaptcha(ctx context.Context, in *GetCaptchaReque } // Login Login authenticates a user and returns a token pair. -func (c *AuthHTTPClientImpl) Login(ctx context.Context, in *LoginRequest, opts ...http.CallOption) (*LoginResponse, error) { +func (c *AuthServiceHTTPClientImpl) Login(ctx context.Context, in *LoginRequest, opts ...http.CallOption) (*LoginResponse, error) { var out LoginResponse pattern := "/api/v1/auth/login" path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthLogin)) + opts = append(opts, http.Operation(OperationAuthServiceLogin)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { @@ -205,11 +204,11 @@ func (c *AuthHTTPClientImpl) Login(ctx context.Context, in *LoginRequest, opts . } // Logout Logout invalidates the user's session. -func (c *AuthHTTPClientImpl) Logout(ctx context.Context, in *LogoutRequest, opts ...http.CallOption) (*emptypb.Empty, error) { - var out emptypb.Empty +func (c *AuthServiceHTTPClientImpl) Logout(ctx context.Context, in *LogoutRequest, opts ...http.CallOption) (*LogoutResponse, error) { + var out LogoutResponse pattern := "/api/v1/auth/logout" path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthLogout)) + opts = append(opts, http.Operation(OperationAuthServiceLogout)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { @@ -219,11 +218,11 @@ func (c *AuthHTTPClientImpl) Logout(ctx context.Context, in *LogoutRequest, opts } // RefreshToken RefreshToken provides a new access token. -func (c *AuthHTTPClientImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...http.CallOption) (*RefreshTokenResponse, error) { +func (c *AuthServiceHTTPClientImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...http.CallOption) (*RefreshTokenResponse, error) { var out RefreshTokenResponse pattern := "/api/v1/auth/token" path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthRefreshToken)) + opts = append(opts, http.Operation(OperationAuthServiceRefreshToken)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { @@ -233,11 +232,11 @@ func (c *AuthHTTPClientImpl) RefreshToken(ctx context.Context, in *RefreshTokenR } // Register Register creates a new user account. -func (c *AuthHTTPClientImpl) Register(ctx context.Context, in *RegisterRequest, opts ...http.CallOption) (*emptypb.Empty, error) { - var out emptypb.Empty +func (c *AuthServiceHTTPClientImpl) Register(ctx context.Context, in *RegisterRequest, opts ...http.CallOption) (*RegisterResponse, error) { + var out RegisterResponse pattern := "/api/v1/auth/register" path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationAuthRegister)) + opts = append(opts, http.Operation(OperationAuthServiceRegister)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index c72ee06b..f7bf50ef 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -28,19 +28,20 @@ var ( _ = codes.Unimplemented ) -const CasbinSourceServiceListGroupingsBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListGroupings" const CasbinSourceServiceListPoliciesBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListPolicies" +const CasbinSourceServiceListGroupingsBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListGroupings" const CasbinSourceServiceWatchUpdateBridgeOperation = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" +const CasbinSourceServiceStreamRulesBridgeOperation = "/api.v1.services.auth.CasbinSourceService/StreamRules" type CasbinSourceServiceBridgeServer interface { - ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) + ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) } type CasbinSourceServiceHooker interface { - CasbinSourceServiceListGroupingsHooker CasbinSourceServiceListPoliciesHooker + CasbinSourceServiceListGroupingsHooker CasbinSourceServiceWatchUpdateHooker } @@ -48,14 +49,14 @@ type CasbinSourceServiceHookedBridger interface { CasbinSourceServiceHooker CasbinSourceServiceBridgeServer } -type CasbinSourceServiceListGroupingsHooker interface { - PrepareListGroupings(http.Context, *ListGroupingsRequest) (context.Context, error) - CompleteListGroupings(http.Context, *ListGroupingsRequest, *ListGroupingsResponse) error -} type CasbinSourceServiceListPoliciesHooker interface { PrepareListPolicies(http.Context, *ListPoliciesRequest) (context.Context, error) CompleteListPolicies(http.Context, *ListPoliciesRequest, *ListPoliciesResponse) error } +type CasbinSourceServiceListGroupingsHooker interface { + PrepareListGroupings(http.Context, *ListGroupingsRequest) (context.Context, error) + CompleteListGroupings(http.Context, *ListGroupingsRequest, *ListGroupingsResponse) error +} type CasbinSourceServiceWatchUpdateHooker interface { PrepareWatchUpdate(http.Context, *WatchUpdateRequest) (context.Context, error) CompleteWatchUpdate(http.Context, *WatchUpdateRequest, *WatchUpdateResponse) error @@ -144,19 +145,19 @@ func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceHoo // pointer dereference when methods are called. type UnimplementedCasbinSourceServiceHooked struct{} -func (UnimplementedCasbinSourceServiceHooked) PrepareListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { +func (UnimplementedCasbinSourceServiceHooked) PrepareListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceHooked) CompleteListGroupings(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { +func (UnimplementedCasbinSourceServiceHooked) CompleteListPolicies(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { return ctx.Result(200, out) } -func (UnimplementedCasbinSourceServiceHooked) PrepareListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { +func (UnimplementedCasbinSourceServiceHooked) PrepareListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceHooked) CompleteListPolicies(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { +func (UnimplementedCasbinSourceServiceHooked) CompleteListGroupings(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { return ctx.Result(200, out) } @@ -190,14 +191,14 @@ func NewCasbinSourceServiceHTTPBridge(client *http.Client) CasbinSourceServiceHT return &CasbinSourceServiceHTTPBridgeImpl{client: NewCasbinSourceServiceHTTPClient(client)} } -func (c *CasbinSourceServiceHTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, in) -} - func (c *CasbinSourceServiceHTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { return c.client.ListPolicies(ctx, in) } +func (c *CasbinSourceServiceHTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + func (c *CasbinSourceServiceHTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { return c.client.WatchUpdate(ctx, in) } @@ -210,14 +211,14 @@ func NewCasbinSourceServiceBridge(client grpc.ClientConnInterface) CasbinSourceS return &CasbinSourceServiceBridgeImpl{client: NewCasbinSourceServiceClient(client)} } -func (c *CasbinSourceServiceBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, in) -} - func (c *CasbinSourceServiceBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { return c.client.ListPolicies(ctx, in) } +func (c *CasbinSourceServiceBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + func (c *CasbinSourceServiceBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { return c.client.WatchUpdate(ctx, in) } @@ -252,14 +253,14 @@ func NewCasbinSourceServiceGRPC2HTTP(client grpc.ClientConnInterface) CasbinSour return &CasbinSourceServiceGRPC2HTTPBridgeImpl{client: NewCasbinSourceServiceClient(client)} } -func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, in) -} - func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { return c.client.ListPolicies(ctx, in) } +func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { return c.client.WatchUpdate(ctx, in) } @@ -272,14 +273,14 @@ func NewCasbinSourceServiceHTTP2GRPC(client *http.Client) CasbinSourceServiceSer return &CasbinSourceServiceHTTP2GRPCBridgeImpl{client: NewCasbinSourceServiceHTTPClient(client)} } -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { - return c.client.ListGroupings(ctx, in) -} - func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { return c.client.ListPolicies(ctx, in) } +func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { + return c.client.ListGroupings(ctx, in) +} + func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { return c.client.WatchUpdate(ctx, in) } diff --git a/api/v1/services/auth/me.pb.go b/api/v1/services/auth/me.pb.go index 2da67f34..102c25dc 100644 --- a/api/v1/services/auth/me.pb.go +++ b/api/v1/services/auth/me.pb.go @@ -10,7 +10,6 @@ import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - emptypb "google.golang.org/protobuf/types/known/emptypb" types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" @@ -61,6 +60,51 @@ func (*GetProfileRequest) Descriptor() ([]byte, []int) { return file_auth_me_proto_rawDescGZIP(), []int{0} } +// The response message for the GetProfile RPC. +type GetProfileResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetProfileResponse) Reset() { + *x = GetProfileResponse{} + mi := &file_auth_me_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProfileResponse) ProtoMessage() {} + +func (x *GetProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_me_proto_msgTypes[1] + 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 GetProfileResponse.ProtoReflect.Descriptor instead. +func (*GetProfileResponse) Descriptor() ([]byte, []int) { + return file_auth_me_proto_rawDescGZIP(), []int{1} +} + +func (x *GetProfileResponse) GetUser() *types.User { + if x != nil { + return x.User + } + return nil +} + // The request message for the UpdateProfile RPC. type UpdateProfileRequest struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -72,7 +116,7 @@ type UpdateProfileRequest struct { func (x *UpdateProfileRequest) Reset() { *x = UpdateProfileRequest{} - mi := &file_auth_me_proto_msgTypes[1] + mi := &file_auth_me_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -84,7 +128,7 @@ func (x *UpdateProfileRequest) String() string { func (*UpdateProfileRequest) ProtoMessage() {} func (x *UpdateProfileRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_me_proto_msgTypes[1] + mi := &file_auth_me_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -97,7 +141,7 @@ func (x *UpdateProfileRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateProfileRequest.ProtoReflect.Descriptor instead. func (*UpdateProfileRequest) Descriptor() ([]byte, []int) { - return file_auth_me_proto_rawDescGZIP(), []int{1} + return file_auth_me_proto_rawDescGZIP(), []int{2} } func (x *UpdateProfileRequest) GetUser() *types.User { @@ -107,6 +151,43 @@ func (x *UpdateProfileRequest) GetUser() *types.User { return nil } +// The response message for the UpdateProfile RPC. +type UpdateProfileResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateProfileResponse) Reset() { + *x = UpdateProfileResponse{} + mi := &file_auth_me_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateProfileResponse) ProtoMessage() {} + +func (x *UpdateProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_me_proto_msgTypes[3] + 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 UpdateProfileResponse.ProtoReflect.Descriptor instead. +func (*UpdateProfileResponse) Descriptor() ([]byte, []int) { + return file_auth_me_proto_rawDescGZIP(), []int{3} +} + // The request message for the UpdatePassword RPC. type UpdatePasswordRequest struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -118,7 +199,7 @@ type UpdatePasswordRequest struct { func (x *UpdatePasswordRequest) Reset() { *x = UpdatePasswordRequest{} - mi := &file_auth_me_proto_msgTypes[2] + mi := &file_auth_me_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -130,7 +211,7 @@ func (x *UpdatePasswordRequest) String() string { func (*UpdatePasswordRequest) ProtoMessage() {} func (x *UpdatePasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_me_proto_msgTypes[2] + mi := &file_auth_me_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -143,7 +224,7 @@ func (x *UpdatePasswordRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdatePasswordRequest.ProtoReflect.Descriptor instead. func (*UpdatePasswordRequest) Descriptor() ([]byte, []int) { - return file_auth_me_proto_rawDescGZIP(), []int{2} + return file_auth_me_proto_rawDescGZIP(), []int{4} } func (x *UpdatePasswordRequest) GetOldPassword() string { @@ -160,6 +241,43 @@ func (x *UpdatePasswordRequest) GetNewPassword() string { return "" } +// The response message for the UpdatePassword RPC. +type UpdatePasswordResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdatePasswordResponse) Reset() { + *x = UpdatePasswordResponse{} + mi := &file_auth_me_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdatePasswordResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdatePasswordResponse) ProtoMessage() {} + +func (x *UpdatePasswordResponse) ProtoReflect() protoreflect.Message { + mi := &file_auth_me_proto_msgTypes[5] + 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 UpdatePasswordResponse.ProtoReflect.Descriptor instead. +func (*UpdatePasswordResponse) Descriptor() ([]byte, []int) { + return file_auth_me_proto_rawDescGZIP(), []int{5} +} + // The request message for the GetUserResources RPC. type GetUserResourcesRequest struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -169,7 +287,7 @@ type GetUserResourcesRequest struct { func (x *GetUserResourcesRequest) Reset() { *x = GetUserResourcesRequest{} - mi := &file_auth_me_proto_msgTypes[3] + mi := &file_auth_me_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -181,7 +299,7 @@ func (x *GetUserResourcesRequest) String() string { func (*GetUserResourcesRequest) ProtoMessage() {} func (x *GetUserResourcesRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_me_proto_msgTypes[3] + mi := &file_auth_me_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -194,7 +312,7 @@ func (x *GetUserResourcesRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserResourcesRequest.ProtoReflect.Descriptor instead. func (*GetUserResourcesRequest) Descriptor() ([]byte, []int) { - return file_auth_me_proto_rawDescGZIP(), []int{3} + return file_auth_me_proto_rawDescGZIP(), []int{6} } // The response message for the GetUserResources RPC. @@ -207,7 +325,7 @@ type GetUserResourcesResponse struct { func (x *GetUserResourcesResponse) Reset() { *x = GetUserResourcesResponse{} - mi := &file_auth_me_proto_msgTypes[4] + mi := &file_auth_me_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -219,7 +337,7 @@ func (x *GetUserResourcesResponse) String() string { func (*GetUserResourcesResponse) ProtoMessage() {} func (x *GetUserResourcesResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_me_proto_msgTypes[4] + mi := &file_auth_me_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -232,7 +350,7 @@ func (x *GetUserResourcesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserResourcesResponse.ProtoReflect.Descriptor instead. func (*GetUserResourcesResponse) Descriptor() ([]byte, []int) { - return file_auth_me_proto_rawDescGZIP(), []int{4} + return file_auth_me_proto_rawDescGZIP(), []int{7} } func (x *GetUserResourcesResponse) GetResources() []*types.Resource { @@ -251,7 +369,7 @@ type GetUserRolesRequest struct { func (x *GetUserRolesRequest) Reset() { *x = GetUserRolesRequest{} - mi := &file_auth_me_proto_msgTypes[5] + mi := &file_auth_me_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -263,7 +381,7 @@ func (x *GetUserRolesRequest) String() string { func (*GetUserRolesRequest) ProtoMessage() {} func (x *GetUserRolesRequest) ProtoReflect() protoreflect.Message { - mi := &file_auth_me_proto_msgTypes[5] + mi := &file_auth_me_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -276,7 +394,7 @@ func (x *GetUserRolesRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserRolesRequest.ProtoReflect.Descriptor instead. func (*GetUserRolesRequest) Descriptor() ([]byte, []int) { - return file_auth_me_proto_rawDescGZIP(), []int{5} + return file_auth_me_proto_rawDescGZIP(), []int{8} } // The response message for the GetUserRoles RPC. @@ -289,7 +407,7 @@ type GetUserRolesResponse struct { func (x *GetUserRolesResponse) Reset() { *x = GetUserRolesResponse{} - mi := &file_auth_me_proto_msgTypes[6] + mi := &file_auth_me_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -301,7 +419,7 @@ func (x *GetUserRolesResponse) String() string { func (*GetUserRolesResponse) ProtoMessage() {} func (x *GetUserRolesResponse) ProtoReflect() protoreflect.Message { - mi := &file_auth_me_proto_msgTypes[6] + mi := &file_auth_me_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -314,7 +432,7 @@ func (x *GetUserRolesResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetUserRolesResponse.ProtoReflect.Descriptor instead. func (*GetUserRolesResponse) Descriptor() ([]byte, []int) { - return file_auth_me_proto_rawDescGZIP(), []int{6} + return file_auth_me_proto_rawDescGZIP(), []int{9} } func (x *GetUserRolesResponse) GetRoles() []*types.Role { @@ -328,24 +446,28 @@ var File_auth_me_proto protoreflect.FileDescriptor const file_auth_me_proto_rawDesc = "" + "\n" + - "\rauth/me.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\x13\n" + - "\x11GetProfileRequest\"G\n" + + "\rauth/me.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x12types/system.proto\"\x13\n" + + "\x11GetProfileRequest\"E\n" + + "\x12GetProfileResponse\x12/\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + "\x14UpdateProfileRequest\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"]\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\x17\n" + + "\x15UpdateProfileResponse\"]\n" + "\x15UpdatePasswordRequest\x12!\n" + "\fold_password\x18\x01 \x01(\tR\voldPassword\x12!\n" + - "\fnew_password\x18\x02 \x01(\tR\vnewPassword\"\x19\n" + + "\fnew_password\x18\x02 \x01(\tR\vnewPassword\"\x18\n" + + "\x16UpdatePasswordResponse\"\x19\n" + "\x17GetUserResourcesRequest\"Y\n" + "\x18GetUserResourcesResponse\x12=\n" + "\tresources\x18\x01 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"\x15\n" + "\x13GetUserRolesRequest\"I\n" + "\x14GetUserRolesResponse\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles2\xf2\x04\n" + - "\x02Me\x12n\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles2\xb3\x05\n" + + "\tMeService\x12{\n" + "\n" + - "GetProfile\x12'.api.v1.services.auth.GetProfileRequest\x1a\x1b.api.v1.services.types.User\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/api/v1/me/profile\x12r\n" + - "\rUpdateProfile\x12*.api.v1.services.auth.UpdateProfileRequest\x1a\x16.google.protobuf.Empty\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\x1a\x12/api/v1/me/profile\x12u\n" + - "\x0eUpdatePassword\x12+.api.v1.services.auth.UpdatePasswordRequest\x1a\x16.google.protobuf.Empty\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\x1a\x13/api/v1/me/password\x12\x8f\x01\n" + + "GetProfile\x12'.api.v1.services.auth.GetProfileRequest\x1a(.api.v1.services.auth.GetProfileResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/api/v1/me/profile\x12\x87\x01\n" + + "\rUpdateProfile\x12*.api.v1.services.auth.UpdateProfileRequest\x1a+.api.v1.services.auth.UpdateProfileResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\x1a\x12/api/v1/me/profile\x12\x8b\x01\n" + + "\x0eUpdatePassword\x12+.api.v1.services.auth.UpdatePasswordRequest\x1a,.api.v1.services.auth.UpdatePasswordResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\x1a\x13/api/v1/me/password\x12\x8f\x01\n" + "\x10GetUserResources\x12-.api.v1.services.auth.GetUserResourcesRequest\x1a..api.v1.services.auth.GetUserResourcesResponse\"\x1c\x82\xd3\xe4\x93\x02\x16\x12\x14/api/v1/me/resources\x12\x7f\n" + "\fGetUserRoles\x12).api.v1.services.auth.GetUserRolesRequest\x1a*.api.v1.services.auth.GetUserRolesResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/api/v1/me/rolesB\xce\x01\n" + "\x18com.api.v1.services.authB\aMeProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" @@ -362,39 +484,42 @@ func file_auth_me_proto_rawDescGZIP() []byte { return file_auth_me_proto_rawDescData } -var file_auth_me_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_auth_me_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_auth_me_proto_goTypes = []any{ (*GetProfileRequest)(nil), // 0: api.v1.services.auth.GetProfileRequest - (*UpdateProfileRequest)(nil), // 1: api.v1.services.auth.UpdateProfileRequest - (*UpdatePasswordRequest)(nil), // 2: api.v1.services.auth.UpdatePasswordRequest - (*GetUserResourcesRequest)(nil), // 3: api.v1.services.auth.GetUserResourcesRequest - (*GetUserResourcesResponse)(nil), // 4: api.v1.services.auth.GetUserResourcesResponse - (*GetUserRolesRequest)(nil), // 5: api.v1.services.auth.GetUserRolesRequest - (*GetUserRolesResponse)(nil), // 6: api.v1.services.auth.GetUserRolesResponse - (*types.User)(nil), // 7: api.v1.services.types.User - (*types.Resource)(nil), // 8: api.v1.services.types.Resource - (*types.Role)(nil), // 9: api.v1.services.types.Role - (*emptypb.Empty)(nil), // 10: google.protobuf.Empty + (*GetProfileResponse)(nil), // 1: api.v1.services.auth.GetProfileResponse + (*UpdateProfileRequest)(nil), // 2: api.v1.services.auth.UpdateProfileRequest + (*UpdateProfileResponse)(nil), // 3: api.v1.services.auth.UpdateProfileResponse + (*UpdatePasswordRequest)(nil), // 4: api.v1.services.auth.UpdatePasswordRequest + (*UpdatePasswordResponse)(nil), // 5: api.v1.services.auth.UpdatePasswordResponse + (*GetUserResourcesRequest)(nil), // 6: api.v1.services.auth.GetUserResourcesRequest + (*GetUserResourcesResponse)(nil), // 7: api.v1.services.auth.GetUserResourcesResponse + (*GetUserRolesRequest)(nil), // 8: api.v1.services.auth.GetUserRolesRequest + (*GetUserRolesResponse)(nil), // 9: api.v1.services.auth.GetUserRolesResponse + (*types.User)(nil), // 10: api.v1.services.types.User + (*types.Resource)(nil), // 11: api.v1.services.types.Resource + (*types.Role)(nil), // 12: api.v1.services.types.Role } var file_auth_me_proto_depIdxs = []int32{ - 7, // 0: api.v1.services.auth.UpdateProfileRequest.user:type_name -> api.v1.services.types.User - 8, // 1: api.v1.services.auth.GetUserResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 9, // 2: api.v1.services.auth.GetUserRolesResponse.roles:type_name -> api.v1.services.types.Role - 0, // 3: api.v1.services.auth.Me.GetProfile:input_type -> api.v1.services.auth.GetProfileRequest - 1, // 4: api.v1.services.auth.Me.UpdateProfile:input_type -> api.v1.services.auth.UpdateProfileRequest - 2, // 5: api.v1.services.auth.Me.UpdatePassword:input_type -> api.v1.services.auth.UpdatePasswordRequest - 3, // 6: api.v1.services.auth.Me.GetUserResources:input_type -> api.v1.services.auth.GetUserResourcesRequest - 5, // 7: api.v1.services.auth.Me.GetUserRoles:input_type -> api.v1.services.auth.GetUserRolesRequest - 7, // 8: api.v1.services.auth.Me.GetProfile:output_type -> api.v1.services.types.User - 10, // 9: api.v1.services.auth.Me.UpdateProfile:output_type -> google.protobuf.Empty - 10, // 10: api.v1.services.auth.Me.UpdatePassword:output_type -> google.protobuf.Empty - 4, // 11: api.v1.services.auth.Me.GetUserResources:output_type -> api.v1.services.auth.GetUserResourcesResponse - 6, // 12: api.v1.services.auth.Me.GetUserRoles:output_type -> api.v1.services.auth.GetUserRolesResponse - 8, // [8:13] is the sub-list for method output_type - 3, // [3:8] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 10, // 0: api.v1.services.auth.GetProfileResponse.user:type_name -> api.v1.services.types.User + 10, // 1: api.v1.services.auth.UpdateProfileRequest.user:type_name -> api.v1.services.types.User + 11, // 2: api.v1.services.auth.GetUserResourcesResponse.resources:type_name -> api.v1.services.types.Resource + 12, // 3: api.v1.services.auth.GetUserRolesResponse.roles:type_name -> api.v1.services.types.Role + 0, // 4: api.v1.services.auth.MeService.GetProfile:input_type -> api.v1.services.auth.GetProfileRequest + 2, // 5: api.v1.services.auth.MeService.UpdateProfile:input_type -> api.v1.services.auth.UpdateProfileRequest + 4, // 6: api.v1.services.auth.MeService.UpdatePassword:input_type -> api.v1.services.auth.UpdatePasswordRequest + 6, // 7: api.v1.services.auth.MeService.GetUserResources:input_type -> api.v1.services.auth.GetUserResourcesRequest + 8, // 8: api.v1.services.auth.MeService.GetUserRoles:input_type -> api.v1.services.auth.GetUserRolesRequest + 1, // 9: api.v1.services.auth.MeService.GetProfile:output_type -> api.v1.services.auth.GetProfileResponse + 3, // 10: api.v1.services.auth.MeService.UpdateProfile:output_type -> api.v1.services.auth.UpdateProfileResponse + 5, // 11: api.v1.services.auth.MeService.UpdatePassword:output_type -> api.v1.services.auth.UpdatePasswordResponse + 7, // 12: api.v1.services.auth.MeService.GetUserResources:output_type -> api.v1.services.auth.GetUserResourcesResponse + 9, // 13: api.v1.services.auth.MeService.GetUserRoles:output_type -> api.v1.services.auth.GetUserRolesResponse + 9, // [9:14] is the sub-list for method output_type + 4, // [4:9] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_auth_me_proto_init() } @@ -408,7 +533,7 @@ func file_auth_me_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_me_proto_rawDesc), len(file_auth_me_proto_rawDesc)), NumEnums: 0, - NumMessages: 7, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, diff --git a/api/v1/services/auth/me.pb.gw.go b/api/v1/services/auth/me.pb.gw.go index 7538d5d9..98745f14 100644 --- a/api/v1/services/auth/me.pb.gw.go +++ b/api/v1/services/auth/me.pb.gw.go @@ -35,7 +35,7 @@ var ( _ = metadata.Join ) -func request_Me_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, client MeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_MeService_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, client MeServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetProfileRequest metadata runtime.ServerMetadata @@ -45,7 +45,7 @@ func request_Me_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, c return msg, metadata, err } -func local_request_Me_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, server MeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_MeService_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, server MeServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetProfileRequest metadata runtime.ServerMetadata @@ -54,7 +54,7 @@ func local_request_Me_GetProfile_0(ctx context.Context, marshaler runtime.Marsha return msg, metadata, err } -func request_Me_UpdateProfile_0(ctx context.Context, marshaler runtime.Marshaler, client MeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_MeService_UpdateProfile_0(ctx context.Context, marshaler runtime.Marshaler, client MeServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateProfileRequest metadata runtime.ServerMetadata @@ -66,7 +66,7 @@ func request_Me_UpdateProfile_0(ctx context.Context, marshaler runtime.Marshaler return msg, metadata, err } -func local_request_Me_UpdateProfile_0(ctx context.Context, marshaler runtime.Marshaler, server MeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_MeService_UpdateProfile_0(ctx context.Context, marshaler runtime.Marshaler, server MeServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateProfileRequest metadata runtime.ServerMetadata @@ -78,7 +78,7 @@ func local_request_Me_UpdateProfile_0(ctx context.Context, marshaler runtime.Mar return msg, metadata, err } -func request_Me_UpdatePassword_0(ctx context.Context, marshaler runtime.Marshaler, client MeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_MeService_UpdatePassword_0(ctx context.Context, marshaler runtime.Marshaler, client MeServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdatePasswordRequest metadata runtime.ServerMetadata @@ -90,7 +90,7 @@ func request_Me_UpdatePassword_0(ctx context.Context, marshaler runtime.Marshale return msg, metadata, err } -func local_request_Me_UpdatePassword_0(ctx context.Context, marshaler runtime.Marshaler, server MeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_MeService_UpdatePassword_0(ctx context.Context, marshaler runtime.Marshaler, server MeServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdatePasswordRequest metadata runtime.ServerMetadata @@ -102,7 +102,7 @@ func local_request_Me_UpdatePassword_0(ctx context.Context, marshaler runtime.Ma return msg, metadata, err } -func request_Me_GetUserResources_0(ctx context.Context, marshaler runtime.Marshaler, client MeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_MeService_GetUserResources_0(ctx context.Context, marshaler runtime.Marshaler, client MeServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetUserResourcesRequest metadata runtime.ServerMetadata @@ -112,7 +112,7 @@ func request_Me_GetUserResources_0(ctx context.Context, marshaler runtime.Marsha return msg, metadata, err } -func local_request_Me_GetUserResources_0(ctx context.Context, marshaler runtime.Marshaler, server MeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_MeService_GetUserResources_0(ctx context.Context, marshaler runtime.Marshaler, server MeServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetUserResourcesRequest metadata runtime.ServerMetadata @@ -121,7 +121,7 @@ func local_request_Me_GetUserResources_0(ctx context.Context, marshaler runtime. return msg, metadata, err } -func request_Me_GetUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, client MeClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_MeService_GetUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, client MeServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetUserRolesRequest metadata runtime.ServerMetadata @@ -131,7 +131,7 @@ func request_Me_GetUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, return msg, metadata, err } -func local_request_Me_GetUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, server MeServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_MeService_GetUserRoles_0(ctx context.Context, marshaler runtime.Marshaler, server MeServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq GetUserRolesRequest metadata runtime.ServerMetadata @@ -140,119 +140,119 @@ func local_request_Me_GetUserRoles_0(ctx context.Context, marshaler runtime.Mars return msg, metadata, err } -// RegisterMeHandlerServer registers the http handlers for service Me to "mux". -// UnaryRPC :call MeServer directly. +// RegisterMeServiceHandlerServer registers the http handlers for service MeService to "mux". +// UnaryRPC :call MeServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMeHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMeServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterMeHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MeServer) error { - mux.Handle(http.MethodGet, pattern_Me_GetProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { +func RegisterMeServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MeServiceServer) error { + mux.Handle(http.MethodGet, pattern_MeService_GetProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Me/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Me_GetProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_MeService_GetProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Me_GetProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_MeService_GetProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPut, pattern_Me_UpdateProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPut, pattern_MeService_UpdateProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Me/UpdateProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdateProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Me_UpdateProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_MeService_UpdateProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Me_UpdateProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_MeService_UpdateProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPut, pattern_Me_UpdatePassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPut, pattern_MeService_UpdatePassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Me/UpdatePassword", runtime.WithHTTPPathPattern("/api/v1/me/password")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdatePassword", runtime.WithHTTPPathPattern("/api/v1/me/password")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Me_UpdatePassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_MeService_UpdatePassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Me_UpdatePassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_MeService_UpdatePassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_Me_GetUserResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_MeService_GetUserResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Me/GetUserResources", runtime.WithHTTPPathPattern("/api/v1/me/resources")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserResources", runtime.WithHTTPPathPattern("/api/v1/me/resources")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Me_GetUserResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_MeService_GetUserResources_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Me_GetUserResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_MeService_GetUserResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_Me_GetUserRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_MeService_GetUserRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.Me/GetUserRoles", runtime.WithHTTPPathPattern("/api/v1/me/roles")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserRoles", runtime.WithHTTPPathPattern("/api/v1/me/roles")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Me_GetUserRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_MeService_GetUserRoles_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Me_GetUserRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_MeService_GetUserRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } -// RegisterMeHandlerFromEndpoint is same as RegisterMeHandler but +// RegisterMeServiceHandlerFromEndpoint is same as RegisterMeServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterMeHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { +func RegisterMeServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err @@ -271,121 +271,121 @@ func RegisterMeHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, e } }() }() - return RegisterMeHandler(ctx, mux, conn) + return RegisterMeServiceHandler(ctx, mux, conn) } -// RegisterMeHandler registers the http handlers for service Me to "mux". +// RegisterMeServiceHandler registers the http handlers for service MeService to "mux". // The handlers forward requests to the grpc endpoint over "conn". -func RegisterMeHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterMeHandlerClient(ctx, mux, NewMeClient(conn)) +func RegisterMeServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterMeServiceHandlerClient(ctx, mux, NewMeServiceClient(conn)) } -// RegisterMeHandlerClient registers the http handlers for service Me -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MeClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MeClient" +// RegisterMeServiceHandlerClient registers the http handlers for service MeService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MeServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MeServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "MeClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterMeHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MeClient) error { - mux.Handle(http.MethodGet, pattern_Me_GetProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { +// "MeServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterMeServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MeServiceClient) error { + mux.Handle(http.MethodGet, pattern_MeService_GetProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Me/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Me_GetProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_MeService_GetProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Me_GetProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_MeService_GetProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPut, pattern_Me_UpdateProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPut, pattern_MeService_UpdateProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Me/UpdateProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdateProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Me_UpdateProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_MeService_UpdateProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Me_UpdateProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_MeService_UpdateProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPut, pattern_Me_UpdatePassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPut, pattern_MeService_UpdatePassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Me/UpdatePassword", runtime.WithHTTPPathPattern("/api/v1/me/password")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdatePassword", runtime.WithHTTPPathPattern("/api/v1/me/password")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Me_UpdatePassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_MeService_UpdatePassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Me_UpdatePassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_MeService_UpdatePassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_Me_GetUserResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_MeService_GetUserResources_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Me/GetUserResources", runtime.WithHTTPPathPattern("/api/v1/me/resources")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserResources", runtime.WithHTTPPathPattern("/api/v1/me/resources")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Me_GetUserResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_MeService_GetUserResources_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Me_GetUserResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_MeService_GetUserResources_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_Me_GetUserRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_MeService_GetUserRoles_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.Me/GetUserRoles", runtime.WithHTTPPathPattern("/api/v1/me/roles")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserRoles", runtime.WithHTTPPathPattern("/api/v1/me/roles")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Me_GetUserRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_MeService_GetUserRoles_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Me_GetUserRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_MeService_GetUserRoles_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( - pattern_Me_GetProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "profile"}, "")) - pattern_Me_UpdateProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "profile"}, "")) - pattern_Me_UpdatePassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "password"}, "")) - pattern_Me_GetUserResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "resources"}, "")) - pattern_Me_GetUserRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "roles"}, "")) + pattern_MeService_GetProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "profile"}, "")) + pattern_MeService_UpdateProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "profile"}, "")) + pattern_MeService_UpdatePassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "password"}, "")) + pattern_MeService_GetUserResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "resources"}, "")) + pattern_MeService_GetUserRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "roles"}, "")) ) var ( - forward_Me_GetProfile_0 = runtime.ForwardResponseMessage - forward_Me_UpdateProfile_0 = runtime.ForwardResponseMessage - forward_Me_UpdatePassword_0 = runtime.ForwardResponseMessage - forward_Me_GetUserResources_0 = runtime.ForwardResponseMessage - forward_Me_GetUserRoles_0 = runtime.ForwardResponseMessage + forward_MeService_GetProfile_0 = runtime.ForwardResponseMessage + forward_MeService_UpdateProfile_0 = runtime.ForwardResponseMessage + forward_MeService_UpdatePassword_0 = runtime.ForwardResponseMessage + forward_MeService_GetUserResources_0 = runtime.ForwardResponseMessage + forward_MeService_GetUserRoles_0 = runtime.ForwardResponseMessage ) diff --git a/api/v1/services/auth/me.pb.validate.go b/api/v1/services/auth/me.pb.validate.go index dbb4e73a..c8a2765b 100644 --- a/api/v1/services/auth/me.pb.validate.go +++ b/api/v1/services/auth/me.pb.validate.go @@ -137,6 +137,137 @@ var _ interface { ErrorName() string } = GetProfileRequestValidationError{} +// Validate checks the field values on GetProfileResponse 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 *GetProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetProfileResponse 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 +// GetProfileResponseMultiError, or nil if none found. +func (m *GetProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetUser()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetProfileResponseValidationError{ + field: "User", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetProfileResponseMultiError(errors) + } + + return nil +} + +// GetProfileResponseMultiError is an error wrapping multiple validation errors +// returned by GetProfileResponse.ValidateAll() if the designated constraints +// aren't met. +type GetProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetProfileResponseMultiError) 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 GetProfileResponseMultiError) AllErrors() []error { return m } + +// GetProfileResponseValidationError is the validation error returned by +// GetProfileResponse.Validate if the designated constraints aren't met. +type GetProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetProfileResponseValidationError) ErrorName() string { + return "GetProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e GetProfileResponseValidationError) 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 %sGetProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetProfileResponseValidationError{} + // Validate checks the field values on UpdateProfileRequest 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. @@ -268,6 +399,108 @@ var _ interface { ErrorName() string } = UpdateProfileRequestValidationError{} +// Validate checks the field values on UpdateProfileResponse 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 *UpdateProfileResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateProfileResponse 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 +// UpdateProfileResponseMultiError, or nil if none found. +func (m *UpdateProfileResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateProfileResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdateProfileResponseMultiError(errors) + } + + return nil +} + +// UpdateProfileResponseMultiError is an error wrapping multiple validation +// errors returned by UpdateProfileResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdateProfileResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateProfileResponseMultiError) 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 UpdateProfileResponseMultiError) AllErrors() []error { return m } + +// UpdateProfileResponseValidationError is the validation error returned by +// UpdateProfileResponse.Validate if the designated constraints aren't met. +type UpdateProfileResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateProfileResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateProfileResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateProfileResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateProfileResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateProfileResponseValidationError) ErrorName() string { + return "UpdateProfileResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateProfileResponseValidationError) 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 %sUpdateProfileResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateProfileResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateProfileResponseValidationError{} + // Validate checks the field values on UpdatePasswordRequest 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. @@ -374,6 +607,108 @@ var _ interface { ErrorName() string } = UpdatePasswordRequestValidationError{} +// Validate checks the field values on UpdatePasswordResponse 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 *UpdatePasswordResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdatePasswordResponse 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 +// UpdatePasswordResponseMultiError, or nil if none found. +func (m *UpdatePasswordResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdatePasswordResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if len(errors) > 0 { + return UpdatePasswordResponseMultiError(errors) + } + + return nil +} + +// UpdatePasswordResponseMultiError is an error wrapping multiple validation +// errors returned by UpdatePasswordResponse.ValidateAll() if the designated +// constraints aren't met. +type UpdatePasswordResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdatePasswordResponseMultiError) 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 UpdatePasswordResponseMultiError) AllErrors() []error { return m } + +// UpdatePasswordResponseValidationError is the validation error returned by +// UpdatePasswordResponse.Validate if the designated constraints aren't met. +type UpdatePasswordResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdatePasswordResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdatePasswordResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdatePasswordResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdatePasswordResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdatePasswordResponseValidationError) ErrorName() string { + return "UpdatePasswordResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdatePasswordResponseValidationError) 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 %sUpdatePasswordResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdatePasswordResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdatePasswordResponseValidationError{} + // Validate checks the field values on GetUserResourcesRequest 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/api/v1/services/auth/me_bridge.pb.go b/api/v1/services/auth/me_bridge.pb.go index 4cc72515..6955bd48 100644 --- a/api/v1/services/auth/me_bridge.pb.go +++ b/api/v1/services/auth/me_bridge.pb.go @@ -12,9 +12,7 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - emptypb "google.golang.org/protobuf/types/known/emptypb" io "io" - types "origadmin/application/admin/api/v1/services/types" ) // This is a compile-time assertion to ensure that this generated file @@ -30,74 +28,74 @@ var ( _ = codes.Unimplemented ) -const MeGetProfileBridgeOperation = "/api.v1.services.auth.Me/GetProfile" -const MeGetUserResourcesBridgeOperation = "/api.v1.services.auth.Me/GetUserResources" -const MeGetUserRolesBridgeOperation = "/api.v1.services.auth.Me/GetUserRoles" -const MeUpdatePasswordBridgeOperation = "/api.v1.services.auth.Me/UpdatePassword" -const MeUpdateProfileBridgeOperation = "/api.v1.services.auth.Me/UpdateProfile" +const MeServiceGetProfileBridgeOperation = "/api.v1.services.auth.MeService/GetProfile" +const MeServiceUpdateProfileBridgeOperation = "/api.v1.services.auth.MeService/UpdateProfile" +const MeServiceUpdatePasswordBridgeOperation = "/api.v1.services.auth.MeService/UpdatePassword" +const MeServiceGetUserResourcesBridgeOperation = "/api.v1.services.auth.MeService/GetUserResources" +const MeServiceGetUserRolesBridgeOperation = "/api.v1.services.auth.MeService/GetUserRoles" -type MeBridgeServer interface { +type MeServiceBridgeServer interface { // GetProfile retrieves the profile of the currently authenticated user. - GetProfile(context.Context, *GetProfileRequest) (*types.User, error) + GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) + // UpdateProfile updates the profile of the currently authenticated user. + UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) + // UpdatePassword changes the password for the currently authenticated user. + UpdatePassword(context.Context, *UpdatePasswordRequest) (*UpdatePasswordResponse, error) // GetUserResources retrieves the menu/resource list for the current user. GetUserResources(context.Context, *GetUserResourcesRequest) (*GetUserResourcesResponse, error) // GetUserRoles retrieves the role list for the current user. GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error) - // UpdatePassword changes the password for the currently authenticated user. - UpdatePassword(context.Context, *UpdatePasswordRequest) (*emptypb.Empty, error) - // UpdateProfile updates the profile of the currently authenticated user. - UpdateProfile(context.Context, *UpdateProfileRequest) (*emptypb.Empty, error) } -type MeHooker interface { - MeGetProfileHooker - MeGetUserResourcesHooker - MeGetUserRolesHooker - MeUpdatePasswordHooker - MeUpdateProfileHooker +type MeServiceHooker interface { + MeServiceGetProfileHooker + MeServiceUpdateProfileHooker + MeServiceUpdatePasswordHooker + MeServiceGetUserResourcesHooker + MeServiceGetUserRolesHooker } -type MeHookedBridger interface { - MeHooker - MeBridgeServer +type MeServiceHookedBridger interface { + MeServiceHooker + MeServiceBridgeServer } -type MeGetProfileHooker interface { +type MeServiceGetProfileHooker interface { PrepareGetProfile(http.Context, *GetProfileRequest) (context.Context, error) - CompleteGetProfile(http.Context, *GetProfileRequest, *types.User) error + CompleteGetProfile(http.Context, *GetProfileRequest, *GetProfileResponse) error +} +type MeServiceUpdateProfileHooker interface { + PrepareUpdateProfile(http.Context, *UpdateProfileRequest) (context.Context, error) + CompleteUpdateProfile(http.Context, *UpdateProfileRequest, *UpdateProfileResponse) error } -type MeGetUserResourcesHooker interface { +type MeServiceUpdatePasswordHooker interface { + PrepareUpdatePassword(http.Context, *UpdatePasswordRequest) (context.Context, error) + CompleteUpdatePassword(http.Context, *UpdatePasswordRequest, *UpdatePasswordResponse) error +} +type MeServiceGetUserResourcesHooker interface { PrepareGetUserResources(http.Context, *GetUserResourcesRequest) (context.Context, error) CompleteGetUserResources(http.Context, *GetUserResourcesRequest, *GetUserResourcesResponse) error } -type MeGetUserRolesHooker interface { +type MeServiceGetUserRolesHooker interface { PrepareGetUserRoles(http.Context, *GetUserRolesRequest) (context.Context, error) CompleteGetUserRoles(http.Context, *GetUserRolesRequest, *GetUserRolesResponse) error } -type MeUpdatePasswordHooker interface { - PrepareUpdatePassword(http.Context, *UpdatePasswordRequest) (context.Context, error) - CompleteUpdatePassword(http.Context, *UpdatePasswordRequest, *emptypb.Empty) error -} -type MeUpdateProfileHooker interface { - PrepareUpdateProfile(http.Context, *UpdateProfileRequest) (context.Context, error) - CompleteUpdateProfile(http.Context, *UpdateProfileRequest, *emptypb.Empty) error -} -func RegisterMeBridgeServer(s *http.Server, srv MeHookedBridger) { +func RegisterMeServiceBridgeServer(s *http.Server, srv MeServiceHookedBridger) { r := s.Route("/") - r.GET("/api/v1/me/profile", _Me_GetProfile0_Bridge_Handler(srv)) - r.PUT("/api/v1/me/profile", _Me_UpdateProfile0_Bridge_Handler(srv)) - r.PUT("/api/v1/me/password", _Me_UpdatePassword0_Bridge_Handler(srv)) - r.GET("/api/v1/me/resources", _Me_GetUserResources0_Bridge_Handler(srv)) - r.GET("/api/v1/me/roles", _Me_GetUserRoles0_Bridge_Handler(srv)) + r.GET("/api/v1/me/profile", _MeService_GetProfile0_Bridge_Handler(srv)) + r.PUT("/api/v1/me/profile", _MeService_UpdateProfile0_Bridge_Handler(srv)) + r.PUT("/api/v1/me/password", _MeService_UpdatePassword0_Bridge_Handler(srv)) + r.GET("/api/v1/me/resources", _MeService_GetUserResources0_Bridge_Handler(srv)) + r.GET("/api/v1/me/roles", _MeService_GetUserRoles0_Bridge_Handler(srv)) } -func _Me_GetProfile0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) error { +func _MeService_GetProfile0_Bridge_Handler(srv MeServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetProfileRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationMeGetProfile) + http.SetOperation(ctx, OperationMeServiceGetProfile) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.GetProfile(ctx, req.(*GetProfileRequest)) }) @@ -110,11 +108,11 @@ func _Me_GetProfile0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) if err != nil { return err } - return srv.CompleteGetProfile(ctx, &in, out.(*types.User)) + return srv.CompleteGetProfile(ctx, &in, out.(*GetProfileResponse)) } } -func _Me_UpdateProfile0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) error { +func _MeService_UpdateProfile0_Bridge_Handler(srv MeServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateProfileRequest if err := ctx.Bind(&in); err != nil { @@ -123,7 +121,7 @@ func _Me_UpdateProfile0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Contex if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationMeUpdateProfile) + http.SetOperation(ctx, OperationMeServiceUpdateProfile) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.UpdateProfile(ctx, req.(*UpdateProfileRequest)) }) @@ -136,11 +134,11 @@ func _Me_UpdateProfile0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Contex if err != nil { return err } - return srv.CompleteUpdateProfile(ctx, &in, out.(*emptypb.Empty)) + return srv.CompleteUpdateProfile(ctx, &in, out.(*UpdateProfileResponse)) } } -func _Me_UpdatePassword0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) error { +func _MeService_UpdatePassword0_Bridge_Handler(srv MeServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdatePasswordRequest if err := ctx.Bind(&in); err != nil { @@ -149,7 +147,7 @@ func _Me_UpdatePassword0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Conte if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationMeUpdatePassword) + http.SetOperation(ctx, OperationMeServiceUpdatePassword) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.UpdatePassword(ctx, req.(*UpdatePasswordRequest)) }) @@ -162,17 +160,17 @@ func _Me_UpdatePassword0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Conte if err != nil { return err } - return srv.CompleteUpdatePassword(ctx, &in, out.(*emptypb.Empty)) + return srv.CompleteUpdatePassword(ctx, &in, out.(*UpdatePasswordResponse)) } } -func _Me_GetUserResources0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) error { +func _MeService_GetUserResources0_Bridge_Handler(srv MeServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetUserResourcesRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationMeGetUserResources) + http.SetOperation(ctx, OperationMeServiceGetUserResources) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.GetUserResources(ctx, req.(*GetUserResourcesRequest)) }) @@ -189,13 +187,13 @@ func _Me_GetUserResources0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Con } } -func _Me_GetUserRoles0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context) error { +func _MeService_GetUserRoles0_Bridge_Handler(srv MeServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetUserRolesRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationMeGetUserRoles) + http.SetOperation(ctx, OperationMeServiceGetUserRoles) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.GetUserRoles(ctx, req.(*GetUserRolesRequest)) }) @@ -212,179 +210,179 @@ func _Me_GetUserRoles0_Bridge_Handler(srv MeHookedBridger) func(ctx http.Context } } -// UnimplementedMeHooked must be embedded to have +// UnimplementedMeServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedMeHooked struct{} +type UnimplementedMeServiceHooked struct{} -func (UnimplementedMeHooked) PrepareGetProfile(ctx http.Context, in *GetProfileRequest) (context.Context, error) { +func (UnimplementedMeServiceHooked) PrepareGetProfile(ctx http.Context, in *GetProfileRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMeHooked) CompleteGetProfile(ctx http.Context, in *GetProfileRequest, out *types.User) error { +func (UnimplementedMeServiceHooked) CompleteGetProfile(ctx http.Context, in *GetProfileRequest, out *GetProfileResponse) error { return ctx.Result(200, out) } -func (UnimplementedMeHooked) PrepareGetUserResources(ctx http.Context, in *GetUserResourcesRequest) (context.Context, error) { +func (UnimplementedMeServiceHooked) PrepareUpdateProfile(ctx http.Context, in *UpdateProfileRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMeHooked) CompleteGetUserResources(ctx http.Context, in *GetUserResourcesRequest, out *GetUserResourcesResponse) error { +func (UnimplementedMeServiceHooked) CompleteUpdateProfile(ctx http.Context, in *UpdateProfileRequest, out *UpdateProfileResponse) error { return ctx.Result(200, out) } -func (UnimplementedMeHooked) PrepareGetUserRoles(ctx http.Context, in *GetUserRolesRequest) (context.Context, error) { +func (UnimplementedMeServiceHooked) PrepareUpdatePassword(ctx http.Context, in *UpdatePasswordRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMeHooked) CompleteGetUserRoles(ctx http.Context, in *GetUserRolesRequest, out *GetUserRolesResponse) error { +func (UnimplementedMeServiceHooked) CompleteUpdatePassword(ctx http.Context, in *UpdatePasswordRequest, out *UpdatePasswordResponse) error { return ctx.Result(200, out) } -func (UnimplementedMeHooked) PrepareUpdatePassword(ctx http.Context, in *UpdatePasswordRequest) (context.Context, error) { +func (UnimplementedMeServiceHooked) PrepareGetUserResources(ctx http.Context, in *GetUserResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMeHooked) CompleteUpdatePassword(ctx http.Context, in *UpdatePasswordRequest, out *emptypb.Empty) error { +func (UnimplementedMeServiceHooked) CompleteGetUserResources(ctx http.Context, in *GetUserResourcesRequest, out *GetUserResourcesResponse) error { return ctx.Result(200, out) } -func (UnimplementedMeHooked) PrepareUpdateProfile(ctx http.Context, in *UpdateProfileRequest) (context.Context, error) { +func (UnimplementedMeServiceHooked) PrepareGetUserRoles(ctx http.Context, in *GetUserRolesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedMeHooked) CompleteUpdateProfile(ctx http.Context, in *UpdateProfileRequest, out *emptypb.Empty) error { +func (UnimplementedMeServiceHooked) CompleteGetUserRoles(ctx http.Context, in *GetUserRolesRequest, out *GetUserRolesResponse) error { return ctx.Result(200, out) } -func WithMeHook(h MeHooker) func(MeBridgeServer) MeHookedBridger { - return func(srv MeBridgeServer) MeHookedBridger { - return MeHookedBridge{MeBridgeServer: srv, MeHooker: h} +func WithMeServiceHook(h MeServiceHooker) func(MeServiceBridgeServer) MeServiceHookedBridger { + return func(srv MeServiceBridgeServer) MeServiceHookedBridger { + return MeServiceHookedBridge{MeServiceBridgeServer: srv, MeServiceHooker: h} } } -// MeHookedBridge is a bridge between the HTTP and gRPC implementations of Me. -// It implements the HTTP and gRPC implementations of Me. +// MeServiceHookedBridge is a bridge between the HTTP and gRPC implementations of MeService. +// It implements the HTTP and gRPC implementations of MeService. // It forwards requests and responses between the two implementations. -type MeHookedBridge struct { - MeBridgeServer - MeHooker +type MeServiceHookedBridge struct { + MeServiceBridgeServer + MeServiceHooker } -type MeHTTPBridgeImpl struct { - client MeHTTPClient +type MeServiceHTTPBridgeImpl struct { + client MeServiceHTTPClient } -func NewMeHTTPBridge(client *http.Client) MeHTTPServer { - return &MeHTTPBridgeImpl{client: NewMeHTTPClient(client)} +func NewMeServiceHTTPBridge(client *http.Client) MeServiceHTTPServer { + return &MeServiceHTTPBridgeImpl{client: NewMeServiceHTTPClient(client)} } -func (c *MeHTTPBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*types.User, error) { +func (c *MeServiceHTTPBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*GetProfileResponse, error) { return c.client.GetProfile(ctx, in) } -func (c *MeHTTPBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { - return c.client.GetUserResources(ctx, in) +func (c *MeServiceHTTPBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*UpdateProfileResponse, error) { + return c.client.UpdateProfile(ctx, in) } -func (c *MeHTTPBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { - return c.client.GetUserRoles(ctx, in) +func (c *MeServiceHTTPBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*UpdatePasswordResponse, error) { + return c.client.UpdatePassword(ctx, in) } -func (c *MeHTTPBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*emptypb.Empty, error) { - return c.client.UpdatePassword(ctx, in) +func (c *MeServiceHTTPBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { + return c.client.GetUserResources(ctx, in) } -func (c *MeHTTPBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*emptypb.Empty, error) { - return c.client.UpdateProfile(ctx, in) +func (c *MeServiceHTTPBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { + return c.client.GetUserRoles(ctx, in) } -type MeBridgeImpl struct { - client MeClient +type MeServiceBridgeImpl struct { + client MeServiceClient } -func NewMeBridge(client grpc.ClientConnInterface) MeServer { - return &MeBridgeImpl{client: NewMeClient(client)} +func NewMeServiceBridge(client grpc.ClientConnInterface) MeServiceServer { + return &MeServiceBridgeImpl{client: NewMeServiceClient(client)} } -func (c *MeBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*types.User, error) { +func (c *MeServiceBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*GetProfileResponse, error) { return c.client.GetProfile(ctx, in) } -func (c *MeBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { - return c.client.GetUserResources(ctx, in) +func (c *MeServiceBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*UpdateProfileResponse, error) { + return c.client.UpdateProfile(ctx, in) } -func (c *MeBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { - return c.client.GetUserRoles(ctx, in) +func (c *MeServiceBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*UpdatePasswordResponse, error) { + return c.client.UpdatePassword(ctx, in) } -func (c *MeBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*emptypb.Empty, error) { - return c.client.UpdatePassword(ctx, in) +func (c *MeServiceBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { + return c.client.GetUserResources(ctx, in) } -func (c *MeBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*emptypb.Empty, error) { - return c.client.UpdateProfile(ctx, in) +func (c *MeServiceBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { + return c.client.GetUserRoles(ctx, in) } -func (c *MeBridgeImpl) mustEmbedUnimplementedMeServer() {} +func (c *MeServiceBridgeImpl) mustEmbedUnimplementedMeServiceServer() {} -type MeGRPC2HTTPBridgeImpl struct { - client MeClient +type MeServiceGRPC2HTTPBridgeImpl struct { + client MeServiceClient } -func NewMeGRPC2HTTP(client grpc.ClientConnInterface) MeHTTPServer { - return &MeGRPC2HTTPBridgeImpl{client: NewMeClient(client)} +func NewMeServiceGRPC2HTTP(client grpc.ClientConnInterface) MeServiceHTTPServer { + return &MeServiceGRPC2HTTPBridgeImpl{client: NewMeServiceClient(client)} } -func (c *MeGRPC2HTTPBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*types.User, error) { +func (c *MeServiceGRPC2HTTPBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*GetProfileResponse, error) { return c.client.GetProfile(ctx, in) } -func (c *MeGRPC2HTTPBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { - return c.client.GetUserResources(ctx, in) +func (c *MeServiceGRPC2HTTPBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*UpdateProfileResponse, error) { + return c.client.UpdateProfile(ctx, in) } -func (c *MeGRPC2HTTPBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { - return c.client.GetUserRoles(ctx, in) +func (c *MeServiceGRPC2HTTPBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*UpdatePasswordResponse, error) { + return c.client.UpdatePassword(ctx, in) } -func (c *MeGRPC2HTTPBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*emptypb.Empty, error) { - return c.client.UpdatePassword(ctx, in) +func (c *MeServiceGRPC2HTTPBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { + return c.client.GetUserResources(ctx, in) } -func (c *MeGRPC2HTTPBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*emptypb.Empty, error) { - return c.client.UpdateProfile(ctx, in) +func (c *MeServiceGRPC2HTTPBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { + return c.client.GetUserRoles(ctx, in) } -type MeHTTP2GRPCBridgeImpl struct { - client MeHTTPClient +type MeServiceHTTP2GRPCBridgeImpl struct { + client MeServiceHTTPClient } -func NewMeHTTP2GRPC(client *http.Client) MeServer { - return &MeHTTP2GRPCBridgeImpl{client: NewMeHTTPClient(client)} +func NewMeServiceHTTP2GRPC(client *http.Client) MeServiceServer { + return &MeServiceHTTP2GRPCBridgeImpl{client: NewMeServiceHTTPClient(client)} } -func (c *MeHTTP2GRPCBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*types.User, error) { +func (c *MeServiceHTTP2GRPCBridgeImpl) GetProfile(ctx context.Context, in *GetProfileRequest) (*GetProfileResponse, error) { return c.client.GetProfile(ctx, in) } -func (c *MeHTTP2GRPCBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { - return c.client.GetUserResources(ctx, in) +func (c *MeServiceHTTP2GRPCBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*UpdateProfileResponse, error) { + return c.client.UpdateProfile(ctx, in) } -func (c *MeHTTP2GRPCBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { - return c.client.GetUserRoles(ctx, in) +func (c *MeServiceHTTP2GRPCBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*UpdatePasswordResponse, error) { + return c.client.UpdatePassword(ctx, in) } -func (c *MeHTTP2GRPCBridgeImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest) (*emptypb.Empty, error) { - return c.client.UpdatePassword(ctx, in) +func (c *MeServiceHTTP2GRPCBridgeImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { + return c.client.GetUserResources(ctx, in) } -func (c *MeHTTP2GRPCBridgeImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest) (*emptypb.Empty, error) { - return c.client.UpdateProfile(ctx, in) +func (c *MeServiceHTTP2GRPCBridgeImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest) (*GetUserRolesResponse, error) { + return c.client.GetUserRoles(ctx, in) } -func (c *MeHTTP2GRPCBridgeImpl) mustEmbedUnimplementedMeServer() {} +func (c *MeServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedMeServiceServer() {} diff --git a/api/v1/services/auth/me_grpc.pb.go b/api/v1/services/auth/me_grpc.pb.go index 923edec7..c6710a93 100644 --- a/api/v1/services/auth/me_grpc.pb.go +++ b/api/v1/services/auth/me_grpc.pb.go @@ -11,8 +11,6 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" ) // This is a compile-time assertion to ensure that this generated file @@ -21,267 +19,267 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - Me_GetProfile_FullMethodName = "/api.v1.services.auth.Me/GetProfile" - Me_UpdateProfile_FullMethodName = "/api.v1.services.auth.Me/UpdateProfile" - Me_UpdatePassword_FullMethodName = "/api.v1.services.auth.Me/UpdatePassword" - Me_GetUserResources_FullMethodName = "/api.v1.services.auth.Me/GetUserResources" - Me_GetUserRoles_FullMethodName = "/api.v1.services.auth.Me/GetUserRoles" + MeService_GetProfile_FullMethodName = "/api.v1.services.auth.MeService/GetProfile" + MeService_UpdateProfile_FullMethodName = "/api.v1.services.auth.MeService/UpdateProfile" + MeService_UpdatePassword_FullMethodName = "/api.v1.services.auth.MeService/UpdatePassword" + MeService_GetUserResources_FullMethodName = "/api.v1.services.auth.MeService/GetUserResources" + MeService_GetUserRoles_FullMethodName = "/api.v1.services.auth.MeService/GetUserRoles" ) -// MeClient is the client API for Me service. +// MeServiceClient is the client API for MeService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // -// Service Me provides APIs for the currently authenticated user to manage their own profile and data. -type MeClient interface { +// Service MeService provides APIs for the currently authenticated user to manage their own profile and data. +type MeServiceClient interface { // GetProfile retrieves the profile of the currently authenticated user. - GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*types.User, error) + GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error) // UpdateProfile updates the profile of the currently authenticated user. - UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...grpc.CallOption) (*UpdateProfileResponse, error) // UpdatePassword changes the password for the currently authenticated user. - UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*UpdatePasswordResponse, error) // GetUserResources retrieves the menu/resource list for the current user. GetUserResources(ctx context.Context, in *GetUserResourcesRequest, opts ...grpc.CallOption) (*GetUserResourcesResponse, error) // GetUserRoles retrieves the role list for the current user. GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...grpc.CallOption) (*GetUserRolesResponse, error) } -type meClient struct { +type meServiceClient struct { cc grpc.ClientConnInterface } -func NewMeClient(cc grpc.ClientConnInterface) MeClient { - return &meClient{cc} +func NewMeServiceClient(cc grpc.ClientConnInterface) MeServiceClient { + return &meServiceClient{cc} } -func (c *meClient) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*types.User, error) { +func (c *meServiceClient) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...grpc.CallOption) (*GetProfileResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(types.User) - err := c.cc.Invoke(ctx, Me_GetProfile_FullMethodName, in, out, cOpts...) + out := new(GetProfileResponse) + err := c.cc.Invoke(ctx, MeService_GetProfile_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *meClient) UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { +func (c *meServiceClient) UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...grpc.CallOption) (*UpdateProfileResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, Me_UpdateProfile_FullMethodName, in, out, cOpts...) + out := new(UpdateProfileResponse) + err := c.cc.Invoke(ctx, MeService_UpdateProfile_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *meClient) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { +func (c *meServiceClient) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*UpdatePasswordResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, Me_UpdatePassword_FullMethodName, in, out, cOpts...) + out := new(UpdatePasswordResponse) + err := c.cc.Invoke(ctx, MeService_UpdatePassword_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *meClient) GetUserResources(ctx context.Context, in *GetUserResourcesRequest, opts ...grpc.CallOption) (*GetUserResourcesResponse, error) { +func (c *meServiceClient) GetUserResources(ctx context.Context, in *GetUserResourcesRequest, opts ...grpc.CallOption) (*GetUserResourcesResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetUserResourcesResponse) - err := c.cc.Invoke(ctx, Me_GetUserResources_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, MeService_GetUserResources_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *meClient) GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...grpc.CallOption) (*GetUserRolesResponse, error) { +func (c *meServiceClient) GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...grpc.CallOption) (*GetUserRolesResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetUserRolesResponse) - err := c.cc.Invoke(ctx, Me_GetUserRoles_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, MeService_GetUserRoles_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -// MeServer is the server API for Me service. -// All implementations must embed UnimplementedMeServer +// MeServiceServer is the server API for MeService service. +// All implementations must embed UnimplementedMeServiceServer // for forward compatibility. // -// Service Me provides APIs for the currently authenticated user to manage their own profile and data. -type MeServer interface { +// Service MeService provides APIs for the currently authenticated user to manage their own profile and data. +type MeServiceServer interface { // GetProfile retrieves the profile of the currently authenticated user. - GetProfile(context.Context, *GetProfileRequest) (*types.User, error) + GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) // UpdateProfile updates the profile of the currently authenticated user. - UpdateProfile(context.Context, *UpdateProfileRequest) (*emptypb.Empty, error) + UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) // UpdatePassword changes the password for the currently authenticated user. - UpdatePassword(context.Context, *UpdatePasswordRequest) (*emptypb.Empty, error) + UpdatePassword(context.Context, *UpdatePasswordRequest) (*UpdatePasswordResponse, error) // GetUserResources retrieves the menu/resource list for the current user. GetUserResources(context.Context, *GetUserResourcesRequest) (*GetUserResourcesResponse, error) // GetUserRoles retrieves the role list for the current user. GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error) - mustEmbedUnimplementedMeServer() + mustEmbedUnimplementedMeServiceServer() } -// UnimplementedMeServer must be embedded to have +// UnimplementedMeServiceServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedMeServer struct{} +type UnimplementedMeServiceServer struct{} -func (UnimplementedMeServer) GetProfile(context.Context, *GetProfileRequest) (*types.User, error) { +func (UnimplementedMeServiceServer) GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetProfile not implemented") } -func (UnimplementedMeServer) UpdateProfile(context.Context, *UpdateProfileRequest) (*emptypb.Empty, error) { +func (UnimplementedMeServiceServer) UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateProfile not implemented") } -func (UnimplementedMeServer) UpdatePassword(context.Context, *UpdatePasswordRequest) (*emptypb.Empty, error) { +func (UnimplementedMeServiceServer) UpdatePassword(context.Context, *UpdatePasswordRequest) (*UpdatePasswordResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdatePassword not implemented") } -func (UnimplementedMeServer) GetUserResources(context.Context, *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { +func (UnimplementedMeServiceServer) GetUserResources(context.Context, *GetUserResourcesRequest) (*GetUserResourcesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetUserResources not implemented") } -func (UnimplementedMeServer) GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error) { +func (UnimplementedMeServiceServer) GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetUserRoles not implemented") } -func (UnimplementedMeServer) mustEmbedUnimplementedMeServer() {} -func (UnimplementedMeServer) testEmbeddedByValue() {} +func (UnimplementedMeServiceServer) mustEmbedUnimplementedMeServiceServer() {} +func (UnimplementedMeServiceServer) testEmbeddedByValue() {} -// UnsafeMeServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to MeServer will +// UnsafeMeServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MeServiceServer will // result in compilation errors. -type UnsafeMeServer interface { - mustEmbedUnimplementedMeServer() +type UnsafeMeServiceServer interface { + mustEmbedUnimplementedMeServiceServer() } -func RegisterMeServer(s grpc.ServiceRegistrar, srv MeServer) { - // If the following call pancis, it indicates UnimplementedMeServer was +func RegisterMeServiceServer(s grpc.ServiceRegistrar, srv MeServiceServer) { + // If the following call pancis, it indicates UnimplementedMeServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&Me_ServiceDesc, srv) + s.RegisterService(&MeService_ServiceDesc, srv) } -func _Me_GetProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _MeService_GetProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetProfileRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MeServer).GetProfile(ctx, in) + return srv.(MeServiceServer).GetProfile(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Me_GetProfile_FullMethodName, + FullMethod: MeService_GetProfile_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MeServer).GetProfile(ctx, req.(*GetProfileRequest)) + return srv.(MeServiceServer).GetProfile(ctx, req.(*GetProfileRequest)) } return interceptor(ctx, in, info, handler) } -func _Me_UpdateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _MeService_UpdateProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(UpdateProfileRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MeServer).UpdateProfile(ctx, in) + return srv.(MeServiceServer).UpdateProfile(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Me_UpdateProfile_FullMethodName, + FullMethod: MeService_UpdateProfile_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MeServer).UpdateProfile(ctx, req.(*UpdateProfileRequest)) + return srv.(MeServiceServer).UpdateProfile(ctx, req.(*UpdateProfileRequest)) } return interceptor(ctx, in, info, handler) } -func _Me_UpdatePassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _MeService_UpdatePassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(UpdatePasswordRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MeServer).UpdatePassword(ctx, in) + return srv.(MeServiceServer).UpdatePassword(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Me_UpdatePassword_FullMethodName, + FullMethod: MeService_UpdatePassword_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MeServer).UpdatePassword(ctx, req.(*UpdatePasswordRequest)) + return srv.(MeServiceServer).UpdatePassword(ctx, req.(*UpdatePasswordRequest)) } return interceptor(ctx, in, info, handler) } -func _Me_GetUserResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _MeService_GetUserResources_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetUserResourcesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MeServer).GetUserResources(ctx, in) + return srv.(MeServiceServer).GetUserResources(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Me_GetUserResources_FullMethodName, + FullMethod: MeService_GetUserResources_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MeServer).GetUserResources(ctx, req.(*GetUserResourcesRequest)) + return srv.(MeServiceServer).GetUserResources(ctx, req.(*GetUserResourcesRequest)) } return interceptor(ctx, in, info, handler) } -func _Me_GetUserRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _MeService_GetUserRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetUserRolesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MeServer).GetUserRoles(ctx, in) + return srv.(MeServiceServer).GetUserRoles(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Me_GetUserRoles_FullMethodName, + FullMethod: MeService_GetUserRoles_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MeServer).GetUserRoles(ctx, req.(*GetUserRolesRequest)) + return srv.(MeServiceServer).GetUserRoles(ctx, req.(*GetUserRolesRequest)) } return interceptor(ctx, in, info, handler) } -// Me_ServiceDesc is the grpc.ServiceDesc for Me service. +// MeService_ServiceDesc is the grpc.ServiceDesc for MeService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var Me_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.auth.Me", - HandlerType: (*MeServer)(nil), +var MeService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.auth.MeService", + HandlerType: (*MeServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetProfile", - Handler: _Me_GetProfile_Handler, + Handler: _MeService_GetProfile_Handler, }, { MethodName: "UpdateProfile", - Handler: _Me_UpdateProfile_Handler, + Handler: _MeService_UpdateProfile_Handler, }, { MethodName: "UpdatePassword", - Handler: _Me_UpdatePassword_Handler, + Handler: _MeService_UpdatePassword_Handler, }, { MethodName: "GetUserResources", - Handler: _Me_GetUserResources_Handler, + Handler: _MeService_GetUserResources_Handler, }, { MethodName: "GetUserRoles", - Handler: _Me_GetUserRoles_Handler, + Handler: _MeService_GetUserRoles_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/api/v1/services/auth/me_http.pb.go b/api/v1/services/auth/me_http.pb.go index 60fe09ad..60d3d8b7 100644 --- a/api/v1/services/auth/me_http.pb.go +++ b/api/v1/services/auth/me_http.pb.go @@ -10,8 +10,6 @@ import ( context "context" http "github.com/go-kratos/kratos/v2/transport/http" binding "github.com/go-kratos/kratos/v2/transport/http/binding" - emptypb "google.golang.org/protobuf/types/known/emptypb" - types "origadmin/application/admin/api/v1/services/types" ) // This is a compile-time assertion to ensure that this generated file @@ -21,41 +19,41 @@ var _ = binding.EncodeURL const _ = http.SupportPackageIsVersion1 -const OperationMeGetProfile = "/api.v1.services.auth.Me/GetProfile" -const OperationMeGetUserResources = "/api.v1.services.auth.Me/GetUserResources" -const OperationMeGetUserRoles = "/api.v1.services.auth.Me/GetUserRoles" -const OperationMeUpdatePassword = "/api.v1.services.auth.Me/UpdatePassword" -const OperationMeUpdateProfile = "/api.v1.services.auth.Me/UpdateProfile" +const OperationMeServiceGetProfile = "/api.v1.services.auth.MeService/GetProfile" +const OperationMeServiceGetUserResources = "/api.v1.services.auth.MeService/GetUserResources" +const OperationMeServiceGetUserRoles = "/api.v1.services.auth.MeService/GetUserRoles" +const OperationMeServiceUpdatePassword = "/api.v1.services.auth.MeService/UpdatePassword" +const OperationMeServiceUpdateProfile = "/api.v1.services.auth.MeService/UpdateProfile" -type MeHTTPServer interface { +type MeServiceHTTPServer interface { // GetProfile GetProfile retrieves the profile of the currently authenticated user. - GetProfile(context.Context, *GetProfileRequest) (*types.User, error) + GetProfile(context.Context, *GetProfileRequest) (*GetProfileResponse, error) // GetUserResources GetUserResources retrieves the menu/resource list for the current user. GetUserResources(context.Context, *GetUserResourcesRequest) (*GetUserResourcesResponse, error) // GetUserRoles GetUserRoles retrieves the role list for the current user. GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error) // UpdatePassword UpdatePassword changes the password for the currently authenticated user. - UpdatePassword(context.Context, *UpdatePasswordRequest) (*emptypb.Empty, error) + UpdatePassword(context.Context, *UpdatePasswordRequest) (*UpdatePasswordResponse, error) // UpdateProfile UpdateProfile updates the profile of the currently authenticated user. - UpdateProfile(context.Context, *UpdateProfileRequest) (*emptypb.Empty, error) + UpdateProfile(context.Context, *UpdateProfileRequest) (*UpdateProfileResponse, error) } -func RegisterMeHTTPServer(s *http.Server, srv MeHTTPServer) { +func RegisterMeServiceHTTPServer(s *http.Server, srv MeServiceHTTPServer) { r := s.Route("/") - r.GET("/api/v1/me/profile", _Me_GetProfile0_HTTP_Handler(srv)) - r.PUT("/api/v1/me/profile", _Me_UpdateProfile0_HTTP_Handler(srv)) - r.PUT("/api/v1/me/password", _Me_UpdatePassword0_HTTP_Handler(srv)) - r.GET("/api/v1/me/resources", _Me_GetUserResources0_HTTP_Handler(srv)) - r.GET("/api/v1/me/roles", _Me_GetUserRoles0_HTTP_Handler(srv)) + r.GET("/api/v1/me/profile", _MeService_GetProfile0_HTTP_Handler(srv)) + r.PUT("/api/v1/me/profile", _MeService_UpdateProfile0_HTTP_Handler(srv)) + r.PUT("/api/v1/me/password", _MeService_UpdatePassword0_HTTP_Handler(srv)) + r.GET("/api/v1/me/resources", _MeService_GetUserResources0_HTTP_Handler(srv)) + r.GET("/api/v1/me/roles", _MeService_GetUserRoles0_HTTP_Handler(srv)) } -func _Me_GetProfile0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error { +func _MeService_GetProfile0_HTTP_Handler(srv MeServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetProfileRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationMeGetProfile) + http.SetOperation(ctx, OperationMeServiceGetProfile) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.GetProfile(ctx, req.(*GetProfileRequest)) }) @@ -63,12 +61,12 @@ func _Me_GetProfile0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error if err != nil { return err } - reply := out.(*types.User) + reply := out.(*GetProfileResponse) return ctx.Result(200, reply) } } -func _Me_UpdateProfile0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error { +func _MeService_UpdateProfile0_HTTP_Handler(srv MeServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateProfileRequest if err := ctx.Bind(&in); err != nil { @@ -77,7 +75,7 @@ func _Me_UpdateProfile0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) er if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationMeUpdateProfile) + http.SetOperation(ctx, OperationMeServiceUpdateProfile) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.UpdateProfile(ctx, req.(*UpdateProfileRequest)) }) @@ -85,12 +83,12 @@ func _Me_UpdateProfile0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) er if err != nil { return err } - reply := out.(*emptypb.Empty) + reply := out.(*UpdateProfileResponse) return ctx.Result(200, reply) } } -func _Me_UpdatePassword0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error { +func _MeService_UpdatePassword0_HTTP_Handler(srv MeServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdatePasswordRequest if err := ctx.Bind(&in); err != nil { @@ -99,7 +97,7 @@ func _Me_UpdatePassword0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) e if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationMeUpdatePassword) + http.SetOperation(ctx, OperationMeServiceUpdatePassword) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.UpdatePassword(ctx, req.(*UpdatePasswordRequest)) }) @@ -107,18 +105,18 @@ func _Me_UpdatePassword0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) e if err != nil { return err } - reply := out.(*emptypb.Empty) + reply := out.(*UpdatePasswordResponse) return ctx.Result(200, reply) } } -func _Me_GetUserResources0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error { +func _MeService_GetUserResources0_HTTP_Handler(srv MeServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetUserResourcesRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationMeGetUserResources) + http.SetOperation(ctx, OperationMeServiceGetUserResources) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.GetUserResources(ctx, req.(*GetUserResourcesRequest)) }) @@ -131,13 +129,13 @@ func _Me_GetUserResources0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) } } -func _Me_GetUserRoles0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) error { +func _MeService_GetUserRoles0_HTTP_Handler(srv MeServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in GetUserRolesRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationMeGetUserRoles) + http.SetOperation(ctx, OperationMeServiceGetUserRoles) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.GetUserRoles(ctx, req.(*GetUserRolesRequest)) }) @@ -150,33 +148,33 @@ func _Me_GetUserRoles0_HTTP_Handler(srv MeHTTPServer) func(ctx http.Context) err } } -type MeHTTPClient interface { +type MeServiceHTTPClient interface { // GetProfile GetProfile retrieves the profile of the currently authenticated user. - GetProfile(ctx context.Context, req *GetProfileRequest, opts ...http.CallOption) (rsp *types.User, err error) + GetProfile(ctx context.Context, req *GetProfileRequest, opts ...http.CallOption) (rsp *GetProfileResponse, err error) // GetUserResources GetUserResources retrieves the menu/resource list for the current user. GetUserResources(ctx context.Context, req *GetUserResourcesRequest, opts ...http.CallOption) (rsp *GetUserResourcesResponse, err error) // GetUserRoles GetUserRoles retrieves the role list for the current user. GetUserRoles(ctx context.Context, req *GetUserRolesRequest, opts ...http.CallOption) (rsp *GetUserRolesResponse, err error) // UpdatePassword UpdatePassword changes the password for the currently authenticated user. - UpdatePassword(ctx context.Context, req *UpdatePasswordRequest, opts ...http.CallOption) (rsp *emptypb.Empty, err error) + UpdatePassword(ctx context.Context, req *UpdatePasswordRequest, opts ...http.CallOption) (rsp *UpdatePasswordResponse, err error) // UpdateProfile UpdateProfile updates the profile of the currently authenticated user. - UpdateProfile(ctx context.Context, req *UpdateProfileRequest, opts ...http.CallOption) (rsp *emptypb.Empty, err error) + UpdateProfile(ctx context.Context, req *UpdateProfileRequest, opts ...http.CallOption) (rsp *UpdateProfileResponse, err error) } -type MeHTTPClientImpl struct { +type MeServiceHTTPClientImpl struct { cc *http.Client } -func NewMeHTTPClient(client *http.Client) MeHTTPClient { - return &MeHTTPClientImpl{client} +func NewMeServiceHTTPClient(client *http.Client) MeServiceHTTPClient { + return &MeServiceHTTPClientImpl{client} } // GetProfile GetProfile retrieves the profile of the currently authenticated user. -func (c *MeHTTPClientImpl) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...http.CallOption) (*types.User, error) { - var out types.User +func (c *MeServiceHTTPClientImpl) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...http.CallOption) (*GetProfileResponse, error) { + var out GetProfileResponse pattern := "/api/v1/me/profile" path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationMeGetProfile)) + opts = append(opts, http.Operation(OperationMeServiceGetProfile)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) if err != nil { @@ -186,11 +184,11 @@ func (c *MeHTTPClientImpl) GetProfile(ctx context.Context, in *GetProfileRequest } // GetUserResources GetUserResources retrieves the menu/resource list for the current user. -func (c *MeHTTPClientImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest, opts ...http.CallOption) (*GetUserResourcesResponse, error) { +func (c *MeServiceHTTPClientImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest, opts ...http.CallOption) (*GetUserResourcesResponse, error) { var out GetUserResourcesResponse pattern := "/api/v1/me/resources" path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationMeGetUserResources)) + opts = append(opts, http.Operation(OperationMeServiceGetUserResources)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) if err != nil { @@ -200,11 +198,11 @@ func (c *MeHTTPClientImpl) GetUserResources(ctx context.Context, in *GetUserReso } // GetUserRoles GetUserRoles retrieves the role list for the current user. -func (c *MeHTTPClientImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...http.CallOption) (*GetUserRolesResponse, error) { +func (c *MeServiceHTTPClientImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...http.CallOption) (*GetUserRolesResponse, error) { var out GetUserRolesResponse pattern := "/api/v1/me/roles" path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationMeGetUserRoles)) + opts = append(opts, http.Operation(OperationMeServiceGetUserRoles)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) if err != nil { @@ -214,11 +212,11 @@ func (c *MeHTTPClientImpl) GetUserRoles(ctx context.Context, in *GetUserRolesReq } // UpdatePassword UpdatePassword changes the password for the currently authenticated user. -func (c *MeHTTPClientImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...http.CallOption) (*emptypb.Empty, error) { - var out emptypb.Empty +func (c *MeServiceHTTPClientImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...http.CallOption) (*UpdatePasswordResponse, error) { + var out UpdatePasswordResponse pattern := "/api/v1/me/password" path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationMeUpdatePassword)) + opts = append(opts, http.Operation(OperationMeServiceUpdatePassword)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) if err != nil { @@ -228,11 +226,11 @@ func (c *MeHTTPClientImpl) UpdatePassword(ctx context.Context, in *UpdatePasswor } // UpdateProfile UpdateProfile updates the profile of the currently authenticated user. -func (c *MeHTTPClientImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...http.CallOption) (*emptypb.Empty, error) { - var out emptypb.Empty +func (c *MeServiceHTTPClientImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...http.CallOption) (*UpdateProfileResponse, error) { + var out UpdateProfileResponse pattern := "/api/v1/me/profile" path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationMeUpdateProfile)) + opts = append(opts, http.Operation(OperationMeServiceUpdateProfile)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) if err != nil { diff --git a/api/v1/services/datastore/datastore.pb.go b/api/v1/services/datastore/datastore.pb.go index f8e0be72..9362cb21 100644 --- a/api/v1/services/datastore/datastore.pb.go +++ b/api/v1/services/datastore/datastore.pb.go @@ -7,7 +7,6 @@ package datastore import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -618,7 +617,7 @@ var File_datastore_datastore_proto protoreflect.FileDescriptor const file_datastore_datastore_proto_rawDesc = "" + "\n" + - "\x19datastore/datastore.proto\x12\x19api.v1.services.datastore\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15types/datastore.proto\x1a\x17validate/validate.proto\"\xd0\x01\n" + + "\x19datastore/datastore.proto\x12\x19api.v1.services.datastore\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15types/datastore.proto\"\xd0\x01\n" + "\x14ListDatastoreRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + diff --git a/api/v1/services/datastore/datastore_bridge.pb.go b/api/v1/services/datastore/datastore_bridge.pb.go index 34b94072..4aff78de 100644 --- a/api/v1/services/datastore/datastore_bridge.pb.go +++ b/api/v1/services/datastore/datastore_bridge.pb.go @@ -28,52 +28,52 @@ var ( _ = codes.Unimplemented ) -const DatastoreServiceCreateDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/CreateDatastore" -const DatastoreServiceDeleteDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" -const DatastoreServiceGetDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/GetDatastore" const DatastoreServiceListDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/ListDatastore" +const DatastoreServiceGetDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/GetDatastore" +const DatastoreServiceCreateDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/CreateDatastore" const DatastoreServiceUpdateDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/UpdateDatastore" +const DatastoreServiceDeleteDatastoreBridgeOperation = "/api.v1.services.datastore.DatastoreService/DeleteDatastore" type DatastoreServiceBridgeServer interface { - CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) - DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) - GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) ListDatastore(context.Context, *ListDatastoreRequest) (*ListDatastoreResponse, error) + GetDatastore(context.Context, *GetDatastoreRequest) (*GetDatastoreResponse, error) + CreateDatastore(context.Context, *CreateDatastoreRequest) (*CreateDatastoreResponse, error) UpdateDatastore(context.Context, *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) + DeleteDatastore(context.Context, *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) } type DatastoreServiceHooker interface { - DatastoreServiceCreateDatastoreHooker - DatastoreServiceDeleteDatastoreHooker - DatastoreServiceGetDatastoreHooker DatastoreServiceListDatastoreHooker + DatastoreServiceGetDatastoreHooker + DatastoreServiceCreateDatastoreHooker DatastoreServiceUpdateDatastoreHooker + DatastoreServiceDeleteDatastoreHooker } type DatastoreServiceHookedBridger interface { DatastoreServiceHooker DatastoreServiceBridgeServer } -type DatastoreServiceCreateDatastoreHooker interface { - PrepareCreateDatastore(http.Context, *CreateDatastoreRequest) (context.Context, error) - CompleteCreateDatastore(http.Context, *CreateDatastoreRequest, *CreateDatastoreResponse) error -} -type DatastoreServiceDeleteDatastoreHooker interface { - PrepareDeleteDatastore(http.Context, *DeleteDatastoreRequest) (context.Context, error) - CompleteDeleteDatastore(http.Context, *DeleteDatastoreRequest, *DeleteDatastoreResponse) error +type DatastoreServiceListDatastoreHooker interface { + PrepareListDatastore(http.Context, *ListDatastoreRequest) (context.Context, error) + CompleteListDatastore(http.Context, *ListDatastoreRequest, *ListDatastoreResponse) error } type DatastoreServiceGetDatastoreHooker interface { PrepareGetDatastore(http.Context, *GetDatastoreRequest) (context.Context, error) CompleteGetDatastore(http.Context, *GetDatastoreRequest, *GetDatastoreResponse) error } -type DatastoreServiceListDatastoreHooker interface { - PrepareListDatastore(http.Context, *ListDatastoreRequest) (context.Context, error) - CompleteListDatastore(http.Context, *ListDatastoreRequest, *ListDatastoreResponse) error +type DatastoreServiceCreateDatastoreHooker interface { + PrepareCreateDatastore(http.Context, *CreateDatastoreRequest) (context.Context, error) + CompleteCreateDatastore(http.Context, *CreateDatastoreRequest, *CreateDatastoreResponse) error } type DatastoreServiceUpdateDatastoreHooker interface { PrepareUpdateDatastore(http.Context, *UpdateDatastoreRequest) (context.Context, error) CompleteUpdateDatastore(http.Context, *UpdateDatastoreRequest, *UpdateDatastoreResponse) error } +type DatastoreServiceDeleteDatastoreHooker interface { + PrepareDeleteDatastore(http.Context, *DeleteDatastoreRequest) (context.Context, error) + CompleteDeleteDatastore(http.Context, *DeleteDatastoreRequest, *DeleteDatastoreResponse) error +} func RegisterDatastoreServiceBridgeServer(s *http.Server, srv DatastoreServiceHookedBridger) { r := s.Route("/") @@ -221,43 +221,43 @@ func _DatastoreService_DeleteDatastore0_Bridge_Handler(srv DatastoreServiceHooke // pointer dereference when methods are called. type UnimplementedDatastoreServiceHooked struct{} -func (UnimplementedDatastoreServiceHooked) PrepareCreateDatastore(ctx http.Context, in *CreateDatastoreRequest) (context.Context, error) { +func (UnimplementedDatastoreServiceHooked) PrepareListDatastore(ctx http.Context, in *ListDatastoreRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDatastoreServiceHooked) CompleteCreateDatastore(ctx http.Context, in *CreateDatastoreRequest, out *CreateDatastoreResponse) error { +func (UnimplementedDatastoreServiceHooked) CompleteListDatastore(ctx http.Context, in *ListDatastoreRequest, out *ListDatastoreResponse) error { return ctx.Result(200, out) } -func (UnimplementedDatastoreServiceHooked) PrepareDeleteDatastore(ctx http.Context, in *DeleteDatastoreRequest) (context.Context, error) { +func (UnimplementedDatastoreServiceHooked) PrepareGetDatastore(ctx http.Context, in *GetDatastoreRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDatastoreServiceHooked) CompleteDeleteDatastore(ctx http.Context, in *DeleteDatastoreRequest, out *DeleteDatastoreResponse) error { +func (UnimplementedDatastoreServiceHooked) CompleteGetDatastore(ctx http.Context, in *GetDatastoreRequest, out *GetDatastoreResponse) error { return ctx.Result(200, out) } -func (UnimplementedDatastoreServiceHooked) PrepareGetDatastore(ctx http.Context, in *GetDatastoreRequest) (context.Context, error) { +func (UnimplementedDatastoreServiceHooked) PrepareCreateDatastore(ctx http.Context, in *CreateDatastoreRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDatastoreServiceHooked) CompleteGetDatastore(ctx http.Context, in *GetDatastoreRequest, out *GetDatastoreResponse) error { +func (UnimplementedDatastoreServiceHooked) CompleteCreateDatastore(ctx http.Context, in *CreateDatastoreRequest, out *CreateDatastoreResponse) error { return ctx.Result(200, out) } -func (UnimplementedDatastoreServiceHooked) PrepareListDatastore(ctx http.Context, in *ListDatastoreRequest) (context.Context, error) { +func (UnimplementedDatastoreServiceHooked) PrepareUpdateDatastore(ctx http.Context, in *UpdateDatastoreRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDatastoreServiceHooked) CompleteListDatastore(ctx http.Context, in *ListDatastoreRequest, out *ListDatastoreResponse) error { +func (UnimplementedDatastoreServiceHooked) CompleteUpdateDatastore(ctx http.Context, in *UpdateDatastoreRequest, out *UpdateDatastoreResponse) error { return ctx.Result(200, out) } -func (UnimplementedDatastoreServiceHooked) PrepareUpdateDatastore(ctx http.Context, in *UpdateDatastoreRequest) (context.Context, error) { +func (UnimplementedDatastoreServiceHooked) PrepareDeleteDatastore(ctx http.Context, in *DeleteDatastoreRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDatastoreServiceHooked) CompleteUpdateDatastore(ctx http.Context, in *UpdateDatastoreRequest, out *UpdateDatastoreResponse) error { +func (UnimplementedDatastoreServiceHooked) CompleteDeleteDatastore(ctx http.Context, in *DeleteDatastoreRequest, out *DeleteDatastoreResponse) error { return ctx.Result(200, out) } @@ -283,26 +283,26 @@ func NewDatastoreServiceHTTPBridge(client *http.Client) DatastoreServiceHTTPServ return &DatastoreServiceHTTPBridgeImpl{client: NewDatastoreServiceHTTPClient(client)} } -func (c *DatastoreServiceHTTPBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { - return c.client.CreateDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTPBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { - return c.client.DeleteDatastore(ctx, in) +func (c *DatastoreServiceHTTPBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) } func (c *DatastoreServiceHTTPBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { return c.client.GetDatastore(ctx, in) } -func (c *DatastoreServiceHTTPBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { - return c.client.ListDatastore(ctx, in) +func (c *DatastoreServiceHTTPBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) } func (c *DatastoreServiceHTTPBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { return c.client.UpdateDatastore(ctx, in) } +func (c *DatastoreServiceHTTPBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + type DatastoreServiceBridgeImpl struct { client DatastoreServiceClient } @@ -311,26 +311,26 @@ func NewDatastoreServiceBridge(client grpc.ClientConnInterface) DatastoreService return &DatastoreServiceBridgeImpl{client: NewDatastoreServiceClient(client)} } -func (c *DatastoreServiceBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { - return c.client.CreateDatastore(ctx, in) -} - -func (c *DatastoreServiceBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { - return c.client.DeleteDatastore(ctx, in) +func (c *DatastoreServiceBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) } func (c *DatastoreServiceBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { return c.client.GetDatastore(ctx, in) } -func (c *DatastoreServiceBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { - return c.client.ListDatastore(ctx, in) +func (c *DatastoreServiceBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) } func (c *DatastoreServiceBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { return c.client.UpdateDatastore(ctx, in) } +func (c *DatastoreServiceBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + func (c *DatastoreServiceBridgeImpl) mustEmbedUnimplementedDatastoreServiceServer() {} type DatastoreServiceGRPC2HTTPBridgeImpl struct { @@ -341,26 +341,26 @@ func NewDatastoreServiceGRPC2HTTP(client grpc.ClientConnInterface) DatastoreServ return &DatastoreServiceGRPC2HTTPBridgeImpl{client: NewDatastoreServiceClient(client)} } -func (c *DatastoreServiceGRPC2HTTPBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { - return c.client.CreateDatastore(ctx, in) -} - -func (c *DatastoreServiceGRPC2HTTPBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { - return c.client.DeleteDatastore(ctx, in) +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) } func (c *DatastoreServiceGRPC2HTTPBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { return c.client.GetDatastore(ctx, in) } -func (c *DatastoreServiceGRPC2HTTPBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { - return c.client.ListDatastore(ctx, in) +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) } func (c *DatastoreServiceGRPC2HTTPBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { return c.client.UpdateDatastore(ctx, in) } +func (c *DatastoreServiceGRPC2HTTPBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + type DatastoreServiceHTTP2GRPCBridgeImpl struct { client DatastoreServiceHTTPClient } @@ -369,24 +369,24 @@ func NewDatastoreServiceHTTP2GRPC(client *http.Client) DatastoreServiceServer { return &DatastoreServiceHTTP2GRPCBridgeImpl{client: NewDatastoreServiceHTTPClient(client)} } -func (c *DatastoreServiceHTTP2GRPCBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { - return c.client.CreateDatastore(ctx, in) -} - -func (c *DatastoreServiceHTTP2GRPCBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { - return c.client.DeleteDatastore(ctx, in) +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { + return c.client.ListDatastore(ctx, in) } func (c *DatastoreServiceHTTP2GRPCBridgeImpl) GetDatastore(ctx context.Context, in *GetDatastoreRequest) (*GetDatastoreResponse, error) { return c.client.GetDatastore(ctx, in) } -func (c *DatastoreServiceHTTP2GRPCBridgeImpl) ListDatastore(ctx context.Context, in *ListDatastoreRequest) (*ListDatastoreResponse, error) { - return c.client.ListDatastore(ctx, in) +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) CreateDatastore(ctx context.Context, in *CreateDatastoreRequest) (*CreateDatastoreResponse, error) { + return c.client.CreateDatastore(ctx, in) } func (c *DatastoreServiceHTTP2GRPCBridgeImpl) UpdateDatastore(ctx context.Context, in *UpdateDatastoreRequest) (*UpdateDatastoreResponse, error) { return c.client.UpdateDatastore(ctx, in) } +func (c *DatastoreServiceHTTP2GRPCBridgeImpl) DeleteDatastore(ctx context.Context, in *DeleteDatastoreRequest) (*DeleteDatastoreResponse, error) { + return c.client.DeleteDatastore(ctx, in) +} + func (c *DatastoreServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedDatastoreServiceServer() {} diff --git a/api/v1/services/datastore/upload.pb.go b/api/v1/services/datastore/upload.pb.go index 227e8804..d0ceacbc 100644 --- a/api/v1/services/datastore/upload.pb.go +++ b/api/v1/services/datastore/upload.pb.go @@ -4,10 +4,9 @@ // protoc (unknown) // source: datastore/upload.proto -package upload +package datastore import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -618,7 +617,7 @@ var File_datastore_upload_proto protoreflect.FileDescriptor const file_datastore_upload_proto_rawDesc = "" + "\n" + - "\x16datastore/upload.proto\x12\x16api.v1.services.upload\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15types/datastore.proto\x1a\x17validate/validate.proto\"\xcd\x01\n" + + "\x16datastore/upload.proto\x12\x19api.v1.services.datastore\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x15types/datastore.proto\"\xcd\x01\n" + "\x11ListUploadRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\acurrent\x18\x02 \x01(\x05R\acurrent\x12\x1c\n" + @@ -659,15 +658,15 @@ const file_datastore_upload_proto_rawDesc = "" + "\x13DeleteUploadRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"D\n" + "\x14DeleteUploadResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x8e\x05\n" + - "\rUploadService\x12t\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xad\x05\n" + + "\rUploadService\x12z\n" + "\n" + - "ListUpload\x12).api.v1.services.upload.ListUploadRequest\x1a*.api.v1.services.upload.ListUploadResponse\"\x0f\x82\xd3\xe4\x93\x02\t\x12\a/upload\x12v\n" + - "\tGetUpload\x12(.api.v1.services.upload.GetUploadRequest\x1a).api.v1.services.upload.GetUploadResponse\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/upload/{id}\x12\x80\x01\n" + - "\fCreateUpload\x12+.api.v1.services.upload.CreateUploadRequest\x1a,.api.v1.services.upload.CreateUploadResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/upload\x12\x8a\x01\n" + - "\fUpdateUpload\x12+.api.v1.services.upload.UpdateUploadRequest\x1a,.api.v1.services.upload.UpdateUploadResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x04data\x1a\x11/upload/{data.id}\x12\x7f\n" + - "\fDeleteUpload\x12+.api.v1.services.upload.DeleteUploadRequest\x1a,.api.v1.services.upload.DeleteUploadResponse\"\x14\x82\xd3\xe4\x93\x02\x0e*\f/upload/{id}B\xe0\x01\n" + - "\x1acom.api.v1.services.uploadB\vUploadProtoP\x01Z9origadmin/application/admin/api/v1/services/upload;upload\xa2\x02\x04AVSU\xaa\x02\x16Api.V1.Services.Upload\xca\x02\x16Api\\V1\\Services\\Upload\xe2\x02\"Api\\V1\\Services\\Upload\\GPBMetadata\xea\x02\x19Api::V1::Services::Uploadb\x06proto3" + "ListUpload\x12,.api.v1.services.datastore.ListUploadRequest\x1a-.api.v1.services.datastore.ListUploadResponse\"\x0f\x82\xd3\xe4\x93\x02\t\x12\a/upload\x12|\n" + + "\tGetUpload\x12+.api.v1.services.datastore.GetUploadRequest\x1a,.api.v1.services.datastore.GetUploadResponse\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/upload/{id}\x12\x86\x01\n" + + "\fCreateUpload\x12..api.v1.services.datastore.CreateUploadRequest\x1a/.api.v1.services.datastore.CreateUploadResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x04data\"\a/upload\x12\x90\x01\n" + + "\fUpdateUpload\x12..api.v1.services.datastore.UpdateUploadRequest\x1a/.api.v1.services.datastore.UpdateUploadResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x04data\x1a\x11/upload/{data.id}\x12\x85\x01\n" + + "\fDeleteUpload\x12..api.v1.services.datastore.DeleteUploadRequest\x1a/.api.v1.services.datastore.DeleteUploadResponse\"\x14\x82\xd3\xe4\x93\x02\x0e*\f/upload/{id}B\xf5\x01\n" + + "\x1dcom.api.v1.services.datastoreB\vUploadProtoP\x01Z?origadmin/application/admin/api/v1/services/datastore;datastore\xa2\x02\x04AVSD\xaa\x02\x19Api.V1.Services.Datastore\xca\x02\x19Api\\V1\\Services\\Datastore\xe2\x02%Api\\V1\\Services\\Datastore\\GPBMetadata\xea\x02\x1cApi::V1::Services::Datastoreb\x06proto3" var ( file_datastore_upload_proto_rawDescOnce sync.Once @@ -683,39 +682,39 @@ func file_datastore_upload_proto_rawDescGZIP() []byte { var file_datastore_upload_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_datastore_upload_proto_goTypes = []any{ - (*ListUploadRequest)(nil), // 0: api.v1.services.upload.ListUploadRequest - (*ListUploadResponse)(nil), // 1: api.v1.services.upload.ListUploadResponse - (*GetUploadRequest)(nil), // 2: api.v1.services.upload.GetUploadRequest - (*GetUploadResponse)(nil), // 3: api.v1.services.upload.GetUploadResponse - (*CreateUploadRequest)(nil), // 4: api.v1.services.upload.CreateUploadRequest - (*CreateUploadResponse)(nil), // 5: api.v1.services.upload.CreateUploadResponse - (*UpdateUploadRequest)(nil), // 6: api.v1.services.upload.UpdateUploadRequest - (*UpdateUploadResponse)(nil), // 7: api.v1.services.upload.UpdateUploadResponse - (*DeleteUploadRequest)(nil), // 8: api.v1.services.upload.DeleteUploadRequest - (*DeleteUploadResponse)(nil), // 9: api.v1.services.upload.DeleteUploadResponse + (*ListUploadRequest)(nil), // 0: api.v1.services.datastore.ListUploadRequest + (*ListUploadResponse)(nil), // 1: api.v1.services.datastore.ListUploadResponse + (*GetUploadRequest)(nil), // 2: api.v1.services.datastore.GetUploadRequest + (*GetUploadResponse)(nil), // 3: api.v1.services.datastore.GetUploadResponse + (*CreateUploadRequest)(nil), // 4: api.v1.services.datastore.CreateUploadRequest + (*CreateUploadResponse)(nil), // 5: api.v1.services.datastore.CreateUploadResponse + (*UpdateUploadRequest)(nil), // 6: api.v1.services.datastore.UpdateUploadRequest + (*UpdateUploadResponse)(nil), // 7: api.v1.services.datastore.UpdateUploadResponse + (*DeleteUploadRequest)(nil), // 8: api.v1.services.datastore.DeleteUploadRequest + (*DeleteUploadResponse)(nil), // 9: api.v1.services.datastore.DeleteUploadResponse (*types.DataObject)(nil), // 10: api.v1.services.types.DataObject (*anypb.Any)(nil), // 11: google.protobuf.Any (*emptypb.Empty)(nil), // 12: google.protobuf.Empty } var file_datastore_upload_proto_depIdxs = []int32{ - 10, // 0: api.v1.services.upload.ListUploadResponse.data:type_name -> api.v1.services.types.DataObject - 11, // 1: api.v1.services.upload.ListUploadResponse.extra:type_name -> google.protobuf.Any - 10, // 2: api.v1.services.upload.GetUploadResponse.data:type_name -> api.v1.services.types.DataObject - 10, // 3: api.v1.services.upload.CreateUploadRequest.data:type_name -> api.v1.services.types.DataObject - 10, // 4: api.v1.services.upload.CreateUploadResponse.data:type_name -> api.v1.services.types.DataObject - 10, // 5: api.v1.services.upload.UpdateUploadRequest.data:type_name -> api.v1.services.types.DataObject - 10, // 6: api.v1.services.upload.UpdateUploadResponse.data:type_name -> api.v1.services.types.DataObject - 12, // 7: api.v1.services.upload.DeleteUploadResponse.empty:type_name -> google.protobuf.Empty - 0, // 8: api.v1.services.upload.UploadService.ListUpload:input_type -> api.v1.services.upload.ListUploadRequest - 2, // 9: api.v1.services.upload.UploadService.GetUpload:input_type -> api.v1.services.upload.GetUploadRequest - 4, // 10: api.v1.services.upload.UploadService.CreateUpload:input_type -> api.v1.services.upload.CreateUploadRequest - 6, // 11: api.v1.services.upload.UploadService.UpdateUpload:input_type -> api.v1.services.upload.UpdateUploadRequest - 8, // 12: api.v1.services.upload.UploadService.DeleteUpload:input_type -> api.v1.services.upload.DeleteUploadRequest - 1, // 13: api.v1.services.upload.UploadService.ListUpload:output_type -> api.v1.services.upload.ListUploadResponse - 3, // 14: api.v1.services.upload.UploadService.GetUpload:output_type -> api.v1.services.upload.GetUploadResponse - 5, // 15: api.v1.services.upload.UploadService.CreateUpload:output_type -> api.v1.services.upload.CreateUploadResponse - 7, // 16: api.v1.services.upload.UploadService.UpdateUpload:output_type -> api.v1.services.upload.UpdateUploadResponse - 9, // 17: api.v1.services.upload.UploadService.DeleteUpload:output_type -> api.v1.services.upload.DeleteUploadResponse + 10, // 0: api.v1.services.datastore.ListUploadResponse.data:type_name -> api.v1.services.types.DataObject + 11, // 1: api.v1.services.datastore.ListUploadResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.datastore.GetUploadResponse.data:type_name -> api.v1.services.types.DataObject + 10, // 3: api.v1.services.datastore.CreateUploadRequest.data:type_name -> api.v1.services.types.DataObject + 10, // 4: api.v1.services.datastore.CreateUploadResponse.data:type_name -> api.v1.services.types.DataObject + 10, // 5: api.v1.services.datastore.UpdateUploadRequest.data:type_name -> api.v1.services.types.DataObject + 10, // 6: api.v1.services.datastore.UpdateUploadResponse.data:type_name -> api.v1.services.types.DataObject + 12, // 7: api.v1.services.datastore.DeleteUploadResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.datastore.UploadService.ListUpload:input_type -> api.v1.services.datastore.ListUploadRequest + 2, // 9: api.v1.services.datastore.UploadService.GetUpload:input_type -> api.v1.services.datastore.GetUploadRequest + 4, // 10: api.v1.services.datastore.UploadService.CreateUpload:input_type -> api.v1.services.datastore.CreateUploadRequest + 6, // 11: api.v1.services.datastore.UploadService.UpdateUpload:input_type -> api.v1.services.datastore.UpdateUploadRequest + 8, // 12: api.v1.services.datastore.UploadService.DeleteUpload:input_type -> api.v1.services.datastore.DeleteUploadRequest + 1, // 13: api.v1.services.datastore.UploadService.ListUpload:output_type -> api.v1.services.datastore.ListUploadResponse + 3, // 14: api.v1.services.datastore.UploadService.GetUpload:output_type -> api.v1.services.datastore.GetUploadResponse + 5, // 15: api.v1.services.datastore.UploadService.CreateUpload:output_type -> api.v1.services.datastore.CreateUploadResponse + 7, // 16: api.v1.services.datastore.UploadService.UpdateUpload:output_type -> api.v1.services.datastore.UpdateUploadResponse + 9, // 17: api.v1.services.datastore.UploadService.DeleteUpload:output_type -> api.v1.services.datastore.DeleteUploadResponse 13, // [13:18] is the sub-list for method output_type 8, // [8:13] is the sub-list for method input_type 8, // [8:8] is the sub-list for extension type_name diff --git a/api/v1/services/datastore/upload.pb.gw.go b/api/v1/services/datastore/upload.pb.gw.go index 0084a218..e03f918c 100644 --- a/api/v1/services/datastore/upload.pb.gw.go +++ b/api/v1/services/datastore/upload.pb.gw.go @@ -2,11 +2,11 @@ // source: datastore/upload.proto /* -Package upload is a reverse proxy. +Package datastore is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ -package upload +package datastore import ( "context" @@ -248,7 +248,7 @@ func RegisterUploadServiceHandlerServer(ctx context.Context, mux *runtime.ServeM var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/ListUpload", runtime.WithHTTPPathPattern("/upload")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.UploadService/ListUpload", runtime.WithHTTPPathPattern("/upload")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -268,7 +268,7 @@ func RegisterUploadServiceHandlerServer(ctx context.Context, mux *runtime.ServeM var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/GetUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.UploadService/GetUpload", runtime.WithHTTPPathPattern("/upload/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -288,7 +288,7 @@ func RegisterUploadServiceHandlerServer(ctx context.Context, mux *runtime.ServeM var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/CreateUpload", runtime.WithHTTPPathPattern("/upload")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.UploadService/CreateUpload", runtime.WithHTTPPathPattern("/upload")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -308,7 +308,7 @@ func RegisterUploadServiceHandlerServer(ctx context.Context, mux *runtime.ServeM var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/UpdateUpload", runtime.WithHTTPPathPattern("/upload/{data.id}")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.UploadService/UpdateUpload", runtime.WithHTTPPathPattern("/upload/{data.id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -328,7 +328,7 @@ func RegisterUploadServiceHandlerServer(ctx context.Context, mux *runtime.ServeM var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.upload.UploadService/DeleteUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.datastore.UploadService/DeleteUpload", runtime.WithHTTPPathPattern("/upload/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -386,7 +386,7 @@ func RegisterUploadServiceHandlerClient(ctx context.Context, mux *runtime.ServeM ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/ListUpload", runtime.WithHTTPPathPattern("/upload")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.UploadService/ListUpload", runtime.WithHTTPPathPattern("/upload")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -403,7 +403,7 @@ func RegisterUploadServiceHandlerClient(ctx context.Context, mux *runtime.ServeM ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/GetUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.UploadService/GetUpload", runtime.WithHTTPPathPattern("/upload/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -420,7 +420,7 @@ func RegisterUploadServiceHandlerClient(ctx context.Context, mux *runtime.ServeM ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/CreateUpload", runtime.WithHTTPPathPattern("/upload")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.UploadService/CreateUpload", runtime.WithHTTPPathPattern("/upload")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -437,7 +437,7 @@ func RegisterUploadServiceHandlerClient(ctx context.Context, mux *runtime.ServeM ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/UpdateUpload", runtime.WithHTTPPathPattern("/upload/{data.id}")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.UploadService/UpdateUpload", runtime.WithHTTPPathPattern("/upload/{data.id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -454,7 +454,7 @@ func RegisterUploadServiceHandlerClient(ctx context.Context, mux *runtime.ServeM ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.upload.UploadService/DeleteUpload", runtime.WithHTTPPathPattern("/upload/{id}")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.datastore.UploadService/DeleteUpload", runtime.WithHTTPPathPattern("/upload/{id}")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return diff --git a/api/v1/services/datastore/upload.pb.validate.go b/api/v1/services/datastore/upload.pb.validate.go index 57c44c58..0808f2c8 100644 --- a/api/v1/services/datastore/upload.pb.validate.go +++ b/api/v1/services/datastore/upload.pb.validate.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-validate. DO NOT EDIT. // source: datastore/upload.proto -package upload +package datastore import ( "bytes" diff --git a/api/v1/services/datastore/upload_bridge.pb.go b/api/v1/services/datastore/upload_bridge.pb.go index 0043c929..16a27a94 100644 --- a/api/v1/services/datastore/upload_bridge.pb.go +++ b/api/v1/services/datastore/upload_bridge.pb.go @@ -4,7 +4,7 @@ // - protoc (unknown) // source: datastore/upload.proto -package upload +package datastore import ( context "context" @@ -28,52 +28,52 @@ var ( _ = codes.Unimplemented ) -const UploadServiceCreateUploadBridgeOperation = "/api.v1.services.upload.UploadService/CreateUpload" -const UploadServiceDeleteUploadBridgeOperation = "/api.v1.services.upload.UploadService/DeleteUpload" -const UploadServiceGetUploadBridgeOperation = "/api.v1.services.upload.UploadService/GetUpload" -const UploadServiceListUploadBridgeOperation = "/api.v1.services.upload.UploadService/ListUpload" -const UploadServiceUpdateUploadBridgeOperation = "/api.v1.services.upload.UploadService/UpdateUpload" +const UploadServiceListUploadBridgeOperation = "/api.v1.services.datastore.UploadService/ListUpload" +const UploadServiceGetUploadBridgeOperation = "/api.v1.services.datastore.UploadService/GetUpload" +const UploadServiceCreateUploadBridgeOperation = "/api.v1.services.datastore.UploadService/CreateUpload" +const UploadServiceUpdateUploadBridgeOperation = "/api.v1.services.datastore.UploadService/UpdateUpload" +const UploadServiceDeleteUploadBridgeOperation = "/api.v1.services.datastore.UploadService/DeleteUpload" type UploadServiceBridgeServer interface { - CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) - DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) - GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) ListUpload(context.Context, *ListUploadRequest) (*ListUploadResponse, error) + GetUpload(context.Context, *GetUploadRequest) (*GetUploadResponse, error) + CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) UpdateUpload(context.Context, *UpdateUploadRequest) (*UpdateUploadResponse, error) + DeleteUpload(context.Context, *DeleteUploadRequest) (*DeleteUploadResponse, error) } type UploadServiceHooker interface { - UploadServiceCreateUploadHooker - UploadServiceDeleteUploadHooker - UploadServiceGetUploadHooker UploadServiceListUploadHooker + UploadServiceGetUploadHooker + UploadServiceCreateUploadHooker UploadServiceUpdateUploadHooker + UploadServiceDeleteUploadHooker } type UploadServiceHookedBridger interface { UploadServiceHooker UploadServiceBridgeServer } -type UploadServiceCreateUploadHooker interface { - PrepareCreateUpload(http.Context, *CreateUploadRequest) (context.Context, error) - CompleteCreateUpload(http.Context, *CreateUploadRequest, *CreateUploadResponse) error -} -type UploadServiceDeleteUploadHooker interface { - PrepareDeleteUpload(http.Context, *DeleteUploadRequest) (context.Context, error) - CompleteDeleteUpload(http.Context, *DeleteUploadRequest, *DeleteUploadResponse) error +type UploadServiceListUploadHooker interface { + PrepareListUpload(http.Context, *ListUploadRequest) (context.Context, error) + CompleteListUpload(http.Context, *ListUploadRequest, *ListUploadResponse) error } type UploadServiceGetUploadHooker interface { PrepareGetUpload(http.Context, *GetUploadRequest) (context.Context, error) CompleteGetUpload(http.Context, *GetUploadRequest, *GetUploadResponse) error } -type UploadServiceListUploadHooker interface { - PrepareListUpload(http.Context, *ListUploadRequest) (context.Context, error) - CompleteListUpload(http.Context, *ListUploadRequest, *ListUploadResponse) error +type UploadServiceCreateUploadHooker interface { + PrepareCreateUpload(http.Context, *CreateUploadRequest) (context.Context, error) + CompleteCreateUpload(http.Context, *CreateUploadRequest, *CreateUploadResponse) error } type UploadServiceUpdateUploadHooker interface { PrepareUpdateUpload(http.Context, *UpdateUploadRequest) (context.Context, error) CompleteUpdateUpload(http.Context, *UpdateUploadRequest, *UpdateUploadResponse) error } +type UploadServiceDeleteUploadHooker interface { + PrepareDeleteUpload(http.Context, *DeleteUploadRequest) (context.Context, error) + CompleteDeleteUpload(http.Context, *DeleteUploadRequest, *DeleteUploadResponse) error +} func RegisterUploadServiceBridgeServer(s *http.Server, srv UploadServiceHookedBridger) { r := s.Route("/") @@ -221,43 +221,43 @@ func _UploadService_DeleteUpload0_Bridge_Handler(srv UploadServiceHookedBridger) // pointer dereference when methods are called. type UnimplementedUploadServiceHooked struct{} -func (UnimplementedUploadServiceHooked) PrepareCreateUpload(ctx http.Context, in *CreateUploadRequest) (context.Context, error) { +func (UnimplementedUploadServiceHooked) PrepareListUpload(ctx http.Context, in *ListUploadRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUploadServiceHooked) CompleteCreateUpload(ctx http.Context, in *CreateUploadRequest, out *CreateUploadResponse) error { +func (UnimplementedUploadServiceHooked) CompleteListUpload(ctx http.Context, in *ListUploadRequest, out *ListUploadResponse) error { return ctx.Result(200, out) } -func (UnimplementedUploadServiceHooked) PrepareDeleteUpload(ctx http.Context, in *DeleteUploadRequest) (context.Context, error) { +func (UnimplementedUploadServiceHooked) PrepareGetUpload(ctx http.Context, in *GetUploadRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUploadServiceHooked) CompleteDeleteUpload(ctx http.Context, in *DeleteUploadRequest, out *DeleteUploadResponse) error { +func (UnimplementedUploadServiceHooked) CompleteGetUpload(ctx http.Context, in *GetUploadRequest, out *GetUploadResponse) error { return ctx.Result(200, out) } -func (UnimplementedUploadServiceHooked) PrepareGetUpload(ctx http.Context, in *GetUploadRequest) (context.Context, error) { +func (UnimplementedUploadServiceHooked) PrepareCreateUpload(ctx http.Context, in *CreateUploadRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUploadServiceHooked) CompleteGetUpload(ctx http.Context, in *GetUploadRequest, out *GetUploadResponse) error { +func (UnimplementedUploadServiceHooked) CompleteCreateUpload(ctx http.Context, in *CreateUploadRequest, out *CreateUploadResponse) error { return ctx.Result(200, out) } -func (UnimplementedUploadServiceHooked) PrepareListUpload(ctx http.Context, in *ListUploadRequest) (context.Context, error) { +func (UnimplementedUploadServiceHooked) PrepareUpdateUpload(ctx http.Context, in *UpdateUploadRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUploadServiceHooked) CompleteListUpload(ctx http.Context, in *ListUploadRequest, out *ListUploadResponse) error { +func (UnimplementedUploadServiceHooked) CompleteUpdateUpload(ctx http.Context, in *UpdateUploadRequest, out *UpdateUploadResponse) error { return ctx.Result(200, out) } -func (UnimplementedUploadServiceHooked) PrepareUpdateUpload(ctx http.Context, in *UpdateUploadRequest) (context.Context, error) { +func (UnimplementedUploadServiceHooked) PrepareDeleteUpload(ctx http.Context, in *DeleteUploadRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUploadServiceHooked) CompleteUpdateUpload(ctx http.Context, in *UpdateUploadRequest, out *UpdateUploadResponse) error { +func (UnimplementedUploadServiceHooked) CompleteDeleteUpload(ctx http.Context, in *DeleteUploadRequest, out *DeleteUploadResponse) error { return ctx.Result(200, out) } @@ -283,26 +283,26 @@ func NewUploadServiceHTTPBridge(client *http.Client) UploadServiceHTTPServer { return &UploadServiceHTTPBridgeImpl{client: NewUploadServiceHTTPClient(client)} } -func (c *UploadServiceHTTPBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { - return c.client.CreateUpload(ctx, in) -} - -func (c *UploadServiceHTTPBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { - return c.client.DeleteUpload(ctx, in) +func (c *UploadServiceHTTPBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) } func (c *UploadServiceHTTPBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { return c.client.GetUpload(ctx, in) } -func (c *UploadServiceHTTPBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { - return c.client.ListUpload(ctx, in) +func (c *UploadServiceHTTPBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) } func (c *UploadServiceHTTPBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { return c.client.UpdateUpload(ctx, in) } +func (c *UploadServiceHTTPBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + type UploadServiceBridgeImpl struct { client UploadServiceClient } @@ -311,26 +311,26 @@ func NewUploadServiceBridge(client grpc.ClientConnInterface) UploadServiceServer return &UploadServiceBridgeImpl{client: NewUploadServiceClient(client)} } -func (c *UploadServiceBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { - return c.client.CreateUpload(ctx, in) -} - -func (c *UploadServiceBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { - return c.client.DeleteUpload(ctx, in) +func (c *UploadServiceBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) } func (c *UploadServiceBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { return c.client.GetUpload(ctx, in) } -func (c *UploadServiceBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { - return c.client.ListUpload(ctx, in) +func (c *UploadServiceBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) } func (c *UploadServiceBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { return c.client.UpdateUpload(ctx, in) } +func (c *UploadServiceBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + func (c *UploadServiceBridgeImpl) mustEmbedUnimplementedUploadServiceServer() {} type UploadServiceGRPC2HTTPBridgeImpl struct { @@ -341,26 +341,26 @@ func NewUploadServiceGRPC2HTTP(client grpc.ClientConnInterface) UploadServiceHTT return &UploadServiceGRPC2HTTPBridgeImpl{client: NewUploadServiceClient(client)} } -func (c *UploadServiceGRPC2HTTPBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { - return c.client.CreateUpload(ctx, in) -} - -func (c *UploadServiceGRPC2HTTPBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { - return c.client.DeleteUpload(ctx, in) +func (c *UploadServiceGRPC2HTTPBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) } func (c *UploadServiceGRPC2HTTPBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { return c.client.GetUpload(ctx, in) } -func (c *UploadServiceGRPC2HTTPBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { - return c.client.ListUpload(ctx, in) +func (c *UploadServiceGRPC2HTTPBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) } func (c *UploadServiceGRPC2HTTPBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { return c.client.UpdateUpload(ctx, in) } +func (c *UploadServiceGRPC2HTTPBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + type UploadServiceHTTP2GRPCBridgeImpl struct { client UploadServiceHTTPClient } @@ -369,24 +369,24 @@ func NewUploadServiceHTTP2GRPC(client *http.Client) UploadServiceServer { return &UploadServiceHTTP2GRPCBridgeImpl{client: NewUploadServiceHTTPClient(client)} } -func (c *UploadServiceHTTP2GRPCBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { - return c.client.CreateUpload(ctx, in) -} - -func (c *UploadServiceHTTP2GRPCBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { - return c.client.DeleteUpload(ctx, in) +func (c *UploadServiceHTTP2GRPCBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { + return c.client.ListUpload(ctx, in) } func (c *UploadServiceHTTP2GRPCBridgeImpl) GetUpload(ctx context.Context, in *GetUploadRequest) (*GetUploadResponse, error) { return c.client.GetUpload(ctx, in) } -func (c *UploadServiceHTTP2GRPCBridgeImpl) ListUpload(ctx context.Context, in *ListUploadRequest) (*ListUploadResponse, error) { - return c.client.ListUpload(ctx, in) +func (c *UploadServiceHTTP2GRPCBridgeImpl) CreateUpload(ctx context.Context, in *CreateUploadRequest) (*CreateUploadResponse, error) { + return c.client.CreateUpload(ctx, in) } func (c *UploadServiceHTTP2GRPCBridgeImpl) UpdateUpload(ctx context.Context, in *UpdateUploadRequest) (*UpdateUploadResponse, error) { return c.client.UpdateUpload(ctx, in) } +func (c *UploadServiceHTTP2GRPCBridgeImpl) DeleteUpload(ctx context.Context, in *DeleteUploadRequest) (*DeleteUploadResponse, error) { + return c.client.DeleteUpload(ctx, in) +} + func (c *UploadServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedUploadServiceServer() {} diff --git a/api/v1/services/datastore/upload_grpc.pb.go b/api/v1/services/datastore/upload_grpc.pb.go index 8f0238b8..51e450de 100644 --- a/api/v1/services/datastore/upload_grpc.pb.go +++ b/api/v1/services/datastore/upload_grpc.pb.go @@ -4,7 +4,7 @@ // - protoc (unknown) // source: datastore/upload.proto -package upload +package datastore import ( context "context" @@ -19,11 +19,11 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - UploadService_ListUpload_FullMethodName = "/api.v1.services.upload.UploadService/ListUpload" - UploadService_GetUpload_FullMethodName = "/api.v1.services.upload.UploadService/GetUpload" - UploadService_CreateUpload_FullMethodName = "/api.v1.services.upload.UploadService/CreateUpload" - UploadService_UpdateUpload_FullMethodName = "/api.v1.services.upload.UploadService/UpdateUpload" - UploadService_DeleteUpload_FullMethodName = "/api.v1.services.upload.UploadService/DeleteUpload" + UploadService_ListUpload_FullMethodName = "/api.v1.services.datastore.UploadService/ListUpload" + UploadService_GetUpload_FullMethodName = "/api.v1.services.datastore.UploadService/GetUpload" + UploadService_CreateUpload_FullMethodName = "/api.v1.services.datastore.UploadService/CreateUpload" + UploadService_UpdateUpload_FullMethodName = "/api.v1.services.datastore.UploadService/UpdateUpload" + UploadService_DeleteUpload_FullMethodName = "/api.v1.services.datastore.UploadService/DeleteUpload" ) // UploadServiceClient is the client API for UploadService service. @@ -248,7 +248,7 @@ func _UploadService_DeleteUpload_Handler(srv interface{}, ctx context.Context, d // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var UploadService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.upload.UploadService", + ServiceName: "api.v1.services.datastore.UploadService", HandlerType: (*UploadServiceServer)(nil), Methods: []grpc.MethodDesc{ { diff --git a/api/v1/services/datastore/upload_http.pb.go b/api/v1/services/datastore/upload_http.pb.go index 2162bd5d..f0b68964 100644 --- a/api/v1/services/datastore/upload_http.pb.go +++ b/api/v1/services/datastore/upload_http.pb.go @@ -4,7 +4,7 @@ // - protoc (unknown) // source: datastore/upload.proto -package upload +package datastore import ( context "context" @@ -19,11 +19,11 @@ var _ = binding.EncodeURL const _ = http.SupportPackageIsVersion1 -const OperationUploadServiceCreateUpload = "/api.v1.services.upload.UploadService/CreateUpload" -const OperationUploadServiceDeleteUpload = "/api.v1.services.upload.UploadService/DeleteUpload" -const OperationUploadServiceGetUpload = "/api.v1.services.upload.UploadService/GetUpload" -const OperationUploadServiceListUpload = "/api.v1.services.upload.UploadService/ListUpload" -const OperationUploadServiceUpdateUpload = "/api.v1.services.upload.UploadService/UpdateUpload" +const OperationUploadServiceCreateUpload = "/api.v1.services.datastore.UploadService/CreateUpload" +const OperationUploadServiceDeleteUpload = "/api.v1.services.datastore.UploadService/DeleteUpload" +const OperationUploadServiceGetUpload = "/api.v1.services.datastore.UploadService/GetUpload" +const OperationUploadServiceListUpload = "/api.v1.services.datastore.UploadService/ListUpload" +const OperationUploadServiceUpdateUpload = "/api.v1.services.datastore.UploadService/UpdateUpload" type UploadServiceHTTPServer interface { CreateUpload(context.Context, *CreateUploadRequest) (*CreateUploadResponse, error) diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go index 03833d7c..c4876b90 100644 --- a/api/v1/services/system/department_bridge.pb.go +++ b/api/v1/services/system/department_bridge.pb.go @@ -28,52 +28,52 @@ var ( _ = codes.Unimplemented ) -const DepartmentServiceCreateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/CreateDepartment" -const DepartmentServiceDeleteDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/DeleteDepartment" -const DepartmentServiceGetDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/GetDepartment" const DepartmentServiceListDepartmentsBridgeOperation = "/api.v1.services.system.DepartmentService/ListDepartments" +const DepartmentServiceGetDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/GetDepartment" +const DepartmentServiceCreateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/CreateDepartment" const DepartmentServiceUpdateDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/UpdateDepartment" +const DepartmentServiceDeleteDepartmentBridgeOperation = "/api.v1.services.system.DepartmentService/DeleteDepartment" type DepartmentServiceBridgeServer interface { - CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) - DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) - GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) ListDepartments(context.Context, *ListDepartmentsRequest) (*ListDepartmentsResponse, error) + GetDepartment(context.Context, *GetDepartmentRequest) (*GetDepartmentResponse, error) + CreateDepartment(context.Context, *CreateDepartmentRequest) (*CreateDepartmentResponse, error) UpdateDepartment(context.Context, *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) + DeleteDepartment(context.Context, *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) } type DepartmentServiceHooker interface { - DepartmentServiceCreateDepartmentHooker - DepartmentServiceDeleteDepartmentHooker - DepartmentServiceGetDepartmentHooker DepartmentServiceListDepartmentsHooker + DepartmentServiceGetDepartmentHooker + DepartmentServiceCreateDepartmentHooker DepartmentServiceUpdateDepartmentHooker + DepartmentServiceDeleteDepartmentHooker } type DepartmentServiceHookedBridger interface { DepartmentServiceHooker DepartmentServiceBridgeServer } -type DepartmentServiceCreateDepartmentHooker interface { - PrepareCreateDepartment(http.Context, *CreateDepartmentRequest) (context.Context, error) - CompleteCreateDepartment(http.Context, *CreateDepartmentRequest, *CreateDepartmentResponse) error -} -type DepartmentServiceDeleteDepartmentHooker interface { - PrepareDeleteDepartment(http.Context, *DeleteDepartmentRequest) (context.Context, error) - CompleteDeleteDepartment(http.Context, *DeleteDepartmentRequest, *DeleteDepartmentResponse) error +type DepartmentServiceListDepartmentsHooker interface { + PrepareListDepartments(http.Context, *ListDepartmentsRequest) (context.Context, error) + CompleteListDepartments(http.Context, *ListDepartmentsRequest, *ListDepartmentsResponse) error } type DepartmentServiceGetDepartmentHooker interface { PrepareGetDepartment(http.Context, *GetDepartmentRequest) (context.Context, error) CompleteGetDepartment(http.Context, *GetDepartmentRequest, *GetDepartmentResponse) error } -type DepartmentServiceListDepartmentsHooker interface { - PrepareListDepartments(http.Context, *ListDepartmentsRequest) (context.Context, error) - CompleteListDepartments(http.Context, *ListDepartmentsRequest, *ListDepartmentsResponse) error +type DepartmentServiceCreateDepartmentHooker interface { + PrepareCreateDepartment(http.Context, *CreateDepartmentRequest) (context.Context, error) + CompleteCreateDepartment(http.Context, *CreateDepartmentRequest, *CreateDepartmentResponse) error } type DepartmentServiceUpdateDepartmentHooker interface { PrepareUpdateDepartment(http.Context, *UpdateDepartmentRequest) (context.Context, error) CompleteUpdateDepartment(http.Context, *UpdateDepartmentRequest, *UpdateDepartmentResponse) error } +type DepartmentServiceDeleteDepartmentHooker interface { + PrepareDeleteDepartment(http.Context, *DeleteDepartmentRequest) (context.Context, error) + CompleteDeleteDepartment(http.Context, *DeleteDepartmentRequest, *DeleteDepartmentResponse) error +} func RegisterDepartmentServiceBridgeServer(s *http.Server, srv DepartmentServiceHookedBridger) { r := s.Route("/") @@ -221,43 +221,43 @@ func _DepartmentService_DeleteDepartment0_Bridge_Handler(srv DepartmentServiceHo // pointer dereference when methods are called. type UnimplementedDepartmentServiceHooked struct{} -func (UnimplementedDepartmentServiceHooked) PrepareCreateDepartment(ctx http.Context, in *CreateDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) PrepareListDepartments(ctx http.Context, in *ListDepartmentsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceHooked) CompleteCreateDepartment(ctx http.Context, in *CreateDepartmentRequest, out *CreateDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) CompleteListDepartments(ctx http.Context, in *ListDepartmentsRequest, out *ListDepartmentsResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceHooked) PrepareDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) PrepareGetDepartment(ctx http.Context, in *GetDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceHooked) CompleteDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest, out *DeleteDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) CompleteGetDepartment(ctx http.Context, in *GetDepartmentRequest, out *GetDepartmentResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceHooked) PrepareGetDepartment(ctx http.Context, in *GetDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) PrepareCreateDepartment(ctx http.Context, in *CreateDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceHooked) CompleteGetDepartment(ctx http.Context, in *GetDepartmentRequest, out *GetDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) CompleteCreateDepartment(ctx http.Context, in *CreateDepartmentRequest, out *CreateDepartmentResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceHooked) PrepareListDepartments(ctx http.Context, in *ListDepartmentsRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) PrepareUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceHooked) CompleteListDepartments(ctx http.Context, in *ListDepartmentsRequest, out *ListDepartmentsResponse) error { +func (UnimplementedDepartmentServiceHooked) CompleteUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest, out *UpdateDepartmentResponse) error { return ctx.Result(200, out) } -func (UnimplementedDepartmentServiceHooked) PrepareUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest) (context.Context, error) { +func (UnimplementedDepartmentServiceHooked) PrepareDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedDepartmentServiceHooked) CompleteUpdateDepartment(ctx http.Context, in *UpdateDepartmentRequest, out *UpdateDepartmentResponse) error { +func (UnimplementedDepartmentServiceHooked) CompleteDeleteDepartment(ctx http.Context, in *DeleteDepartmentRequest, out *DeleteDepartmentResponse) error { return ctx.Result(200, out) } @@ -283,26 +283,26 @@ func NewDepartmentServiceHTTPBridge(client *http.Client) DepartmentServiceHTTPSe return &DepartmentServiceHTTPBridgeImpl{client: NewDepartmentServiceHTTPClient(client)} } -func (c *DepartmentServiceHTTPBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { - return c.client.CreateDepartment(ctx, in) -} - -func (c *DepartmentServiceHTTPBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { - return c.client.DeleteDepartment(ctx, in) +func (c *DepartmentServiceHTTPBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) } func (c *DepartmentServiceHTTPBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { return c.client.GetDepartment(ctx, in) } -func (c *DepartmentServiceHTTPBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { - return c.client.ListDepartments(ctx, in) +func (c *DepartmentServiceHTTPBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) } func (c *DepartmentServiceHTTPBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { return c.client.UpdateDepartment(ctx, in) } +func (c *DepartmentServiceHTTPBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + type DepartmentServiceBridgeImpl struct { client DepartmentServiceClient } @@ -311,26 +311,26 @@ func NewDepartmentServiceBridge(client grpc.ClientConnInterface) DepartmentServi return &DepartmentServiceBridgeImpl{client: NewDepartmentServiceClient(client)} } -func (c *DepartmentServiceBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { - return c.client.CreateDepartment(ctx, in) -} - -func (c *DepartmentServiceBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { - return c.client.DeleteDepartment(ctx, in) +func (c *DepartmentServiceBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) } func (c *DepartmentServiceBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { return c.client.GetDepartment(ctx, in) } -func (c *DepartmentServiceBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { - return c.client.ListDepartments(ctx, in) +func (c *DepartmentServiceBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) } func (c *DepartmentServiceBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { return c.client.UpdateDepartment(ctx, in) } +func (c *DepartmentServiceBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + func (c *DepartmentServiceBridgeImpl) mustEmbedUnimplementedDepartmentServiceServer() {} type DepartmentServiceGRPC2HTTPBridgeImpl struct { @@ -341,26 +341,26 @@ func NewDepartmentServiceGRPC2HTTP(client grpc.ClientConnInterface) DepartmentSe return &DepartmentServiceGRPC2HTTPBridgeImpl{client: NewDepartmentServiceClient(client)} } -func (c *DepartmentServiceGRPC2HTTPBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { - return c.client.CreateDepartment(ctx, in) -} - -func (c *DepartmentServiceGRPC2HTTPBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { - return c.client.DeleteDepartment(ctx, in) +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) } func (c *DepartmentServiceGRPC2HTTPBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { return c.client.GetDepartment(ctx, in) } -func (c *DepartmentServiceGRPC2HTTPBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { - return c.client.ListDepartments(ctx, in) +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) } func (c *DepartmentServiceGRPC2HTTPBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { return c.client.UpdateDepartment(ctx, in) } +func (c *DepartmentServiceGRPC2HTTPBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + type DepartmentServiceHTTP2GRPCBridgeImpl struct { client DepartmentServiceHTTPClient } @@ -369,24 +369,24 @@ func NewDepartmentServiceHTTP2GRPC(client *http.Client) DepartmentServiceServer return &DepartmentServiceHTTP2GRPCBridgeImpl{client: NewDepartmentServiceHTTPClient(client)} } -func (c *DepartmentServiceHTTP2GRPCBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { - return c.client.CreateDepartment(ctx, in) -} - -func (c *DepartmentServiceHTTP2GRPCBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { - return c.client.DeleteDepartment(ctx, in) +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { + return c.client.ListDepartments(ctx, in) } func (c *DepartmentServiceHTTP2GRPCBridgeImpl) GetDepartment(ctx context.Context, in *GetDepartmentRequest) (*GetDepartmentResponse, error) { return c.client.GetDepartment(ctx, in) } -func (c *DepartmentServiceHTTP2GRPCBridgeImpl) ListDepartments(ctx context.Context, in *ListDepartmentsRequest) (*ListDepartmentsResponse, error) { - return c.client.ListDepartments(ctx, in) +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) CreateDepartment(ctx context.Context, in *CreateDepartmentRequest) (*CreateDepartmentResponse, error) { + return c.client.CreateDepartment(ctx, in) } func (c *DepartmentServiceHTTP2GRPCBridgeImpl) UpdateDepartment(ctx context.Context, in *UpdateDepartmentRequest) (*UpdateDepartmentResponse, error) { return c.client.UpdateDepartment(ctx, in) } +func (c *DepartmentServiceHTTP2GRPCBridgeImpl) DeleteDepartment(ctx context.Context, in *DeleteDepartmentRequest) (*DeleteDepartmentResponse, error) { + return c.client.DeleteDepartment(ctx, in) +} + func (c *DepartmentServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedDepartmentServiceServer() {} diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go index 188a6d8b..c1da935f 100644 --- a/api/v1/services/system/permission_bridge.pb.go +++ b/api/v1/services/system/permission_bridge.pb.go @@ -28,52 +28,52 @@ var ( _ = codes.Unimplemented ) -const PermissionServiceCreatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/CreatePermission" -const PermissionServiceDeletePermissionBridgeOperation = "/api.v1.services.system.PermissionService/DeletePermission" -const PermissionServiceGetPermissionBridgeOperation = "/api.v1.services.system.PermissionService/GetPermission" const PermissionServiceListPermissionsBridgeOperation = "/api.v1.services.system.PermissionService/ListPermissions" +const PermissionServiceGetPermissionBridgeOperation = "/api.v1.services.system.PermissionService/GetPermission" +const PermissionServiceCreatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/CreatePermission" const PermissionServiceUpdatePermissionBridgeOperation = "/api.v1.services.system.PermissionService/UpdatePermission" +const PermissionServiceDeletePermissionBridgeOperation = "/api.v1.services.system.PermissionService/DeletePermission" type PermissionServiceBridgeServer interface { - CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) - DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) - GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) ListPermissions(context.Context, *ListPermissionsRequest) (*ListPermissionsResponse, error) + GetPermission(context.Context, *GetPermissionRequest) (*GetPermissionResponse, error) + CreatePermission(context.Context, *CreatePermissionRequest) (*CreatePermissionResponse, error) UpdatePermission(context.Context, *UpdatePermissionRequest) (*UpdatePermissionResponse, error) + DeletePermission(context.Context, *DeletePermissionRequest) (*DeletePermissionResponse, error) } type PermissionServiceHooker interface { - PermissionServiceCreatePermissionHooker - PermissionServiceDeletePermissionHooker - PermissionServiceGetPermissionHooker PermissionServiceListPermissionsHooker + PermissionServiceGetPermissionHooker + PermissionServiceCreatePermissionHooker PermissionServiceUpdatePermissionHooker + PermissionServiceDeletePermissionHooker } type PermissionServiceHookedBridger interface { PermissionServiceHooker PermissionServiceBridgeServer } -type PermissionServiceCreatePermissionHooker interface { - PrepareCreatePermission(http.Context, *CreatePermissionRequest) (context.Context, error) - CompleteCreatePermission(http.Context, *CreatePermissionRequest, *CreatePermissionResponse) error -} -type PermissionServiceDeletePermissionHooker interface { - PrepareDeletePermission(http.Context, *DeletePermissionRequest) (context.Context, error) - CompleteDeletePermission(http.Context, *DeletePermissionRequest, *DeletePermissionResponse) error +type PermissionServiceListPermissionsHooker interface { + PrepareListPermissions(http.Context, *ListPermissionsRequest) (context.Context, error) + CompleteListPermissions(http.Context, *ListPermissionsRequest, *ListPermissionsResponse) error } type PermissionServiceGetPermissionHooker interface { PrepareGetPermission(http.Context, *GetPermissionRequest) (context.Context, error) CompleteGetPermission(http.Context, *GetPermissionRequest, *GetPermissionResponse) error } -type PermissionServiceListPermissionsHooker interface { - PrepareListPermissions(http.Context, *ListPermissionsRequest) (context.Context, error) - CompleteListPermissions(http.Context, *ListPermissionsRequest, *ListPermissionsResponse) error +type PermissionServiceCreatePermissionHooker interface { + PrepareCreatePermission(http.Context, *CreatePermissionRequest) (context.Context, error) + CompleteCreatePermission(http.Context, *CreatePermissionRequest, *CreatePermissionResponse) error } type PermissionServiceUpdatePermissionHooker interface { PrepareUpdatePermission(http.Context, *UpdatePermissionRequest) (context.Context, error) CompleteUpdatePermission(http.Context, *UpdatePermissionRequest, *UpdatePermissionResponse) error } +type PermissionServiceDeletePermissionHooker interface { + PrepareDeletePermission(http.Context, *DeletePermissionRequest) (context.Context, error) + CompleteDeletePermission(http.Context, *DeletePermissionRequest, *DeletePermissionResponse) error +} func RegisterPermissionServiceBridgeServer(s *http.Server, srv PermissionServiceHookedBridger) { r := s.Route("/") @@ -221,43 +221,43 @@ func _PermissionService_DeletePermission0_Bridge_Handler(srv PermissionServiceHo // pointer dereference when methods are called. type UnimplementedPermissionServiceHooked struct{} -func (UnimplementedPermissionServiceHooked) PrepareCreatePermission(ctx http.Context, in *CreatePermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) PrepareListPermissions(ctx http.Context, in *ListPermissionsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceHooked) CompleteCreatePermission(ctx http.Context, in *CreatePermissionRequest, out *CreatePermissionResponse) error { +func (UnimplementedPermissionServiceHooked) CompleteListPermissions(ctx http.Context, in *ListPermissionsRequest, out *ListPermissionsResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceHooked) PrepareDeletePermission(ctx http.Context, in *DeletePermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) PrepareGetPermission(ctx http.Context, in *GetPermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceHooked) CompleteDeletePermission(ctx http.Context, in *DeletePermissionRequest, out *DeletePermissionResponse) error { +func (UnimplementedPermissionServiceHooked) CompleteGetPermission(ctx http.Context, in *GetPermissionRequest, out *GetPermissionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceHooked) PrepareGetPermission(ctx http.Context, in *GetPermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) PrepareCreatePermission(ctx http.Context, in *CreatePermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceHooked) CompleteGetPermission(ctx http.Context, in *GetPermissionRequest, out *GetPermissionResponse) error { +func (UnimplementedPermissionServiceHooked) CompleteCreatePermission(ctx http.Context, in *CreatePermissionRequest, out *CreatePermissionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceHooked) PrepareListPermissions(ctx http.Context, in *ListPermissionsRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) PrepareUpdatePermission(ctx http.Context, in *UpdatePermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceHooked) CompleteListPermissions(ctx http.Context, in *ListPermissionsRequest, out *ListPermissionsResponse) error { +func (UnimplementedPermissionServiceHooked) CompleteUpdatePermission(ctx http.Context, in *UpdatePermissionRequest, out *UpdatePermissionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPermissionServiceHooked) PrepareUpdatePermission(ctx http.Context, in *UpdatePermissionRequest) (context.Context, error) { +func (UnimplementedPermissionServiceHooked) PrepareDeletePermission(ctx http.Context, in *DeletePermissionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPermissionServiceHooked) CompleteUpdatePermission(ctx http.Context, in *UpdatePermissionRequest, out *UpdatePermissionResponse) error { +func (UnimplementedPermissionServiceHooked) CompleteDeletePermission(ctx http.Context, in *DeletePermissionRequest, out *DeletePermissionResponse) error { return ctx.Result(200, out) } @@ -283,26 +283,26 @@ func NewPermissionServiceHTTPBridge(client *http.Client) PermissionServiceHTTPSe return &PermissionServiceHTTPBridgeImpl{client: NewPermissionServiceHTTPClient(client)} } -func (c *PermissionServiceHTTPBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { - return c.client.CreatePermission(ctx, in) -} - -func (c *PermissionServiceHTTPBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { - return c.client.DeletePermission(ctx, in) +func (c *PermissionServiceHTTPBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) } func (c *PermissionServiceHTTPBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { return c.client.GetPermission(ctx, in) } -func (c *PermissionServiceHTTPBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { - return c.client.ListPermissions(ctx, in) +func (c *PermissionServiceHTTPBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) } func (c *PermissionServiceHTTPBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { return c.client.UpdatePermission(ctx, in) } +func (c *PermissionServiceHTTPBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + type PermissionServiceBridgeImpl struct { client PermissionServiceClient } @@ -311,26 +311,26 @@ func NewPermissionServiceBridge(client grpc.ClientConnInterface) PermissionServi return &PermissionServiceBridgeImpl{client: NewPermissionServiceClient(client)} } -func (c *PermissionServiceBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { - return c.client.CreatePermission(ctx, in) -} - -func (c *PermissionServiceBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { - return c.client.DeletePermission(ctx, in) +func (c *PermissionServiceBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) } func (c *PermissionServiceBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { return c.client.GetPermission(ctx, in) } -func (c *PermissionServiceBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { - return c.client.ListPermissions(ctx, in) +func (c *PermissionServiceBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) } func (c *PermissionServiceBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { return c.client.UpdatePermission(ctx, in) } +func (c *PermissionServiceBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + func (c *PermissionServiceBridgeImpl) mustEmbedUnimplementedPermissionServiceServer() {} type PermissionServiceGRPC2HTTPBridgeImpl struct { @@ -341,26 +341,26 @@ func NewPermissionServiceGRPC2HTTP(client grpc.ClientConnInterface) PermissionSe return &PermissionServiceGRPC2HTTPBridgeImpl{client: NewPermissionServiceClient(client)} } -func (c *PermissionServiceGRPC2HTTPBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { - return c.client.CreatePermission(ctx, in) -} - -func (c *PermissionServiceGRPC2HTTPBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { - return c.client.DeletePermission(ctx, in) +func (c *PermissionServiceGRPC2HTTPBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) } func (c *PermissionServiceGRPC2HTTPBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { return c.client.GetPermission(ctx, in) } -func (c *PermissionServiceGRPC2HTTPBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { - return c.client.ListPermissions(ctx, in) +func (c *PermissionServiceGRPC2HTTPBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) } func (c *PermissionServiceGRPC2HTTPBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { return c.client.UpdatePermission(ctx, in) } +func (c *PermissionServiceGRPC2HTTPBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + type PermissionServiceHTTP2GRPCBridgeImpl struct { client PermissionServiceHTTPClient } @@ -369,24 +369,24 @@ func NewPermissionServiceHTTP2GRPC(client *http.Client) PermissionServiceServer return &PermissionServiceHTTP2GRPCBridgeImpl{client: NewPermissionServiceHTTPClient(client)} } -func (c *PermissionServiceHTTP2GRPCBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { - return c.client.CreatePermission(ctx, in) -} - -func (c *PermissionServiceHTTP2GRPCBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { - return c.client.DeletePermission(ctx, in) +func (c *PermissionServiceHTTP2GRPCBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { + return c.client.ListPermissions(ctx, in) } func (c *PermissionServiceHTTP2GRPCBridgeImpl) GetPermission(ctx context.Context, in *GetPermissionRequest) (*GetPermissionResponse, error) { return c.client.GetPermission(ctx, in) } -func (c *PermissionServiceHTTP2GRPCBridgeImpl) ListPermissions(ctx context.Context, in *ListPermissionsRequest) (*ListPermissionsResponse, error) { - return c.client.ListPermissions(ctx, in) +func (c *PermissionServiceHTTP2GRPCBridgeImpl) CreatePermission(ctx context.Context, in *CreatePermissionRequest) (*CreatePermissionResponse, error) { + return c.client.CreatePermission(ctx, in) } func (c *PermissionServiceHTTP2GRPCBridgeImpl) UpdatePermission(ctx context.Context, in *UpdatePermissionRequest) (*UpdatePermissionResponse, error) { return c.client.UpdatePermission(ctx, in) } +func (c *PermissionServiceHTTP2GRPCBridgeImpl) DeletePermission(ctx context.Context, in *DeletePermissionRequest) (*DeletePermissionResponse, error) { + return c.client.DeletePermission(ctx, in) +} + func (c *PermissionServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPermissionServiceServer() {} diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go index c518fd36..9f1d551d 100644 --- a/api/v1/services/system/position_bridge.pb.go +++ b/api/v1/services/system/position_bridge.pb.go @@ -28,52 +28,52 @@ var ( _ = codes.Unimplemented ) -const PositionServiceCreatePositionBridgeOperation = "/api.v1.services.system.PositionService/CreatePosition" -const PositionServiceDeletePositionBridgeOperation = "/api.v1.services.system.PositionService/DeletePosition" -const PositionServiceGetPositionBridgeOperation = "/api.v1.services.system.PositionService/GetPosition" const PositionServiceListPositionsBridgeOperation = "/api.v1.services.system.PositionService/ListPositions" +const PositionServiceGetPositionBridgeOperation = "/api.v1.services.system.PositionService/GetPosition" +const PositionServiceCreatePositionBridgeOperation = "/api.v1.services.system.PositionService/CreatePosition" const PositionServiceUpdatePositionBridgeOperation = "/api.v1.services.system.PositionService/UpdatePosition" +const PositionServiceDeletePositionBridgeOperation = "/api.v1.services.system.PositionService/DeletePosition" type PositionServiceBridgeServer interface { - CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) - DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) - GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) ListPositions(context.Context, *ListPositionsRequest) (*ListPositionsResponse, error) + GetPosition(context.Context, *GetPositionRequest) (*GetPositionResponse, error) + CreatePosition(context.Context, *CreatePositionRequest) (*CreatePositionResponse, error) UpdatePosition(context.Context, *UpdatePositionRequest) (*UpdatePositionResponse, error) + DeletePosition(context.Context, *DeletePositionRequest) (*DeletePositionResponse, error) } type PositionServiceHooker interface { - PositionServiceCreatePositionHooker - PositionServiceDeletePositionHooker - PositionServiceGetPositionHooker PositionServiceListPositionsHooker + PositionServiceGetPositionHooker + PositionServiceCreatePositionHooker PositionServiceUpdatePositionHooker + PositionServiceDeletePositionHooker } type PositionServiceHookedBridger interface { PositionServiceHooker PositionServiceBridgeServer } -type PositionServiceCreatePositionHooker interface { - PrepareCreatePosition(http.Context, *CreatePositionRequest) (context.Context, error) - CompleteCreatePosition(http.Context, *CreatePositionRequest, *CreatePositionResponse) error -} -type PositionServiceDeletePositionHooker interface { - PrepareDeletePosition(http.Context, *DeletePositionRequest) (context.Context, error) - CompleteDeletePosition(http.Context, *DeletePositionRequest, *DeletePositionResponse) error +type PositionServiceListPositionsHooker interface { + PrepareListPositions(http.Context, *ListPositionsRequest) (context.Context, error) + CompleteListPositions(http.Context, *ListPositionsRequest, *ListPositionsResponse) error } type PositionServiceGetPositionHooker interface { PrepareGetPosition(http.Context, *GetPositionRequest) (context.Context, error) CompleteGetPosition(http.Context, *GetPositionRequest, *GetPositionResponse) error } -type PositionServiceListPositionsHooker interface { - PrepareListPositions(http.Context, *ListPositionsRequest) (context.Context, error) - CompleteListPositions(http.Context, *ListPositionsRequest, *ListPositionsResponse) error +type PositionServiceCreatePositionHooker interface { + PrepareCreatePosition(http.Context, *CreatePositionRequest) (context.Context, error) + CompleteCreatePosition(http.Context, *CreatePositionRequest, *CreatePositionResponse) error } type PositionServiceUpdatePositionHooker interface { PrepareUpdatePosition(http.Context, *UpdatePositionRequest) (context.Context, error) CompleteUpdatePosition(http.Context, *UpdatePositionRequest, *UpdatePositionResponse) error } +type PositionServiceDeletePositionHooker interface { + PrepareDeletePosition(http.Context, *DeletePositionRequest) (context.Context, error) + CompleteDeletePosition(http.Context, *DeletePositionRequest, *DeletePositionResponse) error +} func RegisterPositionServiceBridgeServer(s *http.Server, srv PositionServiceHookedBridger) { r := s.Route("/") @@ -221,43 +221,43 @@ func _PositionService_DeletePosition0_Bridge_Handler(srv PositionServiceHookedBr // pointer dereference when methods are called. type UnimplementedPositionServiceHooked struct{} -func (UnimplementedPositionServiceHooked) PrepareCreatePosition(ctx http.Context, in *CreatePositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) PrepareListPositions(ctx http.Context, in *ListPositionsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceHooked) CompleteCreatePosition(ctx http.Context, in *CreatePositionRequest, out *CreatePositionResponse) error { +func (UnimplementedPositionServiceHooked) CompleteListPositions(ctx http.Context, in *ListPositionsRequest, out *ListPositionsResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceHooked) PrepareDeletePosition(ctx http.Context, in *DeletePositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) PrepareGetPosition(ctx http.Context, in *GetPositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceHooked) CompleteDeletePosition(ctx http.Context, in *DeletePositionRequest, out *DeletePositionResponse) error { +func (UnimplementedPositionServiceHooked) CompleteGetPosition(ctx http.Context, in *GetPositionRequest, out *GetPositionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceHooked) PrepareGetPosition(ctx http.Context, in *GetPositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) PrepareCreatePosition(ctx http.Context, in *CreatePositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceHooked) CompleteGetPosition(ctx http.Context, in *GetPositionRequest, out *GetPositionResponse) error { +func (UnimplementedPositionServiceHooked) CompleteCreatePosition(ctx http.Context, in *CreatePositionRequest, out *CreatePositionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceHooked) PrepareListPositions(ctx http.Context, in *ListPositionsRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) PrepareUpdatePosition(ctx http.Context, in *UpdatePositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceHooked) CompleteListPositions(ctx http.Context, in *ListPositionsRequest, out *ListPositionsResponse) error { +func (UnimplementedPositionServiceHooked) CompleteUpdatePosition(ctx http.Context, in *UpdatePositionRequest, out *UpdatePositionResponse) error { return ctx.Result(200, out) } -func (UnimplementedPositionServiceHooked) PrepareUpdatePosition(ctx http.Context, in *UpdatePositionRequest) (context.Context, error) { +func (UnimplementedPositionServiceHooked) PrepareDeletePosition(ctx http.Context, in *DeletePositionRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedPositionServiceHooked) CompleteUpdatePosition(ctx http.Context, in *UpdatePositionRequest, out *UpdatePositionResponse) error { +func (UnimplementedPositionServiceHooked) CompleteDeletePosition(ctx http.Context, in *DeletePositionRequest, out *DeletePositionResponse) error { return ctx.Result(200, out) } @@ -283,26 +283,26 @@ func NewPositionServiceHTTPBridge(client *http.Client) PositionServiceHTTPServer return &PositionServiceHTTPBridgeImpl{client: NewPositionServiceHTTPClient(client)} } -func (c *PositionServiceHTTPBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { - return c.client.CreatePosition(ctx, in) -} - -func (c *PositionServiceHTTPBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { - return c.client.DeletePosition(ctx, in) +func (c *PositionServiceHTTPBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) } func (c *PositionServiceHTTPBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { return c.client.GetPosition(ctx, in) } -func (c *PositionServiceHTTPBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { - return c.client.ListPositions(ctx, in) +func (c *PositionServiceHTTPBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) } func (c *PositionServiceHTTPBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { return c.client.UpdatePosition(ctx, in) } +func (c *PositionServiceHTTPBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + type PositionServiceBridgeImpl struct { client PositionServiceClient } @@ -311,26 +311,26 @@ func NewPositionServiceBridge(client grpc.ClientConnInterface) PositionServiceSe return &PositionServiceBridgeImpl{client: NewPositionServiceClient(client)} } -func (c *PositionServiceBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { - return c.client.CreatePosition(ctx, in) -} - -func (c *PositionServiceBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { - return c.client.DeletePosition(ctx, in) +func (c *PositionServiceBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) } func (c *PositionServiceBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { return c.client.GetPosition(ctx, in) } -func (c *PositionServiceBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { - return c.client.ListPositions(ctx, in) +func (c *PositionServiceBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) } func (c *PositionServiceBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { return c.client.UpdatePosition(ctx, in) } +func (c *PositionServiceBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + func (c *PositionServiceBridgeImpl) mustEmbedUnimplementedPositionServiceServer() {} type PositionServiceGRPC2HTTPBridgeImpl struct { @@ -341,26 +341,26 @@ func NewPositionServiceGRPC2HTTP(client grpc.ClientConnInterface) PositionServic return &PositionServiceGRPC2HTTPBridgeImpl{client: NewPositionServiceClient(client)} } -func (c *PositionServiceGRPC2HTTPBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { - return c.client.CreatePosition(ctx, in) -} - -func (c *PositionServiceGRPC2HTTPBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { - return c.client.DeletePosition(ctx, in) +func (c *PositionServiceGRPC2HTTPBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) } func (c *PositionServiceGRPC2HTTPBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { return c.client.GetPosition(ctx, in) } -func (c *PositionServiceGRPC2HTTPBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { - return c.client.ListPositions(ctx, in) +func (c *PositionServiceGRPC2HTTPBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) } func (c *PositionServiceGRPC2HTTPBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { return c.client.UpdatePosition(ctx, in) } +func (c *PositionServiceGRPC2HTTPBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + type PositionServiceHTTP2GRPCBridgeImpl struct { client PositionServiceHTTPClient } @@ -369,24 +369,24 @@ func NewPositionServiceHTTP2GRPC(client *http.Client) PositionServiceServer { return &PositionServiceHTTP2GRPCBridgeImpl{client: NewPositionServiceHTTPClient(client)} } -func (c *PositionServiceHTTP2GRPCBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { - return c.client.CreatePosition(ctx, in) -} - -func (c *PositionServiceHTTP2GRPCBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { - return c.client.DeletePosition(ctx, in) +func (c *PositionServiceHTTP2GRPCBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { + return c.client.ListPositions(ctx, in) } func (c *PositionServiceHTTP2GRPCBridgeImpl) GetPosition(ctx context.Context, in *GetPositionRequest) (*GetPositionResponse, error) { return c.client.GetPosition(ctx, in) } -func (c *PositionServiceHTTP2GRPCBridgeImpl) ListPositions(ctx context.Context, in *ListPositionsRequest) (*ListPositionsResponse, error) { - return c.client.ListPositions(ctx, in) +func (c *PositionServiceHTTP2GRPCBridgeImpl) CreatePosition(ctx context.Context, in *CreatePositionRequest) (*CreatePositionResponse, error) { + return c.client.CreatePosition(ctx, in) } func (c *PositionServiceHTTP2GRPCBridgeImpl) UpdatePosition(ctx context.Context, in *UpdatePositionRequest) (*UpdatePositionResponse, error) { return c.client.UpdatePosition(ctx, in) } +func (c *PositionServiceHTTP2GRPCBridgeImpl) DeletePosition(ctx context.Context, in *DeletePositionRequest) (*DeletePositionResponse, error) { + return c.client.DeletePosition(ctx, in) +} + func (c *PositionServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedPositionServiceServer() {} diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go index c75a81a6..570a70aa 100644 --- a/api/v1/services/system/resource_bridge.pb.go +++ b/api/v1/services/system/resource_bridge.pb.go @@ -28,57 +28,57 @@ var ( _ = codes.Unimplemented ) -const ResourceServiceCreateResourceBridgeOperation = "/api.v1.services.system.ResourceService/CreateResource" -const ResourceServiceDeleteResourceBridgeOperation = "/api.v1.services.system.ResourceService/DeleteResource" -const ResourceServiceGetResourceBridgeOperation = "/api.v1.services.system.ResourceService/GetResource" const ResourceServiceListResourcesBridgeOperation = "/api.v1.services.system.ResourceService/ListResources" +const ResourceServiceGetResourceBridgeOperation = "/api.v1.services.system.ResourceService/GetResource" +const ResourceServiceCreateResourceBridgeOperation = "/api.v1.services.system.ResourceService/CreateResource" const ResourceServiceUpdateResourceBridgeOperation = "/api.v1.services.system.ResourceService/UpdateResource" +const ResourceServiceDeleteResourceBridgeOperation = "/api.v1.services.system.ResourceService/DeleteResource" type ResourceServiceBridgeServer interface { - // Creates a new backend resource. - CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) - // Deletes a backend resource. - DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) - // Gets a single backend resource. - GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) // Lists all backend resources. ListResources(context.Context, *ListResourcesRequest) (*ListResourcesResponse, error) + // Gets a single backend resource. + GetResource(context.Context, *GetResourceRequest) (*GetResourceResponse, error) + // Creates a new backend resource. + CreateResource(context.Context, *CreateResourceRequest) (*CreateResourceResponse, error) // Updates a backend resource. UpdateResource(context.Context, *UpdateResourceRequest) (*UpdateResourceResponse, error) + // Deletes a backend resource. + DeleteResource(context.Context, *DeleteResourceRequest) (*DeleteResourceResponse, error) } type ResourceServiceHooker interface { - ResourceServiceCreateResourceHooker - ResourceServiceDeleteResourceHooker - ResourceServiceGetResourceHooker ResourceServiceListResourcesHooker + ResourceServiceGetResourceHooker + ResourceServiceCreateResourceHooker ResourceServiceUpdateResourceHooker + ResourceServiceDeleteResourceHooker } type ResourceServiceHookedBridger interface { ResourceServiceHooker ResourceServiceBridgeServer } -type ResourceServiceCreateResourceHooker interface { - PrepareCreateResource(http.Context, *CreateResourceRequest) (context.Context, error) - CompleteCreateResource(http.Context, *CreateResourceRequest, *CreateResourceResponse) error -} -type ResourceServiceDeleteResourceHooker interface { - PrepareDeleteResource(http.Context, *DeleteResourceRequest) (context.Context, error) - CompleteDeleteResource(http.Context, *DeleteResourceRequest, *DeleteResourceResponse) error +type ResourceServiceListResourcesHooker interface { + PrepareListResources(http.Context, *ListResourcesRequest) (context.Context, error) + CompleteListResources(http.Context, *ListResourcesRequest, *ListResourcesResponse) error } type ResourceServiceGetResourceHooker interface { PrepareGetResource(http.Context, *GetResourceRequest) (context.Context, error) CompleteGetResource(http.Context, *GetResourceRequest, *GetResourceResponse) error } -type ResourceServiceListResourcesHooker interface { - PrepareListResources(http.Context, *ListResourcesRequest) (context.Context, error) - CompleteListResources(http.Context, *ListResourcesRequest, *ListResourcesResponse) error +type ResourceServiceCreateResourceHooker interface { + PrepareCreateResource(http.Context, *CreateResourceRequest) (context.Context, error) + CompleteCreateResource(http.Context, *CreateResourceRequest, *CreateResourceResponse) error } type ResourceServiceUpdateResourceHooker interface { PrepareUpdateResource(http.Context, *UpdateResourceRequest) (context.Context, error) CompleteUpdateResource(http.Context, *UpdateResourceRequest, *UpdateResourceResponse) error } +type ResourceServiceDeleteResourceHooker interface { + PrepareDeleteResource(http.Context, *DeleteResourceRequest) (context.Context, error) + CompleteDeleteResource(http.Context, *DeleteResourceRequest, *DeleteResourceResponse) error +} func RegisterResourceServiceBridgeServer(s *http.Server, srv ResourceServiceHookedBridger) { r := s.Route("/") @@ -226,43 +226,43 @@ func _ResourceService_DeleteResource0_Bridge_Handler(srv ResourceServiceHookedBr // pointer dereference when methods are called. type UnimplementedResourceServiceHooked struct{} -func (UnimplementedResourceServiceHooked) PrepareCreateResource(ctx http.Context, in *CreateResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) PrepareListResources(ctx http.Context, in *ListResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceHooked) CompleteCreateResource(ctx http.Context, in *CreateResourceRequest, out *CreateResourceResponse) error { +func (UnimplementedResourceServiceHooked) CompleteListResources(ctx http.Context, in *ListResourcesRequest, out *ListResourcesResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceHooked) PrepareDeleteResource(ctx http.Context, in *DeleteResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) PrepareGetResource(ctx http.Context, in *GetResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceHooked) CompleteDeleteResource(ctx http.Context, in *DeleteResourceRequest, out *DeleteResourceResponse) error { +func (UnimplementedResourceServiceHooked) CompleteGetResource(ctx http.Context, in *GetResourceRequest, out *GetResourceResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceHooked) PrepareGetResource(ctx http.Context, in *GetResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) PrepareCreateResource(ctx http.Context, in *CreateResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceHooked) CompleteGetResource(ctx http.Context, in *GetResourceRequest, out *GetResourceResponse) error { +func (UnimplementedResourceServiceHooked) CompleteCreateResource(ctx http.Context, in *CreateResourceRequest, out *CreateResourceResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceHooked) PrepareListResources(ctx http.Context, in *ListResourcesRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) PrepareUpdateResource(ctx http.Context, in *UpdateResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceHooked) CompleteListResources(ctx http.Context, in *ListResourcesRequest, out *ListResourcesResponse) error { +func (UnimplementedResourceServiceHooked) CompleteUpdateResource(ctx http.Context, in *UpdateResourceRequest, out *UpdateResourceResponse) error { return ctx.Result(200, out) } -func (UnimplementedResourceServiceHooked) PrepareUpdateResource(ctx http.Context, in *UpdateResourceRequest) (context.Context, error) { +func (UnimplementedResourceServiceHooked) PrepareDeleteResource(ctx http.Context, in *DeleteResourceRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedResourceServiceHooked) CompleteUpdateResource(ctx http.Context, in *UpdateResourceRequest, out *UpdateResourceResponse) error { +func (UnimplementedResourceServiceHooked) CompleteDeleteResource(ctx http.Context, in *DeleteResourceRequest, out *DeleteResourceResponse) error { return ctx.Result(200, out) } @@ -288,26 +288,26 @@ func NewResourceServiceHTTPBridge(client *http.Client) ResourceServiceHTTPServer return &ResourceServiceHTTPBridgeImpl{client: NewResourceServiceHTTPClient(client)} } -func (c *ResourceServiceHTTPBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { - return c.client.CreateResource(ctx, in) -} - -func (c *ResourceServiceHTTPBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { - return c.client.DeleteResource(ctx, in) +func (c *ResourceServiceHTTPBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) } func (c *ResourceServiceHTTPBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { return c.client.GetResource(ctx, in) } -func (c *ResourceServiceHTTPBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { - return c.client.ListResources(ctx, in) +func (c *ResourceServiceHTTPBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) } func (c *ResourceServiceHTTPBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { return c.client.UpdateResource(ctx, in) } +func (c *ResourceServiceHTTPBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + type ResourceServiceBridgeImpl struct { client ResourceServiceClient } @@ -316,26 +316,26 @@ func NewResourceServiceBridge(client grpc.ClientConnInterface) ResourceServiceSe return &ResourceServiceBridgeImpl{client: NewResourceServiceClient(client)} } -func (c *ResourceServiceBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { - return c.client.CreateResource(ctx, in) -} - -func (c *ResourceServiceBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { - return c.client.DeleteResource(ctx, in) +func (c *ResourceServiceBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) } func (c *ResourceServiceBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { return c.client.GetResource(ctx, in) } -func (c *ResourceServiceBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { - return c.client.ListResources(ctx, in) +func (c *ResourceServiceBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) } func (c *ResourceServiceBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { return c.client.UpdateResource(ctx, in) } +func (c *ResourceServiceBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + func (c *ResourceServiceBridgeImpl) mustEmbedUnimplementedResourceServiceServer() {} type ResourceServiceGRPC2HTTPBridgeImpl struct { @@ -346,26 +346,26 @@ func NewResourceServiceGRPC2HTTP(client grpc.ClientConnInterface) ResourceServic return &ResourceServiceGRPC2HTTPBridgeImpl{client: NewResourceServiceClient(client)} } -func (c *ResourceServiceGRPC2HTTPBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { - return c.client.CreateResource(ctx, in) -} - -func (c *ResourceServiceGRPC2HTTPBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { - return c.client.DeleteResource(ctx, in) +func (c *ResourceServiceGRPC2HTTPBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) } func (c *ResourceServiceGRPC2HTTPBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { return c.client.GetResource(ctx, in) } -func (c *ResourceServiceGRPC2HTTPBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { - return c.client.ListResources(ctx, in) +func (c *ResourceServiceGRPC2HTTPBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) } func (c *ResourceServiceGRPC2HTTPBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { return c.client.UpdateResource(ctx, in) } +func (c *ResourceServiceGRPC2HTTPBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + type ResourceServiceHTTP2GRPCBridgeImpl struct { client ResourceServiceHTTPClient } @@ -374,24 +374,24 @@ func NewResourceServiceHTTP2GRPC(client *http.Client) ResourceServiceServer { return &ResourceServiceHTTP2GRPCBridgeImpl{client: NewResourceServiceHTTPClient(client)} } -func (c *ResourceServiceHTTP2GRPCBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { - return c.client.CreateResource(ctx, in) -} - -func (c *ResourceServiceHTTP2GRPCBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { - return c.client.DeleteResource(ctx, in) +func (c *ResourceServiceHTTP2GRPCBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { + return c.client.ListResources(ctx, in) } func (c *ResourceServiceHTTP2GRPCBridgeImpl) GetResource(ctx context.Context, in *GetResourceRequest) (*GetResourceResponse, error) { return c.client.GetResource(ctx, in) } -func (c *ResourceServiceHTTP2GRPCBridgeImpl) ListResources(ctx context.Context, in *ListResourcesRequest) (*ListResourcesResponse, error) { - return c.client.ListResources(ctx, in) +func (c *ResourceServiceHTTP2GRPCBridgeImpl) CreateResource(ctx context.Context, in *CreateResourceRequest) (*CreateResourceResponse, error) { + return c.client.CreateResource(ctx, in) } func (c *ResourceServiceHTTP2GRPCBridgeImpl) UpdateResource(ctx context.Context, in *UpdateResourceRequest) (*UpdateResourceResponse, error) { return c.client.UpdateResource(ctx, in) } +func (c *ResourceServiceHTTP2GRPCBridgeImpl) DeleteResource(ctx context.Context, in *DeleteResourceRequest) (*DeleteResourceResponse, error) { + return c.client.DeleteResource(ctx, in) +} + func (c *ResourceServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedResourceServiceServer() {} diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go index c16497d5..f10a5226 100644 --- a/api/v1/services/system/role_bridge.pb.go +++ b/api/v1/services/system/role_bridge.pb.go @@ -28,52 +28,52 @@ var ( _ = codes.Unimplemented ) -const RoleServiceCreateRoleBridgeOperation = "/api.v1.services.system.RoleService/CreateRole" -const RoleServiceDeleteRoleBridgeOperation = "/api.v1.services.system.RoleService/DeleteRole" -const RoleServiceGetRoleBridgeOperation = "/api.v1.services.system.RoleService/GetRole" const RoleServiceListRolesBridgeOperation = "/api.v1.services.system.RoleService/ListRoles" +const RoleServiceGetRoleBridgeOperation = "/api.v1.services.system.RoleService/GetRole" +const RoleServiceCreateRoleBridgeOperation = "/api.v1.services.system.RoleService/CreateRole" const RoleServiceUpdateRoleBridgeOperation = "/api.v1.services.system.RoleService/UpdateRole" +const RoleServiceDeleteRoleBridgeOperation = "/api.v1.services.system.RoleService/DeleteRole" type RoleServiceBridgeServer interface { - CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) - DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) - GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) ListRoles(context.Context, *ListRolesRequest) (*ListRolesResponse, error) + GetRole(context.Context, *GetRoleRequest) (*GetRoleResponse, error) + CreateRole(context.Context, *CreateRoleRequest) (*CreateRoleResponse, error) UpdateRole(context.Context, *UpdateRoleRequest) (*UpdateRoleResponse, error) + DeleteRole(context.Context, *DeleteRoleRequest) (*DeleteRoleResponse, error) } type RoleServiceHooker interface { - RoleServiceCreateRoleHooker - RoleServiceDeleteRoleHooker - RoleServiceGetRoleHooker RoleServiceListRolesHooker + RoleServiceGetRoleHooker + RoleServiceCreateRoleHooker RoleServiceUpdateRoleHooker + RoleServiceDeleteRoleHooker } type RoleServiceHookedBridger interface { RoleServiceHooker RoleServiceBridgeServer } -type RoleServiceCreateRoleHooker interface { - PrepareCreateRole(http.Context, *CreateRoleRequest) (context.Context, error) - CompleteCreateRole(http.Context, *CreateRoleRequest, *CreateRoleResponse) error -} -type RoleServiceDeleteRoleHooker interface { - PrepareDeleteRole(http.Context, *DeleteRoleRequest) (context.Context, error) - CompleteDeleteRole(http.Context, *DeleteRoleRequest, *DeleteRoleResponse) error +type RoleServiceListRolesHooker interface { + PrepareListRoles(http.Context, *ListRolesRequest) (context.Context, error) + CompleteListRoles(http.Context, *ListRolesRequest, *ListRolesResponse) error } type RoleServiceGetRoleHooker interface { PrepareGetRole(http.Context, *GetRoleRequest) (context.Context, error) CompleteGetRole(http.Context, *GetRoleRequest, *GetRoleResponse) error } -type RoleServiceListRolesHooker interface { - PrepareListRoles(http.Context, *ListRolesRequest) (context.Context, error) - CompleteListRoles(http.Context, *ListRolesRequest, *ListRolesResponse) error +type RoleServiceCreateRoleHooker interface { + PrepareCreateRole(http.Context, *CreateRoleRequest) (context.Context, error) + CompleteCreateRole(http.Context, *CreateRoleRequest, *CreateRoleResponse) error } type RoleServiceUpdateRoleHooker interface { PrepareUpdateRole(http.Context, *UpdateRoleRequest) (context.Context, error) CompleteUpdateRole(http.Context, *UpdateRoleRequest, *UpdateRoleResponse) error } +type RoleServiceDeleteRoleHooker interface { + PrepareDeleteRole(http.Context, *DeleteRoleRequest) (context.Context, error) + CompleteDeleteRole(http.Context, *DeleteRoleRequest, *DeleteRoleResponse) error +} func RegisterRoleServiceBridgeServer(s *http.Server, srv RoleServiceHookedBridger) { r := s.Route("/") @@ -221,43 +221,43 @@ func _RoleService_DeleteRole0_Bridge_Handler(srv RoleServiceHookedBridger) func( // pointer dereference when methods are called. type UnimplementedRoleServiceHooked struct{} -func (UnimplementedRoleServiceHooked) PrepareCreateRole(ctx http.Context, in *CreateRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) PrepareListRoles(ctx http.Context, in *ListRolesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceHooked) CompleteCreateRole(ctx http.Context, in *CreateRoleRequest, out *CreateRoleResponse) error { +func (UnimplementedRoleServiceHooked) CompleteListRoles(ctx http.Context, in *ListRolesRequest, out *ListRolesResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceHooked) PrepareDeleteRole(ctx http.Context, in *DeleteRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) PrepareGetRole(ctx http.Context, in *GetRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceHooked) CompleteDeleteRole(ctx http.Context, in *DeleteRoleRequest, out *DeleteRoleResponse) error { +func (UnimplementedRoleServiceHooked) CompleteGetRole(ctx http.Context, in *GetRoleRequest, out *GetRoleResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceHooked) PrepareGetRole(ctx http.Context, in *GetRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) PrepareCreateRole(ctx http.Context, in *CreateRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceHooked) CompleteGetRole(ctx http.Context, in *GetRoleRequest, out *GetRoleResponse) error { +func (UnimplementedRoleServiceHooked) CompleteCreateRole(ctx http.Context, in *CreateRoleRequest, out *CreateRoleResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceHooked) PrepareListRoles(ctx http.Context, in *ListRolesRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) PrepareUpdateRole(ctx http.Context, in *UpdateRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceHooked) CompleteListRoles(ctx http.Context, in *ListRolesRequest, out *ListRolesResponse) error { +func (UnimplementedRoleServiceHooked) CompleteUpdateRole(ctx http.Context, in *UpdateRoleRequest, out *UpdateRoleResponse) error { return ctx.Result(200, out) } -func (UnimplementedRoleServiceHooked) PrepareUpdateRole(ctx http.Context, in *UpdateRoleRequest) (context.Context, error) { +func (UnimplementedRoleServiceHooked) PrepareDeleteRole(ctx http.Context, in *DeleteRoleRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedRoleServiceHooked) CompleteUpdateRole(ctx http.Context, in *UpdateRoleRequest, out *UpdateRoleResponse) error { +func (UnimplementedRoleServiceHooked) CompleteDeleteRole(ctx http.Context, in *DeleteRoleRequest, out *DeleteRoleResponse) error { return ctx.Result(200, out) } @@ -283,26 +283,26 @@ func NewRoleServiceHTTPBridge(client *http.Client) RoleServiceHTTPServer { return &RoleServiceHTTPBridgeImpl{client: NewRoleServiceHTTPClient(client)} } -func (c *RoleServiceHTTPBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { - return c.client.CreateRole(ctx, in) -} - -func (c *RoleServiceHTTPBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { - return c.client.DeleteRole(ctx, in) +func (c *RoleServiceHTTPBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) } func (c *RoleServiceHTTPBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { return c.client.GetRole(ctx, in) } -func (c *RoleServiceHTTPBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { - return c.client.ListRoles(ctx, in) +func (c *RoleServiceHTTPBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) } func (c *RoleServiceHTTPBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { return c.client.UpdateRole(ctx, in) } +func (c *RoleServiceHTTPBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + type RoleServiceBridgeImpl struct { client RoleServiceClient } @@ -311,26 +311,26 @@ func NewRoleServiceBridge(client grpc.ClientConnInterface) RoleServiceServer { return &RoleServiceBridgeImpl{client: NewRoleServiceClient(client)} } -func (c *RoleServiceBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { - return c.client.CreateRole(ctx, in) -} - -func (c *RoleServiceBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { - return c.client.DeleteRole(ctx, in) +func (c *RoleServiceBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) } func (c *RoleServiceBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { return c.client.GetRole(ctx, in) } -func (c *RoleServiceBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { - return c.client.ListRoles(ctx, in) +func (c *RoleServiceBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) } func (c *RoleServiceBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { return c.client.UpdateRole(ctx, in) } +func (c *RoleServiceBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + func (c *RoleServiceBridgeImpl) mustEmbedUnimplementedRoleServiceServer() {} type RoleServiceGRPC2HTTPBridgeImpl struct { @@ -341,26 +341,26 @@ func NewRoleServiceGRPC2HTTP(client grpc.ClientConnInterface) RoleServiceHTTPSer return &RoleServiceGRPC2HTTPBridgeImpl{client: NewRoleServiceClient(client)} } -func (c *RoleServiceGRPC2HTTPBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { - return c.client.CreateRole(ctx, in) -} - -func (c *RoleServiceGRPC2HTTPBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { - return c.client.DeleteRole(ctx, in) +func (c *RoleServiceGRPC2HTTPBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) } func (c *RoleServiceGRPC2HTTPBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { return c.client.GetRole(ctx, in) } -func (c *RoleServiceGRPC2HTTPBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { - return c.client.ListRoles(ctx, in) +func (c *RoleServiceGRPC2HTTPBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) } func (c *RoleServiceGRPC2HTTPBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { return c.client.UpdateRole(ctx, in) } +func (c *RoleServiceGRPC2HTTPBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + type RoleServiceHTTP2GRPCBridgeImpl struct { client RoleServiceHTTPClient } @@ -369,24 +369,24 @@ func NewRoleServiceHTTP2GRPC(client *http.Client) RoleServiceServer { return &RoleServiceHTTP2GRPCBridgeImpl{client: NewRoleServiceHTTPClient(client)} } -func (c *RoleServiceHTTP2GRPCBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { - return c.client.CreateRole(ctx, in) -} - -func (c *RoleServiceHTTP2GRPCBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { - return c.client.DeleteRole(ctx, in) +func (c *RoleServiceHTTP2GRPCBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { + return c.client.ListRoles(ctx, in) } func (c *RoleServiceHTTP2GRPCBridgeImpl) GetRole(ctx context.Context, in *GetRoleRequest) (*GetRoleResponse, error) { return c.client.GetRole(ctx, in) } -func (c *RoleServiceHTTP2GRPCBridgeImpl) ListRoles(ctx context.Context, in *ListRolesRequest) (*ListRolesResponse, error) { - return c.client.ListRoles(ctx, in) +func (c *RoleServiceHTTP2GRPCBridgeImpl) CreateRole(ctx context.Context, in *CreateRoleRequest) (*CreateRoleResponse, error) { + return c.client.CreateRole(ctx, in) } func (c *RoleServiceHTTP2GRPCBridgeImpl) UpdateRole(ctx context.Context, in *UpdateRoleRequest) (*UpdateRoleResponse, error) { return c.client.UpdateRole(ctx, in) } +func (c *RoleServiceHTTP2GRPCBridgeImpl) DeleteRole(ctx context.Context, in *DeleteRoleRequest) (*DeleteRoleResponse, error) { + return c.client.DeleteRole(ctx, in) +} + func (c *RoleServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedRoleServiceServer() {} diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 37aeae0f..8b6ec5fb 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -28,83 +28,83 @@ var ( _ = codes.Unimplemented ) -const UserServiceCreateUserBridgeOperation = "/api.v1.services.system.UserService/CreateUser" -const UserServiceDeleteUserBridgeOperation = "/api.v1.services.system.UserService/DeleteUser" -const UserServiceGetUserBridgeOperation = "/api.v1.services.system.UserService/GetUser" -const UserServiceListUserResourcesBridgeOperation = "/api.v1.services.system.UserService/ListUserResources" const UserServiceListUsersBridgeOperation = "/api.v1.services.system.UserService/ListUsers" -const UserServiceResetUserPasswordBridgeOperation = "/api.v1.services.system.UserService/ResetUserPassword" +const UserServiceListUserResourcesBridgeOperation = "/api.v1.services.system.UserService/ListUserResources" +const UserServiceGetUserBridgeOperation = "/api.v1.services.system.UserService/GetUser" +const UserServiceCreateUserBridgeOperation = "/api.v1.services.system.UserService/CreateUser" const UserServiceUpdateUserBridgeOperation = "/api.v1.services.system.UserService/UpdateUser" -const UserServiceUpdateUserRolesBridgeOperation = "/api.v1.services.system.UserService/UpdateUserRoles" +const UserServiceDeleteUserBridgeOperation = "/api.v1.services.system.UserService/DeleteUser" const UserServiceUpdateUserStatusBridgeOperation = "/api.v1.services.system.UserService/UpdateUserStatus" +const UserServiceUpdateUserRolesBridgeOperation = "/api.v1.services.system.UserService/UpdateUserRoles" +const UserServiceResetUserPasswordBridgeOperation = "/api.v1.services.system.UserService/ResetUserPassword" type UserServiceBridgeServer interface { - CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) - DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) - GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) - ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) - // ResetUserPassword reset the user s password - ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) + ListUserResources(context.Context, *ListUserResourcesRequest) (*ListUserResourcesResponse, error) + GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) + CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) - // UpdateUserRoles update the user roles - UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) + DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) // UpdateUserStatus Update the status of the user information UpdateUserStatus(context.Context, *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) + // UpdateUserRoles update the user roles + UpdateUserRoles(context.Context, *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) + // ResetUserPassword reset the user s password + ResetUserPassword(context.Context, *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) } type UserServiceHooker interface { - UserServiceCreateUserHooker - UserServiceDeleteUserHooker - UserServiceGetUserHooker - UserServiceListUserResourcesHooker UserServiceListUsersHooker - UserServiceResetUserPasswordHooker + UserServiceListUserResourcesHooker + UserServiceGetUserHooker + UserServiceCreateUserHooker UserServiceUpdateUserHooker - UserServiceUpdateUserRolesHooker + UserServiceDeleteUserHooker UserServiceUpdateUserStatusHooker + UserServiceUpdateUserRolesHooker + UserServiceResetUserPasswordHooker } type UserServiceHookedBridger interface { UserServiceHooker UserServiceBridgeServer } -type UserServiceCreateUserHooker interface { - PrepareCreateUser(http.Context, *CreateUserRequest) (context.Context, error) - CompleteCreateUser(http.Context, *CreateUserRequest, *CreateUserResponse) error -} -type UserServiceDeleteUserHooker interface { - PrepareDeleteUser(http.Context, *DeleteUserRequest) (context.Context, error) - CompleteDeleteUser(http.Context, *DeleteUserRequest, *DeleteUserResponse) error -} -type UserServiceGetUserHooker interface { - PrepareGetUser(http.Context, *GetUserRequest) (context.Context, error) - CompleteGetUser(http.Context, *GetUserRequest, *GetUserResponse) error +type UserServiceListUsersHooker interface { + PrepareListUsers(http.Context, *ListUsersRequest) (context.Context, error) + CompleteListUsers(http.Context, *ListUsersRequest, *ListUsersResponse) error } type UserServiceListUserResourcesHooker interface { PrepareListUserResources(http.Context, *ListUserResourcesRequest) (context.Context, error) CompleteListUserResources(http.Context, *ListUserResourcesRequest, *ListUserResourcesResponse) error } -type UserServiceListUsersHooker interface { - PrepareListUsers(http.Context, *ListUsersRequest) (context.Context, error) - CompleteListUsers(http.Context, *ListUsersRequest, *ListUsersResponse) error +type UserServiceGetUserHooker interface { + PrepareGetUser(http.Context, *GetUserRequest) (context.Context, error) + CompleteGetUser(http.Context, *GetUserRequest, *GetUserResponse) error } -type UserServiceResetUserPasswordHooker interface { - PrepareResetUserPassword(http.Context, *ResetUserPasswordRequest) (context.Context, error) - CompleteResetUserPassword(http.Context, *ResetUserPasswordRequest, *ResetUserPasswordResponse) error +type UserServiceCreateUserHooker interface { + PrepareCreateUser(http.Context, *CreateUserRequest) (context.Context, error) + CompleteCreateUser(http.Context, *CreateUserRequest, *CreateUserResponse) error } type UserServiceUpdateUserHooker interface { PrepareUpdateUser(http.Context, *UpdateUserRequest) (context.Context, error) CompleteUpdateUser(http.Context, *UpdateUserRequest, *UpdateUserResponse) error } -type UserServiceUpdateUserRolesHooker interface { - PrepareUpdateUserRoles(http.Context, *UpdateUserRolesRequest) (context.Context, error) - CompleteUpdateUserRoles(http.Context, *UpdateUserRolesRequest, *UpdateUserRolesResponse) error +type UserServiceDeleteUserHooker interface { + PrepareDeleteUser(http.Context, *DeleteUserRequest) (context.Context, error) + CompleteDeleteUser(http.Context, *DeleteUserRequest, *DeleteUserResponse) error } type UserServiceUpdateUserStatusHooker interface { PrepareUpdateUserStatus(http.Context, *UpdateUserStatusRequest) (context.Context, error) CompleteUpdateUserStatus(http.Context, *UpdateUserStatusRequest, *UpdateUserStatusResponse) error } +type UserServiceUpdateUserRolesHooker interface { + PrepareUpdateUserRoles(http.Context, *UpdateUserRolesRequest) (context.Context, error) + CompleteUpdateUserRoles(http.Context, *UpdateUserRolesRequest, *UpdateUserRolesResponse) error +} +type UserServiceResetUserPasswordHooker interface { + PrepareResetUserPassword(http.Context, *ResetUserPasswordRequest) (context.Context, error) + CompleteResetUserPassword(http.Context, *ResetUserPasswordRequest, *ResetUserPasswordResponse) error +} func RegisterUserServiceBridgeServer(s *http.Server, srv UserServiceHookedBridger) { r := s.Route("/") @@ -369,19 +369,19 @@ func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceHookedBridger // pointer dereference when methods are called. type UnimplementedUserServiceHooked struct{} -func (UnimplementedUserServiceHooked) PrepareCreateUser(ctx http.Context, in *CreateUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareListUsers(ctx http.Context, in *ListUsersRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) CompleteCreateUser(ctx http.Context, in *CreateUserRequest, out *CreateUserResponse) error { +func (UnimplementedUserServiceHooked) CompleteListUsers(ctx http.Context, in *ListUsersRequest, out *ListUsersResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) PrepareDeleteUser(ctx http.Context, in *DeleteUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareListUserResources(ctx http.Context, in *ListUserResourcesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) CompleteDeleteUser(ctx http.Context, in *DeleteUserRequest, out *DeleteUserResponse) error { +func (UnimplementedUserServiceHooked) CompleteListUserResources(ctx http.Context, in *ListUserResourcesRequest, out *ListUserResourcesResponse) error { return ctx.Result(200, out) } @@ -393,35 +393,35 @@ func (UnimplementedUserServiceHooked) CompleteGetUser(ctx http.Context, in *GetU return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) PrepareListUserResources(ctx http.Context, in *ListUserResourcesRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareCreateUser(ctx http.Context, in *CreateUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) CompleteListUserResources(ctx http.Context, in *ListUserResourcesRequest, out *ListUserResourcesResponse) error { +func (UnimplementedUserServiceHooked) CompleteCreateUser(ctx http.Context, in *CreateUserRequest, out *CreateUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) PrepareListUsers(ctx http.Context, in *ListUsersRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareUpdateUser(ctx http.Context, in *UpdateUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) CompleteListUsers(ctx http.Context, in *ListUsersRequest, out *ListUsersResponse) error { +func (UnimplementedUserServiceHooked) CompleteUpdateUser(ctx http.Context, in *UpdateUserRequest, out *UpdateUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) PrepareResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareDeleteUser(ctx http.Context, in *DeleteUserRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) CompleteResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest, out *ResetUserPasswordResponse) error { +func (UnimplementedUserServiceHooked) CompleteDeleteUser(ctx http.Context, in *DeleteUserRequest, out *DeleteUserResponse) error { return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) PrepareUpdateUser(ctx http.Context, in *UpdateUserRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) CompleteUpdateUser(ctx http.Context, in *UpdateUserRequest, out *UpdateUserResponse) error { +func (UnimplementedUserServiceHooked) CompleteUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest, out *UpdateUserStatusResponse) error { return ctx.Result(200, out) } @@ -433,11 +433,11 @@ func (UnimplementedUserServiceHooked) CompleteUpdateUserRoles(ctx http.Context, return ctx.Result(200, out) } -func (UnimplementedUserServiceHooked) PrepareUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest) (context.Context, error) { +func (UnimplementedUserServiceHooked) PrepareResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedUserServiceHooked) CompleteUpdateUserStatus(ctx http.Context, in *UpdateUserStatusRequest, out *UpdateUserStatusResponse) error { +func (UnimplementedUserServiceHooked) CompleteResetUserPassword(ctx http.Context, in *ResetUserPasswordRequest, out *ResetUserPasswordResponse) error { return ctx.Result(200, out) } @@ -463,40 +463,40 @@ func NewUserServiceHTTPBridge(client *http.Client) UserServiceHTTPServer { return &UserServiceHTTPBridgeImpl{client: NewUserServiceHTTPClient(client)} } -func (c *UserServiceHTTPBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { - return c.client.CreateUser(ctx, in) +func (c *UserServiceHTTPBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) } -func (c *UserServiceHTTPBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) +func (c *UserServiceHTTPBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) } func (c *UserServiceHTTPBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { return c.client.GetUser(ctx, in) } -func (c *UserServiceHTTPBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { - return c.client.ListUserResources(ctx, in) +func (c *UserServiceHTTPBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) } -func (c *UserServiceHTTPBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) +func (c *UserServiceHTTPBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) } -func (c *UserServiceHTTPBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { - return c.client.ResetUserPassword(ctx, in) +func (c *UserServiceHTTPBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) } -func (c *UserServiceHTTPBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { - return c.client.UpdateUser(ctx, in) +func (c *UserServiceHTTPBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) } func (c *UserServiceHTTPBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { return c.client.UpdateUserRoles(ctx, in) } -func (c *UserServiceHTTPBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { - return c.client.UpdateUserStatus(ctx, in) +func (c *UserServiceHTTPBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) } type UserServiceBridgeImpl struct { @@ -507,40 +507,40 @@ func NewUserServiceBridge(client grpc.ClientConnInterface) UserServiceServer { return &UserServiceBridgeImpl{client: NewUserServiceClient(client)} } -func (c *UserServiceBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { - return c.client.CreateUser(ctx, in) +func (c *UserServiceBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) } -func (c *UserServiceBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) +func (c *UserServiceBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) } func (c *UserServiceBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { return c.client.GetUser(ctx, in) } -func (c *UserServiceBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { - return c.client.ListUserResources(ctx, in) +func (c *UserServiceBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) } -func (c *UserServiceBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) +func (c *UserServiceBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) } -func (c *UserServiceBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { - return c.client.ResetUserPassword(ctx, in) +func (c *UserServiceBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) } -func (c *UserServiceBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { - return c.client.UpdateUser(ctx, in) +func (c *UserServiceBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) } func (c *UserServiceBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { return c.client.UpdateUserRoles(ctx, in) } -func (c *UserServiceBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { - return c.client.UpdateUserStatus(ctx, in) +func (c *UserServiceBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) } func (c *UserServiceBridgeImpl) mustEmbedUnimplementedUserServiceServer() {} @@ -553,40 +553,40 @@ func NewUserServiceGRPC2HTTP(client grpc.ClientConnInterface) UserServiceHTTPSer return &UserServiceGRPC2HTTPBridgeImpl{client: NewUserServiceClient(client)} } -func (c *UserServiceGRPC2HTTPBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { - return c.client.CreateUser(ctx, in) +func (c *UserServiceGRPC2HTTPBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) } -func (c *UserServiceGRPC2HTTPBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) +func (c *UserServiceGRPC2HTTPBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) } func (c *UserServiceGRPC2HTTPBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { return c.client.GetUser(ctx, in) } -func (c *UserServiceGRPC2HTTPBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { - return c.client.ListUserResources(ctx, in) +func (c *UserServiceGRPC2HTTPBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) } -func (c *UserServiceGRPC2HTTPBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) +func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) } -func (c *UserServiceGRPC2HTTPBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { - return c.client.ResetUserPassword(ctx, in) +func (c *UserServiceGRPC2HTTPBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) } -func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { - return c.client.UpdateUser(ctx, in) +func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) } func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { return c.client.UpdateUserRoles(ctx, in) } -func (c *UserServiceGRPC2HTTPBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { - return c.client.UpdateUserStatus(ctx, in) +func (c *UserServiceGRPC2HTTPBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) } type UserServiceHTTP2GRPCBridgeImpl struct { @@ -597,40 +597,40 @@ func NewUserServiceHTTP2GRPC(client *http.Client) UserServiceServer { return &UserServiceHTTP2GRPCBridgeImpl{client: NewUserServiceHTTPClient(client)} } -func (c *UserServiceHTTP2GRPCBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { - return c.client.CreateUser(ctx, in) +func (c *UserServiceHTTP2GRPCBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) } -func (c *UserServiceHTTP2GRPCBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) +func (c *UserServiceHTTP2GRPCBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { + return c.client.ListUserResources(ctx, in) } func (c *UserServiceHTTP2GRPCBridgeImpl) GetUser(ctx context.Context, in *GetUserRequest) (*GetUserResponse, error) { return c.client.GetUser(ctx, in) } -func (c *UserServiceHTTP2GRPCBridgeImpl) ListUserResources(ctx context.Context, in *ListUserResourcesRequest) (*ListUserResourcesResponse, error) { - return c.client.ListUserResources(ctx, in) +func (c *UserServiceHTTP2GRPCBridgeImpl) CreateUser(ctx context.Context, in *CreateUserRequest) (*CreateUserResponse, error) { + return c.client.CreateUser(ctx, in) } -func (c *UserServiceHTTP2GRPCBridgeImpl) ListUsers(ctx context.Context, in *ListUsersRequest) (*ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) +func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { + return c.client.UpdateUser(ctx, in) } -func (c *UserServiceHTTP2GRPCBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { - return c.client.ResetUserPassword(ctx, in) +func (c *UserServiceHTTP2GRPCBridgeImpl) DeleteUser(ctx context.Context, in *DeleteUserRequest) (*DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) } -func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUser(ctx context.Context, in *UpdateUserRequest) (*UpdateUserResponse, error) { - return c.client.UpdateUser(ctx, in) +func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { + return c.client.UpdateUserStatus(ctx, in) } func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUserRoles(ctx context.Context, in *UpdateUserRolesRequest) (*UpdateUserRolesResponse, error) { return c.client.UpdateUserRoles(ctx, in) } -func (c *UserServiceHTTP2GRPCBridgeImpl) UpdateUserStatus(ctx context.Context, in *UpdateUserStatusRequest) (*UpdateUserStatusResponse, error) { - return c.client.UpdateUserStatus(ctx, in) +func (c *UserServiceHTTP2GRPCBridgeImpl) ResetUserPassword(ctx context.Context, in *ResetUserPasswordRequest) (*ResetUserPasswordResponse, error) { + return c.client.ResetUserPassword(ctx, in) } func (c *UserServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedUserServiceServer() {} diff --git a/api/v1/services/types/message.pb.go b/api/v1/services/types/message.pb.go index 17b6aa72..219a57d5 100644 --- a/api/v1/services/types/message.pb.go +++ b/api/v1/services/types/message.pb.go @@ -9,7 +9,6 @@ package types import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - _ "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" unsafe "unsafe" @@ -74,7 +73,7 @@ var File_types_message_proto protoreflect.FileDescriptor const file_types_message_proto_rawDesc = "" + "\n" + - "\x13types/message.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x19\n" + + "\x13types/message.proto\x12\x15api.v1.services.types\"\x19\n" + "\aMessage\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02idB\xda\x01\n" + "\x19com.api.v1.services.typesB\fMessageProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 6385a94d..9ce4f30d 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -20,9 +20,9 @@ paths: /api/v1/auth/login: post: tags: - - Auth + - AuthService description: Login authenticates a user and returns a token pair. - operationId: Auth_Login + operationId: AuthService_Login requestBody: content: application/json: @@ -45,9 +45,9 @@ paths: /api/v1/auth/logout: post: tags: - - Auth + - AuthService description: Logout invalidates the user's session. - operationId: Auth_Logout + operationId: AuthService_Logout requestBody: content: application/json: @@ -57,7 +57,10 @@ paths: responses: "200": description: OK - content: {} + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.LogoutResponse' default: description: Default error response content: @@ -67,9 +70,9 @@ paths: /api/v1/auth/register: post: tags: - - Auth + - AuthService description: Register creates a new user account. - operationId: Auth_Register + operationId: AuthService_Register requestBody: content: application/json: @@ -79,7 +82,10 @@ paths: responses: "200": description: OK - content: {} + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse' default: description: Default error response content: @@ -89,9 +95,9 @@ paths: /api/v1/auth/token: post: tags: - - Auth + - AuthService description: RefreshToken provides a new access token. - operationId: Auth_RefreshToken + operationId: AuthService_RefreshToken requestBody: content: application/json: @@ -114,9 +120,9 @@ paths: /api/v1/captcha: get: tags: - - Auth + - AuthService description: GetCaptcha generates a new captcha. - operationId: Auth_GetCaptcha + operationId: AuthService_GetCaptcha parameters: - name: reload in: query @@ -198,9 +204,9 @@ paths: /api/v1/me/password: put: tags: - - Me + - MeService description: UpdatePassword changes the password for the currently authenticated user. - operationId: Me_UpdatePassword + operationId: MeService_UpdatePassword requestBody: content: application/json: @@ -210,7 +216,10 @@ paths: responses: "200": description: OK - content: {} + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.UpdatePasswordResponse' default: description: Default error response content: @@ -220,16 +229,16 @@ paths: /api/v1/me/profile: get: tags: - - Me + - MeService description: GetProfile retrieves the profile of the currently authenticated user. - operationId: Me_GetProfile + operationId: MeService_GetProfile responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.User' + $ref: '#/components/schemas/api.v1.services.auth.GetProfileResponse' default: description: Default error response content: @@ -238,9 +247,9 @@ paths: $ref: '#/components/schemas/google.rpc.Status' put: tags: - - Me + - MeService description: UpdateProfile updates the profile of the currently authenticated user. - operationId: Me_UpdateProfile + operationId: MeService_UpdateProfile requestBody: content: application/json: @@ -250,7 +259,10 @@ paths: responses: "200": description: OK - content: {} + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.UpdateProfileResponse' default: description: Default error response content: @@ -260,9 +272,9 @@ paths: /api/v1/me/resources: get: tags: - - Me + - MeService description: GetUserResources retrieves the menu/resource list for the current user. - operationId: Me_GetUserResources + operationId: MeService_GetUserResources responses: "200": description: OK @@ -279,9 +291,9 @@ paths: /api/v1/me/roles: get: tags: - - Me + - MeService description: GetUserRoles retrieves the role list for the current user. - operationId: Me_GetUserRoles + operationId: MeService_GetUserRoles responses: "200": description: OK @@ -2143,7 +2155,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.upload.ListUploadResponse' + $ref: '#/components/schemas/api.v1.services.datastore.ListUploadResponse' default: description: Default error response content: @@ -2177,7 +2189,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.upload.CreateUploadResponse' + $ref: '#/components/schemas/api.v1.services.datastore.CreateUploadResponse' default: description: Default error response content: @@ -2212,7 +2224,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.upload.UpdateUploadResponse' + $ref: '#/components/schemas/api.v1.services.datastore.UpdateUploadResponse' default: description: Default error response content: @@ -2237,7 +2249,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.upload.GetUploadResponse' + $ref: '#/components/schemas/api.v1.services.datastore.GetUploadResponse' default: description: Default error response content: @@ -2261,7 +2273,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.upload.DeleteUploadResponse' + $ref: '#/components/schemas/api.v1.services.datastore.DeleteUploadResponse' default: description: Default error response content: @@ -2279,6 +2291,12 @@ components: type: string description: Base64 encoded image data. description: The response message for the GetCaptcha RPC. + api.v1.services.auth.GetProfileResponse: + type: object + properties: + user: + $ref: '#/components/schemas/api.v1.services.types.User' + description: The response message for the GetProfile RPC. api.v1.services.auth.GetUserResourcesResponse: type: object properties: @@ -2348,6 +2366,10 @@ components: refresh_token: type: string description: The request message for the Logout RPC. + api.v1.services.auth.LogoutResponse: + type: object + properties: {} + description: The response message for the Logout RPC. api.v1.services.auth.PolicyRule: type: object properties: @@ -2387,6 +2409,10 @@ components: captcha_code: type: string description: The request message for the Register RPC. + api.v1.services.auth.RegisterResponse: + type: object + properties: {} + description: The response message for the Register RPC. api.v1.services.auth.UpdatePasswordRequest: type: object properties: @@ -2395,6 +2421,10 @@ components: new_password: type: string description: The request message for the UpdatePassword RPC. + api.v1.services.auth.UpdatePasswordResponse: + type: object + properties: {} + description: The response message for the UpdatePassword RPC. api.v1.services.auth.UpdateProfileRequest: type: object properties: @@ -2403,6 +2433,10 @@ components: - $ref: '#/components/schemas/api.v1.services.types.User' description: The fields to update. description: The request message for the UpdateProfile RPC. + api.v1.services.auth.UpdateProfileResponse: + type: object + properties: {} + description: The response message for the UpdateProfile RPC. api.v1.services.auth.WatchUpdateResponse: type: object properties: @@ -2414,10 +2448,20 @@ components: data: $ref: '#/components/schemas/api.v1.services.types.DataObject' description: CreateDatastoreResponse is the response for the DatastoreService.CreateDatastore method. + api.v1.services.datastore.CreateUploadResponse: + type: object + properties: + data: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: CreateUploadResponse is the response for the UploadService.CreateUpload method. api.v1.services.datastore.DeleteDatastoreResponse: type: object properties: {} description: DeleteDatastoreResponse is the response for the DatastoreService.DeleteDatastore method. + api.v1.services.datastore.DeleteUploadResponse: + type: object + properties: {} + description: DeleteUploadResponse is the response for the UploadService.DeleteUpload method. api.v1.services.datastore.GetDatastoreResponse: type: object properties: @@ -2426,6 +2470,14 @@ components: - $ref: '#/components/schemas/api.v1.services.types.DataObject' description: The field id should match the Noun in the method id. description: GetDatastoreResponse is the response for the DatastoreService.GetDatastore method. + api.v1.services.datastore.GetUploadResponse: + type: object + properties: + data: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: The field id should match the Noun in the method id. + description: GetUploadResponse is the response for the UploadService.GetUpload method. api.v1.services.datastore.ListDatastoreResponse: type: object properties: @@ -2454,12 +2506,46 @@ components: - $ref: '#/components/schemas/google.protobuf.Any' description: "Additional information about this response.\r\n content to be added without destroying the current data format" description: ListDatastoreResponse is the response for the DatastoreService.ListDatastore method. + api.v1.services.datastore.ListUploadResponse: + type: object + properties: + total_size: + type: integer + description: The total number of items in the list. + format: int32 + data: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: The paging upload + current: + type: integer + description: The current page number. + format: int32 + page_size: + type: integer + description: The maximum number of items to return. + format: int32 + next_page_token: + type: string + description: "Token to retrieve the next page of results, or empty if there are no\r\n more results in the list." + extra: + allOf: + - $ref: '#/components/schemas/google.protobuf.Any' + description: "Additional information about this response.\r\n content to be added without destroying the current data format" + description: ListUploadResponse is the response for the UploadService.ListUpload method. api.v1.services.datastore.UpdateDatastoreResponse: type: object properties: data: $ref: '#/components/schemas/api.v1.services.types.DataObject' description: UpdateDatastoreResponse is the response for the DatastoreService.UpdateDatastore method. + api.v1.services.datastore.UpdateUploadResponse: + type: object + properties: + data: + $ref: '#/components/schemas/api.v1.services.types.DataObject' + description: UpdateUploadResponse is the response for the UploadService.UpdateUpload method. api.v1.services.message.GetPersonalProfileResponse: type: object properties: @@ -3468,58 +3554,6 @@ components: $ref: '#/components/schemas/api.v1.services.types.Role' description: Roles holds the value of the roles edge. description: View is the model entity for the View schema. - api.v1.services.upload.CreateUploadResponse: - type: object - properties: - data: - $ref: '#/components/schemas/api.v1.services.types.DataObject' - description: CreateUploadResponse is the response for the UploadService.CreateUpload method. - api.v1.services.upload.DeleteUploadResponse: - type: object - properties: {} - description: DeleteUploadResponse is the response for the UploadService.DeleteUpload method. - api.v1.services.upload.GetUploadResponse: - type: object - properties: - data: - allOf: - - $ref: '#/components/schemas/api.v1.services.types.DataObject' - description: The field id should match the Noun in the method id. - description: GetUploadResponse is the response for the UploadService.GetUpload method. - api.v1.services.upload.ListUploadResponse: - type: object - properties: - total_size: - type: integer - description: The total number of items in the list. - format: int32 - data: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.DataObject' - description: The paging upload - current: - type: integer - description: The current page number. - format: int32 - page_size: - type: integer - description: The maximum number of items to return. - format: int32 - next_page_token: - type: string - description: "Token to retrieve the next page of results, or empty if there are no\r\n more results in the list." - extra: - allOf: - - $ref: '#/components/schemas/google.protobuf.Any' - description: "Additional information about this response.\r\n content to be added without destroying the current data format" - description: ListUploadResponse is the response for the UploadService.ListUpload method. - api.v1.services.upload.UpdateUploadResponse: - type: object - properties: - data: - $ref: '#/components/schemas/api.v1.services.types.DataObject' - description: UpdateUploadResponse is the response for the UploadService.UpdateUpload method. google.protobuf.Any: type: object properties: @@ -3553,16 +3587,16 @@ components: name: Authorization in: header tags: - - name: Auth - description: Service Auth provides APIs for the authentication lifecycle. + - name: AuthService + description: Service AuthService provides APIs for the authentication lifecycle. - name: CasbinSourceService description: The Casbin source service definition. - name: DatastoreService description: The data service definition. - name: DepartmentService description: The login service definition. - - name: Me - description: Service Me provides APIs for the currently authenticated user to manage their own profile and data. + - name: MeService + description: Service MeService provides APIs for the currently authenticated user to manage their own profile and data. - name: PermissionService description: The login service definition. - name: PersonalService From 5a0c5e920377d9f76a2aa2054df17fb7166f6fd3 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 00:47:18 +0800 Subject: [PATCH 109/158] refactor(auth): simplify casbin implementation and update password verification --- internal/data/data.go | 2 +- internal/features/auth/biz/auth.go | 2 +- internal/features/auth/biz/captcha.go | 7 +- internal/features/auth/biz/casbin.biz.go | 11 +- internal/features/auth/dal/auth.go | 8 +- internal/features/auth/dal/captcha.go | 74 --- .../features/auth/dal/casbin-adapter.dal.go | 494 ---------------- internal/features/auth/dal/casbin.dal.go | 116 ---- internal/features/auth/dal/casbin.go | 61 ++ internal/features/auth/dal/dal.go | 530 ------------------ internal/features/auth/dal/provider.go | 10 +- test/token_test.go | 2 +- 12 files changed, 86 insertions(+), 1231 deletions(-) delete mode 100644 internal/features/auth/dal/captcha.go delete mode 100644 internal/features/auth/dal/casbin-adapter.dal.go delete mode 100644 internal/features/auth/dal/casbin.dal.go create mode 100644 internal/features/auth/dal/casbin.go delete mode 100644 internal/features/auth/dal/dal.go diff --git a/internal/data/data.go b/internal/data/data.go index 013267de..7c7507b5 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -19,7 +19,7 @@ import ( ) // ProviderSet is data providers. -var ProviderSet = wire.NewSet(NewData, ProvideDatabase, NewStorageProvider) +var ProviderSet = wire.NewSet(NewData, ProvideDatabase, NewStorageProvider, NewAdapter) // Data encapsulates the core data access components. type Data struct { diff --git a/internal/features/auth/biz/auth.go b/internal/features/auth/biz/auth.go index fdcbde57..440adb4e 100644 --- a/internal/features/auth/biz/auth.go +++ b/internal/features/auth/biz/auth.go @@ -34,7 +34,7 @@ func (uc *AuthUseCase) VerifyUser(ctx context.Context, username, password string } // Compare the provided password with the stored hash. - ok, err := uc.hasher.Compare(user.EncryptedPassword, password) + ok, err := uc.hasher.Verify(user.EncryptedPassword, password) if err != nil || !ok { return 0, errors.New("invalid username or password") } diff --git a/internal/features/auth/biz/captcha.go b/internal/features/auth/biz/captcha.go index 715569bd..28b42f00 100644 --- a/internal/features/auth/biz/captcha.go +++ b/internal/features/auth/biz/captcha.go @@ -32,9 +32,10 @@ func (uc *CaptchaUseCase) GenerateCaptcha(ctx context.Context) (id, b64s string, int(uc.config.GetHeight()), int(uc.config.GetWidth()), int(uc.config.GetLength()), - uc.config.GetMaxskew(), - uc.config.GetDotcount(), + float64(uc.config.GetMaxskew()), + uc.config.GetDotCount(), ) c := base64Captcha.NewCaptcha(driver, uc.repo) - return c.Generate() + id, content, err := c.Generate() + return id, content, err } diff --git a/internal/features/auth/biz/casbin.biz.go b/internal/features/auth/biz/casbin.biz.go index 1b7a626c..a76c8ece 100644 --- a/internal/features/auth/biz/casbin.biz.go +++ b/internal/features/auth/biz/casbin.biz.go @@ -10,12 +10,13 @@ import ( "sync/atomic" "time" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" "google.golang.org/grpc" + "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/helpers/repo" + "github.com/origadmin/runtime" pb "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/features/auth/dto" ) @@ -24,7 +25,7 @@ import ( type CasbinSourceServiceBiz struct { dao dto.CasbinSourceRepo limiter repo.PageLimiter - log *log.KHelper + log *log.Helper lastModified *atomic.Int64 } @@ -105,7 +106,7 @@ func newGroupingResponse(rule *pb.GroupingRule) *pb.StreamRulesResponse { } // NewCasbinSourceServiceBiz new a CasbinSource use case. -func NewCasbinSourceServiceBiz(r runtime.Runtime, repo dto.CasbinSourceRepo) *CasbinSourceServiceBiz { - return &CasbinSourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.WithLogger("module", "biz/casbin")), +func NewCasbinSourceServiceBiz(r *runtime.App, repo dto.CasbinSourceRepo) *CasbinSourceServiceBiz { + return &CasbinSourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(log.With(r.Logger(), "module", "biz/casbin")), lastModified: &atomic.Int64{}} } diff --git a/internal/features/auth/dal/auth.go b/internal/features/auth/dal/auth.go index 6d466ed2..9b2ba5b4 100644 --- a/internal/features/auth/dal/auth.go +++ b/internal/features/auth/dal/auth.go @@ -16,9 +16,9 @@ type authRepo struct { } // NewAuthRepo . -func NewAuthRepo(database *ent.Database, logger log.Logger) dto.AuthRepo { +func NewAuthRepo(db *ent.Database, logger log.Logger) dto.AuthRepo { return &authRepo{ - db: database, + db: db, log: log.NewHelper(logger), } } @@ -31,8 +31,8 @@ func (r *authRepo) GetUserByUsername(ctx context.Context, username string) (*dto } return &dto.User{ - ID: u.ID, - Username: u.Username, + ID: u.ID, + Username: u.Username, EncryptedPassword: u.EncryptedPassword, }, nil } diff --git a/internal/features/auth/dal/captcha.go b/internal/features/auth/dal/captcha.go deleted file mode 100644 index 925dde9b..00000000 --- a/internal/features/auth/dal/captcha.go +++ /dev/null @@ -1,74 +0,0 @@ -package dal - -import ( - "context" - "fmt" - "time" - - "github.com/go-kratos/kratos/v2/log" - "github.com/go-redis/redis/v8" - "github.com/mojocn/base64Captcha" - "github.com/origadmin/runtime/data/storage" - - confpb "origadmin/application/admin/internal/conf/pb" -) - -const ( - captchaPrefix = "captcha:" -) - -type captchaRepo struct { - rdb *redis.Client - log *log.Helper -} - -// NewCaptchaRepo creates a new captcha repository that implements the base64Captcha.Store interface. -func NewCaptchaRepo(provider storage.Provider, cfg *confpb.Captcha, logger log.Logger) (base64Captcha.Store, error) { - cacheName := cfg.GetCacheName() - if cacheName == "" { - return nil, fmt.Errorf("captcha cache_name is not configured") - } - - cache, err := provider.Cache(cacheName) - if err != nil { - return nil, fmt.Errorf("failed to get cache '%s': %w", cacheName, err) - } - - rdb := cache.Redis() - if rdb == nil { - return nil, fmt.Errorf("the cache '%s' is not a Redis client", cacheName) - } - - return &captchaRepo{ - rdb: rdb, - log: log.NewHelper(logger), - }, nil -} - -// Set stores the captcha value. -func (r *captchaRepo) Set(id string, value string) error { - return r.rdb.Set(context.Background(), captchaPrefix+id, value, time.Minute*5).Err() -} - -// Get retrieves the captcha value. -func (r *captchaRepo) Get(id string, clear bool) string { - ctx := context.Background() - key := captchaPrefix + id - val, err := r.rdb.Get(ctx, key).Result() - if err != nil { - r.log.Errorf("failed to get captcha from redis: %v", err) - return "" - } - if clear { - if err := r.rdb.Del(ctx, key).Err(); err != nil { - r.log.Errorf("failed to delete captcha from redis: %v", err) - } - } - return val -} - -// Verify verifies the captcha value. -func (r *captchaRepo) Verify(id, answer string, clear bool) bool { - val := r.Get(id, clear) - return val == answer -} diff --git a/internal/features/auth/dal/casbin-adapter.dal.go b/internal/features/auth/dal/casbin-adapter.dal.go deleted file mode 100644 index 5d2474fc..00000000 --- a/internal/features/auth/dal/casbin-adapter.dal.go +++ /dev/null @@ -1,494 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "context" - "database/sql" - "fmt" - "reflect" - "strings" - - "entgo.io/ent/dialect" - entsql "entgo.io/ent/dialect/sql" - "github.com/casbin/casbin/v2/model" - "github.com/casbin/casbin/v2/persist" - "github.com/goexts/generic/configure" - - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/casbinrule" - "origadmin/application/admin/internal/data/entity/ent/predicate" -) - -const ( - DefaultTableName = "casbin_rule" - DefaultDatabase = "casbin" -) - -type casbinRepo struct { - ctx context.Context - data *Data - filtered bool -} - -type CasbinOptions struct { - filtered bool -} - -type Option = func(a *CasbinOptions) error - -func WithFiltered(filtered bool) Option { - return func(a *CasbinOptions) error { - a.filtered = filtered - return nil - } -} - -type Filter struct { - Ptype []string - V0 []string - V1 []string - V2 []string - V3 []string - V4 []string - V5 []string -} - -func open(driverName, dataSourceName string) (*ent.Client, error) { - db, err := sql.Open(driverName, dataSourceName) - if err != nil { - return nil, err - } - var drv dialect.Driver - if driverName == "pgx" { - drv = entsql.OpenDB(dialect.Postgres, db) - } else { - drv = entsql.OpenDB(driverName, db) - } - return ent.NewClient(ent.Driver(drv)), nil -} - -// NewAdapter returns an adapter by driver name and data source string. -func NewAdapter(data *Data, options ...Option) (persist.Adapter, error) { - a := &casbinRepo{ - data: data, - filtered: false, - } - opts, err := configure.ApplyE(&CasbinOptions{}, options) - if err != nil { - return nil, err - } - a.filtered = opts.filtered - return a, nil -} - -// NewAdapterWithClient create an adapter with client passed in. -// This method does not ensure the existence of database, user should create database manually. -func NewAdapterWithClient(client *ent.Client, options ...Option) (persist.Adapter, error) { - a := &casbinRepo{ - data: NewDataWithClient(client), - } - var setting CasbinOptions - for _, option := range options { - if err := option(&setting); err != nil { - return nil, err - } - } - a.filtered = setting.filtered - return a, nil -} - -// LoadPolicy loads all policy rules from the storage. -func (repo *casbinRepo) LoadPolicy(model model.Model) error { - policies, err := repo.data.CasbinRule(repo.ctx).Query().Order(ent.Asc("id")).All(repo.ctx) - if err != nil { - return err - } - for _, policy := range policies { - loadPolicyLine(policy, model) - } - return nil -} - -// LoadFilteredPolicy loads only policy rules that match the filter. -// Filter parameter here is a Filter structure -func (repo *casbinRepo) LoadFilteredPolicy(model model.Model, filter interface{}) error { - filterValue, ok := filter.(Filter) - if !ok { - return fmt.Errorf("invalid filter type: %v", reflect.TypeOf(filter)) - } - - query := repo.data.CasbinRule(repo.ctx).Query() - if len(filterValue.Ptype) != 0 { - query.Where(casbinrule.PtypeIn(filterValue.Ptype...)) - } - if len(filterValue.V0) != 0 { - query.Where(casbinrule.V0In(filterValue.V0...)) - } - if len(filterValue.V1) != 0 { - query.Where(casbinrule.V1In(filterValue.V1...)) - } - if len(filterValue.V2) != 0 { - query.Where(casbinrule.V2In(filterValue.V2...)) - } - if len(filterValue.V3) != 0 { - query.Where(casbinrule.V3In(filterValue.V3...)) - } - if len(filterValue.V4) != 0 { - query.Where(casbinrule.V4In(filterValue.V4...)) - } - if len(filterValue.V5) != 0 { - query.Where(casbinrule.V5In(filterValue.V5...)) - } - - lines, err := query.All(repo.ctx) - if err != nil { - return err - } - - for _, line := range lines { - loadPolicyLine(line, model) - } - repo.filtered = true - return nil -} - -// IsFiltered returns true if the loaded policy has been filtered. -func (repo *casbinRepo) IsFiltered() bool { - return repo.filtered -} - -// SavePolicy saves all policy rules to the storage. -func (repo *casbinRepo) SavePolicy(model model.Model) error { - return repo.data.Tx(repo.ctx, func(ctx context.Context) error { - if _, err := repo.data.CasbinRule(ctx).Delete().Exec(repo.ctx); err != nil { - return err - } - lines := make([]*ent.CasbinRuleCreate, 0) - - for ptype, ast := range model["p"] { - for _, policy := range ast.Policy { - line := repo.savePolicyLine(ctx, ptype, policy) - lines = append(lines, line) - } - } - - for ptype, ast := range model["g"] { - for _, policy := range ast.Policy { - line := repo.savePolicyLine(ctx, ptype, policy) - lines = append(lines, line) - } - } - - _, err := repo.data.CasbinRule(ctx).CreateBulk(lines...).Save(repo.ctx) - return err - }) - -} - -// AddPolicy adds a policy rule to the storage. -// This is part of the Auto-Save feature. -func (repo *casbinRepo) AddPolicy(sec string, ptype string, rule []string) error { - return repo.data.Tx(repo.ctx, func(ctx context.Context) error { - _, err := repo.savePolicyLine(ctx, ptype, rule).Save(repo.ctx) - return err - }) -} - -// RemovePolicy removes a policy rule from the storage. -// This is part of the Auto-Save feature. -func (repo *casbinRepo) RemovePolicy(sec string, ptype string, rule []string) error { - return repo.data.Tx(repo.ctx, func(ctx context.Context) error { - instance := repo.toInstance(ptype, rule) - _, err := repo.data.CasbinRule(ctx).Delete().Where( - casbinrule.PtypeEQ(instance.Ptype), - casbinrule.V0EQ(instance.V0), - casbinrule.V1EQ(instance.V1), - casbinrule.V2EQ(instance.V2), - casbinrule.V3EQ(instance.V3), - casbinrule.V4EQ(instance.V4), - casbinrule.V5EQ(instance.V5), - ).Exec(repo.ctx) - return err - }) -} - -// RemoveFilteredPolicy removes policy rules that match the filter from the storage. -// This is part of the Auto-Save feature. -func (repo *casbinRepo) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error { - return repo.data.Tx(repo.ctx, func(ctx context.Context) error { - cond := make([]predicate.CasbinRule, 0) - cond = append(cond, casbinrule.PtypeEQ(ptype)) - if fieldIndex <= 0 && 0 < fieldIndex+len(fieldValues) && len(fieldValues[0-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V0EQ(fieldValues[0-fieldIndex])) - } - if fieldIndex <= 1 && 1 < fieldIndex+len(fieldValues) && len(fieldValues[1-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V1EQ(fieldValues[1-fieldIndex])) - } - if fieldIndex <= 2 && 2 < fieldIndex+len(fieldValues) && len(fieldValues[2-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V2EQ(fieldValues[2-fieldIndex])) - } - if fieldIndex <= 3 && 3 < fieldIndex+len(fieldValues) && len(fieldValues[3-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V3EQ(fieldValues[3-fieldIndex])) - } - if fieldIndex <= 4 && 4 < fieldIndex+len(fieldValues) && len(fieldValues[4-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V4EQ(fieldValues[4-fieldIndex])) - } - if fieldIndex <= 5 && 5 < fieldIndex+len(fieldValues) && len(fieldValues[5-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V5EQ(fieldValues[5-fieldIndex])) - } - _, err := repo.data.CasbinRule(ctx).Delete().Where(cond...).Exec(repo.ctx) - return err - }) -} - -// AddPolicies adds policy rules to the storage. -// This is part of the Auto-Save feature. -func (repo *casbinRepo) AddPolicies(sec string, ptype string, rules [][]string) error { - return repo.data.Tx(repo.ctx, func(ctx context.Context) error { - return repo.createPolicies(ctx, ptype, rules) - }) -} - -// RemovePolicies removes policy rules from the storage. -// This is part of the Auto-Save feature. -func (repo *casbinRepo) RemovePolicies(sec string, ptype string, rules [][]string) error { - return repo.data.Tx(repo.ctx, func(ctx context.Context) error { - for _, rule := range rules { - instance := repo.toInstance(ptype, rule) - if _, err := repo.data.CasbinRule(ctx).Delete().Where( - casbinrule.PtypeEQ(instance.Ptype), - casbinrule.V0EQ(instance.V0), - casbinrule.V1EQ(instance.V1), - casbinrule.V2EQ(instance.V2), - casbinrule.V3EQ(instance.V3), - casbinrule.V4EQ(instance.V4), - casbinrule.V5EQ(instance.V5), - ).Exec(repo.ctx); err != nil { - return err - } - } - return nil - }) -} - -func loadPolicyLine(line *ent.CasbinRule, model model.Model) { - var p = []string{ - line.Ptype, - line.V0, line.V1, line.V2, line.V3, line.V4, line.V5, - } - - var lineText string - if line.V5 != "" { - lineText = strings.Join(p, ", ") - } else if line.V4 != "" { - lineText = strings.Join(p[:6], ", ") - } else if line.V3 != "" { - lineText = strings.Join(p[:5], ", ") - } else if line.V2 != "" { - lineText = strings.Join(p[:4], ", ") - } else if line.V1 != "" { - lineText = strings.Join(p[:3], ", ") - } else if line.V0 != "" { - lineText = strings.Join(p[:2], ", ") - } - - persist.LoadPolicyLine(lineText, model) -} - -func (repo *casbinRepo) toInstance(ptype string, rule []string) *ent.CasbinRule { - instance := &ent.CasbinRule{} - - instance.Ptype = ptype - - if len(rule) > 0 { - instance.V0 = rule[0] - } - if len(rule) > 1 { - instance.V1 = rule[1] - } - if len(rule) > 2 { - instance.V2 = rule[2] - } - if len(rule) > 3 { - instance.V3 = rule[3] - } - if len(rule) > 4 { - instance.V4 = rule[4] - } - if len(rule) > 5 { - instance.V5 = rule[5] - } - return instance -} - -func (repo *casbinRepo) savePolicyLine(ctx context.Context, ptype string, rule []string) *ent.CasbinRuleCreate { - line := repo.data.CasbinRule(ctx).Create() - - line.SetPtype(ptype) - if len(rule) > 0 { - line.SetV0(rule[0]) - } - if len(rule) > 1 { - line.SetV1(rule[1]) - } - if len(rule) > 2 { - line.SetV2(rule[2]) - } - if len(rule) > 3 { - line.SetV3(rule[3]) - } - if len(rule) > 4 { - line.SetV4(rule[4]) - } - if len(rule) > 5 { - line.SetV5(rule[5]) - } - - return line -} - -// UpdatePolicy updates a policy rule from storage. -// This is part of the Auto-Save feature. -func (repo *casbinRepo) UpdatePolicy(sec string, ptype string, oldRule, newPolicy []string) error { - return repo.data.Tx(repo.ctx, func(ctx context.Context) error { - rule := repo.toInstance(ptype, oldRule) - line := repo.data.CasbinRule(ctx).Update().Where( - casbinrule.PtypeEQ(rule.Ptype), - casbinrule.V0EQ(rule.V0), - casbinrule.V1EQ(rule.V1), - casbinrule.V2EQ(rule.V2), - casbinrule.V3EQ(rule.V3), - casbinrule.V4EQ(rule.V4), - casbinrule.V5EQ(rule.V5), - ) - rule = repo.toInstance(ptype, newPolicy) - line.SetV0(rule.V0) - line.SetV1(rule.V1) - line.SetV2(rule.V2) - line.SetV3(rule.V3) - line.SetV4(rule.V4) - line.SetV5(rule.V5) - _, err := line.Save(repo.ctx) - return err - }) -} - -// UpdatePolicies updates some policy rules to storage, like db, redis. -func (repo *casbinRepo) UpdatePolicies(sec string, ptype string, oldRules, newRules [][]string) error { - return repo.data.Tx(repo.ctx, func(ctx context.Context) error { - for _, policy := range oldRules { - rule := repo.toInstance(ptype, policy) - if _, err := repo.data.CasbinRule(ctx).Delete().Where( - casbinrule.PtypeEQ(rule.Ptype), - casbinrule.V0EQ(rule.V0), - casbinrule.V1EQ(rule.V1), - casbinrule.V2EQ(rule.V2), - casbinrule.V3EQ(rule.V3), - casbinrule.V4EQ(rule.V4), - casbinrule.V5EQ(rule.V5), - ).Exec(repo.ctx); err != nil { - return err - } - } - lines := make([]*ent.CasbinRuleCreate, 0) - for _, policy := range newRules { - lines = append(lines, repo.savePolicyLine(ctx, ptype, policy)) - } - if _, err := repo.data.CasbinRule(ctx).CreateBulk(lines...).Save(repo.ctx); err != nil { - return err - } - return nil - }) -} - -// UpdateFilteredPolicies deletes old rules and adds new rules. -func (repo *casbinRepo) UpdateFilteredPolicies(sec string, ptype string, newPolicies [][]string, fieldIndex int, - fieldValues ...string) ([][]string, error) { - oldPolicies := make([][]string, 0) - err := repo.data.Tx(repo.ctx, func(ctx context.Context) error { - cond := make([]predicate.CasbinRule, 0) - cond = append(cond, casbinrule.PtypeEQ(ptype)) - if fieldIndex <= 0 && 0 < fieldIndex+len(fieldValues) && len(fieldValues[0-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V0EQ(fieldValues[0-fieldIndex])) - } - if fieldIndex <= 1 && 1 < fieldIndex+len(fieldValues) && len(fieldValues[1-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V1EQ(fieldValues[1-fieldIndex])) - } - if fieldIndex <= 2 && 2 < fieldIndex+len(fieldValues) && len(fieldValues[2-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V2EQ(fieldValues[2-fieldIndex])) - } - if fieldIndex <= 3 && 3 < fieldIndex+len(fieldValues) && len(fieldValues[3-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V3EQ(fieldValues[3-fieldIndex])) - } - if fieldIndex <= 4 && 4 < fieldIndex+len(fieldValues) && len(fieldValues[4-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V4EQ(fieldValues[4-fieldIndex])) - } - if fieldIndex <= 5 && 5 < fieldIndex+len(fieldValues) && len(fieldValues[5-fieldIndex]) > 0 { - cond = append(cond, casbinrule.V5EQ(fieldValues[5-fieldIndex])) - } - rules, err := repo.data.CasbinRule(ctx).Query().Where(cond...).All(repo.ctx) - if err != nil { - return err - } - ruleIDs := make([]int, 0, len(rules)) - for _, r := range rules { - ruleIDs = append(ruleIDs, r.ID) - } - - _, err = repo.data.CasbinRule(ctx).Delete(). - Where(casbinrule.IDIn(ruleIDs...)). - Exec(repo.ctx) - if err != nil { - return err - } - - if err := repo.createPolicies(ctx, ptype, newPolicies); err != nil { - return err - } - for _, rule := range rules { - oldPolicies = append(oldPolicies, CasbinRuleToStringArray(rule)) - } - return nil - }) - if err != nil { - return nil, err - } - return oldPolicies, nil -} - -func (repo *casbinRepo) createPolicies(ctx context.Context, ptype string, policies [][]string) error { - lines := make([]*ent.CasbinRuleCreate, 0) - for _, policy := range policies { - lines = append(lines, repo.savePolicyLine(ctx, ptype, policy)) - } - if _, err := repo.data.CasbinRule(ctx).CreateBulk(lines...).Save(repo.ctx); err != nil { - return err - } - return nil -} - -func CasbinRuleToStringArray(rule *ent.CasbinRule) []string { - arr := make([]string, 0) - if rule.V0 != "" { - arr = append(arr, rule.V0) - } - if rule.V1 != "" { - arr = append(arr, rule.V1) - } - if rule.V2 != "" { - arr = append(arr, rule.V2) - } - if rule.V3 != "" { - arr = append(arr, rule.V3) - } - if rule.V4 != "" { - arr = append(arr, rule.V4) - } - if rule.V5 != "" { - arr = append(arr, rule.V5) - } - return arr -} diff --git a/internal/features/auth/dal/casbin.dal.go b/internal/features/auth/dal/casbin.dal.go deleted file mode 100644 index 4aae8655..00000000 --- a/internal/features/auth/dal/casbin.dal.go +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dal implements the functions, types, and interfaces for the module. -package dal - -import ( - "context" - "strconv" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/features/auth/dto" // Corrected import path -) - -type CasbinSourceConfig struct { - PrefixNumberID func(prefix string, id int64) string -} - -type casbinSourceRepo struct { - ctx context.Context - data *data.Data - config *CasbinSourceConfig -} - -func (c casbinSourceRepo) mustEmbedUnimplementedCasbinSourceServiceServer() { - // This method is useless, - // it is just automatically generated when using the inheritance implementation interface -} - -func permissionResourceQuery(query *ent.PermissionQuery) { - query.WithResources() -} -func (c casbinSourceRepo) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { - rolePermissions, err := c.data.RolePermission(ctx).Query().WithPermission(permissionResourceQuery).WithRole().All(ctx) - if err != nil { - return nil, err - } - var rules []*pb.PolicyRule - for _, rolePermission := range rolePermissions { - permission, err := rolePermission.Edges.PermissionOrErr() - if err != nil { - continue - } - resources, err := permission.Edges.ResourcesOrErr() - if err != nil { - continue - } - for _, resource := range resources { - if resource.Type != "A" && resource.Type != "B" { - continue - } - rules = append(rules, &pb.PolicyRule{ - PType: "p", - Params: []string{ - c.config.PrefixNumberID("role", rolePermission.RoleID), - resource.Path, - resource.Method, - "*", - }, - }) - } - } - return &pb.ListPoliciesResponse{Rules: rules}, nil -} - -func (c casbinSourceRepo) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { - userRoles, err := c.data.UserRole(ctx).Query().All(ctx) - if err != nil { - return nil, err - } - var rules []*pb.GroupingRule - for _, userRole := range userRoles { - rules = append(rules, &pb.GroupingRule{ - PType: "g", - Params: []string{ - c.config.PrefixNumberID("user", userRole.UserID), - c.config.PrefixNumberID("role", userRole.RoleID), - //todo: add domain support - "*", - }, - }) - } - return &pb.ListGroupingsResponse{ - Rules: rules, - }, nil -} - -// NewCasbinSourceRepo returns a new CasbinSourceRepo -func NewCasbinSourceRepo(data *data.Data) (dto.CasbinSourceRepo, error) { - c := &casbinSourceRepo{ - data: data, - config: &CasbinSourceConfig{ - PrefixNumberID: func(prefix string, id int64) string { - return prefix + "_" + strconv.FormatInt(id, 10) - }, - }, - } - return c, nil -} - -// NewCasbinSourceWithClient create a new CasbinSourceRepo with given client. -// This method does not ensure the existence of database, user should create database manually. -func NewCasbinSourceWithClient(client *ent.Client) (dto.CasbinSourceRepo, error) { - c := &casbinSourceRepo{ - data: data.NewDataWithClient(client), - config: &CasbinSourceConfig{ - PrefixNumberID: func(prefix string, id int64) string { - return prefix + "_" + strconv.FormatInt(id, 10) - }, - }, - } - return c, nil -} diff --git a/internal/features/auth/dal/casbin.go b/internal/features/auth/dal/casbin.go new file mode 100644 index 00000000..063b8bda --- /dev/null +++ b/internal/features/auth/dal/casbin.go @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dal + +import ( + "context" + + pb "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/features/auth/dto" +) + +// casbinRepo is a repository for casbin rules that implements +// the application's internal CasbinSourceRepo interface. +type casbinRepo struct { + db *ent.Database +} + +// NewCasbinRepo creates a new casbin repository. +func NewCasbinRepo(db *ent.Database) (dto.CasbinSourceRepo, error) { + return &casbinRepo{db: db}, nil +} + +// ListPolicies retrieves policy rules ("p" type) from the storage. +func (r *casbinRepo) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { + rules, err := r.db.CasbinRule(ctx).Query().Where(casbinrule.PtypeEQ("p")).All(ctx) + if err != nil { + return nil, err + } + resp := &pb.ListPoliciesResponse{ + Rules: make([]*pb.PolicyRule, len(rules)), + } + for i, rule := range rules { + resp.Rules[i] = &pb.PolicyRule{ + PType: rule.Ptype, + Params: []string{rule.V0, rule.V1, rule.V2, rule.V3, rule.V4, rule.V5}, + } + } + return resp, nil +} + +// ListGroupings retrieves grouping rules ("g" type) from the storage. +func (r *casbinRepo) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { + rules, err := r.db.CasbinRule(ctx).Query().Where(casbinrule.PtypeEQ("g")).All(ctx) + if err != nil { + return nil, err + } + resp := &pb.ListGroupingsResponse{ + Rules: make([]*pb.GroupingRule, len(rules)), + } + for i, rule := range rules { + resp.Rules[i] = &pb.GroupingRule{ + PType: rule.Ptype, + Params: []string{rule.V0, rule.V1, rule.V2, rule.V3, rule.V4, rule.V5}, + } + } + return resp, nil +} diff --git a/internal/features/auth/dal/dal.go b/internal/features/auth/dal/dal.go deleted file mode 100644 index 8de368ba..00000000 --- a/internal/features/auth/dal/dal.go +++ /dev/null @@ -1,530 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "context" - "path/filepath" - "strings" - - "entgo.io/ent/dialect" - "github.com/google/uuid" - "github.com/origadmin/entslog/v3" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/rand" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/features/auth/dto" // Corrected import path -) - -const ( - TreePathDelimiter = "." -) - -type Data struct { - *data.Data -} - -const FKSuffix = "_fk=1" - -var random = rand.NewGenerator(rand.KindDigit | rand.KindLowerCase | rand.KindUpperCase) - -func FixSource(source string) string { - // Check if the source already contains the FK parameter - if strings.Contains(source, FKSuffix) { - return source - } - - // Check if the source already contains parameters - if strings.Contains(source, "?") { - // If parameters exist, append with & - if !strings.HasSuffix(source, "&") { - source += "&" - } - source += FKSuffix - } else { - // If no parameters exist, append with ? - source += "?" + FKSuffix - } - return source -} - -func debugDatabase(driver dialect.Driver, debug bool) dialect.Driver { - if debug { - return entslog.New(driver) - } - return driver -} - -func (obj *Data) InitDataFromPath(ctx context.Context, path string, filters ...string) error { - type data struct { - name string - fn func(ctx context.Context, filename string) error - } - initializers := []data{ - { - name: "resource", - fn: obj.InitResourceFromFile, - }, - { - name: "role", - fn: obj.InitRoleFromFile, - }, - { - name: "user", - fn: obj.InitUserFromFile, - }, - { - name: "department", - fn: obj.InitDepartmentFromFile, - }, - { - name: "position", - fn: obj.InitPositionFromFile, - }, - { - name: "permission", - fn: obj.InitPermissionFromFile, - }, - } - actions := make([]data, 0) - for _, di := range initializers { - for _, filter := range filters { - if di.name == filter { - actions = append(actions, di) - } - } - - } - for _, action := range actions { - action.name = filepath.Join(path, action.name+".json") - err := action.fn(ctx, action.name) - if err != nil { - return err - } - } - - return nil -} - -//func (obj *Data) InitResourceFromFile(ctx context.Context, filename string) error { -// abs, err := filepath.Abs(filename) -// if err != nil { -// return err -// } -// var resources []*dto.ResourceNode -// err = codec.DecodeFromFile(abs, &resources) -// if err != nil { -// if errors.Is(err, os.ErrNotExist) { -// log.Warnw("Resource data file not found, skip init resource data from file", "file", abs) -// return nil -// } -// return err -// } -// for i, pb := range resources { -// log.Infow("msg", "Processing resource", "index", i, "resourceId", pb.Id, "resourceKeyword", pb.Keyword, "resourceName", pb.Name) -// if pb.Children != nil { -// for i2, child := range pb.Children { -// log.Infow("msg", "Processing child", "index", i2, "childId", child.Id, "childKeyword", child.Keyword, "childName", child.Name) -// } -// } -// } -// return obj.Tx(ctx, func(ctx context.Context) error { -// return obj.createResourceBatchWithParent(ctx, resources, nil) -// }) -//} -// -//func (obj *Data) createResourceBatchWithParent(ctx context.Context, items []*dto.ResourceNode, parent *dto.ResourcePB) error { -// total := len(items) -// log.Infow("msg", "Starting createResourceBatchWithParent", "totalItems", total) -// -// for i, item := range items { -// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) -// var pid int64 -// if parent != nil { -// pid = parent.Id -// log.Infow("msg", "Parent ID set", "parentId", pid) -// } -// founded := false -// switch { -// case item.Id != 0: -// log.Infow("Checking item by ID", "itemId", item.Id) -// exists, err := obj.Resource(ctx).Query().Where(resource.ID(item.Id)).Exist(ctx) -// if err != nil { -// log.Errorw("msg", "Error checking item by ID", "itemId", item.Id, "error", err) -// return err -// } -// if exists { -// log.Infow("msg", "Item already exists by ID", "itemId", item.Id) -// continue -// } -// case item.Keyword != "": -// log.Infow("msg", "Checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid) -// var wheres = []predicate.Resource{ -// resource.Keyword(item.Keyword), -// } -// if pid != 0 { -// wheres = append(wheres, resource.ParentID(pid)) -// } -// exists, err := obj.Resource(ctx).Query().Where(wheres...).Exist(ctx) -// if err != nil { -// log.Errorw("msg", "Error checking item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) -// return err -// } -// if exists { -// resourceItem, err := obj.Resource(ctx).Query().Where(wheres...).First(ctx) -// if err != nil { -// log.Errorw("msg", "Error fetching item by Keyword", "itemKeyword", item.Keyword, "parentId", pid, "error", err) -// return err -// } -// founded = true -// item.Id = resourceItem.ID -// log.Infow("msg", "Item found by Keyword", "itemKeyword", item.Keyword, "itemId", item.Id) -// } -// case item.Name != "": -// log.Infow("msg", "Checking item by Name", "itemName", item.Name, "parentId", pid) -// var conditions = []predicate.Resource{ -// resource.Name(item.Name), -// } -// if pid != 0 { -// conditions = append(conditions, resource.ParentID(pid)) -// } -// exists, err := obj.Resource(ctx).Query().Where(conditions...).Exist(ctx) -// if err != nil { -// log.Errorw("msg", "Error checking item by Name", "itemName", item.Name, "parentId", pid, "error", err) -// return err -// } -// if exists { -// resourceItem, err := obj.Resource(ctx).Query().Where(conditions...).First(ctx) -// if err != nil { -// log.Errorw("msg", "Error fetching item by Name", "itemName", item.Name, "parentId", pid, "error", err) -// return err -// } -// founded = true -// item.Id = resourceItem.ID -// log.Infow("msg", "Item found by Name", "itemName", item.Name, "itemId", item.Id) -// } -// default: -// log.Infow("msg", "No ID, Keyword, or Name provided for item") -// } -// -// if !founded { -// if item.Id == 0 { -// item.Id = id.Gen() -// log.Infow("msg", "Generated new ID for item", "itemId", item.Id) -// } -// if item.Status == 0 { -// item.Status = int32(dto.UserStatusActive) -// log.Infow("msg", "Setting default status for item", "itemId", item.Id, "status", item.Status) -// } -// if item.Sequence == 0 { -// item.Sequence = int32(total - i) -// log.Infow("msg", "Setting default sequence for item", "itemId", item.Id, "sequence", item.Sequence) -// } -// -// item.ParentId = pid -// if parent != nil { -// item.TreePath = parent.TreePath + strconv.Itoa(int(pid)) + TreePathDelimiter -// log.Infow("msg", "Setting parent path for item", "itemId", item.Id, "treePath", item.TreePath) -// } -// itemObj := dto.ConvertResourcePB2Object(&item.ResourcePB) -// itemObj.UpdateTime = time.Now() -// itemObj.CreateTime = time.Now() -// if _, err := obj.Resource(ctx).Create().SetResource(itemObj).Save(ctx); err != nil { -// log.Errorw("msg", "Error creating resource item", "itemId", item.Id, "sequence", item.Sequence, "error", err) -// return err -// } -// log.Infow("msg", "Resource item created successfully", "itemId", item.Id) -// } -// -// if len(item.Children) != 0 { -// log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) -// if err := obj.createResourceBatchWithParent(ctx, item.Children, &item.ResourcePB); err != nil { -// log.Errorw("Error processing children", "itemId", item.Id, "error", err) -// return err -// } -// log.Infow("msg", "Children processed successfully", "itemId", item.Id) -// } -// } -// log.Infow("msg", "Finished createResourceBatchWithParent") -// return nil -//} -// -//func (obj *Data) InitUserFromFile(ctx context.Context, filename string) error { -// abs, err := filepath.Abs(filename) -// if err != nil { -// return err -// } -// var users []*dto.UserNode -// err = codec.DecodeFromFile(abs, &users) -// if err != nil { -// if errors.Is(err, os.ErrNotExist) { -// log.Warnw("User data file not found, skip init user data from file", "file", abs) -// return nil -// } -// return err -// } -// return obj.Tx(ctx, func(ctx context.Context) error { -// return obj.createUserBatch(ctx, users) -// }) -//} -// -//func (obj *Data) createUserBatch(ctx context.Context, users []*dto.UserNode) error { -// total := len(users) -// log.Infow("msg", "Starting createUserBatch", "totalItems", total) -// for i, item := range users { -// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemUsername", item.Username, "itemNickname", item.Nickname) -// user, ps, err := dto.MakeCreateUser(&item.UserPB, item.Username, item.Password, dto.UserMutationOption{}) -// if err != nil { -// return err -// } -// fmt.Println("generate user: ", user.Username, "with password: ", ps) -// if _, err := obj.User(ctx).Create().SetIsSystem(item.IsSystem).SetUser(dto.ConvertUserPB2Object(user)). -// Save(ctx); err != nil { -// log.Errorw("msg", "Error creating user item", "itemId", item.Id, "error", err) -// return err -// } -// log.Infow("msg", "User item created successfully", "itemId", item.Id, "itemUuid", item.Uuid) -// } -// log.Infow("msg", "Finished createUserBatch") -// return nil -//} -// -//func (obj *Data) InitRoleFromFile(ctx context.Context, filename string) error { -// abs, err := filepath.Abs(filename) -// if err != nil { -// return err -// } -// var roles []*dto.RolePB -// err = codec.DecodeFromFile(abs, &roles) -// if err != nil { -// if errors.Is(err, os.ErrNotExist) { -// log.Warnw("Role data file not found, skip init role data from file", "file", abs) -// return nil -// } -// return err -// } -// return obj.Tx(ctx, func(ctx context.Context) error { -// return obj.createRoleBatch(ctx, roles) -// }) -//} -// -//func (obj *Data) createRoleBatch(ctx context.Context, roles []*dto.RolePB) error { -// total := len(roles) -// log.Infow("msg", "Starting createRoleBatch", "totalItems", total) -// for i, item := range roles { -// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) -// if item.Id == 0 { -// item.Id = id.Gen() -// log.Infow("msg", "Generated new ID for item", "itemId", item.Id) -// } -// if _, err := obj.Role(ctx).Create().SetRole(dto.ConvertRolePB2Object(item)).Save(ctx); err != nil { -// log.Errorw("msg", "Error creating role item", "itemId", item.Id, "error", err) -// return err -// } -// log.Infow("msg", "Role item created successfully", "itemId", item.Id) -// } -// log.Infow("msg", "Finished createRoleBatch") -// return nil -//} -// -//func (obj *Data) InitDepartmentFromFile(ctx context.Context, filename string) error { -// abs, err := filepath.Abs(filename) -// if err != nil { -// return err -// } -// var departments []*dto.DepartmentNode -// err = codec.DecodeFromFile(abs, &departments) -// if err != nil { -// if errors.Is(err, os.ErrNotExist) { -// log.Warnw("Department data file not found, skip init department data from file", "file", abs) -// return nil -// } -// return err -// } -// return obj.Tx(ctx, func(ctx context.Context) error { -// return obj.createDepartmentBatch(ctx, departments, nil) -// }) -//} -// -//func (obj *Data) createDepartmentBatch(ctx context.Context, departments []*dto.DepartmentNode, parent *dto.DepartmentPB) error { -// total := len(departments) -// log.Infow("msg", "Starting createDepartmentBatch", "totalItems", total) -// for i, item := range departments { -// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) -// if item.Id == 0 { -// item.Id = id.Gen() -// log.Infow("msg", "Generated new ID for item", "itemId", item.Id) -// } -// if parent != nil { -// item.ParentId = parent.Id -// item.TreePath = parent.TreePath + strconv.Itoa(int(parent.Id)) + TreePathDelimiter -// } -// -// if _, err := obj.Department(ctx).Create(). -// SetDepartment(dto.ConvertDepartmentPB2Object(&item.DepartmentPB)). -// Save(ctx); err != nil { -// log.Errorw("msg", "Error creating department item", "itemId", item.Id, "error", err) -// return err -// } -// -// log.Infow("msg", "Department item created successfully", "itemId", item.Id) -// if len(item.Children) != 0 { -// log.Infow("Processing children for item", "itemId", item.Id, "childCount", len(item.Children)) -// if err := obj.createDepartmentBatch(ctx, item.Children, &item.DepartmentPB); err != nil { -// log.Errorw("Error processing children", "itemId", item.Id, "error", err) -// return err -// } -// log.Infow("msg", "Children processed successfully", "itemId", item.Id) -// } -// } -// log.Infow("msg", "Finished createDepartmentBatch") -// return nil -//} -// -//func (obj *Data) InitPositionFromFile(ctx context.Context, filename string) error { -// abs, err := filepath.Abs(filename) -// if err != nil { -// return err -// } -// var positions []*dto.PositionNode -// err = codec.DecodeFromFile(abs, &positions) -// if err != nil { -// if errors.Is(err, os.ErrNotExist) { -// log.Warnw("Position data file not found, skip init position data from file", "file", abs) -// return nil -// } -// return err -// } -// return obj.Tx(ctx, func(ctx context.Context) error { -// return obj.createPositionBatch(ctx, positions) -// }) -//} -// -//func (obj *Data) createPositionBatch(ctx context.Context, positions []*dto.PositionNode) error { -// total := len(positions) -// log.Infow("msg", "Starting createPositionBatch", "totalItems", total) -// for i, item := range positions { -// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) -// if item.Id == 0 { -// item.Id = id.Gen() -// log.Infow("msg", "Generated new ID for item", "itemId", item.Id) -// } -// dept, err := obj.Department(ctx).Query().Where(department.Keyword(item.DepartmentKeyword)).Only(ctx) -// if err != nil { -// return err -// } -// -// if _, err := obj.Position(ctx).Create().SetPosition(&dto.Position{ -// ID: item.Id, -// CreateTime: time.Now(), -// UpdateTime: time.Now(), -// Name: item.Name, -// Keyword: item.Keyword, -// Description: item.Description, -// DepartmentID: dept.ID, -// }).Save(ctx); err != nil { -// log.Errorw("msg", "Error creating position item", "itemId", item.Id, "error", err) -// return err -// } -// log.Infow("msg", "Position item created successfully", "itemId", item.Id) -// } -// log.Infow("msg", "Finished createPositionBatch") -// return nil -//} -// -//func (obj *Data) InitPermissionFromFile(ctx context.Context, filename string) error { -// abs, err := filepath.Abs(filename) -// if err != nil { -// return err -// } -// var permissions []*dto.PermissionNode -// err = codec.DecodeFromFile(abs, &permissions) -// if err != nil { -// if errors.Is(err, os.ErrNotExist) { -// log.Warnw("Permission data file not found, skip init permission data from file", "file", abs) -// return nil -// } -// return err -// } -// return obj.Tx(ctx, func(ctx context.Context) error { -// return obj.createPermissionBatch(ctx, permissions) -// }) -//} -// -//func (obj *Data) createPermissionBatch(ctx context.Context, permissions []*dto.PermissionNode) error { -// total := len(permissions) -// log.Infow("msg", "Starting createPermissionBatch", "totalItems", total) -// for i, item := range permissions { -// log.Infow("msg", "Processing item", "index", i, "itemId", item.Id, "itemKeyword", item.Keyword, "itemName", item.Name) -// if item.Id == 0 { -// item.Id = id.Gen() -// log.Infow("msg", "Generated new ID for item", "itemId", item.Id) -// } -// if _, err := obj.Permission(ctx).Create(). -// SetPermission(dto.ConvertPermissionPB2Object(&item.PermissionPB)). -// Save(ctx); err != nil { -// log.Errorw("msg", "Error creating permission item", "itemId", item.Id, "error", err) -// return err -// } -// log.Infow("msg", "Permission item created successfully", "itemId", item.Id) -// } -// log.Infow("msg", "Finished createPermissionBatch") -// return nil -//} -// -//func resourceOrderBy(orders []string) []resource.OrderOption { -// return db.OrderBy[resource.OrderOption](orders) -//} -// -func wrapRefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { - return &refreshTokenizer{ - tokenizer: tokenizer, - } -} - -func RefreshTokenizer(tokenizer security.Tokenizer) security.RefreshTokenizer { - if rt, ok := tokenizer.(security.RefreshTokenizer); ok { - return rt - } - return wrapRefreshTokenizer(tokenizer) -} - -// MakeCreateUser functions are used to create new users -func MakeCreateUser(user *dto.UserPB, username, password string, option dto.UserMutationOption) (*dto.UserPB, string, error) { - log.Debugf("Creating user with options: %+v", option) - if !option.NoPasswd { - log.Debugf("NoPasswd is false, checking for RandomPasswd") - if option.RandomPasswd && (user.Email != "" || user.Phone != "") { - log.Debugf("RandomPasswd is true and user has email or phone, generating random password") - password = rand.GenerateRandom(8) - log.Debugf("Generated random password: %s", password) - } else { - log.Debugf("RandomPasswd is false or user has no email or phone") - } - } else { - log.Debugf("NoPasswd is true, setting password to empty string") - password = "" - } - var err error - if password != "" { - log.Debugf("Password is not empty, generating salt") - //user.Salt = rand.GenerateSalt() - //log.Debugf("Generated salt: %s", user.Salt) - user.Password, err = hash.Generate(password) - if err != nil { - log.Errorf("Error generating password hash: %v", err) - return nil, "", err - } - log.Debugf("Generated password hash: %s", user.Password) - } - registerID := id.Gen() - user.Id = registerID - user.Uuid = uuid.Must(uuid.NewRandom()).String() - user.Username = username - user.Name = "user_" + random.String(8) - user.Status = 1 - return user, password, nil -} diff --git a/internal/features/auth/dal/provider.go b/internal/features/auth/dal/provider.go index d7835cd4..81d888dc 100644 --- a/internal/features/auth/dal/provider.go +++ b/internal/features/auth/dal/provider.go @@ -1,6 +1,12 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + package dal -import "github.com/google/wire" +import ( + "github.com/google/wire" +) // ProviderSet is dal providers. -var ProviderSet = wire.NewSet(NewAuthRepo, NewMeRepo, NewCaptchaRepo) +var ProviderSet = wire.NewSet(NewAuthRepo, NewCasbinRepo) diff --git a/test/token_test.go b/test/token_test.go index 40151e51..f9dc8039 100644 --- a/test/token_test.go +++ b/test/token_test.go @@ -64,7 +64,7 @@ func TestGenerateToken(t *testing.T) { authRepo := dal.NewAuthRepo(r, dataData) //authServiceBiz := biz.NewAuthServiceBiz(r, authRepo) //authServiceServer := service.NewAuthServiceServerPB(authServiceBiz) - //casbinSourceRepo, err := dal.NewCasbinSourceRepo(dataData) + //casbinSourceRepo, err := dal.NewCasbinRepo(dataData) //if err != nil { // cleanup() // return From dd363d5dd5094e9a8dc5ebd0f554776c348e5f2e Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 01:21:39 +0800 Subject: [PATCH 110/158] refactor(auth): rename CasbinSourceService to CasbinService for consistency --- api/v1/proto/auth/casbin.proto | 4 +- api/v1/services/auth/casbin.pb.go | 20 +-- api/v1/services/auth/casbin.pb.gw.go | 108 ++++++------ api/v1/services/auth/casbin_bridge.pb.go | 146 ++++++++-------- api/v1/services/auth/casbin_grpc.pb.go | 124 +++++++------- api/v1/services/auth/casbin_http.pb.go | 48 +++--- internal/data/casbin.go | 201 +++++++++++++++++++++++ internal/features/auth/biz/auth.go | 3 +- internal/features/auth/biz/captcha.go | 4 +- internal/features/auth/dal/me.go | 9 +- internal/features/auth/dal/provider.go | 2 +- internal/features/auth/server/server.go | 12 +- internal/features/auth/service/auth.go | 15 +- internal/features/auth/service/casbin.go | 9 +- internal/features/auth/service/me.go | 21 +-- internal/helpers/providers/providers.go | 4 + resources/api-docs/openapi/openapi.yaml | 16 +- 17 files changed, 479 insertions(+), 267 deletions(-) create mode 100644 internal/data/casbin.go diff --git a/api/v1/proto/auth/casbin.proto b/api/v1/proto/auth/casbin.proto index 3c9f3a77..ce9d28a5 100644 --- a/api/v1/proto/auth/casbin.proto +++ b/api/v1/proto/auth/casbin.proto @@ -10,8 +10,8 @@ option java_outer_classname = "APIServiceAuthCasbinProto"; option java_package = "com.origadmin.api.v1.services.auth"; option objc_class_prefix = "APIServiceAuthCasbin"; -// The Casbin source service definition. -service CasbinSourceService { +// The Casbin service definition. +service CasbinService { rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) { option (google.api.http) = { get: "/api/v1/casbin/policies" diff --git a/api/v1/services/auth/casbin.pb.go b/api/v1/services/auth/casbin.pb.go index 2205cf9c..bcddfade 100644 --- a/api/v1/services/auth/casbin.pb.go +++ b/api/v1/services/auth/casbin.pb.go @@ -536,8 +536,8 @@ const file_auth_casbin_proto_rawDesc = "" + "\x12WatchUpdateRequest\x12$\n" + "\rlast_modified\x18\x01 \x01(\x03R\rlast_modified\";\n" + "\x13WatchUpdateResponse\x12$\n" + - "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\x9f\x04\n" + - "\x13CasbinSourceService\x12\x89\x01\n" + + "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\x99\x04\n" + + "\rCasbinService\x12\x89\x01\n" + "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\"\x82\xd3\xe4\x93\x02\x1cb\x01*\x12\x17/api/v1/casbin/policies\x12\x8d\x01\n" + "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"#\x82\xd3\xe4\x93\x02\x1db\x01*\x12\x18/api/v1/casbin/groupings\x12\x83\x01\n" + "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x1f\x82\xd3\xe4\x93\x02\x19b\x01*\x12\x14/api/v1/casbin/watch\x12f\n" + @@ -574,14 +574,14 @@ var file_auth_casbin_proto_depIdxs = []int32{ 5, // 1: api.v1.services.auth.ListGroupingsResponse.rules:type_name -> api.v1.services.auth.GroupingRule 2, // 2: api.v1.services.auth.StreamRulesResponse.policy:type_name -> api.v1.services.auth.PolicyRule 5, // 3: api.v1.services.auth.StreamRulesResponse.grouping:type_name -> api.v1.services.auth.GroupingRule - 0, // 4: api.v1.services.auth.CasbinSourceService.ListPolicies:input_type -> api.v1.services.auth.ListPoliciesRequest - 3, // 5: api.v1.services.auth.CasbinSourceService.ListGroupings:input_type -> api.v1.services.auth.ListGroupingsRequest - 8, // 6: api.v1.services.auth.CasbinSourceService.WatchUpdate:input_type -> api.v1.services.auth.WatchUpdateRequest - 6, // 7: api.v1.services.auth.CasbinSourceService.StreamRules:input_type -> api.v1.services.auth.StreamRulesRequest - 1, // 8: api.v1.services.auth.CasbinSourceService.ListPolicies:output_type -> api.v1.services.auth.ListPoliciesResponse - 4, // 9: api.v1.services.auth.CasbinSourceService.ListGroupings:output_type -> api.v1.services.auth.ListGroupingsResponse - 9, // 10: api.v1.services.auth.CasbinSourceService.WatchUpdate:output_type -> api.v1.services.auth.WatchUpdateResponse - 7, // 11: api.v1.services.auth.CasbinSourceService.StreamRules:output_type -> api.v1.services.auth.StreamRulesResponse + 0, // 4: api.v1.services.auth.CasbinService.ListPolicies:input_type -> api.v1.services.auth.ListPoliciesRequest + 3, // 5: api.v1.services.auth.CasbinService.ListGroupings:input_type -> api.v1.services.auth.ListGroupingsRequest + 8, // 6: api.v1.services.auth.CasbinService.WatchUpdate:input_type -> api.v1.services.auth.WatchUpdateRequest + 6, // 7: api.v1.services.auth.CasbinService.StreamRules:input_type -> api.v1.services.auth.StreamRulesRequest + 1, // 8: api.v1.services.auth.CasbinService.ListPolicies:output_type -> api.v1.services.auth.ListPoliciesResponse + 4, // 9: api.v1.services.auth.CasbinService.ListGroupings:output_type -> api.v1.services.auth.ListGroupingsResponse + 9, // 10: api.v1.services.auth.CasbinService.WatchUpdate:output_type -> api.v1.services.auth.WatchUpdateResponse + 7, // 11: api.v1.services.auth.CasbinService.StreamRules:output_type -> api.v1.services.auth.StreamRulesResponse 8, // [8:12] is the sub-list for method output_type 4, // [4:8] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name diff --git a/api/v1/services/auth/casbin.pb.gw.go b/api/v1/services/auth/casbin.pb.gw.go index dee31a0f..35eb6164 100644 --- a/api/v1/services/auth/casbin.pb.gw.go +++ b/api/v1/services/auth/casbin.pb.gw.go @@ -35,7 +35,7 @@ var ( _ = metadata.Join ) -func request_CasbinSourceService_ListPolicies_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinSourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_CasbinService_ListPolicies_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ListPoliciesRequest metadata runtime.ServerMetadata @@ -45,7 +45,7 @@ func request_CasbinSourceService_ListPolicies_0(ctx context.Context, marshaler r return msg, metadata, err } -func local_request_CasbinSourceService_ListPolicies_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinSourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_CasbinService_ListPolicies_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ListPoliciesRequest metadata runtime.ServerMetadata @@ -54,7 +54,7 @@ func local_request_CasbinSourceService_ListPolicies_0(ctx context.Context, marsh return msg, metadata, err } -func request_CasbinSourceService_ListGroupings_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinSourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_CasbinService_ListGroupings_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ListGroupingsRequest metadata runtime.ServerMetadata @@ -64,7 +64,7 @@ func request_CasbinSourceService_ListGroupings_0(ctx context.Context, marshaler return msg, metadata, err } -func local_request_CasbinSourceService_ListGroupings_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinSourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_CasbinService_ListGroupings_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq ListGroupingsRequest metadata runtime.ServerMetadata @@ -73,9 +73,9 @@ func local_request_CasbinSourceService_ListGroupings_0(ctx context.Context, mars return msg, metadata, err } -var filter_CasbinSourceService_WatchUpdate_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +var filter_CasbinService_WatchUpdate_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -func request_CasbinSourceService_WatchUpdate_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinSourceServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_CasbinService_WatchUpdate_0(ctx context.Context, marshaler runtime.Marshaler, client CasbinServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq WatchUpdateRequest metadata runtime.ServerMetadata @@ -84,14 +84,14 @@ func request_CasbinSourceService_WatchUpdate_0(ctx context.Context, marshaler ru if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CasbinSourceService_WatchUpdate_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CasbinService_WatchUpdate_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := client.WatchUpdate(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_CasbinSourceService_WatchUpdate_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinSourceServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_CasbinService_WatchUpdate_0(ctx context.Context, marshaler runtime.Marshaler, server CasbinServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq WatchUpdateRequest metadata runtime.ServerMetadata @@ -99,86 +99,86 @@ func local_request_CasbinSourceService_WatchUpdate_0(ctx context.Context, marsha if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CasbinSourceService_WatchUpdate_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_CasbinService_WatchUpdate_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } msg, err := server.WatchUpdate(ctx, &protoReq) return msg, metadata, err } -// RegisterCasbinSourceServiceHandlerServer registers the http handlers for service CasbinSourceService to "mux". -// UnaryRPC :call CasbinSourceServiceServer directly. +// RegisterCasbinServiceHandlerServer registers the http handlers for service CasbinService to "mux". +// UnaryRPC :call CasbinServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterCasbinSourceServiceHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterCasbinServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterCasbinSourceServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server CasbinSourceServiceServer) error { - mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListPolicies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { +func RegisterCasbinServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server CasbinServiceServer) error { + mux.Handle(http.MethodGet, pattern_CasbinService_ListPolicies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/api/v1/casbin/policies")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListPolicies", runtime.WithHTTPPathPattern("/api/v1/casbin/policies")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_CasbinSourceService_ListPolicies_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_CasbinService_ListPolicies_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_CasbinSourceService_ListPolicies_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_CasbinService_ListPolicies_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListGroupings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_CasbinService_ListGroupings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/api/v1/casbin/groupings")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListGroupings", runtime.WithHTTPPathPattern("/api/v1/casbin/groupings")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_CasbinSourceService_ListGroupings_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_CasbinService_ListGroupings_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_CasbinSourceService_ListGroupings_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_CasbinService_ListGroupings_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_CasbinSourceService_WatchUpdate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_CasbinService_WatchUpdate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/api/v1/casbin/watch")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/WatchUpdate", runtime.WithHTTPPathPattern("/api/v1/casbin/watch")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_CasbinSourceService_WatchUpdate_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_CasbinService_WatchUpdate_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_CasbinSourceService_WatchUpdate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_CasbinService_WatchUpdate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } -// RegisterCasbinSourceServiceHandlerFromEndpoint is same as RegisterCasbinSourceServiceHandler but +// RegisterCasbinServiceHandlerFromEndpoint is same as RegisterCasbinServiceHandler but // automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterCasbinSourceServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { +func RegisterCasbinServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { conn, err := grpc.NewClient(endpoint, opts...) if err != nil { return err @@ -197,83 +197,83 @@ func RegisterCasbinSourceServiceHandlerFromEndpoint(ctx context.Context, mux *ru } }() }() - return RegisterCasbinSourceServiceHandler(ctx, mux, conn) + return RegisterCasbinServiceHandler(ctx, mux, conn) } -// RegisterCasbinSourceServiceHandler registers the http handlers for service CasbinSourceService to "mux". +// RegisterCasbinServiceHandler registers the http handlers for service CasbinService to "mux". // The handlers forward requests to the grpc endpoint over "conn". -func RegisterCasbinSourceServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterCasbinSourceServiceHandlerClient(ctx, mux, NewCasbinSourceServiceClient(conn)) +func RegisterCasbinServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterCasbinServiceHandlerClient(ctx, mux, NewCasbinServiceClient(conn)) } -// RegisterCasbinSourceServiceHandlerClient registers the http handlers for service CasbinSourceService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "CasbinSourceServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "CasbinSourceServiceClient" +// RegisterCasbinServiceHandlerClient registers the http handlers for service CasbinService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "CasbinServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "CasbinServiceClient" // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "CasbinSourceServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterCasbinSourceServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client CasbinSourceServiceClient) error { - mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListPolicies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { +// "CasbinServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterCasbinServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client CasbinServiceClient) error { + mux.Handle(http.MethodGet, pattern_CasbinService_ListPolicies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListPolicies", runtime.WithHTTPPathPattern("/api/v1/casbin/policies")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListPolicies", runtime.WithHTTPPathPattern("/api/v1/casbin/policies")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_CasbinSourceService_ListPolicies_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_CasbinService_ListPolicies_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_CasbinSourceService_ListPolicies_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_CasbinService_ListPolicies_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_CasbinSourceService_ListGroupings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_CasbinService_ListGroupings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/ListGroupings", runtime.WithHTTPPathPattern("/api/v1/casbin/groupings")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListGroupings", runtime.WithHTTPPathPattern("/api/v1/casbin/groupings")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_CasbinSourceService_ListGroupings_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_CasbinService_ListGroupings_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_CasbinSourceService_ListGroupings_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_CasbinService_ListGroupings_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodGet, pattern_CasbinSourceService_WatchUpdate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_CasbinService_WatchUpdate_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinSourceService/WatchUpdate", runtime.WithHTTPPathPattern("/api/v1/casbin/watch")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/WatchUpdate", runtime.WithHTTPPathPattern("/api/v1/casbin/watch")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_CasbinSourceService_WatchUpdate_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_CasbinService_WatchUpdate_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_CasbinSourceService_WatchUpdate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_CasbinService_WatchUpdate_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( - pattern_CasbinSourceService_ListPolicies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "policies"}, "")) - pattern_CasbinSourceService_ListGroupings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "groupings"}, "")) - pattern_CasbinSourceService_WatchUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "watch"}, "")) + pattern_CasbinService_ListPolicies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "policies"}, "")) + pattern_CasbinService_ListGroupings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "groupings"}, "")) + pattern_CasbinService_WatchUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "watch"}, "")) ) var ( - forward_CasbinSourceService_ListPolicies_0 = runtime.ForwardResponseMessage - forward_CasbinSourceService_ListGroupings_0 = runtime.ForwardResponseMessage - forward_CasbinSourceService_WatchUpdate_0 = runtime.ForwardResponseMessage + forward_CasbinService_ListPolicies_0 = runtime.ForwardResponseMessage + forward_CasbinService_ListGroupings_0 = runtime.ForwardResponseMessage + forward_CasbinService_WatchUpdate_0 = runtime.ForwardResponseMessage ) diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index f7bf50ef..c93ff177 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -28,54 +28,54 @@ var ( _ = codes.Unimplemented ) -const CasbinSourceServiceListPoliciesBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListPolicies" -const CasbinSourceServiceListGroupingsBridgeOperation = "/api.v1.services.auth.CasbinSourceService/ListGroupings" -const CasbinSourceServiceWatchUpdateBridgeOperation = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" -const CasbinSourceServiceStreamRulesBridgeOperation = "/api.v1.services.auth.CasbinSourceService/StreamRules" +const CasbinServiceListPoliciesBridgeOperation = "/api.v1.services.auth.CasbinService/ListPolicies" +const CasbinServiceListGroupingsBridgeOperation = "/api.v1.services.auth.CasbinService/ListGroupings" +const CasbinServiceWatchUpdateBridgeOperation = "/api.v1.services.auth.CasbinService/WatchUpdate" +const CasbinServiceStreamRulesBridgeOperation = "/api.v1.services.auth.CasbinService/StreamRules" -type CasbinSourceServiceBridgeServer interface { +type CasbinServiceBridgeServer interface { ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) } -type CasbinSourceServiceHooker interface { - CasbinSourceServiceListPoliciesHooker - CasbinSourceServiceListGroupingsHooker - CasbinSourceServiceWatchUpdateHooker +type CasbinServiceHooker interface { + CasbinServiceListPoliciesHooker + CasbinServiceListGroupingsHooker + CasbinServiceWatchUpdateHooker } -type CasbinSourceServiceHookedBridger interface { - CasbinSourceServiceHooker - CasbinSourceServiceBridgeServer +type CasbinServiceHookedBridger interface { + CasbinServiceHooker + CasbinServiceBridgeServer } -type CasbinSourceServiceListPoliciesHooker interface { +type CasbinServiceListPoliciesHooker interface { PrepareListPolicies(http.Context, *ListPoliciesRequest) (context.Context, error) CompleteListPolicies(http.Context, *ListPoliciesRequest, *ListPoliciesResponse) error } -type CasbinSourceServiceListGroupingsHooker interface { +type CasbinServiceListGroupingsHooker interface { PrepareListGroupings(http.Context, *ListGroupingsRequest) (context.Context, error) CompleteListGroupings(http.Context, *ListGroupingsRequest, *ListGroupingsResponse) error } -type CasbinSourceServiceWatchUpdateHooker interface { +type CasbinServiceWatchUpdateHooker interface { PrepareWatchUpdate(http.Context, *WatchUpdateRequest) (context.Context, error) CompleteWatchUpdate(http.Context, *WatchUpdateRequest, *WatchUpdateResponse) error } -func RegisterCasbinSourceServiceBridgeServer(s *http.Server, srv CasbinSourceServiceHookedBridger) { +func RegisterCasbinServiceBridgeServer(s *http.Server, srv CasbinServiceHookedBridger) { r := s.Route("/") - r.GET("/api/v1/casbin/policies", _CasbinSourceService_ListPolicies0_Bridge_Handler(srv)) - r.GET("/api/v1/casbin/groupings", _CasbinSourceService_ListGroupings0_Bridge_Handler(srv)) - r.GET("/api/v1/casbin/watch", _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv)) + r.GET("/api/v1/casbin/policies", _CasbinService_ListPolicies0_Bridge_Handler(srv)) + r.GET("/api/v1/casbin/groupings", _CasbinService_ListGroupings0_Bridge_Handler(srv)) + r.GET("/api/v1/casbin/watch", _CasbinService_WatchUpdate0_Bridge_Handler(srv)) } -func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { +func _CasbinService_ListPolicies0_Bridge_Handler(srv CasbinServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListPoliciesRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationCasbinSourceServiceListPolicies) + http.SetOperation(ctx, OperationCasbinServiceListPolicies) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.ListPolicies(ctx, req.(*ListPoliciesRequest)) }) @@ -92,13 +92,13 @@ func _CasbinSourceService_ListPolicies0_Bridge_Handler(srv CasbinSourceServiceHo } } -func _CasbinSourceService_ListGroupings0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { +func _CasbinService_ListGroupings0_Bridge_Handler(srv CasbinServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListGroupingsRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationCasbinSourceServiceListGroupings) + http.SetOperation(ctx, OperationCasbinServiceListGroupings) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.ListGroupings(ctx, req.(*ListGroupingsRequest)) }) @@ -115,13 +115,13 @@ func _CasbinSourceService_ListGroupings0_Bridge_Handler(srv CasbinSourceServiceH } } -func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceHookedBridger) func(ctx http.Context) error { +func _CasbinService_WatchUpdate0_Bridge_Handler(srv CasbinServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in WatchUpdateRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationCasbinSourceServiceWatchUpdate) + http.SetOperation(ctx, OperationCasbinServiceWatchUpdate) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.WatchUpdate(ctx, req.(*WatchUpdateRequest)) }) @@ -138,92 +138,92 @@ func _CasbinSourceService_WatchUpdate0_Bridge_Handler(srv CasbinSourceServiceHoo } } -// UnimplementedCasbinSourceServiceHooked must be embedded to have +// UnimplementedCasbinServiceHooked must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedCasbinSourceServiceHooked struct{} +type UnimplementedCasbinServiceHooked struct{} -func (UnimplementedCasbinSourceServiceHooked) PrepareListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { +func (UnimplementedCasbinServiceHooked) PrepareListPolicies(ctx http.Context, in *ListPoliciesRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceHooked) CompleteListPolicies(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { +func (UnimplementedCasbinServiceHooked) CompleteListPolicies(ctx http.Context, in *ListPoliciesRequest, out *ListPoliciesResponse) error { return ctx.Result(200, out) } -func (UnimplementedCasbinSourceServiceHooked) PrepareListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { +func (UnimplementedCasbinServiceHooked) PrepareListGroupings(ctx http.Context, in *ListGroupingsRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceHooked) CompleteListGroupings(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { +func (UnimplementedCasbinServiceHooked) CompleteListGroupings(ctx http.Context, in *ListGroupingsRequest, out *ListGroupingsResponse) error { return ctx.Result(200, out) } -func (UnimplementedCasbinSourceServiceHooked) PrepareWatchUpdate(ctx http.Context, in *WatchUpdateRequest) (context.Context, error) { +func (UnimplementedCasbinServiceHooked) PrepareWatchUpdate(ctx http.Context, in *WatchUpdateRequest) (context.Context, error) { return ctx, nil } -func (UnimplementedCasbinSourceServiceHooked) CompleteWatchUpdate(ctx http.Context, in *WatchUpdateRequest, out *WatchUpdateResponse) error { +func (UnimplementedCasbinServiceHooked) CompleteWatchUpdate(ctx http.Context, in *WatchUpdateRequest, out *WatchUpdateResponse) error { return ctx.Result(200, out) } -func WithCasbinSourceServiceHook(h CasbinSourceServiceHooker) func(CasbinSourceServiceBridgeServer) CasbinSourceServiceHookedBridger { - return func(srv CasbinSourceServiceBridgeServer) CasbinSourceServiceHookedBridger { - return CasbinSourceServiceHookedBridge{CasbinSourceServiceBridgeServer: srv, CasbinSourceServiceHooker: h} +func WithCasbinServiceHook(h CasbinServiceHooker) func(CasbinServiceBridgeServer) CasbinServiceHookedBridger { + return func(srv CasbinServiceBridgeServer) CasbinServiceHookedBridger { + return CasbinServiceHookedBridge{CasbinServiceBridgeServer: srv, CasbinServiceHooker: h} } } -// CasbinSourceServiceHookedBridge is a bridge between the HTTP and gRPC implementations of CasbinSourceService. -// It implements the HTTP and gRPC implementations of CasbinSourceService. +// CasbinServiceHookedBridge is a bridge between the HTTP and gRPC implementations of CasbinService. +// It implements the HTTP and gRPC implementations of CasbinService. // It forwards requests and responses between the two implementations. -type CasbinSourceServiceHookedBridge struct { - CasbinSourceServiceBridgeServer - CasbinSourceServiceHooker +type CasbinServiceHookedBridge struct { + CasbinServiceBridgeServer + CasbinServiceHooker } -type CasbinSourceServiceHTTPBridgeImpl struct { - client CasbinSourceServiceHTTPClient +type CasbinServiceHTTPBridgeImpl struct { + client CasbinServiceHTTPClient } -func NewCasbinSourceServiceHTTPBridge(client *http.Client) CasbinSourceServiceHTTPServer { - return &CasbinSourceServiceHTTPBridgeImpl{client: NewCasbinSourceServiceHTTPClient(client)} +func NewCasbinServiceHTTPBridge(client *http.Client) CasbinServiceHTTPServer { + return &CasbinServiceHTTPBridgeImpl{client: NewCasbinServiceHTTPClient(client)} } -func (c *CasbinSourceServiceHTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { +func (c *CasbinServiceHTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { return c.client.ListPolicies(ctx, in) } -func (c *CasbinSourceServiceHTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { +func (c *CasbinServiceHTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { return c.client.ListGroupings(ctx, in) } -func (c *CasbinSourceServiceHTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { +func (c *CasbinServiceHTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { return c.client.WatchUpdate(ctx, in) } -type CasbinSourceServiceBridgeImpl struct { - client CasbinSourceServiceClient +type CasbinServiceBridgeImpl struct { + client CasbinServiceClient } -func NewCasbinSourceServiceBridge(client grpc.ClientConnInterface) CasbinSourceServiceServer { - return &CasbinSourceServiceBridgeImpl{client: NewCasbinSourceServiceClient(client)} +func NewCasbinServiceBridge(client grpc.ClientConnInterface) CasbinServiceServer { + return &CasbinServiceBridgeImpl{client: NewCasbinServiceClient(client)} } -func (c *CasbinSourceServiceBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { +func (c *CasbinServiceBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { return c.client.ListPolicies(ctx, in) } -func (c *CasbinSourceServiceBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { +func (c *CasbinServiceBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { return c.client.ListGroupings(ctx, in) } -func (c *CasbinSourceServiceBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { +func (c *CasbinServiceBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { return c.client.WatchUpdate(ctx, in) } -func (c *CasbinSourceServiceBridgeImpl) StreamRules(request *StreamRulesRequest, g grpc.ServerStreamingServer[StreamRulesResponse]) error { +func (c *CasbinServiceBridgeImpl) StreamRules(request *StreamRulesRequest, g grpc.ServerStreamingServer[StreamRulesResponse]) error { stream, err := c.client.StreamRules(g.Context(), request) if err != nil { return err @@ -243,50 +243,50 @@ func (c *CasbinSourceServiceBridgeImpl) StreamRules(request *StreamRulesRequest, return nil } -func (c *CasbinSourceServiceBridgeImpl) mustEmbedUnimplementedCasbinSourceServiceServer() {} +func (c *CasbinServiceBridgeImpl) mustEmbedUnimplementedCasbinServiceServer() {} -type CasbinSourceServiceGRPC2HTTPBridgeImpl struct { - client CasbinSourceServiceClient +type CasbinServiceGRPC2HTTPBridgeImpl struct { + client CasbinServiceClient } -func NewCasbinSourceServiceGRPC2HTTP(client grpc.ClientConnInterface) CasbinSourceServiceHTTPServer { - return &CasbinSourceServiceGRPC2HTTPBridgeImpl{client: NewCasbinSourceServiceClient(client)} +func NewCasbinServiceGRPC2HTTP(client grpc.ClientConnInterface) CasbinServiceHTTPServer { + return &CasbinServiceGRPC2HTTPBridgeImpl{client: NewCasbinServiceClient(client)} } -func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { +func (c *CasbinServiceGRPC2HTTPBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { return c.client.ListPolicies(ctx, in) } -func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { +func (c *CasbinServiceGRPC2HTTPBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { return c.client.ListGroupings(ctx, in) } -func (c *CasbinSourceServiceGRPC2HTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { +func (c *CasbinServiceGRPC2HTTPBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { return c.client.WatchUpdate(ctx, in) } -type CasbinSourceServiceHTTP2GRPCBridgeImpl struct { - client CasbinSourceServiceHTTPClient +type CasbinServiceHTTP2GRPCBridgeImpl struct { + client CasbinServiceHTTPClient } -func NewCasbinSourceServiceHTTP2GRPC(client *http.Client) CasbinSourceServiceServer { - return &CasbinSourceServiceHTTP2GRPCBridgeImpl{client: NewCasbinSourceServiceHTTPClient(client)} +func NewCasbinServiceHTTP2GRPC(client *http.Client) CasbinServiceServer { + return &CasbinServiceHTTP2GRPCBridgeImpl{client: NewCasbinServiceHTTPClient(client)} } -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { +func (c *CasbinServiceHTTP2GRPCBridgeImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest) (*ListPoliciesResponse, error) { return c.client.ListPolicies(ctx, in) } -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { +func (c *CasbinServiceHTTP2GRPCBridgeImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest) (*ListGroupingsResponse, error) { return c.client.ListGroupings(ctx, in) } -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { +func (c *CasbinServiceHTTP2GRPCBridgeImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest) (*WatchUpdateResponse, error) { return c.client.WatchUpdate(ctx, in) } -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) StreamRules(request *StreamRulesRequest, g grpc.ServerStreamingServer[StreamRulesResponse]) error { +func (c *CasbinServiceHTTP2GRPCBridgeImpl) StreamRules(request *StreamRulesRequest, g grpc.ServerStreamingServer[StreamRulesResponse]) error { return status.Errorf(codes.Unimplemented, "StreamRules not implemented") } -func (c *CasbinSourceServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedCasbinSourceServiceServer() {} +func (c *CasbinServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedCasbinServiceServer() {} diff --git a/api/v1/services/auth/casbin_grpc.pb.go b/api/v1/services/auth/casbin_grpc.pb.go index 86911a12..e7c03812 100644 --- a/api/v1/services/auth/casbin_grpc.pb.go +++ b/api/v1/services/auth/casbin_grpc.pb.go @@ -19,65 +19,65 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - CasbinSourceService_ListPolicies_FullMethodName = "/api.v1.services.auth.CasbinSourceService/ListPolicies" - CasbinSourceService_ListGroupings_FullMethodName = "/api.v1.services.auth.CasbinSourceService/ListGroupings" - CasbinSourceService_WatchUpdate_FullMethodName = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" - CasbinSourceService_StreamRules_FullMethodName = "/api.v1.services.auth.CasbinSourceService/StreamRules" + CasbinService_ListPolicies_FullMethodName = "/api.v1.services.auth.CasbinService/ListPolicies" + CasbinService_ListGroupings_FullMethodName = "/api.v1.services.auth.CasbinService/ListGroupings" + CasbinService_WatchUpdate_FullMethodName = "/api.v1.services.auth.CasbinService/WatchUpdate" + CasbinService_StreamRules_FullMethodName = "/api.v1.services.auth.CasbinService/StreamRules" ) -// CasbinSourceServiceClient is the client API for CasbinSourceService service. +// CasbinServiceClient is the client API for CasbinService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // -// The Casbin source service definition. -type CasbinSourceServiceClient interface { +// The Casbin service definition. +type CasbinServiceClient interface { ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...grpc.CallOption) (*ListPoliciesResponse, error) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...grpc.CallOption) (*ListGroupingsResponse, error) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...grpc.CallOption) (*WatchUpdateResponse, error) StreamRules(ctx context.Context, in *StreamRulesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamRulesResponse], error) } -type casbinSourceServiceClient struct { +type casbinServiceClient struct { cc grpc.ClientConnInterface } -func NewCasbinSourceServiceClient(cc grpc.ClientConnInterface) CasbinSourceServiceClient { - return &casbinSourceServiceClient{cc} +func NewCasbinServiceClient(cc grpc.ClientConnInterface) CasbinServiceClient { + return &casbinServiceClient{cc} } -func (c *casbinSourceServiceClient) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...grpc.CallOption) (*ListPoliciesResponse, error) { +func (c *casbinServiceClient) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...grpc.CallOption) (*ListPoliciesResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ListPoliciesResponse) - err := c.cc.Invoke(ctx, CasbinSourceService_ListPolicies_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, CasbinService_ListPolicies_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *casbinSourceServiceClient) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...grpc.CallOption) (*ListGroupingsResponse, error) { +func (c *casbinServiceClient) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...grpc.CallOption) (*ListGroupingsResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ListGroupingsResponse) - err := c.cc.Invoke(ctx, CasbinSourceService_ListGroupings_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, CasbinService_ListGroupings_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *casbinSourceServiceClient) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...grpc.CallOption) (*WatchUpdateResponse, error) { +func (c *casbinServiceClient) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...grpc.CallOption) (*WatchUpdateResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(WatchUpdateResponse) - err := c.cc.Invoke(ctx, CasbinSourceService_WatchUpdate_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, CasbinService_WatchUpdate_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *casbinSourceServiceClient) StreamRules(ctx context.Context, in *StreamRulesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamRulesResponse], error) { +func (c *casbinServiceClient) StreamRules(ctx context.Context, in *StreamRulesRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[StreamRulesResponse], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &CasbinSourceService_ServiceDesc.Streams[0], CasbinSourceService_StreamRules_FullMethodName, cOpts...) + stream, err := c.cc.NewStream(ctx, &CasbinService_ServiceDesc.Streams[0], CasbinService_StreamRules_FullMethodName, cOpts...) if err != nil { return nil, err } @@ -92,150 +92,150 @@ func (c *casbinSourceServiceClient) StreamRules(ctx context.Context, in *StreamR } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type CasbinSourceService_StreamRulesClient = grpc.ServerStreamingClient[StreamRulesResponse] +type CasbinService_StreamRulesClient = grpc.ServerStreamingClient[StreamRulesResponse] -// CasbinSourceServiceServer is the server API for CasbinSourceService service. -// All implementations must embed UnimplementedCasbinSourceServiceServer +// CasbinServiceServer is the server API for CasbinService service. +// All implementations must embed UnimplementedCasbinServiceServer // for forward compatibility. // -// The Casbin source service definition. -type CasbinSourceServiceServer interface { +// The Casbin service definition. +type CasbinServiceServer interface { ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) StreamRules(*StreamRulesRequest, grpc.ServerStreamingServer[StreamRulesResponse]) error - mustEmbedUnimplementedCasbinSourceServiceServer() + mustEmbedUnimplementedCasbinServiceServer() } -// UnimplementedCasbinSourceServiceServer must be embedded to have +// UnimplementedCasbinServiceServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedCasbinSourceServiceServer struct{} +type UnimplementedCasbinServiceServer struct{} -func (UnimplementedCasbinSourceServiceServer) ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) { +func (UnimplementedCasbinServiceServer) ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListPolicies not implemented") } -func (UnimplementedCasbinSourceServiceServer) ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) { +func (UnimplementedCasbinServiceServer) ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ListGroupings not implemented") } -func (UnimplementedCasbinSourceServiceServer) WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) { +func (UnimplementedCasbinServiceServer) WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method WatchUpdate not implemented") } -func (UnimplementedCasbinSourceServiceServer) StreamRules(*StreamRulesRequest, grpc.ServerStreamingServer[StreamRulesResponse]) error { +func (UnimplementedCasbinServiceServer) StreamRules(*StreamRulesRequest, grpc.ServerStreamingServer[StreamRulesResponse]) error { return status.Errorf(codes.Unimplemented, "method StreamRules not implemented") } -func (UnimplementedCasbinSourceServiceServer) mustEmbedUnimplementedCasbinSourceServiceServer() {} -func (UnimplementedCasbinSourceServiceServer) testEmbeddedByValue() {} +func (UnimplementedCasbinServiceServer) mustEmbedUnimplementedCasbinServiceServer() {} +func (UnimplementedCasbinServiceServer) testEmbeddedByValue() {} -// UnsafeCasbinSourceServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to CasbinSourceServiceServer will +// UnsafeCasbinServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to CasbinServiceServer will // result in compilation errors. -type UnsafeCasbinSourceServiceServer interface { - mustEmbedUnimplementedCasbinSourceServiceServer() +type UnsafeCasbinServiceServer interface { + mustEmbedUnimplementedCasbinServiceServer() } -func RegisterCasbinSourceServiceServer(s grpc.ServiceRegistrar, srv CasbinSourceServiceServer) { - // If the following call pancis, it indicates UnimplementedCasbinSourceServiceServer was +func RegisterCasbinServiceServer(s grpc.ServiceRegistrar, srv CasbinServiceServer) { + // If the following call pancis, it indicates UnimplementedCasbinServiceServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&CasbinSourceService_ServiceDesc, srv) + s.RegisterService(&CasbinService_ServiceDesc, srv) } -func _CasbinSourceService_ListPolicies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _CasbinService_ListPolicies_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ListPoliciesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(CasbinSourceServiceServer).ListPolicies(ctx, in) + return srv.(CasbinServiceServer).ListPolicies(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: CasbinSourceService_ListPolicies_FullMethodName, + FullMethod: CasbinService_ListPolicies_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CasbinSourceServiceServer).ListPolicies(ctx, req.(*ListPoliciesRequest)) + return srv.(CasbinServiceServer).ListPolicies(ctx, req.(*ListPoliciesRequest)) } return interceptor(ctx, in, info, handler) } -func _CasbinSourceService_ListGroupings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _CasbinService_ListGroupings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ListGroupingsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(CasbinSourceServiceServer).ListGroupings(ctx, in) + return srv.(CasbinServiceServer).ListGroupings(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: CasbinSourceService_ListGroupings_FullMethodName, + FullMethod: CasbinService_ListGroupings_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CasbinSourceServiceServer).ListGroupings(ctx, req.(*ListGroupingsRequest)) + return srv.(CasbinServiceServer).ListGroupings(ctx, req.(*ListGroupingsRequest)) } return interceptor(ctx, in, info, handler) } -func _CasbinSourceService_WatchUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _CasbinService_WatchUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(WatchUpdateRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(CasbinSourceServiceServer).WatchUpdate(ctx, in) + return srv.(CasbinServiceServer).WatchUpdate(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: CasbinSourceService_WatchUpdate_FullMethodName, + FullMethod: CasbinService_WatchUpdate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CasbinSourceServiceServer).WatchUpdate(ctx, req.(*WatchUpdateRequest)) + return srv.(CasbinServiceServer).WatchUpdate(ctx, req.(*WatchUpdateRequest)) } return interceptor(ctx, in, info, handler) } -func _CasbinSourceService_StreamRules_Handler(srv interface{}, stream grpc.ServerStream) error { +func _CasbinService_StreamRules_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(StreamRulesRequest) if err := stream.RecvMsg(m); err != nil { return err } - return srv.(CasbinSourceServiceServer).StreamRules(m, &grpc.GenericServerStream[StreamRulesRequest, StreamRulesResponse]{ServerStream: stream}) + return srv.(CasbinServiceServer).StreamRules(m, &grpc.GenericServerStream[StreamRulesRequest, StreamRulesResponse]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type CasbinSourceService_StreamRulesServer = grpc.ServerStreamingServer[StreamRulesResponse] +type CasbinService_StreamRulesServer = grpc.ServerStreamingServer[StreamRulesResponse] -// CasbinSourceService_ServiceDesc is the grpc.ServiceDesc for CasbinSourceService service. +// CasbinService_ServiceDesc is the grpc.ServiceDesc for CasbinService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var CasbinSourceService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.auth.CasbinSourceService", - HandlerType: (*CasbinSourceServiceServer)(nil), +var CasbinService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.auth.CasbinService", + HandlerType: (*CasbinServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "ListPolicies", - Handler: _CasbinSourceService_ListPolicies_Handler, + Handler: _CasbinService_ListPolicies_Handler, }, { MethodName: "ListGroupings", - Handler: _CasbinSourceService_ListGroupings_Handler, + Handler: _CasbinService_ListGroupings_Handler, }, { MethodName: "WatchUpdate", - Handler: _CasbinSourceService_WatchUpdate_Handler, + Handler: _CasbinService_WatchUpdate_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "StreamRules", - Handler: _CasbinSourceService_StreamRules_Handler, + Handler: _CasbinService_StreamRules_Handler, ServerStreams: true, }, }, diff --git a/api/v1/services/auth/casbin_http.pb.go b/api/v1/services/auth/casbin_http.pb.go index 94487ae0..5f5f3299 100644 --- a/api/v1/services/auth/casbin_http.pb.go +++ b/api/v1/services/auth/casbin_http.pb.go @@ -19,30 +19,30 @@ var _ = binding.EncodeURL const _ = http.SupportPackageIsVersion1 -const OperationCasbinSourceServiceListGroupings = "/api.v1.services.auth.CasbinSourceService/ListGroupings" -const OperationCasbinSourceServiceListPolicies = "/api.v1.services.auth.CasbinSourceService/ListPolicies" -const OperationCasbinSourceServiceWatchUpdate = "/api.v1.services.auth.CasbinSourceService/WatchUpdate" +const OperationCasbinServiceListGroupings = "/api.v1.services.auth.CasbinService/ListGroupings" +const OperationCasbinServiceListPolicies = "/api.v1.services.auth.CasbinService/ListPolicies" +const OperationCasbinServiceWatchUpdate = "/api.v1.services.auth.CasbinService/WatchUpdate" -type CasbinSourceServiceHTTPServer interface { +type CasbinServiceHTTPServer interface { ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) WatchUpdate(context.Context, *WatchUpdateRequest) (*WatchUpdateResponse, error) } -func RegisterCasbinSourceServiceHTTPServer(s *http.Server, srv CasbinSourceServiceHTTPServer) { +func RegisterCasbinServiceHTTPServer(s *http.Server, srv CasbinServiceHTTPServer) { r := s.Route("/") - r.GET("/api/v1/casbin/policies", _CasbinSourceService_ListPolicies0_HTTP_Handler(srv)) - r.GET("/api/v1/casbin/groupings", _CasbinSourceService_ListGroupings0_HTTP_Handler(srv)) - r.GET("/api/v1/casbin/watch", _CasbinSourceService_WatchUpdate0_HTTP_Handler(srv)) + r.GET("/api/v1/casbin/policies", _CasbinService_ListPolicies0_HTTP_Handler(srv)) + r.GET("/api/v1/casbin/groupings", _CasbinService_ListGroupings0_HTTP_Handler(srv)) + r.GET("/api/v1/casbin/watch", _CasbinService_WatchUpdate0_HTTP_Handler(srv)) } -func _CasbinSourceService_ListPolicies0_HTTP_Handler(srv CasbinSourceServiceHTTPServer) func(ctx http.Context) error { +func _CasbinService_ListPolicies0_HTTP_Handler(srv CasbinServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListPoliciesRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationCasbinSourceServiceListPolicies) + http.SetOperation(ctx, OperationCasbinServiceListPolicies) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.ListPolicies(ctx, req.(*ListPoliciesRequest)) }) @@ -55,13 +55,13 @@ func _CasbinSourceService_ListPolicies0_HTTP_Handler(srv CasbinSourceServiceHTTP } } -func _CasbinSourceService_ListGroupings0_HTTP_Handler(srv CasbinSourceServiceHTTPServer) func(ctx http.Context) error { +func _CasbinService_ListGroupings0_HTTP_Handler(srv CasbinServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in ListGroupingsRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationCasbinSourceServiceListGroupings) + http.SetOperation(ctx, OperationCasbinServiceListGroupings) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.ListGroupings(ctx, req.(*ListGroupingsRequest)) }) @@ -74,13 +74,13 @@ func _CasbinSourceService_ListGroupings0_HTTP_Handler(srv CasbinSourceServiceHTT } } -func _CasbinSourceService_WatchUpdate0_HTTP_Handler(srv CasbinSourceServiceHTTPServer) func(ctx http.Context) error { +func _CasbinService_WatchUpdate0_HTTP_Handler(srv CasbinServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in WatchUpdateRequest if err := ctx.BindQuery(&in); err != nil { return err } - http.SetOperation(ctx, OperationCasbinSourceServiceWatchUpdate) + http.SetOperation(ctx, OperationCasbinServiceWatchUpdate) h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { return srv.WatchUpdate(ctx, req.(*WatchUpdateRequest)) }) @@ -93,25 +93,25 @@ func _CasbinSourceService_WatchUpdate0_HTTP_Handler(srv CasbinSourceServiceHTTPS } } -type CasbinSourceServiceHTTPClient interface { +type CasbinServiceHTTPClient interface { ListGroupings(ctx context.Context, req *ListGroupingsRequest, opts ...http.CallOption) (rsp *ListGroupingsResponse, err error) ListPolicies(ctx context.Context, req *ListPoliciesRequest, opts ...http.CallOption) (rsp *ListPoliciesResponse, err error) WatchUpdate(ctx context.Context, req *WatchUpdateRequest, opts ...http.CallOption) (rsp *WatchUpdateResponse, err error) } -type CasbinSourceServiceHTTPClientImpl struct { +type CasbinServiceHTTPClientImpl struct { cc *http.Client } -func NewCasbinSourceServiceHTTPClient(client *http.Client) CasbinSourceServiceHTTPClient { - return &CasbinSourceServiceHTTPClientImpl{client} +func NewCasbinServiceHTTPClient(client *http.Client) CasbinServiceHTTPClient { + return &CasbinServiceHTTPClientImpl{client} } -func (c *CasbinSourceServiceHTTPClientImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...http.CallOption) (*ListGroupingsResponse, error) { +func (c *CasbinServiceHTTPClientImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...http.CallOption) (*ListGroupingsResponse, error) { var out ListGroupingsResponse pattern := "/api/v1/casbin/groupings" path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationCasbinSourceServiceListGroupings)) + opts = append(opts, http.Operation(OperationCasbinServiceListGroupings)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) if err != nil { @@ -120,11 +120,11 @@ func (c *CasbinSourceServiceHTTPClientImpl) ListGroupings(ctx context.Context, i return &out, nil } -func (c *CasbinSourceServiceHTTPClientImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...http.CallOption) (*ListPoliciesResponse, error) { +func (c *CasbinServiceHTTPClientImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...http.CallOption) (*ListPoliciesResponse, error) { var out ListPoliciesResponse pattern := "/api/v1/casbin/policies" path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationCasbinSourceServiceListPolicies)) + opts = append(opts, http.Operation(OperationCasbinServiceListPolicies)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) if err != nil { @@ -133,11 +133,11 @@ func (c *CasbinSourceServiceHTTPClientImpl) ListPolicies(ctx context.Context, in return &out, nil } -func (c *CasbinSourceServiceHTTPClientImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...http.CallOption) (*WatchUpdateResponse, error) { +func (c *CasbinServiceHTTPClientImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...http.CallOption) (*WatchUpdateResponse, error) { var out WatchUpdateResponse pattern := "/api/v1/casbin/watch" path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationCasbinSourceServiceWatchUpdate)) + opts = append(opts, http.Operation(OperationCasbinServiceWatchUpdate)) opts = append(opts, http.PathTemplate(pattern)) err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) if err != nil { diff --git a/internal/data/casbin.go b/internal/data/casbin.go new file mode 100644 index 00000000..af947069 --- /dev/null +++ b/internal/data/casbin.go @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package data + +import ( + "context" + + "github.com/casbin/casbin/v2/model" + "github.com/casbin/casbin/v2/persist" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/casbinrule" + "origadmin/application/admin/internal/data/entity/ent/predicate" +) + +// casbinAdapter implements the persist.Adapter for casbin. +type casbinAdapter struct { + db *ent.Database +} + +// NewAdapter creates a new casbin adapter. +func NewAdapter(db *ent.Database) (persist.Adapter, error) { + return &casbinAdapter{db: db}, nil +} + +// LoadPolicy loads all policy rules from the storage. +func (a *casbinAdapter) LoadPolicy(model model.Model) error { + ctx := context.Background() + client := a.db.Client(ctx) + policies, err := client.CasbinRule.Query().Order(ent.Asc("id")).All(ctx) + if err != nil { + return err + } + for _, policy := range policies { + loadPolicyLine(policy, model) + } + return nil +} + +// SavePolicy saves all policy rules to the storage. +func (a *casbinAdapter) SavePolicy(model model.Model) error { + ctx := context.Background() + tx, err := a.db.Client(ctx).Tx(ctx) + if err != nil { + return err + } + if _, err := tx.CasbinRule.Delete().Exec(ctx); err != nil { + _ = tx.Rollback() + return err + } + lines := make([]*ent.CasbinRuleCreate, 0) + for ptype, ast := range model["p"] { + for _, policy := range ast.Policy { + lines = append(lines, savePolicyLine(tx, ptype, policy)) + } + } + for ptype, ast := range model["g"] { + for _, policy := range ast.Policy { + lines = append(lines, savePolicyLine(tx, ptype, policy)) + } + } + if _, err := tx.CasbinRule.CreateBulk(lines...).Save(ctx); err != nil { + _ = tx.Rollback() + return err + } + return tx.Commit() +} + +// AddPolicy adds a policy rule to the storage. +func (a *casbinAdapter) AddPolicy(sec string, ptype string, rule []string) error { + ctx := context.Background() + tx, err := a.db.Client(ctx).Tx(ctx) + if err != nil { + return err + } + if _, err := savePolicyLine(tx, ptype, rule).Save(ctx); err != nil { + _ = tx.Rollback() + return err + } + return tx.Commit() +} + +// RemovePolicy removes a policy rule from the storage. +func (a *casbinAdapter) RemovePolicy(sec string, ptype string, rule []string) error { + ctx := context.Background() + tx, err := a.db.Client(ctx).Tx(ctx) + if err != nil { + return err + } + instance := toInstance(ptype, rule) + if _, err := tx.CasbinRule.Delete().Where(buildInstanceFilter(instance)...).Exec(ctx); err != nil { + _ = tx.Rollback() + return err + } + return tx.Commit() +} + +// RemoveFilteredPolicy removes policy rules that match the filter from the storage. +func (a *casbinAdapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error { + ctx := context.Background() + tx, err := a.db.Client(ctx).Tx(ctx) + if err != nil { + return err + } + cond := buildFilteredFilter(ptype, fieldIndex, fieldValues...) + if _, err := tx.CasbinRule.Delete().Where(cond...).Exec(ctx); err != nil { + _ = tx.Rollback() + return err + } + return tx.Commit() +} + +// --- Helper Functions --- + +func loadPolicyLine(line *ent.CasbinRule, model model.Model) { + key := line.Ptype + sec := key[:1] + model[sec][key].Policy = append(model[sec][key].Policy, []string{line.V0, line.V1, line.V2, line.V3, line.V4, line.V5}) +} + +func toInstance(ptype string, rule []string) *ent.CasbinRule { + instance := &ent.CasbinRule{Ptype: ptype} + if len(rule) > 0 { + instance.V0 = rule[0] + } + if len(rule) > 1 { + instance.V1 = rule[1] + } + if len(rule) > 2 { + instance.V2 = rule[2] + } + if len(rule) > 3 { + instance.V3 = rule[3] + } + if len(rule) > 4 { + instance.V4 = rule[4] + } + if len(rule) > 5 { + instance.V5 = rule[5] + } + return instance +} + +func savePolicyLine(tx *ent.Tx, ptype string, rule []string) *ent.CasbinRuleCreate { + line := tx.CasbinRule.Create().SetPtype(ptype) + if len(rule) > 0 { + line.SetV0(rule[0]) + } + if len(rule) > 1 { + line.SetV1(rule[1]) + } + if len(rule) > 2 { + line.SetV2(rule[2]) + } + if len(rule) > 3 { + line.SetV3(rule[3]) + } + if len(rule) > 4 { + line.SetV4(rule[4]) + } + if len(rule) > 5 { + line.SetV5(rule[5]) + } + return line +} + +func buildInstanceFilter(instance *ent.CasbinRule) []predicate.CasbinRule { + return []predicate.CasbinRule{ + casbinrule.PtypeEQ(instance.Ptype), + casbinrule.V0EQ(instance.V0), + casbinrule.V1EQ(instance.V1), + casbinrule.V2EQ(instance.V2), + casbinrule.V3EQ(instance.V3), + casbinrule.V4EQ(instance.V4), + casbinrule.V5EQ(instance.V5), + } +} + +func buildFilteredFilter(ptype string, fieldIndex int, fieldValues ...string) []predicate.CasbinRule { + cond := []predicate.CasbinRule{casbinrule.PtypeEQ(ptype)} + if fieldIndex <= 0 && 0 < fieldIndex+len(fieldValues) { + cond = append(cond, casbinrule.V0EQ(fieldValues[0-fieldIndex])) + } + if fieldIndex <= 1 && 1 < fieldIndex+len(fieldValues) { + cond = append(cond, casbinrule.V1EQ(fieldValues[1-fieldIndex])) + } + if fieldIndex <= 2 && 2 < fieldIndex+len(fieldValues) { + cond = append(cond, casbinrule.V2EQ(fieldValues[2-fieldIndex])) + } + if fieldIndex <= 3 && 3 < fieldIndex+len(fieldValues) { + cond = append(cond, casbinrule.V3EQ(fieldValues[3-fieldIndex])) + } + if fieldIndex <= 4 && 4 < fieldIndex+len(fieldValues) { + cond = append(cond, casbinrule.V4EQ(fieldValues[4-fieldIndex])) + } + if fieldIndex <= 5 && 5 < fieldIndex+len(fieldValues) { + cond = append(cond, casbinrule.V5EQ(fieldValues[5-fieldIndex])) + } + return cond +} diff --git a/internal/features/auth/biz/auth.go b/internal/features/auth/biz/auth.go index 440adb4e..b348691d 100644 --- a/internal/features/auth/biz/auth.go +++ b/internal/features/auth/biz/auth.go @@ -34,8 +34,7 @@ func (uc *AuthUseCase) VerifyUser(ctx context.Context, username, password string } // Compare the provided password with the stored hash. - ok, err := uc.hasher.Verify(user.EncryptedPassword, password) - if err != nil || !ok { + if err := uc.hasher.Verify(user.EncryptedPassword, password); err != nil { return 0, errors.New("invalid username or password") } diff --git a/internal/features/auth/biz/captcha.go b/internal/features/auth/biz/captcha.go index 28b42f00..fd252453 100644 --- a/internal/features/auth/biz/captcha.go +++ b/internal/features/auth/biz/captcha.go @@ -33,9 +33,9 @@ func (uc *CaptchaUseCase) GenerateCaptcha(ctx context.Context) (id, b64s string, int(uc.config.GetWidth()), int(uc.config.GetLength()), float64(uc.config.GetMaxskew()), - uc.config.GetDotCount(), + int(uc.config.GetDotCount()), ) c := base64Captcha.NewCaptcha(driver, uc.repo) - id, content, err := c.Generate() + id, content, _, err := c.Generate() return id, content, err } diff --git a/internal/features/auth/dal/me.go b/internal/features/auth/dal/me.go index ded7fcc2..c325f96c 100644 --- a/internal/features/auth/dal/me.go +++ b/internal/features/auth/dal/me.go @@ -1,10 +1,13 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + package dal import ( "context" "github.com/go-kratos/kratos/v2/log" - "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/user" @@ -17,9 +20,9 @@ type meRepo struct { } // NewMeRepo . -func NewMeRepo(database *ent.Database, logger log.Logger) dto.MeRepo { +func NewMeRepo(db *ent.Database, logger log.Logger) dto.MeRepo { return &meRepo{ - db: database, + db: db, log: log.NewHelper(logger), } } diff --git a/internal/features/auth/dal/provider.go b/internal/features/auth/dal/provider.go index 81d888dc..7891e08d 100644 --- a/internal/features/auth/dal/provider.go +++ b/internal/features/auth/dal/provider.go @@ -9,4 +9,4 @@ import ( ) // ProviderSet is dal providers. -var ProviderSet = wire.NewSet(NewAuthRepo, NewCasbinRepo) +var ProviderSet = wire.NewSet(NewAuthRepo, NewCasbinRepo, NewMeRepo) diff --git a/internal/features/auth/server/server.go b/internal/features/auth/server/server.go index 8b15c830..8f6b88df 100644 --- a/internal/features/auth/server/server.go +++ b/internal/features/auth/server/server.go @@ -77,9 +77,9 @@ func NewHTTPServer( srv := http.NewServer(opts...) // Register HTTP handlers - authv1.RegisterAuthHTTPServer(srv, authSvc) - authv1.RegisterMeHTTPServer(srv, meSvc) - authv1.RegisterCasbinSourceServiceHTTPServer(srv, casbinSvc) + authv1.RegisterAuthServiceHTTPServer(srv, authSvc) + authv1.RegisterMeServiceHTTPServer(srv, meSvc) + authv1.RegisterCasbinServiceHTTPServer(srv, casbinSvc) srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { log.Infof("HTTP %s %s", method, path) @@ -109,9 +109,9 @@ func NewGRPCServer( srv := grpc.NewServer(opts...) // Register gRPC handlers - authv1.RegisterAuthServer(srv, authSvc) - authv1.RegisterMeServer(srv, meSvc) - authv1.RegisterCasbinSourceServiceServer(srv, casbinSvc) + authv1.RegisterAuthServiceServer(srv, authSvc) + authv1.RegisterMeServiceServer(srv, meSvc) + authv1.RegisterCasbinServiceServer(srv, casbinSvc) return srv, nil } diff --git a/internal/features/auth/service/auth.go b/internal/features/auth/service/auth.go index 521be19d..f27ab4b7 100644 --- a/internal/features/auth/service/auth.go +++ b/internal/features/auth/service/auth.go @@ -4,8 +4,7 @@ import ( "context" "fmt" - "google.golang.org/protobuf/types/known/emptypb" - + "github.com/go-kratos/kratos/v2/errors" v1 "origadmin/application/admin/api/v1/services/auth" securityv1 "github.com/origadmin/contrib/api/gen/go/security/v1" "github.com/origadmin/contrib/security/credential" @@ -16,7 +15,7 @@ import ( // AuthService is a service for authentication. type AuthService struct { - v1.UnimplementedAuthServer + v1.UnimplementedAuthServiceServer uc *biz.AuthUseCase captcha *captcha.Captcha creator credential.Creator @@ -31,7 +30,7 @@ func NewAuthService(uc *biz.AuthUseCase, captcha *captcha.Captcha, creator crede func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.LoginResponse, error) { // Verify captcha if !s.captcha.Verify(req.GetCaptchaId(), req.GetCaptchaCode(), true) { - return nil, v1.ErrorCaptchaInvalid("invalid captcha") + return nil, errors.New(400, "CAPTCHA_INVALID", "invalid captcha") } userID, err := s.uc.VerifyUser(ctx, req.Username, req.Password) @@ -74,13 +73,13 @@ func (s *AuthService) GetCaptcha(ctx context.Context, req *v1.GetCaptchaRequest) } // Register creates a new user account. -func (s *AuthService) Register(ctx context.Context, req *v1.RegisterRequest) (*emptypb.Empty, error) { - return &emptypb.Empty{}, nil +func (s *AuthService) Register(ctx context.Context, req *v1.RegisterRequest) (*v1.RegisterResponse, error) { + return &v1.RegisterResponse{}, nil } // Logout invalidates the user's session. -func (s *AuthService) Logout(ctx context.Context, req *v1.LogoutRequest) (*emptypb.Empty, error) { - return &emptypb.Empty{}, nil +func (s *AuthService) Logout(ctx context.Context, req *v1.LogoutRequest) (*v1.LogoutResponse, error) { + return &v1.LogoutResponse{}, nil } // RefreshToken provides a new access token. diff --git a/internal/features/auth/service/casbin.go b/internal/features/auth/service/casbin.go index 4163b8c0..78e22153 100644 --- a/internal/features/auth/service/casbin.go +++ b/internal/features/auth/service/casbin.go @@ -8,7 +8,12 @@ import ( // CasbinSourceService is a service for Casbin. type CasbinSourceService struct { - v1.UnimplementedCasbinSourceServiceServer + v1.UnimplementedCasbinServiceServer +} + +func (s *CasbinSourceService) mustEmbedUnimplementedCasbinServiceServer() { + //TODO implement me + panic("implement me") } // NewCasbinSourceService creates a new Casbin source service. @@ -32,6 +37,6 @@ func (s *CasbinSourceService) WatchUpdate(ctx context.Context, req *v1.WatchUpda } // StreamRules returns a stream of rules. -func (s *CasbinSourceService) StreamRules(req *v1.StreamRulesRequest, stream v1.CasbinSourceService_StreamRulesServer) error { +func (s *CasbinSourceService) StreamRules(req *v1.StreamRulesRequest, stream v1.CasbinService_StreamRulesServer) error { return nil } diff --git a/internal/features/auth/service/me.go b/internal/features/auth/service/me.go index 42d153ed..1c69fd5d 100644 --- a/internal/features/auth/service/me.go +++ b/internal/features/auth/service/me.go @@ -3,16 +3,13 @@ package service import ( "context" - "google.golang.org/protobuf/types/known/emptypb" - v1 "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/features/auth/biz" ) // MeService is a service for the currently authenticated user. type MeService struct { - v1.UnimplementedMeServer + v1.UnimplementedMeServiceServer uc *biz.MeUseCase } @@ -22,20 +19,24 @@ func NewMeService(uc *biz.MeUseCase) *MeService { } // GetProfile retrieves the profile of the currently authenticated user. -func (s *MeService) GetProfile(ctx context.Context, req *v1.GetProfileRequest) (*types.User, error) { +func (s *MeService) GetProfile(ctx context.Context, req *v1.GetProfileRequest) (*v1.GetProfileResponse, error) { // TODO: Get userID from context userID := int64(1) // Placeholder - return s.uc.GetProfile(ctx, userID) + user, err := s.uc.GetProfile(ctx, userID) + if err != nil { + return nil, err + } + return &v1.GetProfileResponse{User: user}, nil } // UpdateProfile updates the profile of the currently authenticated user. -func (s *MeService) UpdateProfile(ctx context.Context, req *v1.UpdateProfileRequest) (*emptypb.Empty, error) { - return &emptypb.Empty{}, nil +func (s *MeService) UpdateProfile(ctx context.Context, req *v1.UpdateProfileRequest) (*v1.UpdateProfileResponse, error) { + return &v1.UpdateProfileResponse{}, nil } // UpdatePassword changes the password for the currently authenticated user. -func (s *MeService) UpdatePassword(ctx context.Context, req *v1.UpdatePasswordRequest) (*emptypb.Empty, error) { - return &emptypb.Empty{}, nil +func (s *MeService) UpdatePassword(ctx context.Context, req *v1.UpdatePasswordRequest) (*v1.UpdatePasswordResponse, error) { + return &v1.UpdatePasswordResponse{}, nil } // GetUserResources retrieves the menu/resource list for the current user. diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go index f6a8f3e1..6f4c7f7a 100644 --- a/internal/helpers/providers/providers.go +++ b/internal/helpers/providers/providers.go @@ -2,6 +2,7 @@ package providers import ( "errors" + "fmt" "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" @@ -65,6 +66,9 @@ func ProvideCache(r *runtime.App) (container.CacheProvider, error) { } func ProvideCaptcha(p container.CacheProvider, cfg *confpb.Captcha) (*captcha.Captcha, error) { + if cfg == nil { + return nil, fmt.Errorf("captcha configuration is missing") + } cache, err := p.Cache(cfg.CacheName) if err != nil { return nil, err diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 9ce4f30d..483ec0fd 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -145,8 +145,8 @@ paths: /api/v1/casbin/groupings: get: tags: - - CasbinSourceService - operationId: CasbinSourceService_ListGroupings + - CasbinService + operationId: CasbinService_ListGroupings responses: "200": description: OK @@ -163,8 +163,8 @@ paths: /api/v1/casbin/policies: get: tags: - - CasbinSourceService - operationId: CasbinSourceService_ListPolicies + - CasbinService + operationId: CasbinService_ListPolicies responses: "200": description: OK @@ -181,8 +181,8 @@ paths: /api/v1/casbin/watch: get: tags: - - CasbinSourceService - operationId: CasbinSourceService_WatchUpdate + - CasbinService + operationId: CasbinService_WatchUpdate parameters: - name: last_modified in: query @@ -3589,8 +3589,8 @@ components: tags: - name: AuthService description: Service AuthService provides APIs for the authentication lifecycle. - - name: CasbinSourceService - description: The Casbin source service definition. + - name: CasbinService + description: The Casbin service definition. - name: DatastoreService description: The data service definition. - name: DepartmentService From 723b25e674be5cf20e80d2a1351390c6fbd89e62 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 01:34:34 +0800 Subject: [PATCH 111/158] feat(security): add default captcha config and security/cache configuration files --- internal/helpers/providers/providers.go | 10 ++++++++-- resources/configs/bootstrap.yaml | 6 ++++++ resources/configs/cache.yaml | 6 ++++++ resources/configs/security.yaml | 10 ++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 resources/configs/cache.yaml create mode 100644 resources/configs/security.yaml diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go index 6f4c7f7a..6c421161 100644 --- a/internal/helpers/providers/providers.go +++ b/internal/helpers/providers/providers.go @@ -2,7 +2,6 @@ package providers import ( "errors" - "fmt" "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" @@ -67,7 +66,14 @@ func ProvideCache(r *runtime.App) (container.CacheProvider, error) { func ProvideCaptcha(p container.CacheProvider, cfg *confpb.Captcha) (*captcha.Captcha, error) { if cfg == nil { - return nil, fmt.Errorf("captcha configuration is missing") + cfg = &confpb.Captcha{ + CacheName: "default", + Height: 80, + Width: 240, + Length: 6, + Maxskew: 0.7, + DotCount: 80, + } } cache, err := p.Cache(cfg.CacheName) if err != nil { diff --git a/resources/configs/bootstrap.yaml b/resources/configs/bootstrap.yaml index c8680bee..46afbe58 100644 --- a/resources/configs/bootstrap.yaml +++ b/resources/configs/bootstrap.yaml @@ -12,5 +12,11 @@ sources: - file: path: logger.yaml type: file + - file: + path: cache.yaml + type: file + - file: + path: security.yaml + type: file # Environment variables are loaded last to override file settings. - type: env diff --git a/resources/configs/cache.yaml b/resources/configs/cache.yaml new file mode 100644 index 00000000..13caefb0 --- /dev/null +++ b/resources/configs/cache.yaml @@ -0,0 +1,6 @@ +# cache.yaml +data: + caches: + configs: + - name: default + driver: memory diff --git a/resources/configs/security.yaml b/resources/configs/security.yaml new file mode 100644 index 00000000..5a54bc7d --- /dev/null +++ b/resources/configs/security.yaml @@ -0,0 +1,10 @@ +# security.yaml +security: + authn: + configs: + - type: jwt + jwt: + signing_key: "your-default-secret-key-change-it" # IMPORTANT: Change this in production + signing_method: "HS256" + access_token_ttl: 3600s + refresh_token_ttl: 7200s From ebf61d7e56db3043da194f3a0b2ef89594eb0a18 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 03:00:28 +0800 Subject: [PATCH 112/158] refactor(gateway): simplify gateway service and update service names to remove version suffix --- cmd/auth/main.go | 2 +- cmd/gateway/main.go | 188 ++++------------- cmd/gateway/wire.go | 46 +--- cmd/gateway/wire.work.go | 12 ++ cmd/gateway/wire_gen.go | 34 +++ cmd/system/main.go | 2 +- internal/gateway/proxy.go | 268 ------------------------ resources/api-docs/openapi/openapi.yaml | 27 +++ resources/configs/bootstrap.yaml | 3 + 9 files changed, 129 insertions(+), 453 deletions(-) create mode 100644 cmd/gateway/wire.work.go create mode 100644 cmd/gateway/wire_gen.go diff --git a/cmd/auth/main.go b/cmd/auth/main.go index 13807875..eca26026 100644 --- a/cmd/auth/main.go +++ b/cmd/auth/main.go @@ -20,7 +20,7 @@ import ( var ( // Name is the name of the compiled software. - Name = "origadmin.service.auth.v1" + Name = "origadmin.service.auth" // Version is the version of the compiled software. Version = "v1.0.0" diff --git a/cmd/gateway/main.go b/cmd/gateway/main.go index f7397a7c..80e3287e 100644 --- a/cmd/gateway/main.go +++ b/cmd/gateway/main.go @@ -2,177 +2,75 @@ * Copyright (c) 2024 OrigAdmin. All rights reserved. */ -// Package main is the main entry point for the gateway application. package main import ( - "context" - "fmt" - "log/slog" - "os" - "github.com/go-kratos/kratos/v2" - "github.com/go-kratos/kratos/v2/encoding" - "github.com/go-kratos/kratos/v2/middleware/tracing" + "github.com/go-kratos/kratos/v2/config" + "github.com/go-kratos/kratos/v2/config/file" + "github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/transport" - "github.com/goexts/generic/cmp" - - "github.com/origadmin/runtime" - middlewarev1 "github.com/origadmin/runtime/api/gen/go/config/middleware/v1" - "github.com/origadmin/runtime/bootstrap" - "github.com/origadmin/runtime/config" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/codec/toml" - "origadmin/application/admin/internal/conf" // Updated import - // _ "origadmin/application/admin/contrib/consul/config" // Removed - // _ "origadmin/application/admin/contrib/consul/registry" // Removed - // _ "origadmin/application/admin/contrib/database/drivers" // Removed - _ "origadmin/application/admin/internal/data/entity/ent/runtime" // Updated import -) - -const ( - startRandom = `random` - startWorkDir = `workdir` - startConfig = `config` - startStatic = `static` - startDaemon = `daemon` - startDebug = `debug` + confpb "origadmin/application/admin/internal/conf/pb" ) var ( // Name is the name of the compiled software. - Name = "origadmin.server.v1.admin" - // Version is the Version of the compiled software. - Version = "v1.0.0" - // flags are the bootstrap flags. - flags = bootstrap.New() + Name = "origadmin.gateway.v1" + // Version is the version of the compiled software. + Version string + // flagconf is the config flag. + flagconf string ) func init() { - encoding.RegisterCodec(toml.Codec) - flags.SetServiceInfo(Name, Version) + // You can use flags to get configuration file path + // flag.StringVar(&flagconf, "conf", "../../configs", "config path, eg: -conf config.yaml") } -// ResolvedBootstrap implements config.Resolver for the application's bootstrap configuration. -type ResolvedBootstrap struct { - bootstrap *conf.Bootstrap -} - -// FillServiceInfo populates service information into the bootstrap flags. -func (r *ResolvedBootstrap) FillServiceInfo(flags *bootstrap.Bootstrap) { - core := r.bootstrap.GetServer().GetCore() - name := cmp.Or(flags.ServiceName(), core.GetName()) - version := cmp.Or(flags.Version(), core.GetVersion()) - flags.SetServiceInfo(name, version) -} - -// Discovery returns the discovery configuration. -func (r *ResolvedBootstrap) Discovery() *configv1.Discovery { - log.NewHelper(log.GetLogger()).Infow("msg", "discovery config", "value", r.bootstrap.GetDiscovery()) - return r.bootstrap.GetDiscovery() -} - -// Resolve scans the configuration into the bootstrap structure. -func (r *ResolvedBootstrap) Resolve(cfg config.KConfig) (config.Resolved, error) { - if err := cfg.Scan(r.bootstrap); err != nil { - return nil, err - } - return r, nil -} - -// WithDecode is not implemented for ResolvedBootstrap. -func (r *ResolvedBootstrap) WithDecode(name string, v any, decode func([]byte, any) error) error { - if decode == nil { - return fmt.Errorf("decode function is nil") - } - return nil -} - -// Value is not implemented for ResolvedBootstrap. -func (r *ResolvedBootstrap) Value(name string) (any, error) { - return nil, fmt.Errorf("unknown config name: %s", name) +func newApp(logger log.Logger, servers []transport.Server) *kratos.App { + return kratos.New( + kratos.Name(Name), + kratos.Version(Version), + kratos.Metadata(map[string]string{}), + kratos.Logger(logger), + kratos.Server( + servers..., + ), + ) } -// Middleware returns the middleware configuration. -func (r *ResolvedBootstrap) Middleware() *middlewarev1.Middleware { - return r.bootstrap.GetMiddleware() -} +func main() { + // use -conf to get config file path + // flag.Parse() -// Services returns the service configurations. -func (r *ResolvedBootstrap) Services() []*configv1.Service { - return r.bootstrap.GetServer().GetServices() -} + // for this example, we use a hardcoded config path + flagconf = "resources/configs" -// Logger returns the logger configuration. -func (r *ResolvedBootstrap) Logger() *configv1.Logger { - return r.bootstrap.GetLogger() -} + c := config.New( + config.WithSource( + file.NewSource(flagconf), + ), + ) + defer c.Close() -func main() { - // Simplified flag parsing for demonstration, replace with actual flag parsing if needed - // For now, hardcode debug mode for testing, or use os.Args to parse - debug := false // Default to false - for _, arg := range os.Args { - if arg == "--debug" || arg == "-d" { - debug = true - break - } + if err := c.Load(); err != nil { + panic(err) } - if debug { - flags.SetEnv("debug") - flags.SetConfigPath("resources/configs/bootstrap.toml") // Updated path - flags.SetWorkDir(".") - slog.SetLogLoggerLevel(slog.LevelDebug) + var bc confpb.Bootstrap + if err := c.Scan(&bc); err != nil { + panic(err) } - ll := log.NewHelper(log.GetLogger()) - ll.Infof("bootstrap flags: %+v", flags) - - // Replicate loader.Bootstrap logic - rb := &ResolvedBootstrap{ - bootstrap: &conf.Bootstrap{}, // Initialize with new conf.Bootstrap - } - r, err := runtime.Load(flags, runtime.WithResolver(rb), runtime.WithContext(context.Background())) // Use context.Background() as no cobra.Command context + app, cleanup, err := wireApp(&bc, log.DefaultLogger) if err != nil { - ll.Errorf("failed to load runtime: %v", err) - os.Exit(1) + panic(err) } - rb.FillServiceInfo(flags) - r = r.WithLoggerAttrs( - "ts", log.DefaultTimestamp, - "caller", log.DefaultCaller, - "service.id", flags.ServiceID(), - "service.name", flags.ServiceName(), - "service.version", flags.Version(), - "trace.id", tracing.TraceID(), - "span.id", tracing.SpanID(), - ) - app, clean, err := buildInjectors(r, rb.bootstrap) // Use rb.bootstrap - if err != nil { - ll.Errorf("failed to build injectors: %v", err) - os.Exit(1) - } - defer clean() - if err := app.Run(); err != nil { - ll.Errorf("application run failed: %v", err) - os.Exit(1) - } -} - -func NewApp(r runtime.Runtime, servers []transport.Server) *kratos.App { - r = r.Client() - return r.CreateApp(servers...) -} + defer cleanup() -func buildInjectors(r runtime.Runtime, bootstrap *conf.Bootstrap) (*kratos.App, func(), error) { // Updated type - ll := log.NewHelper(r.Logger()) - if bootstrap.GetMode() == "cluster" { - ll.Infof("start cluster mode") - return buildRemoteInjectors(r, bootstrap) - } else { - ll.Infof("start local mode") - return buildLocalInjectors(r, bootstrap) + // start and wait for stop signal + if err := app.Run(); err != nil { + panic(err) } } diff --git a/cmd/gateway/wire.go b/cmd/gateway/wire.go index 95a0a4c9..060c90ea 100644 --- a/cmd/gateway/wire.go +++ b/cmd/gateway/wire.go @@ -10,46 +10,16 @@ package main import ( "github.com/go-kratos/kratos/v2" + "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" - "github.com/origadmin/runtime" - - "origadmin/application/admin/internal/configs" - "origadmin/application/admin/internal/loader" - authbiz "origadmin/application/admin/internal/features/auth/biz" // Corrected import path - authdal "origadmin/application/admin/internal/features/auth/dal" // Corrected import path - authservice "origadmin/application/admin/internal/features/auth/service" // Corrected import path - "origadmin/application/admin/internal/features/gateway" // Corrected import path - systembiz "origadmin/application/admin/internal/features/system/biz" // Corrected import path - systemdal "origadmin/application/admin/internal/features/system/dal" // Corrected import path - systemservice "origadmin/application/admin/internal/features/system/service" // Corrected import path - - "origadmin/application/admin/internal/data" + confpb "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/gateway/client" + "origadmin/application/admin/internal/gateway/server" + "origadmin/application/admin/internal/gateway/service" ) -// buildInjectors init kratos application. -func buildLocalInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { - panic(wire.Build( - loader.ProviderSet, - //agent.ProviderSet, - data.ProviderSet, - systemdal.ProviderSet, - systembiz.ProviderSet, - systemservice.LocalProviderSet, - //systemserver.ProviderSet, - authdal.ProviderSet, - authbiz.ProviderSet, - authservice.LocalProviderSet, - gateway.ProviderSet, - NewApp)) -} - -func buildRemoteInjectors(r runtime.Runtime, bootstrap *configs.Bootstrap) (*kratos.App, func(), error) { - panic(wire.Build( - loader.ProviderSet, - systemservice.RemoteProviderSet, - authservice.RemoteProviderSet, - gateway.ProviderSet, - NewApp, - )) +// wireApp init kratos application. +func wireApp(*confpb.Bootstrap, log.Logger) (*kratos.App, func(), error) { + panic(wire.Build(server.ProviderSet, client.ProviderSet, service.ProviderSet, newApp)) } diff --git a/cmd/gateway/wire.work.go b/cmd/gateway/wire.work.go new file mode 100644 index 00000000..059f2257 --- /dev/null +++ b/cmd/gateway/wire.work.go @@ -0,0 +1,12 @@ +//go:build !wireinject && GOWORK +// +build !wireinject,GOWORK + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// The build tag makes sure the stub is not built in the final build. +//go:generate go run github.com/google/wire/cmd/wire + +// Package main is a main package +package main diff --git a/cmd/gateway/wire_gen.go b/cmd/gateway/wire_gen.go new file mode 100644 index 00000000..e51cf274 --- /dev/null +++ b/cmd/gateway/wire_gen.go @@ -0,0 +1,34 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate go run -mod=mod github.com/google/wire/cmd/wire +//go:build !wireinject +// +build !wireinject + +package main + +import ( + "github.com/go-kratos/kratos/v2" + "github.com/go-kratos/kratos/v2/log" + "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/gateway/client" + "origadmin/application/admin/internal/gateway/server" + "origadmin/application/admin/internal/gateway/service" +) + +// Injectors from wire.go: + +// wireApp init kratos application. +func wireApp(bootstrap *confpb.Bootstrap, logger log.Logger) (*kratos.App, func(), error) { + authServiceClient, err := client.NewAuthClient(bootstrap) + if err != nil { + return nil, nil, err + } + gatewayService := service.NewGatewayService(authServiceClient) + v, err := server.NewServers(bootstrap, gatewayService, logger) + if err != nil { + return nil, nil, err + } + app := newApp(logger, v) + return app, func() { + }, nil +} diff --git a/cmd/system/main.go b/cmd/system/main.go index f28b20c5..b84ead13 100644 --- a/cmd/system/main.go +++ b/cmd/system/main.go @@ -24,7 +24,7 @@ import ( var ( // Name is the name of the compiled software. - Name = "origadmin.service.system.v1" + Name = "origadmin.service.system" // Version is the version of the compiled software. Version = "v1.0.0" diff --git a/internal/gateway/proxy.go b/internal/gateway/proxy.go index fc72a6c6..e69de29b 100644 --- a/internal/gateway/proxy.go +++ b/internal/gateway/proxy.go @@ -1,268 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package gateway implements the functions, types, and interfaces for the module. -package gateway - -import ( - "strings" - - "github.com/go-kratos/kratos/v2/metadata" - "github.com/go-kratos/kratos/v2/middleware/recovery" - "github.com/go-kratos/kratos/v2/middleware/selector" - "github.com/go-kratos/kratos/v2/transport" - "github.com/go-kratos/kratos/v2/transport/http" - "github.com/google/wire" - "github.com/gorilla/handlers" - "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/interfaces/security" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/service" - servicegrpc "github.com/origadmin/runtime/service/grpc" - servicehttp "github.com/origadmin/runtime/service/http" - - "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/contrib/security/authz/casbin" - "origadmin/application/admin/helpers/resp" - "origadmin/application/admin/helpers/securityx" - "origadmin/application/admin/internal/configs" -) - -var ( - ProviderSet = wire.NewSet( - NewProxyOptions, - NewProxyServer, - NewProxyGRPCClients, - NewProxyHTTPClients, - ) -) - -type ProxyOptions struct { - Authenticator security.Authenticator - Authorizer security.Authorizer - Registrars []service.ServerRegistrar -} - -func NewProxyOptions(r runtime.Runtime, bootstrap *configs.Bootstrap, - source casbin.RuleSource, registrars []service.ServerRegistrar) (*ProxyOptions, error) { - authenticator, err := securityx.NewAuthenticator(bootstrap) - if err != nil { - return nil, err - } - opts := []casbin.AuthorizerOption{ - casbin.WithSource(source), - } - - authorizer, err := securityx.NewAuthorizer(bootstrap, opts...) - if err != nil { - return nil, err - } - return &ProxyOptions{ - Authenticator: authenticator, - Authorizer: authorizer, - Registrars: registrars, - }, nil -} - -// NewProxyServer creates a new proxy server. -func NewProxyServer( - r runtime.Runtime, - bootstrap *configs.Bootstrap, - opts *ProxyOptions) []transport.Server { - paths := bootstrap.GetSecurity().GetSecurity().GetPublicPaths() - paths = append(DefaultPaths(), paths...) - ms := []middleware.KMiddleware{ - recovery.Recovery(), - } - - bridge := securityx.DefaultBridge() - bridge.Authenticator = opts.Authenticator - bridge.Authorizer = opts.Authorizer - bridge.IsRoot = func(ctx context.Context, claims security.Claims) bool { - return claims.GetSubject() == "root" || claims.GetSubject() == "admin" - } - serv := selector.Server(bridge.Middleware()).Match(func(ctx context.Context, operation string) bool { - for _, p := range paths { - if strings.HasPrefix(operation, p) { - log.Debugf("Operation '%s' matches public path '%s', returning true", operation, p) - return false - } - } - log.Infof("Operation '%s' no matches public path '%s'", operation, "*") - return true - }) - ms = append(ms, serv.Build(), CallLoggerMiddleware()) - var servers []transport.Server - services := bootstrap.GetEntry().GetServices() - for i := range services { - if services[i].GetType() != "http" { - continue - } - srv, err := r.Builder().NewHTTPServer(services[i], - servicehttp.WithServerOptions( - http.PathPrefix("/api/v1"), - http.ErrorEncoder(resp.ResponseErrorEncoder), - http.Filter(BuildProxyCors(bootstrap.GetEntry().GetCors()))), - servicehttp.WithMiddlewares(ms...), - servicehttp.WithPrefix(runtime.DefaultEnvPrefix), - ) - if err != nil { - panic(err) - } - for _, registrar := range opts.Registrars { - registrar.Register(r.Context(), srv) - } - srv.WalkRoute(func(info http.RouteInfo) error { - log.Infof("Registered HTTP route: %s %s", info.Method, info.Path) - return nil - }) - servers = append(servers, srv) - } - return servers -} - -func BuildProxyCors(cors *configv1.Cors) http.FilterFunc { - if cors == nil { - return nil - } - options := []handlers.CORSOption{ - handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), - handlers.AllowedMethods([]string{"GET", "POST", "PUT", "HEAD", "DELETE", "OPTIONS"}), - handlers.AllowedOrigins([]string{"*"}), - } - if cors.GetAllowCredentials() { - options = append(options, handlers.AllowCredentials()) - } - if cors.GetMaxAge() > 0 { - options = append(options, handlers.MaxAge(int(cors.GetMaxAge()))) - } - if len(cors.GetAllowHeaders()) > 0 { - options = append(options, handlers.AllowedHeaders(cors.GetAllowHeaders())) - } - if len(cors.GetAllowMethods()) > 0 { - options = append(options, handlers.AllowedMethods(cors.GetAllowMethods())) - } - - if len(cors.GetAllowOrigins()) > 0 { - options = append(options, handlers.AllowedOrigins(cors.GetAllowOrigins())) - } - return handlers.CORS(options...) -} - -func DefaultPaths() []string { - return []string{ - auth.OperationLoginServiceCaptchaId, - auth.OperationLoginServiceCaptcha, - auth.OperationLoginServiceCaptchaImage, - auth.OperationLoginServiceCaptchaAudio, - auth.OperationLoginServiceLogin, - auth.OperationLoginServiceRegister, - auth.OperationLoginServiceTokenRefresh, - } -} - -func CallLoggerMiddleware() middleware.KMiddleware { - return func(handler middleware.KHandler) middleware.KHandler { - return func(ctx context.Context, req interface{}) (reply interface{}, err error) { - log.Infof("CallLoggerMiddleware: %+v", ctx) - tr, ok := transport.FromServerContext(ctx) - log.Infof("Caller Server: %+v, ok: %+v", tr, ok) - tr, ok = transport.FromClientContext(ctx) - log.Infof("Caller Client: %+v, ok: %+v", tr, ok) - return handler(ctx, req) - } - } -} - -func BridgeMiddleware() middleware.KMiddleware { - return func(handler middleware.KHandler) middleware.KHandler { - return func(ctx context.Context, req interface{}) (reply interface{}, err error) { - meta, _ := metadata.FromClientContext(ctx) - log.Infof("Caller Client Metadata: %+v", meta) - smd, ok := metadata.FromServerContext(ctx) - if !ok { - smd = metadata.New(nil) - } - log.Infof("Caller Server Metadata: %+v", smd) - for k, v := range meta { - smd[k] = v - } - ctx = metadata.NewServerContext(ctx, smd) - return handler(ctx, req) - } - } -} - -func NewProxyGRPCClients(r runtime.Runtime, bootstrap *configs.Bootstrap) map[string]*service.GRPCClient { - ll := log.NewHelper(r.WithLogger("module", "proxy")) - ll.Infof("NewProxyGRPCClients bootstrap: %+v", bootstrap) - clients := bootstrap.GetClients() - clientServices := make(map[string]*service.GRPCClient, len(clients)) - for i := range clients { - services := clients[i].GetServices() - if len(services) == 0 { - continue - } - ll.Infof("NewProxyGRPCClients: %+v", clients[i].GetCore().GetName()) - var options []service.GRPCOption - discovery, err := r.Builder().NewDiscovery(clients[i].GetCore().GetDiscovery()) - if err == nil { - options = append(options, servicegrpc.WithDiscovery(clients[i].GetCore().GetDiscovery().GetServiceName(), - discovery)) - } - for idx := range services { - if services[idx].GetType() == "grpc" { - ll.Infof("NewProxyGRPCClient Middleware: %+v", clients[i].GetMiddleware()) - ms := r.Builder().NewMiddlewaresClient(clients[i].GetMiddleware()) - if len(ms) > 0 { - options = append(options, servicegrpc.WithMiddlewares(ms...)) - } - client, err := r.Builder().NewGRPCClient(r.Context(), services[idx], options...) - if err != nil { - ll.Warnf("NewGRPCClient failed: %v", err) - continue - } - ll.Infof("NewProxyGRPCClients: %+v", clients[i].GetCore().GetName()) - clientServices[clients[i].GetCore().GetName()] = client - } - } - } - return clientServices -} - -func NewProxyHTTPClients(r runtime.Runtime, bootstrap *configs.Bootstrap) map[string]*service.HTTPClient { - ll := log.NewHelper(r.WithLogger("module", "proxy")) - clients := bootstrap.GetClients() - clientServices := make(map[string]*service.HTTPClient, len(clients)) - for i := range clients { - services := clients[i].GetServices() - if len(services) == 0 { - continue - } - var options []service.HTTPOption - discovery, err := r.Builder().NewDiscovery(clients[i].GetCore().GetDiscovery()) - if err == nil { - options = append(options, servicehttp.WithDiscovery(clients[i].GetCore().GetDiscovery().GetServiceName(), discovery)) - } - for idx := range services { - if services[idx].GetType() == "http" { - ll.Infof("NewProxyHTTPClient Middleware: %+v", clients[i].GetMiddleware()) - ms := r.Builder().NewMiddlewaresClient(clients[i].GetMiddleware()) - if len(ms) > 0 { - options = append(options, servicehttp.WithMiddlewares(ms...)) - } - client, err := r.Builder().NewHTTPClient(r.Context(), services[idx], options...) - if err != nil { - ll.Warnf("NewHTTPClient failed: %v", err) - continue - } - clientServices[clients[i].GetCore().GetName()] = client - } - } - } - return clientServices -} diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 483ec0fd..79005b93 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -201,6 +201,31 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' + /api/v1/login: + post: + tags: + - GatewayService + description: Login authenticates a user. + operationId: GatewayService_Login + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.LoginRequest' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.LoginResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' /api/v1/me/password: put: tags: @@ -3595,6 +3620,8 @@ tags: description: The data service definition. - name: DepartmentService description: The login service definition. + - name: GatewayService + description: "GatewayService is the public-facing API gateway.\r\n It proxies requests to backend services." - name: MeService description: Service MeService provides APIs for the currently authenticated user to manage their own profile and data. - name: PermissionService diff --git a/resources/configs/bootstrap.yaml b/resources/configs/bootstrap.yaml index 46afbe58..e49f46ca 100644 --- a/resources/configs/bootstrap.yaml +++ b/resources/configs/bootstrap.yaml @@ -18,5 +18,8 @@ sources: - file: path: security.yaml type: file + - file: + path: clients.yaml + type: file # Environment variables are loaded last to override file settings. - type: env From 242f5a5f4999d6085f90c2e294b13db67fe68ff1 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 03:20:24 +0800 Subject: [PATCH 113/158] refactor(auth): simplify API paths and update go_package paths for auth services --- api/v1/proto/auth/auth.proto | 12 +- api/v1/proto/auth/casbin.proto | 8 +- api/v1/proto/auth/me.proto | 12 +- api/v1/proto/gateway/gateway.proto | 71 +++ api/v1/services/auth/auth.pb.go | 19 +- api/v1/services/auth/auth.pb.gw.go | 30 +- api/v1/services/auth/auth_bridge.pb.go | 10 +- api/v1/services/auth/auth_http.pb.go | 20 +- api/v1/services/auth/casbin.pb.go | 14 +- api/v1/services/auth/casbin.pb.gw.go | 18 +- api/v1/services/auth/casbin_bridge.pb.go | 6 +- api/v1/services/auth/casbin_http.pb.go | 12 +- api/v1/services/auth/me.pb.go | 16 +- api/v1/services/auth/me.pb.gw.go | 30 +- api/v1/services/auth/me_bridge.pb.go | 10 +- api/v1/services/auth/me_http.pb.go | 20 +- cmd/gateway/main.go | 4 +- cmd/gateway/wire.go | 2 +- internal/gateway/client/client.go | 77 ++++ internal/gateway/proxy.go | 0 internal/gateway/server/server.go | 57 +++ internal/gateway/service/service.go | 83 ++++ resources/api-docs/openapi/openapi.yaml | 545 ++++++++++++++++++----- 23 files changed, 854 insertions(+), 222 deletions(-) create mode 100644 api/v1/proto/gateway/gateway.proto create mode 100644 internal/gateway/client/client.go delete mode 100644 internal/gateway/proxy.go create mode 100644 internal/gateway/server/server.go create mode 100644 internal/gateway/service/service.go diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index 36f1560d..e18d655d 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -4,7 +4,7 @@ package api.v1.services.auth; import "google/api/annotations.proto"; -option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; +option go_package = "origadmin/application/admin/services/auth;auth"; option java_multiple_files = true; option java_package = "com.origadmin.api.v1.services.auth"; option java_outer_classname = "APIServiceAuthProto"; @@ -16,7 +16,7 @@ service AuthService { // Login authenticates a user and returns a token pair. rpc Login(LoginRequest) returns (LoginResponse) { option (google.api.http) = { - post: "/api/v1/auth/login" + post: "/auth/login" body: "*" }; } @@ -24,7 +24,7 @@ service AuthService { // Register creates a new user account. rpc Register(RegisterRequest) returns (RegisterResponse) { option (google.api.http) = { - post: "/api/v1/auth/register" + post: "/auth/register" body: "*" }; } @@ -32,7 +32,7 @@ service AuthService { // Logout invalidates the user's session. rpc Logout(LogoutRequest) returns (LogoutResponse) { option (google.api.http) = { - post: "/api/v1/auth/logout" + post: "/auth/logout" body: "*" }; } @@ -40,7 +40,7 @@ service AuthService { // RefreshToken provides a new access token. rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse) { option (google.api.http) = { - post: "/api/v1/auth/token" + post: "/auth/token" body: "*" }; } @@ -50,7 +50,7 @@ service AuthService { // GetCaptcha generates a new captcha. rpc GetCaptcha(GetCaptchaRequest) returns (GetCaptchaResponse) { option (google.api.http) = { - get: "/api/v1/captcha" + get: "/captcha" }; } diff --git a/api/v1/proto/auth/casbin.proto b/api/v1/proto/auth/casbin.proto index ce9d28a5..a10feda4 100644 --- a/api/v1/proto/auth/casbin.proto +++ b/api/v1/proto/auth/casbin.proto @@ -4,7 +4,7 @@ package api.v1.services.auth; import "google/api/annotations.proto"; -option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; +option go_package = "origadmin/application/admin/services/auth;auth"; option java_multiple_files = true; option java_outer_classname = "APIServiceAuthCasbinProto"; option java_package = "com.origadmin.api.v1.services.auth"; @@ -14,19 +14,19 @@ option objc_class_prefix = "APIServiceAuthCasbin"; service CasbinService { rpc ListPolicies(ListPoliciesRequest) returns (ListPoliciesResponse) { option (google.api.http) = { - get: "/api/v1/casbin/policies" + get: "/casbin/policies" response_body: "*" }; } rpc ListGroupings(ListGroupingsRequest) returns (ListGroupingsResponse) { option (google.api.http) = { - get: "/api/v1/casbin/groupings" + get: "/casbin/groupings" response_body: "*" }; } rpc WatchUpdate(WatchUpdateRequest) returns (WatchUpdateResponse) { option (google.api.http) = { - get: "/api/v1/casbin/watch" + get: "/casbin/watch" response_body: "*" }; } diff --git a/api/v1/proto/auth/me.proto b/api/v1/proto/auth/me.proto index dc4dff9b..10d36574 100644 --- a/api/v1/proto/auth/me.proto +++ b/api/v1/proto/auth/me.proto @@ -5,7 +5,7 @@ package api.v1.services.auth; import "google/api/annotations.proto"; import "types/system.proto"; -option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; +option go_package = "origadmin/application/admin/services/auth;auth"; option java_multiple_files = true; option java_package = "com.origadmin.api.v1.services.auth"; option java_outer_classname = "APIServiceMeProto"; @@ -15,14 +15,14 @@ service MeService { // GetProfile retrieves the profile of the currently authenticated user. rpc GetProfile(GetProfileRequest) returns (GetProfileResponse) { option (google.api.http) = { - get: "/api/v1/me/profile" + get: "/me/profile" }; } // UpdateProfile updates the profile of the currently authenticated user. rpc UpdateProfile(UpdateProfileRequest) returns (UpdateProfileResponse) { option (google.api.http) = { - put: "/api/v1/me/profile" + put: "/me/profile" body: "*" }; } @@ -30,7 +30,7 @@ service MeService { // UpdatePassword changes the password for the currently authenticated user. rpc UpdatePassword(UpdatePasswordRequest) returns (UpdatePasswordResponse) { option (google.api.http) = { - put: "/api/v1/me/password" + put: "/me/password" body: "*" }; } @@ -38,14 +38,14 @@ service MeService { // GetUserResources retrieves the menu/resource list for the current user. rpc GetUserResources(GetUserResourcesRequest) returns (GetUserResourcesResponse) { option (google.api.http) = { - get: "/api/v1/me/resources" + get: "/me/resources" }; } // GetUserRoles retrieves the role list for the current user. rpc GetUserRoles(GetUserRolesRequest) returns (GetUserRolesResponse) { option (google.api.http) = { - get: "/api/v1/me/roles" + get: "/me/roles" }; } } diff --git a/api/v1/proto/gateway/gateway.proto b/api/v1/proto/gateway/gateway.proto new file mode 100644 index 00000000..12f9cd1a --- /dev/null +++ b/api/v1/proto/gateway/gateway.proto @@ -0,0 +1,71 @@ +syntax = "proto3"; + +package api.v1.services.gateway; + +import "google/api/annotations.proto"; +import "auth/auth.proto"; +import "auth/me.proto"; +import "system/user.proto"; +import "system/role.proto"; +import "system/resource.proto"; +import "types/system.proto"; + +option go_package = "origadmin/application/admin/api/v1/services/gateway;gateway"; + +// GatewayService is the public-facing API gateway. +// It proxies requests to backend services. +service GatewayService { + // --- Auth Service --- + rpc Login (auth.LoginRequest) returns (auth.LoginResponse) { + option (google.api.http) = { + post: "/api/v1/login", + body: "*" + }; + } + + rpc GetCaptcha (auth.GetCaptchaRequest) returns (auth.GetCaptchaResponse) { + option (google.api.http) = { + get: "/api/v1/captcha" + }; + } + + // --- Me Service --- + rpc GetProfile(auth.GetProfileRequest) returns (auth.GetProfileResponse) { + option (google.api.http) = { + get: "/api/v1/me/profile" + }; + } + + // --- System User Service --- + rpc ListUsers(system.ListUsersRequest) returns (system.ListUsersResponse) { + option (google.api.http) = { + get: "/api/v1/users" + }; + } + + rpc GetUser(system.GetUserRequest) returns (types.User) { + option (google.api.http) = { + get: "/api/v1/users/{id}" + }; + } + + rpc CreateUser(system.CreateUserRequest) returns (types.User) { + option (google.api.http) = { + post: "/api/v1/users", + body: "*" + }; + } + + rpc UpdateUser(system.UpdateUserRequest) returns (types.User) { + option (google.api.http) = { + put: "/api/v1/users/{user.id}", + body: "user" + }; + } + + rpc DeleteUser(system.DeleteUserRequest) returns (system.DeleteUserResponse) { + option (google.api.http) = { + delete: "/api/v1/users/{id}" + }; + } +} diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index ff86e900..02594323 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -727,16 +727,17 @@ const file_auth_auth_proto_rawDesc = "" + "\n" + "authorized\x18\x01 \x01(\bR\n" + "authorized\x12\x17\n" + - "\auser_id\x18\x02 \x01(\tR\x06userId2\xd8\x05\n" + - "\vAuthService\x12o\n" + - "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v1/auth/login\x12{\n" + - "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a&.api.v1.services.auth.RegisterResponse\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/v1/auth/register\x12s\n" + - "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/api/v1/auth/logout\x12\x84\x01\n" + - "\fRefreshToken\x12).api.v1.services.auth.RefreshTokenRequest\x1a*.api.v1.services.auth.RefreshTokenResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v1/auth/token\x12x\n" + + "\auser_id\x18\x02 \x01(\tR\x06userId2\xb4\x05\n" + + "\vAuthService\x12h\n" + + "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/auth/login\x12t\n" + + "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a&.api.v1.services.auth.RegisterResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/auth/register\x12l\n" + + "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x01*\"\f/auth/logout\x12}\n" + + "\fRefreshToken\x12).api.v1.services.auth.RefreshTokenRequest\x1a*.api.v1.services.auth.RefreshTokenResponse\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/auth/token\x12q\n" + "\n" + - "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/api/v1/captcha\x12e\n" + - "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponseB\xd0\x01\n" + - "\x18com.api.v1.services.authB\tAuthProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"\x10\x82\xd3\xe4\x93\x02\n" + + "\x12\b/captcha\x12e\n" + + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponseB\xc9\x01\n" + + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z.origadmin/application/admin/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_auth_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/auth.pb.gw.go b/api/v1/services/auth/auth.pb.gw.go index c5716b4e..5d830815 100644 --- a/api/v1/services/auth/auth.pb.gw.go +++ b/api/v1/services/auth/auth.pb.gw.go @@ -176,7 +176,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Login", runtime.WithHTTPPathPattern("/api/v1/auth/login")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Login", runtime.WithHTTPPathPattern("/auth/login")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -196,7 +196,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Register", runtime.WithHTTPPathPattern("/api/v1/auth/register")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Register", runtime.WithHTTPPathPattern("/auth/register")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -216,7 +216,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Logout", runtime.WithHTTPPathPattern("/api/v1/auth/logout")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Logout", runtime.WithHTTPPathPattern("/auth/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -236,7 +236,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/api/v1/auth/token")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/auth/token")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -256,7 +256,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/GetCaptcha", runtime.WithHTTPPathPattern("/captcha")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -314,7 +314,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Login", runtime.WithHTTPPathPattern("/api/v1/auth/login")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Login", runtime.WithHTTPPathPattern("/auth/login")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -331,7 +331,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Register", runtime.WithHTTPPathPattern("/api/v1/auth/register")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Register", runtime.WithHTTPPathPattern("/auth/register")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -348,7 +348,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Logout", runtime.WithHTTPPathPattern("/api/v1/auth/logout")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/Logout", runtime.WithHTTPPathPattern("/auth/logout")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -365,7 +365,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/api/v1/auth/token")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/auth/token")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -382,7 +382,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/GetCaptcha", runtime.WithHTTPPathPattern("/captcha")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -399,11 +399,11 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux } var ( - pattern_AuthService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "login"}, "")) - pattern_AuthService_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "register"}, "")) - pattern_AuthService_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "logout"}, "")) - pattern_AuthService_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "token"}, "")) - pattern_AuthService_GetCaptcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "captcha"}, "")) + pattern_AuthService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "login"}, "")) + pattern_AuthService_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "register"}, "")) + pattern_AuthService_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "logout"}, "")) + pattern_AuthService_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "token"}, "")) + pattern_AuthService_GetCaptcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"captcha"}, "")) ) var ( diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index 918de030..de9bf285 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -91,11 +91,11 @@ type AuthServiceAuthenticateHooker interface { func RegisterAuthServiceBridgeServer(s *http.Server, srv AuthServiceHookedBridger) { r := s.Route("/") - r.POST("/api/v1/auth/login", _AuthService_Login0_Bridge_Handler(srv)) - r.POST("/api/v1/auth/register", _AuthService_Register0_Bridge_Handler(srv)) - r.POST("/api/v1/auth/logout", _AuthService_Logout0_Bridge_Handler(srv)) - r.POST("/api/v1/auth/token", _AuthService_RefreshToken0_Bridge_Handler(srv)) - r.GET("/api/v1/captcha", _AuthService_GetCaptcha0_Bridge_Handler(srv)) + r.POST("/auth/login", _AuthService_Login0_Bridge_Handler(srv)) + r.POST("/auth/register", _AuthService_Register0_Bridge_Handler(srv)) + r.POST("/auth/logout", _AuthService_Logout0_Bridge_Handler(srv)) + r.POST("/auth/token", _AuthService_RefreshToken0_Bridge_Handler(srv)) + r.GET("/captcha", _AuthService_GetCaptcha0_Bridge_Handler(srv)) } func _AuthService_Login0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go index 2e61a5f3..a1d6f698 100644 --- a/api/v1/services/auth/auth_http.pb.go +++ b/api/v1/services/auth/auth_http.pb.go @@ -40,11 +40,11 @@ type AuthServiceHTTPServer interface { func RegisterAuthServiceHTTPServer(s *http.Server, srv AuthServiceHTTPServer) { r := s.Route("/") - r.POST("/api/v1/auth/login", _AuthService_Login0_HTTP_Handler(srv)) - r.POST("/api/v1/auth/register", _AuthService_Register0_HTTP_Handler(srv)) - r.POST("/api/v1/auth/logout", _AuthService_Logout0_HTTP_Handler(srv)) - r.POST("/api/v1/auth/token", _AuthService_RefreshToken0_HTTP_Handler(srv)) - r.GET("/api/v1/captcha", _AuthService_GetCaptcha0_HTTP_Handler(srv)) + r.POST("/auth/login", _AuthService_Login0_HTTP_Handler(srv)) + r.POST("/auth/register", _AuthService_Register0_HTTP_Handler(srv)) + r.POST("/auth/logout", _AuthService_Logout0_HTTP_Handler(srv)) + r.POST("/auth/token", _AuthService_RefreshToken0_HTTP_Handler(srv)) + r.GET("/captcha", _AuthService_GetCaptcha0_HTTP_Handler(srv)) } func _AuthService_Login0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { @@ -178,7 +178,7 @@ func NewAuthServiceHTTPClient(client *http.Client) AuthServiceHTTPClient { // GetCaptcha GetCaptcha generates a new captcha. func (c *AuthServiceHTTPClientImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest, opts ...http.CallOption) (*GetCaptchaResponse, error) { var out GetCaptchaResponse - pattern := "/api/v1/captcha" + pattern := "/captcha" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationAuthServiceGetCaptcha)) opts = append(opts, http.PathTemplate(pattern)) @@ -192,7 +192,7 @@ func (c *AuthServiceHTTPClientImpl) GetCaptcha(ctx context.Context, in *GetCaptc // Login Login authenticates a user and returns a token pair. func (c *AuthServiceHTTPClientImpl) Login(ctx context.Context, in *LoginRequest, opts ...http.CallOption) (*LoginResponse, error) { var out LoginResponse - pattern := "/api/v1/auth/login" + pattern := "/auth/login" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationAuthServiceLogin)) opts = append(opts, http.PathTemplate(pattern)) @@ -206,7 +206,7 @@ func (c *AuthServiceHTTPClientImpl) Login(ctx context.Context, in *LoginRequest, // Logout Logout invalidates the user's session. func (c *AuthServiceHTTPClientImpl) Logout(ctx context.Context, in *LogoutRequest, opts ...http.CallOption) (*LogoutResponse, error) { var out LogoutResponse - pattern := "/api/v1/auth/logout" + pattern := "/auth/logout" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationAuthServiceLogout)) opts = append(opts, http.PathTemplate(pattern)) @@ -220,7 +220,7 @@ func (c *AuthServiceHTTPClientImpl) Logout(ctx context.Context, in *LogoutReques // RefreshToken RefreshToken provides a new access token. func (c *AuthServiceHTTPClientImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...http.CallOption) (*RefreshTokenResponse, error) { var out RefreshTokenResponse - pattern := "/api/v1/auth/token" + pattern := "/auth/token" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationAuthServiceRefreshToken)) opts = append(opts, http.PathTemplate(pattern)) @@ -234,7 +234,7 @@ func (c *AuthServiceHTTPClientImpl) RefreshToken(ctx context.Context, in *Refres // Register Register creates a new user account. func (c *AuthServiceHTTPClientImpl) Register(ctx context.Context, in *RegisterRequest, opts ...http.CallOption) (*RegisterResponse, error) { var out RegisterResponse - pattern := "/api/v1/auth/register" + pattern := "/auth/register" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationAuthServiceRegister)) opts = append(opts, http.PathTemplate(pattern)) diff --git a/api/v1/services/auth/casbin.pb.go b/api/v1/services/auth/casbin.pb.go index bcddfade..3f03005e 100644 --- a/api/v1/services/auth/casbin.pb.go +++ b/api/v1/services/auth/casbin.pb.go @@ -536,13 +536,13 @@ const file_auth_casbin_proto_rawDesc = "" + "\x12WatchUpdateRequest\x12$\n" + "\rlast_modified\x18\x01 \x01(\x03R\rlast_modified\";\n" + "\x13WatchUpdateResponse\x12$\n" + - "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\x99\x04\n" + - "\rCasbinService\x12\x89\x01\n" + - "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\"\x82\xd3\xe4\x93\x02\x1cb\x01*\x12\x17/api/v1/casbin/policies\x12\x8d\x01\n" + - "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"#\x82\xd3\xe4\x93\x02\x1db\x01*\x12\x18/api/v1/casbin/groupings\x12\x83\x01\n" + - "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x1f\x82\xd3\xe4\x93\x02\x19b\x01*\x12\x14/api/v1/casbin/watch\x12f\n" + - "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xd2\x01\n" + - "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\x83\x04\n" + + "\rCasbinService\x12\x82\x01\n" + + "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x86\x01\n" + + "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12|\n" + + "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12f\n" + + "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xcb\x01\n" + + "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z.origadmin/application/admin/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_casbin_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/casbin.pb.gw.go b/api/v1/services/auth/casbin.pb.gw.go index 35eb6164..d60c8c11 100644 --- a/api/v1/services/auth/casbin.pb.gw.go +++ b/api/v1/services/auth/casbin.pb.gw.go @@ -118,7 +118,7 @@ func RegisterCasbinServiceHandlerServer(ctx context.Context, mux *runtime.ServeM var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListPolicies", runtime.WithHTTPPathPattern("/api/v1/casbin/policies")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -138,7 +138,7 @@ func RegisterCasbinServiceHandlerServer(ctx context.Context, mux *runtime.ServeM var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListGroupings", runtime.WithHTTPPathPattern("/api/v1/casbin/groupings")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -158,7 +158,7 @@ func RegisterCasbinServiceHandlerServer(ctx context.Context, mux *runtime.ServeM var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/WatchUpdate", runtime.WithHTTPPathPattern("/api/v1/casbin/watch")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -216,7 +216,7 @@ func RegisterCasbinServiceHandlerClient(ctx context.Context, mux *runtime.ServeM ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListPolicies", runtime.WithHTTPPathPattern("/api/v1/casbin/policies")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListPolicies", runtime.WithHTTPPathPattern("/casbin/policies")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -233,7 +233,7 @@ func RegisterCasbinServiceHandlerClient(ctx context.Context, mux *runtime.ServeM ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListGroupings", runtime.WithHTTPPathPattern("/api/v1/casbin/groupings")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/ListGroupings", runtime.WithHTTPPathPattern("/casbin/groupings")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -250,7 +250,7 @@ func RegisterCasbinServiceHandlerClient(ctx context.Context, mux *runtime.ServeM ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/WatchUpdate", runtime.WithHTTPPathPattern("/api/v1/casbin/watch")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.CasbinService/WatchUpdate", runtime.WithHTTPPathPattern("/casbin/watch")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -267,9 +267,9 @@ func RegisterCasbinServiceHandlerClient(ctx context.Context, mux *runtime.ServeM } var ( - pattern_CasbinService_ListPolicies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "policies"}, "")) - pattern_CasbinService_ListGroupings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "groupings"}, "")) - pattern_CasbinService_WatchUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "casbin", "watch"}, "")) + pattern_CasbinService_ListPolicies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "policies"}, "")) + pattern_CasbinService_ListGroupings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "groupings"}, "")) + pattern_CasbinService_WatchUpdate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"casbin", "watch"}, "")) ) var ( diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index c93ff177..b64ce367 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -64,9 +64,9 @@ type CasbinServiceWatchUpdateHooker interface { func RegisterCasbinServiceBridgeServer(s *http.Server, srv CasbinServiceHookedBridger) { r := s.Route("/") - r.GET("/api/v1/casbin/policies", _CasbinService_ListPolicies0_Bridge_Handler(srv)) - r.GET("/api/v1/casbin/groupings", _CasbinService_ListGroupings0_Bridge_Handler(srv)) - r.GET("/api/v1/casbin/watch", _CasbinService_WatchUpdate0_Bridge_Handler(srv)) + r.GET("/casbin/policies", _CasbinService_ListPolicies0_Bridge_Handler(srv)) + r.GET("/casbin/groupings", _CasbinService_ListGroupings0_Bridge_Handler(srv)) + r.GET("/casbin/watch", _CasbinService_WatchUpdate0_Bridge_Handler(srv)) } func _CasbinService_ListPolicies0_Bridge_Handler(srv CasbinServiceHookedBridger) func(ctx http.Context) error { diff --git a/api/v1/services/auth/casbin_http.pb.go b/api/v1/services/auth/casbin_http.pb.go index 5f5f3299..a6dfeefe 100644 --- a/api/v1/services/auth/casbin_http.pb.go +++ b/api/v1/services/auth/casbin_http.pb.go @@ -31,9 +31,9 @@ type CasbinServiceHTTPServer interface { func RegisterCasbinServiceHTTPServer(s *http.Server, srv CasbinServiceHTTPServer) { r := s.Route("/") - r.GET("/api/v1/casbin/policies", _CasbinService_ListPolicies0_HTTP_Handler(srv)) - r.GET("/api/v1/casbin/groupings", _CasbinService_ListGroupings0_HTTP_Handler(srv)) - r.GET("/api/v1/casbin/watch", _CasbinService_WatchUpdate0_HTTP_Handler(srv)) + r.GET("/casbin/policies", _CasbinService_ListPolicies0_HTTP_Handler(srv)) + r.GET("/casbin/groupings", _CasbinService_ListGroupings0_HTTP_Handler(srv)) + r.GET("/casbin/watch", _CasbinService_WatchUpdate0_HTTP_Handler(srv)) } func _CasbinService_ListPolicies0_HTTP_Handler(srv CasbinServiceHTTPServer) func(ctx http.Context) error { @@ -109,7 +109,7 @@ func NewCasbinServiceHTTPClient(client *http.Client) CasbinServiceHTTPClient { func (c *CasbinServiceHTTPClientImpl) ListGroupings(ctx context.Context, in *ListGroupingsRequest, opts ...http.CallOption) (*ListGroupingsResponse, error) { var out ListGroupingsResponse - pattern := "/api/v1/casbin/groupings" + pattern := "/casbin/groupings" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationCasbinServiceListGroupings)) opts = append(opts, http.PathTemplate(pattern)) @@ -122,7 +122,7 @@ func (c *CasbinServiceHTTPClientImpl) ListGroupings(ctx context.Context, in *Lis func (c *CasbinServiceHTTPClientImpl) ListPolicies(ctx context.Context, in *ListPoliciesRequest, opts ...http.CallOption) (*ListPoliciesResponse, error) { var out ListPoliciesResponse - pattern := "/api/v1/casbin/policies" + pattern := "/casbin/policies" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationCasbinServiceListPolicies)) opts = append(opts, http.PathTemplate(pattern)) @@ -135,7 +135,7 @@ func (c *CasbinServiceHTTPClientImpl) ListPolicies(ctx context.Context, in *List func (c *CasbinServiceHTTPClientImpl) WatchUpdate(ctx context.Context, in *WatchUpdateRequest, opts ...http.CallOption) (*WatchUpdateResponse, error) { var out WatchUpdateResponse - pattern := "/api/v1/casbin/watch" + pattern := "/casbin/watch" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationCasbinServiceWatchUpdate)) opts = append(opts, http.PathTemplate(pattern)) diff --git a/api/v1/services/auth/me.pb.go b/api/v1/services/auth/me.pb.go index 102c25dc..22885189 100644 --- a/api/v1/services/auth/me.pb.go +++ b/api/v1/services/auth/me.pb.go @@ -462,15 +462,15 @@ const file_auth_me_proto_rawDesc = "" + "\tresources\x18\x01 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"\x15\n" + "\x13GetUserRolesRequest\"I\n" + "\x14GetUserRolesResponse\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles2\xb3\x05\n" + - "\tMeService\x12{\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles2\x90\x05\n" + + "\tMeService\x12t\n" + "\n" + - "GetProfile\x12'.api.v1.services.auth.GetProfileRequest\x1a(.api.v1.services.auth.GetProfileResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/api/v1/me/profile\x12\x87\x01\n" + - "\rUpdateProfile\x12*.api.v1.services.auth.UpdateProfileRequest\x1a+.api.v1.services.auth.UpdateProfileResponse\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\x1a\x12/api/v1/me/profile\x12\x8b\x01\n" + - "\x0eUpdatePassword\x12+.api.v1.services.auth.UpdatePasswordRequest\x1a,.api.v1.services.auth.UpdatePasswordResponse\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\x1a\x13/api/v1/me/password\x12\x8f\x01\n" + - "\x10GetUserResources\x12-.api.v1.services.auth.GetUserResourcesRequest\x1a..api.v1.services.auth.GetUserResourcesResponse\"\x1c\x82\xd3\xe4\x93\x02\x16\x12\x14/api/v1/me/resources\x12\x7f\n" + - "\fGetUserRoles\x12).api.v1.services.auth.GetUserRolesRequest\x1a*.api.v1.services.auth.GetUserRolesResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/api/v1/me/rolesB\xce\x01\n" + - "\x18com.api.v1.services.authB\aMeProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "GetProfile\x12'.api.v1.services.auth.GetProfileRequest\x1a(.api.v1.services.auth.GetProfileResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/me/profile\x12\x80\x01\n" + + "\rUpdateProfile\x12*.api.v1.services.auth.UpdateProfileRequest\x1a+.api.v1.services.auth.UpdateProfileResponse\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\x1a\v/me/profile\x12\x84\x01\n" + + "\x0eUpdatePassword\x12+.api.v1.services.auth.UpdatePasswordRequest\x1a,.api.v1.services.auth.UpdatePasswordResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x01*\x1a\f/me/password\x12\x88\x01\n" + + "\x10GetUserResources\x12-.api.v1.services.auth.GetUserResourcesRequest\x1a..api.v1.services.auth.GetUserResourcesResponse\"\x15\x82\xd3\xe4\x93\x02\x0f\x12\r/me/resources\x12x\n" + + "\fGetUserRoles\x12).api.v1.services.auth.GetUserRolesRequest\x1a*.api.v1.services.auth.GetUserRolesResponse\"\x11\x82\xd3\xe4\x93\x02\v\x12\t/me/rolesB\xc7\x01\n" + + "\x18com.api.v1.services.authB\aMeProtoP\x01Z.origadmin/application/admin/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_me_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/me.pb.gw.go b/api/v1/services/auth/me.pb.gw.go index 98745f14..7bf7c272 100644 --- a/api/v1/services/auth/me.pb.gw.go +++ b/api/v1/services/auth/me.pb.gw.go @@ -152,7 +152,7 @@ func RegisterMeServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetProfile", runtime.WithHTTPPathPattern("/me/profile")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -172,7 +172,7 @@ func RegisterMeServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdateProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdateProfile", runtime.WithHTTPPathPattern("/me/profile")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -192,7 +192,7 @@ func RegisterMeServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdatePassword", runtime.WithHTTPPathPattern("/api/v1/me/password")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdatePassword", runtime.WithHTTPPathPattern("/me/password")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -212,7 +212,7 @@ func RegisterMeServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserResources", runtime.WithHTTPPathPattern("/api/v1/me/resources")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserResources", runtime.WithHTTPPathPattern("/me/resources")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -232,7 +232,7 @@ func RegisterMeServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserRoles", runtime.WithHTTPPathPattern("/api/v1/me/roles")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserRoles", runtime.WithHTTPPathPattern("/me/roles")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -290,7 +290,7 @@ func RegisterMeServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetProfile", runtime.WithHTTPPathPattern("/me/profile")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -307,7 +307,7 @@ func RegisterMeServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdateProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdateProfile", runtime.WithHTTPPathPattern("/me/profile")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -324,7 +324,7 @@ func RegisterMeServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdatePassword", runtime.WithHTTPPathPattern("/api/v1/me/password")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/UpdatePassword", runtime.WithHTTPPathPattern("/me/password")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -341,7 +341,7 @@ func RegisterMeServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserResources", runtime.WithHTTPPathPattern("/api/v1/me/resources")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserResources", runtime.WithHTTPPathPattern("/me/resources")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -358,7 +358,7 @@ func RegisterMeServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserRoles", runtime.WithHTTPPathPattern("/api/v1/me/roles")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.MeService/GetUserRoles", runtime.WithHTTPPathPattern("/me/roles")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -375,11 +375,11 @@ func RegisterMeServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, } var ( - pattern_MeService_GetProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "profile"}, "")) - pattern_MeService_UpdateProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "profile"}, "")) - pattern_MeService_UpdatePassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "password"}, "")) - pattern_MeService_GetUserResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "resources"}, "")) - pattern_MeService_GetUserRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "roles"}, "")) + pattern_MeService_GetProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"me", "profile"}, "")) + pattern_MeService_UpdateProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"me", "profile"}, "")) + pattern_MeService_UpdatePassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"me", "password"}, "")) + pattern_MeService_GetUserResources_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"me", "resources"}, "")) + pattern_MeService_GetUserRoles_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"me", "roles"}, "")) ) var ( diff --git a/api/v1/services/auth/me_bridge.pb.go b/api/v1/services/auth/me_bridge.pb.go index 6955bd48..309451f5 100644 --- a/api/v1/services/auth/me_bridge.pb.go +++ b/api/v1/services/auth/me_bridge.pb.go @@ -82,11 +82,11 @@ type MeServiceGetUserRolesHooker interface { func RegisterMeServiceBridgeServer(s *http.Server, srv MeServiceHookedBridger) { r := s.Route("/") - r.GET("/api/v1/me/profile", _MeService_GetProfile0_Bridge_Handler(srv)) - r.PUT("/api/v1/me/profile", _MeService_UpdateProfile0_Bridge_Handler(srv)) - r.PUT("/api/v1/me/password", _MeService_UpdatePassword0_Bridge_Handler(srv)) - r.GET("/api/v1/me/resources", _MeService_GetUserResources0_Bridge_Handler(srv)) - r.GET("/api/v1/me/roles", _MeService_GetUserRoles0_Bridge_Handler(srv)) + r.GET("/me/profile", _MeService_GetProfile0_Bridge_Handler(srv)) + r.PUT("/me/profile", _MeService_UpdateProfile0_Bridge_Handler(srv)) + r.PUT("/me/password", _MeService_UpdatePassword0_Bridge_Handler(srv)) + r.GET("/me/resources", _MeService_GetUserResources0_Bridge_Handler(srv)) + r.GET("/me/roles", _MeService_GetUserRoles0_Bridge_Handler(srv)) } func _MeService_GetProfile0_Bridge_Handler(srv MeServiceHookedBridger) func(ctx http.Context) error { diff --git a/api/v1/services/auth/me_http.pb.go b/api/v1/services/auth/me_http.pb.go index 60d3d8b7..441e07cc 100644 --- a/api/v1/services/auth/me_http.pb.go +++ b/api/v1/services/auth/me_http.pb.go @@ -40,11 +40,11 @@ type MeServiceHTTPServer interface { func RegisterMeServiceHTTPServer(s *http.Server, srv MeServiceHTTPServer) { r := s.Route("/") - r.GET("/api/v1/me/profile", _MeService_GetProfile0_HTTP_Handler(srv)) - r.PUT("/api/v1/me/profile", _MeService_UpdateProfile0_HTTP_Handler(srv)) - r.PUT("/api/v1/me/password", _MeService_UpdatePassword0_HTTP_Handler(srv)) - r.GET("/api/v1/me/resources", _MeService_GetUserResources0_HTTP_Handler(srv)) - r.GET("/api/v1/me/roles", _MeService_GetUserRoles0_HTTP_Handler(srv)) + r.GET("/me/profile", _MeService_GetProfile0_HTTP_Handler(srv)) + r.PUT("/me/profile", _MeService_UpdateProfile0_HTTP_Handler(srv)) + r.PUT("/me/password", _MeService_UpdatePassword0_HTTP_Handler(srv)) + r.GET("/me/resources", _MeService_GetUserResources0_HTTP_Handler(srv)) + r.GET("/me/roles", _MeService_GetUserRoles0_HTTP_Handler(srv)) } func _MeService_GetProfile0_HTTP_Handler(srv MeServiceHTTPServer) func(ctx http.Context) error { @@ -172,7 +172,7 @@ func NewMeServiceHTTPClient(client *http.Client) MeServiceHTTPClient { // GetProfile GetProfile retrieves the profile of the currently authenticated user. func (c *MeServiceHTTPClientImpl) GetProfile(ctx context.Context, in *GetProfileRequest, opts ...http.CallOption) (*GetProfileResponse, error) { var out GetProfileResponse - pattern := "/api/v1/me/profile" + pattern := "/me/profile" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationMeServiceGetProfile)) opts = append(opts, http.PathTemplate(pattern)) @@ -186,7 +186,7 @@ func (c *MeServiceHTTPClientImpl) GetProfile(ctx context.Context, in *GetProfile // GetUserResources GetUserResources retrieves the menu/resource list for the current user. func (c *MeServiceHTTPClientImpl) GetUserResources(ctx context.Context, in *GetUserResourcesRequest, opts ...http.CallOption) (*GetUserResourcesResponse, error) { var out GetUserResourcesResponse - pattern := "/api/v1/me/resources" + pattern := "/me/resources" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationMeServiceGetUserResources)) opts = append(opts, http.PathTemplate(pattern)) @@ -200,7 +200,7 @@ func (c *MeServiceHTTPClientImpl) GetUserResources(ctx context.Context, in *GetU // GetUserRoles GetUserRoles retrieves the role list for the current user. func (c *MeServiceHTTPClientImpl) GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...http.CallOption) (*GetUserRolesResponse, error) { var out GetUserRolesResponse - pattern := "/api/v1/me/roles" + pattern := "/me/roles" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationMeServiceGetUserRoles)) opts = append(opts, http.PathTemplate(pattern)) @@ -214,7 +214,7 @@ func (c *MeServiceHTTPClientImpl) GetUserRoles(ctx context.Context, in *GetUserR // UpdatePassword UpdatePassword changes the password for the currently authenticated user. func (c *MeServiceHTTPClientImpl) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...http.CallOption) (*UpdatePasswordResponse, error) { var out UpdatePasswordResponse - pattern := "/api/v1/me/password" + pattern := "/me/password" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationMeServiceUpdatePassword)) opts = append(opts, http.PathTemplate(pattern)) @@ -228,7 +228,7 @@ func (c *MeServiceHTTPClientImpl) UpdatePassword(ctx context.Context, in *Update // UpdateProfile UpdateProfile updates the profile of the currently authenticated user. func (c *MeServiceHTTPClientImpl) UpdateProfile(ctx context.Context, in *UpdateProfileRequest, opts ...http.CallOption) (*UpdateProfileResponse, error) { var out UpdateProfileResponse - pattern := "/api/v1/me/profile" + pattern := "/me/profile" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationMeServiceUpdateProfile)) opts = append(opts, http.PathTemplate(pattern)) diff --git a/cmd/gateway/main.go b/cmd/gateway/main.go index 80e3287e..cfcb4061 100644 --- a/cmd/gateway/main.go +++ b/cmd/gateway/main.go @@ -28,14 +28,14 @@ func init() { // flag.StringVar(&flagconf, "conf", "../../configs", "config path, eg: -conf config.yaml") } -func newApp(logger log.Logger, servers []transport.Server) *kratos.App { +func newApp(logger log.Logger, srv transport.Server) *kratos.App { return kratos.New( kratos.Name(Name), kratos.Version(Version), kratos.Metadata(map[string]string{}), kratos.Logger(logger), kratos.Server( - servers..., + srv, ), ) } diff --git a/cmd/gateway/wire.go b/cmd/gateway/wire.go index 060c90ea..b2613fff 100644 --- a/cmd/gateway/wire.go +++ b/cmd/gateway/wire.go @@ -20,6 +20,6 @@ import ( ) // wireApp init kratos application. -func wireApp(*confpb.Bootstrap, log.Logger) (*kratos.App, func(), error) { +func wireApp(bootstrap *confpb.Bootstrap, logger log.Logger) (*kratos.App, func(), error) { panic(wire.Build(server.ProviderSet, client.ProviderSet, service.ProviderSet, newApp)) } diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go new file mode 100644 index 00000000..35a1cfb5 --- /dev/null +++ b/internal/gateway/client/client.go @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package client + +import ( + "context" + "errors" + + "github.com/google/wire" + + transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" + "github.com/origadmin/runtime/service/transport/grpc" + "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/api/v1/services/system" + confpb "origadmin/application/admin/internal/conf/pb" +) + +// ProviderSet is client providers. +var ProviderSet = wire.NewSet(NewAuthClient, NewSystemClient) + +// NewAuthClient creates a new AuthAPI client. +func NewAuthClient(bootstrap *confpb.Bootstrap) (auth.AuthServiceClient, error) { + var clientConfig *transportv1.Client + if bootstrap.Clients != nil { + for _, cli := range bootstrap.Clients.Configs { + if cli.Name == "client.auth" { + clientConfig = cli + break + } + } + } + + if clientConfig == nil { + return nil, errors.New("client config not found: client.auth") + } + + grpcConfig := clientConfig.GetGrpc() + if grpcConfig == nil { + return nil, errors.New("grpc client config not found: client.auth") + } + + conn, err := grpc.NewClient(context.Background(), grpcConfig, &grpc.ClientOptions{}) + if err != nil { + return nil, err + } + return auth.NewAuthServiceClient(conn), nil +} + +// NewSystemClient creates a new SystemAPI client. +func NewSystemClient(bootstrap *confpb.Bootstrap) (system.UserServiceClient, error) { + var clientConfig *transportv1.Client + if bootstrap.Clients != nil { + for _, cli := range bootstrap.Clients.Configs { + if cli.Name == "client.system" { + clientConfig = cli + break + } + } + } + + if clientConfig == nil { + return nil, errors.New("client config not found: client.system") + } + + grpcConfig := clientConfig.GetGrpc() + if grpcConfig == nil { + return nil, errors.New("grpc client config not found: client.system") + } + + conn, err := grpc.NewClient(context.Background(), grpcConfig, &grpc.ClientOptions{}) + if err != nil { + return nil, err + } + return system.NewUserServiceClient(conn), nil +} diff --git a/internal/gateway/proxy.go b/internal/gateway/proxy.go deleted file mode 100644 index e69de29b..00000000 diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go new file mode 100644 index 00000000..44dba53d --- /dev/null +++ b/internal/gateway/server/server.go @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package server + +import ( + "errors" + + "github.com/go-kratos/kratos/v2/log" + "github.com/go-kratos/kratos/v2/transport" + "github.com/go-kratos/kratos/v2/transport/http" + "github.com/google/wire" + + gatewayAPI "origadmin/application/admin/api/v1/services/gateway" + confpb "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/gateway/service" + httpv1 "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1" +) + +// ProviderSet is server providers. +var ProviderSet = wire.NewSet(NewHTTPServer) + +// NewHTTPServer new an HTTP server. +func NewHTTPServer(bootstrap *confpb.Bootstrap, gw *service.GatewayService, logger log.Logger) (transport.Server, + error) { + var opts = []http.ServerOption{ + http.Middleware( + // Add any HTTP middleware here if needed + ), + } + + var httpServerConfig *httpv1.Server + if bootstrap.Servers != nil { + for _, srv := range bootstrap.Servers.Configs { + if srv.Protocol == "http" { + httpServerConfig = srv.GetHttp() + break + } + } + } + + if httpServerConfig == nil { + return nil, errors.New("http server config is not found") + } + + if httpServerConfig.Addr != "" { + opts = append(opts, http.Address(httpServerConfig.Addr)) + } + if httpServerConfig.Timeout != nil { + opts = append(opts, http.Timeout(httpServerConfig.Timeout.AsDuration())) + } + + srv := http.NewServer(opts...) + gatewayAPI.RegisterGatewayServiceHTTPServer(srv, gw) + return srv, nil +} diff --git a/internal/gateway/service/service.go b/internal/gateway/service/service.go new file mode 100644 index 00000000..60a296d3 --- /dev/null +++ b/internal/gateway/service/service.go @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package service + +import ( + "context" + "errors" + + "github.com/google/wire" + + "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/api/v1/services/gateway" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" +) + +// ProviderSet is service providers. +var ProviderSet = wire.NewSet(NewGatewayService) + +// GatewayService implements the GatewayAPI service. +type GatewayService struct { + gateway.UnimplementedGatewayServiceServer + + authClient auth.AuthServiceClient + systemClient system.UserServiceClient +} + +// NewGatewayService creates a new gateway service. +func NewGatewayService(authClient auth.AuthServiceClient, systemClient system.UserServiceClient) *GatewayService { + return &GatewayService{ + authClient: authClient, + systemClient: systemClient, + } +} + +func (g *GatewayService) Login(ctx context.Context, request *auth.LoginRequest) (*auth.LoginResponse, error) { + return g.authClient.Login(ctx, request) +} + +func (g *GatewayService) GetCaptcha(ctx context.Context, request *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { + return g.authClient.GetCaptcha(ctx, request) +} + +func (g *GatewayService) GetProfile(ctx context.Context, request *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { + // Assuming MeService is part of AuthService, if not, a new client for MeService is needed + // This is a placeholder, as MeService is not directly available on AuthServiceClient + // You might need to create a MeServiceClient + return nil, errors.New("GetProfile not implemented on auth client") +} + +func (g *GatewayService) ListUsers(ctx context.Context, request *system.ListUsersRequest) (*system.ListUsersResponse, error) { + return g.systemClient.ListUsers(ctx, request) +} + +func (g *GatewayService) GetUser(ctx context.Context, request *system.GetUserRequest) (*types.User, error) { + res, err := g.systemClient.GetUser(ctx, request) + if err != nil { + return nil, err + } + return res.User, nil +} + +func (g *GatewayService) CreateUser(ctx context.Context, request *system.CreateUserRequest) (*types.User, error) { + res, err := g.systemClient.CreateUser(ctx, request) + if err != nil { + return nil, err + } + return res.User, nil +} + +func (g *GatewayService) UpdateUser(ctx context.Context, request *system.UpdateUserRequest) (*types.User, error) { + res, err := g.systemClient.UpdateUser(ctx, request) + if err != nil { + return nil, err + } + return res.User, nil +} + +func (g *GatewayService) DeleteUser(ctx context.Context, request *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { + return g.systemClient.DeleteUser(ctx, request) +} diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 79005b93..66980d50 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -17,12 +17,36 @@ servers: - url: http://localhost:10080 - url: https://localhost:10080 paths: - /api/v1/auth/login: + /api/v1/captcha: + get: + tags: + - GatewayService + operationId: GatewayService_GetCaptcha + parameters: + - name: reload + in: query + description: If true, forces reloading of the captcha. + schema: + type: boolean + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.GetCaptchaResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /api/v1/login: post: tags: - - AuthService - description: Login authenticates a user and returns a token pair. - operationId: AuthService_Login + - GatewayService + description: '--- Auth Service ---' + operationId: GatewayService_Login requestBody: content: application/json: @@ -42,67 +66,91 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/auth/logout: - post: + /api/v1/me/profile: + get: tags: - - AuthService - description: Logout invalidates the user's session. - operationId: AuthService_Logout - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.LogoutRequest' - required: true + - GatewayService + description: '--- Me Service ---' + operationId: GatewayService_GetProfile responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.LogoutResponse' + $ref: '#/components/schemas/api.v1.services.auth.GetProfileResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/auth/register: - post: + /api/v1/users: + get: tags: - - AuthService - description: Register creates a new user account. - operationId: AuthService_Register - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.RegisterRequest' - required: true + - GatewayService + description: '--- System User Service ---' + operationId: GatewayService_ListUsers + parameters: + - name: id + in: query + description: The parent resource id, for example, "shelves/shelf1". + schema: + type: string + - name: page + in: query + description: The page number. + schema: + type: integer + format: int32 + - name: page_size + in: query + description: The maximum number of items to return. + schema: + type: integer + format: int32 + - name: page_token + in: query + description: The next_page_token value returned from a previous List request, if any. + schema: + type: string + - name: no_paging + in: query + description: The no_paging is used to disable pagination. + schema: + type: boolean + - name: only_count + in: query + description: The only_count is the query parameter for set only to query the total number + schema: + type: boolean + - name: keyword + in: query + description: The title query parameter for set only to query the title + schema: + type: string responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse' + $ref: '#/components/schemas/api.v1.services.system.ListUsersResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/auth/token: post: tags: - - AuthService - description: RefreshToken provides a new access token. - operationId: AuthService_RefreshToken + - GatewayService + operationId: GatewayService_CreateUser requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.RefreshTokenRequest' + $ref: '#/components/schemas/api.v1.services.system.CreateUserRequest' required: true responses: "200": @@ -110,108 +158,294 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.RefreshTokenResponse' + $ref: '#/components/schemas/api.v1.services.types.User' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/captcha: + /api/v1/users/{id}: get: tags: - - AuthService - description: GetCaptcha generates a new captcha. - operationId: AuthService_GetCaptcha + - GatewayService + operationId: GatewayService_GetUser parameters: - - name: reload + - name: id + in: path + description: |- + The field will contain id of the resource requested, for example: + "shelves/shelf1/users/user2" + required: true + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.types.User' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + delete: + tags: + - GatewayService + operationId: GatewayService_DeleteUser + parameters: + - name: id + in: path + description: The resource id of the user to be deleted. + required: true + schema: + type: string + - name: user.id in: query - description: If true, forces reloading of the captcha. + description: |- + ID of the ent. + field.primary_key.comment schema: - type: boolean + type: string + - name: user.create_author + in: query + description: create_author.field.comment + schema: + type: string + - name: user.update_author + in: query + description: update_author.field.comment + schema: + type: string + - name: user.create_time + in: query + description: create_time.field.comment + schema: + type: string + format: date-time + - name: user.update_time + in: query + description: update_time.field.comment + schema: + type: string + format: date-time + - name: user.uuid + in: query + description: user.field.uuid + schema: + type: string + - name: user.allowed_ip + in: query + description: user.field.allowed_ip + schema: + type: string + - name: user.username + in: query + description: user.field.username + schema: + type: string + - name: user.nickname + in: query + description: user.field.nickname + schema: + type: string + - name: user.avatar + in: query + description: user.field.avatar + schema: + type: string + - name: user.name + in: query + description: user.field.nickname + schema: + type: string + - name: user.gender + in: query + description: user.field.gender + schema: + type: string + - name: user.phone + in: query + description: user.field.phone + schema: + type: string + - name: user.email + in: query + description: user.field.email + schema: + type: string + - name: user.remark + in: query + description: user.field.remark + schema: + type: string + - name: user.token + in: query + description: user.field.token + schema: + type: string + - name: user.status + in: query + description: user.field.status + schema: + type: integer + format: int32 + - name: user.last_login_ip + in: query + description: user.field.last_login_ip + schema: + type: string + - name: user.last_login_time + in: query + description: user.field.last_login_time + schema: + type: string + format: date-time + - name: user.sanction_date + in: query + description: user.field.sanction_date + schema: + type: string + format: date-time + - name: user.manager_id + in: query + description: user.field.manager_id + schema: + type: string + - name: user.manager + in: query + description: user.field.manager + schema: + type: string + - name: user.role_ids + in: query + description: Role Ids holds the value of the role_ids + schema: + type: array + items: + type: string responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.GetCaptchaResponse' + $ref: '#/components/schemas/api.v1.services.system.DeleteUserResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/casbin/groupings: - get: + /api/v1/users/{user.id}: + put: tags: - - CasbinService - operationId: CasbinService_ListGroupings + - GatewayService + operationId: GatewayService_UpdateUser + parameters: + - name: user.id + in: path + required: true + schema: + type: string + - name: user_id + in: query + description: The user id to use for this user. + schema: + type: string + - name: is_system + in: query + description: The user is_system to use for this user. + schema: + type: boolean + - name: random_password + in: query + description: The random_password is the query parameter for set only to generate a random password + schema: + type: boolean + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.types.User' + required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.ListGroupingsResponse' + $ref: '#/components/schemas/api.v1.services.types.User' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/casbin/policies: - get: + /auth/login: + post: tags: - - CasbinService - operationId: CasbinService_ListPolicies + - AuthService + description: Login authenticates a user and returns a token pair. + operationId: AuthService_Login + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.LoginRequest' + required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.ListPoliciesResponse' + $ref: '#/components/schemas/api.v1.services.auth.LoginResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/casbin/watch: - get: + /auth/logout: + post: tags: - - CasbinService - operationId: CasbinService_WatchUpdate - parameters: - - name: last_modified - in: query - schema: - type: string + - AuthService + description: Logout invalidates the user's session. + operationId: AuthService_Logout + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.LogoutRequest' + required: true responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.WatchUpdateResponse' + $ref: '#/components/schemas/api.v1.services.auth.LogoutResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/login: + /auth/register: post: tags: - - GatewayService - description: Login authenticates a user. - operationId: GatewayService_Login + - AuthService + description: Register creates a new user account. + operationId: AuthService_Register requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.LoginRequest' + $ref: '#/components/schemas/api.v1.services.auth.RegisterRequest' required: true responses: "200": @@ -219,24 +453,24 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.LoginResponse' + $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/me/password: - put: + /auth/token: + post: tags: - - MeService - description: UpdatePassword changes the password for the currently authenticated user. - operationId: MeService_UpdatePassword + - AuthService + description: RefreshToken provides a new access token. + operationId: AuthService_RefreshToken requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.UpdatePasswordRequest' + $ref: '#/components/schemas/api.v1.services.auth.RefreshTokenRequest' required: true responses: "200": @@ -244,88 +478,91 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.UpdatePasswordResponse' + $ref: '#/components/schemas/api.v1.services.auth.RefreshTokenResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/me/profile: + /captcha: get: tags: - - MeService - description: GetProfile retrieves the profile of the currently authenticated user. - operationId: MeService_GetProfile + - AuthService + description: GetCaptcha generates a new captcha. + operationId: AuthService_GetCaptcha + parameters: + - name: reload + in: query + description: If true, forces reloading of the captcha. + schema: + type: boolean responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.GetProfileResponse' + $ref: '#/components/schemas/api.v1.services.auth.GetCaptchaResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - put: + /casbin/groupings: + get: tags: - - MeService - description: UpdateProfile updates the profile of the currently authenticated user. - operationId: MeService_UpdateProfile - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.UpdateProfileRequest' - required: true + - CasbinService + operationId: CasbinService_ListGroupings responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.UpdateProfileResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListGroupingsResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/me/resources: + /casbin/policies: get: tags: - - MeService - description: GetUserResources retrieves the menu/resource list for the current user. - operationId: MeService_GetUserResources + - CasbinService + operationId: CasbinService_ListPolicies responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.GetUserResourcesResponse' + $ref: '#/components/schemas/api.v1.services.auth.ListPoliciesResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /api/v1/me/roles: + /casbin/watch: get: tags: - - MeService - description: GetUserRoles retrieves the role list for the current user. - operationId: MeService_GetUserRoles + - CasbinService + operationId: CasbinService_WatchUpdate + parameters: + - name: last_modified + in: query + schema: + type: string responses: "200": description: OK content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.GetUserRolesResponse' + $ref: '#/components/schemas/api.v1.services.auth.WatchUpdateResponse' default: description: Default error response content: @@ -506,6 +743,112 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' + /me/password: + put: + tags: + - MeService + description: UpdatePassword changes the password for the currently authenticated user. + operationId: MeService_UpdatePassword + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.UpdatePasswordRequest' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.UpdatePasswordResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /me/profile: + get: + tags: + - MeService + description: GetProfile retrieves the profile of the currently authenticated user. + operationId: MeService_GetProfile + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.GetProfileResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + put: + tags: + - MeService + description: UpdateProfile updates the profile of the currently authenticated user. + operationId: MeService_UpdateProfile + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.UpdateProfileRequest' + required: true + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.UpdateProfileResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /me/resources: + get: + tags: + - MeService + description: GetUserResources retrieves the menu/resource list for the current user. + operationId: MeService_GetUserResources + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.GetUserResourcesResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' + /me/roles: + get: + tags: + - MeService + description: GetUserRoles retrieves the role list for the current user. + operationId: MeService_GetUserRoles + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.GetUserRolesResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' /message/personal/logout: post: tags: From ec6a0f3f853ab15060c99bc8d64623de1ccb6080 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 03:26:00 +0800 Subject: [PATCH 114/158] refactor(auth): update proto go_package paths to include api/v1 prefix --- api/v1/proto/auth/auth.proto | 2 +- api/v1/proto/auth/casbin.proto | 2 +- api/v1/proto/auth/me.proto | 2 +- api/v1/services/auth/auth.pb.go | 4 ++-- api/v1/services/auth/casbin.pb.go | 4 ++-- api/v1/services/auth/me.pb.go | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index e18d655d..b32a434d 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -4,7 +4,7 @@ package api.v1.services.auth; import "google/api/annotations.proto"; -option go_package = "origadmin/application/admin/services/auth;auth"; +option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; option java_package = "com.origadmin.api.v1.services.auth"; option java_outer_classname = "APIServiceAuthProto"; diff --git a/api/v1/proto/auth/casbin.proto b/api/v1/proto/auth/casbin.proto index a10feda4..4840bd50 100644 --- a/api/v1/proto/auth/casbin.proto +++ b/api/v1/proto/auth/casbin.proto @@ -4,7 +4,7 @@ package api.v1.services.auth; import "google/api/annotations.proto"; -option go_package = "origadmin/application/admin/services/auth;auth"; +option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; option java_outer_classname = "APIServiceAuthCasbinProto"; option java_package = "com.origadmin.api.v1.services.auth"; diff --git a/api/v1/proto/auth/me.proto b/api/v1/proto/auth/me.proto index 10d36574..33c06184 100644 --- a/api/v1/proto/auth/me.proto +++ b/api/v1/proto/auth/me.proto @@ -5,7 +5,7 @@ package api.v1.services.auth; import "google/api/annotations.proto"; import "types/system.proto"; -option go_package = "origadmin/application/admin/services/auth;auth"; +option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; option java_package = "com.origadmin.api.v1.services.auth"; option java_outer_classname = "APIServiceMeProto"; diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index 02594323..4932f5ee 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -736,8 +736,8 @@ const file_auth_auth_proto_rawDesc = "" + "\n" + "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"\x10\x82\xd3\xe4\x93\x02\n" + "\x12\b/captcha\x12e\n" + - "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponseB\xc9\x01\n" + - "\x18com.api.v1.services.authB\tAuthProtoP\x01Z.origadmin/application/admin/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponseB\xd0\x01\n" + + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_auth_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/casbin.pb.go b/api/v1/services/auth/casbin.pb.go index 3f03005e..ae5c08cf 100644 --- a/api/v1/services/auth/casbin.pb.go +++ b/api/v1/services/auth/casbin.pb.go @@ -541,8 +541,8 @@ const file_auth_casbin_proto_rawDesc = "" + "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x86\x01\n" + "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12|\n" + "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12f\n" + - "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xcb\x01\n" + - "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z.origadmin/application/admin/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xd2\x01\n" + + "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_casbin_proto_rawDescOnce sync.Once diff --git a/api/v1/services/auth/me.pb.go b/api/v1/services/auth/me.pb.go index 22885189..0429fa18 100644 --- a/api/v1/services/auth/me.pb.go +++ b/api/v1/services/auth/me.pb.go @@ -469,8 +469,8 @@ const file_auth_me_proto_rawDesc = "" + "\rUpdateProfile\x12*.api.v1.services.auth.UpdateProfileRequest\x1a+.api.v1.services.auth.UpdateProfileResponse\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\x1a\v/me/profile\x12\x84\x01\n" + "\x0eUpdatePassword\x12+.api.v1.services.auth.UpdatePasswordRequest\x1a,.api.v1.services.auth.UpdatePasswordResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x01*\x1a\f/me/password\x12\x88\x01\n" + "\x10GetUserResources\x12-.api.v1.services.auth.GetUserResourcesRequest\x1a..api.v1.services.auth.GetUserResourcesResponse\"\x15\x82\xd3\xe4\x93\x02\x0f\x12\r/me/resources\x12x\n" + - "\fGetUserRoles\x12).api.v1.services.auth.GetUserRolesRequest\x1a*.api.v1.services.auth.GetUserRolesResponse\"\x11\x82\xd3\xe4\x93\x02\v\x12\t/me/rolesB\xc7\x01\n" + - "\x18com.api.v1.services.authB\aMeProtoP\x01Z.origadmin/application/admin/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" + "\fGetUserRoles\x12).api.v1.services.auth.GetUserRolesRequest\x1a*.api.v1.services.auth.GetUserRolesResponse\"\x11\x82\xd3\xe4\x93\x02\v\x12\t/me/rolesB\xce\x01\n" + + "\x18com.api.v1.services.authB\aMeProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( file_auth_me_proto_rawDescOnce sync.Once From e2066402398e34ed786c1855b7628620627b34d9 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 04:57:34 +0800 Subject: [PATCH 115/158] feat(api): add gateway service proto and gRPC gateway implementation --- api/v1/services/gateway/gateway.pb.go | 109 ++ api/v1/services/gateway/gateway.pb.gw.go | 682 +++++++++ .../services/gateway/gateway.pb.validate.go | 36 + api/v1/services/gateway/gateway_bridge.pb.go | 566 +++++++ api/v1/services/gateway/gateway_grpc.pb.go | 402 +++++ api/v1/services/gateway/gateway_http.pb.go | 357 +++++ api/v1/services/system/view.pb.go | 724 +++++++++ api/v1/services/system/view.pb.gw.go | 459 ++++++ api/v1/services/system/view.pb.validate.go | 1323 +++++++++++++++++ api/v1/services/system/view_bridge.pb.go | 397 +++++ api/v1/services/system/view_grpc.pb.go | 289 ++++ api/v1/services/system/view_http.pb.go | 249 ++++ cmd/auth/wire.go | 6 - cmd/gateway/main.go | 81 +- cmd/gateway/wire.go | 18 +- cmd/gateway/wire_gen.go | 29 +- cmd/system/wire.go | 5 - go.mod | 2 +- internal/conf/pb/conf.proto | 12 +- internal/gateway/client/client.go | 14 +- internal/gateway/server/server.go | 74 +- internal/helpers/providers/providers.go | 4 + resources/configs/clients.yaml | 10 + resources/configs/server.yaml | 51 +- 24 files changed, 5776 insertions(+), 123 deletions(-) create mode 100644 api/v1/services/gateway/gateway.pb.go create mode 100644 api/v1/services/gateway/gateway.pb.gw.go create mode 100644 api/v1/services/gateway/gateway.pb.validate.go create mode 100644 api/v1/services/gateway/gateway_bridge.pb.go create mode 100644 api/v1/services/gateway/gateway_grpc.pb.go create mode 100644 api/v1/services/gateway/gateway_http.pb.go create mode 100644 api/v1/services/system/view.pb.go create mode 100644 api/v1/services/system/view.pb.gw.go create mode 100644 api/v1/services/system/view.pb.validate.go create mode 100644 api/v1/services/system/view_bridge.pb.go create mode 100644 api/v1/services/system/view_grpc.pb.go create mode 100644 api/v1/services/system/view_http.pb.go create mode 100644 resources/configs/clients.yaml diff --git a/api/v1/services/gateway/gateway.pb.go b/api/v1/services/gateway/gateway.pb.go new file mode 100644 index 00000000..11816de1 --- /dev/null +++ b/api/v1/services/gateway/gateway.pb.go @@ -0,0 +1,109 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: gateway/gateway.proto + +package gateway + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + auth "origadmin/application/admin/api/v1/services/auth" + system "origadmin/application/admin/api/v1/services/system" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var File_gateway_gateway_proto protoreflect.FileDescriptor + +const file_gateway_gateway_proto_rawDesc = "" + + "\n" + + "\x15gateway/gateway.proto\x12\x17api.v1.services.gateway\x1a\x1cgoogle/api/annotations.proto\x1a\x0fauth/auth.proto\x1a\rauth/me.proto\x1a\x11system/user.proto\x1a\x11system/role.proto\x1a\x15system/resource.proto\x1a\x12types/system.proto2\xc6\a\n" + + "\x0eGatewayService\x12j\n" + + "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x01*\"\r/api/v1/login\x12x\n" + + "\n" + + "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/api/v1/captcha\x12{\n" + + "\n" + + "GetProfile\x12'.api.v1.services.auth.GetProfileRequest\x1a(.api.v1.services.auth.GetProfileResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/api/v1/me/profile\x12w\n" + + "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\"\x15\x82\xd3\xe4\x93\x02\x0f\x12\r/api/v1/users\x12j\n" + + "\aGetUser\x12&.api.v1.services.system.GetUserRequest\x1a\x1b.api.v1.services.types.User\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/api/v1/users/{id}\x12n\n" + + "\n" + + "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a\x1b.api.v1.services.types.User\"\x18\x82\xd3\xe4\x93\x02\x12:\x01*\"\r/api/v1/users\x12{\n" + + "\n" + + "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a\x1b.api.v1.services.types.User\"%\x82\xd3\xe4\x93\x02\x1f:\x04user\x1a\x17/api/v1/users/{user.id}\x12\x7f\n" + + "\n" + + "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x1a\x82\xd3\xe4\x93\x02\x14*\x12/api/v1/users/{id}B\xe8\x01\n" + + "\x1bcom.api.v1.services.gatewayB\fGatewayProtoP\x01Z;origadmin/application/admin/api/v1/services/gateway;gateway\xa2\x02\x04AVSG\xaa\x02\x17Api.V1.Services.Gateway\xca\x02\x17Api\\V1\\Services\\Gateway\xe2\x02#Api\\V1\\Services\\Gateway\\GPBMetadata\xea\x02\x1aApi::V1::Services::Gatewayb\x06proto3" + +var file_gateway_gateway_proto_goTypes = []any{ + (*auth.LoginRequest)(nil), // 0: api.v1.services.auth.LoginRequest + (*auth.GetCaptchaRequest)(nil), // 1: api.v1.services.auth.GetCaptchaRequest + (*auth.GetProfileRequest)(nil), // 2: api.v1.services.auth.GetProfileRequest + (*system.ListUsersRequest)(nil), // 3: api.v1.services.system.ListUsersRequest + (*system.GetUserRequest)(nil), // 4: api.v1.services.system.GetUserRequest + (*system.CreateUserRequest)(nil), // 5: api.v1.services.system.CreateUserRequest + (*system.UpdateUserRequest)(nil), // 6: api.v1.services.system.UpdateUserRequest + (*system.DeleteUserRequest)(nil), // 7: api.v1.services.system.DeleteUserRequest + (*auth.LoginResponse)(nil), // 8: api.v1.services.auth.LoginResponse + (*auth.GetCaptchaResponse)(nil), // 9: api.v1.services.auth.GetCaptchaResponse + (*auth.GetProfileResponse)(nil), // 10: api.v1.services.auth.GetProfileResponse + (*system.ListUsersResponse)(nil), // 11: api.v1.services.system.ListUsersResponse + (*types.User)(nil), // 12: api.v1.services.types.User + (*system.DeleteUserResponse)(nil), // 13: api.v1.services.system.DeleteUserResponse +} +var file_gateway_gateway_proto_depIdxs = []int32{ + 0, // 0: api.v1.services.gateway.GatewayService.Login:input_type -> api.v1.services.auth.LoginRequest + 1, // 1: api.v1.services.gateway.GatewayService.GetCaptcha:input_type -> api.v1.services.auth.GetCaptchaRequest + 2, // 2: api.v1.services.gateway.GatewayService.GetProfile:input_type -> api.v1.services.auth.GetProfileRequest + 3, // 3: api.v1.services.gateway.GatewayService.ListUsers:input_type -> api.v1.services.system.ListUsersRequest + 4, // 4: api.v1.services.gateway.GatewayService.GetUser:input_type -> api.v1.services.system.GetUserRequest + 5, // 5: api.v1.services.gateway.GatewayService.CreateUser:input_type -> api.v1.services.system.CreateUserRequest + 6, // 6: api.v1.services.gateway.GatewayService.UpdateUser:input_type -> api.v1.services.system.UpdateUserRequest + 7, // 7: api.v1.services.gateway.GatewayService.DeleteUser:input_type -> api.v1.services.system.DeleteUserRequest + 8, // 8: api.v1.services.gateway.GatewayService.Login:output_type -> api.v1.services.auth.LoginResponse + 9, // 9: api.v1.services.gateway.GatewayService.GetCaptcha:output_type -> api.v1.services.auth.GetCaptchaResponse + 10, // 10: api.v1.services.gateway.GatewayService.GetProfile:output_type -> api.v1.services.auth.GetProfileResponse + 11, // 11: api.v1.services.gateway.GatewayService.ListUsers:output_type -> api.v1.services.system.ListUsersResponse + 12, // 12: api.v1.services.gateway.GatewayService.GetUser:output_type -> api.v1.services.types.User + 12, // 13: api.v1.services.gateway.GatewayService.CreateUser:output_type -> api.v1.services.types.User + 12, // 14: api.v1.services.gateway.GatewayService.UpdateUser:output_type -> api.v1.services.types.User + 13, // 15: api.v1.services.gateway.GatewayService.DeleteUser:output_type -> api.v1.services.system.DeleteUserResponse + 8, // [8:16] is the sub-list for method output_type + 0, // [0:8] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_gateway_gateway_proto_init() } +func file_gateway_gateway_proto_init() { + if File_gateway_gateway_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_gateway_gateway_proto_rawDesc), len(file_gateway_gateway_proto_rawDesc)), + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_gateway_gateway_proto_goTypes, + DependencyIndexes: file_gateway_gateway_proto_depIdxs, + }.Build() + File_gateway_gateway_proto = out.File + file_gateway_gateway_proto_goTypes = nil + file_gateway_gateway_proto_depIdxs = nil +} diff --git a/api/v1/services/gateway/gateway.pb.gw.go b/api/v1/services/gateway/gateway.pb.gw.go new file mode 100644 index 00000000..28e35615 --- /dev/null +++ b/api/v1/services/gateway/gateway.pb.gw.go @@ -0,0 +1,682 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: gateway/gateway.proto + +/* +Package gateway is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package gateway + +import ( + "context" + "errors" + "io" + "net/http" + "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/api/v1/services/system" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +func request_GatewayService_Login_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq auth.LoginRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_GatewayService_Login_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq auth.LoginRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.Login(ctx, &protoReq) + return msg, metadata, err +} + +var filter_GatewayService_GetCaptcha_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_GatewayService_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq auth.GetCaptchaRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_GetCaptcha_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.GetCaptcha(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_GatewayService_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq auth.GetCaptchaRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_GetCaptcha_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.GetCaptcha(ctx, &protoReq) + return msg, metadata, err +} + +func request_GatewayService_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq auth.GetProfileRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + msg, err := client.GetProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_GatewayService_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq auth.GetProfileRequest + metadata runtime.ServerMetadata + ) + msg, err := server.GetProfile(ctx, &protoReq) + return msg, metadata, err +} + +var filter_GatewayService_ListUsers_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_GatewayService_ListUsers_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq system.ListUsersRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_ListUsers_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListUsers(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_GatewayService_ListUsers_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq system.ListUsersRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_ListUsers_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListUsers(ctx, &protoReq) + return msg, metadata, err +} + +func request_GatewayService_GetUser_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq system.GetUserRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_GatewayService_GetUser_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq system.GetUserRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetUser(ctx, &protoReq) + return msg, metadata, err +} + +func request_GatewayService_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq system.CreateUserRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_GatewayService_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq system.CreateUserRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateUser(ctx, &protoReq) + return msg, metadata, err +} + +var filter_GatewayService_UpdateUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} + +func request_GatewayService_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq system.UpdateUserRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["user.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_UpdateUser_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.UpdateUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_GatewayService_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq system.UpdateUserRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["user.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_UpdateUser_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.UpdateUser(ctx, &protoReq) + return msg, metadata, err +} + +var filter_GatewayService_DeleteUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + +func request_GatewayService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq system.DeleteUserRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_DeleteUser_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.DeleteUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_GatewayService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq system.DeleteUserRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_DeleteUser_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.DeleteUser(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterGatewayServiceHandlerServer registers the http handlers for service GatewayService to "mux". +// UnaryRPC :call GatewayServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterGatewayServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterGatewayServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GatewayServiceServer) error { + mux.Handle(http.MethodPost, pattern_GatewayService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/Login", runtime.WithHTTPPathPattern("/api/v1/login")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_GatewayService_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_GatewayService_GetCaptcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_GatewayService_GetCaptcha_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_GetCaptcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_GatewayService_GetProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_GatewayService_GetProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_GetProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_GatewayService_ListUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/ListUsers", runtime.WithHTTPPathPattern("/api/v1/users")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_GatewayService_ListUsers_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_ListUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_GatewayService_GetUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetUser", runtime.WithHTTPPathPattern("/api/v1/users/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_GatewayService_GetUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_GetUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_GatewayService_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/CreateUser", runtime.WithHTTPPathPattern("/api/v1/users")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_GatewayService_CreateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_GatewayService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/UpdateUser", runtime.WithHTTPPathPattern("/api/v1/users/{user.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_GatewayService_UpdateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_GatewayService_DeleteUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/DeleteUser", runtime.WithHTTPPathPattern("/api/v1/users/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_GatewayService_DeleteUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_DeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterGatewayServiceHandlerFromEndpoint is same as RegisterGatewayServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterGatewayServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterGatewayServiceHandler(ctx, mux, conn) +} + +// RegisterGatewayServiceHandler registers the http handlers for service GatewayService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterGatewayServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterGatewayServiceHandlerClient(ctx, mux, NewGatewayServiceClient(conn)) +} + +// RegisterGatewayServiceHandlerClient registers the http handlers for service GatewayService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "GatewayServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "GatewayServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "GatewayServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterGatewayServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GatewayServiceClient) error { + mux.Handle(http.MethodPost, pattern_GatewayService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/Login", runtime.WithHTTPPathPattern("/api/v1/login")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GatewayService_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_GatewayService_GetCaptcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GatewayService_GetCaptcha_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_GetCaptcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_GatewayService_GetProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GatewayService_GetProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_GetProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_GatewayService_ListUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/ListUsers", runtime.WithHTTPPathPattern("/api/v1/users")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GatewayService_ListUsers_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_ListUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_GatewayService_GetUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetUser", runtime.WithHTTPPathPattern("/api/v1/users/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GatewayService_GetUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_GetUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_GatewayService_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/CreateUser", runtime.WithHTTPPathPattern("/api/v1/users")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GatewayService_CreateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_GatewayService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/UpdateUser", runtime.WithHTTPPathPattern("/api/v1/users/{user.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GatewayService_UpdateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_GatewayService_DeleteUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/DeleteUser", runtime.WithHTTPPathPattern("/api/v1/users/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_GatewayService_DeleteUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_GatewayService_DeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_GatewayService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "login"}, "")) + pattern_GatewayService_GetCaptcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "captcha"}, "")) + pattern_GatewayService_GetProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "profile"}, "")) + pattern_GatewayService_ListUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "users"}, "")) + pattern_GatewayService_GetUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "users", "id"}, "")) + pattern_GatewayService_CreateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "users"}, "")) + pattern_GatewayService_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "users", "user.id"}, "")) + pattern_GatewayService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "users", "id"}, "")) +) + +var ( + forward_GatewayService_Login_0 = runtime.ForwardResponseMessage + forward_GatewayService_GetCaptcha_0 = runtime.ForwardResponseMessage + forward_GatewayService_GetProfile_0 = runtime.ForwardResponseMessage + forward_GatewayService_ListUsers_0 = runtime.ForwardResponseMessage + forward_GatewayService_GetUser_0 = runtime.ForwardResponseMessage + forward_GatewayService_CreateUser_0 = runtime.ForwardResponseMessage + forward_GatewayService_UpdateUser_0 = runtime.ForwardResponseMessage + forward_GatewayService_DeleteUser_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/gateway/gateway.pb.validate.go b/api/v1/services/gateway/gateway.pb.validate.go new file mode 100644 index 00000000..4d751b63 --- /dev/null +++ b/api/v1/services/gateway/gateway.pb.validate.go @@ -0,0 +1,36 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: gateway/gateway.proto + +package gateway + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) diff --git a/api/v1/services/gateway/gateway_bridge.pb.go b/api/v1/services/gateway/gateway_bridge.pb.go new file mode 100644 index 00000000..5f6fe475 --- /dev/null +++ b/api/v1/services/gateway/gateway_bridge.pb.go @@ -0,0 +1,566 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: gateway/gateway.proto + +package gateway + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + auth "origadmin/application/admin/api/v1/services/auth" + system "origadmin/application/admin/api/v1/services/system" + types "origadmin/application/admin/api/v1/services/types" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const GatewayServiceLoginBridgeOperation = "/api.v1.services.gateway.GatewayService/Login" +const GatewayServiceGetCaptchaBridgeOperation = "/api.v1.services.gateway.GatewayService/GetCaptcha" +const GatewayServiceGetProfileBridgeOperation = "/api.v1.services.gateway.GatewayService/GetProfile" +const GatewayServiceListUsersBridgeOperation = "/api.v1.services.gateway.GatewayService/ListUsers" +const GatewayServiceGetUserBridgeOperation = "/api.v1.services.gateway.GatewayService/GetUser" +const GatewayServiceCreateUserBridgeOperation = "/api.v1.services.gateway.GatewayService/CreateUser" +const GatewayServiceUpdateUserBridgeOperation = "/api.v1.services.gateway.GatewayService/UpdateUser" +const GatewayServiceDeleteUserBridgeOperation = "/api.v1.services.gateway.GatewayService/DeleteUser" + +type GatewayServiceBridgeServer interface { + // --- Auth Service --- + Login(context.Context, *auth.LoginRequest) (*auth.LoginResponse, error) + GetCaptcha(context.Context, *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) + // --- Me Service --- + GetProfile(context.Context, *auth.GetProfileRequest) (*auth.GetProfileResponse, error) + // --- System User Service --- + ListUsers(context.Context, *system.ListUsersRequest) (*system.ListUsersResponse, error) + GetUser(context.Context, *system.GetUserRequest) (*types.User, error) + CreateUser(context.Context, *system.CreateUserRequest) (*types.User, error) + UpdateUser(context.Context, *system.UpdateUserRequest) (*types.User, error) + DeleteUser(context.Context, *system.DeleteUserRequest) (*system.DeleteUserResponse, error) +} + +type GatewayServiceHooker interface { + GatewayServiceLoginHooker + GatewayServiceGetCaptchaHooker + GatewayServiceGetProfileHooker + GatewayServiceListUsersHooker + GatewayServiceGetUserHooker + GatewayServiceCreateUserHooker + GatewayServiceUpdateUserHooker + GatewayServiceDeleteUserHooker +} + +type GatewayServiceHookedBridger interface { + GatewayServiceHooker + GatewayServiceBridgeServer +} +type GatewayServiceLoginHooker interface { + PrepareLogin(http.Context, *auth.LoginRequest) (context.Context, error) + CompleteLogin(http.Context, *auth.LoginRequest, *auth.LoginResponse) error +} +type GatewayServiceGetCaptchaHooker interface { + PrepareGetCaptcha(http.Context, *auth.GetCaptchaRequest) (context.Context, error) + CompleteGetCaptcha(http.Context, *auth.GetCaptchaRequest, *auth.GetCaptchaResponse) error +} +type GatewayServiceGetProfileHooker interface { + PrepareGetProfile(http.Context, *auth.GetProfileRequest) (context.Context, error) + CompleteGetProfile(http.Context, *auth.GetProfileRequest, *auth.GetProfileResponse) error +} +type GatewayServiceListUsersHooker interface { + PrepareListUsers(http.Context, *system.ListUsersRequest) (context.Context, error) + CompleteListUsers(http.Context, *system.ListUsersRequest, *system.ListUsersResponse) error +} +type GatewayServiceGetUserHooker interface { + PrepareGetUser(http.Context, *system.GetUserRequest) (context.Context, error) + CompleteGetUser(http.Context, *system.GetUserRequest, *types.User) error +} +type GatewayServiceCreateUserHooker interface { + PrepareCreateUser(http.Context, *system.CreateUserRequest) (context.Context, error) + CompleteCreateUser(http.Context, *system.CreateUserRequest, *types.User) error +} +type GatewayServiceUpdateUserHooker interface { + PrepareUpdateUser(http.Context, *system.UpdateUserRequest) (context.Context, error) + CompleteUpdateUser(http.Context, *system.UpdateUserRequest, *types.User) error +} +type GatewayServiceDeleteUserHooker interface { + PrepareDeleteUser(http.Context, *system.DeleteUserRequest) (context.Context, error) + CompleteDeleteUser(http.Context, *system.DeleteUserRequest, *system.DeleteUserResponse) error +} + +func RegisterGatewayServiceBridgeServer(s *http.Server, srv GatewayServiceHookedBridger) { + r := s.Route("/") + r.POST("/api/v1/login", _GatewayService_Login0_Bridge_Handler(srv)) + r.GET("/api/v1/captcha", _GatewayService_GetCaptcha0_Bridge_Handler(srv)) + r.GET("/api/v1/me/profile", _GatewayService_GetProfile0_Bridge_Handler(srv)) + r.GET("/api/v1/users", _GatewayService_ListUsers0_Bridge_Handler(srv)) + r.GET("/api/v1/users/:id", _GatewayService_GetUser0_Bridge_Handler(srv)) + r.POST("/api/v1/users", _GatewayService_CreateUser0_Bridge_Handler(srv)) + r.PUT("/api/v1/users/:user.id", _GatewayService_UpdateUser0_Bridge_Handler(srv)) + r.DELETE("/api/v1/users/:id", _GatewayService_DeleteUser0_Bridge_Handler(srv)) +} + +func _GatewayService_Login0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in auth.LoginRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceLogin) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Login(ctx, req.(*auth.LoginRequest)) + }) + + newctx, err := srv.PrepareLogin(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteLogin(ctx, &in, out.(*auth.LoginResponse)) + } +} + +func _GatewayService_GetCaptcha0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in auth.GetCaptchaRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceGetCaptcha) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetCaptcha(ctx, req.(*auth.GetCaptchaRequest)) + }) + + newctx, err := srv.PrepareGetCaptcha(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetCaptcha(ctx, &in, out.(*auth.GetCaptchaResponse)) + } +} + +func _GatewayService_GetProfile0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in auth.GetProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceGetProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetProfile(ctx, req.(*auth.GetProfileRequest)) + }) + + newctx, err := srv.PrepareGetProfile(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetProfile(ctx, &in, out.(*auth.GetProfileResponse)) + } +} + +func _GatewayService_ListUsers0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in system.ListUsersRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceListUsers) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUsers(ctx, req.(*system.ListUsersRequest)) + }) + + newctx, err := srv.PrepareListUsers(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListUsers(ctx, &in, out.(*system.ListUsersResponse)) + } +} + +func _GatewayService_GetUser0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in system.GetUserRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceGetUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUser(ctx, req.(*system.GetUserRequest)) + }) + + newctx, err := srv.PrepareGetUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetUser(ctx, &in, out.(*types.User)) + } +} + +func _GatewayService_CreateUser0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in system.CreateUserRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceCreateUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateUser(ctx, req.(*system.CreateUserRequest)) + }) + + newctx, err := srv.PrepareCreateUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateUser(ctx, &in, out.(*types.User)) + } +} + +func _GatewayService_UpdateUser0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in system.UpdateUserRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceUpdateUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUser(ctx, req.(*system.UpdateUserRequest)) + }) + + newctx, err := srv.PrepareUpdateUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateUser(ctx, &in, out.(*types.User)) + } +} + +func _GatewayService_DeleteUser0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in system.DeleteUserRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceDeleteUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteUser(ctx, req.(*system.DeleteUserRequest)) + }) + + newctx, err := srv.PrepareDeleteUser(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteUser(ctx, &in, out.(*system.DeleteUserResponse)) + } +} + +// UnimplementedGatewayServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedGatewayServiceHooked struct{} + +func (UnimplementedGatewayServiceHooked) PrepareLogin(ctx http.Context, in *auth.LoginRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedGatewayServiceHooked) CompleteLogin(ctx http.Context, in *auth.LoginRequest, out *auth.LoginResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedGatewayServiceHooked) PrepareGetCaptcha(ctx http.Context, in *auth.GetCaptchaRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedGatewayServiceHooked) CompleteGetCaptcha(ctx http.Context, in *auth.GetCaptchaRequest, out *auth.GetCaptchaResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedGatewayServiceHooked) PrepareGetProfile(ctx http.Context, in *auth.GetProfileRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedGatewayServiceHooked) CompleteGetProfile(ctx http.Context, in *auth.GetProfileRequest, out *auth.GetProfileResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedGatewayServiceHooked) PrepareListUsers(ctx http.Context, in *system.ListUsersRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedGatewayServiceHooked) CompleteListUsers(ctx http.Context, in *system.ListUsersRequest, out *system.ListUsersResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedGatewayServiceHooked) PrepareGetUser(ctx http.Context, in *system.GetUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedGatewayServiceHooked) CompleteGetUser(ctx http.Context, in *system.GetUserRequest, out *types.User) error { + return ctx.Result(200, out) +} + +func (UnimplementedGatewayServiceHooked) PrepareCreateUser(ctx http.Context, in *system.CreateUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedGatewayServiceHooked) CompleteCreateUser(ctx http.Context, in *system.CreateUserRequest, out *types.User) error { + return ctx.Result(200, out) +} + +func (UnimplementedGatewayServiceHooked) PrepareUpdateUser(ctx http.Context, in *system.UpdateUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedGatewayServiceHooked) CompleteUpdateUser(ctx http.Context, in *system.UpdateUserRequest, out *types.User) error { + return ctx.Result(200, out) +} + +func (UnimplementedGatewayServiceHooked) PrepareDeleteUser(ctx http.Context, in *system.DeleteUserRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedGatewayServiceHooked) CompleteDeleteUser(ctx http.Context, in *system.DeleteUserRequest, out *system.DeleteUserResponse) error { + return ctx.Result(200, out) +} + +func WithGatewayServiceHook(h GatewayServiceHooker) func(GatewayServiceBridgeServer) GatewayServiceHookedBridger { + return func(srv GatewayServiceBridgeServer) GatewayServiceHookedBridger { + return GatewayServiceHookedBridge{GatewayServiceBridgeServer: srv, GatewayServiceHooker: h} + } +} + +// GatewayServiceHookedBridge is a bridge between the HTTP and gRPC implementations of GatewayService. +// It implements the HTTP and gRPC implementations of GatewayService. +// It forwards requests and responses between the two implementations. +type GatewayServiceHookedBridge struct { + GatewayServiceBridgeServer + GatewayServiceHooker +} + +type GatewayServiceHTTPBridgeImpl struct { + client GatewayServiceHTTPClient +} + +func NewGatewayServiceHTTPBridge(client *http.Client) GatewayServiceHTTPServer { + return &GatewayServiceHTTPBridgeImpl{client: NewGatewayServiceHTTPClient(client)} +} + +func (c *GatewayServiceHTTPBridgeImpl) Login(ctx context.Context, in *auth.LoginRequest) (*auth.LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *GatewayServiceHTTPBridgeImpl) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) +} + +func (c *GatewayServiceHTTPBridgeImpl) GetProfile(ctx context.Context, in *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { + return c.client.GetProfile(ctx, in) +} + +func (c *GatewayServiceHTTPBridgeImpl) ListUsers(ctx context.Context, in *system.ListUsersRequest) (*system.ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *GatewayServiceHTTPBridgeImpl) GetUser(ctx context.Context, in *system.GetUserRequest) (*types.User, error) { + return c.client.GetUser(ctx, in) +} + +func (c *GatewayServiceHTTPBridgeImpl) CreateUser(ctx context.Context, in *system.CreateUserRequest) (*types.User, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *GatewayServiceHTTPBridgeImpl) UpdateUser(ctx context.Context, in *system.UpdateUserRequest) (*types.User, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *GatewayServiceHTTPBridgeImpl) DeleteUser(ctx context.Context, in *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +type GatewayServiceBridgeImpl struct { + client GatewayServiceClient +} + +func NewGatewayServiceBridge(client grpc.ClientConnInterface) GatewayServiceServer { + return &GatewayServiceBridgeImpl{client: NewGatewayServiceClient(client)} +} + +func (c *GatewayServiceBridgeImpl) Login(ctx context.Context, in *auth.LoginRequest) (*auth.LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *GatewayServiceBridgeImpl) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) +} + +func (c *GatewayServiceBridgeImpl) GetProfile(ctx context.Context, in *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { + return c.client.GetProfile(ctx, in) +} + +func (c *GatewayServiceBridgeImpl) ListUsers(ctx context.Context, in *system.ListUsersRequest) (*system.ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *GatewayServiceBridgeImpl) GetUser(ctx context.Context, in *system.GetUserRequest) (*types.User, error) { + return c.client.GetUser(ctx, in) +} + +func (c *GatewayServiceBridgeImpl) CreateUser(ctx context.Context, in *system.CreateUserRequest) (*types.User, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *GatewayServiceBridgeImpl) UpdateUser(ctx context.Context, in *system.UpdateUserRequest) (*types.User, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *GatewayServiceBridgeImpl) DeleteUser(ctx context.Context, in *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +func (c *GatewayServiceBridgeImpl) mustEmbedUnimplementedGatewayServiceServer() {} + +type GatewayServiceGRPC2HTTPBridgeImpl struct { + client GatewayServiceClient +} + +func NewGatewayServiceGRPC2HTTP(client grpc.ClientConnInterface) GatewayServiceHTTPServer { + return &GatewayServiceGRPC2HTTPBridgeImpl{client: NewGatewayServiceClient(client)} +} + +func (c *GatewayServiceGRPC2HTTPBridgeImpl) Login(ctx context.Context, in *auth.LoginRequest) (*auth.LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *GatewayServiceGRPC2HTTPBridgeImpl) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) +} + +func (c *GatewayServiceGRPC2HTTPBridgeImpl) GetProfile(ctx context.Context, in *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { + return c.client.GetProfile(ctx, in) +} + +func (c *GatewayServiceGRPC2HTTPBridgeImpl) ListUsers(ctx context.Context, in *system.ListUsersRequest) (*system.ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *GatewayServiceGRPC2HTTPBridgeImpl) GetUser(ctx context.Context, in *system.GetUserRequest) (*types.User, error) { + return c.client.GetUser(ctx, in) +} + +func (c *GatewayServiceGRPC2HTTPBridgeImpl) CreateUser(ctx context.Context, in *system.CreateUserRequest) (*types.User, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *GatewayServiceGRPC2HTTPBridgeImpl) UpdateUser(ctx context.Context, in *system.UpdateUserRequest) (*types.User, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *GatewayServiceGRPC2HTTPBridgeImpl) DeleteUser(ctx context.Context, in *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +type GatewayServiceHTTP2GRPCBridgeImpl struct { + client GatewayServiceHTTPClient +} + +func NewGatewayServiceHTTP2GRPC(client *http.Client) GatewayServiceServer { + return &GatewayServiceHTTP2GRPCBridgeImpl{client: NewGatewayServiceHTTPClient(client)} +} + +func (c *GatewayServiceHTTP2GRPCBridgeImpl) Login(ctx context.Context, in *auth.LoginRequest) (*auth.LoginResponse, error) { + return c.client.Login(ctx, in) +} + +func (c *GatewayServiceHTTP2GRPCBridgeImpl) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { + return c.client.GetCaptcha(ctx, in) +} + +func (c *GatewayServiceHTTP2GRPCBridgeImpl) GetProfile(ctx context.Context, in *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { + return c.client.GetProfile(ctx, in) +} + +func (c *GatewayServiceHTTP2GRPCBridgeImpl) ListUsers(ctx context.Context, in *system.ListUsersRequest) (*system.ListUsersResponse, error) { + return c.client.ListUsers(ctx, in) +} + +func (c *GatewayServiceHTTP2GRPCBridgeImpl) GetUser(ctx context.Context, in *system.GetUserRequest) (*types.User, error) { + return c.client.GetUser(ctx, in) +} + +func (c *GatewayServiceHTTP2GRPCBridgeImpl) CreateUser(ctx context.Context, in *system.CreateUserRequest) (*types.User, error) { + return c.client.CreateUser(ctx, in) +} + +func (c *GatewayServiceHTTP2GRPCBridgeImpl) UpdateUser(ctx context.Context, in *system.UpdateUserRequest) (*types.User, error) { + return c.client.UpdateUser(ctx, in) +} + +func (c *GatewayServiceHTTP2GRPCBridgeImpl) DeleteUser(ctx context.Context, in *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { + return c.client.DeleteUser(ctx, in) +} + +func (c *GatewayServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedGatewayServiceServer() {} diff --git a/api/v1/services/gateway/gateway_grpc.pb.go b/api/v1/services/gateway/gateway_grpc.pb.go new file mode 100644 index 00000000..308eb1d4 --- /dev/null +++ b/api/v1/services/gateway/gateway_grpc.pb.go @@ -0,0 +1,402 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: gateway/gateway.proto + +package gateway + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + auth "origadmin/application/admin/api/v1/services/auth" + system "origadmin/application/admin/api/v1/services/system" + types "origadmin/application/admin/api/v1/services/types" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + GatewayService_Login_FullMethodName = "/api.v1.services.gateway.GatewayService/Login" + GatewayService_GetCaptcha_FullMethodName = "/api.v1.services.gateway.GatewayService/GetCaptcha" + GatewayService_GetProfile_FullMethodName = "/api.v1.services.gateway.GatewayService/GetProfile" + GatewayService_ListUsers_FullMethodName = "/api.v1.services.gateway.GatewayService/ListUsers" + GatewayService_GetUser_FullMethodName = "/api.v1.services.gateway.GatewayService/GetUser" + GatewayService_CreateUser_FullMethodName = "/api.v1.services.gateway.GatewayService/CreateUser" + GatewayService_UpdateUser_FullMethodName = "/api.v1.services.gateway.GatewayService/UpdateUser" + GatewayService_DeleteUser_FullMethodName = "/api.v1.services.gateway.GatewayService/DeleteUser" +) + +// GatewayServiceClient is the client API for GatewayService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// GatewayService is the public-facing API gateway. +// It proxies requests to backend services. +type GatewayServiceClient interface { + // --- Auth Service --- + Login(ctx context.Context, in *auth.LoginRequest, opts ...grpc.CallOption) (*auth.LoginResponse, error) + GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest, opts ...grpc.CallOption) (*auth.GetCaptchaResponse, error) + // --- Me Service --- + GetProfile(ctx context.Context, in *auth.GetProfileRequest, opts ...grpc.CallOption) (*auth.GetProfileResponse, error) + // --- System User Service --- + ListUsers(ctx context.Context, in *system.ListUsersRequest, opts ...grpc.CallOption) (*system.ListUsersResponse, error) + GetUser(ctx context.Context, in *system.GetUserRequest, opts ...grpc.CallOption) (*types.User, error) + CreateUser(ctx context.Context, in *system.CreateUserRequest, opts ...grpc.CallOption) (*types.User, error) + UpdateUser(ctx context.Context, in *system.UpdateUserRequest, opts ...grpc.CallOption) (*types.User, error) + DeleteUser(ctx context.Context, in *system.DeleteUserRequest, opts ...grpc.CallOption) (*system.DeleteUserResponse, error) +} + +type gatewayServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewGatewayServiceClient(cc grpc.ClientConnInterface) GatewayServiceClient { + return &gatewayServiceClient{cc} +} + +func (c *gatewayServiceClient) Login(ctx context.Context, in *auth.LoginRequest, opts ...grpc.CallOption) (*auth.LoginResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(auth.LoginResponse) + err := c.cc.Invoke(ctx, GatewayService_Login_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayServiceClient) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest, opts ...grpc.CallOption) (*auth.GetCaptchaResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(auth.GetCaptchaResponse) + err := c.cc.Invoke(ctx, GatewayService_GetCaptcha_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayServiceClient) GetProfile(ctx context.Context, in *auth.GetProfileRequest, opts ...grpc.CallOption) (*auth.GetProfileResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(auth.GetProfileResponse) + err := c.cc.Invoke(ctx, GatewayService_GetProfile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayServiceClient) ListUsers(ctx context.Context, in *system.ListUsersRequest, opts ...grpc.CallOption) (*system.ListUsersResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(system.ListUsersResponse) + err := c.cc.Invoke(ctx, GatewayService_ListUsers_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayServiceClient) GetUser(ctx context.Context, in *system.GetUserRequest, opts ...grpc.CallOption) (*types.User, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(types.User) + err := c.cc.Invoke(ctx, GatewayService_GetUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayServiceClient) CreateUser(ctx context.Context, in *system.CreateUserRequest, opts ...grpc.CallOption) (*types.User, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(types.User) + err := c.cc.Invoke(ctx, GatewayService_CreateUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayServiceClient) UpdateUser(ctx context.Context, in *system.UpdateUserRequest, opts ...grpc.CallOption) (*types.User, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(types.User) + err := c.cc.Invoke(ctx, GatewayService_UpdateUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *gatewayServiceClient) DeleteUser(ctx context.Context, in *system.DeleteUserRequest, opts ...grpc.CallOption) (*system.DeleteUserResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(system.DeleteUserResponse) + err := c.cc.Invoke(ctx, GatewayService_DeleteUser_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// GatewayServiceServer is the server API for GatewayService service. +// All implementations must embed UnimplementedGatewayServiceServer +// for forward compatibility. +// +// GatewayService is the public-facing API gateway. +// It proxies requests to backend services. +type GatewayServiceServer interface { + // --- Auth Service --- + Login(context.Context, *auth.LoginRequest) (*auth.LoginResponse, error) + GetCaptcha(context.Context, *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) + // --- Me Service --- + GetProfile(context.Context, *auth.GetProfileRequest) (*auth.GetProfileResponse, error) + // --- System User Service --- + ListUsers(context.Context, *system.ListUsersRequest) (*system.ListUsersResponse, error) + GetUser(context.Context, *system.GetUserRequest) (*types.User, error) + CreateUser(context.Context, *system.CreateUserRequest) (*types.User, error) + UpdateUser(context.Context, *system.UpdateUserRequest) (*types.User, error) + DeleteUser(context.Context, *system.DeleteUserRequest) (*system.DeleteUserResponse, error) + mustEmbedUnimplementedGatewayServiceServer() +} + +// UnimplementedGatewayServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedGatewayServiceServer struct{} + +func (UnimplementedGatewayServiceServer) Login(context.Context, *auth.LoginRequest) (*auth.LoginResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") +} +func (UnimplementedGatewayServiceServer) GetCaptcha(context.Context, *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCaptcha not implemented") +} +func (UnimplementedGatewayServiceServer) GetProfile(context.Context, *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProfile not implemented") +} +func (UnimplementedGatewayServiceServer) ListUsers(context.Context, *system.ListUsersRequest) (*system.ListUsersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListUsers not implemented") +} +func (UnimplementedGatewayServiceServer) GetUser(context.Context, *system.GetUserRequest) (*types.User, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented") +} +func (UnimplementedGatewayServiceServer) CreateUser(context.Context, *system.CreateUserRequest) (*types.User, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateUser not implemented") +} +func (UnimplementedGatewayServiceServer) UpdateUser(context.Context, *system.UpdateUserRequest) (*types.User, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateUser not implemented") +} +func (UnimplementedGatewayServiceServer) DeleteUser(context.Context, *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteUser not implemented") +} +func (UnimplementedGatewayServiceServer) mustEmbedUnimplementedGatewayServiceServer() {} +func (UnimplementedGatewayServiceServer) testEmbeddedByValue() {} + +// UnsafeGatewayServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to GatewayServiceServer will +// result in compilation errors. +type UnsafeGatewayServiceServer interface { + mustEmbedUnimplementedGatewayServiceServer() +} + +func RegisterGatewayServiceServer(s grpc.ServiceRegistrar, srv GatewayServiceServer) { + // If the following call pancis, it indicates UnimplementedGatewayServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&GatewayService_ServiceDesc, srv) +} + +func _GatewayService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(auth.LoginRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayServiceServer).Login(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: GatewayService_Login_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayServiceServer).Login(ctx, req.(*auth.LoginRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayService_GetCaptcha_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(auth.GetCaptchaRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayServiceServer).GetCaptcha(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: GatewayService_GetCaptcha_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayServiceServer).GetCaptcha(ctx, req.(*auth.GetCaptchaRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayService_GetProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(auth.GetProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayServiceServer).GetProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: GatewayService_GetProfile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayServiceServer).GetProfile(ctx, req.(*auth.GetProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayService_ListUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(system.ListUsersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayServiceServer).ListUsers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: GatewayService_ListUsers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayServiceServer).ListUsers(ctx, req.(*system.ListUsersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(system.GetUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayServiceServer).GetUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: GatewayService_GetUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayServiceServer).GetUser(ctx, req.(*system.GetUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(system.CreateUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayServiceServer).CreateUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: GatewayService_CreateUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayServiceServer).CreateUser(ctx, req.(*system.CreateUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayService_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(system.UpdateUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayServiceServer).UpdateUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: GatewayService_UpdateUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayServiceServer).UpdateUser(ctx, req.(*system.UpdateUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _GatewayService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(system.DeleteUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GatewayServiceServer).DeleteUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: GatewayService_DeleteUser_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GatewayServiceServer).DeleteUser(ctx, req.(*system.DeleteUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// GatewayService_ServiceDesc is the grpc.ServiceDesc for GatewayService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var GatewayService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.gateway.GatewayService", + HandlerType: (*GatewayServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Login", + Handler: _GatewayService_Login_Handler, + }, + { + MethodName: "GetCaptcha", + Handler: _GatewayService_GetCaptcha_Handler, + }, + { + MethodName: "GetProfile", + Handler: _GatewayService_GetProfile_Handler, + }, + { + MethodName: "ListUsers", + Handler: _GatewayService_ListUsers_Handler, + }, + { + MethodName: "GetUser", + Handler: _GatewayService_GetUser_Handler, + }, + { + MethodName: "CreateUser", + Handler: _GatewayService_CreateUser_Handler, + }, + { + MethodName: "UpdateUser", + Handler: _GatewayService_UpdateUser_Handler, + }, + { + MethodName: "DeleteUser", + Handler: _GatewayService_DeleteUser_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "gateway/gateway.proto", +} diff --git a/api/v1/services/gateway/gateway_http.pb.go b/api/v1/services/gateway/gateway_http.pb.go new file mode 100644 index 00000000..bcd2ee40 --- /dev/null +++ b/api/v1/services/gateway/gateway_http.pb.go @@ -0,0 +1,357 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: gateway/gateway.proto + +package gateway + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" + auth "origadmin/application/admin/api/v1/services/auth" + system "origadmin/application/admin/api/v1/services/system" + types "origadmin/application/admin/api/v1/services/types" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationGatewayServiceCreateUser = "/api.v1.services.gateway.GatewayService/CreateUser" +const OperationGatewayServiceDeleteUser = "/api.v1.services.gateway.GatewayService/DeleteUser" +const OperationGatewayServiceGetCaptcha = "/api.v1.services.gateway.GatewayService/GetCaptcha" +const OperationGatewayServiceGetProfile = "/api.v1.services.gateway.GatewayService/GetProfile" +const OperationGatewayServiceGetUser = "/api.v1.services.gateway.GatewayService/GetUser" +const OperationGatewayServiceListUsers = "/api.v1.services.gateway.GatewayService/ListUsers" +const OperationGatewayServiceLogin = "/api.v1.services.gateway.GatewayService/Login" +const OperationGatewayServiceUpdateUser = "/api.v1.services.gateway.GatewayService/UpdateUser" + +type GatewayServiceHTTPServer interface { + CreateUser(context.Context, *system.CreateUserRequest) (*types.User, error) + DeleteUser(context.Context, *system.DeleteUserRequest) (*system.DeleteUserResponse, error) + GetCaptcha(context.Context, *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) + // GetProfile --- Me Service --- + GetProfile(context.Context, *auth.GetProfileRequest) (*auth.GetProfileResponse, error) + GetUser(context.Context, *system.GetUserRequest) (*types.User, error) + // ListUsers --- System User Service --- + ListUsers(context.Context, *system.ListUsersRequest) (*system.ListUsersResponse, error) + // Login --- Auth Service --- + Login(context.Context, *auth.LoginRequest) (*auth.LoginResponse, error) + UpdateUser(context.Context, *system.UpdateUserRequest) (*types.User, error) +} + +func RegisterGatewayServiceHTTPServer(s *http.Server, srv GatewayServiceHTTPServer) { + r := s.Route("/") + r.POST("/api/v1/login", _GatewayService_Login0_HTTP_Handler(srv)) + r.GET("/api/v1/captcha", _GatewayService_GetCaptcha0_HTTP_Handler(srv)) + r.GET("/api/v1/me/profile", _GatewayService_GetProfile0_HTTP_Handler(srv)) + r.GET("/api/v1/users", _GatewayService_ListUsers0_HTTP_Handler(srv)) + r.GET("/api/v1/users/{id}", _GatewayService_GetUser0_HTTP_Handler(srv)) + r.POST("/api/v1/users", _GatewayService_CreateUser0_HTTP_Handler(srv)) + r.PUT("/api/v1/users/{user.id}", _GatewayService_UpdateUser0_HTTP_Handler(srv)) + r.DELETE("/api/v1/users/{id}", _GatewayService_DeleteUser0_HTTP_Handler(srv)) +} + +func _GatewayService_Login0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in auth.LoginRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceLogin) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.Login(ctx, req.(*auth.LoginRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*auth.LoginResponse) + return ctx.Result(200, reply) + } +} + +func _GatewayService_GetCaptcha0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in auth.GetCaptchaRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceGetCaptcha) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetCaptcha(ctx, req.(*auth.GetCaptchaRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*auth.GetCaptchaResponse) + return ctx.Result(200, reply) + } +} + +func _GatewayService_GetProfile0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in auth.GetProfileRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceGetProfile) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetProfile(ctx, req.(*auth.GetProfileRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*auth.GetProfileResponse) + return ctx.Result(200, reply) + } +} + +func _GatewayService_ListUsers0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in system.ListUsersRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceListUsers) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListUsers(ctx, req.(*system.ListUsersRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*system.ListUsersResponse) + return ctx.Result(200, reply) + } +} + +func _GatewayService_GetUser0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in system.GetUserRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceGetUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetUser(ctx, req.(*system.GetUserRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*types.User) + return ctx.Result(200, reply) + } +} + +func _GatewayService_CreateUser0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in system.CreateUserRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceCreateUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateUser(ctx, req.(*system.CreateUserRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*types.User) + return ctx.Result(200, reply) + } +} + +func _GatewayService_UpdateUser0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in system.UpdateUserRequest + if err := ctx.Bind(&in.User); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceUpdateUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateUser(ctx, req.(*system.UpdateUserRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*types.User) + return ctx.Result(200, reply) + } +} + +func _GatewayService_DeleteUser0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in system.DeleteUserRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationGatewayServiceDeleteUser) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteUser(ctx, req.(*system.DeleteUserRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*system.DeleteUserResponse) + return ctx.Result(200, reply) + } +} + +type GatewayServiceHTTPClient interface { + CreateUser(ctx context.Context, req *system.CreateUserRequest, opts ...http.CallOption) (rsp *types.User, err error) + DeleteUser(ctx context.Context, req *system.DeleteUserRequest, opts ...http.CallOption) (rsp *system.DeleteUserResponse, err error) + GetCaptcha(ctx context.Context, req *auth.GetCaptchaRequest, opts ...http.CallOption) (rsp *auth.GetCaptchaResponse, err error) + // GetProfile --- Me Service --- + GetProfile(ctx context.Context, req *auth.GetProfileRequest, opts ...http.CallOption) (rsp *auth.GetProfileResponse, err error) + GetUser(ctx context.Context, req *system.GetUserRequest, opts ...http.CallOption) (rsp *types.User, err error) + // ListUsers --- System User Service --- + ListUsers(ctx context.Context, req *system.ListUsersRequest, opts ...http.CallOption) (rsp *system.ListUsersResponse, err error) + // Login --- Auth Service --- + Login(ctx context.Context, req *auth.LoginRequest, opts ...http.CallOption) (rsp *auth.LoginResponse, err error) + UpdateUser(ctx context.Context, req *system.UpdateUserRequest, opts ...http.CallOption) (rsp *types.User, err error) +} + +type GatewayServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewGatewayServiceHTTPClient(client *http.Client) GatewayServiceHTTPClient { + return &GatewayServiceHTTPClientImpl{client} +} + +func (c *GatewayServiceHTTPClientImpl) CreateUser(ctx context.Context, in *system.CreateUserRequest, opts ...http.CallOption) (*types.User, error) { + var out types.User + pattern := "/api/v1/users" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationGatewayServiceCreateUser)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *GatewayServiceHTTPClientImpl) DeleteUser(ctx context.Context, in *system.DeleteUserRequest, opts ...http.CallOption) (*system.DeleteUserResponse, error) { + var out system.DeleteUserResponse + pattern := "/api/v1/users/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationGatewayServiceDeleteUser)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *GatewayServiceHTTPClientImpl) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest, opts ...http.CallOption) (*auth.GetCaptchaResponse, error) { + var out auth.GetCaptchaResponse + pattern := "/api/v1/captcha" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationGatewayServiceGetCaptcha)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// GetProfile --- Me Service --- +func (c *GatewayServiceHTTPClientImpl) GetProfile(ctx context.Context, in *auth.GetProfileRequest, opts ...http.CallOption) (*auth.GetProfileResponse, error) { + var out auth.GetProfileResponse + pattern := "/api/v1/me/profile" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationGatewayServiceGetProfile)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *GatewayServiceHTTPClientImpl) GetUser(ctx context.Context, in *system.GetUserRequest, opts ...http.CallOption) (*types.User, error) { + var out types.User + pattern := "/api/v1/users/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationGatewayServiceGetUser)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ListUsers --- System User Service --- +func (c *GatewayServiceHTTPClientImpl) ListUsers(ctx context.Context, in *system.ListUsersRequest, opts ...http.CallOption) (*system.ListUsersResponse, error) { + var out system.ListUsersResponse + pattern := "/api/v1/users" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationGatewayServiceListUsers)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// Login --- Auth Service --- +func (c *GatewayServiceHTTPClientImpl) Login(ctx context.Context, in *auth.LoginRequest, opts ...http.CallOption) (*auth.LoginResponse, error) { + var out auth.LoginResponse + pattern := "/api/v1/login" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationGatewayServiceLogin)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +func (c *GatewayServiceHTTPClientImpl) UpdateUser(ctx context.Context, in *system.UpdateUserRequest, opts ...http.CallOption) (*types.User, error) { + var out types.User + pattern := "/api/v1/users/{user.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationGatewayServiceUpdateUser)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/api/v1/services/system/view.pb.go b/api/v1/services/system/view.pb.go new file mode 100644 index 00000000..666468de --- /dev/null +++ b/api/v1/services/system/view.pb.go @@ -0,0 +1,724 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc (unknown) +// source: system/view.proto + +package system + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + emptypb "google.golang.org/protobuf/types/known/emptypb" + types "origadmin/application/admin/api/v1/services/types" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Request message for ViewService.ListViews. +type ListViewsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Page int32 `protobuf:"varint,2,opt,name=page,proto3" json:"page,omitempty"` + PageSize int32 `protobuf:"varint,3,opt,name=page_size,proto3" json:"page_size,omitempty"` + PageToken string `protobuf:"bytes,4,opt,name=page_token,proto3" json:"page_token,omitempty"` + NoPaging bool `protobuf:"varint,5,opt,name=no_paging,proto3" json:"no_paging,omitempty"` + OnlyCount bool `protobuf:"varint,6,opt,name=only_count,proto3" json:"only_count,omitempty"` + Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` + Scope string `protobuf:"bytes,8,opt,name=scope,proto3" json:"scope,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListViewsRequest) Reset() { + *x = ListViewsRequest{} + mi := &file_system_view_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListViewsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListViewsRequest) ProtoMessage() {} + +func (x *ListViewsRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_view_proto_msgTypes[0] + 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 ListViewsRequest.ProtoReflect.Descriptor instead. +func (*ListViewsRequest) Descriptor() ([]byte, []int) { + return file_system_view_proto_rawDescGZIP(), []int{0} +} + +func (x *ListViewsRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ListViewsRequest) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListViewsRequest) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListViewsRequest) GetPageToken() string { + if x != nil { + return x.PageToken + } + return "" +} + +func (x *ListViewsRequest) GetNoPaging() bool { + if x != nil { + return x.NoPaging + } + return false +} + +func (x *ListViewsRequest) GetOnlyCount() bool { + if x != nil { + return x.OnlyCount + } + return false +} + +func (x *ListViewsRequest) GetKeyword() string { + if x != nil { + return x.Keyword + } + return "" +} + +func (x *ListViewsRequest) GetScope() string { + if x != nil { + return x.Scope + } + return "" +} + +// Response message for ViewService.ListViews. +type ListViewsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Total int32 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"` + Views []*types.View `protobuf:"bytes,2,rep,name=views,proto3" json:"views,omitempty"` + Page int32 `protobuf:"varint,3,opt,name=page,proto3" json:"page,omitempty"` + PageSize int32 `protobuf:"varint,4,opt,name=page_size,proto3" json:"page_size,omitempty"` + NextPageToken string `protobuf:"bytes,5,opt,name=next_page_token,proto3" json:"next_page_token,omitempty"` + Extra *anypb.Any `protobuf:"bytes,6,opt,name=extra,proto3,oneof" json:"extra,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ListViewsResponse) Reset() { + *x = ListViewsResponse{} + mi := &file_system_view_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListViewsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListViewsResponse) ProtoMessage() {} + +func (x *ListViewsResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_view_proto_msgTypes[1] + 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 ListViewsResponse.ProtoReflect.Descriptor instead. +func (*ListViewsResponse) Descriptor() ([]byte, []int) { + return file_system_view_proto_rawDescGZIP(), []int{1} +} + +func (x *ListViewsResponse) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +func (x *ListViewsResponse) GetViews() []*types.View { + if x != nil { + return x.Views + } + return nil +} + +func (x *ListViewsResponse) GetPage() int32 { + if x != nil { + return x.Page + } + return 0 +} + +func (x *ListViewsResponse) GetPageSize() int32 { + if x != nil { + return x.PageSize + } + return 0 +} + +func (x *ListViewsResponse) GetNextPageToken() string { + if x != nil { + return x.NextPageToken + } + return "" +} + +func (x *ListViewsResponse) GetExtra() *anypb.Any { + if x != nil { + return x.Extra + } + return nil +} + +// Request message for ViewService.GetView. +type GetViewRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetViewRequest) Reset() { + *x = GetViewRequest{} + mi := &file_system_view_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetViewRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetViewRequest) ProtoMessage() {} + +func (x *GetViewRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_view_proto_msgTypes[2] + 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 GetViewRequest.ProtoReflect.Descriptor instead. +func (*GetViewRequest) Descriptor() ([]byte, []int) { + return file_system_view_proto_rawDescGZIP(), []int{2} +} + +func (x *GetViewRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// Response message for ViewService.GetView. +type GetViewResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + View *types.View `protobuf:"bytes,1,opt,name=view,proto3" json:"view,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetViewResponse) Reset() { + *x = GetViewResponse{} + mi := &file_system_view_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetViewResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetViewResponse) ProtoMessage() {} + +func (x *GetViewResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_view_proto_msgTypes[3] + 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 GetViewResponse.ProtoReflect.Descriptor instead. +func (*GetViewResponse) Descriptor() ([]byte, []int) { + return file_system_view_proto_rawDescGZIP(), []int{3} +} + +func (x *GetViewResponse) GetView() *types.View { + if x != nil { + return x.View + } + return nil +} + +// Request message for ViewService.CreateView. +type CreateViewRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"` + ViewId string `protobuf:"bytes,2,opt,name=view_id,json=viewId,proto3" json:"view_id,omitempty"` + View *types.View `protobuf:"bytes,3,opt,name=view,proto3" json:"view,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateViewRequest) Reset() { + *x = CreateViewRequest{} + mi := &file_system_view_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateViewRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateViewRequest) ProtoMessage() {} + +func (x *CreateViewRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_view_proto_msgTypes[4] + 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 CreateViewRequest.ProtoReflect.Descriptor instead. +func (*CreateViewRequest) Descriptor() ([]byte, []int) { + return file_system_view_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateViewRequest) GetParent() string { + if x != nil { + return x.Parent + } + return "" +} + +func (x *CreateViewRequest) GetViewId() string { + if x != nil { + return x.ViewId + } + return "" +} + +func (x *CreateViewRequest) GetView() *types.View { + if x != nil { + return x.View + } + return nil +} + +// Response message for ViewService.CreateView. +type CreateViewResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + View *types.View `protobuf:"bytes,1,opt,name=view,proto3" json:"view,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateViewResponse) Reset() { + *x = CreateViewResponse{} + mi := &file_system_view_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateViewResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateViewResponse) ProtoMessage() {} + +func (x *CreateViewResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_view_proto_msgTypes[5] + 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 CreateViewResponse.ProtoReflect.Descriptor instead. +func (*CreateViewResponse) Descriptor() ([]byte, []int) { + return file_system_view_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateViewResponse) GetView() *types.View { + if x != nil { + return x.View + } + return nil +} + +// Request message for ViewService.UpdateView. +type UpdateViewRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + View *types.View `protobuf:"bytes,1,opt,name=view,proto3" json:"view,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateViewRequest) Reset() { + *x = UpdateViewRequest{} + mi := &file_system_view_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateViewRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateViewRequest) ProtoMessage() {} + +func (x *UpdateViewRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_view_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 UpdateViewRequest.ProtoReflect.Descriptor instead. +func (*UpdateViewRequest) Descriptor() ([]byte, []int) { + return file_system_view_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateViewRequest) GetView() *types.View { + if x != nil { + return x.View + } + return nil +} + +// Response message for ViewService.UpdateView. +type UpdateViewResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + View *types.View `protobuf:"bytes,1,opt,name=view,proto3" json:"view,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *UpdateViewResponse) Reset() { + *x = UpdateViewResponse{} + mi := &file_system_view_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *UpdateViewResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateViewResponse) ProtoMessage() {} + +func (x *UpdateViewResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_view_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UpdateViewResponse.ProtoReflect.Descriptor instead. +func (*UpdateViewResponse) Descriptor() ([]byte, []int) { + return file_system_view_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateViewResponse) GetView() *types.View { + if x != nil { + return x.View + } + return nil +} + +// Request message for ViewService.DeleteView. +type DeleteViewRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteViewRequest) Reset() { + *x = DeleteViewRequest{} + mi := &file_system_view_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteViewRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteViewRequest) ProtoMessage() {} + +func (x *DeleteViewRequest) ProtoReflect() protoreflect.Message { + mi := &file_system_view_proto_msgTypes[8] + 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 DeleteViewRequest.ProtoReflect.Descriptor instead. +func (*DeleteViewRequest) Descriptor() ([]byte, []int) { + return file_system_view_proto_rawDescGZIP(), []int{8} +} + +func (x *DeleteViewRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// Response message for ViewService.DeleteView. +type DeleteViewResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *DeleteViewResponse) Reset() { + *x = DeleteViewResponse{} + mi := &file_system_view_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *DeleteViewResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteViewResponse) ProtoMessage() {} + +func (x *DeleteViewResponse) ProtoReflect() protoreflect.Message { + mi := &file_system_view_proto_msgTypes[9] + 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 DeleteViewResponse.ProtoReflect.Descriptor instead. +func (*DeleteViewResponse) Descriptor() ([]byte, []int) { + return file_system_view_proto_rawDescGZIP(), []int{9} +} + +func (x *DeleteViewResponse) GetEmpty() *emptypb.Empty { + if x != nil { + return x.Empty + } + return nil +} + +var File_system_view_proto protoreflect.FileDescriptor + +const file_system_view_proto_rawDesc = "" + + "\n" + + "\x11system/view.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xe2\x01\n" + + "\x10ListViewsRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x03 \x01(\x05R\tpage_size\x12\x1e\n" + + "\n" + + "page_token\x18\x04 \x01(\tR\n" + + "page_token\x12\x1c\n" + + "\tno_paging\x18\x05 \x01(\bR\tno_paging\x12\x1e\n" + + "\n" + + "only_count\x18\x06 \x01(\bR\n" + + "only_count\x12\x18\n" + + "\akeyword\x18\a \x01(\tR\akeyword\x12\x14\n" + + "\x05scope\x18\b \x01(\tR\x05scope\"\xf3\x01\n" + + "\x11ListViewsResponse\x12\x14\n" + + "\x05total\x18\x01 \x01(\x05R\x05total\x121\n" + + "\x05views\x18\x02 \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x12\x12\n" + + "\x04page\x18\x03 \x01(\x05R\x04page\x12\x1c\n" + + "\tpage_size\x18\x04 \x01(\x05R\tpage_size\x12(\n" + + "\x0fnext_page_token\x18\x05 \x01(\tR\x0fnext_page_token\x12/\n" + + "\x05extra\x18\x06 \x01(\v2\x14.google.protobuf.AnyH\x00R\x05extra\x88\x01\x01B\b\n" + + "\x06_extra\" \n" + + "\x0eGetViewRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x0fGetViewResponse\x12/\n" + + "\x04view\x18\x01 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"u\n" + + "\x11CreateViewRequest\x12\x16\n" + + "\x06parent\x18\x01 \x01(\tR\x06parent\x12\x17\n" + + "\aview_id\x18\x02 \x01(\tR\x06viewId\x12/\n" + + "\x04view\x18\x03 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"E\n" + + "\x12CreateViewResponse\x12/\n" + + "\x04view\x18\x01 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"D\n" + + "\x11UpdateViewRequest\x12/\n" + + "\x04view\x18\x01 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"E\n" + + "\x12UpdateViewResponse\x12/\n" + + "\x04view\x18\x01 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"#\n" + + "\x11DeleteViewRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + + "\x12DeleteViewResponse\x12,\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xfc\x04\n" + + "\vViewService\x12t\n" + + "\tListViews\x12(.api.v1.services.system.ListViewsRequest\x1a).api.v1.services.system.ListViewsResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + + "/sys/views\x12s\n" + + "\aGetView\x12&.api.v1.services.system.GetViewRequest\x1a'.api.v1.services.system.GetViewResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/views/{id}\x12z\n" + + "\n" + + "CreateView\x12).api.v1.services.system.CreateViewRequest\x1a*.api.v1.services.system.CreateViewResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + + "/sys/views\x12\x87\x01\n" + + "\n" + + "UpdateView\x12).api.v1.services.system.UpdateViewRequest\x1a*.api.v1.services.system.UpdateViewResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04view\x1a\x14/sys/views/{view.id}\x12|\n" + + "\n" + + "DeleteView\x12).api.v1.services.system.DeleteViewRequest\x1a*.api.v1.services.system.DeleteViewResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/views/{id}B\xde\x01\n" + + "\x1acom.api.v1.services.systemB\tViewProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" + +var ( + file_system_view_proto_rawDescOnce sync.Once + file_system_view_proto_rawDescData []byte +) + +func file_system_view_proto_rawDescGZIP() []byte { + file_system_view_proto_rawDescOnce.Do(func() { + file_system_view_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_system_view_proto_rawDesc), len(file_system_view_proto_rawDesc))) + }) + return file_system_view_proto_rawDescData +} + +var file_system_view_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_system_view_proto_goTypes = []any{ + (*ListViewsRequest)(nil), // 0: api.v1.services.system.ListViewsRequest + (*ListViewsResponse)(nil), // 1: api.v1.services.system.ListViewsResponse + (*GetViewRequest)(nil), // 2: api.v1.services.system.GetViewRequest + (*GetViewResponse)(nil), // 3: api.v1.services.system.GetViewResponse + (*CreateViewRequest)(nil), // 4: api.v1.services.system.CreateViewRequest + (*CreateViewResponse)(nil), // 5: api.v1.services.system.CreateViewResponse + (*UpdateViewRequest)(nil), // 6: api.v1.services.system.UpdateViewRequest + (*UpdateViewResponse)(nil), // 7: api.v1.services.system.UpdateViewResponse + (*DeleteViewRequest)(nil), // 8: api.v1.services.system.DeleteViewRequest + (*DeleteViewResponse)(nil), // 9: api.v1.services.system.DeleteViewResponse + (*types.View)(nil), // 10: api.v1.services.types.View + (*anypb.Any)(nil), // 11: google.protobuf.Any + (*emptypb.Empty)(nil), // 12: google.protobuf.Empty +} +var file_system_view_proto_depIdxs = []int32{ + 10, // 0: api.v1.services.system.ListViewsResponse.views:type_name -> api.v1.services.types.View + 11, // 1: api.v1.services.system.ListViewsResponse.extra:type_name -> google.protobuf.Any + 10, // 2: api.v1.services.system.GetViewResponse.view:type_name -> api.v1.services.types.View + 10, // 3: api.v1.services.system.CreateViewRequest.view:type_name -> api.v1.services.types.View + 10, // 4: api.v1.services.system.CreateViewResponse.view:type_name -> api.v1.services.types.View + 10, // 5: api.v1.services.system.UpdateViewRequest.view:type_name -> api.v1.services.types.View + 10, // 6: api.v1.services.system.UpdateViewResponse.view:type_name -> api.v1.services.types.View + 12, // 7: api.v1.services.system.DeleteViewResponse.empty:type_name -> google.protobuf.Empty + 0, // 8: api.v1.services.system.ViewService.ListViews:input_type -> api.v1.services.system.ListViewsRequest + 2, // 9: api.v1.services.system.ViewService.GetView:input_type -> api.v1.services.system.GetViewRequest + 4, // 10: api.v1.services.system.ViewService.CreateView:input_type -> api.v1.services.system.CreateViewRequest + 6, // 11: api.v1.services.system.ViewService.UpdateView:input_type -> api.v1.services.system.UpdateViewRequest + 8, // 12: api.v1.services.system.ViewService.DeleteView:input_type -> api.v1.services.system.DeleteViewRequest + 1, // 13: api.v1.services.system.ViewService.ListViews:output_type -> api.v1.services.system.ListViewsResponse + 3, // 14: api.v1.services.system.ViewService.GetView:output_type -> api.v1.services.system.GetViewResponse + 5, // 15: api.v1.services.system.ViewService.CreateView:output_type -> api.v1.services.system.CreateViewResponse + 7, // 16: api.v1.services.system.ViewService.UpdateView:output_type -> api.v1.services.system.UpdateViewResponse + 9, // 17: api.v1.services.system.ViewService.DeleteView:output_type -> api.v1.services.system.DeleteViewResponse + 13, // [13:18] is the sub-list for method output_type + 8, // [8:13] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_system_view_proto_init() } +func file_system_view_proto_init() { + if File_system_view_proto != nil { + return + } + file_system_view_proto_msgTypes[1].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_system_view_proto_rawDesc), len(file_system_view_proto_rawDesc)), + NumEnums: 0, + NumMessages: 10, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_system_view_proto_goTypes, + DependencyIndexes: file_system_view_proto_depIdxs, + MessageInfos: file_system_view_proto_msgTypes, + }.Build() + File_system_view_proto = out.File + file_system_view_proto_goTypes = nil + file_system_view_proto_depIdxs = nil +} diff --git a/api/v1/services/system/view.pb.gw.go b/api/v1/services/system/view.pb.gw.go new file mode 100644 index 00000000..e2d6d45e --- /dev/null +++ b/api/v1/services/system/view.pb.gw.go @@ -0,0 +1,459 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: system/view.proto + +/* +Package system is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package system + +import ( + "context" + "errors" + "io" + "net/http" + + "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" +) + +// Suppress "imported and not used" errors +var ( + _ codes.Code + _ io.Reader + _ status.Status + _ = errors.New + _ = runtime.String + _ = utilities.NewDoubleArray + _ = metadata.Join +) + +var filter_ViewService_ListViews_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + +func request_ViewService_ListViews_0(ctx context.Context, marshaler runtime.Marshaler, client ViewServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListViewsRequest + metadata runtime.ServerMetadata + ) + io.Copy(io.Discard, req.Body) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ViewService_ListViews_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.ListViews(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_ViewService_ListViews_0(ctx context.Context, marshaler runtime.Marshaler, server ViewServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq ListViewsRequest + metadata runtime.ServerMetadata + ) + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_ViewService_ListViews_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.ListViews(ctx, &protoReq) + return msg, metadata, err +} + +func request_ViewService_GetView_0(ctx context.Context, marshaler runtime.Marshaler, client ViewServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetViewRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.GetView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_ViewService_GetView_0(ctx context.Context, marshaler runtime.Marshaler, server ViewServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq GetViewRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.GetView(ctx, &protoReq) + return msg, metadata, err +} + +func request_ViewService_CreateView_0(ctx context.Context, marshaler runtime.Marshaler, client ViewServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateViewRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.CreateView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_ViewService_CreateView_0(ctx context.Context, marshaler runtime.Marshaler, server ViewServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq CreateViewRequest + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.CreateView(ctx, &protoReq) + return msg, metadata, err +} + +func request_ViewService_UpdateView_0(ctx context.Context, marshaler runtime.Marshaler, client ViewServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateViewRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.View); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["view.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "view.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "view.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "view.id", err) + } + msg, err := client.UpdateView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_ViewService_UpdateView_0(ctx context.Context, marshaler runtime.Marshaler, server ViewServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq UpdateViewRequest + metadata runtime.ServerMetadata + err error + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.View); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + val, ok := pathParams["view.id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "view.id") + } + err = runtime.PopulateFieldFromPath(&protoReq, "view.id", val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "view.id", err) + } + msg, err := server.UpdateView(ctx, &protoReq) + return msg, metadata, err +} + +func request_ViewService_DeleteView_0(ctx context.Context, marshaler runtime.Marshaler, client ViewServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteViewRequest + metadata runtime.ServerMetadata + err error + ) + io.Copy(io.Discard, req.Body) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := client.DeleteView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_ViewService_DeleteView_0(ctx context.Context, marshaler runtime.Marshaler, server ViewServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq DeleteViewRequest + metadata runtime.ServerMetadata + err error + ) + val, ok := pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + protoReq.Id, err = runtime.Int64(val) + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + msg, err := server.DeleteView(ctx, &protoReq) + return msg, metadata, err +} + +// RegisterViewServiceHandlerServer registers the http handlers for service ViewService to "mux". +// UnaryRPC :call ViewServiceServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterViewServiceHandlerFromEndpoint instead. +// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. +func RegisterViewServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server ViewServiceServer) error { + mux.Handle(http.MethodGet, pattern_ViewService_ListViews_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ViewService/ListViews", runtime.WithHTTPPathPattern("/sys/views")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ViewService_ListViews_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ViewService_ListViews_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_ViewService_GetView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ViewService/GetView", runtime.WithHTTPPathPattern("/sys/views/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ViewService_GetView_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ViewService_GetView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_ViewService_CreateView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ViewService/CreateView", runtime.WithHTTPPathPattern("/sys/views")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ViewService_CreateView_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ViewService_CreateView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_ViewService_UpdateView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ViewService/UpdateView", runtime.WithHTTPPathPattern("/sys/views/{view.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ViewService_UpdateView_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ViewService_UpdateView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_ViewService_DeleteView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.system.ViewService/DeleteView", runtime.WithHTTPPathPattern("/sys/views/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_ViewService_DeleteView_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ViewService_DeleteView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + + return nil +} + +// RegisterViewServiceHandlerFromEndpoint is same as RegisterViewServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterViewServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.NewClient(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + return RegisterViewServiceHandler(ctx, mux, conn) +} + +// RegisterViewServiceHandler registers the http handlers for service ViewService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterViewServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterViewServiceHandlerClient(ctx, mux, NewViewServiceClient(conn)) +} + +// RegisterViewServiceHandlerClient registers the http handlers for service ViewService +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "ViewServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "ViewServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "ViewServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. +func RegisterViewServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client ViewServiceClient) error { + mux.Handle(http.MethodGet, pattern_ViewService_ListViews_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ViewService/ListViews", runtime.WithHTTPPathPattern("/sys/views")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ViewService_ListViews_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ViewService_ListViews_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodGet, pattern_ViewService_GetView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ViewService/GetView", runtime.WithHTTPPathPattern("/sys/views/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ViewService_GetView_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ViewService_GetView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPost, pattern_ViewService_CreateView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ViewService/CreateView", runtime.WithHTTPPathPattern("/sys/views")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ViewService_CreateView_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ViewService_CreateView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodPut, pattern_ViewService_UpdateView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ViewService/UpdateView", runtime.WithHTTPPathPattern("/sys/views/{view.id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ViewService_UpdateView_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ViewService_UpdateView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + mux.Handle(http.MethodDelete, pattern_ViewService_DeleteView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.system.ViewService/DeleteView", runtime.WithHTTPPathPattern("/sys/views/{id}")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_ViewService_DeleteView_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_ViewService_DeleteView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) + return nil +} + +var ( + pattern_ViewService_ListViews_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "views"}, "")) + pattern_ViewService_GetView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "views", "id"}, "")) + pattern_ViewService_CreateView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"sys", "views"}, "")) + pattern_ViewService_UpdateView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "views", "view.id"}, "")) + pattern_ViewService_DeleteView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2}, []string{"sys", "views", "id"}, "")) +) + +var ( + forward_ViewService_ListViews_0 = runtime.ForwardResponseMessage + forward_ViewService_GetView_0 = runtime.ForwardResponseMessage + forward_ViewService_CreateView_0 = runtime.ForwardResponseMessage + forward_ViewService_UpdateView_0 = runtime.ForwardResponseMessage + forward_ViewService_DeleteView_0 = runtime.ForwardResponseMessage +) diff --git a/api/v1/services/system/view.pb.validate.go b/api/v1/services/system/view.pb.validate.go new file mode 100644 index 00000000..78265f38 --- /dev/null +++ b/api/v1/services/system/view.pb.validate.go @@ -0,0 +1,1323 @@ +// Code generated by protoc-gen-validate. DO NOT EDIT. +// source: system/view.proto + +package system + +import ( + "bytes" + "errors" + "fmt" + "net" + "net/mail" + "net/url" + "regexp" + "sort" + "strings" + "time" + "unicode/utf8" + + "google.golang.org/protobuf/types/known/anypb" +) + +// ensure the imports are used +var ( + _ = bytes.MinRead + _ = errors.New("") + _ = fmt.Print + _ = utf8.UTFMax + _ = (*regexp.Regexp)(nil) + _ = (*strings.Reader)(nil) + _ = net.IPv4len + _ = time.Duration(0) + _ = (*url.URL)(nil) + _ = (*mail.Address)(nil) + _ = anypb.Any{} + _ = sort.Sort +) + +// Validate checks the field values on ListViewsRequest 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 *ListViewsRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListViewsRequest 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 +// ListViewsRequestMultiError, or nil if none found. +func (m *ListViewsRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *ListViewsRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for PageToken + + // no validation rules for NoPaging + + // no validation rules for OnlyCount + + // no validation rules for Keyword + + // no validation rules for Scope + + if len(errors) > 0 { + return ListViewsRequestMultiError(errors) + } + + return nil +} + +// ListViewsRequestMultiError is an error wrapping multiple validation errors +// returned by ListViewsRequest.ValidateAll() if the designated constraints +// aren't met. +type ListViewsRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListViewsRequestMultiError) 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 ListViewsRequestMultiError) AllErrors() []error { return m } + +// ListViewsRequestValidationError is the validation error returned by +// ListViewsRequest.Validate if the designated constraints aren't met. +type ListViewsRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListViewsRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListViewsRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListViewsRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListViewsRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListViewsRequestValidationError) ErrorName() string { return "ListViewsRequestValidationError" } + +// Error satisfies the builtin error interface +func (e ListViewsRequestValidationError) 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 %sListViewsRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListViewsRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListViewsRequestValidationError{} + +// Validate checks the field values on ListViewsResponse 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 *ListViewsResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on ListViewsResponse 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 +// ListViewsResponseMultiError, or nil if none found. +func (m *ListViewsResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *ListViewsResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Total + + for idx, item := range m.GetViews() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListViewsResponseValidationError{ + field: fmt.Sprintf("Views[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListViewsResponseValidationError{ + field: fmt.Sprintf("Views[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListViewsResponseValidationError{ + field: fmt.Sprintf("Views[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + // no validation rules for Page + + // no validation rules for PageSize + + // no validation rules for NextPageToken + + if m.Extra != nil { + + if all { + switch v := interface{}(m.GetExtra()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, ListViewsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, ListViewsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetExtra()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return ListViewsResponseValidationError{ + field: "Extra", + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return ListViewsResponseMultiError(errors) + } + + return nil +} + +// ListViewsResponseMultiError is an error wrapping multiple validation errors +// returned by ListViewsResponse.ValidateAll() if the designated constraints +// aren't met. +type ListViewsResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m ListViewsResponseMultiError) 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 ListViewsResponseMultiError) AllErrors() []error { return m } + +// ListViewsResponseValidationError is the validation error returned by +// ListViewsResponse.Validate if the designated constraints aren't met. +type ListViewsResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e ListViewsResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e ListViewsResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e ListViewsResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e ListViewsResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e ListViewsResponseValidationError) ErrorName() string { + return "ListViewsResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e ListViewsResponseValidationError) 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 %sListViewsResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = ListViewsResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = ListViewsResponseValidationError{} + +// Validate checks the field values on GetViewRequest 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 *GetViewRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetViewRequest 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 GetViewRequestMultiError, +// or nil if none found. +func (m *GetViewRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *GetViewRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return GetViewRequestMultiError(errors) + } + + return nil +} + +// GetViewRequestMultiError is an error wrapping multiple validation errors +// returned by GetViewRequest.ValidateAll() if the designated constraints +// aren't met. +type GetViewRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetViewRequestMultiError) 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 GetViewRequestMultiError) AllErrors() []error { return m } + +// GetViewRequestValidationError is the validation error returned by +// GetViewRequest.Validate if the designated constraints aren't met. +type GetViewRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetViewRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetViewRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetViewRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetViewRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetViewRequestValidationError) ErrorName() string { return "GetViewRequestValidationError" } + +// Error satisfies the builtin error interface +func (e GetViewRequestValidationError) 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 %sGetViewRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetViewRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetViewRequestValidationError{} + +// Validate checks the field values on GetViewResponse 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 *GetViewResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on GetViewResponse 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 +// GetViewResponseMultiError, or nil if none found. +func (m *GetViewResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *GetViewResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetView()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, GetViewResponseValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, GetViewResponseValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetView()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return GetViewResponseValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return GetViewResponseMultiError(errors) + } + + return nil +} + +// GetViewResponseMultiError is an error wrapping multiple validation errors +// returned by GetViewResponse.ValidateAll() if the designated constraints +// aren't met. +type GetViewResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m GetViewResponseMultiError) 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 GetViewResponseMultiError) AllErrors() []error { return m } + +// GetViewResponseValidationError is the validation error returned by +// GetViewResponse.Validate if the designated constraints aren't met. +type GetViewResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e GetViewResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e GetViewResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e GetViewResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e GetViewResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e GetViewResponseValidationError) ErrorName() string { return "GetViewResponseValidationError" } + +// Error satisfies the builtin error interface +func (e GetViewResponseValidationError) 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 %sGetViewResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = GetViewResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = GetViewResponseValidationError{} + +// Validate checks the field values on CreateViewRequest 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 *CreateViewRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateViewRequest 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 +// CreateViewRequestMultiError, or nil if none found. +func (m *CreateViewRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateViewRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Parent + + // no validation rules for ViewId + + if all { + switch v := interface{}(m.GetView()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateViewRequestValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateViewRequestValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetView()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateViewRequestValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateViewRequestMultiError(errors) + } + + return nil +} + +// CreateViewRequestMultiError is an error wrapping multiple validation errors +// returned by CreateViewRequest.ValidateAll() if the designated constraints +// aren't met. +type CreateViewRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateViewRequestMultiError) 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 CreateViewRequestMultiError) AllErrors() []error { return m } + +// CreateViewRequestValidationError is the validation error returned by +// CreateViewRequest.Validate if the designated constraints aren't met. +type CreateViewRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateViewRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateViewRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateViewRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateViewRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateViewRequestValidationError) ErrorName() string { + return "CreateViewRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateViewRequestValidationError) 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 %sCreateViewRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateViewRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateViewRequestValidationError{} + +// Validate checks the field values on CreateViewResponse 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 *CreateViewResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on CreateViewResponse 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 +// CreateViewResponseMultiError, or nil if none found. +func (m *CreateViewResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *CreateViewResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetView()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, CreateViewResponseValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, CreateViewResponseValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetView()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return CreateViewResponseValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return CreateViewResponseMultiError(errors) + } + + return nil +} + +// CreateViewResponseMultiError is an error wrapping multiple validation errors +// returned by CreateViewResponse.ValidateAll() if the designated constraints +// aren't met. +type CreateViewResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m CreateViewResponseMultiError) 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 CreateViewResponseMultiError) AllErrors() []error { return m } + +// CreateViewResponseValidationError is the validation error returned by +// CreateViewResponse.Validate if the designated constraints aren't met. +type CreateViewResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e CreateViewResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e CreateViewResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e CreateViewResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e CreateViewResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e CreateViewResponseValidationError) ErrorName() string { + return "CreateViewResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e CreateViewResponseValidationError) 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 %sCreateViewResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = CreateViewResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = CreateViewResponseValidationError{} + +// Validate checks the field values on UpdateViewRequest 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 *UpdateViewRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateViewRequest 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 +// UpdateViewRequestMultiError, or nil if none found. +func (m *UpdateViewRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateViewRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetView()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateViewRequestValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateViewRequestValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetView()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateViewRequestValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateViewRequestMultiError(errors) + } + + return nil +} + +// UpdateViewRequestMultiError is an error wrapping multiple validation errors +// returned by UpdateViewRequest.ValidateAll() if the designated constraints +// aren't met. +type UpdateViewRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateViewRequestMultiError) 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 UpdateViewRequestMultiError) AllErrors() []error { return m } + +// UpdateViewRequestValidationError is the validation error returned by +// UpdateViewRequest.Validate if the designated constraints aren't met. +type UpdateViewRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateViewRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateViewRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateViewRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateViewRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateViewRequestValidationError) ErrorName() string { + return "UpdateViewRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateViewRequestValidationError) 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 %sUpdateViewRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateViewRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateViewRequestValidationError{} + +// Validate checks the field values on UpdateViewResponse 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 *UpdateViewResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on UpdateViewResponse 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 +// UpdateViewResponseMultiError, or nil if none found. +func (m *UpdateViewResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *UpdateViewResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetView()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateViewResponseValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateViewResponseValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetView()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateViewResponseValidationError{ + field: "View", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return UpdateViewResponseMultiError(errors) + } + + return nil +} + +// UpdateViewResponseMultiError is an error wrapping multiple validation errors +// returned by UpdateViewResponse.ValidateAll() if the designated constraints +// aren't met. +type UpdateViewResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m UpdateViewResponseMultiError) 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 UpdateViewResponseMultiError) AllErrors() []error { return m } + +// UpdateViewResponseValidationError is the validation error returned by +// UpdateViewResponse.Validate if the designated constraints aren't met. +type UpdateViewResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e UpdateViewResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e UpdateViewResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e UpdateViewResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e UpdateViewResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e UpdateViewResponseValidationError) ErrorName() string { + return "UpdateViewResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e UpdateViewResponseValidationError) 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 %sUpdateViewResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = UpdateViewResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = UpdateViewResponseValidationError{} + +// Validate checks the field values on DeleteViewRequest 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 *DeleteViewRequest) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteViewRequest 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 +// DeleteViewRequestMultiError, or nil if none found. +func (m *DeleteViewRequest) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteViewRequest) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + // no validation rules for Id + + if len(errors) > 0 { + return DeleteViewRequestMultiError(errors) + } + + return nil +} + +// DeleteViewRequestMultiError is an error wrapping multiple validation errors +// returned by DeleteViewRequest.ValidateAll() if the designated constraints +// aren't met. +type DeleteViewRequestMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteViewRequestMultiError) 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 DeleteViewRequestMultiError) AllErrors() []error { return m } + +// DeleteViewRequestValidationError is the validation error returned by +// DeleteViewRequest.Validate if the designated constraints aren't met. +type DeleteViewRequestValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteViewRequestValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteViewRequestValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteViewRequestValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteViewRequestValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteViewRequestValidationError) ErrorName() string { + return "DeleteViewRequestValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteViewRequestValidationError) 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 %sDeleteViewRequest.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteViewRequestValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteViewRequestValidationError{} + +// Validate checks the field values on DeleteViewResponse 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 *DeleteViewResponse) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on DeleteViewResponse 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 +// DeleteViewResponseMultiError, or nil if none found. +func (m *DeleteViewResponse) ValidateAll() error { + return m.validate(true) +} + +func (m *DeleteViewResponse) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetEmpty()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, DeleteViewResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, DeleteViewResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetEmpty()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return DeleteViewResponseValidationError{ + field: "Empty", + reason: "embedded message failed validation", + cause: err, + } + } + } + + if len(errors) > 0 { + return DeleteViewResponseMultiError(errors) + } + + return nil +} + +// DeleteViewResponseMultiError is an error wrapping multiple validation errors +// returned by DeleteViewResponse.ValidateAll() if the designated constraints +// aren't met. +type DeleteViewResponseMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m DeleteViewResponseMultiError) 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 DeleteViewResponseMultiError) AllErrors() []error { return m } + +// DeleteViewResponseValidationError is the validation error returned by +// DeleteViewResponse.Validate if the designated constraints aren't met. +type DeleteViewResponseValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e DeleteViewResponseValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e DeleteViewResponseValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e DeleteViewResponseValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e DeleteViewResponseValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e DeleteViewResponseValidationError) ErrorName() string { + return "DeleteViewResponseValidationError" +} + +// Error satisfies the builtin error interface +func (e DeleteViewResponseValidationError) 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 %sDeleteViewResponse.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = DeleteViewResponseValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = DeleteViewResponseValidationError{} diff --git a/api/v1/services/system/view_bridge.pb.go b/api/v1/services/system/view_bridge.pb.go new file mode 100644 index 00000000..a4e5739b --- /dev/null +++ b/api/v1/services/system/view_bridge.pb.go @@ -0,0 +1,397 @@ +// Code generated by protoc-gen-go-bridge. DO NOT EDIT. +// versions: +// - protoc-gen-go-bridge unknown +// - protoc (unknown) +// source: system/view.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) + +const _ = http.SupportPackageIsVersion1 +const _ = grpc.SupportPackageIsVersion9 + +var ( + _ = io.EOF + _ = status.Errorf + _ = codes.Unimplemented +) + +const ViewServiceListViewsBridgeOperation = "/api.v1.services.system.ViewService/ListViews" +const ViewServiceGetViewBridgeOperation = "/api.v1.services.system.ViewService/GetView" +const ViewServiceCreateViewBridgeOperation = "/api.v1.services.system.ViewService/CreateView" +const ViewServiceUpdateViewBridgeOperation = "/api.v1.services.system.ViewService/UpdateView" +const ViewServiceDeleteViewBridgeOperation = "/api.v1.services.system.ViewService/DeleteView" + +type ViewServiceBridgeServer interface { + // Lists all view elements. + ListViews(context.Context, *ListViewsRequest) (*ListViewsResponse, error) + // Gets a single view element. + GetView(context.Context, *GetViewRequest) (*GetViewResponse, error) + // Creates a new view element. + CreateView(context.Context, *CreateViewRequest) (*CreateViewResponse, error) + // Updates a view element. + UpdateView(context.Context, *UpdateViewRequest) (*UpdateViewResponse, error) + // Deletes a view element. + DeleteView(context.Context, *DeleteViewRequest) (*DeleteViewResponse, error) +} + +type ViewServiceHooker interface { + ViewServiceListViewsHooker + ViewServiceGetViewHooker + ViewServiceCreateViewHooker + ViewServiceUpdateViewHooker + ViewServiceDeleteViewHooker +} + +type ViewServiceHookedBridger interface { + ViewServiceHooker + ViewServiceBridgeServer +} +type ViewServiceListViewsHooker interface { + PrepareListViews(http.Context, *ListViewsRequest) (context.Context, error) + CompleteListViews(http.Context, *ListViewsRequest, *ListViewsResponse) error +} +type ViewServiceGetViewHooker interface { + PrepareGetView(http.Context, *GetViewRequest) (context.Context, error) + CompleteGetView(http.Context, *GetViewRequest, *GetViewResponse) error +} +type ViewServiceCreateViewHooker interface { + PrepareCreateView(http.Context, *CreateViewRequest) (context.Context, error) + CompleteCreateView(http.Context, *CreateViewRequest, *CreateViewResponse) error +} +type ViewServiceUpdateViewHooker interface { + PrepareUpdateView(http.Context, *UpdateViewRequest) (context.Context, error) + CompleteUpdateView(http.Context, *UpdateViewRequest, *UpdateViewResponse) error +} +type ViewServiceDeleteViewHooker interface { + PrepareDeleteView(http.Context, *DeleteViewRequest) (context.Context, error) + CompleteDeleteView(http.Context, *DeleteViewRequest, *DeleteViewResponse) error +} + +func RegisterViewServiceBridgeServer(s *http.Server, srv ViewServiceHookedBridger) { + r := s.Route("/") + r.GET("/sys/views", _ViewService_ListViews0_Bridge_Handler(srv)) + r.GET("/sys/views/:id", _ViewService_GetView0_Bridge_Handler(srv)) + r.POST("/sys/views", _ViewService_CreateView0_Bridge_Handler(srv)) + r.PUT("/sys/views/:view.id", _ViewService_UpdateView0_Bridge_Handler(srv)) + r.DELETE("/sys/views/:id", _ViewService_DeleteView0_Bridge_Handler(srv)) +} + +func _ViewService_ListViews0_Bridge_Handler(srv ViewServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListViewsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationViewServiceListViews) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListViews(ctx, req.(*ListViewsRequest)) + }) + + newctx, err := srv.PrepareListViews(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteListViews(ctx, &in, out.(*ListViewsResponse)) + } +} + +func _ViewService_GetView0_Bridge_Handler(srv ViewServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetViewRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationViewServiceGetView) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetView(ctx, req.(*GetViewRequest)) + }) + + newctx, err := srv.PrepareGetView(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteGetView(ctx, &in, out.(*GetViewResponse)) + } +} + +func _ViewService_CreateView0_Bridge_Handler(srv ViewServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateViewRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationViewServiceCreateView) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateView(ctx, req.(*CreateViewRequest)) + }) + + newctx, err := srv.PrepareCreateView(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteCreateView(ctx, &in, out.(*CreateViewResponse)) + } +} + +func _ViewService_UpdateView0_Bridge_Handler(srv ViewServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateViewRequest + if err := ctx.Bind(&in.View); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationViewServiceUpdateView) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateView(ctx, req.(*UpdateViewRequest)) + }) + + newctx, err := srv.PrepareUpdateView(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteUpdateView(ctx, &in, out.(*UpdateViewResponse)) + } +} + +func _ViewService_DeleteView0_Bridge_Handler(srv ViewServiceHookedBridger) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteViewRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationViewServiceDeleteView) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteView(ctx, req.(*DeleteViewRequest)) + }) + + newctx, err := srv.PrepareDeleteView(ctx, &in) + if err != nil { + return err + } + out, err := h(newctx, &in) + if err != nil { + return err + } + return srv.CompleteDeleteView(ctx, &in, out.(*DeleteViewResponse)) + } +} + +// UnimplementedViewServiceHooked must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedViewServiceHooked struct{} + +func (UnimplementedViewServiceHooked) PrepareListViews(ctx http.Context, in *ListViewsRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedViewServiceHooked) CompleteListViews(ctx http.Context, in *ListViewsRequest, out *ListViewsResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedViewServiceHooked) PrepareGetView(ctx http.Context, in *GetViewRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedViewServiceHooked) CompleteGetView(ctx http.Context, in *GetViewRequest, out *GetViewResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedViewServiceHooked) PrepareCreateView(ctx http.Context, in *CreateViewRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedViewServiceHooked) CompleteCreateView(ctx http.Context, in *CreateViewRequest, out *CreateViewResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedViewServiceHooked) PrepareUpdateView(ctx http.Context, in *UpdateViewRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedViewServiceHooked) CompleteUpdateView(ctx http.Context, in *UpdateViewRequest, out *UpdateViewResponse) error { + return ctx.Result(200, out) +} + +func (UnimplementedViewServiceHooked) PrepareDeleteView(ctx http.Context, in *DeleteViewRequest) (context.Context, error) { + return ctx, nil +} + +func (UnimplementedViewServiceHooked) CompleteDeleteView(ctx http.Context, in *DeleteViewRequest, out *DeleteViewResponse) error { + return ctx.Result(200, out) +} + +func WithViewServiceHook(h ViewServiceHooker) func(ViewServiceBridgeServer) ViewServiceHookedBridger { + return func(srv ViewServiceBridgeServer) ViewServiceHookedBridger { + return ViewServiceHookedBridge{ViewServiceBridgeServer: srv, ViewServiceHooker: h} + } +} + +// ViewServiceHookedBridge is a bridge between the HTTP and gRPC implementations of ViewService. +// It implements the HTTP and gRPC implementations of ViewService. +// It forwards requests and responses between the two implementations. +type ViewServiceHookedBridge struct { + ViewServiceBridgeServer + ViewServiceHooker +} + +type ViewServiceHTTPBridgeImpl struct { + client ViewServiceHTTPClient +} + +func NewViewServiceHTTPBridge(client *http.Client) ViewServiceHTTPServer { + return &ViewServiceHTTPBridgeImpl{client: NewViewServiceHTTPClient(client)} +} + +func (c *ViewServiceHTTPBridgeImpl) ListViews(ctx context.Context, in *ListViewsRequest) (*ListViewsResponse, error) { + return c.client.ListViews(ctx, in) +} + +func (c *ViewServiceHTTPBridgeImpl) GetView(ctx context.Context, in *GetViewRequest) (*GetViewResponse, error) { + return c.client.GetView(ctx, in) +} + +func (c *ViewServiceHTTPBridgeImpl) CreateView(ctx context.Context, in *CreateViewRequest) (*CreateViewResponse, error) { + return c.client.CreateView(ctx, in) +} + +func (c *ViewServiceHTTPBridgeImpl) UpdateView(ctx context.Context, in *UpdateViewRequest) (*UpdateViewResponse, error) { + return c.client.UpdateView(ctx, in) +} + +func (c *ViewServiceHTTPBridgeImpl) DeleteView(ctx context.Context, in *DeleteViewRequest) (*DeleteViewResponse, error) { + return c.client.DeleteView(ctx, in) +} + +type ViewServiceBridgeImpl struct { + client ViewServiceClient +} + +func NewViewServiceBridge(client grpc.ClientConnInterface) ViewServiceServer { + return &ViewServiceBridgeImpl{client: NewViewServiceClient(client)} +} + +func (c *ViewServiceBridgeImpl) ListViews(ctx context.Context, in *ListViewsRequest) (*ListViewsResponse, error) { + return c.client.ListViews(ctx, in) +} + +func (c *ViewServiceBridgeImpl) GetView(ctx context.Context, in *GetViewRequest) (*GetViewResponse, error) { + return c.client.GetView(ctx, in) +} + +func (c *ViewServiceBridgeImpl) CreateView(ctx context.Context, in *CreateViewRequest) (*CreateViewResponse, error) { + return c.client.CreateView(ctx, in) +} + +func (c *ViewServiceBridgeImpl) UpdateView(ctx context.Context, in *UpdateViewRequest) (*UpdateViewResponse, error) { + return c.client.UpdateView(ctx, in) +} + +func (c *ViewServiceBridgeImpl) DeleteView(ctx context.Context, in *DeleteViewRequest) (*DeleteViewResponse, error) { + return c.client.DeleteView(ctx, in) +} + +func (c *ViewServiceBridgeImpl) mustEmbedUnimplementedViewServiceServer() {} + +type ViewServiceGRPC2HTTPBridgeImpl struct { + client ViewServiceClient +} + +func NewViewServiceGRPC2HTTP(client grpc.ClientConnInterface) ViewServiceHTTPServer { + return &ViewServiceGRPC2HTTPBridgeImpl{client: NewViewServiceClient(client)} +} + +func (c *ViewServiceGRPC2HTTPBridgeImpl) ListViews(ctx context.Context, in *ListViewsRequest) (*ListViewsResponse, error) { + return c.client.ListViews(ctx, in) +} + +func (c *ViewServiceGRPC2HTTPBridgeImpl) GetView(ctx context.Context, in *GetViewRequest) (*GetViewResponse, error) { + return c.client.GetView(ctx, in) +} + +func (c *ViewServiceGRPC2HTTPBridgeImpl) CreateView(ctx context.Context, in *CreateViewRequest) (*CreateViewResponse, error) { + return c.client.CreateView(ctx, in) +} + +func (c *ViewServiceGRPC2HTTPBridgeImpl) UpdateView(ctx context.Context, in *UpdateViewRequest) (*UpdateViewResponse, error) { + return c.client.UpdateView(ctx, in) +} + +func (c *ViewServiceGRPC2HTTPBridgeImpl) DeleteView(ctx context.Context, in *DeleteViewRequest) (*DeleteViewResponse, error) { + return c.client.DeleteView(ctx, in) +} + +type ViewServiceHTTP2GRPCBridgeImpl struct { + client ViewServiceHTTPClient +} + +func NewViewServiceHTTP2GRPC(client *http.Client) ViewServiceServer { + return &ViewServiceHTTP2GRPCBridgeImpl{client: NewViewServiceHTTPClient(client)} +} + +func (c *ViewServiceHTTP2GRPCBridgeImpl) ListViews(ctx context.Context, in *ListViewsRequest) (*ListViewsResponse, error) { + return c.client.ListViews(ctx, in) +} + +func (c *ViewServiceHTTP2GRPCBridgeImpl) GetView(ctx context.Context, in *GetViewRequest) (*GetViewResponse, error) { + return c.client.GetView(ctx, in) +} + +func (c *ViewServiceHTTP2GRPCBridgeImpl) CreateView(ctx context.Context, in *CreateViewRequest) (*CreateViewResponse, error) { + return c.client.CreateView(ctx, in) +} + +func (c *ViewServiceHTTP2GRPCBridgeImpl) UpdateView(ctx context.Context, in *UpdateViewRequest) (*UpdateViewResponse, error) { + return c.client.UpdateView(ctx, in) +} + +func (c *ViewServiceHTTP2GRPCBridgeImpl) DeleteView(ctx context.Context, in *DeleteViewRequest) (*DeleteViewResponse, error) { + return c.client.DeleteView(ctx, in) +} + +func (c *ViewServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedViewServiceServer() {} diff --git a/api/v1/services/system/view_grpc.pb.go b/api/v1/services/system/view_grpc.pb.go new file mode 100644 index 00000000..877fd435 --- /dev/null +++ b/api/v1/services/system/view_grpc.pb.go @@ -0,0 +1,289 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc (unknown) +// source: system/view.proto + +package system + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + ViewService_ListViews_FullMethodName = "/api.v1.services.system.ViewService/ListViews" + ViewService_GetView_FullMethodName = "/api.v1.services.system.ViewService/GetView" + ViewService_CreateView_FullMethodName = "/api.v1.services.system.ViewService/CreateView" + ViewService_UpdateView_FullMethodName = "/api.v1.services.system.ViewService/UpdateView" + ViewService_DeleteView_FullMethodName = "/api.v1.services.system.ViewService/DeleteView" +) + +// ViewServiceClient is the client API for ViewService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// The view service definition. +// A View represents a UI element that can be controlled by permissions, such as a menu, button, or page. +type ViewServiceClient interface { + // Lists all view elements. + ListViews(ctx context.Context, in *ListViewsRequest, opts ...grpc.CallOption) (*ListViewsResponse, error) + // Gets a single view element. + GetView(ctx context.Context, in *GetViewRequest, opts ...grpc.CallOption) (*GetViewResponse, error) + // Creates a new view element. + CreateView(ctx context.Context, in *CreateViewRequest, opts ...grpc.CallOption) (*CreateViewResponse, error) + // Updates a view element. + UpdateView(ctx context.Context, in *UpdateViewRequest, opts ...grpc.CallOption) (*UpdateViewResponse, error) + // Deletes a view element. + DeleteView(ctx context.Context, in *DeleteViewRequest, opts ...grpc.CallOption) (*DeleteViewResponse, error) +} + +type viewServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewViewServiceClient(cc grpc.ClientConnInterface) ViewServiceClient { + return &viewServiceClient{cc} +} + +func (c *viewServiceClient) ListViews(ctx context.Context, in *ListViewsRequest, opts ...grpc.CallOption) (*ListViewsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListViewsResponse) + err := c.cc.Invoke(ctx, ViewService_ListViews_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *viewServiceClient) GetView(ctx context.Context, in *GetViewRequest, opts ...grpc.CallOption) (*GetViewResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetViewResponse) + err := c.cc.Invoke(ctx, ViewService_GetView_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *viewServiceClient) CreateView(ctx context.Context, in *CreateViewRequest, opts ...grpc.CallOption) (*CreateViewResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateViewResponse) + err := c.cc.Invoke(ctx, ViewService_CreateView_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *viewServiceClient) UpdateView(ctx context.Context, in *UpdateViewRequest, opts ...grpc.CallOption) (*UpdateViewResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(UpdateViewResponse) + err := c.cc.Invoke(ctx, ViewService_UpdateView_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *viewServiceClient) DeleteView(ctx context.Context, in *DeleteViewRequest, opts ...grpc.CallOption) (*DeleteViewResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(DeleteViewResponse) + err := c.cc.Invoke(ctx, ViewService_DeleteView_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ViewServiceServer is the server API for ViewService service. +// All implementations must embed UnimplementedViewServiceServer +// for forward compatibility. +// +// The view service definition. +// A View represents a UI element that can be controlled by permissions, such as a menu, button, or page. +type ViewServiceServer interface { + // Lists all view elements. + ListViews(context.Context, *ListViewsRequest) (*ListViewsResponse, error) + // Gets a single view element. + GetView(context.Context, *GetViewRequest) (*GetViewResponse, error) + // Creates a new view element. + CreateView(context.Context, *CreateViewRequest) (*CreateViewResponse, error) + // Updates a view element. + UpdateView(context.Context, *UpdateViewRequest) (*UpdateViewResponse, error) + // Deletes a view element. + DeleteView(context.Context, *DeleteViewRequest) (*DeleteViewResponse, error) + mustEmbedUnimplementedViewServiceServer() +} + +// UnimplementedViewServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedViewServiceServer struct{} + +func (UnimplementedViewServiceServer) ListViews(context.Context, *ListViewsRequest) (*ListViewsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListViews not implemented") +} +func (UnimplementedViewServiceServer) GetView(context.Context, *GetViewRequest) (*GetViewResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetView not implemented") +} +func (UnimplementedViewServiceServer) CreateView(context.Context, *CreateViewRequest) (*CreateViewResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateView not implemented") +} +func (UnimplementedViewServiceServer) UpdateView(context.Context, *UpdateViewRequest) (*UpdateViewResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateView not implemented") +} +func (UnimplementedViewServiceServer) DeleteView(context.Context, *DeleteViewRequest) (*DeleteViewResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteView not implemented") +} +func (UnimplementedViewServiceServer) mustEmbedUnimplementedViewServiceServer() {} +func (UnimplementedViewServiceServer) testEmbeddedByValue() {} + +// UnsafeViewServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ViewServiceServer will +// result in compilation errors. +type UnsafeViewServiceServer interface { + mustEmbedUnimplementedViewServiceServer() +} + +func RegisterViewServiceServer(s grpc.ServiceRegistrar, srv ViewServiceServer) { + // If the following call pancis, it indicates UnimplementedViewServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&ViewService_ServiceDesc, srv) +} + +func _ViewService_ListViews_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListViewsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ViewServiceServer).ListViews(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ViewService_ListViews_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ViewServiceServer).ListViews(ctx, req.(*ListViewsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ViewService_GetView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetViewRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ViewServiceServer).GetView(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ViewService_GetView_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ViewServiceServer).GetView(ctx, req.(*GetViewRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ViewService_CreateView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateViewRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ViewServiceServer).CreateView(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ViewService_CreateView_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ViewServiceServer).CreateView(ctx, req.(*CreateViewRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ViewService_UpdateView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateViewRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ViewServiceServer).UpdateView(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ViewService_UpdateView_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ViewServiceServer).UpdateView(ctx, req.(*UpdateViewRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ViewService_DeleteView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteViewRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ViewServiceServer).DeleteView(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: ViewService_DeleteView_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ViewServiceServer).DeleteView(ctx, req.(*DeleteViewRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ViewService_ServiceDesc is the grpc.ServiceDesc for ViewService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ViewService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "api.v1.services.system.ViewService", + HandlerType: (*ViewServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListViews", + Handler: _ViewService_ListViews_Handler, + }, + { + MethodName: "GetView", + Handler: _ViewService_GetView_Handler, + }, + { + MethodName: "CreateView", + Handler: _ViewService_CreateView_Handler, + }, + { + MethodName: "UpdateView", + Handler: _ViewService_UpdateView_Handler, + }, + { + MethodName: "DeleteView", + Handler: _ViewService_DeleteView_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "system/view.proto", +} diff --git a/api/v1/services/system/view_http.pb.go b/api/v1/services/system/view_http.pb.go new file mode 100644 index 00000000..7d754bdc --- /dev/null +++ b/api/v1/services/system/view_http.pb.go @@ -0,0 +1,249 @@ +// Code generated by protoc-gen-go-http. DO NOT EDIT. +// versions: +// - protoc-gen-go-http v2.9.0 +// - protoc (unknown) +// source: system/view.proto + +package system + +import ( + context "context" + http "github.com/go-kratos/kratos/v2/transport/http" + binding "github.com/go-kratos/kratos/v2/transport/http/binding" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the kratos package it is being compiled against. +var _ = new(context.Context) +var _ = binding.EncodeURL + +const _ = http.SupportPackageIsVersion1 + +const OperationViewServiceCreateView = "/api.v1.services.system.ViewService/CreateView" +const OperationViewServiceDeleteView = "/api.v1.services.system.ViewService/DeleteView" +const OperationViewServiceGetView = "/api.v1.services.system.ViewService/GetView" +const OperationViewServiceListViews = "/api.v1.services.system.ViewService/ListViews" +const OperationViewServiceUpdateView = "/api.v1.services.system.ViewService/UpdateView" + +type ViewServiceHTTPServer interface { + // CreateView Creates a new view element. + CreateView(context.Context, *CreateViewRequest) (*CreateViewResponse, error) + // DeleteView Deletes a view element. + DeleteView(context.Context, *DeleteViewRequest) (*DeleteViewResponse, error) + // GetView Gets a single view element. + GetView(context.Context, *GetViewRequest) (*GetViewResponse, error) + // ListViews Lists all view elements. + ListViews(context.Context, *ListViewsRequest) (*ListViewsResponse, error) + // UpdateView Updates a view element. + UpdateView(context.Context, *UpdateViewRequest) (*UpdateViewResponse, error) +} + +func RegisterViewServiceHTTPServer(s *http.Server, srv ViewServiceHTTPServer) { + r := s.Route("/") + r.GET("/sys/views", _ViewService_ListViews0_HTTP_Handler(srv)) + r.GET("/sys/views/{id}", _ViewService_GetView0_HTTP_Handler(srv)) + r.POST("/sys/views", _ViewService_CreateView0_HTTP_Handler(srv)) + r.PUT("/sys/views/{view.id}", _ViewService_UpdateView0_HTTP_Handler(srv)) + r.DELETE("/sys/views/{id}", _ViewService_DeleteView0_HTTP_Handler(srv)) +} + +func _ViewService_ListViews0_HTTP_Handler(srv ViewServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in ListViewsRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationViewServiceListViews) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.ListViews(ctx, req.(*ListViewsRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*ListViewsResponse) + return ctx.Result(200, reply) + } +} + +func _ViewService_GetView0_HTTP_Handler(srv ViewServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in GetViewRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationViewServiceGetView) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.GetView(ctx, req.(*GetViewRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*GetViewResponse) + return ctx.Result(200, reply) + } +} + +func _ViewService_CreateView0_HTTP_Handler(srv ViewServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in CreateViewRequest + if err := ctx.Bind(&in); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationViewServiceCreateView) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.CreateView(ctx, req.(*CreateViewRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*CreateViewResponse) + return ctx.Result(200, reply) + } +} + +func _ViewService_UpdateView0_HTTP_Handler(srv ViewServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in UpdateViewRequest + if err := ctx.Bind(&in.View); err != nil { + return err + } + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationViewServiceUpdateView) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.UpdateView(ctx, req.(*UpdateViewRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*UpdateViewResponse) + return ctx.Result(200, reply) + } +} + +func _ViewService_DeleteView0_HTTP_Handler(srv ViewServiceHTTPServer) func(ctx http.Context) error { + return func(ctx http.Context) error { + var in DeleteViewRequest + if err := ctx.BindQuery(&in); err != nil { + return err + } + if err := ctx.BindVars(&in); err != nil { + return err + } + http.SetOperation(ctx, OperationViewServiceDeleteView) + h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.DeleteView(ctx, req.(*DeleteViewRequest)) + }) + out, err := h(ctx, &in) + if err != nil { + return err + } + reply := out.(*DeleteViewResponse) + return ctx.Result(200, reply) + } +} + +type ViewServiceHTTPClient interface { + // CreateView Creates a new view element. + CreateView(ctx context.Context, req *CreateViewRequest, opts ...http.CallOption) (rsp *CreateViewResponse, err error) + // DeleteView Deletes a view element. + DeleteView(ctx context.Context, req *DeleteViewRequest, opts ...http.CallOption) (rsp *DeleteViewResponse, err error) + // GetView Gets a single view element. + GetView(ctx context.Context, req *GetViewRequest, opts ...http.CallOption) (rsp *GetViewResponse, err error) + // ListViews Lists all view elements. + ListViews(ctx context.Context, req *ListViewsRequest, opts ...http.CallOption) (rsp *ListViewsResponse, err error) + // UpdateView Updates a view element. + UpdateView(ctx context.Context, req *UpdateViewRequest, opts ...http.CallOption) (rsp *UpdateViewResponse, err error) +} + +type ViewServiceHTTPClientImpl struct { + cc *http.Client +} + +func NewViewServiceHTTPClient(client *http.Client) ViewServiceHTTPClient { + return &ViewServiceHTTPClientImpl{client} +} + +// CreateView Creates a new view element. +func (c *ViewServiceHTTPClientImpl) CreateView(ctx context.Context, in *CreateViewRequest, opts ...http.CallOption) (*CreateViewResponse, error) { + var out CreateViewResponse + pattern := "/sys/views" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationViewServiceCreateView)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// DeleteView Deletes a view element. +func (c *ViewServiceHTTPClientImpl) DeleteView(ctx context.Context, in *DeleteViewRequest, opts ...http.CallOption) (*DeleteViewResponse, error) { + var out DeleteViewResponse + pattern := "/sys/views/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationViewServiceDeleteView)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// GetView Gets a single view element. +func (c *ViewServiceHTTPClientImpl) GetView(ctx context.Context, in *GetViewRequest, opts ...http.CallOption) (*GetViewResponse, error) { + var out GetViewResponse + pattern := "/sys/views/{id}" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationViewServiceGetView)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// ListViews Lists all view elements. +func (c *ViewServiceHTTPClientImpl) ListViews(ctx context.Context, in *ListViewsRequest, opts ...http.CallOption) (*ListViewsResponse, error) { + var out ListViewsResponse + pattern := "/sys/views" + path := binding.EncodeURL(pattern, in, true) + opts = append(opts, http.Operation(OperationViewServiceListViews)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} + +// UpdateView Updates a view element. +func (c *ViewServiceHTTPClientImpl) UpdateView(ctx context.Context, in *UpdateViewRequest, opts ...http.CallOption) (*UpdateViewResponse, error) { + var out UpdateViewResponse + pattern := "/sys/views/{view.id}" + path := binding.EncodeURL(pattern, in, false) + opts = append(opts, http.Operation(OperationViewServiceUpdateView)) + opts = append(opts, http.PathTemplate(pattern)) + err := c.cc.Invoke(ctx, "PUT", path, in.View, &out, opts...) + if err != nil { + return nil, err + } + return &out, nil +} diff --git a/cmd/auth/wire.go b/cmd/auth/wire.go index 11557439..784ab01d 100644 --- a/cmd/auth/wire.go +++ b/cmd/auth/wire.go @@ -9,7 +9,6 @@ import ( "github.com/origadmin/runtime" "origadmin/application/admin/internal/conf" - confpb "origadmin/application/admin/internal/conf/pb" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/features/auth/biz" "origadmin/application/admin/internal/features/auth/dal" @@ -24,11 +23,6 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err // Shared infrastructure providers providers.ProviderSet, - // Instructions for wire to extract nested configs - wire.FieldsOf(new(*conf.Config), "Bootstrap"), - wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), - wire.FieldsOf(new(*confpb.Bootstrap), "Captcha"), - // Service-specific providers data.ProviderSet, dal.ProviderSet, diff --git a/cmd/gateway/main.go b/cmd/gateway/main.go index cfcb4061..95f32cf0 100644 --- a/cmd/gateway/main.go +++ b/cmd/gateway/main.go @@ -1,76 +1,71 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - package main import ( + "flag" + "github.com/go-kratos/kratos/v2" - "github.com/go-kratos/kratos/v2/config" - "github.com/go-kratos/kratos/v2/config/file" - "github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/transport" + "github.com/joho/godotenv" + _ "github.com/sqlite3ent/sqlite3" // Import for sqlite3 driver - confpb "origadmin/application/admin/internal/conf/pb" + _ "github.com/origadmin/contrib/config/consul" + _ "github.com/origadmin/contrib/registry/consul" + "github.com/origadmin/runtime" + runtimebootstrap "github.com/origadmin/runtime/bootstrap" + "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/conf" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" + confhelper "origadmin/application/admin/internal/helpers/conf" ) var ( // Name is the name of the compiled software. Name = "origadmin.gateway.v1" // Version is the version of the compiled software. - Version string + Version = "v1.0.0" + // flagconf is the config flag. flagconf string ) func init() { - // You can use flags to get configuration file path - // flag.StringVar(&flagconf, "conf", "../../configs", "config path, eg: -conf config.yaml") + flag.StringVar(&flagconf, "conf", "", "config path, eg: -conf bootstrap.yaml") } - -func newApp(logger log.Logger, srv transport.Server) *kratos.App { - return kratos.New( - kratos.Name(Name), - kratos.Version(Version), - kratos.Metadata(map[string]string{}), - kratos.Logger(logger), - kratos.Server( - srv, - ), - ) +func NewApp(app *runtime.App, servers []transport.Server) *kratos.App { + return app.NewApp(servers) } func main() { - // use -conf to get config file path - // flag.Parse() + _ = godotenv.Load("resources/.env.gateway") - // for this example, we use a hardcoded config path - flagconf = "resources/configs" + flag.Parse() - c := config.New( - config.WithSource( - file.NewSource(flagconf), - ), - ) - defer c.Close() - - if err := c.Load(); err != nil { - panic(err) + confPath := confhelper.FindConfPath(flagconf) + if confPath == "" { + log.Fatalf("Could not find configuration file. Searched -conf flag, executable path, and development path.") } - var bc confpb.Bootstrap - if err := c.Scan(&bc); err != nil { - panic(err) + log.Infof("Loading configuration from: %s\n", confPath) + + rt := runtime.New(Name, Version) + err := rt.Load(confPath, runtimebootstrap.WithConfigTransformer(conf.New())) + if err != nil { + log.Fatalf("failed to create runtime: %v", err) } + defer rt.Config().Close() + log.Infof("Starting %s %s (ID: %s)\n", rt.AppInfo().Name(), rt.AppInfo().Version(), rt.AppInfo().ID()) - app, cleanup, err := wireApp(&bc, log.DefaultLogger) + bootstrapConfig, ok := rt.StructuredConfig().(*conf.Config) + if !ok { + log.Fatalf("failed to get bootstrap config") + } + app, cleanupApp, err := wireApp(rt, bootstrapConfig) if err != nil { - panic(err) + log.Fatalf("failed to wire app: %v", err) } - defer cleanup() + defer cleanupApp() - // start and wait for stop signal if err := app.Run(); err != nil { - panic(err) + log.Fatalf("app run failed: %v", err) } } diff --git a/cmd/gateway/wire.go b/cmd/gateway/wire.go index b2613fff..24fca885 100644 --- a/cmd/gateway/wire.go +++ b/cmd/gateway/wire.go @@ -10,16 +10,26 @@ package main import ( "github.com/go-kratos/kratos/v2" - "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" - confpb "origadmin/application/admin/internal/conf/pb" + "github.com/origadmin/runtime" + "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/gateway/client" "origadmin/application/admin/internal/gateway/server" "origadmin/application/admin/internal/gateway/service" + "origadmin/application/admin/internal/helpers/providers" ) // wireApp init kratos application. -func wireApp(bootstrap *confpb.Bootstrap, logger log.Logger) (*kratos.App, func(), error) { - panic(wire.Build(server.ProviderSet, client.ProviderSet, service.ProviderSet, newApp)) +func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { + panic(wire.Build( + // Shared infrastructure providers + providers.ProviderSet, + + // Service-specific providers + server.ProviderSet, + client.ProviderSet, + service.ProviderSet, + NewApp, + )) } diff --git a/cmd/gateway/wire_gen.go b/cmd/gateway/wire_gen.go index e51cf274..798add05 100644 --- a/cmd/gateway/wire_gen.go +++ b/cmd/gateway/wire_gen.go @@ -8,27 +8,42 @@ package main import ( "github.com/go-kratos/kratos/v2" - "github.com/go-kratos/kratos/v2/log" - "origadmin/application/admin/internal/conf/pb" + "github.com/origadmin/runtime" + "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/gateway/client" "origadmin/application/admin/internal/gateway/server" "origadmin/application/admin/internal/gateway/service" + "origadmin/application/admin/internal/helpers/providers" +) + +import ( + _ "github.com/origadmin/contrib/config/consul" + _ "github.com/origadmin/contrib/registry/consul" + _ "github.com/sqlite3ent/sqlite3" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" ) // Injectors from wire.go: // wireApp init kratos application. -func wireApp(bootstrap *confpb.Bootstrap, logger log.Logger) (*kratos.App, func(), error) { +func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { + confpbBootstrap := &bootstrap.Bootstrap + servers := confpbBootstrap.Servers authServiceClient, err := client.NewAuthClient(bootstrap) if err != nil { return nil, nil, err } - gatewayService := service.NewGatewayService(authServiceClient) - v, err := server.NewServers(bootstrap, gatewayService, logger) + userServiceClient, err := client.NewSystemClient(bootstrap) + if err != nil { + return nil, nil, err + } + gatewayService := service.NewGatewayService(authServiceClient, userServiceClient) + v := providers.ProvideLogger(app) + v2, err := server.NewServers(servers, gatewayService, v) if err != nil { return nil, nil, err } - app := newApp(logger, v) - return app, func() { + kratosApp := NewApp(app, v2) + return kratosApp, func() { }, nil } diff --git a/cmd/system/wire.go b/cmd/system/wire.go index 73c8ec5f..ec0bd6f1 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -14,7 +14,6 @@ import ( "github.com/origadmin/runtime" "origadmin/application/admin/internal/conf" - confpb "origadmin/application/admin/internal/conf/pb" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/features/system/biz" "origadmin/application/admin/internal/features/system/dal" @@ -29,10 +28,6 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err // Shared infrastructure providers providers.ProviderSet, - // Instructions for wire to extract nested configs - wire.FieldsOf(new(*conf.Config), "Bootstrap"), - wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), - // Service-specific providers data.ProviderSet, dal.ProviderSet, diff --git a/go.mod b/go.mod index 1e10cf5b..89ad3239 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0 replace github.com/origadmin/toolkits/i18n v0.0.0 => ../../toolkits/i18n -replace github.com/origadmin/runtime v0.2.13 => ../../runtime +replace github.com/origadmin/runtime v0.2.15 => ../../runtime replace github.com/origadmin/contrib v1.1.0 => ../../contrib diff --git a/internal/conf/pb/conf.proto b/internal/conf/pb/conf.proto index 4c9f1966..d55e7cdc 100644 --- a/internal/conf/pb/conf.proto +++ b/internal/conf/pb/conf.proto @@ -5,11 +5,12 @@ package conf.pb; import "config/data/v1/data.proto"; import "config/discovery/v1/discovery.proto"; import "config/logger/v1/logger.proto"; +import "config/middleware/cors/v1/cors.proto"; import "config/middleware/v1/middleware.proto"; import "config/transport/v1/transport.proto"; -import "security/v1/security.proto"; import "internal/conf/pb/captcha.proto"; import "internal/conf/pb/root.proto"; +import "security/v1/security.proto"; option go_package = "origadmin/application/admin/internal/conf/pb;confpb"; @@ -39,14 +40,17 @@ message Bootstrap { // Security configuration for authentication and authorization. contrib.api.security.v1.Security security = 8; + // CORS configuration for cross-origin resource sharing. + runtime.api.config.middleware.cors.v1.Cors cors = 9; + // Captcha feature specific configuration. - conf.pb.Captcha captcha = 9; + conf.pb.Captcha captcha = 10; // RootUser feature specific configuration for initial user setup. - conf.pb.RootUser root_user = 10; + conf.pb.RootUser root_user = 11; // Default discovery service name. - string default_discovery = 11; + string default_discovery = 12; } // SelectorGlobal defines the global selector/load-balancing strategy. diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index 35a1cfb5..a3d181bf 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -14,17 +14,17 @@ import ( "github.com/origadmin/runtime/service/transport/grpc" "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/api/v1/services/system" - confpb "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/conf" ) // ProviderSet is client providers. var ProviderSet = wire.NewSet(NewAuthClient, NewSystemClient) // NewAuthClient creates a new AuthAPI client. -func NewAuthClient(bootstrap *confpb.Bootstrap) (auth.AuthServiceClient, error) { +func NewAuthClient(bootstrap *conf.Config) (auth.AuthServiceClient, error) { var clientConfig *transportv1.Client - if bootstrap.Clients != nil { - for _, cli := range bootstrap.Clients.Configs { + if bootstrap.Bootstrap.Clients != nil { + for _, cli := range bootstrap.Bootstrap.Clients.Configs { if cli.Name == "client.auth" { clientConfig = cli break @@ -49,10 +49,10 @@ func NewAuthClient(bootstrap *confpb.Bootstrap) (auth.AuthServiceClient, error) } // NewSystemClient creates a new SystemAPI client. -func NewSystemClient(bootstrap *confpb.Bootstrap) (system.UserServiceClient, error) { +func NewSystemClient(bootstrap *conf.Config) (system.UserServiceClient, error) { var clientConfig *transportv1.Client - if bootstrap.Clients != nil { - for _, cli := range bootstrap.Clients.Configs { + if bootstrap.Bootstrap.Clients != nil { + for _, cli := range bootstrap.Bootstrap.Clients.Configs { if cli.Name == "client.system" { clientConfig = cli break diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index 44dba53d..4e3d291b 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -7,51 +7,71 @@ package server import ( "errors" - "github.com/go-kratos/kratos/v2/log" - "github.com/go-kratos/kratos/v2/transport" - "github.com/go-kratos/kratos/v2/transport/http" "github.com/google/wire" + httpv1 "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1" + transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service/transport" + "github.com/origadmin/runtime/service/transport/http" gatewayAPI "origadmin/application/admin/api/v1/services/gateway" - confpb "origadmin/application/admin/internal/conf/pb" "origadmin/application/admin/internal/gateway/service" - httpv1 "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1" ) // ProviderSet is server providers. -var ProviderSet = wire.NewSet(NewHTTPServer) +var ProviderSet = wire.NewSet(NewServers) -// NewHTTPServer new an HTTP server. -func NewHTTPServer(bootstrap *confpb.Bootstrap, gw *service.GatewayService, logger log.Logger) (transport.Server, - error) { - var opts = []http.ServerOption{ - http.Middleware( - // Add any HTTP middleware here if needed - ), +// NewServers creates and configures the gateway service servers (HTTP). +func NewServers(cfg *transportv1.Servers, svc *service.GatewayService, logger log.Logger) ([]transport.Server, error) { + if cfg == nil { + return nil, errors.New("servers config is nil") } - var httpServerConfig *httpv1.Server - if bootstrap.Servers != nil { - for _, srv := range bootstrap.Servers.Configs { - if srv.Protocol == "http" { - httpServerConfig = srv.GetHttp() - break + var transportServers []transport.Server + for _, serverCfg := range cfg.GetConfigs() { + // Filter server configurations by name. + if serverCfg.GetName() != "gateway" { + continue + } + + switch serverCfg.GetProtocol() { + case "http": + srv, err := NewHTTPServer(serverCfg.GetHttp(), svc, logger) + if err != nil { + return nil, err } + transportServers = append(transportServers, srv) + default: + // Log a warning for unsupported protocols but don't return an error + // to allow other servers to start. + log.NewHelper(logger).Warnf("protocol is not supported: %s", serverCfg.GetProtocol()) } } - if httpServerConfig == nil { - return nil, errors.New("http server config is not found") + if len(transportServers) == 0 { + return nil, errors.New("no servers named 'gateway' were created") } - if httpServerConfig.Addr != "" { - opts = append(opts, http.Address(httpServerConfig.Addr)) + return transportServers, nil +} + +// NewHTTPServer new an HTTP server. +func NewHTTPServer(cfg *httpv1.Server, svc *service.GatewayService, logger log.Logger) (transport.Server, error) { + if cfg == nil { + return nil, errors.New("http config is nil") } - if httpServerConfig.Timeout != nil { - opts = append(opts, http.Timeout(httpServerConfig.Timeout.AsDuration())) + + // Create server options. The runtime's NewServer will handle middleware + // and other configurations like CORS based on the provided cfg. + opts := &http.ServerOptions{} + + // Create the HTTP server. + srv, err := http.NewServer(cfg, opts) + if err != nil { + return nil, err } - srv := http.NewServer(opts...) - gatewayAPI.RegisterGatewayServiceHTTPServer(srv, gw) + // Register the gateway service. + gatewayAPI.RegisterGatewayServiceHTTPServer(srv, svc) return srv, nil } diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go index 6c421161..4c103015 100644 --- a/internal/helpers/providers/providers.go +++ b/internal/helpers/providers/providers.go @@ -102,6 +102,10 @@ func ProvideLogger(app *runtime.App) log.Logger { } var ProviderSet = wire.NewSet( + // Instructions for wire to extract nested configs + wire.FieldsOf(new(*conf.Config), "Bootstrap"), + wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), + wire.FieldsOf(new(*confpb.Bootstrap), "Captcha"), ProvideLogger, ProvideCache, ProvideAuthenticatorOptions, diff --git a/resources/configs/clients.yaml b/resources/configs/clients.yaml new file mode 100644 index 00000000..241fccc7 --- /dev/null +++ b/resources/configs/clients.yaml @@ -0,0 +1,10 @@ +clients: + configs: + - name: "client.auth" + grpc: + endpoint: "discovery:///auth" + timeout: 5s + - name: "client.system" + grpc: + endpoint: "discovery:///system" + timeout: 5s diff --git a/resources/configs/server.yaml b/resources/configs/server.yaml index 80930df1..94fc9f79 100644 --- a/resources/configs/server.yaml +++ b/resources/configs/server.yaml @@ -1,21 +1,34 @@ -# server.yaml servers: configs: - - grpc: - # Reads the port from the GRPC_PORT environment variable; defaults to 9090 if not present. - addr: 0.0.0.0:${GRPC_PORT:9090} - middlewares: - - recovery - - logger - network: tcp - name: grpc_server - protocol: grpc - - http: - # Reads the port from the HTTP_PORT environment variable; defaults to 8080 if not present. - addr: 0.0.0.0:${HTTP_PORT:8080} - middlewares: - - recovery - - logger - network: tcp - name: http_server - protocol: http + # Gateway Service HTTP Server + - name: "gateway" + protocol: "http" + http: + addr: "0.0.0.0:8000" + timeout: 5s + cors: + allowed_origins: + - "*" + allowed_methods: + - "GET" + - "POST" + - "PUT" + - "DELETE" + - "OPTIONS" + allowed_headers: + - "*" + allow_credentials: true + + # Auth Service gRPC Server + - name: "auth" + protocol: "grpc" + grpc: + addr: "0.0.0.0:9001" + timeout: 5s + + # System Service gRPC Server + - name: "system" + protocol: "grpc" + grpc: + addr: "0.0.0.0:9002" + timeout: 5s From c5549c97562dd8781be17a8daa8024df35fa59ed Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 05:25:06 +0800 Subject: [PATCH 116/158] refactor(gateway): simplify service initialization and server setup, remove unused providers dependency --- cmd/gateway/wire_gen.go | 11 ++--- internal/conf/pb/conf.proto | 4 +- internal/gateway/server/server.go | 36 ++++++++++------ internal/gateway/service/service.go | 64 +++-------------------------- 4 files changed, 37 insertions(+), 78 deletions(-) diff --git a/cmd/gateway/wire_gen.go b/cmd/gateway/wire_gen.go index 798add05..7a189528 100644 --- a/cmd/gateway/wire_gen.go +++ b/cmd/gateway/wire_gen.go @@ -13,7 +13,6 @@ import ( "origadmin/application/admin/internal/gateway/client" "origadmin/application/admin/internal/gateway/server" "origadmin/application/admin/internal/gateway/service" - "origadmin/application/admin/internal/helpers/providers" ) import ( @@ -37,13 +36,15 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err if err != nil { return nil, nil, err } - gatewayService := service.NewGatewayService(authServiceClient, userServiceClient) - v := providers.ProvideLogger(app) - v2, err := server.NewServers(servers, gatewayService, v) + gatewayService, err := service.NewGatewayService(authServiceClient, userServiceClient) if err != nil { return nil, nil, err } - kratosApp := NewApp(app, v2) + v, err := server.NewServers(app, servers, gatewayService) + if err != nil { + return nil, nil, err + } + kratosApp := NewApp(app, v) return kratosApp, func() { }, nil } diff --git a/internal/conf/pb/conf.proto b/internal/conf/pb/conf.proto index d55e7cdc..aac4b57c 100644 --- a/internal/conf/pb/conf.proto +++ b/internal/conf/pb/conf.proto @@ -40,8 +40,8 @@ message Bootstrap { // Security configuration for authentication and authorization. contrib.api.security.v1.Security security = 8; - // CORS configuration for cross-origin resource sharing. - runtime.api.config.middleware.cors.v1.Cors cors = 9; +// // CORS configuration for cross-origin resource sharing. +// runtime.api.config.middleware.cors.v1.Cors cors = 9; // Captcha feature specific configuration. conf.pb.Captcha captcha = 10; diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index 4e3d291b..d86abf64 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -7,11 +7,12 @@ package server import ( "errors" + "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" + "github.com/origadmin/runtime" httpv1 "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1" transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service/transport" "github.com/origadmin/runtime/service/transport/http" gatewayAPI "origadmin/application/admin/api/v1/services/gateway" @@ -22,13 +23,15 @@ import ( var ProviderSet = wire.NewSet(NewServers) // NewServers creates and configures the gateway service servers (HTTP). -func NewServers(cfg *transportv1.Servers, svc *service.GatewayService, logger log.Logger) ([]transport.Server, error) { - if cfg == nil { +func NewServers(app *runtime.App, serversCfg *transportv1.Servers, + svc *service.GatewayService) ([]transport.Server, + error) { + if serversCfg == nil { return nil, errors.New("servers config is nil") } var transportServers []transport.Server - for _, serverCfg := range cfg.GetConfigs() { + for _, serverCfg := range serversCfg.GetConfigs() { // Filter server configurations by name. if serverCfg.GetName() != "gateway" { continue @@ -36,15 +39,14 @@ func NewServers(cfg *transportv1.Servers, svc *service.GatewayService, logger lo switch serverCfg.GetProtocol() { case "http": - srv, err := NewHTTPServer(serverCfg.GetHttp(), svc, logger) + srv, err := NewHTTPServer(app, serverCfg.GetHttp(), svc) if err != nil { return nil, err } transportServers = append(transportServers, srv) default: - // Log a warning for unsupported protocols but don't return an error - // to allow other servers to start. - log.NewHelper(logger).Warnf("protocol is not supported: %s", serverCfg.GetProtocol()) + log.NewHelper(app.Logger()).Warn("protocol", serverCfg.GetProtocol(), "msg", + "protocol is not supported") } } @@ -56,14 +58,22 @@ func NewServers(cfg *transportv1.Servers, svc *service.GatewayService, logger lo } // NewHTTPServer new an HTTP server. -func NewHTTPServer(cfg *httpv1.Server, svc *service.GatewayService, logger log.Logger) (transport.Server, error) { +func NewHTTPServer(app *runtime.App, cfg *httpv1.Server, svc *service.GatewayService) (transport.Server, error) { if cfg == nil { return nil, errors.New("http config is nil") } - - // Create server options. The runtime's NewServer will handle middleware - // and other configurations like CORS based on the provided cfg. - opts := &http.ServerOptions{} + middlewareProvider, err := app.MiddlewareProvider() + if err != nil { + return nil, err + } + mws, err := middlewareProvider.ServerMiddlewares() + if err != nil { + return nil, err + } + // Create server options and provide the application's available middlewares and discoveries. + opts := &http.ServerOptions{ + ServerMiddlewares: mws, + } // Create the HTTP server. srv, err := http.NewServer(cfg, opts) diff --git a/internal/gateway/service/service.go b/internal/gateway/service/service.go index 60a296d3..a26ead6d 100644 --- a/internal/gateway/service/service.go +++ b/internal/gateway/service/service.go @@ -5,79 +5,27 @@ package service import ( - "context" - "errors" - "github.com/google/wire" "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/api/v1/services/gateway" + gatewayAPI "origadmin/application/admin/api/v1/services/gateway" "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/api/v1/services/types" ) // ProviderSet is service providers. var ProviderSet = wire.NewSet(NewGatewayService) -// GatewayService implements the GatewayAPI service. +// GatewayService is a gateway service. type GatewayService struct { - gateway.UnimplementedGatewayServiceServer - + gatewayAPI.UnimplementedGatewayServiceServer authClient auth.AuthServiceClient systemClient system.UserServiceClient } -// NewGatewayService creates a new gateway service. -func NewGatewayService(authClient auth.AuthServiceClient, systemClient system.UserServiceClient) *GatewayService { +// NewGatewayService new a gateway service. +func NewGatewayService(authClient auth.AuthServiceClient, systemClient system.UserServiceClient) (*GatewayService, error) { return &GatewayService{ authClient: authClient, systemClient: systemClient, - } -} - -func (g *GatewayService) Login(ctx context.Context, request *auth.LoginRequest) (*auth.LoginResponse, error) { - return g.authClient.Login(ctx, request) -} - -func (g *GatewayService) GetCaptcha(ctx context.Context, request *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { - return g.authClient.GetCaptcha(ctx, request) -} - -func (g *GatewayService) GetProfile(ctx context.Context, request *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { - // Assuming MeService is part of AuthService, if not, a new client for MeService is needed - // This is a placeholder, as MeService is not directly available on AuthServiceClient - // You might need to create a MeServiceClient - return nil, errors.New("GetProfile not implemented on auth client") -} - -func (g *GatewayService) ListUsers(ctx context.Context, request *system.ListUsersRequest) (*system.ListUsersResponse, error) { - return g.systemClient.ListUsers(ctx, request) -} - -func (g *GatewayService) GetUser(ctx context.Context, request *system.GetUserRequest) (*types.User, error) { - res, err := g.systemClient.GetUser(ctx, request) - if err != nil { - return nil, err - } - return res.User, nil -} - -func (g *GatewayService) CreateUser(ctx context.Context, request *system.CreateUserRequest) (*types.User, error) { - res, err := g.systemClient.CreateUser(ctx, request) - if err != nil { - return nil, err - } - return res.User, nil -} - -func (g *GatewayService) UpdateUser(ctx context.Context, request *system.UpdateUserRequest) (*types.User, error) { - res, err := g.systemClient.UpdateUser(ctx, request) - if err != nil { - return nil, err - } - return res.User, nil -} - -func (g *GatewayService) DeleteUser(ctx context.Context, request *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { - return g.systemClient.DeleteUser(ctx, request) + }, nil } From 61d08e44a7518fbf84e7a2b0ec92a16b63516f07 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 05:38:03 +0800 Subject: [PATCH 117/158] feat(client): refactor gRPC client creation and add SystemClientSet for shared connection --- internal/gateway/client/client.go | 70 ++++++++++++++++++------------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index a3d181bf..8589ae0a 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -9,23 +9,34 @@ import ( "errors" "github.com/google/wire" + "google.golang.org/grpc" transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" - "github.com/origadmin/runtime/service/transport/grpc" + runtimegrpc "github.com/origadmin/runtime/service/transport/grpc" "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/conf" ) // ProviderSet is client providers. -var ProviderSet = wire.NewSet(NewAuthClient, NewSystemClient) +var ProviderSet = wire.NewSet(NewAuthClient, NewSystemClient, NewSystemClientSet) -// NewAuthClient creates a new AuthAPI client. -func NewAuthClient(bootstrap *conf.Config) (auth.AuthServiceClient, error) { +// SystemClientSet holds all the clients for the 'system' service. +// This avoids creating multiple connections to the same downstream service. +type SystemClientSet struct { + UserClient system.UserServiceClient + RoleClient system.RoleServiceClient + PermissionClient system.PermissionServiceClient + ResourceClient system.ResourceServiceClient + ViewClient system.ViewServiceClient +} + +// newGRPCConn is a private helper to create a gRPC connection from config. +func newGRPCConn(bootstrap *conf.Config, clientName string) (*grpc.ClientConn, error) { var clientConfig *transportv1.Client if bootstrap.Bootstrap.Clients != nil { for _, cli := range bootstrap.Bootstrap.Clients.Configs { - if cli.Name == "client.auth" { + if cli.Name == clientName { clientConfig = cli break } @@ -33,43 +44,46 @@ func NewAuthClient(bootstrap *conf.Config) (auth.AuthServiceClient, error) { } if clientConfig == nil { - return nil, errors.New("client config not found: client.auth") + return nil, errors.New("client config not found: " + clientName) } grpcConfig := clientConfig.GetGrpc() if grpcConfig == nil { - return nil, errors.New("grpc client config not found: client.auth") + return nil, errors.New("grpc client config not found: " + clientName) } - conn, err := grpc.NewClient(context.Background(), grpcConfig, &grpc.ClientOptions{}) + return runtimegrpc.NewClient(context.Background(), grpcConfig, &runtimegrpc.ClientOptions{}) +} + +// NewAuthClient creates a new AuthAPI client. +func NewAuthClient(bootstrap *conf.Config) (auth.AuthServiceClient, error) { + conn, err := newGRPCConn(bootstrap, "client.auth") if err != nil { return nil, err } return auth.NewAuthServiceClient(conn), nil } -// NewSystemClient creates a new SystemAPI client. -func NewSystemClient(bootstrap *conf.Config) (system.UserServiceClient, error) { - var clientConfig *transportv1.Client - if bootstrap.Bootstrap.Clients != nil { - for _, cli := range bootstrap.Bootstrap.Clients.Configs { - if cli.Name == "client.system" { - clientConfig = cli - break - } - } - } - - if clientConfig == nil { - return nil, errors.New("client config not found: client.system") - } - - grpcConfig := clientConfig.GetGrpc() - if grpcConfig == nil { - return nil, errors.New("grpc client config not found: client.system") +// NewSystemClientSet creates a set of clients for the system service. +// It establishes a single gRPC connection and initializes all related clients. +func NewSystemClientSet(bootstrap *conf.Config) (*SystemClientSet, error) { + conn, err := newGRPCConn(bootstrap, "client.system") + if err != nil { + return nil, err } + return &SystemClientSet{ + UserClient: system.NewUserServiceClient(conn), + RoleClient: system.NewRoleServiceClient(conn), + PermissionClient: system.NewPermissionServiceClient(conn), + ResourceClient: system.NewResourceServiceClient(conn), + ViewClient: system.NewViewServiceClient(conn), + }, nil +} - conn, err := grpc.NewClient(context.Background(), grpcConfig, &grpc.ClientOptions{}) +// NewSystemClient creates a new SystemAPI client. +// Deprecated: Use NewSystemClientSet instead to access all clients for the system service. +func NewSystemClient(bootstrap *conf.Config) (system.UserServiceClient, error) { + conn, err := newGRPCConn(bootstrap, "client.system") if err != nil { return nil, err } From 12406a7bb9e0ba2b0004b5b4269e6f347b470854 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 14:21:38 +0800 Subject: [PATCH 118/158] refactor(datastore): remove deprecated biz and dal packages for system module --- Dockerfile | 51 + docker-compose.yml | 82 ++ go.mod | 61 +- go.sum | 373 +++-- internal/features/datastore/biz/biz.go | 24 - internal/features/datastore/biz/datastore.go | 92 -- internal/features/datastore/biz/provider.go | 22 - internal/features/datastore/dal/dal.go | 9 - internal/features/datastore/dal/menu.dal.go | 177 --- .../features/datastore/dal/permission.dal.go | 172 --- internal/features/datastore/dal/provider.go | 24 - .../features/datastore/dal/resource.dal.go | 152 -- internal/features/datastore/dal/role.dal.go | 176 --- internal/features/datastore/dal/user.dal.go | 227 --- internal/features/datastore/dto/custom.gen.go | 52 + internal/features/datastore/dto/department.go | 12 - internal/features/datastore/dto/dto.gen.go | 1279 +++++++++++++++++ internal/features/datastore/dto/dto.go | 1014 +------------ internal/features/datastore/dto/menu.go | 75 - internal/features/datastore/dto/permission.go | 83 -- internal/features/datastore/dto/position.go | 12 - internal/features/datastore/dto/resource.go | 83 -- .../features/datastore/dto/resource_type.go | 65 - internal/features/datastore/dto/role.go | 109 -- internal/features/datastore/dto/user.go | 147 -- internal/features/datastore/server/gins.go | 67 - internal/features/datastore/server/grpc.go | 27 - internal/features/datastore/server/http.go | 27 - internal/features/datastore/server/server.go | 62 +- internal/gateway/client/client.go | 46 +- internal/gateway/server/server.go | 87 +- internal/gateway/service/service.go | 9 +- internal/helpers/resp/result.go | 18 +- .../securityx/{auth.go => auth.go.bak} | 0 .../{security.go => security.go.bak} | 0 .../securityx/{user.go => user.go.bak} | 0 internal/helpers/time/time.go | 4 +- test/token_test.go | 141 -- 38 files changed, 1876 insertions(+), 3185 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml delete mode 100644 internal/features/datastore/biz/biz.go delete mode 100644 internal/features/datastore/biz/datastore.go delete mode 100644 internal/features/datastore/biz/provider.go delete mode 100644 internal/features/datastore/dal/dal.go delete mode 100644 internal/features/datastore/dal/menu.dal.go delete mode 100644 internal/features/datastore/dal/permission.dal.go delete mode 100644 internal/features/datastore/dal/provider.go delete mode 100644 internal/features/datastore/dal/resource.dal.go delete mode 100644 internal/features/datastore/dal/role.dal.go delete mode 100644 internal/features/datastore/dal/user.dal.go create mode 100644 internal/features/datastore/dto/custom.gen.go delete mode 100644 internal/features/datastore/dto/department.go create mode 100644 internal/features/datastore/dto/dto.gen.go delete mode 100644 internal/features/datastore/dto/menu.go delete mode 100644 internal/features/datastore/dto/permission.go delete mode 100644 internal/features/datastore/dto/position.go delete mode 100644 internal/features/datastore/dto/resource.go delete mode 100644 internal/features/datastore/dto/resource_type.go delete mode 100644 internal/features/datastore/dto/role.go delete mode 100644 internal/features/datastore/dto/user.go delete mode 100644 internal/features/datastore/server/gins.go delete mode 100644 internal/features/datastore/server/grpc.go delete mode 100644 internal/features/datastore/server/http.go rename internal/helpers/securityx/{auth.go => auth.go.bak} (100%) rename internal/helpers/securityx/{security.go => security.go.bak} (100%) rename internal/helpers/securityx/{user.go => user.go.bak} (100%) delete mode 100644 test/token_test.go diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..dae27d41 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,51 @@ +# Dockerfile for Go services in the backend project +# This Dockerfile is designed to be built from the monorepo root. +# Example: docker build -f projects/backend/Dockerfile --build-arg SERVICE_NAME=auth . + +# --- Builder Stage --- +FROM golang:1.25.3-alpine AS builder + +WORKDIR /build + +# Set GOPROXY for faster dependency downloads in China +ENV GOPROXY=https://goproxy.cn,direct + +# To leverage Docker's layer caching, we first copy only the files +# that define our dependencies. +COPY go.mod go.sum ./ + +# Download all dependencies based on the workspace and module files. +# This step is cached as long as the dependency files don't change. +RUN go mod download + +# Now, copy the entire source code. +COPY . . + +# Declare the service name to be built, passed as a build argument. +ARG SERVICE_NAME + +# Build the Go application. +# - CGO_ENABLED=0 produces a static binary. +# - GOOS=linux ensures it's built for the Alpine base image. +# - -a flag forces rebuilding of packages that are already up-to-date. +# - -o specifies the output file path. +RUN CGO_ENABLED=0 GOOS=linux go build -a -o /app/${SERVICE_NAME} ./projects/backend/cmd/${SERVICE_NAME} + +# --- Runner Stage --- +FROM alpine:latest + +WORKDIR /app + +# Argument for the service name, needed again in this stage. +ARG SERVICE_NAME + +# Copy the compiled binary from the builder stage. +COPY --from=builder /app/${SERVICE_NAME} . + +# Copy the service's configuration files. +# The path is relative to the build context (monorepo root). +COPY resources/configs /data/configs + +# Define the entrypoint for the container. +# It executes the service binary, passing the path to the config directory. +ENTRYPOINT ["./${SERVICE_NAME}", "-conf", "/data/configs"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..1d284d76 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,82 @@ +networks: + origadmin-net: + driver: bridge + +services: + # Service Discovery + consul: + image: hashicorp/consul:1.15.4 + container_name: consul + ports: + - "8500:8500" + networks: + - origadmin-net + command: "agent -server -bootstrap-expect=1 -ui -client=0.0.0.0" + + # Database + postgres: + image: postgres:16-alpine + container_name: postgres + environment: + POSTGRES_DB: origadmin + POSTGRES_USER: user + POSTGRES_PASSWORD: password + ports: + - "5432:5432" + networks: + - origadmin-net + volumes: + - postgres_data:/var/lib/postgresql/data + + # Auth Service + auth: + build: + context: . + dockerfile: Dockerfile + args: + SERVICE_NAME: auth + container_name: auth-service + depends_on: + - consul + - postgres + ports: + - "9001:9001" + networks: + - origadmin-net + + # System Service + system: + build: + context: . + dockerfile: Dockerfile + args: + SERVICE_NAME: system + container_name: system-service + depends_on: + - consul + - postgres + ports: + - "9002:9002" + networks: + - origadmin-net + + # Gateway Service + gateway: + build: + context: . + dockerfile: Dockerfile + args: + SERVICE_NAME: gateway + container_name: gateway-service + depends_on: + - consul + - auth + - system + ports: + - "8000:8000" + networks: + - origadmin-net + +volumes: + postgres_data: + driver: local diff --git a/go.mod b/go.mod index 89ad3239..a0a16444 100644 --- a/go.mod +++ b/go.mod @@ -4,43 +4,46 @@ go 1.25.3 replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0.5.4 -replace github.com/origadmin/toolkits/i18n v0.0.0 => ../../toolkits/i18n - -replace github.com/origadmin/runtime v0.2.15 => ../../runtime - -replace github.com/origadmin/contrib v1.1.0 => ../../contrib +//replace github.com/origadmin/runtime v0.2.15 => ../../runtime +// +//replace github.com/origadmin/contrib v1.1.0 => ../../contrib require ( entgo.io/ent v0.14.5 github.com/casbin/casbin/v2 v2.135.0 github.com/envoyproxy/protoc-gen-validate v1.3.0 github.com/go-kratos/kratos/v2 v2.9.2 - github.com/go-redis/redis/v8 v8.11.5 github.com/goexts/generic v0.14.0 github.com/golang-jwt/jwt/v5 v5.3.0 // indirect - github.com/google/gnostic v0.7.1 // indirect + github.com/google/gnostic v0.7.1 github.com/google/uuid v1.6.0 github.com/google/wire v0.7.0 - github.com/gorilla/handlers v1.5.2 github.com/mattn/go-sqlite3 v1.14.32 // indirect github.com/mojocn/base64Captcha v1.3.8 github.com/origadmin/contrib v1.1.0 - github.com/origadmin/entslog/v3 v3.1.1 github.com/origadmin/runtime v0.2.14 github.com/origadmin/slog-kratos v1.0.5 // indirect - github.com/origadmin/toolkits v1.2.0 github.com/origadmin/toolkits/codec v1.2.0 github.com/origadmin/toolkits/crypto v1.2.0 github.com/origadmin/toolkits/errors v1.2.0 github.com/sony/sonyflake v1.3.0 github.com/sqlite3ent/sqlite3 v1.40.0 - golang.org/x/net v0.47.0 - google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b // indirect + golang.org/x/net v0.47.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b google.golang.org/grpc v1.77.0 google.golang.org/protobuf v1.36.11 ) -require github.com/joho/godotenv v1.5.1 +require ( + github.com/bufbuild/buf v1.61.0 + github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251217105121-fb8e43efb207 + github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251217105121-fb8e43efb207 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 + github.com/joho/godotenv v1.5.1 + github.com/origadmin/toolkits/i18n v1.2.0 + golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 + google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0 +) require ( ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 // indirect @@ -69,16 +72,13 @@ require ( github.com/agext/levenshtein v1.2.3 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect + github.com/armon/go-metrics v0.4.1 // indirect github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect - github.com/bufbuild/buf v1.61.0 // indirect github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8 // indirect github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1 // indirect - github.com/bytedance/gopkg v0.1.3 // indirect - github.com/bytedance/sonic v1.14.2 // indirect - github.com/bytedance/sonic/loader v0.4.0 // indirect github.com/casbin/govaluate v1.3.0 // indirect github.com/catppuccin/go v0.3.0 // indirect github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 // indirect @@ -94,11 +94,11 @@ require ( github.com/clipperhouse/displaywidth v0.6.2 // indirect github.com/clipperhouse/stringish v0.1.1 // indirect github.com/clipperhouse/uax29/v2 v2.3.0 // indirect - github.com/cloudwego/base64x v0.1.6 // indirect github.com/containerd/errdefs v1.0.0 // indirect github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.18.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect + github.com/dchest/uniuri v1.2.0 // indirect github.com/distribution/reference v0.6.0 // indirect github.com/docker/cli v29.0.4+incompatible // indirect github.com/docker/distribution v2.8.3+incompatible // indirect @@ -114,14 +114,15 @@ require ( github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/go-chi/chi/v5 v5.2.3 // indirect github.com/go-kratos/aegis v0.2.0 // indirect - github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251217105121-fb8e43efb207 // indirect github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251217105121-fb8e43efb207 // indirect - github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251217105121-fb8e43efb207 // indirect + github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20251201062103-6f0b3015b803 // indirect + github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20251201062103-6f0b3015b803 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-openapi/inflect v0.21.2 // indirect github.com/go-playground/form/v4 v4.3.0 // indirect + github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gofrs/flock v0.13.0 // indirect github.com/golang-cz/devslog v0.0.15 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect @@ -132,16 +133,21 @@ require ( github.com/google/go-containerregistry v0.20.7 // indirect github.com/google/subcommands v1.2.0 // indirect github.com/gorilla/mux v1.8.1 // indirect + github.com/hashicorp/consul/api v1.33.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/go-rootcerts v1.0.2 // indirect + github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/hcl/v2 v2.23.0 // indirect + github.com/hashicorp/serf v0.10.1 // indirect github.com/iancoleman/strcase v0.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jdx/go-netrc v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.18.2 // indirect - github.com/klauspost/cpuid/v2 v2.3.0 // indirect github.com/klauspost/pgzip v1.2.6 // indirect github.com/lmittmann/tint v1.1.2 // indirect github.com/lucasb-eyer/go-colorful v1.3.0 // indirect @@ -155,19 +161,18 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/term v0.5.2 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/termenv v0.16.0 // indirect github.com/ncruces/go-strftime v0.1.10 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect github.com/origadmin/toolkits/slogx v1.1.0 // indirect + github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/petermattis/goid v0.0.0-20251121121749-a11dd1a45f9a // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect @@ -187,11 +192,11 @@ require ( github.com/spf13/cobra v1.10.2 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/stoewer/go-strcase v1.3.1 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/tetratelabs/wazero v1.9.0 // indirect github.com/tidwall/btree v1.8.1 // indirect github.com/tklauser/go-sysconf v0.3.16 // indirect github.com/tklauser/numcpus v0.11.0 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/vbatts/tar-split v0.12.2 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect @@ -209,9 +214,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.1 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/arch v0.22.0 // indirect golang.org/x/crypto v0.45.0 // indirect - golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect golang.org/x/image v0.26.0 // indirect golang.org/x/mod v0.30.0 // indirect golang.org/x/sync v0.18.0 // indirect @@ -220,8 +223,6 @@ require ( golang.org/x/text v0.31.0 // indirect golang.org/x/tools v0.39.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect - google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect modernc.org/libc v1.66.10 // indirect diff --git a/go.sum b/go.sum index de2ecbd9..c0cf9afc 100644 --- a/go.sum +++ b/go.sum @@ -1,27 +1,15 @@ ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9 h1:E0wvcUXTkgyN4wy4LGtNzMNGMytJN8afmIWXJVMi4cc= ariga.io/atlas v0.32.1-0.20250325101103-175b25e1c1b9/go.mod h1:Oe1xWPuu5q9LzyrWfbZmEZxFYeu4BHTyzfjeW2aZp/w= -buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.10-20250718181942-e35f9b667443.1 h1:FzJGrb8r7vir+P3zJ5Ebey8p54LYTYtQsrM/U35YO9Q= -buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.10-20250718181942-e35f9b667443.1/go.mod h1:E6HwqUm4Ag7bXtg/tX7jHWO7CgpknbmeACgDax0icV0= buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.11-20250718181942-e35f9b667443.1 h1:zQ9C3e6FtwSZUFuKAQfpIKGFk5ZuRoGt5g35Bix55sI= buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.11-20250718181942-e35f9b667443.1/go.mod h1:1Znr6gmYBhbxWUPRrrVnSLXQsz8bvFVw1HHJq2bI3VQ= -buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.10-20250109164928-1da0de137947.1 h1:9hkMnVoImDlY7rTlAWIWXdkGUKOjf3YlyZeSbYT29uA= -buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.10-20250109164928-1da0de137947.1/go.mod h1:/AouMCAeQ+kB7+RRFpdUlZe3503p18VoUNcU2AFqZXM= buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.11-20250109164928-1da0de137947.1 h1:HwzzCRS4ZrEm1++rzSDxHnO0DOjiT1b8I/24e8a4exY= buf.build/gen/go/bufbuild/protodescriptor/protocolbuffers/go v1.36.11-20250109164928-1da0de137947.1/go.mod h1:8PRKXhgNes29Tjrnv8KdZzg3I1QceOkzibW1QK7EXv0= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1 h1:31on4W/yPcV4nZHL4+UCiCvLPsMqe/vJcNg8Rci0scc= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.10-20250912141014-52f32327d4b0.1/go.mod h1:fUl8CEN/6ZAMk6bP8ahBJPUJw7rbp+j4x+wCcYi2IG4= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1 h1:j9yeqTWEFrtimt8Nng2MIeRrpoCvQzM9/g25XTvqUGg= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.11-20251209175733-2a1774d88802.1/go.mod h1:tvtbpgaVXZX4g6Pn+AnzFycuRK3MOz5HJfEGeEllXYM= -buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251027152159-f1066ce064ca.2 h1:Dbh4Edwy5qHlz1/boPAQ7T5Q7ZDMgEuQlEbXa94+JEo= -buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251027152159-f1066ce064ca.2/go.mod h1:SqqTA3aiYVDkpDINxgbxDT6QBjkVjdqUXtbiz6DiWIg= buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251202164234-62b14f0b533c.2 h1:eQ6XRVUaYYZFOZvBsyrOYLWbw6464s5dVnHscxa0b8w= buf.build/gen/go/bufbuild/registry/connectrpc/go v1.19.1-20251202164234-62b14f0b533c.2/go.mod h1:omxVRch3jEPMINnUipLsuRWoEhND6LPXELKBG7xzyDw= -buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.10-20251027152159-f1066ce064ca.1 h1:5tUFlRgcC+N2JJtjwlwyb2J4bBk/bJYLXk50zlewtzk= -buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.10-20251027152159-f1066ce064ca.1/go.mod h1:AaYXXeRvnOc151wEuupAmn58Mh9bccKce2kk3QKMIrQ= buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.11-20251202164234-62b14f0b533c.1 h1:PdfIJUbUVKdajMVYuMdvr2Wvo+wmzGnlPEYA4bhFaWI= buf.build/gen/go/bufbuild/registry/protocolbuffers/go v1.36.11-20251202164234-62b14f0b533c.1/go.mod h1:1JJi9jvOqRxSMa+JxiZSm57doB+db/1WYCIa2lHfc40= -buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.10-20241007202033-cf42259fcbfc.1 h1:CzM0kZcoaIr8+R4i8QVorUNRM/CqMr87i3j+w2pdpCc= -buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.10-20241007202033-cf42259fcbfc.1/go.mod h1:bG+Fa7tcA+4pW0JdOh4h7iKjleyZIKhfVzVS10qfrnk= buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.11-20241007202033-cf42259fcbfc.1 h1:iGPvEJltOXUMANWf0zajcRcbiOXLD90ZwPUFvbcuv6Q= buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.11-20241007202033-cf42259fcbfc.1/go.mod h1:nWVKKRA29zdt4uvkjka3i/y4mkrswyWwiu0TbdX0zts= buf.build/go/app v0.2.0 h1:NYaH13A+RzPb7M5vO8uZYZ2maBZI5+MS9A9tQm66fy8= @@ -40,8 +28,6 @@ buf.build/go/spdx v0.2.0 h1:IItqM0/cMxvFJJumcBuP8NrsIzMs/UYjp/6WSpq8LTw= buf.build/go/spdx v0.2.0/go.mod h1:bXdwQFem9Si3nsbNy8aJKGPoaPi5DKwdeEp5/ArZ6w8= buf.build/go/standard v0.1.0 h1:g98T9IyvAl0vS3Pq8iVk6Cvj2ZiFvoUJRtfyGa0120U= buf.build/go/standard v0.1.0/go.mod h1:PiqpHz/7ZFq+kqvYhc/SK3lxFIB9N/aiH2CFC2JHIQg= -cel.dev/expr v0.25.0 h1:qbCFvDJJthxLvf3TqeF9Ys7pjjWrO7LMzfYhpJUc30g= -cel.dev/expr v0.25.0/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4= cel.dev/expr v0.25.1/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= connectrpc.com/connect v1.19.1 h1:R5M57z05+90EfEvCY1b7hBxDVOUl45PrtXtAV2fOC14= @@ -60,52 +46,61 @@ github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= +github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/antlr4-go/antlr/v4 v4.13.1 h1:SqQKkuVZ+zWkMMNkjy5FZe5mr5WURWnlpmOuzYWrPrQ= github.com/antlr4-go/antlr/v4 v4.13.1/go.mod h1:GKmUxMtwp6ZgGwZSva4eWPC5mS6vUAmOABFgjdkM7Nw= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= +github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= +github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY= +github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/bmatcuk/doublestar/v4 v4.9.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/avrEXE= github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4= +github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs= github.com/bufbuild/buf v1.61.0 h1:JPaK/RM2eoheyzznW+1LxaFgN6xjBCi8s25q2kUbH9A= github.com/bufbuild/buf v1.61.0/go.mod h1:Xs3leBmxjL5tTnSVYfNwNXHXD1k5et3fR/tJyIyQl4s= github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8 h1:l4PKzJ7Usff8j5/e+YaWZPaM+rJHIghgDxRn8vDNxNo= github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8/go.mod h1:HKN246DRQwavs64sr2xYmSL+RFOFxmLti+WGCZ2jh9U= github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1 h1:V1xulAoqLqVg44rY97xOR+mQpD2N+GzhMHVwJ030WEU= github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1/go.mod h1:c5D8gWRIZ2HLWO3gXYTtUfw/hbJyD8xikv2ooPxnklQ= -github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M= -github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= -github.com/bytedance/sonic v1.13.3 h1:MS8gmaH16Gtirygw7jV91pDCN33NyMrPbN7qiYhEsF0= -github.com/bytedance/sonic v1.13.3/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4= -github.com/bytedance/sonic v1.14.1/go.mod h1:gi6uhQLMbTdeP0muCnrjHLeCUPyb70ujhnNlhOylAFc= -github.com/bytedance/sonic v1.14.2 h1:k1twIoe97C1DtYUo+fZQy865IuHia4PR5RPiuGPPIIE= -github.com/bytedance/sonic v1.14.2/go.mod h1:T80iDELeHiHKSc0C9tubFygiuXoGzrkjKzX2quAx980= -github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= -github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY= -github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= -github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= -github.com/bytedance/sonic/loader v0.4.0 h1:olZ7lEqcxtZygCK9EKYKADnpQoYkRQxaeY2NYzevs+o= -github.com/bytedance/sonic/loader v0.4.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo= -github.com/casbin/casbin/v2 v2.134.0 h1:wyO3hZb487GzlGVAI2hUoHQT0ehFD+9B5P+HVG9BVTM= -github.com/casbin/casbin/v2 v2.134.0/go.mod h1:FmcfntdXLTcYXv/hxgNntcRPqAbwOG9xsism0yXT+18= github.com/casbin/casbin/v2 v2.135.0 h1:6BLkMQiGotYyS5yYeWgW19vxqugUlvHFkFiLnLR/bxk= github.com/casbin/casbin/v2 v2.135.0/go.mod h1:FmcfntdXLTcYXv/hxgNntcRPqAbwOG9xsism0yXT+18= github.com/casbin/govaluate v1.3.0 h1:VA0eSY0M2lA86dYd5kPPuNZMUD9QkWnOCnavGrw9myc= github.com/casbin/govaluate v1.3.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY= github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws= github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7/go.mod h1:ISC1gtLcVilLOf23wvTfoQuYbW2q0JevFxPfUzZ9Ybw= github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= @@ -120,10 +115,22 @@ github.com/charmbracelet/x/ansi v0.11.3 h1:6DcVaqWI82BBVM/atTyq6yBoRLZFBsnoDoX9G github.com/charmbracelet/x/ansi v0.11.3/go.mod h1:yI7Zslym9tCJcedxz5+WBq+eUGMJT0bM06Fqy1/Y4dI= github.com/charmbracelet/x/cellbuf v0.0.14 h1:iUEMryGyFTelKW3THW4+FfPgi4fkmKnnaLOXuc+/Kj4= github.com/charmbracelet/x/cellbuf v0.0.14/go.mod h1:P447lJl49ywBbil/KjCk2HexGh4tEY9LH0/1QrZZ9rA= +github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U= +github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ= +github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA= +github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0= +github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ= +github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= github.com/charmbracelet/x/exp/strings v0.0.0-20251215102626-e0db08df7383 h1:EW707oHc6fWA5o8kvGjt/kta6DUd4VZ/3fGuH8L4REE= github.com/charmbracelet/x/exp/strings v0.0.0-20251215102626-e0db08df7383/go.mod h1:/ehtMPNh9K4odGFkqYJKpIYyePhdp1hLBRvyY4bWkH8= github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk= github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI= +github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY= +github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo= +github.com/charmbracelet/x/xpty v0.1.2 h1:Pqmu4TEJ8KeA9uSkISKMU3f+C1F6OGBn8ABuGlqCbtI= +github.com/charmbracelet/x/xpty v0.1.2/go.mod h1:XK2Z0id5rtLWcpeNiMYBccNNBrP2IJnzHI0Lq13Xzq4= +github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk= github.com/clipperhouse/displaywidth v0.6.2 h1:ZDpTkFfpHOKte4RG5O/BOyf3ysnvFswpyYrV7z2uAKo= @@ -132,32 +139,30 @@ github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfa github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4= github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= -github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4= -github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M= -github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU= -github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f h1:Y8xYupdHxryycyPlc9Y+bSQAYZnetRJ70VMVKm5CKI0= +github.com/cncf/xds/go v0.0.0-20251022180443-0feb69152e9f/go.mod h1:HlzOvOjVBOfTGSRXRyY0OiCS/3J1akRGQQpRO/7zyF4= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= -github.com/containerd/stargz-snapshotter/estargz v0.18.0 h1:Ny5yptQgEXSkDFKvlKJGTvf1YJ+4xD8V+hXqoRG0n74= -github.com/containerd/stargz-snapshotter/estargz v0.18.0/go.mod h1:7hfU1BO2KB3axZl0dRQCdnHrIWw7TRDdK6L44Rdeuo0= +github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= +github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/stargz-snapshotter/estargz v0.18.1 h1:cy2/lpgBXDA3cDKSyEfNOFMA/c10O1axL69EU7iirO8= github.com/containerd/stargz-snapshotter/estargz v0.18.1/go.mod h1:ALIEqa7B6oVDsrF37GkGN20SuvG/pIMm7FwP7ZmRb0Q= github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo= github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= +github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= +github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dchest/uniuri v1.2.0 h1:koIcOUdrTIivZgSLhHQvKgqdWZq5d7KdMEWF1Ud6+5g= +github.com/dchest/uniuri v1.2.0/go.mod h1:fSzm4SLHzNZvWLvWJew423PhAzkpNQYq+uNLq4kxhkY= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/cli v28.5.1+incompatible h1:ESutzBALAD6qyCLqbQSEf1a/U8Ybms5agw59yGVc+yY= -github.com/docker/cli v28.5.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v29.0.4+incompatible h1:mffN/hPqaI39vx/4QiSkdldHeM0rP1ZZBIXRUOPI5+I= github.com/docker/cli v29.0.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= @@ -176,12 +181,14 @@ github.com/emicklei/proto v1.14.2 h1:wJPxPy2Xifja9cEMrcA/g08art5+7CGJNFNk35iXC1I github.com/emicklei/proto v1.14.2/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= github.com/envoyproxy/go-control-plane v0.13.5-0.20251024222203-75eaa193e329 h1:K+fnvUM0VZ7ZFJf0n4L/BRlnsb9pL/GuDG6FqaH+PwM= github.com/envoyproxy/go-control-plane/envoy v1.35.0 h1:ixjkELDE+ru6idPxcHLj8LBVc2bFP7iBytj353BoHUo= -github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8= -github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU= +github.com/envoyproxy/go-control-plane/envoy v1.35.0/go.mod h1:09qwbGVuSWWAyN5t/b3iyVfz5+z8QWGrzkoqm/8SbEs= github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg5VPuZ0uONDT6eb4= github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -190,27 +197,24 @@ github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE= github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kratos/aegis v0.2.0 h1:dObzCDWn3XVjUkgxyBp6ZeWtx/do0DPZ7LY3yNSJLUQ= github.com/go-kratos/aegis v0.2.0/go.mod h1:v0R2m73WgEEYB3XYu6aE2WcMwsZkJ/Rzuf5eVccm7bI= -github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251106012513-9262193e351a h1:hXTsD6lWaAU7UQchbmafi9WLTyBMjoLttEnVpWMiGJA= -github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:tr3LJLUypg8Js3bClD6s7p2eWLTIitvq9Paf7FAK3R4= -github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:tr3LJLUypg8Js3bClD6s7p2eWLTIitvq9Paf7FAK3R4= github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251217105121-fb8e43efb207 h1:9/jBnQSuRMIdLTfeoM0IWXF1cGFKVjKb7fTDOEoD4H8= github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251217105121-fb8e43efb207/go.mod h1:S0grzHPbqVD8ilueT7yd0k32/ZSbY64y7zdovhGNzyg= -github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251106012513-9262193e351a h1:3nyCH1sGH9sSWnnVDpvxywg8r+Esr1lObU6wTzW3ups= -github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= -github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251217105121-fb8e43efb207 h1:admtUgwA6qCvdh1A5Ke0r+1s1aEO8wrLWj07/5uqXxM= github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251217105121-fb8e43efb207/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= -github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251106012513-9262193e351a h1:lyM6XpKxtzwcII0cvVk8QsGyJvu9xMJT8yoW6fwIbT4= -github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251106012513-9262193e351a/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= -github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251217105121-fb8e43efb207 h1:SlUVCwGBsK/ITX9HkWSGNhbA0Ud9t56r0m9qhy+pip0= github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251217105121-fb8e43efb207/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= -github.com/go-kratos/kratos/v2 v2.9.1 h1:EGif6/S/aK/RCR5clIbyhioTNyoSrii3FC118jG40Z0= -github.com/go-kratos/kratos/v2 v2.9.1/go.mod h1:a1MQLjMhIh7R0kcJS9SzJYR43BRI7EPzzN0J1Ksu2bA= +github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20251201062103-6f0b3015b803 h1:Ve6D/PdPNf1bUvrTjJPrxvR7Qdwz4Q1PNNE15f4tOTg= +github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:kflKS9PrbiyPNmC1hQCRyJTsF5ip5rBMYy94GTcABKI= +github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20251201062103-6f0b3015b803 h1:WedOGvRd7vjApUL1ORLcCMRfly+xov2Ug5HSvNMortY= +github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:xHV9lQKrBSSzqY7zLlQiZ1gRpMawhDTWg6NdfX1wg7k= github.com/go-kratos/kratos/v2 v2.9.2 h1:px8GJQBeLpquDKQWQ9zohEWiLA8n4D/pv7aH3asvUvo= github.com/go-kratos/kratos/v2 v2.9.2/go.mod h1:Jc7jaeYd4RAPjetun2C+oFAOO7HNMHTT/Z4LxpuEDJM= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -225,12 +229,16 @@ github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lY github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/form/v4 v4.3.0 h1:OVttojbQv2WNCs4P+VnjPtrt/+30Ipw4890W3OaFlvk= github.com/go-playground/form/v4 v4.3.0/go.mod h1:Cpe1iYJKoXb1vILRXEwxpWMGWyQuqplQ/4cvPecy+Jo= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= +github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/goexts/generic v0.14.0 h1:Lw8QKwgN9w6vnHuEbs3K+42frxi7MHS2pJrg7/ZCkJc= github.com/goexts/generic v0.14.0/go.mod h1:3L0Ou9PAX35WPvO+aSeZsoENlGIRSDAuZ8/GNqUqaEs= github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw= github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang-cz/devslog v0.0.15 h1:ejoBLTCwJHWGbAmDf2fyTJJQO3AkzcPjw8SC9LaOQMI= github.com/golang-cz/devslog v0.0.15/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= @@ -240,22 +248,25 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U= github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/cel-go v0.26.1 h1:iPbVVEdkhTX++hpe3lzSk7D3G3QSYqLGoHOcEio+UXQ= github.com/google/cel-go v0.26.1/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM= github.com/google/gnostic v0.7.1 h1:t5Kc7j/8kYr8t2u11rykRrPPovlEMG4+xdc/SpekATs= github.com/google/gnostic v0.7.1/go.mod h1:KSw6sxnxEBFM8jLPfJd46xZP+yQcfE8XkiqfZx5zR28= -github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= -github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/gnostic-models v0.7.1 h1:SisTfuFKJSKM5CPZkffwi6coztzzeYUhc3v4yxLWH8c= github.com/google/gnostic-models v0.7.1/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= -github.com/google/go-containerregistry v0.20.6 h1:cvWX87UxxLgaH76b4hIvya6Dzz9qHB31qAwjAohdSTU= -github.com/google/go-containerregistry v0.20.6/go.mod h1:T0x8MuoAoKX/873bkeSfLD2FAkwCDf9/HZgsFJ02E2Y= github.com/google/go-containerregistry v0.20.7 h1:24VGNpS0IwrOZ2ms2P1QE3Xa5X9p4phx0aUgzYzHW6I= github.com/google/go-containerregistry v0.20.7/go.mod h1:Lx5LCZQjLH1QBaMPeGwsME9biPeo1lPx6lbGj/UmzgM= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -267,17 +278,57 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4= github.com/google/wire v0.7.0/go.mod h1:n6YbUQD9cPKTnHXEBN2DXlOp/mVADhVErcMFb0v3J18= -github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE= -github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLWMC+vZCkfs+FHv1Vg= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4= +github.com/hashicorp/consul/api v1.33.0 h1:MnFUzN1Bo6YDGi/EsRLbVNgA4pyCymmcswrE5j4OHBM= +github.com/hashicorp/consul/api v1.33.0/go.mod h1:vLz2I/bqqCYiG0qRHGerComvbwSWKswc8rRFtnYBrIw= +github.com/hashicorp/consul/sdk v0.17.0 h1:N/JigV6y1yEMfTIhXoW0DXUecM2grQnFuRpY7PcLHLI= +github.com/hashicorp/consul/sdk v0.17.0/go.mod h1:8dgIhY6VlPUprRH7o7UenVuFEgq017qUn3k9wS5mCt4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= +github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= +github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= +github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= +github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= +github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl/v2 v2.23.0 h1:Fphj1/gCylPxHutVSEOf2fBOh1VE4AuLV7+kbJf3qos= github.com/hashicorp/hcl/v2 v2.23.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= +github.com/hashicorp/memberlist v0.5.0 h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR/prTM= +github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0= +github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY= +github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4= +github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog= github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= @@ -285,26 +336,26 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jdx/go-netrc v1.0.0 h1:QbLMLyCZGj0NA8glAhxUpf1zDg6cxnWgMBbjq40W0gQ= github.com/jdx/go-netrc v1.0.0/go.mod h1:Gh9eFQJnoTNIRHXl2j5bJXA1u84hQWJWgGh569zF3v8= +github.com/jhump/protoreflect/v2 v2.0.0-beta.2 h1:qZU+rEZUOYTz1Bnhi3xbwn+VxdXkLVeEpAeZzVXLY88= +github.com/jhump/protoreflect/v2 v2.0.0-beta.2/go.mod h1:4tnOYkB/mq7QTyS3YKtVtNrJv4Psqout8HA1U+hZtgM= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= -github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co= -github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0= github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk= github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= -github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= -github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= -github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU= github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= -github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lmittmann/tint v1.1.2 h1:2CQzrL6rslrsyjqLDwD11bZ5OpLBPU+g3G/r5LSfS8w= @@ -315,40 +366,55 @@ github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 h1:PwQumkgq4/acIi github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/lyft/protoc-gen-star/v2 v2.0.4 h1:JDlNKttNIRd68AAIychs0AqEpO8/I/WYi01OQ7Raw6Q= github.com/lyft/protoc-gen-star/v2 v2.0.4/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= -github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A= -github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= +github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw= +github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs= +github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU= +github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko= github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 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/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mojocn/base64Captcha v1.3.8 h1:rrN9BhCwXKS8ht1e21kvR3iTaMgf4qPC9sRoV52bqEg= github.com/mojocn/base64Captcha v1.3.8/go.mod h1:QFZy927L8HVP3+VV5z2b1EAEiv1KxVJKZbAucVgLUy4= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= @@ -359,53 +425,40 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= -github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= -github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/ncruces/go-strftime v0.1.10 h1:UYG9J7oU9Z0i5ohqzg9kicKcV4hc5YzEgZowOGjP4us= github.com/ncruces/go-strftime v0.1.10/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= github.com/origadmin/contrib v1.1.0 h1:5ZMuxPas9+WIDNDlG+99Y5JHGwQRq2rZ4TjJXM5/Oek= github.com/origadmin/contrib v1.1.0/go.mod h1:lqSKEAQHNRf96zWG3XvZZv96oFUeMBstLAWBGP7VIus= -github.com/origadmin/entslog/v3 v3.1.0 h1:1SPjs2CWytl08obWW2wAk8UTiwoc0ak/doWdQHN64Rk= -github.com/origadmin/entslog/v3 v3.1.0/go.mod h1:cIFyIZprNlJ69T18DnXBpylvO2CWvEGPhW1r2Sm/51s= -github.com/origadmin/entslog/v3 v3.1.1 h1:xuNst8prXxqa51marfhWwEAJJd1ZiYNEEBqflifL19o= -github.com/origadmin/entslog/v3 v3.1.1/go.mod h1:mmxKcgx7YflNUwaVAmkq0ajK/SqyaETPsLM1l1ty3lY= -github.com/origadmin/runtime v0.2.3 h1:1DEiXawwftHOOWwHM5ScSSOk8CuMRyfvAQDAUUvGhDs= -github.com/origadmin/runtime v0.2.3/go.mod h1:rgOxokXjWXXbzzHr2ICXW3KNsQ8KNGFqjMcpGo54aOM= -github.com/origadmin/runtime v0.2.13/go.mod h1:P4X8gBcPhGpH778JV/VVlj7xi4iX1WYDfir3lJOoTwg= github.com/origadmin/runtime v0.2.14 h1:4D0udgzQumSsbr2XW0Ozuv4jma7vWvY+blqaiEp8xtc= github.com/origadmin/runtime v0.2.14/go.mod h1:HIzn3AGmC/OybEmANsXZFTo/xPSRTVnyE+89mm8PMCE= -github.com/origadmin/slog-kratos v1.0.4 h1:1et3TBy61Uwf5N1ZbEBFhMqCjgxqfRXmz2w0Q1dujG0= -github.com/origadmin/slog-kratos v1.0.4/go.mod h1:WUdhcWLyN0i8TbdemqE2Y/muoj0GaZ86OcdpumAWHPo= github.com/origadmin/slog-kratos v1.0.5 h1:yDLxVaN8A8MMmIny3xy65uT1wLKl3S9tVZVijn+1Vhc= github.com/origadmin/slog-kratos v1.0.5/go.mod h1:zuOf6B1cMjPwwMJ2or2sPbzNAdx/fMn/6MekdG30Xh4= -github.com/origadmin/toolkits v0.3.16 h1:R/Ws2S2W64ZScSkBz4QQ8HPXWpuH/ac+z1z0iHPyG0M= -github.com/origadmin/toolkits v0.3.16/go.mod h1:l0H6drsQuWNiSDagDwI2jvLqxlNGtF1LI++fPrz5KAg= -github.com/origadmin/toolkits v1.2.0 h1:7L/hgf0WC/q7yIJH9V0uENrxkAN0oU3D2EobfqKO4uw= -github.com/origadmin/toolkits v1.2.0/go.mod h1:ylurxc+wCcSK3FyT7a6bnGfR2l4tu11b128X+dh1fbw= -github.com/origadmin/toolkits/codec v0.3.16 h1:fRyWCMwyXz032I1ZHpsRuG/8YfWRS4YlfqYNdjeziMw= -github.com/origadmin/toolkits/codec v0.3.16/go.mod h1:XqlOlTxdD3lLDPmC82cZEVoiD4/r4QA3umKKRVrgGu4= github.com/origadmin/toolkits/codec v1.2.0 h1:Tnnxc2Bcf9wTcMiV/4h89CxGTz+v6EN6+ZBbYdyCLD8= github.com/origadmin/toolkits/codec v1.2.0/go.mod h1:NgbdOtowlFY79/CXZzRhes1tRHTBr3XZX+VBWL7yUpw= -github.com/origadmin/toolkits/crypto v0.3.15 h1:OHgIXLvB2jCvKH55YVdSyTjcOAwB05FmvCQLKn2BoMQ= -github.com/origadmin/toolkits/crypto v0.3.15/go.mod h1:ozRQi1rYHAIL/NSw0hJEWITEkZlSZ7wA9pCQKpqFv2s= github.com/origadmin/toolkits/crypto v1.2.0 h1:SajjJuDHf/KT0AEvvW/Z2HnPW07vnyCvIlgD4lfykeA= github.com/origadmin/toolkits/crypto v1.2.0/go.mod h1:PlR7+Dh88bVl8z+wKjAcxVBHxl3fllwfhLGOvzAO9nQ= -github.com/origadmin/toolkits/errors v1.1.0 h1:Vh5ic7kU6e01koOuGpu3c6etbSZ7gEfesXQMpOsO2D8= -github.com/origadmin/toolkits/errors v1.1.0/go.mod h1:YCPShNuAmn0ns0JB43iKbVdWcPA8XCTiFG+7UA2+tJw= github.com/origadmin/toolkits/errors v1.2.0 h1:dQzGVa9QtlptaQ3ljXz6+dbMwHMBORPdiyAF5xxErlk= github.com/origadmin/toolkits/errors v1.2.0/go.mod h1:YCPShNuAmn0ns0JB43iKbVdWcPA8XCTiFG+7UA2+tJw= -github.com/origadmin/toolkits/slogx v0.3.16 h1:+sJAKM2t/3ZyT6qi+Q1CwnzXO/ObXJlKTfPA6RdJno0= -github.com/origadmin/toolkits/slogx v0.3.16/go.mod h1:6ODf/5T3M7XBc0aKHHkMgOLawkASDzaPCj99JzabYME= +github.com/origadmin/toolkits/i18n v1.2.0 h1:1/fRapVye5IQXPTOfMUZAHq26/rYWxXh3+6IaP1yOWw= +github.com/origadmin/toolkits/i18n v1.2.0/go.mod h1:utfVq5IU8KGeygz1Ey6g+6fV3oplUNW2iZofUG8Be5c= github.com/origadmin/toolkits/slogx v1.1.0 h1:UEqIMxMwUiWZe4/g/0aIVA/i7FMKqh4kSj0J+PRPJi8= github.com/origadmin/toolkits/slogx v1.1.0/go.mod h1:rpyegD2CZypR+ctlpVz4q3KROwb3xc6mUKQQZ9ow+qI= -github.com/petermattis/goid v0.0.0-20250904145737-900bdf8bb490 h1:QTvNkZ5ylY0PGgA+Lih+GdboMLY/G9SEGLMEGVjTVA4= -github.com/petermattis/goid v0.0.0-20250904145737-900bdf8bb490/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= +github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= github.com/petermattis/goid v0.0.0-20251121121749-a11dd1a45f9a h1:VweslR2akb/ARhXfqSfRbj1vpWwYXf3eeAUyw/ndms0= github.com/petermattis/goid v0.0.0-20251121121749-a11dd1a45f9a/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= @@ -413,8 +466,23 @@ github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10/go.mod h1 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt9k/+g42oCprj/FisM4qX9L3sZB3upGN2ZU= github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/protocolbuffers/protoscope v0.0.0-20221109213918-8e7a6aafa2c9 h1:arwj11zP0yJIxIRiDn22E0H8PxfF7TsTrc2wIPFIsf4= +github.com/protocolbuffers/protoscope v0.0.0-20221109213918-8e7a6aafa2c9/go.mod h1:SKZx6stCn03JN3BOWTwvVIO2ajMkb/zQdTceXYhKw/4= github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= github.com/quic-go/quic-go v0.56.0 h1:q/TW+OLismmXAehgFLczhCDTYB3bFmua4D9lsNBWxvY= @@ -424,12 +492,16 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qq github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rodaine/protogofakeit v0.1.1 h1:ZKouljuRM3A+TArppfBqnH8tGZHOwM/pjvtXe9DaXH8= +github.com/rodaine/protogofakeit v0.1.1/go.mod h1:pXn/AstBYMaSfc1/RqH3N82pBuxtWgejz1AlYpY1mI0= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0= github.com/segmentio/asm v1.2.1/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/segmentio/encoding v0.5.3 h1:OjMgICtcSFuNvQCdwqMCv9Tg7lEOXGwm1J5RPQccx6w= @@ -439,14 +511,15 @@ github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U3 github.com/shoenig/go-m1cpu v0.1.7 h1:C76Yd0ObKR82W4vhfjZiCp0HxcSZ8Nqd84v+HZ0qyI0= github.com/shoenig/go-m1cpu v0.1.7/go.mod h1:KkDOw6m3ZJQAPHbrzkZki4hnx+pDRR1Lo+ldA56wD5w= github.com/shoenig/test v1.7.0 h1:eWcHtTXa6QLnBvm0jgEabMRN/uJ4DMV3M8xUGgRkZmk= +github.com/shoenig/test v1.7.0/go.mod h1:UxJ6u/x2v/TNs/LoLxBNJRV9DiwBBKYxXSyczsBHFoI= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sony/sonyflake v1.3.0 h1:tiB4Dlp0lnmKp/h6BLXA14P8Qi+LYS9+0QRpcrKHvg4= github.com/sony/sonyflake v1.3.0/go.mod h1:LORtCywH/cq10ZbyfhKrHYgAUGH7mOBa76enV9txy/Y= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= -github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= -github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -457,32 +530,31 @@ github.com/sqlite3ent/sqlite3 v1.40.0/go.mod h1:WIpC0Synq6v0xDJ179B/epHrs/Lkv5Ex github.com/stoewer/go-strcase v1.3.1 h1:iS0MdW+kVTxgMoE1LAZyMiYJFKlOzLooE4MxjirtkAs= github.com/stoewer/go-strcase v1.3.1/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I= github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM= github.com/tidwall/btree v1.8.1 h1:27ehoXvm5AG/g+1VxLS1SD3vRhp/H7LuEfwNvddEdmA= github.com/tidwall/btree v1.8.1/go.mod h1:jBbTdUWhSZClZWoDg54VnvV7/54modSOzDN7VXftj1A= -github.com/tklauser/go-sysconf v0.3.15 h1:VE89k0criAymJ/Os65CSn1IXaol+1wrsFHEB8Ol49K4= -github.com/tklauser/go-sysconf v0.3.15/go.mod h1:Dmjwr6tYFIseJw7a3dRLJfsHAMXZ3nEnL/aZY+0IuI4= github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA= github.com/tklauser/go-sysconf v0.3.16/go.mod h1:/qNL9xxDhc7tx3HSRsLWNnuzbVfh3e7gh/BmM179nYI= -github.com/tklauser/numcpus v0.10.0 h1:18njr6LDBk1zuna922MgdjQuJFjrdppsZG60sHGfjso= -github.com/tklauser/numcpus v0.10.0/go.mod h1:BiTKazU708GQTYF4mB+cmlpT2Is1gLk7XVuEeem8LsQ= github.com/tklauser/numcpus v0.11.0 h1:nSTwhKH5e1dMNsCdVBukSZrURJRoHbSEQjdEbY+9RXw= github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZejzM6/3MQ= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/vbatts/tar-split v0.12.2 h1:w/Y6tjxpeiFMR47yzZPlPj/FcPLpXbTUi/9H7d3CPa4= github.com/vbatts/tar-split v0.12.2/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVOpnNdfTMFA= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= @@ -511,23 +583,33 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0/go.mod h1:h06DGIukJOevXaj/xrNjhi/2098RZzcLTbc0jDAUbsg= go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0 h1:wpMfgF8E1rkrT1Z6meFh1NDtownE9Ii3n3X2GJYjsaU= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0/go.mod h1:wAy0T/dUbs468uOlkT31xjvqQgEVXv58BRFWEgn5v/0= go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= +go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= +go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= +go.opentelemetry.io/proto/otlp v1.8.0 h1:fRAZQDcAFHySxpJ1TwlA1cJ4tvcrw7nXl9xWWC8N5CE= +go.opentelemetry.io/proto/otlp v1.8.0/go.mod h1:tIeYOeNBU4cvmPqpaji1P+KbB4Oloai8wN4rWzRrFF0= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= +go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc= go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/arch v0.18.0 h1:WN9poc33zL4AzGxqf8VtpKUnGvMi8O9lhNyBMF/85qc= -golang.org/x/arch v0.18.0/go.mod h1:bdwinDaKcfZUGpH09BB7ZmOfhalA8lQdzl62l8gGWsk= -golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI= -golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= @@ -548,11 +630,14 @@ golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= -golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= @@ -562,8 +647,10 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= -golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -573,21 +660,36 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= -golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -597,7 +699,6 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -609,6 +710,7 @@ golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -621,9 +723,11 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= -golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= +golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= +golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= @@ -632,46 +736,52 @@ golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= -golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= +golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= +golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= +golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= +golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= -google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 h1:fCvbg86sFXwdrl5LgVcTEvNC+2txB5mgROGmRL5mrls= -google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217/go.mod h1:+rXWjjaukWZun3mLfjmVnQi18E1AsFbDN9QdJ5YXLto= +gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b h1:uA40e2M6fYRBf0+8uN5mLlqUtV192iiksiICIBkYJ1E= google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:Xa7le7qx2vmqB/SzWUBa7KdMjpdpAHlh5QCSnjessQk= -google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846 h1:Wgl1rcDNThT+Zn47YyCXOXyX/COgMTIdhJ717F0l4xk= -google.golang.org/genproto/googleapis/rpc v0.0.0-20251124214823-79d6a2a48846/go.mod h1:7i2o+ce6H/6BluujYR+kqX3GKH+dChPTQU19wjRPiGk= google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b h1:Mv8VFug0MP9e5vUxfBcE3vUkV6CImK3cMNMIDFjmzxU= google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ= google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM= google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1/go.mod h1:5KF+wpkbTSbGcR9zteSqZV6fqFOWBl4Yde8En8MryZA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0 h1:6Al3kEFFP9VJhRz3DID6quisgPnTeZVr4lep9kkxdPA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0/go.mod h1:QLvsjh0OIR0TYBeiu2bkWGTJBUNQ64st52iWj/yA93I= -google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= -google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= +gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= modernc.org/cc/v4 v4.26.5 h1:xM3bX7Mve6G8K8b+T11ReenJOT+BmVqQj0FY5T4+5Y4= +modernc.org/cc/v4 v4.26.5/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= modernc.org/ccgo/v4 v4.28.1 h1:wPKYn5EC/mYTqBO373jKjvX2n+3+aK7+sICCv4Fjy1A= +modernc.org/ccgo/v4 v4.28.1/go.mod h1:uD+4RnfrVgE6ec9NGguUNdhqzNIeeomeXf6CL0GTE5Q= modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA= +modernc.org/fileutil v1.3.40/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc= modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= +modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= modernc.org/libc v1.66.10 h1:yZkb3YeLx4oynyR+iUsXsybsX4Ubx7MQlSYEw4yj59A= modernc.org/libc v1.66.10/go.mod h1:8vGSEwvoUoltr4dlywvHqjtAqHBaw0j1jI7iFBTAr2I= modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= @@ -682,14 +792,11 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= -modernc.org/sqlite v1.40.0 h1:bNWEDlYhNPAUdUdBzjAvn8icAs/2gaKlj4vM+tQ6KdQ= -modernc.org/sqlite v1.40.0/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE= modernc.org/sqlite v1.40.1 h1:VfuXcxcUWWKRBuP8+BR9L7VnmusMgBNNnBYGEe9w/iY= modernc.org/sqlite v1.40.1/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE= modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= -nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= pluginrpc.com/pluginrpc v0.5.0 h1:tOQj2D35hOmvHyPu8e7ohW2/QvAnEtKscy2IJYWQ2yo= pluginrpc.com/pluginrpc v0.5.0/go.mod h1:UNWZ941hcVAoOZUn8YZsMmOZBzbUjQa3XMns8RQLp9o= diff --git a/internal/features/datastore/biz/biz.go b/internal/features/datastore/biz/biz.go deleted file mode 100644 index faa0f4e6..00000000 --- a/internal/features/datastore/biz/biz.go +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package biz - -import ( - "github.com/origadmin/runtime/errors" - typespb "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/helpers/pagination" -) - -var ( - // ErrUserNotFound is user not found. - ErrUserNotFound = errors.New(50001, typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), "user not found") -) - -var ( - defaultLimiter = repo.PageLimiter{} -) - -type UpdateHooker interface { - UpdateRules() -} diff --git a/internal/features/datastore/biz/datastore.go b/internal/features/datastore/biz/datastore.go deleted file mode 100644 index 6555fb25..00000000 --- a/internal/features/datastore/biz/datastore.go +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the system module of OrigAdmin. -package biz - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/runtime/log" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -// PermissionServiceBiz is a PermissionPB use case. -type PermissionServiceBiz struct { - dao dto.PermissionRepo - limiter repo.PageLimiter - log *log.KHelper -} - -func (biz PermissionServiceBiz) ListPermissions(ctx context.Context, in *pb.ListPermissionsRequest) (*pb.ListPermissionsResponse, error) { - var option dto.PermissionQueryOption - if err := option.FromListRequest(in, biz.limiter); err != nil { - return nil, err - } - option.IncludeResources = true - log.Info("ListPermissions") - result, total, err := biz.dao.List(ctx, in, option) - if err != nil { - return nil, err - } - return dto.ToListPermissionsResponse(result, in, total) -} - -func (biz PermissionServiceBiz) GetPermission(ctx context.Context, in *pb.GetPermissionRequest) (*pb.GetPermissionResponse, error) { - var option dto.PermissionQueryOption - if err := option.FromGetRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("GetPermission") - result, err := biz.dao.Get(ctx, in.GetId(), option) - if err != nil { - return nil, err - } - return &pb.GetPermissionResponse{ - Permission: result, - }, nil -} - -func (biz PermissionServiceBiz) CreatePermission(ctx context.Context, in *pb.CreatePermissionRequest) (*pb.CreatePermissionResponse, error) { - var option dto.PermissionQueryOption - if err := option.FromCreateRequest(in, biz.limiter); err != nil { - return nil, err - } - log.Info("CreatePermission") - result, err := biz.dao.Create(ctx, in.Permission, option) - if err != nil { - return nil, err - } - return &pb.CreatePermissionResponse{ - Permission: result, - }, nil -} - -func (biz PermissionServiceBiz) UpdatePermission(ctx context.Context, in *pb.UpdatePermissionRequest) (*pb.UpdatePermissionResponse, error) { - log.Info("UpdatePermission") - result, err := biz.dao.Update(ctx, in.Permission) - if err != nil { - return nil, err - } - return &pb.UpdatePermissionResponse{ - Permission: result, - }, nil -} - -func (biz PermissionServiceBiz) DeletePermission(ctx context.Context, in *pb.DeletePermissionRequest) (*pb.DeletePermissionResponse, error) { - log.Info("DeletePermission") - if err := biz.dao.Delete(ctx, in.GetId()); err != nil { - return nil, err - } - return &pb.DeletePermissionResponse{}, nil -} - -// NewPermissionServiceBiz new a PermissionPB use case. -func NewPermissionServiceBiz(r runtime.Runtime, repo dto.PermissionRepo) *PermissionServiceBiz { - return &PermissionServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(r.Logger())} -} diff --git a/internal/features/datastore/biz/provider.go b/internal/features/datastore/biz/provider.go deleted file mode 100644 index 8e15c2fc..00000000 --- a/internal/features/datastore/biz/provider.go +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz implements the functions, types, and interfaces for the module. -package biz - -import ( - "github.com/google/wire" -) - -// ProviderSet is biz providers. -var ProviderSet = wire.NewSet( - //NewAuthServiceBiz, - //NewLoginServiceBiz, - //NewPersonalServiceBiz, - NewResourceServiceBiz, - NewRoleServiceBiz, - NewUserServiceBiz, - NewPermissionServiceBiz, - //NewCasbinSourceServiceBiz, -) diff --git a/internal/features/datastore/dal/dal.go b/internal/features/datastore/dal/dal.go deleted file mode 100644 index 18173605..00000000 --- a/internal/features/datastore/dal/dal.go +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "github.com/google/wire" -) diff --git a/internal/features/datastore/dal/menu.dal.go b/internal/features/datastore/dal/menu.dal.go deleted file mode 100644 index b6dfa1b3..00000000 --- a/internal/features/datastore/dal/menu.dal.go +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "github.com/origadmin/runtime" - - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -type menuRepo struct { - db *data.Data -} - -// -//func (repo menuRepo) Get(ctx context.Context, id int64, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { -// var option dto.MenuQueryOption -// if len(options) > 0 { -// option = options[0] -// } -// query := repo.db.Menu(ctx).Query().Where(menu.ID(id)) -// query = menuQueryOptions(query, option) -// result, err := query.First(ctx) -// if err != nil { -// return nil, err -// } -// return dto.ConvertMenu2PB(result), nil -//} -// -//func (repo menuRepo) Create(ctx context.Context, menuPB *dto.MenuPB, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { -// var option dto.MenuQueryOption -// if len(options) > 0 { -// option = options[0] -// } -// err := repo.db.Tx(ctx, func(ctx context.Context) error { -// create := repo.db.Menu(ctx).Create() -// create.SetMenu(dto.ConvertMenuPB2Object(menuPB), option.Fields...) -// saved, err := create.Save(ctx) -// if err != nil { -// return err -// } -// menuPB = dto.ConvertMenu2PB(saved) -// return nil -// }) -// if err != nil { -// return nil, err -// } -// return menuPB, nil -//} -// -//func (repo menuRepo) Delete(ctx context.Context, id int64) error { -// return repo.db.Tx(ctx, func(ctx context.Context) error { -// return repo.db.Menu(ctx).DeleteOneID(id).Exec(ctx) -// }) -//} -// -//func (repo menuRepo) Update(ctx context.Context, menuPB *dto.MenuPB, options ...dto.MenuQueryOption) (*dto.MenuPB, error) { -// err := repo.db.Tx(ctx, func(ctx context.Context) error { -// update := repo.db.Menu(ctx).UpdateOneID(menuPB.Id) -// update.SetMenu(dto.ConvertMenuPB2Object(menuPB)) -// saved, err := update.Save(ctx) -// if err != nil { -// return err -// } -// menuPB = dto.ConvertMenu2PB(saved) -// return nil -// }) -// if err != nil { -// return nil, err -// } -// return menuPB, nil -//} -// -//func (repo menuRepo) List(ctx context.Context, in *dto.ListMenusRequest, options ...dto.MenuQueryOption) ([]*dto.MenuPB, int32, error) { -// var option dto.MenuQueryOption -// if len(options) > 0 { -// option = options[0] -// } -// -// query := repo.db.Menu(ctx).Query() -// if option.IncludeResources { -// query = query.WithResources() -// } -// if v := option.UserID; v > 0 { -// query = query.Where(menu.HasRolesWith(role.HasUsersWith(user.ID(v)))) -// } -// if v := option.RoleID; v > 0 { -// query = query.Where(menu.HasRolesWith(role.ID(v))) -// } -// if v := option.InIDs; len(v) > 0 { -// query = query.Where(menu.IDIn(v...)) -// } -// if v := option.Name; len(v) > 0 { -// query = query.Where(menu.ParentPathContains(v)) -// } -// if v := option.Status; v > 0 { -// query = query.Where(menu.StatusEQ(v)) -// } -// if v := option.ParentID; v > 0 { -// query = query.Where(menu.ParentID(v)) -// } -// if v := option.ParentPathPrefix; len(v) > 0 { -// query = query.Where(menu.ParentPathHasPrefix(v)) -// } -// -// return menuPageQuery(ctx, query, in, option) -//} - -// NewMenuRepo . -func NewMenuRepo(r runtime.Runtime, db *data.Data) dto.MenuRepo { - return &menuRepo{ - db: db, - } -} - -// -//func menuPageQuery(ctx context.Context, query *ent.MenuQuery, in *pb.ListMenusRequest, option dto.MenuQueryOption) ([]*dto.MenuPB, int32, error) { -// if in.OnlyCount { -// count, err := query.Count(ctx) -// if err != nil { -// return nil, 0, err -// } -// return nil, int32(count), nil -// } -// count, err := query.Clone().Count(ctx) -// if err != nil { -// return nil, 0, err -// } -// query = menuQueryPage(query, in) -// query = menuQueryOptions(query, option) -// result, err := query.Clone().All(ctx) -// return dto.ConvertMenus(result), int32(count), err -//} -// -//func menuQueryPage(query *ent.MenuQuery, in *pb.ListMenusRequest) *ent.MenuQuery { -// if in.NoPaging { -// pageSize := in.PageSize -// if pageSize > 0 { -// query = query.Limit(int(pageSize)) -// } -// return query -// } -// -// pageSize := in.PageSize -// if pageSize > 0 { -// query = query.Limit(int(pageSize)) -// } -// current := in.Current -// if current > 0 { -// query = query.Offset(int((current - 1) * pageSize)) -// } -// return query -//} -// -//func menuQueryOptions(query *ent.MenuQuery, option dto.MenuQueryOption) *ent.MenuQuery { -// if len(option.SelectFields) > 0 { -// query = query.Select(option.SelectFields...).MenuQuery -// } -// if len(option.OmitFields) > 0 { -// query = query.Omit(option.OmitFields...).MenuQuery -// } -// if len(option.OrderFields) > 0 { -// query = query.Order(menuOrderBy(option.OrderFields)...) -// } -// return query -//} -// -//func menuOrderBy(fields []string, opts ...sql.OrderTermOption) []menu.OrderOption { -// var orders []menu.OrderOption -// for _, field := range fields { -// orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) -// } -// return orders -//} diff --git a/internal/features/datastore/dal/permission.dal.go b/internal/features/datastore/dal/permission.dal.go deleted file mode 100644 index a79b5fb8..00000000 --- a/internal/features/datastore/dal/permission.dal.go +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "context" - - "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/db" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/permission" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -type permissionRepo struct { - db *data.Data -} - -func (repo permissionRepo) Get(ctx context.Context, id int64, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { - var option dto.PermissionQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.Permission(ctx).Query().Where(permission.ID(id)) - query = permissionQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return dto.ConvertPermission2PB(result), nil -} - -func (repo permissionRepo) Create(ctx context.Context, permission *dto.PermissionPB, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { - var option dto.PermissionQueryOption - if len(options) > 0 { - option = options[0] - } - obj := dto.ConvertPermissionPB2Object(permission) - create := repo.db.Permission(ctx).Create() - if len(permission.ResourceIds) > 0 { - create.AddResourceIDs(permission.ResourceIds...) - } - if len(permission.Resources) > 0 { - create.AddResources(dto.ConvertResourcesPB2Object(permission.Resources)...) - } - create.SetPermission(obj, option.Fields...) - saved, err := create.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertPermission2PB(saved), nil -} - -func (repo permissionRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Permission(ctx).DeleteOneID(id).Exec(ctx) -} - -func (repo permissionRepo) Update(ctx context.Context, permission *dto.PermissionPB, options ...dto.PermissionQueryOption) (*dto.PermissionPB, error) { - var option dto.PermissionQueryOption - if len(options) > 0 { - option = options[0] - } - - update := repo.db.Permission(ctx).UpdateOneID(permission.Id) - obj := dto.ConvertPermissionPB2Object(permission) - if len(permission.ResourceIds) > 0 { - update.ClearResources() - update.AddResourceIDs(permission.ResourceIds...) - } - if len(permission.Resources) > 0 { - update.ClearResources() - update.AddResources(dto.ConvertResourcesPB2Object(permission.Resources)...) - } - update.SetPermission(obj, option.Fields...) - saved, err := update.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertPermission2PB(saved), nil -} - -func (repo permissionRepo) List(ctx context.Context, in *dto.ListPermissionsRequest, options ...dto.PermissionQueryOption) ([]*dto.PermissionPB, int32, error) { - var option dto.PermissionQueryOption - if len(options) > 0 { - option = options[0] - } - - query := repo.db.Permission(ctx).Query() - if option.IncludeResources { - query = query.WithResources() - } - if option.IncludeRoles { - query = query.WithRoles() - } - if len(in.DataScopes) > 0 { - query = query.Where(permission.DataScopeIn(in.DataScopes...)) - } - return permissionPageQuery(ctx, query, in, option) -} - -// NewPermissionRepo . -func NewPermissionRepo(r runtime.Runtime, db *data.Data) dto.PermissionRepo { - return &permissionRepo{ - db: db, - } -} - -func permissionPageQuery(ctx context.Context, query *ent.PermissionQuery, in *pb.ListPermissionsRequest, option dto.PermissionQueryOption) ([]*dto.PermissionPB, int32, error) { - if in.OnlyCount { - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - return nil, int32(count), nil - } - - query = permissionQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - query = db.Query(query, in, !in.NoPaging) - result, err := query.All(ctx) - return dto.ConvertPermissions(result), int32(count), err -} - -func permissionQueryPage(query *ent.PermissionQuery, in *pb.ListPermissionsRequest) *ent.PermissionQuery { - if in.NoPaging { - pageSize := in.PageSize - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - return query - } - - pageSize := in.PageSize - if pageSize > 0 { - query = query.Limit(int(pageSize)) - } - current := in.Current - if current > 0 { - query = query.Offset(int((current - 1) * pageSize)) - } - return query -} - -func permissionQueryOptions(query *ent.PermissionQuery, option dto.PermissionQueryOption) *ent.PermissionQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).(*ent.PermissionQuery) - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).(*ent.PermissionQuery) - } - if len(option.OrderFields) > 0 { - query = query.Order(permissionOrderBy(option.OrderFields)...) - } - return query -} - -func permissionOrderBy(fields []string, opts ...sql.OrderTermOption) []permission.OrderOption { - var orders []permission.OrderOption - for _, field := range fields { - orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) - } - return orders -} diff --git a/internal/features/datastore/dal/provider.go b/internal/features/datastore/dal/provider.go deleted file mode 100644 index e013feb9..00000000 --- a/internal/features/datastore/dal/provider.go +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dal implements the functions, types, and interfaces for the module. -package dal - -import ( - "github.com/google/wire" -) - -// ProviderSet is data providers. -var ProviderSet = wire.NewSet( - //NewAuthRepo, - //NewLoginRepo, - //NewPersonalRepo, - NewMenuRepo, - NewResourceRepo, - NewRoleRepo, - NewUserRepo, - NewPermissionRepo, - //NewCasbinSourceRepo, - //RefreshTokenizer, -) diff --git a/internal/features/datastore/dal/resource.dal.go b/internal/features/datastore/dal/resource.dal.go deleted file mode 100644 index 137a1b10..00000000 --- a/internal/features/datastore/dal/resource.dal.go +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package dal - -import ( - "context" - "strconv" - - "github.com/origadmin/runtime" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/db" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -type resourceRepo struct { - db *data.Data -} - -func (repo resourceRepo) Get(ctx context.Context, id int64, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { - var option dto.ResourceQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.Resource(ctx).Query().Where(resource.ID(id)) - query = resourceQueryOptions(query, option) - if option.IncludePermissions { - query.WithPermissions() - } - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResource2PB(result), nil -} - -func (repo resourceRepo) Create(ctx context.Context, resource *dto.ResourcePB, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { - var option dto.ResourceQueryOption - if len(options) > 0 { - option = options[0] - } - obj := dto.ConvertResourcePB2Object(resource) - if obj.ParentID > 0 { - parent, err := repo.db.Resource(ctx).Get(ctx, obj.ParentID) - if err != nil { - return nil, err - } - obj.TreePath = parent.TreePath + strconv.Itoa(int(parent.ID)) + repo.db.Delimiter - } - - create := repo.db.Resource(ctx).Create() - create.SetResource(obj, option.Fields...) - if len(resource.PermissionIds) > 0 { - create.AddPermissionIDs(resource.PermissionIds...) - } - if len(resource.Permissions) > 0 { - create.AddPermissions(dto.ConvertPermissionsPB2Object(resource.Permissions)...) - } - saved, err := create.Save(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResource2PB(saved), nil -} - -func (repo resourceRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Resource(ctx).DeleteOneID(id).Exec(ctx) -} - -func (repo resourceRepo) Update(ctx context.Context, resource *dto.ResourcePB, options ...dto.ResourceQueryOption) (*dto.ResourcePB, error) { - var option dto.ResourceQueryOption - if len(options) > 0 { - option = options[0] - } - err := repo.db.Tx(ctx, func(ctx context.Context) error { - update := repo.db.Resource(ctx).UpdateOneID(resource.Id) - update.SetResourceWithZero(dto.ConvertResourcePB2Object(resource), option.Fields...) - if len(resource.PermissionIds) > 0 { - update.AddPermissionIDs(resource.PermissionIds...) - } - if len(resource.Permissions) > 0 { - update.AddPermissions(dto.ConvertPermissionsPB2Object(resource.Permissions)...) - } - saved, err := update.Save(ctx) - if err != nil { - return err - } - resource = dto.ConvertResource2PB(saved) - return nil - }) - if err != nil { - return nil, err - } - return resource, nil -} - -func (repo resourceRepo) List(ctx context.Context, in *dto.ListResourcesRequest, options ...dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { - var option dto.ResourceQueryOption - if len(options) > 0 { - option = options[0] - } - - query := repo.db.Resource(ctx).Query() - return resourcePageQuery(ctx, query, in, option) -} - -// NewResourceRepo . -func NewResourceRepo(r runtime.Runtime, db *data.Data) dto.ResourceRepo { - return &resourceRepo{ - db: db, - } -} - -func resourcePageQuery(ctx context.Context, query *ent.ResourceQuery, in *pb.ListResourcesRequest, option dto.ResourceQueryOption) ([]*dto.ResourcePB, int32, error) { - if in.OnlyCount { - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - return nil, int32(count), nil - } - query = resourceQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - query = db.Query(query, in, !in.NoPaging) - result, err := query.All(ctx) - return dto.ConvertResources(result), int32(count), err -} - -func resourceOrderBy(orders []string) []resource.OrderOption { - return db.OrderBy[resource.OrderOption](orders) -} - -func resourceQueryOptions(query *ent.ResourceQuery, option dto.ResourceQueryOption) *ent.ResourceQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).(*ent.ResourceQuery) - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).(*ent.ResourceQuery) - } - if len(option.OrderFields) > 0 { - query = query.Order(resourceOrderBy(option.OrderFields)...) - } - return query -} diff --git a/internal/features/datastore/dal/role.dal.go b/internal/features/datastore/dal/role.dal.go deleted file mode 100644 index aa79e75c..00000000 --- a/internal/features/datastore/dal/role.dal.go +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dal is the data access object -package dal - -import ( - "errors" - - "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - "github.com/origadmin/toolkits/crypto/rand" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/db" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/role" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -type roleRepo struct { - gen *rand.Rand - db *data.Data -} - -func (repo roleRepo) Get(ctx context.Context, id int64, options ...dto.RoleQueryOption) (*dto.RolePB, error) { - var option dto.RoleQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.Role(ctx).Query().Where(role.ID(id)) - query = roleQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return dto.ConvertRole2PB(result), nil -} - -func (repo roleRepo) Create(ctx context.Context, rolePB *dto.RolePB, options ...dto.RoleUpdateOption) (*dto.RolePB, error) { - var option dto.RoleUpdateOption - if len(options) > 0 { - option = options[0] - } - obj := dto.ConvertRolePB2Object(rolePB) - if obj.Keyword == "" { - obj.Keyword = "system:role:" + repo.gen.RandString(12) - } - exist, err := repo.db.Role(ctx).Query().Where(role.KeywordEqualFold(rolePB.Keyword)).Exist(ctx) - if err != nil || exist { - return nil, errors.New("role keyword already exists") - } - err = repo.db.Tx(ctx, func(ctx context.Context) error { - create := repo.db.Role(ctx).Create() - create.SetRole(obj, option.Fields...) - saved, err := create.Save(ctx) - if err != nil { - return err - } - rolePB = dto.ConvertRole2PB(saved) - return nil - }) - if err != nil { - return nil, err - } - return rolePB, nil -} - -func (repo roleRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Tx(ctx, func(ctx context.Context) error { - err := repo.db.Role(ctx).DeleteOneID(id).Exec(ctx) - if err != nil { - return err - } - return nil - }) -} - -func (repo roleRepo) Update(ctx context.Context, rolePB *dto.RolePB, options ...dto.RoleUpdateOption) (*dto.RolePB, error) { - var option dto.RoleUpdateOption - if len(options) > 0 { - option = options[0] - } - update := repo.db.Role(ctx).UpdateOneID(rolePB.Id) - if len(rolePB.PermissionIds) > 0 { - update.ClearPermissions() - update.AddPermissionIDs(rolePB.PermissionIds...) - } - if len(rolePB.Permissions) > 0 { - update.ClearPermissions() - update.AddPermissions(dto.ConvertPermissionsPB2Object(rolePB.Permissions)...) - } - saved, err := update.SetRoleWithZero(dto.ConvertRolePB2Object(rolePB), option.Fields...).Save(ctx) - if err != nil { - return nil, err - } - rolePB = dto.ConvertRole2PB(saved) - return rolePB, nil -} - -func (repo roleRepo) List(ctx context.Context, in *pb.ListRolesRequest, options ...dto.RoleQueryOption) ([]*dto.RolePB, int32, error) { - var option dto.RoleQueryOption - if len(options) > 0 { - option = options[0] - } - - query := repo.db.Role(ctx).Query() - if option.IncludePermissions { - query = query.WithPermissions() - } - if v := option.InIDs; len(v) > 0 { - query = query.Where(role.IDIn(v...)) - } - if v := option.Name; len(v) > 0 { - query = query.Where(role.NameContains(v)) - } - if v := option.Status; v > 0 { - query = query.Where(role.StatusEQ(v)) - } - if v := option.UpdateTimeGT; v != nil { - query = query.Where(role.UpdateTimeGT(*v)) - } - - return rolePageQuery(ctx, query, in, option) -} - -// NewRoleRepo . -func NewRoleRepo(r runtime.Runtime, db *data.Data) dto.RoleRepo { - return &roleRepo{ - gen: rand.DigitAndLowerCase, - db: db, - } -} - -func rolePageQuery(ctx context.Context, query *ent.RoleQuery, in *pb.ListRolesRequest, option dto.RoleQueryOption) ([]*dto.RolePB, int32, error) { - if in.OnlyCount { - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - return nil, int32(count), nil - } - - query = roleQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - query = db.Query(query, in, !in.NoPaging) - result, err := query.All(ctx) - return dto.ConvertRoles(result), int32(count), err -} - -func roleQueryOptions(query *ent.RoleQuery, option dto.RoleQueryOption) *ent.RoleQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).(*ent.RoleQuery) - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).(*ent.RoleQuery) - } - if len(option.OrderFields) > 0 { - query = query.Order(roleOrderBy(option.OrderFields)...) - } - return query -} - -func roleOrderBy(fields []string, opts ...sql.OrderTermOption) []role.OrderOption { - var orders []role.OrderOption - for _, field := range fields { - orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) - } - return orders -} diff --git a/internal/features/datastore/dal/user.dal.go b/internal/features/datastore/dal/user.dal.go deleted file mode 100644 index 3ed61bd1..00000000 --- a/internal/features/datastore/dal/user.dal.go +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dal is the data access object -package dal - -import ( - "errors" - "time" - - "entgo.io/ent/dialect/sql" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/context" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/db" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/features/system/dto" // Corrected import path -) - -type userRepo struct { - db *data.Data -} - -func (repo userRepo) AddRoleIDs(ctx context.Context, i int64, int64s []int64, option ...dto.UserMutationOption) error { - //TODO implement me - panic("implement me") -} - -func (repo userRepo) UpdateUserStatus(ctx context.Context, id int64, status int8, options ...dto.UserQueryOption) error { - err := repo.db.User(ctx).UpdateOneID(id).SetStatus(status).Exec(ctx) - if err != nil { - return err - } - return nil -} - -func (repo userRepo) Current(ctx context.Context, id int64) (*dto.UserPB, error) { - return repo.Get(ctx, id) -} - -func (repo userRepo) ListResourceByUserID(ctx context.Context, id int64, - option ...dto.UserQueryOption) ([]*dto.ResourcePB, error) { - resources, err := repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().QueryPermissions().QueryResources().All(ctx) - if err != nil { - return nil, err - } - return dto.ConvertResources(resources), nil -} - -func (repo userRepo) GetByUsername(ctx context.Context, username string, fields ...string) (*dto.UserNode, error) { - query := repo.db.User(ctx).Query().Where(user.UsernameEQ(username)) - var option dto.UserQueryOption - if len(fields) > 0 { - option.SelectFields = fields - } - query = userQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return &dto.UserNode{ - UserPB: *dto.ConvertUser2PB(result), - EncryptedPassword: result.EncryptedPassword, - }, nil -} - -func (repo userRepo) GetRoleIDs(ctx context.Context, id int64) ([]int64, error) { - return repo.db.User(ctx).Query().Where(user.ID(id)).QueryRoles().IDs(ctx) -} - -func (repo userRepo) Get(ctx context.Context, id int64, options ...dto.UserQueryOption) (*dto.UserPB, error) { - var option dto.UserQueryOption - if len(options) > 0 { - option = options[0] - } - query := repo.db.User(ctx).Query().Where(user.ID(id)) - query = userQueryOptions(query, option) - result, err := query.First(ctx) - if err != nil { - return nil, err - } - return dto.ConvertUser2PB(result), nil -} - -func (repo userRepo) Create(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { - var option dto.UserMutationOption - if len(options) > 0 { - option = options[0] - } - - var err error - exist, err := repo.db.User(ctx).Query().Where(user.UsernameEQ(userPB.Username)).Exist(ctx) - if err != nil || exist { - return nil, errors.New("user already exists") - } - obj := dto.ConvertUserPB2Object(userPB) - obj.CreateTime = time.Now() - obj.UpdateTime = time.Now() - err = repo.db.Tx(ctx, func(ctx context.Context) error { - create := repo.db.User(ctx).Create() - create.SetUser(obj, option.Fields...) - saved, err := create.Save(ctx) - if err != nil { - return err - } - userPB = dto.ConvertUser2PB(saved) - return nil - }) - if err != nil { - return nil, err - } - return userPB, nil -} - -func (repo userRepo) Delete(ctx context.Context, id int64) error { - return repo.db.Tx(ctx, func(ctx context.Context) error { - return repo.db.User(ctx).DeleteOneID(id).Exec(ctx) - }) -} - -func (repo userRepo) Update(ctx context.Context, userPB *dto.UserPB, options ...dto.UserMutationOption) (*dto.UserPB, error) { - obj := dto.ConvertUserPB2Object(userPB) - obj.UpdateTime = time.Now() - err := repo.db.Tx(ctx, func(ctx context.Context) error { - update := repo.db.User(ctx).UpdateOneID(userPB.Id) - if len(userPB.Roles) > 0 { - update.ClearRoles() - update.AddRoles(dto.ConvertRolesPB2Object(userPB.Roles)...) - } else { - update.ClearRoles() - } - if len(userPB.RoleIds) > 0 { - update.ClearRoles() - update.AddRoleIDs(userPB.RoleIds...) - } else { - update.ClearRoles() - } - update.SetUser(obj, user.SelectColumns([]string{ - user.FieldNickname, - user.FieldUsername, - user.FieldPhone, - user.FieldEmail, - user.FieldUpdateTime})...) - saved, err := update.Save(ctx) - if err != nil { - return err - } - userPB = dto.ConvertUser2PB(saved) - return nil - }) - if err != nil { - return nil, err - } - return userPB, nil -} - -func (repo userRepo) List(ctx context.Context, in *pb.ListUsersRequest, options ...dto.UserQueryOption) ([]*dto.UserPB, int32, error) { - var option dto.UserQueryOption - if len(options) > 0 { - option = options[0] - } - - query := repo.db.User(ctx).Query() - if option.IncludeRoles { - query = query.WithRoles() - } - if in.Title != "" { - query = query.Where(user.Or(user.UsernameContainsFold(in.Title), user.PhoneContainsFold(in.Title), user.EmailContainsFold(in.Title))) - } - - if v := option.Status; v > 0 { - query = query.Where(user.StatusEQ(v)) - } - - return userPageQuery(ctx, query, in, option) -} - -// NewUserRepo . -func NewUserRepo(r runtime.Runtime, db *data.Data) dto.UserRepo { - return &userRepo{ - db: db, - } -} - -func userPageQuery(ctx context.Context, query *ent.UserQuery, in *pb.ListUsersRequest, option dto.UserQueryOption) ([]*dto.UserPB, int32, error) { - if in.OnlyCount { - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - return nil, int32(count), nil - } - - query = userQueryOptions(query, option) - count, err := query.Count(ctx) - if err != nil { - return nil, 0, err - } - query = db.Query(query, in, !in.NoPaging) - result, err := query.All(ctx) - return dto.ConvertUsers(result), int32(count), err -} - -func userQueryOptions(query *ent.UserQuery, option dto.UserQueryOption) *ent.UserQuery { - if len(option.SelectFields) > 0 { - query = query.Select(option.SelectFields...).(*ent.UserQuery) - } - if len(option.OmitFields) > 0 { - query = query.Omit(option.OmitFields...).(*ent.UserQuery) - } - if len(option.OrderFields) > 0 { - query = query.Order(userOrderBy(option.OrderFields)...) - } - return query -} - -func userOrderBy(fields []string, opts ...sql.OrderTermOption) []user.OrderOption { - var orders []user.OrderOption - for _, field := range fields { - orders = append(orders, sql.OrderByField(field, opts...).ToFunc()) - } - return orders -} diff --git a/internal/features/datastore/dto/custom.gen.go b/internal/features/datastore/dto/custom.gen.go new file mode 100644 index 00000000..5435a449 --- /dev/null +++ b/internal/features/datastore/dto/custom.gen.go @@ -0,0 +1,52 @@ +// This file is generated by abgen, but you can edit it. +// More info: https://github.com/origadmin/abgen + +package dto + +import ( + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/view" +) + +// ConvertGenderToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertGenderToString(from user.Gender) string { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertInt32ToStatus is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertInt32ToStatus(from int32) resource.Status { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertStatusToInt32 is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStatusToInt32(from resource.Status) int32 { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertStringToGender is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToGender(from string) user.Gender { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertStringToType is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToType(from string) view.Type { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertTypeToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertTypeToString(from view.Type) string { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} diff --git a/internal/features/datastore/dto/department.go b/internal/features/datastore/dto/department.go deleted file mode 100644 index 1e1fad52..00000000 --- a/internal/features/datastore/dto/department.go +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto implements the functions, types, and interfaces for the module. -package dto - -type DepartmentNode struct { - DepartmentPB - Children []*DepartmentNode `json:"children"` - PositionKeywords []string `json:"position_keywords"` -} diff --git a/internal/features/datastore/dto/dto.gen.go b/internal/features/datastore/dto/dto.gen.go new file mode 100644 index 00000000..144fda3d --- /dev/null +++ b/internal/features/datastore/dto/dto.gen.go @@ -0,0 +1,1279 @@ +//go:build !abgen_source + +// Code generated by abgen. DO NOT EDIT. +// versions: v0.0.1 +// source: . + +package dto + +import ( + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/enums" + "time" + + "google.golang.org/protobuf/types/known/timestamppb" +) + +// Local type aliases for external types. +type ( + Department = ent.Department + DepartmentEdges = ent.DepartmentEdges + DepartmentEdgesPB = types.DepartmentEdges + DepartmentPB = types.Department + Departments = []*ent.Department + DepartmentsPB = []*types.Department + Permission = ent.Permission + PermissionEdges = ent.PermissionEdges + PermissionEdgesPB = types.PermissionEdges + PermissionPB = types.Permission + PermissionResource = ent.PermissionResource + PermissionResourceEdges = ent.PermissionResourceEdges + PermissionResourceEdgesPB = types.PermissionResourceEdges + PermissionResourcePB = types.PermissionResource + PermissionResources = []*ent.PermissionResource + PermissionResourcesPB = []*types.PermissionResource + Permissions = []*ent.Permission + PermissionsPB = []*types.Permission + Position = ent.Position + PositionEdges = ent.PositionEdges + PositionEdgesPB = types.PositionEdges + PositionPB = types.Position + PositionPermission = ent.PositionPermission + PositionPermissionEdges = ent.PositionPermissionEdges + PositionPermissionEdgesPB = types.PositionPermissionEdges + PositionPermissionPB = types.PositionPermission + PositionPermissions = []*ent.PositionPermission + PositionPermissionsPB = []*types.PositionPermission + Positions = []*ent.Position + PositionsPB = []*types.Position + Resource = ent.Resource + ResourceEdges = ent.ResourceEdges + ResourceEdgesPB = types.ResourceEdges + ResourcePB = types.Resource + Resources = []*ent.Resource + ResourcesPB = []*types.Resource + Role = ent.Role + RoleEdges = ent.RoleEdges + RoleEdgesPB = types.RoleEdges + RolePB = types.Role + RolePermission = ent.RolePermission + RolePermissionEdges = ent.RolePermissionEdges + RolePermissionEdgesPB = types.RolePermissionEdges + RolePermissionPB = types.RolePermission + RolePermissions = []*ent.RolePermission + RolePermissionsPB = []*types.RolePermission + RoleViewPB = types.RoleView + RoleViewsPB = []*types.RoleView + Roles = []*ent.Role + RolesPB = []*types.Role + User = ent.User + UserDepartment = ent.UserDepartment + UserDepartmentEdges = ent.UserDepartmentEdges + UserDepartmentEdgesPB = types.UserDepartmentEdges + UserDepartmentPB = types.UserDepartment + UserDepartments = []*ent.UserDepartment + UserDepartmentsPB = []*types.UserDepartment + UserEdges = ent.UserEdges + UserEdgesPB = types.UserEdges + UserPB = types.User + UserPosition = ent.UserPosition + UserPositionEdges = ent.UserPositionEdges + UserPositionEdgesPB = types.UserPositionEdges + UserPositionPB = types.UserPosition + UserPositions = []*ent.UserPosition + UserPositionsPB = []*types.UserPosition + UserRole = ent.UserRole + UserRoleEdges = ent.UserRoleEdges + UserRoleEdgesPB = types.UserRoleEdges + UserRolePB = types.UserRole + UserRoles = []*ent.UserRole + UserRolesPB = []*types.UserRole + Users = []*ent.User + UsersPB = []*types.User + View = ent.View + ViewEdges = ent.ViewEdges + ViewEdgesPB = types.ViewEdges + ViewPB = types.View + ViewPermission = ent.ViewPermission + ViewPermissionEdges = ent.ViewPermissionEdges + ViewPermissions = []*ent.ViewPermission + ViewResource = ent.ViewResource + ViewResourceEdges = ent.ViewResourceEdges + ViewResources = []*ent.ViewResource + Views = []*ent.View + ViewsPB = []*types.View +) + +// ConvertDepartmentEdgesPBToDepartmentEdges converts DepartmentEdgesPB to DepartmentEdges. +func ConvertDepartmentEdgesPBToDepartmentEdges(from *DepartmentEdgesPB) *DepartmentEdges { + if from == nil { + return nil + } + + to := &DepartmentEdges{ + Users: ConvertUsersPBToUsers(from.Users), + Positions: ConvertPositionsPBToPositions(from.Positions), + Parent: ConvertDepartmentPBToDepartment(from.Parent), + Children: ConvertDepartmentsPBToDepartments(from.Children), + UserDepartments: ConvertUserDepartmentsPBToUserDepartments(from.UserDepartments), + } + return to +} + +// ConvertDepartmentEdgesToDepartmentEdgesPB converts DepartmentEdges to DepartmentEdgesPB. +func ConvertDepartmentEdgesToDepartmentEdgesPB(from *DepartmentEdges) *DepartmentEdgesPB { + if from == nil { + return nil + } + + to := &DepartmentEdgesPB{ + Users: ConvertUsersToUsersPB(from.Users), + Positions: ConvertPositionsToPositionsPB(from.Positions), + Children: ConvertDepartmentsToDepartmentsPB(from.Children), + Parent: ConvertDepartmentToDepartmentPB(from.Parent), + UserDepartments: ConvertUserDepartmentsToUserDepartmentsPB(from.UserDepartments), + } + return to +} + +// ConvertDepartmentPBToDepartment converts DepartmentPB to Department. +func ConvertDepartmentPBToDepartment(from *DepartmentPB) *Department { + if from == nil { + return nil + } + + to := &Department{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + TreePath: from.TreePath, + Sequence: int(from.Sequence), + Status: int8(from.Status), + Level: int(from.Level), + Description: from.Description, + ParentID: from.ParentId, + } + return to +} + +// ConvertDepartmentToDepartmentPB converts Department to DepartmentPB. +func ConvertDepartmentToDepartmentPB(from *Department) *DepartmentPB { + if from == nil { + return nil + } + + to := &DepartmentPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + TreePath: from.TreePath, + Sequence: int32(from.Sequence), + Status: int32(from.Status), + Level: int32(from.Level), + Description: from.Description, + ParentId: from.ParentID, + Children: ConvertDepartmentsToDepartmentsPB(from.Edges.Children), + Parent: ConvertDepartmentToDepartmentPB(from.Edges.Parent), + } + return to +} + +// ConvertDepartmentsPBToDepartments converts a slice of *DepartmentPB to a slice of *Department. +func ConvertDepartmentsPBToDepartments(froms DepartmentsPB) Departments { + if froms == nil { + return nil + } + tos := make(Departments, len(froms)) + for i, f := range froms { + tos[i] = ConvertDepartmentPBToDepartment(f) + } + return tos +} + +// ConvertDepartmentsToDepartmentsPB converts a slice of *Department to a slice of *DepartmentPB. +func ConvertDepartmentsToDepartmentsPB(froms Departments) DepartmentsPB { + if froms == nil { + return nil + } + tos := make(DepartmentsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertDepartmentToDepartmentPB(f) + } + return tos +} + +// ConvertPermissionEdgesPBToPermissionEdges converts PermissionEdgesPB to PermissionEdges. +func ConvertPermissionEdgesPBToPermissionEdges(from *PermissionEdgesPB) *PermissionEdges { + if from == nil { + return nil + } + + to := &PermissionEdges{ + Roles: ConvertRolesPBToRoles(from.Roles), + Positions: ConvertPositionsPBToPositions(from.Positions), + Resources: ConvertResourcesPBToResources(from.Resources), + RolePermissions: ConvertRolePermissionsPBToRolePermissions(from.RolePermissions), + PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), + PermissionResources: ConvertPermissionResourcesPBToPermissionResources(from.PermissionResources), + } + return to +} + +// ConvertPermissionEdgesToPermissionEdgesPB converts PermissionEdges to PermissionEdgesPB. +func ConvertPermissionEdgesToPermissionEdgesPB(from *PermissionEdges) *PermissionEdgesPB { + if from == nil { + return nil + } + + to := &PermissionEdgesPB{ + Roles: ConvertRolesToRolesPB(from.Roles), + Resources: ConvertResourcesToResourcesPB(from.Resources), + Positions: ConvertPositionsToPositionsPB(from.Positions), + RolePermissions: ConvertRolePermissionsToRolePermissionsPB(from.RolePermissions), + PermissionResources: ConvertPermissionResourcesToPermissionResourcesPB(from.PermissionResources), + PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), + } + return to +} + +// ConvertPermissionPBToPermission converts PermissionPB to Permission. +func ConvertPermissionPBToPermission(from *PermissionPB) *Permission { + if from == nil { + return nil + } + + to := &Permission{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DataScope: from.DataScope, + DataRules: from.DataRules, + } + return to +} + +// ConvertPermissionResourceEdgesPBToPermissionResourceEdges converts PermissionResourceEdgesPB to PermissionResourceEdges. +func ConvertPermissionResourceEdgesPBToPermissionResourceEdges(from *PermissionResourceEdgesPB) *PermissionResourceEdges { + if from == nil { + return nil + } + + to := &PermissionResourceEdges{ + Permission: ConvertPermissionPBToPermission(from.Permission), + Resource: ConvertResourcePBToResource(from.Resource), + } + return to +} + +// ConvertPermissionResourceEdgesToPermissionResourceEdgesPB converts PermissionResourceEdges to PermissionResourceEdgesPB. +func ConvertPermissionResourceEdgesToPermissionResourceEdgesPB(from *PermissionResourceEdges) *PermissionResourceEdgesPB { + if from == nil { + return nil + } + + to := &PermissionResourceEdgesPB{ + Permission: ConvertPermissionToPermissionPB(from.Permission), + Resource: ConvertResourceToResourcePB(from.Resource), + } + return to +} + +// ConvertPermissionResourcePBToPermissionResource converts PermissionResourcePB to PermissionResource. +func ConvertPermissionResourcePBToPermissionResource(from *PermissionResourcePB) *PermissionResource { + if from == nil { + return nil + } + + to := &PermissionResource{ + ID: int(from.Id), + PermissionID: from.PermissionId, + ResourceID: from.ResourceId, + } + return to +} + +// ConvertPermissionResourceToPermissionResourcePB converts PermissionResource to PermissionResourcePB. +func ConvertPermissionResourceToPermissionResourcePB(from *PermissionResource) *PermissionResourcePB { + if from == nil { + return nil + } + + to := &PermissionResourcePB{ + Id: int64(from.ID), + PermissionId: from.PermissionID, + ResourceId: from.ResourceID, + } + return to +} + +// ConvertPermissionResourcesPBToPermissionResources converts a slice of *PermissionResourcePB to a slice of *PermissionResource. +func ConvertPermissionResourcesPBToPermissionResources(froms PermissionResourcesPB) PermissionResources { + if froms == nil { + return nil + } + tos := make(PermissionResources, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionResourcePBToPermissionResource(f) + } + return tos +} + +// ConvertPermissionResourcesToPermissionResourcesPB converts a slice of *PermissionResource to a slice of *PermissionResourcePB. +func ConvertPermissionResourcesToPermissionResourcesPB(froms PermissionResources) PermissionResourcesPB { + if froms == nil { + return nil + } + tos := make(PermissionResourcesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionResourceToPermissionResourcePB(f) + } + return tos +} + +// ConvertPermissionToPermissionPB converts Permission to PermissionPB. +func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { + if from == nil { + return nil + } + + to := &PermissionPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DataScope: from.DataScope, + DataRules: from.DataRules, + Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), + } + return to +} + +// ConvertPermissionsPBToPermissions converts a slice of *PermissionPB to a slice of *Permission. +func ConvertPermissionsPBToPermissions(froms PermissionsPB) Permissions { + if froms == nil { + return nil + } + tos := make(Permissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionPBToPermission(f) + } + return tos +} + +// ConvertPermissionsToPermissionsPB converts a slice of *Permission to a slice of *PermissionPB. +func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { + if froms == nil { + return nil + } + tos := make(PermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionToPermissionPB(f) + } + return tos +} + +// ConvertPositionEdgesPBToPositionEdges converts PositionEdgesPB to PositionEdges. +func ConvertPositionEdgesPBToPositionEdges(from *PositionEdgesPB) *PositionEdges { + if from == nil { + return nil + } + + to := &PositionEdges{ + Department: ConvertDepartmentPBToDepartment(from.Department), + Users: ConvertUsersPBToUsers(from.Users), + Permissions: ConvertPermissionsPBToPermissions(from.Permissions), + UserPositions: ConvertUserPositionsPBToUserPositions(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), + } + return to +} + +// ConvertPositionEdgesToPositionEdgesPB converts PositionEdges to PositionEdgesPB. +func ConvertPositionEdgesToPositionEdgesPB(from *PositionEdges) *PositionEdgesPB { + if from == nil { + return nil + } + + to := &PositionEdgesPB{ + Department: ConvertDepartmentToDepartmentPB(from.Department), + Users: ConvertUsersToUsersPB(from.Users), + Permissions: ConvertPermissionsToPermissionsPB(from.Permissions), + UserPositions: ConvertUserPositionsToUserPositionsPB(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), + } + return to +} + +// ConvertPositionPBToPosition converts PositionPB to Position. +func ConvertPositionPBToPosition(from *PositionPB) *Position { + if from == nil { + return nil + } + + to := &Position{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DepartmentID: from.DepartmentId, + } + return to +} + +// ConvertPositionPermissionEdgesPBToPositionPermissionEdges converts PositionPermissionEdgesPB to PositionPermissionEdges. +func ConvertPositionPermissionEdgesPBToPositionPermissionEdges(from *PositionPermissionEdgesPB) *PositionPermissionEdges { + if from == nil { + return nil + } + + to := &PositionPermissionEdges{ + Position: ConvertPositionPBToPosition(from.Position), + Permission: ConvertPermissionPBToPermission(from.Permission), + } + return to +} + +// ConvertPositionPermissionEdgesToPositionPermissionEdgesPB converts PositionPermissionEdges to PositionPermissionEdgesPB. +func ConvertPositionPermissionEdgesToPositionPermissionEdgesPB(from *PositionPermissionEdges) *PositionPermissionEdgesPB { + if from == nil { + return nil + } + + to := &PositionPermissionEdgesPB{ + Position: ConvertPositionToPositionPB(from.Position), + Permission: ConvertPermissionToPermissionPB(from.Permission), + } + return to +} + +// ConvertPositionPermissionPBToPositionPermission converts PositionPermissionPB to PositionPermission. +func ConvertPositionPermissionPBToPositionPermission(from *PositionPermissionPB) *PositionPermission { + if from == nil { + return nil + } + + to := &PositionPermission{ + ID: int(from.Id), + PositionID: from.PositionId, + PermissionID: from.PermissionId, + } + return to +} + +// ConvertPositionPermissionToPositionPermissionPB converts PositionPermission to PositionPermissionPB. +func ConvertPositionPermissionToPositionPermissionPB(from *PositionPermission) *PositionPermissionPB { + if from == nil { + return nil + } + + to := &PositionPermissionPB{ + Id: int64(from.ID), + PositionId: from.PositionID, + PermissionId: from.PermissionID, + } + return to +} + +// ConvertPositionPermissionsPBToPositionPermissions converts a slice of *PositionPermissionPB to a slice of *PositionPermission. +func ConvertPositionPermissionsPBToPositionPermissions(froms PositionPermissionsPB) PositionPermissions { + if froms == nil { + return nil + } + tos := make(PositionPermissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionPBToPositionPermission(f) + } + return tos +} + +// ConvertPositionPermissionsToPositionPermissionsPB converts a slice of *PositionPermission to a slice of *PositionPermissionPB. +func ConvertPositionPermissionsToPositionPermissionsPB(froms PositionPermissions) PositionPermissionsPB { + if froms == nil { + return nil + } + tos := make(PositionPermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionToPositionPermissionPB(f) + } + return tos +} + +// ConvertPositionToPositionPB converts Position to PositionPB. +func ConvertPositionToPositionPB(from *Position) *PositionPB { + if from == nil { + return nil + } + + to := &PositionPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, + Keyword: from.Keyword, + Description: from.Description, + DepartmentId: from.DepartmentID, + } + return to +} + +// ConvertPositionsPBToPositions converts a slice of *PositionPB to a slice of *Position. +func ConvertPositionsPBToPositions(froms PositionsPB) Positions { + if froms == nil { + return nil + } + tos := make(Positions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPBToPosition(f) + } + return tos +} + +// ConvertPositionsToPositionsPB converts a slice of *Position to a slice of *PositionPB. +func ConvertPositionsToPositionsPB(froms Positions) PositionsPB { + if froms == nil { + return nil + } + tos := make(PositionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionToPositionPB(f) + } + return tos +} + +// ConvertResourceEdgesPBToResourceEdges converts ResourceEdgesPB to ResourceEdges. +func ConvertResourceEdgesPBToResourceEdges(from *ResourceEdgesPB) *ResourceEdges { + if from == nil { + return nil + } + + to := &ResourceEdges{} + return to +} + +// ConvertResourceEdgesToResourceEdgesPB converts ResourceEdges to ResourceEdgesPB. +func ConvertResourceEdgesToResourceEdgesPB(from *ResourceEdges) *ResourceEdgesPB { + if from == nil { + return nil + } + + to := &ResourceEdgesPB{} + return to +} + +// ConvertResourcePBToResource converts ResourcePB to Resource. +func ConvertResourcePBToResource(from *ResourcePB) *Resource { + if from == nil { + return nil + } + + to := &Resource{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Path: from.Path, + Method: from.Method, + Operation: from.Operation, + Status: ConvertInt32ToStatus(from.Status), + } + return to +} + +// ConvertResourceToResourcePB converts Resource to ResourcePB. +func ConvertResourceToResourcePB(from *Resource) *ResourcePB { + if from == nil { + return nil + } + + to := &ResourcePB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Status: ConvertStatusToInt32(from.Status), + Path: from.Path, + Operation: from.Operation, + Method: from.Method, + Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), + } + return to +} + +// ConvertResourcesPBToResources converts a slice of *ResourcePB to a slice of *Resource. +func ConvertResourcesPBToResources(froms ResourcesPB) Resources { + if froms == nil { + return nil + } + tos := make(Resources, len(froms)) + for i, f := range froms { + tos[i] = ConvertResourcePBToResource(f) + } + return tos +} + +// ConvertResourcesToResourcesPB converts a slice of *Resource to a slice of *ResourcePB. +func ConvertResourcesToResourcesPB(froms Resources) ResourcesPB { + if froms == nil { + return nil + } + tos := make(ResourcesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertResourceToResourcePB(f) + } + return tos +} + +// ConvertRoleEdgesPBToRoleEdges converts RoleEdgesPB to RoleEdges. +func ConvertRoleEdgesPBToRoleEdges(from *RoleEdgesPB) *RoleEdges { + if from == nil { + return nil + } + + to := &RoleEdges{ + Users: ConvertUsersPBToUsers(from.Users), + UserRoles: ConvertUserRolesPBToUserRoles(from.UserRoles), + } + return to +} + +// ConvertRoleEdgesToRoleEdgesPB converts RoleEdges to RoleEdgesPB. +func ConvertRoleEdgesToRoleEdgesPB(from *RoleEdges) *RoleEdgesPB { + if from == nil { + return nil + } + + to := &RoleEdgesPB{ + Users: ConvertUsersToUsersPB(from.Users), + UserRoles: ConvertUserRolesToUserRolesPB(from.UserRoles), + } + return to +} + +// ConvertRolePBToRole converts RolePB to Role. +func ConvertRolePBToRole(from *RolePB) *Role { + if from == nil { + return nil + } + + to := &Role{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Description: from.Description, + Type: enums.RoleType(from.Type), + Sequence: int(from.Sequence), + Status: enums.Status(from.Status), + } + return to +} + +// ConvertRolePermissionEdgesPBToRolePermissionEdges converts RolePermissionEdgesPB to RolePermissionEdges. +func ConvertRolePermissionEdgesPBToRolePermissionEdges(from *RolePermissionEdgesPB) *RolePermissionEdges { + if from == nil { + return nil + } + + to := &RolePermissionEdges{ + Role: ConvertRolePBToRole(from.Role), + Permission: ConvertPermissionPBToPermission(from.Permission), + } + return to +} + +// ConvertRolePermissionEdgesToRolePermissionEdgesPB converts RolePermissionEdges to RolePermissionEdgesPB. +func ConvertRolePermissionEdgesToRolePermissionEdgesPB(from *RolePermissionEdges) *RolePermissionEdgesPB { + if from == nil { + return nil + } + + to := &RolePermissionEdgesPB{ + Role: ConvertRoleToRolePB(from.Role), + Permission: ConvertPermissionToPermissionPB(from.Permission), + } + return to +} + +// ConvertRolePermissionPBToRolePermission converts RolePermissionPB to RolePermission. +func ConvertRolePermissionPBToRolePermission(from *RolePermissionPB) *RolePermission { + if from == nil { + return nil + } + + to := &RolePermission{ + ID: int(from.Id), + RoleID: from.RoleId, + PermissionID: from.PermissionId, + } + return to +} + +// ConvertRolePermissionToRolePermissionPB converts RolePermission to RolePermissionPB. +func ConvertRolePermissionToRolePermissionPB(from *RolePermission) *RolePermissionPB { + if from == nil { + return nil + } + + to := &RolePermissionPB{ + Id: int64(from.ID), + RoleId: from.RoleID, + PermissionId: from.PermissionID, + } + return to +} + +// ConvertRolePermissionsPBToRolePermissions converts a slice of *RolePermissionPB to a slice of *RolePermission. +func ConvertRolePermissionsPBToRolePermissions(froms RolePermissionsPB) RolePermissions { + if froms == nil { + return nil + } + tos := make(RolePermissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertRolePermissionPBToRolePermission(f) + } + return tos +} + +// ConvertRolePermissionsToRolePermissionsPB converts a slice of *RolePermission to a slice of *RolePermissionPB. +func ConvertRolePermissionsToRolePermissionsPB(froms RolePermissions) RolePermissionsPB { + if froms == nil { + return nil + } + tos := make(RolePermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertRolePermissionToRolePermissionPB(f) + } + return tos +} + +// ConvertRoleToRolePB converts Role to RolePB. +func ConvertRoleToRolePB(from *Role) *RolePB { + if from == nil { + return nil + } + + to := &RolePB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Description: from.Description, + Type: int32(from.Type), + Sequence: int32(from.Sequence), + Status: int32(from.Status), + Users: ConvertUsersToUsersPB(from.Edges.Users), + Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), + } + return to +} + +// ConvertRolesPBToRoles converts a slice of *RolePB to a slice of *Role. +func ConvertRolesPBToRoles(froms RolesPB) Roles { + if froms == nil { + return nil + } + tos := make(Roles, len(froms)) + for i, f := range froms { + tos[i] = ConvertRolePBToRole(f) + } + return tos +} + +// ConvertRolesToRolesPB converts a slice of *Role to a slice of *RolePB. +func ConvertRolesToRolesPB(froms Roles) RolesPB { + if froms == nil { + return nil + } + tos := make(RolesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertRoleToRolePB(f) + } + return tos +} + +// ConvertUserDepartmentEdgesPBToUserDepartmentEdges converts UserDepartmentEdgesPB to UserDepartmentEdges. +func ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from *UserDepartmentEdgesPB) *UserDepartmentEdges { + if from == nil { + return nil + } + + to := &UserDepartmentEdges{ + User: ConvertUserPBToUser(from.User), + Department: ConvertDepartmentPBToDepartment(from.Department), + } + return to +} + +// ConvertUserDepartmentEdgesToUserDepartmentEdgesPB converts UserDepartmentEdges to UserDepartmentEdgesPB. +func ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(from *UserDepartmentEdges) *UserDepartmentEdgesPB { + if from == nil { + return nil + } + + to := &UserDepartmentEdgesPB{ + User: ConvertUserToUserPB(from.User), + Department: ConvertDepartmentToDepartmentPB(from.Department), + } + return to +} + +// ConvertUserDepartmentPBToUserDepartment converts UserDepartmentPB to UserDepartment. +func ConvertUserDepartmentPBToUserDepartment(from *UserDepartmentPB) *UserDepartment { + if from == nil { + return nil + } + + to := &UserDepartment{ + ID: int(from.Id), + UserID: from.UserId, + DepartmentID: from.DepartmentId, + Edges: *ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from.Edges), + } + return to +} + +// ConvertUserDepartmentToUserDepartmentPB converts UserDepartment to UserDepartmentPB. +func ConvertUserDepartmentToUserDepartmentPB(from *UserDepartment) *UserDepartmentPB { + if from == nil { + return nil + } + + to := &UserDepartmentPB{ + Id: int64(from.ID), + UserId: from.UserID, + DepartmentId: from.DepartmentID, + Edges: ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(&from.Edges), + } + return to +} + +// ConvertUserDepartmentsPBToUserDepartments converts a slice of *UserDepartmentPB to a slice of *UserDepartment. +func ConvertUserDepartmentsPBToUserDepartments(froms UserDepartmentsPB) UserDepartments { + if froms == nil { + return nil + } + tos := make(UserDepartments, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserDepartmentPBToUserDepartment(f) + } + return tos +} + +// ConvertUserDepartmentsToUserDepartmentsPB converts a slice of *UserDepartment to a slice of *UserDepartmentPB. +func ConvertUserDepartmentsToUserDepartmentsPB(froms UserDepartments) UserDepartmentsPB { + if froms == nil { + return nil + } + tos := make(UserDepartmentsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserDepartmentToUserDepartmentPB(f) + } + return tos +} + +// ConvertUserEdgesPBToUserEdges converts UserEdgesPB to UserEdges. +func ConvertUserEdgesPBToUserEdges(from *UserEdgesPB) *UserEdges { + if from == nil { + return nil + } + + to := &UserEdges{ + Roles: ConvertRolesPBToRoles(from.Roles), + UserRoles: ConvertUserRolesPBToUserRoles(from.UserRoles), + } + return to +} + +// ConvertUserEdgesToUserEdgesPB converts UserEdges to UserEdgesPB. +func ConvertUserEdgesToUserEdgesPB(from *UserEdges) *UserEdgesPB { + if from == nil { + return nil + } + + to := &UserEdgesPB{ + Roles: ConvertRolesToRolesPB(from.Roles), + UserRoles: ConvertUserRolesToUserRolesPB(from.UserRoles), + } + return to +} + +// ConvertUserPBToUser converts UserPB to User. +func ConvertUserPBToUser(from *UserPB) *User { + if from == nil { + return nil + } + + to := &User{ + ID: from.Id, + CreateAuthor: from.CreateAuthor, + UpdateAuthor: from.UpdateAuthor, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + UUID: from.Uuid, + AllowedIP: from.AllowedIp, + Username: from.Username, + Nickname: from.Nickname, + Avatar: from.Avatar, + Name: from.Name, + Gender: ConvertStringToGender(from.Gender), + Phone: from.Phone, + Email: from.Email, + Remark: from.Remark, + Token: from.Token, + Status: enums.Status(from.Status), + LastLoginIP: from.LastLoginIp, + LastLoginTime: ConvertTimestampToTime(from.LastLoginTime), + SanctionDate: ConvertTimestampToTime(from.SanctionDate), + ManagerID: from.ManagerId, + Manager: from.Manager, + } + return to +} + +// ConvertUserPositionEdgesPBToUserPositionEdges converts UserPositionEdgesPB to UserPositionEdges. +func ConvertUserPositionEdgesPBToUserPositionEdges(from *UserPositionEdgesPB) *UserPositionEdges { + if from == nil { + return nil + } + + to := &UserPositionEdges{ + User: ConvertUserPBToUser(from.User), + Position: ConvertPositionPBToPosition(from.Position), + } + return to +} + +// ConvertUserPositionEdgesToUserPositionEdgesPB converts UserPositionEdges to UserPositionEdgesPB. +func ConvertUserPositionEdgesToUserPositionEdgesPB(from *UserPositionEdges) *UserPositionEdgesPB { + if from == nil { + return nil + } + + to := &UserPositionEdgesPB{ + User: ConvertUserToUserPB(from.User), + Position: ConvertPositionToPositionPB(from.Position), + } + return to +} + +// ConvertUserPositionPBToUserPosition converts UserPositionPB to UserPosition. +func ConvertUserPositionPBToUserPosition(from *UserPositionPB) *UserPosition { + if from == nil { + return nil + } + + to := &UserPosition{ + ID: int(from.Id), + UserID: from.UserId, + PositionID: from.PositionId, + } + return to +} + +// ConvertUserPositionToUserPositionPB converts UserPosition to UserPositionPB. +func ConvertUserPositionToUserPositionPB(from *UserPosition) *UserPositionPB { + if from == nil { + return nil + } + + to := &UserPositionPB{ + Id: int64(from.ID), + UserId: from.UserID, + PositionId: from.PositionID, + } + return to +} + +// ConvertUserPositionsPBToUserPositions converts a slice of *UserPositionPB to a slice of *UserPosition. +func ConvertUserPositionsPBToUserPositions(froms UserPositionsPB) UserPositions { + if froms == nil { + return nil + } + tos := make(UserPositions, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionPBToUserPosition(f) + } + return tos +} + +// ConvertUserPositionsToUserPositionsPB converts a slice of *UserPosition to a slice of *UserPositionPB. +func ConvertUserPositionsToUserPositionsPB(froms UserPositions) UserPositionsPB { + if froms == nil { + return nil + } + tos := make(UserPositionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionToUserPositionPB(f) + } + return tos +} + +// ConvertUserRoleEdgesPBToUserRoleEdges converts UserRoleEdgesPB to UserRoleEdges. +func ConvertUserRoleEdgesPBToUserRoleEdges(from *UserRoleEdgesPB) *UserRoleEdges { + if from == nil { + return nil + } + + to := &UserRoleEdges{ + User: ConvertUserPBToUser(from.User), + Role: ConvertRolePBToRole(from.Role), + } + return to +} + +// ConvertUserRoleEdgesToUserRoleEdgesPB converts UserRoleEdges to UserRoleEdgesPB. +func ConvertUserRoleEdgesToUserRoleEdgesPB(from *UserRoleEdges) *UserRoleEdgesPB { + if from == nil { + return nil + } + + to := &UserRoleEdgesPB{ + User: ConvertUserToUserPB(from.User), + Role: ConvertRoleToRolePB(from.Role), + } + return to +} + +// ConvertUserRolePBToUserRole converts UserRolePB to UserRole. +func ConvertUserRolePBToUserRole(from *UserRolePB) *UserRole { + if from == nil { + return nil + } + + to := &UserRole{ + ID: int(from.Id), + UserID: from.UserId, + RoleID: from.RoleId, + } + return to +} + +// ConvertUserRoleToUserRolePB converts UserRole to UserRolePB. +func ConvertUserRoleToUserRolePB(from *UserRole) *UserRolePB { + if from == nil { + return nil + } + + to := &UserRolePB{ + Id: int64(from.ID), + UserId: from.UserID, + RoleId: from.RoleID, + User: ConvertUserToUserPB(from.Edges.User), + Role: ConvertRoleToRolePB(from.Edges.Role), + } + return to +} + +// ConvertUserRolesPBToUserRoles converts a slice of *UserRolePB to a slice of *UserRole. +func ConvertUserRolesPBToUserRoles(froms UserRolesPB) UserRoles { + if froms == nil { + return nil + } + tos := make(UserRoles, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserRolePBToUserRole(f) + } + return tos +} + +// ConvertUserRolesToUserRolesPB converts a slice of *UserRole to a slice of *UserRolePB. +func ConvertUserRolesToUserRolesPB(froms UserRoles) UserRolesPB { + if froms == nil { + return nil + } + tos := make(UserRolesPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserRoleToUserRolePB(f) + } + return tos +} + +// ConvertUserToUserPB converts User to UserPB. +func ConvertUserToUserPB(from *User) *UserPB { + if from == nil { + return nil + } + + to := &UserPB{ + Id: from.ID, + CreateAuthor: from.CreateAuthor, + UpdateAuthor: from.UpdateAuthor, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Uuid: from.UUID, + AllowedIp: from.AllowedIP, + Username: from.Username, + Nickname: from.Nickname, + Avatar: from.Avatar, + Name: from.Name, + Gender: ConvertGenderToString(from.Gender), + Phone: from.Phone, + Email: from.Email, + Remark: from.Remark, + Token: from.Token, + Status: int32(from.Status), + LastLoginIp: from.LastLoginIP, + LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), + SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), + ManagerId: from.ManagerID, + Manager: from.Manager, + Roles: ConvertRolesToRolesPB(from.Edges.Roles), + } + return to +} + +// ConvertUsersPBToUsers converts a slice of *UserPB to a slice of *User. +func ConvertUsersPBToUsers(froms UsersPB) Users { + if froms == nil { + return nil + } + tos := make(Users, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPBToUser(f) + } + return tos +} + +// ConvertUsersToUsersPB converts a slice of *User to a slice of *UserPB. +func ConvertUsersToUsersPB(froms Users) UsersPB { + if froms == nil { + return nil + } + tos := make(UsersPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserToUserPB(f) + } + return tos +} + +// ConvertViewEdgesPBToViewEdges converts ViewEdgesPB to ViewEdges. +func ConvertViewEdgesPBToViewEdges(from *ViewEdgesPB) *ViewEdges { + if from == nil { + return nil + } + + to := &ViewEdges{ + Parent: ConvertViewPBToView(from.Parent), + Children: ConvertViewsPBToViews(from.Children), + Resources: ConvertResourcesPBToResources(from.Resources), + } + return to +} + +// ConvertViewEdgesToViewEdgesPB converts ViewEdges to ViewEdgesPB. +func ConvertViewEdgesToViewEdgesPB(from *ViewEdges) *ViewEdgesPB { + if from == nil { + return nil + } + + to := &ViewEdgesPB{ + Children: ConvertViewsToViewsPB(from.Children), + Parent: ConvertViewToViewPB(from.Parent), + Resources: ConvertResourcesToResourcesPB(from.Resources), + } + return to +} + +// ConvertViewPBToView converts ViewPB to View. +func ConvertViewPBToView(from *ViewPB) *View { + if from == nil { + return nil + } + + to := &View{ + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + ParentID: from.ParentId, + Keyword: from.Keyword, + Scope: from.Scope, + Name: from.Name, + Type: ConvertStringToType(from.Type), + Path: from.Path, + Icon: from.Icon, + Visible: from.Visible, + Sequence: int(from.Sequence), + TreePath: from.TreePath, + } + return to +} + +// ConvertViewToViewPB converts View to ViewPB. +func ConvertViewToViewPB(from *View) *ViewPB { + if from == nil { + return nil + } + + to := &ViewPB{ + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Scope: from.Scope, + Sequence: int32(from.Sequence), + Type: ConvertTypeToString(from.Type), + Icon: from.Icon, + Visible: from.Visible, + Path: from.Path, + TreePath: from.TreePath, + ParentId: from.ParentID, + Children: ConvertViewsToViewsPB(from.Edges.Children), + Parent: ConvertViewToViewPB(from.Edges.Parent), + Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), + } + return to +} + +// ConvertViewsPBToViews converts a slice of *ViewPB to a slice of *View. +func ConvertViewsPBToViews(froms ViewsPB) Views { + if froms == nil { + return nil + } + tos := make(Views, len(froms)) + for i, f := range froms { + tos[i] = ConvertViewPBToView(f) + } + return tos +} + +// ConvertViewsToViewsPB converts a slice of *View to a slice of *ViewPB. +func ConvertViewsToViewsPB(froms Views) ViewsPB { + if froms == nil { + return nil + } + tos := make(ViewsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertViewToViewPB(f) + } + return tos +} + +// --- Helper Functions --- + +func ConvertTimeToTimestamp(t time.Time) *timestamppb.Timestamp { + if t.IsZero() { + return nil + } + return timestamppb.New(t) +} +func ConvertTimestampToTime(ts *timestamppb.Timestamp) time.Time { + if ts == nil { + return time.Time{} + } + return ts.AsTime() +} diff --git a/internal/features/datastore/dto/dto.go b/internal/features/datastore/dto/dto.go index a2616597..c5cf75ad 100644 --- a/internal/features/datastore/dto/dto.go +++ b/internal/features/datastore/dto/dto.go @@ -9,1011 +9,35 @@ import ( "net/http" "github.com/origadmin/runtime/errors" - "google.golang.org/protobuf/types/known/timestamppb" + "origadmin/application/admin/internal/data/enums" typespb "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/internal/data/entity/ent" - "origadmin/application/admin/internal/data/entity/ent/schema/types" - "origadmin/application/admin/internal/data/entity/ent/user" ) +//go:generate abgen -debug . + +//go:abgen:package:path=origadmin/application/admin/internal/data/entity/ent,alias=ent +//go:abgen:package:path=origadmin/application/admin/api/v1/services/types,alias=types +//go:abgen:pair:packages="ent,types" +//go:abgen:convert:direction="both" +//go:abgen:convert:source:suffix="" +//go:abgen:convert:target:suffix="PB" + var ( // ErrUserNotFound is user not found. - ErrUserNotFound = errors.New(http.errors"http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), http.StatusNotFound, "user not found") - ErrInvalidCaptchaID = errors.New(http.errors"http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), http.StatusBadRequest, "invalid captcha id") - ErrInvalidPassword = errors.New(http.errors"http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), http.StatusBadRequest, "invalid password") - ErrInvalidUsername = errors.New(http.errors"http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), http.StatusBadRequest, "invalid username") - ErrCaptchaIDNotFound = errors.New(http.errors"http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), http.StatusBadRequest, "captcha id not found") + ErrUserNotFound = errors.New(http.StatusNotFound, "http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_USER_NOT_FOUND.String(), "user not found") + ErrInvalidCaptchaID = errors.New(http.StatusBadRequest, "http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_CAPTCHA_ID.String(), "invalid captcha id") + ErrInvalidPassword = errors.New(http.StatusBadRequest, "http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_PASSWORD.String(), "invalid password") + ErrInvalidUsername = errors.New(http.StatusBadRequest, "http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_INVALID_USERNAME.String(), "invalid username") + ErrCaptchaIDNotFound = errors.New(http.StatusBadRequest, "http.response.status."+typespb.SystemErrorReason_SYSTEM_ERROR_REASON_CAPTCHA_ID_NOT_FOUND.String(), "captcha id not found") ) const ( - UserStatusActive = types.Active - UserStatusFrozen = types.Frozen + UserStatusActive = enums.StatusActive + UserStatusFrozen = enums.StatusFrozen ) const ( - ResourceStatusEnabled = types.Enabled - ResourceStatusDisabled = types.Disabled -) - -type ( - // User 用户类型 - // @Convert( - // target = "UserPB", - // direction = "both", - // ignoreFields = ["password", "salt"] - // ) - User = ent.User - // UserPB - // @Convert( - // target="User", - // direction="both" - // ) - UserPB = typespb.User -) - -// ConvertUser2PB user.table.comment -func ConvertUser2PB(goModel *User) (pbModel *UserPB) { - pbModel = &UserPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.CreateAuthor = int64(goModel.CreateAuthor) - pbModel.UpdateAuthor = int64(goModel.UpdateAuthor) - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Uuid = goModel.UUID - pbModel.AllowedIp = goModel.AllowedIP - pbModel.Username = goModel.Username - pbModel.Nickname = goModel.Nickname - pbModel.Avatar = goModel.Avatar - pbModel.Name = goModel.Name - pbModel.Gender = ConvertGender2PB(goModel.Gender) - //pbModel.Password = goModel.EncryptedPassword - //pbModel.Salt = goModel.Salt - pbModel.Phone = goModel.Phone - pbModel.Email = goModel.Email - pbModel.Remark = goModel.Remark - pbModel.Token = goModel.Token - pbModel.Status = int32(goModel.Status) - pbModel.LastLoginIp = goModel.LastLoginIP - pbModel.LastLoginTime = timestamppb.New(goModel.LastLoginTime) - pbModel.SanctionDate = timestamppb.New(goModel.SanctionDate) - pbModel.ManagerId = int64(goModel.ManagerID) - pbModel.Manager = goModel.Manager - //pbModel.Roles = ConvertRoles(goModel.Edges.Roles) - for _, role := range goModel.Edges.Roles { - pbModel.RoleIds = append(pbModel.RoleIds, role.ID) - } - pbModel.Roles = ConvertRoles(goModel.Edges.Roles) - return pbModel -} - -func ConvertGender2PB(gender user.Gender) string { - return gender.String() -} - -// ConvertUserPB2Object user.table.comment -func ConvertUserPB2Object(pbModel *UserPB) (goModel *User) { - goModel = &User{} - if pbModel == nil { - return goModel - } - - goModel.ID = int64(pbModel.Id) - goModel.CreateAuthor = int64(pbModel.CreateAuthor) - goModel.UpdateAuthor = int64(pbModel.UpdateAuthor) - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.UUID = pbModel.Uuid - goModel.AllowedIP = pbModel.AllowedIp - goModel.Username = pbModel.Username - goModel.Nickname = pbModel.Nickname - goModel.Avatar = pbModel.Avatar - goModel.Name = pbModel.Name - goModel.Gender = user.Gender(pbModel.Gender) - //goModel.Password = pbModel.Password - //goModel.Salt = pbModel.Salt - goModel.Phone = pbModel.Phone - goModel.Email = pbModel.Email - goModel.Remark = pbModel.Remark - goModel.Token = pbModel.Token - goModel.Status = int8(pbModel.Status) - goModel.LastLoginIP = pbModel.LastLoginIp - goModel.LastLoginTime = pbModel.LastLoginTime.AsTime() - goModel.SanctionDate = pbModel.SanctionDate.AsTime() - goModel.ManagerID = pbModel.ManagerId - goModel.Manager = pbModel.Manager - return goModel -} - -type ( - Resource = ent.Resource - ResourcePB = typespb.Resource -) - -func ConvertResource2PB(goModel *Resource) (pbModel *ResourcePB) { - pbModel = &ResourcePB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = goModel.ID - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Name = goModel.Name - pbModel.Keyword = goModel.Keyword - pbModel.I18NKey = goModel.I18nKey - pbModel.Type = goModel.Type - pbModel.Status = int32(goModel.Status) - pbModel.Path = goModel.Path - pbModel.Operation = goModel.Operation - pbModel.Method = goModel.Method - pbModel.Component = goModel.Component - pbModel.Icon = goModel.Icon - pbModel.Sequence = int32(goModel.Sequence) - pbModel.Visible = goModel.Visible - pbModel.TreePath = goModel.TreePath - pbModel.Properties = goModel.Properties - pbModel.Description = goModel.Description - pbModel.ParentId = int64(goModel.ParentID) - return pbModel -} - -func ConvertResourcePB2Object(pbModel *ResourcePB) (goModel *Resource) { - goModel = &Resource{} - if pbModel == nil { - return goModel - } - - goModel.ID = pbModel.Id - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Name = pbModel.Name - goModel.Keyword = pbModel.Keyword - goModel.I18nKey = pbModel.I18NKey - goModel.Type = pbModel.Type - goModel.Status = int8(pbModel.Status) - goModel.Path = pbModel.Path - goModel.Operation = pbModel.Operation - goModel.Method = pbModel.Method - goModel.Component = pbModel.Component - goModel.Icon = pbModel.Icon - goModel.Sequence = int(pbModel.Sequence) - goModel.Visible = pbModel.Visible - goModel.TreePath = pbModel.TreePath - goModel.Properties = pbModel.Properties - goModel.Description = pbModel.Description - goModel.ParentID = pbModel.ParentId - return goModel -} - -type ( - Role = ent.Role - RolePB = typespb.Role -) - -// ConvertRole2PB role.table.comment -func ConvertRole2PB(goModel *Role) (pbModel *RolePB) { - pbModel = &RolePB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = goModel.ID - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Keyword = goModel.Keyword - pbModel.Name = goModel.Name - pbModel.Description = goModel.Description - pbModel.Type = int32(goModel.Type) - pbModel.Sequence = int32(goModel.Sequence) - pbModel.Status = int32(goModel.Status) - for _, permission := range goModel.Edges.Permissions { - pbModel.PermissionIds = append(pbModel.PermissionIds, int64(permission.ID)) - } - pbModel.Permissions = ConvertPermissions(goModel.Edges.Permissions) - //pbModel.IsSystem = goModel.IsSystem - return pbModel -} - -// ConvertRolePB2Object role.table.comment -func ConvertRolePB2Object(pbModel *RolePB) (goModel *Role) { - goModel = &Role{} - if pbModel == nil { - return goModel - } - - goModel.ID = pbModel.Id - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Keyword = pbModel.Keyword - goModel.Name = pbModel.Name - goModel.Description = pbModel.Description - goModel.Type = int8(pbModel.Type) - goModel.Sequence = int(pbModel.Sequence) - goModel.Status = int8(pbModel.Status) - - //goModel.IsSystem = pbModel.IsSystem - return goModel -} - -type ( - Department = ent.Department - DepartmentPB = typespb.Department -) - -// ConvertDepartment2PB department.table.comment -func ConvertDepartment2PB(goModel *Department) (pbModel *DepartmentPB) { - pbModel = &DepartmentPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = goModel.ID - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Keyword = goModel.Keyword - pbModel.Name = goModel.Name - pbModel.Description = goModel.Description - pbModel.Sequence = int32(goModel.Sequence) - pbModel.Status = int32(goModel.Status) - pbModel.Level = int32(goModel.Level) - pbModel.ParentId = goModel.ParentID - return pbModel -} - -// ConvertDepartmentPB2Object department.table.comment -func ConvertDepartmentPB2Object(pbModel *DepartmentPB) (goModel *Department) { - goModel = &Department{} - if pbModel == nil { - return goModel - } - - goModel.ID = pbModel.Id - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Keyword = pbModel.Keyword - goModel.Name = pbModel.Name - goModel.TreePath = pbModel.TreePath - goModel.Description = pbModel.Description - goModel.Sequence = int(pbModel.Sequence) - goModel.Status = int8(pbModel.Status) - goModel.Level = int(pbModel.Level) - goModel.ParentID = pbModel.ParentId - return goModel -} - -type ( - Departments = []*ent.Department - DepartmentsPB = []*typespb.Department -) - -// ConvertDepartments2PB Children holds the value of the children edge. -func ConvertDepartments2PB(gosModel Departments) (pbsModel DepartmentsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertDepartment2PB(model)) - } - return pbsModel -} - -// ConvertDepartmentsPB2Object Children holds the value of the children edge. -func ConvertDepartmentsPB2Object(pbsModel DepartmentsPB) (gosModel Departments) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertDepartmentPB2Object(model)) - } - return gosModel -} - -type ( - UserDepartments = []*ent.UserDepartment - UserDepartmentsPB = []*typespb.UserDepartment -) - -// ConvertUserDepartments2PB UserDepartments holds the value of the user_departments edge. -func ConvertUserDepartments2PB(gosModel UserDepartments) (pbsModel UserDepartmentsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertUserDepartment2PB(model)) - } - return pbsModel -} - -// ConvertUserDepartmentsPB2Object UserDepartments holds the value of the user_departments edge. -func ConvertUserDepartmentsPB2Object(pbsModel UserDepartmentsPB) (gosModel UserDepartments) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertUserDepartmentPB2Object(model)) - } - return gosModel -} - -type ( - DepartmentEdges = ent.DepartmentEdges - DepartmentEdgesPB = typespb.DepartmentEdges -) - -// ConvertDepartmentEdges2PB DepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertDepartmentEdges2PB(goModel *DepartmentEdges) (pbModel *DepartmentEdgesPB) { - pbModel = &DepartmentEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Users = ConvertUsers2PB(goModel.Users) - pbModel.Positions = ConvertPositions2PB(goModel.Positions) - pbModel.Children = ConvertDepartments2PB(goModel.Children) - pbModel.Parent = ConvertDepartment2PB(goModel.Parent) - pbModel.UserDepartments = ConvertUserDepartments2PB(goModel.UserDepartments) - return pbModel -} - -// ConvertDepartmentEdgesPB2Object DepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertDepartmentEdgesPB2Object(pbModel *DepartmentEdgesPB) (goModel *DepartmentEdges) { - goModel = &DepartmentEdges{} - if pbModel == nil { - return goModel - } - - goModel.Users = ConvertUsersPB2Object(pbModel.Users) - goModel.Positions = ConvertPositionsPB2Object(pbModel.Positions) - goModel.Children = ConvertDepartmentsPB2Object(pbModel.Children) - goModel.Parent = ConvertDepartmentPB2Object(pbModel.Parent) - goModel.UserDepartments = ConvertUserDepartmentsPB2Object(pbModel.UserDepartments) - return goModel -} - -type ( - UserDepartment = ent.UserDepartment - UserDepartmentPB = typespb.UserDepartment -) - -// ConvertUserDepartment2PB user_department.table.comment -func ConvertUserDepartment2PB(goModel *UserDepartment) (pbModel *UserDepartmentPB) { - pbModel = &UserDepartmentPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.UserId = int64(goModel.UserID) - pbModel.DepartmentId = int64(goModel.DepartmentID) - return pbModel -} - -// ConvertUserDepartmentPB2Object user_department.table.comment -func ConvertUserDepartmentPB2Object(pbModel *UserDepartmentPB) (goModel *UserDepartment) { - goModel = &UserDepartment{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.UserID = int64(pbModel.UserId) - goModel.DepartmentID = int64(pbModel.DepartmentId) - return goModel -} - -type ( - UserDepartmentEdges = ent.UserDepartmentEdges - UserDepartmentEdgesPB = typespb.UserDepartmentEdges -) - -// ConvertUserDepartmentEdges2PB UserDepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertUserDepartmentEdges2PB(goModel *UserDepartmentEdges) (pbModel *UserDepartmentEdgesPB) { - pbModel = &UserDepartmentEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.User = ConvertUser2PB(goModel.User) - pbModel.Department = ConvertDepartment2PB(goModel.Department) - return pbModel -} - -// ConvertUserDepartmentEdgesPB2Object UserDepartmentEdges holds the relations/edges for other nodes in the graph. -func ConvertUserDepartmentEdgesPB2Object(pbModel *UserDepartmentEdgesPB) (goModel *UserDepartmentEdges) { - goModel = &UserDepartmentEdges{} - if pbModel == nil { - return goModel - } - - goModel.User = ConvertUserPB2Object(pbModel.User) - goModel.Department = ConvertDepartmentPB2Object(pbModel.Department) - return goModel -} - -type ( - Position = ent.Position - PositionPB = typespb.Position -) - -// ConvertPosition2PB position.table.comment -func ConvertPosition2PB(goModel *Position) (pbModel *PositionPB) { - pbModel = &PositionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Name = goModel.Name - pbModel.Description = goModel.Description - pbModel.DepartmentId = int64(goModel.DepartmentID) - return pbModel -} - -// ConvertPositionPB2Object position.table.comment -func ConvertPositionPB2Object(pbModel *PositionPB) (goModel *Position) { - goModel = &Position{} - if pbModel == nil { - return goModel - } - - goModel.ID = int64(pbModel.Id) - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Name = pbModel.Name - goModel.Description = pbModel.Description - goModel.DepartmentID = int64(pbModel.DepartmentId) - return goModel -} - -type ( - Users = []*ent.User - UsersPB = []*typespb.User -) - -// ConvertUsers2PB Users holds the value of the users edge. -func ConvertUsers2PB(gosModel Users) (pbsModel UsersPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertUser2PB(model)) - } - return pbsModel -} - -// ConvertUsersPB2Object Users holds the value of the users edge. -func ConvertUsersPB2Object(pbsModel UsersPB) (gosModel Users) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertUserPB2Object(model)) - } - return gosModel -} - -type ( - Permissions = []*ent.Permission - PermissionsPB = []*typespb.Permission -) - -// ConvertPermissions2PB Permissions holds the value of the permissions edge. -func ConvertPermissions2PB(gosModel Permissions) (pbsModel PermissionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPermission2PB(model)) - } - return pbsModel -} - -// ConvertPermissionsPB2Object Permissions holds the value of the permissions edge. -func ConvertPermissionsPB2Object(pbsModel PermissionsPB) (gosModel Permissions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPermissionPB2Object(model)) - } - return gosModel -} - -type ( - UserPositions = []*ent.UserPosition - UserPositionsPB = []*typespb.UserPosition -) - -// ConvertUserPositions2PB UserPositions holds the value of the user_positions edge. -func ConvertUserPositions2PB(gosModel UserPositions) (pbsModel UserPositionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertUserPosition2PB(model)) - } - return pbsModel -} - -// ConvertUserPositionsPB2Object UserPositions holds the value of the user_positions edge. -func ConvertUserPositionsPB2Object(pbsModel UserPositionsPB) (gosModel UserPositions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertUserPositionPB2Object(model)) - } - return gosModel -} - -type ( - PositionEdges = ent.PositionEdges - PositionEdgesPB = typespb.PositionEdges -) - -// ConvertPositionEdges2PB PositionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionEdges2PB(goModel *PositionEdges) (pbModel *PositionEdgesPB) { - pbModel = &PositionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Department = ConvertDepartment2PB(goModel.Department) - pbModel.Users = ConvertUsers2PB(goModel.Users) - pbModel.Permissions = ConvertPermissions2PB(goModel.Permissions) - pbModel.UserPositions = ConvertUserPositions2PB(goModel.UserPositions) - pbModel.PositionPermissions = ConvertPositionPermissions2PB(goModel.PositionPermissions) - return pbModel -} - -// ConvertPositionEdgesPB2Object PositionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionEdgesPB2Object(pbModel *PositionEdgesPB) (goModel *PositionEdges) { - goModel = &PositionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Department = ConvertDepartmentPB2Object(pbModel.Department) - goModel.Users = ConvertUsersPB2Object(pbModel.Users) - goModel.Permissions = ConvertPermissionsPB2Object(pbModel.Permissions) - goModel.UserPositions = ConvertUserPositionsPB2Object(pbModel.UserPositions) - goModel.PositionPermissions = ConvertPositionPermissionsPB2Object(pbModel.PositionPermissions) - return goModel -} - -// ConvertDataRules2PB permission.field.data_rules -func ConvertDataRules2PB(gosModel map[string]string) map[string]string { - return gosModel -} - -// ConvertDataRulesPB2Object permission.field.data_rules -func ConvertDataRulesPB2Object(pbsModel map[string]string) map[string]string { - return pbsModel -} - -type ( - Permission = ent.Permission - PermissionPB = typespb.Permission + ResourceStatusEnabled = enums.StatusEnabled + ResourceStatusDisabled = enums.StatusDisabled ) - -// ConvertPermission2PB permission.table.comment -func ConvertPermission2PB(goModel *Permission) (pbModel *PermissionPB) { - pbModel = &PermissionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.CreateTime = timestamppb.New(goModel.CreateTime) - pbModel.UpdateTime = timestamppb.New(goModel.UpdateTime) - pbModel.Name = goModel.Name - pbModel.Keyword = goModel.Keyword - pbModel.Description = goModel.Description - pbModel.DataScope = goModel.DataScope - pbModel.DataRules = ConvertDataRules2PB(goModel.DataRules) - for _, resource := range goModel.Edges.Resources { - pbModel.ResourceIds = append(pbModel.ResourceIds, resource.ID) - } - pbModel.Resources = ConvertResources2PB(goModel.Edges.Resources) - return pbModel -} - -// ConvertPermissionPB2Object permission.table.comment -func ConvertPermissionPB2Object(pbModel *PermissionPB) (goModel *Permission) { - goModel = &Permission{} - if pbModel == nil { - return goModel - } - - goModel.ID = int64(pbModel.Id) - goModel.CreateTime = pbModel.CreateTime.AsTime() - goModel.UpdateTime = pbModel.UpdateTime.AsTime() - goModel.Name = pbModel.Name - goModel.Keyword = pbModel.Keyword - goModel.Description = pbModel.Description - goModel.DataScope = pbModel.DataScope - goModel.DataRules = ConvertDataRulesPB2Object(pbModel.DataRules) - return goModel -} - -type ( - Roles = []*ent.Role - RolesPB = []*typespb.Role -) - -// ConvertRoles2PB Roles holds the value of the roles edge. -func ConvertRoles2PB(gosModel Roles) (pbsModel RolesPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertRole2PB(model)) - } - return pbsModel -} - -// ConvertRolesPB2Object Roles holds the value of the roles edge. -func ConvertRolesPB2Object(pbsModel RolesPB) (gosModel Roles) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertRolePB2Object(model)) - } - return gosModel -} - -type ( - Resources = []*ent.Resource - ResourcesPB = []*typespb.Resource -) - -// ConvertResources2PB Resources holds the value of the resources edge. -func ConvertResources2PB(gosModel Resources) (pbsModel ResourcesPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertResource2PB(model)) - } - return pbsModel -} - -// ConvertResourcesPB2Object Resources holds the value of the resources edge. -func ConvertResourcesPB2Object(pbsModel ResourcesPB) (gosModel Resources) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertResourcePB2Object(model)) - } - return gosModel -} - -type ( - Positions = []*ent.Position - PositionsPB = []*typespb.Position -) - -// ConvertPositions2PB Positions holds the value of the positions edge. -func ConvertPositions2PB(gosModel Positions) (pbsModel PositionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPosition2PB(model)) - } - return pbsModel -} - -// ConvertPositionsPB2Object Positions holds the value of the positions edge. -func ConvertPositionsPB2Object(pbsModel PositionsPB) (gosModel Positions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPositionPB2Object(model)) - } - return gosModel -} - -type ( - RolePermissions = []*ent.RolePermission - RolePermissionsPB = []*typespb.RolePermission -) - -// ConvertRolePermissions2PB RolePermissions holds the value of the role_permissions edge. -func ConvertRolePermissions2PB(gosModel RolePermissions) (pbsModel RolePermissionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertRolePermission2PB(model)) - } - return pbsModel -} - -// ConvertRolePermissionsPB2Object RolePermissions holds the value of the role_permissions edge. -func ConvertRolePermissionsPB2Object(pbsModel RolePermissionsPB) (gosModel RolePermissions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertRolePermissionPB2Object(model)) - } - return gosModel -} - -type ( - PermissionResources = []*ent.PermissionResource - PermissionResourcesPB = []*typespb.PermissionResource -) - -// ConvertPermissionResources2PB PermissionResources holds the value of the permission_resources edge. -func ConvertPermissionResources2PB(gosModel PermissionResources) (pbsModel PermissionResourcesPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPermissionResource2PB(model)) - } - return pbsModel -} - -// ConvertPermissionResourcesPB2Object PermissionResources holds the value of the permission_resources edge. -func ConvertPermissionResourcesPB2Object(pbsModel PermissionResourcesPB) (gosModel PermissionResources) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPermissionResourcePB2Object(model)) - } - return gosModel -} - -type ( - PositionPermissions = []*ent.PositionPermission - PositionPermissionsPB = []*typespb.PositionPermission -) - -// ConvertPositionPermissions2PB PositionPermissions holds the value of the position_permissions edge. -func ConvertPositionPermissions2PB(gosModel PositionPermissions) (pbsModel PositionPermissionsPB) { - for _, model := range gosModel { - pbsModel = append(pbsModel, ConvertPositionPermission2PB(model)) - } - return pbsModel -} - -// ConvertPositionPermissionsPB2Object PositionPermissions holds the value of the position_permissions edge. -func ConvertPositionPermissionsPB2Object(pbsModel PositionPermissionsPB) (gosModel PositionPermissions) { - for _, model := range pbsModel { - gosModel = append(gosModel, ConvertPositionPermissionPB2Object(model)) - } - return gosModel -} - -type ( - PermissionEdges = ent.PermissionEdges - PermissionEdgesPB = typespb.PermissionEdges -) - -// ConvertPermissionEdges2PB PermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionEdges2PB(goModel *PermissionEdges) (pbModel *PermissionEdgesPB) { - pbModel = &PermissionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Roles = ConvertRoles2PB(goModel.Roles) - pbModel.Resources = ConvertResources2PB(goModel.Resources) - pbModel.Positions = ConvertPositions2PB(goModel.Positions) - pbModel.RolePermissions = ConvertRolePermissions2PB(goModel.RolePermissions) - pbModel.PermissionResources = ConvertPermissionResources2PB(goModel.PermissionResources) - pbModel.PositionPermissions = ConvertPositionPermissions2PB(goModel.PositionPermissions) - return pbModel -} - -// ConvertPermissionEdgesPB2Object PermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionEdgesPB2Object(pbModel *PermissionEdgesPB) (goModel *PermissionEdges) { - goModel = &PermissionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Roles = ConvertRolesPB2Object(pbModel.Roles) - goModel.Resources = ConvertResourcesPB2Object(pbModel.Resources) - goModel.Positions = ConvertPositionsPB2Object(pbModel.Positions) - goModel.RolePermissions = ConvertRolePermissionsPB2Object(pbModel.RolePermissions) - goModel.PermissionResources = ConvertPermissionResourcesPB2Object(pbModel.PermissionResources) - goModel.PositionPermissions = ConvertPositionPermissionsPB2Object(pbModel.PositionPermissions) - return goModel -} - -type ( - UserPosition = ent.UserPosition - UserPositionPB = typespb.UserPosition -) - -// ConvertUserPosition2PB user_position.table.comment -func ConvertUserPosition2PB(goModel *UserPosition) (pbModel *UserPositionPB) { - pbModel = &UserPositionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.UserId = int64(goModel.UserID) - pbModel.PositionId = int64(goModel.PositionID) - return pbModel -} - -// ConvertUserPositionPB2Object user_position.table.comment -func ConvertUserPositionPB2Object(pbModel *UserPositionPB) (goModel *UserPosition) { - goModel = &UserPosition{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.UserID = int64(pbModel.UserId) - goModel.PositionID = int64(pbModel.PositionId) - return goModel -} - -type ( - UserPositionEdges = ent.UserPositionEdges - UserPositionEdgesPB = typespb.UserPositionEdges -) - -// ConvertUserPositionEdges2PB UserPositionEdges holds the relations/edges for other nodes in the graph. -func ConvertUserPositionEdges2PB(goModel *UserPositionEdges) (pbModel *UserPositionEdgesPB) { - pbModel = &UserPositionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.User = ConvertUser2PB(goModel.User) - pbModel.Position = ConvertPosition2PB(goModel.Position) - return pbModel -} - -// ConvertUserPositionEdgesPB2Object UserPositionEdges holds the relations/edges for other nodes in the graph. -func ConvertUserPositionEdgesPB2Object(pbModel *UserPositionEdgesPB) (goModel *UserPositionEdges) { - goModel = &UserPositionEdges{} - if pbModel == nil { - return goModel - } - - goModel.User = ConvertUserPB2Object(pbModel.User) - goModel.Position = ConvertPositionPB2Object(pbModel.Position) - return goModel -} - -type ( - PositionPermission = ent.PositionPermission - PositionPermissionPB = typespb.PositionPermission -) - -// ConvertPositionPermission2PB position_permission.table.comment -func ConvertPositionPermission2PB(goModel *PositionPermission) (pbModel *PositionPermissionPB) { - pbModel = &PositionPermissionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.PositionId = int64(goModel.PositionID) - pbModel.PermissionId = int64(goModel.PermissionID) - return pbModel -} - -// ConvertPositionPermissionPB2Object position_permission.table.comment -func ConvertPositionPermissionPB2Object(pbModel *PositionPermissionPB) (goModel *PositionPermission) { - goModel = &PositionPermission{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.PositionID = int64(pbModel.PositionId) - goModel.PermissionID = int64(pbModel.PermissionId) - return goModel -} - -type ( - PositionPermissionEdges = ent.PositionPermissionEdges - PositionPermissionEdgesPB = typespb.PositionPermissionEdges -) - -// ConvertPositionPermissionEdges2PB PositionPermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionPermissionEdges2PB(goModel *PositionPermissionEdges) (pbModel *PositionPermissionEdgesPB) { - pbModel = &PositionPermissionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Position = ConvertPosition2PB(goModel.Position) - pbModel.Permission = ConvertPermission2PB(goModel.Permission) - return pbModel -} - -// ConvertPositionPermissionEdgesPB2Object PositionPermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertPositionPermissionEdgesPB2Object(pbModel *PositionPermissionEdgesPB) (goModel *PositionPermissionEdges) { - goModel = &PositionPermissionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Position = ConvertPositionPB2Object(pbModel.Position) - goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) - return goModel -} - -type ( - RolePermission = ent.RolePermission - RolePermissionPB = typespb.RolePermission -) - -// ConvertRolePermission2PB role_permission.table.comment -func ConvertRolePermission2PB(goModel *RolePermission) (pbModel *RolePermissionPB) { - pbModel = &RolePermissionPB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.RoleId = int64(goModel.RoleID) - pbModel.PermissionId = int64(goModel.PermissionID) - return pbModel -} - -// ConvertRolePermissionPB2Object role_permission.table.comment -func ConvertRolePermissionPB2Object(pbModel *RolePermissionPB) (goModel *RolePermission) { - goModel = &RolePermission{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.RoleID = int64(pbModel.RoleId) - goModel.PermissionID = int64(pbModel.PermissionId) - return goModel -} - -type ( - RolePermissionEdges = ent.RolePermissionEdges - RolePermissionEdgesPB = typespb.RolePermissionEdges -) - -// ConvertRolePermissionEdges2PB RolePermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertRolePermissionEdges2PB(goModel *RolePermissionEdges) (pbModel *RolePermissionEdgesPB) { - pbModel = &RolePermissionEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Role = ConvertRole2PB(goModel.Role) - pbModel.Permission = ConvertPermission2PB(goModel.Permission) - return pbModel -} - -// ConvertRolePermissionEdgesPB2Object RolePermissionEdges holds the relations/edges for other nodes in the graph. -func ConvertRolePermissionEdgesPB2Object(pbModel *RolePermissionEdgesPB) (goModel *RolePermissionEdges) { - goModel = &RolePermissionEdges{} - if pbModel == nil { - return goModel - } - - goModel.Role = ConvertRolePB2Object(pbModel.Role) - goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) - return goModel -} - -type ( - PermissionResource = ent.PermissionResource - PermissionResourcePB = typespb.PermissionResource -) - -// ConvertPermissionResource2PB permission_resource.table.comment -func ConvertPermissionResource2PB(goModel *PermissionResource) (pbModel *PermissionResourcePB) { - pbModel = &PermissionResourcePB{} - if goModel == nil { - return pbModel - } - - pbModel.Id = int64(goModel.ID) - pbModel.PermissionId = int64(goModel.PermissionID) - pbModel.ResourceId = int64(goModel.ResourceID) - //pbModel.Actions = goModel.Actions - return pbModel -} - -// ConvertPermissionResourcePB2Object permission_resource.table.comment -func ConvertPermissionResourcePB2Object(pbModel *PermissionResourcePB) (goModel *PermissionResource) { - goModel = &PermissionResource{} - if pbModel == nil { - return goModel - } - - //goModel.ID = int64(pbModel.Id) - goModel.PermissionID = int64(pbModel.PermissionId) - goModel.ResourceID = int64(pbModel.ResourceId) - //goModel.Actions = pbModel.Actions - return goModel -} - -type ( - PermissionResourceEdges = ent.PermissionResourceEdges - PermissionResourceEdgesPB = typespb.PermissionResourceEdges -) - -// ConvertPermissionResourceEdges2PB PermissionResourceEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionResourceEdges2PB(goModel *PermissionResourceEdges) (pbModel *PermissionResourceEdgesPB) { - pbModel = &PermissionResourceEdgesPB{} - if goModel == nil { - return pbModel - } - - pbModel.Permission = ConvertPermission2PB(goModel.Permission) - pbModel.Resource = ConvertResource2PB(goModel.Resource) - return pbModel -} - -// ConvertPermissionResourceEdgesPB2Object PermissionResourceEdges holds the relations/edges for other nodes in the graph. -func ConvertPermissionResourceEdgesPB2Object(pbModel *PermissionResourceEdgesPB) (goModel *PermissionResourceEdges) { - goModel = &PermissionResourceEdges{} - if pbModel == nil { - return goModel - } - - goModel.Permission = ConvertPermissionPB2Object(pbModel.Permission) - goModel.Resource = ConvertResourcePB2Object(pbModel.Resource) - return goModel -} diff --git a/internal/features/datastore/dto/menu.go b/internal/features/datastore/dto/menu.go deleted file mode 100644 index 0598d713..00000000 --- a/internal/features/datastore/dto/menu.go +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the system module. -package dto - -import ( - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/system" -) - -type ( - ListMenusRequest = pb.ListMenusRequest - ListMenusResponse = pb.ListMenusResponse -) - -// MenuRepo is a Menu repository interface. -type MenuRepo interface { - //Get(context.Context, int64, ...MenuQueryOption) (*MenuPB, error) - //Create(context.Context, *MenuPB, ...MenuQueryOption) (*MenuPB, error) - //Delete(context.Context, int64) error - //Update(context.Context, *MenuPB, ...MenuQueryOption) (*MenuPB, error) - //List(context.Context, *ListMenusRequest, ...MenuQueryOption) ([]*MenuPB, int32, error) -} - -type MenuQueryOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - InIDs []int64 `form:"-" json:"-"` - UserID int64 `form:"-" json:"-"` // UserPB ID - RoleID int64 `form:"-" json:"-"` // RolePB ID - ParentID int64 `form:"-" json:"-"` // Parent ID - ParentPathPrefix string `form:"-" json:"-"` - IncludeResources bool `form:"-" json:"-"` // Include resources - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string -} - -func (o MenuQueryOption) FromListRequest(in *ListMenusRequest, limiter repo.PageLimiter) error { - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func (o MenuQueryOption) FromGetRequest(in *pb.GetMenuRequest, limiter repo.PageLimiter) error { - return nil -} - -func (o MenuQueryOption) FromCreateRequest(in *pb.CreateMenuRequest, limiter repo.PageLimiter) error { - return nil -} - -// -//func ToListMenusResponse(result []*MenuPB, in *ListMenusRequest, total int32, args ...any) (*ListMenusResponse, error) { -// response := &ListMenusResponse{ -// TotalSize: total, -// Current: in.Current, -// PageSize: in.PageSize, -// Menus: result, -// Extra: resp.Any(args...), -// } -// return response, nil -//} -// -//func ConvertMenus(menus []*Menu) []*MenuPB { -// var result []*MenuPB -// for _, menu := range menus { -// result = append(result, ConvertMenu2PB(menu)) -// } -// return result -//} diff --git a/internal/features/datastore/dto/permission.go b/internal/features/datastore/dto/permission.go deleted file mode 100644 index a2f33a92..00000000 --- a/internal/features/datastore/dto/permission.go +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the system module. -package dto - -import ( - "context" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/resp" -) - -type ( - ListPermissionsRequest = pb.ListPermissionsRequest - ListPermissionsResponse = pb.ListPermissionsResponse -) - -type PermissionNode struct { - PermissionPB - ResourceKeywords []string `json:"resource_keywords"` -} - -// PermissionRepo is a Permission repository interface. -type PermissionRepo interface { - Get(context.Context, int64, ...PermissionQueryOption) (*PermissionPB, error) - Create(context.Context, *PermissionPB, ...PermissionQueryOption) (*PermissionPB, error) - Delete(context.Context, int64) error - Update(context.Context, *PermissionPB, ...PermissionQueryOption) (*PermissionPB, error) - List(context.Context, *ListPermissionsRequest, ...PermissionQueryOption) ([]*PermissionPB, int32, error) -} - -type PermissionQueryOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - InIDs []string `form:"-" json:"-"` - UserID string `form:"-" json:"-"` // UserPB ID - RoleID string `form:"-" json:"-"` // RolePB ID - ParentID string `form:"-" json:"-"` // Parent ID - ParentPathPrefix string `form:"-" json:"-"` - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string - IncludeResources bool - IncludeRoles bool -} - -func (o PermissionQueryOption) FromListRequest(in *ListPermissionsRequest, limiter repo.PageLimiter) error { - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func (o PermissionQueryOption) FromGetRequest(in *pb.GetPermissionRequest, limiter repo.PageLimiter) error { - return nil -} - -func (o PermissionQueryOption) FromCreateRequest(in *pb.CreatePermissionRequest, limiter repo.PageLimiter) error { - return nil -} - -func ToListPermissionsResponse(result []*PermissionPB, in *ListPermissionsRequest, total int32, args ...any) (*ListPermissionsResponse, error) { - response := &ListPermissionsResponse{ - TotalSize: total, - Current: in.Current, - PageSize: in.PageSize, - Permissions: result, - Extra: resp.Any(args...), - } - return response, nil -} - -func ConvertPermissions(permissions []*Permission) []*PermissionPB { - var result []*PermissionPB - for _, permission := range permissions { - result = append(result, ConvertPermission2PB(permission)) - } - return result -} diff --git a/internal/features/datastore/dto/position.go b/internal/features/datastore/dto/position.go deleted file mode 100644 index 6d294141..00000000 --- a/internal/features/datastore/dto/position.go +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto implements the functions, types, and interfaces for the module. -package dto - -// PositionNode position.table.comment -type PositionNode struct { - PositionPB - DepartmentKeyword string `json:"department_keyword,omitempty"` -} diff --git a/internal/features/datastore/dto/resource.go b/internal/features/datastore/dto/resource.go deleted file mode 100644 index 9c082d97..00000000 --- a/internal/features/datastore/dto/resource.go +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the system module. -package dto - -import ( - "context" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/helpers/resp" -) - -type ( - ListResourcesRequest = pb.ListResourcesRequest - ListResourcesResponse = pb.ListResourcesResponse -) - -type ResourceNode struct { - ResourcePB - Children []*ResourceNode `json:"children"` -} - -// ResourceRepo is a Resource repository interface. -type ResourceRepo interface { - Get(context.Context, int64, ...ResourceQueryOption) (*ResourcePB, error) - Create(context.Context, *ResourcePB, ...ResourceQueryOption) (*ResourcePB, error) - Delete(context.Context, int64) error - Update(context.Context, *ResourcePB, ...ResourceQueryOption) (*ResourcePB, error) - List(context.Context, *ListResourcesRequest, ...ResourceQueryOption) ([]*ResourcePB, int32, error) -} - -type ResourceQueryOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - InIDs []string `form:"-" json:"-"` - UserID string `form:"-" json:"-"` // UserPB ID - RoleID string `form:"-" json:"-"` // RolePB ID - ParentID string `form:"-" json:"-"` // Parent ID - ParentPathPrefix string `form:"-" json:"-"` - IncludeResources bool `form:"-" json:"-"` // Include resources - IncludePermissions bool `form:"-" json:"-"` - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string -} - -func (o ResourceQueryOption) FromListRequest(in *ListResourcesRequest, limiter repo.PageLimiter) error { - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func (o ResourceQueryOption) FromGetRequest(in *pb.GetResourceRequest, limiter repo.PageLimiter) error { - return nil -} - -func (o ResourceQueryOption) FromCreateRequest(in *pb.CreateResourceRequest, limiter repo.PageLimiter) error { - return nil -} - -func ToListResourcesResponse(result []*ResourcePB, in *ListResourcesRequest, total int32, args ...any) (*ListResourcesResponse, error) { - response := &ListResourcesResponse{ - TotalSize: total, - Current: in.Current, - PageSize: in.PageSize, - Resources: result, - Extra: resp.Any(args...), - } - return response, nil -} - -func ConvertResources(resources []*Resource) []*ResourcePB { - var result []*ResourcePB - for _, resource := range resources { - result = append(result, ConvertResource2PB(resource)) - } - return result -} diff --git a/internal/features/datastore/dto/resource_type.go b/internal/features/datastore/dto/resource_type.go deleted file mode 100644 index f3b265fa..00000000 --- a/internal/features/datastore/dto/resource_type.go +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto implements the functions, types, and interfaces for the module. -package dto - -import ( - "origadmin/application/admin/internal/data/entity/ent/schema" -) - -const ( - ResourceTypeRoot = schema.ResourceTypeRoot - ResourceTypeGroup = schema.ResourceTypeGroup - ResourceTypeMenu = schema.ResourceTypeMenu - ResourceTypePage = schema.ResourceTypePage - ResourceTypeButton = schema.ResourceTypeButton - ResourceTypeAPI = schema.ResourceTypeAPI - ResourceTypeRedirect = schema.ResourceTypeRedirect - ResourceTypeUnknown = schema.ResourceTypeUnknown -) - -// ResourceTypeName returns the name of the resource type -func ResourceTypeName(str string) string { - switch str { - case ResourceTypeMenu: - return "Menu" - case ResourceTypePage: - return "Page" - case ResourceTypeButton: - return "Button" - case ResourceTypeAPI: - return "API" - case ResourceTypeRedirect: - return "Redirect" - case ResourceTypeRoot: - return "ROOT" - case ResourceTypeGroup: - return "Group" - default: - return "Unknown" - } -} - -// ResourceTypeCode returns the code of the resource type -func ResourceTypeCode(s string) string { - switch s { - case "Menu": - return ResourceTypeMenu - case "Page": - return ResourceTypePage - case "Button": - return ResourceTypeButton - case "API": - return ResourceTypeAPI - case "Redirect": - return ResourceTypeRedirect - case "ROOT": - return ResourceTypeRoot - case "Group": - return ResourceTypeGroup - default: - return ResourceTypeUnknown - } -} diff --git a/internal/features/datastore/dto/role.go b/internal/features/datastore/dto/role.go deleted file mode 100644 index 0c8de645..00000000 --- a/internal/features/datastore/dto/role.go +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the system module. -package dto - -import ( - "context" - "time" - - "origadmin/application/admin/internal/helpers/pagination" - "google.golang.org/protobuf/proto" - - pb "origadmin/application/admin/api/v1/services/system" - typespb "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/helpers/resp" - "origadmin/application/admin/internal/data/entity/ent" -) - -type ( - RoleEdges = ent.RoleEdges - RoleEdgesPB = typespb.RoleEdges - - ListRolesRequest = pb.ListRolesRequest - ListRolesResponse = pb.ListRolesResponse -) - -// RoleRepo is a RolePB repository interface. -type RoleRepo interface { - Get(context.Context, int64, ...RoleQueryOption) (*RolePB, error) - List(context.Context, *ListRolesRequest, ...RoleQueryOption) ([]*RolePB, int32, error) - Create(context.Context, *RolePB, ...RoleUpdateOption) (*RolePB, error) - Update(context.Context, *RolePB, ...RoleUpdateOption) (*RolePB, error) - Delete(context.Context, int64) error -} - -type RoleQueryOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - InIDs []int64 `form:"-" json:"-"` - UpdateTimeGT *time.Time - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string - IncludePermissions bool -} - -func (o RoleQueryOption) FromListRequest(in *ListRolesRequest, limiter repo.PageLimiter) error { - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func (o RoleQueryOption) FromGetRequest(in *pb.GetRoleRequest, limiter repo.PageLimiter) error { - return nil -} - -func (o RoleQueryOption) FromCreateRequest(in *pb.CreateRoleRequest, limiter repo.PageLimiter) error { - return nil -} - -// RoleUpdateOption is used for creating and updating roles. -type RoleUpdateOption struct { - Name string `form:"name" json:"name,omitempty"` - Status int8 `form:"status" json:"status,omitempty"` - UpdateTimeGT *time.Time - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string - IncludePermissions bool -} - -func (o RoleUpdateOption) FromCreateRequest(in *pb.CreateRoleRequest) error { - return nil -} - -func (o RoleUpdateOption) FromUpdateRequest(in *pb.UpdateRoleRequest) error { - return nil -} - -func ToListRolesResponse(result []*RolePB, in *ListRolesRequest, total int32, args ...any) (*ListRolesResponse, error) { - response := &ListRolesResponse{ - TotalSize: total, - Current: in.Current, - PageSize: in.PageSize, - Roles: result, - Extra: resp.Any(args...), - } - return response, nil -} - -func ConvertRoles(roles []*Role) []*RolePB { - var result []*RolePB - for _, role := range roles { - result = append(result, ConvertRole2PB(role)) - } - return result -} - -type RoleQueryResult struct { - Current int `json:"current"` - PageSize int `json:"page_size"` - Data []*RolePB `json:"data"` - Total int64 `json:"total"` - Args map[string]proto.Message `json:"args"` -} diff --git a/internal/features/datastore/dto/user.go b/internal/features/datastore/dto/user.go deleted file mode 100644 index d1d99300..00000000 --- a/internal/features/datastore/dto/user.go +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package dto is the data transfer object package for the system module. -package dto - -import ( - "context" - - "github.com/google/uuid" - "github.com/origadmin/runtime/log" - "github.com/origadmin/toolkits/crypto/hash" - "github.com/origadmin/toolkits/crypto/rand" - - "origadmin/application/admin/internal/helpers/pagination" - - pb "origadmin/application/admin/api/v1/services/system" - typespb "origadmin/application/admin/api/v1/services/types" - "origadmin/application/admin/helpers/id" - "origadmin/application/admin/helpers/resp" - "origadmin/application/admin/internal/data/entity/ent" -) - -type ( - UserRole = ent.UserRole - UserRolePB = typespb.UserRole - UserRoleEdges = ent.UserRoleEdges - UserRoleEdgesPB = typespb.UserRoleEdges - - ListUsersRequest = pb.ListUsersRequest - ListUsersResponse = pb.ListUsersResponse -) - -type UserNode struct { - UserPB - IsSystem bool `json:"is_system"` - RoleKeywords []string `json:"role_keywords"` - EncryptedPassword string `json:"encrypted_password"` -} - -// UserRepo is a UserPB repository interface. -type UserRepo interface { - Get(context.Context, int64, ...UserQueryOption) (*UserPB, error) - Create(context.Context, *UserPB, ...UserMutationOption) (*UserPB, error) - Delete(context.Context, int64) error - Update(context.Context, *UserPB, ...UserMutationOption) (*UserPB, error) - List(context.Context, *ListUsersRequest, ...UserQueryOption) ([]*UserPB, int32, error) - AddRoleIDs(context.Context, int64, []int64, ...UserMutationOption) error - GetByUsername(context.Context, string, ...string) (*UserNode, error) - GetRoleIDs(context.Context, int64) ([]int64, error) - ListResourceByUserID(context.Context, int64, ...UserQueryOption) ([]*ResourcePB, error) - Current(context.Context, int64) (*UserPB, error) - UpdateUserStatus(ctx context.Context, id int64, status int8, options ...UserQueryOption) error -} - -type UserMutationOption struct { - RandomPasswd bool - NoPasswd bool - Fields []string -} - -type UserQueryOption struct { - IncludeRoles bool - IsSystem bool - NoPasswd bool - RandomPasswd bool - Status int8 `form:"status" json:"status,omitempty"` - SelectFields []string - OmitFields []string - OrderFields []string - Fields []string -} - -func (o *UserQueryOption) FromListRequest(in *ListUsersRequest, limiter repo.PageLimiter) error { - in.Current = limiter.Current(in.Current) - in.PageSize = limiter.PerPage(in.PageSize) - return nil -} - -func (o *UserQueryOption) FromGetRequest(in *pb.GetUserRequest, limiter repo.PageLimiter) error { - return nil -} - -func (o *UserMutationOption) FromCreateRequest(in *pb.CreateUserRequest, limiter repo.PageLimiter) error { - o.RandomPasswd = in.RandomPassword - return nil -} - -func ToListUsersResponse(result []*UserPB, in *ListUsersRequest, total int32, args ...any) (*ListUsersResponse, error) { - response := &ListUsersResponse{ - TotalSize: total, - Current: in.Current, - PageSize: in.PageSize, - Users: result, - Extra: resp.Any(args...), - } - - return response, nil -} - -func ConvertUsers(users []*User) []*UserPB { - var result []*UserPB - for _, user := range users { - result = append(result, ConvertUser2PB(user)) - } - return result -} - -// MakeCreateUser functions are used to create new users -func MakeCreateUser(user *UserPB, username, password string, option UserMutationOption) (*UserPB, string, error) { - log.Debugf("Creating user with options: %+v", option) - if !option.NoPasswd { - log.Debugf("NoPasswd is false, checking for RandomPasswd") - if option.RandomPasswd && (user.Email != "" || user.Phone != "") { - log.Debugf("RandomPasswd is true and user has email or phone, generating random password") - password = rand.GenerateRandom(8) - log.Debugf("Generated random password: %s", password) - } else { - log.Debugf("RandomPasswd is false or user has no email or phone") - } - } else { - log.Debugf("NoPasswd is true, setting password to empty string") - password = "" - } - var err error - if password != "" { - log.Debugf("Password is not empty, generating salt") - //user.Salt = rand.GenerateSalt() - //log.Debugf("Generated salt: %s", user.Salt) - user.Password, err = hash.Generate(password) - if err != nil { - log.Errorf("Error generating password hash: %v", err) - return nil, "", err - } - log.Debugf("Generated password hash: %s", user.Password) - } - registerID := id.Gen() - user.Id = registerID - user.Uuid = uuid.Must(uuid.NewRandom()).String() - user.Username = username - user.Name = "user_" + random.RandString(8) - user.Status = 1 - return user, password, nil -} - -var random = rand.NewRand(rand.KindDigit | rand.KindLowerCase | rand.KindUpperCase) diff --git a/internal/features/datastore/server/gins.go b/internal/features/datastore/server/gins.go deleted file mode 100644 index 26373997..00000000 --- a/internal/features/datastore/server/gins.go +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "net/url" - - "github.com/origadmin/contrib/transport/gins" - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/log" - "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/service" - "github.com/origadmin/toolkits/env" - "github.com/origadmin/toolkits/net" - - "origadmin/application/admin/internal/configs" -) - -// NewGINSServer new a gin server. -func NewGINSServer(bootstrap *configs.Bootstrap, l log.KLogger, ss ...service.ServerOption) *gins.Server { - ms := middleware.NewServer(bootstrap.GetMiddleware()) - //option := settings.ApplyOrZero(ss...) - var opts = []gins.ServerOption{ - gins.Middleware(ms...), - } - //serviceConfig := bootstrap.GetService() - //cfg := serviceConfig.GetGins() - //if cfg == nil { - // return nil - //} - // - //if cfg.Network != "" { - // opts = append(opts, gins.Network(cfg.Network)) - //} - //if cfg.Addr != "" { - // opts = append(opts, gins.Address(cfg.Addr)) - //} - //if cfg.Timeout != nil { - // opts = append(opts, gins.Timeout(cfg.Timeout.AsDuration())) - //} - - //middlewares, err := bootstrap.LoadMiddlewares(bootstrap.GetServiceName(), bootstrap, l) - //if err == nil && len(middlewares) > 0 { - // opts = append(opts, http.Middleware(middlewares...)) - //} - - if l != nil { - opts = append(opts, gins.WithLogger(log.With(l, "module", "gins"))) - } - log.Infof("GetHostName: %s", env.Var(runtime.DefaultEnvPrefix, "host")) - hostVar := env.Var(runtime.DefaultEnvPrefix, "host") - hostIP := env.GetEnv(env.Var(runtime.DefaultEnvPrefix, "host_ip")) - if hostIP == "" { - log.Debugf("HostIP is empty, replacing with HostAddr: %s", hostVar) - hostIP = net.HostAddr(net.WithEnvVar(hostVar)) - log.Debugf("HostIP after replacement: %s", hostIP) - } - - var endpoint string - log.Debugf("GINS.Endpoint: %v", endpoint) - ep, _ := url.Parse(endpoint) - opts = append(opts, gins.Endpoint(ep)) - srv := gins.NewServer(opts...) - return srv -} diff --git a/internal/features/datastore/server/grpc.go b/internal/features/datastore/server/grpc.go deleted file mode 100644 index 43cb5ac0..00000000 --- a/internal/features/datastore/server/grpc.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/service" - - "origadmin/application/admin/internal/configs" -) - -// NewGRPCServer new a gRPC server. -func NewGRPCServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.GRPCServer { - services := bootstrap.GetServer().GetServices() - for _, serviceConfig := range services { - if serviceConfig.GetType() == "grpc" { - grpcServer, err := r.Builder().NewGRPCServer(serviceConfig) - if err != nil { - return nil - } - return grpcServer - } - } - return nil -} diff --git a/internal/features/datastore/server/http.go b/internal/features/datastore/server/http.go deleted file mode 100644 index f1be2682..00000000 --- a/internal/features/datastore/server/http.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -package server - -import ( - "github.com/origadmin/runtime" - "github.com/origadmin/runtime/service" - - "origadmin/application/admin/internal/configs" -) - -// NewHTTPServer new an HTTP server. -func NewHTTPServer(r runtime.Runtime, bootstrap *configs.Bootstrap) *service.HTTPServer { - services := bootstrap.GetServer().GetServices() - for _, serviceConfig := range services { - if serviceConfig.GetType() == "http" { - httpServer, err := r.Builder().NewHTTPServer(serviceConfig) - if err != nil { - return nil - } - return httpServer - } - } - return nil -} diff --git a/internal/features/datastore/server/server.go b/internal/features/datastore/server/server.go index 2c0a8a6e..3b26473d 100644 --- a/internal/features/datastore/server/server.go +++ b/internal/features/datastore/server/server.go @@ -6,20 +6,15 @@ package server import ( "github.com/go-kratos/kratos/v2/metadata" - "github.com/go-kratos/kratos/v2/transport" "github.com/google/wire" "github.com/origadmin/runtime" - configv1 "github.com/origadmin/runtime/api/gen/go/config/v1" "github.com/origadmin/runtime/context" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/middleware" - "github.com/origadmin/runtime/service" - servicegrpc "github.com/origadmin/runtime/service/grpc" - servicehttp "github.com/origadmin/runtime/service/http" + "github.com/origadmin/runtime/service/transport" + configs "github.com/origadmin/runtime/test/integration/app/proto" "github.com/origadmin/toolkits/errors" - - "origadmin/application/admin/internal/configs" - systemservice "origadmin/application/admin/internal/features/system/service" // Corrected import path + systemservice "origadmin/application/admin/internal/features/system/service" ) const ( @@ -36,62 +31,17 @@ var ( ) func init() { - runtime.RegisterService(ServiceName, service.DefaultServiceFactory) } -func NewSystemServer(r runtime.Runtime, bootstrap *configs.Bootstrap, svc systemservice.SystemServerRegistrar) []transport. +func NewSystemServer(app *runtime.App, bootstrap *configs.Bootstrap, + svc systemservice.SystemService) []transport. Server { var servers []transport.Server - serverConfig := bootstrap.GetServer() - if serverConfig == nil { - return servers - } - ll := log.NewHelper(r.WithLogger("module", "system/server")) - middlewares := r.Builder().Middleware().BuildServer(bootstrap.GetServer().GetMiddleware()) - services := bootstrap.GetServer().GetServices() - coreinfo := bootstrap.GetServer().GetCore() - for _, serviceConfig := range services { - ll.Infow("msg", "service init", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) - var option service.ServerOption - switch serviceConfig.GetType() { - case "grpc": - options := []servicegrpc.Option{ - servicegrpc.WithMiddlewares(middlewares...), - servicegrpc.WithPrefix(runtime.DefaultEnvPrefix), - } - option = service.WithGRPC(options...) - case "http": - options := []servicehttp.Option{ - servicehttp.WithMiddlewares(middlewares...), - servicehttp.WithPrefix(runtime.DefaultEnvPrefix), - } - //httpServer, err := r.Builder().NewServer(serviceConfig, options...) - //if err != nil { - // continue - //} - //ll.Infow("msg", "http server init", "name", coreinfo.GetName(), "version", - // coreinfo.GetVersion()) - //svc.Register(r.Context(), httpServer) - //servers = append(servers, httpServer) - option = service.WithHTTP(options...) - default: - ll.Warnw("msg", "service type not support", "name", serviceConfig.GetName(), "type", serviceConfig.GetType()) - continue - } - grpcServer, err := r.Builder().NewServer("system", serviceConfig, option) - if err != nil { - continue - } - ll.Infow("msg", "system server init", "name", coreinfo.GetName(), "version", - coreinfo.GetVersion()) - svc.Register(r.Context(), grpcServer) - servers = append(servers, grpcServer) - } return servers } -func NewSystemClient(r runtime.Runtime, bootstrap *configs.Bootstrap) (*service.GRPCClient, error) { +func NewSystemClient(app *runtime.App, bootstrap *configs.Bootstrap) (*transport.GRPCClient, error) { discovery := bootstrap.GetDiscovery() if discovery == nil { return nil, errors.New("no discovery") diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index 8589ae0a..4f2191c9 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -19,10 +19,20 @@ import ( ) // ProviderSet is client providers. -var ProviderSet = wire.NewSet(NewAuthClient, NewSystemClient, NewSystemClientSet) +var ProviderSet = wire.NewSet( + NewAuthClient, + NewSystemClient, + NewAuthClientSet, + NewSystemClientSet, +) + +// AuthClientSet holds all the clients for the 'auth' service. +type AuthClientSet struct { + AuthClient auth.AuthServiceClient + MeClient auth.MeServiceClient +} // SystemClientSet holds all the clients for the 'system' service. -// This avoids creating multiple connections to the same downstream service. type SystemClientSet struct { UserClient system.UserServiceClient RoleClient system.RoleServiceClient @@ -31,8 +41,8 @@ type SystemClientSet struct { ViewClient system.ViewServiceClient } -// newGRPCConn is a private helper to create a gRPC connection from config. -func newGRPCConn(bootstrap *conf.Config, clientName string) (*grpc.ClientConn, error) { +// NewGRPCConn is a helper to create a gRPC connection from config by name. +func NewGRPCConn(bootstrap *conf.Config, clientName string) (*grpc.ClientConn, error) { var clientConfig *transportv1.Client if bootstrap.Bootstrap.Clients != nil { for _, cli := range bootstrap.Bootstrap.Clients.Configs { @@ -55,19 +65,21 @@ func newGRPCConn(bootstrap *conf.Config, clientName string) (*grpc.ClientConn, e return runtimegrpc.NewClient(context.Background(), grpcConfig, &runtimegrpc.ClientOptions{}) } -// NewAuthClient creates a new AuthAPI client. -func NewAuthClient(bootstrap *conf.Config) (auth.AuthServiceClient, error) { - conn, err := newGRPCConn(bootstrap, "client.auth") +// NewAuthClientSet creates a set of clients for the auth service. +func NewAuthClientSet(bootstrap *conf.Config) (*AuthClientSet, error) { + conn, err := NewGRPCConn(bootstrap, "client.auth") if err != nil { return nil, err } - return auth.NewAuthServiceClient(conn), nil + return &AuthClientSet{ + AuthClient: auth.NewAuthServiceClient(conn), + MeClient: auth.NewMeServiceClient(conn), + }, nil } // NewSystemClientSet creates a set of clients for the system service. -// It establishes a single gRPC connection and initializes all related clients. func NewSystemClientSet(bootstrap *conf.Config) (*SystemClientSet, error) { - conn, err := newGRPCConn(bootstrap, "client.system") + conn, err := NewGRPCConn(bootstrap, "client.system") if err != nil { return nil, err } @@ -80,10 +92,20 @@ func NewSystemClientSet(bootstrap *conf.Config) (*SystemClientSet, error) { }, nil } +// NewAuthClient creates a new AuthAPI client. +// Deprecated: Use NewAuthClientSet instead. +func NewAuthClient(bootstrap *conf.Config) (auth.AuthServiceClient, error) { + conn, err := NewGRPCConn(bootstrap, "client.auth") + if err != nil { + return nil, err + } + return auth.NewAuthServiceClient(conn), nil +} + // NewSystemClient creates a new SystemAPI client. -// Deprecated: Use NewSystemClientSet instead to access all clients for the system service. +// Deprecated: Use NewSystemClientSet instead. func NewSystemClient(bootstrap *conf.Config) (system.UserServiceClient, error) { - conn, err := newGRPCConn(bootstrap, "client.system") + conn, err := NewGRPCConn(bootstrap, "client.system") if err != nil { return nil, err } diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index d86abf64..c2c86936 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -5,6 +5,7 @@ package server import ( + "context" "errors" "github.com/go-kratos/kratos/v2/log" @@ -15,7 +16,11 @@ import ( transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" "github.com/origadmin/runtime/service/transport" "github.com/origadmin/runtime/service/transport/http" + "origadmin/application/admin/api/v1/services/auth" gatewayAPI "origadmin/application/admin/api/v1/services/gateway" + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/conf" + "origadmin/application/admin/internal/gateway/client" "origadmin/application/admin/internal/gateway/service" ) @@ -23,9 +28,12 @@ import ( var ProviderSet = wire.NewSet(NewServers) // NewServers creates and configures the gateway service servers (HTTP). -func NewServers(app *runtime.App, serversCfg *transportv1.Servers, - svc *service.GatewayService) ([]transport.Server, - error) { +func NewServers( + app *runtime.App, + serversCfg *transportv1.Servers, + appCfg *conf.Config, + svc *service.GatewayService, +) ([]transport.Server, error) { if serversCfg == nil { return nil, errors.New("servers config is nil") } @@ -39,14 +47,13 @@ func NewServers(app *runtime.App, serversCfg *transportv1.Servers, switch serverCfg.GetProtocol() { case "http": - srv, err := NewHTTPServer(app, serverCfg.GetHttp(), svc) + srv, err := NewHTTPServer(app, serverCfg.GetHttp(), appCfg, svc) if err != nil { return nil, err } transportServers = append(transportServers, srv) default: - log.NewHelper(app.Logger()).Warn("protocol", serverCfg.GetProtocol(), "msg", - "protocol is not supported") + log.NewHelper(app.Logger()).Warn("protocol", serverCfg.GetProtocol(), "msg", "protocol is not supported") } } @@ -57,11 +64,31 @@ func NewServers(app *runtime.App, serversCfg *transportv1.Servers, return transportServers, nil } -// NewHTTPServer new an HTTP server. -func NewHTTPServer(app *runtime.App, cfg *httpv1.Server, svc *service.GatewayService) (transport.Server, error) { +// NewHTTPServer creates a new HTTP server and registers all downstream service handlers. +func NewHTTPServer( + app *runtime.App, + cfg *httpv1.Server, + appCfg *conf.Config, + svc *service.GatewayService, +) (transport.Server, error) { if cfg == nil { return nil, errors.New("http config is nil") } + + // 1. Create a new ServeMux for registering routes. + mux := http.NewServeMux() + + // 2. Register all services to the mux. + // Register the gateway's own service. + if err := gatewayAPI.RegisterGatewayServiceHandlerServer(context.Background(), mux, svc); err != nil { + return nil, err + } + // Dynamically register all downstream services. + if err := registerDownstreamServices(context.Background(), mux, appCfg); err != nil { + return nil, err + } + + // 3. Create the server, passing the configured mux. middlewareProvider, err := app.MiddlewareProvider() if err != nil { return nil, err @@ -70,18 +97,48 @@ func NewHTTPServer(app *runtime.App, cfg *httpv1.Server, svc *service.GatewaySer if err != nil { return nil, err } - // Create server options and provide the application's available middlewares and discoveries. opts := &http.ServerOptions{ ServerMiddlewares: mws, + Mux: mux, // Pass the configured mux to the server. } - // Create the HTTP server. - srv, err := http.NewServer(cfg, opts) + return http.NewServer(cfg, opts) +} + +// registerDownstreamServices creates connections and registers handlers to the provided ServeMux. +func registerDownstreamServices(ctx context.Context, mux *http.ServeMux, cfg *conf.Config) error { + // --- Register System Service --- + systemConn, err := client.NewGRPCConn(cfg, "client.system") if err != nil { - return nil, err + return err + } + if err := system.RegisterUserServiceHandler(ctx, mux, systemConn); err != nil { + return err + } + if err := system.RegisterRoleServiceHandler(ctx, mux, systemConn); err != nil { + return err + } + if err := system.RegisterPermissionServiceHandler(ctx, mux, systemConn); err != nil { + return err + } + if err := system.RegisterResourceServiceHandler(ctx, mux, systemConn); err != nil { + return err + } + if err := system.RegisterViewServiceHandler(ctx, mux, systemConn); err != nil { + return err + } + + // --- Register Auth Service --- + authConn, err := client.NewGRPCConn(cfg, "client.auth") + if err != nil { + return err + } + if err := auth.RegisterAuthServiceHandler(ctx, mux, authConn); err != nil { + return err + } + if err := auth.RegisterMeServiceHandler(ctx, mux, authConn); err != nil { + return err } - // Register the gateway service. - gatewayAPI.RegisterGatewayServiceHTTPServer(srv, svc) - return srv, nil + return nil } diff --git a/internal/gateway/service/service.go b/internal/gateway/service/service.go index a26ead6d..16eba251 100644 --- a/internal/gateway/service/service.go +++ b/internal/gateway/service/service.go @@ -7,9 +7,8 @@ package service import ( "github.com/google/wire" - "origadmin/application/admin/api/v1/services/auth" gatewayAPI "origadmin/application/admin/api/v1/services/gateway" - "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/gateway/client" ) // ProviderSet is service providers. @@ -18,12 +17,12 @@ var ProviderSet = wire.NewSet(NewGatewayService) // GatewayService is a gateway service. type GatewayService struct { gatewayAPI.UnimplementedGatewayServiceServer - authClient auth.AuthServiceClient - systemClient system.UserServiceClient + authClient *client.AuthClientSet + systemClient *client.SystemClientSet } // NewGatewayService new a gateway service. -func NewGatewayService(authClient auth.AuthServiceClient, systemClient system.UserServiceClient) (*GatewayService, error) { +func NewGatewayService(authClient *client.AuthClientSet, systemClient *client.SystemClientSet) (*GatewayService, error) { return &GatewayService{ authClient: authClient, systemClient: systemClient, diff --git a/internal/helpers/resp/result.go b/internal/helpers/resp/result.go index 9bfb4fd1..a5167a66 100644 --- a/internal/helpers/resp/result.go +++ b/internal/helpers/resp/result.go @@ -10,11 +10,10 @@ import ( "fmt" "net/http" - paginationv1 "github.com/origadmin/runtime/api/gen/go/pagination/v1" - jwtv1 "github.com/origadmin/runtime/api/gen/go/security/jwt/v1" - "github.com/origadmin/toolkits/errors/httperr" "google.golang.org/protobuf/proto" + commonv1 "github.com/origadmin/runtime/api/gen/go/config/common/v1" + "github.com/origadmin/runtime/errors" datav1 "origadmin/application/admin/internal/helpers/resp/data/v1" ) @@ -39,7 +38,7 @@ type Result struct { NextPageToken *string `json:"next_page_token,omitempty"` Data json.RawMessage `json:"data,omitempty"` Extra json.RawMessage `json:"extra,omitempty"` - Error *httperr.Error `json:"error,omitempty"` + Error *errors.Error `json:"error,omitempty"` } type ResultBytes struct { @@ -52,7 +51,7 @@ type ResultBytes struct { } type PageResponse struct { - *paginationv1.PageResponse + commonv1.Pagination Data []json.RawMessage `json:"data"` Extra map[string]json.RawMessage `json:"extra,omitempty"` } @@ -146,12 +145,3 @@ func resultJSON(rw http.ResponseWriter, status int, data any) error { _, _ = rw.Write(v) return nil } - -func FromToken(token *jwtv1.Token) *Token { - return &Token{ - UserId: token.UserId, - AccessToken: token.AccessToken, - RefreshToken: token.RefreshToken, - ExpiresAt: token.ExpirationTime, - } -} diff --git a/internal/helpers/securityx/auth.go b/internal/helpers/securityx/auth.go.bak similarity index 100% rename from internal/helpers/securityx/auth.go rename to internal/helpers/securityx/auth.go.bak diff --git a/internal/helpers/securityx/security.go b/internal/helpers/securityx/security.go.bak similarity index 100% rename from internal/helpers/securityx/security.go rename to internal/helpers/securityx/security.go.bak diff --git a/internal/helpers/securityx/user.go b/internal/helpers/securityx/user.go.bak similarity index 100% rename from internal/helpers/securityx/user.go rename to internal/helpers/securityx/user.go.bak diff --git a/internal/helpers/time/time.go b/internal/helpers/time/time.go index 741a5414..7ae43f85 100644 --- a/internal/helpers/time/time.go +++ b/internal/helpers/time/time.go @@ -8,13 +8,13 @@ package time import ( "time" - "github.com/origadmin/contrib/i18n/tz" + "github.com/origadmin/toolkits/i18n/tz" ) type Time = time.Time func IsZero(t time.Time) bool { - location, err := time.LoadLocation(tz.Location()) + location, err := tz.GetLocation() if err != nil { return false } diff --git a/test/token_test.go b/test/token_test.go deleted file mode 100644 index f9dc8039..00000000 --- a/test/token_test.go +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package mock implements the functions, types, and interfaces for the module. -package test - -import ( - "context" - "testing" - - "github.com/go-kratos/kratos/v2/encoding" - "github.com/origadmin/runtime/interfaces/security" - - "github.com/origadmin/runtime" - sourcev1 "github.com/origadmin/runtime/api/gen/go/config/source/v1" - "github.com/origadmin/runtime/bootstrap" - "github.com/origadmin/toolkits/codec/toml" - - _ "origadmin/application/admin/contrib/consul/config" - _ "origadmin/application/admin/contrib/consul/registry" - _ "origadmin/application/admin/contrib/database" - "origadmin/application/admin/contrib/security/authz/casbin" - "origadmin/application/admin/helpers/securityx" - "origadmin/application/admin/internal/loader" - - pb "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/data" - "origadmin/application/admin/internal/features/auth/dal" // Corrected import path - "origadmin/application/admin/internal/features/auth/service" // Corrected import path -) - -type mockData struct { -} - -func (d mockData) QueryRoles(ctx context.Context, subject string) ([]string, error) { - return []string{ - "role_1", - }, nil -} - -func (d mockData) QueryPermissions(ctx context.Context, subject string) ([]string, error) { - return []string{ - "user_1", - }, nil -} - -func init() { - encoding.RegisterCodec(toml.Codec) -} - -func TestGenerateToken(t *testing.T) { - - r := runtime.New("test", "v0.0.1") - err := r.Load("", bootstrap.WithDirectly()) - if err != nil { - return - } - dataData, cleanup, err := data.NewData(r, bootstrap) - if err != nil { - return - } - defer cleanup() - authRepo := dal.NewAuthRepo(r, dataData) - //authServiceBiz := biz.NewAuthServiceBiz(r, authRepo) - //authServiceServer := service.NewAuthServiceServerPB(authServiceBiz) - //casbinSourceRepo, err := dal.NewCasbinRepo(dataData) - //if err != nil { - // cleanup() - // return - //} - //casbinSourceServiceBiz := biz.NewCasbinSourceServiceBiz(r, casbinSourceRepo) - //casbinSourceServiceServer := service.NewCasbinSourceServiceServerPB(casbinSourceServiceBiz) - //tokenizer, err := data.NewTokenizer(bootstrap) - //if err != nil { - // cleanup() - // return - //} - //refreshTokenizer := dal.RefreshTokenizer(tokenizer) - //loginData := data.NewLoginData(bootstrap, refreshTokenizer) - //loginRepo := dal.NewLoginRepo(dataData, loginData) - //loginServiceBiz := biz.NewLoginServiceBiz(r, loginRepo) - //loginServiceServer := service.NewLoginServiceServerPB(loginServiceBiz) - //personalRepo := dal.NewPersonalRepo(r, dataData) - //personalServiceBiz := biz.NewPersonalServiceBiz(r, personalRepo) - //personalServiceServer := service.NewPersonalServiceServerPB(r, personalServiceBiz) - //registerServer := service.NewRegisterServer(authServiceServer, casbinSourceServiceServer, loginServiceServer, personalServiceServer) - //v := server.NewAuthServer(r, bootstrap, registerServer) - authenticator, err := securityx.NewAuthenticator(bootstrap) - if err != nil { - panic(err) - } - clients := loader.NewProxyGRPCClients(r, bootstrap) - ruleSource := service.NewCasbinSourceClient(r, clients) - opts := []casbin.AuthorizerOption{ - casbin.WithSource(ruleSource), - } - - authorizer, err := securityx.NewAuthorizer(bootstrap, opts...) - if err != nil { - panic(err) - } - bridge := securityx.DefaultBridge() - bridge.PolicyParser = func(ctx context.Context, claims security.Claims) (security.Policy, error) { - return security.RegisteredPolicy{ - Subject: "user_1", - Object: "/api/v1/sys/users", - Action: "GET", - Domain: "*", - }, nil - } - bridge.Authenticator = authenticator - bridge.Authorizer = authorizer - ctx := context.Background() - token, err := authRepo.CreateToken(ctx, &pb.CreateTokenRequest{ - Data: &pb.CreateTokenRequest_Data{ - UserId: "user_1", - }, - }) - if err != nil { - t.Fatalf("failed to create token: %v", err) - } - claims, err := bridge.Authenticator.Authenticate(ctx, token.GetToken()) - if err != nil { - t.Fatalf("failed to authenticate: %v", err) - } - policy, err := bridge.PolicyParser(ctx, claims) - if err != nil { - t.Fatalf("failed to parse policy: %v", err) - } - - authorized, err := bridge.Authorizer.AuthorizedWithExtra(ctx, security.DataWithExtra(claims, - policy, nil)) - if err != nil { - t.Errorf("failed to authorize: %v", err) - } - if !authorized { - t.Errorf("failed to authorize: %v", err) - } - t.Logf("authorized: %v", authorized) -} From 10759f0f62e5a510b7d597be7cad351394e68017 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 14:55:27 +0800 Subject: [PATCH 119/158] refactor(gateway): remove proto-based service and simplify client registration --- Dockerfile | 2 +- api/v1/proto/gateway/gateway.proto | 71 ---------- cmd/gateway/wire_gen.go | 6 +- docker-compose.yml | 14 +- internal/gateway/client/client.go | 22 --- internal/gateway/server/server.go | 116 ++++++++-------- internal/gateway/service/service.go | 208 +++++++++++++++++++++++++++- 7 files changed, 267 insertions(+), 172 deletions(-) delete mode 100644 api/v1/proto/gateway/gateway.proto diff --git a/Dockerfile b/Dockerfile index dae27d41..0668a3a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ ARG SERVICE_NAME # - GOOS=linux ensures it's built for the Alpine base image. # - -a flag forces rebuilding of packages that are already up-to-date. # - -o specifies the output file path. -RUN CGO_ENABLED=0 GOOS=linux go build -a -o /app/${SERVICE_NAME} ./projects/backend/cmd/${SERVICE_NAME} +RUN CGO_ENABLED=0 GOOS=linux go build -a -o /app/${SERVICE_NAME} ./cmd/${SERVICE_NAME} # --- Runner Stage --- FROM alpine:latest diff --git a/api/v1/proto/gateway/gateway.proto b/api/v1/proto/gateway/gateway.proto deleted file mode 100644 index 12f9cd1a..00000000 --- a/api/v1/proto/gateway/gateway.proto +++ /dev/null @@ -1,71 +0,0 @@ -syntax = "proto3"; - -package api.v1.services.gateway; - -import "google/api/annotations.proto"; -import "auth/auth.proto"; -import "auth/me.proto"; -import "system/user.proto"; -import "system/role.proto"; -import "system/resource.proto"; -import "types/system.proto"; - -option go_package = "origadmin/application/admin/api/v1/services/gateway;gateway"; - -// GatewayService is the public-facing API gateway. -// It proxies requests to backend services. -service GatewayService { - // --- Auth Service --- - rpc Login (auth.LoginRequest) returns (auth.LoginResponse) { - option (google.api.http) = { - post: "/api/v1/login", - body: "*" - }; - } - - rpc GetCaptcha (auth.GetCaptchaRequest) returns (auth.GetCaptchaResponse) { - option (google.api.http) = { - get: "/api/v1/captcha" - }; - } - - // --- Me Service --- - rpc GetProfile(auth.GetProfileRequest) returns (auth.GetProfileResponse) { - option (google.api.http) = { - get: "/api/v1/me/profile" - }; - } - - // --- System User Service --- - rpc ListUsers(system.ListUsersRequest) returns (system.ListUsersResponse) { - option (google.api.http) = { - get: "/api/v1/users" - }; - } - - rpc GetUser(system.GetUserRequest) returns (types.User) { - option (google.api.http) = { - get: "/api/v1/users/{id}" - }; - } - - rpc CreateUser(system.CreateUserRequest) returns (types.User) { - option (google.api.http) = { - post: "/api/v1/users", - body: "*" - }; - } - - rpc UpdateUser(system.UpdateUserRequest) returns (types.User) { - option (google.api.http) = { - put: "/api/v1/users/{user.id}", - body: "user" - }; - } - - rpc DeleteUser(system.DeleteUserRequest) returns (system.DeleteUserResponse) { - option (google.api.http) = { - delete: "/api/v1/users/{id}" - }; - } -} diff --git a/cmd/gateway/wire_gen.go b/cmd/gateway/wire_gen.go index 7a189528..85b912f7 100644 --- a/cmd/gateway/wire_gen.go +++ b/cmd/gateway/wire_gen.go @@ -28,15 +28,15 @@ import ( func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { confpbBootstrap := &bootstrap.Bootstrap servers := confpbBootstrap.Servers - authServiceClient, err := client.NewAuthClient(bootstrap) + authClientSet, err := client.NewAuthClientSet(bootstrap) if err != nil { return nil, nil, err } - userServiceClient, err := client.NewSystemClient(bootstrap) + systemClientSet, err := client.NewSystemClientSet(bootstrap) if err != nil { return nil, nil, err } - gatewayService, err := service.NewGatewayService(authServiceClient, userServiceClient) + gatewayService, err := service.NewGatewayService(authClientSet, systemClientSet) if err != nil { return nil, nil, err } diff --git a/docker-compose.yml b/docker-compose.yml index 1d284d76..3aef1451 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,16 +1,16 @@ networks: - origadmin-net: + original-net: driver: bridge services: # Service Discovery consul: - image: hashicorp/consul:1.15.4 + image: hashicorp/consul:1.22.2 container_name: consul ports: - "8500:8500" networks: - - origadmin-net + - original-net command: "agent -server -bootstrap-expect=1 -ui -client=0.0.0.0" # Database @@ -24,7 +24,7 @@ services: ports: - "5432:5432" networks: - - origadmin-net + - original-net volumes: - postgres_data:/var/lib/postgresql/data @@ -42,7 +42,7 @@ services: ports: - "9001:9001" networks: - - origadmin-net + - original-net # System Service system: @@ -58,7 +58,7 @@ services: ports: - "9002:9002" networks: - - origadmin-net + - original-net # Gateway Service gateway: @@ -75,7 +75,7 @@ services: ports: - "8000:8000" networks: - - origadmin-net + - original-net volumes: postgres_data: diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index 4f2191c9..f26ff061 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -20,8 +20,6 @@ import ( // ProviderSet is client providers. var ProviderSet = wire.NewSet( - NewAuthClient, - NewSystemClient, NewAuthClientSet, NewSystemClientSet, ) @@ -91,23 +89,3 @@ func NewSystemClientSet(bootstrap *conf.Config) (*SystemClientSet, error) { ViewClient: system.NewViewServiceClient(conn), }, nil } - -// NewAuthClient creates a new AuthAPI client. -// Deprecated: Use NewAuthClientSet instead. -func NewAuthClient(bootstrap *conf.Config) (auth.AuthServiceClient, error) { - conn, err := NewGRPCConn(bootstrap, "client.auth") - if err != nil { - return nil, err - } - return auth.NewAuthServiceClient(conn), nil -} - -// NewSystemClient creates a new SystemAPI client. -// Deprecated: Use NewSystemClientSet instead. -func NewSystemClient(bootstrap *conf.Config) (system.UserServiceClient, error) { - conn, err := NewGRPCConn(bootstrap, "client.system") - if err != nil { - return nil, err - } - return system.NewUserServiceClient(conn), nil -} diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index c2c86936..827bdca8 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -5,7 +5,6 @@ package server import ( - "context" "errors" "github.com/go-kratos/kratos/v2/log" @@ -17,10 +16,7 @@ import ( "github.com/origadmin/runtime/service/transport" "github.com/origadmin/runtime/service/transport/http" "origadmin/application/admin/api/v1/services/auth" - gatewayAPI "origadmin/application/admin/api/v1/services/gateway" "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/conf" - "origadmin/application/admin/internal/gateway/client" "origadmin/application/admin/internal/gateway/service" ) @@ -31,7 +27,6 @@ var ProviderSet = wire.NewSet(NewServers) func NewServers( app *runtime.App, serversCfg *transportv1.Servers, - appCfg *conf.Config, svc *service.GatewayService, ) ([]transport.Server, error) { if serversCfg == nil { @@ -47,7 +42,7 @@ func NewServers( switch serverCfg.GetProtocol() { case "http": - srv, err := NewHTTPServer(app, serverCfg.GetHttp(), appCfg, svc) + srv, err := NewHTTPServer(app, serverCfg.GetHttp(), svc) if err != nil { return nil, err } @@ -65,29 +60,11 @@ func NewServers( } // NewHTTPServer creates a new HTTP server and registers all downstream service handlers. -func NewHTTPServer( - app *runtime.App, - cfg *httpv1.Server, - appCfg *conf.Config, - svc *service.GatewayService, -) (transport.Server, error) { +func NewHTTPServer(app *runtime.App, cfg *httpv1.Server, svc *service.GatewayService, ) (transport.Server, error) { if cfg == nil { return nil, errors.New("http config is nil") } - // 1. Create a new ServeMux for registering routes. - mux := http.NewServeMux() - - // 2. Register all services to the mux. - // Register the gateway's own service. - if err := gatewayAPI.RegisterGatewayServiceHandlerServer(context.Background(), mux, svc); err != nil { - return nil, err - } - // Dynamically register all downstream services. - if err := registerDownstreamServices(context.Background(), mux, appCfg); err != nil { - return nil, err - } - // 3. Create the server, passing the configured mux. middlewareProvider, err := app.MiddlewareProvider() if err != nil { @@ -99,46 +76,61 @@ func NewHTTPServer( } opts := &http.ServerOptions{ ServerMiddlewares: mws, - Mux: mux, // Pass the configured mux to the server. } - return http.NewServer(cfg, opts) -} - -// registerDownstreamServices creates connections and registers handlers to the provided ServeMux. -func registerDownstreamServices(ctx context.Context, mux *http.ServeMux, cfg *conf.Config) error { - // --- Register System Service --- - systemConn, err := client.NewGRPCConn(cfg, "client.system") + srv, err := http.NewServer(cfg, opts) if err != nil { - return err - } - if err := system.RegisterUserServiceHandler(ctx, mux, systemConn); err != nil { - return err - } - if err := system.RegisterRoleServiceHandler(ctx, mux, systemConn); err != nil { - return err - } - if err := system.RegisterPermissionServiceHandler(ctx, mux, systemConn); err != nil { - return err - } - if err := system.RegisterResourceServiceHandler(ctx, mux, systemConn); err != nil { - return err - } - if err := system.RegisterViewServiceHandler(ctx, mux, systemConn); err != nil { - return err - } - - // --- Register Auth Service --- - authConn, err := client.NewGRPCConn(cfg, "client.auth") - if err != nil { - return err - } - if err := auth.RegisterAuthServiceHandler(ctx, mux, authConn); err != nil { - return err - } - if err := auth.RegisterMeServiceHandler(ctx, mux, authConn); err != nil { - return err + return nil, err } + // 2. Register all services. + registerServices(srv, svc) + return srv, nil +} - return nil +func registerServices(srv *transport.HTTPServer, svc *service.GatewayService) { + system.RegisterUserServiceHTTPServer(srv, svc) + system.RegisterRoleServiceHTTPServer(srv, svc) + system.RegisterPermissionServiceHTTPServer(srv, svc) + system.RegisterResourceServiceHTTPServer(srv, svc) + system.RegisterViewServiceHTTPServer(srv, svc) + auth.RegisterAuthServiceHTTPServer(srv, svc) + auth.RegisterMeServiceHTTPServer(srv, svc) } + +// registerDownstreamServices creates connections and registers handlers to the provided ServeMux. +//func registerDownstreamServices(srv *transport.HTTPServer, cfg *service.GatewayService) error { +// // --- Register System Service --- +// svc, err := client.NewGRPCConn(cfg, "client.system") +// if err != nil { +// return err +// } +// if err := system.RegisterUserServiceHTTPServer(srv, systemConn); err != nil { +// return err +// } +// if err := system.RegisterRoleServiceHTTPServer(srv, systemConn); err != nil { +// return err +// } +// if err := system.RegisterPermissionServiceHTTPServer(srv, systemConn); err != nil { +// return err +// } +// if err := system.RegisterResourceServiceHTTPServer(srv, systemConn); err != nil { +// return err +// } +// if err := system.RegisterViewServiceHTTPServer(srv, systemConn); err != nil { +// return err +// } +// +// // --- Register Auth Service --- +// authConn, err := client.NewGRPCConn(cfg, "client.auth") +// if err != nil { +// return err +// } +// if err := auth.RegisterAuthServiceHTTPServer(srv, authConn); err != nil { +// return err +// } +// if err := auth.RegisterMeServiceHTTPServer(srv, authConn); err != nil { +// return err +// } +// +// return nil +//} diff --git a/internal/gateway/service/service.go b/internal/gateway/service/service.go index 16eba251..5f4adb00 100644 --- a/internal/gateway/service/service.go +++ b/internal/gateway/service/service.go @@ -7,7 +7,9 @@ package service import ( "github.com/google/wire" - gatewayAPI "origadmin/application/admin/api/v1/services/gateway" + "github.com/origadmin/runtime/context" + "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/gateway/client" ) @@ -16,15 +18,209 @@ var ProviderSet = wire.NewSet(NewGatewayService) // GatewayService is a gateway service. type GatewayService struct { - gatewayAPI.UnimplementedGatewayServiceServer - authClient *client.AuthClientSet - systemClient *client.SystemClientSet + Auth *client.AuthClientSet + System *client.SystemClientSet +} + +func (g GatewayService) GetProfile(ctx context.Context, request *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) GetUserResources(ctx context.Context, request *auth.GetUserResourcesRequest) (*auth.GetUserResourcesResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) GetUserRoles(ctx context.Context, request *auth.GetUserRolesRequest) (*auth.GetUserRolesResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) UpdatePassword(ctx context.Context, request *auth.UpdatePasswordRequest) (*auth.UpdatePasswordResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) UpdateProfile(ctx context.Context, request *auth.UpdateProfileRequest) (*auth.UpdateProfileResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) GetCaptcha(ctx context.Context, request *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) Login(ctx context.Context, request *auth.LoginRequest) (*auth.LoginResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) Logout(ctx context.Context, request *auth.LogoutRequest) (*auth.LogoutResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) RefreshToken(ctx context.Context, request *auth.RefreshTokenRequest) (*auth.RefreshTokenResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) Register(ctx context.Context, request *auth.RegisterRequest) (*auth.RegisterResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) CreateView(ctx context.Context, request *system.CreateViewRequest) (*system.CreateViewResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) DeleteView(ctx context.Context, request *system.DeleteViewRequest) (*system.DeleteViewResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) GetView(ctx context.Context, request *system.GetViewRequest) (*system.GetViewResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) ListViews(ctx context.Context, request *system.ListViewsRequest) (*system.ListViewsResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) UpdateView(ctx context.Context, request *system.UpdateViewRequest) (*system.UpdateViewResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) CreateResource(ctx context.Context, request *system.CreateResourceRequest) (*system.CreateResourceResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) DeleteResource(ctx context.Context, request *system.DeleteResourceRequest) (*system.DeleteResourceResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) GetResource(ctx context.Context, request *system.GetResourceRequest) (*system.GetResourceResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) ListResources(ctx context.Context, request *system.ListResourcesRequest) (*system.ListResourcesResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) UpdateResource(ctx context.Context, request *system.UpdateResourceRequest) (*system.UpdateResourceResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) CreatePermission(ctx context.Context, request *system.CreatePermissionRequest) (*system.CreatePermissionResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) DeletePermission(ctx context.Context, request *system.DeletePermissionRequest) (*system.DeletePermissionResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) GetPermission(ctx context.Context, request *system.GetPermissionRequest) (*system.GetPermissionResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) ListPermissions(ctx context.Context, request *system.ListPermissionsRequest) (*system.ListPermissionsResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) UpdatePermission(ctx context.Context, request *system.UpdatePermissionRequest) (*system.UpdatePermissionResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) CreateRole(ctx context.Context, request *system.CreateRoleRequest) (*system.CreateRoleResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) DeleteRole(ctx context.Context, request *system.DeleteRoleRequest) (*system.DeleteRoleResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) GetRole(ctx context.Context, request *system.GetRoleRequest) (*system.GetRoleResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) ListRoles(ctx context.Context, request *system.ListRolesRequest) (*system.ListRolesResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) UpdateRole(ctx context.Context, request *system.UpdateRoleRequest) (*system.UpdateRoleResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) CreateUser(ctx context.Context, request *system.CreateUserRequest) (*system.CreateUserResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) DeleteUser(ctx context.Context, request *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) GetUser(ctx context.Context, request *system.GetUserRequest) (*system.GetUserResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) ListUserResources(ctx context.Context, request *system.ListUserResourcesRequest) (*system.ListUserResourcesResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) ListUsers(ctx context.Context, request *system.ListUsersRequest) (*system.ListUsersResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) ResetUserPassword(ctx context.Context, request *system.ResetUserPasswordRequest) (*system.ResetUserPasswordResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) UpdateUser(ctx context.Context, request *system.UpdateUserRequest) (*system.UpdateUserResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) UpdateUserRoles(ctx context.Context, request *system.UpdateUserRolesRequest) (*system.UpdateUserRolesResponse, error) { + //TODO implement me + panic("implement me") +} + +func (g GatewayService) UpdateUserStatus(ctx context.Context, request *system.UpdateUserStatusRequest) (*system.UpdateUserStatusResponse, error) { + //TODO implement me + panic("implement me") } // NewGatewayService new a gateway service. func NewGatewayService(authClient *client.AuthClientSet, systemClient *client.SystemClientSet) (*GatewayService, error) { return &GatewayService{ - authClient: authClient, - systemClient: systemClient, + Auth: authClient, + System: systemClient, }, nil } From 7793567a3fb4eb037e38b40132bd870c5b98b7ac Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 15:22:02 +0800 Subject: [PATCH 120/158] refactor(api): remove gateway service protobuf and gRPC gateway files --- api/v1/services/gateway/gateway.pb.go | 109 --- api/v1/services/gateway/gateway.pb.gw.go | 682 ------------------ .../services/gateway/gateway.pb.validate.go | 36 - api/v1/services/gateway/gateway_bridge.pb.go | 566 --------------- api/v1/services/gateway/gateway_grpc.pb.go | 402 ----------- api/v1/services/gateway/gateway_http.pb.go | 357 --------- cmd/gateway/wire.go | 2 - internal/gateway/client/client.go | 44 +- internal/gateway/server/server.go | 70 +- internal/gateway/service/service.go | 208 +----- 10 files changed, 49 insertions(+), 2427 deletions(-) delete mode 100644 api/v1/services/gateway/gateway.pb.go delete mode 100644 api/v1/services/gateway/gateway.pb.gw.go delete mode 100644 api/v1/services/gateway/gateway.pb.validate.go delete mode 100644 api/v1/services/gateway/gateway_bridge.pb.go delete mode 100644 api/v1/services/gateway/gateway_grpc.pb.go delete mode 100644 api/v1/services/gateway/gateway_http.pb.go diff --git a/api/v1/services/gateway/gateway.pb.go b/api/v1/services/gateway/gateway.pb.go deleted file mode 100644 index 11816de1..00000000 --- a/api/v1/services/gateway/gateway.pb.go +++ /dev/null @@ -1,109 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.36.10 -// protoc (unknown) -// source: gateway/gateway.proto - -package gateway - -import ( - _ "google.golang.org/genproto/googleapis/api/annotations" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - auth "origadmin/application/admin/api/v1/services/auth" - system "origadmin/application/admin/api/v1/services/system" - types "origadmin/application/admin/api/v1/services/types" - reflect "reflect" - unsafe "unsafe" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -var File_gateway_gateway_proto protoreflect.FileDescriptor - -const file_gateway_gateway_proto_rawDesc = "" + - "\n" + - "\x15gateway/gateway.proto\x12\x17api.v1.services.gateway\x1a\x1cgoogle/api/annotations.proto\x1a\x0fauth/auth.proto\x1a\rauth/me.proto\x1a\x11system/user.proto\x1a\x11system/role.proto\x1a\x15system/resource.proto\x1a\x12types/system.proto2\xc6\a\n" + - "\x0eGatewayService\x12j\n" + - "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x18\x82\xd3\xe4\x93\x02\x12:\x01*\"\r/api/v1/login\x12x\n" + - "\n" + - "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/api/v1/captcha\x12{\n" + - "\n" + - "GetProfile\x12'.api.v1.services.auth.GetProfileRequest\x1a(.api.v1.services.auth.GetProfileResponse\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/api/v1/me/profile\x12w\n" + - "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\"\x15\x82\xd3\xe4\x93\x02\x0f\x12\r/api/v1/users\x12j\n" + - "\aGetUser\x12&.api.v1.services.system.GetUserRequest\x1a\x1b.api.v1.services.types.User\"\x1a\x82\xd3\xe4\x93\x02\x14\x12\x12/api/v1/users/{id}\x12n\n" + - "\n" + - "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a\x1b.api.v1.services.types.User\"\x18\x82\xd3\xe4\x93\x02\x12:\x01*\"\r/api/v1/users\x12{\n" + - "\n" + - "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a\x1b.api.v1.services.types.User\"%\x82\xd3\xe4\x93\x02\x1f:\x04user\x1a\x17/api/v1/users/{user.id}\x12\x7f\n" + - "\n" + - "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x1a\x82\xd3\xe4\x93\x02\x14*\x12/api/v1/users/{id}B\xe8\x01\n" + - "\x1bcom.api.v1.services.gatewayB\fGatewayProtoP\x01Z;origadmin/application/admin/api/v1/services/gateway;gateway\xa2\x02\x04AVSG\xaa\x02\x17Api.V1.Services.Gateway\xca\x02\x17Api\\V1\\Services\\Gateway\xe2\x02#Api\\V1\\Services\\Gateway\\GPBMetadata\xea\x02\x1aApi::V1::Services::Gatewayb\x06proto3" - -var file_gateway_gateway_proto_goTypes = []any{ - (*auth.LoginRequest)(nil), // 0: api.v1.services.auth.LoginRequest - (*auth.GetCaptchaRequest)(nil), // 1: api.v1.services.auth.GetCaptchaRequest - (*auth.GetProfileRequest)(nil), // 2: api.v1.services.auth.GetProfileRequest - (*system.ListUsersRequest)(nil), // 3: api.v1.services.system.ListUsersRequest - (*system.GetUserRequest)(nil), // 4: api.v1.services.system.GetUserRequest - (*system.CreateUserRequest)(nil), // 5: api.v1.services.system.CreateUserRequest - (*system.UpdateUserRequest)(nil), // 6: api.v1.services.system.UpdateUserRequest - (*system.DeleteUserRequest)(nil), // 7: api.v1.services.system.DeleteUserRequest - (*auth.LoginResponse)(nil), // 8: api.v1.services.auth.LoginResponse - (*auth.GetCaptchaResponse)(nil), // 9: api.v1.services.auth.GetCaptchaResponse - (*auth.GetProfileResponse)(nil), // 10: api.v1.services.auth.GetProfileResponse - (*system.ListUsersResponse)(nil), // 11: api.v1.services.system.ListUsersResponse - (*types.User)(nil), // 12: api.v1.services.types.User - (*system.DeleteUserResponse)(nil), // 13: api.v1.services.system.DeleteUserResponse -} -var file_gateway_gateway_proto_depIdxs = []int32{ - 0, // 0: api.v1.services.gateway.GatewayService.Login:input_type -> api.v1.services.auth.LoginRequest - 1, // 1: api.v1.services.gateway.GatewayService.GetCaptcha:input_type -> api.v1.services.auth.GetCaptchaRequest - 2, // 2: api.v1.services.gateway.GatewayService.GetProfile:input_type -> api.v1.services.auth.GetProfileRequest - 3, // 3: api.v1.services.gateway.GatewayService.ListUsers:input_type -> api.v1.services.system.ListUsersRequest - 4, // 4: api.v1.services.gateway.GatewayService.GetUser:input_type -> api.v1.services.system.GetUserRequest - 5, // 5: api.v1.services.gateway.GatewayService.CreateUser:input_type -> api.v1.services.system.CreateUserRequest - 6, // 6: api.v1.services.gateway.GatewayService.UpdateUser:input_type -> api.v1.services.system.UpdateUserRequest - 7, // 7: api.v1.services.gateway.GatewayService.DeleteUser:input_type -> api.v1.services.system.DeleteUserRequest - 8, // 8: api.v1.services.gateway.GatewayService.Login:output_type -> api.v1.services.auth.LoginResponse - 9, // 9: api.v1.services.gateway.GatewayService.GetCaptcha:output_type -> api.v1.services.auth.GetCaptchaResponse - 10, // 10: api.v1.services.gateway.GatewayService.GetProfile:output_type -> api.v1.services.auth.GetProfileResponse - 11, // 11: api.v1.services.gateway.GatewayService.ListUsers:output_type -> api.v1.services.system.ListUsersResponse - 12, // 12: api.v1.services.gateway.GatewayService.GetUser:output_type -> api.v1.services.types.User - 12, // 13: api.v1.services.gateway.GatewayService.CreateUser:output_type -> api.v1.services.types.User - 12, // 14: api.v1.services.gateway.GatewayService.UpdateUser:output_type -> api.v1.services.types.User - 13, // 15: api.v1.services.gateway.GatewayService.DeleteUser:output_type -> api.v1.services.system.DeleteUserResponse - 8, // [8:16] is the sub-list for method output_type - 0, // [0:8] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_gateway_gateway_proto_init() } -func file_gateway_gateway_proto_init() { - if File_gateway_gateway_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_gateway_gateway_proto_rawDesc), len(file_gateway_gateway_proto_rawDesc)), - NumEnums: 0, - NumMessages: 0, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_gateway_gateway_proto_goTypes, - DependencyIndexes: file_gateway_gateway_proto_depIdxs, - }.Build() - File_gateway_gateway_proto = out.File - file_gateway_gateway_proto_goTypes = nil - file_gateway_gateway_proto_depIdxs = nil -} diff --git a/api/v1/services/gateway/gateway.pb.gw.go b/api/v1/services/gateway/gateway.pb.gw.go deleted file mode 100644 index 28e35615..00000000 --- a/api/v1/services/gateway/gateway.pb.gw.go +++ /dev/null @@ -1,682 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: gateway/gateway.proto - -/* -Package gateway is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package gateway - -import ( - "context" - "errors" - "io" - "net/http" - "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/api/v1/services/system" - - "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" - "github.com/grpc-ecosystem/grpc-gateway/v2/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" - "google.golang.org/protobuf/proto" -) - -// Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = errors.New - _ = runtime.String - _ = utilities.NewDoubleArray - _ = metadata.Join -) - -func request_GatewayService_Login_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq auth.LoginRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_GatewayService_Login_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq auth.LoginRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.Login(ctx, &protoReq) - return msg, metadata, err -} - -var filter_GatewayService_GetCaptcha_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_GatewayService_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq auth.GetCaptchaRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_GetCaptcha_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.GetCaptcha(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_GatewayService_GetCaptcha_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq auth.GetCaptchaRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_GetCaptcha_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.GetCaptcha(ctx, &protoReq) - return msg, metadata, err -} - -func request_GatewayService_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq auth.GetProfileRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - msg, err := client.GetProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_GatewayService_GetProfile_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq auth.GetProfileRequest - metadata runtime.ServerMetadata - ) - msg, err := server.GetProfile(ctx, &protoReq) - return msg, metadata, err -} - -var filter_GatewayService_ListUsers_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} - -func request_GatewayService_ListUsers_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq system.ListUsersRequest - metadata runtime.ServerMetadata - ) - io.Copy(io.Discard, req.Body) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_ListUsers_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.ListUsers(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_GatewayService_ListUsers_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq system.ListUsersRequest - metadata runtime.ServerMetadata - ) - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_ListUsers_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.ListUsers(ctx, &protoReq) - return msg, metadata, err -} - -func request_GatewayService_GetUser_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq system.GetUserRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := client.GetUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_GatewayService_GetUser_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq system.GetUserRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - msg, err := server.GetUser(ctx, &protoReq) - return msg, metadata, err -} - -func request_GatewayService_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq system.CreateUserRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.CreateUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_GatewayService_CreateUser_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq system.CreateUserRequest - metadata runtime.ServerMetadata - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.CreateUser(ctx, &protoReq) - return msg, metadata, err -} - -var filter_GatewayService_UpdateUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - -func request_GatewayService_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq system.UpdateUserRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["user.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_UpdateUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.UpdateUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_GatewayService_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq system.UpdateUserRequest - metadata runtime.ServerMetadata - err error - ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - val, ok := pathParams["user.id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user.id") - } - err = runtime.PopulateFieldFromPath(&protoReq, "user.id", val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_UpdateUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.UpdateUser(ctx, &protoReq) - return msg, metadata, err -} - -var filter_GatewayService_DeleteUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - -func request_GatewayService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, client GatewayServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq system.DeleteUserRequest - metadata runtime.ServerMetadata - err error - ) - io.Copy(io.Discard, req.Body) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_DeleteUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := client.DeleteUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err -} - -func local_request_GatewayService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, server GatewayServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var ( - protoReq system.DeleteUserRequest - metadata runtime.ServerMetadata - err error - ) - val, ok := pathParams["id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") - } - protoReq.Id, err = runtime.Int64(val) - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) - } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_GatewayService_DeleteUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.DeleteUser(ctx, &protoReq) - return msg, metadata, err -} - -// RegisterGatewayServiceHandlerServer registers the http handlers for service GatewayService to "mux". -// UnaryRPC :call GatewayServiceServer directly. -// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterGatewayServiceHandlerFromEndpoint instead. -// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. -func RegisterGatewayServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server GatewayServiceServer) error { - mux.Handle(http.MethodPost, pattern_GatewayService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/Login", runtime.WithHTTPPathPattern("/api/v1/login")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_GatewayService_Login_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_GatewayService_GetCaptcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_GatewayService_GetCaptcha_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_GetCaptcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_GatewayService_GetProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_GatewayService_GetProfile_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_GetProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_GatewayService_ListUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/ListUsers", runtime.WithHTTPPathPattern("/api/v1/users")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_GatewayService_ListUsers_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_ListUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_GatewayService_GetUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetUser", runtime.WithHTTPPathPattern("/api/v1/users/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_GatewayService_GetUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_GetUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_GatewayService_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/CreateUser", runtime.WithHTTPPathPattern("/api/v1/users")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_GatewayService_CreateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_GatewayService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/UpdateUser", runtime.WithHTTPPathPattern("/api/v1/users/{user.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_GatewayService_UpdateUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_GatewayService_DeleteUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/DeleteUser", runtime.WithHTTPPathPattern("/api/v1/users/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_GatewayService_DeleteUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_DeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - - return nil -} - -// RegisterGatewayServiceHandlerFromEndpoint is same as RegisterGatewayServiceHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterGatewayServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.NewClient(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - return RegisterGatewayServiceHandler(ctx, mux, conn) -} - -// RegisterGatewayServiceHandler registers the http handlers for service GatewayService to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterGatewayServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterGatewayServiceHandlerClient(ctx, mux, NewGatewayServiceClient(conn)) -} - -// RegisterGatewayServiceHandlerClient registers the http handlers for service GatewayService -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "GatewayServiceClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "GatewayServiceClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "GatewayServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. -func RegisterGatewayServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client GatewayServiceClient) error { - mux.Handle(http.MethodPost, pattern_GatewayService_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/Login", runtime.WithHTTPPathPattern("/api/v1/login")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_GatewayService_Login_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_GatewayService_GetCaptcha_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetCaptcha", runtime.WithHTTPPathPattern("/api/v1/captcha")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_GatewayService_GetCaptcha_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_GetCaptcha_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_GatewayService_GetProfile_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetProfile", runtime.WithHTTPPathPattern("/api/v1/me/profile")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_GatewayService_GetProfile_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_GetProfile_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_GatewayService_ListUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/ListUsers", runtime.WithHTTPPathPattern("/api/v1/users")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_GatewayService_ListUsers_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_ListUsers_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodGet, pattern_GatewayService_GetUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/GetUser", runtime.WithHTTPPathPattern("/api/v1/users/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_GatewayService_GetUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_GetUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPost, pattern_GatewayService_CreateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/CreateUser", runtime.WithHTTPPathPattern("/api/v1/users")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_GatewayService_CreateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodPut, pattern_GatewayService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/UpdateUser", runtime.WithHTTPPathPattern("/api/v1/users/{user.id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_GatewayService_UpdateUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_UpdateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - mux.Handle(http.MethodDelete, pattern_GatewayService_DeleteUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.gateway.GatewayService/DeleteUser", runtime.WithHTTPPathPattern("/api/v1/users/{id}")) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_GatewayService_DeleteUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) - annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) - if err != nil { - runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) - return - } - forward_GatewayService_DeleteUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - }) - return nil -} - -var ( - pattern_GatewayService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "login"}, "")) - pattern_GatewayService_GetCaptcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "captcha"}, "")) - pattern_GatewayService_GetProfile_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "me", "profile"}, "")) - pattern_GatewayService_ListUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "users"}, "")) - pattern_GatewayService_GetUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "users", "id"}, "")) - pattern_GatewayService_CreateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "users"}, "")) - pattern_GatewayService_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "users", "user.id"}, "")) - pattern_GatewayService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "users", "id"}, "")) -) - -var ( - forward_GatewayService_Login_0 = runtime.ForwardResponseMessage - forward_GatewayService_GetCaptcha_0 = runtime.ForwardResponseMessage - forward_GatewayService_GetProfile_0 = runtime.ForwardResponseMessage - forward_GatewayService_ListUsers_0 = runtime.ForwardResponseMessage - forward_GatewayService_GetUser_0 = runtime.ForwardResponseMessage - forward_GatewayService_CreateUser_0 = runtime.ForwardResponseMessage - forward_GatewayService_UpdateUser_0 = runtime.ForwardResponseMessage - forward_GatewayService_DeleteUser_0 = runtime.ForwardResponseMessage -) diff --git a/api/v1/services/gateway/gateway.pb.validate.go b/api/v1/services/gateway/gateway.pb.validate.go deleted file mode 100644 index 4d751b63..00000000 --- a/api/v1/services/gateway/gateway.pb.validate.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by protoc-gen-validate. DO NOT EDIT. -// source: gateway/gateway.proto - -package gateway - -import ( - "bytes" - "errors" - "fmt" - "net" - "net/mail" - "net/url" - "regexp" - "sort" - "strings" - "time" - "unicode/utf8" - - "google.golang.org/protobuf/types/known/anypb" -) - -// ensure the imports are used -var ( - _ = bytes.MinRead - _ = errors.New("") - _ = fmt.Print - _ = utf8.UTFMax - _ = (*regexp.Regexp)(nil) - _ = (*strings.Reader)(nil) - _ = net.IPv4len - _ = time.Duration(0) - _ = (*url.URL)(nil) - _ = (*mail.Address)(nil) - _ = anypb.Any{} - _ = sort.Sort -) diff --git a/api/v1/services/gateway/gateway_bridge.pb.go b/api/v1/services/gateway/gateway_bridge.pb.go deleted file mode 100644 index 5f6fe475..00000000 --- a/api/v1/services/gateway/gateway_bridge.pb.go +++ /dev/null @@ -1,566 +0,0 @@ -// Code generated by protoc-gen-go-bridge. DO NOT EDIT. -// versions: -// - protoc-gen-go-bridge unknown -// - protoc (unknown) -// source: gateway/gateway.proto - -package gateway - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - io "io" - auth "origadmin/application/admin/api/v1/services/auth" - system "origadmin/application/admin/api/v1/services/system" - types "origadmin/application/admin/api/v1/services/types" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) - -const _ = http.SupportPackageIsVersion1 -const _ = grpc.SupportPackageIsVersion9 - -var ( - _ = io.EOF - _ = status.Errorf - _ = codes.Unimplemented -) - -const GatewayServiceLoginBridgeOperation = "/api.v1.services.gateway.GatewayService/Login" -const GatewayServiceGetCaptchaBridgeOperation = "/api.v1.services.gateway.GatewayService/GetCaptcha" -const GatewayServiceGetProfileBridgeOperation = "/api.v1.services.gateway.GatewayService/GetProfile" -const GatewayServiceListUsersBridgeOperation = "/api.v1.services.gateway.GatewayService/ListUsers" -const GatewayServiceGetUserBridgeOperation = "/api.v1.services.gateway.GatewayService/GetUser" -const GatewayServiceCreateUserBridgeOperation = "/api.v1.services.gateway.GatewayService/CreateUser" -const GatewayServiceUpdateUserBridgeOperation = "/api.v1.services.gateway.GatewayService/UpdateUser" -const GatewayServiceDeleteUserBridgeOperation = "/api.v1.services.gateway.GatewayService/DeleteUser" - -type GatewayServiceBridgeServer interface { - // --- Auth Service --- - Login(context.Context, *auth.LoginRequest) (*auth.LoginResponse, error) - GetCaptcha(context.Context, *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) - // --- Me Service --- - GetProfile(context.Context, *auth.GetProfileRequest) (*auth.GetProfileResponse, error) - // --- System User Service --- - ListUsers(context.Context, *system.ListUsersRequest) (*system.ListUsersResponse, error) - GetUser(context.Context, *system.GetUserRequest) (*types.User, error) - CreateUser(context.Context, *system.CreateUserRequest) (*types.User, error) - UpdateUser(context.Context, *system.UpdateUserRequest) (*types.User, error) - DeleteUser(context.Context, *system.DeleteUserRequest) (*system.DeleteUserResponse, error) -} - -type GatewayServiceHooker interface { - GatewayServiceLoginHooker - GatewayServiceGetCaptchaHooker - GatewayServiceGetProfileHooker - GatewayServiceListUsersHooker - GatewayServiceGetUserHooker - GatewayServiceCreateUserHooker - GatewayServiceUpdateUserHooker - GatewayServiceDeleteUserHooker -} - -type GatewayServiceHookedBridger interface { - GatewayServiceHooker - GatewayServiceBridgeServer -} -type GatewayServiceLoginHooker interface { - PrepareLogin(http.Context, *auth.LoginRequest) (context.Context, error) - CompleteLogin(http.Context, *auth.LoginRequest, *auth.LoginResponse) error -} -type GatewayServiceGetCaptchaHooker interface { - PrepareGetCaptcha(http.Context, *auth.GetCaptchaRequest) (context.Context, error) - CompleteGetCaptcha(http.Context, *auth.GetCaptchaRequest, *auth.GetCaptchaResponse) error -} -type GatewayServiceGetProfileHooker interface { - PrepareGetProfile(http.Context, *auth.GetProfileRequest) (context.Context, error) - CompleteGetProfile(http.Context, *auth.GetProfileRequest, *auth.GetProfileResponse) error -} -type GatewayServiceListUsersHooker interface { - PrepareListUsers(http.Context, *system.ListUsersRequest) (context.Context, error) - CompleteListUsers(http.Context, *system.ListUsersRequest, *system.ListUsersResponse) error -} -type GatewayServiceGetUserHooker interface { - PrepareGetUser(http.Context, *system.GetUserRequest) (context.Context, error) - CompleteGetUser(http.Context, *system.GetUserRequest, *types.User) error -} -type GatewayServiceCreateUserHooker interface { - PrepareCreateUser(http.Context, *system.CreateUserRequest) (context.Context, error) - CompleteCreateUser(http.Context, *system.CreateUserRequest, *types.User) error -} -type GatewayServiceUpdateUserHooker interface { - PrepareUpdateUser(http.Context, *system.UpdateUserRequest) (context.Context, error) - CompleteUpdateUser(http.Context, *system.UpdateUserRequest, *types.User) error -} -type GatewayServiceDeleteUserHooker interface { - PrepareDeleteUser(http.Context, *system.DeleteUserRequest) (context.Context, error) - CompleteDeleteUser(http.Context, *system.DeleteUserRequest, *system.DeleteUserResponse) error -} - -func RegisterGatewayServiceBridgeServer(s *http.Server, srv GatewayServiceHookedBridger) { - r := s.Route("/") - r.POST("/api/v1/login", _GatewayService_Login0_Bridge_Handler(srv)) - r.GET("/api/v1/captcha", _GatewayService_GetCaptcha0_Bridge_Handler(srv)) - r.GET("/api/v1/me/profile", _GatewayService_GetProfile0_Bridge_Handler(srv)) - r.GET("/api/v1/users", _GatewayService_ListUsers0_Bridge_Handler(srv)) - r.GET("/api/v1/users/:id", _GatewayService_GetUser0_Bridge_Handler(srv)) - r.POST("/api/v1/users", _GatewayService_CreateUser0_Bridge_Handler(srv)) - r.PUT("/api/v1/users/:user.id", _GatewayService_UpdateUser0_Bridge_Handler(srv)) - r.DELETE("/api/v1/users/:id", _GatewayService_DeleteUser0_Bridge_Handler(srv)) -} - -func _GatewayService_Login0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in auth.LoginRequest - if err := ctx.Bind(&in); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceLogin) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Login(ctx, req.(*auth.LoginRequest)) - }) - - newctx, err := srv.PrepareLogin(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteLogin(ctx, &in, out.(*auth.LoginResponse)) - } -} - -func _GatewayService_GetCaptcha0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in auth.GetCaptchaRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceGetCaptcha) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetCaptcha(ctx, req.(*auth.GetCaptchaRequest)) - }) - - newctx, err := srv.PrepareGetCaptcha(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetCaptcha(ctx, &in, out.(*auth.GetCaptchaResponse)) - } -} - -func _GatewayService_GetProfile0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in auth.GetProfileRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceGetProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetProfile(ctx, req.(*auth.GetProfileRequest)) - }) - - newctx, err := srv.PrepareGetProfile(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetProfile(ctx, &in, out.(*auth.GetProfileResponse)) - } -} - -func _GatewayService_ListUsers0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in system.ListUsersRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceListUsers) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListUsers(ctx, req.(*system.ListUsersRequest)) - }) - - newctx, err := srv.PrepareListUsers(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteListUsers(ctx, &in, out.(*system.ListUsersResponse)) - } -} - -func _GatewayService_GetUser0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in system.GetUserRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceGetUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetUser(ctx, req.(*system.GetUserRequest)) - }) - - newctx, err := srv.PrepareGetUser(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteGetUser(ctx, &in, out.(*types.User)) - } -} - -func _GatewayService_CreateUser0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in system.CreateUserRequest - if err := ctx.Bind(&in); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceCreateUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateUser(ctx, req.(*system.CreateUserRequest)) - }) - - newctx, err := srv.PrepareCreateUser(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteCreateUser(ctx, &in, out.(*types.User)) - } -} - -func _GatewayService_UpdateUser0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in system.UpdateUserRequest - if err := ctx.Bind(&in.User); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceUpdateUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateUser(ctx, req.(*system.UpdateUserRequest)) - }) - - newctx, err := srv.PrepareUpdateUser(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteUpdateUser(ctx, &in, out.(*types.User)) - } -} - -func _GatewayService_DeleteUser0_Bridge_Handler(srv GatewayServiceHookedBridger) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in system.DeleteUserRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceDeleteUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteUser(ctx, req.(*system.DeleteUserRequest)) - }) - - newctx, err := srv.PrepareDeleteUser(ctx, &in) - if err != nil { - return err - } - out, err := h(newctx, &in) - if err != nil { - return err - } - return srv.CompleteDeleteUser(ctx, &in, out.(*system.DeleteUserResponse)) - } -} - -// UnimplementedGatewayServiceHooked must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedGatewayServiceHooked struct{} - -func (UnimplementedGatewayServiceHooked) PrepareLogin(ctx http.Context, in *auth.LoginRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedGatewayServiceHooked) CompleteLogin(ctx http.Context, in *auth.LoginRequest, out *auth.LoginResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedGatewayServiceHooked) PrepareGetCaptcha(ctx http.Context, in *auth.GetCaptchaRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedGatewayServiceHooked) CompleteGetCaptcha(ctx http.Context, in *auth.GetCaptchaRequest, out *auth.GetCaptchaResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedGatewayServiceHooked) PrepareGetProfile(ctx http.Context, in *auth.GetProfileRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedGatewayServiceHooked) CompleteGetProfile(ctx http.Context, in *auth.GetProfileRequest, out *auth.GetProfileResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedGatewayServiceHooked) PrepareListUsers(ctx http.Context, in *system.ListUsersRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedGatewayServiceHooked) CompleteListUsers(ctx http.Context, in *system.ListUsersRequest, out *system.ListUsersResponse) error { - return ctx.Result(200, out) -} - -func (UnimplementedGatewayServiceHooked) PrepareGetUser(ctx http.Context, in *system.GetUserRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedGatewayServiceHooked) CompleteGetUser(ctx http.Context, in *system.GetUserRequest, out *types.User) error { - return ctx.Result(200, out) -} - -func (UnimplementedGatewayServiceHooked) PrepareCreateUser(ctx http.Context, in *system.CreateUserRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedGatewayServiceHooked) CompleteCreateUser(ctx http.Context, in *system.CreateUserRequest, out *types.User) error { - return ctx.Result(200, out) -} - -func (UnimplementedGatewayServiceHooked) PrepareUpdateUser(ctx http.Context, in *system.UpdateUserRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedGatewayServiceHooked) CompleteUpdateUser(ctx http.Context, in *system.UpdateUserRequest, out *types.User) error { - return ctx.Result(200, out) -} - -func (UnimplementedGatewayServiceHooked) PrepareDeleteUser(ctx http.Context, in *system.DeleteUserRequest) (context.Context, error) { - return ctx, nil -} - -func (UnimplementedGatewayServiceHooked) CompleteDeleteUser(ctx http.Context, in *system.DeleteUserRequest, out *system.DeleteUserResponse) error { - return ctx.Result(200, out) -} - -func WithGatewayServiceHook(h GatewayServiceHooker) func(GatewayServiceBridgeServer) GatewayServiceHookedBridger { - return func(srv GatewayServiceBridgeServer) GatewayServiceHookedBridger { - return GatewayServiceHookedBridge{GatewayServiceBridgeServer: srv, GatewayServiceHooker: h} - } -} - -// GatewayServiceHookedBridge is a bridge between the HTTP and gRPC implementations of GatewayService. -// It implements the HTTP and gRPC implementations of GatewayService. -// It forwards requests and responses between the two implementations. -type GatewayServiceHookedBridge struct { - GatewayServiceBridgeServer - GatewayServiceHooker -} - -type GatewayServiceHTTPBridgeImpl struct { - client GatewayServiceHTTPClient -} - -func NewGatewayServiceHTTPBridge(client *http.Client) GatewayServiceHTTPServer { - return &GatewayServiceHTTPBridgeImpl{client: NewGatewayServiceHTTPClient(client)} -} - -func (c *GatewayServiceHTTPBridgeImpl) Login(ctx context.Context, in *auth.LoginRequest) (*auth.LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *GatewayServiceHTTPBridgeImpl) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { - return c.client.GetCaptcha(ctx, in) -} - -func (c *GatewayServiceHTTPBridgeImpl) GetProfile(ctx context.Context, in *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { - return c.client.GetProfile(ctx, in) -} - -func (c *GatewayServiceHTTPBridgeImpl) ListUsers(ctx context.Context, in *system.ListUsersRequest) (*system.ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) -} - -func (c *GatewayServiceHTTPBridgeImpl) GetUser(ctx context.Context, in *system.GetUserRequest) (*types.User, error) { - return c.client.GetUser(ctx, in) -} - -func (c *GatewayServiceHTTPBridgeImpl) CreateUser(ctx context.Context, in *system.CreateUserRequest) (*types.User, error) { - return c.client.CreateUser(ctx, in) -} - -func (c *GatewayServiceHTTPBridgeImpl) UpdateUser(ctx context.Context, in *system.UpdateUserRequest) (*types.User, error) { - return c.client.UpdateUser(ctx, in) -} - -func (c *GatewayServiceHTTPBridgeImpl) DeleteUser(ctx context.Context, in *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) -} - -type GatewayServiceBridgeImpl struct { - client GatewayServiceClient -} - -func NewGatewayServiceBridge(client grpc.ClientConnInterface) GatewayServiceServer { - return &GatewayServiceBridgeImpl{client: NewGatewayServiceClient(client)} -} - -func (c *GatewayServiceBridgeImpl) Login(ctx context.Context, in *auth.LoginRequest) (*auth.LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *GatewayServiceBridgeImpl) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { - return c.client.GetCaptcha(ctx, in) -} - -func (c *GatewayServiceBridgeImpl) GetProfile(ctx context.Context, in *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { - return c.client.GetProfile(ctx, in) -} - -func (c *GatewayServiceBridgeImpl) ListUsers(ctx context.Context, in *system.ListUsersRequest) (*system.ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) -} - -func (c *GatewayServiceBridgeImpl) GetUser(ctx context.Context, in *system.GetUserRequest) (*types.User, error) { - return c.client.GetUser(ctx, in) -} - -func (c *GatewayServiceBridgeImpl) CreateUser(ctx context.Context, in *system.CreateUserRequest) (*types.User, error) { - return c.client.CreateUser(ctx, in) -} - -func (c *GatewayServiceBridgeImpl) UpdateUser(ctx context.Context, in *system.UpdateUserRequest) (*types.User, error) { - return c.client.UpdateUser(ctx, in) -} - -func (c *GatewayServiceBridgeImpl) DeleteUser(ctx context.Context, in *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) -} - -func (c *GatewayServiceBridgeImpl) mustEmbedUnimplementedGatewayServiceServer() {} - -type GatewayServiceGRPC2HTTPBridgeImpl struct { - client GatewayServiceClient -} - -func NewGatewayServiceGRPC2HTTP(client grpc.ClientConnInterface) GatewayServiceHTTPServer { - return &GatewayServiceGRPC2HTTPBridgeImpl{client: NewGatewayServiceClient(client)} -} - -func (c *GatewayServiceGRPC2HTTPBridgeImpl) Login(ctx context.Context, in *auth.LoginRequest) (*auth.LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *GatewayServiceGRPC2HTTPBridgeImpl) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { - return c.client.GetCaptcha(ctx, in) -} - -func (c *GatewayServiceGRPC2HTTPBridgeImpl) GetProfile(ctx context.Context, in *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { - return c.client.GetProfile(ctx, in) -} - -func (c *GatewayServiceGRPC2HTTPBridgeImpl) ListUsers(ctx context.Context, in *system.ListUsersRequest) (*system.ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) -} - -func (c *GatewayServiceGRPC2HTTPBridgeImpl) GetUser(ctx context.Context, in *system.GetUserRequest) (*types.User, error) { - return c.client.GetUser(ctx, in) -} - -func (c *GatewayServiceGRPC2HTTPBridgeImpl) CreateUser(ctx context.Context, in *system.CreateUserRequest) (*types.User, error) { - return c.client.CreateUser(ctx, in) -} - -func (c *GatewayServiceGRPC2HTTPBridgeImpl) UpdateUser(ctx context.Context, in *system.UpdateUserRequest) (*types.User, error) { - return c.client.UpdateUser(ctx, in) -} - -func (c *GatewayServiceGRPC2HTTPBridgeImpl) DeleteUser(ctx context.Context, in *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) -} - -type GatewayServiceHTTP2GRPCBridgeImpl struct { - client GatewayServiceHTTPClient -} - -func NewGatewayServiceHTTP2GRPC(client *http.Client) GatewayServiceServer { - return &GatewayServiceHTTP2GRPCBridgeImpl{client: NewGatewayServiceHTTPClient(client)} -} - -func (c *GatewayServiceHTTP2GRPCBridgeImpl) Login(ctx context.Context, in *auth.LoginRequest) (*auth.LoginResponse, error) { - return c.client.Login(ctx, in) -} - -func (c *GatewayServiceHTTP2GRPCBridgeImpl) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { - return c.client.GetCaptcha(ctx, in) -} - -func (c *GatewayServiceHTTP2GRPCBridgeImpl) GetProfile(ctx context.Context, in *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { - return c.client.GetProfile(ctx, in) -} - -func (c *GatewayServiceHTTP2GRPCBridgeImpl) ListUsers(ctx context.Context, in *system.ListUsersRequest) (*system.ListUsersResponse, error) { - return c.client.ListUsers(ctx, in) -} - -func (c *GatewayServiceHTTP2GRPCBridgeImpl) GetUser(ctx context.Context, in *system.GetUserRequest) (*types.User, error) { - return c.client.GetUser(ctx, in) -} - -func (c *GatewayServiceHTTP2GRPCBridgeImpl) CreateUser(ctx context.Context, in *system.CreateUserRequest) (*types.User, error) { - return c.client.CreateUser(ctx, in) -} - -func (c *GatewayServiceHTTP2GRPCBridgeImpl) UpdateUser(ctx context.Context, in *system.UpdateUserRequest) (*types.User, error) { - return c.client.UpdateUser(ctx, in) -} - -func (c *GatewayServiceHTTP2GRPCBridgeImpl) DeleteUser(ctx context.Context, in *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { - return c.client.DeleteUser(ctx, in) -} - -func (c *GatewayServiceHTTP2GRPCBridgeImpl) mustEmbedUnimplementedGatewayServiceServer() {} diff --git a/api/v1/services/gateway/gateway_grpc.pb.go b/api/v1/services/gateway/gateway_grpc.pb.go deleted file mode 100644 index 308eb1d4..00000000 --- a/api/v1/services/gateway/gateway_grpc.pb.go +++ /dev/null @@ -1,402 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc (unknown) -// source: gateway/gateway.proto - -package gateway - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - auth "origadmin/application/admin/api/v1/services/auth" - system "origadmin/application/admin/api/v1/services/system" - types "origadmin/application/admin/api/v1/services/types" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 - -const ( - GatewayService_Login_FullMethodName = "/api.v1.services.gateway.GatewayService/Login" - GatewayService_GetCaptcha_FullMethodName = "/api.v1.services.gateway.GatewayService/GetCaptcha" - GatewayService_GetProfile_FullMethodName = "/api.v1.services.gateway.GatewayService/GetProfile" - GatewayService_ListUsers_FullMethodName = "/api.v1.services.gateway.GatewayService/ListUsers" - GatewayService_GetUser_FullMethodName = "/api.v1.services.gateway.GatewayService/GetUser" - GatewayService_CreateUser_FullMethodName = "/api.v1.services.gateway.GatewayService/CreateUser" - GatewayService_UpdateUser_FullMethodName = "/api.v1.services.gateway.GatewayService/UpdateUser" - GatewayService_DeleteUser_FullMethodName = "/api.v1.services.gateway.GatewayService/DeleteUser" -) - -// GatewayServiceClient is the client API for GatewayService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -// -// GatewayService is the public-facing API gateway. -// It proxies requests to backend services. -type GatewayServiceClient interface { - // --- Auth Service --- - Login(ctx context.Context, in *auth.LoginRequest, opts ...grpc.CallOption) (*auth.LoginResponse, error) - GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest, opts ...grpc.CallOption) (*auth.GetCaptchaResponse, error) - // --- Me Service --- - GetProfile(ctx context.Context, in *auth.GetProfileRequest, opts ...grpc.CallOption) (*auth.GetProfileResponse, error) - // --- System User Service --- - ListUsers(ctx context.Context, in *system.ListUsersRequest, opts ...grpc.CallOption) (*system.ListUsersResponse, error) - GetUser(ctx context.Context, in *system.GetUserRequest, opts ...grpc.CallOption) (*types.User, error) - CreateUser(ctx context.Context, in *system.CreateUserRequest, opts ...grpc.CallOption) (*types.User, error) - UpdateUser(ctx context.Context, in *system.UpdateUserRequest, opts ...grpc.CallOption) (*types.User, error) - DeleteUser(ctx context.Context, in *system.DeleteUserRequest, opts ...grpc.CallOption) (*system.DeleteUserResponse, error) -} - -type gatewayServiceClient struct { - cc grpc.ClientConnInterface -} - -func NewGatewayServiceClient(cc grpc.ClientConnInterface) GatewayServiceClient { - return &gatewayServiceClient{cc} -} - -func (c *gatewayServiceClient) Login(ctx context.Context, in *auth.LoginRequest, opts ...grpc.CallOption) (*auth.LoginResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(auth.LoginResponse) - err := c.cc.Invoke(ctx, GatewayService_Login_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *gatewayServiceClient) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest, opts ...grpc.CallOption) (*auth.GetCaptchaResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(auth.GetCaptchaResponse) - err := c.cc.Invoke(ctx, GatewayService_GetCaptcha_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *gatewayServiceClient) GetProfile(ctx context.Context, in *auth.GetProfileRequest, opts ...grpc.CallOption) (*auth.GetProfileResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(auth.GetProfileResponse) - err := c.cc.Invoke(ctx, GatewayService_GetProfile_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *gatewayServiceClient) ListUsers(ctx context.Context, in *system.ListUsersRequest, opts ...grpc.CallOption) (*system.ListUsersResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(system.ListUsersResponse) - err := c.cc.Invoke(ctx, GatewayService_ListUsers_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *gatewayServiceClient) GetUser(ctx context.Context, in *system.GetUserRequest, opts ...grpc.CallOption) (*types.User, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(types.User) - err := c.cc.Invoke(ctx, GatewayService_GetUser_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *gatewayServiceClient) CreateUser(ctx context.Context, in *system.CreateUserRequest, opts ...grpc.CallOption) (*types.User, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(types.User) - err := c.cc.Invoke(ctx, GatewayService_CreateUser_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *gatewayServiceClient) UpdateUser(ctx context.Context, in *system.UpdateUserRequest, opts ...grpc.CallOption) (*types.User, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(types.User) - err := c.cc.Invoke(ctx, GatewayService_UpdateUser_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *gatewayServiceClient) DeleteUser(ctx context.Context, in *system.DeleteUserRequest, opts ...grpc.CallOption) (*system.DeleteUserResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(system.DeleteUserResponse) - err := c.cc.Invoke(ctx, GatewayService_DeleteUser_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GatewayServiceServer is the server API for GatewayService service. -// All implementations must embed UnimplementedGatewayServiceServer -// for forward compatibility. -// -// GatewayService is the public-facing API gateway. -// It proxies requests to backend services. -type GatewayServiceServer interface { - // --- Auth Service --- - Login(context.Context, *auth.LoginRequest) (*auth.LoginResponse, error) - GetCaptcha(context.Context, *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) - // --- Me Service --- - GetProfile(context.Context, *auth.GetProfileRequest) (*auth.GetProfileResponse, error) - // --- System User Service --- - ListUsers(context.Context, *system.ListUsersRequest) (*system.ListUsersResponse, error) - GetUser(context.Context, *system.GetUserRequest) (*types.User, error) - CreateUser(context.Context, *system.CreateUserRequest) (*types.User, error) - UpdateUser(context.Context, *system.UpdateUserRequest) (*types.User, error) - DeleteUser(context.Context, *system.DeleteUserRequest) (*system.DeleteUserResponse, error) - mustEmbedUnimplementedGatewayServiceServer() -} - -// UnimplementedGatewayServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedGatewayServiceServer struct{} - -func (UnimplementedGatewayServiceServer) Login(context.Context, *auth.LoginRequest) (*auth.LoginResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") -} -func (UnimplementedGatewayServiceServer) GetCaptcha(context.Context, *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetCaptcha not implemented") -} -func (UnimplementedGatewayServiceServer) GetProfile(context.Context, *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetProfile not implemented") -} -func (UnimplementedGatewayServiceServer) ListUsers(context.Context, *system.ListUsersRequest) (*system.ListUsersResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ListUsers not implemented") -} -func (UnimplementedGatewayServiceServer) GetUser(context.Context, *system.GetUserRequest) (*types.User, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented") -} -func (UnimplementedGatewayServiceServer) CreateUser(context.Context, *system.CreateUserRequest) (*types.User, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateUser not implemented") -} -func (UnimplementedGatewayServiceServer) UpdateUser(context.Context, *system.UpdateUserRequest) (*types.User, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateUser not implemented") -} -func (UnimplementedGatewayServiceServer) DeleteUser(context.Context, *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteUser not implemented") -} -func (UnimplementedGatewayServiceServer) mustEmbedUnimplementedGatewayServiceServer() {} -func (UnimplementedGatewayServiceServer) testEmbeddedByValue() {} - -// UnsafeGatewayServiceServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GatewayServiceServer will -// result in compilation errors. -type UnsafeGatewayServiceServer interface { - mustEmbedUnimplementedGatewayServiceServer() -} - -func RegisterGatewayServiceServer(s grpc.ServiceRegistrar, srv GatewayServiceServer) { - // If the following call pancis, it indicates UnimplementedGatewayServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } - s.RegisterService(&GatewayService_ServiceDesc, srv) -} - -func _GatewayService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(auth.LoginRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GatewayServiceServer).Login(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: GatewayService_Login_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GatewayServiceServer).Login(ctx, req.(*auth.LoginRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GatewayService_GetCaptcha_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(auth.GetCaptchaRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GatewayServiceServer).GetCaptcha(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: GatewayService_GetCaptcha_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GatewayServiceServer).GetCaptcha(ctx, req.(*auth.GetCaptchaRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GatewayService_GetProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(auth.GetProfileRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GatewayServiceServer).GetProfile(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: GatewayService_GetProfile_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GatewayServiceServer).GetProfile(ctx, req.(*auth.GetProfileRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GatewayService_ListUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(system.ListUsersRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GatewayServiceServer).ListUsers(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: GatewayService_ListUsers_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GatewayServiceServer).ListUsers(ctx, req.(*system.ListUsersRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GatewayService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(system.GetUserRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GatewayServiceServer).GetUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: GatewayService_GetUser_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GatewayServiceServer).GetUser(ctx, req.(*system.GetUserRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GatewayService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(system.CreateUserRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GatewayServiceServer).CreateUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: GatewayService_CreateUser_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GatewayServiceServer).CreateUser(ctx, req.(*system.CreateUserRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GatewayService_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(system.UpdateUserRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GatewayServiceServer).UpdateUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: GatewayService_UpdateUser_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GatewayServiceServer).UpdateUser(ctx, req.(*system.UpdateUserRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _GatewayService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(system.DeleteUserRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GatewayServiceServer).DeleteUser(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: GatewayService_DeleteUser_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GatewayServiceServer).DeleteUser(ctx, req.(*system.DeleteUserRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// GatewayService_ServiceDesc is the grpc.ServiceDesc for GatewayService service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var GatewayService_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "api.v1.services.gateway.GatewayService", - HandlerType: (*GatewayServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Login", - Handler: _GatewayService_Login_Handler, - }, - { - MethodName: "GetCaptcha", - Handler: _GatewayService_GetCaptcha_Handler, - }, - { - MethodName: "GetProfile", - Handler: _GatewayService_GetProfile_Handler, - }, - { - MethodName: "ListUsers", - Handler: _GatewayService_ListUsers_Handler, - }, - { - MethodName: "GetUser", - Handler: _GatewayService_GetUser_Handler, - }, - { - MethodName: "CreateUser", - Handler: _GatewayService_CreateUser_Handler, - }, - { - MethodName: "UpdateUser", - Handler: _GatewayService_UpdateUser_Handler, - }, - { - MethodName: "DeleteUser", - Handler: _GatewayService_DeleteUser_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "gateway/gateway.proto", -} diff --git a/api/v1/services/gateway/gateway_http.pb.go b/api/v1/services/gateway/gateway_http.pb.go deleted file mode 100644 index bcd2ee40..00000000 --- a/api/v1/services/gateway/gateway_http.pb.go +++ /dev/null @@ -1,357 +0,0 @@ -// Code generated by protoc-gen-go-http. DO NOT EDIT. -// versions: -// - protoc-gen-go-http v2.9.0 -// - protoc (unknown) -// source: gateway/gateway.proto - -package gateway - -import ( - context "context" - http "github.com/go-kratos/kratos/v2/transport/http" - binding "github.com/go-kratos/kratos/v2/transport/http/binding" - auth "origadmin/application/admin/api/v1/services/auth" - system "origadmin/application/admin/api/v1/services/system" - types "origadmin/application/admin/api/v1/services/types" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the kratos package it is being compiled against. -var _ = new(context.Context) -var _ = binding.EncodeURL - -const _ = http.SupportPackageIsVersion1 - -const OperationGatewayServiceCreateUser = "/api.v1.services.gateway.GatewayService/CreateUser" -const OperationGatewayServiceDeleteUser = "/api.v1.services.gateway.GatewayService/DeleteUser" -const OperationGatewayServiceGetCaptcha = "/api.v1.services.gateway.GatewayService/GetCaptcha" -const OperationGatewayServiceGetProfile = "/api.v1.services.gateway.GatewayService/GetProfile" -const OperationGatewayServiceGetUser = "/api.v1.services.gateway.GatewayService/GetUser" -const OperationGatewayServiceListUsers = "/api.v1.services.gateway.GatewayService/ListUsers" -const OperationGatewayServiceLogin = "/api.v1.services.gateway.GatewayService/Login" -const OperationGatewayServiceUpdateUser = "/api.v1.services.gateway.GatewayService/UpdateUser" - -type GatewayServiceHTTPServer interface { - CreateUser(context.Context, *system.CreateUserRequest) (*types.User, error) - DeleteUser(context.Context, *system.DeleteUserRequest) (*system.DeleteUserResponse, error) - GetCaptcha(context.Context, *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) - // GetProfile --- Me Service --- - GetProfile(context.Context, *auth.GetProfileRequest) (*auth.GetProfileResponse, error) - GetUser(context.Context, *system.GetUserRequest) (*types.User, error) - // ListUsers --- System User Service --- - ListUsers(context.Context, *system.ListUsersRequest) (*system.ListUsersResponse, error) - // Login --- Auth Service --- - Login(context.Context, *auth.LoginRequest) (*auth.LoginResponse, error) - UpdateUser(context.Context, *system.UpdateUserRequest) (*types.User, error) -} - -func RegisterGatewayServiceHTTPServer(s *http.Server, srv GatewayServiceHTTPServer) { - r := s.Route("/") - r.POST("/api/v1/login", _GatewayService_Login0_HTTP_Handler(srv)) - r.GET("/api/v1/captcha", _GatewayService_GetCaptcha0_HTTP_Handler(srv)) - r.GET("/api/v1/me/profile", _GatewayService_GetProfile0_HTTP_Handler(srv)) - r.GET("/api/v1/users", _GatewayService_ListUsers0_HTTP_Handler(srv)) - r.GET("/api/v1/users/{id}", _GatewayService_GetUser0_HTTP_Handler(srv)) - r.POST("/api/v1/users", _GatewayService_CreateUser0_HTTP_Handler(srv)) - r.PUT("/api/v1/users/{user.id}", _GatewayService_UpdateUser0_HTTP_Handler(srv)) - r.DELETE("/api/v1/users/{id}", _GatewayService_DeleteUser0_HTTP_Handler(srv)) -} - -func _GatewayService_Login0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in auth.LoginRequest - if err := ctx.Bind(&in); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceLogin) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.Login(ctx, req.(*auth.LoginRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*auth.LoginResponse) - return ctx.Result(200, reply) - } -} - -func _GatewayService_GetCaptcha0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in auth.GetCaptchaRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceGetCaptcha) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetCaptcha(ctx, req.(*auth.GetCaptchaRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*auth.GetCaptchaResponse) - return ctx.Result(200, reply) - } -} - -func _GatewayService_GetProfile0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in auth.GetProfileRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceGetProfile) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetProfile(ctx, req.(*auth.GetProfileRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*auth.GetProfileResponse) - return ctx.Result(200, reply) - } -} - -func _GatewayService_ListUsers0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in system.ListUsersRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceListUsers) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.ListUsers(ctx, req.(*system.ListUsersRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*system.ListUsersResponse) - return ctx.Result(200, reply) - } -} - -func _GatewayService_GetUser0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in system.GetUserRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceGetUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.GetUser(ctx, req.(*system.GetUserRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*types.User) - return ctx.Result(200, reply) - } -} - -func _GatewayService_CreateUser0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in system.CreateUserRequest - if err := ctx.Bind(&in); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceCreateUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.CreateUser(ctx, req.(*system.CreateUserRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*types.User) - return ctx.Result(200, reply) - } -} - -func _GatewayService_UpdateUser0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in system.UpdateUserRequest - if err := ctx.Bind(&in.User); err != nil { - return err - } - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceUpdateUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.UpdateUser(ctx, req.(*system.UpdateUserRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*types.User) - return ctx.Result(200, reply) - } -} - -func _GatewayService_DeleteUser0_HTTP_Handler(srv GatewayServiceHTTPServer) func(ctx http.Context) error { - return func(ctx http.Context) error { - var in system.DeleteUserRequest - if err := ctx.BindQuery(&in); err != nil { - return err - } - if err := ctx.BindVars(&in); err != nil { - return err - } - http.SetOperation(ctx, OperationGatewayServiceDeleteUser) - h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.DeleteUser(ctx, req.(*system.DeleteUserRequest)) - }) - out, err := h(ctx, &in) - if err != nil { - return err - } - reply := out.(*system.DeleteUserResponse) - return ctx.Result(200, reply) - } -} - -type GatewayServiceHTTPClient interface { - CreateUser(ctx context.Context, req *system.CreateUserRequest, opts ...http.CallOption) (rsp *types.User, err error) - DeleteUser(ctx context.Context, req *system.DeleteUserRequest, opts ...http.CallOption) (rsp *system.DeleteUserResponse, err error) - GetCaptcha(ctx context.Context, req *auth.GetCaptchaRequest, opts ...http.CallOption) (rsp *auth.GetCaptchaResponse, err error) - // GetProfile --- Me Service --- - GetProfile(ctx context.Context, req *auth.GetProfileRequest, opts ...http.CallOption) (rsp *auth.GetProfileResponse, err error) - GetUser(ctx context.Context, req *system.GetUserRequest, opts ...http.CallOption) (rsp *types.User, err error) - // ListUsers --- System User Service --- - ListUsers(ctx context.Context, req *system.ListUsersRequest, opts ...http.CallOption) (rsp *system.ListUsersResponse, err error) - // Login --- Auth Service --- - Login(ctx context.Context, req *auth.LoginRequest, opts ...http.CallOption) (rsp *auth.LoginResponse, err error) - UpdateUser(ctx context.Context, req *system.UpdateUserRequest, opts ...http.CallOption) (rsp *types.User, err error) -} - -type GatewayServiceHTTPClientImpl struct { - cc *http.Client -} - -func NewGatewayServiceHTTPClient(client *http.Client) GatewayServiceHTTPClient { - return &GatewayServiceHTTPClientImpl{client} -} - -func (c *GatewayServiceHTTPClientImpl) CreateUser(ctx context.Context, in *system.CreateUserRequest, opts ...http.CallOption) (*types.User, error) { - var out types.User - pattern := "/api/v1/users" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationGatewayServiceCreateUser)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *GatewayServiceHTTPClientImpl) DeleteUser(ctx context.Context, in *system.DeleteUserRequest, opts ...http.CallOption) (*system.DeleteUserResponse, error) { - var out system.DeleteUserResponse - pattern := "/api/v1/users/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationGatewayServiceDeleteUser)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "DELETE", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *GatewayServiceHTTPClientImpl) GetCaptcha(ctx context.Context, in *auth.GetCaptchaRequest, opts ...http.CallOption) (*auth.GetCaptchaResponse, error) { - var out auth.GetCaptchaResponse - pattern := "/api/v1/captcha" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationGatewayServiceGetCaptcha)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// GetProfile --- Me Service --- -func (c *GatewayServiceHTTPClientImpl) GetProfile(ctx context.Context, in *auth.GetProfileRequest, opts ...http.CallOption) (*auth.GetProfileResponse, error) { - var out auth.GetProfileResponse - pattern := "/api/v1/me/profile" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationGatewayServiceGetProfile)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *GatewayServiceHTTPClientImpl) GetUser(ctx context.Context, in *system.GetUserRequest, opts ...http.CallOption) (*types.User, error) { - var out types.User - pattern := "/api/v1/users/{id}" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationGatewayServiceGetUser)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// ListUsers --- System User Service --- -func (c *GatewayServiceHTTPClientImpl) ListUsers(ctx context.Context, in *system.ListUsersRequest, opts ...http.CallOption) (*system.ListUsersResponse, error) { - var out system.ListUsersResponse - pattern := "/api/v1/users" - path := binding.EncodeURL(pattern, in, true) - opts = append(opts, http.Operation(OperationGatewayServiceListUsers)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -// Login --- Auth Service --- -func (c *GatewayServiceHTTPClientImpl) Login(ctx context.Context, in *auth.LoginRequest, opts ...http.CallOption) (*auth.LoginResponse, error) { - var out auth.LoginResponse - pattern := "/api/v1/login" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationGatewayServiceLogin)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} - -func (c *GatewayServiceHTTPClientImpl) UpdateUser(ctx context.Context, in *system.UpdateUserRequest, opts ...http.CallOption) (*types.User, error) { - var out types.User - pattern := "/api/v1/users/{user.id}" - path := binding.EncodeURL(pattern, in, false) - opts = append(opts, http.Operation(OperationGatewayServiceUpdateUser)) - opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) - if err != nil { - return nil, err - } - return &out, nil -} diff --git a/cmd/gateway/wire.go b/cmd/gateway/wire.go index 24fca885..1e940d4e 100644 --- a/cmd/gateway/wire.go +++ b/cmd/gateway/wire.go @@ -16,7 +16,6 @@ import ( "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/gateway/client" "origadmin/application/admin/internal/gateway/server" - "origadmin/application/admin/internal/gateway/service" "origadmin/application/admin/internal/helpers/providers" ) @@ -29,7 +28,6 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err // Service-specific providers server.ProviderSet, client.ProviderSet, - service.ProviderSet, NewApp, )) } diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index f26ff061..d27ca9af 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -24,19 +24,19 @@ var ProviderSet = wire.NewSet( NewSystemClientSet, ) -// AuthClientSet holds all the clients for the 'auth' service. -type AuthClientSet struct { - AuthClient auth.AuthServiceClient - MeClient auth.MeServiceClient +// AuthBridgeSet holds all the clients for the 'auth' service. +type AuthBridgeSet struct { + Auth auth.AuthServiceHTTPServer + Me auth.MeServiceHTTPServer } -// SystemClientSet holds all the clients for the 'system' service. -type SystemClientSet struct { - UserClient system.UserServiceClient - RoleClient system.RoleServiceClient - PermissionClient system.PermissionServiceClient - ResourceClient system.ResourceServiceClient - ViewClient system.ViewServiceClient +// SystemBridgeSet holds all the clients for the 'system' service. +type SystemBridgeSet struct { + User system.UserServiceHTTPServer + Role system.RoleServiceHTTPServer + Permission system.PermissionServiceHTTPServer + Resource system.ResourceServiceHTTPServer + View system.ViewServiceHTTPServer } // NewGRPCConn is a helper to create a gRPC connection from config by name. @@ -64,28 +64,28 @@ func NewGRPCConn(bootstrap *conf.Config, clientName string) (*grpc.ClientConn, e } // NewAuthClientSet creates a set of clients for the auth service. -func NewAuthClientSet(bootstrap *conf.Config) (*AuthClientSet, error) { +func NewAuthClientSet(bootstrap *conf.Config) (*AuthBridgeSet, error) { conn, err := NewGRPCConn(bootstrap, "client.auth") if err != nil { return nil, err } - return &AuthClientSet{ - AuthClient: auth.NewAuthServiceClient(conn), - MeClient: auth.NewMeServiceClient(conn), + return &AuthBridgeSet{ + Auth: auth.NewAuthServiceGRPC2HTTP(conn), + Me: auth.NewMeServiceGRPC2HTTP(conn), }, nil } // NewSystemClientSet creates a set of clients for the system service. -func NewSystemClientSet(bootstrap *conf.Config) (*SystemClientSet, error) { +func NewSystemClientSet(bootstrap *conf.Config) (*SystemBridgeSet, error) { conn, err := NewGRPCConn(bootstrap, "client.system") if err != nil { return nil, err } - return &SystemClientSet{ - UserClient: system.NewUserServiceClient(conn), - RoleClient: system.NewRoleServiceClient(conn), - PermissionClient: system.NewPermissionServiceClient(conn), - ResourceClient: system.NewResourceServiceClient(conn), - ViewClient: system.NewViewServiceClient(conn), + return &SystemBridgeSet{ + User: system.NewUserServiceGRPC2HTTP(conn), + Role: system.NewRoleServiceGRPC2HTTP(conn), + Permission: system.NewPermissionServiceGRPC2HTTP(conn), + Resource: system.NewResourceServiceGRPC2HTTP(conn), + View: system.NewViewServiceGRPC2HTTP(conn), }, nil } diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index 827bdca8..b7481f99 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -6,6 +6,7 @@ package server import ( "errors" + stdhttp "net/http" "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" @@ -60,12 +61,15 @@ func NewServers( } // NewHTTPServer creates a new HTTP server and registers all downstream service handlers. -func NewHTTPServer(app *runtime.App, cfg *httpv1.Server, svc *service.GatewayService, ) (transport.Server, error) { +func NewHTTPServer( + app *runtime.App, + cfg *httpv1.Server, + svc *service.GatewayService, +) (transport.Server, error) { if cfg == nil { return nil, errors.New("http config is nil") } - // 3. Create the server, passing the configured mux. middlewareProvider, err := app.MiddlewareProvider() if err != nil { return nil, err @@ -82,55 +86,23 @@ func NewHTTPServer(app *runtime.App, cfg *httpv1.Server, svc *service.GatewaySer if err != nil { return nil, err } - // 2. Register all services. + // Register all services. registerServices(srv, svc) return srv, nil } -func registerServices(srv *transport.HTTPServer, svc *service.GatewayService) { - system.RegisterUserServiceHTTPServer(srv, svc) - system.RegisterRoleServiceHTTPServer(srv, svc) - system.RegisterPermissionServiceHTTPServer(srv, svc) - system.RegisterResourceServiceHTTPServer(srv, svc) - system.RegisterViewServiceHTTPServer(srv, svc) - auth.RegisterAuthServiceHTTPServer(srv, svc) - auth.RegisterMeServiceHTTPServer(srv, svc) +func registerServices( + srv *transport.HTTPServer, + svc *service.GatewayService, +) { + system.RegisterUserServiceHTTPServer(srv, svc.System.User) + system.RegisterRoleServiceHTTPServer(srv, svc.System.Role) + system.RegisterPermissionServiceHTTPServer(srv, svc.System.Permission) + system.RegisterResourceServiceHTTPServer(srv, svc.System.Resource) + system.RegisterViewServiceHTTPServer(srv, svc.System.View) + auth.RegisterAuthServiceHTTPServer(srv, svc.Auth.Auth) + auth.RegisterMeServiceHTTPServer(srv, svc.Auth.Me) + srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { + log.Infof("HTTP %s %s", method, path) + }) } - -// registerDownstreamServices creates connections and registers handlers to the provided ServeMux. -//func registerDownstreamServices(srv *transport.HTTPServer, cfg *service.GatewayService) error { -// // --- Register System Service --- -// svc, err := client.NewGRPCConn(cfg, "client.system") -// if err != nil { -// return err -// } -// if err := system.RegisterUserServiceHTTPServer(srv, systemConn); err != nil { -// return err -// } -// if err := system.RegisterRoleServiceHTTPServer(srv, systemConn); err != nil { -// return err -// } -// if err := system.RegisterPermissionServiceHTTPServer(srv, systemConn); err != nil { -// return err -// } -// if err := system.RegisterResourceServiceHTTPServer(srv, systemConn); err != nil { -// return err -// } -// if err := system.RegisterViewServiceHTTPServer(srv, systemConn); err != nil { -// return err -// } -// -// // --- Register Auth Service --- -// authConn, err := client.NewGRPCConn(cfg, "client.auth") -// if err != nil { -// return err -// } -// if err := auth.RegisterAuthServiceHTTPServer(srv, authConn); err != nil { -// return err -// } -// if err := auth.RegisterMeServiceHTTPServer(srv, authConn); err != nil { -// return err -// } -// -// return nil -//} diff --git a/internal/gateway/service/service.go b/internal/gateway/service/service.go index 5f4adb00..b69e9675 100644 --- a/internal/gateway/service/service.go +++ b/internal/gateway/service/service.go @@ -7,218 +7,22 @@ package service import ( "github.com/google/wire" - "github.com/origadmin/runtime/context" - "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/gateway/client" ) // ProviderSet is service providers. var ProviderSet = wire.NewSet(NewGatewayService) -// GatewayService is a gateway service. +// GatewayService is a container for downstream service clients. +// It does not implement any gRPC service interfaces itself. The gateway is +// transparent, and HTTP handlers are registered directly with client connections. type GatewayService struct { - Auth *client.AuthClientSet - System *client.SystemClientSet -} - -func (g GatewayService) GetProfile(ctx context.Context, request *auth.GetProfileRequest) (*auth.GetProfileResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) GetUserResources(ctx context.Context, request *auth.GetUserResourcesRequest) (*auth.GetUserResourcesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) GetUserRoles(ctx context.Context, request *auth.GetUserRolesRequest) (*auth.GetUserRolesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) UpdatePassword(ctx context.Context, request *auth.UpdatePasswordRequest) (*auth.UpdatePasswordResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) UpdateProfile(ctx context.Context, request *auth.UpdateProfileRequest) (*auth.UpdateProfileResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) GetCaptcha(ctx context.Context, request *auth.GetCaptchaRequest) (*auth.GetCaptchaResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) Login(ctx context.Context, request *auth.LoginRequest) (*auth.LoginResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) Logout(ctx context.Context, request *auth.LogoutRequest) (*auth.LogoutResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) RefreshToken(ctx context.Context, request *auth.RefreshTokenRequest) (*auth.RefreshTokenResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) Register(ctx context.Context, request *auth.RegisterRequest) (*auth.RegisterResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) CreateView(ctx context.Context, request *system.CreateViewRequest) (*system.CreateViewResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) DeleteView(ctx context.Context, request *system.DeleteViewRequest) (*system.DeleteViewResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) GetView(ctx context.Context, request *system.GetViewRequest) (*system.GetViewResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) ListViews(ctx context.Context, request *system.ListViewsRequest) (*system.ListViewsResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) UpdateView(ctx context.Context, request *system.UpdateViewRequest) (*system.UpdateViewResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) CreateResource(ctx context.Context, request *system.CreateResourceRequest) (*system.CreateResourceResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) DeleteResource(ctx context.Context, request *system.DeleteResourceRequest) (*system.DeleteResourceResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) GetResource(ctx context.Context, request *system.GetResourceRequest) (*system.GetResourceResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) ListResources(ctx context.Context, request *system.ListResourcesRequest) (*system.ListResourcesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) UpdateResource(ctx context.Context, request *system.UpdateResourceRequest) (*system.UpdateResourceResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) CreatePermission(ctx context.Context, request *system.CreatePermissionRequest) (*system.CreatePermissionResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) DeletePermission(ctx context.Context, request *system.DeletePermissionRequest) (*system.DeletePermissionResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) GetPermission(ctx context.Context, request *system.GetPermissionRequest) (*system.GetPermissionResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) ListPermissions(ctx context.Context, request *system.ListPermissionsRequest) (*system.ListPermissionsResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) UpdatePermission(ctx context.Context, request *system.UpdatePermissionRequest) (*system.UpdatePermissionResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) CreateRole(ctx context.Context, request *system.CreateRoleRequest) (*system.CreateRoleResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) DeleteRole(ctx context.Context, request *system.DeleteRoleRequest) (*system.DeleteRoleResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) GetRole(ctx context.Context, request *system.GetRoleRequest) (*system.GetRoleResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) ListRoles(ctx context.Context, request *system.ListRolesRequest) (*system.ListRolesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) UpdateRole(ctx context.Context, request *system.UpdateRoleRequest) (*system.UpdateRoleResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) CreateUser(ctx context.Context, request *system.CreateUserRequest) (*system.CreateUserResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) DeleteUser(ctx context.Context, request *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) GetUser(ctx context.Context, request *system.GetUserRequest) (*system.GetUserResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) ListUserResources(ctx context.Context, request *system.ListUserResourcesRequest) (*system.ListUserResourcesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) ListUsers(ctx context.Context, request *system.ListUsersRequest) (*system.ListUsersResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) ResetUserPassword(ctx context.Context, request *system.ResetUserPasswordRequest) (*system.ResetUserPasswordResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) UpdateUser(ctx context.Context, request *system.UpdateUserRequest) (*system.UpdateUserResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) UpdateUserRoles(ctx context.Context, request *system.UpdateUserRolesRequest) (*system.UpdateUserRolesResponse, error) { - //TODO implement me - panic("implement me") -} - -func (g GatewayService) UpdateUserStatus(ctx context.Context, request *system.UpdateUserStatusRequest) (*system.UpdateUserStatusResponse, error) { - //TODO implement me - panic("implement me") + Auth *client.AuthBridgeSet + System *client.SystemBridgeSet } // NewGatewayService new a gateway service. -func NewGatewayService(authClient *client.AuthClientSet, systemClient *client.SystemClientSet) (*GatewayService, error) { +func NewGatewayService(authClient *client.AuthBridgeSet, systemClient *client.SystemBridgeSet) (*GatewayService, error) { return &GatewayService{ Auth: authClient, System: systemClient, From 6d80b9ac802bf50888a1cbb4f6281ade95d43eef Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 15:32:30 +0800 Subject: [PATCH 121/158] refactor(gateway): consolidate service registration and improve error messages --- internal/gateway/client/client.go | 9 ++++---- internal/gateway/server/server.go | 23 ++---------------- internal/gateway/service/service.go | 36 +++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index d27ca9af..51ca2633 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -6,7 +6,7 @@ package client import ( "context" - "errors" + "fmt" "github.com/google/wire" "google.golang.org/grpc" @@ -39,7 +39,8 @@ type SystemBridgeSet struct { View system.ViewServiceHTTPServer } -// NewGRPCConn is a helper to create a gRPC connection from config by name. +// NewGRPCConn finds a client configuration by name from the bootstrap config +// and establishes a gRPC connection. func NewGRPCConn(bootstrap *conf.Config, clientName string) (*grpc.ClientConn, error) { var clientConfig *transportv1.Client if bootstrap.Bootstrap.Clients != nil { @@ -52,12 +53,12 @@ func NewGRPCConn(bootstrap *conf.Config, clientName string) (*grpc.ClientConn, e } if clientConfig == nil { - return nil, errors.New("client config not found: " + clientName) + return nil, fmt.Errorf("client config not found: %s", clientName) } grpcConfig := clientConfig.GetGrpc() if grpcConfig == nil { - return nil, errors.New("grpc client config not found: " + clientName) + return nil, fmt.Errorf("gRPC client config not found for: %s", clientName) } return runtimegrpc.NewClient(context.Background(), grpcConfig, &runtimegrpc.ClientOptions{}) diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index b7481f99..bda29bcf 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -6,7 +6,6 @@ package server import ( "errors" - stdhttp "net/http" "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" @@ -16,8 +15,6 @@ import ( transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" "github.com/origadmin/runtime/service/transport" "github.com/origadmin/runtime/service/transport/http" - "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/gateway/service" ) @@ -86,23 +83,7 @@ func NewHTTPServer( if err != nil { return nil, err } - // Register all services. - registerServices(srv, svc) + // Register all services using the GatewayService method. + svc.RegisterHTTPHandlers(srv) return srv, nil } - -func registerServices( - srv *transport.HTTPServer, - svc *service.GatewayService, -) { - system.RegisterUserServiceHTTPServer(srv, svc.System.User) - system.RegisterRoleServiceHTTPServer(srv, svc.System.Role) - system.RegisterPermissionServiceHTTPServer(srv, svc.System.Permission) - system.RegisterResourceServiceHTTPServer(srv, svc.System.Resource) - system.RegisterViewServiceHTTPServer(srv, svc.System.View) - auth.RegisterAuthServiceHTTPServer(srv, svc.Auth.Auth) - auth.RegisterMeServiceHTTPServer(srv, svc.Auth.Me) - srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { - log.Infof("HTTP %s %s", method, path) - }) -} diff --git a/internal/gateway/service/service.go b/internal/gateway/service/service.go index b69e9675..7b41348a 100644 --- a/internal/gateway/service/service.go +++ b/internal/gateway/service/service.go @@ -5,26 +5,54 @@ package service import ( + stdhttp "net/http" + "github.com/google/wire" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service/transport" + "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/gateway/client" ) // ProviderSet is service providers. var ProviderSet = wire.NewSet(NewGatewayService) -// GatewayService is a container for downstream service clients. -// It does not implement any gRPC service interfaces itself. The gateway is -// transparent, and HTTP handlers are registered directly with client connections. +// GatewayService acts as a dependency injection container for the various +// generated bridge sets. Each bridge set contains the client-side logic +// to forward requests to a specific downstream gRPC service. +// This approach avoids implementing downstream service interfaces directly in the gateway. type GatewayService struct { Auth *client.AuthBridgeSet System *client.SystemBridgeSet } -// NewGatewayService new a gateway service. +// NewGatewayService creates a new GatewayService, aggregating the generated +// bridge clients for all downstream services. func NewGatewayService(authClient *client.AuthBridgeSet, systemClient *client.SystemBridgeSet) (*GatewayService, error) { return &GatewayService{ Auth: authClient, System: systemClient, }, nil } + +// RegisterHTTPHandlers registers all the HTTP handlers for the downstream services +// onto the provided HTTP server. It also logs the registered routes. +func (s *GatewayService) RegisterHTTPHandlers(srv *transport.HTTPServer) { + // Register handlers for the 'system' service + system.RegisterUserServiceHTTPServer(srv, s.System.User) + system.RegisterRoleServiceHTTPServer(srv, s.System.Role) + system.RegisterPermissionServiceHTTPServer(srv, s.System.Permission) + system.RegisterResourceServiceHTTPServer(srv, s.System.Resource) + system.RegisterViewServiceHTTPServer(srv, s.System.View) + + // Register handlers for the 'auth' service + auth.RegisterAuthServiceHTTPServer(srv, s.Auth.Auth) + auth.RegisterMeServiceHTTPServer(srv, s.Auth.Me) + + // Log all registered HTTP routes for debugging and verification + srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { + log.Infof("HTTP %s %s", method, path) + }) +} From f8b3ee27a173c98d926c84a8fe7e55713dc6c719 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 15:37:46 +0800 Subject: [PATCH 122/158] refactor(gateway): update service name to "origadmin.server.gateway --- cmd/gateway/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gateway/main.go b/cmd/gateway/main.go index 95f32cf0..982b950c 100644 --- a/cmd/gateway/main.go +++ b/cmd/gateway/main.go @@ -20,7 +20,7 @@ import ( var ( // Name is the name of the compiled software. - Name = "origadmin.gateway.v1" + Name = "origadmin.server.gateway" // Version is the version of the compiled software. Version = "v1.0.0" From 0580b79ae91bfd65a66411bf839c56c9c483398d Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 16:04:59 +0800 Subject: [PATCH 123/158] feat(gateway): enhance client service discovery with smart name matching and constants --- internal/gateway/client/client.go | 43 ++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index 51ca2633..13b899c3 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -24,6 +24,13 @@ var ProviderSet = wire.NewSet( NewSystemClientSet, ) +const ( + // ServiceNameAuth is the short name for the auth service. + ServiceNameAuth = "auth" + // ServiceNameSystem is the short name for the system service. + ServiceNameSystem = "system" +) + // AuthBridgeSet holds all the clients for the 'auth' service. type AuthBridgeSet struct { Auth auth.AuthServiceHTTPServer @@ -39,13 +46,28 @@ type SystemBridgeSet struct { View system.ViewServiceHTTPServer } -// NewGRPCConn finds a client configuration by name from the bootstrap config +// NewGRPCConn finds a client configuration by service name or convention // and establishes a gRPC connection. -func NewGRPCConn(bootstrap *conf.Config, clientName string) (*grpc.ClientConn, error) { +// +// It implements smart matching logic: +// 1. Capability Check: It ignores configs that do not have a 'grpc' section. +// 2. Name Matching: It matches if the config name equals the input name (e.g., "auth") +// OR the conventional name (e.g., "origadmin.service.auth.client.grpc"). +func NewGRPCConn(bootstrap *conf.Config, name string) (*grpc.ClientConn, error) { var clientConfig *transportv1.Client + + // The conventional name for gRPC clients + convention := fmt.Sprintf("origadmin.service.%s.client.grpc", name) + if bootstrap.Bootstrap.Clients != nil { for _, cli := range bootstrap.Bootstrap.Clients.Configs { - if cli.Name == clientName { + // Capability Check: Must have gRPC config + if cli.GetGrpc() == nil { + continue + } + + // Smart Matching: Match exact name OR convention name + if cli.Name == name || cli.Name == convention { clientConfig = cli break } @@ -53,20 +75,16 @@ func NewGRPCConn(bootstrap *conf.Config, clientName string) (*grpc.ClientConn, e } if clientConfig == nil { - return nil, fmt.Errorf("client config not found: %s", clientName) - } - - grpcConfig := clientConfig.GetGrpc() - if grpcConfig == nil { - return nil, fmt.Errorf("gRPC client config not found for: %s", clientName) + return nil, fmt.Errorf("gRPC client config not found for service: %s (checked name: '%s' and '%s')", name, name, convention) } - return runtimegrpc.NewClient(context.Background(), grpcConfig, &runtimegrpc.ClientOptions{}) + return runtimegrpc.NewClient(context.Background(), clientConfig.GetGrpc(), &runtimegrpc.ClientOptions{}) } // NewAuthClientSet creates a set of clients for the auth service. func NewAuthClientSet(bootstrap *conf.Config) (*AuthBridgeSet, error) { - conn, err := NewGRPCConn(bootstrap, "client.auth") + // Pass the simple service name. The helper handles the smart matching. + conn, err := NewGRPCConn(bootstrap, ServiceNameAuth) if err != nil { return nil, err } @@ -78,7 +96,8 @@ func NewAuthClientSet(bootstrap *conf.Config) (*AuthBridgeSet, error) { // NewSystemClientSet creates a set of clients for the system service. func NewSystemClientSet(bootstrap *conf.Config) (*SystemBridgeSet, error) { - conn, err := NewGRPCConn(bootstrap, "client.system") + // Pass the simple service name. The helper handles the smart matching. + conn, err := NewGRPCConn(bootstrap, ServiceNameSystem) if err != nil { return nil, err } From 1ce229f2d2a1349dbe5c0fe50e9ac62ec0939610 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 16:23:55 +0800 Subject: [PATCH 124/158] feat(gateway): refactor client connections to use app context and rename client sets to bridge sets --- cmd/gateway/wire.go | 2 ++ cmd/gateway/wire_gen.go | 6 +++--- internal/gateway/client/client.go | 33 +++++++++++++++---------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/cmd/gateway/wire.go b/cmd/gateway/wire.go index 1e940d4e..4bb0c77d 100644 --- a/cmd/gateway/wire.go +++ b/cmd/gateway/wire.go @@ -16,6 +16,7 @@ import ( "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/gateway/client" "origadmin/application/admin/internal/gateway/server" + "origadmin/application/admin/internal/gateway/service" "origadmin/application/admin/internal/helpers/providers" ) @@ -27,6 +28,7 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err // Service-specific providers server.ProviderSet, + service.ProviderSet, client.ProviderSet, NewApp, )) diff --git a/cmd/gateway/wire_gen.go b/cmd/gateway/wire_gen.go index 85b912f7..deb0fc59 100644 --- a/cmd/gateway/wire_gen.go +++ b/cmd/gateway/wire_gen.go @@ -28,15 +28,15 @@ import ( func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { confpbBootstrap := &bootstrap.Bootstrap servers := confpbBootstrap.Servers - authClientSet, err := client.NewAuthClientSet(bootstrap) + authBridgeSet, err := client.NewAuthBridgeSet(app, bootstrap) if err != nil { return nil, nil, err } - systemClientSet, err := client.NewSystemClientSet(bootstrap) + systemBridgeSet, err := client.NewSystemBridgeSet(app, bootstrap) if err != nil { return nil, nil, err } - gatewayService, err := service.NewGatewayService(authClientSet, systemClientSet) + gatewayService, err := service.NewGatewayService(authBridgeSet, systemBridgeSet) if err != nil { return nil, nil, err } diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index 13b899c3..4eb51dc4 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -11,6 +11,7 @@ import ( "github.com/google/wire" "google.golang.org/grpc" + "github.com/origadmin/runtime" transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" runtimegrpc "github.com/origadmin/runtime/service/transport/grpc" "origadmin/application/admin/api/v1/services/auth" @@ -20,8 +21,8 @@ import ( // ProviderSet is client providers. var ProviderSet = wire.NewSet( - NewAuthClientSet, - NewSystemClientSet, + NewAuthBridgeSet, + NewSystemBridgeSet, ) const ( @@ -49,13 +50,10 @@ type SystemBridgeSet struct { // NewGRPCConn finds a client configuration by service name or convention // and establishes a gRPC connection. // -// It implements smart matching logic: -// 1. Capability Check: It ignores configs that do not have a 'grpc' section. -// 2. Name Matching: It matches if the config name equals the input name (e.g., "auth") -// OR the conventional name (e.g., "origadmin.service.auth.client.grpc"). -func NewGRPCConn(bootstrap *conf.Config, name string) (*grpc.ClientConn, error) { +// The provided context is used for the client lifecycle. +func NewGRPCConn(ctx context.Context, bootstrap *conf.Config, name string) (*grpc.ClientConn, error) { var clientConfig *transportv1.Client - + // The conventional name for gRPC clients convention := fmt.Sprintf("origadmin.service.%s.client.grpc", name) @@ -78,13 +76,14 @@ func NewGRPCConn(bootstrap *conf.Config, name string) (*grpc.ClientConn, error) return nil, fmt.Errorf("gRPC client config not found for service: %s (checked name: '%s' and '%s')", name, name, convention) } - return runtimegrpc.NewClient(context.Background(), clientConfig.GetGrpc(), &runtimegrpc.ClientOptions{}) + return runtimegrpc.NewClient(ctx, clientConfig.GetGrpc(), &runtimegrpc.ClientOptions{}) } -// NewAuthClientSet creates a set of clients for the auth service. -func NewAuthClientSet(bootstrap *conf.Config) (*AuthBridgeSet, error) { - // Pass the simple service name. The helper handles the smart matching. - conn, err := NewGRPCConn(bootstrap, ServiceNameAuth) +// NewAuthBridgeSet creates a set of clients for the auth service. +func NewAuthBridgeSet(app *runtime.App, bootstrap *conf.Config) (*AuthBridgeSet, error) { + // Use the application's root context. This ensures that the client's lifecycle + // is tied to the application's lifecycle. + conn, err := NewGRPCConn(app.Context(), bootstrap, ServiceNameAuth) if err != nil { return nil, err } @@ -94,10 +93,10 @@ func NewAuthClientSet(bootstrap *conf.Config) (*AuthBridgeSet, error) { }, nil } -// NewSystemClientSet creates a set of clients for the system service. -func NewSystemClientSet(bootstrap *conf.Config) (*SystemBridgeSet, error) { - // Pass the simple service name. The helper handles the smart matching. - conn, err := NewGRPCConn(bootstrap, ServiceNameSystem) +// NewSystemBridgeSet creates a set of clients for the system service. +func NewSystemBridgeSet(app *runtime.App, bootstrap *conf.Config) (*SystemBridgeSet, error) { + // Use the application's root context. + conn, err := NewGRPCConn(app.Context(), bootstrap, ServiceNameSystem) if err != nil { return nil, err } From 42a8ff6e86cb729bc4d9c8c282946f9c43c9e74c Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 17:33:49 +0800 Subject: [PATCH 125/158] feat(config): add direct getter methods and refactor config access patterns --- go.mod | 6 +-- internal/conf/config.go | 89 ++++++++++++++++++++++++++----- internal/gateway/client/client.go | 6 ++- 3 files changed, 82 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index a0a16444..59864c9b 100644 --- a/go.mod +++ b/go.mod @@ -4,9 +4,9 @@ go 1.25.3 replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0.5.4 -//replace github.com/origadmin/runtime v0.2.15 => ../../runtime -// -//replace github.com/origadmin/contrib v1.1.0 => ../../contrib +replace github.com/origadmin/runtime v0.2.15 => ../../runtime + +replace github.com/origadmin/contrib v1.1.0 => ../../contrib require ( entgo.io/ent v0.14.5 diff --git a/internal/conf/config.go b/internal/conf/config.go index 55a95d78..1758e2fd 100644 --- a/internal/conf/config.go +++ b/internal/conf/config.go @@ -16,52 +16,114 @@ type Config struct { Bootstrap confpb.Bootstrap } +// Data returns the data configuration. +func (c *Config) Data() *datav1.Data { + return c.Bootstrap.GetData() +} + +// Caches returns the caches configuration. +func (c *Config) Caches() *datav1.Caches { + return c.Bootstrap.GetData().GetCaches() +} + +// Databases returns the databases configuration. +func (c *Config) Databases() *datav1.Databases { + return c.Bootstrap.GetData().GetDatabases() +} + +// ObjectStores returns the object stores configuration. +func (c *Config) ObjectStores() *datav1.ObjectStores { + return c.Bootstrap.GetData().GetObjectStores() +} + +// DefaultDiscovery returns the default discovery name. +func (c *Config) DefaultDiscovery() string { + return c.Bootstrap.GetDefaultDiscovery() +} + +// Discoveries returns the discoveries configuration. +func (c *Config) Discoveries() *discoveryv1.Discoveries { + return c.Bootstrap.GetDiscoveries() +} + +// Logger returns the logger configuration. +func (c *Config) Logger() *loggerv1.Logger { + return c.Bootstrap.GetLogger() +} + +// Middlewares returns the middlewares configuration. +func (c *Config) Middlewares() *middlewarev1.Middlewares { + return c.Bootstrap.GetMiddlewares() +} + +// Servers returns the servers configuration. +func (c *Config) Servers() *transportv1.Servers { + return c.Bootstrap.GetServers() +} + +// Clients returns the clients configuration. +func (c *Config) Clients() *transportv1.Clients { + return c.Bootstrap.GetClients() +} + +// Captcha returns the captcha configuration. +func (c *Config) Captcha() *confpb.Captcha { + return c.Bootstrap.GetCaptcha() +} + +// RootUser returns the root user configuration. +func (c *Config) RootUser() *confpb.RootUser { + return c.Bootstrap.GetRootUser() +} + +// --- Runtime Interface Adapters (Deprecated: Use direct getters above) --- + func (c *Config) DecodeData() (*datav1.Data, error) { - return c.Bootstrap.GetData(), nil + return c.Data(), nil } func (c *Config) DecodeCaches() (*datav1.Caches, error) { - return c.Bootstrap.GetData().GetCaches(), nil + return c.Caches(), nil } func (c *Config) DecodeDatabases() (*datav1.Databases, error) { - return c.Bootstrap.GetData().GetDatabases(), nil + return c.Databases(), nil } func (c *Config) DecodeObjectStores() (*datav1.ObjectStores, error) { - return c.Bootstrap.GetData().GetObjectStores(), nil + return c.ObjectStores(), nil } func (c *Config) DecodeDefaultDiscovery() (string, error) { - return c.Bootstrap.GetDefaultDiscovery(), nil + return c.DefaultDiscovery(), nil } func (c *Config) DecodeDiscoveries() (*discoveryv1.Discoveries, error) { - return c.Bootstrap.GetDiscoveries(), nil + return c.Discoveries(), nil } func (c *Config) DecodeLogger() (*loggerv1.Logger, error) { - return c.Bootstrap.GetLogger(), nil + return c.Logger(), nil } func (c *Config) DecodeMiddlewares() (*middlewarev1.Middlewares, error) { - return c.Bootstrap.GetMiddlewares(), nil + return c.Middlewares(), nil } func (c *Config) DecodeServers() (*transportv1.Servers, error) { - return c.Bootstrap.GetServers(), nil + return c.Servers(), nil } func (c *Config) DecodeClients() (*transportv1.Clients, error) { - return c.Bootstrap.GetClients(), nil + return c.Clients(), nil } func (c *Config) GetCaptcha() (*confpb.Captcha, error) { - return c.Bootstrap.GetCaptcha(), nil + return c.Captcha(), nil } func (c *Config) GetRootUser() (*confpb.RootUser, error) { - return c.Bootstrap.GetRootUser(), nil + return c.RootUser(), nil } func (c *Config) GetBootstrap() *confpb.Bootstrap { @@ -72,8 +134,7 @@ func (c *Config) DecodedConfig() any { return &c.Bootstrap } -func (c *Config) Transform(config interfaces.Config, sc interfaces.StructuredConfig) (interfaces. -StructuredConfig, error) { +func (c *Config) Transform(config interfaces.ConfigLoader, sc interfaces.StructuredConfig) (interfaces.StructuredConfig, error) { err := config.Decode("", &c.Bootstrap) if err != nil { return nil, err diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index 4eb51dc4..641e45f4 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -57,8 +57,10 @@ func NewGRPCConn(ctx context.Context, bootstrap *conf.Config, name string) (*grp // The conventional name for gRPC clients convention := fmt.Sprintf("origadmin.service.%s.client.grpc", name) - if bootstrap.Bootstrap.Clients != nil { - for _, cli := range bootstrap.Bootstrap.Clients.Configs { + // Use the new, cleaner getter method + clients := bootstrap.Clients() + if clients != nil { + for _, cli := range clients.Configs { // Capability Check: Must have gRPC config if cli.GetGrpc() == nil { continue From d4858f6cffa2ca15bdad7ed5f45a0f0f3c057c3f Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 18:02:23 +0800 Subject: [PATCH 126/158] feat(system): refactor service layer to use individual services with dependency injection --- cmd/system/wire_gen.go | 9 +- internal/features/system/biz/view.go | 4 +- internal/features/system/server/server.go | 84 +++++++++++-------- .../features/system/service/permission.go | 30 ++++--- internal/features/system/service/provider.go | 7 +- internal/features/system/service/resource.go | 30 ++++--- internal/features/system/service/role.go | 30 ++++--- internal/features/system/service/service.go | 33 +++----- internal/features/system/service/user.go | 46 ++++++---- internal/features/system/service/view.go | 30 ++++--- internal/gateway/server/server.go | 1 + resources/configs/clients.yaml | 8 +- 12 files changed, 189 insertions(+), 123 deletions(-) diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index d830a2d5..6b0d39f6 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -42,8 +42,10 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err } resourceRepo := dal.NewResourceRepo(database) resourceUseCase := biz.NewResourceUseCase(resourceRepo) + resourceService := service.NewResourceService(resourceUseCase) roleRepo := dal.NewRoleRepo(database) roleUseCase := biz.NewRoleUseCase(roleRepo) + roleService := service.NewRoleService(roleUseCase) userRepo := dal.NewUserRepo(database) crypto, err := providers.ProvideHasher() if err != nil { @@ -51,12 +53,15 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err return nil, nil, err } userUseCase := biz.NewUserUseCase(userRepo, crypto) + userService := service.NewUserService(userUseCase) permissionRepo := dal.NewPermissionRepo(database) permissionUseCase := biz.NewPermissionUseCase(permissionRepo) + permissionService := service.NewPermissionService(permissionUseCase) viewRepo := dal.NewViewRepo(database) viewUseCase := biz.NewViewUseCase(viewRepo) - systemService := service.New(resourceUseCase, roleUseCase, userUseCase, permissionUseCase, viewUseCase) - v2, err := server.NewServers(servers, systemService, v) + viewService := service.NewViewService(viewUseCase) + systemService := service.NewSystemService(resourceService, roleService, userService, permissionService, viewService) + v2, err := server.NewServers(app, servers, systemService, v) if err != nil { cleanup() return nil, nil, err diff --git a/internal/features/system/biz/view.go b/internal/features/system/biz/view.go index 82a8b4a6..d2db3fa8 100644 --- a/internal/features/system/biz/view.go +++ b/internal/features/system/biz/view.go @@ -33,8 +33,8 @@ func (uc *ViewUseCase) GetView(ctx context.Context, id int64) (*types.View, erro // CreateView creates a new view, ensuring essential fields have valid default values. func (uc *ViewUseCase) CreateView(ctx context.Context, in *types.View) (*types.View, error) { // The backend must always enforce data integrity, regardless of frontend behavior. - if in.Type == "" || in.Type == enums.ViewTypeUnknown.String() { - in.Type = enums.ViewTypePage.String() + if in.Type == "" || in.Type == dto.ViewTypeUnknown.String() { + in.Type = dto.ViewTypePage.String() } if in.Status == 0 { in.Status = int32(enums.StatusEnabled) diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index 6cfb136d..aa73ed9a 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -8,25 +8,26 @@ import ( "errors" stdhttp "net/http" - "github.com/go-kratos/kratos/v2/transport" - "github.com/go-kratos/kratos/v2/transport/grpc" - "github.com/go-kratos/kratos/v2/transport/http" "github.com/google/wire" - "github.com/origadmin/runtime/log" - systemv1 "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/service" - + "github.com/origadmin/runtime" grpcv1 "github.com/origadmin/runtime/api/gen/go/config/transport/grpc/v1" httpv1 "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1" transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service/transport" + "github.com/origadmin/runtime/service/transport/grpc" + "github.com/origadmin/runtime/service/transport/http" + systemv1 "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/internal/features/system/service" ) // ProviderSet is server providers. var ProviderSet = wire.NewSet(NewServers) // NewServers creates and configures the system service servers (gRPC, HTTP). -func NewServers(cfg *transportv1.Servers, svc *service.SystemService, logger log.Logger) ([]transport.Server, error) { +func NewServers(app *runtime.App, cfg *transportv1.Servers, svc *service.SystemService, logger log.Logger) ([]transport.Server, + error) { if cfg == nil { return nil, errors.New("servers config is nil") } @@ -35,13 +36,13 @@ func NewServers(cfg *transportv1.Servers, svc *service.SystemService, logger log for _, serverCfg := range cfg.GetConfigs() { switch serverCfg.GetProtocol() { case "http": - srv, err := NewHTTPServer(serverCfg.GetHttp(), svc, logger) + srv, err := NewHTTPServer(app, serverCfg.GetHttp(), svc, logger) if err != nil { return nil, err } transportServers = append(transportServers, srv) case "grpc": - srv, err := NewGRPCServer(serverCfg.GetGrpc(), svc, logger) + srv, err := NewGRPCServer(app, serverCfg.GetGrpc(), svc, logger) if err != nil { return nil, err } @@ -54,26 +55,34 @@ func NewServers(cfg *transportv1.Servers, svc *service.SystemService, logger log } // NewHTTPServer new an HTTP server. -func NewHTTPServer(cfg *httpv1.Server, svc *service.SystemService, logger log.Logger) (*http.Server, error) { +func NewHTTPServer(app *runtime.App, cfg *httpv1.Server, svc *service.SystemService, logger log.Logger) (*transport.HTTPServer, error) { if cfg == nil { return nil, errors.New("http config is nil") } - var opts []http.ServerOption - if cfg.GetAddr() != "" { - opts = append(opts, http.Address(cfg.GetAddr())) + middlewareProvider, err := app.MiddlewareProvider() + if err != nil { + return nil, err + } + mws, err := middlewareProvider.ServerMiddlewares() + if err != nil { + return nil, err + } + opts := &http.ServerOptions{ + ServerMiddlewares: mws, } - if cfg.GetTimeout() != nil { - opts = append(opts, http.Timeout(cfg.GetTimeout().AsDuration())) + + srv, err := http.NewServer(cfg, opts) + if err != nil { + return nil, err } - srv := http.NewServer(opts...) // Register HTTP handlers - systemv1.RegisterUserServiceHTTPServer(srv, svc) - systemv1.RegisterRoleServiceHTTPServer(srv, svc) - systemv1.RegisterPermissionServiceHTTPServer(srv, svc) - systemv1.RegisterResourceServiceHTTPServer(srv, svc) - systemv1.RegisterViewServiceHTTPServer(srv, svc) + systemv1.RegisterUserServiceHTTPServer(srv, svc.User) + systemv1.RegisterRoleServiceHTTPServer(srv, svc.Role) + systemv1.RegisterPermissionServiceHTTPServer(srv, svc.Permission) + systemv1.RegisterResourceServiceHTTPServer(srv, svc.Resource) + systemv1.RegisterViewServiceHTTPServer(srv, svc.View) srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { log.Infof("HTTP %s %s", method, path) }) @@ -81,26 +90,33 @@ func NewHTTPServer(cfg *httpv1.Server, svc *service.SystemService, logger log.Lo } // NewGRPCServer new a gRPC server. -func NewGRPCServer(cfg *grpcv1.Server, svc *service.SystemService, logger log.Logger) (*grpc.Server, error) { +func NewGRPCServer(app *runtime.App, cfg *grpcv1.Server, svc *service.SystemService, logger log.Logger) (*transport.GRPCServer, error) { if cfg == nil { return nil, errors.New("grpc config is nil") } - var opts []grpc.ServerOption - if cfg.GetAddr() != "" { - opts = append(opts, grpc.Address(cfg.GetAddr())) + middlewareProvider, err := app.MiddlewareProvider() + if err != nil { + return nil, err + } + mws, err := middlewareProvider.ServerMiddlewares() + if err != nil { + return nil, err + } + opts := &grpc.ServerOptions{ + ServerMiddlewares: mws, } - if cfg.GetTimeout() != nil { - opts = append(opts, grpc.Timeout(cfg.GetTimeout().AsDuration())) + srv, err := grpc.NewServer(cfg, opts) + if err != nil { + return nil, err } - srv := grpc.NewServer(opts...) // Register gRPC handlers - systemv1.RegisterUserServiceServer(srv, svc) - systemv1.RegisterRoleServiceServer(srv, svc) - systemv1.RegisterPermissionServiceServer(srv, svc) - systemv1.RegisterResourceServiceServer(srv, svc) - systemv1.RegisterViewServiceServer(srv, svc) + systemv1.RegisterUserServiceServer(srv, svc.User) + systemv1.RegisterRoleServiceServer(srv, svc.Role) + systemv1.RegisterPermissionServiceServer(srv, svc.Permission) + systemv1.RegisterResourceServiceServer(srv, svc.Resource) + systemv1.RegisterViewServiceServer(srv, svc.View) return srv, nil } diff --git a/internal/features/system/service/permission.go b/internal/features/system/service/permission.go index cb7f5f46..f12dea14 100644 --- a/internal/features/system/service/permission.go +++ b/internal/features/system/service/permission.go @@ -10,10 +10,20 @@ import ( "github.com/origadmin/runtime/errors" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/features/system/biz" ) -func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPermissionsRequest) (*system.ListPermissionsResponse, error) { - permissions, total, err := s.Permission.ListPermissions(ctx, req) +type PermissionService struct { + system.UnimplementedPermissionServiceServer + uc *biz.PermissionUseCase +} + +func NewPermissionService(uc *biz.PermissionUseCase) *PermissionService { + return &PermissionService{uc: uc} +} + +func (s *PermissionService) ListPermissions(ctx context.Context, req *system.ListPermissionsRequest) (*system.ListPermissionsResponse, error) { + permissions, total, err := s.uc.ListPermissions(ctx, req) if err != nil { return nil, err } @@ -25,8 +35,8 @@ func (s *SystemService) ListPermissions(ctx context.Context, req *system.ListPer }, nil } -func (s *SystemService) GetPermission(ctx context.Context, req *system.GetPermissionRequest) (*system.GetPermissionResponse, error) { - permission, err := s.Permission.GetPermission(ctx, req.GetId()) +func (s *PermissionService) GetPermission(ctx context.Context, req *system.GetPermissionRequest) (*system.GetPermissionResponse, error) { + permission, err := s.uc.GetPermission(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("PERMISSION_NOT_FOUND", "Permission not found") @@ -36,16 +46,16 @@ func (s *SystemService) GetPermission(ctx context.Context, req *system.GetPermis return &system.GetPermissionResponse{Permission: permission}, nil } -func (s *SystemService) CreatePermission(ctx context.Context, req *system.CreatePermissionRequest) (*system.CreatePermissionResponse, error) { - permission, err := s.Permission.CreatePermission(ctx, req.GetPermission()) +func (s *PermissionService) CreatePermission(ctx context.Context, req *system.CreatePermissionRequest) (*system.CreatePermissionResponse, error) { + permission, err := s.uc.CreatePermission(ctx, req.GetPermission()) if err != nil { return nil, err } return &system.CreatePermissionResponse{Permission: permission}, nil } -func (s *SystemService) UpdatePermission(ctx context.Context, req *system.UpdatePermissionRequest) (*system.UpdatePermissionResponse, error) { - permission, err := s.Permission.UpdatePermission(ctx, req.GetPermission()) +func (s *PermissionService) UpdatePermission(ctx context.Context, req *system.UpdatePermissionRequest) (*system.UpdatePermissionResponse, error) { + permission, err := s.uc.UpdatePermission(ctx, req.GetPermission()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("PERMISSION_NOT_FOUND", "Permission not found") @@ -55,8 +65,8 @@ func (s *SystemService) UpdatePermission(ctx context.Context, req *system.Update return &system.UpdatePermissionResponse{Permission: permission}, nil } -func (s *SystemService) DeletePermission(ctx context.Context, req *system.DeletePermissionRequest) (*system.DeletePermissionResponse, error) { - err := s.Permission.DeletePermission(ctx, req.GetId()) +func (s *PermissionService) DeletePermission(ctx context.Context, req *system.DeletePermissionRequest) (*system.DeletePermissionResponse, error) { + err := s.uc.DeletePermission(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("PERMISSION_NOT_FOUND", "Permission not found") diff --git a/internal/features/system/service/provider.go b/internal/features/system/service/provider.go index 295fb7a2..a5f43972 100644 --- a/internal/features/system/service/provider.go +++ b/internal/features/system/service/provider.go @@ -11,5 +11,10 @@ import ( // ProviderSet is service providers. var ProviderSet = wire.NewSet( - New, + NewUserService, + NewRoleService, + NewResourceService, + NewPermissionService, + NewViewService, + NewSystemService, ) diff --git a/internal/features/system/service/resource.go b/internal/features/system/service/resource.go index 0ae59dc0..d6e532a8 100644 --- a/internal/features/system/service/resource.go +++ b/internal/features/system/service/resource.go @@ -10,10 +10,20 @@ import ( "github.com/origadmin/runtime/errors" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/features/system/biz" ) -func (s *SystemService) ListResources(ctx context.Context, req *system.ListResourcesRequest) (*system.ListResourcesResponse, error) { - resources, total, err := s.Resource.ListResources(ctx, req) +type ResourceService struct { + system.UnimplementedResourceServiceServer + uc *biz.ResourceUseCase +} + +func NewResourceService(uc *biz.ResourceUseCase) *ResourceService { + return &ResourceService{uc: uc} +} + +func (s *ResourceService) ListResources(ctx context.Context, req *system.ListResourcesRequest) (*system.ListResourcesResponse, error) { + resources, total, err := s.uc.ListResources(ctx, req) if err != nil { return nil, err } @@ -25,8 +35,8 @@ func (s *SystemService) ListResources(ctx context.Context, req *system.ListResou }, nil } -func (s *SystemService) GetResource(ctx context.Context, req *system.GetResourceRequest) (*system.GetResourceResponse, error) { - resource, err := s.Resource.GetResource(ctx, req.GetId()) +func (s *ResourceService) GetResource(ctx context.Context, req *system.GetResourceRequest) (*system.GetResourceResponse, error) { + resource, err := s.uc.GetResource(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("RESOURCE_NOT_FOUND", "Resource not found") @@ -36,16 +46,16 @@ func (s *SystemService) GetResource(ctx context.Context, req *system.GetResource return &system.GetResourceResponse{Resource: resource}, nil } -func (s *SystemService) CreateResource(ctx context.Context, req *system.CreateResourceRequest) (*system.CreateResourceResponse, error) { - resource, err := s.Resource.CreateResource(ctx, req.GetResource()) +func (s *ResourceService) CreateResource(ctx context.Context, req *system.CreateResourceRequest) (*system.CreateResourceResponse, error) { + resource, err := s.uc.CreateResource(ctx, req.GetResource()) if err != nil { return nil, err } return &system.CreateResourceResponse{Resource: resource}, nil } -func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateResourceRequest) (*system.UpdateResourceResponse, error) { - resource, err := s.Resource.UpdateResource(ctx, req.GetResource()) +func (s *ResourceService) UpdateResource(ctx context.Context, req *system.UpdateResourceRequest) (*system.UpdateResourceResponse, error) { + resource, err := s.uc.UpdateResource(ctx, req.GetResource()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("RESOURCE_NOT_FOUND", "Resource not found") @@ -55,8 +65,8 @@ func (s *SystemService) UpdateResource(ctx context.Context, req *system.UpdateRe return &system.UpdateResourceResponse{Resource: resource}, nil } -func (s *SystemService) DeleteResource(ctx context.Context, req *system.DeleteResourceRequest) (*system.DeleteResourceResponse, error) { - err := s.Resource.DeleteResource(ctx, req.GetId()) +func (s *ResourceService) DeleteResource(ctx context.Context, req *system.DeleteResourceRequest) (*system.DeleteResourceResponse, error) { + err := s.uc.DeleteResource(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("RESOURCE_NOT_FOUND", "Resource not found") diff --git a/internal/features/system/service/role.go b/internal/features/system/service/role.go index f4dd6e5c..a21b8c38 100644 --- a/internal/features/system/service/role.go +++ b/internal/features/system/service/role.go @@ -10,10 +10,20 @@ import ( "github.com/origadmin/runtime/errors" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/features/system/biz" ) -func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequest) (*system.ListRolesResponse, error) { - roles, total, err := s.Role.ListRoles(ctx, req) +type RoleService struct { + system.UnimplementedRoleServiceServer + uc *biz.RoleUseCase +} + +func NewRoleService(uc *biz.RoleUseCase) *RoleService { + return &RoleService{uc: uc} +} + +func (s *RoleService) ListRoles(ctx context.Context, req *system.ListRolesRequest) (*system.ListRolesResponse, error) { + roles, total, err := s.uc.ListRoles(ctx, req) if err != nil { return nil, err } @@ -25,8 +35,8 @@ func (s *SystemService) ListRoles(ctx context.Context, req *system.ListRolesRequ PageSize: req.GetPageSize(), }, nil } -func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*system.GetRoleResponse, error) { - role, err := s.Role.GetRole(ctx, req.GetId()) +func (s *RoleService) GetRole(ctx context.Context, req *system.GetRoleRequest) (*system.GetRoleResponse, error) { + role, err := s.uc.GetRole(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("ROLE_NOT_FOUND", "Role not found") @@ -35,15 +45,15 @@ func (s *SystemService) GetRole(ctx context.Context, req *system.GetRoleRequest) } return &system.GetRoleResponse{Role: role}, nil } -func (s *SystemService) CreateRole(ctx context.Context, req *system.CreateRoleRequest) (*system.CreateRoleResponse, error) { - role, err := s.Role.CreateRole(ctx, req.GetRole()) +func (s *RoleService) CreateRole(ctx context.Context, req *system.CreateRoleRequest) (*system.CreateRoleResponse, error) { + role, err := s.uc.CreateRole(ctx, req.GetRole()) if err != nil { return nil, err } return &system.CreateRoleResponse{Role: role}, nil } -func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRequest) (*system.UpdateRoleResponse, error) { - role, err := s.Role.UpdateRole(ctx, req.GetRole()) +func (s *RoleService) UpdateRole(ctx context.Context, req *system.UpdateRoleRequest) (*system.UpdateRoleResponse, error) { + role, err := s.uc.UpdateRole(ctx, req.GetRole()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("ROLE_NOT_FOUND", "Role not found") @@ -52,8 +62,8 @@ func (s *SystemService) UpdateRole(ctx context.Context, req *system.UpdateRoleRe } return &system.UpdateRoleResponse{Role: role}, nil } -func (s *SystemService) DeleteRole(ctx context.Context, req *system.DeleteRoleRequest) (*system.DeleteRoleResponse, error) { - err := s.Role.DeleteRole(ctx, req.GetId()) +func (s *RoleService) DeleteRole(ctx context.Context, req *system.DeleteRoleRequest) (*system.DeleteRoleResponse, error) { + err := s.uc.DeleteRole(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("ROLE_NOT_FOUND", "Role not found") diff --git a/internal/features/system/service/service.go b/internal/features/system/service/service.go index 28a26a62..5980137d 100644 --- a/internal/features/system/service/service.go +++ b/internal/features/system/service/service.go @@ -4,31 +4,20 @@ package service -import ( - "origadmin/application/admin/api/v1/services/system" - "origadmin/application/admin/internal/features/system/biz" -) - type SystemService struct { - system.UnimplementedResourceServiceServer - system.UnimplementedRoleServiceServer - system.UnimplementedUserServiceServer - system.UnimplementedPermissionServiceServer - system.UnimplementedViewServiceServer - - Resource *biz.ResourceUseCase - Role *biz.RoleUseCase - User *biz.UserUseCase - Permission *biz.PermissionUseCase - View *biz.ViewUseCase + Resource *ResourceService + Role *RoleService + User *UserService + Permission *PermissionService + View *ViewService } -func New( - resource *biz.ResourceUseCase, - role *biz.RoleUseCase, - user *biz.UserUseCase, - permission *biz.PermissionUseCase, - view *biz.ViewUseCase, +func NewSystemService( + resource *ResourceService, + role *RoleService, + user *UserService, + permission *PermissionService, + view *ViewService, ) *SystemService { return &SystemService{ Resource: resource, diff --git a/internal/features/system/service/user.go b/internal/features/system/service/user.go index fc6521fd..f4fff10c 100644 --- a/internal/features/system/service/user.go +++ b/internal/features/system/service/user.go @@ -10,10 +10,20 @@ import ( "github.com/origadmin/runtime/errors" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/features/system/biz" ) -func (s *SystemService) ListUserResources(ctx context.Context, req *system.ListUserResourcesRequest) (*system.ListUserResourcesResponse, error) { - resources, err := s.User.ListUserResources(ctx, req.GetId()) +type UserService struct { + system.UnimplementedUserServiceServer + uc *biz.UserUseCase +} + +func NewUserService(uc *biz.UserUseCase) *UserService { + return &UserService{uc: uc} +} + +func (s *UserService) ListUserResources(ctx context.Context, req *system.ListUserResourcesRequest) (*system.ListUserResourcesResponse, error) { + resources, err := s.uc.ListUserResources(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("USER_NOT_FOUND", "User not found") @@ -25,8 +35,8 @@ func (s *SystemService) ListUserResources(ctx context.Context, req *system.ListU }, nil } -func (s *SystemService) UpdateUserRoles(ctx context.Context, req *system.UpdateUserRolesRequest) (*system.UpdateUserRolesResponse, error) { - err := s.User.UpdateUserRoles(ctx, req.GetId(), req.GetRoleIds()) +func (s *UserService) UpdateUserRoles(ctx context.Context, req *system.UpdateUserRolesRequest) (*system.UpdateUserRolesResponse, error) { + err := s.uc.UpdateUserRoles(ctx, req.GetId(), req.GetRoleIds()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("USER_NOT_FOUND", "User not found") @@ -36,8 +46,8 @@ func (s *SystemService) UpdateUserRoles(ctx context.Context, req *system.UpdateU return &system.UpdateUserRolesResponse{}, nil } -func (s *SystemService) UpdateUserStatus(ctx context.Context, req *system.UpdateUserStatusRequest) (*system.UpdateUserStatusResponse, error) { - err := s.User.UpdateUserStatus(ctx, req.GetId(), int8(req.GetStatus())) +func (s *UserService) UpdateUserStatus(ctx context.Context, req *system.UpdateUserStatusRequest) (*system.UpdateUserStatusResponse, error) { + err := s.uc.UpdateUserStatus(ctx, req.GetId(), int8(req.GetStatus())) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("USER_NOT_FOUND", "User not found") @@ -47,8 +57,8 @@ func (s *SystemService) UpdateUserStatus(ctx context.Context, req *system.Update return &system.UpdateUserStatusResponse{}, nil } -func (s *SystemService) ResetUserPassword(ctx context.Context, req *system.ResetUserPasswordRequest) (*system.ResetUserPasswordResponse, error) { - err := s.User.ResetUserPassword(ctx, req.GetId(), req.GetPassword()) +func (s *UserService) ResetUserPassword(ctx context.Context, req *system.ResetUserPasswordRequest) (*system.ResetUserPasswordResponse, error) { + err := s.uc.ResetUserPassword(ctx, req.GetId(), req.GetPassword()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("USER_NOT_FOUND", "User not found") @@ -58,8 +68,8 @@ func (s *SystemService) ResetUserPassword(ctx context.Context, req *system.Reset return &system.ResetUserPasswordResponse{}, nil } -func (s *SystemService) ListUsers(ctx context.Context, req *system.ListUsersRequest) (*system.ListUsersResponse, error) { - users, total, err := s.User.ListUsers(ctx, req) +func (s *UserService) ListUsers(ctx context.Context, req *system.ListUsersRequest) (*system.ListUsersResponse, error) { + users, total, err := s.uc.ListUsers(ctx, req) if err != nil { return nil, err } @@ -71,8 +81,8 @@ func (s *SystemService) ListUsers(ctx context.Context, req *system.ListUsersRequ }, nil } -func (s *SystemService) GetUser(ctx context.Context, req *system.GetUserRequest) (*system.GetUserResponse, error) { - user, err := s.User.GetUser(ctx, req.GetId()) +func (s *UserService) GetUser(ctx context.Context, req *system.GetUserRequest) (*system.GetUserResponse, error) { + user, err := s.uc.GetUser(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("USER_NOT_FOUND", "User not found") @@ -82,16 +92,16 @@ func (s *SystemService) GetUser(ctx context.Context, req *system.GetUserRequest) return &system.GetUserResponse{User: user}, nil } -func (s *SystemService) CreateUser(ctx context.Context, req *system.CreateUserRequest) (*system.CreateUserResponse, error) { - user, err := s.User.CreateUser(ctx, req.GetUser(), req.GetPassword()) +func (s *UserService) CreateUser(ctx context.Context, req *system.CreateUserRequest) (*system.CreateUserResponse, error) { + user, err := s.uc.CreateUser(ctx, req.GetUser(), req.GetPassword()) if err != nil { return nil, err } return &system.CreateUserResponse{User: user}, nil } -func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRequest) (*system.UpdateUserResponse, error) { - user, err := s.User.UpdateUser(ctx, req.GetUser()) +func (s *UserService) UpdateUser(ctx context.Context, req *system.UpdateUserRequest) (*system.UpdateUserResponse, error) { + user, err := s.uc.UpdateUser(ctx, req.GetUser()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("USER_NOT_FOUND", "User not found") @@ -101,8 +111,8 @@ func (s *SystemService) UpdateUser(ctx context.Context, req *system.UpdateUserRe return &system.UpdateUserResponse{User: user}, nil } -func (s *SystemService) DeleteUser(ctx context.Context, req *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { - err := s.User.DeleteUser(ctx, req.GetId()) +func (s *UserService) DeleteUser(ctx context.Context, req *system.DeleteUserRequest) (*system.DeleteUserResponse, error) { + err := s.uc.DeleteUser(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("USER_NOT_FOUND", "User not found") diff --git a/internal/features/system/service/view.go b/internal/features/system/service/view.go index d199431c..c2054d05 100644 --- a/internal/features/system/service/view.go +++ b/internal/features/system/service/view.go @@ -6,11 +6,21 @@ import ( "github.com/origadmin/runtime/errors" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/features/system/biz" ) +type ViewService struct { + system.UnimplementedViewServiceServer + uc *biz.ViewUseCase +} + +func NewViewService(uc *biz.ViewUseCase) *ViewService { + return &ViewService{uc: uc} +} + // ListViews handles the RPC for listing views. -func (s *SystemService) ListViews(ctx context.Context, req *system.ListViewsRequest) (*system.ListViewsResponse, error) { - views, total, err := s.View.ListViews(ctx, req) +func (s *ViewService) ListViews(ctx context.Context, req *system.ListViewsRequest) (*system.ListViewsResponse, error) { + views, total, err := s.uc.ListViews(ctx, req) if err != nil { return nil, err } @@ -23,8 +33,8 @@ func (s *SystemService) ListViews(ctx context.Context, req *system.ListViewsRequ } // GetView handles the RPC for getting a single view. -func (s *SystemService) GetView(ctx context.Context, req *system.GetViewRequest) (*system.GetViewResponse, error) { - view, err := s.View.GetView(ctx, req.GetId()) +func (s *ViewService) GetView(ctx context.Context, req *system.GetViewRequest) (*system.GetViewResponse, error) { + view, err := s.uc.GetView(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("VIEW_NOT_FOUND", "View not found") @@ -35,8 +45,8 @@ func (s *SystemService) GetView(ctx context.Context, req *system.GetViewRequest) } // CreateView handles the RPC for creating a new view. -func (s *SystemService) CreateView(ctx context.Context, req *system.CreateViewRequest) (*system.CreateViewResponse, error) { - view, err := s.View.CreateView(ctx, req.GetView()) +func (s *ViewService) CreateView(ctx context.Context, req *system.CreateViewRequest) (*system.CreateViewResponse, error) { + view, err := s.uc.CreateView(ctx, req.GetView()) if err != nil { return nil, err } @@ -44,8 +54,8 @@ func (s *SystemService) CreateView(ctx context.Context, req *system.CreateViewRe } // UpdateView handles the RPC for updating an existing view. -func (s *SystemService) UpdateView(ctx context.Context, req *system.UpdateViewRequest) (*system.UpdateViewResponse, error) { - view, err := s.View.UpdateView(ctx, req.GetView()) +func (s *ViewService) UpdateView(ctx context.Context, req *system.UpdateViewRequest) (*system.UpdateViewResponse, error) { + view, err := s.uc.UpdateView(ctx, req.GetView()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("VIEW_NOT_FOUND", "View not found") @@ -56,8 +66,8 @@ func (s *SystemService) UpdateView(ctx context.Context, req *system.UpdateViewRe } // DeleteView handles the RPC for deleting a view. -func (s *SystemService) DeleteView(ctx context.Context, req *system.DeleteViewRequest) (*system.DeleteViewResponse, error) { - err := s.View.DeleteView(ctx, req.GetId()) +func (s *ViewService) DeleteView(ctx context.Context, req *system.DeleteViewRequest) (*system.DeleteViewResponse, error) { + err := s.uc.DeleteView(ctx, req.GetId()) if err != nil { if ent.IsNotFound(err) { return nil, errors.NotFound("VIEW_NOT_FOUND", "View not found") diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index bda29bcf..7e7ba932 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -83,6 +83,7 @@ func NewHTTPServer( if err != nil { return nil, err } + srv.HandlePrefix("/api/v1", srv) // Register all services using the GatewayService method. svc.RegisterHTTPHandlers(srv) return srv, nil diff --git a/resources/configs/clients.yaml b/resources/configs/clients.yaml index 241fccc7..5e316a03 100644 --- a/resources/configs/clients.yaml +++ b/resources/configs/clients.yaml @@ -1,10 +1,10 @@ clients: configs: - - name: "client.auth" + - name: "origadmin.service.auth.client.grpc" grpc: - endpoint: "discovery:///auth" +# endpoint: "discovery:///auth" timeout: 5s - - name: "client.system" + - name: "origadmin.service.system.client.grpcm" grpc: - endpoint: "discovery:///system" +# endpoint: "discovery:///system" timeout: 5s From 3851ef2105f5932fd00ee3a6296cf86d1d826c66 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 18:19:51 +0800 Subject: [PATCH 127/158] feat(auth): enhance server filtering to support both short and full service names --- internal/data/casbin.go | 4 +++- internal/features/auth/server/server.go | 6 ++++++ internal/features/system/server/server.go | 6 ++++++ internal/gateway/server/server.go | 4 ++-- resources/configs/clients.yaml | 2 +- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/internal/data/casbin.go b/internal/data/casbin.go index af947069..ed5119b8 100644 --- a/internal/data/casbin.go +++ b/internal/data/casbin.go @@ -14,7 +14,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/predicate" ) -// casbinAdapter implements the persist.Adapter for casbin. +// casbinAdapter implements the casbin persist.Adapter for casbin. type casbinAdapter struct { db *ent.Database } @@ -199,3 +199,5 @@ func buildFilteredFilter(ptype string, fieldIndex int, fieldValues ...string) [] } return cond } + +var _ persist.Adapter = (*casbinAdapter)(nil) diff --git a/internal/features/auth/server/server.go b/internal/features/auth/server/server.go index 8f6b88df..b73da800 100644 --- a/internal/features/auth/server/server.go +++ b/internal/features/auth/server/server.go @@ -35,6 +35,9 @@ func NewServers( var transportServers []transport.Server for _, serverCfg := range cfg.GetConfigs() { + if serverCfg.GetName() != "auth" && serverCfg.GetName() != "origadmin.service.auth" { + continue + } switch serverCfg.GetProtocol() { case "http": srv, err := NewHTTPServer(serverCfg.GetHttp(), authSvc, meSvc, casbinSvc, logger) @@ -52,6 +55,9 @@ func NewServers( return nil, errors.New("protocol is not supported: " + serverCfg.GetProtocol()) } } + if len(transportServers) == 0 { + return nil, errors.New("no servers named 'auth' or 'origadmin.service.auth' were created") + } return transportServers, nil } diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index aa73ed9a..42155edf 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -34,6 +34,9 @@ func NewServers(app *runtime.App, cfg *transportv1.Servers, svc *service.SystemS var transportServers []transport.Server for _, serverCfg := range cfg.GetConfigs() { + if serverCfg.GetName() != "system" && serverCfg.GetName() != "origadmin.service.system" { + continue + } switch serverCfg.GetProtocol() { case "http": srv, err := NewHTTPServer(app, serverCfg.GetHttp(), svc, logger) @@ -51,6 +54,9 @@ func NewServers(app *runtime.App, cfg *transportv1.Servers, svc *service.SystemS return nil, errors.New("protocol is not supported: " + serverCfg.GetProtocol()) } } + if len(transportServers) == 0 { + return nil, errors.New("no servers named 'system' or 'origadmin.service.system' were created") + } return transportServers, nil } diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index 7e7ba932..4feef9c1 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -34,7 +34,7 @@ func NewServers( var transportServers []transport.Server for _, serverCfg := range serversCfg.GetConfigs() { // Filter server configurations by name. - if serverCfg.GetName() != "gateway" { + if serverCfg.GetName() != "gateway" && serverCfg.GetName() != "origadmin.server.gateway" { continue } @@ -51,7 +51,7 @@ func NewServers( } if len(transportServers) == 0 { - return nil, errors.New("no servers named 'gateway' were created") + return nil, errors.New("no servers named 'gateway' or 'origadmin.server.gateway' were created") } return transportServers, nil diff --git a/resources/configs/clients.yaml b/resources/configs/clients.yaml index 5e316a03..3283886a 100644 --- a/resources/configs/clients.yaml +++ b/resources/configs/clients.yaml @@ -4,7 +4,7 @@ clients: grpc: # endpoint: "discovery:///auth" timeout: 5s - - name: "origadmin.service.system.client.grpcm" + - name: "origadmin.service.system.client.grpc" grpc: # endpoint: "discovery:///system" timeout: 5s From efb757478e6075a74badd6a65495184fc247c996 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 19:05:03 +0800 Subject: [PATCH 128/158] feat(api): refactor user service proto to use field masks and simplify request messages --- api/v1/proto/system/user.proto | 28 +- api/v1/services/system/user.pb.go | 211 +++----- api/v1/services/system/user.pb.gw.go | 36 +- api/v1/services/system/user.pb.validate.go | 134 ++--- api/v1/services/system/user_bridge.pb.go | 4 +- api/v1/services/system/user_http.pb.go | 6 +- internal/gateway/client/client.go | 19 +- resources/api-docs/openapi/openapi.yaml | 543 +-------------------- resources/configs/bootstrap.yaml | 3 + resources/configs/clients.yaml | 6 +- resources/configs/discovery.yaml | 13 + resources/configs/server.yaml | 14 +- 12 files changed, 175 insertions(+), 842 deletions(-) create mode 100644 resources/configs/discovery.yaml diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index 295a66f9..7cf56efd 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -5,6 +5,7 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; import "types/system.proto"; option go_package = "origadmin/application/admin/api/v1/services/system;system"; @@ -34,8 +35,8 @@ service UserService { } rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse) { option (google.api.http) = { - put: "/sys/users/{user.id}" - body: "user" + patch: "/sys/users/{user.id}" + body: "*" }; } rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse) { @@ -78,7 +79,6 @@ message ListUserResourcesResponse { message UpdateUserStatusRequest { int64 id = 1; int32 status = 2; - optional api.v1.services.types.User user = 3 [json_name = "user"]; } message UpdateUserStatusResponse {} @@ -140,13 +140,8 @@ message CreateUserRequest { // The user resource to be created. api.v1.services.types.User user = 2; // The password to use for this user. + // If this field is left empty, a random password will be generated by the server. string password = 3 [json_name = "password"]; - // The user id to use for this user. - string user_id = 4 [json_name = "user_id"]; - // The user is_system to use for this user. - bool is_system = 5 [json_name = "is_system"]; - // The random_password is the query parameter for set only to generate a random password - bool random_password = 6 [json_name = "random_password"]; } message CreateUserResponse { @@ -156,12 +151,9 @@ message CreateUserResponse { message UpdateUserRequest { // The user resource which replaces the resource on the server. api.v1.services.types.User user = 1; - // The user id to use for this user. - string user_id = 3 [json_name = "user_id"]; - // The user is_system to use for this user. - bool is_system = 4 [json_name = "is_system"]; - // The random_password is the query parameter for set only to generate a random password - bool random_password = 2 [json_name = "random_password"]; + // The update mask applies to the resource. For the `FieldMask` definition, + // see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + google.protobuf.FieldMask update_mask = 2; } message UpdateUserResponse { @@ -171,8 +163,6 @@ message UpdateUserResponse { message DeleteUserRequest { // The resource id of the user to be deleted. int64 id = 1; - // The user object, for compatibility. - optional api.v1.services.types.User user = 2; } message DeleteUserResponse { @@ -181,9 +171,7 @@ message DeleteUserResponse { message UpdateUserRolesRequest { int64 id = 1; - api.v1.services.types.User user = 2 [json_name = "user"]; - repeated int64 role_ids = 3 [json_name = "role_ids"]; - // bool is_add = 5 [json_name = "is_add"]; + repeated int64 role_ids = 2 [json_name = "role_ids"]; } message UpdateUserRolesResponse { diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go index 8afef874..e7e4cfb5 100644 --- a/api/v1/services/system/user.pb.go +++ b/api/v1/services/system/user.pb.go @@ -12,6 +12,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" anypb "google.golang.org/protobuf/types/known/anypb" emptypb "google.golang.org/protobuf/types/known/emptypb" + fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" types "origadmin/application/admin/api/v1/services/types" reflect "reflect" sync "sync" @@ -125,7 +126,6 @@ type UpdateUserStatusRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` - User *types.User `protobuf:"bytes,3,opt,name=user,proto3,oneof" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -174,13 +174,6 @@ func (x *UpdateUserStatusRequest) GetStatus() int32 { return 0 } -func (x *UpdateUserStatusRequest) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - type UpdateUserStatusResponse struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -593,15 +586,10 @@ type CreateUserRequest struct { // The user resource to be created. User *types.User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` // The password to use for this user. - Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` - // The user id to use for this user. - UserId string `protobuf:"bytes,4,opt,name=user_id,proto3" json:"user_id,omitempty"` - // The user is_system to use for this user. - IsSystem bool `protobuf:"varint,5,opt,name=is_system,proto3" json:"is_system,omitempty"` - // The random_password is the query parameter for set only to generate a random password - RandomPassword bool `protobuf:"varint,6,opt,name=random_password,proto3" json:"random_password,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + // If this field is left empty, a random password will be generated by the server. + Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *CreateUserRequest) Reset() { @@ -655,27 +643,6 @@ func (x *CreateUserRequest) GetPassword() string { return "" } -func (x *CreateUserRequest) GetUserId() string { - if x != nil { - return x.UserId - } - return "" -} - -func (x *CreateUserRequest) GetIsSystem() bool { - if x != nil { - return x.IsSystem - } - return false -} - -func (x *CreateUserRequest) GetRandomPassword() bool { - if x != nil { - return x.RandomPassword - } - return false -} - type CreateUserResponse struct { state protoimpl.MessageState `protogen:"open.v1"` User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` @@ -724,14 +691,11 @@ type UpdateUserRequest struct { state protoimpl.MessageState `protogen:"open.v1"` // The user resource which replaces the resource on the server. User *types.User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // The user id to use for this user. - UserId string `protobuf:"bytes,3,opt,name=user_id,proto3" json:"user_id,omitempty"` - // The user is_system to use for this user. - IsSystem bool `protobuf:"varint,4,opt,name=is_system,proto3" json:"is_system,omitempty"` - // The random_password is the query parameter for set only to generate a random password - RandomPassword bool `protobuf:"varint,2,opt,name=random_password,proto3" json:"random_password,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + // The update mask applies to the resource. For the `FieldMask` definition, + // see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UpdateUserRequest) Reset() { @@ -771,25 +735,11 @@ func (x *UpdateUserRequest) GetUser() *types.User { return nil } -func (x *UpdateUserRequest) GetUserId() string { - if x != nil { - return x.UserId - } - return "" -} - -func (x *UpdateUserRequest) GetIsSystem() bool { - if x != nil { - return x.IsSystem - } - return false -} - -func (x *UpdateUserRequest) GetRandomPassword() bool { +func (x *UpdateUserRequest) GetUpdateMask() *fieldmaskpb.FieldMask { if x != nil { - return x.RandomPassword + return x.UpdateMask } - return false + return nil } type UpdateUserResponse struct { @@ -839,9 +789,7 @@ func (x *UpdateUserResponse) GetUser() *types.User { type DeleteUserRequest struct { state protoimpl.MessageState `protogen:"open.v1"` // The resource id of the user to be deleted. - Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // The user object, for compatibility. - User *types.User `protobuf:"bytes,2,opt,name=user,proto3,oneof" json:"user,omitempty"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -883,13 +831,6 @@ func (x *DeleteUserRequest) GetId() int64 { return 0 } -func (x *DeleteUserRequest) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - type DeleteUserResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Empty *emptypb.Empty `protobuf:"bytes,1,opt,name=empty,proto3" json:"empty,omitempty"` @@ -937,8 +878,7 @@ func (x *DeleteUserResponse) GetEmpty() *emptypb.Empty { type UpdateUserRolesRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - User *types.User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` - RoleIds []int64 `protobuf:"varint,3,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` // bool is_add = 5 [json_name = "is_add"]; + RoleIds []int64 `protobuf:"varint,2,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -980,13 +920,6 @@ func (x *UpdateUserRolesRequest) GetId() int64 { return 0 } -func (x *UpdateUserRolesRequest) GetUser() *types.User { - if x != nil { - return x.User - } - return nil -} - func (x *UpdateUserRolesRequest) GetRoleIds() []int64 { if x != nil { return x.RoleIds @@ -1042,17 +975,15 @@ var File_system_user_proto protoreflect.FileDescriptor const file_system_user_proto_rawDesc = "" + "\n" + - "\x11system/user.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"*\n" + + "\x11system/user.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x12types/system.proto\"*\n" + "\x18ListUserResourcesRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"p\n" + "\x19ListUserResourcesResponse\x12\x14\n" + "\x05total\x18\x01 \x01(\x05R\x05total\x12=\n" + - "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"\x80\x01\n" + + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"A\n" + "\x17UpdateUserStatusRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + - "\x06status\x18\x02 \x01(\x05R\x06status\x124\n" + - "\x04user\x18\x03 \x01(\v2\x1b.api.v1.services.types.UserH\x00R\x04user\x88\x01\x01B\a\n" + - "\x05_user\"\x1a\n" + + "\x06status\x18\x02 \x01(\x05R\x06status\"\x1a\n" + "\x18UpdateUserStatusResponse\"F\n" + "\x18ResetUserPasswordRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" + @@ -1081,35 +1012,28 @@ const file_system_user_proto_rawDesc = "" + "\x0eGetUserRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + "\x0fGetUserResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\xda\x01\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"x\n" + "\x11CreateUserRequest\x12\x16\n" + "\x06parent\x18\x01 \x01(\tR\x06parent\x12/\n" + "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x1a\n" + - "\bpassword\x18\x03 \x01(\tR\bpassword\x12\x18\n" + - "\auser_id\x18\x04 \x01(\tR\auser_id\x12\x1c\n" + - "\tis_system\x18\x05 \x01(\bR\tis_system\x12(\n" + - "\x0frandom_password\x18\x06 \x01(\bR\x0frandom_password\"E\n" + + "\bpassword\x18\x03 \x01(\tR\bpassword\"E\n" + "\x12CreateUserResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\xa6\x01\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"\x81\x01\n" + "\x11UpdateUserRequest\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x18\n" + - "\auser_id\x18\x03 \x01(\tR\auser_id\x12\x1c\n" + - "\tis_system\x18\x04 \x01(\bR\tis_system\x12(\n" + - "\x0frandom_password\x18\x02 \x01(\bR\x0frandom_password\"E\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12;\n" + + "\vupdate_mask\x18\x02 \x01(\v2\x1a.google.protobuf.FieldMaskR\n" + + "updateMask\"E\n" + "\x12UpdateUserResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"b\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"#\n" + "\x11DeleteUserRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x124\n" + - "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserH\x00R\x04user\x88\x01\x01B\a\n" + - "\x05_user\"B\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + "\x12DeleteUserResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"u\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty\"D\n" + "\x16UpdateUserRolesRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12/\n" + - "\x04user\x18\x02 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12\x1a\n" + - "\brole_ids\x18\x03 \x03(\x03R\brole_ids\"J\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" + + "\brole_ids\x18\x02 \x03(\x03R\brole_ids\"J\n" + "\x17UpdateUserRolesResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\xf9\t\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\xf6\t\n" + "\vUserService\x12t\n" + "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + "/sys/users\x12\x9b\x01\n" + @@ -1117,9 +1041,9 @@ const file_system_user_proto_rawDesc = "" + "\aGetUser\x12&.api.v1.services.system.GetUserRequest\x1a'.api.v1.services.system.GetUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/users/{id}\x12z\n" + "\n" + "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a*.api.v1.services.system.CreateUserResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + - "/sys/users\x12\x87\x01\n" + + "/sys/users\x12\x84\x01\n" + "\n" + - "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04user\x1a\x14/sys/users/{user.id}\x12|\n" + + "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*2\x14/sys/users/{user.id}\x12|\n" + "\n" + "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/users/{id}\x12\x98\x01\n" + "\x10UpdateUserStatus\x12/.api.v1.services.system.UpdateUserStatusRequest\x1a0.api.v1.services.system.UpdateUserStatusResponse\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x1a\x16/sys/users/{id}/status\x12\x94\x01\n" + @@ -1162,45 +1086,44 @@ var file_system_user_proto_goTypes = []any{ (*types.Resource)(nil), // 18: api.v1.services.types.Resource (*types.User)(nil), // 19: api.v1.services.types.User (*anypb.Any)(nil), // 20: google.protobuf.Any - (*emptypb.Empty)(nil), // 21: google.protobuf.Empty + (*fieldmaskpb.FieldMask)(nil), // 21: google.protobuf.FieldMask + (*emptypb.Empty)(nil), // 22: google.protobuf.Empty } var file_system_user_proto_depIdxs = []int32{ 18, // 0: api.v1.services.system.ListUserResourcesResponse.resources:type_name -> api.v1.services.types.Resource - 19, // 1: api.v1.services.system.UpdateUserStatusRequest.user:type_name -> api.v1.services.types.User - 19, // 2: api.v1.services.system.ListUsersResponse.users:type_name -> api.v1.services.types.User - 20, // 3: api.v1.services.system.ListUsersResponse.extra:type_name -> google.protobuf.Any - 19, // 4: api.v1.services.system.GetUserResponse.user:type_name -> api.v1.services.types.User - 19, // 5: api.v1.services.system.CreateUserRequest.user:type_name -> api.v1.services.types.User - 19, // 6: api.v1.services.system.CreateUserResponse.user:type_name -> api.v1.services.types.User - 19, // 7: api.v1.services.system.UpdateUserRequest.user:type_name -> api.v1.services.types.User + 19, // 1: api.v1.services.system.ListUsersResponse.users:type_name -> api.v1.services.types.User + 20, // 2: api.v1.services.system.ListUsersResponse.extra:type_name -> google.protobuf.Any + 19, // 3: api.v1.services.system.GetUserResponse.user:type_name -> api.v1.services.types.User + 19, // 4: api.v1.services.system.CreateUserRequest.user:type_name -> api.v1.services.types.User + 19, // 5: api.v1.services.system.CreateUserResponse.user:type_name -> api.v1.services.types.User + 19, // 6: api.v1.services.system.UpdateUserRequest.user:type_name -> api.v1.services.types.User + 21, // 7: api.v1.services.system.UpdateUserRequest.update_mask:type_name -> google.protobuf.FieldMask 19, // 8: api.v1.services.system.UpdateUserResponse.user:type_name -> api.v1.services.types.User - 19, // 9: api.v1.services.system.DeleteUserRequest.user:type_name -> api.v1.services.types.User - 21, // 10: api.v1.services.system.DeleteUserResponse.empty:type_name -> google.protobuf.Empty - 19, // 11: api.v1.services.system.UpdateUserRolesRequest.user:type_name -> api.v1.services.types.User - 19, // 12: api.v1.services.system.UpdateUserRolesResponse.user:type_name -> api.v1.services.types.User - 6, // 13: api.v1.services.system.UserService.ListUsers:input_type -> api.v1.services.system.ListUsersRequest - 0, // 14: api.v1.services.system.UserService.ListUserResources:input_type -> api.v1.services.system.ListUserResourcesRequest - 8, // 15: api.v1.services.system.UserService.GetUser:input_type -> api.v1.services.system.GetUserRequest - 10, // 16: api.v1.services.system.UserService.CreateUser:input_type -> api.v1.services.system.CreateUserRequest - 12, // 17: api.v1.services.system.UserService.UpdateUser:input_type -> api.v1.services.system.UpdateUserRequest - 14, // 18: api.v1.services.system.UserService.DeleteUser:input_type -> api.v1.services.system.DeleteUserRequest - 2, // 19: api.v1.services.system.UserService.UpdateUserStatus:input_type -> api.v1.services.system.UpdateUserStatusRequest - 16, // 20: api.v1.services.system.UserService.UpdateUserRoles:input_type -> api.v1.services.system.UpdateUserRolesRequest - 4, // 21: api.v1.services.system.UserService.ResetUserPassword:input_type -> api.v1.services.system.ResetUserPasswordRequest - 7, // 22: api.v1.services.system.UserService.ListUsers:output_type -> api.v1.services.system.ListUsersResponse - 1, // 23: api.v1.services.system.UserService.ListUserResources:output_type -> api.v1.services.system.ListUserResourcesResponse - 9, // 24: api.v1.services.system.UserService.GetUser:output_type -> api.v1.services.system.GetUserResponse - 11, // 25: api.v1.services.system.UserService.CreateUser:output_type -> api.v1.services.system.CreateUserResponse - 13, // 26: api.v1.services.system.UserService.UpdateUser:output_type -> api.v1.services.system.UpdateUserResponse - 15, // 27: api.v1.services.system.UserService.DeleteUser:output_type -> api.v1.services.system.DeleteUserResponse - 3, // 28: api.v1.services.system.UserService.UpdateUserStatus:output_type -> api.v1.services.system.UpdateUserStatusResponse - 17, // 29: api.v1.services.system.UserService.UpdateUserRoles:output_type -> api.v1.services.system.UpdateUserRolesResponse - 5, // 30: api.v1.services.system.UserService.ResetUserPassword:output_type -> api.v1.services.system.ResetUserPasswordResponse - 22, // [22:31] is the sub-list for method output_type - 13, // [13:22] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 22, // 9: api.v1.services.system.DeleteUserResponse.empty:type_name -> google.protobuf.Empty + 19, // 10: api.v1.services.system.UpdateUserRolesResponse.user:type_name -> api.v1.services.types.User + 6, // 11: api.v1.services.system.UserService.ListUsers:input_type -> api.v1.services.system.ListUsersRequest + 0, // 12: api.v1.services.system.UserService.ListUserResources:input_type -> api.v1.services.system.ListUserResourcesRequest + 8, // 13: api.v1.services.system.UserService.GetUser:input_type -> api.v1.services.system.GetUserRequest + 10, // 14: api.v1.services.system.UserService.CreateUser:input_type -> api.v1.services.system.CreateUserRequest + 12, // 15: api.v1.services.system.UserService.UpdateUser:input_type -> api.v1.services.system.UpdateUserRequest + 14, // 16: api.v1.services.system.UserService.DeleteUser:input_type -> api.v1.services.system.DeleteUserRequest + 2, // 17: api.v1.services.system.UserService.UpdateUserStatus:input_type -> api.v1.services.system.UpdateUserStatusRequest + 16, // 18: api.v1.services.system.UserService.UpdateUserRoles:input_type -> api.v1.services.system.UpdateUserRolesRequest + 4, // 19: api.v1.services.system.UserService.ResetUserPassword:input_type -> api.v1.services.system.ResetUserPasswordRequest + 7, // 20: api.v1.services.system.UserService.ListUsers:output_type -> api.v1.services.system.ListUsersResponse + 1, // 21: api.v1.services.system.UserService.ListUserResources:output_type -> api.v1.services.system.ListUserResourcesResponse + 9, // 22: api.v1.services.system.UserService.GetUser:output_type -> api.v1.services.system.GetUserResponse + 11, // 23: api.v1.services.system.UserService.CreateUser:output_type -> api.v1.services.system.CreateUserResponse + 13, // 24: api.v1.services.system.UserService.UpdateUser:output_type -> api.v1.services.system.UpdateUserResponse + 15, // 25: api.v1.services.system.UserService.DeleteUser:output_type -> api.v1.services.system.DeleteUserResponse + 3, // 26: api.v1.services.system.UserService.UpdateUserStatus:output_type -> api.v1.services.system.UpdateUserStatusResponse + 17, // 27: api.v1.services.system.UserService.UpdateUserRoles:output_type -> api.v1.services.system.UpdateUserRolesResponse + 5, // 28: api.v1.services.system.UserService.ResetUserPassword:output_type -> api.v1.services.system.ResetUserPasswordResponse + 20, // [20:29] is the sub-list for method output_type + 11, // [11:20] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_system_user_proto_init() } @@ -1208,9 +1131,7 @@ func file_system_user_proto_init() { if File_system_user_proto != nil { return } - file_system_user_proto_msgTypes[2].OneofWrappers = []any{} file_system_user_proto_msgTypes[7].OneofWrappers = []any{} - file_system_user_proto_msgTypes[14].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/api/v1/services/system/user.pb.gw.go b/api/v1/services/system/user.pb.gw.go index b9fec933..1cc5e5d6 100644 --- a/api/v1/services/system/user.pb.gw.go +++ b/api/v1/services/system/user.pb.gw.go @@ -166,15 +166,13 @@ func local_request_UserService_CreateUser_0(ctx context.Context, marshaler runti return msg, metadata, err } -var filter_UserService_UpdateUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"user": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - func request_UserService_UpdateUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateUserRequest metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["user.id"] @@ -185,12 +183,6 @@ func request_UserService_UpdateUser_0(ctx context.Context, marshaler runtime.Mar if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } msg, err := client.UpdateUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -201,7 +193,7 @@ func local_request_UserService_UpdateUser_0(ctx context.Context, marshaler runti metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["user.id"] @@ -212,18 +204,10 @@ func local_request_UserService_UpdateUser_0(ctx context.Context, marshaler runti if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user.id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } msg, err := server.UpdateUser(ctx, &protoReq) return msg, metadata, err } -var filter_UserService_DeleteUser_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} - func request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq DeleteUserRequest @@ -239,12 +223,6 @@ func request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Mar if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_DeleteUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } msg, err := client.DeleteUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -263,12 +241,6 @@ func local_request_UserService_DeleteUser_0(ctx context.Context, marshaler runti if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_DeleteUser_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } msg, err := server.DeleteUser(ctx, &protoReq) return msg, metadata, err } @@ -485,7 +457,7 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux } forward_UserService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPut, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPatch, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -693,7 +665,7 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux } forward_UserService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPut, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPatch, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) diff --git a/api/v1/services/system/user.pb.validate.go b/api/v1/services/system/user.pb.validate.go index 6f8b2eb0..b71c77c8 100644 --- a/api/v1/services/system/user.pb.validate.go +++ b/api/v1/services/system/user.pb.validate.go @@ -303,39 +303,6 @@ func (m *UpdateUserStatusRequest) validate(all bool) error { // no validation rules for Status - if m.User != nil { - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateUserStatusRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateUserStatusRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateUserStatusRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - if len(errors) > 0 { return UpdateUserStatusRequestMultiError(errors) } @@ -1303,12 +1270,6 @@ func (m *CreateUserRequest) validate(all bool) error { // no validation rules for Password - // no validation rules for UserId - - // no validation rules for IsSystem - - // no validation rules for RandomPassword - if len(errors) > 0 { return CreateUserRequestMultiError(errors) } @@ -1571,11 +1532,34 @@ func (m *UpdateUserRequest) validate(all bool) error { } } - // no validation rules for UserId - - // no validation rules for IsSystem - - // no validation rules for RandomPassword + if all { + switch v := interface{}(m.GetUpdateMask()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UpdateUserRequestValidationError{ + field: "UpdateMask", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UpdateUserRequestValidationError{ + field: "UpdateMask", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetUpdateMask()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UpdateUserRequestValidationError{ + field: "UpdateMask", + reason: "embedded message failed validation", + cause: err, + } + } + } if len(errors) > 0 { return UpdateUserRequestMultiError(errors) @@ -1812,39 +1796,6 @@ func (m *DeleteUserRequest) validate(all bool) error { // no validation rules for Id - if m.User != nil { - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DeleteUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DeleteUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DeleteUserRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - if len(errors) > 0 { return DeleteUserRequestMultiError(errors) } @@ -2080,35 +2031,6 @@ func (m *UpdateUserRolesRequest) validate(all bool) error { // no validation rules for Id - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UpdateUserRolesRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UpdateUserRolesRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UpdateUserRolesRequestValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - if len(errors) > 0 { return UpdateUserRolesRequestMultiError(errors) } diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 8b6ec5fb..655b3438 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -112,7 +112,7 @@ func RegisterUserServiceBridgeServer(s *http.Server, srv UserServiceHookedBridge r.GET("/sys/users/:id/resources", _UserService_ListUserResources0_Bridge_Handler(srv)) r.GET("/sys/users/:id", _UserService_GetUser0_Bridge_Handler(srv)) r.POST("/sys/users", _UserService_CreateUser0_Bridge_Handler(srv)) - r.PUT("/sys/users/:user.id", _UserService_UpdateUser0_Bridge_Handler(srv)) + r.PATCH("/sys/users/:user.id", _UserService_UpdateUser0_Bridge_Handler(srv)) r.DELETE("/sys/users/:id", _UserService_DeleteUser0_Bridge_Handler(srv)) r.PUT("/sys/users/:id/status", _UserService_UpdateUserStatus0_Bridge_Handler(srv)) r.PUT("/sys/users/:id/roles", _UserService_UpdateUserRoles0_Bridge_Handler(srv)) @@ -223,7 +223,7 @@ func _UserService_CreateUser0_Bridge_Handler(srv UserServiceHookedBridger) func( func _UserService_UpdateUser0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateUserRequest - if err := ctx.Bind(&in.User); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/user_http.pb.go b/api/v1/services/system/user_http.pb.go index 68749962..603183a6 100644 --- a/api/v1/services/system/user_http.pb.go +++ b/api/v1/services/system/user_http.pb.go @@ -50,7 +50,7 @@ func RegisterUserServiceHTTPServer(s *http.Server, srv UserServiceHTTPServer) { r.GET("/sys/users/{id}/resources", _UserService_ListUserResources0_HTTP_Handler(srv)) r.GET("/sys/users/{id}", _UserService_GetUser0_HTTP_Handler(srv)) r.POST("/sys/users", _UserService_CreateUser0_HTTP_Handler(srv)) - r.PUT("/sys/users/{user.id}", _UserService_UpdateUser0_HTTP_Handler(srv)) + r.PATCH("/sys/users/{user.id}", _UserService_UpdateUser0_HTTP_Handler(srv)) r.DELETE("/sys/users/{id}", _UserService_DeleteUser0_HTTP_Handler(srv)) r.PUT("/sys/users/{id}/status", _UserService_UpdateUserStatus0_HTTP_Handler(srv)) r.PUT("/sys/users/{id}/roles", _UserService_UpdateUserRoles0_HTTP_Handler(srv)) @@ -145,7 +145,7 @@ func _UserService_CreateUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx h func _UserService_UpdateUser0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateUserRequest - if err := ctx.Bind(&in.User); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -372,7 +372,7 @@ func (c *UserServiceHTTPClientImpl) UpdateUser(ctx context.Context, in *UpdateUs path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationUserServiceUpdateUser)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.User, &out, opts...) + err := c.cc.Invoke(ctx, "PATCH", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index 641e45f4..b13a686f 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -5,7 +5,6 @@ package client import ( - "context" "fmt" "github.com/google/wire" @@ -51,7 +50,7 @@ type SystemBridgeSet struct { // and establishes a gRPC connection. // // The provided context is used for the client lifecycle. -func NewGRPCConn(ctx context.Context, bootstrap *conf.Config, name string) (*grpc.ClientConn, error) { +func NewGRPCConn(app *runtime.App, bootstrap *conf.Config, name string) (*grpc.ClientConn, error) { var clientConfig *transportv1.Client // The conventional name for gRPC clients @@ -77,15 +76,25 @@ func NewGRPCConn(ctx context.Context, bootstrap *conf.Config, name string) (*grp if clientConfig == nil { return nil, fmt.Errorf("gRPC client config not found for service: %s (checked name: '%s' and '%s')", name, name, convention) } + registryProvider, err := app.RegistryProvider() + if err != nil { + return nil, err + } + discoveries, err := registryProvider.Discoveries() + if err != nil { + return nil, err + } - return runtimegrpc.NewClient(ctx, clientConfig.GetGrpc(), &runtimegrpc.ClientOptions{}) + return runtimegrpc.NewClient(app.Context(), clientConfig.GetGrpc(), &runtimegrpc.ClientOptions{ + Discoveries: discoveries, + }) } // NewAuthBridgeSet creates a set of clients for the auth service. func NewAuthBridgeSet(app *runtime.App, bootstrap *conf.Config) (*AuthBridgeSet, error) { // Use the application's root context. This ensures that the client's lifecycle // is tied to the application's lifecycle. - conn, err := NewGRPCConn(app.Context(), bootstrap, ServiceNameAuth) + conn, err := NewGRPCConn(app, bootstrap, ServiceNameAuth) if err != nil { return nil, err } @@ -98,7 +107,7 @@ func NewAuthBridgeSet(app *runtime.App, bootstrap *conf.Config) (*AuthBridgeSet, // NewSystemBridgeSet creates a set of clients for the system service. func NewSystemBridgeSet(app *runtime.App, bootstrap *conf.Config) (*SystemBridgeSet, error) { // Use the application's root context. - conn, err := NewGRPCConn(app.Context(), bootstrap, ServiceNameSystem) + conn, err := NewGRPCConn(app, bootstrap, ServiceNameSystem) if err != nil { return nil, err } diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 66980d50..c07a9889 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -17,374 +17,6 @@ servers: - url: http://localhost:10080 - url: https://localhost:10080 paths: - /api/v1/captcha: - get: - tags: - - GatewayService - operationId: GatewayService_GetCaptcha - parameters: - - name: reload - in: query - description: If true, forces reloading of the captcha. - schema: - type: boolean - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.GetCaptchaResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /api/v1/login: - post: - tags: - - GatewayService - description: '--- Auth Service ---' - operationId: GatewayService_Login - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.LoginRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.LoginResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /api/v1/me/profile: - get: - tags: - - GatewayService - description: '--- Me Service ---' - operationId: GatewayService_GetProfile - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.GetProfileResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /api/v1/users: - get: - tags: - - GatewayService - description: '--- System User Service ---' - operationId: GatewayService_ListUsers - parameters: - - name: id - in: query - description: The parent resource id, for example, "shelves/shelf1". - schema: - type: string - - name: page - in: query - description: The page number. - schema: - type: integer - format: int32 - - name: page_size - in: query - description: The maximum number of items to return. - schema: - type: integer - format: int32 - - name: page_token - in: query - description: The next_page_token value returned from a previous List request, if any. - schema: - type: string - - name: no_paging - in: query - description: The no_paging is used to disable pagination. - schema: - type: boolean - - name: only_count - in: query - description: The only_count is the query parameter for set only to query the total number - schema: - type: boolean - - name: keyword - in: query - description: The title query parameter for set only to query the title - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.ListUsersResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - post: - tags: - - GatewayService - operationId: GatewayService_CreateUser - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.CreateUserRequest' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.types.User' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /api/v1/users/{id}: - get: - tags: - - GatewayService - operationId: GatewayService_GetUser - parameters: - - name: id - in: path - description: |- - The field will contain id of the resource requested, for example: - "shelves/shelf1/users/user2" - required: true - schema: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.types.User' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - delete: - tags: - - GatewayService - operationId: GatewayService_DeleteUser - parameters: - - name: id - in: path - description: The resource id of the user to be deleted. - required: true - schema: - type: string - - name: user.id - in: query - description: |- - ID of the ent. - field.primary_key.comment - schema: - type: string - - name: user.create_author - in: query - description: create_author.field.comment - schema: - type: string - - name: user.update_author - in: query - description: update_author.field.comment - schema: - type: string - - name: user.create_time - in: query - description: create_time.field.comment - schema: - type: string - format: date-time - - name: user.update_time - in: query - description: update_time.field.comment - schema: - type: string - format: date-time - - name: user.uuid - in: query - description: user.field.uuid - schema: - type: string - - name: user.allowed_ip - in: query - description: user.field.allowed_ip - schema: - type: string - - name: user.username - in: query - description: user.field.username - schema: - type: string - - name: user.nickname - in: query - description: user.field.nickname - schema: - type: string - - name: user.avatar - in: query - description: user.field.avatar - schema: - type: string - - name: user.name - in: query - description: user.field.nickname - schema: - type: string - - name: user.gender - in: query - description: user.field.gender - schema: - type: string - - name: user.phone - in: query - description: user.field.phone - schema: - type: string - - name: user.email - in: query - description: user.field.email - schema: - type: string - - name: user.remark - in: query - description: user.field.remark - schema: - type: string - - name: user.token - in: query - description: user.field.token - schema: - type: string - - name: user.status - in: query - description: user.field.status - schema: - type: integer - format: int32 - - name: user.last_login_ip - in: query - description: user.field.last_login_ip - schema: - type: string - - name: user.last_login_time - in: query - description: user.field.last_login_time - schema: - type: string - format: date-time - - name: user.sanction_date - in: query - description: user.field.sanction_date - schema: - type: string - format: date-time - - name: user.manager_id - in: query - description: user.field.manager_id - schema: - type: string - - name: user.manager - in: query - description: user.field.manager - schema: - type: string - - name: user.role_ids - in: query - description: Role Ids holds the value of the role_ids - schema: - type: array - items: - type: string - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.system.DeleteUserResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' - /api/v1/users/{user.id}: - put: - tags: - - GatewayService - operationId: GatewayService_UpdateUser - parameters: - - name: user.id - in: path - required: true - schema: - type: string - - name: user_id - in: query - description: The user id to use for this user. - schema: - type: string - - name: is_system - in: query - description: The user is_system to use for this user. - schema: - type: boolean - - name: random_password - in: query - description: The random_password is the query parameter for set only to generate a random password - schema: - type: boolean - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.types.User' - required: true - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.types.User' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' /auth/login: post: tags: @@ -2017,130 +1649,6 @@ paths: required: true schema: type: string - - name: user.id - in: query - description: |- - ID of the ent. - field.primary_key.comment - schema: - type: string - - name: user.create_author - in: query - description: create_author.field.comment - schema: - type: string - - name: user.update_author - in: query - description: update_author.field.comment - schema: - type: string - - name: user.create_time - in: query - description: create_time.field.comment - schema: - type: string - format: date-time - - name: user.update_time - in: query - description: update_time.field.comment - schema: - type: string - format: date-time - - name: user.uuid - in: query - description: user.field.uuid - schema: - type: string - - name: user.allowed_ip - in: query - description: user.field.allowed_ip - schema: - type: string - - name: user.username - in: query - description: user.field.username - schema: - type: string - - name: user.nickname - in: query - description: user.field.nickname - schema: - type: string - - name: user.avatar - in: query - description: user.field.avatar - schema: - type: string - - name: user.name - in: query - description: user.field.nickname - schema: - type: string - - name: user.gender - in: query - description: user.field.gender - schema: - type: string - - name: user.phone - in: query - description: user.field.phone - schema: - type: string - - name: user.email - in: query - description: user.field.email - schema: - type: string - - name: user.remark - in: query - description: user.field.remark - schema: - type: string - - name: user.token - in: query - description: user.field.token - schema: - type: string - - name: user.status - in: query - description: user.field.status - schema: - type: integer - format: int32 - - name: user.last_login_ip - in: query - description: user.field.last_login_ip - schema: - type: string - - name: user.last_login_time - in: query - description: user.field.last_login_time - schema: - type: string - format: date-time - - name: user.sanction_date - in: query - description: user.field.sanction_date - schema: - type: string - format: date-time - - name: user.manager_id - in: query - description: user.field.manager_id - schema: - type: string - - name: user.manager - in: query - description: user.field.manager - schema: - type: string - - name: user.role_ids - in: query - description: Role Ids holds the value of the role_ids - schema: - type: array - items: - type: string responses: "200": description: OK @@ -2272,7 +1780,7 @@ paths: schema: $ref: '#/components/schemas/google.rpc.Status' /sys/users/{user.id}: - put: + patch: tags: - UserService operationId: UserService_UpdateUser @@ -2282,26 +1790,11 @@ paths: required: true schema: type: string - - name: user_id - in: query - description: The user id to use for this user. - schema: - type: string - - name: is_system - in: query - description: The user is_system to use for this user. - schema: - type: boolean - - name: random_password - in: query - description: The random_password is the query parameter for set only to generate a random password - schema: - type: boolean requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.User' + $ref: '#/components/schemas/api.v1.services.system.UpdateUserRequest' required: true responses: "200": @@ -3065,16 +2558,9 @@ components: description: The user resource to be created. password: type: string - description: The password to use for this user. - user_id: - type: string - description: The user id to use for this user. - is_system: - type: boolean - description: The user is_system to use for this user. - random_password: - type: boolean - description: The random_password is the query parameter for set only to generate a random password + description: |- + The password to use for this user. + If this field is left empty, a random password will be generated by the server. api.v1.services.system.CreateUserResponse: type: object properties: @@ -3392,6 +2878,19 @@ components: properties: role: $ref: '#/components/schemas/api.v1.services.types.Role' + api.v1.services.system.UpdateUserRequest: + type: object + properties: + user: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.User' + description: The user resource which replaces the resource on the server. + update_mask: + type: string + description: |- + The update mask applies to the resource. For the `FieldMask` definition, + see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask + format: field-mask api.v1.services.system.UpdateUserResponse: type: object properties: @@ -3402,8 +2901,6 @@ components: properties: id: type: string - user: - $ref: '#/components/schemas/api.v1.services.types.User' role_ids: type: array items: @@ -3421,8 +2918,6 @@ components: status: type: integer format: int32 - user: - $ref: '#/components/schemas/api.v1.services.types.User' api.v1.services.system.UpdateUserStatusResponse: type: object properties: {} @@ -3963,8 +3458,6 @@ tags: description: The data service definition. - name: DepartmentService description: The login service definition. - - name: GatewayService - description: "GatewayService is the public-facing API gateway.\r\n It proxies requests to backend services." - name: MeService description: Service MeService provides APIs for the currently authenticated user to manage their own profile and data. - name: PermissionService diff --git a/resources/configs/bootstrap.yaml b/resources/configs/bootstrap.yaml index e49f46ca..c8145c29 100644 --- a/resources/configs/bootstrap.yaml +++ b/resources/configs/bootstrap.yaml @@ -21,5 +21,8 @@ sources: - file: path: clients.yaml type: file + - file: + path: discovery.yaml + type: file # Environment variables are loaded last to override file settings. - type: env diff --git a/resources/configs/clients.yaml b/resources/configs/clients.yaml index 3283886a..c5a80e04 100644 --- a/resources/configs/clients.yaml +++ b/resources/configs/clients.yaml @@ -2,9 +2,11 @@ clients: configs: - name: "origadmin.service.auth.client.grpc" grpc: -# endpoint: "discovery:///auth" + endpoint: "discovery:///origadmin.service.auth" timeout: 5s + discovery_name: "default_consul" - name: "origadmin.service.system.client.grpc" grpc: -# endpoint: "discovery:///system" + endpoint: "discovery:///origadmin.service.system" timeout: 5s + discovery_name: "default_consul" diff --git a/resources/configs/discovery.yaml b/resources/configs/discovery.yaml new file mode 100644 index 00000000..b25e6b10 --- /dev/null +++ b/resources/configs/discovery.yaml @@ -0,0 +1,13 @@ +discoveries: + default: default_consul + active: default_consul + configs: + - name: default_consul + type: consul + debug: true + consul: + address: 127.0.0.1:8500 + scheme: http + health_check: true + health_check_interval: 10 + deregister_critical_service_after: 30 diff --git a/resources/configs/server.yaml b/resources/configs/server.yaml index 94fc9f79..b48a6556 100644 --- a/resources/configs/server.yaml +++ b/resources/configs/server.yaml @@ -23,12 +23,22 @@ servers: - name: "auth" protocol: "grpc" grpc: - addr: "0.0.0.0:9001" + addr: "0.0.0.0:9081" + timeout: 5s + - name: "auth" + protocol: "http" + http: + addr: "0.0.0.0:9082" timeout: 5s # System Service gRPC Server - name: "system" protocol: "grpc" grpc: - addr: "0.0.0.0:9002" + addr: "0.0.0.0:9001" timeout: 5s + - name: "system" + protocol: "http" + http: + addr: "0.0.0.0:9002" + timeout: 5s \ No newline at end of file From 29d0ebdd5bce07e0bfafc6fa94e07310518ddbf4 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 19:25:57 +0800 Subject: [PATCH 129/158] feat(api): update service routes to use /api/v1 prefix and refactor gateway registration --- api/v1/services/auth/auth_bridge.pb.go | 2 +- api/v1/services/auth/casbin_bridge.pb.go | 2 +- api/v1/services/auth/me_bridge.pb.go | 2 +- .../services/datastore/datastore_bridge.pb.go | 2 +- api/v1/services/datastore/upload_bridge.pb.go | 2 +- api/v1/services/message/message_bridge.pb.go | 2 +- .../services/system/department_bridge.pb.go | 2 +- .../services/system/permission_bridge.pb.go | 2 +- api/v1/services/system/position_bridge.pb.go | 2 +- api/v1/services/system/resource_bridge.pb.go | 2 +- api/v1/services/system/role_bridge.pb.go | 2 +- api/v1/services/system/user_bridge.pb.go | 2 +- api/v1/services/system/view_bridge.pb.go | 2 +- buf.gen.yaml | 4 ++- internal/gateway/server/server.go | 11 +++++--- internal/gateway/service/service.go | 27 +++++++------------ 16 files changed, 34 insertions(+), 34 deletions(-) diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index de9bf285..665b74cf 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -90,7 +90,7 @@ type AuthServiceAuthenticateHooker interface { } func RegisterAuthServiceBridgeServer(s *http.Server, srv AuthServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.POST("/auth/login", _AuthService_Login0_Bridge_Handler(srv)) r.POST("/auth/register", _AuthService_Register0_Bridge_Handler(srv)) r.POST("/auth/logout", _AuthService_Logout0_Bridge_Handler(srv)) diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index b64ce367..124113fc 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -63,7 +63,7 @@ type CasbinServiceWatchUpdateHooker interface { } func RegisterCasbinServiceBridgeServer(s *http.Server, srv CasbinServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/casbin/policies", _CasbinService_ListPolicies0_Bridge_Handler(srv)) r.GET("/casbin/groupings", _CasbinService_ListGroupings0_Bridge_Handler(srv)) r.GET("/casbin/watch", _CasbinService_WatchUpdate0_Bridge_Handler(srv)) diff --git a/api/v1/services/auth/me_bridge.pb.go b/api/v1/services/auth/me_bridge.pb.go index 309451f5..08f6cf74 100644 --- a/api/v1/services/auth/me_bridge.pb.go +++ b/api/v1/services/auth/me_bridge.pb.go @@ -81,7 +81,7 @@ type MeServiceGetUserRolesHooker interface { } func RegisterMeServiceBridgeServer(s *http.Server, srv MeServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/me/profile", _MeService_GetProfile0_Bridge_Handler(srv)) r.PUT("/me/profile", _MeService_UpdateProfile0_Bridge_Handler(srv)) r.PUT("/me/password", _MeService_UpdatePassword0_Bridge_Handler(srv)) diff --git a/api/v1/services/datastore/datastore_bridge.pb.go b/api/v1/services/datastore/datastore_bridge.pb.go index 4aff78de..b620ff78 100644 --- a/api/v1/services/datastore/datastore_bridge.pb.go +++ b/api/v1/services/datastore/datastore_bridge.pb.go @@ -76,7 +76,7 @@ type DatastoreServiceDeleteDatastoreHooker interface { } func RegisterDatastoreServiceBridgeServer(s *http.Server, srv DatastoreServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/datastore", _DatastoreService_ListDatastore0_Bridge_Handler(srv)) r.GET("/datastore/:id", _DatastoreService_GetDatastore0_Bridge_Handler(srv)) r.POST("/datastore", _DatastoreService_CreateDatastore0_Bridge_Handler(srv)) diff --git a/api/v1/services/datastore/upload_bridge.pb.go b/api/v1/services/datastore/upload_bridge.pb.go index 16a27a94..75a9e4a2 100644 --- a/api/v1/services/datastore/upload_bridge.pb.go +++ b/api/v1/services/datastore/upload_bridge.pb.go @@ -76,7 +76,7 @@ type UploadServiceDeleteUploadHooker interface { } func RegisterUploadServiceBridgeServer(s *http.Server, srv UploadServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/upload", _UploadService_ListUpload0_Bridge_Handler(srv)) r.GET("/upload/:id", _UploadService_GetUpload0_Bridge_Handler(srv)) r.POST("/upload", _UploadService_CreateUpload0_Bridge_Handler(srv)) diff --git a/api/v1/services/message/message_bridge.pb.go b/api/v1/services/message/message_bridge.pb.go index 14cefe32..80f619df 100644 --- a/api/v1/services/message/message_bridge.pb.go +++ b/api/v1/services/message/message_bridge.pb.go @@ -105,7 +105,7 @@ type PersonalServiceUpdatePersonalSettingHooker interface { } func RegisterPersonalServiceBridgeServer(s *http.Server, srv PersonalServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/message/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) r.GET("/message/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) r.GET("/message/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go index c4876b90..e75bd226 100644 --- a/api/v1/services/system/department_bridge.pb.go +++ b/api/v1/services/system/department_bridge.pb.go @@ -76,7 +76,7 @@ type DepartmentServiceDeleteDepartmentHooker interface { } func RegisterDepartmentServiceBridgeServer(s *http.Server, srv DepartmentServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/sys/departments", _DepartmentService_ListDepartments0_Bridge_Handler(srv)) r.GET("/sys/departments/:id", _DepartmentService_GetDepartment0_Bridge_Handler(srv)) r.POST("/sys/departments", _DepartmentService_CreateDepartment0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go index c1da935f..5c2255bf 100644 --- a/api/v1/services/system/permission_bridge.pb.go +++ b/api/v1/services/system/permission_bridge.pb.go @@ -76,7 +76,7 @@ type PermissionServiceDeletePermissionHooker interface { } func RegisterPermissionServiceBridgeServer(s *http.Server, srv PermissionServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/sys/permissions", _PermissionService_ListPermissions0_Bridge_Handler(srv)) r.GET("/sys/permissions/:id", _PermissionService_GetPermission0_Bridge_Handler(srv)) r.POST("/sys/permissions", _PermissionService_CreatePermission0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go index 9f1d551d..0295df9d 100644 --- a/api/v1/services/system/position_bridge.pb.go +++ b/api/v1/services/system/position_bridge.pb.go @@ -76,7 +76,7 @@ type PositionServiceDeletePositionHooker interface { } func RegisterPositionServiceBridgeServer(s *http.Server, srv PositionServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/sys/positions", _PositionService_ListPositions0_Bridge_Handler(srv)) r.GET("/sys/positions/:id", _PositionService_GetPosition0_Bridge_Handler(srv)) r.POST("/sys/positions", _PositionService_CreatePosition0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go index 570a70aa..6cfbfe5c 100644 --- a/api/v1/services/system/resource_bridge.pb.go +++ b/api/v1/services/system/resource_bridge.pb.go @@ -81,7 +81,7 @@ type ResourceServiceDeleteResourceHooker interface { } func RegisterResourceServiceBridgeServer(s *http.Server, srv ResourceServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/sys/resources", _ResourceService_ListResources0_Bridge_Handler(srv)) r.GET("/sys/resources/:id", _ResourceService_GetResource0_Bridge_Handler(srv)) r.POST("/sys/resources", _ResourceService_CreateResource0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go index f10a5226..178759b3 100644 --- a/api/v1/services/system/role_bridge.pb.go +++ b/api/v1/services/system/role_bridge.pb.go @@ -76,7 +76,7 @@ type RoleServiceDeleteRoleHooker interface { } func RegisterRoleServiceBridgeServer(s *http.Server, srv RoleServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/sys/roles", _RoleService_ListRoles0_Bridge_Handler(srv)) r.GET("/sys/roles/:id", _RoleService_GetRole0_Bridge_Handler(srv)) r.POST("/sys/roles", _RoleService_CreateRole0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 655b3438..0eae15fd 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -107,7 +107,7 @@ type UserServiceResetUserPasswordHooker interface { } func RegisterUserServiceBridgeServer(s *http.Server, srv UserServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/sys/users", _UserService_ListUsers0_Bridge_Handler(srv)) r.GET("/sys/users/:id/resources", _UserService_ListUserResources0_Bridge_Handler(srv)) r.GET("/sys/users/:id", _UserService_GetUser0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/view_bridge.pb.go b/api/v1/services/system/view_bridge.pb.go index a4e5739b..02a9a117 100644 --- a/api/v1/services/system/view_bridge.pb.go +++ b/api/v1/services/system/view_bridge.pb.go @@ -81,7 +81,7 @@ type ViewServiceDeleteViewHooker interface { } func RegisterViewServiceBridgeServer(s *http.Server, srv ViewServiceHookedBridger) { - r := s.Route("/") + r := s.Route("/api/v1") r.GET("/sys/views", _ViewService_ListViews0_Bridge_Handler(srv)) r.GET("/sys/views/:id", _ViewService_GetView0_Bridge_Handler(srv)) r.POST("/sys/views", _ViewService_CreateView0_Bridge_Handler(srv)) diff --git a/buf.gen.yaml b/buf.gen.yaml index 841e8ee8..d30f68fa 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -43,7 +43,9 @@ plugins: opt: paths=source_relative - local: protoc-gen-go-bridge out: api/v1/services - opt: paths=source_relative + opt: + - paths=source_relative + - prefix=/api/v1 - local: protoc-gen-grpc-gateway out: api/v1/services opt: paths=source_relative diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index 4feef9c1..165af4f9 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -83,8 +83,13 @@ func NewHTTPServer( if err != nil { return nil, err } - srv.HandlePrefix("/api/v1", srv) - // Register all services using the GatewayService method. - svc.RegisterHTTPHandlers(srv) + + // Get a router group with the /api/v1 prefix. + // All subsequent routes registered on this router will be automatically prefixed. + apiRouter := srv.Route("/api/v1") + + // Register all services onto this specific router group. + svc.RegisterHTTPHandlers(apiRouter) + return srv, nil } diff --git a/internal/gateway/service/service.go b/internal/gateway/service/service.go index 7b41348a..0e49f2eb 100644 --- a/internal/gateway/service/service.go +++ b/internal/gateway/service/service.go @@ -5,12 +5,10 @@ package service import ( - stdhttp "net/http" - "github.com/google/wire" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service/transport" + "github.com/origadmin/runtime/service/transport/http" "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/gateway/client" @@ -38,21 +36,16 @@ func NewGatewayService(authClient *client.AuthBridgeSet, systemClient *client.Sy } // RegisterHTTPHandlers registers all the HTTP handlers for the downstream services -// onto the provided HTTP server. It also logs the registered routes. -func (s *GatewayService) RegisterHTTPHandlers(srv *transport.HTTPServer) { +// onto the provided HTTP router. +func (s *GatewayService) RegisterHTTPHandlers(router *transport.RouterHTTP) { // Register handlers for the 'system' service - system.RegisterUserServiceHTTPServer(srv, s.System.User) - system.RegisterRoleServiceHTTPServer(srv, s.System.Role) - system.RegisterPermissionServiceHTTPServer(srv, s.System.Permission) - system.RegisterResourceServiceHTTPServer(srv, s.System.Resource) - system.RegisterViewServiceHTTPServer(srv, s.System.View) + system.RegisterUserServiceHTTPServer(router, s.System.User) + system.RegisterRoleServiceHTTPServer(router, s.System.Role) + system.RegisterPermissionServiceHTTPServer(router, s.System.Permission) + system.RegisterResourceServiceHTTPServer(router, s.System.Resource) + system.RegisterViewServiceHTTPServer(router, s.System.View) // Register handlers for the 'auth' service - auth.RegisterAuthServiceHTTPServer(srv, s.Auth.Auth) - auth.RegisterMeServiceHTTPServer(srv, s.Auth.Me) - - // Log all registered HTTP routes for debugging and verification - srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { - log.Infof("HTTP %s %s", method, path) - }) + auth.RegisterAuthServiceHTTPServer(router, s.Auth.Auth) + auth.RegisterMeServiceHTTPServer(router, s.Auth.Me) } From f3f0447fa8def214444f0210edc8b390766be0f5 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 19:29:08 +0800 Subject: [PATCH 130/158] feat(api): simplify route registration by removing /api/v1 prefix from service endpoints --- api/v1/services/auth/auth_bridge.pb.go | 2 +- api/v1/services/auth/casbin_bridge.pb.go | 2 +- api/v1/services/auth/me_bridge.pb.go | 2 +- .../services/datastore/datastore_bridge.pb.go | 2 +- api/v1/services/datastore/upload_bridge.pb.go | 2 +- api/v1/services/message/message_bridge.pb.go | 2 +- .../services/system/department_bridge.pb.go | 2 +- .../services/system/permission_bridge.pb.go | 2 +- api/v1/services/system/position_bridge.pb.go | 2 +- api/v1/services/system/resource_bridge.pb.go | 2 +- api/v1/services/system/role_bridge.pb.go | 2 +- api/v1/services/system/user_bridge.pb.go | 2 +- api/v1/services/system/view_bridge.pb.go | 2 +- buf.gen.yaml | 1 - internal/gateway/server/server.go | 10 ++----- internal/gateway/service/service.go | 27 ++++++++++++------- 16 files changed, 32 insertions(+), 32 deletions(-) diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index 665b74cf..de9bf285 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -90,7 +90,7 @@ type AuthServiceAuthenticateHooker interface { } func RegisterAuthServiceBridgeServer(s *http.Server, srv AuthServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.POST("/auth/login", _AuthService_Login0_Bridge_Handler(srv)) r.POST("/auth/register", _AuthService_Register0_Bridge_Handler(srv)) r.POST("/auth/logout", _AuthService_Logout0_Bridge_Handler(srv)) diff --git a/api/v1/services/auth/casbin_bridge.pb.go b/api/v1/services/auth/casbin_bridge.pb.go index 124113fc..b64ce367 100644 --- a/api/v1/services/auth/casbin_bridge.pb.go +++ b/api/v1/services/auth/casbin_bridge.pb.go @@ -63,7 +63,7 @@ type CasbinServiceWatchUpdateHooker interface { } func RegisterCasbinServiceBridgeServer(s *http.Server, srv CasbinServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/casbin/policies", _CasbinService_ListPolicies0_Bridge_Handler(srv)) r.GET("/casbin/groupings", _CasbinService_ListGroupings0_Bridge_Handler(srv)) r.GET("/casbin/watch", _CasbinService_WatchUpdate0_Bridge_Handler(srv)) diff --git a/api/v1/services/auth/me_bridge.pb.go b/api/v1/services/auth/me_bridge.pb.go index 08f6cf74..309451f5 100644 --- a/api/v1/services/auth/me_bridge.pb.go +++ b/api/v1/services/auth/me_bridge.pb.go @@ -81,7 +81,7 @@ type MeServiceGetUserRolesHooker interface { } func RegisterMeServiceBridgeServer(s *http.Server, srv MeServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/me/profile", _MeService_GetProfile0_Bridge_Handler(srv)) r.PUT("/me/profile", _MeService_UpdateProfile0_Bridge_Handler(srv)) r.PUT("/me/password", _MeService_UpdatePassword0_Bridge_Handler(srv)) diff --git a/api/v1/services/datastore/datastore_bridge.pb.go b/api/v1/services/datastore/datastore_bridge.pb.go index b620ff78..4aff78de 100644 --- a/api/v1/services/datastore/datastore_bridge.pb.go +++ b/api/v1/services/datastore/datastore_bridge.pb.go @@ -76,7 +76,7 @@ type DatastoreServiceDeleteDatastoreHooker interface { } func RegisterDatastoreServiceBridgeServer(s *http.Server, srv DatastoreServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/datastore", _DatastoreService_ListDatastore0_Bridge_Handler(srv)) r.GET("/datastore/:id", _DatastoreService_GetDatastore0_Bridge_Handler(srv)) r.POST("/datastore", _DatastoreService_CreateDatastore0_Bridge_Handler(srv)) diff --git a/api/v1/services/datastore/upload_bridge.pb.go b/api/v1/services/datastore/upload_bridge.pb.go index 75a9e4a2..16a27a94 100644 --- a/api/v1/services/datastore/upload_bridge.pb.go +++ b/api/v1/services/datastore/upload_bridge.pb.go @@ -76,7 +76,7 @@ type UploadServiceDeleteUploadHooker interface { } func RegisterUploadServiceBridgeServer(s *http.Server, srv UploadServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/upload", _UploadService_ListUpload0_Bridge_Handler(srv)) r.GET("/upload/:id", _UploadService_GetUpload0_Bridge_Handler(srv)) r.POST("/upload", _UploadService_CreateUpload0_Bridge_Handler(srv)) diff --git a/api/v1/services/message/message_bridge.pb.go b/api/v1/services/message/message_bridge.pb.go index 80f619df..14cefe32 100644 --- a/api/v1/services/message/message_bridge.pb.go +++ b/api/v1/services/message/message_bridge.pb.go @@ -105,7 +105,7 @@ type PersonalServiceUpdatePersonalSettingHooker interface { } func RegisterPersonalServiceBridgeServer(s *http.Server, srv PersonalServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/message/personal/profile", _PersonalService_GetPersonalProfile0_Bridge_Handler(srv)) r.GET("/message/personal/resources", _PersonalService_ListPersonalResources0_Bridge_Handler(srv)) r.GET("/message/personal/roles", _PersonalService_ListPersonalRoles0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/department_bridge.pb.go b/api/v1/services/system/department_bridge.pb.go index e75bd226..c4876b90 100644 --- a/api/v1/services/system/department_bridge.pb.go +++ b/api/v1/services/system/department_bridge.pb.go @@ -76,7 +76,7 @@ type DepartmentServiceDeleteDepartmentHooker interface { } func RegisterDepartmentServiceBridgeServer(s *http.Server, srv DepartmentServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/sys/departments", _DepartmentService_ListDepartments0_Bridge_Handler(srv)) r.GET("/sys/departments/:id", _DepartmentService_GetDepartment0_Bridge_Handler(srv)) r.POST("/sys/departments", _DepartmentService_CreateDepartment0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go index 5c2255bf..c1da935f 100644 --- a/api/v1/services/system/permission_bridge.pb.go +++ b/api/v1/services/system/permission_bridge.pb.go @@ -76,7 +76,7 @@ type PermissionServiceDeletePermissionHooker interface { } func RegisterPermissionServiceBridgeServer(s *http.Server, srv PermissionServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/sys/permissions", _PermissionService_ListPermissions0_Bridge_Handler(srv)) r.GET("/sys/permissions/:id", _PermissionService_GetPermission0_Bridge_Handler(srv)) r.POST("/sys/permissions", _PermissionService_CreatePermission0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/position_bridge.pb.go b/api/v1/services/system/position_bridge.pb.go index 0295df9d..9f1d551d 100644 --- a/api/v1/services/system/position_bridge.pb.go +++ b/api/v1/services/system/position_bridge.pb.go @@ -76,7 +76,7 @@ type PositionServiceDeletePositionHooker interface { } func RegisterPositionServiceBridgeServer(s *http.Server, srv PositionServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/sys/positions", _PositionService_ListPositions0_Bridge_Handler(srv)) r.GET("/sys/positions/:id", _PositionService_GetPosition0_Bridge_Handler(srv)) r.POST("/sys/positions", _PositionService_CreatePosition0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go index 6cfbfe5c..570a70aa 100644 --- a/api/v1/services/system/resource_bridge.pb.go +++ b/api/v1/services/system/resource_bridge.pb.go @@ -81,7 +81,7 @@ type ResourceServiceDeleteResourceHooker interface { } func RegisterResourceServiceBridgeServer(s *http.Server, srv ResourceServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/sys/resources", _ResourceService_ListResources0_Bridge_Handler(srv)) r.GET("/sys/resources/:id", _ResourceService_GetResource0_Bridge_Handler(srv)) r.POST("/sys/resources", _ResourceService_CreateResource0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go index 178759b3..f10a5226 100644 --- a/api/v1/services/system/role_bridge.pb.go +++ b/api/v1/services/system/role_bridge.pb.go @@ -76,7 +76,7 @@ type RoleServiceDeleteRoleHooker interface { } func RegisterRoleServiceBridgeServer(s *http.Server, srv RoleServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/sys/roles", _RoleService_ListRoles0_Bridge_Handler(srv)) r.GET("/sys/roles/:id", _RoleService_GetRole0_Bridge_Handler(srv)) r.POST("/sys/roles", _RoleService_CreateRole0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 0eae15fd..655b3438 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -107,7 +107,7 @@ type UserServiceResetUserPasswordHooker interface { } func RegisterUserServiceBridgeServer(s *http.Server, srv UserServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/sys/users", _UserService_ListUsers0_Bridge_Handler(srv)) r.GET("/sys/users/:id/resources", _UserService_ListUserResources0_Bridge_Handler(srv)) r.GET("/sys/users/:id", _UserService_GetUser0_Bridge_Handler(srv)) diff --git a/api/v1/services/system/view_bridge.pb.go b/api/v1/services/system/view_bridge.pb.go index 02a9a117..a4e5739b 100644 --- a/api/v1/services/system/view_bridge.pb.go +++ b/api/v1/services/system/view_bridge.pb.go @@ -81,7 +81,7 @@ type ViewServiceDeleteViewHooker interface { } func RegisterViewServiceBridgeServer(s *http.Server, srv ViewServiceHookedBridger) { - r := s.Route("/api/v1") + r := s.Route("/") r.GET("/sys/views", _ViewService_ListViews0_Bridge_Handler(srv)) r.GET("/sys/views/:id", _ViewService_GetView0_Bridge_Handler(srv)) r.POST("/sys/views", _ViewService_CreateView0_Bridge_Handler(srv)) diff --git a/buf.gen.yaml b/buf.gen.yaml index d30f68fa..5420344f 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -45,7 +45,6 @@ plugins: out: api/v1/services opt: - paths=source_relative - - prefix=/api/v1 - local: protoc-gen-grpc-gateway out: api/v1/services opt: paths=source_relative diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index 165af4f9..fd4b7319 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -83,13 +83,7 @@ func NewHTTPServer( if err != nil { return nil, err } - - // Get a router group with the /api/v1 prefix. - // All subsequent routes registered on this router will be automatically prefixed. - apiRouter := srv.Route("/api/v1") - - // Register all services onto this specific router group. - svc.RegisterHTTPHandlers(apiRouter) - + // Register all services using the GatewayService method. + svc.RegisterHTTPHandlers(srv) return srv, nil } diff --git a/internal/gateway/service/service.go b/internal/gateway/service/service.go index 0e49f2eb..7b41348a 100644 --- a/internal/gateway/service/service.go +++ b/internal/gateway/service/service.go @@ -5,10 +5,12 @@ package service import ( + stdhttp "net/http" + "github.com/google/wire" + "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service/transport" - "github.com/origadmin/runtime/service/transport/http" "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/gateway/client" @@ -36,16 +38,21 @@ func NewGatewayService(authClient *client.AuthBridgeSet, systemClient *client.Sy } // RegisterHTTPHandlers registers all the HTTP handlers for the downstream services -// onto the provided HTTP router. -func (s *GatewayService) RegisterHTTPHandlers(router *transport.RouterHTTP) { +// onto the provided HTTP server. It also logs the registered routes. +func (s *GatewayService) RegisterHTTPHandlers(srv *transport.HTTPServer) { // Register handlers for the 'system' service - system.RegisterUserServiceHTTPServer(router, s.System.User) - system.RegisterRoleServiceHTTPServer(router, s.System.Role) - system.RegisterPermissionServiceHTTPServer(router, s.System.Permission) - system.RegisterResourceServiceHTTPServer(router, s.System.Resource) - system.RegisterViewServiceHTTPServer(router, s.System.View) + system.RegisterUserServiceHTTPServer(srv, s.System.User) + system.RegisterRoleServiceHTTPServer(srv, s.System.Role) + system.RegisterPermissionServiceHTTPServer(srv, s.System.Permission) + system.RegisterResourceServiceHTTPServer(srv, s.System.Resource) + system.RegisterViewServiceHTTPServer(srv, s.System.View) // Register handlers for the 'auth' service - auth.RegisterAuthServiceHTTPServer(router, s.Auth.Auth) - auth.RegisterMeServiceHTTPServer(router, s.Auth.Me) + auth.RegisterAuthServiceHTTPServer(srv, s.Auth.Auth) + auth.RegisterMeServiceHTTPServer(srv, s.Auth.Me) + + // Log all registered HTTP routes for debugging and verification + srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { + log.Infof("HTTP %s %s", method, path) + }) } From 6cf6eec672e5a48d411b95dec98c650af963d88b Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 19:42:55 +0800 Subject: [PATCH 131/158] feat(gateway): add path prefix and move route logging to server initialization --- api/http/api/v1/sys/rbac.http | 2 +- internal/gateway/server/server.go | 9 +++++++++ internal/gateway/service/service.go | 8 -------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/api/http/api/v1/sys/rbac.http b/api/http/api/v1/sys/rbac.http index 94285934..35c4797f 100644 --- a/api/http/api/v1/sys/rbac.http +++ b/api/http/api/v1/sys/rbac.http @@ -1,5 +1,5 @@ @token = eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzYyNzEyMDEsImlzcyI6ImxvY2FsaG9zdCIsInN1YiI6ImFkbWluIn0.3x9WnK9OZQUFdYYBAwVwqtNrMK3VRZJjBgQXRnQLNd8K4m0WwfTyAiA1TfwlUyh8t95WXfl99AkXJEJUWAQppg -@host = http://127.0.0.1:8080 +@host = http://127.0.0.1:8000 ### # RBAC - Resources diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index fd4b7319..b9a544d4 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -6,8 +6,10 @@ package server import ( "errors" + stdhttp "net/http" "github.com/go-kratos/kratos/v2/log" + kratoshttp "github.com/go-kratos/kratos/v2/transport/http" "github.com/google/wire" "github.com/origadmin/runtime" @@ -76,6 +78,9 @@ func NewHTTPServer( return nil, err } opts := &http.ServerOptions{ + ServerOptions: []kratoshttp.ServerOption{ + kratoshttp.PathPrefix("/api/v1"), + }, ServerMiddlewares: mws, } @@ -85,5 +90,9 @@ func NewHTTPServer( } // Register all services using the GatewayService method. svc.RegisterHTTPHandlers(srv) + // Log all registered HTTP routes for debugging and verification + srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { + log.Infof("HTTP %s %s", method, path) + }) return srv, nil } diff --git a/internal/gateway/service/service.go b/internal/gateway/service/service.go index 7b41348a..8d85e840 100644 --- a/internal/gateway/service/service.go +++ b/internal/gateway/service/service.go @@ -5,11 +5,8 @@ package service import ( - stdhttp "net/http" - "github.com/google/wire" - "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service/transport" "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/api/v1/services/system" @@ -50,9 +47,4 @@ func (s *GatewayService) RegisterHTTPHandlers(srv *transport.HTTPServer) { // Register handlers for the 'auth' service auth.RegisterAuthServiceHTTPServer(srv, s.Auth.Auth) auth.RegisterMeServiceHTTPServer(srv, s.Auth.Me) - - // Log all registered HTTP routes for debugging and verification - srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { - log.Infof("HTTP %s %s", method, path) - }) } From 67deedc780ea75b6ce4bf4186f971a1b13dd97bf Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 20:07:19 +0800 Subject: [PATCH 132/158] feat(seed): add database seeding command with root user initialization support --- cmd/seed/main.go | 69 +++++++++++++++++ cmd/seed/wire.go | 37 ++++++++++ cmd/seed/wire.work.go | 12 +++ cmd/seed/wire_gen.go | 52 +++++++++++++ internal/conf/pb/root.proto | 46 +++--------- internal/data/data.go | 4 +- internal/tasks/seeder/seeder.go | 123 +++++++++++++++++++++++++++++++ resources/configs/bootstrap.yaml | 3 + 8 files changed, 310 insertions(+), 36 deletions(-) create mode 100644 cmd/seed/main.go create mode 100644 cmd/seed/wire.go create mode 100644 cmd/seed/wire.work.go create mode 100644 cmd/seed/wire_gen.go create mode 100644 internal/tasks/seeder/seeder.go diff --git a/cmd/seed/main.go b/cmd/seed/main.go new file mode 100644 index 00000000..00a2537f --- /dev/null +++ b/cmd/seed/main.go @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// The seed command is a one-off task to initialize the database with default data. +package main + +import ( + "flag" + + "github.com/joho/godotenv" + _ "github.com/sqlite3ent/sqlite3" // Import for sqlite3 driver + + "github.com/origadmin/runtime" + runtimebootstrap "github.com/origadmin/runtime/bootstrap" + "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/conf" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" + confhelper "origadmin/application/admin/internal/helpers/conf" +) + +var ( + // Name is the name of the compiled software. + Name = "origadmin.task.seed" + // Version is the version of the compiled software. + Version = "v1.0.0" + + // flagconf is the config flag. + flagconf string +) + +func init() { + flag.StringVar(&flagconf, "conf", "", "config path, eg: -conf bootstrap.yaml") +} + +func main() { + _ = godotenv.Load("resources/.env.system") + flag.Parse() + + confPath := confhelper.FindConfPath(flagconf) + if confPath == "" { + log.Fatal("Could not find configuration file.") + } + + rt := runtime.New(Name, Version) + if err := rt.Load(confPath, runtimebootstrap.WithConfigTransformer(conf.New())); err != nil { + log.Fatalf("failed to create runtime: %v", err) + } + defer rt.Config().Close() + + bootstrapConfig, ok := rt.StructuredConfig().(*conf.Config) + if !ok { + log.Fatalf("failed to get bootstrap config") + } + + // wireApp builds the dependencies needed for the seed task. + s, cleanup, err := wireApp(rt, bootstrapConfig) + if err != nil { + log.Fatalf("failed to wire app: %v", err) + } + defer cleanup() + + // Execute the seed task. + if err := s.Run(); err != nil { + log.Fatalf("seed task failed: %v", err) + } + + log.Info("seed task completed successfully.") +} diff --git a/cmd/seed/wire.go b/cmd/seed/wire.go new file mode 100644 index 00000000..e6eaf98b --- /dev/null +++ b/cmd/seed/wire.go @@ -0,0 +1,37 @@ +//go:build wireinject +// +build wireinject + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// The build tag makes sure the stub is not built in the final build. +package main + +import ( + "github.com/google/wire" + + "github.com/origadmin/runtime" + "origadmin/application/admin/internal/conf" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/features/system/biz" + "origadmin/application/admin/internal/features/system/dal" + "origadmin/application/admin/internal/helpers/providers" + "origadmin/application/admin/internal/tasks/seeder" +) + +// wireApp init kratos application. +func wireApp(app *runtime.App, bootstrap *conf.Config) (*seeder.Seeder, func(), error) { + panic(wire.Build( + // Shared infrastructure providers + providers.ProviderSet, + + // Data and Biz layers are needed for seeding + data.ProviderSet, + dal.ProviderSet, + biz.ProviderSet, + + // The Seeder itself + seeder.ProviderSet, + )) +} diff --git a/cmd/seed/wire.work.go b/cmd/seed/wire.work.go new file mode 100644 index 00000000..059f2257 --- /dev/null +++ b/cmd/seed/wire.work.go @@ -0,0 +1,12 @@ +//go:build !wireinject && GOWORK +// +build !wireinject,GOWORK + +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// The build tag makes sure the stub is not built in the final build. +//go:generate go run github.com/google/wire/cmd/wire + +// Package main is a main package +package main diff --git a/cmd/seed/wire_gen.go b/cmd/seed/wire_gen.go new file mode 100644 index 00000000..093cede1 --- /dev/null +++ b/cmd/seed/wire_gen.go @@ -0,0 +1,52 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate go run -mod=mod github.com/google/wire/cmd/wire +//go:build !wireinject +// +build !wireinject + +package main + +import ( + "github.com/origadmin/runtime" + "origadmin/application/admin/internal/conf" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/features/system/biz" + "origadmin/application/admin/internal/features/system/dal" + "origadmin/application/admin/internal/helpers/providers" + "origadmin/application/admin/internal/tasks/seeder" +) + +import ( + _ "github.com/sqlite3ent/sqlite3" + _ "origadmin/application/admin/internal/data/entity/ent/runtime" +) + +// Injectors from wire.go: + +// wireApp init kratos application. +func wireApp(app *runtime.App, bootstrap *conf.Config) (*seeder.Seeder, func(), error) { + provider, err := data.NewStorageProvider(app) + if err != nil { + return nil, nil, err + } + v := providers.ProvideLogger(app) + database, cleanup, err := data.ProvideDatabase(provider, v) + if err != nil { + return nil, nil, err + } + userRepo := dal.NewUserRepo(database) + crypto, err := providers.ProvideHasher() + if err != nil { + cleanup() + return nil, nil, err + } + userUseCase := biz.NewUserUseCase(userRepo, crypto) + seederSeeder, err := seeder.NewSeeder(userUseCase, bootstrap, v) + if err != nil { + cleanup() + return nil, nil, err + } + return seederSeeder, func() { + cleanup() + }, nil +} diff --git a/internal/conf/pb/root.proto b/internal/conf/pb/root.proto index c4452908..5129afe5 100644 --- a/internal/conf/pb/root.proto +++ b/internal/conf/pb/root.proto @@ -2,41 +2,19 @@ syntax = "proto3"; package conf.pb; -import "validate/validate.proto"; - option go_package = "origadmin/application/admin/internal/conf/pb;confpb"; +// RootUser defines the configuration for the initial administrator user. +// This is used by the seed command. message RootUser { - bool enabled = 1 [json_name = "enabled"]; - string id = 2 [ - json_name = "id", - (validate.rules).string.min_len = 1 // Assuming id should not be empty - ]; - string username = 3 [ - json_name = "username", - (validate.rules).string.min_len = 1 // Required field - ]; - string password = 4 [ - json_name = "password", - (validate.rules).string = { - min_len: 6 - max_len: 32 - } - ]; - string salt = 5 [ - json_name = "salt", - (validate.rules).string = { - min_len: 6 - max_len: 12 - } - ]; - string name = 6 [json_name = "name"]; - string email = 7 [json_name = "email"]; - string nickname = 8 [json_name = "nickname"]; - string avatar = 9 [json_name = "avatar"]; - string mobile = 10 [json_name = "mobile"]; - string description = 11 [json_name = "description"]; - - bool auto_create = 100 [json_name = "auto_create"]; - bool random_password = 101 [json_name = "random_password"]; + // enabled controls whether the root user initialization task should run. + bool enabled = 1; + // username for the root user. + string username = 2; + // password for the root user. It is strongly recommended to change this after the first login. + string password = 3; + // nickname for the root user. + optional string nickname = 4; + // email for the root user. + optional string email = 5; } diff --git a/internal/data/data.go b/internal/data/data.go index 7c7507b5..401ba4f8 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -36,7 +36,7 @@ func ProvideDatabase(pv storage.Provider, logger log.Logger) (*ent.Database, fun } activeDB := entsql.OpenDB(db.Dialect(), db.DB()) - database := ent.NewDatabase(ent.Driver(activeDB)) + database := ent.NewDatabase(ent.Driver(activeDB), ent.Debug()) return database, func() { if database != nil { if err := database.Client(context.Background()).Close(); err != nil { @@ -67,7 +67,7 @@ func NewData(database *ent.Database, logger log.Logger) (*Data, error) { ); err != nil { logHelper.Fatalf("failed creating schema resources: %v", err) } - ent.Debug() + d := &Data{ DB: database, log: logHelper, diff --git a/internal/tasks/seeder/seeder.go b/internal/tasks/seeder/seeder.go new file mode 100644 index 00000000..f3372397 --- /dev/null +++ b/internal/tasks/seeder/seeder.go @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package seeder contains the implementation for database seeding tasks. +package seeder + +import ( + "context" + "crypto/rand" + "math/big" + + "github.com/go-kratos/kratos/v2/log" + "github.com/google/wire" + + "origadmin/application/admin/api/v1/services/system" + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/conf" + "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/features/system/biz" +) + +// ProviderSet is for wire injection. +var ProviderSet = wire.NewSet(NewSeeder) + +const ( + passwordCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + passwordLength = 16 +) + +// Seeder is the container for initialization tasks. +type Seeder struct { + userUseCase *biz.UserUseCase + rootUserCfg *confpb.RootUser + log *log.Helper +} + +// NewSeeder creates a new Seeder. +func NewSeeder(userUseCase *biz.UserUseCase, cfg *conf.Config, logger log.Logger) (*Seeder, error) { + return &Seeder{ + userUseCase: userUseCase, + rootUserCfg: cfg.RootUser(), + log: log.NewHelper(log.With(logger, "module", "seeder")), + }, nil +} + +// Run executes all seeding tasks. +func (s *Seeder) Run() error { + if err := s.createRootUser(); err != nil { + return err + } + // Add other seeding tasks here, e.g., s.createInitialMenus() + return nil +} + +// createRootUser creates the initial administrator user if it does not exist. +// If the password in the config is empty, a random one will be generated and printed. +func (s *Seeder) createRootUser() error { + if s.rootUserCfg == nil || !s.rootUserCfg.Enabled { + s.log.Info("Root user seeding is disabled in config.") + return nil + } + + ctx := context.Background() + username := s.rootUserCfg.GetUsername() + + // 1. Check if the user already exists by trying to list them. + listReq := &system.ListUsersRequest{ + Keyword: username, + PageSize: 1, + } + existingUsers, total, err := s.userUseCase.ListUsers(ctx, listReq) + if err != nil { + s.log.Errorf("Failed to check for root user: %v", err) + return err + } + if total > 0 || len(existingUsers) > 0 { + s.log.Infof("Root user '%s' already exists, skipping creation.", username) + return nil + } + + // 2. If not found, create the new user. + s.log.Infof("Root user '%s' not found, creating...", username) + + password := s.rootUserCfg.GetPassword() + if password == "" { + var err error + password, err = generateRandomPassword(passwordLength) + if err != nil { + s.log.Errorf("Failed to generate random password: %v", err) + return err + } + s.log.Infof("Generated random password for user '%s': %s", username, password) + } + + newUser := &types.User{ + Username: username, + Nickname: s.rootUserCfg.GetNickname(), + Email: s.rootUserCfg.GetEmail(), + } + + createdUser, err := s.userUseCase.CreateUser(ctx, newUser, password) + if err != nil { + s.log.Errorf("Failed to create root user '%s': %v", username, err) + return err + } + + s.log.Infof("Successfully created root user '%s' with ID: %d", createdUser.Username, createdUser.Id) + return nil +} + +// generateRandomPassword creates a random string of a given length. +func generateRandomPassword(length int) (string, error) { + b := make([]byte, length) + for i := range b { + num, err := rand.Int(rand.Reader, big.NewInt(int64(len(passwordCharset)))) + if err != nil { + return "", err + } + b[i] = passwordCharset[num.Int64()] + } + return string(b), nil +} diff --git a/resources/configs/bootstrap.yaml b/resources/configs/bootstrap.yaml index c8145c29..e77d0825 100644 --- a/resources/configs/bootstrap.yaml +++ b/resources/configs/bootstrap.yaml @@ -24,5 +24,8 @@ sources: - file: path: discovery.yaml type: file + - file: + path: root_user.yaml + type: file # Environment variables are loaded last to override file settings. - type: env From cc22a06622212a2533f2a4b43fa3619f11b10881 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 21:53:36 +0800 Subject: [PATCH 133/158] feat(ent): update schema configuration for entity models with detailed field definitions and relationships --- internal/data/data.go | 11 +- internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 66 +++---- internal/data/entity/ent/mutation.go | 163 +----------------- internal/data/entity/ent/mutation_fields.go | 14 -- .../data/entity/ent/permission/permission.go | 2 +- .../permissionresource/permissionresource.go | 2 +- internal/data/entity/ent/resource.go | 2 +- internal/data/entity/ent/resource/resource.go | 2 +- internal/data/entity/ent/runtime/runtime.go | 7 +- internal/data/entity/ent/schema/resource.go | 11 ++ internal/data/entity/ent/schema/user.go | 57 ++++-- internal/data/entity/ent/user.go | 26 +-- internal/data/entity/ent/user/user.go | 20 +-- internal/data/entity/ent/user/where.go | 125 -------------- internal/data/entity/ent/user_create.go | 43 ----- internal/data/entity/ent/user_query.go | 4 - internal/data/entity/ent/user_update.go | 106 ------------ internal/data/entity/ent/view/view.go | 2 +- .../entity/ent/viewresource/viewresource.go | 2 +- resources/configs/databases.yaml | 2 +- 21 files changed, 115 insertions(+), 554 deletions(-) diff --git a/internal/data/data.go b/internal/data/data.go index 401ba4f8..40434156 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -7,6 +7,7 @@ package data import ( "context" + "fmt" entsql "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/schema" @@ -37,6 +38,14 @@ func ProvideDatabase(pv storage.Provider, logger log.Logger) (*ent.Database, fun activeDB := entsql.OpenDB(db.Dialect(), db.DB()) database := ent.NewDatabase(ent.Driver(activeDB), ent.Debug()) + // === The migration logic is moved here === + if err := database.Migration(context.Background(), + schema.WithDropIndex(true), + schema.WithDropColumn(true), + schema.WithForeignKeys(false), + ); err != nil { + return nil, nil, fmt.Errorf("failed creating schema resources: %w", err) + } return database, func() { if database != nil { if err := database.Client(context.Background()).Close(); err != nil { @@ -65,7 +74,7 @@ func NewData(database *ent.Database, logger log.Logger) (*Data, error) { schema.WithDropColumn(true), schema.WithForeignKeys(false), ); err != nil { - logHelper.Fatalf("failed creating schema resources: %v", err) + return nil, fmt.Errorf("failed creating schema resources: %w", err) } d := &Data{ diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index 7175fa98..b2ffc194 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}]},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"},{\"name\":\"manager_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.user.field.manager_id\"},{\"name\":\"manager\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.manager\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index c3237f6b..1eed1115 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -179,9 +179,9 @@ var ( OnDelete: schema.NoAction, }, { - Symbol: "sys_permission_resources_resources_resource", + Symbol: "sys_permission_resources_sys_resources_resource", Columns: []*schema.Column{SysPermissionResourcesColumns[2]}, - RefColumns: []*schema.Column{ResourcesColumns[0]}, + RefColumns: []*schema.Column{SysResourcesColumns[0]}, OnDelete: schema.NoAction, }, }, @@ -264,37 +264,38 @@ var ( }, }, } - // ResourcesColumns holds the columns for the "resources" table. - ResourcesColumns = []*schema.Column{ - {Name: "id", Type: field.TypeInt64}, - {Name: "create_time", Type: field.TypeTime}, - {Name: "update_time", Type: field.TypeTime}, - {Name: "service_name", Type: field.TypeString}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255}, - {Name: "path", Type: field.TypeString, Nullable: true}, - {Name: "method", Type: field.TypeString, Nullable: true}, - {Name: "operation", Type: field.TypeString, Nullable: true}, - {Name: "policy", Type: field.TypeString, Default: ""}, - {Name: "version_id", Type: field.TypeString, Default: ""}, - {Name: "last_sync_version_id", Type: field.TypeString, Default: ""}, - {Name: "sync_status", Type: field.TypeString, Default: "Synced"}, - {Name: "status", Type: field.TypeEnum, Enums: []string{"enabled", "disabled"}, Default: "enabled"}, - } - // ResourcesTable holds the schema information for the "resources" table. - ResourcesTable = &schema.Table{ - Name: "resources", - Columns: ResourcesColumns, - PrimaryKey: []*schema.Column{ResourcesColumns[0]}, + // SysResourcesColumns holds the columns for the "sys_resources" table. + SysResourcesColumns = []*schema.Column{ + {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, + {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, + {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, + {Name: "service_name", Type: field.TypeString, Comment: "resource.service_name.comment"}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "resource.keyword.comment"}, + {Name: "path", Type: field.TypeString, Nullable: true, Comment: "resource.path.comment"}, + {Name: "method", Type: field.TypeString, Nullable: true, Comment: "resource.method.comment"}, + {Name: "operation", Type: field.TypeString, Nullable: true, Comment: "resource.operation.comment"}, + {Name: "policy", Type: field.TypeString, Comment: "resource.policy.comment", Default: ""}, + {Name: "version_id", Type: field.TypeString, Comment: "resource.version_id.comment", Default: ""}, + {Name: "last_sync_version_id", Type: field.TypeString, Comment: "resource.last_sync_version_id.comment", Default: ""}, + {Name: "sync_status", Type: field.TypeString, Comment: "resource.sync_status.comment", Default: "Synced"}, + {Name: "status", Type: field.TypeEnum, Comment: "resource.status.comment", Enums: []string{"enabled", "disabled"}, Default: "enabled"}, + } + // SysResourcesTable holds the schema information for the "sys_resources" table. + SysResourcesTable = &schema.Table{ + Name: "sys_resources", + Comment: "entity.resource.table.comment", + Columns: SysResourcesColumns, + PrimaryKey: []*schema.Column{SysResourcesColumns[0]}, Indexes: []*schema.Index{ { Name: "resource_create_time", Unique: false, - Columns: []*schema.Column{ResourcesColumns[1]}, + Columns: []*schema.Column{SysResourcesColumns[1]}, }, { Name: "resource_update_time", Unique: false, - Columns: []*schema.Column{ResourcesColumns[2]}, + Columns: []*schema.Column{SysResourcesColumns[2]}, }, }, } @@ -411,8 +412,6 @@ var ( {Name: "last_login_time", Type: field.TypeTime, Comment: "entity.user.field.last_login_time", SchemaType: map[string]string{"mysql": "datetime"}}, {Name: "login_time", Type: field.TypeTime, Comment: "entity.user.field.login_time", SchemaType: map[string]string{"mysql": "datetime"}}, {Name: "sanction_date", Type: field.TypeTime, Nullable: true, Comment: "entity.user.field.sanction_date", SchemaType: map[string]string{"mysql": "datetime"}}, - {Name: "manager_id", Type: field.TypeInt64, Nullable: true, Comment: "entity.user.field.manager_id"}, - {Name: "manager", Type: field.TypeString, Comment: "entity.user.field.manager", Default: ""}, } // SysUsersTable holds the schema information for the "sys_users" table. SysUsersTable = &schema.Table{ @@ -696,9 +695,9 @@ var ( OnDelete: schema.NoAction, }, { - Symbol: "sys_view_resources_resources_resource", + Symbol: "sys_view_resources_sys_resources_resource", Columns: []*schema.Column{SysViewResourcesColumns[6]}, - RefColumns: []*schema.Column{ResourcesColumns[0]}, + RefColumns: []*schema.Column{SysResourcesColumns[0]}, OnDelete: schema.NoAction, }, }, @@ -739,7 +738,7 @@ var ( SysPermissionResourcesTable, SysPositionsTable, SysPositionPermissionsTable, - ResourcesTable, + SysResourcesTable, SysRolesTable, SysRolePermissionsTable, SysUsersTable, @@ -764,7 +763,7 @@ func init() { Table: "sys_permissions", } SysPermissionResourcesTable.ForeignKeys[0].RefTable = SysPermissionsTable - SysPermissionResourcesTable.ForeignKeys[1].RefTable = ResourcesTable + SysPermissionResourcesTable.ForeignKeys[1].RefTable = SysResourcesTable SysPermissionResourcesTable.Annotation = &entsql.Annotation{ Table: "sys_permission_resources", } @@ -777,6 +776,9 @@ func init() { SysPositionPermissionsTable.Annotation = &entsql.Annotation{ Table: "sys_position_permissions", } + SysResourcesTable.Annotation = &entsql.Annotation{ + Table: "sys_resources", + } SysRolesTable.Annotation = &entsql.Annotation{ Table: "sys_roles", } @@ -813,7 +815,7 @@ func init() { Table: "sys_view_permissions", } SysViewResourcesTable.ForeignKeys[0].RefTable = SysViewsTable - SysViewResourcesTable.ForeignKeys[1].RefTable = ResourcesTable + SysViewResourcesTable.ForeignKeys[1].RefTable = SysResourcesTable SysViewResourcesTable.Annotation = &entsql.Annotation{ Table: "sys_view_resources", } diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index a586ab54..1f92931d 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -9209,9 +9209,6 @@ type UserMutation struct { last_login_time *time.Time login_time *time.Time sanction_date *time.Time - manager_id *int64 - addmanager_id *int64 - manager *string clearedFields map[string]struct{} roles map[int64]struct{} removedroles map[int64]struct{} @@ -10354,112 +10351,6 @@ func (m *UserMutation) ResetSanctionDate() { delete(m.clearedFields, user.FieldSanctionDate) } -// SetManagerID sets the "manager_id" field. -func (m *UserMutation) SetManagerID(i int64) { - m.manager_id = &i - m.addmanager_id = nil -} - -// ManagerID returns the value of the "manager_id" field in the mutation. -func (m *UserMutation) ManagerID() (r int64, exists bool) { - v := m.manager_id - if v == nil { - return - } - return *v, true -} - -// OldManagerID returns the old "manager_id" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldManagerID(ctx context.Context) (v int64, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManagerID is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManagerID requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldManagerID: %w", err) - } - return oldValue.ManagerID, nil -} - -// AddManagerID adds i to the "manager_id" field. -func (m *UserMutation) AddManagerID(i int64) { - if m.addmanager_id != nil { - *m.addmanager_id += i - } else { - m.addmanager_id = &i - } -} - -// AddedManagerID returns the value that was added to the "manager_id" field in this mutation. -func (m *UserMutation) AddedManagerID() (r int64, exists bool) { - v := m.addmanager_id - if v == nil { - return - } - return *v, true -} - -// ClearManagerID clears the value of the "manager_id" field. -func (m *UserMutation) ClearManagerID() { - m.manager_id = nil - m.addmanager_id = nil - m.clearedFields[user.FieldManagerID] = struct{}{} -} - -// ManagerIDCleared returns if the "manager_id" field was cleared in this mutation. -func (m *UserMutation) ManagerIDCleared() bool { - _, ok := m.clearedFields[user.FieldManagerID] - return ok -} - -// ResetManagerID resets all changes to the "manager_id" field. -func (m *UserMutation) ResetManagerID() { - m.manager_id = nil - m.addmanager_id = nil - delete(m.clearedFields, user.FieldManagerID) -} - -// SetManager sets the "manager" field. -func (m *UserMutation) SetManager(s string) { - m.manager = &s -} - -// Manager returns the value of the "manager" field in the mutation. -func (m *UserMutation) Manager() (r string, exists bool) { - v := m.manager - if v == nil { - return - } - return *v, true -} - -// OldManager returns the old "manager" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldManager(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldManager is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldManager requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldManager: %w", err) - } - return oldValue.Manager, nil -} - -// ResetManager resets all changes to the "manager" field. -func (m *UserMutation) ResetManager() { - m.manager = nil -} - // AddRoleIDs adds the "roles" edge to the Role entity by ids. func (m *UserMutation) AddRoleIDs(ids ...int64) { if m.roles == nil { @@ -10818,7 +10709,7 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 27) + fields := make([]string, 0, 25) if m.create_author != nil { fields = append(fields, user.FieldCreateAuthor) } @@ -10894,12 +10785,6 @@ func (m *UserMutation) Fields() []string { if m.sanction_date != nil { fields = append(fields, user.FieldSanctionDate) } - if m.manager_id != nil { - fields = append(fields, user.FieldManagerID) - } - if m.manager != nil { - fields = append(fields, user.FieldManager) - } return fields } @@ -10958,10 +10843,6 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.LoginTime() case user.FieldSanctionDate: return m.SanctionDate() - case user.FieldManagerID: - return m.ManagerID() - case user.FieldManager: - return m.Manager() } return nil, false } @@ -11021,10 +10902,6 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldLoginTime(ctx) case user.FieldSanctionDate: return m.OldSanctionDate(ctx) - case user.FieldManagerID: - return m.OldManagerID(ctx) - case user.FieldManager: - return m.OldManager(ctx) } return nil, fmt.Errorf("unknown User field %s", name) } @@ -11209,20 +11086,6 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetSanctionDate(v) return nil - case user.FieldManagerID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetManagerID(v) - return nil - case user.FieldManager: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetManager(v) - return nil } return fmt.Errorf("unknown User field %s", name) } @@ -11240,9 +11103,6 @@ func (m *UserMutation) AddedFields() []string { if m.addstatus != nil { fields = append(fields, user.FieldStatus) } - if m.addmanager_id != nil { - fields = append(fields, user.FieldManagerID) - } return fields } @@ -11257,8 +11117,6 @@ func (m *UserMutation) AddedField(name string) (ent.Value, bool) { return m.AddedUpdateAuthor() case user.FieldStatus: return m.AddedStatus() - case user.FieldManagerID: - return m.AddedManagerID() } return nil, false } @@ -11289,13 +11147,6 @@ func (m *UserMutation) AddField(name string, value ent.Value) error { } m.AddStatus(v) return nil - case user.FieldManagerID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.AddManagerID(v) - return nil } return fmt.Errorf("unknown User numeric field %s", name) } @@ -11316,9 +11167,6 @@ func (m *UserMutation) ClearedFields() []string { if m.FieldCleared(user.FieldSanctionDate) { fields = append(fields, user.FieldSanctionDate) } - if m.FieldCleared(user.FieldManagerID) { - fields = append(fields, user.FieldManagerID) - } return fields } @@ -11345,9 +11193,6 @@ func (m *UserMutation) ClearField(name string) error { case user.FieldSanctionDate: m.ClearSanctionDate() return nil - case user.FieldManagerID: - m.ClearManagerID() - return nil } return fmt.Errorf("unknown User nullable field %s", name) } @@ -11431,12 +11276,6 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldSanctionDate: m.ResetSanctionDate() return nil - case user.FieldManagerID: - m.ResetManagerID() - return nil - case user.FieldManager: - m.ResetManager() - return nil } return fmt.Errorf("unknown User field %s", name) } diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index 23ae1ba2..f9e8574b 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -829,10 +829,6 @@ func (m *UserMutation) SetFields(input *User, fields ...string) error { m.SetLoginTime(input.LoginTime) case user.FieldSanctionDate: m.SetSanctionDate(input.SanctionDate) - case user.FieldManagerID: - m.SetManagerID(input.ManagerID) - case user.FieldManager: - m.SetManager(input.Manager) case user.FieldID: m.SetID(input.ID) default: @@ -969,16 +965,6 @@ func (m *UserMutation) SetFieldsSkipZero(input *User, fields ...string) error { if input.SanctionDate.Unix() != 0 { m.SetSanctionDate(input.SanctionDate) } - case user.FieldManagerID: - // check int64 with sql.NullInt64 if it is zero - if input.ManagerID != 0 { - m.SetManagerID(input.ManagerID) - } - case user.FieldManager: - // check string with sql.NullString if it is empty - if input.Manager != "" { - m.SetManager(input.Manager) - } case user.FieldID: // check int64 with sql.NullInt64 if it is zero if input.ID != 0 { diff --git a/internal/data/entity/ent/permission/permission.go b/internal/data/entity/ent/permission/permission.go index bf300029..ad67646c 100644 --- a/internal/data/entity/ent/permission/permission.go +++ b/internal/data/entity/ent/permission/permission.go @@ -63,7 +63,7 @@ const ( ResourcesTable = "sys_permission_resources" // ResourcesInverseTable is the table name for the Resource entity. // It exists in this package in order to avoid circular dependency with the "resource" package. - ResourcesInverseTable = "resources" + ResourcesInverseTable = "sys_resources" // ViewsTable is the table that holds the views relation/edge. The primary key declared below. ViewsTable = "sys_view_permissions" // ViewsInverseTable is the table name for the View entity. diff --git a/internal/data/entity/ent/permissionresource/permissionresource.go b/internal/data/entity/ent/permissionresource/permissionresource.go index 087c01db..22d0c165 100644 --- a/internal/data/entity/ent/permissionresource/permissionresource.go +++ b/internal/data/entity/ent/permissionresource/permissionresource.go @@ -33,7 +33,7 @@ const ( ResourceTable = "sys_permission_resources" // ResourceInverseTable is the table name for the Resource entity. // It exists in this package in order to avoid circular dependency with the "resource" package. - ResourceInverseTable = "resources" + ResourceInverseTable = "sys_resources" // ResourceColumn is the table column denoting the resource relation/edge. ResourceColumn = "resource_id" ) diff --git a/internal/data/entity/ent/resource.go b/internal/data/entity/ent/resource.go index 42753cbe..9455c796 100644 --- a/internal/data/entity/ent/resource.go +++ b/internal/data/entity/ent/resource.go @@ -12,7 +12,7 @@ import ( "entgo.io/ent/dialect/sql" ) -// Resource is the model entity for the Resource schema. +// entity.resource.table.comment type Resource struct { config `json:"-"` // ID of the ent. diff --git a/internal/data/entity/ent/resource/resource.go b/internal/data/entity/ent/resource/resource.go index 695bdaf2..4b0b0da7 100644 --- a/internal/data/entity/ent/resource/resource.go +++ b/internal/data/entity/ent/resource/resource.go @@ -46,7 +46,7 @@ const ( // EdgeViewResources holds the string denoting the view_resources edge name in mutations. EdgeViewResources = "view_resources" // Table holds the table name of the resource in the database. - Table = "resources" + Table = "sys_resources" // ViewsTable is the table that holds the views relation/edge. The primary key declared below. ViewsTable = "sys_view_resources" // ViewsInverseTable is the table name for the View entity. diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index e38e4a7b..6251f63a 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -397,7 +397,10 @@ func init() { rolepermission.PermissionIDValidator = rolepermissionDescPermissionID.Validators[0].(func(int64) error) userMixin := schema.User{}.Mixin() userMixinHooks4 := userMixin[4].Hooks() + userHooks := schema.User{}.Hooks() user.Hooks[0] = userMixinHooks4[0] + user.Hooks[1] = userHooks[0] + user.Hooks[2] = userHooks[1] userMixinInters4 := userMixin[4].Interceptors() user.Interceptors[0] = userMixinInters4[0] userMixinFields0 := userMixin[0].Fields() @@ -522,10 +525,6 @@ func init() { userDescLoginTime := userFields[18].Descriptor() // user.DefaultLoginTime holds the default value on creation for the login_time field. user.DefaultLoginTime = userDescLoginTime.Default.(func() time.Time) - // userDescManager is the schema descriptor for manager field. - userDescManager := userFields[21].Descriptor() - // user.DefaultManager holds the default value on creation for the manager field. - user.DefaultManager = userDescManager.Default.(string) // userDescID is the schema descriptor for id field. userDescID := userMixinFields0[0].Descriptor() // user.DefaultID holds the default value on creation for the id field. diff --git a/internal/data/entity/ent/schema/resource.go b/internal/data/entity/ent/schema/resource.go index baf5d16b..a72f5ee5 100644 --- a/internal/data/entity/ent/schema/resource.go +++ b/internal/data/entity/ent/schema/resource.go @@ -2,6 +2,8 @@ package schema import ( "entgo.io/ent" + "entgo.io/ent/dialect/entsql" + "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" "origadmin/application/admin/internal/helpers/ent/mixin" @@ -62,6 +64,15 @@ func (Resource) Edges() []ent.Edge { } } +// Annotations of the Resource. +func (Resource) Annotations() []schema.Annotation { + return []schema.Annotation{ + entsql.Table("sys_resources"), + entsql.WithComments(true), + schema.Comment(i18n.Text("entity.resource.table.comment")), + } +} + // Mixin of the Resource. func (Resource) Mixin() []ent.Mixin { return mixin.ModelMixin diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 84dcf90d..2eb43c1f 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -6,6 +6,9 @@ package schema import ( + "context" + "fmt" + "entgo.io/ent" "entgo.io/ent/dialect/entsql" "entgo.io/ent/schema" @@ -13,6 +16,10 @@ import ( "entgo.io/ent/schema/field" "entgo.io/ent/schema/index" + gen "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/hook" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/helpers/ent/mixin" "origadmin/application/admin/internal/helpers/i18n" @@ -97,10 +104,6 @@ func (User) Fields() []ent.Field { mixin.Time("last_login_time", i18n.Text("entity.user.field.last_login_time")), mixin.Time("login_time", i18n.Text("entity.user.field.login_time")), mixin.TimeOptional("sanction_date", i18n.Text("entity.user.field.sanction_date")), - mixin.OptionalFK("manager_id", i18n.Text("entity.user.field.manager_id")), - field.String("manager"). - Default(""). - Comment(i18n.Text("entity.user.field.manager")), } } @@ -131,22 +134,52 @@ func (User) Annotations() []schema.Annotation { // Edges of the User. func (User) Edges() []ent.Edge { return []ent.Edge{ - // Roles of user edge.To("roles", Role.Type). Through("user_roles", UserRole.Type), - // Posts of user - // edge.To("posts", Post.Type). - // Through("user_posts", UserPost.Type), - // Departments of user edge.To("positions", Position.Type). Through("user_positions", UserPosition.Type), - //// Departments of user edge.To("departments", Department.Type). Through("user_departments", UserDepartment.Type), - //edge.To("user_departments", UserDepartment.Type), } } +// preventDuplicateSystemUser is a hook that prevents creating more than one system user. +func preventDuplicateSystemUser(next ent.Mutator) ent.Mutator { + return hook.UserFunc(func(ctx context.Context, m *gen.UserMutation) (ent.Value, error) { + isSystem, ok := m.IsSystem() + if !ok || !isSystem { + return next.Mutate(ctx, m) + } + // If creating a system user, check if one already exists. + count, err := m.Client().User. + Query(). + Where(user.IsSystem(true)). + Count(ctx) + if err != nil { + return nil, fmt.Errorf("failed to check for existing system user: %w", err) + } + if count > 0 { + return nil, fmt.Errorf("a system user already exists") + } + return next.Mutate(ctx, m) + }) +} + +// preventDeleteSystemUser is a hook that prevents deleting a system user. +func preventDeleteSystemUser(next ent.Mutator) ent.Mutator { + return hook.UserFunc(func(ctx context.Context, m *gen.UserMutation) (ent.Value, error) { + // Add a predicate to ensure system users are not included in the delete operation. + m.Where(user.IsSystem(false)) + return next.Mutate(ctx, m) + }) +} + +// Hooks of the User. func (User) Hooks() []ent.Hook { - return []ent.Hook{} + return []ent.Hook{ + // On CREATE, prevent creating more than one system user. + hook.On(preventDuplicateSystemUser, ent.OpCreate), + // On DELETE, prevent system users from being deleted. + hook.On(preventDeleteSystemUser, ent.OpDelete|ent.OpDeleteOne), + } } diff --git a/internal/data/entity/ent/user.go b/internal/data/entity/ent/user.go index 63f898e9..d88706b5 100644 --- a/internal/data/entity/ent/user.go +++ b/internal/data/entity/ent/user.go @@ -71,10 +71,6 @@ type User struct { LoginTime time.Time `json:"login_time,omitempty"` // entity.user.field.sanction_date SanctionDate time.Time `json:"sanction_date,omitempty"` - // entity.user.field.manager_id - ManagerID int64 `json:"manager_id,omitempty"` - // entity.user.field.manager - Manager string `json:"manager,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the UserQuery when eager-loading is set. Edges UserEdges `json:"edges"` @@ -161,9 +157,9 @@ func (*User) scanValues(columns []string) ([]any, error) { switch columns[i] { case user.FieldIsSystem: values[i] = new(sql.NullBool) - case user.FieldID, user.FieldCreateAuthor, user.FieldUpdateAuthor, user.FieldStatus, user.FieldManagerID: + case user.FieldID, user.FieldCreateAuthor, user.FieldUpdateAuthor, user.FieldStatus: values[i] = new(sql.NullInt64) - case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldEncryptedPassword, user.FieldSalt, user.FieldPhone, user.FieldEmail, user.FieldDepartment, user.FieldRemark, user.FieldToken, user.FieldLastLoginIP, user.FieldManager: + case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldEncryptedPassword, user.FieldSalt, user.FieldPhone, user.FieldEmail, user.FieldDepartment, user.FieldRemark, user.FieldToken, user.FieldLastLoginIP: values[i] = new(sql.NullString) case user.FieldCreateTime, user.FieldUpdateTime, user.FieldDeleteTime, user.FieldLastLoginTime, user.FieldLoginTime, user.FieldSanctionDate: values[i] = new(sql.NullTime) @@ -339,18 +335,6 @@ func (_m *User) assignValues(columns []string, values []any) error { } else if value.Valid { _m.SanctionDate = value.Time } - case user.FieldManagerID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field manager_id", values[i]) - } else if value.Valid { - _m.ManagerID = value.Int64 - } - case user.FieldManager: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field manager", values[i]) - } else if value.Valid { - _m.Manager = value.String - } default: _m.selectValues.Set(columns[i], values[i]) } @@ -493,12 +477,6 @@ func (_m *User) String() string { builder.WriteString(", ") builder.WriteString("sanction_date=") builder.WriteString(_m.SanctionDate.Format(time.ANSIC)) - builder.WriteString(", ") - builder.WriteString("manager_id=") - builder.WriteString(fmt.Sprintf("%v", _m.ManagerID)) - builder.WriteString(", ") - builder.WriteString("manager=") - builder.WriteString(_m.Manager) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/user/user.go b/internal/data/entity/ent/user/user.go index 0b354301..774a9b44 100644 --- a/internal/data/entity/ent/user/user.go +++ b/internal/data/entity/ent/user/user.go @@ -67,10 +67,6 @@ const ( FieldLoginTime = "login_time" // FieldSanctionDate holds the string denoting the sanction_date field in the database. FieldSanctionDate = "sanction_date" - // FieldManagerID holds the string denoting the manager_id field in the database. - FieldManagerID = "manager_id" - // FieldManager holds the string denoting the manager field in the database. - FieldManager = "manager" // EdgeRoles holds the string denoting the roles edge name in mutations. EdgeRoles = "roles" // EdgePositions holds the string denoting the positions edge name in mutations. @@ -150,8 +146,6 @@ var Columns = []string{ FieldLastLoginTime, FieldLoginTime, FieldSanctionDate, - FieldManagerID, - FieldManager, } var ( @@ -187,7 +181,7 @@ func ValidColumn(column string) bool { // // import _ "origadmin/application/admin/internal/data/entity/ent/runtime" var ( - Hooks [1]ent.Hook + Hooks [3]ent.Hook Interceptors [1]ent.Interceptor // DefaultCreateAuthor holds the default value on creation for the "create_author" field. DefaultCreateAuthor int64 @@ -257,8 +251,6 @@ var ( DefaultLastLoginTime func() time.Time // DefaultLoginTime holds the default value on creation for the "login_time" field. DefaultLoginTime func() time.Time - // DefaultManager holds the default value on creation for the "manager" field. - DefaultManager string // DefaultID holds the default value on creation for the "id" field. DefaultID func() int64 // IDValidator is a validator for the "id" field. It is called by the builders before save. @@ -425,16 +417,6 @@ func BySanctionDate(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSanctionDate, opts...).ToFunc() } -// ByManagerID orders the results by the manager_id field. -func ByManagerID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldManagerID, opts...).ToFunc() -} - -// ByManager orders the results by the manager field. -func ByManager(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldManager, opts...).ToFunc() -} - // ByRolesCount orders the results by roles count. func ByRolesCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/internal/data/entity/ent/user/where.go b/internal/data/entity/ent/user/where.go index 76205250..0586c094 100644 --- a/internal/data/entity/ent/user/where.go +++ b/internal/data/entity/ent/user/where.go @@ -177,16 +177,6 @@ func SanctionDate(v time.Time) predicate.User { return predicate.User(sql.FieldEQ(FieldSanctionDate, v)) } -// ManagerID applies equality check predicate on the "manager_id" field. It's identical to ManagerIDEQ. -func ManagerID(v int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldManagerID, v)) -} - -// Manager applies equality check predicate on the "manager" field. It's identical to ManagerEQ. -func Manager(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldManager, v)) -} - // CreateAuthorEQ applies the EQ predicate on the "create_author" field. func CreateAuthorEQ(v int64) predicate.User { return predicate.User(sql.FieldEQ(FieldCreateAuthor, v)) @@ -1541,121 +1531,6 @@ func SanctionDateNotNil() predicate.User { return predicate.User(sql.FieldNotNull(FieldSanctionDate)) } -// ManagerIDEQ applies the EQ predicate on the "manager_id" field. -func ManagerIDEQ(v int64) predicate.User { - return predicate.User(sql.FieldEQ(FieldManagerID, v)) -} - -// ManagerIDNEQ applies the NEQ predicate on the "manager_id" field. -func ManagerIDNEQ(v int64) predicate.User { - return predicate.User(sql.FieldNEQ(FieldManagerID, v)) -} - -// ManagerIDIn applies the In predicate on the "manager_id" field. -func ManagerIDIn(vs ...int64) predicate.User { - return predicate.User(sql.FieldIn(FieldManagerID, vs...)) -} - -// ManagerIDNotIn applies the NotIn predicate on the "manager_id" field. -func ManagerIDNotIn(vs ...int64) predicate.User { - return predicate.User(sql.FieldNotIn(FieldManagerID, vs...)) -} - -// ManagerIDGT applies the GT predicate on the "manager_id" field. -func ManagerIDGT(v int64) predicate.User { - return predicate.User(sql.FieldGT(FieldManagerID, v)) -} - -// ManagerIDGTE applies the GTE predicate on the "manager_id" field. -func ManagerIDGTE(v int64) predicate.User { - return predicate.User(sql.FieldGTE(FieldManagerID, v)) -} - -// ManagerIDLT applies the LT predicate on the "manager_id" field. -func ManagerIDLT(v int64) predicate.User { - return predicate.User(sql.FieldLT(FieldManagerID, v)) -} - -// ManagerIDLTE applies the LTE predicate on the "manager_id" field. -func ManagerIDLTE(v int64) predicate.User { - return predicate.User(sql.FieldLTE(FieldManagerID, v)) -} - -// ManagerIDIsNil applies the IsNil predicate on the "manager_id" field. -func ManagerIDIsNil() predicate.User { - return predicate.User(sql.FieldIsNull(FieldManagerID)) -} - -// ManagerIDNotNil applies the NotNil predicate on the "manager_id" field. -func ManagerIDNotNil() predicate.User { - return predicate.User(sql.FieldNotNull(FieldManagerID)) -} - -// ManagerEQ applies the EQ predicate on the "manager" field. -func ManagerEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldManager, v)) -} - -// ManagerNEQ applies the NEQ predicate on the "manager" field. -func ManagerNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldManager, v)) -} - -// ManagerIn applies the In predicate on the "manager" field. -func ManagerIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldManager, vs...)) -} - -// ManagerNotIn applies the NotIn predicate on the "manager" field. -func ManagerNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldManager, vs...)) -} - -// ManagerGT applies the GT predicate on the "manager" field. -func ManagerGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldManager, v)) -} - -// ManagerGTE applies the GTE predicate on the "manager" field. -func ManagerGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldManager, v)) -} - -// ManagerLT applies the LT predicate on the "manager" field. -func ManagerLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldManager, v)) -} - -// ManagerLTE applies the LTE predicate on the "manager" field. -func ManagerLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldManager, v)) -} - -// ManagerContains applies the Contains predicate on the "manager" field. -func ManagerContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldManager, v)) -} - -// ManagerHasPrefix applies the HasPrefix predicate on the "manager" field. -func ManagerHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldManager, v)) -} - -// ManagerHasSuffix applies the HasSuffix predicate on the "manager" field. -func ManagerHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldManager, v)) -} - -// ManagerEqualFold applies the EqualFold predicate on the "manager" field. -func ManagerEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldManager, v)) -} - -// ManagerContainsFold applies the ContainsFold predicate on the "manager" field. -func ManagerContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldManager, v)) -} - // HasRoles applies the HasEdge predicate on the "roles" edge. func HasRoles() predicate.User { return predicate.User(func(s *sql.Selector) { diff --git a/internal/data/entity/ent/user_create.go b/internal/data/entity/ent/user_create.go index fc4c26e9..a2a1242a 100644 --- a/internal/data/entity/ent/user_create.go +++ b/internal/data/entity/ent/user_create.go @@ -361,34 +361,6 @@ func (_c *UserCreate) SetNillableSanctionDate(v *time.Time) *UserCreate { return _c } -// SetManagerID sets the "manager_id" field. -func (_c *UserCreate) SetManagerID(v int64) *UserCreate { - _c.mutation.SetManagerID(v) - return _c -} - -// SetNillableManagerID sets the "manager_id" field if the given value is not nil. -func (_c *UserCreate) SetNillableManagerID(v *int64) *UserCreate { - if v != nil { - _c.SetManagerID(*v) - } - return _c -} - -// SetManager sets the "manager" field. -func (_c *UserCreate) SetManager(v string) *UserCreate { - _c.mutation.SetManager(v) - return _c -} - -// SetNillableManager sets the "manager" field if the given value is not nil. -func (_c *UserCreate) SetNillableManager(v *string) *UserCreate { - if v != nil { - _c.SetManager(*v) - } - return _c -} - // SetID sets the "id" field. func (_c *UserCreate) SetID(v int64) *UserCreate { _c.mutation.SetID(v) @@ -626,10 +598,6 @@ func (_c *UserCreate) defaults() error { v := user.DefaultLoginTime() _c.mutation.SetLoginTime(v) } - if _, ok := _c.mutation.Manager(); !ok { - v := user.DefaultManager - _c.mutation.SetManager(v) - } if _, ok := _c.mutation.ID(); !ok { if user.DefaultID == nil { return fmt.Errorf("ent: uninitialized user.DefaultID (forgotten import ent/runtime?)") @@ -775,9 +743,6 @@ func (_c *UserCreate) check() error { if _, ok := _c.mutation.LoginTime(); !ok { return &ValidationError{Name: "login_time", err: errors.New(`ent: missing required field "User.login_time"`)} } - if _, ok := _c.mutation.Manager(); !ok { - return &ValidationError{Name: "manager", err: errors.New(`ent: missing required field "User.manager"`)} - } if v, ok := _c.mutation.ID(); ok { if err := user.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "User.id": %w`, err)} @@ -915,14 +880,6 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldSanctionDate, field.TypeTime, value) _node.SanctionDate = value } - if value, ok := _c.mutation.ManagerID(); ok { - _spec.SetField(user.FieldManagerID, field.TypeInt64, value) - _node.ManagerID = value - } - if value, ok := _c.mutation.Manager(); ok { - _spec.SetField(user.FieldManager, field.TypeString, value) - _node.Manager = value - } if nodes := _c.mutation.RolesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, diff --git a/internal/data/entity/ent/user_query.go b/internal/data/entity/ent/user_query.go index 454395df..d22ae6c1 100644 --- a/internal/data/entity/ent/user_query.go +++ b/internal/data/entity/ent/user_query.go @@ -1052,8 +1052,6 @@ func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // LastLoginTime time.Time `json:"last_login_time,omitempty"` // LoginTime time.Time `json:"login_time,omitempty"` // SanctionDate time.Time `json:"sanction_date,omitempty"` -// ManagerID int64 `json:"manager_id,omitempty"` -// Manager string `json:"manager,omitempty"` // } // // client.User.Query(). @@ -1083,8 +1081,6 @@ func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // user.FieldLastLoginTime, // user.FieldLoginTime, // user.FieldSanctionDate, -// user.FieldManagerID, -// user.FieldManager, // ). // Scan(ctx, &v) func (uq *UserQuery) Omit(fields ...string) *UserSelect { diff --git a/internal/data/entity/ent/user_update.go b/internal/data/entity/ent/user_update.go index e1bb33bd..7806b74d 100644 --- a/internal/data/entity/ent/user_update.go +++ b/internal/data/entity/ent/user_update.go @@ -409,47 +409,6 @@ func (_u *UserUpdate) ClearSanctionDate() *UserUpdate { return _u } -// SetManagerID sets the "manager_id" field. -func (_u *UserUpdate) SetManagerID(v int64) *UserUpdate { - _u.mutation.ResetManagerID() - _u.mutation.SetManagerID(v) - return _u -} - -// SetNillableManagerID sets the "manager_id" field if the given value is not nil. -func (_u *UserUpdate) SetNillableManagerID(v *int64) *UserUpdate { - if v != nil { - _u.SetManagerID(*v) - } - return _u -} - -// AddManagerID adds value to the "manager_id" field. -func (_u *UserUpdate) AddManagerID(v int64) *UserUpdate { - _u.mutation.AddManagerID(v) - return _u -} - -// ClearManagerID clears the value of the "manager_id" field. -func (_u *UserUpdate) ClearManagerID() *UserUpdate { - _u.mutation.ClearManagerID() - return _u -} - -// SetManager sets the "manager" field. -func (_u *UserUpdate) SetManager(v string) *UserUpdate { - _u.mutation.SetManager(v) - return _u -} - -// SetNillableManager sets the "manager" field if the given value is not nil. -func (_u *UserUpdate) SetNillableManager(v *string) *UserUpdate { - if v != nil { - _u.SetManager(*v) - } - return _u -} - // AddRoleIDs adds the "roles" edge to the Role entity by IDs. func (_u *UserUpdate) AddRoleIDs(ids ...int64) *UserUpdate { _u.mutation.AddRoleIDs(ids...) @@ -899,18 +858,6 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { if _u.mutation.SanctionDateCleared() { _spec.ClearField(user.FieldSanctionDate, field.TypeTime) } - if value, ok := _u.mutation.ManagerID(); ok { - _spec.SetField(user.FieldManagerID, field.TypeInt64, value) - } - if value, ok := _u.mutation.AddedManagerID(); ok { - _spec.AddField(user.FieldManagerID, field.TypeInt64, value) - } - if _u.mutation.ManagerIDCleared() { - _spec.ClearField(user.FieldManagerID, field.TypeInt64) - } - if value, ok := _u.mutation.Manager(); ok { - _spec.SetField(user.FieldManager, field.TypeString, value) - } if _u.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, @@ -1576,47 +1523,6 @@ func (_u *UserUpdateOne) ClearSanctionDate() *UserUpdateOne { return _u } -// SetManagerID sets the "manager_id" field. -func (_u *UserUpdateOne) SetManagerID(v int64) *UserUpdateOne { - _u.mutation.ResetManagerID() - _u.mutation.SetManagerID(v) - return _u -} - -// SetNillableManagerID sets the "manager_id" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableManagerID(v *int64) *UserUpdateOne { - if v != nil { - _u.SetManagerID(*v) - } - return _u -} - -// AddManagerID adds value to the "manager_id" field. -func (_u *UserUpdateOne) AddManagerID(v int64) *UserUpdateOne { - _u.mutation.AddManagerID(v) - return _u -} - -// ClearManagerID clears the value of the "manager_id" field. -func (_u *UserUpdateOne) ClearManagerID() *UserUpdateOne { - _u.mutation.ClearManagerID() - return _u -} - -// SetManager sets the "manager" field. -func (_u *UserUpdateOne) SetManager(v string) *UserUpdateOne { - _u.mutation.SetManager(v) - return _u -} - -// SetNillableManager sets the "manager" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableManager(v *string) *UserUpdateOne { - if v != nil { - _u.SetManager(*v) - } - return _u -} - // AddRoleIDs adds the "roles" edge to the Role entity by IDs. func (_u *UserUpdateOne) AddRoleIDs(ids ...int64) *UserUpdateOne { _u.mutation.AddRoleIDs(ids...) @@ -2096,18 +2002,6 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { if _u.mutation.SanctionDateCleared() { _spec.ClearField(user.FieldSanctionDate, field.TypeTime) } - if value, ok := _u.mutation.ManagerID(); ok { - _spec.SetField(user.FieldManagerID, field.TypeInt64, value) - } - if value, ok := _u.mutation.AddedManagerID(); ok { - _spec.AddField(user.FieldManagerID, field.TypeInt64, value) - } - if _u.mutation.ManagerIDCleared() { - _spec.ClearField(user.FieldManagerID, field.TypeInt64) - } - if value, ok := _u.mutation.Manager(); ok { - _spec.SetField(user.FieldManager, field.TypeString, value) - } if _u.mutation.RolesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, diff --git a/internal/data/entity/ent/view/view.go b/internal/data/entity/ent/view/view.go index becfd145..db2dcaad 100644 --- a/internal/data/entity/ent/view/view.go +++ b/internal/data/entity/ent/view/view.go @@ -67,7 +67,7 @@ const ( ResourcesTable = "sys_view_resources" // ResourcesInverseTable is the table name for the Resource entity. // It exists in this package in order to avoid circular dependency with the "resource" package. - ResourcesInverseTable = "resources" + ResourcesInverseTable = "sys_resources" // PermissionsTable is the table that holds the permissions relation/edge. The primary key declared below. PermissionsTable = "sys_view_permissions" // PermissionsInverseTable is the table name for the Permission entity. diff --git a/internal/data/entity/ent/viewresource/viewresource.go b/internal/data/entity/ent/viewresource/viewresource.go index c2f8dfe0..bdd58738 100644 --- a/internal/data/entity/ent/viewresource/viewresource.go +++ b/internal/data/entity/ent/viewresource/viewresource.go @@ -43,7 +43,7 @@ const ( ResourceTable = "sys_view_resources" // ResourceInverseTable is the table name for the Resource entity. // It exists in this package in order to avoid circular dependency with the "resource" package. - ResourceInverseTable = "resources" + ResourceInverseTable = "sys_resources" // ResourceColumn is the table column denoting the resource relation/edge. ResourceColumn = "resource_id" ) diff --git a/resources/configs/databases.yaml b/resources/configs/databases.yaml index 0d6182af..e12d5c8a 100644 --- a/resources/configs/databases.yaml +++ b/resources/configs/databases.yaml @@ -4,4 +4,4 @@ data: configs: - dialect: sqlite3 name: default - source: file:./data.db?cache=shared&mode=memory&_fk=1 + source: file:./data.db?cache=shared&_fk=1 From e3fc3f392a588ad9dcb23f2ea5991c59d80d0b89 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 21:59:22 +0800 Subject: [PATCH 134/158] feat(system): remove manager-related fields from user proto and related files --- api/v1/proto/types/system.proto | 8 +++--- api/v1/services/types/system.pb.go | 31 +++++---------------- api/v1/services/types/system.pb.validate.go | 4 --- internal/data/entity/ent/schema/user.go | 10 +++++-- internal/features/system/dto/dto.gen.go | 4 --- resources/api-docs/openapi/openapi.yaml | 13 ++++----- 6 files changed, 24 insertions(+), 46 deletions(-) diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index 07c05ef9..44cb1b0a 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -166,10 +166,10 @@ message User { google.protobuf.Timestamp last_login_time = 19 [json_name = "last_login_time"]; // user.field.sanction_date optional google.protobuf.Timestamp sanction_date = 20 [json_name = "sanction_date"]; - // user.field.manager_id - int64 manager_id = 21 [json_name = "manager_id"]; - // user.field.manager - string manager = 22 [json_name = "manager"]; +// // user.field.manager_id +// int64 manager_id = 21 [json_name = "manager_id"]; +// // user.field.manager +// string manager = 22 [json_name = "manager"]; // Roles holds the value of the roles edge. repeated Role roles = 23 [json_name = "roles"]; // Role Ids holds the value of the role_ids diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index 42e51674..9c06de71 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -647,10 +647,11 @@ type User struct { LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,19,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` // user.field.sanction_date SanctionDate *timestamppb.Timestamp `protobuf:"bytes,20,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` - // user.field.manager_id - ManagerId int64 `protobuf:"varint,21,opt,name=manager_id,proto3" json:"manager_id,omitempty"` - // user.field.manager - Manager string `protobuf:"bytes,22,opt,name=manager,proto3" json:"manager,omitempty"` + // // user.field.manager_id + // int64 manager_id = 21 [json_name = "manager_id"]; + // // user.field.manager + // string manager = 22 [json_name = "manager"]; + // // Roles holds the value of the roles edge. Roles []*Role `protobuf:"bytes,23,rep,name=roles,proto3" json:"roles,omitempty"` // Role Ids holds the value of the role_ids @@ -829,20 +830,6 @@ func (x *User) GetSanctionDate() *timestamppb.Timestamp { return nil } -func (x *User) GetManagerId() int64 { - if x != nil { - return x.ManagerId - } - return 0 -} - -func (x *User) GetManager() string { - if x != nil { - return x.Manager - } - return "" -} - func (x *User) GetRoles() []*Role { if x != nil { return x.Roles @@ -2845,7 +2832,7 @@ const file_types_system_proto_rawDesc = "" + "role_views\x12?\n" + "\n" + "user_roles\x18\x04 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + - "user_roles\"\xce\x06\n" + + "user_roles\"\x94\x06\n" + "\x04User\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + @@ -2869,11 +2856,7 @@ const file_types_system_proto_rawDesc = "" + "\x06status\x18\x11 \x01(\x05R\x06status\x12$\n" + "\rlast_login_ip\x18\x12 \x01(\tR\rlast_login_ip\x12D\n" + "\x0flast_login_time\x18\x13 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12E\n" + - "\rsanction_date\x18\x14 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x12\x1e\n" + - "\n" + - "manager_id\x18\x15 \x01(\x03R\n" + - "manager_id\x12\x18\n" + - "\amanager\x18\x16 \x01(\tR\amanager\x121\n" + + "\rsanction_date\x18\x14 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x121\n" + "\x05roles\x18\x17 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + "\brole_ids\x18\x18 \x03(\x03R\brole_idsB\x10\n" + "\x0e_sanction_date\"\x7f\n" + diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index 957c6afa..9a2e1170 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -1303,10 +1303,6 @@ func (m *User) validate(all bool) error { } } - // no validation rules for ManagerId - - // no validation rules for Manager - for idx, item := range m.GetRoles() { _, _ = idx, item diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 2eb43c1f..54a8fb01 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -104,6 +104,10 @@ func (User) Fields() []ent.Field { mixin.Time("last_login_time", i18n.Text("entity.user.field.last_login_time")), mixin.Time("login_time", i18n.Text("entity.user.field.login_time")), mixin.TimeOptional("sanction_date", i18n.Text("entity.user.field.sanction_date")), + //mixin.OptionalFK("manager_id", i18n.Text("entity.user.field.manager_id")), + //field.String("manager"). + // Default(""). + // Comment(i18n.Text("entity.user.field.manager")), } } @@ -148,7 +152,7 @@ func preventDuplicateSystemUser(next ent.Mutator) ent.Mutator { return hook.UserFunc(func(ctx context.Context, m *gen.UserMutation) (ent.Value, error) { isSystem, ok := m.IsSystem() if !ok || !isSystem { - return next.Mutate(ctx, m) + return m.Next().Mutate(ctx, m) } // If creating a system user, check if one already exists. count, err := m.Client().User. @@ -161,7 +165,7 @@ func preventDuplicateSystemUser(next ent.Mutator) ent.Mutator { if count > 0 { return nil, fmt.Errorf("a system user already exists") } - return next.Mutate(ctx, m) + return m.Next().Mutate(ctx, m) }) } @@ -170,7 +174,7 @@ func preventDeleteSystemUser(next ent.Mutator) ent.Mutator { return hook.UserFunc(func(ctx context.Context, m *gen.UserMutation) (ent.Value, error) { // Add a predicate to ensure system users are not included in the delete operation. m.Where(user.IsSystem(false)) - return next.Mutate(ctx, m) + return m.Next().Mutate(ctx, m) }) } diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index 144fda3d..c73876f0 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -938,8 +938,6 @@ func ConvertUserPBToUser(from *UserPB) *User { LastLoginIP: from.LastLoginIp, LastLoginTime: ConvertTimestampToTime(from.LastLoginTime), SanctionDate: ConvertTimestampToTime(from.SanctionDate), - ManagerID: from.ManagerId, - Manager: from.Manager, } return to } @@ -1129,8 +1127,6 @@ func ConvertUserToUserPB(from *User) *UserPB { LastLoginIp: from.LastLoginIP, LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), - ManagerId: from.ManagerID, - Manager: from.Manager, Roles: ConvertRolesToRolesPB(from.Edges.Roles), } return to diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index c07a9889..c45ef00c 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -3316,17 +3316,16 @@ components: type: string description: user.field.sanction_date format: date-time - manager_id: - type: string - description: user.field.manager_id - manager: - type: string - description: user.field.manager roles: type: array items: $ref: '#/components/schemas/api.v1.services.types.Role' - description: Roles holds the value of the roles edge. + description: |- + // user.field.manager_id + int64 manager_id = 21 [json_name = "manager_id"]; + // user.field.manager + string manager = 22 [json_name = "manager"]; + Roles holds the value of the roles edge. role_ids: type: array items: From 858737c794722e719d75e889f4ae697a528297b2 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 31 Dec 2025 22:19:14 +0800 Subject: [PATCH 135/158] feat(gateway): add client middlewares support to gRPC client initialization --- internal/gateway/client/client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index b13a686f..a799a3fd 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -84,9 +84,18 @@ func NewGRPCConn(app *runtime.App, bootstrap *conf.Config, name string) (*grpc.C if err != nil { return nil, err } + middlewareProvider, err := app.MiddlewareProvider() + if err != nil { + return nil, err + } + middlewares, err := middlewareProvider.ClientMiddlewares() + if err != nil { + return nil, err + } return runtimegrpc.NewClient(app.Context(), clientConfig.GetGrpc(), &runtimegrpc.ClientOptions{ - Discoveries: discoveries, + Discoveries: discoveries, + ClientMiddlewares: middlewares, }) } From f227e5b4c15c9b9f7922d8cbed79ec692ffb2039 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 1 Jan 2026 01:54:09 +0800 Subject: [PATCH 136/158] feat(auth): implement authentication and authorization middleware with casbin integration --- cmd/gateway/wire.go | 2 +- cmd/gateway/wire_gen.go | 12 +- cmd/system/wire.go | 2 +- cmd/system/wire_gen.go | 13 ++- internal/data/entity/ent/schema/user.go | 6 +- internal/features/auth/dto/dto.gen.go | 4 - internal/features/system/server/server.go | 26 ++--- internal/gateway/server/server.go | 11 +- internal/helpers/providers/providers.go | 136 +++++++++++++++++++++- resources/casbin_model.conf | 14 +++ resources/configs/middlewares.yaml | 8 ++ resources/configs/root_user.yaml | 6 + resources/configs/security.yaml | 6 + resources/configs/server.yaml | 17 ++- 14 files changed, 224 insertions(+), 39 deletions(-) create mode 100644 resources/casbin_model.conf create mode 100644 resources/configs/middlewares.yaml create mode 100644 resources/configs/root_user.yaml diff --git a/cmd/gateway/wire.go b/cmd/gateway/wire.go index 4bb0c77d..4cf17f35 100644 --- a/cmd/gateway/wire.go +++ b/cmd/gateway/wire.go @@ -25,7 +25,7 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err panic(wire.Build( // Shared infrastructure providers providers.ProviderSet, - + providers.ProviderGatewaySet, // Service-specific providers server.ProviderSet, service.ProviderSet, diff --git a/cmd/gateway/wire_gen.go b/cmd/gateway/wire_gen.go index deb0fc59..2a55cec4 100644 --- a/cmd/gateway/wire_gen.go +++ b/cmd/gateway/wire_gen.go @@ -13,6 +13,7 @@ import ( "origadmin/application/admin/internal/gateway/client" "origadmin/application/admin/internal/gateway/server" "origadmin/application/admin/internal/gateway/service" + "origadmin/application/admin/internal/helpers/providers" ) import ( @@ -40,7 +41,16 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err if err != nil { return nil, nil, err } - v, err := server.NewServers(app, servers, gatewayService) + authenticator, err := providers.ProvideAuthenticator(app, bootstrap) + if err != nil { + return nil, nil, err + } + skipChecker := providers.ProvideSkipChecker(app, bootstrap) + serverMiddlewareProvider, err := providers.ProvideGatewayMiddlewares(app, authenticator, skipChecker) + if err != nil { + return nil, nil, err + } + v, err := server.NewServers(app, servers, gatewayService, serverMiddlewareProvider) if err != nil { return nil, nil, err } diff --git a/cmd/system/wire.go b/cmd/system/wire.go index ec0bd6f1..52bac5d3 100644 --- a/cmd/system/wire.go +++ b/cmd/system/wire.go @@ -27,7 +27,7 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err panic(wire.Build( // Shared infrastructure providers providers.ProviderSet, - + providers.ProviderBackendSet, // Service-specific providers data.ProviderSet, dal.ProviderSet, diff --git a/cmd/system/wire_gen.go b/cmd/system/wire_gen.go index 6b0d39f6..7ade479c 100644 --- a/cmd/system/wire_gen.go +++ b/cmd/system/wire_gen.go @@ -61,7 +61,18 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err viewUseCase := biz.NewViewUseCase(viewRepo) viewService := service.NewViewService(viewUseCase) systemService := service.NewSystemService(resourceService, roleService, userService, permissionService, viewService) - v2, err := server.NewServers(app, servers, systemService, v) + authorizer, err := providers.ProvideAuthorizer(app, bootstrap, database) + if err != nil { + cleanup() + return nil, nil, err + } + skipChecker := providers.ProvideSkipChecker(app, bootstrap) + serverMiddlewareProvider, err := providers.ProvideServiceMiddlewares(app, authorizer, skipChecker) + if err != nil { + cleanup() + return nil, nil, err + } + v2, err := server.NewServers(app, servers, systemService, serverMiddlewareProvider) if err != nil { cleanup() return nil, nil, err diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 54a8fb01..6468c86a 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -152,7 +152,7 @@ func preventDuplicateSystemUser(next ent.Mutator) ent.Mutator { return hook.UserFunc(func(ctx context.Context, m *gen.UserMutation) (ent.Value, error) { isSystem, ok := m.IsSystem() if !ok || !isSystem { - return m.Next().Mutate(ctx, m) + return next.Mutate(ctx, m) } // If creating a system user, check if one already exists. count, err := m.Client().User. @@ -165,7 +165,7 @@ func preventDuplicateSystemUser(next ent.Mutator) ent.Mutator { if count > 0 { return nil, fmt.Errorf("a system user already exists") } - return m.Next().Mutate(ctx, m) + return next.Mutate(ctx, m) }) } @@ -174,7 +174,7 @@ func preventDeleteSystemUser(next ent.Mutator) ent.Mutator { return hook.UserFunc(func(ctx context.Context, m *gen.UserMutation) (ent.Value, error) { // Add a predicate to ensure system users are not included in the delete operation. m.Where(user.IsSystem(false)) - return m.Next().Mutate(ctx, m) + return next.Mutate(ctx, m) }) } diff --git a/internal/features/auth/dto/dto.gen.go b/internal/features/auth/dto/dto.gen.go index 144fda3d..c73876f0 100644 --- a/internal/features/auth/dto/dto.gen.go +++ b/internal/features/auth/dto/dto.gen.go @@ -938,8 +938,6 @@ func ConvertUserPBToUser(from *UserPB) *User { LastLoginIP: from.LastLoginIp, LastLoginTime: ConvertTimestampToTime(from.LastLoginTime), SanctionDate: ConvertTimestampToTime(from.SanctionDate), - ManagerID: from.ManagerId, - Manager: from.Manager, } return to } @@ -1129,8 +1127,6 @@ func ConvertUserToUserPB(from *User) *UserPB { LastLoginIp: from.LastLoginIP, LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), - ManagerId: from.ManagerID, - Manager: from.Manager, Roles: ConvertRolesToRolesPB(from.Edges.Roles), } return to diff --git a/internal/features/system/server/server.go b/internal/features/system/server/server.go index 42155edf..e1bf988d 100644 --- a/internal/features/system/server/server.go +++ b/internal/features/system/server/server.go @@ -14,6 +14,7 @@ import ( grpcv1 "github.com/origadmin/runtime/api/gen/go/config/transport/grpc/v1" httpv1 "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1" transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" + "github.com/origadmin/runtime/container" "github.com/origadmin/runtime/log" "github.com/origadmin/runtime/service/transport" "github.com/origadmin/runtime/service/transport/grpc" @@ -26,7 +27,8 @@ import ( var ProviderSet = wire.NewSet(NewServers) // NewServers creates and configures the system service servers (gRPC, HTTP). -func NewServers(app *runtime.App, cfg *transportv1.Servers, svc *service.SystemService, logger log.Logger) ([]transport.Server, +func NewServers(app *runtime.App, cfg *transportv1.Servers, svc *service.SystemService, + middlwareProvider container.ServerMiddlewareProvider) ([]transport.Server, error) { if cfg == nil { return nil, errors.New("servers config is nil") @@ -39,13 +41,13 @@ func NewServers(app *runtime.App, cfg *transportv1.Servers, svc *service.SystemS } switch serverCfg.GetProtocol() { case "http": - srv, err := NewHTTPServer(app, serverCfg.GetHttp(), svc, logger) + srv, err := NewHTTPServer(app, serverCfg.GetHttp(), svc, middlwareProvider) if err != nil { return nil, err } transportServers = append(transportServers, srv) case "grpc": - srv, err := NewGRPCServer(app, serverCfg.GetGrpc(), svc, logger) + srv, err := NewGRPCServer(app, serverCfg.GetGrpc(), svc, middlwareProvider) if err != nil { return nil, err } @@ -61,16 +63,13 @@ func NewServers(app *runtime.App, cfg *transportv1.Servers, svc *service.SystemS } // NewHTTPServer new an HTTP server. -func NewHTTPServer(app *runtime.App, cfg *httpv1.Server, svc *service.SystemService, logger log.Logger) (*transport.HTTPServer, error) { +func NewHTTPServer(_ *runtime.App, cfg *httpv1.Server, svc *service.SystemService, + provider container.ServerMiddlewareProvider) (*transport.HTTPServer, error) { if cfg == nil { return nil, errors.New("http config is nil") } - middlewareProvider, err := app.MiddlewareProvider() - if err != nil { - return nil, err - } - mws, err := middlewareProvider.ServerMiddlewares() + mws, err := provider.ServerMiddlewares() if err != nil { return nil, err } @@ -96,16 +95,13 @@ func NewHTTPServer(app *runtime.App, cfg *httpv1.Server, svc *service.SystemServ } // NewGRPCServer new a gRPC server. -func NewGRPCServer(app *runtime.App, cfg *grpcv1.Server, svc *service.SystemService, logger log.Logger) (*transport.GRPCServer, error) { +func NewGRPCServer(_ *runtime.App, cfg *grpcv1.Server, svc *service.SystemService, + provider container.ServerMiddlewareProvider) (*transport.GRPCServer, error) { if cfg == nil { return nil, errors.New("grpc config is nil") } - middlewareProvider, err := app.MiddlewareProvider() - if err != nil { - return nil, err - } - mws, err := middlewareProvider.ServerMiddlewares() + mws, err := provider.ServerMiddlewares() if err != nil { return nil, err } diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index b9a544d4..f3ef62f8 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -15,6 +15,7 @@ import ( "github.com/origadmin/runtime" httpv1 "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1" transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" + "github.com/origadmin/runtime/container" "github.com/origadmin/runtime/service/transport" "github.com/origadmin/runtime/service/transport/http" "origadmin/application/admin/internal/gateway/service" @@ -28,6 +29,7 @@ func NewServers( app *runtime.App, serversCfg *transportv1.Servers, svc *service.GatewayService, + middlewareProvider container.ServerMiddlewareProvider, ) ([]transport.Server, error) { if serversCfg == nil { return nil, errors.New("servers config is nil") @@ -42,7 +44,7 @@ func NewServers( switch serverCfg.GetProtocol() { case "http": - srv, err := NewHTTPServer(app, serverCfg.GetHttp(), svc) + srv, err := NewHTTPServer(app, serverCfg.GetHttp(), svc, middlewareProvider) if err != nil { return nil, err } @@ -61,18 +63,15 @@ func NewServers( // NewHTTPServer creates a new HTTP server and registers all downstream service handlers. func NewHTTPServer( - app *runtime.App, + _ *runtime.App, cfg *httpv1.Server, svc *service.GatewayService, + middlewareProvider container.ServerMiddlewareProvider, ) (transport.Server, error) { if cfg == nil { return nil, errors.New("http config is nil") } - middlewareProvider, err := app.MiddlewareProvider() - if err != nil { - return nil, err - } mws, err := middlewareProvider.ServerMiddlewares() if err != nil { return nil, err diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go index 4c103015..ac148638 100644 --- a/internal/helpers/providers/providers.go +++ b/internal/helpers/providers/providers.go @@ -1,24 +1,36 @@ package providers import ( + "context" "errors" - "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" authnv1 "github.com/origadmin/contrib/api/gen/go/security/authn/v1" + authzv1 "github.com/origadmin/contrib/api/gen/go/security/authz/v1" + "github.com/origadmin/contrib/security" + "github.com/origadmin/contrib/security/authn" "github.com/origadmin/contrib/security/authn/jwt" + "github.com/origadmin/contrib/security/authz" + "github.com/origadmin/contrib/security/authz/casbin" "github.com/origadmin/contrib/security/credential" + secmiddleware "github.com/origadmin/contrib/security/middleware" "github.com/origadmin/runtime" "github.com/origadmin/runtime/container" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/middleware" "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" "github.com/origadmin/toolkits/crypto/hash/types" "origadmin/application/admin/internal/conf" confpb "origadmin/application/admin/internal/conf/pb" + "origadmin/application/admin/internal/data" + "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/helpers/captcha" ) +var factory = secmiddleware.NewFactory() + // ProvideAuthenticatorOptions creates the JWT options from the application configuration. func ProvideAuthenticatorOptions(c *conf.Config) (*jwt.Options, error) { securityConfig := c.GetBootstrap().GetSecurity() @@ -50,10 +62,59 @@ func ProvideCredentialCreator(opts *jwt.Options, logger log.Logger) (credential. return jwt.New(opts, logger) } -// ProvideAuthenticator creates the JWT authenticator instance. -// It returns a *jwt.Authenticator, which is needed by the AuthService. -func ProvideAuthenticator(opts *jwt.Options, logger log.Logger) (*jwt.Authenticator, error) { - return jwt.New(opts, logger) +// ProvideAuthorizer creates the Casbin authorizer. +func ProvideAuthorizer(app *runtime.App, c *conf.Config, database *ent.Database) (authz.Authorizer, error) { + securityConfig := c.GetBootstrap().GetSecurity() + if securityConfig == nil { + return nil, errors.New("security configuration not found") + } + authzConfig := securityConfig.GetAuthz() + if authzConfig == nil { + return nil, errors.New("authz configuration not found") + } + + var casbinConfig *authzv1.Authorizer + for _, cfg := range authzConfig.GetConfigs() { + if cfg.GetType() == "casbin" { + casbinConfig = cfg + break + } + } + + if casbinConfig == nil || casbinConfig.GetCasbin() == nil { + return nil, errors.New("casbin authorizer configuration not found") + } + adapter, err := data.NewAdapter(database) + if err != nil { + return nil, err + } + + return casbin.NewAuthorizer(casbinConfig, log.WithLogger(app.Logger()), casbin.WithPolicyAdapter(adapter)) +} + +// ProvideAuthenticator creates the Casbin authorizer. +func ProvideAuthenticator(app *runtime.App, c *conf.Config) (authn.Authenticator, error) { + securityConfig := c.GetBootstrap().GetSecurity() + if securityConfig == nil { + return nil, errors.New("security configuration not found") + } + authnConfig := securityConfig.GetAuthn() + if authnConfig == nil { + return nil, errors.New("authz configuration not found") + } + + var jwtConfig *authnv1.Authenticator + for _, cfg := range authnConfig.GetConfigs() { + if cfg.GetType() == "jwt" { + jwtConfig = cfg + break + } + } + + if jwtConfig == nil || jwtConfig.GetJwt() == nil { + return nil, errors.New("casbin authorizer configuration not found") + } + return jwt.NewAuthenticator(jwtConfig, log.WithLogger(app.Logger())) } func ProvideCache(r *runtime.App) (container.CacheProvider, error) { @@ -101,6 +162,70 @@ func ProvideLogger(app *runtime.App) log.Logger { return app.Logger() } +func ProvideServiceMiddlewares(app *runtime.App, authorizer authz.Authorizer, + skip security.SkipChecker) (container.ServerMiddlewareProvider, + error) { + provider, err := app.MiddlewareProvider() + if err != nil { + return nil, err + } + m := factory.NewBackend(authorizer, skip) + // authz for backend + provider.RegisterServerMiddleware("authz", m) + provider.RegisterClientMiddleware("authz", middleware.Noop()) + + return provider, nil +} + +func ProvideGatewayMiddlewares(app *runtime.App, authenticator authn.Authenticator, + skip security.SkipChecker) (container.ServerMiddlewareProvider, + error) { + provider, err := app.MiddlewareProvider() + if err != nil { + return nil, err + } + m := factory.NewGateway(authenticator, skip) + // authz for backend + provider.RegisterServerMiddleware("authn", m) + provider.RegisterClientMiddleware("authn", middleware.Noop()) + + return provider, nil +} + +func ProvideClientMiddlewares(app *runtime.App) (container.ClientMiddlewareProvider, + error) { + provider, err := app.MiddlewareProvider() + if err != nil { + return nil, err + } + m := factory.NewClient() + // authz for backend + provider.RegisterClientMiddleware("propagation", m) + provider.RegisterServerMiddleware("propagation", middleware.Noop()) + return provider, nil +} + +func ProvideSkipChecker(app *runtime.App, cfg *conf.Config) security.SkipChecker { + helper := log.NewHelper(log.With(app.Logger(), "module", "security.skip")) + return func(ctx context.Context, req security.Request) bool { + helper.Infow("kind", req.Kind(), "operation", req.GetOperation(), "method", req.GetMethod(), "path", + req.GetRouteTemplate()) + return false + } +} + +var ProviderGatewaySet = wire.NewSet( + ProvideClientMiddlewares, + ProvideGatewayMiddlewares, + ProvideSkipChecker, +) + +var ProviderBackendSet = wire.NewSet( + ProvideClientMiddlewares, + ProvideServiceMiddlewares, + ProvideSkipChecker, +) + var ProviderSet = wire.NewSet( // Instructions for wire to extract nested configs wire.FieldsOf(new(*conf.Config), "Bootstrap"), @@ -111,6 +236,7 @@ var ProviderSet = wire.NewSet( ProvideAuthenticatorOptions, ProvideCredentialCreator, ProvideAuthenticator, + ProvideAuthorizer, ProvideCaptcha, ProvideHasher, ) diff --git a/resources/casbin_model.conf b/resources/casbin_model.conf new file mode 100644 index 00000000..7d955cc1 --- /dev/null +++ b/resources/casbin_model.conf @@ -0,0 +1,14 @@ +[request_definition] +r = sub, obj, act, dom + +[policy_definition] +p = sub, obj, act, dom + +[role_definition] +g = _, _, _ + +[policy_effect] +e = some(where (p.eft == allow)) + +[matchers] +m = g(r.sub, p.sub, r.dom) && keyMatch2(r.obj, p.obj) && (regexMatch(r.act, p.act) || p.act == 'ANY') && (keyMatch(r.dom, p.dom) || p.dom == '*') diff --git a/resources/configs/middlewares.yaml b/resources/configs/middlewares.yaml new file mode 100644 index 00000000..83c2f82c --- /dev/null +++ b/resources/configs/middlewares.yaml @@ -0,0 +1,8 @@ +# This file defines reusable middleware configurations. +middlewares: + configs: + # Define a middleware instance named "security". + # The 'type' must match the name we registered in main.go's init() function. + - name: security + type: security + enabled: true diff --git a/resources/configs/root_user.yaml b/resources/configs/root_user.yaml new file mode 100644 index 00000000..5734bb6c --- /dev/null +++ b/resources/configs/root_user.yaml @@ -0,0 +1,6 @@ +root_user: + enabled: true + username: admin + password: "admin123" + nickname: "Administrator" + email: "admin@example.com" diff --git a/resources/configs/security.yaml b/resources/configs/security.yaml index 5a54bc7d..8853ce31 100644 --- a/resources/configs/security.yaml +++ b/resources/configs/security.yaml @@ -8,3 +8,9 @@ security: signing_method: "HS256" access_token_ttl: 3600s refresh_token_ttl: 7200s + authz: + configs: + - type: casbin + casbin: + wildcard_item: "*" + model_path: "resources/casbin_model.conf" diff --git a/resources/configs/server.yaml b/resources/configs/server.yaml index b48a6556..df01d378 100644 --- a/resources/configs/server.yaml +++ b/resources/configs/server.yaml @@ -18,6 +18,8 @@ servers: allowed_headers: - "*" allow_credentials: true + middlewares: + - "authn" # Auth Service gRPC Server - name: "auth" @@ -25,20 +27,31 @@ servers: grpc: addr: "0.0.0.0:9081" timeout: 5s + middlewares: + - "authz" - name: "auth" protocol: "http" http: addr: "0.0.0.0:9082" timeout: 5s - + middlewares: + - "authz" # System Service gRPC Server - name: "system" protocol: "grpc" grpc: addr: "0.0.0.0:9001" timeout: 5s + # Apply middlewares by name. These names must correspond to entries + # in the middlewares.yaml configuration file. + middlewares: + - "authz" + # System Service HTTP Server - name: "system" protocol: "http" http: addr: "0.0.0.0:9002" - timeout: 5s \ No newline at end of file + timeout: 5s + # Apply middlewares by name. + middlewares: + - "authz" From 4e8e4f6eaa3438656654c8e2945041cad2e4ec8b Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 1 Jan 2026 02:19:29 +0800 Subject: [PATCH 137/158] feat(auth): add policy annotations to auth and system proto services --- api/v1/proto/auth/auth.proto | 6 ++ api/v1/proto/auth/casbin.proto | 5 ++ api/v1/proto/auth/me.proto | 6 ++ api/v1/proto/system/department.proto | 6 ++ api/v1/proto/system/permission.proto | 6 ++ api/v1/proto/system/position.proto | 6 ++ api/v1/proto/system/resource.proto | 6 ++ api/v1/proto/system/role.proto | 6 ++ api/v1/proto/system/user.proto | 10 +++ api/v1/proto/system/view.proto | 6 ++ api/v1/services/auth/auth.pb.go | 24 ++++--- api/v1/services/auth/auth.pb.security.go | 45 ++++++++++++ api/v1/services/auth/casbin.pb.go | 23 +++++-- api/v1/services/auth/casbin.pb.security.go | 39 +++++++++++ api/v1/services/auth/me.pb.go | 27 +++++--- api/v1/services/auth/me.pb.security.go | 45 ++++++++++++ api/v1/services/system/department.pb.go | 29 +++++--- .../services/system/department.pb.security.go | 45 ++++++++++++ api/v1/services/system/permission.pb.go | 29 +++++--- .../services/system/permission.pb.security.go | 45 ++++++++++++ api/v1/services/system/position.pb.go | 27 +++++--- .../services/system/position.pb.security.go | 45 ++++++++++++ api/v1/services/system/resource.pb.go | 27 +++++--- .../services/system/resource.pb.security.go | 45 ++++++++++++ api/v1/services/system/role.pb.go | 31 ++++++--- api/v1/services/system/role.pb.security.go | 45 ++++++++++++ api/v1/services/system/user.pb.go | 48 +++++++++---- api/v1/services/system/user.pb.security.go | 69 +++++++++++++++++++ api/v1/services/system/view.pb.go | 31 ++++++--- api/v1/services/system/view.pb.security.go | 45 ++++++++++++ buf.gen.yaml | 4 +- internal/helpers/providers/providers.go | 17 ++++- 32 files changed, 755 insertions(+), 93 deletions(-) create mode 100644 api/v1/services/auth/auth.pb.security.go create mode 100644 api/v1/services/auth/casbin.pb.security.go create mode 100644 api/v1/services/auth/me.pb.security.go create mode 100644 api/v1/services/system/department.pb.security.go create mode 100644 api/v1/services/system/permission.pb.security.go create mode 100644 api/v1/services/system/position.pb.security.go create mode 100644 api/v1/services/system/resource.pb.security.go create mode 100644 api/v1/services/system/role.pb.security.go create mode 100644 api/v1/services/system/user.pb.security.go create mode 100644 api/v1/services/system/view.pb.security.go diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index b32a434d..fe7b7ce6 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package api.v1.services.auth; import "google/api/annotations.proto"; +import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; @@ -19,6 +20,7 @@ service AuthService { post: "/auth/login" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "public"}; } // Register creates a new user account. @@ -27,6 +29,7 @@ service AuthService { post: "/auth/register" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "public"}; } // Logout invalidates the user's session. @@ -35,6 +38,7 @@ service AuthService { post: "/auth/logout" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // RefreshToken provides a new access token. @@ -43,6 +47,7 @@ service AuthService { post: "/auth/token" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // --- Captcha --- @@ -52,6 +57,7 @@ service AuthService { option (google.api.http) = { get: "/captcha" }; + option (contrib.api.policy.v1.policy) = {name: "public"}; } // --- Internal --- diff --git a/api/v1/proto/auth/casbin.proto b/api/v1/proto/auth/casbin.proto index 4840bd50..e2a955cd 100644 --- a/api/v1/proto/auth/casbin.proto +++ b/api/v1/proto/auth/casbin.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package api.v1.services.auth; import "google/api/annotations.proto"; +import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; @@ -17,18 +18,21 @@ service CasbinService { get: "/casbin/policies" response_body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc ListGroupings(ListGroupingsRequest) returns (ListGroupingsResponse) { option (google.api.http) = { get: "/casbin/groupings" response_body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc WatchUpdate(WatchUpdateRequest) returns (WatchUpdateResponse) { option (google.api.http) = { get: "/casbin/watch" response_body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc StreamRules(StreamRulesRequest) returns (stream StreamRulesResponse) { @@ -37,6 +41,7 @@ service CasbinService { // response_body: "*" // }; // (google.api.method_signature) = "with_policies,with_groupings"; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } } diff --git a/api/v1/proto/auth/me.proto b/api/v1/proto/auth/me.proto index 33c06184..b91668dc 100644 --- a/api/v1/proto/auth/me.proto +++ b/api/v1/proto/auth/me.proto @@ -4,6 +4,7 @@ package api.v1.services.auth; import "google/api/annotations.proto"; import "types/system.proto"; +import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; @@ -17,6 +18,7 @@ service MeService { option (google.api.http) = { get: "/me/profile" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // UpdateProfile updates the profile of the currently authenticated user. @@ -25,6 +27,7 @@ service MeService { put: "/me/profile" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // UpdatePassword changes the password for the currently authenticated user. @@ -33,6 +36,7 @@ service MeService { put: "/me/password" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // GetUserResources retrieves the menu/resource list for the current user. @@ -40,6 +44,7 @@ service MeService { option (google.api.http) = { get: "/me/resources" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // GetUserRoles retrieves the role list for the current user. @@ -47,6 +52,7 @@ service MeService { option (google.api.http) = { get: "/me/roles" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } } diff --git a/api/v1/proto/system/department.proto b/api/v1/proto/system/department.proto index 650574c9..9a527bf2 100644 --- a/api/v1/proto/system/department.proto +++ b/api/v1/proto/system/department.proto @@ -6,6 +6,7 @@ import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; +import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; @@ -17,24 +18,29 @@ option objc_class_prefix = "APIServiceSystemDepartment"; service DepartmentService { rpc ListDepartments(ListDepartmentsRequest) returns (ListDepartmentsResponse) { option (google.api.http) = {get: "/sys/departments"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc GetDepartment(GetDepartmentRequest) returns (GetDepartmentResponse) { option (google.api.http) = {get: "/sys/departments/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc CreateDepartment(CreateDepartmentRequest) returns (CreateDepartmentResponse) { option (google.api.http) = { post: "/sys/departments" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc UpdateDepartment(UpdateDepartmentRequest) returns (UpdateDepartmentResponse) { option (google.api.http) = { put: "/sys/departments/{department.id}" body: "department" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc DeleteDepartment(DeleteDepartmentRequest) returns (DeleteDepartmentResponse) { option (google.api.http) = {delete: "/sys/departments/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } } diff --git a/api/v1/proto/system/permission.proto b/api/v1/proto/system/permission.proto index 666c3ed7..b936e592 100644 --- a/api/v1/proto/system/permission.proto +++ b/api/v1/proto/system/permission.proto @@ -6,6 +6,7 @@ import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; +import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; @@ -17,24 +18,29 @@ option objc_class_prefix = "APIServiceSystemPermission"; service PermissionService { rpc ListPermissions(ListPermissionsRequest) returns (ListPermissionsResponse) { option (google.api.http) = {get: "/sys/permissions"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc GetPermission(GetPermissionRequest) returns (GetPermissionResponse) { option (google.api.http) = {get: "/sys/permissions/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc CreatePermission(CreatePermissionRequest) returns (CreatePermissionResponse) { option (google.api.http) = { post: "/sys/permissions" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc UpdatePermission(UpdatePermissionRequest) returns (UpdatePermissionResponse) { option (google.api.http) = { put: "/sys/permissions/{permission.id}" body: "permission" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc DeletePermission(DeletePermissionRequest) returns (DeletePermissionResponse) { option (google.api.http) = {delete: "/sys/permissions/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } } diff --git a/api/v1/proto/system/position.proto b/api/v1/proto/system/position.proto index 2c7edb6b..76c5f818 100644 --- a/api/v1/proto/system/position.proto +++ b/api/v1/proto/system/position.proto @@ -6,6 +6,7 @@ import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; +import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; @@ -17,24 +18,29 @@ option objc_class_prefix = "APIServiceSystemPosition"; service PositionService { rpc ListPositions(ListPositionsRequest) returns (ListPositionsResponse) { option (google.api.http) = {get: "/sys/positions"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc GetPosition(GetPositionRequest) returns (GetPositionResponse) { option (google.api.http) = {get: "/sys/positions/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc CreatePosition(CreatePositionRequest) returns (CreatePositionResponse) { option (google.api.http) = { post: "/sys/positions" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc UpdatePosition(UpdatePositionRequest) returns (UpdatePositionResponse) { option (google.api.http) = { put: "/sys/positions/{position.id}" body: "position" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc DeletePosition(DeletePositionRequest) returns (DeletePositionResponse) { option (google.api.http) = {delete: "/sys/positions/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } } diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index d005cb6c..88afd693 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -6,6 +6,7 @@ import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; +import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; @@ -22,10 +23,12 @@ service ResourceService { // Lists all backend resources. rpc ListResources(ListResourcesRequest) returns (ListResourcesResponse) { option (google.api.http) = {get: "/sys/resources"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // Gets a single backend resource. rpc GetResource(GetResourceRequest) returns (GetResourceResponse) { option (google.api.http) = {get: "/sys/resources/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // Creates a new backend resource. rpc CreateResource(CreateResourceRequest) returns (CreateResourceResponse) { @@ -33,6 +36,7 @@ service ResourceService { post: "/sys/resources" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // Updates a backend resource. rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) { @@ -40,10 +44,12 @@ service ResourceService { put: "/sys/resources/{resource.id}" body: "resource" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // Deletes a backend resource. rpc DeleteResource(DeleteResourceRequest) returns (DeleteResourceResponse) { option (google.api.http) = {delete: "/sys/resources/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } } diff --git a/api/v1/proto/system/role.proto b/api/v1/proto/system/role.proto index a94aaeb3..6e6fde40 100644 --- a/api/v1/proto/system/role.proto +++ b/api/v1/proto/system/role.proto @@ -6,6 +6,7 @@ import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; +import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; @@ -17,24 +18,29 @@ option objc_class_prefix = "APIServiceSystemRole"; service RoleService { rpc ListRoles(ListRolesRequest) returns (ListRolesResponse) { option (google.api.http) = {get: "/sys/roles"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc GetRole(GetRoleRequest) returns (GetRoleResponse) { option (google.api.http) = {get: "/sys/roles/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc CreateRole(CreateRoleRequest) returns (CreateRoleResponse) { option (google.api.http) = { post: "/sys/roles" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc UpdateRole(UpdateRoleRequest) returns (UpdateRoleResponse) { option (google.api.http) = { put: "/sys/roles/{role.id}" body: "role" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc DeleteRole(DeleteRoleRequest) returns (DeleteRoleResponse) { option (google.api.http) = {delete: "/sys/roles/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } } diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index 7cf56efd..7d4cb80f 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -7,6 +7,7 @@ import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; import "types/system.proto"; +import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; @@ -18,29 +19,35 @@ option objc_class_prefix = "APIServiceSystemUser"; service UserService { rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) { option (google.api.http) = {get: "/sys/users"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc ListUserResources(ListUserResourcesRequest) returns (ListUserResourcesResponse) { option (google.api.http) = {get: "/sys/users/{id}/resources"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc GetUser(GetUserRequest) returns (GetUserResponse) { option (google.api.http) = {get: "/sys/users/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc CreateUser(CreateUserRequest) returns (CreateUserResponse) { option (google.api.http) = { post: "/sys/users" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse) { option (google.api.http) = { patch: "/sys/users/{user.id}" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse) { option (google.api.http) = {delete: "/sys/users/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // UpdateUserStatus Update the status of the user information rpc UpdateUserStatus(UpdateUserStatusRequest) returns (UpdateUserStatusResponse) { @@ -48,6 +55,7 @@ service UserService { put: "/sys/users/{id}/status" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // UpdateUserRoles update the user roles @@ -56,6 +64,7 @@ service UserService { put: "/sys/users/{id}/roles" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // ResetUserPassword reset the user s password @@ -64,6 +73,7 @@ service UserService { post: "/sys/users/{id}/password/reset" body: "password" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } } diff --git a/api/v1/proto/system/view.proto b/api/v1/proto/system/view.proto index 32cc2692..c28805c8 100644 --- a/api/v1/proto/system/view.proto +++ b/api/v1/proto/system/view.proto @@ -6,6 +6,7 @@ import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; import "types/system.proto"; +import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; @@ -19,10 +20,12 @@ service ViewService { // Lists all view elements. rpc ListViews(ListViewsRequest) returns (ListViewsResponse) { option (google.api.http) = {get: "/sys/views"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // Gets a single view element. rpc GetView(GetViewRequest) returns (GetViewResponse) { option (google.api.http) = {get: "/sys/views/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // Creates a new view element. rpc CreateView(CreateViewRequest) returns (CreateViewResponse) { @@ -30,6 +33,7 @@ service ViewService { post: "/sys/views" body: "*" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // Updates a view element. rpc UpdateView(UpdateViewRequest) returns (UpdateViewResponse) { @@ -37,10 +41,12 @@ service ViewService { put: "/sys/views/{view.id}" body: "view" }; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } // Deletes a view element. rpc DeleteView(DeleteViewRequest) returns (DeleteViewResponse) { option (google.api.http) = {delete: "/sys/views/{id}"}; + option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } } diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index 4932f5ee..69634da4 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -7,6 +7,7 @@ package auth import ( + _ "github.com/origadmin/contrib/api/gen/go/policy/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -680,7 +681,7 @@ var File_auth_auth_proto protoreflect.FileDescriptor const file_auth_auth_proto_rawDesc = "" + "\n" + - "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\"\x88\x01\n" + + "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x16policy/v1/policy.proto\"\x88\x01\n" + "\fLoginRequest\x12\x1a\n" + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x1d\n" + @@ -727,14 +728,21 @@ const file_auth_auth_proto_rawDesc = "" + "\n" + "authorized\x18\x01 \x01(\bR\n" + "authorized\x12\x17\n" + - "\auser_id\x18\x02 \x01(\tR\x06userId2\xb4\x05\n" + - "\vAuthService\x12h\n" + - "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/auth/login\x12t\n" + - "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a&.api.v1.services.auth.RegisterResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/auth/register\x12l\n" + - "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x01*\"\f/auth/logout\x12}\n" + - "\fRefreshToken\x12).api.v1.services.auth.RefreshTokenRequest\x1a*.api.v1.services.auth.RefreshTokenResponse\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/auth/token\x12q\n" + + "\auser_id\x18\x02 \x01(\tR\x06userId2\xf6\x05\n" + + "\vAuthService\x12t\n" + + "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\"\xea\xea\x1b\b\n" + + "\x06public\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/auth/login\x12\x80\x01\n" + + "\bRegister\x12%.api.v1.services.auth.RegisterRequest\x1a&.api.v1.services.auth.RegisterResponse\"%\xea\xea\x1b\b\n" + + "\x06public\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/auth/register\x12z\n" + + "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"%\xea\xea\x1b\n" + "\n" + - "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"\x10\x82\xd3\xe4\x93\x02\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x11:\x01*\"\f/auth/logout\x12\x8b\x01\n" + + "\fRefreshToken\x12).api.v1.services.auth.RefreshTokenRequest\x1a*.api.v1.services.auth.RefreshTokenResponse\"$\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/auth/token\x12}\n" + + "\n" + + "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"\x1c\xea\xea\x1b\b\n" + + "\x06public\x82\xd3\xe4\x93\x02\n" + "\x12\b/captcha\x12e\n" + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponseB\xd0\x01\n" + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" diff --git a/api/v1/services/auth/auth.pb.security.go b/api/v1/services/auth/auth.pb.security.go new file mode 100644 index 00000000..55981b27 --- /dev/null +++ b/api/v1/services/auth/auth.pb.security.go @@ -0,0 +1,45 @@ +// Code generated by protoc-gen-go-security. DO NOT EDIT. +// version: 1.0.8 + +package auth + +import ( + security "github.com/origadmin/contrib/security" +) + +func init() { + policies := []security.Policy{ + { + ServiceMethod: "/api.v1.services.auth.AuthService/Login", + GatewayPath: "POST:/auth/login", + Name: "public", + VersionID: "65b40a40507644710e6dc327991196a4edbac576f2e26919378e2c4426d11be7", + }, + { + ServiceMethod: "/api.v1.services.auth.AuthService/Register", + GatewayPath: "POST:/auth/register", + Name: "public", + VersionID: "78daab746f1d0187aa83907fc46a8218bef63d122e95e10ccad8e5162aa810ea", + }, + { + ServiceMethod: "/api.v1.services.auth.AuthService/Logout", + GatewayPath: "POST:/auth/logout", + Name: "jwt-auth", + VersionID: "5316e0e2f4982e02f72aefca0823a9435816d1b5f96e6a7ee476886d60479a47", + }, + { + ServiceMethod: "/api.v1.services.auth.AuthService/RefreshToken", + GatewayPath: "POST:/auth/token", + Name: "jwt-auth", + VersionID: "440ef699b2899614bcdd7cee97480b260e7cf04f1ae1ad681fc491e9453d6218", + }, + { + ServiceMethod: "/api.v1.services.auth.AuthService/GetCaptcha", + GatewayPath: "GET:/captcha", + Name: "public", + VersionID: "4c2d4078ffb54002daae7094b5af8c76dcbcaf87e1f79b9826fac1079d78889f", + }, + } + + security.RegisterPolicies(policies) +} diff --git a/api/v1/services/auth/casbin.pb.go b/api/v1/services/auth/casbin.pb.go index ae5c08cf..c25fc5e4 100644 --- a/api/v1/services/auth/casbin.pb.go +++ b/api/v1/services/auth/casbin.pb.go @@ -7,6 +7,7 @@ package auth import ( + _ "github.com/origadmin/contrib/api/gen/go/policy/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -512,7 +513,7 @@ var File_auth_casbin_proto protoreflect.FileDescriptor const file_auth_casbin_proto_rawDesc = "" + "\n" + - "\x11auth/casbin.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\"\x15\n" + + "\x11auth/casbin.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x16policy/v1/policy.proto\"\x15\n" + "\x13ListPoliciesRequest\"N\n" + "\x14ListPoliciesResponse\x126\n" + "\x05rules\x18\x01 \x03(\v2 .api.v1.services.auth.PolicyRuleR\x05rules\"<\n" + @@ -536,12 +537,20 @@ const file_auth_casbin_proto_rawDesc = "" + "\x12WatchUpdateRequest\x12$\n" + "\rlast_modified\x18\x01 \x01(\x03R\rlast_modified\";\n" + "\x13WatchUpdateResponse\x12$\n" + - "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\x83\x04\n" + - "\rCasbinService\x12\x82\x01\n" + - "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\"\x1b\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x86\x01\n" + - "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"\x1c\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12|\n" + - "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"\x18\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12f\n" + - "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x000\x01B\xd2\x01\n" + + "\rmodified_date\x18\x01 \x01(\x03R\rmodified_date2\xbc\x04\n" + + "\rCasbinService\x12\x90\x01\n" + + "\fListPolicies\x12).api.v1.services.auth.ListPoliciesRequest\x1a*.api.v1.services.auth.ListPoliciesResponse\")\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x15b\x01*\x12\x10/casbin/policies\x12\x94\x01\n" + + "\rListGroupings\x12*.api.v1.services.auth.ListGroupingsRequest\x1a+.api.v1.services.auth.ListGroupingsResponse\"*\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x16b\x01*\x12\x11/casbin/groupings\x12\x8a\x01\n" + + "\vWatchUpdate\x12(.api.v1.services.auth.WatchUpdateRequest\x1a).api.v1.services.auth.WatchUpdateResponse\"&\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x12b\x01*\x12\r/casbin/watch\x12t\n" + + "\vStreamRules\x12(.api.v1.services.auth.StreamRulesRequest\x1a).api.v1.services.auth.StreamRulesResponse\"\x0e\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth0\x01B\xd2\x01\n" + "\x18com.api.v1.services.authB\vCasbinProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( diff --git a/api/v1/services/auth/casbin.pb.security.go b/api/v1/services/auth/casbin.pb.security.go new file mode 100644 index 00000000..d1deddb8 --- /dev/null +++ b/api/v1/services/auth/casbin.pb.security.go @@ -0,0 +1,39 @@ +// Code generated by protoc-gen-go-security. DO NOT EDIT. +// version: 1.0.8 + +package auth + +import ( + security "github.com/origadmin/contrib/security" +) + +func init() { + policies := []security.Policy{ + { + ServiceMethod: "/api.v1.services.auth.CasbinService/ListPolicies", + GatewayPath: "GET:/casbin/policies", + Name: "jwt-auth", + VersionID: "18622517adfd1c89ce1ada20b5f4af8f0bef9c7490deec6f364609cbaa9a6b8d", + }, + { + ServiceMethod: "/api.v1.services.auth.CasbinService/ListGroupings", + GatewayPath: "GET:/casbin/groupings", + Name: "jwt-auth", + VersionID: "8bfaf806e938ac5a8c8ca5be8148ef3fcd7e202fc1659266fe40d6045df021e2", + }, + { + ServiceMethod: "/api.v1.services.auth.CasbinService/WatchUpdate", + GatewayPath: "GET:/casbin/watch", + Name: "jwt-auth", + VersionID: "ae9423cf8facd7b38a0b27595e8fe15ce7666beca64e0db0831a8356baf0efba", + }, + { + ServiceMethod: "/api.v1.services.auth.CasbinService/StreamRules", + GatewayPath: "", + Name: "jwt-auth", + VersionID: "2204990505087177bba9898d6cb43b0f29fcc15723626cbaf0d9e243bb6c1696", + }, + } + + security.RegisterPolicies(policies) +} diff --git a/api/v1/services/auth/me.pb.go b/api/v1/services/auth/me.pb.go index 0429fa18..06edbde1 100644 --- a/api/v1/services/auth/me.pb.go +++ b/api/v1/services/auth/me.pb.go @@ -7,6 +7,7 @@ package auth import ( + _ "github.com/origadmin/contrib/api/gen/go/policy/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -446,7 +447,7 @@ var File_auth_me_proto protoreflect.FileDescriptor const file_auth_me_proto_rawDesc = "" + "\n" + - "\rauth/me.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x12types/system.proto\"\x13\n" + + "\rauth/me.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"\x13\n" + "\x11GetProfileRequest\"E\n" + "\x12GetProfileResponse\x12/\n" + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\"G\n" + @@ -462,14 +463,24 @@ const file_auth_me_proto_rawDesc = "" + "\tresources\x18\x01 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\"\x15\n" + "\x13GetUserRolesRequest\"I\n" + "\x14GetUserRolesResponse\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles2\x90\x05\n" + - "\tMeService\x12t\n" + + "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles2\xd8\x05\n" + + "\tMeService\x12\x82\x01\n" + "\n" + - "GetProfile\x12'.api.v1.services.auth.GetProfileRequest\x1a(.api.v1.services.auth.GetProfileResponse\"\x13\x82\xd3\xe4\x93\x02\r\x12\v/me/profile\x12\x80\x01\n" + - "\rUpdateProfile\x12*.api.v1.services.auth.UpdateProfileRequest\x1a+.api.v1.services.auth.UpdateProfileResponse\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\x1a\v/me/profile\x12\x84\x01\n" + - "\x0eUpdatePassword\x12+.api.v1.services.auth.UpdatePasswordRequest\x1a,.api.v1.services.auth.UpdatePasswordResponse\"\x17\x82\xd3\xe4\x93\x02\x11:\x01*\x1a\f/me/password\x12\x88\x01\n" + - "\x10GetUserResources\x12-.api.v1.services.auth.GetUserResourcesRequest\x1a..api.v1.services.auth.GetUserResourcesResponse\"\x15\x82\xd3\xe4\x93\x02\x0f\x12\r/me/resources\x12x\n" + - "\fGetUserRoles\x12).api.v1.services.auth.GetUserRolesRequest\x1a*.api.v1.services.auth.GetUserRolesResponse\"\x11\x82\xd3\xe4\x93\x02\v\x12\t/me/rolesB\xce\x01\n" + + "GetProfile\x12'.api.v1.services.auth.GetProfileRequest\x1a(.api.v1.services.auth.GetProfileResponse\"!\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\r\x12\v/me/profile\x12\x8e\x01\n" + + "\rUpdateProfile\x12*.api.v1.services.auth.UpdateProfileRequest\x1a+.api.v1.services.auth.UpdateProfileResponse\"$\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x10:\x01*\x1a\v/me/profile\x12\x92\x01\n" + + "\x0eUpdatePassword\x12+.api.v1.services.auth.UpdatePasswordRequest\x1a,.api.v1.services.auth.UpdatePasswordResponse\"%\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x11:\x01*\x1a\f/me/password\x12\x96\x01\n" + + "\x10GetUserResources\x12-.api.v1.services.auth.GetUserResourcesRequest\x1a..api.v1.services.auth.GetUserResourcesResponse\"#\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x0f\x12\r/me/resources\x12\x86\x01\n" + + "\fGetUserRoles\x12).api.v1.services.auth.GetUserRolesRequest\x1a*.api.v1.services.auth.GetUserRolesResponse\"\x1f\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\v\x12\t/me/rolesB\xce\x01\n" + "\x18com.api.v1.services.authB\aMeProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" var ( diff --git a/api/v1/services/auth/me.pb.security.go b/api/v1/services/auth/me.pb.security.go new file mode 100644 index 00000000..791d48fe --- /dev/null +++ b/api/v1/services/auth/me.pb.security.go @@ -0,0 +1,45 @@ +// Code generated by protoc-gen-go-security. DO NOT EDIT. +// version: 1.0.8 + +package auth + +import ( + security "github.com/origadmin/contrib/security" +) + +func init() { + policies := []security.Policy{ + { + ServiceMethod: "/api.v1.services.auth.MeService/GetProfile", + GatewayPath: "GET:/me/profile", + Name: "jwt-auth", + VersionID: "f88566a0bc6e606dc46809e38b56906261814856b8512f9df4f942d1c972167f", + }, + { + ServiceMethod: "/api.v1.services.auth.MeService/UpdateProfile", + GatewayPath: "PUT:/me/profile", + Name: "jwt-auth", + VersionID: "6b9f1e295516367e07e805f814684047b84f7955a41d73297de5f0b28e0607d7", + }, + { + ServiceMethod: "/api.v1.services.auth.MeService/UpdatePassword", + GatewayPath: "PUT:/me/password", + Name: "jwt-auth", + VersionID: "2f0240b918bcc1f0f0d50ebdb63e66ebdcda8a6c19cd39b0c962fc39393ae58e", + }, + { + ServiceMethod: "/api.v1.services.auth.MeService/GetUserResources", + GatewayPath: "GET:/me/resources", + Name: "jwt-auth", + VersionID: "3343d31b838f9cc340ccc3c8c79baa3601f5ed0f469d2bb40f5f5c8ac8e02692", + }, + { + ServiceMethod: "/api.v1.services.auth.MeService/GetUserRoles", + GatewayPath: "GET:/me/roles", + Name: "jwt-auth", + VersionID: "2fcac1e2b35f7cbdfc2fb099e79a106bc1feb73b3600e0e53fdaf6dc9a3c9078", + }, + } + + security.RegisterPolicies(policies) +} diff --git a/api/v1/services/system/department.pb.go b/api/v1/services/system/department.pb.go index ba47090b..2faafadd 100644 --- a/api/v1/services/system/department.pb.go +++ b/api/v1/services/system/department.pb.go @@ -7,6 +7,7 @@ package system import ( + _ "github.com/origadmin/contrib/api/gen/go/policy/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -606,7 +607,7 @@ var File_system_department_proto protoreflect.FileDescriptor const file_system_department_proto_rawDesc = "" + "\n" + - "\x17system/department.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xd2\x01\n" + + "\x17system/department.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"\xd2\x01\n" + "\x16ListDepartmentsRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + @@ -655,14 +656,24 @@ const file_system_department_proto_rawDesc = "" + "\x17DeleteDepartmentRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + "\x18DeleteDepartmentResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x8a\x06\n" + - "\x11DepartmentService\x12\x8c\x01\n" + - "\x0fListDepartments\x12..api.v1.services.system.ListDepartmentsRequest\x1a/.api.v1.services.system.ListDepartmentsResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/departments\x12\x8b\x01\n" + - "\rGetDepartment\x12,.api.v1.services.system.GetDepartmentRequest\x1a-.api.v1.services.system.GetDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/departments/{id}\x12\x92\x01\n" + - "\x10CreateDepartment\x12/.api.v1.services.system.CreateDepartmentRequest\x1a0.api.v1.services.system.CreateDepartmentResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/sys/departments\x12\xab\x01\n" + - "\x10UpdateDepartment\x12/.api.v1.services.system.UpdateDepartmentRequest\x1a0.api.v1.services.system.UpdateDepartmentResponse\"4\x82\xd3\xe4\x93\x02.:\n" + - "department\x1a /sys/departments/{department.id}\x12\x94\x01\n" + - "\x10DeleteDepartment\x12/.api.v1.services.system.DeleteDepartmentRequest\x1a0.api.v1.services.system.DeleteDepartmentResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/departments/{id}B\xe4\x01\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xd0\x06\n" + + "\x11DepartmentService\x12\x9a\x01\n" + + "\x0fListDepartments\x12..api.v1.services.system.ListDepartmentsRequest\x1a/.api.v1.services.system.ListDepartmentsResponse\"&\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/departments\x12\x99\x01\n" + + "\rGetDepartment\x12,.api.v1.services.system.GetDepartmentRequest\x1a-.api.v1.services.system.GetDepartmentResponse\"+\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/departments/{id}\x12\xa0\x01\n" + + "\x10CreateDepartment\x12/.api.v1.services.system.CreateDepartmentRequest\x1a0.api.v1.services.system.CreateDepartmentResponse\")\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/sys/departments\x12\xb9\x01\n" + + "\x10UpdateDepartment\x12/.api.v1.services.system.UpdateDepartmentRequest\x1a0.api.v1.services.system.UpdateDepartmentResponse\"B\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02.:\n" + + "department\x1a /sys/departments/{department.id}\x12\xa2\x01\n" + + "\x10DeleteDepartment\x12/.api.v1.services.system.DeleteDepartmentRequest\x1a0.api.v1.services.system.DeleteDepartmentResponse\"+\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x17*\x15/sys/departments/{id}B\xe4\x01\n" + "\x1acom.api.v1.services.systemB\x0fDepartmentProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( diff --git a/api/v1/services/system/department.pb.security.go b/api/v1/services/system/department.pb.security.go new file mode 100644 index 00000000..b762566b --- /dev/null +++ b/api/v1/services/system/department.pb.security.go @@ -0,0 +1,45 @@ +// Code generated by protoc-gen-go-security. DO NOT EDIT. +// version: 1.0.8 + +package system + +import ( + security "github.com/origadmin/contrib/security" +) + +func init() { + policies := []security.Policy{ + { + ServiceMethod: "/api.v1.services.system.DepartmentService/ListDepartments", + GatewayPath: "GET:/sys/departments", + Name: "jwt-auth", + VersionID: "24d3da2eb7b9118c4a034455dc49d3eab24a30e72aadb86740e411244f6fe3ff", + }, + { + ServiceMethod: "/api.v1.services.system.DepartmentService/GetDepartment", + GatewayPath: "GET:/sys/departments/{id}", + Name: "jwt-auth", + VersionID: "b59f690402b9b5fce77774731c1b67e03f2843db393d1326dca80e4c6c60c4bd", + }, + { + ServiceMethod: "/api.v1.services.system.DepartmentService/CreateDepartment", + GatewayPath: "POST:/sys/departments", + Name: "jwt-auth", + VersionID: "1b845cbc34961752487f3f8ffd09b52e5ab25c02400a921d45aebde69586aaae", + }, + { + ServiceMethod: "/api.v1.services.system.DepartmentService/UpdateDepartment", + GatewayPath: "PUT:/sys/departments/{department.id}", + Name: "jwt-auth", + VersionID: "47d63e68261d9ce41603e02259d60c66f835cc8a25deceb4e5314bd443262e43", + }, + { + ServiceMethod: "/api.v1.services.system.DepartmentService/DeleteDepartment", + GatewayPath: "DELETE:/sys/departments/{id}", + Name: "jwt-auth", + VersionID: "df57910ba6698301e581718a9f45a4f2c98d8ad5f28dcc78da5f530fc7e17f61", + }, + } + + security.RegisterPolicies(policies) +} diff --git a/api/v1/services/system/permission.pb.go b/api/v1/services/system/permission.pb.go index 7dd4d018..5971b223 100644 --- a/api/v1/services/system/permission.pb.go +++ b/api/v1/services/system/permission.pb.go @@ -7,6 +7,7 @@ package system import ( + _ "github.com/origadmin/contrib/api/gen/go/policy/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -615,7 +616,7 @@ var File_system_permission_proto protoreflect.FileDescriptor const file_system_permission_proto_rawDesc = "" + "\n" + - "\x17system/permission.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xf4\x01\n" + + "\x17system/permission.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"\xf4\x01\n" + "\x16ListPermissionsRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + @@ -665,14 +666,24 @@ const file_system_permission_proto_rawDesc = "" + "\x17DeletePermissionRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + "\x18DeletePermissionResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x8a\x06\n" + - "\x11PermissionService\x12\x8c\x01\n" + - "\x0fListPermissions\x12..api.v1.services.system.ListPermissionsRequest\x1a/.api.v1.services.system.ListPermissionsResponse\"\x18\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/permissions\x12\x8b\x01\n" + - "\rGetPermission\x12,.api.v1.services.system.GetPermissionRequest\x1a-.api.v1.services.system.GetPermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/permissions/{id}\x12\x92\x01\n" + - "\x10CreatePermission\x12/.api.v1.services.system.CreatePermissionRequest\x1a0.api.v1.services.system.CreatePermissionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/sys/permissions\x12\xab\x01\n" + - "\x10UpdatePermission\x12/.api.v1.services.system.UpdatePermissionRequest\x1a0.api.v1.services.system.UpdatePermissionResponse\"4\x82\xd3\xe4\x93\x02.:\n" + - "permission\x1a /sys/permissions/{permission.id}\x12\x94\x01\n" + - "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"\x1d\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xe4\x01\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xd0\x06\n" + + "\x11PermissionService\x12\x9a\x01\n" + + "\x0fListPermissions\x12..api.v1.services.system.ListPermissionsRequest\x1a/.api.v1.services.system.ListPermissionsResponse\"&\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x12\x12\x10/sys/permissions\x12\x99\x01\n" + + "\rGetPermission\x12,.api.v1.services.system.GetPermissionRequest\x1a-.api.v1.services.system.GetPermissionResponse\"+\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/permissions/{id}\x12\xa0\x01\n" + + "\x10CreatePermission\x12/.api.v1.services.system.CreatePermissionRequest\x1a0.api.v1.services.system.CreatePermissionResponse\")\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/sys/permissions\x12\xb9\x01\n" + + "\x10UpdatePermission\x12/.api.v1.services.system.UpdatePermissionRequest\x1a0.api.v1.services.system.UpdatePermissionResponse\"B\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02.:\n" + + "permission\x1a /sys/permissions/{permission.id}\x12\xa2\x01\n" + + "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"+\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xe4\x01\n" + "\x1acom.api.v1.services.systemB\x0fPermissionProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( diff --git a/api/v1/services/system/permission.pb.security.go b/api/v1/services/system/permission.pb.security.go new file mode 100644 index 00000000..0ecd8d91 --- /dev/null +++ b/api/v1/services/system/permission.pb.security.go @@ -0,0 +1,45 @@ +// Code generated by protoc-gen-go-security. DO NOT EDIT. +// version: 1.0.8 + +package system + +import ( + security "github.com/origadmin/contrib/security" +) + +func init() { + policies := []security.Policy{ + { + ServiceMethod: "/api.v1.services.system.PermissionService/ListPermissions", + GatewayPath: "GET:/sys/permissions", + Name: "jwt-auth", + VersionID: "747ca3e97c4da01880928edded91956b432c5998d094e72eb24049843708f8b2", + }, + { + ServiceMethod: "/api.v1.services.system.PermissionService/GetPermission", + GatewayPath: "GET:/sys/permissions/{id}", + Name: "jwt-auth", + VersionID: "e9e5ef228b3f5bd2ed85525ff5feab76b7024c7926b0f20bffcd57140d4dd819", + }, + { + ServiceMethod: "/api.v1.services.system.PermissionService/CreatePermission", + GatewayPath: "POST:/sys/permissions", + Name: "jwt-auth", + VersionID: "468e4a0da8ac26691071d6f6b9625a6e8e44406d15cd6ae8a7b890601f64e039", + }, + { + ServiceMethod: "/api.v1.services.system.PermissionService/UpdatePermission", + GatewayPath: "PUT:/sys/permissions/{permission.id}", + Name: "jwt-auth", + VersionID: "eec3e1eeb9af9c9aa68077fcdb249478624469780e64f7d608d5361a18b27a6f", + }, + { + ServiceMethod: "/api.v1.services.system.PermissionService/DeletePermission", + GatewayPath: "DELETE:/sys/permissions/{id}", + Name: "jwt-auth", + VersionID: "b7140fde854958f886c7a644c8563ede7b0828335f1054ed4b512faf198cb846", + }, + } + + security.RegisterPolicies(policies) +} diff --git a/api/v1/services/system/position.pb.go b/api/v1/services/system/position.pb.go index 27055225..32e21c6c 100644 --- a/api/v1/services/system/position.pb.go +++ b/api/v1/services/system/position.pb.go @@ -7,6 +7,7 @@ package system import ( + _ "github.com/origadmin/contrib/api/gen/go/policy/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -605,7 +606,7 @@ var File_system_position_proto protoreflect.FileDescriptor const file_system_position_proto_rawDesc = "" + "\n" + - "\x15system/position.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xd0\x01\n" + + "\x15system/position.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"\xd0\x01\n" + "\x14ListPositionsRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + @@ -644,13 +645,23 @@ const file_system_position_proto_rawDesc = "" + "\x15DeletePositionRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + "\x16DeletePositionResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xdc\x05\n" + - "\x0fPositionService\x12\x84\x01\n" + - "\rListPositions\x12,.api.v1.services.system.ListPositionsRequest\x1a-.api.v1.services.system.ListPositionsResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/positions\x12\x83\x01\n" + - "\vGetPosition\x12*.api.v1.services.system.GetPositionRequest\x1a+.api.v1.services.system.GetPositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/positions/{id}\x12\x8a\x01\n" + - "\x0eCreatePosition\x12-.api.v1.services.system.CreatePositionRequest\x1a..api.v1.services.system.CreatePositionResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/sys/positions\x12\x9f\x01\n" + - "\x0eUpdatePosition\x12-.api.v1.services.system.UpdatePositionRequest\x1a..api.v1.services.system.UpdatePositionResponse\".\x82\xd3\xe4\x93\x02(:\bposition\x1a\x1c/sys/positions/{position.id}\x12\x8c\x01\n" + - "\x0eDeletePosition\x12-.api.v1.services.system.DeletePositionRequest\x1a..api.v1.services.system.DeletePositionResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/positions/{id}B\xe2\x01\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xa2\x06\n" + + "\x0fPositionService\x12\x92\x01\n" + + "\rListPositions\x12,.api.v1.services.system.ListPositionsRequest\x1a-.api.v1.services.system.ListPositionsResponse\"$\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/positions\x12\x91\x01\n" + + "\vGetPosition\x12*.api.v1.services.system.GetPositionRequest\x1a+.api.v1.services.system.GetPositionResponse\")\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/positions/{id}\x12\x98\x01\n" + + "\x0eCreatePosition\x12-.api.v1.services.system.CreatePositionRequest\x1a..api.v1.services.system.CreatePositionResponse\"'\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/sys/positions\x12\xad\x01\n" + + "\x0eUpdatePosition\x12-.api.v1.services.system.UpdatePositionRequest\x1a..api.v1.services.system.UpdatePositionResponse\"<\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02(:\bposition\x1a\x1c/sys/positions/{position.id}\x12\x9a\x01\n" + + "\x0eDeletePosition\x12-.api.v1.services.system.DeletePositionRequest\x1a..api.v1.services.system.DeletePositionResponse\")\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x15*\x13/sys/positions/{id}B\xe2\x01\n" + "\x1acom.api.v1.services.systemB\rPositionProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( diff --git a/api/v1/services/system/position.pb.security.go b/api/v1/services/system/position.pb.security.go new file mode 100644 index 00000000..db232151 --- /dev/null +++ b/api/v1/services/system/position.pb.security.go @@ -0,0 +1,45 @@ +// Code generated by protoc-gen-go-security. DO NOT EDIT. +// version: 1.0.8 + +package system + +import ( + security "github.com/origadmin/contrib/security" +) + +func init() { + policies := []security.Policy{ + { + ServiceMethod: "/api.v1.services.system.PositionService/ListPositions", + GatewayPath: "GET:/sys/positions", + Name: "jwt-auth", + VersionID: "6bf7a7477afcced6886e75decd95c3b399e9bacb1c2dff5362514e31bfa4f51d", + }, + { + ServiceMethod: "/api.v1.services.system.PositionService/GetPosition", + GatewayPath: "GET:/sys/positions/{id}", + Name: "jwt-auth", + VersionID: "1cebb8b8b0ed6df56b0b468ab0d096a977210d3ccc6410cee801927d408d18a4", + }, + { + ServiceMethod: "/api.v1.services.system.PositionService/CreatePosition", + GatewayPath: "POST:/sys/positions", + Name: "jwt-auth", + VersionID: "6dc561ae7080ba5a1e0fd8d149a2e329dfabca22846fc14c21a778a149b93ca6", + }, + { + ServiceMethod: "/api.v1.services.system.PositionService/UpdatePosition", + GatewayPath: "PUT:/sys/positions/{position.id}", + Name: "jwt-auth", + VersionID: "4bc4e32a8bee29ae8ecc88f1869c28bce0f2244f184886896e4376e24bee4901", + }, + { + ServiceMethod: "/api.v1.services.system.PositionService/DeletePosition", + GatewayPath: "DELETE:/sys/positions/{id}", + Name: "jwt-auth", + VersionID: "d18e93827f6e8dbea7ad7ae93d7799b15e9056e49f876d727d377f11c8eceba6", + }, + } + + security.RegisterPolicies(policies) +} diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go index 581196ea..a134d569 100644 --- a/api/v1/services/system/resource.pb.go +++ b/api/v1/services/system/resource.pb.go @@ -7,6 +7,7 @@ package system import ( + _ "github.com/origadmin/contrib/api/gen/go/policy/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -599,7 +600,7 @@ var File_system_resource_proto protoreflect.FileDescriptor const file_system_resource_proto_rawDesc = "" + "\n" + - "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\x96\x02\n" + + "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"\x96\x02\n" + "\x14ListResourcesRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + @@ -640,13 +641,23 @@ const file_system_resource_proto_rawDesc = "" + "\x15DeleteResourceRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + "\x16DeleteResourceResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xdc\x05\n" + - "\x0fResourceService\x12\x84\x01\n" + - "\rListResources\x12,.api.v1.services.system.ListResourcesRequest\x1a-.api.v1.services.system.ListResourcesResponse\"\x16\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/resources\x12\x83\x01\n" + - "\vGetResource\x12*.api.v1.services.system.GetResourceRequest\x1a+.api.v1.services.system.GetResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/resources/{id}\x12\x8a\x01\n" + - "\x0eCreateResource\x12-.api.v1.services.system.CreateResourceRequest\x1a..api.v1.services.system.CreateResourceResponse\"\x19\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/sys/resources\x12\x9f\x01\n" + - "\x0eUpdateResource\x12-.api.v1.services.system.UpdateResourceRequest\x1a..api.v1.services.system.UpdateResourceResponse\".\x82\xd3\xe4\x93\x02(:\bresource\x1a\x1c/sys/resources/{resource.id}\x12\x8c\x01\n" + - "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\"\x1b\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xe2\x01\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xa2\x06\n" + + "\x0fResourceService\x12\x92\x01\n" + + "\rListResources\x12,.api.v1.services.system.ListResourcesRequest\x1a-.api.v1.services.system.ListResourcesResponse\"$\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x10\x12\x0e/sys/resources\x12\x91\x01\n" + + "\vGetResource\x12*.api.v1.services.system.GetResourceRequest\x1a+.api.v1.services.system.GetResourceResponse\")\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/resources/{id}\x12\x98\x01\n" + + "\x0eCreateResource\x12-.api.v1.services.system.CreateResourceRequest\x1a..api.v1.services.system.CreateResourceResponse\"'\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/sys/resources\x12\xad\x01\n" + + "\x0eUpdateResource\x12-.api.v1.services.system.UpdateResourceRequest\x1a..api.v1.services.system.UpdateResourceResponse\"<\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02(:\bresource\x1a\x1c/sys/resources/{resource.id}\x12\x9a\x01\n" + + "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\")\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xe2\x01\n" + "\x1acom.api.v1.services.systemB\rResourceProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( diff --git a/api/v1/services/system/resource.pb.security.go b/api/v1/services/system/resource.pb.security.go new file mode 100644 index 00000000..93b28cdf --- /dev/null +++ b/api/v1/services/system/resource.pb.security.go @@ -0,0 +1,45 @@ +// Code generated by protoc-gen-go-security. DO NOT EDIT. +// version: 1.0.8 + +package system + +import ( + security "github.com/origadmin/contrib/security" +) + +func init() { + policies := []security.Policy{ + { + ServiceMethod: "/api.v1.services.system.ResourceService/ListResources", + GatewayPath: "GET:/sys/resources", + Name: "jwt-auth", + VersionID: "62e6cf359f3f4f68f734db7f0a36c9a2d6ce146cf4ab9d8e1edb99044738edd6", + }, + { + ServiceMethod: "/api.v1.services.system.ResourceService/GetResource", + GatewayPath: "GET:/sys/resources/{id}", + Name: "jwt-auth", + VersionID: "17ee1cdd756d86df3727468e227aea81f5119c04a6873774a31a3a5502872637", + }, + { + ServiceMethod: "/api.v1.services.system.ResourceService/CreateResource", + GatewayPath: "POST:/sys/resources", + Name: "jwt-auth", + VersionID: "db0dba76c69e0cdc54006974df2daba4e597fd201b33063f24ed011ef4af7e44", + }, + { + ServiceMethod: "/api.v1.services.system.ResourceService/UpdateResource", + GatewayPath: "PUT:/sys/resources/{resource.id}", + Name: "jwt-auth", + VersionID: "82c33a0a40fc0f4cc76b276b50dfbfae135f0d1577d44ca8f6718ea5eab61b58", + }, + { + ServiceMethod: "/api.v1.services.system.ResourceService/DeleteResource", + GatewayPath: "DELETE:/sys/resources/{id}", + Name: "jwt-auth", + VersionID: "76bd515d9cd6ade8dbdbaf90ba32033d6ed31cfecd1fcbbf3fcb8f6c498bf973", + }, + } + + security.RegisterPolicies(policies) +} diff --git a/api/v1/services/system/role.pb.go b/api/v1/services/system/role.pb.go index 60714fc4..7e7330a9 100644 --- a/api/v1/services/system/role.pb.go +++ b/api/v1/services/system/role.pb.go @@ -7,6 +7,7 @@ package system import ( + _ "github.com/origadmin/contrib/api/gen/go/policy/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -606,7 +607,7 @@ var File_system_role_proto protoreflect.FileDescriptor const file_system_role_proto_rawDesc = "" + "\n" + - "\x11system/role.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xcc\x01\n" + + "\x11system/role.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"\xcc\x01\n" + "\x10ListRolesRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + @@ -645,18 +646,28 @@ const file_system_role_proto_rawDesc = "" + "\x11DeleteRoleRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + "\x12DeleteRoleResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xfc\x04\n" + - "\vRoleService\x12t\n" + - "\tListRoles\x12(.api.v1.services.system.ListRolesRequest\x1a).api.v1.services.system.ListRolesResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + - "/sys/roles\x12s\n" + - "\aGetRole\x12&.api.v1.services.system.GetRoleRequest\x1a'.api.v1.services.system.GetRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/roles/{id}\x12z\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xc6\x05\n" + + "\vRoleService\x12\x82\x01\n" + + "\tListRoles\x12(.api.v1.services.system.ListRolesRequest\x1a).api.v1.services.system.ListRolesResponse\" \xea\xea\x1b\n" + "\n" + - "CreateRole\x12).api.v1.services.system.CreateRoleRequest\x1a*.api.v1.services.system.CreateRoleResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + - "/sys/roles\x12\x87\x01\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\f\x12\n" + + "/sys/roles\x12\x81\x01\n" + + "\aGetRole\x12&.api.v1.services.system.GetRoleRequest\x1a'.api.v1.services.system.GetRoleResponse\"%\xea\xea\x1b\n" + "\n" + - "UpdateRole\x12).api.v1.services.system.UpdateRoleRequest\x1a*.api.v1.services.system.UpdateRoleResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04role\x1a\x14/sys/roles/{role.id}\x12|\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/roles/{id}\x12\x88\x01\n" + "\n" + - "DeleteRole\x12).api.v1.services.system.DeleteRoleRequest\x1a*.api.v1.services.system.DeleteRoleResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/roles/{id}B\xde\x01\n" + + "CreateRole\x12).api.v1.services.system.CreateRoleRequest\x1a*.api.v1.services.system.CreateRoleResponse\"#\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + + "/sys/roles\x12\x95\x01\n" + + "\n" + + "UpdateRole\x12).api.v1.services.system.UpdateRoleRequest\x1a*.api.v1.services.system.UpdateRoleResponse\"0\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x1c:\x04role\x1a\x14/sys/roles/{role.id}\x12\x8a\x01\n" + + "\n" + + "DeleteRole\x12).api.v1.services.system.DeleteRoleRequest\x1a*.api.v1.services.system.DeleteRoleResponse\"%\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x11*\x0f/sys/roles/{id}B\xde\x01\n" + "\x1acom.api.v1.services.systemB\tRoleProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( diff --git a/api/v1/services/system/role.pb.security.go b/api/v1/services/system/role.pb.security.go new file mode 100644 index 00000000..eef92c0f --- /dev/null +++ b/api/v1/services/system/role.pb.security.go @@ -0,0 +1,45 @@ +// Code generated by protoc-gen-go-security. DO NOT EDIT. +// version: 1.0.8 + +package system + +import ( + security "github.com/origadmin/contrib/security" +) + +func init() { + policies := []security.Policy{ + { + ServiceMethod: "/api.v1.services.system.RoleService/ListRoles", + GatewayPath: "GET:/sys/roles", + Name: "jwt-auth", + VersionID: "228722f545152df1a8f7905556bcd31b981d5a410e0033dc288caf5506877850", + }, + { + ServiceMethod: "/api.v1.services.system.RoleService/GetRole", + GatewayPath: "GET:/sys/roles/{id}", + Name: "jwt-auth", + VersionID: "21d6dc540298d65142addc20699e4f5db4984cdd1fdcdb967ddef5d741ee16b9", + }, + { + ServiceMethod: "/api.v1.services.system.RoleService/CreateRole", + GatewayPath: "POST:/sys/roles", + Name: "jwt-auth", + VersionID: "fd37642c9c512fd181135d2c39fde7cd43ab7e19e8c8127bc523b50100a3826a", + }, + { + ServiceMethod: "/api.v1.services.system.RoleService/UpdateRole", + GatewayPath: "PUT:/sys/roles/{role.id}", + Name: "jwt-auth", + VersionID: "a64f541e97fb9df4639ae1cb9e686db3f9f83fc863a139500f2e59adcc526482", + }, + { + ServiceMethod: "/api.v1.services.system.RoleService/DeleteRole", + GatewayPath: "DELETE:/sys/roles/{id}", + Name: "jwt-auth", + VersionID: "0fb85f5063855de7a00a4fa97bde5cdaaa244fa3d2edee395a7e7f67e2f653f6", + }, + } + + security.RegisterPolicies(policies) +} diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go index e7e4cfb5..e6e7d7dc 100644 --- a/api/v1/services/system/user.pb.go +++ b/api/v1/services/system/user.pb.go @@ -7,6 +7,7 @@ package system import ( + _ "github.com/origadmin/contrib/api/gen/go/policy/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -975,7 +976,7 @@ var File_system_user_proto protoreflect.FileDescriptor const file_system_user_proto_rawDesc = "" + "\n" + - "\x11system/user.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x12types/system.proto\"*\n" + + "\x11system/user.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"*\n" + "\x18ListUserResourcesRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"p\n" + "\x19ListUserResourcesResponse\x12\x14\n" + @@ -1033,22 +1034,41 @@ const file_system_user_proto_rawDesc = "" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" + "\brole_ids\x18\x02 \x03(\x03R\brole_ids\"J\n" + "\x17UpdateUserRolesResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\xf6\t\n" + - "\vUserService\x12t\n" + - "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + - "/sys/users\x12\x9b\x01\n" + - "\x11ListUserResources\x120.api.v1.services.system.ListUserResourcesRequest\x1a1.api.v1.services.system.ListUserResourcesResponse\"!\x82\xd3\xe4\x93\x02\x1b\x12\x19/sys/users/{id}/resources\x12s\n" + - "\aGetUser\x12&.api.v1.services.system.GetUserRequest\x1a'.api.v1.services.system.GetUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/users/{id}\x12z\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\xf8\n" + "\n" + - "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a*.api.v1.services.system.CreateUserResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + - "/sys/users\x12\x84\x01\n" + + "\vUserService\x12\x82\x01\n" + + "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\" \xea\xea\x1b\n" + "\n" + - "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*2\x14/sys/users/{user.id}\x12|\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\f\x12\n" + + "/sys/users\x12\xa9\x01\n" + + "\x11ListUserResources\x120.api.v1.services.system.ListUserResourcesRequest\x1a1.api.v1.services.system.ListUserResourcesResponse\"/\xea\xea\x1b\n" + "\n" + - "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/users/{id}\x12\x98\x01\n" + - "\x10UpdateUserStatus\x12/.api.v1.services.system.UpdateUserStatusRequest\x1a0.api.v1.services.system.UpdateUserStatusResponse\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x1a\x16/sys/users/{id}/status\x12\x94\x01\n" + - "\x0fUpdateUserRoles\x12..api.v1.services.system.UpdateUserRolesRequest\x1a/.api.v1.services.system.UpdateUserRolesResponse\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x1a\x15/sys/users/{id}/roles\x12\xaa\x01\n" + - "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\"0\x82\xd3\xe4\x93\x02*:\bpassword\"\x1e/sys/users/{id}/password/resetB\xde\x01\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x1b\x12\x19/sys/users/{id}/resources\x12\x81\x01\n" + + "\aGetUser\x12&.api.v1.services.system.GetUserRequest\x1a'.api.v1.services.system.GetUserResponse\"%\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/users/{id}\x12\x88\x01\n" + + "\n" + + "CreateUser\x12).api.v1.services.system.CreateUserRequest\x1a*.api.v1.services.system.CreateUserResponse\"#\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + + "/sys/users\x12\x92\x01\n" + + "\n" + + "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"-\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x19:\x01*2\x14/sys/users/{user.id}\x12\x8a\x01\n" + + "\n" + + "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"%\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x11*\x0f/sys/users/{id}\x12\xa6\x01\n" + + "\x10UpdateUserStatus\x12/.api.v1.services.system.UpdateUserStatusRequest\x1a0.api.v1.services.system.UpdateUserStatusResponse\"/\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x1b:\x01*\x1a\x16/sys/users/{id}/status\x12\xa2\x01\n" + + "\x0fUpdateUserRoles\x12..api.v1.services.system.UpdateUserRolesRequest\x1a/.api.v1.services.system.UpdateUserRolesResponse\".\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x1a:\x01*\x1a\x15/sys/users/{id}/roles\x12\xb8\x01\n" + + "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\">\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02*:\bpassword\"\x1e/sys/users/{id}/password/resetB\xde\x01\n" + "\x1acom.api.v1.services.systemB\tUserProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( diff --git a/api/v1/services/system/user.pb.security.go b/api/v1/services/system/user.pb.security.go new file mode 100644 index 00000000..a7048486 --- /dev/null +++ b/api/v1/services/system/user.pb.security.go @@ -0,0 +1,69 @@ +// Code generated by protoc-gen-go-security. DO NOT EDIT. +// version: 1.0.8 + +package system + +import ( + security "github.com/origadmin/contrib/security" +) + +func init() { + policies := []security.Policy{ + { + ServiceMethod: "/api.v1.services.system.UserService/ListUsers", + GatewayPath: "GET:/sys/users", + Name: "jwt-auth", + VersionID: "fff9e3d98631684d273f2def397c68a76c2bb518a2fec6ba254ef3ee45330f8f", + }, + { + ServiceMethod: "/api.v1.services.system.UserService/ListUserResources", + GatewayPath: "GET:/sys/users/{id}/resources", + Name: "jwt-auth", + VersionID: "b09a00f1c250dfd0f4f27969900e6a037f140931825abc211db379ee30981794", + }, + { + ServiceMethod: "/api.v1.services.system.UserService/GetUser", + GatewayPath: "GET:/sys/users/{id}", + Name: "jwt-auth", + VersionID: "a7734db6f17a2d0832dfd3f4f585feecd021cbbd5435268706fef092ea238543", + }, + { + ServiceMethod: "/api.v1.services.system.UserService/CreateUser", + GatewayPath: "POST:/sys/users", + Name: "jwt-auth", + VersionID: "5728bce5dd33d8897a33b19b4f4db6a0aa29d3edb34628705d5f05a2b4819977", + }, + { + ServiceMethod: "/api.v1.services.system.UserService/UpdateUser", + GatewayPath: "PATCH:/sys/users/{user.id}", + Name: "jwt-auth", + VersionID: "d8e0be7e0fdf3b02e0af09c8d0f8404c763d57d14e621679533071caca4446bb", + }, + { + ServiceMethod: "/api.v1.services.system.UserService/DeleteUser", + GatewayPath: "DELETE:/sys/users/{id}", + Name: "jwt-auth", + VersionID: "61eafa3ffa93174ae5ca94de12e56d15cdaf3974825e4fea7d67e774a500f508", + }, + { + ServiceMethod: "/api.v1.services.system.UserService/UpdateUserStatus", + GatewayPath: "PUT:/sys/users/{id}/status", + Name: "jwt-auth", + VersionID: "a8e76b49f79b221da442a6ce3ad68ecb6684bfeed7787e167ac2afd08fda4154", + }, + { + ServiceMethod: "/api.v1.services.system.UserService/UpdateUserRoles", + GatewayPath: "PUT:/sys/users/{id}/roles", + Name: "jwt-auth", + VersionID: "847674c4c093178ee50e57e69164c091acdf398d9a4b16d0aa2b1e1550d8b7da", + }, + { + ServiceMethod: "/api.v1.services.system.UserService/ResetUserPassword", + GatewayPath: "POST:/sys/users/{id}/password/reset", + Name: "jwt-auth", + VersionID: "abb93618667b2661943887ee14d389e8bd7fbbd0adb95c6a032ebe4e8f1252f4", + }, + } + + security.RegisterPolicies(policies) +} diff --git a/api/v1/services/system/view.pb.go b/api/v1/services/system/view.pb.go index 666468de..14dd4fb3 100644 --- a/api/v1/services/system/view.pb.go +++ b/api/v1/services/system/view.pb.go @@ -7,6 +7,7 @@ package system import ( + _ "github.com/origadmin/contrib/api/gen/go/policy/v1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -591,7 +592,7 @@ var File_system_view_proto protoreflect.FileDescriptor const file_system_view_proto_rawDesc = "" + "\n" + - "\x11system/view.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\"\xe2\x01\n" + + "\x11system/view.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"\xe2\x01\n" + "\x10ListViewsRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + @@ -630,18 +631,28 @@ const file_system_view_proto_rawDesc = "" + "\x11DeleteViewRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + "\x12DeleteViewResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xfc\x04\n" + - "\vViewService\x12t\n" + - "\tListViews\x12(.api.v1.services.system.ListViewsRequest\x1a).api.v1.services.system.ListViewsResponse\"\x12\x82\xd3\xe4\x93\x02\f\x12\n" + - "/sys/views\x12s\n" + - "\aGetView\x12&.api.v1.services.system.GetViewRequest\x1a'.api.v1.services.system.GetViewResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/views/{id}\x12z\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xc6\x05\n" + + "\vViewService\x12\x82\x01\n" + + "\tListViews\x12(.api.v1.services.system.ListViewsRequest\x1a).api.v1.services.system.ListViewsResponse\" \xea\xea\x1b\n" + "\n" + - "CreateView\x12).api.v1.services.system.CreateViewRequest\x1a*.api.v1.services.system.CreateViewResponse\"\x15\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + - "/sys/views\x12\x87\x01\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\f\x12\n" + + "/sys/views\x12\x81\x01\n" + + "\aGetView\x12&.api.v1.services.system.GetViewRequest\x1a'.api.v1.services.system.GetViewResponse\"%\xea\xea\x1b\n" + "\n" + - "UpdateView\x12).api.v1.services.system.UpdateViewRequest\x1a*.api.v1.services.system.UpdateViewResponse\"\"\x82\xd3\xe4\x93\x02\x1c:\x04view\x1a\x14/sys/views/{view.id}\x12|\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x11\x12\x0f/sys/views/{id}\x12\x88\x01\n" + "\n" + - "DeleteView\x12).api.v1.services.system.DeleteViewRequest\x1a*.api.v1.services.system.DeleteViewResponse\"\x17\x82\xd3\xe4\x93\x02\x11*\x0f/sys/views/{id}B\xde\x01\n" + + "CreateView\x12).api.v1.services.system.CreateViewRequest\x1a*.api.v1.services.system.CreateViewResponse\"#\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + + "/sys/views\x12\x95\x01\n" + + "\n" + + "UpdateView\x12).api.v1.services.system.UpdateViewRequest\x1a*.api.v1.services.system.UpdateViewResponse\"0\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x1c:\x04view\x1a\x14/sys/views/{view.id}\x12\x8a\x01\n" + + "\n" + + "DeleteView\x12).api.v1.services.system.DeleteViewRequest\x1a*.api.v1.services.system.DeleteViewResponse\"%\xea\xea\x1b\n" + + "\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x11*\x0f/sys/views/{id}B\xde\x01\n" + "\x1acom.api.v1.services.systemB\tViewProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( diff --git a/api/v1/services/system/view.pb.security.go b/api/v1/services/system/view.pb.security.go new file mode 100644 index 00000000..393d7a73 --- /dev/null +++ b/api/v1/services/system/view.pb.security.go @@ -0,0 +1,45 @@ +// Code generated by protoc-gen-go-security. DO NOT EDIT. +// version: 1.0.8 + +package system + +import ( + security "github.com/origadmin/contrib/security" +) + +func init() { + policies := []security.Policy{ + { + ServiceMethod: "/api.v1.services.system.ViewService/ListViews", + GatewayPath: "GET:/sys/views", + Name: "jwt-auth", + VersionID: "cb5228a182b02217caefa9c4572e25ad9b2d3431fcb51d4047d85ee8a1db626d", + }, + { + ServiceMethod: "/api.v1.services.system.ViewService/GetView", + GatewayPath: "GET:/sys/views/{id}", + Name: "jwt-auth", + VersionID: "7be763290efdeec48dcf720d41317bbe8662eff4ba949b847e71a9858a29fe35", + }, + { + ServiceMethod: "/api.v1.services.system.ViewService/CreateView", + GatewayPath: "POST:/sys/views", + Name: "jwt-auth", + VersionID: "6a74b0bb52a02ebd0c706ac87916c3e1fd1d3285fd1e55646217ae74b852d9c2", + }, + { + ServiceMethod: "/api.v1.services.system.ViewService/UpdateView", + GatewayPath: "PUT:/sys/views/{view.id}", + Name: "jwt-auth", + VersionID: "59aa07527952ca86a392ac92d860a0f2d0e3e89027827062f987710259dcadb3", + }, + { + ServiceMethod: "/api.v1.services.system.ViewService/DeleteView", + GatewayPath: "DELETE:/sys/views/{id}", + Name: "jwt-auth", + VersionID: "9098bf1e5d12172b3e7fc2eaa8b1c893db2f7cb3f373b6fea737512dfb804fab", + }, + } + + security.RegisterPolicies(policies) +} diff --git a/buf.gen.yaml b/buf.gen.yaml index 5420344f..386cab23 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -48,7 +48,9 @@ plugins: - local: protoc-gen-grpc-gateway out: api/v1/services opt: paths=source_relative - + - local: protoc-gen-go-security + out: api/v1/services + opt: paths=source_relative # - local: protoc-gen-ent # out: database diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go index ac148638..321c5212 100644 --- a/internal/helpers/providers/providers.go +++ b/internal/helpers/providers/providers.go @@ -22,6 +22,8 @@ import ( "github.com/origadmin/toolkits/crypto/hash" "github.com/origadmin/toolkits/crypto/hash/algorithms/bcrypt" "github.com/origadmin/toolkits/crypto/hash/types" + _ "origadmin/application/admin/api/v1/services/auth" + _ "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/internal/conf" confpb "origadmin/application/admin/internal/conf/pb" "origadmin/application/admin/internal/data" @@ -29,7 +31,17 @@ import ( "origadmin/application/admin/internal/helpers/captcha" ) -var factory = secmiddleware.NewFactory() +var ( + factory = secmiddleware.NewFactory() + policies = map[string]security.Policy{} +) + +func init() { + ps := security.RegisteredPolicies() + for _, p := range ps { + policies[p.ServiceMethod] = p + } +} // ProvideAuthenticatorOptions creates the JWT options from the application configuration. func ProvideAuthenticatorOptions(c *conf.Config) (*jwt.Options, error) { @@ -210,6 +222,9 @@ func ProvideSkipChecker(app *runtime.App, cfg *conf.Config) security.SkipChecker return func(ctx context.Context, req security.Request) bool { helper.Infow("kind", req.Kind(), "operation", req.GetOperation(), "method", req.GetMethod(), "path", req.GetRouteTemplate()) + if v, ok := policies[req.GetOperation()]; ok && v.Name == "public" { + return true + } return false } } From d9f345bb5aedf816b68c5ff8468dea2defefd4d0 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 1 Jan 2026 03:06:03 +0800 Subject: [PATCH 138/158] feat(gateway): refactor client middleware injection and enhance skip checker logging --- cmd/gateway/wire_gen.go | 10 +++++++--- internal/features/auth/service/auth.go | 13 ++++++++----- internal/gateway/client/client.go | 15 ++++++--------- internal/helpers/captcha/captcha.go | 8 ++++---- internal/helpers/providers/providers.go | 25 ++++++++++++++++++++----- resources/configs/clients.yaml | 4 ++++ 6 files changed, 49 insertions(+), 26 deletions(-) diff --git a/cmd/gateway/wire_gen.go b/cmd/gateway/wire_gen.go index 2a55cec4..2d37add4 100644 --- a/cmd/gateway/wire_gen.go +++ b/cmd/gateway/wire_gen.go @@ -29,11 +29,15 @@ import ( func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), error) { confpbBootstrap := &bootstrap.Bootstrap servers := confpbBootstrap.Servers - authBridgeSet, err := client.NewAuthBridgeSet(app, bootstrap) + clientMiddlewareProvider, err := providers.ProvideClientMiddlewares(app) if err != nil { return nil, nil, err } - systemBridgeSet, err := client.NewSystemBridgeSet(app, bootstrap) + authBridgeSet, err := client.NewAuthBridgeSet(app, bootstrap, clientMiddlewareProvider) + if err != nil { + return nil, nil, err + } + systemBridgeSet, err := client.NewSystemBridgeSet(app, bootstrap, clientMiddlewareProvider) if err != nil { return nil, nil, err } @@ -45,7 +49,7 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err if err != nil { return nil, nil, err } - skipChecker := providers.ProvideSkipChecker(app, bootstrap) + skipChecker := providers.ProvideGatewaySkipChecker(app, bootstrap) serverMiddlewareProvider, err := providers.ProvideGatewayMiddlewares(app, authenticator, skipChecker) if err != nil { return nil, nil, err diff --git a/internal/features/auth/service/auth.go b/internal/features/auth/service/auth.go index f27ab4b7..8c70c066 100644 --- a/internal/features/auth/service/auth.go +++ b/internal/features/auth/service/auth.go @@ -5,10 +5,12 @@ import ( "fmt" "github.com/go-kratos/kratos/v2/errors" - v1 "origadmin/application/admin/api/v1/services/auth" + securityv1 "github.com/origadmin/contrib/api/gen/go/security/v1" "github.com/origadmin/contrib/security/credential" securityPrincipal "github.com/origadmin/contrib/security/principal" + "github.com/origadmin/runtime/log" + v1 "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/features/auth/biz" "origadmin/application/admin/internal/helpers/captcha" ) @@ -16,9 +18,9 @@ import ( // AuthService is a service for authentication. type AuthService struct { v1.UnimplementedAuthServiceServer - uc *biz.AuthUseCase - captcha *captcha.Captcha - creator credential.Creator + uc *biz.AuthUseCase + captcha *captcha.Captcha + creator credential.Creator } // NewAuthService creates a new authentication service. @@ -62,10 +64,11 @@ func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.Logi // GetCaptcha generates a new captcha. func (s *AuthService) GetCaptcha(ctx context.Context, req *v1.GetCaptchaRequest) (*v1.GetCaptchaResponse, error) { - _, id, b64s, err := s.captcha.GenerateDigit() + id, b64s, answer, err := s.captcha.GenerateDigit() if err != nil { return nil, err } + log.Infof("Captcha generated: id=%s, answer=%s", id, answer) return &v1.GetCaptchaResponse{ CaptchaId: id, CaptchaImage: b64s, diff --git a/internal/gateway/client/client.go b/internal/gateway/client/client.go index a799a3fd..9e23ad11 100644 --- a/internal/gateway/client/client.go +++ b/internal/gateway/client/client.go @@ -12,6 +12,7 @@ import ( "github.com/origadmin/runtime" transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" + "github.com/origadmin/runtime/container" runtimegrpc "github.com/origadmin/runtime/service/transport/grpc" "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/api/v1/services/system" @@ -50,7 +51,7 @@ type SystemBridgeSet struct { // and establishes a gRPC connection. // // The provided context is used for the client lifecycle. -func NewGRPCConn(app *runtime.App, bootstrap *conf.Config, name string) (*grpc.ClientConn, error) { +func NewGRPCConn(app *runtime.App, bootstrap *conf.Config, name string, middlewareProvider container.ClientMiddlewareProvider) (*grpc.ClientConn, error) { var clientConfig *transportv1.Client // The conventional name for gRPC clients @@ -84,10 +85,6 @@ func NewGRPCConn(app *runtime.App, bootstrap *conf.Config, name string) (*grpc.C if err != nil { return nil, err } - middlewareProvider, err := app.MiddlewareProvider() - if err != nil { - return nil, err - } middlewares, err := middlewareProvider.ClientMiddlewares() if err != nil { return nil, err @@ -100,10 +97,10 @@ func NewGRPCConn(app *runtime.App, bootstrap *conf.Config, name string) (*grpc.C } // NewAuthBridgeSet creates a set of clients for the auth service. -func NewAuthBridgeSet(app *runtime.App, bootstrap *conf.Config) (*AuthBridgeSet, error) { +func NewAuthBridgeSet(app *runtime.App, bootstrap *conf.Config, middlewareProvider container.ClientMiddlewareProvider) (*AuthBridgeSet, error) { // Use the application's root context. This ensures that the client's lifecycle // is tied to the application's lifecycle. - conn, err := NewGRPCConn(app, bootstrap, ServiceNameAuth) + conn, err := NewGRPCConn(app, bootstrap, ServiceNameAuth, middlewareProvider) if err != nil { return nil, err } @@ -114,9 +111,9 @@ func NewAuthBridgeSet(app *runtime.App, bootstrap *conf.Config) (*AuthBridgeSet, } // NewSystemBridgeSet creates a set of clients for the system service. -func NewSystemBridgeSet(app *runtime.App, bootstrap *conf.Config) (*SystemBridgeSet, error) { +func NewSystemBridgeSet(app *runtime.App, bootstrap *conf.Config, middlewareProvider container.ClientMiddlewareProvider) (*SystemBridgeSet, error) { // Use the application's root context. - conn, err := NewGRPCConn(app, bootstrap, ServiceNameSystem) + conn, err := NewGRPCConn(app, bootstrap, ServiceNameSystem, middlewareProvider) if err != nil { return nil, err } diff --git a/internal/helpers/captcha/captcha.go b/internal/helpers/captcha/captcha.go index 7a239618..337ab267 100644 --- a/internal/helpers/captcha/captcha.go +++ b/internal/helpers/captcha/captcha.go @@ -81,19 +81,19 @@ func NewCaptcha(config *Config) *Captcha { } } -func (c *Captcha) GenerateDigit() (string, string, string, error) { +func (c *Captcha) GenerateDigit() (id, b64s, answer string, err error) { return c.DriverDigit.Generate() } -func (c *Captcha) GenerateString() (string, string, string, error) { +func (c *Captcha) GenerateString() (id, b64s, answer string, err error) { return c.DriverString.Generate() } -func (c *Captcha) GenerateAudio() (string, string, string, error) { +func (c *Captcha) GenerateAudio() (id, b64s, answer string, err error) { return c.DriverAudio.Generate() } -func (c *Captcha) GenerateChinese() (string, string, string, error) { +func (c *Captcha) GenerateChinese() (id, b64s, answer string, err error) { return c.DriverChinese.Generate() } diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go index 321c5212..4a502cd8 100644 --- a/internal/helpers/providers/providers.go +++ b/internal/helpers/providers/providers.go @@ -217,12 +217,27 @@ func ProvideClientMiddlewares(app *runtime.App) (container.ClientMiddlewareProvi return provider, nil } +func ProvideGatewaySkipChecker(app *runtime.App, cfg *conf.Config) security.SkipChecker { + return func(ctx context.Context, req security.Request) bool { + helper := log.NewHelper(log.With(app.Logger(), "kind", req.Kind(), "operation", req.GetOperation(), "method", req.GetMethod(), "path", + req.GetRouteTemplate())) + + if v, ok := policies[req.GetOperation()]; ok && (v.Name == "public") { + helper.Infof("skip checker: %s", v.Name) + return true + } + helper.Infof("unskipped request: %s", req.GetOperation()) + return false + } +} + func ProvideSkipChecker(app *runtime.App, cfg *conf.Config) security.SkipChecker { - helper := log.NewHelper(log.With(app.Logger(), "module", "security.skip")) + //helper := log.NewHelper(log.With(app.Logger(), "module", "security.skip")) return func(ctx context.Context, req security.Request) bool { - helper.Infow("kind", req.Kind(), "operation", req.GetOperation(), "method", req.GetMethod(), "path", - req.GetRouteTemplate()) - if v, ok := policies[req.GetOperation()]; ok && v.Name == "public" { + helper := log.NewHelper(log.With(app.Logger(), "kind", req.Kind(), "operation", req.GetOperation(), "method", req.GetMethod(), "path", + req.GetRouteTemplate())) + if v, ok := policies[req.GetOperation()]; ok && (v.Name == "jwt-auth" || v.Name == "public") { + helper.Infof("skip checker: %s", v.Name) return true } return false @@ -232,7 +247,7 @@ func ProvideSkipChecker(app *runtime.App, cfg *conf.Config) security.SkipChecker var ProviderGatewaySet = wire.NewSet( ProvideClientMiddlewares, ProvideGatewayMiddlewares, - ProvideSkipChecker, + ProvideGatewaySkipChecker, ) var ProviderBackendSet = wire.NewSet( diff --git a/resources/configs/clients.yaml b/resources/configs/clients.yaml index c5a80e04..497c5276 100644 --- a/resources/configs/clients.yaml +++ b/resources/configs/clients.yaml @@ -5,8 +5,12 @@ clients: endpoint: "discovery:///origadmin.service.auth" timeout: 5s discovery_name: "default_consul" + middlewares: + - "propagation" - name: "origadmin.service.system.client.grpc" grpc: endpoint: "discovery:///origadmin.service.system" timeout: 5s discovery_name: "default_consul" + middlewares: + - "propagation" From cb7247c85db468ac8630ad6b492c94e228a5a27b Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 1 Jan 2026 05:47:27 +0800 Subject: [PATCH 139/158] feat(proto): add status field to Permission proto and update field indices --- api/v1/proto/types/system.proto | 20 ++++--- api/v1/services/types/system.pb.go | 36 +++++++----- api/v1/services/types/system.pb.validate.go | 2 + internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 43 +++++++------- internal/data/entity/ent/mutation.go | 56 ++++++++++++++++++- internal/data/entity/ent/mutation_fields.go | 8 +++ internal/data/entity/ent/permission.go | 13 ++++- .../data/entity/ent/permission/permission.go | 34 +++++++++++ internal/data/entity/ent/permission/where.go | 20 +++++++ internal/data/entity/ent/permission_create.go | 30 ++++++++++ internal/data/entity/ent/permission_query.go | 2 + internal/data/entity/ent/permission_update.go | 44 +++++++++++++++ internal/data/entity/ent/resource.go | 20 +++---- internal/data/entity/ent/schema/permission.go | 4 ++ internal/data/entity/ent/schema/resource.go | 20 +++---- internal/data/entity/ent/schema/view.go | 22 ++++---- internal/data/entity/ent/view.go | 22 ++++---- resources/api-docs/openapi/openapi.yaml | 4 ++ 19 files changed, 314 insertions(+), 88 deletions(-) diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index 44cb1b0a..edc4e698 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -166,10 +166,10 @@ message User { google.protobuf.Timestamp last_login_time = 19 [json_name = "last_login_time"]; // user.field.sanction_date optional google.protobuf.Timestamp sanction_date = 20 [json_name = "sanction_date"]; -// // user.field.manager_id -// int64 manager_id = 21 [json_name = "manager_id"]; -// // user.field.manager -// string manager = 22 [json_name = "manager"]; + // // user.field.manager_id + // int64 manager_id = 21 [json_name = "manager_id"]; + // // user.field.manager + // string manager = 22 [json_name = "manager"]; // Roles holds the value of the roles edge. repeated Role roles = 23 [json_name = "roles"]; // Role Ids holds the value of the role_ids @@ -407,16 +407,18 @@ message Permission { string name = 4 [json_name = "name"]; // permission.field.keyword string keyword = 5 [json_name = "keyword"]; + // permission.field.status + int32 status = 6 [json_name = "status"]; // permission.field.description - string description = 6 [json_name = "description"]; + string description = 7 [json_name = "description"]; // permission.field.data_scope - string data_scope = 7 [json_name = "data_scope"]; + string data_scope = 8 [json_name = "data_scope"]; // permission.field.data_rules - map data_rules = 8 [json_name = "data_rules"]; + map data_rules = 9 [json_name = "data_rules"]; // permission.field.resource_ids - repeated int64 resource_ids = 9 [json_name = "resource_ids"]; + repeated int64 resource_ids = 10 [json_name = "resource_ids"]; // permission.field.resources - repeated Resource resources = 10 [json_name = "resources"]; + repeated Resource resources = 11 [json_name = "resources"]; } // PermissionEdges holds the relations/edges for other nodes in the graph. diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index 9c06de71..f3130cfc 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -2072,16 +2072,18 @@ type Permission struct { Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` // permission.field.keyword Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` + // permission.field.status + Status int32 `protobuf:"varint,6,opt,name=status,proto3" json:"status,omitempty"` // permission.field.description - Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` // permission.field.data_scope - DataScope string `protobuf:"bytes,7,opt,name=data_scope,proto3" json:"data_scope,omitempty"` + DataScope string `protobuf:"bytes,8,opt,name=data_scope,proto3" json:"data_scope,omitempty"` // permission.field.data_rules - DataRules map[string]string `protobuf:"bytes,8,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + DataRules map[string]string `protobuf:"bytes,9,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // permission.field.resource_ids - ResourceIds []int64 `protobuf:"varint,9,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` + ResourceIds []int64 `protobuf:"varint,10,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` // permission.field.resources - Resources []*Resource `protobuf:"bytes,10,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*Resource `protobuf:"bytes,11,rep,name=resources,proto3" json:"resources,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -2151,6 +2153,13 @@ func (x *Permission) GetKeyword() string { return "" } +func (x *Permission) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + func (x *Permission) GetDescription() string { if x != nil { return x.Description @@ -2967,24 +2976,25 @@ const file_types_system_proto_rawDesc = "" + "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12C\n" + "\vpermissions\x18\x03 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12K\n" + "\x0euser_positions\x18\x04 \x03(\v2#.api.v1.services.types.UserPositionR\x0euser_positions\x12]\n" + - "\x14position_permissions\x18\x05 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"\xfb\x03\n" + + "\x14position_permissions\x18\x05 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"\x93\x04\n" + "\n" + "Permission\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + - "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x1e\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x16\n" + + "\x06status\x18\x06 \x01(\x05R\x06status\x12 \n" + + "\vdescription\x18\a \x01(\tR\vdescription\x12\x1e\n" + "\n" + - "data_scope\x18\a \x01(\tR\n" + + "data_scope\x18\b \x01(\tR\n" + "data_scope\x12P\n" + "\n" + - "data_rules\x18\b \x03(\v20.api.v1.services.types.Permission.DataRulesEntryR\n" + + "data_rules\x18\t \x03(\v20.api.v1.services.types.Permission.DataRulesEntryR\n" + "data_rules\x12\"\n" + - "\fresource_ids\x18\t \x03(\x03R\fresource_ids\x12=\n" + - "\tresources\x18\n" + - " \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x1a<\n" + + "\fresource_ids\x18\n" + + " \x03(\x03R\fresource_ids\x12=\n" + + "\tresources\x18\v \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x1a<\n" + "\x0eDataRulesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xd3\x03\n" + diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index 9a2e1170..208db57d 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -4107,6 +4107,8 @@ func (m *Permission) validate(all bool) error { // no validation rules for Keyword + // no validation rules for Status + // no validation rules for Description // no validation rules for DataScope diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index b2ffc194..cddeb23b 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"resource.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"view.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"permission.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status.comment\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index 1eed1115..2c26dc4c 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -138,6 +138,7 @@ var ( {Name: "description", Type: field.TypeString, Size: 1024, Comment: "entity.permission.field.description", Default: ""}, {Name: "data_scope", Type: field.TypeString, Comment: "entity.permission.field.data_scope", Default: "self"}, {Name: "data_rules", Type: field.TypeJSON, Nullable: true, Comment: "entity.permission.field.data_rules"}, + {Name: "status", Type: field.TypeEnum, Comment: "entity.permission.field.status.comment", Enums: []string{"enabled", "disabled"}, Default: "enabled"}, {Name: "actions", Type: field.TypeEnum, Comment: "entity.permission.field.actions", Enums: []string{"read", "write", "delete", "manage"}, Default: "read"}, } // SysPermissionsTable holds the schema information for the "sys_permissions" table. @@ -269,16 +270,16 @@ var ( {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "service_name", Type: field.TypeString, Comment: "resource.service_name.comment"}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "resource.keyword.comment"}, - {Name: "path", Type: field.TypeString, Nullable: true, Comment: "resource.path.comment"}, - {Name: "method", Type: field.TypeString, Nullable: true, Comment: "resource.method.comment"}, - {Name: "operation", Type: field.TypeString, Nullable: true, Comment: "resource.operation.comment"}, - {Name: "policy", Type: field.TypeString, Comment: "resource.policy.comment", Default: ""}, - {Name: "version_id", Type: field.TypeString, Comment: "resource.version_id.comment", Default: ""}, - {Name: "last_sync_version_id", Type: field.TypeString, Comment: "resource.last_sync_version_id.comment", Default: ""}, - {Name: "sync_status", Type: field.TypeString, Comment: "resource.sync_status.comment", Default: "Synced"}, - {Name: "status", Type: field.TypeEnum, Comment: "resource.status.comment", Enums: []string{"enabled", "disabled"}, Default: "enabled"}, + {Name: "service_name", Type: field.TypeString, Comment: "entity.resource.field.service_name.comment"}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.resource.field.keyword.comment"}, + {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.path.comment"}, + {Name: "method", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.method.comment"}, + {Name: "operation", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.operation.comment"}, + {Name: "policy", Type: field.TypeString, Comment: "entity.resource.field.policy.comment", Default: ""}, + {Name: "version_id", Type: field.TypeString, Comment: "entity.resource.field.version_id.comment", Default: ""}, + {Name: "last_sync_version_id", Type: field.TypeString, Comment: "entity.resource.field.last_sync_version_id.comment", Default: ""}, + {Name: "sync_status", Type: field.TypeString, Comment: "entity.resource.field.sync_status.comment", Default: "Synced"}, + {Name: "status", Type: field.TypeEnum, Comment: "entity.resource.field.status.comment", Enums: []string{"enabled", "disabled"}, Default: "enabled"}, } // SysResourcesTable holds the schema information for the "sys_resources" table. SysResourcesTable = &schema.Table{ @@ -569,17 +570,17 @@ var ( {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "view.keyword.comment"}, - {Name: "scope", Type: field.TypeString, Comment: "view.scope.comment", Default: "default"}, - {Name: "name", Type: field.TypeString, Comment: "view.name.comment"}, - {Name: "type", Type: field.TypeEnum, Comment: "view.type.comment", Enums: []string{"T", "G", "M", "L", "P", "B", "E", "R", "U"}, Default: "U"}, - {Name: "component", Type: field.TypeString, Nullable: true, Comment: "view.component.comment"}, - {Name: "path", Type: field.TypeString, Nullable: true, Comment: "view.path.comment"}, - {Name: "icon", Type: field.TypeString, Nullable: true, Comment: "view.icon.comment"}, - {Name: "visible", Type: field.TypeBool, Comment: "view.visible.comment", Default: true}, - {Name: "sequence", Type: field.TypeInt, Comment: "view.sequence.comment", Default: 0}, - {Name: "tree_path", Type: field.TypeString, Nullable: true, Comment: "view.tree_path.comment"}, - {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "view.parent_id.comment"}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.view.field.keyword.comment"}, + {Name: "scope", Type: field.TypeString, Comment: "entity.view.field.scope.comment", Default: "default"}, + {Name: "name", Type: field.TypeString, Comment: "entity.view.field.name.comment"}, + {Name: "type", Type: field.TypeEnum, Comment: "entity.view.field.type.comment", Enums: []string{"T", "G", "M", "L", "P", "B", "E", "R", "U"}, Default: "U"}, + {Name: "component", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.component.comment"}, + {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.path.comment"}, + {Name: "icon", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.icon.comment"}, + {Name: "visible", Type: field.TypeBool, Comment: "entity.view.field.visible.comment", Default: true}, + {Name: "sequence", Type: field.TypeInt, Comment: "entity.view.field.sequence.comment", Default: 0}, + {Name: "tree_path", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.tree_path.comment"}, + {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "entity.view.field.parent_id.comment"}, } // SysViewsTable holds the schema information for the "sys_views" table. SysViewsTable = &schema.Table{ diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index 1f92931d..85494df9 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -2941,6 +2941,7 @@ type PermissionMutation struct { description *string data_scope *string data_rules *map[string]string + status *permission.Status actions *permission.Actions clearedFields map[string]struct{} roles map[int64]struct{} @@ -3341,6 +3342,42 @@ func (m *PermissionMutation) ResetDataRules() { delete(m.clearedFields, permission.FieldDataRules) } +// SetStatus sets the "status" field. +func (m *PermissionMutation) SetStatus(pe permission.Status) { + m.status = &pe +} + +// Status returns the value of the "status" field in the mutation. +func (m *PermissionMutation) Status() (r permission.Status, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the Permission entity. +// If the Permission object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PermissionMutation) OldStatus(ctx context.Context) (v permission.Status, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// ResetStatus resets all changes to the "status" field. +func (m *PermissionMutation) ResetStatus() { + m.status = nil +} + // SetActions sets the "actions" field. func (m *PermissionMutation) SetActions(pe permission.Actions) { m.actions = &pe @@ -3843,7 +3880,7 @@ func (m *PermissionMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *PermissionMutation) Fields() []string { - fields := make([]string, 0, 8) + fields := make([]string, 0, 9) if m.create_time != nil { fields = append(fields, permission.FieldCreateTime) } @@ -3865,6 +3902,9 @@ func (m *PermissionMutation) Fields() []string { if m.data_rules != nil { fields = append(fields, permission.FieldDataRules) } + if m.status != nil { + fields = append(fields, permission.FieldStatus) + } if m.actions != nil { fields = append(fields, permission.FieldActions) } @@ -3890,6 +3930,8 @@ func (m *PermissionMutation) Field(name string) (ent.Value, bool) { return m.DataScope() case permission.FieldDataRules: return m.DataRules() + case permission.FieldStatus: + return m.Status() case permission.FieldActions: return m.Actions() } @@ -3915,6 +3957,8 @@ func (m *PermissionMutation) OldField(ctx context.Context, name string) (ent.Val return m.OldDataScope(ctx) case permission.FieldDataRules: return m.OldDataRules(ctx) + case permission.FieldStatus: + return m.OldStatus(ctx) case permission.FieldActions: return m.OldActions(ctx) } @@ -3975,6 +4019,13 @@ func (m *PermissionMutation) SetField(name string, value ent.Value) error { } m.SetDataRules(v) return nil + case permission.FieldStatus: + v, ok := value.(permission.Status) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil case permission.FieldActions: v, ok := value.(permission.Actions) if !ok { @@ -4061,6 +4112,9 @@ func (m *PermissionMutation) ResetField(name string) error { case permission.FieldDataRules: m.ResetDataRules() return nil + case permission.FieldStatus: + m.ResetStatus() + return nil case permission.FieldActions: m.ResetActions() return nil diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index f9e8574b..af6ce9c1 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -306,6 +306,8 @@ func (m *PermissionMutation) SetFields(input *Permission, fields ...string) erro m.SetDataScope(input.DataScope) case permission.FieldDataRules: m.SetDataRules(input.DataRules) + case permission.FieldStatus: + m.SetStatus(input.Status) case permission.FieldActions: m.SetActions(input.Actions) case permission.FieldID: @@ -355,6 +357,12 @@ func (m *PermissionMutation) SetFieldsSkipZero(input *Permission, fields ...stri if len(input.DataRules) > 0 { m.SetDataRules(input.DataRules) } + case permission.FieldStatus: + var zero permission.Status + // check permission.Status with sql.NullString if it is empty + if input.Status != zero { + m.SetStatus(input.Status) + } case permission.FieldActions: var zero permission.Actions // check permission.Actions with sql.NullString if it is empty diff --git a/internal/data/entity/ent/permission.go b/internal/data/entity/ent/permission.go index 86ccdd64..c670cca9 100644 --- a/internal/data/entity/ent/permission.go +++ b/internal/data/entity/ent/permission.go @@ -33,6 +33,8 @@ type Permission struct { DataScope string `json:"data_scope,omitempty"` // entity.permission.field.data_rules DataRules map[string]string `json:"data_rules,omitempty"` + // entity.permission.field.status.comment + Status permission.Status `json:"status,omitempty"` // entity.permission.field.actions Actions permission.Actions `json:"actions,omitempty"` // Edges holds the relations/edges for other nodes in the graph. @@ -145,7 +147,7 @@ func (*Permission) scanValues(columns []string) ([]any, error) { values[i] = new([]byte) case permission.FieldID: values[i] = new(sql.NullInt64) - case permission.FieldName, permission.FieldKeyword, permission.FieldDescription, permission.FieldDataScope, permission.FieldActions: + case permission.FieldName, permission.FieldKeyword, permission.FieldDescription, permission.FieldDataScope, permission.FieldStatus, permission.FieldActions: values[i] = new(sql.NullString) case permission.FieldCreateTime, permission.FieldUpdateTime: values[i] = new(sql.NullTime) @@ -214,6 +216,12 @@ func (_m *Permission) assignValues(columns []string, values []any) error { return fmt.Errorf("unmarshal field data_rules: %w", err) } } + case permission.FieldStatus: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = permission.Status(value.String) + } case permission.FieldActions: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field actions", values[i]) @@ -317,6 +325,9 @@ func (_m *Permission) String() string { builder.WriteString("data_rules=") builder.WriteString(fmt.Sprintf("%v", _m.DataRules)) builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") builder.WriteString("actions=") builder.WriteString(fmt.Sprintf("%v", _m.Actions)) builder.WriteByte(')') diff --git a/internal/data/entity/ent/permission/permission.go b/internal/data/entity/ent/permission/permission.go index ad67646c..903ee53c 100644 --- a/internal/data/entity/ent/permission/permission.go +++ b/internal/data/entity/ent/permission/permission.go @@ -29,6 +29,8 @@ const ( FieldDataScope = "data_scope" // FieldDataRules holds the string denoting the data_rules field in the database. FieldDataRules = "data_rules" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" // FieldActions holds the string denoting the actions field in the database. FieldActions = "actions" // EdgeRoles holds the string denoting the roles edge name in mutations. @@ -109,6 +111,7 @@ var Columns = []string{ FieldDescription, FieldDataScope, FieldDataRules, + FieldStatus, FieldActions, } @@ -162,6 +165,32 @@ var ( IDValidator func(int64) error ) +// Status defines the type for the "status" enum field. +type Status string + +// StatusEnabled is the default value of the Status enum. +const DefaultStatus = StatusEnabled + +// Status values. +const ( + StatusEnabled Status = "enabled" + StatusDisabled Status = "disabled" +) + +func (s Status) String() string { + return string(s) +} + +// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. +func StatusValidator(s Status) error { + switch s { + case StatusEnabled, StatusDisabled: + return nil + default: + return fmt.Errorf("permission: invalid enum value for status field: %q", s) + } +} + // Actions defines the type for the "actions" enum field. type Actions string @@ -228,6 +257,11 @@ func ByDataScope(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDataScope, opts...).ToFunc() } +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + // ByActions orders the results by the actions field. func ByActions(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldActions, opts...).ToFunc() diff --git a/internal/data/entity/ent/permission/where.go b/internal/data/entity/ent/permission/where.go index aed383e5..4a97f59f 100644 --- a/internal/data/entity/ent/permission/where.go +++ b/internal/data/entity/ent/permission/where.go @@ -435,6 +435,26 @@ func DataRulesNotNil() predicate.Permission { return predicate.Permission(sql.FieldNotNull(FieldDataRules)) } +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v Status) predicate.Permission { + return predicate.Permission(sql.FieldEQ(FieldStatus, v)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v Status) predicate.Permission { + return predicate.Permission(sql.FieldNEQ(FieldStatus, v)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...Status) predicate.Permission { + return predicate.Permission(sql.FieldIn(FieldStatus, vs...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...Status) predicate.Permission { + return predicate.Permission(sql.FieldNotIn(FieldStatus, vs...)) +} + // ActionsEQ applies the EQ predicate on the "actions" field. func ActionsEQ(v Actions) predicate.Permission { return predicate.Permission(sql.FieldEQ(FieldActions, v)) diff --git a/internal/data/entity/ent/permission_create.go b/internal/data/entity/ent/permission_create.go index f4ee265f..d4c5666e 100644 --- a/internal/data/entity/ent/permission_create.go +++ b/internal/data/entity/ent/permission_create.go @@ -110,6 +110,20 @@ func (_c *PermissionCreate) SetDataRules(v map[string]string) *PermissionCreate return _c } +// SetStatus sets the "status" field. +func (_c *PermissionCreate) SetStatus(v permission.Status) *PermissionCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *PermissionCreate) SetNillableStatus(v *permission.Status) *PermissionCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + // SetActions sets the "actions" field. func (_c *PermissionCreate) SetActions(v permission.Actions) *PermissionCreate { _c.mutation.SetActions(v) @@ -313,6 +327,10 @@ func (_c *PermissionCreate) defaults() { v := permission.DefaultDataScope _c.mutation.SetDataScope(v) } + if _, ok := _c.mutation.Status(); !ok { + v := permission.DefaultStatus + _c.mutation.SetStatus(v) + } if _, ok := _c.mutation.Actions(); !ok { v := permission.DefaultActions _c.mutation.SetActions(v) @@ -358,6 +376,14 @@ func (_c *PermissionCreate) check() error { if _, ok := _c.mutation.DataScope(); !ok { return &ValidationError{Name: "data_scope", err: errors.New(`ent: missing required field "Permission.data_scope"`)} } + if _, ok := _c.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Permission.status"`)} + } + if v, ok := _c.mutation.Status(); ok { + if err := permission.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Permission.status": %w`, err)} + } + } if _, ok := _c.mutation.Actions(); !ok { return &ValidationError{Name: "actions", err: errors.New(`ent: missing required field "Permission.actions"`)} } @@ -431,6 +457,10 @@ func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { _spec.SetField(permission.FieldDataRules, field.TypeJSON, value) _node.DataRules = value } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(permission.FieldStatus, field.TypeEnum, value) + _node.Status = value + } if value, ok := _c.mutation.Actions(); ok { _spec.SetField(permission.FieldActions, field.TypeEnum, value) _node.Actions = value diff --git a/internal/data/entity/ent/permission_query.go b/internal/data/entity/ent/permission_query.go index 98bc1802..26787d3f 100644 --- a/internal/data/entity/ent/permission_query.go +++ b/internal/data/entity/ent/permission_query.go @@ -1217,6 +1217,7 @@ func (_q *PermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *Permissio // Description string `json:"description,omitempty"` // DataScope string `json:"data_scope,omitempty"` // DataRules map[string]string `json:"data_rules,omitempty"` +// Status permission.Status `json:"status,omitempty"` // Actions permission.Actions `json:"actions,omitempty"` // } // @@ -1229,6 +1230,7 @@ func (_q *PermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *Permissio // permission.FieldDescription, // permission.FieldDataScope, // permission.FieldDataRules, +// permission.FieldStatus, // permission.FieldActions, // ). // Scan(ctx, &v) diff --git a/internal/data/entity/ent/permission_update.go b/internal/data/entity/ent/permission_update.go index b072b659..e16b5125 100644 --- a/internal/data/entity/ent/permission_update.go +++ b/internal/data/entity/ent/permission_update.go @@ -111,6 +111,20 @@ func (_u *PermissionUpdate) ClearDataRules() *PermissionUpdate { return _u } +// SetStatus sets the "status" field. +func (_u *PermissionUpdate) SetStatus(v permission.Status) *PermissionUpdate { + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PermissionUpdate) SetNillableStatus(v *permission.Status) *PermissionUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + // SetActions sets the "actions" field. func (_u *PermissionUpdate) SetActions(v permission.Actions) *PermissionUpdate { _u.mutation.SetActions(v) @@ -471,6 +485,11 @@ func (_u *PermissionUpdate) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} } } + if v, ok := _u.mutation.Status(); ok { + if err := permission.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Permission.status": %w`, err)} + } + } if v, ok := _u.mutation.Actions(); ok { if err := permission.ActionsValidator(v); err != nil { return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} @@ -518,6 +537,9 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) if _u.mutation.DataRulesCleared() { _spec.ClearField(permission.FieldDataRules, field.TypeJSON) } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(permission.FieldStatus, field.TypeEnum, value) + } if value, ok := _u.mutation.Actions(); ok { _spec.SetField(permission.FieldActions, field.TypeEnum, value) } @@ -998,6 +1020,20 @@ func (_u *PermissionUpdateOne) ClearDataRules() *PermissionUpdateOne { return _u } +// SetStatus sets the "status" field. +func (_u *PermissionUpdateOne) SetStatus(v permission.Status) *PermissionUpdateOne { + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *PermissionUpdateOne) SetNillableStatus(v *permission.Status) *PermissionUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + // SetActions sets the "actions" field. func (_u *PermissionUpdateOne) SetActions(v permission.Actions) *PermissionUpdateOne { _u.mutation.SetActions(v) @@ -1371,6 +1407,11 @@ func (_u *PermissionUpdateOne) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} } } + if v, ok := _u.mutation.Status(); ok { + if err := permission.StatusValidator(v); err != nil { + return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Permission.status": %w`, err)} + } + } if v, ok := _u.mutation.Actions(); ok { if err := permission.ActionsValidator(v); err != nil { return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} @@ -1435,6 +1476,9 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, if _u.mutation.DataRulesCleared() { _spec.ClearField(permission.FieldDataRules, field.TypeJSON) } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(permission.FieldStatus, field.TypeEnum, value) + } if value, ok := _u.mutation.Actions(); ok { _spec.SetField(permission.FieldActions, field.TypeEnum, value) } diff --git a/internal/data/entity/ent/resource.go b/internal/data/entity/ent/resource.go index 9455c796..7739c995 100644 --- a/internal/data/entity/ent/resource.go +++ b/internal/data/entity/ent/resource.go @@ -22,25 +22,25 @@ type Resource struct { CreateTime time.Time `json:"create_time,omitempty"` // update_time.field.comment UpdateTime time.Time `json:"update_time,omitempty"` - // resource.service_name.comment + // entity.resource.field.service_name.comment ServiceName string `json:"service_name,omitempty"` - // resource.keyword.comment + // entity.resource.field.keyword.comment Keyword string `json:"keyword,omitempty"` - // resource.path.comment + // entity.resource.field.path.comment Path string `json:"path,omitempty"` - // resource.method.comment + // entity.resource.field.method.comment Method string `json:"method,omitempty"` - // resource.operation.comment + // entity.resource.field.operation.comment Operation string `json:"operation,omitempty"` - // resource.policy.comment + // entity.resource.field.policy.comment Policy string `json:"policy,omitempty"` - // resource.version_id.comment + // entity.resource.field.version_id.comment VersionID string `json:"version_id,omitempty"` - // resource.last_sync_version_id.comment + // entity.resource.field.last_sync_version_id.comment LastSyncVersionID string `json:"last_sync_version_id,omitempty"` - // resource.sync_status.comment + // entity.resource.field.sync_status.comment SyncStatus string `json:"sync_status,omitempty"` - // resource.status.comment + // entity.resource.field.status.comment Status resource.Status `json:"status,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ResourceQuery when eager-loading is set. diff --git a/internal/data/entity/ent/schema/permission.go b/internal/data/entity/ent/schema/permission.go index eeb048b0..cae67037 100644 --- a/internal/data/entity/ent/schema/permission.go +++ b/internal/data/entity/ent/schema/permission.go @@ -50,6 +50,10 @@ func (Permission) Fields() []ent.Field { field.JSON("data_rules", map[string]string{}). Optional(). Comment(i18n.Text("entity.permission.field.data_rules")), + field.Enum("status"). + Comment(i18n.Text("entity.permission.field.status.comment")). + Values("enabled", "disabled"). + Default("enabled"), //field.JSON("conditions", []types.PermissionCondition{}). // Optional(). // Comment(i18n.Text("entity.permission.field.conditions")), diff --git a/internal/data/entity/ent/schema/resource.go b/internal/data/entity/ent/schema/resource.go index a72f5ee5..aa5bc924 100644 --- a/internal/data/entity/ent/schema/resource.go +++ b/internal/data/entity/ent/schema/resource.go @@ -19,35 +19,35 @@ type Resource struct { func (Resource) Fields() []ent.Field { return []ent.Field{ field.String("service_name"). - Comment(i18n.Text("resource.service_name.comment")), + Comment(i18n.Text("entity.resource.field.service_name.comment")), field.String("keyword"). MaxLen(255). - Comment(i18n.Text("resource.keyword.comment")). + Comment(i18n.Text("entity.resource.field.keyword.comment")). Unique(). NotEmpty(), field.String("path"). - Comment(i18n.Text("resource.path.comment")). + Comment(i18n.Text("entity.resource.field.path.comment")). Optional(), field.String("method"). - Comment(i18n.Text("resource.method.comment")). + Comment(i18n.Text("entity.resource.field.method.comment")). Optional(), field.String("operation"). - Comment(i18n.Text("resource.operation.comment")). + Comment(i18n.Text("entity.resource.field.operation.comment")). Optional(), field.String("policy"). - Comment(i18n.Text("resource.policy.comment")). + Comment(i18n.Text("entity.resource.field.policy.comment")). Default(""), field.String("version_id"). - Comment(i18n.Text("resource.version_id.comment")). + Comment(i18n.Text("entity.resource.field.version_id.comment")). Default(""), field.String("last_sync_version_id"). - Comment(i18n.Text("resource.last_sync_version_id.comment")). + Comment(i18n.Text("entity.resource.field.last_sync_version_id.comment")). Default(""), field.String("sync_status"). - Comment(i18n.Text("resource.sync_status.comment")). + Comment(i18n.Text("entity.resource.field.sync_status.comment")). Default("Synced"), field.Enum("status"). - Comment(i18n.Text("resource.status.comment")). + Comment(i18n.Text("entity.resource.field.status.comment")). Values("enabled", "disabled"). Default("enabled"), } diff --git a/internal/data/entity/ent/schema/view.go b/internal/data/entity/ent/schema/view.go index d2fee841..57d8f551 100644 --- a/internal/data/entity/ent/schema/view.go +++ b/internal/data/entity/ent/schema/view.go @@ -22,19 +22,19 @@ type View struct { func (View) Fields() []ent.Field { return []ent.Field{ // Use OptionalFK for an optional foreign key, as designed in the mixin package. - mixin.OptionalFK("parent_id", i18n.Text("view.parent_id.comment")), + mixin.OptionalFK("parent_id", i18n.Text("entity.view.field.parent_id.comment")), field.String("keyword"). MaxLen(255). - Comment(i18n.Text("view.keyword.comment")). + Comment(i18n.Text("entity.view.field.keyword.comment")). Unique(). NotEmpty(), field.String("scope"). - Comment(i18n.Text("view.scope.comment")). + Comment(i18n.Text("entity.view.field.scope.comment")). Default("default"), field.String("name"). - Comment(i18n.Text("view.name.comment")), + Comment(i18n.Text("entity.view.field.name.comment")), field.Enum("type"). - Comment(i18n.Text("view.type.comment")). + Comment(i18n.Text("entity.view.field.type.comment")). Values( string(enums.ViewTypeRoot), string(enums.ViewTypeGroup), @@ -48,22 +48,22 @@ func (View) Fields() []ent.Field { ). Default(string(enums.ViewTypeUnknown)), field.String("component"). - Comment(i18n.Text("view.component.comment")). + Comment(i18n.Text("entity.view.field.component.comment")). Optional(), field.String("path"). - Comment(i18n.Text("view.path.comment")). + Comment(i18n.Text("entity.view.field.path.comment")). Optional(), field.String("icon"). - Comment(i18n.Text("view.icon.comment")). + Comment(i18n.Text("entity.view.field.icon.comment")). Optional(), field.Bool("visible"). - Comment(i18n.Text("view.visible.comment")). + Comment(i18n.Text("entity.view.field.visible.comment")). Default(true), field.Int("sequence"). - Comment(i18n.Text("view.sequence.comment")). + Comment(i18n.Text("entity.view.field.sequence.comment")). Default(0), field.String("tree_path"). - Comment(i18n.Text("view.tree_path.comment")). + Comment(i18n.Text("entity.view.field.tree_path.comment")). Optional(), } } diff --git a/internal/data/entity/ent/view.go b/internal/data/entity/ent/view.go index 4db5f830..a4974c73 100644 --- a/internal/data/entity/ent/view.go +++ b/internal/data/entity/ent/view.go @@ -22,27 +22,27 @@ type View struct { CreateTime time.Time `json:"create_time,omitempty"` // update_time.field.comment UpdateTime time.Time `json:"update_time,omitempty"` - // view.parent_id.comment + // entity.view.field.parent_id.comment ParentID int64 `json:"parent_id,omitempty"` - // view.keyword.comment + // entity.view.field.keyword.comment Keyword string `json:"keyword,omitempty"` - // view.scope.comment + // entity.view.field.scope.comment Scope string `json:"scope,omitempty"` - // view.name.comment + // entity.view.field.name.comment Name string `json:"name,omitempty"` - // view.type.comment + // entity.view.field.type.comment Type view.Type `json:"type,omitempty"` - // view.component.comment + // entity.view.field.component.comment Component string `json:"component,omitempty"` - // view.path.comment + // entity.view.field.path.comment Path string `json:"path,omitempty"` - // view.icon.comment + // entity.view.field.icon.comment Icon string `json:"icon,omitempty"` - // view.visible.comment + // entity.view.field.visible.comment Visible bool `json:"visible,omitempty"` - // view.sequence.comment + // entity.view.field.sequence.comment Sequence int `json:"sequence,omitempty"` - // view.tree_path.comment + // entity.view.field.tree_path.comment TreePath string `json:"tree_path,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ViewQuery when eager-loading is set. diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index c45ef00c..8dfeabe9 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -3036,6 +3036,10 @@ components: keyword: type: string description: permission.field.keyword + status: + type: integer + description: permission.field.status + format: int32 description: type: string description: permission.field.description From ef3116e72a80418896765f342990a0bfb4e422c8 Mon Sep 17 00:00:00 2001 From: godcong Date: Sun, 4 Jan 2026 13:03:03 +0800 Subject: [PATCH 140/158] feat(webui): refactor avatar example and permission dialog components with improved form handling --- api/v1/proto/types/system.proto | 4 ++ api/v1/services/types/system.pb.go | 65 ++++++++++++++------- api/v1/services/types/system.pb.validate.go | 34 +++++++++++ resources/api-docs/openapi/openapi.yaml | 10 ++++ 4 files changed, 91 insertions(+), 22 deletions(-) diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index edc4e698..84753dd5 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -419,6 +419,10 @@ message Permission { repeated int64 resource_ids = 10 [json_name = "resource_ids"]; // permission.field.resources repeated Resource resources = 11 [json_name = "resources"]; + // permission.field.view_ids + repeated int64 view_ids = 12 [json_name = "view_ids"]; + // permission.field.views + repeated View views = 13 [json_name = "views"]; } // PermissionEdges holds the relations/edges for other nodes in the graph. diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index f3130cfc..b7fc5922 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -2083,7 +2083,11 @@ type Permission struct { // permission.field.resource_ids ResourceIds []int64 `protobuf:"varint,10,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` // permission.field.resources - Resources []*Resource `protobuf:"bytes,11,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*Resource `protobuf:"bytes,11,rep,name=resources,proto3" json:"resources,omitempty"` + // permission.field.view_ids + ViewIds []int64 `protobuf:"varint,12,rep,packed,name=view_ids,proto3" json:"view_ids,omitempty"` + // permission.field.views + Views []*View `protobuf:"bytes,13,rep,name=views,proto3" json:"views,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -2195,6 +2199,20 @@ func (x *Permission) GetResources() []*Resource { return nil } +func (x *Permission) GetViewIds() []int64 { + if x != nil { + return x.ViewIds + } + return nil +} + +func (x *Permission) GetViews() []*View { + if x != nil { + return x.Views + } + return nil +} + // PermissionEdges holds the relations/edges for other nodes in the graph. type PermissionEdges struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -2976,7 +2994,7 @@ const file_types_system_proto_rawDesc = "" + "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12C\n" + "\vpermissions\x18\x03 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12K\n" + "\x0euser_positions\x18\x04 \x03(\v2#.api.v1.services.types.UserPositionR\x0euser_positions\x12]\n" + - "\x14position_permissions\x18\x05 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"\x93\x04\n" + + "\x14position_permissions\x18\x05 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"\xe2\x04\n" + "\n" + "Permission\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + @@ -2994,7 +3012,9 @@ const file_types_system_proto_rawDesc = "" + "data_rules\x12\"\n" + "\fresource_ids\x18\n" + " \x03(\x03R\fresource_ids\x12=\n" + - "\tresources\x18\v \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x1a<\n" + + "\tresources\x18\v \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x1a\n" + + "\bview_ids\x18\f \x03(\x03R\bview_ids\x121\n" + + "\x05views\x18\r \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x1a<\n" + "\x0eDataRulesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xd3\x03\n" + @@ -3159,25 +3179,26 @@ var file_types_system_proto_depIdxs = []int32{ 30, // 67: api.v1.services.types.Permission.update_time:type_name -> google.protobuf.Timestamp 29, // 68: api.v1.services.types.Permission.data_rules:type_name -> api.v1.services.types.Permission.DataRulesEntry 10, // 69: api.v1.services.types.Permission.resources:type_name -> api.v1.services.types.Resource - 2, // 70: api.v1.services.types.PermissionEdges.roles:type_name -> api.v1.services.types.Role - 10, // 71: api.v1.services.types.PermissionEdges.resources:type_name -> api.v1.services.types.Resource - 16, // 72: api.v1.services.types.PermissionEdges.positions:type_name -> api.v1.services.types.Position - 24, // 73: api.v1.services.types.PermissionEdges.role_permissions:type_name -> api.v1.services.types.RolePermission - 26, // 74: api.v1.services.types.PermissionEdges.permission_resources:type_name -> api.v1.services.types.PermissionResource - 22, // 75: api.v1.services.types.PermissionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission - 4, // 76: api.v1.services.types.UserPositionEdges.user:type_name -> api.v1.services.types.User - 16, // 77: api.v1.services.types.UserPositionEdges.position:type_name -> api.v1.services.types.Position - 16, // 78: api.v1.services.types.PositionPermissionEdges.position:type_name -> api.v1.services.types.Position - 18, // 79: api.v1.services.types.PositionPermissionEdges.permission:type_name -> api.v1.services.types.Permission - 2, // 80: api.v1.services.types.RolePermissionEdges.role:type_name -> api.v1.services.types.Role - 18, // 81: api.v1.services.types.RolePermissionEdges.permission:type_name -> api.v1.services.types.Permission - 18, // 82: api.v1.services.types.PermissionResourceEdges.permission:type_name -> api.v1.services.types.Permission - 10, // 83: api.v1.services.types.PermissionResourceEdges.resource:type_name -> api.v1.services.types.Resource - 84, // [84:84] is the sub-list for method output_type - 84, // [84:84] is the sub-list for method input_type - 84, // [84:84] is the sub-list for extension type_name - 84, // [84:84] is the sub-list for extension extendee - 0, // [0:84] is the sub-list for field type_name + 0, // 70: api.v1.services.types.Permission.views:type_name -> api.v1.services.types.View + 2, // 71: api.v1.services.types.PermissionEdges.roles:type_name -> api.v1.services.types.Role + 10, // 72: api.v1.services.types.PermissionEdges.resources:type_name -> api.v1.services.types.Resource + 16, // 73: api.v1.services.types.PermissionEdges.positions:type_name -> api.v1.services.types.Position + 24, // 74: api.v1.services.types.PermissionEdges.role_permissions:type_name -> api.v1.services.types.RolePermission + 26, // 75: api.v1.services.types.PermissionEdges.permission_resources:type_name -> api.v1.services.types.PermissionResource + 22, // 76: api.v1.services.types.PermissionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission + 4, // 77: api.v1.services.types.UserPositionEdges.user:type_name -> api.v1.services.types.User + 16, // 78: api.v1.services.types.UserPositionEdges.position:type_name -> api.v1.services.types.Position + 16, // 79: api.v1.services.types.PositionPermissionEdges.position:type_name -> api.v1.services.types.Position + 18, // 80: api.v1.services.types.PositionPermissionEdges.permission:type_name -> api.v1.services.types.Permission + 2, // 81: api.v1.services.types.RolePermissionEdges.role:type_name -> api.v1.services.types.Role + 18, // 82: api.v1.services.types.RolePermissionEdges.permission:type_name -> api.v1.services.types.Permission + 18, // 83: api.v1.services.types.PermissionResourceEdges.permission:type_name -> api.v1.services.types.Permission + 10, // 84: api.v1.services.types.PermissionResourceEdges.resource:type_name -> api.v1.services.types.Resource + 85, // [85:85] is the sub-list for method output_type + 85, // [85:85] is the sub-list for method input_type + 85, // [85:85] is the sub-list for extension type_name + 85, // [85:85] is the sub-list for extension extendee + 0, // [0:85] is the sub-list for field type_name } func init() { file_types_system_proto_init() } diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index 208db57d..5bfb472d 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -4149,6 +4149,40 @@ func (m *Permission) validate(all bool) error { } + for idx, item := range m.GetViews() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionValidationError{ + field: fmt.Sprintf("Views[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionValidationError{ + field: fmt.Sprintf("Views[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionValidationError{ + field: fmt.Sprintf("Views[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + if len(errors) > 0 { return PermissionMultiError(errors) } diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 8dfeabe9..29f169fb 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -3061,6 +3061,16 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.Resource' description: permission.field.resources + view_ids: + type: array + items: + type: string + description: permission.field.view_ids + views: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.View' + description: permission.field.views description: permission.table.comment api.v1.services.types.Position: type: object From 0a65ec2ba7521fe004ad597a701d8b61b57fa337 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 5 Jan 2026 04:22:26 +0800 Subject: [PATCH 141/158] feat(auth): enhance captcha API with type support and update request/response fields, move endpoint to /auth/captcha --- Dockerfile.dev | 18 +++ Makefile | 48 ++++-- api/v1/proto/auth/auth.proto | 67 ++++---- api/v1/services/auth/auth.pb.go | 147 +++++++++++------- api/v1/services/auth/auth.pb.gw.go | 6 +- api/v1/services/auth/auth.pb.security.go | 4 +- api/v1/services/auth/auth.pb.validate.go | 8 +- api/v1/services/auth/auth_bridge.pb.go | 2 +- api/v1/services/auth/auth_http.pb.go | 4 +- cmd/auth/wire.go | 3 +- cmd/auth/wire_gen.go | 7 +- docker-compose.dev.yml | 34 ++++ docker-compose.yml | 91 +++-------- go.mod | 6 +- internal/conf/pb/captcha.proto | 1 + internal/features/auth/biz/captcha.go | 39 +++-- internal/features/auth/biz/casbin.biz.go | 26 ++-- .../features/auth/biz/casbin_stream.biz.go | 103 ------------ internal/features/auth/biz/provider.go | 2 +- internal/features/auth/dal/auth.go | 6 +- internal/features/auth/dal/casbin.go | 14 +- internal/features/auth/dal/me.go | 12 +- internal/features/auth/dto/casbin.go | 2 +- internal/features/auth/server/server.go | 6 +- internal/features/auth/service/auth.go | 38 +++-- internal/features/auth/service/casbin.go | 20 +-- internal/features/auth/service/me.go | 18 ++- internal/features/auth/service/provider.go | 2 +- internal/gateway/server/server.go | 24 ++- internal/helpers/captcha/captcha.go | 139 +++++++++++++---- internal/helpers/providers/providers.go | 13 +- resources/api-docs/openapi/openapi.yaml | 63 ++++---- tools.go | 1 + 33 files changed, 536 insertions(+), 438 deletions(-) create mode 100644 Dockerfile.dev create mode 100644 docker-compose.dev.yml delete mode 100644 internal/features/auth/biz/casbin_stream.biz.go diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 00000000..b489f10f --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,18 @@ +# Dockerfile for DEVELOPMENT with live-reloading +# Use a consistent Go version with the production Dockerfile +FROM golang:1.25.3-alpine + +# Set working directory +WORKDIR /app + +# Copy go modules to cache dependencies. +# This will also include the 'air' tool dependency. +COPY go.mod go.sum ./ +RUN go mod download + +# Copy the rest of the source code +COPY . . + +# Use 'go run' to execute the version of 'air' specified in go.mod. +# This avoids installing it globally and ensures version consistency. +CMD ["go", "run", "github.com/air-verse/air"] diff --git a/Makefile b/Makefile index 088cc8c0..a08dd35f 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ PROTO_TOOLKITS_PATH=toolkits PROTO_API_PATH=api OPENAPI_DOCS_PATH=resources/api-docs/openapi +# Path to the web UI submodule, relative to this Makefile +WEBUI_PATH=./webui + ifeq ($(GOHOSTOS), windows) #the `find.exe` is different from `find` in bash/shell. #to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find. @@ -61,16 +64,14 @@ endif BUILT_BY = $(PROJECT_ORG) -ifeq ($(ENV), release) - LDFLAGS = -s -w -endif -MODULE_PATH=github.com/origadmin/toolkits/version -LDFLAGS := -X $(MODULE_PATH).gitTag=$(TAG) \ - -X $(MODULE_PATH).buildDate=$(BUILT_DATE) \ - -X $(MODULE_PATH).gitCommit=$(COMMIT) \ - -X $(MODULE_PATH).gitTreeState=$(TREE_STATE) \ - -X $(MODULE_PATH).gitBranch=$(BRANCH) \ - -X $(MODULE_PATH).gitVersion=$(VERSION) +# LDFLAGS are now primarily managed by .goreleaser.yaml, but can be kept for direct go build commands if any. +# We will let goreleaser handle the version injection to ensure consistency. +LDFLAGS := -X github.com/origadmin/toolkits/version.gitTag=$(TAG) \ + -X github.com/origadmin/toolkits/version.buildDate=$(BUILT_DATE) \ + -X github.com/origadmin/toolkits/version.gitCommit=$(COMMIT) \ + -X github.com/origadmin/toolkits/version.gitTreeState=$(TREE_STATE) \ + -X github.com/origadmin/toolkits/version.gitBranch=$(BRANCH) \ + -X github.com/origadmin/toolkits/version.gitVersion=$(VERSION) PROTO_PATH := --proto_path=. --proto_path=./third_party @@ -114,21 +115,34 @@ ent: --ent_out=./database/ent/schema \ api/v1/proto/secondworld/greeter.proto -.PHONY: pre -# pre -pre: - goreleaser build --single-target --clean --snapshot +.PHONY: build-ui +# build the web UI from the submodule +build-ui: + @echo "Building Web UI from submodule..." + @cd $(WEBUI_PATH) && npm install && npm run build .PHONY: build -# build +# build a standard backend-only snapshot binary build: - go build -ldflags "$(LDFLAGS)" -gcflags=all="-N -l" -o ./dist/ ./... + @echo "Building standard backend-only snapshot..." + goreleaser build --single-target --clean --snapshot + +.PHONY: build-all-in-one +# build an all-in-one snapshot binary with embedded UI +build-all-in-one: build-ui + @echo "Building all-in-one snapshot with embedded UI..." + goreleaser build --single-target --clean --snapshot --config .goreleaser.all-in-one.yaml .PHONY: release -# release +# create a full release (backend-only) release: goreleaser release --clean +.PHONY: release-all-in-one +# create a full all-in-one release with embedded UI +release-all-in-one: build-ui + goreleaser release --config .goreleaser.all-in-one.yaml --clean + #.PHONY: server ## server used generate a service at first #server: diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index fe7b7ce6..0a8edafc 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -7,8 +7,8 @@ import "policy/v1/policy.proto"; option go_package = "origadmin/application/admin/api/v1/services/auth;auth"; option java_multiple_files = true; -option java_package = "com.origadmin.api.v1.services.auth"; option java_outer_classname = "APIServiceAuthProto"; +option java_package = "com.origadmin.api.v1.services.auth"; // Service AuthService provides APIs for the authentication lifecycle. service AuthService { @@ -54,9 +54,7 @@ service AuthService { // GetCaptcha generates a new captcha. rpc GetCaptcha(GetCaptchaRequest) returns (GetCaptchaResponse) { - option (google.api.http) = { - get: "/captcha" - }; + option (google.api.http) = {get: "/auth/captcha"}; option (contrib.api.policy.v1.policy) = {name: "public"}; } @@ -71,27 +69,27 @@ service AuthService { // The request message for the Login RPC. message LoginRequest { - string username = 1; - string password = 2; - string captcha_id = 3; - string captcha_code = 4; + string username = 1 [json_name = "username"]; + string password = 2 [json_name = "password"]; + string captcha_id = 3 [json_name = "captcha_id"]; + string captcha_code = 4 [json_name = "captcha_code"]; } // The response message for the Login RPC. message LoginResponse { - string access_token = 1; - string refresh_token = 2; - string token_type = 3; - int64 expires_in = 4; + string access_token = 1 [json_name = "access_token"]; + string refresh_token = 2 [json_name = "refresh_token"]; + string token_type = 3 [json_name = "token_type"]; + int64 expires_in = 4 [json_name = "expires_in"]; } // The request message for the Register RPC. message RegisterRequest { - string username = 1; - string password = 2; - string email = 3; - string captcha_id = 4; - string captcha_code = 5; + string username = 1 [json_name = "username"]; + string password = 2 [json_name = "password"]; + string email = 3 [json_name = "email"]; + string captcha_id = 4 [json_name = "captcha_id"]; + string captcha_code = 5 [json_name = "captcha_code"]; } // The response message for the Register RPC. @@ -99,7 +97,7 @@ message RegisterResponse {} // The request message for the Logout RPC. message LogoutRequest { - string refresh_token = 1; + string refresh_token = 1 [json_name = "refresh_token"]; } // The response message for the Logout RPC. @@ -107,38 +105,43 @@ message LogoutResponse {} // The request message for the RefreshToken RPC. message RefreshTokenRequest { - string refresh_token = 1; + string refresh_token = 1 [json_name = "refresh_token"]; } // The response message for the RefreshToken RPC. message RefreshTokenResponse { - string access_token = 1; - string token_type = 2; - int64 expires_in = 3; + string access_token = 1 [json_name = "access_token"]; + string token_type = 2 [json_name = "token_type"]; + int64 expires_in = 3 [json_name = "expires_in"]; } // The request message for the GetCaptcha RPC. message GetCaptchaRequest { - // If true, forces reloading of the captcha. - bool reload = 1; + // The ID of an existing captcha, used for refreshing or getting audio. + string captcha_id = 1 [json_name = "captcha_id"]; + // The type of captcha to generate (e.g., "digit", "string", "math", "chinese", "audio"). + string captcha_type = 2 [json_name = "captcha_type"]; } // The response message for the GetCaptcha RPC. message GetCaptchaResponse { - string captcha_id = 1; - // Base64 encoded image data. - string captcha_image = 2; + // The unique identifier for the generated captcha. + string captcha_id = 1 [json_name = "captcha_id"]; + // Base64 encoded data of the captcha (image or audio). + string captcha_data = 2 [json_name = "captcha_data"]; + // The MIME type of the captcha data (e.g., "image/png", "audio/wav"). + string mime_type = 3 [json_name = "mime_type"]; } // The request message for the Authenticate RPC. message AuthenticateRequest { - string token = 1; - string path = 2; - string method = 3; + string token = 1 [json_name = "token"]; + string path = 2 [json_name = "path"]; + string method = 3 [json_name = "method"]; } // The response message for the Authenticate RPC. message AuthenticateResponse { - bool authorized = 1; - string user_id = 2; + bool authorized = 1 [json_name = "authorized"]; + string user_id = 2 [json_name = "user_id"]; } diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index 69634da4..e06f2d1e 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -28,8 +28,8 @@ type LoginRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` - CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` - CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,json=captchaCode,proto3" json:"captcha_code,omitempty"` + CaptchaId string `protobuf:"bytes,3,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` + CaptchaCode string `protobuf:"bytes,4,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -95,10 +95,10 @@ func (x *LoginRequest) GetCaptchaCode() string { // The response message for the Login RPC. type LoginResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` - RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` - TokenType string `protobuf:"bytes,3,opt,name=token_type,json=tokenType,proto3" json:"token_type,omitempty"` - ExpiresIn int64 `protobuf:"varint,4,opt,name=expires_in,json=expiresIn,proto3" json:"expires_in,omitempty"` + AccessToken string `protobuf:"bytes,1,opt,name=access_token,proto3" json:"access_token,omitempty"` + RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` + TokenType string `protobuf:"bytes,3,opt,name=token_type,proto3" json:"token_type,omitempty"` + ExpiresIn int64 `protobuf:"varint,4,opt,name=expires_in,proto3" json:"expires_in,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -167,8 +167,8 @@ type RegisterRequest struct { Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` - CaptchaId string `protobuf:"bytes,4,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` - CaptchaCode string `protobuf:"bytes,5,opt,name=captcha_code,json=captchaCode,proto3" json:"captcha_code,omitempty"` + CaptchaId string `protobuf:"bytes,4,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` + CaptchaCode string `protobuf:"bytes,5,opt,name=captcha_code,proto3" json:"captcha_code,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -278,7 +278,7 @@ func (*RegisterResponse) Descriptor() ([]byte, []int) { // The request message for the Logout RPC. type LogoutRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` + RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -360,7 +360,7 @@ func (*LogoutResponse) Descriptor() ([]byte, []int) { // The request message for the RefreshToken RPC. type RefreshTokenRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"` + RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -405,9 +405,9 @@ func (x *RefreshTokenRequest) GetRefreshToken() string { // The response message for the RefreshToken RPC. type RefreshTokenResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` - TokenType string `protobuf:"bytes,2,opt,name=token_type,json=tokenType,proto3" json:"token_type,omitempty"` - ExpiresIn int64 `protobuf:"varint,3,opt,name=expires_in,json=expiresIn,proto3" json:"expires_in,omitempty"` + AccessToken string `protobuf:"bytes,1,opt,name=access_token,proto3" json:"access_token,omitempty"` + TokenType string `protobuf:"bytes,2,opt,name=token_type,proto3" json:"token_type,omitempty"` + ExpiresIn int64 `protobuf:"varint,3,opt,name=expires_in,proto3" json:"expires_in,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -466,8 +466,10 @@ func (x *RefreshTokenResponse) GetExpiresIn() int64 { // The request message for the GetCaptcha RPC. type GetCaptchaRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - // If true, forces reloading of the captcha. - Reload bool `protobuf:"varint,1,opt,name=reload,proto3" json:"reload,omitempty"` + // The ID of an existing captcha, used for refreshing or getting audio. + CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` + // The type of captcha to generate (e.g., "digit", "string", "math", "chinese", "audio"). + CaptchaType string `protobuf:"bytes,2,opt,name=captcha_type,proto3" json:"captcha_type,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -502,19 +504,29 @@ func (*GetCaptchaRequest) Descriptor() ([]byte, []int) { return file_auth_auth_proto_rawDescGZIP(), []int{8} } -func (x *GetCaptchaRequest) GetReload() bool { +func (x *GetCaptchaRequest) GetCaptchaId() string { if x != nil { - return x.Reload + return x.CaptchaId } - return false + return "" +} + +func (x *GetCaptchaRequest) GetCaptchaType() string { + if x != nil { + return x.CaptchaType + } + return "" } // The response message for the GetCaptcha RPC. type GetCaptchaResponse struct { - state protoimpl.MessageState `protogen:"open.v1"` - CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` - // Base64 encoded image data. - CaptchaImage string `protobuf:"bytes,2,opt,name=captcha_image,json=captchaImage,proto3" json:"captcha_image,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + // The unique identifier for the generated captcha. + CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,proto3" json:"captcha_id,omitempty"` + // Base64 encoded data of the captcha (image or audio). + CaptchaData string `protobuf:"bytes,2,opt,name=captcha_data,proto3" json:"captcha_data,omitempty"` + // The MIME type of the captcha data (e.g., "image/png", "audio/wav"). + MimeType string `protobuf:"bytes,3,opt,name=mime_type,proto3" json:"mime_type,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -556,9 +568,16 @@ func (x *GetCaptchaResponse) GetCaptchaId() string { return "" } -func (x *GetCaptchaResponse) GetCaptchaImage() string { +func (x *GetCaptchaResponse) GetCaptchaData() string { if x != nil { - return x.CaptchaImage + return x.CaptchaData + } + return "" +} + +func (x *GetCaptchaResponse) GetMimeType() string { + if x != nil { + return x.MimeType } return "" } @@ -628,7 +647,7 @@ func (x *AuthenticateRequest) GetMethod() string { type AuthenticateResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Authorized bool `protobuf:"varint,1,opt,name=authorized,proto3" json:"authorized,omitempty"` - UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + UserId string `protobuf:"bytes,2,opt,name=user_id,proto3" json:"user_id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -681,54 +700,65 @@ var File_auth_auth_proto protoreflect.FileDescriptor const file_auth_auth_proto_rawDesc = "" + "\n" + - "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x16policy/v1/policy.proto\"\x88\x01\n" + + "\x0fauth/auth.proto\x12\x14api.v1.services.auth\x1a\x1cgoogle/api/annotations.proto\x1a\x16policy/v1/policy.proto\"\x8a\x01\n" + "\fLoginRequest\x12\x1a\n" + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + - "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x1d\n" + + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x1e\n" + "\n" + - "captcha_id\x18\x03 \x01(\tR\tcaptchaId\x12!\n" + - "\fcaptcha_code\x18\x04 \x01(\tR\vcaptchaCode\"\x95\x01\n" + - "\rLoginResponse\x12!\n" + - "\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12#\n" + - "\rrefresh_token\x18\x02 \x01(\tR\frefreshToken\x12\x1d\n" + + "captcha_id\x18\x03 \x01(\tR\n" + + "captcha_id\x12\"\n" + + "\fcaptcha_code\x18\x04 \x01(\tR\fcaptcha_code\"\x99\x01\n" + + "\rLoginResponse\x12\"\n" + + "\faccess_token\x18\x01 \x01(\tR\faccess_token\x12$\n" + + "\rrefresh_token\x18\x02 \x01(\tR\rrefresh_token\x12\x1e\n" + "\n" + - "token_type\x18\x03 \x01(\tR\ttokenType\x12\x1d\n" + + "token_type\x18\x03 \x01(\tR\n" + + "token_type\x12\x1e\n" + "\n" + - "expires_in\x18\x04 \x01(\x03R\texpiresIn\"\xa1\x01\n" + + "expires_in\x18\x04 \x01(\x03R\n" + + "expires_in\"\xa3\x01\n" + "\x0fRegisterRequest\x12\x1a\n" + "\busername\x18\x01 \x01(\tR\busername\x12\x1a\n" + "\bpassword\x18\x02 \x01(\tR\bpassword\x12\x14\n" + - "\x05email\x18\x03 \x01(\tR\x05email\x12\x1d\n" + + "\x05email\x18\x03 \x01(\tR\x05email\x12\x1e\n" + + "\n" + + "captcha_id\x18\x04 \x01(\tR\n" + + "captcha_id\x12\"\n" + + "\fcaptcha_code\x18\x05 \x01(\tR\fcaptcha_code\"\x12\n" + + "\x10RegisterResponse\"5\n" + + "\rLogoutRequest\x12$\n" + + "\rrefresh_token\x18\x01 \x01(\tR\rrefresh_token\"\x10\n" + + "\x0eLogoutResponse\";\n" + + "\x13RefreshTokenRequest\x12$\n" + + "\rrefresh_token\x18\x01 \x01(\tR\rrefresh_token\"z\n" + + "\x14RefreshTokenResponse\x12\"\n" + + "\faccess_token\x18\x01 \x01(\tR\faccess_token\x12\x1e\n" + "\n" + - "captcha_id\x18\x04 \x01(\tR\tcaptchaId\x12!\n" + - "\fcaptcha_code\x18\x05 \x01(\tR\vcaptchaCode\"\x12\n" + - "\x10RegisterResponse\"4\n" + - "\rLogoutRequest\x12#\n" + - "\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\"\x10\n" + - "\x0eLogoutResponse\":\n" + - "\x13RefreshTokenRequest\x12#\n" + - "\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\"w\n" + - "\x14RefreshTokenResponse\x12!\n" + - "\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12\x1d\n" + + "token_type\x18\x02 \x01(\tR\n" + + "token_type\x12\x1e\n" + "\n" + - "token_type\x18\x02 \x01(\tR\ttokenType\x12\x1d\n" + + "expires_in\x18\x03 \x01(\x03R\n" + + "expires_in\"W\n" + + "\x11GetCaptchaRequest\x12\x1e\n" + "\n" + - "expires_in\x18\x03 \x01(\x03R\texpiresIn\"+\n" + - "\x11GetCaptchaRequest\x12\x16\n" + - "\x06reload\x18\x01 \x01(\bR\x06reload\"X\n" + - "\x12GetCaptchaResponse\x12\x1d\n" + + "captcha_id\x18\x01 \x01(\tR\n" + + "captcha_id\x12\"\n" + + "\fcaptcha_type\x18\x02 \x01(\tR\fcaptcha_type\"v\n" + + "\x12GetCaptchaResponse\x12\x1e\n" + "\n" + - "captcha_id\x18\x01 \x01(\tR\tcaptchaId\x12#\n" + - "\rcaptcha_image\x18\x02 \x01(\tR\fcaptchaImage\"W\n" + + "captcha_id\x18\x01 \x01(\tR\n" + + "captcha_id\x12\"\n" + + "\fcaptcha_data\x18\x02 \x01(\tR\fcaptcha_data\x12\x1c\n" + + "\tmime_type\x18\x03 \x01(\tR\tmime_type\"W\n" + "\x13AuthenticateRequest\x12\x14\n" + "\x05token\x18\x01 \x01(\tR\x05token\x12\x12\n" + "\x04path\x18\x02 \x01(\tR\x04path\x12\x16\n" + - "\x06method\x18\x03 \x01(\tR\x06method\"O\n" + + "\x06method\x18\x03 \x01(\tR\x06method\"P\n" + "\x14AuthenticateResponse\x12\x1e\n" + "\n" + "authorized\x18\x01 \x01(\bR\n" + - "authorized\x12\x17\n" + - "\auser_id\x18\x02 \x01(\tR\x06userId2\xf6\x05\n" + + "authorized\x12\x18\n" + + "\auser_id\x18\x02 \x01(\tR\auser_id2\xfc\x05\n" + "\vAuthService\x12t\n" + "\x05Login\x12\".api.v1.services.auth.LoginRequest\x1a#.api.v1.services.auth.LoginResponse\"\"\xea\xea\x1b\b\n" + "\x06public\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/auth/login\x12\x80\x01\n" + @@ -739,11 +769,10 @@ const file_auth_auth_proto_rawDesc = "" + "\bjwt-auth\x82\xd3\xe4\x93\x02\x11:\x01*\"\f/auth/logout\x12\x8b\x01\n" + "\fRefreshToken\x12).api.v1.services.auth.RefreshTokenRequest\x1a*.api.v1.services.auth.RefreshTokenResponse\"$\xea\xea\x1b\n" + "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/auth/token\x12}\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/auth/token\x12\x82\x01\n" + "\n" + - "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"\x1c\xea\xea\x1b\b\n" + - "\x06public\x82\xd3\xe4\x93\x02\n" + - "\x12\b/captcha\x12e\n" + + "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"!\xea\xea\x1b\b\n" + + "\x06public\x82\xd3\xe4\x93\x02\x0f\x12\r/auth/captcha\x12e\n" + "\fAuthenticate\x12).api.v1.services.auth.AuthenticateRequest\x1a*.api.v1.services.auth.AuthenticateResponseB\xd0\x01\n" + "\x18com.api.v1.services.authB\tAuthProtoP\x01Z5origadmin/application/admin/api/v1/services/auth;auth\xa2\x02\x04AVSA\xaa\x02\x14Api.V1.Services.Auth\xca\x02\x14Api\\V1\\Services\\Auth\xe2\x02 Api\\V1\\Services\\Auth\\GPBMetadata\xea\x02\x17Api::V1::Services::Authb\x06proto3" diff --git a/api/v1/services/auth/auth.pb.gw.go b/api/v1/services/auth/auth.pb.gw.go index 5d830815..b73fad6f 100644 --- a/api/v1/services/auth/auth.pb.gw.go +++ b/api/v1/services/auth/auth.pb.gw.go @@ -256,7 +256,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/GetCaptcha", runtime.WithHTTPPathPattern("/captcha")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/GetCaptcha", runtime.WithHTTPPathPattern("/auth/captcha")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -382,7 +382,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/GetCaptcha", runtime.WithHTTPPathPattern("/captcha")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/GetCaptcha", runtime.WithHTTPPathPattern("/auth/captcha")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -403,7 +403,7 @@ var ( pattern_AuthService_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "register"}, "")) pattern_AuthService_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "logout"}, "")) pattern_AuthService_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "token"}, "")) - pattern_AuthService_GetCaptcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"captcha"}, "")) + pattern_AuthService_GetCaptcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "captcha"}, "")) ) var ( diff --git a/api/v1/services/auth/auth.pb.security.go b/api/v1/services/auth/auth.pb.security.go index 55981b27..6dd2d4ea 100644 --- a/api/v1/services/auth/auth.pb.security.go +++ b/api/v1/services/auth/auth.pb.security.go @@ -35,9 +35,9 @@ func init() { }, { ServiceMethod: "/api.v1.services.auth.AuthService/GetCaptcha", - GatewayPath: "GET:/captcha", + GatewayPath: "GET:/auth/captcha", Name: "public", - VersionID: "4c2d4078ffb54002daae7094b5af8c76dcbcaf87e1f79b9826fac1079d78889f", + VersionID: "db87ea691879696f62dff3f5177ff7aa5e0be02f53c02273abeb016e185a5917", }, } diff --git a/api/v1/services/auth/auth.pb.validate.go b/api/v1/services/auth/auth.pb.validate.go index 96525455..2eebbc90 100644 --- a/api/v1/services/auth/auth.pb.validate.go +++ b/api/v1/services/auth/auth.pb.validate.go @@ -896,7 +896,9 @@ func (m *GetCaptchaRequest) validate(all bool) error { var errors []error - // no validation rules for Reload + // no validation rules for CaptchaId + + // no validation rules for CaptchaType if len(errors) > 0 { return GetCaptchaRequestMultiError(errors) @@ -1002,7 +1004,9 @@ func (m *GetCaptchaResponse) validate(all bool) error { // no validation rules for CaptchaId - // no validation rules for CaptchaImage + // no validation rules for CaptchaData + + // no validation rules for MimeType if len(errors) > 0 { return GetCaptchaResponseMultiError(errors) diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index de9bf285..8775c522 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -95,7 +95,7 @@ func RegisterAuthServiceBridgeServer(s *http.Server, srv AuthServiceHookedBridge r.POST("/auth/register", _AuthService_Register0_Bridge_Handler(srv)) r.POST("/auth/logout", _AuthService_Logout0_Bridge_Handler(srv)) r.POST("/auth/token", _AuthService_RefreshToken0_Bridge_Handler(srv)) - r.GET("/captcha", _AuthService_GetCaptcha0_Bridge_Handler(srv)) + r.GET("/auth/captcha", _AuthService_GetCaptcha0_Bridge_Handler(srv)) } func _AuthService_Login0_Bridge_Handler(srv AuthServiceHookedBridger) func(ctx http.Context) error { diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go index a1d6f698..99a63cd5 100644 --- a/api/v1/services/auth/auth_http.pb.go +++ b/api/v1/services/auth/auth_http.pb.go @@ -44,7 +44,7 @@ func RegisterAuthServiceHTTPServer(s *http.Server, srv AuthServiceHTTPServer) { r.POST("/auth/register", _AuthService_Register0_HTTP_Handler(srv)) r.POST("/auth/logout", _AuthService_Logout0_HTTP_Handler(srv)) r.POST("/auth/token", _AuthService_RefreshToken0_HTTP_Handler(srv)) - r.GET("/captcha", _AuthService_GetCaptcha0_HTTP_Handler(srv)) + r.GET("/auth/captcha", _AuthService_GetCaptcha0_HTTP_Handler(srv)) } func _AuthService_Login0_HTTP_Handler(srv AuthServiceHTTPServer) func(ctx http.Context) error { @@ -178,7 +178,7 @@ func NewAuthServiceHTTPClient(client *http.Client) AuthServiceHTTPClient { // GetCaptcha GetCaptcha generates a new captcha. func (c *AuthServiceHTTPClientImpl) GetCaptcha(ctx context.Context, in *GetCaptchaRequest, opts ...http.CallOption) (*GetCaptchaResponse, error) { var out GetCaptchaResponse - pattern := "/captcha" + pattern := "/auth/captcha" path := binding.EncodeURL(pattern, in, true) opts = append(opts, http.Operation(OperationAuthServiceGetCaptcha)) opts = append(opts, http.PathTemplate(pattern)) diff --git a/cmd/auth/wire.go b/cmd/auth/wire.go index 784ab01d..4203a6c0 100644 --- a/cmd/auth/wire.go +++ b/cmd/auth/wire.go @@ -7,7 +7,7 @@ import ( "github.com/go-kratos/kratos/v2" "github.com/google/wire" - "github.com/origadmin/runtime" + "github.comcom/origadmin/runtime" "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/features/auth/biz" @@ -22,6 +22,7 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err panic(wire.Build( // Shared infrastructure providers providers.ProviderSet, + providers.ProviderBackendSet, // CORRECTED: Added the backend-specific security middleware providers. // Service-specific providers data.ProviderSet, diff --git a/cmd/auth/wire_gen.go b/cmd/auth/wire_gen.go index e4c11582..5432f09f 100644 --- a/cmd/auth/wire_gen.go +++ b/cmd/auth/wire_gen.go @@ -58,6 +58,7 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err cleanup() return nil, nil, err } + captchaUseCase := biz.NewCaptchaUseCase(captchaCaptcha, v) options, err := providers.ProvideAuthenticatorOptions(bootstrap) if err != nil { cleanup() @@ -68,12 +69,12 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err cleanup() return nil, nil, err } - authService := service.NewAuthService(authUseCase, captchaCaptcha, creator) + authService := service.NewAuthService(authUseCase, captchaUseCase, creator) meRepo := dal.NewMeRepo(database, v) meUseCase := biz.NewMeUseCase(meRepo, v) meService := service.NewMeService(meUseCase) - casbinSourceService := service.NewCasbinSourceService() - v2, err := server.NewServers(servers, authService, meService, casbinSourceService, v) + casbinService := service.NewCasbinService() + v2, err := server.NewServers(servers, authService, meService, casbinService, v) if err != nil { cleanup() return nil, nil, err diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 00000000..f062d73f --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,34 @@ +version: '3.8' + +services: + gateway: + build: + context: . + dockerfile: Dockerfile.dev + ports: + - "8000:8000" + - "9000:9000" + volumes: + # Mount the entire project to allow air to watch for changes + - .:/app + # The working_dir tells 'air' where to find its config + working_dir: /app/cmd/gateway + depends_on: + - auth + - system + + auth: + build: + context: . + dockerfile: Dockerfile.dev + volumes: + - .:/app + working_dir: /app/cmd/auth + + system: + build: + context: . + dockerfile: Dockerfile.dev + volumes: + - .:/app + working_dir: /app/cmd/system diff --git a/docker-compose.yml b/docker-compose.yml index 3aef1451..8354559a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,82 +1,37 @@ -networks: - original-net: - driver: bridge +version: '3.8' services: - # Service Discovery - consul: - image: hashicorp/consul:1.22.2 - container_name: consul - ports: - - "8500:8500" - networks: - - original-net - command: "agent -server -bootstrap-expect=1 -ui -client=0.0.0.0" - - # Database - postgres: - image: postgres:16-alpine - container_name: postgres - environment: - POSTGRES_DB: origadmin - POSTGRES_USER: user - POSTGRES_PASSWORD: password - ports: - - "5432:5432" - networks: - - original-net - volumes: - - postgres_data:/var/lib/postgresql/data - - # Auth Service - auth: + gateway: build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile # Use the root Dockerfile args: - SERVICE_NAME: auth - container_name: auth-service - depends_on: - - consul - - postgres + SERVICE_NAME: gateway # Pass the service name as a build argument ports: - - "9001:9001" - networks: - - original-net + - "8000:8000" # Expose gateway's HTTP port + - "9000:9000" # Expose gateway's gRPC port + volumes: + - .:/app # Mount the entire project directory to enable live reload + depends_on: + - auth + - system - # System Service - system: + auth: build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile # Use the root Dockerfile args: - SERVICE_NAME: system - container_name: system-service - depends_on: - - consul - - postgres - ports: - - "9002:9002" - networks: - - original-net + SERVICE_NAME: auth # Pass the service name as a build argument + volumes: + - .:/app + # No ports need to be exposed as it's an internal service. - # Gateway Service - gateway: + system: build: context: . - dockerfile: Dockerfile + dockerfile: Dockerfile # Use the root Dockerfile args: - SERVICE_NAME: gateway - container_name: gateway-service - depends_on: - - consul - - auth - - system - ports: - - "8000:8000" - networks: - - original-net - -volumes: - postgres_data: - driver: local + SERVICE_NAME: system # Pass the service name as a build argument + volumes: + - .:/app + # No ports need to be exposed as it's an internal service. diff --git a/go.mod b/go.mod index 59864c9b..a0a16444 100644 --- a/go.mod +++ b/go.mod @@ -4,9 +4,9 @@ go 1.25.3 replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0.5.4 -replace github.com/origadmin/runtime v0.2.15 => ../../runtime - -replace github.com/origadmin/contrib v1.1.0 => ../../contrib +//replace github.com/origadmin/runtime v0.2.15 => ../../runtime +// +//replace github.com/origadmin/contrib v1.1.0 => ../../contrib require ( entgo.io/ent v0.14.5 diff --git a/internal/conf/pb/captcha.proto b/internal/conf/pb/captcha.proto index 22100c6b..39c4fbe4 100644 --- a/internal/conf/pb/captcha.proto +++ b/internal/conf/pb/captcha.proto @@ -11,6 +11,7 @@ message Captcha { float maxskew = 4 [json_name = "maxskew"]; int32 dot_count = 5 [json_name = "dot_count"]; string cache_name = 6 [json_name = "cache_name"]; + string language = 7 [json_name = "language"]; // runtime.api.config.data.v1.Caches caches = 5 [json_name = "caches"]; // 注释原有Redis配置(应由公共配置管理) diff --git a/internal/features/auth/biz/captcha.go b/internal/features/auth/biz/captcha.go index fd252453..5fe8690d 100644 --- a/internal/features/auth/biz/captcha.go +++ b/internal/features/auth/biz/captcha.go @@ -4,38 +4,35 @@ import ( "context" "github.com/go-kratos/kratos/v2/log" - "github.com/mojocn/base64Captcha" - confpb "origadmin/application/admin/internal/conf/pb" - "origadmin/application/admin/internal/features/auth/dto" + "origadmin/application/admin/internal/helpers/captcha" ) // CaptchaUseCase is a captcha use case. type CaptchaUseCase struct { - repo dto.CaptchaRepo - config *confpb.Captcha - log *log.Helper + captcha *captcha.Captcha + log *log.Helper } // NewCaptchaUseCase new a captcha use case. -func NewCaptchaUseCase(repo dto.CaptchaRepo, c *confpb.Captcha, logger log.Logger) *CaptchaUseCase { +func NewCaptchaUseCase(c *captcha.Captcha, logger log.Logger) *CaptchaUseCase { return &CaptchaUseCase{ - repo: repo, - config: c, - log: log.NewHelper(logger), + captcha: c, + log: log.NewHelper(logger), } } // GenerateCaptcha generates a new captcha. -func (uc *CaptchaUseCase) GenerateCaptcha(ctx context.Context) (id, b64s string, err error) { - driver := base64Captcha.NewDriverDigit( - int(uc.config.GetHeight()), - int(uc.config.GetWidth()), - int(uc.config.GetLength()), - float64(uc.config.GetMaxskew()), - int(uc.config.GetDotCount()), - ) - c := base64Captcha.NewCaptcha(driver, uc.repo) - id, content, _, err := c.Generate() - return id, content, err +func (uc *CaptchaUseCase) GenerateCaptcha(ctx context.Context, captchaType string) (id, b64s, answer string, err error) { + return uc.captcha.Generate(captchaType) +} + +// GetCaptchaAudio generates audio for a given captcha ID. +func (uc *CaptchaUseCase) GetCaptchaAudio(ctx context.Context, id string) (string, error) { + return uc.captcha.GetAudioForID(id) +} + +// VerifyCaptcha verifies a user's answer for a given captcha ID. +func (uc *CaptchaUseCase) VerifyCaptcha(ctx context.Context, id, answer string) bool { + return uc.captcha.Verify(id, answer, true) } diff --git a/internal/features/auth/biz/casbin.biz.go b/internal/features/auth/biz/casbin.biz.go index a76c8ece..a065740f 100644 --- a/internal/features/auth/biz/casbin.biz.go +++ b/internal/features/auth/biz/casbin.biz.go @@ -21,15 +21,15 @@ import ( "origadmin/application/admin/internal/features/auth/dto" ) -// CasbinSourceServiceBiz is a CasbinSource use case. -type CasbinSourceServiceBiz struct { - dao dto.CasbinSourceRepo +// CasbinServiceBiz is a Casbin use case. +type CasbinServiceBiz struct { + dao dto.CasbinRepo limiter repo.PageLimiter log *log.Helper lastModified *atomic.Int64 } -func (c CasbinSourceServiceBiz) StreamRules(request *pb.StreamRulesRequest, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { +func (c CasbinServiceBiz) StreamRules(request *pb.StreamRulesRequest, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { c.log.Debug("StreamRules") ctx := stream.Context() if request.WithPolicies { @@ -46,28 +46,28 @@ func (c CasbinSourceServiceBiz) StreamRules(request *pb.StreamRulesRequest, stre return nil } -func (c CasbinSourceServiceBiz) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { +func (c CasbinServiceBiz) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { c.log.Debug("ListPolicies") return c.dao.ListPolicies(ctx, in) } -func (c CasbinSourceServiceBiz) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { +func (c CasbinServiceBiz) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { c.log.Debug("ListGroupings") return c.dao.ListGroupings(ctx, in) } -func (c CasbinSourceServiceBiz) WatchUpdate(_ context.Context, +func (c CasbinServiceBiz) WatchUpdate(_ context.Context, request *pb.WatchUpdateRequest) (*pb.WatchUpdateResponse, error) { c.log.Debug("WatchUpdate") return &pb.WatchUpdateResponse{ModifiedDate: c.lastModified.Load()}, nil } -func (c CasbinSourceServiceBiz) UpdateRules() { +func (c CasbinServiceBiz) UpdateRules() { // todo: load from db c.lastModified.Store(time.Now().Unix()) } -func (c CasbinSourceServiceBiz) streamPolicies(ctx context.Context, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { +func (c CasbinServiceBiz) streamPolicies(ctx context.Context, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { policies, err := c.ListPolicies(ctx, &pb.ListPoliciesRequest{}) if err != nil { return err @@ -80,7 +80,7 @@ func (c CasbinSourceServiceBiz) streamPolicies(ctx context.Context, stream grpc. return nil } -func (c CasbinSourceServiceBiz) streamGroupings(ctx context.Context, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { +func (c CasbinServiceBiz) streamGroupings(ctx context.Context, stream grpc.ServerStreamingServer[pb.StreamRulesResponse]) error { groupings, err := c.ListGroupings(ctx, &pb.ListGroupingsRequest{}) if err != nil { return err @@ -105,8 +105,8 @@ func newGroupingResponse(rule *pb.GroupingRule) *pb.StreamRulesResponse { } } -// NewCasbinSourceServiceBiz new a CasbinSource use case. -func NewCasbinSourceServiceBiz(r *runtime.App, repo dto.CasbinSourceRepo) *CasbinSourceServiceBiz { - return &CasbinSourceServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(log.With(r.Logger(), "module", "biz/casbin")), +// NewCasbinServiceBiz new a Casbin use case. +func NewCasbinServiceBiz(r *runtime.App, repo dto.CasbinRepo) *CasbinServiceBiz { + return &CasbinServiceBiz{dao: repo, limiter: defaultLimiter, log: log.NewHelper(log.With(r.Logger(), "module", "biz/casbin")), lastModified: &atomic.Int64{}} } diff --git a/internal/features/auth/biz/casbin_stream.biz.go b/internal/features/auth/biz/casbin_stream.biz.go deleted file mode 100644 index d595a591..00000000 --- a/internal/features/auth/biz/casbin_stream.biz.go +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2024 OrigAdmin. All rights reserved. - */ - -// Package biz is a biz layer for the auth module of OrigAdmin. -package biz - -import ( - "context" - "errors" - "io" - - "google.golang.org/grpc" - "google.golang.org/grpc/metadata" - - pb "origadmin/application/admin/api/v1/services/auth" -) - -// CasbinRuleStream is a CasbinSource use case. -type CasbinRuleStream struct { - ctx context.Context - cancel context.CancelFunc - receiver chan *pb.StreamRulesResponse - client *CasbinSourceServiceBiz -} - -func (c CasbinRuleStream) Recv() (*pb.StreamRulesResponse, error) { - select { - case msg := <-c.receiver: - c.client.log.Debugf("received message: %v", msg) - if msg == nil { - c.client.log.Debugf("stream closed") - return nil, io.EOF - } - return msg, nil - case <-c.ctx.Done(): - c.client.log.Debugf("no message received") - return nil, c.ctx.Err() - } -} - -func (c CasbinRuleStream) Header() (metadata.MD, error) { - return metadata.MD{}, errors.New("not implemented") -} - -func (c CasbinRuleStream) Trailer() metadata.MD { - return metadata.MD{} -} - -func (c CasbinRuleStream) CloseSend() error { - return errors.New("not implemented") -} - -func (c CasbinRuleStream) Context() context.Context { - return c.ctx -} - -func (c CasbinRuleStream) SendMsg(m any) error { - return errors.New("not implemented") -} - -func (c CasbinRuleStream) RecvMsg(m any) error { - return errors.New("not implemented") -} - -func (c CasbinRuleStream) Start(request *pb.StreamRulesRequest) error { - defer close(c.receiver) - //c.client.log.Infof("sending request: %v", request) - if request.WithPolicies { - policies, err := c.client.ListPolicies(c.ctx, &pb.ListPoliciesRequest{}) - if err != nil { - return err - } - //c.client.log.Infof("sending %d policies", len(policies.Rules)) - for _, rule := range policies.Rules { - c.receiver <- newPolicyResponse(rule) - } - } - - if request.WithGroupings { - groupings, err := c.client.ListGroupings(c.ctx, &pb.ListGroupingsRequest{}) - if err != nil { - return err - } - //c.client.log.Infof("sending %d groupings", len(groupings.Rules)) - for _, grouping := range groupings.Rules { - c.receiver <- newGroupingResponse(grouping) - } - } - return nil -} - -func NewCasbinRuleStream(ctx context.Context, client *CasbinSourceServiceBiz) *CasbinRuleStream { - ctx, cancel := context.WithCancel(ctx) - return &CasbinRuleStream{ - ctx: ctx, - cancel: cancel, - receiver: make(chan *pb.StreamRulesResponse, 1), - client: client, - } -} - -var _ grpc.ServerStreamingClient[pb.StreamRulesResponse] = (*CasbinRuleStream)(nil) diff --git a/internal/features/auth/biz/provider.go b/internal/features/auth/biz/provider.go index 44db5db3..016550e8 100644 --- a/internal/features/auth/biz/provider.go +++ b/internal/features/auth/biz/provider.go @@ -3,4 +3,4 @@ package biz import "github.com/google/wire" // ProviderSet is biz providers. -var ProviderSet = wire.NewSet(NewAuthUseCase, NewMeUseCase, NewCaptchaUseCase, NewCasbinSourceServiceBiz) +var ProviderSet = wire.NewSet(NewAuthUseCase, NewMeUseCase, NewCaptchaUseCase, NewCasbinServiceBiz) diff --git a/internal/features/auth/dal/auth.go b/internal/features/auth/dal/auth.go index 9b2ba5b4..73ed0a32 100644 --- a/internal/features/auth/dal/auth.go +++ b/internal/features/auth/dal/auth.go @@ -10,21 +10,21 @@ import ( "origadmin/application/admin/internal/features/auth/dto" ) -type authRepo struct { +type AuthRepo struct { db *ent.Database log *log.Helper } // NewAuthRepo . func NewAuthRepo(db *ent.Database, logger log.Logger) dto.AuthRepo { - return &authRepo{ + return &AuthRepo{ db: db, log: log.NewHelper(logger), } } // GetUserByUsername retrieves a user by their username. -func (r *authRepo) GetUserByUsername(ctx context.Context, username string) (*dto.User, error) { +func (r *AuthRepo) GetUserByUsername(ctx context.Context, username string) (*dto.User, error) { u, err := r.db.User(ctx).Query().Where(user.UsernameEQ(username)).Only(ctx) if err != nil { return nil, err diff --git a/internal/features/auth/dal/casbin.go b/internal/features/auth/dal/casbin.go index 063b8bda..3662c5fb 100644 --- a/internal/features/auth/dal/casbin.go +++ b/internal/features/auth/dal/casbin.go @@ -13,19 +13,19 @@ import ( "origadmin/application/admin/internal/features/auth/dto" ) -// casbinRepo is a repository for casbin rules that implements -// the application's internal CasbinSourceRepo interface. -type casbinRepo struct { +// CasbinRepo is a repository for casbin rules that implements +// the application's internal CasbinRepo interface. +type CasbinRepo struct { db *ent.Database } // NewCasbinRepo creates a new casbin repository. -func NewCasbinRepo(db *ent.Database) (dto.CasbinSourceRepo, error) { - return &casbinRepo{db: db}, nil +func NewCasbinRepo(db *ent.Database) (dto.CasbinRepo, error) { + return &CasbinRepo{db: db}, nil } // ListPolicies retrieves policy rules ("p" type) from the storage. -func (r *casbinRepo) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { +func (r *CasbinRepo) ListPolicies(ctx context.Context, in *pb.ListPoliciesRequest) (*pb.ListPoliciesResponse, error) { rules, err := r.db.CasbinRule(ctx).Query().Where(casbinrule.PtypeEQ("p")).All(ctx) if err != nil { return nil, err @@ -43,7 +43,7 @@ func (r *casbinRepo) ListPolicies(ctx context.Context, in *pb.ListPoliciesReques } // ListGroupings retrieves grouping rules ("g" type) from the storage. -func (r *casbinRepo) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { +func (r *CasbinRepo) ListGroupings(ctx context.Context, in *pb.ListGroupingsRequest) (*pb.ListGroupingsResponse, error) { rules, err := r.db.CasbinRule(ctx).Query().Where(casbinrule.PtypeEQ("g")).All(ctx) if err != nil { return nil, err diff --git a/internal/features/auth/dal/me.go b/internal/features/auth/dal/me.go index c325f96c..49063ff3 100644 --- a/internal/features/auth/dal/me.go +++ b/internal/features/auth/dal/me.go @@ -7,6 +7,7 @@ package dal import ( "context" + "github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/log" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" @@ -14,22 +15,27 @@ import ( "origadmin/application/admin/internal/features/auth/dto" ) -type meRepo struct { +type MeRepo struct { db *ent.Database log *log.Helper } // NewMeRepo . func NewMeRepo(db *ent.Database, logger log.Logger) dto.MeRepo { - return &meRepo{ + return &MeRepo{ db: db, log: log.NewHelper(logger), } } -func (r *meRepo) GetProfile(ctx context.Context, userID int64) (*types.User, error) { +func (r *MeRepo) GetProfile(ctx context.Context, userID int64) (*types.User, error) { u, err := r.db.User(ctx).Query().Where(user.ID(userID)).Only(ctx) if err != nil { + // CORRECTED: Check for a "not found" error and return a specific, application-level error. + if ent.IsNotFound(err) { + return nil, errors.NotFound("USER_NOT_FOUND", "User not found") + } + // For all other errors, return them as is. return nil, err } return dto.ConvertUserToUserPB(u), nil diff --git a/internal/features/auth/dto/casbin.go b/internal/features/auth/dto/casbin.go index 357c03b1..4edce9f0 100644 --- a/internal/features/auth/dto/casbin.go +++ b/internal/features/auth/dto/casbin.go @@ -18,7 +18,7 @@ type ( ListGroupingsResponse = pb.ListGroupingsResponse ) -type CasbinSourceRepo interface { +type CasbinRepo interface { ListPolicies(context.Context, *ListPoliciesRequest) (*ListPoliciesResponse, error) ListGroupings(context.Context, *ListGroupingsRequest) (*ListGroupingsResponse, error) } diff --git a/internal/features/auth/server/server.go b/internal/features/auth/server/server.go index b73da800..2c8beabe 100644 --- a/internal/features/auth/server/server.go +++ b/internal/features/auth/server/server.go @@ -26,7 +26,7 @@ func NewServers( cfg *transportv1.Servers, authSvc *service.AuthService, meSvc *service.MeService, - casbinSvc *service.CasbinSourceService, + casbinSvc *service.CasbinService, logger log.Logger, ) ([]transport.Server, error) { if cfg == nil { @@ -66,7 +66,7 @@ func NewHTTPServer( cfg *httpv1.Server, authSvc *service.AuthService, meSvc *service.MeService, - casbinSvc *service.CasbinSourceService, + casbinSvc *service.CasbinService, logger log.Logger, ) (*http.Server, error) { if cfg == nil { @@ -98,7 +98,7 @@ func NewGRPCServer( cfg *grpcv1.Server, authSvc *service.AuthService, meSvc *service.MeService, - casbinSvc *service.CasbinSourceService, + casbinSvc *service.CasbinService, logger log.Logger, ) (*grpc.Server, error) { if cfg == nil { diff --git a/internal/features/auth/service/auth.go b/internal/features/auth/service/auth.go index 8c70c066..f7d6346d 100644 --- a/internal/features/auth/service/auth.go +++ b/internal/features/auth/service/auth.go @@ -9,7 +9,6 @@ import ( securityv1 "github.com/origadmin/contrib/api/gen/go/security/v1" "github.com/origadmin/contrib/security/credential" securityPrincipal "github.com/origadmin/contrib/security/principal" - "github.com/origadmin/runtime/log" v1 "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/features/auth/biz" "origadmin/application/admin/internal/helpers/captcha" @@ -18,20 +17,20 @@ import ( // AuthService is a service for authentication. type AuthService struct { v1.UnimplementedAuthServiceServer - uc *biz.AuthUseCase - captcha *captcha.Captcha - creator credential.Creator + uc *biz.AuthUseCase + captchaUC *biz.CaptchaUseCase + creator credential.Creator } // NewAuthService creates a new authentication service. -func NewAuthService(uc *biz.AuthUseCase, captcha *captcha.Captcha, creator credential.Creator) *AuthService { - return &AuthService{uc: uc, captcha: captcha, creator: creator} +func NewAuthService(uc *biz.AuthUseCase, cuc *biz.CaptchaUseCase, creator credential.Creator) *AuthService { + return &AuthService{uc: uc, captchaUC: cuc, creator: creator} } // Login authenticates a user and returns a token pair. func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.LoginResponse, error) { // Verify captcha - if !s.captcha.Verify(req.GetCaptchaId(), req.GetCaptchaCode(), true) { + if !s.captchaUC.VerifyCaptcha(ctx, req.GetCaptchaId(), req.GetCaptchaCode()) { return nil, errors.New(400, "CAPTCHA_INVALID", "invalid captcha") } @@ -64,14 +63,31 @@ func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.Logi // GetCaptcha generates a new captcha. func (s *AuthService) GetCaptcha(ctx context.Context, req *v1.GetCaptchaRequest) (*v1.GetCaptchaResponse, error) { - id, b64s, answer, err := s.captcha.GenerateDigit() + captchaType := req.GetCaptchaType() + if captchaType == "" { + captchaType = captcha.TypeDigit + } + + if captchaType == captcha.TypeAudio { + b64s, err := s.captchaUC.GetCaptchaAudio(ctx, req.GetCaptchaId()) + if err != nil { + return nil, err + } + return &v1.GetCaptchaResponse{ + CaptchaId: req.GetCaptchaId(), + CaptchaData: b64s, + MimeType: captcha.MimeTypeAudio, + }, nil + } + + id, b64s, _, err := s.captchaUC.GenerateCaptcha(ctx, captchaType) if err != nil { return nil, err } - log.Infof("Captcha generated: id=%s, answer=%s", id, answer) return &v1.GetCaptchaResponse{ - CaptchaId: id, - CaptchaImage: b64s, + CaptchaId: id, + CaptchaData: b64s, + MimeType: captcha.MimeTypeImage, }, nil } diff --git a/internal/features/auth/service/casbin.go b/internal/features/auth/service/casbin.go index 78e22153..d2f0c753 100644 --- a/internal/features/auth/service/casbin.go +++ b/internal/features/auth/service/casbin.go @@ -6,37 +6,37 @@ import ( v1 "origadmin/application/admin/api/v1/services/auth" ) -// CasbinSourceService is a service for Casbin. -type CasbinSourceService struct { +// CasbinService is a service for Casbin. +type CasbinService struct { v1.UnimplementedCasbinServiceServer } -func (s *CasbinSourceService) mustEmbedUnimplementedCasbinServiceServer() { +func (s *CasbinService) mustEmbedUnimplementedCasbinServiceServer() { //TODO implement me panic("implement me") } -// NewCasbinSourceService creates a new Casbin source service. -func NewCasbinSourceService() *CasbinSourceService { - return &CasbinSourceService{} +// NewCasbinService creates a new Casbin source service. +func NewCasbinService() *CasbinService { + return &CasbinService{} } // ListPolicies returns a list of policies. -func (s *CasbinSourceService) ListPolicies(ctx context.Context, req *v1.ListPoliciesRequest) (*v1.ListPoliciesResponse, error) { +func (s *CasbinService) ListPolicies(ctx context.Context, req *v1.ListPoliciesRequest) (*v1.ListPoliciesResponse, error) { return &v1.ListPoliciesResponse{}, nil } // ListGroupings returns a list of groupings. -func (s *CasbinSourceService) ListGroupings(ctx context.Context, req *v1.ListGroupingsRequest) (*v1.ListGroupingsResponse, error) { +func (s *CasbinService) ListGroupings(ctx context.Context, req *v1.ListGroupingsRequest) (*v1.ListGroupingsResponse, error) { return &v1.ListGroupingsResponse{}, nil } // WatchUpdate returns a watch update. -func (s *CasbinSourceService) WatchUpdate(ctx context.Context, req *v1.WatchUpdateRequest) (*v1.WatchUpdateResponse, error) { +func (s *CasbinService) WatchUpdate(ctx context.Context, req *v1.WatchUpdateRequest) (*v1.WatchUpdateResponse, error) { return &v1.WatchUpdateResponse{}, nil } // StreamRules returns a stream of rules. -func (s *CasbinSourceService) StreamRules(req *v1.StreamRulesRequest, stream v1.CasbinService_StreamRulesServer) error { +func (s *CasbinService) StreamRules(req *v1.StreamRulesRequest, stream v1.CasbinService_StreamRulesServer) error { return nil } diff --git a/internal/features/auth/service/me.go b/internal/features/auth/service/me.go index 1c69fd5d..81481e97 100644 --- a/internal/features/auth/service/me.go +++ b/internal/features/auth/service/me.go @@ -2,7 +2,11 @@ package service import ( "context" + "strconv" + "github.com/go-kratos/kratos/v2/errors" + + "github.com/origadmin/contrib/security/principal" v1 "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/features/auth/biz" ) @@ -20,8 +24,18 @@ func NewMeService(uc *biz.MeUseCase) *MeService { // GetProfile retrieves the profile of the currently authenticated user. func (s *MeService) GetProfile(ctx context.Context, req *v1.GetProfileRequest) (*v1.GetProfileResponse, error) { - // TODO: Get userID from context - userID := int64(1) // Placeholder + // Get the principal from the context, which is populated by the auth middleware. + p, ok := principal.FromContext(ctx) + if !ok { + return nil, errors.Unauthorized("UNAUTHORIZED", "Missing user principal in context") + } + + // The principal's ID is a string, so it needs to be converted to an integer. + userID, err := strconv.ParseInt(p.GetID(), 10, 64) + if err != nil { + return nil, errors.InternalServer("INVALID_PRINCIPAL_ID", "User ID in principal is not a valid integer") + } + user, err := s.uc.GetProfile(ctx, userID) if err != nil { return nil, err diff --git a/internal/features/auth/service/provider.go b/internal/features/auth/service/provider.go index feaa45fe..929841ed 100644 --- a/internal/features/auth/service/provider.go +++ b/internal/features/auth/service/provider.go @@ -3,4 +3,4 @@ package service import "github.com/google/wire" // ProviderSet is service providers. -var ProviderSet = wire.NewSet(NewAuthService, NewMeService, NewCasbinSourceService) +var ProviderSet = wire.NewSet(NewAuthService, NewMeService, NewCasbinService) diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index f3ef62f8..1fb273e6 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -19,6 +19,7 @@ import ( "github.com/origadmin/runtime/service/transport" "github.com/origadmin/runtime/service/transport/http" "origadmin/application/admin/internal/gateway/service" + "origadmin/application/admin/internal/gateway/web" ) // ProviderSet is server providers. @@ -63,7 +64,7 @@ func NewServers( // NewHTTPServer creates a new HTTP server and registers all downstream service handlers. func NewHTTPServer( - _ *runtime.App, + app *runtime.App, cfg *httpv1.Server, svc *service.GatewayService, middlewareProvider container.ServerMiddlewareProvider, @@ -76,10 +77,23 @@ func NewHTTPServer( if err != nil { return nil, err } + + serverOpts := []kratoshttp.ServerOption{ + kratoshttp.PathPrefix("/api/v1"), + } + + // Try to get the handler for the embedded Web UI. + webUIHandler, err := web.GetHandler() + if err == nil { + log.NewHelper(app.Logger()).Info("msg", "Embedded Web UI is enabled and will be served.") + // If the handler is available, register it for the root path. + serverOpts = append(serverOpts) + } else { + log.NewHelper(app.Logger()).Warn("msg", "Embedded Web UI is disabled. To enable, build with '-tags embed_ui'.") + } + opts := &http.ServerOptions{ - ServerOptions: []kratoshttp.ServerOption{ - kratoshttp.PathPrefix("/api/v1"), - }, + ServerOptions: serverOpts, ServerMiddlewares: mws, } @@ -89,6 +103,8 @@ func NewHTTPServer( } // Register all services using the GatewayService method. svc.RegisterHTTPHandlers(srv) + srv.HandlePrefix("/", webUIHandler) + // Log all registered HTTP routes for debugging and verification srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { log.Infof("HTTP %s %s", method, path) diff --git a/internal/helpers/captcha/captcha.go b/internal/helpers/captcha/captcha.go index 337ab267..3a5b0284 100644 --- a/internal/helpers/captcha/captcha.go +++ b/internal/helpers/captcha/captcha.go @@ -6,6 +6,7 @@ package captcha import ( + "fmt" "net/http" "github.com/mojocn/base64Captcha" @@ -13,12 +14,15 @@ import ( "github.com/origadmin/runtime/errors" typespb "origadmin/application/admin/api/v1/services/types" + confpb "origadmin/application/admin/internal/conf/pb" ) var ( + // ErrNotFound is returned when a captcha ID is not found in the store. ErrNotFound = errors.New(http.StatusBadRequest, typespb.AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND.String(), "captcha not found") ) +// Constants for different captcha types. const ( TypeAudio = "audio" TypeString = "string" @@ -27,11 +31,13 @@ const ( TypeMath = "math" ) +// Constants for MIME types. const ( MimeTypeAudio = base64Captcha.MimeTypeAudio MimeTypeImage = base64Captcha.MimeTypeImage ) +// Type aliases for base64Captcha types. type ( Store = base64Captcha.Store Driver = base64Captcha.Driver @@ -42,16 +48,14 @@ type ( DriverDigit = base64Captcha.DriverDigit ) -//Captcha json request body. +// Captcha provides an interface for generating and verifying captchas. type Captcha struct { - Store Store - DriverAudio *base64Captcha.Captcha - DriverString *base64Captcha.Captcha - DriverChinese *base64Captcha.Captcha - DriverMath *base64Captcha.Captcha - DriverDigit *base64Captcha.Captcha + store Store + captchas map[string]*base64Captcha.Captcha + drivers map[string]base64Captcha.Driver } +// Config holds the configuration for the captcha service. type Config struct { Store Store DriverAudio *DriverAudio @@ -59,8 +63,11 @@ type Config struct { DriverChinese *DriverChinese DriverMath *DriverMath DriverDigit *DriverDigit + Captcha *confpb.Captcha } +// NewCaptcha creates a new Captcha instance with the given configuration. +// It initializes default drivers for various captcha types if they are not provided. func NewCaptcha(config *Config) *Captcha { if config == nil { config = &Config{} @@ -68,37 +75,117 @@ func NewCaptcha(config *Config) *Captcha { if config.Store == nil { config.Store = base64Captcha.DefaultMemStore } - if config.DriverAudio == nil { - config.DriverAudio = base64Captcha.DefaultDriverAudio + if config.Captcha == nil { + config.Captcha = &confpb.Captcha{} } + + drivers := make(map[string]base64Captcha.Driver) + captchas := make(map[string]*base64Captcha.Captcha) + + // Initialize Digit Driver if config.DriverDigit == nil { - config.DriverDigit = base64Captcha.DefaultDriverDigit + config.DriverDigit = &base64Captcha.DriverDigit{ + Height: int(config.Captcha.GetHeight()), + Width: int(config.Captcha.GetWidth()), + Length: int(config.Captcha.GetLength()), + MaxSkew: float64(config.Captcha.GetMaxskew()), + DotCount: int(config.Captcha.GetDotCount()), + } + } + drivers[TypeDigit] = config.DriverDigit + captchas[TypeDigit] = base64Captcha.NewCaptcha(config.DriverDigit, config.Store) + + // Initialize String Driver + if config.DriverString == nil { + config.DriverString = &base64Captcha.DriverString{ + Height: int(config.Captcha.GetHeight()), + Width: int(config.Captcha.GetWidth()), + NoiseCount: int(config.Captcha.GetDotCount()), + ShowLineOptions: base64Captcha.OptionShowHollowLine, + Length: int(config.Captcha.GetLength()), + Source: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", + } } + drivers[TypeString] = config.DriverString + captchas[TypeString] = base64Captcha.NewCaptcha(config.DriverString, config.Store) + + // Initialize Chinese Driver + if config.DriverChinese == nil { + config.DriverChinese = &base64Captcha.DriverChinese{ + Height: int(config.Captcha.GetHeight()), + Width: int(config.Captcha.GetWidth()), + NoiseCount: int(config.Captcha.GetDotCount()), + ShowLineOptions: base64Captcha.OptionShowSlimeLine, + Length: int(config.Captcha.GetLength()), + Source: "的一是在不了有和人这中大为上个国我以要他时来用们生到作地于出就分对成会可主发年动同工也能下过子说产种面而方后多定行学法所民得经十三之进着等", + } + } + drivers[TypeChinese] = config.DriverChinese + captchas[TypeChinese] = base64Captcha.NewCaptcha(config.DriverChinese, config.Store) + + // Initialize Math Driver + if config.DriverMath == nil { + config.DriverMath = &base64Captcha.DriverMath{ + Height: int(config.Captcha.GetHeight()), + Width: int(config.Captcha.GetWidth()), + NoiseCount: int(config.Captcha.GetDotCount()), + ShowLineOptions: base64Captcha.OptionShowSineLine, + } + } + drivers[TypeMath] = config.DriverMath + captchas[TypeMath] = base64Captcha.NewCaptcha(config.DriverMath, config.Store) + + // Initialize Audio Driver + if config.DriverAudio == nil { + config.DriverAudio = base64Captcha.DefaultDriverAudio + } + drivers[TypeAudio] = config.DriverAudio + captchas[TypeAudio] = base64Captcha.NewCaptcha(config.DriverAudio, config.Store) + return &Captcha{ - DriverAudio: base64Captcha.NewCaptcha(config.DriverAudio, config.Store), - DriverDigit: base64Captcha.NewCaptcha(config.DriverDigit, config.Store), - Store: config.Store, + store: config.Store, + captchas: captchas, + drivers: drivers, } } -func (c *Captcha) GenerateDigit() (id, b64s, answer string, err error) { - return c.DriverDigit.Generate() +// Generate creates a new captcha of the specified type. +// It returns the captcha ID, the base64 encoded image or audio, the answer, and an error if any. +func (c *Captcha) Generate(captchaType string) (id, b64s, answer string, err error) { + captcha, ok := c.captchas[captchaType] + if !ok { + return "", "", "", errors.New(http.StatusBadRequest, "INVALID_CAPTCHA_TYPE", fmt.Sprintf("invalid captcha type: %s", captchaType)) + } + return captcha.Generate() } -func (c *Captcha) GenerateString() (id, b64s, answer string, err error) { - return c.DriverString.Generate() -} +// GetAudioForID generates an audio representation for an existing captcha ID. +// This is useful for accessibility purposes, allowing users to listen to a captcha. +func (c *Captcha) GetAudioForID(id string) (b64s string, err error) { + // Get the answer from the store without clearing it. + answer := c.store.Get(id, false) + if answer == "" { + return "", ErrNotFound + } -func (c *Captcha) GenerateAudio() (id, b64s, answer string, err error) { - return c.DriverAudio.Generate() -} + // Get the audio driver. + audioDriver, ok := c.drivers[TypeAudio].(*DriverAudio) + if !ok { + // This should not happen if the captcha service is configured correctly. + return "", errors.New(http.StatusInternalServerError, "AUDIO_DRIVER_NOT_CONFIGURED", "audio driver is not configured") + } -func (c *Captcha) GenerateChinese() (id, b64s, answer string, err error) { - return c.DriverChinese.Generate() -} + // Generate audio content using the retrieved answer. + audio, err := audioDriver.DrawCaptcha(answer) + if err != nil { + return "", err + } -func (c *Captcha) ServerHTTP(w http.ResponseWriter, r *http.Request) {} + return audio.EncodeB64string(), nil +} +// Verify checks if the provided answer for a given captcha ID is correct. +// The `clear` parameter determines whether to remove the captcha from the store after verification. func (c *Captcha) Verify(id, answer string, clear bool) bool { - return c.Store.Verify(id, answer, clear) + return c.store.Verify(id, answer, clear) } diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go index 4a502cd8..98c1fbae 100644 --- a/internal/helpers/providers/providers.go +++ b/internal/helpers/providers/providers.go @@ -154,14 +154,8 @@ func ProvideCaptcha(p container.CacheProvider, cfg *confpb.Captcha) (*captcha.Ca } c := &captcha.Config{ - Store: captcha.NewStore(cache), - DriverDigit: &captcha.DriverDigit{ - Height: int(cfg.GetHeight()), - Width: int(cfg.GetWidth()), - Length: int(cfg.GetLength()), - MaxSkew: float64(cfg.GetMaxskew()), - DotCount: int(cfg.GetDotCount()), - }, + Store: captcha.NewStore(cache), + Captcha: cfg, } return captcha.NewCaptcha(c), nil } @@ -257,8 +251,9 @@ var ProviderBackendSet = wire.NewSet( ) var ProviderSet = wire.NewSet( - // Instructions for wire to extract nested configs + // CORRECTED: Added FieldsOf for Security to ensure it's provided to the authenticator. wire.FieldsOf(new(*conf.Config), "Bootstrap"), + wire.FieldsOf(new(*confpb.Bootstrap), "Security"), wire.FieldsOf(new(*confpb.Bootstrap), "Servers"), wire.FieldsOf(new(*confpb.Bootstrap), "Captcha"), ProvideLogger, diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 29f169fb..ed3eb1e0 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -17,6 +17,36 @@ servers: - url: http://localhost:10080 - url: https://localhost:10080 paths: + /auth/captcha: + get: + tags: + - AuthService + description: GetCaptcha generates a new captcha. + operationId: AuthService_GetCaptcha + parameters: + - name: captcha_id + in: query + description: The ID of an existing captcha, used for refreshing or getting audio. + schema: + type: string + - name: captcha_type + in: query + description: The type of captcha to generate (e.g., "digit", "string", "math", "chinese", "audio"). + schema: + type: string + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/api.v1.services.auth.GetCaptchaResponse' + default: + description: Default error response + content: + application/json: + schema: + $ref: '#/components/schemas/google.rpc.Status' /auth/login: post: tags: @@ -117,31 +147,6 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /captcha: - get: - tags: - - AuthService - description: GetCaptcha generates a new captcha. - operationId: AuthService_GetCaptcha - parameters: - - name: reload - in: query - description: If true, forces reloading of the captcha. - schema: - type: boolean - responses: - "200": - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/api.v1.services.auth.GetCaptchaResponse' - default: - description: Default error response - content: - application/json: - schema: - $ref: '#/components/schemas/google.rpc.Status' /casbin/groupings: get: tags: @@ -2148,9 +2153,13 @@ components: properties: captcha_id: type: string - captcha_image: + description: The unique identifier for the generated captcha. + captcha_data: + type: string + description: Base64 encoded data of the captcha (image or audio). + mime_type: type: string - description: Base64 encoded image data. + description: The MIME type of the captcha data (e.g., "image/png", "audio/wav"). description: The response message for the GetCaptcha RPC. api.v1.services.auth.GetProfileResponse: type: object diff --git a/tools.go b/tools.go index 92db8ef2..c140205a 100644 --- a/tools.go +++ b/tools.go @@ -4,6 +4,7 @@ package tools import ( _ "entgo.io/ent/cmd/ent" + _ "github.com/air-verse/air" // Add air for live-reloading _ "github.com/bufbuild/buf/cmd/buf" _ "github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking" _ "github.com/bufbuild/buf/cmd/protoc-gen-buf-lint" From b7ad601997f35b8d2950f55a96c2bd9244dabd3f Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 5 Jan 2026 14:55:02 +0800 Subject: [PATCH 142/158] feat(auth): implement custom type conversions and enhance server middleware integration --- cmd/auth/wire.go | 4 +- cmd/auth/wire_gen.go | 13 ++++- cmd/gateway/wire.go | 1 + go.mod | 6 +- internal/features/auth/dto/custom.gen.go | 48 --------------- internal/features/auth/dto/dto.go | 62 ++++++++++++++++++++ internal/features/auth/dto/view_type.go | 74 ++++++++++++++++++++++++ internal/features/auth/server/server.go | 67 ++++++++++++--------- internal/features/auth/service/me.go | 2 + 9 files changed, 197 insertions(+), 80 deletions(-) create mode 100644 internal/features/auth/dto/view_type.go diff --git a/cmd/auth/wire.go b/cmd/auth/wire.go index 4203a6c0..ae0e7d50 100644 --- a/cmd/auth/wire.go +++ b/cmd/auth/wire.go @@ -7,7 +7,7 @@ import ( "github.com/go-kratos/kratos/v2" "github.com/google/wire" - "github.comcom/origadmin/runtime" + "github.com/origadmin/runtime" "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/data" "origadmin/application/admin/internal/features/auth/biz" @@ -22,7 +22,7 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err panic(wire.Build( // Shared infrastructure providers providers.ProviderSet, - providers.ProviderBackendSet, // CORRECTED: Added the backend-specific security middleware providers. + providers.ProviderBackendSet, // Service-specific providers data.ProviderSet, diff --git a/cmd/auth/wire_gen.go b/cmd/auth/wire_gen.go index 5432f09f..5f234b72 100644 --- a/cmd/auth/wire_gen.go +++ b/cmd/auth/wire_gen.go @@ -74,7 +74,18 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err meUseCase := biz.NewMeUseCase(meRepo, v) meService := service.NewMeService(meUseCase) casbinService := service.NewCasbinService() - v2, err := server.NewServers(servers, authService, meService, casbinService, v) + authorizer, err := providers.ProvideAuthorizer(app, bootstrap, database) + if err != nil { + cleanup() + return nil, nil, err + } + skipChecker := providers.ProvideSkipChecker(app, bootstrap) + serverMiddlewareProvider, err := providers.ProvideServiceMiddlewares(app, authorizer, skipChecker) + if err != nil { + cleanup() + return nil, nil, err + } + v2, err := server.NewServers(app, servers, authService, meService, casbinService, serverMiddlewareProvider) if err != nil { cleanup() return nil, nil, err diff --git a/cmd/gateway/wire.go b/cmd/gateway/wire.go index 4cf17f35..0b1a1e1c 100644 --- a/cmd/gateway/wire.go +++ b/cmd/gateway/wire.go @@ -26,6 +26,7 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err // Shared infrastructure providers providers.ProviderSet, providers.ProviderGatewaySet, + // Service-specific providers server.ProviderSet, service.ProviderSet, diff --git a/go.mod b/go.mod index a0a16444..59864c9b 100644 --- a/go.mod +++ b/go.mod @@ -4,9 +4,9 @@ go 1.25.3 replace github.com/armon/go-metrics v0.5.4 => github.com/origadmin/go-metrics v0.5.4 -//replace github.com/origadmin/runtime v0.2.15 => ../../runtime -// -//replace github.com/origadmin/contrib v1.1.0 => ../../contrib +replace github.com/origadmin/runtime v0.2.15 => ../../runtime + +replace github.com/origadmin/contrib v1.1.0 => ../../contrib require ( entgo.io/ent v0.14.5 diff --git a/internal/features/auth/dto/custom.gen.go b/internal/features/auth/dto/custom.gen.go index 5435a449..263fb2d7 100644 --- a/internal/features/auth/dto/custom.gen.go +++ b/internal/features/auth/dto/custom.gen.go @@ -2,51 +2,3 @@ // More info: https://github.com/origadmin/abgen package dto - -import ( - "origadmin/application/admin/internal/data/entity/ent/resource" - "origadmin/application/admin/internal/data/entity/ent/user" - "origadmin/application/admin/internal/data/entity/ent/view" -) - -// ConvertGenderToString is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertGenderToString(from user.Gender) string { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} - -// ConvertInt32ToStatus is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertInt32ToStatus(from int32) resource.Status { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} - -// ConvertStatusToInt32 is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertStatusToInt32(from resource.Status) int32 { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} - -// ConvertStringToGender is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertStringToGender(from string) user.Gender { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} - -// ConvertStringToType is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertStringToType(from string) view.Type { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} - -// ConvertTypeToString is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertTypeToString(from view.Type) string { - // TODO: Implement this custom conversion - panic("stub! not implemented") -} diff --git a/internal/features/auth/dto/dto.go b/internal/features/auth/dto/dto.go index f1bd0eae..68df9567 100644 --- a/internal/features/auth/dto/dto.go +++ b/internal/features/auth/dto/dto.go @@ -5,6 +5,12 @@ // Package dto is the data transfer object package for the auth module. package dto +import ( + "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/entity/ent/user" + "origadmin/application/admin/internal/data/entity/ent/view" +) + //go:generate abgen -debug . //go:abgen:package:path=origadmin/application/admin/internal/data/entity/ent,alias=ent @@ -13,3 +19,59 @@ package dto //go:abgen:convert:direction="both" //go:abgen:convert:source:suffix="" //go:abgen:convert:target:suffix="PB" + +// ConvertGenderToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertGenderToString(from user.Gender) string { + switch from { + case user.GenderFemale: + return "female" + default: + return "male" + } +} + +// ConvertStringToGender is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToGender(from string) user.Gender { + switch from { + case "female": + return user.GenderFemale + default: + return user.GenderMale + } +} + +// ConvertStringToType is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToType(from string) view.Type { + return ViewTypeCode(from) +} + +// ConvertTypeToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertTypeToString(from view.Type) string { + return ViewTypeName(from) +} + +// ConvertInt32ToStatus is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertInt32ToStatus(from int32) resource.Status { + switch from { + case 1: + return resource.StatusEnabled + default: + return resource.StatusDisabled + } +} + +// ConvertStatusToInt32 is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStatusToInt32(from resource.Status) int32 { + switch from { + case resource.StatusEnabled: + return 1 + default: + return 0 + } +} diff --git a/internal/features/auth/dto/view_type.go b/internal/features/auth/dto/view_type.go new file mode 100644 index 00000000..37bb79ee --- /dev/null +++ b/internal/features/auth/dto/view_type.go @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +// Package dto implements the functions, types, and interfaces for the module. +package dto + +import ( + "strings" + + "origadmin/application/admin/internal/data/entity/ent/view" +) + +const ( + ViewTypeRoot = view.TypeT + ViewTypeGroup = view.TypeG + ViewTypeMenu = view.TypeM + ViewTypeLink = view.TypeL + ViewTypePage = view.TypeP + ViewTypeButton = view.TypeB + ViewTypeElement = view.TypeE + ViewTypeRedirect = view.TypeR + ViewTypeUnknown = view.TypeU +) + +type ViewType = view.Type + +// ViewTypeName returns the name of the resource type +func ViewTypeName(str ViewType) string { + switch str { + case ViewTypeMenu: + return "Menu" + case ViewTypePage: + return "Page" + case ViewTypeButton: + return "Button" + case ViewTypeElement: + return "Element" + case ViewTypeRedirect: + return "Redirect" + case ViewTypeRoot: + return "Root" + case ViewTypeGroup: + return "Group" + case ViewTypeLink: + return "Link" + default: + return "Unknown" + } +} + +// ViewTypeCode returns the code of the resource type +func ViewTypeCode(s string) ViewType { + switch strings.ToLower(s) { + case "menu": + return ViewTypeMenu + case "page": + return ViewTypePage + case "button": + return ViewTypeButton + case "redirect": + return ViewTypeRedirect + case "root": + return ViewTypeRoot + case "group": + return ViewTypeGroup + case "link": + return ViewTypeLink + case "element": + return ViewTypeElement + default: + return ViewTypeUnknown + } +} diff --git a/internal/features/auth/server/server.go b/internal/features/auth/server/server.go index 2c8beabe..d9b231e0 100644 --- a/internal/features/auth/server/server.go +++ b/internal/features/auth/server/server.go @@ -1,21 +1,26 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + package server import ( "errors" stdhttp "net/http" - "github.com/go-kratos/kratos/v2/transport" - "github.com/go-kratos/kratos/v2/transport/grpc" - "github.com/go-kratos/kratos/v2/transport/http" "github.com/google/wire" - "github.com/origadmin/runtime/log" - authv1 "origadmin/application/admin/api/v1/services/auth" - "origadmin/application/admin/internal/features/auth/service" - + "github.com/origadmin/runtime" grpcv1 "github.com/origadmin/runtime/api/gen/go/config/transport/grpc/v1" httpv1 "github.com/origadmin/runtime/api/gen/go/config/transport/http/v1" transportv1 "github.com/origadmin/runtime/api/gen/go/config/transport/v1" + "github.com/origadmin/runtime/container" + "github.com/origadmin/runtime/log" + "github.com/origadmin/runtime/service/transport" + "github.com/origadmin/runtime/service/transport/grpc" + "github.com/origadmin/runtime/service/transport/http" + authv1 "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/internal/features/auth/service" ) // ProviderSet is server providers. @@ -23,11 +28,12 @@ var ProviderSet = wire.NewSet(NewServers) // NewServers creates and configures the auth service servers (gRPC, HTTP). func NewServers( + app *runtime.App, cfg *transportv1.Servers, authSvc *service.AuthService, meSvc *service.MeService, casbinSvc *service.CasbinService, - logger log.Logger, + middlewareProvider container.ServerMiddlewareProvider, ) ([]transport.Server, error) { if cfg == nil { return nil, errors.New("servers config is nil") @@ -40,13 +46,13 @@ func NewServers( } switch serverCfg.GetProtocol() { case "http": - srv, err := NewHTTPServer(serverCfg.GetHttp(), authSvc, meSvc, casbinSvc, logger) + srv, err := NewHTTPServer(app, serverCfg.GetHttp(), authSvc, meSvc, casbinSvc, middlewareProvider) if err != nil { return nil, err } transportServers = append(transportServers, srv) case "grpc": - srv, err := NewGRPCServer(serverCfg.GetGrpc(), authSvc, meSvc, casbinSvc, logger) + srv, err := NewGRPCServer(app, serverCfg.GetGrpc(), authSvc, meSvc, casbinSvc, middlewareProvider) if err != nil { return nil, err } @@ -63,24 +69,29 @@ func NewServers( // NewHTTPServer new an HTTP server. func NewHTTPServer( + _ *runtime.App, cfg *httpv1.Server, authSvc *service.AuthService, meSvc *service.MeService, casbinSvc *service.CasbinService, - logger log.Logger, -) (*http.Server, error) { + provider container.ServerMiddlewareProvider, +) (*transport.HTTPServer, error) { if cfg == nil { return nil, errors.New("http config is nil") } - var opts []http.ServerOption - if cfg.GetAddr() != "" { - opts = append(opts, http.Address(cfg.GetAddr())) + mws, err := provider.ServerMiddlewares() + if err != nil { + return nil, err } - if cfg.GetTimeout() != nil { - opts = append(opts, http.Timeout(cfg.GetTimeout().AsDuration())) + opts := &http.ServerOptions{ + ServerMiddlewares: mws, + } + + srv, err := http.NewServer(cfg, opts) + if err != nil { + return nil, err } - srv := http.NewServer(opts...) // Register HTTP handlers authv1.RegisterAuthServiceHTTPServer(srv, authSvc) @@ -95,24 +106,28 @@ func NewHTTPServer( // NewGRPCServer new a gRPC server. func NewGRPCServer( + _ *runtime.App, cfg *grpcv1.Server, authSvc *service.AuthService, meSvc *service.MeService, casbinSvc *service.CasbinService, - logger log.Logger, -) (*grpc.Server, error) { + provider container.ServerMiddlewareProvider, +) (*transport.GRPCServer, error) { if cfg == nil { return nil, errors.New("grpc config is nil") } - var opts []grpc.ServerOption - if cfg.GetAddr() != "" { - opts = append(opts, grpc.Address(cfg.GetAddr())) + mws, err := provider.ServerMiddlewares() + if err != nil { + return nil, err + } + opts := &grpc.ServerOptions{ + ServerMiddlewares: mws, } - if cfg.GetTimeout() != nil { - opts = append(opts, grpc.Timeout(cfg.GetTimeout().AsDuration())) + srv, err := grpc.NewServer(cfg, opts) + if err != nil { + return nil, err } - srv := grpc.NewServer(opts...) // Register gRPC handlers authv1.RegisterAuthServiceServer(srv, authSvc) diff --git a/internal/features/auth/service/me.go b/internal/features/auth/service/me.go index 81481e97..1e49ad4e 100644 --- a/internal/features/auth/service/me.go +++ b/internal/features/auth/service/me.go @@ -7,6 +7,7 @@ import ( "github.com/go-kratos/kratos/v2/errors" "github.com/origadmin/contrib/security/principal" + "github.com/origadmin/runtime/log" v1 "origadmin/application/admin/api/v1/services/auth" "origadmin/application/admin/internal/features/auth/biz" ) @@ -27,6 +28,7 @@ func (s *MeService) GetProfile(ctx context.Context, req *v1.GetProfileRequest) ( // Get the principal from the context, which is populated by the auth middleware. p, ok := principal.FromContext(ctx) if !ok { + log.Debugf("context type %T", ctx) return nil, errors.Unauthorized("UNAUTHORIZED", "Missing user principal in context") } From c663951a642fbdd53dca32b347dbd2aa2c248cd3 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 5 Jan 2026 17:05:04 +0800 Subject: [PATCH 143/158] feat(web): implement embedded UI with build tags and enhance logging middleware registration --- internal/conf/config.go | 4 +++ internal/gateway/server/server.go | 6 ++-- internal/gateway/web/embed_real.go | 42 +++++++++++++++++++++++++ internal/gateway/web/embed_stub.go | 15 +++++++++ internal/helpers/providers/providers.go | 8 +++-- resources/configs/bootstrap.yaml | 3 ++ resources/configs/logger.yaml | 2 +- resources/configs/middlewares.yaml | 16 ++++++++-- resources/configs/server.yaml | 5 +++ 9 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 internal/gateway/web/embed_real.go create mode 100644 internal/gateway/web/embed_stub.go diff --git a/internal/conf/config.go b/internal/conf/config.go index 1758e2fd..3319cbc1 100644 --- a/internal/conf/config.go +++ b/internal/conf/config.go @@ -139,6 +139,10 @@ func (c *Config) Transform(config interfaces.ConfigLoader, sc interfaces.Structu if err != nil { return nil, err } + //var debugMap map[string]any + //if err = config.Decode("", &debugMap); err != nil { + // return nil, err + //} return c, nil } diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index 1fb273e6..5a9945a4 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -10,6 +10,7 @@ import ( "github.com/go-kratos/kratos/v2/log" kratoshttp "github.com/go-kratos/kratos/v2/transport/http" + "github.com/goexts/generic/maps" "github.com/google/wire" "github.com/origadmin/runtime" @@ -85,13 +86,14 @@ func NewHTTPServer( // Try to get the handler for the embedded Web UI. webUIHandler, err := web.GetHandler() if err == nil { - log.NewHelper(app.Logger()).Info("msg", "Embedded Web UI is enabled and will be served.") + log.NewHelper(app.Logger()).Infow("msg", "Embedded Web UI is enabled and will be served.") // If the handler is available, register it for the root path. serverOpts = append(serverOpts) } else { - log.NewHelper(app.Logger()).Warn("msg", "Embedded Web UI is disabled. To enable, build with '-tags embed_ui'.") + log.NewHelper(app.Logger()).Warnw("msg", "Embedded Web UI is disabled. To enable, build with '-tags embed_ui'.") } + log.NewHelper(app.Logger()).Infow("msg", "Registering middleware", "middlewares", maps.Keys(mws)) opts := &http.ServerOptions{ ServerOptions: serverOpts, ServerMiddlewares: mws, diff --git a/internal/gateway/web/embed_real.go b/internal/gateway/web/embed_real.go new file mode 100644 index 00000000..946375bd --- /dev/null +++ b/internal/gateway/web/embed_real.go @@ -0,0 +1,42 @@ +//go:build embed_ui + +package web + +import ( + "embed" + "io/fs" + "net/http" +) + +//go:embed all:../../../../resources/web +var WebUI embed.FS + +// GetHandler returns an http.Handler that serves the embedded Web UI. +// This version is compiled only when the 'embed_ui' build tag is provided. +func GetHandler() (http.Handler, error) { + // The `WebUI` embed.FS now contains the `resources/web` directory structure. + // We need to create a sub-filesystem that starts from that directory. + distFS, err := fs.Sub(WebUI, "resources/web") + if err != nil { + return nil, err + } + + // Create a file server for the sub-filesystem. + fileServer := http.FileServer(http.FS(distFS)) + + // Create a handler that serves static files and falls back to index.html for SPAs. + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Try to serve the static file first. + _, err := distFS.Open(r.URL.Path[1:]) + if err == nil { + fileServer.ServeHTTP(w, r) + return + } + + // If the file is not found, serve index.html. + r.URL.Path = "/" + fileServer.ServeHTTP(w, r) + }) + + return handler, nil +} diff --git a/internal/gateway/web/embed_stub.go b/internal/gateway/web/embed_stub.go new file mode 100644 index 00000000..57f64b36 --- /dev/null +++ b/internal/gateway/web/embed_stub.go @@ -0,0 +1,15 @@ +//go:build !embed_ui + +package web + +import ( + "errors" + "net/http" +) + +// GetHandler is a stub implementation for when the UI is not embedded. +// It returns an error, indicating that the embedded UI is not available. +// This version is compiled by default, unless the 'embed_ui' build tag is provided. +func GetHandler() (http.Handler, error) { + return nil, errors.New("web UI is not embedded in this build") +} diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go index 98c1fbae..6ad19f0b 100644 --- a/internal/helpers/providers/providers.go +++ b/internal/helpers/providers/providers.go @@ -179,7 +179,8 @@ func ProvideServiceMiddlewares(app *runtime.App, authorizer authz.Authorizer, // authz for backend provider.RegisterServerMiddleware("authz", m) provider.RegisterClientMiddleware("authz", middleware.Noop()) - + helper := log.NewHelper(app.Logger()) + helper.Infof("registered %+v middlewares", provider.Names()) return provider, nil } @@ -194,7 +195,8 @@ func ProvideGatewayMiddlewares(app *runtime.App, authenticator authn.Authenticat // authz for backend provider.RegisterServerMiddleware("authn", m) provider.RegisterClientMiddleware("authn", middleware.Noop()) - + helper := log.NewHelper(app.Logger()) + helper.Infof("registered %+v middlewares", provider.Names()) return provider, nil } @@ -208,6 +210,8 @@ func ProvideClientMiddlewares(app *runtime.App) (container.ClientMiddlewareProvi // authz for backend provider.RegisterClientMiddleware("propagation", m) provider.RegisterServerMiddleware("propagation", middleware.Noop()) + helper := log.NewHelper(app.Logger()) + helper.Infof("registered %+v client middlewares", provider.Names()) return provider, nil } diff --git a/resources/configs/bootstrap.yaml b/resources/configs/bootstrap.yaml index e77d0825..432cc4e5 100644 --- a/resources/configs/bootstrap.yaml +++ b/resources/configs/bootstrap.yaml @@ -27,5 +27,8 @@ sources: - file: path: root_user.yaml type: file + - file: + path: middlewares.yaml + type: file # Environment variables are loaded last to override file settings. - type: env diff --git a/resources/configs/logger.yaml b/resources/configs/logger.yaml index 89dcb027..1a1413bb 100644 --- a/resources/configs/logger.yaml +++ b/resources/configs/logger.yaml @@ -1,6 +1,6 @@ # logger.yaml logger: caller: true - format: text + format: dev level: debug output: stdout diff --git a/resources/configs/middlewares.yaml b/resources/configs/middlewares.yaml index 83c2f82c..e8b63d20 100644 --- a/resources/configs/middlewares.yaml +++ b/resources/configs/middlewares.yaml @@ -3,6 +3,18 @@ middlewares: configs: # Define a middleware instance named "security". # The 'type' must match the name we registered in main.go's init() function. - - name: security - type: security +# - name: security +# type: security +# enabled: true + - name: "logging" + type: "logging" + enabled: true + - name: "tracing" + type: "tracing" + enabled: true + - name: "metrics" + type: "metrics" + enabled: true + - name: "recovery" + type: "recovery" enabled: true diff --git a/resources/configs/server.yaml b/resources/configs/server.yaml index df01d378..a682515f 100644 --- a/resources/configs/server.yaml +++ b/resources/configs/server.yaml @@ -19,6 +19,7 @@ servers: - "*" allow_credentials: true middlewares: + - "recovery" - "authn" # Auth Service gRPC Server @@ -28,6 +29,7 @@ servers: addr: "0.0.0.0:9081" timeout: 5s middlewares: + - "recovery" - "authz" - name: "auth" protocol: "http" @@ -35,6 +37,7 @@ servers: addr: "0.0.0.0:9082" timeout: 5s middlewares: + - "recovery" - "authz" # System Service gRPC Server - name: "system" @@ -45,6 +48,7 @@ servers: # Apply middlewares by name. These names must correspond to entries # in the middlewares.yaml configuration file. middlewares: + - "recovery" - "authz" # System Service HTTP Server - name: "system" @@ -54,4 +58,5 @@ servers: timeout: 5s # Apply middlewares by name. middlewares: + - "recovery" - "authz" From 34c5b94ebe916b13ffcc73aa086238375a957b4e Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 6 Jan 2026 15:02:59 +0800 Subject: [PATCH 144/158] feat(api): update proto definitions and generated code for system services to use wildcard body binding --- api/v1/proto/system/permission.proto | 2 +- api/v1/proto/system/resource.proto | 2 +- api/v1/proto/system/role.proto | 2 +- api/v1/proto/system/user.proto | 4 +- api/v1/proto/system/view.proto | 2 +- api/v1/proto/types/system.proto | 8 +- api/v1/services/system/permission.pb.go | 9 +- api/v1/services/system/permission.pb.gw.go | 18 +- .../services/system/permission_bridge.pb.go | 2 +- api/v1/services/system/permission_http.pb.go | 4 +- api/v1/services/system/resource.pb.go | 8 +- api/v1/services/system/resource.pb.gw.go | 4 +- api/v1/services/system/resource_bridge.pb.go | 2 +- api/v1/services/system/resource_http.pb.go | 4 +- api/v1/services/system/role.pb.go | 8 +- api/v1/services/system/role.pb.gw.go | 18 +- api/v1/services/system/role_bridge.pb.go | 2 +- api/v1/services/system/role_http.pb.go | 4 +- api/v1/services/system/user.pb.go | 10 +- api/v1/services/system/user.pb.gw.go | 8 +- api/v1/services/system/user.pb.security.go | 4 +- api/v1/services/system/user_bridge.pb.go | 4 +- api/v1/services/system/user_http.pb.go | 8 +- api/v1/services/system/view.pb.go | 8 +- api/v1/services/system/view.pb.gw.go | 4 +- api/v1/services/system/view_bridge.pb.go | 2 +- api/v1/services/system/view_http.pb.go | 4 +- api/v1/services/types/system.pb.go | 167 ++++++++++-------- api/v1/services/types/system.pb.validate.go | 31 ++++ cmd/auth/wire.go | 3 +- cmd/auth/wire_gen.go | 2 +- internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 7 +- internal/data/entity/ent/mutation.go | 56 +++++- internal/data/entity/ent/mutation_fields.go | 7 + internal/data/entity/ent/runtime/runtime.go | 10 +- internal/data/entity/ent/schema/user.go | 7 +- internal/data/entity/ent/user.go | 13 +- internal/data/entity/ent/user/user.go | 12 ++ internal/data/entity/ent/user/where.go | 70 ++++++++ internal/data/entity/ent/user_create.go | 30 ++++ internal/data/entity/ent/user_query.go | 2 + internal/data/entity/ent/user_update.go | 44 +++++ internal/features/auth/biz/auth.go | 24 ++- internal/features/auth/dal/auth.go | 29 ++- internal/features/auth/dto/auth.go | 14 +- internal/features/auth/service/auth.go | 21 ++- internal/gateway/server/server.go | 19 +- internal/gateway/web/embed_real.go | 6 +- internal/helpers/ent/mixin/field.go | 26 +-- internal/helpers/ent/mixin/mixin.go | 134 +++++++++++--- internal/helpers/ent/mixin/mixin_id.go | 1 + resources/api-docs/openapi/openapi.yaml | 68 +++++-- 53 files changed, 691 insertions(+), 269 deletions(-) diff --git a/api/v1/proto/system/permission.proto b/api/v1/proto/system/permission.proto index b936e592..9f2504b9 100644 --- a/api/v1/proto/system/permission.proto +++ b/api/v1/proto/system/permission.proto @@ -34,7 +34,7 @@ service PermissionService { rpc UpdatePermission(UpdatePermissionRequest) returns (UpdatePermissionResponse) { option (google.api.http) = { put: "/sys/permissions/{permission.id}" - body: "permission" + body: "*" }; option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index 88afd693..6793a5a1 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -42,7 +42,7 @@ service ResourceService { rpc UpdateResource(UpdateResourceRequest) returns (UpdateResourceResponse) { option (google.api.http) = { put: "/sys/resources/{resource.id}" - body: "resource" + body: "*" }; option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } diff --git a/api/v1/proto/system/role.proto b/api/v1/proto/system/role.proto index 6e6fde40..015f1c12 100644 --- a/api/v1/proto/system/role.proto +++ b/api/v1/proto/system/role.proto @@ -34,7 +34,7 @@ service RoleService { rpc UpdateRole(UpdateRoleRequest) returns (UpdateRoleResponse) { option (google.api.http) = { put: "/sys/roles/{role.id}" - body: "role" + body: "*" }; option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } diff --git a/api/v1/proto/system/user.proto b/api/v1/proto/system/user.proto index 7d4cb80f..acf6f9e3 100644 --- a/api/v1/proto/system/user.proto +++ b/api/v1/proto/system/user.proto @@ -40,7 +40,7 @@ service UserService { } rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse) { option (google.api.http) = { - patch: "/sys/users/{user.id}" + put: "/sys/users/{user.id}" body: "*" }; option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; @@ -71,7 +71,7 @@ service UserService { rpc ResetUserPassword(ResetUserPasswordRequest) returns (ResetUserPasswordResponse) { option (google.api.http) = { post: "/sys/users/{id}/password/reset" - body: "password" + body: "*" }; option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } diff --git a/api/v1/proto/system/view.proto b/api/v1/proto/system/view.proto index c28805c8..644c1e09 100644 --- a/api/v1/proto/system/view.proto +++ b/api/v1/proto/system/view.proto @@ -39,7 +39,7 @@ service ViewService { rpc UpdateView(UpdateViewRequest) returns (UpdateViewResponse) { option (google.api.http) = { put: "/sys/views/{view.id}" - body: "view" + body: "*" }; option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; } diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index 84753dd5..59da2f9b 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -162,10 +162,14 @@ message User { int32 status = 17 [json_name = "status"]; // user.field.last_login_ip string last_login_ip = 18 [json_name = "last_login_ip"]; + // user.field.login_ip + string login_ip = 19 [json_name = "login_ip"]; // user.field.last_login_time - google.protobuf.Timestamp last_login_time = 19 [json_name = "last_login_time"]; + google.protobuf.Timestamp last_login_time = 20 [json_name = "last_login_time"]; + // user.field.login_time + google.protobuf.Timestamp login_time = 21 [json_name = "login_time"]; // user.field.sanction_date - optional google.protobuf.Timestamp sanction_date = 20 [json_name = "sanction_date"]; + optional google.protobuf.Timestamp sanction_date = 22 [json_name = "sanction_date"]; // // user.field.manager_id // int64 manager_id = 21 [json_name = "manager_id"]; // // user.field.manager diff --git a/api/v1/services/system/permission.pb.go b/api/v1/services/system/permission.pb.go index 5971b223..648f8985 100644 --- a/api/v1/services/system/permission.pb.go +++ b/api/v1/services/system/permission.pb.go @@ -666,7 +666,7 @@ const file_system_permission_proto_rawDesc = "" + "\x17DeletePermissionRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"H\n" + "\x18DeletePermissionResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xd0\x06\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xc7\x06\n" + "\x11PermissionService\x12\x9a\x01\n" + "\x0fListPermissions\x12..api.v1.services.system.ListPermissionsRequest\x1a/.api.v1.services.system.ListPermissionsResponse\"&\xea\xea\x1b\n" + "\n" + @@ -676,11 +676,10 @@ const file_system_permission_proto_rawDesc = "" + "\bjwt-auth\x82\xd3\xe4\x93\x02\x17\x12\x15/sys/permissions/{id}\x12\xa0\x01\n" + "\x10CreatePermission\x12/.api.v1.services.system.CreatePermissionRequest\x1a0.api.v1.services.system.CreatePermissionResponse\")\xea\xea\x1b\n" + "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/sys/permissions\x12\xb9\x01\n" + - "\x10UpdatePermission\x12/.api.v1.services.system.UpdatePermissionRequest\x1a0.api.v1.services.system.UpdatePermissionResponse\"B\xea\xea\x1b\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/sys/permissions\x12\xb0\x01\n" + + "\x10UpdatePermission\x12/.api.v1.services.system.UpdatePermissionRequest\x1a0.api.v1.services.system.UpdatePermissionResponse\"9\xea\xea\x1b\n" + "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02.:\n" + - "permission\x1a /sys/permissions/{permission.id}\x12\xa2\x01\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02%:\x01*\x1a /sys/permissions/{permission.id}\x12\xa2\x01\n" + "\x10DeletePermission\x12/.api.v1.services.system.DeletePermissionRequest\x1a0.api.v1.services.system.DeletePermissionResponse\"+\xea\xea\x1b\n" + "\n" + "\bjwt-auth\x82\xd3\xe4\x93\x02\x17*\x15/sys/permissions/{id}B\xe4\x01\n" + diff --git a/api/v1/services/system/permission.pb.gw.go b/api/v1/services/system/permission.pb.gw.go index 4a5053f0..53ef7d8f 100644 --- a/api/v1/services/system/permission.pb.gw.go +++ b/api/v1/services/system/permission.pb.gw.go @@ -129,15 +129,13 @@ func local_request_PermissionService_CreatePermission_0(ctx context.Context, mar return msg, metadata, err } -var filter_PermissionService_UpdatePermission_0 = &utilities.DoubleArray{Encoding: map[string]int{"permission": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - func request_PermissionService_UpdatePermission_0(ctx context.Context, marshaler runtime.Marshaler, client PermissionServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdatePermissionRequest metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["permission.id"] @@ -148,12 +146,6 @@ func request_PermissionService_UpdatePermission_0(ctx context.Context, marshaler if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "permission.id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_UpdatePermission_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } msg, err := client.UpdatePermission(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -164,7 +156,7 @@ func local_request_PermissionService_UpdatePermission_0(ctx context.Context, mar metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Permission); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["permission.id"] @@ -175,12 +167,6 @@ func local_request_PermissionService_UpdatePermission_0(ctx context.Context, mar if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "permission.id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_PermissionService_UpdatePermission_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } msg, err := server.UpdatePermission(ctx, &protoReq) return msg, metadata, err } diff --git a/api/v1/services/system/permission_bridge.pb.go b/api/v1/services/system/permission_bridge.pb.go index c1da935f..3eb990ad 100644 --- a/api/v1/services/system/permission_bridge.pb.go +++ b/api/v1/services/system/permission_bridge.pb.go @@ -162,7 +162,7 @@ func _PermissionService_CreatePermission0_Bridge_Handler(srv PermissionServiceHo func _PermissionService_UpdatePermission0_Bridge_Handler(srv PermissionServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdatePermissionRequest - if err := ctx.Bind(&in.Permission); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/permission_http.pb.go b/api/v1/services/system/permission_http.pb.go index 971bc1da..c3377ec6 100644 --- a/api/v1/services/system/permission_http.pb.go +++ b/api/v1/services/system/permission_http.pb.go @@ -108,7 +108,7 @@ func _PermissionService_CreatePermission0_HTTP_Handler(srv PermissionServiceHTTP func _PermissionService_UpdatePermission0_HTTP_Handler(srv PermissionServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdatePermissionRequest - if err := ctx.Bind(&in.Permission); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -226,7 +226,7 @@ func (c *PermissionServiceHTTPClientImpl) UpdatePermission(ctx context.Context, path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationPermissionServiceUpdatePermission)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Permission, &out, opts...) + err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go index a134d569..44ad4573 100644 --- a/api/v1/services/system/resource.pb.go +++ b/api/v1/services/system/resource.pb.go @@ -641,7 +641,7 @@ const file_system_resource_proto_rawDesc = "" + "\x15DeleteResourceRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"F\n" + "\x16DeleteResourceResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xa2\x06\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\x9b\x06\n" + "\x0fResourceService\x12\x92\x01\n" + "\rListResources\x12,.api.v1.services.system.ListResourcesRequest\x1a-.api.v1.services.system.ListResourcesResponse\"$\xea\xea\x1b\n" + "\n" + @@ -651,10 +651,10 @@ const file_system_resource_proto_rawDesc = "" + "\bjwt-auth\x82\xd3\xe4\x93\x02\x15\x12\x13/sys/resources/{id}\x12\x98\x01\n" + "\x0eCreateResource\x12-.api.v1.services.system.CreateResourceRequest\x1a..api.v1.services.system.CreateResourceResponse\"'\xea\xea\x1b\n" + "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/sys/resources\x12\xad\x01\n" + - "\x0eUpdateResource\x12-.api.v1.services.system.UpdateResourceRequest\x1a..api.v1.services.system.UpdateResourceResponse\"<\xea\xea\x1b\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x13:\x01*\"\x0e/sys/resources\x12\xa6\x01\n" + + "\x0eUpdateResource\x12-.api.v1.services.system.UpdateResourceRequest\x1a..api.v1.services.system.UpdateResourceResponse\"5\xea\xea\x1b\n" + "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02(:\bresource\x1a\x1c/sys/resources/{resource.id}\x12\x9a\x01\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02!:\x01*\x1a\x1c/sys/resources/{resource.id}\x12\x9a\x01\n" + "\x0eDeleteResource\x12-.api.v1.services.system.DeleteResourceRequest\x1a..api.v1.services.system.DeleteResourceResponse\")\xea\xea\x1b\n" + "\n" + "\bjwt-auth\x82\xd3\xe4\x93\x02\x15*\x13/sys/resources/{id}B\xe2\x01\n" + diff --git a/api/v1/services/system/resource.pb.gw.go b/api/v1/services/system/resource.pb.gw.go index f57e17f2..1133c6d0 100644 --- a/api/v1/services/system/resource.pb.gw.go +++ b/api/v1/services/system/resource.pb.gw.go @@ -135,7 +135,7 @@ func request_ResourceService_UpdateResource_0(ctx context.Context, marshaler run metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["resource.id"] @@ -156,7 +156,7 @@ func local_request_ResourceService_UpdateResource_0(ctx context.Context, marshal metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Resource); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["resource.id"] diff --git a/api/v1/services/system/resource_bridge.pb.go b/api/v1/services/system/resource_bridge.pb.go index 570a70aa..a202c207 100644 --- a/api/v1/services/system/resource_bridge.pb.go +++ b/api/v1/services/system/resource_bridge.pb.go @@ -167,7 +167,7 @@ func _ResourceService_CreateResource0_Bridge_Handler(srv ResourceServiceHookedBr func _ResourceService_UpdateResource0_Bridge_Handler(srv ResourceServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateResourceRequest - if err := ctx.Bind(&in.Resource); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/resource_http.pb.go b/api/v1/services/system/resource_http.pb.go index 9ab206b5..89bacb3f 100644 --- a/api/v1/services/system/resource_http.pb.go +++ b/api/v1/services/system/resource_http.pb.go @@ -113,7 +113,7 @@ func _ResourceService_CreateResource0_HTTP_Handler(srv ResourceServiceHTTPServer func _ResourceService_UpdateResource0_HTTP_Handler(srv ResourceServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateResourceRequest - if err := ctx.Bind(&in.Resource); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -241,7 +241,7 @@ func (c *ResourceServiceHTTPClientImpl) UpdateResource(ctx context.Context, in * path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationResourceServiceUpdateResource)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Resource, &out, opts...) + err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/system/role.pb.go b/api/v1/services/system/role.pb.go index 7e7330a9..bb7e198f 100644 --- a/api/v1/services/system/role.pb.go +++ b/api/v1/services/system/role.pb.go @@ -646,7 +646,7 @@ const file_system_role_proto_rawDesc = "" + "\x11DeleteRoleRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + "\x12DeleteRoleResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xc6\x05\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xc3\x05\n" + "\vRoleService\x12\x82\x01\n" + "\tListRoles\x12(.api.v1.services.system.ListRolesRequest\x1a).api.v1.services.system.ListRolesResponse\" \xea\xea\x1b\n" + "\n" + @@ -659,11 +659,11 @@ const file_system_role_proto_rawDesc = "" + "CreateRole\x12).api.v1.services.system.CreateRoleRequest\x1a*.api.v1.services.system.CreateRoleResponse\"#\xea\xea\x1b\n" + "\n" + "\bjwt-auth\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + - "/sys/roles\x12\x95\x01\n" + + "/sys/roles\x12\x92\x01\n" + "\n" + - "UpdateRole\x12).api.v1.services.system.UpdateRoleRequest\x1a*.api.v1.services.system.UpdateRoleResponse\"0\xea\xea\x1b\n" + + "UpdateRole\x12).api.v1.services.system.UpdateRoleRequest\x1a*.api.v1.services.system.UpdateRoleResponse\"-\xea\xea\x1b\n" + "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02\x1c:\x04role\x1a\x14/sys/roles/{role.id}\x12\x8a\x01\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x19:\x01*\x1a\x14/sys/roles/{role.id}\x12\x8a\x01\n" + "\n" + "DeleteRole\x12).api.v1.services.system.DeleteRoleRequest\x1a*.api.v1.services.system.DeleteRoleResponse\"%\xea\xea\x1b\n" + "\n" + diff --git a/api/v1/services/system/role.pb.gw.go b/api/v1/services/system/role.pb.gw.go index de552e88..0dbc09ae 100644 --- a/api/v1/services/system/role.pb.gw.go +++ b/api/v1/services/system/role.pb.gw.go @@ -129,15 +129,13 @@ func local_request_RoleService_CreateRole_0(ctx context.Context, marshaler runti return msg, metadata, err } -var filter_RoleService_UpdateRole_0 = &utilities.DoubleArray{Encoding: map[string]int{"role": 0, "id": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}} - func request_RoleService_UpdateRole_0(ctx context.Context, marshaler runtime.Marshaler, client RoleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( protoReq UpdateRoleRequest metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["role.id"] @@ -148,12 +146,6 @@ func request_RoleService_UpdateRole_0(ctx context.Context, marshaler runtime.Mar if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role.id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_UpdateRole_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } msg, err := client.UpdateRole(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -164,7 +156,7 @@ func local_request_RoleService_UpdateRole_0(ctx context.Context, marshaler runti metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Role); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["role.id"] @@ -175,12 +167,6 @@ func local_request_RoleService_UpdateRole_0(ctx context.Context, marshaler runti if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "role.id", err) } - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RoleService_UpdateRole_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } msg, err := server.UpdateRole(ctx, &protoReq) return msg, metadata, err } diff --git a/api/v1/services/system/role_bridge.pb.go b/api/v1/services/system/role_bridge.pb.go index f10a5226..f74e0bb0 100644 --- a/api/v1/services/system/role_bridge.pb.go +++ b/api/v1/services/system/role_bridge.pb.go @@ -162,7 +162,7 @@ func _RoleService_CreateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func( func _RoleService_UpdateRole0_Bridge_Handler(srv RoleServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateRoleRequest - if err := ctx.Bind(&in.Role); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/role_http.pb.go b/api/v1/services/system/role_http.pb.go index 4c486700..386a5f6d 100644 --- a/api/v1/services/system/role_http.pb.go +++ b/api/v1/services/system/role_http.pb.go @@ -108,7 +108,7 @@ func _RoleService_CreateRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx h func _RoleService_UpdateRole0_HTTP_Handler(srv RoleServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateRoleRequest - if err := ctx.Bind(&in.Role); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -226,7 +226,7 @@ func (c *RoleServiceHTTPClientImpl) UpdateRole(ctx context.Context, in *UpdateRo path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationRoleServiceUpdateRole)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.Role, &out, opts...) + err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/system/user.pb.go b/api/v1/services/system/user.pb.go index e6e7d7dc..614275cd 100644 --- a/api/v1/services/system/user.pb.go +++ b/api/v1/services/system/user.pb.go @@ -1034,7 +1034,7 @@ const file_system_user_proto_rawDesc = "" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1a\n" + "\brole_ids\x18\x02 \x03(\x03R\brole_ids\"J\n" + "\x17UpdateUserRolesResponse\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\xf8\n" + + "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user2\xf1\n" + "\n" + "\vUserService\x12\x82\x01\n" + "\tListUsers\x12(.api.v1.services.system.ListUsersRequest\x1a).api.v1.services.system.ListUsersResponse\" \xea\xea\x1b\n" + @@ -1055,7 +1055,7 @@ const file_system_user_proto_rawDesc = "" + "\n" + "UpdateUser\x12).api.v1.services.system.UpdateUserRequest\x1a*.api.v1.services.system.UpdateUserResponse\"-\xea\xea\x1b\n" + "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02\x19:\x01*2\x14/sys/users/{user.id}\x12\x8a\x01\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x19:\x01*\x1a\x14/sys/users/{user.id}\x12\x8a\x01\n" + "\n" + "DeleteUser\x12).api.v1.services.system.DeleteUserRequest\x1a*.api.v1.services.system.DeleteUserResponse\"%\xea\xea\x1b\n" + "\n" + @@ -1065,10 +1065,10 @@ const file_system_user_proto_rawDesc = "" + "\bjwt-auth\x82\xd3\xe4\x93\x02\x1b:\x01*\x1a\x16/sys/users/{id}/status\x12\xa2\x01\n" + "\x0fUpdateUserRoles\x12..api.v1.services.system.UpdateUserRolesRequest\x1a/.api.v1.services.system.UpdateUserRolesResponse\".\xea\xea\x1b\n" + "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02\x1a:\x01*\x1a\x15/sys/users/{id}/roles\x12\xb8\x01\n" + - "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\">\xea\xea\x1b\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x1a:\x01*\x1a\x15/sys/users/{id}/roles\x12\xb1\x01\n" + + "\x11ResetUserPassword\x120.api.v1.services.system.ResetUserPasswordRequest\x1a1.api.v1.services.system.ResetUserPasswordResponse\"7\xea\xea\x1b\n" + "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02*:\bpassword\"\x1e/sys/users/{id}/password/resetB\xde\x01\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02#:\x01*\"\x1e/sys/users/{id}/password/resetB\xde\x01\n" + "\x1acom.api.v1.services.systemB\tUserProtoP\x01Z9origadmin/application/admin/api/v1/services/system;system\xa2\x02\x04AVSS\xaa\x02\x16Api.V1.Services.System\xca\x02\x16Api\\V1\\Services\\System\xe2\x02\"Api\\V1\\Services\\System\\GPBMetadata\xea\x02\x19Api::V1::Services::Systemb\x06proto3" var ( diff --git a/api/v1/services/system/user.pb.gw.go b/api/v1/services/system/user.pb.gw.go index 1cc5e5d6..ee56e8ec 100644 --- a/api/v1/services/system/user.pb.gw.go +++ b/api/v1/services/system/user.pb.gw.go @@ -335,7 +335,7 @@ func request_UserService_ResetUserPassword_0(ctx context.Context, marshaler runt metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Password); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["id"] @@ -356,7 +356,7 @@ func local_request_UserService_ResetUserPassword_0(ctx context.Context, marshale metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Password); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["id"] @@ -457,7 +457,7 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux } forward_UserService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPatch, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPut, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -665,7 +665,7 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux } forward_UserService_CreateUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPatch, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPut, pattern_UserService_UpdateUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) diff --git a/api/v1/services/system/user.pb.security.go b/api/v1/services/system/user.pb.security.go index a7048486..ad5ce23e 100644 --- a/api/v1/services/system/user.pb.security.go +++ b/api/v1/services/system/user.pb.security.go @@ -35,9 +35,9 @@ func init() { }, { ServiceMethod: "/api.v1.services.system.UserService/UpdateUser", - GatewayPath: "PATCH:/sys/users/{user.id}", + GatewayPath: "PUT:/sys/users/{user.id}", Name: "jwt-auth", - VersionID: "d8e0be7e0fdf3b02e0af09c8d0f8404c763d57d14e621679533071caca4446bb", + VersionID: "0fb25e54ac26e6ef490962ccb46f2f1e74a5391f77f26c6acb9c6ce0270b6ccd", }, { ServiceMethod: "/api.v1.services.system.UserService/DeleteUser", diff --git a/api/v1/services/system/user_bridge.pb.go b/api/v1/services/system/user_bridge.pb.go index 655b3438..ed213e06 100644 --- a/api/v1/services/system/user_bridge.pb.go +++ b/api/v1/services/system/user_bridge.pb.go @@ -112,7 +112,7 @@ func RegisterUserServiceBridgeServer(s *http.Server, srv UserServiceHookedBridge r.GET("/sys/users/:id/resources", _UserService_ListUserResources0_Bridge_Handler(srv)) r.GET("/sys/users/:id", _UserService_GetUser0_Bridge_Handler(srv)) r.POST("/sys/users", _UserService_CreateUser0_Bridge_Handler(srv)) - r.PATCH("/sys/users/:user.id", _UserService_UpdateUser0_Bridge_Handler(srv)) + r.PUT("/sys/users/:user.id", _UserService_UpdateUser0_Bridge_Handler(srv)) r.DELETE("/sys/users/:id", _UserService_DeleteUser0_Bridge_Handler(srv)) r.PUT("/sys/users/:id/status", _UserService_UpdateUserStatus0_Bridge_Handler(srv)) r.PUT("/sys/users/:id/roles", _UserService_UpdateUserRoles0_Bridge_Handler(srv)) @@ -336,7 +336,7 @@ func _UserService_UpdateUserRoles0_Bridge_Handler(srv UserServiceHookedBridger) func _UserService_ResetUserPassword0_Bridge_Handler(srv UserServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in ResetUserPasswordRequest - if err := ctx.Bind(&in.Password); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/user_http.pb.go b/api/v1/services/system/user_http.pb.go index 603183a6..8ff07957 100644 --- a/api/v1/services/system/user_http.pb.go +++ b/api/v1/services/system/user_http.pb.go @@ -50,7 +50,7 @@ func RegisterUserServiceHTTPServer(s *http.Server, srv UserServiceHTTPServer) { r.GET("/sys/users/{id}/resources", _UserService_ListUserResources0_HTTP_Handler(srv)) r.GET("/sys/users/{id}", _UserService_GetUser0_HTTP_Handler(srv)) r.POST("/sys/users", _UserService_CreateUser0_HTTP_Handler(srv)) - r.PATCH("/sys/users/{user.id}", _UserService_UpdateUser0_HTTP_Handler(srv)) + r.PUT("/sys/users/{user.id}", _UserService_UpdateUser0_HTTP_Handler(srv)) r.DELETE("/sys/users/{id}", _UserService_DeleteUser0_HTTP_Handler(srv)) r.PUT("/sys/users/{id}/status", _UserService_UpdateUserStatus0_HTTP_Handler(srv)) r.PUT("/sys/users/{id}/roles", _UserService_UpdateUserRoles0_HTTP_Handler(srv)) @@ -242,7 +242,7 @@ func _UserService_UpdateUserRoles0_HTTP_Handler(srv UserServiceHTTPServer) func( func _UserService_ResetUserPassword0_HTTP_Handler(srv UserServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in ResetUserPasswordRequest - if err := ctx.Bind(&in.Password); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -359,7 +359,7 @@ func (c *UserServiceHTTPClientImpl) ResetUserPassword(ctx context.Context, in *R path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationUserServiceResetUserPassword)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "POST", path, in.Password, &out, opts...) + err := c.cc.Invoke(ctx, "POST", path, in, &out, opts...) if err != nil { return nil, err } @@ -372,7 +372,7 @@ func (c *UserServiceHTTPClientImpl) UpdateUser(ctx context.Context, in *UpdateUs path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationUserServiceUpdateUser)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PATCH", path, in, &out, opts...) + err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/system/view.pb.go b/api/v1/services/system/view.pb.go index 14dd4fb3..722d8e27 100644 --- a/api/v1/services/system/view.pb.go +++ b/api/v1/services/system/view.pb.go @@ -631,7 +631,7 @@ const file_system_view_proto_rawDesc = "" + "\x11DeleteViewRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\"B\n" + "\x12DeleteViewResponse\x12,\n" + - "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xc6\x05\n" + + "\x05empty\x18\x01 \x01(\v2\x16.google.protobuf.EmptyR\x05empty2\xc3\x05\n" + "\vViewService\x12\x82\x01\n" + "\tListViews\x12(.api.v1.services.system.ListViewsRequest\x1a).api.v1.services.system.ListViewsResponse\" \xea\xea\x1b\n" + "\n" + @@ -644,11 +644,11 @@ const file_system_view_proto_rawDesc = "" + "CreateView\x12).api.v1.services.system.CreateViewRequest\x1a*.api.v1.services.system.CreateViewResponse\"#\xea\xea\x1b\n" + "\n" + "\bjwt-auth\x82\xd3\xe4\x93\x02\x0f:\x01*\"\n" + - "/sys/views\x12\x95\x01\n" + + "/sys/views\x12\x92\x01\n" + "\n" + - "UpdateView\x12).api.v1.services.system.UpdateViewRequest\x1a*.api.v1.services.system.UpdateViewResponse\"0\xea\xea\x1b\n" + + "UpdateView\x12).api.v1.services.system.UpdateViewRequest\x1a*.api.v1.services.system.UpdateViewResponse\"-\xea\xea\x1b\n" + "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02\x1c:\x04view\x1a\x14/sys/views/{view.id}\x12\x8a\x01\n" + + "\bjwt-auth\x82\xd3\xe4\x93\x02\x19:\x01*\x1a\x14/sys/views/{view.id}\x12\x8a\x01\n" + "\n" + "DeleteView\x12).api.v1.services.system.DeleteViewRequest\x1a*.api.v1.services.system.DeleteViewResponse\"%\xea\xea\x1b\n" + "\n" + diff --git a/api/v1/services/system/view.pb.gw.go b/api/v1/services/system/view.pb.gw.go index e2d6d45e..8977ae4c 100644 --- a/api/v1/services/system/view.pb.gw.go +++ b/api/v1/services/system/view.pb.gw.go @@ -135,7 +135,7 @@ func request_ViewService_UpdateView_0(ctx context.Context, marshaler runtime.Mar metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.View); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["view.id"] @@ -156,7 +156,7 @@ func local_request_ViewService_UpdateView_0(ctx context.Context, marshaler runti metadata runtime.ServerMetadata err error ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.View); err != nil && !errors.Is(err, io.EOF) { + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } val, ok := pathParams["view.id"] diff --git a/api/v1/services/system/view_bridge.pb.go b/api/v1/services/system/view_bridge.pb.go index a4e5739b..fd9d41b1 100644 --- a/api/v1/services/system/view_bridge.pb.go +++ b/api/v1/services/system/view_bridge.pb.go @@ -167,7 +167,7 @@ func _ViewService_CreateView0_Bridge_Handler(srv ViewServiceHookedBridger) func( func _ViewService_UpdateView0_Bridge_Handler(srv ViewServiceHookedBridger) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateViewRequest - if err := ctx.Bind(&in.View); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { diff --git a/api/v1/services/system/view_http.pb.go b/api/v1/services/system/view_http.pb.go index 7d754bdc..3d4a90e3 100644 --- a/api/v1/services/system/view_http.pb.go +++ b/api/v1/services/system/view_http.pb.go @@ -113,7 +113,7 @@ func _ViewService_CreateView0_HTTP_Handler(srv ViewServiceHTTPServer) func(ctx h func _ViewService_UpdateView0_HTTP_Handler(srv ViewServiceHTTPServer) func(ctx http.Context) error { return func(ctx http.Context) error { var in UpdateViewRequest - if err := ctx.Bind(&in.View); err != nil { + if err := ctx.Bind(&in); err != nil { return err } if err := ctx.BindQuery(&in); err != nil { @@ -241,7 +241,7 @@ func (c *ViewServiceHTTPClientImpl) UpdateView(ctx context.Context, in *UpdateVi path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationViewServiceUpdateView)) opts = append(opts, http.PathTemplate(pattern)) - err := c.cc.Invoke(ctx, "PUT", path, in.View, &out, opts...) + err := c.cc.Invoke(ctx, "PUT", path, in, &out, opts...) if err != nil { return nil, err } diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index b7fc5922..82ddc8c2 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -643,10 +643,14 @@ type User struct { Status int32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` // user.field.last_login_ip LastLoginIp string `protobuf:"bytes,18,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` + // user.field.login_ip + LoginIp string `protobuf:"bytes,19,opt,name=login_ip,proto3" json:"login_ip,omitempty"` // user.field.last_login_time - LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,19,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` + LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,20,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` + // user.field.login_time + LoginTime *timestamppb.Timestamp `protobuf:"bytes,21,opt,name=login_time,proto3" json:"login_time,omitempty"` // user.field.sanction_date - SanctionDate *timestamppb.Timestamp `protobuf:"bytes,20,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` + SanctionDate *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` // // user.field.manager_id // int64 manager_id = 21 [json_name = "manager_id"]; // // user.field.manager @@ -816,6 +820,13 @@ func (x *User) GetLastLoginIp() string { return "" } +func (x *User) GetLoginIp() string { + if x != nil { + return x.LoginIp + } + return "" +} + func (x *User) GetLastLoginTime() *timestamppb.Timestamp { if x != nil { return x.LastLoginTime @@ -823,6 +834,13 @@ func (x *User) GetLastLoginTime() *timestamppb.Timestamp { return nil } +func (x *User) GetLoginTime() *timestamppb.Timestamp { + if x != nil { + return x.LoginTime + } + return nil +} + func (x *User) GetSanctionDate() *timestamppb.Timestamp { if x != nil { return x.SanctionDate @@ -2859,7 +2877,7 @@ const file_types_system_proto_rawDesc = "" + "role_views\x12?\n" + "\n" + "user_roles\x18\x04 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + - "user_roles\"\x94\x06\n" + + "user_roles\"\xec\x06\n" + "\x04User\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + @@ -2881,9 +2899,13 @@ const file_types_system_proto_rawDesc = "" + "\x06remark\x18\x0f \x01(\tR\x06remark\x12\x14\n" + "\x05token\x18\x10 \x01(\tR\x05token\x12\x16\n" + "\x06status\x18\x11 \x01(\x05R\x06status\x12$\n" + - "\rlast_login_ip\x18\x12 \x01(\tR\rlast_login_ip\x12D\n" + - "\x0flast_login_time\x18\x13 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12E\n" + - "\rsanction_date\x18\x14 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x121\n" + + "\rlast_login_ip\x18\x12 \x01(\tR\rlast_login_ip\x12\x1a\n" + + "\blogin_ip\x18\x13 \x01(\tR\blogin_ip\x12D\n" + + "\x0flast_login_time\x18\x14 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12:\n" + + "\n" + + "login_time\x18\x15 \x01(\v2\x1a.google.protobuf.TimestampR\n" + + "login_time\x12E\n" + + "\rsanction_date\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x121\n" + "\x05roles\x18\x17 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + "\brole_ids\x18\x18 \x03(\x03R\brole_idsB\x10\n" + "\x0e_sanction_date\"\x7f\n" + @@ -3133,72 +3155,73 @@ var file_types_system_proto_depIdxs = []int32{ 30, // 21: api.v1.services.types.User.create_time:type_name -> google.protobuf.Timestamp 30, // 22: api.v1.services.types.User.update_time:type_name -> google.protobuf.Timestamp 30, // 23: api.v1.services.types.User.last_login_time:type_name -> google.protobuf.Timestamp - 30, // 24: api.v1.services.types.User.sanction_date:type_name -> google.protobuf.Timestamp - 2, // 25: api.v1.services.types.User.roles:type_name -> api.v1.services.types.Role - 2, // 26: api.v1.services.types.UserEdges.roles:type_name -> api.v1.services.types.Role - 6, // 27: api.v1.services.types.UserEdges.user_roles:type_name -> api.v1.services.types.UserRole - 30, // 28: api.v1.services.types.UserRole.create_time:type_name -> google.protobuf.Timestamp - 30, // 29: api.v1.services.types.UserRole.update_time:type_name -> google.protobuf.Timestamp - 4, // 30: api.v1.services.types.UserRole.user:type_name -> api.v1.services.types.User - 2, // 31: api.v1.services.types.UserRole.role:type_name -> api.v1.services.types.Role - 4, // 32: api.v1.services.types.UserRoleEdges.user:type_name -> api.v1.services.types.User - 2, // 33: api.v1.services.types.UserRoleEdges.role:type_name -> api.v1.services.types.Role - 30, // 34: api.v1.services.types.RoleView.create_time:type_name -> google.protobuf.Timestamp - 30, // 35: api.v1.services.types.RoleView.update_time:type_name -> google.protobuf.Timestamp - 2, // 36: api.v1.services.types.RoleView.role:type_name -> api.v1.services.types.Role - 0, // 37: api.v1.services.types.RoleView.view:type_name -> api.v1.services.types.View - 2, // 38: api.v1.services.types.RoleViewEdges.role:type_name -> api.v1.services.types.Role - 0, // 39: api.v1.services.types.RoleViewEdges.view:type_name -> api.v1.services.types.View - 30, // 40: api.v1.services.types.Resource.create_time:type_name -> google.protobuf.Timestamp - 30, // 41: api.v1.services.types.Resource.update_time:type_name -> google.protobuf.Timestamp - 28, // 42: api.v1.services.types.Resource.properties:type_name -> api.v1.services.types.Resource.PropertiesEntry - 10, // 43: api.v1.services.types.Resource.children:type_name -> api.v1.services.types.Resource - 10, // 44: api.v1.services.types.Resource.parent:type_name -> api.v1.services.types.Resource - 18, // 45: api.v1.services.types.Resource.permissions:type_name -> api.v1.services.types.Permission - 0, // 46: api.v1.services.types.ResourceEdges.view:type_name -> api.v1.services.types.View - 30, // 47: api.v1.services.types.Department.create_time:type_name -> google.protobuf.Timestamp - 30, // 48: api.v1.services.types.Department.update_time:type_name -> google.protobuf.Timestamp - 12, // 49: api.v1.services.types.Department.children:type_name -> api.v1.services.types.Department - 12, // 50: api.v1.services.types.Department.parent:type_name -> api.v1.services.types.Department - 4, // 51: api.v1.services.types.DepartmentEdges.users:type_name -> api.v1.services.types.User - 16, // 52: api.v1.services.types.DepartmentEdges.positions:type_name -> api.v1.services.types.Position - 12, // 53: api.v1.services.types.DepartmentEdges.children:type_name -> api.v1.services.types.Department - 12, // 54: api.v1.services.types.DepartmentEdges.parent:type_name -> api.v1.services.types.Department - 14, // 55: api.v1.services.types.DepartmentEdges.user_departments:type_name -> api.v1.services.types.UserDepartment - 15, // 56: api.v1.services.types.UserDepartment.edges:type_name -> api.v1.services.types.UserDepartmentEdges - 4, // 57: api.v1.services.types.UserDepartmentEdges.user:type_name -> api.v1.services.types.User - 12, // 58: api.v1.services.types.UserDepartmentEdges.department:type_name -> api.v1.services.types.Department - 30, // 59: api.v1.services.types.Position.create_time:type_name -> google.protobuf.Timestamp - 30, // 60: api.v1.services.types.Position.update_time:type_name -> google.protobuf.Timestamp - 12, // 61: api.v1.services.types.PositionEdges.department:type_name -> api.v1.services.types.Department - 4, // 62: api.v1.services.types.PositionEdges.users:type_name -> api.v1.services.types.User - 18, // 63: api.v1.services.types.PositionEdges.permissions:type_name -> api.v1.services.types.Permission - 20, // 64: api.v1.services.types.PositionEdges.user_positions:type_name -> api.v1.services.types.UserPosition - 22, // 65: api.v1.services.types.PositionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission - 30, // 66: api.v1.services.types.Permission.create_time:type_name -> google.protobuf.Timestamp - 30, // 67: api.v1.services.types.Permission.update_time:type_name -> google.protobuf.Timestamp - 29, // 68: api.v1.services.types.Permission.data_rules:type_name -> api.v1.services.types.Permission.DataRulesEntry - 10, // 69: api.v1.services.types.Permission.resources:type_name -> api.v1.services.types.Resource - 0, // 70: api.v1.services.types.Permission.views:type_name -> api.v1.services.types.View - 2, // 71: api.v1.services.types.PermissionEdges.roles:type_name -> api.v1.services.types.Role - 10, // 72: api.v1.services.types.PermissionEdges.resources:type_name -> api.v1.services.types.Resource - 16, // 73: api.v1.services.types.PermissionEdges.positions:type_name -> api.v1.services.types.Position - 24, // 74: api.v1.services.types.PermissionEdges.role_permissions:type_name -> api.v1.services.types.RolePermission - 26, // 75: api.v1.services.types.PermissionEdges.permission_resources:type_name -> api.v1.services.types.PermissionResource - 22, // 76: api.v1.services.types.PermissionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission - 4, // 77: api.v1.services.types.UserPositionEdges.user:type_name -> api.v1.services.types.User - 16, // 78: api.v1.services.types.UserPositionEdges.position:type_name -> api.v1.services.types.Position - 16, // 79: api.v1.services.types.PositionPermissionEdges.position:type_name -> api.v1.services.types.Position - 18, // 80: api.v1.services.types.PositionPermissionEdges.permission:type_name -> api.v1.services.types.Permission - 2, // 81: api.v1.services.types.RolePermissionEdges.role:type_name -> api.v1.services.types.Role - 18, // 82: api.v1.services.types.RolePermissionEdges.permission:type_name -> api.v1.services.types.Permission - 18, // 83: api.v1.services.types.PermissionResourceEdges.permission:type_name -> api.v1.services.types.Permission - 10, // 84: api.v1.services.types.PermissionResourceEdges.resource:type_name -> api.v1.services.types.Resource - 85, // [85:85] is the sub-list for method output_type - 85, // [85:85] is the sub-list for method input_type - 85, // [85:85] is the sub-list for extension type_name - 85, // [85:85] is the sub-list for extension extendee - 0, // [0:85] is the sub-list for field type_name + 30, // 24: api.v1.services.types.User.login_time:type_name -> google.protobuf.Timestamp + 30, // 25: api.v1.services.types.User.sanction_date:type_name -> google.protobuf.Timestamp + 2, // 26: api.v1.services.types.User.roles:type_name -> api.v1.services.types.Role + 2, // 27: api.v1.services.types.UserEdges.roles:type_name -> api.v1.services.types.Role + 6, // 28: api.v1.services.types.UserEdges.user_roles:type_name -> api.v1.services.types.UserRole + 30, // 29: api.v1.services.types.UserRole.create_time:type_name -> google.protobuf.Timestamp + 30, // 30: api.v1.services.types.UserRole.update_time:type_name -> google.protobuf.Timestamp + 4, // 31: api.v1.services.types.UserRole.user:type_name -> api.v1.services.types.User + 2, // 32: api.v1.services.types.UserRole.role:type_name -> api.v1.services.types.Role + 4, // 33: api.v1.services.types.UserRoleEdges.user:type_name -> api.v1.services.types.User + 2, // 34: api.v1.services.types.UserRoleEdges.role:type_name -> api.v1.services.types.Role + 30, // 35: api.v1.services.types.RoleView.create_time:type_name -> google.protobuf.Timestamp + 30, // 36: api.v1.services.types.RoleView.update_time:type_name -> google.protobuf.Timestamp + 2, // 37: api.v1.services.types.RoleView.role:type_name -> api.v1.services.types.Role + 0, // 38: api.v1.services.types.RoleView.view:type_name -> api.v1.services.types.View + 2, // 39: api.v1.services.types.RoleViewEdges.role:type_name -> api.v1.services.types.Role + 0, // 40: api.v1.services.types.RoleViewEdges.view:type_name -> api.v1.services.types.View + 30, // 41: api.v1.services.types.Resource.create_time:type_name -> google.protobuf.Timestamp + 30, // 42: api.v1.services.types.Resource.update_time:type_name -> google.protobuf.Timestamp + 28, // 43: api.v1.services.types.Resource.properties:type_name -> api.v1.services.types.Resource.PropertiesEntry + 10, // 44: api.v1.services.types.Resource.children:type_name -> api.v1.services.types.Resource + 10, // 45: api.v1.services.types.Resource.parent:type_name -> api.v1.services.types.Resource + 18, // 46: api.v1.services.types.Resource.permissions:type_name -> api.v1.services.types.Permission + 0, // 47: api.v1.services.types.ResourceEdges.view:type_name -> api.v1.services.types.View + 30, // 48: api.v1.services.types.Department.create_time:type_name -> google.protobuf.Timestamp + 30, // 49: api.v1.services.types.Department.update_time:type_name -> google.protobuf.Timestamp + 12, // 50: api.v1.services.types.Department.children:type_name -> api.v1.services.types.Department + 12, // 51: api.v1.services.types.Department.parent:type_name -> api.v1.services.types.Department + 4, // 52: api.v1.services.types.DepartmentEdges.users:type_name -> api.v1.services.types.User + 16, // 53: api.v1.services.types.DepartmentEdges.positions:type_name -> api.v1.services.types.Position + 12, // 54: api.v1.services.types.DepartmentEdges.children:type_name -> api.v1.services.types.Department + 12, // 55: api.v1.services.types.DepartmentEdges.parent:type_name -> api.v1.services.types.Department + 14, // 56: api.v1.services.types.DepartmentEdges.user_departments:type_name -> api.v1.services.types.UserDepartment + 15, // 57: api.v1.services.types.UserDepartment.edges:type_name -> api.v1.services.types.UserDepartmentEdges + 4, // 58: api.v1.services.types.UserDepartmentEdges.user:type_name -> api.v1.services.types.User + 12, // 59: api.v1.services.types.UserDepartmentEdges.department:type_name -> api.v1.services.types.Department + 30, // 60: api.v1.services.types.Position.create_time:type_name -> google.protobuf.Timestamp + 30, // 61: api.v1.services.types.Position.update_time:type_name -> google.protobuf.Timestamp + 12, // 62: api.v1.services.types.PositionEdges.department:type_name -> api.v1.services.types.Department + 4, // 63: api.v1.services.types.PositionEdges.users:type_name -> api.v1.services.types.User + 18, // 64: api.v1.services.types.PositionEdges.permissions:type_name -> api.v1.services.types.Permission + 20, // 65: api.v1.services.types.PositionEdges.user_positions:type_name -> api.v1.services.types.UserPosition + 22, // 66: api.v1.services.types.PositionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission + 30, // 67: api.v1.services.types.Permission.create_time:type_name -> google.protobuf.Timestamp + 30, // 68: api.v1.services.types.Permission.update_time:type_name -> google.protobuf.Timestamp + 29, // 69: api.v1.services.types.Permission.data_rules:type_name -> api.v1.services.types.Permission.DataRulesEntry + 10, // 70: api.v1.services.types.Permission.resources:type_name -> api.v1.services.types.Resource + 0, // 71: api.v1.services.types.Permission.views:type_name -> api.v1.services.types.View + 2, // 72: api.v1.services.types.PermissionEdges.roles:type_name -> api.v1.services.types.Role + 10, // 73: api.v1.services.types.PermissionEdges.resources:type_name -> api.v1.services.types.Resource + 16, // 74: api.v1.services.types.PermissionEdges.positions:type_name -> api.v1.services.types.Position + 24, // 75: api.v1.services.types.PermissionEdges.role_permissions:type_name -> api.v1.services.types.RolePermission + 26, // 76: api.v1.services.types.PermissionEdges.permission_resources:type_name -> api.v1.services.types.PermissionResource + 22, // 77: api.v1.services.types.PermissionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission + 4, // 78: api.v1.services.types.UserPositionEdges.user:type_name -> api.v1.services.types.User + 16, // 79: api.v1.services.types.UserPositionEdges.position:type_name -> api.v1.services.types.Position + 16, // 80: api.v1.services.types.PositionPermissionEdges.position:type_name -> api.v1.services.types.Position + 18, // 81: api.v1.services.types.PositionPermissionEdges.permission:type_name -> api.v1.services.types.Permission + 2, // 82: api.v1.services.types.RolePermissionEdges.role:type_name -> api.v1.services.types.Role + 18, // 83: api.v1.services.types.RolePermissionEdges.permission:type_name -> api.v1.services.types.Permission + 18, // 84: api.v1.services.types.PermissionResourceEdges.permission:type_name -> api.v1.services.types.Permission + 10, // 85: api.v1.services.types.PermissionResourceEdges.resource:type_name -> api.v1.services.types.Resource + 86, // [86:86] is the sub-list for method output_type + 86, // [86:86] is the sub-list for method input_type + 86, // [86:86] is the sub-list for extension type_name + 86, // [86:86] is the sub-list for extension extendee + 0, // [0:86] is the sub-list for field type_name } func init() { file_types_system_proto_init() } diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index 5bfb472d..f2142666 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -1274,6 +1274,8 @@ func (m *User) validate(all bool) error { // no validation rules for LastLoginIp + // no validation rules for LoginIp + if all { switch v := interface{}(m.GetLastLoginTime()).(type) { case interface{ ValidateAll() error }: @@ -1303,6 +1305,35 @@ func (m *User) validate(all bool) error { } } + if all { + switch v := interface{}(m.GetLoginTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserValidationError{ + field: "LoginTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, UserValidationError{ + field: "LoginTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetLoginTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return UserValidationError{ + field: "LoginTime", + reason: "embedded message failed validation", + cause: err, + } + } + } + for idx, item := range m.GetRoles() { _, _ = idx, item diff --git a/cmd/auth/wire.go b/cmd/auth/wire.go index ae0e7d50..e4df89f6 100644 --- a/cmd/auth/wire.go +++ b/cmd/auth/wire.go @@ -24,12 +24,13 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err providers.ProviderSet, providers.ProviderBackendSet, - // Service-specific providers + // Auth-specific providers data.ProviderSet, dal.ProviderSet, biz.ProviderSet, service.ProviderSet, server.ProviderSet, + NewApp, )) } diff --git a/cmd/auth/wire_gen.go b/cmd/auth/wire_gen.go index 5f234b72..d3c8de65 100644 --- a/cmd/auth/wire_gen.go +++ b/cmd/auth/wire_gen.go @@ -69,7 +69,7 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*kratos.App, func(), err cleanup() return nil, nil, err } - authService := service.NewAuthService(authUseCase, captchaUseCase, creator) + authService := service.NewAuthService(authUseCase, captchaUseCase, creator, v) meRepo := dal.NewMeRepo(database, v) meUseCase := biz.NewMeUseCase(meRepo, v) meService := service.NewMeService(meUseCase) diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index cddeb23b..42f15a3a 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"permission.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status.comment\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"schema_type\":{\"mysql\":\"datetime\"},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"permission.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status.comment\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index 2c26dc4c..9aeeff08 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -410,9 +410,10 @@ var ( {Name: "status", Type: field.TypeInt8, Comment: "entity.user.field.status", Default: 1}, {Name: "is_system", Type: field.TypeBool, Comment: "entity.user.field.is_system", Default: false}, {Name: "last_login_ip", Type: field.TypeString, Size: 32, Comment: "entity.user.field.last_login_ip", Default: ""}, - {Name: "last_login_time", Type: field.TypeTime, Comment: "entity.user.field.last_login_time", SchemaType: map[string]string{"mysql": "datetime"}}, - {Name: "login_time", Type: field.TypeTime, Comment: "entity.user.field.login_time", SchemaType: map[string]string{"mysql": "datetime"}}, - {Name: "sanction_date", Type: field.TypeTime, Nullable: true, Comment: "entity.user.field.sanction_date", SchemaType: map[string]string{"mysql": "datetime"}}, + {Name: "login_ip", Type: field.TypeString, Size: 32, Comment: "entity.user.field.login_ip", Default: ""}, + {Name: "last_login_time", Type: field.TypeTime, Comment: "entity.user.field.last_login_time"}, + {Name: "login_time", Type: field.TypeTime, Comment: "entity.user.field.login_time"}, + {Name: "sanction_date", Type: field.TypeTime, Nullable: true, Comment: "entity.user.field.sanction_date"}, } // SysUsersTable holds the schema information for the "sys_users" table. SysUsersTable = &schema.Table{ diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index 85494df9..6a072de8 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -9260,6 +9260,7 @@ type UserMutation struct { addstatus *enums.Status is_system *bool last_login_ip *string + login_ip *string last_login_time *time.Time login_time *time.Time sanction_date *time.Time @@ -10284,6 +10285,42 @@ func (m *UserMutation) ResetLastLoginIP() { m.last_login_ip = nil } +// SetLoginIP sets the "login_ip" field. +func (m *UserMutation) SetLoginIP(s string) { + m.login_ip = &s +} + +// LoginIP returns the value of the "login_ip" field in the mutation. +func (m *UserMutation) LoginIP() (r string, exists bool) { + v := m.login_ip + if v == nil { + return + } + return *v, true +} + +// OldLoginIP returns the old "login_ip" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldLoginIP(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoginIP is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoginIP requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoginIP: %w", err) + } + return oldValue.LoginIP, nil +} + +// ResetLoginIP resets all changes to the "login_ip" field. +func (m *UserMutation) ResetLoginIP() { + m.login_ip = nil +} + // SetLastLoginTime sets the "last_login_time" field. func (m *UserMutation) SetLastLoginTime(t time.Time) { m.last_login_time = &t @@ -10763,7 +10800,7 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 25) + fields := make([]string, 0, 26) if m.create_author != nil { fields = append(fields, user.FieldCreateAuthor) } @@ -10830,6 +10867,9 @@ func (m *UserMutation) Fields() []string { if m.last_login_ip != nil { fields = append(fields, user.FieldLastLoginIP) } + if m.login_ip != nil { + fields = append(fields, user.FieldLoginIP) + } if m.last_login_time != nil { fields = append(fields, user.FieldLastLoginTime) } @@ -10891,6 +10931,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.IsSystem() case user.FieldLastLoginIP: return m.LastLoginIP() + case user.FieldLoginIP: + return m.LoginIP() case user.FieldLastLoginTime: return m.LastLoginTime() case user.FieldLoginTime: @@ -10950,6 +10992,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldIsSystem(ctx) case user.FieldLastLoginIP: return m.OldLastLoginIP(ctx) + case user.FieldLoginIP: + return m.OldLoginIP(ctx) case user.FieldLastLoginTime: return m.OldLastLoginTime(ctx) case user.FieldLoginTime: @@ -11119,6 +11163,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetLastLoginIP(v) return nil + case user.FieldLoginIP: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoginIP(v) + return nil case user.FieldLastLoginTime: v, ok := value.(time.Time) if !ok { @@ -11321,6 +11372,9 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldLastLoginIP: m.ResetLastLoginIP() return nil + case user.FieldLoginIP: + m.ResetLoginIP() + return nil case user.FieldLastLoginTime: m.ResetLastLoginTime() return nil diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index af6ce9c1..70383d0f 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -831,6 +831,8 @@ func (m *UserMutation) SetFields(input *User, fields ...string) error { m.SetIsSystem(input.IsSystem) case user.FieldLastLoginIP: m.SetLastLoginIP(input.LastLoginIP) + case user.FieldLoginIP: + m.SetLoginIP(input.LoginIP) case user.FieldLastLoginTime: m.SetLastLoginTime(input.LastLoginTime) case user.FieldLoginTime: @@ -961,6 +963,11 @@ func (m *UserMutation) SetFieldsSkipZero(input *User, fields ...string) error { if input.LastLoginIP != "" { m.SetLastLoginIP(input.LastLoginIP) } + case user.FieldLoginIP: + // check string with sql.NullString if it is empty + if input.LoginIP != "" { + m.SetLoginIP(input.LoginIP) + } case user.FieldLastLoginTime: if input.LastLoginTime.Unix() != 0 { m.SetLastLoginTime(input.LastLoginTime) diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index 6251f63a..5e6e019b 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -517,12 +517,18 @@ func init() { user.DefaultLastLoginIP = userDescLastLoginIP.Default.(string) // user.LastLoginIPValidator is a validator for the "last_login_ip" field. It is called by the builders before save. user.LastLoginIPValidator = userDescLastLoginIP.Validators[0].(func(string) error) + // userDescLoginIP is the schema descriptor for login_ip field. + userDescLoginIP := userFields[17].Descriptor() + // user.DefaultLoginIP holds the default value on creation for the login_ip field. + user.DefaultLoginIP = userDescLoginIP.Default.(string) + // user.LoginIPValidator is a validator for the "login_ip" field. It is called by the builders before save. + user.LoginIPValidator = userDescLoginIP.Validators[0].(func(string) error) // userDescLastLoginTime is the schema descriptor for last_login_time field. - userDescLastLoginTime := userFields[17].Descriptor() + userDescLastLoginTime := userFields[18].Descriptor() // user.DefaultLastLoginTime holds the default value on creation for the last_login_time field. user.DefaultLastLoginTime = userDescLastLoginTime.Default.(func() time.Time) // userDescLoginTime is the schema descriptor for login_time field. - userDescLoginTime := userFields[18].Descriptor() + userDescLoginTime := userFields[19].Descriptor() // user.DefaultLoginTime holds the default value on creation for the login_time field. user.DefaultLoginTime = userDescLoginTime.Default.(func() time.Time) // userDescID is the schema descriptor for id field. diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 6468c86a..6c8cc289 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -7,6 +7,7 @@ package schema import ( "context" + "errors" "fmt" "entgo.io/ent" @@ -101,6 +102,10 @@ func (User) Fields() []ent.Field { MaxLen(32). Default(""). Comment(i18n.Text("entity.user.field.last_login_ip")), + field.String("login_ip"). + MaxLen(32). + Default(""). + Comment(i18n.Text("entity.user.field.login_ip")), mixin.Time("last_login_time", i18n.Text("entity.user.field.last_login_time")), mixin.Time("login_time", i18n.Text("entity.user.field.login_time")), mixin.TimeOptional("sanction_date", i18n.Text("entity.user.field.sanction_date")), @@ -163,7 +168,7 @@ func preventDuplicateSystemUser(next ent.Mutator) ent.Mutator { return nil, fmt.Errorf("failed to check for existing system user: %w", err) } if count > 0 { - return nil, fmt.Errorf("a system user already exists") + return nil, errors.New("only one system user is allowed") } return next.Mutate(ctx, m) }) diff --git a/internal/data/entity/ent/user.go b/internal/data/entity/ent/user.go index d88706b5..124a1fd0 100644 --- a/internal/data/entity/ent/user.go +++ b/internal/data/entity/ent/user.go @@ -65,6 +65,8 @@ type User struct { IsSystem bool `json:"is_system,omitempty"` // entity.user.field.last_login_ip LastLoginIP string `json:"last_login_ip,omitempty"` + // entity.user.field.login_ip + LoginIP string `json:"login_ip,omitempty"` // entity.user.field.last_login_time LastLoginTime time.Time `json:"last_login_time,omitempty"` // entity.user.field.login_time @@ -159,7 +161,7 @@ func (*User) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case user.FieldID, user.FieldCreateAuthor, user.FieldUpdateAuthor, user.FieldStatus: values[i] = new(sql.NullInt64) - case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldEncryptedPassword, user.FieldSalt, user.FieldPhone, user.FieldEmail, user.FieldDepartment, user.FieldRemark, user.FieldToken, user.FieldLastLoginIP: + case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldEncryptedPassword, user.FieldSalt, user.FieldPhone, user.FieldEmail, user.FieldDepartment, user.FieldRemark, user.FieldToken, user.FieldLastLoginIP, user.FieldLoginIP: values[i] = new(sql.NullString) case user.FieldCreateTime, user.FieldUpdateTime, user.FieldDeleteTime, user.FieldLastLoginTime, user.FieldLoginTime, user.FieldSanctionDate: values[i] = new(sql.NullTime) @@ -317,6 +319,12 @@ func (_m *User) assignValues(columns []string, values []any) error { } else if value.Valid { _m.LastLoginIP = value.String } + case user.FieldLoginIP: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field login_ip", values[i]) + } else if value.Valid { + _m.LoginIP = value.String + } case user.FieldLastLoginTime: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field last_login_time", values[i]) @@ -469,6 +477,9 @@ func (_m *User) String() string { builder.WriteString("last_login_ip=") builder.WriteString(_m.LastLoginIP) builder.WriteString(", ") + builder.WriteString("login_ip=") + builder.WriteString(_m.LoginIP) + builder.WriteString(", ") builder.WriteString("last_login_time=") builder.WriteString(_m.LastLoginTime.Format(time.ANSIC)) builder.WriteString(", ") diff --git a/internal/data/entity/ent/user/user.go b/internal/data/entity/ent/user/user.go index 774a9b44..9a7d0644 100644 --- a/internal/data/entity/ent/user/user.go +++ b/internal/data/entity/ent/user/user.go @@ -61,6 +61,8 @@ const ( FieldIsSystem = "is_system" // FieldLastLoginIP holds the string denoting the last_login_ip field in the database. FieldLastLoginIP = "last_login_ip" + // FieldLoginIP holds the string denoting the login_ip field in the database. + FieldLoginIP = "login_ip" // FieldLastLoginTime holds the string denoting the last_login_time field in the database. FieldLastLoginTime = "last_login_time" // FieldLoginTime holds the string denoting the login_time field in the database. @@ -143,6 +145,7 @@ var Columns = []string{ FieldStatus, FieldIsSystem, FieldLastLoginIP, + FieldLoginIP, FieldLastLoginTime, FieldLoginTime, FieldSanctionDate, @@ -247,6 +250,10 @@ var ( DefaultLastLoginIP string // LastLoginIPValidator is a validator for the "last_login_ip" field. It is called by the builders before save. LastLoginIPValidator func(string) error + // DefaultLoginIP holds the default value on creation for the "login_ip" field. + DefaultLoginIP string + // LoginIPValidator is a validator for the "login_ip" field. It is called by the builders before save. + LoginIPValidator func(string) error // DefaultLastLoginTime holds the default value on creation for the "last_login_time" field. DefaultLastLoginTime func() time.Time // DefaultLoginTime holds the default value on creation for the "login_time" field. @@ -402,6 +409,11 @@ func ByLastLoginIP(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldLastLoginIP, opts...).ToFunc() } +// ByLoginIP orders the results by the login_ip field. +func ByLoginIP(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldLoginIP, opts...).ToFunc() +} + // ByLastLoginTime orders the results by the last_login_time field. func ByLastLoginTime(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldLastLoginTime, opts...).ToFunc() diff --git a/internal/data/entity/ent/user/where.go b/internal/data/entity/ent/user/where.go index 0586c094..c87f8fb3 100644 --- a/internal/data/entity/ent/user/where.go +++ b/internal/data/entity/ent/user/where.go @@ -162,6 +162,11 @@ func LastLoginIP(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldLastLoginIP, v)) } +// LoginIP applies equality check predicate on the "login_ip" field. It's identical to LoginIPEQ. +func LoginIP(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldLoginIP, v)) +} + // LastLoginTime applies equality check predicate on the "last_login_time" field. It's identical to LastLoginTimeEQ. func LastLoginTime(v time.Time) predicate.User { return predicate.User(sql.FieldEQ(FieldLastLoginTime, v)) @@ -1401,6 +1406,71 @@ func LastLoginIPContainsFold(v string) predicate.User { return predicate.User(sql.FieldContainsFold(FieldLastLoginIP, v)) } +// LoginIPEQ applies the EQ predicate on the "login_ip" field. +func LoginIPEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldLoginIP, v)) +} + +// LoginIPNEQ applies the NEQ predicate on the "login_ip" field. +func LoginIPNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldLoginIP, v)) +} + +// LoginIPIn applies the In predicate on the "login_ip" field. +func LoginIPIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldLoginIP, vs...)) +} + +// LoginIPNotIn applies the NotIn predicate on the "login_ip" field. +func LoginIPNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldLoginIP, vs...)) +} + +// LoginIPGT applies the GT predicate on the "login_ip" field. +func LoginIPGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldLoginIP, v)) +} + +// LoginIPGTE applies the GTE predicate on the "login_ip" field. +func LoginIPGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldLoginIP, v)) +} + +// LoginIPLT applies the LT predicate on the "login_ip" field. +func LoginIPLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldLoginIP, v)) +} + +// LoginIPLTE applies the LTE predicate on the "login_ip" field. +func LoginIPLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldLoginIP, v)) +} + +// LoginIPContains applies the Contains predicate on the "login_ip" field. +func LoginIPContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldLoginIP, v)) +} + +// LoginIPHasPrefix applies the HasPrefix predicate on the "login_ip" field. +func LoginIPHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldLoginIP, v)) +} + +// LoginIPHasSuffix applies the HasSuffix predicate on the "login_ip" field. +func LoginIPHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldLoginIP, v)) +} + +// LoginIPEqualFold applies the EqualFold predicate on the "login_ip" field. +func LoginIPEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldLoginIP, v)) +} + +// LoginIPContainsFold applies the ContainsFold predicate on the "login_ip" field. +func LoginIPContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldLoginIP, v)) +} + // LastLoginTimeEQ applies the EQ predicate on the "last_login_time" field. func LastLoginTimeEQ(v time.Time) predicate.User { return predicate.User(sql.FieldEQ(FieldLastLoginTime, v)) diff --git a/internal/data/entity/ent/user_create.go b/internal/data/entity/ent/user_create.go index a2a1242a..6f2c345f 100644 --- a/internal/data/entity/ent/user_create.go +++ b/internal/data/entity/ent/user_create.go @@ -319,6 +319,20 @@ func (_c *UserCreate) SetNillableLastLoginIP(v *string) *UserCreate { return _c } +// SetLoginIP sets the "login_ip" field. +func (_c *UserCreate) SetLoginIP(v string) *UserCreate { + _c.mutation.SetLoginIP(v) + return _c +} + +// SetNillableLoginIP sets the "login_ip" field if the given value is not nil. +func (_c *UserCreate) SetNillableLoginIP(v *string) *UserCreate { + if v != nil { + _c.SetLoginIP(*v) + } + return _c +} + // SetLastLoginTime sets the "last_login_time" field. func (_c *UserCreate) SetLastLoginTime(v time.Time) *UserCreate { _c.mutation.SetLastLoginTime(v) @@ -584,6 +598,10 @@ func (_c *UserCreate) defaults() error { v := user.DefaultLastLoginIP _c.mutation.SetLastLoginIP(v) } + if _, ok := _c.mutation.LoginIP(); !ok { + v := user.DefaultLoginIP + _c.mutation.SetLoginIP(v) + } if _, ok := _c.mutation.LastLoginTime(); !ok { if user.DefaultLastLoginTime == nil { return fmt.Errorf("ent: uninitialized user.DefaultLastLoginTime (forgotten import ent/runtime?)") @@ -737,6 +755,14 @@ func (_c *UserCreate) check() error { return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} } } + if _, ok := _c.mutation.LoginIP(); !ok { + return &ValidationError{Name: "login_ip", err: errors.New(`ent: missing required field "User.login_ip"`)} + } + if v, ok := _c.mutation.LoginIP(); ok { + if err := user.LoginIPValidator(v); err != nil { + return &ValidationError{Name: "login_ip", err: fmt.Errorf(`ent: validator failed for field "User.login_ip": %w`, err)} + } + } if _, ok := _c.mutation.LastLoginTime(); !ok { return &ValidationError{Name: "last_login_time", err: errors.New(`ent: missing required field "User.last_login_time"`)} } @@ -868,6 +894,10 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) _node.LastLoginIP = value } + if value, ok := _c.mutation.LoginIP(); ok { + _spec.SetField(user.FieldLoginIP, field.TypeString, value) + _node.LoginIP = value + } if value, ok := _c.mutation.LastLoginTime(); ok { _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) _node.LastLoginTime = value diff --git a/internal/data/entity/ent/user_query.go b/internal/data/entity/ent/user_query.go index d22ae6c1..fc94cb45 100644 --- a/internal/data/entity/ent/user_query.go +++ b/internal/data/entity/ent/user_query.go @@ -1049,6 +1049,7 @@ func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // Status enums.Status `json:"status,omitempty"` // IsSystem bool `json:"is_system,omitempty"` // LastLoginIP string `json:"last_login_ip,omitempty"` +// LoginIP string `json:"login_ip,omitempty"` // LastLoginTime time.Time `json:"last_login_time,omitempty"` // LoginTime time.Time `json:"login_time,omitempty"` // SanctionDate time.Time `json:"sanction_date,omitempty"` @@ -1078,6 +1079,7 @@ func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // user.FieldStatus, // user.FieldIsSystem, // user.FieldLastLoginIP, +// user.FieldLoginIP, // user.FieldLastLoginTime, // user.FieldLoginTime, // user.FieldSanctionDate, diff --git a/internal/data/entity/ent/user_update.go b/internal/data/entity/ent/user_update.go index 7806b74d..09795a1c 100644 --- a/internal/data/entity/ent/user_update.go +++ b/internal/data/entity/ent/user_update.go @@ -361,6 +361,20 @@ func (_u *UserUpdate) SetNillableLastLoginIP(v *string) *UserUpdate { return _u } +// SetLoginIP sets the "login_ip" field. +func (_u *UserUpdate) SetLoginIP(v string) *UserUpdate { + _u.mutation.SetLoginIP(v) + return _u +} + +// SetNillableLoginIP sets the "login_ip" field if the given value is not nil. +func (_u *UserUpdate) SetNillableLoginIP(v *string) *UserUpdate { + if v != nil { + _u.SetLoginIP(*v) + } + return _u +} + // SetLastLoginTime sets the "last_login_time" field. func (_u *UserUpdate) SetLastLoginTime(v time.Time) *UserUpdate { _u.mutation.SetLastLoginTime(v) @@ -744,6 +758,11 @@ func (_u *UserUpdate) check() error { return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} } } + if v, ok := _u.mutation.LoginIP(); ok { + if err := user.LoginIPValidator(v); err != nil { + return &ValidationError{Name: "login_ip", err: fmt.Errorf(`ent: validator failed for field "User.login_ip": %w`, err)} + } + } return nil } @@ -846,6 +865,9 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.LastLoginIP(); ok { _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) } + if value, ok := _u.mutation.LoginIP(); ok { + _spec.SetField(user.FieldLoginIP, field.TypeString, value) + } if value, ok := _u.mutation.LastLoginTime(); ok { _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) } @@ -1475,6 +1497,20 @@ func (_u *UserUpdateOne) SetNillableLastLoginIP(v *string) *UserUpdateOne { return _u } +// SetLoginIP sets the "login_ip" field. +func (_u *UserUpdateOne) SetLoginIP(v string) *UserUpdateOne { + _u.mutation.SetLoginIP(v) + return _u +} + +// SetNillableLoginIP sets the "login_ip" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableLoginIP(v *string) *UserUpdateOne { + if v != nil { + _u.SetLoginIP(*v) + } + return _u +} + // SetLastLoginTime sets the "last_login_time" field. func (_u *UserUpdateOne) SetLastLoginTime(v time.Time) *UserUpdateOne { _u.mutation.SetLastLoginTime(v) @@ -1871,6 +1907,11 @@ func (_u *UserUpdateOne) check() error { return &ValidationError{Name: "last_login_ip", err: fmt.Errorf(`ent: validator failed for field "User.last_login_ip": %w`, err)} } } + if v, ok := _u.mutation.LoginIP(); ok { + if err := user.LoginIPValidator(v); err != nil { + return &ValidationError{Name: "login_ip", err: fmt.Errorf(`ent: validator failed for field "User.login_ip": %w`, err)} + } + } return nil } @@ -1990,6 +2031,9 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { if value, ok := _u.mutation.LastLoginIP(); ok { _spec.SetField(user.FieldLastLoginIP, field.TypeString, value) } + if value, ok := _u.mutation.LoginIP(); ok { + _spec.SetField(user.FieldLoginIP, field.TypeString, value) + } if value, ok := _u.mutation.LastLoginTime(); ok { _spec.SetField(user.FieldLastLoginTime, field.TypeTime, value) } diff --git a/internal/features/auth/biz/auth.go b/internal/features/auth/biz/auth.go index b348691d..03fbd952 100644 --- a/internal/features/auth/biz/auth.go +++ b/internal/features/auth/biz/auth.go @@ -7,6 +7,7 @@ import ( "github.com/go-kratos/kratos/v2/log" "github.com/origadmin/toolkits/crypto/hash" + "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/features/auth/dto" ) @@ -26,17 +27,24 @@ func NewAuthUseCase(repo dto.AuthRepo, hasher hash.Crypto, logger log.Logger) *A } } -// VerifyUser verifies the user's credentials and returns the user ID if successful. -func (uc *AuthUseCase) VerifyUser(ctx context.Context, username, password string) (int64, error) { - user, err := uc.repo.GetUserByUsername(ctx, username) +// VerifyUser verifies the user's credentials and returns the secure DTO if successful. +func (uc *AuthUseCase) VerifyUser(ctx context.Context, username, password string) (*types.User, error) { + // 1. Get the internal AuthedUser DTO from the AuthRepo. + authedUser, err := uc.repo.GetUserByUsername(ctx, username) if err != nil { - return 0, err + return nil, err } - // Compare the provided password with the stored hash. - if err := uc.hasher.Verify(user.EncryptedPassword, password); err != nil { - return 0, errors.New("invalid username or password") + // 2. Compare the provided password with the stored hash. + if err := uc.hasher.Verify(authedUser.EncryptedPassword, password); err != nil { + return nil, errors.New("invalid username or password") } - return user.ID, nil + // 3. On successful verification, return the safe User object from the DTO. + return authedUser.User, nil +} + +// UpdateLoginInfo delegates the update of login-related information to the repository. +func (uc *AuthUseCase) UpdateLoginInfo(ctx context.Context, userID int64, loginIP string) error { + return uc.repo.UpdateLoginInfo(ctx, userID, loginIP) } diff --git a/internal/features/auth/dal/auth.go b/internal/features/auth/dal/auth.go index 73ed0a32..88563d61 100644 --- a/internal/features/auth/dal/auth.go +++ b/internal/features/auth/dal/auth.go @@ -2,6 +2,7 @@ package dal import ( "context" + "time" "github.com/go-kratos/kratos/v2/log" @@ -23,16 +24,32 @@ func NewAuthRepo(db *ent.Database, logger log.Logger) dto.AuthRepo { } } -// GetUserByUsername retrieves a user by their username. -func (r *AuthRepo) GetUserByUsername(ctx context.Context, username string) (*dto.User, error) { +// GetUserByUsername retrieves a user's auth-specific data by their username. +func (r *AuthRepo) GetUserByUsername(ctx context.Context, username string) (*dto.AuthedUser, error) { u, err := r.db.User(ctx).Query().Where(user.UsernameEQ(username)).Only(ctx) if err != nil { return nil, err } - - return &dto.User{ - ID: u.ID, - Username: u.Username, + return &dto.AuthedUser{ + User: dto.ConvertUserToUserPB(u), EncryptedPassword: u.EncryptedPassword, }, nil } + +// UpdateLoginInfo updates the last login time, current login time, and last login IP for a user. +func (r *AuthRepo) UpdateLoginInfo(ctx context.Context, userID int64, loginIP string) error { + // First, get the current user entity to perform the "shift change". + currentUser, err := r.db.User(ctx).Get(ctx, userID) + if err != nil { + return err + } + + // Perform the "shift change" and update to the new values. + return r.db.User(ctx). + UpdateOneID(userID). + SetLastLoginTime(currentUser.LoginTime). // Previous login time becomes the last login time + SetLoginTime(time.Now()). // Set current login time + SetLastLoginIP(currentUser.LoginIP). // Previous login IP becomes the last login IP + SetLoginIP(loginIP). // Set current login IP + Exec(ctx) +} diff --git a/internal/features/auth/dto/auth.go b/internal/features/auth/dto/auth.go index 2d7bdba3..2c590870 100644 --- a/internal/features/auth/dto/auth.go +++ b/internal/features/auth/dto/auth.go @@ -2,10 +2,20 @@ package dto import ( "context" + "origadmin/application/admin/api/v1/services/types" ) +// AuthedUser is an internal DTO for authentication, containing sensitive data. +// It should NOT be returned to the service layer or external clients. +type AuthedUser struct { + User *types.User + EncryptedPassword string +} + // AuthRepo defines the data access methods for authentication. type AuthRepo interface { - // GetUserByUsername retrieves a user by their username. - GetUserByUsername(ctx context.Context, username string) (*User, error) + // GetUserByUsername retrieves a user's auth-specific data by their username. + GetUserByUsername(ctx context.Context, username string) (*AuthedUser, error) + // UpdateLoginInfo updates the login-related fields for a user. + UpdateLoginInfo(ctx context.Context, userID int64, loginIP string) error } diff --git a/internal/features/auth/service/auth.go b/internal/features/auth/service/auth.go index f7d6346d..6160ab56 100644 --- a/internal/features/auth/service/auth.go +++ b/internal/features/auth/service/auth.go @@ -5,6 +5,8 @@ import ( "fmt" "github.com/go-kratos/kratos/v2/errors" + "github.com/go-kratos/kratos/v2/log" + "github.com/go-kratos/kratos/v2/transport" securityv1 "github.com/origadmin/contrib/api/gen/go/security/v1" "github.com/origadmin/contrib/security/credential" @@ -20,11 +22,12 @@ type AuthService struct { uc *biz.AuthUseCase captchaUC *biz.CaptchaUseCase creator credential.Creator + log *log.Helper } // NewAuthService creates a new authentication service. -func NewAuthService(uc *biz.AuthUseCase, cuc *biz.CaptchaUseCase, creator credential.Creator) *AuthService { - return &AuthService{uc: uc, captchaUC: cuc, creator: creator} +func NewAuthService(uc *biz.AuthUseCase, cuc *biz.CaptchaUseCase, creator credential.Creator, logger log.Logger) *AuthService { + return &AuthService{uc: uc, captchaUC: cuc, creator: creator, log: log.NewHelper(logger)} } // Login authenticates a user and returns a token pair. @@ -34,13 +37,23 @@ func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.Logi return nil, errors.New(400, "CAPTCHA_INVALID", "invalid captcha") } - userID, err := s.uc.VerifyUser(ctx, req.Username, req.Password) + user, err := s.uc.VerifyUser(ctx, req.Username, req.Password) if err != nil { return nil, err } + // Update login info before creating the token. + var loginIP string + if tr, ok := transport.FromServerContext(ctx); ok { + loginIP = tr.RequestHeader().Get("X-Real-IP") + } + if err := s.uc.UpdateLoginInfo(ctx, user.Id, loginIP); err != nil { + // Log the error but don't block the login process. + s.log.Errorf("failed to update login info for user %d: %v", user.Id, err) + } + // Create a principal for the user. - p := securityPrincipal.New(fmt.Sprint(userID)) + p := securityPrincipal.New(fmt.Sprint(user.Id)) // Create a credential (which contains the token). credResp, err := s.creator.CreateCredential(ctx, p) diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index 5a9945a4..081efe6f 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -83,16 +83,6 @@ func NewHTTPServer( kratoshttp.PathPrefix("/api/v1"), } - // Try to get the handler for the embedded Web UI. - webUIHandler, err := web.GetHandler() - if err == nil { - log.NewHelper(app.Logger()).Infow("msg", "Embedded Web UI is enabled and will be served.") - // If the handler is available, register it for the root path. - serverOpts = append(serverOpts) - } else { - log.NewHelper(app.Logger()).Warnw("msg", "Embedded Web UI is disabled. To enable, build with '-tags embed_ui'.") - } - log.NewHelper(app.Logger()).Infow("msg", "Registering middleware", "middlewares", maps.Keys(mws)) opts := &http.ServerOptions{ ServerOptions: serverOpts, @@ -105,7 +95,14 @@ func NewHTTPServer( } // Register all services using the GatewayService method. svc.RegisterHTTPHandlers(srv) - srv.HandlePrefix("/", webUIHandler) + // Try to get the handler for the embedded Web UI. + webUIHandler, err := web.GetHandler() + if err == nil { + log.NewHelper(app.Logger()).Infow("msg", "Embedded Web UI is enabled and will be served.") + srv.HandlePrefix("/", webUIHandler) + } else { + log.NewHelper(app.Logger()).Warnw("msg", "Embedded Web UI is disabled. To enable, build with '-tags embed_ui'.") + } // Log all registered HTTP routes for debugging and verification srv.WalkHandle(func(method, path string, handler stdhttp.HandlerFunc) { diff --git a/internal/gateway/web/embed_real.go b/internal/gateway/web/embed_real.go index 946375bd..4d228658 100644 --- a/internal/gateway/web/embed_real.go +++ b/internal/gateway/web/embed_real.go @@ -8,15 +8,15 @@ import ( "net/http" ) -//go:embed all:../../../../resources/web +//go:embed all:../../../../webui/dist var WebUI embed.FS // GetHandler returns an http.Handler that serves the embedded Web UI. // This version is compiled only when the 'embed_ui' build tag is provided. func GetHandler() (http.Handler, error) { - // The `WebUI` embed.FS now contains the `resources/web` directory structure. + // The `WebUI` embed.FS now contains the `webui/dist` directory structure. // We need to create a sub-filesystem that starts from that directory. - distFS, err := fs.Sub(WebUI, "resources/web") + distFS, err := fs.Sub(WebUI, "webui/dist") if err != nil { return nil, err } diff --git a/internal/helpers/ent/mixin/field.go b/internal/helpers/ent/mixin/field.go index 210049ef..47755d36 100644 --- a/internal/helpers/ent/mixin/field.go +++ b/internal/helpers/ent/mixin/field.go @@ -9,7 +9,6 @@ import ( "time" "entgo.io/ent" - "entgo.io/ent/dialect" "entgo.io/ent/schema/field" "origadmin/application/admin/internal/helpers/i18n" @@ -48,25 +47,18 @@ func OptionalFK(name string, comment ...string) ent.Field { return innerID.Comment(comment[0]).OptionalFK(name) } -// TimeOptional returns a time field with a default value of ZeroTime and a custom schema type for MySQL. +// TimeOptional returns a time field with a default value of ZeroTime. func TimeOptional(name string, comment ...string) ent.Field { if len(comment) == 0 { - return field.Time(name). - Optional(). - SchemaType(map[string]string{ - dialect.MySQL: "datetime", - }) + return field.Time(name).Optional() } // Create a time field with the given name and a default value of ZeroTime. return field.Time(name). Comment(comment[0]). - Optional(). - SchemaType(map[string]string{ - dialect.MySQL: "datetime", - }) + Optional() } -// Time returns a time field with a default value of ZeroTime and a custom schema type for MySQL. +// Time returns a time field with a default value of ZeroTime. func Time(name string, comment ...string) ent.Field { if len(comment) == 0 { return FieldTime(name) @@ -77,10 +69,6 @@ func Time(name string, comment ...string) ent.Field { // Set the default value of the field to ZeroTime. Default(func() time.Time { return ZeroTime - }). - // Set the schema type of the field to "datetime" for MySQL dialect. - SchemaType(map[string]string{ - dialect.MySQL: "datetime", }) } @@ -127,15 +115,11 @@ func FieldUUIDOptional(name string, comment ...string) ent.Field { return UUID{}.Comment(comment[0]).OptionalFK(name) } -// FieldTime returns a time field with a default value of ZeroTime and a custom schema type for MySQL. +// FieldTime returns a time field with a default value of ZeroTime. func FieldTime(name string) ent.Field { return field.Time(name). // Set the default value of the field to ZeroTime. Default(func() time.Time { return ZeroTime - }). - // Set the schema type of the field to "datetime" for MySQL dialect. - SchemaType(map[string]string{ - dialect.MySQL: "datetime", }) } diff --git a/internal/helpers/ent/mixin/mixin.go b/internal/helpers/ent/mixin/mixin.go index 1c5a1ab9..e9c7a621 100644 --- a/internal/helpers/ent/mixin/mixin.go +++ b/internal/helpers/ent/mixin/mixin.go @@ -7,6 +7,7 @@ package mixin import ( "context" + "errors" "time" "entgo.io/ent" @@ -14,6 +15,7 @@ import ( "entgo.io/ent/schema/index" "entgo.io/ent/schema/mixin" + "origadmin/application/admin/internal/helpers/contextutil" "origadmin/application/admin/internal/helpers/i18n" ) @@ -24,30 +26,16 @@ type IDGenerator interface { PK(name string) ent.Field } -// Audit schema to include control and time fields. -type auditMixin struct { +// auditFields defines only the fields and indexes for auditing, without any hooks. +// This allows models to include audit fields without enabling automatic updates. +type auditFields struct { mixin.Schema CreateField string UpdateField string } -func DefaultAudit() ent.Mixin { - return auditMixin{ - CreateField: "create_author", - UpdateField: "update_author", - } -} - -// Audit returns a new audit mixin with configurable field names. -func Audit(createField, updateField string) ent.Mixin { - return auditMixin{ - CreateField: createField, - UpdateField: updateField, - } -} - -// Fields of the mixin. -func (m auditMixin) Fields() []ent.Field { +// Fields of the auditFields mixin. +func (m auditFields) Fields() []ent.Field { auditCreate := innerID auditCreate.Key = m.CreateField auditCreate.CommentKey = i18n.Text("create_author.field.comment") @@ -64,14 +52,94 @@ func (m auditMixin) Fields() []ent.Field { } } -// Indexes of the mixin. -func (m auditMixin) Indexes() []ent.Index { +// Indexes of the auditFields mixin. +func (m auditFields) Indexes() []ent.Index { return []ent.Index{ index.Fields(m.CreateField), index.Fields(m.UpdateField), } } +// AuditFields returns a mixin that includes only the audit fields (create_author, update_author) +// and their indexes, without any automatic update hooks. +func AuditFields(createField, updateField string) ent.Mixin { + return auditFields{ + CreateField: createField, + UpdateField: updateField, + } +} + +// DefaultAuditFields returns a new audit mixin with default field names, without hooks. +func DefaultAuditFields() ent.Mixin { + return AuditFields("create_author", "update_author") +} + +// auditMixin composes auditFields and adds an automatic update hook. +// This provides the full-featured auditing capability. +type auditMixin struct { + auditFields +} + +// AuditHook is a hook that sets the create_author and update_author fields +// by extracting the user ID from the context via contextutil.GetUserID. +func AuditHook(createField, updateField string) ent.Hook { + return func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + // Skip if not a Create or Update operation. + if !m.Op().Is(ent.OpCreate | ent.OpUpdate) { + return next.Mutate(ctx, m) + } + + userID, err := contextutil.GetUserID(ctx) + if err != nil { + // If the error indicates no principal was found, proceed without setting audit fields. + // This allows for anonymous or system-level actions. + if errors.Is(err, contextutil.ErrNoPrincipalInContext) { + return next.Mutate(ctx, m) + } + // For other errors (e.g., parsing), fail the mutation to prevent data corruption. + return nil, err + } + + if m.Op().Is(ent.OpCreate) { + if err := m.SetField(createField, userID); err != nil { + return nil, err + } + } + if err := m.SetField(updateField, userID); err != nil { + return nil, err + } + + return next.Mutate(ctx, m) + }) + } +} + +// Hooks of the mixin. +// It uses the AuditHook to automatically set the author fields during create and update operations. +// This hook relies on a user identifier being present in the `context.Context` +// and uses the encapsulated `contextutil.GetUserID` function to retrieve it. +func (m auditMixin) Hooks() []ent.Hook { + return []ent.Hook{ + AuditHook(m.CreateField, m.UpdateField), + } +} + +// AuditWithHook returns a mixin that includes audit fields and an automatic update hook. +func AuditWithHook(createField, updateField string) ent.Mixin { + return auditMixin{ + auditFields: auditFields{ + CreateField: createField, + UpdateField: updateField, + }, + } +} + +// DefaultAuditWithHook returns a new audit mixin with default field names and the update hook. +func DefaultAuditWithHook() ent.Mixin { + return AuditWithHook("create_author", "update_author") +} + // ManagerSchema schema to include control and time fields. type ManagerSchema struct { mixin.Schema @@ -84,11 +152,16 @@ func (ManagerSchema) Fields() []ent.Field { manager.CommentKey = i18n.Text("manager_id.field.comment") manager.Optional = true manager.UseDefault = true + if manager.UseAlias { + return []ent.Field{ + manager.ToField(), + field.String("manager_name"). + Comment(i18n.Text("manager_name.field.comment")). + Default(""), + } + } return []ent.Field{ manager.ToField(), - field.String("manager_name"). - Comment(i18n.Text("manager_name.field.comment")). - Default(""), } } @@ -228,14 +301,25 @@ func (m DeleteMixin) Indexes() []ent.Index { } var ( + // ModelMixin provides a basic set of fields for standard models. ModelMixin = []ent.Mixin{ innerID, DefaultCreateMixin(), DefaultUpdateMixin(), } + + // AuditFieldsModelMixin provides the basic model fields plus audit fields, but without automatic update hooks. + AuditFieldsModelMixin = []ent.Mixin{ + innerID, + DefaultAuditFields(), + DefaultCreateMixin(), + DefaultUpdateMixin(), + } + + // AuditModelMixin provides the full suite: basic fields, audit fields, and automatic update hooks. AuditModelMixin = []ent.Mixin{ innerID, - DefaultAudit(), + DefaultAuditWithHook(), DefaultCreateMixin(), DefaultUpdateMixin(), } diff --git a/internal/helpers/ent/mixin/mixin_id.go b/internal/helpers/ent/mixin/mixin_id.go index 16f6bb13..cbe78058 100644 --- a/internal/helpers/ent/mixin/mixin_id.go +++ b/internal/helpers/ent/mixin/mixin_id.go @@ -26,6 +26,7 @@ type ID struct { UseDefault bool DefaultFunc func() int64 UseCustomIDGenerator bool + UseAlias bool } func (obj ID) ToField() ent.Field { diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index ed3eb1e0..005973da 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -1017,16 +1017,11 @@ paths: required: true schema: type: string - - name: id - in: query - description: The resource name of the permission to update. - schema: - type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Permission' + $ref: '#/components/schemas/api.v1.services.system.UpdatePermissionRequest' required: true responses: "200": @@ -1355,7 +1350,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Resource' + $ref: '#/components/schemas/api.v1.services.system.UpdateResourceRequest' required: true responses: "200": @@ -1513,16 +1508,11 @@ paths: required: true schema: type: string - - name: id - in: query - description: The id of the role resource to update. - schema: - type: string requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.Role' + $ref: '#/components/schemas/api.v1.services.system.UpdateRoleRequest' required: true responses: "200": @@ -1683,7 +1673,7 @@ paths: content: application/json: schema: - type: string + $ref: '#/components/schemas/api.v1.services.system.ResetUserPasswordRequest' required: true responses: "200": @@ -1785,7 +1775,7 @@ paths: schema: $ref: '#/components/schemas/google.rpc.Status' /sys/users/{user.id}: - patch: + put: tags: - UserService operationId: UserService_UpdateUser @@ -1957,7 +1947,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.types.View' + $ref: '#/components/schemas/api.v1.services.system.UpdateViewRequest' required: true responses: "200": @@ -2858,6 +2848,13 @@ components: extra: $ref: '#/components/schemas/google.protobuf.Any' description: Response message for ViewService.ListViews. + api.v1.services.system.ResetUserPasswordRequest: + type: object + properties: + id: + type: string + password: + type: string api.v1.services.system.ResetUserPasswordResponse: type: object properties: {} @@ -2866,6 +2863,16 @@ components: properties: department: $ref: '#/components/schemas/api.v1.services.types.Department' + api.v1.services.system.UpdatePermissionRequest: + type: object + properties: + id: + type: string + description: The resource name of the permission to update. + permission: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.Permission' + description: The permission resource which replaces the resource on the server. api.v1.services.system.UpdatePermissionResponse: type: object properties: @@ -2876,12 +2883,28 @@ components: properties: position: $ref: '#/components/schemas/api.v1.services.types.Position' + api.v1.services.system.UpdateResourceRequest: + type: object + properties: + resource: + $ref: '#/components/schemas/api.v1.services.types.Resource' + description: Request message for ResourceService.UpdateResource. api.v1.services.system.UpdateResourceResponse: type: object properties: resource: $ref: '#/components/schemas/api.v1.services.types.Resource' description: Response message for ResourceService.UpdateResource. + api.v1.services.system.UpdateRoleRequest: + type: object + properties: + id: + type: string + description: The id of the role resource to update. + role: + allOf: + - $ref: '#/components/schemas/api.v1.services.types.Role' + description: The role resource which replaces the resource on the server. api.v1.services.system.UpdateRoleResponse: type: object properties: @@ -2930,6 +2953,12 @@ components: api.v1.services.system.UpdateUserStatusResponse: type: object properties: {} + api.v1.services.system.UpdateViewRequest: + type: object + properties: + view: + $ref: '#/components/schemas/api.v1.services.types.View' + description: Request message for ViewService.UpdateView. api.v1.services.system.UpdateViewResponse: type: object properties: @@ -3331,10 +3360,17 @@ components: last_login_ip: type: string description: user.field.last_login_ip + login_ip: + type: string + description: user.field.login_ip last_login_time: type: string description: user.field.last_login_time format: date-time + login_time: + type: string + description: user.field.login_time + format: date-time sanction_date: type: string description: user.field.sanction_date From bb65d242ce67fc02c874baf462d6addcc5fff069 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 6 Jan 2026 17:17:32 +0800 Subject: [PATCH 145/158] feat(schema): update ent schema definitions for system entities including permissions, roles and resources --- internal/data/data.go | 5 +- internal/data/entity/ent/client.go | 9 +- internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 2 +- .../entity/ent/notification/notification.go | 7 + .../data/entity/ent/notification_create.go | 16 ++- .../data/entity/ent/notification_update.go | 20 ++- internal/data/entity/ent/permission_create.go | 2 +- internal/data/entity/ent/permission_update.go | 12 +- internal/data/entity/ent/resource_create.go | 2 +- internal/data/entity/ent/resource_update.go | 12 +- internal/data/entity/ent/runtime/runtime.go | 17 ++- internal/data/entity/ent/schema/user.go | 33 +++-- internal/data/entity/ent/user.go | 2 +- internal/data/entity/ent/user/user.go | 4 +- internal/data/entity/ent/view_create.go | 4 +- internal/data/entity/ent/view_update.go | 24 ++-- .../ent/viewpermission/viewpermission.go | 7 + .../data/entity/ent/viewpermission_create.go | 16 ++- .../data/entity/ent/viewpermission_update.go | 20 ++- .../entity/ent/viewresource/viewresource.go | 7 + .../data/entity/ent/viewresource_create.go | 16 ++- .../data/entity/ent/viewresource_update.go | 20 ++- internal/helpers/ent/mixin/mixin.go | 34 ----- internal/helpers/ent/mixin/soft_delete.go | 133 ++++++++++-------- 25 files changed, 258 insertions(+), 168 deletions(-) diff --git a/internal/data/data.go b/internal/data/data.go index 40434156..359126dd 100644 --- a/internal/data/data.go +++ b/internal/data/data.go @@ -37,7 +37,10 @@ func ProvideDatabase(pv storage.Provider, logger log.Logger) (*ent.Database, fun } activeDB := entsql.OpenDB(db.Dialect(), db.DB()) - database := ent.NewDatabase(ent.Driver(activeDB), ent.Debug()) + database := ent.NewDatabase( + ent.Driver(activeDB), + ent.Debug(), + ) // === The migration logic is moved here === if err := database.Migration(context.Background(), schema.WithDropIndex(true), diff --git a/internal/data/entity/ent/client.go b/internal/data/entity/ent/client.go index 2d35c06e..a101b4fb 100644 --- a/internal/data/entity/ent/client.go +++ b/internal/data/entity/ent/client.go @@ -796,7 +796,8 @@ func (c *NotificationClient) GetX(ctx context.Context, id int64) *Notification { // Hooks returns the client hooks. func (c *NotificationClient) Hooks() []Hook { - return c.hooks.Notification + hooks := c.hooks.Notification + return append(hooks[:len(hooks):len(hooks)], notification.Hooks[:]...) } // Interceptors returns the client interceptors. @@ -3263,7 +3264,8 @@ func (c *ViewPermissionClient) QueryPermission(_m *ViewPermission) *PermissionQu // Hooks returns the client hooks. func (c *ViewPermissionClient) Hooks() []Hook { - return c.hooks.ViewPermission + hooks := c.hooks.ViewPermission + return append(hooks[:len(hooks):len(hooks)], viewpermission.Hooks[:]...) } // Interceptors returns the client interceptors. @@ -3428,7 +3430,8 @@ func (c *ViewResourceClient) QueryResource(_m *ViewResource) *ResourceQuery { // Hooks returns the client hooks. func (c *ViewResourceClient) Hooks() []Hook { - return c.hooks.ViewResource + hooks := c.hooks.ViewResource + return append(hooks[:len(hooks):len(hooks)], viewresource.Hooks[:]...) } // Interceptors returns the client interceptors. diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index 42f15a3a..f4fce002 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"permission.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status.comment\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"Time of soft-delete\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"permission.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status.comment\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index 9aeeff08..e218d482 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -392,7 +392,7 @@ var ( {Name: "update_author", Type: field.TypeInt64, Nullable: true, Comment: "update_author.field.comment", Default: 0}, {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "delete_time", Type: field.TypeTime, Nullable: true, Comment: "Time of soft-delete"}, + {Name: "delete_time", Type: field.TypeTime, Nullable: true, Comment: "delete_time.field.comment"}, {Name: "uuid", Type: field.TypeString, Size: 36, Comment: "entity.user.field.uuid"}, {Name: "allowed_ip", Type: field.TypeString, Comment: "entity.user.field.allowed_ip", Default: "0.0.0.0"}, {Name: "username", Type: field.TypeString, Unique: true, Size: 32, Comment: "entity.user.field.username"}, diff --git a/internal/data/entity/ent/notification/notification.go b/internal/data/entity/ent/notification/notification.go index 49cadcb9..9028319f 100644 --- a/internal/data/entity/ent/notification/notification.go +++ b/internal/data/entity/ent/notification/notification.go @@ -6,6 +6,7 @@ import ( "origadmin/application/admin/internal/data/enums" "time" + "entgo.io/ent" "entgo.io/ent/dialect/sql" ) @@ -57,7 +58,13 @@ func ValidColumn(column string) bool { return false } +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "origadmin/application/admin/internal/data/entity/ent/runtime" var ( + Hooks [1]ent.Hook // DefaultCreateAuthor holds the default value on creation for the "create_author" field. DefaultCreateAuthor int64 // DefaultUpdateAuthor holds the default value on creation for the "update_author" field. diff --git a/internal/data/entity/ent/notification_create.go b/internal/data/entity/ent/notification_create.go index 44c06cb4..e0ef164c 100644 --- a/internal/data/entity/ent/notification_create.go +++ b/internal/data/entity/ent/notification_create.go @@ -146,7 +146,9 @@ func (_c *NotificationCreate) Mutation() *NotificationMutation { // Save creates the Notification in the database. func (_c *NotificationCreate) Save(ctx context.Context) (*Notification, error) { - _c.defaults() + if err := _c.defaults(); err != nil { + return nil, err + } return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } @@ -173,7 +175,7 @@ func (_c *NotificationCreate) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (_c *NotificationCreate) defaults() { +func (_c *NotificationCreate) defaults() error { if _, ok := _c.mutation.CreateAuthor(); !ok { v := notification.DefaultCreateAuthor _c.mutation.SetCreateAuthor(v) @@ -183,10 +185,16 @@ func (_c *NotificationCreate) defaults() { _c.mutation.SetUpdateAuthor(v) } if _, ok := _c.mutation.CreateTime(); !ok { + if notification.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized notification.DefaultCreateTime (forgotten import ent/runtime?)") + } v := notification.DefaultCreateTime() _c.mutation.SetCreateTime(v) } if _, ok := _c.mutation.UpdateTime(); !ok { + if notification.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized notification.DefaultUpdateTime (forgotten import ent/runtime?)") + } v := notification.DefaultUpdateTime() _c.mutation.SetUpdateTime(v) } @@ -203,9 +211,13 @@ func (_c *NotificationCreate) defaults() { _c.mutation.SetStatus(v) } if _, ok := _c.mutation.ID(); !ok { + if notification.DefaultID == nil { + return fmt.Errorf("ent: uninitialized notification.DefaultID (forgotten import ent/runtime?)") + } v := notification.DefaultID() _c.mutation.SetID(v) } + return nil } // check runs all checks and user-defined validators on the builder. diff --git a/internal/data/entity/ent/notification_update.go b/internal/data/entity/ent/notification_update.go index 8aa2e61a..32f7ef31 100644 --- a/internal/data/entity/ent/notification_update.go +++ b/internal/data/entity/ent/notification_update.go @@ -167,7 +167,9 @@ func (_u *NotificationUpdate) Mutation() *NotificationMutation { // Save executes the query and returns the number of nodes affected by the update operation. func (_u *NotificationUpdate) Save(ctx context.Context) (int, error) { - _u.defaults() + if err := _u.defaults(); err != nil { + return 0, err + } return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } @@ -194,11 +196,15 @@ func (_u *NotificationUpdate) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (_u *NotificationUpdate) defaults() { +func (_u *NotificationUpdate) defaults() error { if _, ok := _u.mutation.UpdateTime(); !ok { + if notification.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized notification.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } v := notification.UpdateDefaultUpdateTime() _u.mutation.SetUpdateTime(v) } + return nil } // check runs all checks and user-defined validators on the builder. @@ -440,7 +446,9 @@ func (_u *NotificationUpdateOne) Select(field string, fields ...string) *Notific // Save executes the query and returns the updated Notification entity. func (_u *NotificationUpdateOne) Save(ctx context.Context) (*Notification, error) { - _u.defaults() + if err := _u.defaults(); err != nil { + return nil, err + } return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } @@ -467,11 +475,15 @@ func (_u *NotificationUpdateOne) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (_u *NotificationUpdateOne) defaults() { +func (_u *NotificationUpdateOne) defaults() error { if _, ok := _u.mutation.UpdateTime(); !ok { + if notification.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized notification.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } v := notification.UpdateDefaultUpdateTime() _u.mutation.SetUpdateTime(v) } + return nil } // check runs all checks and user-defined validators on the builder. diff --git a/internal/data/entity/ent/permission_create.go b/internal/data/entity/ent/permission_create.go index d4c5666e..f81b48c9 100644 --- a/internal/data/entity/ent/permission_create.go +++ b/internal/data/entity/ent/permission_create.go @@ -528,7 +528,7 @@ func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewPermissionCreate{config: _c.config, mutation: newViewPermissionMutation(_c.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { diff --git a/internal/data/entity/ent/permission_update.go b/internal/data/entity/ent/permission_update.go index e16b5125..dac41e34 100644 --- a/internal/data/entity/ent/permission_update.go +++ b/internal/data/entity/ent/permission_update.go @@ -690,7 +690,7 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) }, } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -713,7 +713,7 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -736,7 +736,7 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1629,7 +1629,7 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, }, } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1652,7 +1652,7 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1675,7 +1675,7 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { diff --git a/internal/data/entity/ent/resource_create.go b/internal/data/entity/ent/resource_create.go index 9fa0a673..abcfac38 100644 --- a/internal/data/entity/ent/resource_create.go +++ b/internal/data/entity/ent/resource_create.go @@ -442,7 +442,7 @@ func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewResourceCreate{config: _c.config, mutation: newViewResourceMutation(_c.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { diff --git a/internal/data/entity/ent/resource_update.go b/internal/data/entity/ent/resource_update.go index 11eb9bac..bf62ce84 100644 --- a/internal/data/entity/ent/resource_update.go +++ b/internal/data/entity/ent/resource_update.go @@ -432,7 +432,7 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { }, } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -455,7 +455,7 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -478,7 +478,7 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1028,7 +1028,7 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err }, } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1051,7 +1051,7 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1074,7 +1074,7 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index 5e6e019b..70685e9e 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -115,6 +115,8 @@ func init() { // department.IDValidator is a validator for the "id" field. It is called by the builders before save. department.IDValidator = departmentDescID.Validators[0].(func(int64) error) notificationMixin := schema.Notification{}.Mixin() + notificationMixinHooks1 := notificationMixin[1].Hooks() + notification.Hooks[0] = notificationMixinHooks1[0] notificationMixinFields0 := notificationMixin[0].Fields() _ = notificationMixinFields0 notificationMixinFields1 := notificationMixin[1].Fields() @@ -396,13 +398,18 @@ func init() { // rolepermission.PermissionIDValidator is a validator for the "permission_id" field. It is called by the builders before save. rolepermission.PermissionIDValidator = rolepermissionDescPermissionID.Validators[0].(func(int64) error) userMixin := schema.User{}.Mixin() + userMixinHooks1 := userMixin[1].Hooks() userMixinHooks4 := userMixin[4].Hooks() userHooks := schema.User{}.Hooks() - user.Hooks[0] = userMixinHooks4[0] - user.Hooks[1] = userHooks[0] - user.Hooks[2] = userHooks[1] + user.Hooks[0] = userMixinHooks1[0] + user.Hooks[1] = userMixinHooks4[0] + user.Hooks[2] = userHooks[0] + user.Hooks[3] = userHooks[1] + user.Hooks[4] = userHooks[2] userMixinInters4 := userMixin[4].Interceptors() + userInters := schema.User{}.Interceptors() user.Interceptors[0] = userMixinInters4[0] + user.Interceptors[1] = userInters[0] userMixinFields0 := userMixin[0].Fields() _ = userMixinFields0 userMixinFields1 := userMixin[1].Fields() @@ -623,6 +630,8 @@ func init() { // view.IDValidator is a validator for the "id" field. It is called by the builders before save. view.IDValidator = viewDescID.Validators[0].(func(int64) error) viewpermissionMixin := schema.ViewPermission{}.Mixin() + viewpermissionMixinHooks1 := viewpermissionMixin[1].Hooks() + viewpermission.Hooks[0] = viewpermissionMixinHooks1[0] viewpermissionMixinFields0 := viewpermissionMixin[0].Fields() _ = viewpermissionMixinFields0 viewpermissionMixinFields1 := viewpermissionMixin[1].Fields() @@ -666,6 +675,8 @@ func init() { // viewpermission.IDValidator is a validator for the "id" field. It is called by the builders before save. viewpermission.IDValidator = viewpermissionDescID.Validators[0].(func(int64) error) viewresourceMixin := schema.ViewResource{}.Mixin() + viewresourceMixinHooks1 := viewresourceMixin[1].Hooks() + viewresource.Hooks[0] = viewresourceMixinHooks1[0] viewresourceMixinFields0 := viewresourceMixin[0].Fields() _ = viewresourceMixinFields0 viewresourceMixinFields1 := viewresourceMixin[1].Fields() diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index 6c8cc289..dadd1f32 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -109,10 +109,6 @@ func (User) Fields() []ent.Field { mixin.Time("last_login_time", i18n.Text("entity.user.field.last_login_time")), mixin.Time("login_time", i18n.Text("entity.user.field.login_time")), mixin.TimeOptional("sanction_date", i18n.Text("entity.user.field.sanction_date")), - //mixin.OptionalFK("manager_id", i18n.Text("entity.user.field.manager_id")), - //field.String("manager"). - // Default(""). - // Comment(i18n.Text("entity.user.field.manager")), } } @@ -152,6 +148,25 @@ func (User) Edges() []ent.Edge { } } +// Interceptors of the User. +func (User) Interceptors() []ent.Interceptor { + return []ent.Interceptor{ + mixin.SoftDeleteInterceptor(mixin.SoftDeleteMixin{}), + } +} + +// Hooks of the User. +func (User) Hooks() []ent.Hook { + return []ent.Hook{ + // On CREATE, prevent creating more than one system user. + hook.On(preventDuplicateSystemUser, ent.OpCreate), + // On DELETE, prevent system users from being deleted. + hook.On(preventDeleteSystemUser, ent.OpDelete|ent.OpDeleteOne), + // On UPDATE, convert DELETE operations to UPDATE operations. + mixin.SoftDeleteHook(mixin.SoftDeleteMixin{}), + } +} + // preventDuplicateSystemUser is a hook that prevents creating more than one system user. func preventDuplicateSystemUser(next ent.Mutator) ent.Mutator { return hook.UserFunc(func(ctx context.Context, m *gen.UserMutation) (ent.Value, error) { @@ -182,13 +197,3 @@ func preventDeleteSystemUser(next ent.Mutator) ent.Mutator { return next.Mutate(ctx, m) }) } - -// Hooks of the User. -func (User) Hooks() []ent.Hook { - return []ent.Hook{ - // On CREATE, prevent creating more than one system user. - hook.On(preventDuplicateSystemUser, ent.OpCreate), - // On DELETE, prevent system users from being deleted. - hook.On(preventDeleteSystemUser, ent.OpDelete|ent.OpDeleteOne), - } -} diff --git a/internal/data/entity/ent/user.go b/internal/data/entity/ent/user.go index 124a1fd0..de7270ad 100644 --- a/internal/data/entity/ent/user.go +++ b/internal/data/entity/ent/user.go @@ -27,7 +27,7 @@ type User struct { CreateTime time.Time `json:"create_time,omitempty"` // update_time.field.comment UpdateTime time.Time `json:"update_time,omitempty"` - // Time of soft-delete + // delete_time.field.comment DeleteTime *time.Time `json:"delete_time,omitempty"` // entity.user.field.uuid UUID string `json:"uuid,omitempty"` diff --git a/internal/data/entity/ent/user/user.go b/internal/data/entity/ent/user/user.go index 9a7d0644..65c8add1 100644 --- a/internal/data/entity/ent/user/user.go +++ b/internal/data/entity/ent/user/user.go @@ -184,8 +184,8 @@ func ValidColumn(column string) bool { // // import _ "origadmin/application/admin/internal/data/entity/ent/runtime" var ( - Hooks [3]ent.Hook - Interceptors [1]ent.Interceptor + Hooks [5]ent.Hook + Interceptors [2]ent.Interceptor // DefaultCreateAuthor holds the default value on creation for the "create_author" field. DefaultCreateAuthor int64 // DefaultUpdateAuthor holds the default value on creation for the "update_author" field. diff --git a/internal/data/entity/ent/view_create.go b/internal/data/entity/ent/view_create.go index b9e34252..12ea154c 100644 --- a/internal/data/entity/ent/view_create.go +++ b/internal/data/entity/ent/view_create.go @@ -518,7 +518,7 @@ func (_c *ViewCreate) createSpec() (*View, *sqlgraph.CreateSpec) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewResourceCreate{config: _c.config, mutation: newViewResourceMutation(_c.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -541,7 +541,7 @@ func (_c *ViewCreate) createSpec() (*View, *sqlgraph.CreateSpec) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewPermissionCreate{config: _c.config, mutation: newViewPermissionMutation(_c.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { diff --git a/internal/data/entity/ent/view_update.go b/internal/data/entity/ent/view_update.go index 9902cfcc..cb710a9c 100644 --- a/internal/data/entity/ent/view_update.go +++ b/internal/data/entity/ent/view_update.go @@ -629,7 +629,7 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { }, } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -652,7 +652,7 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -675,7 +675,7 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -695,7 +695,7 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { }, } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -718,7 +718,7 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -741,7 +741,7 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1487,7 +1487,7 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { }, } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1510,7 +1510,7 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1533,7 +1533,7 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewResourceCreate{config: _u.config, mutation: newViewResourceMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1553,7 +1553,7 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { }, } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1576,7 +1576,7 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { @@ -1599,7 +1599,7 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { edge.Target.Nodes = append(edge.Target.Nodes, k) } createE := &ViewPermissionCreate{config: _u.config, mutation: newViewPermissionMutation(_u.config, OpCreate)} - createE.defaults() + _ = createE.defaults() _, specE := createE.createSpec() edge.Target.Fields = specE.Fields if specE.ID.Value != nil { diff --git a/internal/data/entity/ent/viewpermission/viewpermission.go b/internal/data/entity/ent/viewpermission/viewpermission.go index aca30d06..4e06fadd 100644 --- a/internal/data/entity/ent/viewpermission/viewpermission.go +++ b/internal/data/entity/ent/viewpermission/viewpermission.go @@ -5,6 +5,7 @@ package viewpermission import ( "time" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" ) @@ -69,7 +70,13 @@ func ValidColumn(column string) bool { return false } +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "origadmin/application/admin/internal/data/entity/ent/runtime" var ( + Hooks [1]ent.Hook // DefaultCreateAuthor holds the default value on creation for the "create_author" field. DefaultCreateAuthor int64 // DefaultUpdateAuthor holds the default value on creation for the "update_author" field. diff --git a/internal/data/entity/ent/viewpermission_create.go b/internal/data/entity/ent/viewpermission_create.go index ca189207..fdfa3130 100644 --- a/internal/data/entity/ent/viewpermission_create.go +++ b/internal/data/entity/ent/viewpermission_create.go @@ -121,7 +121,9 @@ func (_c *ViewPermissionCreate) Mutation() *ViewPermissionMutation { // Save creates the ViewPermission in the database. func (_c *ViewPermissionCreate) Save(ctx context.Context) (*ViewPermission, error) { - _c.defaults() + if err := _c.defaults(); err != nil { + return nil, err + } return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } @@ -148,7 +150,7 @@ func (_c *ViewPermissionCreate) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (_c *ViewPermissionCreate) defaults() { +func (_c *ViewPermissionCreate) defaults() error { if _, ok := _c.mutation.CreateAuthor(); !ok { v := viewpermission.DefaultCreateAuthor _c.mutation.SetCreateAuthor(v) @@ -158,17 +160,27 @@ func (_c *ViewPermissionCreate) defaults() { _c.mutation.SetUpdateAuthor(v) } if _, ok := _c.mutation.CreateTime(); !ok { + if viewpermission.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized viewpermission.DefaultCreateTime (forgotten import ent/runtime?)") + } v := viewpermission.DefaultCreateTime() _c.mutation.SetCreateTime(v) } if _, ok := _c.mutation.UpdateTime(); !ok { + if viewpermission.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized viewpermission.DefaultUpdateTime (forgotten import ent/runtime?)") + } v := viewpermission.DefaultUpdateTime() _c.mutation.SetUpdateTime(v) } if _, ok := _c.mutation.ID(); !ok { + if viewpermission.DefaultID == nil { + return fmt.Errorf("ent: uninitialized viewpermission.DefaultID (forgotten import ent/runtime?)") + } v := viewpermission.DefaultID() _c.mutation.SetID(v) } + return nil } // check runs all checks and user-defined validators on the builder. diff --git a/internal/data/entity/ent/viewpermission_update.go b/internal/data/entity/ent/viewpermission_update.go index 17899ba7..5162bfd2 100644 --- a/internal/data/entity/ent/viewpermission_update.go +++ b/internal/data/entity/ent/viewpermission_update.go @@ -148,7 +148,9 @@ func (_u *ViewPermissionUpdate) ClearPermission() *ViewPermissionUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (_u *ViewPermissionUpdate) Save(ctx context.Context) (int, error) { - _u.defaults() + if err := _u.defaults(); err != nil { + return 0, err + } return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } @@ -175,11 +177,15 @@ func (_u *ViewPermissionUpdate) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (_u *ViewPermissionUpdate) defaults() { +func (_u *ViewPermissionUpdate) defaults() error { if _, ok := _u.mutation.UpdateTime(); !ok { + if viewpermission.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized viewpermission.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } v := viewpermission.UpdateDefaultUpdateTime() _u.mutation.SetUpdateTime(v) } + return nil } // check runs all checks and user-defined validators on the builder. @@ -452,7 +458,9 @@ func (_u *ViewPermissionUpdateOne) Select(field string, fields ...string) *ViewP // Save executes the query and returns the updated ViewPermission entity. func (_u *ViewPermissionUpdateOne) Save(ctx context.Context) (*ViewPermission, error) { - _u.defaults() + if err := _u.defaults(); err != nil { + return nil, err + } return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } @@ -479,11 +487,15 @@ func (_u *ViewPermissionUpdateOne) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (_u *ViewPermissionUpdateOne) defaults() { +func (_u *ViewPermissionUpdateOne) defaults() error { if _, ok := _u.mutation.UpdateTime(); !ok { + if viewpermission.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized viewpermission.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } v := viewpermission.UpdateDefaultUpdateTime() _u.mutation.SetUpdateTime(v) } + return nil } // check runs all checks and user-defined validators on the builder. diff --git a/internal/data/entity/ent/viewresource/viewresource.go b/internal/data/entity/ent/viewresource/viewresource.go index bdd58738..356e4adc 100644 --- a/internal/data/entity/ent/viewresource/viewresource.go +++ b/internal/data/entity/ent/viewresource/viewresource.go @@ -5,6 +5,7 @@ package viewresource import ( "time" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" ) @@ -69,7 +70,13 @@ func ValidColumn(column string) bool { return false } +// Note that the variables below are initialized by the runtime +// package on the initialization of the application. Therefore, +// it should be imported in the main as follows: +// +// import _ "origadmin/application/admin/internal/data/entity/ent/runtime" var ( + Hooks [1]ent.Hook // DefaultCreateAuthor holds the default value on creation for the "create_author" field. DefaultCreateAuthor int64 // DefaultUpdateAuthor holds the default value on creation for the "update_author" field. diff --git a/internal/data/entity/ent/viewresource_create.go b/internal/data/entity/ent/viewresource_create.go index 6dd0af92..8b11ffbd 100644 --- a/internal/data/entity/ent/viewresource_create.go +++ b/internal/data/entity/ent/viewresource_create.go @@ -121,7 +121,9 @@ func (_c *ViewResourceCreate) Mutation() *ViewResourceMutation { // Save creates the ViewResource in the database. func (_c *ViewResourceCreate) Save(ctx context.Context) (*ViewResource, error) { - _c.defaults() + if err := _c.defaults(); err != nil { + return nil, err + } return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } @@ -148,7 +150,7 @@ func (_c *ViewResourceCreate) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (_c *ViewResourceCreate) defaults() { +func (_c *ViewResourceCreate) defaults() error { if _, ok := _c.mutation.CreateAuthor(); !ok { v := viewresource.DefaultCreateAuthor _c.mutation.SetCreateAuthor(v) @@ -158,17 +160,27 @@ func (_c *ViewResourceCreate) defaults() { _c.mutation.SetUpdateAuthor(v) } if _, ok := _c.mutation.CreateTime(); !ok { + if viewresource.DefaultCreateTime == nil { + return fmt.Errorf("ent: uninitialized viewresource.DefaultCreateTime (forgotten import ent/runtime?)") + } v := viewresource.DefaultCreateTime() _c.mutation.SetCreateTime(v) } if _, ok := _c.mutation.UpdateTime(); !ok { + if viewresource.DefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized viewresource.DefaultUpdateTime (forgotten import ent/runtime?)") + } v := viewresource.DefaultUpdateTime() _c.mutation.SetUpdateTime(v) } if _, ok := _c.mutation.ID(); !ok { + if viewresource.DefaultID == nil { + return fmt.Errorf("ent: uninitialized viewresource.DefaultID (forgotten import ent/runtime?)") + } v := viewresource.DefaultID() _c.mutation.SetID(v) } + return nil } // check runs all checks and user-defined validators on the builder. diff --git a/internal/data/entity/ent/viewresource_update.go b/internal/data/entity/ent/viewresource_update.go index 70589dac..602085ba 100644 --- a/internal/data/entity/ent/viewresource_update.go +++ b/internal/data/entity/ent/viewresource_update.go @@ -148,7 +148,9 @@ func (_u *ViewResourceUpdate) ClearResource() *ViewResourceUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (_u *ViewResourceUpdate) Save(ctx context.Context) (int, error) { - _u.defaults() + if err := _u.defaults(); err != nil { + return 0, err + } return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } @@ -175,11 +177,15 @@ func (_u *ViewResourceUpdate) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (_u *ViewResourceUpdate) defaults() { +func (_u *ViewResourceUpdate) defaults() error { if _, ok := _u.mutation.UpdateTime(); !ok { + if viewresource.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized viewresource.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } v := viewresource.UpdateDefaultUpdateTime() _u.mutation.SetUpdateTime(v) } + return nil } // check runs all checks and user-defined validators on the builder. @@ -452,7 +458,9 @@ func (_u *ViewResourceUpdateOne) Select(field string, fields ...string) *ViewRes // Save executes the query and returns the updated ViewResource entity. func (_u *ViewResourceUpdateOne) Save(ctx context.Context) (*ViewResource, error) { - _u.defaults() + if err := _u.defaults(); err != nil { + return nil, err + } return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } @@ -479,11 +487,15 @@ func (_u *ViewResourceUpdateOne) ExecX(ctx context.Context) { } // defaults sets the default values of the builder before save. -func (_u *ViewResourceUpdateOne) defaults() { +func (_u *ViewResourceUpdateOne) defaults() error { if _, ok := _u.mutation.UpdateTime(); !ok { + if viewresource.UpdateDefaultUpdateTime == nil { + return fmt.Errorf("ent: uninitialized viewresource.UpdateDefaultUpdateTime (forgotten import ent/runtime?)") + } v := viewresource.UpdateDefaultUpdateTime() _u.mutation.SetUpdateTime(v) } + return nil } // check runs all checks and user-defined validators on the builder. diff --git a/internal/helpers/ent/mixin/mixin.go b/internal/helpers/ent/mixin/mixin.go index e9c7a621..2784331f 100644 --- a/internal/helpers/ent/mixin/mixin.go +++ b/internal/helpers/ent/mixin/mixin.go @@ -278,28 +278,6 @@ func (m updateMixin) Indexes() []ent.Index { } } -// DeleteMixin schema to include control and time fields. -type DeleteMixin struct { - mixin.Schema -} - -// Fields of the Model. -func (m DeleteMixin) Fields() []ent.Field { - return []ent.Field{ - field.Time("delete_time"). - Comment(i18n.Text("delete_time.field.comment")). - Optional(). - Nillable(), - } -} - -// Indexes of the mixin. -func (m DeleteMixin) Indexes() []ent.Index { - return []ent.Index{ - index.Fields("delete_time"), - } -} - var ( // ModelMixin provides a basic set of fields for standard models. ModelMixin = []ent.Mixin{ @@ -324,15 +302,3 @@ var ( DefaultUpdateMixin(), } ) - -type softDeleteKey struct{} - -// SkipSoftDelete returns a new context that skips the soft-delete interceptor/mutators. -func SkipSoftDelete(parent context.Context) context.Context { - return context.WithValue(parent, softDeleteKey{}, true) -} - -func IsSkipSoftDelete(ctx context.Context) bool { - v, _ := ctx.Value(softDeleteKey{}).(bool) - return v -} diff --git a/internal/helpers/ent/mixin/soft_delete.go b/internal/helpers/ent/mixin/soft_delete.go index ff6ebaf4..a786ea66 100644 --- a/internal/helpers/ent/mixin/soft_delete.go +++ b/internal/helpers/ent/mixin/soft_delete.go @@ -2,16 +2,35 @@ package mixin import ( "context" - "errors" + "fmt" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/schema/field" "entgo.io/ent/schema/mixin" + + gen "origadmin/application/admin/internal/data/entity/ent" + "origadmin/application/admin/internal/data/entity/ent/hook" + "origadmin/application/admin/internal/data/entity/ent/intercept" + "origadmin/application/admin/internal/helpers/i18n" ) -// SoftDeleteMixin implements the soft-delete pattern for a schema. +type softDeleteKey struct{} + +// SkipSoftDelete returns a new context that skips the soft-delete interceptor/mutators. +func SkipSoftDelete(parent context.Context) context.Context { + return context.WithValue(parent, softDeleteKey{}, true) +} + +// IsSkipSoftDelete checks if the context is configured to skip soft-delete. +func IsSkipSoftDelete(ctx context.Context) bool { + v, _ := ctx.Value(softDeleteKey{}).(bool) + return v +} + +// SoftDeleteMixin provides soft-delete capabilities to a schema. +// It adds a `delete_time` field and a hook to intercept delete operations. type SoftDeleteMixin struct { mixin.Schema } @@ -20,84 +39,74 @@ type SoftDeleteMixin struct { func (SoftDeleteMixin) Fields() []ent.Field { return []ent.Field{ field.Time("delete_time"). - Comment("Time of soft-delete"). + Comment(i18n.Text("delete_time.field.comment")). Optional(). Nillable(), } } // Hooks of the SoftDeleteMixin. -func (SoftDeleteMixin) Hooks() []ent.Hook { +// This hook intercepts delete operations and converts them to update operations +// that set the `delete_time` field. +func (d SoftDeleteMixin) Hooks() []ent.Hook { return []ent.Hook{ - softDeleteHook(), + SoftDeleteHook(d), } } // Interceptors of the SoftDeleteMixin. -func (SoftDeleteMixin) Interceptors() []ent.Interceptor { +func (d SoftDeleteMixin) Interceptors() []ent.Interceptor { return []ent.Interceptor{ - softDeleteInterceptor(), + SoftDeleteInterceptor(d), } } -// softDeleteHook intercepts DELETE operations and converts them to UPDATEs. -func softDeleteHook() ent.Hook { - // Define an interface for mutations that support soft-delete. - // This relies on structural typing and code generation. - type softDeleter interface { - SetOp(ent.Op) - SetDeleteTime(time.Time) - } - - return func(next ent.Mutator) ent.Mutator { - return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { - // Skip if not a DELETE operation or if soft-delete is skipped. - if !m.Op().Is(ent.OpDelete|ent.OpDeleteOne) || IsSkipSoftDelete(ctx) { - return next.Mutate(ctx, m) - } - - // Check if the mutation implements the softDeleter interface. - mx, ok := m.(softDeleter) - if !ok { - return nil, errors.New("ent: mutation does not support soft-delete") - } - - // Change the operation to UPDATE and set the delete_time. - mx.SetOp(ent.OpUpdate) - mx.SetDeleteTime(time.Now()) - - // Proceed with the mutation, which is now an update. - return next.Mutate(ctx, m) - }) - } +// SoftDeleteHook intercepts DELETE operations and converts them to UPDATEs. +func SoftDeleteHook(d SoftDeleteMixin) ent.Hook { + return hook.On( + func(next ent.Mutator) ent.Mutator { + return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { + // Skip soft-delete, means delete the entity permanently. + if IsSkipSoftDelete(ctx) { + return next.Mutate(ctx, m) + } + mx, ok := m.(interface { + SetOp(ent.Op) + Client() *gen.Client + SetDeleteTime(time.Time) + WhereP(...func(*sql.Selector)) + }) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + d.P(mx) + mx.SetOp(ent.OpUpdate) + mx.SetDeleteTime(time.Now()) + return mx.Client().Mutate(ctx, m) + }) + }, + ent.OpDeleteOne|ent.OpDelete, + ) } -// softDeleteInterceptor filters out soft-deleted records from queries. -func softDeleteInterceptor() ent.Interceptor { - // Define an interface for queries that support WhereP. - type queryWither interface { - WhereP(...func(*sql.Selector)) - } - - return ent.InterceptFunc(func(next ent.Querier) ent.Querier { - return ent.QuerierFunc(func(ctx context.Context, query ent.Query) (ent.Value, error) { - // Skip if soft-delete is skipped for this query. - if IsSkipSoftDelete(ctx) { - return next.Query(ctx, query) - } - - // Check if the query supports the WhereP method. - q, ok := query.(queryWither) - if !ok { - return next.Query(ctx, query) - } +type P interface { + WhereP(...func(*sql.Selector)) +} - // Add the WHERE clause to filter out soft-deleted records. - q.WhereP(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C("delete_time"))) - }) +// P adds a storage-level predicate to the queries and mutations. +func (d SoftDeleteMixin) P(w P) { + w.WhereP( + sql.FieldIsNull("delete_time"), + ) +} - return next.Query(ctx, query) - }) +// SoftDeleteInterceptor returns a query interceptor that filters out soft-deleted records. +func SoftDeleteInterceptor(d SoftDeleteMixin) ent.Interceptor { + return intercept.TraverseFunc(func(ctx context.Context, q intercept.Query) error { + if IsSkipSoftDelete(ctx) { + return nil + } + d.P(q) + return nil }) } From 73972a29693f4dcee49b9301ee79cd35252f2d05 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 6 Jan 2026 18:17:47 +0800 Subject: [PATCH 146/158] chore(deps): update go.mod dependencies and tool versions --- go.mod | 95 +++++++++------- go.sum | 339 +++++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 288 insertions(+), 146 deletions(-) diff --git a/go.mod b/go.mod index 59864c9b..edd79329 100644 --- a/go.mod +++ b/go.mod @@ -18,30 +18,31 @@ require ( github.com/google/gnostic v0.7.1 github.com/google/uuid v1.6.0 github.com/google/wire v0.7.0 - github.com/mattn/go-sqlite3 v1.14.32 // indirect + github.com/mattn/go-sqlite3 v1.14.33 // indirect github.com/mojocn/base64Captcha v1.3.8 - github.com/origadmin/contrib v1.1.0 - github.com/origadmin/runtime v0.2.14 + github.com/origadmin/contrib v1.2.0 + github.com/origadmin/runtime v0.2.15 github.com/origadmin/slog-kratos v1.0.5 // indirect - github.com/origadmin/toolkits/codec v1.2.0 - github.com/origadmin/toolkits/crypto v1.2.0 + github.com/origadmin/toolkits/codec v1.3.0 + github.com/origadmin/toolkits/crypto v1.3.0 github.com/origadmin/toolkits/errors v1.2.0 github.com/sony/sonyflake v1.3.0 github.com/sqlite3ent/sqlite3 v1.40.0 - golang.org/x/net v0.47.0 // indirect + golang.org/x/net v0.48.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b - google.golang.org/grpc v1.77.0 + google.golang.org/grpc v1.78.0 google.golang.org/protobuf v1.36.11 ) require ( - github.com/bufbuild/buf v1.61.0 - github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251217105121-fb8e43efb207 - github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251217105121-fb8e43efb207 - github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 + github.com/air-verse/air v1.63.6 + github.com/bufbuild/buf v1.62.1 + github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20260105075216-c7a58ff59f80 + github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20260105075216-c7a58ff59f80 + github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 github.com/joho/godotenv v1.5.1 github.com/origadmin/toolkits/i18n v1.2.0 - golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 + golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0 ) @@ -57,17 +58,17 @@ require ( buf.build/go/bufplugin v0.9.0 // indirect buf.build/go/bufprivateusage v0.1.0 // indirect buf.build/go/interrupt v1.1.0 // indirect - buf.build/go/protovalidate v1.0.1 // indirect + buf.build/go/protovalidate v1.1.0 // indirect buf.build/go/protoyaml v0.6.0 // indirect buf.build/go/spdx v0.2.0 // indirect buf.build/go/standard v0.1.0 // indirect cel.dev/expr v0.25.1 // indirect connectrpc.com/connect v1.19.1 // indirect - connectrpc.com/otelconnect v0.8.0 // indirect + connectrpc.com/otelconnect v0.9.0 // indirect dario.cat/mergo v1.0.2 // indirect github.com/AlecAivazis/survey/v2 v2.3.7 // indirect github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect - github.com/BurntSushi/toml v1.5.0 // indirect + github.com/BurntSushi/toml v1.6.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/antlr4-go/antlr/v4 v4.13.1 // indirect @@ -75,15 +76,18 @@ require ( github.com/armon/go-metrics v0.4.1 // indirect github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect + github.com/bep/godartsass/v2 v2.5.0 // indirect + github.com/bep/golibsass v1.2.0 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect - github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8 // indirect + github.com/bufbuild/protocompile v0.14.2-0.20251223142729-db46c1b9d34e // indirect github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1 // indirect - github.com/casbin/govaluate v1.3.0 // indirect + github.com/casbin/govaluate v1.10.0 // indirect github.com/catppuccin/go v0.3.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 // indirect github.com/charmbracelet/bubbletea v1.3.10 // indirect - github.com/charmbracelet/colorprofile v0.3.3 // indirect + github.com/charmbracelet/colorprofile v0.4.1 // indirect github.com/charmbracelet/huh v0.8.0 // indirect github.com/charmbracelet/lipgloss v1.1.0 // indirect github.com/charmbracelet/x/ansi v0.11.3 // indirect @@ -100,7 +104,7 @@ require ( github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect github.com/dchest/uniuri v1.2.0 // indirect github.com/distribution/reference v0.6.0 // indirect - github.com/docker/cli v29.0.4+incompatible // indirect + github.com/docker/cli v29.1.3+incompatible // indirect github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker v28.5.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.9.4 // indirect @@ -114,7 +118,7 @@ require ( github.com/fsnotify/fsnotify v1.9.0 // indirect github.com/go-chi/chi/v5 v5.2.3 // indirect github.com/go-kratos/aegis v0.2.0 // indirect - github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251217105121-fb8e43efb207 // indirect + github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20260105075216-c7a58ff59f80 // indirect github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20251201062103-6f0b3015b803 // indirect github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20251201062103-6f0b3015b803 // indirect github.com/go-logr/logr v1.4.3 // indirect @@ -123,10 +127,11 @@ require ( github.com/go-openapi/inflect v0.21.2 // indirect github.com/go-playground/form/v4 v4.3.0 // indirect github.com/go-viper/mapstructure/v2 v2.4.0 // indirect + github.com/gobwas/glob v0.2.3 // indirect github.com/gofrs/flock v0.13.0 // indirect + github.com/gohugoio/hugo v0.149.1 // indirect github.com/golang-cz/devslog v0.0.15 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/golang/mock v1.7.0-rc.1 // indirect github.com/google/cel-go v0.26.1 // indirect github.com/google/gnostic-models v0.7.1 // indirect github.com/google/go-cmp v0.7.0 // indirect @@ -163,22 +168,26 @@ require ( github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/term v0.5.2 // indirect - github.com/morikuni/aec v1.0.0 // indirect + github.com/morikuni/aec v1.1.0 // indirect github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/termenv v0.16.0 // indirect - github.com/ncruces/go-strftime v0.1.10 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/ncruces/go-strftime v1.0.0 // indirect + github.com/olekukonko/errors v1.1.0 // indirect + github.com/olekukonko/ll v0.0.9 // indirect + github.com/olekukonko/tablewriter v1.0.9 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect - github.com/origadmin/toolkits/slogx v1.1.0 // indirect + github.com/origadmin/toolkits/slogx v1.3.0 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible // indirect + github.com/pelletier/go-toml v1.9.5 // indirect + github.com/pelletier/go-toml/v2 v2.2.4 // indirect github.com/petermattis/goid v0.0.0-20251121121749-a11dd1a45f9a // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect - github.com/quic-go/qpack v0.5.1 // indirect - github.com/quic-go/quic-go v0.56.0 // indirect + github.com/quic-go/qpack v0.6.0 // indirect + github.com/quic-go/quic-go v0.58.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rs/cors v1.11.1 // indirect @@ -189,11 +198,13 @@ require ( github.com/shoenig/go-m1cpu v0.1.7 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/afero v1.15.0 // indirect + github.com/spf13/cast v1.10.0 // indirect github.com/spf13/cobra v1.10.2 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/stoewer/go-strcase v1.3.1 // indirect github.com/stretchr/objx v0.5.2 // indirect - github.com/tetratelabs/wazero v1.9.0 // indirect + github.com/tdewolff/parse/v2 v2.8.3 // indirect + github.com/tetratelabs/wazero v1.11.0 // indirect github.com/tidwall/btree v1.8.1 // indirect github.com/tklauser/go-sysconf v0.3.16 // indirect github.com/tklauser/numcpus v0.11.0 // indirect @@ -207,27 +218,27 @@ require ( go.lsp.dev/protocol v0.12.0 // indirect go.lsp.dev/uri v0.3.0 // indirect go.opentelemetry.io/auto/sdk v1.2.1 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect - go.opentelemetry.io/otel v1.38.0 // indirect - go.opentelemetry.io/otel/metric v1.38.0 // indirect - go.opentelemetry.io/otel/trace v1.38.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 // indirect + go.opentelemetry.io/otel v1.39.0 // indirect + go.opentelemetry.io/otel/metric v1.39.0 // indirect + go.opentelemetry.io/otel/trace v1.39.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.1 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/crypto v0.45.0 // indirect - golang.org/x/image v0.26.0 // indirect - golang.org/x/mod v0.30.0 // indirect - golang.org/x/sync v0.18.0 // indirect - golang.org/x/sys v0.38.0 // indirect - golang.org/x/term v0.37.0 // indirect - golang.org/x/text v0.31.0 // indirect - golang.org/x/tools v0.39.0 // indirect + golang.org/x/crypto v0.46.0 // indirect + golang.org/x/image v0.34.0 // indirect + golang.org/x/mod v0.31.0 // indirect + golang.org/x/sync v0.19.0 // indirect + golang.org/x/sys v0.39.0 // indirect + golang.org/x/term v0.38.0 // indirect + golang.org/x/text v0.32.0 // indirect + golang.org/x/tools v0.40.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - modernc.org/libc v1.66.10 // indirect + modernc.org/libc v1.67.4 // indirect modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.11.0 // indirect - modernc.org/sqlite v1.40.1 // indirect + modernc.org/sqlite v1.42.2 // indirect pluginrpc.com/pluginrpc v0.5.0 // indirect ) diff --git a/go.sum b/go.sum index c0cf9afc..3965502f 100644 --- a/go.sum +++ b/go.sum @@ -20,8 +20,8 @@ buf.build/go/bufprivateusage v0.1.0 h1:SzCoCcmzS3zyXHEXHeSQhGI7OTkgtljoknLzsUz9G buf.build/go/bufprivateusage v0.1.0/go.mod h1:GlCCJ3VVF7EqqU0CoRmo1FzAwwaKymEWSr+ty69xU5w= buf.build/go/interrupt v1.1.0 h1:olBuhgv9Sav4/9pkSLoxgiOsZDgM5VhRhvRpn3DL0lE= buf.build/go/interrupt v1.1.0/go.mod h1:ql56nXPG1oHlvZa6efNC7SKAQ/tUjS6z0mhJl0gyeRM= -buf.build/go/protovalidate v1.0.1 h1:Fwmf08OOUuKVeMvEnDmcKxQam4PJc/zFgvVX64BhTms= -buf.build/go/protovalidate v1.0.1/go.mod h1:SoZmvk/3ZzOVg9YSkTdm4grMAByjf8zgZq4ZNaLZXoQ= +buf.build/go/protovalidate v1.1.0 h1:pQqEQRpOo4SqS60qkvmhLTTQU9JwzEvdyiqAtXa5SeY= +buf.build/go/protovalidate v1.1.0/go.mod h1:bGZcPiAQDC3ErCHK3t74jSoJDFOs2JH3d7LWuTEIdss= buf.build/go/protoyaml v0.6.0 h1:Nzz1lvcXF8YgNZXk+voPPwdU8FjDPTUV4ndNTXN0n2w= buf.build/go/protoyaml v0.6.0/go.mod h1:RgUOsBu/GYKLDSIRgQXniXbNgFlGEZnQpRAUdLAFV2Q= buf.build/go/spdx v0.2.0 h1:IItqM0/cMxvFJJumcBuP8NrsIzMs/UYjp/6WSpq8LTw= @@ -32,8 +32,8 @@ cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4= cel.dev/expr v0.25.1/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= connectrpc.com/connect v1.19.1 h1:R5M57z05+90EfEvCY1b7hBxDVOUl45PrtXtAV2fOC14= connectrpc.com/connect v1.19.1/go.mod h1:tN20fjdGlewnSFeZxLKb0xwIZ6ozc3OQs2hTXy4du9w= -connectrpc.com/otelconnect v0.8.0 h1:a4qrN4H8aEE2jAoCxheZYYfEjXMgVPyL9OzPQLBEFXU= -connectrpc.com/otelconnect v0.8.0/go.mod h1:AEkVLjCPXra+ObGFCOClcJkNjS7zPaQSqvO0lCyjfZc= +connectrpc.com/otelconnect v0.9.0 h1:NggB3pzRC3pukQWaYbRHJulxuXvmCKCKkQ9hbrHAWoA= +connectrpc.com/otelconnect v0.9.0/go.mod h1:AEkVLjCPXra+ObGFCOClcJkNjS7zPaQSqvO0lCyjfZc= dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4= @@ -42,8 +42,10 @@ github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkk github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEKWjV8V+WSxDXJ4NFATAsZjh8iIbsQIg= github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg= -github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 h1:+tu3HOoMXB7RXEINRVIpxJCT+KdYiI7LAEAUrOw3dIU= +github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69/go.mod h1:L1AbZdiDllfyYH5l5OkAaZtk7VkWe89bPJFmnDBNHxg= +github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= +github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= @@ -55,6 +57,10 @@ github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63n github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/air-verse/air v1.63.6 h1:izaqxGhacjPCBtVIGtEJ8wXEtwx4TxruFnE0wGJzipI= +github.com/air-verse/air v1.63.6/go.mod h1:Dnn4m4DlC9IQiNd3ir57SOdpvGJ3gnC1+OlIGMi2fJY= +github.com/alecthomas/chroma/v2 v2.20.0 h1:sfIHpxPyR07/Oylvmcai3X/exDlE8+FA820NTz+9sGw= +github.com/alecthomas/chroma/v2 v2.20.0/go.mod h1:e7tViK0xh/Nf4BYHl00ycY6rV7b8iXBksI9E359yNmA= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -69,15 +75,47 @@ github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.1-0.20221118154546-54df44f2176c h1:651/eoCRnQ7YtSjAnSzRucrJz+3iGEFt+ysraELS81M= +github.com/armon/go-radix v1.0.1-0.20221118154546-54df44f2176c/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8= github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY= github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E= +github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= +github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bep/clocks v0.5.0 h1:hhvKVGLPQWRVsBP/UB7ErrHYIO42gINVbvqxvYTPVps= +github.com/bep/clocks v0.5.0/go.mod h1:SUq3q+OOq41y2lRQqH5fsOoxN8GbxSiT6jvoVVLCVhU= +github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY= +github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0= +github.com/bep/gitmap v1.9.0 h1:2pyb1ex+cdwF6c4tsrhEgEKfyNfxE34d5K+s2sa9byc= +github.com/bep/gitmap v1.9.0/go.mod h1:Juq6e1qqCRvc1W7nzgadPGI9IGV13ZncEebg5atj4Vo= +github.com/bep/goat v0.5.0 h1:S8jLXHCVy/EHIoCY+btKkmcxcXFd34a0Q63/0D4TKeA= +github.com/bep/goat v0.5.0/go.mod h1:Md9x7gRxiWKs85yHlVTvHQw9rg86Bm+Y4SuYE8CTH7c= +github.com/bep/godartsass/v2 v2.5.0 h1:tKRvwVdyjCIr48qgtLa4gHEdtRkPF8H1OeEhJAEv7xg= +github.com/bep/godartsass/v2 v2.5.0/go.mod h1:rjsi1YSXAl/UbsGL85RLDEjRKdIKUlMQHr6ChUNYOFU= +github.com/bep/golibsass v1.2.0 h1:nyZUkKP/0psr8nT6GR2cnmt99xS93Ji82ZD9AgOK6VI= +github.com/bep/golibsass v1.2.0/go.mod h1:DL87K8Un/+pWUS75ggYv41bliGiolxzDKWJAq3eJ1MA= +github.com/bep/goportabletext v0.1.0 h1:8dqym2So1cEqVZiBa4ZnMM1R9l/DnC1h4ONg4J5kujw= +github.com/bep/goportabletext v0.1.0/go.mod h1:6lzSTsSue75bbcyvVc0zqd1CdApuT+xkZQ6Re5DzZFg= +github.com/bep/gowebp v0.4.0 h1:QihuVnvIKbRoeBNQkN0JPMM8ClLmD6V2jMftTFwSK3Q= +github.com/bep/gowebp v0.4.0/go.mod h1:95gtYkAA8iIn1t3HkAPurRCVGV/6NhgaHJ1urz0iIwc= +github.com/bep/helpers v0.6.0 h1:qtqMCK8XPFNM9hp5Ztu9piPjxNNkk8PIyUVjg6v8Bsw= +github.com/bep/helpers v0.6.0/go.mod h1:IOZlgx5PM/R/2wgyCatfsgg5qQ6rNZJNDpWGXqDR044= +github.com/bep/imagemeta v0.12.0 h1:ARf+igs5B7pf079LrqRnwzQ/wEB8Q9v4NSDRZO1/F5k= +github.com/bep/imagemeta v0.12.0/go.mod h1:23AF6O+4fUi9avjiydpKLStUNtJr5hJB4rarG18JpN8= +github.com/bep/lazycache v0.8.0 h1:lE5frnRjxaOFbkPZ1YL6nijzOPPz6zeXasJq8WpG4L8= +github.com/bep/lazycache v0.8.0/go.mod h1:BQ5WZepss7Ko91CGdWz8GQZi/fFnCcyWupv8gyTeKwk= +github.com/bep/logg v0.4.0 h1:luAo5mO4ZkhA5M1iDVDqDqnBBnlHjmtZF6VAyTp+nCQ= +github.com/bep/logg v0.4.0/go.mod h1:Ccp9yP3wbR1mm++Kpxet91hAZBEQgmWgFgnXX3GkIV0= +github.com/bep/overlayfs v0.10.0 h1:wS3eQ6bRsLX+4AAmwGjvoFSAQoeheamxofFiJ2SthSE= +github.com/bep/overlayfs v0.10.0/go.mod h1:ouu4nu6fFJaL0sPzNICzxYsBeWwrjiTdFZdK4lI3tro= +github.com/bep/tmc v0.5.1 h1:CsQnSC6MsomH64gw0cT5f+EwQDcvZz4AazKunFwTpuI= +github.com/bep/tmc v0.5.1/go.mod h1:tGYHN8fS85aJPhDLgXETVKp+PR382OvFi2+q2GkGsq0= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= @@ -86,27 +124,30 @@ github.com/bmatcuk/doublestar/v4 v4.9.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/ github.com/bmatcuk/doublestar/v4 v4.9.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4= github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs= -github.com/bufbuild/buf v1.61.0 h1:JPaK/RM2eoheyzznW+1LxaFgN6xjBCi8s25q2kUbH9A= -github.com/bufbuild/buf v1.61.0/go.mod h1:Xs3leBmxjL5tTnSVYfNwNXHXD1k5et3fR/tJyIyQl4s= -github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8 h1:l4PKzJ7Usff8j5/e+YaWZPaM+rJHIghgDxRn8vDNxNo= -github.com/bufbuild/protocompile v0.14.2-0.20251120233202-3f9009bcd6c8/go.mod h1:HKN246DRQwavs64sr2xYmSL+RFOFxmLti+WGCZ2jh9U= +github.com/bufbuild/buf v1.62.1 h1:QdYB6JDW7dP+5H7sKx0lN1raxnuUJDDlEJtPHDYKB0g= +github.com/bufbuild/buf v1.62.1/go.mod h1:igMN/6U32/GDzyfkmn0VfIaKoeOnWTTizEf5CG0/87k= +github.com/bufbuild/protocompile v0.14.2-0.20251223142729-db46c1b9d34e h1:LQA+1MyiPkolGHJGC2GMDC5Xu+0RDVH6jGMKech7Exs= +github.com/bufbuild/protocompile v0.14.2-0.20251223142729-db46c1b9d34e/go.mod h1:5UUj46Eu+U+C59C5N6YilaMI7WWfP2bW9xGcOkme2DI= github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1 h1:V1xulAoqLqVg44rY97xOR+mQpD2N+GzhMHVwJ030WEU= github.com/bufbuild/protoplugin v0.0.0-20250218205857-750e09ce93e1/go.mod h1:c5D8gWRIZ2HLWO3gXYTtUfw/hbJyD8xikv2ooPxnklQ= github.com/casbin/casbin/v2 v2.135.0 h1:6BLkMQiGotYyS5yYeWgW19vxqugUlvHFkFiLnLR/bxk= github.com/casbin/casbin/v2 v2.135.0/go.mod h1:FmcfntdXLTcYXv/hxgNntcRPqAbwOG9xsism0yXT+18= -github.com/casbin/govaluate v1.3.0 h1:VA0eSY0M2lA86dYd5kPPuNZMUD9QkWnOCnavGrw9myc= github.com/casbin/govaluate v1.3.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= +github.com/casbin/govaluate v1.10.0 h1:ffGw51/hYH3w3rZcxO/KcaUIDOLP84w7nsidMVgaDG0= +github.com/casbin/govaluate v1.10.0/go.mod h1:G/UnbIjZk/0uMNaLwZZmFQrR72tYRZWQkO70si/iR7A= github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY= github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws= github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7/go.mod h1:ISC1gtLcVilLOf23wvTfoQuYbW2q0JevFxPfUzZ9Ybw= github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw= github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4= -github.com/charmbracelet/colorprofile v0.3.3 h1:DjJzJtLP6/NZ8p7Cgjno0CKGr7wwRJGxWUwh2IyhfAI= -github.com/charmbracelet/colorprofile v0.3.3/go.mod h1:nB1FugsAbzq284eJcjfah2nhdSLppN2NqvfotkfRYP4= +github.com/charmbracelet/colorprofile v0.4.1 h1:a1lO03qTrSIRaK8c3JRxJDZOvhvIeSco3ej+ngLk1kk= +github.com/charmbracelet/colorprofile v0.4.1/go.mod h1:U1d9Dljmdf9DLegaJ0nGZNJvoXAhayhmidOdcBwAvKk= github.com/charmbracelet/huh v0.8.0 h1:Xz/Pm2h64cXQZn/Jvele4J3r7DDiqFCNIVteYukxDvY= github.com/charmbracelet/huh v0.8.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4= github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY= @@ -131,6 +172,8 @@ github.com/charmbracelet/x/xpty v0.1.2 h1:Pqmu4TEJ8KeA9uSkISKMU3f+C1F6OGBn8ABuGl github.com/charmbracelet/x/xpty v0.1.2/go.mod h1:XK2Z0id5rtLWcpeNiMYBccNNBrP2IJnzHI0Lq13Xzq4= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= +github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= +github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk= github.com/clipperhouse/displaywidth v0.6.2 h1:ZDpTkFfpHOKte4RG5O/BOyf3ysnvFswpyYrV7z2uAKo= @@ -161,10 +204,14 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dchest/uniuri v1.2.0 h1:koIcOUdrTIivZgSLhHQvKgqdWZq5d7KdMEWF1Ud6+5g= github.com/dchest/uniuri v1.2.0/go.mod h1:fSzm4SLHzNZvWLvWJew423PhAzkpNQYq+uNLq4kxhkY= +github.com/disintegration/gift v1.2.1 h1:Y005a1X4Z7Uc+0gLpSAsKhWi4qLtsdEcMIbbdvdZ6pc= +github.com/disintegration/gift v1.2.1/go.mod h1:Jh2i7f7Q2BM7Ezno3PhfezbR1xpUg9dUg3/RlKGr4HI= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/cli v29.0.4+incompatible h1:mffN/hPqaI39vx/4QiSkdldHeM0rP1ZZBIXRUOPI5+I= -github.com/docker/cli v29.0.4+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= +github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/docker/cli v29.1.3+incompatible h1:+kz9uDWgs+mAaIZojWfFt4d53/jv0ZUOOoSh5ZnH36c= +github.com/docker/cli v29.1.3+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v28.5.2+incompatible h1:DBX0Y0zAjZbSrm1uzOkdr1onVghKaftjlSWt4AFexzM= @@ -186,6 +233,8 @@ github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= +github.com/evanw/esbuild v0.25.9 h1:aU7GVC4lxJGC1AyaPwySWjSIaNLAdVEEuq3chD0Khxs= +github.com/evanw/esbuild v0.25.9/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -193,20 +242,27 @@ github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= +github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/getkin/kin-openapi v0.133.0 h1:pJdmNohVIJ97r4AUFtEXRXwESr8b0bD721u/Tz6k8PQ= +github.com/getkin/kin-openapi v0.133.0/go.mod h1:boAciF6cXk5FhPqe/NQeBTeenbjqU4LhWBf09ILVvWE= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE= github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kratos/aegis v0.2.0 h1:dObzCDWn3XVjUkgxyBp6ZeWtx/do0DPZ7LY3yNSJLUQ= github.com/go-kratos/aegis v0.2.0/go.mod h1:v0R2m73WgEEYB3XYu6aE2WcMwsZkJ/Rzuf5eVccm7bI= -github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251217105121-fb8e43efb207 h1:9/jBnQSuRMIdLTfeoM0IWXF1cGFKVjKb7fTDOEoD4H8= -github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20251217105121-fb8e43efb207/go.mod h1:S0grzHPbqVD8ilueT7yd0k32/ZSbY64y7zdovhGNzyg= -github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251217105121-fb8e43efb207 h1:admtUgwA6qCvdh1A5Ke0r+1s1aEO8wrLWj07/5uqXxM= -github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20251217105121-fb8e43efb207/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= -github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251217105121-fb8e43efb207 h1:SlUVCwGBsK/ITX9HkWSGNhbA0Ud9t56r0m9qhy+pip0= -github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20251217105121-fb8e43efb207/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= +github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20260105075216-c7a58ff59f80 h1:eQso+jdomEw7m5fnKdtaXeN1Mr9uLwXDT0/bXF4kB1w= +github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20260105075216-c7a58ff59f80/go.mod h1:S0grzHPbqVD8ilueT7yd0k32/ZSbY64y7zdovhGNzyg= +github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20260105075216-c7a58ff59f80 h1:e0F8JmzlacvEWyo+rki9AQ4qgz5xSddWCfyAWhXJ43Y= +github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2 v2.0.0-20260105075216-c7a58ff59f80/go.mod h1:xOlUxoJf69I9g3z8xfd7quBxlSZFP+IyoipYz0x2Ikk= +github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20260105075216-c7a58ff59f80 h1:EWDtxS1uIXepYwl3IO4mNBvNcqImOVeeO8U4bkOiGFA= +github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20260105075216-c7a58ff59f80/go.mod h1:vq88Fzyqs42QnpH+vkJxdJKpkWLnNPzfkjStSUUCKDk= github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20251201062103-6f0b3015b803 h1:Ve6D/PdPNf1bUvrTjJPrxvR7Qdwz4Q1PNNE15f4tOTg= github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20251201062103-6f0b3015b803/go.mod h1:kflKS9PrbiyPNmC1hQCRyJTsF5ip5rBMYy94GTcABKI= github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20251201062103-6f0b3015b803 h1:WedOGvRd7vjApUL1ORLcCMRfly+xov2Ug5HSvNMortY= @@ -225,6 +281,10 @@ github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= github.com/go-openapi/inflect v0.21.2 h1:0gClGlGcxifcJR56zwvhaOulnNgnhc4qTAkob5ObnSM= github.com/go-openapi/inflect v0.21.2/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/form/v4 v4.3.0 h1:OVttojbQv2WNCs4P+VnjPtrt/+30Ipw4890W3OaFlvk= @@ -234,11 +294,31 @@ github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4= +github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= +github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= +github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/goexts/generic v0.14.0 h1:Lw8QKwgN9w6vnHuEbs3K+42frxi7MHS2pJrg7/ZCkJc= github.com/goexts/generic v0.14.0/go.mod h1:3L0Ou9PAX35WPvO+aSeZsoENlGIRSDAuZ8/GNqUqaEs= github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw= github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e h1:QArsSubW7eDh8APMXkByjQWvuljwPGAGQpJEFn0F0wY= +github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e/go.mod h1:3Ltoo9Banwq0gOtcOwxuHG6omk+AwsQPADyw2vQYOJQ= +github.com/gohugoio/hashstructure v0.5.0 h1:G2fjSBU36RdwEJBWJ+919ERvOVqAg9tfcYp47K9swqg= +github.com/gohugoio/hashstructure v0.5.0/go.mod h1:Ser0TniXuu/eauYmrwM4o64EBvySxNzITEOLlm4igec= +github.com/gohugoio/httpcache v0.7.0 h1:ukPnn04Rgvx48JIinZvZetBfHaWE7I01JR2Q2RrQ3Vs= +github.com/gohugoio/httpcache v0.7.0/go.mod h1:fMlPrdY/vVJhAriLZnrF5QpN3BNAcoBClgAyQd+lGFI= +github.com/gohugoio/hugo v0.149.1 h1:uWOc8Ve4h4e48FyYhBquRoHCJviyxA5yGrFJLT48yio= +github.com/gohugoio/hugo v0.149.1/go.mod h1:HS6BP6e8FGxungP4CHC3zeLDvhBLnTJIjHJZWTZjs7o= +github.com/gohugoio/hugo-goldmark-extensions/extras v0.5.0 h1:dco+7YiOryRoPOMXwwaf+kktZSCtlFtreNdiJbETvYE= +github.com/gohugoio/hugo-goldmark-extensions/extras v0.5.0/go.mod h1:CRrxQTKeM3imw+UoS4EHKyrqB7Zp6sAJiqHit+aMGTE= +github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.3.1 h1:nUzXfRTszLliZuN0JTKeunXTRaiFX6ksaWP0puLLYAY= +github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.3.1/go.mod h1:Wy8ThAA8p2/w1DY05vEzq6EIeI2mzDjvHsu7ULBVwog= +github.com/gohugoio/locales v0.14.0 h1:Q0gpsZwfv7ATHMbcTNepFd59H7GoykzWJIxi113XGDc= +github.com/gohugoio/locales v0.14.0/go.mod h1:ip8cCAv/cnmVLzzXtiTpPwgJ4xhKZranqNqtoIu0b/4= +github.com/gohugoio/localescompressed v1.0.1 h1:KTYMi8fCWYLswFyJAeOtuk/EkXR/KPTHHNN9OS+RTxo= +github.com/gohugoio/localescompressed v1.0.1/go.mod h1:jBF6q8D7a0vaEmcWPNcAjUZLJaIVNiwvM3WlmTvooB0= github.com/golang-cz/devslog v0.0.15 h1:ejoBLTCwJHWGbAmDf2fyTJJQO3AkzcPjw8SC9LaOQMI= github.com/golang-cz/devslog v0.0.15/go.mod h1:bSe5bm0A7Nyfqtijf1OMNgVJHlWEuVSXnkuASiE1vV8= github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= @@ -278,10 +358,14 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4= github.com/google/wire v0.7.0/go.mod h1:n6YbUQD9cPKTnHXEBN2DXlOp/mVADhVErcMFb0v3J18= +github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= +github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 h1:NmZ1PKzSTQbuGHw9DGPFomqkkLWMC+vZCkfs+FHv1Vg= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3/go.mod h1:zQrxl1YP88HQlA6i9c63DSVPFklWpGX4OWAc9bFuaH4= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 h1:kEISI/Gx67NzH3nJxAmY/dGac80kKZgZt134u7Y/k1s= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4/go.mod h1:6Nz966r3vQYCqIzWsuEl9d7cf7mRhtDmm++sOxlnfxI= +github.com/hairyhenderson/go-codeowners v0.7.0 h1:s0W4wF8bdsBEjTWzwzSlsatSthWtTAF2xLgo4a4RwAo= +github.com/hairyhenderson/go-codeowners v0.7.0/go.mod h1:wUlNgQ3QjqC4z8DnM5nnCYVq/icpqXJyJOukKx5U8/Q= github.com/hashicorp/consul/api v1.33.0 h1:MnFUzN1Bo6YDGi/EsRLbVNgA4pyCymmcswrE5j4OHBM= github.com/hashicorp/consul/api v1.33.0/go.mod h1:vLz2I/bqqCYiG0qRHGerComvbwSWKswc8rRFtnYBrIw= github.com/hashicorp/consul/sdk v0.17.0 h1:N/JigV6y1yEMfTIhXoW0DXUecM2grQnFuRpY7PcLHLI= @@ -320,6 +404,8 @@ github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl/v2 v2.23.0 h1:Fphj1/gCylPxHutVSEOf2fBOh1VE4AuLV7+kbJf3qos= github.com/hashicorp/hcl/v2 v2.23.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -334,12 +420,16 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jdkato/prose v1.2.1 h1:Fp3UnJmLVISmlc57BgKUzdjr0lOtjqTZicL3PaYy6cU= +github.com/jdkato/prose v1.2.1/go.mod h1:AiRHgVagnEx2JbQRQowVBKjG0bcs/vtkGCH1dYAL1rA= github.com/jdx/go-netrc v1.0.0 h1:QbLMLyCZGj0NA8glAhxUpf1zDg6cxnWgMBbjq40W0gQ= github.com/jdx/go-netrc v1.0.0/go.mod h1:Gh9eFQJnoTNIRHXl2j5bJXA1u84hQWJWgGh569zF3v8= github.com/jhump/protoreflect/v2 v2.0.0-beta.2 h1:qZU+rEZUOYTz1Bnhi3xbwn+VxdXkLVeEpAeZzVXLY88= github.com/jhump/protoreflect/v2 v2.0.0-beta.2/go.mod h1:4tnOYkB/mq7QTyS3YKtVtNrJv4Psqout8HA1U+hZtgM= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= @@ -358,6 +448,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kyokomi/emoji/v2 v2.2.13 h1:GhTfQa67venUUvmleTNFnb+bi7S3aocF7ZCXU9fSO7U= +github.com/kyokomi/emoji/v2 v2.2.13/go.mod h1:JUcn42DTdsXJo1SWanHh4HKDEyPaR5CqkmoirZZP9qE= github.com/lmittmann/tint v1.1.2 h1:2CQzrL6rslrsyjqLDwD11bZ5OpLBPU+g3G/r5LSfS8w= github.com/lmittmann/tint v1.1.2/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE= github.com/lucasb-eyer/go-colorful v1.3.0 h1:2/yBRLdWBZKrf7gB40FoiKfAWYQ0lqNcbuQwVHXptag= @@ -366,6 +458,12 @@ github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 h1:PwQumkgq4/acIi github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/lyft/protoc-gen-star/v2 v2.0.4 h1:JDlNKttNIRd68AAIychs0AqEpO8/I/WYi01OQ7Raw6Q= github.com/lyft/protoc-gen-star/v2 v2.0.4/go.mod h1:amey7yeodaJhXSbf/TlLvWiqQfLOSpEk//mLlc+axEk= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/makeworld-the-better-one/dither/v2 v2.4.0 h1:Az/dYXiTcwcRSe59Hzw4RI1rSnAZns+1msaCXetrMFE= +github.com/makeworld-the-better-one/dither/v2 v2.4.0/go.mod h1:VBtN8DXO7SNtyGmLiGA7IsFeKrBkQPze1/iAeM95arc= +github.com/marekm4/color-extractor v1.2.1 h1:3Zb2tQsn6bITZ8MBVhc33Qn1k5/SEuZ18mrXGUqIwn0= +github.com/marekm4/color-extractor v1.2.1/go.mod h1:90VjmiHI6M8ez9eYUaXLdcKnS+BAOp7w+NpwBdkJmpA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -383,15 +481,16 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4= github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= -github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= -github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/mattn/go-sqlite3 v1.14.33 h1:A5blZ5ulQo2AtayQ9/limgHEkFreKj1Dv226a1K73s0= +github.com/mattn/go-sqlite3 v1.14.33/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= +github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= +github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= @@ -403,6 +502,8 @@ github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTS github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c h1:cqn374mizHuIWj+OSJCajGr/phAmuMug9qIX3l9CflE= +github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw= @@ -415,46 +516,66 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/mojocn/base64Captcha v1.3.8 h1:rrN9BhCwXKS8ht1e21kvR3iTaMgf4qPC9sRoV52bqEg= github.com/mojocn/base64Captcha v1.3.8/go.mod h1:QFZy927L8HVP3+VV5z2b1EAEiv1KxVJKZbAucVgLUy4= -github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= -github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= +github.com/morikuni/aec v1.1.0 h1:vBBl0pUnvi/Je71dsRrhMBtreIqNMYErSAbEeb8jrXQ= +github.com/morikuni/aec v1.1.0/go.mod h1:xDRgiq/iw5l+zkao76YTKzKttOp2cwPEne25HDkJnBw= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI= github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo= github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA= github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= +github.com/muesli/smartcrop v0.3.0 h1:JTlSkmxWg/oQ1TcLDoypuirdE8Y/jzNirQeLkxpA6Oc= +github.com/muesli/smartcrop v0.3.0/go.mod h1:i2fCI/UorTfgEpPPLWiFBv4pye+YAG78RwcQLUkocpI= github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc= github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/ncruces/go-strftime v0.1.10 h1:UYG9J7oU9Z0i5ohqzg9kicKcV4hc5YzEgZowOGjP4us= -github.com/ncruces/go-strftime v0.1.10/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w= +github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/niklasfasching/go-org v1.9.1 h1:/3s4uTPOF06pImGa2Yvlp24yKXZoTYM+nsIlMzfpg/0= +github.com/niklasfasching/go-org v1.9.1/go.mod h1:ZAGFFkWvUQcpazmi/8nHqwvARpr1xpb+Es67oUGX/48= +github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY= +github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037/go.mod h1:2bpvgLBZEtENV5scfDFEtB/5+1M4hkQhDQrccEJ/qGw= +github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c= +github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o= +github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM= +github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y= +github.com/olekukonko/ll v0.0.9 h1:Y+1YqDfVkqMWuEQMclsF9HUR5+a82+dxJuL1HHSRpxI= +github.com/olekukonko/ll v0.0.9/go.mod h1:En+sEW0JNETl26+K8eZ6/W4UQ7CYSrrgg/EdIYT2H8g= +github.com/olekukonko/tablewriter v1.0.9 h1:XGwRsYLC2bY7bNd93Dk51bcPZksWZmLYuaTHR0FqfL8= +github.com/olekukonko/tablewriter v1.0.9/go.mod h1:5c+EBPeSqvXnLLgkm9isDdzR3wjfBkHR9Nhfp3NWrzo= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= -github.com/origadmin/contrib v1.1.0 h1:5ZMuxPas9+WIDNDlG+99Y5JHGwQRq2rZ4TjJXM5/Oek= -github.com/origadmin/contrib v1.1.0/go.mod h1:lqSKEAQHNRf96zWG3XvZZv96oFUeMBstLAWBGP7VIus= -github.com/origadmin/runtime v0.2.14 h1:4D0udgzQumSsbr2XW0Ozuv4jma7vWvY+blqaiEp8xtc= -github.com/origadmin/runtime v0.2.14/go.mod h1:HIzn3AGmC/OybEmANsXZFTo/xPSRTVnyE+89mm8PMCE= +github.com/origadmin/contrib v1.2.0 h1:pyNPpIBHLUOgB6CzYMVp9uClrwtEb14ESInIqXM/AuI= +github.com/origadmin/contrib v1.2.0/go.mod h1:LG2kg7teY2H5Yr73cAcbdPvbysS5sV2cdGkxLmfcILs= github.com/origadmin/slog-kratos v1.0.5 h1:yDLxVaN8A8MMmIny3xy65uT1wLKl3S9tVZVijn+1Vhc= github.com/origadmin/slog-kratos v1.0.5/go.mod h1:zuOf6B1cMjPwwMJ2or2sPbzNAdx/fMn/6MekdG30Xh4= -github.com/origadmin/toolkits/codec v1.2.0 h1:Tnnxc2Bcf9wTcMiV/4h89CxGTz+v6EN6+ZBbYdyCLD8= -github.com/origadmin/toolkits/codec v1.2.0/go.mod h1:NgbdOtowlFY79/CXZzRhes1tRHTBr3XZX+VBWL7yUpw= -github.com/origadmin/toolkits/crypto v1.2.0 h1:SajjJuDHf/KT0AEvvW/Z2HnPW07vnyCvIlgD4lfykeA= -github.com/origadmin/toolkits/crypto v1.2.0/go.mod h1:PlR7+Dh88bVl8z+wKjAcxVBHxl3fllwfhLGOvzAO9nQ= +github.com/origadmin/toolkits/codec v1.3.0 h1:U9eRN5R8N6/yly5JoxKJ9UCRayaIbdLUBd+Xekonu5w= +github.com/origadmin/toolkits/codec v1.3.0/go.mod h1:NgbdOtowlFY79/CXZzRhes1tRHTBr3XZX+VBWL7yUpw= +github.com/origadmin/toolkits/crypto v1.3.0 h1:5p27+nInJapn6SpsLS/2jTgZDY4DnoRBb+JinIBvdrs= +github.com/origadmin/toolkits/crypto v1.3.0/go.mod h1:PlR7+Dh88bVl8z+wKjAcxVBHxl3fllwfhLGOvzAO9nQ= github.com/origadmin/toolkits/errors v1.2.0 h1:dQzGVa9QtlptaQ3ljXz6+dbMwHMBORPdiyAF5xxErlk= github.com/origadmin/toolkits/errors v1.2.0/go.mod h1:YCPShNuAmn0ns0JB43iKbVdWcPA8XCTiFG+7UA2+tJw= github.com/origadmin/toolkits/i18n v1.2.0 h1:1/fRapVye5IQXPTOfMUZAHq26/rYWxXh3+6IaP1yOWw= github.com/origadmin/toolkits/i18n v1.2.0/go.mod h1:utfVq5IU8KGeygz1Ey6g+6fV3oplUNW2iZofUG8Be5c= -github.com/origadmin/toolkits/slogx v1.1.0 h1:UEqIMxMwUiWZe4/g/0aIVA/i7FMKqh4kSj0J+PRPJi8= -github.com/origadmin/toolkits/slogx v1.1.0/go.mod h1:rpyegD2CZypR+ctlpVz4q3KROwb3xc6mUKQQZ9ow+qI= +github.com/origadmin/toolkits/slogx v1.3.0 h1:F4ril11Te2wSKvifEjdBIeFvtFHk7cEG+lxoX56SB4I= +github.com/origadmin/toolkits/slogx v1.3.0/go.mod h1:p2hI6XV9DWZli+vyRRO+t9OQKbcBuDIDgYJ6TEvfVAI= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= +github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= +github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= +github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= +github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/petermattis/goid v0.0.0-20251121121749-a11dd1a45f9a h1:VweslR2akb/ARhXfqSfRbj1vpWwYXf3eeAUyw/ndms0= github.com/petermattis/goid v0.0.0-20251121121749-a11dd1a45f9a/go.mod h1:pxMtw7cyUw6B2bRH0ZBANSPg+AoSud1I1iyJHI69jH4= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -483,10 +604,10 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/protocolbuffers/protoscope v0.0.0-20221109213918-8e7a6aafa2c9 h1:arwj11zP0yJIxIRiDn22E0H8PxfF7TsTrc2wIPFIsf4= github.com/protocolbuffers/protoscope v0.0.0-20221109213918-8e7a6aafa2c9/go.mod h1:SKZx6stCn03JN3BOWTwvVIO2ajMkb/zQdTceXYhKw/4= -github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= -github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= -github.com/quic-go/quic-go v0.56.0 h1:q/TW+OLismmXAehgFLczhCDTYB3bFmua4D9lsNBWxvY= -github.com/quic-go/quic-go v0.56.0/go.mod h1:9gx5KsFQtw2oZ6GZTyh+7YEvOxWCL9WZAepnHxgAo6c= +github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8= +github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII= +github.com/quic-go/quic-go v0.58.0 h1:ggY2pvZaVdB9EyojxL1p+5mptkuHyX5MOSv4dgWF4Ug= +github.com/quic-go/quic-go v0.58.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= @@ -520,6 +641,8 @@ github.com/sony/sonyflake v1.3.0 h1:tiB4Dlp0lnmKp/h6BLXA14P8Qi+LYS9+0QRpcrKHvg4= github.com/sony/sonyflake v1.3.0/go.mod h1:LORtCywH/cq10ZbyfhKrHYgAUGH7mOBa76enV9txy/Y= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg= +github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY= +github.com/spf13/cast v1.10.0/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -546,8 +669,14 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I= -github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM= +github.com/tdewolff/minify/v2 v2.24.2 h1:vnY3nTulEAbCAAlxTxPPDkzG24rsq31SOzp63yT+7mo= +github.com/tdewolff/minify/v2 v2.24.2/go.mod h1:1JrCtoZXaDbqioQZfk3Jdmr0GPJKiU7c1Apmb+7tCeE= +github.com/tdewolff/parse/v2 v2.8.3 h1:5VbvtJ83cfb289A1HzRA9sf02iT8YyUwN84ezjkdY1I= +github.com/tdewolff/parse/v2 v2.8.3/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo= +github.com/tdewolff/test v1.0.11 h1:FdLbwQVHxqG16SlkGveC0JVyrJN62COWTRyUFzfbtBE= +github.com/tdewolff/test v1.0.11/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8= +github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA= +github.com/tetratelabs/wazero v1.11.0/go.mod h1:eV28rsN8Q+xwjogd7f4/Pp4xFxO7uOGbLcD/LzB1wiU= github.com/tidwall/btree v1.8.1 h1:27ehoXvm5AG/g+1VxLS1SD3vRhp/H7LuEfwNvddEdmA= github.com/tidwall/btree v1.8.1/go.mod h1:jBbTdUWhSZClZWoDg54VnvV7/54modSOzDN7VXftj1A= github.com/tklauser/go-sysconf v0.3.16 h1:frioLaCQSsF5Cy1jgRBrzr6t502KIIwQ0MArYICU0nA= @@ -557,10 +686,15 @@ github.com/tklauser/numcpus v0.11.0/go.mod h1:z+LwcLq54uWZTX0u/bGobaV34u6V7KNlTZ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/vbatts/tar-split v0.12.2 h1:w/Y6tjxpeiFMR47yzZPlPj/FcPLpXbTUi/9H7d3CPa4= github.com/vbatts/tar-split v0.12.2/go.mod h1:eF6B6i6ftWQcDqEn3/iGFRFRo8cBIMSJVOpnNdfTMFA= +github.com/woodsbury/decimal128 v1.3.0 h1:8pffMNWIlC0O5vbyHWFZAt5yWvWcrHA+3ovIIjVWss0= +github.com/woodsbury/decimal128 v1.3.0/go.mod h1:C5UTmyTjW3JftjUFzOVhC20BEQa2a4ZKOB5I6Zjb+ds= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.7.13 h1:GPddIs617DnBLFFVJFgpo1aBfe/4xcvMc3SB5t/D0pA= +github.com/yuin/goldmark v1.7.13/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg= +github.com/yuin/goldmark-emoji v1.0.6 h1:QWfF2FYaXwL74tfGOW5izeiZepUDroDJfWubQI9HTHs= +github.com/yuin/goldmark-emoji v1.0.6/go.mod h1:ukxJDKFpdFb5x0a5HqbdlcKtebh086iJpI31LTKmWuA= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zclconf/go-cty v1.16.2 h1:LAJSwc3v81IRBZyUVQDUdZ7hs3SYs9jv0eZJDWHD/70= @@ -579,24 +713,24 @@ go.lsp.dev/uri v0.3.0 h1:KcZJmh6nFIBeJzTugn5JTU6OOyG0lDOo3R9KwTxTYbo= go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I= go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64= go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 h1:RbKq8BG0FI8OiXhBfcRtqqHcZcka+gU3cskNuf05R18= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0/go.mod h1:h06DGIukJOevXaj/xrNjhi/2098RZzcLTbc0jDAUbsg= -go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= -go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0 h1:GqRJVj7UmLjCVyVJ3ZFLdPRmhDUp2zFmQe3RHIOsw24= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.38.0/go.mod h1:ri3aaHSmCTVYu2AWv44YMauwAQc0aqI9gHKIcSbI1pU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 h1:ssfIgGNANqpVFCndZvcuyKbl0g+UAVcbBcqGkG28H0Y= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0/go.mod h1:GQ/474YrbE4Jx8gZ4q5I4hrhUzM6UPzyrqJYV2AqPoQ= +go.opentelemetry.io/otel v1.39.0 h1:8yPrr/S0ND9QEfTfdP9V+SiwT4E0G7Y5MO7p85nis48= +go.opentelemetry.io/otel v1.39.0/go.mod h1:kLlFTywNWrFyEdH0oj2xK0bFYZtHRYUdv1NklR/tgc8= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 h1:f0cb2XPmrqn4XMy9PNliTgRKJgS5WcL/u0/WRYGz4t0= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0/go.mod h1:vnakAaFckOMiMtOIhFI2MNH4FYrZzXCYxmb1LlhoGz8= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0 h1:wpMfgF8E1rkrT1Z6meFh1NDtownE9Ii3n3X2GJYjsaU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0/go.mod h1:wAy0T/dUbs468uOlkT31xjvqQgEVXv58BRFWEgn5v/0= -go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= -go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= -go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E= -go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg= -go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM= -go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA= -go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= -go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= -go.opentelemetry.io/proto/otlp v1.8.0 h1:fRAZQDcAFHySxpJ1TwlA1cJ4tvcrw7nXl9xWWC8N5CE= -go.opentelemetry.io/proto/otlp v1.8.0/go.mod h1:tIeYOeNBU4cvmPqpaji1P+KbB4Oloai8wN4rWzRrFF0= +go.opentelemetry.io/otel/metric v1.39.0 h1:d1UzonvEZriVfpNKEVmHXbdf909uGTOQjA0HF0Ls5Q0= +go.opentelemetry.io/otel/metric v1.39.0/go.mod h1:jrZSWL33sD7bBxg1xjrqyDjnuzTUB0x1nBERXd7Ftcs= +go.opentelemetry.io/otel/sdk v1.39.0 h1:nMLYcjVsvdui1B/4FRkwjzoRVsMK8uL/cj0OyhKzt18= +go.opentelemetry.io/otel/sdk v1.39.0/go.mod h1:vDojkC4/jsTJsE+kh+LXYQlbL8CgrEcwmt1ENZszdJE= +go.opentelemetry.io/otel/sdk/metric v1.39.0 h1:cXMVVFVgsIf2YL6QkRF4Urbr/aMInf+2WKg+sEJTtB8= +go.opentelemetry.io/otel/sdk/metric v1.39.0/go.mod h1:xq9HEVH7qeX69/JnwEfp6fVq5wosJsY1mt4lLfYdVew= +go.opentelemetry.io/otel/trace v1.39.0 h1:2d2vfpEDmCJ5zVYz7ijaJdOF59xLomrvj7bjt6/qCJI= +go.opentelemetry.io/otel/trace v1.39.0/go.mod h1:88w4/PnZSazkGzz/w84VHpQafiU4EtqqlVdxWy+rNOA= +go.opentelemetry.io/proto/otlp v1.9.0 h1:l706jCMITVouPOqEnii2fIAuO3IVGBRPV5ICjceRb/A= +go.opentelemetry.io/proto/otlp v1.9.0/go.mod h1:xE+Cx5E/eEHw+ISFkwPLwCZefwVjY+pqKg1qcK03+/4= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= @@ -610,26 +744,24 @@ go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= -golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= -golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= -golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2wtOnGAHZWCHUM4KGzY= -golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70= +golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU= +golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= +golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 h1:fQsdNF2N+/YewlRZiricy4P1iimyPKZ/xwniHj8Q2a0= +golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU= golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= -golang.org/x/image v0.26.0 h1:4XjIFEZWQmCZi6Wv8BoxsDhRU3RVnLX04dToTDAEPlY= -golang.org/x/image v0.26.0/go.mod h1:lcxbMFAovzpnJxzXS3nyL83K27tmqtKzIJpctK8YO5c= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/image v0.34.0 h1:33gCkyw9hmwbZJeZkct8XyR11yH889EQt/QH4VmXMn8= +golang.org/x/image v0.34.0/go.mod h1:2RNFBZRB+vnwwFil8GkMdRvrJOFd1AzdZI6vOY+eJVU= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= -golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= +golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI= +golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -638,15 +770,14 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= -golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -658,14 +789,13 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= -golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -678,13 +808,11 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -697,8 +825,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= -golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -707,8 +835,8 @@ golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= -golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= -golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= +golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q= +golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -721,37 +849,34 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= -golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= -golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= +golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= +golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b h1:uA40e2M6fYRBf0+8uN5mLlqUtV192iiksiICIBkYJ1E= google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:Xa7le7qx2vmqB/SzWUBa7KdMjpdpAHlh5QCSnjessQk= google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b h1:Mv8VFug0MP9e5vUxfBcE3vUkV6CImK3cMNMIDFjmzxU= google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ= -google.golang.org/grpc v1.77.0 h1:wVVY6/8cGA6vvffn+wWK5ToddbgdU3d8MNENr4evgXM= -google.golang.org/grpc v1.77.0/go.mod h1:z0BY1iVj0q8E1uSQCjL9cppRj+gnZjzDnzV0dHhrNig= +google.golang.org/grpc v1.78.0 h1:K1XZG/yGDJnzMdd/uZHAkVqJE+xIDOcmdSFZkBUicNc= +google.golang.org/grpc v1.78.0/go.mod h1:I47qjTo4OKbMkjA/aOOwxDIiPSBofUtQUI5EfpWvW7U= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0 h1:6Al3kEFFP9VJhRz3DID6quisgPnTeZVr4lep9kkxdPA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0/go.mod h1:QLvsjh0OIR0TYBeiu2bkWGTJBUNQ64st52iWj/yA93I= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= @@ -767,23 +892,27 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= -modernc.org/cc/v4 v4.26.5 h1:xM3bX7Mve6G8K8b+T11ReenJOT+BmVqQj0FY5T4+5Y4= -modernc.org/cc/v4 v4.26.5/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= -modernc.org/ccgo/v4 v4.28.1 h1:wPKYn5EC/mYTqBO373jKjvX2n+3+aK7+sICCv4Fjy1A= -modernc.org/ccgo/v4 v4.28.1/go.mod h1:uD+4RnfrVgE6ec9NGguUNdhqzNIeeomeXf6CL0GTE5Q= +modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis= +modernc.org/cc/v4 v4.27.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= +modernc.org/ccgo/v4 v4.30.1 h1:4r4U1J6Fhj98NKfSjnPUN7Ze2c6MnAdL0hWw6+LrJpc= +modernc.org/ccgo/v4 v4.30.1/go.mod h1:bIOeI1JL54Utlxn+LwrFyjCx2n2RDiYEaJVSrgdrRfM= modernc.org/fileutil v1.3.40 h1:ZGMswMNc9JOCrcrakF1HrvmergNLAmxOPjizirpfqBA= modernc.org/fileutil v1.3.40/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc= modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= +modernc.org/gc/v3 v3.1.1 h1:k8T3gkXWY9sEiytKhcgyiZ2L0DTyCQ/nvX+LoCljoRE= +modernc.org/gc/v3 v3.1.1/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY= modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= -modernc.org/libc v1.66.10 h1:yZkb3YeLx4oynyR+iUsXsybsX4Ubx7MQlSYEw4yj59A= -modernc.org/libc v1.66.10/go.mod h1:8vGSEwvoUoltr4dlywvHqjtAqHBaw0j1jI7iFBTAr2I= +modernc.org/libc v1.67.4 h1:zZGmCMUVPORtKv95c2ReQN5VDjvkoRm9GWPTEPuvlWg= +modernc.org/libc v1.67.4/go.mod h1:QvvnnJ5P7aitu0ReNpVIEyesuhmDLQ8kaEoyMjIFZJA= modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= @@ -792,11 +921,13 @@ modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= -modernc.org/sqlite v1.40.1 h1:VfuXcxcUWWKRBuP8+BR9L7VnmusMgBNNnBYGEe9w/iY= -modernc.org/sqlite v1.40.1/go.mod h1:9fjQZ0mB1LLP0GYrp39oOJXx/I2sxEnZtzCmEQIKvGE= +modernc.org/sqlite v1.42.2 h1:7hkZUNJvJFN2PgfUdjni9Kbvd4ef4mNLOu0B9FGxM74= +modernc.org/sqlite v1.42.2/go.mod h1:+VkC6v3pLOAE0A0uVucQEcbVW0I5nHCeDaBf+DpsQT8= modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= pluginrpc.com/pluginrpc v0.5.0 h1:tOQj2D35hOmvHyPu8e7ohW2/QvAnEtKscy2IJYWQ2yo= pluginrpc.com/pluginrpc v0.5.0/go.mod h1:UNWZ941hcVAoOZUn8YZsMmOZBzbUjQa3XMns8RQLp9o= +rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY= +rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs= From 8fa7d91bd69980a0e76f8f154edecc516013ced9 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 6 Jan 2026 19:10:03 +0800 Subject: [PATCH 147/158] feat(auth): implement refresh token endpoint with new path and public policy, add refresh token to response and new error reasons --- api/v1/proto/auth/auth.proto | 5 ++- api/v1/proto/types/auth_error.proto | 2 + api/v1/services/auth/auth.pb.go | 5 +-- api/v1/services/auth/auth.pb.gw.go | 6 +-- api/v1/services/auth/auth.pb.security.go | 6 +-- api/v1/services/auth/auth_bridge.pb.go | 2 +- api/v1/services/auth/auth_http.pb.go | 4 +- internal/features/auth/service/auth.go | 28 +++++++++++- internal/helpers/captcha/cache.go | 17 ++++++-- internal/helpers/contextutil/context.go | 46 ++++++++++++++++++++ internal/helpers/providers/providers.go | 4 +- internal/helpers/providers/providers_test.go | 40 +++++++++++++++++ resources/api-docs/openapi/openapi.yaml | 20 ++++----- 13 files changed, 155 insertions(+), 30 deletions(-) create mode 100644 internal/helpers/contextutil/context.go create mode 100644 internal/helpers/providers/providers_test.go diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index 0a8edafc..ff6b5eff 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -44,10 +44,10 @@ service AuthService { // RefreshToken provides a new access token. rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse) { option (google.api.http) = { - post: "/auth/token" + post: "/auth/refresh" body: "*" }; - option (contrib.api.policy.v1.policy) = {name: "jwt-auth"}; + option (contrib.api.policy.v1.policy) = {name: "public"}; } // --- Captcha --- @@ -113,6 +113,7 @@ message RefreshTokenResponse { string access_token = 1 [json_name = "access_token"]; string token_type = 2 [json_name = "token_type"]; int64 expires_in = 3 [json_name = "expires_in"]; + string refresh_token = 4 [json_name = "refresh_token"]; } // The request message for the GetCaptcha RPC. diff --git a/api/v1/proto/types/auth_error.proto b/api/v1/proto/types/auth_error.proto index 1845b3b1..d9a3db37 100644 --- a/api/v1/proto/types/auth_error.proto +++ b/api/v1/proto/types/auth_error.proto @@ -15,4 +15,6 @@ enum AuthErrorReason { AUTH_ERROR_REASON_UNSPECIFIED = 0; AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND = 2001 [(errors.code) = 404]; AUTH_ERROR_REASON_TOKEN_EXPIRED = 2002 [(errors.code) = 401]; + AUTH_ERROR_REASON_TOKEN_INVALID = 2003 [(errors.code) = 401]; + AUTH_ERROR_REASON_TOKEN_MISSING = 2004 [(errors.code) = 401]; } diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index e06f2d1e..4339f6ea 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -767,9 +767,8 @@ const file_auth_auth_proto_rawDesc = "" + "\x06Logout\x12#.api.v1.services.auth.LogoutRequest\x1a$.api.v1.services.auth.LogoutResponse\"%\xea\xea\x1b\n" + "\n" + "\bjwt-auth\x82\xd3\xe4\x93\x02\x11:\x01*\"\f/auth/logout\x12\x8b\x01\n" + - "\fRefreshToken\x12).api.v1.services.auth.RefreshTokenRequest\x1a*.api.v1.services.auth.RefreshTokenResponse\"$\xea\xea\x1b\n" + - "\n" + - "\bjwt-auth\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/auth/token\x12\x82\x01\n" + + "\fRefreshToken\x12).api.v1.services.auth.RefreshTokenRequest\x1a*.api.v1.services.auth.RefreshTokenResponse\"$\xea\xea\x1b\b\n" + + "\x06public\x82\xd3\xe4\x93\x02\x12:\x01*\"\r/auth/refresh\x12\x82\x01\n" + "\n" + "GetCaptcha\x12'.api.v1.services.auth.GetCaptchaRequest\x1a(.api.v1.services.auth.GetCaptchaResponse\"!\xea\xea\x1b\b\n" + "\x06public\x82\xd3\xe4\x93\x02\x0f\x12\r/auth/captcha\x12e\n" + diff --git a/api/v1/services/auth/auth.pb.gw.go b/api/v1/services/auth/auth.pb.gw.go index b73fad6f..153e6019 100644 --- a/api/v1/services/auth/auth.pb.gw.go +++ b/api/v1/services/auth/auth.pb.gw.go @@ -236,7 +236,7 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/auth/token")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/api.v1.services.auth.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/auth/refresh")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -365,7 +365,7 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/auth/token")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/api.v1.services.auth.AuthService/RefreshToken", runtime.WithHTTPPathPattern("/auth/refresh")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return @@ -402,7 +402,7 @@ var ( pattern_AuthService_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "login"}, "")) pattern_AuthService_Register_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "register"}, "")) pattern_AuthService_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "logout"}, "")) - pattern_AuthService_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "token"}, "")) + pattern_AuthService_RefreshToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "refresh"}, "")) pattern_AuthService_GetCaptcha_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"auth", "captcha"}, "")) ) diff --git a/api/v1/services/auth/auth.pb.security.go b/api/v1/services/auth/auth.pb.security.go index 6dd2d4ea..abc38ef3 100644 --- a/api/v1/services/auth/auth.pb.security.go +++ b/api/v1/services/auth/auth.pb.security.go @@ -29,9 +29,9 @@ func init() { }, { ServiceMethod: "/api.v1.services.auth.AuthService/RefreshToken", - GatewayPath: "POST:/auth/token", - Name: "jwt-auth", - VersionID: "440ef699b2899614bcdd7cee97480b260e7cf04f1ae1ad681fc491e9453d6218", + GatewayPath: "POST:/auth/refresh", + Name: "public", + VersionID: "570c41f64c1e11446c73d2bc95b714c2cb88807d7210e3829149fb0f5d57b853", }, { ServiceMethod: "/api.v1.services.auth.AuthService/GetCaptcha", diff --git a/api/v1/services/auth/auth_bridge.pb.go b/api/v1/services/auth/auth_bridge.pb.go index 8775c522..35738e10 100644 --- a/api/v1/services/auth/auth_bridge.pb.go +++ b/api/v1/services/auth/auth_bridge.pb.go @@ -94,7 +94,7 @@ func RegisterAuthServiceBridgeServer(s *http.Server, srv AuthServiceHookedBridge r.POST("/auth/login", _AuthService_Login0_Bridge_Handler(srv)) r.POST("/auth/register", _AuthService_Register0_Bridge_Handler(srv)) r.POST("/auth/logout", _AuthService_Logout0_Bridge_Handler(srv)) - r.POST("/auth/token", _AuthService_RefreshToken0_Bridge_Handler(srv)) + r.POST("/auth/refresh", _AuthService_RefreshToken0_Bridge_Handler(srv)) r.GET("/auth/captcha", _AuthService_GetCaptcha0_Bridge_Handler(srv)) } diff --git a/api/v1/services/auth/auth_http.pb.go b/api/v1/services/auth/auth_http.pb.go index 99a63cd5..0af871df 100644 --- a/api/v1/services/auth/auth_http.pb.go +++ b/api/v1/services/auth/auth_http.pb.go @@ -43,7 +43,7 @@ func RegisterAuthServiceHTTPServer(s *http.Server, srv AuthServiceHTTPServer) { r.POST("/auth/login", _AuthService_Login0_HTTP_Handler(srv)) r.POST("/auth/register", _AuthService_Register0_HTTP_Handler(srv)) r.POST("/auth/logout", _AuthService_Logout0_HTTP_Handler(srv)) - r.POST("/auth/token", _AuthService_RefreshToken0_HTTP_Handler(srv)) + r.POST("/auth/refresh", _AuthService_RefreshToken0_HTTP_Handler(srv)) r.GET("/auth/captcha", _AuthService_GetCaptcha0_HTTP_Handler(srv)) } @@ -220,7 +220,7 @@ func (c *AuthServiceHTTPClientImpl) Logout(ctx context.Context, in *LogoutReques // RefreshToken RefreshToken provides a new access token. func (c *AuthServiceHTTPClientImpl) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...http.CallOption) (*RefreshTokenResponse, error) { var out RefreshTokenResponse - pattern := "/auth/token" + pattern := "/auth/refresh" path := binding.EncodeURL(pattern, in, false) opts = append(opts, http.Operation(OperationAuthServiceRefreshToken)) opts = append(opts, http.PathTemplate(pattern)) diff --git a/internal/features/auth/service/auth.go b/internal/features/auth/service/auth.go index 6160ab56..47be658d 100644 --- a/internal/features/auth/service/auth.go +++ b/internal/features/auth/service/auth.go @@ -12,6 +12,7 @@ import ( "github.com/origadmin/contrib/security/credential" securityPrincipal "github.com/origadmin/contrib/security/principal" v1 "origadmin/application/admin/api/v1/services/auth" + "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/features/auth/biz" "origadmin/application/admin/internal/helpers/captcha" ) @@ -116,7 +117,32 @@ func (s *AuthService) Logout(ctx context.Context, req *v1.LogoutRequest) (*v1.Lo // RefreshToken provides a new access token. func (s *AuthService) RefreshToken(ctx context.Context, req *v1.RefreshTokenRequest) (*v1.RefreshTokenResponse, error) { - return &v1.RefreshTokenResponse{}, nil + refreshToken := req.GetRefreshToken() + if refreshToken == "" { + return nil, types.ErrorAuthErrorReasonTokenMissing("refresh token is missing") + } + + refresher, ok := s.creator.(credential.Refresher) + if !ok { + return nil, types.ErrorAuthErrorReasonUnspecified("credential creator does not support refresh") + } + + credResp, err := refresher.RefreshCredential(ctx, refreshToken) + if err != nil { + return nil, err + } + + token := credResp.Response().GetPayload().GetToken() + if token == nil { + return nil, types.ErrorAuthErrorReasonTokenInvalid("token is missing in response") + } + + return &v1.RefreshTokenResponse{ + AccessToken: token.GetAccessToken(), + TokenType: token.GetTokenType(), + ExpiresIn: token.GetExpiresIn(), + RefreshToken: token.GetRefreshToken(), + }, nil } // Authenticate is for internal use by the gateway to verify user access via gRPC. diff --git a/internal/helpers/captcha/cache.go b/internal/helpers/captcha/cache.go index c2d08c95..409e438c 100644 --- a/internal/helpers/captcha/cache.go +++ b/internal/helpers/captcha/cache.go @@ -6,9 +6,10 @@ import ( "time" "github.com/mojocn/base64Captcha" - "github.com/origadmin/runtime/log" storageiface "github.com/origadmin/runtime/interfaces/storage" + "github.com/origadmin/runtime/log" + "origadmin/application/admin/internal/helpers/contextutil" ) const ( @@ -32,6 +33,15 @@ func NewStore(cache storageiface.Cache) base64Captcha.Store { } } +// NewStoreWithContext creates a new captcha store backed by the provided storage.Cache. +// It holds a provided context for cache operations. +func NewStoreWithContext(ctx context.Context, cache storageiface.Cache) base64Captcha.Store { + return &store{ + ctx: ctx, + cache: cache, + } +} + // Set stores the captcha value with a default expiration. func (s *store) Set(id string, value string) error { key := captchaPrefix + id @@ -42,15 +52,16 @@ func (s *store) Set(id string, value string) error { // Get retrieves the captcha value. func (s *store) Get(id string, clear bool) string { key := captchaPrefix + id + helper := log.NewHelper(contextutil.GetLogger(s.ctx)) // The cache's Get method returns a string value. val, err := s.cache.Get(s.ctx, key) if err != nil { - log.Errorf("failed to get captcha from cache: %v", err) + helper.Errorf("failed to get captcha from cache: %v", err) return "" } if clear { if err := s.cache.Delete(s.ctx, key); err != nil { - log.Errorf("failed to delete captcha from cache: %v", err) + helper.Errorf("failed to delete captcha from cache: %v", err) } } return val diff --git a/internal/helpers/contextutil/context.go b/internal/helpers/contextutil/context.go new file mode 100644 index 00000000..6390ab48 --- /dev/null +++ b/internal/helpers/contextutil/context.go @@ -0,0 +1,46 @@ +// Package contextutil provides utility functions for working with context. +package contextutil + +import ( + "context" + "errors" + "fmt" + "strconv" + + "github.com/origadmin/contrib/security/principal" + "github.com/origadmin/runtime/log" +) + +// ErrNoPrincipalInContext is returned when no principal is found in the context. +var ErrNoPrincipalInContext = errors.New("contextutil: no principal found in context") + +// GetUserID extracts the user ID from the context. +// It encapsulates the logic of retrieving user information, which is expected +// to be stored as a principal.Principal. This decouples consumers from the +// specific implementation of the principal package. +func GetUserID(ctx context.Context) (int64, error) { + p, ok := principal.FromContext(ctx) + if !ok { + return 0, ErrNoPrincipalInContext + } + + userID, err := strconv.ParseInt(p.GetID(), 10, 64) + if err != nil { + return 0, fmt.Errorf("contextutil: failed to parse principal ID '%s': %w", p.GetID(), err) + } + return userID, nil +} + +type logKey struct{} + +func GetLogger(ctx context.Context) log.Logger { + logger, ok := ctx.Value(logKey{}).(log.Logger) + if !ok { + return log.DefaultLogger + } + return logger +} + +func SetLogger(ctx context.Context, logger log.Logger) context.Context { + return context.WithValue(ctx, logKey{}, logger) +} diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go index 6ad19f0b..6eb87497 100644 --- a/internal/helpers/providers/providers.go +++ b/internal/helpers/providers/providers.go @@ -215,7 +215,7 @@ func ProvideClientMiddlewares(app *runtime.App) (container.ClientMiddlewareProvi return provider, nil } -func ProvideGatewaySkipChecker(app *runtime.App, cfg *conf.Config) security.SkipChecker { +func ProvideGatewaySkipChecker(app *runtime.App, _ *conf.Config) security.SkipChecker { return func(ctx context.Context, req security.Request) bool { helper := log.NewHelper(log.With(app.Logger(), "kind", req.Kind(), "operation", req.GetOperation(), "method", req.GetMethod(), "path", req.GetRouteTemplate())) @@ -229,7 +229,7 @@ func ProvideGatewaySkipChecker(app *runtime.App, cfg *conf.Config) security.Skip } } -func ProvideSkipChecker(app *runtime.App, cfg *conf.Config) security.SkipChecker { +func ProvideSkipChecker(app *runtime.App, _ *conf.Config) security.SkipChecker { //helper := log.NewHelper(log.With(app.Logger(), "module", "security.skip")) return func(ctx context.Context, req security.Request) bool { helper := log.NewHelper(log.With(app.Logger(), "kind", req.Kind(), "operation", req.GetOperation(), "method", req.GetMethod(), "path", diff --git a/internal/helpers/providers/providers_test.go b/internal/helpers/providers/providers_test.go new file mode 100644 index 00000000..71cf8aef --- /dev/null +++ b/internal/helpers/providers/providers_test.go @@ -0,0 +1,40 @@ +// Package providers implements the functions, types, and interfaces for the module. +package providers + +import ( + "testing" +) + +func TestProvideHasher(t *testing.T) { + tests := []struct { + name string + oldString string + password string + wantErr bool + }{ + { + name: "Testing ProvideHasher v1", + oldString: "$bcrypt$v1$c:10$243261243130244e44744e3144515a53446a63372e32626a752e354e75576c6a594a6c495544326f4346466e373763576a4d49325157446b372f4879$4a36457446474d376b35674d5a4c7376", + password: "admin123", + wantErr: false, + }, + { + name: "Testing ProvideHasher v2", + oldString: "$bcrypt$v1$c:100244e44744e3144515a53446a63372e32626a752e354e75576c6a594a6c495544326f4346466e373763576a4d49325157446b372f4879a36457446474d376b35674d5a4c7376", + password: "testpassword", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + hasher, err := ProvideHasher() + if err != nil { + t.Fatalf("ProvideHasher() error = %v", err) + return + } + err1 := hasher.Verify(tt.oldString, tt.password) + if (err1 != nil) != tt.wantErr { + t.Errorf("Hasher.Verify() error = %v, wantErr %v", err1, tt.wantErr) + } + }) + } +} diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 005973da..d51ec05f 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -97,17 +97,17 @@ paths: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /auth/register: + /auth/refresh: post: tags: - AuthService - description: Register creates a new user account. - operationId: AuthService_Register + description: RefreshToken provides a new access token. + operationId: AuthService_RefreshToken requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.RegisterRequest' + $ref: '#/components/schemas/api.v1.services.auth.RefreshTokenRequest' required: true responses: "200": @@ -115,24 +115,24 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse' + $ref: '#/components/schemas/api.v1.services.auth.RefreshTokenResponse' default: description: Default error response content: application/json: schema: $ref: '#/components/schemas/google.rpc.Status' - /auth/token: + /auth/register: post: tags: - AuthService - description: RefreshToken provides a new access token. - operationId: AuthService_RefreshToken + description: Register creates a new user account. + operationId: AuthService_Register requestBody: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.RefreshTokenRequest' + $ref: '#/components/schemas/api.v1.services.auth.RegisterRequest' required: true responses: "200": @@ -140,7 +140,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/api.v1.services.auth.RefreshTokenResponse' + $ref: '#/components/schemas/api.v1.services.auth.RegisterResponse' default: description: Default error response content: From 4b1804c3456f9b49ef4a749cf770465195c20f62 Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 6 Jan 2026 19:13:33 +0800 Subject: [PATCH 148/158] feat(auth): reorder token fields in RefreshTokenResponse and add new token error types --- api/v1/proto/auth/auth.proto | 6 ++--- api/v1/services/auth/auth.pb.go | 21 +++++++++++----- api/v1/services/auth/auth.pb.validate.go | 2 ++ api/v1/services/types/auth_error.pb.go | 12 ++++++++-- api/v1/services/types/auth_error_errors.pb.go | 24 +++++++++++++++++++ resources/api-docs/openapi/openapi.yaml | 2 ++ 6 files changed, 56 insertions(+), 11 deletions(-) diff --git a/api/v1/proto/auth/auth.proto b/api/v1/proto/auth/auth.proto index ff6b5eff..e70de23e 100644 --- a/api/v1/proto/auth/auth.proto +++ b/api/v1/proto/auth/auth.proto @@ -111,9 +111,9 @@ message RefreshTokenRequest { // The response message for the RefreshToken RPC. message RefreshTokenResponse { string access_token = 1 [json_name = "access_token"]; - string token_type = 2 [json_name = "token_type"]; - int64 expires_in = 3 [json_name = "expires_in"]; - string refresh_token = 4 [json_name = "refresh_token"]; + string refresh_token = 2 [json_name = "refresh_token"]; + string token_type = 3 [json_name = "token_type"]; + int64 expires_in = 4 [json_name = "expires_in"]; } // The request message for the GetCaptcha RPC. diff --git a/api/v1/services/auth/auth.pb.go b/api/v1/services/auth/auth.pb.go index 4339f6ea..1f7fe713 100644 --- a/api/v1/services/auth/auth.pb.go +++ b/api/v1/services/auth/auth.pb.go @@ -406,8 +406,9 @@ func (x *RefreshTokenRequest) GetRefreshToken() string { type RefreshTokenResponse struct { state protoimpl.MessageState `protogen:"open.v1"` AccessToken string `protobuf:"bytes,1,opt,name=access_token,proto3" json:"access_token,omitempty"` - TokenType string `protobuf:"bytes,2,opt,name=token_type,proto3" json:"token_type,omitempty"` - ExpiresIn int64 `protobuf:"varint,3,opt,name=expires_in,proto3" json:"expires_in,omitempty"` + RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,proto3" json:"refresh_token,omitempty"` + TokenType string `protobuf:"bytes,3,opt,name=token_type,proto3" json:"token_type,omitempty"` + ExpiresIn int64 `protobuf:"varint,4,opt,name=expires_in,proto3" json:"expires_in,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -449,6 +450,13 @@ func (x *RefreshTokenResponse) GetAccessToken() string { return "" } +func (x *RefreshTokenResponse) GetRefreshToken() string { + if x != nil { + return x.RefreshToken + } + return "" +} + func (x *RefreshTokenResponse) GetTokenType() string { if x != nil { return x.TokenType @@ -730,14 +738,15 @@ const file_auth_auth_proto_rawDesc = "" + "\rrefresh_token\x18\x01 \x01(\tR\rrefresh_token\"\x10\n" + "\x0eLogoutResponse\";\n" + "\x13RefreshTokenRequest\x12$\n" + - "\rrefresh_token\x18\x01 \x01(\tR\rrefresh_token\"z\n" + + "\rrefresh_token\x18\x01 \x01(\tR\rrefresh_token\"\xa0\x01\n" + "\x14RefreshTokenResponse\x12\"\n" + - "\faccess_token\x18\x01 \x01(\tR\faccess_token\x12\x1e\n" + + "\faccess_token\x18\x01 \x01(\tR\faccess_token\x12$\n" + + "\rrefresh_token\x18\x02 \x01(\tR\rrefresh_token\x12\x1e\n" + "\n" + - "token_type\x18\x02 \x01(\tR\n" + + "token_type\x18\x03 \x01(\tR\n" + "token_type\x12\x1e\n" + "\n" + - "expires_in\x18\x03 \x01(\x03R\n" + + "expires_in\x18\x04 \x01(\x03R\n" + "expires_in\"W\n" + "\x11GetCaptchaRequest\x12\x1e\n" + "\n" + diff --git a/api/v1/services/auth/auth.pb.validate.go b/api/v1/services/auth/auth.pb.validate.go index 2eebbc90..bfa426fe 100644 --- a/api/v1/services/auth/auth.pb.validate.go +++ b/api/v1/services/auth/auth.pb.validate.go @@ -790,6 +790,8 @@ func (m *RefreshTokenResponse) validate(all bool) error { // no validation rules for AccessToken + // no validation rules for RefreshToken + // no validation rules for TokenType // no validation rules for ExpiresIn diff --git a/api/v1/services/types/auth_error.pb.go b/api/v1/services/types/auth_error.pb.go index e05ea522..abc71bb1 100644 --- a/api/v1/services/types/auth_error.pb.go +++ b/api/v1/services/types/auth_error.pb.go @@ -28,6 +28,8 @@ const ( AuthErrorReason_AUTH_ERROR_REASON_UNSPECIFIED AuthErrorReason = 0 AuthErrorReason_AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND AuthErrorReason = 2001 AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED AuthErrorReason = 2002 + AuthErrorReason_AUTH_ERROR_REASON_TOKEN_INVALID AuthErrorReason = 2003 + AuthErrorReason_AUTH_ERROR_REASON_TOKEN_MISSING AuthErrorReason = 2004 ) // Enum value maps for AuthErrorReason. @@ -36,11 +38,15 @@ var ( 0: "AUTH_ERROR_REASON_UNSPECIFIED", 2001: "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND", 2002: "AUTH_ERROR_REASON_TOKEN_EXPIRED", + 2003: "AUTH_ERROR_REASON_TOKEN_INVALID", + 2004: "AUTH_ERROR_REASON_TOKEN_MISSING", } AuthErrorReason_value = map[string]int32{ "AUTH_ERROR_REASON_UNSPECIFIED": 0, "AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND": 2001, "AUTH_ERROR_REASON_TOKEN_EXPIRED": 2002, + "AUTH_ERROR_REASON_TOKEN_INVALID": 2003, + "AUTH_ERROR_REASON_TOKEN_MISSING": 2004, } ) @@ -75,11 +81,13 @@ var File_types_auth_error_proto protoreflect.FileDescriptor const file_types_auth_error_proto_rawDesc = "" + "\n" + - "\x16types/auth_error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*\x96\x01\n" + + "\x16types/auth_error.proto\x12\x15api.v1.services.types\x1a\x13errors/errors.proto*\xee\x01\n" + "\x0fAuthErrorReason\x12!\n" + "\x1dAUTH_ERROR_REASON_UNSPECIFIED\x10\x00\x12.\n" + "#AUTH_ERROR_REASON_CAPTCHA_NOT_FOUND\x10\xd1\x0f\x1a\x04\xa8E\x94\x03\x12*\n" + - "\x1fAUTH_ERROR_REASON_TOKEN_EXPIRED\x10\xd2\x0f\x1a\x04\xa8E\x91\x03\x1a\x04\xa0E\xf4\x03B\xdc\x01\n" + + "\x1fAUTH_ERROR_REASON_TOKEN_EXPIRED\x10\xd2\x0f\x1a\x04\xa8E\x91\x03\x12*\n" + + "\x1fAUTH_ERROR_REASON_TOKEN_INVALID\x10\xd3\x0f\x1a\x04\xa8E\x91\x03\x12*\n" + + "\x1fAUTH_ERROR_REASON_TOKEN_MISSING\x10\xd4\x0f\x1a\x04\xa8E\x91\x03\x1a\x04\xa0E\xf4\x03B\xdc\x01\n" + "\x19com.api.v1.services.typesB\x0eAuthErrorProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" var ( diff --git a/api/v1/services/types/auth_error_errors.pb.go b/api/v1/services/types/auth_error_errors.pb.go index b4915c00..ad7046fa 100644 --- a/api/v1/services/types/auth_error_errors.pb.go +++ b/api/v1/services/types/auth_error_errors.pb.go @@ -46,3 +46,27 @@ func IsAuthErrorReasonTokenExpired(err error) bool { func ErrorAuthErrorReasonTokenExpired(format string, args ...interface{}) *errors.Error { return errors.New(401, AuthErrorReason_AUTH_ERROR_REASON_TOKEN_EXPIRED.String(), fmt.Sprintf(format, args...)) } + +func IsAuthErrorReasonTokenInvalid(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_TOKEN_INVALID.String() && e.Code == 401 +} + +func ErrorAuthErrorReasonTokenInvalid(format string, args ...interface{}) *errors.Error { + return errors.New(401, AuthErrorReason_AUTH_ERROR_REASON_TOKEN_INVALID.String(), fmt.Sprintf(format, args...)) +} + +func IsAuthErrorReasonTokenMissing(err error) bool { + if err == nil { + return false + } + e := errors.FromError(err) + return e.Reason == AuthErrorReason_AUTH_ERROR_REASON_TOKEN_MISSING.String() && e.Code == 401 +} + +func ErrorAuthErrorReasonTokenMissing(format string, args ...interface{}) *errors.Error { + return errors.New(401, AuthErrorReason_AUTH_ERROR_REASON_TOKEN_MISSING.String(), fmt.Sprintf(format, args...)) +} diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index d51ec05f..513bedcb 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -2250,6 +2250,8 @@ components: properties: access_token: type: string + refresh_token: + type: string token_type: type: string expires_in: From 670ddda3b2f94aee160f19878ec9ee4adc37de4f Mon Sep 17 00:00:00 2001 From: godcong Date: Tue, 6 Jan 2026 21:40:38 +0800 Subject: [PATCH 149/158] feat(auth): include user roles in principal and token generation --- internal/features/auth/dal/auth.go | 2 +- internal/features/auth/service/auth.go | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/features/auth/dal/auth.go b/internal/features/auth/dal/auth.go index 88563d61..9df09875 100644 --- a/internal/features/auth/dal/auth.go +++ b/internal/features/auth/dal/auth.go @@ -26,7 +26,7 @@ func NewAuthRepo(db *ent.Database, logger log.Logger) dto.AuthRepo { // GetUserByUsername retrieves a user's auth-specific data by their username. func (r *AuthRepo) GetUserByUsername(ctx context.Context, username string) (*dto.AuthedUser, error) { - u, err := r.db.User(ctx).Query().Where(user.UsernameEQ(username)).Only(ctx) + u, err := r.db.User(ctx).Query().Where(user.UsernameEQ(username)).WithRoles().Only(ctx) if err != nil { return nil, err } diff --git a/internal/features/auth/service/auth.go b/internal/features/auth/service/auth.go index 47be658d..406233bb 100644 --- a/internal/features/auth/service/auth.go +++ b/internal/features/auth/service/auth.go @@ -53,8 +53,15 @@ func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.Logi s.log.Errorf("failed to update login info for user %d: %v", user.Id, err) } - // Create a principal for the user. - p := securityPrincipal.New(fmt.Sprint(user.Id)) + // Create a principal for the user, including their roles. + var roleKeywords []string + for _, role := range user.GetRoles() { + roleKeywords = append(roleKeywords, role.Keyword) + } + p := securityPrincipal.New( + fmt.Sprint(user.Id), + securityPrincipal.WithRoles(roleKeywords), + ) // Create a credential (which contains the token). credResp, err := s.creator.CreateCredential(ctx, p) @@ -62,7 +69,7 @@ func (s *AuthService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.Logi return nil, err } - token := credResp.Response().GetPayload().GetToken() + token := credResp.Payload().GetToken() if token == nil { return nil, securityv1.ErrorTokenInvalid("token is missing") } From 0e690d726d584e42c920d6e6ba2044b2343502c2 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 7 Jan 2026 00:47:24 +0800 Subject: [PATCH 150/158] feat(proto): refactor system proto definitions and remove redundant edges messages --- api/v1/proto/types/system.proto | 318 +- api/v1/services/types/system.pb.go | 1791 ++------ api/v1/services/types/system.pb.validate.go | 3606 ++--------------- cmd/seed/wire_gen.go | 6 +- go.mod | 17 +- go.sum | 82 +- internal/data/entity/ent/generate.go | 2 +- internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 47 +- internal/data/entity/ent/mutation.go | 156 +- internal/data/entity/ent/mutation_fields.go | 17 +- internal/data/entity/ent/permission.go | 13 +- .../data/entity/ent/permission/permission.go | 29 +- internal/data/entity/ent/permission/where.go | 57 +- internal/data/entity/ent/permission_create.go | 12 +- internal/data/entity/ent/permission_query.go | 2 +- internal/data/entity/ent/permission_update.go | 43 +- internal/data/entity/ent/resource.go | 31 +- internal/data/entity/ent/resource/resource.go | 30 +- internal/data/entity/ent/resource/where.go | 57 +- internal/data/entity/ent/resource_create.go | 12 +- internal/data/entity/ent/resource_query.go | 2 +- internal/data/entity/ent/resource_update.go | 43 +- internal/data/entity/ent/runtime/runtime.go | 36 +- internal/data/entity/ent/schema/permission.go | 15 +- internal/data/entity/ent/schema/resource.go | 29 +- internal/data/entity/ent/schema/user.go | 3 + internal/data/entity/ent/schema/view.go | 22 +- internal/data/entity/ent/user.go | 13 +- internal/data/entity/ent/user/user.go | 12 + internal/data/entity/ent/user/where.go | 70 + internal/data/entity/ent/user_create.go | 30 + internal/data/entity/ent/user_query.go | 2 + internal/data/entity/ent/user_update.go | 44 + internal/data/entity/ent/view.go | 22 +- internal/features/auth/dto/dto.gen.go | 765 +--- internal/features/auth/dto/dto.go | 23 - internal/features/system/dal/resource.go | 4 + internal/features/system/dto/dto.gen.go | 781 +--- internal/features/system/dto/dto.go | 23 - internal/helpers/providers/providers.go | 2 +- internal/tasks/seeder/seeder.go | 121 +- resources/api-docs/openapi/openapi.yaml | 79 +- 43 files changed, 1960 insertions(+), 6511 deletions(-) diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index 59da2f9b..0538d79e 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -32,46 +32,34 @@ message View { int32 sequence = 9 [json_name = "sequence"]; // Type holds the value of the "type" field. string type = 10 [json_name = "type"]; + // Component holds the value of the "component" field. + string component = 11 [json_name = "component"]; // Comment holds the value of the "comment" field. - string comment = 11 [json_name = "comment"]; + string comment = 12 [json_name = "comment"]; // Icon holds the value of the "icon" field. - string icon = 12 [json_name = "icon"]; + string icon = 13 [json_name = "icon"]; // Visible holds the value of the "visible" field. - bool visible = 13 [json_name = "visible"]; + bool visible = 14 [json_name = "visible"]; // Path holds the value of the "path" field. - string path = 14 [json_name = "path"]; + string path = 15 [json_name = "path"]; // TreePath holds the value of the "tree_path" field. - string tree_path = 15 [json_name = "tree_path"]; + string tree_path = 16 [json_name = "tree_path"]; // Properties holds the value of the "properties" field. - string properties = 16 [json_name = "properties"]; + string properties = 17 [json_name = "properties"]; // Status holds the value of the "status" field. - int32 status = 17 [json_name = "status"]; + int32 status = 18 [json_name = "status"]; // ParentID holds the value of the "parent_id" field. - int64 parent_id = 18 [json_name = "parent_id"]; + int64 parent_id = 19 [json_name = "parent_id"]; // ParentPath holds the value of the "parent_path" field. - string parent_path = 19 [json_name = "parent_path"]; + string parent_path = 20 [json_name = "parent_path"]; // Children holds the value of the children edge. - repeated View children = 20 [json_name = "children"]; + repeated View children = 21 [json_name = "children"]; // Parent holds the value of the parent edge. - View parent = 21 [json_name = "parent"]; + View parent = 22 [json_name = "parent"]; // Resources holds the value of the resources edge. - repeated Resource resources = 22 [json_name = "resources"]; - // Roles holds the value of the roles edge. - repeated Role roles = 23 [json_name = "roles"]; -} - -// ViewEdges holds the relations/edges for other nodes in the graph. -message ViewEdges { - // Children holds the value of the children edge. - repeated View children = 1 [json_name = "children"]; - // Parent holds the value of the parent edge. - View parent = 2 [json_name = "parent"]; - // Resources holds the value of the resources edge. - repeated Resource resources = 3 [json_name = "resources"]; + repeated Resource resources = 23 [json_name = "resources"]; // Roles holds the value of the roles edge. - repeated Role roles = 4 [json_name = "roles"]; - // RoleView holds the value of the role_view edge. - repeated RoleView role_views = 5 [json_name = "role_views"]; + repeated Role roles = 24 [json_name = "roles"]; } // Role is the model entity for the Role schema. @@ -83,44 +71,40 @@ message Role { google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; + // create_author.field.comment + int64 create_author = 4 [json_name = "create_author"]; + // update_author.field.comment + int64 update_author = 5 [json_name = "update_author"]; // role.field.keyword - string keyword = 4 [json_name = "keyword"]; + string keyword = 6 [json_name = "keyword"]; // role.field.name - string name = 5 [json_name = "name"]; + string name = 7 [json_name = "name"]; // role.field.description - string description = 6 [json_name = "description"]; + string description = 8 [json_name = "description"]; // role.field.type - int32 type = 7 [json_name = "type"]; + int32 type = 9 [json_name = "type"]; // role.field.sequence - int32 sequence = 8 [json_name = "sequence"]; + int32 sequence = 10 [json_name = "sequence"]; // role.field.status - int32 status = 9 [json_name = "status"]; + int32 status = 11 [json_name = "status"]; // role.field.is_types - bool is_types = 10 [json_name = "is_types"]; + bool is_types = 12 [json_name = "is_types"]; // Views holds the value of the views edge. repeated View views = 21 [json_name = "views"]; + // View Ids holds the value of the view_ids edge. + repeated int64 view_ids = 20 [json_name = "view_ids"]; // Users holds the value of the users edge. repeated User users = 22 [json_name = "users"]; + // Users Ids holds the value of the user_ids edge. + repeated int64 user_ids = 23 [json_name = "user_ids"]; // Resources holds the value of the resources edge. - repeated Resource resources = 23 [json_name = "resources"]; + repeated Resource resources = 24 [json_name = "resources"]; // Resource Ids holds the value of the resource_ids edge. - repeated int64 resource_ids = 24 [json_name = "resource_ids"]; + repeated int64 resource_ids = 25 [json_name = "resource_ids"]; // Permissions holds the value of the permissions edge. - repeated Permission permissions = 25 [json_name = "permissions"]; + repeated Permission permissions = 26 [json_name = "permissions"]; // Permission Ids holds the value of the permission_ids edge. - repeated int64 permission_ids = 26 [json_name = "permission_ids"]; -} - -// RoleEdges holds the relations/edges for other nodes in the graph. -message RoleEdges { - // Views holds the value of the views edge. - repeated View views = 1 [json_name = "views"]; - // Users holds the value of the users edge. - repeated User users = 2 [json_name = "users"]; - // RoleView holds the value of the role_view edge. - repeated RoleView role_views = 3 [json_name = "role_views"]; - // UserRole holds the value of the user_role edge. - repeated UserRole user_roles = 4 [json_name = "user_roles"]; + repeated int64 permission_ids = 27 [json_name = "permission_ids"]; } // User is the model entity for the User schema. @@ -128,14 +112,14 @@ message User { // ID of the ent. // field.primary_key.comment int64 id = 1 [json_name = "id"]; - // create_author.field.comment - int64 create_author = 2 [json_name = "create_author"]; - // update_author.field.comment - int64 update_author = 3 [json_name = "update_author"]; // create_time.field.comment - google.protobuf.Timestamp create_time = 4 [json_name = "create_time"]; + google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment - google.protobuf.Timestamp update_time = 5 [json_name = "update_time"]; + google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; + // create_author.field.comment + int64 create_author = 4 [json_name = "create_author"]; + // update_author.field.comment + int64 update_author = 5 [json_name = "update_author"]; // user.field.uuid string uuid = 6 [json_name = "uuid"]; // user.field.allowed_ip @@ -160,32 +144,22 @@ message User { string token = 16 [json_name = "token"]; // user.field.status int32 status = 17 [json_name = "status"]; + // user.field.i18n + string i18n = 18 [json_name = "i18n"]; // user.field.last_login_ip - string last_login_ip = 18 [json_name = "last_login_ip"]; + string last_login_ip = 19 [json_name = "last_login_ip"]; // user.field.login_ip - string login_ip = 19 [json_name = "login_ip"]; + string login_ip = 20 [json_name = "login_ip"]; // user.field.last_login_time - google.protobuf.Timestamp last_login_time = 20 [json_name = "last_login_time"]; + google.protobuf.Timestamp last_login_time = 21 [json_name = "last_login_time"]; // user.field.login_time - google.protobuf.Timestamp login_time = 21 [json_name = "login_time"]; + google.protobuf.Timestamp login_time = 22 [json_name = "login_time"]; // user.field.sanction_date - optional google.protobuf.Timestamp sanction_date = 22 [json_name = "sanction_date"]; - // // user.field.manager_id - // int64 manager_id = 21 [json_name = "manager_id"]; - // // user.field.manager - // string manager = 22 [json_name = "manager"]; + optional google.protobuf.Timestamp sanction_date = 23 [json_name = "sanction_date"]; // Roles holds the value of the roles edge. - repeated Role roles = 23 [json_name = "roles"]; + repeated Role roles = 24 [json_name = "roles"]; // Role Ids holds the value of the role_ids - repeated int64 role_ids = 24 [json_name = "role_ids"]; -} - -// UserEdges holds the relations/edges for other nodes in the graph. -message UserEdges { - // Roles holds the value of the roles edge. - repeated Role roles = 1 [json_name = "roles"]; - // UserRole holds the value of the user_role edge. - repeated UserRole user_roles = 2 [json_name = "user_roles"]; + repeated int64 role_ids = 25 [json_name = "role_ids"]; } // UserRole is the model entity for the UserRole schema. @@ -208,14 +182,6 @@ message UserRole { Role role = 22 [json_name = "role"]; } -// UserRoleEdges holds the relations/edges for other nodes in the graph. -message UserRoleEdges { - // User holds the value of the user edge. - User user = 1 [json_name = "user"]; - // Role holds the value of the role edge. - Role role = 2 [json_name = "role"]; -} - // RoleView is the model entity for the RoleView schema. message RoleView { // ID of the ent. @@ -234,14 +200,6 @@ message RoleView { View view = 22 [json_name = "view"]; } -// RoleViewEdges holds the relations/edges for other nodes in the graph. -message RoleViewEdges { - // Role holds the value of the role edge. - Role role = 1 [json_name = "role"]; - // View holds the value of the view edge. - View view = 2 [json_name = "view"]; -} - // Resource is the model entity for the Resource schema. message Resource { // ID of the ent. @@ -251,30 +209,26 @@ message Resource { google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; + // create_author.field.comment + int64 create_author = 4 [json_name = "create_author"]; + // update_author.field.comment + int64 update_author = 5 [json_name = "update_author"]; // resource.field.name - string name = 4 [json_name = "name"]; + string name = 6 [json_name = "name"]; // resource.field.keyword - string keyword = 5 [json_name = "keyword"]; - // resource.field.i18n_key - string i18n_key = 6 [json_name = "i18n_key"]; + string keyword = 7 [json_name = "keyword"]; // resource.field.type - string type = 7 [json_name = "type"]; + string type = 9 [json_name = "type"]; // resource.field.status - int32 status = 8 [json_name = "status"]; + int32 status = 10 [json_name = "status"]; // resource.field.path - string path = 9 [json_name = "path"]; + string path = 11 [json_name = "path"]; // resource.field.operation - string operation = 10 [json_name = "operation"]; + string operation = 12 [json_name = "operation"]; // resource.field.method - string method = 11 [json_name = "method"]; - // resource.field.component - string component = 12 [json_name = "component"]; - // resource.field.icon - string icon = 13 [json_name = "icon"]; + string method = 13 [json_name = "method"]; // resource.field.sequence int32 sequence = 14 [json_name = "sequence"]; - // resource.field.visible - bool visible = 15 [json_name = "visible"]; // resource.field.tree_path string tree_path = 16 [json_name = "tree_path"]; // resource.field.properties @@ -291,12 +245,8 @@ message Resource { repeated int64 permission_ids = 23 [json_name = "permission_ids"]; // Permissions holds the value of the permissions edge. repeated Permission permissions = 24 [json_name = "permissions"]; -} -// ResourceEdges holds the relations/edges for other nodes in the graph. -message ResourceEdges { - // View holds the value of the view edge. - View view = 1 [json_name = "view"]; + string service_name = 25 [json_name = "service_name"]; } // department.table.comment @@ -308,39 +258,30 @@ message Department { google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; + // create_author.field.comment + int64 create_author = 4 [json_name = "create_author"]; + // update_author.field.comment + int64 update_author = 5 [json_name = "update_author"]; // department.field.keyword - string keyword = 4 [json_name = "keyword"]; + string keyword = 6 [json_name = "keyword"]; // department.field.name - string name = 5 [json_name = "name"]; + string name = 7 [json_name = "name"]; // department.field.tree_path - string tree_path = 6 [json_name = "tree_path"]; + string tree_path = 8 [json_name = "tree_path"]; // department.field.sequence - int32 sequence = 7 [json_name = "sequence"]; + int32 sequence = 9 [json_name = "sequence"]; // department.field.status - int32 status = 8 [json_name = "status"]; + int32 status = 10 [json_name = "status"]; // department.field.level - int32 level = 9 [json_name = "level"]; + int32 level = 11 [json_name = "level"]; // department.field.description - string description = 10 [json_name = "description"]; + string description = 12 [json_name = "description"]; // department.field.parent_id - int64 parent_id = 11 [json_name = "parent_id"]; + int64 parent_id = 13 [json_name = "parent_id"]; // Children holds the value of the children edge. - repeated Department children = 12 [json_name = "children"]; + repeated Department children = 14 [json_name = "children"]; // Parent holds the value of the parent edge. - Department parent = 13 [json_name = "parent"]; -} - -message DepartmentEdges { - // Users holds the value of the users edge. - repeated User users = 1 [json_name = "users"]; - // Positions holds the value of the positions edge. - repeated Position positions = 2 [json_name = "positions"]; - // Children holds the value of the children edge. - repeated Department children = 3 [json_name = "children"]; - // Parent holds the value of the parent edge. - Department parent = 4 [json_name = "parent"]; - // UserDepartments holds the value of the user_departments edge. - repeated UserDepartment user_departments = 5 [json_name = "user_departments"]; + Department parent = 15 [json_name = "parent"]; } // user_department.table.comment @@ -352,17 +293,6 @@ message UserDepartment { int64 user_id = 2 [json_name = "user_id"]; // field.foreign_key.comment int64 department_id = 3 [json_name = "department_id"]; - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the UserDepartmentQuery when eager-loading is set. - UserDepartmentEdges edges = 4 [json_name = "edges"]; -} - -// UserDepartmentEdges holds the relations/edges for other nodes in the graph. -message UserDepartmentEdges { - // User holds the value of the user edge. - User user = 1 [json_name = "user"]; - // Department holds the value of the department edge. - Department department = 2 [json_name = "department"]; } // position.table.comment @@ -374,28 +304,18 @@ message Position { google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; + // create_author.field.comment + int64 create_author = 4 [json_name = "create_author"]; + // update_author.field.comment + int64 update_author = 5 [json_name = "update_author"]; // position.field.name - string name = 4 [json_name = "name"]; + string name = 6 [json_name = "name"]; // position.field.keyword - string keyword = 5 [json_name = "keyword"]; + string keyword = 7 [json_name = "keyword"]; // position.field.description - string description = 6 [json_name = "description"]; + string description = 8 [json_name = "description"]; // department.field.department_id - int64 department_id = 7 [json_name = "department_id"]; -} - -// PositionEdges holds the relations/edges for other nodes in the graph. -message PositionEdges { - // Department holds the value of the department edge. - Department department = 1 [json_name = "department"]; - // Users holds the value of the users edge. - repeated User users = 2 [json_name = "users"]; - // Permissions holds the value of the permissions edge. - repeated Permission permissions = 3 [json_name = "permissions"]; - // UserPositions holds the value of the user_positions edge. - repeated UserPosition user_positions = 4 [json_name = "user_positions"]; - // PositionPermissions holds the value of the position_permissions edge. - repeated PositionPermission position_permissions = 5 [json_name = "position_permissions"]; + int64 department_id = 9 [json_name = "department_id"]; } // permission.table.comment @@ -407,42 +327,30 @@ message Permission { google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; + // create_author.field.comment + int64 create_author = 4 [json_name = "create_author"]; + // update_author.field.comment + int64 update_author = 5 [json_name = "update_author"]; // permission.field.name - string name = 4 [json_name = "name"]; + string name = 6 [json_name = "name"]; // permission.field.keyword - string keyword = 5 [json_name = "keyword"]; + string keyword = 7 [json_name = "keyword"]; // permission.field.status - int32 status = 6 [json_name = "status"]; + int32 status = 8 [json_name = "status"]; // permission.field.description - string description = 7 [json_name = "description"]; + string description = 9 [json_name = "description"]; // permission.field.data_scope - string data_scope = 8 [json_name = "data_scope"]; + string data_scope = 10 [json_name = "data_scope"]; // permission.field.data_rules - map data_rules = 9 [json_name = "data_rules"]; + map data_rules = 11 [json_name = "data_rules"]; // permission.field.resource_ids - repeated int64 resource_ids = 10 [json_name = "resource_ids"]; + repeated int64 resource_ids = 12 [json_name = "resource_ids"]; // permission.field.resources - repeated Resource resources = 11 [json_name = "resources"]; + repeated Resource resources = 13 [json_name = "resources"]; // permission.field.view_ids - repeated int64 view_ids = 12 [json_name = "view_ids"]; + repeated int64 view_ids = 14 [json_name = "view_ids"]; // permission.field.views - repeated View views = 13 [json_name = "views"]; -} - -// PermissionEdges holds the relations/edges for other nodes in the graph. -message PermissionEdges { - // Roles holds the value of the roles edge. - repeated Role roles = 1 [json_name = "roles"]; - // Resources holds the value of the resources edge. - repeated Resource resources = 2 [json_name = "resources"]; - // Positions holds the value of the positions edge. - repeated Position positions = 3 [json_name = "positions"]; - // RolePermissions holds the value of the role_permissions edge. - repeated RolePermission role_permissions = 4 [json_name = "role_permissions"]; - // PermissionResources holds the value of the permission_resources edge. - repeated PermissionResource permission_resources = 5 [json_name = "permission_resources"]; - // PositionPermissions holds the value of the position_permissions edge. - repeated PositionPermission position_permissions = 6 [json_name = "position_permissions"]; + repeated View views = 15 [json_name = "views"]; } // user_position.table.comment @@ -456,14 +364,6 @@ message UserPosition { int64 position_id = 3 [json_name = "position_id"]; } -// UserPositionEdges holds the relations/edges for other nodes in the graph. -message UserPositionEdges { - // User holds the value of the user edge. - User user = 1 [json_name = "user"]; - // Position holds the value of the position edge. - Position position = 2 [json_name = "position"]; -} - // position_permission.table.comment message PositionPermission { // ID of the ent. @@ -475,14 +375,6 @@ message PositionPermission { int64 permission_id = 3 [json_name = "permission_id"]; } -// PositionPermissionEdges holds the relations/edges for other nodes in the graph. -message PositionPermissionEdges { - // Position holds the value of the position edge. - Position position = 1 [json_name = "position"]; - // Permission holds the value of the permission edge. - Permission permission = 2 [json_name = "permission"]; -} - // role_permission.table.comment message RolePermission { // ID of the ent. @@ -494,14 +386,6 @@ message RolePermission { int64 permission_id = 3 [json_name = "permission_id"]; } -// RolePermissionEdges holds the relations/edges for other nodes in the graph. -message RolePermissionEdges { - // Role holds the value of the role edge. - Role role = 1 [json_name = "role"]; - // Permission holds the value of the permission edge. - Permission permission = 2 [json_name = "permission"]; -} - // permission_resource.table.comment message PermissionResource { // ID of the ent. @@ -514,11 +398,3 @@ message PermissionResource { // permission_resource.field.actions string actions = 4 [json_name = "actions"]; } - -// PermissionResourceEdges holds the relations/edges for other nodes in the graph. -message PermissionResourceEdges { - // Permission holds the value of the permission edge. - Permission permission = 1 [json_name = "permission"]; - // Resource holds the value of the resource edge. - Resource resource = 2 [json_name = "resource"]; -} diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index 82ddc8c2..13f2924c 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -45,32 +45,34 @@ type View struct { Sequence int32 `protobuf:"varint,9,opt,name=sequence,proto3" json:"sequence,omitempty"` // Type holds the value of the "type" field. Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` + // Component holds the value of the "component" field. + Component string `protobuf:"bytes,11,opt,name=component,proto3" json:"component,omitempty"` // Comment holds the value of the "comment" field. - Comment string `protobuf:"bytes,11,opt,name=comment,proto3" json:"comment,omitempty"` + Comment string `protobuf:"bytes,12,opt,name=comment,proto3" json:"comment,omitempty"` // Icon holds the value of the "icon" field. - Icon string `protobuf:"bytes,12,opt,name=icon,proto3" json:"icon,omitempty"` + Icon string `protobuf:"bytes,13,opt,name=icon,proto3" json:"icon,omitempty"` // Visible holds the value of the "visible" field. - Visible bool `protobuf:"varint,13,opt,name=visible,proto3" json:"visible,omitempty"` + Visible bool `protobuf:"varint,14,opt,name=visible,proto3" json:"visible,omitempty"` // Path holds the value of the "path" field. - Path string `protobuf:"bytes,14,opt,name=path,proto3" json:"path,omitempty"` + Path string `protobuf:"bytes,15,opt,name=path,proto3" json:"path,omitempty"` // TreePath holds the value of the "tree_path" field. - TreePath string `protobuf:"bytes,15,opt,name=tree_path,proto3" json:"tree_path,omitempty"` + TreePath string `protobuf:"bytes,16,opt,name=tree_path,proto3" json:"tree_path,omitempty"` // Properties holds the value of the "properties" field. - Properties string `protobuf:"bytes,16,opt,name=properties,proto3" json:"properties,omitempty"` + Properties string `protobuf:"bytes,17,opt,name=properties,proto3" json:"properties,omitempty"` // Status holds the value of the "status" field. - Status int32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,18,opt,name=status,proto3" json:"status,omitempty"` // ParentID holds the value of the "parent_id" field. - ParentId int64 `protobuf:"varint,18,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + ParentId int64 `protobuf:"varint,19,opt,name=parent_id,proto3" json:"parent_id,omitempty"` // ParentPath holds the value of the "parent_path" field. - ParentPath string `protobuf:"bytes,19,opt,name=parent_path,proto3" json:"parent_path,omitempty"` + ParentPath string `protobuf:"bytes,20,opt,name=parent_path,proto3" json:"parent_path,omitempty"` // Children holds the value of the children edge. - Children []*View `protobuf:"bytes,20,rep,name=children,proto3" json:"children,omitempty"` + Children []*View `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. - Parent *View `protobuf:"bytes,21,opt,name=parent,proto3" json:"parent,omitempty"` + Parent *View `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,22,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,23,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -175,6 +177,13 @@ func (x *View) GetType() string { return "" } +func (x *View) GetComponent() string { + if x != nil { + return x.Component + } + return "" +} + func (x *View) GetComment() string { if x != nil { return x.Comment @@ -266,88 +275,6 @@ func (x *View) GetRoles() []*Role { return nil } -// ViewEdges holds the relations/edges for other nodes in the graph. -type ViewEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Children holds the value of the children edge. - Children []*View `protobuf:"bytes,1,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *View `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,3,rep,name=resources,proto3" json:"resources,omitempty"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,4,rep,name=roles,proto3" json:"roles,omitempty"` - // RoleView holds the value of the role_view edge. - RoleViews []*RoleView `protobuf:"bytes,5,rep,name=role_views,proto3" json:"role_views,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ViewEdges) Reset() { - *x = ViewEdges{} - mi := &file_types_system_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ViewEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ViewEdges) ProtoMessage() {} - -func (x *ViewEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[1] - 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 ViewEdges.ProtoReflect.Descriptor instead. -func (*ViewEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{1} -} - -func (x *ViewEdges) GetChildren() []*View { - if x != nil { - return x.Children - } - return nil -} - -func (x *ViewEdges) GetParent() *View { - if x != nil { - return x.Parent - } - return nil -} - -func (x *ViewEdges) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *ViewEdges) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *ViewEdges) GetRoleViews() []*RoleView { - if x != nil { - return x.RoleViews - } - return nil -} - // Role is the model entity for the Role schema. type Role struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -358,39 +285,47 @@ type Role struct { CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // create_author.field.comment + CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // role.field.keyword - Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` + Keyword string `protobuf:"bytes,6,opt,name=keyword,proto3" json:"keyword,omitempty"` // role.field.name - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"` // role.field.description - Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,8,opt,name=description,proto3" json:"description,omitempty"` // role.field.type - Type int32 `protobuf:"varint,7,opt,name=type,proto3" json:"type,omitempty"` + Type int32 `protobuf:"varint,9,opt,name=type,proto3" json:"type,omitempty"` // role.field.sequence - Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` + Sequence int32 `protobuf:"varint,10,opt,name=sequence,proto3" json:"sequence,omitempty"` // role.field.status - Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,11,opt,name=status,proto3" json:"status,omitempty"` // role.field.is_types - IsTypes bool `protobuf:"varint,10,opt,name=is_types,proto3" json:"is_types,omitempty"` + IsTypes bool `protobuf:"varint,12,opt,name=is_types,proto3" json:"is_types,omitempty"` // Views holds the value of the views edge. Views []*View `protobuf:"bytes,21,rep,name=views,proto3" json:"views,omitempty"` + // View Ids holds the value of the view_ids edge. + ViewIds []int64 `protobuf:"varint,20,rep,packed,name=view_ids,proto3" json:"view_ids,omitempty"` // Users holds the value of the users edge. Users []*User `protobuf:"bytes,22,rep,name=users,proto3" json:"users,omitempty"` + // Users Ids holds the value of the user_ids edge. + UserIds []int64 `protobuf:"varint,23,rep,packed,name=user_ids,proto3" json:"user_ids,omitempty"` // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*Resource `protobuf:"bytes,24,rep,name=resources,proto3" json:"resources,omitempty"` // Resource Ids holds the value of the resource_ids edge. - ResourceIds []int64 `protobuf:"varint,24,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` + ResourceIds []int64 `protobuf:"varint,25,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,25,rep,name=permissions,proto3" json:"permissions,omitempty"` + Permissions []*Permission `protobuf:"bytes,26,rep,name=permissions,proto3" json:"permissions,omitempty"` // Permission Ids holds the value of the permission_ids edge. - PermissionIds []int64 `protobuf:"varint,26,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` + PermissionIds []int64 `protobuf:"varint,27,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Role) Reset() { *x = Role{} - mi := &file_types_system_proto_msgTypes[2] + mi := &file_types_system_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -402,7 +337,7 @@ func (x *Role) String() string { func (*Role) ProtoMessage() {} func (x *Role) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[2] + mi := &file_types_system_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -415,7 +350,7 @@ func (x *Role) ProtoReflect() protoreflect.Message { // Deprecated: Use Role.ProtoReflect.Descriptor instead. func (*Role) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{2} + return file_types_system_proto_rawDescGZIP(), []int{1} } func (x *Role) GetId() int64 { @@ -439,6 +374,20 @@ func (x *Role) GetUpdateTime() *timestamppb.Timestamp { return nil } +func (x *Role) GetCreateAuthor() int64 { + if x != nil { + return x.CreateAuthor + } + return 0 +} + +func (x *Role) GetUpdateAuthor() int64 { + if x != nil { + return x.UpdateAuthor + } + return 0 +} + func (x *Role) GetKeyword() string { if x != nil { return x.Keyword @@ -495,110 +444,51 @@ func (x *Role) GetViews() []*View { return nil } -func (x *Role) GetUsers() []*User { - if x != nil { - return x.Users - } - return nil -} - -func (x *Role) GetResources() []*Resource { +func (x *Role) GetViewIds() []int64 { if x != nil { - return x.Resources - } - return nil -} - -func (x *Role) GetResourceIds() []int64 { - if x != nil { - return x.ResourceIds + return x.ViewIds } return nil } -func (x *Role) GetPermissions() []*Permission { +func (x *Role) GetUsers() []*User { if x != nil { - return x.Permissions + return x.Users } return nil } -func (x *Role) GetPermissionIds() []int64 { +func (x *Role) GetUserIds() []int64 { if x != nil { - return x.PermissionIds + return x.UserIds } return nil } -// RoleEdges holds the relations/edges for other nodes in the graph. -type RoleEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Views holds the value of the views edge. - Views []*View `protobuf:"bytes,1,rep,name=views,proto3" json:"views,omitempty"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` - // RoleView holds the value of the role_view edge. - RoleViews []*RoleView `protobuf:"bytes,3,rep,name=role_views,proto3" json:"role_views,omitempty"` - // UserRole holds the value of the user_role edge. - UserRoles []*UserRole `protobuf:"bytes,4,rep,name=user_roles,proto3" json:"user_roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RoleEdges) Reset() { - *x = RoleEdges{} - mi := &file_types_system_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RoleEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RoleEdges) ProtoMessage() {} - -func (x *RoleEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[3] - 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 RoleEdges.ProtoReflect.Descriptor instead. -func (*RoleEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{3} -} - -func (x *RoleEdges) GetViews() []*View { +func (x *Role) GetResources() []*Resource { if x != nil { - return x.Views + return x.Resources } return nil } -func (x *RoleEdges) GetUsers() []*User { +func (x *Role) GetResourceIds() []int64 { if x != nil { - return x.Users + return x.ResourceIds } return nil } -func (x *RoleEdges) GetRoleViews() []*RoleView { +func (x *Role) GetPermissions() []*Permission { if x != nil { - return x.RoleViews + return x.Permissions } return nil } -func (x *RoleEdges) GetUserRoles() []*UserRole { +func (x *Role) GetPermissionIds() []int64 { if x != nil { - return x.UserRoles + return x.PermissionIds } return nil } @@ -609,14 +499,14 @@ type User struct { // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_author.field.comment - CreateAuthor int64 `protobuf:"varint,2,opt,name=create_author,proto3" json:"create_author,omitempty"` - // update_author.field.comment - UpdateAuthor int64 `protobuf:"varint,3,opt,name=update_author,proto3" json:"update_author,omitempty"` // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=create_time,proto3" json:"create_time,omitempty"` + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=update_time,proto3" json:"update_time,omitempty"` + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // create_author.field.comment + CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // user.field.uuid Uuid string `protobuf:"bytes,6,opt,name=uuid,proto3" json:"uuid,omitempty"` // user.field.allowed_ip @@ -641,32 +531,29 @@ type User struct { Token string `protobuf:"bytes,16,opt,name=token,proto3" json:"token,omitempty"` // user.field.status Status int32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` + // user.field.i18n + I18N string `protobuf:"bytes,18,opt,name=i18n,proto3" json:"i18n,omitempty"` // user.field.last_login_ip - LastLoginIp string `protobuf:"bytes,18,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` + LastLoginIp string `protobuf:"bytes,19,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` // user.field.login_ip - LoginIp string `protobuf:"bytes,19,opt,name=login_ip,proto3" json:"login_ip,omitempty"` + LoginIp string `protobuf:"bytes,20,opt,name=login_ip,proto3" json:"login_ip,omitempty"` // user.field.last_login_time - LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,20,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` + LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,21,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` // user.field.login_time - LoginTime *timestamppb.Timestamp `protobuf:"bytes,21,opt,name=login_time,proto3" json:"login_time,omitempty"` + LoginTime *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=login_time,proto3" json:"login_time,omitempty"` // user.field.sanction_date - SanctionDate *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` - // // user.field.manager_id - // int64 manager_id = 21 [json_name = "manager_id"]; - // // user.field.manager - // string manager = 22 [json_name = "manager"]; - // + SanctionDate *timestamppb.Timestamp `protobuf:"bytes,23,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,23,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` // Role Ids holds the value of the role_ids - RoleIds []int64 `protobuf:"varint,24,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` + RoleIds []int64 `protobuf:"varint,25,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *User) Reset() { *x = User{} - mi := &file_types_system_proto_msgTypes[4] + mi := &file_types_system_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -678,7 +565,7 @@ func (x *User) String() string { func (*User) ProtoMessage() {} func (x *User) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[4] + mi := &file_types_system_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -691,7 +578,7 @@ func (x *User) ProtoReflect() protoreflect.Message { // Deprecated: Use User.ProtoReflect.Descriptor instead. func (*User) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{4} + return file_types_system_proto_rawDescGZIP(), []int{2} } func (x *User) GetId() int64 { @@ -701,32 +588,32 @@ func (x *User) GetId() int64 { return 0 } -func (x *User) GetCreateAuthor() int64 { +func (x *User) GetCreateTime() *timestamppb.Timestamp { if x != nil { - return x.CreateAuthor + return x.CreateTime } - return 0 + return nil } -func (x *User) GetUpdateAuthor() int64 { +func (x *User) GetUpdateTime() *timestamppb.Timestamp { if x != nil { - return x.UpdateAuthor + return x.UpdateTime } - return 0 + return nil } -func (x *User) GetCreateTime() *timestamppb.Timestamp { +func (x *User) GetCreateAuthor() int64 { if x != nil { - return x.CreateTime + return x.CreateAuthor } - return nil + return 0 } -func (x *User) GetUpdateTime() *timestamppb.Timestamp { +func (x *User) GetUpdateAuthor() int64 { if x != nil { - return x.UpdateTime + return x.UpdateAuthor } - return nil + return 0 } func (x *User) GetUuid() string { @@ -813,6 +700,13 @@ func (x *User) GetStatus() int32 { return 0 } +func (x *User) GetI18N() string { + if x != nil { + return x.I18N + } + return "" +} + func (x *User) GetLastLoginIp() string { if x != nil { return x.LastLoginIp @@ -862,61 +756,6 @@ func (x *User) GetRoleIds() []int64 { return nil } -// UserEdges holds the relations/edges for other nodes in the graph. -type UserEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` - // UserRole holds the value of the user_role edge. - UserRoles []*UserRole `protobuf:"bytes,2,rep,name=user_roles,proto3" json:"user_roles,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserEdges) Reset() { - *x = UserEdges{} - mi := &file_types_system_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserEdges) ProtoMessage() {} - -func (x *UserEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[5] - 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 UserEdges.ProtoReflect.Descriptor instead. -func (*UserEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{5} -} - -func (x *UserEdges) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *UserEdges) GetUserRoles() []*UserRole { - if x != nil { - return x.UserRoles - } - return nil -} - // UserRole is the model entity for the UserRole schema. type UserRole struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -942,7 +781,7 @@ type UserRole struct { func (x *UserRole) Reset() { *x = UserRole{} - mi := &file_types_system_proto_msgTypes[6] + mi := &file_types_system_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -954,7 +793,7 @@ func (x *UserRole) String() string { func (*UserRole) ProtoMessage() {} func (x *UserRole) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[6] + mi := &file_types_system_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -967,7 +806,7 @@ func (x *UserRole) ProtoReflect() protoreflect.Message { // Deprecated: Use UserRole.ProtoReflect.Descriptor instead. func (*UserRole) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{6} + return file_types_system_proto_rawDescGZIP(), []int{3} } func (x *UserRole) GetId() int64 { @@ -1026,63 +865,8 @@ func (x *UserRole) GetRole() *Role { return nil } -// UserRoleEdges holds the relations/edges for other nodes in the graph. -type UserRoleEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserRoleEdges) Reset() { - *x = UserRoleEdges{} - mi := &file_types_system_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserRoleEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserRoleEdges) ProtoMessage() {} - -func (x *UserRoleEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[7] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserRoleEdges.ProtoReflect.Descriptor instead. -func (*UserRoleEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{7} -} - -func (x *UserRoleEdges) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserRoleEdges) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -// RoleView is the model entity for the RoleView schema. -type RoleView struct { +// RoleView is the model entity for the RoleView schema. +type RoleView struct { state protoimpl.MessageState `protogen:"open.v1"` // ID of the ent. Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -1104,7 +888,7 @@ type RoleView struct { func (x *RoleView) Reset() { *x = RoleView{} - mi := &file_types_system_proto_msgTypes[8] + mi := &file_types_system_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1116,7 +900,7 @@ func (x *RoleView) String() string { func (*RoleView) ProtoMessage() {} func (x *RoleView) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[8] + mi := &file_types_system_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1129,7 +913,7 @@ func (x *RoleView) ProtoReflect() protoreflect.Message { // Deprecated: Use RoleView.ProtoReflect.Descriptor instead. func (*RoleView) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{8} + return file_types_system_proto_rawDescGZIP(), []int{4} } func (x *RoleView) GetId() int64 { @@ -1181,61 +965,6 @@ func (x *RoleView) GetView() *View { return nil } -// RoleViewEdges holds the relations/edges for other nodes in the graph. -type RoleViewEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - // View holds the value of the view edge. - View *View `protobuf:"bytes,2,opt,name=view,proto3" json:"view,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RoleViewEdges) Reset() { - *x = RoleViewEdges{} - mi := &file_types_system_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RoleViewEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RoleViewEdges) ProtoMessage() {} - -func (x *RoleViewEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[9] - 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 RoleViewEdges.ProtoReflect.Descriptor instead. -func (*RoleViewEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{9} -} - -func (x *RoleViewEdges) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -func (x *RoleViewEdges) GetView() *View { - if x != nil { - return x.View - } - return nil -} - // Resource is the model entity for the Resource schema. type Resource struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -1246,30 +975,26 @@ type Resource struct { CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // create_author.field.comment + CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // resource.field.name - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` // resource.field.keyword - Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` - // resource.field.i18n_key - I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` + Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` // resource.field.type - Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` + Type string `protobuf:"bytes,9,opt,name=type,proto3" json:"type,omitempty"` // resource.field.status - Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,10,opt,name=status,proto3" json:"status,omitempty"` // resource.field.path - Path string `protobuf:"bytes,9,opt,name=path,proto3" json:"path,omitempty"` + Path string `protobuf:"bytes,11,opt,name=path,proto3" json:"path,omitempty"` // resource.field.operation - Operation string `protobuf:"bytes,10,opt,name=operation,proto3" json:"operation,omitempty"` + Operation string `protobuf:"bytes,12,opt,name=operation,proto3" json:"operation,omitempty"` // resource.field.method - Method string `protobuf:"bytes,11,opt,name=method,proto3" json:"method,omitempty"` - // resource.field.component - Component string `protobuf:"bytes,12,opt,name=component,proto3" json:"component,omitempty"` - // resource.field.icon - Icon string `protobuf:"bytes,13,opt,name=icon,proto3" json:"icon,omitempty"` + Method string `protobuf:"bytes,13,opt,name=method,proto3" json:"method,omitempty"` // resource.field.sequence Sequence int32 `protobuf:"varint,14,opt,name=sequence,proto3" json:"sequence,omitempty"` - // resource.field.visible - Visible bool `protobuf:"varint,15,opt,name=visible,proto3" json:"visible,omitempty"` // resource.field.tree_path TreePath string `protobuf:"bytes,16,opt,name=tree_path,proto3" json:"tree_path,omitempty"` // resource.field.properties @@ -1286,13 +1011,14 @@ type Resource struct { PermissionIds []int64 `protobuf:"varint,23,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` // Permissions holds the value of the permissions edge. Permissions []*Permission `protobuf:"bytes,24,rep,name=permissions,proto3" json:"permissions,omitempty"` + ServiceName string `protobuf:"bytes,25,opt,name=service_name,proto3" json:"service_name,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Resource) Reset() { *x = Resource{} - mi := &file_types_system_proto_msgTypes[10] + mi := &file_types_system_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1304,7 +1030,7 @@ func (x *Resource) String() string { func (*Resource) ProtoMessage() {} func (x *Resource) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[10] + mi := &file_types_system_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1317,7 +1043,7 @@ func (x *Resource) ProtoReflect() protoreflect.Message { // Deprecated: Use Resource.ProtoReflect.Descriptor instead. func (*Resource) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{10} + return file_types_system_proto_rawDescGZIP(), []int{5} } func (x *Resource) GetId() int64 { @@ -1341,23 +1067,30 @@ func (x *Resource) GetUpdateTime() *timestamppb.Timestamp { return nil } -func (x *Resource) GetName() string { +func (x *Resource) GetCreateAuthor() int64 { if x != nil { - return x.Name + return x.CreateAuthor } - return "" + return 0 } -func (x *Resource) GetKeyword() string { +func (x *Resource) GetUpdateAuthor() int64 { if x != nil { - return x.Keyword + return x.UpdateAuthor + } + return 0 +} + +func (x *Resource) GetName() string { + if x != nil { + return x.Name } return "" } -func (x *Resource) GetI18NKey() string { +func (x *Resource) GetKeyword() string { if x != nil { - return x.I18NKey + return x.Keyword } return "" } @@ -1397,20 +1130,6 @@ func (x *Resource) GetMethod() string { return "" } -func (x *Resource) GetComponent() string { - if x != nil { - return x.Component - } - return "" -} - -func (x *Resource) GetIcon() string { - if x != nil { - return x.Icon - } - return "" -} - func (x *Resource) GetSequence() int32 { if x != nil { return x.Sequence @@ -1418,13 +1137,6 @@ func (x *Resource) GetSequence() int32 { return 0 } -func (x *Resource) GetVisible() bool { - if x != nil { - return x.Visible - } - return false -} - func (x *Resource) GetTreePath() string { if x != nil { return x.TreePath @@ -1481,50 +1193,11 @@ func (x *Resource) GetPermissions() []*Permission { return nil } -// ResourceEdges holds the relations/edges for other nodes in the graph. -type ResourceEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // View holds the value of the view edge. - View *View `protobuf:"bytes,1,opt,name=view,proto3" json:"view,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *ResourceEdges) Reset() { - *x = ResourceEdges{} - mi := &file_types_system_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *ResourceEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ResourceEdges) ProtoMessage() {} - -func (x *ResourceEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[11] - 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 ResourceEdges.ProtoReflect.Descriptor instead. -func (*ResourceEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{11} -} - -func (x *ResourceEdges) GetView() *View { +func (x *Resource) GetServiceName() string { if x != nil { - return x.View + return x.ServiceName } - return nil + return "" } // department.table.comment @@ -1537,33 +1210,37 @@ type Department struct { CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // create_author.field.comment + CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // department.field.keyword - Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` + Keyword string `protobuf:"bytes,6,opt,name=keyword,proto3" json:"keyword,omitempty"` // department.field.name - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"` // department.field.tree_path - TreePath string `protobuf:"bytes,6,opt,name=tree_path,proto3" json:"tree_path,omitempty"` + TreePath string `protobuf:"bytes,8,opt,name=tree_path,proto3" json:"tree_path,omitempty"` // department.field.sequence - Sequence int32 `protobuf:"varint,7,opt,name=sequence,proto3" json:"sequence,omitempty"` + Sequence int32 `protobuf:"varint,9,opt,name=sequence,proto3" json:"sequence,omitempty"` // department.field.status - Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,10,opt,name=status,proto3" json:"status,omitempty"` // department.field.level - Level int32 `protobuf:"varint,9,opt,name=level,proto3" json:"level,omitempty"` + Level int32 `protobuf:"varint,11,opt,name=level,proto3" json:"level,omitempty"` // department.field.description - Description string `protobuf:"bytes,10,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,12,opt,name=description,proto3" json:"description,omitempty"` // department.field.parent_id - ParentId int64 `protobuf:"varint,11,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + ParentId int64 `protobuf:"varint,13,opt,name=parent_id,proto3" json:"parent_id,omitempty"` // Children holds the value of the children edge. - Children []*Department `protobuf:"bytes,12,rep,name=children,proto3" json:"children,omitempty"` + Children []*Department `protobuf:"bytes,14,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. - Parent *Department `protobuf:"bytes,13,opt,name=parent,proto3" json:"parent,omitempty"` + Parent *Department `protobuf:"bytes,15,opt,name=parent,proto3" json:"parent,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Department) Reset() { *x = Department{} - mi := &file_types_system_proto_msgTypes[12] + mi := &file_types_system_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1575,7 +1252,7 @@ func (x *Department) String() string { func (*Department) ProtoMessage() {} func (x *Department) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[12] + mi := &file_types_system_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1588,7 +1265,7 @@ func (x *Department) ProtoReflect() protoreflect.Message { // Deprecated: Use Department.ProtoReflect.Descriptor instead. func (*Department) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{12} + return file_types_system_proto_rawDescGZIP(), []int{6} } func (x *Department) GetId() int64 { @@ -1612,6 +1289,20 @@ func (x *Department) GetUpdateTime() *timestamppb.Timestamp { return nil } +func (x *Department) GetCreateAuthor() int64 { + if x != nil { + return x.CreateAuthor + } + return 0 +} + +func (x *Department) GetUpdateAuthor() int64 { + if x != nil { + return x.UpdateAuthor + } + return 0 +} + func (x *Department) GetKeyword() string { if x != nil { return x.Keyword @@ -1682,87 +1373,6 @@ func (x *Department) GetParent() *Department { return nil } -type DepartmentEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` - // Positions holds the value of the positions edge. - Positions []*Position `protobuf:"bytes,2,rep,name=positions,proto3" json:"positions,omitempty"` - // Children holds the value of the children edge. - Children []*Department `protobuf:"bytes,3,rep,name=children,proto3" json:"children,omitempty"` - // Parent holds the value of the parent edge. - Parent *Department `protobuf:"bytes,4,opt,name=parent,proto3" json:"parent,omitempty"` - // UserDepartments holds the value of the user_departments edge. - UserDepartments []*UserDepartment `protobuf:"bytes,5,rep,name=user_departments,proto3" json:"user_departments,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *DepartmentEdges) Reset() { - *x = DepartmentEdges{} - mi := &file_types_system_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *DepartmentEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DepartmentEdges) ProtoMessage() {} - -func (x *DepartmentEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[13] - 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 DepartmentEdges.ProtoReflect.Descriptor instead. -func (*DepartmentEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{13} -} - -func (x *DepartmentEdges) GetUsers() []*User { - if x != nil { - return x.Users - } - return nil -} - -func (x *DepartmentEdges) GetPositions() []*Position { - if x != nil { - return x.Positions - } - return nil -} - -func (x *DepartmentEdges) GetChildren() []*Department { - if x != nil { - return x.Children - } - return nil -} - -func (x *DepartmentEdges) GetParent() *Department { - if x != nil { - return x.Parent - } - return nil -} - -func (x *DepartmentEdges) GetUserDepartments() []*UserDepartment { - if x != nil { - return x.UserDepartments - } - return nil -} - // user_department.table.comment type UserDepartment struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -1772,17 +1382,14 @@ type UserDepartment struct { // field.foreign_key.comment UserId int64 `protobuf:"varint,2,opt,name=user_id,proto3" json:"user_id,omitempty"` // field.foreign_key.comment - DepartmentId int64 `protobuf:"varint,3,opt,name=department_id,proto3" json:"department_id,omitempty"` - // Edges holds the relations/edges for other nodes in the graph. - // The values are being populated by the UserDepartmentQuery when eager-loading is set. - Edges *UserDepartmentEdges `protobuf:"bytes,4,opt,name=edges,proto3" json:"edges,omitempty"` + DepartmentId int64 `protobuf:"varint,3,opt,name=department_id,proto3" json:"department_id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *UserDepartment) Reset() { *x = UserDepartment{} - mi := &file_types_system_proto_msgTypes[14] + mi := &file_types_system_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1794,7 +1401,7 @@ func (x *UserDepartment) String() string { func (*UserDepartment) ProtoMessage() {} func (x *UserDepartment) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[14] + mi := &file_types_system_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1807,7 +1414,7 @@ func (x *UserDepartment) ProtoReflect() protoreflect.Message { // Deprecated: Use UserDepartment.ProtoReflect.Descriptor instead. func (*UserDepartment) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{14} + return file_types_system_proto_rawDescGZIP(), []int{7} } func (x *UserDepartment) GetId() int64 { @@ -1831,68 +1438,6 @@ func (x *UserDepartment) GetDepartmentId() int64 { return 0 } -func (x *UserDepartment) GetEdges() *UserDepartmentEdges { - if x != nil { - return x.Edges - } - return nil -} - -// UserDepartmentEdges holds the relations/edges for other nodes in the graph. -type UserDepartmentEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // Department holds the value of the department edge. - Department *Department `protobuf:"bytes,2,opt,name=department,proto3" json:"department,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserDepartmentEdges) Reset() { - *x = UserDepartmentEdges{} - mi := &file_types_system_proto_msgTypes[15] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserDepartmentEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserDepartmentEdges) ProtoMessage() {} - -func (x *UserDepartmentEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[15] - 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 UserDepartmentEdges.ProtoReflect.Descriptor instead. -func (*UserDepartmentEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{15} -} - -func (x *UserDepartmentEdges) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserDepartmentEdges) GetDepartment() *Department { - if x != nil { - return x.Department - } - return nil -} - // position.table.comment type Position struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -1903,21 +1448,25 @@ type Position struct { CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // create_author.field.comment + CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // position.field.name - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` // position.field.keyword - Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` + Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` // position.field.description - Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,8,opt,name=description,proto3" json:"description,omitempty"` // department.field.department_id - DepartmentId int64 `protobuf:"varint,7,opt,name=department_id,proto3" json:"department_id,omitempty"` + DepartmentId int64 `protobuf:"varint,9,opt,name=department_id,proto3" json:"department_id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Position) Reset() { *x = Position{} - mi := &file_types_system_proto_msgTypes[16] + mi := &file_types_system_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1929,7 +1478,7 @@ func (x *Position) String() string { func (*Position) ProtoMessage() {} func (x *Position) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[16] + mi := &file_types_system_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1942,7 +1491,7 @@ func (x *Position) ProtoReflect() protoreflect.Message { // Deprecated: Use Position.ProtoReflect.Descriptor instead. func (*Position) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{16} + return file_types_system_proto_rawDescGZIP(), []int{8} } func (x *Position) GetId() int64 { @@ -1966,114 +1515,46 @@ func (x *Position) GetUpdateTime() *timestamppb.Timestamp { return nil } -func (x *Position) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *Position) GetKeyword() string { +func (x *Position) GetCreateAuthor() int64 { if x != nil { - return x.Keyword - } - return "" -} - -func (x *Position) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Position) GetDepartmentId() int64 { - if x != nil { - return x.DepartmentId + return x.CreateAuthor } return 0 } -// PositionEdges holds the relations/edges for other nodes in the graph. -type PositionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Department holds the value of the department edge. - Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` - // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` - // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,3,rep,name=permissions,proto3" json:"permissions,omitempty"` - // UserPositions holds the value of the user_positions edge. - UserPositions []*UserPosition `protobuf:"bytes,4,rep,name=user_positions,proto3" json:"user_positions,omitempty"` - // PositionPermissions holds the value of the position_permissions edge. - PositionPermissions []*PositionPermission `protobuf:"bytes,5,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PositionEdges) Reset() { - *x = PositionEdges{} - mi := &file_types_system_proto_msgTypes[17] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PositionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PositionEdges) ProtoMessage() {} - -func (x *PositionEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[17] +func (x *Position) GetUpdateAuthor() int64 { 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 PositionEdges.ProtoReflect.Descriptor instead. -func (*PositionEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{17} -} - -func (x *PositionEdges) GetDepartment() *Department { - if x != nil { - return x.Department + return x.UpdateAuthor } - return nil + return 0 } -func (x *PositionEdges) GetUsers() []*User { +func (x *Position) GetName() string { if x != nil { - return x.Users + return x.Name } - return nil + return "" } -func (x *PositionEdges) GetPermissions() []*Permission { +func (x *Position) GetKeyword() string { if x != nil { - return x.Permissions + return x.Keyword } - return nil + return "" } -func (x *PositionEdges) GetUserPositions() []*UserPosition { +func (x *Position) GetDescription() string { if x != nil { - return x.UserPositions + return x.Description } - return nil + return "" } -func (x *PositionEdges) GetPositionPermissions() []*PositionPermission { +func (x *Position) GetDepartmentId() int64 { if x != nil { - return x.PositionPermissions + return x.DepartmentId } - return nil + return 0 } // permission.table.comment @@ -2086,33 +1567,37 @@ type Permission struct { CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` + // create_author.field.comment + CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` + // update_author.field.comment + UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // permission.field.name - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` // permission.field.keyword - Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` + Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` // permission.field.status - Status int32 `protobuf:"varint,6,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` // permission.field.description - Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,9,opt,name=description,proto3" json:"description,omitempty"` // permission.field.data_scope - DataScope string `protobuf:"bytes,8,opt,name=data_scope,proto3" json:"data_scope,omitempty"` + DataScope string `protobuf:"bytes,10,opt,name=data_scope,proto3" json:"data_scope,omitempty"` // permission.field.data_rules - DataRules map[string]string `protobuf:"bytes,9,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + DataRules map[string]string `protobuf:"bytes,11,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // permission.field.resource_ids - ResourceIds []int64 `protobuf:"varint,10,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` + ResourceIds []int64 `protobuf:"varint,12,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` // permission.field.resources - Resources []*Resource `protobuf:"bytes,11,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*Resource `protobuf:"bytes,13,rep,name=resources,proto3" json:"resources,omitempty"` // permission.field.view_ids - ViewIds []int64 `protobuf:"varint,12,rep,packed,name=view_ids,proto3" json:"view_ids,omitempty"` + ViewIds []int64 `protobuf:"varint,14,rep,packed,name=view_ids,proto3" json:"view_ids,omitempty"` // permission.field.views - Views []*View `protobuf:"bytes,13,rep,name=views,proto3" json:"views,omitempty"` + Views []*View `protobuf:"bytes,15,rep,name=views,proto3" json:"views,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Permission) Reset() { *x = Permission{} - mi := &file_types_system_proto_msgTypes[18] + mi := &file_types_system_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2124,7 +1609,7 @@ func (x *Permission) String() string { func (*Permission) ProtoMessage() {} func (x *Permission) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[18] + mi := &file_types_system_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2137,7 +1622,7 @@ func (x *Permission) ProtoReflect() protoreflect.Message { // Deprecated: Use Permission.ProtoReflect.Descriptor instead. func (*Permission) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{18} + return file_types_system_proto_rawDescGZIP(), []int{9} } func (x *Permission) GetId() int64 { @@ -2161,6 +1646,20 @@ func (x *Permission) GetUpdateTime() *timestamppb.Timestamp { return nil } +func (x *Permission) GetCreateAuthor() int64 { + if x != nil { + return x.CreateAuthor + } + return 0 +} + +func (x *Permission) GetUpdateAuthor() int64 { + if x != nil { + return x.UpdateAuthor + } + return 0 +} + func (x *Permission) GetName() string { if x != nil { return x.Name @@ -2231,97 +1730,6 @@ func (x *Permission) GetViews() []*View { return nil } -// PermissionEdges holds the relations/edges for other nodes in the graph. -type PermissionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"` - // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,2,rep,name=resources,proto3" json:"resources,omitempty"` - // Positions holds the value of the positions edge. - Positions []*Position `protobuf:"bytes,3,rep,name=positions,proto3" json:"positions,omitempty"` - // RolePermissions holds the value of the role_permissions edge. - RolePermissions []*RolePermission `protobuf:"bytes,4,rep,name=role_permissions,proto3" json:"role_permissions,omitempty"` - // PermissionResources holds the value of the permission_resources edge. - PermissionResources []*PermissionResource `protobuf:"bytes,5,rep,name=permission_resources,proto3" json:"permission_resources,omitempty"` - // PositionPermissions holds the value of the position_permissions edge. - PositionPermissions []*PositionPermission `protobuf:"bytes,6,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PermissionEdges) Reset() { - *x = PermissionEdges{} - mi := &file_types_system_proto_msgTypes[19] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PermissionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PermissionEdges) ProtoMessage() {} - -func (x *PermissionEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[19] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PermissionEdges.ProtoReflect.Descriptor instead. -func (*PermissionEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{19} -} - -func (x *PermissionEdges) GetRoles() []*Role { - if x != nil { - return x.Roles - } - return nil -} - -func (x *PermissionEdges) GetResources() []*Resource { - if x != nil { - return x.Resources - } - return nil -} - -func (x *PermissionEdges) GetPositions() []*Position { - if x != nil { - return x.Positions - } - return nil -} - -func (x *PermissionEdges) GetRolePermissions() []*RolePermission { - if x != nil { - return x.RolePermissions - } - return nil -} - -func (x *PermissionEdges) GetPermissionResources() []*PermissionResource { - if x != nil { - return x.PermissionResources - } - return nil -} - -func (x *PermissionEdges) GetPositionPermissions() []*PositionPermission { - if x != nil { - return x.PositionPermissions - } - return nil -} - // user_position.table.comment type UserPosition struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -2338,7 +1746,7 @@ type UserPosition struct { func (x *UserPosition) Reset() { *x = UserPosition{} - mi := &file_types_system_proto_msgTypes[20] + mi := &file_types_system_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2350,7 +1758,7 @@ func (x *UserPosition) String() string { func (*UserPosition) ProtoMessage() {} func (x *UserPosition) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[20] + mi := &file_types_system_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2363,7 +1771,7 @@ func (x *UserPosition) ProtoReflect() protoreflect.Message { // Deprecated: Use UserPosition.ProtoReflect.Descriptor instead. func (*UserPosition) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{20} + return file_types_system_proto_rawDescGZIP(), []int{10} } func (x *UserPosition) GetId() int64 { @@ -2387,61 +1795,6 @@ func (x *UserPosition) GetPositionId() int64 { return 0 } -// UserPositionEdges holds the relations/edges for other nodes in the graph. -type UserPositionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // User holds the value of the user edge. - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` - // Position holds the value of the position edge. - Position *Position `protobuf:"bytes,2,opt,name=position,proto3" json:"position,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *UserPositionEdges) Reset() { - *x = UserPositionEdges{} - mi := &file_types_system_proto_msgTypes[21] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *UserPositionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*UserPositionEdges) ProtoMessage() {} - -func (x *UserPositionEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[21] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use UserPositionEdges.ProtoReflect.Descriptor instead. -func (*UserPositionEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{21} -} - -func (x *UserPositionEdges) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - -func (x *UserPositionEdges) GetPosition() *Position { - if x != nil { - return x.Position - } - return nil -} - // position_permission.table.comment type PositionPermission struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -2458,7 +1811,7 @@ type PositionPermission struct { func (x *PositionPermission) Reset() { *x = PositionPermission{} - mi := &file_types_system_proto_msgTypes[22] + mi := &file_types_system_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2470,7 +1823,7 @@ func (x *PositionPermission) String() string { func (*PositionPermission) ProtoMessage() {} func (x *PositionPermission) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[22] + mi := &file_types_system_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2483,7 +1836,7 @@ func (x *PositionPermission) ProtoReflect() protoreflect.Message { // Deprecated: Use PositionPermission.ProtoReflect.Descriptor instead. func (*PositionPermission) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{22} + return file_types_system_proto_rawDescGZIP(), []int{11} } func (x *PositionPermission) GetId() int64 { @@ -2507,61 +1860,6 @@ func (x *PositionPermission) GetPermissionId() int64 { return 0 } -// PositionPermissionEdges holds the relations/edges for other nodes in the graph. -type PositionPermissionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Position holds the value of the position edge. - Position *Position `protobuf:"bytes,1,opt,name=position,proto3" json:"position,omitempty"` - // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PositionPermissionEdges) Reset() { - *x = PositionPermissionEdges{} - mi := &file_types_system_proto_msgTypes[23] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PositionPermissionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PositionPermissionEdges) ProtoMessage() {} - -func (x *PositionPermissionEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[23] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PositionPermissionEdges.ProtoReflect.Descriptor instead. -func (*PositionPermissionEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{23} -} - -func (x *PositionPermissionEdges) GetPosition() *Position { - if x != nil { - return x.Position - } - return nil -} - -func (x *PositionPermissionEdges) GetPermission() *Permission { - if x != nil { - return x.Permission - } - return nil -} - // role_permission.table.comment type RolePermission struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -2578,7 +1876,7 @@ type RolePermission struct { func (x *RolePermission) Reset() { *x = RolePermission{} - mi := &file_types_system_proto_msgTypes[24] + mi := &file_types_system_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2590,7 +1888,7 @@ func (x *RolePermission) String() string { func (*RolePermission) ProtoMessage() {} func (x *RolePermission) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[24] + mi := &file_types_system_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2603,7 +1901,7 @@ func (x *RolePermission) ProtoReflect() protoreflect.Message { // Deprecated: Use RolePermission.ProtoReflect.Descriptor instead. func (*RolePermission) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{24} + return file_types_system_proto_rawDescGZIP(), []int{12} } func (x *RolePermission) GetId() int64 { @@ -2627,61 +1925,6 @@ func (x *RolePermission) GetPermissionId() int64 { return 0 } -// RolePermissionEdges holds the relations/edges for other nodes in the graph. -type RolePermissionEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"` - // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *RolePermissionEdges) Reset() { - *x = RolePermissionEdges{} - mi := &file_types_system_proto_msgTypes[25] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RolePermissionEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RolePermissionEdges) ProtoMessage() {} - -func (x *RolePermissionEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_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 RolePermissionEdges.ProtoReflect.Descriptor instead. -func (*RolePermissionEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{25} -} - -func (x *RolePermissionEdges) GetRole() *Role { - if x != nil { - return x.Role - } - return nil -} - -func (x *RolePermissionEdges) GetPermission() *Permission { - if x != nil { - return x.Permission - } - return nil -} - // permission_resource.table.comment type PermissionResource struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -2700,7 +1943,7 @@ type PermissionResource struct { func (x *PermissionResource) Reset() { *x = PermissionResource{} - mi := &file_types_system_proto_msgTypes[26] + mi := &file_types_system_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2712,7 +1955,7 @@ func (x *PermissionResource) String() string { func (*PermissionResource) ProtoMessage() {} func (x *PermissionResource) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[26] + mi := &file_types_system_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2725,7 +1968,7 @@ func (x *PermissionResource) ProtoReflect() protoreflect.Message { // Deprecated: Use PermissionResource.ProtoReflect.Descriptor instead. func (*PermissionResource) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{26} + return file_types_system_proto_rawDescGZIP(), []int{13} } func (x *PermissionResource) GetId() int64 { @@ -2756,66 +1999,11 @@ func (x *PermissionResource) GetActions() string { return "" } -// PermissionResourceEdges holds the relations/edges for other nodes in the graph. -type PermissionResourceEdges struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Permission holds the value of the permission edge. - Permission *Permission `protobuf:"bytes,1,opt,name=permission,proto3" json:"permission,omitempty"` - // Resource holds the value of the resource edge. - Resource *Resource `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache -} - -func (x *PermissionResourceEdges) Reset() { - *x = PermissionResourceEdges{} - mi := &file_types_system_proto_msgTypes[27] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *PermissionResourceEdges) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*PermissionResourceEdges) ProtoMessage() {} - -func (x *PermissionResourceEdges) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[27] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use PermissionResourceEdges.ProtoReflect.Descriptor instead. -func (*PermissionResourceEdges) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{27} -} - -func (x *PermissionResourceEdges) GetPermission() *Permission { - if x != nil { - return x.Permission - } - return nil -} - -func (x *PermissionResourceEdges) GetResource() *Resource { - if x != nil { - return x.Resource - } - return nil -} - var File_types_system_proto protoreflect.FileDescriptor const file_types_system_proto_rawDesc = "" + "\n" + - "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x96\x06\n" + + "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xb4\x06\n" + "\x04View\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + @@ -2827,63 +2015,51 @@ const file_types_system_proto_rawDesc = "" + "\vdescription\x18\b \x01(\tR\vdescription\x12\x1a\n" + "\bsequence\x18\t \x01(\x05R\bsequence\x12\x12\n" + "\x04type\x18\n" + - " \x01(\tR\x04type\x12\x18\n" + - "\acomment\x18\v \x01(\tR\acomment\x12\x12\n" + - "\x04icon\x18\f \x01(\tR\x04icon\x12\x18\n" + - "\avisible\x18\r \x01(\bR\avisible\x12\x12\n" + - "\x04path\x18\x0e \x01(\tR\x04path\x12\x1c\n" + - "\ttree_path\x18\x0f \x01(\tR\ttree_path\x12\x1e\n" + + " \x01(\tR\x04type\x12\x1c\n" + + "\tcomponent\x18\v \x01(\tR\tcomponent\x12\x18\n" + + "\acomment\x18\f \x01(\tR\acomment\x12\x12\n" + + "\x04icon\x18\r \x01(\tR\x04icon\x12\x18\n" + + "\avisible\x18\x0e \x01(\bR\avisible\x12\x12\n" + + "\x04path\x18\x0f \x01(\tR\x04path\x12\x1c\n" + + "\ttree_path\x18\x10 \x01(\tR\ttree_path\x12\x1e\n" + "\n" + - "properties\x18\x10 \x01(\tR\n" + + "properties\x18\x11 \x01(\tR\n" + "properties\x12\x16\n" + - "\x06status\x18\x11 \x01(\x05R\x06status\x12\x1c\n" + - "\tparent_id\x18\x12 \x01(\x03R\tparent_id\x12 \n" + - "\vparent_path\x18\x13 \x01(\tR\vparent_path\x127\n" + - "\bchildren\x18\x14 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + - "\x06parent\x18\x15 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + - "\tresources\x18\x16 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + - "\x05roles\x18\x17 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xac\x02\n" + - "\tViewEdges\x127\n" + - "\bchildren\x18\x01 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + - "\x06parent\x18\x02 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + - "\tresources\x18\x03 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + - "\x05roles\x18\x04 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12?\n" + - "\n" + - "role_views\x18\x05 \x03(\v2\x1f.api.v1.services.types.RoleViewR\n" + - "role_views\"\xfc\x04\n" + + "\x06status\x18\x12 \x01(\x05R\x06status\x12\x1c\n" + + "\tparent_id\x18\x13 \x01(\x03R\tparent_id\x12 \n" + + "\vparent_path\x18\x14 \x01(\tR\vparent_path\x127\n" + + "\bchildren\x18\x15 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + + "\x06parent\x18\x16 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + + "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + + "\x05roles\x18\x18 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x80\x06\n" + "\x04Role\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\x05 \x01(\tR\x04name\x12 \n" + - "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x12\n" + - "\x04type\x18\a \x01(\x05R\x04type\x12\x1a\n" + - "\bsequence\x18\b \x01(\x05R\bsequence\x12\x16\n" + - "\x06status\x18\t \x01(\x05R\x06status\x12\x1a\n" + - "\bis_types\x18\n" + - " \x01(\bR\bis_types\x121\n" + - "\x05views\x18\x15 \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x121\n" + - "\x05users\x18\x16 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + - "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\"\n" + - "\fresource_ids\x18\x18 \x03(\x03R\fresource_ids\x12C\n" + - "\vpermissions\x18\x19 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12&\n" + - "\x0epermission_ids\x18\x1a \x03(\x03R\x0epermission_ids\"\xf3\x01\n" + - "\tRoleEdges\x121\n" + - "\x05views\x18\x01 \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x121\n" + - "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12?\n" + - "\n" + - "role_views\x18\x03 \x03(\v2\x1f.api.v1.services.types.RoleViewR\n" + - "role_views\x12?\n" + - "\n" + - "user_roles\x18\x04 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + - "user_roles\"\xec\x06\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + + "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + + "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x18\n" + + "\akeyword\x18\x06 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\a \x01(\tR\x04name\x12 \n" + + "\vdescription\x18\b \x01(\tR\vdescription\x12\x12\n" + + "\x04type\x18\t \x01(\x05R\x04type\x12\x1a\n" + + "\bsequence\x18\n" + + " \x01(\x05R\bsequence\x12\x16\n" + + "\x06status\x18\v \x01(\x05R\x06status\x12\x1a\n" + + "\bis_types\x18\f \x01(\bR\bis_types\x121\n" + + "\x05views\x18\x15 \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x12\x1a\n" + + "\bview_ids\x18\x14 \x03(\x03R\bview_ids\x121\n" + + "\x05users\x18\x16 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12\x1a\n" + + "\buser_ids\x18\x17 \x03(\x03R\buser_ids\x12=\n" + + "\tresources\x18\x18 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\"\n" + + "\fresource_ids\x18\x19 \x03(\x03R\fresource_ids\x12C\n" + + "\vpermissions\x18\x1a \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12&\n" + + "\x0epermission_ids\x18\x1b \x03(\x03R\x0epermission_ids\"\x80\a\n" + "\x04User\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + - "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + - "\rupdate_author\x18\x03 \x01(\x03R\rupdate_author\x12<\n" + - "\vcreate_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + + "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + + "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x12\n" + "\x04uuid\x18\x06 \x01(\tR\x04uuid\x12\x1e\n" + "\n" + "allowed_ip\x18\a \x01(\tR\n" + @@ -2898,22 +2074,18 @@ const file_types_system_proto_rawDesc = "" + "\x05email\x18\x0e \x01(\tR\x05email\x12\x16\n" + "\x06remark\x18\x0f \x01(\tR\x06remark\x12\x14\n" + "\x05token\x18\x10 \x01(\tR\x05token\x12\x16\n" + - "\x06status\x18\x11 \x01(\x05R\x06status\x12$\n" + - "\rlast_login_ip\x18\x12 \x01(\tR\rlast_login_ip\x12\x1a\n" + - "\blogin_ip\x18\x13 \x01(\tR\blogin_ip\x12D\n" + - "\x0flast_login_time\x18\x14 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12:\n" + + "\x06status\x18\x11 \x01(\x05R\x06status\x12\x12\n" + + "\x04i18n\x18\x12 \x01(\tR\x04i18n\x12$\n" + + "\rlast_login_ip\x18\x13 \x01(\tR\rlast_login_ip\x12\x1a\n" + + "\blogin_ip\x18\x14 \x01(\tR\blogin_ip\x12D\n" + + "\x0flast_login_time\x18\x15 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12:\n" + "\n" + - "login_time\x18\x15 \x01(\v2\x1a.google.protobuf.TimestampR\n" + + "login_time\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampR\n" + "login_time\x12E\n" + - "\rsanction_date\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x121\n" + - "\x05roles\x18\x17 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + - "\brole_ids\x18\x18 \x03(\x03R\brole_idsB\x10\n" + - "\x0e_sanction_date\"\x7f\n" + - "\tUserEdges\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12?\n" + - "\n" + - "user_roles\x18\x02 \x03(\v2\x1f.api.v1.services.types.UserRoleR\n" + - "user_roles\"\xca\x02\n" + + "\rsanction_date\x18\x17 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x121\n" + + "\x05roles\x18\x18 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + + "\brole_ids\x18\x19 \x03(\x03R\brole_idsB\x10\n" + + "\x0e_sanction_date\"\xca\x02\n" + "\bUserRole\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + @@ -2922,10 +2094,7 @@ const file_types_system_proto_rawDesc = "" + "\arole_id\x18\x05 \x01(\x03R\arole_id\x12\x1c\n" + "\trole_name\x18\x06 \x01(\tR\trole_name\x12/\n" + "\x04user\x18\x15 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + - "\x04role\x18\x16 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"q\n" + - "\rUserRoleEdges\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + - "\x04role\x18\x02 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\xac\x02\n" + + "\x04role\x18\x16 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\xac\x02\n" + "\bRoleView\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + @@ -2933,27 +2102,22 @@ const file_types_system_proto_rawDesc = "" + "\arole_id\x18\x04 \x01(\x03R\arole_id\x12\x18\n" + "\aview_id\x18\x05 \x01(\x03R\aview_id\x12/\n" + "\x04role\x18\x15 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + - "\x04view\x18\x16 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"q\n" + - "\rRoleViewEdges\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + - "\x04view\x18\x02 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\x8f\a\n" + + "\x04view\x18\x16 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\x97\a\n" + "\bResource\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x1a\n" + - "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12\x12\n" + - "\x04type\x18\a \x01(\tR\x04type\x12\x16\n" + - "\x06status\x18\b \x01(\x05R\x06status\x12\x12\n" + - "\x04path\x18\t \x01(\tR\x04path\x12\x1c\n" + - "\toperation\x18\n" + - " \x01(\tR\toperation\x12\x16\n" + - "\x06method\x18\v \x01(\tR\x06method\x12\x1c\n" + - "\tcomponent\x18\f \x01(\tR\tcomponent\x12\x12\n" + - "\x04icon\x18\r \x01(\tR\x04icon\x12\x1a\n" + - "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x18\n" + - "\avisible\x18\x0f \x01(\bR\avisible\x12\x1c\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + + "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + + "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x12\n" + + "\x04name\x18\x06 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\a \x01(\tR\akeyword\x12\x12\n" + + "\x04type\x18\t \x01(\tR\x04type\x12\x16\n" + + "\x06status\x18\n" + + " \x01(\x05R\x06status\x12\x12\n" + + "\x04path\x18\v \x01(\tR\x04path\x12\x1c\n" + + "\toperation\x18\f \x01(\tR\toperation\x12\x16\n" + + "\x06method\x18\r \x01(\tR\x06method\x12\x1a\n" + + "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x1c\n" + "\ttree_path\x18\x10 \x01(\tR\ttree_path\x12O\n" + "\n" + "properties\x18\x11 \x03(\v2/.api.v1.services.types.Resource.PropertiesEntryR\n" + @@ -2963,125 +2127,85 @@ const file_types_system_proto_rawDesc = "" + "\bchildren\x18\x15 \x03(\v2\x1f.api.v1.services.types.ResourceR\bchildren\x127\n" + "\x06parent\x18\x16 \x01(\v2\x1f.api.v1.services.types.ResourceR\x06parent\x12&\n" + "\x0epermission_ids\x18\x17 \x03(\x03R\x0epermission_ids\x12C\n" + - "\vpermissions\x18\x18 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x1a=\n" + + "\vpermissions\x18\x18 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12\"\n" + + "\fservice_name\x18\x19 \x01(\tR\fservice_name\x1a=\n" + "\x0fPropertiesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"@\n" + - "\rResourceEdges\x12/\n" + - "\x04view\x18\x01 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\xe8\x03\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xb4\x04\n" + "\n" + "Department\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + - "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\x05 \x01(\tR\x04name\x12\x1c\n" + - "\ttree_path\x18\x06 \x01(\tR\ttree_path\x12\x1a\n" + - "\bsequence\x18\a \x01(\x05R\bsequence\x12\x16\n" + - "\x06status\x18\b \x01(\x05R\x06status\x12\x14\n" + - "\x05level\x18\t \x01(\x05R\x05level\x12 \n" + - "\vdescription\x18\n" + - " \x01(\tR\vdescription\x12\x1c\n" + - "\tparent_id\x18\v \x01(\x03R\tparent_id\x12=\n" + - "\bchildren\x18\f \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + - "\x06parent\x18\r \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\"\xd0\x02\n" + - "\x0fDepartmentEdges\x121\n" + - "\x05users\x18\x01 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + - "\tpositions\x18\x02 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12=\n" + - "\bchildren\x18\x03 \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + - "\x06parent\x18\x04 \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\x12Q\n" + - "\x10user_departments\x18\x05 \x03(\v2%.api.v1.services.types.UserDepartmentR\x10user_departments\"\xa2\x01\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + + "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + + "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x18\n" + + "\akeyword\x18\x06 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\a \x01(\tR\x04name\x12\x1c\n" + + "\ttree_path\x18\b \x01(\tR\ttree_path\x12\x1a\n" + + "\bsequence\x18\t \x01(\x05R\bsequence\x12\x16\n" + + "\x06status\x18\n" + + " \x01(\x05R\x06status\x12\x14\n" + + "\x05level\x18\v \x01(\x05R\x05level\x12 \n" + + "\vdescription\x18\f \x01(\tR\vdescription\x12\x1c\n" + + "\tparent_id\x18\r \x01(\x03R\tparent_id\x12=\n" + + "\bchildren\x18\x0e \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + + "\x06parent\x18\x0f \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\"`\n" + "\x0eUserDepartment\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\auser_id\x18\x02 \x01(\x03R\auser_id\x12$\n" + - "\rdepartment_id\x18\x03 \x01(\x03R\rdepartment_id\x12@\n" + - "\x05edges\x18\x04 \x01(\v2*.api.v1.services.types.UserDepartmentEdgesR\x05edges\"\x89\x01\n" + - "\x13UserDepartmentEdges\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12A\n" + - "\n" + - "department\x18\x02 \x01(\v2!.api.v1.services.types.DepartmentR\n" + - "department\"\x8c\x02\n" + + "\rdepartment_id\x18\x03 \x01(\x03R\rdepartment_id\"\xd8\x02\n" + "\bPosition\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + - "\vdescription\x18\x06 \x01(\tR\vdescription\x12$\n" + - "\rdepartment_id\x18\a \x01(\x03R\rdepartment_id\"\xf6\x02\n" + - "\rPositionEdges\x12A\n" + - "\n" + - "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + - "department\x121\n" + - "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12C\n" + - "\vpermissions\x18\x03 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12K\n" + - "\x0euser_positions\x18\x04 \x03(\v2#.api.v1.services.types.UserPositionR\x0euser_positions\x12]\n" + - "\x14position_permissions\x18\x05 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"\xe2\x04\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + + "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + + "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x12\n" + + "\x04name\x18\x06 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\a \x01(\tR\akeyword\x12 \n" + + "\vdescription\x18\b \x01(\tR\vdescription\x12$\n" + + "\rdepartment_id\x18\t \x01(\x03R\rdepartment_id\"\xae\x05\n" + "\n" + "Permission\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x16\n" + - "\x06status\x18\x06 \x01(\x05R\x06status\x12 \n" + - "\vdescription\x18\a \x01(\tR\vdescription\x12\x1e\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + + "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + + "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x12\n" + + "\x04name\x18\x06 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\a \x01(\tR\akeyword\x12\x16\n" + + "\x06status\x18\b \x01(\x05R\x06status\x12 \n" + + "\vdescription\x18\t \x01(\tR\vdescription\x12\x1e\n" + "\n" + - "data_scope\x18\b \x01(\tR\n" + + "data_scope\x18\n" + + " \x01(\tR\n" + "data_scope\x12P\n" + "\n" + - "data_rules\x18\t \x03(\v20.api.v1.services.types.Permission.DataRulesEntryR\n" + + "data_rules\x18\v \x03(\v20.api.v1.services.types.Permission.DataRulesEntryR\n" + "data_rules\x12\"\n" + - "\fresource_ids\x18\n" + - " \x03(\x03R\fresource_ids\x12=\n" + - "\tresources\x18\v \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x1a\n" + - "\bview_ids\x18\f \x03(\x03R\bview_ids\x121\n" + - "\x05views\x18\r \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x1a<\n" + + "\fresource_ids\x18\f \x03(\x03R\fresource_ids\x12=\n" + + "\tresources\x18\r \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x1a\n" + + "\bview_ids\x18\x0e \x03(\x03R\bview_ids\x121\n" + + "\x05views\x18\x0f \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x1a<\n" + "\x0eDataRulesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xd3\x03\n" + - "\x0fPermissionEdges\x121\n" + - "\x05roles\x18\x01 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12=\n" + - "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12=\n" + - "\tpositions\x18\x03 \x03(\v2\x1f.api.v1.services.types.PositionR\tpositions\x12Q\n" + - "\x10role_permissions\x18\x04 \x03(\v2%.api.v1.services.types.RolePermissionR\x10role_permissions\x12]\n" + - "\x14permission_resources\x18\x05 \x03(\v2).api.v1.services.types.PermissionResourceR\x14permission_resources\x12]\n" + - "\x14position_permissions\x18\x06 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"Z\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"Z\n" + "\fUserPosition\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\auser_id\x18\x02 \x01(\x03R\auser_id\x12 \n" + - "\vposition_id\x18\x03 \x01(\x03R\vposition_id\"\x81\x01\n" + - "\x11UserPositionEdges\x12/\n" + - "\x04user\x18\x01 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12;\n" + - "\bposition\x18\x02 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\"l\n" + + "\vposition_id\x18\x03 \x01(\x03R\vposition_id\"l\n" + "\x12PositionPermission\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12 \n" + "\vposition_id\x18\x02 \x01(\x03R\vposition_id\x12$\n" + - "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x99\x01\n" + - "\x17PositionPermissionEdges\x12;\n" + - "\bposition\x18\x01 \x01(\v2\x1f.api.v1.services.types.PositionR\bposition\x12A\n" + - "\n" + - "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\"`\n" + + "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"`\n" + "\x0eRolePermission\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\arole_id\x18\x02 \x01(\x03R\arole_id\x12$\n" + - "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x89\x01\n" + - "\x13RolePermissionEdges\x12/\n" + - "\x04role\x18\x01 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12A\n" + - "\n" + - "permission\x18\x02 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\"\x86\x01\n" + + "\rpermission_id\x18\x03 \x01(\x03R\rpermission_id\"\x86\x01\n" + "\x12PermissionResource\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + "\rpermission_id\x18\x02 \x01(\x03R\rpermission_id\x12 \n" + "\vresource_id\x18\x03 \x01(\x03R\vresource_id\x12\x18\n" + - "\aactions\x18\x04 \x01(\tR\aactions\"\x99\x01\n" + - "\x17PermissionResourceEdges\x12A\n" + - "\n" + - "permission\x18\x01 \x01(\v2!.api.v1.services.types.PermissionR\n" + - "permission\x12;\n" + - "\bresource\x18\x02 \x01(\v2\x1f.api.v1.services.types.ResourceR\bresourceB\xd9\x01\n" + + "\aactions\x18\x04 \x01(\tR\aactionsB\xd9\x01\n" + "\x19com.api.v1.services.typesB\vSystemProtoP\x01Z7origadmin/application/admin/api/v1/services/types;types\xa2\x02\x04AVST\xaa\x02\x15Api.V1.Services.Types\xca\x02\x15Api\\V1\\Services\\Types\xe2\x02!Api\\V1\\Services\\Types\\GPBMetadata\xea\x02\x18Api::V1::Services::Typesb\x06proto3" var ( @@ -3096,132 +2220,75 @@ func file_types_system_proto_rawDescGZIP() []byte { return file_types_system_proto_rawDescData } -var file_types_system_proto_msgTypes = make([]protoimpl.MessageInfo, 30) +var file_types_system_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_types_system_proto_goTypes = []any{ - (*View)(nil), // 0: api.v1.services.types.View - (*ViewEdges)(nil), // 1: api.v1.services.types.ViewEdges - (*Role)(nil), // 2: api.v1.services.types.Role - (*RoleEdges)(nil), // 3: api.v1.services.types.RoleEdges - (*User)(nil), // 4: api.v1.services.types.User - (*UserEdges)(nil), // 5: api.v1.services.types.UserEdges - (*UserRole)(nil), // 6: api.v1.services.types.UserRole - (*UserRoleEdges)(nil), // 7: api.v1.services.types.UserRoleEdges - (*RoleView)(nil), // 8: api.v1.services.types.RoleView - (*RoleViewEdges)(nil), // 9: api.v1.services.types.RoleViewEdges - (*Resource)(nil), // 10: api.v1.services.types.Resource - (*ResourceEdges)(nil), // 11: api.v1.services.types.ResourceEdges - (*Department)(nil), // 12: api.v1.services.types.Department - (*DepartmentEdges)(nil), // 13: api.v1.services.types.DepartmentEdges - (*UserDepartment)(nil), // 14: api.v1.services.types.UserDepartment - (*UserDepartmentEdges)(nil), // 15: api.v1.services.types.UserDepartmentEdges - (*Position)(nil), // 16: api.v1.services.types.Position - (*PositionEdges)(nil), // 17: api.v1.services.types.PositionEdges - (*Permission)(nil), // 18: api.v1.services.types.Permission - (*PermissionEdges)(nil), // 19: api.v1.services.types.PermissionEdges - (*UserPosition)(nil), // 20: api.v1.services.types.UserPosition - (*UserPositionEdges)(nil), // 21: api.v1.services.types.UserPositionEdges - (*PositionPermission)(nil), // 22: api.v1.services.types.PositionPermission - (*PositionPermissionEdges)(nil), // 23: api.v1.services.types.PositionPermissionEdges - (*RolePermission)(nil), // 24: api.v1.services.types.RolePermission - (*RolePermissionEdges)(nil), // 25: api.v1.services.types.RolePermissionEdges - (*PermissionResource)(nil), // 26: api.v1.services.types.PermissionResource - (*PermissionResourceEdges)(nil), // 27: api.v1.services.types.PermissionResourceEdges - nil, // 28: api.v1.services.types.Resource.PropertiesEntry - nil, // 29: api.v1.services.types.Permission.DataRulesEntry - (*timestamppb.Timestamp)(nil), // 30: google.protobuf.Timestamp + (*View)(nil), // 0: api.v1.services.types.View + (*Role)(nil), // 1: api.v1.services.types.Role + (*User)(nil), // 2: api.v1.services.types.User + (*UserRole)(nil), // 3: api.v1.services.types.UserRole + (*RoleView)(nil), // 4: api.v1.services.types.RoleView + (*Resource)(nil), // 5: api.v1.services.types.Resource + (*Department)(nil), // 6: api.v1.services.types.Department + (*UserDepartment)(nil), // 7: api.v1.services.types.UserDepartment + (*Position)(nil), // 8: api.v1.services.types.Position + (*Permission)(nil), // 9: api.v1.services.types.Permission + (*UserPosition)(nil), // 10: api.v1.services.types.UserPosition + (*PositionPermission)(nil), // 11: api.v1.services.types.PositionPermission + (*RolePermission)(nil), // 12: api.v1.services.types.RolePermission + (*PermissionResource)(nil), // 13: api.v1.services.types.PermissionResource + nil, // 14: api.v1.services.types.Resource.PropertiesEntry + nil, // 15: api.v1.services.types.Permission.DataRulesEntry + (*timestamppb.Timestamp)(nil), // 16: google.protobuf.Timestamp } var file_types_system_proto_depIdxs = []int32{ - 30, // 0: api.v1.services.types.View.create_time:type_name -> google.protobuf.Timestamp - 30, // 1: api.v1.services.types.View.update_time:type_name -> google.protobuf.Timestamp + 16, // 0: api.v1.services.types.View.create_time:type_name -> google.protobuf.Timestamp + 16, // 1: api.v1.services.types.View.update_time:type_name -> google.protobuf.Timestamp 0, // 2: api.v1.services.types.View.children:type_name -> api.v1.services.types.View 0, // 3: api.v1.services.types.View.parent:type_name -> api.v1.services.types.View - 10, // 4: api.v1.services.types.View.resources:type_name -> api.v1.services.types.Resource - 2, // 5: api.v1.services.types.View.roles:type_name -> api.v1.services.types.Role - 0, // 6: api.v1.services.types.ViewEdges.children:type_name -> api.v1.services.types.View - 0, // 7: api.v1.services.types.ViewEdges.parent:type_name -> api.v1.services.types.View - 10, // 8: api.v1.services.types.ViewEdges.resources:type_name -> api.v1.services.types.Resource - 2, // 9: api.v1.services.types.ViewEdges.roles:type_name -> api.v1.services.types.Role - 8, // 10: api.v1.services.types.ViewEdges.role_views:type_name -> api.v1.services.types.RoleView - 30, // 11: api.v1.services.types.Role.create_time:type_name -> google.protobuf.Timestamp - 30, // 12: api.v1.services.types.Role.update_time:type_name -> google.protobuf.Timestamp - 0, // 13: api.v1.services.types.Role.views:type_name -> api.v1.services.types.View - 4, // 14: api.v1.services.types.Role.users:type_name -> api.v1.services.types.User - 10, // 15: api.v1.services.types.Role.resources:type_name -> api.v1.services.types.Resource - 18, // 16: api.v1.services.types.Role.permissions:type_name -> api.v1.services.types.Permission - 0, // 17: api.v1.services.types.RoleEdges.views:type_name -> api.v1.services.types.View - 4, // 18: api.v1.services.types.RoleEdges.users:type_name -> api.v1.services.types.User - 8, // 19: api.v1.services.types.RoleEdges.role_views:type_name -> api.v1.services.types.RoleView - 6, // 20: api.v1.services.types.RoleEdges.user_roles:type_name -> api.v1.services.types.UserRole - 30, // 21: api.v1.services.types.User.create_time:type_name -> google.protobuf.Timestamp - 30, // 22: api.v1.services.types.User.update_time:type_name -> google.protobuf.Timestamp - 30, // 23: api.v1.services.types.User.last_login_time:type_name -> google.protobuf.Timestamp - 30, // 24: api.v1.services.types.User.login_time:type_name -> google.protobuf.Timestamp - 30, // 25: api.v1.services.types.User.sanction_date:type_name -> google.protobuf.Timestamp - 2, // 26: api.v1.services.types.User.roles:type_name -> api.v1.services.types.Role - 2, // 27: api.v1.services.types.UserEdges.roles:type_name -> api.v1.services.types.Role - 6, // 28: api.v1.services.types.UserEdges.user_roles:type_name -> api.v1.services.types.UserRole - 30, // 29: api.v1.services.types.UserRole.create_time:type_name -> google.protobuf.Timestamp - 30, // 30: api.v1.services.types.UserRole.update_time:type_name -> google.protobuf.Timestamp - 4, // 31: api.v1.services.types.UserRole.user:type_name -> api.v1.services.types.User - 2, // 32: api.v1.services.types.UserRole.role:type_name -> api.v1.services.types.Role - 4, // 33: api.v1.services.types.UserRoleEdges.user:type_name -> api.v1.services.types.User - 2, // 34: api.v1.services.types.UserRoleEdges.role:type_name -> api.v1.services.types.Role - 30, // 35: api.v1.services.types.RoleView.create_time:type_name -> google.protobuf.Timestamp - 30, // 36: api.v1.services.types.RoleView.update_time:type_name -> google.protobuf.Timestamp - 2, // 37: api.v1.services.types.RoleView.role:type_name -> api.v1.services.types.Role - 0, // 38: api.v1.services.types.RoleView.view:type_name -> api.v1.services.types.View - 2, // 39: api.v1.services.types.RoleViewEdges.role:type_name -> api.v1.services.types.Role - 0, // 40: api.v1.services.types.RoleViewEdges.view:type_name -> api.v1.services.types.View - 30, // 41: api.v1.services.types.Resource.create_time:type_name -> google.protobuf.Timestamp - 30, // 42: api.v1.services.types.Resource.update_time:type_name -> google.protobuf.Timestamp - 28, // 43: api.v1.services.types.Resource.properties:type_name -> api.v1.services.types.Resource.PropertiesEntry - 10, // 44: api.v1.services.types.Resource.children:type_name -> api.v1.services.types.Resource - 10, // 45: api.v1.services.types.Resource.parent:type_name -> api.v1.services.types.Resource - 18, // 46: api.v1.services.types.Resource.permissions:type_name -> api.v1.services.types.Permission - 0, // 47: api.v1.services.types.ResourceEdges.view:type_name -> api.v1.services.types.View - 30, // 48: api.v1.services.types.Department.create_time:type_name -> google.protobuf.Timestamp - 30, // 49: api.v1.services.types.Department.update_time:type_name -> google.protobuf.Timestamp - 12, // 50: api.v1.services.types.Department.children:type_name -> api.v1.services.types.Department - 12, // 51: api.v1.services.types.Department.parent:type_name -> api.v1.services.types.Department - 4, // 52: api.v1.services.types.DepartmentEdges.users:type_name -> api.v1.services.types.User - 16, // 53: api.v1.services.types.DepartmentEdges.positions:type_name -> api.v1.services.types.Position - 12, // 54: api.v1.services.types.DepartmentEdges.children:type_name -> api.v1.services.types.Department - 12, // 55: api.v1.services.types.DepartmentEdges.parent:type_name -> api.v1.services.types.Department - 14, // 56: api.v1.services.types.DepartmentEdges.user_departments:type_name -> api.v1.services.types.UserDepartment - 15, // 57: api.v1.services.types.UserDepartment.edges:type_name -> api.v1.services.types.UserDepartmentEdges - 4, // 58: api.v1.services.types.UserDepartmentEdges.user:type_name -> api.v1.services.types.User - 12, // 59: api.v1.services.types.UserDepartmentEdges.department:type_name -> api.v1.services.types.Department - 30, // 60: api.v1.services.types.Position.create_time:type_name -> google.protobuf.Timestamp - 30, // 61: api.v1.services.types.Position.update_time:type_name -> google.protobuf.Timestamp - 12, // 62: api.v1.services.types.PositionEdges.department:type_name -> api.v1.services.types.Department - 4, // 63: api.v1.services.types.PositionEdges.users:type_name -> api.v1.services.types.User - 18, // 64: api.v1.services.types.PositionEdges.permissions:type_name -> api.v1.services.types.Permission - 20, // 65: api.v1.services.types.PositionEdges.user_positions:type_name -> api.v1.services.types.UserPosition - 22, // 66: api.v1.services.types.PositionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission - 30, // 67: api.v1.services.types.Permission.create_time:type_name -> google.protobuf.Timestamp - 30, // 68: api.v1.services.types.Permission.update_time:type_name -> google.protobuf.Timestamp - 29, // 69: api.v1.services.types.Permission.data_rules:type_name -> api.v1.services.types.Permission.DataRulesEntry - 10, // 70: api.v1.services.types.Permission.resources:type_name -> api.v1.services.types.Resource - 0, // 71: api.v1.services.types.Permission.views:type_name -> api.v1.services.types.View - 2, // 72: api.v1.services.types.PermissionEdges.roles:type_name -> api.v1.services.types.Role - 10, // 73: api.v1.services.types.PermissionEdges.resources:type_name -> api.v1.services.types.Resource - 16, // 74: api.v1.services.types.PermissionEdges.positions:type_name -> api.v1.services.types.Position - 24, // 75: api.v1.services.types.PermissionEdges.role_permissions:type_name -> api.v1.services.types.RolePermission - 26, // 76: api.v1.services.types.PermissionEdges.permission_resources:type_name -> api.v1.services.types.PermissionResource - 22, // 77: api.v1.services.types.PermissionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission - 4, // 78: api.v1.services.types.UserPositionEdges.user:type_name -> api.v1.services.types.User - 16, // 79: api.v1.services.types.UserPositionEdges.position:type_name -> api.v1.services.types.Position - 16, // 80: api.v1.services.types.PositionPermissionEdges.position:type_name -> api.v1.services.types.Position - 18, // 81: api.v1.services.types.PositionPermissionEdges.permission:type_name -> api.v1.services.types.Permission - 2, // 82: api.v1.services.types.RolePermissionEdges.role:type_name -> api.v1.services.types.Role - 18, // 83: api.v1.services.types.RolePermissionEdges.permission:type_name -> api.v1.services.types.Permission - 18, // 84: api.v1.services.types.PermissionResourceEdges.permission:type_name -> api.v1.services.types.Permission - 10, // 85: api.v1.services.types.PermissionResourceEdges.resource:type_name -> api.v1.services.types.Resource - 86, // [86:86] is the sub-list for method output_type - 86, // [86:86] is the sub-list for method input_type - 86, // [86:86] is the sub-list for extension type_name - 86, // [86:86] is the sub-list for extension extendee - 0, // [0:86] is the sub-list for field type_name + 5, // 4: api.v1.services.types.View.resources:type_name -> api.v1.services.types.Resource + 1, // 5: api.v1.services.types.View.roles:type_name -> api.v1.services.types.Role + 16, // 6: api.v1.services.types.Role.create_time:type_name -> google.protobuf.Timestamp + 16, // 7: api.v1.services.types.Role.update_time:type_name -> google.protobuf.Timestamp + 0, // 8: api.v1.services.types.Role.views:type_name -> api.v1.services.types.View + 2, // 9: api.v1.services.types.Role.users:type_name -> api.v1.services.types.User + 5, // 10: api.v1.services.types.Role.resources:type_name -> api.v1.services.types.Resource + 9, // 11: api.v1.services.types.Role.permissions:type_name -> api.v1.services.types.Permission + 16, // 12: api.v1.services.types.User.create_time:type_name -> google.protobuf.Timestamp + 16, // 13: api.v1.services.types.User.update_time:type_name -> google.protobuf.Timestamp + 16, // 14: api.v1.services.types.User.last_login_time:type_name -> google.protobuf.Timestamp + 16, // 15: api.v1.services.types.User.login_time:type_name -> google.protobuf.Timestamp + 16, // 16: api.v1.services.types.User.sanction_date:type_name -> google.protobuf.Timestamp + 1, // 17: api.v1.services.types.User.roles:type_name -> api.v1.services.types.Role + 16, // 18: api.v1.services.types.UserRole.create_time:type_name -> google.protobuf.Timestamp + 16, // 19: api.v1.services.types.UserRole.update_time:type_name -> google.protobuf.Timestamp + 2, // 20: api.v1.services.types.UserRole.user:type_name -> api.v1.services.types.User + 1, // 21: api.v1.services.types.UserRole.role:type_name -> api.v1.services.types.Role + 16, // 22: api.v1.services.types.RoleView.create_time:type_name -> google.protobuf.Timestamp + 16, // 23: api.v1.services.types.RoleView.update_time:type_name -> google.protobuf.Timestamp + 1, // 24: api.v1.services.types.RoleView.role:type_name -> api.v1.services.types.Role + 0, // 25: api.v1.services.types.RoleView.view:type_name -> api.v1.services.types.View + 16, // 26: api.v1.services.types.Resource.create_time:type_name -> google.protobuf.Timestamp + 16, // 27: api.v1.services.types.Resource.update_time:type_name -> google.protobuf.Timestamp + 14, // 28: api.v1.services.types.Resource.properties:type_name -> api.v1.services.types.Resource.PropertiesEntry + 5, // 29: api.v1.services.types.Resource.children:type_name -> api.v1.services.types.Resource + 5, // 30: api.v1.services.types.Resource.parent:type_name -> api.v1.services.types.Resource + 9, // 31: api.v1.services.types.Resource.permissions:type_name -> api.v1.services.types.Permission + 16, // 32: api.v1.services.types.Department.create_time:type_name -> google.protobuf.Timestamp + 16, // 33: api.v1.services.types.Department.update_time:type_name -> google.protobuf.Timestamp + 6, // 34: api.v1.services.types.Department.children:type_name -> api.v1.services.types.Department + 6, // 35: api.v1.services.types.Department.parent:type_name -> api.v1.services.types.Department + 16, // 36: api.v1.services.types.Position.create_time:type_name -> google.protobuf.Timestamp + 16, // 37: api.v1.services.types.Position.update_time:type_name -> google.protobuf.Timestamp + 16, // 38: api.v1.services.types.Permission.create_time:type_name -> google.protobuf.Timestamp + 16, // 39: api.v1.services.types.Permission.update_time:type_name -> google.protobuf.Timestamp + 15, // 40: api.v1.services.types.Permission.data_rules:type_name -> api.v1.services.types.Permission.DataRulesEntry + 5, // 41: api.v1.services.types.Permission.resources:type_name -> api.v1.services.types.Resource + 0, // 42: api.v1.services.types.Permission.views:type_name -> api.v1.services.types.View + 43, // [43:43] is the sub-list for method output_type + 43, // [43:43] is the sub-list for method input_type + 43, // [43:43] is the sub-list for extension type_name + 43, // [43:43] is the sub-list for extension extendee + 0, // [0:43] is the sub-list for field type_name } func init() { file_types_system_proto_init() } @@ -3229,14 +2296,14 @@ func file_types_system_proto_init() { if File_types_system_proto != nil { return } - file_types_system_proto_msgTypes[4].OneofWrappers = []any{} + file_types_system_proto_msgTypes[2].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_system_proto_rawDesc), len(file_types_system_proto_rawDesc)), NumEnums: 0, - NumMessages: 30, + NumMessages: 16, NumExtensions: 0, NumServices: 0, }, diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index f2142666..9815c758 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -130,6 +130,8 @@ func (m *View) validate(all bool) error { // no validation rules for Type + // no validation rules for Component + // no validation rules for Comment // no validation rules for Icon @@ -356,270 +358,6 @@ var _ interface { ErrorName() string } = ViewValidationError{} -// Validate checks the field values on ViewEdges 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 *ViewEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ViewEdges 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 ViewEdgesMultiError, or nil -// if none found. -func (m *ViewEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *ViewEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ViewEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ViewEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ViewEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ViewEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ViewEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ViewEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ViewEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ViewEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ViewEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ViewEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ViewEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ViewEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoleViews() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ViewEdgesValidationError{ - field: fmt.Sprintf("RoleViews[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ViewEdgesValidationError{ - field: fmt.Sprintf("RoleViews[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ViewEdgesValidationError{ - field: fmt.Sprintf("RoleViews[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return ViewEdgesMultiError(errors) - } - - return nil -} - -// ViewEdgesMultiError is an error wrapping multiple validation errors returned -// by ViewEdges.ValidateAll() if the designated constraints aren't met. -type ViewEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ViewEdgesMultiError) 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 ViewEdgesMultiError) AllErrors() []error { return m } - -// ViewEdgesValidationError is the validation error returned by -// ViewEdges.Validate if the designated constraints aren't met. -type ViewEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ViewEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ViewEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ViewEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ViewEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ViewEdgesValidationError) ErrorName() string { return "ViewEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e ViewEdgesValidationError) 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 %sViewEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ViewEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ViewEdgesValidationError{} - // Validate checks the field values on Role 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. @@ -701,6 +439,10 @@ func (m *Role) validate(all bool) error { } } + // no validation rules for CreateAuthor + + // no validation rules for UpdateAuthor + // no validation rules for Keyword // no validation rules for Name @@ -928,267 +670,28 @@ var _ interface { ErrorName() string } = RoleValidationError{} -// Validate checks the field values on RoleEdges 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 *RoleEdges) Validate() error { +// Validate checks the field values on User 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 *User) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on RoleEdges 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 RoleEdgesMultiError, or nil -// if none found. -func (m *RoleEdges) ValidateAll() error { +// ValidateAll checks the field values on User 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 UserMultiError, or nil if none found. +func (m *User) ValidateAll() error { return m.validate(true) } -func (m *RoleEdges) validate(all bool) error { +func (m *User) validate(all bool) error { if m == nil { return nil } var errors []error - for idx, item := range m.GetViews() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Views[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Views[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("Views[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRoleViews() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("RoleViews[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("RoleViews[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("RoleViews[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUserRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return RoleEdgesMultiError(errors) - } - - return nil -} - -// RoleEdgesMultiError is an error wrapping multiple validation errors returned -// by RoleEdges.ValidateAll() if the designated constraints aren't met. -type RoleEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RoleEdgesMultiError) 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 RoleEdgesMultiError) AllErrors() []error { return m } - -// RoleEdgesValidationError is the validation error returned by -// RoleEdges.Validate if the designated constraints aren't met. -type RoleEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RoleEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RoleEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RoleEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RoleEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RoleEdgesValidationError) ErrorName() string { return "RoleEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e RoleEdgesValidationError) 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 %sRoleEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RoleEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RoleEdgesValidationError{} - -// Validate checks the field values on User 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 *User) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on User 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 UserMultiError, or nil if none found. -func (m *User) ValidateAll() error { - return m.validate(true) -} - -func (m *User) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for CreateAuthor - - // no validation rules for UpdateAuthor + // no validation rules for Id if all { switch v := interface{}(m.GetCreateTime()).(type) { @@ -1248,6 +751,10 @@ func (m *User) validate(all bool) error { } } + // no validation rules for CreateAuthor + + // no validation rules for UpdateAuthor + // no validation rules for Uuid // no validation rules for AllowedIp @@ -1272,6 +779,8 @@ func (m *User) validate(all bool) error { // no validation rules for Status + // no validation rules for I18N + // no validation rules for LastLoginIp // no validation rules for LoginIp @@ -1478,214 +987,47 @@ var _ interface { ErrorName() string } = UserValidationError{} -// Validate checks the field values on UserEdges with the rules defined in the +// Validate checks the field values on UserRole 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 *UserEdges) Validate() error { +func (m *UserRole) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on UserEdges with the rules defined in +// ValidateAll checks the field values on UserRole 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 UserEdgesMultiError, or nil +// result is a list of violation errors wrapped in UserRoleMultiError, or nil // if none found. -func (m *UserEdges) ValidateAll() error { +func (m *UserRole) ValidateAll() error { return m.validate(true) } -func (m *UserEdges) validate(all bool) error { +func (m *UserRole) validate(all bool) error { if m == nil { return nil } var errors []error - for idx, item := range m.GetRoles() { - _, _ = idx, item + // no validation rules for Id - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, UserRoleValidationError{ + field: "CreateTime", reason: "embedded message failed validation", cause: err, - } - } - } - - } - - for idx, item := range m.GetUserRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } + }) } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + case interface{ Validate() error }: if err := v.Validate(); err != nil { - return UserEdgesValidationError{ - field: fmt.Sprintf("UserRoles[%v]", idx), + errors = append(errors, UserRoleValidationError{ + field: "CreateTime", reason: "embedded message failed validation", cause: err, - } - } - } - - } - - if len(errors) > 0 { - return UserEdgesMultiError(errors) - } - - return nil -} - -// UserEdgesMultiError is an error wrapping multiple validation errors returned -// by UserEdges.ValidateAll() if the designated constraints aren't met. -type UserEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserEdgesMultiError) 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 UserEdgesMultiError) AllErrors() []error { return m } - -// UserEdgesValidationError is the validation error returned by -// UserEdges.Validate if the designated constraints aren't met. -type UserEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserEdgesValidationError) ErrorName() string { return "UserEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e UserEdgesValidationError) 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 %sUserEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserEdgesValidationError{} - -// Validate checks the field values on UserRole 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 *UserRole) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserRole 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 UserRoleMultiError, or nil -// if none found. -func (m *UserRole) ValidateAll() error { - return m.validate(true) -} - -func (m *UserRole) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) + }) } } } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { @@ -1868,164 +1210,6 @@ var _ interface { ErrorName() string } = UserRoleValidationError{} -// Validate checks the field values on UserRoleEdges 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 *UserRoleEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserRoleEdges 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 UserRoleEdgesMultiError, or -// nil if none found. -func (m *UserRoleEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserRoleEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserRoleEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserRoleEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserRoleEdgesMultiError(errors) - } - - return nil -} - -// UserRoleEdgesMultiError is an error wrapping multiple validation errors -// returned by UserRoleEdges.ValidateAll() if the designated constraints -// aren't met. -type UserRoleEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserRoleEdgesMultiError) 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 UserRoleEdgesMultiError) AllErrors() []error { return m } - -// UserRoleEdgesValidationError is the validation error returned by -// UserRoleEdges.Validate if the designated constraints aren't met. -type UserRoleEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserRoleEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserRoleEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserRoleEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserRoleEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserRoleEdgesValidationError) ErrorName() string { return "UserRoleEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e UserRoleEdgesValidationError) 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 %sUserRoleEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserRoleEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserRoleEdgesValidationError{} - // Validate checks the field values on RoleView 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. @@ -2247,208 +1431,50 @@ var _ interface { ErrorName() string } = RoleViewValidationError{} -// Validate checks the field values on RoleViewEdges with the rules defined in -// the proto definition for this message. If any rules are violated, the first +// Validate checks the field values on Resource 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 *RoleViewEdges) Validate() error { +func (m *Resource) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on RoleViewEdges 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 RoleViewEdgesMultiError, or -// nil if none found. -func (m *RoleViewEdges) ValidateAll() error { +// ValidateAll checks the field values on Resource 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 ResourceMultiError, or nil +// if none found. +func (m *Resource) ValidateAll() error { return m.validate(true) } -func (m *RoleViewEdges) validate(all bool) error { +func (m *Resource) validate(all bool) error { if m == nil { return nil } var errors []error + // no validation rules for Id + if all { - switch v := interface{}(m.GetRole()).(type) { + switch v := interface{}(m.GetCreateTime()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleViewEdgesValidationError{ - field: "Role", + errors = append(errors, ResourceValidationError{ + field: "CreateTime", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, RoleViewEdgesValidationError{ - field: "Role", + errors = append(errors, ResourceValidationError{ + field: "CreateTime", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleViewEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetView()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RoleViewEdgesValidationError{ - field: "View", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RoleViewEdgesValidationError{ - field: "View", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetView()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RoleViewEdgesValidationError{ - field: "View", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return RoleViewEdgesMultiError(errors) - } - - return nil -} - -// RoleViewEdgesMultiError is an error wrapping multiple validation errors -// returned by RoleViewEdges.ValidateAll() if the designated constraints -// aren't met. -type RoleViewEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m RoleViewEdgesMultiError) 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 RoleViewEdgesMultiError) AllErrors() []error { return m } - -// RoleViewEdgesValidationError is the validation error returned by -// RoleViewEdges.Validate if the designated constraints aren't met. -type RoleViewEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e RoleViewEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e RoleViewEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e RoleViewEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e RoleViewEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e RoleViewEdgesValidationError) ErrorName() string { return "RoleViewEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e RoleViewEdgesValidationError) 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 %sRoleViewEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = RoleViewEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = RoleViewEdgesValidationError{} - -// Validate checks the field values on Resource 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 *Resource) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Resource 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 ResourceMultiError, or nil -// if none found. -func (m *Resource) ValidateAll() error { - return m.validate(true) -} - -func (m *Resource) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ResourceValidationError{ field: "CreateTime", @@ -2487,12 +1513,14 @@ func (m *Resource) validate(all bool) error { } } + // no validation rules for CreateAuthor + + // no validation rules for UpdateAuthor + // no validation rules for Name // no validation rules for Keyword - // no validation rules for I18NKey - // no validation rules for Type // no validation rules for Status @@ -2503,14 +1531,8 @@ func (m *Resource) validate(all bool) error { // no validation rules for Method - // no validation rules for Component - - // no validation rules for Icon - // no validation rules for Sequence - // no validation rules for Visible - // no validation rules for TreePath // no validation rules for Properties @@ -2616,6 +1638,8 @@ func (m *Resource) validate(all bool) error { } + // no validation rules for ServiceName + if len(errors) > 0 { return ResourceMultiError(errors) } @@ -2693,135 +1717,6 @@ var _ interface { ErrorName() string } = ResourceValidationError{} -// Validate checks the field values on ResourceEdges 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 *ResourceEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on ResourceEdges 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 ResourceEdgesMultiError, or -// nil if none found. -func (m *ResourceEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *ResourceEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetView()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, ResourceEdgesValidationError{ - field: "View", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, ResourceEdgesValidationError{ - field: "View", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetView()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return ResourceEdgesValidationError{ - field: "View", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return ResourceEdgesMultiError(errors) - } - - return nil -} - -// ResourceEdgesMultiError is an error wrapping multiple validation errors -// returned by ResourceEdges.ValidateAll() if the designated constraints -// aren't met. -type ResourceEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m ResourceEdgesMultiError) 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 ResourceEdgesMultiError) AllErrors() []error { return m } - -// ResourceEdgesValidationError is the validation error returned by -// ResourceEdges.Validate if the designated constraints aren't met. -type ResourceEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e ResourceEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e ResourceEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e ResourceEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e ResourceEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e ResourceEdgesValidationError) ErrorName() string { return "ResourceEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e ResourceEdgesValidationError) 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 %sResourceEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = ResourceEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = ResourceEdgesValidationError{} - // Validate checks the field values on Department 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. @@ -2904,9 +1799,13 @@ func (m *Department) validate(all bool) error { } } - // no validation rules for Keyword + // no validation rules for CreateAuthor - // no validation rules for Name + // no validation rules for UpdateAuthor + + // no validation rules for Keyword + + // no validation rules for Name // no validation rules for TreePath @@ -3060,207 +1959,48 @@ var _ interface { ErrorName() string } = DepartmentValidationError{} -// Validate checks the field values on DepartmentEdges 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 *DepartmentEdges) Validate() error { +// Validate checks the field values on UserDepartment 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 *UserDepartment) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on DepartmentEdges 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 -// DepartmentEdgesMultiError, or nil if none found. -func (m *DepartmentEdges) ValidateAll() error { +// ValidateAll checks the field values on UserDepartment 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 UserDepartmentMultiError, +// or nil if none found. +func (m *UserDepartment) ValidateAll() error { return m.validate(true) } -func (m *DepartmentEdges) validate(all bool) error { +func (m *UserDepartment) validate(all bool) error { if m == nil { return nil } var errors []error - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetChildren() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("Children[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if all { - switch v := interface{}(m.GetParent()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetParent()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: "Parent", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetUserDepartments() { - _, _ = idx, item + // no validation rules for Id - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("UserDepartments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, DepartmentEdgesValidationError{ - field: fmt.Sprintf("UserDepartments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return DepartmentEdgesValidationError{ - field: fmt.Sprintf("UserDepartments[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for UserId - } + // no validation rules for DepartmentId if len(errors) > 0 { - return DepartmentEdgesMultiError(errors) + return UserDepartmentMultiError(errors) } return nil } -// DepartmentEdgesMultiError is an error wrapping multiple validation errors -// returned by DepartmentEdges.ValidateAll() if the designated constraints +// UserDepartmentMultiError is an error wrapping multiple validation errors +// returned by UserDepartment.ValidateAll() if the designated constraints // aren't met. -type DepartmentEdgesMultiError []error +type UserDepartmentMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m DepartmentEdgesMultiError) Error() string { +func (m UserDepartmentMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -3269,11 +2009,11 @@ func (m DepartmentEdgesMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m DepartmentEdgesMultiError) AllErrors() []error { return m } +func (m UserDepartmentMultiError) AllErrors() []error { return m } -// DepartmentEdgesValidationError is the validation error returned by -// DepartmentEdges.Validate if the designated constraints aren't met. -type DepartmentEdgesValidationError struct { +// UserDepartmentValidationError is the validation error returned by +// UserDepartment.Validate if the designated constraints aren't met. +type UserDepartmentValidationError struct { field string reason string cause error @@ -3281,22 +2021,22 @@ type DepartmentEdgesValidationError struct { } // Field function returns field value. -func (e DepartmentEdgesValidationError) Field() string { return e.field } +func (e UserDepartmentValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e DepartmentEdgesValidationError) Reason() string { return e.reason } +func (e UserDepartmentValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e DepartmentEdgesValidationError) Cause() error { return e.cause } +func (e UserDepartmentValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e DepartmentEdgesValidationError) Key() bool { return e.key } +func (e UserDepartmentValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e DepartmentEdgesValidationError) ErrorName() string { return "DepartmentEdgesValidationError" } +func (e UserDepartmentValidationError) ErrorName() string { return "UserDepartmentValidationError" } // Error satisfies the builtin error interface -func (e DepartmentEdgesValidationError) Error() string { +func (e UserDepartmentValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -3308,14 +2048,14 @@ func (e DepartmentEdgesValidationError) Error() string { } return fmt.Sprintf( - "invalid %sDepartmentEdges.%s: %s%s", + "invalid %sUserDepartment.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = DepartmentEdgesValidationError{} +var _ error = UserDepartmentValidationError{} var _ interface { Field() string @@ -3323,24 +2063,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = DepartmentEdgesValidationError{} +} = UserDepartmentValidationError{} -// Validate checks the field values on UserDepartment with the rules defined in -// the proto definition for this message. If any rules are violated, the first +// Validate checks the field values on Position 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 *UserDepartment) Validate() error { +func (m *Position) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on UserDepartment 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 UserDepartmentMultiError, -// or nil if none found. -func (m *UserDepartment) ValidateAll() error { +// ValidateAll checks the field values on Position 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 PositionMultiError, or nil +// if none found. +func (m *Position) ValidateAll() error { return m.validate(true) } -func (m *UserDepartment) validate(all bool) error { +func (m *Position) validate(all bool) error { if m == nil { return nil } @@ -3349,1559 +2089,89 @@ func (m *UserDepartment) validate(all bool) error { // no validation rules for Id - // no validation rules for UserId - - // no validation rules for DepartmentId + if all { + switch v := interface{}(m.GetCreateTime()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionValidationError{ + field: "CreateTime", + reason: "embedded message failed validation", + cause: err, + } + } + } if all { - switch v := interface{}(m.GetEdges()).(type) { + switch v := interface{}(m.GetUpdateTime()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, UserDepartmentValidationError{ - field: "Edges", + errors = append(errors, PositionValidationError{ + field: "UpdateTime", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, UserDepartmentValidationError{ - field: "Edges", + errors = append(errors, PositionValidationError{ + field: "UpdateTime", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetEdges()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return UserDepartmentValidationError{ - field: "Edges", + return PositionValidationError{ + field: "UpdateTime", reason: "embedded message failed validation", cause: err, } } } + // no validation rules for CreateAuthor + + // no validation rules for UpdateAuthor + + // no validation rules for Name + + // no validation rules for Keyword + + // no validation rules for Description + + // no validation rules for DepartmentId + if len(errors) > 0 { - return UserDepartmentMultiError(errors) + return PositionMultiError(errors) } return nil } -// UserDepartmentMultiError is an error wrapping multiple validation errors -// returned by UserDepartment.ValidateAll() if the designated constraints -// aren't met. -type UserDepartmentMultiError []error +// PositionMultiError is an error wrapping multiple validation errors returned +// by Position.ValidateAll() if the designated constraints aren't met. +type PositionMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m UserDepartmentMultiError) 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 UserDepartmentMultiError) AllErrors() []error { return m } - -// UserDepartmentValidationError is the validation error returned by -// UserDepartment.Validate if the designated constraints aren't met. -type UserDepartmentValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserDepartmentValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserDepartmentValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserDepartmentValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserDepartmentValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserDepartmentValidationError) ErrorName() string { return "UserDepartmentValidationError" } - -// Error satisfies the builtin error interface -func (e UserDepartmentValidationError) 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 %sUserDepartment.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserDepartmentValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserDepartmentValidationError{} - -// Validate checks the field values on UserDepartmentEdges 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 *UserDepartmentEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserDepartmentEdges 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 -// UserDepartmentEdgesMultiError, or nil if none found. -func (m *UserDepartmentEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserDepartmentEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserDepartmentEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserDepartmentEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserDepartmentEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserDepartmentEdgesMultiError(errors) - } - - return nil -} - -// UserDepartmentEdgesMultiError is an error wrapping multiple validation -// errors returned by UserDepartmentEdges.ValidateAll() if the designated -// constraints aren't met. -type UserDepartmentEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserDepartmentEdgesMultiError) 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 UserDepartmentEdgesMultiError) AllErrors() []error { return m } - -// UserDepartmentEdgesValidationError is the validation error returned by -// UserDepartmentEdges.Validate if the designated constraints aren't met. -type UserDepartmentEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserDepartmentEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserDepartmentEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserDepartmentEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserDepartmentEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserDepartmentEdgesValidationError) ErrorName() string { - return "UserDepartmentEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e UserDepartmentEdgesValidationError) 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 %sUserDepartmentEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserDepartmentEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserDepartmentEdgesValidationError{} - -// Validate checks the field values on Position 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 *Position) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Position 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 PositionMultiError, or nil -// if none found. -func (m *Position) ValidateAll() error { - return m.validate(true) -} - -func (m *Position) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Name - - // no validation rules for Keyword - - // no validation rules for Description - - // no validation rules for DepartmentId - - if len(errors) > 0 { - return PositionMultiError(errors) - } - - return nil -} - -// PositionMultiError is an error wrapping multiple validation errors returned -// by Position.ValidateAll() if the designated constraints aren't met. -type PositionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionMultiError) 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 PositionMultiError) AllErrors() []error { return m } - -// PositionValidationError is the validation error returned by -// Position.Validate if the designated constraints aren't met. -type PositionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PositionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PositionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PositionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PositionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PositionValidationError) ErrorName() string { return "PositionValidationError" } - -// Error satisfies the builtin error interface -func (e PositionValidationError) 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 %sPosition.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PositionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PositionValidationError{} - -// Validate checks the field values on PositionEdges 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 *PositionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PositionEdges 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 PositionEdgesMultiError, or -// nil if none found. -func (m *PositionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *PositionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetDepartment()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: "Department", - reason: "embedded message failed validation", - cause: err, - } - } - } - - for idx, item := range m.GetUsers() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("Users[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("Permissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetUserPositions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("UserPositions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("UserPositions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("UserPositions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositionPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PositionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PositionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return PositionEdgesMultiError(errors) - } - - return nil -} - -// PositionEdgesMultiError is an error wrapping multiple validation errors -// returned by PositionEdges.ValidateAll() if the designated constraints -// aren't met. -type PositionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionEdgesMultiError) 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 PositionEdgesMultiError) AllErrors() []error { return m } - -// PositionEdgesValidationError is the validation error returned by -// PositionEdges.Validate if the designated constraints aren't met. -type PositionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PositionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PositionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PositionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PositionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PositionEdgesValidationError) ErrorName() string { return "PositionEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e PositionEdgesValidationError) 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 %sPositionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PositionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PositionEdgesValidationError{} - -// Validate checks the field values on Permission 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 *Permission) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on Permission 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 PermissionMultiError, or -// nil if none found. -func (m *Permission) ValidateAll() error { - return m.validate(true) -} - -func (m *Permission) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - if all { - switch v := interface{}(m.GetCreateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionValidationError{ - field: "CreateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetUpdateTime()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionValidationError{ - field: "UpdateTime", - reason: "embedded message failed validation", - cause: err, - } - } - } - - // no validation rules for Name - - // no validation rules for Keyword - - // no validation rules for Status - - // no validation rules for Description - - // no validation rules for DataScope - - // no validation rules for DataRules - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetViews() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionValidationError{ - field: fmt.Sprintf("Views[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionValidationError{ - field: fmt.Sprintf("Views[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionValidationError{ - field: fmt.Sprintf("Views[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return PermissionMultiError(errors) - } - - return nil -} - -// PermissionMultiError is an error wrapping multiple validation errors -// returned by Permission.ValidateAll() if the designated constraints aren't met. -type PermissionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PermissionMultiError) 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 PermissionMultiError) AllErrors() []error { return m } - -// PermissionValidationError is the validation error returned by -// Permission.Validate if the designated constraints aren't met. -type PermissionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PermissionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PermissionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PermissionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PermissionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PermissionValidationError) ErrorName() string { return "PermissionValidationError" } - -// Error satisfies the builtin error interface -func (e PermissionValidationError) 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 %sPermission.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PermissionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PermissionValidationError{} - -// Validate checks the field values on PermissionEdges 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 *PermissionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PermissionEdges 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 -// PermissionEdgesMultiError, or nil if none found. -func (m *PermissionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *PermissionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - for idx, item := range m.GetRoles() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("Roles[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("Resources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("Positions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetRolePermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("RolePermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("RolePermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("RolePermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPermissionResources() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PermissionResources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PermissionResources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("PermissionResources[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - for idx, item := range m.GetPositionPermissions() { - _, _ = idx, item - - if all { - switch v := interface{}(item).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionEdgesValidationError{ - field: fmt.Sprintf("PositionPermissions[%v]", idx), - reason: "embedded message failed validation", - cause: err, - } - } - } - - } - - if len(errors) > 0 { - return PermissionEdgesMultiError(errors) - } - - return nil -} - -// PermissionEdgesMultiError is an error wrapping multiple validation errors -// returned by PermissionEdges.ValidateAll() if the designated constraints -// aren't met. -type PermissionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PermissionEdgesMultiError) 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 PermissionEdgesMultiError) AllErrors() []error { return m } - -// PermissionEdgesValidationError is the validation error returned by -// PermissionEdges.Validate if the designated constraints aren't met. -type PermissionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e PermissionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e PermissionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e PermissionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e PermissionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e PermissionEdgesValidationError) ErrorName() string { return "PermissionEdgesValidationError" } - -// Error satisfies the builtin error interface -func (e PermissionEdgesValidationError) 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 %sPermissionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = PermissionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = PermissionEdgesValidationError{} - -// Validate checks the field values on UserPosition 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 *UserPosition) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserPosition 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 UserPositionMultiError, or -// nil if none found. -func (m *UserPosition) ValidateAll() error { - return m.validate(true) -} - -func (m *UserPosition) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for UserId - - // no validation rules for PositionId - - if len(errors) > 0 { - return UserPositionMultiError(errors) - } - - return nil -} - -// UserPositionMultiError is an error wrapping multiple validation errors -// returned by UserPosition.ValidateAll() if the designated constraints aren't met. -type UserPositionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserPositionMultiError) 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 UserPositionMultiError) AllErrors() []error { return m } - -// UserPositionValidationError is the validation error returned by -// UserPosition.Validate if the designated constraints aren't met. -type UserPositionValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserPositionValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserPositionValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserPositionValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserPositionValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserPositionValidationError) ErrorName() string { return "UserPositionValidationError" } - -// Error satisfies the builtin error interface -func (e UserPositionValidationError) 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 %sUserPosition.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserPositionValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserPositionValidationError{} - -// Validate checks the field values on UserPositionEdges 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 *UserPositionEdges) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on UserPositionEdges 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 -// UserPositionEdgesMultiError, or nil if none found. -func (m *UserPositionEdges) ValidateAll() error { - return m.validate(true) -} - -func (m *UserPositionEdges) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - if all { - switch v := interface{}(m.GetUser()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetUser()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserPositionEdgesValidationError{ - field: "User", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if all { - switch v := interface{}(m.GetPosition()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, UserPositionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return UserPositionEdgesValidationError{ - field: "Position", - reason: "embedded message failed validation", - cause: err, - } - } - } - - if len(errors) > 0 { - return UserPositionEdgesMultiError(errors) - } - - return nil -} - -// UserPositionEdgesMultiError is an error wrapping multiple validation errors -// returned by UserPositionEdges.ValidateAll() if the designated constraints -// aren't met. -type UserPositionEdgesMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m UserPositionEdgesMultiError) 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 UserPositionEdgesMultiError) AllErrors() []error { return m } - -// UserPositionEdgesValidationError is the validation error returned by -// UserPositionEdges.Validate if the designated constraints aren't met. -type UserPositionEdgesValidationError struct { - field string - reason string - cause error - key bool -} - -// Field function returns field value. -func (e UserPositionEdgesValidationError) Field() string { return e.field } - -// Reason function returns reason value. -func (e UserPositionEdgesValidationError) Reason() string { return e.reason } - -// Cause function returns cause value. -func (e UserPositionEdgesValidationError) Cause() error { return e.cause } - -// Key function returns key value. -func (e UserPositionEdgesValidationError) Key() bool { return e.key } - -// ErrorName returns error name. -func (e UserPositionEdgesValidationError) ErrorName() string { - return "UserPositionEdgesValidationError" -} - -// Error satisfies the builtin error interface -func (e UserPositionEdgesValidationError) 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 %sUserPositionEdges.%s: %s%s", - key, - e.field, - e.reason, - cause) -} - -var _ error = UserPositionEdgesValidationError{} - -var _ interface { - Field() string - Reason() string - Key() bool - Cause() error - ErrorName() string -} = UserPositionEdgesValidationError{} - -// Validate checks the field values on PositionPermission 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 *PositionPermission) Validate() error { - return m.validate(false) -} - -// ValidateAll checks the field values on PositionPermission 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 -// PositionPermissionMultiError, or nil if none found. -func (m *PositionPermission) ValidateAll() error { - return m.validate(true) -} - -func (m *PositionPermission) validate(all bool) error { - if m == nil { - return nil - } - - var errors []error - - // no validation rules for Id - - // no validation rules for PositionId - - // no validation rules for PermissionId - - if len(errors) > 0 { - return PositionPermissionMultiError(errors) - } - - return nil -} - -// PositionPermissionMultiError is an error wrapping multiple validation errors -// returned by PositionPermission.ValidateAll() if the designated constraints -// aren't met. -type PositionPermissionMultiError []error - -// Error returns a concatenation of all the error messages it wraps. -func (m PositionPermissionMultiError) Error() string { +func (m PositionMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -4910,11 +2180,11 @@ func (m PositionPermissionMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m PositionPermissionMultiError) AllErrors() []error { return m } +func (m PositionMultiError) AllErrors() []error { return m } -// PositionPermissionValidationError is the validation error returned by -// PositionPermission.Validate if the designated constraints aren't met. -type PositionPermissionValidationError struct { +// PositionValidationError is the validation error returned by +// Position.Validate if the designated constraints aren't met. +type PositionValidationError struct { field string reason string cause error @@ -4922,24 +2192,22 @@ type PositionPermissionValidationError struct { } // Field function returns field value. -func (e PositionPermissionValidationError) Field() string { return e.field } +func (e PositionValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e PositionPermissionValidationError) Reason() string { return e.reason } +func (e PositionValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e PositionPermissionValidationError) Cause() error { return e.cause } +func (e PositionValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e PositionPermissionValidationError) Key() bool { return e.key } +func (e PositionValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e PositionPermissionValidationError) ErrorName() string { - return "PositionPermissionValidationError" -} +func (e PositionValidationError) ErrorName() string { return "PositionValidationError" } // Error satisfies the builtin error interface -func (e PositionPermissionValidationError) Error() string { +func (e PositionValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -4951,14 +2219,14 @@ func (e PositionPermissionValidationError) Error() string { } return fmt.Sprintf( - "invalid %sPositionPermission.%s: %s%s", + "invalid %sPosition.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = PositionPermissionValidationError{} +var _ error = PositionValidationError{} var _ interface { Field() string @@ -4966,53 +2234,55 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = PositionPermissionValidationError{} +} = PositionValidationError{} -// Validate checks the field values on PositionPermissionEdges 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 *PositionPermissionEdges) Validate() error { +// Validate checks the field values on Permission 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 *Permission) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on PositionPermissionEdges 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 -// PositionPermissionEdgesMultiError, or nil if none found. -func (m *PositionPermissionEdges) ValidateAll() error { +// ValidateAll checks the field values on Permission 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 PermissionMultiError, or +// nil if none found. +func (m *Permission) ValidateAll() error { return m.validate(true) } -func (m *PositionPermissionEdges) validate(all bool) error { +func (m *Permission) validate(all bool) error { if m == nil { return nil } var errors []error + // no validation rules for Id + if all { - switch v := interface{}(m.GetPosition()).(type) { + switch v := interface{}(m.GetCreateTime()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Position", + errors = append(errors, PermissionValidationError{ + field: "CreateTime", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Position", + errors = append(errors, PermissionValidationError{ + field: "CreateTime", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetPosition()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetCreateTime()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return PositionPermissionEdgesValidationError{ - field: "Position", + return PermissionValidationError{ + field: "CreateTime", reason: "embedded message failed validation", cause: err, } @@ -5020,48 +2290,131 @@ func (m *PositionPermissionEdges) validate(all bool) error { } if all { - switch v := interface{}(m.GetPermission()).(type) { + switch v := interface{}(m.GetUpdateTime()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Permission", + errors = append(errors, PermissionValidationError{ + field: "UpdateTime", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { - errors = append(errors, PositionPermissionEdgesValidationError{ - field: "Permission", + errors = append(errors, PermissionValidationError{ + field: "UpdateTime", reason: "embedded message failed validation", cause: err, }) } } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { + } else if v, ok := interface{}(m.GetUpdateTime()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { - return PositionPermissionEdgesValidationError{ - field: "Permission", + return PermissionValidationError{ + field: "UpdateTime", reason: "embedded message failed validation", cause: err, } } } + // no validation rules for CreateAuthor + + // no validation rules for UpdateAuthor + + // no validation rules for Name + + // no validation rules for Keyword + + // no validation rules for Status + + // no validation rules for Description + + // no validation rules for DataScope + + // no validation rules for DataRules + + for idx, item := range m.GetResources() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionValidationError{ + field: fmt.Sprintf("Resources[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetViews() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PermissionValidationError{ + field: fmt.Sprintf("Views[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PermissionValidationError{ + field: fmt.Sprintf("Views[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PermissionValidationError{ + field: fmt.Sprintf("Views[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + if len(errors) > 0 { - return PositionPermissionEdgesMultiError(errors) + return PermissionMultiError(errors) } return nil } -// PositionPermissionEdgesMultiError is an error wrapping multiple validation -// errors returned by PositionPermissionEdges.ValidateAll() if the designated -// constraints aren't met. -type PositionPermissionEdgesMultiError []error +// PermissionMultiError is an error wrapping multiple validation errors +// returned by Permission.ValidateAll() if the designated constraints aren't met. +type PermissionMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m PositionPermissionEdgesMultiError) Error() string { +func (m PermissionMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -5070,11 +2423,11 @@ func (m PositionPermissionEdgesMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m PositionPermissionEdgesMultiError) AllErrors() []error { return m } +func (m PermissionMultiError) AllErrors() []error { return m } -// PositionPermissionEdgesValidationError is the validation error returned by -// PositionPermissionEdges.Validate if the designated constraints aren't met. -type PositionPermissionEdgesValidationError struct { +// PermissionValidationError is the validation error returned by +// Permission.Validate if the designated constraints aren't met. +type PermissionValidationError struct { field string reason string cause error @@ -5082,24 +2435,22 @@ type PositionPermissionEdgesValidationError struct { } // Field function returns field value. -func (e PositionPermissionEdgesValidationError) Field() string { return e.field } +func (e PermissionValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e PositionPermissionEdgesValidationError) Reason() string { return e.reason } +func (e PermissionValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e PositionPermissionEdgesValidationError) Cause() error { return e.cause } +func (e PermissionValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e PositionPermissionEdgesValidationError) Key() bool { return e.key } +func (e PermissionValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e PositionPermissionEdgesValidationError) ErrorName() string { - return "PositionPermissionEdgesValidationError" -} +func (e PermissionValidationError) ErrorName() string { return "PermissionValidationError" } // Error satisfies the builtin error interface -func (e PositionPermissionEdgesValidationError) Error() string { +func (e PermissionValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -5111,14 +2462,14 @@ func (e PositionPermissionEdgesValidationError) Error() string { } return fmt.Sprintf( - "invalid %sPositionPermissionEdges.%s: %s%s", + "invalid %sPermission.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = PositionPermissionEdgesValidationError{} +var _ error = PermissionValidationError{} var _ interface { Field() string @@ -5126,24 +2477,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = PositionPermissionEdgesValidationError{} +} = PermissionValidationError{} -// Validate checks the field values on RolePermission with the rules defined in +// Validate checks the field values on UserPosition 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 *RolePermission) Validate() error { +func (m *UserPosition) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on RolePermission with the rules defined +// ValidateAll checks the field values on UserPosition 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 RolePermissionMultiError, -// or nil if none found. -func (m *RolePermission) ValidateAll() error { +// result is a list of violation errors wrapped in UserPositionMultiError, or +// nil if none found. +func (m *UserPosition) ValidateAll() error { return m.validate(true) } -func (m *RolePermission) validate(all bool) error { +func (m *UserPosition) validate(all bool) error { if m == nil { return nil } @@ -5152,24 +2503,23 @@ func (m *RolePermission) validate(all bool) error { // no validation rules for Id - // no validation rules for RoleId + // no validation rules for UserId - // no validation rules for PermissionId + // no validation rules for PositionId if len(errors) > 0 { - return RolePermissionMultiError(errors) + return UserPositionMultiError(errors) } return nil } -// RolePermissionMultiError is an error wrapping multiple validation errors -// returned by RolePermission.ValidateAll() if the designated constraints -// aren't met. -type RolePermissionMultiError []error +// UserPositionMultiError is an error wrapping multiple validation errors +// returned by UserPosition.ValidateAll() if the designated constraints aren't met. +type UserPositionMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m RolePermissionMultiError) Error() string { +func (m UserPositionMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -5178,11 +2528,11 @@ func (m RolePermissionMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m RolePermissionMultiError) AllErrors() []error { return m } +func (m UserPositionMultiError) AllErrors() []error { return m } -// RolePermissionValidationError is the validation error returned by -// RolePermission.Validate if the designated constraints aren't met. -type RolePermissionValidationError struct { +// UserPositionValidationError is the validation error returned by +// UserPosition.Validate if the designated constraints aren't met. +type UserPositionValidationError struct { field string reason string cause error @@ -5190,22 +2540,22 @@ type RolePermissionValidationError struct { } // Field function returns field value. -func (e RolePermissionValidationError) Field() string { return e.field } +func (e UserPositionValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e RolePermissionValidationError) Reason() string { return e.reason } +func (e UserPositionValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e RolePermissionValidationError) Cause() error { return e.cause } +func (e UserPositionValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e RolePermissionValidationError) Key() bool { return e.key } +func (e UserPositionValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e RolePermissionValidationError) ErrorName() string { return "RolePermissionValidationError" } +func (e UserPositionValidationError) ErrorName() string { return "UserPositionValidationError" } // Error satisfies the builtin error interface -func (e RolePermissionValidationError) Error() string { +func (e UserPositionValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -5217,14 +2567,14 @@ func (e RolePermissionValidationError) Error() string { } return fmt.Sprintf( - "invalid %sRolePermission.%s: %s%s", + "invalid %sUserPosition.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = RolePermissionValidationError{} +var _ error = UserPositionValidationError{} var _ interface { Field() string @@ -5232,102 +2582,50 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = RolePermissionValidationError{} +} = UserPositionValidationError{} -// Validate checks the field values on RolePermissionEdges with the rules +// Validate checks the field values on PositionPermission 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 *RolePermissionEdges) Validate() error { +func (m *PositionPermission) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on RolePermissionEdges with the rules +// ValidateAll checks the field values on PositionPermission 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 -// RolePermissionEdgesMultiError, or nil if none found. -func (m *RolePermissionEdges) ValidateAll() error { +// PositionPermissionMultiError, or nil if none found. +func (m *PositionPermission) ValidateAll() error { return m.validate(true) } -func (m *RolePermissionEdges) validate(all bool) error { +func (m *PositionPermission) validate(all bool) error { if m == nil { return nil } var errors []error - if all { - switch v := interface{}(m.GetRole()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetRole()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RolePermissionEdgesValidationError{ - field: "Role", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for Id - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, RolePermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return RolePermissionEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for PositionId + + // no validation rules for PermissionId if len(errors) > 0 { - return RolePermissionEdgesMultiError(errors) + return PositionPermissionMultiError(errors) } return nil } -// RolePermissionEdgesMultiError is an error wrapping multiple validation -// errors returned by RolePermissionEdges.ValidateAll() if the designated -// constraints aren't met. -type RolePermissionEdgesMultiError []error +// PositionPermissionMultiError is an error wrapping multiple validation errors +// returned by PositionPermission.ValidateAll() if the designated constraints +// aren't met. +type PositionPermissionMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m RolePermissionEdgesMultiError) Error() string { +func (m PositionPermissionMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -5336,11 +2634,11 @@ func (m RolePermissionEdgesMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m RolePermissionEdgesMultiError) AllErrors() []error { return m } +func (m PositionPermissionMultiError) AllErrors() []error { return m } -// RolePermissionEdgesValidationError is the validation error returned by -// RolePermissionEdges.Validate if the designated constraints aren't met. -type RolePermissionEdgesValidationError struct { +// PositionPermissionValidationError is the validation error returned by +// PositionPermission.Validate if the designated constraints aren't met. +type PositionPermissionValidationError struct { field string reason string cause error @@ -5348,24 +2646,24 @@ type RolePermissionEdgesValidationError struct { } // Field function returns field value. -func (e RolePermissionEdgesValidationError) Field() string { return e.field } +func (e PositionPermissionValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e RolePermissionEdgesValidationError) Reason() string { return e.reason } +func (e PositionPermissionValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e RolePermissionEdgesValidationError) Cause() error { return e.cause } +func (e PositionPermissionValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e RolePermissionEdgesValidationError) Key() bool { return e.key } +func (e PositionPermissionValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e RolePermissionEdgesValidationError) ErrorName() string { - return "RolePermissionEdgesValidationError" +func (e PositionPermissionValidationError) ErrorName() string { + return "PositionPermissionValidationError" } // Error satisfies the builtin error interface -func (e RolePermissionEdgesValidationError) Error() string { +func (e PositionPermissionValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -5377,14 +2675,14 @@ func (e RolePermissionEdgesValidationError) Error() string { } return fmt.Sprintf( - "invalid %sRolePermissionEdges.%s: %s%s", + "invalid %sPositionPermission.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = RolePermissionEdgesValidationError{} +var _ error = PositionPermissionValidationError{} var _ interface { Field() string @@ -5392,24 +2690,24 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = RolePermissionEdgesValidationError{} +} = PositionPermissionValidationError{} -// Validate checks the field values on PermissionResource 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 *PermissionResource) Validate() error { +// Validate checks the field values on RolePermission 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 *RolePermission) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on PermissionResource 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 -// PermissionResourceMultiError, or nil if none found. -func (m *PermissionResource) ValidateAll() error { +// ValidateAll checks the field values on RolePermission 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 RolePermissionMultiError, +// or nil if none found. +func (m *RolePermission) ValidateAll() error { return m.validate(true) } -func (m *PermissionResource) validate(all bool) error { +func (m *RolePermission) validate(all bool) error { if m == nil { return nil } @@ -5418,26 +2716,24 @@ func (m *PermissionResource) validate(all bool) error { // no validation rules for Id - // no validation rules for PermissionId - - // no validation rules for ResourceId + // no validation rules for RoleId - // no validation rules for Actions + // no validation rules for PermissionId if len(errors) > 0 { - return PermissionResourceMultiError(errors) + return RolePermissionMultiError(errors) } return nil } -// PermissionResourceMultiError is an error wrapping multiple validation errors -// returned by PermissionResource.ValidateAll() if the designated constraints +// RolePermissionMultiError is an error wrapping multiple validation errors +// returned by RolePermission.ValidateAll() if the designated constraints // aren't met. -type PermissionResourceMultiError []error +type RolePermissionMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m PermissionResourceMultiError) Error() string { +func (m RolePermissionMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -5446,11 +2742,11 @@ func (m PermissionResourceMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m PermissionResourceMultiError) AllErrors() []error { return m } +func (m RolePermissionMultiError) AllErrors() []error { return m } -// PermissionResourceValidationError is the validation error returned by -// PermissionResource.Validate if the designated constraints aren't met. -type PermissionResourceValidationError struct { +// RolePermissionValidationError is the validation error returned by +// RolePermission.Validate if the designated constraints aren't met. +type RolePermissionValidationError struct { field string reason string cause error @@ -5458,24 +2754,22 @@ type PermissionResourceValidationError struct { } // Field function returns field value. -func (e PermissionResourceValidationError) Field() string { return e.field } +func (e RolePermissionValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e PermissionResourceValidationError) Reason() string { return e.reason } +func (e RolePermissionValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e PermissionResourceValidationError) Cause() error { return e.cause } +func (e RolePermissionValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e PermissionResourceValidationError) Key() bool { return e.key } +func (e RolePermissionValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e PermissionResourceValidationError) ErrorName() string { - return "PermissionResourceValidationError" -} +func (e RolePermissionValidationError) ErrorName() string { return "RolePermissionValidationError" } // Error satisfies the builtin error interface -func (e PermissionResourceValidationError) Error() string { +func (e RolePermissionValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -5487,14 +2781,14 @@ func (e PermissionResourceValidationError) Error() string { } return fmt.Sprintf( - "invalid %sPermissionResource.%s: %s%s", + "invalid %sRolePermission.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = PermissionResourceValidationError{} +var _ error = RolePermissionValidationError{} var _ interface { Field() string @@ -5502,102 +2796,52 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = PermissionResourceValidationError{} +} = RolePermissionValidationError{} -// Validate checks the field values on PermissionResourceEdges with the rules +// Validate checks the field values on PermissionResource 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 *PermissionResourceEdges) Validate() error { +func (m *PermissionResource) Validate() error { return m.validate(false) } -// ValidateAll checks the field values on PermissionResourceEdges with the -// rules defined in the proto definition for this message. If any rules are +// ValidateAll checks the field values on PermissionResource 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 -// PermissionResourceEdgesMultiError, or nil if none found. -func (m *PermissionResourceEdges) ValidateAll() error { +// PermissionResourceMultiError, or nil if none found. +func (m *PermissionResource) ValidateAll() error { return m.validate(true) } -func (m *PermissionResourceEdges) validate(all bool) error { +func (m *PermissionResource) validate(all bool) error { if m == nil { return nil } var errors []error - if all { - switch v := interface{}(m.GetPermission()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetPermission()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionResourceEdgesValidationError{ - field: "Permission", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for Id - if all { - switch v := interface{}(m.GetResource()).(type) { - case interface{ ValidateAll() error }: - if err := v.ValidateAll(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - case interface{ Validate() error }: - if err := v.Validate(); err != nil { - errors = append(errors, PermissionResourceEdgesValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - }) - } - } - } else if v, ok := interface{}(m.GetResource()).(interface{ Validate() error }); ok { - if err := v.Validate(); err != nil { - return PermissionResourceEdgesValidationError{ - field: "Resource", - reason: "embedded message failed validation", - cause: err, - } - } - } + // no validation rules for PermissionId + + // no validation rules for ResourceId + + // no validation rules for Actions if len(errors) > 0 { - return PermissionResourceEdgesMultiError(errors) + return PermissionResourceMultiError(errors) } return nil } -// PermissionResourceEdgesMultiError is an error wrapping multiple validation -// errors returned by PermissionResourceEdges.ValidateAll() if the designated -// constraints aren't met. -type PermissionResourceEdgesMultiError []error +// PermissionResourceMultiError is an error wrapping multiple validation errors +// returned by PermissionResource.ValidateAll() if the designated constraints +// aren't met. +type PermissionResourceMultiError []error // Error returns a concatenation of all the error messages it wraps. -func (m PermissionResourceEdgesMultiError) Error() string { +func (m PermissionResourceMultiError) Error() string { msgs := make([]string, 0, len(m)) for _, err := range m { msgs = append(msgs, err.Error()) @@ -5606,11 +2850,11 @@ func (m PermissionResourceEdgesMultiError) Error() string { } // AllErrors returns a list of validation violation errors. -func (m PermissionResourceEdgesMultiError) AllErrors() []error { return m } +func (m PermissionResourceMultiError) AllErrors() []error { return m } -// PermissionResourceEdgesValidationError is the validation error returned by -// PermissionResourceEdges.Validate if the designated constraints aren't met. -type PermissionResourceEdgesValidationError struct { +// PermissionResourceValidationError is the validation error returned by +// PermissionResource.Validate if the designated constraints aren't met. +type PermissionResourceValidationError struct { field string reason string cause error @@ -5618,24 +2862,24 @@ type PermissionResourceEdgesValidationError struct { } // Field function returns field value. -func (e PermissionResourceEdgesValidationError) Field() string { return e.field } +func (e PermissionResourceValidationError) Field() string { return e.field } // Reason function returns reason value. -func (e PermissionResourceEdgesValidationError) Reason() string { return e.reason } +func (e PermissionResourceValidationError) Reason() string { return e.reason } // Cause function returns cause value. -func (e PermissionResourceEdgesValidationError) Cause() error { return e.cause } +func (e PermissionResourceValidationError) Cause() error { return e.cause } // Key function returns key value. -func (e PermissionResourceEdgesValidationError) Key() bool { return e.key } +func (e PermissionResourceValidationError) Key() bool { return e.key } // ErrorName returns error name. -func (e PermissionResourceEdgesValidationError) ErrorName() string { - return "PermissionResourceEdgesValidationError" +func (e PermissionResourceValidationError) ErrorName() string { + return "PermissionResourceValidationError" } // Error satisfies the builtin error interface -func (e PermissionResourceEdgesValidationError) Error() string { +func (e PermissionResourceValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) @@ -5647,14 +2891,14 @@ func (e PermissionResourceEdgesValidationError) Error() string { } return fmt.Sprintf( - "invalid %sPermissionResourceEdges.%s: %s%s", + "invalid %sPermissionResource.%s: %s%s", key, e.field, e.reason, cause) } -var _ error = PermissionResourceEdgesValidationError{} +var _ error = PermissionResourceValidationError{} var _ interface { Field() string @@ -5662,4 +2906,4 @@ var _ interface { Key() bool Cause() error ErrorName() string -} = PermissionResourceEdgesValidationError{} +} = PermissionResourceValidationError{} diff --git a/cmd/seed/wire_gen.go b/cmd/seed/wire_gen.go index 093cede1..1421792d 100644 --- a/cmd/seed/wire_gen.go +++ b/cmd/seed/wire_gen.go @@ -41,7 +41,11 @@ func wireApp(app *runtime.App, bootstrap *conf.Config) (*seeder.Seeder, func(), return nil, nil, err } userUseCase := biz.NewUserUseCase(userRepo, crypto) - seederSeeder, err := seeder.NewSeeder(userUseCase, bootstrap, v) + resourceRepo := dal.NewResourceRepo(database) + resourceUseCase := biz.NewResourceUseCase(resourceRepo) + viewRepo := dal.NewViewRepo(database) + viewUseCase := biz.NewViewUseCase(viewRepo) + seederSeeder, err := seeder.NewSeeder(userUseCase, resourceUseCase, viewUseCase, bootstrap, v) if err != nil { cleanup() return nil, nil, err diff --git a/go.mod b/go.mod index edd79329..2692c4d8 100644 --- a/go.mod +++ b/go.mod @@ -23,9 +23,9 @@ require ( github.com/origadmin/contrib v1.2.0 github.com/origadmin/runtime v0.2.15 github.com/origadmin/slog-kratos v1.0.5 // indirect - github.com/origadmin/toolkits/codec v1.3.0 + github.com/origadmin/toolkits/codec v1.3.1 github.com/origadmin/toolkits/crypto v1.3.0 - github.com/origadmin/toolkits/errors v1.2.0 + github.com/origadmin/toolkits/errors v1.3.1 github.com/sony/sonyflake v1.3.0 github.com/sqlite3ent/sqlite3 v1.40.0 golang.org/x/net v0.48.0 // indirect @@ -41,7 +41,7 @@ require ( github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2 v2.0.0-20260105075216-c7a58ff59f80 github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 github.com/joho/godotenv v1.5.1 - github.com/origadmin/toolkits/i18n v1.2.0 + github.com/origadmin/toolkits/i18n v1.3.0 golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0 ) @@ -78,6 +78,7 @@ require ( github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/bep/godartsass/v2 v2.5.0 // indirect github.com/bep/golibsass v1.2.0 // indirect + github.com/bits-and-blooms/bitset v1.24.4 // indirect github.com/bmatcuk/doublestar v1.3.4 // indirect github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect github.com/bufbuild/protocompile v0.14.2-0.20251223142729-db46c1b9d34e // indirect @@ -129,7 +130,8 @@ require ( github.com/go-viper/mapstructure/v2 v2.4.0 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/gofrs/flock v0.13.0 // indirect - github.com/gohugoio/hugo v0.149.1 // indirect + github.com/gohugoio/hashstructure v0.6.0 // indirect + github.com/gohugoio/hugo v0.154.2 // indirect github.com/golang-cz/devslog v0.0.15 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/google/cel-go v0.26.1 // indirect @@ -173,9 +175,10 @@ require ( github.com/muesli/cancelreader v0.2.2 // indirect github.com/muesli/termenv v0.16.0 // indirect github.com/ncruces/go-strftime v1.0.0 // indirect + github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect github.com/olekukonko/errors v1.1.0 // indirect - github.com/olekukonko/ll v0.0.9 // indirect - github.com/olekukonko/tablewriter v1.0.9 // indirect + github.com/olekukonko/ll v0.1.3 // indirect + github.com/olekukonko/tablewriter v1.1.2 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect github.com/origadmin/toolkits/slogx v1.3.0 // indirect @@ -203,7 +206,7 @@ require ( github.com/spf13/pflag v1.0.10 // indirect github.com/stoewer/go-strcase v1.3.1 // indirect github.com/stretchr/objx v0.5.2 // indirect - github.com/tdewolff/parse/v2 v2.8.3 // indirect + github.com/tdewolff/parse/v2 v2.8.5 // indirect github.com/tetratelabs/wazero v1.11.0 // indirect github.com/tidwall/btree v1.8.1 // indirect github.com/tklauser/go-sysconf v0.3.16 // indirect diff --git a/go.sum b/go.sum index 3965502f..567f7bf8 100644 --- a/go.sum +++ b/go.sum @@ -49,6 +49,10 @@ github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2 github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/JohannesKaufmann/dom v0.2.0 h1:1bragmEb19K8lHAqgFgqCpiPCFEZMTXzOIEjuxkUfLQ= +github.com/JohannesKaufmann/dom v0.2.0/go.mod h1:57iSUl5RKric4bUkgos4zu6Xt5LMHUnw3TF1l5CbGZo= +github.com/JohannesKaufmann/html-to-markdown/v2 v2.5.0 h1:mklaPbT4f/EiDr1Q+zPrEt9lgKAkVrIBtWf33d9GpVA= +github.com/JohannesKaufmann/html-to-markdown/v2 v2.5.0/go.mod h1:D56Cl9r8M5i3UwAchE+LlLc5hPN3kJtdZNVJn06lSHU= github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= @@ -59,8 +63,8 @@ github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7l github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/air-verse/air v1.63.6 h1:izaqxGhacjPCBtVIGtEJ8wXEtwx4TxruFnE0wGJzipI= github.com/air-verse/air v1.63.6/go.mod h1:Dnn4m4DlC9IQiNd3ir57SOdpvGJ3gnC1+OlIGMi2fJY= -github.com/alecthomas/chroma/v2 v2.20.0 h1:sfIHpxPyR07/Oylvmcai3X/exDlE8+FA820NTz+9sGw= -github.com/alecthomas/chroma/v2 v2.20.0/go.mod h1:e7tViK0xh/Nf4BYHl00ycY6rV7b8iXBksI9E359yNmA= +github.com/alecthomas/chroma/v2 v2.21.1 h1:FaSDrp6N+3pphkNKU6HPCiYLgm8dbe5UXIXcoBhZSWA= +github.com/alecthomas/chroma/v2 v2.21.1/go.mod h1:NqVhfBR0lte5Ouh3DcthuUCTUpDC9cxBOfyMbMQPs3o= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -75,8 +79,6 @@ github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.1-0.20221118154546-54df44f2176c h1:651/eoCRnQ7YtSjAnSzRucrJz+3iGEFt+ysraELS81M= -github.com/armon/go-radix v1.0.1-0.20221118154546-54df44f2176c/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -102,21 +104,23 @@ github.com/bep/golibsass v1.2.0 h1:nyZUkKP/0psr8nT6GR2cnmt99xS93Ji82ZD9AgOK6VI= github.com/bep/golibsass v1.2.0/go.mod h1:DL87K8Un/+pWUS75ggYv41bliGiolxzDKWJAq3eJ1MA= github.com/bep/goportabletext v0.1.0 h1:8dqym2So1cEqVZiBa4ZnMM1R9l/DnC1h4ONg4J5kujw= github.com/bep/goportabletext v0.1.0/go.mod h1:6lzSTsSue75bbcyvVc0zqd1CdApuT+xkZQ6Re5DzZFg= -github.com/bep/gowebp v0.4.0 h1:QihuVnvIKbRoeBNQkN0JPMM8ClLmD6V2jMftTFwSK3Q= -github.com/bep/gowebp v0.4.0/go.mod h1:95gtYkAA8iIn1t3HkAPurRCVGV/6NhgaHJ1urz0iIwc= github.com/bep/helpers v0.6.0 h1:qtqMCK8XPFNM9hp5Ztu9piPjxNNkk8PIyUVjg6v8Bsw= github.com/bep/helpers v0.6.0/go.mod h1:IOZlgx5PM/R/2wgyCatfsgg5qQ6rNZJNDpWGXqDR044= -github.com/bep/imagemeta v0.12.0 h1:ARf+igs5B7pf079LrqRnwzQ/wEB8Q9v4NSDRZO1/F5k= -github.com/bep/imagemeta v0.12.0/go.mod h1:23AF6O+4fUi9avjiydpKLStUNtJr5hJB4rarG18JpN8= +github.com/bep/imagemeta v0.12.1 h1:43sIg/XJhXLVOo6troJFj9dyUr1jH+VN2UjO4/l26cQ= +github.com/bep/imagemeta v0.12.1/go.mod h1:23AF6O+4fUi9avjiydpKLStUNtJr5hJB4rarG18JpN8= github.com/bep/lazycache v0.8.0 h1:lE5frnRjxaOFbkPZ1YL6nijzOPPz6zeXasJq8WpG4L8= github.com/bep/lazycache v0.8.0/go.mod h1:BQ5WZepss7Ko91CGdWz8GQZi/fFnCcyWupv8gyTeKwk= github.com/bep/logg v0.4.0 h1:luAo5mO4ZkhA5M1iDVDqDqnBBnlHjmtZF6VAyTp+nCQ= github.com/bep/logg v0.4.0/go.mod h1:Ccp9yP3wbR1mm++Kpxet91hAZBEQgmWgFgnXX3GkIV0= github.com/bep/overlayfs v0.10.0 h1:wS3eQ6bRsLX+4AAmwGjvoFSAQoeheamxofFiJ2SthSE= github.com/bep/overlayfs v0.10.0/go.mod h1:ouu4nu6fFJaL0sPzNICzxYsBeWwrjiTdFZdK4lI3tro= +github.com/bep/textandbinarywriter v0.0.0-20251212174530-cd9f0732f60f h1:NzhMpf5eis+w8bTbT1jqVz+gcMEBhcIPA/KRbYvX8+Y= +github.com/bep/textandbinarywriter v0.0.0-20251212174530-cd9f0732f60f/go.mod h1:vTWM9sqhanOWdo2B2NHwDQPuPmD/nCdMKDFPYxd4VKU= github.com/bep/tmc v0.5.1 h1:CsQnSC6MsomH64gw0cT5f+EwQDcvZz4AazKunFwTpuI= github.com/bep/tmc v0.5.1/go.mod h1:tGYHN8fS85aJPhDLgXETVKp+PR382OvFi2+q2GkGsq0= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bits-and-blooms/bitset v1.24.4 h1:95H15Og1clikBrKr/DuzMXkQzECs1M6hhoGXLwLQOZE= +github.com/bits-and-blooms/bitset v1.24.4/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= @@ -233,8 +237,8 @@ github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= -github.com/evanw/esbuild v0.25.9 h1:aU7GVC4lxJGC1AyaPwySWjSIaNLAdVEEuq3chD0Khxs= -github.com/evanw/esbuild v0.25.9/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= +github.com/evanw/esbuild v0.27.2 h1:3xBEws9y/JosfewXMM2qIyHAi+xRo8hVx475hVkJfNg= +github.com/evanw/esbuild v0.27.2/go.mod h1:D2vIQZqV/vIf/VRHtViaUtViZmG7o+kKmlBfVQuRi48= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= @@ -249,8 +253,6 @@ github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/getkin/kin-openapi v0.133.0 h1:pJdmNohVIJ97r4AUFtEXRXwESr8b0bD721u/Tz6k8PQ= github.com/getkin/kin-openapi v0.133.0/go.mod h1:boAciF6cXk5FhPqe/NQeBTeenbjqU4LhWBf09ILVvWE= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE= github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -298,19 +300,23 @@ github.com/gobuffalo/flect v1.0.3 h1:xeWBM2nui+qnVvNM4S3foBhCAL2XgPU+a7FdpelbTq4 github.com/gobuffalo/flect v1.0.3/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= +github.com/goccy/go-yaml v1.19.1 h1:3rG3+v8pkhRqoQ/88NYNMHYVGYztCOCIZ7UQhu7H+NE= +github.com/goccy/go-yaml v1.19.1/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/goexts/generic v0.14.0 h1:Lw8QKwgN9w6vnHuEbs3K+42frxi7MHS2pJrg7/ZCkJc= github.com/goexts/generic v0.14.0/go.mod h1:3L0Ou9PAX35WPvO+aSeZsoENlGIRSDAuZ8/GNqUqaEs= github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw= github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e h1:QArsSubW7eDh8APMXkByjQWvuljwPGAGQpJEFn0F0wY= -github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e/go.mod h1:3Ltoo9Banwq0gOtcOwxuHG6omk+AwsQPADyw2vQYOJQ= -github.com/gohugoio/hashstructure v0.5.0 h1:G2fjSBU36RdwEJBWJ+919ERvOVqAg9tfcYp47K9swqg= -github.com/gohugoio/hashstructure v0.5.0/go.mod h1:Ser0TniXuu/eauYmrwM4o64EBvySxNzITEOLlm4igec= -github.com/gohugoio/httpcache v0.7.0 h1:ukPnn04Rgvx48JIinZvZetBfHaWE7I01JR2Q2RrQ3Vs= -github.com/gohugoio/httpcache v0.7.0/go.mod h1:fMlPrdY/vVJhAriLZnrF5QpN3BNAcoBClgAyQd+lGFI= -github.com/gohugoio/hugo v0.149.1 h1:uWOc8Ve4h4e48FyYhBquRoHCJviyxA5yGrFJLT48yio= -github.com/gohugoio/hugo v0.149.1/go.mod h1:HS6BP6e8FGxungP4CHC3zeLDvhBLnTJIjHJZWTZjs7o= +github.com/gohugoio/go-i18n/v2 v2.1.3-0.20251018145728-cfcc22d823c6 h1:pxlAea9eRwuAnt/zKbGqlFO2ZszpIe24YpOVLf+N+4I= +github.com/gohugoio/go-i18n/v2 v2.1.3-0.20251018145728-cfcc22d823c6/go.mod h1:m5hu1im5Qc7LDycVLvee6MPobJiRLBYHklypFJR0/aE= +github.com/gohugoio/go-radix v1.2.0 h1:D5GTk8jIoeXirBSc2P4E4NdHKDrenk9k9N0ctU5Yrhg= +github.com/gohugoio/go-radix v1.2.0/go.mod h1:k6vDa0ebpbpgtzSj9lPGJcA4AZwJ9xUNObUy2vczPFM= +github.com/gohugoio/hashstructure v0.6.0 h1:7wMB/2CfXoThFYhdWRGv3u3rUM761Cq29CxUW+NltUg= +github.com/gohugoio/hashstructure v0.6.0/go.mod h1:lapVLk9XidheHG1IQ4ZSbyYrXcaILU1ZEP/+vno5rBQ= +github.com/gohugoio/httpcache v0.8.0 h1:hNdsmGSELztetYCsPVgjA960zSa4dfEqqF/SficorCU= +github.com/gohugoio/httpcache v0.8.0/go.mod h1:fMlPrdY/vVJhAriLZnrF5QpN3BNAcoBClgAyQd+lGFI= +github.com/gohugoio/hugo v0.154.2 h1:KHvcs0qGXwaebyQHIH/JgZbOQlUViffj2HWnWV6v/08= +github.com/gohugoio/hugo v0.154.2/go.mod h1:/4rqF6hPIBDeyDQaYPsA+ezFvRtWZlUaw2800CW0GNk= github.com/gohugoio/hugo-goldmark-extensions/extras v0.5.0 h1:dco+7YiOryRoPOMXwwaf+kktZSCtlFtreNdiJbETvYE= github.com/gohugoio/hugo-goldmark-extensions/extras v0.5.0/go.mod h1:CRrxQTKeM3imw+UoS4EHKyrqB7Zp6sAJiqHit+aMGTE= github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.3.1 h1:nUzXfRTszLliZuN0JTKeunXTRaiFX6ksaWP0puLLYAY= @@ -539,12 +545,14 @@ github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//J github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037/go.mod h1:2bpvgLBZEtENV5scfDFEtB/5+1M4hkQhDQrccEJ/qGw= github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c= github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90/go.mod h1:y5+oSEHCPT/DGrS++Wc/479ERge0zTFxaF8PbGKcg2o= +github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj4EljqMiZsIcE09mmF8XsD5AYOJc= +github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0= github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM= github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y= -github.com/olekukonko/ll v0.0.9 h1:Y+1YqDfVkqMWuEQMclsF9HUR5+a82+dxJuL1HHSRpxI= -github.com/olekukonko/ll v0.0.9/go.mod h1:En+sEW0JNETl26+K8eZ6/W4UQ7CYSrrgg/EdIYT2H8g= -github.com/olekukonko/tablewriter v1.0.9 h1:XGwRsYLC2bY7bNd93Dk51bcPZksWZmLYuaTHR0FqfL8= -github.com/olekukonko/tablewriter v1.0.9/go.mod h1:5c+EBPeSqvXnLLgkm9isDdzR3wjfBkHR9Nhfp3NWrzo= +github.com/olekukonko/ll v0.1.3 h1:sV2jrhQGq5B3W0nENUISCR6azIPf7UBUpVq0x/y70Fg= +github.com/olekukonko/ll v0.1.3/go.mod h1:b52bVQRRPObe+yyBl0TxNfhesL0nedD4Cht0/zx55Ew= +github.com/olekukonko/tablewriter v1.1.2 h1:L2kI1Y5tZBct/O/TyZK1zIE9GlBj/TVs+AY5tZDCDSc= +github.com/olekukonko/tablewriter v1.1.2/go.mod h1:z7SYPugVqGVavWoA2sGsFIoOVNmEHxUAAMrhXONtfkg= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= @@ -553,14 +561,14 @@ github.com/origadmin/contrib v1.2.0 h1:pyNPpIBHLUOgB6CzYMVp9uClrwtEb14ESInIqXM/A github.com/origadmin/contrib v1.2.0/go.mod h1:LG2kg7teY2H5Yr73cAcbdPvbysS5sV2cdGkxLmfcILs= github.com/origadmin/slog-kratos v1.0.5 h1:yDLxVaN8A8MMmIny3xy65uT1wLKl3S9tVZVijn+1Vhc= github.com/origadmin/slog-kratos v1.0.5/go.mod h1:zuOf6B1cMjPwwMJ2or2sPbzNAdx/fMn/6MekdG30Xh4= -github.com/origadmin/toolkits/codec v1.3.0 h1:U9eRN5R8N6/yly5JoxKJ9UCRayaIbdLUBd+Xekonu5w= -github.com/origadmin/toolkits/codec v1.3.0/go.mod h1:NgbdOtowlFY79/CXZzRhes1tRHTBr3XZX+VBWL7yUpw= +github.com/origadmin/toolkits/codec v1.3.1 h1:zT1gh0YOK1mSrQjqtwuwo9JLdECuDY71GMt/oChEO3Q= +github.com/origadmin/toolkits/codec v1.3.1/go.mod h1:NgbdOtowlFY79/CXZzRhes1tRHTBr3XZX+VBWL7yUpw= github.com/origadmin/toolkits/crypto v1.3.0 h1:5p27+nInJapn6SpsLS/2jTgZDY4DnoRBb+JinIBvdrs= github.com/origadmin/toolkits/crypto v1.3.0/go.mod h1:PlR7+Dh88bVl8z+wKjAcxVBHxl3fllwfhLGOvzAO9nQ= -github.com/origadmin/toolkits/errors v1.2.0 h1:dQzGVa9QtlptaQ3ljXz6+dbMwHMBORPdiyAF5xxErlk= -github.com/origadmin/toolkits/errors v1.2.0/go.mod h1:YCPShNuAmn0ns0JB43iKbVdWcPA8XCTiFG+7UA2+tJw= -github.com/origadmin/toolkits/i18n v1.2.0 h1:1/fRapVye5IQXPTOfMUZAHq26/rYWxXh3+6IaP1yOWw= -github.com/origadmin/toolkits/i18n v1.2.0/go.mod h1:utfVq5IU8KGeygz1Ey6g+6fV3oplUNW2iZofUG8Be5c= +github.com/origadmin/toolkits/errors v1.3.1 h1:MhVeCMs8TCxwG40HxOc0IaXueOci6HrQl+njeMpwB7o= +github.com/origadmin/toolkits/errors v1.3.1/go.mod h1:YCPShNuAmn0ns0JB43iKbVdWcPA8XCTiFG+7UA2+tJw= +github.com/origadmin/toolkits/i18n v1.3.0 h1:4OKYcO4EpW8BpaJzRyLEmpdjrcKqyYfTUkIDI23d758= +github.com/origadmin/toolkits/i18n v1.3.0/go.mod h1:utfVq5IU8KGeygz1Ey6g+6fV3oplUNW2iZofUG8Be5c= github.com/origadmin/toolkits/slogx v1.3.0 h1:F4ril11Te2wSKvifEjdBIeFvtFHk7cEG+lxoX56SB4I= github.com/origadmin/toolkits/slogx v1.3.0/go.mod h1:p2hI6XV9DWZli+vyRRO+t9OQKbcBuDIDgYJ6TEvfVAI= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -669,10 +677,10 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/tdewolff/minify/v2 v2.24.2 h1:vnY3nTulEAbCAAlxTxPPDkzG24rsq31SOzp63yT+7mo= -github.com/tdewolff/minify/v2 v2.24.2/go.mod h1:1JrCtoZXaDbqioQZfk3Jdmr0GPJKiU7c1Apmb+7tCeE= -github.com/tdewolff/parse/v2 v2.8.3 h1:5VbvtJ83cfb289A1HzRA9sf02iT8YyUwN84ezjkdY1I= -github.com/tdewolff/parse/v2 v2.8.3/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo= +github.com/tdewolff/minify/v2 v2.24.8 h1:58/VjsbevI4d5FGV0ZSuBrHMSSkH4MCH0sIz/eKIauE= +github.com/tdewolff/minify/v2 v2.24.8/go.mod h1:0Ukj0CRpo/sW/nd8uZ4ccXaV1rEVIWA3dj8U7+Shhfw= +github.com/tdewolff/parse/v2 v2.8.5 h1:ZmBiA/8Do5Rpk7bDye0jbbDUpXXbCdc3iah4VeUvwYU= +github.com/tdewolff/parse/v2 v2.8.5/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo= github.com/tdewolff/test v1.0.11 h1:FdLbwQVHxqG16SlkGveC0JVyrJN62COWTRyUFzfbtBE= github.com/tdewolff/test v1.0.11/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8= github.com/tetratelabs/wazero v1.11.0 h1:+gKemEuKCTevU4d7ZTzlsvgd1uaToIDtlQlmNbwqYhA= @@ -851,8 +859,8 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= -golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= -golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= +golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= +golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -892,8 +900,6 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/data/entity/ent/generate.go b/internal/data/entity/ent/generate.go index a46b7e6d..30225e2e 100644 --- a/internal/data/entity/ent/generate.go +++ b/internal/data/entity/ent/generate.go @@ -5,4 +5,4 @@ // Package ent is the data access object for SYS. package ent -//go:generate go run entgo.io/ent/cmd/ent generate --template ./template --feature intercept --feature schema/snapshot --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema +//go:generate ent generate --template ./template --feature intercept --feature schema/snapshot --feature sql/versioned-migration --feature sql/lock --feature sql/modifier ./schema diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index f4fce002..dab0b937 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"permission.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status.comment\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path.comment\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method.comment\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation.comment\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy.comment\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id.comment\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id.comment\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status.comment\"},{\"name\":\"status\",\"type\":{\"Type\":6,\"Ident\":\"resource.Status\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"enabled\",\"V\":\"enabled\"},{\"N\":\"disabled\",\"V\":\"disabled\"}],\"default\":true,\"default_value\":\"enabled\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword.comment\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name.comment\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type.comment\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component.comment\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path.comment\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon.comment\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible.comment\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence.comment\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path.comment\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.i18n\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index e218d482..d852043d 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -138,7 +138,7 @@ var ( {Name: "description", Type: field.TypeString, Size: 1024, Comment: "entity.permission.field.description", Default: ""}, {Name: "data_scope", Type: field.TypeString, Comment: "entity.permission.field.data_scope", Default: "self"}, {Name: "data_rules", Type: field.TypeJSON, Nullable: true, Comment: "entity.permission.field.data_rules"}, - {Name: "status", Type: field.TypeEnum, Comment: "entity.permission.field.status.comment", Enums: []string{"enabled", "disabled"}, Default: "enabled"}, + {Name: "status", Type: field.TypeInt8, Comment: "entity.permission.field.status", Default: 1}, {Name: "actions", Type: field.TypeEnum, Comment: "entity.permission.field.actions", Enums: []string{"read", "write", "delete", "manage"}, Default: "read"}, } // SysPermissionsTable holds the schema information for the "sys_permissions" table. @@ -270,16 +270,16 @@ var ( {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "service_name", Type: field.TypeString, Comment: "entity.resource.field.service_name.comment"}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.resource.field.keyword.comment"}, - {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.path.comment"}, - {Name: "method", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.method.comment"}, - {Name: "operation", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.operation.comment"}, - {Name: "policy", Type: field.TypeString, Comment: "entity.resource.field.policy.comment", Default: ""}, - {Name: "version_id", Type: field.TypeString, Comment: "entity.resource.field.version_id.comment", Default: ""}, - {Name: "last_sync_version_id", Type: field.TypeString, Comment: "entity.resource.field.last_sync_version_id.comment", Default: ""}, - {Name: "sync_status", Type: field.TypeString, Comment: "entity.resource.field.sync_status.comment", Default: "Synced"}, - {Name: "status", Type: field.TypeEnum, Comment: "entity.resource.field.status.comment", Enums: []string{"enabled", "disabled"}, Default: "enabled"}, + {Name: "service_name", Type: field.TypeString, Comment: "entity.resource.field.service_name"}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.resource.field.keyword"}, + {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.path"}, + {Name: "method", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.method"}, + {Name: "operation", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.operation"}, + {Name: "policy", Type: field.TypeString, Comment: "entity.resource.field.policy", Default: ""}, + {Name: "version_id", Type: field.TypeString, Comment: "entity.resource.field.version_id", Default: ""}, + {Name: "last_sync_version_id", Type: field.TypeString, Comment: "entity.resource.field.last_sync_version_id", Default: ""}, + {Name: "sync_status", Type: field.TypeString, Comment: "entity.resource.field.sync_status", Default: "Synced"}, + {Name: "status", Type: field.TypeInt8, Comment: "entity.resource.field.status", Default: 1}, } // SysResourcesTable holds the schema information for the "sys_resources" table. SysResourcesTable = &schema.Table{ @@ -404,6 +404,7 @@ var ( {Name: "salt", Type: field.TypeString, Size: 64, Comment: "entity.user.field.salt", Default: ""}, {Name: "phone", Type: field.TypeString, Size: 32, Comment: "entity.user.field.phone", Default: ""}, {Name: "email", Type: field.TypeString, Size: 64, Comment: "entity.user.field.email", Default: ""}, + {Name: "i18n", Type: field.TypeString, Size: 64, Comment: "entity.user.field.i18n", Default: ""}, {Name: "department", Type: field.TypeString, Size: 64, Comment: "entity.user.field.department", Default: ""}, {Name: "remark", Type: field.TypeString, Size: 1024, Comment: "entity.user.field.remark", Default: ""}, {Name: "token", Type: field.TypeString, Size: 512, Comment: "entity.user.field.token", Default: ""}, @@ -460,7 +461,7 @@ var ( { Name: "user_status", Unique: false, - Columns: []*schema.Column{SysUsersColumns[20]}, + Columns: []*schema.Column{SysUsersColumns[21]}, }, }, } @@ -571,17 +572,17 @@ var ( {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.view.field.keyword.comment"}, - {Name: "scope", Type: field.TypeString, Comment: "entity.view.field.scope.comment", Default: "default"}, - {Name: "name", Type: field.TypeString, Comment: "entity.view.field.name.comment"}, - {Name: "type", Type: field.TypeEnum, Comment: "entity.view.field.type.comment", Enums: []string{"T", "G", "M", "L", "P", "B", "E", "R", "U"}, Default: "U"}, - {Name: "component", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.component.comment"}, - {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.path.comment"}, - {Name: "icon", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.icon.comment"}, - {Name: "visible", Type: field.TypeBool, Comment: "entity.view.field.visible.comment", Default: true}, - {Name: "sequence", Type: field.TypeInt, Comment: "entity.view.field.sequence.comment", Default: 0}, - {Name: "tree_path", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.tree_path.comment"}, - {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "entity.view.field.parent_id.comment"}, + {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.view.field.keyword"}, + {Name: "scope", Type: field.TypeString, Comment: "entity.view.field.scope", Default: "default"}, + {Name: "name", Type: field.TypeString, Comment: "entity.view.field.name"}, + {Name: "type", Type: field.TypeEnum, Comment: "entity.view.field.type", Enums: []string{"T", "G", "M", "L", "P", "B", "E", "R", "U"}, Default: "U"}, + {Name: "component", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.component"}, + {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.path"}, + {Name: "icon", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.icon"}, + {Name: "visible", Type: field.TypeBool, Comment: "entity.view.field.visible", Default: true}, + {Name: "sequence", Type: field.TypeInt, Comment: "entity.view.field.sequence", Default: 0}, + {Name: "tree_path", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.tree_path"}, + {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "entity.view.field.parent_id"}, } // SysViewsTable holds the schema information for the "sys_views" table. SysViewsTable = &schema.Table{ diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index 6a072de8..b7d3e1ba 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -2941,7 +2941,8 @@ type PermissionMutation struct { description *string data_scope *string data_rules *map[string]string - status *permission.Status + status *enums.Status + addstatus *enums.Status actions *permission.Actions clearedFields map[string]struct{} roles map[int64]struct{} @@ -3343,12 +3344,13 @@ func (m *PermissionMutation) ResetDataRules() { } // SetStatus sets the "status" field. -func (m *PermissionMutation) SetStatus(pe permission.Status) { - m.status = &pe +func (m *PermissionMutation) SetStatus(e enums.Status) { + m.status = &e + m.addstatus = nil } // Status returns the value of the "status" field in the mutation. -func (m *PermissionMutation) Status() (r permission.Status, exists bool) { +func (m *PermissionMutation) Status() (r enums.Status, exists bool) { v := m.status if v == nil { return @@ -3359,7 +3361,7 @@ func (m *PermissionMutation) Status() (r permission.Status, exists bool) { // OldStatus returns the old "status" field's value of the Permission entity. // If the Permission object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *PermissionMutation) OldStatus(ctx context.Context) (v permission.Status, err error) { +func (m *PermissionMutation) OldStatus(ctx context.Context) (v enums.Status, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStatus is only allowed on UpdateOne operations") } @@ -3373,9 +3375,28 @@ func (m *PermissionMutation) OldStatus(ctx context.Context) (v permission.Status return oldValue.Status, nil } +// AddStatus adds e to the "status" field. +func (m *PermissionMutation) AddStatus(e enums.Status) { + if m.addstatus != nil { + *m.addstatus += e + } else { + m.addstatus = &e + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *PermissionMutation) AddedStatus() (r enums.Status, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + // ResetStatus resets all changes to the "status" field. func (m *PermissionMutation) ResetStatus() { m.status = nil + m.addstatus = nil } // SetActions sets the "actions" field. @@ -4020,7 +4041,7 @@ func (m *PermissionMutation) SetField(name string, value ent.Value) error { m.SetDataRules(v) return nil case permission.FieldStatus: - v, ok := value.(permission.Status) + v, ok := value.(enums.Status) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -4040,13 +4061,21 @@ func (m *PermissionMutation) SetField(name string, value ent.Value) error { // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *PermissionMutation) AddedFields() []string { - return nil + var fields []string + if m.addstatus != nil { + fields = append(fields, permission.FieldStatus) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *PermissionMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case permission.FieldStatus: + return m.AddedStatus() + } return nil, false } @@ -4055,6 +4084,13 @@ func (m *PermissionMutation) AddedField(name string) (ent.Value, bool) { // type. func (m *PermissionMutation) AddField(name string, value ent.Value) error { switch name { + case permission.FieldStatus: + v, ok := value.(enums.Status) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil } return fmt.Errorf("unknown Permission numeric field %s", name) } @@ -6364,7 +6400,8 @@ type ResourceMutation struct { version_id *string last_sync_version_id *string sync_status *string - status *resource.Status + status *enums.Status + addstatus *enums.Status clearedFields map[string]struct{} views map[int64]struct{} removedviews map[int64]struct{} @@ -6920,12 +6957,13 @@ func (m *ResourceMutation) ResetSyncStatus() { } // SetStatus sets the "status" field. -func (m *ResourceMutation) SetStatus(r resource.Status) { - m.status = &r +func (m *ResourceMutation) SetStatus(e enums.Status) { + m.status = &e + m.addstatus = nil } // Status returns the value of the "status" field in the mutation. -func (m *ResourceMutation) Status() (r resource.Status, exists bool) { +func (m *ResourceMutation) Status() (r enums.Status, exists bool) { v := m.status if v == nil { return @@ -6936,7 +6974,7 @@ func (m *ResourceMutation) Status() (r resource.Status, exists bool) { // OldStatus returns the old "status" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldStatus(ctx context.Context) (v resource.Status, err error) { +func (m *ResourceMutation) OldStatus(ctx context.Context) (v enums.Status, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldStatus is only allowed on UpdateOne operations") } @@ -6950,9 +6988,28 @@ func (m *ResourceMutation) OldStatus(ctx context.Context) (v resource.Status, er return oldValue.Status, nil } +// AddStatus adds e to the "status" field. +func (m *ResourceMutation) AddStatus(e enums.Status) { + if m.addstatus != nil { + *m.addstatus += e + } else { + m.addstatus = &e + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *ResourceMutation) AddedStatus() (r enums.Status, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + // ResetStatus resets all changes to the "status" field. func (m *ResourceMutation) ResetStatus() { m.status = nil + m.addstatus = nil } // AddViewIDs adds the "views" edge to the View entity by ids. @@ -7340,7 +7397,7 @@ func (m *ResourceMutation) SetField(name string, value ent.Value) error { m.SetSyncStatus(v) return nil case resource.FieldStatus: - v, ok := value.(resource.Status) + v, ok := value.(enums.Status) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -7353,13 +7410,21 @@ func (m *ResourceMutation) SetField(name string, value ent.Value) error { // AddedFields returns all numeric fields that were incremented/decremented during // this mutation. func (m *ResourceMutation) AddedFields() []string { - return nil + var fields []string + if m.addstatus != nil { + fields = append(fields, resource.FieldStatus) + } + return fields } // AddedField returns the numeric value that was incremented/decremented on a field // with the given name. The second boolean return value indicates that this field // was not set, or was not defined in the schema. func (m *ResourceMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case resource.FieldStatus: + return m.AddedStatus() + } return nil, false } @@ -7368,6 +7433,13 @@ func (m *ResourceMutation) AddedField(name string) (ent.Value, bool) { // type. func (m *ResourceMutation) AddField(name string, value ent.Value) error { switch name { + case resource.FieldStatus: + v, ok := value.(enums.Status) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil } return fmt.Errorf("unknown Resource numeric field %s", name) } @@ -9253,6 +9325,7 @@ type UserMutation struct { salt *string phone *string email *string + i18n *string department *string remark *string token *string @@ -10049,6 +10122,42 @@ func (m *UserMutation) ResetEmail() { m.email = nil } +// SetI18n sets the "i18n" field. +func (m *UserMutation) SetI18n(s string) { + m.i18n = &s +} + +// I18n returns the value of the "i18n" field in the mutation. +func (m *UserMutation) I18n() (r string, exists bool) { + v := m.i18n + if v == nil { + return + } + return *v, true +} + +// OldI18n returns the old "i18n" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldI18n(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldI18n is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldI18n requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldI18n: %w", err) + } + return oldValue.I18n, nil +} + +// ResetI18n resets all changes to the "i18n" field. +func (m *UserMutation) ResetI18n() { + m.i18n = nil +} + // SetDepartment sets the "department" field. func (m *UserMutation) SetDepartment(s string) { m.department = &s @@ -10800,7 +10909,7 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 26) + fields := make([]string, 0, 27) if m.create_author != nil { fields = append(fields, user.FieldCreateAuthor) } @@ -10849,6 +10958,9 @@ func (m *UserMutation) Fields() []string { if m.email != nil { fields = append(fields, user.FieldEmail) } + if m.i18n != nil { + fields = append(fields, user.FieldI18n) + } if m.department != nil { fields = append(fields, user.FieldDepartment) } @@ -10919,6 +11031,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.Phone() case user.FieldEmail: return m.Email() + case user.FieldI18n: + return m.I18n() case user.FieldDepartment: return m.Department() case user.FieldRemark: @@ -10980,6 +11094,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldPhone(ctx) case user.FieldEmail: return m.OldEmail(ctx) + case user.FieldI18n: + return m.OldI18n(ctx) case user.FieldDepartment: return m.OldDepartment(ctx) case user.FieldRemark: @@ -11121,6 +11237,13 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetEmail(v) return nil + case user.FieldI18n: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetI18n(v) + return nil case user.FieldDepartment: v, ok := value.(string) if !ok { @@ -11354,6 +11477,9 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldEmail: m.ResetEmail() return nil + case user.FieldI18n: + m.ResetI18n() + return nil case user.FieldDepartment: m.ResetDepartment() return nil diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index 70383d0f..385b01ea 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -358,9 +358,8 @@ func (m *PermissionMutation) SetFieldsSkipZero(input *Permission, fields ...stri m.SetDataRules(input.DataRules) } case permission.FieldStatus: - var zero permission.Status - // check permission.Status with sql.NullString if it is empty - if input.Status != zero { + // check enums.Status with sql.NullInt64 if it is zero + if input.Status != 0 { m.SetStatus(input.Status) } case permission.FieldActions: @@ -633,9 +632,8 @@ func (m *ResourceMutation) SetFieldsSkipZero(input *Resource, fields ...string) m.SetSyncStatus(input.SyncStatus) } case resource.FieldStatus: - var zero resource.Status - // check resource.Status with sql.NullString if it is empty - if input.Status != zero { + // check enums.Status with sql.NullInt64 if it is zero + if input.Status != 0 { m.SetStatus(input.Status) } case resource.FieldID: @@ -819,6 +817,8 @@ func (m *UserMutation) SetFields(input *User, fields ...string) error { m.SetPhone(input.Phone) case user.FieldEmail: m.SetEmail(input.Email) + case user.FieldI18n: + m.SetI18n(input.I18n) case user.FieldDepartment: m.SetDepartment(input.Department) case user.FieldRemark: @@ -934,6 +934,11 @@ func (m *UserMutation) SetFieldsSkipZero(input *User, fields ...string) error { if input.Email != "" { m.SetEmail(input.Email) } + case user.FieldI18n: + // check string with sql.NullString if it is empty + if input.I18n != "" { + m.SetI18n(input.I18n) + } case user.FieldDepartment: // check string with sql.NullString if it is empty if input.Department != "" { diff --git a/internal/data/entity/ent/permission.go b/internal/data/entity/ent/permission.go index c670cca9..d474d357 100644 --- a/internal/data/entity/ent/permission.go +++ b/internal/data/entity/ent/permission.go @@ -6,6 +6,7 @@ import ( "encoding/json" "fmt" "origadmin/application/admin/internal/data/entity/ent/permission" + "origadmin/application/admin/internal/data/enums" "strings" "time" @@ -33,8 +34,8 @@ type Permission struct { DataScope string `json:"data_scope,omitempty"` // entity.permission.field.data_rules DataRules map[string]string `json:"data_rules,omitempty"` - // entity.permission.field.status.comment - Status permission.Status `json:"status,omitempty"` + // entity.permission.field.status + Status enums.Status `json:"status,omitempty"` // entity.permission.field.actions Actions permission.Actions `json:"actions,omitempty"` // Edges holds the relations/edges for other nodes in the graph. @@ -145,9 +146,9 @@ func (*Permission) scanValues(columns []string) ([]any, error) { switch columns[i] { case permission.FieldDataRules: values[i] = new([]byte) - case permission.FieldID: + case permission.FieldID, permission.FieldStatus: values[i] = new(sql.NullInt64) - case permission.FieldName, permission.FieldKeyword, permission.FieldDescription, permission.FieldDataScope, permission.FieldStatus, permission.FieldActions: + case permission.FieldName, permission.FieldKeyword, permission.FieldDescription, permission.FieldDataScope, permission.FieldActions: values[i] = new(sql.NullString) case permission.FieldCreateTime, permission.FieldUpdateTime: values[i] = new(sql.NullTime) @@ -217,10 +218,10 @@ func (_m *Permission) assignValues(columns []string, values []any) error { } } case permission.FieldStatus: - if value, ok := values[i].(*sql.NullString); !ok { + if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - _m.Status = permission.Status(value.String) + _m.Status = enums.Status(value.Int64) } case permission.FieldActions: if value, ok := values[i].(*sql.NullString); !ok { diff --git a/internal/data/entity/ent/permission/permission.go b/internal/data/entity/ent/permission/permission.go index 903ee53c..f6787ac4 100644 --- a/internal/data/entity/ent/permission/permission.go +++ b/internal/data/entity/ent/permission/permission.go @@ -4,6 +4,7 @@ package permission import ( "fmt" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -159,38 +160,14 @@ var ( DescriptionValidator func(string) error // DefaultDataScope holds the default value on creation for the "data_scope" field. DefaultDataScope string + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus enums.Status // DefaultID holds the default value on creation for the "id" field. DefaultID func() int64 // IDValidator is a validator for the "id" field. It is called by the builders before save. IDValidator func(int64) error ) -// Status defines the type for the "status" enum field. -type Status string - -// StatusEnabled is the default value of the Status enum. -const DefaultStatus = StatusEnabled - -// Status values. -const ( - StatusEnabled Status = "enabled" - StatusDisabled Status = "disabled" -) - -func (s Status) String() string { - return string(s) -} - -// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. -func StatusValidator(s Status) error { - switch s { - case StatusEnabled, StatusDisabled: - return nil - default: - return fmt.Errorf("permission: invalid enum value for status field: %q", s) - } -} - // Actions defines the type for the "actions" enum field. type Actions string diff --git a/internal/data/entity/ent/permission/where.go b/internal/data/entity/ent/permission/where.go index 4a97f59f..77a20238 100644 --- a/internal/data/entity/ent/permission/where.go +++ b/internal/data/entity/ent/permission/where.go @@ -4,6 +4,7 @@ package permission import ( "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -85,6 +86,12 @@ func DataScope(v string) predicate.Permission { return predicate.Permission(sql.FieldEQ(FieldDataScope, v)) } +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v enums.Status) predicate.Permission { + vc := int8(v) + return predicate.Permission(sql.FieldEQ(FieldStatus, vc)) +} + // CreateTimeEQ applies the EQ predicate on the "create_time" field. func CreateTimeEQ(v time.Time) predicate.Permission { return predicate.Permission(sql.FieldEQ(FieldCreateTime, v)) @@ -436,23 +443,57 @@ func DataRulesNotNil() predicate.Permission { } // StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v Status) predicate.Permission { - return predicate.Permission(sql.FieldEQ(FieldStatus, v)) +func StatusEQ(v enums.Status) predicate.Permission { + vc := int8(v) + return predicate.Permission(sql.FieldEQ(FieldStatus, vc)) } // StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v Status) predicate.Permission { - return predicate.Permission(sql.FieldNEQ(FieldStatus, v)) +func StatusNEQ(v enums.Status) predicate.Permission { + vc := int8(v) + return predicate.Permission(sql.FieldNEQ(FieldStatus, vc)) } // StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...Status) predicate.Permission { - return predicate.Permission(sql.FieldIn(FieldStatus, vs...)) +func StatusIn(vs ...enums.Status) predicate.Permission { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Permission(sql.FieldIn(FieldStatus, v...)) } // StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...Status) predicate.Permission { - return predicate.Permission(sql.FieldNotIn(FieldStatus, vs...)) +func StatusNotIn(vs ...enums.Status) predicate.Permission { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Permission(sql.FieldNotIn(FieldStatus, v...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v enums.Status) predicate.Permission { + vc := int8(v) + return predicate.Permission(sql.FieldGT(FieldStatus, vc)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v enums.Status) predicate.Permission { + vc := int8(v) + return predicate.Permission(sql.FieldGTE(FieldStatus, vc)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v enums.Status) predicate.Permission { + vc := int8(v) + return predicate.Permission(sql.FieldLT(FieldStatus, vc)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v enums.Status) predicate.Permission { + vc := int8(v) + return predicate.Permission(sql.FieldLTE(FieldStatus, vc)) } // ActionsEQ applies the EQ predicate on the "actions" field. diff --git a/internal/data/entity/ent/permission_create.go b/internal/data/entity/ent/permission_create.go index f81b48c9..723c06f4 100644 --- a/internal/data/entity/ent/permission_create.go +++ b/internal/data/entity/ent/permission_create.go @@ -15,6 +15,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/rolepermission" "origadmin/application/admin/internal/data/entity/ent/view" "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -111,13 +112,13 @@ func (_c *PermissionCreate) SetDataRules(v map[string]string) *PermissionCreate } // SetStatus sets the "status" field. -func (_c *PermissionCreate) SetStatus(v permission.Status) *PermissionCreate { +func (_c *PermissionCreate) SetStatus(v enums.Status) *PermissionCreate { _c.mutation.SetStatus(v) return _c } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *PermissionCreate) SetNillableStatus(v *permission.Status) *PermissionCreate { +func (_c *PermissionCreate) SetNillableStatus(v *enums.Status) *PermissionCreate { if v != nil { _c.SetStatus(*v) } @@ -379,11 +380,6 @@ func (_c *PermissionCreate) check() error { if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Permission.status"`)} } - if v, ok := _c.mutation.Status(); ok { - if err := permission.StatusValidator(v); err != nil { - return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Permission.status": %w`, err)} - } - } if _, ok := _c.mutation.Actions(); !ok { return &ValidationError{Name: "actions", err: errors.New(`ent: missing required field "Permission.actions"`)} } @@ -458,7 +454,7 @@ func (_c *PermissionCreate) createSpec() (*Permission, *sqlgraph.CreateSpec) { _node.DataRules = value } if value, ok := _c.mutation.Status(); ok { - _spec.SetField(permission.FieldStatus, field.TypeEnum, value) + _spec.SetField(permission.FieldStatus, field.TypeInt8, value) _node.Status = value } if value, ok := _c.mutation.Actions(); ok { diff --git a/internal/data/entity/ent/permission_query.go b/internal/data/entity/ent/permission_query.go index 26787d3f..a195f0c9 100644 --- a/internal/data/entity/ent/permission_query.go +++ b/internal/data/entity/ent/permission_query.go @@ -1217,7 +1217,7 @@ func (_q *PermissionQuery) Modify(modifiers ...func(s *sql.Selector)) *Permissio // Description string `json:"description,omitempty"` // DataScope string `json:"data_scope,omitempty"` // DataRules map[string]string `json:"data_rules,omitempty"` -// Status permission.Status `json:"status,omitempty"` +// Status enums.Status `json:"status,omitempty"` // Actions permission.Actions `json:"actions,omitempty"` // } // diff --git a/internal/data/entity/ent/permission_update.go b/internal/data/entity/ent/permission_update.go index dac41e34..0f15193d 100644 --- a/internal/data/entity/ent/permission_update.go +++ b/internal/data/entity/ent/permission_update.go @@ -16,6 +16,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/rolepermission" "origadmin/application/admin/internal/data/entity/ent/view" "origadmin/application/admin/internal/data/entity/ent/viewpermission" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -112,19 +113,26 @@ func (_u *PermissionUpdate) ClearDataRules() *PermissionUpdate { } // SetStatus sets the "status" field. -func (_u *PermissionUpdate) SetStatus(v permission.Status) *PermissionUpdate { +func (_u *PermissionUpdate) SetStatus(v enums.Status) *PermissionUpdate { + _u.mutation.ResetStatus() _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *PermissionUpdate) SetNillableStatus(v *permission.Status) *PermissionUpdate { +func (_u *PermissionUpdate) SetNillableStatus(v *enums.Status) *PermissionUpdate { if v != nil { _u.SetStatus(*v) } return _u } +// AddStatus adds value to the "status" field. +func (_u *PermissionUpdate) AddStatus(v enums.Status) *PermissionUpdate { + _u.mutation.AddStatus(v) + return _u +} + // SetActions sets the "actions" field. func (_u *PermissionUpdate) SetActions(v permission.Actions) *PermissionUpdate { _u.mutation.SetActions(v) @@ -485,11 +493,6 @@ func (_u *PermissionUpdate) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} } } - if v, ok := _u.mutation.Status(); ok { - if err := permission.StatusValidator(v); err != nil { - return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Permission.status": %w`, err)} - } - } if v, ok := _u.mutation.Actions(); ok { if err := permission.ActionsValidator(v); err != nil { return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} @@ -538,7 +541,10 @@ func (_u *PermissionUpdate) sqlSave(ctx context.Context) (_node int, err error) _spec.ClearField(permission.FieldDataRules, field.TypeJSON) } if value, ok := _u.mutation.Status(); ok { - _spec.SetField(permission.FieldStatus, field.TypeEnum, value) + _spec.SetField(permission.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(permission.FieldStatus, field.TypeInt8, value) } if value, ok := _u.mutation.Actions(); ok { _spec.SetField(permission.FieldActions, field.TypeEnum, value) @@ -1021,19 +1027,26 @@ func (_u *PermissionUpdateOne) ClearDataRules() *PermissionUpdateOne { } // SetStatus sets the "status" field. -func (_u *PermissionUpdateOne) SetStatus(v permission.Status) *PermissionUpdateOne { +func (_u *PermissionUpdateOne) SetStatus(v enums.Status) *PermissionUpdateOne { + _u.mutation.ResetStatus() _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *PermissionUpdateOne) SetNillableStatus(v *permission.Status) *PermissionUpdateOne { +func (_u *PermissionUpdateOne) SetNillableStatus(v *enums.Status) *PermissionUpdateOne { if v != nil { _u.SetStatus(*v) } return _u } +// AddStatus adds value to the "status" field. +func (_u *PermissionUpdateOne) AddStatus(v enums.Status) *PermissionUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + // SetActions sets the "actions" field. func (_u *PermissionUpdateOne) SetActions(v permission.Actions) *PermissionUpdateOne { _u.mutation.SetActions(v) @@ -1407,11 +1420,6 @@ func (_u *PermissionUpdateOne) check() error { return &ValidationError{Name: "description", err: fmt.Errorf(`ent: validator failed for field "Permission.description": %w`, err)} } } - if v, ok := _u.mutation.Status(); ok { - if err := permission.StatusValidator(v); err != nil { - return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Permission.status": %w`, err)} - } - } if v, ok := _u.mutation.Actions(); ok { if err := permission.ActionsValidator(v); err != nil { return &ValidationError{Name: "actions", err: fmt.Errorf(`ent: validator failed for field "Permission.actions": %w`, err)} @@ -1477,7 +1485,10 @@ func (_u *PermissionUpdateOne) sqlSave(ctx context.Context) (_node *Permission, _spec.ClearField(permission.FieldDataRules, field.TypeJSON) } if value, ok := _u.mutation.Status(); ok { - _spec.SetField(permission.FieldStatus, field.TypeEnum, value) + _spec.SetField(permission.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(permission.FieldStatus, field.TypeInt8, value) } if value, ok := _u.mutation.Actions(); ok { _spec.SetField(permission.FieldActions, field.TypeEnum, value) diff --git a/internal/data/entity/ent/resource.go b/internal/data/entity/ent/resource.go index 7739c995..1fcf58c8 100644 --- a/internal/data/entity/ent/resource.go +++ b/internal/data/entity/ent/resource.go @@ -5,6 +5,7 @@ package ent import ( "fmt" "origadmin/application/admin/internal/data/entity/ent/resource" + "origadmin/application/admin/internal/data/enums" "strings" "time" @@ -22,26 +23,26 @@ type Resource struct { CreateTime time.Time `json:"create_time,omitempty"` // update_time.field.comment UpdateTime time.Time `json:"update_time,omitempty"` - // entity.resource.field.service_name.comment + // entity.resource.field.service_name ServiceName string `json:"service_name,omitempty"` - // entity.resource.field.keyword.comment + // entity.resource.field.keyword Keyword string `json:"keyword,omitempty"` - // entity.resource.field.path.comment + // entity.resource.field.path Path string `json:"path,omitempty"` - // entity.resource.field.method.comment + // entity.resource.field.method Method string `json:"method,omitempty"` - // entity.resource.field.operation.comment + // entity.resource.field.operation Operation string `json:"operation,omitempty"` - // entity.resource.field.policy.comment + // entity.resource.field.policy Policy string `json:"policy,omitempty"` - // entity.resource.field.version_id.comment + // entity.resource.field.version_id VersionID string `json:"version_id,omitempty"` - // entity.resource.field.last_sync_version_id.comment + // entity.resource.field.last_sync_version_id LastSyncVersionID string `json:"last_sync_version_id,omitempty"` - // entity.resource.field.sync_status.comment + // entity.resource.field.sync_status SyncStatus string `json:"sync_status,omitempty"` - // entity.resource.field.status.comment - Status resource.Status `json:"status,omitempty"` + // entity.resource.field.status + Status enums.Status `json:"status,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ResourceQuery when eager-loading is set. Edges ResourceEdges `json:"edges"` @@ -93,9 +94,9 @@ func (*Resource) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case resource.FieldID: + case resource.FieldID, resource.FieldStatus: values[i] = new(sql.NullInt64) - case resource.FieldServiceName, resource.FieldKeyword, resource.FieldPath, resource.FieldMethod, resource.FieldOperation, resource.FieldPolicy, resource.FieldVersionID, resource.FieldLastSyncVersionID, resource.FieldSyncStatus, resource.FieldStatus: + case resource.FieldServiceName, resource.FieldKeyword, resource.FieldPath, resource.FieldMethod, resource.FieldOperation, resource.FieldPolicy, resource.FieldVersionID, resource.FieldLastSyncVersionID, resource.FieldSyncStatus: values[i] = new(sql.NullString) case resource.FieldCreateTime, resource.FieldUpdateTime: values[i] = new(sql.NullTime) @@ -187,10 +188,10 @@ func (_m *Resource) assignValues(columns []string, values []any) error { _m.SyncStatus = value.String } case resource.FieldStatus: - if value, ok := values[i].(*sql.NullString); !ok { + if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { - _m.Status = resource.Status(value.String) + _m.Status = enums.Status(value.Int64) } default: _m.selectValues.Set(columns[i], values[i]) diff --git a/internal/data/entity/ent/resource/resource.go b/internal/data/entity/ent/resource/resource.go index 4b0b0da7..89e18a7b 100644 --- a/internal/data/entity/ent/resource/resource.go +++ b/internal/data/entity/ent/resource/resource.go @@ -3,7 +3,7 @@ package resource import ( - "fmt" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -119,38 +119,14 @@ var ( DefaultLastSyncVersionID string // DefaultSyncStatus holds the default value on creation for the "sync_status" field. DefaultSyncStatus string + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus enums.Status // DefaultID holds the default value on creation for the "id" field. DefaultID func() int64 // IDValidator is a validator for the "id" field. It is called by the builders before save. IDValidator func(int64) error ) -// Status defines the type for the "status" enum field. -type Status string - -// StatusEnabled is the default value of the Status enum. -const DefaultStatus = StatusEnabled - -// Status values. -const ( - StatusEnabled Status = "enabled" - StatusDisabled Status = "disabled" -) - -func (s Status) String() string { - return string(s) -} - -// StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. -func StatusValidator(s Status) error { - switch s { - case StatusEnabled, StatusDisabled: - return nil - default: - return fmt.Errorf("resource: invalid enum value for status field: %q", s) - } -} - // OrderOption defines the ordering options for the Resource queries. type OrderOption func(*sql.Selector) diff --git a/internal/data/entity/ent/resource/where.go b/internal/data/entity/ent/resource/where.go index a83f7158..5ec2ee86 100644 --- a/internal/data/entity/ent/resource/where.go +++ b/internal/data/entity/ent/resource/where.go @@ -4,6 +4,7 @@ package resource import ( "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -105,6 +106,12 @@ func SyncStatus(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldSyncStatus, v)) } +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldEQ(FieldStatus, vc)) +} + // CreateTimeEQ applies the EQ predicate on the "create_time" field. func CreateTimeEQ(v time.Time) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldCreateTime, v)) @@ -801,23 +808,57 @@ func SyncStatusContainsFold(v string) predicate.Resource { } // StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v Status) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldStatus, v)) +func StatusEQ(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldEQ(FieldStatus, vc)) } // StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v Status) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldStatus, v)) +func StatusNEQ(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldNEQ(FieldStatus, vc)) } // StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...Status) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldStatus, vs...)) +func StatusIn(vs ...enums.Status) predicate.Resource { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Resource(sql.FieldIn(FieldStatus, v...)) } // StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...Status) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldStatus, vs...)) +func StatusNotIn(vs ...enums.Status) predicate.Resource { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Resource(sql.FieldNotIn(FieldStatus, v...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldGT(FieldStatus, vc)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldGTE(FieldStatus, vc)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldLT(FieldStatus, vc)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldLTE(FieldStatus, vc)) } // HasViews applies the HasEdge predicate on the "views" edge. diff --git a/internal/data/entity/ent/resource_create.go b/internal/data/entity/ent/resource_create.go index abcfac38..3f6b1b71 100644 --- a/internal/data/entity/ent/resource_create.go +++ b/internal/data/entity/ent/resource_create.go @@ -10,6 +10,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/view" "origadmin/application/admin/internal/data/entity/ent/viewresource" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -162,13 +163,13 @@ func (_c *ResourceCreate) SetNillableSyncStatus(v *string) *ResourceCreate { } // SetStatus sets the "status" field. -func (_c *ResourceCreate) SetStatus(v resource.Status) *ResourceCreate { +func (_c *ResourceCreate) SetStatus(v enums.Status) *ResourceCreate { _c.mutation.SetStatus(v) return _c } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableStatus(v *resource.Status) *ResourceCreate { +func (_c *ResourceCreate) SetNillableStatus(v *enums.Status) *ResourceCreate { if v != nil { _c.SetStatus(*v) } @@ -337,11 +338,6 @@ func (_c *ResourceCreate) check() error { if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Resource.status"`)} } - if v, ok := _c.mutation.Status(); ok { - if err := resource.StatusValidator(v); err != nil { - return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Resource.status": %w`, err)} - } - } if v, ok := _c.mutation.ID(); ok { if err := resource.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Resource.id": %w`, err)} @@ -424,7 +420,7 @@ func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { _node.SyncStatus = value } if value, ok := _c.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeEnum, value) + _spec.SetField(resource.FieldStatus, field.TypeInt8, value) _node.Status = value } if nodes := _c.mutation.ViewsIDs(); len(nodes) > 0 { diff --git a/internal/data/entity/ent/resource_query.go b/internal/data/entity/ent/resource_query.go index 18e9be90..5d5a3840 100644 --- a/internal/data/entity/ent/resource_query.go +++ b/internal/data/entity/ent/resource_query.go @@ -785,7 +785,7 @@ func (_q *ResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *ResourceSel // VersionID string `json:"version_id,omitempty"` // LastSyncVersionID string `json:"last_sync_version_id,omitempty"` // SyncStatus string `json:"sync_status,omitempty"` -// Status resource.Status `json:"status,omitempty"` +// Status enums.Status `json:"status,omitempty"` // } // // client.Resource.Query(). diff --git a/internal/data/entity/ent/resource_update.go b/internal/data/entity/ent/resource_update.go index bf62ce84..a7215054 100644 --- a/internal/data/entity/ent/resource_update.go +++ b/internal/data/entity/ent/resource_update.go @@ -11,6 +11,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/view" "origadmin/application/admin/internal/data/entity/ent/viewresource" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -183,19 +184,26 @@ func (_u *ResourceUpdate) SetNillableSyncStatus(v *string) *ResourceUpdate { } // SetStatus sets the "status" field. -func (_u *ResourceUpdate) SetStatus(v resource.Status) *ResourceUpdate { +func (_u *ResourceUpdate) SetStatus(v enums.Status) *ResourceUpdate { + _u.mutation.ResetStatus() _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableStatus(v *resource.Status) *ResourceUpdate { +func (_u *ResourceUpdate) SetNillableStatus(v *enums.Status) *ResourceUpdate { if v != nil { _u.SetStatus(*v) } return _u } +// AddStatus adds value to the "status" field. +func (_u *ResourceUpdate) AddStatus(v enums.Status) *ResourceUpdate { + _u.mutation.AddStatus(v) + return _u +} + // AddViewIDs adds the "views" edge to the View entity by IDs. func (_u *ResourceUpdate) AddViewIDs(ids ...int64) *ResourceUpdate { _u.mutation.AddViewIDs(ids...) @@ -352,11 +360,6 @@ func (_u *ResourceUpdate) check() error { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} } } - if v, ok := _u.mutation.Status(); ok { - if err := resource.StatusValidator(v); err != nil { - return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Resource.status": %w`, err)} - } - } return nil } @@ -418,7 +421,10 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec.SetField(resource.FieldSyncStatus, field.TypeString, value) } if value, ok := _u.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeEnum, value) + _spec.SetField(resource.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(resource.FieldStatus, field.TypeInt8, value) } if _u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ @@ -749,19 +755,26 @@ func (_u *ResourceUpdateOne) SetNillableSyncStatus(v *string) *ResourceUpdateOne } // SetStatus sets the "status" field. -func (_u *ResourceUpdateOne) SetStatus(v resource.Status) *ResourceUpdateOne { +func (_u *ResourceUpdateOne) SetStatus(v enums.Status) *ResourceUpdateOne { + _u.mutation.ResetStatus() _u.mutation.SetStatus(v) return _u } // SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableStatus(v *resource.Status) *ResourceUpdateOne { +func (_u *ResourceUpdateOne) SetNillableStatus(v *enums.Status) *ResourceUpdateOne { if v != nil { _u.SetStatus(*v) } return _u } +// AddStatus adds value to the "status" field. +func (_u *ResourceUpdateOne) AddStatus(v enums.Status) *ResourceUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + // AddViewIDs adds the "views" edge to the View entity by IDs. func (_u *ResourceUpdateOne) AddViewIDs(ids ...int64) *ResourceUpdateOne { _u.mutation.AddViewIDs(ids...) @@ -931,11 +944,6 @@ func (_u *ResourceUpdateOne) check() error { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} } } - if v, ok := _u.mutation.Status(); ok { - if err := resource.StatusValidator(v); err != nil { - return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "Resource.status": %w`, err)} - } - } return nil } @@ -1014,7 +1022,10 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err _spec.SetField(resource.FieldSyncStatus, field.TypeString, value) } if value, ok := _u.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeEnum, value) + _spec.SetField(resource.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(resource.FieldStatus, field.TypeInt8, value) } if _u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index 70685e9e..009cb721 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -206,6 +206,10 @@ func init() { permissionDescDataScope := permissionFields[3].Descriptor() // permission.DefaultDataScope holds the default value on creation for the data_scope field. permission.DefaultDataScope = permissionDescDataScope.Default.(string) + // permissionDescStatus is the schema descriptor for status field. + permissionDescStatus := permissionFields[5].Descriptor() + // permission.DefaultStatus holds the default value on creation for the status field. + permission.DefaultStatus = enums.Status(permissionDescStatus.Default.(int8)) // permissionDescID is the schema descriptor for id field. permissionDescID := permissionMixinFields0[0].Descriptor() // permission.DefaultID holds the default value on creation for the id field. @@ -328,6 +332,10 @@ func init() { resourceDescSyncStatus := resourceFields[8].Descriptor() // resource.DefaultSyncStatus holds the default value on creation for the sync_status field. resource.DefaultSyncStatus = resourceDescSyncStatus.Default.(string) + // resourceDescStatus is the schema descriptor for status field. + resourceDescStatus := resourceFields[9].Descriptor() + // resource.DefaultStatus holds the default value on creation for the status field. + resource.DefaultStatus = enums.Status(resourceDescStatus.Default.(int8)) // resourceDescID is the schema descriptor for id field. resourceDescID := resourceMixinFields0[0].Descriptor() // resource.DefaultID holds the default value on creation for the id field. @@ -492,50 +500,56 @@ func init() { user.DefaultEmail = userDescEmail.Default.(string) // user.EmailValidator is a validator for the "email" field. It is called by the builders before save. user.EmailValidator = userDescEmail.Validators[0].(func(string) error) + // userDescI18n is the schema descriptor for i18n field. + userDescI18n := userFields[11].Descriptor() + // user.DefaultI18n holds the default value on creation for the i18n field. + user.DefaultI18n = userDescI18n.Default.(string) + // user.I18nValidator is a validator for the "i18n" field. It is called by the builders before save. + user.I18nValidator = userDescI18n.Validators[0].(func(string) error) // userDescDepartment is the schema descriptor for department field. - userDescDepartment := userFields[11].Descriptor() + userDescDepartment := userFields[12].Descriptor() // user.DefaultDepartment holds the default value on creation for the department field. user.DefaultDepartment = userDescDepartment.Default.(string) // user.DepartmentValidator is a validator for the "department" field. It is called by the builders before save. user.DepartmentValidator = userDescDepartment.Validators[0].(func(string) error) // userDescRemark is the schema descriptor for remark field. - userDescRemark := userFields[12].Descriptor() + userDescRemark := userFields[13].Descriptor() // user.DefaultRemark holds the default value on creation for the remark field. user.DefaultRemark = userDescRemark.Default.(string) // user.RemarkValidator is a validator for the "remark" field. It is called by the builders before save. user.RemarkValidator = userDescRemark.Validators[0].(func(string) error) // userDescToken is the schema descriptor for token field. - userDescToken := userFields[13].Descriptor() + userDescToken := userFields[14].Descriptor() // user.DefaultToken holds the default value on creation for the token field. user.DefaultToken = userDescToken.Default.(string) // user.TokenValidator is a validator for the "token" field. It is called by the builders before save. user.TokenValidator = userDescToken.Validators[0].(func(string) error) // userDescStatus is the schema descriptor for status field. - userDescStatus := userFields[14].Descriptor() + userDescStatus := userFields[15].Descriptor() // user.DefaultStatus holds the default value on creation for the status field. user.DefaultStatus = enums.Status(userDescStatus.Default.(int8)) // userDescIsSystem is the schema descriptor for is_system field. - userDescIsSystem := userFields[15].Descriptor() + userDescIsSystem := userFields[16].Descriptor() // user.DefaultIsSystem holds the default value on creation for the is_system field. user.DefaultIsSystem = userDescIsSystem.Default.(bool) // userDescLastLoginIP is the schema descriptor for last_login_ip field. - userDescLastLoginIP := userFields[16].Descriptor() + userDescLastLoginIP := userFields[17].Descriptor() // user.DefaultLastLoginIP holds the default value on creation for the last_login_ip field. user.DefaultLastLoginIP = userDescLastLoginIP.Default.(string) // user.LastLoginIPValidator is a validator for the "last_login_ip" field. It is called by the builders before save. user.LastLoginIPValidator = userDescLastLoginIP.Validators[0].(func(string) error) // userDescLoginIP is the schema descriptor for login_ip field. - userDescLoginIP := userFields[17].Descriptor() + userDescLoginIP := userFields[18].Descriptor() // user.DefaultLoginIP holds the default value on creation for the login_ip field. user.DefaultLoginIP = userDescLoginIP.Default.(string) // user.LoginIPValidator is a validator for the "login_ip" field. It is called by the builders before save. user.LoginIPValidator = userDescLoginIP.Validators[0].(func(string) error) // userDescLastLoginTime is the schema descriptor for last_login_time field. - userDescLastLoginTime := userFields[18].Descriptor() + userDescLastLoginTime := userFields[19].Descriptor() // user.DefaultLastLoginTime holds the default value on creation for the last_login_time field. user.DefaultLastLoginTime = userDescLastLoginTime.Default.(func() time.Time) // userDescLoginTime is the schema descriptor for login_time field. - userDescLoginTime := userFields[19].Descriptor() + userDescLoginTime := userFields[20].Descriptor() // user.DefaultLoginTime holds the default value on creation for the login_time field. user.DefaultLoginTime = userDescLoginTime.Default.(func() time.Time) // userDescID is the schema descriptor for id field. @@ -722,6 +736,6 @@ func init() { } const ( - Version = "v0.14.5" // Version of ent codegen. - Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen. + Version = "v0.14.6-0.20251211203232-397ebe9f39af" // Version of ent codegen. + Sum = "h1:bTFOfVixGo0QXY69RnBIvUIYAJUrnkjqfV5UhU91hTU=" // Sum of ent codegen. ) diff --git a/internal/data/entity/ent/schema/permission.go b/internal/data/entity/ent/schema/permission.go index cae67037..b56f534c 100644 --- a/internal/data/entity/ent/schema/permission.go +++ b/internal/data/entity/ent/schema/permission.go @@ -12,6 +12,7 @@ import ( "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/helpers/ent/mixin" "origadmin/application/admin/internal/helpers/i18n" ) @@ -50,16 +51,10 @@ func (Permission) Fields() []ent.Field { field.JSON("data_rules", map[string]string{}). Optional(). Comment(i18n.Text("entity.permission.field.data_rules")), - field.Enum("status"). - Comment(i18n.Text("entity.permission.field.status.comment")). - Values("enabled", "disabled"). - Default("enabled"), - //field.JSON("conditions", []types.PermissionCondition{}). - // Optional(). - // Comment(i18n.Text("entity.permission.field.conditions")), - //field.JSON("access_control", types.PermissionAccessControl{}). - // Optional(). - // Comment(i18n.Text("entity.permission.field.access_control")), + field.Int8("status"). + GoType(enums.Status(0)). + Default(int8(enums.StatusActive)). + Comment(i18n.Text("entity.permission.field.status")), field.Enum("actions"). Values("read", "write", "delete", "manage"). Default("read"). diff --git a/internal/data/entity/ent/schema/resource.go b/internal/data/entity/ent/schema/resource.go index aa5bc924..58a840a3 100644 --- a/internal/data/entity/ent/schema/resource.go +++ b/internal/data/entity/ent/schema/resource.go @@ -6,6 +6,8 @@ import ( "entgo.io/ent/schema" "entgo.io/ent/schema/edge" "entgo.io/ent/schema/field" + + "origadmin/application/admin/internal/data/enums" "origadmin/application/admin/internal/helpers/ent/mixin" "origadmin/application/admin/internal/helpers/i18n" ) @@ -19,37 +21,38 @@ type Resource struct { func (Resource) Fields() []ent.Field { return []ent.Field{ field.String("service_name"). - Comment(i18n.Text("entity.resource.field.service_name.comment")), + Default(""). + Comment(i18n.Text("entity.resource.field.service_name")), field.String("keyword"). MaxLen(255). - Comment(i18n.Text("entity.resource.field.keyword.comment")). + Comment(i18n.Text("entity.resource.field.keyword")). Unique(). NotEmpty(), field.String("path"). - Comment(i18n.Text("entity.resource.field.path.comment")). + Comment(i18n.Text("entity.resource.field.path")). Optional(), field.String("method"). - Comment(i18n.Text("entity.resource.field.method.comment")). + Comment(i18n.Text("entity.resource.field.method")). Optional(), field.String("operation"). - Comment(i18n.Text("entity.resource.field.operation.comment")). + Comment(i18n.Text("entity.resource.field.operation")). Optional(), field.String("policy"). - Comment(i18n.Text("entity.resource.field.policy.comment")). + Comment(i18n.Text("entity.resource.field.policy")). Default(""), field.String("version_id"). - Comment(i18n.Text("entity.resource.field.version_id.comment")). + Comment(i18n.Text("entity.resource.field.version_id")). Default(""), field.String("last_sync_version_id"). - Comment(i18n.Text("entity.resource.field.last_sync_version_id.comment")). + Comment(i18n.Text("entity.resource.field.last_sync_version_id")). Default(""), field.String("sync_status"). - Comment(i18n.Text("entity.resource.field.sync_status.comment")). + Comment(i18n.Text("entity.resource.field.sync_status")). Default("Synced"), - field.Enum("status"). - Comment(i18n.Text("entity.resource.field.status.comment")). - Values("enabled", "disabled"). - Default("enabled"), + field.Int8("status"). + GoType(enums.Status(0)). + Default(int8(enums.StatusActive)). + Comment(i18n.Text("entity.resource.field.status")), } } diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index dadd1f32..b68de363 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -79,6 +79,9 @@ func (User) Fields() []ent.Field { MaxLen(64). Default(""). Comment(i18n.Text("entity.user.field.email")), // login email of user + field.String("i18n").MaxLen(64). + Default(""). + Comment("entity.user.field.i18n"), field.String("department"). MaxLen(64). Default(""). diff --git a/internal/data/entity/ent/schema/view.go b/internal/data/entity/ent/schema/view.go index 57d8f551..c306d680 100644 --- a/internal/data/entity/ent/schema/view.go +++ b/internal/data/entity/ent/schema/view.go @@ -22,19 +22,19 @@ type View struct { func (View) Fields() []ent.Field { return []ent.Field{ // Use OptionalFK for an optional foreign key, as designed in the mixin package. - mixin.OptionalFK("parent_id", i18n.Text("entity.view.field.parent_id.comment")), + mixin.OptionalFK("parent_id", i18n.Text("entity.view.field.parent_id")), field.String("keyword"). MaxLen(255). - Comment(i18n.Text("entity.view.field.keyword.comment")). + Comment(i18n.Text("entity.view.field.keyword")). Unique(). NotEmpty(), field.String("scope"). - Comment(i18n.Text("entity.view.field.scope.comment")). + Comment(i18n.Text("entity.view.field.scope")). Default("default"), field.String("name"). - Comment(i18n.Text("entity.view.field.name.comment")), + Comment(i18n.Text("entity.view.field.name")), field.Enum("type"). - Comment(i18n.Text("entity.view.field.type.comment")). + Comment(i18n.Text("entity.view.field.type")). Values( string(enums.ViewTypeRoot), string(enums.ViewTypeGroup), @@ -48,22 +48,22 @@ func (View) Fields() []ent.Field { ). Default(string(enums.ViewTypeUnknown)), field.String("component"). - Comment(i18n.Text("entity.view.field.component.comment")). + Comment(i18n.Text("entity.view.field.component")). Optional(), field.String("path"). - Comment(i18n.Text("entity.view.field.path.comment")). + Comment(i18n.Text("entity.view.field.path")). Optional(), field.String("icon"). - Comment(i18n.Text("entity.view.field.icon.comment")). + Comment(i18n.Text("entity.view.field.icon")). Optional(), field.Bool("visible"). - Comment(i18n.Text("entity.view.field.visible.comment")). + Comment(i18n.Text("entity.view.field.visible")). Default(true), field.Int("sequence"). - Comment(i18n.Text("entity.view.field.sequence.comment")). + Comment(i18n.Text("entity.view.field.sequence")). Default(0), field.String("tree_path"). - Comment(i18n.Text("entity.view.field.tree_path.comment")). + Comment(i18n.Text("entity.view.field.tree_path")). Optional(), } } diff --git a/internal/data/entity/ent/user.go b/internal/data/entity/ent/user.go index de7270ad..050fef8b 100644 --- a/internal/data/entity/ent/user.go +++ b/internal/data/entity/ent/user.go @@ -53,6 +53,8 @@ type User struct { Phone string `json:"phone,omitempty"` // entity.user.field.email Email string `json:"email,omitempty"` + // entity.user.field.i18n + I18n string `json:"i18n,omitempty"` // entity.user.field.department Department string `json:"department,omitempty"` // entity.user.field.remark @@ -161,7 +163,7 @@ func (*User) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case user.FieldID, user.FieldCreateAuthor, user.FieldUpdateAuthor, user.FieldStatus: values[i] = new(sql.NullInt64) - case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldEncryptedPassword, user.FieldSalt, user.FieldPhone, user.FieldEmail, user.FieldDepartment, user.FieldRemark, user.FieldToken, user.FieldLastLoginIP, user.FieldLoginIP: + case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldEncryptedPassword, user.FieldSalt, user.FieldPhone, user.FieldEmail, user.FieldI18n, user.FieldDepartment, user.FieldRemark, user.FieldToken, user.FieldLastLoginIP, user.FieldLoginIP: values[i] = new(sql.NullString) case user.FieldCreateTime, user.FieldUpdateTime, user.FieldDeleteTime, user.FieldLastLoginTime, user.FieldLoginTime, user.FieldSanctionDate: values[i] = new(sql.NullTime) @@ -283,6 +285,12 @@ func (_m *User) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Email = value.String } + case user.FieldI18n: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field i18n", values[i]) + } else if value.Valid { + _m.I18n = value.String + } case user.FieldDepartment: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field department", values[i]) @@ -459,6 +467,9 @@ func (_m *User) String() string { builder.WriteString("email=") builder.WriteString(_m.Email) builder.WriteString(", ") + builder.WriteString("i18n=") + builder.WriteString(_m.I18n) + builder.WriteString(", ") builder.WriteString("department=") builder.WriteString(_m.Department) builder.WriteString(", ") diff --git a/internal/data/entity/ent/user/user.go b/internal/data/entity/ent/user/user.go index 65c8add1..172866a3 100644 --- a/internal/data/entity/ent/user/user.go +++ b/internal/data/entity/ent/user/user.go @@ -49,6 +49,8 @@ const ( FieldPhone = "phone" // FieldEmail holds the string denoting the email field in the database. FieldEmail = "email" + // FieldI18n holds the string denoting the i18n field in the database. + FieldI18n = "i18n" // FieldDepartment holds the string denoting the department field in the database. FieldDepartment = "department" // FieldRemark holds the string denoting the remark field in the database. @@ -139,6 +141,7 @@ var Columns = []string{ FieldEncryptedPassword, FieldPhone, FieldEmail, + FieldI18n, FieldDepartment, FieldRemark, FieldToken, @@ -230,6 +233,10 @@ var ( DefaultEmail string // EmailValidator is a validator for the "email" field. It is called by the builders before save. EmailValidator func(string) error + // DefaultI18n holds the default value on creation for the "i18n" field. + DefaultI18n string + // I18nValidator is a validator for the "i18n" field. It is called by the builders before save. + I18nValidator func(string) error // DefaultDepartment holds the default value on creation for the "department" field. DefaultDepartment string // DepartmentValidator is a validator for the "department" field. It is called by the builders before save. @@ -379,6 +386,11 @@ func ByEmail(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldEmail, opts...).ToFunc() } +// ByI18n orders the results by the i18n field. +func ByI18n(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldI18n, opts...).ToFunc() +} + // ByDepartment orders the results by the department field. func ByDepartment(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDepartment, opts...).ToFunc() diff --git a/internal/data/entity/ent/user/where.go b/internal/data/entity/ent/user/where.go index c87f8fb3..f8ab5d8b 100644 --- a/internal/data/entity/ent/user/where.go +++ b/internal/data/entity/ent/user/where.go @@ -131,6 +131,11 @@ func Email(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldEmail, v)) } +// I18n applies equality check predicate on the "i18n" field. It's identical to I18nEQ. +func I18n(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldI18n, v)) +} + // Department applies equality check predicate on the "department" field. It's identical to DepartmentEQ. func Department(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldDepartment, v)) @@ -1082,6 +1087,71 @@ func EmailContainsFold(v string) predicate.User { return predicate.User(sql.FieldContainsFold(FieldEmail, v)) } +// I18nEQ applies the EQ predicate on the "i18n" field. +func I18nEQ(v string) predicate.User { + return predicate.User(sql.FieldEQ(FieldI18n, v)) +} + +// I18nNEQ applies the NEQ predicate on the "i18n" field. +func I18nNEQ(v string) predicate.User { + return predicate.User(sql.FieldNEQ(FieldI18n, v)) +} + +// I18nIn applies the In predicate on the "i18n" field. +func I18nIn(vs ...string) predicate.User { + return predicate.User(sql.FieldIn(FieldI18n, vs...)) +} + +// I18nNotIn applies the NotIn predicate on the "i18n" field. +func I18nNotIn(vs ...string) predicate.User { + return predicate.User(sql.FieldNotIn(FieldI18n, vs...)) +} + +// I18nGT applies the GT predicate on the "i18n" field. +func I18nGT(v string) predicate.User { + return predicate.User(sql.FieldGT(FieldI18n, v)) +} + +// I18nGTE applies the GTE predicate on the "i18n" field. +func I18nGTE(v string) predicate.User { + return predicate.User(sql.FieldGTE(FieldI18n, v)) +} + +// I18nLT applies the LT predicate on the "i18n" field. +func I18nLT(v string) predicate.User { + return predicate.User(sql.FieldLT(FieldI18n, v)) +} + +// I18nLTE applies the LTE predicate on the "i18n" field. +func I18nLTE(v string) predicate.User { + return predicate.User(sql.FieldLTE(FieldI18n, v)) +} + +// I18nContains applies the Contains predicate on the "i18n" field. +func I18nContains(v string) predicate.User { + return predicate.User(sql.FieldContains(FieldI18n, v)) +} + +// I18nHasPrefix applies the HasPrefix predicate on the "i18n" field. +func I18nHasPrefix(v string) predicate.User { + return predicate.User(sql.FieldHasPrefix(FieldI18n, v)) +} + +// I18nHasSuffix applies the HasSuffix predicate on the "i18n" field. +func I18nHasSuffix(v string) predicate.User { + return predicate.User(sql.FieldHasSuffix(FieldI18n, v)) +} + +// I18nEqualFold applies the EqualFold predicate on the "i18n" field. +func I18nEqualFold(v string) predicate.User { + return predicate.User(sql.FieldEqualFold(FieldI18n, v)) +} + +// I18nContainsFold applies the ContainsFold predicate on the "i18n" field. +func I18nContainsFold(v string) predicate.User { + return predicate.User(sql.FieldContainsFold(FieldI18n, v)) +} + // DepartmentEQ applies the EQ predicate on the "department" field. func DepartmentEQ(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldDepartment, v)) diff --git a/internal/data/entity/ent/user_create.go b/internal/data/entity/ent/user_create.go index 6f2c345f..f2f1f27d 100644 --- a/internal/data/entity/ent/user_create.go +++ b/internal/data/entity/ent/user_create.go @@ -235,6 +235,20 @@ func (_c *UserCreate) SetNillableEmail(v *string) *UserCreate { return _c } +// SetI18n sets the "i18n" field. +func (_c *UserCreate) SetI18n(v string) *UserCreate { + _c.mutation.SetI18n(v) + return _c +} + +// SetNillableI18n sets the "i18n" field if the given value is not nil. +func (_c *UserCreate) SetNillableI18n(v *string) *UserCreate { + if v != nil { + _c.SetI18n(*v) + } + return _c +} + // SetDepartment sets the "department" field. func (_c *UserCreate) SetDepartment(v string) *UserCreate { _c.mutation.SetDepartment(v) @@ -574,6 +588,10 @@ func (_c *UserCreate) defaults() error { v := user.DefaultEmail _c.mutation.SetEmail(v) } + if _, ok := _c.mutation.I18n(); !ok { + v := user.DefaultI18n + _c.mutation.SetI18n(v) + } if _, ok := _c.mutation.Department(); !ok { v := user.DefaultDepartment _c.mutation.SetDepartment(v) @@ -717,6 +735,14 @@ func (_c *UserCreate) check() error { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} } } + if _, ok := _c.mutation.I18n(); !ok { + return &ValidationError{Name: "i18n", err: errors.New(`ent: missing required field "User.i18n"`)} + } + if v, ok := _c.mutation.I18n(); ok { + if err := user.I18nValidator(v); err != nil { + return &ValidationError{Name: "i18n", err: fmt.Errorf(`ent: validator failed for field "User.i18n": %w`, err)} + } + } if _, ok := _c.mutation.Department(); !ok { return &ValidationError{Name: "department", err: errors.New(`ent: missing required field "User.department"`)} } @@ -870,6 +896,10 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldEmail, field.TypeString, value) _node.Email = value } + if value, ok := _c.mutation.I18n(); ok { + _spec.SetField(user.FieldI18n, field.TypeString, value) + _node.I18n = value + } if value, ok := _c.mutation.Department(); ok { _spec.SetField(user.FieldDepartment, field.TypeString, value) _node.Department = value diff --git a/internal/data/entity/ent/user_query.go b/internal/data/entity/ent/user_query.go index fc94cb45..2f2daf7b 100644 --- a/internal/data/entity/ent/user_query.go +++ b/internal/data/entity/ent/user_query.go @@ -1043,6 +1043,7 @@ func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // Salt string `json:"salt,omitempty"` // Phone string `json:"phone,omitempty"` // Email string `json:"email,omitempty"` +// I18n string `json:"i18n,omitempty"` // Department string `json:"department,omitempty"` // Remark string `json:"remark,omitempty"` // Token string `json:"token,omitempty"` @@ -1073,6 +1074,7 @@ func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // user.FieldSalt, // user.FieldPhone, // user.FieldEmail, +// user.FieldI18n, // user.FieldDepartment, // user.FieldRemark, // user.FieldToken, diff --git a/internal/data/entity/ent/user_update.go b/internal/data/entity/ent/user_update.go index 09795a1c..ce478c3b 100644 --- a/internal/data/entity/ent/user_update.go +++ b/internal/data/entity/ent/user_update.go @@ -270,6 +270,20 @@ func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate { return _u } +// SetI18n sets the "i18n" field. +func (_u *UserUpdate) SetI18n(v string) *UserUpdate { + _u.mutation.SetI18n(v) + return _u +} + +// SetNillableI18n sets the "i18n" field if the given value is not nil. +func (_u *UserUpdate) SetNillableI18n(v *string) *UserUpdate { + if v != nil { + _u.SetI18n(*v) + } + return _u +} + // SetDepartment sets the "department" field. func (_u *UserUpdate) SetDepartment(v string) *UserUpdate { _u.mutation.SetDepartment(v) @@ -738,6 +752,11 @@ func (_u *UserUpdate) check() error { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} } } + if v, ok := _u.mutation.I18n(); ok { + if err := user.I18nValidator(v); err != nil { + return &ValidationError{Name: "i18n", err: fmt.Errorf(`ent: validator failed for field "User.i18n": %w`, err)} + } + } if v, ok := _u.mutation.Department(); ok { if err := user.DepartmentValidator(v); err != nil { return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} @@ -844,6 +863,9 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.Email(); ok { _spec.SetField(user.FieldEmail, field.TypeString, value) } + if value, ok := _u.mutation.I18n(); ok { + _spec.SetField(user.FieldI18n, field.TypeString, value) + } if value, ok := _u.mutation.Department(); ok { _spec.SetField(user.FieldDepartment, field.TypeString, value) } @@ -1406,6 +1428,20 @@ func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne { return _u } +// SetI18n sets the "i18n" field. +func (_u *UserUpdateOne) SetI18n(v string) *UserUpdateOne { + _u.mutation.SetI18n(v) + return _u +} + +// SetNillableI18n sets the "i18n" field if the given value is not nil. +func (_u *UserUpdateOne) SetNillableI18n(v *string) *UserUpdateOne { + if v != nil { + _u.SetI18n(*v) + } + return _u +} + // SetDepartment sets the "department" field. func (_u *UserUpdateOne) SetDepartment(v string) *UserUpdateOne { _u.mutation.SetDepartment(v) @@ -1887,6 +1923,11 @@ func (_u *UserUpdateOne) check() error { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} } } + if v, ok := _u.mutation.I18n(); ok { + if err := user.I18nValidator(v); err != nil { + return &ValidationError{Name: "i18n", err: fmt.Errorf(`ent: validator failed for field "User.i18n": %w`, err)} + } + } if v, ok := _u.mutation.Department(); ok { if err := user.DepartmentValidator(v); err != nil { return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} @@ -2010,6 +2051,9 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { if value, ok := _u.mutation.Email(); ok { _spec.SetField(user.FieldEmail, field.TypeString, value) } + if value, ok := _u.mutation.I18n(); ok { + _spec.SetField(user.FieldI18n, field.TypeString, value) + } if value, ok := _u.mutation.Department(); ok { _spec.SetField(user.FieldDepartment, field.TypeString, value) } diff --git a/internal/data/entity/ent/view.go b/internal/data/entity/ent/view.go index a4974c73..4d2d6be5 100644 --- a/internal/data/entity/ent/view.go +++ b/internal/data/entity/ent/view.go @@ -22,27 +22,27 @@ type View struct { CreateTime time.Time `json:"create_time,omitempty"` // update_time.field.comment UpdateTime time.Time `json:"update_time,omitempty"` - // entity.view.field.parent_id.comment + // entity.view.field.parent_id ParentID int64 `json:"parent_id,omitempty"` - // entity.view.field.keyword.comment + // entity.view.field.keyword Keyword string `json:"keyword,omitempty"` - // entity.view.field.scope.comment + // entity.view.field.scope Scope string `json:"scope,omitempty"` - // entity.view.field.name.comment + // entity.view.field.name Name string `json:"name,omitempty"` - // entity.view.field.type.comment + // entity.view.field.type Type view.Type `json:"type,omitempty"` - // entity.view.field.component.comment + // entity.view.field.component Component string `json:"component,omitempty"` - // entity.view.field.path.comment + // entity.view.field.path Path string `json:"path,omitempty"` - // entity.view.field.icon.comment + // entity.view.field.icon Icon string `json:"icon,omitempty"` - // entity.view.field.visible.comment + // entity.view.field.visible Visible bool `json:"visible,omitempty"` - // entity.view.field.sequence.comment + // entity.view.field.sequence Sequence int `json:"sequence,omitempty"` - // entity.view.field.tree_path.comment + // entity.view.field.tree_path TreePath string `json:"tree_path,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ViewQuery when eager-loading is set. diff --git a/internal/features/auth/dto/dto.gen.go b/internal/features/auth/dto/dto.gen.go index c73876f0..7cb762c7 100644 --- a/internal/features/auth/dto/dto.gen.go +++ b/internal/features/auth/dto/dto.gen.go @@ -17,126 +17,72 @@ import ( // Local type aliases for external types. type ( - Department = ent.Department - DepartmentEdges = ent.DepartmentEdges - DepartmentEdgesPB = types.DepartmentEdges - DepartmentPB = types.Department - Departments = []*ent.Department - DepartmentsPB = []*types.Department - Permission = ent.Permission - PermissionEdges = ent.PermissionEdges - PermissionEdgesPB = types.PermissionEdges - PermissionPB = types.Permission - PermissionResource = ent.PermissionResource - PermissionResourceEdges = ent.PermissionResourceEdges - PermissionResourceEdgesPB = types.PermissionResourceEdges - PermissionResourcePB = types.PermissionResource - PermissionResources = []*ent.PermissionResource - PermissionResourcesPB = []*types.PermissionResource - Permissions = []*ent.Permission - PermissionsPB = []*types.Permission - Position = ent.Position - PositionEdges = ent.PositionEdges - PositionEdgesPB = types.PositionEdges - PositionPB = types.Position - PositionPermission = ent.PositionPermission - PositionPermissionEdges = ent.PositionPermissionEdges - PositionPermissionEdgesPB = types.PositionPermissionEdges - PositionPermissionPB = types.PositionPermission - PositionPermissions = []*ent.PositionPermission - PositionPermissionsPB = []*types.PositionPermission - Positions = []*ent.Position - PositionsPB = []*types.Position - Resource = ent.Resource - ResourceEdges = ent.ResourceEdges - ResourceEdgesPB = types.ResourceEdges - ResourcePB = types.Resource - Resources = []*ent.Resource - ResourcesPB = []*types.Resource - Role = ent.Role - RoleEdges = ent.RoleEdges - RoleEdgesPB = types.RoleEdges - RolePB = types.Role - RolePermission = ent.RolePermission - RolePermissionEdges = ent.RolePermissionEdges - RolePermissionEdgesPB = types.RolePermissionEdges - RolePermissionPB = types.RolePermission - RolePermissions = []*ent.RolePermission - RolePermissionsPB = []*types.RolePermission - RoleViewPB = types.RoleView - RoleViewsPB = []*types.RoleView - Roles = []*ent.Role - RolesPB = []*types.Role - User = ent.User - UserDepartment = ent.UserDepartment - UserDepartmentEdges = ent.UserDepartmentEdges - UserDepartmentEdgesPB = types.UserDepartmentEdges - UserDepartmentPB = types.UserDepartment - UserDepartments = []*ent.UserDepartment - UserDepartmentsPB = []*types.UserDepartment - UserEdges = ent.UserEdges - UserEdgesPB = types.UserEdges - UserPB = types.User - UserPosition = ent.UserPosition - UserPositionEdges = ent.UserPositionEdges - UserPositionEdgesPB = types.UserPositionEdges - UserPositionPB = types.UserPosition - UserPositions = []*ent.UserPosition - UserPositionsPB = []*types.UserPosition - UserRole = ent.UserRole - UserRoleEdges = ent.UserRoleEdges - UserRoleEdgesPB = types.UserRoleEdges - UserRolePB = types.UserRole - UserRoles = []*ent.UserRole - UserRolesPB = []*types.UserRole - Users = []*ent.User - UsersPB = []*types.User - View = ent.View - ViewEdges = ent.ViewEdges - ViewEdgesPB = types.ViewEdges - ViewPB = types.View - ViewPermission = ent.ViewPermission - ViewPermissionEdges = ent.ViewPermissionEdges - ViewPermissions = []*ent.ViewPermission - ViewResource = ent.ViewResource - ViewResourceEdges = ent.ViewResourceEdges - ViewResources = []*ent.ViewResource - Views = []*ent.View - ViewsPB = []*types.View + Department = ent.Department + DepartmentEdges = ent.DepartmentEdges + DepartmentPB = types.Department + Departments = []*ent.Department + DepartmentsPB = []*types.Department + Permission = ent.Permission + PermissionEdges = ent.PermissionEdges + PermissionPB = types.Permission + PermissionResource = ent.PermissionResource + PermissionResourceEdges = ent.PermissionResourceEdges + PermissionResourcePB = types.PermissionResource + PermissionResources = []*ent.PermissionResource + Permissions = []*ent.Permission + PermissionsPB = []*types.Permission + Position = ent.Position + PositionEdges = ent.PositionEdges + PositionPB = types.Position + PositionPermission = ent.PositionPermission + PositionPermissionEdges = ent.PositionPermissionEdges + PositionPermissionPB = types.PositionPermission + PositionPermissions = []*ent.PositionPermission + Positions = []*ent.Position + Resource = ent.Resource + ResourceEdges = ent.ResourceEdges + ResourcePB = types.Resource + Resources = []*ent.Resource + ResourcesPB = []*types.Resource + Role = ent.Role + RoleEdges = ent.RoleEdges + RolePB = types.Role + RolePermission = ent.RolePermission + RolePermissionEdges = ent.RolePermissionEdges + RolePermissionPB = types.RolePermission + RolePermissions = []*ent.RolePermission + Roles = []*ent.Role + RolesPB = []*types.Role + User = ent.User + UserDepartment = ent.UserDepartment + UserDepartmentEdges = ent.UserDepartmentEdges + UserDepartmentPB = types.UserDepartment + UserDepartments = []*ent.UserDepartment + UserEdges = ent.UserEdges + UserPB = types.User + UserPosition = ent.UserPosition + UserPositionEdges = ent.UserPositionEdges + UserPositionPB = types.UserPosition + UserPositions = []*ent.UserPosition + UserRole = ent.UserRole + UserRoleEdges = ent.UserRoleEdges + UserRolePB = types.UserRole + UserRoles = []*ent.UserRole + Users = []*ent.User + UsersPB = []*types.User + View = ent.View + ViewEdges = ent.ViewEdges + ViewPB = types.View + ViewPermission = ent.ViewPermission + ViewPermissionEdges = ent.ViewPermissionEdges + ViewPermissions = []*ent.ViewPermission + ViewResource = ent.ViewResource + ViewResourceEdges = ent.ViewResourceEdges + ViewResources = []*ent.ViewResource + Views = []*ent.View + ViewsPB = []*types.View ) -// ConvertDepartmentEdgesPBToDepartmentEdges converts DepartmentEdgesPB to DepartmentEdges. -func ConvertDepartmentEdgesPBToDepartmentEdges(from *DepartmentEdgesPB) *DepartmentEdges { - if from == nil { - return nil - } - - to := &DepartmentEdges{ - Users: ConvertUsersPBToUsers(from.Users), - Positions: ConvertPositionsPBToPositions(from.Positions), - Parent: ConvertDepartmentPBToDepartment(from.Parent), - Children: ConvertDepartmentsPBToDepartments(from.Children), - UserDepartments: ConvertUserDepartmentsPBToUserDepartments(from.UserDepartments), - } - return to -} - -// ConvertDepartmentEdgesToDepartmentEdgesPB converts DepartmentEdges to DepartmentEdgesPB. -func ConvertDepartmentEdgesToDepartmentEdgesPB(from *DepartmentEdges) *DepartmentEdgesPB { - if from == nil { - return nil - } - - to := &DepartmentEdgesPB{ - Users: ConvertUsersToUsersPB(from.Users), - Positions: ConvertPositionsToPositionsPB(from.Positions), - Children: ConvertDepartmentsToDepartmentsPB(from.Children), - Parent: ConvertDepartmentToDepartmentPB(from.Parent), - UserDepartments: ConvertUserDepartmentsToUserDepartmentsPB(from.UserDepartments), - } - return to -} - // ConvertDepartmentPBToDepartment converts DepartmentPB to Department. func ConvertDepartmentPBToDepartment(from *DepartmentPB) *Department { if from == nil { @@ -183,18 +129,6 @@ func ConvertDepartmentToDepartmentPB(from *Department) *DepartmentPB { return to } -// ConvertDepartmentsPBToDepartments converts a slice of *DepartmentPB to a slice of *Department. -func ConvertDepartmentsPBToDepartments(froms DepartmentsPB) Departments { - if froms == nil { - return nil - } - tos := make(Departments, len(froms)) - for i, f := range froms { - tos[i] = ConvertDepartmentPBToDepartment(f) - } - return tos -} - // ConvertDepartmentsToDepartmentsPB converts a slice of *Department to a slice of *DepartmentPB. func ConvertDepartmentsToDepartmentsPB(froms Departments) DepartmentsPB { if froms == nil { @@ -207,40 +141,6 @@ func ConvertDepartmentsToDepartmentsPB(froms Departments) DepartmentsPB { return tos } -// ConvertPermissionEdgesPBToPermissionEdges converts PermissionEdgesPB to PermissionEdges. -func ConvertPermissionEdgesPBToPermissionEdges(from *PermissionEdgesPB) *PermissionEdges { - if from == nil { - return nil - } - - to := &PermissionEdges{ - Roles: ConvertRolesPBToRoles(from.Roles), - Positions: ConvertPositionsPBToPositions(from.Positions), - Resources: ConvertResourcesPBToResources(from.Resources), - RolePermissions: ConvertRolePermissionsPBToRolePermissions(from.RolePermissions), - PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), - PermissionResources: ConvertPermissionResourcesPBToPermissionResources(from.PermissionResources), - } - return to -} - -// ConvertPermissionEdgesToPermissionEdgesPB converts PermissionEdges to PermissionEdgesPB. -func ConvertPermissionEdgesToPermissionEdgesPB(from *PermissionEdges) *PermissionEdgesPB { - if from == nil { - return nil - } - - to := &PermissionEdgesPB{ - Roles: ConvertRolesToRolesPB(from.Roles), - Resources: ConvertResourcesToResourcesPB(from.Resources), - Positions: ConvertPositionsToPositionsPB(from.Positions), - RolePermissions: ConvertRolePermissionsToRolePermissionsPB(from.RolePermissions), - PermissionResources: ConvertPermissionResourcesToPermissionResourcesPB(from.PermissionResources), - PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), - } - return to -} - // ConvertPermissionPBToPermission converts PermissionPB to Permission. func ConvertPermissionPBToPermission(from *PermissionPB) *Permission { if from == nil { @@ -256,32 +156,7 @@ func ConvertPermissionPBToPermission(from *PermissionPB) *Permission { Description: from.Description, DataScope: from.DataScope, DataRules: from.DataRules, - } - return to -} - -// ConvertPermissionResourceEdgesPBToPermissionResourceEdges converts PermissionResourceEdgesPB to PermissionResourceEdges. -func ConvertPermissionResourceEdgesPBToPermissionResourceEdges(from *PermissionResourceEdgesPB) *PermissionResourceEdges { - if from == nil { - return nil - } - - to := &PermissionResourceEdges{ - Permission: ConvertPermissionPBToPermission(from.Permission), - Resource: ConvertResourcePBToResource(from.Resource), - } - return to -} - -// ConvertPermissionResourceEdgesToPermissionResourceEdgesPB converts PermissionResourceEdges to PermissionResourceEdgesPB. -func ConvertPermissionResourceEdgesToPermissionResourceEdgesPB(from *PermissionResourceEdges) *PermissionResourceEdgesPB { - if from == nil { - return nil - } - - to := &PermissionResourceEdgesPB{ - Permission: ConvertPermissionToPermissionPB(from.Permission), - Resource: ConvertResourceToResourcePB(from.Resource), + Status: enums.Status(from.Status), } return to } @@ -314,30 +189,6 @@ func ConvertPermissionResourceToPermissionResourcePB(from *PermissionResource) * return to } -// ConvertPermissionResourcesPBToPermissionResources converts a slice of *PermissionResourcePB to a slice of *PermissionResource. -func ConvertPermissionResourcesPBToPermissionResources(froms PermissionResourcesPB) PermissionResources { - if froms == nil { - return nil - } - tos := make(PermissionResources, len(froms)) - for i, f := range froms { - tos[i] = ConvertPermissionResourcePBToPermissionResource(f) - } - return tos -} - -// ConvertPermissionResourcesToPermissionResourcesPB converts a slice of *PermissionResource to a slice of *PermissionResourcePB. -func ConvertPermissionResourcesToPermissionResourcesPB(froms PermissionResources) PermissionResourcesPB { - if froms == nil { - return nil - } - tos := make(PermissionResourcesPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertPermissionResourceToPermissionResourcePB(f) - } - return tos -} - // ConvertPermissionToPermissionPB converts Permission to PermissionPB. func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { if from == nil { @@ -350,26 +201,16 @@ func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Name: from.Name, Keyword: from.Keyword, + Status: int32(from.Status), Description: from.Description, DataScope: from.DataScope, DataRules: from.DataRules, Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), + Views: ConvertViewsToViewsPB(from.Edges.Views), } return to } -// ConvertPermissionsPBToPermissions converts a slice of *PermissionPB to a slice of *Permission. -func ConvertPermissionsPBToPermissions(froms PermissionsPB) Permissions { - if froms == nil { - return nil - } - tos := make(Permissions, len(froms)) - for i, f := range froms { - tos[i] = ConvertPermissionPBToPermission(f) - } - return tos -} - // ConvertPermissionsToPermissionsPB converts a slice of *Permission to a slice of *PermissionPB. func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { if froms == nil { @@ -382,38 +223,6 @@ func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { return tos } -// ConvertPositionEdgesPBToPositionEdges converts PositionEdgesPB to PositionEdges. -func ConvertPositionEdgesPBToPositionEdges(from *PositionEdgesPB) *PositionEdges { - if from == nil { - return nil - } - - to := &PositionEdges{ - Department: ConvertDepartmentPBToDepartment(from.Department), - Users: ConvertUsersPBToUsers(from.Users), - Permissions: ConvertPermissionsPBToPermissions(from.Permissions), - UserPositions: ConvertUserPositionsPBToUserPositions(from.UserPositions), - PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), - } - return to -} - -// ConvertPositionEdgesToPositionEdgesPB converts PositionEdges to PositionEdgesPB. -func ConvertPositionEdgesToPositionEdgesPB(from *PositionEdges) *PositionEdgesPB { - if from == nil { - return nil - } - - to := &PositionEdgesPB{ - Department: ConvertDepartmentToDepartmentPB(from.Department), - Users: ConvertUsersToUsersPB(from.Users), - Permissions: ConvertPermissionsToPermissionsPB(from.Permissions), - UserPositions: ConvertUserPositionsToUserPositionsPB(from.UserPositions), - PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), - } - return to -} - // ConvertPositionPBToPosition converts PositionPB to Position. func ConvertPositionPBToPosition(from *PositionPB) *Position { if from == nil { @@ -432,32 +241,6 @@ func ConvertPositionPBToPosition(from *PositionPB) *Position { return to } -// ConvertPositionPermissionEdgesPBToPositionPermissionEdges converts PositionPermissionEdgesPB to PositionPermissionEdges. -func ConvertPositionPermissionEdgesPBToPositionPermissionEdges(from *PositionPermissionEdgesPB) *PositionPermissionEdges { - if from == nil { - return nil - } - - to := &PositionPermissionEdges{ - Position: ConvertPositionPBToPosition(from.Position), - Permission: ConvertPermissionPBToPermission(from.Permission), - } - return to -} - -// ConvertPositionPermissionEdgesToPositionPermissionEdgesPB converts PositionPermissionEdges to PositionPermissionEdgesPB. -func ConvertPositionPermissionEdgesToPositionPermissionEdgesPB(from *PositionPermissionEdges) *PositionPermissionEdgesPB { - if from == nil { - return nil - } - - to := &PositionPermissionEdgesPB{ - Position: ConvertPositionToPositionPB(from.Position), - Permission: ConvertPermissionToPermissionPB(from.Permission), - } - return to -} - // ConvertPositionPermissionPBToPositionPermission converts PositionPermissionPB to PositionPermission. func ConvertPositionPermissionPBToPositionPermission(from *PositionPermissionPB) *PositionPermission { if from == nil { @@ -486,30 +269,6 @@ func ConvertPositionPermissionToPositionPermissionPB(from *PositionPermission) * return to } -// ConvertPositionPermissionsPBToPositionPermissions converts a slice of *PositionPermissionPB to a slice of *PositionPermission. -func ConvertPositionPermissionsPBToPositionPermissions(froms PositionPermissionsPB) PositionPermissions { - if froms == nil { - return nil - } - tos := make(PositionPermissions, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionPermissionPBToPositionPermission(f) - } - return tos -} - -// ConvertPositionPermissionsToPositionPermissionsPB converts a slice of *PositionPermission to a slice of *PositionPermissionPB. -func ConvertPositionPermissionsToPositionPermissionsPB(froms PositionPermissions) PositionPermissionsPB { - if froms == nil { - return nil - } - tos := make(PositionPermissionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionPermissionToPositionPermissionPB(f) - } - return tos -} - // ConvertPositionToPositionPB converts Position to PositionPB. func ConvertPositionToPositionPB(from *Position) *PositionPB { if from == nil { @@ -528,50 +287,6 @@ func ConvertPositionToPositionPB(from *Position) *PositionPB { return to } -// ConvertPositionsPBToPositions converts a slice of *PositionPB to a slice of *Position. -func ConvertPositionsPBToPositions(froms PositionsPB) Positions { - if froms == nil { - return nil - } - tos := make(Positions, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionPBToPosition(f) - } - return tos -} - -// ConvertPositionsToPositionsPB converts a slice of *Position to a slice of *PositionPB. -func ConvertPositionsToPositionsPB(froms Positions) PositionsPB { - if froms == nil { - return nil - } - tos := make(PositionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionToPositionPB(f) - } - return tos -} - -// ConvertResourceEdgesPBToResourceEdges converts ResourceEdgesPB to ResourceEdges. -func ConvertResourceEdgesPBToResourceEdges(from *ResourceEdgesPB) *ResourceEdges { - if from == nil { - return nil - } - - to := &ResourceEdges{} - return to -} - -// ConvertResourceEdgesToResourceEdgesPB converts ResourceEdges to ResourceEdgesPB. -func ConvertResourceEdgesToResourceEdgesPB(from *ResourceEdges) *ResourceEdgesPB { - if from == nil { - return nil - } - - to := &ResourceEdgesPB{} - return to -} - // ConvertResourcePBToResource converts ResourcePB to Resource. func ConvertResourcePBToResource(from *ResourcePB) *Resource { if from == nil { @@ -586,7 +301,7 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { Path: from.Path, Method: from.Method, Operation: from.Operation, - Status: ConvertInt32ToStatus(from.Status), + Status: enums.Status(from.Status), } return to } @@ -602,7 +317,7 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Keyword: from.Keyword, - Status: ConvertStatusToInt32(from.Status), + Status: int32(from.Status), Path: from.Path, Operation: from.Operation, Method: from.Method, @@ -611,18 +326,6 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { return to } -// ConvertResourcesPBToResources converts a slice of *ResourcePB to a slice of *Resource. -func ConvertResourcesPBToResources(froms ResourcesPB) Resources { - if froms == nil { - return nil - } - tos := make(Resources, len(froms)) - for i, f := range froms { - tos[i] = ConvertResourcePBToResource(f) - } - return tos -} - // ConvertResourcesToResourcesPB converts a slice of *Resource to a slice of *ResourcePB. func ConvertResourcesToResourcesPB(froms Resources) ResourcesPB { if froms == nil { @@ -635,32 +338,6 @@ func ConvertResourcesToResourcesPB(froms Resources) ResourcesPB { return tos } -// ConvertRoleEdgesPBToRoleEdges converts RoleEdgesPB to RoleEdges. -func ConvertRoleEdgesPBToRoleEdges(from *RoleEdgesPB) *RoleEdges { - if from == nil { - return nil - } - - to := &RoleEdges{ - Users: ConvertUsersPBToUsers(from.Users), - UserRoles: ConvertUserRolesPBToUserRoles(from.UserRoles), - } - return to -} - -// ConvertRoleEdgesToRoleEdgesPB converts RoleEdges to RoleEdgesPB. -func ConvertRoleEdgesToRoleEdgesPB(from *RoleEdges) *RoleEdgesPB { - if from == nil { - return nil - } - - to := &RoleEdgesPB{ - Users: ConvertUsersToUsersPB(from.Users), - UserRoles: ConvertUserRolesToUserRolesPB(from.UserRoles), - } - return to -} - // ConvertRolePBToRole converts RolePB to Role. func ConvertRolePBToRole(from *RolePB) *Role { if from == nil { @@ -681,32 +358,6 @@ func ConvertRolePBToRole(from *RolePB) *Role { return to } -// ConvertRolePermissionEdgesPBToRolePermissionEdges converts RolePermissionEdgesPB to RolePermissionEdges. -func ConvertRolePermissionEdgesPBToRolePermissionEdges(from *RolePermissionEdgesPB) *RolePermissionEdges { - if from == nil { - return nil - } - - to := &RolePermissionEdges{ - Role: ConvertRolePBToRole(from.Role), - Permission: ConvertPermissionPBToPermission(from.Permission), - } - return to -} - -// ConvertRolePermissionEdgesToRolePermissionEdgesPB converts RolePermissionEdges to RolePermissionEdgesPB. -func ConvertRolePermissionEdgesToRolePermissionEdgesPB(from *RolePermissionEdges) *RolePermissionEdgesPB { - if from == nil { - return nil - } - - to := &RolePermissionEdgesPB{ - Role: ConvertRoleToRolePB(from.Role), - Permission: ConvertPermissionToPermissionPB(from.Permission), - } - return to -} - // ConvertRolePermissionPBToRolePermission converts RolePermissionPB to RolePermission. func ConvertRolePermissionPBToRolePermission(from *RolePermissionPB) *RolePermission { if from == nil { @@ -735,30 +386,6 @@ func ConvertRolePermissionToRolePermissionPB(from *RolePermission) *RolePermissi return to } -// ConvertRolePermissionsPBToRolePermissions converts a slice of *RolePermissionPB to a slice of *RolePermission. -func ConvertRolePermissionsPBToRolePermissions(froms RolePermissionsPB) RolePermissions { - if froms == nil { - return nil - } - tos := make(RolePermissions, len(froms)) - for i, f := range froms { - tos[i] = ConvertRolePermissionPBToRolePermission(f) - } - return tos -} - -// ConvertRolePermissionsToRolePermissionsPB converts a slice of *RolePermission to a slice of *RolePermissionPB. -func ConvertRolePermissionsToRolePermissionsPB(froms RolePermissions) RolePermissionsPB { - if froms == nil { - return nil - } - tos := make(RolePermissionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertRolePermissionToRolePermissionPB(f) - } - return tos -} - // ConvertRoleToRolePB converts Role to RolePB. func ConvertRoleToRolePB(from *Role) *RolePB { if from == nil { @@ -781,18 +408,6 @@ func ConvertRoleToRolePB(from *Role) *RolePB { return to } -// ConvertRolesPBToRoles converts a slice of *RolePB to a slice of *Role. -func ConvertRolesPBToRoles(froms RolesPB) Roles { - if froms == nil { - return nil - } - tos := make(Roles, len(froms)) - for i, f := range froms { - tos[i] = ConvertRolePBToRole(f) - } - return tos -} - // ConvertRolesToRolesPB converts a slice of *Role to a slice of *RolePB. func ConvertRolesToRolesPB(froms Roles) RolesPB { if froms == nil { @@ -805,32 +420,6 @@ func ConvertRolesToRolesPB(froms Roles) RolesPB { return tos } -// ConvertUserDepartmentEdgesPBToUserDepartmentEdges converts UserDepartmentEdgesPB to UserDepartmentEdges. -func ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from *UserDepartmentEdgesPB) *UserDepartmentEdges { - if from == nil { - return nil - } - - to := &UserDepartmentEdges{ - User: ConvertUserPBToUser(from.User), - Department: ConvertDepartmentPBToDepartment(from.Department), - } - return to -} - -// ConvertUserDepartmentEdgesToUserDepartmentEdgesPB converts UserDepartmentEdges to UserDepartmentEdgesPB. -func ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(from *UserDepartmentEdges) *UserDepartmentEdgesPB { - if from == nil { - return nil - } - - to := &UserDepartmentEdgesPB{ - User: ConvertUserToUserPB(from.User), - Department: ConvertDepartmentToDepartmentPB(from.Department), - } - return to -} - // ConvertUserDepartmentPBToUserDepartment converts UserDepartmentPB to UserDepartment. func ConvertUserDepartmentPBToUserDepartment(from *UserDepartmentPB) *UserDepartment { if from == nil { @@ -841,7 +430,6 @@ func ConvertUserDepartmentPBToUserDepartment(from *UserDepartmentPB) *UserDepart ID: int(from.Id), UserID: from.UserId, DepartmentID: from.DepartmentId, - Edges: *ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from.Edges), } return to } @@ -856,57 +444,6 @@ func ConvertUserDepartmentToUserDepartmentPB(from *UserDepartment) *UserDepartme Id: int64(from.ID), UserId: from.UserID, DepartmentId: from.DepartmentID, - Edges: ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(&from.Edges), - } - return to -} - -// ConvertUserDepartmentsPBToUserDepartments converts a slice of *UserDepartmentPB to a slice of *UserDepartment. -func ConvertUserDepartmentsPBToUserDepartments(froms UserDepartmentsPB) UserDepartments { - if froms == nil { - return nil - } - tos := make(UserDepartments, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserDepartmentPBToUserDepartment(f) - } - return tos -} - -// ConvertUserDepartmentsToUserDepartmentsPB converts a slice of *UserDepartment to a slice of *UserDepartmentPB. -func ConvertUserDepartmentsToUserDepartmentsPB(froms UserDepartments) UserDepartmentsPB { - if froms == nil { - return nil - } - tos := make(UserDepartmentsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserDepartmentToUserDepartmentPB(f) - } - return tos -} - -// ConvertUserEdgesPBToUserEdges converts UserEdgesPB to UserEdges. -func ConvertUserEdgesPBToUserEdges(from *UserEdgesPB) *UserEdges { - if from == nil { - return nil - } - - to := &UserEdges{ - Roles: ConvertRolesPBToRoles(from.Roles), - UserRoles: ConvertUserRolesPBToUserRoles(from.UserRoles), - } - return to -} - -// ConvertUserEdgesToUserEdgesPB converts UserEdges to UserEdgesPB. -func ConvertUserEdgesToUserEdgesPB(from *UserEdges) *UserEdgesPB { - if from == nil { - return nil - } - - to := &UserEdgesPB{ - Roles: ConvertRolesToRolesPB(from.Roles), - UserRoles: ConvertUserRolesToUserRolesPB(from.UserRoles), } return to } @@ -932,42 +469,19 @@ func ConvertUserPBToUser(from *UserPB) *User { Gender: ConvertStringToGender(from.Gender), Phone: from.Phone, Email: from.Email, + I18n: from.I18N, Remark: from.Remark, Token: from.Token, Status: enums.Status(from.Status), LastLoginIP: from.LastLoginIp, + LoginIP: from.LoginIp, LastLoginTime: ConvertTimestampToTime(from.LastLoginTime), + LoginTime: ConvertTimestampToTime(from.LoginTime), SanctionDate: ConvertTimestampToTime(from.SanctionDate), } return to } -// ConvertUserPositionEdgesPBToUserPositionEdges converts UserPositionEdgesPB to UserPositionEdges. -func ConvertUserPositionEdgesPBToUserPositionEdges(from *UserPositionEdgesPB) *UserPositionEdges { - if from == nil { - return nil - } - - to := &UserPositionEdges{ - User: ConvertUserPBToUser(from.User), - Position: ConvertPositionPBToPosition(from.Position), - } - return to -} - -// ConvertUserPositionEdgesToUserPositionEdgesPB converts UserPositionEdges to UserPositionEdgesPB. -func ConvertUserPositionEdgesToUserPositionEdgesPB(from *UserPositionEdges) *UserPositionEdgesPB { - if from == nil { - return nil - } - - to := &UserPositionEdgesPB{ - User: ConvertUserToUserPB(from.User), - Position: ConvertPositionToPositionPB(from.Position), - } - return to -} - // ConvertUserPositionPBToUserPosition converts UserPositionPB to UserPosition. func ConvertUserPositionPBToUserPosition(from *UserPositionPB) *UserPosition { if from == nil { @@ -996,56 +510,6 @@ func ConvertUserPositionToUserPositionPB(from *UserPosition) *UserPositionPB { return to } -// ConvertUserPositionsPBToUserPositions converts a slice of *UserPositionPB to a slice of *UserPosition. -func ConvertUserPositionsPBToUserPositions(froms UserPositionsPB) UserPositions { - if froms == nil { - return nil - } - tos := make(UserPositions, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserPositionPBToUserPosition(f) - } - return tos -} - -// ConvertUserPositionsToUserPositionsPB converts a slice of *UserPosition to a slice of *UserPositionPB. -func ConvertUserPositionsToUserPositionsPB(froms UserPositions) UserPositionsPB { - if froms == nil { - return nil - } - tos := make(UserPositionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserPositionToUserPositionPB(f) - } - return tos -} - -// ConvertUserRoleEdgesPBToUserRoleEdges converts UserRoleEdgesPB to UserRoleEdges. -func ConvertUserRoleEdgesPBToUserRoleEdges(from *UserRoleEdgesPB) *UserRoleEdges { - if from == nil { - return nil - } - - to := &UserRoleEdges{ - User: ConvertUserPBToUser(from.User), - Role: ConvertRolePBToRole(from.Role), - } - return to -} - -// ConvertUserRoleEdgesToUserRoleEdgesPB converts UserRoleEdges to UserRoleEdgesPB. -func ConvertUserRoleEdgesToUserRoleEdgesPB(from *UserRoleEdges) *UserRoleEdgesPB { - if from == nil { - return nil - } - - to := &UserRoleEdgesPB{ - User: ConvertUserToUserPB(from.User), - Role: ConvertRoleToRolePB(from.Role), - } - return to -} - // ConvertUserRolePBToUserRole converts UserRolePB to UserRole. func ConvertUserRolePBToUserRole(from *UserRolePB) *UserRole { if from == nil { @@ -1076,30 +540,6 @@ func ConvertUserRoleToUserRolePB(from *UserRole) *UserRolePB { return to } -// ConvertUserRolesPBToUserRoles converts a slice of *UserRolePB to a slice of *UserRole. -func ConvertUserRolesPBToUserRoles(froms UserRolesPB) UserRoles { - if froms == nil { - return nil - } - tos := make(UserRoles, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserRolePBToUserRole(f) - } - return tos -} - -// ConvertUserRolesToUserRolesPB converts a slice of *UserRole to a slice of *UserRolePB. -func ConvertUserRolesToUserRolesPB(froms UserRoles) UserRolesPB { - if froms == nil { - return nil - } - tos := make(UserRolesPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserRoleToUserRolePB(f) - } - return tos -} - // ConvertUserToUserPB converts User to UserPB. func ConvertUserToUserPB(from *User) *UserPB { if from == nil { @@ -1108,10 +548,10 @@ func ConvertUserToUserPB(from *User) *UserPB { to := &UserPB{ Id: from.ID, - CreateAuthor: from.CreateAuthor, - UpdateAuthor: from.UpdateAuthor, CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + CreateAuthor: from.CreateAuthor, + UpdateAuthor: from.UpdateAuthor, Uuid: from.UUID, AllowedIp: from.AllowedIP, Username: from.Username, @@ -1124,26 +564,17 @@ func ConvertUserToUserPB(from *User) *UserPB { Remark: from.Remark, Token: from.Token, Status: int32(from.Status), + I18N: from.I18n, LastLoginIp: from.LastLoginIP, + LoginIp: from.LoginIP, LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), + LoginTime: ConvertTimeToTimestamp(from.LoginTime), SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), Roles: ConvertRolesToRolesPB(from.Edges.Roles), } return to } -// ConvertUsersPBToUsers converts a slice of *UserPB to a slice of *User. -func ConvertUsersPBToUsers(froms UsersPB) Users { - if froms == nil { - return nil - } - tos := make(Users, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserPBToUser(f) - } - return tos -} - // ConvertUsersToUsersPB converts a slice of *User to a slice of *UserPB. func ConvertUsersToUsersPB(froms Users) UsersPB { if froms == nil { @@ -1156,34 +587,6 @@ func ConvertUsersToUsersPB(froms Users) UsersPB { return tos } -// ConvertViewEdgesPBToViewEdges converts ViewEdgesPB to ViewEdges. -func ConvertViewEdgesPBToViewEdges(from *ViewEdgesPB) *ViewEdges { - if from == nil { - return nil - } - - to := &ViewEdges{ - Parent: ConvertViewPBToView(from.Parent), - Children: ConvertViewsPBToViews(from.Children), - Resources: ConvertResourcesPBToResources(from.Resources), - } - return to -} - -// ConvertViewEdgesToViewEdgesPB converts ViewEdges to ViewEdgesPB. -func ConvertViewEdgesToViewEdgesPB(from *ViewEdges) *ViewEdgesPB { - if from == nil { - return nil - } - - to := &ViewEdgesPB{ - Children: ConvertViewsToViewsPB(from.Children), - Parent: ConvertViewToViewPB(from.Parent), - Resources: ConvertResourcesToResourcesPB(from.Resources), - } - return to -} - // ConvertViewPBToView converts ViewPB to View. func ConvertViewPBToView(from *ViewPB) *View { if from == nil { @@ -1199,6 +602,7 @@ func ConvertViewPBToView(from *ViewPB) *View { Scope: from.Scope, Name: from.Name, Type: ConvertStringToType(from.Type), + Component: from.Component, Path: from.Path, Icon: from.Icon, Visible: from.Visible, @@ -1223,6 +627,7 @@ func ConvertViewToViewPB(from *View) *ViewPB { Scope: from.Scope, Sequence: int32(from.Sequence), Type: ConvertTypeToString(from.Type), + Component: from.Component, Icon: from.Icon, Visible: from.Visible, Path: from.Path, @@ -1235,18 +640,6 @@ func ConvertViewToViewPB(from *View) *ViewPB { return to } -// ConvertViewsPBToViews converts a slice of *ViewPB to a slice of *View. -func ConvertViewsPBToViews(froms ViewsPB) Views { - if froms == nil { - return nil - } - tos := make(Views, len(froms)) - for i, f := range froms { - tos[i] = ConvertViewPBToView(f) - } - return tos -} - // ConvertViewsToViewsPB converts a slice of *View to a slice of *ViewPB. func ConvertViewsToViewsPB(froms Views) ViewsPB { if froms == nil { diff --git a/internal/features/auth/dto/dto.go b/internal/features/auth/dto/dto.go index 68df9567..7b74d15d 100644 --- a/internal/features/auth/dto/dto.go +++ b/internal/features/auth/dto/dto.go @@ -6,7 +6,6 @@ package dto import ( - "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/data/entity/ent/view" ) @@ -53,25 +52,3 @@ func ConvertStringToType(from string) view.Type { func ConvertTypeToString(from view.Type) string { return ViewTypeName(from) } - -// ConvertInt32ToStatus is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertInt32ToStatus(from int32) resource.Status { - switch from { - case 1: - return resource.StatusEnabled - default: - return resource.StatusDisabled - } -} - -// ConvertStatusToInt32 is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertStatusToInt32(from resource.Status) int32 { - switch from { - case resource.StatusEnabled: - return 1 - default: - return 0 - } -} diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index d5bcd77e..235d7a57 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -94,6 +94,10 @@ func (r *resourceRepo) List(ctx context.Context, opts ...*dto.ResourceQueryOptio query.WithPermissions() } + if opt.Keyword != "" { + query.Where(resource.KeywordContains(opt.Keyword)) + } + if opt.ReadMask != nil { selectCols := db.SelectFields(opt.ReadMask, resource.ValidColumn, resource.FieldID, new(types.Resource)) if len(selectCols) > 0 { diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index c73876f0..b7938f83 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -17,126 +17,72 @@ import ( // Local type aliases for external types. type ( - Department = ent.Department - DepartmentEdges = ent.DepartmentEdges - DepartmentEdgesPB = types.DepartmentEdges - DepartmentPB = types.Department - Departments = []*ent.Department - DepartmentsPB = []*types.Department - Permission = ent.Permission - PermissionEdges = ent.PermissionEdges - PermissionEdgesPB = types.PermissionEdges - PermissionPB = types.Permission - PermissionResource = ent.PermissionResource - PermissionResourceEdges = ent.PermissionResourceEdges - PermissionResourceEdgesPB = types.PermissionResourceEdges - PermissionResourcePB = types.PermissionResource - PermissionResources = []*ent.PermissionResource - PermissionResourcesPB = []*types.PermissionResource - Permissions = []*ent.Permission - PermissionsPB = []*types.Permission - Position = ent.Position - PositionEdges = ent.PositionEdges - PositionEdgesPB = types.PositionEdges - PositionPB = types.Position - PositionPermission = ent.PositionPermission - PositionPermissionEdges = ent.PositionPermissionEdges - PositionPermissionEdgesPB = types.PositionPermissionEdges - PositionPermissionPB = types.PositionPermission - PositionPermissions = []*ent.PositionPermission - PositionPermissionsPB = []*types.PositionPermission - Positions = []*ent.Position - PositionsPB = []*types.Position - Resource = ent.Resource - ResourceEdges = ent.ResourceEdges - ResourceEdgesPB = types.ResourceEdges - ResourcePB = types.Resource - Resources = []*ent.Resource - ResourcesPB = []*types.Resource - Role = ent.Role - RoleEdges = ent.RoleEdges - RoleEdgesPB = types.RoleEdges - RolePB = types.Role - RolePermission = ent.RolePermission - RolePermissionEdges = ent.RolePermissionEdges - RolePermissionEdgesPB = types.RolePermissionEdges - RolePermissionPB = types.RolePermission - RolePermissions = []*ent.RolePermission - RolePermissionsPB = []*types.RolePermission - RoleViewPB = types.RoleView - RoleViewsPB = []*types.RoleView - Roles = []*ent.Role - RolesPB = []*types.Role - User = ent.User - UserDepartment = ent.UserDepartment - UserDepartmentEdges = ent.UserDepartmentEdges - UserDepartmentEdgesPB = types.UserDepartmentEdges - UserDepartmentPB = types.UserDepartment - UserDepartments = []*ent.UserDepartment - UserDepartmentsPB = []*types.UserDepartment - UserEdges = ent.UserEdges - UserEdgesPB = types.UserEdges - UserPB = types.User - UserPosition = ent.UserPosition - UserPositionEdges = ent.UserPositionEdges - UserPositionEdgesPB = types.UserPositionEdges - UserPositionPB = types.UserPosition - UserPositions = []*ent.UserPosition - UserPositionsPB = []*types.UserPosition - UserRole = ent.UserRole - UserRoleEdges = ent.UserRoleEdges - UserRoleEdgesPB = types.UserRoleEdges - UserRolePB = types.UserRole - UserRoles = []*ent.UserRole - UserRolesPB = []*types.UserRole - Users = []*ent.User - UsersPB = []*types.User - View = ent.View - ViewEdges = ent.ViewEdges - ViewEdgesPB = types.ViewEdges - ViewPB = types.View - ViewPermission = ent.ViewPermission - ViewPermissionEdges = ent.ViewPermissionEdges - ViewPermissions = []*ent.ViewPermission - ViewResource = ent.ViewResource - ViewResourceEdges = ent.ViewResourceEdges - ViewResources = []*ent.ViewResource - Views = []*ent.View - ViewsPB = []*types.View + Department = ent.Department + DepartmentEdges = ent.DepartmentEdges + DepartmentPB = types.Department + Departments = []*ent.Department + DepartmentsPB = []*types.Department + Permission = ent.Permission + PermissionEdges = ent.PermissionEdges + PermissionPB = types.Permission + PermissionResource = ent.PermissionResource + PermissionResourceEdges = ent.PermissionResourceEdges + PermissionResourcePB = types.PermissionResource + PermissionResources = []*ent.PermissionResource + Permissions = []*ent.Permission + PermissionsPB = []*types.Permission + Position = ent.Position + PositionEdges = ent.PositionEdges + PositionPB = types.Position + PositionPermission = ent.PositionPermission + PositionPermissionEdges = ent.PositionPermissionEdges + PositionPermissionPB = types.PositionPermission + PositionPermissions = []*ent.PositionPermission + Positions = []*ent.Position + Resource = ent.Resource + ResourceEdges = ent.ResourceEdges + ResourcePB = types.Resource + Resources = []*ent.Resource + ResourcesPB = []*types.Resource + Role = ent.Role + RoleEdges = ent.RoleEdges + RolePB = types.Role + RolePermission = ent.RolePermission + RolePermissionEdges = ent.RolePermissionEdges + RolePermissionPB = types.RolePermission + RolePermissions = []*ent.RolePermission + Roles = []*ent.Role + RolesPB = []*types.Role + User = ent.User + UserDepartment = ent.UserDepartment + UserDepartmentEdges = ent.UserDepartmentEdges + UserDepartmentPB = types.UserDepartment + UserDepartments = []*ent.UserDepartment + UserEdges = ent.UserEdges + UserPB = types.User + UserPosition = ent.UserPosition + UserPositionEdges = ent.UserPositionEdges + UserPositionPB = types.UserPosition + UserPositions = []*ent.UserPosition + UserRole = ent.UserRole + UserRoleEdges = ent.UserRoleEdges + UserRolePB = types.UserRole + UserRoles = []*ent.UserRole + Users = []*ent.User + UsersPB = []*types.User + View = ent.View + ViewEdges = ent.ViewEdges + ViewPB = types.View + ViewPermission = ent.ViewPermission + ViewPermissionEdges = ent.ViewPermissionEdges + ViewPermissions = []*ent.ViewPermission + ViewResource = ent.ViewResource + ViewResourceEdges = ent.ViewResourceEdges + ViewResources = []*ent.ViewResource + Views = []*ent.View + ViewsPB = []*types.View ) -// ConvertDepartmentEdgesPBToDepartmentEdges converts DepartmentEdgesPB to DepartmentEdges. -func ConvertDepartmentEdgesPBToDepartmentEdges(from *DepartmentEdgesPB) *DepartmentEdges { - if from == nil { - return nil - } - - to := &DepartmentEdges{ - Users: ConvertUsersPBToUsers(from.Users), - Positions: ConvertPositionsPBToPositions(from.Positions), - Parent: ConvertDepartmentPBToDepartment(from.Parent), - Children: ConvertDepartmentsPBToDepartments(from.Children), - UserDepartments: ConvertUserDepartmentsPBToUserDepartments(from.UserDepartments), - } - return to -} - -// ConvertDepartmentEdgesToDepartmentEdgesPB converts DepartmentEdges to DepartmentEdgesPB. -func ConvertDepartmentEdgesToDepartmentEdgesPB(from *DepartmentEdges) *DepartmentEdgesPB { - if from == nil { - return nil - } - - to := &DepartmentEdgesPB{ - Users: ConvertUsersToUsersPB(from.Users), - Positions: ConvertPositionsToPositionsPB(from.Positions), - Children: ConvertDepartmentsToDepartmentsPB(from.Children), - Parent: ConvertDepartmentToDepartmentPB(from.Parent), - UserDepartments: ConvertUserDepartmentsToUserDepartmentsPB(from.UserDepartments), - } - return to -} - // ConvertDepartmentPBToDepartment converts DepartmentPB to Department. func ConvertDepartmentPBToDepartment(from *DepartmentPB) *Department { if from == nil { @@ -183,18 +129,6 @@ func ConvertDepartmentToDepartmentPB(from *Department) *DepartmentPB { return to } -// ConvertDepartmentsPBToDepartments converts a slice of *DepartmentPB to a slice of *Department. -func ConvertDepartmentsPBToDepartments(froms DepartmentsPB) Departments { - if froms == nil { - return nil - } - tos := make(Departments, len(froms)) - for i, f := range froms { - tos[i] = ConvertDepartmentPBToDepartment(f) - } - return tos -} - // ConvertDepartmentsToDepartmentsPB converts a slice of *Department to a slice of *DepartmentPB. func ConvertDepartmentsToDepartmentsPB(froms Departments) DepartmentsPB { if froms == nil { @@ -207,40 +141,6 @@ func ConvertDepartmentsToDepartmentsPB(froms Departments) DepartmentsPB { return tos } -// ConvertPermissionEdgesPBToPermissionEdges converts PermissionEdgesPB to PermissionEdges. -func ConvertPermissionEdgesPBToPermissionEdges(from *PermissionEdgesPB) *PermissionEdges { - if from == nil { - return nil - } - - to := &PermissionEdges{ - Roles: ConvertRolesPBToRoles(from.Roles), - Positions: ConvertPositionsPBToPositions(from.Positions), - Resources: ConvertResourcesPBToResources(from.Resources), - RolePermissions: ConvertRolePermissionsPBToRolePermissions(from.RolePermissions), - PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), - PermissionResources: ConvertPermissionResourcesPBToPermissionResources(from.PermissionResources), - } - return to -} - -// ConvertPermissionEdgesToPermissionEdgesPB converts PermissionEdges to PermissionEdgesPB. -func ConvertPermissionEdgesToPermissionEdgesPB(from *PermissionEdges) *PermissionEdgesPB { - if from == nil { - return nil - } - - to := &PermissionEdgesPB{ - Roles: ConvertRolesToRolesPB(from.Roles), - Resources: ConvertResourcesToResourcesPB(from.Resources), - Positions: ConvertPositionsToPositionsPB(from.Positions), - RolePermissions: ConvertRolePermissionsToRolePermissionsPB(from.RolePermissions), - PermissionResources: ConvertPermissionResourcesToPermissionResourcesPB(from.PermissionResources), - PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), - } - return to -} - // ConvertPermissionPBToPermission converts PermissionPB to Permission. func ConvertPermissionPBToPermission(from *PermissionPB) *Permission { if from == nil { @@ -256,32 +156,7 @@ func ConvertPermissionPBToPermission(from *PermissionPB) *Permission { Description: from.Description, DataScope: from.DataScope, DataRules: from.DataRules, - } - return to -} - -// ConvertPermissionResourceEdgesPBToPermissionResourceEdges converts PermissionResourceEdgesPB to PermissionResourceEdges. -func ConvertPermissionResourceEdgesPBToPermissionResourceEdges(from *PermissionResourceEdgesPB) *PermissionResourceEdges { - if from == nil { - return nil - } - - to := &PermissionResourceEdges{ - Permission: ConvertPermissionPBToPermission(from.Permission), - Resource: ConvertResourcePBToResource(from.Resource), - } - return to -} - -// ConvertPermissionResourceEdgesToPermissionResourceEdgesPB converts PermissionResourceEdges to PermissionResourceEdgesPB. -func ConvertPermissionResourceEdgesToPermissionResourceEdgesPB(from *PermissionResourceEdges) *PermissionResourceEdgesPB { - if from == nil { - return nil - } - - to := &PermissionResourceEdgesPB{ - Permission: ConvertPermissionToPermissionPB(from.Permission), - Resource: ConvertResourceToResourcePB(from.Resource), + Status: enums.Status(from.Status), } return to } @@ -314,30 +189,6 @@ func ConvertPermissionResourceToPermissionResourcePB(from *PermissionResource) * return to } -// ConvertPermissionResourcesPBToPermissionResources converts a slice of *PermissionResourcePB to a slice of *PermissionResource. -func ConvertPermissionResourcesPBToPermissionResources(froms PermissionResourcesPB) PermissionResources { - if froms == nil { - return nil - } - tos := make(PermissionResources, len(froms)) - for i, f := range froms { - tos[i] = ConvertPermissionResourcePBToPermissionResource(f) - } - return tos -} - -// ConvertPermissionResourcesToPermissionResourcesPB converts a slice of *PermissionResource to a slice of *PermissionResourcePB. -func ConvertPermissionResourcesToPermissionResourcesPB(froms PermissionResources) PermissionResourcesPB { - if froms == nil { - return nil - } - tos := make(PermissionResourcesPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertPermissionResourceToPermissionResourcePB(f) - } - return tos -} - // ConvertPermissionToPermissionPB converts Permission to PermissionPB. func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { if from == nil { @@ -350,26 +201,16 @@ func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Name: from.Name, Keyword: from.Keyword, + Status: int32(from.Status), Description: from.Description, DataScope: from.DataScope, DataRules: from.DataRules, Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), + Views: ConvertViewsToViewsPB(from.Edges.Views), } return to } -// ConvertPermissionsPBToPermissions converts a slice of *PermissionPB to a slice of *Permission. -func ConvertPermissionsPBToPermissions(froms PermissionsPB) Permissions { - if froms == nil { - return nil - } - tos := make(Permissions, len(froms)) - for i, f := range froms { - tos[i] = ConvertPermissionPBToPermission(f) - } - return tos -} - // ConvertPermissionsToPermissionsPB converts a slice of *Permission to a slice of *PermissionPB. func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { if froms == nil { @@ -382,38 +223,6 @@ func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { return tos } -// ConvertPositionEdgesPBToPositionEdges converts PositionEdgesPB to PositionEdges. -func ConvertPositionEdgesPBToPositionEdges(from *PositionEdgesPB) *PositionEdges { - if from == nil { - return nil - } - - to := &PositionEdges{ - Department: ConvertDepartmentPBToDepartment(from.Department), - Users: ConvertUsersPBToUsers(from.Users), - Permissions: ConvertPermissionsPBToPermissions(from.Permissions), - UserPositions: ConvertUserPositionsPBToUserPositions(from.UserPositions), - PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), - } - return to -} - -// ConvertPositionEdgesToPositionEdgesPB converts PositionEdges to PositionEdgesPB. -func ConvertPositionEdgesToPositionEdgesPB(from *PositionEdges) *PositionEdgesPB { - if from == nil { - return nil - } - - to := &PositionEdgesPB{ - Department: ConvertDepartmentToDepartmentPB(from.Department), - Users: ConvertUsersToUsersPB(from.Users), - Permissions: ConvertPermissionsToPermissionsPB(from.Permissions), - UserPositions: ConvertUserPositionsToUserPositionsPB(from.UserPositions), - PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), - } - return to -} - // ConvertPositionPBToPosition converts PositionPB to Position. func ConvertPositionPBToPosition(from *PositionPB) *Position { if from == nil { @@ -432,32 +241,6 @@ func ConvertPositionPBToPosition(from *PositionPB) *Position { return to } -// ConvertPositionPermissionEdgesPBToPositionPermissionEdges converts PositionPermissionEdgesPB to PositionPermissionEdges. -func ConvertPositionPermissionEdgesPBToPositionPermissionEdges(from *PositionPermissionEdgesPB) *PositionPermissionEdges { - if from == nil { - return nil - } - - to := &PositionPermissionEdges{ - Position: ConvertPositionPBToPosition(from.Position), - Permission: ConvertPermissionPBToPermission(from.Permission), - } - return to -} - -// ConvertPositionPermissionEdgesToPositionPermissionEdgesPB converts PositionPermissionEdges to PositionPermissionEdgesPB. -func ConvertPositionPermissionEdgesToPositionPermissionEdgesPB(from *PositionPermissionEdges) *PositionPermissionEdgesPB { - if from == nil { - return nil - } - - to := &PositionPermissionEdgesPB{ - Position: ConvertPositionToPositionPB(from.Position), - Permission: ConvertPermissionToPermissionPB(from.Permission), - } - return to -} - // ConvertPositionPermissionPBToPositionPermission converts PositionPermissionPB to PositionPermission. func ConvertPositionPermissionPBToPositionPermission(from *PositionPermissionPB) *PositionPermission { if from == nil { @@ -486,30 +269,6 @@ func ConvertPositionPermissionToPositionPermissionPB(from *PositionPermission) * return to } -// ConvertPositionPermissionsPBToPositionPermissions converts a slice of *PositionPermissionPB to a slice of *PositionPermission. -func ConvertPositionPermissionsPBToPositionPermissions(froms PositionPermissionsPB) PositionPermissions { - if froms == nil { - return nil - } - tos := make(PositionPermissions, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionPermissionPBToPositionPermission(f) - } - return tos -} - -// ConvertPositionPermissionsToPositionPermissionsPB converts a slice of *PositionPermission to a slice of *PositionPermissionPB. -func ConvertPositionPermissionsToPositionPermissionsPB(froms PositionPermissions) PositionPermissionsPB { - if froms == nil { - return nil - } - tos := make(PositionPermissionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionPermissionToPositionPermissionPB(f) - } - return tos -} - // ConvertPositionToPositionPB converts Position to PositionPB. func ConvertPositionToPositionPB(from *Position) *PositionPB { if from == nil { @@ -528,50 +287,6 @@ func ConvertPositionToPositionPB(from *Position) *PositionPB { return to } -// ConvertPositionsPBToPositions converts a slice of *PositionPB to a slice of *Position. -func ConvertPositionsPBToPositions(froms PositionsPB) Positions { - if froms == nil { - return nil - } - tos := make(Positions, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionPBToPosition(f) - } - return tos -} - -// ConvertPositionsToPositionsPB converts a slice of *Position to a slice of *PositionPB. -func ConvertPositionsToPositionsPB(froms Positions) PositionsPB { - if froms == nil { - return nil - } - tos := make(PositionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertPositionToPositionPB(f) - } - return tos -} - -// ConvertResourceEdgesPBToResourceEdges converts ResourceEdgesPB to ResourceEdges. -func ConvertResourceEdgesPBToResourceEdges(from *ResourceEdgesPB) *ResourceEdges { - if from == nil { - return nil - } - - to := &ResourceEdges{} - return to -} - -// ConvertResourceEdgesToResourceEdgesPB converts ResourceEdges to ResourceEdgesPB. -func ConvertResourceEdgesToResourceEdgesPB(from *ResourceEdges) *ResourceEdgesPB { - if from == nil { - return nil - } - - to := &ResourceEdgesPB{} - return to -} - // ConvertResourcePBToResource converts ResourcePB to Resource. func ConvertResourcePBToResource(from *ResourcePB) *Resource { if from == nil { @@ -579,14 +294,15 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { } to := &Resource{ - ID: from.Id, - CreateTime: ConvertTimestampToTime(from.CreateTime), - UpdateTime: ConvertTimestampToTime(from.UpdateTime), - Keyword: from.Keyword, - Path: from.Path, - Method: from.Method, - Operation: from.Operation, - Status: ConvertInt32ToStatus(from.Status), + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + ServiceName: from.ServiceName, + Keyword: from.Keyword, + Path: from.Path, + Method: from.Method, + Operation: from.Operation, + Status: enums.Status(from.Status), } return to } @@ -602,27 +318,16 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Keyword: from.Keyword, - Status: ConvertStatusToInt32(from.Status), + Status: int32(from.Status), Path: from.Path, Operation: from.Operation, Method: from.Method, Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), + ServiceName: from.ServiceName, } return to } -// ConvertResourcesPBToResources converts a slice of *ResourcePB to a slice of *Resource. -func ConvertResourcesPBToResources(froms ResourcesPB) Resources { - if froms == nil { - return nil - } - tos := make(Resources, len(froms)) - for i, f := range froms { - tos[i] = ConvertResourcePBToResource(f) - } - return tos -} - // ConvertResourcesToResourcesPB converts a slice of *Resource to a slice of *ResourcePB. func ConvertResourcesToResourcesPB(froms Resources) ResourcesPB { if froms == nil { @@ -635,32 +340,6 @@ func ConvertResourcesToResourcesPB(froms Resources) ResourcesPB { return tos } -// ConvertRoleEdgesPBToRoleEdges converts RoleEdgesPB to RoleEdges. -func ConvertRoleEdgesPBToRoleEdges(from *RoleEdgesPB) *RoleEdges { - if from == nil { - return nil - } - - to := &RoleEdges{ - Users: ConvertUsersPBToUsers(from.Users), - UserRoles: ConvertUserRolesPBToUserRoles(from.UserRoles), - } - return to -} - -// ConvertRoleEdgesToRoleEdgesPB converts RoleEdges to RoleEdgesPB. -func ConvertRoleEdgesToRoleEdgesPB(from *RoleEdges) *RoleEdgesPB { - if from == nil { - return nil - } - - to := &RoleEdgesPB{ - Users: ConvertUsersToUsersPB(from.Users), - UserRoles: ConvertUserRolesToUserRolesPB(from.UserRoles), - } - return to -} - // ConvertRolePBToRole converts RolePB to Role. func ConvertRolePBToRole(from *RolePB) *Role { if from == nil { @@ -681,32 +360,6 @@ func ConvertRolePBToRole(from *RolePB) *Role { return to } -// ConvertRolePermissionEdgesPBToRolePermissionEdges converts RolePermissionEdgesPB to RolePermissionEdges. -func ConvertRolePermissionEdgesPBToRolePermissionEdges(from *RolePermissionEdgesPB) *RolePermissionEdges { - if from == nil { - return nil - } - - to := &RolePermissionEdges{ - Role: ConvertRolePBToRole(from.Role), - Permission: ConvertPermissionPBToPermission(from.Permission), - } - return to -} - -// ConvertRolePermissionEdgesToRolePermissionEdgesPB converts RolePermissionEdges to RolePermissionEdgesPB. -func ConvertRolePermissionEdgesToRolePermissionEdgesPB(from *RolePermissionEdges) *RolePermissionEdgesPB { - if from == nil { - return nil - } - - to := &RolePermissionEdgesPB{ - Role: ConvertRoleToRolePB(from.Role), - Permission: ConvertPermissionToPermissionPB(from.Permission), - } - return to -} - // ConvertRolePermissionPBToRolePermission converts RolePermissionPB to RolePermission. func ConvertRolePermissionPBToRolePermission(from *RolePermissionPB) *RolePermission { if from == nil { @@ -735,30 +388,6 @@ func ConvertRolePermissionToRolePermissionPB(from *RolePermission) *RolePermissi return to } -// ConvertRolePermissionsPBToRolePermissions converts a slice of *RolePermissionPB to a slice of *RolePermission. -func ConvertRolePermissionsPBToRolePermissions(froms RolePermissionsPB) RolePermissions { - if froms == nil { - return nil - } - tos := make(RolePermissions, len(froms)) - for i, f := range froms { - tos[i] = ConvertRolePermissionPBToRolePermission(f) - } - return tos -} - -// ConvertRolePermissionsToRolePermissionsPB converts a slice of *RolePermission to a slice of *RolePermissionPB. -func ConvertRolePermissionsToRolePermissionsPB(froms RolePermissions) RolePermissionsPB { - if froms == nil { - return nil - } - tos := make(RolePermissionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertRolePermissionToRolePermissionPB(f) - } - return tos -} - // ConvertRoleToRolePB converts Role to RolePB. func ConvertRoleToRolePB(from *Role) *RolePB { if from == nil { @@ -781,18 +410,6 @@ func ConvertRoleToRolePB(from *Role) *RolePB { return to } -// ConvertRolesPBToRoles converts a slice of *RolePB to a slice of *Role. -func ConvertRolesPBToRoles(froms RolesPB) Roles { - if froms == nil { - return nil - } - tos := make(Roles, len(froms)) - for i, f := range froms { - tos[i] = ConvertRolePBToRole(f) - } - return tos -} - // ConvertRolesToRolesPB converts a slice of *Role to a slice of *RolePB. func ConvertRolesToRolesPB(froms Roles) RolesPB { if froms == nil { @@ -805,32 +422,6 @@ func ConvertRolesToRolesPB(froms Roles) RolesPB { return tos } -// ConvertUserDepartmentEdgesPBToUserDepartmentEdges converts UserDepartmentEdgesPB to UserDepartmentEdges. -func ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from *UserDepartmentEdgesPB) *UserDepartmentEdges { - if from == nil { - return nil - } - - to := &UserDepartmentEdges{ - User: ConvertUserPBToUser(from.User), - Department: ConvertDepartmentPBToDepartment(from.Department), - } - return to -} - -// ConvertUserDepartmentEdgesToUserDepartmentEdgesPB converts UserDepartmentEdges to UserDepartmentEdgesPB. -func ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(from *UserDepartmentEdges) *UserDepartmentEdgesPB { - if from == nil { - return nil - } - - to := &UserDepartmentEdgesPB{ - User: ConvertUserToUserPB(from.User), - Department: ConvertDepartmentToDepartmentPB(from.Department), - } - return to -} - // ConvertUserDepartmentPBToUserDepartment converts UserDepartmentPB to UserDepartment. func ConvertUserDepartmentPBToUserDepartment(from *UserDepartmentPB) *UserDepartment { if from == nil { @@ -841,7 +432,6 @@ func ConvertUserDepartmentPBToUserDepartment(from *UserDepartmentPB) *UserDepart ID: int(from.Id), UserID: from.UserId, DepartmentID: from.DepartmentId, - Edges: *ConvertUserDepartmentEdgesPBToUserDepartmentEdges(from.Edges), } return to } @@ -856,57 +446,6 @@ func ConvertUserDepartmentToUserDepartmentPB(from *UserDepartment) *UserDepartme Id: int64(from.ID), UserId: from.UserID, DepartmentId: from.DepartmentID, - Edges: ConvertUserDepartmentEdgesToUserDepartmentEdgesPB(&from.Edges), - } - return to -} - -// ConvertUserDepartmentsPBToUserDepartments converts a slice of *UserDepartmentPB to a slice of *UserDepartment. -func ConvertUserDepartmentsPBToUserDepartments(froms UserDepartmentsPB) UserDepartments { - if froms == nil { - return nil - } - tos := make(UserDepartments, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserDepartmentPBToUserDepartment(f) - } - return tos -} - -// ConvertUserDepartmentsToUserDepartmentsPB converts a slice of *UserDepartment to a slice of *UserDepartmentPB. -func ConvertUserDepartmentsToUserDepartmentsPB(froms UserDepartments) UserDepartmentsPB { - if froms == nil { - return nil - } - tos := make(UserDepartmentsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserDepartmentToUserDepartmentPB(f) - } - return tos -} - -// ConvertUserEdgesPBToUserEdges converts UserEdgesPB to UserEdges. -func ConvertUserEdgesPBToUserEdges(from *UserEdgesPB) *UserEdges { - if from == nil { - return nil - } - - to := &UserEdges{ - Roles: ConvertRolesPBToRoles(from.Roles), - UserRoles: ConvertUserRolesPBToUserRoles(from.UserRoles), - } - return to -} - -// ConvertUserEdgesToUserEdgesPB converts UserEdges to UserEdgesPB. -func ConvertUserEdgesToUserEdgesPB(from *UserEdges) *UserEdgesPB { - if from == nil { - return nil - } - - to := &UserEdgesPB{ - Roles: ConvertRolesToRolesPB(from.Roles), - UserRoles: ConvertUserRolesToUserRolesPB(from.UserRoles), } return to } @@ -932,42 +471,19 @@ func ConvertUserPBToUser(from *UserPB) *User { Gender: ConvertStringToGender(from.Gender), Phone: from.Phone, Email: from.Email, + I18n: from.I18N, Remark: from.Remark, Token: from.Token, Status: enums.Status(from.Status), LastLoginIP: from.LastLoginIp, + LoginIP: from.LoginIp, LastLoginTime: ConvertTimestampToTime(from.LastLoginTime), + LoginTime: ConvertTimestampToTime(from.LoginTime), SanctionDate: ConvertTimestampToTime(from.SanctionDate), } return to } -// ConvertUserPositionEdgesPBToUserPositionEdges converts UserPositionEdgesPB to UserPositionEdges. -func ConvertUserPositionEdgesPBToUserPositionEdges(from *UserPositionEdgesPB) *UserPositionEdges { - if from == nil { - return nil - } - - to := &UserPositionEdges{ - User: ConvertUserPBToUser(from.User), - Position: ConvertPositionPBToPosition(from.Position), - } - return to -} - -// ConvertUserPositionEdgesToUserPositionEdgesPB converts UserPositionEdges to UserPositionEdgesPB. -func ConvertUserPositionEdgesToUserPositionEdgesPB(from *UserPositionEdges) *UserPositionEdgesPB { - if from == nil { - return nil - } - - to := &UserPositionEdgesPB{ - User: ConvertUserToUserPB(from.User), - Position: ConvertPositionToPositionPB(from.Position), - } - return to -} - // ConvertUserPositionPBToUserPosition converts UserPositionPB to UserPosition. func ConvertUserPositionPBToUserPosition(from *UserPositionPB) *UserPosition { if from == nil { @@ -996,56 +512,6 @@ func ConvertUserPositionToUserPositionPB(from *UserPosition) *UserPositionPB { return to } -// ConvertUserPositionsPBToUserPositions converts a slice of *UserPositionPB to a slice of *UserPosition. -func ConvertUserPositionsPBToUserPositions(froms UserPositionsPB) UserPositions { - if froms == nil { - return nil - } - tos := make(UserPositions, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserPositionPBToUserPosition(f) - } - return tos -} - -// ConvertUserPositionsToUserPositionsPB converts a slice of *UserPosition to a slice of *UserPositionPB. -func ConvertUserPositionsToUserPositionsPB(froms UserPositions) UserPositionsPB { - if froms == nil { - return nil - } - tos := make(UserPositionsPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserPositionToUserPositionPB(f) - } - return tos -} - -// ConvertUserRoleEdgesPBToUserRoleEdges converts UserRoleEdgesPB to UserRoleEdges. -func ConvertUserRoleEdgesPBToUserRoleEdges(from *UserRoleEdgesPB) *UserRoleEdges { - if from == nil { - return nil - } - - to := &UserRoleEdges{ - User: ConvertUserPBToUser(from.User), - Role: ConvertRolePBToRole(from.Role), - } - return to -} - -// ConvertUserRoleEdgesToUserRoleEdgesPB converts UserRoleEdges to UserRoleEdgesPB. -func ConvertUserRoleEdgesToUserRoleEdgesPB(from *UserRoleEdges) *UserRoleEdgesPB { - if from == nil { - return nil - } - - to := &UserRoleEdgesPB{ - User: ConvertUserToUserPB(from.User), - Role: ConvertRoleToRolePB(from.Role), - } - return to -} - // ConvertUserRolePBToUserRole converts UserRolePB to UserRole. func ConvertUserRolePBToUserRole(from *UserRolePB) *UserRole { if from == nil { @@ -1076,30 +542,6 @@ func ConvertUserRoleToUserRolePB(from *UserRole) *UserRolePB { return to } -// ConvertUserRolesPBToUserRoles converts a slice of *UserRolePB to a slice of *UserRole. -func ConvertUserRolesPBToUserRoles(froms UserRolesPB) UserRoles { - if froms == nil { - return nil - } - tos := make(UserRoles, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserRolePBToUserRole(f) - } - return tos -} - -// ConvertUserRolesToUserRolesPB converts a slice of *UserRole to a slice of *UserRolePB. -func ConvertUserRolesToUserRolesPB(froms UserRoles) UserRolesPB { - if froms == nil { - return nil - } - tos := make(UserRolesPB, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserRoleToUserRolePB(f) - } - return tos -} - // ConvertUserToUserPB converts User to UserPB. func ConvertUserToUserPB(from *User) *UserPB { if from == nil { @@ -1108,10 +550,10 @@ func ConvertUserToUserPB(from *User) *UserPB { to := &UserPB{ Id: from.ID, - CreateAuthor: from.CreateAuthor, - UpdateAuthor: from.UpdateAuthor, CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + CreateAuthor: from.CreateAuthor, + UpdateAuthor: from.UpdateAuthor, Uuid: from.UUID, AllowedIp: from.AllowedIP, Username: from.Username, @@ -1124,26 +566,17 @@ func ConvertUserToUserPB(from *User) *UserPB { Remark: from.Remark, Token: from.Token, Status: int32(from.Status), + I18N: from.I18n, LastLoginIp: from.LastLoginIP, + LoginIp: from.LoginIP, LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), + LoginTime: ConvertTimeToTimestamp(from.LoginTime), SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), Roles: ConvertRolesToRolesPB(from.Edges.Roles), } return to } -// ConvertUsersPBToUsers converts a slice of *UserPB to a slice of *User. -func ConvertUsersPBToUsers(froms UsersPB) Users { - if froms == nil { - return nil - } - tos := make(Users, len(froms)) - for i, f := range froms { - tos[i] = ConvertUserPBToUser(f) - } - return tos -} - // ConvertUsersToUsersPB converts a slice of *User to a slice of *UserPB. func ConvertUsersToUsersPB(froms Users) UsersPB { if froms == nil { @@ -1156,34 +589,6 @@ func ConvertUsersToUsersPB(froms Users) UsersPB { return tos } -// ConvertViewEdgesPBToViewEdges converts ViewEdgesPB to ViewEdges. -func ConvertViewEdgesPBToViewEdges(from *ViewEdgesPB) *ViewEdges { - if from == nil { - return nil - } - - to := &ViewEdges{ - Parent: ConvertViewPBToView(from.Parent), - Children: ConvertViewsPBToViews(from.Children), - Resources: ConvertResourcesPBToResources(from.Resources), - } - return to -} - -// ConvertViewEdgesToViewEdgesPB converts ViewEdges to ViewEdgesPB. -func ConvertViewEdgesToViewEdgesPB(from *ViewEdges) *ViewEdgesPB { - if from == nil { - return nil - } - - to := &ViewEdgesPB{ - Children: ConvertViewsToViewsPB(from.Children), - Parent: ConvertViewToViewPB(from.Parent), - Resources: ConvertResourcesToResourcesPB(from.Resources), - } - return to -} - // ConvertViewPBToView converts ViewPB to View. func ConvertViewPBToView(from *ViewPB) *View { if from == nil { @@ -1199,6 +604,7 @@ func ConvertViewPBToView(from *ViewPB) *View { Scope: from.Scope, Name: from.Name, Type: ConvertStringToType(from.Type), + Component: from.Component, Path: from.Path, Icon: from.Icon, Visible: from.Visible, @@ -1223,6 +629,7 @@ func ConvertViewToViewPB(from *View) *ViewPB { Scope: from.Scope, Sequence: int32(from.Sequence), Type: ConvertTypeToString(from.Type), + Component: from.Component, Icon: from.Icon, Visible: from.Visible, Path: from.Path, @@ -1235,18 +642,6 @@ func ConvertViewToViewPB(from *View) *ViewPB { return to } -// ConvertViewsPBToViews converts a slice of *ViewPB to a slice of *View. -func ConvertViewsPBToViews(froms ViewsPB) Views { - if froms == nil { - return nil - } - tos := make(Views, len(froms)) - for i, f := range froms { - tos[i] = ConvertViewPBToView(f) - } - return tos -} - // ConvertViewsToViewsPB converts a slice of *View to a slice of *ViewPB. func ConvertViewsToViewsPB(froms Views) ViewsPB { if froms == nil { diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index 0df28c0d..410225b6 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -1,7 +1,6 @@ package dto import ( - "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/data/entity/ent/view" ) @@ -53,25 +52,3 @@ func ConvertStringToType(from string) view.Type { func ConvertTypeToString(from view.Type) string { return ViewTypeName(from) } - -// ConvertInt32ToStatus is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertInt32ToStatus(from int32) resource.Status { - switch from { - case 1: - return resource.StatusEnabled - default: - return resource.StatusDisabled - } -} - -// ConvertStatusToInt32 is a custom conversion function stub. -// Please implement this function to complete the conversion. -func ConvertStatusToInt32(from resource.Status) int32 { - switch from { - case resource.StatusEnabled: - return 1 - default: - return 0 - } -} diff --git a/internal/helpers/providers/providers.go b/internal/helpers/providers/providers.go index 6eb87497..f4aef9ba 100644 --- a/internal/helpers/providers/providers.go +++ b/internal/helpers/providers/providers.go @@ -33,7 +33,7 @@ import ( var ( factory = secmiddleware.NewFactory() - policies = map[string]security.Policy{} + policies = make(map[string]security.Policy) ) func init() { diff --git a/internal/tasks/seeder/seeder.go b/internal/tasks/seeder/seeder.go index f3372397..6cdc4d79 100644 --- a/internal/tasks/seeder/seeder.go +++ b/internal/tasks/seeder/seeder.go @@ -9,10 +9,12 @@ import ( "context" "crypto/rand" "math/big" + "strings" "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" + "github.com/origadmin/contrib/security" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/conf" @@ -30,17 +32,21 @@ const ( // Seeder is the container for initialization tasks. type Seeder struct { - userUseCase *biz.UserUseCase - rootUserCfg *confpb.RootUser - log *log.Helper + userUseCase *biz.UserUseCase + resourceUseCase *biz.ResourceUseCase + viewUseCase *biz.ViewUseCase + rootUserCfg *confpb.RootUser + log *log.Helper } // NewSeeder creates a new Seeder. -func NewSeeder(userUseCase *biz.UserUseCase, cfg *conf.Config, logger log.Logger) (*Seeder, error) { +func NewSeeder(userUseCase *biz.UserUseCase, resourceUseCase *biz.ResourceUseCase, viewUseCase *biz.ViewUseCase, cfg *conf.Config, logger log.Logger) (*Seeder, error) { return &Seeder{ - userUseCase: userUseCase, - rootUserCfg: cfg.RootUser(), - log: log.NewHelper(log.With(logger, "module", "seeder")), + userUseCase: userUseCase, + resourceUseCase: resourceUseCase, + viewUseCase: viewUseCase, + rootUserCfg: cfg.RootUser(), + log: log.NewHelper(log.With(logger, "module", "seeder")), }, nil } @@ -49,7 +55,12 @@ func (s *Seeder) Run() error { if err := s.createRootUser(); err != nil { return err } - // Add other seeding tasks here, e.g., s.createInitialMenus() + if err := s.createInitialResources(); err != nil { + return err + } + if err := s.createInitialViews(); err != nil { + return err + } return nil } @@ -109,6 +120,100 @@ func (s *Seeder) createRootUser() error { return nil } +func (s *Seeder) createInitialResources() error { + ctx := context.Background() + for _, policy := range security.RegisteredPolicies() { + parts := strings.Split(policy.ServiceMethod, "/") + if len(parts) < 3 { + continue + } + // e.g. /api.v1.services.auth.AuthService/Login -> auth:auth:Login:write + services := strings.SplitN(strings.TrimPrefix(policy.ServiceMethod, "/"), "/", 2) + keyword := strings.ReplaceAll(services[0], ".", ":") + keyword = strings.TrimPrefix(keyword, "api:v1:services:") + keyword = strings.ReplaceAll(keyword, "Service", "") + + keyword = keyword + ":" + services[1] + + // Map HTTP method to action suffix + var action string + if policy.GatewayPath != "" { + if methodParts := strings.SplitN(policy.GatewayPath, ":", 2); len(methodParts) >= 1 { + method := methodParts[0] + switch method { + case "GET", "HEAD", "OPTIONS": + action = "Read" + case "POST": + action = "Write" + case "PUT", "PATCH": + action = "Write" + case "DELETE": + action = "Delete" + default: + action = "Any" + } + keyword = keyword + ":" + action + } + } + + // Extract method and path from GatewayPath, e.g., "GET:/api/v1/users/{id}" + var method, path string + if policy.GatewayPath != "" { + if parts := strings.SplitN(policy.GatewayPath, ":", 2); len(parts) == 2 { + method = parts[0] + path = parts[1] + } + } + + resource := &types.Resource{ + ServiceName: services[0], + Name: policy.Name, + Keyword: keyword, + Path: path, + Operation: policy.ServiceMethod, + Method: method, + } + + _, count, err := s.resourceUseCase.ListResources(ctx, + &system.ListResourcesRequest{ + Keyword: resource.Keyword, + OnlyCount: true, + }) + if err == nil && count > 0 { + s.log.Infof("Resource '%s' already exists, skipping.", resource.Keyword) + continue + } + if _, err := s.resourceUseCase.CreateResource(ctx, resource); err != nil { + s.log.Errorf("failed to create resource %s: %v", resource.Keyword, err) + } else { + s.log.Infof("Successfully created resource: %s", resource.Keyword) + } + } + return nil +} + +func (s *Seeder) createInitialViews() error { + ctx := context.Background() + views := []*types.View{ + {Name: "Dashboard", Keyword: "dashboard", Path: "/dashboard", Component: "default"}, + {Name: "System", Keyword: "system", Path: "/system", Component: "default"}, + } + + for _, view := range views { + _, _, err := s.viewUseCase.ListViews(ctx, &system.ListViewsRequest{Keyword: view.Keyword}) + if err == nil { + s.log.Infof("View '%s' already exists, skipping.", view.Name) + continue + } + if _, err := s.viewUseCase.CreateView(ctx, view); err != nil { + s.log.Errorf("failed to create view %s: %v", view.Name, err) + } else { + s.log.Infof("Successfully created view: %s", view.Name) + } + } + return nil +} + // generateRandomPassword creates a random string of a given length. func generateRandomPassword(length int) (string, error) { b := make([]byte, length) diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 513bedcb..358914ab 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -3017,6 +3017,12 @@ components: type: string description: update_time.field.comment format: date-time + create_author: + type: string + description: create_author.field.comment + update_author: + type: string + description: update_author.field.comment keyword: type: string description: department.field.keyword @@ -3070,6 +3076,12 @@ components: type: string description: update_time.field.comment format: date-time + create_author: + type: string + description: create_author.field.comment + update_author: + type: string + description: update_author.field.comment name: type: string description: permission.field.name @@ -3128,6 +3140,12 @@ components: type: string description: update_time.field.comment format: date-time + create_author: + type: string + description: create_author.field.comment + update_author: + type: string + description: update_author.field.comment name: type: string description: position.field.name @@ -3157,15 +3175,18 @@ components: type: string description: update_time.field.comment format: date-time + create_author: + type: string + description: create_author.field.comment + update_author: + type: string + description: update_author.field.comment name: type: string description: resource.field.name keyword: type: string description: resource.field.keyword - i18n_key: - type: string - description: resource.field.i18n_key type: type: string description: resource.field.type @@ -3182,19 +3203,10 @@ components: method: type: string description: resource.field.method - component: - type: string - description: resource.field.component - icon: - type: string - description: resource.field.icon sequence: type: integer description: resource.field.sequence format: int32 - visible: - type: boolean - description: resource.field.visible tree_path: type: string description: resource.field.tree_path @@ -3228,6 +3240,8 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.Permission' description: Permissions holds the value of the permissions edge. + service_name: + type: string description: Resource is the model entity for the Resource schema. api.v1.services.types.Role: type: object @@ -3245,6 +3259,12 @@ components: type: string description: update_time.field.comment format: date-time + create_author: + type: string + description: create_author.field.comment + update_author: + type: string + description: update_author.field.comment keyword: type: string description: role.field.keyword @@ -3274,11 +3294,21 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.View' description: Views holds the value of the views edge. + view_ids: + type: array + items: + type: string + description: View Ids holds the value of the view_ids edge. users: type: array items: $ref: '#/components/schemas/api.v1.services.types.User' description: Users holds the value of the users edge. + user_ids: + type: array + items: + type: string + description: Users Ids holds the value of the user_ids edge. resources: type: array items: @@ -3308,12 +3338,6 @@ components: description: |- ID of the ent. field.primary_key.comment - create_author: - type: string - description: create_author.field.comment - update_author: - type: string - description: update_author.field.comment create_time: type: string description: create_time.field.comment @@ -3322,6 +3346,12 @@ components: type: string description: update_time.field.comment format: date-time + create_author: + type: string + description: create_author.field.comment + update_author: + type: string + description: update_author.field.comment uuid: type: string description: user.field.uuid @@ -3359,6 +3389,9 @@ components: type: integer description: user.field.status format: int32 + i18n: + type: string + description: user.field.i18n last_login_ip: type: string description: user.field.last_login_ip @@ -3381,12 +3414,7 @@ components: type: array items: $ref: '#/components/schemas/api.v1.services.types.Role' - description: |- - // user.field.manager_id - int64 manager_id = 21 [json_name = "manager_id"]; - // user.field.manager - string manager = 22 [json_name = "manager"]; - Roles holds the value of the roles edge. + description: Roles holds the value of the roles edge. role_ids: type: array items: @@ -3429,6 +3457,9 @@ components: type: type: string description: Type holds the value of the "type" field. + component: + type: string + description: Component holds the value of the "component" field. comment: type: string description: Comment holds the value of the "comment" field. From 8cd2d9873a906b7425033baef97a36f48aa10968 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 7 Jan 2026 14:16:43 +0800 Subject: [PATCH 151/158] chore(deps): add entgo.io/contrib and update protobuf dependencies --- go.mod | 4 ++- go.sum | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2692c4d8..ab3691aa 100644 --- a/go.mod +++ b/go.mod @@ -35,6 +35,7 @@ require ( ) require ( + entgo.io/contrib v0.7.0 github.com/air-verse/air v1.63.6 github.com/bufbuild/buf v1.62.1 github.com/go-kratos/kratos/cmd/kratos/v2 v2.0.0-20260105075216-c7a58ff59f80 @@ -134,6 +135,7 @@ require ( github.com/gohugoio/hugo v0.154.2 // indirect github.com/golang-cz/devslog v0.0.15 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/cel-go v0.26.1 // indirect github.com/google/gnostic-models v0.7.1 // indirect github.com/google/go-cmp v0.7.0 // indirect @@ -153,6 +155,7 @@ require ( github.com/iancoleman/strcase v0.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jdx/go-netrc v1.0.0 // indirect + github.com/jhump/protoreflect v1.10.1 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/klauspost/compress v1.18.2 // indirect github.com/klauspost/pgzip v1.2.6 // indirect @@ -205,7 +208,6 @@ require ( github.com/spf13/cobra v1.10.2 // indirect github.com/spf13/pflag v1.0.10 // indirect github.com/stoewer/go-strcase v1.3.1 // indirect - github.com/stretchr/objx v0.5.2 // indirect github.com/tdewolff/parse/v2 v2.8.5 // indirect github.com/tetratelabs/wazero v1.11.0 // indirect github.com/tidwall/btree v1.8.1 // indirect diff --git a/go.sum b/go.sum index 567f7bf8..eeb1c489 100644 --- a/go.sum +++ b/go.sum @@ -30,12 +30,15 @@ buf.build/go/standard v0.1.0 h1:g98T9IyvAl0vS3Pq8iVk6Cvj2ZiFvoUJRtfyGa0120U= buf.build/go/standard v0.1.0/go.mod h1:PiqpHz/7ZFq+kqvYhc/SK3lxFIB9N/aiH2CFC2JHIQg= cel.dev/expr v0.25.1 h1:1KrZg61W6TWSxuNZ37Xy49ps13NUovb66QLprthtwi4= cel.dev/expr v0.25.1/go.mod h1:hrXvqGP6G6gyx8UAHSHJ5RGk//1Oj5nXQ2NI02Nrsg4= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= connectrpc.com/connect v1.19.1 h1:R5M57z05+90EfEvCY1b7hBxDVOUl45PrtXtAV2fOC14= connectrpc.com/connect v1.19.1/go.mod h1:tN20fjdGlewnSFeZxLKb0xwIZ6ozc3OQs2hTXy4du9w= connectrpc.com/otelconnect v0.9.0 h1:NggB3pzRC3pukQWaYbRHJulxuXvmCKCKkQ9hbrHAWoA= connectrpc.com/otelconnect v0.9.0/go.mod h1:AEkVLjCPXra+ObGFCOClcJkNjS7zPaQSqvO0lCyjfZc= dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= +entgo.io/contrib v0.7.0 h1:4Ghx8O0rqSMmca3FIJ6QyZbQAoLvdzWqLMl1MbHFEEw= +entgo.io/contrib v0.7.0/go.mod h1:zbPSUrbn+6dfyv8S9HWEvn1MyGpO95ik2lUNgaqWTt4= entgo.io/ent v0.14.5 h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4= entgo.io/ent v0.14.5/go.mod h1:zTzLmWtPvGpmSwtkaayM2cm5m819NdM7z7tYPq3vN0U= github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= @@ -44,6 +47,7 @@ github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEK github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 h1:+tu3HOoMXB7RXEINRVIpxJCT+KdYiI7LAEAUrOw3dIU= github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69/go.mod h1:L1AbZdiDllfyYH5l5OkAaZtk7VkWe89bPJFmnDBNHxg= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= @@ -143,6 +147,7 @@ github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY= github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -180,6 +185,7 @@ github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyM github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/cli/browser v1.3.0 h1:LejqCrpWr+1pRqmEPDGnTZOjsMe7sehifLynZJuqJpo= github.com/cli/browser v1.3.0/go.mod h1:HH8s+fOAxjhQoBUAsKuPCbqUuxZDhQ2/aD+SzsEfBTk= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/clipperhouse/displaywidth v0.6.2 h1:ZDpTkFfpHOKte4RG5O/BOyf3ysnvFswpyYrV7z2uAKo= github.com/clipperhouse/displaywidth v0.6.2/go.mod h1:R+kHuzaYWFkTm7xoMmK1lFydbci4X2CicfbGstSGg0o= github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= @@ -230,9 +236,11 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/emicklei/proto v1.14.2 h1:wJPxPy2Xifja9cEMrcA/g08art5+7CGJNFNk35iXC1I= github.com/emicklei/proto v1.14.2/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.13.5-0.20251024222203-75eaa193e329 h1:K+fnvUM0VZ7ZFJf0n4L/BRlnsb9pL/GuDG6FqaH+PwM= github.com/envoyproxy/go-control-plane/envoy v1.35.0 h1:ixjkELDE+ru6idPxcHLj8LBVc2bFP7iBytj353BoHUo= github.com/envoyproxy/go-control-plane/envoy v1.35.0/go.mod h1:09qwbGVuSWWAyN5t/b3iyVfz5+z8QWGrzkoqm/8SbEs= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v1.3.0 h1:TvGH1wof4H33rezVKWSpqKz5NXWg5VPuZ0uONDT6eb4= github.com/envoyproxy/protoc-gen-validate v1.3.0/go.mod h1:HvYl7zwPa5mffgyeTUHA9zHIH36nmrm7oCbo4YKoSWA= github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= @@ -331,12 +339,21 @@ github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9v github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U= github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -348,8 +365,11 @@ github.com/google/gnostic v0.7.1 h1:t5Kc7j/8kYr8t2u11rykRrPPovlEMG4+xdc/SpekATs= github.com/google/gnostic v0.7.1/go.mod h1:KSw6sxnxEBFM8jLPfJd46xZP+yQcfE8XkiqfZx5zR28= github.com/google/gnostic-models v0.7.1 h1:SisTfuFKJSKM5CPZkffwi6coztzzeYUhc3v4yxLWH8c= github.com/google/gnostic-models v0.7.1/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= @@ -358,12 +378,14 @@ github.com/google/go-containerregistry v0.20.7/go.mod h1:Lx5LCZQjLH1QBaMPeGwsME9 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.7.0 h1:JxUKI6+CVBgCO2WToKy/nQk0sS+amI9z9EjVmdaocj4= github.com/google/wire v0.7.0/go.mod h1:n6YbUQD9cPKTnHXEBN2DXlOp/mVADhVErcMFb0v3J18= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8= github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= @@ -430,6 +452,8 @@ github.com/jdkato/prose v1.2.1 h1:Fp3UnJmLVISmlc57BgKUzdjr0lOtjqTZicL3PaYy6cU= github.com/jdkato/prose v1.2.1/go.mod h1:AiRHgVagnEx2JbQRQowVBKjG0bcs/vtkGCH1dYAL1rA= github.com/jdx/go-netrc v1.0.0 h1:QbLMLyCZGj0NA8glAhxUpf1zDg6cxnWgMBbjq40W0gQ= github.com/jdx/go-netrc v1.0.0/go.mod h1:Gh9eFQJnoTNIRHXl2j5bJXA1u84hQWJWgGh569zF3v8= +github.com/jhump/protoreflect v1.10.1 h1:iH+UZfsbRE6vpyZH7asAjTPWJf7RJbpZ9j/N3lDlKs0= +github.com/jhump/protoreflect v1.10.1/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= github.com/jhump/protoreflect/v2 v2.0.0-beta.2 h1:qZU+rEZUOYTz1Bnhi3xbwn+VxdXkLVeEpAeZzVXLY88= github.com/jhump/protoreflect/v2 v2.0.0-beta.2/go.mod h1:4tnOYkB/mq7QTyS3YKtVtNrJv4Psqout8HA1U+hZtgM= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= @@ -441,6 +465,7 @@ github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk= github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4= github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU= @@ -541,6 +566,7 @@ github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOF github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/niklasfasching/go-org v1.9.1 h1:/3s4uTPOF06pImGa2Yvlp24yKXZoTYM+nsIlMzfpg/0= github.com/niklasfasching/go-org v1.9.1/go.mod h1:ZAGFFkWvUQcpazmi/8nHqwvARpr1xpb+Es67oUGX/48= +github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 h1:G7ERwszslrBzRxj//JalHPu/3yz+De2J+4aLtSRlHiY= github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037/go.mod h1:2bpvgLBZEtENV5scfDFEtB/5+1M4hkQhDQrccEJ/qGw= github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 h1:bQx3WeLcUWy+RletIKwUIt4x3t8n2SxavmoclizMb8c= @@ -604,6 +630,7 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= @@ -622,6 +649,7 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rodaine/protogofakeit v0.1.1 h1:ZKouljuRM3A+TArppfBqnH8tGZHOwM/pjvtXe9DaXH8= github.com/rodaine/protogofakeit v0.1.1/go.mod h1:pXn/AstBYMaSfc1/RqH3N82pBuxtWgejz1AlYpY1mI0= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= @@ -698,6 +726,8 @@ github.com/woodsbury/decimal128 v1.3.0 h1:8pffMNWIlC0O5vbyHWFZAt5yWvWcrHA+3ovIIj github.com/woodsbury/decimal128 v1.3.0/go.mod h1:C5UTmyTjW3JftjUFzOVhC20BEQa2a4ZKOB5I6Zjb+ds= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.7.13 h1:GPddIs617DnBLFFVJFgpo1aBfe/4xcvMc3SB5t/D0pA= github.com/yuin/goldmark v1.7.13/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg= @@ -751,18 +781,28 @@ go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU= golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 h1:fQsdNF2N+/YewlRZiricy4P1iimyPKZ/xwniHj8Q2a0= golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU= golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= golang.org/x/image v0.34.0 h1:33gCkyw9hmwbZJeZkct8XyR11yH889EQt/QH4VmXMn8= golang.org/x/image v0.34.0/go.mod h1:2RNFBZRB+vnwwFil8GkMdRvrJOFd1AzdZI6vOY+eJVU= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -770,12 +810,17 @@ golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI= golang.org/x/mod v0.31.0/go.mod h1:43JraMp9cGx1Rx3AqioxrbrhNsLl2l/iNAvuBkrezpg= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -786,10 +831,13 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -800,10 +848,12 @@ golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -812,6 +862,7 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -862,9 +913,16 @@ golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= @@ -876,24 +934,46 @@ golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/ golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk= gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79 h1:Nt6z9UHqSlIdIGJdz6KhTIs2VRx/iOsA5iE8bmQNcxs= +google.golang.org/genproto v0.0.0-20250715232539-7130f93afb79/go.mod h1:kTmlBHMPqR5uCZPBvwa2B18mvubkjyY3CRLI0c6fj0s= google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b h1:uA40e2M6fYRBf0+8uN5mLlqUtV192iiksiICIBkYJ1E= google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:Xa7le7qx2vmqB/SzWUBa7KdMjpdpAHlh5QCSnjessQk= google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b h1:Mv8VFug0MP9e5vUxfBcE3vUkV6CImK3cMNMIDFjmzxU= google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.78.0 h1:K1XZG/yGDJnzMdd/uZHAkVqJE+xIDOcmdSFZkBUicNc= google.golang.org/grpc v1.78.0/go.mod h1:I47qjTo4OKbMkjA/aOOwxDIiPSBofUtQUI5EfpWvW7U= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0 h1:6Al3kEFFP9VJhRz3DID6quisgPnTeZVr4lep9kkxdPA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.6.0/go.mod h1:QLvsjh0OIR0TYBeiu2bkWGTJBUNQ64st52iWj/yA93I= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -905,6 +985,9 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= modernc.org/cc/v4 v4.27.1 h1:9W30zRlYrefrDV2JE2O8VDtJ1yPGownxciz5rrbQZis= modernc.org/cc/v4 v4.27.1/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= modernc.org/ccgo/v4 v4.30.1 h1:4r4U1J6Fhj98NKfSjnPUN7Ze2c6MnAdL0hWw6+LrJpc= From e399e78329eba65d489fd31fbd9404d2cc20a894 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 7 Jan 2026 17:01:53 +0800 Subject: [PATCH 152/158] feat(proto): restructure system proto definitions and optimize field ordering --- api/v1/proto/types/system.proto | 222 +-- api/v1/services/types/system.pb.go | 807 +++++----- api/v1/services/types/system.pb.validate.go | 313 +++- internal/data/entity/ent/client.go | 32 + internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 29 +- internal/data/entity/ent/mutation.go | 1304 +++++++++++++++-- internal/data/entity/ent/mutation_fields.go | 120 +- internal/data/entity/ent/resource.go | 184 ++- internal/data/entity/ent/resource/resource.go | 161 +- internal/data/entity/ent/resource/where.go | 946 +++++++++--- internal/data/entity/ent/resource_create.go | 295 +++- internal/data/entity/ent/resource_query.go | 177 ++- internal/data/entity/ent/resource_update.go | 822 +++++++++-- internal/data/entity/ent/runtime/runtime.go | 38 +- internal/data/entity/ent/schema/resource.go | 44 +- internal/data/entity/ent/schema/view.go | 13 + internal/data/entity/ent/view.go | 49 +- internal/data/entity/ent/view/view.go | 35 + internal/data/entity/ent/view/where.go | 301 ++++ internal/data/entity/ent/view_create.go | 80 + internal/data/entity/ent/view_query.go | 8 + internal/data/entity/ent/view_update.go | 211 +++ internal/features/auth/dto/dto.gen.go | 137 +- internal/features/system/biz/resource.go | 12 +- internal/features/system/dal/resource.go | 44 +- internal/features/system/dto/dto.gen.go | 121 +- internal/features/system/dto/resource.go | 2 + internal/features/system/dto/schema_test.go | 108 ++ internal/tasks/seeder/seeder.go | 65 +- resources/api-docs/openapi/openapi.yaml | 92 +- 31 files changed, 5533 insertions(+), 1241 deletions(-) create mode 100644 internal/features/system/dto/schema_test.go diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index 0538d79e..6789e92a 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -32,34 +32,34 @@ message View { int32 sequence = 9 [json_name = "sequence"]; // Type holds the value of the "type" field. string type = 10 [json_name = "type"]; - // Component holds the value of the "component" field. - string component = 11 [json_name = "component"]; // Comment holds the value of the "comment" field. - string comment = 12 [json_name = "comment"]; + string comment = 11 [json_name = "comment"]; // Icon holds the value of the "icon" field. - string icon = 13 [json_name = "icon"]; + string icon = 12 [json_name = "icon"]; // Visible holds the value of the "visible" field. - bool visible = 14 [json_name = "visible"]; + bool visible = 13 [json_name = "visible"]; // Path holds the value of the "path" field. - string path = 15 [json_name = "path"]; + string path = 14 [json_name = "path"]; // TreePath holds the value of the "tree_path" field. - string tree_path = 16 [json_name = "tree_path"]; + string tree_path = 15 [json_name = "tree_path"]; // Properties holds the value of the "properties" field. - string properties = 17 [json_name = "properties"]; + string properties = 16 [json_name = "properties"]; // Status holds the value of the "status" field. - int32 status = 18 [json_name = "status"]; + int32 status = 17 [json_name = "status"]; // ParentID holds the value of the "parent_id" field. - int64 parent_id = 19 [json_name = "parent_id"]; + int64 parent_id = 18 [json_name = "parent_id"]; // ParentPath holds the value of the "parent_path" field. - string parent_path = 20 [json_name = "parent_path"]; + string parent_path = 19 [json_name = "parent_path"]; + // Component holds the value of the "component" field. + string component = 20 [json_name = "component"]; // Children holds the value of the children edge. - repeated View children = 21 [json_name = "children"]; + repeated View children = 100 [json_name = "children"]; // Parent holds the value of the parent edge. - View parent = 22 [json_name = "parent"]; + View parent = 101 [json_name = "parent"]; // Resources holds the value of the resources edge. - repeated Resource resources = 23 [json_name = "resources"]; + repeated Resource resources = 102 [json_name = "resources"]; // Roles holds the value of the roles edge. - repeated Role roles = 24 [json_name = "roles"]; + repeated Role roles = 103 [json_name = "roles"]; } // Role is the model entity for the Role schema. @@ -71,40 +71,32 @@ message Role { google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; - // create_author.field.comment - int64 create_author = 4 [json_name = "create_author"]; - // update_author.field.comment - int64 update_author = 5 [json_name = "update_author"]; // role.field.keyword - string keyword = 6 [json_name = "keyword"]; + string keyword = 4 [json_name = "keyword"]; // role.field.name - string name = 7 [json_name = "name"]; + string name = 5 [json_name = "name"]; // role.field.description - string description = 8 [json_name = "description"]; + string description = 6 [json_name = "description"]; // role.field.type - int32 type = 9 [json_name = "type"]; + int32 type = 7 [json_name = "type"]; // role.field.sequence - int32 sequence = 10 [json_name = "sequence"]; + int32 sequence = 8 [json_name = "sequence"]; // role.field.status - int32 status = 11 [json_name = "status"]; + int32 status = 9 [json_name = "status"]; // role.field.is_types - bool is_types = 12 [json_name = "is_types"]; + bool is_types = 10 [json_name = "is_types"]; // Views holds the value of the views edge. - repeated View views = 21 [json_name = "views"]; - // View Ids holds the value of the view_ids edge. - repeated int64 view_ids = 20 [json_name = "view_ids"]; + repeated View views = 100 [json_name = "views"]; // Users holds the value of the users edge. - repeated User users = 22 [json_name = "users"]; - // Users Ids holds the value of the user_ids edge. - repeated int64 user_ids = 23 [json_name = "user_ids"]; + repeated User users = 101 [json_name = "users"]; // Resources holds the value of the resources edge. - repeated Resource resources = 24 [json_name = "resources"]; + repeated Resource resources = 102 [json_name = "resources"]; // Resource Ids holds the value of the resource_ids edge. - repeated int64 resource_ids = 25 [json_name = "resource_ids"]; + repeated int64 resource_ids = 103 [json_name = "resource_ids"]; // Permissions holds the value of the permissions edge. - repeated Permission permissions = 26 [json_name = "permissions"]; + repeated Permission permissions = 104 [json_name = "permissions"]; // Permission Ids holds the value of the permission_ids edge. - repeated int64 permission_ids = 27 [json_name = "permission_ids"]; + repeated int64 permission_ids = 105 [json_name = "permission_ids"]; } // User is the model entity for the User schema. @@ -112,14 +104,14 @@ message User { // ID of the ent. // field.primary_key.comment int64 id = 1 [json_name = "id"]; - // create_time.field.comment - google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; - // update_time.field.comment - google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; // create_author.field.comment - int64 create_author = 4 [json_name = "create_author"]; + int64 create_author = 2 [json_name = "create_author"]; // update_author.field.comment - int64 update_author = 5 [json_name = "update_author"]; + int64 update_author = 3 [json_name = "update_author"]; + // create_time.field.comment + google.protobuf.Timestamp create_time = 4 [json_name = "create_time"]; + // update_time.field.comment + google.protobuf.Timestamp update_time = 5 [json_name = "update_time"]; // user.field.uuid string uuid = 6 [json_name = "uuid"]; // user.field.allowed_ip @@ -144,22 +136,24 @@ message User { string token = 16 [json_name = "token"]; // user.field.status int32 status = 17 [json_name = "status"]; - // user.field.i18n - string i18n = 18 [json_name = "i18n"]; // user.field.last_login_ip - string last_login_ip = 19 [json_name = "last_login_ip"]; + string last_login_ip = 18 [json_name = "last_login_ip"]; // user.field.login_ip - string login_ip = 20 [json_name = "login_ip"]; + string login_ip = 19 [json_name = "login_ip"]; // user.field.last_login_time - google.protobuf.Timestamp last_login_time = 21 [json_name = "last_login_time"]; + google.protobuf.Timestamp last_login_time = 20 [json_name = "last_login_time"]; // user.field.login_time - google.protobuf.Timestamp login_time = 22 [json_name = "login_time"]; + google.protobuf.Timestamp login_time = 21 [json_name = "login_time"]; // user.field.sanction_date - optional google.protobuf.Timestamp sanction_date = 23 [json_name = "sanction_date"]; + optional google.protobuf.Timestamp sanction_date = 22 [json_name = "sanction_date"]; + // user.field.i18n + string i18n = 23 [json_name = "i18n"]; + // user.field.department + string department = 24 [json_name = "department"]; // Roles holds the value of the roles edge. - repeated Role roles = 24 [json_name = "roles"]; + repeated Role roles = 100 [json_name = "roles"]; // Role Ids holds the value of the role_ids - repeated int64 role_ids = 25 [json_name = "role_ids"]; + repeated int64 role_ids = 101 [json_name = "role_ids"]; } // UserRole is the model entity for the UserRole schema. @@ -177,9 +171,9 @@ message UserRole { // RoleName holds the value of the "role_name" field. string role_name = 6 [json_name = "role_name"]; // User holds the value of the user edge. - User user = 21 [json_name = "user"]; + User user = 100 [json_name = "user"]; // Role holds the value of the role edge. - Role role = 22 [json_name = "role"]; + Role role = 101 [json_name = "role"]; } // RoleView is the model entity for the RoleView schema. @@ -195,9 +189,9 @@ message RoleView { // ViewID holds the value of the "view_id" field. int64 view_id = 5 [json_name = "view_id"]; // Role holds the value of the role edge. - Role role = 21 [json_name = "role"]; + Role role = 100 [json_name = "role"]; // View holds the value of the view edge. - View view = 22 [json_name = "view"]; + View view = 101 [json_name = "view"]; } // Resource is the model entity for the Resource schema. @@ -209,26 +203,30 @@ message Resource { google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; - // create_author.field.comment - int64 create_author = 4 [json_name = "create_author"]; - // update_author.field.comment - int64 update_author = 5 [json_name = "update_author"]; // resource.field.name - string name = 6 [json_name = "name"]; + string name = 4 [json_name = "name"]; // resource.field.keyword - string keyword = 7 [json_name = "keyword"]; + string keyword = 5 [json_name = "keyword"]; + // resource.field.i18n_key + string i18n_key = 6 [json_name = "i18n_key"]; // resource.field.type - string type = 9 [json_name = "type"]; + string type = 7 [json_name = "type"]; // resource.field.status - int32 status = 10 [json_name = "status"]; + int32 status = 8 [json_name = "status"]; // resource.field.path - string path = 11 [json_name = "path"]; + string path = 9 [json_name = "path"]; // resource.field.operation - string operation = 12 [json_name = "operation"]; + string operation = 10 [json_name = "operation"]; // resource.field.method - string method = 13 [json_name = "method"]; + string method = 11 [json_name = "method"]; + // resource.field.component + string component = 12 [json_name = "component"]; + // resource.field.icon + string icon = 13 [json_name = "icon"]; // resource.field.sequence int32 sequence = 14 [json_name = "sequence"]; + // resource.field.visible + bool visible = 15 [json_name = "visible"]; // resource.field.tree_path string tree_path = 16 [json_name = "tree_path"]; // resource.field.properties @@ -237,16 +235,20 @@ message Resource { string description = 18 [json_name = "description"]; // resource.field.parent_id int64 parent_id = 19 [json_name = "parent_id"]; + // resource.field.sync_status + string sync_status = 20 [json_name = "sync_status"]; + // resource.field.service_name + string service_name = 21 [json_name = "service_name"]; + // resource.field.policy + string policy = 22 [json_name = "policy"]; // Children holds the value of the children edge. - repeated Resource children = 21 [json_name = "children"]; + repeated Resource children = 100 [json_name = "children"]; // Parent holds the value of the parent edge. - Resource parent = 22 [json_name = "parent"]; + Resource parent = 101 [json_name = "parent"]; // Permission Ids holds the value of the permission_ids edge. - repeated int64 permission_ids = 23 [json_name = "permission_ids"]; + repeated int64 permission_ids = 102 [json_name = "permission_ids"]; // Permissions holds the value of the permissions edge. - repeated Permission permissions = 24 [json_name = "permissions"]; - - string service_name = 25 [json_name = "service_name"]; + repeated Permission permissions = 103 [json_name = "permissions"]; } // department.table.comment @@ -258,30 +260,26 @@ message Department { google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; - // create_author.field.comment - int64 create_author = 4 [json_name = "create_author"]; - // update_author.field.comment - int64 update_author = 5 [json_name = "update_author"]; // department.field.keyword - string keyword = 6 [json_name = "keyword"]; + string keyword = 4 [json_name = "keyword"]; // department.field.name - string name = 7 [json_name = "name"]; + string name = 5 [json_name = "name"]; // department.field.tree_path - string tree_path = 8 [json_name = "tree_path"]; + string tree_path = 6 [json_name = "tree_path"]; // department.field.sequence - int32 sequence = 9 [json_name = "sequence"]; + int32 sequence = 7 [json_name = "sequence"]; // department.field.status - int32 status = 10 [json_name = "status"]; + int32 status = 8 [json_name = "status"]; // department.field.level - int32 level = 11 [json_name = "level"]; + int32 level = 9 [json_name = "level"]; // department.field.description - string description = 12 [json_name = "description"]; + string description = 10 [json_name = "description"]; // department.field.parent_id - int64 parent_id = 13 [json_name = "parent_id"]; + int64 parent_id = 11 [json_name = "parent_id"]; // Children holds the value of the children edge. - repeated Department children = 14 [json_name = "children"]; + repeated Department children = 100 [json_name = "children"]; // Parent holds the value of the parent edge. - Department parent = 15 [json_name = "parent"]; + Department parent = 101 [json_name = "parent"]; } // user_department.table.comment @@ -304,18 +302,28 @@ message Position { google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; - // create_author.field.comment - int64 create_author = 4 [json_name = "create_author"]; - // update_author.field.comment - int64 update_author = 5 [json_name = "update_author"]; // position.field.name - string name = 6 [json_name = "name"]; + string name = 4 [json_name = "name"]; // position.field.keyword - string keyword = 7 [json_name = "keyword"]; + string keyword = 5 [json_name = "keyword"]; // position.field.description - string description = 8 [json_name = "description"]; + string description = 6 [json_name = "description"]; // department.field.department_id - int64 department_id = 9 [json_name = "department_id"]; + int64 department_id = 7 [json_name = "department_id"]; +} + +// PositionEdges holds the relations/edges for other nodes in the graph. +message PositionEdges { + // Department holds the value of the department edge. + Department department = 1 [json_name = "department"]; + // Users holds the value of the users edge. + repeated User users = 2 [json_name = "users"]; + // Permissions holds the value of the permissions edge. + repeated Permission permissions = 3 [json_name = "permissions"]; + // UserPositions holds the value of the user_positions edge. + repeated UserPosition user_positions = 4 [json_name = "user_positions"]; + // PositionPermissions holds the value of the position_permissions edge. + repeated PositionPermission position_permissions = 5 [json_name = "position_permissions"]; } // permission.table.comment @@ -327,30 +335,26 @@ message Permission { google.protobuf.Timestamp create_time = 2 [json_name = "create_time"]; // update_time.field.comment google.protobuf.Timestamp update_time = 3 [json_name = "update_time"]; - // create_author.field.comment - int64 create_author = 4 [json_name = "create_author"]; - // update_author.field.comment - int64 update_author = 5 [json_name = "update_author"]; // permission.field.name - string name = 6 [json_name = "name"]; + string name = 4 [json_name = "name"]; // permission.field.keyword - string keyword = 7 [json_name = "keyword"]; + string keyword = 5 [json_name = "keyword"]; // permission.field.status - int32 status = 8 [json_name = "status"]; + int32 status = 6 [json_name = "status"]; // permission.field.description - string description = 9 [json_name = "description"]; + string description = 7 [json_name = "description"]; // permission.field.data_scope - string data_scope = 10 [json_name = "data_scope"]; + string data_scope = 8 [json_name = "data_scope"]; // permission.field.data_rules - map data_rules = 11 [json_name = "data_rules"]; + map data_rules = 9 [json_name = "data_rules"]; // permission.field.resource_ids - repeated int64 resource_ids = 12 [json_name = "resource_ids"]; - // permission.field.resources - repeated Resource resources = 13 [json_name = "resources"]; + repeated int64 resource_ids = 10 [json_name = "resource_ids"]; // permission.field.view_ids - repeated int64 view_ids = 14 [json_name = "view_ids"]; + repeated int64 view_ids = 12 [json_name = "view_ids"]; + // permission.field.resources + repeated Resource resources = 100 [json_name = "resources"]; // permission.field.views - repeated View views = 15 [json_name = "views"]; + repeated View views = 101 [json_name = "views"]; } // user_position.table.comment diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index 13f2924c..90450d64 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -37,42 +37,40 @@ type View struct { Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` // Scope holds the value of the "scope" field. Scope string `protobuf:"bytes,6,opt,name=scope,proto3" json:"scope,omitempty"` - // I18nKey holds the value of the "i18n_key" field. - I18NKey string `protobuf:"bytes,7,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` + // I18nKey holds the value of the "i18n" field. + I18N string `protobuf:"bytes,7,opt,name=i18n,proto3" json:"i18n,omitempty"` // Description holds the value of the "description" field. Description string `protobuf:"bytes,8,opt,name=description,proto3" json:"description,omitempty"` // Sequence holds the value of the "sequence" field. Sequence int32 `protobuf:"varint,9,opt,name=sequence,proto3" json:"sequence,omitempty"` // Type holds the value of the "type" field. Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` - // Component holds the value of the "component" field. - Component string `protobuf:"bytes,11,opt,name=component,proto3" json:"component,omitempty"` // Comment holds the value of the "comment" field. - Comment string `protobuf:"bytes,12,opt,name=comment,proto3" json:"comment,omitempty"` + Comment string `protobuf:"bytes,11,opt,name=comment,proto3" json:"comment,omitempty"` // Icon holds the value of the "icon" field. - Icon string `protobuf:"bytes,13,opt,name=icon,proto3" json:"icon,omitempty"` + Icon string `protobuf:"bytes,12,opt,name=icon,proto3" json:"icon,omitempty"` // Visible holds the value of the "visible" field. - Visible bool `protobuf:"varint,14,opt,name=visible,proto3" json:"visible,omitempty"` + Visible bool `protobuf:"varint,13,opt,name=visible,proto3" json:"visible,omitempty"` // Path holds the value of the "path" field. - Path string `protobuf:"bytes,15,opt,name=path,proto3" json:"path,omitempty"` + Path string `protobuf:"bytes,14,opt,name=path,proto3" json:"path,omitempty"` // TreePath holds the value of the "tree_path" field. - TreePath string `protobuf:"bytes,16,opt,name=tree_path,proto3" json:"tree_path,omitempty"` + TreePath string `protobuf:"bytes,15,opt,name=tree_path,proto3" json:"tree_path,omitempty"` // Properties holds the value of the "properties" field. - Properties string `protobuf:"bytes,17,opt,name=properties,proto3" json:"properties,omitempty"` + Properties string `protobuf:"bytes,16,opt,name=properties,proto3" json:"properties,omitempty"` // Status holds the value of the "status" field. - Status int32 `protobuf:"varint,18,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` // ParentID holds the value of the "parent_id" field. - ParentId int64 `protobuf:"varint,19,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + ParentId int64 `protobuf:"varint,18,opt,name=parent_id,proto3" json:"parent_id,omitempty"` // ParentPath holds the value of the "parent_path" field. - ParentPath string `protobuf:"bytes,20,opt,name=parent_path,proto3" json:"parent_path,omitempty"` + ParentPath string `protobuf:"bytes,19,opt,name=parent_path,proto3" json:"parent_path,omitempty"` // Children holds the value of the children edge. - Children []*View `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` + Children []*View `protobuf:"bytes,100,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. - Parent *View `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` + Parent *View `protobuf:"bytes,101,opt,name=parent,proto3" json:"parent,omitempty"` // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,23,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*Resource `protobuf:"bytes,102,rep,name=resources,proto3" json:"resources,omitempty"` // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*Role `protobuf:"bytes,103,rep,name=roles,proto3" json:"roles,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -149,9 +147,9 @@ func (x *View) GetScope() string { return "" } -func (x *View) GetI18NKey() string { +func (x *View) GetI18N() string { if x != nil { - return x.I18NKey + return x.I18N } return "" } @@ -177,13 +175,6 @@ func (x *View) GetType() string { return "" } -func (x *View) GetComponent() string { - if x != nil { - return x.Component - } - return "" -} - func (x *View) GetComment() string { if x != nil { return x.Comment @@ -285,40 +276,32 @@ type Role struct { CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // create_author.field.comment - CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` - // update_author.field.comment - UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // role.field.keyword - Keyword string `protobuf:"bytes,6,opt,name=keyword,proto3" json:"keyword,omitempty"` + Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` // role.field.name - Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` // role.field.description - Description string `protobuf:"bytes,8,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` // role.field.type - Type int32 `protobuf:"varint,9,opt,name=type,proto3" json:"type,omitempty"` + Type int32 `protobuf:"varint,7,opt,name=type,proto3" json:"type,omitempty"` // role.field.sequence - Sequence int32 `protobuf:"varint,10,opt,name=sequence,proto3" json:"sequence,omitempty"` + Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` // role.field.status - Status int32 `protobuf:"varint,11,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"` // role.field.is_types - IsTypes bool `protobuf:"varint,12,opt,name=is_types,proto3" json:"is_types,omitempty"` + IsTypes bool `protobuf:"varint,10,opt,name=is_types,proto3" json:"is_types,omitempty"` // Views holds the value of the views edge. - Views []*View `protobuf:"bytes,21,rep,name=views,proto3" json:"views,omitempty"` - // View Ids holds the value of the view_ids edge. - ViewIds []int64 `protobuf:"varint,20,rep,packed,name=view_ids,proto3" json:"view_ids,omitempty"` + Views []*View `protobuf:"bytes,100,rep,name=views,proto3" json:"views,omitempty"` // Users holds the value of the users edge. - Users []*User `protobuf:"bytes,22,rep,name=users,proto3" json:"users,omitempty"` - // Users Ids holds the value of the user_ids edge. - UserIds []int64 `protobuf:"varint,23,rep,packed,name=user_ids,proto3" json:"user_ids,omitempty"` + Users []*User `protobuf:"bytes,101,rep,name=users,proto3" json:"users,omitempty"` // Resources holds the value of the resources edge. - Resources []*Resource `protobuf:"bytes,24,rep,name=resources,proto3" json:"resources,omitempty"` + Resources []*Resource `protobuf:"bytes,102,rep,name=resources,proto3" json:"resources,omitempty"` // Resource Ids holds the value of the resource_ids edge. - ResourceIds []int64 `protobuf:"varint,25,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` + ResourceIds []int64 `protobuf:"varint,103,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,26,rep,name=permissions,proto3" json:"permissions,omitempty"` + Permissions []*Permission `protobuf:"bytes,104,rep,name=permissions,proto3" json:"permissions,omitempty"` // Permission Ids holds the value of the permission_ids edge. - PermissionIds []int64 `protobuf:"varint,27,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` + PermissionIds []int64 `protobuf:"varint,105,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -374,20 +357,6 @@ func (x *Role) GetUpdateTime() *timestamppb.Timestamp { return nil } -func (x *Role) GetCreateAuthor() int64 { - if x != nil { - return x.CreateAuthor - } - return 0 -} - -func (x *Role) GetUpdateAuthor() int64 { - if x != nil { - return x.UpdateAuthor - } - return 0 -} - func (x *Role) GetKeyword() string { if x != nil { return x.Keyword @@ -444,13 +413,6 @@ func (x *Role) GetViews() []*View { return nil } -func (x *Role) GetViewIds() []int64 { - if x != nil { - return x.ViewIds - } - return nil -} - func (x *Role) GetUsers() []*User { if x != nil { return x.Users @@ -458,13 +420,6 @@ func (x *Role) GetUsers() []*User { return nil } -func (x *Role) GetUserIds() []int64 { - if x != nil { - return x.UserIds - } - return nil -} - func (x *Role) GetResources() []*Resource { if x != nil { return x.Resources @@ -499,14 +454,14 @@ type User struct { // ID of the ent. // field.primary_key.comment Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - // create_time.field.comment - CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` - // update_time.field.comment - UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` // create_author.field.comment - CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` + CreateAuthor int64 `protobuf:"varint,2,opt,name=create_author,proto3" json:"create_author,omitempty"` // update_author.field.comment - UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` + UpdateAuthor int64 `protobuf:"varint,3,opt,name=update_author,proto3" json:"update_author,omitempty"` + // create_time.field.comment + CreateTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=create_time,proto3" json:"create_time,omitempty"` + // update_time.field.comment + UpdateTime *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=update_time,proto3" json:"update_time,omitempty"` // user.field.uuid Uuid string `protobuf:"bytes,6,opt,name=uuid,proto3" json:"uuid,omitempty"` // user.field.allowed_ip @@ -531,22 +486,20 @@ type User struct { Token string `protobuf:"bytes,16,opt,name=token,proto3" json:"token,omitempty"` // user.field.status Status int32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` - // user.field.i18n - I18N string `protobuf:"bytes,18,opt,name=i18n,proto3" json:"i18n,omitempty"` // user.field.last_login_ip - LastLoginIp string `protobuf:"bytes,19,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` + LastLoginIp string `protobuf:"bytes,18,opt,name=last_login_ip,proto3" json:"last_login_ip,omitempty"` // user.field.login_ip - LoginIp string `protobuf:"bytes,20,opt,name=login_ip,proto3" json:"login_ip,omitempty"` + LoginIp string `protobuf:"bytes,19,opt,name=login_ip,proto3" json:"login_ip,omitempty"` // user.field.last_login_time - LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,21,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` + LastLoginTime *timestamppb.Timestamp `protobuf:"bytes,20,opt,name=last_login_time,proto3" json:"last_login_time,omitempty"` // user.field.login_time - LoginTime *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=login_time,proto3" json:"login_time,omitempty"` + LoginTime *timestamppb.Timestamp `protobuf:"bytes,21,opt,name=login_time,proto3" json:"login_time,omitempty"` // user.field.sanction_date - SanctionDate *timestamppb.Timestamp `protobuf:"bytes,23,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` + SanctionDate *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` // Roles holds the value of the roles edge. - Roles []*Role `protobuf:"bytes,24,rep,name=roles,proto3" json:"roles,omitempty"` + Roles []*Role `protobuf:"bytes,100,rep,name=roles,proto3" json:"roles,omitempty"` // Role Ids holds the value of the role_ids - RoleIds []int64 `protobuf:"varint,25,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` + RoleIds []int64 `protobuf:"varint,101,rep,packed,name=role_ids,proto3" json:"role_ids,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -588,32 +541,32 @@ func (x *User) GetId() int64 { return 0 } -func (x *User) GetCreateTime() *timestamppb.Timestamp { +func (x *User) GetCreateAuthor() int64 { if x != nil { - return x.CreateTime + return x.CreateAuthor } - return nil + return 0 } -func (x *User) GetUpdateTime() *timestamppb.Timestamp { +func (x *User) GetUpdateAuthor() int64 { if x != nil { - return x.UpdateTime + return x.UpdateAuthor } - return nil + return 0 } -func (x *User) GetCreateAuthor() int64 { +func (x *User) GetCreateTime() *timestamppb.Timestamp { if x != nil { - return x.CreateAuthor + return x.CreateTime } - return 0 + return nil } -func (x *User) GetUpdateAuthor() int64 { +func (x *User) GetUpdateTime() *timestamppb.Timestamp { if x != nil { - return x.UpdateAuthor + return x.UpdateTime } - return 0 + return nil } func (x *User) GetUuid() string { @@ -700,13 +653,6 @@ func (x *User) GetStatus() int32 { return 0 } -func (x *User) GetI18N() string { - if x != nil { - return x.I18N - } - return "" -} - func (x *User) GetLastLoginIp() string { if x != nil { return x.LastLoginIp @@ -772,9 +718,9 @@ type UserRole struct { // RoleName holds the value of the "role_name" field. RoleName string `protobuf:"bytes,6,opt,name=role_name,proto3" json:"role_name,omitempty"` // User holds the value of the user edge. - User *User `protobuf:"bytes,21,opt,name=user,proto3" json:"user,omitempty"` + User *User `protobuf:"bytes,100,opt,name=user,proto3" json:"user,omitempty"` // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,22,opt,name=role,proto3" json:"role,omitempty"` + Role *Role `protobuf:"bytes,101,opt,name=role,proto3" json:"role,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -879,9 +825,9 @@ type RoleView struct { // ViewID holds the value of the "view_id" field. ViewId int64 `protobuf:"varint,5,opt,name=view_id,proto3" json:"view_id,omitempty"` // Role holds the value of the role edge. - Role *Role `protobuf:"bytes,21,opt,name=role,proto3" json:"role,omitempty"` + Role *Role `protobuf:"bytes,100,opt,name=role,proto3" json:"role,omitempty"` // View holds the value of the view edge. - View *View `protobuf:"bytes,22,opt,name=view,proto3" json:"view,omitempty"` + View *View `protobuf:"bytes,101,opt,name=view,proto3" json:"view,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -975,26 +921,30 @@ type Resource struct { CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // create_author.field.comment - CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` - // update_author.field.comment - UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // resource.field.name - Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` // resource.field.keyword - Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` + Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` + // resource.field.i18n_key + I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` // resource.field.type - Type string `protobuf:"bytes,9,opt,name=type,proto3" json:"type,omitempty"` + Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` // resource.field.status - Status int32 `protobuf:"varint,10,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` // resource.field.path - Path string `protobuf:"bytes,11,opt,name=path,proto3" json:"path,omitempty"` + Path string `protobuf:"bytes,9,opt,name=path,proto3" json:"path,omitempty"` // resource.field.operation - Operation string `protobuf:"bytes,12,opt,name=operation,proto3" json:"operation,omitempty"` + Operation string `protobuf:"bytes,10,opt,name=operation,proto3" json:"operation,omitempty"` // resource.field.method - Method string `protobuf:"bytes,13,opt,name=method,proto3" json:"method,omitempty"` + Method string `protobuf:"bytes,11,opt,name=method,proto3" json:"method,omitempty"` + // resource.field.component + Component string `protobuf:"bytes,12,opt,name=component,proto3" json:"component,omitempty"` + // resource.field.icon + Icon string `protobuf:"bytes,13,opt,name=icon,proto3" json:"icon,omitempty"` // resource.field.sequence Sequence int32 `protobuf:"varint,14,opt,name=sequence,proto3" json:"sequence,omitempty"` + // resource.field.visible + Visible bool `protobuf:"varint,15,opt,name=visible,proto3" json:"visible,omitempty"` // resource.field.tree_path TreePath string `protobuf:"bytes,16,opt,name=tree_path,proto3" json:"tree_path,omitempty"` // resource.field.properties @@ -1003,15 +953,18 @@ type Resource struct { Description string `protobuf:"bytes,18,opt,name=description,proto3" json:"description,omitempty"` // resource.field.parent_id ParentId int64 `protobuf:"varint,19,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + // resource.field.sync_status + SyncStatus string `protobuf:"bytes,20,opt,name=sync_status,proto3" json:"sync_status,omitempty"` + // resource.field.service_name + ServiceName string `protobuf:"bytes,21,opt,name=service_name,proto3" json:"service_name,omitempty"` // Children holds the value of the children edge. - Children []*Resource `protobuf:"bytes,21,rep,name=children,proto3" json:"children,omitempty"` + Children []*Resource `protobuf:"bytes,100,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. - Parent *Resource `protobuf:"bytes,22,opt,name=parent,proto3" json:"parent,omitempty"` + Parent *Resource `protobuf:"bytes,101,opt,name=parent,proto3" json:"parent,omitempty"` // Permission Ids holds the value of the permission_ids edge. - PermissionIds []int64 `protobuf:"varint,23,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` + PermissionIds []int64 `protobuf:"varint,102,rep,packed,name=permission_ids,proto3" json:"permission_ids,omitempty"` // Permissions holds the value of the permissions edge. - Permissions []*Permission `protobuf:"bytes,24,rep,name=permissions,proto3" json:"permissions,omitempty"` - ServiceName string `protobuf:"bytes,25,opt,name=service_name,proto3" json:"service_name,omitempty"` + Permissions []*Permission `protobuf:"bytes,103,rep,name=permissions,proto3" json:"permissions,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1067,20 +1020,6 @@ func (x *Resource) GetUpdateTime() *timestamppb.Timestamp { return nil } -func (x *Resource) GetCreateAuthor() int64 { - if x != nil { - return x.CreateAuthor - } - return 0 -} - -func (x *Resource) GetUpdateAuthor() int64 { - if x != nil { - return x.UpdateAuthor - } - return 0 -} - func (x *Resource) GetName() string { if x != nil { return x.Name @@ -1095,6 +1034,13 @@ func (x *Resource) GetKeyword() string { return "" } +func (x *Resource) GetI18NKey() string { + if x != nil { + return x.I18NKey + } + return "" +} + func (x *Resource) GetType() string { if x != nil { return x.Type @@ -1130,6 +1076,20 @@ func (x *Resource) GetMethod() string { return "" } +func (x *Resource) GetComponent() string { + if x != nil { + return x.Component + } + return "" +} + +func (x *Resource) GetIcon() string { + if x != nil { + return x.Icon + } + return "" +} + func (x *Resource) GetSequence() int32 { if x != nil { return x.Sequence @@ -1137,6 +1097,13 @@ func (x *Resource) GetSequence() int32 { return 0 } +func (x *Resource) GetVisible() bool { + if x != nil { + return x.Visible + } + return false +} + func (x *Resource) GetTreePath() string { if x != nil { return x.TreePath @@ -1165,6 +1132,20 @@ func (x *Resource) GetParentId() int64 { return 0 } +func (x *Resource) GetSyncStatus() string { + if x != nil { + return x.SyncStatus + } + return "" +} + +func (x *Resource) GetServiceName() string { + if x != nil { + return x.ServiceName + } + return "" +} + func (x *Resource) GetChildren() []*Resource { if x != nil { return x.Children @@ -1193,13 +1174,6 @@ func (x *Resource) GetPermissions() []*Permission { return nil } -func (x *Resource) GetServiceName() string { - if x != nil { - return x.ServiceName - } - return "" -} - // department.table.comment type Department struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -1210,30 +1184,26 @@ type Department struct { CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // create_author.field.comment - CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` - // update_author.field.comment - UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // department.field.keyword - Keyword string `protobuf:"bytes,6,opt,name=keyword,proto3" json:"keyword,omitempty"` + Keyword string `protobuf:"bytes,4,opt,name=keyword,proto3" json:"keyword,omitempty"` // department.field.name - Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` // department.field.tree_path - TreePath string `protobuf:"bytes,8,opt,name=tree_path,proto3" json:"tree_path,omitempty"` + TreePath string `protobuf:"bytes,6,opt,name=tree_path,proto3" json:"tree_path,omitempty"` // department.field.sequence - Sequence int32 `protobuf:"varint,9,opt,name=sequence,proto3" json:"sequence,omitempty"` + Sequence int32 `protobuf:"varint,7,opt,name=sequence,proto3" json:"sequence,omitempty"` // department.field.status - Status int32 `protobuf:"varint,10,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` // department.field.level - Level int32 `protobuf:"varint,11,opt,name=level,proto3" json:"level,omitempty"` + Level int32 `protobuf:"varint,9,opt,name=level,proto3" json:"level,omitempty"` // department.field.description - Description string `protobuf:"bytes,12,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,10,opt,name=description,proto3" json:"description,omitempty"` // department.field.parent_id - ParentId int64 `protobuf:"varint,13,opt,name=parent_id,proto3" json:"parent_id,omitempty"` + ParentId int64 `protobuf:"varint,11,opt,name=parent_id,proto3" json:"parent_id,omitempty"` // Children holds the value of the children edge. - Children []*Department `protobuf:"bytes,14,rep,name=children,proto3" json:"children,omitempty"` + Children []*Department `protobuf:"bytes,100,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. - Parent *Department `protobuf:"bytes,15,opt,name=parent,proto3" json:"parent,omitempty"` + Parent *Department `protobuf:"bytes,101,opt,name=parent,proto3" json:"parent,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1289,20 +1259,6 @@ func (x *Department) GetUpdateTime() *timestamppb.Timestamp { return nil } -func (x *Department) GetCreateAuthor() int64 { - if x != nil { - return x.CreateAuthor - } - return 0 -} - -func (x *Department) GetUpdateAuthor() int64 { - if x != nil { - return x.UpdateAuthor - } - return 0 -} - func (x *Department) GetKeyword() string { if x != nil { return x.Keyword @@ -1448,18 +1404,14 @@ type Position struct { CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // create_author.field.comment - CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` - // update_author.field.comment - UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // position.field.name - Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` // position.field.keyword - Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` + Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` // position.field.description - Description string `protobuf:"bytes,8,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,6,opt,name=description,proto3" json:"description,omitempty"` // department.field.department_id - DepartmentId int64 `protobuf:"varint,9,opt,name=department_id,proto3" json:"department_id,omitempty"` + DepartmentId int64 `protobuf:"varint,7,opt,name=department_id,proto3" json:"department_id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1515,20 +1467,6 @@ func (x *Position) GetUpdateTime() *timestamppb.Timestamp { return nil } -func (x *Position) GetCreateAuthor() int64 { - if x != nil { - return x.CreateAuthor - } - return 0 -} - -func (x *Position) GetUpdateAuthor() int64 { - if x != nil { - return x.UpdateAuthor - } - return 0 -} - func (x *Position) GetName() string { if x != nil { return x.Name @@ -1557,6 +1495,88 @@ func (x *Position) GetDepartmentId() int64 { return 0 } +// PositionEdges holds the relations/edges for other nodes in the graph. +type PositionEdges struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Department holds the value of the department edge. + Department *Department `protobuf:"bytes,1,opt,name=department,proto3" json:"department,omitempty"` + // Users holds the value of the users edge. + Users []*User `protobuf:"bytes,2,rep,name=users,proto3" json:"users,omitempty"` + // Permissions holds the value of the permissions edge. + Permissions []*Permission `protobuf:"bytes,3,rep,name=permissions,proto3" json:"permissions,omitempty"` + // UserPositions holds the value of the user_positions edge. + UserPositions []*UserPosition `protobuf:"bytes,4,rep,name=user_positions,proto3" json:"user_positions,omitempty"` + // PositionPermissions holds the value of the position_permissions edge. + PositionPermissions []*PositionPermission `protobuf:"bytes,5,rep,name=position_permissions,proto3" json:"position_permissions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *PositionEdges) Reset() { + *x = PositionEdges{} + mi := &file_types_system_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PositionEdges) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PositionEdges) ProtoMessage() {} + +func (x *PositionEdges) ProtoReflect() protoreflect.Message { + mi := &file_types_system_proto_msgTypes[9] + 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 PositionEdges.ProtoReflect.Descriptor instead. +func (*PositionEdges) Descriptor() ([]byte, []int) { + return file_types_system_proto_rawDescGZIP(), []int{9} +} + +func (x *PositionEdges) GetDepartment() *Department { + if x != nil { + return x.Department + } + return nil +} + +func (x *PositionEdges) GetUsers() []*User { + if x != nil { + return x.Users + } + return nil +} + +func (x *PositionEdges) GetPermissions() []*Permission { + if x != nil { + return x.Permissions + } + return nil +} + +func (x *PositionEdges) GetUserPositions() []*UserPosition { + if x != nil { + return x.UserPositions + } + return nil +} + +func (x *PositionEdges) GetPositionPermissions() []*PositionPermission { + if x != nil { + return x.PositionPermissions + } + return nil +} + // permission.table.comment type Permission struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -1567,37 +1587,33 @@ type Permission struct { CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,proto3" json:"create_time,omitempty"` // update_time.field.comment UpdateTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=update_time,proto3" json:"update_time,omitempty"` - // create_author.field.comment - CreateAuthor int64 `protobuf:"varint,4,opt,name=create_author,proto3" json:"create_author,omitempty"` - // update_author.field.comment - UpdateAuthor int64 `protobuf:"varint,5,opt,name=update_author,proto3" json:"update_author,omitempty"` // permission.field.name - Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` // permission.field.keyword - Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` + Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` // permission.field.status - Status int32 `protobuf:"varint,8,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,6,opt,name=status,proto3" json:"status,omitempty"` // permission.field.description - Description string `protobuf:"bytes,9,opt,name=description,proto3" json:"description,omitempty"` + Description string `protobuf:"bytes,7,opt,name=description,proto3" json:"description,omitempty"` // permission.field.data_scope - DataScope string `protobuf:"bytes,10,opt,name=data_scope,proto3" json:"data_scope,omitempty"` + DataScope string `protobuf:"bytes,8,opt,name=data_scope,proto3" json:"data_scope,omitempty"` // permission.field.data_rules - DataRules map[string]string `protobuf:"bytes,11,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + DataRules map[string]string `protobuf:"bytes,9,rep,name=data_rules,proto3" json:"data_rules,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // permission.field.resource_ids - ResourceIds []int64 `protobuf:"varint,12,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` - // permission.field.resources - Resources []*Resource `protobuf:"bytes,13,rep,name=resources,proto3" json:"resources,omitempty"` + ResourceIds []int64 `protobuf:"varint,10,rep,packed,name=resource_ids,proto3" json:"resource_ids,omitempty"` // permission.field.view_ids - ViewIds []int64 `protobuf:"varint,14,rep,packed,name=view_ids,proto3" json:"view_ids,omitempty"` + ViewIds []int64 `protobuf:"varint,12,rep,packed,name=view_ids,proto3" json:"view_ids,omitempty"` + // permission.field.resources + Resources []*Resource `protobuf:"bytes,100,rep,name=resources,proto3" json:"resources,omitempty"` // permission.field.views - Views []*View `protobuf:"bytes,15,rep,name=views,proto3" json:"views,omitempty"` + Views []*View `protobuf:"bytes,101,rep,name=views,proto3" json:"views,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *Permission) Reset() { *x = Permission{} - mi := &file_types_system_proto_msgTypes[9] + mi := &file_types_system_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1609,7 +1625,7 @@ func (x *Permission) String() string { func (*Permission) ProtoMessage() {} func (x *Permission) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[9] + mi := &file_types_system_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1622,7 +1638,7 @@ func (x *Permission) ProtoReflect() protoreflect.Message { // Deprecated: Use Permission.ProtoReflect.Descriptor instead. func (*Permission) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{9} + return file_types_system_proto_rawDescGZIP(), []int{10} } func (x *Permission) GetId() int64 { @@ -1646,20 +1662,6 @@ func (x *Permission) GetUpdateTime() *timestamppb.Timestamp { return nil } -func (x *Permission) GetCreateAuthor() int64 { - if x != nil { - return x.CreateAuthor - } - return 0 -} - -func (x *Permission) GetUpdateAuthor() int64 { - if x != nil { - return x.UpdateAuthor - } - return 0 -} - func (x *Permission) GetName() string { if x != nil { return x.Name @@ -1709,16 +1711,16 @@ func (x *Permission) GetResourceIds() []int64 { return nil } -func (x *Permission) GetResources() []*Resource { +func (x *Permission) GetViewIds() []int64 { if x != nil { - return x.Resources + return x.ViewIds } return nil } -func (x *Permission) GetViewIds() []int64 { +func (x *Permission) GetResources() []*Resource { if x != nil { - return x.ViewIds + return x.Resources } return nil } @@ -1746,7 +1748,7 @@ type UserPosition struct { func (x *UserPosition) Reset() { *x = UserPosition{} - mi := &file_types_system_proto_msgTypes[10] + mi := &file_types_system_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1758,7 +1760,7 @@ func (x *UserPosition) String() string { func (*UserPosition) ProtoMessage() {} func (x *UserPosition) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[10] + mi := &file_types_system_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1771,7 +1773,7 @@ func (x *UserPosition) ProtoReflect() protoreflect.Message { // Deprecated: Use UserPosition.ProtoReflect.Descriptor instead. func (*UserPosition) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{10} + return file_types_system_proto_rawDescGZIP(), []int{11} } func (x *UserPosition) GetId() int64 { @@ -1811,7 +1813,7 @@ type PositionPermission struct { func (x *PositionPermission) Reset() { *x = PositionPermission{} - mi := &file_types_system_proto_msgTypes[11] + mi := &file_types_system_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1823,7 +1825,7 @@ func (x *PositionPermission) String() string { func (*PositionPermission) ProtoMessage() {} func (x *PositionPermission) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[11] + mi := &file_types_system_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1836,7 +1838,7 @@ func (x *PositionPermission) ProtoReflect() protoreflect.Message { // Deprecated: Use PositionPermission.ProtoReflect.Descriptor instead. func (*PositionPermission) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{11} + return file_types_system_proto_rawDescGZIP(), []int{12} } func (x *PositionPermission) GetId() int64 { @@ -1876,7 +1878,7 @@ type RolePermission struct { func (x *RolePermission) Reset() { *x = RolePermission{} - mi := &file_types_system_proto_msgTypes[12] + mi := &file_types_system_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1888,7 +1890,7 @@ func (x *RolePermission) String() string { func (*RolePermission) ProtoMessage() {} func (x *RolePermission) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[12] + mi := &file_types_system_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1901,7 +1903,7 @@ func (x *RolePermission) ProtoReflect() protoreflect.Message { // Deprecated: Use RolePermission.ProtoReflect.Descriptor instead. func (*RolePermission) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{12} + return file_types_system_proto_rawDescGZIP(), []int{13} } func (x *RolePermission) GetId() int64 { @@ -1943,7 +1945,7 @@ type PermissionResource struct { func (x *PermissionResource) Reset() { *x = PermissionResource{} - mi := &file_types_system_proto_msgTypes[13] + mi := &file_types_system_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1955,7 +1957,7 @@ func (x *PermissionResource) String() string { func (*PermissionResource) ProtoMessage() {} func (x *PermissionResource) ProtoReflect() protoreflect.Message { - mi := &file_types_system_proto_msgTypes[13] + mi := &file_types_system_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1968,7 +1970,7 @@ func (x *PermissionResource) ProtoReflect() protoreflect.Message { // Deprecated: Use PermissionResource.ProtoReflect.Descriptor instead. func (*PermissionResource) Descriptor() ([]byte, []int) { - return file_types_system_proto_rawDescGZIP(), []int{13} + return file_types_system_proto_rawDescGZIP(), []int{14} } func (x *PermissionResource) GetId() int64 { @@ -2003,63 +2005,58 @@ var File_types_system_proto protoreflect.FileDescriptor const file_types_system_proto_rawDesc = "" + "\n" + - "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xb4\x06\n" + + "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x8e\x06\n" + "\x04View\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + "\x04name\x18\x05 \x01(\tR\x04name\x12\x14\n" + - "\x05scope\x18\x06 \x01(\tR\x05scope\x12\x1a\n" + - "\bi18n_key\x18\a \x01(\tR\bi18n_key\x12 \n" + + "\x05scope\x18\x06 \x01(\tR\x05scope\x12\x12\n" + + "\x04i18n\x18\a \x01(\tR\x04i18n\x12 \n" + "\vdescription\x18\b \x01(\tR\vdescription\x12\x1a\n" + "\bsequence\x18\t \x01(\x05R\bsequence\x12\x12\n" + "\x04type\x18\n" + - " \x01(\tR\x04type\x12\x1c\n" + - "\tcomponent\x18\v \x01(\tR\tcomponent\x12\x18\n" + - "\acomment\x18\f \x01(\tR\acomment\x12\x12\n" + - "\x04icon\x18\r \x01(\tR\x04icon\x12\x18\n" + - "\avisible\x18\x0e \x01(\bR\avisible\x12\x12\n" + - "\x04path\x18\x0f \x01(\tR\x04path\x12\x1c\n" + - "\ttree_path\x18\x10 \x01(\tR\ttree_path\x12\x1e\n" + + " \x01(\tR\x04type\x12\x18\n" + + "\acomment\x18\v \x01(\tR\acomment\x12\x12\n" + + "\x04icon\x18\f \x01(\tR\x04icon\x12\x18\n" + + "\avisible\x18\r \x01(\bR\avisible\x12\x12\n" + + "\x04path\x18\x0e \x01(\tR\x04path\x12\x1c\n" + + "\ttree_path\x18\x0f \x01(\tR\ttree_path\x12\x1e\n" + "\n" + - "properties\x18\x11 \x01(\tR\n" + + "properties\x18\x10 \x01(\tR\n" + "properties\x12\x16\n" + - "\x06status\x18\x12 \x01(\x05R\x06status\x12\x1c\n" + - "\tparent_id\x18\x13 \x01(\x03R\tparent_id\x12 \n" + - "\vparent_path\x18\x14 \x01(\tR\vparent_path\x127\n" + - "\bchildren\x18\x15 \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + - "\x06parent\x18\x16 \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + - "\tresources\x18\x17 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + - "\x05roles\x18\x18 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\x80\x06\n" + + "\x06status\x18\x11 \x01(\x05R\x06status\x12\x1c\n" + + "\tparent_id\x18\x12 \x01(\x03R\tparent_id\x12 \n" + + "\vparent_path\x18\x13 \x01(\tR\vparent_path\x127\n" + + "\bchildren\x18d \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + + "\x06parent\x18e \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + + "\tresources\x18f \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + + "\x05roles\x18g \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xfc\x04\n" + "\x04Role\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + - "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + - "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x18\n" + - "\akeyword\x18\x06 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\a \x01(\tR\x04name\x12 \n" + - "\vdescription\x18\b \x01(\tR\vdescription\x12\x12\n" + - "\x04type\x18\t \x01(\x05R\x04type\x12\x1a\n" + - "\bsequence\x18\n" + - " \x01(\x05R\bsequence\x12\x16\n" + - "\x06status\x18\v \x01(\x05R\x06status\x12\x1a\n" + - "\bis_types\x18\f \x01(\bR\bis_types\x121\n" + - "\x05views\x18\x15 \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x12\x1a\n" + - "\bview_ids\x18\x14 \x03(\x03R\bview_ids\x121\n" + - "\x05users\x18\x16 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12\x1a\n" + - "\buser_ids\x18\x17 \x03(\x03R\buser_ids\x12=\n" + - "\tresources\x18\x18 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\"\n" + - "\fresource_ids\x18\x19 \x03(\x03R\fresource_ids\x12C\n" + - "\vpermissions\x18\x1a \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12&\n" + - "\x0epermission_ids\x18\x1b \x03(\x03R\x0epermission_ids\"\x80\a\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x12\n" + + "\x04type\x18\a \x01(\x05R\x04type\x12\x1a\n" + + "\bsequence\x18\b \x01(\x05R\bsequence\x12\x16\n" + + "\x06status\x18\t \x01(\x05R\x06status\x12\x1a\n" + + "\bis_types\x18\n" + + " \x01(\bR\bis_types\x121\n" + + "\x05views\x18d \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x121\n" + + "\x05users\x18e \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + + "\tresources\x18f \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\"\n" + + "\fresource_ids\x18g \x03(\x03R\fresource_ids\x12C\n" + + "\vpermissions\x18h \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12&\n" + + "\x0epermission_ids\x18i \x03(\x03R\x0epermission_ids\"\xec\x06\n" + "\x04User\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + - "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + - "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + - "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x12\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + + "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + + "\rupdate_author\x18\x03 \x01(\x03R\rupdate_author\x12<\n" + + "\vcreate_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + + "\vupdate_time\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + "\x04uuid\x18\x06 \x01(\tR\x04uuid\x12\x1e\n" + "\n" + "allowed_ip\x18\a \x01(\tR\n" + @@ -2074,17 +2071,16 @@ const file_types_system_proto_rawDesc = "" + "\x05email\x18\x0e \x01(\tR\x05email\x12\x16\n" + "\x06remark\x18\x0f \x01(\tR\x06remark\x12\x14\n" + "\x05token\x18\x10 \x01(\tR\x05token\x12\x16\n" + - "\x06status\x18\x11 \x01(\x05R\x06status\x12\x12\n" + - "\x04i18n\x18\x12 \x01(\tR\x04i18n\x12$\n" + - "\rlast_login_ip\x18\x13 \x01(\tR\rlast_login_ip\x12\x1a\n" + - "\blogin_ip\x18\x14 \x01(\tR\blogin_ip\x12D\n" + - "\x0flast_login_time\x18\x15 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12:\n" + + "\x06status\x18\x11 \x01(\x05R\x06status\x12$\n" + + "\rlast_login_ip\x18\x12 \x01(\tR\rlast_login_ip\x12\x1a\n" + + "\blogin_ip\x18\x13 \x01(\tR\blogin_ip\x12D\n" + + "\x0flast_login_time\x18\x14 \x01(\v2\x1a.google.protobuf.TimestampR\x0flast_login_time\x12:\n" + "\n" + - "login_time\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampR\n" + + "login_time\x18\x15 \x01(\v2\x1a.google.protobuf.TimestampR\n" + "login_time\x12E\n" + - "\rsanction_date\x18\x17 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x121\n" + - "\x05roles\x18\x18 \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + - "\brole_ids\x18\x19 \x03(\x03R\brole_idsB\x10\n" + + "\rsanction_date\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x121\n" + + "\x05roles\x18d \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + + "\brole_ids\x18e \x03(\x03R\brole_idsB\x10\n" + "\x0e_sanction_date\"\xca\x02\n" + "\bUserRole\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + @@ -2093,99 +2089,104 @@ const file_types_system_proto_rawDesc = "" + "\auser_id\x18\x04 \x01(\x03R\auser_id\x12\x18\n" + "\arole_id\x18\x05 \x01(\x03R\arole_id\x12\x1c\n" + "\trole_name\x18\x06 \x01(\tR\trole_name\x12/\n" + - "\x04user\x18\x15 \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + - "\x04role\x18\x16 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\xac\x02\n" + + "\x04user\x18d \x01(\v2\x1b.api.v1.services.types.UserR\x04user\x12/\n" + + "\x04role\x18e \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\"\xac\x02\n" + "\bRoleView\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + "\arole_id\x18\x04 \x01(\x03R\arole_id\x12\x18\n" + "\aview_id\x18\x05 \x01(\x03R\aview_id\x12/\n" + - "\x04role\x18\x15 \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + - "\x04view\x18\x16 \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\x97\a\n" + + "\x04role\x18d \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + + "\x04view\x18e \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\xd5\a\n" + "\bResource\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + - "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + - "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x12\n" + - "\x04name\x18\x06 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\a \x01(\tR\akeyword\x12\x12\n" + - "\x04type\x18\t \x01(\tR\x04type\x12\x16\n" + - "\x06status\x18\n" + - " \x01(\x05R\x06status\x12\x12\n" + - "\x04path\x18\v \x01(\tR\x04path\x12\x1c\n" + - "\toperation\x18\f \x01(\tR\toperation\x12\x16\n" + - "\x06method\x18\r \x01(\tR\x06method\x12\x1a\n" + - "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x1c\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x1a\n" + + "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12\x12\n" + + "\x04type\x18\a \x01(\tR\x04type\x12\x16\n" + + "\x06status\x18\b \x01(\x05R\x06status\x12\x12\n" + + "\x04path\x18\t \x01(\tR\x04path\x12\x1c\n" + + "\toperation\x18\n" + + " \x01(\tR\toperation\x12\x16\n" + + "\x06method\x18\v \x01(\tR\x06method\x12\x1c\n" + + "\tcomponent\x18\f \x01(\tR\tcomponent\x12\x12\n" + + "\x04icon\x18\r \x01(\tR\x04icon\x12\x1a\n" + + "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x18\n" + + "\avisible\x18\x0f \x01(\bR\avisible\x12\x1c\n" + "\ttree_path\x18\x10 \x01(\tR\ttree_path\x12O\n" + "\n" + "properties\x18\x11 \x03(\v2/.api.v1.services.types.Resource.PropertiesEntryR\n" + "properties\x12 \n" + "\vdescription\x18\x12 \x01(\tR\vdescription\x12\x1c\n" + - "\tparent_id\x18\x13 \x01(\x03R\tparent_id\x12;\n" + - "\bchildren\x18\x15 \x03(\v2\x1f.api.v1.services.types.ResourceR\bchildren\x127\n" + - "\x06parent\x18\x16 \x01(\v2\x1f.api.v1.services.types.ResourceR\x06parent\x12&\n" + - "\x0epermission_ids\x18\x17 \x03(\x03R\x0epermission_ids\x12C\n" + - "\vpermissions\x18\x18 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12\"\n" + - "\fservice_name\x18\x19 \x01(\tR\fservice_name\x1a=\n" + + "\tparent_id\x18\x13 \x01(\x03R\tparent_id\x12 \n" + + "\vsync_status\x18\x14 \x01(\tR\vsync_status\x12\"\n" + + "\fservice_name\x18\x15 \x01(\tR\fservice_name\x12;\n" + + "\bchildren\x18d \x03(\v2\x1f.api.v1.services.types.ResourceR\bchildren\x127\n" + + "\x06parent\x18e \x01(\v2\x1f.api.v1.services.types.ResourceR\x06parent\x12&\n" + + "\x0epermission_ids\x18f \x03(\x03R\x0epermission_ids\x12C\n" + + "\vpermissions\x18g \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x1a=\n" + "\x0fPropertiesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xb4\x04\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xe8\x03\n" + "\n" + "Department\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + - "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + - "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x18\n" + - "\akeyword\x18\x06 \x01(\tR\akeyword\x12\x12\n" + - "\x04name\x18\a \x01(\tR\x04name\x12\x1c\n" + - "\ttree_path\x18\b \x01(\tR\ttree_path\x12\x1a\n" + - "\bsequence\x18\t \x01(\x05R\bsequence\x12\x16\n" + - "\x06status\x18\n" + - " \x01(\x05R\x06status\x12\x14\n" + - "\x05level\x18\v \x01(\x05R\x05level\x12 \n" + - "\vdescription\x18\f \x01(\tR\vdescription\x12\x1c\n" + - "\tparent_id\x18\r \x01(\x03R\tparent_id\x12=\n" + - "\bchildren\x18\x0e \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + - "\x06parent\x18\x0f \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\"`\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x18\n" + + "\akeyword\x18\x04 \x01(\tR\akeyword\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12\x1c\n" + + "\ttree_path\x18\x06 \x01(\tR\ttree_path\x12\x1a\n" + + "\bsequence\x18\a \x01(\x05R\bsequence\x12\x16\n" + + "\x06status\x18\b \x01(\x05R\x06status\x12\x14\n" + + "\x05level\x18\t \x01(\x05R\x05level\x12 \n" + + "\vdescription\x18\n" + + " \x01(\tR\vdescription\x12\x1c\n" + + "\tparent_id\x18\v \x01(\x03R\tparent_id\x12=\n" + + "\bchildren\x18d \x03(\v2!.api.v1.services.types.DepartmentR\bchildren\x129\n" + + "\x06parent\x18e \x01(\v2!.api.v1.services.types.DepartmentR\x06parent\"`\n" + "\x0eUserDepartment\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x18\n" + "\auser_id\x18\x02 \x01(\x03R\auser_id\x12$\n" + - "\rdepartment_id\x18\x03 \x01(\x03R\rdepartment_id\"\xd8\x02\n" + + "\rdepartment_id\x18\x03 \x01(\x03R\rdepartment_id\"\x8c\x02\n" + "\bPosition\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + - "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + - "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x12\n" + - "\x04name\x18\x06 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\a \x01(\tR\akeyword\x12 \n" + - "\vdescription\x18\b \x01(\tR\vdescription\x12$\n" + - "\rdepartment_id\x18\t \x01(\x03R\rdepartment_id\"\xae\x05\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12 \n" + + "\vdescription\x18\x06 \x01(\tR\vdescription\x12$\n" + + "\rdepartment_id\x18\a \x01(\x03R\rdepartment_id\"\xf6\x02\n" + + "\rPositionEdges\x12A\n" + + "\n" + + "department\x18\x01 \x01(\v2!.api.v1.services.types.DepartmentR\n" + + "department\x121\n" + + "\x05users\x18\x02 \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12C\n" + + "\vpermissions\x18\x03 \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12K\n" + + "\x0euser_positions\x18\x04 \x03(\v2#.api.v1.services.types.UserPositionR\x0euser_positions\x12]\n" + + "\x14position_permissions\x18\x05 \x03(\v2).api.v1.services.types.PositionPermissionR\x14position_permissions\"\xe2\x04\n" + "\n" + "Permission\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + - "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12$\n" + - "\rcreate_author\x18\x04 \x01(\x03R\rcreate_author\x12$\n" + - "\rupdate_author\x18\x05 \x01(\x03R\rupdate_author\x12\x12\n" + - "\x04name\x18\x06 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\a \x01(\tR\akeyword\x12\x16\n" + - "\x06status\x18\b \x01(\x05R\x06status\x12 \n" + - "\vdescription\x18\t \x01(\tR\vdescription\x12\x1e\n" + + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x16\n" + + "\x06status\x18\x06 \x01(\x05R\x06status\x12 \n" + + "\vdescription\x18\a \x01(\tR\vdescription\x12\x1e\n" + "\n" + - "data_scope\x18\n" + - " \x01(\tR\n" + + "data_scope\x18\b \x01(\tR\n" + "data_scope\x12P\n" + "\n" + - "data_rules\x18\v \x03(\v20.api.v1.services.types.Permission.DataRulesEntryR\n" + + "data_rules\x18\t \x03(\v20.api.v1.services.types.Permission.DataRulesEntryR\n" + "data_rules\x12\"\n" + - "\fresource_ids\x18\f \x03(\x03R\fresource_ids\x12=\n" + - "\tresources\x18\r \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x1a\n" + - "\bview_ids\x18\x0e \x03(\x03R\bview_ids\x121\n" + - "\x05views\x18\x0f \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x1a<\n" + + "\fresource_ids\x18\n" + + " \x03(\x03R\fresource_ids\x12\x1a\n" + + "\bview_ids\x18\f \x03(\x03R\bview_ids\x12=\n" + + "\tresources\x18d \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + + "\x05views\x18e \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x1a<\n" + "\x0eDataRulesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"Z\n" + @@ -2220,7 +2221,7 @@ func file_types_system_proto_rawDescGZIP() []byte { return file_types_system_proto_rawDescData } -var file_types_system_proto_msgTypes = make([]protoimpl.MessageInfo, 16) +var file_types_system_proto_msgTypes = make([]protoimpl.MessageInfo, 17) var file_types_system_proto_goTypes = []any{ (*View)(nil), // 0: api.v1.services.types.View (*Role)(nil), // 1: api.v1.services.types.Role @@ -2231,64 +2232,70 @@ var file_types_system_proto_goTypes = []any{ (*Department)(nil), // 6: api.v1.services.types.Department (*UserDepartment)(nil), // 7: api.v1.services.types.UserDepartment (*Position)(nil), // 8: api.v1.services.types.Position - (*Permission)(nil), // 9: api.v1.services.types.Permission - (*UserPosition)(nil), // 10: api.v1.services.types.UserPosition - (*PositionPermission)(nil), // 11: api.v1.services.types.PositionPermission - (*RolePermission)(nil), // 12: api.v1.services.types.RolePermission - (*PermissionResource)(nil), // 13: api.v1.services.types.PermissionResource - nil, // 14: api.v1.services.types.Resource.PropertiesEntry - nil, // 15: api.v1.services.types.Permission.DataRulesEntry - (*timestamppb.Timestamp)(nil), // 16: google.protobuf.Timestamp + (*PositionEdges)(nil), // 9: api.v1.services.types.PositionEdges + (*Permission)(nil), // 10: api.v1.services.types.Permission + (*UserPosition)(nil), // 11: api.v1.services.types.UserPosition + (*PositionPermission)(nil), // 12: api.v1.services.types.PositionPermission + (*RolePermission)(nil), // 13: api.v1.services.types.RolePermission + (*PermissionResource)(nil), // 14: api.v1.services.types.PermissionResource + nil, // 15: api.v1.services.types.Resource.PropertiesEntry + nil, // 16: api.v1.services.types.Permission.DataRulesEntry + (*timestamppb.Timestamp)(nil), // 17: google.protobuf.Timestamp } var file_types_system_proto_depIdxs = []int32{ - 16, // 0: api.v1.services.types.View.create_time:type_name -> google.protobuf.Timestamp - 16, // 1: api.v1.services.types.View.update_time:type_name -> google.protobuf.Timestamp + 17, // 0: api.v1.services.types.View.create_time:type_name -> google.protobuf.Timestamp + 17, // 1: api.v1.services.types.View.update_time:type_name -> google.protobuf.Timestamp 0, // 2: api.v1.services.types.View.children:type_name -> api.v1.services.types.View 0, // 3: api.v1.services.types.View.parent:type_name -> api.v1.services.types.View 5, // 4: api.v1.services.types.View.resources:type_name -> api.v1.services.types.Resource 1, // 5: api.v1.services.types.View.roles:type_name -> api.v1.services.types.Role - 16, // 6: api.v1.services.types.Role.create_time:type_name -> google.protobuf.Timestamp - 16, // 7: api.v1.services.types.Role.update_time:type_name -> google.protobuf.Timestamp + 17, // 6: api.v1.services.types.Role.create_time:type_name -> google.protobuf.Timestamp + 17, // 7: api.v1.services.types.Role.update_time:type_name -> google.protobuf.Timestamp 0, // 8: api.v1.services.types.Role.views:type_name -> api.v1.services.types.View 2, // 9: api.v1.services.types.Role.users:type_name -> api.v1.services.types.User 5, // 10: api.v1.services.types.Role.resources:type_name -> api.v1.services.types.Resource - 9, // 11: api.v1.services.types.Role.permissions:type_name -> api.v1.services.types.Permission - 16, // 12: api.v1.services.types.User.create_time:type_name -> google.protobuf.Timestamp - 16, // 13: api.v1.services.types.User.update_time:type_name -> google.protobuf.Timestamp - 16, // 14: api.v1.services.types.User.last_login_time:type_name -> google.protobuf.Timestamp - 16, // 15: api.v1.services.types.User.login_time:type_name -> google.protobuf.Timestamp - 16, // 16: api.v1.services.types.User.sanction_date:type_name -> google.protobuf.Timestamp + 10, // 11: api.v1.services.types.Role.permissions:type_name -> api.v1.services.types.Permission + 17, // 12: api.v1.services.types.User.create_time:type_name -> google.protobuf.Timestamp + 17, // 13: api.v1.services.types.User.update_time:type_name -> google.protobuf.Timestamp + 17, // 14: api.v1.services.types.User.last_login_time:type_name -> google.protobuf.Timestamp + 17, // 15: api.v1.services.types.User.login_time:type_name -> google.protobuf.Timestamp + 17, // 16: api.v1.services.types.User.sanction_date:type_name -> google.protobuf.Timestamp 1, // 17: api.v1.services.types.User.roles:type_name -> api.v1.services.types.Role - 16, // 18: api.v1.services.types.UserRole.create_time:type_name -> google.protobuf.Timestamp - 16, // 19: api.v1.services.types.UserRole.update_time:type_name -> google.protobuf.Timestamp + 17, // 18: api.v1.services.types.UserRole.create_time:type_name -> google.protobuf.Timestamp + 17, // 19: api.v1.services.types.UserRole.update_time:type_name -> google.protobuf.Timestamp 2, // 20: api.v1.services.types.UserRole.user:type_name -> api.v1.services.types.User 1, // 21: api.v1.services.types.UserRole.role:type_name -> api.v1.services.types.Role - 16, // 22: api.v1.services.types.RoleView.create_time:type_name -> google.protobuf.Timestamp - 16, // 23: api.v1.services.types.RoleView.update_time:type_name -> google.protobuf.Timestamp + 17, // 22: api.v1.services.types.RoleView.create_time:type_name -> google.protobuf.Timestamp + 17, // 23: api.v1.services.types.RoleView.update_time:type_name -> google.protobuf.Timestamp 1, // 24: api.v1.services.types.RoleView.role:type_name -> api.v1.services.types.Role 0, // 25: api.v1.services.types.RoleView.view:type_name -> api.v1.services.types.View - 16, // 26: api.v1.services.types.Resource.create_time:type_name -> google.protobuf.Timestamp - 16, // 27: api.v1.services.types.Resource.update_time:type_name -> google.protobuf.Timestamp - 14, // 28: api.v1.services.types.Resource.properties:type_name -> api.v1.services.types.Resource.PropertiesEntry + 17, // 26: api.v1.services.types.Resource.create_time:type_name -> google.protobuf.Timestamp + 17, // 27: api.v1.services.types.Resource.update_time:type_name -> google.protobuf.Timestamp + 15, // 28: api.v1.services.types.Resource.properties:type_name -> api.v1.services.types.Resource.PropertiesEntry 5, // 29: api.v1.services.types.Resource.children:type_name -> api.v1.services.types.Resource 5, // 30: api.v1.services.types.Resource.parent:type_name -> api.v1.services.types.Resource - 9, // 31: api.v1.services.types.Resource.permissions:type_name -> api.v1.services.types.Permission - 16, // 32: api.v1.services.types.Department.create_time:type_name -> google.protobuf.Timestamp - 16, // 33: api.v1.services.types.Department.update_time:type_name -> google.protobuf.Timestamp + 10, // 31: api.v1.services.types.Resource.permissions:type_name -> api.v1.services.types.Permission + 17, // 32: api.v1.services.types.Department.create_time:type_name -> google.protobuf.Timestamp + 17, // 33: api.v1.services.types.Department.update_time:type_name -> google.protobuf.Timestamp 6, // 34: api.v1.services.types.Department.children:type_name -> api.v1.services.types.Department 6, // 35: api.v1.services.types.Department.parent:type_name -> api.v1.services.types.Department - 16, // 36: api.v1.services.types.Position.create_time:type_name -> google.protobuf.Timestamp - 16, // 37: api.v1.services.types.Position.update_time:type_name -> google.protobuf.Timestamp - 16, // 38: api.v1.services.types.Permission.create_time:type_name -> google.protobuf.Timestamp - 16, // 39: api.v1.services.types.Permission.update_time:type_name -> google.protobuf.Timestamp - 15, // 40: api.v1.services.types.Permission.data_rules:type_name -> api.v1.services.types.Permission.DataRulesEntry - 5, // 41: api.v1.services.types.Permission.resources:type_name -> api.v1.services.types.Resource - 0, // 42: api.v1.services.types.Permission.views:type_name -> api.v1.services.types.View - 43, // [43:43] is the sub-list for method output_type - 43, // [43:43] is the sub-list for method input_type - 43, // [43:43] is the sub-list for extension type_name - 43, // [43:43] is the sub-list for extension extendee - 0, // [0:43] is the sub-list for field type_name + 17, // 36: api.v1.services.types.Position.create_time:type_name -> google.protobuf.Timestamp + 17, // 37: api.v1.services.types.Position.update_time:type_name -> google.protobuf.Timestamp + 6, // 38: api.v1.services.types.PositionEdges.department:type_name -> api.v1.services.types.Department + 2, // 39: api.v1.services.types.PositionEdges.users:type_name -> api.v1.services.types.User + 10, // 40: api.v1.services.types.PositionEdges.permissions:type_name -> api.v1.services.types.Permission + 11, // 41: api.v1.services.types.PositionEdges.user_positions:type_name -> api.v1.services.types.UserPosition + 12, // 42: api.v1.services.types.PositionEdges.position_permissions:type_name -> api.v1.services.types.PositionPermission + 17, // 43: api.v1.services.types.Permission.create_time:type_name -> google.protobuf.Timestamp + 17, // 44: api.v1.services.types.Permission.update_time:type_name -> google.protobuf.Timestamp + 16, // 45: api.v1.services.types.Permission.data_rules:type_name -> api.v1.services.types.Permission.DataRulesEntry + 5, // 46: api.v1.services.types.Permission.resources:type_name -> api.v1.services.types.Resource + 0, // 47: api.v1.services.types.Permission.views:type_name -> api.v1.services.types.View + 48, // [48:48] is the sub-list for method output_type + 48, // [48:48] is the sub-list for method input_type + 48, // [48:48] is the sub-list for extension type_name + 48, // [48:48] is the sub-list for extension extendee + 0, // [0:48] is the sub-list for field type_name } func init() { file_types_system_proto_init() } @@ -2303,7 +2310,7 @@ func file_types_system_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_system_proto_rawDesc), len(file_types_system_proto_rawDesc)), NumEnums: 0, - NumMessages: 16, + NumMessages: 17, NumExtensions: 0, NumServices: 0, }, diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index 9815c758..8ec66789 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -122,7 +122,7 @@ func (m *View) validate(all bool) error { // no validation rules for Scope - // no validation rules for I18NKey + // no validation rules for I18N // no validation rules for Description @@ -130,8 +130,6 @@ func (m *View) validate(all bool) error { // no validation rules for Type - // no validation rules for Component - // no validation rules for Comment // no validation rules for Icon @@ -439,10 +437,6 @@ func (m *Role) validate(all bool) error { } } - // no validation rules for CreateAuthor - - // no validation rules for UpdateAuthor - // no validation rules for Keyword // no validation rules for Name @@ -693,6 +687,10 @@ func (m *User) validate(all bool) error { // no validation rules for Id + // no validation rules for CreateAuthor + + // no validation rules for UpdateAuthor + if all { switch v := interface{}(m.GetCreateTime()).(type) { case interface{ ValidateAll() error }: @@ -751,10 +749,6 @@ func (m *User) validate(all bool) error { } } - // no validation rules for CreateAuthor - - // no validation rules for UpdateAuthor - // no validation rules for Uuid // no validation rules for AllowedIp @@ -779,8 +773,6 @@ func (m *User) validate(all bool) error { // no validation rules for Status - // no validation rules for I18N - // no validation rules for LastLoginIp // no validation rules for LoginIp @@ -1513,14 +1505,12 @@ func (m *Resource) validate(all bool) error { } } - // no validation rules for CreateAuthor - - // no validation rules for UpdateAuthor - // no validation rules for Name // no validation rules for Keyword + // no validation rules for I18NKey + // no validation rules for Type // no validation rules for Status @@ -1531,8 +1521,14 @@ func (m *Resource) validate(all bool) error { // no validation rules for Method + // no validation rules for Component + + // no validation rules for Icon + // no validation rules for Sequence + // no validation rules for Visible + // no validation rules for TreePath // no validation rules for Properties @@ -1541,6 +1537,10 @@ func (m *Resource) validate(all bool) error { // no validation rules for ParentId + // no validation rules for SyncStatus + + // no validation rules for ServiceName + for idx, item := range m.GetChildren() { _, _ = idx, item @@ -1638,8 +1638,6 @@ func (m *Resource) validate(all bool) error { } - // no validation rules for ServiceName - if len(errors) > 0 { return ResourceMultiError(errors) } @@ -1799,10 +1797,6 @@ func (m *Department) validate(all bool) error { } } - // no validation rules for CreateAuthor - - // no validation rules for UpdateAuthor - // no validation rules for Keyword // no validation rules for Name @@ -2147,10 +2141,6 @@ func (m *Position) validate(all bool) error { } } - // no validation rules for CreateAuthor - - // no validation rules for UpdateAuthor - // no validation rules for Name // no validation rules for Keyword @@ -2236,6 +2226,271 @@ var _ interface { ErrorName() string } = PositionValidationError{} +// Validate checks the field values on PositionEdges 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 *PositionEdges) Validate() error { + return m.validate(false) +} + +// ValidateAll checks the field values on PositionEdges 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 PositionEdgesMultiError, or +// nil if none found. +func (m *PositionEdges) ValidateAll() error { + return m.validate(true) +} + +func (m *PositionEdges) validate(all bool) error { + if m == nil { + return nil + } + + var errors []error + + if all { + switch v := interface{}(m.GetDepartment()).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(m.GetDepartment()).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: "Department", + reason: "embedded message failed validation", + cause: err, + } + } + } + + for idx, item := range m.GetUsers() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("Users[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("Permissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetUserPositions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("UserPositions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("UserPositions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("UserPositions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + for idx, item := range m.GetPositionPermissions() { + _, _ = idx, item + + if all { + switch v := interface{}(item).(type) { + case interface{ ValidateAll() error }: + if err := v.ValidateAll(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + case interface{ Validate() error }: + if err := v.Validate(); err != nil { + errors = append(errors, PositionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + }) + } + } + } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { + if err := v.Validate(); err != nil { + return PositionEdgesValidationError{ + field: fmt.Sprintf("PositionPermissions[%v]", idx), + reason: "embedded message failed validation", + cause: err, + } + } + } + + } + + if len(errors) > 0 { + return PositionEdgesMultiError(errors) + } + + return nil +} + +// PositionEdgesMultiError is an error wrapping multiple validation errors +// returned by PositionEdges.ValidateAll() if the designated constraints +// aren't met. +type PositionEdgesMultiError []error + +// Error returns a concatenation of all the error messages it wraps. +func (m PositionEdgesMultiError) 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 PositionEdgesMultiError) AllErrors() []error { return m } + +// PositionEdgesValidationError is the validation error returned by +// PositionEdges.Validate if the designated constraints aren't met. +type PositionEdgesValidationError struct { + field string + reason string + cause error + key bool +} + +// Field function returns field value. +func (e PositionEdgesValidationError) Field() string { return e.field } + +// Reason function returns reason value. +func (e PositionEdgesValidationError) Reason() string { return e.reason } + +// Cause function returns cause value. +func (e PositionEdgesValidationError) Cause() error { return e.cause } + +// Key function returns key value. +func (e PositionEdgesValidationError) Key() bool { return e.key } + +// ErrorName returns error name. +func (e PositionEdgesValidationError) ErrorName() string { return "PositionEdgesValidationError" } + +// Error satisfies the builtin error interface +func (e PositionEdgesValidationError) 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 %sPositionEdges.%s: %s%s", + key, + e.field, + e.reason, + cause) +} + +var _ error = PositionEdgesValidationError{} + +var _ interface { + Field() string + Reason() string + Key() bool + Cause() error + ErrorName() string +} = PositionEdgesValidationError{} + // Validate checks the field values on Permission 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. @@ -2318,10 +2573,6 @@ func (m *Permission) validate(all bool) error { } } - // no validation rules for CreateAuthor - - // no validation rules for UpdateAuthor - // no validation rules for Name // no validation rules for Keyword diff --git a/internal/data/entity/ent/client.go b/internal/data/entity/ent/client.go index a101b4fb..cbfcc87c 100644 --- a/internal/data/entity/ent/client.go +++ b/internal/data/entity/ent/client.go @@ -1732,6 +1732,38 @@ func (c *ResourceClient) GetX(ctx context.Context, id int64) *Resource { return obj } +// QueryParent queries the parent edge of a Resource. +func (c *ResourceClient) QueryParent(_m *Resource) *ResourceQuery { + query := (&ResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, id), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, resource.ParentTable, resource.ParentColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + +// QueryChildren queries the children edge of a Resource. +func (c *ResourceClient) QueryChildren(_m *Resource) *ResourceQuery { + query := (&ResourceClient{config: c.config}).Query() + query.path = func(context.Context) (fromV *sql.Selector, _ error) { + id := _m.ID + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, id), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, resource.ChildrenTable, resource.ChildrenColumn), + ) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) + return fromV, nil + } + return query +} + // QueryViews queries the views edge of a Resource. func (c *ResourceClient) QueryViews(_m *Resource) *ViewQuery { query := (&ViewClient{config: c.config}).Query() diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index dab0b937..b3a9ab2f 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.i18n\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Resource\"},\"unique\":true,\"inverse\":true},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.resource.field.parent_id\"},{\"name\":\"properties\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.i18n\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.i18n\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.description\"},{\"name\":\"properties\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.properties\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index d852043d..736733f7 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -270,16 +270,24 @@ var ( {Name: "id", Type: field.TypeInt64, Comment: "field.primary_key.comment"}, {Name: "create_time", Type: field.TypeTime, Comment: "create_time.field.comment"}, {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, - {Name: "service_name", Type: field.TypeString, Comment: "entity.resource.field.service_name"}, {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.resource.field.keyword"}, - {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.path"}, + {Name: "name", Type: field.TypeString, Comment: "entity.resource.field.name", Default: ""}, + {Name: "i18n", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.i18n"}, + {Name: "type", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.type"}, + {Name: "status", Type: field.TypeInt8, Comment: "entity.resource.field.status", Default: 1}, + {Name: "sequence", Type: field.TypeInt, Comment: "entity.resource.field.sequence", Default: 0}, {Name: "method", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.method"}, + {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.path"}, {Name: "operation", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.operation"}, + {Name: "service_name", Type: field.TypeString, Comment: "entity.resource.field.service_name", Default: ""}, {Name: "policy", Type: field.TypeString, Comment: "entity.resource.field.policy", Default: ""}, {Name: "version_id", Type: field.TypeString, Comment: "entity.resource.field.version_id", Default: ""}, {Name: "last_sync_version_id", Type: field.TypeString, Comment: "entity.resource.field.last_sync_version_id", Default: ""}, {Name: "sync_status", Type: field.TypeString, Comment: "entity.resource.field.sync_status", Default: "Synced"}, - {Name: "status", Type: field.TypeInt8, Comment: "entity.resource.field.status", Default: 1}, + {Name: "tree_path", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.tree_path"}, + {Name: "properties", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.properties"}, + {Name: "description", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.description"}, + {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "entity.resource.field.parent_id"}, } // SysResourcesTable holds the schema information for the "sys_resources" table. SysResourcesTable = &schema.Table{ @@ -287,6 +295,14 @@ var ( Comment: "entity.resource.table.comment", Columns: SysResourcesColumns, PrimaryKey: []*schema.Column{SysResourcesColumns[0]}, + ForeignKeys: []*schema.ForeignKey{ + { + Symbol: "sys_resources_sys_resources_children", + Columns: []*schema.Column{SysResourcesColumns[20]}, + RefColumns: []*schema.Column{SysResourcesColumns[0]}, + OnDelete: schema.SetNull, + }, + }, Indexes: []*schema.Index{ { Name: "resource_create_time", @@ -575,6 +591,7 @@ var ( {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.view.field.keyword"}, {Name: "scope", Type: field.TypeString, Comment: "entity.view.field.scope", Default: "default"}, {Name: "name", Type: field.TypeString, Comment: "entity.view.field.name"}, + {Name: "i18n", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.i18n"}, {Name: "type", Type: field.TypeEnum, Comment: "entity.view.field.type", Enums: []string{"T", "G", "M", "L", "P", "B", "E", "R", "U"}, Default: "U"}, {Name: "component", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.component"}, {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.path"}, @@ -582,6 +599,9 @@ var ( {Name: "visible", Type: field.TypeBool, Comment: "entity.view.field.visible", Default: true}, {Name: "sequence", Type: field.TypeInt, Comment: "entity.view.field.sequence", Default: 0}, {Name: "tree_path", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.tree_path"}, + {Name: "description", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.description"}, + {Name: "properties", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.properties"}, + {Name: "status", Type: field.TypeInt8, Comment: "entity.view.field.status", Default: 1}, {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "entity.view.field.parent_id"}, } // SysViewsTable holds the schema information for the "sys_views" table. @@ -593,7 +613,7 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "sys_views_sys_views_children", - Columns: []*schema.Column{SysViewsColumns[13]}, + Columns: []*schema.Column{SysViewsColumns[17]}, RefColumns: []*schema.Column{SysViewsColumns[0]}, OnDelete: schema.SetNull, }, @@ -779,6 +799,7 @@ func init() { SysPositionPermissionsTable.Annotation = &entsql.Annotation{ Table: "sys_position_permissions", } + SysResourcesTable.ForeignKeys[0].RefTable = SysResourcesTable SysResourcesTable.Annotation = &entsql.Annotation{ Table: "sys_resources", } diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index b7d3e1ba..7e27bb0e 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -6391,18 +6391,31 @@ type ResourceMutation struct { id *int64 create_time *time.Time update_time *time.Time - service_name *string keyword *string - _path *string + name *string + i18n *string + _type *string + status *enums.Status + addstatus *enums.Status + sequence *int + addsequence *int method *string + _path *string operation *string + service_name *string policy *string version_id *string last_sync_version_id *string sync_status *string - status *enums.Status - addstatus *enums.Status + tree_path *string + properties *string + description *string clearedFields map[string]struct{} + parent *int64 + clearedparent bool + children map[int64]struct{} + removedchildren map[int64]struct{} + clearedchildren bool views map[int64]struct{} removedviews map[int64]struct{} clearedviews bool @@ -6593,125 +6606,286 @@ func (m *ResourceMutation) ResetUpdateTime() { m.update_time = nil } -// SetServiceName sets the "service_name" field. -func (m *ResourceMutation) SetServiceName(s string) { - m.service_name = &s +// SetKeyword sets the "keyword" field. +func (m *ResourceMutation) SetKeyword(s string) { + m.keyword = &s } -// ServiceName returns the value of the "service_name" field in the mutation. -func (m *ResourceMutation) ServiceName() (r string, exists bool) { - v := m.service_name +// Keyword returns the value of the "keyword" field in the mutation. +func (m *ResourceMutation) Keyword() (r string, exists bool) { + v := m.keyword if v == nil { return } return *v, true } -// OldServiceName returns the old "service_name" field's value of the Resource entity. +// OldKeyword returns the old "keyword" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldServiceName(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldKeyword(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldServiceName is only allowed on UpdateOne operations") + return v, errors.New("OldKeyword is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldServiceName requires an ID field in the mutation") + return v, errors.New("OldKeyword requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldServiceName: %w", err) + return v, fmt.Errorf("querying old value for OldKeyword: %w", err) } - return oldValue.ServiceName, nil + return oldValue.Keyword, nil } -// ResetServiceName resets all changes to the "service_name" field. -func (m *ResourceMutation) ResetServiceName() { - m.service_name = nil +// ResetKeyword resets all changes to the "keyword" field. +func (m *ResourceMutation) ResetKeyword() { + m.keyword = nil } -// SetKeyword sets the "keyword" field. -func (m *ResourceMutation) SetKeyword(s string) { - m.keyword = &s +// SetName sets the "name" field. +func (m *ResourceMutation) SetName(s string) { + m.name = &s } -// Keyword returns the value of the "keyword" field in the mutation. -func (m *ResourceMutation) Keyword() (r string, exists bool) { - v := m.keyword +// Name returns the value of the "name" field in the mutation. +func (m *ResourceMutation) Name() (r string, exists bool) { + v := m.name if v == nil { return } return *v, true } -// OldKeyword returns the old "keyword" field's value of the Resource entity. +// OldName returns the old "name" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldKeyword(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldName(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldKeyword is only allowed on UpdateOne operations") + return v, errors.New("OldName is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldKeyword requires an ID field in the mutation") + return v, errors.New("OldName requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldKeyword: %w", err) + return v, fmt.Errorf("querying old value for OldName: %w", err) } - return oldValue.Keyword, nil + return oldValue.Name, nil } -// ResetKeyword resets all changes to the "keyword" field. -func (m *ResourceMutation) ResetKeyword() { - m.keyword = nil +// ResetName resets all changes to the "name" field. +func (m *ResourceMutation) ResetName() { + m.name = nil } -// SetPath sets the "path" field. -func (m *ResourceMutation) SetPath(s string) { - m._path = &s +// SetI18n sets the "i18n" field. +func (m *ResourceMutation) SetI18n(s string) { + m.i18n = &s } -// Path returns the value of the "path" field in the mutation. -func (m *ResourceMutation) Path() (r string, exists bool) { - v := m._path +// I18n returns the value of the "i18n" field in the mutation. +func (m *ResourceMutation) I18n() (r string, exists bool) { + v := m.i18n if v == nil { return } return *v, true } -// OldPath returns the old "path" field's value of the Resource entity. +// OldI18n returns the old "i18n" field's value of the Resource entity. // If the Resource object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldPath(ctx context.Context) (v string, err error) { +func (m *ResourceMutation) OldI18n(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldPath is only allowed on UpdateOne operations") + return v, errors.New("OldI18n is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldPath requires an ID field in the mutation") + return v, errors.New("OldI18n requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldPath: %w", err) + return v, fmt.Errorf("querying old value for OldI18n: %w", err) } - return oldValue.Path, nil + return oldValue.I18n, nil } -// ClearPath clears the value of the "path" field. -func (m *ResourceMutation) ClearPath() { - m._path = nil - m.clearedFields[resource.FieldPath] = struct{}{} +// ClearI18n clears the value of the "i18n" field. +func (m *ResourceMutation) ClearI18n() { + m.i18n = nil + m.clearedFields[resource.FieldI18n] = struct{}{} } -// PathCleared returns if the "path" field was cleared in this mutation. -func (m *ResourceMutation) PathCleared() bool { - _, ok := m.clearedFields[resource.FieldPath] +// I18nCleared returns if the "i18n" field was cleared in this mutation. +func (m *ResourceMutation) I18nCleared() bool { + _, ok := m.clearedFields[resource.FieldI18n] return ok } -// ResetPath resets all changes to the "path" field. -func (m *ResourceMutation) ResetPath() { - m._path = nil - delete(m.clearedFields, resource.FieldPath) +// ResetI18n resets all changes to the "i18n" field. +func (m *ResourceMutation) ResetI18n() { + m.i18n = nil + delete(m.clearedFields, resource.FieldI18n) +} + +// SetType sets the "type" field. +func (m *ResourceMutation) SetType(s string) { + m._type = &s +} + +// GetType returns the value of the "type" field in the mutation. +func (m *ResourceMutation) GetType() (r string, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ClearType clears the value of the "type" field. +func (m *ResourceMutation) ClearType() { + m._type = nil + m.clearedFields[resource.FieldType] = struct{}{} +} + +// TypeCleared returns if the "type" field was cleared in this mutation. +func (m *ResourceMutation) TypeCleared() bool { + _, ok := m.clearedFields[resource.FieldType] + return ok +} + +// ResetType resets all changes to the "type" field. +func (m *ResourceMutation) ResetType() { + m._type = nil + delete(m.clearedFields, resource.FieldType) +} + +// SetStatus sets the "status" field. +func (m *ResourceMutation) SetStatus(e enums.Status) { + m.status = &e + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *ResourceMutation) Status() (r enums.Status, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldStatus(ctx context.Context) (v enums.Status, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds e to the "status" field. +func (m *ResourceMutation) AddStatus(e enums.Status) { + if m.addstatus != nil { + *m.addstatus += e + } else { + m.addstatus = &e + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *ResourceMutation) AddedStatus() (r enums.Status, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ResetStatus resets all changes to the "status" field. +func (m *ResourceMutation) ResetStatus() { + m.status = nil + m.addstatus = nil +} + +// SetSequence sets the "sequence" field. +func (m *ResourceMutation) SetSequence(i int) { + m.sequence = &i + m.addsequence = nil +} + +// Sequence returns the value of the "sequence" field in the mutation. +func (m *ResourceMutation) Sequence() (r int, exists bool) { + v := m.sequence + if v == nil { + return + } + return *v, true +} + +// OldSequence returns the old "sequence" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldSequence(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSequence is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSequence requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSequence: %w", err) + } + return oldValue.Sequence, nil +} + +// AddSequence adds i to the "sequence" field. +func (m *ResourceMutation) AddSequence(i int) { + if m.addsequence != nil { + *m.addsequence += i + } else { + m.addsequence = &i + } +} + +// AddedSequence returns the value that was added to the "sequence" field in this mutation. +func (m *ResourceMutation) AddedSequence() (r int, exists bool) { + v := m.addsequence + if v == nil { + return + } + return *v, true +} + +// ResetSequence resets all changes to the "sequence" field. +func (m *ResourceMutation) ResetSequence() { + m.sequence = nil + m.addsequence = nil } // SetMethod sets the "method" field. @@ -6763,6 +6937,55 @@ func (m *ResourceMutation) ResetMethod() { delete(m.clearedFields, resource.FieldMethod) } +// SetPath sets the "path" field. +func (m *ResourceMutation) SetPath(s string) { + m._path = &s +} + +// Path returns the value of the "path" field in the mutation. +func (m *ResourceMutation) Path() (r string, exists bool) { + v := m._path + if v == nil { + return + } + return *v, true +} + +// OldPath returns the old "path" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldPath(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPath is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPath requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPath: %w", err) + } + return oldValue.Path, nil +} + +// ClearPath clears the value of the "path" field. +func (m *ResourceMutation) ClearPath() { + m._path = nil + m.clearedFields[resource.FieldPath] = struct{}{} +} + +// PathCleared returns if the "path" field was cleared in this mutation. +func (m *ResourceMutation) PathCleared() bool { + _, ok := m.clearedFields[resource.FieldPath] + return ok +} + +// ResetPath resets all changes to the "path" field. +func (m *ResourceMutation) ResetPath() { + m._path = nil + delete(m.clearedFields, resource.FieldPath) +} + // SetOperation sets the "operation" field. func (m *ResourceMutation) SetOperation(s string) { m.operation = &s @@ -6812,6 +7035,42 @@ func (m *ResourceMutation) ResetOperation() { delete(m.clearedFields, resource.FieldOperation) } +// SetServiceName sets the "service_name" field. +func (m *ResourceMutation) SetServiceName(s string) { + m.service_name = &s +} + +// ServiceName returns the value of the "service_name" field in the mutation. +func (m *ResourceMutation) ServiceName() (r string, exists bool) { + v := m.service_name + if v == nil { + return + } + return *v, true +} + +// OldServiceName returns the old "service_name" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldServiceName(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServiceName is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServiceName requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServiceName: %w", err) + } + return oldValue.ServiceName, nil +} + +// ResetServiceName resets all changes to the "service_name" field. +func (m *ResourceMutation) ResetServiceName() { + m.service_name = nil +} + // SetPolicy sets the "policy" field. func (m *ResourceMutation) SetPolicy(s string) { m.policy = &s @@ -6948,68 +7207,289 @@ func (m *ResourceMutation) OldSyncStatus(ctx context.Context) (v string, err err if err != nil { return v, fmt.Errorf("querying old value for OldSyncStatus: %w", err) } - return oldValue.SyncStatus, nil + return oldValue.SyncStatus, nil +} + +// ResetSyncStatus resets all changes to the "sync_status" field. +func (m *ResourceMutation) ResetSyncStatus() { + m.sync_status = nil +} + +// SetTreePath sets the "tree_path" field. +func (m *ResourceMutation) SetTreePath(s string) { + m.tree_path = &s +} + +// TreePath returns the value of the "tree_path" field in the mutation. +func (m *ResourceMutation) TreePath() (r string, exists bool) { + v := m.tree_path + if v == nil { + return + } + return *v, true +} + +// OldTreePath returns the old "tree_path" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldTreePath(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTreePath is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTreePath requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTreePath: %w", err) + } + return oldValue.TreePath, nil +} + +// ClearTreePath clears the value of the "tree_path" field. +func (m *ResourceMutation) ClearTreePath() { + m.tree_path = nil + m.clearedFields[resource.FieldTreePath] = struct{}{} +} + +// TreePathCleared returns if the "tree_path" field was cleared in this mutation. +func (m *ResourceMutation) TreePathCleared() bool { + _, ok := m.clearedFields[resource.FieldTreePath] + return ok +} + +// ResetTreePath resets all changes to the "tree_path" field. +func (m *ResourceMutation) ResetTreePath() { + m.tree_path = nil + delete(m.clearedFields, resource.FieldTreePath) +} + +// SetParentID sets the "parent_id" field. +func (m *ResourceMutation) SetParentID(i int64) { + m.parent = &i +} + +// ParentID returns the value of the "parent_id" field in the mutation. +func (m *ResourceMutation) ParentID() (r int64, exists bool) { + v := m.parent + if v == nil { + return + } + return *v, true +} + +// OldParentID returns the old "parent_id" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldParentID(ctx context.Context) (v int64, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldParentID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldParentID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldParentID: %w", err) + } + return oldValue.ParentID, nil +} + +// ClearParentID clears the value of the "parent_id" field. +func (m *ResourceMutation) ClearParentID() { + m.parent = nil + m.clearedFields[resource.FieldParentID] = struct{}{} +} + +// ParentIDCleared returns if the "parent_id" field was cleared in this mutation. +func (m *ResourceMutation) ParentIDCleared() bool { + _, ok := m.clearedFields[resource.FieldParentID] + return ok +} + +// ResetParentID resets all changes to the "parent_id" field. +func (m *ResourceMutation) ResetParentID() { + m.parent = nil + delete(m.clearedFields, resource.FieldParentID) +} + +// SetProperties sets the "properties" field. +func (m *ResourceMutation) SetProperties(s string) { + m.properties = &s +} + +// Properties returns the value of the "properties" field in the mutation. +func (m *ResourceMutation) Properties() (r string, exists bool) { + v := m.properties + if v == nil { + return + } + return *v, true +} + +// OldProperties returns the old "properties" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldProperties(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProperties is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProperties requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProperties: %w", err) + } + return oldValue.Properties, nil +} + +// ClearProperties clears the value of the "properties" field. +func (m *ResourceMutation) ClearProperties() { + m.properties = nil + m.clearedFields[resource.FieldProperties] = struct{}{} +} + +// PropertiesCleared returns if the "properties" field was cleared in this mutation. +func (m *ResourceMutation) PropertiesCleared() bool { + _, ok := m.clearedFields[resource.FieldProperties] + return ok +} + +// ResetProperties resets all changes to the "properties" field. +func (m *ResourceMutation) ResetProperties() { + m.properties = nil + delete(m.clearedFields, resource.FieldProperties) +} + +// SetDescription sets the "description" field. +func (m *ResourceMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *ResourceMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Resource entity. +// If the Resource object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ResourceMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *ResourceMutation) ClearDescription() { + m.description = nil + m.clearedFields[resource.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *ResourceMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[resource.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *ResourceMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, resource.FieldDescription) +} + +// ClearParent clears the "parent" edge to the Resource entity. +func (m *ResourceMutation) ClearParent() { + m.clearedparent = true + m.clearedFields[resource.FieldParentID] = struct{}{} +} + +// ParentCleared reports if the "parent" edge to the Resource entity was cleared. +func (m *ResourceMutation) ParentCleared() bool { + return m.ParentIDCleared() || m.clearedparent +} + +// ParentIDs returns the "parent" edge IDs in the mutation. +// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use +// ParentID instead. It exists only for internal usage by the builders. +func (m *ResourceMutation) ParentIDs() (ids []int64) { + if id := m.parent; id != nil { + ids = append(ids, *id) + } + return } -// ResetSyncStatus resets all changes to the "sync_status" field. -func (m *ResourceMutation) ResetSyncStatus() { - m.sync_status = nil +// ResetParent resets all changes to the "parent" edge. +func (m *ResourceMutation) ResetParent() { + m.parent = nil + m.clearedparent = false } -// SetStatus sets the "status" field. -func (m *ResourceMutation) SetStatus(e enums.Status) { - m.status = &e - m.addstatus = nil +// AddChildIDs adds the "children" edge to the Resource entity by ids. +func (m *ResourceMutation) AddChildIDs(ids ...int64) { + if m.children == nil { + m.children = make(map[int64]struct{}) + } + for i := range ids { + m.children[ids[i]] = struct{}{} + } } -// Status returns the value of the "status" field in the mutation. -func (m *ResourceMutation) Status() (r enums.Status, exists bool) { - v := m.status - if v == nil { - return - } - return *v, true +// ClearChildren clears the "children" edge to the Resource entity. +func (m *ResourceMutation) ClearChildren() { + m.clearedchildren = true } -// OldStatus returns the old "status" field's value of the Resource entity. -// If the Resource object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *ResourceMutation) OldStatus(ctx context.Context) (v enums.Status, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldStatus is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldStatus requires an ID field in the mutation") +// ChildrenCleared reports if the "children" edge to the Resource entity was cleared. +func (m *ResourceMutation) ChildrenCleared() bool { + return m.clearedchildren +} + +// RemoveChildIDs removes the "children" edge to the Resource entity by IDs. +func (m *ResourceMutation) RemoveChildIDs(ids ...int64) { + if m.removedchildren == nil { + m.removedchildren = make(map[int64]struct{}) } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldStatus: %w", err) + for i := range ids { + delete(m.children, ids[i]) + m.removedchildren[ids[i]] = struct{}{} } - return oldValue.Status, nil } -// AddStatus adds e to the "status" field. -func (m *ResourceMutation) AddStatus(e enums.Status) { - if m.addstatus != nil { - *m.addstatus += e - } else { - m.addstatus = &e +// RemovedChildren returns the removed IDs of the "children" edge to the Resource entity. +func (m *ResourceMutation) RemovedChildrenIDs() (ids []int64) { + for id := range m.removedchildren { + ids = append(ids, id) } + return } -// AddedStatus returns the value that was added to the "status" field in this mutation. -func (m *ResourceMutation) AddedStatus() (r enums.Status, exists bool) { - v := m.addstatus - if v == nil { - return +// ChildrenIDs returns the "children" edge IDs in the mutation. +func (m *ResourceMutation) ChildrenIDs() (ids []int64) { + for id := range m.children { + ids = append(ids, id) } - return *v, true + return } -// ResetStatus resets all changes to the "status" field. -func (m *ResourceMutation) ResetStatus() { - m.status = nil - m.addstatus = nil +// ResetChildren resets all changes to the "children" edge. +func (m *ResourceMutation) ResetChildren() { + m.children = nil + m.clearedchildren = false + m.removedchildren = nil } // AddViewIDs adds the "views" edge to the View entity by ids. @@ -7208,28 +7688,43 @@ func (m *ResourceMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *ResourceMutation) Fields() []string { - fields := make([]string, 0, 12) + fields := make([]string, 0, 20) if m.create_time != nil { fields = append(fields, resource.FieldCreateTime) } if m.update_time != nil { fields = append(fields, resource.FieldUpdateTime) } - if m.service_name != nil { - fields = append(fields, resource.FieldServiceName) - } if m.keyword != nil { fields = append(fields, resource.FieldKeyword) } - if m._path != nil { - fields = append(fields, resource.FieldPath) + if m.name != nil { + fields = append(fields, resource.FieldName) + } + if m.i18n != nil { + fields = append(fields, resource.FieldI18n) + } + if m._type != nil { + fields = append(fields, resource.FieldType) + } + if m.status != nil { + fields = append(fields, resource.FieldStatus) + } + if m.sequence != nil { + fields = append(fields, resource.FieldSequence) } if m.method != nil { fields = append(fields, resource.FieldMethod) } + if m._path != nil { + fields = append(fields, resource.FieldPath) + } if m.operation != nil { fields = append(fields, resource.FieldOperation) } + if m.service_name != nil { + fields = append(fields, resource.FieldServiceName) + } if m.policy != nil { fields = append(fields, resource.FieldPolicy) } @@ -7242,8 +7737,17 @@ func (m *ResourceMutation) Fields() []string { if m.sync_status != nil { fields = append(fields, resource.FieldSyncStatus) } - if m.status != nil { - fields = append(fields, resource.FieldStatus) + if m.tree_path != nil { + fields = append(fields, resource.FieldTreePath) + } + if m.parent != nil { + fields = append(fields, resource.FieldParentID) + } + if m.properties != nil { + fields = append(fields, resource.FieldProperties) + } + if m.description != nil { + fields = append(fields, resource.FieldDescription) } return fields } @@ -7257,16 +7761,26 @@ func (m *ResourceMutation) Field(name string) (ent.Value, bool) { return m.CreateTime() case resource.FieldUpdateTime: return m.UpdateTime() - case resource.FieldServiceName: - return m.ServiceName() case resource.FieldKeyword: return m.Keyword() - case resource.FieldPath: - return m.Path() + case resource.FieldName: + return m.Name() + case resource.FieldI18n: + return m.I18n() + case resource.FieldType: + return m.GetType() + case resource.FieldStatus: + return m.Status() + case resource.FieldSequence: + return m.Sequence() case resource.FieldMethod: return m.Method() + case resource.FieldPath: + return m.Path() case resource.FieldOperation: return m.Operation() + case resource.FieldServiceName: + return m.ServiceName() case resource.FieldPolicy: return m.Policy() case resource.FieldVersionID: @@ -7275,8 +7789,14 @@ func (m *ResourceMutation) Field(name string) (ent.Value, bool) { return m.LastSyncVersionID() case resource.FieldSyncStatus: return m.SyncStatus() - case resource.FieldStatus: - return m.Status() + case resource.FieldTreePath: + return m.TreePath() + case resource.FieldParentID: + return m.ParentID() + case resource.FieldProperties: + return m.Properties() + case resource.FieldDescription: + return m.Description() } return nil, false } @@ -7290,16 +7810,26 @@ func (m *ResourceMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldCreateTime(ctx) case resource.FieldUpdateTime: return m.OldUpdateTime(ctx) - case resource.FieldServiceName: - return m.OldServiceName(ctx) case resource.FieldKeyword: return m.OldKeyword(ctx) - case resource.FieldPath: - return m.OldPath(ctx) + case resource.FieldName: + return m.OldName(ctx) + case resource.FieldI18n: + return m.OldI18n(ctx) + case resource.FieldType: + return m.OldType(ctx) + case resource.FieldStatus: + return m.OldStatus(ctx) + case resource.FieldSequence: + return m.OldSequence(ctx) case resource.FieldMethod: return m.OldMethod(ctx) + case resource.FieldPath: + return m.OldPath(ctx) case resource.FieldOperation: return m.OldOperation(ctx) + case resource.FieldServiceName: + return m.OldServiceName(ctx) case resource.FieldPolicy: return m.OldPolicy(ctx) case resource.FieldVersionID: @@ -7308,8 +7838,14 @@ func (m *ResourceMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldLastSyncVersionID(ctx) case resource.FieldSyncStatus: return m.OldSyncStatus(ctx) - case resource.FieldStatus: - return m.OldStatus(ctx) + case resource.FieldTreePath: + return m.OldTreePath(ctx) + case resource.FieldParentID: + return m.OldParentID(ctx) + case resource.FieldProperties: + return m.OldProperties(ctx) + case resource.FieldDescription: + return m.OldDescription(ctx) } return nil, fmt.Errorf("unknown Resource field %s", name) } @@ -7333,26 +7869,47 @@ func (m *ResourceMutation) SetField(name string, value ent.Value) error { } m.SetUpdateTime(v) return nil - case resource.FieldServiceName: + case resource.FieldKeyword: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetServiceName(v) + m.SetKeyword(v) return nil - case resource.FieldKeyword: + case resource.FieldName: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetKeyword(v) + m.SetName(v) return nil - case resource.FieldPath: + case resource.FieldI18n: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetPath(v) + m.SetI18n(v) + return nil + case resource.FieldType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case resource.FieldStatus: + v, ok := value.(enums.Status) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case resource.FieldSequence: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSequence(v) return nil case resource.FieldMethod: v, ok := value.(string) @@ -7361,6 +7918,13 @@ func (m *ResourceMutation) SetField(name string, value ent.Value) error { } m.SetMethod(v) return nil + case resource.FieldPath: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPath(v) + return nil case resource.FieldOperation: v, ok := value.(string) if !ok { @@ -7368,6 +7932,13 @@ func (m *ResourceMutation) SetField(name string, value ent.Value) error { } m.SetOperation(v) return nil + case resource.FieldServiceName: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServiceName(v) + return nil case resource.FieldPolicy: v, ok := value.(string) if !ok { @@ -7396,12 +7967,33 @@ func (m *ResourceMutation) SetField(name string, value ent.Value) error { } m.SetSyncStatus(v) return nil - case resource.FieldStatus: - v, ok := value.(enums.Status) + case resource.FieldTreePath: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetStatus(v) + m.SetTreePath(v) + return nil + case resource.FieldParentID: + v, ok := value.(int64) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetParentID(v) + return nil + case resource.FieldProperties: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProperties(v) + return nil + case resource.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) return nil } return fmt.Errorf("unknown Resource field %s", name) @@ -7414,6 +8006,9 @@ func (m *ResourceMutation) AddedFields() []string { if m.addstatus != nil { fields = append(fields, resource.FieldStatus) } + if m.addsequence != nil { + fields = append(fields, resource.FieldSequence) + } return fields } @@ -7424,6 +8019,8 @@ func (m *ResourceMutation) AddedField(name string) (ent.Value, bool) { switch name { case resource.FieldStatus: return m.AddedStatus() + case resource.FieldSequence: + return m.AddedSequence() } return nil, false } @@ -7440,6 +8037,13 @@ func (m *ResourceMutation) AddField(name string, value ent.Value) error { } m.AddStatus(v) return nil + case resource.FieldSequence: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddSequence(v) + return nil } return fmt.Errorf("unknown Resource numeric field %s", name) } @@ -7448,15 +8052,33 @@ func (m *ResourceMutation) AddField(name string, value ent.Value) error { // mutation. func (m *ResourceMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(resource.FieldPath) { - fields = append(fields, resource.FieldPath) + if m.FieldCleared(resource.FieldI18n) { + fields = append(fields, resource.FieldI18n) + } + if m.FieldCleared(resource.FieldType) { + fields = append(fields, resource.FieldType) } if m.FieldCleared(resource.FieldMethod) { fields = append(fields, resource.FieldMethod) } + if m.FieldCleared(resource.FieldPath) { + fields = append(fields, resource.FieldPath) + } if m.FieldCleared(resource.FieldOperation) { fields = append(fields, resource.FieldOperation) } + if m.FieldCleared(resource.FieldTreePath) { + fields = append(fields, resource.FieldTreePath) + } + if m.FieldCleared(resource.FieldParentID) { + fields = append(fields, resource.FieldParentID) + } + if m.FieldCleared(resource.FieldProperties) { + fields = append(fields, resource.FieldProperties) + } + if m.FieldCleared(resource.FieldDescription) { + fields = append(fields, resource.FieldDescription) + } return fields } @@ -7471,15 +8093,33 @@ func (m *ResourceMutation) FieldCleared(name string) bool { // error if the field is not defined in the schema. func (m *ResourceMutation) ClearField(name string) error { switch name { - case resource.FieldPath: - m.ClearPath() + case resource.FieldI18n: + m.ClearI18n() + return nil + case resource.FieldType: + m.ClearType() return nil case resource.FieldMethod: m.ClearMethod() return nil + case resource.FieldPath: + m.ClearPath() + return nil case resource.FieldOperation: m.ClearOperation() return nil + case resource.FieldTreePath: + m.ClearTreePath() + return nil + case resource.FieldParentID: + m.ClearParentID() + return nil + case resource.FieldProperties: + m.ClearProperties() + return nil + case resource.FieldDescription: + m.ClearDescription() + return nil } return fmt.Errorf("unknown Resource nullable field %s", name) } @@ -7494,21 +8134,36 @@ func (m *ResourceMutation) ResetField(name string) error { case resource.FieldUpdateTime: m.ResetUpdateTime() return nil - case resource.FieldServiceName: - m.ResetServiceName() - return nil case resource.FieldKeyword: m.ResetKeyword() return nil - case resource.FieldPath: - m.ResetPath() + case resource.FieldName: + m.ResetName() + return nil + case resource.FieldI18n: + m.ResetI18n() + return nil + case resource.FieldType: + m.ResetType() + return nil + case resource.FieldStatus: + m.ResetStatus() + return nil + case resource.FieldSequence: + m.ResetSequence() return nil case resource.FieldMethod: m.ResetMethod() return nil + case resource.FieldPath: + m.ResetPath() + return nil case resource.FieldOperation: m.ResetOperation() return nil + case resource.FieldServiceName: + m.ResetServiceName() + return nil case resource.FieldPolicy: m.ResetPolicy() return nil @@ -7521,8 +8176,17 @@ func (m *ResourceMutation) ResetField(name string) error { case resource.FieldSyncStatus: m.ResetSyncStatus() return nil - case resource.FieldStatus: - m.ResetStatus() + case resource.FieldTreePath: + m.ResetTreePath() + return nil + case resource.FieldParentID: + m.ResetParentID() + return nil + case resource.FieldProperties: + m.ResetProperties() + return nil + case resource.FieldDescription: + m.ResetDescription() return nil } return fmt.Errorf("unknown Resource field %s", name) @@ -7530,7 +8194,13 @@ func (m *ResourceMutation) ResetField(name string) error { // AddedEdges returns all edge names that were set/added in this mutation. func (m *ResourceMutation) AddedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 5) + if m.parent != nil { + edges = append(edges, resource.EdgeParent) + } + if m.children != nil { + edges = append(edges, resource.EdgeChildren) + } if m.views != nil { edges = append(edges, resource.EdgeViews) } @@ -7547,6 +8217,16 @@ func (m *ResourceMutation) AddedEdges() []string { // name in this mutation. func (m *ResourceMutation) AddedIDs(name string) []ent.Value { switch name { + case resource.EdgeParent: + if id := m.parent; id != nil { + return []ent.Value{*id} + } + case resource.EdgeChildren: + ids := make([]ent.Value, 0, len(m.children)) + for id := range m.children { + ids = append(ids, id) + } + return ids case resource.EdgeViews: ids := make([]ent.Value, 0, len(m.views)) for id := range m.views { @@ -7571,7 +8251,10 @@ func (m *ResourceMutation) AddedIDs(name string) []ent.Value { // RemovedEdges returns all edge names that were removed in this mutation. func (m *ResourceMutation) RemovedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 5) + if m.removedchildren != nil { + edges = append(edges, resource.EdgeChildren) + } if m.removedviews != nil { edges = append(edges, resource.EdgeViews) } @@ -7588,6 +8271,12 @@ func (m *ResourceMutation) RemovedEdges() []string { // the given name in this mutation. func (m *ResourceMutation) RemovedIDs(name string) []ent.Value { switch name { + case resource.EdgeChildren: + ids := make([]ent.Value, 0, len(m.removedchildren)) + for id := range m.removedchildren { + ids = append(ids, id) + } + return ids case resource.EdgeViews: ids := make([]ent.Value, 0, len(m.removedviews)) for id := range m.removedviews { @@ -7612,7 +8301,13 @@ func (m *ResourceMutation) RemovedIDs(name string) []ent.Value { // ClearedEdges returns all edge names that were cleared in this mutation. func (m *ResourceMutation) ClearedEdges() []string { - edges := make([]string, 0, 3) + edges := make([]string, 0, 5) + if m.clearedparent { + edges = append(edges, resource.EdgeParent) + } + if m.clearedchildren { + edges = append(edges, resource.EdgeChildren) + } if m.clearedviews { edges = append(edges, resource.EdgeViews) } @@ -7629,6 +8324,10 @@ func (m *ResourceMutation) ClearedEdges() []string { // was cleared in this mutation. func (m *ResourceMutation) EdgeCleared(name string) bool { switch name { + case resource.EdgeParent: + return m.clearedparent + case resource.EdgeChildren: + return m.clearedchildren case resource.EdgeViews: return m.clearedviews case resource.EdgePermissions: @@ -7643,6 +8342,9 @@ func (m *ResourceMutation) EdgeCleared(name string) bool { // if that edge is not defined in the schema. func (m *ResourceMutation) ClearEdge(name string) error { switch name { + case resource.EdgeParent: + m.ClearParent() + return nil } return fmt.Errorf("unknown Resource unique edge %s", name) } @@ -7651,6 +8353,12 @@ func (m *ResourceMutation) ClearEdge(name string) error { // It returns an error if the edge is not defined in the schema. func (m *ResourceMutation) ResetEdge(name string) error { switch name { + case resource.EdgeParent: + m.ResetParent() + return nil + case resource.EdgeChildren: + m.ResetChildren() + return nil case resource.EdgeViews: m.ResetViews() return nil @@ -13188,6 +13896,7 @@ type ViewMutation struct { keyword *string scope *string name *string + i18n *string _type *view.Type component *string _path *string @@ -13196,6 +13905,10 @@ type ViewMutation struct { sequence *int addsequence *int tree_path *string + description *string + properties *string + status *enums.Status + addstatus *enums.Status clearedFields map[string]struct{} parent *int64 clearedparent bool @@ -13552,6 +14265,55 @@ func (m *ViewMutation) ResetName() { m.name = nil } +// SetI18n sets the "i18n" field. +func (m *ViewMutation) SetI18n(s string) { + m.i18n = &s +} + +// I18n returns the value of the "i18n" field in the mutation. +func (m *ViewMutation) I18n() (r string, exists bool) { + v := m.i18n + if v == nil { + return + } + return *v, true +} + +// OldI18n returns the old "i18n" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldI18n(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldI18n is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldI18n requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldI18n: %w", err) + } + return oldValue.I18n, nil +} + +// ClearI18n clears the value of the "i18n" field. +func (m *ViewMutation) ClearI18n() { + m.i18n = nil + m.clearedFields[view.FieldI18n] = struct{}{} +} + +// I18nCleared returns if the "i18n" field was cleared in this mutation. +func (m *ViewMutation) I18nCleared() bool { + _, ok := m.clearedFields[view.FieldI18n] + return ok +} + +// ResetI18n resets all changes to the "i18n" field. +func (m *ViewMutation) ResetI18n() { + m.i18n = nil + delete(m.clearedFields, view.FieldI18n) +} + // SetType sets the "type" field. func (m *ViewMutation) SetType(v view.Type) { m._type = &v @@ -13876,6 +14638,160 @@ func (m *ViewMutation) ResetTreePath() { delete(m.clearedFields, view.FieldTreePath) } +// SetDescription sets the "description" field. +func (m *ViewMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *ViewMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ClearDescription clears the value of the "description" field. +func (m *ViewMutation) ClearDescription() { + m.description = nil + m.clearedFields[view.FieldDescription] = struct{}{} +} + +// DescriptionCleared returns if the "description" field was cleared in this mutation. +func (m *ViewMutation) DescriptionCleared() bool { + _, ok := m.clearedFields[view.FieldDescription] + return ok +} + +// ResetDescription resets all changes to the "description" field. +func (m *ViewMutation) ResetDescription() { + m.description = nil + delete(m.clearedFields, view.FieldDescription) +} + +// SetProperties sets the "properties" field. +func (m *ViewMutation) SetProperties(s string) { + m.properties = &s +} + +// Properties returns the value of the "properties" field in the mutation. +func (m *ViewMutation) Properties() (r string, exists bool) { + v := m.properties + if v == nil { + return + } + return *v, true +} + +// OldProperties returns the old "properties" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldProperties(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldProperties is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldProperties requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldProperties: %w", err) + } + return oldValue.Properties, nil +} + +// ClearProperties clears the value of the "properties" field. +func (m *ViewMutation) ClearProperties() { + m.properties = nil + m.clearedFields[view.FieldProperties] = struct{}{} +} + +// PropertiesCleared returns if the "properties" field was cleared in this mutation. +func (m *ViewMutation) PropertiesCleared() bool { + _, ok := m.clearedFields[view.FieldProperties] + return ok +} + +// ResetProperties resets all changes to the "properties" field. +func (m *ViewMutation) ResetProperties() { + m.properties = nil + delete(m.clearedFields, view.FieldProperties) +} + +// SetStatus sets the "status" field. +func (m *ViewMutation) SetStatus(e enums.Status) { + m.status = &e + m.addstatus = nil +} + +// Status returns the value of the "status" field in the mutation. +func (m *ViewMutation) Status() (r enums.Status, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the View entity. +// If the View object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ViewMutation) OldStatus(ctx context.Context) (v enums.Status, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// AddStatus adds e to the "status" field. +func (m *ViewMutation) AddStatus(e enums.Status) { + if m.addstatus != nil { + *m.addstatus += e + } else { + m.addstatus = &e + } +} + +// AddedStatus returns the value that was added to the "status" field in this mutation. +func (m *ViewMutation) AddedStatus() (r enums.Status, exists bool) { + v := m.addstatus + if v == nil { + return + } + return *v, true +} + +// ResetStatus resets all changes to the "status" field. +func (m *ViewMutation) ResetStatus() { + m.status = nil + m.addstatus = nil +} + // ClearParent clears the "parent" edge to the View entity. func (m *ViewMutation) ClearParent() { m.clearedparent = true @@ -14207,7 +15123,7 @@ func (m *ViewMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *ViewMutation) Fields() []string { - fields := make([]string, 0, 13) + fields := make([]string, 0, 17) if m.create_time != nil { fields = append(fields, view.FieldCreateTime) } @@ -14226,6 +15142,9 @@ func (m *ViewMutation) Fields() []string { if m.name != nil { fields = append(fields, view.FieldName) } + if m.i18n != nil { + fields = append(fields, view.FieldI18n) + } if m._type != nil { fields = append(fields, view.FieldType) } @@ -14247,6 +15166,15 @@ func (m *ViewMutation) Fields() []string { if m.tree_path != nil { fields = append(fields, view.FieldTreePath) } + if m.description != nil { + fields = append(fields, view.FieldDescription) + } + if m.properties != nil { + fields = append(fields, view.FieldProperties) + } + if m.status != nil { + fields = append(fields, view.FieldStatus) + } return fields } @@ -14267,6 +15195,8 @@ func (m *ViewMutation) Field(name string) (ent.Value, bool) { return m.Scope() case view.FieldName: return m.Name() + case view.FieldI18n: + return m.I18n() case view.FieldType: return m.GetType() case view.FieldComponent: @@ -14281,6 +15211,12 @@ func (m *ViewMutation) Field(name string) (ent.Value, bool) { return m.Sequence() case view.FieldTreePath: return m.TreePath() + case view.FieldDescription: + return m.Description() + case view.FieldProperties: + return m.Properties() + case view.FieldStatus: + return m.Status() } return nil, false } @@ -14302,6 +15238,8 @@ func (m *ViewMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldScope(ctx) case view.FieldName: return m.OldName(ctx) + case view.FieldI18n: + return m.OldI18n(ctx) case view.FieldType: return m.OldType(ctx) case view.FieldComponent: @@ -14316,6 +15254,12 @@ func (m *ViewMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldSequence(ctx) case view.FieldTreePath: return m.OldTreePath(ctx) + case view.FieldDescription: + return m.OldDescription(ctx) + case view.FieldProperties: + return m.OldProperties(ctx) + case view.FieldStatus: + return m.OldStatus(ctx) } return nil, fmt.Errorf("unknown View field %s", name) } @@ -14367,6 +15311,13 @@ func (m *ViewMutation) SetField(name string, value ent.Value) error { } m.SetName(v) return nil + case view.FieldI18n: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetI18n(v) + return nil case view.FieldType: v, ok := value.(view.Type) if !ok { @@ -14416,6 +15367,27 @@ func (m *ViewMutation) SetField(name string, value ent.Value) error { } m.SetTreePath(v) return nil + case view.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + case view.FieldProperties: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetProperties(v) + return nil + case view.FieldStatus: + v, ok := value.(enums.Status) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil } return fmt.Errorf("unknown View field %s", name) } @@ -14427,6 +15399,9 @@ func (m *ViewMutation) AddedFields() []string { if m.addsequence != nil { fields = append(fields, view.FieldSequence) } + if m.addstatus != nil { + fields = append(fields, view.FieldStatus) + } return fields } @@ -14437,6 +15412,8 @@ func (m *ViewMutation) AddedField(name string) (ent.Value, bool) { switch name { case view.FieldSequence: return m.AddedSequence() + case view.FieldStatus: + return m.AddedStatus() } return nil, false } @@ -14453,6 +15430,13 @@ func (m *ViewMutation) AddField(name string, value ent.Value) error { } m.AddSequence(v) return nil + case view.FieldStatus: + v, ok := value.(enums.Status) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddStatus(v) + return nil } return fmt.Errorf("unknown View numeric field %s", name) } @@ -14464,6 +15448,9 @@ func (m *ViewMutation) ClearedFields() []string { if m.FieldCleared(view.FieldParentID) { fields = append(fields, view.FieldParentID) } + if m.FieldCleared(view.FieldI18n) { + fields = append(fields, view.FieldI18n) + } if m.FieldCleared(view.FieldComponent) { fields = append(fields, view.FieldComponent) } @@ -14476,6 +15463,12 @@ func (m *ViewMutation) ClearedFields() []string { if m.FieldCleared(view.FieldTreePath) { fields = append(fields, view.FieldTreePath) } + if m.FieldCleared(view.FieldDescription) { + fields = append(fields, view.FieldDescription) + } + if m.FieldCleared(view.FieldProperties) { + fields = append(fields, view.FieldProperties) + } return fields } @@ -14493,6 +15486,9 @@ func (m *ViewMutation) ClearField(name string) error { case view.FieldParentID: m.ClearParentID() return nil + case view.FieldI18n: + m.ClearI18n() + return nil case view.FieldComponent: m.ClearComponent() return nil @@ -14505,6 +15501,12 @@ func (m *ViewMutation) ClearField(name string) error { case view.FieldTreePath: m.ClearTreePath() return nil + case view.FieldDescription: + m.ClearDescription() + return nil + case view.FieldProperties: + m.ClearProperties() + return nil } return fmt.Errorf("unknown View nullable field %s", name) } @@ -14531,6 +15533,9 @@ func (m *ViewMutation) ResetField(name string) error { case view.FieldName: m.ResetName() return nil + case view.FieldI18n: + m.ResetI18n() + return nil case view.FieldType: m.ResetType() return nil @@ -14552,6 +15557,15 @@ func (m *ViewMutation) ResetField(name string) error { case view.FieldTreePath: m.ResetTreePath() return nil + case view.FieldDescription: + m.ResetDescription() + return nil + case view.FieldProperties: + m.ResetProperties() + return nil + case view.FieldStatus: + m.ResetStatus() + return nil } return fmt.Errorf("unknown View field %s", name) } diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index 385b01ea..d89d0326 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -543,16 +543,26 @@ func (m *ResourceMutation) SetFields(input *Resource, fields ...string) error { m.SetCreateTime(input.CreateTime) case resource.FieldUpdateTime: m.SetUpdateTime(input.UpdateTime) - case resource.FieldServiceName: - m.SetServiceName(input.ServiceName) case resource.FieldKeyword: m.SetKeyword(input.Keyword) - case resource.FieldPath: - m.SetPath(input.Path) + case resource.FieldName: + m.SetName(input.Name) + case resource.FieldI18n: + m.SetI18n(input.I18n) + case resource.FieldType: + m.SetType(input.Type) + case resource.FieldStatus: + m.SetStatus(input.Status) + case resource.FieldSequence: + m.SetSequence(input.Sequence) case resource.FieldMethod: m.SetMethod(input.Method) + case resource.FieldPath: + m.SetPath(input.Path) case resource.FieldOperation: m.SetOperation(input.Operation) + case resource.FieldServiceName: + m.SetServiceName(input.ServiceName) case resource.FieldPolicy: m.SetPolicy(input.Policy) case resource.FieldVersionID: @@ -561,8 +571,14 @@ func (m *ResourceMutation) SetFields(input *Resource, fields ...string) error { m.SetLastSyncVersionID(input.LastSyncVersionID) case resource.FieldSyncStatus: m.SetSyncStatus(input.SyncStatus) - case resource.FieldStatus: - m.SetStatus(input.Status) + case resource.FieldTreePath: + m.SetTreePath(input.TreePath) + case resource.FieldParentID: + m.SetParentID(input.ParentID) + case resource.FieldProperties: + m.SetProperties(input.Properties) + case resource.FieldDescription: + m.SetDescription(input.Description) case resource.FieldID: m.SetID(input.ID) default: @@ -586,31 +602,56 @@ func (m *ResourceMutation) SetFieldsSkipZero(input *Resource, fields ...string) if input.UpdateTime.Unix() != 0 { m.SetUpdateTime(input.UpdateTime) } - case resource.FieldServiceName: - // check string with sql.NullString if it is empty - if input.ServiceName != "" { - m.SetServiceName(input.ServiceName) - } case resource.FieldKeyword: // check string with sql.NullString if it is empty if input.Keyword != "" { m.SetKeyword(input.Keyword) } - case resource.FieldPath: + case resource.FieldName: // check string with sql.NullString if it is empty - if input.Path != "" { - m.SetPath(input.Path) + if input.Name != "" { + m.SetName(input.Name) + } + case resource.FieldI18n: + // check string with sql.NullString if it is empty + if input.I18n != "" { + m.SetI18n(input.I18n) + } + case resource.FieldType: + // check string with sql.NullString if it is empty + if input.Type != "" { + m.SetType(input.Type) + } + case resource.FieldStatus: + // check enums.Status with sql.NullInt64 if it is zero + if input.Status != 0 { + m.SetStatus(input.Status) + } + case resource.FieldSequence: + // check int with sql.NullInt64 if it is zero + if input.Sequence != 0 { + m.SetSequence(input.Sequence) } case resource.FieldMethod: // check string with sql.NullString if it is empty if input.Method != "" { m.SetMethod(input.Method) } + case resource.FieldPath: + // check string with sql.NullString if it is empty + if input.Path != "" { + m.SetPath(input.Path) + } case resource.FieldOperation: // check string with sql.NullString if it is empty if input.Operation != "" { m.SetOperation(input.Operation) } + case resource.FieldServiceName: + // check string with sql.NullString if it is empty + if input.ServiceName != "" { + m.SetServiceName(input.ServiceName) + } case resource.FieldPolicy: // check string with sql.NullString if it is empty if input.Policy != "" { @@ -631,10 +672,25 @@ func (m *ResourceMutation) SetFieldsSkipZero(input *Resource, fields ...string) if input.SyncStatus != "" { m.SetSyncStatus(input.SyncStatus) } - case resource.FieldStatus: - // check enums.Status with sql.NullInt64 if it is zero - if input.Status != 0 { - m.SetStatus(input.Status) + case resource.FieldTreePath: + // check string with sql.NullString if it is empty + if input.TreePath != "" { + m.SetTreePath(input.TreePath) + } + case resource.FieldParentID: + // check int64 with sql.NullInt64 if it is zero + if input.ParentID != 0 { + m.SetParentID(input.ParentID) + } + case resource.FieldProperties: + // check string with sql.NullString if it is empty + if input.Properties != "" { + m.SetProperties(input.Properties) + } + case resource.FieldDescription: + // check string with sql.NullString if it is empty + if input.Description != "" { + m.SetDescription(input.Description) } case resource.FieldID: // check int64 with sql.NullInt64 if it is zero @@ -1135,6 +1191,8 @@ func (m *ViewMutation) SetFields(input *View, fields ...string) error { m.SetScope(input.Scope) case view.FieldName: m.SetName(input.Name) + case view.FieldI18n: + m.SetI18n(input.I18n) case view.FieldType: m.SetType(input.Type) case view.FieldComponent: @@ -1149,6 +1207,12 @@ func (m *ViewMutation) SetFields(input *View, fields ...string) error { m.SetSequence(input.Sequence) case view.FieldTreePath: m.SetTreePath(input.TreePath) + case view.FieldDescription: + m.SetDescription(input.Description) + case view.FieldProperties: + m.SetProperties(input.Properties) + case view.FieldStatus: + m.SetStatus(input.Status) case view.FieldID: m.SetID(input.ID) default: @@ -1192,6 +1256,11 @@ func (m *ViewMutation) SetFieldsSkipZero(input *View, fields ...string) error { if input.Name != "" { m.SetName(input.Name) } + case view.FieldI18n: + // check string with sql.NullString if it is empty + if input.I18n != "" { + m.SetI18n(input.I18n) + } case view.FieldType: var zero view.Type // check view.Type with sql.NullString if it is empty @@ -1227,6 +1296,21 @@ func (m *ViewMutation) SetFieldsSkipZero(input *View, fields ...string) error { if input.TreePath != "" { m.SetTreePath(input.TreePath) } + case view.FieldDescription: + // check string with sql.NullString if it is empty + if input.Description != "" { + m.SetDescription(input.Description) + } + case view.FieldProperties: + // check string with sql.NullString if it is empty + if input.Properties != "" { + m.SetProperties(input.Properties) + } + case view.FieldStatus: + // check enums.Status with sql.NullInt64 if it is zero + if input.Status != 0 { + m.SetStatus(input.Status) + } case view.FieldID: // check int64 with sql.NullInt64 if it is zero if input.ID != 0 { diff --git a/internal/data/entity/ent/resource.go b/internal/data/entity/ent/resource.go index 1fcf58c8..7e23add0 100644 --- a/internal/data/entity/ent/resource.go +++ b/internal/data/entity/ent/resource.go @@ -23,16 +23,26 @@ type Resource struct { CreateTime time.Time `json:"create_time,omitempty"` // update_time.field.comment UpdateTime time.Time `json:"update_time,omitempty"` - // entity.resource.field.service_name - ServiceName string `json:"service_name,omitempty"` // entity.resource.field.keyword Keyword string `json:"keyword,omitempty"` - // entity.resource.field.path - Path string `json:"path,omitempty"` + // entity.resource.field.name + Name string `json:"name,omitempty"` + // entity.resource.field.i18n + I18n string `json:"i18n,omitempty"` + // entity.resource.field.type + Type string `json:"type,omitempty"` + // entity.resource.field.status + Status enums.Status `json:"status,omitempty"` + // entity.resource.field.sequence + Sequence int `json:"sequence,omitempty"` // entity.resource.field.method Method string `json:"method,omitempty"` + // entity.resource.field.path + Path string `json:"path,omitempty"` // entity.resource.field.operation Operation string `json:"operation,omitempty"` + // entity.resource.field.service_name + ServiceName string `json:"service_name,omitempty"` // entity.resource.field.policy Policy string `json:"policy,omitempty"` // entity.resource.field.version_id @@ -41,8 +51,14 @@ type Resource struct { LastSyncVersionID string `json:"last_sync_version_id,omitempty"` // entity.resource.field.sync_status SyncStatus string `json:"sync_status,omitempty"` - // entity.resource.field.status - Status enums.Status `json:"status,omitempty"` + // entity.resource.field.tree_path + TreePath string `json:"tree_path,omitempty"` + // entity.resource.field.parent_id + ParentID int64 `json:"parent_id,omitempty"` + // entity.resource.field.properties + Properties string `json:"properties,omitempty"` + // entity.resource.field.description + Description string `json:"description,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ResourceQuery when eager-loading is set. Edges ResourceEdges `json:"edges"` @@ -51,6 +67,10 @@ type Resource struct { // ResourceEdges holds the relations/edges for other nodes in the graph. type ResourceEdges struct { + // Parent holds the value of the parent edge. + Parent *Resource `json:"parent,omitempty"` + // Children holds the value of the children edge. + Children []*Resource `json:"children,omitempty"` // Views holds the value of the views edge. Views []*View `json:"views,omitempty"` // Permissions holds the value of the permissions edge. @@ -59,13 +79,33 @@ type ResourceEdges struct { ViewResources []*ViewResource `json:"view_resources,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. - loadedTypes [3]bool + loadedTypes [5]bool +} + +// ParentOrErr returns the Parent value or an error if the edge +// was not loaded in eager-loading, or loaded but was not found. +func (e ResourceEdges) ParentOrErr() (*Resource, error) { + if e.Parent != nil { + return e.Parent, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: resource.Label} + } + return nil, &NotLoadedError{edge: "parent"} +} + +// ChildrenOrErr returns the Children value or an error if the edge +// was not loaded in eager-loading. +func (e ResourceEdges) ChildrenOrErr() ([]*Resource, error) { + if e.loadedTypes[1] { + return e.Children, nil + } + return nil, &NotLoadedError{edge: "children"} } // ViewsOrErr returns the Views value or an error if the edge // was not loaded in eager-loading. func (e ResourceEdges) ViewsOrErr() ([]*View, error) { - if e.loadedTypes[0] { + if e.loadedTypes[2] { return e.Views, nil } return nil, &NotLoadedError{edge: "views"} @@ -74,7 +114,7 @@ func (e ResourceEdges) ViewsOrErr() ([]*View, error) { // PermissionsOrErr returns the Permissions value or an error if the edge // was not loaded in eager-loading. func (e ResourceEdges) PermissionsOrErr() ([]*Permission, error) { - if e.loadedTypes[1] { + if e.loadedTypes[3] { return e.Permissions, nil } return nil, &NotLoadedError{edge: "permissions"} @@ -83,7 +123,7 @@ func (e ResourceEdges) PermissionsOrErr() ([]*Permission, error) { // ViewResourcesOrErr returns the ViewResources value or an error if the edge // was not loaded in eager-loading. func (e ResourceEdges) ViewResourcesOrErr() ([]*ViewResource, error) { - if e.loadedTypes[2] { + if e.loadedTypes[4] { return e.ViewResources, nil } return nil, &NotLoadedError{edge: "view_resources"} @@ -94,9 +134,9 @@ func (*Resource) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case resource.FieldID, resource.FieldStatus: + case resource.FieldID, resource.FieldStatus, resource.FieldSequence, resource.FieldParentID: values[i] = new(sql.NullInt64) - case resource.FieldServiceName, resource.FieldKeyword, resource.FieldPath, resource.FieldMethod, resource.FieldOperation, resource.FieldPolicy, resource.FieldVersionID, resource.FieldLastSyncVersionID, resource.FieldSyncStatus: + case resource.FieldKeyword, resource.FieldName, resource.FieldI18n, resource.FieldType, resource.FieldMethod, resource.FieldPath, resource.FieldOperation, resource.FieldServiceName, resource.FieldPolicy, resource.FieldVersionID, resource.FieldLastSyncVersionID, resource.FieldSyncStatus, resource.FieldTreePath, resource.FieldProperties, resource.FieldDescription: values[i] = new(sql.NullString) case resource.FieldCreateTime, resource.FieldUpdateTime: values[i] = new(sql.NullTime) @@ -133,23 +173,41 @@ func (_m *Resource) assignValues(columns []string, values []any) error { } else if value.Valid { _m.UpdateTime = value.Time } - case resource.FieldServiceName: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field service_name", values[i]) - } else if value.Valid { - _m.ServiceName = value.String - } case resource.FieldKeyword: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field keyword", values[i]) } else if value.Valid { _m.Keyword = value.String } - case resource.FieldPath: + case resource.FieldName: if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field path", values[i]) + return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { - _m.Path = value.String + _m.Name = value.String + } + case resource.FieldI18n: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field i18n", values[i]) + } else if value.Valid { + _m.I18n = value.String + } + case resource.FieldType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + _m.Type = value.String + } + case resource.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = enums.Status(value.Int64) + } + case resource.FieldSequence: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field sequence", values[i]) + } else if value.Valid { + _m.Sequence = int(value.Int64) } case resource.FieldMethod: if value, ok := values[i].(*sql.NullString); !ok { @@ -157,12 +215,24 @@ func (_m *Resource) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Method = value.String } + case resource.FieldPath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field path", values[i]) + } else if value.Valid { + _m.Path = value.String + } case resource.FieldOperation: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field operation", values[i]) } else if value.Valid { _m.Operation = value.String } + case resource.FieldServiceName: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field service_name", values[i]) + } else if value.Valid { + _m.ServiceName = value.String + } case resource.FieldPolicy: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field policy", values[i]) @@ -187,11 +257,29 @@ func (_m *Resource) assignValues(columns []string, values []any) error { } else if value.Valid { _m.SyncStatus = value.String } - case resource.FieldStatus: + case resource.FieldTreePath: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field tree_path", values[i]) + } else if value.Valid { + _m.TreePath = value.String + } + case resource.FieldParentID: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field status", values[i]) + return fmt.Errorf("unexpected type %T for field parent_id", values[i]) } else if value.Valid { - _m.Status = enums.Status(value.Int64) + _m.ParentID = value.Int64 + } + case resource.FieldProperties: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field properties", values[i]) + } else if value.Valid { + _m.Properties = value.String + } + case resource.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String } default: _m.selectValues.Set(columns[i], values[i]) @@ -206,6 +294,16 @@ func (_m *Resource) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } +// QueryParent queries the "parent" edge of the Resource entity. +func (_m *Resource) QueryParent() *ResourceQuery { + return NewResourceClient(_m.config).QueryParent(_m) +} + +// QueryChildren queries the "children" edge of the Resource entity. +func (_m *Resource) QueryChildren() *ResourceQuery { + return NewResourceClient(_m.config).QueryChildren(_m) +} + // QueryViews queries the "views" edge of the Resource entity. func (_m *Resource) QueryViews() *ViewQuery { return NewResourceClient(_m.config).QueryViews(_m) @@ -250,21 +348,36 @@ func (_m *Resource) String() string { builder.WriteString("update_time=") builder.WriteString(_m.UpdateTime.Format(time.ANSIC)) builder.WriteString(", ") - builder.WriteString("service_name=") - builder.WriteString(_m.ServiceName) - builder.WriteString(", ") builder.WriteString("keyword=") builder.WriteString(_m.Keyword) builder.WriteString(", ") - builder.WriteString("path=") - builder.WriteString(_m.Path) + builder.WriteString("name=") + builder.WriteString(_m.Name) + builder.WriteString(", ") + builder.WriteString("i18n=") + builder.WriteString(_m.I18n) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(_m.Type) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString(", ") + builder.WriteString("sequence=") + builder.WriteString(fmt.Sprintf("%v", _m.Sequence)) builder.WriteString(", ") builder.WriteString("method=") builder.WriteString(_m.Method) builder.WriteString(", ") + builder.WriteString("path=") + builder.WriteString(_m.Path) + builder.WriteString(", ") builder.WriteString("operation=") builder.WriteString(_m.Operation) builder.WriteString(", ") + builder.WriteString("service_name=") + builder.WriteString(_m.ServiceName) + builder.WriteString(", ") builder.WriteString("policy=") builder.WriteString(_m.Policy) builder.WriteString(", ") @@ -277,8 +390,17 @@ func (_m *Resource) String() string { builder.WriteString("sync_status=") builder.WriteString(_m.SyncStatus) builder.WriteString(", ") - builder.WriteString("status=") - builder.WriteString(fmt.Sprintf("%v", _m.Status)) + builder.WriteString("tree_path=") + builder.WriteString(_m.TreePath) + builder.WriteString(", ") + builder.WriteString("parent_id=") + builder.WriteString(fmt.Sprintf("%v", _m.ParentID)) + builder.WriteString(", ") + builder.WriteString("properties=") + builder.WriteString(_m.Properties) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/resource/resource.go b/internal/data/entity/ent/resource/resource.go index 89e18a7b..4e3a960b 100644 --- a/internal/data/entity/ent/resource/resource.go +++ b/internal/data/entity/ent/resource/resource.go @@ -19,16 +19,26 @@ const ( FieldCreateTime = "create_time" // FieldUpdateTime holds the string denoting the update_time field in the database. FieldUpdateTime = "update_time" - // FieldServiceName holds the string denoting the service_name field in the database. - FieldServiceName = "service_name" // FieldKeyword holds the string denoting the keyword field in the database. FieldKeyword = "keyword" - // FieldPath holds the string denoting the path field in the database. - FieldPath = "path" + // FieldName holds the string denoting the name field in the database. + FieldName = "name" + // FieldI18n holds the string denoting the i18n field in the database. + FieldI18n = "i18n" + // FieldType holds the string denoting the type field in the database. + FieldType = "type" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" + // FieldSequence holds the string denoting the sequence field in the database. + FieldSequence = "sequence" // FieldMethod holds the string denoting the method field in the database. FieldMethod = "method" + // FieldPath holds the string denoting the path field in the database. + FieldPath = "path" // FieldOperation holds the string denoting the operation field in the database. FieldOperation = "operation" + // FieldServiceName holds the string denoting the service_name field in the database. + FieldServiceName = "service_name" // FieldPolicy holds the string denoting the policy field in the database. FieldPolicy = "policy" // FieldVersionID holds the string denoting the version_id field in the database. @@ -37,8 +47,18 @@ const ( FieldLastSyncVersionID = "last_sync_version_id" // FieldSyncStatus holds the string denoting the sync_status field in the database. FieldSyncStatus = "sync_status" - // FieldStatus holds the string denoting the status field in the database. - FieldStatus = "status" + // FieldTreePath holds the string denoting the tree_path field in the database. + FieldTreePath = "tree_path" + // FieldParentID holds the string denoting the parent_id field in the database. + FieldParentID = "parent_id" + // FieldProperties holds the string denoting the properties field in the database. + FieldProperties = "properties" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // EdgeParent holds the string denoting the parent edge name in mutations. + EdgeParent = "parent" + // EdgeChildren holds the string denoting the children edge name in mutations. + EdgeChildren = "children" // EdgeViews holds the string denoting the views edge name in mutations. EdgeViews = "views" // EdgePermissions holds the string denoting the permissions edge name in mutations. @@ -47,6 +67,14 @@ const ( EdgeViewResources = "view_resources" // Table holds the table name of the resource in the database. Table = "sys_resources" + // ParentTable is the table that holds the parent relation/edge. + ParentTable = "sys_resources" + // ParentColumn is the table column denoting the parent relation/edge. + ParentColumn = "parent_id" + // ChildrenTable is the table that holds the children relation/edge. + ChildrenTable = "sys_resources" + // ChildrenColumn is the table column denoting the children relation/edge. + ChildrenColumn = "parent_id" // ViewsTable is the table that holds the views relation/edge. The primary key declared below. ViewsTable = "sys_view_resources" // ViewsInverseTable is the table name for the View entity. @@ -71,16 +99,24 @@ var Columns = []string{ FieldID, FieldCreateTime, FieldUpdateTime, - FieldServiceName, FieldKeyword, - FieldPath, + FieldName, + FieldI18n, + FieldType, + FieldStatus, + FieldSequence, FieldMethod, + FieldPath, FieldOperation, + FieldServiceName, FieldPolicy, FieldVersionID, FieldLastSyncVersionID, FieldSyncStatus, - FieldStatus, + FieldTreePath, + FieldParentID, + FieldProperties, + FieldDescription, } var ( @@ -111,6 +147,14 @@ var ( UpdateDefaultUpdateTime func() time.Time // KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. KeywordValidator func(string) error + // DefaultName holds the default value on creation for the "name" field. + DefaultName string + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus enums.Status + // DefaultSequence holds the default value on creation for the "sequence" field. + DefaultSequence int + // DefaultServiceName holds the default value on creation for the "service_name" field. + DefaultServiceName string // DefaultPolicy holds the default value on creation for the "policy" field. DefaultPolicy string // DefaultVersionID holds the default value on creation for the "version_id" field. @@ -119,8 +163,6 @@ var ( DefaultLastSyncVersionID string // DefaultSyncStatus holds the default value on creation for the "sync_status" field. DefaultSyncStatus string - // DefaultStatus holds the default value on creation for the "status" field. - DefaultStatus enums.Status // DefaultID holds the default value on creation for the "id" field. DefaultID func() int64 // IDValidator is a validator for the "id" field. It is called by the builders before save. @@ -145,19 +187,34 @@ func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUpdateTime, opts...).ToFunc() } -// ByServiceName orders the results by the service_name field. -func ByServiceName(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldServiceName, opts...).ToFunc() -} - // ByKeyword orders the results by the keyword field. func ByKeyword(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldKeyword, opts...).ToFunc() } -// ByPath orders the results by the path field. -func ByPath(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldPath, opts...).ToFunc() +// ByName orders the results by the name field. +func ByName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldName, opts...).ToFunc() +} + +// ByI18n orders the results by the i18n field. +func ByI18n(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldI18n, opts...).ToFunc() +} + +// ByType orders the results by the type field. +func ByType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldType, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + +// BySequence orders the results by the sequence field. +func BySequence(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldSequence, opts...).ToFunc() } // ByMethod orders the results by the method field. @@ -165,11 +222,21 @@ func ByMethod(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldMethod, opts...).ToFunc() } +// ByPath orders the results by the path field. +func ByPath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldPath, opts...).ToFunc() +} + // ByOperation orders the results by the operation field. func ByOperation(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldOperation, opts...).ToFunc() } +// ByServiceName orders the results by the service_name field. +func ByServiceName(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldServiceName, opts...).ToFunc() +} + // ByPolicy orders the results by the policy field. func ByPolicy(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPolicy, opts...).ToFunc() @@ -190,9 +257,45 @@ func BySyncStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldSyncStatus, opts...).ToFunc() } -// ByStatus orders the results by the status field. -func ByStatus(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldStatus, opts...).ToFunc() +// ByTreePath orders the results by the tree_path field. +func ByTreePath(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldTreePath, opts...).ToFunc() +} + +// ByParentID orders the results by the parent_id field. +func ByParentID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldParentID, opts...).ToFunc() +} + +// ByProperties orders the results by the properties field. +func ByProperties(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldProperties, opts...).ToFunc() +} + +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByParentField orders the results by parent field. +func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newParentStep(), sql.OrderByField(field, opts...)) + } +} + +// ByChildrenCount orders the results by children count. +func ByChildrenCount(opts ...sql.OrderTermOption) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborsCount(s, newChildrenStep(), opts...) + } +} + +// ByChildren orders the results by children terms. +func ByChildren(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { + return func(s *sql.Selector) { + sqlgraph.OrderByNeighborTerms(s, newChildrenStep(), append([]sql.OrderTerm{term}, terms...)...) + } } // ByViewsCount orders the results by views count. @@ -236,6 +339,20 @@ func ByViewResources(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { sqlgraph.OrderByNeighborTerms(s, newViewResourcesStep(), append([]sql.OrderTerm{term}, terms...)...) } } +func newParentStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) +} +func newChildrenStep() *sqlgraph.Step { + return sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.To(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) +} func newViewsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), diff --git a/internal/data/entity/ent/resource/where.go b/internal/data/entity/ent/resource/where.go index 5ec2ee86..0985c143 100644 --- a/internal/data/entity/ent/resource/where.go +++ b/internal/data/entity/ent/resource/where.go @@ -66,19 +66,35 @@ func UpdateTime(v time.Time) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldUpdateTime, v)) } -// ServiceName applies equality check predicate on the "service_name" field. It's identical to ServiceNameEQ. -func ServiceName(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldServiceName, v)) -} - // Keyword applies equality check predicate on the "keyword" field. It's identical to KeywordEQ. func Keyword(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) } -// Path applies equality check predicate on the "path" field. It's identical to PathEQ. -func Path(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldPath, v)) +// Name applies equality check predicate on the "name" field. It's identical to NameEQ. +func Name(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldName, v)) +} + +// I18n applies equality check predicate on the "i18n" field. It's identical to I18nEQ. +func I18n(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldI18n, v)) +} + +// Type applies equality check predicate on the "type" field. It's identical to TypeEQ. +func Type(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldType, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldEQ(FieldStatus, vc)) +} + +// Sequence applies equality check predicate on the "sequence" field. It's identical to SequenceEQ. +func Sequence(v int) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldSequence, v)) } // Method applies equality check predicate on the "method" field. It's identical to MethodEQ. @@ -86,11 +102,21 @@ func Method(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldMethod, v)) } +// Path applies equality check predicate on the "path" field. It's identical to PathEQ. +func Path(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldPath, v)) +} + // Operation applies equality check predicate on the "operation" field. It's identical to OperationEQ. func Operation(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldOperation, v)) } +// ServiceName applies equality check predicate on the "service_name" field. It's identical to ServiceNameEQ. +func ServiceName(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldServiceName, v)) +} + // VersionID applies equality check predicate on the "version_id" field. It's identical to VersionIDEQ. func VersionID(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldVersionID, v)) @@ -106,10 +132,24 @@ func SyncStatus(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldSyncStatus, v)) } -// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. -func Status(v enums.Status) predicate.Resource { - vc := int8(v) - return predicate.Resource(sql.FieldEQ(FieldStatus, vc)) +// TreePath applies equality check predicate on the "tree_path" field. It's identical to TreePathEQ. +func TreePath(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) +} + +// ParentID applies equality check predicate on the "parent_id" field. It's identical to ParentIDEQ. +func ParentID(v int64) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldParentID, v)) +} + +// Properties applies equality check predicate on the "properties" field. It's identical to PropertiesEQ. +func Properties(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldProperties, v)) +} + +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldDescription, v)) } // CreateTimeEQ applies the EQ predicate on the "create_time" field. @@ -192,71 +232,6 @@ func UpdateTimeLTE(v time.Time) predicate.Resource { return predicate.Resource(sql.FieldLTE(FieldUpdateTime, v)) } -// ServiceNameEQ applies the EQ predicate on the "service_name" field. -func ServiceNameEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldServiceName, v)) -} - -// ServiceNameNEQ applies the NEQ predicate on the "service_name" field. -func ServiceNameNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldServiceName, v)) -} - -// ServiceNameIn applies the In predicate on the "service_name" field. -func ServiceNameIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldServiceName, vs...)) -} - -// ServiceNameNotIn applies the NotIn predicate on the "service_name" field. -func ServiceNameNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldServiceName, vs...)) -} - -// ServiceNameGT applies the GT predicate on the "service_name" field. -func ServiceNameGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldServiceName, v)) -} - -// ServiceNameGTE applies the GTE predicate on the "service_name" field. -func ServiceNameGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldServiceName, v)) -} - -// ServiceNameLT applies the LT predicate on the "service_name" field. -func ServiceNameLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldServiceName, v)) -} - -// ServiceNameLTE applies the LTE predicate on the "service_name" field. -func ServiceNameLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldServiceName, v)) -} - -// ServiceNameContains applies the Contains predicate on the "service_name" field. -func ServiceNameContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldServiceName, v)) -} - -// ServiceNameHasPrefix applies the HasPrefix predicate on the "service_name" field. -func ServiceNameHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldServiceName, v)) -} - -// ServiceNameHasSuffix applies the HasSuffix predicate on the "service_name" field. -func ServiceNameHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldServiceName, v)) -} - -// ServiceNameEqualFold applies the EqualFold predicate on the "service_name" field. -func ServiceNameEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldServiceName, v)) -} - -// ServiceNameContainsFold applies the ContainsFold predicate on the "service_name" field. -func ServiceNameContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldServiceName, v)) -} - // KeywordEQ applies the EQ predicate on the "keyword" field. func KeywordEQ(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldKeyword, v)) @@ -322,79 +297,313 @@ func KeywordContainsFold(v string) predicate.Resource { return predicate.Resource(sql.FieldContainsFold(FieldKeyword, v)) } -// PathEQ applies the EQ predicate on the "path" field. -func PathEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldEQ(FieldPath, v)) +// NameEQ applies the EQ predicate on the "name" field. +func NameEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldName, v)) } -// PathNEQ applies the NEQ predicate on the "path" field. -func PathNEQ(v string) predicate.Resource { - return predicate.Resource(sql.FieldNEQ(FieldPath, v)) +// NameNEQ applies the NEQ predicate on the "name" field. +func NameNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldName, v)) } -// PathIn applies the In predicate on the "path" field. -func PathIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldIn(FieldPath, vs...)) +// NameIn applies the In predicate on the "name" field. +func NameIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldName, vs...)) } -// PathNotIn applies the NotIn predicate on the "path" field. -func PathNotIn(vs ...string) predicate.Resource { - return predicate.Resource(sql.FieldNotIn(FieldPath, vs...)) +// NameNotIn applies the NotIn predicate on the "name" field. +func NameNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldName, vs...)) } -// PathGT applies the GT predicate on the "path" field. -func PathGT(v string) predicate.Resource { - return predicate.Resource(sql.FieldGT(FieldPath, v)) +// NameGT applies the GT predicate on the "name" field. +func NameGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldName, v)) } -// PathGTE applies the GTE predicate on the "path" field. -func PathGTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldGTE(FieldPath, v)) +// NameGTE applies the GTE predicate on the "name" field. +func NameGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldName, v)) } -// PathLT applies the LT predicate on the "path" field. -func PathLT(v string) predicate.Resource { - return predicate.Resource(sql.FieldLT(FieldPath, v)) +// NameLT applies the LT predicate on the "name" field. +func NameLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldName, v)) } -// PathLTE applies the LTE predicate on the "path" field. -func PathLTE(v string) predicate.Resource { - return predicate.Resource(sql.FieldLTE(FieldPath, v)) +// NameLTE applies the LTE predicate on the "name" field. +func NameLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldName, v)) } -// PathContains applies the Contains predicate on the "path" field. -func PathContains(v string) predicate.Resource { - return predicate.Resource(sql.FieldContains(FieldPath, v)) +// NameContains applies the Contains predicate on the "name" field. +func NameContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldName, v)) } -// PathHasPrefix applies the HasPrefix predicate on the "path" field. -func PathHasPrefix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasPrefix(FieldPath, v)) +// NameHasPrefix applies the HasPrefix predicate on the "name" field. +func NameHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldName, v)) } -// PathHasSuffix applies the HasSuffix predicate on the "path" field. -func PathHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldPath, v)) +// NameHasSuffix applies the HasSuffix predicate on the "name" field. +func NameHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldName, v)) } -// PathIsNil applies the IsNil predicate on the "path" field. -func PathIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldPath)) +// NameEqualFold applies the EqualFold predicate on the "name" field. +func NameEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldName, v)) } -// PathNotNil applies the NotNil predicate on the "path" field. -func PathNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldPath)) +// NameContainsFold applies the ContainsFold predicate on the "name" field. +func NameContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldName, v)) } -// PathEqualFold applies the EqualFold predicate on the "path" field. -func PathEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldPath, v)) +// I18nEQ applies the EQ predicate on the "i18n" field. +func I18nEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldI18n, v)) } -// PathContainsFold applies the ContainsFold predicate on the "path" field. -func PathContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldPath, v)) +// I18nNEQ applies the NEQ predicate on the "i18n" field. +func I18nNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldI18n, v)) +} + +// I18nIn applies the In predicate on the "i18n" field. +func I18nIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldI18n, vs...)) +} + +// I18nNotIn applies the NotIn predicate on the "i18n" field. +func I18nNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldI18n, vs...)) +} + +// I18nGT applies the GT predicate on the "i18n" field. +func I18nGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldI18n, v)) +} + +// I18nGTE applies the GTE predicate on the "i18n" field. +func I18nGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldI18n, v)) +} + +// I18nLT applies the LT predicate on the "i18n" field. +func I18nLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldI18n, v)) +} + +// I18nLTE applies the LTE predicate on the "i18n" field. +func I18nLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldI18n, v)) +} + +// I18nContains applies the Contains predicate on the "i18n" field. +func I18nContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldI18n, v)) +} + +// I18nHasPrefix applies the HasPrefix predicate on the "i18n" field. +func I18nHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldI18n, v)) +} + +// I18nHasSuffix applies the HasSuffix predicate on the "i18n" field. +func I18nHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldI18n, v)) +} + +// I18nIsNil applies the IsNil predicate on the "i18n" field. +func I18nIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldI18n)) +} + +// I18nNotNil applies the NotNil predicate on the "i18n" field. +func I18nNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldI18n)) +} + +// I18nEqualFold applies the EqualFold predicate on the "i18n" field. +func I18nEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldI18n, v)) +} + +// I18nContainsFold applies the ContainsFold predicate on the "i18n" field. +func I18nContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldI18n, v)) +} + +// TypeEQ applies the EQ predicate on the "type" field. +func TypeEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldType, v)) +} + +// TypeNEQ applies the NEQ predicate on the "type" field. +func TypeNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldType, v)) +} + +// TypeIn applies the In predicate on the "type" field. +func TypeIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldType, vs...)) +} + +// TypeNotIn applies the NotIn predicate on the "type" field. +func TypeNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldType, vs...)) +} + +// TypeGT applies the GT predicate on the "type" field. +func TypeGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldType, v)) +} + +// TypeGTE applies the GTE predicate on the "type" field. +func TypeGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldType, v)) +} + +// TypeLT applies the LT predicate on the "type" field. +func TypeLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldType, v)) +} + +// TypeLTE applies the LTE predicate on the "type" field. +func TypeLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldType, v)) +} + +// TypeContains applies the Contains predicate on the "type" field. +func TypeContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldType, v)) +} + +// TypeHasPrefix applies the HasPrefix predicate on the "type" field. +func TypeHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldType, v)) +} + +// TypeHasSuffix applies the HasSuffix predicate on the "type" field. +func TypeHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldType, v)) +} + +// TypeIsNil applies the IsNil predicate on the "type" field. +func TypeIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldType)) +} + +// TypeNotNil applies the NotNil predicate on the "type" field. +func TypeNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldType)) +} + +// TypeEqualFold applies the EqualFold predicate on the "type" field. +func TypeEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldType, v)) +} + +// TypeContainsFold applies the ContainsFold predicate on the "type" field. +func TypeContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldType, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldEQ(FieldStatus, vc)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldNEQ(FieldStatus, vc)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...enums.Status) predicate.Resource { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Resource(sql.FieldIn(FieldStatus, v...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...enums.Status) predicate.Resource { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.Resource(sql.FieldNotIn(FieldStatus, v...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldGT(FieldStatus, vc)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldGTE(FieldStatus, vc)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldLT(FieldStatus, vc)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v enums.Status) predicate.Resource { + vc := int8(v) + return predicate.Resource(sql.FieldLTE(FieldStatus, vc)) +} + +// SequenceEQ applies the EQ predicate on the "sequence" field. +func SequenceEQ(v int) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldSequence, v)) +} + +// SequenceNEQ applies the NEQ predicate on the "sequence" field. +func SequenceNEQ(v int) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldSequence, v)) +} + +// SequenceIn applies the In predicate on the "sequence" field. +func SequenceIn(vs ...int) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldSequence, vs...)) +} + +// SequenceNotIn applies the NotIn predicate on the "sequence" field. +func SequenceNotIn(vs ...int) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldSequence, vs...)) +} + +// SequenceGT applies the GT predicate on the "sequence" field. +func SequenceGT(v int) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldSequence, v)) +} + +// SequenceGTE applies the GTE predicate on the "sequence" field. +func SequenceGTE(v int) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldSequence, v)) +} + +// SequenceLT applies the LT predicate on the "sequence" field. +func SequenceLT(v int) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldSequence, v)) +} + +// SequenceLTE applies the LTE predicate on the "sequence" field. +func SequenceLTE(v int) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldSequence, v)) } // MethodEQ applies the EQ predicate on the "method" field. @@ -447,29 +656,104 @@ func MethodHasPrefix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasPrefix(FieldMethod, v)) } -// MethodHasSuffix applies the HasSuffix predicate on the "method" field. -func MethodHasSuffix(v string) predicate.Resource { - return predicate.Resource(sql.FieldHasSuffix(FieldMethod, v)) +// MethodHasSuffix applies the HasSuffix predicate on the "method" field. +func MethodHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldMethod, v)) +} + +// MethodIsNil applies the IsNil predicate on the "method" field. +func MethodIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldMethod)) +} + +// MethodNotNil applies the NotNil predicate on the "method" field. +func MethodNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldMethod)) +} + +// MethodEqualFold applies the EqualFold predicate on the "method" field. +func MethodEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldMethod, v)) +} + +// MethodContainsFold applies the ContainsFold predicate on the "method" field. +func MethodContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldMethod, v)) +} + +// PathEQ applies the EQ predicate on the "path" field. +func PathEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldPath, v)) +} + +// PathNEQ applies the NEQ predicate on the "path" field. +func PathNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldPath, v)) +} + +// PathIn applies the In predicate on the "path" field. +func PathIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldPath, vs...)) +} + +// PathNotIn applies the NotIn predicate on the "path" field. +func PathNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldPath, vs...)) +} + +// PathGT applies the GT predicate on the "path" field. +func PathGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldPath, v)) +} + +// PathGTE applies the GTE predicate on the "path" field. +func PathGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldPath, v)) +} + +// PathLT applies the LT predicate on the "path" field. +func PathLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldPath, v)) +} + +// PathLTE applies the LTE predicate on the "path" field. +func PathLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldPath, v)) +} + +// PathContains applies the Contains predicate on the "path" field. +func PathContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldPath, v)) +} + +// PathHasPrefix applies the HasPrefix predicate on the "path" field. +func PathHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldPath, v)) +} + +// PathHasSuffix applies the HasSuffix predicate on the "path" field. +func PathHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldPath, v)) } -// MethodIsNil applies the IsNil predicate on the "method" field. -func MethodIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldMethod)) +// PathIsNil applies the IsNil predicate on the "path" field. +func PathIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldPath)) } -// MethodNotNil applies the NotNil predicate on the "method" field. -func MethodNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldMethod)) +// PathNotNil applies the NotNil predicate on the "path" field. +func PathNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldPath)) } -// MethodEqualFold applies the EqualFold predicate on the "method" field. -func MethodEqualFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldEqualFold(FieldMethod, v)) +// PathEqualFold applies the EqualFold predicate on the "path" field. +func PathEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldPath, v)) } -// MethodContainsFold applies the ContainsFold predicate on the "method" field. -func MethodContainsFold(v string) predicate.Resource { - return predicate.Resource(sql.FieldContainsFold(FieldMethod, v)) +// PathContainsFold applies the ContainsFold predicate on the "path" field. +func PathContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldPath, v)) } // OperationEQ applies the EQ predicate on the "operation" field. @@ -547,6 +831,71 @@ func OperationContainsFold(v string) predicate.Resource { return predicate.Resource(sql.FieldContainsFold(FieldOperation, v)) } +// ServiceNameEQ applies the EQ predicate on the "service_name" field. +func ServiceNameEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldServiceName, v)) +} + +// ServiceNameNEQ applies the NEQ predicate on the "service_name" field. +func ServiceNameNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldServiceName, v)) +} + +// ServiceNameIn applies the In predicate on the "service_name" field. +func ServiceNameIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldServiceName, vs...)) +} + +// ServiceNameNotIn applies the NotIn predicate on the "service_name" field. +func ServiceNameNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldServiceName, vs...)) +} + +// ServiceNameGT applies the GT predicate on the "service_name" field. +func ServiceNameGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldServiceName, v)) +} + +// ServiceNameGTE applies the GTE predicate on the "service_name" field. +func ServiceNameGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldServiceName, v)) +} + +// ServiceNameLT applies the LT predicate on the "service_name" field. +func ServiceNameLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldServiceName, v)) +} + +// ServiceNameLTE applies the LTE predicate on the "service_name" field. +func ServiceNameLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldServiceName, v)) +} + +// ServiceNameContains applies the Contains predicate on the "service_name" field. +func ServiceNameContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldServiceName, v)) +} + +// ServiceNameHasPrefix applies the HasPrefix predicate on the "service_name" field. +func ServiceNameHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldServiceName, v)) +} + +// ServiceNameHasSuffix applies the HasSuffix predicate on the "service_name" field. +func ServiceNameHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldServiceName, v)) +} + +// ServiceNameEqualFold applies the EqualFold predicate on the "service_name" field. +func ServiceNameEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldServiceName, v)) +} + +// ServiceNameContainsFold applies the ContainsFold predicate on the "service_name" field. +func ServiceNameContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldServiceName, v)) +} + // PolicyEQ applies the EQ predicate on the "policy" field. func PolicyEQ(v string) predicate.Resource { return predicate.Resource(sql.FieldEQ(FieldPolicy, v)) @@ -807,58 +1156,305 @@ func SyncStatusContainsFold(v string) predicate.Resource { return predicate.Resource(sql.FieldContainsFold(FieldSyncStatus, v)) } -// StatusEQ applies the EQ predicate on the "status" field. -func StatusEQ(v enums.Status) predicate.Resource { - vc := int8(v) - return predicate.Resource(sql.FieldEQ(FieldStatus, vc)) +// TreePathEQ applies the EQ predicate on the "tree_path" field. +func TreePathEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldTreePath, v)) } -// StatusNEQ applies the NEQ predicate on the "status" field. -func StatusNEQ(v enums.Status) predicate.Resource { - vc := int8(v) - return predicate.Resource(sql.FieldNEQ(FieldStatus, vc)) +// TreePathNEQ applies the NEQ predicate on the "tree_path" field. +func TreePathNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldTreePath, v)) } -// StatusIn applies the In predicate on the "status" field. -func StatusIn(vs ...enums.Status) predicate.Resource { - v := make([]any, len(vs)) - for i := range v { - v[i] = int8(vs[i]) - } - return predicate.Resource(sql.FieldIn(FieldStatus, v...)) +// TreePathIn applies the In predicate on the "tree_path" field. +func TreePathIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldTreePath, vs...)) } -// StatusNotIn applies the NotIn predicate on the "status" field. -func StatusNotIn(vs ...enums.Status) predicate.Resource { - v := make([]any, len(vs)) - for i := range v { - v[i] = int8(vs[i]) - } - return predicate.Resource(sql.FieldNotIn(FieldStatus, v...)) +// TreePathNotIn applies the NotIn predicate on the "tree_path" field. +func TreePathNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldTreePath, vs...)) } -// StatusGT applies the GT predicate on the "status" field. -func StatusGT(v enums.Status) predicate.Resource { - vc := int8(v) - return predicate.Resource(sql.FieldGT(FieldStatus, vc)) +// TreePathGT applies the GT predicate on the "tree_path" field. +func TreePathGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldTreePath, v)) } -// StatusGTE applies the GTE predicate on the "status" field. -func StatusGTE(v enums.Status) predicate.Resource { - vc := int8(v) - return predicate.Resource(sql.FieldGTE(FieldStatus, vc)) +// TreePathGTE applies the GTE predicate on the "tree_path" field. +func TreePathGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldTreePath, v)) } -// StatusLT applies the LT predicate on the "status" field. -func StatusLT(v enums.Status) predicate.Resource { - vc := int8(v) - return predicate.Resource(sql.FieldLT(FieldStatus, vc)) +// TreePathLT applies the LT predicate on the "tree_path" field. +func TreePathLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldTreePath, v)) } -// StatusLTE applies the LTE predicate on the "status" field. -func StatusLTE(v enums.Status) predicate.Resource { - vc := int8(v) - return predicate.Resource(sql.FieldLTE(FieldStatus, vc)) +// TreePathLTE applies the LTE predicate on the "tree_path" field. +func TreePathLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldTreePath, v)) +} + +// TreePathContains applies the Contains predicate on the "tree_path" field. +func TreePathContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldTreePath, v)) +} + +// TreePathHasPrefix applies the HasPrefix predicate on the "tree_path" field. +func TreePathHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldTreePath, v)) +} + +// TreePathHasSuffix applies the HasSuffix predicate on the "tree_path" field. +func TreePathHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldTreePath, v)) +} + +// TreePathIsNil applies the IsNil predicate on the "tree_path" field. +func TreePathIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldTreePath)) +} + +// TreePathNotNil applies the NotNil predicate on the "tree_path" field. +func TreePathNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldTreePath)) +} + +// TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. +func TreePathEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldTreePath, v)) +} + +// TreePathContainsFold applies the ContainsFold predicate on the "tree_path" field. +func TreePathContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldTreePath, v)) +} + +// ParentIDEQ applies the EQ predicate on the "parent_id" field. +func ParentIDEQ(v int64) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldParentID, v)) +} + +// ParentIDNEQ applies the NEQ predicate on the "parent_id" field. +func ParentIDNEQ(v int64) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldParentID, v)) +} + +// ParentIDIn applies the In predicate on the "parent_id" field. +func ParentIDIn(vs ...int64) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldParentID, vs...)) +} + +// ParentIDNotIn applies the NotIn predicate on the "parent_id" field. +func ParentIDNotIn(vs ...int64) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldParentID, vs...)) +} + +// ParentIDIsNil applies the IsNil predicate on the "parent_id" field. +func ParentIDIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldParentID)) +} + +// ParentIDNotNil applies the NotNil predicate on the "parent_id" field. +func ParentIDNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldParentID)) +} + +// PropertiesEQ applies the EQ predicate on the "properties" field. +func PropertiesEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldProperties, v)) +} + +// PropertiesNEQ applies the NEQ predicate on the "properties" field. +func PropertiesNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldProperties, v)) +} + +// PropertiesIn applies the In predicate on the "properties" field. +func PropertiesIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldProperties, vs...)) +} + +// PropertiesNotIn applies the NotIn predicate on the "properties" field. +func PropertiesNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldProperties, vs...)) +} + +// PropertiesGT applies the GT predicate on the "properties" field. +func PropertiesGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldProperties, v)) +} + +// PropertiesGTE applies the GTE predicate on the "properties" field. +func PropertiesGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldProperties, v)) +} + +// PropertiesLT applies the LT predicate on the "properties" field. +func PropertiesLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldProperties, v)) +} + +// PropertiesLTE applies the LTE predicate on the "properties" field. +func PropertiesLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldProperties, v)) +} + +// PropertiesContains applies the Contains predicate on the "properties" field. +func PropertiesContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldProperties, v)) +} + +// PropertiesHasPrefix applies the HasPrefix predicate on the "properties" field. +func PropertiesHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldProperties, v)) +} + +// PropertiesHasSuffix applies the HasSuffix predicate on the "properties" field. +func PropertiesHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldProperties, v)) +} + +// PropertiesIsNil applies the IsNil predicate on the "properties" field. +func PropertiesIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldProperties)) +} + +// PropertiesNotNil applies the NotNil predicate on the "properties" field. +func PropertiesNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldProperties)) +} + +// PropertiesEqualFold applies the EqualFold predicate on the "properties" field. +func PropertiesEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldProperties, v)) +} + +// PropertiesContainsFold applies the ContainsFold predicate on the "properties" field. +func PropertiesContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldProperties, v)) +} + +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.Resource { + return predicate.Resource(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.Resource { + return predicate.Resource(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.Resource { + return predicate.Resource(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.Resource { + return predicate.Resource(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.Resource { + return predicate.Resource(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.Resource { + return predicate.Resource(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.Resource { + return predicate.Resource(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.Resource { + return predicate.Resource(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.Resource { + return predicate.Resource(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.Resource { + return predicate.Resource(sql.FieldContainsFold(FieldDescription, v)) +} + +// HasParent applies the HasEdge predicate on the "parent" edge. +func HasParent() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, ParentTable, ParentColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasParentWith applies the HasEdge predicate on the "parent" edge with a given conditions (other predicates). +func HasParentWith(preds ...predicate.Resource) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newParentStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) +} + +// HasChildren applies the HasEdge predicate on the "children" edge. +func HasChildren() predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := sqlgraph.NewStep( + sqlgraph.From(Table, FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, ChildrenTable, ChildrenColumn), + ) + sqlgraph.HasNeighbors(s, step) + }) +} + +// HasChildrenWith applies the HasEdge predicate on the "children" edge with a given conditions (other predicates). +func HasChildrenWith(preds ...predicate.Resource) predicate.Resource { + return predicate.Resource(func(s *sql.Selector) { + step := newChildrenStep() + sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { + for _, p := range preds { + p(s) + } + }) + }) } // HasViews applies the HasEdge predicate on the "views" edge. diff --git a/internal/data/entity/ent/resource_create.go b/internal/data/entity/ent/resource_create.go index 3f6b1b71..59a82339 100644 --- a/internal/data/entity/ent/resource_create.go +++ b/internal/data/entity/ent/resource_create.go @@ -52,28 +52,78 @@ func (_c *ResourceCreate) SetNillableUpdateTime(v *time.Time) *ResourceCreate { return _c } -// SetServiceName sets the "service_name" field. -func (_c *ResourceCreate) SetServiceName(v string) *ResourceCreate { - _c.mutation.SetServiceName(v) - return _c -} - // SetKeyword sets the "keyword" field. func (_c *ResourceCreate) SetKeyword(v string) *ResourceCreate { _c.mutation.SetKeyword(v) return _c } -// SetPath sets the "path" field. -func (_c *ResourceCreate) SetPath(v string) *ResourceCreate { - _c.mutation.SetPath(v) +// SetName sets the "name" field. +func (_c *ResourceCreate) SetName(v string) *ResourceCreate { + _c.mutation.SetName(v) return _c } -// SetNillablePath sets the "path" field if the given value is not nil. -func (_c *ResourceCreate) SetNillablePath(v *string) *ResourceCreate { +// SetNillableName sets the "name" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableName(v *string) *ResourceCreate { if v != nil { - _c.SetPath(*v) + _c.SetName(*v) + } + return _c +} + +// SetI18n sets the "i18n" field. +func (_c *ResourceCreate) SetI18n(v string) *ResourceCreate { + _c.mutation.SetI18n(v) + return _c +} + +// SetNillableI18n sets the "i18n" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableI18n(v *string) *ResourceCreate { + if v != nil { + _c.SetI18n(*v) + } + return _c +} + +// SetType sets the "type" field. +func (_c *ResourceCreate) SetType(v string) *ResourceCreate { + _c.mutation.SetType(v) + return _c +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableType(v *string) *ResourceCreate { + if v != nil { + _c.SetType(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *ResourceCreate) SetStatus(v enums.Status) *ResourceCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableStatus(v *enums.Status) *ResourceCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + +// SetSequence sets the "sequence" field. +func (_c *ResourceCreate) SetSequence(v int) *ResourceCreate { + _c.mutation.SetSequence(v) + return _c +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableSequence(v *int) *ResourceCreate { + if v != nil { + _c.SetSequence(*v) } return _c } @@ -92,6 +142,20 @@ func (_c *ResourceCreate) SetNillableMethod(v *string) *ResourceCreate { return _c } +// SetPath sets the "path" field. +func (_c *ResourceCreate) SetPath(v string) *ResourceCreate { + _c.mutation.SetPath(v) + return _c +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (_c *ResourceCreate) SetNillablePath(v *string) *ResourceCreate { + if v != nil { + _c.SetPath(*v) + } + return _c +} + // SetOperation sets the "operation" field. func (_c *ResourceCreate) SetOperation(v string) *ResourceCreate { _c.mutation.SetOperation(v) @@ -106,6 +170,20 @@ func (_c *ResourceCreate) SetNillableOperation(v *string) *ResourceCreate { return _c } +// SetServiceName sets the "service_name" field. +func (_c *ResourceCreate) SetServiceName(v string) *ResourceCreate { + _c.mutation.SetServiceName(v) + return _c +} + +// SetNillableServiceName sets the "service_name" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableServiceName(v *string) *ResourceCreate { + if v != nil { + _c.SetServiceName(*v) + } + return _c +} + // SetPolicy sets the "policy" field. func (_c *ResourceCreate) SetPolicy(v string) *ResourceCreate { _c.mutation.SetPolicy(v) @@ -162,16 +240,58 @@ func (_c *ResourceCreate) SetNillableSyncStatus(v *string) *ResourceCreate { return _c } -// SetStatus sets the "status" field. -func (_c *ResourceCreate) SetStatus(v enums.Status) *ResourceCreate { - _c.mutation.SetStatus(v) +// SetTreePath sets the "tree_path" field. +func (_c *ResourceCreate) SetTreePath(v string) *ResourceCreate { + _c.mutation.SetTreePath(v) return _c } -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_c *ResourceCreate) SetNillableStatus(v *enums.Status) *ResourceCreate { +// SetNillableTreePath sets the "tree_path" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableTreePath(v *string) *ResourceCreate { if v != nil { - _c.SetStatus(*v) + _c.SetTreePath(*v) + } + return _c +} + +// SetParentID sets the "parent_id" field. +func (_c *ResourceCreate) SetParentID(v int64) *ResourceCreate { + _c.mutation.SetParentID(v) + return _c +} + +// SetNillableParentID sets the "parent_id" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableParentID(v *int64) *ResourceCreate { + if v != nil { + _c.SetParentID(*v) + } + return _c +} + +// SetProperties sets the "properties" field. +func (_c *ResourceCreate) SetProperties(v string) *ResourceCreate { + _c.mutation.SetProperties(v) + return _c +} + +// SetNillableProperties sets the "properties" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableProperties(v *string) *ResourceCreate { + if v != nil { + _c.SetProperties(*v) + } + return _c +} + +// SetDescription sets the "description" field. +func (_c *ResourceCreate) SetDescription(v string) *ResourceCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *ResourceCreate) SetNillableDescription(v *string) *ResourceCreate { + if v != nil { + _c.SetDescription(*v) } return _c } @@ -190,6 +310,26 @@ func (_c *ResourceCreate) SetNillableID(v *int64) *ResourceCreate { return _c } +// SetParent sets the "parent" edge to the Resource entity. +func (_c *ResourceCreate) SetParent(v *Resource) *ResourceCreate { + return _c.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Resource entity by IDs. +func (_c *ResourceCreate) AddChildIDs(ids ...int64) *ResourceCreate { + _c.mutation.AddChildIDs(ids...) + return _c +} + +// AddChildren adds the "children" edges to the Resource entity. +func (_c *ResourceCreate) AddChildren(v ...*Resource) *ResourceCreate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _c.AddChildIDs(ids...) +} + // AddViewIDs adds the "views" edge to the View entity by IDs. func (_c *ResourceCreate) AddViewIDs(ids ...int64) *ResourceCreate { _c.mutation.AddViewIDs(ids...) @@ -278,6 +418,22 @@ func (_c *ResourceCreate) defaults() { v := resource.DefaultUpdateTime() _c.mutation.SetUpdateTime(v) } + if _, ok := _c.mutation.Name(); !ok { + v := resource.DefaultName + _c.mutation.SetName(v) + } + if _, ok := _c.mutation.Status(); !ok { + v := resource.DefaultStatus + _c.mutation.SetStatus(v) + } + if _, ok := _c.mutation.Sequence(); !ok { + v := resource.DefaultSequence + _c.mutation.SetSequence(v) + } + if _, ok := _c.mutation.ServiceName(); !ok { + v := resource.DefaultServiceName + _c.mutation.SetServiceName(v) + } if _, ok := _c.mutation.Policy(); !ok { v := resource.DefaultPolicy _c.mutation.SetPolicy(v) @@ -294,10 +450,6 @@ func (_c *ResourceCreate) defaults() { v := resource.DefaultSyncStatus _c.mutation.SetSyncStatus(v) } - if _, ok := _c.mutation.Status(); !ok { - v := resource.DefaultStatus - _c.mutation.SetStatus(v) - } if _, ok := _c.mutation.ID(); !ok { v := resource.DefaultID() _c.mutation.SetID(v) @@ -312,9 +464,6 @@ func (_c *ResourceCreate) check() error { if _, ok := _c.mutation.UpdateTime(); !ok { return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "Resource.update_time"`)} } - if _, ok := _c.mutation.ServiceName(); !ok { - return &ValidationError{Name: "service_name", err: errors.New(`ent: missing required field "Resource.service_name"`)} - } if _, ok := _c.mutation.Keyword(); !ok { return &ValidationError{Name: "keyword", err: errors.New(`ent: missing required field "Resource.keyword"`)} } @@ -323,6 +472,18 @@ func (_c *ResourceCreate) check() error { return &ValidationError{Name: "keyword", err: fmt.Errorf(`ent: validator failed for field "Resource.keyword": %w`, err)} } } + if _, ok := _c.mutation.Name(); !ok { + return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Resource.name"`)} + } + if _, ok := _c.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Resource.status"`)} + } + if _, ok := _c.mutation.Sequence(); !ok { + return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "Resource.sequence"`)} + } + if _, ok := _c.mutation.ServiceName(); !ok { + return &ValidationError{Name: "service_name", err: errors.New(`ent: missing required field "Resource.service_name"`)} + } if _, ok := _c.mutation.Policy(); !ok { return &ValidationError{Name: "policy", err: errors.New(`ent: missing required field "Resource.policy"`)} } @@ -335,9 +496,6 @@ func (_c *ResourceCreate) check() error { if _, ok := _c.mutation.SyncStatus(); !ok { return &ValidationError{Name: "sync_status", err: errors.New(`ent: missing required field "Resource.sync_status"`)} } - if _, ok := _c.mutation.Status(); !ok { - return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Resource.status"`)} - } if v, ok := _c.mutation.ID(); ok { if err := resource.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Resource.id": %w`, err)} @@ -383,26 +541,46 @@ func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) _node.UpdateTime = value } - if value, ok := _c.mutation.ServiceName(); ok { - _spec.SetField(resource.FieldServiceName, field.TypeString, value) - _node.ServiceName = value - } if value, ok := _c.mutation.Keyword(); ok { _spec.SetField(resource.FieldKeyword, field.TypeString, value) _node.Keyword = value } - if value, ok := _c.mutation.Path(); ok { - _spec.SetField(resource.FieldPath, field.TypeString, value) - _node.Path = value + if value, ok := _c.mutation.Name(); ok { + _spec.SetField(resource.FieldName, field.TypeString, value) + _node.Name = value + } + if value, ok := _c.mutation.I18n(); ok { + _spec.SetField(resource.FieldI18n, field.TypeString, value) + _node.I18n = value + } + if value, ok := _c.mutation.GetType(); ok { + _spec.SetField(resource.FieldType, field.TypeString, value) + _node.Type = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(resource.FieldStatus, field.TypeInt8, value) + _node.Status = value + } + if value, ok := _c.mutation.Sequence(); ok { + _spec.SetField(resource.FieldSequence, field.TypeInt, value) + _node.Sequence = value } if value, ok := _c.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) _node.Method = value } + if value, ok := _c.mutation.Path(); ok { + _spec.SetField(resource.FieldPath, field.TypeString, value) + _node.Path = value + } if value, ok := _c.mutation.Operation(); ok { _spec.SetField(resource.FieldOperation, field.TypeString, value) _node.Operation = value } + if value, ok := _c.mutation.ServiceName(); ok { + _spec.SetField(resource.FieldServiceName, field.TypeString, value) + _node.ServiceName = value + } if value, ok := _c.mutation.Policy(); ok { _spec.SetField(resource.FieldPolicy, field.TypeString, value) _node.Policy = value @@ -419,9 +597,50 @@ func (_c *ResourceCreate) createSpec() (*Resource, *sqlgraph.CreateSpec) { _spec.SetField(resource.FieldSyncStatus, field.TypeString, value) _node.SyncStatus = value } - if value, ok := _c.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeInt8, value) - _node.Status = value + if value, ok := _c.mutation.TreePath(); ok { + _spec.SetField(resource.FieldTreePath, field.TypeString, value) + _node.TreePath = value + } + if value, ok := _c.mutation.Properties(); ok { + _spec.SetField(resource.FieldProperties, field.TypeString, value) + _node.Properties = value + } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(resource.FieldDescription, field.TypeString, value) + _node.Description = value + } + if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: resource.ParentTable, + Columns: []string{resource.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _node.ParentID = nodes[0] + _spec.Edges = append(_spec.Edges, edge) + } + if nodes := _c.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges = append(_spec.Edges, edge) } if nodes := _c.mutation.ViewsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ diff --git a/internal/data/entity/ent/resource_query.go b/internal/data/entity/ent/resource_query.go index 5d5a3840..14b49d80 100644 --- a/internal/data/entity/ent/resource_query.go +++ b/internal/data/entity/ent/resource_query.go @@ -27,6 +27,8 @@ type ResourceQuery struct { order []resource.OrderOption inters []Interceptor predicates []predicate.Resource + withParent *ResourceQuery + withChildren *ResourceQuery withViews *ViewQuery withPermissions *PermissionQuery withViewResources *ViewResourceQuery @@ -67,6 +69,50 @@ func (_q *ResourceQuery) Order(o ...resource.OrderOption) *ResourceQuery { return _q } +// QueryParent chains the current query on the "parent" edge. +func (_q *ResourceQuery) QueryParent() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, selector), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.M2O, true, resource.ParentTable, resource.ParentColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + +// QueryChildren chains the current query on the "children" edge. +func (_q *ResourceQuery) QueryChildren() *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { + if err := _q.prepareQuery(ctx); err != nil { + return nil, err + } + selector := _q.sqlQuery(ctx) + if err := selector.Err(); err != nil { + return nil, err + } + step := sqlgraph.NewStep( + sqlgraph.From(resource.Table, resource.FieldID, selector), + sqlgraph.To(resource.Table, resource.FieldID), + sqlgraph.Edge(sqlgraph.O2M, false, resource.ChildrenTable, resource.ChildrenColumn), + ) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) + return fromU, nil + } + return query +} + // QueryViews chains the current query on the "views" edge. func (_q *ResourceQuery) QueryViews() *ViewQuery { query := (&ViewClient{config: _q.config}).Query() @@ -325,6 +371,8 @@ func (_q *ResourceQuery) Clone() *ResourceQuery { order: append([]resource.OrderOption{}, _q.order...), inters: append([]Interceptor{}, _q.inters...), predicates: append([]predicate.Resource{}, _q.predicates...), + withParent: _q.withParent.Clone(), + withChildren: _q.withChildren.Clone(), withViews: _q.withViews.Clone(), withPermissions: _q.withPermissions.Clone(), withViewResources: _q.withViewResources.Clone(), @@ -335,6 +383,28 @@ func (_q *ResourceQuery) Clone() *ResourceQuery { } } +// WithParent tells the query-builder to eager-load the nodes that are connected to +// the "parent" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ResourceQuery) WithParent(opts ...func(*ResourceQuery)) *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withParent = query + return _q +} + +// WithChildren tells the query-builder to eager-load the nodes that are connected to +// the "children" edge. The optional arguments are used to configure the query builder of the edge. +func (_q *ResourceQuery) WithChildren(opts ...func(*ResourceQuery)) *ResourceQuery { + query := (&ResourceClient{config: _q.config}).Query() + for _, opt := range opts { + opt(query) + } + _q.withChildren = query + return _q +} + // WithViews tells the query-builder to eager-load the nodes that are connected to // the "views" edge. The optional arguments are used to configure the query builder of the edge. func (_q *ResourceQuery) WithViews(opts ...func(*ViewQuery)) *ResourceQuery { @@ -446,7 +516,9 @@ func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Res var ( nodes = []*Resource{} _spec = _q.querySpec() - loadedTypes = [3]bool{ + loadedTypes = [5]bool{ + _q.withParent != nil, + _q.withChildren != nil, _q.withViews != nil, _q.withPermissions != nil, _q.withViewResources != nil, @@ -473,6 +545,19 @@ func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Res if len(nodes) == 0 { return nodes, nil } + if query := _q.withParent; query != nil { + if err := _q.loadParent(ctx, query, nodes, nil, + func(n *Resource, e *Resource) { n.Edges.Parent = e }); err != nil { + return nil, err + } + } + if query := _q.withChildren; query != nil { + if err := _q.loadChildren(ctx, query, nodes, + func(n *Resource) { n.Edges.Children = []*Resource{} }, + func(n *Resource, e *Resource) { n.Edges.Children = append(n.Edges.Children, e) }); err != nil { + return nil, err + } + } if query := _q.withViews; query != nil { if err := _q.loadViews(ctx, query, nodes, func(n *Resource) { n.Edges.Views = []*View{} }, @@ -497,6 +582,65 @@ func (_q *ResourceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Res return nodes, nil } +func (_q *ResourceQuery) loadParent(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { + ids := make([]int64, 0, len(nodes)) + nodeids := make(map[int64][]*Resource) + for i := range nodes { + fk := nodes[i].ParentID + if _, ok := nodeids[fk]; !ok { + ids = append(ids, fk) + } + nodeids[fk] = append(nodeids[fk], nodes[i]) + } + if len(ids) == 0 { + return nil + } + query.Where(resource.IDIn(ids...)) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + nodes, ok := nodeids[n.ID] + if !ok { + return fmt.Errorf(`unexpected foreign-key "parent_id" returned %v`, n.ID) + } + for i := range nodes { + assign(nodes[i], n) + } + } + return nil +} +func (_q *ResourceQuery) loadChildren(ctx context.Context, query *ResourceQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *Resource)) error { + fks := make([]driver.Value, 0, len(nodes)) + nodeids := make(map[int64]*Resource) + for i := range nodes { + fks = append(fks, nodes[i].ID) + nodeids[nodes[i].ID] = nodes[i] + if init != nil { + init(nodes[i]) + } + } + if len(query.ctx.Fields) > 0 { + query.ctx.AppendFieldOnce(resource.FieldParentID) + } + query.Where(predicate.Resource(func(s *sql.Selector) { + s.Where(sql.InValues(s.C(resource.ChildrenColumn), fks...)) + })) + neighbors, err := query.All(ctx) + if err != nil { + return err + } + for _, n := range neighbors { + fk := n.ParentID + node, ok := nodeids[fk] + if !ok { + return fmt.Errorf(`unexpected referenced foreign-key "parent_id" returned %v for node %v`, fk, n.ID) + } + assign(node, n) + } + return nil +} func (_q *ResourceQuery) loadViews(ctx context.Context, query *ViewQuery, nodes []*Resource, init func(*Resource), assign func(*Resource, *View)) error { edgeIDs := make([]driver.Value, len(nodes)) byID := make(map[int64]*Resource) @@ -678,6 +822,9 @@ func (_q *ResourceQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } + if _q.withParent != nil { + _spec.Node.AddColumnOnce(resource.FieldParentID) + } } if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { @@ -776,32 +923,48 @@ func (_q *ResourceQuery) Modify(modifiers ...func(s *sql.Selector)) *ResourceSel // var v []struct { // CreateTime time.Time `json:"create_time,omitempty"` // UpdateTime time.Time `json:"update_time,omitempty"` -// ServiceName string `json:"service_name,omitempty"` // Keyword string `json:"keyword,omitempty"` -// Path string `json:"path,omitempty"` +// Name string `json:"name,omitempty"` +// I18n string `json:"i18n,omitempty"` +// Type string `json:"type,omitempty"` +// Status enums.Status `json:"status,omitempty"` +// Sequence int `json:"sequence,omitempty"` // Method string `json:"method,omitempty"` +// Path string `json:"path,omitempty"` // Operation string `json:"operation,omitempty"` +// ServiceName string `json:"service_name,omitempty"` // Policy string `json:"policy,omitempty"` // VersionID string `json:"version_id,omitempty"` // LastSyncVersionID string `json:"last_sync_version_id,omitempty"` // SyncStatus string `json:"sync_status,omitempty"` -// Status enums.Status `json:"status,omitempty"` +// TreePath string `json:"tree_path,omitempty"` +// ParentID int64 `json:"parent_id,omitempty"` +// Properties string `json:"properties,omitempty"` +// Description string `json:"description,omitempty"` // } // // client.Resource.Query(). // Omit( // resource.FieldCreateTime, // resource.FieldUpdateTime, -// resource.FieldServiceName, // resource.FieldKeyword, -// resource.FieldPath, +// resource.FieldName, +// resource.FieldI18n, +// resource.FieldType, +// resource.FieldStatus, +// resource.FieldSequence, // resource.FieldMethod, +// resource.FieldPath, // resource.FieldOperation, +// resource.FieldServiceName, // resource.FieldPolicy, // resource.FieldVersionID, // resource.FieldLastSyncVersionID, // resource.FieldSyncStatus, -// resource.FieldStatus, +// resource.FieldTreePath, +// resource.FieldParentID, +// resource.FieldProperties, +// resource.FieldDescription, // ). // Scan(ctx, &v) func (rq *ResourceQuery) Omit(fields ...string) *ResourceSelect { diff --git a/internal/data/entity/ent/resource_update.go b/internal/data/entity/ent/resource_update.go index a7215054..755c663f 100644 --- a/internal/data/entity/ent/resource_update.go +++ b/internal/data/entity/ent/resource_update.go @@ -39,51 +39,113 @@ func (_u *ResourceUpdate) SetUpdateTime(v time.Time) *ResourceUpdate { return _u } -// SetServiceName sets the "service_name" field. -func (_u *ResourceUpdate) SetServiceName(v string) *ResourceUpdate { - _u.mutation.SetServiceName(v) +// SetKeyword sets the "keyword" field. +func (_u *ResourceUpdate) SetKeyword(v string) *ResourceUpdate { + _u.mutation.SetKeyword(v) return _u } -// SetNillableServiceName sets the "service_name" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableServiceName(v *string) *ResourceUpdate { +// SetNillableKeyword sets the "keyword" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableKeyword(v *string) *ResourceUpdate { if v != nil { - _u.SetServiceName(*v) + _u.SetKeyword(*v) } return _u } -// SetKeyword sets the "keyword" field. -func (_u *ResourceUpdate) SetKeyword(v string) *ResourceUpdate { - _u.mutation.SetKeyword(v) +// SetName sets the "name" field. +func (_u *ResourceUpdate) SetName(v string) *ResourceUpdate { + _u.mutation.SetName(v) return _u } -// SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableKeyword(v *string) *ResourceUpdate { +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableName(v *string) *ResourceUpdate { if v != nil { - _u.SetKeyword(*v) + _u.SetName(*v) } return _u } -// SetPath sets the "path" field. -func (_u *ResourceUpdate) SetPath(v string) *ResourceUpdate { - _u.mutation.SetPath(v) +// SetI18n sets the "i18n" field. +func (_u *ResourceUpdate) SetI18n(v string) *ResourceUpdate { + _u.mutation.SetI18n(v) return _u } -// SetNillablePath sets the "path" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillablePath(v *string) *ResourceUpdate { +// SetNillableI18n sets the "i18n" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableI18n(v *string) *ResourceUpdate { if v != nil { - _u.SetPath(*v) + _u.SetI18n(*v) } return _u } -// ClearPath clears the value of the "path" field. -func (_u *ResourceUpdate) ClearPath() *ResourceUpdate { - _u.mutation.ClearPath() +// ClearI18n clears the value of the "i18n" field. +func (_u *ResourceUpdate) ClearI18n() *ResourceUpdate { + _u.mutation.ClearI18n() + return _u +} + +// SetType sets the "type" field. +func (_u *ResourceUpdate) SetType(v string) *ResourceUpdate { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableType(v *string) *ResourceUpdate { + if v != nil { + _u.SetType(*v) + } + return _u +} + +// ClearType clears the value of the "type" field. +func (_u *ResourceUpdate) ClearType() *ResourceUpdate { + _u.mutation.ClearType() + return _u +} + +// SetStatus sets the "status" field. +func (_u *ResourceUpdate) SetStatus(v enums.Status) *ResourceUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableStatus(v *enums.Status) *ResourceUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *ResourceUpdate) AddStatus(v enums.Status) *ResourceUpdate { + _u.mutation.AddStatus(v) + return _u +} + +// SetSequence sets the "sequence" field. +func (_u *ResourceUpdate) SetSequence(v int) *ResourceUpdate { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableSequence(v *int) *ResourceUpdate { + if v != nil { + _u.SetSequence(*v) + } + return _u +} + +// AddSequence adds value to the "sequence" field. +func (_u *ResourceUpdate) AddSequence(v int) *ResourceUpdate { + _u.mutation.AddSequence(v) return _u } @@ -107,6 +169,26 @@ func (_u *ResourceUpdate) ClearMethod() *ResourceUpdate { return _u } +// SetPath sets the "path" field. +func (_u *ResourceUpdate) SetPath(v string) *ResourceUpdate { + _u.mutation.SetPath(v) + return _u +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillablePath(v *string) *ResourceUpdate { + if v != nil { + _u.SetPath(*v) + } + return _u +} + +// ClearPath clears the value of the "path" field. +func (_u *ResourceUpdate) ClearPath() *ResourceUpdate { + _u.mutation.ClearPath() + return _u +} + // SetOperation sets the "operation" field. func (_u *ResourceUpdate) SetOperation(v string) *ResourceUpdate { _u.mutation.SetOperation(v) @@ -127,6 +209,20 @@ func (_u *ResourceUpdate) ClearOperation() *ResourceUpdate { return _u } +// SetServiceName sets the "service_name" field. +func (_u *ResourceUpdate) SetServiceName(v string) *ResourceUpdate { + _u.mutation.SetServiceName(v) + return _u +} + +// SetNillableServiceName sets the "service_name" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableServiceName(v *string) *ResourceUpdate { + if v != nil { + _u.SetServiceName(*v) + } + return _u +} + // SetPolicy sets the "policy" field. func (_u *ResourceUpdate) SetPolicy(v string) *ResourceUpdate { _u.mutation.SetPolicy(v) @@ -183,27 +279,106 @@ func (_u *ResourceUpdate) SetNillableSyncStatus(v *string) *ResourceUpdate { return _u } -// SetStatus sets the "status" field. -func (_u *ResourceUpdate) SetStatus(v enums.Status) *ResourceUpdate { - _u.mutation.ResetStatus() - _u.mutation.SetStatus(v) +// SetTreePath sets the "tree_path" field. +func (_u *ResourceUpdate) SetTreePath(v string) *ResourceUpdate { + _u.mutation.SetTreePath(v) return _u } -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *ResourceUpdate) SetNillableStatus(v *enums.Status) *ResourceUpdate { +// SetNillableTreePath sets the "tree_path" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableTreePath(v *string) *ResourceUpdate { if v != nil { - _u.SetStatus(*v) + _u.SetTreePath(*v) } return _u } -// AddStatus adds value to the "status" field. -func (_u *ResourceUpdate) AddStatus(v enums.Status) *ResourceUpdate { - _u.mutation.AddStatus(v) +// ClearTreePath clears the value of the "tree_path" field. +func (_u *ResourceUpdate) ClearTreePath() *ResourceUpdate { + _u.mutation.ClearTreePath() + return _u +} + +// SetParentID sets the "parent_id" field. +func (_u *ResourceUpdate) SetParentID(v int64) *ResourceUpdate { + _u.mutation.SetParentID(v) + return _u +} + +// SetNillableParentID sets the "parent_id" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableParentID(v *int64) *ResourceUpdate { + if v != nil { + _u.SetParentID(*v) + } + return _u +} + +// ClearParentID clears the value of the "parent_id" field. +func (_u *ResourceUpdate) ClearParentID() *ResourceUpdate { + _u.mutation.ClearParentID() + return _u +} + +// SetProperties sets the "properties" field. +func (_u *ResourceUpdate) SetProperties(v string) *ResourceUpdate { + _u.mutation.SetProperties(v) + return _u +} + +// SetNillableProperties sets the "properties" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableProperties(v *string) *ResourceUpdate { + if v != nil { + _u.SetProperties(*v) + } + return _u +} + +// ClearProperties clears the value of the "properties" field. +func (_u *ResourceUpdate) ClearProperties() *ResourceUpdate { + _u.mutation.ClearProperties() + return _u +} + +// SetDescription sets the "description" field. +func (_u *ResourceUpdate) SetDescription(v string) *ResourceUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ResourceUpdate) SetNillableDescription(v *string) *ResourceUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *ResourceUpdate) ClearDescription() *ResourceUpdate { + _u.mutation.ClearDescription() + return _u +} + +// SetParent sets the "parent" edge to the Resource entity. +func (_u *ResourceUpdate) SetParent(v *Resource) *ResourceUpdate { + return _u.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Resource entity by IDs. +func (_u *ResourceUpdate) AddChildIDs(ids ...int64) *ResourceUpdate { + _u.mutation.AddChildIDs(ids...) return _u } +// AddChildren adds the "children" edges to the Resource entity. +func (_u *ResourceUpdate) AddChildren(v ...*Resource) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChildIDs(ids...) +} + // AddViewIDs adds the "views" edge to the View entity by IDs. func (_u *ResourceUpdate) AddViewIDs(ids ...int64) *ResourceUpdate { _u.mutation.AddViewIDs(ids...) @@ -254,6 +429,33 @@ func (_u *ResourceUpdate) Mutation() *ResourceMutation { return _u.mutation } +// ClearParent clears the "parent" edge to the Resource entity. +func (_u *ResourceUpdate) ClearParent() *ResourceUpdate { + _u.mutation.ClearParent() + return _u +} + +// ClearChildren clears all "children" edges to the Resource entity. +func (_u *ResourceUpdate) ClearChildren() *ResourceUpdate { + _u.mutation.ClearChildren() + return _u +} + +// RemoveChildIDs removes the "children" edge to Resource entities by IDs. +func (_u *ResourceUpdate) RemoveChildIDs(ids ...int64) *ResourceUpdate { + _u.mutation.RemoveChildIDs(ids...) + return _u +} + +// RemoveChildren removes "children" edges to Resource entities. +func (_u *ResourceUpdate) RemoveChildren(v ...*Resource) *ResourceUpdate { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChildIDs(ids...) +} + // ClearViews clears all "views" edges to the View entity. func (_u *ResourceUpdate) ClearViews() *ResourceUpdate { _u.mutation.ClearViews() @@ -384,17 +586,35 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) } - if value, ok := _u.mutation.ServiceName(); ok { - _spec.SetField(resource.FieldServiceName, field.TypeString, value) - } if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(resource.FieldKeyword, field.TypeString, value) } - if value, ok := _u.mutation.Path(); ok { - _spec.SetField(resource.FieldPath, field.TypeString, value) + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(resource.FieldName, field.TypeString, value) } - if _u.mutation.PathCleared() { - _spec.ClearField(resource.FieldPath, field.TypeString) + if value, ok := _u.mutation.I18n(); ok { + _spec.SetField(resource.FieldI18n, field.TypeString, value) + } + if _u.mutation.I18nCleared() { + _spec.ClearField(resource.FieldI18n, field.TypeString) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(resource.FieldType, field.TypeString, value) + } + if _u.mutation.TypeCleared() { + _spec.ClearField(resource.FieldType, field.TypeString) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(resource.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(resource.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.Sequence(); ok { + _spec.SetField(resource.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSequence(); ok { + _spec.AddField(resource.FieldSequence, field.TypeInt, value) } if value, ok := _u.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) @@ -402,12 +622,21 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { if _u.mutation.MethodCleared() { _spec.ClearField(resource.FieldMethod, field.TypeString) } + if value, ok := _u.mutation.Path(); ok { + _spec.SetField(resource.FieldPath, field.TypeString, value) + } + if _u.mutation.PathCleared() { + _spec.ClearField(resource.FieldPath, field.TypeString) + } if value, ok := _u.mutation.Operation(); ok { _spec.SetField(resource.FieldOperation, field.TypeString, value) } if _u.mutation.OperationCleared() { _spec.ClearField(resource.FieldOperation, field.TypeString) } + if value, ok := _u.mutation.ServiceName(); ok { + _spec.SetField(resource.FieldServiceName, field.TypeString, value) + } if value, ok := _u.mutation.Policy(); ok { _spec.SetField(resource.FieldPolicy, field.TypeString, value) } @@ -420,11 +649,97 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.SyncStatus(); ok { _spec.SetField(resource.FieldSyncStatus, field.TypeString, value) } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeInt8, value) + if value, ok := _u.mutation.TreePath(); ok { + _spec.SetField(resource.FieldTreePath, field.TypeString, value) } - if value, ok := _u.mutation.AddedStatus(); ok { - _spec.AddField(resource.FieldStatus, field.TypeInt8, value) + if _u.mutation.TreePathCleared() { + _spec.ClearField(resource.FieldTreePath, field.TypeString) + } + if value, ok := _u.mutation.Properties(); ok { + _spec.SetField(resource.FieldProperties, field.TypeString, value) + } + if _u.mutation.PropertiesCleared() { + _spec.ClearField(resource.FieldProperties, field.TypeString) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(resource.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(resource.FieldDescription, field.TypeString) + } + if _u.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: resource.ParentTable, + Columns: []string{resource.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: resource.ParentTable, + Columns: []string{resource.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ @@ -591,70 +906,132 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { } return 0, err } - _u.mutation.done = true - return _node, nil + _u.mutation.done = true + return _node, nil +} + +// ResourceUpdateOne is the builder for updating a single Resource entity. +type ResourceUpdateOne struct { + config + fields []string + hooks []Hook + mutation *ResourceMutation + modifiers []func(*sql.UpdateBuilder) +} + +// SetUpdateTime sets the "update_time" field. +func (_u *ResourceUpdateOne) SetUpdateTime(v time.Time) *ResourceUpdateOne { + _u.mutation.SetUpdateTime(v) + return _u +} + +// SetKeyword sets the "keyword" field. +func (_u *ResourceUpdateOne) SetKeyword(v string) *ResourceUpdateOne { + _u.mutation.SetKeyword(v) + return _u +} + +// SetNillableKeyword sets the "keyword" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableKeyword(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetKeyword(*v) + } + return _u } -// ResourceUpdateOne is the builder for updating a single Resource entity. -type ResourceUpdateOne struct { - config - fields []string - hooks []Hook - mutation *ResourceMutation - modifiers []func(*sql.UpdateBuilder) +// SetName sets the "name" field. +func (_u *ResourceUpdateOne) SetName(v string) *ResourceUpdateOne { + _u.mutation.SetName(v) + return _u } -// SetUpdateTime sets the "update_time" field. -func (_u *ResourceUpdateOne) SetUpdateTime(v time.Time) *ResourceUpdateOne { - _u.mutation.SetUpdateTime(v) +// SetNillableName sets the "name" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableName(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetName(*v) + } return _u } -// SetServiceName sets the "service_name" field. -func (_u *ResourceUpdateOne) SetServiceName(v string) *ResourceUpdateOne { - _u.mutation.SetServiceName(v) +// SetI18n sets the "i18n" field. +func (_u *ResourceUpdateOne) SetI18n(v string) *ResourceUpdateOne { + _u.mutation.SetI18n(v) return _u } -// SetNillableServiceName sets the "service_name" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableServiceName(v *string) *ResourceUpdateOne { +// SetNillableI18n sets the "i18n" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableI18n(v *string) *ResourceUpdateOne { if v != nil { - _u.SetServiceName(*v) + _u.SetI18n(*v) } return _u } -// SetKeyword sets the "keyword" field. -func (_u *ResourceUpdateOne) SetKeyword(v string) *ResourceUpdateOne { - _u.mutation.SetKeyword(v) +// ClearI18n clears the value of the "i18n" field. +func (_u *ResourceUpdateOne) ClearI18n() *ResourceUpdateOne { + _u.mutation.ClearI18n() return _u } -// SetNillableKeyword sets the "keyword" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableKeyword(v *string) *ResourceUpdateOne { +// SetType sets the "type" field. +func (_u *ResourceUpdateOne) SetType(v string) *ResourceUpdateOne { + _u.mutation.SetType(v) + return _u +} + +// SetNillableType sets the "type" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableType(v *string) *ResourceUpdateOne { if v != nil { - _u.SetKeyword(*v) + _u.SetType(*v) } return _u } -// SetPath sets the "path" field. -func (_u *ResourceUpdateOne) SetPath(v string) *ResourceUpdateOne { - _u.mutation.SetPath(v) +// ClearType clears the value of the "type" field. +func (_u *ResourceUpdateOne) ClearType() *ResourceUpdateOne { + _u.mutation.ClearType() return _u } -// SetNillablePath sets the "path" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillablePath(v *string) *ResourceUpdateOne { +// SetStatus sets the "status" field. +func (_u *ResourceUpdateOne) SetStatus(v enums.Status) *ResourceUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableStatus(v *enums.Status) *ResourceUpdateOne { if v != nil { - _u.SetPath(*v) + _u.SetStatus(*v) } return _u } -// ClearPath clears the value of the "path" field. -func (_u *ResourceUpdateOne) ClearPath() *ResourceUpdateOne { - _u.mutation.ClearPath() +// AddStatus adds value to the "status" field. +func (_u *ResourceUpdateOne) AddStatus(v enums.Status) *ResourceUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + +// SetSequence sets the "sequence" field. +func (_u *ResourceUpdateOne) SetSequence(v int) *ResourceUpdateOne { + _u.mutation.ResetSequence() + _u.mutation.SetSequence(v) + return _u +} + +// SetNillableSequence sets the "sequence" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableSequence(v *int) *ResourceUpdateOne { + if v != nil { + _u.SetSequence(*v) + } + return _u +} + +// AddSequence adds value to the "sequence" field. +func (_u *ResourceUpdateOne) AddSequence(v int) *ResourceUpdateOne { + _u.mutation.AddSequence(v) return _u } @@ -678,6 +1055,26 @@ func (_u *ResourceUpdateOne) ClearMethod() *ResourceUpdateOne { return _u } +// SetPath sets the "path" field. +func (_u *ResourceUpdateOne) SetPath(v string) *ResourceUpdateOne { + _u.mutation.SetPath(v) + return _u +} + +// SetNillablePath sets the "path" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillablePath(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetPath(*v) + } + return _u +} + +// ClearPath clears the value of the "path" field. +func (_u *ResourceUpdateOne) ClearPath() *ResourceUpdateOne { + _u.mutation.ClearPath() + return _u +} + // SetOperation sets the "operation" field. func (_u *ResourceUpdateOne) SetOperation(v string) *ResourceUpdateOne { _u.mutation.SetOperation(v) @@ -698,6 +1095,20 @@ func (_u *ResourceUpdateOne) ClearOperation() *ResourceUpdateOne { return _u } +// SetServiceName sets the "service_name" field. +func (_u *ResourceUpdateOne) SetServiceName(v string) *ResourceUpdateOne { + _u.mutation.SetServiceName(v) + return _u +} + +// SetNillableServiceName sets the "service_name" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableServiceName(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetServiceName(*v) + } + return _u +} + // SetPolicy sets the "policy" field. func (_u *ResourceUpdateOne) SetPolicy(v string) *ResourceUpdateOne { _u.mutation.SetPolicy(v) @@ -754,27 +1165,106 @@ func (_u *ResourceUpdateOne) SetNillableSyncStatus(v *string) *ResourceUpdateOne return _u } -// SetStatus sets the "status" field. -func (_u *ResourceUpdateOne) SetStatus(v enums.Status) *ResourceUpdateOne { - _u.mutation.ResetStatus() - _u.mutation.SetStatus(v) +// SetTreePath sets the "tree_path" field. +func (_u *ResourceUpdateOne) SetTreePath(v string) *ResourceUpdateOne { + _u.mutation.SetTreePath(v) return _u } -// SetNillableStatus sets the "status" field if the given value is not nil. -func (_u *ResourceUpdateOne) SetNillableStatus(v *enums.Status) *ResourceUpdateOne { +// SetNillableTreePath sets the "tree_path" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableTreePath(v *string) *ResourceUpdateOne { if v != nil { - _u.SetStatus(*v) + _u.SetTreePath(*v) } return _u } -// AddStatus adds value to the "status" field. -func (_u *ResourceUpdateOne) AddStatus(v enums.Status) *ResourceUpdateOne { - _u.mutation.AddStatus(v) +// ClearTreePath clears the value of the "tree_path" field. +func (_u *ResourceUpdateOne) ClearTreePath() *ResourceUpdateOne { + _u.mutation.ClearTreePath() + return _u +} + +// SetParentID sets the "parent_id" field. +func (_u *ResourceUpdateOne) SetParentID(v int64) *ResourceUpdateOne { + _u.mutation.SetParentID(v) + return _u +} + +// SetNillableParentID sets the "parent_id" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableParentID(v *int64) *ResourceUpdateOne { + if v != nil { + _u.SetParentID(*v) + } + return _u +} + +// ClearParentID clears the value of the "parent_id" field. +func (_u *ResourceUpdateOne) ClearParentID() *ResourceUpdateOne { + _u.mutation.ClearParentID() + return _u +} + +// SetProperties sets the "properties" field. +func (_u *ResourceUpdateOne) SetProperties(v string) *ResourceUpdateOne { + _u.mutation.SetProperties(v) + return _u +} + +// SetNillableProperties sets the "properties" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableProperties(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetProperties(*v) + } + return _u +} + +// ClearProperties clears the value of the "properties" field. +func (_u *ResourceUpdateOne) ClearProperties() *ResourceUpdateOne { + _u.mutation.ClearProperties() + return _u +} + +// SetDescription sets the "description" field. +func (_u *ResourceUpdateOne) SetDescription(v string) *ResourceUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ResourceUpdateOne) SetNillableDescription(v *string) *ResourceUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *ResourceUpdateOne) ClearDescription() *ResourceUpdateOne { + _u.mutation.ClearDescription() + return _u +} + +// SetParent sets the "parent" edge to the Resource entity. +func (_u *ResourceUpdateOne) SetParent(v *Resource) *ResourceUpdateOne { + return _u.SetParentID(v.ID) +} + +// AddChildIDs adds the "children" edge to the Resource entity by IDs. +func (_u *ResourceUpdateOne) AddChildIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.AddChildIDs(ids...) return _u } +// AddChildren adds the "children" edges to the Resource entity. +func (_u *ResourceUpdateOne) AddChildren(v ...*Resource) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.AddChildIDs(ids...) +} + // AddViewIDs adds the "views" edge to the View entity by IDs. func (_u *ResourceUpdateOne) AddViewIDs(ids ...int64) *ResourceUpdateOne { _u.mutation.AddViewIDs(ids...) @@ -825,6 +1315,33 @@ func (_u *ResourceUpdateOne) Mutation() *ResourceMutation { return _u.mutation } +// ClearParent clears the "parent" edge to the Resource entity. +func (_u *ResourceUpdateOne) ClearParent() *ResourceUpdateOne { + _u.mutation.ClearParent() + return _u +} + +// ClearChildren clears all "children" edges to the Resource entity. +func (_u *ResourceUpdateOne) ClearChildren() *ResourceUpdateOne { + _u.mutation.ClearChildren() + return _u +} + +// RemoveChildIDs removes the "children" edge to Resource entities by IDs. +func (_u *ResourceUpdateOne) RemoveChildIDs(ids ...int64) *ResourceUpdateOne { + _u.mutation.RemoveChildIDs(ids...) + return _u +} + +// RemoveChildren removes "children" edges to Resource entities. +func (_u *ResourceUpdateOne) RemoveChildren(v ...*Resource) *ResourceUpdateOne { + ids := make([]int64, len(v)) + for i := range v { + ids[i] = v[i].ID + } + return _u.RemoveChildIDs(ids...) +} + // ClearViews clears all "views" edges to the View entity. func (_u *ResourceUpdateOne) ClearViews() *ResourceUpdateOne { _u.mutation.ClearViews() @@ -985,17 +1502,35 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err if value, ok := _u.mutation.UpdateTime(); ok { _spec.SetField(resource.FieldUpdateTime, field.TypeTime, value) } - if value, ok := _u.mutation.ServiceName(); ok { - _spec.SetField(resource.FieldServiceName, field.TypeString, value) - } if value, ok := _u.mutation.Keyword(); ok { _spec.SetField(resource.FieldKeyword, field.TypeString, value) } - if value, ok := _u.mutation.Path(); ok { - _spec.SetField(resource.FieldPath, field.TypeString, value) + if value, ok := _u.mutation.Name(); ok { + _spec.SetField(resource.FieldName, field.TypeString, value) } - if _u.mutation.PathCleared() { - _spec.ClearField(resource.FieldPath, field.TypeString) + if value, ok := _u.mutation.I18n(); ok { + _spec.SetField(resource.FieldI18n, field.TypeString, value) + } + if _u.mutation.I18nCleared() { + _spec.ClearField(resource.FieldI18n, field.TypeString) + } + if value, ok := _u.mutation.GetType(); ok { + _spec.SetField(resource.FieldType, field.TypeString, value) + } + if _u.mutation.TypeCleared() { + _spec.ClearField(resource.FieldType, field.TypeString) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(resource.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(resource.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.Sequence(); ok { + _spec.SetField(resource.FieldSequence, field.TypeInt, value) + } + if value, ok := _u.mutation.AddedSequence(); ok { + _spec.AddField(resource.FieldSequence, field.TypeInt, value) } if value, ok := _u.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) @@ -1003,12 +1538,21 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err if _u.mutation.MethodCleared() { _spec.ClearField(resource.FieldMethod, field.TypeString) } + if value, ok := _u.mutation.Path(); ok { + _spec.SetField(resource.FieldPath, field.TypeString, value) + } + if _u.mutation.PathCleared() { + _spec.ClearField(resource.FieldPath, field.TypeString) + } if value, ok := _u.mutation.Operation(); ok { _spec.SetField(resource.FieldOperation, field.TypeString, value) } if _u.mutation.OperationCleared() { _spec.ClearField(resource.FieldOperation, field.TypeString) } + if value, ok := _u.mutation.ServiceName(); ok { + _spec.SetField(resource.FieldServiceName, field.TypeString, value) + } if value, ok := _u.mutation.Policy(); ok { _spec.SetField(resource.FieldPolicy, field.TypeString, value) } @@ -1021,11 +1565,97 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err if value, ok := _u.mutation.SyncStatus(); ok { _spec.SetField(resource.FieldSyncStatus, field.TypeString, value) } - if value, ok := _u.mutation.Status(); ok { - _spec.SetField(resource.FieldStatus, field.TypeInt8, value) + if value, ok := _u.mutation.TreePath(); ok { + _spec.SetField(resource.FieldTreePath, field.TypeString, value) } - if value, ok := _u.mutation.AddedStatus(); ok { - _spec.AddField(resource.FieldStatus, field.TypeInt8, value) + if _u.mutation.TreePathCleared() { + _spec.ClearField(resource.FieldTreePath, field.TypeString) + } + if value, ok := _u.mutation.Properties(); ok { + _spec.SetField(resource.FieldProperties, field.TypeString, value) + } + if _u.mutation.PropertiesCleared() { + _spec.ClearField(resource.FieldProperties, field.TypeString) + } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(resource.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(resource.FieldDescription, field.TypeString) + } + if _u.mutation.ParentCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: resource.ParentTable, + Columns: []string{resource.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ParentIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.M2O, + Inverse: true, + Table: resource.ParentTable, + Columns: []string{resource.ParentColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) + } + if _u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.RemovedChildrenIDs(); len(nodes) > 0 && !_u.mutation.ChildrenCleared() { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Clear = append(_spec.Edges.Clear, edge) + } + if nodes := _u.mutation.ChildrenIDs(); len(nodes) > 0 { + edge := &sqlgraph.EdgeSpec{ + Rel: sqlgraph.O2M, + Inverse: false, + Table: resource.ChildrenTable, + Columns: []string{resource.ChildrenColumn}, + Bidi: false, + Target: &sqlgraph.EdgeTarget{ + IDSpec: sqlgraph.NewFieldSpec(resource.FieldID, field.TypeInt64), + }, + } + for _, k := range nodes { + edge.Target.Nodes = append(edge.Target.Nodes, k) + } + _spec.Edges.Add = append(_spec.Edges.Add, edge) } if _u.mutation.ViewsCleared() { edge := &sqlgraph.EdgeSpec{ diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index 009cb721..ecb9d958 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -299,7 +299,7 @@ func init() { // resource.UpdateDefaultUpdateTime holds the default value on update for the update_time field. resource.UpdateDefaultUpdateTime = resourceDescUpdateTime.UpdateDefault.(func() time.Time) // resourceDescKeyword is the schema descriptor for keyword field. - resourceDescKeyword := resourceFields[1].Descriptor() + resourceDescKeyword := resourceFields[0].Descriptor() // resource.KeywordValidator is a validator for the "keyword" field. It is called by the builders before save. resource.KeywordValidator = func() func(string) error { validators := resourceDescKeyword.Validators @@ -316,26 +316,38 @@ func init() { return nil } }() + // resourceDescName is the schema descriptor for name field. + resourceDescName := resourceFields[1].Descriptor() + // resource.DefaultName holds the default value on creation for the name field. + resource.DefaultName = resourceDescName.Default.(string) + // resourceDescStatus is the schema descriptor for status field. + resourceDescStatus := resourceFields[4].Descriptor() + // resource.DefaultStatus holds the default value on creation for the status field. + resource.DefaultStatus = enums.Status(resourceDescStatus.Default.(int8)) + // resourceDescSequence is the schema descriptor for sequence field. + resourceDescSequence := resourceFields[5].Descriptor() + // resource.DefaultSequence holds the default value on creation for the sequence field. + resource.DefaultSequence = resourceDescSequence.Default.(int) + // resourceDescServiceName is the schema descriptor for service_name field. + resourceDescServiceName := resourceFields[9].Descriptor() + // resource.DefaultServiceName holds the default value on creation for the service_name field. + resource.DefaultServiceName = resourceDescServiceName.Default.(string) // resourceDescPolicy is the schema descriptor for policy field. - resourceDescPolicy := resourceFields[5].Descriptor() + resourceDescPolicy := resourceFields[10].Descriptor() // resource.DefaultPolicy holds the default value on creation for the policy field. resource.DefaultPolicy = resourceDescPolicy.Default.(string) // resourceDescVersionID is the schema descriptor for version_id field. - resourceDescVersionID := resourceFields[6].Descriptor() + resourceDescVersionID := resourceFields[11].Descriptor() // resource.DefaultVersionID holds the default value on creation for the version_id field. resource.DefaultVersionID = resourceDescVersionID.Default.(string) // resourceDescLastSyncVersionID is the schema descriptor for last_sync_version_id field. - resourceDescLastSyncVersionID := resourceFields[7].Descriptor() + resourceDescLastSyncVersionID := resourceFields[12].Descriptor() // resource.DefaultLastSyncVersionID holds the default value on creation for the last_sync_version_id field. resource.DefaultLastSyncVersionID = resourceDescLastSyncVersionID.Default.(string) // resourceDescSyncStatus is the schema descriptor for sync_status field. - resourceDescSyncStatus := resourceFields[8].Descriptor() + resourceDescSyncStatus := resourceFields[13].Descriptor() // resource.DefaultSyncStatus holds the default value on creation for the sync_status field. resource.DefaultSyncStatus = resourceDescSyncStatus.Default.(string) - // resourceDescStatus is the schema descriptor for status field. - resourceDescStatus := resourceFields[9].Descriptor() - // resource.DefaultStatus holds the default value on creation for the status field. - resource.DefaultStatus = enums.Status(resourceDescStatus.Default.(int8)) // resourceDescID is the schema descriptor for id field. resourceDescID := resourceMixinFields0[0].Descriptor() // resource.DefaultID holds the default value on creation for the id field. @@ -630,13 +642,17 @@ func init() { // view.DefaultScope holds the default value on creation for the scope field. view.DefaultScope = viewDescScope.Default.(string) // viewDescVisible is the schema descriptor for visible field. - viewDescVisible := viewFields[8].Descriptor() + viewDescVisible := viewFields[9].Descriptor() // view.DefaultVisible holds the default value on creation for the visible field. view.DefaultVisible = viewDescVisible.Default.(bool) // viewDescSequence is the schema descriptor for sequence field. - viewDescSequence := viewFields[9].Descriptor() + viewDescSequence := viewFields[10].Descriptor() // view.DefaultSequence holds the default value on creation for the sequence field. view.DefaultSequence = viewDescSequence.Default.(int) + // viewDescStatus is the schema descriptor for status field. + viewDescStatus := viewFields[14].Descriptor() + // view.DefaultStatus holds the default value on creation for the status field. + view.DefaultStatus = enums.Status(viewDescStatus.Default.(int8)) // viewDescID is the schema descriptor for id field. viewDescID := viewMixinFields0[0].Descriptor() // view.DefaultID holds the default value on creation for the id field. diff --git a/internal/data/entity/ent/schema/resource.go b/internal/data/entity/ent/schema/resource.go index 58a840a3..3ee098e6 100644 --- a/internal/data/entity/ent/schema/resource.go +++ b/internal/data/entity/ent/schema/resource.go @@ -20,23 +20,39 @@ type Resource struct { // Fields of the Resource. func (Resource) Fields() []ent.Field { return []ent.Field{ - field.String("service_name"). - Default(""). - Comment(i18n.Text("entity.resource.field.service_name")), field.String("keyword"). MaxLen(255). Comment(i18n.Text("entity.resource.field.keyword")). Unique(). NotEmpty(), - field.String("path"). - Comment(i18n.Text("entity.resource.field.path")). + field.String("name"). + Comment(i18n.Text("entity.resource.field.name")). + Default(""), + field.String("i18n"). + Comment(i18n.Text("entity.resource.field.i18n")). Optional(), + field.String("type"). + Comment(i18n.Text("entity.resource.field.type")). + Optional(), + field.Int8("status"). + GoType(enums.Status(0)). + Default(int8(enums.StatusActive)). + Comment(i18n.Text("entity.resource.field.status")), + field.Int("sequence"). + Comment(i18n.Text("entity.resource.field.sequence")). + Default(0), field.String("method"). Comment(i18n.Text("entity.resource.field.method")). Optional(), + field.String("path"). + Comment(i18n.Text("entity.resource.field.path")). + Optional(), field.String("operation"). Comment(i18n.Text("entity.resource.field.operation")). Optional(), + field.String("service_name"). + Default(""). + Comment(i18n.Text("entity.resource.field.service_name")), field.String("policy"). Comment(i18n.Text("entity.resource.field.policy")). Default(""), @@ -49,16 +65,26 @@ func (Resource) Fields() []ent.Field { field.String("sync_status"). Comment(i18n.Text("entity.resource.field.sync_status")). Default("Synced"), - field.Int8("status"). - GoType(enums.Status(0)). - Default(int8(enums.StatusActive)). - Comment(i18n.Text("entity.resource.field.status")), + field.String("tree_path"). + Comment(i18n.Text("entity.resource.field.tree_path")). + Optional(), + mixin.OptionalFK("parent_id", i18n.Text("entity.resource.field.parent_id")), + field.String("properties"). + Comment(i18n.Text("entity.resource.field.properties")). + Optional(), + field.String("description"). + Comment(i18n.Text("entity.resource.field.description")). + Optional(), } } // Edges of the Resource. func (Resource) Edges() []ent.Edge { return []ent.Edge{ + edge.To("children", Resource.Type). + From("parent"). + Field("parent_id"). + Unique(), edge.From("views", View.Type). Ref("resources"). Through("view_resources", ViewResource.Type), diff --git a/internal/data/entity/ent/schema/view.go b/internal/data/entity/ent/schema/view.go index c306d680..e5304760 100644 --- a/internal/data/entity/ent/schema/view.go +++ b/internal/data/entity/ent/schema/view.go @@ -33,6 +33,9 @@ func (View) Fields() []ent.Field { Default("default"), field.String("name"). Comment(i18n.Text("entity.view.field.name")), + field.String("i18n"). + Comment(i18n.Text("entity.view.field.i18n")). + Optional(), field.Enum("type"). Comment(i18n.Text("entity.view.field.type")). Values( @@ -65,6 +68,16 @@ func (View) Fields() []ent.Field { field.String("tree_path"). Comment(i18n.Text("entity.view.field.tree_path")). Optional(), + field.String("description"). + Comment(i18n.Text("entity.view.field.description")). + Optional(), + field.String("properties"). + Comment(i18n.Text("entity.view.field.properties")). + Optional(), + field.Int8("status"). + GoType(enums.Status(0)). + Default(int8(enums.StatusActive)). + Comment(i18n.Text("entity.view.field.status")), } } diff --git a/internal/data/entity/ent/view.go b/internal/data/entity/ent/view.go index 4d2d6be5..8a03ae3f 100644 --- a/internal/data/entity/ent/view.go +++ b/internal/data/entity/ent/view.go @@ -5,6 +5,7 @@ package ent import ( "fmt" "origadmin/application/admin/internal/data/entity/ent/view" + "origadmin/application/admin/internal/data/enums" "strings" "time" @@ -30,6 +31,8 @@ type View struct { Scope string `json:"scope,omitempty"` // entity.view.field.name Name string `json:"name,omitempty"` + // entity.view.field.i18n + I18n string `json:"i18n,omitempty"` // entity.view.field.type Type view.Type `json:"type,omitempty"` // entity.view.field.component @@ -44,6 +47,12 @@ type View struct { Sequence int `json:"sequence,omitempty"` // entity.view.field.tree_path TreePath string `json:"tree_path,omitempty"` + // entity.view.field.description + Description string `json:"description,omitempty"` + // entity.view.field.properties + Properties string `json:"properties,omitempty"` + // entity.view.field.status + Status enums.Status `json:"status,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the ViewQuery when eager-loading is set. Edges ViewEdges `json:"edges"` @@ -132,9 +141,9 @@ func (*View) scanValues(columns []string) ([]any, error) { switch columns[i] { case view.FieldVisible: values[i] = new(sql.NullBool) - case view.FieldID, view.FieldParentID, view.FieldSequence: + case view.FieldID, view.FieldParentID, view.FieldSequence, view.FieldStatus: values[i] = new(sql.NullInt64) - case view.FieldKeyword, view.FieldScope, view.FieldName, view.FieldType, view.FieldComponent, view.FieldPath, view.FieldIcon, view.FieldTreePath: + case view.FieldKeyword, view.FieldScope, view.FieldName, view.FieldI18n, view.FieldType, view.FieldComponent, view.FieldPath, view.FieldIcon, view.FieldTreePath, view.FieldDescription, view.FieldProperties: values[i] = new(sql.NullString) case view.FieldCreateTime, view.FieldUpdateTime: values[i] = new(sql.NullTime) @@ -195,6 +204,12 @@ func (_m *View) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Name = value.String } + case view.FieldI18n: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field i18n", values[i]) + } else if value.Valid { + _m.I18n = value.String + } case view.FieldType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) @@ -237,6 +252,24 @@ func (_m *View) assignValues(columns []string, values []any) error { } else if value.Valid { _m.TreePath = value.String } + case view.FieldDescription: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field description", values[i]) + } else if value.Valid { + _m.Description = value.String + } + case view.FieldProperties: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field properties", values[i]) + } else if value.Valid { + _m.Properties = value.String + } + case view.FieldStatus: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field status", values[i]) + } else if value.Valid { + _m.Status = enums.Status(value.Int64) + } default: _m.selectValues.Set(columns[i], values[i]) } @@ -321,6 +354,9 @@ func (_m *View) String() string { builder.WriteString("name=") builder.WriteString(_m.Name) builder.WriteString(", ") + builder.WriteString("i18n=") + builder.WriteString(_m.I18n) + builder.WriteString(", ") builder.WriteString("type=") builder.WriteString(fmt.Sprintf("%v", _m.Type)) builder.WriteString(", ") @@ -341,6 +377,15 @@ func (_m *View) String() string { builder.WriteString(", ") builder.WriteString("tree_path=") builder.WriteString(_m.TreePath) + builder.WriteString(", ") + builder.WriteString("description=") + builder.WriteString(_m.Description) + builder.WriteString(", ") + builder.WriteString("properties=") + builder.WriteString(_m.Properties) + builder.WriteString(", ") + builder.WriteString("status=") + builder.WriteString(fmt.Sprintf("%v", _m.Status)) builder.WriteByte(')') return builder.String() } diff --git a/internal/data/entity/ent/view/view.go b/internal/data/entity/ent/view/view.go index db2dcaad..d3a5b173 100644 --- a/internal/data/entity/ent/view/view.go +++ b/internal/data/entity/ent/view/view.go @@ -4,6 +4,7 @@ package view import ( "fmt" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -27,6 +28,8 @@ const ( FieldScope = "scope" // FieldName holds the string denoting the name field in the database. FieldName = "name" + // FieldI18n holds the string denoting the i18n field in the database. + FieldI18n = "i18n" // FieldType holds the string denoting the type field in the database. FieldType = "type" // FieldComponent holds the string denoting the component field in the database. @@ -41,6 +44,12 @@ const ( FieldSequence = "sequence" // FieldTreePath holds the string denoting the tree_path field in the database. FieldTreePath = "tree_path" + // FieldDescription holds the string denoting the description field in the database. + FieldDescription = "description" + // FieldProperties holds the string denoting the properties field in the database. + FieldProperties = "properties" + // FieldStatus holds the string denoting the status field in the database. + FieldStatus = "status" // EdgeParent holds the string denoting the parent edge name in mutations. EdgeParent = "parent" // EdgeChildren holds the string denoting the children edge name in mutations. @@ -98,6 +107,7 @@ var Columns = []string{ FieldKeyword, FieldScope, FieldName, + FieldI18n, FieldType, FieldComponent, FieldPath, @@ -105,6 +115,9 @@ var Columns = []string{ FieldVisible, FieldSequence, FieldTreePath, + FieldDescription, + FieldProperties, + FieldStatus, } var ( @@ -141,6 +154,8 @@ var ( DefaultVisible bool // DefaultSequence holds the default value on creation for the "sequence" field. DefaultSequence int + // DefaultStatus holds the default value on creation for the "status" field. + DefaultStatus enums.Status // DefaultID holds the default value on creation for the "id" field. DefaultID func() int64 // IDValidator is a validator for the "id" field. It is called by the builders before save. @@ -218,6 +233,11 @@ func ByName(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldName, opts...).ToFunc() } +// ByI18n orders the results by the i18n field. +func ByI18n(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldI18n, opts...).ToFunc() +} + // ByType orders the results by the type field. func ByType(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldType, opts...).ToFunc() @@ -253,6 +273,21 @@ func ByTreePath(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldTreePath, opts...).ToFunc() } +// ByDescription orders the results by the description field. +func ByDescription(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldDescription, opts...).ToFunc() +} + +// ByProperties orders the results by the properties field. +func ByProperties(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldProperties, opts...).ToFunc() +} + +// ByStatus orders the results by the status field. +func ByStatus(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldStatus, opts...).ToFunc() +} + // ByParentField orders the results by parent field. func ByParentField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/internal/data/entity/ent/view/where.go b/internal/data/entity/ent/view/where.go index b43c68df..964017ee 100644 --- a/internal/data/entity/ent/view/where.go +++ b/internal/data/entity/ent/view/where.go @@ -4,6 +4,7 @@ package view import ( "origadmin/application/admin/internal/data/entity/ent/predicate" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -85,6 +86,11 @@ func Name(v string) predicate.View { return predicate.View(sql.FieldEQ(FieldName, v)) } +// I18n applies equality check predicate on the "i18n" field. It's identical to I18nEQ. +func I18n(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldI18n, v)) +} + // Component applies equality check predicate on the "component" field. It's identical to ComponentEQ. func Component(v string) predicate.View { return predicate.View(sql.FieldEQ(FieldComponent, v)) @@ -115,6 +121,22 @@ func TreePath(v string) predicate.View { return predicate.View(sql.FieldEQ(FieldTreePath, v)) } +// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. +func Description(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldDescription, v)) +} + +// Properties applies equality check predicate on the "properties" field. It's identical to PropertiesEQ. +func Properties(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldProperties, v)) +} + +// Status applies equality check predicate on the "status" field. It's identical to StatusEQ. +func Status(v enums.Status) predicate.View { + vc := int8(v) + return predicate.View(sql.FieldEQ(FieldStatus, vc)) +} + // CreateTimeEQ applies the EQ predicate on the "create_time" field. func CreateTimeEQ(v time.Time) predicate.View { return predicate.View(sql.FieldEQ(FieldCreateTime, v)) @@ -420,6 +442,81 @@ func NameContainsFold(v string) predicate.View { return predicate.View(sql.FieldContainsFold(FieldName, v)) } +// I18nEQ applies the EQ predicate on the "i18n" field. +func I18nEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldI18n, v)) +} + +// I18nNEQ applies the NEQ predicate on the "i18n" field. +func I18nNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldI18n, v)) +} + +// I18nIn applies the In predicate on the "i18n" field. +func I18nIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldI18n, vs...)) +} + +// I18nNotIn applies the NotIn predicate on the "i18n" field. +func I18nNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldI18n, vs...)) +} + +// I18nGT applies the GT predicate on the "i18n" field. +func I18nGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldI18n, v)) +} + +// I18nGTE applies the GTE predicate on the "i18n" field. +func I18nGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldI18n, v)) +} + +// I18nLT applies the LT predicate on the "i18n" field. +func I18nLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldI18n, v)) +} + +// I18nLTE applies the LTE predicate on the "i18n" field. +func I18nLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldI18n, v)) +} + +// I18nContains applies the Contains predicate on the "i18n" field. +func I18nContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldI18n, v)) +} + +// I18nHasPrefix applies the HasPrefix predicate on the "i18n" field. +func I18nHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldI18n, v)) +} + +// I18nHasSuffix applies the HasSuffix predicate on the "i18n" field. +func I18nHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldI18n, v)) +} + +// I18nIsNil applies the IsNil predicate on the "i18n" field. +func I18nIsNil() predicate.View { + return predicate.View(sql.FieldIsNull(FieldI18n)) +} + +// I18nNotNil applies the NotNil predicate on the "i18n" field. +func I18nNotNil() predicate.View { + return predicate.View(sql.FieldNotNull(FieldI18n)) +} + +// I18nEqualFold applies the EqualFold predicate on the "i18n" field. +func I18nEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldI18n, v)) +} + +// I18nContainsFold applies the ContainsFold predicate on the "i18n" field. +func I18nContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldI18n, v)) +} + // TypeEQ applies the EQ predicate on the "type" field. func TypeEQ(v Type) predicate.View { return predicate.View(sql.FieldEQ(FieldType, v)) @@ -790,6 +887,210 @@ func TreePathContainsFold(v string) predicate.View { return predicate.View(sql.FieldContainsFold(FieldTreePath, v)) } +// DescriptionEQ applies the EQ predicate on the "description" field. +func DescriptionEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldDescription, v)) +} + +// DescriptionNEQ applies the NEQ predicate on the "description" field. +func DescriptionNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldDescription, v)) +} + +// DescriptionIn applies the In predicate on the "description" field. +func DescriptionIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldDescription, vs...)) +} + +// DescriptionNotIn applies the NotIn predicate on the "description" field. +func DescriptionNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldDescription, vs...)) +} + +// DescriptionGT applies the GT predicate on the "description" field. +func DescriptionGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldDescription, v)) +} + +// DescriptionGTE applies the GTE predicate on the "description" field. +func DescriptionGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldDescription, v)) +} + +// DescriptionLT applies the LT predicate on the "description" field. +func DescriptionLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldDescription, v)) +} + +// DescriptionLTE applies the LTE predicate on the "description" field. +func DescriptionLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldDescription, v)) +} + +// DescriptionContains applies the Contains predicate on the "description" field. +func DescriptionContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldDescription, v)) +} + +// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. +func DescriptionHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldDescription, v)) +} + +// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. +func DescriptionHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldDescription, v)) +} + +// DescriptionIsNil applies the IsNil predicate on the "description" field. +func DescriptionIsNil() predicate.View { + return predicate.View(sql.FieldIsNull(FieldDescription)) +} + +// DescriptionNotNil applies the NotNil predicate on the "description" field. +func DescriptionNotNil() predicate.View { + return predicate.View(sql.FieldNotNull(FieldDescription)) +} + +// DescriptionEqualFold applies the EqualFold predicate on the "description" field. +func DescriptionEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldDescription, v)) +} + +// DescriptionContainsFold applies the ContainsFold predicate on the "description" field. +func DescriptionContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldDescription, v)) +} + +// PropertiesEQ applies the EQ predicate on the "properties" field. +func PropertiesEQ(v string) predicate.View { + return predicate.View(sql.FieldEQ(FieldProperties, v)) +} + +// PropertiesNEQ applies the NEQ predicate on the "properties" field. +func PropertiesNEQ(v string) predicate.View { + return predicate.View(sql.FieldNEQ(FieldProperties, v)) +} + +// PropertiesIn applies the In predicate on the "properties" field. +func PropertiesIn(vs ...string) predicate.View { + return predicate.View(sql.FieldIn(FieldProperties, vs...)) +} + +// PropertiesNotIn applies the NotIn predicate on the "properties" field. +func PropertiesNotIn(vs ...string) predicate.View { + return predicate.View(sql.FieldNotIn(FieldProperties, vs...)) +} + +// PropertiesGT applies the GT predicate on the "properties" field. +func PropertiesGT(v string) predicate.View { + return predicate.View(sql.FieldGT(FieldProperties, v)) +} + +// PropertiesGTE applies the GTE predicate on the "properties" field. +func PropertiesGTE(v string) predicate.View { + return predicate.View(sql.FieldGTE(FieldProperties, v)) +} + +// PropertiesLT applies the LT predicate on the "properties" field. +func PropertiesLT(v string) predicate.View { + return predicate.View(sql.FieldLT(FieldProperties, v)) +} + +// PropertiesLTE applies the LTE predicate on the "properties" field. +func PropertiesLTE(v string) predicate.View { + return predicate.View(sql.FieldLTE(FieldProperties, v)) +} + +// PropertiesContains applies the Contains predicate on the "properties" field. +func PropertiesContains(v string) predicate.View { + return predicate.View(sql.FieldContains(FieldProperties, v)) +} + +// PropertiesHasPrefix applies the HasPrefix predicate on the "properties" field. +func PropertiesHasPrefix(v string) predicate.View { + return predicate.View(sql.FieldHasPrefix(FieldProperties, v)) +} + +// PropertiesHasSuffix applies the HasSuffix predicate on the "properties" field. +func PropertiesHasSuffix(v string) predicate.View { + return predicate.View(sql.FieldHasSuffix(FieldProperties, v)) +} + +// PropertiesIsNil applies the IsNil predicate on the "properties" field. +func PropertiesIsNil() predicate.View { + return predicate.View(sql.FieldIsNull(FieldProperties)) +} + +// PropertiesNotNil applies the NotNil predicate on the "properties" field. +func PropertiesNotNil() predicate.View { + return predicate.View(sql.FieldNotNull(FieldProperties)) +} + +// PropertiesEqualFold applies the EqualFold predicate on the "properties" field. +func PropertiesEqualFold(v string) predicate.View { + return predicate.View(sql.FieldEqualFold(FieldProperties, v)) +} + +// PropertiesContainsFold applies the ContainsFold predicate on the "properties" field. +func PropertiesContainsFold(v string) predicate.View { + return predicate.View(sql.FieldContainsFold(FieldProperties, v)) +} + +// StatusEQ applies the EQ predicate on the "status" field. +func StatusEQ(v enums.Status) predicate.View { + vc := int8(v) + return predicate.View(sql.FieldEQ(FieldStatus, vc)) +} + +// StatusNEQ applies the NEQ predicate on the "status" field. +func StatusNEQ(v enums.Status) predicate.View { + vc := int8(v) + return predicate.View(sql.FieldNEQ(FieldStatus, vc)) +} + +// StatusIn applies the In predicate on the "status" field. +func StatusIn(vs ...enums.Status) predicate.View { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.View(sql.FieldIn(FieldStatus, v...)) +} + +// StatusNotIn applies the NotIn predicate on the "status" field. +func StatusNotIn(vs ...enums.Status) predicate.View { + v := make([]any, len(vs)) + for i := range v { + v[i] = int8(vs[i]) + } + return predicate.View(sql.FieldNotIn(FieldStatus, v...)) +} + +// StatusGT applies the GT predicate on the "status" field. +func StatusGT(v enums.Status) predicate.View { + vc := int8(v) + return predicate.View(sql.FieldGT(FieldStatus, vc)) +} + +// StatusGTE applies the GTE predicate on the "status" field. +func StatusGTE(v enums.Status) predicate.View { + vc := int8(v) + return predicate.View(sql.FieldGTE(FieldStatus, vc)) +} + +// StatusLT applies the LT predicate on the "status" field. +func StatusLT(v enums.Status) predicate.View { + vc := int8(v) + return predicate.View(sql.FieldLT(FieldStatus, vc)) +} + +// StatusLTE applies the LTE predicate on the "status" field. +func StatusLTE(v enums.Status) predicate.View { + vc := int8(v) + return predicate.View(sql.FieldLTE(FieldStatus, vc)) +} + // HasParent applies the HasEdge predicate on the "parent" edge. func HasParent() predicate.View { return predicate.View(func(s *sql.Selector) { diff --git a/internal/data/entity/ent/view_create.go b/internal/data/entity/ent/view_create.go index 12ea154c..d7a54d2d 100644 --- a/internal/data/entity/ent/view_create.go +++ b/internal/data/entity/ent/view_create.go @@ -11,6 +11,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/view" "origadmin/application/admin/internal/data/entity/ent/viewpermission" "origadmin/application/admin/internal/data/entity/ent/viewresource" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql/sqlgraph" @@ -92,6 +93,20 @@ func (_c *ViewCreate) SetName(v string) *ViewCreate { return _c } +// SetI18n sets the "i18n" field. +func (_c *ViewCreate) SetI18n(v string) *ViewCreate { + _c.mutation.SetI18n(v) + return _c +} + +// SetNillableI18n sets the "i18n" field if the given value is not nil. +func (_c *ViewCreate) SetNillableI18n(v *string) *ViewCreate { + if v != nil { + _c.SetI18n(*v) + } + return _c +} + // SetType sets the "type" field. func (_c *ViewCreate) SetType(v view.Type) *ViewCreate { _c.mutation.SetType(v) @@ -190,6 +205,48 @@ func (_c *ViewCreate) SetNillableTreePath(v *string) *ViewCreate { return _c } +// SetDescription sets the "description" field. +func (_c *ViewCreate) SetDescription(v string) *ViewCreate { + _c.mutation.SetDescription(v) + return _c +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_c *ViewCreate) SetNillableDescription(v *string) *ViewCreate { + if v != nil { + _c.SetDescription(*v) + } + return _c +} + +// SetProperties sets the "properties" field. +func (_c *ViewCreate) SetProperties(v string) *ViewCreate { + _c.mutation.SetProperties(v) + return _c +} + +// SetNillableProperties sets the "properties" field if the given value is not nil. +func (_c *ViewCreate) SetNillableProperties(v *string) *ViewCreate { + if v != nil { + _c.SetProperties(*v) + } + return _c +} + +// SetStatus sets the "status" field. +func (_c *ViewCreate) SetStatus(v enums.Status) *ViewCreate { + _c.mutation.SetStatus(v) + return _c +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_c *ViewCreate) SetNillableStatus(v *enums.Status) *ViewCreate { + if v != nil { + _c.SetStatus(*v) + } + return _c +} + // SetID sets the "id" field. func (_c *ViewCreate) SetID(v int64) *ViewCreate { _c.mutation.SetID(v) @@ -343,6 +400,10 @@ func (_c *ViewCreate) defaults() { v := view.DefaultSequence _c.mutation.SetSequence(v) } + if _, ok := _c.mutation.Status(); !ok { + v := view.DefaultStatus + _c.mutation.SetStatus(v) + } if _, ok := _c.mutation.ID(); !ok { v := view.DefaultID() _c.mutation.SetID(v) @@ -385,6 +446,9 @@ func (_c *ViewCreate) check() error { if _, ok := _c.mutation.Sequence(); !ok { return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "View.sequence"`)} } + if _, ok := _c.mutation.Status(); !ok { + return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "View.status"`)} + } if v, ok := _c.mutation.ID(); ok { if err := view.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "View.id": %w`, err)} @@ -442,6 +506,10 @@ func (_c *ViewCreate) createSpec() (*View, *sqlgraph.CreateSpec) { _spec.SetField(view.FieldName, field.TypeString, value) _node.Name = value } + if value, ok := _c.mutation.I18n(); ok { + _spec.SetField(view.FieldI18n, field.TypeString, value) + _node.I18n = value + } if value, ok := _c.mutation.GetType(); ok { _spec.SetField(view.FieldType, field.TypeEnum, value) _node.Type = value @@ -470,6 +538,18 @@ func (_c *ViewCreate) createSpec() (*View, *sqlgraph.CreateSpec) { _spec.SetField(view.FieldTreePath, field.TypeString, value) _node.TreePath = value } + if value, ok := _c.mutation.Description(); ok { + _spec.SetField(view.FieldDescription, field.TypeString, value) + _node.Description = value + } + if value, ok := _c.mutation.Properties(); ok { + _spec.SetField(view.FieldProperties, field.TypeString, value) + _node.Properties = value + } + if value, ok := _c.mutation.Status(); ok { + _spec.SetField(view.FieldStatus, field.TypeInt8, value) + _node.Status = value + } if nodes := _c.mutation.ParentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/internal/data/entity/ent/view_query.go b/internal/data/entity/ent/view_query.go index 20e5e9ad..a1a1a442 100644 --- a/internal/data/entity/ent/view_query.go +++ b/internal/data/entity/ent/view_query.go @@ -1001,6 +1001,7 @@ func (_q *ViewQuery) Modify(modifiers ...func(s *sql.Selector)) *ViewSelect { // Keyword string `json:"keyword,omitempty"` // Scope string `json:"scope,omitempty"` // Name string `json:"name,omitempty"` +// I18n string `json:"i18n,omitempty"` // Type view.Type `json:"type,omitempty"` // Component string `json:"component,omitempty"` // Path string `json:"path,omitempty"` @@ -1008,6 +1009,9 @@ func (_q *ViewQuery) Modify(modifiers ...func(s *sql.Selector)) *ViewSelect { // Visible bool `json:"visible,omitempty"` // Sequence int `json:"sequence,omitempty"` // TreePath string `json:"tree_path,omitempty"` +// Description string `json:"description,omitempty"` +// Properties string `json:"properties,omitempty"` +// Status enums.Status `json:"status,omitempty"` // } // // client.View.Query(). @@ -1018,6 +1022,7 @@ func (_q *ViewQuery) Modify(modifiers ...func(s *sql.Selector)) *ViewSelect { // view.FieldKeyword, // view.FieldScope, // view.FieldName, +// view.FieldI18n, // view.FieldType, // view.FieldComponent, // view.FieldPath, @@ -1025,6 +1030,9 @@ func (_q *ViewQuery) Modify(modifiers ...func(s *sql.Selector)) *ViewSelect { // view.FieldVisible, // view.FieldSequence, // view.FieldTreePath, +// view.FieldDescription, +// view.FieldProperties, +// view.FieldStatus, // ). // Scan(ctx, &v) func (vq *ViewQuery) Omit(fields ...string) *ViewSelect { diff --git a/internal/data/entity/ent/view_update.go b/internal/data/entity/ent/view_update.go index cb710a9c..6ee28e1d 100644 --- a/internal/data/entity/ent/view_update.go +++ b/internal/data/entity/ent/view_update.go @@ -12,6 +12,7 @@ import ( "origadmin/application/admin/internal/data/entity/ent/view" "origadmin/application/admin/internal/data/entity/ent/viewpermission" "origadmin/application/admin/internal/data/entity/ent/viewresource" + "origadmin/application/admin/internal/data/enums" "time" "entgo.io/ent/dialect/sql" @@ -101,6 +102,26 @@ func (_u *ViewUpdate) SetNillableName(v *string) *ViewUpdate { return _u } +// SetI18n sets the "i18n" field. +func (_u *ViewUpdate) SetI18n(v string) *ViewUpdate { + _u.mutation.SetI18n(v) + return _u +} + +// SetNillableI18n sets the "i18n" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableI18n(v *string) *ViewUpdate { + if v != nil { + _u.SetI18n(*v) + } + return _u +} + +// ClearI18n clears the value of the "i18n" field. +func (_u *ViewUpdate) ClearI18n() *ViewUpdate { + _u.mutation.ClearI18n() + return _u +} + // SetType sets the "type" field. func (_u *ViewUpdate) SetType(v view.Type) *ViewUpdate { _u.mutation.SetType(v) @@ -230,6 +251,67 @@ func (_u *ViewUpdate) ClearTreePath() *ViewUpdate { return _u } +// SetDescription sets the "description" field. +func (_u *ViewUpdate) SetDescription(v string) *ViewUpdate { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableDescription(v *string) *ViewUpdate { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *ViewUpdate) ClearDescription() *ViewUpdate { + _u.mutation.ClearDescription() + return _u +} + +// SetProperties sets the "properties" field. +func (_u *ViewUpdate) SetProperties(v string) *ViewUpdate { + _u.mutation.SetProperties(v) + return _u +} + +// SetNillableProperties sets the "properties" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableProperties(v *string) *ViewUpdate { + if v != nil { + _u.SetProperties(*v) + } + return _u +} + +// ClearProperties clears the value of the "properties" field. +func (_u *ViewUpdate) ClearProperties() *ViewUpdate { + _u.mutation.ClearProperties() + return _u +} + +// SetStatus sets the "status" field. +func (_u *ViewUpdate) SetStatus(v enums.Status) *ViewUpdate { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *ViewUpdate) SetNillableStatus(v *enums.Status) *ViewUpdate { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *ViewUpdate) AddStatus(v enums.Status) *ViewUpdate { + _u.mutation.AddStatus(v) + return _u +} + // SetParent sets the "parent" edge to the View entity. func (_u *ViewUpdate) SetParent(v *View) *ViewUpdate { return _u.SetParentID(v.ID) @@ -507,6 +589,12 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.Name(); ok { _spec.SetField(view.FieldName, field.TypeString, value) } + if value, ok := _u.mutation.I18n(); ok { + _spec.SetField(view.FieldI18n, field.TypeString, value) + } + if _u.mutation.I18nCleared() { + _spec.ClearField(view.FieldI18n, field.TypeString) + } if value, ok := _u.mutation.GetType(); ok { _spec.SetField(view.FieldType, field.TypeEnum, value) } @@ -543,6 +631,24 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { if _u.mutation.TreePathCleared() { _spec.ClearField(view.FieldTreePath, field.TypeString) } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(view.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(view.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.Properties(); ok { + _spec.SetField(view.FieldProperties, field.TypeString, value) + } + if _u.mutation.PropertiesCleared() { + _spec.ClearField(view.FieldProperties, field.TypeString) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(view.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(view.FieldStatus, field.TypeInt8, value) + } if _u.mutation.ParentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -929,6 +1035,26 @@ func (_u *ViewUpdateOne) SetNillableName(v *string) *ViewUpdateOne { return _u } +// SetI18n sets the "i18n" field. +func (_u *ViewUpdateOne) SetI18n(v string) *ViewUpdateOne { + _u.mutation.SetI18n(v) + return _u +} + +// SetNillableI18n sets the "i18n" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableI18n(v *string) *ViewUpdateOne { + if v != nil { + _u.SetI18n(*v) + } + return _u +} + +// ClearI18n clears the value of the "i18n" field. +func (_u *ViewUpdateOne) ClearI18n() *ViewUpdateOne { + _u.mutation.ClearI18n() + return _u +} + // SetType sets the "type" field. func (_u *ViewUpdateOne) SetType(v view.Type) *ViewUpdateOne { _u.mutation.SetType(v) @@ -1058,6 +1184,67 @@ func (_u *ViewUpdateOne) ClearTreePath() *ViewUpdateOne { return _u } +// SetDescription sets the "description" field. +func (_u *ViewUpdateOne) SetDescription(v string) *ViewUpdateOne { + _u.mutation.SetDescription(v) + return _u +} + +// SetNillableDescription sets the "description" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableDescription(v *string) *ViewUpdateOne { + if v != nil { + _u.SetDescription(*v) + } + return _u +} + +// ClearDescription clears the value of the "description" field. +func (_u *ViewUpdateOne) ClearDescription() *ViewUpdateOne { + _u.mutation.ClearDescription() + return _u +} + +// SetProperties sets the "properties" field. +func (_u *ViewUpdateOne) SetProperties(v string) *ViewUpdateOne { + _u.mutation.SetProperties(v) + return _u +} + +// SetNillableProperties sets the "properties" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableProperties(v *string) *ViewUpdateOne { + if v != nil { + _u.SetProperties(*v) + } + return _u +} + +// ClearProperties clears the value of the "properties" field. +func (_u *ViewUpdateOne) ClearProperties() *ViewUpdateOne { + _u.mutation.ClearProperties() + return _u +} + +// SetStatus sets the "status" field. +func (_u *ViewUpdateOne) SetStatus(v enums.Status) *ViewUpdateOne { + _u.mutation.ResetStatus() + _u.mutation.SetStatus(v) + return _u +} + +// SetNillableStatus sets the "status" field if the given value is not nil. +func (_u *ViewUpdateOne) SetNillableStatus(v *enums.Status) *ViewUpdateOne { + if v != nil { + _u.SetStatus(*v) + } + return _u +} + +// AddStatus adds value to the "status" field. +func (_u *ViewUpdateOne) AddStatus(v enums.Status) *ViewUpdateOne { + _u.mutation.AddStatus(v) + return _u +} + // SetParent sets the "parent" edge to the View entity. func (_u *ViewUpdateOne) SetParent(v *View) *ViewUpdateOne { return _u.SetParentID(v.ID) @@ -1365,6 +1552,12 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { if value, ok := _u.mutation.Name(); ok { _spec.SetField(view.FieldName, field.TypeString, value) } + if value, ok := _u.mutation.I18n(); ok { + _spec.SetField(view.FieldI18n, field.TypeString, value) + } + if _u.mutation.I18nCleared() { + _spec.ClearField(view.FieldI18n, field.TypeString) + } if value, ok := _u.mutation.GetType(); ok { _spec.SetField(view.FieldType, field.TypeEnum, value) } @@ -1401,6 +1594,24 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { if _u.mutation.TreePathCleared() { _spec.ClearField(view.FieldTreePath, field.TypeString) } + if value, ok := _u.mutation.Description(); ok { + _spec.SetField(view.FieldDescription, field.TypeString, value) + } + if _u.mutation.DescriptionCleared() { + _spec.ClearField(view.FieldDescription, field.TypeString) + } + if value, ok := _u.mutation.Properties(); ok { + _spec.SetField(view.FieldProperties, field.TypeString, value) + } + if _u.mutation.PropertiesCleared() { + _spec.ClearField(view.FieldProperties, field.TypeString) + } + if value, ok := _u.mutation.Status(); ok { + _spec.SetField(view.FieldStatus, field.TypeInt8, value) + } + if value, ok := _u.mutation.AddedStatus(); ok { + _spec.AddField(view.FieldStatus, field.TypeInt8, value) + } if _u.mutation.ParentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/internal/features/auth/dto/dto.gen.go b/internal/features/auth/dto/dto.gen.go index 7cb762c7..3f90cf4a 100644 --- a/internal/features/auth/dto/dto.gen.go +++ b/internal/features/auth/dto/dto.gen.go @@ -33,11 +33,13 @@ type ( PermissionsPB = []*types.Permission Position = ent.Position PositionEdges = ent.PositionEdges + PositionEdgesPB = types.PositionEdges PositionPB = types.Position PositionPermission = ent.PositionPermission PositionPermissionEdges = ent.PositionPermissionEdges PositionPermissionPB = types.PositionPermission PositionPermissions = []*ent.PositionPermission + PositionPermissionsPB = []*types.PositionPermission Positions = []*ent.Position Resource = ent.Resource ResourceEdges = ent.ResourceEdges @@ -64,6 +66,7 @@ type ( UserPositionEdges = ent.UserPositionEdges UserPositionPB = types.UserPosition UserPositions = []*ent.UserPosition + UserPositionsPB = []*types.UserPosition UserRole = ent.UserRole UserRoleEdges = ent.UserRoleEdges UserRolePB = types.UserRole @@ -211,6 +214,18 @@ func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { return to } +// ConvertPermissionsPBToPermissions converts a slice of *PermissionPB to a slice of *Permission. +func ConvertPermissionsPBToPermissions(froms PermissionsPB) Permissions { + if froms == nil { + return nil + } + tos := make(Permissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionPBToPermission(f) + } + return tos +} + // ConvertPermissionsToPermissionsPB converts a slice of *Permission to a slice of *PermissionPB. func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { if froms == nil { @@ -223,6 +238,38 @@ func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { return tos } +// ConvertPositionEdgesPBToPositionEdges converts PositionEdgesPB to PositionEdges. +func ConvertPositionEdgesPBToPositionEdges(from *PositionEdgesPB) *PositionEdges { + if from == nil { + return nil + } + + to := &PositionEdges{ + Department: ConvertDepartmentPBToDepartment(from.Department), + Users: ConvertUsersPBToUsers(from.Users), + Permissions: ConvertPermissionsPBToPermissions(from.Permissions), + UserPositions: ConvertUserPositionsPBToUserPositions(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), + } + return to +} + +// ConvertPositionEdgesToPositionEdgesPB converts PositionEdges to PositionEdgesPB. +func ConvertPositionEdgesToPositionEdgesPB(from *PositionEdges) *PositionEdgesPB { + if from == nil { + return nil + } + + to := &PositionEdgesPB{ + Department: ConvertDepartmentToDepartmentPB(from.Department), + Users: ConvertUsersToUsersPB(from.Users), + Permissions: ConvertPermissionsToPermissionsPB(from.Permissions), + UserPositions: ConvertUserPositionsToUserPositionsPB(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), + } + return to +} + // ConvertPositionPBToPosition converts PositionPB to Position. func ConvertPositionPBToPosition(from *PositionPB) *Position { if from == nil { @@ -269,6 +316,30 @@ func ConvertPositionPermissionToPositionPermissionPB(from *PositionPermission) * return to } +// ConvertPositionPermissionsPBToPositionPermissions converts a slice of *PositionPermissionPB to a slice of *PositionPermission. +func ConvertPositionPermissionsPBToPositionPermissions(froms PositionPermissionsPB) PositionPermissions { + if froms == nil { + return nil + } + tos := make(PositionPermissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionPBToPositionPermission(f) + } + return tos +} + +// ConvertPositionPermissionsToPositionPermissionsPB converts a slice of *PositionPermission to a slice of *PositionPermissionPB. +func ConvertPositionPermissionsToPositionPermissionsPB(froms PositionPermissions) PositionPermissionsPB { + if froms == nil { + return nil + } + tos := make(PositionPermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionToPositionPermissionPB(f) + } + return tos +} + // ConvertPositionToPositionPB converts Position to PositionPB. func ConvertPositionToPositionPB(from *Position) *PositionPB { if from == nil { @@ -294,14 +365,17 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { } to := &Resource{ - ID: from.Id, - CreateTime: ConvertTimestampToTime(from.CreateTime), - UpdateTime: ConvertTimestampToTime(from.UpdateTime), - Keyword: from.Keyword, - Path: from.Path, - Method: from.Method, - Operation: from.Operation, - Status: enums.Status(from.Status), + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Name: from.Name, + ServiceName: from.ServiceName, + Keyword: from.Keyword, + Path: from.Path, + Method: from.Method, + Operation: from.Operation, + SyncStatus: from.SyncStatus, + Status: enums.Status(from.Status), } return to } @@ -316,11 +390,14 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { Id: from.ID, CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, Keyword: from.Keyword, Status: int32(from.Status), Path: from.Path, Operation: from.Operation, Method: from.Method, + SyncStatus: from.SyncStatus, + ServiceName: from.ServiceName, Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), } return to @@ -469,7 +546,6 @@ func ConvertUserPBToUser(from *UserPB) *User { Gender: ConvertStringToGender(from.Gender), Phone: from.Phone, Email: from.Email, - I18n: from.I18N, Remark: from.Remark, Token: from.Token, Status: enums.Status(from.Status), @@ -510,6 +586,30 @@ func ConvertUserPositionToUserPositionPB(from *UserPosition) *UserPositionPB { return to } +// ConvertUserPositionsPBToUserPositions converts a slice of *UserPositionPB to a slice of *UserPosition. +func ConvertUserPositionsPBToUserPositions(froms UserPositionsPB) UserPositions { + if froms == nil { + return nil + } + tos := make(UserPositions, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionPBToUserPosition(f) + } + return tos +} + +// ConvertUserPositionsToUserPositionsPB converts a slice of *UserPosition to a slice of *UserPositionPB. +func ConvertUserPositionsToUserPositionsPB(froms UserPositions) UserPositionsPB { + if froms == nil { + return nil + } + tos := make(UserPositionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionToUserPositionPB(f) + } + return tos +} + // ConvertUserRolePBToUserRole converts UserRolePB to UserRole. func ConvertUserRolePBToUserRole(from *UserRolePB) *UserRole { if from == nil { @@ -548,10 +648,10 @@ func ConvertUserToUserPB(from *User) *UserPB { to := &UserPB{ Id: from.ID, - CreateTime: ConvertTimeToTimestamp(from.CreateTime), - UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), CreateAuthor: from.CreateAuthor, UpdateAuthor: from.UpdateAuthor, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Uuid: from.UUID, AllowedIp: from.AllowedIP, Username: from.Username, @@ -564,7 +664,6 @@ func ConvertUserToUserPB(from *User) *UserPB { Remark: from.Remark, Token: from.Token, Status: int32(from.Status), - I18N: from.I18n, LastLoginIp: from.LastLoginIP, LoginIp: from.LoginIP, LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), @@ -575,6 +674,18 @@ func ConvertUserToUserPB(from *User) *UserPB { return to } +// ConvertUsersPBToUsers converts a slice of *UserPB to a slice of *User. +func ConvertUsersPBToUsers(froms UsersPB) Users { + if froms == nil { + return nil + } + tos := make(Users, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPBToUser(f) + } + return tos +} + // ConvertUsersToUsersPB converts a slice of *User to a slice of *UserPB. func ConvertUsersToUsersPB(froms Users) UsersPB { if froms == nil { @@ -602,7 +713,6 @@ func ConvertViewPBToView(from *ViewPB) *View { Scope: from.Scope, Name: from.Name, Type: ConvertStringToType(from.Type), - Component: from.Component, Path: from.Path, Icon: from.Icon, Visible: from.Visible, @@ -627,7 +737,6 @@ func ConvertViewToViewPB(from *View) *ViewPB { Scope: from.Scope, Sequence: int32(from.Sequence), Type: ConvertTypeToString(from.Type), - Component: from.Component, Icon: from.Icon, Visible: from.Visible, Path: from.Path, diff --git a/internal/features/system/biz/resource.go b/internal/features/system/biz/resource.go index 63688de0..7e6cacc6 100644 --- a/internal/features/system/biz/resource.go +++ b/internal/features/system/biz/resource.go @@ -8,6 +8,7 @@ package biz import ( "context" + "github.com/origadmin/contrib/security" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/enums" @@ -33,9 +34,10 @@ func (uc *ResourceUseCase) GetResource(ctx context.Context, id int64) (*types.Re return uc.repo.Get(ctx, id) } -// CreateResource creates a new resource, ensuring essential fields have valid default values. +// CreateResource creates a new resource, intended for use by external APIs (e.g., frontend). +// It handles manual creation logic. func (uc *ResourceUseCase) CreateResource(ctx context.Context, in *types.Resource) (*types.Resource, error) { - // The backend must always enforce data integrity, regardless of frontend behavior. + // The backend must always enforce data integrity. if in.Status == 0 { in.Status = int32(enums.StatusEnabled) } @@ -43,6 +45,12 @@ func (uc *ResourceUseCase) CreateResource(ctx context.Context, in *types.Resourc return uc.repo.Create(ctx, in) } +// CreateResourceFromPolicy creates a new resource based on a security policy definition. +// This is intended for internal use, like database seeding. +func (uc *ResourceUseCase) CreateResourceFromPolicy(ctx context.Context, policy *security.Policy) (*types.Resource, error) { + return uc.repo.CreateFromPolicy(ctx, policy) +} + func (uc *ResourceUseCase) UpdateResource(ctx context.Context, in *types.Resource) (*types.Resource, error) { return uc.repo.Update(ctx, in) } diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index 235d7a57..cd4b4889 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -6,7 +6,9 @@ package dal import ( "context" + "strings" + "github.com/origadmin/contrib/security" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" @@ -52,7 +54,47 @@ func (r *resourceRepo) Get(ctx context.Context, id int64, opts ...*dto.ResourceQ func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ...*dto.ResourceCreateOption) (*types.Resource, error) { entResource := dto.ConvertResourcePBToResource(res) - create := r.db.Resource(ctx).Create().SetResourceSkipZero(entResource) + create := r.db.Resource(ctx).Create(). + SetResourceSkipZero(entResource). + SetName(res.Name). + SetSyncStatus("Modified"). + SetVersionID(""). + SetLastSyncVersionID("") + + saved, err := create.Save(ctx) + if err != nil { + return nil, err + } + return dto.ConvertResourceToResourcePB(saved), nil +} + +func (r *resourceRepo) CreateFromPolicy(ctx context.Context, policy *security.Policy) (*types.Resource, error) { + // e.g. /api.v1.services.auth.AuthService/Login -> auth:auth:Login:write + keyword := strings.ReplaceAll(strings.TrimPrefix(policy.ServiceMethod, "/"), ".", ":") + keyword = strings.ReplaceAll(keyword, "Service", "") + + // Extract method and path from GatewayPath, e.g., "GET:/api/v1/users/{id}" + var method, path string + if policy.GatewayPath != "" { + if parts := strings.SplitN(policy.GatewayPath, ":", 2); len(parts) == 2 { + method = parts[0] + path = parts[1] + } + } + + create := r.db.Resource(ctx).Create(). + SetKeyword(keyword). + SetPath(path). + SetMethod(method). + SetOperation(policy.ServiceMethod). + SetPolicy(policy.Name). + SetVersionID(policy.VersionID). + SetLastSyncVersionID(policy.VersionID). + SetSyncStatus("Synced") + + if policy.DisplayName != "" { + create.SetName(policy.DisplayName) + } saved, err := create.Save(ctx) if err != nil { diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index b7938f83..3f90cf4a 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -33,11 +33,13 @@ type ( PermissionsPB = []*types.Permission Position = ent.Position PositionEdges = ent.PositionEdges + PositionEdgesPB = types.PositionEdges PositionPB = types.Position PositionPermission = ent.PositionPermission PositionPermissionEdges = ent.PositionPermissionEdges PositionPermissionPB = types.PositionPermission PositionPermissions = []*ent.PositionPermission + PositionPermissionsPB = []*types.PositionPermission Positions = []*ent.Position Resource = ent.Resource ResourceEdges = ent.ResourceEdges @@ -64,6 +66,7 @@ type ( UserPositionEdges = ent.UserPositionEdges UserPositionPB = types.UserPosition UserPositions = []*ent.UserPosition + UserPositionsPB = []*types.UserPosition UserRole = ent.UserRole UserRoleEdges = ent.UserRoleEdges UserRolePB = types.UserRole @@ -211,6 +214,18 @@ func ConvertPermissionToPermissionPB(from *Permission) *PermissionPB { return to } +// ConvertPermissionsPBToPermissions converts a slice of *PermissionPB to a slice of *Permission. +func ConvertPermissionsPBToPermissions(froms PermissionsPB) Permissions { + if froms == nil { + return nil + } + tos := make(Permissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPermissionPBToPermission(f) + } + return tos +} + // ConvertPermissionsToPermissionsPB converts a slice of *Permission to a slice of *PermissionPB. func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { if froms == nil { @@ -223,6 +238,38 @@ func ConvertPermissionsToPermissionsPB(froms Permissions) PermissionsPB { return tos } +// ConvertPositionEdgesPBToPositionEdges converts PositionEdgesPB to PositionEdges. +func ConvertPositionEdgesPBToPositionEdges(from *PositionEdgesPB) *PositionEdges { + if from == nil { + return nil + } + + to := &PositionEdges{ + Department: ConvertDepartmentPBToDepartment(from.Department), + Users: ConvertUsersPBToUsers(from.Users), + Permissions: ConvertPermissionsPBToPermissions(from.Permissions), + UserPositions: ConvertUserPositionsPBToUserPositions(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsPBToPositionPermissions(from.PositionPermissions), + } + return to +} + +// ConvertPositionEdgesToPositionEdgesPB converts PositionEdges to PositionEdgesPB. +func ConvertPositionEdgesToPositionEdgesPB(from *PositionEdges) *PositionEdgesPB { + if from == nil { + return nil + } + + to := &PositionEdgesPB{ + Department: ConvertDepartmentToDepartmentPB(from.Department), + Users: ConvertUsersToUsersPB(from.Users), + Permissions: ConvertPermissionsToPermissionsPB(from.Permissions), + UserPositions: ConvertUserPositionsToUserPositionsPB(from.UserPositions), + PositionPermissions: ConvertPositionPermissionsToPositionPermissionsPB(from.PositionPermissions), + } + return to +} + // ConvertPositionPBToPosition converts PositionPB to Position. func ConvertPositionPBToPosition(from *PositionPB) *Position { if from == nil { @@ -269,6 +316,30 @@ func ConvertPositionPermissionToPositionPermissionPB(from *PositionPermission) * return to } +// ConvertPositionPermissionsPBToPositionPermissions converts a slice of *PositionPermissionPB to a slice of *PositionPermission. +func ConvertPositionPermissionsPBToPositionPermissions(froms PositionPermissionsPB) PositionPermissions { + if froms == nil { + return nil + } + tos := make(PositionPermissions, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionPBToPositionPermission(f) + } + return tos +} + +// ConvertPositionPermissionsToPositionPermissionsPB converts a slice of *PositionPermission to a slice of *PositionPermissionPB. +func ConvertPositionPermissionsToPositionPermissionsPB(froms PositionPermissions) PositionPermissionsPB { + if froms == nil { + return nil + } + tos := make(PositionPermissionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertPositionPermissionToPositionPermissionPB(f) + } + return tos +} + // ConvertPositionToPositionPB converts Position to PositionPB. func ConvertPositionToPositionPB(from *Position) *PositionPB { if from == nil { @@ -297,11 +368,13 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { ID: from.Id, CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), + Name: from.Name, ServiceName: from.ServiceName, Keyword: from.Keyword, Path: from.Path, Method: from.Method, Operation: from.Operation, + SyncStatus: from.SyncStatus, Status: enums.Status(from.Status), } return to @@ -317,13 +390,15 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { Id: from.ID, CreateTime: ConvertTimeToTimestamp(from.CreateTime), UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Name: from.Name, Keyword: from.Keyword, Status: int32(from.Status), Path: from.Path, Operation: from.Operation, Method: from.Method, - Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), + SyncStatus: from.SyncStatus, ServiceName: from.ServiceName, + Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), } return to } @@ -471,7 +546,6 @@ func ConvertUserPBToUser(from *UserPB) *User { Gender: ConvertStringToGender(from.Gender), Phone: from.Phone, Email: from.Email, - I18n: from.I18N, Remark: from.Remark, Token: from.Token, Status: enums.Status(from.Status), @@ -512,6 +586,30 @@ func ConvertUserPositionToUserPositionPB(from *UserPosition) *UserPositionPB { return to } +// ConvertUserPositionsPBToUserPositions converts a slice of *UserPositionPB to a slice of *UserPosition. +func ConvertUserPositionsPBToUserPositions(froms UserPositionsPB) UserPositions { + if froms == nil { + return nil + } + tos := make(UserPositions, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionPBToUserPosition(f) + } + return tos +} + +// ConvertUserPositionsToUserPositionsPB converts a slice of *UserPosition to a slice of *UserPositionPB. +func ConvertUserPositionsToUserPositionsPB(froms UserPositions) UserPositionsPB { + if froms == nil { + return nil + } + tos := make(UserPositionsPB, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPositionToUserPositionPB(f) + } + return tos +} + // ConvertUserRolePBToUserRole converts UserRolePB to UserRole. func ConvertUserRolePBToUserRole(from *UserRolePB) *UserRole { if from == nil { @@ -550,10 +648,10 @@ func ConvertUserToUserPB(from *User) *UserPB { to := &UserPB{ Id: from.ID, - CreateTime: ConvertTimeToTimestamp(from.CreateTime), - UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), CreateAuthor: from.CreateAuthor, UpdateAuthor: from.UpdateAuthor, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Uuid: from.UUID, AllowedIp: from.AllowedIP, Username: from.Username, @@ -566,7 +664,6 @@ func ConvertUserToUserPB(from *User) *UserPB { Remark: from.Remark, Token: from.Token, Status: int32(from.Status), - I18N: from.I18n, LastLoginIp: from.LastLoginIP, LoginIp: from.LoginIP, LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), @@ -577,6 +674,18 @@ func ConvertUserToUserPB(from *User) *UserPB { return to } +// ConvertUsersPBToUsers converts a slice of *UserPB to a slice of *User. +func ConvertUsersPBToUsers(froms UsersPB) Users { + if froms == nil { + return nil + } + tos := make(Users, len(froms)) + for i, f := range froms { + tos[i] = ConvertUserPBToUser(f) + } + return tos +} + // ConvertUsersToUsersPB converts a slice of *User to a slice of *UserPB. func ConvertUsersToUsersPB(froms Users) UsersPB { if froms == nil { @@ -604,7 +713,6 @@ func ConvertViewPBToView(from *ViewPB) *View { Scope: from.Scope, Name: from.Name, Type: ConvertStringToType(from.Type), - Component: from.Component, Path: from.Path, Icon: from.Icon, Visible: from.Visible, @@ -629,7 +737,6 @@ func ConvertViewToViewPB(from *View) *ViewPB { Scope: from.Scope, Sequence: int32(from.Sequence), Type: ConvertTypeToString(from.Type), - Component: from.Component, Icon: from.Icon, Visible: from.Visible, Path: from.Path, diff --git a/internal/features/system/dto/resource.go b/internal/features/system/dto/resource.go index 7a9d5053..32b76292 100644 --- a/internal/features/system/dto/resource.go +++ b/internal/features/system/dto/resource.go @@ -8,6 +8,7 @@ package dto import ( "context" + "github.com/origadmin/contrib/security" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/helpers/repo" @@ -18,6 +19,7 @@ type ResourceRepo interface { Get(context.Context, int64, ...*ResourceQueryOption) (*types.Resource, error) List(context.Context, ...*ResourceQueryOption) ([]*types.Resource, int32, error) Create(context.Context, *types.Resource, ...*ResourceCreateOption) (*types.Resource, error) + CreateFromPolicy(ctx context.Context, policy *security.Policy) (*types.Resource, error) Update(context.Context, *types.Resource, ...*ResourceUpdateOption) (*types.Resource, error) Delete(context.Context, int64) error } diff --git a/internal/features/system/dto/schema_test.go b/internal/features/system/dto/schema_test.go new file mode 100644 index 00000000..71c9be62 --- /dev/null +++ b/internal/features/system/dto/schema_test.go @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package dto_test + +import ( + "fmt" + "reflect" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + + "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/data/entity/ent" +) + +// validateFields checks if all exported fields in entStruct exist in protoStruct and have compatible types. +func validateFields(t *testing.T, entStruct interface{}, protoStruct interface{}, ignoreFields []string) { + entType := reflect.TypeOf(entStruct) + protoType := reflect.TypeOf(protoStruct) + + if entType.Kind() == reflect.Ptr { + entType = entType.Elem() + } + if protoType.Kind() == reflect.Ptr { + protoType = protoType.Elem() + } + + entFields := make(map[string]reflect.StructField) + for i := 0; i < entType.NumField(); i++ { + field := entType.Field(i) + // Skip unexported fields and embedded structs like ent.Schema + if field.PkgPath != "" || field.Anonymous { + continue + } + // Skip specific fields + if isIgnored(field.Name, ignoreFields) { + continue + } + entFields[strings.ToLower(field.Name)] = field + } + + protoFields := make(map[string]reflect.StructField) + for i := 0; i < protoType.NumField(); i++ { + field := protoType.Field(i) + // Skip unexported fields and internal proto fields + if field.PkgPath != "" || strings.HasPrefix(field.Name, "XXX_") { + continue + } + protoFields[strings.ToLower(field.Name)] = field + } + + for name, entField := range entFields { + // Special handling for ID field which might be named differently or handled by mixin + if name == "id" { + if _, ok := protoFields["id"]; ok { + continue + } + } + + protoField, exists := protoFields[name] + if !exists { + assert.Fail(t, fmt.Sprintf("[%s] Field mismatch: '%s' (%s) exists in Ent but missing in Proto", + entType.Name(), entField.Name, entField.Type)) + continue + } + + // Optional: Check for type compatibility if needed. + // Note: Ent types (e.g. int8) might differ from Proto types (e.g. int32), so strict equality check might fail. + // We can add loose type checking here if required. + _ = protoField + } +} + +func isIgnored(fieldName string, ignoreList []string) bool { + for _, ignored := range ignoreList { + if fieldName == ignored { + return true + } + } + return false +} + +func TestSchemaProtoConsistency(t *testing.T) { + // Common fields to ignore in Ent entities that are not expected in Proto + commonIgnores := []string{ + "Edges", + "config", + } + + t.Run("User", func(t *testing.T) { + validateFields(t, &ent.User{}, &types.User{}, append(commonIgnores, "EncryptedPassword", "Salt", "Token", "IsSystem", "DeleteTime")) + }) + + t.Run("Role", func(t *testing.T) { + validateFields(t, &ent.Role{}, &types.Role{}, commonIgnores) + }) + + t.Run("Resource", func(t *testing.T) { + validateFields(t, &ent.Resource{}, &types.Resource{}, commonIgnores) + }) + + t.Run("View", func(t *testing.T) { + validateFields(t, &ent.View{}, &types.View{}, commonIgnores) + }) +} diff --git a/internal/tasks/seeder/seeder.go b/internal/tasks/seeder/seeder.go index 6cdc4d79..1b26e645 100644 --- a/internal/tasks/seeder/seeder.go +++ b/internal/tasks/seeder/seeder.go @@ -9,7 +9,6 @@ import ( "context" "crypto/rand" "math/big" - "strings" "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" @@ -123,70 +122,22 @@ func (s *Seeder) createRootUser() error { func (s *Seeder) createInitialResources() error { ctx := context.Background() for _, policy := range security.RegisteredPolicies() { - parts := strings.Split(policy.ServiceMethod, "/") - if len(parts) < 3 { - continue - } - // e.g. /api.v1.services.auth.AuthService/Login -> auth:auth:Login:write - services := strings.SplitN(strings.TrimPrefix(policy.ServiceMethod, "/"), "/", 2) - keyword := strings.ReplaceAll(services[0], ".", ":") - keyword = strings.TrimPrefix(keyword, "api:v1:services:") - keyword = strings.ReplaceAll(keyword, "Service", "") - - keyword = keyword + ":" + services[1] - - // Map HTTP method to action suffix - var action string - if policy.GatewayPath != "" { - if methodParts := strings.SplitN(policy.GatewayPath, ":", 2); len(methodParts) >= 1 { - method := methodParts[0] - switch method { - case "GET", "HEAD", "OPTIONS": - action = "Read" - case "POST": - action = "Write" - case "PUT", "PATCH": - action = "Write" - case "DELETE": - action = "Delete" - default: - action = "Any" - } - keyword = keyword + ":" + action - } - } - - // Extract method and path from GatewayPath, e.g., "GET:/api/v1/users/{id}" - var method, path string - if policy.GatewayPath != "" { - if parts := strings.SplitN(policy.GatewayPath, ":", 2); len(parts) == 2 { - method = parts[0] - path = parts[1] - } - } - - resource := &types.Resource{ - ServiceName: services[0], - Name: policy.Name, - Keyword: keyword, - Path: path, - Operation: policy.ServiceMethod, - Method: method, - } - + // Check if resource already exists by its operation, which should be unique. _, count, err := s.resourceUseCase.ListResources(ctx, &system.ListResourcesRequest{ - Keyword: resource.Keyword, + Operation: policy.ServiceMethod, OnlyCount: true, }) if err == nil && count > 0 { - s.log.Infof("Resource '%s' already exists, skipping.", resource.Keyword) + s.log.Infof("Resource for operation '%s' already exists, skipping.", policy.ServiceMethod) continue } - if _, err := s.resourceUseCase.CreateResource(ctx, resource); err != nil { - s.log.Errorf("failed to create resource %s: %v", resource.Keyword, err) + + // If not exists, create it using the dedicated biz method. + if _, err := s.resourceUseCase.CreateResourceFromPolicy(ctx, &policy); err != nil { + s.log.Errorf("failed to create resource from policy '%s': %v", policy.ServiceMethod, err) } else { - s.log.Infof("Successfully created resource: %s", resource.Keyword) + s.log.Infof("Successfully created resource from policy: %s", policy.ServiceMethod) } } return nil diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 358914ab..0d876829 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -3017,12 +3017,6 @@ components: type: string description: update_time.field.comment format: date-time - create_author: - type: string - description: create_author.field.comment - update_author: - type: string - description: update_author.field.comment keyword: type: string description: department.field.keyword @@ -3076,12 +3070,6 @@ components: type: string description: update_time.field.comment format: date-time - create_author: - type: string - description: create_author.field.comment - update_author: - type: string - description: update_author.field.comment name: type: string description: permission.field.name @@ -3108,16 +3096,16 @@ components: items: type: string description: permission.field.resource_ids - resources: - type: array - items: - $ref: '#/components/schemas/api.v1.services.types.Resource' - description: permission.field.resources view_ids: type: array items: type: string description: permission.field.view_ids + resources: + type: array + items: + $ref: '#/components/schemas/api.v1.services.types.Resource' + description: permission.field.resources views: type: array items: @@ -3140,12 +3128,6 @@ components: type: string description: update_time.field.comment format: date-time - create_author: - type: string - description: create_author.field.comment - update_author: - type: string - description: update_author.field.comment name: type: string description: position.field.name @@ -3175,18 +3157,15 @@ components: type: string description: update_time.field.comment format: date-time - create_author: - type: string - description: create_author.field.comment - update_author: - type: string - description: update_author.field.comment name: type: string description: resource.field.name keyword: type: string description: resource.field.keyword + i18n_key: + type: string + description: resource.field.i18n_key type: type: string description: resource.field.type @@ -3203,10 +3182,19 @@ components: method: type: string description: resource.field.method + component: + type: string + description: resource.field.component + icon: + type: string + description: resource.field.icon sequence: type: integer description: resource.field.sequence format: int32 + visible: + type: boolean + description: resource.field.visible tree_path: type: string description: resource.field.tree_path @@ -3221,6 +3209,12 @@ components: parent_id: type: string description: resource.field.parent_id + sync_status: + type: string + description: resource.field.sync_status + service_name: + type: string + description: resource.field.service_name children: type: array items: @@ -3240,8 +3234,6 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.Permission' description: Permissions holds the value of the permissions edge. - service_name: - type: string description: Resource is the model entity for the Resource schema. api.v1.services.types.Role: type: object @@ -3259,12 +3251,6 @@ components: type: string description: update_time.field.comment format: date-time - create_author: - type: string - description: create_author.field.comment - update_author: - type: string - description: update_author.field.comment keyword: type: string description: role.field.keyword @@ -3294,21 +3280,11 @@ components: items: $ref: '#/components/schemas/api.v1.services.types.View' description: Views holds the value of the views edge. - view_ids: - type: array - items: - type: string - description: View Ids holds the value of the view_ids edge. users: type: array items: $ref: '#/components/schemas/api.v1.services.types.User' description: Users holds the value of the users edge. - user_ids: - type: array - items: - type: string - description: Users Ids holds the value of the user_ids edge. resources: type: array items: @@ -3338,6 +3314,12 @@ components: description: |- ID of the ent. field.primary_key.comment + create_author: + type: string + description: create_author.field.comment + update_author: + type: string + description: update_author.field.comment create_time: type: string description: create_time.field.comment @@ -3346,12 +3328,6 @@ components: type: string description: update_time.field.comment format: date-time - create_author: - type: string - description: create_author.field.comment - update_author: - type: string - description: update_author.field.comment uuid: type: string description: user.field.uuid @@ -3389,9 +3365,6 @@ components: type: integer description: user.field.status format: int32 - i18n: - type: string - description: user.field.i18n last_login_ip: type: string description: user.field.last_login_ip @@ -3444,9 +3417,9 @@ components: scope: type: string description: Scope holds the value of the "scope" field. - i18n_key: + i18n: type: string - description: I18nKey holds the value of the "i18n_key" field. + description: I18nKey holds the value of the "i18n" field. description: type: string description: Description holds the value of the "description" field. @@ -3457,9 +3430,6 @@ components: type: type: string description: Type holds the value of the "type" field. - component: - type: string - description: Component holds the value of the "component" field. comment: type: string description: Comment holds the value of the "comment" field. From 3a15e5e6a05d8b850898ed5b68bf5a19218ceff1 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 7 Jan 2026 18:08:40 +0800 Subject: [PATCH 153/158] feat(proto): update system proto files with new fields and field name changes --- Makefile | 30 +- api/v1/proto/system/resource.proto | 1 + api/v1/proto/types/system.proto | 12 +- api/v1/services/system/resource.pb.go | 14 +- .../services/system/resource.pb.validate.go | 2 + api/v1/services/types/system.pb.go | 56 +++- api/v1/services/types/system.pb.validate.go | 8 +- buf.lock | 4 +- internal/conf/pb/captcha.pb.go | 13 +- internal/conf/pb/captcha.pb.validate.go | 2 + internal/conf/pb/conf.pb.go | 16 +- internal/conf/pb/conf.proto | 1 - internal/conf/pb/root.pb.go | 122 ++------ internal/conf/pb/root.pb.validate.go | 60 +--- internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 30 +- internal/data/entity/ent/mutation.go | 285 ------------------ internal/data/entity/ent/resource/resource.go | 16 + internal/data/entity/ent/resource/where.go | 80 ----- internal/data/entity/ent/resource_create.go | 56 ++++ internal/data/entity/ent/resource_update.go | 144 --------- internal/data/entity/ent/runtime/runtime.go | 60 ++++ internal/data/entity/ent/schema/resource.go | 16 +- internal/data/entity/ent/schema/view.go | 14 +- internal/data/entity/ent/view/view.go | 14 + internal/data/entity/ent/view/where.go | 70 ----- internal/data/entity/ent/view_create.go | 49 +++ internal/data/entity/ent/view_update.go | 126 -------- internal/features/system/dal/resource.go | 5 +- internal/features/system/dto/dto.gen.go | 96 ++++-- internal/features/system/dto/dto.go | 23 ++ internal/features/system/dto/resource.go | 3 + internal/tasks/seeder/seeder.go | 13 +- resources/api-docs/openapi/openapi.yaml | 17 +- 34 files changed, 483 insertions(+), 977 deletions(-) diff --git a/Makefile b/Makefile index a08dd35f..d8b35ad2 100644 --- a/Makefile +++ b/Makefile @@ -163,21 +163,21 @@ release-all-in-one: build-ui #go generate ./cmd/system #generate system module #go generate ./cmd/internal/start #generate main module start gen: - go mod tidy - - buf dep update - buf build - buf generate - - @#echo "Generating Protobuf code for helpers/resp/data/v1..." - @#protoc -I. -I./third_party --go_out=paths=source_relative:. ./helpers/resp/data/v1/*.proto - - @echo "Generating Protobuf code for conf/pb..." - @protoc -I. -I./third_party --go_out=paths=source_relative:. --validate_out=paths=source_relative,lang=go:. ./internal/conf/pb/*.proto - - go generate ./internal/data/entity/ent/generate.go - go generate ./cmd/system - go generate ./cmd/auth +# @echo "Generating Protobuf service api..." +# @buf dep update +# @buf build +# @buf generate +# +# @echo "Generating Protobuf code for conf/pb..." +# @protoc -I. -I./third_party --go_out=paths=source_relative:. --validate_out=paths=source_relative,lang=go:. ./internal/conf/pb/*.proto +# +# @echo "Generating Ent data..." +# @go generate ./internal/data/entity/ent/generate.go + @echo "Generating main wire..." + @go generate ./cmd/seed/wire.work.go + @go generate ./cmd/system/wire.work.go + @go generate ./cmd/auth/wire.work.go + @go generate ./cmd/gateway/wire.work.go .PHONY: all # generate all diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index 6793a5a1..babebc36 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -64,6 +64,7 @@ message ListResourcesRequest { string keyword = 7 [json_name = "keyword"]; string service_name = 8 [json_name = "service_name"]; string sync_status = 9 [json_name = "sync_status"]; + string operation = 10 [json_name = "operation"]; } // Response message for ResourceService.ListResources. diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index 6789e92a..f4d9d211 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -24,8 +24,8 @@ message View { string name = 5 [json_name = "name"]; // Scope holds the value of the "scope" field. string scope = 6 [json_name = "scope"]; - // I18nKey holds the value of the "i18n_key" field. - string i18n_key = 7 [json_name = "i18n_key"]; + // I18nKey holds the value of the "i18n" field. + string i18n = 7 [json_name = "i18n"]; // Description holds the value of the "description" field. string description = 8 [json_name = "description"]; // Sequence holds the value of the "sequence" field. @@ -146,10 +146,8 @@ message User { google.protobuf.Timestamp login_time = 21 [json_name = "login_time"]; // user.field.sanction_date optional google.protobuf.Timestamp sanction_date = 22 [json_name = "sanction_date"]; - // user.field.i18n - string i18n = 23 [json_name = "i18n"]; // user.field.department - string department = 24 [json_name = "department"]; + string department = 23 [json_name = "department"]; // Roles holds the value of the roles edge. repeated Role roles = 100 [json_name = "roles"]; // Role Ids holds the value of the role_ids @@ -207,8 +205,8 @@ message Resource { string name = 4 [json_name = "name"]; // resource.field.keyword string keyword = 5 [json_name = "keyword"]; - // resource.field.i18n_key - string i18n_key = 6 [json_name = "i18n_key"]; + // resource.field.i18n + string i18n = 6 [json_name = "i18n"]; // resource.field.type string type = 7 [json_name = "type"]; // resource.field.status diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go index 44ad4573..517bfd09 100644 --- a/api/v1/services/system/resource.pb.go +++ b/api/v1/services/system/resource.pb.go @@ -38,6 +38,7 @@ type ListResourcesRequest struct { Keyword string `protobuf:"bytes,7,opt,name=keyword,proto3" json:"keyword,omitempty"` ServiceName string `protobuf:"bytes,8,opt,name=service_name,proto3" json:"service_name,omitempty"` SyncStatus string `protobuf:"bytes,9,opt,name=sync_status,proto3" json:"sync_status,omitempty"` + Operation string `protobuf:"bytes,10,opt,name=operation,proto3" json:"operation,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -135,6 +136,13 @@ func (x *ListResourcesRequest) GetSyncStatus() string { return "" } +func (x *ListResourcesRequest) GetOperation() string { + if x != nil { + return x.Operation + } + return "" +} + // Response message for ResourceService.ListResources. type ListResourcesResponse struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -600,7 +608,7 @@ var File_system_resource_proto protoreflect.FileDescriptor const file_system_resource_proto_rawDesc = "" + "\n" + - "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"\x96\x02\n" + + "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"\xb4\x02\n" + "\x14ListResourcesRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + @@ -614,7 +622,9 @@ const file_system_resource_proto_rawDesc = "" + "only_count\x12\x18\n" + "\akeyword\x18\a \x01(\tR\akeyword\x12\"\n" + "\fservice_name\x18\b \x01(\tR\fservice_name\x12 \n" + - "\vsync_status\x18\t \x01(\tR\vsync_status\"\x83\x02\n" + + "\vsync_status\x18\t \x01(\tR\vsync_status\x12\x1c\n" + + "\toperation\x18\n" + + " \x01(\tR\toperation\"\x83\x02\n" + "\x15ListResourcesResponse\x12\x14\n" + "\x05total\x18\x01 \x01(\x05R\x05total\x12=\n" + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x12\n" + diff --git a/api/v1/services/system/resource.pb.validate.go b/api/v1/services/system/resource.pb.validate.go index 004aec33..8bde65b5 100644 --- a/api/v1/services/system/resource.pb.validate.go +++ b/api/v1/services/system/resource.pb.validate.go @@ -75,6 +75,8 @@ func (m *ListResourcesRequest) validate(all bool) error { // no validation rules for SyncStatus + // no validation rules for Operation + if len(errors) > 0 { return ListResourcesRequestMultiError(errors) } diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index 90450d64..6745dfa4 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -63,6 +63,8 @@ type View struct { ParentId int64 `protobuf:"varint,18,opt,name=parent_id,proto3" json:"parent_id,omitempty"` // ParentPath holds the value of the "parent_path" field. ParentPath string `protobuf:"bytes,19,opt,name=parent_path,proto3" json:"parent_path,omitempty"` + // Component holds the value of the "component" field. + Component string `protobuf:"bytes,20,opt,name=component,proto3" json:"component,omitempty"` // Children holds the value of the children edge. Children []*View `protobuf:"bytes,100,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. @@ -238,6 +240,13 @@ func (x *View) GetParentPath() string { return "" } +func (x *View) GetComponent() string { + if x != nil { + return x.Component + } + return "" +} + func (x *View) GetChildren() []*View { if x != nil { return x.Children @@ -496,6 +505,8 @@ type User struct { LoginTime *timestamppb.Timestamp `protobuf:"bytes,21,opt,name=login_time,proto3" json:"login_time,omitempty"` // user.field.sanction_date SanctionDate *timestamppb.Timestamp `protobuf:"bytes,22,opt,name=sanction_date,proto3,oneof" json:"sanction_date,omitempty"` + // user.field.department + Department string `protobuf:"bytes,23,opt,name=department,proto3" json:"department,omitempty"` // Roles holds the value of the roles edge. Roles []*Role `protobuf:"bytes,100,rep,name=roles,proto3" json:"roles,omitempty"` // Role Ids holds the value of the role_ids @@ -688,6 +699,13 @@ func (x *User) GetSanctionDate() *timestamppb.Timestamp { return nil } +func (x *User) GetDepartment() string { + if x != nil { + return x.Department + } + return "" +} + func (x *User) GetRoles() []*Role { if x != nil { return x.Roles @@ -925,8 +943,8 @@ type Resource struct { Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` // resource.field.keyword Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` - // resource.field.i18n_key - I18NKey string `protobuf:"bytes,6,opt,name=i18n_key,proto3" json:"i18n_key,omitempty"` + // resource.field.i18n + I18N string `protobuf:"bytes,6,opt,name=i18n,proto3" json:"i18n,omitempty"` // resource.field.type Type string `protobuf:"bytes,7,opt,name=type,proto3" json:"type,omitempty"` // resource.field.status @@ -957,6 +975,8 @@ type Resource struct { SyncStatus string `protobuf:"bytes,20,opt,name=sync_status,proto3" json:"sync_status,omitempty"` // resource.field.service_name ServiceName string `protobuf:"bytes,21,opt,name=service_name,proto3" json:"service_name,omitempty"` + // resource.field.policy + Policy string `protobuf:"bytes,22,opt,name=policy,proto3" json:"policy,omitempty"` // Children holds the value of the children edge. Children []*Resource `protobuf:"bytes,100,rep,name=children,proto3" json:"children,omitempty"` // Parent holds the value of the parent edge. @@ -1034,9 +1054,9 @@ func (x *Resource) GetKeyword() string { return "" } -func (x *Resource) GetI18NKey() string { +func (x *Resource) GetI18N() string { if x != nil { - return x.I18NKey + return x.I18N } return "" } @@ -1146,6 +1166,13 @@ func (x *Resource) GetServiceName() string { return "" } +func (x *Resource) GetPolicy() string { + if x != nil { + return x.Policy + } + return "" +} + func (x *Resource) GetChildren() []*Resource { if x != nil { return x.Children @@ -2005,7 +2032,7 @@ var File_types_system_proto protoreflect.FileDescriptor const file_types_system_proto_rawDesc = "" + "\n" + - "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\x8e\x06\n" + + "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xac\x06\n" + "\x04View\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + @@ -2028,7 +2055,8 @@ const file_types_system_proto_rawDesc = "" + "properties\x12\x16\n" + "\x06status\x18\x11 \x01(\x05R\x06status\x12\x1c\n" + "\tparent_id\x18\x12 \x01(\x03R\tparent_id\x12 \n" + - "\vparent_path\x18\x13 \x01(\tR\vparent_path\x127\n" + + "\vparent_path\x18\x13 \x01(\tR\vparent_path\x12\x1c\n" + + "\tcomponent\x18\x14 \x01(\tR\tcomponent\x127\n" + "\bchildren\x18d \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + "\x06parent\x18e \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + "\tresources\x18f \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + @@ -2050,7 +2078,7 @@ const file_types_system_proto_rawDesc = "" + "\tresources\x18f \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\"\n" + "\fresource_ids\x18g \x03(\x03R\fresource_ids\x12C\n" + "\vpermissions\x18h \x03(\v2!.api.v1.services.types.PermissionR\vpermissions\x12&\n" + - "\x0epermission_ids\x18i \x03(\x03R\x0epermission_ids\"\xec\x06\n" + + "\x0epermission_ids\x18i \x03(\x03R\x0epermission_ids\"\x8c\a\n" + "\x04User\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12$\n" + "\rcreate_author\x18\x02 \x01(\x03R\rcreate_author\x12$\n" + @@ -2078,7 +2106,10 @@ const file_types_system_proto_rawDesc = "" + "\n" + "login_time\x18\x15 \x01(\v2\x1a.google.protobuf.TimestampR\n" + "login_time\x12E\n" + - "\rsanction_date\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x121\n" + + "\rsanction_date\x18\x16 \x01(\v2\x1a.google.protobuf.TimestampH\x00R\rsanction_date\x88\x01\x01\x12\x1e\n" + + "\n" + + "department\x18\x17 \x01(\tR\n" + + "department\x121\n" + "\x05roles\x18d \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\x12\x1a\n" + "\brole_ids\x18e \x03(\x03R\brole_idsB\x10\n" + "\x0e_sanction_date\"\xca\x02\n" + @@ -2098,14 +2129,14 @@ const file_types_system_proto_rawDesc = "" + "\arole_id\x18\x04 \x01(\x03R\arole_id\x12\x18\n" + "\aview_id\x18\x05 \x01(\x03R\aview_id\x12/\n" + "\x04role\x18d \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + - "\x04view\x18e \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\xd5\a\n" + + "\x04view\x18e \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\xe5\a\n" + "\bResource\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + "\vupdate_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\vupdate_time\x12\x12\n" + "\x04name\x18\x04 \x01(\tR\x04name\x12\x18\n" + - "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x1a\n" + - "\bi18n_key\x18\x06 \x01(\tR\bi18n_key\x12\x12\n" + + "\akeyword\x18\x05 \x01(\tR\akeyword\x12\x12\n" + + "\x04i18n\x18\x06 \x01(\tR\x04i18n\x12\x12\n" + "\x04type\x18\a \x01(\tR\x04type\x12\x16\n" + "\x06status\x18\b \x01(\x05R\x06status\x12\x12\n" + "\x04path\x18\t \x01(\tR\x04path\x12\x1c\n" + @@ -2123,7 +2154,8 @@ const file_types_system_proto_rawDesc = "" + "\vdescription\x18\x12 \x01(\tR\vdescription\x12\x1c\n" + "\tparent_id\x18\x13 \x01(\x03R\tparent_id\x12 \n" + "\vsync_status\x18\x14 \x01(\tR\vsync_status\x12\"\n" + - "\fservice_name\x18\x15 \x01(\tR\fservice_name\x12;\n" + + "\fservice_name\x18\x15 \x01(\tR\fservice_name\x12\x16\n" + + "\x06policy\x18\x16 \x01(\tR\x06policy\x12;\n" + "\bchildren\x18d \x03(\v2\x1f.api.v1.services.types.ResourceR\bchildren\x127\n" + "\x06parent\x18e \x01(\v2\x1f.api.v1.services.types.ResourceR\x06parent\x12&\n" + "\x0epermission_ids\x18f \x03(\x03R\x0epermission_ids\x12C\n" + diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index 8ec66789..81c5df3c 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -148,6 +148,8 @@ func (m *View) validate(all bool) error { // no validation rules for ParentPath + // no validation rules for Component + for idx, item := range m.GetChildren() { _, _ = idx, item @@ -835,6 +837,8 @@ func (m *User) validate(all bool) error { } } + // no validation rules for Department + for idx, item := range m.GetRoles() { _, _ = idx, item @@ -1509,7 +1513,7 @@ func (m *Resource) validate(all bool) error { // no validation rules for Keyword - // no validation rules for I18NKey + // no validation rules for I18N // no validation rules for Type @@ -1541,6 +1545,8 @@ func (m *Resource) validate(all bool) error { // no validation rules for ServiceName + // no validation rules for Policy + for idx, item := range m.GetChildren() { _, _ = idx, item diff --git a/buf.lock b/buf.lock index 008f0975..2e373e76 100644 --- a/buf.lock +++ b/buf.lock @@ -20,5 +20,5 @@ deps: commit: 7e6455be0f4e46b2bae60c64017ea644 digest: b5:e7f88ce9864519fe26d98d2424587a94a6a771fbfd0711da75a597a2e8b8bcb51db619456245b558c60ebc8662fa4aeeb0d867b3412c299f833f82100770ce3e - name: buf.build/protocolbuffers/wellknowntypes - commit: 9220c3cb4fac4bb4a8587d4fd7aa7582 - digest: b5:412c81d3f1549cc9ef52b364a11ab41d9ea6ba5e8e22a2b3f1f614c180b991a76503d715574e94ff77e33f216a1614a8026f1fc01aeaefdaf701155cb125e8bc + commit: 4e1ccfa6827947beb55974645a315b8d + digest: b5:eb5228b1abd02064d6ff0248918500c1ec1ce7df69126af3f220c0b67d81ff45bdf9f016a8e66cd9c1e534f18afc6d8e090d400604c5331d551a68d05f7e7be9 diff --git a/internal/conf/pb/captcha.pb.go b/internal/conf/pb/captcha.pb.go index d6a003ec..58f349b5 100644 --- a/internal/conf/pb/captcha.pb.go +++ b/internal/conf/pb/captcha.pb.go @@ -29,6 +29,7 @@ type Captcha struct { Maxskew float32 `protobuf:"fixed32,4,opt,name=maxskew,proto3" json:"maxskew,omitempty"` DotCount int32 `protobuf:"varint,5,opt,name=dot_count,proto3" json:"dot_count,omitempty"` CacheName string `protobuf:"bytes,6,opt,name=cache_name,proto3" json:"cache_name,omitempty"` + Language string `protobuf:"bytes,7,opt,name=language,proto3" json:"language,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -105,11 +106,18 @@ func (x *Captcha) GetCacheName() string { return "" } +func (x *Captcha) GetLanguage() string { + if x != nil { + return x.Language + } + return "" +} + var File_internal_conf_pb_captcha_proto protoreflect.FileDescriptor const file_internal_conf_pb_captcha_proto_rawDesc = "" + "\n" + - "\x1einternal/conf/pb/captcha.proto\x12\aconf.pb\"\xa7\x01\n" + + "\x1einternal/conf/pb/captcha.proto\x12\aconf.pb\"\xc3\x01\n" + "\aCaptcha\x12\x16\n" + "\x06length\x18\x01 \x01(\x05R\x06length\x12\x14\n" + "\x05width\x18\x02 \x01(\x05R\x05width\x12\x16\n" + @@ -118,7 +126,8 @@ const file_internal_conf_pb_captcha_proto_rawDesc = "" + "\tdot_count\x18\x05 \x01(\x05R\tdot_count\x12\x1e\n" + "\n" + "cache_name\x18\x06 \x01(\tR\n" + - "cache_nameB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" + "cache_name\x12\x1a\n" + + "\blanguage\x18\a \x01(\tR\blanguageB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" var ( file_internal_conf_pb_captcha_proto_rawDescOnce sync.Once diff --git a/internal/conf/pb/captcha.pb.validate.go b/internal/conf/pb/captcha.pb.validate.go index 83233bc9..e49b461d 100644 --- a/internal/conf/pb/captcha.pb.validate.go +++ b/internal/conf/pb/captcha.pb.validate.go @@ -68,6 +68,8 @@ func (m *Captcha) validate(all bool) error { // no validation rules for CacheName + // no validation rules for Language + if len(errors) > 0 { return CaptchaMultiError(errors) } diff --git a/internal/conf/pb/conf.pb.go b/internal/conf/pb/conf.pb.go index 21247da2..2e6b7541 100644 --- a/internal/conf/pb/conf.pb.go +++ b/internal/conf/pb/conf.pb.go @@ -47,11 +47,11 @@ type Bootstrap struct { // Security configuration for authentication and authorization. Security *v15.Security `protobuf:"bytes,8,opt,name=security,proto3" json:"security,omitempty"` // Captcha feature specific configuration. - Captcha *Captcha `protobuf:"bytes,9,opt,name=captcha,proto3" json:"captcha,omitempty"` + Captcha *Captcha `protobuf:"bytes,10,opt,name=captcha,proto3" json:"captcha,omitempty"` // RootUser feature specific configuration for initial user setup. - RootUser *RootUser `protobuf:"bytes,10,opt,name=root_user,json=rootUser,proto3" json:"root_user,omitempty"` + RootUser *RootUser `protobuf:"bytes,11,opt,name=root_user,json=rootUser,proto3" json:"root_user,omitempty"` // Default discovery service name. - DefaultDiscovery string `protobuf:"bytes,11,opt,name=default_discovery,json=defaultDiscovery,proto3" json:"default_discovery,omitempty"` + DefaultDiscovery string `protobuf:"bytes,12,opt,name=default_discovery,json=defaultDiscovery,proto3" json:"default_discovery,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -213,7 +213,7 @@ var File_internal_conf_pb_conf_proto protoreflect.FileDescriptor const file_internal_conf_pb_conf_proto_rawDesc = "" + "\n" + - "\x1binternal/conf/pb/conf.proto\x12\aconf.pb\x1a\x19config/data/v1/data.proto\x1a#config/discovery/v1/discovery.proto\x1a\x1dconfig/logger/v1/logger.proto\x1a%config/middleware/v1/middleware.proto\x1a#config/transport/v1/transport.proto\x1a\x1asecurity/v1/security.proto\x1a\x1einternal/conf/pb/captcha.proto\x1a\x1binternal/conf/pb/root.proto\"\xb2\x05\n" + + "\x1binternal/conf/pb/conf.proto\x12\aconf.pb\x1a\x19config/data/v1/data.proto\x1a#config/discovery/v1/discovery.proto\x1a\x1dconfig/logger/v1/logger.proto\x1a%config/middleware/v1/middleware.proto\x1a#config/transport/v1/transport.proto\x1a\x1einternal/conf/pb/captcha.proto\x1a\x1binternal/conf/pb/root.proto\x1a\x1asecurity/v1/security.proto\"\xb2\x05\n" + "\tBootstrap\x12B\n" + "\aservers\x18\x01 \x01(\v2(.runtime.api.config.transport.v1.ServersR\aservers\x12B\n" + "\aclients\x18\x02 \x01(\v2(.runtime.api.config.transport.v1.ClientsR\aclients\x12@\n" + @@ -223,10 +223,10 @@ const file_internal_conf_pb_conf_proto_rawDesc = "" + "\x06logger\x18\x06 \x01(\v2$.runtime.api.config.logger.v1.LoggerR\x06logger\x12O\n" + "\vmiddlewares\x18\a \x01(\v2-.runtime.api.config.middleware.v1.MiddlewaresR\vmiddlewares\x12=\n" + "\bsecurity\x18\b \x01(\v2!.contrib.api.security.v1.SecurityR\bsecurity\x12*\n" + - "\acaptcha\x18\t \x01(\v2\x10.conf.pb.CaptchaR\acaptcha\x12.\n" + - "\troot_user\x18\n" + - " \x01(\v2\x11.conf.pb.RootUserR\brootUser\x12+\n" + - "\x11default_discovery\x18\v \x01(\tR\x10defaultDiscovery\"*\n" + + "\acaptcha\x18\n" + + " \x01(\v2\x10.conf.pb.CaptchaR\acaptcha\x12.\n" + + "\troot_user\x18\v \x01(\v2\x11.conf.pb.RootUserR\brootUser\x12+\n" + + "\x11default_discovery\x18\f \x01(\tR\x10defaultDiscovery\"*\n" + "\x0eSelectorGlobal\x12\x18\n" + "\abuilder\x18\x01 \x01(\tR\abuilderB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" diff --git a/internal/conf/pb/conf.proto b/internal/conf/pb/conf.proto index aac4b57c..81b3ae27 100644 --- a/internal/conf/pb/conf.proto +++ b/internal/conf/pb/conf.proto @@ -5,7 +5,6 @@ package conf.pb; import "config/data/v1/data.proto"; import "config/discovery/v1/discovery.proto"; import "config/logger/v1/logger.proto"; -import "config/middleware/cors/v1/cors.proto"; import "config/middleware/v1/middleware.proto"; import "config/transport/v1/transport.proto"; import "internal/conf/pb/captcha.proto"; diff --git a/internal/conf/pb/root.pb.go b/internal/conf/pb/root.pb.go index 7842757c..87fa01ce 100644 --- a/internal/conf/pb/root.pb.go +++ b/internal/conf/pb/root.pb.go @@ -7,7 +7,6 @@ package confpb import ( - _ "github.com/envoyproxy/protoc-gen-validate/validate" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -22,23 +21,22 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// RootUser defines the configuration for the initial administrator user. +// This is used by the seed command. type RootUser struct { - state protoimpl.MessageState `protogen:"open.v1"` - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` - Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"` - Salt string `protobuf:"bytes,5,opt,name=salt,proto3" json:"salt,omitempty"` - Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` - Email string `protobuf:"bytes,7,opt,name=email,proto3" json:"email,omitempty"` - Nickname string `protobuf:"bytes,8,opt,name=nickname,proto3" json:"nickname,omitempty"` - Avatar string `protobuf:"bytes,9,opt,name=avatar,proto3" json:"avatar,omitempty"` - Mobile string `protobuf:"bytes,10,opt,name=mobile,proto3" json:"mobile,omitempty"` - Description string `protobuf:"bytes,11,opt,name=description,proto3" json:"description,omitempty"` - AutoCreate bool `protobuf:"varint,100,opt,name=auto_create,proto3" json:"auto_create,omitempty"` - RandomPassword bool `protobuf:"varint,101,opt,name=random_password,proto3" json:"random_password,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + // enabled controls whether the root user initialization task should run. + Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` + // username for the root user. + Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` + // password for the root user. It is strongly recommended to change this after the first login. + Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` + // nickname for the root user. + Nickname *string `protobuf:"bytes,4,opt,name=nickname,proto3,oneof" json:"nickname,omitempty"` + // email for the root user. + Email *string `protobuf:"bytes,5,opt,name=email,proto3,oneof" json:"email,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *RootUser) Reset() { @@ -78,13 +76,6 @@ func (x *RootUser) GetEnabled() bool { return false } -func (x *RootUser) GetId() string { - if x != nil { - return x.Id - } - return "" -} - func (x *RootUser) GetUsername() string { if x != nil { return x.Username @@ -99,89 +90,33 @@ func (x *RootUser) GetPassword() string { return "" } -func (x *RootUser) GetSalt() string { - if x != nil { - return x.Salt - } - return "" -} - -func (x *RootUser) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *RootUser) GetEmail() string { - if x != nil { - return x.Email - } - return "" -} - func (x *RootUser) GetNickname() string { - if x != nil { - return x.Nickname + if x != nil && x.Nickname != nil { + return *x.Nickname } return "" } -func (x *RootUser) GetAvatar() string { - if x != nil { - return x.Avatar - } - return "" -} - -func (x *RootUser) GetMobile() string { - if x != nil { - return x.Mobile - } - return "" -} - -func (x *RootUser) GetDescription() string { - if x != nil { - return x.Description +func (x *RootUser) GetEmail() string { + if x != nil && x.Email != nil { + return *x.Email } return "" } -func (x *RootUser) GetAutoCreate() bool { - if x != nil { - return x.AutoCreate - } - return false -} - -func (x *RootUser) GetRandomPassword() bool { - if x != nil { - return x.RandomPassword - } - return false -} - var File_internal_conf_pb_root_proto protoreflect.FileDescriptor const file_internal_conf_pb_root_proto_rawDesc = "" + "\n" + - "\x1binternal/conf/pb/root.proto\x12\aconf.pb\x1a\x17validate/validate.proto\"\x8c\x03\n" + + "\x1binternal/conf/pb/root.proto\x12\aconf.pb\"\xaf\x01\n" + "\bRootUser\x12\x18\n" + - "\aenabled\x18\x01 \x01(\bR\aenabled\x12\x17\n" + - "\x02id\x18\x02 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\x02id\x12#\n" + - "\busername\x18\x03 \x01(\tB\a\xfaB\x04r\x02\x10\x01R\busername\x12%\n" + - "\bpassword\x18\x04 \x01(\tB\t\xfaB\x06r\x04\x10\x06\x18 R\bpassword\x12\x1d\n" + - "\x04salt\x18\x05 \x01(\tB\t\xfaB\x06r\x04\x10\x06\x18\fR\x04salt\x12\x12\n" + - "\x04name\x18\x06 \x01(\tR\x04name\x12\x14\n" + - "\x05email\x18\a \x01(\tR\x05email\x12\x1a\n" + - "\bnickname\x18\b \x01(\tR\bnickname\x12\x16\n" + - "\x06avatar\x18\t \x01(\tR\x06avatar\x12\x16\n" + - "\x06mobile\x18\n" + - " \x01(\tR\x06mobile\x12 \n" + - "\vdescription\x18\v \x01(\tR\vdescription\x12 \n" + - "\vauto_create\x18d \x01(\bR\vauto_create\x12(\n" + - "\x0frandom_password\x18e \x01(\bR\x0frandom_passwordB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" + "\aenabled\x18\x01 \x01(\bR\aenabled\x12\x1a\n" + + "\busername\x18\x02 \x01(\tR\busername\x12\x1a\n" + + "\bpassword\x18\x03 \x01(\tR\bpassword\x12\x1f\n" + + "\bnickname\x18\x04 \x01(\tH\x00R\bnickname\x88\x01\x01\x12\x19\n" + + "\x05email\x18\x05 \x01(\tH\x01R\x05email\x88\x01\x01B\v\n" + + "\t_nicknameB\b\n" + + "\x06_emailB5Z3origadmin/application/admin/internal/conf/pb;confpbb\x06proto3" var ( file_internal_conf_pb_root_proto_rawDescOnce sync.Once @@ -212,6 +147,7 @@ func file_internal_conf_pb_root_proto_init() { if File_internal_conf_pb_root_proto != nil { return } + file_internal_conf_pb_root_proto_msgTypes[0].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/internal/conf/pb/root.pb.validate.go b/internal/conf/pb/root.pb.validate.go index 63adc558..84161cad 100644 --- a/internal/conf/pb/root.pb.validate.go +++ b/internal/conf/pb/root.pb.validate.go @@ -59,66 +59,18 @@ func (m *RootUser) validate(all bool) error { // no validation rules for Enabled - if utf8.RuneCountInString(m.GetId()) < 1 { - err := RootUserValidationError{ - field: "Id", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } + // no validation rules for Username - if utf8.RuneCountInString(m.GetUsername()) < 1 { - err := RootUserValidationError{ - field: "Username", - reason: "value length must be at least 1 runes", - } - if !all { - return err - } - errors = append(errors, err) - } + // no validation rules for Password - if l := utf8.RuneCountInString(m.GetPassword()); l < 6 || l > 32 { - err := RootUserValidationError{ - field: "Password", - reason: "value length must be between 6 and 32 runes, inclusive", - } - if !all { - return err - } - errors = append(errors, err) + if m.Nickname != nil { + // no validation rules for Nickname } - if l := utf8.RuneCountInString(m.GetSalt()); l < 6 || l > 12 { - err := RootUserValidationError{ - field: "Salt", - reason: "value length must be between 6 and 12 runes, inclusive", - } - if !all { - return err - } - errors = append(errors, err) + if m.Email != nil { + // no validation rules for Email } - // no validation rules for Name - - // no validation rules for Email - - // no validation rules for Nickname - - // no validation rules for Avatar - - // no validation rules for Mobile - - // no validation rules for Description - - // no validation rules for AutoCreate - - // no validation rules for RandomPassword - if len(errors) > 0 { return RootUserMultiError(errors) } diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index b3a9ab2f..512eaa10 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Resource\"},\"unique\":true,\"inverse\":true},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.resource.field.parent_id\"},{\"name\":\"properties\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.i18n\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.i18n\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.description\"},{\"name\":\"properties\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.properties\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Resource\"},\"unique\":true,\"inverse\":true},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"API\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.resource.field.parent_id\"},{\"name\":\"properties\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.i18n\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.i18n\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.description\"},{\"name\":\"properties\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.properties\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index 736733f7..1235a0f9 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -272,21 +272,21 @@ var ( {Name: "update_time", Type: field.TypeTime, Comment: "update_time.field.comment"}, {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.resource.field.keyword"}, {Name: "name", Type: field.TypeString, Comment: "entity.resource.field.name", Default: ""}, - {Name: "i18n", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.i18n"}, - {Name: "type", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.type"}, + {Name: "i18n", Type: field.TypeString, Comment: "entity.resource.field.i18n", Default: ""}, + {Name: "type", Type: field.TypeString, Comment: "entity.resource.field.type", Default: "API"}, {Name: "status", Type: field.TypeInt8, Comment: "entity.resource.field.status", Default: 1}, {Name: "sequence", Type: field.TypeInt, Comment: "entity.resource.field.sequence", Default: 0}, - {Name: "method", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.method"}, - {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.path"}, - {Name: "operation", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.operation"}, + {Name: "method", Type: field.TypeString, Comment: "entity.resource.field.method", Default: ""}, + {Name: "path", Type: field.TypeString, Comment: "entity.resource.field.path", Default: ""}, + {Name: "operation", Type: field.TypeString, Comment: "entity.resource.field.operation", Default: ""}, {Name: "service_name", Type: field.TypeString, Comment: "entity.resource.field.service_name", Default: ""}, {Name: "policy", Type: field.TypeString, Comment: "entity.resource.field.policy", Default: ""}, {Name: "version_id", Type: field.TypeString, Comment: "entity.resource.field.version_id", Default: ""}, {Name: "last_sync_version_id", Type: field.TypeString, Comment: "entity.resource.field.last_sync_version_id", Default: ""}, {Name: "sync_status", Type: field.TypeString, Comment: "entity.resource.field.sync_status", Default: "Synced"}, - {Name: "tree_path", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.tree_path"}, - {Name: "properties", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.properties"}, - {Name: "description", Type: field.TypeString, Nullable: true, Comment: "entity.resource.field.description"}, + {Name: "tree_path", Type: field.TypeString, Comment: "entity.resource.field.tree_path", Default: ""}, + {Name: "properties", Type: field.TypeString, Comment: "entity.resource.field.properties", Default: ""}, + {Name: "description", Type: field.TypeString, Comment: "entity.resource.field.description", Default: ""}, {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "entity.resource.field.parent_id"}, } // SysResourcesTable holds the schema information for the "sys_resources" table. @@ -591,16 +591,16 @@ var ( {Name: "keyword", Type: field.TypeString, Unique: true, Size: 255, Comment: "entity.view.field.keyword"}, {Name: "scope", Type: field.TypeString, Comment: "entity.view.field.scope", Default: "default"}, {Name: "name", Type: field.TypeString, Comment: "entity.view.field.name"}, - {Name: "i18n", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.i18n"}, + {Name: "i18n", Type: field.TypeString, Comment: "entity.view.field.i18n", Default: ""}, {Name: "type", Type: field.TypeEnum, Comment: "entity.view.field.type", Enums: []string{"T", "G", "M", "L", "P", "B", "E", "R", "U"}, Default: "U"}, - {Name: "component", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.component"}, - {Name: "path", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.path"}, - {Name: "icon", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.icon"}, + {Name: "component", Type: field.TypeString, Comment: "entity.view.field.component", Default: ""}, + {Name: "path", Type: field.TypeString, Comment: "entity.view.field.path", Default: ""}, + {Name: "icon", Type: field.TypeString, Comment: "entity.view.field.icon", Default: ""}, {Name: "visible", Type: field.TypeBool, Comment: "entity.view.field.visible", Default: true}, {Name: "sequence", Type: field.TypeInt, Comment: "entity.view.field.sequence", Default: 0}, - {Name: "tree_path", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.tree_path"}, - {Name: "description", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.description"}, - {Name: "properties", Type: field.TypeString, Nullable: true, Comment: "entity.view.field.properties"}, + {Name: "tree_path", Type: field.TypeString, Comment: "entity.view.field.tree_path", Default: ""}, + {Name: "description", Type: field.TypeString, Comment: "entity.view.field.description", Default: ""}, + {Name: "properties", Type: field.TypeString, Comment: "entity.view.field.properties", Default: ""}, {Name: "status", Type: field.TypeInt8, Comment: "entity.view.field.status", Default: 1}, {Name: "parent_id", Type: field.TypeInt64, Nullable: true, Comment: "entity.view.field.parent_id"}, } diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index 7e27bb0e..d5bfb565 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -6709,22 +6709,9 @@ func (m *ResourceMutation) OldI18n(ctx context.Context) (v string, err error) { return oldValue.I18n, nil } -// ClearI18n clears the value of the "i18n" field. -func (m *ResourceMutation) ClearI18n() { - m.i18n = nil - m.clearedFields[resource.FieldI18n] = struct{}{} -} - -// I18nCleared returns if the "i18n" field was cleared in this mutation. -func (m *ResourceMutation) I18nCleared() bool { - _, ok := m.clearedFields[resource.FieldI18n] - return ok -} - // ResetI18n resets all changes to the "i18n" field. func (m *ResourceMutation) ResetI18n() { m.i18n = nil - delete(m.clearedFields, resource.FieldI18n) } // SetType sets the "type" field. @@ -6758,22 +6745,9 @@ func (m *ResourceMutation) OldType(ctx context.Context) (v string, err error) { return oldValue.Type, nil } -// ClearType clears the value of the "type" field. -func (m *ResourceMutation) ClearType() { - m._type = nil - m.clearedFields[resource.FieldType] = struct{}{} -} - -// TypeCleared returns if the "type" field was cleared in this mutation. -func (m *ResourceMutation) TypeCleared() bool { - _, ok := m.clearedFields[resource.FieldType] - return ok -} - // ResetType resets all changes to the "type" field. func (m *ResourceMutation) ResetType() { m._type = nil - delete(m.clearedFields, resource.FieldType) } // SetStatus sets the "status" field. @@ -6919,22 +6893,9 @@ func (m *ResourceMutation) OldMethod(ctx context.Context) (v string, err error) return oldValue.Method, nil } -// ClearMethod clears the value of the "method" field. -func (m *ResourceMutation) ClearMethod() { - m.method = nil - m.clearedFields[resource.FieldMethod] = struct{}{} -} - -// MethodCleared returns if the "method" field was cleared in this mutation. -func (m *ResourceMutation) MethodCleared() bool { - _, ok := m.clearedFields[resource.FieldMethod] - return ok -} - // ResetMethod resets all changes to the "method" field. func (m *ResourceMutation) ResetMethod() { m.method = nil - delete(m.clearedFields, resource.FieldMethod) } // SetPath sets the "path" field. @@ -6968,22 +6929,9 @@ func (m *ResourceMutation) OldPath(ctx context.Context) (v string, err error) { return oldValue.Path, nil } -// ClearPath clears the value of the "path" field. -func (m *ResourceMutation) ClearPath() { - m._path = nil - m.clearedFields[resource.FieldPath] = struct{}{} -} - -// PathCleared returns if the "path" field was cleared in this mutation. -func (m *ResourceMutation) PathCleared() bool { - _, ok := m.clearedFields[resource.FieldPath] - return ok -} - // ResetPath resets all changes to the "path" field. func (m *ResourceMutation) ResetPath() { m._path = nil - delete(m.clearedFields, resource.FieldPath) } // SetOperation sets the "operation" field. @@ -7017,22 +6965,9 @@ func (m *ResourceMutation) OldOperation(ctx context.Context) (v string, err erro return oldValue.Operation, nil } -// ClearOperation clears the value of the "operation" field. -func (m *ResourceMutation) ClearOperation() { - m.operation = nil - m.clearedFields[resource.FieldOperation] = struct{}{} -} - -// OperationCleared returns if the "operation" field was cleared in this mutation. -func (m *ResourceMutation) OperationCleared() bool { - _, ok := m.clearedFields[resource.FieldOperation] - return ok -} - // ResetOperation resets all changes to the "operation" field. func (m *ResourceMutation) ResetOperation() { m.operation = nil - delete(m.clearedFields, resource.FieldOperation) } // SetServiceName sets the "service_name" field. @@ -7246,22 +7181,9 @@ func (m *ResourceMutation) OldTreePath(ctx context.Context) (v string, err error return oldValue.TreePath, nil } -// ClearTreePath clears the value of the "tree_path" field. -func (m *ResourceMutation) ClearTreePath() { - m.tree_path = nil - m.clearedFields[resource.FieldTreePath] = struct{}{} -} - -// TreePathCleared returns if the "tree_path" field was cleared in this mutation. -func (m *ResourceMutation) TreePathCleared() bool { - _, ok := m.clearedFields[resource.FieldTreePath] - return ok -} - // ResetTreePath resets all changes to the "tree_path" field. func (m *ResourceMutation) ResetTreePath() { m.tree_path = nil - delete(m.clearedFields, resource.FieldTreePath) } // SetParentID sets the "parent_id" field. @@ -7344,22 +7266,9 @@ func (m *ResourceMutation) OldProperties(ctx context.Context) (v string, err err return oldValue.Properties, nil } -// ClearProperties clears the value of the "properties" field. -func (m *ResourceMutation) ClearProperties() { - m.properties = nil - m.clearedFields[resource.FieldProperties] = struct{}{} -} - -// PropertiesCleared returns if the "properties" field was cleared in this mutation. -func (m *ResourceMutation) PropertiesCleared() bool { - _, ok := m.clearedFields[resource.FieldProperties] - return ok -} - // ResetProperties resets all changes to the "properties" field. func (m *ResourceMutation) ResetProperties() { m.properties = nil - delete(m.clearedFields, resource.FieldProperties) } // SetDescription sets the "description" field. @@ -7393,22 +7302,9 @@ func (m *ResourceMutation) OldDescription(ctx context.Context) (v string, err er return oldValue.Description, nil } -// ClearDescription clears the value of the "description" field. -func (m *ResourceMutation) ClearDescription() { - m.description = nil - m.clearedFields[resource.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *ResourceMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[resource.FieldDescription] - return ok -} - // ResetDescription resets all changes to the "description" field. func (m *ResourceMutation) ResetDescription() { m.description = nil - delete(m.clearedFields, resource.FieldDescription) } // ClearParent clears the "parent" edge to the Resource entity. @@ -8052,33 +7948,9 @@ func (m *ResourceMutation) AddField(name string, value ent.Value) error { // mutation. func (m *ResourceMutation) ClearedFields() []string { var fields []string - if m.FieldCleared(resource.FieldI18n) { - fields = append(fields, resource.FieldI18n) - } - if m.FieldCleared(resource.FieldType) { - fields = append(fields, resource.FieldType) - } - if m.FieldCleared(resource.FieldMethod) { - fields = append(fields, resource.FieldMethod) - } - if m.FieldCleared(resource.FieldPath) { - fields = append(fields, resource.FieldPath) - } - if m.FieldCleared(resource.FieldOperation) { - fields = append(fields, resource.FieldOperation) - } - if m.FieldCleared(resource.FieldTreePath) { - fields = append(fields, resource.FieldTreePath) - } if m.FieldCleared(resource.FieldParentID) { fields = append(fields, resource.FieldParentID) } - if m.FieldCleared(resource.FieldProperties) { - fields = append(fields, resource.FieldProperties) - } - if m.FieldCleared(resource.FieldDescription) { - fields = append(fields, resource.FieldDescription) - } return fields } @@ -8093,33 +7965,9 @@ func (m *ResourceMutation) FieldCleared(name string) bool { // error if the field is not defined in the schema. func (m *ResourceMutation) ClearField(name string) error { switch name { - case resource.FieldI18n: - m.ClearI18n() - return nil - case resource.FieldType: - m.ClearType() - return nil - case resource.FieldMethod: - m.ClearMethod() - return nil - case resource.FieldPath: - m.ClearPath() - return nil - case resource.FieldOperation: - m.ClearOperation() - return nil - case resource.FieldTreePath: - m.ClearTreePath() - return nil case resource.FieldParentID: m.ClearParentID() return nil - case resource.FieldProperties: - m.ClearProperties() - return nil - case resource.FieldDescription: - m.ClearDescription() - return nil } return fmt.Errorf("unknown Resource nullable field %s", name) } @@ -14296,22 +14144,9 @@ func (m *ViewMutation) OldI18n(ctx context.Context) (v string, err error) { return oldValue.I18n, nil } -// ClearI18n clears the value of the "i18n" field. -func (m *ViewMutation) ClearI18n() { - m.i18n = nil - m.clearedFields[view.FieldI18n] = struct{}{} -} - -// I18nCleared returns if the "i18n" field was cleared in this mutation. -func (m *ViewMutation) I18nCleared() bool { - _, ok := m.clearedFields[view.FieldI18n] - return ok -} - // ResetI18n resets all changes to the "i18n" field. func (m *ViewMutation) ResetI18n() { m.i18n = nil - delete(m.clearedFields, view.FieldI18n) } // SetType sets the "type" field. @@ -14381,22 +14216,9 @@ func (m *ViewMutation) OldComponent(ctx context.Context) (v string, err error) { return oldValue.Component, nil } -// ClearComponent clears the value of the "component" field. -func (m *ViewMutation) ClearComponent() { - m.component = nil - m.clearedFields[view.FieldComponent] = struct{}{} -} - -// ComponentCleared returns if the "component" field was cleared in this mutation. -func (m *ViewMutation) ComponentCleared() bool { - _, ok := m.clearedFields[view.FieldComponent] - return ok -} - // ResetComponent resets all changes to the "component" field. func (m *ViewMutation) ResetComponent() { m.component = nil - delete(m.clearedFields, view.FieldComponent) } // SetPath sets the "path" field. @@ -14430,22 +14252,9 @@ func (m *ViewMutation) OldPath(ctx context.Context) (v string, err error) { return oldValue.Path, nil } -// ClearPath clears the value of the "path" field. -func (m *ViewMutation) ClearPath() { - m._path = nil - m.clearedFields[view.FieldPath] = struct{}{} -} - -// PathCleared returns if the "path" field was cleared in this mutation. -func (m *ViewMutation) PathCleared() bool { - _, ok := m.clearedFields[view.FieldPath] - return ok -} - // ResetPath resets all changes to the "path" field. func (m *ViewMutation) ResetPath() { m._path = nil - delete(m.clearedFields, view.FieldPath) } // SetIcon sets the "icon" field. @@ -14479,22 +14288,9 @@ func (m *ViewMutation) OldIcon(ctx context.Context) (v string, err error) { return oldValue.Icon, nil } -// ClearIcon clears the value of the "icon" field. -func (m *ViewMutation) ClearIcon() { - m.icon = nil - m.clearedFields[view.FieldIcon] = struct{}{} -} - -// IconCleared returns if the "icon" field was cleared in this mutation. -func (m *ViewMutation) IconCleared() bool { - _, ok := m.clearedFields[view.FieldIcon] - return ok -} - // ResetIcon resets all changes to the "icon" field. func (m *ViewMutation) ResetIcon() { m.icon = nil - delete(m.clearedFields, view.FieldIcon) } // SetVisible sets the "visible" field. @@ -14620,22 +14416,9 @@ func (m *ViewMutation) OldTreePath(ctx context.Context) (v string, err error) { return oldValue.TreePath, nil } -// ClearTreePath clears the value of the "tree_path" field. -func (m *ViewMutation) ClearTreePath() { - m.tree_path = nil - m.clearedFields[view.FieldTreePath] = struct{}{} -} - -// TreePathCleared returns if the "tree_path" field was cleared in this mutation. -func (m *ViewMutation) TreePathCleared() bool { - _, ok := m.clearedFields[view.FieldTreePath] - return ok -} - // ResetTreePath resets all changes to the "tree_path" field. func (m *ViewMutation) ResetTreePath() { m.tree_path = nil - delete(m.clearedFields, view.FieldTreePath) } // SetDescription sets the "description" field. @@ -14669,22 +14452,9 @@ func (m *ViewMutation) OldDescription(ctx context.Context) (v string, err error) return oldValue.Description, nil } -// ClearDescription clears the value of the "description" field. -func (m *ViewMutation) ClearDescription() { - m.description = nil - m.clearedFields[view.FieldDescription] = struct{}{} -} - -// DescriptionCleared returns if the "description" field was cleared in this mutation. -func (m *ViewMutation) DescriptionCleared() bool { - _, ok := m.clearedFields[view.FieldDescription] - return ok -} - // ResetDescription resets all changes to the "description" field. func (m *ViewMutation) ResetDescription() { m.description = nil - delete(m.clearedFields, view.FieldDescription) } // SetProperties sets the "properties" field. @@ -14718,22 +14488,9 @@ func (m *ViewMutation) OldProperties(ctx context.Context) (v string, err error) return oldValue.Properties, nil } -// ClearProperties clears the value of the "properties" field. -func (m *ViewMutation) ClearProperties() { - m.properties = nil - m.clearedFields[view.FieldProperties] = struct{}{} -} - -// PropertiesCleared returns if the "properties" field was cleared in this mutation. -func (m *ViewMutation) PropertiesCleared() bool { - _, ok := m.clearedFields[view.FieldProperties] - return ok -} - // ResetProperties resets all changes to the "properties" field. func (m *ViewMutation) ResetProperties() { m.properties = nil - delete(m.clearedFields, view.FieldProperties) } // SetStatus sets the "status" field. @@ -15448,27 +15205,6 @@ func (m *ViewMutation) ClearedFields() []string { if m.FieldCleared(view.FieldParentID) { fields = append(fields, view.FieldParentID) } - if m.FieldCleared(view.FieldI18n) { - fields = append(fields, view.FieldI18n) - } - if m.FieldCleared(view.FieldComponent) { - fields = append(fields, view.FieldComponent) - } - if m.FieldCleared(view.FieldPath) { - fields = append(fields, view.FieldPath) - } - if m.FieldCleared(view.FieldIcon) { - fields = append(fields, view.FieldIcon) - } - if m.FieldCleared(view.FieldTreePath) { - fields = append(fields, view.FieldTreePath) - } - if m.FieldCleared(view.FieldDescription) { - fields = append(fields, view.FieldDescription) - } - if m.FieldCleared(view.FieldProperties) { - fields = append(fields, view.FieldProperties) - } return fields } @@ -15486,27 +15222,6 @@ func (m *ViewMutation) ClearField(name string) error { case view.FieldParentID: m.ClearParentID() return nil - case view.FieldI18n: - m.ClearI18n() - return nil - case view.FieldComponent: - m.ClearComponent() - return nil - case view.FieldPath: - m.ClearPath() - return nil - case view.FieldIcon: - m.ClearIcon() - return nil - case view.FieldTreePath: - m.ClearTreePath() - return nil - case view.FieldDescription: - m.ClearDescription() - return nil - case view.FieldProperties: - m.ClearProperties() - return nil } return fmt.Errorf("unknown View nullable field %s", name) } diff --git a/internal/data/entity/ent/resource/resource.go b/internal/data/entity/ent/resource/resource.go index 4e3a960b..5ae73911 100644 --- a/internal/data/entity/ent/resource/resource.go +++ b/internal/data/entity/ent/resource/resource.go @@ -149,10 +149,20 @@ var ( KeywordValidator func(string) error // DefaultName holds the default value on creation for the "name" field. DefaultName string + // DefaultI18n holds the default value on creation for the "i18n" field. + DefaultI18n string + // DefaultType holds the default value on creation for the "type" field. + DefaultType string // DefaultStatus holds the default value on creation for the "status" field. DefaultStatus enums.Status // DefaultSequence holds the default value on creation for the "sequence" field. DefaultSequence int + // DefaultMethod holds the default value on creation for the "method" field. + DefaultMethod string + // DefaultPath holds the default value on creation for the "path" field. + DefaultPath string + // DefaultOperation holds the default value on creation for the "operation" field. + DefaultOperation string // DefaultServiceName holds the default value on creation for the "service_name" field. DefaultServiceName string // DefaultPolicy holds the default value on creation for the "policy" field. @@ -163,6 +173,12 @@ var ( DefaultLastSyncVersionID string // DefaultSyncStatus holds the default value on creation for the "sync_status" field. DefaultSyncStatus string + // DefaultTreePath holds the default value on creation for the "tree_path" field. + DefaultTreePath string + // DefaultProperties holds the default value on creation for the "properties" field. + DefaultProperties string + // DefaultDescription holds the default value on creation for the "description" field. + DefaultDescription string // DefaultID holds the default value on creation for the "id" field. DefaultID func() int64 // IDValidator is a validator for the "id" field. It is called by the builders before save. diff --git a/internal/data/entity/ent/resource/where.go b/internal/data/entity/ent/resource/where.go index 0985c143..36ec7ff2 100644 --- a/internal/data/entity/ent/resource/where.go +++ b/internal/data/entity/ent/resource/where.go @@ -417,16 +417,6 @@ func I18nHasSuffix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasSuffix(FieldI18n, v)) } -// I18nIsNil applies the IsNil predicate on the "i18n" field. -func I18nIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldI18n)) -} - -// I18nNotNil applies the NotNil predicate on the "i18n" field. -func I18nNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldI18n)) -} - // I18nEqualFold applies the EqualFold predicate on the "i18n" field. func I18nEqualFold(v string) predicate.Resource { return predicate.Resource(sql.FieldEqualFold(FieldI18n, v)) @@ -492,16 +482,6 @@ func TypeHasSuffix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasSuffix(FieldType, v)) } -// TypeIsNil applies the IsNil predicate on the "type" field. -func TypeIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldType)) -} - -// TypeNotNil applies the NotNil predicate on the "type" field. -func TypeNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldType)) -} - // TypeEqualFold applies the EqualFold predicate on the "type" field. func TypeEqualFold(v string) predicate.Resource { return predicate.Resource(sql.FieldEqualFold(FieldType, v)) @@ -661,16 +641,6 @@ func MethodHasSuffix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasSuffix(FieldMethod, v)) } -// MethodIsNil applies the IsNil predicate on the "method" field. -func MethodIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldMethod)) -} - -// MethodNotNil applies the NotNil predicate on the "method" field. -func MethodNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldMethod)) -} - // MethodEqualFold applies the EqualFold predicate on the "method" field. func MethodEqualFold(v string) predicate.Resource { return predicate.Resource(sql.FieldEqualFold(FieldMethod, v)) @@ -736,16 +706,6 @@ func PathHasSuffix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasSuffix(FieldPath, v)) } -// PathIsNil applies the IsNil predicate on the "path" field. -func PathIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldPath)) -} - -// PathNotNil applies the NotNil predicate on the "path" field. -func PathNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldPath)) -} - // PathEqualFold applies the EqualFold predicate on the "path" field. func PathEqualFold(v string) predicate.Resource { return predicate.Resource(sql.FieldEqualFold(FieldPath, v)) @@ -811,16 +771,6 @@ func OperationHasSuffix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasSuffix(FieldOperation, v)) } -// OperationIsNil applies the IsNil predicate on the "operation" field. -func OperationIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldOperation)) -} - -// OperationNotNil applies the NotNil predicate on the "operation" field. -func OperationNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldOperation)) -} - // OperationEqualFold applies the EqualFold predicate on the "operation" field. func OperationEqualFold(v string) predicate.Resource { return predicate.Resource(sql.FieldEqualFold(FieldOperation, v)) @@ -1211,16 +1161,6 @@ func TreePathHasSuffix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasSuffix(FieldTreePath, v)) } -// TreePathIsNil applies the IsNil predicate on the "tree_path" field. -func TreePathIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldTreePath)) -} - -// TreePathNotNil applies the NotNil predicate on the "tree_path" field. -func TreePathNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldTreePath)) -} - // TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. func TreePathEqualFold(v string) predicate.Resource { return predicate.Resource(sql.FieldEqualFold(FieldTreePath, v)) @@ -1316,16 +1256,6 @@ func PropertiesHasSuffix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasSuffix(FieldProperties, v)) } -// PropertiesIsNil applies the IsNil predicate on the "properties" field. -func PropertiesIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldProperties)) -} - -// PropertiesNotNil applies the NotNil predicate on the "properties" field. -func PropertiesNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldProperties)) -} - // PropertiesEqualFold applies the EqualFold predicate on the "properties" field. func PropertiesEqualFold(v string) predicate.Resource { return predicate.Resource(sql.FieldEqualFold(FieldProperties, v)) @@ -1391,16 +1321,6 @@ func DescriptionHasSuffix(v string) predicate.Resource { return predicate.Resource(sql.FieldHasSuffix(FieldDescription, v)) } -// DescriptionIsNil applies the IsNil predicate on the "description" field. -func DescriptionIsNil() predicate.Resource { - return predicate.Resource(sql.FieldIsNull(FieldDescription)) -} - -// DescriptionNotNil applies the NotNil predicate on the "description" field. -func DescriptionNotNil() predicate.Resource { - return predicate.Resource(sql.FieldNotNull(FieldDescription)) -} - // DescriptionEqualFold applies the EqualFold predicate on the "description" field. func DescriptionEqualFold(v string) predicate.Resource { return predicate.Resource(sql.FieldEqualFold(FieldDescription, v)) diff --git a/internal/data/entity/ent/resource_create.go b/internal/data/entity/ent/resource_create.go index 59a82339..ee8b9256 100644 --- a/internal/data/entity/ent/resource_create.go +++ b/internal/data/entity/ent/resource_create.go @@ -422,6 +422,14 @@ func (_c *ResourceCreate) defaults() { v := resource.DefaultName _c.mutation.SetName(v) } + if _, ok := _c.mutation.I18n(); !ok { + v := resource.DefaultI18n + _c.mutation.SetI18n(v) + } + if _, ok := _c.mutation.GetType(); !ok { + v := resource.DefaultType + _c.mutation.SetType(v) + } if _, ok := _c.mutation.Status(); !ok { v := resource.DefaultStatus _c.mutation.SetStatus(v) @@ -430,6 +438,18 @@ func (_c *ResourceCreate) defaults() { v := resource.DefaultSequence _c.mutation.SetSequence(v) } + if _, ok := _c.mutation.Method(); !ok { + v := resource.DefaultMethod + _c.mutation.SetMethod(v) + } + if _, ok := _c.mutation.Path(); !ok { + v := resource.DefaultPath + _c.mutation.SetPath(v) + } + if _, ok := _c.mutation.Operation(); !ok { + v := resource.DefaultOperation + _c.mutation.SetOperation(v) + } if _, ok := _c.mutation.ServiceName(); !ok { v := resource.DefaultServiceName _c.mutation.SetServiceName(v) @@ -450,6 +470,18 @@ func (_c *ResourceCreate) defaults() { v := resource.DefaultSyncStatus _c.mutation.SetSyncStatus(v) } + if _, ok := _c.mutation.TreePath(); !ok { + v := resource.DefaultTreePath + _c.mutation.SetTreePath(v) + } + if _, ok := _c.mutation.Properties(); !ok { + v := resource.DefaultProperties + _c.mutation.SetProperties(v) + } + if _, ok := _c.mutation.Description(); !ok { + v := resource.DefaultDescription + _c.mutation.SetDescription(v) + } if _, ok := _c.mutation.ID(); !ok { v := resource.DefaultID() _c.mutation.SetID(v) @@ -475,12 +507,27 @@ func (_c *ResourceCreate) check() error { if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Resource.name"`)} } + if _, ok := _c.mutation.I18n(); !ok { + return &ValidationError{Name: "i18n", err: errors.New(`ent: missing required field "Resource.i18n"`)} + } + if _, ok := _c.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Resource.type"`)} + } if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Resource.status"`)} } if _, ok := _c.mutation.Sequence(); !ok { return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "Resource.sequence"`)} } + if _, ok := _c.mutation.Method(); !ok { + return &ValidationError{Name: "method", err: errors.New(`ent: missing required field "Resource.method"`)} + } + if _, ok := _c.mutation.Path(); !ok { + return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "Resource.path"`)} + } + if _, ok := _c.mutation.Operation(); !ok { + return &ValidationError{Name: "operation", err: errors.New(`ent: missing required field "Resource.operation"`)} + } if _, ok := _c.mutation.ServiceName(); !ok { return &ValidationError{Name: "service_name", err: errors.New(`ent: missing required field "Resource.service_name"`)} } @@ -496,6 +543,15 @@ func (_c *ResourceCreate) check() error { if _, ok := _c.mutation.SyncStatus(); !ok { return &ValidationError{Name: "sync_status", err: errors.New(`ent: missing required field "Resource.sync_status"`)} } + if _, ok := _c.mutation.TreePath(); !ok { + return &ValidationError{Name: "tree_path", err: errors.New(`ent: missing required field "Resource.tree_path"`)} + } + if _, ok := _c.mutation.Properties(); !ok { + return &ValidationError{Name: "properties", err: errors.New(`ent: missing required field "Resource.properties"`)} + } + if _, ok := _c.mutation.Description(); !ok { + return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Resource.description"`)} + } if v, ok := _c.mutation.ID(); ok { if err := resource.IDValidator(v); err != nil { return &ValidationError{Name: "id", err: fmt.Errorf(`ent: validator failed for field "Resource.id": %w`, err)} diff --git a/internal/data/entity/ent/resource_update.go b/internal/data/entity/ent/resource_update.go index 755c663f..dfbfd326 100644 --- a/internal/data/entity/ent/resource_update.go +++ b/internal/data/entity/ent/resource_update.go @@ -81,12 +81,6 @@ func (_u *ResourceUpdate) SetNillableI18n(v *string) *ResourceUpdate { return _u } -// ClearI18n clears the value of the "i18n" field. -func (_u *ResourceUpdate) ClearI18n() *ResourceUpdate { - _u.mutation.ClearI18n() - return _u -} - // SetType sets the "type" field. func (_u *ResourceUpdate) SetType(v string) *ResourceUpdate { _u.mutation.SetType(v) @@ -101,12 +95,6 @@ func (_u *ResourceUpdate) SetNillableType(v *string) *ResourceUpdate { return _u } -// ClearType clears the value of the "type" field. -func (_u *ResourceUpdate) ClearType() *ResourceUpdate { - _u.mutation.ClearType() - return _u -} - // SetStatus sets the "status" field. func (_u *ResourceUpdate) SetStatus(v enums.Status) *ResourceUpdate { _u.mutation.ResetStatus() @@ -163,12 +151,6 @@ func (_u *ResourceUpdate) SetNillableMethod(v *string) *ResourceUpdate { return _u } -// ClearMethod clears the value of the "method" field. -func (_u *ResourceUpdate) ClearMethod() *ResourceUpdate { - _u.mutation.ClearMethod() - return _u -} - // SetPath sets the "path" field. func (_u *ResourceUpdate) SetPath(v string) *ResourceUpdate { _u.mutation.SetPath(v) @@ -183,12 +165,6 @@ func (_u *ResourceUpdate) SetNillablePath(v *string) *ResourceUpdate { return _u } -// ClearPath clears the value of the "path" field. -func (_u *ResourceUpdate) ClearPath() *ResourceUpdate { - _u.mutation.ClearPath() - return _u -} - // SetOperation sets the "operation" field. func (_u *ResourceUpdate) SetOperation(v string) *ResourceUpdate { _u.mutation.SetOperation(v) @@ -203,12 +179,6 @@ func (_u *ResourceUpdate) SetNillableOperation(v *string) *ResourceUpdate { return _u } -// ClearOperation clears the value of the "operation" field. -func (_u *ResourceUpdate) ClearOperation() *ResourceUpdate { - _u.mutation.ClearOperation() - return _u -} - // SetServiceName sets the "service_name" field. func (_u *ResourceUpdate) SetServiceName(v string) *ResourceUpdate { _u.mutation.SetServiceName(v) @@ -293,12 +263,6 @@ func (_u *ResourceUpdate) SetNillableTreePath(v *string) *ResourceUpdate { return _u } -// ClearTreePath clears the value of the "tree_path" field. -func (_u *ResourceUpdate) ClearTreePath() *ResourceUpdate { - _u.mutation.ClearTreePath() - return _u -} - // SetParentID sets the "parent_id" field. func (_u *ResourceUpdate) SetParentID(v int64) *ResourceUpdate { _u.mutation.SetParentID(v) @@ -333,12 +297,6 @@ func (_u *ResourceUpdate) SetNillableProperties(v *string) *ResourceUpdate { return _u } -// ClearProperties clears the value of the "properties" field. -func (_u *ResourceUpdate) ClearProperties() *ResourceUpdate { - _u.mutation.ClearProperties() - return _u -} - // SetDescription sets the "description" field. func (_u *ResourceUpdate) SetDescription(v string) *ResourceUpdate { _u.mutation.SetDescription(v) @@ -353,12 +311,6 @@ func (_u *ResourceUpdate) SetNillableDescription(v *string) *ResourceUpdate { return _u } -// ClearDescription clears the value of the "description" field. -func (_u *ResourceUpdate) ClearDescription() *ResourceUpdate { - _u.mutation.ClearDescription() - return _u -} - // SetParent sets the "parent" edge to the Resource entity. func (_u *ResourceUpdate) SetParent(v *Resource) *ResourceUpdate { return _u.SetParentID(v.ID) @@ -595,15 +547,9 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.I18n(); ok { _spec.SetField(resource.FieldI18n, field.TypeString, value) } - if _u.mutation.I18nCleared() { - _spec.ClearField(resource.FieldI18n, field.TypeString) - } if value, ok := _u.mutation.GetType(); ok { _spec.SetField(resource.FieldType, field.TypeString, value) } - if _u.mutation.TypeCleared() { - _spec.ClearField(resource.FieldType, field.TypeString) - } if value, ok := _u.mutation.Status(); ok { _spec.SetField(resource.FieldStatus, field.TypeInt8, value) } @@ -619,21 +565,12 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) } - if _u.mutation.MethodCleared() { - _spec.ClearField(resource.FieldMethod, field.TypeString) - } if value, ok := _u.mutation.Path(); ok { _spec.SetField(resource.FieldPath, field.TypeString, value) } - if _u.mutation.PathCleared() { - _spec.ClearField(resource.FieldPath, field.TypeString) - } if value, ok := _u.mutation.Operation(); ok { _spec.SetField(resource.FieldOperation, field.TypeString, value) } - if _u.mutation.OperationCleared() { - _spec.ClearField(resource.FieldOperation, field.TypeString) - } if value, ok := _u.mutation.ServiceName(); ok { _spec.SetField(resource.FieldServiceName, field.TypeString, value) } @@ -652,21 +589,12 @@ func (_u *ResourceUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.TreePath(); ok { _spec.SetField(resource.FieldTreePath, field.TypeString, value) } - if _u.mutation.TreePathCleared() { - _spec.ClearField(resource.FieldTreePath, field.TypeString) - } if value, ok := _u.mutation.Properties(); ok { _spec.SetField(resource.FieldProperties, field.TypeString, value) } - if _u.mutation.PropertiesCleared() { - _spec.ClearField(resource.FieldProperties, field.TypeString) - } if value, ok := _u.mutation.Description(); ok { _spec.SetField(resource.FieldDescription, field.TypeString, value) } - if _u.mutation.DescriptionCleared() { - _spec.ClearField(resource.FieldDescription, field.TypeString) - } if _u.mutation.ParentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, @@ -967,12 +895,6 @@ func (_u *ResourceUpdateOne) SetNillableI18n(v *string) *ResourceUpdateOne { return _u } -// ClearI18n clears the value of the "i18n" field. -func (_u *ResourceUpdateOne) ClearI18n() *ResourceUpdateOne { - _u.mutation.ClearI18n() - return _u -} - // SetType sets the "type" field. func (_u *ResourceUpdateOne) SetType(v string) *ResourceUpdateOne { _u.mutation.SetType(v) @@ -987,12 +909,6 @@ func (_u *ResourceUpdateOne) SetNillableType(v *string) *ResourceUpdateOne { return _u } -// ClearType clears the value of the "type" field. -func (_u *ResourceUpdateOne) ClearType() *ResourceUpdateOne { - _u.mutation.ClearType() - return _u -} - // SetStatus sets the "status" field. func (_u *ResourceUpdateOne) SetStatus(v enums.Status) *ResourceUpdateOne { _u.mutation.ResetStatus() @@ -1049,12 +965,6 @@ func (_u *ResourceUpdateOne) SetNillableMethod(v *string) *ResourceUpdateOne { return _u } -// ClearMethod clears the value of the "method" field. -func (_u *ResourceUpdateOne) ClearMethod() *ResourceUpdateOne { - _u.mutation.ClearMethod() - return _u -} - // SetPath sets the "path" field. func (_u *ResourceUpdateOne) SetPath(v string) *ResourceUpdateOne { _u.mutation.SetPath(v) @@ -1069,12 +979,6 @@ func (_u *ResourceUpdateOne) SetNillablePath(v *string) *ResourceUpdateOne { return _u } -// ClearPath clears the value of the "path" field. -func (_u *ResourceUpdateOne) ClearPath() *ResourceUpdateOne { - _u.mutation.ClearPath() - return _u -} - // SetOperation sets the "operation" field. func (_u *ResourceUpdateOne) SetOperation(v string) *ResourceUpdateOne { _u.mutation.SetOperation(v) @@ -1089,12 +993,6 @@ func (_u *ResourceUpdateOne) SetNillableOperation(v *string) *ResourceUpdateOne return _u } -// ClearOperation clears the value of the "operation" field. -func (_u *ResourceUpdateOne) ClearOperation() *ResourceUpdateOne { - _u.mutation.ClearOperation() - return _u -} - // SetServiceName sets the "service_name" field. func (_u *ResourceUpdateOne) SetServiceName(v string) *ResourceUpdateOne { _u.mutation.SetServiceName(v) @@ -1179,12 +1077,6 @@ func (_u *ResourceUpdateOne) SetNillableTreePath(v *string) *ResourceUpdateOne { return _u } -// ClearTreePath clears the value of the "tree_path" field. -func (_u *ResourceUpdateOne) ClearTreePath() *ResourceUpdateOne { - _u.mutation.ClearTreePath() - return _u -} - // SetParentID sets the "parent_id" field. func (_u *ResourceUpdateOne) SetParentID(v int64) *ResourceUpdateOne { _u.mutation.SetParentID(v) @@ -1219,12 +1111,6 @@ func (_u *ResourceUpdateOne) SetNillableProperties(v *string) *ResourceUpdateOne return _u } -// ClearProperties clears the value of the "properties" field. -func (_u *ResourceUpdateOne) ClearProperties() *ResourceUpdateOne { - _u.mutation.ClearProperties() - return _u -} - // SetDescription sets the "description" field. func (_u *ResourceUpdateOne) SetDescription(v string) *ResourceUpdateOne { _u.mutation.SetDescription(v) @@ -1239,12 +1125,6 @@ func (_u *ResourceUpdateOne) SetNillableDescription(v *string) *ResourceUpdateOn return _u } -// ClearDescription clears the value of the "description" field. -func (_u *ResourceUpdateOne) ClearDescription() *ResourceUpdateOne { - _u.mutation.ClearDescription() - return _u -} - // SetParent sets the "parent" edge to the Resource entity. func (_u *ResourceUpdateOne) SetParent(v *Resource) *ResourceUpdateOne { return _u.SetParentID(v.ID) @@ -1511,15 +1391,9 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err if value, ok := _u.mutation.I18n(); ok { _spec.SetField(resource.FieldI18n, field.TypeString, value) } - if _u.mutation.I18nCleared() { - _spec.ClearField(resource.FieldI18n, field.TypeString) - } if value, ok := _u.mutation.GetType(); ok { _spec.SetField(resource.FieldType, field.TypeString, value) } - if _u.mutation.TypeCleared() { - _spec.ClearField(resource.FieldType, field.TypeString) - } if value, ok := _u.mutation.Status(); ok { _spec.SetField(resource.FieldStatus, field.TypeInt8, value) } @@ -1535,21 +1409,12 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err if value, ok := _u.mutation.Method(); ok { _spec.SetField(resource.FieldMethod, field.TypeString, value) } - if _u.mutation.MethodCleared() { - _spec.ClearField(resource.FieldMethod, field.TypeString) - } if value, ok := _u.mutation.Path(); ok { _spec.SetField(resource.FieldPath, field.TypeString, value) } - if _u.mutation.PathCleared() { - _spec.ClearField(resource.FieldPath, field.TypeString) - } if value, ok := _u.mutation.Operation(); ok { _spec.SetField(resource.FieldOperation, field.TypeString, value) } - if _u.mutation.OperationCleared() { - _spec.ClearField(resource.FieldOperation, field.TypeString) - } if value, ok := _u.mutation.ServiceName(); ok { _spec.SetField(resource.FieldServiceName, field.TypeString, value) } @@ -1568,21 +1433,12 @@ func (_u *ResourceUpdateOne) sqlSave(ctx context.Context) (_node *Resource, err if value, ok := _u.mutation.TreePath(); ok { _spec.SetField(resource.FieldTreePath, field.TypeString, value) } - if _u.mutation.TreePathCleared() { - _spec.ClearField(resource.FieldTreePath, field.TypeString) - } if value, ok := _u.mutation.Properties(); ok { _spec.SetField(resource.FieldProperties, field.TypeString, value) } - if _u.mutation.PropertiesCleared() { - _spec.ClearField(resource.FieldProperties, field.TypeString) - } if value, ok := _u.mutation.Description(); ok { _spec.SetField(resource.FieldDescription, field.TypeString, value) } - if _u.mutation.DescriptionCleared() { - _spec.ClearField(resource.FieldDescription, field.TypeString) - } if _u.mutation.ParentCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index ecb9d958..5182bbee 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -320,6 +320,14 @@ func init() { resourceDescName := resourceFields[1].Descriptor() // resource.DefaultName holds the default value on creation for the name field. resource.DefaultName = resourceDescName.Default.(string) + // resourceDescI18n is the schema descriptor for i18n field. + resourceDescI18n := resourceFields[2].Descriptor() + // resource.DefaultI18n holds the default value on creation for the i18n field. + resource.DefaultI18n = resourceDescI18n.Default.(string) + // resourceDescType is the schema descriptor for type field. + resourceDescType := resourceFields[3].Descriptor() + // resource.DefaultType holds the default value on creation for the type field. + resource.DefaultType = resourceDescType.Default.(string) // resourceDescStatus is the schema descriptor for status field. resourceDescStatus := resourceFields[4].Descriptor() // resource.DefaultStatus holds the default value on creation for the status field. @@ -328,6 +336,18 @@ func init() { resourceDescSequence := resourceFields[5].Descriptor() // resource.DefaultSequence holds the default value on creation for the sequence field. resource.DefaultSequence = resourceDescSequence.Default.(int) + // resourceDescMethod is the schema descriptor for method field. + resourceDescMethod := resourceFields[6].Descriptor() + // resource.DefaultMethod holds the default value on creation for the method field. + resource.DefaultMethod = resourceDescMethod.Default.(string) + // resourceDescPath is the schema descriptor for path field. + resourceDescPath := resourceFields[7].Descriptor() + // resource.DefaultPath holds the default value on creation for the path field. + resource.DefaultPath = resourceDescPath.Default.(string) + // resourceDescOperation is the schema descriptor for operation field. + resourceDescOperation := resourceFields[8].Descriptor() + // resource.DefaultOperation holds the default value on creation for the operation field. + resource.DefaultOperation = resourceDescOperation.Default.(string) // resourceDescServiceName is the schema descriptor for service_name field. resourceDescServiceName := resourceFields[9].Descriptor() // resource.DefaultServiceName holds the default value on creation for the service_name field. @@ -348,6 +368,18 @@ func init() { resourceDescSyncStatus := resourceFields[13].Descriptor() // resource.DefaultSyncStatus holds the default value on creation for the sync_status field. resource.DefaultSyncStatus = resourceDescSyncStatus.Default.(string) + // resourceDescTreePath is the schema descriptor for tree_path field. + resourceDescTreePath := resourceFields[14].Descriptor() + // resource.DefaultTreePath holds the default value on creation for the tree_path field. + resource.DefaultTreePath = resourceDescTreePath.Default.(string) + // resourceDescProperties is the schema descriptor for properties field. + resourceDescProperties := resourceFields[16].Descriptor() + // resource.DefaultProperties holds the default value on creation for the properties field. + resource.DefaultProperties = resourceDescProperties.Default.(string) + // resourceDescDescription is the schema descriptor for description field. + resourceDescDescription := resourceFields[17].Descriptor() + // resource.DefaultDescription holds the default value on creation for the description field. + resource.DefaultDescription = resourceDescDescription.Default.(string) // resourceDescID is the schema descriptor for id field. resourceDescID := resourceMixinFields0[0].Descriptor() // resource.DefaultID holds the default value on creation for the id field. @@ -641,6 +673,22 @@ func init() { viewDescScope := viewFields[2].Descriptor() // view.DefaultScope holds the default value on creation for the scope field. view.DefaultScope = viewDescScope.Default.(string) + // viewDescI18n is the schema descriptor for i18n field. + viewDescI18n := viewFields[4].Descriptor() + // view.DefaultI18n holds the default value on creation for the i18n field. + view.DefaultI18n = viewDescI18n.Default.(string) + // viewDescComponent is the schema descriptor for component field. + viewDescComponent := viewFields[6].Descriptor() + // view.DefaultComponent holds the default value on creation for the component field. + view.DefaultComponent = viewDescComponent.Default.(string) + // viewDescPath is the schema descriptor for path field. + viewDescPath := viewFields[7].Descriptor() + // view.DefaultPath holds the default value on creation for the path field. + view.DefaultPath = viewDescPath.Default.(string) + // viewDescIcon is the schema descriptor for icon field. + viewDescIcon := viewFields[8].Descriptor() + // view.DefaultIcon holds the default value on creation for the icon field. + view.DefaultIcon = viewDescIcon.Default.(string) // viewDescVisible is the schema descriptor for visible field. viewDescVisible := viewFields[9].Descriptor() // view.DefaultVisible holds the default value on creation for the visible field. @@ -649,6 +697,18 @@ func init() { viewDescSequence := viewFields[10].Descriptor() // view.DefaultSequence holds the default value on creation for the sequence field. view.DefaultSequence = viewDescSequence.Default.(int) + // viewDescTreePath is the schema descriptor for tree_path field. + viewDescTreePath := viewFields[11].Descriptor() + // view.DefaultTreePath holds the default value on creation for the tree_path field. + view.DefaultTreePath = viewDescTreePath.Default.(string) + // viewDescDescription is the schema descriptor for description field. + viewDescDescription := viewFields[12].Descriptor() + // view.DefaultDescription holds the default value on creation for the description field. + view.DefaultDescription = viewDescDescription.Default.(string) + // viewDescProperties is the schema descriptor for properties field. + viewDescProperties := viewFields[13].Descriptor() + // view.DefaultProperties holds the default value on creation for the properties field. + view.DefaultProperties = viewDescProperties.Default.(string) // viewDescStatus is the schema descriptor for status field. viewDescStatus := viewFields[14].Descriptor() // view.DefaultStatus holds the default value on creation for the status field. diff --git a/internal/data/entity/ent/schema/resource.go b/internal/data/entity/ent/schema/resource.go index 3ee098e6..a803b363 100644 --- a/internal/data/entity/ent/schema/resource.go +++ b/internal/data/entity/ent/schema/resource.go @@ -30,10 +30,10 @@ func (Resource) Fields() []ent.Field { Default(""), field.String("i18n"). Comment(i18n.Text("entity.resource.field.i18n")). - Optional(), + Default(""), field.String("type"). Comment(i18n.Text("entity.resource.field.type")). - Optional(), + Default("API"), field.Int8("status"). GoType(enums.Status(0)). Default(int8(enums.StatusActive)). @@ -43,13 +43,13 @@ func (Resource) Fields() []ent.Field { Default(0), field.String("method"). Comment(i18n.Text("entity.resource.field.method")). - Optional(), + Default(""), field.String("path"). Comment(i18n.Text("entity.resource.field.path")). - Optional(), + Default(""), field.String("operation"). Comment(i18n.Text("entity.resource.field.operation")). - Optional(), + Default(""), field.String("service_name"). Default(""). Comment(i18n.Text("entity.resource.field.service_name")), @@ -67,14 +67,14 @@ func (Resource) Fields() []ent.Field { Default("Synced"), field.String("tree_path"). Comment(i18n.Text("entity.resource.field.tree_path")). - Optional(), + Default(""), mixin.OptionalFK("parent_id", i18n.Text("entity.resource.field.parent_id")), field.String("properties"). Comment(i18n.Text("entity.resource.field.properties")). - Optional(), + Default(""), field.String("description"). Comment(i18n.Text("entity.resource.field.description")). - Optional(), + Default(""), } } diff --git a/internal/data/entity/ent/schema/view.go b/internal/data/entity/ent/schema/view.go index e5304760..6caf2033 100644 --- a/internal/data/entity/ent/schema/view.go +++ b/internal/data/entity/ent/schema/view.go @@ -35,7 +35,7 @@ func (View) Fields() []ent.Field { Comment(i18n.Text("entity.view.field.name")), field.String("i18n"). Comment(i18n.Text("entity.view.field.i18n")). - Optional(), + Default(""), field.Enum("type"). Comment(i18n.Text("entity.view.field.type")). Values( @@ -52,13 +52,13 @@ func (View) Fields() []ent.Field { Default(string(enums.ViewTypeUnknown)), field.String("component"). Comment(i18n.Text("entity.view.field.component")). - Optional(), + Default(""), field.String("path"). Comment(i18n.Text("entity.view.field.path")). - Optional(), + Default(""), field.String("icon"). Comment(i18n.Text("entity.view.field.icon")). - Optional(), + Default(""), field.Bool("visible"). Comment(i18n.Text("entity.view.field.visible")). Default(true), @@ -67,13 +67,13 @@ func (View) Fields() []ent.Field { Default(0), field.String("tree_path"). Comment(i18n.Text("entity.view.field.tree_path")). - Optional(), + Default(""), field.String("description"). Comment(i18n.Text("entity.view.field.description")). - Optional(), + Default(""), field.String("properties"). Comment(i18n.Text("entity.view.field.properties")). - Optional(), + Default(""), field.Int8("status"). GoType(enums.Status(0)). Default(int8(enums.StatusActive)). diff --git a/internal/data/entity/ent/view/view.go b/internal/data/entity/ent/view/view.go index d3a5b173..75903132 100644 --- a/internal/data/entity/ent/view/view.go +++ b/internal/data/entity/ent/view/view.go @@ -150,10 +150,24 @@ var ( KeywordValidator func(string) error // DefaultScope holds the default value on creation for the "scope" field. DefaultScope string + // DefaultI18n holds the default value on creation for the "i18n" field. + DefaultI18n string + // DefaultComponent holds the default value on creation for the "component" field. + DefaultComponent string + // DefaultPath holds the default value on creation for the "path" field. + DefaultPath string + // DefaultIcon holds the default value on creation for the "icon" field. + DefaultIcon string // DefaultVisible holds the default value on creation for the "visible" field. DefaultVisible bool // DefaultSequence holds the default value on creation for the "sequence" field. DefaultSequence int + // DefaultTreePath holds the default value on creation for the "tree_path" field. + DefaultTreePath string + // DefaultDescription holds the default value on creation for the "description" field. + DefaultDescription string + // DefaultProperties holds the default value on creation for the "properties" field. + DefaultProperties string // DefaultStatus holds the default value on creation for the "status" field. DefaultStatus enums.Status // DefaultID holds the default value on creation for the "id" field. diff --git a/internal/data/entity/ent/view/where.go b/internal/data/entity/ent/view/where.go index 964017ee..35c7447d 100644 --- a/internal/data/entity/ent/view/where.go +++ b/internal/data/entity/ent/view/where.go @@ -497,16 +497,6 @@ func I18nHasSuffix(v string) predicate.View { return predicate.View(sql.FieldHasSuffix(FieldI18n, v)) } -// I18nIsNil applies the IsNil predicate on the "i18n" field. -func I18nIsNil() predicate.View { - return predicate.View(sql.FieldIsNull(FieldI18n)) -} - -// I18nNotNil applies the NotNil predicate on the "i18n" field. -func I18nNotNil() predicate.View { - return predicate.View(sql.FieldNotNull(FieldI18n)) -} - // I18nEqualFold applies the EqualFold predicate on the "i18n" field. func I18nEqualFold(v string) predicate.View { return predicate.View(sql.FieldEqualFold(FieldI18n, v)) @@ -592,16 +582,6 @@ func ComponentHasSuffix(v string) predicate.View { return predicate.View(sql.FieldHasSuffix(FieldComponent, v)) } -// ComponentIsNil applies the IsNil predicate on the "component" field. -func ComponentIsNil() predicate.View { - return predicate.View(sql.FieldIsNull(FieldComponent)) -} - -// ComponentNotNil applies the NotNil predicate on the "component" field. -func ComponentNotNil() predicate.View { - return predicate.View(sql.FieldNotNull(FieldComponent)) -} - // ComponentEqualFold applies the EqualFold predicate on the "component" field. func ComponentEqualFold(v string) predicate.View { return predicate.View(sql.FieldEqualFold(FieldComponent, v)) @@ -667,16 +647,6 @@ func PathHasSuffix(v string) predicate.View { return predicate.View(sql.FieldHasSuffix(FieldPath, v)) } -// PathIsNil applies the IsNil predicate on the "path" field. -func PathIsNil() predicate.View { - return predicate.View(sql.FieldIsNull(FieldPath)) -} - -// PathNotNil applies the NotNil predicate on the "path" field. -func PathNotNil() predicate.View { - return predicate.View(sql.FieldNotNull(FieldPath)) -} - // PathEqualFold applies the EqualFold predicate on the "path" field. func PathEqualFold(v string) predicate.View { return predicate.View(sql.FieldEqualFold(FieldPath, v)) @@ -742,16 +712,6 @@ func IconHasSuffix(v string) predicate.View { return predicate.View(sql.FieldHasSuffix(FieldIcon, v)) } -// IconIsNil applies the IsNil predicate on the "icon" field. -func IconIsNil() predicate.View { - return predicate.View(sql.FieldIsNull(FieldIcon)) -} - -// IconNotNil applies the NotNil predicate on the "icon" field. -func IconNotNil() predicate.View { - return predicate.View(sql.FieldNotNull(FieldIcon)) -} - // IconEqualFold applies the EqualFold predicate on the "icon" field. func IconEqualFold(v string) predicate.View { return predicate.View(sql.FieldEqualFold(FieldIcon, v)) @@ -867,16 +827,6 @@ func TreePathHasSuffix(v string) predicate.View { return predicate.View(sql.FieldHasSuffix(FieldTreePath, v)) } -// TreePathIsNil applies the IsNil predicate on the "tree_path" field. -func TreePathIsNil() predicate.View { - return predicate.View(sql.FieldIsNull(FieldTreePath)) -} - -// TreePathNotNil applies the NotNil predicate on the "tree_path" field. -func TreePathNotNil() predicate.View { - return predicate.View(sql.FieldNotNull(FieldTreePath)) -} - // TreePathEqualFold applies the EqualFold predicate on the "tree_path" field. func TreePathEqualFold(v string) predicate.View { return predicate.View(sql.FieldEqualFold(FieldTreePath, v)) @@ -942,16 +892,6 @@ func DescriptionHasSuffix(v string) predicate.View { return predicate.View(sql.FieldHasSuffix(FieldDescription, v)) } -// DescriptionIsNil applies the IsNil predicate on the "description" field. -func DescriptionIsNil() predicate.View { - return predicate.View(sql.FieldIsNull(FieldDescription)) -} - -// DescriptionNotNil applies the NotNil predicate on the "description" field. -func DescriptionNotNil() predicate.View { - return predicate.View(sql.FieldNotNull(FieldDescription)) -} - // DescriptionEqualFold applies the EqualFold predicate on the "description" field. func DescriptionEqualFold(v string) predicate.View { return predicate.View(sql.FieldEqualFold(FieldDescription, v)) @@ -1017,16 +957,6 @@ func PropertiesHasSuffix(v string) predicate.View { return predicate.View(sql.FieldHasSuffix(FieldProperties, v)) } -// PropertiesIsNil applies the IsNil predicate on the "properties" field. -func PropertiesIsNil() predicate.View { - return predicate.View(sql.FieldIsNull(FieldProperties)) -} - -// PropertiesNotNil applies the NotNil predicate on the "properties" field. -func PropertiesNotNil() predicate.View { - return predicate.View(sql.FieldNotNull(FieldProperties)) -} - // PropertiesEqualFold applies the EqualFold predicate on the "properties" field. func PropertiesEqualFold(v string) predicate.View { return predicate.View(sql.FieldEqualFold(FieldProperties, v)) diff --git a/internal/data/entity/ent/view_create.go b/internal/data/entity/ent/view_create.go index d7a54d2d..020b8f38 100644 --- a/internal/data/entity/ent/view_create.go +++ b/internal/data/entity/ent/view_create.go @@ -388,10 +388,26 @@ func (_c *ViewCreate) defaults() { v := view.DefaultScope _c.mutation.SetScope(v) } + if _, ok := _c.mutation.I18n(); !ok { + v := view.DefaultI18n + _c.mutation.SetI18n(v) + } if _, ok := _c.mutation.GetType(); !ok { v := view.DefaultType _c.mutation.SetType(v) } + if _, ok := _c.mutation.Component(); !ok { + v := view.DefaultComponent + _c.mutation.SetComponent(v) + } + if _, ok := _c.mutation.Path(); !ok { + v := view.DefaultPath + _c.mutation.SetPath(v) + } + if _, ok := _c.mutation.Icon(); !ok { + v := view.DefaultIcon + _c.mutation.SetIcon(v) + } if _, ok := _c.mutation.Visible(); !ok { v := view.DefaultVisible _c.mutation.SetVisible(v) @@ -400,6 +416,18 @@ func (_c *ViewCreate) defaults() { v := view.DefaultSequence _c.mutation.SetSequence(v) } + if _, ok := _c.mutation.TreePath(); !ok { + v := view.DefaultTreePath + _c.mutation.SetTreePath(v) + } + if _, ok := _c.mutation.Description(); !ok { + v := view.DefaultDescription + _c.mutation.SetDescription(v) + } + if _, ok := _c.mutation.Properties(); !ok { + v := view.DefaultProperties + _c.mutation.SetProperties(v) + } if _, ok := _c.mutation.Status(); !ok { v := view.DefaultStatus _c.mutation.SetStatus(v) @@ -432,6 +460,9 @@ func (_c *ViewCreate) check() error { if _, ok := _c.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "View.name"`)} } + if _, ok := _c.mutation.I18n(); !ok { + return &ValidationError{Name: "i18n", err: errors.New(`ent: missing required field "View.i18n"`)} + } if _, ok := _c.mutation.GetType(); !ok { return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "View.type"`)} } @@ -440,12 +471,30 @@ func (_c *ViewCreate) check() error { return &ValidationError{Name: "type", err: fmt.Errorf(`ent: validator failed for field "View.type": %w`, err)} } } + if _, ok := _c.mutation.Component(); !ok { + return &ValidationError{Name: "component", err: errors.New(`ent: missing required field "View.component"`)} + } + if _, ok := _c.mutation.Path(); !ok { + return &ValidationError{Name: "path", err: errors.New(`ent: missing required field "View.path"`)} + } + if _, ok := _c.mutation.Icon(); !ok { + return &ValidationError{Name: "icon", err: errors.New(`ent: missing required field "View.icon"`)} + } if _, ok := _c.mutation.Visible(); !ok { return &ValidationError{Name: "visible", err: errors.New(`ent: missing required field "View.visible"`)} } if _, ok := _c.mutation.Sequence(); !ok { return &ValidationError{Name: "sequence", err: errors.New(`ent: missing required field "View.sequence"`)} } + if _, ok := _c.mutation.TreePath(); !ok { + return &ValidationError{Name: "tree_path", err: errors.New(`ent: missing required field "View.tree_path"`)} + } + if _, ok := _c.mutation.Description(); !ok { + return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "View.description"`)} + } + if _, ok := _c.mutation.Properties(); !ok { + return &ValidationError{Name: "properties", err: errors.New(`ent: missing required field "View.properties"`)} + } if _, ok := _c.mutation.Status(); !ok { return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "View.status"`)} } diff --git a/internal/data/entity/ent/view_update.go b/internal/data/entity/ent/view_update.go index 6ee28e1d..36351f5c 100644 --- a/internal/data/entity/ent/view_update.go +++ b/internal/data/entity/ent/view_update.go @@ -116,12 +116,6 @@ func (_u *ViewUpdate) SetNillableI18n(v *string) *ViewUpdate { return _u } -// ClearI18n clears the value of the "i18n" field. -func (_u *ViewUpdate) ClearI18n() *ViewUpdate { - _u.mutation.ClearI18n() - return _u -} - // SetType sets the "type" field. func (_u *ViewUpdate) SetType(v view.Type) *ViewUpdate { _u.mutation.SetType(v) @@ -150,12 +144,6 @@ func (_u *ViewUpdate) SetNillableComponent(v *string) *ViewUpdate { return _u } -// ClearComponent clears the value of the "component" field. -func (_u *ViewUpdate) ClearComponent() *ViewUpdate { - _u.mutation.ClearComponent() - return _u -} - // SetPath sets the "path" field. func (_u *ViewUpdate) SetPath(v string) *ViewUpdate { _u.mutation.SetPath(v) @@ -170,12 +158,6 @@ func (_u *ViewUpdate) SetNillablePath(v *string) *ViewUpdate { return _u } -// ClearPath clears the value of the "path" field. -func (_u *ViewUpdate) ClearPath() *ViewUpdate { - _u.mutation.ClearPath() - return _u -} - // SetIcon sets the "icon" field. func (_u *ViewUpdate) SetIcon(v string) *ViewUpdate { _u.mutation.SetIcon(v) @@ -190,12 +172,6 @@ func (_u *ViewUpdate) SetNillableIcon(v *string) *ViewUpdate { return _u } -// ClearIcon clears the value of the "icon" field. -func (_u *ViewUpdate) ClearIcon() *ViewUpdate { - _u.mutation.ClearIcon() - return _u -} - // SetVisible sets the "visible" field. func (_u *ViewUpdate) SetVisible(v bool) *ViewUpdate { _u.mutation.SetVisible(v) @@ -245,12 +221,6 @@ func (_u *ViewUpdate) SetNillableTreePath(v *string) *ViewUpdate { return _u } -// ClearTreePath clears the value of the "tree_path" field. -func (_u *ViewUpdate) ClearTreePath() *ViewUpdate { - _u.mutation.ClearTreePath() - return _u -} - // SetDescription sets the "description" field. func (_u *ViewUpdate) SetDescription(v string) *ViewUpdate { _u.mutation.SetDescription(v) @@ -265,12 +235,6 @@ func (_u *ViewUpdate) SetNillableDescription(v *string) *ViewUpdate { return _u } -// ClearDescription clears the value of the "description" field. -func (_u *ViewUpdate) ClearDescription() *ViewUpdate { - _u.mutation.ClearDescription() - return _u -} - // SetProperties sets the "properties" field. func (_u *ViewUpdate) SetProperties(v string) *ViewUpdate { _u.mutation.SetProperties(v) @@ -285,12 +249,6 @@ func (_u *ViewUpdate) SetNillableProperties(v *string) *ViewUpdate { return _u } -// ClearProperties clears the value of the "properties" field. -func (_u *ViewUpdate) ClearProperties() *ViewUpdate { - _u.mutation.ClearProperties() - return _u -} - // SetStatus sets the "status" field. func (_u *ViewUpdate) SetStatus(v enums.Status) *ViewUpdate { _u.mutation.ResetStatus() @@ -592,30 +550,18 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.I18n(); ok { _spec.SetField(view.FieldI18n, field.TypeString, value) } - if _u.mutation.I18nCleared() { - _spec.ClearField(view.FieldI18n, field.TypeString) - } if value, ok := _u.mutation.GetType(); ok { _spec.SetField(view.FieldType, field.TypeEnum, value) } if value, ok := _u.mutation.Component(); ok { _spec.SetField(view.FieldComponent, field.TypeString, value) } - if _u.mutation.ComponentCleared() { - _spec.ClearField(view.FieldComponent, field.TypeString) - } if value, ok := _u.mutation.Path(); ok { _spec.SetField(view.FieldPath, field.TypeString, value) } - if _u.mutation.PathCleared() { - _spec.ClearField(view.FieldPath, field.TypeString) - } if value, ok := _u.mutation.Icon(); ok { _spec.SetField(view.FieldIcon, field.TypeString, value) } - if _u.mutation.IconCleared() { - _spec.ClearField(view.FieldIcon, field.TypeString) - } if value, ok := _u.mutation.Visible(); ok { _spec.SetField(view.FieldVisible, field.TypeBool, value) } @@ -628,21 +574,12 @@ func (_u *ViewUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.TreePath(); ok { _spec.SetField(view.FieldTreePath, field.TypeString, value) } - if _u.mutation.TreePathCleared() { - _spec.ClearField(view.FieldTreePath, field.TypeString) - } if value, ok := _u.mutation.Description(); ok { _spec.SetField(view.FieldDescription, field.TypeString, value) } - if _u.mutation.DescriptionCleared() { - _spec.ClearField(view.FieldDescription, field.TypeString) - } if value, ok := _u.mutation.Properties(); ok { _spec.SetField(view.FieldProperties, field.TypeString, value) } - if _u.mutation.PropertiesCleared() { - _spec.ClearField(view.FieldProperties, field.TypeString) - } if value, ok := _u.mutation.Status(); ok { _spec.SetField(view.FieldStatus, field.TypeInt8, value) } @@ -1049,12 +986,6 @@ func (_u *ViewUpdateOne) SetNillableI18n(v *string) *ViewUpdateOne { return _u } -// ClearI18n clears the value of the "i18n" field. -func (_u *ViewUpdateOne) ClearI18n() *ViewUpdateOne { - _u.mutation.ClearI18n() - return _u -} - // SetType sets the "type" field. func (_u *ViewUpdateOne) SetType(v view.Type) *ViewUpdateOne { _u.mutation.SetType(v) @@ -1083,12 +1014,6 @@ func (_u *ViewUpdateOne) SetNillableComponent(v *string) *ViewUpdateOne { return _u } -// ClearComponent clears the value of the "component" field. -func (_u *ViewUpdateOne) ClearComponent() *ViewUpdateOne { - _u.mutation.ClearComponent() - return _u -} - // SetPath sets the "path" field. func (_u *ViewUpdateOne) SetPath(v string) *ViewUpdateOne { _u.mutation.SetPath(v) @@ -1103,12 +1028,6 @@ func (_u *ViewUpdateOne) SetNillablePath(v *string) *ViewUpdateOne { return _u } -// ClearPath clears the value of the "path" field. -func (_u *ViewUpdateOne) ClearPath() *ViewUpdateOne { - _u.mutation.ClearPath() - return _u -} - // SetIcon sets the "icon" field. func (_u *ViewUpdateOne) SetIcon(v string) *ViewUpdateOne { _u.mutation.SetIcon(v) @@ -1123,12 +1042,6 @@ func (_u *ViewUpdateOne) SetNillableIcon(v *string) *ViewUpdateOne { return _u } -// ClearIcon clears the value of the "icon" field. -func (_u *ViewUpdateOne) ClearIcon() *ViewUpdateOne { - _u.mutation.ClearIcon() - return _u -} - // SetVisible sets the "visible" field. func (_u *ViewUpdateOne) SetVisible(v bool) *ViewUpdateOne { _u.mutation.SetVisible(v) @@ -1178,12 +1091,6 @@ func (_u *ViewUpdateOne) SetNillableTreePath(v *string) *ViewUpdateOne { return _u } -// ClearTreePath clears the value of the "tree_path" field. -func (_u *ViewUpdateOne) ClearTreePath() *ViewUpdateOne { - _u.mutation.ClearTreePath() - return _u -} - // SetDescription sets the "description" field. func (_u *ViewUpdateOne) SetDescription(v string) *ViewUpdateOne { _u.mutation.SetDescription(v) @@ -1198,12 +1105,6 @@ func (_u *ViewUpdateOne) SetNillableDescription(v *string) *ViewUpdateOne { return _u } -// ClearDescription clears the value of the "description" field. -func (_u *ViewUpdateOne) ClearDescription() *ViewUpdateOne { - _u.mutation.ClearDescription() - return _u -} - // SetProperties sets the "properties" field. func (_u *ViewUpdateOne) SetProperties(v string) *ViewUpdateOne { _u.mutation.SetProperties(v) @@ -1218,12 +1119,6 @@ func (_u *ViewUpdateOne) SetNillableProperties(v *string) *ViewUpdateOne { return _u } -// ClearProperties clears the value of the "properties" field. -func (_u *ViewUpdateOne) ClearProperties() *ViewUpdateOne { - _u.mutation.ClearProperties() - return _u -} - // SetStatus sets the "status" field. func (_u *ViewUpdateOne) SetStatus(v enums.Status) *ViewUpdateOne { _u.mutation.ResetStatus() @@ -1555,30 +1450,18 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { if value, ok := _u.mutation.I18n(); ok { _spec.SetField(view.FieldI18n, field.TypeString, value) } - if _u.mutation.I18nCleared() { - _spec.ClearField(view.FieldI18n, field.TypeString) - } if value, ok := _u.mutation.GetType(); ok { _spec.SetField(view.FieldType, field.TypeEnum, value) } if value, ok := _u.mutation.Component(); ok { _spec.SetField(view.FieldComponent, field.TypeString, value) } - if _u.mutation.ComponentCleared() { - _spec.ClearField(view.FieldComponent, field.TypeString) - } if value, ok := _u.mutation.Path(); ok { _spec.SetField(view.FieldPath, field.TypeString, value) } - if _u.mutation.PathCleared() { - _spec.ClearField(view.FieldPath, field.TypeString) - } if value, ok := _u.mutation.Icon(); ok { _spec.SetField(view.FieldIcon, field.TypeString, value) } - if _u.mutation.IconCleared() { - _spec.ClearField(view.FieldIcon, field.TypeString) - } if value, ok := _u.mutation.Visible(); ok { _spec.SetField(view.FieldVisible, field.TypeBool, value) } @@ -1591,21 +1474,12 @@ func (_u *ViewUpdateOne) sqlSave(ctx context.Context) (_node *View, err error) { if value, ok := _u.mutation.TreePath(); ok { _spec.SetField(view.FieldTreePath, field.TypeString, value) } - if _u.mutation.TreePathCleared() { - _spec.ClearField(view.FieldTreePath, field.TypeString) - } if value, ok := _u.mutation.Description(); ok { _spec.SetField(view.FieldDescription, field.TypeString, value) } - if _u.mutation.DescriptionCleared() { - _spec.ClearField(view.FieldDescription, field.TypeString) - } if value, ok := _u.mutation.Properties(); ok { _spec.SetField(view.FieldProperties, field.TypeString, value) } - if _u.mutation.PropertiesCleared() { - _spec.ClearField(view.FieldProperties, field.TypeString) - } if value, ok := _u.mutation.Status(); ok { _spec.SetField(view.FieldStatus, field.TypeInt8, value) } diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index cd4b4889..43571129 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -56,7 +56,6 @@ func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ... entResource := dto.ConvertResourcePBToResource(res) create := r.db.Resource(ctx).Create(). SetResourceSkipZero(entResource). - SetName(res.Name). SetSyncStatus("Modified"). SetVersionID(""). SetLastSyncVersionID("") @@ -140,6 +139,10 @@ func (r *resourceRepo) List(ctx context.Context, opts ...*dto.ResourceQueryOptio query.Where(resource.KeywordContains(opt.Keyword)) } + if opt.Operation != "" { + query.Where(resource.Operation(opt.Operation)) + } + if opt.ReadMask != nil { selectCols := db.SelectFields(opt.ReadMask, resource.ValidColumn, resource.FieldID, new(types.Resource)) if len(selectCols) > 0 { diff --git a/internal/features/system/dto/dto.gen.go b/internal/features/system/dto/dto.gen.go index 3f90cf4a..38231f4f 100644 --- a/internal/features/system/dto/dto.gen.go +++ b/internal/features/system/dto/dto.gen.go @@ -368,14 +368,22 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { ID: from.Id, CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), - Name: from.Name, - ServiceName: from.ServiceName, Keyword: from.Keyword, - Path: from.Path, + Name: from.Name, + I18n: from.I18N, + Type: from.Type, + Status: enums.Status(from.Status), + Sequence: int(from.Sequence), Method: from.Method, + Path: from.Path, Operation: from.Operation, + ServiceName: from.ServiceName, + Policy: from.Policy, SyncStatus: from.SyncStatus, - Status: enums.Status(from.Status), + TreePath: from.TreePath, + ParentID: from.ParentId, + Properties: ConvertStringToStringMapToString(from.Properties), + Description: from.Description, } return to } @@ -392,12 +400,22 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Name: from.Name, Keyword: from.Keyword, + I18N: from.I18n, + Type: from.Type, Status: int32(from.Status), Path: from.Path, Operation: from.Operation, Method: from.Method, + Sequence: int32(from.Sequence), + TreePath: from.TreePath, + Properties: ConvertStringToStringToStringMap(from.Properties), + Description: from.Description, + ParentId: from.ParentID, SyncStatus: from.SyncStatus, ServiceName: from.ServiceName, + Policy: from.Policy, + Children: ConvertResourcesToResourcesPB(from.Edges.Children), + Parent: ConvertResourceToResourcePB(from.Edges.Parent), Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), } return to @@ -546,6 +564,7 @@ func ConvertUserPBToUser(from *UserPB) *User { Gender: ConvertStringToGender(from.Gender), Phone: from.Phone, Email: from.Email, + Department: from.Department, Remark: from.Remark, Token: from.Token, Status: enums.Status(from.Status), @@ -669,6 +688,7 @@ func ConvertUserToUserPB(from *User) *UserPB { LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), LoginTime: ConvertTimeToTimestamp(from.LoginTime), SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), + Department: from.Department, Roles: ConvertRolesToRolesPB(from.Edges.Roles), } return to @@ -705,19 +725,24 @@ func ConvertViewPBToView(from *ViewPB) *View { } to := &View{ - ID: from.Id, - CreateTime: ConvertTimestampToTime(from.CreateTime), - UpdateTime: ConvertTimestampToTime(from.UpdateTime), - ParentID: from.ParentId, - Keyword: from.Keyword, - Scope: from.Scope, - Name: from.Name, - Type: ConvertStringToType(from.Type), - Path: from.Path, - Icon: from.Icon, - Visible: from.Visible, - Sequence: int(from.Sequence), - TreePath: from.TreePath, + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + ParentID: from.ParentId, + Keyword: from.Keyword, + Scope: from.Scope, + Name: from.Name, + I18n: from.I18N, + Type: ConvertStringToType(from.Type), + Component: from.Component, + Path: from.Path, + Icon: from.Icon, + Visible: from.Visible, + Sequence: int(from.Sequence), + TreePath: from.TreePath, + Description: from.Description, + Properties: from.Properties, + Status: enums.Status(from.Status), } return to } @@ -729,22 +754,27 @@ func ConvertViewToViewPB(from *View) *ViewPB { } to := &ViewPB{ - Id: from.ID, - CreateTime: ConvertTimeToTimestamp(from.CreateTime), - UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), - Keyword: from.Keyword, - Name: from.Name, - Scope: from.Scope, - Sequence: int32(from.Sequence), - Type: ConvertTypeToString(from.Type), - Icon: from.Icon, - Visible: from.Visible, - Path: from.Path, - TreePath: from.TreePath, - ParentId: from.ParentID, - Children: ConvertViewsToViewsPB(from.Edges.Children), - Parent: ConvertViewToViewPB(from.Edges.Parent), - Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Scope: from.Scope, + I18N: from.I18n, + Description: from.Description, + Sequence: int32(from.Sequence), + Type: ConvertTypeToString(from.Type), + Icon: from.Icon, + Visible: from.Visible, + Path: from.Path, + TreePath: from.TreePath, + Properties: from.Properties, + Status: int32(from.Status), + ParentId: from.ParentID, + Component: from.Component, + Children: ConvertViewsToViewsPB(from.Edges.Children), + Parent: ConvertViewToViewPB(from.Edges.Parent), + Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), } return to } diff --git a/internal/features/system/dto/dto.go b/internal/features/system/dto/dto.go index 410225b6..6034b65b 100644 --- a/internal/features/system/dto/dto.go +++ b/internal/features/system/dto/dto.go @@ -1,6 +1,8 @@ package dto import ( + "encoding/json" + "origadmin/application/admin/internal/data/entity/ent/user" "origadmin/application/admin/internal/data/entity/ent/view" ) @@ -19,6 +21,27 @@ const ( StatusDisabled = 0 ) +// ConvertStringToStringMapToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToStringMapToString(from map[string]string) string { + bytes, err := json.Marshal(from) + if err != nil { + return "" + } + return string(bytes) +} + +// ConvertStringToStringToStringMap is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToStringToStringMap(from string) map[string]string { + m := make(map[string]string) + err := json.Unmarshal([]byte(from), &m) + if err != nil { + return nil + } + return m +} + // ConvertGenderToString is a custom conversion function stub. // Please implement this function to complete the conversion. func ConvertGenderToString(from user.Gender) string { diff --git a/internal/features/system/dto/resource.go b/internal/features/system/dto/resource.go index 32b76292..db634c57 100644 --- a/internal/features/system/dto/resource.go +++ b/internal/features/system/dto/resource.go @@ -27,6 +27,7 @@ type ResourceRepo interface { // ResourceQueryOption specifies options for querying resources. type ResourceQueryOption struct { repo.QueryOption + Operation string WithPermissions bool } @@ -46,6 +47,8 @@ func ListResourcesRequestToQueryOption(req *system.ListResourcesRequest) *Resour } return &ResourceQueryOption{ QueryOption: repo.QueryOptionFromRequest(req), + //WithPermissions: req.WithPermissions, + Operation: req.Operation, } } diff --git a/internal/tasks/seeder/seeder.go b/internal/tasks/seeder/seeder.go index 1b26e645..e7eeb6d8 100644 --- a/internal/tasks/seeder/seeder.go +++ b/internal/tasks/seeder/seeder.go @@ -122,22 +122,19 @@ func (s *Seeder) createRootUser() error { func (s *Seeder) createInitialResources() error { ctx := context.Background() for _, policy := range security.RegisteredPolicies() { - // Check if resource already exists by its operation, which should be unique. _, count, err := s.resourceUseCase.ListResources(ctx, &system.ListResourcesRequest{ Operation: policy.ServiceMethod, OnlyCount: true, }) if err == nil && count > 0 { - s.log.Infof("Resource for operation '%s' already exists, skipping.", policy.ServiceMethod) + s.log.Infof("Resource '%s' already exists, skipping.", policy.ServiceMethod) continue } - - // If not exists, create it using the dedicated biz method. if _, err := s.resourceUseCase.CreateResourceFromPolicy(ctx, &policy); err != nil { - s.log.Errorf("failed to create resource from policy '%s': %v", policy.ServiceMethod, err) + s.log.Errorf("failed to create resource %s: %v", policy.ServiceMethod, err) } else { - s.log.Infof("Successfully created resource from policy: %s", policy.ServiceMethod) + s.log.Infof("Successfully created resource: %s", policy.ServiceMethod) } } return nil @@ -146,8 +143,8 @@ func (s *Seeder) createInitialResources() error { func (s *Seeder) createInitialViews() error { ctx := context.Background() views := []*types.View{ - {Name: "Dashboard", Keyword: "dashboard", Path: "/dashboard", Component: "default"}, - {Name: "System", Keyword: "system", Path: "/system", Component: "default"}, + {Name: "Dashboard", Keyword: "dashboard", Path: "/dashboard"}, // TODO: Add Component: "default" after proto regen + {Name: "System", Keyword: "system", Path: "/system"}, // TODO: Add Component: "default" after proto regen } for _, view := range views { diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 0d876829..ef97a28b 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -1248,6 +1248,10 @@ paths: in: query schema: type: string + - name: operation + in: query + schema: + type: string responses: "200": description: OK @@ -3163,9 +3167,9 @@ components: keyword: type: string description: resource.field.keyword - i18n_key: + i18n: type: string - description: resource.field.i18n_key + description: resource.field.i18n type: type: string description: resource.field.type @@ -3215,6 +3219,9 @@ components: service_name: type: string description: resource.field.service_name + policy: + type: string + description: resource.field.policy children: type: array items: @@ -3383,6 +3390,9 @@ components: type: string description: user.field.sanction_date format: date-time + department: + type: string + description: user.field.department roles: type: array items: @@ -3458,6 +3468,9 @@ components: parent_path: type: string description: ParentPath holds the value of the "parent_path" field. + component: + type: string + description: Component holds the value of the "component" field. children: type: array items: From 0f187d9611a918d039f6e105685b0a59445c2482 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 7 Jan 2026 19:04:55 +0800 Subject: [PATCH 154/158] feat(seed): enhance resource and DTO models with additional fields and improved policy handling --- Makefile | 25 +++--- internal/features/auth/dto/custom.gen.go | 14 +++ internal/features/auth/dto/dto.gen.go | 96 +++++++++++++------- internal/features/system/biz/resource.go | 5 +- internal/features/system/dal/resource.go | 25 ++++-- internal/features/system/dto/resource.go | 12 ++- internal/tasks/seeder/seeder.go | 106 +++++++++++++++++++++-- 7 files changed, 222 insertions(+), 61 deletions(-) diff --git a/Makefile b/Makefile index d8b35ad2..cf3759f5 100644 --- a/Makefile +++ b/Makefile @@ -163,22 +163,27 @@ release-all-in-one: build-ui #go generate ./cmd/system #generate system module #go generate ./cmd/internal/start #generate main module start gen: -# @echo "Generating Protobuf service api..." -# @buf dep update -# @buf build -# @buf generate -# -# @echo "Generating Protobuf code for conf/pb..." -# @protoc -I. -I./third_party --go_out=paths=source_relative:. --validate_out=paths=source_relative,lang=go:. ./internal/conf/pb/*.proto -# -# @echo "Generating Ent data..." -# @go generate ./internal/data/entity/ent/generate.go + @echo "Generating Protobuf service api..." + @buf dep update + @buf build + @buf generate + + @echo "Generating Protobuf code for conf/pb..." + @protoc -I. -I./third_party --go_out=paths=source_relative:. --validate_out=paths=source_relative,lang=go:. ./internal/conf/pb/*.proto + + @echo "Generating Ent data..." + @go generate ./internal/data/entity/ent/generate.go + @echo "Generating main wire..." @go generate ./cmd/seed/wire.work.go @go generate ./cmd/system/wire.work.go @go generate ./cmd/auth/wire.work.go @go generate ./cmd/gateway/wire.work.go + @echo "Generating dto data convert functions ..." + @go generate ./internal/features/system/dto + @go generate ./internal/features/auth/dto + .PHONY: all # generate all all: diff --git a/internal/features/auth/dto/custom.gen.go b/internal/features/auth/dto/custom.gen.go index 263fb2d7..b41a6c2a 100644 --- a/internal/features/auth/dto/custom.gen.go +++ b/internal/features/auth/dto/custom.gen.go @@ -2,3 +2,17 @@ // More info: https://github.com/origadmin/abgen package dto + +// ConvertStringToStringMapToString is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToStringMapToString(from map[string]string) string { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} + +// ConvertStringToStringToStringMap is a custom conversion function stub. +// Please implement this function to complete the conversion. +func ConvertStringToStringToStringMap(from string) map[string]string { + // TODO: Implement this custom conversion + panic("stub! not implemented") +} diff --git a/internal/features/auth/dto/dto.gen.go b/internal/features/auth/dto/dto.gen.go index 3f90cf4a..38231f4f 100644 --- a/internal/features/auth/dto/dto.gen.go +++ b/internal/features/auth/dto/dto.gen.go @@ -368,14 +368,22 @@ func ConvertResourcePBToResource(from *ResourcePB) *Resource { ID: from.Id, CreateTime: ConvertTimestampToTime(from.CreateTime), UpdateTime: ConvertTimestampToTime(from.UpdateTime), - Name: from.Name, - ServiceName: from.ServiceName, Keyword: from.Keyword, - Path: from.Path, + Name: from.Name, + I18n: from.I18N, + Type: from.Type, + Status: enums.Status(from.Status), + Sequence: int(from.Sequence), Method: from.Method, + Path: from.Path, Operation: from.Operation, + ServiceName: from.ServiceName, + Policy: from.Policy, SyncStatus: from.SyncStatus, - Status: enums.Status(from.Status), + TreePath: from.TreePath, + ParentID: from.ParentId, + Properties: ConvertStringToStringMapToString(from.Properties), + Description: from.Description, } return to } @@ -392,12 +400,22 @@ func ConvertResourceToResourcePB(from *Resource) *ResourcePB { UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), Name: from.Name, Keyword: from.Keyword, + I18N: from.I18n, + Type: from.Type, Status: int32(from.Status), Path: from.Path, Operation: from.Operation, Method: from.Method, + Sequence: int32(from.Sequence), + TreePath: from.TreePath, + Properties: ConvertStringToStringToStringMap(from.Properties), + Description: from.Description, + ParentId: from.ParentID, SyncStatus: from.SyncStatus, ServiceName: from.ServiceName, + Policy: from.Policy, + Children: ConvertResourcesToResourcesPB(from.Edges.Children), + Parent: ConvertResourceToResourcePB(from.Edges.Parent), Permissions: ConvertPermissionsToPermissionsPB(from.Edges.Permissions), } return to @@ -546,6 +564,7 @@ func ConvertUserPBToUser(from *UserPB) *User { Gender: ConvertStringToGender(from.Gender), Phone: from.Phone, Email: from.Email, + Department: from.Department, Remark: from.Remark, Token: from.Token, Status: enums.Status(from.Status), @@ -669,6 +688,7 @@ func ConvertUserToUserPB(from *User) *UserPB { LastLoginTime: ConvertTimeToTimestamp(from.LastLoginTime), LoginTime: ConvertTimeToTimestamp(from.LoginTime), SanctionDate: ConvertTimeToTimestamp(from.SanctionDate), + Department: from.Department, Roles: ConvertRolesToRolesPB(from.Edges.Roles), } return to @@ -705,19 +725,24 @@ func ConvertViewPBToView(from *ViewPB) *View { } to := &View{ - ID: from.Id, - CreateTime: ConvertTimestampToTime(from.CreateTime), - UpdateTime: ConvertTimestampToTime(from.UpdateTime), - ParentID: from.ParentId, - Keyword: from.Keyword, - Scope: from.Scope, - Name: from.Name, - Type: ConvertStringToType(from.Type), - Path: from.Path, - Icon: from.Icon, - Visible: from.Visible, - Sequence: int(from.Sequence), - TreePath: from.TreePath, + ID: from.Id, + CreateTime: ConvertTimestampToTime(from.CreateTime), + UpdateTime: ConvertTimestampToTime(from.UpdateTime), + ParentID: from.ParentId, + Keyword: from.Keyword, + Scope: from.Scope, + Name: from.Name, + I18n: from.I18N, + Type: ConvertStringToType(from.Type), + Component: from.Component, + Path: from.Path, + Icon: from.Icon, + Visible: from.Visible, + Sequence: int(from.Sequence), + TreePath: from.TreePath, + Description: from.Description, + Properties: from.Properties, + Status: enums.Status(from.Status), } return to } @@ -729,22 +754,27 @@ func ConvertViewToViewPB(from *View) *ViewPB { } to := &ViewPB{ - Id: from.ID, - CreateTime: ConvertTimeToTimestamp(from.CreateTime), - UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), - Keyword: from.Keyword, - Name: from.Name, - Scope: from.Scope, - Sequence: int32(from.Sequence), - Type: ConvertTypeToString(from.Type), - Icon: from.Icon, - Visible: from.Visible, - Path: from.Path, - TreePath: from.TreePath, - ParentId: from.ParentID, - Children: ConvertViewsToViewsPB(from.Edges.Children), - Parent: ConvertViewToViewPB(from.Edges.Parent), - Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), + Id: from.ID, + CreateTime: ConvertTimeToTimestamp(from.CreateTime), + UpdateTime: ConvertTimeToTimestamp(from.UpdateTime), + Keyword: from.Keyword, + Name: from.Name, + Scope: from.Scope, + I18N: from.I18n, + Description: from.Description, + Sequence: int32(from.Sequence), + Type: ConvertTypeToString(from.Type), + Icon: from.Icon, + Visible: from.Visible, + Path: from.Path, + TreePath: from.TreePath, + Properties: from.Properties, + Status: int32(from.Status), + ParentId: from.ParentID, + Component: from.Component, + Children: ConvertViewsToViewsPB(from.Edges.Children), + Parent: ConvertViewToViewPB(from.Edges.Parent), + Resources: ConvertResourcesToResourcesPB(from.Edges.Resources), } return to } diff --git a/internal/features/system/biz/resource.go b/internal/features/system/biz/resource.go index 7e6cacc6..f17a2ed6 100644 --- a/internal/features/system/biz/resource.go +++ b/internal/features/system/biz/resource.go @@ -8,7 +8,6 @@ package biz import ( "context" - "github.com/origadmin/contrib/security" "origadmin/application/admin/api/v1/services/system" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/enums" @@ -47,8 +46,8 @@ func (uc *ResourceUseCase) CreateResource(ctx context.Context, in *types.Resourc // CreateResourceFromPolicy creates a new resource based on a security policy definition. // This is intended for internal use, like database seeding. -func (uc *ResourceUseCase) CreateResourceFromPolicy(ctx context.Context, policy *security.Policy) (*types.Resource, error) { - return uc.repo.CreateFromPolicy(ctx, policy) +func (uc *ResourceUseCase) CreateResourceFromPolicy(ctx context.Context, input *dto.ResourceFromPolicyInput) (*types.Resource, error) { + return uc.repo.CreateFromPolicy(ctx, input) } func (uc *ResourceUseCase) UpdateResource(ctx context.Context, in *types.Resource) (*types.Resource, error) { diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index 43571129..4f9814d3 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -8,7 +8,6 @@ import ( "context" "strings" - "github.com/origadmin/contrib/security" "origadmin/application/admin/api/v1/services/types" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" @@ -56,6 +55,7 @@ func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ... entResource := dto.ConvertResourcePBToResource(res) create := r.db.Resource(ctx).Create(). SetResourceSkipZero(entResource). + SetName(res.Name). SetSyncStatus("Modified"). SetVersionID(""). SetLastSyncVersionID("") @@ -67,10 +67,8 @@ func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ... return dto.ConvertResourceToResourcePB(saved), nil } -func (r *resourceRepo) CreateFromPolicy(ctx context.Context, policy *security.Policy) (*types.Resource, error) { - // e.g. /api.v1.services.auth.AuthService/Login -> auth:auth:Login:write - keyword := strings.ReplaceAll(strings.TrimPrefix(policy.ServiceMethod, "/"), ".", ":") - keyword = strings.ReplaceAll(keyword, "Service", "") +func (r *resourceRepo) CreateFromPolicy(ctx context.Context, input *dto.ResourceFromPolicyInput) (*types.Resource, error) { + policy := input.Policy // Extract method and path from GatewayPath, e.g., "GET:/api/v1/users/{id}" var method, path string @@ -82,17 +80,26 @@ func (r *resourceRepo) CreateFromPolicy(ctx context.Context, policy *security.Po } create := r.db.Resource(ctx).Create(). - SetKeyword(keyword). + SetKeyword(input.Keyword). SetPath(path). SetMethod(method). SetOperation(policy.ServiceMethod). SetPolicy(policy.Name). SetVersionID(policy.VersionID). SetLastSyncVersionID(policy.VersionID). - SetSyncStatus("Synced") + SetSyncStatus("Synced"). + SetSequence(input.Sequence) - if policy.DisplayName != "" { - create.SetName(policy.DisplayName) + if input.DisplayName != "" { + create.SetName(input.DisplayName) + } + + if input.I18n != "" { + create.SetI18n(input.I18n) + } + + if input.ServiceName != "" { + create.SetServiceName(input.ServiceName) } saved, err := create.Save(ctx) diff --git a/internal/features/system/dto/resource.go b/internal/features/system/dto/resource.go index db634c57..1f732df9 100644 --- a/internal/features/system/dto/resource.go +++ b/internal/features/system/dto/resource.go @@ -19,11 +19,21 @@ type ResourceRepo interface { Get(context.Context, int64, ...*ResourceQueryOption) (*types.Resource, error) List(context.Context, ...*ResourceQueryOption) ([]*types.Resource, int32, error) Create(context.Context, *types.Resource, ...*ResourceCreateOption) (*types.Resource, error) - CreateFromPolicy(ctx context.Context, policy *security.Policy) (*types.Resource, error) + CreateFromPolicy(ctx context.Context, input *ResourceFromPolicyInput) (*types.Resource, error) Update(context.Context, *types.Resource, ...*ResourceUpdateOption) (*types.Resource, error) Delete(context.Context, int64) error } +// ResourceFromPolicyInput contains the data needed to create a resource from a policy. +type ResourceFromPolicyInput struct { + Policy *security.Policy + DisplayName string + I18n string + Sequence int + Keyword string + ServiceName string +} + // ResourceQueryOption specifies options for querying resources. type ResourceQueryOption struct { repo.QueryOption diff --git a/internal/tasks/seeder/seeder.go b/internal/tasks/seeder/seeder.go index e7eeb6d8..14f65824 100644 --- a/internal/tasks/seeder/seeder.go +++ b/internal/tasks/seeder/seeder.go @@ -8,7 +8,10 @@ package seeder import ( "context" "crypto/rand" + "fmt" "math/big" + "strings" + "unicode" "github.com/go-kratos/kratos/v2/log" "github.com/google/wire" @@ -19,6 +22,7 @@ import ( "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/conf/pb" "origadmin/application/admin/internal/features/system/biz" + "origadmin/application/admin/internal/features/system/dto" ) // ProviderSet is for wire injection. @@ -100,7 +104,13 @@ func (s *Seeder) createRootUser() error { s.log.Errorf("Failed to generate random password: %v", err) return err } - s.log.Infof("Generated random password for user '%s': %s", username, password) + // Use fmt.Printf with ANSI colors for high visibility + fmt.Printf("\n") + fmt.Printf("\033[1;32m==================== [Root User Created] ===================\033[0m\n") + fmt.Printf("\033[1;33mUsername: %s\033[0m\n", username) + fmt.Printf("\033[1;33mPassword: %s\033[0m\n", password) + fmt.Printf("\033[1;32m============================================================\033[0m\n") + fmt.Printf("\n") } newUser := &types.User{ @@ -121,21 +131,83 @@ func (s *Seeder) createRootUser() error { func (s *Seeder) createInitialResources() error { ctx := context.Background() + // Use a counter for sequence + seq := 1 for _, policy := range security.RegisteredPolicies() { + // Parse gRPC method: /package.Service/Method + // e.g. /api.v1.services.auth.AuthService/Login + parts := strings.Split(policy.ServiceMethod, "/") + if len(parts) < 3 { + s.log.Warnf("Skipping malformed service method: %s", policy.ServiceMethod) + continue + } + // parts[0] is empty, parts[1] is package.Service, parts[2] is Method + fullService := parts[1] + method := parts[2] + + // Parse Service: api.v1.services.auth.AuthService + serviceParts := strings.Split(fullService, ".") + if len(serviceParts) < 2 { + s.log.Warnf("Skipping malformed service name: %s", fullService) + continue + } + + // Extract Module Name (e.g. "auth" from "api.v1.services.auth.AuthService") + // Assuming standard structure: ...services.. + var moduleName string + if len(serviceParts) >= 2 { + // Take the second to last part as module name + moduleName = serviceParts[len(serviceParts)-2] + } else { + moduleName = "system" // Fallback + } + + // Ensure module name ends with "-service" + if !strings.HasSuffix(moduleName, "-service") { + moduleName += "-service" + } + + // Extract Resource Name (e.g. "Auth" from "AuthService") + serviceName := serviceParts[len(serviceParts)-1] + resourceName := strings.TrimSuffix(serviceName, "Service") + + // Construct Keyword: module:resource:method (e.g. auth-service:Auth:Login) + // Use toSnakeCase for resourceName and method to ensure consistency + keyword := strings.Join([]string{strings.ToLower(moduleName), toSnakeCase(resourceName), toSnakeCase(method)}, ":") + + // Construct Name: Resource Method (e.g. Auth Login) + // Convert CamelCase to Title Case with spaces + displayName := toTitleCase(resourceName) + " " + toTitleCase(method) + + // Construct I18n: resource.module.resource.method (e.g. resource.auth-service.auth.login) + i18nKey := "resource." + strings.ToLower(moduleName) + "." + toSnakeCase(resourceName) + "." + toSnakeCase(method) + + // Check if resource already exists _, count, err := s.resourceUseCase.ListResources(ctx, &system.ListResourcesRequest{ Operation: policy.ServiceMethod, OnlyCount: true, }) if err == nil && count > 0 { - s.log.Infof("Resource '%s' already exists, skipping.", policy.ServiceMethod) + s.log.Infof("Resource '%s' already exists, skipping.", keyword) continue } - if _, err := s.resourceUseCase.CreateResourceFromPolicy(ctx, &policy); err != nil { - s.log.Errorf("failed to create resource %s: %v", policy.ServiceMethod, err) + + input := &dto.ResourceFromPolicyInput{ + Policy: &policy, + DisplayName: displayName, + I18n: i18nKey, + Sequence: seq, + Keyword: keyword, + ServiceName: moduleName, + } + + if _, err := s.resourceUseCase.CreateResourceFromPolicy(ctx, input); err != nil { + s.log.Errorf("failed to create resource from policy '%s': %v", policy.ServiceMethod, err) } else { - s.log.Infof("Successfully created resource: %s", policy.ServiceMethod) + s.log.Infof("Successfully created resource from policy: %s", policy.ServiceMethod) } + seq++ } return nil } @@ -162,6 +234,30 @@ func (s *Seeder) createInitialViews() error { return nil } +// toTitleCase converts CamelCase to Title Case (e.g. "GetProfile" -> "Get Profile") +func toTitleCase(s string) string { + var result strings.Builder + for i, r := range s { + if i > 0 && unicode.IsUpper(r) { + result.WriteRune(' ') + } + result.WriteRune(r) + } + return result.String() +} + +// toSnakeCase converts CamelCase to snake_case (e.g. "GetProfile" -> "get_profile") +func toSnakeCase(s string) string { + var result strings.Builder + for i, r := range s { + if i > 0 && unicode.IsUpper(r) { + result.WriteRune('_') + } + result.WriteRune(unicode.ToLower(r)) + } + return result.String() +} + // generateRandomPassword creates a random string of a given length. func generateRandomPassword(length int) (string, error) { b := make([]byte, length) From 2501a92cf788d96b919388e9f7e24358c6f9de91 Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 7 Jan 2026 20:27:50 +0800 Subject: [PATCH 155/158] feat(api): standardize API prefix and resource path handling with configurable prefix --- ...go build origadmin_application_admin.run.xml | 12 ------------ ...origadmin_application_admin_cmd_auth.run.xml | 8 ++++++++ ...origadmin_application_admin_cmd_seed.run.xml | 10 ++++++++++ ...igadmin_application_admin_cmd_system.run.xml | 8 ++++++++ internal/conf/config.go | 5 +++++ internal/features/system/dal/resource.go | 6 ++++++ internal/gateway/server/server.go | 3 ++- internal/tasks/seeder/seeder.go | 17 +++++++++-------- 8 files changed, 48 insertions(+), 21 deletions(-) delete mode 100644 .run/go build origadmin_application_admin.run.xml create mode 100644 .run/go build origadmin_application_admin_cmd_seed.run.xml diff --git a/.run/go build origadmin_application_admin.run.xml b/.run/go build origadmin_application_admin.run.xml deleted file mode 100644 index 61937aa2..00000000 --- a/.run/go build origadmin_application_admin.run.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.run/go build origadmin_application_admin_cmd_auth.run.xml b/.run/go build origadmin_application_admin_cmd_auth.run.xml index ceb79f01..977dab80 100644 --- a/.run/go build origadmin_application_admin_cmd_auth.run.xml +++ b/.run/go build origadmin_application_admin_cmd_auth.run.xml @@ -9,4 +9,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.run/go build origadmin_application_admin_cmd_seed.run.xml b/.run/go build origadmin_application_admin_cmd_seed.run.xml new file mode 100644 index 00000000..e7f9767b --- /dev/null +++ b/.run/go build origadmin_application_admin_cmd_seed.run.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.run/go build origadmin_application_admin_cmd_system.run.xml b/.run/go build origadmin_application_admin_cmd_system.run.xml index 2f0671b6..75b6b697 100644 --- a/.run/go build origadmin_application_admin_cmd_system.run.xml +++ b/.run/go build origadmin_application_admin_cmd_system.run.xml @@ -9,4 +9,12 @@ + + + + + + + + \ No newline at end of file diff --git a/internal/conf/config.go b/internal/conf/config.go index 3319cbc1..375d675e 100644 --- a/internal/conf/config.go +++ b/internal/conf/config.go @@ -12,6 +12,11 @@ import ( confpb "origadmin/application/admin/internal/conf/pb" ) +const ( + // APIPrefix is the prefix for all API routes. + APIPrefix = "/api/v1" +) + type Config struct { Bootstrap confpb.Bootstrap } diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index 4f9814d3..593b5bb4 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -9,6 +9,7 @@ import ( "strings" "origadmin/application/admin/api/v1/services/types" + "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/data/entity/ent" "origadmin/application/admin/internal/data/entity/ent/resource" "origadmin/application/admin/internal/features/system/dto" @@ -79,6 +80,11 @@ func (r *resourceRepo) CreateFromPolicy(ctx context.Context, input *dto.Resource } } + // Ensure path has the correct prefix + if path != "" && !strings.HasPrefix(path, conf.APIPrefix) { + path = conf.APIPrefix + path + } + create := r.db.Resource(ctx).Create(). SetKeyword(input.Keyword). SetPath(path). diff --git a/internal/gateway/server/server.go b/internal/gateway/server/server.go index 081efe6f..5d4177e5 100644 --- a/internal/gateway/server/server.go +++ b/internal/gateway/server/server.go @@ -19,6 +19,7 @@ import ( "github.com/origadmin/runtime/container" "github.com/origadmin/runtime/service/transport" "github.com/origadmin/runtime/service/transport/http" + "origadmin/application/admin/internal/conf" "origadmin/application/admin/internal/gateway/service" "origadmin/application/admin/internal/gateway/web" ) @@ -80,7 +81,7 @@ func NewHTTPServer( } serverOpts := []kratoshttp.ServerOption{ - kratoshttp.PathPrefix("/api/v1"), + kratoshttp.PathPrefix(conf.APIPrefix), } log.NewHelper(app.Logger()).Infow("msg", "Registering middleware", "middlewares", maps.Keys(mws)) diff --git a/internal/tasks/seeder/seeder.go b/internal/tasks/seeder/seeder.go index 14f65824..c1cc65e0 100644 --- a/internal/tasks/seeder/seeder.go +++ b/internal/tasks/seeder/seeder.go @@ -162,16 +162,11 @@ func (s *Seeder) createInitialResources() error { moduleName = "system" // Fallback } - // Ensure module name ends with "-service" - if !strings.HasSuffix(moduleName, "-service") { - moduleName += "-service" - } - // Extract Resource Name (e.g. "Auth" from "AuthService") serviceName := serviceParts[len(serviceParts)-1] resourceName := strings.TrimSuffix(serviceName, "Service") - // Construct Keyword: module:resource:method (e.g. auth-service:Auth:Login) + // Construct Keyword: module:resource:method (e.g. auth:auth:login) // Use toSnakeCase for resourceName and method to ensure consistency keyword := strings.Join([]string{strings.ToLower(moduleName), toSnakeCase(resourceName), toSnakeCase(method)}, ":") @@ -179,9 +174,15 @@ func (s *Seeder) createInitialResources() error { // Convert CamelCase to Title Case with spaces displayName := toTitleCase(resourceName) + " " + toTitleCase(method) - // Construct I18n: resource.module.resource.method (e.g. resource.auth-service.auth.login) + // Construct I18n: resource.module.resource.method (e.g. resource.auth.auth.login) i18nKey := "resource." + strings.ToLower(moduleName) + "." + toSnakeCase(resourceName) + "." + toSnakeCase(method) + // Ensure service name ends with "-service" + fullServiceName := moduleName + if !strings.HasSuffix(fullServiceName, "-service") { + fullServiceName += "-service" + } + // Check if resource already exists _, count, err := s.resourceUseCase.ListResources(ctx, &system.ListResourcesRequest{ @@ -199,7 +200,7 @@ func (s *Seeder) createInitialResources() error { I18n: i18nKey, Sequence: seq, Keyword: keyword, - ServiceName: moduleName, + ServiceName: fullServiceName, } if _, err := s.resourceUseCase.CreateResourceFromPolicy(ctx, input); err != nil { From dc6612de9a0aeae562a42dfe5b3a3b70b1524f7c Mon Sep 17 00:00:00 2001 From: godcong Date: Wed, 7 Jan 2026 23:01:14 +0800 Subject: [PATCH 156/158] feat(system): remove unused fields from View, Role and Resource proto definitions --- api/v1/proto/types/system.proto | 12 ---- api/v1/services/types/system.pb.go | 77 +++------------------ api/v1/services/types/system.pb.validate.go | 12 ---- internal/data/entity/ent/internal/schema.go | 2 +- internal/data/entity/ent/migrate/schema.go | 3 +- internal/data/entity/ent/mutation.go | 56 +-------------- internal/data/entity/ent/mutation_fields.go | 7 -- internal/data/entity/ent/runtime/runtime.go | 24 +++---- internal/data/entity/ent/schema/user.go | 3 - internal/data/entity/ent/user.go | 13 +--- internal/data/entity/ent/user/user.go | 12 ---- internal/data/entity/ent/user/where.go | 70 ------------------- internal/data/entity/ent/user_create.go | 30 -------- internal/data/entity/ent/user_query.go | 2 - internal/data/entity/ent/user_update.go | 44 ------------ internal/features/system/dto/schema_test.go | 48 +++++++++---- resources/api-docs/openapi/openapi.yaml | 18 ----- 17 files changed, 56 insertions(+), 377 deletions(-) diff --git a/api/v1/proto/types/system.proto b/api/v1/proto/types/system.proto index f4d9d211..a8a3c858 100644 --- a/api/v1/proto/types/system.proto +++ b/api/v1/proto/types/system.proto @@ -32,8 +32,6 @@ message View { int32 sequence = 9 [json_name = "sequence"]; // Type holds the value of the "type" field. string type = 10 [json_name = "type"]; - // Comment holds the value of the "comment" field. - string comment = 11 [json_name = "comment"]; // Icon holds the value of the "icon" field. string icon = 12 [json_name = "icon"]; // Visible holds the value of the "visible" field. @@ -48,8 +46,6 @@ message View { int32 status = 17 [json_name = "status"]; // ParentID holds the value of the "parent_id" field. int64 parent_id = 18 [json_name = "parent_id"]; - // ParentPath holds the value of the "parent_path" field. - string parent_path = 19 [json_name = "parent_path"]; // Component holds the value of the "component" field. string component = 20 [json_name = "component"]; // Children holds the value of the children edge. @@ -83,8 +79,6 @@ message Role { int32 sequence = 8 [json_name = "sequence"]; // role.field.status int32 status = 9 [json_name = "status"]; - // role.field.is_types - bool is_types = 10 [json_name = "is_types"]; // Views holds the value of the views edge. repeated View views = 100 [json_name = "views"]; // Users holds the value of the users edge. @@ -217,14 +211,8 @@ message Resource { string operation = 10 [json_name = "operation"]; // resource.field.method string method = 11 [json_name = "method"]; - // resource.field.component - string component = 12 [json_name = "component"]; - // resource.field.icon - string icon = 13 [json_name = "icon"]; // resource.field.sequence int32 sequence = 14 [json_name = "sequence"]; - // resource.field.visible - bool visible = 15 [json_name = "visible"]; // resource.field.tree_path string tree_path = 16 [json_name = "tree_path"]; // resource.field.properties diff --git a/api/v1/services/types/system.pb.go b/api/v1/services/types/system.pb.go index 6745dfa4..69be5cb1 100644 --- a/api/v1/services/types/system.pb.go +++ b/api/v1/services/types/system.pb.go @@ -45,8 +45,6 @@ type View struct { Sequence int32 `protobuf:"varint,9,opt,name=sequence,proto3" json:"sequence,omitempty"` // Type holds the value of the "type" field. Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` - // Comment holds the value of the "comment" field. - Comment string `protobuf:"bytes,11,opt,name=comment,proto3" json:"comment,omitempty"` // Icon holds the value of the "icon" field. Icon string `protobuf:"bytes,12,opt,name=icon,proto3" json:"icon,omitempty"` // Visible holds the value of the "visible" field. @@ -61,8 +59,6 @@ type View struct { Status int32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` // ParentID holds the value of the "parent_id" field. ParentId int64 `protobuf:"varint,18,opt,name=parent_id,proto3" json:"parent_id,omitempty"` - // ParentPath holds the value of the "parent_path" field. - ParentPath string `protobuf:"bytes,19,opt,name=parent_path,proto3" json:"parent_path,omitempty"` // Component holds the value of the "component" field. Component string `protobuf:"bytes,20,opt,name=component,proto3" json:"component,omitempty"` // Children holds the value of the children edge. @@ -177,13 +173,6 @@ func (x *View) GetType() string { return "" } -func (x *View) GetComment() string { - if x != nil { - return x.Comment - } - return "" -} - func (x *View) GetIcon() string { if x != nil { return x.Icon @@ -233,13 +222,6 @@ func (x *View) GetParentId() int64 { return 0 } -func (x *View) GetParentPath() string { - if x != nil { - return x.ParentPath - } - return "" -} - func (x *View) GetComponent() string { if x != nil { return x.Component @@ -297,8 +279,6 @@ type Role struct { Sequence int32 `protobuf:"varint,8,opt,name=sequence,proto3" json:"sequence,omitempty"` // role.field.status Status int32 `protobuf:"varint,9,opt,name=status,proto3" json:"status,omitempty"` - // role.field.is_types - IsTypes bool `protobuf:"varint,10,opt,name=is_types,proto3" json:"is_types,omitempty"` // Views holds the value of the views edge. Views []*View `protobuf:"bytes,100,rep,name=views,proto3" json:"views,omitempty"` // Users holds the value of the users edge. @@ -408,13 +388,6 @@ func (x *Role) GetStatus() int32 { return 0 } -func (x *Role) GetIsTypes() bool { - if x != nil { - return x.IsTypes - } - return false -} - func (x *Role) GetViews() []*View { if x != nil { return x.Views @@ -955,14 +928,8 @@ type Resource struct { Operation string `protobuf:"bytes,10,opt,name=operation,proto3" json:"operation,omitempty"` // resource.field.method Method string `protobuf:"bytes,11,opt,name=method,proto3" json:"method,omitempty"` - // resource.field.component - Component string `protobuf:"bytes,12,opt,name=component,proto3" json:"component,omitempty"` - // resource.field.icon - Icon string `protobuf:"bytes,13,opt,name=icon,proto3" json:"icon,omitempty"` // resource.field.sequence Sequence int32 `protobuf:"varint,14,opt,name=sequence,proto3" json:"sequence,omitempty"` - // resource.field.visible - Visible bool `protobuf:"varint,15,opt,name=visible,proto3" json:"visible,omitempty"` // resource.field.tree_path TreePath string `protobuf:"bytes,16,opt,name=tree_path,proto3" json:"tree_path,omitempty"` // resource.field.properties @@ -1096,20 +1063,6 @@ func (x *Resource) GetMethod() string { return "" } -func (x *Resource) GetComponent() string { - if x != nil { - return x.Component - } - return "" -} - -func (x *Resource) GetIcon() string { - if x != nil { - return x.Icon - } - return "" -} - func (x *Resource) GetSequence() int32 { if x != nil { return x.Sequence @@ -1117,13 +1070,6 @@ func (x *Resource) GetSequence() int32 { return 0 } -func (x *Resource) GetVisible() bool { - if x != nil { - return x.Visible - } - return false -} - func (x *Resource) GetTreePath() string { if x != nil { return x.TreePath @@ -2032,7 +1978,7 @@ var File_types_system_proto protoreflect.FileDescriptor const file_types_system_proto_rawDesc = "" + "\n" + - "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xac\x06\n" + + "\x12types/system.proto\x12\x15api.v1.services.types\x1a\x1fgoogle/protobuf/timestamp.proto\"\xf0\x05\n" + "\x04View\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + @@ -2044,8 +1990,7 @@ const file_types_system_proto_rawDesc = "" + "\vdescription\x18\b \x01(\tR\vdescription\x12\x1a\n" + "\bsequence\x18\t \x01(\x05R\bsequence\x12\x12\n" + "\x04type\x18\n" + - " \x01(\tR\x04type\x12\x18\n" + - "\acomment\x18\v \x01(\tR\acomment\x12\x12\n" + + " \x01(\tR\x04type\x12\x12\n" + "\x04icon\x18\f \x01(\tR\x04icon\x12\x18\n" + "\avisible\x18\r \x01(\bR\avisible\x12\x12\n" + "\x04path\x18\x0e \x01(\tR\x04path\x12\x1c\n" + @@ -2054,13 +1999,12 @@ const file_types_system_proto_rawDesc = "" + "properties\x18\x10 \x01(\tR\n" + "properties\x12\x16\n" + "\x06status\x18\x11 \x01(\x05R\x06status\x12\x1c\n" + - "\tparent_id\x18\x12 \x01(\x03R\tparent_id\x12 \n" + - "\vparent_path\x18\x13 \x01(\tR\vparent_path\x12\x1c\n" + + "\tparent_id\x18\x12 \x01(\x03R\tparent_id\x12\x1c\n" + "\tcomponent\x18\x14 \x01(\tR\tcomponent\x127\n" + "\bchildren\x18d \x03(\v2\x1b.api.v1.services.types.ViewR\bchildren\x123\n" + "\x06parent\x18e \x01(\v2\x1b.api.v1.services.types.ViewR\x06parent\x12=\n" + "\tresources\x18f \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x121\n" + - "\x05roles\x18g \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xfc\x04\n" + + "\x05roles\x18g \x03(\v2\x1b.api.v1.services.types.RoleR\x05roles\"\xe0\x04\n" + "\x04Role\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + @@ -2070,9 +2014,7 @@ const file_types_system_proto_rawDesc = "" + "\vdescription\x18\x06 \x01(\tR\vdescription\x12\x12\n" + "\x04type\x18\a \x01(\x05R\x04type\x12\x1a\n" + "\bsequence\x18\b \x01(\x05R\bsequence\x12\x16\n" + - "\x06status\x18\t \x01(\x05R\x06status\x12\x1a\n" + - "\bis_types\x18\n" + - " \x01(\bR\bis_types\x121\n" + + "\x06status\x18\t \x01(\x05R\x06status\x121\n" + "\x05views\x18d \x03(\v2\x1b.api.v1.services.types.ViewR\x05views\x121\n" + "\x05users\x18e \x03(\v2\x1b.api.v1.services.types.UserR\x05users\x12=\n" + "\tresources\x18f \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\"\n" + @@ -2129,7 +2071,7 @@ const file_types_system_proto_rawDesc = "" + "\arole_id\x18\x04 \x01(\x03R\arole_id\x12\x18\n" + "\aview_id\x18\x05 \x01(\x03R\aview_id\x12/\n" + "\x04role\x18d \x01(\v2\x1b.api.v1.services.types.RoleR\x04role\x12/\n" + - "\x04view\x18e \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\xe5\a\n" + + "\x04view\x18e \x01(\v2\x1b.api.v1.services.types.ViewR\x04view\"\x99\a\n" + "\bResource\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12<\n" + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\vcreate_time\x12<\n" + @@ -2142,11 +2084,8 @@ const file_types_system_proto_rawDesc = "" + "\x04path\x18\t \x01(\tR\x04path\x12\x1c\n" + "\toperation\x18\n" + " \x01(\tR\toperation\x12\x16\n" + - "\x06method\x18\v \x01(\tR\x06method\x12\x1c\n" + - "\tcomponent\x18\f \x01(\tR\tcomponent\x12\x12\n" + - "\x04icon\x18\r \x01(\tR\x04icon\x12\x1a\n" + - "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x18\n" + - "\avisible\x18\x0f \x01(\bR\avisible\x12\x1c\n" + + "\x06method\x18\v \x01(\tR\x06method\x12\x1a\n" + + "\bsequence\x18\x0e \x01(\x05R\bsequence\x12\x1c\n" + "\ttree_path\x18\x10 \x01(\tR\ttree_path\x12O\n" + "\n" + "properties\x18\x11 \x03(\v2/.api.v1.services.types.Resource.PropertiesEntryR\n" + diff --git a/api/v1/services/types/system.pb.validate.go b/api/v1/services/types/system.pb.validate.go index 81c5df3c..cace3ea1 100644 --- a/api/v1/services/types/system.pb.validate.go +++ b/api/v1/services/types/system.pb.validate.go @@ -130,8 +130,6 @@ func (m *View) validate(all bool) error { // no validation rules for Type - // no validation rules for Comment - // no validation rules for Icon // no validation rules for Visible @@ -146,8 +144,6 @@ func (m *View) validate(all bool) error { // no validation rules for ParentId - // no validation rules for ParentPath - // no validation rules for Component for idx, item := range m.GetChildren() { @@ -451,8 +447,6 @@ func (m *Role) validate(all bool) error { // no validation rules for Status - // no validation rules for IsTypes - for idx, item := range m.GetViews() { _, _ = idx, item @@ -1525,14 +1519,8 @@ func (m *Resource) validate(all bool) error { // no validation rules for Method - // no validation rules for Component - - // no validation rules for Icon - // no validation rules for Sequence - // no validation rules for Visible - // no validation rules for TreePath // no validation rules for Properties diff --git a/internal/data/entity/ent/internal/schema.go b/internal/data/entity/ent/internal/schema.go index 512eaa10..afd5556a 100644 --- a/internal/data/entity/ent/internal/schema.go +++ b/internal/data/entity/ent/internal/schema.go @@ -6,4 +6,4 @@ // Package internal holds a loadable version of the latest schema. package internal -const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Resource\"},\"unique\":true,\"inverse\":true},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"API\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.resource.field.parent_id\"},{\"name\":\"properties\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.i18n\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":21,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.i18n\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.description\"},{\"name\":\"properties\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.properties\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" +const Schema = "{\"Schema\":\"origadmin/application/admin/internal/data/entity/ent/schema\",\"Package\":\"origadmin/application/admin/internal/data/entity/ent\",\"Schemas\":[{\"name\":\"CasbinRule\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"Ptype\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V0\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V1\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V2\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V3\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V4\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0}},{\"name\":\"V5\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0}}]},{\"name\":\"Department\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"departments\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\"},{\"name\":\"parent\",\"type\":\"Department\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Department\"},\"unique\":true,\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.name\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.menu.field.tree_path\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.status\"},{\"name\":\"level\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":1,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.level\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.department.field.description\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"department.field.parent_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.department.table.comment\"},\"EntSQL\":{\"table\":\"sys_departments\",\"with_comments\":true}}},{\"name\":\"Notification\",\"config\":{\"Table\":\"\"},\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"subject\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.subject\"},{\"name\":\"content\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.content\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":0,\"default_kind\":3,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.notification.field.status\"},{\"name\":\"category_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.notification.field.category_id\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.notification.table.comment\"},\"EntSQL\":{\"table\":\"msg_notifications\",\"with_comments\":true}}},{\"name\":\"Permission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"inverse\":true},{\"name\":\"positions\",\"type\":\"Position\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"},\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"permission_resources\",\"T\":\"PermissionResource\"}},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"permissions\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"},\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.description\"},{\"name\":\"data_scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"self\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_scope\"},{\"name\":\"data_rules\",\"type\":{\"Type\":3,\"Ident\":\"map[string]string\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":true,\"RType\":{\"Name\":\"\",\"Ident\":\"map[string]string\",\"Kind\":21,\"PkgPath\":\"\",\"Methods\":{}}},\"optional\":true,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.data_rules\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.status\"},{\"name\":\"actions\",\"type\":{\"Type\":6,\"Ident\":\"permission.Actions\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"read\",\"V\":\"read\"},{\"N\":\"write\",\"V\":\"write\"},{\"N\":\"delete\",\"V\":\"delete\"},{\"N\":\"manage\",\"V\":\"manage\"}],\"default\":true,\"default_value\":\"read\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.permission.field.actions\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_permissions\",\"with_comments\":true}}},{\"name\":\"PermissionResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"permission_id\",\"resource_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.permission_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_permission_resources\",\"with_comments\":true}}},{\"name\":\"Position\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"ref_name\":\"positions\",\"unique\":true,\"inverse\":true,\"required\":true},{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"positions\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"position_permissions\",\"T\":\"PositionPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.name\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.keyword\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.position.field.description\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.department.field.department_id\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position.table.comment\"},\"EntSQL\":{\"table\":\"sys_positions\",\"with_comments\":true}}},{\"name\":\"PositionPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.position_id\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"position_permission.field.permission_id\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"position_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.position_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_position_permissions\",\"with_comments\":true}}},{\"name\":\"Resource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"Resource\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"Resource\"},\"unique\":true,\"inverse\":true},{\"name\":\"views\",\"type\":\"View\",\"ref_name\":\"resources\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"ref_name\":\"resources\",\"inverse\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.name\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.i18n\"},{\"name\":\"type\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"API\",\"default_kind\":24,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.type\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.status\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sequence\"},{\"name\":\"method\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.method\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.path\"},{\"name\":\"operation\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.operation\"},{\"name\":\"service_name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.service_name\"},{\"name\":\"policy\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.policy\"},{\"name\":\"version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.version_id\"},{\"name\":\"last_sync_version_id\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.last_sync_version_id\"},{\"name\":\"sync_status\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"Synced\",\"default_kind\":24,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.sync_status\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.tree_path\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.resource.field.parent_id\"},{\"name\":\"properties\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.properties\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.resource.field.description\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_resources\",\"with_comments\":true}}},{\"name\":\"Role\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"users\",\"type\":\"User\",\"ref_name\":\"roles\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"},\"inverse\":true},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"role_permissions\",\"T\":\"RolePermission\"},\"storage_key\":{\"Table\":\"\",\"Symbols\":null,\"Columns\":[\"role_id\",\"permission_id\"]}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.keyword\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":128,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.name\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.description\"},{\"name\":\"type\",\"type\":{\"Type\":9,\"Ident\":\"enums.RoleType\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"RoleType\",\"Ident\":\"enums.RoleType\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":2,\"default_kind\":3,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.type\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.sequence\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.role.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"keyword\"]},{\"fields\":[\"name\"]},{\"fields\":[\"sequence\"]},{\"fields\":[\"status\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role.table.comment\"},\"EntSQL\":{\"table\":\"sys_roles\",\"with_comments\":true}}},{\"name\":\"RolePermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"role_id\",\"permission_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.role_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_role_permissions\",\"with_comments\":true}}},{\"name\":\"User\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"roles\",\"type\":\"Role\",\"through\":{\"N\":\"user_roles\",\"T\":\"UserRole\"}},{\"name\":\"positions\",\"type\":\"Position\",\"through\":{\"N\":\"user_positions\",\"T\":\"UserPosition\"}},{\"name\":\"departments\",\"type\":\"Department\",\"through\":{\"N\":\"user_departments\",\"T\":\"UserDepartment\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"delete_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"nillable\":true,\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},\"comment\":\"delete_time.field.comment\"},{\"name\":\"uuid\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":36,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.uuid\"},{\"name\":\"allowed_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"0.0.0.0\",\"default_kind\":24,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.allowed_ip\"},{\"name\":\"username\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"unique\":true,\"validators\":1,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.username\"},{\"name\":\"nickname\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"avatar\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.avatar\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.nickname\"},{\"name\":\"gender\",\"type\":{\"Type\":6,\"Ident\":\"user.Gender\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"male\",\"V\":\"male\"},{\"N\":\"female\",\"V\":\"female\"},{\"N\":\"unknown\",\"V\":\"unknown\"}],\"default\":true,\"default_value\":\"unknown\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.gender\"},{\"name\":\"encrypted_password\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":256,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.encrypted_password\"},{\"name\":\"salt\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.salt\",\"deprecated\":true,\"deprecated_reason\":\"toolkits/crypto includes salt management\"},{\"name\":\"phone\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.phone\"},{\"name\":\"email\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.email\"},{\"name\":\"department\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":64,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.department\"},{\"name\":\"remark\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":1024,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.remark\"},{\"name\":\"token\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":512,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.token\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.status\"},{\"name\":\"is_system\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":false,\"default_kind\":1,\"position\":{\"Index\":15,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.is_system\"},{\"name\":\"last_login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":16,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_ip\"},{\"name\":\"login_ip\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":32,\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"validators\":1,\"position\":{\"Index\":17,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_ip\"},{\"name\":\"last_login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":18,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.last_login_time\"},{\"name\":\"login_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"position\":{\"Index\":19,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.login_time\"},{\"name\":\"sanction_date\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":20,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.user.field.sanction_date\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"fields\":[\"username\"]},{\"fields\":[\"phone\"]},{\"fields\":[\"email\"]},{\"fields\":[\"status\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0}],\"interceptors\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":4},{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user.table.comment\"},\"EntSQL\":{\"table\":\"sys_users\",\"with_comments\":true}}},{\"name\":\"UserDepartment\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"department\",\"type\":\"Department\",\"field\":\"department_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"department_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"department_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_department.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_departments\",\"with_comments\":true}}},{\"name\":\"UserPosition\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"position\",\"type\":\"Position\",\"field\":\"position_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"position_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"position_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_position.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_positions\",\"with_comments\":true}}},{\"name\":\"UserRole\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"user\",\"type\":\"User\",\"field\":\"user_id\",\"unique\":true,\"required\":true},{\"name\":\"role\",\"type\":\"Role\",\"field\":\"role_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"user_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"},{\"name\":\"role_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.foreign_key.comment\"}],\"indexes\":[{\"unique\":true,\"fields\":[\"user_id\",\"role_id\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.user_role.table.comment\"},\"EntSQL\":{\"table\":\"sys_user_roles\",\"with_comments\":true}}},{\"name\":\"View\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"parent\",\"type\":\"View\",\"field\":\"parent_id\",\"ref\":{\"name\":\"children\",\"type\":\"View\"},\"unique\":true,\"inverse\":true},{\"name\":\"resources\",\"type\":\"Resource\",\"through\":{\"N\":\"view_resources\",\"T\":\"ViewResource\"}},{\"name\":\"permissions\",\"type\":\"Permission\",\"through\":{\"N\":\"view_permissions\",\"T\":\"ViewPermission\"}}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"update_time.field.comment\"},{\"name\":\"parent_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"entity.view.field.parent_id\"},{\"name\":\"keyword\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"size\":255,\"unique\":true,\"validators\":2,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.keyword\"},{\"name\":\"scope\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"default\",\"default_kind\":24,\"position\":{\"Index\":2,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.scope\"},{\"name\":\"name\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"position\":{\"Index\":3,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.name\"},{\"name\":\"i18n\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":4,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.i18n\"},{\"name\":\"type\",\"type\":{\"Type\":6,\"Ident\":\"view.Type\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"enums\":[{\"N\":\"T\",\"V\":\"T\"},{\"N\":\"G\",\"V\":\"G\"},{\"N\":\"M\",\"V\":\"M\"},{\"N\":\"L\",\"V\":\"L\"},{\"N\":\"P\",\"V\":\"P\"},{\"N\":\"B\",\"V\":\"B\"},{\"N\":\"E\",\"V\":\"E\"},{\"N\":\"R\",\"V\":\"R\"},{\"N\":\"U\",\"V\":\"U\"}],\"default\":true,\"default_value\":\"U\",\"default_kind\":24,\"position\":{\"Index\":5,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.type\"},{\"name\":\"component\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":6,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.component\"},{\"name\":\"path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":7,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.path\"},{\"name\":\"icon\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":8,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.icon\"},{\"name\":\"visible\",\"type\":{\"Type\":1,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":true,\"default_kind\":1,\"position\":{\"Index\":9,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.visible\"},{\"name\":\"sequence\",\"type\":{\"Type\":12,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":0,\"default_kind\":2,\"position\":{\"Index\":10,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.sequence\"},{\"name\":\"tree_path\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":11,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.tree_path\"},{\"name\":\"description\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":12,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.description\"},{\"name\":\"properties\",\"type\":{\"Type\":7,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_value\":\"\",\"default_kind\":24,\"position\":{\"Index\":13,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.properties\"},{\"name\":\"status\",\"type\":{\"Type\":9,\"Ident\":\"enums.Status\",\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"PkgName\":\"enums\",\"Nillable\":false,\"RType\":{\"Name\":\"Status\",\"Ident\":\"enums.Status\",\"Kind\":3,\"PkgPath\":\"origadmin/application/admin/internal/data/enums\",\"Methods\":{\"String\":{\"In\":[],\"Out\":[{\"Name\":\"string\",\"Ident\":\"string\",\"Kind\":24,\"PkgPath\":\"\",\"Methods\":null}]}}}},\"default\":true,\"default_value\":1,\"default_kind\":3,\"position\":{\"Index\":14,\"MixedIn\":false,\"MixinIndex\":0},\"comment\":\"entity.view.field.status\"}],\"indexes\":[{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"keyword\",\"scope\"]}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view.table.comment\"},\"EntSQL\":{\"table\":\"sys_views\",\"with_comments\":true}}},{\"name\":\"ViewPermission\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"permission\",\"type\":\"Permission\",\"field\":\"permission_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.view_id.comment\"},{\"name\":\"permission_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_permission.permission_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"permission_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_permission.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_permissions\",\"with_comments\":true}}},{\"name\":\"ViewResource\",\"config\":{\"Table\":\"\"},\"edges\":[{\"name\":\"view\",\"type\":\"View\",\"field\":\"view_id\",\"unique\":true,\"required\":true},{\"name\":\"resource\",\"type\":\"Resource\",\"field\":\"resource_id\",\"unique\":true,\"required\":true}],\"fields\":[{\"name\":\"id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"unique\":true,\"default\":true,\"default_kind\":19,\"immutable\":true,\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"field.primary_key.comment\"},{\"name\":\"create_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"create_author.field.comment\"},{\"name\":\"update_author\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"optional\":true,\"default\":true,\"default_value\":0,\"default_kind\":6,\"position\":{\"Index\":1,\"MixedIn\":true,\"MixinIndex\":1},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"update_author.field.comment\"},{\"name\":\"create_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"immutable\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":2},\"comment\":\"create_time.field.comment\"},{\"name\":\"update_time\",\"type\":{\"Type\":2,\"Ident\":\"\",\"PkgPath\":\"time\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"default\":true,\"default_kind\":19,\"update_default\":true,\"position\":{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":3},\"comment\":\"update_time.field.comment\"},{\"name\":\"view_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":0,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.view_id.comment\"},{\"name\":\"resource_id\",\"type\":{\"Type\":13,\"Ident\":\"\",\"PkgPath\":\"\",\"PkgName\":\"\",\"Nillable\":false,\"RType\":null},\"validators\":1,\"position\":{\"Index\":1,\"MixedIn\":false,\"MixinIndex\":0},\"annotations\":{\"EntSQL\":{\"incremental\":false}},\"comment\":\"view_resource.resource_id.comment\"}],\"indexes\":[{\"fields\":[\"create_author\"]},{\"fields\":[\"update_author\"]},{\"fields\":[\"create_time\"]},{\"fields\":[\"update_time\"]},{\"unique\":true,\"fields\":[\"view_id\",\"resource_id\"]}],\"hooks\":[{\"Index\":0,\"MixedIn\":true,\"MixinIndex\":1}],\"annotations\":{\"Comment\":{\"Text\":\"entity.view_resource.table.comment\"},\"EntSQL\":{\"table\":\"sys_view_resources\",\"with_comments\":true}}}],\"Features\":[\"intercept\",\"schema/snapshot\",\"sql/versioned-migration\",\"sql/lock\",\"sql/modifier\"]}" diff --git a/internal/data/entity/ent/migrate/schema.go b/internal/data/entity/ent/migrate/schema.go index 1235a0f9..72607f7e 100644 --- a/internal/data/entity/ent/migrate/schema.go +++ b/internal/data/entity/ent/migrate/schema.go @@ -420,7 +420,6 @@ var ( {Name: "salt", Type: field.TypeString, Size: 64, Comment: "entity.user.field.salt", Default: ""}, {Name: "phone", Type: field.TypeString, Size: 32, Comment: "entity.user.field.phone", Default: ""}, {Name: "email", Type: field.TypeString, Size: 64, Comment: "entity.user.field.email", Default: ""}, - {Name: "i18n", Type: field.TypeString, Size: 64, Comment: "entity.user.field.i18n", Default: ""}, {Name: "department", Type: field.TypeString, Size: 64, Comment: "entity.user.field.department", Default: ""}, {Name: "remark", Type: field.TypeString, Size: 1024, Comment: "entity.user.field.remark", Default: ""}, {Name: "token", Type: field.TypeString, Size: 512, Comment: "entity.user.field.token", Default: ""}, @@ -477,7 +476,7 @@ var ( { Name: "user_status", Unique: false, - Columns: []*schema.Column{SysUsersColumns[21]}, + Columns: []*schema.Column{SysUsersColumns[20]}, }, }, } diff --git a/internal/data/entity/ent/mutation.go b/internal/data/entity/ent/mutation.go index d5bfb565..e34353e8 100644 --- a/internal/data/entity/ent/mutation.go +++ b/internal/data/entity/ent/mutation.go @@ -9881,7 +9881,6 @@ type UserMutation struct { salt *string phone *string email *string - i18n *string department *string remark *string token *string @@ -10678,42 +10677,6 @@ func (m *UserMutation) ResetEmail() { m.email = nil } -// SetI18n sets the "i18n" field. -func (m *UserMutation) SetI18n(s string) { - m.i18n = &s -} - -// I18n returns the value of the "i18n" field in the mutation. -func (m *UserMutation) I18n() (r string, exists bool) { - v := m.i18n - if v == nil { - return - } - return *v, true -} - -// OldI18n returns the old "i18n" field's value of the User entity. -// If the User object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *UserMutation) OldI18n(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldI18n is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldI18n requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldI18n: %w", err) - } - return oldValue.I18n, nil -} - -// ResetI18n resets all changes to the "i18n" field. -func (m *UserMutation) ResetI18n() { - m.i18n = nil -} - // SetDepartment sets the "department" field. func (m *UserMutation) SetDepartment(s string) { m.department = &s @@ -11465,7 +11428,7 @@ func (m *UserMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *UserMutation) Fields() []string { - fields := make([]string, 0, 27) + fields := make([]string, 0, 26) if m.create_author != nil { fields = append(fields, user.FieldCreateAuthor) } @@ -11514,9 +11477,6 @@ func (m *UserMutation) Fields() []string { if m.email != nil { fields = append(fields, user.FieldEmail) } - if m.i18n != nil { - fields = append(fields, user.FieldI18n) - } if m.department != nil { fields = append(fields, user.FieldDepartment) } @@ -11587,8 +11547,6 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) { return m.Phone() case user.FieldEmail: return m.Email() - case user.FieldI18n: - return m.I18n() case user.FieldDepartment: return m.Department() case user.FieldRemark: @@ -11650,8 +11608,6 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er return m.OldPhone(ctx) case user.FieldEmail: return m.OldEmail(ctx) - case user.FieldI18n: - return m.OldI18n(ctx) case user.FieldDepartment: return m.OldDepartment(ctx) case user.FieldRemark: @@ -11793,13 +11749,6 @@ func (m *UserMutation) SetField(name string, value ent.Value) error { } m.SetEmail(v) return nil - case user.FieldI18n: - v, ok := value.(string) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetI18n(v) - return nil case user.FieldDepartment: v, ok := value.(string) if !ok { @@ -12033,9 +11982,6 @@ func (m *UserMutation) ResetField(name string) error { case user.FieldEmail: m.ResetEmail() return nil - case user.FieldI18n: - m.ResetI18n() - return nil case user.FieldDepartment: m.ResetDepartment() return nil diff --git a/internal/data/entity/ent/mutation_fields.go b/internal/data/entity/ent/mutation_fields.go index d89d0326..fac230e8 100644 --- a/internal/data/entity/ent/mutation_fields.go +++ b/internal/data/entity/ent/mutation_fields.go @@ -873,8 +873,6 @@ func (m *UserMutation) SetFields(input *User, fields ...string) error { m.SetPhone(input.Phone) case user.FieldEmail: m.SetEmail(input.Email) - case user.FieldI18n: - m.SetI18n(input.I18n) case user.FieldDepartment: m.SetDepartment(input.Department) case user.FieldRemark: @@ -990,11 +988,6 @@ func (m *UserMutation) SetFieldsSkipZero(input *User, fields ...string) error { if input.Email != "" { m.SetEmail(input.Email) } - case user.FieldI18n: - // check string with sql.NullString if it is empty - if input.I18n != "" { - m.SetI18n(input.I18n) - } case user.FieldDepartment: // check string with sql.NullString if it is empty if input.Department != "" { diff --git a/internal/data/entity/ent/runtime/runtime.go b/internal/data/entity/ent/runtime/runtime.go index 5182bbee..56f7ab7d 100644 --- a/internal/data/entity/ent/runtime/runtime.go +++ b/internal/data/entity/ent/runtime/runtime.go @@ -544,56 +544,50 @@ func init() { user.DefaultEmail = userDescEmail.Default.(string) // user.EmailValidator is a validator for the "email" field. It is called by the builders before save. user.EmailValidator = userDescEmail.Validators[0].(func(string) error) - // userDescI18n is the schema descriptor for i18n field. - userDescI18n := userFields[11].Descriptor() - // user.DefaultI18n holds the default value on creation for the i18n field. - user.DefaultI18n = userDescI18n.Default.(string) - // user.I18nValidator is a validator for the "i18n" field. It is called by the builders before save. - user.I18nValidator = userDescI18n.Validators[0].(func(string) error) // userDescDepartment is the schema descriptor for department field. - userDescDepartment := userFields[12].Descriptor() + userDescDepartment := userFields[11].Descriptor() // user.DefaultDepartment holds the default value on creation for the department field. user.DefaultDepartment = userDescDepartment.Default.(string) // user.DepartmentValidator is a validator for the "department" field. It is called by the builders before save. user.DepartmentValidator = userDescDepartment.Validators[0].(func(string) error) // userDescRemark is the schema descriptor for remark field. - userDescRemark := userFields[13].Descriptor() + userDescRemark := userFields[12].Descriptor() // user.DefaultRemark holds the default value on creation for the remark field. user.DefaultRemark = userDescRemark.Default.(string) // user.RemarkValidator is a validator for the "remark" field. It is called by the builders before save. user.RemarkValidator = userDescRemark.Validators[0].(func(string) error) // userDescToken is the schema descriptor for token field. - userDescToken := userFields[14].Descriptor() + userDescToken := userFields[13].Descriptor() // user.DefaultToken holds the default value on creation for the token field. user.DefaultToken = userDescToken.Default.(string) // user.TokenValidator is a validator for the "token" field. It is called by the builders before save. user.TokenValidator = userDescToken.Validators[0].(func(string) error) // userDescStatus is the schema descriptor for status field. - userDescStatus := userFields[15].Descriptor() + userDescStatus := userFields[14].Descriptor() // user.DefaultStatus holds the default value on creation for the status field. user.DefaultStatus = enums.Status(userDescStatus.Default.(int8)) // userDescIsSystem is the schema descriptor for is_system field. - userDescIsSystem := userFields[16].Descriptor() + userDescIsSystem := userFields[15].Descriptor() // user.DefaultIsSystem holds the default value on creation for the is_system field. user.DefaultIsSystem = userDescIsSystem.Default.(bool) // userDescLastLoginIP is the schema descriptor for last_login_ip field. - userDescLastLoginIP := userFields[17].Descriptor() + userDescLastLoginIP := userFields[16].Descriptor() // user.DefaultLastLoginIP holds the default value on creation for the last_login_ip field. user.DefaultLastLoginIP = userDescLastLoginIP.Default.(string) // user.LastLoginIPValidator is a validator for the "last_login_ip" field. It is called by the builders before save. user.LastLoginIPValidator = userDescLastLoginIP.Validators[0].(func(string) error) // userDescLoginIP is the schema descriptor for login_ip field. - userDescLoginIP := userFields[18].Descriptor() + userDescLoginIP := userFields[17].Descriptor() // user.DefaultLoginIP holds the default value on creation for the login_ip field. user.DefaultLoginIP = userDescLoginIP.Default.(string) // user.LoginIPValidator is a validator for the "login_ip" field. It is called by the builders before save. user.LoginIPValidator = userDescLoginIP.Validators[0].(func(string) error) // userDescLastLoginTime is the schema descriptor for last_login_time field. - userDescLastLoginTime := userFields[19].Descriptor() + userDescLastLoginTime := userFields[18].Descriptor() // user.DefaultLastLoginTime holds the default value on creation for the last_login_time field. user.DefaultLastLoginTime = userDescLastLoginTime.Default.(func() time.Time) // userDescLoginTime is the schema descriptor for login_time field. - userDescLoginTime := userFields[20].Descriptor() + userDescLoginTime := userFields[19].Descriptor() // user.DefaultLoginTime holds the default value on creation for the login_time field. user.DefaultLoginTime = userDescLoginTime.Default.(func() time.Time) // userDescID is the schema descriptor for id field. diff --git a/internal/data/entity/ent/schema/user.go b/internal/data/entity/ent/schema/user.go index b68de363..dadd1f32 100644 --- a/internal/data/entity/ent/schema/user.go +++ b/internal/data/entity/ent/schema/user.go @@ -79,9 +79,6 @@ func (User) Fields() []ent.Field { MaxLen(64). Default(""). Comment(i18n.Text("entity.user.field.email")), // login email of user - field.String("i18n").MaxLen(64). - Default(""). - Comment("entity.user.field.i18n"), field.String("department"). MaxLen(64). Default(""). diff --git a/internal/data/entity/ent/user.go b/internal/data/entity/ent/user.go index 050fef8b..de7270ad 100644 --- a/internal/data/entity/ent/user.go +++ b/internal/data/entity/ent/user.go @@ -53,8 +53,6 @@ type User struct { Phone string `json:"phone,omitempty"` // entity.user.field.email Email string `json:"email,omitempty"` - // entity.user.field.i18n - I18n string `json:"i18n,omitempty"` // entity.user.field.department Department string `json:"department,omitempty"` // entity.user.field.remark @@ -163,7 +161,7 @@ func (*User) scanValues(columns []string) ([]any, error) { values[i] = new(sql.NullBool) case user.FieldID, user.FieldCreateAuthor, user.FieldUpdateAuthor, user.FieldStatus: values[i] = new(sql.NullInt64) - case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldEncryptedPassword, user.FieldSalt, user.FieldPhone, user.FieldEmail, user.FieldI18n, user.FieldDepartment, user.FieldRemark, user.FieldToken, user.FieldLastLoginIP, user.FieldLoginIP: + case user.FieldUUID, user.FieldAllowedIP, user.FieldUsername, user.FieldNickname, user.FieldAvatar, user.FieldName, user.FieldGender, user.FieldEncryptedPassword, user.FieldSalt, user.FieldPhone, user.FieldEmail, user.FieldDepartment, user.FieldRemark, user.FieldToken, user.FieldLastLoginIP, user.FieldLoginIP: values[i] = new(sql.NullString) case user.FieldCreateTime, user.FieldUpdateTime, user.FieldDeleteTime, user.FieldLastLoginTime, user.FieldLoginTime, user.FieldSanctionDate: values[i] = new(sql.NullTime) @@ -285,12 +283,6 @@ func (_m *User) assignValues(columns []string, values []any) error { } else if value.Valid { _m.Email = value.String } - case user.FieldI18n: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field i18n", values[i]) - } else if value.Valid { - _m.I18n = value.String - } case user.FieldDepartment: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field department", values[i]) @@ -467,9 +459,6 @@ func (_m *User) String() string { builder.WriteString("email=") builder.WriteString(_m.Email) builder.WriteString(", ") - builder.WriteString("i18n=") - builder.WriteString(_m.I18n) - builder.WriteString(", ") builder.WriteString("department=") builder.WriteString(_m.Department) builder.WriteString(", ") diff --git a/internal/data/entity/ent/user/user.go b/internal/data/entity/ent/user/user.go index 172866a3..65c8add1 100644 --- a/internal/data/entity/ent/user/user.go +++ b/internal/data/entity/ent/user/user.go @@ -49,8 +49,6 @@ const ( FieldPhone = "phone" // FieldEmail holds the string denoting the email field in the database. FieldEmail = "email" - // FieldI18n holds the string denoting the i18n field in the database. - FieldI18n = "i18n" // FieldDepartment holds the string denoting the department field in the database. FieldDepartment = "department" // FieldRemark holds the string denoting the remark field in the database. @@ -141,7 +139,6 @@ var Columns = []string{ FieldEncryptedPassword, FieldPhone, FieldEmail, - FieldI18n, FieldDepartment, FieldRemark, FieldToken, @@ -233,10 +230,6 @@ var ( DefaultEmail string // EmailValidator is a validator for the "email" field. It is called by the builders before save. EmailValidator func(string) error - // DefaultI18n holds the default value on creation for the "i18n" field. - DefaultI18n string - // I18nValidator is a validator for the "i18n" field. It is called by the builders before save. - I18nValidator func(string) error // DefaultDepartment holds the default value on creation for the "department" field. DefaultDepartment string // DepartmentValidator is a validator for the "department" field. It is called by the builders before save. @@ -386,11 +379,6 @@ func ByEmail(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldEmail, opts...).ToFunc() } -// ByI18n orders the results by the i18n field. -func ByI18n(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldI18n, opts...).ToFunc() -} - // ByDepartment orders the results by the department field. func ByDepartment(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDepartment, opts...).ToFunc() diff --git a/internal/data/entity/ent/user/where.go b/internal/data/entity/ent/user/where.go index f8ab5d8b..c87f8fb3 100644 --- a/internal/data/entity/ent/user/where.go +++ b/internal/data/entity/ent/user/where.go @@ -131,11 +131,6 @@ func Email(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldEmail, v)) } -// I18n applies equality check predicate on the "i18n" field. It's identical to I18nEQ. -func I18n(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldI18n, v)) -} - // Department applies equality check predicate on the "department" field. It's identical to DepartmentEQ. func Department(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldDepartment, v)) @@ -1087,71 +1082,6 @@ func EmailContainsFold(v string) predicate.User { return predicate.User(sql.FieldContainsFold(FieldEmail, v)) } -// I18nEQ applies the EQ predicate on the "i18n" field. -func I18nEQ(v string) predicate.User { - return predicate.User(sql.FieldEQ(FieldI18n, v)) -} - -// I18nNEQ applies the NEQ predicate on the "i18n" field. -func I18nNEQ(v string) predicate.User { - return predicate.User(sql.FieldNEQ(FieldI18n, v)) -} - -// I18nIn applies the In predicate on the "i18n" field. -func I18nIn(vs ...string) predicate.User { - return predicate.User(sql.FieldIn(FieldI18n, vs...)) -} - -// I18nNotIn applies the NotIn predicate on the "i18n" field. -func I18nNotIn(vs ...string) predicate.User { - return predicate.User(sql.FieldNotIn(FieldI18n, vs...)) -} - -// I18nGT applies the GT predicate on the "i18n" field. -func I18nGT(v string) predicate.User { - return predicate.User(sql.FieldGT(FieldI18n, v)) -} - -// I18nGTE applies the GTE predicate on the "i18n" field. -func I18nGTE(v string) predicate.User { - return predicate.User(sql.FieldGTE(FieldI18n, v)) -} - -// I18nLT applies the LT predicate on the "i18n" field. -func I18nLT(v string) predicate.User { - return predicate.User(sql.FieldLT(FieldI18n, v)) -} - -// I18nLTE applies the LTE predicate on the "i18n" field. -func I18nLTE(v string) predicate.User { - return predicate.User(sql.FieldLTE(FieldI18n, v)) -} - -// I18nContains applies the Contains predicate on the "i18n" field. -func I18nContains(v string) predicate.User { - return predicate.User(sql.FieldContains(FieldI18n, v)) -} - -// I18nHasPrefix applies the HasPrefix predicate on the "i18n" field. -func I18nHasPrefix(v string) predicate.User { - return predicate.User(sql.FieldHasPrefix(FieldI18n, v)) -} - -// I18nHasSuffix applies the HasSuffix predicate on the "i18n" field. -func I18nHasSuffix(v string) predicate.User { - return predicate.User(sql.FieldHasSuffix(FieldI18n, v)) -} - -// I18nEqualFold applies the EqualFold predicate on the "i18n" field. -func I18nEqualFold(v string) predicate.User { - return predicate.User(sql.FieldEqualFold(FieldI18n, v)) -} - -// I18nContainsFold applies the ContainsFold predicate on the "i18n" field. -func I18nContainsFold(v string) predicate.User { - return predicate.User(sql.FieldContainsFold(FieldI18n, v)) -} - // DepartmentEQ applies the EQ predicate on the "department" field. func DepartmentEQ(v string) predicate.User { return predicate.User(sql.FieldEQ(FieldDepartment, v)) diff --git a/internal/data/entity/ent/user_create.go b/internal/data/entity/ent/user_create.go index f2f1f27d..6f2c345f 100644 --- a/internal/data/entity/ent/user_create.go +++ b/internal/data/entity/ent/user_create.go @@ -235,20 +235,6 @@ func (_c *UserCreate) SetNillableEmail(v *string) *UserCreate { return _c } -// SetI18n sets the "i18n" field. -func (_c *UserCreate) SetI18n(v string) *UserCreate { - _c.mutation.SetI18n(v) - return _c -} - -// SetNillableI18n sets the "i18n" field if the given value is not nil. -func (_c *UserCreate) SetNillableI18n(v *string) *UserCreate { - if v != nil { - _c.SetI18n(*v) - } - return _c -} - // SetDepartment sets the "department" field. func (_c *UserCreate) SetDepartment(v string) *UserCreate { _c.mutation.SetDepartment(v) @@ -588,10 +574,6 @@ func (_c *UserCreate) defaults() error { v := user.DefaultEmail _c.mutation.SetEmail(v) } - if _, ok := _c.mutation.I18n(); !ok { - v := user.DefaultI18n - _c.mutation.SetI18n(v) - } if _, ok := _c.mutation.Department(); !ok { v := user.DefaultDepartment _c.mutation.SetDepartment(v) @@ -735,14 +717,6 @@ func (_c *UserCreate) check() error { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} } } - if _, ok := _c.mutation.I18n(); !ok { - return &ValidationError{Name: "i18n", err: errors.New(`ent: missing required field "User.i18n"`)} - } - if v, ok := _c.mutation.I18n(); ok { - if err := user.I18nValidator(v); err != nil { - return &ValidationError{Name: "i18n", err: fmt.Errorf(`ent: validator failed for field "User.i18n": %w`, err)} - } - } if _, ok := _c.mutation.Department(); !ok { return &ValidationError{Name: "department", err: errors.New(`ent: missing required field "User.department"`)} } @@ -896,10 +870,6 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { _spec.SetField(user.FieldEmail, field.TypeString, value) _node.Email = value } - if value, ok := _c.mutation.I18n(); ok { - _spec.SetField(user.FieldI18n, field.TypeString, value) - _node.I18n = value - } if value, ok := _c.mutation.Department(); ok { _spec.SetField(user.FieldDepartment, field.TypeString, value) _node.Department = value diff --git a/internal/data/entity/ent/user_query.go b/internal/data/entity/ent/user_query.go index 2f2daf7b..fc94cb45 100644 --- a/internal/data/entity/ent/user_query.go +++ b/internal/data/entity/ent/user_query.go @@ -1043,7 +1043,6 @@ func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // Salt string `json:"salt,omitempty"` // Phone string `json:"phone,omitempty"` // Email string `json:"email,omitempty"` -// I18n string `json:"i18n,omitempty"` // Department string `json:"department,omitempty"` // Remark string `json:"remark,omitempty"` // Token string `json:"token,omitempty"` @@ -1074,7 +1073,6 @@ func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { // user.FieldSalt, // user.FieldPhone, // user.FieldEmail, -// user.FieldI18n, // user.FieldDepartment, // user.FieldRemark, // user.FieldToken, diff --git a/internal/data/entity/ent/user_update.go b/internal/data/entity/ent/user_update.go index ce478c3b..09795a1c 100644 --- a/internal/data/entity/ent/user_update.go +++ b/internal/data/entity/ent/user_update.go @@ -270,20 +270,6 @@ func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate { return _u } -// SetI18n sets the "i18n" field. -func (_u *UserUpdate) SetI18n(v string) *UserUpdate { - _u.mutation.SetI18n(v) - return _u -} - -// SetNillableI18n sets the "i18n" field if the given value is not nil. -func (_u *UserUpdate) SetNillableI18n(v *string) *UserUpdate { - if v != nil { - _u.SetI18n(*v) - } - return _u -} - // SetDepartment sets the "department" field. func (_u *UserUpdate) SetDepartment(v string) *UserUpdate { _u.mutation.SetDepartment(v) @@ -752,11 +738,6 @@ func (_u *UserUpdate) check() error { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} } } - if v, ok := _u.mutation.I18n(); ok { - if err := user.I18nValidator(v); err != nil { - return &ValidationError{Name: "i18n", err: fmt.Errorf(`ent: validator failed for field "User.i18n": %w`, err)} - } - } if v, ok := _u.mutation.Department(); ok { if err := user.DepartmentValidator(v); err != nil { return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} @@ -863,9 +844,6 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) { if value, ok := _u.mutation.Email(); ok { _spec.SetField(user.FieldEmail, field.TypeString, value) } - if value, ok := _u.mutation.I18n(); ok { - _spec.SetField(user.FieldI18n, field.TypeString, value) - } if value, ok := _u.mutation.Department(); ok { _spec.SetField(user.FieldDepartment, field.TypeString, value) } @@ -1428,20 +1406,6 @@ func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne { return _u } -// SetI18n sets the "i18n" field. -func (_u *UserUpdateOne) SetI18n(v string) *UserUpdateOne { - _u.mutation.SetI18n(v) - return _u -} - -// SetNillableI18n sets the "i18n" field if the given value is not nil. -func (_u *UserUpdateOne) SetNillableI18n(v *string) *UserUpdateOne { - if v != nil { - _u.SetI18n(*v) - } - return _u -} - // SetDepartment sets the "department" field. func (_u *UserUpdateOne) SetDepartment(v string) *UserUpdateOne { _u.mutation.SetDepartment(v) @@ -1923,11 +1887,6 @@ func (_u *UserUpdateOne) check() error { return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)} } } - if v, ok := _u.mutation.I18n(); ok { - if err := user.I18nValidator(v); err != nil { - return &ValidationError{Name: "i18n", err: fmt.Errorf(`ent: validator failed for field "User.i18n": %w`, err)} - } - } if v, ok := _u.mutation.Department(); ok { if err := user.DepartmentValidator(v); err != nil { return &ValidationError{Name: "department", err: fmt.Errorf(`ent: validator failed for field "User.department": %w`, err)} @@ -2051,9 +2010,6 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { if value, ok := _u.mutation.Email(); ok { _spec.SetField(user.FieldEmail, field.TypeString, value) } - if value, ok := _u.mutation.I18n(); ok { - _spec.SetField(user.FieldI18n, field.TypeString, value) - } if value, ok := _u.mutation.Department(); ok { _spec.SetField(user.FieldDepartment, field.TypeString, value) } diff --git a/internal/features/system/dto/schema_test.go b/internal/features/system/dto/schema_test.go index 71c9be62..a53588f7 100644 --- a/internal/features/system/dto/schema_test.go +++ b/internal/features/system/dto/schema_test.go @@ -35,7 +35,6 @@ func validateFields(t *testing.T, entStruct interface{}, protoStruct interface{} if field.PkgPath != "" || field.Anonymous { continue } - // Skip specific fields if isIgnored(field.Name, ignoreFields) { continue } @@ -49,9 +48,13 @@ func validateFields(t *testing.T, entStruct interface{}, protoStruct interface{} if field.PkgPath != "" || strings.HasPrefix(field.Name, "XXX_") { continue } + if isIgnored(field.Name, ignoreFields) { + continue + } protoFields[strings.ToLower(field.Name)] = field } + // Check 1: Ent -> Proto for name, entField := range entFields { // Special handling for ID field which might be named differently or handled by mixin if name == "id" { @@ -60,23 +63,33 @@ func validateFields(t *testing.T, entStruct interface{}, protoStruct interface{} } } - protoField, exists := protoFields[name] + _, exists := protoFields[name] if !exists { assert.Fail(t, fmt.Sprintf("[%s] Field mismatch: '%s' (%s) exists in Ent but missing in Proto", entType.Name(), entField.Name, entField.Type)) - continue + } + } + + // Check 2: Proto -> Ent + for name, protoField := range protoFields { + // Special handling for ID field + if name == "id" { + if _, ok := entFields["id"]; ok { + continue + } } - // Optional: Check for type compatibility if needed. - // Note: Ent types (e.g. int8) might differ from Proto types (e.g. int32), so strict equality check might fail. - // We can add loose type checking here if required. - _ = protoField + _, exists := entFields[name] + if !exists { + assert.Fail(t, fmt.Sprintf("[%s] Field mismatch: '%s' (%s) exists in Proto but missing in Ent", + protoType.Name(), protoField.Name, protoField.Type)) + } } } func isIgnored(fieldName string, ignoreList []string) bool { for _, ignored := range ignoreList { - if fieldName == ignored { + if strings.EqualFold(fieldName, ignored) { return true } } @@ -84,25 +97,34 @@ func isIgnored(fieldName string, ignoreList []string) bool { } func TestSchemaProtoConsistency(t *testing.T) { - // Common fields to ignore in Ent entities that are not expected in Proto + // Common fields to ignore in both Ent and Proto commonIgnores := []string{ "Edges", "config", + "DeleteTime", + "XXX_NoUnkeyedLiteral", + "XXX_unrecognized", + "XXX_sizecache", } t.Run("User", func(t *testing.T) { - validateFields(t, &ent.User{}, &types.User{}, append(commonIgnores, "EncryptedPassword", "Salt", "Token", "IsSystem", "DeleteTime")) + specificIgnores := append(commonIgnores, "EncryptedPassword", "Salt", "Token", "IsSystem", "RoleIds", "Roles") + validateFields(t, &ent.User{}, &types.User{}, specificIgnores) }) t.Run("Role", func(t *testing.T) { - validateFields(t, &ent.Role{}, &types.Role{}, commonIgnores) + specificIgnores := append(commonIgnores, "views", "users", "resources", "ResourceIds", "permissions", + "PermissionIds") + validateFields(t, &ent.Role{}, &types.Role{}, specificIgnores) }) t.Run("Resource", func(t *testing.T) { - validateFields(t, &ent.Resource{}, &types.Resource{}, commonIgnores) + specificIgnores := append(commonIgnores, "VersionID", "LastSyncVersionID", "children", "parent", "PermissionIds", "permissions") + validateFields(t, &ent.Resource{}, &types.Resource{}, specificIgnores) }) t.Run("View", func(t *testing.T) { - validateFields(t, &ent.View{}, &types.View{}, commonIgnores) + specificIgnores := append(commonIgnores, "children", "parent", "resources", "roles") + validateFields(t, &ent.View{}, &types.View{}, specificIgnores) }) } diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index ef97a28b..5087bb43 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -3186,19 +3186,10 @@ components: method: type: string description: resource.field.method - component: - type: string - description: resource.field.component - icon: - type: string - description: resource.field.icon sequence: type: integer description: resource.field.sequence format: int32 - visible: - type: boolean - description: resource.field.visible tree_path: type: string description: resource.field.tree_path @@ -3279,9 +3270,6 @@ components: type: integer description: role.field.status format: int32 - is_types: - type: boolean - description: role.field.is_types views: type: array items: @@ -3440,9 +3428,6 @@ components: type: type: string description: Type holds the value of the "type" field. - comment: - type: string - description: Comment holds the value of the "comment" field. icon: type: string description: Icon holds the value of the "icon" field. @@ -3465,9 +3450,6 @@ components: parent_id: type: string description: ParentID holds the value of the "parent_id" field. - parent_path: - type: string - description: ParentPath holds the value of the "parent_path" field. component: type: string description: Component holds the value of the "component" field. From 3e86f13557ed185bdf03cf13e4013b21beeffd71 Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 8 Jan 2026 02:26:18 +0800 Subject: [PATCH 157/158] feat(resource): add sorting support to resource list API and update pagination helper --- ...dmin_application_admin_cmd_gateway.run.xml | 10 +++++++++ api/v1/proto/system/resource.proto | 3 ++- api/v1/services/system/resource.pb.go | 13 ++++++++++-- internal/helpers/repo/limiter.go | 21 +++++++++++++++++++ internal/helpers/repo/options.go | 9 ++++++++ resources/api-docs/openapi/openapi.yaml | 6 ++++++ 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 .run/go build origadmin_application_admin_cmd_gateway.run.xml create mode 100644 internal/helpers/repo/limiter.go diff --git a/.run/go build origadmin_application_admin_cmd_gateway.run.xml b/.run/go build origadmin_application_admin_cmd_gateway.run.xml new file mode 100644 index 00000000..80442089 --- /dev/null +++ b/.run/go build origadmin_application_admin_cmd_gateway.run.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/api/v1/proto/system/resource.proto b/api/v1/proto/system/resource.proto index babebc36..8769c3a7 100644 --- a/api/v1/proto/system/resource.proto +++ b/api/v1/proto/system/resource.proto @@ -5,8 +5,8 @@ package api.v1.services.system; import "google/api/annotations.proto"; import "google/protobuf/any.proto"; import "google/protobuf/empty.proto"; -import "types/system.proto"; import "policy/v1/policy.proto"; +import "types/system.proto"; option go_package = "origadmin/application/admin/api/v1/services/system;system"; option java_multiple_files = true; @@ -65,6 +65,7 @@ message ListResourcesRequest { string service_name = 8 [json_name = "service_name"]; string sync_status = 9 [json_name = "sync_status"]; string operation = 10 [json_name = "operation"]; + repeated string sorting = 11 [json_name = "sorting"]; } // Response message for ResourceService.ListResources. diff --git a/api/v1/services/system/resource.pb.go b/api/v1/services/system/resource.pb.go index 517bfd09..a0b7b85f 100644 --- a/api/v1/services/system/resource.pb.go +++ b/api/v1/services/system/resource.pb.go @@ -39,6 +39,7 @@ type ListResourcesRequest struct { ServiceName string `protobuf:"bytes,8,opt,name=service_name,proto3" json:"service_name,omitempty"` SyncStatus string `protobuf:"bytes,9,opt,name=sync_status,proto3" json:"sync_status,omitempty"` Operation string `protobuf:"bytes,10,opt,name=operation,proto3" json:"operation,omitempty"` + Sorting []string `protobuf:"bytes,11,rep,name=sorting,proto3" json:"sorting,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -143,6 +144,13 @@ func (x *ListResourcesRequest) GetOperation() string { return "" } +func (x *ListResourcesRequest) GetSorting() []string { + if x != nil { + return x.Sorting + } + return nil +} + // Response message for ResourceService.ListResources. type ListResourcesResponse struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -608,7 +616,7 @@ var File_system_resource_proto protoreflect.FileDescriptor const file_system_resource_proto_rawDesc = "" + "\n" + - "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x12types/system.proto\x1a\x16policy/v1/policy.proto\"\xb4\x02\n" + + "\x15system/resource.proto\x12\x16api.v1.services.system\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/protobuf/any.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x16policy/v1/policy.proto\x1a\x12types/system.proto\"\xce\x02\n" + "\x14ListResourcesRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04page\x18\x02 \x01(\x05R\x04page\x12\x1c\n" + @@ -624,7 +632,8 @@ const file_system_resource_proto_rawDesc = "" + "\fservice_name\x18\b \x01(\tR\fservice_name\x12 \n" + "\vsync_status\x18\t \x01(\tR\vsync_status\x12\x1c\n" + "\toperation\x18\n" + - " \x01(\tR\toperation\"\x83\x02\n" + + " \x01(\tR\toperation\x12\x18\n" + + "\asorting\x18\v \x03(\tR\asorting\"\x83\x02\n" + "\x15ListResourcesResponse\x12\x14\n" + "\x05total\x18\x01 \x01(\x05R\x05total\x12=\n" + "\tresources\x18\x02 \x03(\v2\x1f.api.v1.services.types.ResourceR\tresources\x12\x12\n" + diff --git a/internal/helpers/repo/limiter.go b/internal/helpers/repo/limiter.go new file mode 100644 index 00000000..6e8a9823 --- /dev/null +++ b/internal/helpers/repo/limiter.go @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 OrigAdmin. All rights reserved. + */ + +package repo + +// PageLimiter is a limiter for pagination. +type PageLimiter struct { + DefaultPageSize int + MaxPageSize int + HardLimit int +} + +// DefaultLimiter returns a default PageLimiter. +func DefaultLimiter() PageLimiter { + return PageLimiter{ + DefaultPageSize: DefaultPageSize, + MaxPageSize: MaxPageSize, + HardLimit: HardLimit, + } +} diff --git a/internal/helpers/repo/options.go b/internal/helpers/repo/options.go index 866f705a..5c296084 100644 --- a/internal/helpers/repo/options.go +++ b/internal/helpers/repo/options.go @@ -46,6 +46,11 @@ type KeywordRequest interface { GetKeyword() string } +// SortingRequest defines the contract for any request that supports sorting +type SortingRequest interface { + GetSorting() []string +} + // QueryOption holds common query options like pagination and ordering. // It is intended to be embedded in more specific query option structs. type QueryOption struct { @@ -85,6 +90,10 @@ func QueryOptionFromRequest(req interface{}) QueryOption { opt.Keyword = r.GetKeyword() } + if r, ok := req.(SortingRequest); ok { + opt.OrderBy = r.GetSorting() + } + // This is a generic helper. The ReadMask should be populated from the specific // request type in the service layer, as the field name (`read_mask`) can vary. // Example in service layer: diff --git a/resources/api-docs/openapi/openapi.yaml b/resources/api-docs/openapi/openapi.yaml index 5087bb43..0348bc56 100644 --- a/resources/api-docs/openapi/openapi.yaml +++ b/resources/api-docs/openapi/openapi.yaml @@ -1252,6 +1252,12 @@ paths: in: query schema: type: string + - name: sorting + in: query + schema: + type: array + items: + type: string responses: "200": description: OK From e699acb6fc626874fabf46c1eaf9f21d0c683bbc Mon Sep 17 00:00:00 2001 From: godcong Date: Thu, 8 Jan 2026 18:25:53 +0800 Subject: [PATCH 158/158] feat(resources): restructure resource creation with hierarchical module-service-api model and improved policy handling --- internal/features/system/dal/resource.go | 81 ++++++---- internal/features/system/dto/resource.go | 12 +- internal/tasks/seeder/seeder.go | 182 +++++++++++++++++------ 3 files changed, 196 insertions(+), 79 deletions(-) diff --git a/internal/features/system/dal/resource.go b/internal/features/system/dal/resource.go index 593b5bb4..0741acf8 100644 --- a/internal/features/system/dal/resource.go +++ b/internal/features/system/dal/resource.go @@ -69,43 +69,68 @@ func (r *resourceRepo) Create(ctx context.Context, res *types.Resource, opts ... } func (r *resourceRepo) CreateFromPolicy(ctx context.Context, input *dto.ResourceFromPolicyInput) (*types.Resource, error) { - policy := input.Policy - - // Extract method and path from GatewayPath, e.g., "GET:/api/v1/users/{id}" - var method, path string - if policy.GatewayPath != "" { - if parts := strings.SplitN(policy.GatewayPath, ":", 2); len(parts) == 2 { - method = parts[0] - path = parts[1] - } + create := r.db.Resource(ctx).Create(). + SetKeyword(input.Resource.Keyword). + SetSequence(int(input.Resource.Sequence)) + + // Set Type if provided + if input.Resource.Type != "" { + create.SetType(input.Resource.Type) } - // Ensure path has the correct prefix - if path != "" && !strings.HasPrefix(path, conf.APIPrefix) { - path = conf.APIPrefix + path + // Set TreePath if provided + if input.Resource.TreePath != "" { + create.SetTreePath(input.Resource.TreePath) } - create := r.db.Resource(ctx).Create(). - SetKeyword(input.Keyword). - SetPath(path). - SetMethod(method). - SetOperation(policy.ServiceMethod). - SetPolicy(policy.Name). - SetVersionID(policy.VersionID). - SetLastSyncVersionID(policy.VersionID). - SetSyncStatus("Synced"). - SetSequence(input.Sequence) + // Set ParentID if provided + if input.Resource.ParentId != 0 { + create.SetParentID(input.Resource.ParentId) + } + + // Set Name, I18n, ServiceName if provided + if input.Resource.Name != "" { + create.SetName(input.Resource.Name) + } - if input.DisplayName != "" { - create.SetName(input.DisplayName) + if input.Resource.I18N != "" { + create.SetI18n(input.Resource.I18N) } - if input.I18n != "" { - create.SetI18n(input.I18n) + if input.Resource.ServiceName != "" { + create.SetServiceName(input.Resource.ServiceName) } - if input.ServiceName != "" { - create.SetServiceName(input.ServiceName) + // Only set policy-related fields if Policy is provided + if input.Policy != nil { + policy := input.Policy + + // Extract method and path from GatewayPath if not already provided + method := input.Resource.Method + path := input.Resource.Path + if policy.GatewayPath != "" && (method == "" || path == "") { + if parts := strings.SplitN(policy.GatewayPath, ":", 2); len(parts) == 2 { + if method == "" { + method = parts[0] + } + if path == "" { + path = parts[1] + } + } + } + + // Ensure path has the correct prefix + if path != "" && !strings.HasPrefix(path, conf.APIPrefix) { + path = conf.APIPrefix + path + } + + create.SetPath(path). + SetMethod(method). + SetOperation(policy.ServiceMethod). + SetPolicy(policy.Name). + SetVersionID(policy.VersionID). + SetLastSyncVersionID(policy.VersionID). + SetSyncStatus("Synced") } saved, err := create.Save(ctx) diff --git a/internal/features/system/dto/resource.go b/internal/features/system/dto/resource.go index 1f732df9..1bc4544c 100644 --- a/internal/features/system/dto/resource.go +++ b/internal/features/system/dto/resource.go @@ -26,12 +26,8 @@ type ResourceRepo interface { // ResourceFromPolicyInput contains the data needed to create a resource from a policy. type ResourceFromPolicyInput struct { - Policy *security.Policy - DisplayName string - I18n string - Sequence int - Keyword string - ServiceName string + Policy *security.Policy + types.Resource } // ResourceQueryOption specifies options for querying resources. @@ -39,6 +35,7 @@ type ResourceQueryOption struct { repo.QueryOption Operation string WithPermissions bool + CreationMethod string } // ResourceCreateOption specifies options for creating a resource. @@ -57,8 +54,7 @@ func ListResourcesRequestToQueryOption(req *system.ListResourcesRequest) *Resour } return &ResourceQueryOption{ QueryOption: repo.QueryOptionFromRequest(req), - //WithPermissions: req.WithPermissions, - Operation: req.Operation, + Operation: req.Operation, } } diff --git a/internal/tasks/seeder/seeder.go b/internal/tasks/seeder/seeder.go index c1cc65e0..140d8f1b 100644 --- a/internal/tasks/seeder/seeder.go +++ b/internal/tasks/seeder/seeder.go @@ -131,8 +131,10 @@ func (s *Seeder) createRootUser() error { func (s *Seeder) createInitialResources() error { ctx := context.Background() - // Use a counter for sequence - seq := 1 + + // Collect resources by module:service + moduleResources := make(map[string]map[string][]*security.Policy) + for _, policy := range security.RegisteredPolicies() { // Parse gRPC method: /package.Service/Method // e.g. /api.v1.services.auth.AuthService/Login @@ -141,9 +143,8 @@ func (s *Seeder) createInitialResources() error { s.log.Warnf("Skipping malformed service method: %s", policy.ServiceMethod) continue } - // parts[0] is empty, parts[1] is package.Service, parts[2] is Method + fullService := parts[1] - method := parts[2] // Parse Service: api.v1.services.auth.AuthService serviceParts := strings.Split(fullService, ".") @@ -153,66 +154,161 @@ func (s *Seeder) createInitialResources() error { } // Extract Module Name (e.g. "auth" from "api.v1.services.auth.AuthService") - // Assuming standard structure: ...services.. var moduleName string if len(serviceParts) >= 2 { - // Take the second to last part as module name moduleName = serviceParts[len(serviceParts)-2] } else { - moduleName = "system" // Fallback + moduleName = "system" } // Extract Resource Name (e.g. "Auth" from "AuthService") serviceName := serviceParts[len(serviceParts)-1] - resourceName := strings.TrimSuffix(serviceName, "Service") - // Construct Keyword: module:resource:method (e.g. auth:auth:login) - // Use toSnakeCase for resourceName and method to ensure consistency - keyword := strings.Join([]string{strings.ToLower(moduleName), toSnakeCase(resourceName), toSnakeCase(method)}, ":") - - // Construct Name: Resource Method (e.g. Auth Login) - // Convert CamelCase to Title Case with spaces - displayName := toTitleCase(resourceName) + " " + toTitleCase(method) + // Ensure module and service collections exist + if moduleResources[moduleName] == nil { + moduleResources[moduleName] = make(map[string][]*security.Policy) + } + if moduleResources[moduleName][serviceName] == nil { + moduleResources[moduleName][serviceName] = []*security.Policy{} + } - // Construct I18n: resource.module.resource.method (e.g. resource.auth.auth.login) - i18nKey := "resource." + strings.ToLower(moduleName) + "." + toSnakeCase(resourceName) + "." + toSnakeCase(method) + moduleResources[moduleName][serviceName] = append(moduleResources[moduleName][serviceName], &policy) + } - // Ensure service name ends with "-service" - fullServiceName := moduleName - if !strings.HasSuffix(fullServiceName, "-service") { - fullServiceName += "-service" + // Create resources with 3-level structure: Module -> Service -> API + seq := 1 + for moduleName, services := range moduleResources { + // Create module level resource + moduleKeyword := toSnakeCase(moduleName) + moduleNameDisplay := toTitleCase(moduleName) + " Module" + moduleI18n := "resource." + moduleKeyword + ".module" + moduleTreePath := "/" + moduleKeyword + + moduleResource := &dto.ResourceFromPolicyInput{ + Resource: types.Resource{ + Name: moduleNameDisplay, + I18N: moduleI18n, + Sequence: int32(seq), + Keyword: moduleKeyword, + ServiceName: moduleName, + Type: "module", + TreePath: moduleTreePath, + }, + Policy: nil, // No policy for module } - // Check if resource already exists - _, count, err := s.resourceUseCase.ListResources(ctx, - &system.ListResourcesRequest{ - Operation: policy.ServiceMethod, - OnlyCount: true, - }) - if err == nil && count > 0 { - s.log.Infof("Resource '%s' already exists, skipping.", keyword) + moduleID, err := s.createOrUpdateResource(ctx, moduleResource, moduleKeyword, true) + if err != nil { + s.log.Errorf("failed to create module resource '%s': %v", moduleName, err) continue } + seq++ - input := &dto.ResourceFromPolicyInput{ - Policy: &policy, - DisplayName: displayName, - I18n: i18nKey, - Sequence: seq, - Keyword: keyword, - ServiceName: fullServiceName, + // Create service level resources + for serviceName, policies := range services { + resourceName := strings.TrimSuffix(serviceName, "Service") + serviceKeyword := strings.Join([]string{moduleKeyword, toSnakeCase(resourceName)}, ":") + serviceNameDisplay := toTitleCase(resourceName) + " Service" + serviceI18n := "resource." + serviceKeyword + ".service" + serviceTreePath := moduleTreePath + "/" + toSnakeCase(resourceName) + + serviceResource := &dto.ResourceFromPolicyInput{ + Resource: types.Resource{ + Name: serviceNameDisplay, + I18N: serviceI18n, + Sequence: int32(seq), + Keyword: serviceKeyword, + ServiceName: resourceName, + Type: "service", + TreePath: serviceTreePath, + ParentId: moduleID, + }, + Policy: nil, // No policy for service + } + + serviceID, err := s.createOrUpdateResource(ctx, serviceResource, serviceKeyword, false) + if err != nil { + s.log.Errorf("failed to create service resource '%s': %v", serviceName, err) + continue + } + seq++ + + // Create API level resources + for _, policy := range policies { + parts := strings.Split(policy.ServiceMethod, "/") + method := parts[2] + + apiKeyword := strings.Join([]string{moduleKeyword, toSnakeCase(resourceName), toSnakeCase(method)}, ":") + apiNameDisplay := toTitleCase(resourceName) + " " + toTitleCase(method) + apiI18n := "resource." + apiKeyword + ".api" + apiTreePath := serviceTreePath + "/" + toSnakeCase(method) + + // Extract method and path from GatewayPath + var httpMethod, path string + if policy.GatewayPath != "" { + if gatewayParts := strings.SplitN(policy.GatewayPath, ":", 2); len(gatewayParts) == 2 { + httpMethod = gatewayParts[0] + path = gatewayParts[1] + } + } + + apiResource := &dto.ResourceFromPolicyInput{ + Resource: types.Resource{ + Name: apiNameDisplay, + I18N: apiI18n, + Sequence: int32(seq), + Keyword: apiKeyword, + ServiceName: resourceName, + Type: "api", + TreePath: apiTreePath, + ParentId: serviceID, + Method: httpMethod, + Path: path, + }, + Policy: policy, + } + + _, err := s.createOrUpdateResource(ctx, apiResource, apiKeyword, false) + if err != nil { + s.log.Errorf("failed to create API resource from policy '%s': %v", policy.ServiceMethod, err) + } else { + s.log.Infof("Successfully created resource from policy: %s", policy.ServiceMethod) + } + seq++ + } } - - if _, err := s.resourceUseCase.CreateResourceFromPolicy(ctx, input); err != nil { - s.log.Errorf("failed to create resource from policy '%s': %v", policy.ServiceMethod, err) - } else { - s.log.Infof("Successfully created resource from policy: %s", policy.ServiceMethod) - } - seq++ } + return nil } +// createOrUpdateResource creates or updates a resource based on keyword +func (s *Seeder) createOrUpdateResource(ctx context.Context, input *dto.ResourceFromPolicyInput, keyword string, isModule bool) (int64, error) { + // Check if resource already exists + resources, count, err := s.resourceUseCase.ListResources(ctx, + &system.ListResourcesRequest{ + Keyword: keyword, + OnlyCount: false, + PageSize: 1, + }) + if err != nil && count == 0 { + s.log.Errorf("failed to check existing resource '%s': %v", keyword, err) + return 0, err + } + + if count > 0 && len(resources) > 0 { + s.log.Infof("Resource '%s' already exists, skipping.", keyword) + return resources[0].Id, nil + } + + created, err := s.resourceUseCase.CreateResourceFromPolicy(ctx, input) + if err != nil { + return 0, err + } + + return created.Id, nil +} + func (s *Seeder) createInitialViews() error { ctx := context.Background() views := []*types.View{